[magics] 01/31: Upstream, 2.18.7

Alastair McKinstry mckinstry at moszumanska.debian.org
Fri Jun 12 11:09:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch master
in repository magics.

commit 11f67e99d0a39e63550b33ac91e63b9533c265fd
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Sun Dec 23 00:38:02 2012 +0000

    Upstream, 2.18.7
---
 AUTHORS                                            |    31 +
 COPYING                                            |   201 +
 ChangeLog                                          |  3066 +++
 INSTALL                                            |   229 +
 LICENSE                                            |   201 +
 Makefile.am                                        |    82 +
 Makefile.in                                        |   946 +
 NEWS                                               |   141 +
 NOTICE                                             |   152 +
 README                                             |    49 +
 aclocal.m4                                         |  1374 ++
 apps/MagMLInterpretor/Makefile.am                  |    27 +
 apps/MagMLInterpretor/Makefile.in                  |   631 +
 apps/MagMLInterpretor/json.cc                      |    74 +
 apps/MagMLInterpretor/magml.cc                     |   118 +
 apps/Makefile.am                                   |     5 +
 apps/Makefile.in                                   |   642 +
 apps/metgram/10_days_epsgram.xml                   |   136 +
 apps/metgram/10_days_epsgram_a3.xml                |   128 +
 apps/metgram/10_days_metgram.xml                   |   161 +
 apps/metgram/10_days_wave_epsgram.xml              |   213 +
 apps/metgram/15_days_epsgram.xml                   |   161 +
 apps/metgram/15_days_epsgram_a3.xml                |   153 +
 apps/metgram/15_days_with_clim_epsgram.xml         |   223 +
 apps/metgram/Makefile.am                           |    43 +
 apps/metgram/Makefile.in                           |   722 +
 apps/metgram/classic_plumes.json                   |   298 +
 apps/metgram/efi_distribution.xml                  |   356 +
 apps/metgram/eps10.xml                             |     9 +
 apps/metgram/eps10_a3.xml                          |     9 +
 apps/metgram/eps15.xml                             |     8 +
 apps/metgram/eps15_a3.xml                          |    10 +
 apps/metgram/epsgram.template                      |   143 +
 apps/metgram/epswave.xml                           |     8 +
 apps/metgram/metgram                               |   389 +
 apps/metgram/metgram.template                      |   163 +
 apps/metgram/metgramx.cc                           |   251 +
 apps/metgram/new_efi_distribution.xml              |   142 +
 config/README                                      |     1 +
 config/config.guess                                |  1511 ++
 config/config.sub                                  |  1705 ++
 config/depcomp                                     |   630 +
 config/install-sh                                  |   520 +
 config/ltmain.sh                                   |  8406 +++++++
 config/missing                                     |   376 +
 config/py-compile                                  |   146 +
 configure                                          | 24632 +++++++++++++++++++
 configure.ac                                       |  1149 +
 docs/Magics.dox.in                                 |  1531 ++
 m4/autotroll.m4                                    |   563 +
 m4/autotroll.mk                                    |   108 +
 m4/ax_boost_base.m4                                |   258 +
 m4/libtool.m4                                      |  7356 ++++++
 m4/ltoptions.m4                                    |   368 +
 m4/ltsugar.m4                                      |   123 +
 m4/ltversion.m4                                    |    23 +
 m4/lt~obsolete.m4                                  |    92 +
 m4/magics.m4                                       |    38 +
 magics-config.in                                   |   308 +
 python/Magics/Magics.i                             |    66 +
 python/Magics/Magics_interface.cc                  |   217 +
 python/Magics/Makefile.am                          |    35 +
 python/Magics/Makefile.in                          |   525 +
 python/Magics/macro.py                             |   438 +
 python/Magics/metgram.py                           |   322 +
 python/Magics/numpy.i                              |  1634 ++
 python/Magics/setup.py.in                          |    82 +
 rpms/Magics.spec.in                                |   183 +
 rpms/Makefile.am                                   |    26 +
 rpms/Makefile.in                                   |   465 +
 .../magics/10m/10m_admin_0_boundary_lines_land.dbf |   Bin 0 -> 12752 bytes
 .../magics/10m/10m_admin_0_boundary_lines_land.prj |     1 +
 .../magics/10m/10m_admin_0_boundary_lines_land.shp |   Bin 0 -> 1195564 bytes
 .../magics/10m/10m_admin_0_boundary_lines_land.shx |   Bin 0 -> 2836 bytes
 .../10m/10m_admin_1_states_provinces_shp.dbf       |   Bin 0 -> 4553698 bytes
 .../10m/10m_admin_1_states_provinces_shp.prj       |     1 +
 .../10m/10m_admin_1_states_provinces_shp.shp       |   Bin 0 -> 15598952 bytes
 .../10m/10m_admin_1_states_provinces_shp.shx       |   Bin 0 -> 15644 bytes
 share/magics/10m/10m_lakes.dbf                     |   Bin 0 -> 540735 bytes
 share/magics/10m/10m_lakes.prj                     |     1 +
 share/magics/10m/10m_lakes.shp                     |   Bin 0 -> 1253556 bytes
 share/magics/10m/10m_lakes.shx                     |   Bin 0 -> 3452 bytes
 share/magics/10m/10m_land.dbf                      |   Bin 0 -> 1064577 bytes
 share/magics/10m/10m_land.prj                      |     1 +
 share/magics/10m/10m_land.shp                      |   Bin 0 -> 6248904 bytes
 share/magics/10m/10m_land.shx                      |   Bin 0 -> 16228 bytes
 share/magics/10m/10m_populated_places_simple.dbf   |   Bin 0 -> 32124176 bytes
 share/magics/10m/10m_populated_places_simple.prj   |     1 +
 share/magics/10m/10m_populated_places_simple.shp   |   Bin 0 -> 204752 bytes
 share/magics/10m/10m_populated_places_simple.shx   |   Bin 0 -> 58572 bytes
 share/magics/10m/10m_rivers_lake_centerlines.dbf   |   Bin 0 -> 163625 bytes
 share/magics/10m/10m_rivers_lake_centerlines.prj   |     1 +
 share/magics/10m/10m_rivers_lake_centerlines.shp   |   Bin 0 -> 1950380 bytes
 share/magics/10m/10m_rivers_lake_centerlines.shx   |   Bin 0 -> 3900 bytes
 .../10m_full/10m_admin_0_boundary_lines_land.dbf   |   Bin 0 -> 12752 bytes
 .../10m_full/10m_admin_0_boundary_lines_land.prj   |     1 +
 .../10m_full/10m_admin_0_boundary_lines_land.shp   |   Bin 0 -> 1195564 bytes
 .../10m_full/10m_admin_0_boundary_lines_land.shx   |   Bin 0 -> 2836 bytes
 .../10m_full/10m_admin_1_states_provinces_shp.dbf  |   Bin 0 -> 8354045 bytes
 .../10m_full/10m_admin_1_states_provinces_shp.prj  |     1 +
 .../10m_full/10m_admin_1_states_provinces_shp.shp  |   Bin 0 -> 19936848 bytes
 .../10m_full/10m_admin_1_states_provinces_shp.shx  |   Bin 0 -> 28620 bytes
 share/magics/10m_full/10m_lakes.dbf                |   Bin 0 -> 1724955 bytes
 share/magics/10m_full/10m_lakes.prj                |     1 +
 share/magics/10m_full/10m_lakes.shp                |   Bin 0 -> 2252300 bytes
 share/magics/10m_full/10m_lakes.shx                |   Bin 0 -> 10796 bytes
 share/magics/10m_full/10m_land.dbf                 |   Bin 0 -> 293905 bytes
 share/magics/10m_full/10m_land.prj                 |     1 +
 share/magics/10m_full/10m_land.shp                 |   Bin 0 -> 6945784 bytes
 share/magics/10m_full/10m_land.shx                 |   Bin 0 -> 31436 bytes
 .../10m_full/10m_rivers_lake_centerlines.dbf       |   Bin 0 -> 481138 bytes
 .../10m_full/10m_rivers_lake_centerlines.prj       |     1 +
 .../10m_full/10m_rivers_lake_centerlines.shp       |   Bin 0 -> 4130540 bytes
 .../10m_full/10m_rivers_lake_centerlines.shx       |   Bin 0 -> 11284 bytes
 .../110m/110m_admin_0_boundary_lines_land.dbf      |   Bin 0 -> 9168 bytes
 .../110m/110m_admin_0_boundary_lines_land.prj      |     1 +
 .../110m/110m_admin_0_boundary_lines_land.shp      |   Bin 0 -> 53188 bytes
 .../110m/110m_admin_0_boundary_lines_land.shx      |   Bin 0 -> 1364 bytes
 .../110m/110m_admin_1_states_provinces_shp.dbf     |   Bin 0 -> 102605 bytes
 .../110m/110m_admin_1_states_provinces_shp.prj     |     1 +
 .../110m/110m_admin_1_states_provinces_shp.shp     |   Bin 0 -> 39132 bytes
 .../110m/110m_admin_1_states_provinces_shp.shx     |   Bin 0 -> 508 bytes
 share/magics/110m/110m_lakes.dbf                   |   Bin 0 -> 19711 bytes
 share/magics/110m/110m_lakes.prj                   |     1 +
 share/magics/110m/110m_lakes.shp                   |   Bin 0 -> 9324 bytes
 share/magics/110m/110m_lakes.shx                   |   Bin 0 -> 300 bytes
 share/magics/110m/110m_land.dbf                    |   Bin 0 -> 3400 bytes
 share/magics/110m/110m_land.prj                    |     1 +
 share/magics/110m/110m_land.sbx                    |   Bin 0 -> 268 bytes
 share/magics/110m/110m_land.shp                    |   Bin 0 -> 89504 bytes
 share/magics/110m/110m_land.shp.xml                |     3 +
 share/magics/110m/110m_land.shx                    |   Bin 0 -> 1116 bytes
 share/magics/110m/110m_rivers_lake_centerlines.dbf |   Bin 0 -> 7876 bytes
 share/magics/110m/110m_rivers_lake_centerlines.prj |     1 +
 share/magics/110m/110m_rivers_lake_centerlines.shp |   Bin 0 -> 19268 bytes
 share/magics/110m/110m_rivers_lake_centerlines.shx |   Bin 0 -> 212 bytes
 .../magics/50m/50m_admin_0_boundary_lines_land.dbf |   Bin 0 -> 102853 bytes
 .../magics/50m/50m_admin_0_boundary_lines_land.prj |     1 +
 .../magics/50m/50m_admin_0_boundary_lines_land.shp |   Bin 0 -> 334300 bytes
 .../magics/50m/50m_admin_0_boundary_lines_land.shx |   Bin 0 -> 2924 bytes
 .../50m/50m_admin_1_states_provinces_shp.dbf       |   Bin 0 -> 36546 bytes
 .../50m/50m_admin_1_states_provinces_shp.prj       |     1 +
 .../50m/50m_admin_1_states_provinces_shp.shp       |   Bin 0 -> 409604 bytes
 .../50m/50m_admin_1_states_provinces_shp.shx       |   Bin 0 -> 612 bytes
 share/magics/50m/50m_lakes.dbf                     |   Bin 0 -> 410449 bytes
 share/magics/50m/50m_lakes.prj                     |     1 +
 share/magics/50m/50m_lakes.shp                     |   Bin 0 -> 330436 bytes
 share/magics/50m/50m_lakes.shx                     |   Bin 0 -> 3268 bytes
 share/magics/50m/50m_land.dbf                      |   Bin 0 -> 782582 bytes
 share/magics/50m/50m_land.prj                      |     1 +
 share/magics/50m/50m_land.shp                      |   Bin 0 -> 1050812 bytes
 share/magics/50m/50m_land.shx                      |   Bin 0 -> 11460 bytes
 share/magics/50m/50m_rivers_lake_centerlines.dbf   |   Bin 0 -> 154476 bytes
 share/magics/50m/50m_rivers_lake_centerlines.prj   |     1 +
 share/magics/50m/50m_rivers_lake_centerlines.shp   |   Bin 0 -> 433660 bytes
 .../magics/50m/50m_rivers_lake_centerlines.shp.xml |     3 +
 share/magics/50m/50m_rivers_lake_centerlines.shx   |   Bin 0 -> 3764 bytes
 share/magics/Fonts.dat                             |    29 +
 share/magics/ObstatGribVisDef.txt                  |  1083 +
 share/magics/PostScriptFonts.dat                   |    21 +
 share/magics/PostScriptMacro1.ps                   |    51 +
 share/magics/PostScriptMacro2.ps                   |    58 +
 share/magics/bufr_98.xml                           |   121 +
 share/magics/centre.xml                            |    21 +
 share/magics/ecmwf_logo.gif                        |   Bin 0 -> 1634 bytes
 share/magics/ecmwf_logo.png                        |   Bin 0 -> 1567 bytes
 share/magics/efi/Africa_All32parameters_0.js       |    25 +
 share/magics/efi/Africa_All32parameters_1.js       |    25 +
 share/magics/efi/Africa_All32parameters_2.js       |    25 +
 share/magics/efi/Africa_All32parameters_3.js       |    25 +
 share/magics/efi/Africa_All32parameters_4.js       |    25 +
 share/magics/efi/Africa_All32parameters_5.js       |    25 +
 share/magics/efi/Asia_All32parameters_0.js         |    25 +
 share/magics/efi/Asia_All32parameters_1.js         |    25 +
 share/magics/efi/Asia_All32parameters_2.js         |    25 +
 share/magics/efi/Asia_All32parameters_3.js         |    25 +
 share/magics/efi/Asia_All32parameters_4.js         |    25 +
 share/magics/efi/Asia_All32parameters_5.js         |    25 +
 share/magics/efi/Australia_All32parameters_0.js    |    25 +
 share/magics/efi/Australia_All32parameters_1.js    |    25 +
 share/magics/efi/Australia_All32parameters_2.js    |    25 +
 share/magics/efi/Australia_All32parameters_3.js    |    25 +
 share/magics/efi/Australia_All32parameters_4.js    |    25 +
 share/magics/efi/Australia_All32parameters_5.js    |    25 +
 share/magics/efi/Europe_All32parameters_0.js       |    48 +
 share/magics/efi/Europe_All32parameters_1.js       |    48 +
 share/magics/efi/Europe_All32parameters_2.js       |    48 +
 share/magics/efi/Europe_All32parameters_3.js       |    48 +
 share/magics/efi/Europe_All32parameters_4.js       |    48 +
 share/magics/efi/Europe_All32parameters_5.js       |    48 +
 share/magics/efi/Global_All32parameters_0.js       |    25 +
 share/magics/efi/Global_All32parameters_1.js       |    25 +
 share/magics/efi/Global_All32parameters_2.js       |    25 +
 share/magics/efi/Global_All32parameters_3.js       |    25 +
 share/magics/efi/Global_All32parameters_4.js       |    25 +
 share/magics/efi/Global_All32parameters_5.js       |    25 +
 .../magics/efi/North32America_All32parameters_0.js |    25 +
 .../magics/efi/North32America_All32parameters_1.js |    25 +
 .../magics/efi/North32America_All32parameters_2.js |    25 +
 .../magics/efi/North32America_All32parameters_3.js |    25 +
 .../magics/efi/North32America_All32parameters_4.js |    25 +
 .../magics/efi/North32America_All32parameters_5.js |    25 +
 .../magics/efi/South32America_All32parameters_0.js |    25 +
 .../magics/efi/South32America_All32parameters_1.js |    25 +
 .../magics/efi/South32America_All32parameters_2.js |    25 +
 .../magics/efi/South32America_All32parameters_3.js |    25 +
 .../magics/efi/South32America_All32parameters_4.js |    25 +
 .../magics/efi/South32America_All32parameters_5.js |    25 +
 share/magics/efi/efi_template.js                   |     1 +
 share/magics/entities.dtd                          |   255 +
 share/magics/epsg.json                             |   138 +
 share/magics/kml_logo.png                          |   Bin 0 -> 7291 bytes
 share/magics/level.xml                             |    13 +
 share/magics/magics_kml_icons.png                  |   Bin 0 -> 6389 bytes
 share/magics/magics_kml_icons.svg                  |   176 +
 share/magics/obs.xml                               |   110 +
 share/magics/satellite.xml                         |    13 +
 share/magics/symbols.svg                           |   860 +
 share/magics/table_128.xml                         |  1299 +
 share/magics/table_129.xml                         |  1285 +
 share/magics/table_130.xml                         |   179 +
 share/magics/table_131.xml                         |    67 +
 share/magics/table_132.xml                         |    32 +
 share/magics/table_140.xml                         |   256 +
 share/magics/table_150.xml                         |   221 +
 share/magics/table_151.xml                         |   312 +
 share/magics/table_160.xml                         |   753 +
 share/magics/table_162.xml                         |     4 +
 share/magics/table_170.xml                         |   116 +
 share/magics/table_171.xml                         |  1292 +
 share/magics/table_172.xml                         |   256 +
 share/magics/table_173.xml                         |     4 +
 share/magics/table_174.xml                         |   179 +
 share/magics/table_175.xml                         |   179 +
 share/magics/table_180.xml                         |   221 +
 share/magics/table_190.xml                         |   221 +
 share/magics/table_2.xml                           |    10 +
 share/magics/table_200.xml                         |  1299 +
 share/magics/table_210.xml                         |   480 +
 share/magics/table_254.xml                         |   604 +
 share/magics/title_template.xml                    |    50 +
 share/magics/ttf/DejaVuSans-Bold.ttf               |   Bin 0 -> 494260 bytes
 share/magics/ttf/DejaVuSans-BoldOblique.ttf        |   Bin 0 -> 468340 bytes
 share/magics/ttf/DejaVuSans-Oblique.ttf            |   Bin 0 -> 461680 bytes
 share/magics/ttf/DejaVuSans.ttf                    |   Bin 0 -> 520788 bytes
 share/magics/ttf/DejaVuSerif-Bold.ttf              |   Bin 0 -> 203488 bytes
 share/magics/ttf/DejaVuSerif-BoldOblique.ttf       |   Bin 0 -> 183096 bytes
 share/magics/ttf/DejaVuSerif-Oblique.ttf           |   Bin 0 -> 181932 bytes
 share/magics/ttf/DejaVuSerif.ttf                   |   Bin 0 -> 212332 bytes
 share/magics/ttf/LICENSE-dejavu-ttf-2.15           |    98 +
 share/magics/type.xml                              |    16 +
 src/MagicsDouble.cc                                |   140 +
 src/MagicsSingle.cc                                |    80 +
 src/Makefile.am                                    |   228 +
 src/Makefile.in                                    |  1282 +
 src/MvObs/Makefile.am                              |    14 +
 src/MvObs/Makefile.in                              |   664 +
 src/MvObs/MvBufr.h                                 |   444 +
 src/MvObs/MvBufrObs.h                              |   599 +
 src/MvObs/MvLocation.cc                            |   263 +
 src/MvObs/MvLocation.h                             |   187 +
 src/MvObs/MvObs.cc                                 |  3297 +++
 src/MvObs/MvObs.h                                  |    25 +
 src/MvObs/MvObsSet.cc                              |  1011 +
 src/MvObs/MvObsSet.h                               |   337 +
 src/MvObs/MvPrepBufrPrep.cc                        |   553 +
 src/MvObs/MvPrepBufrPrep.h                         |   117 +
 src/MvObs/fdyntime.cc                              |   171 +
 src/MvObs/fdyntime.h                               |    52 +
 src/MvObs/fmettim.cc                               |   210 +
 src/MvObs/fmettim.h                                |    76 +
 src/MvObs/fobject.cc                               |    39 +
 src/MvObs/fobject.h                                |    29 +
 src/MvObs/fsortabl.cc                              |    40 +
 src/MvObs/fsortabl.h                               |    34 +
 src/MvObs/fstatime.cc                              |   354 +
 src/MvObs/fstatime.h                               |    80 +
 src/MvObs/inc_iostream.h                           |    77 +
 src/VectorOfPointers.h                             |   133 +
 src/basic/BasicGraphicsObject.cc                   |    98 +
 src/basic/BasicGraphicsObject.h                    |   193 +
 src/basic/BasicSceneObject.cc                      |   211 +
 src/basic/BasicSceneObject.h                       |   325 +
 src/basic/BasicSceneVisitor.cc                     |    35 +
 src/basic/BasicSceneVisitor.h                      |    44 +
 src/basic/DisplayManager.h                         |   100 +
 src/basic/FortranMagics.cc                         |  1061 +
 src/basic/FortranMagics.h                          |   169 +
 src/basic/HistoVisitor.cc                          |    71 +
 src/basic/HistoVisitor.h                           |    95 +
 src/basic/ImportObjectHandler.cc                   |    80 +
 src/basic/ImportObjectHandler.h                    |    55 +
 src/basic/Layer.cc                                 |  1174 +
 src/basic/Layer.h                                  |   585 +
 src/basic/LayoutManager.cc                         |   296 +
 src/basic/LayoutManager.h                          |   187 +
 src/basic/LegendVisitor.cc                         |  1302 +
 src/basic/LegendVisitor.h                          |   443 +
 src/basic/LegendVisitorAttributes.h                |   129 +
 src/basic/MagicsEvent.h                            |   287 +
 src/basic/MagicsObserver.h                         |    88 +
 src/basic/MagnifierVisitor.cc                      |   148 +
 src/basic/MagnifierVisitor.h                       |   120 +
 src/basic/MagnifierVisitorAttributes.h             |    91 +
 src/basic/Makefile.am                              |    46 +
 src/basic/Makefile.in                              |   722 +
 src/basic/MultiVisdef.cc                           |    89 +
 src/basic/MultiVisdef.h                            |    60 +
 src/basic/ParameterSettings.cc                     |   120 +
 src/basic/ParameterSettings.h                      |   123 +
 src/basic/PreviewVisitor.cc                        |    71 +
 src/basic/PreviewVisitor.h                         |   101 +
 src/basic/RootSceneNode.cc                         |   442 +
 src/basic/RootSceneNode.h                          |   236 +
 src/basic/SceneNode.cc                             |   255 +
 src/basic/SceneNode.h                              |   108 +
 src/basic/SceneVisitor.cc                          |   409 +
 src/basic/SceneVisitor.h                           |   253 +
 src/basic/TagHandler.cc                            |   400 +
 src/basic/TagHandler.h                             |   105 +
 src/basic/TextVisitor.cc                           |   682 +
 src/basic/TextVisitor.h                            |   175 +
 src/basic/ThreadNode.h                             |    44 +
 src/basic/ViewNode.cc                              |   604 +
 src/basic/ViewNode.h                               |   176 +
 src/basic/Visdef.h                                 |    88 +
 src/basic/VisualAction.cc                          |   348 +
 src/basic/VisualAction.h                           |   133 +
 src/basic/WebFormat.cc                             |   156 +
 src/basic/WebFormat.h                              |   127 +
 src/basic/WrepRootNodeAttributes.h                 |    83 +
 src/basic/XmlBasicNodeAttributes.h                 |   110 +
 src/basic/XmlMagics.cc                             |   907 +
 src/basic/XmlMagics.h                              |   169 +
 src/basic/XmlRootNodeAttributes.h                  |    90 +
 src/basic/XmlSceneNodeAttributes.h                 |   106 +
 src/basic/XmlViewNodeAttributes.h                  |    83 +
 src/boost/README.update_boost                      |    23 +
 src/boost/geometry/algorithms/append.hpp           |   233 +
 src/boost/geometry/algorithms/area.hpp             |   295 +
 src/boost/geometry/algorithms/assign.hpp           |   171 +
 src/boost/geometry/algorithms/buffer.hpp           |   167 +
 src/boost/geometry/algorithms/centroid.hpp         |   470 +
 src/boost/geometry/algorithms/clear.hpp            |   159 +
 .../geometry/algorithms/comparable_distance.hpp    |    74 +
 src/boost/geometry/algorithms/convert.hpp          |   411 +
 src/boost/geometry/algorithms/convex_hull.hpp      |   275 +
 src/boost/geometry/algorithms/correct.hpp          |   265 +
 src/boost/geometry/algorithms/covered_by.hpp       |   195 +
 src/boost/geometry/algorithms/detail/as_range.hpp  |   107 +
 .../algorithms/detail/assign_box_corners.hpp       |    93 +
 .../algorithms/detail/assign_indexed_point.hpp     |    94 +
 .../geometry/algorithms/detail/assign_values.hpp   |   443 +
 .../geometry/algorithms/detail/calculate_null.hpp  |    38 +
 .../geometry/algorithms/detail/calculate_sum.hpp   |    64 +
 .../detail/convert_indexed_to_indexed.hpp          |    80 +
 .../algorithms/detail/convert_point_to_point.hpp   |    68 +
 src/boost/geometry/algorithms/detail/disjoint.hpp  |   225 +
 .../algorithms/detail/equals/collect_vectors.hpp   |   315 +
 .../geometry/algorithms/detail/for_each_range.hpp  |   149 +
 .../geometry/algorithms/detail/get_left_turns.hpp  |   367 +
 .../algorithms/detail/has_self_intersections.hpp   |   120 +
 src/boost/geometry/algorithms/detail/not.hpp       |    50 +
 .../geometry/algorithms/detail/occupation_info.hpp |   329 +
 .../algorithms/detail/overlay/add_rings.hpp        |   160 +
 .../detail/overlay/append_no_duplicates.hpp        |    53 +
 .../algorithms/detail/overlay/assign_parents.hpp   |   338 +
 .../detail/overlay/backtrack_check_si.hpp          |   170 +
 .../detail/overlay/calculate_distance_policy.hpp   |    64 +
 .../algorithms/detail/overlay/check_enrich.hpp     |   172 +
 .../algorithms/detail/overlay/clip_linestring.hpp  |   242 +
 .../algorithms/detail/overlay/convert_ring.hpp     |    99 +
 .../detail/overlay/copy_segment_point.hpp          |   295 +
 .../algorithms/detail/overlay/copy_segments.hpp    |   328 +
 .../algorithms/detail/overlay/debug_turn_info.hpp  |    66 +
 .../detail/overlay/enrich_intersection_points.hpp  |   523 +
 .../algorithms/detail/overlay/enrichment_info.hpp  |    76 +
 .../geometry/algorithms/detail/overlay/follow.hpp  |   416 +
 .../detail/overlay/get_intersection_points.hpp     |   146 +
 .../detail/overlay/get_relative_order.hpp          |   108 +
 .../algorithms/detail/overlay/get_ring.hpp         |   102 +
 .../algorithms/detail/overlay/get_turn_info.hpp    |  1094 +
 .../algorithms/detail/overlay/get_turns.hpp        |   873 +
 .../detail/overlay/handle_tangencies.hpp           |   672 +
 .../detail/overlay/intersection_insert.hpp         |   690 +
 .../geometry/algorithms/detail/overlay/overlay.hpp |   301 +
 .../algorithms/detail/overlay/overlay_type.hpp     |    29 +
 .../algorithms/detail/overlay/ring_properties.hpp  |    78 +
 .../detail/overlay/segment_identifier.hpp          |    91 +
 .../algorithms/detail/overlay/select_rings.hpp     |   295 +
 .../algorithms/detail/overlay/self_turn_points.hpp |   308 +
 .../algorithms/detail/overlay/stream_info.hpp      |    75 +
 .../algorithms/detail/overlay/traversal_info.hpp   |    47 +
 .../algorithms/detail/overlay/traverse.hpp         |   395 +
 .../algorithms/detail/overlay/turn_info.hpp        |   152 +
 .../algorithms/detail/overlay/visit_info.hpp       |   136 +
 .../algorithms/detail/overlay/within_util.hpp      |    98 +
 src/boost/geometry/algorithms/detail/partition.hpp |   425 +
 .../geometry/algorithms/detail/point_on_border.hpp |   246 +
 .../geometry/algorithms/detail/ring_identifier.hpp |    70 +
 .../detail/sections/range_by_section.hpp           |   131 +
 .../algorithms/detail/sections/sectionalize.hpp    |   648 +
 .../algorithms/detail/throw_on_empty_input.hpp     |    53 +
 src/boost/geometry/algorithms/difference.hpp       |   160 +
 src/boost/geometry/algorithms/disjoint.hpp         |   301 +
 src/boost/geometry/algorithms/distance.hpp         |   591 +
 src/boost/geometry/algorithms/envelope.hpp         |   273 +
 src/boost/geometry/algorithms/equals.hpp           |   319 +
 src/boost/geometry/algorithms/expand.hpp           |   319 +
 src/boost/geometry/algorithms/for_each.hpp         |   358 +
 src/boost/geometry/algorithms/intersection.hpp     |   237 +
 src/boost/geometry/algorithms/intersects.hpp       |   106 +
 src/boost/geometry/algorithms/length.hpp           |   204 +
 src/boost/geometry/algorithms/make.hpp             |   200 +
 src/boost/geometry/algorithms/not_implemented.hpp  |   117 +
 src/boost/geometry/algorithms/num_geometries.hpp   |    95 +
 .../geometry/algorithms/num_interior_rings.hpp     |    88 +
 src/boost/geometry/algorithms/num_points.hpp       |   171 +
 src/boost/geometry/algorithms/overlaps.hpp         |   202 +
 src/boost/geometry/algorithms/perimeter.hpp        |   144 +
 src/boost/geometry/algorithms/reverse.hpp          |   134 +
 src/boost/geometry/algorithms/simplify.hpp         |   405 +
 src/boost/geometry/algorithms/sym_difference.hpp   |   177 +
 src/boost/geometry/algorithms/touches.hpp          |   181 +
 src/boost/geometry/algorithms/transform.hpp        |   351 +
 src/boost/geometry/algorithms/union.hpp            |   284 +
 src/boost/geometry/algorithms/unique.hpp           |   153 +
 src/boost/geometry/algorithms/within.hpp           |   344 +
 src/boost/geometry/arithmetic/arithmetic.hpp       |   281 +
 src/boost/geometry/arithmetic/determinant.hpp      |    76 +
 src/boost/geometry/arithmetic/dot_product.hpp      |    82 +
 src/boost/geometry/core/access.hpp                 |   324 +
 src/boost/geometry/core/closure.hpp                |   180 +
 src/boost/geometry/core/coordinate_dimension.hpp   |   126 +
 src/boost/geometry/core/coordinate_system.hpp      |    97 +
 src/boost/geometry/core/coordinate_type.hpp        |   102 +
 src/boost/geometry/core/cs.hpp                     |   220 +
 src/boost/geometry/core/exception.hpp              |    60 +
 src/boost/geometry/core/exterior_ring.hpp          |   144 +
 src/boost/geometry/core/geometry_id.hpp            |    94 +
 src/boost/geometry/core/interior_rings.hpp         |   139 +
 src/boost/geometry/core/interior_type.hpp          |   161 +
 src/boost/geometry/core/is_areal.hpp               |    60 +
 src/boost/geometry/core/mutable_range.hpp          |    98 +
 src/boost/geometry/core/point_order.hpp            |   162 +
 src/boost/geometry/core/point_type.hpp             |   130 +
 src/boost/geometry/core/radian_access.hpp          |   152 +
 src/boost/geometry/core/reverse_dispatch.hpp       |    67 +
 src/boost/geometry/core/ring_type.hpp              |   170 +
 src/boost/geometry/core/tag.hpp                    |    70 +
 src/boost/geometry/core/tag_cast.hpp               |    84 +
 src/boost/geometry/core/tags.hpp                   |    94 +
 src/boost/geometry/core/topological_dimension.hpp  |    88 +
 src/boost/geometry/domains/gis/io/io.hpp           |    65 +
 .../geometry/domains/gis/io/wkt/detail/wkt.hpp     |    49 +
 .../domains/gis/io/wkt/detail/wkt_multi.hpp        |    56 +
 src/boost/geometry/domains/gis/io/wkt/read_wkt.hpp |   692 +
 .../geometry/domains/gis/io/wkt/read_wkt_multi.hpp |   112 +
 src/boost/geometry/domains/gis/io/wkt/wkt.hpp      |    25 +
 .../geometry/domains/gis/io/wkt/write_wkt.hpp      |   394 +
 .../domains/gis/io/wkt/write_wkt_multi.hpp         |   117 +
 .../algorithms/buffer/intersecting_inserter.hpp    |    93 +
 .../algorithms/buffer/line_line_intersection.hpp   |    84 +
 .../algorithms/buffer/linestring_buffer.hpp        |   223 +
 .../algorithms/buffer/polygon_buffer.hpp           |   231 +
 .../algorithms/buffer/remove_within_distance.hpp   |   151 +
 .../algorithms/buffer/sectionalizing_buffer.hpp    |   167 +
 .../algorithms/buffer/segmenting_buffer.hpp        |   350 +
 .../algorithms/buffer/splitting_buffer.hpp         |   116 +
 .../algorithms/buffer/traversing_buffer.hpp        |    89 +
 .../geometry/extensions/algorithms/connect.hpp     |   581 +
 .../algorithms/detail/overlay/dissolver.hpp        |   640 +
 .../algorithms/detail/overlay/msm_state.hpp        |   187 +
 .../algorithms/detail/overlay/split_rings.hpp      |   547 +
 .../geometry/extensions/algorithms/dissolve.hpp    |   293 +
 .../geometry/extensions/algorithms/mark_spikes.hpp |   516 +
 .../geometry/extensions/algorithms/midpoints.hpp   |   131 +
 .../geometry/extensions/algorithms/offset.hpp      |   204 +
 src/boost/geometry/extensions/algorithms/parse.hpp |   123 +
 .../extensions/algorithms/point_on_line.hpp        |    75 +
 .../extensions/algorithms/remove_holes_if.hpp      |   166 +
 .../extensions/algorithms/remove_marked.hpp        |   224 +
 .../extensions/algorithms/remove_spikes.hpp        |   378 +
 .../geometry/extensions/algorithms/selected.hpp    |   278 +
 .../extensions/arithmetic/cross_product.hpp        |   109 +
 .../geometry/extensions/astronomy/core/cs.hpp      |    53 +
 .../geometry/extensions/contrib/ttmath/ttmath.h    |  2849 +++
 .../geometry/extensions/contrib/ttmath/ttmathbig.h |  6064 +++++
 .../geometry/extensions/contrib/ttmath/ttmathint.h |  1922 ++
 .../extensions/contrib/ttmath/ttmathmisc.h         |   250 +
 .../extensions/contrib/ttmath/ttmathobjects.h      |   809 +
 .../extensions/contrib/ttmath/ttmathparser.h       |  2777 +++
 .../extensions/contrib/ttmath/ttmaththreads.h      |   250 +
 .../extensions/contrib/ttmath/ttmathtypes.h        |   675 +
 .../extensions/contrib/ttmath/ttmathuint.h         |  4121 ++++
 .../extensions/contrib/ttmath/ttmathuint_noasm.h   |  1017 +
 .../extensions/contrib/ttmath/ttmathuint_x86.h     |  1602 ++
 .../extensions/contrib/ttmath/ttmathuint_x86_64.h  |  1146 +
 .../contrib/ttmath/ttmathuint_x86_64_msvc.asm      |   548 +
 .../geometry/extensions/contrib/ttmath_stub.hpp    |   293 +
 .../extensions/geometries/quantity_point.hpp       |   134 +
 .../geometry/extensions/gis/geographic/core/cs.hpp |    81 +
 .../extensions/gis/geographic/detail/ellipsoid.hpp |    65 +
 .../gis/geographic/strategies/andoyer.hpp          |   224 +
 .../geographic/strategies/area_huiller_earth.hpp   |    64 +
 .../geographic/strategies/distance_cross_track.hpp |    72 +
 .../gis/geographic/strategies/dms_parser.hpp       |   267 +
 .../gis/geographic/strategies/vincenty.hpp         |   262 +
 .../gis/io/shapelib/dbf_write_attribute.hpp        |    87 +
 .../extensions/gis/io/shapelib/shape_creator.hpp   |   154 +
 .../extensions/gis/io/shapelib/shape_reader.hpp    |    72 +
 .../gis/io/shapelib/shp_create_object.hpp          |   227 +
 .../gis/io/shapelib/shp_create_object_multi.hpp    |   147 +
 .../extensions/gis/io/shapelib/shp_read_object.hpp |   225 +
 .../extensions/gis/io/veshape/write_veshape.hpp    |   281 +
 .../extensions/gis/io/wkb/detail/endian.hpp        |   262 +
 .../geometry/extensions/gis/io/wkb/detail/ogc.hpp  |    86 +
 .../extensions/gis/io/wkb/detail/parser.hpp        |   315 +
 .../geometry/extensions/gis/io/wkb/read_wkb.hpp    |   108 +
 .../geometry/extensions/gis/io/wkb/utility.hpp     |    92 +
 .../geometry/extensions/gis/io/wkt/read_wkt.hpp    |    68 +
 .../geometry/extensions/gis/io/wkt/readme.txt      |    15 +
 .../geometry/extensions/gis/io/wkt/stream_wkt.hpp  |    46 +
 src/boost/geometry/extensions/gis/io/wkt/wkt.hpp   |    32 +
 .../geometry/extensions/gis/io/wkt/write_wkt.hpp   |    44 +
 .../extensions/gis/latlong/detail/graticule.hpp    |   238 +
 .../geometry/extensions/gis/latlong/latlong.hpp    |    54 +
 .../geometry/extensions/gis/latlong/point_ll.hpp   |   269 +
 .../geometry/extensions/gis/projections/epsg.hpp   |  3568 +++
 .../extensions/gis/projections/epsg_traits.hpp     |    43 +
 .../extensions/gis/projections/factory.hpp         |   255 +
 .../extensions/gis/projections/impl/aasincos.hpp   |   107 +
 .../extensions/gis/projections/impl/adjlon.hpp     |    73 +
 .../gis/projections/impl/base_dynamic.hpp          |   106 +
 .../gis/projections/impl/base_static.hpp           |   105 +
 .../gis/projections/impl/factory_entry.hpp         |    43 +
 .../gis/projections/impl/function_overloads.hpp    |    35 +
 .../extensions/gis/projections/impl/pj_auth.hpp    |    85 +
 .../gis/projections/impl/pj_datum_set.hpp          |   167 +
 .../extensions/gis/projections/impl/pj_datums.hpp  |   106 +
 .../extensions/gis/projections/impl/pj_ell_set.hpp |   155 +
 .../extensions/gis/projections/impl/pj_ellps.hpp   |    93 +
 .../extensions/gis/projections/impl/pj_fwd.hpp     |    98 +
 .../extensions/gis/projections/impl/pj_gauss.hpp   |   130 +
 .../extensions/gis/projections/impl/pj_init.hpp    |   301 +
 .../extensions/gis/projections/impl/pj_inv.hpp     |    80 +
 .../extensions/gis/projections/impl/pj_mlfn.hpp    |   111 +
 .../extensions/gis/projections/impl/pj_msfn.hpp    |    54 +
 .../extensions/gis/projections/impl/pj_param.hpp   |   155 +
 .../extensions/gis/projections/impl/pj_phi2.hpp    |    73 +
 .../extensions/gis/projections/impl/pj_qsfn.hpp    |    84 +
 .../extensions/gis/projections/impl/pj_tsfn.hpp    |    54 +
 .../extensions/gis/projections/impl/pj_units.hpp   |    75 +
 .../extensions/gis/projections/impl/pj_zpoly1.hpp  |   100 +
 .../extensions/gis/projections/impl/proj_mdist.hpp |   137 +
 .../extensions/gis/projections/impl/projects.hpp   |   184 +
 .../extensions/gis/projections/parameters.hpp      |    65 +
 .../extensions/gis/projections/proj/aea.hpp        |   525 +
 .../extensions/gis/projections/proj/aeqd.hpp       |   454 +
 .../extensions/gis/projections/proj/airy.hpp       |   217 +
 .../extensions/gis/projections/proj/aitoff.hpp     |   210 +
 .../extensions/gis/projections/proj/august.hpp     |   141 +
 .../extensions/gis/projections/proj/bacon.hpp      |   238 +
 .../extensions/gis/projections/proj/bipc.hpp       |   253 +
 .../extensions/gis/projections/proj/boggs.hpp      |   154 +
 .../extensions/gis/projections/proj/bonne.hpp      |   246 +
 .../extensions/gis/projections/proj/cass.hpp       |   465 +
 .../extensions/gis/projections/proj/cc.hpp         |   145 +
 .../extensions/gis/projections/proj/cea.hpp        |   224 +
 .../extensions/gis/projections/proj/chamb.hpp      |   242 +
 .../extensions/gis/projections/proj/collg.hpp      |   152 +
 .../extensions/gis/projections/proj/crast.hpp      |   144 +
 .../extensions/gis/projections/proj/denoy.hpp      |   140 +
 .../extensions/gis/projections/proj/eck1.hpp       |   140 +
 .../extensions/gis/projections/proj/eck2.hpp       |   151 +
 .../extensions/gis/projections/proj/eck3.hpp       |   286 +
 .../extensions/gis/projections/proj/eck4.hpp       |   167 +
 .../extensions/gis/projections/proj/eck5.hpp       |   141 +
 .../extensions/gis/projections/proj/eqc.hpp        |   146 +
 .../extensions/gis/projections/proj/eqdc.hpp       |   212 +
 .../extensions/gis/projections/proj/fahey.hpp      |   140 +
 .../extensions/gis/projections/proj/fouc_s.hpp     |   167 +
 .../extensions/gis/projections/proj/gall.hpp       |   142 +
 .../extensions/gis/projections/proj/geocent.hpp    |   143 +
 .../extensions/gis/projections/proj/geos.hpp       |   280 +
 .../extensions/gis/projections/proj/gins8.hpp      |   140 +
 .../extensions/gis/projections/proj/gn_sinu.hpp    |   380 +
 .../extensions/gis/projections/proj/gnom.hpp       |   227 +
 .../extensions/gis/projections/proj/goode.hpp      |   160 +
 .../extensions/gis/projections/proj/gstmerc.hpp    |   176 +
 .../extensions/gis/projections/proj/hammer.hpp     |   152 +
 .../extensions/gis/projections/proj/hatano.hpp     |   173 +
 .../extensions/gis/projections/proj/imw_p.hpp      |   281 +
 .../extensions/gis/projections/proj/krovak.hpp     |   338 +
 .../extensions/gis/projections/proj/labrd.hpp      |   231 +
 .../extensions/gis/projections/proj/laea.hpp       |   391 +
 .../extensions/gis/projections/proj/lagrng.hpp     |   158 +
 .../extensions/gis/projections/proj/larr.hpp       |   134 +
 .../extensions/gis/projections/proj/lask.hpp       |   148 +
 .../extensions/gis/projections/proj/latlong.hpp    |   282 +
 .../extensions/gis/projections/proj/lcc.hpp        |   249 +
 .../extensions/gis/projections/proj/lcca.hpp       |   191 +
 .../extensions/gis/projections/proj/loxim.hpp      |   164 +
 .../extensions/gis/projections/proj/lsat.hpp       |   299 +
 .../extensions/gis/projections/proj/mbt_fps.hpp    |   161 +
 .../extensions/gis/projections/proj/mbtfpp.hpp     |   155 +
 .../extensions/gis/projections/proj/mbtfpq.hpp     |   170 +
 .../extensions/gis/projections/proj/merc.hpp       |   213 +
 .../extensions/gis/projections/proj/mill.hpp       |   138 +
 .../extensions/gis/projections/proj/mod_ster.hpp   |   474 +
 .../extensions/gis/projections/proj/moll.hpp       |   262 +
 .../extensions/gis/projections/proj/nell.hpp       |   154 +
 .../extensions/gis/projections/proj/nell_h.hpp     |   153 +
 .../extensions/gis/projections/proj/nocol.hpp      |   160 +
 .../extensions/gis/projections/proj/nsper.hpp      |   317 +
 .../extensions/gis/projections/proj/nzmg.hpp       |   196 +
 .../extensions/gis/projections/proj/ob_tran.hpp    |   318 +
 .../extensions/gis/projections/proj/ocea.hpp       |   189 +
 .../extensions/gis/projections/proj/oea.hpp        |   181 +
 .../extensions/gis/projections/proj/omerc.hpp      |   295 +
 .../extensions/gis/projections/proj/ortho.hpp      |   219 +
 .../extensions/gis/projections/proj/poly.hpp       |   266 +
 .../extensions/gis/projections/proj/putp2.hpp      |   163 +
 .../extensions/gis/projections/proj/putp3.hpp      |   197 +
 .../extensions/gis/projections/proj/putp4p.hpp     |   201 +
 .../extensions/gis/projections/proj/putp5.hpp      |   198 +
 .../extensions/gis/projections/proj/putp6.hpp      |   223 +
 .../extensions/gis/projections/proj/robin.hpp      |   232 +
 .../extensions/gis/projections/proj/rouss.hpp      |   211 +
 .../extensions/gis/projections/proj/rpoly.hpp      |   158 +
 .../extensions/gis/projections/proj/sconics.hpp    |   511 +
 .../extensions/gis/projections/proj/somerc.hpp     |   188 +
 .../extensions/gis/projections/proj/stere.hpp      |   451 +
 .../extensions/gis/projections/proj/sterea.hpp     |   381 +
 .../extensions/gis/projections/proj/sts.hpp        |   294 +
 .../extensions/gis/projections/proj/tcc.hpp        |   142 +
 .../extensions/gis/projections/proj/tcea.hpp       |   149 +
 .../extensions/gis/projections/proj/tmerc.hpp      |   458 +
 .../extensions/gis/projections/proj/tpeqd.hpp      |   198 +
 .../extensions/gis/projections/proj/urm5.hpp       |   149 +
 .../extensions/gis/projections/proj/urmfps.hpp     |   205 +
 .../extensions/gis/projections/proj/vandg.hpp      |   201 +
 .../extensions/gis/projections/proj/vandg2.hpp     |   205 +
 .../extensions/gis/projections/proj/vandg4.hpp     |   163 +
 .../extensions/gis/projections/proj/wag2.hpp       |   144 +
 .../extensions/gis/projections/proj/wag3.hpp       |   148 +
 .../extensions/gis/projections/proj/wag7.hpp       |   137 +
 .../extensions/gis/projections/proj/wink1.hpp      |   145 +
 .../extensions/gis/projections/proj/wink2.hpp      |   159 +
 .../projections/project_inverse_transformer.hpp    |    73 +
 .../gis/projections/project_transformer.hpp        |    65 +
 .../extensions/gis/projections/projection.hpp      |    65 +
 .../geometry/extensions/index/rtree/helpers.hpp    |    68 +
 .../geometry/extensions/index/rtree/rtree.hpp      |   774 +
 .../geometry/extensions/index/rtree/rtree_leaf.hpp |   253 +
 .../geometry/extensions/index/rtree/rtree_node.hpp |   493 +
 .../geometry/extensions/io/svg/svg_mapper.hpp      |   347 +
 src/boost/geometry/extensions/io/svg/write_svg.hpp |   272 +
 .../geometry/extensions/io/svg/write_svg_multi.hpp |    78 +
 .../extensions/iterators/circular_iterator.hpp     |   121 +
 .../extensions/iterators/section_iterators.hpp     |   233 +
 .../iterators/segment_returning_iterator.hpp       |   139 +
 .../extensions/multi/algorithms/dissolve.hpp       |    99 +
 .../extensions/nsphere/algorithms/append.hpp       |    45 +
 .../extensions/nsphere/algorithms/area.hpp         |    82 +
 .../extensions/nsphere/algorithms/assign.hpp       |    93 +
 .../extensions/nsphere/algorithms/clear.hpp        |    47 +
 .../extensions/nsphere/algorithms/envelope.hpp     |    83 +
 .../extensions/nsphere/algorithms/num_points.hpp   |    46 +
 .../extensions/nsphere/algorithms/within.hpp       |   209 +
 .../geometry/extensions/nsphere/core/access.hpp    |    52 +
 .../extensions/nsphere/core/geometry_id.hpp        |    47 +
 .../geometry/extensions/nsphere/core/radius.hpp    |   160 +
 .../extensions/nsphere/core/replace_point_type.hpp |    48 +
 .../geometry/extensions/nsphere/core/tags.hpp      |    29 +
 .../nsphere/core/topological_dimension.hpp         |    50 +
 .../nsphere/geometries/concepts/check.hpp          |    42 +
 .../geometries/concepts/nsphere_concept.hpp        |   122 +
 .../extensions/nsphere/geometries/nsphere.hpp      |   144 +
 src/boost/geometry/extensions/nsphere/nsphere.hpp  |    37 +
 .../geometry/extensions/strategies/buffer.hpp      |   396 +
 .../extensions/strategies/buffer_join_round.hpp    |   176 +
 .../geometry/extensions/strategies/buffer_side.hpp |    31 +
 src/boost/geometry/extensions/strategies/parse.hpp |    41 +
 .../geometry/extensions/util/get_cs_as_radian.hpp  |    55 +
 .../extensions/util/replace_point_type.hpp         |    98 +
 .../geometry/extensions/views/enveloped_view.hpp   |   126 +
 .../geometry/extensions/views/section_view.hpp     |    73 +
 .../geometry/geometries/adapted/boost_array.hpp    |   120 +
 .../geometry/geometries/adapted/boost_fusion.hpp   |   172 +
 .../geometry/geometries/adapted/boost_polygon.hpp  |    18 +
 .../geometries/adapted/boost_polygon/box.hpp       |   141 +
 .../adapted/boost_polygon/hole_iterator.hpp        |    84 +
 .../adapted/boost_polygon/holes_proxy.hpp          |   204 +
 .../geometries/adapted/boost_polygon/point.hpp     |   102 +
 .../geometries/adapted/boost_polygon/polygon.hpp   |   111 +
 .../geometries/adapted/boost_polygon/ring.hpp      |   163 +
 .../adapted/boost_polygon/ring_proxy.hpp           |   301 +
 .../adapted/boost_range/adjacent_filtered.hpp      |    40 +
 .../geometries/adapted/boost_range/filtered.hpp    |    40 +
 .../geometries/adapted/boost_range/reversed.hpp    |    40 +
 .../geometries/adapted/boost_range/sliced.hpp      |    36 +
 .../geometries/adapted/boost_range/strided.hpp     |    36 +
 .../geometries/adapted/boost_range/uniqued.hpp     |    40 +
 .../geometry/geometries/adapted/boost_tuple.hpp    |   109 +
 src/boost/geometry/geometries/adapted/c_array.hpp  |   111 +
 .../geometries/adapted/std_pair_as_segment.hpp     |    98 +
 src/boost/geometry/geometries/box.hpp              |   134 +
 .../geometry/geometries/concepts/box_concept.hpp   |   136 +
 src/boost/geometry/geometries/concepts/check.hpp   |   171 +
 .../geometries/concepts/linestring_concept.hpp     |   125 +
 .../geometry/geometries/concepts/point_concept.hpp |   176 +
 .../geometries/concepts/polygon_concept.hpp        |   135 +
 .../geometry/geometries/concepts/ring_concept.hpp  |    99 +
 .../geometries/concepts/segment_concept.hpp        |   135 +
 src/boost/geometry/geometries/geometries.hpp       |    25 +
 src/boost/geometry/geometries/linestring.hpp       |    95 +
 src/boost/geometry/geometries/point.hpp            |   178 +
 src/boost/geometry/geometries/point_xy.hpp         |   128 +
 src/boost/geometry/geometries/polygon.hpp          |   319 +
 src/boost/geometry/geometries/register/box.hpp     |   179 +
 .../geometry/geometries/register/linestring.hpp    |    60 +
 src/boost/geometry/geometries/register/point.hpp   |   173 +
 src/boost/geometry/geometries/register/ring.hpp    |    60 +
 src/boost/geometry/geometries/register/segment.hpp |   129 +
 src/boost/geometry/geometries/ring.hpp             |   153 +
 src/boost/geometry/geometries/segment.hpp          |   203 +
 src/boost/geometry/geometry.hpp                    |    91 +
 src/boost/geometry/io/dsv/write.hpp                |   375 +
 src/boost/geometry/io/io.hpp                       |    58 +
 src/boost/geometry/io/wkt/detail/prefix.hpp        |    45 +
 src/boost/geometry/io/wkt/detail/wkt_multi.hpp     |    57 +
 src/boost/geometry/io/wkt/iomanip.hpp              |    46 +
 src/boost/geometry/io/wkt/read.hpp                 |   686 +
 src/boost/geometry/io/wkt/stream.hpp               |    40 +
 src/boost/geometry/io/wkt/wkt.hpp                  |    25 +
 src/boost/geometry/io/wkt/write.hpp                |   376 +
 src/boost/geometry/iterators/base.hpp              |    70 +
 src/boost/geometry/iterators/closing_iterator.hpp  |   157 +
 .../geometry/iterators/ever_circling_iterator.hpp  |   212 +
 src/boost/geometry/multi/algorithms/append.hpp     |    52 +
 src/boost/geometry/multi/algorithms/area.hpp       |    57 +
 src/boost/geometry/multi/algorithms/centroid.hpp   |   178 +
 src/boost/geometry/multi/algorithms/clear.hpp      |    43 +
 src/boost/geometry/multi/algorithms/convert.hpp    |   128 +
 src/boost/geometry/multi/algorithms/correct.hpp    |    66 +
 src/boost/geometry/multi/algorithms/covered_by.hpp |    70 +
 .../multi/algorithms/detail/for_each_range.hpp     |    86 +
 .../geometry/multi/algorithms/detail/modify.hpp    |    53 +
 .../algorithms/detail/modify_with_predicate.hpp    |    52 +
 .../geometry/multi/algorithms/detail/multi_sum.hpp |    58 +
 .../detail/overlay/copy_segment_point.hpp          |   101 +
 .../algorithms/detail/overlay/copy_segments.hpp    |   104 +
 .../multi/algorithms/detail/overlay/get_ring.hpp   |    54 +
 .../multi/algorithms/detail/overlay/get_turns.hpp  |   111 +
 .../algorithms/detail/overlay/select_rings.hpp     |    62 +
 .../algorithms/detail/overlay/self_turn_points.hpp |    56 +
 .../multi/algorithms/detail/point_on_border.hpp    |    95 +
 .../detail/sections/range_by_section.hpp           |    90 +
 .../algorithms/detail/sections/sectionalize.hpp    |    95 +
 src/boost/geometry/multi/algorithms/distance.hpp   |   157 +
 src/boost/geometry/multi/algorithms/envelope.hpp   |   117 +
 src/boost/geometry/multi/algorithms/equals.hpp     |    70 +
 src/boost/geometry/multi/algorithms/for_each.hpp   |   129 +
 .../geometry/multi/algorithms/intersection.hpp     |   438 +
 src/boost/geometry/multi/algorithms/length.hpp     |    57 +
 .../geometry/multi/algorithms/num_geometries.hpp   |    51 +
 .../multi/algorithms/num_interior_rings.hpp        |    61 +
 src/boost/geometry/multi/algorithms/num_points.hpp |    81 +
 src/boost/geometry/multi/algorithms/perimeter.hpp  |    56 +
 src/boost/geometry/multi/algorithms/reverse.hpp    |    69 +
 src/boost/geometry/multi/algorithms/simplify.hpp   |   117 +
 src/boost/geometry/multi/algorithms/transform.hpp  |   102 +
 src/boost/geometry/multi/algorithms/unique.hpp     |   102 +
 src/boost/geometry/multi/algorithms/within.hpp     |   104 +
 src/boost/geometry/multi/core/closure.hpp          |    58 +
 src/boost/geometry/multi/core/geometry_id.hpp      |    56 +
 src/boost/geometry/multi/core/interior_rings.hpp   |    55 +
 src/boost/geometry/multi/core/is_areal.hpp         |    43 +
 src/boost/geometry/multi/core/point_order.hpp      |    57 +
 src/boost/geometry/multi/core/point_type.hpp       |    64 +
 src/boost/geometry/multi/core/ring_type.hpp        |    66 +
 src/boost/geometry/multi/core/tags.hpp             |    71 +
 .../geometry/multi/core/topological_dimension.hpp  |    52 +
 .../geometry/multi/geometries/concepts/check.hpp   |    83 +
 .../concepts/multi_linestring_concept.hpp          |    86 +
 .../geometries/concepts/multi_point_concept.hpp    |    85 +
 .../geometries/concepts/multi_polygon_concept.hpp  |    86 +
 .../geometry/multi/geometries/multi_geometries.hpp |    21 +
 .../geometry/multi/geometries/multi_linestring.hpp |    80 +
 .../geometry/multi/geometries/multi_point.hpp      |    94 +
 .../geometry/multi/geometries/multi_polygon.hpp    |    78 +
 .../multi/geometries/register/multi_linestring.hpp |    59 +
 .../multi/geometries/register/multi_point.hpp      |    59 +
 .../multi/geometries/register/multi_polygon.hpp    |    59 +
 src/boost/geometry/multi/io/dsv/write.hpp          |    83 +
 src/boost/geometry/multi/io/wkt/detail/prefix.hpp  |    51 +
 src/boost/geometry/multi/io/wkt/read.hpp           |   167 +
 src/boost/geometry/multi/io/wkt/wkt.hpp            |    20 +
 src/boost/geometry/multi/io/wkt/write.hpp          |   108 +
 src/boost/geometry/multi/multi.hpp                 |    77 +
 .../strategies/cartesian/centroid_average.hpp      |   116 +
 src/boost/geometry/multi/util/write_dsv.hpp        |    78 +
 .../geometry/multi/views/detail/range_type.hpp     |    62 +
 src/boost/geometry/policies/compare.hpp            |   242 +
 src/boost/geometry/policies/relate/de9im.hpp       |   177 +
 src/boost/geometry/policies/relate/direction.hpp   |   362 +
 .../policies/relate/intersection_points.hpp        |   165 +
 .../relate/intersection_points_determinant.hpp     |   176 +
 .../policies/relate/intersection_points_slope.hpp  |   213 +
 src/boost/geometry/policies/relate/tupled.hpp      |   175 +
 .../strategies/agnostic/hull_graham_andrew.hpp     |   384 +
 .../strategies/agnostic/point_in_box_by_side.hpp   |   151 +
 .../agnostic/point_in_poly_oriented_winding.hpp    |   208 +
 .../strategies/agnostic/point_in_poly_winding.hpp  |   232 +
 .../agnostic/simplify_douglas_peucker.hpp          |   229 +
 src/boost/geometry/strategies/area.hpp             |    50 +
 .../strategies/cartesian/area_surveyor.hpp         |   134 +
 .../geometry/strategies/cartesian/box_in_box.hpp   |   176 +
 .../strategies/cartesian/cart_intersect.hpp        |   738 +
 .../cartesian/centroid_bashein_detmer.hpp          |   242 +
 .../cartesian/centroid_weighted_length.hpp         |   144 +
 .../cartesian/distance_projected_point.hpp         |   319 +
 .../strategies/cartesian/distance_pythagoras.hpp   |   349 +
 .../geometry/strategies/cartesian/point_in_box.hpp |   172 +
 .../cartesian/point_in_poly_crossings_multiply.hpp |   124 +
 .../cartesian/point_in_poly_franklin.hpp           |   118 +
 .../strategies/cartesian/side_by_triangle.hpp      |   121 +
 src/boost/geometry/strategies/centroid.hpp         |    72 +
 src/boost/geometry/strategies/compare.hpp          |   172 +
 .../geometry/strategies/concepts/area_concept.hpp  |    75 +
 .../strategies/concepts/centroid_concept.hpp       |    78 +
 .../strategies/concepts/convex_hull_concept.hpp    |    75 +
 .../strategies/concepts/distance_concept.hpp       |   206 +
 .../concepts/segment_intersect_concept.hpp         |    78 +
 .../strategies/concepts/simplify_concept.hpp       |   109 +
 .../strategies/concepts/within_concept.hpp         |   291 +
 src/boost/geometry/strategies/convex_hull.hpp      |    47 +
 src/boost/geometry/strategies/covered_by.hpp       |    72 +
 .../geometry/strategies/default_area_result.hpp    |    51 +
 .../strategies/default_distance_result.hpp         |    50 +
 .../geometry/strategies/default_length_result.hpp  |    46 +
 src/boost/geometry/strategies/distance.hpp         |   135 +
 src/boost/geometry/strategies/intersection.hpp     |    93 +
 .../geometry/strategies/intersection_result.hpp    |   174 +
 src/boost/geometry/strategies/side.hpp             |    55 +
 src/boost/geometry/strategies/side_info.hpp        |   166 +
 .../geometry/strategies/spherical/area_huiller.hpp |   202 +
 .../strategies/spherical/compare_circular.hpp      |   152 +
 .../strategies/spherical/distance_cross_track.hpp  |   349 +
 .../strategies/spherical/distance_haversine.hpp    |   330 +
 .../strategies/spherical/side_by_cross_track.hpp   |   100 +
 src/boost/geometry/strategies/spherical/ssf.hpp    |   136 +
 src/boost/geometry/strategies/strategies.hpp       |    59 +
 .../geometry/strategies/strategy_transform.hpp     |   504 +
 src/boost/geometry/strategies/tags.hpp             |    41 +
 src/boost/geometry/strategies/transform.hpp        |    63 +
 .../strategies/transform/inverse_transformer.hpp   |    78 +
 .../strategies/transform/map_transformer.hpp       |   165 +
 .../strategies/transform/matrix_transformers.hpp   |   422 +
 src/boost/geometry/strategies/within.hpp           |    71 +
 src/boost/geometry/util/add_const_if_c.hpp         |    56 +
 src/boost/geometry/util/calculation_type.hpp       |   176 +
 src/boost/geometry/util/closure_as_bool.hpp        |    46 +
 src/boost/geometry/util/coordinate_cast.hpp        |    55 +
 src/boost/geometry/util/for_each_coordinate.hpp    |    94 +
 src/boost/geometry/util/math.hpp                   |   222 +
 src/boost/geometry/util/order_as_direction.hpp     |    46 +
 src/boost/geometry/util/parameter_type_of.hpp      |    75 +
 src/boost/geometry/util/promote_floating_point.hpp |    50 +
 src/boost/geometry/util/rational.hpp               |   179 +
 src/boost/geometry/util/readme.txt                 |    17 +
 .../geometry/util/select_calculation_type.hpp      |    57 +
 src/boost/geometry/util/select_coordinate_type.hpp |    45 +
 src/boost/geometry/util/select_most_precise.hpp    |   162 +
 src/boost/geometry/util/write_dsv.hpp              |   396 +
 src/boost/geometry/views/box_view.hpp              |   114 +
 src/boost/geometry/views/closeable_view.hpp        |   100 +
 src/boost/geometry/views/detail/points_view.hpp    |   141 +
 src/boost/geometry/views/detail/range_type.hpp     |   106 +
 src/boost/geometry/views/identity_view.hpp         |    53 +
 src/boost/geometry/views/reversible_view.hpp       |    74 +
 src/boost/geometry/views/segment_view.hpp          |   100 +
 src/boost/range/adaptor/adjacent_filtered.hpp      |   238 +
 src/boost/range/adaptor/argument_fwd.hpp           |    80 +
 src/boost/range/adaptor/copied.hpp                 |    58 +
 src/boost/range/adaptor/define_adaptor.hpp         |   109 +
 src/boost/range/adaptor/filtered.hpp               |   101 +
 src/boost/range/adaptor/indexed.hpp                |   156 +
 src/boost/range/adaptor/indirected.hpp             |    88 +
 src/boost/range/adaptor/map.hpp                    |   187 +
 src/boost/range/adaptor/replaced.hpp               |   134 +
 src/boost/range/adaptor/replaced_if.hpp            |   136 +
 src/boost/range/adaptor/reversed.hpp               |    90 +
 src/boost/range/adaptor/sliced.hpp                 |    82 +
 src/boost/range/adaptor/strided.hpp                |   350 +
 src/boost/range/adaptor/tokenized.hpp              |   137 +
 src/boost/range/adaptor/transformed.hpp            |   104 +
 src/boost/range/adaptor/type_erased.hpp            |   184 +
 src/boost/range/adaptor/uniqued.hpp                |    90 +
 src/boost/range/adaptors.hpp                       |    30 +
 src/boost/range/algorithm.hpp                      |   104 +
 src/boost/range/algorithm/adjacent_find.hpp        |   125 +
 src/boost/range/algorithm/binary_search.hpp        |    49 +
 src/boost/range/algorithm/copy.hpp                 |    41 +
 src/boost/range/algorithm/copy_backward.hpp        |    43 +
 src/boost/range/algorithm/count.hpp                |    50 +
 src/boost/range/algorithm/count_if.hpp             |    51 +
 src/boost/range/algorithm/equal.hpp                |   198 +
 src/boost/range/algorithm/equal_range.hpp          |    80 +
 src/boost/range/algorithm/fill.hpp                 |    49 +
 src/boost/range/algorithm/fill_n.hpp               |    53 +
 src/boost/range/algorithm/find.hpp                 |    80 +
 src/boost/range/algorithm/find_end.hpp             |   152 +
 src/boost/range/algorithm/find_first_of.hpp        |   155 +
 src/boost/range/algorithm/find_if.hpp              |    81 +
 src/boost/range/algorithm/for_each.hpp             |   109 +
 src/boost/range/algorithm/generate.hpp             |    49 +
 src/boost/range/algorithm/heap_algorithm.hpp       |   194 +
 src/boost/range/algorithm/inplace_merge.hpp        |    74 +
 .../range/algorithm/lexicographical_compare.hpp    |    58 +
 src/boost/range/algorithm/lower_bound.hpp          |   124 +
 src/boost/range/algorithm/max_element.hpp          |   115 +
 src/boost/range/algorithm/merge.hpp                |    61 +
 src/boost/range/algorithm/min_element.hpp          |   115 +
 src/boost/range/algorithm/mismatch.hpp             |   195 +
 src/boost/range/algorithm/nth_element.hpp          |    74 +
 src/boost/range/algorithm/partial_sort.hpp         |    76 +
 src/boost/range/algorithm/partial_sort_copy.hpp    |    82 +
 src/boost/range/algorithm/partition.hpp            |    74 +
 src/boost/range/algorithm/permutation.hpp          |   108 +
 src/boost/range/algorithm/random_shuffle.hpp       |    68 +
 src/boost/range/algorithm/remove.hpp               |    74 +
 src/boost/range/algorithm/remove_copy.hpp          |    44 +
 src/boost/range/algorithm/remove_copy_if.hpp       |    38 +
 src/boost/range/algorithm/remove_if.hpp            |    75 +
 src/boost/range/algorithm/replace.hpp              |    53 +
 src/boost/range/algorithm/replace_copy.hpp         |    42 +
 src/boost/range/algorithm/replace_copy_if.hpp      |    46 +
 src/boost/range/algorithm/replace_if.hpp           |    54 +
 src/boost/range/algorithm/reverse.hpp              |    50 +
 src/boost/range/algorithm/reverse_copy.hpp         |    40 +
 src/boost/range/algorithm/rotate.hpp               |    51 +
 src/boost/range/algorithm/rotate_copy.hpp          |    44 +
 src/boost/range/algorithm/search.hpp               |   134 +
 src/boost/range/algorithm/search_n.hpp             |   360 +
 src/boost/range/algorithm/set_algorithm.hpp        |   198 +
 src/boost/range/algorithm/sort.hpp                 |    68 +
 src/boost/range/algorithm/stable_partition.hpp     |    73 +
 src/boost/range/algorithm/stable_sort.hpp          |    68 +
 src/boost/range/algorithm/swap_ranges.hpp          |   132 +
 src/boost/range/algorithm/transform.hpp            |    97 +
 src/boost/range/algorithm/unique.hpp               |   107 +
 src/boost/range/algorithm/unique_copy.hpp          |    51 +
 src/boost/range/algorithm/upper_bound.hpp          |   127 +
 src/boost/range/algorithm_ext.hpp                  |    28 +
 src/boost/range/algorithm_ext/copy_n.hpp           |    53 +
 src/boost/range/algorithm_ext/erase.hpp            |    61 +
 src/boost/range/algorithm_ext/for_each.hpp         |    86 +
 src/boost/range/algorithm_ext/insert.hpp           |    42 +
 src/boost/range/algorithm_ext/iota.hpp             |    54 +
 src/boost/range/algorithm_ext/is_sorted.hpp        |    57 +
 src/boost/range/algorithm_ext/overwrite.hpp        |    84 +
 src/boost/range/algorithm_ext/push_back.hpp        |    40 +
 src/boost/range/algorithm_ext/push_front.hpp       |    40 +
 src/boost/range/any_range.hpp                      |   205 +
 src/boost/range/as_array.hpp                       |    45 +
 src/boost/range/as_literal.hpp                     |   127 +
 src/boost/range/atl.hpp                            |   733 +
 src/boost/range/begin.hpp                          |   143 +
 src/boost/range/category.hpp                       |    29 +
 src/boost/range/combine.hpp                        |   304 +
 src/boost/range/concepts.hpp                       |   366 +
 src/boost/range/config.hpp                         |    54 +
 src/boost/range/const_iterator.hpp                 |    67 +
 src/boost/range/const_reverse_iterator.hpp         |    32 +
 src/boost/range/counting_range.hpp                 |    66 +
 src/boost/range/detail/any_iterator.hpp            |   586 +
 src/boost/range/detail/any_iterator_buffer.hpp     |   117 +
 src/boost/range/detail/any_iterator_interface.hpp  |   258 +
 src/boost/range/detail/any_iterator_wrapper.hpp    |   590 +
 src/boost/range/detail/as_literal.hpp              |    33 +
 src/boost/range/detail/begin.hpp                   |    94 +
 src/boost/range/detail/collection_traits.hpp       |   266 +
 .../range/detail/collection_traits_detail.hpp      |   621 +
 src/boost/range/detail/common.hpp                  |   117 +
 src/boost/range/detail/const_iterator.hpp          |    71 +
 .../range/detail/demote_iterator_traversal_tag.hpp |    91 +
 src/boost/range/detail/detail_str.hpp              |   376 +
 src/boost/range/detail/difference_type.hpp         |   121 +
 src/boost/range/detail/empty.hpp                   |   120 +
 src/boost/range/detail/end.hpp                     |   101 +
 src/boost/range/detail/extract_optional_type.hpp   |    52 +
 src/boost/range/detail/implementation_help.hpp     |   103 +
 src/boost/range/detail/iterator.hpp                |    78 +
 src/boost/range/detail/join_iterator.hpp           |   344 +
 src/boost/range/detail/microsoft.hpp               |   931 +
 src/boost/range/detail/misc_concept.hpp            |    33 +
 src/boost/range/detail/range_return.hpp            |   180 +
 src/boost/range/detail/remove_extent.hpp           |   157 +
 src/boost/range/detail/safe_bool.hpp               |    72 +
 src/boost/range/detail/sfinae.hpp                  |    77 +
 src/boost/range/detail/size.hpp                    |   159 +
 src/boost/range/detail/size_type.hpp               |    55 +
 src/boost/range/detail/sizer.hpp                   |    35 +
 src/boost/range/detail/str_types.hpp               |    38 +
 src/boost/range/detail/value_type.hpp              |    72 +
 src/boost/range/detail/vc6/end.hpp                 |   170 +
 src/boost/range/detail/vc6/size.hpp                |   166 +
 src/boost/range/difference_type.hpp                |    29 +
 src/boost/range/distance.hpp                       |    34 +
 src/boost/range/empty.hpp                          |    34 +
 src/boost/range/end.hpp                            |   136 +
 src/boost/range/functions.hpp                      |    27 +
 src/boost/range/has_range_iterator.hpp             |    62 +
 src/boost/range/irange.hpp                         |   230 +
 src/boost/range/istream_range.hpp                  |    37 +
 src/boost/range/iterator.hpp                       |    72 +
 src/boost/range/iterator_range.hpp                 |    16 +
 src/boost/range/iterator_range_core.hpp            |   650 +
 src/boost/range/iterator_range_io.hpp              |    93 +
 src/boost/range/join.hpp                           |    91 +
 src/boost/range/metafunctions.hpp                  |    31 +
 src/boost/range/mfc.hpp                            |   984 +
 src/boost/range/mutable_iterator.hpp               |    67 +
 src/boost/range/numeric.hpp                        |   118 +
 src/boost/range/pointer.hpp                        |    29 +
 src/boost/range/rbegin.hpp                         |    65 +
 src/boost/range/reference.hpp                      |    29 +
 src/boost/range/rend.hpp                           |    65 +
 src/boost/range/result_iterator.hpp                |    33 +
 src/boost/range/reverse_iterator.hpp               |    40 +
 src/boost/range/reverse_result_iterator.hpp        |    32 +
 src/boost/range/size.hpp                           |    52 +
 src/boost/range/size_type.hpp                      |    89 +
 src/boost/range/sub_range.hpp                      |   182 +
 src/boost/range/value_type.hpp                     |    34 +
 src/common/AnimationRules.cc                       |   267 +
 src/common/AnimationRules.h                        |   165 +
 src/common/Arrow.h                                 |    99 +
 src/common/ArrowProperties.cc                      |    67 +
 src/common/ArrowProperties.h                       |    98 +
 src/common/AutoLock.h                              |    63 +
 src/common/AutoLocker.cc                           |   126 +
 src/common/BackgroundColour.h                      |    65 +
 src/common/BaseParameter.cc                        |    54 +
 src/common/BaseParameter.h                         |   245 +
 src/common/BasePointsHandler.cc                    |    42 +
 src/common/BasePointsHandler.h                     |   175 +
 src/common/BinaryObject.cc                         |    52 +
 src/common/BinaryObject.h                          |    67 +
 src/common/CartesianTransformation.cc              |   242 +
 src/common/CartesianTransformation.h               |   168 +
 src/common/Clipper.h                               |   362 +
 src/common/Colour.cc                               |   529 +
 src/common/Colour.h                                |   207 +
 src/common/ColourTable.cc                          |   106 +
 src/common/ColourTable.h                           |    99 +
 src/common/ColourTableDefinition.h                 |    93 +
 src/common/ColourTableDefinitionCompute.cc         |   159 +
 src/common/ColourTableDefinitionCompute.h          |    77 +
 src/common/ColourTableDefinitionComputeInterface.h |    68 +
 src/common/ColourTableDefinitionList.cc            |   101 +
 src/common/ColourTableDefinitionList.h             |    74 +
 src/common/ColourTableDefinitionListInterface.h    |    63 +
 src/common/Coordinate.cc                           |    55 +
 src/common/Coordinate.h                            |   924 +
 src/common/CustomisedPoint.h                       |   111 +
 src/common/Data.cc                                 |   132 +
 src/common/Data.h                                  |   224 +
 src/common/DataStats.cc                            |   107 +
 src/common/DataStats.h                             |    68 +
 src/common/Decoder.h                               |    64 +
 src/common/Dimension.cc                            |    66 +
 src/common/Dimension.h                             |    71 +
 src/common/DriverStatic.cc                         |    45 +
 src/common/DriverStatic.h                          |    62 +
 src/common/Factory.cc                              |    89 +
 src/common/Factory.h                               |    82 +
 src/common/Flag.cc                                 |    51 +
 src/common/Flag.h                                  |    78 +
 src/common/FortranRootSceneNodeAttributes.h        |    91 +
 src/common/FortranSceneNodeAttributes.h            |    94 +
 src/common/FortranViewNodeAttributes.h             |   109 +
 src/common/Frame.h                                 |    93 +
 src/common/FrameBase.cc                            |    53 +
 src/common/FrameBase.h                             |   116 +
 src/common/FullPaperPoint.h                        |    92 +
 src/common/GeoPoint.h                              |   221 +
 src/common/GeoRectangularProjection.cc             |   684 +
 src/common/GeoRectangularProjection.h              |   222 +
 src/common/GeoRectangularProjectionAttributes.h    |    85 +
 src/common/HeightTableDefinition.h                 |    88 +
 src/common/Image.h                                 |    74 +
 src/common/ImageProperties.h                       |   110 +
 src/common/ImportObject.cc                         |    69 +
 src/common/ImportObject.h                          |    79 +
 src/common/IntervalMap.h                           |   124 +
 src/common/Label.cc                                |    64 +
 src/common/Label.h                                 |   153 +
 src/common/Layout.cc                               |   506 +
 src/common/Layout.h                                |   377 +
 src/common/LevelTableDefinition.h                  |    86 +
 src/common/LogoPlotting.cc                         |   132 +
 src/common/LogoPlotting.h                          |   162 +
 src/common/LogoPlottingAttributes.h                |    80 +
 src/common/LogoPlottingBase.h                      |    46 +
 src/common/MagException.cc                         |    38 +
 src/common/MagException.h                          |   120 +
 src/common/MagExceptions.cc                        |   203 +
 src/common/MagExceptions.h                         |   213 +
 src/common/MagFont.cc                              |    70 +
 src/common/MagFont.h                               |    94 +
 src/common/MagLog.cc                               |   280 +
 src/common/MagLog.h                                |   162 +
 src/common/MagTranslator.h                         |   592 +
 src/common/MagicsCalls.cc                          |  1618 ++
 src/common/MagicsFormat.cc                         |   304 +
 src/common/MagicsFormat.h                          |    47 +
 src/common/MagicsParameter.cc                      |    35 +
 src/common/MagicsParameter.h                       |    91 +
 src/common/MagicsSingleton.h                       |   253 +
 src/common/Makefile.am                             |   119 +
 src/common/Makefile.in                             |   932 +
 src/common/Matrix.cc                               |   436 +
 src/common/Matrix.h                                |   532 +
 src/common/MatrixHandler.h                         |   875 +
 src/common/MetaData.cc                             |   195 +
 src/common/MetaData.h                              |   143 +
 src/common/Mutex.cc                                |   102 +
 src/common/Mutex.h                                 |    71 +
 src/common/MutexCond.cc                            |   115 +
 src/common/MutexCond.h                             |    85 +
 src/common/Node.h                                  |   111 +
 src/common/OutputFactory.cc                        |   267 +
 src/common/OutputFactory.h                         |   303 +
 src/common/OutputHandler.cc                        |   100 +
 src/common/OutputHandler.h                         |   112 +
 src/common/OutputHandlerAttributes.h               |    82 +
 src/common/PageID.cc                               |   119 +
 src/common/PageID.h                                |   134 +
 src/common/PageIDAttributes.h                      |    93 +
 src/common/PaperDimension.h                        |   126 +
 src/common/PaperPoint.h                            |   120 +
 src/common/ParameterManager.cc                     |    62 +
 src/common/ParameterManager.h                      |   309 +
 src/common/Path.h                                  |    91 +
 src/common/PlotManager.h                           |    99 +
 src/common/PointsHandler.cc                        |   172 +
 src/common/PointsHandler.h                         |   202 +
 src/common/PolarStereographicProjection.cc         |  1003 +
 src/common/PolarStereographicProjection.h          |   238 +
 src/common/PolyCoast.h                             |   137 +
 src/common/Polyline.cc                             |   355 +
 src/common/Polyline.h                              |   405 +
 src/common/ProgressObject.h                        |    64 +
 src/common/ProgressTask.h                          |    52 +
 src/common/Proj4Projection.cc                      |  1054 +
 src/common/Proj4Projection.h                       |   305 +
 src/common/RasterData.h                            |   130 +
 src/common/SatelliteProjection.h                   |   142 +
 src/common/SciMethods.cc                           |   318 +
 src/common/SciMethods.h                            |    64 +
 src/common/Seconds.cc                              |    80 +
 src/common/Seconds.h                               |    60 +
 src/common/Static.cc                               |    45 +
 src/common/Static.h                                |    35 +
 src/common/Symbol.cc                               |   302 +
 src/common/Symbol.h                                |   294 +
 src/common/SymbolItem.cc                           |    90 +
 src/common/SymbolItem.h                            |   125 +
 src/common/TableDefinition.h                       |   115 +
 src/common/TableDefinitionCompute.cc               |    76 +
 src/common/TableDefinitionCompute.h                |    77 +
 src/common/TableDefinitionComputeInterface.h       |    67 +
 src/common/TableDefinitionList.cc                  |    65 +
 src/common/TableDefinitionList.h                   |    77 +
 src/common/TableDefinitionListInterface.h          |    65 +
 src/common/Task.cc                                 |    30 +
 src/common/Task.h                                  |    57 +
 src/common/TaylorProjection.cc                     |   216 +
 src/common/TaylorProjection.h                      |   181 +
 src/common/Text.cc                                 |   101 +
 src/common/Text.h                                  |   200 +
 src/common/Thread.cc                               |    51 +
 src/common/Thread.h                                |    78 +
 src/common/ThreadControler.cc                      |   231 +
 src/common/ThreadControler.h                       |    93 +
 src/common/ThreadSingleton.cc                      |    72 +
 src/common/ThreadSingleton.h                       |    66 +
 src/common/Timer.cc                                |   108 +
 src/common/Timer.h                                 |   105 +
 src/common/Tokenizer.cc                            |    70 +
 src/common/Tokenizer.h                             |    70 +
 src/common/Transformation.cc                       |   483 +
 src/common/Transformation.h                        |   375 +
 src/common/UserLogoPlottingAttributes.h            |    89 +
 src/common/UserPoint.h                             |   156 +
 src/common/Visualiser.h                            |    96 +
 src/common/XCoordinate.h                           |    35 +
 src/common/XmlNode.cc                              |   119 +
 src/common/XmlNode.h                               |   108 +
 src/common/XmlReader.cc                            |   206 +
 src/common/XmlReader.h                             |    67 +
 src/common/XmlTree.cc                              |   136 +
 src/common/XmlTree.h                               |    70 +
 src/common/YCoordinate.h                           |    31 +
 src/common/aix.h                                   |   121 +
 src/common/linux.h                                 |   118 +
 src/common/magics_api.h                            |   107 +
 src/common/marsmachine.h                           |   134 +
 src/decoders/BinningObject.cc                      |   147 +
 src/decoders/BinningObject.h                       |   168 +
 src/decoders/BinningObjectAttributes.h             |    94 +
 src/decoders/BoxPlotDecoder.cc                     |    98 +
 src/decoders/BoxPlotDecoder.h                      |    82 +
 src/decoders/ClassicMtgDecoder.cc                  |   672 +
 src/decoders/ClassicMtgDecoder.h                   |   161 +
 src/decoders/Date.cc                               |   325 +
 src/decoders/DateGribLoopStepAttributes.h          |    83 +
 src/decoders/DateTime.cc                           |   185 +
 src/decoders/DateTime.h                            |   359 +
 src/decoders/EfiDataDecoder.h                      |    82 +
 src/decoders/EfiLegendEntry.h                      |   198 +
 src/decoders/EpsBufr.cc                            |   242 +
 src/decoders/EpsBufr.h                             |   101 +
 src/decoders/EpsXmlInput.cc                        |   216 +
 src/decoders/EpsXmlInput.h                         |   107 +
 src/decoders/EpsgramDecoder.cc                     |  1979 ++
 src/decoders/EpsgramDecoder.h                      |   261 +
 src/decoders/GeoPointsDecoder.cc                   |   319 +
 src/decoders/GeoPointsDecoder.h                    |   112 +
 src/decoders/GeoPointsDecoderAttributes.h          |    81 +
 src/decoders/GribAddressMode.h                     |   166 +
 src/decoders/GribDecoder.cc                        |  2030 ++
 src/decoders/GribDecoder.h                         |   352 +
 src/decoders/GribDecoderAttributes.h               |    97 +
 src/decoders/GribInterpretor.h                     |   104 +
 src/decoders/GribLoopAttributes.h                  |    96 +
 src/decoders/GribLoopStep.cc                       |    82 +
 src/decoders/GribLoopStep.h                        |   114 +
 src/decoders/GribRegularInterpretor.cc             |  1403 ++
 src/decoders/GribRegularInterpretor.h              |   185 +
 src/decoders/GribSatelliteInterpretor.cc           |   132 +
 src/decoders/GribSatelliteInterpretor.h            |    71 +
 src/decoders/ImportAction.h                        |   127 +
 src/decoders/ImportActionAttributes.h              |    85 +
 src/decoders/InputData.cc                          |   426 +
 src/decoders/InputData.h                           |   100 +
 src/decoders/InputMatrix.cc                        |   246 +
 src/decoders/InputMatrix.h                         |   103 +
 src/decoders/InputMatrixInterpretor.cc             |   279 +
 src/decoders/InputMatrixInterpretor.h              |   175 +
 src/decoders/LandgramDecoder.cc                    |   190 +
 src/decoders/LandgramDecoder.h                     |    95 +
 src/decoders/LocalTable.cc                         |   107 +
 src/decoders/LocalTable.h                          |   108 +
 src/decoders/Makefile.am                           |   113 +
 src/decoders/Makefile.in                           |   961 +
 src/decoders/MapGenDecoder.cc                      |   118 +
 src/decoders/MapGenDecoder.h                       |    95 +
 src/decoders/MatrixTestDecoder.cc                  |   102 +
 src/decoders/MatrixTestDecoder.h                   |    85 +
 src/decoders/Netcdf.cc                             |   302 +
 src/decoders/Netcdf.h                              |   396 +
 src/decoders/NetcdfConvention.cc                   |    51 +
 src/decoders/NetcdfConvention.h                    |    85 +
 src/decoders/NetcdfDecoder.cc                      |   149 +
 src/decoders/NetcdfDecoder.h                       |   186 +
 src/decoders/NetcdfDecoderAttributes.h             |    82 +
 src/decoders/NetcdfGeoMatrixInterpretor.cc         |   211 +
 src/decoders/NetcdfGeoMatrixInterpretor.h          |    97 +
 .../NetcdfGeoMatrixInterpretorAttributes.h         |    85 +
 .../NetcdfGeoPolarMatrixInterpretorAttributes.h    |    84 +
 .../NetcdfGeoVectorInterpretorAttributes.h         |    84 +
 src/decoders/NetcdfGeopointsInterpretor.cc         |   556 +
 src/decoders/NetcdfGeopointsInterpretor.h          |   148 +
 .../NetcdfGeopointsInterpretorAttributes.h         |    82 +
 src/decoders/NetcdfInterpretor.cc                  |   121 +
 src/decoders/NetcdfInterpretor.h                   |   118 +
 src/decoders/NetcdfInterpretorAttributes.h         |    89 +
 src/decoders/NetcdfMarsConvention.cc               |    55 +
 src/decoders/NetcdfMarsConvention.h                |    63 +
 src/decoders/NetcdfMatrixInterpretor.cc            |   400 +
 src/decoders/NetcdfMatrixInterpretor.h             |   127 +
 src/decoders/NetcdfMatrixInterpretorAttributes.h   |    85 +
 src/decoders/NetcdfOrcaInterpretor.cc              |   326 +
 src/decoders/NetcdfOrcaInterpretor.h               |    80 +
 src/decoders/NetcdfVectorInterpretor.cc            |   240 +
 src/decoders/NetcdfVectorInterpretor.h             |   205 +
 src/decoders/NetcdfVectorInterpretorAttributes.h   |    84 +
 src/decoders/ObsDecoder.cc                         |   752 +
 src/decoders/ObsDecoder.h                          |   115 +
 src/decoders/ObsDecoderAttributes.h                |    85 +
 src/decoders/ObsStatDecoder.cc                     |   291 +
 src/decoders/ObsStatDecoder.h                      |   117 +
 src/decoders/ObsStatDecoderAttributes.h            |    81 +
 src/decoders/ShapeDecoder.cc                       |   467 +
 src/decoders/ShapeDecoder.h                        |   104 +
 src/decoders/SimplePolylineInput.cc                |   119 +
 src/decoders/SimplePolylineInput.h                 |    84 +
 src/decoders/SymbolInput.h                         |   184 +
 src/decoders/TableDecoder.cc                       |   722 +
 src/decoders/TableDecoder.h                        |   123 +
 src/decoders/ThinningMethod.cc                     |   147 +
 src/decoders/ThinningMethod.h                      |   115 +
 src/decoders/Time.cc                               |   203 +
 src/decoders/TitleField.cc                         |    50 +
 src/decoders/TitleField.h                          |    71 +
 src/decoders/TitleMetaField.cc                     |    73 +
 src/decoders/TitleMetaField.h                      |    71 +
 src/decoders/TitleStringField.cc                   |    55 +
 src/decoders/TitleStringField.h                    |    67 +
 src/decoders/TitleTemplate.cc                      |   179 +
 src/decoders/TitleTemplate.h                       |   190 +
 src/decoders/WindMode.cc                           |   119 +
 src/decoders/WindMode.h                            |   157 +
 src/decoders/XYList.cc                             |   300 +
 src/decoders/XYList.h                              |    99 +
 src/decoders/dbfopen.c                             |  1495 ++
 src/decoders/shapefil.h                            |   484 +
 src/decoders/shpopen.c                             |  1866 ++
 src/drivers/BaseDriver.cc                          |   685 +
 src/drivers/BaseDriver.h                           |   503 +
 src/drivers/BaseDriverBinaryReader.cc              |   513 +
 src/drivers/BaseDriverImages.h                     |   480 +
 src/drivers/BaseDriverSymbols.h                    |   541 +
 src/drivers/BaseDriverWind.h                       |   266 +
 src/drivers/BinaryDriver.cc                        |   701 +
 src/drivers/BinaryDriver.h                         |   130 +
 src/drivers/CairoDriver.cc                         |  1471 ++
 src/drivers/CairoDriver.h                          |   159 +
 src/drivers/DriverManager.cc                       |   123 +
 src/drivers/DriverManager.h                        |    75 +
 src/drivers/GDDriver.cc                            |   971 +
 src/drivers/GDDriver.h                             |   161 +
 src/drivers/KMLDriver.cc                           |  1444 ++
 src/drivers/KMLDriver.h                            |   140 +
 src/drivers/Makefile.am                            |   107 +
 src/drivers/Makefile.in                            |  1185 +
 src/drivers/MgQ/MgQ.h                              |    63 +
 src/drivers/MgQ/MgQDriverObject.h                  |    45 +
 src/drivers/MgQ/MgQHistoItem.cc                    |    41 +
 src/drivers/MgQ/MgQHistoItem.h                     |    63 +
 src/drivers/MgQ/MgQLayerItem.cc                    |   612 +
 src/drivers/MgQ/MgQLayerItem.h                     |   172 +
 src/drivers/MgQ/MgQLayoutItem.cc                   |   176 +
 src/drivers/MgQ/MgQLayoutItem.h                    |   160 +
 src/drivers/MgQ/MgQPathItem.cc                     |    80 +
 src/drivers/MgQ/MgQPathItem.h                      |    54 +
 src/drivers/MgQ/MgQPattern.cc                      |   189 +
 src/drivers/MgQ/MgQPattern.h                       |    83 +
 src/drivers/MgQ/MgQPixmapItem.cc                   |    71 +
 src/drivers/MgQ/MgQPixmapItem.h                    |    57 +
 src/drivers/MgQ/MgQPlotScene.cc                    |   550 +
 src/drivers/MgQ/MgQPlotScene.h                     |   144 +
 src/drivers/MgQ/MgQPolylineSetItem.cc              |   216 +
 src/drivers/MgQ/MgQPolylineSetItem.h               |    72 +
 src/drivers/MgQ/MgQRootItem.h                      |    58 +
 src/drivers/MgQ/MgQScene.cc                        |   164 +
 src/drivers/MgQ/MgQScene.h                         |    63 +
 src/drivers/MgQ/MgQSceneCacheItem.cc               |    68 +
 src/drivers/MgQ/MgQSceneCacheItem.h                |    58 +
 src/drivers/MgQ/MgQSceneItem.cc                    |   943 +
 src/drivers/MgQ/MgQSceneItem.h                     |   174 +
 src/drivers/MgQ/MgQStepItem.cc                     |    43 +
 src/drivers/MgQ/MgQStepItem.h                      |    67 +
 src/drivers/MgQ/MgQStepMetaData.cc                 |    80 +
 src/drivers/MgQ/MgQStepMetaData.h                  |    52 +
 src/drivers/MgQ/MgQSymbol.cc                       |   239 +
 src/drivers/MgQ/MgQSymbol.h                        |   131 +
 src/drivers/MgQ/MgQTextItem.cc                     |    61 +
 src/drivers/MgQ/MgQTextItem.h                      |    56 +
 src/drivers/PostScriptDriver.cc                    |  1625 ++
 src/drivers/PostScriptDriver.h                     |   153 +
 src/drivers/QtDriver.cc                            |  2331 ++
 src/drivers/QtDriver.h                             |   209 +
 src/drivers/SVGDriver.cc                           |  1491 ++
 src/drivers/SVGDriver.h                            |   145 +
 src/drivers/System.h                               |    90 +
 src/drivers/minizip/crypt.h                        |   132 +
 src/drivers/minizip/ioapi.c                        |   177 +
 src/drivers/minizip/ioapi.h                        |    75 +
 src/drivers/minizip/zip.c                          |  1219 +
 src/drivers/minizip/zip.h                          |   235 +
 src/libMagWrapper/MagPlus.cc                       |  1601 ++
 src/libMagWrapper/MagPlus.h                        |   136 +
 src/libMagWrapper/MagRequest.h                     |    79 +
 src/libMagWrapper/Makefile.am                      |   132 +
 src/libMagWrapper/Makefile.in                      |  1080 +
 src/libTable/Makefile.am                           |    17 +
 src/libTable/Makefile.in                           |   629 +
 src/libTable/TableReader.cc                        |   702 +
 src/libTable/TableReader.h                         |   210 +
 src/magics.h                                       |   310 +
 src/magics.pc.in                                   |    13 +
 src/magics_config.h                                |   218 +
 src/magics_config.h.in                             |   217 +
 src/magics_ecmwf_log.h                             |    79 +
 src/oda/Makefile.am                                |    24 +
 src/oda/Makefile.in                                |   673 +
 src/oda/ODACalls.cc                                |    39 +
 src/oda/OdaDecoder.cc                              |  1194 +
 src/oda/OdaDecoder.h                               |   178 +
 src/terralib/Makefile.am                           |   138 +
 src/terralib/Makefile.in                           |  1704 ++
 src/terralib/kernel/Gra_algo.h                     |   195 +
 src/terralib/kernel/TeAbstractFactory.h            |   145 +
 src/terralib/kernel/TeAbstractTheme.cpp            |  1255 +
 src/terralib/kernel/TeAbstractTheme.h              |   673 +
 src/terralib/kernel/TeAffineGT.cpp                 |   211 +
 src/terralib/kernel/TeAffineGT.h                   |    94 +
 src/terralib/kernel/TeAffineGTFactory.cpp          |    48 +
 src/terralib/kernel/TeAffineGTFactory.h            |    71 +
 src/terralib/kernel/TeAgnostic.cpp                 |    14 +
 src/terralib/kernel/TeAgnostic.h                   |   395 +
 src/terralib/kernel/TeAsciiFile.cpp                |   363 +
 src/terralib/kernel/TeAsciiFile.h                  |   132 +
 src/terralib/kernel/TeAssertions.h                 |    35 +
 src/terralib/kernel/TeAttribute.h                  |   174 +
 src/terralib/kernel/TeBaseSTInstance.h             |   552 +
 src/terralib/kernel/TeBaseSTInstanceSet.h          |  1212 +
 src/terralib/kernel/TeBox.cpp                      |   213 +
 src/terralib/kernel/TeBox.h                        |   218 +
 src/terralib/kernel/TeBufferRegion.cpp             |  1073 +
 src/terralib/kernel/TeBufferRegion.h               |   156 +
 src/terralib/kernel/TeCentroid.cpp                 |   416 +
 src/terralib/kernel/TeComposite.h                  |   184 +
 src/terralib/kernel/TeCoord2D.h                    |   160 +
 src/terralib/kernel/TeCounted.h                    |    77 +
 src/terralib/kernel/TeDBConnection.cpp             |   619 +
 src/terralib/kernel/TeDBConnection.h               |   207 +
 src/terralib/kernel/TeDBConnectionsPool.cpp        |   403 +
 src/terralib/kernel/TeDBConnectionsPool.h          |   210 +
 src/terralib/kernel/TeDataTypes.h                  |   182 +
 src/terralib/kernel/TeDatabase.cpp                 |  9711 ++++++++
 src/terralib/kernel/TeDatabase.h                   |  1695 ++
 src/terralib/kernel/TeDatabaseFactory.h            |    59 +
 src/terralib/kernel/TeDatabaseFactoryParams.cpp    |    77 +
 src/terralib/kernel/TeDatabaseFactoryParams.h      |    71 +
 src/terralib/kernel/TeDatum.cpp                    |   522 +
 src/terralib/kernel/TeDatum.h                      |   161 +
 src/terralib/kernel/TeDecoder.h                    |   214 +
 src/terralib/kernel/TeDecoderASCIIGrid.cpp         |   416 +
 src/terralib/kernel/TeDecoderASCIIGrid.h           |    97 +
 src/terralib/kernel/TeDecoderDatabase.cpp          |   534 +
 src/terralib/kernel/TeDecoderDatabase.h            |   158 +
 src/terralib/kernel/TeDecoderFile.cpp              |   361 +
 src/terralib/kernel/TeDecoderFile.h                |    84 +
 src/terralib/kernel/TeDecoderMemory.cpp            |   591 +
 src/terralib/kernel/TeDecoderMemory.h              |   279 +
 src/terralib/kernel/TeDecoderMemoryMap.cpp         |   430 +
 src/terralib/kernel/TeDecoderMemoryMap.h           |    94 +
 src/terralib/kernel/TeDecoderSPR.cpp               |   399 +
 src/terralib/kernel/TeDecoderSPR.h                 |    80 +
 src/terralib/kernel/TeDecoderSmartMem.cpp          |   539 +
 src/terralib/kernel/TeDecoderSmartMem.h            |   382 +
 src/terralib/kernel/TeDecoderVirtualMemory.cpp     |   473 +
 src/terralib/kernel/TeDecoderVirtualMemory.h       |   241 +
 src/terralib/kernel/TeDefines.h                    |   238 +
 src/terralib/kernel/TeErrorLog.cpp                 |   184 +
 src/terralib/kernel/TeErrorLog.h                   |   142 +
 src/terralib/kernel/TeErrorMessage.cpp             |    33 +
 src/terralib/kernel/TeErrorMessage.h               |   110 +
 src/terralib/kernel/TeException.cpp                |    52 +
 src/terralib/kernel/TeException.h                  |    72 +
 src/terralib/kernel/TeExternalTheme.cpp            |  1447 ++
 src/terralib/kernel/TeExternalTheme.h              |   422 +
 src/terralib/kernel/TeFactory.h                    |   145 +
 src/terralib/kernel/TeFragmentation.cpp            |   666 +
 src/terralib/kernel/TeFragmentation.h              |    61 +
 src/terralib/kernel/TeGTFactory.cpp                |    32 +
 src/terralib/kernel/TeGTFactory.h                  |    78 +
 src/terralib/kernel/TeGTParams.cpp                 |    86 +
 src/terralib/kernel/TeGTParams.h                   |   186 +
 src/terralib/kernel/TeGeometricTransformation.cpp  |   637 +
 src/terralib/kernel/TeGeometricTransformation.h    |   322 +
 src/terralib/kernel/TeGeometry.cpp                 |   146 +
 src/terralib/kernel/TeGeometry.h                   |   979 +
 src/terralib/kernel/TeGeometryAlgorithms.cpp       |  2834 +++
 src/terralib/kernel/TeGeometryAlgorithms.h         |  1019 +
 src/terralib/kernel/TeGroupingAlgorithms.cpp       |   112 +
 src/terralib/kernel/TeGroupingAlgorithms.h         |   281 +
 src/terralib/kernel/TeImportRaster.cpp             |   687 +
 src/terralib/kernel/TeImportRaster.h               |   105 +
 src/terralib/kernel/TeInitRasterDecoders.cpp       |    77 +
 src/terralib/kernel/TeInitRasterDecoders.h         |    37 +
 src/terralib/kernel/TeIntersector.cpp              |  1056 +
 src/terralib/kernel/TeIntersector.h                |   214 +
 src/terralib/kernel/TeKdTree.h                     |  1190 +
 src/terralib/kernel/TeLayer.cpp                    |  1243 +
 src/terralib/kernel/TeLayer.h                      |   432 +
 src/terralib/kernel/TeLegendEntry.cpp              |   174 +
 src/terralib/kernel/TeLegendEntry.h                |   168 +
 src/terralib/kernel/TeMappedMemory.cpp             |   415 +
 src/terralib/kernel/TeMappedMemory.h               |   232 +
 src/terralib/kernel/TeMatrix.cpp                   |  1540 ++
 src/terralib/kernel/TeMatrix.h                     |   198 +
 src/terralib/kernel/TeMeasure.h                    |    59 +
 src/terralib/kernel/TeMetaModelCache.cpp           |    40 +
 src/terralib/kernel/TeMetaModelCache.h             |   118 +
 src/terralib/kernel/TeMultiContainer.h             |   625 +
 src/terralib/kernel/TeMultiGeometry.cpp            |   267 +
 src/terralib/kernel/TeMultiGeometry.h              |   161 +
 src/terralib/kernel/TeMutex.cpp                    |    59 +
 src/terralib/kernel/TeMutex.h                      |   179 +
 src/terralib/kernel/TeNeighbours.cpp               |   221 +
 src/terralib/kernel/TeNeighbours.h                 |   207 +
 src/terralib/kernel/TeNetwork.cpp                  |   578 +
 src/terralib/kernel/TeNetwork.h                    |   160 +
 src/terralib/kernel/TeOverlay.cpp                  |   763 +
 src/terralib/kernel/TeOverlay.h                    |   214 +
 src/terralib/kernel/TeOverlayUtils.cpp             |  1222 +
 src/terralib/kernel/TeOverlayUtils.h               |   172 +
 src/terralib/kernel/TePieBar.h                     |   317 +
 src/terralib/kernel/TePrecision.h                  |    61 +
 src/terralib/kernel/TeProgress.cpp                 |    37 +
 src/terralib/kernel/TeProgress.h                   |    67 +
 src/terralib/kernel/TeProgressBase.h               |    76 +
 src/terralib/kernel/TeProject.cpp                  |   291 +
 src/terralib/kernel/TeProject.h                    |   176 +
 src/terralib/kernel/TeProjection.cpp               |  2316 ++
 src/terralib/kernel/TeProjection.h                 |   796 +
 src/terralib/kernel/TeProjectiveGT.cpp             |   571 +
 src/terralib/kernel/TeProjectiveGT.h               |   118 +
 src/terralib/kernel/TeProjectiveGTFactory.cpp      |    49 +
 src/terralib/kernel/TeProjectiveGTFactory.h        |    67 +
 src/terralib/kernel/TePrototype.h                  |    83 +
 .../kernel/TeProxMatrixConstructionStrategy.cpp    |   922 +
 .../kernel/TeProxMatrixConstructionStrategy.h      |   491 +
 src/terralib/kernel/TeProxMatrixImplementation.cpp |   498 +
 src/terralib/kernel/TeProxMatrixImplementation.h   |   215 +
 src/terralib/kernel/TeProxMatrixSlicingStrategy.h  |   113 +
 src/terralib/kernel/TeProxMatrixStrategies.cpp     |   296 +
 src/terralib/kernel/TeProxMatrixWeightsStrategy.h  |   168 +
 src/terralib/kernel/TeQuerier.cpp                  |   204 +
 src/terralib/kernel/TeQuerier.h                    |   154 +
 src/terralib/kernel/TeQuerierDB.cpp                |   536 +
 src/terralib/kernel/TeQuerierDB.h                  |   122 +
 src/terralib/kernel/TeQuerierDBStr1.cpp            |  1174 +
 src/terralib/kernel/TeQuerierDBStr1.h              |   123 +
 src/terralib/kernel/TeQuerierDBStr2.cpp            |   350 +
 src/terralib/kernel/TeQuerierDBStr2.h              |   106 +
 src/terralib/kernel/TeQuerierDBStr3.cpp            |   421 +
 src/terralib/kernel/TeQuerierDBStr3.h              |   112 +
 src/terralib/kernel/TeQuerierImpl.cpp              |   144 +
 src/terralib/kernel/TeQuerierImpl.h                |   122 +
 src/terralib/kernel/TeQuerierParams.cpp            |   286 +
 src/terralib/kernel/TeQuerierParams.h              |   233 +
 src/terralib/kernel/TeRTree.h                      |   980 +
 src/terralib/kernel/TeRaster.cpp                   |  1049 +
 src/terralib/kernel/TeRaster.h                     |   525 +
 src/terralib/kernel/TeRasterMemManager.cpp         |   404 +
 src/terralib/kernel/TeRasterMemManager.h           |   240 +
 src/terralib/kernel/TeRasterParams.cpp             |   877 +
 src/terralib/kernel/TeRasterParams.h               |   500 +
 src/terralib/kernel/TeRasterRemap.cpp              |   697 +
 src/terralib/kernel/TeRasterRemap.h                |   131 +
 src/terralib/kernel/TeRasterTransform.cpp          |   136 +
 src/terralib/kernel/TeRasterTransform.h            |   357 +
 src/terralib/kernel/TeRepresentation.cpp           |    34 +
 src/terralib/kernel/TeRepresentation.h             |    78 +
 src/terralib/kernel/TeSTEFunctionsDB.h             |   432 +
 src/terralib/kernel/TeSTElementSet.cpp             |   256 +
 src/terralib/kernel/TeSTElementSet.h               |   125 +
 src/terralib/kernel/TeSTEvent.cpp                  |   207 +
 src/terralib/kernel/TeSTEvent.h                    |   132 +
 src/terralib/kernel/TeSTInstance.cpp               |   353 +
 src/terralib/kernel/TeSTInstance.h                 |   174 +
 src/terralib/kernel/TeSharedPtr.h                  |   435 +
 src/terralib/kernel/TeSingleton.h                  |    67 +
 src/terralib/kernel/TeSlice.h                      |    77 +
 src/terralib/kernel/TeSpatialOperations.cpp        |  1660 ++
 src/terralib/kernel/TeSpatialOperations.h          |   283 +
 src/terralib/kernel/TeStatistics.h                 |   664 +
 src/terralib/kernel/TeStdFile.cpp                  |    60 +
 src/terralib/kernel/TeStdFile.h                    |    84 +
 src/terralib/kernel/TeTable.cpp                    |   376 +
 src/terralib/kernel/TeTable.h                      |   393 +
 src/terralib/kernel/TeTemporalSeries.cpp           |   290 +
 src/terralib/kernel/TeTemporalSeries.h             |   192 +
 src/terralib/kernel/TeTheme.cpp                    |  2493 ++
 src/terralib/kernel/TeTheme.h                      |   443 +
 src/terralib/kernel/TeThread.cpp                   |   263 +
 src/terralib/kernel/TeThread.h                     |   157 +
 src/terralib/kernel/TeThreadDatatypes.h            |    59 +
 src/terralib/kernel/TeThreadFunctor.cpp            |    56 +
 src/terralib/kernel/TeThreadFunctor.h              |   116 +
 src/terralib/kernel/TeThreadParameters.h           |    40 +
 src/terralib/kernel/TeThreadSignal.cpp             |   192 +
 src/terralib/kernel/TeThreadSignal.h               |   141 +
 src/terralib/kernel/TeTime.cpp                     |   631 +
 src/terralib/kernel/TeTime.h                       |   153 +
 src/terralib/kernel/TeTimeInterval.cpp             |   181 +
 src/terralib/kernel/TeTimeInterval.h               |   169 +
 src/terralib/kernel/TeTin.cpp                      |  1796 ++
 src/terralib/kernel/TeTin.h                        |   445 +
 src/terralib/kernel/TeUtils.cpp                    |   660 +
 src/terralib/kernel/TeUtils.h                      |   266 +
 src/terralib/kernel/TeVectorRemap.cpp              |   160 +
 src/terralib/kernel/TeVectorRemap.h                |    86 +
 src/terralib/kernel/TeView.h                       |   233 +
 src/terralib/kernel/TeViewNode.cpp                 |   362 +
 src/terralib/kernel/TeViewNode.h                   |   404 +
 src/terralib/kernel/TeVisual.cpp                   |   258 +
 src/terralib/kernel/TeVisual.h                     |   368 +
 src/terralib/kernel/checkvec.h                     |    71 +
 src/terralib/kernel/dynpq.h                        |   190 +
 src/terralib/kernel/graph.h                        |   379 +
 src/terralib/kernel/lexTemporal.cpp                |  1927 ++
 src/terralib/kernel/showseq.h                      |    23 +
 src/terralib/kernel/yyTemporal.cpp                 |   495 +
 src/terralib/kernel/yyTemporal.h                   |    35 +
 src/terralib/utils/TeDatabaseUtils.h               |   167 +
 src/visualisers/Akima474.cc                        |  1365 +
 src/visualisers/Akima474Method.h                   |   165 +
 src/visualisers/Akima474MethodAttributes.h         |    82 +
 src/visualisers/Akima760.cc                        |  1443 ++
 src/visualisers/Akima760Method.h                   |   173 +
 src/visualisers/Akima760MethodAttributes.h         |    82 +
 src/visualisers/Akima761Method.h                   |   302 +
 src/visualisers/ArrowPlotting.cc                   |   230 +
 src/visualisers/ArrowPlotting.h                    |   101 +
 src/visualisers/AutomaticContourMethod.h           |   311 +
 src/visualisers/Axis.cc                            |   699 +
 src/visualisers/Axis.h                             |   242 +
 src/visualisers/AxisAttributes.cc                  |   463 +
 src/visualisers/AxisAttributes.h                   |   133 +
 src/visualisers/AxisItem.cc                        |   139 +
 src/visualisers/AxisItem.h                         |   170 +
 src/visualisers/AxisMethod.cc                      |   325 +
 src/visualisers/AxisMethod.h                       |   148 +
 src/visualisers/AxisMethodAttributes.cc            |    91 +
 src/visualisers/Bar.cc                             |   417 +
 src/visualisers/Bar.h                              |   165 +
 src/visualisers/BothValuePlotMethod.h              |   118 +
 src/visualisers/BothValuePlotMethodAttributes.cc   |   125 +
 src/visualisers/Boundaries.cc                      |   171 +
 src/visualisers/Boundaries.h                       |   134 +
 src/visualisers/BoundariesAttributes.h             |    93 +
 src/visualisers/BoxPlotBasicItem.h                 |   332 +
 src/visualisers/BoxPlotBoxAttributes.cc            |   146 +
 src/visualisers/BoxPlotBoxBorderAttributes.cc      |   117 +
 src/visualisers/BoxPlotItem.cc                     |   179 +
 src/visualisers/BoxPlotItem.h                      |   231 +
 src/visualisers/BoxPlotMedianAttributes.cc         |   117 +
 src/visualisers/BoxPlotVisualiser.cc               |   102 +
 src/visualisers/BoxPlotVisualiser.h                |    88 +
 src/visualisers/BoxPlotVisualiserAttributes.cc     |   132 +
 src/visualisers/BoxPlotWhiskerBorderAttributes.cc  |   119 +
 src/visualisers/BoxPlotWhiskerBoxAttributes.cc     |   129 +
 src/visualisers/BoxPlotWhiskerLineAttributes.cc    |   118 +
 src/visualisers/CalculateColourTechnique.cc        |    67 +
 src/visualisers/CalculateColourTechnique.h         |    84 +
 .../CalculateColourTechniqueAttributes.h           |    85 +
 src/visualisers/CalmIndicator.h                    |   141 +
 src/visualisers/CdfGraphAttributes.cc              |   137 +
 src/visualisers/CellShading.cc                     |   197 +
 src/visualisers/CellShading.h                      |    96 +
 src/visualisers/CellShadingAttributes.h            |    82 +
 src/visualisers/Cities.cc                          |   193 +
 src/visualisers/Cities.h                           |   134 +
 src/visualisers/CoastPlotting.cc                   |   497 +
 src/visualisers/CoastPlotting.h                    |   215 +
 src/visualisers/CoastPlottingAttributes.h          |    84 +
 src/visualisers/Coastlines.cc                      |   142 +
 src/visualisers/Coastlines.h                       |    86 +
 src/visualisers/CoastlinesAttributes.h             |    86 +
 src/visualisers/ColourSelection.h                  |    88 +
 src/visualisers/ColourSelectionCount.h             |    66 +
 src/visualisers/ColourSelectionList.h              |    66 +
 src/visualisers/ColourTechnique.cc                 |   189 +
 src/visualisers/ColourTechnique.h                  |   136 +
 src/visualisers/ContinuousLegendMethodAttributes.h |    81 +
 src/visualisers/Contour.cc                         |   152 +
 src/visualisers/Contour.h                          |    86 +
 src/visualisers/ContourAttributes.cc               |   206 +
 src/visualisers/ContourAttributes.h                |    93 +
 src/visualisers/ContourLibrary.cc                  |   144 +
 src/visualisers/ContourLibrary.h                   |    59 +
 src/visualisers/ContourMethod.h                    |   101 +
 src/visualisers/CountSelectionType.cc              |   187 +
 src/visualisers/CountSelectionType.h               |    88 +
 src/visualisers/CountSelectionTypeAttributes.h     |    83 +
 src/visualisers/Curve.cc                           |   383 +
 src/visualisers/Curve.h                            |   120 +
 src/visualisers/DateAxis.cc                        |   582 +
 src/visualisers/DateAxis.h                         |   132 +
 src/visualisers/DefinitionTable.cc                 |   128 +
 src/visualisers/DefinitionTable.h                  |    85 +
 src/visualisers/DotPolyShadingMethod.h             |    85 +
 src/visualisers/DotPolyShadingMethodAttributes.h   |    84 +
 src/visualisers/EfiGraphAttributes.cc              |   172 +
 src/visualisers/EpsCloudAttributes.cc              |   110 +
 src/visualisers/EpsForecastPlot.h                  |   136 +
 src/visualisers/EpsGraph.cc                        |  2644 ++
 src/visualisers/EpsGraph.h                         |   413 +
 src/visualisers/EpsGraphAttributes.cc              |   312 +
 src/visualisers/EpsPlumeAttributes.cc              |   166 +
 src/visualisers/EpsShadeAttributes.cc              |   123 +
 src/visualisers/EpsWindAttributes.cc               |   117 +
 src/visualisers/EquidistantTableMode.cc            |   186 +
 src/visualisers/EquidistantTableMode.h             |    73 +
 src/visualisers/Filter.cc                          |   353 +
 src/visualisers/Filter.h                           |   146 +
 src/visualisers/FixedTableModeAttributes.h         |    82 +
 src/visualisers/FlagPlotting.cc                    |   145 +
 src/visualisers/FlagPlotting.h                     |    88 +
 src/visualisers/FloatSelection.h                   |    67 +
 src/visualisers/Graph.h                            |   110 +
 src/visualisers/GraphPlotting.cc                   |    53 +
 src/visualisers/GraphPlotting.h                    |    83 +
 src/visualisers/GraphShade.cc                      |   123 +
 src/visualisers/GraphShade.h                       |   129 +
 src/visualisers/GraphShadeStyle.cc                 |   132 +
 src/visualisers/GraphShadeStyle.h                  |   158 +
 src/visualisers/GribTables.h                       |   153 +
 src/visualisers/GridPlotting.cc                    |   203 +
 src/visualisers/GridPlotting.h                     |   180 +
 src/visualisers/GridPlottingAttributes.h           |    84 +
 src/visualisers/GridShadingAttributes.h            |    81 +
 src/visualisers/HatchPolyShadingMethod.h           |    81 +
 src/visualisers/HatchPolyShadingMethodAttributes.h |    83 +
 src/visualisers/HeightSelection.h                  |    90 +
 src/visualisers/HeightSelectionCount.h             |    66 +
 src/visualisers/HeightSelectionList.h              |    66 +
 src/visualisers/HeightTechnique.cc                 |   133 +
 src/visualisers/HeightTechnique.h                  |   137 +
 src/visualisers/HiLo.cc                            |   171 +
 src/visualisers/HiLo.h                             |   144 +
 src/visualisers/HiLoAttributes.cc                  |   187 +
 src/visualisers/HiLoAttributes.h                   |    92 +
 src/visualisers/HiLoBase.h                         |   113 +
 src/visualisers/HiLoBoth.h                         |   135 +
 src/visualisers/HiLoMarker.h                       |   127 +
 src/visualisers/HiLoMarkerAttributes.h             |    84 +
 src/visualisers/HiLoMarkerBase.h                   |   110 +
 src/visualisers/HiLoNumber.h                       |   110 +
 src/visualisers/HiLoNumberAttributes.h             |    82 +
 src/visualisers/HiLoTechnique.cc                   |    52 +
 src/visualisers/HiLoTechnique.h                    |    94 +
 src/visualisers/HiLoTechniqueAttributes.h          |    85 +
 src/visualisers/HiLoText.h                         |   106 +
 src/visualisers/HiLoTextAttributes.h               |    83 +
 src/visualisers/HistoIndividualMode.h              |    80 +
 src/visualisers/HistoMode.h                        |    98 +
 src/visualisers/HistoTableMode.h                   |    71 +
 src/visualisers/Histogram.cc                       |   343 +
 src/visualisers/Histogram.h                        |   112 +
 src/visualisers/HistogramAttributes.cc             |   175 +
 src/visualisers/HistogramLegendMethodAttributes.h  |    92 +
 src/visualisers/ImageCalculateColourTechnique.h    |    74 +
 src/visualisers/ImageListColourTechnique.h         |    71 +
 src/visualisers/ImagePlotting.cc                   |   292 +
 src/visualisers/ImagePlotting.h                    |    86 +
 src/visualisers/ImagePlottingAttributes.h          |    86 +
 src/visualisers/ImportPlot.h                       |   152 +
 src/visualisers/ImportPlotAttributes.h             |    91 +
 src/visualisers/IntervalSelectionType.cc           |   109 +
 src/visualisers/IntervalSelectionType.h            |    91 +
 src/visualisers/IntervalSelectionTypeAttributes.h  |    82 +
 src/visualisers/Intervals.h                        |    81 +
 src/visualisers/IsoHelper.cc                       |   192 +
 src/visualisers/IsoHelper.h                        |    87 +
 src/visualisers/IsoHighlight.h                     |   155 +
 src/visualisers/IsoHighlightAttributes.h           |    86 +
 src/visualisers/IsoLabel.cc                        |   112 +
 src/visualisers/IsoLabel.h                         |   135 +
 src/visualisers/IsoLabelAttributes.h               |    89 +
 src/visualisers/IsoPlot.cc                         |  1781 ++
 src/visualisers/IsoPlot.h                          |   505 +
 src/visualisers/IsoPlotAttributes.cc               |   222 +
 src/visualisers/IsoPlotAttributes.h                |    97 +
 src/visualisers/IsoShading.cc                      |    91 +
 src/visualisers/IsoShading.h                       |   177 +
 src/visualisers/IsoShadingAttributes.cc            |   149 +
 src/visualisers/IsoShadingAttributes.h             |    86 +
 src/visualisers/LabelPlotting.cc                   |    84 +
 src/visualisers/LabelPlotting.h                    |   169 +
 src/visualisers/LabelPlottingAttributes.h          |    90 +
 src/visualisers/LandgramBox.cc                     |   144 +
 src/visualisers/LandgramBox.h                      |    87 +
 src/visualisers/LegendBoxAttributes.h              |    80 +
 src/visualisers/LegendMethod.cc                    |   126 +
 src/visualisers/LegendMethod.h                     |   159 +
 src/visualisers/LevelListSelectionType.cc          |    80 +
 src/visualisers/LevelListSelectionType.h           |    93 +
 src/visualisers/LevelListSelectionTypeAttributes.h |    81 +
 src/visualisers/LevelSelection.cc                  |   103 +
 src/visualisers/LevelSelection.h                   |   105 +
 src/visualisers/LevelSelectionAttributes.h         |    84 +
 src/visualisers/LinearTableMode.cc                 |   156 +
 src/visualisers/LinearTableMode.h                  |    69 +
 src/visualisers/ListColourTechnique.cc             |    66 +
 src/visualisers/ListColourTechnique.h              |    81 +
 src/visualisers/ListColourTechniqueAttributes.h    |    82 +
 src/visualisers/LookupTableMode.cc                 |   104 +
 src/visualisers/LookupTableMode.h                  |   127 +
 src/visualisers/LookupTableModeAttributes.h        |    83 +
 src/visualisers/Makefile.am                        |   192 +
 src/visualisers/Makefile.in                        |  1192 +
 src/visualisers/MarkerSelection.h                  |    90 +
 src/visualisers/MarkerSelectionCount.h             |    66 +
 src/visualisers/MarkerSelectionList.h              |    66 +
 src/visualisers/MarkerShadingTechnique.cc          |   171 +
 src/visualisers/MarkerShadingTechnique.h           |    97 +
 src/visualisers/MarkerShadingTechniqueAttributes.h |    83 +
 src/visualisers/MarkerValuePlotMethod.h            |   102 +
 src/visualisers/MetgramCurveAttributes.cc          |   137 +
 src/visualisers/MetgramFlagsAttributes.cc          |   116 +
 src/visualisers/MetgramGraph.cc                    |    77 +
 src/visualisers/MetgramGraph.h                     |    88 +
 src/visualisers/MetgramGraphAttributes.cc          |   111 +
 src/visualisers/MetgramStyle.cc                    |   320 +
 src/visualisers/MetgramStyle.h                     |   193 +
 src/visualisers/NoGridPlottingAttributes.h         |    84 +
 src/visualisers/NormalTableMode.cc                 |   166 +
 src/visualisers/NormalTableMode.h                  |    67 +
 src/visualisers/ObsItem.h                          |    96 +
 src/visualisers/ObsItemFamily.cc                   |   801 +
 src/visualisers/ObsItemFamily.h                    |   384 +
 src/visualisers/ObsPlotting.cc                     |   145 +
 src/visualisers/ObsPlotting.h                      |    92 +
 src/visualisers/ObsPlottingAttributes.h            |    81 +
 src/visualisers/ObsStatGraph.h                     |    90 +
 src/visualisers/ObsTable.cc                        |   162 +
 src/visualisers/ObsTable.h                         |   120 +
 src/visualisers/OriginMarker.h                     |   150 +
 src/visualisers/OutLayerTechnique.cc               |    62 +
 src/visualisers/OutLayerTechnique.h                |   117 +
 src/visualisers/PolyShadingMethod.cc               |   203 +
 src/visualisers/PolyShadingMethod.h                |   108 +
 src/visualisers/PolyShadingTechnique.cc            |    70 +
 src/visualisers/PolyShadingTechnique.h             |   171 +
 src/visualisers/PolyShadingTechniqueAttributes.cc  |   117 +
 src/visualisers/PolyShadingTechniqueAttributes.h   |    82 +
 src/visualisers/SampleContourMethodAttributes.h    |    82 +
 src/visualisers/SegmentJoiner.cc                   |   623 +
 src/visualisers/SegmentJoiner.h                    |   155 +
 src/visualisers/ShadingTechnique.h                 |   111 +
 src/visualisers/SimplePolylineVisualiser.cc        |   114 +
 src/visualisers/SimplePolylineVisualiser.h         |    99 +
 src/visualisers/SymbolAdvancedTableMode.cc         |   311 +
 src/visualisers/SymbolAdvancedTableMode.h          |   141 +
 src/visualisers/SymbolIndividualModeAttributes.h   |    98 +
 src/visualisers/SymbolMode.cc                      |   397 +
 src/visualisers/SymbolMode.h                       |   231 +
 src/visualisers/SymbolPlotting.cc                  |   209 +
 src/visualisers/SymbolPlotting.h                   |    91 +
 src/visualisers/SymbolTableModeAttributes.h        |    86 +
 src/visualisers/TaylorGrid.cc                      |   228 +
 src/visualisers/TaylorGrid.h                       |    74 +
 src/visualisers/TextOrientation.cc                 |    53 +
 src/visualisers/TextOrientation.h                  |    93 +
 src/visualisers/Title.h                            |   123 +
 src/visualisers/TitleBase.h                        |   130 +
 src/visualisers/ValuePlot.cc                       |    88 +
 src/visualisers/ValuePlot.h                        |   102 +
 src/visualisers/ValuePlotBase.h                    |   110 +
 src/visualisers/ValuePlotMethod.h                  |   151 +
 src/visualisers/VisDefInfo.cc                      |   253 +
 src/visualisers/VisDefInfo.h                       |   127 +
 src/visualisers/Wind.cc                            |   117 +
 src/visualisers/Wind.h                             |    81 +
 src/visualisers/WindPlotting.cc                    |   168 +
 src/visualisers/WindPlotting.h                     |   126 +
 src/web/MagConfig.cc                               |    90 +
 src/web/MagConfig.h                                |    90 +
 src/web/MagJSon.cc                                 |   171 +
 src/web/MagJSon.h                                  |    75 +
 src/web/Makefile.am                                |    24 +
 src/web/Makefile.in                                |   677 +
 src/web/ObsJSon.cc                                 |   178 +
 src/web/ObsJSon.h                                  |   106 +
 src/web/ObsJSonAttributes.cc                       |   102 +
 src/web/WrepJSon.cc                                |  1127 +
 src/web/WrepJSon.h                                 |   225 +
 src/web/WrepJSonAttributes.cc                      |   228 +
 src/web/json_spirit.h                              |    20 +
 src/web/json_spirit_reader.cpp                     |   755 +
 src/web/json_spirit_reader.h                       |    77 +
 src/web/json_spirit_utils.h                        |    63 +
 src/web/json_spirit_value.cpp                      |     8 +
 src/web/json_spirit_value.h                        |   558 +
 src/web/json_spirit_writer.cpp                     |   329 +
 src/web/json_spirit_writer.h                       |    52 +
 src/xml/ActionRoutines.xml                         |   167 +
 src/xml/Akima.xml                                  |    69 +
 src/xml/Axis.xml                                   |   372 +
 src/xml/BaseDriver.xml                             |    79 +
 src/xml/BinaryDriver.xml                           |    35 +
 src/xml/BinningObject.xml                          |    75 +
 src/xml/BoxPlot.xml                                |   193 +
 src/xml/CairoDriver.xml                            |    22 +
 src/xml/CoastPlotting.xml                          |   233 +
 src/xml/Coastlines.xml                             |    40 +
 src/xml/Contour.xml                                |    94 +
 src/xml/Drivers.xml                                |    26 +
 src/xml/EpsJSon.xml                                |   141 +
 src/xml/Epsgram.xml                                |   812 +
 src/xml/Frame.xml                                  |    45 +
 src/xml/GDDriver.xml                               |    33 +
 src/xml/GeoRectangularProjection.xml               |    63 +
 src/xml/Geopoints.xml                              |   186 +
 src/xml/Grib.xml                                   |   232 +
 src/xml/GridPlotting.xml                           |    71 +
 src/xml/HiLo.xml                                   |   186 +
 src/xml/HiLoMarker.xml                             |    41 +
 src/xml/HiLoNumber.xml                             |    15 +
 src/xml/HiLoTechnique.xml                          |    32 +
 src/xml/HiLoText.xml                               |    23 +
 src/xml/Histogram.xml                              |    79 +
 src/xml/ImagePlotting.xml                          |   264 +
 src/xml/Import.xml                                 |   119 +
 src/xml/InputData.xml                              |    94 +
 src/xml/InputMatrix.xml                            |   151 +
 src/xml/IsoHighlight.xml                           |    43 +
 src/xml/IsoLabel.xml                               |    85 +
 src/xml/IsoPlot.xml                                |    86 +
 src/xml/IsoShading.xml                             |   177 +
 src/xml/KMLDriver.xml                              |    58 +
 src/xml/LabelPlotting.xml                          |    84 +
 src/xml/Landgram.xml                               |    63 +
 src/xml/Layout.xml                                 |    54 +
 src/xml/Legend.xml                                 |   269 +
 src/xml/LevelSelection.xml                         |   107 +
 src/xml/Makefile.am                                |   134 +
 src/xml/Makefile.in                                |   524 +
 src/xml/MetaData.xml                               |    37 +
 src/xml/NetcdfDecoder.xml                          |    47 +
 src/xml/NetcdfInterpretor.xml                      |   249 +
 src/xml/Obs.xml                                    |    26 +
 src/xml/ObsJSon.xml                                |    11 +
 src/xml/ObsPlotting.xml                            |   233 +
 src/xml/ObsStat.xml                                |    32 +
 src/xml/OdaDecoder.xml                             |   100 +
 src/xml/Page.xml                                   |   103 +
 src/xml/PageID.xml                                 |   124 +
 src/xml/PolarStereographicProjection.xml           |   116 +
 src/xml/PostScriptDriver.xml                       |    29 +
 src/xml/Proj4Projection.xml                        |    73 +
 src/xml/QtDriver.xml                               |    39 +
 src/xml/SVGDriver.xml                              |    38 +
 src/xml/SatelliteProjection.xml                    |    19 +
 src/xml/SelectionMode.xml                          |    39 +
 src/xml/SubPage.xml                                |   214 +
 src/xml/SubPageProj4.xml                           |   212 +
 src/xml/SuperPage.xml                              |   183 +
 src/xml/SymbolInput.xml                            |    43 +
 src/xml/SymbolPlotting.xml                         |   441 +
 src/xml/TableDecoder.xml                           |    93 +
 src/xml/Taylor.xml                                 |   193 +
 src/xml/TextVisitor.xml                            |   405 +
 src/xml/Title.xml                                  |    54 +
 src/xml/TitleTemplate.xml                          |    16 +
 src/xml/ValuePlot.xml                              |   130 +
 src/xml/View.xml                                   |   348 +
 src/xml/Wind.xml                                   |   343 +
 src/xml/XYList.xml                                 |   154 +
 src/xml/XYTransformation.xml                       |   267 +
 src/xml/XmlBox.xml                                 |    57 +
 src/xml/XmlPage.xml                                |    39 +
 src/xml/XmlSubPage.xml                             |    46 +
 src/xml/graph_params.xml                           |   233 +
 src/xml/magml.xml                                  |   114 +
 src/xml/output.xml                                 |    16 +
 test/C/Makefile.am                                 |    25 +
 test/C/Makefile.in                                 |   722 +
 test/C/cairo.c                                     |    52 +
 test/C/contours.c                                  |    68 +
 test/C/drivers.c                                   |    40 +
 test/C/land_sea_shade.c                            |    72 +
 test/C/large_area.c                                |    61 +
 test/MagML/Makefile.am                             |     7 +
 test/MagML/Makefile.in                             |   539 +
 test/MagML/drivers.magml                           |   123 +
 test/Makefile.am                                   |    18 +
 test/Makefile.in                                   |   654 +
 test/data/cloudcover.grib                          |   Bin 0 -> 1557480 bytes
 test/data/t2m_fc12.grib                            |   Bin 0 -> 82680 bytes
 test/data/t850_fc_12.grib                          |   Bin 0 -> 9840 bytes
 test/data/uv500.grb                                |   Bin 0 -> 116400 bytes
 test/data/wind30m_fc12.grib                        |   Bin 0 -> 166800 bytes
 test/data/z500.grb                                 |   Bin 0 -> 58200 bytes
 test/data/z500_fc_12.grib                          |   Bin 0 -> 9840 bytes
 test/fortran/Makefile.am                           |    15 +
 test/fortran/Makefile.in                           |   690 +
 test/fortran/boxplot.f                             |   168 +
 test/fortran/coast_only.f                          |    52 +
 test/fortran/layout_test.f                         |   572 +
 test/fortran/shaded_isolines.f                     |   131 +
 test/fortran/wind.f                                |    69 +
 test/python/Makefile.am                            |     7 +
 test/python/Makefile.in                            |   539 +
 test/python/magmacro_example.py                    |    35 +
 test/python/simple.py                              |    33 +
 tools/Makefile.am                                  |     9 +
 tools/Makefile.in                                  |   508 +
 tools/magicsCompatibilityChecker                   |   184 +
 tools/make_attributes                              |   110 +
 tools/mapgen_clip                                  |    53 +
 tools/mergexml.pl                                  |   173 +
 tools/newdriver.pl                                 |   536 +
 tools/xml2cc.pl                                    |   797 +
 tools/xml2cc_new.pl                                |   780 +
 tools/xml2dtd.pl                                   |   174 +
 tools/xml2mv.pl                                    |   563 +
 version.sh                                         |    32 +
 2008 files changed, 489060 insertions(+)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..c247cf4
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,31 @@
+Authors of Magics++
+===================
+
+The main development of Magics++ is done through the 
+
+            Meteorological Visualisation Section
+
+at the
+
+       European Centre for Medium-Range Weather Forecasts
+               (ECMWF - http://www.ecmwf.int )
+
+
+Main programmers:
+=================
+
+Sylvie Lamy-Thepaut
+Stephan Siemen
+Fernando Ii
+Iain Russell
+Sandor Kertesz
+Vesa Karhila
+Peter Bispham
+
+
+Thanks for contributions from:
+==============================
+
+INPE/CPTEC for Terralib
+Carlos Valiente (contributions to configure scripts - magics.m4)
+Anne Fouilloux (first version of the swig Python interface)
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..f4ed7ed
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,201 @@
+                                Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright 2007-2012 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e9bed51
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,3066 @@
+Changes in Magics++ (for developers - users should read 'NEWS')
+===============================================================
+Change 69349 on 2012/02/24 by cgs at cgs
+
+        Magics: Probkem in setting matrix.
+
+Change 69335 on 2012/02/24 by cgs at cgs
+
+        magics:bug in input setting
+
+Change 69334 on 2012/02/24 by cgs at cgs
+
+        Magics: 
+             bug in cell_shading nearest method.
+             Bug in Matrix setting 
+
+Change 69304 on 2012/02/24 by cgs at cgs
+
+        Magics: Curve problem in a succession of regulat=r and data curve!
+
+Change 68898 on 2012/02/22 by cgm at magics_opensuse113
+
+        DRIVERS PostScript backport fix for (HTML) text alignment MAGP-50
+
+Change 68881 on 2012/02/22 by cgs at cgs
+
+        Magics: fix small issues in legend 
+
+Change 68838 on 2012/02/21 by cgs at cgs
+
+        Magics : problem with long time serie
+
+Change 68088 on 2012/02/01 by cgi at cgi_metview_4
+
+        MAG++: updated maintenance branch to use the latest odb_api 0.9.9 (for the purpose of a new Metview 4.1.x internal release)
+
+Change 68067 on 2012/01/31 by cgs at cgs
+
+        Magics: Fix for legend and symboltable mode
+
+Change 67822 on 2012/01/24 by cgm at magics_opensuse113
+
+        VERSION 2.14.10
+
+Change 67258 on 2012/01/19 by cgm at magics_opensuse113
+
+        USE SCRIPTS update for 2.14.9 (using GRIB_API 1.9.14)
+
+Change 67177 on 2012/01/17 by cgm at magics_opensuse113
+
+        LOG clean-up of messages
+
+Change 67118 on 2012/01/16 by cgm at magics_opensuse113
+
+        LICENSE correct license text
+
+Change 67107 on 2012/01/16 by cgm at magics_opensuse113
+
+        DRIVERS KML clean-up minizip code
+
+Change 67103 on 2012/01/16 by cgm at magics_mac
+
+        MAC clean-up of error message (converted it to info)
+
+Change 67087 on 2012/01/16 by cgm at magics_mac
+
+        MAC update compile options
+
+Change 67071 on 2012/01/16 by cgs at cgs
+
+        Magics: Locale cleaning
+
+Change 67064 on 2012/01/16 by cgm at magics_mac
+
+        MAC CONFIG add option to overcome non-c++ aware linker
+
+Change 67017 on 2012/01/13 by cgs at cgs
+
+        Magics: AxisTip position
+
+Change 66793 on 2012/01/10 by cgs at cgs
+
+        Magics: AxisTip positionning + exception pb for static!
+
+Change 66233 on 2012/01/02 by cgm at magics_opensuse113
+
+        CONFIG revert MAC change
+
+Change 66232 on 2012/01/02 by cgm at magics_opensuse113
+
+        CONFIG for Mac (second try)
+
+Change 66230 on 2012/01/02 by cgm at magics_opensuse113
+
+        VERSION update year to 2012
+
+Change 66229 on 2012/01/02 by cgm at magics_opensuse113
+
+        MAC put back link option
+
+Change 66228 on 2012/01/02 by cgm at magics_opensuse113
+
+        CONFIG update GRIB_API to version 1.9.14
+
+Change 66099 on 2011/12/19 by cgm at magics_opensuse113
+
+        DOCS clean-up
+
+Change 66094 on 2011/12/19 by cgs at cgs
+
+        Integrate bug fix in default colour for isoline label.
+
+Change 66068 on 2011/12/18 by cgm at magics_opensuse113
+
+        INTEGRATE from main (2.15.0) to fix 10m resolution (admin) boundaries
+
+Change 65980 on 2011/12/15 by cgm at magics_opensuse113
+
+        BOUNDARIES fix missing file error message reported by Iain on Metview
+
+Change 65926 on 2011/12/14 by cgr at cgr
+
+        MAG+ Integrate from main:  Apply "%d" formatting for integer values that can be casted into an integer when "(automatic)" format is used in symbol plotting.
+
+Change 65878 on 2011/12/13 by cgs at cgs
+
+        Integration change: box border off
+
+Change 65849 on 2011/12/12 by cgm at magics_opensuse113
+
+        VERSION 2.14.9
+
+Change 65847 on 2011/12/12 by cgm at cgm_meshon
+
+        RPMS remove /usr/lib/Magics directory from installation
+
+Change 65846 on 2011/12/11 by cgm at magics_opensuse113
+
+        PYTHON fix make check
+
+Change 65845 on 2011/12/11 by cgm at cgm_meshon
+
+        PYTHON restructure swig directory to fix problems reported by MPI Hamburg
+
+Change 65844 on 2011/12/11 by cgm at cgm_meshon
+
+        PYTHON clean-up of makefile (remove unused installation directory)
+
+Change 65842 on 2011/12/10 by cgm at cgm_meshon
+
+        INTEGRATE fix for disputed boundaries back into 2.14 (Kosovo)
+
+Change 65638 on 2011/12/02 by cgs at cgs
+
+        Magics : add a warning when map_coastline_resolution is set to high or medium 
+
+Change 65637 on 2011/12/02 by cgm at magics_opensuse113
+
+        CONFIG give simple version number for magics-config --version and set project name to Magics (instead of Magics++) 
+
+Change 65627 on 2011/12/02 by cgs at cgs
+
+        Magics typo
+
+Change 65625 on 2011/12/02 by cgs at cgs
+
+        Integration change.
+
+Change 65613 on 2011/12/02 by cgs at cgs
+
+        Magics: integration
+
+Change 65605 on 2011/12/02 by cgs at cgs
+
+        Magics Small adjustement in lefgend
+
+Change 65602 on 2011/12/02 by cgs at cgs
+
+        Integration change.
+
+Change 65586 on 2011/12/01 by cgs at cgs
+
+        Magics integrate change for legend_histogram
+
+Change 65570 on 2011/12/01 by cgs at cgs
+
+        Magics: symbol_input_marker_list
+
+Change 65565 on 2011/12/01 by cgs at cgs
+
+        Magics .. Integration change.
+
+Change 65511 on 2011/11/30 by cgm at magics_opensuse113
+
+        VERSION 2.14.8
+
+Change 65482 on 2011/11/29 by cgs at cgs
+
+        Metview/magics: integrate!
+
+Change 65465 on 2011/11/29 by cgs at cgs
+
+        Magics: more station on Classic metgrams
+
+Change 65462 on 2011/11/29 by cgs at cgs
+
+        Magics: adjustement in positioning!
+
+Change 65457 on 2011/11/29 by cgs at cgs
+
+        Magics/Metgram: Add Skopje(MK) in classic metgram template
+
+Change 65455 on 2011/11/29 by cgs at cgs
+
+        Magics: fallback behaviour if info for obs/centre not found. 
+
+Change 65441 on 2011/11/28 by cgs at cgs
+
+        Magics: Observation plotting improvment + gloabl reduced gaussian grids.
+
+Change 65411 on 2011/11/27 by cgm at magics_opensuse113
+
+        PCLOSE clean-up for footer
+
+Change 65358 on 2011/11/25 by cgr at cgr
+
+        Integrate from main: Meta-data collector can now access grib scaling information.
+
+Change 65341 on 2011/11/24 by cgm at magics_opensuse113
+
+        LOGGING flush output properly
+
+Change 65336 on 2011/11/24 by cgm at magics_opensuse113
+
+        LOGGING reposition the footer after all processing
+
+Change 65328 on 2011/11/24 by cgm at magics_opensuse113
+
+        COLOUR HSL sets now alpha if not given
+
+Change 65327 on 2011/11/24 by cgm at magics_opensuse113
+
+        VERSION 2.14.7
+
+Change 65309 on 2011/11/23 by cgs at cgs
+
+        Stupid pclose
+
+Change 65298 on 2011/11/23 by cgm at magics
+
+        Remove random character
+
+Change 65296 on 2011/11/23 by cgs at cgs
+
+        More on pclose 
+
+Change 65283 on 2011/11/23 by cgm at magics_opensuse113
+
+        LAYOUT fix bug obstat plots
+
+Change 65280 on 2011/11/23 by cgm at magics_opensuse113
+
+        VERSION 2.14.6  &  USE SCRIPTS
+
+Change 65236 on 2011/11/22 by cgi at cgi_metview_4
+
+        MAG++: GeoPoints version of the table decoder now takes delimiter parameters into account [2.14 branch]
+
+Change 65233 on 2011/11/22 by cgs at cgs_metview
+
+        Magics: axis_minor_tick_count fixed.
+
+Change 65214 on 2011/11/22 by cgm at magics_opensuse113
+
+        DRIVERS reverse symbol plotting before outline was added ... was leaking (reported by Luciana) 
+
+Change 65183 on 2011/11/21 by cgm at magics_opensuse113
+
+        RPMS add dependency to gd-devel for installation
+
+
+Change 65173 on 2011/11/20 by cgm at magics_opensuse113
+
+    NEW BRANCH r2.14 (used by emos)
+
+Change 65171 on 2011/11/20 by cgm at magics_opensuse113
+
+    VERSION 2.14.5
+
+Change 65169 on 2011/11/20 by cgm at magics_opensuse113
+
+    DRIVERS SVG optimise file size by writing hex color codes
+
+Change 65162 on 2011/11/19 by cgm at magics_opensuse113
+
+    DRIVERS SVG optimise rendering of image data
+
+Change 65154 on 2011/11/18 by cgs at cgs_metview
+
+    missing value
+
+Change 65152 on 2011/11/18 by cgm at magics_opensuse113
+
+    DRIVERS symbols - make sure calour is set before line style is set
+
+Change 65151 on 2011/11/18 by cgs at cgs_metview
+
+    Magics: legend can be turned off for a wind action
+                implement graph_x_missing_value graph_y_missing_value
+
+Change 65149 on 2011/11/18 by cgm at magics_opensuse113
+
+    DRIVERS CAIRO put back plotting of cell array (wrong transparency values were causing problems) 
+
+Change 65148 on 2011/11/18 by cgm at magics_opensuse113
+
+    DRIVERS SVG reduce file size if cell array is used
+
+Change 65147 on 2011/11/18 by cgm at magics_opensuse113
+
+    DRIVERS SVG set default to NOT use external files if possible
+
+Change 65143 on 2011/11/18 by cgr at cgr
+
+    MAG++ DRIVERS symbols and their outlines are now rendered together
+
+Change 65140 on 2011/11/18 by cgm at magics_opensuse113
+
+    RPMS update spec files after succesfull RPM builds for 2.14
+
+Change 65137 on 2011/11/17 by cgm at magics_opensuse113
+
+    VERSION 2.14.4
+
+Change 65135 on 2011/11/17 by maf at belleus
+
+    change to landsea to make GreatLakes behave themselves
+
+Change 65134 on 2011/11/17 by cgm at magics_opensuse113
+
+    SRC-XML reorder tags into lines
+
+Change 65124 on 2011/11/17 by cgr at cgr
+
+    MAG++ DRIVERS add symbol outlines 
+
+Change 65121 on 2011/11/17 by cgm at magics_opensuse113
+
+    DRIVERS contour label positioning - trial to avoid too many labels at biginning of contour
+
+Change 65120 on 2011/11/17 by cgm at magics_opensuse113
+
+    BOUNDARIES hardcode min resolution to 50m until we fix 10m 
+
+Change 65117 on 2011/11/17 by maf at belleus
+
+    Modified shape files as follows:
+       - Redownloaded older (version 1.2) copies of naturalearthdata 10m physical files
+       - Renamed these files to resemble those in 50m and 110m cases (e.g. ne_xxxxx.shp)
+       - The 110m and 50m are downloaded from natura
+
+Change 65084 on 2011/11/16 by cgr at cgr
+
+    Histogram preview can now be generated by using a specified visdef. If no visdef is specified the whole data value range is used to generate the histogram preview.
+
+Change 65028 on 2011/11/15 by cgm at magics_opensuse113
+
+    DRIVERS add symbol outlines
+
+Change 65024 on 2011/11/15 by cgm at magics_opensuse113
+
+    COASTLINES reduce files for installation and changed the way we do land/sea shading
+
+Change 65022 on 2011/11/15 by cgm at magics_opensuse113
+
+    COASTLINES commented out not needed Boost header file
+
+Change 65014 on 2011/11/15 by cgm at magicsIBM
+
+    AIX remove warning message
+
+Change 64993 on 2011/11/15 by cgm at magics_opensuse113
+
+    CONFIG add comment about possible additional dependencies (such as PNG) to error message of Grib_API could not be linked - SUP-20
+
+Change 64992 on 2011/11/15 by cgm at magics_opensuse113
+
+    MAKE add missing file for tarball
+
+Change 64990 on 2011/11/15 by cgi at cgi_metview_4
+
+    MAG++: changed ODA/B lib path to the version installed for Metview
+
+Change 64944 on 2011/11/14 by cgm at magics_opensuse113
+
+    VERSION 2.14.3
+
+Change 64927 on 2011/11/14 by cgm at magics_opensuse113
+
+    DRIVERS PS revert calculations on dimension
+
+Change 64918 on 2011/11/14 by cgh at mv_vesa4-32
+
+    add code to cope with NCEP PrepBUFR files
+
+Change 64916 on 2011/11/14 by cgm at magics_opensuse113
+
+    DRIVERS PS scaling for Binary
+
+Change 64915 on 2011/11/14 by cgm at magics_opensuse113
+
+    PROJECTIONS Mercator extend to 89 degree in latitude (from 85)
+
+Change 64914 on 2011/11/14 by cgm at cgm_meshon
+
+    DRIVERS comment unused variable
+
+Change 64913 on 2011/11/13 by cgm at magics_lxa
+
+    CONFIG enable SPOT on LXAB
+
+Change 64912 on 2011/11/13 by cgm at magics_opensuse113
+
+    MAKE remove not needed files from share directory
+
+Change 64910 on 2011/11/13 by cgm at cgm_orion
+
+    CONFIG improve reporting of missing dependencies for Boost and Cairo - MAGP-5
+
+Change 64909 on 2011/11/13 by cgm at magics_opensuse113
+
+    DRIVER PS reduce file size by removing comments
+
+Change 64908 on 2011/11/13 by cgm at magics_opensuse113
+
+    DRIVERS SVG fix offset problem which we say with legends in plumes
+
+Change 64907 on 2011/11/13 by cgm at magics_opensuse113
+
+    DRIVERS SVG fix logo
+
+Change 64885 on 2011/11/11 by cgs at cgs_lxab
+
+    Global efi patch : update navigation
+
+Change 64880 on 2011/11/11 by cgm at magics_opensuse113
+
+    CONFIG remove -O0 for debug
+
+Change 64875 on 2011/11/11 by cgs at cgs_metview
+
+    Patch for glovbal efi
+
+Change 64806 on 2011/11/10 by cgr at cgr
+
+    Increase histogram preview size in the QtDriver.
+
+Change 64805 on 2011/11/10 by cgr at cgr
+
+    Meta-data collector statictics and histogram for gribs are now computed using the visualised grid points only.
+
+Change 64804 on 2011/11/10 by cgs at cgs
+
+    Magics: added 2 parameters to tune contouring for noisy fields.
+
+Change 64754 on 2011/11/09 by cgs at cgs_metview
+
+    Magics: temporary increase in IsoPlot! 
+
+Change 64752 on 2011/11/09 by cgs at cgs_metview
+
+    Magics: netcdf + boundaries
+
+Change 64728 on 2011/11/09 by maf at belleus
+
+    html changes for circles
+
+Change 64727 on 2011/11/09 by maf at belleus
+
+    fancy circle-type error indicators on overview pages
+
+Change 64699 on 2011/11/08 by cgs at cgs_lxab_debug
+
+    Magics/Python
+
+Change 64697 on 2011/11/08 by maf at belleus
+
+    Added colour-coded summary information to the top-level summary pages on the number of tests that failed.
+
+Change 64695 on 2011/11/08 by cgm at magics_opensuse113
+
+    CONFIG improve testing for Boost and Boost::Math
+
+Change 64694 on 2011/11/08 by cgm at magics_opensuse113
+
+    CONFIG remove spaces at end of line (caused error)
+
+Change 64687 on 2011/11/08 by cgm at magics_opensuse113
+
+    DRIVERS PS adjust page dimension for Binary
+
+Change 64683 on 2011/11/08 by cgr at cgr
+
+    Improved histrogram rendering for the histogram preview in Metview.
+
+Change 64681 on 2011/11/08 by cgr at cgr
+
+    Enabled valuescollector to strore data for both the unscaled and scaled fields.
+
+Change 64679 on 2011/11/08 by cgr at cgr
+
+    Increased histogram pixmap size in the QtDriver.
+
+Change 64668 on 2011/11/08 by cgr at cgr
+
+    Increased horizontal size for histogram preview in the QtDriver.
+
+Change 64666 on 2011/11/08 by cgs at cgs_lxab_debug
+
+    Magics: More in legend_user_text and curve
+
+Change 64664 on 2011/11/08 by cgs at cgs_metview
+
+    Magics: Legend user text bug fix
+
+Change 64661 on 2011/11/08 by cgr at cgr
+
+    Added curve plotting for ODB.
+
+Change 64660 on 2011/11/08 by cgr at cgr
+
+    Use double precision to store positions for symbol plotting in the Qt Driver.
+
+Change 64633 on 2011/11/07 by maf at belleus
+
+    some cleanup
+
+Change 64632 on 2011/11/07 by cgm at magics_opensuse113
+
+    DRIVERS PS add binary dimenesions
+
+Change 64631 on 2011/11/07 by maf at belleus
+
+    Suite name now comes from the name of the config file that created it.
+    Existing suties on the server with the same name may be overwritten with --force
+                      otherwise the suite submission fails gracefully if name conflict.
+    No longer clea
+
+Change 64617 on 2011/11/05 by cgm at cgm_orion
+
+    DRIVERS SVG optimisation for horizontal and vertical segments in paths
+
+Change 64616 on 2011/11/05 by cgm at cgm_orion
+
+    DRIVERS Binary - prober eror message if MGB file can not be opened
+
+Change 64614 on 2011/11/04 by maf at belleus
+
+    added instructions on how to run the server locally
+
+Change 64609 on 2011/11/04 by maf at belleus
+
+    - Un-hard-coded the available diff programs. Can now add and remove as necessary.
+    - Added a working folder to the settings. Solved problem with suite running on consecutive days.
+    - Added additional information to the summary page so that user can dec
+
+Change 64546 on 2011/11/02 by cgr at cgr
+
+    Save the current step for each scene item before the new request is applied in the QtDriver 
+
+Change 64528 on 2011/11/02 by cgr at cgr
+
+    Save the current step for each scene item before the new request is applied in the QtDriver 
+
+Change 64526 on 2011/11/01 by cgm at cgm_orion
+
+    WREP BinaryDriver - add more nice text options (for plumes)
+
+Change 64519 on 2011/11/01 by cgs at cgs_metview
+
+    Magics: Clipping bug
+
+Change 64512 on 2011/11/01 by cgs at cgs_metview
+
+    Magics/Migration: add patch for global EFI
+
+Change 64511 on 2011/11/01 by cgs at cgs_metview
+
+    MOS presentation
+
+Change 64510 on 2011/11/01 by cgi at cgi_metview_4
+
+    MV4: added MOS workshop 2011 presentation 'Metview 4: Enhanced functionalities for observation monitoring'
+
+Change 64476 on 2011/10/31 by maf at belleus
+
+           Contains the following additions:
+    - percentage-based tolerance checking for pixel differences.
+    - summary of all differences found appears on the test summary page
+
+Change 64449 on 2011/10/30 by cgm at magics_opensuse113
+
+    PPTX slides for MOS Magics presentation (1st Draft)
+
+Change 64433 on 2011/10/28 by maf at belleus
+
+    the verbose flag went away somewhere. reinstated
+
+Change 64429 on 2011/10/28 by maf at belleus
+
+    Many examples stolen from Iain's test suite added. convert.sh does the theft automatically
+
+Change 64428 on 2011/10/28 by maf at belleus
+
+    Added pdiff output and colour coding to the html output
+
+Change 64427 on 2011/10/28 by maf at belleus
+
+    Added pdiff build files and dependent library FreeImage
+    NB I have removed .NET and other examples from FreeImage prior to submit as these are not needed.
+    NB A correction was necessary to perceptualdiff/Metric.cpp to include cstdio
+    Run the build.sh sc
+
+Change 64424 on 2011/10/28 by cgs at cgs
+
+    Magics: more on page_id_line_magics
+
+Change 64423 on 2011/10/28 by cgs at cgs_metview
+
+    Magics: stupid print
+
+Change 64421 on 2011/10/28 by cgs at cgs_metview
+
+    Magics: Boundaries are back + page_id_line_magics
+
+Change 64402 on 2011/10/27 by cgm at magics_opensuse113
+
+    VERSION 2.14.2
+
+Change 64388 on 2011/10/26 by cgm at magics_opensuse113
+
+    WARNING cleanup alignment
+
+Change 64386 on 2011/10/26 by cgm at magics_opensuse113
+
+    SWIG fix for tarball - remove references to old files
+
+Change 64385 on 2011/10/26 by cgm at magics_opensuse113
+
+    SWIG clean-up of Python interface for numpy types (reported by Oxford and with help of Cristian)
+
+Change 64383 on 2011/10/26 by cgs at cgs_metview
+
+    magics : warning are back in pure Magics
+                 add taylor in python interface
+
+Change 64368 on 2011/10/26 by cgs at cgs_metview
+
+    Magics: user logo deprecated
+
+Change 64352 on 2011/10/26 by cgm at magics_opensuse113
+
+    DOCS remove hidden characters
+
+Change 64351 on 2011/10/25 by cgm at cgm_meshon
+
+    CONFIG AIX clean-up call to bash
+
+Change 64350 on 2011/10/25 by cgm at cgm_meshon
+
+    CONFIG AIX boost test
+
+Change 64330 on 2011/10/25 by cgm at magics_opensuse113
+
+    CONFIG add test for curl and boost - disabled Proj4 by default
+
+Change 64317 on 2011/10/25 by cgr at cgr
+
+    Changed formula in BaseDriver to compute the distance between isoline labels. The new formula is now based on the absolute value of the coordinate value ranges.
+
+Change 64309 on 2011/10/25 by cgr at cgr
+
+    Check thinning values and revert them back to 1 if they are less than 1.
+
+Change 64305 on 2011/10/25 by cgr at cgr
+
+    Assinged the x and y datasets to the correct axes for xy odb plots. Previously the axes were swapped.
+
+Change 64280 on 2011/10/24 by cgs at cgs_metview
+
+    Magics/Wrep: Globalefi -> add patch for producing old javascript for the globalefi plots! 
+
+Change 64278 on 2011/10/24 by cgs at cgs_metview
+
+    Magics/Metview : Coastlines resolution MEDIUM is not reset systematically to automatic 
+
+Change 64258 on 2011/10/24 by cgs at cgs_metview
+
+    Wrep/Magics: Efi patch
+
+Change 64257 on 2011/10/24 by cgs at cgs_metview
+
+    Magics: legend + input mssing value
+
+Change 64256 on 2011/10/24 by cgr at cgr
+
+    Do not use antialiasing for filled polygons in the Qt Driver if the polygon outine is not rendered. Otherwise "ghost lines" appear in the plot along the shared polygon borders due to the antialiasing algorythm that Qt uses.
+
+Change 64252 on 2011/10/24 by maf at belleus
+
+    Added some plots from wrep/main/services/apps/plot that seem to work
+
+Change 64244 on 2011/10/24 by cgs at cgs_metview
+
+    Magics/Metview: coastlines_resolution + mssing value for table decoder
+
+Change 64238 on 2011/10/23 by cgm at cgm_meshon
+
+    SRC remove compiler warnings
+
+Change 64237 on 2011/10/23 by cgm at cgm_orion
+
+    SRC add name to layers
+
+Change 64216 on 2011/10/21 by cgs at cgs_metview
+
+    Magics: logarithmic axis
+    + Wrep Epsgram 
+
+Change 64210 on 2011/10/21 by cgr at cgr
+
+    Delete the painter first then the device for pixmap cache resizing in the Qt scene. Otherwise Qt crashes.
+
+Change 64209 on 2011/10/21 by cgr at cgr
+
+    Made transparency work for resized scenes in the QtDriver.
+
+Change 64185 on 2011/10/20 by maf at belleus
+
+    Removed as automated testing now done using ecflow
+
+Change 64178 on 2011/10/20 by cgr at cgr
+
+    Add obsmon seminar to docs.
+
+Change 64174 on 2011/10/20 by maf at belleus
+
+    Added that darn css file
+
+Change 64173 on 2011/10/20 by maf at belleus
+
+    Changes to allow colour-coding of results.
+      - altered the way error reporting is done
+      - changes to html
+      - inclusion of css file for common formatting across pages
+
+Change 64168 on 2011/10/20 by maf at belleus
+
+    removing output file from perforce which caused test to fail to write over the write-protected file
+
+Change 64165 on 2011/10/20 by maf at belleus
+
+    New test from SLT added
+
+Change 64161 on 2011/10/19 by cgm at cgm_orion
+
+    DRIVERS SVG remove spaces and set version back to 1.1 'full'
+
+Change 64160 on 2011/10/19 by cgm at cgm_orion
+
+    DRIVERS add debug information if text number mismatches symbols
+        (WREP problem in citis layer)
+
+Change 64158 on 2011/10/19 by cgs at cgs_metview
+
+    Magics/Metview: Input data and missing value
+
+Change 64155 on 2011/10/19 by cgs at cgs_metview
+
+    Magics/Wrep: Classic 10 days! 
+
+Change 64122 on 2011/10/19 by cgs at cgs_metview
+
+    magics: compilation error10.3
+
+Change 64117 on 2011/10/18 by cgs at cgs_metview
+
+    Magics/Metview : Geoline and Hov data
+
+Change 64115 on 2011/10/18 by maf at belleus
+
+    Added script to start ecflow on local or remote host according to settings stored in configuration files.
+
+Change 64114 on 2011/10/18 by maf at belleus
+
+    added repeated daily running of suite
+
+Change 64103 on 2011/10/18 by cgm at cgm_orion
+
+    DRIVERS SVG magnifier is back working and layer ticks are replace with buttons
+
+Change 64100 on 2011/10/18 by cgs at cgs_metview
+
+    Magics: Ajustement on polar stereographic labels
+
+Change 64090 on 2011/10/18 by cgs at cgs_metview
+
+    Magics: adjust label on PolarProjection
+
+Change 64079 on 2011/10/17 by cgm at cgm_orion
+
+    DRIVERS SVG put 1.2 tiny header and little clean-up
+
+Change 64078 on 2011/10/17 by cgm at cgm_orion
+
+    DRIVERS SVG - Introduce polygon grouping + removed empty id parameters
+       put 'non-scaling-stroke' in global group
+
+Change 64067 on 2011/10/17 by cgs at cgs_lxab
+
+    Magics: Text adjustement  
+
+Change 64066 on 2011/10/17 by maf at belleus
+
+    changed name of limit
+
+Change 64065 on 2011/10/17 by maf at belleus
+
+    Modified code to allow several versions of Magics to run concurrently
+    thus improving performence. Added triggers to the initialisation and summarising
+    tasks to ensure proper operation.
+
+Change 64062 on 2011/10/17 by maf at belleus
+
+    deleted tmp file 
+
+Change 64054 on 2011/10/17 by maf at belleus
+
+    added new tests from Sylvie
+
+Change 64052 on 2011/10/17 by maf at belleus
+
+    added imagemagick error output to the error log for each test
+
+Change 64044 on 2011/10/17 by cgm at cgm_orion
+
+    DRIVERS SVG hardcode filling to 'evenodd'
+
+Change 64041 on 2011/10/17 by cgm at magics_opensuse113
+
+    VERSION 2.14.1
+
+Change 64040 on 2011/10/17 by cgm at cgm_orion
+
+    DRIVERS SVG reduce stroke between transparent fill areas
+
+Change 64039 on 2011/10/17 by maf at belleus
+
+    do not remove output folder rather allow result folders to build over time
+
+Change 64038 on 2011/10/17 by maf at belleus
+
+    altered run time
+
+Change 64037 on 2011/10/17 by cgs at cgs_metview
+
+    Magics/Metview : More on netcdf cleaning
+
+Change 64036 on 2011/10/17 by cgs at cgs_metview
+
+    Magics: more on legend... cleaning of  necdf parameters
+
+Change 64034 on 2011/10/14 by cgm at cgm_orion
+
+    DRIVERS SVG add transparency for shadig and set right shading method 
+    (both for WREP)
+
+Change 64030 on 2011/10/14 by cgm at magics_opensuse113
+
+    DOCS first ODF version
+
+Change 64028 on 2011/10/14 by maf at belleus
+
+    altered run time
+
+Change 64027 on 2011/10/14 by maf at belleus
+
+    Added settings file to config. This allows specification of:
+      input folder (where the tests are)
+      output folder
+      verbose setting
+      time when suite is to be run
+      tolerance for significant image difference in pixels
+      ecflow server and port
+    Script 
+
+Change 64010 on 2011/10/14 by maf at belleus
+
+    renamed conf to config for clarity.
+    added configurable image difference threshold for ignoring minor difference (defaults to 50 pixels)
+    imagemagick location now got from the system rather than hard-coded
+
+Change 64001 on 2011/10/14 by cgm at magics_opensuse113
+
+    VERSION 2.14.0
+
+Change 64000 on 2011/10/14 by cgm at magics_opensuse113
+
+    MAKE disable C++ linking (was needed for mac)
+
+Change 63999 on 2011/10/14 by cgm at magics_opensuse113
+
+    CONFIG add proj4 to paths
+
+Change 63998 on 2011/10/14 by cgm at magics_opensuse113
+
+    USE SCRIPTS for 2.13.10 release
+
+Change 63991 on 2011/10/13 by cgr at cgr
+
+    Clear the list storing the latest currentStep value for the scene items in the QtDriver.
+
+Change 63989 on 2011/10/13 by maf at belleus
+
+    piffling text change
+
+Change 63988 on 2011/10/13 by cgs at cgs_metview
+
+    Magics : MagicsObserver
+
+Change 63987 on 2011/10/13 by maf at belleus
+
+    removed debug output
+
+Change 63986 on 2011/10/13 by maf at belleus
+
+    Added schedule run time to the suite
+    Added error output and diff fields to the output html documents
+
+Change 63983 on 2011/10/13 by maf at belleus
+
+    Modifications to output html
+    Support for version names like current++ rather than 2.13.9. These had previously caused issues with ecflow.
+    Fixed issues in output where images missing. Now we show all images produced even if some missing.
+    Better handli
+
+Change 63980 on 2011/10/13 by cgs at cgs_metview
+
+    Magics: MagicsObserver
+
+Change 63976 on 2011/10/13 by cgs at cgs_lxab
+
+    Magics: print
+
+Change 63975 on 2011/10/13 by cgs at cgs_metview
+
+    Magics: MAGICS_EXCEPTION
+
+Change 63970 on 2011/10/13 by cgr at cgr
+
+    Save he latest currentStep value for th scene items in the QtDriver.
+
+Change 63955 on 2011/10/13 by cgi at cgi_metview_4
+
+    MAG++: corrected test suite example graph_venice_01.f
+
+Change 63954 on 2011/10/13 by cgi at cgi_metview_4_nightly
+
+    M++: changed Log to MagLog in magmlx.cc
+
+Change 63945 on 2011/10/12 by cgs at cgs_lxab_debug
+
+    Log++=
+
+Change 63944 on 2011/10/12 by cgs at cgs_lxab_debug
+
+    LOg+++
+
+Change 63940 on 2011/10/12 by max at cgs_wrep_devel
+
+    refactoring
+
+Change 63936 on 2011/10/12 by max at cgs_wrep_devel
+
+    Magics/Wrep: metadata formatting
+
+Change 63934 on 2011/10/12 by cgs at cgs_metview
+
+    More onrefactoring
+
+Change 63923 on 2011/10/12 by cgs at cgs_metview
+
+    rename
+
+Change 63920 on 2011/10/12 by cgm at magics_mac
+
+    CONFIG MAC compilation works
+
+Change 63919 on 2011/10/12 by cgs at cgs
+
+    Magics: more on legend histogram
+
+Change 63907 on 2011/10/12 by cgs at cgs_metview
+
+    magics: Legend Histogram
+
+Change 63904 on 2011/10/12 by cgs at cgs_metview
+
+    Magics: legend histogram mode
+
+Change 63895 on 2011/10/12 by cgi at cgi_metview_4
+
+    MAG++: now uses ODA library version 0.9.2
+
+Change 63890 on 2011/10/12 by cgm at magics_opensuse113
+
+    DRIVERS remove debug output
+
+Change 63889 on 2011/10/12 by cgs at cgs
+
+    Magics: stupid typo!
+
+Change 63888 on 2011/10/12 by cgs at cgs_metview
+
+    Magics: cleanup print
+
+Change 63885 on 2011/10/12 by cgm at magics_opensuse113
+
+    DRIVERS Binary - fix unclosed layout
+
+Change 63884 on 2011/10/12 by cgm at magics_opensuse113
+
+    DRIVERS SVG fix wrong colour for shading outline
+
+Change 63881 on 2011/10/12 by cgm at magics_opensuse113
+
+    DRIVERS SVG update shading code
+
+Change 63870 on 2011/10/11 by cgm at magics_opensuse113
+
+    DRIVERS Base make debug information more unique
+
+Change 63868 on 2011/10/11 by cgm at magics_opensuse113
+
+    DRIVERS svg enable debug
+
+Change 63862 on 2011/10/11 by cgs at cgs_metview
+
+    More on refactoring!
+
+Change 63861 on 2011/10/11 by cgm at magics_opensuse113
+
+    CONFIG disable STATIC by default
+
+Change 63854 on 2011/10/11 by maf at belleus
+
+    added mechanism to create html index files for all tests run. these are produced as part of the suite at the end of the tests
+
+Change 63852 on 2011/10/11 by cgs at cgs_metview
+
+    python ++
+
+Change 63851 on 2011/10/11 by cgs at cgs
+
+    Exceptions
+
+Change 63850 on 2011/10/11 by cgs at cgs_metview
+
+    Refactoring
+
+Change 63847 on 2011/10/11 by cgs at cgs_metview
+
+    Refactoring machine.h
+
+Change 63843 on 2011/10/11 by cgs at cgs_metview
+
+    Magics: More on implicit definition of data!
+
+Change 63841 on 2011/10/11 by cgs at cgs_metview
+
+    refactoring
+
+Change 63840 on 2011/10/11 by cgs at cgs_metview
+
+    Refactoring
+
+Change 63838 on 2011/10/11 by cgs at cgs_metview
+
+    refcatoring
+
+Change 63837 on 2011/10/11 by cgs at cgs_metview
+
+    Refactoring
+
+Change 63836 on 2011/10/11 by cgs at cgs_metview
+
+    Refactoring+++
+
+Change 63835 on 2011/10/11 by cgs at cgs_metview
+
+    More on refcatoring
+
+Change 63834 on 2011/10/11 by cgs at cgs_metview
+
+    Magics: refctoring Exceotion.
+
+Change 63825 on 2011/10/11 by cgs at cgs_metview
+
+    rmp
+
+Change 63824 on 2011/10/11 by cgs at cgs_lxab
+
+    Magics: 
+
+Change 63821 on 2011/10/11 by cgs at cgs_metview
+
+    Magics: Translator
+
+Change 63818 on 2011/10/10 by cgm at magics_opensuse113
+
+    USE SCRIPTS correct spelling
+
+Change 63817 on 2011/10/10 by cgm at magics_opensuse113
+
+    DRIVERS SVG remove debug print-outs
+
+Change 63815 on 2011/10/10 by cgs at cgs
+
+    Typo
+
+Change 63814 on 2011/10/10 by cgs at cgs_metview
+
+    More on translator
+
+Change 63813 on 2011/10/10 by cgs at cgs_metview
+
+    More on translator
+
+Change 63812 on 2011/10/10 by cgs at cgs_metview
+
+    magics: rename Translator to MagTranslator
+
+Change 63811 on 2011/10/10 by cgs at cgs_metview
+
+    New name
+
+Change 63810 on 2011/10/10 by cgs at cgs_metview
+
+    Before rename
+
+Change 63803 on 2011/10/10 by cgm at magics_opensuse113
+
+    DRIVERS clarify PostScript info message
+
+Change 63802 on 2011/10/10 by cgm at magics_opensuse113
+
+    CONFIG make tarball work again
+
+Change 63797 on 2011/10/10 by maf at belleus
+
+    various changes to allow ecflow-based testing
+
+Change 63796 on 2011/10/10 by maf at belleus
+
+    added ecflow-based test running framework
+
+Change 63787 on 2011/10/10 by cgm at magics_opensuse113
+
+    Remove compiler warning
+
+Change 63775 on 2011/10/07 by cgs at cgs_metview
+
+    Magics:implements graph_x/y_suppress_above and graph_x/y_suppress_below
+    Magics/metview: small big fixes on TableDecoder 
+
+Change 63770 on 2011/10/07 by cgr at cgr
+
+    1. Added serachRadius[X,Y] to ValuesCollector. It is used to find data for a given position in scattered data sets. 2. Added mehod "nearest" to Matrix to find data for a given position in a matrix. 3. Used both new features in the OdaDecoder.  
+
+Change 63769 on 2011/10/07 by cgr at cgr
+
+    Added CoordinateType enum to Transformation.
+
+Change 63749 on 2011/10/07 by cgm at magics_opensuse113
+
+    USE SCRIPTS bring test scripts up-to-date
+
+Change 63742 on 2011/10/06 by cgs at cgs_metview
+
+    magics: Add Histogram mode for legend
+
+Change 63689 on 2011/10/05 by cgs at cgs_metview
+
+    Magics: curve optimisation
+
+Change 63688 on 2011/10/05 by cgs at cgs_metview
+
+    Magics/Metview: Renaming!
+
+Change 63669 on 2011/10/05 by cgm at magics_opensuse113
+
+    DOCS Magics Migration presentation held on 3rd October 2011
+
+Change 63666 on 2011/10/05 by cgr at cgr
+
+    Change parameter names for odb. 
+
+Change 63664 on 2011/10/05 by cgr at cgr
+
+    Use binning object defined in the request for odb visualisation in Metview.
+
+Change 63646 on 2011/10/05 by cgs at cgs_metview
+
+    Magics: Optimisation for simple graphs!
+
+Change 63636 on 2011/10/05 by maf at belleus
+
+    latest check in. error codes better.
+
+Change 63599 on 2011/10/04 by cgs at cgs_lxab
+
+    Magics: pnew super_page + adjsut in grid plotting
+
+Change 63597 on 2011/10/04 by cgr at cgr
+
+    Build title for xy ODB plots.
+
+Change 63593 on 2011/10/04 by cgs at cgs_metview
+
+    Magics/Metgram: adjust wave template
+
+Change 63590 on 2011/10/04 by maf at belleus
+
+    added url to the overview page to the output of the script
+
+Change 63589 on 2011/10/04 by cgs at cgs_metview
+
+    Magics/Metgram: fix 10 days epsgram
+
+Change 63588 on 2011/10/04 by maf at belleus
+
+    Added preliminary version of a script to run a set of tests and generate an overview page.
+    To run: 
+       ./runtests.sh <version1> <version2> <script_folder>
+    
+       for example:
+       ./runtests.sh current++ new++ examples
+    
+    
+    Also added two new tests to the se
+
+Change 63586 on 2011/10/04 by maf at belleus
+
+    added new tests to version comparison tool
+
+Change 63580 on 2011/10/04 by max at cgs_wrep_devel
+
+    Magics/Wrep: Navigation
+
+Change 63577 on 2011/10/04 by cgs at cgs_metview
+
+    Magics: pnew(super_page) small bug fix.
+                Improved line spacing
+                add new magics parameter x_missing_value y_missing_value to handle missing value in graph plotting
+
+Change 63529 on 2011/10/03 by cgs at cgs_lxab
+
+    Magics: graph_linei bug fix
+
+Change 63521 on 2011/10/03 by maf at belleus
+
+    fixed side-by-side txt comparison output by finally working out how the diff program arranges the side-by-side text in its output
+
+Change 63500 on 2011/10/03 by maf at belleus
+
+    added missing data file and updated fortran
+
+Change 63498 on 2011/10/03 by maf at belleus
+
+    fixed error message with bad args. added script guidelines to README.
+
+Change 63492 on 2011/10/03 by maf at belleus
+
+    added new examples to version comparison tool
+
+Change 63474 on 2011/09/30 by cgr at cgr
+
+    Added SciMethods which is planned to be a collection of scientific methods. Currently it only contains a method to compute the disctance between two geographial points. This method is used by OdaDecoder to find the nearest data point for the position
+
+Change 63462 on 2011/09/30 by maf at belleus
+
+    Following changes have been made:
+       - screen layout adapts to changes in window size
+       - text output has been split into two windows (co-scrolling) for convenience
+       - added warning for largish (>50 pixel) differences
+       - script output contains a
+
+Change 63442 on 2011/09/30 by max at cgs_wrep_devel
+
+    Magics/Wrep: navigation
+
+Change 63432 on 2011/09/30 by cgs at cgs_metview
+
+    Magics/Wrep: navigation
+
+Change 63424 on 2011/09/30 by cgm at magics_opensuse113
+
+    DOCS - backup old PDFs as part of the move away from docbook
+
+Change 63386 on 2011/09/29 by cgm at magics_opensuse113
+
+    USE SCRIPTS add Proj4 location to LD_LIBRARY_PATH (needed sometimes by STATIC)
+
+Change 63384 on 2011/09/29 by maf at belleus
+
+    added script run times to output. Some width scaling work
+
+Change 63380 on 2011/09/29 by cgm at magics_opensuse113
+
+    VERSION 2.13.10
+
+Change 63379 on 2011/09/29 by cgm at magics_opensuse113
+
+    USE SCRIPTS for 2.13.9 release (add -lproj)
+
+Change 63373 on 2011/09/29 by maf at belleus
+
+    fixed pixel count statistic in output for multiple pages
+
+Change 63372 on 2011/09/29 by cgm at magics_opensuse113
+
+    USE SCRIPTS changes for emos users (Sylvie)
+
+Change 63367 on 2011/09/29 by maf at belleus
+
+    multiple output pages now work. pixel difference text needs fixing therefore WORK IN PROGRESS
+
+Change 63350 on 2011/09/28 by cgs at cgs_lxab
+
+    Magics: Wind arrow legend
+
+Change 63349 on 2011/09/28 by cgs at cgs_metview
+
+    Magics: message out!
+
+Change 63336 on 2011/09/28 by cgs at cgs_metview
+
+    Magics: Legend_box_blanking is now off by default
+                Arrow Wind Legend improved
+
+Change 63334 on 2011/09/28 by cgm at magics_opensuse113
+
+    PYTHON revert module naming back to 'M'agics
+
+Change 63330 on 2011/09/28 by cgm at magics_opensuse113
+
+    PYTHON rename magmacro to 'macro'
+
+Change 63322 on 2011/09/28 by cgm at magics_opensuse113
+
+    PYTHON renaming interface to 'm'agics and use subdirectory for module
+
+Change 63319 on 2011/09/28 by cgs at cgs_metview
+
+    Magics: Bug in wind thinning around the poles.
+
+Change 63315 on 2011/09/28 by cgr at cgr
+
+    1. Extended ValuesCollector to collect more data for the queried layers 2. Implemented the visit method for ValuesCollector in OdaDecoder. 
+
+Change 63313 on 2011/09/28 by cgs at cgs_metview
+
+    Removed the ShpOpen() printout
+
+Change 63308 on 2011/09/27 by max at cgs_wrep_devel
+
+    Magics/Wrep: Legend+++
+
+Change 63304 on 2011/09/27 by cgm at magics_opensuse113
+
+    Binary - set meta data right for WREP (as is in CairoDriver)
+
+Change 63294 on 2011/09/27 by maf at belleus
+
+    added creation of logs folder. Script was failing if it was missing
+
+Change 63289 on 2011/09/27 by maf at belleus
+
+    new improved README
+
+Change 63288 on 2011/09/27 by maf at belleus
+
+    added readme. Added option to specify output folder
+
+Change 63285 on 2011/09/27 by maf at belleus
+
+    added test data for versioncmp.sh script
+
+Change 63283 on 2011/09/27 by maf at belleus
+
+    removed debug output. added image_magick_loc as variable
+
+Change 63282 on 2011/09/27 by maf at belleus
+
+    Now uses ImageMagick to convert from ps to pgn rather than pstopng. Added better error handling
+
+Change 63277 on 2011/09/27 by maf at belleus
+
+    populated places shape files as generated by latest shp_process.ksh
+
+Change 63276 on 2011/09/27 by cgs at cgs_lxab
+
+    Magics: change default of legend_entry_text_width + adjust plume default visualisation
+
+Change 63252 on 2011/09/26 by cgs at cgs_lxab_debug
+
+    Magics: cleaning
+
+Change 63251 on 2011/09/26 by cgs at cgs_metview
+
+    Magics: Plumes templates
+
+Change 63250 on 2011/09/26 by maf at belleus
+
+    added option to run the (quite slow) part of the script that handles city data. Defaults to on
+
+Change 63249 on 2011/09/26 by maf at belleus
+
+    New shape files produced by tools script shp_process.ksh at 63243 using geotools
+
+Change 63245 on 2011/09/26 by maf at belleus
+
+    removed unused shp file utility. See shp_process.ksh for how it is to be done now.
+
+Change 63243 on 2011/09/26 by maf at belleus
+
+    Scripts and associated for running geoscript (geodata manipulation lib) on workstations using groovy
+
+Change 63230 on 2011/09/26 by cgm at magics
+
+    CONFIG correct PROJ4 path on OpenSuSE 10.3
+
+Change 63229 on 2011/09/26 by cgm at magics_opensuse113
+
+    VERSION 2.13.9
+
+Change 63226 on 2011/09/26 by cgs at cgs_metview
+
+    Magics: graph and shading .
+
+Change 63214 on 2011/09/23 by cgr at cgr
+
+    Remove data value lines (dash) from histogram and adjust x-axis label positions.
+
+Change 63205 on 2011/09/23 by cgs at cgs_metview
+
+    Magics: legend
+
+Change 63204 on 2011/09/23 by cgs at cgs_lxab
+
+    ignore
+
+Change 63203 on 2011/09/23 by cgs at cgs_lxab
+
+    ignore
+
+Change 63202 on 2011/09/23 by cgs at cgs_lxab
+
+    Magics: Small fixes
+
+Change 63201 on 2011/09/23 by cgs at cgs_metview
+
+    Magics: AxisMinorTick
+
+Change 63200 on 2011/09/23 by cgs at cgs_metview
+
+    Magics: More on graph annotation
+
+Change 63192 on 2011/09/23 by cgs at cgs_lxab
+
+    Magics: Wind legend
+
+Change 63191 on 2011/09/23 by cgs at cgs_metview
+
+    magics: add annotation for bar at the top of the plots.
+
+Change 63179 on 2011/09/22 by cgr at cgr
+
+    The QtDriver is now using the correct screen resolution to compute the plot and font sizes.
+
+Change 63174 on 2011/09/22 by cgs at cgs_metview
+
+    Magics : little adjustements
+
+Change 63169 on 2011/09/22 by cgs at cgs_metview
+
+    magics: A litlle bit more on legend...
+                Migration messages
+
+Change 63163 on 2011/09/22 by cgs at cgs_metview
+
+    Magics/Metview: uplotbatch and cartesian view!
+
+Change 62813 on 2011/09/22 by cgs at cgs_lxab
+
+    Magics: ignore
+
+Change 62810 on 2011/09/22 by cgs at cgs_metview
+
+    Magics/Wrep: Small integration
+
+Change 62808 on 2011/09/22 by cgs at cgs_metview
+
+    Magics: pnew (super_page) allowed from the beginning
+                multiline spacing slighly increased
+                top box adjustement in cartesian view
+                fix when AXIS_MONTHS_LABEL_COMPOSITION THREE
+
+Change 62790 on 2011/09/21 by cgs at cgs_metview
+
+    Magics: More on legend title
+
+Change 62784 on 2011/09/21 by cgs at cgs_metview
+
+    Magics : Legend improvement ( legend_entry_text_width)
+                 Plumes legend 
+                 Lines spacing adjsutement
+                 Lost space at the top of a cartesian view 
+
+Change 62748 on 2011/09/20 by cgs at cgs_lxab
+
+    Close shape files
+
+Change 62733 on 2011/09/20 by cgs at cgs_metview
+
+    Magics/Legend: More on text_width...
+
+Change 62732 on 2011/09/19 by cgm at magics_opensuse113
+
+    PYTHON test new configure setup for swig (10) - correct install paths for ECMWF
+
+Change 62731 on 2011/09/19 by cgm at cgm_meshon
+
+    PYTHON test new configure setup for swig (9) - simplify Makefiles
+
+Change 62727 on 2011/09/19 by cgs at cgs_metview
+
+    Magics: Introduction of a new parameter for legend management legend_entry_text_width
+    Warning: implementaion not finished!
+
+Change 62704 on 2011/09/19 by cgs at cgs_metview
+
+    Magics/Metview: More on netcdf title.
+
+Change 62698 on 2011/09/19 by cgs at cgs_metview
+
+    Magics: ignore ( stupid typo!)
+
+Change 62688 on 2011/09/16 by cgm at magics_opensuse113
+
+    PYTHON test new configure setup for swig (8) - fix numpy path
+
+Change 62687 on 2011/09/16 by cgm at magics_lxa
+
+    PYTHON test new configure setup for swig (7) - fix site-packages path
+
+Change 62682 on 2011/09/16 by cgi at dell_suse12
+
+    PYTHON test new configure setup for swig (6) - now it works on suse 12.1
+
+Change 62671 on 2011/09/16 by cgm at magics_opensuse113
+
+    PYTHON test new configure setup for swig (5) - now it works on suse 11.3
+
+Change 62659 on 2011/09/16 by cgm at magics_opensuse113
+
+    PYTHON test new configure setup for swig (4)
+
+Change 62658 on 2011/09/15 by cgm at cgm_meshon
+
+    PYTHON test new configure setup for swig (3)
+
+Change 62657 on 2011/09/15 by cgm at cgm_meshon
+
+    PYTHON test new configure setup for swig (2)
+
+Change 62656 on 2011/09/15 by cgm at cgm_meshon
+
+    PYTHON test new configure setup for swig
+
+Change 62652 on 2011/09/15 by cgm at cgm_meshon
+
+    CONFIG fix syntax (no spaces allowed as end of line)
+
+Change 62643 on 2011/09/15 by cgs at cgs_metview
+
+    Magics/Wrep: 
+    Netcdf Matrix and Title...
+    Label enabled when no contour
+    Highlight and label using reference level
+    Curve and missing value
+
+Change 62636 on 2011/09/15 by cgs at cgs_metview
+
+    Magics/Wrep: ignore missing data.
+
+Change 62620 on 2011/09/14 by cgm at magics_opensuse113
+
+    CONFIG Always enable Proj4 and JSON by default
+
+Change 62619 on 2011/09/14 by cgm at magics_opensuse113
+
+    TESTS add python example with netCDF data read from SciPy
+
+Change 62618 on 2011/09/14 by cgm at magics_opensuse113
+
+    DOCS hide development parameter
+
+Change 62617 on 2011/09/14 by cgm at magics_opensuse113
+
+    MagMacro - update after feedback from Pyflakes
+
+Change 62587 on 2011/09/14 by cgs at cgs_metview
+
+    Magics/Python: improvment after training course
+
+Change 62493 on 2011/09/12 by cgr at cgr
+
+    Force annotationRootItem to be rendered on top of plotRootItem in the Qtdriver
+
+Change 62445 on 2011/09/11 by cgm at cgm_meshon
+
+    TESTS Python example combining GRIB_API and Magics
+
+Change 62423 on 2011/09/09 by cgs at cgs_metview
+
+    Magics/Wrep : Clipping of curves ( Cihan) 
+
+Change 62415 on 2011/09/09 by cgi at cgi_metview_4
+
+    MAG++: quick update for reboot of class08
+
+Change 62368 on 2011/09/08 by cgs at cgs_metview
+
+    Magics: Axis warning taken out (Hans)
+
+Change 62365 on 2011/09/08 by maf at belleus
+
+    further output tidying and ensured env variables unaffected by running this script
+
+Change 62364 on 2011/09/08 by maf at belleus
+
+    added auto image and text area height on output html. Tidied verbose output
+
+Change 62362 on 2011/09/08 by maf at belleus
+
+    essential html template for the versioncmp utility
+
+Change 62361 on 2011/09/08 by cgs at cgs_metview
+
+    Magics: Proj4
+
+Change 62360 on 2011/09/08 by maf at belleus
+
+    moved versioncmp script
+
+Change 62346 on 2011/09/08 by maf at belleus
+
+    added -v and -force flags: verbosity and force overwrite of output folder respectively
+
+Change 62345 on 2011/09/08 by cgi at cgi_metview_4
+
+    MAG++: ensured that automatically-generated NoFactoryException code in libMagWrapper is safe when exceptions are disabled
+
+Change 62338 on 2011/09/08 by maf at belleus
+
+    Added script to compare versions of magics. Works subject to refinements
+
+Change 62325 on 2011/09/08 by cgs at cgs_metview
+
+    Magics: Proj4
+
+Change 62310 on 2011/09/07 by cgs at cgs_metview
+
+    Magics/Wrep: plumes
+
+Change 62309 on 2011/09/07 by cgs at cgs_metview
+
+    Magics: Config for Proj4
+
+Change 62307 on 2011/09/07 by cgs at cgs_metview
+
+    Magics: More on Proj4 
+
+Change 62293 on 2011/09/07 by cgs at cgs_metview
+
+    Magics: Inputmatrix and missing data
+
+Change 62258 on 2011/09/06 by cgr at cgr
+
+    Add new header file defining the MgQ namespace in the QtDriver.
+
+Change 62256 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62255 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62254 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62253 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62252 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62251 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62250 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62249 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62248 on 2011/09/06 by cgr at cgr
+
+    Rename/move file(s)
+
+Change 62247 on 2011/09/06 by cgr at cgr
+
+    Tidy up the QtDriver code.
+
+Change 62246 on 2011/09/06 by cgr at cgr
+
+    Tidy up the QtDriver code.
+
+Change 62228 on 2011/09/05 by max at cgs_wrep_devel
+
+    Magics/Wrpe: More on Proj4 Integration
+
+Change 62221 on 2011/09/05 by cgs at cgs_metview
+
+    Magics/Wrep: Proj4 Integration
+
+Change 62220 on 2011/09/05 by max at cgs_wrep_devel
+
+    Magics/Wrep : Proj4 integration
+
+Change 62219 on 2011/09/05 by cgs at cgs_metview
+
+    Magics: Add proj4 in distribution tar ball
+
+Change 62205 on 2011/09/05 by cgr at cgr
+
+    Tidy up Layer.cc by grouping the methods according to the classes
+
+Change 62200 on 2011/09/05 by cgr at cgr
+
+    Add code to highlight a given node in the scene in the QtDriver
+
+Change 62197 on 2011/09/05 by cgi at cgi_metview_4
+
+    MAG++: corrected path to PROJ4 library on openSUSE 10.3 systems
+
+Change 62191 on 2011/09/05 by cgs at cgs_metview
+
+    Magics/Wrep: Ignore!
+
+Change 62190 on 2011/09/05 by cgs at cgs_metview
+
+    Magics/Wrep: generate Metadata to navigate maps when using proj4
+
+Change 62185 on 2011/09/02 by cgs at cgs_metview
+
+    Magics: add support for Proj4 + cleaning
+
+Change 62173 on 2011/09/02 by cgr at cgr
+
+    Added a new custom Qt graphics item to store (cache) the whole plot as a pixmap. 
+
+Change 62162 on 2011/09/02 by cgs at cgs_main
+
+    Magics: cleaning in progress!
+
+Change 62130 on 2011/09/01 by cgs at cgs_metview_next
+
+    Magics/Metview: forgot one class for the Wrapper!
+
+Change 62129 on 2011/09/01 by cgs at cgs_metview
+
+    Magics: add the possibility to define the x_date_values/y_data_values, using a base date and an offset.
+
+Change 62123 on 2011/09/01 by cgr at cgr
+
+    Qt driver does not render the scene any more after close() is called. It is now the task of ineractive application  using the driver (metview)
+
+Change 62117 on 2011/09/01 by cgs at cgs_metview
+
+    Magics: Add possibility of user format for date date labels. simplify the code around the date labelling.
+
+Change 62079 on 2011/08/31 by cgs at cgs_metview
+
+    Magics/Wrep: Automatic date axis. ( fix bug in setting)
+
+Change 62040 on 2011/08/26 by cgm at magics_opensuse113
+
+    KML - fix shading (reported by J.Kaiser - MACC)
+
+Change 62007 on 2011/08/25 by cgm at magics_opensuse113
+
+    Cairo - another Y-offset test
+
+Change 61992 on 2011/08/25 by cgm at magics_opensuse113
+
+    Drivers - trial on y-offset for meta data
+
+Change 61981 on 2011/08/25 by cgm at magics_opensuse113
+
+    New version 2.13.8
+
+Change 61980 on 2011/08/25 by cgs at cgs_metview
+
+    Magics/Metview/Wrep: new toxml method in attributes 
+
+Change 61979 on 2011/08/25 by cgs at cgs_metview
+
+    Magics/Wrep: navigation of cartesian projection
+
+Change 61963 on 2011/08/24 by cgm at magics_opensuse113
+
+    Remove reference to Graphics Section
+
+Change 61962 on 2011/08/24 by cgm at magics_opensuse113
+
+    Remove warning for tmpnam
+
+Change 61955 on 2011/08/24 by cgm at magics_opensuse113
+
+    Compile - hardcode shared and static
+
+Change 61954 on 2011/08/24 by cgm at magics_opensuse113
+
+    USE SCRIPTS - fixes for 2.13.6 release
+
+Change 61932 on 2011/08/24 by cgm at cgm_orion
+
+    Version 2.13.7
+
+Change 61929 on 2011/08/23 by cgm at magics_opensuse113
+
+    Boost - update from subversion
+
+Change 61928 on 2011/08/23 by cgm at magics_opensuse113
+
+    Config - correct variable names
+
+Change 61927 on 2011/08/23 by cgm at cgm_meshon
+
+    Config - fix library version numbers (broken after MacOS update)
+
+Change 61915 on 2011/08/23 by cgs at cgs_metview_next
+
+    Magics/Metview: optimisation of the tree
+
+Change 61913 on 2011/08/23 by cgs at cgs_metview_next
+
+    Magics/Metview: optimisation of the graphical tree 
+
+Change 61906 on 2011/08/23 by cgm at magics_opensuse113
+
+    New version 2.13.6
+
+Change 61896 on 2011/08/23 by cgm at magics_opensuse113
+
+    Docs - add EGOWS presentations
+
+Change 61891 on 2011/08/23 by cgm at magics_opensuse113
+
+    Cairo - add test is the layout is navigatable
+
+Change 61880 on 2011/08/22 by cgm at cgm_meshon
+
+    xml2mv - exclude parameter which breaks drivers
+
+Change 61879 on 2011/08/22 by cgm at cgm_meshon
+
+    Coastlines - fix spelling mistake in path name
+
+Change 61808 on 2011/08/22 by cgs at cgs_metview_next
+
+    Magics/Python: Symbol and Cartesian projection(Martin Janousek)
+
+Change 61747 on 2011/08/19 by cgr at cgr_update
+
+    Increase the default size of the background pixmap in the QtDriver
+
+Change 61723 on 2011/08/18 by cgm at cgm_meshon
+
+    Docs - add scripts to generate ODT tables of magics parameters
+
+Change 61710 on 2011/08/18 by max at cgs_wrep_devel
+
+    Magics/Wrep: Do not create any  automatic arrow legend text anymmore
+
+Change 61686 on 2011/08/18 by cgs at cgs_metview
+
+    Rollback //depot/magics/main/src/libMagWrapper/MagPlus.h to revision 46
+
+Change 61685 on 2011/08/18 by cgs at cgs_metview
+
+    Rollback //depot/magics/main/src/libMagWrapper/MagPlus.cc to revision 124
+
+Change 61675 on 2011/08/17 by cgs at cgs_metview_next
+
+    Magics/Metview: Start optimising the rendering of a Metview Tree!
+
+Change 61670 on 2011/08/17 by max at cgs_wrep_devel
+
+    Magics/Wrep: Add special mode wrep for legend handling
+
+Change 61668 on 2011/08/17 by cgs at cgs_metview
+
+    Magics/Metview: Add progress messages 
+
+Change 61667 on 2011/08/17 by cgs at cgs_metview
+
+    Magics/Metview: Legend adjustement
+
+Change 61661 on 2011/08/17 by cgs at cgs_metview
+
+    Magics/Metview : Hovmoller adjustements
+
+Change 61659 on 2011/08/17 by cgr at cgr
+
+    Start new developments to implement an update mode for the metview interface. The new code is protected 
+    by the MAG_NEXT macro.  A new flag ( --enable-magnext) was added to configure. If it is enabled (by default disabled)
+    a -DMAG_NEXT flag is added 
+
+Change 61654 on 2011/08/16 by cgm at cgm_meshon
+
+    MvDef - update scripts for driver files
+
+Change 61650 on 2011/08/16 by cgm at magics_opensuse113
+
+    Def - update on generating driver files for Metview
+
+Change 61647 on 2011/08/16 by cgi at cgi_metview_4
+
+    MAG++: enabled automatic GRIB scaling for GRIB 2 data. Still needs some work in order to get it working better with GRIB_API approach.
+
+Change 61626 on 2011/08/16 by cgm at magics_opensuse113
+
+    Correct function name
+
+Change 61625 on 2011/08/16 by cgm at magics_opensuse113
+
+    Boundaries - change behaviour for local borders
+
+Change 61623 on 2011/08/16 by cgm at magics_opensuse113
+
+    Remove old files
+
+Change 61619 on 2011/08/16 by cgm at magics_mac
+
+    Config - remove redundant bootstrap call
+
+Change 61617 on 2011/08/15 by cgm at cgm_meshon
+
+    Coastines - boundaries + cities  
+
+Change 61609 on 2011/08/15 by cgm at magics_opensuse113
+
+    Coastlines - fixes for borders and cities
+
+Change 61608 on 2011/08/15 by cgm at magics_opensuse113
+
+    Test - further updates on boundary example
+
+Change 61606 on 2011/08/15 by cgm at magics_opensuse113
+
+    Tests - update for small scale
+
+Change 61604 on 2011/08/15 by cgm at magics_opensuse113
+
+    Tests - updates for plotting of boundaries & rivers
+
+Change 61591 on 2011/08/15 by cgi at cgi_metview_4
+
+    MAG++: removed reliance on MvObs/inc_string.h
+
+Change 61588 on 2011/08/15 by cgm at magics_opensuse113
+
+    Coastlines - correct attribute name
+
+Change 61584 on 2011/08/15 by cgm at magics_opensuse113
+
+    Python - update Python version to 2.7 (on request of Carlos)
+
+Change 61577 on 2011/08/15 by cgm at magics
+
+    Config - Remove call which fails on OpenSuSE 10.3 (was put in for MacOS X)
+
+Change 61576 on 2011/08/15 by cgm at cgm_meshon
+
+    Coastlines - updated script and data set (east canada merged with usa in 10m land)
+
+Change 61575 on 2011/08/15 by cgm at cgm_meshon
+
+    Boost - comment out version definition
+
+Change 61573 on 2011/08/13 by cgm at cgm_meshon
+
+    Cities - put city data files back (crashed Metview if cities were enabled)
+
+Change 61571 on 2011/08/12 by cgm at magics_opensuse113
+
+    Clean-up
+
+Change 61568 on 2011/08/12 by cgi at dell112
+
+    removed presumably nonstandard p4login command
+
+Change 61567 on 2011/08/12 by maf at belleus
+
+    added utility to process 10m shape files and write to our local share folders
+
+Change 61557 on 2011/08/12 by cgm at magics_mac
+
+    Config - changes for MacOSX (GCC 4.5)
+                  (see compile.sh how to compile)
+
+Change 61546 on 2011/08/12 by maf at belleus
+
+    removed great lakes duplicates from the 10m_full dataset
+
+Change 61532 on 2011/08/11 by cgm at cgm_meshon
+
+    Clean-up
+
+Change 61531 on 2011/08/11 by cgm at cgm_meshon
+
+    Compile - use proj4
+
+Change 61530 on 2011/08/11 by cgm at cgm_meshon
+
+    Config - update options for proj4
+
+Change 61524 on 2011/08/11 by cgm at magics_opensuse113
+
+    Coastlines - remove test for Great Lakes
+
+Change 61513 on 2011/08/11 by cgi at cgi_metview_4
+
+    MAG++: small fix for the M6 part of the test suite
+
+Change 61507 on 2011/08/11 by cgs at cgs_metview
+
+    Magics: More on Dimensions resetting 
+
+Change 61499 on 2011/08/11 by maf at belleus
+
+    removed Caspian sea from 110m lakes dataset
+
+Change 61498 on 2011/08/11 by maf at belleus
+
+    removed great lakes from 50m dataset
+
+Change 61497 on 2011/08/11 by maf at belleus
+
+    deleted some unnecessary sbx files
+
+Change 61494 on 2011/08/11 by cgi at cgi_metview_4
+
+    MAG++: now uses odalib 0.8.6
+
+Change 61484 on 2011/08/11 by cgi at magics_cgi
+
+    MAG++: adapted some test suite programs to ensure that GRIB scaling is consistently on/off regardless of whether run under MAGICS 6 or Magics++
+
+Change 61482 on 2011/08/11 by cgi at cgi_metview_4
+
+    MAG++: re-enabled M6 in test suite
+
+Change 61480 on 2011/08/10 by cgm at cgm_meshon
+
+    Boost - updates to hardcode for latest version
+
+Change 61471 on 2011/08/10 by cgs at cgs_metview
+
+    Magics: More on HiLo type BOTH
+
+Change 61470 on 2011/08/10 by cgs at cgs_metview
+
+    Magics/EpsGrams: fix bug in legend... 
+
+Change 61464 on 2011/08/10 by cgs at cgs_metview
+
+    Magics: Pb in in computing dimensions in portrait (Martin Janousek) 
+
+Change 61459 on 2011/08/10 by cgm at magics_opensuse113
+
+    Boost - add missing files (after update)
+
+Change 61448 on 2011/08/10 by cgs at cgs_metview
+
+    Magics/Epsgrams: Adjust templates for the epsgrams products!
+
+Change 61444 on 2011/08/10 by cgm at magicsIBM
+
+    Config - clean-up for ecgate
+
+Change 61443 on 2011/08/10 by cgm at magicsIBM
+
+    Config - remove unnecessary option
+
+Change 61442 on 2011/08/10 by cgm at magicsIBM
+
+    Config - use latest compiler on  ecgate
+
+Change 61440 on 2011/08/10 by cgm at magics_opensuse113
+
+    Boost - update bugfixes from SVN branch
+                svn co http://svn.boost.org/svn/boost/trunk boost-trunk
+
+Change 61434 on 2011/08/10 by cgi at cgi_metview_4
+
+    MAG++: added the complete set of Fortran parameters to a single additional chapter in the documentation [main branch]
+
+Change 61420 on 2011/08/10 by maf at belleus
+
+    removed unnecessary sbn file
+
+Change 61417 on 2011/08/10 by cgi at cgi_metview_4
+
+    MAG++: now uses emoslib 000390
+
+Change 61403 on 2011/08/09 by cgm at magics_opensuse113
+
+    Config - add global Proj4 settings
+
+Change 61402 on 2011/08/09 by cgs at cgs_metview
+
+    proj4
+
+Change 61396 on 2011/08/09 by cgs at cgs_metview
+
+    Metview: subpage dimensions and cartesian projection ( Andrew Orr) 
+
+Change 61380 on 2011/08/08 by cgi at magics_cgi
+
+    MAG++: updated axis/python example for documentation; also ensure that example code listings are regenerated when make_plots is run.
+
+Change 61378 on 2011/08/08 by cgm at magics_opensuse113
+
+    Docs - add a MagMacro python example for axis
+
+Change 61376 on 2011/08/08 by cgs at cgs_metview
+
+    Magics: magmacro example with date...
+
+Change 61374 on 2011/08/08 by cgm at magics_opensuse113
+
+    Tests: graph plotting in Python (David Tan)
+
+Change 61372 on 2011/08/08 by cgs at cgs_metview
+
+    Magics: legend_text_height is accepted as deprecated (Frederic Vitard) 
+
+Change 61370 on 2011/08/08 by cgs at cgs_metview
+
+    Magics: Hilo_type set to both was not setting the symbol. (Luc Vrijens)
+
+Change 61349 on 2011/08/08 by cgm at magics_opensuse113
+
+    Docs-  add new option to build Magics++ without GRIB support
+
+Change 61346 on 2011/08/07 by cgm at cgm_meshon
+
+    Tests - add example using pset1i where numpy needs to be told to use INT32
+
+Change 61345 on 2011/08/07 by cgm at cgm_meshon
+
+    Clean-up
+
+Change 61344 on 2011/08/07 by cgm at cgm_meshon
+
+    Remove print-outs
+
+Change 61343 on 2011/08/07 by cgm at cgm_meshon
+
+    Correct warning messages
+
+Change 61341 on 2011/08/07 by cgm at cgm_meshon
+
+    Docs - Remove Metview specific parameter from documentation
+
+Change 61340 on 2011/08/07 by cgm at cgm_meshon
+
+    Wrapper - fix header include and remove compiler warnings
+
+Change 61338 on 2011/08/06 by cgm at cgm_meshon
+
+    Docs -  add comment about HTML syntax and Pgf90 compiler backslash
+
+Change 61335 on 2011/08/06 by cgm at magics_ubuntu
+
+    Config - improve small Magics installations (NetCDF and GRIB disabled) - tested on Ubuntu 11.04
+
+Change 61334 on 2011/08/05 by cgm at magics_opensuse113
+
+    Clean-up tofortran()
+
+Change 61322 on 2011/08/05 by cgi at magics_cgi
+
+    MAG++: test suite - added Magics version string to top of html pages
+
+Change 61317 on 2011/08/05 by cgi at magics_cgi
+
+    MAG++: added another graph (scatter) plotting example for Venice (graph_venice_02)
+
+Change 61313 on 2011/08/05 by cgi at cgi_metview_4
+
+    MAG++: fixed formatting error in test suite example graph_venice_01 (only picked up with PGF 10.5 and later)
+
+Change 61312 on 2011/08/05 by cgi at cgi_metview_4
+
+    MAG++: test suite fixes to ensure that only the latest plots are copied across to SCRATCH
+
+Change 61310 on 2011/08/05 by cgm at magics_opensuse113
+
+    BOOST - correct include path for old platforms
+
+Change 61300 on 2011/08/05 by cgm at magics_opensuse113
+
+    Manual - Restructuring of axis chapter
+
+Change 61299 on 2011/08/05 by cgi at magics_cgi
+
+    MAG++: docs - ensure that images for tutorial are not processed
+
+Change 61298 on 2011/08/05 by cgi at magics_cgi
+
+    MAG++: updates to the Python graph/date plotting example
+
+Change 61297 on 2011/08/05 by cgm at magics_opensuse113
+
+    fix file name
+
+Change 61296 on 2011/08/05 by cgm at magics_opensuse113
+
+    Add Axis example in manual (in python)
+
+Change 61294 on 2011/08/04 by cgm at magics_opensuse113
+
+    remove debug messages
+
+Change 61293 on 2011/08/04 by cgm at magics_opensuse113
+
+    use Boost from /usr/local/apps
+
+Change 61291 on 2011/08/04 by cgm at magics_opensuse113
+
+    Clean-up between INT and DOUBLE
+
+Change 61289 on 2011/08/04 by cgm at cgm_meshon
+
+    Add new tests for undocumented parameters and action routine (reported by CNR Venice)
+
+Change 61288 on 2011/08/04 by cgm at cgm_meshon
+
+    Update name of section and authors (MetVis) - use scripts
+
+Change 61287 on 2011/08/04 by cgm at cgm_meshon
+
+    remove obsolete files
+
+Change 61286 on 2011/08/04 by cgm at cgm_meshon
+
+    Update name of section and authors (MetVis) - more common, basic, visualisers directories 
+
+Change 61285 on 2011/08/04 by cgm at cgm_meshon
+
+    Update name of section and authors (MetVis) - common, basic, visualisers directories
+
+Change 61284 on 2011/08/04 by cgm at cgm_meshon
+
+    Update name of section and authors (MetVis) - driver directory
+
+Change 61283 on 2011/08/04 by cgm at cgm_meshon
+
+    Update name of section and authors (MetVis)
+
+Change 61264 on 2011/08/04 by cgi at magics_cgi
+
+    MAG++: added example to the test suite based on code from Venice which needed a partial rewrite in order to work with Magics++ (it had been using undocumented parameters from MAGICS 6 which were not implemented in Magics++). It is under the Graph sec
+
+Change 61255 on 2011/08/04 by maf at belleus
+
+    Added utility to reduce detail in compatible shape files (10m_xxxxx) while leaving certain regions at full resolution. Use -help for usage info
+
+Change 61219 on 2011/08/02 by cgm at magics_opensuse113
+
+    Compatibility checker - Add comment about undocumented MAGICS 6 parameter (CNR Venice)
+
+Change 61217 on 2011/08/02 by maf at belleus
+
+    removed stray field
+
+Change 61213 on 2011/08/02 by maf at belleus
+
+    Added installation of non-reduced 10m shape files (to 10m_full folder) when installing magics
+
+Change 61201 on 2011/08/02 by cgr at cgr
+
+    Added "statsType" meta-data item to MetviewIcon::information_ to control statistics computations.
+
+Change 61189 on 2011/08/01 by maf at belleus
+
+    seems we need a little more resolution outside of Europe so this version has ScaleRank of 5 or below generally, with all resolution data within the Europe area
+
+Change 61188 on 2011/08/01 by maf at belleus
+
+    Updated 10m files with new versions. These contain land features with scaleRank of 5 or below, with the exception of a European bounding box (-12, 72, 48, 32) which contains all data
+
+Change 61176 on 2011/08/01 by maf at belleus
+
+    deleted sbn file
+
+Change 61175 on 2011/08/01 by maf at belleus
+
+    deleted sbn file
+
+Change 61174 on 2011/08/01 by maf at belleus
+
+    deleted sbn file
+
+Change 61171 on 2011/08/01 by maf at belleus
+
+    removed sbn file
+
+Change 61161 on 2011/07/30 by cgm at cgm_meshon
+
+    Add check for the replacement of 'positional' with 'automatic'
+
+Change 61160 on 2011/07/30 by cgm at cgm_meshon
+
+    Change default for axis_grid_colour from yellow to black and clean-up documentation
+
+Change 61092 on 2011/07/28 by maf at belleus
+
+    Added doxygen comment relating to coastline handling
+
+Change 61086 on 2011/07/28 by maf at belleus
+
+    Added new versions of 10m shapefiles containing trimmed data (except the 'admin_0' files which are unchanged). Original unedited versions now in subfolder 10m_full. Reverted an earlier change to allow viewing of 10m-resolution shapefiles now that cra
+
+Change 61031 on 2011/07/26 by cgm at magics_opensuse113
+
+    Coast - Disable Boost exception to make south polar sterographic work (reported by Philippe Lopez)
+
+Change 61025 on 2011/07/26 by cgr at cgr
+
+    The QtDriver is now able to handle multiple-page layouts.  The METVIEW_MULTIPAGE macro was removed from the QtDriver and the --enable-qtmultipage flag was removed from configure. 
+
+Change 61014 on 2011/07/25 by cgm at magics_opensuse113
+
+    Docs - Add more graphs to the doxygen output
+
+Change 61013 on 2011/07/25 by cgm at magics_opensuse113
+
+    Add comment about WIND_ARROW_LEGEND
+
+Change 61012 on 2011/07/25 by cgm at magics_opensuse113
+
+    Smaller code clean-up (ie avoid devision by zero)
+
+Change 61011 on 2011/07/25 by cgm at magics_opensuse113
+
+    Change code to use DBL_* constatnts instead of INT_*
+
+Change 61010 on 2011/07/25 by cgm at magics_opensuse113
+
+    Add compability checker for 'wind_arrow_legend' (reported by CNR Venice)
+
+Change 61008 on 2011/07/25 by cgm at magics_opensuse113
+
+    Add missing (duplicate!) method (Sylvie to check)
+
+Change 61007 on 2011/07/25 by cgm at magics_opensuse113
+
+    Correct offset for matrices from -180. to 0.  (reported by Peter Janssen)
+
+Change 61006 on 2011/07/25 by cgm at magics_opensuse113
+
+    Remove 'USER' option for logo (reported by CNR Venice)
+
+Change 60992 on 2011/07/24 by cgm at cgm_meshon
+
+    Add code comments
+
+Change 60991 on 2011/07/24 by cgm at cgm_orion
+
+    Compile - add better test if magics compiles
+
+Change 60990 on 2011/07/24 by cgm at cgm_meshon
+
+    Revert includes for fstream
+
+Change 60989 on 2011/07/24 by cgm at cgm_orion
+
+    Compile - add intel icpc options
+
+Change 60987 on 2011/07/24 by cgm at cgm_meshon
+
+    Reduce compiler warnings
+
+Change 60962 on 2011/07/22 by cgi at cgi_metview_4
+
+    MAG++: enable correct plotting of regular lat/long GRIB files where jPointsAreConsecutive=1
+
+Change 60905 on 2011/07/21 by cgi at cgi_metview_4
+
+    MV4: enabled GRIB_SCALING_OF_RETRIEVED_FIELDS and GRIB_SCALING_OF_DERIVED_FIELDS in both PCONT and MCONT icons. The main changes were in Magics++ (added an undocumented parameter 'GRIB_AUTOMATIC_DERIVED_SCALING')
+
+Change 60885 on 2011/07/20 by cgi at cgi_metview_4
+
+    MAG++: uncommented a fix for plotting regular Gaussian grids on sub-areas
+
+Change 60877 on 2011/07/20 by cgi at cgi_metview_4_nightly
+
+    MAG++: moved the 'longitudesSanityCheck' up in the GribDecoder class heirarchy so that it is available to all grd types that require it (this allows the plotting of a particular dodgy reduced Gaussian grid which otherwise triggered an assertion)
+
+Change 60846 on 2011/07/19 by cgm at cgm_orion
+
+    Python - more debug output
+
+Change 60845 on 2011/07/19 by cgm at cgm_orion
+
+    Clearify exception error messages
+
+Change 60844 on 2011/07/19 by cgi at magics_cgi
+
+    MAG++: in the test suite, ensure that the ps directory is cleaned at the start of the cron job
+
+Change 60840 on 2011/07/19 by cgm at cgm_meshon
+
+    Tests - updated python test
+
+Change 60832 on 2011/07/18 by cgm at magics_opensuse113
+
+    Python: add Graph examples
+
+Change 60799 on 2011/07/16 by cgm at magics_opensuse113
+
+    Boost - update Geometry to version 1.0 (Boost 1.47.0)
+
+Change 60798 on 2011/07/16 by cgm at magics_opensuse113
+
+    Boost - remove Geometry < 1.0 version
+
+Change 60765 on 2011/07/14 by cgm at magics_opensuse113
+
+    Rollback //depot/magics/main/src/drivers/Makefile.am to revision 109
+
+Change 60759 on 2011/07/14 by cgm at magics_opensuse113
+
+    Clean-up INT_MAX (2)
+
+Change 60758 on 2011/07/14 by cgm at magics_opensuse113
+
+    Clean-up INT_MAX 
+
+Change 60748 on 2011/07/14 by cgm at magics_opensuse113
+
+    Remove old Terralib code
+
+Change 60745 on 2011/07/14 by cgm at cgm_meshon
+
+    RPMS update SPEC files for Grib_API and Emoslib
+
+Change 60744 on 2011/07/13 by cgm at cgm_meshon
+
+    Drivers: code improvements - remove unnecessary members
+
+Change 60739 on 2011/07/13 by cgs at cgs_metview
+
+    Wrep/Magics: scores and date Axis!
+
+Change 60736 on 2011/07/13 by cgm at magics_opensuse113
+
+    Compile: add json on clusters and fix static on 113
+
+Change 60728 on 2011/07/13 by cgs at cgs_lxab
+
+    Magics: If trouble with penqr function revert MagicsCalls.cc to revison 175
+
+Change 60727 on 2011/07/13 by max at cgs_wrep_devel
+
+    Wrep/Magics: WrepJSon data and missing values.
+
+Change 60725 on 2011/07/13 by cgm at magicsIBM
+
+    IBM xlC change required to work for latest xlC 11.1
+
+Change 60723 on 2011/07/13 by cgm at magics_opensuse113
+
+    VERSION 2.13.5
+
+Change 60699 on 2011/07/12 by cgs at cgs_metview
+
+    Wrep/Magics: implements missing values for wrep curve ( Cihan)
+
+Change 60671 on 2011/07/11 by cgs at cgs_metview
+
+    Magics: Bar : allow parameter graph_shade_colour to set the bar coulour ( backward compatibility) 
+                        add a parameter graph_bar_clipping to allow clpping or nor  of bar if outside the the plotting area
+
+Change 60669 on 2011/07/11 by max at cgs_wrep_devel
+
+    magics/wrep: coastlines
+
+Change 60660 on 2011/07/11 by cgs at cgs_metview
+
+    Wrep/Magics: Caostlines
+
+Change 60658 on 2011/07/11 by cgs at cgs_metview
+
+    Wrep/Magics: Coastlines
+
+Change 60657 on 2011/07/11 by cgs at cgs_metview
+
+    Wrep/Magics: Coastlines
+
+Change 60655 on 2011/07/11 by cgs at cgs_metview
+
+    Wrep/Magics: rivers???
+
+Change 60647 on 2011/07/11 by cgm at magics_opensuse113
+
+    Rollback //depot/magics/main/src/basic/magplus.h to revision 4
+
+Change 60646 on 2011/07/11 by cgm at magics_opensuse113
+
+    Rollback //depot/magics/main/src/basic/magplus.cc to revision 12
+
+Change 60643 on 2011/07/11 by cgm at magics_opensuse113
+
+    VERSION 2.13.4
+
+Change 60636 on 2011/07/10 by cgm at magics_opensuse113
+
+    CairoDriver adjust line width
+
+Change 60628 on 2011/07/08 by cgm at cgm_meshon
+
+    Remove unnecessary files
+
+Change 60627 on 2011/07/08 by cgm at cgm_meshon
+
+    Change email adress in footer
+
+Change 60620 on 2011/07/08 by cgs at cgs_metview
+
+    Wrep/Magics: do not send empty holes!
+
+Change 60616 on 2011/07/08 by cgm at magics_opensuse113
+
+    SVG fix proplem in broken syntax
+
+Change 60614 on 2011/07/08 by cgs at cgs_metview
+
+    Wrep/Magics: Coastlines resolution adjsutement
+    Metview/Magics: _ID implemented ( SceneLayout)
+
+Change 60601 on 2011/07/08 by cgm at magics_opensuse113
+
+    Renamed Polyline stroke method and fixed wrong frame in SVG
+
+Change 60571 on 2011/07/08 by cgm at magics_opensuse113
+
+    PostScript - reset colours before text (Fernando 'green' text issue)
+
+Change 60569 on 2011/07/08 by cgm at magics_opensuse113
+
+    Make - remove reference to deleted file
+
+Change 60535 on 2011/07/07 by max at cgs_wrep_devel
+
+    Wrep/Magics: Coastlines
+
+Change 60532 on 2011/07/07 by cgs at cgs_metview
+
+    Wrep/Magics: caostlines
+
+Change 60528 on 2011/07/07 by cgs at cgs_metview
+
+    Wrep/Magics: Coastlines
+
+Change 60520 on 2011/07/07 by cgi at cgi_metview_4
+
+    MAG++: removed redundant XML file: TextAction.xml. This was for the purpose of ensuring that the text chapter in the documentation does not pick up the wrong version of the TextVisitor class (and therefore get the wrong set of parameters). [r2.12 and
+
+Change 60518 on 2011/07/07 by cgs at cgs_metview
+
+    Wrep/Magics: Coastlines
+
+Change 60516 on 2011/07/07 by max at cgs_wrep_devel
+
+    Wrep/Magics: More on coastlines
+
+Change 60515 on 2011/07/07 by cgs at cgs_metview
+
+    Magics : Coastlines
+
+Change 60509 on 2011/07/07 by cgs at cgs_metview
+
+    Magics: Coastlines
+
+Change 60501 on 2011/07/07 by cgs at cgs_metview
+
+    Wrep: setting of cylindrical projection adjustment
+
+Change 60486 on 2011/07/07 by max at cgs_wrep_devel
+
+    Wrep: Valid Json for CartesianProjection
+
+Change 60483 on 2011/07/06 by cgm at cgm_meshon
+
+    Doc Small updates
+
+Change 60482 on 2011/07/06 by cgm at cgm_meshon
+
+    Code clean-up - Remove old files
+
+Change 60466 on 2011/07/06 by cgm at magics_opensuse113
+
+    Scripts for testing
+
+Change 60465 on 2011/07/06 by cgm at magics_opensuse113
+
+    Proj4 fixes for compilation
+
+Change 60462 on 2011/07/06 by cgm at magics_opensuse113
+
+    DOCS updated documenatation about coastlines/borders
+
+Change 60447 on 2011/07/06 by cgs at cgs_metview
+
+    Magics: Introduction of Proj4
+
+Change 60443 on 2011/07/06 by cgs at cgs_metview
+
+    Magics Migration : Ignore parameters 
+
+Change 60439 on 2011/07/06 by cgr at cgr
+
+    Enable antialias for multiple-page layout in the QtDriver
+
+Change 60438 on 2011/07/06 by cgr at cgr
+
+    Make redisplay(SceneLayout) virtual
+
+Change 60437 on 2011/07/06 by cgm at magics_opensuse113
+
+    Config - add Proj4 path for ECMWF
+
+Change 60436 on 2011/07/06 by cgs at cgs_metview
+
+    metview4: SceneLayout
+
+Change 60422 on 2011/07/06 by cgs at cgs_metview
+
+    Metview4: Histogram projection was wrong
+
+Change 60414 on 2011/07/05 by cgm at cgm_meshon
+
+    Fix compilation problem
+
+Change 60413 on 2011/07/05 by cgm at cgm_meshon
+
+    GD  put gd_png parameters back to work, clean-up code
+
+Change 60406 on 2011/07/05 by cgs at cgs_metview
+
+    Metview4: More on TableVisualiser
+
+Change 60405 on 2011/07/05 by cgs at cgs_metview
+
+    Metview4 : add TableVisualiser
+
+Change 60404 on 2011/07/05 by cgs at cgs_metview
+
+    Metview4 : Preview is back
+
+Change 60403 on 2011/07/05 by cgm at magics_opensuse113
+
+    GD fix bug in shading and adjusted line width
+
+Change 60391 on 2011/07/05 by cgm at magics_opensuse113
+
+    USE SCRIPTS change for Mohamed and Obstat on DRN cluster
+
+Change 60390 on 2011/07/05 by cgm at magics_opensuse113
+
+    GD add simple polygon shading (only solid for now)
+
+Change 60359 on 2011/07/05 by cgm at magics_opensuse113
+
+    Revert Grib API version (causes crashes?)
+
+Change 60338 on 2011/07/04 by cgr at cgr
+
+    Add sceneNode identification to the QtDriver
+
+Change 60332 on 2011/07/04 by cgs at cgs_metview
+
+    metview4 : implements input data
+
+Change 60320 on 2011/07/04 by cgi at magics_cgi
+
+    MAG++: added GIF to scheduled test suite run
+
+Change 60319 on 2011/07/04 by cgi at magics_cgi
+
+    MAG++: docs / test suite compilation script - fix of syntax error
+
+Change 60317 on 2011/07/03 by cgm at cgm_meshon
+
+    GDDriver fix segmentation fault in handling fonts
+
+Change 60310 on 2011/07/02 by cgm at cgm_meshon
+
+    Update docs - add grib_info description for text
+
+Change 60309 on 2011/07/02 by cgm at cgm_meshon
+
+    DOCS small changes to documentation
+
+Change 60301 on 2011/07/02 by cgm at magics_opensuse113
+
+    Add SCIN option for ECMWF local compilations
+
+Change 60210 on 2011/07/01 by cgs at cgs_metview
+
+    Ignore: stupid type.
+
+Change 60209 on 2011/07/01 by cgs at cgs_metview
+
+    metview : more on input data and curve
+
+Change 60197 on 2011/06/30 by cgr at cgr
+
+    Development on the multiple page layout in the QtDriver 
+
+Change 60170 on 2011/06/30 by cgs at cgs_metview
+
+    Magics: allow world file description ( Florian)
+
+Change 60167 on 2011/06/30 by cgs at cgs_metview
+
+    Metview4: new action names for odb and netcdf
+
+Change 60166 on 2011/06/30 by cgs at cgs_metview
+
+    legend
+
+Change 60165 on 2011/06/30 by cgs at cgs_metview
+
+    Metview4: send an SceneLayout to describe a page ( SceneNode) 
+
+Change 60164 on 2011/06/30 by cgs at cgs_metview
+
+    Magics : axis_type --> position_list is enable again ( Marta )
+
+Change 60140 on 2011/06/29 by cgm at cgm_meshon
+
+    SVGDriver updates on scripting
+
+Change 60118 on 2011/06/29 by cgm at magics_opensuse113
+
+    PPT Slides of MAGICS6 migration seminar
+
+Change 60116 on 2011/06/29 by cgs at cgs_metview
+
+    IGNORE: stupid thing
+
+Change 60108 on 2011/06/29 by cgs at cgs_metview
+
+    Metview4-ODB : Binning object
+
+Change 60102 on 2011/06/29 by cgs at cgs_metview
+
+    Metview4-ODA : change parameter names for ODB + add deprecated messages
+
+Change 60075 on 2011/06/28 by cgm at magics_opensuse113
+
+    Add Boost Geometry header files to tarball (plus acknoledgement)
+
+Change 60072 on 2011/06/28 by cgm at magics_opensuse113
+
+    Correct path to administrative data and remove couts
+
+Change 60061 on 2011/06/28 by cgs at cgs_metview
+
+    Metview4: enable creation of metadat from a macro for Florian
+
+Change 60041 on 2011/06/28 by max at cgs_wrep_devel
+
+    WREP : to be integrated
+
+Change 60039 on 2011/06/28 by max at cgs_wrep_devel
+
+    Wrep::to be integrated!
+
+Change 59985 on 2011/06/27 by cgi at cgi_metview_4
+
+    MAG++: integrated docs update (Data chapter) into main branch
+
+Change 59961 on 2011/06/27 by cgr at cgr
+
+    Introduce MgQRootNode to the QtDriver
+
+Change 59956 on 2011/06/27 by cgm at magics
+
+    Configure add include path on 'old' platforms for Boost header files
+
+Change 59927 on 2011/06/26 by cgm at cgm_meshon
+
+    Reduce compiler warnings
+
+Change 59885 on 2011/06/24 by max at cgs_wrep_devel
+
+    ignore: stupid test
+
+Change 59884 on 2011/06/24 by max at cgs_wrep_devel
+
+    Coastlines: empty holes...
+
+Change 59883 on 2011/06/24 by cgm at magics_opensuse113
+
+    BaseDriver - remove cout messages
+
+Change 59869 on 2011/06/24 by cgr at cgr
+
+    Check if the outline of a shaded polyline should be rendered in the QtDriver. 
+
+Change 59863 on 2011/06/24 by cgr at cgr
+
+    Development on the multi-page layout in the QtDriver
+
+Change 59855 on 2011/06/24 by cgs at cgs_metview
+
+    adding boost!
+
+Change 59854 on 2011/06/24 by cgm at magics_opensuse113
+
+    Configure - remove boost options
+
+Change 59852 on 2011/06/24 by cgm at magics_opensuse113
+
+    Coast - remove stroke around fill area - prevents spurious lines at side
+
+Change 59831 on 2011/06/24 by cgm at magics_opensuse113
+
+    Configure more specific eror message for Emoslib
+
+Change 59811 on 2011/06/23 by cgs at cgs_metview
+
+    Integration change : legend was not plotted for individual symbol mode
+
+Change 59796 on 2011/06/23 by cgs at cgs_metview
+
+    boost
+
+Change 59795 on 2011/06/23 by cgs at cgs_metview
+
+    boost
+
+Change 59786 on 2011/06/23 by cgs at cgs_metview
+
+    IGNORE:Just some idea for automatic date
+
+Change 59785 on 2011/06/23 by cgs at cgs_metview
+
+    Shape and caostlines
+
+Change 59763 on 2011/06/23 by cgr at cgr
+
+    Set metadata "_datatype" for coastlines.
+
+Change 59758 on 2011/06/23 by cgr at cgr
+
+    Start new developments for multiple page layout in the QtDriver. The multiple layout code is protected by the 
+    METVIEW_MULTIPAGE macro in the QtDriver.  A new flag ( --enable-qtmultipage) was added to configure. 
+    If it is enabled (by default disabled
+
+Change 59734 on 2011/06/22 by cgm at cgm_meshon
+
+    SVGDriver reactivate layer menu
+
+Change 59674 on 2011/06/22 by cgs at cgs
+
+    implements MetaDataCollecyor for coastlines...
+
+Change 59673 on 2011/06/22 by cgs at cgs_metview
+
+    MetaDataCollector implemented for coastlines...
+
+Change 59640 on 2011/06/22 by cgm at magics_opensuse113
+
+    Coastlines - adjust resolution of used data set
+
+Change 59636 on 2011/06/22 by cgm at magics_opensuse113
+
+    SVGDriver combine shading and stroking of polylines (for size reductions)
+
+Change 59566 on 2011/06/21 by cgm at magics_opensuse113
+
+    Config - add options for proj4 and boost
+
+Change 59552 on 2011/06/21 by cgm at magics_opensuse113
+
+    Python interface - revert to April 14th before new structure
+
+Change 59547 on 2011/06/21 by cgm at magics_opensuse113
+
+    Version 2.13.3 version change - start tests with new thresholds for coast resolutions
+
+Change 59532 on 2011/06/21 by cgm at magics_opensuse113
+
+    Wind flags - improved visibility of small barbs
+
+Change 59528 on 2011/06/21 by cgi at cgi_metview_4
+
+    MAG++: updated cron job for test suite
+
+Change 59522 on 2011/06/20 by cgm at cgm_meshon
+
+    CONFIG remove debug version of library
+
+Change 59521 on 2011/06/20 by cgm at cgm_meshon
+
+    BinaryReader add scale and offset for placing binary files
+      Example: <mgb mgb_filename='coast.mgb' mgb_x='70' mgb_y='70' mgb_width='30' mgb_height='30' />
+
+Change 59480 on 2011/06/20 by cgm at magics_opensuse113
+
+    SVGDriver small clean-up of how code is stored in file (each hole a line)
+
+Change 59477 on 2011/06/20 by cgm at magics_opensuse113
+
+    PostScriptDriver Set correct symbol colour
+
+Change 59474 on 2011/06/20 by cgs at cgs_metview
+
+    TestSuite: Problem in setting the min of the fiield in the interval selection method
+
+Change 59451 on 2011/06/20 by cgm at cgm_meshon
+
+    PostScriptDriver reduce file size by setting colour more efficient
+
+Change 59408 on 2011/06/17 by cgm at magics_opensuse113
+
+    PostScriptDriver: correct logic for cell shading
+
+Change 59404 on 2011/06/17 by cgm at magics_opensuse113
+
+    CairoDriver: corrected colours for cell shading (Johannes Kaiser)
+
+Change 59399 on 2011/06/17 by cgm at magics_opensuse113
+
+    PostScriptDriver remove blank lines and but test for zero length lines back
+
+Change 59398 on 2011/06/17 by cgi at magics_cgi
+
+    MAG++: changed the MagML example used in the 'checkup' test suite to something that works(!)
+
+Change 59392 on 2011/06/17 by cgs at cgs_metview
+
+    WrepPlot: Input Matrix -> Speed and direction 
+
+Change 59382 on 2011/06/16 by cgm at magics_opensuse113
+
+    Trial for fixing cell shading problem
+
+Change 59370 on 2011/06/16 by cgm at magics_opensuse113
+
+    Clean-up wind
+
+Change 59367 on 2011/06/16 10:45:12 by cgm at magics_opensuse113
+
+        Fix bug when markers are set to OFF
+
+Change 59366 on 2011/06/16 10:26:17 by cgs at cgs
+
+        Fix for wind flags in legend 
+
+Change 59345 on 2011/06/16 08:14:00 by cgm at magics_opensuse113
+
+        MAG++ PS increased dot size for dot shading
+
+Change 59338 on 2011/06/15 15:35:21 by cgm at magics_opensuse113
+
+        MAG++ PS fix leak in dot shading (austria layout)
+
+Change 59326 on 2011/06/15 13:41:08 by cgs at cgs
+
+        pcoast
+
+Change 59320 on 2011/06/15 12:38:53 by cgs at cgs
+
+        Fix for HiLoBlanking
+
+Change 59296 on 2011/06/15 09:07:45 by cgm at magics_opensuse113
+
+        MAG++ PS remove debug option
+
+Change 59295 on 2011/06/15 09:05:06 by cgm at magics_opensuse113
+
+        MAG++ SYMBOLS fix wind flag direction
+
+Change 59291 on 2011/06/15 08:23:44 by cgm at magics_opensuse113
+
+        MAG++ PS put ps_scale back
+
+Change 59290 on 2011/06/15 07:40:33 by cgm at magics_opensuse113
+
+        MAG++ CAIRO remove dependency to jpeg
+
+Change 59256 on 2011/06/14 08:59:07 by cgm at magics_opensuse113
+
+        MAG++ version 1.12.9
+
+Change 59227 on 2011/06/13 15:19:12 by cgs at cgs
+
+        Mapgen 
+
+Change 58883 on 2011/06/02 15:04:16 by cgi at mv4_suse103_inst
+
+        MAG++: updated ODB-2 version to 0.8.5 [r2.12 branch]
+
+Change 54787 on 2011/05/24 14:22:10 by cgm at magics_opensuse113
+
+        MAG++ new version 2.12.8
+
+Change 54786 on 2011/05/24 14:20:46 by cgs at cgs
+
+        Legend
+
+Change 54711 on 2011/05/23 13:49:55 by cgs at cgs
+
+        Threads
+
+Change 54703 on 2011/05/23 08:08:03 by cgm at magics_opensuse113
+
+        MAG++ CONFIG add --disable-threads option
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..54caf7c
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,229 @@
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
+Foundation, Inc.
+
+   This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+   These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  (Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.)
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You only need
+`configure.ac' if you want to change it or regenerate `configure' using
+a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not support the `VPATH'
+variable, you have to compile the package for one architecture at a
+time in the source code directory.  After you have installed the
+package for one architecture, use `make distclean' before reconfiguring
+for another architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the `--target=TYPE' option to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+will cause the specified gcc to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f4ed7ed
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright 2007-2012 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..46fa43c
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,82 @@
+
+SUBDIRS       = src apps python/Magics test tools 
+DIST_SUBDIRS  = src apps test tools python/Magics rpms
+
+ 
+EXTRA_DIST    = LICENSE NOTICE config share version.sh m4/magics.m4
+
+
+bin_SCRIPTS   = magics-config
+
+
+ACLOCAL_AMFLAGS = -I m4
+m4datadir       = $(datadir)/aclocal
+m4data_DATA     = m4/magics.m4
+
+
+quiet:
+	make --quiet install
+
+
+#
+#  DOCS
+#
+docs: clean-docs
+	cd docs && \
+	doxygen Magics.dox
+	echo ""
+	echo " Warnings and errors are written in /docs/Magics.dox.error.out"
+	echo ""
+	echo " Now open file://${PWD}/docs/api/html/index.html in your browser."
+	echo ""
+
+manual:
+	cd docs/manual/ && \
+	./make_plots  && \
+	./make_all_docs -targets -pdf && \
+	./make_all_docs -pdf 
+	echo ""
+	echo " Manual (PDF) are in docs/manual/publish/pdf/*.pdf"
+	echo ""
+
+#
+#  CLEAN-UP
+#  
+clean-docs:
+	-rm -rf docs/api
+
+clean-output:
+	-rm -f test/*/*.svg test/*/*.ps test/*/*.eps test/*/*.pdf test/*/*.png test/*/*.gif test/*/*.kml
+
+clean-all: clean clean-coast clean-output
+	-rm -rf docs/api/html docs/api/xml
+	-rm -rf docs/www/html/test/*
+	-rm -rf test/*/*.o
+	-rm -f src/*/*Attributes.*
+
+
+#
+#  TEST SUITE
+#
+test-suite:
+	PATH=$(prefix)/bin:${PATH} ; cd docs/www/testsuite/progs/ ; ./setbin -shared ; ./cleanmpponly ; \
+	./make_testsuite -nomag69 -shared ; \
+	./make_c_testsuite ; \
+	./make_magml_testsuite
+
+test-suite-static:
+	cd docs/www/testsuite/progs/ ; ./setbin -static ; ./cleanmpponly
+	./make_testsuite -static
+
+
+RPM = rpm
+
+rpms srcrpm: dist
+	(cd rpms && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1
+	rpmarch=`$(RPM) --showrc | grep "^build arch" | \
+	sed 's/\(.*: \)\(.*\)/\2/'`; \
+	test -z "rpms/$$rpmarch" || \
+	 ( mv rpms/$$rpmarch/* rpms/. && rm -rf rpms/$$rpmarch )
+	rm -rf rpms/$(distdir)
+
+.PHONY: srcrpm rpms
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..60e79fe
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,946 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in $(srcdir)/magics-config.in \
+	$(top_srcdir)/configure $(top_srcdir)/docs/Magics.dox.in \
+	AUTHORS COPYING ChangeLog INSTALL NEWS config/README \
+	config/config.guess config/config.sub config/depcomp \
+	config/install-sh config/ltmain.sh config/missing \
+	config/py-compile
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES = magics-config docs/Magics.dox
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(m4datadir)"
+SCRIPTS = $(bin_SCRIPTS)
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+DATA = $(m4data_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir dist dist-all distcheck
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = src apps python/Magics test tools 
+DIST_SUBDIRS = src apps test tools python/Magics rpms
+EXTRA_DIST = LICENSE NOTICE config share version.sh m4/magics.m4
+bin_SCRIPTS = magics-config
+ACLOCAL_AMFLAGS = -I m4
+m4datadir = $(datadir)/aclocal
+m4data_DATA = m4/magics.m4
+RPM = rpm
+all: all-recursive
+
+.SUFFIXES:
+am--refresh:
+	@:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	$(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+magics-config: $(top_builddir)/config.status $(srcdir)/magics-config.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+docs/Magics.dox: $(top_builddir)/config.status $(top_srcdir)/docs/Magics.dox.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n' \
+	    -e 'h;s|.*|.|' \
+	    -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+	      if (++n[d] == $(am__install_max)) { \
+		print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+	    else { print "f", d "/" $$4, $$1 } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	     if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	     test -z "$$files" || { \
+	       echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	       $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	     } \
+	; done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	       sed -e 's,.*/,,;$(transform)'`; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool config.lt
+install-m4dataDATA: $(m4data_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(m4datadir)" || $(MKDIR_P) "$(DESTDIR)$(m4datadir)"
+	@list='$(m4data_DATA)'; test -n "$(m4datadir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(m4datadir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(m4datadir)" || exit $$?; \
+	done
+
+uninstall-m4dataDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(m4data_DATA)'; test -n "$(m4datadir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(m4datadir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(m4datadir)" && rm -f $$files
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	test -d "$(distdir)" || mkdir "$(distdir)"
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+	-test -n "$(am__skip_mode_fix)" \
+	|| find "$(distdir)" -type d ! -perm -755 \
+		-exec chmod u+rwx,go+rx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+dist-bzip2: distdir
+	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	$(am__remove_distdir)
+
+dist-lzma: distdir
+	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+	$(am__remove_distdir)
+
+dist-xz: distdir
+	tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+	$(am__remove_distdir)
+
+dist-tarZ: distdir
+	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+	$(am__remove_distdir)
+
+dist-shar: distdir
+	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	$(am__remove_distdir)
+
+dist-zip: distdir
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(am__remove_distdir)
+
+dist dist-all: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+	case '$(DIST_ARCHIVES)' in \
+	*.tar.gz*) \
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+	*.tar.bz2*) \
+	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lzma*) \
+	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
+	*.tar.xz*) \
+	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+	*.tar.Z*) \
+	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+	*.shar.gz*) \
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+	*.zip*) \
+	  unzip $(distdir).zip ;;\
+	esac
+	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	mkdir $(distdir)/_build
+	mkdir $(distdir)/_inst
+	chmod a-w $(distdir)
+	test -d $(distdir)/_build || exit 0; \
+	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && am__cwd=`pwd` \
+	  && $(am__cd) $(distdir)/_build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist \
+	  && rm -rf $(DIST_ARCHIVES) \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+	  && cd "$$am__cwd" \
+	  || exit 1
+	$(am__remove_distdir)
+	@(echo "$(distdir) archives ready for distribution: "; \
+	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+	@$(am__cd) '$(distuninstallcheck_dir)' \
+	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	@if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(SCRIPTS) $(DATA)
+installdirs: installdirs-recursive
+installdirs-am:
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(m4datadir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool \
+	distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-m4dataDATA
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-binSCRIPTS
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf $(top_srcdir)/autom4te.cache
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-binSCRIPTS uninstall-m4dataDATA
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+	install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am am--refresh check check-am clean clean-generic \
+	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
+	dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
+	distcheck distclean distclean-generic distclean-libtool \
+	distclean-tags distcleancheck distdir distuninstallcheck dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binSCRIPTS install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-m4dataDATA install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am uninstall-binSCRIPTS \
+	uninstall-m4dataDATA
+
+
+quiet:
+	make --quiet install
+
+#
+#  DOCS
+#
+docs: clean-docs
+	cd docs && \
+	doxygen Magics.dox
+	echo ""
+	echo " Warnings and errors are written in /docs/Magics.dox.error.out"
+	echo ""
+	echo " Now open file://${PWD}/docs/api/html/index.html in your browser."
+	echo ""
+
+manual:
+	cd docs/manual/ && \
+	./make_plots  && \
+	./make_all_docs -targets -pdf && \
+	./make_all_docs -pdf 
+	echo ""
+	echo " Manual (PDF) are in docs/manual/publish/pdf/*.pdf"
+	echo ""
+
+#
+#  CLEAN-UP
+#  
+clean-docs:
+	-rm -rf docs/api
+
+clean-output:
+	-rm -f test/*/*.svg test/*/*.ps test/*/*.eps test/*/*.pdf test/*/*.png test/*/*.gif test/*/*.kml
+
+clean-all: clean clean-coast clean-output
+	-rm -rf docs/api/html docs/api/xml
+	-rm -rf docs/www/html/test/*
+	-rm -rf test/*/*.o
+	-rm -f src/*/*Attributes.*
+
+#
+#  TEST SUITE
+#
+test-suite:
+	PATH=$(prefix)/bin:${PATH} ; cd docs/www/testsuite/progs/ ; ./setbin -shared ; ./cleanmpponly ; \
+	./make_testsuite -nomag69 -shared ; \
+	./make_c_testsuite ; \
+	./make_magml_testsuite
+
+test-suite-static:
+	cd docs/www/testsuite/progs/ ; ./setbin -static ; ./cleanmpponly
+	./make_testsuite -static
+
+rpms srcrpm: dist
+	(cd rpms && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1
+	rpmarch=`$(RPM) --showrc | grep "^build arch" | \
+	sed 's/\(.*: \)\(.*\)/\2/'`; \
+	test -z "rpms/$$rpmarch" || \
+	 ( mv rpms/$$rpmarch/* rpms/. && rm -rf rpms/$$rpmarch )
+	rm -rf rpms/$(distdir)
+
+.PHONY: srcrpm rpms
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..d76e334
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,141 @@
+Magics++ News (for users)
+=========================
+
+MAGICS++ Version 2.12.9 ( June 2011)
+
+ * Bug fixes (layout, MapGen, Dot shading)
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.12.8 ( May 2011)
+
+ * Bug fixes (legend)
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.12.7 ( May 2011)
+
+ * Bug fixes (layout)
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.12.2 ( January 2011)
+
+ * Bug fixes (layout, NetCDF handling)
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.12 ( November 2010)
+
+ * NEW threaded contouring
+ * NEW use high quality shape files from http://www.naturalearthdata.com/
+       for coast lines & rivers 
+ * Allow plotting of metgrams from Weather Parameter BUFR files 
+       (using Python interface)
+ * Improved BUFR synop plotting
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.10 ( April 2010)
+
+ * NEW object-oriented Python interface (magmacro.py)
+ * NEW action routine PIMPORT to include raster graphics into plots (for logos, etc) 
+ * Improved BUFR synop plotting
+ * Updates on Geopoint interface
+ * Clean-up of installation routines
+ * Uses Grib_API 1.8x & 1.9.0
+ * New object-oriented Python interface (magmacro.py)
+ * Test suite is made to compile outside ECMWF
+ * Development was driven mainly by Metview 4 developments and WREP
+ * Removal of OpenGL driver and replacement through a Qt based driver
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.8 ( October 2009)
+
+ * Improvements in the graph plotting
+ * Improved satellite plotting
+ * More options on InputMatrix for irregular grid
+ * NEW Introduction of a parameter 'subpage_mapping'. If this parameter is set 
+   'automatic', the geographical area will be automatically adjusted to the plotted 
+   data. This option is only available for cylindrical and mercator projection. 
+   The default is 'user_defined'. Requested by Tigge team.
+ * NEW Introduction of a shading technique (parameter contour_shade_technique = 'grid_shading'). 
+   This shading technique will attach a colour to each grid point of the grid. 
+   No interpolation is performed - a filled box is drawn around each grid point.
+ * Improved Taylor diagram
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.6 ( October 2008)
+
+  * Changes in contouring and shading, including better support for missing data
+  * Add rotated grid
+  * Bug fixes related to NetCDF cross-sections
+  * Better support for multiple POPEN calls 
+  * Bug fixes in drivers related to wind plotting
+  * Adjustment of Mercator projection
+  * Small fix in wind plotting
+  * Fix FFT support in raster output (PNG, GIF - only AIX was affected)
+  * Smaller bugs fixes and improvements
+
+This release contains the first prototype of a C++ and Python interfaces; please 
+contact us if you want to use it. 
+
+-----------------------------------------------------------------------------------
+
+ MAGICS++ Version 2.4.3 (17th March 2008)
+
+    * Current export version becomes 2.4.3
+    * Bug fixes in drivers related to wind plotting
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.4.2 (6th March 2008)
+
+    * Current export version becomes 2.4.2
+
+-----------------------------------------------------------------------------------
+
+MAGICS++ Version 2.4.1 (3rd March 2008)
+
+    * Disable by default page frame
+    * Small bug fixes 
+
+
+2.4.0
+=====
+
+ - Moved to GribAPI 1.4.0
+ - All files of 'share/' have been mobved to 'share/magics/'
+ - PostScript driver does NOT use anymore the 'share/magics/Printercap' file anymore
+ - Default scaling for PostScript output is now 1.0 instead of 0.95
+ - New drivers added Cairo + KML
+
+26th March 2007 - 2.0.0
+=======================
+
+ - New text and title handling
+
+1.3.0
+=====
+ 
+ - Support for boxplots with new action routine PBOXPLOT
+ - Support for geographical areas larger than 360 degrees of longitude 
+
+1.2.0
+=====
+
+ - Add C interface
+ - New coastline database with lakes and rivers
+
+1.1.0 
+=====
+
+ - EPSgram on the web is now using Magics++ operationally
+ - Cross sections taken from NetCDF data can now be visualised 
+
+30th November 2005
+==================
+     
+Release of Magics++ version 1.0 at ECMWF (Linux 32 and 64 bit)
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..fefab6e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,152 @@
+Magics++
+========
+
+Copyright 2007-2012 ECMWF
+
+This product mainly includes software developed by the 
+
+  Meteorological Visualisation Section
+
+at the 
+
+  "European Centre for Medium-Range Weather Forecasts" 
+           (ECMWF - http://www.ecmwf.int ).
+
+Below is a list of software packages which are used inside Magics++:
+
+
+Terralib
+========
+
+This software contains code derived from the Terralib library developed by 
+National Institute for Space Research (INPE, Brazil). More information about Terralib
+can be found at http://www.terralib.org . The library is distributed under 
+the LGPL but special permission was granted to allow ECMWF the distribution 
+of the code within Magics++.
+
+ECMWF has a close co-operation with INPE regarding the development of 
+visualisation software.
+
+
+shapelib
+========
+http://shapelib.maptools.org/license.html
+
+Copyright (c) 1999, Frank Warmerdam
+
+This software is available under the following "MIT Style" license, or at the option 
+of the licensee under the LGPL (see LICENSE.LGPL). This option is discussed in more 
+detail in shapelib.html.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this 
+software and associated documentation files (the "Software"), to deal in the Software 
+without restriction, including without limitation the rights to 
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
+of the Software, and to permit persons to whom the Software is furnished to do so, 
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies 
+or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+MINIZIP
+=======
+
+   http://www.winimage.com/zLibDll/minizip.html
+
+
+/* zip.h -- IO for compress .zip files using zlib
+   Version 1.01e, February 12th, 2005
+
+   Copyright (C) 1998-2005 Gilles Vollant
+
+   This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
+     WinZip, InfoZip tools and compatible.
+   Multi volume ZipFile (span) are not supported.
+   Encryption compatible with pkzip 2.04g only supported
+   Old compressions used by old PKZip 1.x are not supported
+
+  For uncompress .zip file, look at unzip.h
+
+   I WAIT FEEDBACK at mail info at winimage.com
+   Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
+
+   Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+*/
+
+
+JSON_SPIRIT_READER
+==================
+
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   json spirit version 4.00
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+
+NATURAL EARTH
+=============
+http://www.naturalearthdata.com/
+
+Natural Earth is a public domain map dataset available at 
+1:10m, 1:50m, and 1:110 million scales. 
+Featuring tightly integrated vector and raster data, with Natural Earth 
+you can make a variety of visually pleasing, 
+well-crafted maps with cartography or GIS software.
+
+Natural Earth was built through a collaboration of many volunteers  
+and is supported by NACIS  (North American Cartographic Information Society), 
+and is free for use in any type of project (see Terms of Use  page for more information).
+http://www.naturalearthdata.com/about/terms-of-use/
+
+
+Boost Software License - Version 1.0 - August 17th, 2003
+========================================================
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..08645e0
--- /dev/null
+++ b/README
@@ -0,0 +1,49 @@
+
+Magics++ README
+===============
+
+1. Changes to MAGICS 6
+2. Getting the source
+3. Installation
+4. License
+
+
+1. Changes to MAGICS 6
+======================
+
+Before you install Magics++ you might want to check the
+list features of MAGICS 6 not implemented (yet):
+
+- support for Lambert projection
+- wind: streamlines and isotachs
+- specification groups
+- pie charts
+
+Changes
+-------
+
+- Default coast line colour has change from yellow to black
+
+- Default scaling of PostScript output is now 1.0 instead of 0.95
+   --> set parameter OUTPUT_PS_SCALE to 0.95 if the old scaling is required
+   
+   
+
+2. Getting the source
+=====================
+
+The tarball of the source can be downloaded from Software Services 
+at ECMWF ( http://www.ecmwf.int/products/data/software/magics++.html ).
+
+
+2. Installation
+===============
+
+Please read the installation guide:
+http://www.ecmwf.int/publications/manuals/magics/magplus/manuals/pdf/magics_install.pdf
+
+
+3. License
+==========
+
+Please read COPYING and LICENSE.
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
index 0000000..be0f718
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,1374 @@
+# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
+[m4_warning([this file was generated for autoconf 2.65.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# 
+# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+		
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+        else 
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+		[AC_MSG_RESULT([no])
+                $4])
+elif test $pkg_failed = untried; then
+	ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
+		[$4])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11.1], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.11.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 10
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+#serial 5
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 8
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 16
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+			     [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+		  [_AM_DEPENDENCIES(CC)],
+		  [define([AC_PROG_CC],
+			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+		  [_AM_DEPENDENCIES(CXX)],
+		  [define([AC_PROG_CXX],
+			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+		  [_AM_DEPENDENCIES(OBJC)],
+		  [define([AC_PROG_OBJC],
+			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 6
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 4
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------
+# Adds support for distributing Python modules and packages.  To
+# install modules, copy them to $(pythondir), using the python_PYTHON
+# automake variable.  To install a package with the same name as the
+# automake package, install to $(pkgpythondir), or use the
+# pkgpython_PYTHON automake variable.
+#
+# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
+# locations to install python extension modules (shared libraries).
+# Another macro is required to find the appropriate flags to compile
+# extension modules.
+#
+# If your package is configured with a different prefix to python,
+# users will have to add the install directory to the PYTHONPATH
+# environment variable, or create a .pth file (see the python
+# documentation for details).
+#
+# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
+# cause an error if the version of python installed on the system
+# doesn't meet the requirement.  MINIMUM-VERSION should consist of
+# numbers and dots only.
+AC_DEFUN([AM_PATH_PYTHON],
+ [
+  dnl Find a Python interpreter.  Python versions prior to 2.0 are not
+  dnl supported. (2.0 was released on October 16, 2000).
+  m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
+                    [python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl
+python2.1 python2.0])
+
+  m4_if([$1],[],[
+    dnl No version check is needed.
+    # Find any Python interpreter.
+    if test -z "$PYTHON"; then
+      AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
+    fi
+    am_display_PYTHON=python
+  ], [
+    dnl A version check is needed.
+    if test -n "$PYTHON"; then
+      # If the user set $PYTHON, use it and don't search something else.
+      AC_MSG_CHECKING([whether $PYTHON version >= $1])
+      AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
+			      [AC_MSG_RESULT(yes)],
+			      [AC_MSG_ERROR(too old)])
+      am_display_PYTHON=$PYTHON
+    else
+      # Otherwise, try each interpreter until we find one that satisfies
+      # VERSION.
+      AC_CACHE_CHECK([for a Python interpreter with version >= $1],
+	[am_cv_pathless_PYTHON],[
+	for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
+	  test "$am_cv_pathless_PYTHON" = none && break
+	  AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
+	done])
+      # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
+      if test "$am_cv_pathless_PYTHON" = none; then
+	PYTHON=:
+      else
+        AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+      fi
+      am_display_PYTHON=$am_cv_pathless_PYTHON
+    fi
+  ])
+
+  if test "$PYTHON" = :; then
+  dnl Run any user-specified action, or abort.
+    m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
+  else
+
+  dnl Query Python for its version number.  Getting [:3] seems to be
+  dnl the best way to do this; it's what "site.py" does in the standard
+  dnl library.
+
+  AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
+    [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
+  AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
+
+  dnl Use the values of $prefix and $exec_prefix for the corresponding
+  dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
+  dnl distinct variables so they can be overridden if need be.  However,
+  dnl general consensus is that you shouldn't need this ability.
+
+  AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
+  AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
+
+  dnl At times (like when building shared libraries) you may want
+  dnl to know which OS platform Python thinks this is.
+
+  AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
+    [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
+  AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
+
+
+  dnl Set up 4 directories:
+
+  dnl pythondir -- where to install python scripts.  This is the
+  dnl   site-packages directory, not the python standard library
+  dnl   directory like in previous automake betas.  This behavior
+  dnl   is more consistent with lispdir.m4 for example.
+  dnl Query distutils for this directory.  distutils does not exist in
+  dnl Python 1.5, so we fall back to the hardcoded directory if it
+  dnl doesn't work.
+  AC_CACHE_CHECK([for $am_display_PYTHON script directory],
+    [am_cv_python_pythondir],
+    [if test "x$prefix" = xNONE
+     then
+       am_py_prefix=$ac_default_prefix
+     else
+       am_py_prefix=$prefix
+     fi
+     am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null ||
+     echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
+     case $am_cv_python_pythondir in
+     $am_py_prefix*)
+       am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+       am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
+       ;;
+     *)
+       case $am_py_prefix in
+         /usr|/System*) ;;
+         *)
+	  am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
+	  ;;
+       esac
+       ;;
+     esac
+    ])
+  AC_SUBST([pythondir], [$am_cv_python_pythondir])
+
+  dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
+  dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
+  dnl   more consistent with the rest of automake.
+
+  AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
+
+  dnl pyexecdir -- directory for installing python extension modules
+  dnl   (shared libraries)
+  dnl Query distutils for this directory.  distutils does not exist in
+  dnl Python 1.5, so we fall back to the hardcoded directory if it
+  dnl doesn't work.
+  AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
+    [am_cv_python_pyexecdir],
+    [if test "x$exec_prefix" = xNONE
+     then
+       am_py_exec_prefix=$am_py_prefix
+     else
+       am_py_exec_prefix=$exec_prefix
+     fi
+     am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null ||
+     echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
+     case $am_cv_python_pyexecdir in
+     $am_py_exec_prefix*)
+       am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+       am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
+       ;;
+     *)
+       case $am_py_exec_prefix in
+         /usr|/System*) ;;
+         *)
+	   am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
+	   ;;
+       esac
+       ;;
+     esac
+    ])
+  AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
+
+  dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
+
+  AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
+
+  dnl Run any user-specified action.
+  $2
+  fi
+
+])
+
+
+# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
+# Run ACTION-IF-FALSE otherwise.
+# This test uses sys.hexversion instead of the string equivalent (first
+# word of sys.version), in order to cope with versions such as 2.2c1.
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
+AC_DEFUN([AM_PYTHON_CHECK_VERSION],
+ [prog="import sys
+# split strings by '.' and convert to numeric.  Append some zeros
+# because we need at least 4 digits for the hex conversion.
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
+minverhex = 0
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
+sys.exit(sys.hexversion < minverhex)"
+  AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   (exit $ac_status); }])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# (`yes' being less verbose, `no' or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules],
+[  --enable-silent-rules          less verbose build output (undo: `make V=1')
+  --disable-silent-rules         verbose build output (undo: `make V=0')])
+case $enable_silent_rules in
+yes) AM_DEFAULT_VERBOSITY=0;;
+no)  AM_DEFAULT_VERBOSITY=1;;
+*)   AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/ax_boost_base.m4])
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
diff --git a/apps/MagMLInterpretor/Makefile.am b/apps/MagMLInterpretor/Makefile.am
new file mode 100644
index 0000000..6a8f249
--- /dev/null
+++ b/apps/MagMLInterpretor/Makefile.am
@@ -0,0 +1,27 @@
+AUTOMAKE_OPTIONS = foreign
+
+if MAGICS_BUFR
+FORTRAN_LIBS = $(FLIBS)
+endif
+
+if MAGICS_JSON
+JSON_PROG = magjson
+JSON_CODE = json.cc
+endif
+
+AM_LDFLAGS  = -L$(top_builddir)/src
+LIBS        = -lMagPlus ${MAGICS_3RDPARTY_LIBS} $(FORTRAN_LIBS) 
+
+#AM_LDFLAGS="-Wl,-rpath,$(libdir)"
+
+AM_CPPFLAGS	= -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/web
+
+if MAGICS_QT
+AM_CPPFLAGS += -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+AM_LDFLAGS  += $(QT_LIBS)
+endif
+
+
+bin_PROGRAMS	= magmlx ${JSON_PROG}
+magmlx_SOURCES	= magml.cc 
+magjson_SOURCES	= ${JSON_CODE}
diff --git a/apps/MagMLInterpretor/Makefile.in b/apps/MagMLInterpretor/Makefile.in
new file mode 100644
index 0000000..79e1300
--- /dev/null
+++ b/apps/MagMLInterpretor/Makefile.in
@@ -0,0 +1,631 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_QT_TRUE@am__append_1 = -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+ at MAGICS_QT_TRUE@am__append_2 = $(QT_LIBS)
+bin_PROGRAMS = magmlx$(EXEEXT) $(am__EXEEXT_1)
+subdir = apps/MagMLInterpretor
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+ at MAGICS_JSON_TRUE@am__EXEEXT_1 = magjson$(EXEEXT)
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am__magjson_SOURCES_DIST = json.cc
+ at MAGICS_JSON_TRUE@am__objects_1 = json.$(OBJEXT)
+am_magjson_OBJECTS = $(am__objects_1)
+magjson_OBJECTS = $(am_magjson_OBJECTS)
+magjson_LDADD = $(LDADD)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am_magmlx_OBJECTS = magml.$(OBJEXT)
+magmlx_OBJECTS = $(am_magmlx_OBJECTS)
+magmlx_LDADD = $(LDADD)
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(magjson_SOURCES) $(magmlx_SOURCES)
+DIST_SOURCES = $(am__magjson_SOURCES_DIST) $(magmlx_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = -lMagPlus ${MAGICS_3RDPARTY_LIBS} $(FORTRAN_LIBS) 
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+ at MAGICS_BUFR_TRUE@FORTRAN_LIBS = $(FLIBS)
+ at MAGICS_JSON_TRUE@JSON_PROG = magjson
+ at MAGICS_JSON_TRUE@JSON_CODE = json.cc
+AM_LDFLAGS = -L$(top_builddir)/src $(am__append_2)
+
+#AM_LDFLAGS="-Wl,-rpath,$(libdir)"
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel \
+	-I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common \
+	-I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers \
+	-I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/web \
+	$(am__append_1)
+magmlx_SOURCES = magml.cc 
+magjson_SOURCES = ${JSON_CODE}
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign apps/MagMLInterpretor/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign apps/MagMLInterpretor/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+magjson$(EXEEXT): $(magjson_OBJECTS) $(magjson_DEPENDENCIES) 
+	@rm -f magjson$(EXEEXT)
+	$(AM_V_CXXLD)$(CXXLINK) $(magjson_OBJECTS) $(magjson_LDADD) $(LIBS)
+magmlx$(EXEEXT): $(magmlx_OBJECTS) $(magmlx_DEPENDENCIES) 
+	@rm -f magmlx$(EXEEXT)
+	$(AM_V_CXXLD)$(CXXLINK) $(magmlx_OBJECTS) $(magmlx_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/json.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/magml.Po at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binPROGRAMS install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am \
+	uninstall-binPROGRAMS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/apps/MagMLInterpretor/json.cc b/apps/MagMLInterpretor/json.cc
new file mode 100644
index 0000000..cd9604d
--- /dev/null
+++ b/apps/MagMLInterpretor/json.cc
@@ -0,0 +1,74 @@
+#include "WebFormat.h"
+
+using namespace magics;
+
+namespace magml
+{
+
+pair<string, string> cut(const string& in)
+{
+	string::const_iterator c = in.begin();
+	string var;
+	string current;
+	bool  param = true;
+
+	while ( c != in.end() )
+	{		
+		if ( *c == '='  && param )
+		{			
+			var = current;
+			current = "";
+			param= false;
+		}
+		else {
+			current.push_back(*c);
+		}
+		c++;
+	}
+	return make_pair(var, current);
+}
+
+void setVariable(const string& in, map<string, string>& variables)
+{
+	if(in[0] != '-')
+	{
+		MagLog::warning() << "argument " << in << " ignored."<<endl;
+		return;
+	}
+	variables.insert(magml::cut(in.substr(1, in.size())));
+}
+
+} //end of namespace magml
+
+int main(int argc, char **argv)
+{
+  try
+    {
+	if(argc<2)
+	{
+		cout << " Usage: " << argv[0] << " file.json [-varname=varvalue]"<< endl;
+		exit (1);
+	}
+
+	map<string, string> variables;
+
+	for( int i = 2; i < argc; i++ )
+		magml::setVariable(argv[i], WebInterpretor::parameters());
+
+	//for ( int i = 0; i < 10; i++) 
+	{
+		try {
+			WebInterpretor::json(argv[1]);
+		}
+		catch (...) {
+			cout << argv[0] << " FAILED to dispatch JSON file!"<< endl;
+			exit(1);
+		}
+	}
+    }
+    catch (MagicsException& e)
+    {
+		cout << "MagJson: Catch Exception " << e << endl;
+		exit(1);
+    }
+}
diff --git a/apps/MagMLInterpretor/magml.cc b/apps/MagMLInterpretor/magml.cc
new file mode 100644
index 0000000..153abf4
--- /dev/null
+++ b/apps/MagMLInterpretor/magml.cc
@@ -0,0 +1,118 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+#include "WebFormat.h"
+#include <unistd.h>
+#include <signal.h>
+#include <new>
+#include "Timer.h"
+
+using namespace magics;
+
+namespace magml
+{
+
+pair<string, string> cut(const string& in)
+{
+	string::const_iterator c = in.begin();
+	string var;
+	string current;
+	bool  param = true;
+
+	while ( c != in.end() )
+	{
+		if ( *c == '='  && param )
+		{			
+			var = current;
+			current = "";
+			param= false;
+		}
+		else {
+			current.push_back(*c);
+		}
+		c++;
+	}
+	return make_pair(var, current);
+}
+
+void setVariable(const string& in, map<string, string>& variables)
+{
+	if(in[0] != '-')
+	{
+		MagLog::warning() << "argument " << in << " ignored.\n";
+		return;
+	}
+	variables.insert(magml::cut(in.substr(1, in.size())));
+}
+
+} //end of namespace magml
+
+void catch_alarm(int)
+{
+	printf("MagPlus ERROR: Operation timed out. Exiting...\n");
+	abort();   
+}
+
+void no_memory ()
+{
+	printf("MagPlus ERROR: Failed to allocate memory!\n");
+	abort();   
+}
+
+
+int main(int argc, char **argv)
+{
+  set_new_handler(no_memory);
+  try
+  {
+	if(argc<2)
+	{
+		MagLog::error() << " Usage: " << argv[0] << " file.magml [-varname=varvalue] -timeout=seconds)\n";		   
+		exit (1);
+	}
+
+	map<string, string> variables;
+
+	for( int i = 2; i < argc; i++ )
+		magml::setVariable(argv[i], WebInterpretor::parameters());
+
+	//for ( int i = 0; i < 10; i++) 
+	{
+	try
+	{
+		map<string, string>::const_iterator out = WebInterpretor::parameters().find("timeout");
+		int timeout = (out == WebInterpretor::parameters().end() ) ? 0 : tonumber(out->second);
+		MagLog::info() << "Time out armed for " << timeout << endl; 
+		signal(SIGALRM, catch_alarm);
+		alarm(timeout); 
+		WebInterpretor::magml(argv[1]);
+		alarm(0);
+	}
+	catch (...) {
+		abort();
+	}
+	}
+  }
+  catch (MagicsException& e)
+  {
+	printf("MagPlus ERROR: Fatal!\n");
+	abort();
+  }
+}
diff --git a/apps/Makefile.am b/apps/Makefile.am
new file mode 100644
index 0000000..f1f8d44
--- /dev/null
+++ b/apps/Makefile.am
@@ -0,0 +1,5 @@
+AUTOMAKE_OPTIONS	= foreign
+
+if MAGICS_APPS
+SUBDIRS			= MagMLInterpretor metgram
+endif
diff --git a/apps/Makefile.in b/apps/Makefile.in
new file mode 100644
index 0000000..dd385ec
--- /dev/null
+++ b/apps/Makefile.in
@@ -0,0 +1,642 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = apps
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = MagMLInterpretor metgram
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+ at MAGICS_APPS_TRUE@SUBDIRS = MagMLInterpretor metgram
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign apps/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign apps/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+	install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/apps/metgram/10_days_epsgram.xml b/apps/metgram/10_days_epsgram.xml
new file mode 100644
index 0000000..70a3b21
--- /dev/null
+++ b/apps/metgram/10_days_epsgram.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a4" orientation="portrait">
+	<definition>
+		
+		<epsgram id="station" 
+                station_name='$station' date='' time=''
+                latitude="$latitude" longitude="$longitude" station_height='$height'
+                eps_database='$database/epsdb'> 
+                <none/>
+        </epsgram>
+	
+        <text id="title" font='sansserif' colour='blue' font_size='0.4'
+               justification='left' display='absolute'>	
+		</text>
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='kelly_green'>
+			<nolabel/>
+			<date/>
+			<noline/>
+            <minortick colour='kelly_green'/>
+			<grid line_style="dot" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='kelly_green'>
+			<noline/>
+            <label colour='kelly_green' quality='sansserif' height='0.3'/>
+			<grid line_style="dot" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</vertical_axis>        
+		<map id='box'  margin_bottom='7%' margin_top='15%' border-colour='Rgb(0.5, 0.5, 0.5)'/>
+	</definition>
+	<drivers>
+		<$ps/>
+		<$pdf/>
+		<$png/>
+		<$gif/>
+		<$svg/>
+	</drivers>
+
+	<page height="7.5%" border='off'>
+		<nopageid/>
+	</page>
+
+	<page height="20%" border='off'>
+		<nopageid/> 
+		<map use_id='box'>
+		<cartesian>
+			<x_date   automatic='on'/>
+			<y_regular y_min='0' y_max='8'/>
+		</cartesian>  
+
+	<text margin_bottom='80%' use_id='title'/>
+	<horizontal_axis use_id='haxis'/>    
+	   <vertical_axis  use_id='vaxis'/> 
+	<plot>                
+			<epsgram use_id="station" parameter="cloud-cover" long_title='true'/>
+			<epsgraph deterministic='on' whisker='on'> <both/> </epsgraph>
+		</plot>
+	  </map>
+	</page>
+
+          <page height="20%" border='off'> 
+          <nopageid/> 
+          <map use_id='box'>
+       
+          <cartesian>
+			<x_date  automatic='on'/>
+            <y_regular automatic='on'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>    
+		   <vertical_axis  use_id='vaxis'/>            
+           <text margin_bottom='84%' use_id='title'/>             
+           <plot>
+                <epsgram use_id="station" y_axis_threshold='3'  parameter="precip"/>
+				<epsgraph deterministic='on' whisker='on'> <both/> </epsgraph>
+			</plot>
+		  </map>
+          </page>
+          <page height="20%" border='off'> 
+          <nopageid/>
+           <map  use_id='box'>
+       
+          <cartesian>
+			<x_date   automatic='on'/>
+            <y_regular automatic='on'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>    
+		   <vertical_axis  use_id='vaxis'/> 
+           <text margin_bottom='78%' use_id='title'/>
+           <plot>
+                <epsgram use_id="station" parameter="10m-wind"/>
+				<epsgraph deterministic='on' whisker='on'> <both/> </epsgraph>
+			</plot>
+		  </map>
+          </page>
+          <page height="30%" border='off'>
+        
+	   
+        <nopageid />
+        line_system_plot='on' line_date_plot='off' line_errors_plot='off' 
+                font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'s
+        <map   margin_bottom='30%' margin_top='15%' border-colour='Rgb(0.5, 0.5, 0.5)' >
+          <cartesian>
+			<x_date    automatic='on'/>
+            <y_regular automatic='on'/>
+           </cartesian>  
+           
+           <text margin_bottom='80%' use_id='title'/>
+           <vertical_axis  use_id='vaxis'/>                                       
+          
+            <horizontal_axis 
+                axis_grid='on' 
+                axis_grid_line_style="dot" 
+                axis_grid_colour='kelly_green'
+                axis_date_type = "days"
+                axis_days_label=  "both" 
+                axis_days_label_colour = "navy"
+                axis_months_label_colour= "navy"
+                axis_days_label_height= "0.3"
+                axis_months_label_height= "0.3"
+                axis_years_label_height ="0.3"
+                axis_type= "date"
+                axis_years_label_colour = "navy" />
+                   
+			
+          
+           <plot>
+                <epsgram use_id="station" parameter="2mt"/>
+				<epsgraph > <both/> </epsgraph>
+			</plot> 
+		    <legend display='absolute' bottom='-5%' left='0%' width='50%' height='25%' 
+		        plot_direction='column' columns='3' 
+		        text_colour='Rgb(0.5, 0.5, 0.5)' border='off' blanking='off'/>	
+		  </map>
+	</page>
+</magics>
diff --git a/apps/metgram/10_days_epsgram_a3.xml b/apps/metgram/10_days_epsgram_a3.xml
new file mode 100644
index 0000000..a398279
--- /dev/null
+++ b/apps/metgram/10_days_epsgram_a3.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a3" orientation="portrait">
+	<definition>
+		
+		<epsgram id="station" 
+                station_name='$station' date='' time=''
+                latitude="$latitude" longitude="$longitude" station_height='$height'
+                eps_database='$database/epsdb'> 
+                <none/>
+        </epsgram>
+	
+        <text id="title" font='sansserif' colour='blue' font_size='0.6'
+               justification='left' display='absolute'>	
+		</text>
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='kelly_green'>
+			<nolabel/>
+			<date/>
+			<noline/>
+            <minortick colour='kelly_green'/>
+			<grid line_style="dot" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='kelly_green'>
+			<noline/>
+            <label colour='kelly_green' quality='sansserif' height='0.5'/>
+			<grid line_style="dot" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</vertical_axis>        
+		<map id='box'  margin_bottom='7%' margin_top='15%' border-colour='Rgb(0.5, 0.5, 0.5)'/>
+	</definition>
+	<drivers>
+		<$ps/>
+		<$pdf/>
+		<$png/>
+		<$gif/>
+		<$svg/>
+	</drivers>
+
+	<page height="7.5%" border='off'>
+		<nopageid/>
+	</page>
+
+	<page height="20%" border='off'>
+		<nopageid/> 
+		<map use_id='box'>
+		<cartesian>
+			<x_date   automatic='on'/>
+			<y_regular y_min='0' y_max='8'/>
+		</cartesian>  
+
+	<text margin_bottom='86%' use_id='title'/>
+	<horizontal_axis use_id='haxis'/>    
+	   <vertical_axis  use_id='vaxis'/> 
+	<plot>                
+			<epsgram use_id="station" parameter="cloud-cover" long_title='true'/>
+			<epsgraph deterministic='on' whisker='on'> <both/> </epsgraph>
+		</plot>
+	  </map>
+	</page>
+
+          <page height="20%" border='off'> 
+          <nopageid/> 
+          <map use_id='box'>
+       
+          <cartesian>
+			<x_date  automatic='on'/>
+            <y_regular automatic='on'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>    
+		   <vertical_axis  use_id='vaxis'/>            
+           <text margin_bottom='86%' use_id='title'/>             
+           <plot>
+                <epsgram use_id="station" y_axis_threshold='3'  parameter="precip"/>
+				<epsgraph deterministic='on' whisker='on'> <both/> </epsgraph>
+			</plot>
+		  </map>
+          </page>
+          <page height="20%" border='off'> 
+          <nopageid/>
+           <map  use_id='box'>
+       
+          <cartesian>
+			<x_date   automatic='on'/>
+            <y_regular automatic='on'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>    
+		   <vertical_axis  use_id='vaxis'/> 
+           <text margin_bottom='86%' use_id='title'/>
+           <plot>
+                <epsgram use_id="station" parameter="10m-wind"/>
+				<epsgraph deterministic='on' whisker='on'> <both/> </epsgraph>
+			</plot>
+		  </map>
+          </page>
+          <page height="30%" border='off'>
+        
+	   
+        <pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+                font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+        <map   margin_bottom='30%' margin_top='15%' border-colour='Rgb(0.5, 0.5, 0.5)' >
+          <cartesian>
+			<x_date    automatic='on'/>
+            <y_regular automatic='on'/>
+           </cartesian>  
+           
+           <text margin_bottom='85%' use_id='title'/>
+           <vertical_axis  use_id='vaxis'/>                                       
+          
+            <horizontal_axis use_id="haxis">
+                   <date>
+                    <both label_colour='blue' label_height='0.5' />
+                     <month label_height='0.5' label_colour='blue'> <monthandyear /> </month>
+                     <noyear height='0.5'/>
+                    </date>
+                    <label quality='sansserif'/>
+			</horizontal_axis>    
+          
+           <plot>
+                <epsgram use_id="station" parameter="2mt"/>
+				<epsgraph > <both/> </epsgraph>
+			</plot> 
+		<legend display='absolute' bottom='2%' left='0%' width='40%' height='18%' 
+		        plot_direction='column' columns='3' 
+		        text_colour='Rgb(0.5, 0.5, 0.5)' border='off' blanking='off'/>	
+		  </map>
+	</page>
+</magics>
diff --git a/apps/metgram/10_days_metgram.xml b/apps/metgram/10_days_metgram.xml
new file mode 100644
index 0000000..8f7d464
--- /dev/null
+++ b/apps/metgram/10_days_metgram.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a4" orientation="portrait">
+	<definition>
+		<metgram id="station" 
+                station_name='$station' station_height="$height" 
+                latitude="$latitude" longitude="$longitude" 
+                date='$date' time="$time" 
+                eps_temperature_correction='yes'
+                database='$database/detdb'> $title 
+                <none/>
+        </metgram>
+	
+       <text id='title' margin_bottom='75%'
+                    font='sansserif' colour='blue' font_size='0.4'
+                    justification='left' display='absolute'/>
+       <text id='title_tempe' margin_bottom='78%'
+                    font='sansserif' colour='blue' font_size='0.4'
+                    justification='left' display='absolute'/>
+        <text id='title_wind' margin_bottom='60%'
+                    font='sansserif' colour='blue' font_size='0.4'
+                    justification='left' display='absolute'/>
+
+		<map id="box"  margin_bottom='7%' margin_top='15%' border-colour='kelly_green'/>			
+		<map id="box_wind"  margin_bottom='7%' margin_top='21%' border-colour='kelly_green'/>			
+
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='kelly_green'>			
+			<nolabel/>
+			<date/>
+			<noline/>
+            <minortick colour='kelly_green'/>
+			<grid line_style="dot" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='kelly_green'>		
+			<noline/>
+            <label colour='kelly_green'/>
+			<grid line_style="dot" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</vertical_axis>
+	</definition>
+	<drivers>
+		<$ps/>
+		<$pdf/>
+		<$png/>
+		<$gif/>
+		<$svg/>
+	</drivers>
+   
+	<page height='8%' border='off'>
+		<$meta/>
+		<nopageid/>
+	</page>
+	<page height='15%' border='off'>  
+		<nopageid/>
+		<map use_id='box'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="0" y_max="100"/>
+			</cartesian> 
+			<text use_id='title'/>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"> <regular/>	</vertical_axis>
+			<plot>
+				<metgram use_id="station" parameter="cloud_cover" long_title='true'/>
+				<metgraph> <bar/> </metgraph>
+			</plot>
+		</map>
+	</page>
+	<page  height='15%' border='off'>
+		<nopageid/>
+		<map use_id='box'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="0" y_max="100"/>
+			</cartesian> 
+			<text use_id='title'/>
+			<horizontal_axis use_id="haxis"/>                
+			<vertical_axis use_id="vaxis"> </vertical_axis>
+			<plot>
+				<metgram use_id="station" parameter="humidity"/>
+				<metgraph> </metgraph>
+			</plot>
+		</map>
+	</page>
+
+	<page  height='15%' border='off'>
+		<nopageid/>
+		<map use_id='box'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular automatic='on'/>
+			</cartesian> 
+			<text use_id='title'/>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"/>
+			<plot>
+				<metgram use_id="station" parameter="precipitation"/>
+				<metgraph> <bar/> </metgraph>
+			</plot>
+		</map>
+	</page>
+
+	<page  height='15%' border='off'>
+		<nopageid/>
+		<map use_id='box' >
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular automatic='on'/>
+			</cartesian>
+			<text use_id='title'/>
+			<horizontal_axis use_id="haxis"/>				
+			<vertical_axis use_id="vaxis"/>
+			<plot>
+				<metgram use_id="station" parameter="msl"/>
+				<metgraph> </metgraph>
+			</plot>
+		</map>
+	</page>
+
+	<page height="8%" border='off'>
+		<nopageid/>
+		<map use_id='box_wind'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular y_min='-1' y_max='1'/>
+			</cartesian>
+			<text use_id='title_wind'/>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"> <nolabel/> <notick/> <nogrid/> </vertical_axis>
+			<plot>
+				<metgram use_id="station" parameter="10m_wind"/>
+				<metgraph> <flags/> </metgraph>
+			</plot>
+		</map> 
+	</page>
+
+        <page height="21%" border='off'>
+			<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+			<map  margin_bottom='25%' margin_top='15%' border-colour='kelly_green' >
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  automatic='on'/>
+			</cartesian>
+			<horizontal_axis use_id="haxis">
+				<date >
+				<both label_colour='blue' label_height='0.35' />
+				<month label_height='0.35' label_colour='blue'> <monthandyear /> </month>
+				<noyear height='0.4'/>
+				</date>
+				<label/>
+			</horizontal_axis>
+			<text use_id='title_tempe'/>
+			<vertical_axis use_id="vaxis"/>
+			<plot>
+				<metgram use_id="station" parameter="temperature"/>
+				<metgraph> </metgraph>
+			</plot>
+		</map>
+	</page>
+</magics>
diff --git a/apps/metgram/10_days_wave_epsgram.xml b/apps/metgram/10_days_wave_epsgram.xml
new file mode 100644
index 0000000..452ca21
--- /dev/null
+++ b/apps/metgram/10_days_wave_epsgram.xml
@@ -0,0 +1,213 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a4" orientation="portrait">
+	<definition>
+		<epsgram id="eps_wave" 
+                station_name='$station' 
+                latitude="$latitude" longitude="$longitude" 
+                time='' date=''
+                eps_temperature_correction='yes'
+                eps_database='$database/eps/db'> 
+                <none/>
+        </epsgram>
+        <epsgram id="eps_wave_det" 
+                station_name='$station' 
+                latitude="$latitude" longitude="$longitude" 
+                time='' date=''
+                eps_temperature_correction='yes'
+                eps_database='$database/det/db'> 
+                <none/>
+        </epsgram>
+
+
+        <epsgram id="eps_wind"               
+                station_name='$station' 
+                latitude="$latitude" longitude="$longitude" 
+                time='' date=''
+                eps_temperature_correction='yes'
+                eps_database='$database/epsdb'> 
+                <none/>
+        </epsgram>
+ 	
+        <text  id="title" justification="left" font_style='bold'  font_size='0.4' 
+            colour='navy' font='sansserif' border='off' />
+        	
+		<map id="box" border='on' 
+            border_colour='navy' border_thickness='2'/>
+
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='navy'>
+			<automatic/>
+			<nolabel/>
+			<date/>
+			<noline/>
+            <nominortick colour='kelly_green'/>			
+			<grid line_style="dash" colour='kelly_green'/>
+            <tick colour='kelly_green'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='navy'>
+			<automatic/>
+			<noline/>
+            <label colour='navy' quality='sansserif'/>
+ 			<grid line_style="dash" colour='kelly_green'/>
+            <tick colour='kelly_green'/>      
+		</vertical_axis>
+	</definition>
+    <drivers>
+        <$ps/>
+        <$pdf/>
+        <$png/>
+	<$gif/>
+	<$svg/>
+    </drivers>
+   
+    <page height="7%" border='off'><nopageid/> </page>
+    <page height="10%" border='off'>
+    <$meta/>     
+     <nopageid/>
+        <text margin_left='10%' margin_bottom='0' height='35%'  width='40%' use_id='title'/>
+        <legend  display='absolute' height='30%' width='30%' bottom='60%'
+                   plot_direction='column' left='50%' 
+                   text_colour='navy' border='off' blanking='off'/>
+         <map height='65%' border='on' margin_top='1%'
+            border_colour='navy' border_thickness='2'>
+        
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="-43200" y_max="43200" />
+			</cartesian> 
+			
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"><nolabel/><notick/><nogrid/></vertical_axis> 
+			<plot>
+				<epsgram use_id="eps_wind" type='epsrose' parameter="249.140" 
+                    long_title='true' title_text='Wave Epsgram' long_title_height='off'
+                    parameter_title='Distribution of 10m Wind Direction'/>
+				<epswind rose_wind_colour='greenish_blue'/>
+              
+			</plot> 
+            
+            </map>
+       
+
+        </page>
+     <page height="20%" border='on'>
+         <nopageid/>
+         <text display='absolute' bottom='74%' height='10%' width='90%' use_id='title'/>
+         <map use_id='box' display='absolute' bottom='0%' height='90%'>
+           <cartesian>
+			<x_date  automatic='on' />
+            <y_regular automatic='on' y_min='0' y_max='20' />
+           </cartesian>  
+                     
+                <plot>
+					<epsgram  use_id="eps_wind" type='epswave' parameter="165.128"  
+                        parameter_title='10m Wind Speed (m/s)'/>
+                    <epsgraph box_width='1.5' box_colour='greenish_blue' box_border_colour='navy'> <both/> </epsgraph>
+				</plot>
+          <horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			
+		</map>
+    </page>
+   
+    
+    <page height="20%" border='on'>
+        <nopageid/>
+         <text display='absolute' bottom='74%' height='10%' width='90%' use_id='title'/>
+         <map use_id='box' display='absolute' bottom='0%' height='90%'>
+           <cartesian>
+			<x_date  automatic='on' />
+            <y_regular automatic='on' y_min='0' y_max='20' />
+           </cartesian>            
+                <plot>
+					<epsgram use_id="eps_wave" type='epswave' parameter="229.140" parameter_title='ignore'/>
+                    <epsgraph box_width='1.5' box_colour='greenish_blue' box_border_colour='navy'> <both/> </epsgraph>
+				</plot>
+                <plot>
+					<epsgram use_id="eps_wave_det" type='epswave' parameter="229.140" parameter_title='Significant wave height (m)'/>
+                    <epsgraph box_width='1.5' box_colour='greenish_blue' box_border_colour='navy'> <both/> </epsgraph>
+				</plot>
+          <horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			
+		</map>
+    </page> 
+     <page height="10%" border='off'>
+         <nopageid/>
+         <text display='absolute' bottom='52%' height='10%' width='90%' use_id='title'/>
+        <legend  display='absolute' height='30%' width='30%' bottom='60%'
+                   plot_direction='column' left='45%' 
+                   text_colour='navy' border='off' blanking='off'/>
+         <map display='absolute' bottom='0%' height='70%' border='on'
+            border_colour='navy' border_thickness='2'>
+        
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="-43200" y_max="43200" />
+			</cartesian> 
+			
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"><nolabel/><notick/><nogrid/></vertical_axis> 
+			<plot>
+				<epsgram use_id="eps_wave" type='epsrose' parameter="230.140" parameter_title='Mean wave direction ( oceanographic convention )'/>
+				<epswave rose_wind_colour='Rgb(0.925, 0.609, 0.953)' rose_wind_convention='oceanographic'/>
+			</plot>
+             <plot>
+				<epsgram use_id="eps_wave_det" type='epsrose' parameter="230.140" parameter_title='ignore'/>
+				<epsdirection keyword='forecast' line_colour='blue' line_thickness='3' />
+			</plot>
+            <plot>
+				<epsgram use_id="eps_wave" type='epsrose' parameter="230.140" parameter_title='ignore'/>
+				<epsdirection keyword='control' line_colour='red' line_thickness='3' line_style='dash'/>
+			</plot>
+		
+         
+          </map>
+        </page>   
+    <page height="28%" border='off'>
+     <pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+                font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+         <text display='absolute' bottom='85%' height='10%' width='90%' use_id='title'/>
+         <map display='absolute' bottom='30%' height='60%' legend='40%' border='on' border_colour='navy' border_thickness='2' margin_top='1%'>
+          
+           <cartesian>
+			<x_date  automatic='on' />
+            <y_regular automatic='on'/>
+           </cartesian>  
+         
+                 <plot>
+					<epsgram use_id="eps_wave" type='epswave' parameter="232.140" parameter_title='ignore'/>
+                    <epsgraph box_width='1.5' box_colour='greenish_blue' box_border_colour='navy' 
+                    font='sansserif' font_colour='navy' legend_resolution='degrees'> <both/> </epsgraph>
+				</plot>
+                <plot>
+					<epsgram use_id="eps_wave_det" type='epswave' parameter="232.140" parameter_title='Mean wave period (s)'/>
+                    <epsgraph box_width='1.5' box_colour='greenish_blue' box_border_colour='navy' 
+                    font='sansserif' font_colour='navy' legend_resolution='degrees' > <both/> </epsgraph>
+				</plot>
+                 <horizontal_axis 
+                axis_grid='on' 
+                axis_grid_line_style="dot" 
+                axis_grid_colour='kelly_green'
+                axis_date_type = "days"
+                axis_days_label=  "both" 
+                axis_days_label_colour = "navy"
+                axis_months_label_colour= "navy"
+                axis_days_label_height= "0.3"
+                axis_months_label_height= "0.3"
+                axis_years_label_height ="0.3"
+                axis_type= "date"
+                axis_years_label_colour = "navy" />
+                   
+            <vertical_axis use_id="vaxis"/>			          
+   		 		
+		</map>
+        <legend display='absolute' width='47%' height='25%' bottom='-5%'
+                   plot_direction='column' columns='6'
+                   text_colour='Rgb(0.5, 0.5, 0.5)' border='off' blanking='off'/>	
+    </page> 
+        
+
+		
+	
+</magics>
diff --git a/apps/metgram/15_days_epsgram.xml b/apps/metgram/15_days_epsgram.xml
new file mode 100644
index 0000000..641f197
--- /dev/null
+++ b/apps/metgram/15_days_epsgram.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a4" orientation="portrait">
+	<definition>
+		<epsgram id="eps" 
+			type='eps15'
+			station_name='$station' 
+			latitude="$latitude" longitude="$longitude" 
+			date='$date' time="$time" station_height="$height" 
+			eps_temperature_correction='yes'
+			eps_database='$database/epsdb'> 
+			<none/>
+	</epsgram>
+	
+	<text id="title" justification="left" font_style='bold'  font_size='0.4' 
+	      colour='Rgb(0.5, 0.5, 0.5)' font='sansserif' />
+
+		<map id="box" margin_bottom='7%' margin_top='15%' 
+		     border-colour='grey' border-thickness='2'/>
+
+		<horizontal_axis id="haxis" 
+			axis_tick_label='off'
+			axis_grid='on' 
+			axis_grid_line_style='dash' 
+			axis_grid_colour='Rgb(0.5, 0.5, 0.5)' 
+			axis_line="false" line_thickness="4" colour='Rgb(0.5, 0.5, 0.5)'>
+			<automatic/>
+			<nolabel/>
+			<date/>
+			<noline/>
+			<nominortick colour='Rgb(0.5, 0.5, 0.5)'/>			
+			<grid line_style="solid" colour='Rgb(0.5, 0.5, 0.5)'/>
+			<tick colour='Rgb(0.5, 0.5, 0.5)'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_grid='on' 
+			axis_grid_line_style='dash' 
+			axis_grid_colour='Rgb(0.5, 0.5, 0.5)' 
+			axis_line="false" line_thickness="4" colour='Rgb(0.5, 0.5, 0.5)'>
+			<automatic/>
+			<noline/>
+			<label colour='Rgb(0.5, 0.5, 0.5)' quality='sansserif'/>
+ 			<grid line_style="dash" colour='Rgb(0.5, 0.5, 0.5)'/>
+			<tick colour='grey'/>      
+		</vertical_axis>
+
+	</definition>
+		<drivers>
+			<$ps/>
+			<$pdf/>
+			<$png/>
+			<$gif/>
+			<$svg/>
+		</drivers>
+
+	<page  height="7.5%" border='off'>
+		<nopageid/>       
+	</page>
+
+	<page  height="19%" border='off'>
+		<nopageid/>
+			<$meta/>
+			<map use_id='box'>
+				<text use_id='title' margin_bottom='80%' />
+				<cartesian>
+					<x_date  automatic='on' />
+					<y_regular automatic='on' />
+				</cartesian>  
+				<plot>
+					<epsgram use_id="eps" parameter="cloud-cover" long_title='true'/>                    
+					<epsgraph box_colour='Rgb(0.925, 0.609, 0.953)' box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+				</plot>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			</map>
+	</page>
+	<page height="19%" border='off'>
+		<nopageid/>
+		<map  use_id='box' >
+          <text margin_bottom='80%' use_id='title'/>
+           <cartesian>
+			<x_date  automatic='on' />
+            <y_regular automatic='on' y_min='0' y_max='20' />
+           </cartesian>  
+          
+			
+                <plot>
+					<epsgram use_id="eps" parameter="precip"/>
+					<epsgraph max='20' box_colour='Rgb(0.49, 0.89, 0.51)' box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+
+				</plot>
+           <horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			
+		</map> 
+	</page>
+	<page height="6%" border='off'>
+		<nopageid/>
+		<map margin_bottom='7%' margin_top='25%' 
+		     border-colour='grey' border-thickness='2'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="-43200" y_max="43200" />
+			</cartesian> 
+			<text bottom='55%' use_id='title'/>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis" axis_tick_label='off' axis_tick='off' axis_grid='off'></vertical_axis> 
+			<plot>
+				<epsgram use_id="eps" parameter="10m-wind-dd"/>
+				<epswind rose_wind_colour='gold' rose_wind_border_colour='Rgb(0.5000, 0.5000, 0.5000)'/>
+			</plot>
+        <legend display='absolute' bottom='50%' left='1.25' width='20%' height='90%' 
+	        text_colour='Rgb(0.5, 0.5, 0.5)' border='off' blanking='off'/>
+        </map>  
+        </page>
+	<page height="19%" border='off'>
+		<nopageid/>
+		<map use_id='box'>
+			<text margin_bottom='78%' use_id='title'/>
+			<cartesian>
+				<x_date  automatic='on' />
+				<y_regular automatic='on' y_min='0' y_max='20' />
+			</cartesian>  
+			<plot>
+				<epsgram use_id="eps" parameter="10m-wind"/>
+				<epsgraph box_colour='gold' box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+			</plot>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"/>
+		</map>
+	</page>
+	<page height="28%" border='off'>
+		<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+		        font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+		<map margin_bottom='37%' margin_top='10%' border-colour='Rgb(0.5, 0.5, 0.5)' >
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular automatic='on'/>
+			</cartesian>
+			<horizontal_axis use_id="haxis">
+				<date>
+				<both label_colour='Rgb(0.5, 0.5, 0.5)' label_height='0.3' />
+				<month label_height='0.4' label_colour='Rgb(0.5, 0.5, 0.5)'> <monthandyear /> </month>
+				<noyear height='0.4'/>
+				</date>
+				<label quality='sansserif'/>
+			</horizontal_axis>			
+			<vertical_axis  use_id="vaxis"/> 
+			<text margin_bottom='85%' use_id='title' display='absolute'/>		
+			<plot>
+				<epsgram use_id="eps" parameter="temperature"/>
+				<epsgraph border_colour='Rgb(0.5, 0.5, 0.5)' 
+				left_box_colour='sky' box_median_colour='black' right_box_colour='RGB(1.0, 0.222, 0.222)'
+				font='sansserif' font_colour='Rgb(0.5, 0.5, 0.5)' box_colour='grey'
+				box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+			</plot>
+		</map>
+		<legend display='absolute' bottom='10%' left='20%' width='20%' height='25%' 
+		        plot_direction='column' text_colour='Rgb(0.5, 0.5, 0.5)' border='on' blanking='off'/>
+        
+	</page>
+</magics>
diff --git a/apps/metgram/15_days_epsgram_a3.xml b/apps/metgram/15_days_epsgram_a3.xml
new file mode 100644
index 0000000..d9fd0f9
--- /dev/null
+++ b/apps/metgram/15_days_epsgram_a3.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a3" orientation="portrait">
+	<definition>
+		<epsgram id="eps" 
+			type='eps15'
+			station_name='$station' 
+			latitude="$latitude" longitude="$longitude" 
+			date='$date' time="$time" station_height="$height" 
+			eps_temperature_correction='yes'
+			eps_database='$database/epsdb'> 
+			<none/>
+	</epsgram>
+	
+	<text id="title" justification="left" font_style='bold'  font_size='0.6' 
+	      colour='Rgb(0.5, 0.5, 0.5)' font='sansserif' />
+
+		<map id="box" margin_bottom='7%' margin_top='15%' 
+		     border-colour='grey' border-thickness='2'/>
+
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='Rgb(0.5, 0.5, 0.5)'>
+			<automatic/>
+			<nolabel/>
+			<date/>
+			<noline/>
+			<nominortick colour='Rgb(0.5, 0.5, 0.5)'/>			
+			<grid line_style="solid" colour='Rgb(0.5, 0.5, 0.5)'/>
+			<tick colour='Rgb(0.5, 0.5, 0.5)'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='Rgb(0.5, 0.5, 0.5)'>
+			<automatic/>
+			<noline/>
+			<label colour='Rgb(0.5, 0.5, 0.5)' quality='sansserif' height='0.5'/>
+ 			<grid line_style="dash" colour='Rgb(0.5, 0.5, 0.5)'/>
+			<tick colour='grey'/>      
+		</vertical_axis>
+
+	</definition>
+		<drivers>
+			<$ps/>
+			<$pdf/>
+			<$png/>
+			<$gif/>
+			<$svg/>
+		</drivers>
+
+	<page  height="7.5%" border='off'>
+		<nopageid/>       
+	</page>
+
+	<page  height="19%" border='off'>
+		<nopageid/>
+			<$meta/>
+			<map use_id='box'>
+				<text use_id='title' margin_bottom='87%' />
+				<cartesian>
+					<x_date  automatic='on' />
+					<y_regular automatic='on' />
+				</cartesian>  
+				<plot>
+					<epsgram use_id="eps" parameter="cloud-cover" long_title='true'/>                    
+					<epsgraph box_colour='Rgb(0.925, 0.609, 0.953)' box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+				</plot>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			</map>
+	</page>
+	<page height="19%" border='off'>
+		<nopageid/>
+		<map  use_id='box' >
+          <text margin_bottom='87%' use_id='title'/>
+           <cartesian>
+			<x_date  automatic='on' />
+            <y_regular automatic='on' y_min='0' y_max='20' />
+           </cartesian>  
+          
+			
+                <plot>
+					<epsgram use_id="eps" parameter="precip"/>
+					<epsgraph max='20' box_colour='Rgb(0.49, 0.89, 0.51)' box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+
+				</plot>
+           <horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			
+		</map> 
+	</page>
+	<page height="6%" border='off'>
+		<nopageid/>
+		<map margin_bottom='7%' margin_top='25%' 
+		     border-colour='grey' border-thickness='2'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="-43200" y_max="43200" />
+			</cartesian> 
+			<text bottom='85%' use_id='title'/>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"><nolabel/><notick/><nogrid/></vertical_axis> 
+			<plot>
+				<epsgram use_id="eps" parameter="10m-wind-dd"/>
+				<epswind rose_wind_colour='gold' rose_wind_border_colour='Rgb(0.5000, 0.5000, 0.5000)'/>
+			</plot>
+        <legend display='absolute' bottom='80%' left='60%' width='20%' height='90%' 
+	        text_colour='Rgb(0.5, 0.5, 0.5)' border='off' blanking='off'/>
+        </map>  
+        </page>
+	<page height="19%" border='off'>
+		<nopageid/>
+		<map use_id='box'>
+			<text margin_bottom='87%' use_id='title'/>
+			<cartesian>
+				<x_date  automatic='on' />
+				<y_regular automatic='on' y_min='0' y_max='20' />
+			</cartesian>  
+			<plot>
+				<epsgram use_id="eps" parameter="10m-wind"/>
+				<epsgraph box_colour='gold' box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+			</plot>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"/>
+		</map>
+	</page>
+	<page height="28%" border='off'>
+		<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+		        font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+		<map margin_bottom='37%' margin_top='10%' border-colour='Rgb(0.5, 0.5, 0.5)' >
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular automatic='on'/>
+			</cartesian>
+			<horizontal_axis use_id="haxis">
+				<date>
+				<both label_colour='Rgb(0.5, 0.5, 0.5)' label_height='0.5' />
+				<month label_height='0.5' label_colour='Rgb(0.5, 0.5, 0.5)'> <monthandyear /> </month>
+				<noyear height='0.4'/>
+				</date>
+				<label quality='sansserif'/>
+			</horizontal_axis>			
+			<vertical_axis  use_id="vaxis"/> 
+			<text margin_bottom='92%' use_id='title' display='absolute'/>		
+			<plot>
+				<epsgram use_id="eps" parameter="temperature"/>
+				<epsgraph border_colour='Rgb(0.5, 0.5, 0.5)' 
+				left_box_colour='sky' box_median_colour='black' right_box_colour='RGB(1.0, 0.222, 0.222)'
+				font='sansserif' font_colour='Rgb(0.5, 0.5, 0.5)' box_colour='grey'
+				box_border_colour='Rgb(0.5, 0.5, 0.5)'> <both/> </epsgraph>
+			</plot>
+		<legend display='absolute' bottom='2%' left='2%' width='12%' height='23%' 
+		        plot_direction='column' text_colour='Rgb(0.5, 0.5, 0.5)' border='off' blanking='off'/>
+		</map>
+        
+	</page>
+</magics>
diff --git a/apps/metgram/15_days_with_clim_epsgram.xml b/apps/metgram/15_days_with_clim_epsgram.xml
new file mode 100644
index 0000000..2123a73
--- /dev/null
+++ b/apps/metgram/15_days_with_clim_epsgram.xml
@@ -0,0 +1,223 @@
+<?xml version="1.0"?>
+<magics version="3.0" format="a4" orientation="portrait">
+	<definition>
+		<epsgram id="eps" 
+			type='eps15'
+			station_name='$station' 
+			latitude="$latitude" longitude="$longitude" 
+			date='$date' time="$time" station_height="$height"
+			eps_temperature_correction='yes'
+			eps_database='$database_eps/epsdb'> 
+			<none/>
+	</epsgram>
+	
+	  <epsgram id="clim"
+               type='eps15'
+               station='$station'
+               latitude="$latitude" longitude="$longitude"
+               date='' time="" station_height="48"
+               eps_temperature_correction='yes'
+               eps_database='$database_clim/epsdb'>
+               <none/>
+     </epsgram>
+
+	<text id="title" justification="left" font_style='bold' left='0%' font_size='0.4' 
+	      colour='Rgb(0.5, 0.5, 0.5)' font='sansserif' />
+
+		<map id="box" border='on' 
+		     border-colour='grey' border-thickness='2'/>
+
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='Rgb(0.2, 0.2, 0.2)'>
+			<automatic/>
+			<nolabel/>
+			<date/>
+			<noline/>
+			<nominortick colour='Rgb(0.2, 0.2, 0.2)'/>			
+			<grid line_style="solid" colour='Rgb(0.2, 0.2, 0.2)'/>
+			<tick colour='Rgb(0.2, 0.2, 0.2)'/>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='Rgb(0.2, 0.2, 0.2)'>
+			<automatic/>
+			<noline/>
+			<label colour='Rgb(0.2, 0.2, 0.2)' quality='sansserif'/>
+ 			<grid line_style="dash" colour='Rgb(0.2, 0.2, 0.2)'/>
+			<tick colour='grey'/>      
+		</vertical_axis>
+
+	</definition>
+		<drivers>
+		    <$ps/>
+		    <$pdf/>
+		    <$png/>
+		    <$gif/>
+		    <$svg/>
+		</drivers>
+
+	<page  height="9%" border='off'>
+		<nopageid/>       
+	</page>
+
+	<page  height="15%" border='on'>
+		<nopageid/>
+			<text use_id='title' height='10%' />
+			<map use_id='box' height='80%'>
+				<cartesian>
+					<x_date  automatic='on' />
+					<y_regular automatic='on' />
+				</cartesian>  
+				<plot>
+				    <epsgram use_id="clim" parameter="clim-eps-cloud-cover" long_title='false'/>
+					<epsshade eps_shade_colour='Rgb(0.925, 0.609, 0.953)' eps_shade_line_thickness='4' />
+                </plot>
+
+				<plot>
+					<epsgram use_id="eps" parameter="cloud-cover" long_title='true'/>                    
+					<epsgraph box_colour='Rgb(0.925, 0.609, 0.953)' box_border_colour='Rgb(0.2, 0.2, 0.2)'> <both/> </epsgraph>
+				</plot>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			</map>
+	</page>
+	<page height="15%" border='off'>
+		<nopageid/>
+        <text height='10%' use_id='title'/>
+		<map  height='80%' use_id='box' >
+           <cartesian>
+			<x_date  automatic='on' />
+            <y_regular automatic='on' y_min='0' y_max='20' />
+           </cartesian>  
+          
+		  <plot>
+		      <epsgram use_id="clim" parameter="clim-eps-precip" />
+		      <epsshade eps_shade_colour='Rgb(0.49, 0.89, 0.51)' eps_shade_line_thickness='4' />
+          </plot>
+
+			
+                <plot>
+					<epsgram use_id="eps" parameter="precip"/>
+					<epsgraph max='20' box_colour='Rgb(0.49, 0.89, 0.51)' box_border_colour='Rgb(0.2, 0.2, 0.2)'> <both/> </epsgraph>
+
+				</plot>
+           <horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+			
+		</map> 
+	</page>
+	<page height="6%" border='off'>
+		<nopageid/>
+        <text  margin_left='9%' height='30%' width='60%' use_id='title'/>
+		<map height='70%' border='on' 
+		     border-colour='grey' border-thickness='2'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="-43200" y_max="43200" />
+			</cartesian> 
+			
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"><nolabel/><notick/><nogrid/></vertical_axis> 
+			<plot>
+				<epsgram use_id="clim" parameter="249.140" 
+				parameter_title='M-Climate of the distribution of 10m Wind Direction'/> 
+				<epswind rose_wind_colour='gold' rose_wind_border_colour='Rgb(0.5000, 0.5000, 0.5000)'/>
+			</plot>
+        </map>  
+        <legend display='absolute' bottom='65%' left='60%' width='30%' height='40%' 
+	        text_colour='Rgb(0.2, 0.2, 0.2)' border='off' blanking='off'/>
+        </page>
+	<page height="2%" border='off'>
+		<nopageid/>
+    </page>
+	<page height="6%" border='off'>
+		<nopageid/> 
+        <text margin_left='9%'  height='30%' width='60%' use_id='title'/>
+		<map height='70%' border='on' 
+		     border-colour='grey' border-thickness='2'>
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular  y_min="-43200" y_max="43200" />
+			</cartesian> 
+			
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"><nolabel/><notick/><nogrid/></vertical_axis> 
+			<plot>
+				<epsgram use_id="eps" parameter="10m-wind-dd"/>
+				<epswind rose_wind_colour='gold' rose_wind_border_colour='Rgb(0.5000, 0.5000, 0.5000)'/>
+			</plot>
+        </map>  
+        <legend display='absolute' bottom='65%' left='60%' width='30%' height='50%' 
+	        text_colour='Rgb(0.2, 0.2, 0.2)' border='off' blanking='off'/>
+        </page>
+	<page height="15%" border='off'>
+		<nopageid/>
+        <text height='20%' use_id='title'/>
+		<map use_id='box' height='80%' margin_top='5%'>
+			
+			<cartesian>
+				<x_date  automatic='on' />
+				<y_regular automatic='on' y_min='0' y_max='20' />
+			</cartesian>  
+			 <plot>
+			     <epsgram use_id="clim" parameter="clim-10m-wind" />
+				 <epsshade eps_shade_colour='gold' eps_shade_line_thickness='4' />
+	        </plot>
+
+			<plot>
+				<epsgram use_id="eps" parameter="10m-wind"/>
+				<epsgraph box_colour='gold' box_border_colour='Rgb(0.2, 0.2, 0.2)'> <both/> </epsgraph>
+			</plot>
+			<horizontal_axis use_id="haxis"/>
+			<vertical_axis use_id="vaxis"/>
+		</map>
+	</page>
+	<page height="30%" border='off'>
+		<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+		        font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+                <text height='8%' use_id='title' />	
+		<map height='40%' border='on' border-colour='Rgb(0.2, 0.2, 0.2)' margin_top='5%' >
+			<cartesian>
+				<x_date automatic='on'/>
+				<y_regular automatic='on'/>
+			</cartesian>
+			
+				
+			  <plot>
+			      <epsgram use_id="clim" parameter="clim-temperature" parameter_title=''/>
+			     <epsshade eps_shade_colour='sky' eps_shade_line_thickness='3' />
+		     </plot>
+		     <!--plot>
+		         <epsgram use_id="clim" parameter="clim-eps-2mt-max" />
+		         <epsshade eps_shade_colour='RGB(1.0, 0.222, 0.222)'
+		                   eps_shade_line_thickness='4' />
+	        </plot-->
+
+			<plot>
+				<epsgram use_id="eps" parameter="temperature"/>
+				<epsgraph border_colour='Rgb(0.2, 0.2, 0.2)' 
+				left_box_colour='sky' box_median_colour='black' right_box_colour='RGB(1.0, 0.222, 0.222)'
+				font='sansserif' font_colour='Rgb(0.2, 0.2, 0.2)' box_colour='grey'
+				box_border_colour='Rgb(0.2, 0.2, 0.2)'> <both/> </epsgraph>
+			</plot>
+            <horizontal_axis use_id="haxis">
+				<date>
+				<both label_colour='Rgb(0.2, 0.2, 0.2)' label_height='0.3' />
+				<month label_height='0.4' label_colour='Rgb(0.2, 0.2, 0.2)'> <monthandyear /> </month>
+				<noyear height='0.4'/>
+				</date>
+				<label quality='sansserif'/>
+			</horizontal_axis>			
+			<vertical_axis  use_id="vaxis"/> 
+		</map>
+        <text display='absolute' bottom='8%' left='45%' width='40%' height='20%' font_size='0.4' 
+		        text_colour='Rgb(0.2, 0.2, 0.2)' justification='left' border='off' blanking='off'> 
+            <br/><b>M-Climate</b>: this stands for "Model Climate". It is a 
+            <br/>function of lead time, date (+/-15days), and model
+            <br/>version. It is derived by rerunning a 5 member
+            <br/>ensemble over the last 20 years. once per week (500 
+            <br/>realisations). M-Climate is always from the same
+            <br/>model version as the displayed EPS data.
+        </text>
+		<legend display='absolute' bottom='20%' left='14%' width='25%' height='25%' 
+		        plot_direction='column' text_colour='Rgb(0.2, 0.2, 0.2)' border='off' blanking='off'/>
+	</page>
+</magics>
diff --git a/apps/metgram/Makefile.am b/apps/metgram/Makefile.am
new file mode 100644
index 0000000..48a98c1
--- /dev/null
+++ b/apps/metgram/Makefile.am
@@ -0,0 +1,43 @@
+AUTOMAKE_OPTIONS = foreign
+
+if MAGICS_BUFR
+FORTRAN_LIBS	= $(FLIBS)
+endif
+
+magplus 	= -L$(top_builddir)/src -lMagPlus $(ODA_LIBS) 
+LDADD		=  $(magplus) ${MAGICS_3RDPARTY_LIBS} $(FORTRAN_LIBS)
+
+AM_CPPFLAGS	= -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/common -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders
+
+if MAGICS_QT
+AM_CPPFLAGS += -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+AM_LDFLAGS   = $(QT_LIBS)
+endif
+
+if MAGICS_METGRAM
+bin_SCRIPTS	= metgram
+endif
+
+if MAGICS_SPOT
+bin_PROGRAMS	= metgramx
+metgramx_SOURCES = metgramx.cc
+
+templatedir = $(datadir)/templates
+template_DATA = 10_days_epsgram.xml 10_days_epsgram_a3.xml \
+                15_days_epsgram.xml 15_days_epsgram_a3.xml \
+                10_days_metgram.xml 10_days_wave_epsgram.xml \
+                15_days_with_clim_epsgram.xml \
+                efi_distribution.xml new_efi_distribution.xml \
+                classic_plumes.json
+endif
+
+EXTRA_DIST	= metgram epsgram.template metgram.template \
+		eps15.xml eps10.xml \
+		eps10_a3.xml eps15_a3.xml epswave.xml\
+		10_days_epsgram.xml 10_days_epsgram_a3.xml \
+		15_days_epsgram.xml 15_days_epsgram_a3.xml \
+		10_days_metgram.xml 10_days_wave_epsgram.xml \
+		15_days_with_clim_epsgram.xml \
+		efi_distribution.xml new_efi_distribution.xml \
+		classic_plumes.json
+
diff --git a/apps/metgram/Makefile.in b/apps/metgram/Makefile.in
new file mode 100644
index 0000000..b193d31
--- /dev/null
+++ b/apps/metgram/Makefile.in
@@ -0,0 +1,722 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_QT_TRUE@am__append_1 = -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+ at MAGICS_SPOT_TRUE@bin_PROGRAMS = metgramx$(EXEEXT)
+subdir = apps/metgram
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" \
+	"$(DESTDIR)$(templatedir)"
+PROGRAMS = $(bin_PROGRAMS)
+am__metgramx_SOURCES_DIST = metgramx.cc
+ at MAGICS_SPOT_TRUE@am_metgramx_OBJECTS = metgramx.$(OBJEXT)
+metgramx_OBJECTS = $(am_metgramx_OBJECTS)
+metgramx_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+ at MAGICS_BUFR_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
+metgramx_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+SCRIPTS = $(bin_SCRIPTS)
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(metgramx_SOURCES)
+DIST_SOURCES = $(am__metgramx_SOURCES_DIST)
+DATA = $(template_DATA)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+ at MAGICS_BUFR_TRUE@FORTRAN_LIBS = $(FLIBS)
+magplus = -L$(top_builddir)/src -lMagPlus $(ODA_LIBS) 
+LDADD = $(magplus) ${MAGICS_3RDPARTY_LIBS} $(FORTRAN_LIBS)
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel \
+	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/basic \
+	-I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers \
+	-I$(top_srcdir)/src/decoders $(am__append_1)
+ at MAGICS_QT_TRUE@AM_LDFLAGS = $(QT_LIBS)
+ at MAGICS_METGRAM_TRUE@bin_SCRIPTS = metgram
+ at MAGICS_SPOT_TRUE@metgramx_SOURCES = metgramx.cc
+ at MAGICS_SPOT_TRUE@templatedir = $(datadir)/templates
+ at MAGICS_SPOT_TRUE@template_DATA = 10_days_epsgram.xml 10_days_epsgram_a3.xml \
+ at MAGICS_SPOT_TRUE@                15_days_epsgram.xml 15_days_epsgram_a3.xml \
+ at MAGICS_SPOT_TRUE@                10_days_metgram.xml 10_days_wave_epsgram.xml \
+ at MAGICS_SPOT_TRUE@                15_days_with_clim_epsgram.xml \
+ at MAGICS_SPOT_TRUE@                efi_distribution.xml new_efi_distribution.xml \
+ at MAGICS_SPOT_TRUE@                classic_plumes.json
+
+EXTRA_DIST = metgram epsgram.template metgram.template \
+		eps15.xml eps10.xml \
+		eps10_a3.xml eps15_a3.xml epswave.xml\
+		10_days_epsgram.xml 10_days_epsgram_a3.xml \
+		15_days_epsgram.xml 15_days_epsgram_a3.xml \
+		10_days_metgram.xml 10_days_wave_epsgram.xml \
+		15_days_with_clim_epsgram.xml \
+		efi_distribution.xml new_efi_distribution.xml \
+		classic_plumes.json
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign apps/metgram/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign apps/metgram/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+metgramx$(EXEEXT): $(metgramx_OBJECTS) $(metgramx_DEPENDENCIES) 
+	@rm -f metgramx$(EXEEXT)
+	$(AM_V_CXXLD)$(CXXLINK) $(metgramx_OBJECTS) $(metgramx_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n' \
+	    -e 'h;s|.*|.|' \
+	    -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+	      if (++n[d] == $(am__install_max)) { \
+		print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+	    else { print "f", d "/" $$4, $$1 } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	     if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	     test -z "$$files" || { \
+	       echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	       $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	     } \
+	; done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	       sed -e 's,.*/,,;$(transform)'`; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/metgramx.Po at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-templateDATA: $(template_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(templatedir)" || $(MKDIR_P) "$(DESTDIR)$(templatedir)"
+	@list='$(template_DATA)'; test -n "$(templatedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(templatedir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(templatedir)" || exit $$?; \
+	done
+
+uninstall-templateDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(template_DATA)'; test -n "$(templatedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(templatedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(templatedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(templatedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-templateDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+	uninstall-templateDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool ctags distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binPROGRAMS install-binSCRIPTS install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip install-templateDATA \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-binSCRIPTS uninstall-templateDATA
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/apps/metgram/classic_plumes.json b/apps/metgram/classic_plumes.json
new file mode 100644
index 0000000..9738b1a
--- /dev/null
+++ b/apps/metgram/classic_plumes.json
@@ -0,0 +1,298 @@
+{
+    "drivers": [
+        {
+            "format": "${format=ps}", 
+            "fullname": "${path=plumes.ps}" 
+        }
+    ], 
+    "height": "${height=29.7}",
+     "page": {
+      "height": "7%",
+      "page_id": "off"
+    },
+    "page": {
+        "border": "on", 
+        "height": "30%", 
+		"text" : {
+			"height":"20%",
+			"width":"100%",
+			"display" : "absolute",
+			"bottom" : "65%",
+			"border" : "off",
+			"text_justification" : "left",
+			"text_colour" : "navy",
+			"text_line_count":5,
+			"text_line_1":"<json_info key='forecast'/>",
+			"text_line_2":"<json_info key='location'/>",
+            "text_line_3": "<json_info key='date'/>",
+            "text_line_4":" ",
+			"text_line_5":"<font size='0.4'><json_info key='title'/></font>"
+		},
+		"legend" : {
+			"height":"20%",
+			"left" : "50%",
+			"width" : "60%",
+			"display" : "absolute",
+			"bottom" : "75%",
+			"border":"off",
+			"legend_text_colour" : "navy",
+			"legend_text_font_size" : "0.35",
+			"legend_column_count" : 5,
+			"legend_entry_text_width": "72%",
+			"legend_text_quality": "high",
+			"legend_text_composition" : "user_text_only",
+			"legend_user_lines" : "0.5-10%/1-30%/30-50%/50-100%/ /Oper/Ctr/Mmem"
+		},
+        "map": {
+            "border": "on", 
+            "border-colour": "navy", 
+            "cartesian": {
+                "x_date": {
+                    "automatic": "on"
+                }, 
+                "y_regular": {
+                    "automatic": "on"
+                }
+            }, 
+            "height": "100%", 
+            "horizontal_axis": {
+                "axis_date_type": "days", 
+                "axis_days_label": "both", 
+                "axis_days_label_colour": "navy", 
+                "axis_months_label_colour": "navy", 
+                "axis_years_label_colour": "navy", 
+                "axis_days_label_height": "0.3", 
+                "axis_months_label_height": "0.3", 
+                "axis_years_label_height": "0.3", 
+                "axis_grid": "on", 
+                "axis_grid_colour": "Rgb(0.5, 0.5, 0.5)", 
+                "axis_grid_line_style": "dash", 
+                "axis_line_colour": "navy", 
+                "axis_minor_tick": "on", 
+                "axis_minor_tick_colour": "navy", 
+                "axis_tick_colour": "navy", 
+                "axis_type": "date", 
+                "axis_years_label_colour": "navy" 
+            }, 
+            "margin_bottom": "0%", 
+            "margin_top": "30%", 
+            "plot": {
+                "contour": {
+					"legend" : "on",
+                    "contour_akima_x_resolution": "36", 
+                    "contour_akima_y_resolution": "1", 
+                    "contour_hilo": "off", 
+                    "contour_label": "off", 
+                    "contour_level_list": "0.5/10/30/50/100", 
+                    "contour_level_selection_type": "list", 
+                    "contour_line_colour": "black", 
+                    "contour_line_thickness": "5", 
+                    "contour_method": "akima760", 
+                    "contour_shade": "on", 
+                    "contour_shade_colour_list": "blue/#00ffaa/#aaff00/red", 
+                    "contour_shade_colour_method": "list", 
+                    "contour_shade_method": "area_fill"
+                }, 
+                "wrepjson": {
+                    "wrepjson_family": "eps", 
+                    "wrepjson_input_filename": "${data=t850.json}", 
+                    "wrepjson_parameter": "${param=130.128}", 
+                    "wrepjson_parameter_offset_factor": "-273.15", 
+                    "wrepjson_temperature_correction": true,
+                    "wrepjson_parameter_title": "Temperature 850hPa" 
+                },
+                "epsplume": {} 
+            }, 
+            "template": "plume.json", 
+            "vertical_axis": {
+                "axis_grid": "on", 
+                "axis_grid_colour": "grey", 
+                "axis_grid_line_style": "dash", 
+                "axis_grid_reference_level": 0, 
+                "axis_grid_reference_thickness": 1, 
+                "axis_label_font": "sansserif", 
+                "axis_line": "on", 
+                "axis_line_colour": "navy", 
+                "axis_tick_colour": "navy", 
+                "axis_tick_label_colour": "navy", 
+                "id": "vaxis"
+            }
+        }, 
+        "meta": {
+            "javascript_path": "${js=js.js}"
+        }, 
+        "page_id": "off"
+    }, 
+        "page": {
+        "border": "on", 
+        "height": "30%",
+        "text" : {
+			"height":"20%",
+			"width":"100%",
+			"display" : "absolute",
+			"bottom" : "75%",
+			"border" : "off",
+			"text_justification" : "left",
+			"text_colour" : "navy",
+            "text_font_size" : "0.4",
+			"text_line_count":1,
+			"text_line_1":"<json_info key='title'/>"
+		}, 
+        "map": {
+            "border": "on", 
+            "border-colour": "Rgb(0.5, 0.5, 0.5)", 
+            "cartesian": {
+                "x_date": {
+                    "automatic": "on"
+                }, 
+                "y_regular": {
+                    "automatic": "on"
+                }
+            }, 
+            "height": "100%", 
+             "horizontal_axis": {
+                "axis_date_type": "days", 
+                "axis_days_label": "both", 
+                "axis_days_label_colour": "navy", 
+                "axis_months_label_colour": "navy", 
+                "axis_years_label_colour": "navy", 
+                "axis_days_label_height": "0.3", 
+                "axis_months_label_height": "0.3", 
+                "axis_years_label_height": "0.3", 
+                "axis_grid": "on", 
+                "axis_grid_colour": "Rgb(0.5, 0.5, 0.5)", 
+                "axis_grid_line_style": "dash", 
+                "axis_line_colour": "navy", 
+                "axis_minor_tick": "on", 
+                "axis_minor_tick_colour": "navy", 
+                "axis_tick_colour": "navy", 
+                "axis_type": "date", 
+                "axis_years_label_colour": "navy" 
+            }, 
+            "margin_bottom": "10%", 
+            "margin_top": "20%", 
+            "plot": {
+                "epsplume": {}, 
+                "wrepjson": {
+                    "wrepjson_family": "eps", 
+                    "wrepjson_input_filename": "${data=tp.json}", 
+                    "wrepjson_parameter": "${param=143.128}", 
+                    "wrepjson_parameter_title": "Ensemble members of Total Precipitation", 
+                    "wrepjson_parameter_scaling_factor": "1000" 
+                }
+            }, 
+            "template": "plume.json", 
+             "vertical_axis": {
+                "axis_grid": "on", 
+                "axis_grid_colour": "grey", 
+                "axis_grid_line_style": "dash", 
+                "axis_grid_reference_level": 0, 
+                "axis_grid_reference_thickness": 1, 
+                "axis_label_font": "sansserif", 
+                "axis_line": "on", 
+                "axis_line_colour": "navy", 
+                "axis_tick_colour": "navy", 
+                "axis_tick_label_colour": "navy", 
+                "id": "vaxis"
+            }
+        }, 
+        "meta": {
+            "javascript_path": "${js=js.js}"
+        }, 
+        "page_id": "off"
+    },         "page": {
+        "border": "on", 
+        "height": "30%",  
+        "text" : {
+			"height":"20%",
+			"width":"100%",
+			"display" : "absolute",
+			"bottom" : "85%",
+			"border" : "off",
+            "text_font_size" : "0.4",
+			"text_justification" : "left",
+			"text_colour" : "navy",
+			"text_line_count":1,
+			"text_line_1":"<json_info key='title'/>"
+		}, 
+        "map": {
+            "border": "on", 
+            "border-colour": "Rgb(0.5, 0.5, 0.5)", 
+            "cartesian": {
+                "x_date": {
+                    "automatic": "on"
+                }, 
+                "y_regular": {
+                    "automatic": "on"
+                }
+            }, 
+            "height": "100%", 
+            "horizontal_axis": {
+                "axis_date_type": "days", 
+                "axis_days_label": "both", 
+                "axis_days_label_colour": "navy", 
+                "axis_months_label_colour": "navy", 
+                "axis_years_label_colour": "navy", 
+                "axis_days_label_height": "0.3", 
+                "axis_months_label_height": "0.3", 
+                "axis_years_label_height": "0.3", 
+                "axis_grid": "on", 
+                "axis_grid_colour": "Rgb(0.5, 0.5, 0.5)", 
+                "axis_grid_line_style": "dash", 
+                "axis_line_colour": "navy", 
+                "axis_minor_tick": "on", 
+                "axis_minor_tick_colour": "navy", 
+                "axis_tick_colour": "navy", 
+                "axis_type": "date", 
+                "axis_years_label_colour": "navy" 
+            }, 
+            "margin_bottom": "20%", 
+            "margin_top": "10%", 
+            "plot": {
+                "contour": {
+                    "contour_akima_x_resolution": "36", 
+                    "contour_akima_y_resolution": "1", 
+                    "contour_hilo": "off", 
+                    "contour_label": "off", 
+                    "contour_level_list": "0.5/10/30/50/100", 
+                    "contour_level_selection_type": "list", 
+                    "contour_line_colour": "black", 
+                    "contour_line_thickness": "5", 
+                    "contour_method": "akima760", 
+                    "contour_shade": "on", 
+                    "contour_shade_colour_list": "blue/#00ffaa/#aaff00/red", 
+                    "contour_shade_colour_method": "list", 
+                    "contour_shade_method": "area_fill"
+                }, 
+                "epsplume": {}, 
+                "wrepjson": {
+                    "wrepjson_family": "eps", 
+                    "wrepjson_input_filename": "${data=z500.json}", 
+                    "wrepjson_parameter": "${param=129.128}",
+                    "wrepjson_parameter_scaling_factor": "0.01" ,
+                    "wrepjson_parameter_title": "Geopotential 500hPa" 
+                }
+            }, 
+            "template": "plume.json", 
+            "vertical_axis": {
+                "axis_grid": "on", 
+                "axis_grid_colour": "grey", 
+                "axis_grid_line_style": "dash", 
+                "axis_grid_reference_level": 0, 
+                "axis_grid_reference_thickness": 1, 
+                "axis_label_font": "sansserif", 
+                "axis_line": "on", 
+                "axis_line_colour": "navy", 
+                "axis_tick_colour": "navy", 
+                "axis_tick_label_colour": "navy", 
+                "id": "vaxis"
+            }
+        }, 
+        "meta": {
+            "javascript_path": "${js=js.js}"
+        }, 
+        "page_id": "on"
+    }, 
+    "version": "3.0", 
+    "width": "${width=21}"
+}
diff --git a/apps/metgram/efi_distribution.xml b/apps/metgram/efi_distribution.xml
new file mode 100644
index 0000000..22e056a
--- /dev/null
+++ b/apps/metgram/efi_distribution.xml
@@ -0,0 +1,356 @@
+<?xml version="2.0"?>
+<magics version="3.0" orientation='portrait'>
+    <drivers>
+        <$ps/>        
+        <$png/>        
+        <$svg/>        
+        <$gif/>        
+        <$pdf/>        
+    </drivers>
+    <definition>
+        <map id='box' height='100%' width='47%'  margin_left='15%' border_colour='navy'/>
+        <legend id='legend' width='52%'  left='45%' height='80%' bottom='7%' margin_right='0'
+                   entry_plot_direction='column' column_count='2' border_colour='navy' border_blanking='on'                  
+                   text_colour='navy'  />
+        <horizontal_axis id='haxis' >
+                    <line colour='navy'/> 
+                    <label colour='navy' quality='helvetica' /> 
+                    <tick colour='navy'/>                   
+		            <grid line_style="dash" colour='navy'/>
+		   </horizontal_axis>
+        <vertical_axis id='vaxis'>                                       
+                    <line colour='navy'/> 
+                    <label colour='navy' quality='helvetica'>
+                        <list list='0%/20%/40%/60%/80%/100%'/>
+                    </label> 
+                    <tick colour='navy'/>  
+                    <grid line_style="dot" colour='navy'/>
+           </vertical_axis>
+           <text id='title' bottom='83%' height='15%' left='0' 
+               colour='navy' font_size='0.4'
+               justification='left' display='absolute'/>
+			<efigram id='clim' latitude="$latitude" longitude="$longitude" efi_steps='36' 
+			      database='$database_clim/epsdb' title='off' legend_style='title'/>
+			<efigraph id='graph_clim' line_colour='navy' line_style='solid' line_thickness='6'/>
+			<efigram id='efi12' latitude="$latitude" longitude="$longitude" title='off'
+				    efi_steps='12' 
+                    database='$database_eps-12h/epsdb' 
+                    legend_database='$database_efi-12h/epsdb' 
+                    legend_step='24'
+                    legend_style='top'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph12' line_colour='purple' line_style='solid' line_thickness='4'/>
+			<efigram id='efi24' latitude="$latitude" longitude="$longitude" title='off'
+				    efi_steps='24' 
+                    database='$database_eps-24h/epsdb' 
+                    legend_database='$database_efi-24h/epsdb' 
+                    legend_step='36' 
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph24' line_colour='purple' line_style='dash' line_thickness='4'/>
+			<efigram id='efi36' latitude="$latitude" longitude="$longitude" title='off'
+				    efi_steps='36'  
+                    database='$database_eps-36h/epsdb' 
+                    legend_database='$database_efi-36h/epsdb' 
+                    legend_step='48'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph36' line_colour='red' line_style='solid' line_thickness='4'/>
+			<efigram id='efi48' latitude="$latitude" longitude="$longitude" efi_steps='48' 
+                    database='$database_eps-48h/epsdb' 
+                    legend_database='$database_efi-48h/epsdb' 
+                    legend_step='60'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph48' line_colour='red' line_style='dash' line_thickness='4'/>
+			<efigram id='efi60' latitude="$latitude" longitude="$longitude" efi_steps='60' 
+                    database='$database_eps-60h/epsdb' 
+                    legend_database='$database_efi-60h/epsdb' 
+                    legend_step='72'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph60' line_colour='RGB(1, 0.25, 0.25, 1)' line_style='solid' line_thickness='4'/>
+			<efigram id='efi72' latitude="$latitude" longitude="$longitude" efi_steps='72' 
+                    database='$database_eps-72h/epsdb' 
+                    legend_database='$database_efi-72h/epsdb' 
+                    legend_step='84'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph72' line_colour='RGB(1, 0.25, 0.25, 1)' line_style='dash' line_thickness='4'/>
+			<efigram id='efi84' latitude="$latitude" title='off' longitude="$longitude" efi_steps='84' 
+                    database='$database_eps-84h/epsdb' 
+                    legend_database='$database_efi-84h/epsdb' 
+                    legend_step='96'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph84' line_colour='RGB(1, 0.5, 0.5, 1)' line_style='solid' line_thickness='4'/>
+			<efigram id='efi96' latitude="$latitude" longitude="$longitude" efi_steps='96' 
+                    database='$database_eps-96h/epsdb' 
+                    legend_database='$database_efi-96h/epsdb' 
+                    legend_step='108'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph96' line_colour='RGB(1, 0.5, 0.5, 1)' line_style='dash' line_thickness='4'/>
+			<efigram id='efi108' latitude="$latitude" title='on' longitude="$longitude" efi_steps='108' 
+                    database='$database_eps-108h/epsdb' 
+                    legend_database='$database_efi-108h/epsdb' 
+                    legend_step='120'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph108' line_colour='RGB(1, 0.65, 0.65, 1)' line_style='solid' line_thickness='4'/>
+			<efigram id='efi120' latitude="$latitude" longitude="$longitude" efi_steps='120' 
+                    database='$database_eps-120h/epsdb' 
+                    legend_database='$database_efi-120h/epsdb' 
+                    legend_step='132'
+                    legend_style='bottom'
+                    legend_colour='RGB(1, 0.6, 0.6, 1)'/>
+			<efigraph id='graph120' line_colour='RGB(1, 0.65, 0.65, 1)' line_style='dash' line_thickness='4'/>
+
+    </definition>
+    <page height='10%'>
+		<nopageid/>
+	</page>
+    <page height='27%'>
+		<nopageid/>
+        
+	    <map use_id='box'>
+       
+          <cartesian>
+			<x_regular automatic='on'/>
+            <y_regular y_min='0' y_max='100'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>                    
+		   <vertical_axis use_id='vaxis'/>                                       
+                    
+           <text use_id='title'/>
+           <plot>
+				<efigram use_id='clim'  parameter="clim-precip"/>
+				<efigraph use_id='graph_clim'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi12'  parameter="efi-precip"/>
+				<efigraph use_id='graph12'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi24'  parameter="efi-precip"/>
+				<efigraph use_id='graph24'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi36'  parameter="efi-precip"/>
+				<efigraph use_id='graph36'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi48' parameter="efi-precip"/>
+				<efigraph use_id='graph48'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi60' parameter="efi-precip"/>
+				<efigraph use_id='graph60'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi72' parameter="efi-precip"/>
+				<efigraph use_id='graph72'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi84'   parameter="efi-precip"/>
+				<efigraph use_id='graph84'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi96' parameter="efi-precip"/>
+				<efigraph use_id='graph96'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi108' long_title='on' parameter="efi-precip"/>
+				<efigraph use_id='graph108'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi120' parameter="efi-precip"/>
+				<efigraph use_id='graph120'/>
+			</plot>
+        </map>
+             <legend use_id='legend' />
+		</page>	 
+		<page height='27%'>	 
+		<nopageid/>
+         <map use_id='box'>
+           <text use_id='title'/>
+              
+          <cartesian>
+			<x_regular automatic='on'/>
+            <y_regular min='0' max='100'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>
+                    
+		   <vertical_axis use_id='vaxis'/>                                       
+          
+           <plot>
+				<efigram use_id='clim' parameter="clim-wind-gust"/>
+				<efigraph use_id='graph_clim'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi12' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph12'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi24' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph24'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi36' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph36'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi48' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph48'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi60' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph60'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi72' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph72'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi84' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph84'/>
+            </plot>
+            <plot>
+				<efigram use_id='efi96' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph96'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi108' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph108'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi120' parameter="efi-wind-gust"/>
+				<efigraph use_id='graph120'/>
+			</plot>
+		    
+        </map>
+            <legend use_id='legend' />          
+		</page>
+		<!--page height='22%'>	 
+		<nopageid/>
+         <map use_id='box'>
+        
+           <text use_id='title'/>
+              
+          <cartesian>
+			<x_regular automatic='on'/>
+            <y_regular min='0' max='100'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>
+                    
+		   <vertical_axis use_id='vaxis'/>                                       
+          
+           <plot>
+				<efigram use_id='clim' parameter="clim-2mt-min"/>
+				<efigraph use_id='graph_clim'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi12'  parameter="efi-2mt-min"/>
+				<efigraph use_id='graph12'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi24'  parameter="efi-2mt-min"/>
+				<efigraph use_id='graph24'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi36' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph36'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi48' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph48'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi60' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph60'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi72' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph72'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi84' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph84'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi96' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph96'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi108' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph108'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi120' parameter="efi-2mt-min"/>
+				<efigraph use_id='graph120'/>
+			</plot>
+		    
+        </map>
+            <legend use_id='legend' />          
+		</page-->
+		<page height='27%'>	 
+		<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+		        font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+         <map use_id='box'>
+     
+           <text use_id='title'/>
+              
+          <cartesian>
+			<x_regular automatic='on'/>
+            <y_regular min='0' max='100'/>
+           </cartesian>  
+           <horizontal_axis use_id='haxis'/>
+                    
+		   <vertical_axis use_id='vaxis'/>                                       
+          
+           <plot>
+				<efigram use_id='clim' parameter="clim-2mt-mean"/>
+				<efigraph use_id='graph_clim'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi12'  parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph12'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi24'  parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph24'/>
+			</plot>
+			<plot>
+				<efigram use_id='efi36' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph36'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi48' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph48'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi60' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph60'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi72' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph72'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi84' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph84'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi96' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph96'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi108' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph108'/>
+			</plot>
+            <plot>
+				<efigram use_id='efi120' parameter="efi-2mt-mean"/>
+				<efigraph use_id='graph120'/>
+			</plot>
+		    
+        </map>
+            <legend use_id='legend' />          
+       
+        
+       
+      </page>
+    </magics>  
+
+
diff --git a/apps/metgram/eps10.xml b/apps/metgram/eps10.xml
new file mode 100644
index 0000000..c6620e7
--- /dev/null
+++ b/apps/metgram/eps10.xml
@@ -0,0 +1,9 @@
+
+<eps template='/tmp/cgs/perforce/mv4/apps/metgram/10_days_epsgram.xml' database='/scratch/graphics/cgs/efi/10_days/0001/2009042200' format='a4'> 
+   
+    
+   <station name='Reading' latitude='51.4' longitude='-1' height='48' psfile='Reading.ps'
+       metafile='Reading.meta'/>
+   
+    
+</eps>
diff --git a/apps/metgram/eps10_a3.xml b/apps/metgram/eps10_a3.xml
new file mode 100644
index 0000000..55a9c00
--- /dev/null
+++ b/apps/metgram/eps10_a3.xml
@@ -0,0 +1,9 @@
+
+<eps template='10_days_epsgram_a3.xml' database='/vol/epsgram/data/spotbase/10_days/0001/latest' format='a3'> 
+   
+    
+   <station name='Reading' latitude='51.4' longitude='-1' height='48' psfile='Reading.ps'
+       giffile='Reading.gif' metafile='Reading.meta'/>
+   
+    
+</eps>
diff --git a/apps/metgram/eps15.xml b/apps/metgram/eps15.xml
new file mode 100644
index 0000000..88e9b6e
--- /dev/null
+++ b/apps/metgram/eps15.xml
@@ -0,0 +1,8 @@
+<eps template='/tmp/cgs/perforce/mv4/apps/metgram/15_days_epsgram.xml' database='/scratch/graphics/cgs/efi/15_days/0001/2009042200' format='a4'> 
+   <station name='Reading' latitude='51.4' longitude='-1' noheight='48'
+            psfile='eps15.ps'
+            pngfile='Reading15.png'
+            giffile='Reading.gif'
+	    svgfile='Reading.svg'
+	    metafile='Reading.meta'/>
+</eps>
diff --git a/apps/metgram/eps15_a3.xml b/apps/metgram/eps15_a3.xml
new file mode 100644
index 0000000..5b86546
--- /dev/null
+++ b/apps/metgram/eps15_a3.xml
@@ -0,0 +1,10 @@
+<eps template='15_days_epsgram_a3.xml' 
+     database='/vol/epsgram/data/spotbase/15_days/0001/latest' 
+     format='a3'> 
+  <station name='Reading'
+           latitude='51.4' longitude='-1' height='48' 
+	   psfile='Reading15.ps'
+	   giffile='Reading.gif'
+	   pngfile='Reading.png'
+	   metafile='Reading.meta'/>
+</eps>
diff --git a/apps/metgram/epsgram.template b/apps/metgram/epsgram.template
new file mode 100644
index 0000000..ac3ec7d
--- /dev/null
+++ b/apps/metgram/epsgram.template
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<magics>
+	<definition>
+		<epsgram id="station" 
+                station='$station' 
+                latitude="$latitude" longitude="$longitude" 
+                date="$date" time="$time" height="$height" 
+                eps_temperature_correction='yes'/>
+	
+        <title id="title" justification="left" character_height="0.4">
+			<colour>blue</colour>
+		</title>
+		<axisview id="box" height="75%" bottom="15%" width="85%" left='10%'>
+			<frame thickness="3">
+				<colour>kelly_green</colour>
+			</frame>
+		</axisview>
+
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4">
+			<automatic/>
+			<nolabel/>
+			<date/>
+			<noline/>
+            <minortick/>
+			<colour>kelly_green</colour>
+			<grid line_style="dot">
+				<colour>kelly_green</colour>
+			</grid>
+            <tick>
+                <colour>kelly_green</colour>
+			</tick>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4">
+			<colour>kelly_green</colour>
+			<automatic/>
+			<noline/>
+            <label>
+                <colour>kelly_green</colour>
+			</label>
+			<grid line_style="dot">
+				<colour>kelly_green</colour>
+			</grid>
+            <tick>
+                <colour>kelly_green</colour>
+			</tick>
+		</vertical_axis>
+	</definition>
+
+    <page orientation="portrait" format="a4">
+		<pageid/>
+		<subpage height="30.0%" bottom='5%'>
+			<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' />
+			<noframe/>
+
+			<axisview height="50%" bottom="25.0%" width="85%" left='10%' >
+                 <frame thickness="3">
+				    <colour>kelly_green</colour>
+			    </frame>
+				<area x_min="0" x_max="240" y_min="-50" y_max="50"/>
+				<horizontal_axis use_id="haxis">
+					<label/>
+                    
+				</horizontal_axis>
+				<vertical_axis use_id="vaxis"/>
+				<xylayer>
+					<epsgram use_id="station" parameter="2mt"/>
+					<epsgraph> <both/> </epsgraph>
+				</xylayer>
+			</axisview>
+            <legend>  
+                  <positional x='0.2' y='0.3' width='8' height='2'/>             
+            </legend>
+			<title use_id="title"/>
+		</subpage>
+
+		<subpage bottom="30%" height="20%">
+			<nopageid/>
+			<noframe/>
+
+			<axisview use_id="box">
+				<area x_min="0" x_max="240" y_min="0" y_max="50"/>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+				<xylayer>
+					<epsgram use_id="station" parameter="10m-wind"/>
+					<epsgraph> <both/> </epsgraph>
+				</xylayer>
+			</axisview>
+        
+			<title use_id='title'/>
+		</subpage>
+
+		<subpage bottom="49%" height="20%">
+			<noframe/>
+
+			<!--
+				Here we load and plot the actual data. Within the 'layer' tag
+				we also include the visual definitions that will be used
+				to plot the data
+			-->
+			<axisview use_id="box">
+				<area x_min="0" x_max="240" y_min="0" y_max="1000"/>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+				<legend/>
+				<xylayer>
+					<epsgram use_id="station" parameter="precip"/>
+					<!-- Define the contour attributes and plot the contours -->
+					<epsgraph> <both/> </epsgraph>
+				</xylayer>
+			</axisview>
+            <title use_id='title'/>
+			
+			<nopageid/>
+		</subpage>
+
+		<subpage bottom="67.5%" height="40%">
+			<axisview height="40%"  width="85%" left='10%' >
+            <frame thickness="3">
+				    <colour>kelly_green</colour>
+			    </frame>
+				<area x_min="0" x_max="240" y_min="0" y_max="8"/>
+				<horizontal_axis use_id="haxis"/>				
+		        <vertical_axis  use_id="vaxis">
+			        <regular/>			
+		        </vertical_axis>
+				<legend/>
+				<xylayer>
+					<epsgram use_id="station" parameter="cloud-cover" long_title='true'/>
+					<!-- Define the contour attributes and plot the contours -->
+					<epsgraph> <both/> </epsgraph>
+				</xylayer>
+			</axisview>
+			<!-- Set up the title text -->
+			
+            <title use_id='title'/>
+			<nopageid/>
+		</subpage>
+
+		
+	</page>
+</magics>
diff --git a/apps/metgram/epswave.xml b/apps/metgram/epswave.xml
new file mode 100644
index 0000000..0fa3cfa
--- /dev/null
+++ b/apps/metgram/epswave.xml
@@ -0,0 +1,8 @@
+
+<eps template='/tmp/cgs/perforce/mv4/apps/metgram/10_days_wave_epsgram.xml' database='/scratch/graphics/cgs/efi/10_days_wave/0001/2009042200' format='a4'> 
+   
+    
+   <station name='hello' latitude='51.4' longitude='-10' psfile='epswave.ps'/>
+   
+    
+</eps>
diff --git a/apps/metgram/metgram b/apps/metgram/metgram
new file mode 100755
index 0000000..792acc4
--- /dev/null
+++ b/apps/metgram/metgram
@@ -0,0 +1,389 @@
+#!/usr/bin/perl
+use strict;
+use Data::Dumper;
+use IO::Socket;
+use XML::Parser;
+use File::Basename;
+
+my $file = shift;
+my $info = {};
+my $element = {};
+my $cpfile;
+my $psfile = "";
+my $giffile = "";
+my $xmlfile = "";
+my $pngfile = "";
+my $jpgfile = "";
+my $pdffile = "";
+my @suffixlist = ( ".ps", ".gif", ".png", ".pdf", ".jpg", ".xml" );
+my @suffixlist2 = ( "ps", "gif", "png", "pdf", "jpg", "xml" );
+
+my $request = {
+    action    => "make_eps",
+    expver    => "0001"
+};
+
+my %templates = (
+    "15_days_epsgram.xml" => "15_days",
+    "15_days" => "15_days",
+    "15_days_with_clim" => "15_days_with_clim",
+    "15_days_epsgram_a3.xml" => "15_days",
+    "10_days_epsgram.xml" => "10_days",
+    "10_days" => "10_days",
+    "10_days_epsgram_a3.xml" => "10_days", 
+    "10_days_metgram_a3.xml" => "10_days_metgram", 
+    "10_days_metgram" => "10_days_metgram", 
+    "10_days_metgram.xml" => "10_days_metgram", 
+    "10_days_wave_epsgram.xml" => "10_days_wave", 
+    "10_days_wave" => "10_days_wave", 
+    "multi_metgrams_page1" => "multi_metgrams_page1", 
+    "multi_metgrams_page2" => "multi_metgrams_page2", 
+    "multi_metgrams_page3" => "multi_metgrams_page3", 
+    "multi_metgrams_page4" => "multi_metgrams_page4", 
+);
+
+my $localtemplates = {
+    a4 => {
+        '15_days_epsgram.xml' => '15_days_epsgram.xml',
+        '15_days' => "15_days_epsgram.xml",
+        '10_days_epsgram.xml' => "10_days_epsgram.xml",
+        '10_days' => "10_days_epsgram.xml",
+        '10_days_wave_epsgram.xml' => "10_days_wave_epsgram.xml",
+        '10_days_wave' => "10_days_wave_epsgram.xml",
+        '10_days_wave_epsgram' => "10_days_wave_epsgram.xml",
+        '10_days' => "10_days_epsgram.xml",
+        '10_days_metgram_a3.xml' => "10_days_metgram.xml", 
+        '10_days_metgram' => "10_days_metgram.xml", 
+        '10_days_metgram.xml' => "10_days_metgram.xml", 
+    },
+    a3 => {
+        '15_days_epsgram' => "15_days_epsgram_a3.xml",
+        '15_days_epsgram_a3.xml' => "15_days_epsgram_a3.xml",
+        '15_days' => "15_days_epsgram_a3.xml",
+        '10_days_epsgram.xml' => "10_days_epsgram_a3.xml",
+        '10_days_epsgram_a3' => "10_days_epsgram_a3.xml",
+        '10_days' => "10_days_epsgram_a3.xml",
+        '10_days_metgram_a3.xml' => "10_days_metgram.xml", 
+        '10_days_metgram' => "10_days_metgram.xml", 
+        '10_days_metgram.xml' => "10_days_metgram.xml", 
+        '10_days_wave_epsgram.xml' => "10_days_wave_epsgram.xml",
+        '10_days_wave' => "10_days_wave_epsgram.xml",
+        '10_days_wave_epsgram' => "10_days_wave_epsgram.xml",
+    },
+};
+
+my %actions = (
+    eps => \&eps,
+    epslocal => \&epslocal,
+    station => \&station,
+);
+
+
+my %savefile = (
+    ps => \&ps,
+    gif => \&gif,
+    png => \&png,
+    pdf => \&pdf,
+    jpeg => \&jpeg, 
+    jpg => \&jpeg,
+    xml => \&xml,
+);
+
+my $xml= new XML::Parser::Expat;
+
+$xml->setHandlers(Start=>\&tag);  
+$xml->parsefile($file);
+my $localeps;
+
+sub epslocal
+{
+    my %params = @_;
+    my $format = "a4";
+    $format = $params{format} unless $params{format} eq '';
+    print "$format\n";
+    print "$localtemplates->{$format}\n";
+    $localeps="<eps template='$localtemplates->{$format}->{$params{template}}' database='$params{database}'>\n";
+    $actions{station} = \&localstation;
+}
+
+sub eps
+{
+    my %params = @_;
+    
+    my $expver = "0001";
+    $expver = $params{expver} unless $params{expver} eq '';
+    
+    $request->{action} = 'make_eps';
+    $request->{expver} = $params{expver};
+    $request->{database} = $templates{$params{template}};
+    $request->{fullpath} = $params{database} unless  $params{database} eq '';
+    $request->{time} = $params{time};
+    if ( $params{date} eq 'latest' ) {
+       $request->{time} = "";
+        
+    }
+    $request->{date} = $params{date};
+    
+    $request->{format} = lc $params{format};
+    
+}
+sub localstation
+{
+    my %params = @_;
+    my $tmp = "metgram.$$.xml";
+    my $magplushome = $ENV{'MAGPLUS_HOME'};
+    my $magplusbin  = ($magplushome) ? $magplushome . "/bin/" : "";
+
+    open(OUT,">$tmp") or die "$tmp: $!";
+    print OUT $localeps;
+    
+    print OUT "<station name='$params{name}' latitude='$params{latitude}' longitude='$params{longitude}'";
+    print OUT " height='$params{height}' "    unless $params{height}   eq "";
+    print OUT " psfile='$params{psfile}' "    unless $params{psfile}   eq "";
+    print OUT " giffile='$params{giffile}' "  unless $params{giffile}  eq "";
+    print OUT " pdffile='$params{pdffile}' "  unless $params{pdffile}  eq "";
+    print OUT " jpgfile='$params{jpgfile}' "  unless $params{jpgfile}  eq "";
+    print OUT " jpgfile='$params{jpegfile}' " unless $params{jpegfile} eq "";
+    print OUT " pngfile='$params{pngfile}' "  unless $params{pngfile}  eq "";
+    print OUT "/>\n</eps>\n";
+
+    system ($magplusbin . 'metgramx', $tmp);
+    unlink $tmp;
+    
+}
+
+sub station
+{
+    my %params = @_;
+ 
+    $request->{title} = $params{name};
+    $request->{latitude} = $params{latitude};
+    $request->{longitude} = $params{longitude};
+    $request->{height} = $params{height};      
+    $psfile  = $params{psfile}; 
+    $giffile = $params{giffile};
+    $jpgfile = $params{jpgfile}; 
+    $pngfile = $params{pngfile}; 
+    $pdffile = $params{pdffile}; 
+
+    # find out if the user has supplied any output filenames
+    my $givenfile = "";
+    $givenfile = $params{psfile}  unless ($givenfile ne "" or $params{psfile}  eq "");
+    $givenfile = $params{giffile} unless ($givenfile ne "" or $params{giffile} eq "");
+    $givenfile = $params{jpgfile} unless ($givenfile ne "" or $params{jpgfile} eq "");
+    $givenfile = $params{pngfile} unless ($givenfile ne "" or $params{pngfile} eq "");
+    $givenfile = $params{pdffile} unless ($givenfile ne "" or $params{pdffile} eq "");
+
+    if ($givenfile eq "") {
+        die "No output filename supplied!";
+    }
+
+
+    # print ("Taking input name of $givenfile\n");
+    my ($path,$dir,$suffix) = fileparse($givenfile, at suffixlist);
+   
+    $request->{path}=$dir . $path;  
+
+
+    # add flags to say which formats are being requested
+
+    if ($params{psfile}  ne "") {$request->{ps}  = "1"};
+    if ($params{giffile} ne "") {$request->{gif} = "1"};
+    if ($params{jpgfile} ne "") {$request->{jpg} = "1"};
+    if ($params{pngfile} ne "") {$request->{png} = "1"};
+    if ($params{pdffile} ne "") {$request->{pdf} = "1"};
+
+
+    #print Dumper($request);
+    remote_call($request);
+    
+}
+sub ps 
+{
+    my ($from) = @_;
+
+    if ( $psfile eq '' ) {
+        unlink $from;
+    }
+    else {
+        rename($from, $psfile) || die "Can't rename $from to $psfile: $!";;
+        #print "metgram info: file $psfile created (from $from)\n";
+    }
+ 
+}
+
+sub gif 
+{
+    my ($from) = @_;
+    
+    if ( $giffile eq '') {
+        unlink $from 
+    }
+    else {
+        rename($from, $giffile); 
+        print "metgram info: file $giffile created\n";
+    
+    }
+}    
+
+sub png 
+{
+    my ($from) = @_;
+    
+    if ( $pngfile eq '') {
+        unlink $from 
+    }
+    else {
+        rename($from, $pngfile); 
+        print "metgram info: file $pngfile created\n";
+    
+    }
+} 
+   
+sub jpeg 
+{
+    my ($from) = @_;
+    
+    if ( $jpgfile eq '') {
+        unlink $from 
+    }
+    else {
+        rename($from, $jpgfile); 
+        print "metgram info: file $jpgfile created\n";
+    
+    }
+}    
+
+sub pdf 
+{
+    my ($from) = @_;
+    
+    if ( $pdffile eq '') {
+        unlink $from 
+    }
+    else {
+        rename($from, $pdffile); 
+        print "metgram info: file $pdffile created\n";
+    
+    }
+}   
+ 
+sub xml 
+{
+     my ($from) = @_;
+    
+    if ( $xmlfile eq '') {
+        unlink $from;
+    }
+    else {
+        rename($from, $xmlfile); 
+        print "metgram info: file $xmlfile created\n";
+    }
+} 
+
+sub tag
+{
+
+    my ($parser, $tag, %attr) = @_; 
+    
+   
+    if ( defined $actions{$tag} ) {
+        &{$actions{$tag}}(%attr);
+    }
+   
+   
+   
+}   
+
+
+
+sub remote_call {
+	my ($args) = @_;
+
+	local $SIG{ALRM} = sub { die "timeout waiting for meteogram server"; };
+
+	alarm(60);
+	alarm(400);
+	alarm(0);
+
+	my $soc = IO::Socket::INET->new(
+			PeerAddr => "epsgrams:9898",
+			Proto    => "tcp",
+			Type     => SOCK_STREAM,
+			);
+
+	print $soc Dumper($args);
+	shutdown($soc,1);
+
+	my $VAR1;
+	local $/;
+	$/ = "\n";
+
+	my $line;
+	while($line = get_line($soc))
+	{
+         
+		if($line eq "FILE")
+		{
+			my $size = get_line($soc);
+			my $path = get_line($soc); 
+            my ($name,$dir,$suffix) = fileparse($path, at suffixlist2);
+			my $buf;
+			my $buflen = 64*1024;
+			my $read;
+			my $total = 0;
+
+            #print ("saving to $path.tmp\n");
+			open(OUT,">$path.tmp") or die "$path.tmp: $!";
+			while($size>0)
+			{
+				$buflen = $size if($size < $buflen);
+				$read = sysread($soc,$buf,$buflen);
+				last if($read <= 0);
+				syswrite(OUT,$buf,$read);
+				$size -= $read;
+				$total += $read;
+			}
+			close(OUT) or die "$path.tmp: $!";
+            
+          
+           
+			&{$savefile{$suffix}}("$path.tmp") unless($size);
+			next;
+		}
+
+		if($line eq "REPLY")
+		{
+			local $/;
+			$VAR1 = <$soc>;
+			eval $VAR1;
+			last;
+		}
+
+		die "[$line]";
+	}
+
+	close($soc);
+
+	alarm(0);
+
+	return $VAR1;
+
+}
+sub get_line {
+	my ($soc) = @_;
+	my $buf;
+	my $text;
+
+	while(sysread($soc,$buf,1) == 1)
+	{
+		last if($buf eq "\n");
+		$text .= $buf;
+	}
+
+	return $text;
+
+
+}
+
+
diff --git a/apps/metgram/metgram.template b/apps/metgram/metgram.template
new file mode 100644
index 0000000..e8b95ff
--- /dev/null
+++ b/apps/metgram/metgram.template
@@ -0,0 +1,163 @@
+<?xml version="1.0"?>
+<magics>
+	<definition>
+		<metgram id="station" 
+                station='$station' 
+                latitude="$latitude" longitude="$longitude" 
+                date='$date' time="$time" height="$height" 
+                eps_temperature_correction='yes'
+                database='$database'> $title 
+                <none/>
+        </metgram>
+	
+        <title id="title" justification="left" character_height="0.4" colour='blue'>
+		
+		</title>
+		<axisview id="box" height="2.5cm" bottom="1cm" width="17.5cm" left='2cm'>
+			<frame thickness="2" colour='kelly_green'>
+			</frame>
+		</axisview>
+
+		<horizontal_axis id="haxis" axis_line="false" line_thickness="4" colour='kelly_green'>
+			<automatic/>
+			<nolabel/>
+			<date/>
+			<noline/>
+            <minortick colour='kelly_green'/>
+			<colour>kelly_green</colour>
+			<grid line_style="dot" colour='kelly_green'>
+				
+			</grid>
+            <tick colour='kelly_green'>
+               
+			</tick>
+		</horizontal_axis>
+
+		<vertical_axis id="vaxis" axis_line="false" line_thickness="4" colour='kelly_green'>
+			
+			<automatic/>
+			<noline/>
+            <label colour='kelly_green'>
+              
+			</label>
+			<grid line_style="dot" colour='kelly_green'>
+				
+			</grid>
+            <tick colour='kelly_green'>
+               
+			</tick>
+		</vertical_axis>
+	</definition>
+
+    <page orientation="portrait" format="$format">
+        <$meta/>
+		<pageid/>
+		<subpage height="14%" bottom='7%'>
+			<pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' />
+			<noframe/>
+
+			<axisview use_id='box' >
+				<xy_system x_min="0" x_max="240" y_min="-50" y_max="50"/>
+				<horizontal_axis use_id="haxis">
+					<date >
+                    <both colour='blue' height='0.25' />
+                     <month height='0.3' colour='blue'> <monthandyear /> </month>
+                     <noyear height='0.4'/>
+                    </date>
+                    <label/>
+				</horizontal_axis>
+				<vertical_axis use_id="vaxis"/>
+				<xylayer>
+					<metgram use_id="station" parameter="temperature"/>
+					<metgraph> </metgraph>
+				</xylayer>
+			</axisview>
+              <!--legend>
+                <positional x='4' y='1' width='5' height='1' border='on' blanking='on'>
+                </positional>
+            </legend-->
+			<title use_id="title"/>
+		</subpage>
+        
+        <subpage height="14%" bottom='20%'>
+			<nopageid/><noframe/>
+
+			<axisview use_id='box' >
+				<xy_system x_min="0" x_max="240" y_min="0" y_max="2"/>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"> <nolabel/> <notick/> <nogrid/> </vertical_axis>
+				<xylayer>
+					<metgram use_id="station" parameter="10m_wind"/>
+					<metgraph> <flags/> </metgraph>
+				</xylayer>
+			</axisview>
+           
+			<title use_id="title"/>
+		</subpage>
+
+        	<subpage height="14%" bottom='33%'>
+			<nopageid/><noframe/>
+
+			<axisview use_id='box' >
+				<xy_system x_min="0" x_max="240" y_min="-50" y_max="50"/>
+				<horizontal_axis use_id="haxis"/>				
+				<vertical_axis use_id="vaxis"/>
+				<xylayer>
+					<metgram use_id="station" parameter="msl"/>
+					<metgraph> </metgraph>
+				</xylayer>
+			</axisview>
+           
+			<title use_id="title"/>
+		</subpage>
+        <subpage height="14%" bottom='46%'>
+			<nopageid/><noframe/>
+
+			<axisview use_id='box' >
+               
+				<xy_system x_min="0" x_max="240" y_min="-50" y_max="50"/>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"/>
+				<xylayer>
+					<metgram use_id="station" parameter="precipitation"/>
+					<metgraph> <bar/> </metgraph>
+				</xylayer>
+			</axisview>
+          
+			<title use_id="title"/>
+		</subpage>
+        <subpage height="14%" bottom='59%'>
+			<nopageid/><noframe/>
+
+			<axisview use_id='box' >
+				<xy_system x_min="0" x_max="240" y_min="0" y_max="100"/>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"> <regular/>	</vertical_axis>
+				<xylayer>
+					<metgram use_id="station" parameter="humidity"/>
+					<metgraph> </metgraph>
+				</xylayer>
+			</axisview>
+            
+			<title use_id="title"/>
+		</subpage>
+	  <subpage height="38%" bottom='72%'>
+			<nopageid/><noframe/>
+
+			<axisview use_id='box'>
+			
+				<xy_system x_min="0" x_max="240" y_min="0" y_max="100"/>
+				<horizontal_axis use_id="haxis"/>
+				<vertical_axis use_id="vaxis"> <regular/>	</vertical_axis>
+				<xylayer>
+					<metgram use_id="station" parameter="cloud_cover" long_title='true'/>
+					<metgraph> <bar/> </metgraph>
+				</xylayer>
+			</axisview>
+            
+			<title use_id="title"/>
+		</subpage>
+
+		
+	</page>
+</magics>
diff --git a/apps/metgram/metgramx.cc b/apps/metgram/metgramx.cc
new file mode 100644
index 0000000..ec15525
--- /dev/null
+++ b/apps/metgram/metgramx.cc
@@ -0,0 +1,251 @@
+#include <iostream>
+
+#include <XmlMagics.h>
+#include <ParameterManager.h>
+
+#include <XmlReader.h>
+
+using namespace std;
+using namespace magics;
+
+
+class MagicsService {
+public:
+	MagicsService() : 
+		manager_()
+	{
+	}
+	
+	void execute(const string& xml)
+	{
+		try {
+			manager_.execute(xml);
+		}
+		catch(MagicsException& e)
+		{
+			MagLog::error() << e << endl;    
+		}
+	}
+
+private:
+	XmlMagics     manager_;
+};
+
+
+static 
+void substitute(string& xml, const string& var, const string& val)
+{
+	string name = "$" + var;
+	string::size_type index = xml.find(name);
+	int last = 0;
+	
+	while ( index != string::npos)
+	{
+		xml.replace(index, name.length(), val);
+		last = index + val.length();
+
+		index = xml.find(name, last);
+        }
+}
+
+char nospace(char c)
+{
+	if (c == ' ' ) return '_'; 
+	return c;  
+}
+
+class TempFile
+{
+  public:
+    TempFile() : filename(tmpnam(0)), ofs(filename)
+    {
+        if (!ofs) return;
+    }
+
+    ~TempFile()
+    {
+        ofs.close();
+        remove(filename);
+    }
+
+    ofstream& operator()() { return ofs; }
+    string name() { return filename; }
+
+  private:
+    const char* filename;
+    ofstream ofs;
+};
+
+class Station: public XmlNodeVisitor
+{
+public:
+    Station(const XmlNode& node)
+    {
+        date_ = node.getAttribute("date");
+        time_ = node.getAttribute("time");
+        template_ = node.getAttribute("template");
+        if ( template_.empty() ) 
+            template_ = string(getenv("MAGPLUS_HOME")) + "/share/templates/10_days_epsgram.xml";
+        database_ = node.getAttribute("database");
+        format_ = node.getAttribute("format");
+         if ( format_.empty() ) format_ = "a4";
+        deterministic_ = node.getAttribute("deterministic");
+        if ( deterministic_.empty() ) deterministic_ = "on";
+        whisker_ = node.getAttribute("whisker");
+        if ( whisker_.empty() ) whisker_ = "on";
+        parameters_ = node.attributes();
+    }
+    
+    ~Station() {}
+    void visit(const XmlNode& node )
+    {
+	if ( node.name() == "station")
+	{
+		ostringstream station;
+		for ( XmlNode::DataIterator data = node.firstData(); data != node.lastData(); ++data)
+		station << *data;
+
+		MagLog::dev() << "title-->" << station.str() << endl;    
+		MagLog::dev() << "Plot Station-->" << node.getAttribute("name") << endl;
+		MagLog::dev() << "Template-->" << template_ << endl;
+
+		try{
+			ifstream test(template_.c_str());
+			
+			if ( !test.good() )
+			{		
+				// Try to look in ethe default template directory :
+				template_ = string(getenv("MAGPLUS_HOME")) + "/share/templates/" + template_;
+				MagLog::dev() << "try to find template in system directory-> " << template_ << endl;
+				ifstream defaut(template_.c_str());
+				if ( !defaut.good() ) {
+					MagLog::error() << "Can not open template file " << template_ << endl;
+					return;
+				}
+				defaut.close();
+			}
+			test.close();
+			
+			ifstream in(template_.c_str());
+			
+			TempFile file;
+			ofstream& out = file();
+			static string s; 
+			s = "";
+
+			char c;
+			while(in.get(c))
+			{
+				s+=c;
+			}
+
+			ostringstream def;
+			def << INT_MAX;
+
+			string meta = node.getAttribute("metafile");
+#ifdef MAGICS_AIX_XLC
+			meta ="";
+#endif
+			meta = (meta.empty()) ? "nometada" : "meta path=\'" + meta + "\'";
+
+			MagLog::dev() << "Meta-->" << meta;
+			substitute(s, "meta", meta);
+
+			string height = (node.getAttribute("height") == "" )? def.str() : node.getAttribute("height");
+			substitute(s, "height", height);
+			substitute(s, "latitude", node.getAttribute("latitude"));
+			substitute(s, "longitude", node.getAttribute("longitude"));
+			substitute(s, "station", node.getAttribute("name"));
+			substitute(s, "title", station.str());
+			substitute(s, "date", date_);
+			substitute(s, "time", time_);
+			
+			substitute(s, "format", format_);
+			substitute(s, "deterministic", deterministic_);
+			substitute(s, "whisker", whisker_);
+
+            for ( map<string, string>::iterator param = parameters_.begin(); param != parameters_.end(); ++param)
+                     substitute(s, param->first, param->second);       
+			string ps = node.getAttribute("psfile");
+			ps = ps.empty() ? "nops" : "ps fullname=\'" + ps + "\'";
+			substitute(s, "ps", ps);
+            
+			string pdf = node.getAttribute("pdffile");
+			pdf = pdf.empty() ? "nopdf" : "pdf fullname=\'" + pdf + "\'";
+			substitute(s, "pdf", pdf);
+            
+			string gif = node.getAttribute("giffile");
+			gif = gif.empty() ? "nogif" : "gif fullname=\'" + gif + "\'";
+			substitute(s, "gif", gif);
+
+			string png = node.getAttribute("pngfile");
+			png = png.empty() ? "nopng" : "png fullname=\'" + png + "\'";
+			substitute(s, "png", png);
+
+			string svg = node.getAttribute("svgfile");
+			svg = svg.empty() ? "nosvg" : "svg fullname=\'" + svg + "\'";
+			substitute(s, "svg", svg);
+
+			out << s;
+
+			in.close();
+			out.flush();
+ 
+			magics_.execute(file.name());
+		}
+		catch (exception e) {}
+	}
+    }
+protected:
+    string date_;
+    string time_;
+    string  template_;
+    string  directory_;
+    string  database_;
+    string  format_;
+    string  deterministic_;
+    string  whisker_;
+    MagicsService magics_;
+    map<string, string> parameters_;
+};
+
+
+class Eps: public XmlNodeVisitor
+{
+public:
+    Eps()  {}
+    ~Eps() {}
+    void visit(const XmlNode& node)
+    {
+        MagLog::dev() << "node-->" << node.name() << endl;
+        if ( node.name() == "eps")
+	{
+            Station station(node);
+            node.visit(station);
+        }       
+    }
+};
+
+int main(int argc, char **argv)
+{
+    if ( argc < 2 )
+    {
+        cout << "Usage: " << argv[0] << " <file.epsml>\n"; 
+        exit(1);
+    }
+
+    string xml = argv[1];
+    XmlReader reader;
+    XmlTree tree;
+    
+    try {
+        reader.interpret(xml, &tree);
+    }
+    catch (...)
+    {
+        cerr << "metgram : error interpreting file " << xml << "\n";
+    }
+    Eps metgram;
+
+    tree.visit(metgram);
+}
diff --git a/apps/metgram/new_efi_distribution.xml b/apps/metgram/new_efi_distribution.xml
new file mode 100755
index 0000000..60b9ccd
--- /dev/null
+++ b/apps/metgram/new_efi_distribution.xml
@@ -0,0 +1,142 @@
+<?xml version="2.0"?>
+<magics version="3.0" orientation='portrait'>
+    <drivers>
+		<$ps/>
+	    <$pdf/>
+	    <$png/>
+	    <$gif/>
+	    <$svg/>
+    </drivers>
+    <definition>
+        <map id='box' 
+           
+            margin_left='7.5%' 
+            margin_right='50%' 
+            margin_top='17%'
+            border='on'
+            border_colour='navy'/>
+        <legend id='legend' width='47%' left='51%' height='75%' bottom='7%'
+                    entry_plot_direction='column' border_colour='navy' border='on' border_blanking='on'                  
+                   text_colour='navy'  />
+        <horizontal_axis id='haxis' >
+                    <line colour='navy'/> 
+                    <label colour='navy' quality='helvetica' /> 
+                    <tick colour='navy'/>                   
+		            <grid line_style="dash" colour='navy'/>
+		   </horizontal_axis>
+        <vertical_axis id='vaxis'>                                       
+                    <line colour='navy'/> 
+                    <label colour='navy' quality='helvetica'>
+                        <list list='0%/20%/40%/60%/80%/100%'/>
+                    </label> 
+                    <tick colour='navy'/>  
+                    <grid line_style="dot" colour='navy'/>
+         </vertical_axis>
+         <text id='title' bottom='86%' height='14%' 
+               colour='navy' font_size='0.4'
+               justification='left' />
+         <text id='footer' 
+               colour='navy' font_size='0.4'
+               justification='left' />
+         <efigram id='data' latitude="$latitude" longitude="$longitude"  
+		        efi_legend_colour_list='purplish_red/blue_purple/RGB(0,0.2,1)/RGB(0,0.3,1)/RGB(0,0.4,1)/RGB(0,0.5,1)/RGB(0,0.6,1)/RGB(0,0.7,1)/RGB(0,0.9,1)/RGB(0,1,1)'
+		        efi_root_database='$eps_database' 
+		        efi_clim_root_database='$clim_database' 
+		        efi_clim_date='$clim_date'
+		        efi_dates='$step12h/$step24h/$step36h/$step48h/$step60h/$step72h/$step84h/$step96h/$step108h/$step120h'
+		        efi_steps='12/24/36/48/60/72/84/96/108/120'
+		        efi_legend_root_database='$efi_database'/> 
+			<efigraph id='graph' 
+		        efi_lines_colour_array='purplish_red/blue_purple/RGB(0,0.2,1)/RGB(0,0.3,1)/RGB(0,0.4,1)/RGB(0,0.5,1)/RGB(0,0.6,1)/RGB(0,0.7,1)/RGB(0,0.9,1)/RGB(0,1,1)'
+                efi_lines_style_array='solid/dash/solid/dash/solid/dash/solid/dash/solid/dash' 
+                efi_lines_thickness_array='4/4/4/4/4/4/4/4/4/4/4' 
+            />
+        
+    </definition>
+   <page  height='7%'><nopageid/></page>
+	<page  height='25%'>
+        <nopageid/>
+		<map use_id='box'>
+		    <cartesian>
+		        <x_regular automatic='on'/>
+		        <y_regular y_min='0' y_max='100'/>
+		    </cartesian>  
+		    <horizontal_axis use_id='haxis'/>                    
+		    <vertical_axis use_id='vaxis'/>                                       
+
+		    <text use_id='title'/>
+		
+		    <plot>
+		    <efigram use_id='data' parameter="efi-precip" clim_parameter="clim-precip"
+		        efi_long_title='on'/> 
+			<efigraph use_id='graph' />
+			</plot>
+            <legend use_id='legend' />
+        </map>
+        
+            
+      </page>
+      <page  height='25%'>
+        <nopageid/>
+		<map use_id='box'>
+		    <cartesian>
+		        <x_regular automatic='on'/>
+		        <y_regular y_min='0' y_max='100'/>
+		    </cartesian>  
+		    <horizontal_axis use_id='haxis'/>                    
+		    <vertical_axis use_id='vaxis'/>                                       
+
+		    <text use_id='title'/>
+		
+		    <plot>
+		    <efigram use_id='data' parameter="efi-wind-gust" clim_parameter="clim-wind-gust"
+		        efi_title='on'/> 
+			<efigraph use_id='graph' />
+			</plot> 
+            <legend use_id='legend' />
+        </map>
+       
+            
+      </page> 
+      <page  height='25%'>
+        <nopageid/>
+		<map use_id='box'>
+		    <cartesian>
+		        <x_regular automatic='on'/>
+		        <y_regular y_min='0' y_max='100'/>
+		    </cartesian>  
+		    <horizontal_axis use_id='haxis'/>                    
+		    <vertical_axis use_id='vaxis'/>                                       
+
+		    <text use_id='title'/>
+		
+		    <plot>
+		    <efigram use_id='data' parameter="efi-2mt-mean" clim_parameter="clim-2mt-mean"
+		        efi_title='on'/> 
+			<efigraph use_id='graph' />
+			</plot>
+            <legend use_id='legend' />
+        </map>
+        
+            
+      </page>
+      <page height='15%'>
+	    <pageid line_system_plot='off' line_date_plot='off' line_errors_plot='off' 
+				        font='sansserif' line_colour='Rgb(0.8, 0.8, 0.8)'/>
+       <text use_id='footer' display='absolute' left='50%' height='85%' bottom='15%' width='40%'> 
+       <br/><b>M-Climate</b>: this stands for "Model Climate". It is a  
+       <br/>function of lead time, date (+/- ~15 days), and model 
+       <br/>version. It is derived by rerunning a 5 member
+       <br/>ensemble, over the last 20 years, once a week (500
+       <br/>realisations). M-Climate is always from the same 
+       <br/>model version as the displayed EPS data. On this
+       <br/>page only the 24-48h lead M-Climate is displayed.
+	   </text>
+							 
+	  <text display='absolute' height='25%' colour='navy' font_size='0.4' justification='left'
+	   		left='17%'  width='40%' bottom='52%'> 24-48h M-Climate extrema</text>
+	  <text display='absolute' height='25%' border='on' border_colour='navy' width='6%' left='10%' bottom='47%' colour='navy' font_size='0.4' justification='left' > Max: <br/> Min: </text>
+	   </page>
+    </magics>  
+
+
diff --git a/config/README b/config/README
new file mode 100644
index 0000000..12bf2c6
--- /dev/null
+++ b/config/README
@@ -0,0 +1 @@
+This file is necessary for bootstrap to work ;-)
diff --git a/config/config.guess b/config/config.guess
new file mode 100755
index 0000000..666c5ad
--- /dev/null
+++ b/config/config.guess
@@ -0,0 +1,1511 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-11-20'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <config-patches at gnu.org> and include a ChangeLog
+# entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found ;
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "${UNAME_MACHINE}" in
+    i?86)
+	test -z "$VENDOR" && VENDOR=pc
+	;;
+    *)
+	test -z "$VENDOR" && VENDOR=unknown
+	;;
+esac
+test -f /etc/SuSE-release -o -f /.buildenv && VENDOR=suse
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# NetBSD (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    sh5el) machine=sh5le-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		eval $set_cc_for_build
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep -q __ELF__
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit ;;
+    *:OpenBSD:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+	echo ${UNAME_MACHINE_ARCH}-${VENDOR}-openbsd${UNAME_RELEASE}
+	exit ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-ekkobsd${UNAME_RELEASE}
+	exit ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-${VENDOR}-mirbsd${UNAME_RELEASE}
+	exit ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-mirbsd${UNAME_RELEASE}
+	exit ;;
+    alpha:OSF1:*:*)
+	case $UNAME_RELEASE in
+	*4.0)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-${VENDOR}-sysv4
+	exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-amigaos
+	exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-morphos
+	exit ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+	exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+	echo arm-${VENDOR}-riscos
+	exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7; exit ;;
+	esac ;;
+    s390x:SunOS:*:*)
+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+	echo i386-pc-auroraux${UNAME_RELEASE}
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	eval $set_cc_for_build
+	SUN_ARCH="i386"
+	# If there is a compiler, see if it is configured for 64-bit objects.
+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+	# This test works for both compilers.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		SUN_ARCH="x86_64"
+	    fi
+	fi
+	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-${VENDOR}-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c &&
+	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+	  SYSTEM_NAME=`$dummy $dummyarg` &&
+	    { echo "$SYSTEM_NAME"; exit; }
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+		then
+			echo "$SYSTEM_NAME"
+		else
+			echo rs6000-ibm-aix3.2.5
+		fi
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit ;;
+    *:AIX:*:[456])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
+	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    eval $set_cc_for_build
+
+	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+	    # generating 64-bit code.  GNU and HP use different nomenclature:
+	    #
+	    # $ CC_FOR_BUILD=cc ./config.guess
+	    # => hppa2.0w-hp-hpux11.23
+	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+	    # => hppa64-hp-hpux11.23
+
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+		grep -q __LP64__
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit ;;
+    3050*:HI-UX:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+		{ echo "$SYSTEM_NAME"; exit; }
+	echo unknown-hitachi-hiuxwe2
+	exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-${VENDOR}-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-${VENDOR}-osf1
+	fi
+	exit ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    *:UNICOS/mp:*:*)
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-${VENDOR}-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-bsdi${UNAME_RELEASE}
+	exit ;;
+    *:FreeBSD:*:*)
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    amd64)
+		echo x86_64-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_MACHINE}-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit ;;
+    *:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit ;;
+    i*:windows32*:*)
+    	# uname -m includes "-pc" on this system.
+    	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit ;;
+    *:Interix*:*)
+    	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    authenticamd | genuineintel | EM64T)
+		echo x86_64-${VENDOR}-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-${VENDOR}-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    8664:Windows_NT:*)
+	echo x86_64-pc-mks
+	exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i586-pc-interix
+	exit ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+	echo x86_64-${VENDOR}-cygwin
+	exit ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-${VENDOR}-cygwin
+	exit ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-${VENDOR}-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    *:GNU:*:*)
+	# the GNU system
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-${VENDOR}-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-${VENDOR}-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep -q ld.so.1
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu${LIBC}
+	exit ;;
+    arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	else
+	    echo ${UNAME_MACHINE}-${VENDOR}-linux-gnueabi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-gnu
+	exit ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit ;;
+    frv:Linux:*:*)
+    	echo frv-${VENDOR}-linux-gnu
+	exit ;;
+    i*86:Linux:*:*)
+	LIBC=gnu
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	echo "${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}"
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=${UNAME_MACHINE}el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=${UNAME_MACHINE}
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+	test x"${CPU}" != x && { echo "${CPU}-${VENDOR}-linux-gnu"; exit; }
+	;;
+    or32:Linux:*:*)
+	echo or32-${VENDOR}-linux-gnu
+	exit ;;
+    padre:Linux:*:*)
+	echo sparc-${VENDOR}-linux-gnu
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-${VENDOR}-linux-gnu
+	exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-${VENDOR}-linux-gnu ;;
+	  PA8*) echo hppa2.0-${VENDOR}-linux-gnu ;;
+	  *)    echo hppa-${VENDOR}-linux-gnu ;;
+	esac
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-${VENDOR}-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-${VENDOR}-linux-gnu
+	exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit ;;
+    sh64*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-gnu
+	exit ;;
+    x86_64:Linux:*:*)
+	echo x86_64-${VENDOR}-linux-gnu
+	exit ;;
+    xtensa*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-${VENDOR}-linux-gnu
+	exit ;;
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
+	echo i386-sequent-sysv4
+	exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-${VENDOR}-stop
+	exit ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-atheos
+	exit ;;
+    i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+	echo i386-${VENDOR}-lynxos${UNAME_RELEASE}
+	exit ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit ;;
+    i*86:*:5:[678]*)
+    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit ;;
+    i*86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+	# Note: whatever this is, it MUST be the same as what config.sub
+	# prints for the "djgpp" host, or else GDB configury will decide that
+	# this is a cross-build.
+	echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-${VENDOR}-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit ;;
+    M68*:*:R3V[5678]*:*)
+	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+	OS_REL='.3'
+	test -r /etc/.relid \
+	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-${VENDOR}-lynxos${UNAME_RELEASE}
+	exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-${VENDOR}-lynxos${UNAME_RELEASE}
+	exit ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-${VENDOR}-lynxos${UNAME_RELEASE}
+	exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+	echo powerpc-${VENDOR}-lynxos${UNAME_RELEASE}
+	exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel at ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes at openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit ;;
+    *:*:*:FTX*)
+	# From seanf at swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo hppa1.1-stratus-vos
+	exit ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-${VENDOR}-sysv${UNAME_RELEASE}
+	fi
+        exit ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit ;;
+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
+	echo i586-pc-haiku
+	exit ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit ;;
+    *:Darwin:*:*)
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
+	    i386)
+		eval $set_cc_for_build
+		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		      grep IS_64BIT_ARCH >/dev/null
+		  then
+		      UNAME_PROCESSOR="x86_64"
+		  fi
+		fi ;;
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
+		UNAME_MACHINE=pc
+	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-${VENDOR}-plan9
+	exit ;;
+    *:TOPS-10:*:*)
+	echo pdp10-${VENDOR}-tops10
+	exit ;;
+    *:TENEX:*:*)
+	echo pdp10-${VENDOR}-tenex
+	exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit ;;
+    *:TOPS-20:*:*)
+	echo pdp10-${VENDOR}-tops20
+	exit ;;
+    *:ITS:*:*)
+	echo pdp10-${VENDOR}-its
+	exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-${VENDOR}-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms ; exit ;;
+	    I*) echo ia64-dec-vms ; exit ;;
+	    V*) echo vax-dec-vms ; exit ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit ;;
+    i*86:skyos:*:*)
+	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+	exit ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+    i*86:AROS:*:*)
+	echo ${UNAME_MACHINE}-pc-aros
+	exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit ;;
+    c34*)
+	echo c34-convex-bsd
+	exit ;;
+    c38*)
+	echo c38-convex-bsd
+	exit ;;
+    c4*)
+	echo c4-convex-bsd
+	exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config/config.sub b/config/config.sub
new file mode 100755
index 0000000..2a55a50
--- /dev/null
+++ b/config/config.sub
@@ -0,0 +1,1705 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+#   Free Software Foundation, Inc.
+
+timestamp='2009-11-20'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches at gnu.org>.  Submit a context
+# diff and a properly formatted GNU ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis | -knuth | -cray | -microblaze)
+		os=
+		basic_machine=$1
+		;;
+        -bluegene*)
+	        os=-cnk
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| bfin \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx \
+	| fido | fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| lm32 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep | metag \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64octeon | mips64octeonel \
+	| mips64orion | mips64orionel \
+	| mips64r5900 | mips64r5900el \
+	| mips64vr | mips64vrel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| moxie \
+	| mt \
+	| msp430 \
+	| nios | nios2 \
+	| ns16k | ns32k \
+	| or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| rx \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| ubicom32 \
+	| v850 | v850e \
+	| we32k \
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| z8k | z80)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i*86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* | avr32-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| lm32-* \
+	| m32c-* | m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64octeon-* | mips64octeonel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64r5900-* | mips64r5900el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nios-* | nios2-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* | rx-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+	| tron-* \
+	| ubicom32-* \
+	| v850-* | v850e-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
+	| ymp-* \
+	| z8k-* | z80-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aros)
+		basic_machine=i386-pc
+		os=-aros
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	bluegene*)
+		basic_machine=powerpc-ibm
+		os=-cnk
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+        cegcc)
+		basic_machine=arm-unknown
+		os=-cegcc
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | j90)
+		basic_machine=j90-cray
+		os=-unicos
+		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16)
+		basic_machine=cr16-unknown
+		os=-elf
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	decsystem10* | dec10*)
+		basic_machine=pdp10-dec
+		os=-tops10
+		;;
+	decsystem20* | dec20*)
+		basic_machine=pdp10-dec
+		os=-tops20
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dicos)
+		basic_machine=i686-pc
+		os=-dicos
+		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i*86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i*86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i*86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i*86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+        microblaze)
+		basic_machine=microblaze-xilinx
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	morphos)
+		basic_machine=powerpc-unknown
+		os=-morphos
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	openrisc | openrisc-*)
+		basic_machine=or32-unknown
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium | p5 | k5 | k6 | nexgen | viac3)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2 | pentiumiii | pentium3)
+		basic_machine=i686-pc
+		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium4-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+		;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+		;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64)	basic_machine=powerpc64-unknown
+		;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+		;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	s390 | s390-*)
+		basic_machine=s390-ibm
+		;;
+	s390x | s390x-*)
+		basic_machine=s390x-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparclite-wrs | simso-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=alphaev5-cray
+		os=-unicos
+		;;
+	t90)
+		basic_machine=t90-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	toad1)
+		basic_machine=pdp10-xkl
+		os=-tops20
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+		basic_machine=f301-fujitsu
+		;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
+	xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	z80-*-coff)
+		basic_machine=z80-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+		basic_machine=sparc-sun
+		;;
+	cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+        -auroraux)
+	        os=-auroraux
+		;;
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+	      | -sym* | -kopensolaris* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* | -aros* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* | -cegcc* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto-qnx*)
+		;;
+	-nto*)
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+        -os400*)
+		os=-os400
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-atheos*)
+		os=-atheos
+		;;
+	-syllable*)
+		os=-syllable
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-nova*)
+		os=-rtmk-nova
+		;;
+	-ns2 )
+		os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+        -tpf*)
+		os=-tpf
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+		os=-mint
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-dicos*)
+		os=-dicos
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
+	# This must come before the *-dec entry.
+	pdp10-*)
+		os=-tops20
+		;;
+	pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+        mep-*)
+		os=-elf
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or32-*)
+		os=-coff
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-haiku)
+		os=-haiku
+		;;
+	*-ibm)
+		os=-aix
+		;;
+    	*-knuth)
+		os=-mmixware
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+	*-gould)
+		os=-sysv
+		;;
+	*-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+	*-sgi)
+		os=-irix
+		;;
+	*-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-cnk*|-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-os400*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-tpf*)
+				vendor=ibm
+				;;
+			-vxsim* | -vxworks* | -windiss*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+			-vos*)
+				vendor=stratus
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config/depcomp b/config/depcomp
new file mode 100755
index 0000000..df8eea7
--- /dev/null
+++ b/config/depcomp
@@ -0,0 +1,630 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s,\\\\\\\\,/,g"
+   depmode=msvisualcpp
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am.  Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+  for arg
+  do
+    case $arg in
+    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+    *)  set fnord "$@" "$arg" ;;
+    esac
+    shift # fnord
+    shift # $arg
+  done
+  "$@"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> "$depfile"
+    echo >> "$depfile"
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$base.u
+    tmpdepfile3=$dir.libs/$base.u
+    "$@" -Wc,-M
+  else
+    tmpdepfile1=$dir$base.u
+    tmpdepfile2=$dir$base.u
+    tmpdepfile3=$dir$base.u
+    "$@" -M
+  fi
+  stat=$?
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+    # That's a tab and a space in the [].
+    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp2)
+  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+  # compilers, which have integrated preprocessors.  The correct option
+  # to use with these is +Maked; it writes dependencies to a file named
+  # 'foo.d', which lands next to the object file, wherever that
+  # happens to be.
+  # Much of this is similar to the tru64 case; see comments there.
+  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+  test "x$dir" = "x$object" && dir=
+  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  if test "$libtool" = yes; then
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir.libs/$base.d
+    "$@" -Wc,+Maked
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    "$@" +Maked
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+     rm -f "$tmpdepfile1" "$tmpdepfile2"
+     exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  if test -f "$tmpdepfile"; then
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
+    sed -ne '2,${
+	       s/^ *//
+	       s/ \\*$//
+	       s/$/:/
+	       p
+	     }' "$tmpdepfile" >> "$depfile"
+  else
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile" "$tmpdepfile2"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mechanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no eat=no
+  for arg
+  do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+	set fnord "$@"
+	shift
+	shift
+	;;
+    *)
+	set fnord "$@" "$arg"
+	shift
+	shift
+	;;
+    esac
+  done
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  echo "	" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/config/install-sh b/config/install-sh
new file mode 100755
index 0000000..6781b98
--- /dev/null
+++ b/config/install-sh
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" ""	$nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
+
+  -c            (ignored)
+  -C            install only if different (preserve the last data modification time)
+  -d            create directories instead of installing files.
+  -g GROUP      $chgrpprog installed files to GROUP.
+  -m MODE       $chmodprog installed files to MODE.
+  -o USER       $chownprog installed files to USER.
+  -s            $stripprog installed files.
+  -t DIRECTORY  install into DIRECTORY.
+  -T            report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
+
+    -C) copy_on_change=true;;
+
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+	shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
+
+    -o) chowncmd="$chownprog $2"
+	shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+	shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)	shift
+	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
+  esac
+  shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+  # When -d is used, all remaining arguments are directories to create.
+  # When -t is used, the destination is already specified.
+  # Otherwise, the last argument is the destination.  Remove it from $@.
+  for arg
+  do
+    if test -n "$dst_arg"; then
+      # $@ is not empty: it contains at least $arg.
+      set fnord "$@" "$dst_arg"
+      shift # fnord
+    fi
+    shift # arg
+    dst_arg=$arg
+  done
+fi
+
+if test $# -eq 0; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+if test -z "$dir_arg"; then
+  trap '(exit $?); exit' 1 2 13 15
+
+  # Set umask so as not to create temps with too-generous modes.
+  # However, 'strip' requires both read and write access to temps.
+  case $mode in
+    # Optimize common cases.
+    *644) cp_umask=133;;
+    *755) cp_umask=22;;
+
+    *[0-7])
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw='% 200'
+      fi
+      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+    *)
+      if test -z "$stripcmd"; then
+	u_plus_rw=
+      else
+	u_plus_rw=,u+rw
+      fi
+      cp_umask=$mode$u_plus_rw;;
+  esac
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    dstdir=$dst
+    test -d "$dstdir"
+    dstdir_status=$?
+  else
+
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dst_arg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dst_arg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+	echo "$0: $dst_arg: Is a directory" >&2
+	exit 1
+      fi
+      dstdir=$dst
+      dst=$dstdir/`basename "$src"`
+      dstdir_status=0
+    else
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
+      test -d "$dstdir"
+      dstdir_status=$?
+    fi
+  fi
+
+  obsolete_mkdir_used=false
+
+  if test $dstdir_status != 0; then
+    case $posix_mkdir in
+      '')
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
+
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
+
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      if test -z "$dir_arg" || {
+		   # Check for POSIX incompatibilities with -m.
+		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+		   # other-writeable bit of parent directory when it shouldn't.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
+    esac
+
+    if
+      $posix_mkdir && (
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+      )
+    then :
+    else
+
+      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # or it failed possibly due to a race condition.  Create the
+      # directory the slow way, step by step, checking for races as we go.
+
+      case $dstdir in
+	/*) prefix='/';;
+	-*) prefix='./';;
+	*)  prefix='';;
+      esac
+
+      eval "$initialize_posix_glob"
+
+      oIFS=$IFS
+      IFS=/
+      $posix_glob set -f
+      set fnord $dstdir
+      shift
+      $posix_glob set +f
+      IFS=$oIFS
+
+      prefixes=
+
+      for d
+      do
+	test -z "$d" && continue
+
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
+      done
+
+      if test -n "$prefixes"; then
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
+      fi
+    fi
+  fi
+
+  if test -n "$dir_arg"; then
+    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+  else
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+    # Copy the file name to the temp name.
+    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+    # If -C, don't bother to copy if it wouldn't change the file.
+    if $copy_on_change &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
+       set X $old && old=:$2:$4:$5:$6 &&
+       set X $new && new=:$2:$4:$5:$6 &&
+       $posix_glob set +f &&
+
+       test "$old" = "$new" &&
+       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+    then
+      rm -f "$dsttmp"
+    else
+      # Rename the file to the real destination.
+      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+      # The rename failed, perhaps because mv can't rename something else
+      # to itself, or perhaps because mv is so ancient that it does not
+      # support -f.
+      {
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
+
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
+      }
+    fi || exit 1
+
+    trap '' 0
+  fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/config/ltmain.sh b/config/ltmain.sh
new file mode 100755
index 0000000..a72f2fd
--- /dev/null
+++ b/config/ltmain.sh
@@ -0,0 +1,8406 @@
+# Generated from ltmain.m4sh.
+
+# ltmain.sh (GNU libtool) 2.2.6b
+# Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions.  There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+#     --config             show all configuration variables
+#     --debug              enable verbose shell tracing
+# -n, --dry-run            display commands without modifying any files
+#     --features           display basic configuration information and exit
+#     --mode=MODE          use operation mode MODE
+#     --preserve-dup-deps  don't remove duplicate dependency libraries
+#     --quiet, --silent    don't print informational messages
+#     --tag=TAG            use configuration variables from tag TAG
+# -v, --verbose            print informational messages (default)
+#     --version            print version information
+# -h, --help               print short or long help message
+#
+# MODE must be one of the following:
+#
+#       clean              remove files from the build directory
+#       compile            compile a source file into a libtool object
+#       execute            automatically set library path, then run a program
+#       finish             complete the installation of libtool libraries
+#       install            install libraries or executables
+#       link               create a library or an executable
+#       uninstall          remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+#       host-triplet:	$host
+#       shell:		$SHELL
+#       compiler:		$LTCC
+#       compiler flags:		$LTCFLAGS
+#       linker:		$LD (gnu? $with_gnu_ld)
+#       $progname:		(GNU libtool) 2.2.6b
+#       automake:		$automake_version
+#       autoconf:		$autoconf_version
+#
+# Report bugs to <bug-libtool at gnu.org>.
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=2.2.6b
+TIMESTAMP=""
+package_revision=1.3017
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# NLS nuisances: We save the old values to restore during execute mode.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+	  export $lt_var
+	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+	fi"
+done
+
+$lt_unset CDPATH
+
+
+
+
+
+: ${CP="cp -f"}
+: ${ECHO="echo"}
+: ${EGREP="/bin/grep -E"}
+: ${FGREP="/bin/grep -F"}
+: ${GREP="/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/bin/sed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" 	$lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+# In the unlikely event $progname began with a '-', it would play havoc with
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+  -*) progname=./$progname ;;
+esac
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+  [\\/]*|[A-Za-z]:\\*) ;;
+  *[\\/]*)
+     progdir=$func_dirname_result
+     progdir=`cd "$progdir" && pwd`
+     progpath="$progdir/$progname"
+     ;;
+  *)
+     save_IFS="$IFS"
+     IFS=:
+     for progdir in $PATH; do
+       IFS="$save_IFS"
+       test -x "$progdir/$progname" && break
+     done
+     IFS="$save_IFS"
+     test -n "$progdir" || progdir=`pwd`
+     progpath="$progdir/$progname"
+     ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+  s/$bs4/&\\
+/g
+  s/^$bs2$dollar/$bs&/
+  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+  s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+    $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+    $opt_verbose && func_echo ${1+"$@"}
+
+    # A bug in bash halts the script if the last line of a function
+    # fails when set -e is in force, so we need another command to
+    # work around that:
+    :
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+    # bash bug again:
+    :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+    func_error ${1+"$@"}
+    exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+    func_error ${1+"$@"}
+    func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information."  ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+    $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+    my_directory_path="$1"
+    my_dir_list=
+
+    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+      # Protect directory names starting with `-'
+      case $my_directory_path in
+        -*) my_directory_path="./$my_directory_path" ;;
+      esac
+
+      # While some portion of DIR does not yet exist...
+      while test ! -d "$my_directory_path"; do
+        # ...make a list in topmost first order.  Use a colon delimited
+	# list incase some portion of path contains whitespace.
+        my_dir_list="$my_directory_path:$my_dir_list"
+
+        # If the last portion added has no slash in it, the list is done
+        case $my_directory_path in */*) ;; *) break ;; esac
+
+        # ...otherwise throw away the child directory and loop
+        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
+      done
+      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
+
+      save_mkdir_p_IFS="$IFS"; IFS=':'
+      for my_dir in $my_dir_list; do
+	IFS="$save_mkdir_p_IFS"
+        # mkdir can fail with a `File exist' error if two processes
+        # try to create one of the directories concurrently.  Don't
+        # stop in that case!
+        $MKDIR "$my_dir" 2>/dev/null || :
+      done
+      IFS="$save_mkdir_p_IFS"
+
+      # Bail out if we (or some other process) failed to create a directory.
+      test -d "$my_directory_path" || \
+        func_fatal_error "Failed to create \`$1'"
+    fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$opt_dry_run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+        # Failing that, at least try and use $RANDOM to avoid a race
+        my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+        save_mktempdir_umask=`umask`
+        umask 0077
+        $MKDIR "$my_tmpdir"
+        umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || \
+        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+    fi
+
+    $ECHO "X$my_tmpdir" | $Xsed
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+    case $1 in
+      *[\\\`\"\$]*)
+	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
+      *)
+        func_quote_for_eval_unquoted_result="$1" ;;
+    esac
+
+    case $func_quote_for_eval_unquoted_result in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting, command substitution and and variable
+      # expansion for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+        ;;
+      *)
+        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+    esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+    case $1 in
+      *[\\\`\"]*)
+	my_arg=`$ECHO "X$1" | $Xsed \
+	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+      *)
+        my_arg="$1" ;;
+    esac
+
+    case $my_arg in
+      # Double-quote args containing shell metacharacters to delay
+      # word splitting and command substitution for a subsequent eval.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, so we specify it separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
+        my_arg="\"$my_arg\""
+        ;;
+    esac
+
+    func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$my_cmd"
+      my_status=$?
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
+# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.  Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+    my_cmd="$1"
+    my_fail_exp="${2-:}"
+
+    ${opt_silent-false} || {
+      func_quote_for_expand "$my_cmd"
+      eval "func_echo $func_quote_for_expand_result"
+    }
+
+    if ${opt_dry_run-false}; then :; else
+      eval "$lt_user_locale
+	    $my_cmd"
+      my_status=$?
+      eval "$lt_safe_locale"
+      if test "$my_status" -eq 0; then :; else
+	eval "(exit $my_status); $my_fail_exp"
+      fi
+    fi
+}
+
+
+
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
+        s/^# //
+	s/^# *$//
+        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+        p
+     }' < "$progpath"
+     exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+    $SED -n '/^# Usage:/,/# -h/ {
+        s/^# //
+	s/^# *$//
+	s/\$progname/'$progname'/
+	p
+    }' < "$progpath"
+    $ECHO
+    $ECHO "run \`$progname --help | more' for full usage"
+    exit $?
+}
+
+# func_help
+# Echo long help message to standard output and exit.
+func_help ()
+{
+    $SED -n '/^# Usage:/,/# Report bugs to/ {
+        s/^# //
+	s/^# *$//
+	s*\$progname*'$progname'*
+	s*\$host*'"$host"'*
+	s*\$SHELL*'"$SHELL"'*
+	s*\$LTCC*'"$LTCC"'*
+	s*\$LTCFLAGS*'"$LTCFLAGS"'*
+	s*\$LD*'"$LD"'*
+	s/\$with_gnu_ld/'"$with_gnu_ld"'/
+	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+	p
+     }' < "$progpath"
+    exit $?
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+    func_error "missing argument for $1"
+    exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+# Check that we have a working $ECHO.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell, and then maybe $ECHO will work.
+  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+    func_error ${1+"$@"}
+    func_error "See the $PACKAGE documentation for more information."
+    func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+    re_begincf='^# ### BEGIN LIBTOOL'
+    re_endcf='^# ### END LIBTOOL'
+
+    # Default configuration.
+    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+    done
+
+    exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+    $ECHO "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      $ECHO "enable shared libraries"
+    else
+      $ECHO "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      $ECHO "enable static libraries"
+    else
+      $ECHO "disable static libraries"
+    fi
+
+    exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+  # Global variable:
+  tagname="$1"
+
+  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+  sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+  # Validate tagname.
+  case $tagname in
+    *[!-_A-Za-z0-9,/]*)
+      func_fatal_error "invalid tag name: $tagname"
+      ;;
+  esac
+
+  # Don't test for the "default" C tag, as we know it's
+  # there but not specially marked.
+  case $tagname in
+    CC) ;;
+    *)
+      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+	taglist="$taglist $tagname"
+
+	# Evaluate the configuration.  Be careful to quote the path
+	# and the sed script, to avoid splitting on whitespace, but
+	# also don't use non-portable quotes within backquotes within
+	# quotes we have to do it in 2 steps:
+	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+	eval "$extractedcf"
+      else
+	func_error "ignoring unknown tag $tagname"
+      fi
+      ;;
+  esac
+}
+
+# Parse options once, thoroughly.  This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+  # Shorthand for --mode=foo, only valid as the first argument
+  case $1 in
+  clean|clea|cle|cl)
+    shift; set dummy --mode clean ${1+"$@"}; shift
+    ;;
+  compile|compil|compi|comp|com|co|c)
+    shift; set dummy --mode compile ${1+"$@"}; shift
+    ;;
+  execute|execut|execu|exec|exe|ex|e)
+    shift; set dummy --mode execute ${1+"$@"}; shift
+    ;;
+  finish|finis|fini|fin|fi|f)
+    shift; set dummy --mode finish ${1+"$@"}; shift
+    ;;
+  install|instal|insta|inst|ins|in|i)
+    shift; set dummy --mode install ${1+"$@"}; shift
+    ;;
+  link|lin|li|l)
+    shift; set dummy --mode link ${1+"$@"}; shift
+    ;;
+  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+    shift; set dummy --mode uninstall ${1+"$@"}; shift
+    ;;
+  esac
+
+  # Parse non-mode specific arguments:
+  while test "$#" -gt 0; do
+    opt="$1"
+    shift
+
+    case $opt in
+      --config)		func_config					;;
+
+      --debug)		preserve_args="$preserve_args $opt"
+			func_echo "enabling shell trace mode"
+			opt_debug='set -x'
+			$opt_debug
+			;;
+
+      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			execute_dlfiles="$execute_dlfiles $1"
+			shift
+			;;
+
+      --dry-run | -n)	opt_dry_run=:					;;
+      --features)       func_features					;;
+      --finish)		mode="finish"					;;
+
+      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			case $1 in
+			  # Valid mode arguments:
+			  clean)	;;
+			  compile)	;;
+			  execute)	;;
+			  finish)	;;
+			  install)	;;
+			  link)		;;
+			  relink)	;;
+			  uninstall)	;;
+
+			  # Catch anything else as an error
+			  *) func_error "invalid argument for $opt"
+			     exit_cmd=exit
+			     break
+			     ;;
+		        esac
+
+			mode="$1"
+			shift
+			;;
+
+      --preserve-dup-deps)
+			opt_duplicate_deps=:				;;
+
+      --quiet|--silent)	preserve_args="$preserve_args $opt"
+			opt_silent=:
+			;;
+
+      --verbose| -v)	preserve_args="$preserve_args $opt"
+			opt_silent=false
+			;;
+
+      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
+			preserve_args="$preserve_args $opt $1"
+			func_enable_tag "$1"	# tagname is set here
+			shift
+			;;
+
+      # Separate optargs to long options:
+      -dlopen=*|--mode=*|--tag=*)
+			func_opt_split "$opt"
+			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+			shift
+			;;
+
+      -\?|-h)		func_usage					;;
+      --help)		opt_help=:					;;
+      --version)	func_version					;;
+
+      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
+
+      *)		nonopt="$opt"
+			break
+			;;
+    esac
+  done
+
+
+  case $host in
+    *cygwin* | *mingw* | *pw32* | *cegcc*)
+      # don't eliminate duplications in $postdeps and $predeps
+      opt_duplicate_compiler_generated_deps=:
+      ;;
+    *)
+      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+      ;;
+  esac
+
+  # Having warned about all mis-specified options, bail out if
+  # anything was wrong.
+  $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+  if test "$package_revision" != "$macro_revision"; then
+    if test "$VERSION" != "$macro_version"; then
+      if test -z "$macro_version"; then
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      else
+        cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+      fi
+    else
+      cat >&2 <<_LT_EOF
+$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+    fi
+
+    exit $EXIT_MISMATCH
+  fi
+}
+
+
+## ----------- ##
+##    Main.    ##
+## ----------- ##
+
+$opt_help || {
+  # Sanity checks first:
+  func_check_version_match
+
+  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+    func_fatal_configuration "not configured to build any kind of library"
+  fi
+
+  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+  # Darwin sucks
+  eval std_shrext=\"$shrext_cmds\"
+
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    func_error "unrecognized option \`-dlopen'"
+    $ECHO "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+    test -f "$1" &&
+      $SED -e 4q "$1" 2>/dev/null \
+        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs.  To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway.  Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+    lalib_p=no
+    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+	for lalib_p_l in 1 2 3 4
+	do
+	    read lalib_p_line
+	    case "$lalib_p_line" in
+		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+	    esac
+	done
+	exec 0<&5 5<&-
+    fi
+    test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+    func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+    func_ltwrapper_exec_suffix=
+    case $1 in
+    *.exe) ;;
+    *) func_ltwrapper_exec_suffix=.exe ;;
+    esac
+    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+    func_ltwrapper_scriptname_result=""
+    if func_ltwrapper_executable_p "$1"; then
+	func_dirname_and_basename "$1" "" "."
+	func_stripname '' '.exe' "$func_basename_result"
+	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+    fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+    $opt_debug
+    save_ifs=$IFS; IFS='~'
+    for cmd in $1; do
+      IFS=$save_ifs
+      eval cmd=\"$cmd\"
+      func_show_eval "$cmd" "${2-:}"
+    done
+    IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)!  Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+    $opt_debug
+    case $1 in
+    */* | *\\*)	. "$1" ;;
+    *)		. "./$1" ;;
+    esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    $opt_debug
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+        func_quote_for_eval "$arg"
+	CC_quoted="$CC_quoted $func_quote_for_eval_result"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+	for z in $available_tags; do
+	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+	    # Evaluate the configuration.
+	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+	    CC_quoted=
+	    for arg in $CC; do
+	      # Double-quote args containing other shell metacharacters.
+	      func_quote_for_eval "$arg"
+	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
+	    done
+	    case "$@ " in
+	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
+	      # The compiler in the base compile command matches
+	      # the one in the tagged configuration.
+	      # Assume this is the tagged configuration we want.
+	      tagname=$z
+	      break
+	      ;;
+	    esac
+	  fi
+	done
+	# If $tagname still isn't set, then no tagged configuration
+	# was found and let the user know that the "--tag" command
+	# line option must be used.
+	if test -z "$tagname"; then
+	  func_echo "unable to infer tagged configuration"
+	  func_fatal_error "specify a tag with \`--tag'"
+#	else
+#	  func_verbose "using $tagname tagged configuration"
+	fi
+	;;
+      esac
+    fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+    write_libobj=${1}
+    if test "$build_libtool_libs" = yes; then
+      write_lobj=\'${2}\'
+    else
+      write_lobj=none
+    fi
+
+    if test "$build_old_libs" = yes; then
+      write_oldobj=\'${3}\'
+    else
+      write_oldobj=none
+    fi
+
+    $opt_dry_run || {
+      cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+      $MV "${write_libobj}T" "${write_libobj}"
+    }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+    $opt_debug
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+    pie_flag=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+	# do not "continue".  Instead, add this to base_compile
+	lastarg="$arg"
+	arg_mode=normal
+	;;
+
+      target )
+	libobj="$arg"
+	arg_mode=normal
+	continue
+	;;
+
+      normal )
+	# Accept any command-line options.
+	case $arg in
+	-o)
+	  test -n "$libobj" && \
+	    func_fatal_error "you cannot specify \`-o' more than once"
+	  arg_mode=target
+	  continue
+	  ;;
+
+	-pie | -fpie | -fPIE)
+          pie_flag="$pie_flag $arg"
+	  continue
+	  ;;
+
+	-shared | -static | -prefer-pic | -prefer-non-pic)
+	  later="$later $arg"
+	  continue
+	  ;;
+
+	-no-suppress)
+	  suppress_opt=no
+	  continue
+	  ;;
+
+	-Xcompiler)
+	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
+	  continue      #  The current "srcfile" will either be retained or
+	  ;;            #  replaced later.  I would guess that would be a bug.
+
+	-Wc,*)
+	  func_stripname '-Wc,' '' "$arg"
+	  args=$func_stripname_result
+	  lastarg=
+	  save_ifs="$IFS"; IFS=','
+	  for arg in $args; do
+	    IFS="$save_ifs"
+	    func_quote_for_eval "$arg"
+	    lastarg="$lastarg $func_quote_for_eval_result"
+	  done
+	  IFS="$save_ifs"
+	  func_stripname ' ' '' "$lastarg"
+	  lastarg=$func_stripname_result
+
+	  # Add the arguments to base_compile.
+	  base_compile="$base_compile $lastarg"
+	  continue
+	  ;;
+
+	*)
+	  # Accept the current argument as the source file.
+	  # The previous "srcfile" becomes the current argument.
+	  #
+	  lastarg="$srcfile"
+	  srcfile="$arg"
+	  ;;
+	esac  #  case $arg
+	;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      func_quote_for_eval "$lastarg"
+      base_compile="$base_compile $func_quote_for_eval_result"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      func_fatal_error "you must specify an argument for -Xcompile"
+      ;;
+    target)
+      func_fatal_error "you must specify a target with \`-o'"
+      ;;
+    *)
+      # Get the name of the library object.
+      test -z "$libobj" && {
+	func_basename "$srcfile"
+	libobj="$func_basename_result"
+      }
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    case $libobj in
+    *.[cCFSifmso] | \
+    *.ada | *.adb | *.ads | *.asm | \
+    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
+      func_xform "$libobj"
+      libobj=$func_xform_result
+      ;;
+    esac
+
+    case $libobj in
+    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+    *)
+      func_fatal_error "cannot determine name of library object from \`$libobj'"
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	continue
+	;;
+
+      -static)
+	build_libtool_libs=no
+	build_old_libs=yes
+	continue
+	;;
+
+      -prefer-pic)
+	pic_mode=yes
+	continue
+	;;
+
+      -prefer-non-pic)
+	pic_mode=no
+	continue
+	;;
+      esac
+    done
+
+    func_quote_for_eval "$libobj"
+    test "X$libobj" != "X$func_quote_for_eval_result" \
+      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
+      && func_warning "libobj name \`$libobj' may not contain shell special characters."
+    func_dirname_and_basename "$obj" "/" ""
+    objname="$func_basename_result"
+    xdir="$func_dirname_result"
+    lobj=${xdir}$objdir/$objname
+
+    test -z "$base_compile" && \
+      func_fatal_help "you must specify a compilation command"
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2* | cegcc*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+	func_echo "Waiting for $lockfile to be removed"
+	sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+	$ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+      removelist="$removelist $output_obj"
+      $ECHO "$srcfile" > "$lockfile"
+    fi
+
+    $opt_dry_run || $RM $removelist
+    removelist="$removelist $lockfile"
+    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    func_quote_for_eval "$srcfile"
+    qsrcfile=$func_quote_for_eval_result
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+	command="$base_compile $qsrcfile $pic_flag"
+      else
+	# Don't build PIC code
+	command="$base_compile $qsrcfile"
+      fi
+
+      func_mkdir_p "$xdir$objdir"
+
+      if test -z "$output_obj"; then
+	# Place PIC objects in $objdir
+	command="$command -o $lobj"
+      fi
+
+      func_show_eval_locale "$command"	\
+          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+	func_show_eval '$MV "$output_obj" "$lobj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+	suppress_output=' >/dev/null 2>&1'
+      fi
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+	# Don't build PIC code
+	command="$base_compile $qsrcfile$pie_flag"
+      else
+	command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      func_show_eval_locale "$command" \
+        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+      if test "$need_locks" = warn &&
+	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+	$ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$opt_dry_run || $RM $removelist
+	exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+	func_show_eval '$MV "$output_obj" "$obj"' \
+	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+      fi
+    fi
+
+    $opt_dry_run || {
+      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+      # Unlock the critical section if it was locked
+      if test "$need_locks" != no; then
+	removelist=$lockfile
+        $RM "$lockfile"
+      fi
+    }
+
+    exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+    # We need to display help for each of the modes.
+    case $mode in
+      "")
+        # Generic help is extracted from the usage comments
+        # at the start of this file.
+        func_help
+        ;;
+
+      clean)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      compile)
+      $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -no-suppress      do not suppress compiler output for multiple passes
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -shared           do not build a \`.o' file suitable for static linking
+  -static           only build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+        ;;
+
+      execute)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+        ;;
+
+      finish)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+        ;;
+
+      install)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+        ;;
+
+      link)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -shared           only do dynamic linking of libtool libraries
+  -shrext SUFFIX    override the standard shared library file extension
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                    specify library version info [each variable defaults to 0]
+  -weak LIBNAME     declare that the target provides the LIBNAME interface
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+        ;;
+
+      uninstall)
+        $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+        ;;
+
+      *)
+        func_fatal_help "invalid operation mode \`$mode'"
+        ;;
+    esac
+
+    $ECHO
+    $ECHO "Try \`$progname --help' for more information about other modes."
+
+    exit $?
+}
+
+  # Now that we've collected a possible --mode arg, show help if necessary
+  $opt_help && func_mode_help
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+    $opt_debug
+    # The first argument is the command name.
+    cmd="$nonopt"
+    test -z "$cmd" && \
+      func_fatal_help "you must specify a COMMAND"
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      test -f "$file" \
+	|| func_fatal_help "\`$file' is not a file"
+
+      dir=
+      case $file in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+	# Read the libtool library.
+	dlname=
+	library_names=
+	func_source "$file"
+
+	# Skip this library if it cannot be dlopened.
+	if test -z "$dlname"; then
+	  # Warn if it was a shared library.
+	  test -n "$library_names" && \
+	    func_warning "\`$file' was not linked with \`-export-dynamic'"
+	  continue
+	fi
+
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+
+	if test -f "$dir/$objdir/$dlname"; then
+	  dir="$dir/$objdir"
+	else
+	  if test ! -f "$dir/$dlname"; then
+	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+	  fi
+	fi
+	;;
+
+      *.lo)
+	# Just add the directory containing the .lo file.
+	func_dirname "$file" "" "."
+	dir="$func_dirname_result"
+	;;
+
+      *)
+	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+	continue
+	;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+	eval "$shlibpath_var=\"\$dir\""
+      else
+	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+	# Do a test to see if this is really a libtool program.
+	if func_ltwrapper_script_p "$file"; then
+	  func_source "$file"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	elif func_ltwrapper_executable_p "$file"; then
+	  func_ltwrapper_scriptname "$file"
+	  func_source "$func_ltwrapper_scriptname_result"
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	fi
+	;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      func_quote_for_eval "$file"
+      args="$args $func_quote_for_eval_result"
+    done
+
+    if test "X$opt_dry_run" = Xfalse; then
+      if test -n "$shlibpath_var"; then
+	# Export the shlibpath_var.
+	eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+	eval "if test \"\${save_$lt_var+set}\" = set; then
+                $lt_var=\$save_$lt_var; export $lt_var
+	      else
+		$lt_unset $lt_var
+	      fi"
+      done
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+	$ECHO "export $shlibpath_var"
+      fi
+      $ECHO "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+    $opt_debug
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+	libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+	if test -n "$finish_cmds"; then
+	  # Do each command in the finish commands.
+	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+	fi
+	if test -n "$finish_eval"; then
+	  # Do the single finish_eval.
+	  eval cmds=\"$finish_eval\"
+	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+       $cmds"
+	fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    $opt_silent && exit $EXIT_SUCCESS
+
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    $ECHO "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $ECHO "   $libdir"
+    done
+    $ECHO
+    $ECHO "If you ever happen to want to link against installed libraries"
+    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
+    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    $ECHO "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      $ECHO "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
+      $ECHO "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $ECHO "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $ECHO "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    $ECHO
+
+    $ECHO "See any operating system documentation about shared libraries for"
+    case $host in
+      solaris2.[6789]|solaris2.1[0-9])
+        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+	$ECHO "pages."
+	;;
+      *)
+        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
+        ;;
+    esac
+    $ECHO "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+    $opt_debug
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
+      # Aesthetically quote it.
+      func_quote_for_eval "$nonopt"
+      install_prog="$func_quote_for_eval_result "
+      arg=$1
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    func_quote_for_eval "$arg"
+    install_prog="$install_prog$func_quote_for_eval_result"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+	files="$files $dest"
+	dest=$arg
+	continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f)
+	case " $install_prog " in
+	*[\\\ /]cp\ *) ;;
+	*) prev=$arg ;;
+	esac
+	;;
+      -g | -m | -o)
+	prev=$arg
+	;;
+      -s)
+	stripme=" -s"
+	continue
+	;;
+      -*)
+	;;
+      *)
+	# If the previous option needed an argument, then skip it.
+	if test -n "$prev"; then
+	  prev=
+	else
+	  dest=$arg
+	  continue
+	fi
+	;;
+      esac
+
+      # Aesthetically quote the argument.
+      func_quote_for_eval "$arg"
+      install_prog="$install_prog $func_quote_for_eval_result"
+    done
+
+    test -z "$install_prog" && \
+      func_fatal_help "you must specify an install program"
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prev' option requires an argument"
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+	func_fatal_help "no file or destination specified"
+      else
+	func_fatal_help "you must specify a destination"
+      fi
+    fi
+
+    # Strip any trailing slash from the destination.
+    func_stripname '' '/' "$dest"
+    dest=$func_stripname_result
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      func_dirname_and_basename "$dest" "" "."
+      destdir="$func_dirname_result"
+      destname="$func_basename_result"
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files; shift
+      test "$#" -gt 1 && \
+	func_fatal_help "\`$dest' is not a directory"
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+	case $file in
+	*.lo) ;;
+	*)
+	  func_fatal_help "\`$destdir' must be an absolute directory name"
+	  ;;
+	esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+	# Do the static libraries later.
+	staticlibs="$staticlibs $file"
+	;;
+
+      *.la)
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$file" \
+	  || func_fatal_help "\`$file' is not a valid libtool archive"
+
+	library_names=
+	old_library=
+	relink_command=
+	func_source "$file"
+
+	# Add the libdir to current_libdirs if it is the destination.
+	if test "X$destdir" = "X$libdir"; then
+	  case "$current_libdirs " in
+	  *" $libdir "*) ;;
+	  *) current_libdirs="$current_libdirs $libdir" ;;
+	  esac
+	else
+	  # Note the libdir as a future libdir.
+	  case "$future_libdirs " in
+	  *" $libdir "*) ;;
+	  *) future_libdirs="$future_libdirs $libdir" ;;
+	  esac
+	fi
+
+	func_dirname "$file" "/" ""
+	dir="$func_dirname_result"
+	dir="$dir$objdir"
+
+	if test -n "$relink_command"; then
+	  # Determine the prefix the user has applied to our future dir.
+	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
+
+	  # Don't allow the user to place us outside of our expected
+	  # location b/c this prevents finding dependent libraries that
+	  # are installed to the same prefix.
+	  # At present, this check doesn't affect windows .dll's that
+	  # are installed into $libdir/../bin (currently, that works fine)
+	  # but it's something to keep an eye on.
+	  test "$inst_prefix_dir" = "$destdir" && \
+	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+	  if test -n "$inst_prefix_dir"; then
+	    # Stick the inst_prefix_dir data into the link command.
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	  else
+	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+	  fi
+
+	  func_warning "relinking \`$file'"
+	  func_show_eval "$relink_command" \
+	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+	fi
+
+	# See the names of the shared library.
+	set dummy $library_names; shift
+	if test -n "$1"; then
+	  realname="$1"
+	  shift
+
+	  srcname="$realname"
+	  test -n "$relink_command" && srcname="$realname"T
+
+	  # Install the shared library and build the symlinks.
+	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+	      'exit $?'
+	  tstripme="$stripme"
+	  case $host_os in
+	  cygwin* | mingw* | pw32* | cegcc*)
+	    case $realname in
+	    *.dll.a)
+	      tstripme=""
+	      ;;
+	    esac
+	    ;;
+	  esac
+	  if test -n "$tstripme" && test -n "$striplib"; then
+	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
+	  fi
+
+	  if test "$#" -gt 0; then
+	    # Delete the old symlinks, and create new ones.
+	    # Try `ln -sf' first, because the `ln' binary might depend on
+	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
+	    # so we also need to try rm && ln -s.
+	    for linkname
+	    do
+	      test "$linkname" != "$realname" \
+		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  func_execute_cmds "$postinstall_cmds" 'exit $?'
+	fi
+
+	# Install the pseudo-library for information purposes.
+	func_basename "$file"
+	name="$func_basename_result"
+	instname="$dir/$name"i
+	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+	# Maybe install the static library, too.
+	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+	;;
+
+      *.lo)
+	# Install (i.e. copy) a libtool object.
+
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Deduce the name of the destination old-style object file.
+	case $destfile in
+	*.lo)
+	  func_lo2o "$destfile"
+	  staticdest=$func_lo2o_result
+	  ;;
+	*.$objext)
+	  staticdest="$destfile"
+	  destfile=
+	  ;;
+	*)
+	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
+	  ;;
+	esac
+
+	# Install the libtool object if requested.
+	test -n "$destfile" && \
+	  func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+	# Install the old object if enabled.
+	if test "$build_old_libs" = yes; then
+	  # Deduce the name of the old-style object file.
+	  func_lo2o "$file"
+	  staticobj=$func_lo2o_result
+	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+	fi
+	exit $EXIT_SUCCESS
+	;;
+
+      *)
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  func_basename "$file"
+	  destfile="$func_basename_result"
+	  destfile="$destdir/$destfile"
+	fi
+
+	# If the file is missing, and there is a .exe on the end, strip it
+	# because it is most likely a libtool script we actually want to
+	# install
+	stripped_ext=""
+	case $file in
+	  *.exe)
+	    if test ! -f "$file"; then
+	      func_stripname '' '.exe' "$file"
+	      file=$func_stripname_result
+	      stripped_ext=".exe"
+	    fi
+	    ;;
+	esac
+
+	# Do a test to see if this is really a libtool program.
+	case $host in
+	*cygwin* | *mingw*)
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      wrapper=$func_ltwrapper_scriptname_result
+	    else
+	      func_stripname '' '.exe' "$file"
+	      wrapper=$func_stripname_result
+	    fi
+	    ;;
+	*)
+	    wrapper=$file
+	    ;;
+	esac
+	if func_ltwrapper_script_p "$wrapper"; then
+	  notinst_deplibs=
+	  relink_command=
+
+	  func_source "$wrapper"
+
+	  # Check the variables that should have been set.
+	  test -z "$generated_by_libtool_version" && \
+	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+	  finalize=yes
+	  for lib in $notinst_deplibs; do
+	    # Check to see that each library is installed.
+	    libdir=
+	    if test -f "$lib"; then
+	      func_source "$lib"
+	    fi
+	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+	    if test -n "$libdir" && test ! -f "$libfile"; then
+	      func_warning "\`$lib' has not been installed in \`$libdir'"
+	      finalize=no
+	    fi
+	  done
+
+	  relink_command=
+	  func_source "$wrapper"
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    $opt_dry_run || {
+	      if test "$finalize" = yes; then
+	        tmpdir=`func_mktempdir`
+		func_basename "$file$stripped_ext"
+		file="$func_basename_result"
+	        outputname="$tmpdir/$file"
+	        # Replace the output file specification.
+	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+	        $opt_silent || {
+	          func_quote_for_expand "$relink_command"
+		  eval "func_echo $func_quote_for_expand_result"
+	        }
+	        if eval "$relink_command"; then :
+	          else
+		  func_error "error: relink \`$file' with the above command before installing it"
+		  $opt_dry_run || ${RM}r "$tmpdir"
+		  continue
+	        fi
+	        file="$outputname"
+	      else
+	        func_warning "cannot relink \`$file'"
+	      fi
+	    }
+	  else
+	    # Install the binary that we compiled earlier.
+	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	# remove .exe since cygwin /usr/bin/install will append another
+	# one anyway
+	case $install_prog,$host in
+	*/usr/bin/install*,*cygwin*)
+	  case $file:$destfile in
+	  *.exe:*.exe)
+	    # this is ok
+	    ;;
+	  *.exe:*)
+	    destfile=$destfile.exe
+	    ;;
+	  *:*.exe)
+	    func_stripname '' '.exe' "$destfile"
+	    destfile=$func_stripname_result
+	    ;;
+	  esac
+	  ;;
+	esac
+	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+	$opt_dry_run || if test -n "$outputname"; then
+	  ${RM}r "$tmpdir"
+	fi
+	;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      func_basename "$file"
+      name="$func_basename_result"
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+	func_show_eval "$old_striplib $oldlib" 'exit $?'
+      fi
+
+      # Do each command in the postinstall commands.
+      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+    done
+
+    test -n "$future_libdirs" && \
+      func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      $opt_dry_run && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+    $opt_debug
+    my_outputname="$1"
+    my_originator="$2"
+    my_pic_p="${3-no}"
+    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+    my_dlsyms=
+
+    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+      if test -n "$NM" && test -n "$global_symbol_pipe"; then
+	my_dlsyms="${my_outputname}S.c"
+      else
+	func_error "not configured to extract global symbols from dlpreopened files"
+      fi
+    fi
+
+    if test -n "$my_dlsyms"; then
+      case $my_dlsyms in
+      "") ;;
+      *.c)
+	# Discover the nlist of each of the dlfiles.
+	nlist="$output_objdir/${my_outputname}.nm"
+
+	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+	# Parse the name list into a source file.
+	func_verbose "creating $output_objdir/$my_dlsyms"
+
+	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+	if test "$dlself" = yes; then
+	  func_verbose "generating symbol list for \`$output'"
+
+	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+	  # Add our own program objects to the symbol list.
+	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	  for progfile in $progfiles; do
+	    func_verbose "extracting global C symbols from \`$progfile'"
+	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+	  done
+
+	  if test -n "$exclude_expsyms"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  if test -n "$export_symbols_regex"; then
+	    $opt_dry_run || {
+	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	    }
+	  fi
+
+	  # Prepare the list of exported symbols
+	  if test -z "$export_symbols"; then
+	    export_symbols="$output_objdir/$outputname.exp"
+	    $opt_dry_run || {
+	      $RM $export_symbols
+	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	      case $host in
+	      *cygwin* | *mingw* | *cegcc* )
+                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+	        ;;
+	      esac
+	    }
+	  else
+	    $opt_dry_run || {
+	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+	      eval '$MV "$nlist"T "$nlist"'
+	      case $host in
+	        *cygwin | *mingw* | *cegcc* )
+	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+	          ;;
+	      esac
+	    }
+	  fi
+	fi
+
+	for dlprefile in $dlprefiles; do
+	  func_verbose "extracting global C symbols from \`$dlprefile'"
+	  func_basename "$dlprefile"
+	  name="$func_basename_result"
+	  $opt_dry_run || {
+	    eval '$ECHO ": $name " >> "$nlist"'
+	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+	  }
+	done
+
+	$opt_dry_run || {
+	  # Make sure we have at least an empty file.
+	  test -f "$nlist" || : > "$nlist"
+
+	  if test -n "$exclude_expsyms"; then
+	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+	    $MV "$nlist"T "$nlist"
+	  fi
+
+	  # Try sorting and uniquifying the output.
+	  if $GREP -v "^: " < "$nlist" |
+	      if sort -k 3 </dev/null >/dev/null 2>&1; then
+		sort -k 3
+	      else
+		sort +2
+	      fi |
+	      uniq > "$nlist"S; then
+	    :
+	  else
+	    $GREP -v "^: " < "$nlist" > "$nlist"S
+	  fi
+
+	  if test -f "$nlist"S; then
+	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+	  else
+	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
+	  fi
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols.  */
+typedef struct {
+  const char *name;
+  void *address;
+} lt_dlsymlist;
+"
+	  case $host in
+	  *cygwin* | *mingw* | *cegcc* )
+	    $ECHO >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs.  */"
+	    lt_dlsym_const= ;;
+	  *osf5*)
+	    echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+	    lt_dlsym_const= ;;
+	  *)
+	    lt_dlsym_const=const ;;
+	  esac
+
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+  { \"$my_originator\", (void *) 0 },"
+
+	  case $need_lib_prefix in
+	  no)
+	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  *)
+	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+	    ;;
+	  esac
+	  $ECHO >> "$output_objdir/$my_dlsyms" "\
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+	} # !$opt_dry_run
+
+	pic_flag_for_symtable=
+	case "$compile_command " in
+	*" -static "*) ;;
+	*)
+	  case $host in
+	  # compiling the symbol table file with pic_flag works around
+	  # a FreeBSD bug that causes programs to crash when -lm is
+	  # linked before any other PIC object.  But we must not use
+	  # pic_flag when linking with -static.  The problem exists in
+	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+	  *-*-hpux*)
+	    pic_flag_for_symtable=" $pic_flag"  ;;
+	  *)
+	    if test "X$my_pic_p" != Xno; then
+	      pic_flag_for_symtable=" $pic_flag"
+	    fi
+	    ;;
+	  esac
+	  ;;
+	esac
+	symtab_cflags=
+	for arg in $LTCFLAGS; do
+	  case $arg in
+	  -pie | -fpie | -fPIE) ;;
+	  *) symtab_cflags="$symtab_cflags $arg" ;;
+	  esac
+	done
+
+	# Now compile the dynamic symbol file.
+	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+	# Clean up the generated files.
+	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+	# Transform the symbol file into the correct name.
+	symfileobj="$output_objdir/${my_outputname}S.$objext"
+	case $host in
+	*cygwin* | *mingw* | *cegcc* )
+	  if test -f "$output_objdir/$my_outputname.def"; then
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+	  else
+	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  fi
+	  ;;
+	*)
+	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+	  ;;
+	esac
+	;;
+      *)
+	func_fatal_error "unknown suffix for \`$my_dlsyms'"
+	;;
+      esac
+    else
+      # We keep going just in case the user didn't refer to
+      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+      # really was required.
+
+      # Nullify the symbol file.
+      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+    fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  $opt_debug
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 |
+	$SED -n -e '
+	    1,100{
+		/ I /{
+		    s,.*,import,
+		    p
+		    q
+		}
+	    }'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    $opt_debug
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+    fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    $opt_debug
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+	*) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      func_basename "$my_xlib"
+      my_xlib="$func_basename_result"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+	*" $my_xlib_u "*)
+	  func_arith $extracted_serial + 1
+	  extracted_serial=$func_arith_result
+	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
+	*) break ;;
+	esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
+
+      func_mkdir_p "$my_xdir"
+
+      case $host in
+      *-darwin*)
+	func_verbose "Extracting $my_xabs"
+	# Do not bother doing anything if just a dry run
+	$opt_dry_run || {
+	  darwin_orig_dir=`pwd`
+	  cd $my_xdir || exit $?
+	  darwin_archive=$my_xabs
+	  darwin_curdir=`pwd`
+	  darwin_base_archive=`basename "$darwin_archive"`
+	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+	  if test -n "$darwin_arches"; then
+	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+	    darwin_arch=
+	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+	    for darwin_arch in  $darwin_arches ; do
+	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+	      cd "$darwin_curdir"
+	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+	    done # $darwin_arches
+            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+	    darwin_file=
+	    darwin_files=
+	    for darwin_file in $darwin_filelist; do
+	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+	      $LIPO -create -output "$darwin_file" $darwin_files
+	    done # $darwin_filelist
+	    $RM -rf unfat-$$
+	    cd "$darwin_orig_dir"
+	  else
+	    cd $darwin_orig_dir
+	    func_extract_an_archive "$my_xdir" "$my_xabs"
+	  fi # $darwin_arches
+	} # !$opt_dry_run
+	;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+	;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+
+    func_extract_archives_result="$my_oldobjs"
+}
+
+
+
+# func_emit_wrapper_part1 [arg=no]
+#
+# Emit the first part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part1 ()
+{
+	func_emit_wrapper_part1_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_part1_arg1=$1
+	fi
+
+	$ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    ECHO=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$ECHO works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$ECHO will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+	$ECHO "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+  done
+"
+}
+# end: func_emit_wrapper_part1
+
+# func_emit_wrapper_part2 [arg=no]
+#
+# Emit the second part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part2 ()
+{
+	func_emit_wrapper_part2_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_part2_arg1=$1
+	fi
+
+	$ECHO "\
+
+  # Usually 'no', except on cygwin/mingw when embedded into
+  # the cwrapper.
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
+  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+    # special case for '.'
+    if test \"\$thisdir\" = \".\"; then
+      thisdir=\`pwd\`
+    fi
+    # remove .libs from thisdir
+    case \"\$thisdir\" in
+    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
+    $objdir )   thisdir=. ;;
+    esac
+  fi
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+	if test "$fast_install" = yes; then
+	  $ECHO "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" ||
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $MKDIR \"\$progdir\"
+    else
+      $RM \"\$progdir/\$file\"
+    fi"
+
+	  $ECHO "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+	$ECHO \"\$relink_command_output\" >&2
+	$RM \"\$progdir/\$file\"
+	exit 1
+      fi
+    fi
+
+    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $RM \"\$progdir/\$program\";
+      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $RM \"\$progdir/\$file\"
+  fi"
+	else
+	  $ECHO "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+	fi
+
+	$ECHO "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+	# Export our shlibpath_var if we have one.
+	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	  $ECHO "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+	fi
+
+	# fixup the dll searchpath if we need to.
+	if test -n "$dllsearchpath"; then
+	  $ECHO "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+	fi
+
+	$ECHO "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+	case $host in
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2* | *-cegcc*)
+	  $ECHO "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $ECHO "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$ECHO "\
+      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+}
+# end: func_emit_wrapper_part2
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take.  If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory.  This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+	func_emit_wrapper_arg1=no
+	if test -n "$1" ; then
+	  func_emit_wrapper_arg1=$1
+	fi
+
+	# split this up so that func_emit_cwrapperexe_src
+	# can call each part independently.
+	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
+	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
+}
+
+
+# func_to_host_path arg
+#
+# Convert paths to host format when used with build tools.
+# Intended for use with "native" mingw (where libtool itself
+# is running under the msys shell), or in the following cross-
+# build environments:
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin.  Calling this function does no harm for other
+# $host/$build combinations not listed above.
+#
+# ARG is the path (on $build) that should be converted to
+# the proper representation for $host. The result is stored
+# in $func_to_host_path_result.
+func_to_host_path ()
+{
+  func_to_host_path_result="$1"
+  if test -n "$1" ; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        case $build in
+          *mingw* ) # actually, msys
+            # awkward: cmd appends spaces to result
+            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
+              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_path_tmp1=`cygpath -w "$1"`
+            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # Unfortunately, winepath does not exit with a non-zero
+            # error code, so we are forced to check the contents of
+            # stdout. On the other hand, if the command is not
+            # found, the shell will set an exit code of 127 and print
+            # *an error message* to stdout. So we must check for both
+            # error code of zero AND non-empty stdout, which explains
+            # the odd construction:
+            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
+            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
+              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+                $SED -e "$lt_sed_naive_backslashify"`
+            else
+              # Allow warning below.
+              func_to_host_path_result=""
+            fi
+            ;;
+        esac
+        if test -z "$func_to_host_path_result" ; then
+          func_error "Could not determine host path corresponding to"
+          func_error "  '$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback:
+          func_to_host_path_result="$1"
+        fi
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_path
+
+# func_to_host_pathlist arg
+#
+# Convert pathlists to host format when used with build tools.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+#    $build          $host
+#    mingw (msys)    mingw  [e.g. native]
+#    cygwin          mingw
+#    *nix + wine     mingw
+#
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
+#
+# ARG is a pathlist (on $build) that should be converted to
+# the proper representation on $host. The result is stored
+# in $func_to_host_pathlist_result.
+func_to_host_pathlist ()
+{
+  func_to_host_pathlist_result="$1"
+  if test -n "$1" ; then
+    case $host in
+      *mingw* )
+        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+        # Remove leading and trailing path separator characters from
+        # ARG. msys behavior is inconsistent here, cygpath turns them
+        # into '.;' and ';.', and winepath ignores them completely.
+        func_to_host_pathlist_tmp2="$1"
+        # Once set for this call, this variable should not be
+        # reassigned. It is used in tha fallback case.
+        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
+          $SED -e 's|^:*||' -e 's|:*$||'`
+        case $build in
+          *mingw* ) # Actually, msys.
+            # Awkward: cmd appends spaces to result.
+            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
+              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          *cygwin* )
+            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
+            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+              $SED -e "$lt_sed_naive_backslashify"`
+            ;;
+          * )
+            # unfortunately, winepath doesn't convert pathlists
+            func_to_host_pathlist_result=""
+            func_to_host_pathlist_oldIFS=$IFS
+            IFS=:
+            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
+              IFS=$func_to_host_pathlist_oldIFS
+              if test -n "$func_to_host_pathlist_f" ; then
+                func_to_host_path "$func_to_host_pathlist_f"
+                if test -n "$func_to_host_path_result" ; then
+                  if test -z "$func_to_host_pathlist_result" ; then
+                    func_to_host_pathlist_result="$func_to_host_path_result"
+                  else
+                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
+                  fi
+                fi
+              fi
+              IFS=:
+            done
+            IFS=$func_to_host_pathlist_oldIFS
+            ;;
+        esac
+        if test -z "$func_to_host_pathlist_result" ; then
+          func_error "Could not determine the host path(s) corresponding to"
+          func_error "  '$1'"
+          func_error "Continuing, but uninstalled executables may not work."
+          # Fallback. This may break if $1 contains DOS-style drive
+          # specifications. The fix is not to complicate the expression
+          # below, but for the user to provide a working wine installation
+          # with winepath so that path translation in the cross-to-mingw
+          # case works properly.
+          lt_replace_pathsep_nix_to_dos="s|:|;|g"
+          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
+            $SED -e "$lt_replace_pathsep_nix_to_dos"`
+        fi
+        # Now, add the leading and trailing path separators back
+        case "$1" in
+          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
+            ;;
+        esac
+        case "$1" in
+          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
+            ;;
+        esac
+        ;;
+    esac
+  fi
+}
+# end: func_to_host_pathlist
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+	cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "$SHELL $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+	    cat <<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+# define setmode _setmode
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+#  include <io.h>
+#  define HAVE_SETENV
+#  ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+#  endif
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+#ifdef _MSC_VER
+# define S_IXUSR _S_IEXEC
+# define stat _stat
+# ifndef _INTPTR_T_DEFINED
+#  define intptr_t int
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifdef __CYGWIN__
+# define FOPEN_WB "wb"
+#endif
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#undef LTWRAPPER_DEBUGPRINTF
+#if defined DEBUGWRAPPER
+# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
+static void
+ltwrapper_debugprintf (const char *fmt, ...)
+{
+    va_list args;
+    va_start (args, fmt);
+    (void) vfprintf (stderr, fmt, args);
+    va_end (args);
+}
+#else
+# define LTWRAPPER_DEBUGPRINTF(args)
+#endif
+
+const char *program_name = NULL;
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_opt_process_env_set (const char *arg);
+void lt_opt_process_env_prepend (const char *arg);
+void lt_opt_process_env_append (const char *arg);
+int lt_split_name_value (const char *arg, char** name, char** value);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+
+static const char *script_text_part1 =
+EOF
+
+	    func_emit_wrapper_part1 yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+	    cat <<EOF
+
+static const char *script_text_part2 =
+EOF
+	    func_emit_wrapper_part2 yes |
+	        $SED -e 's/\([\\"]\)/\\\1/g' \
+	             -e 's/^/  "/' -e 's/$/\\n"/'
+	    echo ";"
+
+	    cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+              func_to_host_pathlist "$temp_rpath"
+	      cat <<EOF
+const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+	    else
+	      cat <<"EOF"
+const char * LIB_PATH_VALUE   = "";
+EOF
+	    fi
+
+	    if test -n "$dllsearchpath"; then
+              func_to_host_pathlist "$dllsearchpath:"
+	      cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
+EOF
+	    else
+	      cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE   = "";
+EOF
+	    fi
+
+	    if test "$fast_install" = yes; then
+	      cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+	    else
+	      cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+	    fi
+
+
+	    cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX         "--lt-"
+#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
+
+static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+
+static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
+
+static const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
+static const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
+  /* argument is putenv-style "foo=bar", value of foo is set to bar */
+
+static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
+static const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
+  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
+
+static const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
+static const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
+  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int  newargc;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *actual_cwrapper_name;
+  char *target_name;
+  char *lt_argv_zero;
+  intptr_t rval = 127;
+
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
+  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
+
+  /* very simple arg parsing; don't want to rely on getopt */
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], dumpscript_opt) == 0)
+	{
+EOF
+	    case "$host" in
+	      *mingw* | *cygwin* )
+		# make stdout use "unix" line endings
+		echo "          setmode(1,_O_BINARY);"
+		;;
+	      esac
+
+	    cat <<"EOF"
+	  printf ("%s", script_text_part1);
+	  printf ("%s", script_text_part2);
+	  return 0;
+	}
+    }
+
+  newargz = XMALLOC (char *, argc + 1);
+  tmp_pathspec = find_executable (argv[0]);
+  if (tmp_pathspec == NULL)
+    lt_fatal ("Couldn't find %s", argv[0]);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
+			  tmp_pathspec));
+
+  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
+			  actual_cwrapper_path));
+  XFREE (tmp_pathspec);
+
+  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
+  strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+  /* wrapper name transforms */
+  strendzap (actual_cwrapper_name, ".exe");
+  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+  XFREE (actual_cwrapper_name);
+  actual_cwrapper_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  /* target_name transforms -- use actual target program name; might have lt- prefix */
+  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+  strendzap (target_name, ".exe");
+  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+  XFREE (target_name);
+  target_name = tmp_pathspec;
+  tmp_pathspec = 0;
+
+  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
+			  target_name));
+EOF
+
+	    cat <<EOF
+  newargz[0] =
+    XMALLOC (char, (strlen (actual_cwrapper_path) +
+		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+  strcpy (newargz[0], actual_cwrapper_path);
+  strcat (newargz[0], "$objdir");
+  strcat (newargz[0], "/");
+EOF
+
+	    cat <<"EOF"
+  /* stop here, and copy so we don't have to do this twice */
+  tmp_pathspec = xstrdup (newargz[0]);
+
+  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+  strcat (newargz[0], actual_cwrapper_name);
+
+  /* DO want the lt- prefix here if it exists, so use target_name */
+  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+  XFREE (tmp_pathspec);
+  tmp_pathspec = NULL;
+EOF
+
+	    case $host_os in
+	      mingw*)
+	    cat <<"EOF"
+  {
+    char* p;
+    while ((p = strchr (newargz[0], '\\')) != NULL)
+      {
+	*p = '/';
+      }
+    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+      {
+	*p = '/';
+      }
+  }
+EOF
+	    ;;
+	    esac
+
+	    cat <<"EOF"
+  XFREE (target_name);
+  XFREE (actual_cwrapper_path);
+  XFREE (actual_cwrapper_name);
+
+  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
+  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+
+  newargc=0;
+  for (i = 1; i < argc; i++)
+    {
+      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
+        {
+          if (argv[i][env_set_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_set_opt_len + 1;
+              lt_opt_process_env_set (p);
+            }
+          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_set (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_set_opt);
+          continue;
+        }
+      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
+        {
+          if (argv[i][env_prepend_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_prepend_opt_len + 1;
+              lt_opt_process_env_prepend (p);
+            }
+          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_prepend_opt);
+          continue;
+        }
+      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
+        {
+          if (argv[i][env_append_opt_len] == '=')
+            {
+              const char *p = argv[i] + env_append_opt_len + 1;
+              lt_opt_process_env_append (p);
+            }
+          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
+            {
+              lt_opt_process_env_append (argv[++i]); /* don't copy */
+            }
+          else
+            lt_fatal ("%s missing required argument", env_append_opt);
+          continue;
+        }
+      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
+        {
+          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+             namespace, but it is not one of the ones we know about and
+             have already dealt with, above (inluding dump-script), then
+             report an error. Otherwise, targets might begin to believe
+             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+             namespace. The first time any user complains about this, we'll
+             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+             or a configure.ac-settable value.
+           */
+          lt_fatal ("Unrecognized option in %s namespace: '%s'",
+                    ltwrapper_option_prefix, argv[i]);
+        }
+      /* otherwise ... */
+      newargz[++newargc] = xstrdup (argv[i]);
+    }
+  newargz[++newargc] = NULL;
+
+  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
+  for (i = 0; i < newargc; i++)
+    {
+      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
+    }
+
+EOF
+
+	    case $host_os in
+	      mingw*)
+		cat <<"EOF"
+  /* execv doesn't actually work on mingw as expected on unix */
+  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+  if (rval == -1)
+    {
+      /* failed to start process */
+      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
+      return 127;
+    }
+  return rval;
+EOF
+		;;
+	      *)
+		cat <<"EOF"
+  execv (lt_argv_zero, newargz);
+  return rval; /* =127, but avoids unused variable warning */
+EOF
+		;;
+	    esac
+
+	    cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+  void *p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+			  string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable (const char *path)
+{
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0)
+      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+    return 1;
+  else
+    return 0;
+}
+
+int
+make_executable (const char *path)
+{
+  int rval = 0;
+  struct stat st;
+
+  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
+			  path ? (*path ? path : "EMPTY!") : "NULL!"));
+  if ((!path) || (!*path))
+    return 0;
+
+  if (stat (path, &st) >= 0)
+    {
+      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+    }
+  return rval;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise
+   Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+  int has_slash = 0;
+  const char *p;
+  const char *p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char *concat_name;
+
+  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
+			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable (concat_name))
+	return concat_name;
+      XFREE (concat_name);
+    }
+  else
+    {
+#endif
+      if (IS_DIR_SEPARATOR (wrapper[0]))
+	{
+	  concat_name = xstrdup (wrapper);
+	  if (check_executable (concat_name))
+	    return concat_name;
+	  XFREE (concat_name);
+	}
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+    }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+      {
+	has_slash = 1;
+	break;
+      }
+  if (!has_slash)
+    {
+      /* no slashes; search PATH */
+      const char *path = getenv ("PATH");
+      if (path != NULL)
+	{
+	  for (p = path; *p; p = p_next)
+	    {
+	      const char *q;
+	      size_t p_len;
+	      for (q = p; *q; q++)
+		if (IS_PATH_SEPARATOR (*q))
+		  break;
+	      p_len = q - p;
+	      p_next = (*q == '\0' ? q : q + 1);
+	      if (p_len == 0)
+		{
+		  /* empty path: current directory */
+		  if (getcwd (tmp, LT_PATHMAX) == NULL)
+		    lt_fatal ("getcwd failed");
+		  tmp_len = strlen (tmp);
+		  concat_name =
+		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, tmp, tmp_len);
+		  concat_name[tmp_len] = '/';
+		  strcpy (concat_name + tmp_len + 1, wrapper);
+		}
+	      else
+		{
+		  concat_name =
+		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+		  memcpy (concat_name, p, p_len);
+		  concat_name[p_len] = '/';
+		  strcpy (concat_name + p_len + 1, wrapper);
+		}
+	      if (check_executable (concat_name))
+		return concat_name;
+	      XFREE (concat_name);
+	    }
+	}
+      /* not found in PATH; assume curdir */
+    }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen (tmp);
+  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable (concat_name))
+    return concat_name;
+  XFREE (concat_name);
+  return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+  return xstrdup (pathspec);
+#else
+  char buf[LT_PATHMAX];
+  struct stat s;
+  char *tmp_pathspec = xstrdup (pathspec);
+  char *p;
+  int has_symlinks = 0;
+  while (strlen (tmp_pathspec) && !has_symlinks)
+    {
+      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
+			      tmp_pathspec));
+      if (lstat (tmp_pathspec, &s) == 0)
+	{
+	  if (S_ISLNK (s.st_mode) != 0)
+	    {
+	      has_symlinks = 1;
+	      break;
+	    }
+
+	  /* search backwards for last DIR_SEPARATOR */
+	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    p--;
+	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+	    {
+	      /* no more DIR_SEPARATORS left */
+	      break;
+	    }
+	  *p = '\0';
+	}
+      else
+	{
+	  char *errstr = strerror (errno);
+	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
+	}
+    }
+  XFREE (tmp_pathspec);
+
+  if (!has_symlinks)
+    {
+      return xstrdup (pathspec);
+    }
+
+  tmp_pathspec = realpath (pathspec, buf);
+  if (tmp_pathspec == 0)
+    {
+      lt_fatal ("Could not follow symlinks for %s", pathspec);
+    }
+  return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert (str != NULL);
+  assert (pat != NULL);
+
+  len = strlen (str);
+  patlen = strlen (pat);
+
+  if (patlen <= len)
+    {
+      str += len - patlen;
+      if (strcmp (str, pat) == 0)
+	*str = '\0';
+    }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char *mode,
+	       const char *message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+  {
+#ifdef HAVE_SETENV
+    /* always make a copy, for consistency with !HAVE_SETENV */
+    char *str = xstrdup (value);
+    setenv (name, str, 1);
+#else
+    int len = strlen (name) + 1 + strlen (value) + 1;
+    char *str = XMALLOC (char, len);
+    sprintf (str, "%s=%s", name, value);
+    if (putenv (str) != EXIT_SUCCESS)
+      {
+        XFREE (str);
+      }
+#endif
+  }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+  char *new_value;
+  if (orig_value && *orig_value)
+    {
+      int orig_value_len = strlen (orig_value);
+      int add_len = strlen (add);
+      new_value = XMALLOC (char, add_len + orig_value_len + 1);
+      if (to_end)
+        {
+          strcpy (new_value, orig_value);
+          strcpy (new_value + orig_value_len, add);
+        }
+      else
+        {
+          strcpy (new_value, add);
+          strcpy (new_value + add_len, orig_value);
+        }
+    }
+  else
+    {
+      new_value = xstrdup (add);
+    }
+  return new_value;
+}
+
+int
+lt_split_name_value (const char *arg, char** name, char** value)
+{
+  const char *p;
+  int len;
+  if (!arg || !*arg)
+    return 1;
+
+  p = strchr (arg, (int)'=');
+
+  if (!p)
+    return 1;
+
+  *value = xstrdup (++p);
+
+  len = strlen (arg) - strlen (*value);
+  *name = XMALLOC (char, len);
+  strncpy (*name, arg, len-1);
+  (*name)[len - 1] = '\0';
+
+  return 0;
+}
+
+void
+lt_opt_process_env_set (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
+    }
+
+  lt_setenv (name, value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_opt_process_env_prepend (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+  char *new_value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
+    }
+
+  new_value = lt_extend_str (getenv (name), value, 0);
+  lt_setenv (name, new_value);
+  XFREE (new_value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_opt_process_env_append (const char *arg)
+{
+  char *name = NULL;
+  char *value = NULL;
+  char *new_value = NULL;
+
+  if (lt_split_name_value (arg, &name, &value) != 0)
+    {
+      XFREE (name);
+      XFREE (value);
+      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
+    }
+
+  new_value = lt_extend_str (getenv (name), value, 1);
+  lt_setenv (name, new_value);
+  XFREE (new_value);
+  XFREE (name);
+  XFREE (value);
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      /* some systems can't cope with a ':'-terminated path #' */
+      int len = strlen (new_value);
+      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+        {
+          new_value[len-1] = '\0';
+        }
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+                          (name ? name : "<NULL>"),
+                          (value ? value : "<NULL>")));
+
+  if (name && *name && value && *value)
+    {
+      char *new_value = lt_extend_str (getenv (name), value, 0);
+      lt_setenv (name, new_value);
+      XFREE (new_value);
+    }
+}
+
+
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_mode_link arg...
+func_mode_link ()
+{
+    $opt_debug
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args=$nonopt
+    base_compile="$nonopt $@"
+    compile_command=$nonopt
+    finalize_command=$nonopt
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+    new_inherited_linker_flags=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+    weak_libs=
+    single_module="${wl}-single_module"
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -shared)
+	test "$build_libtool_libs" != yes && \
+	  func_fatal_configuration "can not build a shared library"
+	build_old_libs=no
+	break
+	;;
+      -all-static | -static | -static-libtool-libs)
+	case $arg in
+	-all-static)
+	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	    func_warning "complete static linking is impossible in this configuration"
+	  fi
+	  if test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	-static)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=built
+	  ;;
+	-static-libtool-libs)
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	  prefer_static_libs=yes
+	  ;;
+	esac
+	build_libtool_libs=no
+	build_old_libs=yes
+	break
+	;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      func_quote_for_eval "$arg"
+      qarg=$func_quote_for_eval_unquoted_result
+      func_append libtool_args " $func_quote_for_eval_result"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+	case $prev in
+	output)
+	  func_append compile_command " @OUTPUT@"
+	  func_append finalize_command " @OUTPUT@"
+	  ;;
+	esac
+
+	case $prev in
+	dlfiles|dlprefiles)
+	  if test "$preload" = no; then
+	    # Add the symbol object into the linking commands.
+	    func_append compile_command " @SYMFILE@"
+	    func_append finalize_command " @SYMFILE@"
+	    preload=yes
+	  fi
+	  case $arg in
+	  *.la | *.lo) ;;  # We handle these cases below.
+	  force)
+	    if test "$dlself" = no; then
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  self)
+	    if test "$prev" = dlprefiles; then
+	      dlself=yes
+	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	      dlself=yes
+	    else
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  *)
+	    if test "$prev" = dlfiles; then
+	      dlfiles="$dlfiles $arg"
+	    else
+	      dlprefiles="$dlprefiles $arg"
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  esac
+	  ;;
+	expsyms)
+	  export_symbols="$arg"
+	  test -f "$arg" \
+	    || func_fatal_error "symbol file \`$arg' does not exist"
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	framework)
+	  case $host in
+	    *-*-darwin*)
+	      case "$deplibs " in
+		*" $qarg.ltframework "*) ;;
+		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+		   ;;
+	      esac
+	      ;;
+	  esac
+	  prev=
+	  continue
+	  ;;
+	inst_prefix)
+	  inst_prefix_dir="$arg"
+	  prev=
+	  continue
+	  ;;
+	objectlist)
+	  if test -f "$arg"; then
+	    save_arg=$arg
+	    moreargs=
+	    for fil in `cat "$save_arg"`
+	    do
+#	      moreargs="$moreargs $fil"
+	      arg=$fil
+	      # A libtool-controlled object.
+
+	      # Check to see that this really is a libtool object.
+	      if func_lalib_unsafe_p "$arg"; then
+		pic_object=
+		non_pic_object=
+
+		# Read the .lo file
+		func_source "$arg"
+
+		if test -z "$pic_object" ||
+		   test -z "$non_pic_object" ||
+		   test "$pic_object" = none &&
+		   test "$non_pic_object" = none; then
+		  func_fatal_error "cannot find name of object for \`$arg'"
+		fi
+
+		# Extract subdirectory from the argument.
+		func_dirname "$arg" "/" ""
+		xdir="$func_dirname_result"
+
+		if test "$pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  pic_object="$xdir$pic_object"
+
+		  if test "$prev" = dlfiles; then
+		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		      dlfiles="$dlfiles $pic_object"
+		      prev=
+		      continue
+		    else
+		      # If libtool objects are unsupported, then we need to preload.
+		      prev=dlprefiles
+		    fi
+		  fi
+
+		  # CHECK ME:  I think I busted this.  -Ossama
+		  if test "$prev" = dlprefiles; then
+		    # Preload the old-style object.
+		    dlprefiles="$dlprefiles $pic_object"
+		    prev=
+		  fi
+
+		  # A PIC object.
+		  func_append libobjs " $pic_object"
+		  arg="$pic_object"
+		fi
+
+		# Non-PIC object.
+		if test "$non_pic_object" != none; then
+		  # Prepend the subdirectory the object is found in.
+		  non_pic_object="$xdir$non_pic_object"
+
+		  # A standard non-PIC object
+		  func_append non_pic_objects " $non_pic_object"
+		  if test -z "$pic_object" || test "$pic_object" = none ; then
+		    arg="$non_pic_object"
+		  fi
+		else
+		  # If the PIC object exists, use it instead.
+		  # $xdir was prepended to $pic_object above.
+		  non_pic_object="$pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+		fi
+	      else
+		# Only an error if not doing a dry-run.
+		if $opt_dry_run; then
+		  # Extract subdirectory from the argument.
+		  func_dirname "$arg" "/" ""
+		  xdir="$func_dirname_result"
+
+		  func_lo2o "$arg"
+		  pic_object=$xdir$objdir/$func_lo2o_result
+		  non_pic_object=$xdir$func_lo2o_result
+		  func_append libobjs " $pic_object"
+		  func_append non_pic_objects " $non_pic_object"
+	        else
+		  func_fatal_error "\`$arg' is not a valid libtool object"
+		fi
+	      fi
+	    done
+	  else
+	    func_fatal_error "link input file \`$arg' does not exist"
+	  fi
+	  arg=$save_arg
+	  prev=
+	  continue
+	  ;;
+	precious_regex)
+	  precious_files_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	rpath | xrpath)
+	  # We need an absolute path.
+	  case $arg in
+	  [\\/]* | [A-Za-z]:[\\/]*) ;;
+	  *)
+	    func_fatal_error "only absolute run-paths are allowed"
+	    ;;
+	  esac
+	  if test "$prev" = rpath; then
+	    case "$rpath " in
+	    *" $arg "*) ;;
+	    *) rpath="$rpath $arg" ;;
+	    esac
+	  else
+	    case "$xrpath " in
+	    *" $arg "*) ;;
+	    *) xrpath="$xrpath $arg" ;;
+	    esac
+	  fi
+	  prev=
+	  continue
+	  ;;
+	shrext)
+	  shrext_cmds="$arg"
+	  prev=
+	  continue
+	  ;;
+	weak)
+	  weak_libs="$weak_libs $arg"
+	  prev=
+	  continue
+	  ;;
+	xcclinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xcompiler)
+	  compiler_flags="$compiler_flags $qarg"
+	  prev=
+	  func_append compile_command " $qarg"
+	  func_append finalize_command " $qarg"
+	  continue
+	  ;;
+	xlinker)
+	  linker_flags="$linker_flags $qarg"
+	  compiler_flags="$compiler_flags $wl$qarg"
+	  prev=
+	  func_append compile_command " $wl$qarg"
+	  func_append finalize_command " $wl$qarg"
+	  continue
+	  ;;
+	*)
+	  eval "$prev=\"\$arg\""
+	  prev=
+	  continue
+	  ;;
+	esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+	if test -n "$link_static_flag"; then
+	  # See comment for -static flag below, for more details.
+	  func_append compile_command " $link_static_flag"
+	  func_append finalize_command " $link_static_flag"
+	fi
+	continue
+	;;
+
+      -allow-undefined)
+	# FIXME: remove this flag sometime in the future.
+	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+	;;
+
+      -avoid-version)
+	avoid_version=yes
+	continue
+	;;
+
+      -dlopen)
+	prev=dlfiles
+	continue
+	;;
+
+      -dlpreopen)
+	prev=dlprefiles
+	continue
+	;;
+
+      -export-dynamic)
+	export_dynamic=yes
+	continue
+	;;
+
+      -export-symbols | -export-symbols-regex)
+	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	  func_fatal_error "more than one -exported-symbols argument is not allowed"
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -framework)
+	prev=framework
+	continue
+	;;
+
+      -inst-prefix-dir)
+	prev=inst_prefix
+	continue
+	;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+	case $with_gcc/$host in
+	no/*-*-irix* | /*-*-irix*)
+	  func_append compile_command " $arg"
+	  func_append finalize_command " $arg"
+	  ;;
+	esac
+	continue
+	;;
+
+      -L*)
+	func_stripname '-L' '' "$arg"
+	dir=$func_stripname_result
+	if test -z "$dir"; then
+	  if test "$#" -gt 0; then
+	    func_fatal_error "require no space between \`-L' and \`$1'"
+	  else
+	    func_fatal_error "need path for \`-L' option"
+	  fi
+	fi
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  absdir=`cd "$dir" && pwd`
+	  test -z "$absdir" && \
+	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
+	  dir="$absdir"
+	  ;;
+	esac
+	case "$deplibs " in
+	*" -L$dir "*) ;;
+	*)
+	  deplibs="$deplibs -L$dir"
+	  lib_search_path="$lib_search_path $dir"
+	  ;;
+	esac
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$dir:"*) ;;
+	  ::) dllsearchpath=$dir;;
+	  *) dllsearchpath="$dllsearchpath:$dir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  ::) dllsearchpath=$testbindir;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+	continue
+	;;
+
+      -l*)
+	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
+	    # These systems don't actually have a C or math library (as such)
+	    continue
+	    ;;
+	  *-*-os2*)
+	    # These systems don't actually have a C library (as such)
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C and math libraries are in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    continue
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    test "X$arg" = "X-lc" && continue
+	    ;;
+	  esac
+	elif test "X$arg" = "X-lc_r"; then
+	 case $host in
+	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	   # Do not include libc_r directly, use -pthread flag.
+	   continue
+	   ;;
+	 esac
+	fi
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      # Darwin uses the -arch flag to determine output architecture.
+      -model|-arch|-isysroot)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	prev=xcompiler
+	continue
+	;;
+
+      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	compiler_flags="$compiler_flags $arg"
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+	case "$new_inherited_linker_flags " in
+	    *" $arg "*) ;;
+	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+	esac
+	continue
+	;;
+
+      -multi_module)
+	single_module="${wl}-multi_module"
+	continue
+	;;
+
+      -no-fast-install)
+	fast_install=no
+	continue
+	;;
+
+      -no-install)
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+	  # The PATH hackery in wrapper scripts is required on Windows
+	  # and Darwin in order for the loader to find any dlls it needs.
+	  func_warning "\`-no-install' is ignored for $host"
+	  func_warning "assuming \`-no-fast-install' instead"
+	  fast_install=no
+	  ;;
+	*) no_install=yes ;;
+	esac
+	continue
+	;;
+
+      -no-undefined)
+	allow_undefined=no
+	continue
+	;;
+
+      -objectlist)
+	prev=objectlist
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+	prev=precious_regex
+	continue
+	;;
+
+      -release)
+	prev=release
+	continue
+	;;
+
+      -rpath)
+	prev=rpath
+	continue
+	;;
+
+      -R)
+	prev=xrpath
+	continue
+	;;
+
+      -R*)
+	func_stripname '-R' '' "$arg"
+	dir=$func_stripname_result
+	# We need an absolute path.
+	case $dir in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  func_fatal_error "only absolute run-paths are allowed"
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -shared)
+	# The effects of -shared are defined in a previous loop.
+	continue
+	;;
+
+      -shrext)
+	prev=shrext
+	continue
+	;;
+
+      -static | -static-libtool-libs)
+	# The effects of -static are defined in a previous loop.
+	# We used to do the same as -all-static on platforms that
+	# didn't have a PIC flag, but the assumption that the effects
+	# would be equivalent was wrong.  It would break on at least
+	# Digital Unix and AIX.
+	continue
+	;;
+
+      -thread-safe)
+	thread_safe=yes
+	continue
+	;;
+
+      -version-info)
+	prev=vinfo
+	continue
+	;;
+
+      -version-number)
+	prev=vinfo
+	vinfo_number=yes
+	continue
+	;;
+
+      -weak)
+        prev=weak
+	continue
+	;;
+
+      -Wc,*)
+	func_stripname '-Wc,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Wl,*)
+	func_stripname '-Wl,' '' "$arg"
+	args=$func_stripname_result
+	arg=
+	save_ifs="$IFS"; IFS=','
+	for flag in $args; do
+	  IFS="$save_ifs"
+          func_quote_for_eval "$flag"
+	  arg="$arg $wl$func_quote_for_eval_result"
+	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+	  linker_flags="$linker_flags $func_quote_for_eval_result"
+	done
+	IFS="$save_ifs"
+	func_stripname ' ' '' "$arg"
+	arg=$func_stripname_result
+	;;
+
+      -Xcompiler)
+	prev=xcompiler
+	continue
+	;;
+
+      -Xlinker)
+	prev=xlinker
+	continue
+	;;
+
+      -XCClinker)
+	prev=xcclinker
+	continue
+	;;
+
+      # -msg_* for osf cc
+      -msg_*)
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -F/path gives path to uninstalled frameworks, gcc on darwin
+      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      # Some other compiler flag.
+      -* | +*)
+        func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+
+      *.$objext)
+	# A standard object.
+	objs="$objs $arg"
+	;;
+
+      *.lo)
+	# A libtool-controlled object.
+
+	# Check to see that this really is a libtool object.
+	if func_lalib_unsafe_p "$arg"; then
+	  pic_object=
+	  non_pic_object=
+
+	  # Read the .lo file
+	  func_source "$arg"
+
+	  if test -z "$pic_object" ||
+	     test -z "$non_pic_object" ||
+	     test "$pic_object" = none &&
+	     test "$non_pic_object" = none; then
+	    func_fatal_error "cannot find name of object for \`$arg'"
+	  fi
+
+	  # Extract subdirectory from the argument.
+	  func_dirname "$arg" "/" ""
+	  xdir="$func_dirname_result"
+
+	  if test "$pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    pic_object="$xdir$pic_object"
+
+	    if test "$prev" = dlfiles; then
+	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+		dlfiles="$dlfiles $pic_object"
+		prev=
+		continue
+	      else
+		# If libtool objects are unsupported, then we need to preload.
+		prev=dlprefiles
+	      fi
+	    fi
+
+	    # CHECK ME:  I think I busted this.  -Ossama
+	    if test "$prev" = dlprefiles; then
+	      # Preload the old-style object.
+	      dlprefiles="$dlprefiles $pic_object"
+	      prev=
+	    fi
+
+	    # A PIC object.
+	    func_append libobjs " $pic_object"
+	    arg="$pic_object"
+	  fi
+
+	  # Non-PIC object.
+	  if test "$non_pic_object" != none; then
+	    # Prepend the subdirectory the object is found in.
+	    non_pic_object="$xdir$non_pic_object"
+
+	    # A standard non-PIC object
+	    func_append non_pic_objects " $non_pic_object"
+	    if test -z "$pic_object" || test "$pic_object" = none ; then
+	      arg="$non_pic_object"
+	    fi
+	  else
+	    # If the PIC object exists, use it instead.
+	    # $xdir was prepended to $pic_object above.
+	    non_pic_object="$pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  fi
+	else
+	  # Only an error if not doing a dry-run.
+	  if $opt_dry_run; then
+	    # Extract subdirectory from the argument.
+	    func_dirname "$arg" "/" ""
+	    xdir="$func_dirname_result"
+
+	    func_lo2o "$arg"
+	    pic_object=$xdir$objdir/$func_lo2o_result
+	    non_pic_object=$xdir$func_lo2o_result
+	    func_append libobjs " $pic_object"
+	    func_append non_pic_objects " $non_pic_object"
+	  else
+	    func_fatal_error "\`$arg' is not a valid libtool object"
+	  fi
+	fi
+	;;
+
+      *.$libext)
+	# An archive.
+	deplibs="$deplibs $arg"
+	old_deplibs="$old_deplibs $arg"
+	continue
+	;;
+
+      *.la)
+	# A libtool-controlled library.
+
+	if test "$prev" = dlfiles; then
+	  # This library was specified with -dlopen.
+	  dlfiles="$dlfiles $arg"
+	  prev=
+	elif test "$prev" = dlprefiles; then
+	  # The library was specified with -dlpreopen.
+	  dlprefiles="$dlprefiles $arg"
+	  prev=
+	else
+	  deplibs="$deplibs $arg"
+	fi
+	continue
+	;;
+
+      # Some other compiler argument.
+      *)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	func_quote_for_eval "$arg"
+	arg="$func_quote_for_eval_result"
+	;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+	func_append compile_command " $arg"
+	func_append finalize_command " $arg"
+      fi
+    done # argument parsing loop
+
+    test -n "$prev" && \
+      func_fatal_help "the \`$prevarg' option requires an argument"
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      func_append compile_command " $arg"
+      func_append finalize_command " $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    func_basename "$output"
+    outputname="$func_basename_result"
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    func_dirname "$output" "/" ""
+    output_objdir="$func_dirname_result$objdir"
+    # Create the object directory.
+    func_mkdir_p "$output_objdir"
+
+    # Determine the type of output
+    case $output in
+    "")
+      func_fatal_help "you must specify an output file"
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if $opt_duplicate_deps ; then
+	case "$libs " in
+	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if $opt_duplicate_compiler_generated_deps; then
+	for pre_post_dep in $predeps $postdeps; do
+	  case "$pre_post_deps " in
+	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+	  esac
+	  pre_post_deps="$pre_post_deps $pre_post_dep"
+	done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    notinst_path= # paths that contain not-installed libtool libraries
+
+    case $linkmode in
+    lib)
+	passes="conv dlpreopen link"
+	for file in $dlfiles $dlprefiles; do
+	  case $file in
+	  *.la) ;;
+	  *)
+	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+	    ;;
+	  esac
+	done
+	;;
+    prog)
+	compile_deplibs=
+	finalize_deplibs=
+	alldeplibs=no
+	newdlfiles=
+	newdlprefiles=
+	passes="conv scan dlopen dlpreopen link"
+	;;
+    *)  passes="conv"
+	;;
+    esac
+
+    for pass in $passes; do
+      # The preopen pass in lib mode reverses $deplibs; put it back here
+      # so that -L comes before libs that need it for instance...
+      if test "$linkmode,$pass" = "lib,link"; then
+	## FIXME: Find the place where the list is rebuilt in the wrong
+	##        order, and fix it there properly
+        tmp_deplibs=
+	for deplib in $deplibs; do
+	  tmp_deplibs="$deplib $tmp_deplibs"
+	done
+	deplibs="$tmp_deplibs"
+      fi
+
+      if test "$linkmode,$pass" = "lib,link" ||
+	 test "$linkmode,$pass" = "prog,scan"; then
+	libs="$deplibs"
+	deplibs=
+      fi
+      if test "$linkmode" = prog; then
+	case $pass in
+	dlopen) libs="$dlfiles" ;;
+	dlpreopen) libs="$dlprefiles" ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+	esac
+      fi
+      if test "$linkmode,$pass" = "lib,dlpreopen"; then
+	# Collect and forward deplibs of preopened libtool libs
+	for lib in $dlprefiles; do
+	  # Ignore non-libtool-libs
+	  dependency_libs=
+	  case $lib in
+	  *.la)	func_source "$lib" ;;
+	  esac
+
+	  # Collect preopened libtool deplibs, except any this library
+	  # has declared as weak libs
+	  for deplib in $dependency_libs; do
+            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
+	    case " $weak_libs " in
+	    *" $deplib_base "*) ;;
+	    *) deplibs="$deplibs $deplib" ;;
+	    esac
+	  done
+	done
+	libs="$dlprefiles"
+      fi
+      if test "$pass" = dlopen; then
+	# Collect dlpreopened libraries
+	save_deplibs="$deplibs"
+	deplibs=
+      fi
+
+      for deplib in $libs; do
+	lib=
+	found=no
+	case $deplib in
+	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    compiler_flags="$compiler_flags $deplib"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-l*)
+	  if test "$linkmode" != lib && test "$linkmode" != prog; then
+	    func_warning "\`-l' is ignored for archives/objects"
+	    continue
+	  fi
+	  func_stripname '-l' '' "$deplib"
+	  name=$func_stripname_result
+	  if test "$linkmode" = lib; then
+	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+	  else
+	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+	  fi
+	  for searchdir in $searchdirs; do
+	    for search_ext in .la $std_shrext .so .a; do
+	      # Search the libtool library
+	      lib="$searchdir/lib${name}${search_ext}"
+	      if test -f "$lib"; then
+		if test "$search_ext" = ".la"; then
+		  found=yes
+		else
+		  found=no
+		fi
+		break 2
+	      fi
+	    done
+	  done
+	  if test "$found" != yes; then
+	    # deplib doesn't seem to be a libtool library
+	    if test "$linkmode,$pass" = "prog,link"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
+	  else # deplib is a libtool library
+	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+	    # We need to do some special things here, and not later.
+	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	      case " $predeps $postdeps " in
+	      *" $deplib "*)
+		if func_lalib_p "$lib"; then
+		  library_names=
+		  old_library=
+		  func_source "$lib"
+		  for l in $old_library $library_names; do
+		    ll="$l"
+		  done
+		  if test "X$ll" = "X$old_library" ; then # only static version available
+		    found=no
+		    func_dirname "$lib" "" "."
+		    ladir="$func_dirname_result"
+		    lib=$ladir/$old_library
+		    if test "$linkmode,$pass" = "prog,link"; then
+		      compile_deplibs="$deplib $compile_deplibs"
+		      finalize_deplibs="$deplib $finalize_deplibs"
+		    else
+		      deplibs="$deplib $deplibs"
+		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+		    fi
+		    continue
+		  fi
+		fi
+		;;
+	      *) ;;
+	      esac
+	    fi
+	  fi
+	  ;; # -l
+	*.ltframework)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    deplibs="$deplib $deplibs"
+	    if test "$linkmode" = lib ; then
+		case "$new_inherited_linker_flags " in
+		    *" $deplib "*) ;;
+		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+		esac
+	    fi
+	  fi
+	  continue
+	  ;;
+	-L*)
+	  case $linkmode in
+	  lib)
+	    deplibs="$deplib $deplibs"
+	    test "$pass" = conv && continue
+	    newdependency_libs="$deplib $newdependency_libs"
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  prog)
+	    if test "$pass" = conv; then
+	      deplibs="$deplib $deplibs"
+	      continue
+	    fi
+	    if test "$pass" = scan; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    func_stripname '-L' '' "$deplib"
+	    newlib_search_path="$newlib_search_path $func_stripname_result"
+	    ;;
+	  *)
+	    func_warning "\`-L' is ignored for archives/objects"
+	    ;;
+	  esac # linkmode
+	  continue
+	  ;; # -L
+	-R*)
+	  if test "$pass" = link; then
+	    func_stripname '-R' '' "$deplib"
+	    dir=$func_stripname_result
+	    # Make sure the xrpath contains only unique directories.
+	    case "$xrpath " in
+	    *" $dir "*) ;;
+	    *) xrpath="$xrpath $dir" ;;
+	    esac
+	  fi
+	  deplibs="$deplib $deplibs"
+	  continue
+	  ;;
+	*.la) lib="$deplib" ;;
+	*.$libext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	    continue
+	  fi
+	  case $linkmode in
+	  lib)
+	    # Linking convenience modules into shared libraries is allowed,
+	    # but linking other static libraries is non-portable.
+	    case " $dlpreconveniencelibs " in
+	    *" $deplib "*) ;;
+	    *)
+	      valid_a_lib=no
+	      case $deplibs_check_method in
+		match_pattern*)
+		  set dummy $deplibs_check_method; shift
+		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
+		    | $EGREP "$match_pattern_regex" > /dev/null; then
+		    valid_a_lib=yes
+		  fi
+		;;
+		pass_all)
+		  valid_a_lib=yes
+		;;
+	      esac
+	      if test "$valid_a_lib" != yes; then
+		$ECHO
+		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
+		$ECHO "*** that it is just a static archive that I should not use here."
+	      else
+		$ECHO
+		$ECHO "*** Warning: Linking the shared library $output against the"
+		$ECHO "*** static library $deplib is not portable!"
+		deplibs="$deplib $deplibs"
+	      fi
+	      ;;
+	    esac
+	    continue
+	    ;;
+	  prog)
+	    if test "$pass" != link; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    fi
+	    continue
+	    ;;
+	  esac # linkmode
+	  ;; # *.$libext
+	*.lo | *.$objext)
+	  if test "$pass" = conv; then
+	    deplibs="$deplib $deplibs"
+	  elif test "$linkmode" = prog; then
+	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+	      # If there is no dlopen support or we're linking statically,
+	      # we need to preload.
+	      newdlprefiles="$newdlprefiles $deplib"
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      newdlfiles="$newdlfiles $deplib"
+	    fi
+	  fi
+	  continue
+	  ;;
+	%DEPLIBS%)
+	  alldeplibs=yes
+	  continue
+	  ;;
+	esac # case $deplib
+
+	if test "$found" = yes || test -f "$lib"; then :
+	else
+	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+	fi
+
+	# Check to see that this really is a libtool archive.
+	func_lalib_unsafe_p "$lib" \
+	  || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+	func_dirname "$lib" "" "."
+	ladir="$func_dirname_result"
+
+	dlname=
+	dlopen=
+	dlpreopen=
+	libdir=
+	library_names=
+	old_library=
+	inherited_linker_flags=
+	# If the library was installed with an old release of libtool,
+	# it will not redefine variables installed, or shouldnotlink
+	installed=yes
+	shouldnotlink=no
+	avoidtemprpath=
+
+
+	# Read the .la file
+	func_source "$lib"
+
+	# Convert "-framework foo" to "foo.ltframework"
+	if test -n "$inherited_linker_flags"; then
+	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
+	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+	    case " $new_inherited_linker_flags " in
+	      *" $tmp_inherited_linker_flag "*) ;;
+	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+	    esac
+	  done
+	fi
+	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	if test "$linkmode,$pass" = "lib,link" ||
+	   test "$linkmode,$pass" = "prog,scan" ||
+	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+	fi
+
+	if test "$pass" = conv; then
+	  # Only check for convenience libraries
+	  deplibs="$lib $deplibs"
+	  if test -z "$libdir"; then
+	    if test -z "$old_library"; then
+	      func_fatal_error "cannot find name of link library for \`$lib'"
+	    fi
+	    # It is a libtool convenience library, so add in its objects.
+	    convenience="$convenience $ladir/$objdir/$old_library"
+	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
+	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
+	    func_fatal_error "\`$lib' is not a convenience library"
+	  fi
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    deplibs="$deplib $deplibs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+	  continue
+	fi # $pass = conv
+
+
+	# Get the name of the library we link against.
+	linklib=
+	for l in $old_library $library_names; do
+	  linklib="$l"
+	done
+	if test -z "$linklib"; then
+	  func_fatal_error "cannot find name of link library for \`$lib'"
+	fi
+
+	# This library was specified with -dlopen.
+	if test "$pass" = dlopen; then
+	  if test -z "$libdir"; then
+	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+	  fi
+	  if test -z "$dlname" ||
+	     test "$dlopen_support" != yes ||
+	     test "$build_libtool_libs" = no; then
+	    # If there is no dlname, no dlopen support or we're linking
+	    # statically, we need to preload.  We also need to preload any
+	    # dependent libraries so libltdl's deplib preloader doesn't
+	    # bomb out in the load deplibs phase.
+	    dlprefiles="$dlprefiles $lib $dependency_libs"
+	  else
+	    newdlfiles="$newdlfiles $lib"
+	  fi
+	  continue
+	fi # $pass = dlopen
+
+	# We need an absolute path.
+	case $ladir in
+	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+	*)
+	  abs_ladir=`cd "$ladir" && pwd`
+	  if test -z "$abs_ladir"; then
+	    func_warning "cannot determine absolute directory name of \`$ladir'"
+	    func_warning "passing it literally to the linker, although it might fail"
+	    abs_ladir="$ladir"
+	  fi
+	  ;;
+	esac
+	func_basename "$lib"
+	laname="$func_basename_result"
+
+	# Find the relevant object directory and library name.
+	if test "X$installed" = Xyes; then
+	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    func_warning "library \`$lib' was moved."
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    libdir="$abs_ladir"
+	  else
+	    dir="$libdir"
+	    absdir="$libdir"
+	  fi
+	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+	else
+	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+	    dir="$ladir"
+	    absdir="$abs_ladir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  else
+	    dir="$ladir/$objdir"
+	    absdir="$abs_ladir/$objdir"
+	    # Remove this search path later
+	    notinst_path="$notinst_path $abs_ladir"
+	  fi
+	fi # $installed = yes
+	func_stripname 'lib' '.la' "$laname"
+	name=$func_stripname_result
+
+	# This library was specified with -dlpreopen.
+	if test "$pass" = dlpreopen; then
+	  if test -z "$libdir" && test "$linkmode" = prog; then
+	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+	  fi
+	  # Prefer using a static library (so that no silly _DYNAMIC symbols
+	  # are required to link).
+	  if test -n "$old_library"; then
+	    newdlprefiles="$newdlprefiles $dir/$old_library"
+	    # Keep a list of preopened convenience libraries to check
+	    # that they are being used correctly in the link pass.
+	    test -z "$libdir" && \
+		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+	  # Otherwise, use the dlname, so that lt_dlopen finds it.
+	  elif test -n "$dlname"; then
+	    newdlprefiles="$newdlprefiles $dir/$dlname"
+	  else
+	    newdlprefiles="$newdlprefiles $dir/$linklib"
+	  fi
+	fi # $pass = dlpreopen
+
+	if test -z "$libdir"; then
+	  # Link the convenience library
+	  if test "$linkmode" = lib; then
+	    deplibs="$dir/$old_library $deplibs"
+	  elif test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$dir/$old_library $compile_deplibs"
+	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
+	  else
+	    deplibs="$lib $deplibs" # used for prog,scan pass
+	  fi
+	  continue
+	fi
+
+
+	if test "$linkmode" = prog && test "$pass" != link; then
+	  newlib_search_path="$newlib_search_path $ladir"
+	  deplibs="$lib $deplibs"
+
+	  linkalldeplibs=no
+	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
+	     test "$build_libtool_libs" = no; then
+	    linkalldeplibs=yes
+	  fi
+
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    case $deplib in
+	    -L*) func_stripname '-L' '' "$deplib"
+	         newlib_search_path="$newlib_search_path $func_stripname_result"
+		 ;;
+	    esac
+	    # Need to link against all dependency_libs?
+	    if test "$linkalldeplibs" = yes; then
+	      deplibs="$deplib $deplibs"
+	    else
+	      # Need to hardcode shared library paths
+	      # or/and link against static libraries
+	      newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done # for deplib
+	  continue
+	fi # $linkmode = prog...
+
+	if test "$linkmode,$pass" = "prog,link"; then
+	  if test -n "$library_names" &&
+	     { { test "$prefer_static_libs" = no ||
+	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
+	       test -z "$old_library"; }; then
+	    # We need to hardcode the library path
+	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+	      # Make sure the rpath contains only unique directories.
+	      case "$temp_rpath:" in
+	      *"$absdir:"*) ;;
+	      *) temp_rpath="$temp_rpath$absdir:" ;;
+	      esac
+	    fi
+
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi # $linkmode,$pass = prog,link...
+
+	  if test "$alldeplibs" = yes &&
+	     { test "$deplibs_check_method" = pass_all ||
+	       { test "$build_libtool_libs" = yes &&
+		 test -n "$library_names"; }; }; then
+	    # We only need to search for static libraries
+	    continue
+	  fi
+	fi
+
+	link_static=no # Whether the deplib will be linked statically
+	use_static_libs=$prefer_static_libs
+	if test "$use_static_libs" = built && test "$installed" = yes; then
+	  use_static_libs=no
+	fi
+	if test -n "$library_names" &&
+	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
+	  case $host in
+	  *cygwin* | *mingw* | *cegcc*)
+	      # No point in relinking DLLs because paths are not encoded
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=no
+	    ;;
+	  *)
+	    if test "$installed" = no; then
+	      notinst_deplibs="$notinst_deplibs $lib"
+	      need_relink=yes
+	    fi
+	    ;;
+	  esac
+	  # This is a shared library
+
+	  # Warn about portability, can't link against -module's on some
+	  # systems (darwin).  Don't bleat about dlopened modules though!
+	  dlopenmodule=""
+	  for dlpremoduletest in $dlprefiles; do
+	    if test "X$dlpremoduletest" = "X$lib"; then
+	      dlopenmodule="$dlpremoduletest"
+	      break
+	    fi
+	  done
+	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+	    $ECHO
+	    if test "$linkmode" = prog; then
+	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
+	    else
+	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+	    fi
+	    $ECHO "*** $linklib is not portable!"
+	  fi
+	  if test "$linkmode" = lib &&
+	     test "$hardcode_into_libs" = yes; then
+	    # Hardcode the library path.
+	    # Skip directories that are in the system default run-time
+	    # search path.
+	    case " $sys_lib_dlsearch_path " in
+	    *" $absdir "*) ;;
+	    *)
+	      case "$compile_rpath " in
+	      *" $absdir "*) ;;
+	      *) compile_rpath="$compile_rpath $absdir"
+	      esac
+	      ;;
+	    esac
+	    case " $sys_lib_dlsearch_path " in
+	    *" $libdir "*) ;;
+	    *)
+	      case "$finalize_rpath " in
+	      *" $libdir "*) ;;
+	      *) finalize_rpath="$finalize_rpath $libdir"
+	      esac
+	      ;;
+	    esac
+	  fi
+
+	  if test -n "$old_archive_from_expsyms_cmds"; then
+	    # figure out the soname
+	    set dummy $library_names
+	    shift
+	    realname="$1"
+	    shift
+	    libname=`eval "\\$ECHO \"$libname_spec\""`
+	    # use dlname if we got it. it's perfectly good, no?
+	    if test -n "$dlname"; then
+	      soname="$dlname"
+	    elif test -n "$soname_spec"; then
+	      # bleh windows
+	      case $host in
+	      *cygwin* | mingw* | *cegcc*)
+	        func_arith $current - $age
+		major=$func_arith_result
+		versuffix="-$major"
+		;;
+	      esac
+	      eval soname=\"$soname_spec\"
+	    else
+	      soname="$realname"
+	    fi
+
+	    # Make a new name for the extract_expsyms_cmds to use
+	    soroot="$soname"
+	    func_basename "$soroot"
+	    soname="$func_basename_result"
+	    func_stripname 'lib' '.dll' "$soname"
+	    newlib=libimp-$func_stripname_result.a
+
+	    # If the library has no export list, then create one now
+	    if test -f "$output_objdir/$soname-def"; then :
+	    else
+	      func_verbose "extracting exported symbol list from \`$soname'"
+	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+	    fi
+
+	    # Create $newlib
+	    if test -f "$output_objdir/$newlib"; then :; else
+	      func_verbose "generating import library for \`$soname'"
+	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+	    fi
+	    # make sure the library variables are pointing to the new library
+	    dir=$output_objdir
+	    linklib=$newlib
+	  fi # test -n "$old_archive_from_expsyms_cmds"
+
+	  if test "$linkmode" = prog || test "$mode" != relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    lib_linked=yes
+	    case $hardcode_action in
+	    immediate | unsupported)
+	      if test "$hardcode_direct" = no; then
+		add="$dir/$linklib"
+		case $host in
+		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+		    *-*-unixware7*) add_dir="-L$dir" ;;
+		  *-*-darwin* )
+		    # if the lib is a (non-dlopened) module then we can not
+		    # link against it, someone is ignoring the earlier warnings
+		    if /usr/bin/file -L $add 2> /dev/null |
+			 $GREP ": [^:]* bundle" >/dev/null ; then
+		      if test "X$dlopenmodule" != "X$lib"; then
+			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
+			if test -z "$old_library" ; then
+			  $ECHO
+			  $ECHO "*** And there doesn't seem to be a static archive available"
+			  $ECHO "*** The link will probably fail, sorry"
+			else
+			  add="$dir/$old_library"
+			fi
+		      elif test -n "$old_library"; then
+			add="$dir/$old_library"
+		      fi
+		    fi
+		esac
+	      elif test "$hardcode_minus_L" = no; then
+		case $host in
+		*-*-sunos*) add_shlibpath="$dir" ;;
+		esac
+		add_dir="-L$dir"
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = no; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    relink)
+	      if test "$hardcode_direct" = yes &&
+	         test "$hardcode_direct_absolute" = no; then
+		add="$dir/$linklib"
+	      elif test "$hardcode_minus_L" = yes; then
+		add_dir="-L$dir"
+		# Try looking first in the location we're being installed to.
+		if test -n "$inst_prefix_dir"; then
+		  case $libdir in
+		    [\\/]*)
+		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		      ;;
+		  esac
+		fi
+		add="-l$name"
+	      elif test "$hardcode_shlibpath_var" = yes; then
+		add_shlibpath="$dir"
+		add="-l$name"
+	      else
+		lib_linked=no
+	      fi
+	      ;;
+	    *) lib_linked=no ;;
+	    esac
+
+	    if test "$lib_linked" != yes; then
+	      func_fatal_configuration "unsupported hardcode properties"
+	    fi
+
+	    if test -n "$add_shlibpath"; then
+	      case :$compile_shlibpath: in
+	      *":$add_shlibpath:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+	      esac
+	    fi
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	      if test "$hardcode_direct" != yes &&
+		 test "$hardcode_minus_L" != yes &&
+		 test "$hardcode_shlibpath_var" = yes; then
+		case :$finalize_shlibpath: in
+		*":$libdir:"*) ;;
+		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+		esac
+	      fi
+	    fi
+	  fi
+
+	  if test "$linkmode" = prog || test "$mode" = relink; then
+	    add_shlibpath=
+	    add_dir=
+	    add=
+	    # Finalize command for both is simple: just hardcode it.
+	    if test "$hardcode_direct" = yes &&
+	       test "$hardcode_direct_absolute" = no; then
+	      add="$libdir/$linklib"
+	    elif test "$hardcode_minus_L" = yes; then
+	      add_dir="-L$libdir"
+	      add="-l$name"
+	    elif test "$hardcode_shlibpath_var" = yes; then
+	      case :$finalize_shlibpath: in
+	      *":$libdir:"*) ;;
+	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+	      esac
+	      add="-l$name"
+	    elif test "$hardcode_automatic" = yes; then
+	      if test -n "$inst_prefix_dir" &&
+		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
+		add="$inst_prefix_dir$libdir/$linklib"
+	      else
+		add="$libdir/$linklib"
+	      fi
+	    else
+	      # We cannot seem to hardcode it, guess we'll fake it.
+	      add_dir="-L$libdir"
+	      # Try looking first in the location we're being installed to.
+	      if test -n "$inst_prefix_dir"; then
+		case $libdir in
+		  [\\/]*)
+		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
+		    ;;
+		esac
+	      fi
+	      add="-l$name"
+	    fi
+
+	    if test "$linkmode" = prog; then
+	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+	    else
+	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
+	      test -n "$add" && deplibs="$add $deplibs"
+	    fi
+	  fi
+	elif test "$linkmode" = prog; then
+	  # Here we assume that one of hardcode_direct or hardcode_minus_L
+	  # is not unsupported.  This is valid on all known static and
+	  # shared platforms.
+	  if test "$hardcode_direct" != unsupported; then
+	    test -n "$old_library" && linklib="$old_library"
+	    compile_deplibs="$dir/$linklib $compile_deplibs"
+	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
+	  else
+	    compile_deplibs="-l$name -L$dir $compile_deplibs"
+	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+	  fi
+	elif test "$build_libtool_libs" = yes; then
+	  # Not a shared library
+	  if test "$deplibs_check_method" != pass_all; then
+	    # We're trying link a shared library against a static one
+	    # but the system doesn't support it.
+
+	    # Just print a warning and add the library to dependency_libs so
+	    # that the program can be linked against the static library.
+	    $ECHO
+	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
+	    $ECHO "*** I have the capability to make that library automatically link in when"
+	    $ECHO "*** you link to this library.  But I can only do this if you have a"
+	    $ECHO "*** shared version of the library, which you do not appear to have."
+	    if test "$module" = yes; then
+	      $ECHO "*** But as you try to build a module library, libtool will still create "
+	      $ECHO "*** a static module, that should work as long as the dlopening application"
+	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
+	      if test -z "$global_symbol_pipe"; then
+		$ECHO
+		$ECHO "*** However, this would only work if libtool was able to extract symbol"
+		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+		$ECHO "*** not find such a program.  So, this module is probably useless."
+		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	      fi
+	      if test "$build_old_libs" = no; then
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  else
+	    deplibs="$dir/$old_library $deplibs"
+	    link_static=yes
+	  fi
+	fi # link shared/static library?
+
+	if test "$linkmode" = lib; then
+	  if test -n "$dependency_libs" &&
+	     { test "$hardcode_into_libs" != yes ||
+	       test "$build_old_libs" = yes ||
+	       test "$link_static" = yes; }; then
+	    # Extract -R from dependency_libs
+	    temp_deplibs=
+	    for libdir in $dependency_libs; do
+	      case $libdir in
+	      -R*) func_stripname '-R' '' "$libdir"
+	           temp_xrpath=$func_stripname_result
+		   case " $xrpath " in
+		   *" $temp_xrpath "*) ;;
+		   *) xrpath="$xrpath $temp_xrpath";;
+		   esac;;
+	      *) temp_deplibs="$temp_deplibs $libdir";;
+	      esac
+	    done
+	    dependency_libs="$temp_deplibs"
+	  fi
+
+	  newlib_search_path="$newlib_search_path $absdir"
+	  # Link against this library
+	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+	  # ... and its dependency_libs
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    newdependency_libs="$deplib $newdependency_libs"
+	    if $opt_duplicate_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+	      esac
+	    fi
+	    tmp_libs="$tmp_libs $deplib"
+	  done
+
+	  if test "$link_all_deplibs" != no; then
+	    # Add the search paths of all dependency libraries
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      -L*) path="$deplib" ;;
+	      *.la)
+	        func_dirname "$deplib" "" "."
+		dir="$func_dirname_result"
+		# We need an absolute path.
+		case $dir in
+		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+		*)
+		  absdir=`cd "$dir" && pwd`
+		  if test -z "$absdir"; then
+		    func_warning "cannot determine absolute directory name of \`$dir'"
+		    absdir="$dir"
+		  fi
+		  ;;
+		esac
+		if $GREP "^installed=no" $deplib > /dev/null; then
+		case $host in
+		*-*-darwin*)
+		  depdepl=
+		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+		  if test -n "$deplibrary_names" ; then
+		    for tmp in $deplibrary_names ; do
+		      depdepl=$tmp
+		    done
+		    if test -f "$absdir/$objdir/$depdepl" ; then
+		      depdepl="$absdir/$objdir/$depdepl"
+		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+                      if test -z "$darwin_install_name"; then
+                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
+                      fi
+		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+		      path=
+		    fi
+		  fi
+		  ;;
+		*)
+		  path="-L$absdir/$objdir"
+		  ;;
+		esac
+		else
+		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		  test -z "$libdir" && \
+		    func_fatal_error "\`$deplib' is not a valid libtool archive"
+		  test "$absdir" != "$libdir" && \
+		    func_warning "\`$deplib' seems to be moved"
+
+		  path="-L$absdir"
+		fi
+		;;
+	      esac
+	      case " $deplibs " in
+	      *" $path "*) ;;
+	      *) deplibs="$path $deplibs" ;;
+	      esac
+	    done
+	  fi # link_all_deplibs != no
+	fi # linkmode = lib
+      done # for deplib in $libs
+      if test "$pass" = link; then
+	if test "$linkmode" = "prog"; then
+	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+	else
+	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	fi
+      fi
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+	# Link the dlpreopened libraries before other libraries
+	for deplib in $save_deplibs; do
+	  deplibs="$deplib $deplibs"
+	done
+      fi
+      if test "$pass" != dlopen; then
+	if test "$pass" != conv; then
+	  # Make sure lib_search_path contains only unique directories.
+	  lib_search_path=
+	  for dir in $newlib_search_path; do
+	    case "$lib_search_path " in
+	    *" $dir "*) ;;
+	    *) lib_search_path="$lib_search_path $dir" ;;
+	    esac
+	  done
+	  newlib_search_path=
+	fi
+
+	if test "$linkmode,$pass" != "prog,link"; then
+	  vars="deplibs"
+	else
+	  vars="compile_deplibs finalize_deplibs"
+	fi
+	for var in $vars dependency_libs; do
+	  # Add libraries to $var in reverse order
+	  eval tmp_libs=\"\$$var\"
+	  new_libs=
+	  for deplib in $tmp_libs; do
+	    # FIXME: Pedantically, this is the right thing to do, so
+	    #        that some nasty dependency loop isn't accidentally
+	    #        broken:
+	    #new_libs="$deplib $new_libs"
+	    # Pragmatically, this seems to cause very few problems in
+	    # practice:
+	    case $deplib in
+	    -L*) new_libs="$deplib $new_libs" ;;
+	    -R*) ;;
+	    *)
+	      # And here is the reason: when a library appears more
+	      # than once as an explicit dependence of a library, or
+	      # is implicitly linked in more than once by the
+	      # compiler, it is considered special, and multiple
+	      # occurrences thereof are not removed.  Compare this
+	      # with having the same library being listed as a
+	      # dependency of multiple other libraries: in this case,
+	      # we know (pedantically, we assume) the library does not
+	      # need to be listed more than once, so we keep only the
+	      # last copy.  This is not always right, but it is rare
+	      # enough that we require users that really mean to play
+	      # such unportable linking tricks to link the library
+	      # using -Wl,-lname, so that libtool does not consider it
+	      # for duplicate removal.
+	      case " $specialdeplibs " in
+	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
+	      *)
+		case " $new_libs " in
+		*" $deplib "*) ;;
+		*) new_libs="$deplib $new_libs" ;;
+		esac
+		;;
+	      esac
+	      ;;
+	    esac
+	  done
+	  tmp_libs=
+	  for deplib in $new_libs; do
+	    case $deplib in
+	    -L*)
+	      case " $tmp_libs " in
+	      *" $deplib "*) ;;
+	      *) tmp_libs="$tmp_libs $deplib" ;;
+	      esac
+	      ;;
+	    *) tmp_libs="$tmp_libs $deplib" ;;
+	    esac
+	  done
+	  eval $var=\"$tmp_libs\"
+	done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+	case " $predeps $postdeps $compiler_lib_search_path " in
+	*" $i "*)
+	  i=""
+	  ;;
+	esac
+	if test -n "$i" ; then
+	  tmp_libs="$tmp_libs $i"
+	fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+    fi
+    if test "$linkmode" = prog || test "$linkmode" = lib; then
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for archives"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for archives" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for archives"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for archives"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info/-version-number' is ignored for archives"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for archives"
+
+      test -n "$export_symbols$export_symbols_regex" && \
+	func_warning "\`-export-symbols' is ignored for archives"
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+	func_stripname 'lib' '.la' "$outputname"
+	name=$func_stripname_result
+	eval shared_ext=\"$shrext_cmds\"
+	eval libname=\"$libname_spec\"
+	;;
+      *)
+	test "$module" = no && \
+	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+	if test "$need_lib_prefix" != no; then
+	  # Add the "lib" prefix for modules if required
+	  func_stripname '' '.la' "$outputname"
+	  name=$func_stripname_result
+	  eval shared_ext=\"$shrext_cmds\"
+	  eval libname=\"$libname_spec\"
+	else
+	  func_stripname '' '.la' "$outputname"
+	  libname=$func_stripname_result
+	fi
+	;;
+      esac
+
+      if test -n "$objs"; then
+	if test "$deplibs_check_method" != pass_all; then
+	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+	else
+	  $ECHO
+	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+	  $ECHO "*** objects $objs is not portable!"
+	  libobjs="$libobjs $objs"
+	fi
+      fi
+
+      test "$dlself" != no && \
+	func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+      set dummy $rpath
+      shift
+      test "$#" -gt 1 && \
+	func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+      install_libdir="$1"
+
+      oldlibs=
+      if test -z "$rpath"; then
+	if test "$build_libtool_libs" = yes; then
+	  # Building a libtool convenience library.
+	  # Some compilers have problems with a `.al' extension so
+	  # convenience libraries should have the same extension an
+	  # archive normally would.
+	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
+	  build_libtool_libs=convenience
+	  build_old_libs=yes
+	fi
+
+	test -n "$vinfo" && \
+	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+	test -n "$release" && \
+	  func_warning "\`-release' is ignored for convenience libraries"
+      else
+
+	# Parse the version information argument.
+	save_ifs="$IFS"; IFS=':'
+	set dummy $vinfo 0 0 0
+	shift
+	IFS="$save_ifs"
+
+	test -n "$7" && \
+	  func_fatal_help "too many parameters to \`-version-info'"
+
+	# convert absolute version numbers to libtool ages
+	# this retains compatibility with .la files and attempts
+	# to make the code below a bit more comprehensible
+
+	case $vinfo_number in
+	yes)
+	  number_major="$1"
+	  number_minor="$2"
+	  number_revision="$3"
+	  #
+	  # There are really only two kinds -- those that
+	  # use the current revision as the major version
+	  # and those that subtract age and use age as
+	  # a minor version.  But, then there is irix
+	  # which has an extra 1 added just for fun
+	  #
+	  case $version_type in
+	  darwin|linux|osf|windows|none)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_revision"
+	    ;;
+	  freebsd-aout|freebsd-elf|sunos)
+	    current="$number_major"
+	    revision="$number_minor"
+	    age="0"
+	    ;;
+	  irix|nonstopux)
+	    func_arith $number_major + $number_minor
+	    current=$func_arith_result
+	    age="$number_minor"
+	    revision="$number_minor"
+	    lt_irix_increment=no
+	    ;;
+	  esac
+	  ;;
+	no)
+	  current="$1"
+	  revision="$2"
+	  age="$3"
+	  ;;
+	esac
+
+	# Check that each of the things are valid numbers.
+	case $current in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "CURRENT \`$current' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $revision in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "REVISION \`$revision' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	case $age in
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+	*)
+	  func_error "AGE \`$age' must be a nonnegative integer"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	  ;;
+	esac
+
+	if test "$age" -gt "$current"; then
+	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
+	  func_fatal_error "\`$vinfo' is not valid version information"
+	fi
+
+	# Calculate the version variables.
+	major=
+	versuffix=
+	verstring=
+	case $version_type in
+	none) ;;
+
+	darwin)
+	  # Like Linux, but with the current version available in
+	  # verstring for coding it into the library header
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  # Darwin ld doesn't like 0 for these options...
+	  func_arith $current + 1
+	  minor_current=$func_arith_result
+	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	irix | nonstopux)
+	  if test "X$lt_irix_increment" = "Xno"; then
+	    func_arith $current - $age
+	  else
+	    func_arith $current - $age + 1
+	  fi
+	  major=$func_arith_result
+
+	  case $version_type in
+	    nonstopux) verstring_prefix=nonstopux ;;
+	    *)         verstring_prefix=sgi ;;
+	  esac
+	  verstring="$verstring_prefix$major.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$revision
+	  while test "$loop" -ne 0; do
+	    func_arith $revision - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring_prefix$major.$iface:$verstring"
+	  done
+
+	  # Before this point, $major must not contain `.'.
+	  major=.$major
+	  versuffix="$major.$revision"
+	  ;;
+
+	linux)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix="$major.$age.$revision"
+	  ;;
+
+	osf)
+	  func_arith $current - $age
+	  major=.$func_arith_result
+	  versuffix=".$current.$age.$revision"
+	  verstring="$current.$age.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$age
+	  while test "$loop" -ne 0; do
+	    func_arith $current - $loop
+	    iface=$func_arith_result
+	    func_arith $loop - 1
+	    loop=$func_arith_result
+	    verstring="$verstring:${iface}.0"
+	  done
+
+	  # Make executables depend on our current version.
+	  verstring="$verstring:${current}.0"
+	  ;;
+
+	qnx)
+	  major=".$current"
+	  versuffix=".$current"
+	  ;;
+
+	sunos)
+	  major=".$current"
+	  versuffix=".$current.$revision"
+	  ;;
+
+	windows)
+	  # Use '-' rather than '.', since we only want one
+	  # extension on DOS 8.3 filesystems.
+	  func_arith $current - $age
+	  major=$func_arith_result
+	  versuffix="-$major"
+	  ;;
+
+	*)
+	  func_fatal_configuration "unknown library version type \`$version_type'"
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  case $version_type in
+	  darwin)
+	    # we can't check for "0.0" in archive_cmds due to quoting
+	    # problems, so we reset it completely
+	    verstring=
+	    ;;
+	  *)
+	    verstring="0.0"
+	    ;;
+	  esac
+	  if test "$need_version" = no; then
+	    versuffix=
+	  else
+	    versuffix=".0.0"
+	  fi
+	fi
+
+	# Remove version info from name if versioning should be avoided
+	if test "$avoid_version" = yes && test "$need_version" = no; then
+	  major=
+	  versuffix=
+	  verstring=""
+	fi
+
+	# Check to see if the archive will have undefined symbols.
+	if test "$allow_undefined" = yes; then
+	  if test "$allow_undefined_flag" = unsupported; then
+	    func_warning "undefined symbols not allowed in $host shared libraries"
+	    build_libtool_libs=no
+	    build_old_libs=yes
+	  fi
+	else
+	  # Don't allow undefined symbols.
+	  allow_undefined_flag="$no_undefined_flag"
+	fi
+
+      fi
+
+      func_generate_dlsyms "$libname" "$libname" "yes"
+      libobjs="$libobjs $symfileobj"
+      test "X$libobjs" = "X " && libobjs=
+
+      if test "$mode" != relink; then
+	# Remove our outputs, but don't remove object files since they
+	# may have been created when compiling PIC objects.
+	removelist=
+	tempremovelist=`$ECHO "$output_objdir/*"`
+	for p in $tempremovelist; do
+	  case $p in
+	    *.$objext | *.gcno)
+	       ;;
+	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+	       if test "X$precious_files_regex" != "X"; then
+		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+		 then
+		   continue
+		 fi
+	       fi
+	       removelist="$removelist $p"
+	       ;;
+	    *) ;;
+	  esac
+	done
+	test -n "$removelist" && \
+	  func_show_eval "${RM}r \$removelist"
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+	oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+	# Transform .lo files to .o files.
+	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      #for path in $notinst_path; do
+      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
+      #done
+
+      if test -n "$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	temp_xrpath=
+	for libdir in $xrpath; do
+	  temp_xrpath="$temp_xrpath -R$libdir"
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+	  dependency_libs="$temp_xrpath $dependency_libs"
+	fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+	case " $dlprefiles $dlfiles " in
+	*" $lib "*) ;;
+	*) dlfiles="$dlfiles $lib" ;;
+	esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+	case "$dlprefiles " in
+	*" $lib "*) ;;
+	*) dlprefiles="$dlprefiles $lib" ;;
+	esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+	if test -n "$rpath"; then
+	  case $host in
+	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
+	    # these systems don't actually have a c library (as such)!
+	    ;;
+	  *-*-rhapsody* | *-*-darwin1.[012])
+	    # Rhapsody C library is in the System framework
+	    deplibs="$deplibs System.ltframework"
+	    ;;
+	  *-*-netbsd*)
+	    # Don't link with libc until the a.out ld.so is fixed.
+	    ;;
+	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+	    # Do not include libc due to us having libc/libc_r.
+	    ;;
+	  *-*-sco3.2v5* | *-*-sco5v6*)
+	    # Causes problems with __ctype
+	    ;;
+	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+	    # Compiler inserts libc in the correct place for threads to work
+	    ;;
+	  *)
+	    # Add libc to deplibs on all other systems if necessary.
+	    if test "$build_libtool_need_lc" = "yes"; then
+	      deplibs="$deplibs -lc"
+	    fi
+	    ;;
+	  esac
+	fi
+
+	# Transform deplibs into only deplibs that can be linked in shared.
+	name_save=$name
+	libname_save=$libname
+	release_save=$release
+	versuffix_save=$versuffix
+	major_save=$major
+	# I'm not sure if I'm treating the release correctly.  I think
+	# release should show up in the -l (ie -lgmp5) so we don't want to
+	# add it in twice.  Is that correct?
+	release=""
+	versuffix=""
+	major=""
+	newdeplibs=
+	droppeddeps=no
+	case $deplibs_check_method in
+	pass_all)
+	  # Don't check for shared/static.  Everything works.
+	  # This might be a little naive.  We might want to check
+	  # whether the library exists or not.  But this is on
+	  # osf3 & osf4 and I'm not really sure... Just
+	  # implementing what was already the behavior.
+	  newdeplibs=$deplibs
+	  ;;
+	test_compile)
+	  # This code stresses the "libraries are programs" paradigm to its
+	  # limits. Maybe even breaks it.  We compile a program, linking it
+	  # against the deplibs as a proxy for the library.  Then we can check
+	  # whether they linked in statically or dynamically with ldd.
+	  $opt_dry_run || $RM conftest.c
+	  cat > conftest.c <<EOF
+	  int main() { return 0; }
+EOF
+	  $opt_dry_run || $RM conftest
+	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+	    ldd_output=`ldd conftest`
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		  case " $predeps $postdeps " in
+		  *" $i "*)
+		    newdeplibs="$newdeplibs $i"
+		    i=""
+		    ;;
+		  esac
+		fi
+		if test -n "$i" ; then
+		  libname=`eval "\\$ECHO \"$libname_spec\""`
+		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		  set dummy $deplib_matches; shift
+		  deplib_match=$1
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    newdeplibs="$newdeplibs $i"
+		  else
+		    droppeddeps=yes
+		    $ECHO
+		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		    $ECHO "*** I have the capability to make that library automatically link in when"
+		    $ECHO "*** you link to this library.  But I can only do this if you have a"
+		    $ECHO "*** shared version of the library, which I believe you do not have"
+		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
+		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
+		  fi
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  else
+	    # Error occurred in the first compile.  Let's try to salvage
+	    # the situation: Compile a separate program for each library.
+	    for i in $deplibs; do
+	      case $i in
+	      -l*)
+		func_stripname -l '' "$i"
+		name=$func_stripname_result
+		$opt_dry_run || $RM conftest
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+		  ldd_output=`ldd conftest`
+		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		    case " $predeps $postdeps " in
+		    *" $i "*)
+		      newdeplibs="$newdeplibs $i"
+		      i=""
+		      ;;
+		    esac
+		  fi
+		  if test -n "$i" ; then
+		    libname=`eval "\\$ECHO \"$libname_spec\""`
+		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+		    set dummy $deplib_matches; shift
+		    deplib_match=$1
+		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		      newdeplibs="$newdeplibs $i"
+		    else
+		      droppeddeps=yes
+		      $ECHO
+		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+		      $ECHO "*** I have the capability to make that library automatically link in when"
+		      $ECHO "*** you link to this library.  But I can only do this if you have a"
+		      $ECHO "*** shared version of the library, which you do not appear to have"
+		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
+		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
+		    fi
+		  fi
+		else
+		  droppeddeps=yes
+		  $ECHO
+		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
+		  $ECHO "*** make it link in!  You will probably need to install it or some"
+		  $ECHO "*** library that it depends on before this library will be fully"
+		  $ECHO "*** functional.  Installing it before continuing would be even better."
+		fi
+		;;
+	      *)
+		newdeplibs="$newdeplibs $i"
+		;;
+	      esac
+	    done
+	  fi
+	  ;;
+	file_magic*)
+	  set dummy $deplibs_check_method; shift
+	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null |
+			 $GREP " -> " >/dev/null; then
+			continue
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+			case $potliblink in
+			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+			 $SED -e 10q |
+			 $EGREP "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a file magic. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	match_pattern*)
+	  set dummy $deplibs_check_method; shift
+	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+	  for a_deplib in $deplibs; do
+	    case $a_deplib in
+	    -l*)
+	      func_stripname -l '' "$a_deplib"
+	      name=$func_stripname_result
+	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+		case " $predeps $postdeps " in
+		*" $a_deplib "*)
+		  newdeplibs="$newdeplibs $a_deplib"
+		  a_deplib=""
+		  ;;
+		esac
+	      fi
+	      if test -n "$a_deplib" ; then
+		libname=`eval "\\$ECHO \"$libname_spec\""`
+		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  for potent_lib in $potential_libs; do
+		    potlib="$potent_lib" # see symlink-check above in file_magic test
+		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
+		       $EGREP "$match_pattern_regex" > /dev/null; then
+		      newdeplibs="$newdeplibs $a_deplib"
+		      a_deplib=""
+		      break 2
+		    fi
+		  done
+		done
+	      fi
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		$ECHO
+		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+		$ECHO "*** I have the capability to make that library automatically link in when"
+		$ECHO "*** you link to this library.  But I can only do this if you have a"
+		$ECHO "*** shared version of the library, which you do not appear to have"
+		$ECHO "*** because I did check the linker path looking for a file starting"
+		if test -z "$potlib" ; then
+		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+		else
+		  $ECHO "*** with $libname and none of the candidates passed a file format test"
+		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
+		fi
+	      fi
+	      ;;
+	    *)
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	      ;;
+	    esac
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
+	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
+	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+	    for i in $predeps $postdeps ; do
+	      # can't use Xsed below, because $i might contain '/'
+	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
+	    done
+	  fi
+	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
+	     $GREP . >/dev/null; then
+	    $ECHO
+	    if test "X$deplibs_check_method" = "Xnone"; then
+	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
+	    else
+	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
+	    fi
+	    $ECHO "*** All declared inter-library dependencies are being dropped."
+	    droppeddeps=yes
+	  fi
+	  ;;
+	esac
+	versuffix=$versuffix_save
+	major=$major_save
+	release=$release_save
+	libname=$libname_save
+	name=$name_save
+
+	case $host in
+	*-*-rhapsody* | *-*-darwin1.[012])
+	  # On Rhapsody replace the C library with the System framework
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	  ;;
+	esac
+
+	if test "$droppeddeps" = yes; then
+	  if test "$module" = yes; then
+	    $ECHO
+	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
+	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
+	    $ECHO "*** a static module, that should work as long as the dlopening"
+	    $ECHO "*** application is linked with the -dlopen flag."
+	    if test -z "$global_symbol_pipe"; then
+	      $ECHO
+	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
+	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      $ECHO "*** not find such a program.  So, this module is probably useless."
+	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+	    fi
+	    if test "$build_old_libs" = no; then
+	      oldlibs="$output_objdir/$libname.$libext"
+	      build_libtool_libs=module
+	      build_old_libs=yes
+	    else
+	      build_libtool_libs=no
+	    fi
+	  else
+	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
+	    $ECHO "*** automatically added whenever a program is linked with this library"
+	    $ECHO "*** or is declared to -dlopen it."
+
+	    if test "$allow_undefined" = no; then
+	      $ECHO
+	      $ECHO "*** Since this library must not contain undefined symbols,"
+	      $ECHO "*** because either the platform does not support them or"
+	      $ECHO "*** it was explicitly requested with -no-undefined,"
+	      $ECHO "*** libtool will only create a static version of it."
+	      if test "$build_old_libs" = no; then
+		oldlibs="$output_objdir/$libname.$libext"
+		build_libtool_libs=module
+		build_old_libs=yes
+	      else
+		build_libtool_libs=no
+	      fi
+	    fi
+	  fi
+	fi
+	# Done checking deplibs!
+	deplibs=$newdeplibs
+      fi
+      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+      case $host in
+	*-*-darwin*)
+	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	  ;;
+      esac
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      deplibs="$new_libs"
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+	if test "$hardcode_into_libs" = yes; then
+	  # Hardcode the library paths
+	  hardcode_libdirs=
+	  dep_rpath=
+	  rpath="$finalize_rpath"
+	  test "$mode" != relink && rpath="$compile_rpath$rpath"
+	  for libdir in $rpath; do
+	    if test -n "$hardcode_libdir_flag_spec"; then
+	      if test -n "$hardcode_libdir_separator"; then
+		if test -z "$hardcode_libdirs"; then
+		  hardcode_libdirs="$libdir"
+		else
+		  # Just accumulate the unique libdirs.
+		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		    ;;
+		  *)
+		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		    ;;
+		  esac
+		fi
+	      else
+		eval flag=\"$hardcode_libdir_flag_spec\"
+		dep_rpath="$dep_rpath $flag"
+	      fi
+	    elif test -n "$runpath_var"; then
+	      case "$perm_rpath " in
+	      *" $libdir "*) ;;
+	      *) perm_rpath="$perm_rpath $libdir" ;;
+	      esac
+	    fi
+	  done
+	  # Substitute the hardcoded libdirs into the rpath.
+	  if test -n "$hardcode_libdir_separator" &&
+	     test -n "$hardcode_libdirs"; then
+	    libdir="$hardcode_libdirs"
+	    if test -n "$hardcode_libdir_flag_spec_ld"; then
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+	    else
+	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+	    fi
+	  fi
+	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
+	    # We should set the runpath_var.
+	    rpath=
+	    for dir in $perm_rpath; do
+	      rpath="$rpath$dir:"
+	    done
+	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+	  fi
+	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+	fi
+
+	shlibpath="$finalize_shlibpath"
+	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+	if test -n "$shlibpath"; then
+	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+	fi
+
+	# Get the real and link names of the library.
+	eval shared_ext=\"$shrext_cmds\"
+	eval library_names=\"$library_names_spec\"
+	set dummy $library_names
+	shift
+	realname="$1"
+	shift
+
+	if test -n "$soname_spec"; then
+	  eval soname=\"$soname_spec\"
+	else
+	  soname="$realname"
+	fi
+	if test -z "$dlname"; then
+	  dlname=$soname
+	fi
+
+	lib="$output_objdir/$realname"
+	linknames=
+	for link
+	do
+	  linknames="$linknames $link"
+	done
+
+	# Use standard objects if they are pic
+	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	test "X$libobjs" = "X " && libobjs=
+
+	delfiles=
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+	  export_symbols="$output_objdir/$libname.uexp"
+	  delfiles="$delfiles $export_symbols"
+	fi
+
+	orig_export_symbols=
+	case $host_os in
+	cygwin* | mingw* | cegcc*)
+	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+	    # exporting using user supplied symfile
+	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+	      # and it's NOT already a .def file. Must figure out
+	      # which of the given symbols are data symbols and tag
+	      # them as such. So, trigger use of export_symbols_cmds.
+	      # export_symbols gets reassigned inside the "prepare
+	      # the list of exported symbols" if statement, so the
+	      # include_expsyms logic still works.
+	      orig_export_symbols="$export_symbols"
+	      export_symbols=
+	      always_export_symbols=yes
+	    fi
+	  fi
+	  ;;
+	esac
+
+	# Prepare the list of exported symbols
+	if test -z "$export_symbols"; then
+	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+	    func_verbose "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $opt_dry_run || $RM $export_symbols
+	    cmds=$export_symbols_cmds
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      eval cmd=\"$cmd\"
+	      func_len " $cmd"
+	      len=$func_len_result
+	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+		func_show_eval "$cmd" 'exit $?'
+		skipped_export=false
+	      else
+		# The command line is too long to execute in one step.
+		func_verbose "using reloadable object file for export list..."
+		skipped_export=:
+		# Break out early, otherwise skipped_export may be
+		# set to false by a later but shorter cmd.
+		break
+	      fi
+	    done
+	    IFS="$save_ifs"
+	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+	fi
+
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  tmp_export_symbols="$export_symbols"
+	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	fi
+
+	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+	  # The given exports_symbols file has to be filtered, so filter it.
+	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	  # 's' commands which not all seds can handle. GNU sed should be fine
+	  # though. Also, the filter scales superlinearly with the number of
+	  # global variables. join(1) would be nice here, but unfortunately
+	  # isn't a blessed tool.
+	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	  export_symbols=$output_objdir/$libname.def
+	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	fi
+
+	tmp_deplibs=
+	for test_deplib in $deplibs; do
+	  case " $convenience " in
+	  *" $test_deplib "*) ;;
+	  *)
+	    tmp_deplibs="$tmp_deplibs $test_deplib"
+	    ;;
+	  esac
+	done
+	deplibs="$tmp_deplibs"
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec" &&
+	    test "$compiler_needs_object" = yes &&
+	    test -z "$libobjs"; then
+	    # extract the archives, so we have objects to list.
+	    # TODO: could optimize this to just extract one archive.
+	    whole_archive_flag_spec=
+	  fi
+	  if test -n "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    generated="$generated $gentop"
+
+	    func_extract_archives $gentop $convenience
+	    libobjs="$libobjs $func_extract_archives_result"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	fi
+
+	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	  eval flag=\"$thread_safe_flag_spec\"
+	  linker_flags="$linker_flags $flag"
+	fi
+
+	# Make a backup of the uninstalled library when relinking
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+	fi
+
+	# Do each of the archive commands.
+	if test "$module" = yes && test -n "$module_cmds" ; then
+	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	    eval test_cmds=\"$module_expsym_cmds\"
+	    cmds=$module_expsym_cmds
+	  else
+	    eval test_cmds=\"$module_cmds\"
+	    cmds=$module_cmds
+	  fi
+	else
+	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	    eval test_cmds=\"$archive_expsym_cmds\"
+	    cmds=$archive_expsym_cmds
+	  else
+	    eval test_cmds=\"$archive_cmds\"
+	    cmds=$archive_cmds
+	  fi
+	fi
+
+	if test "X$skipped_export" != "X:" &&
+	   func_len " $test_cmds" &&
+	   len=$func_len_result &&
+	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  :
+	else
+	  # The command line is too long to link in one step, link piecewise
+	  # or, if using GNU ld and skipped_export is not :, use a linker
+	  # script.
+
+	  # Save the value of $output and $libobjs because we want to
+	  # use them later.  If we have whole_archive_flag_spec, we
+	  # want to use save_libobjs as it was before
+	  # whole_archive_flag_spec was expanded, because we can't
+	  # assume the linker understands whole_archive_flag_spec.
+	  # This may have to be revisited, in case too many
+	  # convenience libraries get linked in and end up exceeding
+	  # the spec.
+	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+	    save_libobjs=$libobjs
+	  fi
+	  save_output=$output
+	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
+
+	  # Clear the reloadable object creation command queue and
+	  # initialize k to one.
+	  test_cmds=
+	  concat_cmds=
+	  objlist=
+	  last_robj=
+	  k=1
+
+	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+	    output=${output_objdir}/${output_la}.lnkscript
+	    func_verbose "creating GNU ld script: $output"
+	    $ECHO 'INPUT (' > $output
+	    for obj in $save_libobjs
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    $ECHO ')' >> $output
+	    delfiles="$delfiles $output"
+	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+	    output=${output_objdir}/${output_la}.lnk
+	    func_verbose "creating linker input file list: $output"
+	    : > $output
+	    set x $save_libobjs
+	    shift
+	    firstobj=
+	    if test "$compiler_needs_object" = yes; then
+	      firstobj="$1 "
+	      shift
+	    fi
+	    for obj
+	    do
+	      $ECHO "$obj" >> $output
+	    done
+	    delfiles="$delfiles $output"
+	    output=$firstobj\"$file_list_spec$output\"
+	  else
+	    if test -n "$save_libobjs"; then
+	      func_verbose "creating reloadable object files..."
+	      output=$output_objdir/$output_la-${k}.$objext
+	      eval test_cmds=\"$reload_cmds\"
+	      func_len " $test_cmds"
+	      len0=$func_len_result
+	      len=$len0
+
+	      # Loop over the list of objects to be linked.
+	      for obj in $save_libobjs
+	      do
+		func_len " $obj"
+		func_arith $len + $func_len_result
+		len=$func_arith_result
+		if test "X$objlist" = X ||
+		   test "$len" -lt "$max_cmd_len"; then
+		  func_append objlist " $obj"
+		else
+		  # The command $test_cmds is almost too long, add a
+		  # command to the queue.
+		  if test "$k" -eq 1 ; then
+		    # The first file doesn't have a previous command to add.
+		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+		  else
+		    # All subsequent reloadable object files will link in
+		    # the last one created.
+		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
+		  fi
+		  last_robj=$output_objdir/$output_la-${k}.$objext
+		  func_arith $k + 1
+		  k=$func_arith_result
+		  output=$output_objdir/$output_la-${k}.$objext
+		  objlist=$obj
+		  func_len " $last_robj"
+		  func_arith $len0 + $func_len_result
+		  len=$func_arith_result
+		fi
+	      done
+	      # Handle the remaining objects by creating one last
+	      # reloadable object file.  All subsequent reloadable object
+	      # files will link in the last one created.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+	      if test -n "$last_robj"; then
+	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+	      fi
+	      delfiles="$delfiles $output"
+
+	    else
+	      output=
+	    fi
+
+	    if ${skipped_export-false}; then
+	      func_verbose "generating symbol list for \`$libname.la'"
+	      export_symbols="$output_objdir/$libname.exp"
+	      $opt_dry_run || $RM $export_symbols
+	      libobjs=$output
+	      # Append the command to create the export file.
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+	      if test -n "$last_robj"; then
+		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+	      fi
+	    fi
+
+	    test -n "$save_libobjs" &&
+	      func_verbose "creating a temporary reloadable object file: $output"
+
+	    # Loop through the commands generated above and execute them.
+	    save_ifs="$IFS"; IFS='~'
+	    for cmd in $concat_cmds; do
+	      IFS="$save_ifs"
+	      $opt_silent || {
+		  func_quote_for_expand "$cmd"
+		  eval "func_echo $func_quote_for_expand_result"
+	      }
+	      $opt_dry_run || eval "$cmd" || {
+		lt_exit=$?
+
+		# Restore the uninstalled library and exit
+		if test "$mode" = relink; then
+		  ( cd "$output_objdir" && \
+		    $RM "${realname}T" && \
+		    $MV "${realname}U" "$realname" )
+		fi
+
+		exit $lt_exit
+	      }
+	    done
+	    IFS="$save_ifs"
+
+	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+
+          if ${skipped_export-false}; then
+	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	      tmp_export_symbols="$export_symbols"
+	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+	    fi
+
+	    if test -n "$orig_export_symbols"; then
+	      # The given exports_symbols file has to be filtered, so filter it.
+	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
+	      # 's' commands which not all seds can handle. GNU sed should be fine
+	      # though. Also, the filter scales superlinearly with the number of
+	      # global variables. join(1) would be nice here, but unfortunately
+	      # isn't a blessed tool.
+	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+	      export_symbols=$output_objdir/$libname.def
+	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+	    fi
+	  fi
+
+	  libobjs=$output
+	  # Restore the value of output.
+	  output=$save_output
+
+	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	    test "X$libobjs" = "X " && libobjs=
+	  fi
+	  # Expand the library linking commands again to reset the
+	  # value of $libobjs for piecewise linking.
+
+	  # Do each of the archive commands.
+	  if test "$module" = yes && test -n "$module_cmds" ; then
+	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+	      cmds=$module_expsym_cmds
+	    else
+	      cmds=$module_cmds
+	    fi
+	  else
+	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	      cmds=$archive_expsym_cmds
+	    else
+	      cmds=$archive_cmds
+	    fi
+	  fi
+	fi
+
+	if test -n "$delfiles"; then
+	  # Append the command to remove temporary files to $cmds.
+	  eval cmds=\"\$cmds~\$RM $delfiles\"
+	fi
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  libobjs="$libobjs $func_extract_archives_result"
+	  test "X$libobjs" = "X " && libobjs=
+	fi
+
+	save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  eval cmd=\"$cmd\"
+	  $opt_silent || {
+	    func_quote_for_expand "$cmd"
+	    eval "func_echo $func_quote_for_expand_result"
+	  }
+	  $opt_dry_run || eval "$cmd" || {
+	    lt_exit=$?
+
+	    # Restore the uninstalled library and exit
+	    if test "$mode" = relink; then
+	      ( cd "$output_objdir" && \
+	        $RM "${realname}T" && \
+		$MV "${realname}U" "$realname" )
+	    fi
+
+	    exit $lt_exit
+	  }
+	done
+	IFS="$save_ifs"
+
+	# Restore the uninstalled library and exit
+	if test "$mode" = relink; then
+	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+	  if test -n "$convenience"; then
+	    if test -z "$whole_archive_flag_spec"; then
+	      func_show_eval '${RM}r "$gentop"'
+	    fi
+	  fi
+
+	  exit $EXIT_SUCCESS
+	fi
+
+	# Create links to the real library.
+	for linkname in $linknames; do
+	  if test "$realname" != "$linkname"; then
+	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+	  fi
+	done
+
+	# If -module or -export-dynamic was specified, set the dlname.
+	if test "$module" = yes || test "$export_dynamic" = yes; then
+	  # On all known operating systems, these are identical.
+	  dlname="$soname"
+	fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	func_warning "\`-dlopen' is ignored for objects"
+      fi
+
+      case " $deplibs" in
+      *\ -l* | *\ -L*)
+	func_warning "\`-l' and \`-L' are ignored for objects" ;;
+      esac
+
+      test -n "$rpath" && \
+	func_warning "\`-rpath' is ignored for objects"
+
+      test -n "$xrpath" && \
+	func_warning "\`-R' is ignored for objects"
+
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for objects"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for objects"
+
+      case $output in
+      *.lo)
+	test -n "$objs$old_deplibs" && \
+	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+	libobj=$output
+	func_lo2o "$libobj"
+	obj=$func_lo2o_result
+	;;
+      *)
+	libobj=
+	obj="$output"
+	;;
+      esac
+
+      # Delete the old objects.
+      $opt_dry_run || $RM $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
+      wl=
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+	else
+	  gentop="$output_objdir/${obj}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $convenience
+	  reload_conv_objs="$reload_objs $func_extract_archives_result"
+	fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      func_execute_cmds "$reload_cmds" 'exit $?'
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+	if test -n "$gentop"; then
+	  func_show_eval '${RM}r "$gentop"'
+	fi
+
+	# Create an invalid libtool object if no PIC, so that we don't
+	# accidentally link it into a program.
+	# $show "echo timestamp > $libobj"
+	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+	exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+	# Only do commands if we really have different PIC objects.
+	reload_objs="$libobjs $reload_conv_objs"
+	output="$libobj"
+	func_execute_cmds "$reload_cmds" 'exit $?'
+      fi
+
+      if test -n "$gentop"; then
+	func_show_eval '${RM}r "$gentop"'
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+	*cygwin*) func_stripname '' '.exe' "$output"
+	          output=$func_stripname_result.exe;;
+      esac
+      test -n "$vinfo" && \
+	func_warning "\`-version-info' is ignored for programs"
+
+      test -n "$release" && \
+	func_warning "\`-release' is ignored for programs"
+
+      test "$preload" = yes \
+        && test "$dlopen_support" = unknown \
+	&& test "$dlopen_self" = unknown \
+	&& test "$dlopen_self_static" = unknown && \
+	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+	# On Rhapsody replace the C library is the System framework
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+	;;
+      esac
+
+      case $host in
+      *-*-darwin*)
+	# Don't allow lazy linking, it breaks C++ global constructors
+	# But is supposedly fixed on 10.4 or later (yay!).
+	if test "$tagname" = CXX ; then
+	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+	    10.[0123])
+	      compile_command="$compile_command ${wl}-bind_at_load"
+	      finalize_command="$finalize_command ${wl}-bind_at_load"
+	    ;;
+	  esac
+	fi
+	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
+	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+	;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+	case " $new_libs " in
+	*" -L$path/$objdir "*) ;;
+	*)
+	  case " $compile_deplibs " in
+	  *" -L$path/$objdir "*)
+	    new_libs="$new_libs -L$path/$objdir" ;;
+	  esac
+	  ;;
+	esac
+      done
+      for deplib in $compile_deplibs; do
+	case $deplib in
+	-L*)
+	  case " $new_libs " in
+	  *" $deplib "*) ;;
+	  *) new_libs="$new_libs $deplib" ;;
+	  esac
+	  ;;
+	*) new_libs="$new_libs $deplib" ;;
+	esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	for libdir in $rpath $xrpath; do
+	  # This is the magic to use -rpath.
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) perm_rpath="$perm_rpath $libdir" ;;
+	  esac
+	fi
+	case $host in
+	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+	  case :$dllsearchpath: in
+	  *":$libdir:"*) ;;
+	  ::) dllsearchpath=$libdir;;
+	  *) dllsearchpath="$dllsearchpath:$libdir";;
+	  esac
+	  case :$dllsearchpath: in
+	  *":$testbindir:"*) ;;
+	  ::) dllsearchpath=$testbindir;;
+	  *) dllsearchpath="$dllsearchpath:$testbindir";;
+	  esac
+	  ;;
+	esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$finalize_perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+	# Transform all the library objects into standard objects.
+	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+      # template prelinking step
+      if test -n "$prelink_cmds"; then
+	func_execute_cmds "$prelink_cmds" 'exit $?'
+      fi
+
+      wrappers_required=yes
+      case $host in
+      *cygwin* | *mingw* )
+        if test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      *cegcc)
+        # Disable wrappers for cegcc, we are cross compiling anyway.
+        wrappers_required=no
+        ;;
+      *)
+        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+          wrappers_required=no
+        fi
+        ;;
+      esac
+      if test "$wrappers_required" = no; then
+	# Replace the output file specification.
+	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	exit_status=0
+	func_show_eval "$link_command" 'exit_status=$?'
+
+	# Delete the generated files.
+	if test -f "$output_objdir/${outputname}S.${objext}"; then
+	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+	fi
+
+	exit $exit_status
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+	if test -n "$perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+	if test -n "$finalize_perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $finalize_perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+      fi
+
+      if test "$no_install" = yes; then
+	# We don't need to create a wrapper script.
+	link_command="$compile_var$compile_command$compile_rpath"
+	# Replace the output file specification.
+	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	# Delete the old output file.
+	$opt_dry_run || $RM $output
+	# Link the executable and exit
+	func_show_eval "$link_command" 'exit $?'
+	exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+	# Fast installation is not supported
+	link_command="$compile_var$compile_command$compile_rpath"
+	relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+	func_warning "this platform does not like uninstalled shared libraries"
+	func_warning "\`$output' will be relinked during installation"
+      else
+	if test "$fast_install" != no; then
+	  link_command="$finalize_var$compile_command$finalize_rpath"
+	  if test "$fast_install" = yes; then
+	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	  else
+	    # fast_install is set to needless
+	    relink_command=
+	  fi
+	else
+	  link_command="$compile_var$compile_command$compile_rpath"
+	  relink_command="$finalize_var$finalize_command$finalize_rpath"
+	fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      func_show_eval "$link_command" 'exit $?'
+
+      # Now create the wrapper script.
+      func_verbose "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+	# Preserve any variables that may affect compiler behavior
+	for var in $variables_saved_for_relink; do
+	  if eval test -z \"\${$var+set}\"; then
+	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	  elif eval var_value=\$$var; test -z "$var_value"; then
+	    relink_command="$var=; export $var; $relink_command"
+	  else
+	    func_quote_for_eval "$var_value"
+	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	  fi
+	done
+	relink_command="(cd `pwd`; $relink_command)"
+	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $ECHO for shipping.
+      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
+	case $progpath in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+	esac
+	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if not in dry run mode.
+      $opt_dry_run || {
+	# win32 will think the script is a binary if it has
+	# a .exe suffix, so we strip it off here.
+	case $output in
+	  *.exe) func_stripname '' '.exe' "$output"
+	         output=$func_stripname_result ;;
+	esac
+	# test for cygwin because mv fails w/o .exe extensions
+	case $host in
+	  *cygwin*)
+	    exeext=.exe
+	    func_stripname '' '.exe' "$outputname"
+	    outputname=$func_stripname_result ;;
+	  *) exeext= ;;
+	esac
+	case $host in
+	  *cygwin* | *mingw* )
+	    func_dirname_and_basename "$output" "" "."
+	    output_name=$func_basename_result
+	    output_path=$func_dirname_result
+	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
+	    cwrapper="$output_path/$output_name.exe"
+	    $RM $cwrappersource $cwrapper
+	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_cwrapperexe_src > $cwrappersource
+
+	    # The wrapper executable is built using the $host compiler,
+	    # because it contains $host paths and files. If cross-
+	    # compiling, it, like the target executable, must be
+	    # executed on the $host or under an emulation environment.
+	    $opt_dry_run || {
+	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+	      $STRIP $cwrapper
+	    }
+
+	    # Now, create the wrapper script for func_source use:
+	    func_ltwrapper_scriptname $cwrapper
+	    $RM $func_ltwrapper_scriptname_result
+	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+	    $opt_dry_run || {
+	      # note: this script will not be executed, so do not chmod.
+	      if test "x$build" = "x$host" ; then
+		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+	      else
+		func_emit_wrapper no > $func_ltwrapper_scriptname_result
+	      fi
+	    }
+	  ;;
+	  * )
+	    $RM $output
+	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+	    func_emit_wrapper no > $output
+	    chmod +x $output
+	  ;;
+	esac
+      }
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+	oldobjs="$libobjs_save $symfileobj"
+	addlibs="$convenience"
+	build_libtool_libs=no
+      else
+	if test "$build_libtool_libs" = module; then
+	  oldobjs="$libobjs_save"
+	  build_libtool_libs=no
+	else
+	  oldobjs="$old_deplibs $non_pic_objects"
+	  if test "$preload" = yes && test -f "$symfileobj"; then
+	    oldobjs="$oldobjs $symfileobj"
+	  fi
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	generated="$generated $gentop"
+
+	func_extract_archives $gentop $addlibs
+	oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+	cmds=$old_archive_from_new_cmds
+      else
+
+	# Add any objects from preloaded convenience libraries
+	if test -n "$dlprefiles"; then
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+
+	  func_extract_archives $gentop $dlprefiles
+	  oldobjs="$oldobjs $func_extract_archives_result"
+	fi
+
+	# POSIX demands no paths to be encoded in archives.  We have
+	# to avoid creating archives with duplicate basenames if we
+	# might have to extract them afterwards, e.g., when creating a
+	# static archive out of a convenience library, or when linking
+	# the entirety of a libtool archive into another (currently
+	# not supported by libtool).
+	if (for obj in $oldobjs
+	    do
+	      func_basename "$obj"
+	      $ECHO "$func_basename_result"
+	    done | sort | sort -uc >/dev/null 2>&1); then
+	  :
+	else
+	  $ECHO "copying selected object files to avoid basename conflicts..."
+	  gentop="$output_objdir/${outputname}x"
+	  generated="$generated $gentop"
+	  func_mkdir_p "$gentop"
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  counter=1
+	  for obj in $save_oldobjs
+	  do
+	    func_basename "$obj"
+	    objbase="$func_basename_result"
+	    case " $oldobjs " in
+	    " ") oldobjs=$obj ;;
+	    *[\ /]"$objbase "*)
+	      while :; do
+		# Make sure we don't pick an alternate name that also
+		# overlaps.
+		newobj=lt$counter-$objbase
+		func_arith $counter + 1
+		counter=$func_arith_result
+		case " $oldobjs " in
+		*[\ /]"$newobj "*) ;;
+		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
+		esac
+	      done
+	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+	      oldobjs="$oldobjs $gentop/$newobj"
+	      ;;
+	    *) oldobjs="$oldobjs $obj" ;;
+	    esac
+	  done
+	fi
+	eval cmds=\"$old_archive_cmds\"
+
+	func_len " $cmds"
+	len=$func_len_result
+	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+	  cmds=$old_archive_cmds
+	else
+	  # the command line is too long to link in one step, link in parts
+	  func_verbose "using piecewise archive linking..."
+	  save_RANLIB=$RANLIB
+	  RANLIB=:
+	  objlist=
+	  concat_cmds=
+	  save_oldobjs=$oldobjs
+	  oldobjs=
+	  # Is there a better way of finding the last object in the list?
+	  for obj in $save_oldobjs
+	  do
+	    last_oldobj=$obj
+	  done
+	  eval test_cmds=\"$old_archive_cmds\"
+	  func_len " $test_cmds"
+	  len0=$func_len_result
+	  len=$len0
+	  for obj in $save_oldobjs
+	  do
+	    func_len " $obj"
+	    func_arith $len + $func_len_result
+	    len=$func_arith_result
+	    func_append objlist " $obj"
+	    if test "$len" -lt "$max_cmd_len"; then
+	      :
+	    else
+	      # the above command should be used before it gets too long
+	      oldobjs=$objlist
+	      if test "$obj" = "$last_oldobj" ; then
+		RANLIB=$save_RANLIB
+	      fi
+	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+	      objlist=
+	      len=$len0
+	    fi
+	  done
+	  RANLIB=$save_RANLIB
+	  oldobjs=$objlist
+	  if test "X$oldobjs" = "X" ; then
+	    eval cmds=\"\$concat_cmds\"
+	  else
+	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+	  fi
+	fi
+      fi
+      func_execute_cmds "$cmds" 'exit $?'
+    done
+
+    test -n "$generated" && \
+      func_show_eval "${RM}r$generated"
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      func_verbose "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+	if eval test -z \"\${$var+set}\"; then
+	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+	elif eval var_value=\$$var; test -z "$var_value"; then
+	  relink_command="$var=; export $var; $relink_command"
+	else
+	  func_quote_for_eval "$var_value"
+	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+	fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+	relink_command=
+      fi
+
+      # Only create the output if not a dry run.
+      $opt_dry_run || {
+	for installed in no yes; do
+	  if test "$installed" = yes; then
+	    if test -z "$install_libdir"; then
+	      break
+	    fi
+	    output="$output_objdir/$outputname"i
+	    # Replace all uninstalled libtool libraries with the installed ones
+	    newdependency_libs=
+	    for deplib in $dependency_libs; do
+	      case $deplib in
+	      *.la)
+		func_basename "$deplib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$deplib' is not a valid libtool archive"
+		newdependency_libs="$newdependency_libs $libdir/$name"
+		;;
+	      *) newdependency_libs="$newdependency_libs $deplib" ;;
+	      esac
+	    done
+	    dependency_libs="$newdependency_libs"
+	    newdlfiles=
+
+	    for lib in $dlfiles; do
+	      case $lib in
+	      *.la)
+	        func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlfiles="$newdlfiles $libdir/$name"
+		;;
+	      *) newdlfiles="$newdlfiles $lib" ;;
+	      esac
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+	      *.la)
+		# Only pass preopened files to the pseudo-archive (for
+		# eventual linking with the app. that links it) if we
+		# didn't already link the preopened objects directly into
+		# the library:
+		func_basename "$lib"
+		name="$func_basename_result"
+		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+		test -z "$libdir" && \
+		  func_fatal_error "\`$lib' is not a valid libtool archive"
+		newdlprefiles="$newdlprefiles $libdir/$name"
+		;;
+	      esac
+	    done
+	    dlprefiles="$newdlprefiles"
+	  else
+	    newdlfiles=
+	    for lib in $dlfiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlfiles="$newdlfiles $abs"
+	    done
+	    dlfiles="$newdlfiles"
+	    newdlprefiles=
+	    for lib in $dlprefiles; do
+	      case $lib in
+		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+		*) abs=`pwd`"/$lib" ;;
+	      esac
+	      newdlprefiles="$newdlprefiles $abs"
+	    done
+	    dlprefiles="$newdlprefiles"
+	  fi
+	  $RM $output
+	  # place dlname in correct position for cygwin
+	  tdlname=$dlname
+	  case $host,$output,$installed,$module,$dlname in
+	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+	  esac
+	  $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+	  if test "$installed" = no && test "$need_relink" = yes; then
+	    $ECHO >> $output "\
+relink_command=\"$relink_command\""
+	  fi
+	done
+      }
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+    func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+    $opt_debug
+    RM="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) RM="$RM $arg"; rmforce=yes ;;
+      -*) RM="$RM $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    test -z "$RM" && \
+      func_fatal_help "you must specify an RM program"
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      func_dirname "$file" "" "."
+      dir="$func_dirname_result"
+      if test "X$dir" = X.; then
+	objdir="$origobjdir"
+      else
+	objdir="$dir/$origobjdir"
+      fi
+      func_basename "$file"
+      name="$func_basename_result"
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+	case " $rmdirs " in
+	  *" $objdir "*) ;;
+	  *) rmdirs="$rmdirs $objdir" ;;
+	esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if { test -L "$file"; } >/dev/null 2>&1 ||
+	 { test -h "$file"; } >/dev/null 2>&1 ||
+	 test -f "$file"; then
+	:
+      elif test -d "$file"; then
+	exit_status=1
+	continue
+      elif test "$rmforce" = yes; then
+	continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+	# Possibly a libtool archive, so verify it.
+	if func_lalib_p "$file"; then
+	  func_source $dir/$name
+
+	  # Delete the libtool libraries and symlinks.
+	  for n in $library_names; do
+	    rmfiles="$rmfiles $objdir/$n"
+	  done
+	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+	  case "$mode" in
+	  clean)
+	    case "  $library_names " in
+	    # "  " in the beginning catches empty $dlname
+	    *" $dlname "*) ;;
+	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
+	    esac
+	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+	    ;;
+	  uninstall)
+	    if test -n "$library_names"; then
+	      # Do each command in the postuninstall commands.
+	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+
+	    if test -n "$old_library"; then
+	      # Do each command in the old_postuninstall commands.
+	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+	    fi
+	    # FIXME: should reinstall the best remaining shared library.
+	    ;;
+	  esac
+	fi
+	;;
+
+      *.lo)
+	# Possibly a libtool object, so verify it.
+	if func_lalib_p "$file"; then
+
+	  # Read the .lo file
+	  func_source $dir/$name
+
+	  # Add PIC object to the list of files to remove.
+	  if test -n "$pic_object" &&
+	     test "$pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$pic_object"
+	  fi
+
+	  # Add non-PIC object to the list of files to remove.
+	  if test -n "$non_pic_object" &&
+	     test "$non_pic_object" != none; then
+	    rmfiles="$rmfiles $dir/$non_pic_object"
+	  fi
+	fi
+	;;
+
+      *)
+	if test "$mode" = clean ; then
+	  noexename=$name
+	  case $file in
+	  *.exe)
+	    func_stripname '' '.exe' "$file"
+	    file=$func_stripname_result
+	    func_stripname '' '.exe' "$name"
+	    noexename=$func_stripname_result
+	    # $file with .exe has already been added to rmfiles,
+	    # add $file without .exe
+	    rmfiles="$rmfiles $file"
+	    ;;
+	  esac
+	  # Do a test to see if this is a libtool program.
+	  if func_ltwrapper_p "$file"; then
+	    if func_ltwrapper_executable_p "$file"; then
+	      func_ltwrapper_scriptname "$file"
+	      relink_command=
+	      func_source $func_ltwrapper_scriptname_result
+	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+	    else
+	      relink_command=
+	      func_source $dir/$noexename
+	    fi
+
+	    # note $name still contains .exe if it was in $file originally
+	    # as does the version of $file that was added into $rmfiles
+	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+	    if test "$fast_install" = yes && test -n "$relink_command"; then
+	      rmfiles="$rmfiles $objdir/lt-$name"
+	    fi
+	    if test "X$noexename" != "X$name" ; then
+	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+	    fi
+	  fi
+	fi
+	;;
+      esac
+      func_show_eval "$RM $rmfiles" 'exit_status=1'
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+	func_show_eval "rmdir $dir >/dev/null 2>&1"
+      fi
+    done
+
+    exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+    func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+  help="$generic_help"
+  func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+  func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+  eval exec "$exec_cmd"
+  exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/config/missing b/config/missing
new file mode 100755
index 0000000..28055d2
--- /dev/null
+++ b/config/missing
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  autom4te     touch the output file, or create a stub one
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake at gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).  This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+  lex*|yacc*)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar*)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case $f in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  autom4te*)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo "#! /bin/sh"
+	echo "# Created by GNU Automake missing as a replacement of"
+	echo "#  $ $@"
+	echo "exit 0"
+	chmod +x $file
+	exit 1
+    fi
+    ;;
+
+  bison*|yacc*)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f y.tab.h; then
+	echo >y.tab.h
+    fi
+    if test ! -f y.tab.c; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex*|flex*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if test $# -ne 1; then
+        eval LASTARG="\${$#}"
+	case $LASTARG in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if test -f "$SRCFILE"; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if test ! -f lex.yy.c; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+	 you modified a dependency of a manual page.  You may need the
+	 \`Help2man' package in order for those modifications to take
+	 effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -f "$file"; then
+	touch $file
+    else
+	test -z "$file" || exec >$file
+	echo ".ab help2man is required to generate this page"
+	exit $?
+    fi
+    ;;
+
+  makeinfo*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n "$sed_output"`
+    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '
+	/^@setfilename/{
+	  s/.* \([^ ]*\) *$/\1/
+	  p
+	  q
+	}' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar*)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+	case $firstarg in
+	*o*)
+	    firstarg=`echo "$firstarg" | sed s/o//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+	case $firstarg in
+	*h*)
+	    firstarg=`echo "$firstarg" | sed s/h//`
+	    tar "$firstarg" "$@" && exit 0
+	    ;;
+	esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/config/py-compile b/config/py-compile
new file mode 100755
index 0000000..3f9d05b
--- /dev/null
+++ b/config/py-compile
@@ -0,0 +1,146 @@
+#!/bin/sh
+# py-compile - Compile a Python program
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2008, 2009 Free Software
+# Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+if [ -z "$PYTHON" ]; then
+  PYTHON=python
+fi
+
+basedir=
+destdir=
+files=
+while test $# -ne 0; do
+  case "$1" in
+    --basedir)
+      basedir=$2
+      if test -z "$basedir"; then
+        echo "$0: Missing argument to --basedir." 1>&2
+        exit 1
+      fi
+      shift
+      ;;
+    --destdir)
+      destdir=$2
+      if test -z "$destdir"; then
+        echo "$0: Missing argument to --destdir." 1>&2
+        exit 1
+      fi
+      shift
+      ;;
+    -h|--h*)
+      cat <<\EOF
+Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
+
+Byte compile some python scripts FILES.  Use --destdir to specify any
+leading directory path to the FILES that you don't want to include in the
+byte compiled file.  Specify --basedir for any additional path information you
+do want to be shown in the byte compiled file.
+
+Example:
+  py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+      exit $?
+      ;;
+    -v|--v*)
+      echo "py-compile $scriptversion"
+      exit $?
+      ;;
+    *)
+      files="$files $1"
+      ;;
+  esac
+  shift
+done
+
+if test -z "$files"; then
+    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
+    exit 1
+fi
+
+# if basedir was given, then it should be prepended to filenames before
+# byte compilation.
+if [ -z "$basedir" ]; then
+    pathtrans="path = file"
+else
+    pathtrans="path = os.path.join('$basedir', file)"
+fi
+
+# if destdir was given, then it needs to be prepended to the filename to
+# byte compile but not go into the compiled file.
+if [ -z "$destdir" ]; then
+    filetrans="filepath = path"
+else
+    filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
+fi
+
+$PYTHON -c "
+import sys, os, py_compile
+
+files = '''$files'''
+
+sys.stdout.write('Byte-compiling python modules...\n')
+for file in files.split():
+    $pathtrans
+    $filetrans
+    if not os.path.exists(filepath) or not (len(filepath) >= 3
+                                            and filepath[-3:] == '.py'):
+	    continue
+    sys.stdout.write(file)
+    sys.stdout.flush()
+    py_compile.compile(filepath, filepath + 'c', path)
+sys.stdout.write('\n')" || exit $?
+
+# this will fail for python < 1.5, but that doesn't matter ...
+$PYTHON -O -c "
+import sys, os, py_compile
+
+files = '''$files'''
+sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
+for file in files.split():
+    $pathtrans
+    $filetrans
+    if not os.path.exists(filepath) or not (len(filepath) >= 3
+                                            and filepath[-3:] == '.py'):
+	    continue
+    sys.stdout.write(file)
+    sys.stdout.flush()
+    py_compile.compile(filepath, filepath + 'o', path)
+sys.stdout.write('\n')" 2>/dev/null || :
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/configure b/configure
new file mode 100755
index 0000000..65e9252
--- /dev/null
+++ b/configure
@@ -0,0 +1,24632 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.65 for MagPlus 2.
+#
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     # Try only shells that exist, to save several forks.
+	     as_shell=$as_dir/$as_base
+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+	   done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+	# neutralization value for shells without unset; and this also
+	# works around shells that cannot unset nonexistent variables.
+	BASH_ENV=/dev/null
+	ENV=/dev/null
+	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+	export CONFIG_SHELL
+	exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf at gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
+  ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<_LT_EOF
+$*
+_LT_EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+  if test "X${echo_test_string+set}" != Xset; then
+    # find a string as large as possible, as long as the shell can cope with it
+    for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+      # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+      if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+	 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+      then
+        break
+      fi
+    done
+  fi
+
+  if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+     echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+     test "X$echo_testing_string" = "X$echo_test_string"; then
+    :
+  else
+    # The Solaris, AIX, and Digital Unix default echo programs unquote
+    # backslashes.  This makes it impossible to quote backslashes using
+    #   echo "$something" | sed 's/\\/\\\\/g'
+    #
+    # So, first we look for a working echo in the user's PATH.
+
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for dir in $PATH /usr/ucb; do
+      IFS="$lt_save_ifs"
+      if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+         test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        ECHO="$dir/echo"
+        break
+      fi
+    done
+    IFS="$lt_save_ifs"
+
+    if test "X$ECHO" = Xecho; then
+      # We didn't find a better echo, so look for alternatives.
+      if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        # This shell has a builtin print -r that does the trick.
+        ECHO='print -r'
+      elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+	   test "X$CONFIG_SHELL" != X/bin/ksh; then
+        # If we have ksh, try running configure again with it.
+        ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+        export ORIGINAL_CONFIG_SHELL
+        CONFIG_SHELL=/bin/ksh
+        export CONFIG_SHELL
+        exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+      else
+        # Try using printf.
+        ECHO='printf %s\n'
+        if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+	   echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	  # Cool, printf works
+	  :
+        elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	  export CONFIG_SHELL
+	  SHELL="$CONFIG_SHELL"
+	  export SHELL
+	  ECHO="$CONFIG_SHELL $0 --fallback-echo"
+        elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  ECHO="$CONFIG_SHELL $0 --fallback-echo"
+        else
+	  # maybe with a smaller string...
+	  prev=:
+
+	  for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+	    if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+	    then
+	      break
+	    fi
+	    prev="$cmd"
+	  done
+
+	  if test "$prev" != 'sed 50q "$0"'; then
+	    echo_test_string=`eval $prev`
+	    export echo_test_string
+	    exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+	  else
+	    # Oops.  We lost completely, so just stick with echo.
+	    ECHO=echo
+	  fi
+        fi
+      fi
+    fi
+  fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+as_awk_strverscmp='
+  # Use only awk features that work with 7th edition Unix awk (1978).
+  # My, what an old awk you have, Mr. Solaris!
+  END {
+    while (length(v1) && length(v2)) {
+      # Set d1 to be the next thing to compare from v1, and likewise for d2.
+      # Normally this is a single character, but if v1 and v2 contain digits,
+      # compare them as integers and fractions as strverscmp does.
+      if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
+	# Split v1 and v2 into their leading digit string components d1 and d2,
+	# and advance v1 and v2 past the leading digit strings.
+	for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
+	for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
+	d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
+	d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
+	if (d1 ~ /^0/) {
+	  if (d2 ~ /^0/) {
+	    # Compare two fractions.
+	    while (d1 ~ /^0/ && d2 ~ /^0/) {
+	      d1 = substr(d1, 2); len1--
+	      d2 = substr(d2, 2); len2--
+	    }
+	    if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
+	      # The two components differ in length, and the common prefix
+	      # contains only leading zeros.  Consider the longer to be less.
+	      d1 = -len1
+	      d2 = -len2
+	    } else {
+	      # Otherwise, compare as strings.
+	      d1 = "x" d1
+	      d2 = "x" d2
+	    }
+	  } else {
+	    # A fraction is less than an integer.
+	    exit 1
+	  }
+	} else {
+	  if (d2 ~ /^0/) {
+	    # An integer is greater than a fraction.
+	    exit 2
+	  } else {
+	    # Compare two integers.
+	    d1 += 0
+	    d2 += 0
+	  }
+	}
+      } else {
+	# The normal case, without worrying about digits.
+	d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
+	d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
+      }
+      if (d1 < d2) exit 1
+      if (d1 > d2) exit 2
+    }
+    # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
+    # which mishandles some comparisons of empty strings to integers.
+    if (length(v2)) exit 1
+    if (length(v1)) exit 2
+  }
+'
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='MagPlus'
+PACKAGE_TARNAME='magplus'
+PACKAGE_VERSION='2'
+PACKAGE_STRING='MagPlus 2'
+PACKAGE_BUGREPORT=''
+PACKAGE_URL=''
+
+ac_unique_file="src/MagicsDouble.cc"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+MAGICS_MAC_FALSE
+MAGICS_MAC_TRUE
+MAGICS_PROJ4_FALSE
+MAGICS_PROJ4_TRUE
+MAGICS_THREADS_FALSE
+MAGICS_THREADS_TRUE
+MAGICS_ALLHEADERS_FALSE
+MAGICS_ALLHEADERS_TRUE
+MAGICS_PYTHON_FALSE
+MAGICS_PYTHON_TRUE
+MAGICS_RASTER_FALSE
+MAGICS_RASTER_TRUE
+MAGICS_TIFF_FALSE
+MAGICS_TIFF_TRUE
+MAGICS_CAIRO_FALSE
+MAGICS_CAIRO_TRUE
+MAGICS_QTDEBUG_FALSE
+MAGICS_QTDEBUG_TRUE
+MAGICS_QT_FALSE
+MAGICS_QT_TRUE
+MAGICS_METGRAM_FALSE
+MAGICS_METGRAM_TRUE
+MAGICS_NETCDF_FALSE
+MAGICS_NETCDF_TRUE
+MAGICS_GRIB_FALSE
+MAGICS_GRIB_TRUE
+MAGICS_SPOT_FALSE
+MAGICS_SPOT_TRUE
+MAGICS_EXCEPTION_FALSE
+MAGICS_EXCEPTION_TRUE
+MAGICS_ODB_FALSE
+MAGICS_ODB_TRUE
+MAGICS_JSON_FALSE
+MAGICS_JSON_TRUE
+MAGICS_BUFR_FALSE
+MAGICS_BUFR_TRUE
+MAGICS_APPS_FALSE
+MAGICS_APPS_TRUE
+MAGICS_32BIT_FALSE
+MAGICS_32BIT_TRUE
+MAGICS_METVIEW_FALSE
+MAGICS_METVIEW_TRUE
+LIBNAME
+MAGICS_3RDPARTY_LIBS
+MAGICS_3RDPARTY_INCLUDE
+GSVersion
+ghostscript_font_dir
+PSDelegate
+cairo
+CAIRO_LIBS
+CAIRO_CFLAGS
+PKG_CONFIG
+raster
+proj4
+spot
+bufr
+EMOS_LIB_NAME
+FORTRAN_LIB_PATH
+GRIBAPI_ROOT
+GRIBAPI_LIBS
+BOOST_LDFLAGS
+BOOST_CPPFLAGS
+odb
+ODB_PATH
+qt
+metview
+QT_VERSION
+QT_LIBS
+QT_LDFLAGS
+QT_LFLAGS
+QT_CPPFLAGS
+QT_INCPATH
+QT_CXXFLAGS
+QT_CFLAGS
+QT_DEFINES
+QT_VERSION_MAJOR
+RCC
+UIC
+MOC
+QMAKE
+QT_PATH
+FLIBS
+FLIB
+MAGICS_VISIBILITY
+CPPLIBS
+PLATFORM_DEFINES_MARS
+SHLIB_EXT
+AXX
+python
+NUMPY_INCLUDE
+pkgpyexecdir
+pyexecdir
+pkgpythondir
+pythondir
+PYTHON_PLATFORM
+PYTHON_EXEC_PREFIX
+PYTHON_PREFIX
+PYTHON_VERSION
+PYTHON
+PKGCONFIG_REQUIRES
+ac_ct_F77
+FFLAGS
+F77
+CXXCPP
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+ac_ct_CXX
+CXXFLAGS
+CXX
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+lt_ECHO
+RANLIB
+AR
+OBJDUMP
+LN_S
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+SED
+LIBTOOL
+EGREP
+GREP
+CPP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+MAGICS_PACKAGE_VERSION_ADDENDUM
+MAGICS_PACKAGE_COPYRIGHT_PERIOD
+MAGICS_PACKAGE_RELEASE_DATE
+MAGICS_PACKAGE_VERSION
+MAGICS_PACKAGE_NAME
+MAGICS_LIBRARY_AGE
+MAGICS_LIBRARY_REVISION
+MAGICS_LIBRARY_CURRENT
+SITE_NAME
+target_os
+target_vendor
+target_cpu
+target
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+with_site
+enable_silent_rules
+enable_static
+enable_dependency_tracking
+enable_shared
+with_pic
+enable_fast_install
+with_gnu_ld
+enable_libtool_lock
+enable_metview
+enable_threads
+enable_python
+enable_32_bits_addressing_mode
+enable_exception
+enable_allheaders
+enable_qt
+with_qt
+enable_qtdebug
+enable_raster
+with_gd
+enable_json
+enable_apps
+enable_bufr
+enable_odb
+with_odb
+enable_magnext
+with_boost
+with_boost_libdir
+enable_grib
+with_grib_api
+with_fortran_libraries
+with_emos_libraries
+with_emos_libname
+enable_spot
+with_spot
+enable_proj4
+with_proj4
+enable_netcdf
+with_netcdf
+enable_cairo
+with_gs_font_dir
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP
+CXX
+CXXFLAGS
+CCC
+CXXCPP
+F77
+FFLAGS
+QT_PATH
+QMAKE
+MOC
+UIC
+RCC
+PKG_CONFIG
+CAIRO_CFLAGS
+CAIRO_LIBS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures MagPlus 2 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/magplus]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+  --target=TARGET   configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of MagPlus 2:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-silent-rules          less verbose build output (undo: `make V=1')
+  --disable-silent-rules         verbose build output (undo: `make V=0')
+  --enable-static[=PKGS]  build static libraries [default=no]
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-shared[=PKGS]  build shared libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-metview	  enable Metview 4 interface. [default=no]
+
+  --enable-python	  enable Python interface. [default=no]
+  --enable-32-bits-addressing-mode
+                          Force 32 bits addressing mode on 64 bits machines
+  --enable-exception	  enable the use of all C++ exceptions (Not recommended for static library using PGF90!) [default=yes]
+  --enable-allheaders	  install all header files [default=no]
+  --enable-qt             enable Qt-based modules [default=no]
+  --enable-qtdebug             enable QDebug output in Qt-based modules [default=no]
+  --enable-raster         enable the GIF, PNG and JPEG output [default=yes]
+  --enable-json	          enable the JSON support (JSON) [default=yes]
+  --enable-apps	          enable the compilation of applications (magml) [default=yes]
+  --enable-bufr	          enable the BUFR support [default=no]
+  --enable-odb	          enable the ODB support [default=no]
+  --enable-magnext      enable update developments for metview (ECMWF only) [default=false]
+  --enable-grib	          enable the GRIB 1/2 support [default=yes]
+  --enable-spot	          enable the SPOT support for metgrams (ECMWF internal) [default=no]
+  --enable-proj4	          enable the Proj4 support for projections [default=yes]
+  --enable-netcdf	          enable the netCDF support [default=yes]
+  --enable-cairo          enable the Cairo library support [default=yes]
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-site             Name of installation site
+  --with-pic              try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-qt               Path to Qt [Look in PATH and /usr/local/Trolltech]
+  --with-gd               Prefix of GD libraries and headers.
+  --with-odb              Prefix of ODB libraries and headers.
+  --with-boost[=ARG]      use Boost library from a standard location
+                          (ARG=yes), from the specified location (ARG=<path>),
+                          or disable it (ARG=no) [ARG=yes]
+  --with-boost-libdir=LIB_DIR
+                          Force given directory for boost libraries. Note that
+                          this will override library path detection, so use
+                          this parameter only if default library detection
+                          fails and you know exactly where your boost
+                          libraries are located.
+  --with-grib-api         Prefix of GRIB API libraries and headers.
+  --with-fortran-libraries
+                          Locaction of Fortran runtime libraries required for
+                          EMOS library [default is /usr/lib]
+  --with-emos-libraries   Locaction of EMOS library [default is
+                          /usr/local/lib]
+  --with-emos-libname     Name of EMOS library [default is emosR64]
+  --with-spot             Prefix of SPOT libraries and headers.
+  --with-proj4            Prefix of Proj4 libraries and headers.
+  --with-netcdf           Prefix of NetCDF libraries and headers.
+  --with-gs-font-dir=DIR  Directory containing Ghostscript fonts.
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  CXXCPP      C++ preprocessor
+  F77         Fortran 77 compiler command
+  FFLAGS      Fortran 77 compiler flags
+  QT_PATH     Path to the Qt installation
+  QMAKE       Qt Makefile generator command
+  MOC         Qt Meta Object Compiler command
+  UIC         Qt User Interface Compiler command
+  RCC         Qt Resource Compiler command
+  PKG_CONFIG  path to pkg-config utility
+  CAIRO_CFLAGS
+              C compiler flags for CAIRO, overriding pkg-config
+  CAIRO_LIBS  linker flags for CAIRO, overriding pkg-config
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+MagPlus configure 2
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_func
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } >/dev/null && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_cpp
+
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
+# ac_fn_f77_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_f77_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_f77_try_compile
+
+# ac_fn_f77_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_f77_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_f77_try_link
+
+# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
+# ---------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_cxx_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_cxx_check_header_mongrel
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by MagPlus $as_me 2, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+	ac_must_keep_next=false # Got value, back to normal.
+      else
+	case $ac_arg in
+	  *=* | --config-cache | -C | -disable-* | --disable-* \
+	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+	  | -with-* | --with-* | -without-* | --without-* | --x)
+	    case "$ac_configure_args0 " in
+	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+	    esac
+	    ;;
+	  -* ) ac_must_keep_next=true ;;
+	esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	$as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=`echo x $ac_old_val`
+	ac_new_val_w=`echo x $ac_new_val`
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_aux_dir=
+for ac_dir in config "$srcdir"/config; do
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
+$as_echo_n "checking target system type... " >&6; }
+if test "${ac_cv_target+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$target_alias" = x; then
+  ac_cv_target=$ac_cv_host
+else
+  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
+$as_echo "$ac_cv_target" >&6; }
+case $ac_cv_target in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
+esac
+target=$ac_cv_target
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_target
+shift
+target_cpu=$1
+target_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+target_os=$*
+IFS=$ac_save_IFS
+case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+  test "$program_prefix$program_suffix$program_transform_name" = \
+    NONENONEs,x,x, &&
+  program_prefix=${target_alias}-
+
+
+# Source file containing package/library versioning information.
+. ${srcdir}/version.sh
+
+MAGICS_OUTPUTS="PS_EPS_PDF_SVG_KML"
+
+SITE_NAME="outside"
+
+# Check whether --with-site was given.
+if test "${with_site+set}" = set; then :
+  withval=$with_site; SITE_NAME="$with_site"
+
+fi
+
+
+
+
+if test "x$prefix" != xNONE; then
+  ac_default_prefix=${prefix}
+else
+  prefix=${ac_default_prefix}
+fi
+includedir=${prefix}/include/magics
+
+echo ""
+echo "configuring ${MAGICS_PACKAGE_NAME} ${MAGICS_PACKAGE_VERSION}${MAGICS_PACKAGE_VERSION_ADDENDUM} at ${SITE_NAME}"
+echo ""
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_VERSION "${MAGICS_PACKAGE_VERSION}"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_NAME "${MAGICS_PACKAGE_NAME}"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_RELEASE_DATE "${MAGICS_PACKAGE_RELEASE_DATE}"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_COPYRIGHT_PERIOD "${MAGICS_PACKAGE_COPYRIGHT_PERIOD}"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_INSTALL_PATH "${prefix}"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_SITE "${SITE_NAME}"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_TTF_PATH "share/magics/ttf/"
+_ACEOF
+
+
+
+
+
+ac_config_headers="$ac_config_headers src/magics_config.h"
+
+
+am__api_version='1.11'
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	  if test $ac_prog = install &&
+	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # AIX install.  It has an incompatible calling convention.
+	    :
+	  elif test $ac_prog = install &&
+	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # program-specific install script used by HP pwplus--don't use.
+	    :
+	  else
+	    rm -rf conftest.one conftest.two conftest.dir
+	    echo one > conftest.one
+	    echo two > conftest.two
+	    mkdir conftest.dir
+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+	      test -s conftest.one && test -s conftest.two &&
+	      test -s conftest.dir/conftest.one &&
+	      test -s conftest.dir/conftest.two
+	    then
+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	      break 3
+	    fi
+	  fi
+	fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \	]*)
+    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" "$LINENO" 5
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+	 for ac_exec_ext in '' $ac_executable_extensions; do
+	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+	     'mkdir (GNU coreutils) '* | \
+	     'mkdir (coreutils) '* | \
+	     'mkdir (fileutils) '4.1*)
+	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+	       break 3;;
+	   esac
+	 done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE=$MAGICS_PACKAGE_NAME
+ VERSION="${MAGICS_PACKAGE_VERSION}${MAGICS_PACKAGE_VERSION_ADDENDUM}"
+
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in
+yes) AM_DEFAULT_VERBOSITY=0;;
+no)  AM_DEFAULT_VERBOSITY=1;;
+*)   AM_DEFAULT_VERBOSITY=0;;
+esac
+AM_BACKSLASH='\'
+
+
+
+# Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=no
+fi
+
+
+
+
+
+
+
+
+         # TEMPORARY !!!!
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "C compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+  ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
+if test "x$ac_cv_header_minix_config_h" = x""yes; then :
+  MINIX=yes
+else
+  MINIX=
+fi
+
+
+  if test "$MINIX" = yes; then
+
+$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h
+
+
+$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h
+
+
+$as_echo "#define _MINIX 1" >>confdefs.h
+
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
+$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
+if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#	  define __EXTENSIONS__ 1
+	  $ac_includes_default
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_safe_to_define___extensions__=yes
+else
+  ac_cv_safe_to_define___extensions__=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5
+$as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
+  test $ac_cv_safe_to_define___extensions__ = yes &&
+    $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h
+
+  $as_echo "#define _ALL_SOURCE 1" >>confdefs.h
+
+  $as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+  $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
+
+  $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h
+
+
+
+case `pwd` in
+  *\ * | *\	*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.2.6b'
+macro_revision='1.3017'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if test "${ac_cv_path_SED+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if test "${ac_cv_path_FGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     if test -z "$FGREP"; then
+  ac_path_FGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in fgrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+  # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'FGREP' >> "conftest.nl"
+    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_FGREP="$ac_path_FGREP"
+      ac_path_FGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_FGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_FGREP"; then
+    as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_FGREP=$FGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if test "${lt_cv_path_NM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_DUMPBIN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$DUMPBIN" && break
+  done
+fi
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_DUMPBIN" && break
+done
+
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DUMPBIN=$ac_ct_DUMPBIN
+  fi
+fi
+
+
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if test "${lt_cv_nm_interface+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:5516: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:5519: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:5522: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+	         = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if test "${lt_cv_ld_reload_flag+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OBJDUMP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if test "${lt_cv_deplibs_check_method+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+	  cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+const struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$lt_save_LIBS"
+	  CFLAGS="$lt_save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&5
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 6727 "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_i386"
+	    ;;
+	  ppc64-*linux*|powerpc64-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  ppc*-*linux*|powerpc*-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if test "${lt_cv_cc_needs_belf+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
+else
+  lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_DSYMUTIL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_NMEDIT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_LIPO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OTOOL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_OTOOL64+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if test "${lt_cv_apple_cc_single_mod+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&5
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if test "${lt_cv_ld_exported_symbols_list+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_ld_exported_symbols_list=yes
+else
+  lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+	LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[012]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+# Set options
+
+
+
+        enable_dlopen=no
+
+
+  enable_win32_dll=no
+
+
+            # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; pic_mode="$withval"
+else
+  pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+  # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if test "${lt_cv_objdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:7959: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:7963: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+
+
+
+
+
+  lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='-fPIC'
+	;;
+      esac
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      else
+	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-KPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='--shared'
+	lt_prog_compiler_static='--static'
+	;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fpic'
+	lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-qpic'
+	lt_prog_compiler_static='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic='-Kconform_pic'
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
+$as_echo "$lt_prog_compiler_pic" >&6; }
+
+
+
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:8298: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:8302: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test "${lt_cv_prog_compiler_static_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:8403: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:8407: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:8458: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:8462: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  always_export_symbols=no
+  archive_cmds=
+  archive_expsym_cmds=
+  compiler_needs_object=no
+  enable_shared_with_static_runtimes=no
+  export_dynamic_flag_spec=
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic=no
+  hardcode_direct=no
+  hardcode_direct_absolute=no
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_flag_spec_ld=
+  hardcode_libdir_separator=
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  inherit_rpath=no
+  link_all_deplibs=unknown
+  module_cmds=
+  module_expsym_cmds=
+  old_archive_from_new_cmds=
+  old_archive_from_expsyms_cmds=
+  thread_safe_flag_spec=
+  whole_archive_flag_spec=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	lf95*)				# Lahey Fortran 8.1
+	  whole_archive_flag_spec=
+	  tmp_sharedflag='--shared' ;;
+	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec=
+	  hardcode_libdir_flag_spec_ld='-rpath $libdir'
+	  archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_direct_absolute=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      file_list_spec='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L=yes
+	  hardcode_libdir_flag_spec='-L$libdir'
+	  hardcode_libdir_separator=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      export_dynamic_flag_spec='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag="-z nodefs"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag=' ${wl}-bernotok'
+	  allow_undefined_flag=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec='$convenience'
+	  archive_cmds_need_lc=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      allow_undefined_flag=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_from_new_cmds='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
+    darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc=no
+  hardcode_direct=no
+  hardcode_automatic=yes
+  hardcode_shlibpath_var=unsupported
+  whole_archive_flag_spec=''
+  link_all_deplibs=yes
+  allow_undefined_flag="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+  else
+  ld_shlibs=no
+  fi
+
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_flag_spec_ld='+b $libdir'
+	hardcode_libdir_separator=:
+	hardcode_direct=yes
+	hardcode_direct_absolute=yes
+	export_dynamic_flag_spec='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct=no
+	  hardcode_shlibpath_var=no
+	  ;;
+	*)
+	  hardcode_direct=yes
+	  hardcode_direct_absolute=yes
+	  export_dynamic_flag_spec='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo(void) {}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+      else
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      inherit_rpath=yes
+      link_all_deplibs=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct=yes
+	hardcode_shlibpath_var=no
+	hardcode_direct_absolute=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	ld_shlibs=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_separator=:
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds='$CC -r -o $output$reload_objs'
+	  hardcode_direct=no
+        ;;
+	motorola)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      ld_shlibs=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl
+	pic_flag=$lt_prog_compiler_pic
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag
+        allow_undefined_flag=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+	  archive_cmds_need_lc=no
+        else
+	  archive_cmds_need_lc=yes
+        fi
+        allow_undefined_flag=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5
+$as_echo "$archive_cmds_need_lc" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+   test -n "$runpath_var" ||
+   test "X$hardcode_automatic" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+   test "$inherit_rpath" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+  if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+    ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line 10825 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line 10921 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+    ;;
+  *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+  # Report which library types will actually be built
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+
+
+
+
+
+
+
+
+
+
+
+        ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+#AC_PROG_CC([xlc_r icc aCC gcc cc CC])
+: ${CXXFLAGS=""}                            # avoid '-g' - see http://www.gnu.org/software/autoconf/manual/autoconf.html#C_002b_002b-Compiler
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in xlC_r icpc aC++ g++ c++ CC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in xlC_r icpc aC++ g++ c++ CC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX"  am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if test "${ac_cv_prog_cxx_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX"  am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+fi
+
+
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
+if test -z "$CXXCPP"; then
+  if test "${ac_cv_prog_CXXCPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+$as_echo "$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+_lt_caught_CXX_error=yes; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+else
+  _lt_caught_CXX_error=yes
+fi
+
+
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_flag_spec_ld_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  compiler=$CC
+  compiler_CXX=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+    else
+      lt_prog_compiler_no_builtin_flag_CXX=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+	  $GREP 'no-whole-archive' > /dev/null; then
+          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          whole_archive_flag_spec_CXX=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+    ld_shlibs_CXX=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+      aix[4-9]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	    for ld_flag in $LDFLAGS; do
+	      case $ld_flag in
+	      *-brtl*)
+	        aix_use_runtimelinking=yes
+	        break
+	        ;;
+	      esac
+	    done
+	    ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        archive_cmds_CXX=''
+        hardcode_direct_CXX=yes
+        hardcode_direct_absolute_CXX=yes
+        hardcode_libdir_separator_CXX=':'
+        link_all_deplibs_CXX=yes
+        file_list_spec_CXX='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[012]|aix4.[012].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	    # We have reworked collect2
+	    :
+	  else
+	    # We have old collect2
+	    hardcode_direct_CXX=unsupported
+	    # It fails to find uninstalled libraries when the uninstalled
+	    # path is not listed in the libpath.  Setting hardcode_minus_L
+	    # to unsupported forces relinking
+	    hardcode_minus_L_CXX=yes
+	    hardcode_libdir_flag_spec_CXX='-L$libdir'
+	    hardcode_libdir_separator_CXX=
+	  fi
+          esac
+          shared_flag='-shared'
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag="$shared_flag "'${wl}-G'
+	  fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	  # chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+          else
+	    if test "$aix_use_runtimelinking" = yes; then
+	      shared_flag='${wl}-G'
+	    else
+	      shared_flag='${wl}-bM:SRE'
+	    fi
+          fi
+        fi
+
+        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+	# export.
+        always_export_symbols_CXX=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          allow_undefined_flag_CXX='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+	    allow_undefined_flag_CXX="-z nodefs"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+	    # Determine the default libpath from the value encoded in an
+	    # empty executable.
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    # Warning - without using the other run time loading flags,
+	    # -berok will link without error, but may produce a broken library.
+	    no_undefined_flag_CXX=' ${wl}-bernotok'
+	    allow_undefined_flag_CXX=' ${wl}-berok'
+	    # Exported symbols can be pulled into shared objects from archives
+	    whole_archive_flag_spec_CXX='$convenience'
+	    archive_cmds_need_lc_CXX=yes
+	    # This is similar to how AIX traditionally builds its shared
+	    # libraries.
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	  allow_undefined_flag_CXX=unsupported
+	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	  # support --undefined.  This deserves some investigation.  FIXME
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	else
+	  ld_shlibs_CXX=no
+	fi
+	;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+	  # FIXME: insert proper C++ library support
+	  ld_shlibs_CXX=no
+	  ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32* | cegcc*)
+        # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+        # as there is no search path for DLLs.
+        hardcode_libdir_flag_spec_CXX='-L$libdir'
+        allow_undefined_flag_CXX=unsupported
+        always_export_symbols_CXX=no
+        enable_shared_with_static_runtimes_CXX=yes
+
+        if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+          archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+          # If the export-symbols file already is a .def file (1st line
+          # is EXPORTS), use it as is; otherwise, prepend...
+          archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	    cp $export_symbols $output_objdir/$soname.def;
+          else
+	    echo EXPORTS > $output_objdir/$soname.def;
+	    cat $export_symbols >> $output_objdir/$soname.def;
+          fi~
+          $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        else
+          ld_shlibs_CXX=no
+        fi
+        ;;
+      darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc_CXX=no
+  hardcode_direct_CXX=no
+  hardcode_automatic_CXX=yes
+  hardcode_shlibpath_var_CXX=unsupported
+  whole_archive_flag_spec_CXX=''
+  link_all_deplibs_CXX=yes
+  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+
+  else
+  ld_shlibs_CXX=no
+  fi
+
+	;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          ghcx*)
+	    # Green Hills C++ Compiler
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
+
+      freebsd[12]*)
+        # C++ shared libraries reported to be fairly broken before
+	# switch to ELF
+        ld_shlibs_CXX=no
+        ;;
+
+      freebsd-elf*)
+        archive_cmds_need_lc_CXX=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        ld_shlibs_CXX=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      hpux9*)
+        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        export_dynamic_flag_spec_CXX='${wl}-E'
+        hardcode_direct_CXX=yes
+        hardcode_minus_L_CXX=yes # Not in the search PATH,
+				             # but as the default
+				             # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            ld_shlibs_CXX=no
+            ;;
+          aCC*)
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              ld_shlibs_CXX=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_separator_CXX=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+	      export_dynamic_flag_spec_CXX='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            hardcode_direct_CXX=no
+            hardcode_shlibpath_var_CXX=no
+            ;;
+          *)
+            hardcode_direct_CXX=yes
+            hardcode_direct_absolute_CXX=yes
+            hardcode_minus_L_CXX=yes # Not in the search PATH,
+					         # but as the default
+					         # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          aCC*)
+	    case $host_cpu in
+	      hppa*64*)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      ia64*)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      *)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	    esac
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test $with_gnu_ld = no; then
+	        case $host_cpu in
+	          hppa*64*)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          ia64*)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          *)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	        esac
+	      fi
+	    else
+	      # FIXME: insert proper C++ library support
+	      ld_shlibs_CXX=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      interix[3-9]*)
+	hardcode_direct_CXX=no
+	hardcode_shlibpath_var_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='${wl}-E'
+	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+	# Instead, shared libraries are loaded at an image base (0x10000000 by
+	# default) and relocated if they conflict, which is a slow very memory
+	# consuming and fragmenting process.  To avoid this, we pick a random,
+	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+	    # SGI C++
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test "$with_gnu_ld" = no; then
+	        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	      else
+	        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+	      fi
+	    fi
+	    link_all_deplibs_CXX=yes
+	    ;;
+        esac
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        inherit_rpath_CXX=yes
+        ;;
+
+      linux* | k*bsd*-gnu)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	    old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    with_gnu_ld=yes
+	    # version 8.0 and above of icpc choke on multiply defined symbols
+	    # if we add $predep_objects and $postdep_objects, however 7.1 and
+	    # earlier do not add the objects themselves.
+	    case `$CC -V 2>&1` in
+	      *"Version 7."*)
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	      *)  # Version 8.0 or newer
+	        tmp_idyn=
+	        case $host_cpu in
+		  ia64*) tmp_idyn=' -i_dynamic';;
+		esac
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	    esac
+	    archive_cmds_need_lc_CXX=no
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+	    case `$CC -V` in
+	    *pgCC\ [1-5]* | *pgcpp\ [1-5]*)
+	      prelink_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+	      old_archive_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+		$RANLIB $oldlib'
+	      archive_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      archive_expsym_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    *) # Version 6 will use weak symbols
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    esac
+
+	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+	  cxx*)
+	    # Compaq C++
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	    runpath_var=LD_RUN_PATH
+	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+	    hardcode_libdir_separator_CXX=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  xl*)
+	    # IBM XL 8.0 on PPC, with GNU ld
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    if test "x$supports_anon_versioning" = xyes; then
+	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+		echo "local: *; };" >> $output_objdir/$libname.ver~
+		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	    fi
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      no_undefined_flag_CXX=' -zdefs'
+	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      hardcode_libdir_flag_spec_CXX='-R$libdir'
+	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	      compiler_needs_object_CXX=yes
+
+	      # Not sure whether something based on
+	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	      # would be better.
+	      output_verbose_link_cmd='echo'
+
+	      # Archives containing C++ object files must be created using
+	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	      # necessary to make sure instantiated templates are included
+	      # in the archive.
+	      old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+	;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+	  *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+	esac
+	;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	  archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+	  wlarc=
+	  hardcode_libdir_flag_spec_CXX='-R$libdir'
+	  hardcode_direct_CXX=yes
+	  hardcode_shlibpath_var_CXX=no
+	fi
+	# Workaround some broken pre-1.5 toolchains
+	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+	;;
+
+      *nto* | *qnx*)
+        ld_shlibs_CXX=yes
+	;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+	ld_shlibs_CXX=no
+	;;
+
+      openbsd*)
+	if test -f /usr/libexec/ld.so; then
+	  hardcode_direct_CXX=yes
+	  hardcode_shlibpath_var_CXX=no
+	  hardcode_direct_absolute_CXX=yes
+	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='${wl}-E'
+	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  fi
+	  output_verbose_link_cmd=echo
+	else
+	  ld_shlibs_CXX=no
+	fi
+	;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_separator_CXX=:
+
+	    # Archives containing C++ object files must be created using
+	    # the KAI C++ compiler.
+	    case $host in
+	      osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+	      *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+	    esac
+	    ;;
+          RCC*)
+	    # Rational C++ 2.4.1
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          cxx*)
+	    case $host in
+	      osf3*)
+	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+		;;
+	      *)
+	        allow_undefined_flag_CXX=' -expect_unresolved \*'
+	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	          echo "-hidden">> $lib.exp~
+	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+	          $RM $lib.exp'
+	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+		;;
+	    esac
+
+	    hardcode_libdir_separator_CXX=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  *)
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	      case $host in
+	        osf3*)
+	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	        *)
+	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	      esac
+
+	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_separator_CXX=:
+
+	      # Commands to make compiler produce verbose output that lists
+	      # what "hidden" libraries, object files and flags are used when
+	      # linking a shared library.
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+	    else
+	      # FIXME: insert proper C++ library support
+	      ld_shlibs_CXX=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.x
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          lcc*)
+	    # Lucid
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+            archive_cmds_need_lc_CXX=yes
+	    no_undefined_flag_CXX=' -zdefs'
+	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	    hardcode_libdir_flag_spec_CXX='-R$libdir'
+	    hardcode_shlibpath_var_CXX=no
+	    case $host_os in
+	      solaris2.[0-5] | solaris2.[0-5].*) ;;
+	      *)
+		# The compiler driver will combine and reorder linker options,
+		# but understands `-z linker_flag'.
+	        # Supported since Solaris 2.6 (maybe 2.5.1?)
+		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+	        ;;
+	    esac
+	    link_all_deplibs_CXX=yes
+
+	    output_verbose_link_cmd='echo'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	    ;;
+          gcx*)
+	    # Green Hills C++ Compiler
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	    # The C++ compiler must be used to create the archive.
+	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    # GNU C++ compiler with Solaris linker
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+	        archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      else
+	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # platform.
+	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      fi
+
+	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      case $host_os in
+		solaris2.[0-5] | solaris2.[0-5].*) ;;
+		*)
+		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  ;;
+	      esac
+	    fi
+	    ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_CXX='${wl}-z,text'
+      archive_cmds_need_lc_CXX=no
+      hardcode_shlibpath_var_CXX=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+	# Note: We can NOT use -z defs as we might desire, because we do not
+	# link with -lc, and that would cause any symbols used from libc to
+	# always be unresolved, which means just about no library would
+	# ever link correctly.  If we're not using GNU ld we use -z text
+	# though, which does catch some bad symbols but isn't as heavy-handed
+	# as -z defs.
+	no_undefined_flag_CXX='${wl}-z,text'
+	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	archive_cmds_need_lc_CXX=no
+	hardcode_shlibpath_var_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_separator_CXX=':'
+	link_all_deplibs_CXX=yes
+	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	runpath_var='LD_RUN_PATH'
+
+	case $cc_basename in
+          CC*)
+	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	  *)
+	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+	    # NonStop-UX NCC 3.20
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+    esac
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+    test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+    GCC_CXX="$GXX"
+    LD_CXX="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$compiler_lib_search_path_CXX"; then
+	     compiler_lib_search_path_CXX="${prev}${p}"
+	   else
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$postdeps_CXX"; then
+	   postdeps_CXX="${prev}${p}"
+	 else
+	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$predep_objects_CXX"; then
+	   predep_objects_CXX="$p"
+	 else
+	   predep_objects_CXX="$predep_objects_CXX $p"
+	 fi
+       else
+	 if test -z "$postdep_objects_CXX"; then
+	   postdep_objects_CXX="$p"
+	 else
+	   postdep_objects_CXX="$postdep_objects_CXX $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  predep_objects_CXX=
+  postdep_objects_CXX=
+  postdeps_CXX=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    lt_prog_compiler_wl_CXX='-Wl,'
+    lt_prog_compiler_static_CXX='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_CXX='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_CXX='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_CXX='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      lt_prog_compiler_pic_CXX=
+      ;;
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_CXX=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	;;
+      *)
+	lt_prog_compiler_pic_CXX='-fPIC'
+	;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_CXX='-fPIC -shared'
+      ;;
+    *)
+      lt_prog_compiler_pic_CXX='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[4-9]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  lt_prog_compiler_static_CXX='-Bstatic'
+	else
+	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      lt_prog_compiler_pic_CXX='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      lt_prog_compiler_pic_CXX='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    ;;
+	  ecpc* )
+	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-static'
+	    ;;
+	  icpc* )
+	    # Intel C++, used to be incompatible with GCC.
+	    # ICC 10 doesn't accept -KPIC any more.
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    lt_prog_compiler_static_CXX='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-fpic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  xlc* | xlC*)
+	    # IBM XL 8.0 on PPC
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-qpic'
+	    lt_prog_compiler_static_CXX='-qstaticlink'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      lt_prog_compiler_pic_CXX='-KPIC'
+	      lt_prog_compiler_static_CXX='-Bstatic'
+	      lt_prog_compiler_wl_CXX='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    lt_prog_compiler_pic_CXX='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd*)
+	;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        lt_prog_compiler_pic_CXX='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    lt_prog_compiler_wl_CXX='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    lt_prog_compiler_pic_CXX='-pic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	lt_prog_compiler_can_build_shared_CXX=no
+	;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_CXX=
+    ;;
+  *)
+    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_CXX" >&5
+$as_echo "$lt_prog_compiler_pic_CXX" >&6; }
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_CXX=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13809: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:13813: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_CXX=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+    case $lt_prog_compiler_pic_CXX in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+     esac
+else
+    lt_prog_compiler_pic_CXX=
+     lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works_CXX=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_CXX=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_CXX=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+    :
+else
+    lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13908: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:13912: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13960: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:13964: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[4-9]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    export_symbols_cmds_CXX="$ltdll_cmds"
+  ;;
+  cygwin* | mingw* | cegcc*)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_CXX=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_CXX in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_CXX
+	pic_flag=$lt_prog_compiler_pic_CXX
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+        allow_undefined_flag_CXX=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+	  archive_cmds_need_lc_CXX=no
+        else
+	  archive_cmds_need_lc_CXX=yes
+        fi
+        allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_CXX" >&5
+$as_echo "$archive_cmds_need_lc_CXX" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+   test -n "$runpath_var_CXX" ||
+   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_CXX" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+     test "$hardcode_minus_L_CXX" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_CXX=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_CXX=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_CXX=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+$as_echo "$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = relink ||
+   test "$inherit_rpath_CXX" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ifort gfortran pgf90 pgf77 xlf90_r xlf90 xlf77_r f90 g77
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$F77"; then
+  ac_cv_prog_F77="$F77" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $F77" >&5
+$as_echo "$F77" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$F77" && break
+  done
+fi
+if test -z "$F77"; then
+  ac_ct_F77=$F77
+  for ac_prog in ifort gfortran pgf90 pgf77 xlf90_r xlf90 xlf77_r f90 g77
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_F77"; then
+  ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_F77="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_F77" >&5
+$as_echo "$ac_ct_F77" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_F77" && break
+done
+
+  if test "x$ac_ct_F77" = x; then
+    F77=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    F77=$ac_ct_F77
+  fi
+fi
+
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran 77 compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file.  (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran 77 compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran 77 compiler... " >&6; }
+if test "${ac_cv_f77_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+#ifndef __GNUC__
+       choke me
+#endif
+
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_f77_compiler_gnu" >&5
+$as_echo "$ac_cv_f77_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $F77 accepts -g" >&5
+$as_echo_n "checking whether $F77 accepts -g... " >&6; }
+if test "${ac_cv_prog_f77_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  FFLAGS=-g
+cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_cv_prog_f77_g=yes
+else
+  ac_cv_prog_f77_g=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_f77_g" >&5
+$as_echo "$ac_cv_prog_f77_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+  FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-g -O2"
+  else
+    FFLAGS="-g"
+  fi
+else
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-O2"
+  else
+    FFLAGS=
+  fi
+fi
+
+if test $ac_compiler_gnu = yes; then
+  G77=yes
+else
+  G77=
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$F77"; then
+  ac_cv_prog_F77="$F77" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $F77" >&5
+$as_echo "$F77" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$F77" && break
+  done
+fi
+if test -z "$F77"; then
+  ac_ct_F77=$F77
+  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_F77"; then
+  ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_F77="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_F77" >&5
+$as_echo "$ac_ct_F77" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_F77" && break
+done
+
+  if test "x$ac_ct_F77" = x; then
+    F77=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    F77=$ac_ct_F77
+  fi
+fi
+
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran 77 compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file.  (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran 77 compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran 77 compiler... " >&6; }
+if test "${ac_cv_f77_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+#ifndef __GNUC__
+       choke me
+#endif
+
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_f77_compiler_gnu" >&5
+$as_echo "$ac_cv_f77_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $F77 accepts -g" >&5
+$as_echo_n "checking whether $F77 accepts -g... " >&6; }
+if test "${ac_cv_prog_f77_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  FFLAGS=-g
+cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_cv_prog_f77_g=yes
+else
+  ac_cv_prog_f77_g=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_f77_g" >&5
+$as_echo "$ac_cv_prog_f77_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+  FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-g -O2"
+  else
+    FFLAGS="-g"
+  fi
+else
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-O2"
+  else
+    FFLAGS=
+  fi
+fi
+
+if test $ac_compiler_gnu = yes; then
+  G77=yes
+else
+  G77=
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+if test -z "$F77" || test "X$F77" = "Xno"; then
+  _lt_disable_F77=yes
+fi
+
+
+
+      ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+
+
+archive_cmds_need_lc_F77=no
+allow_undefined_flag_F77=
+always_export_symbols_F77=no
+archive_expsym_cmds_F77=
+export_dynamic_flag_spec_F77=
+hardcode_direct_F77=no
+hardcode_direct_absolute_F77=no
+hardcode_libdir_flag_spec_F77=
+hardcode_libdir_flag_spec_ld_F77=
+hardcode_libdir_separator_F77=
+hardcode_minus_L_F77=no
+hardcode_automatic_F77=no
+inherit_rpath_F77=no
+module_cmds_F77=
+module_expsym_cmds_F77=
+link_all_deplibs_F77=unknown
+old_archive_cmds_F77=$old_archive_cmds
+no_undefined_flag_F77=
+whole_archive_flag_spec_F77=
+enable_shared_with_static_runtimes_F77=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+objext_F77=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${F77-"f77"}
+  compiler=$CC
+  compiler_F77=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  GCC=$G77
+  if test -n "$compiler"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[4-9]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+    GCC_F77="$G77"
+    LD_F77="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    lt_prog_compiler_wl_F77=
+lt_prog_compiler_pic_F77=
+lt_prog_compiler_static_F77=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_F77='-Wl,'
+    lt_prog_compiler_static_F77='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_F77='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_F77='-fno-common'
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_F77='-fPIC'
+	;;
+      esac
+      ;;
+
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_F77=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_F77='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_F77=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      lt_prog_compiler_pic_F77='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
+      else
+	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_F77='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-KPIC'
+	lt_prog_compiler_static_F77='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-fPIC'
+	lt_prog_compiler_static_F77='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='--shared'
+	lt_prog_compiler_static_F77='--static'
+	;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-fpic'
+	lt_prog_compiler_static_F77='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_F77='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_F77='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-qpic'
+	lt_prog_compiler_static_F77='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic_F77='-KPIC'
+	  lt_prog_compiler_static_F77='-Bstatic'
+	  lt_prog_compiler_wl_F77='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic_F77='-KPIC'
+	  lt_prog_compiler_static_F77='-Bstatic'
+	  lt_prog_compiler_wl_F77=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_F77='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
+
+    rdos*)
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl_F77='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl_F77='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl_F77='-Qoption ld '
+      lt_prog_compiler_pic_F77='-PIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_F77='-Kconform_pic'
+	lt_prog_compiler_static_F77='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_can_build_shared_F77=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic_F77='-pic'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared_F77=no
+      ;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_F77=
+    ;;
+  *)
+    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_F77" >&5
+$as_echo "$lt_prog_compiler_pic_F77" >&6; }
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_F77=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_F77"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:15768: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:15772: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_F77=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_F77" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_F77" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_F77" = xyes; then
+    case $lt_prog_compiler_pic_F77 in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
+     esac
+else
+    lt_prog_compiler_pic_F77=
+     lt_prog_compiler_can_build_shared_F77=no
+fi
+
+fi
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test "${lt_cv_prog_compiler_static_works_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works_F77=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_F77=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_F77=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_F77" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_F77" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_F77" = xyes; then
+    :
+else
+    lt_prog_compiler_static_F77=
+fi
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_F77=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:15867: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:15871: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_F77=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_F77" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_F77" >&6; }
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_F77=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:15919: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:15923: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_F77=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_F77" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_F77" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag_F77=
+  always_export_symbols_F77=no
+  archive_cmds_F77=
+  archive_expsym_cmds_F77=
+  compiler_needs_object_F77=no
+  enable_shared_with_static_runtimes_F77=no
+  export_dynamic_flag_spec_F77=
+  export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic_F77=no
+  hardcode_direct_F77=no
+  hardcode_direct_absolute_F77=no
+  hardcode_libdir_flag_spec_F77=
+  hardcode_libdir_flag_spec_ld_F77=
+  hardcode_libdir_separator_F77=
+  hardcode_minus_L_F77=no
+  hardcode_shlibpath_var_F77=unsupported
+  inherit_rpath_F77=no
+  link_all_deplibs_F77=unknown
+  module_cmds_F77=
+  module_expsym_cmds_F77=
+  old_archive_from_new_cmds_F77=
+  old_archive_from_expsyms_cmds_F77=
+  thread_safe_flag_spec_F77=
+  whole_archive_flag_spec_F77=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_F77=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_F77='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs_F77=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec_F77=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_F77=''
+        ;;
+      m68k)
+            archive_cmds_F77='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_F77='-L$libdir'
+            hardcode_minus_L_F77=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_F77=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=no
+      enable_shared_with_static_runtimes_F77=yes
+      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    interix[3-9]*)
+      hardcode_direct_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec_F77='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	lf95*)				# Lahey Fortran 8.1
+	  whole_archive_flag_spec_F77=
+	  tmp_sharedflag='--shared' ;;
+	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object_F77=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds_F77='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds_F77='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec_F77='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec_F77=
+	  hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
+	  archive_cmds_F77='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds_F77='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs_F77=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+	    archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs_F77=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs_F77" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_F77=
+      export_dynamic_flag_spec_F77=
+      whole_archive_flag_spec_F77=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=yes
+      archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_F77=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_F77=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds_F77=''
+      hardcode_direct_F77=yes
+      hardcode_direct_absolute_F77=yes
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
+      file_list_spec_F77='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct_F77=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L_F77=yes
+	  hardcode_libdir_flag_spec_F77='-L$libdir'
+	  hardcode_libdir_separator_F77=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      export_dynamic_flag_spec_F77='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_F77=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag_F77='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+if ac_fn_f77_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds_F77='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_F77="-z nodefs"
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+if ac_fn_f77_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_F77=' ${wl}-bernotok'
+	  allow_undefined_flag_F77=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_F77='$convenience'
+	  archive_cmds_need_lc_F77=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_F77=''
+        ;;
+      m68k)
+            archive_cmds_F77='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_F77='-L$libdir'
+            hardcode_minus_L_F77=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec_F77=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_F77=' '
+      allow_undefined_flag_F77=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_from_new_cmds_F77='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_F77='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_F77=yes
+      ;;
+
+    darwin* | rhapsody*)
+
+
+  archive_cmds_need_lc_F77=no
+  hardcode_direct_F77=no
+  hardcode_automatic_F77=yes
+  hardcode_shlibpath_var_F77=unsupported
+  whole_archive_flag_spec_F77=''
+  link_all_deplibs_F77=yes
+  allow_undefined_flag_F77="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds_F77="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_F77="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_F77="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_F77="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+  else
+  ld_shlibs_F77=no
+  fi
+
+      ;;
+
+    dgux*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs_F77=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_F77='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_direct_F77=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	hardcode_libdir_flag_spec_ld_F77='+b $libdir'
+	hardcode_libdir_separator_F77=:
+	hardcode_direct_F77=yes
+	hardcode_direct_absolute_F77=yes
+	export_dynamic_flag_spec_F77='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L_F77=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_F77=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct_F77=no
+	  hardcode_shlibpath_var_F77=no
+	  ;;
+	*)
+	  hardcode_direct_F77=yes
+	  hardcode_direct_absolute_F77=yes
+	  export_dynamic_flag_spec_F77='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_F77=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        cat > conftest.$ac_ext <<_ACEOF
+int foo(void) {}
+_ACEOF
+if ac_fn_f77_try_link "$LINENO"; then :
+  archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+      else
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc_F77='no'
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      inherit_rpath_F77=yes
+      link_all_deplibs_F77=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    newsos6)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct_F77=yes
+	hardcode_shlibpath_var_F77=no
+	hardcode_direct_absolute_F77=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec_F77='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec_F77='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+      allow_undefined_flag_F77=unsupported
+      archive_cmds_F77='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc_F77='no'
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_F77='-rpath $libdir'
+      fi
+      archive_cmds_need_lc_F77='no'
+      hardcode_libdir_separator_F77=:
+      ;;
+
+    solaris*)
+      no_undefined_flag_F77=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds_F77='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  archive_cmds_F77='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_shlibpath_var_F77=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs_F77=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_F77='$CC -r -o $output$reload_objs'
+	  hardcode_direct_F77=no
+        ;;
+	motorola)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_F77=no
+      export_dynamic_flag_spec_F77='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_F77=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_F77=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_F77='${wl}-z,text'
+      archive_cmds_need_lc_F77=no
+      hardcode_shlibpath_var_F77=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag_F77='${wl}-z,text'
+      allow_undefined_flag_F77='${wl}-z,nodefs'
+      archive_cmds_need_lc_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_libdir_flag_spec_F77='${wl}-R,$libdir'
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
+
+    *)
+      ld_shlibs_F77=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec_F77='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_F77" >&5
+$as_echo "$ld_shlibs_F77" >&6; }
+test "$ld_shlibs_F77" = no && can_build_shared=no
+
+with_gnu_ld_F77=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_F77" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_F77=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_F77 in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_F77
+	pic_flag=$lt_prog_compiler_pic_F77
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
+        allow_undefined_flag_F77=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_F77 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_F77 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+	  archive_cmds_need_lc_F77=no
+        else
+	  archive_cmds_need_lc_F77=yes
+        fi
+        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_F77" >&5
+$as_echo "$archive_cmds_need_lc_F77" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_F77\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_F77\""
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+if ac_fn_f77_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_F77=
+if test -n "$hardcode_libdir_flag_spec_F77" ||
+   test -n "$runpath_var_F77" ||
+   test "X$hardcode_automatic_F77" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_F77" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
+     test "$hardcode_minus_L_F77" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_F77=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_F77=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_F77=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_F77" >&5
+$as_echo "$hardcode_action_F77" >&6; }
+
+if test "$hardcode_action_F77" = relink ||
+   test "$inherit_rpath_F77" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+######################
+#
+# Checks for programs.
+#
+
+
+#LT_LANG([C++])
+
+#
+#  Generic Metview support  --enable-metview
+#
+# Check whether --enable-metview was given.
+if test "${enable_metview+set}" = set; then :
+  enableval=$enable_metview; metview=$enableval
+else
+  metview=no
+fi
+
+
+if test "x$metview" = "xyes" ; then
+
+  qt=yes
+fi
+
+##################################
+#
+#  T H R E A D I N G
+#
+# Check whether --enable-threads was given.
+if test "${enable_threads+set}" = set; then :
+  enableval=$enable_threads; threads=$enableval
+else
+  threads=yes
+fi
+
+
+if test "x$threads" = "xyes" ; then
+  $as_echo "#define MAGICS_THREADS 1" >>confdefs.h
+
+fi
+
+##################################
+#
+#  Enable PKG_CONFIG
+#
+case `${PKG_CONFIG:-pkg-config} --version` in
+0.?|0.?.?|0.1[0-7]|0.1[0-7].?) PKGCONFIG_REQUIRES="Requires"; ;;
+*) PKGCONFIG_REQUIRES="Requires.private"; ;;
+esac
+
+
+
+###############################################################################################
+#
+#   P Y T H O N   &   S W I G
+#
+#      --enable-python
+#
+# Check whether --enable-python was given.
+if test "${enable_python+set}" = set; then :
+  enableval=$enable_python; python=$enableval
+else
+  python=no
+fi
+
+
+
+if test "x$python" = "xyes"
+then
+  ### search for a python interpreter on the system abort if one not found
+  ### am_path_python sets many python vars - RTFM for more info
+
+
+
+
+        if test -n "$PYTHON"; then
+      # If the user set $PYTHON, use it and don't search something else.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.5" >&5
+$as_echo_n "checking whether $PYTHON version >= 2.5... " >&6; }
+      prog="import sys
+# split strings by '.' and convert to numeric.  Append some zeros
+# because we need at least 4 digits for the hex conversion.
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '2.5'.split('.'))) + [0, 0, 0]
+minverhex = 0
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i]
+sys.exit(sys.hexversion < minverhex)"
+  if { echo "$as_me:$LINENO: $PYTHON -c "$prog"" >&5
+   ($PYTHON -c "$prog") >&5 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  as_fn_error "too old" "$LINENO" 5
+fi
+      am_display_PYTHON=$PYTHON
+    else
+      # Otherwise, try each interpreter until we find one that satisfies
+      # VERSION.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 2.5" >&5
+$as_echo_n "checking for a Python interpreter with version >= 2.5... " >&6; }
+if test "${am_cv_pathless_PYTHON+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+	for am_cv_pathless_PYTHON in python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+	  test "$am_cv_pathless_PYTHON" = none && break
+	  prog="import sys
+# split strings by '.' and convert to numeric.  Append some zeros
+# because we need at least 4 digits for the hex conversion.
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '2.5'.split('.'))) + [0, 0, 0]
+minverhex = 0
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i]
+sys.exit(sys.hexversion < minverhex)"
+  if { echo "$as_me:$LINENO: $am_cv_pathless_PYTHON -c "$prog"" >&5
+   ($am_cv_pathless_PYTHON -c "$prog") >&5 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }; then :
+  break
+fi
+	done
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_pathless_PYTHON" >&5
+$as_echo "$am_cv_pathless_PYTHON" >&6; }
+      # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
+      if test "$am_cv_pathless_PYTHON" = none; then
+	PYTHON=:
+      else
+        # Extract the first word of "$am_cv_pathless_PYTHON", so it can be a program name with args.
+set dummy $am_cv_pathless_PYTHON; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PYTHON+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PYTHON in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PYTHON=$ac_cv_path_PYTHON
+if test -n "$PYTHON"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
+$as_echo "$PYTHON" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+      fi
+      am_display_PYTHON=$am_cv_pathless_PYTHON
+    fi
+
+
+  if test "$PYTHON" = :; then
+      as_fn_error "no suitable Python interpreter found" "$LINENO" 5
+  else
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5
+$as_echo_n "checking for $am_display_PYTHON version... " >&6; }
+if test "${am_cv_python_version+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5
+$as_echo "$am_cv_python_version" >&6; }
+  PYTHON_VERSION=$am_cv_python_version
+
+
+
+  PYTHON_PREFIX='${prefix}'
+
+  PYTHON_EXEC_PREFIX='${exec_prefix}'
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5
+$as_echo_n "checking for $am_display_PYTHON platform... " >&6; }
+if test "${am_cv_python_platform+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5
+$as_echo "$am_cv_python_platform" >&6; }
+  PYTHON_PLATFORM=$am_cv_python_platform
+
+
+
+
+                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5
+$as_echo_n "checking for $am_display_PYTHON script directory... " >&6; }
+if test "${am_cv_python_pythondir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$prefix" = xNONE
+     then
+       am_py_prefix=$ac_default_prefix
+     else
+       am_py_prefix=$prefix
+     fi
+     am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null ||
+     echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
+     case $am_cv_python_pythondir in
+     $am_py_prefix*)
+       am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
+       am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
+       ;;
+     *)
+       case $am_py_prefix in
+         /usr|/System*) ;;
+         *)
+	  am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
+	  ;;
+       esac
+       ;;
+     esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5
+$as_echo "$am_cv_python_pythondir" >&6; }
+  pythondir=$am_cv_python_pythondir
+
+
+
+  pkgpythondir=\${pythondir}/$PACKAGE
+
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory" >&5
+$as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; }
+if test "${am_cv_python_pyexecdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$exec_prefix" = xNONE
+     then
+       am_py_exec_prefix=$am_py_prefix
+     else
+       am_py_exec_prefix=$exec_prefix
+     fi
+     am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null ||
+     echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
+     case $am_cv_python_pyexecdir in
+     $am_py_exec_prefix*)
+       am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
+       am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
+       ;;
+     *)
+       case $am_py_exec_prefix in
+         /usr|/System*) ;;
+         *)
+	   am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
+	   ;;
+       esac
+       ;;
+     esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5
+$as_echo "$am_cv_python_pyexecdir" >&6; }
+  pyexecdir=$am_cv_python_pyexecdir
+
+
+
+  pkgpyexecdir=\${pyexecdir}/$PACKAGE
+
+
+
+  fi
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether numpy is installed" >&5
+$as_echo_n "checking whether numpy is installed... " >&6; }
+   has_numpy=`$PYTHON -c "import numpy;print numpy" 2> /dev/null`
+   if test "x$has_numpy" = "x"
+    then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+       as_fn_error "NumPy is not installed. Use --disable-python if you want to continue without NumPy." "$LINENO" 5
+    else
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       NUMPY_INCLUDE=`$PYTHON -c "import numpy;print numpy.get_include()"`
+       CPPFLAGS="-I${NUMPY_INCLUDE} ${CPPFLAGS}"
+
+    fi
+  $as_echo "#define MAGICS_PYTHON 1" >>confdefs.h
+
+
+fi
+
+#
+#  E N D   P Y T H O N  &  S W I G
+#
+##############################################################################################################
+
+
+
+##################################################
+#
+#  32 bit addressing  --enable-32bit
+#
+# Check whether --enable-32-bits-addressing-mode was given.
+if test "${enable_32_bits_addressing_mode+set}" = set; then :
+  enableval=$enable_32_bits_addressing_mode; enable_32_bits_addressing_mode='yes'
+else
+  enable_32_bits_addressing_mode='no'
+fi
+
+
+##################################################
+#
+#  Exception support  --enable-exception
+#
+# Check whether --enable-exception was given.
+if test "${enable_exception+set}" = set; then :
+  enableval=$enable_exception; exception=$enableval
+else
+  exception=yes
+fi
+
+if test "x$exception" = "xyes" ; then
+  $as_echo "#define MAGICS_EXCEPTION 1" >>confdefs.h
+
+fi
+
+#######################################################################
+#
+# Architecture dependent Compiler options
+#
+windows=no
+SHLIB_EXT=so
+LIBNAME=${LIBNAME:="lib"}
+PLATFORM_DEFINES_MARS=""
+
+
+
+case "${host}" in
+	x86_64*linux*)
+		if test "x$enable_32_bits_addressing_mode" = "xyes" ; then
+		echo " "
+		echo "You are on x86-64 and building a 32 bit version of Magics++."
+		echo " "
+		AXX="-m32"
+		CPPFLAGS="$CPPFLAGS -I/usr/include/freetype2 -I/usr/include -I/usr/X11R6/include -I/usr/local/include"
+		LDFLAGS="$LDFLAGS -L/usr/lib -L/usr/local/lib -L/usr/X11R6/lib"
+		else
+		echo " "
+		echo "You are on x86-64 and building a 64 bit version of Magics++."
+		echo " "
+#		if test "x$SITE_NAME" = xecmwf; then
+#			libdir=${prefix}/lib64
+#		fi
+		AXX="-m64 -fPIC"
+		LIBNAME="lib64"
+		CPPFLAGS="$CPPFLAGS -Dlinux -I/usr/include/freetype2 -I/usr/include -I/usr/X11R6/include -I/usr/local/include"
+		CXXFLAGS="$CXXFLAGS"
+		LDFLAGS="$LDFLAGS -L/usr/local/lib64 -L/usr/X11R6/lib64"
+		PLATFORM_DEFINES_MARS="-DLITTLE -DLITTLE_END -DI64 -DR64 -Dlinux"
+		fi
+		;;
+	# Linux workstations x86
+	*86-*-linux* )
+		CPPFLAGS="$CPPFLAGS -Dlinux -I/usr/include/freetype2 -I/usr/include -I/usr/X11R6/include -I/usr/local/include"
+		LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -L/usr/local/lib"
+		AXX="-m32"
+		PLATFORM_DEFINES_MARS="-DLITTLE -DLITTLE_END -DI32 -DR64 -Dlinux"
+		;;
+	# IBM Server
+	*-ibm-aix* )
+		AXX="-mminimal-toc"
+		CPPFLAGS="${CPPFLAGS} -Daix -DMAGICS_AIX_XLC -I/usr/include/freetype2" # -I/usr/include/freetype2 -I/opt/freeware/include -I/usr/local/include"
+#		LDFLAGS="-L/usr/lib $LDFLAGS"
+		LDFLAGS="-L/usr/lib -Wl,-brtl $LDFLAGS"
+		LIBS="-lfreetype $LIBS -lpng -lz -liconv"  # for terralib
+		MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -lfreetype -lpng"
+		PLATFORM_DEFINES_MARS="-DI32 -DR64 -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DAIX"
+		;;
+    # MACs
+    *-darwin*)
+        CPPFLAGS="${CPPFLAGS} -DMAGICS_MAC_GCC"
+        LIBS="$LIBS -lpng -lcurl"
+        LDFLAGS="-L/usr/local/lib -L/opt/local/lib $LDFLAGS -lstdc++"
+        CPPFLAGS="-I/usr/local/include -I/opt/local/include $CPPFLAGS"
+        SHLIB_EXT=dylib
+        mac=true
+        $as_echo "#define MAGICS_MAC 1" >>confdefs.h
+
+        ;;
+    # HP - aCC
+    *-*-hpux* )
+		#AXX="-AA -Wp,-H30000"
+		PLATFORM_DEFINES_MARS="-DI64 -DR64 -Dhpux"
+		;;
+	*-*-cygwin* | *-*-mingw32*)
+		echo " "
+		echo "You try to install Magics++ on Windows!"
+		echo " "
+		echo " Please be aware that Windows is NOT a supported platform!!!"
+		echo " Following features will NOT work: BUFR decoding"
+		echo " "
+		CPPFLAGS="$CPPFLAGS -DMAGICS_WINDOWS_CYGWIN -I/usr/include/freetype2 -I/usr/include -I/usr/local/include"
+		AXX="-m32"
+		windows=yes
+		;;
+esac
+
+
+
+
+
+#
+# Compiler dependent Compiler options
+#
+MAGICS_VISIBILITY=""
+
+case "${CXX}" in
+	# GNU GCC
+	g++* )
+		CFLAGS="$CFLAGS $AXX -ansi -std=c99" # -fpermissive
+
+		CXXFLAGS=${CXXFLAGS:="-g -O2 -mtune=native"}
+		CXXFLAGS="$CXXFLAGS $AXX -fno-gnu-keywords -ansi -std=c++98 -Wno-deprecated -Wno-write-strings"
+		CPPLIBS="${CPPLIBS} -lstdc++"
+
+#		AC_LANG([C++])
+#		AC_COMPILE_IFELSE([
+#		#if defined(__GNUC__) && (__GNUC__ < 4 )
+#		#error "GCC < 4.0"
+#		#endif
+#		int main(){return 0;}], gcc4=yes)
+
+#		AC_MSG_RESULT(Test if GCC 4 ${gcc4})
+
+#		if test "x$gcc4" = "xyes" -a "x$metview" = xno; then
+#			  MAGICS_VISIBILITY="-fvisibility=hidden"
+#		fi
+
+		;;
+	# Intel compiler
+	icpc | icc )
+		#  -O3 -xhost -opt-report=3 -vec-report 3
+		#  -O3 -xhost -opt-report=3 -vec-report 3 -parallel -par-report3
+		#  -guide -parallel                                 # produces NO binary output!
+		intel_common="-static-intel -wr654 -wr1125 -wr1011"
+		CFLAGS="$CFLAGS ${intel_common}"
+		CXXFLAGS="$CXXFLAGS ${intel_common}"
+		# -static-intel does the job but if any libraries compiled with g++ are used this is needed
+		CPPLIBS="${CPPLIBS} -lstdc++"
+		;;
+	# IBM C++ compiler
+	xlC_r | xlC )
+		# -qtune=auto
+		#
+		# -qfuncsect   --> code bloat but later reduction?
+		#
+		# -qmkshrobj   --> no entry point message??? (570 MB)
+		#
+		# -qtemplateregistry=/scratch/graphics/cgm/magics/IBM/templateregistry
+		#
+	#	rm -f ${PWD}/templateregistry
+	#	CXXFLAGS="$CXXFLAGS -O2 -qtune=auto -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000 -qstrict -qtemplateregistry=${PWD}/templateregistry " # 560 MB
+	#	CXXFLAGS="$CXXFLAGS -O2 -qtune=auto -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000 -qtmplinst=none "       # 203 MB - does not work
+	#	CXXFLAGS="$CXXFLAGS -O3 -qsuppress=1540-1101 -DAIX -DNDEBUG -qcpluscmt -qinline=15 -qtune=auto -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000" # 220 MB - works
+		CXXFLAGS="${CXXFLAGS:-"-O3 -DNDEBUG -qinline=15 -qtune=auto"}"     # 21 Apr 2012 - works 174MB
+		CXXFLAGS="${CXXFLAGS:-"-O0 -DDEBUG  -qnoinline  -qNOOPTimize"}"    # 21 Apr 2012 - works 950MB
+		CXXFLAGS="$CXXFLAGS -qxflag=KeepUnqualifiedStaticCandidate -DBOOST_TYPEOF_NATIVE -DBOOST_TYPEOF_KEYWORD=__typeof__ -qsuppress=1540-1101 -DAIX -qcpluscmt -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000"
+	#	CXX="xlC $CXXFLAGS"
+		LD=xlC_r
+		CC=xlC_r
+		LDFLAGS="$LDFLAGS -Wl,-bbigtoc"  # -qmkshrobj
+		CFLAGS="$CFLAGS -qtune=auto -qstrict -qmaxmem=-1 -qarch=auto -bmaxdata:0x60000000"
+
+		CPPLIBS="${CPPLIBS} -lC"     # should strictly not nessecary when xlf is used
+		;;
+esac
+
+
+
+# end of C++
+
+ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+#
+# Which fortran compiler should be used?
+#
+# FLIBS is determined which Fortran compiler was used for Emoslib!!!
+#
+case "${F77}" in
+	*gfortran* )
+		FLIB="gfortran"
+		FLIBS="-l${FLIB}"
+		FFLAGS="${FFLAGS} ${AXX}"
+		;;
+	# Intel compiler 9.x
+	ifc | ifort)
+		FFLAGS="${FFLAGS}"
+		FLIBS="-lifcore -lifport"
+		;;
+	# Portland C++
+	pgf* )
+		FLIB="pgftnrtl','pgc','rt"             # for Python distutils
+		FLIBS="$FLIBS -lpgftnrtl -lpgc -lrt"   # PGI 7.1
+		case "${host}" in
+			x86_64*linux*)
+				FFLAGS="${FFLAGS} -tp amd64"
+				;;
+			# Linux workstations x86
+			*86-*-linux* )
+				FFLAGS="${FFLAGS} -tp px"
+				;;
+		esac
+		;;
+	# IBM fortran compiler
+	xlf* )
+		FLIB="xlf90"
+		FLIBS="-l${FLIB}"
+		FFLAGS="${FFLAGS} -qfixed=72 -q32"
+		;;
+	# all other C++ compilers ...
+	* )
+		if test "x${F77}" = "x"; then
+			echo "No Fortran compiler defined! Use F77=<name> to set one."
+			FLIBS=""
+		else
+		echo "Oops ... $F77 not supported yet"
+		fi
+		;;
+esac
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# end of F O R T R A N
+
+
+
+# Check whether --enable-allheaders was given.
+if test "${enable_allheaders+set}" = set; then :
+  enableval=$enable_allheaders; allheaders=$enableval
+else
+  allheaders=no
+fi
+
+
+######################################################################
+#
+#     Qt
+#
+######################################################################
+# Check whether --enable-qt was given.
+if test "${enable_qt+set}" = set; then :
+  enableval=$enable_qt; qt=$enableval
+fi
+
+
+if test "x$qt" = "xyes" ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt" >&5
+$as_echo_n "checking for Qt... " >&6; }
+  # Qt with AutoTroll.
+  # Build Qt apps with the autotools (Autoconf/Automake).
+# M4 macros.
+# This file is part of AutoTroll.
+# Copyright (C) 2006  Benoit Sigoure <benoit.sigoure at lrde.epita.fr>
+#
+# AutoTroll is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+#
+# In addition, as a special exception, the copyright holders of AutoTroll
+# give you unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the macros of
+# AutoTroll.  You need not follow the terms of the GNU General Public License
+# when using or distributing such scripts, even though portions of the text of
+# AutoTroll appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes AutoTroll.
+#
+# This special exception to the GPL applies to versions of AutoTroll
+# released by the copyright holders of AutoTroll.  Note that people who make
+# modified versions of AutoTroll are not obligated to grant this special
+# exception for their modified versions; it is their choice whether to do so.
+# The GNU General Public License gives permission to release a modified version
+# without this exception; this exception also makes it possible to release a
+# modified version which carries forward this exception.
+
+ # ------------- #
+ # DOCUMENTATION #
+ # ------------- #
+
+# Disclaimer: Never tested with anything else than Qt 4.2! Feedback welcome.
+# Simply invoke AT_WITH_QT in your configure.ac. AT_WITH_QT can take
+# arguments which are documented in depth below. The default arguments are
+# equivalent to the default .pro file generated by qmake.
+#
+# Invoking AT_WITH_QT will do the following:
+#  - Add a --with-qt option to your configure
+#  - Find qmake, moc and uic and save them in the make variables $(QMAKE),
+#    $(MOC), $(UIC).
+#  - Save the path to Qt in $(QT_PATH)
+#  - Find the flags to use Qt, that is:
+#     * $(QT_DEFINES): -D's defined by qmake.
+#     * $(QT_CFLAGS): CFLAGS as defined by qmake (C?!)
+#     * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake.
+#     * $(QT_INCPATH): -I's defined by qmake.
+#     * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH)
+#     * $(QT_LFLAGS): LFLAGS defined by qmake.
+#     * $(QT_LDFLAGS): Same thing as $(QT_LFLAGS).
+#     * $(QT_LIBS): LIBS defined by qmake.
+#
+# You *MUST* invoke $(MOC) and/or $(UIC) where necessary. AutoTroll provides
+# you with Makerules to ease this, here is a sample Makefile.am to use with
+# AutoTroll which builds the code given in the chapter 7 of the Qt Tutorial:
+# http://doc.trolltech.com/4.2/tutorial-t7.html
+#
+# -------------------------------------------------------------------------
+# include $(top_srcdir)/build-aux/autotroll.mk
+#
+# ACLOCAL_AMFLAGS = -I build-aux
+#
+# bin_PROGRAMS = lcdrange
+# lcdrange_SOURCES =  $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp
+# lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS)
+# lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS)
+# lcdrange_LDFLAGS  = $(QT_LDFLAGS) $(LDFLAGS)
+# lcdrange_LDADD    = $(QT_LIBS) $(LDADD)
+#
+# BUILT_SOURCES = lcdrange.moc.cpp
+# -------------------------------------------------------------------------
+#
+# Note that your MOC, UIC and QRC files *MUST* be listed manually in
+# BUILT_SOURCES. If you name them properly (eg: .moc.cc, .qrc.cc, .ui.cc -- of
+# course you can use .cpp or .cxx or .C rather than .cc) AutoTroll will build
+# them automagically for you (using implicit rules defined in autotroll.mk).
+
+
+
+
+
+
+
+# AT_WITH_QT([QT_modules], [QT_config], [QT_misc], [RUN-IF-FAILED], [RUN-IF-OK])
+# ------------------------------------------------------------------------------
+# Enable Qt support and add an option --with-qt to the configure script.
+#
+# The QT_modules argument is optional and defines extra modules to enable or
+# disable (it's equivalent to the QT variable in .pro files). Modules can be
+# specified as follows:
+#
+# AT_WITH_QT   => No argument -> No QT value.
+#                                Qmake sets it to "core gui" by default.
+# AT_WITH_QT([xml])   => QT += xml
+# AT_WITH_QT([+xml])  => QT += xml
+# AT_WITH_QT([-gui])  => QT -= gui
+# AT_WITH_QT([xml -gui +sql svg])  => QT += xml sql svg
+#                                     QT -= gui
+#
+# The QT_config argument is also optional and follows the same convention as
+# QT_modules. Instead of changing the QT variable, it changes the CONFIG
+# variable, which is used to tweak configuration and compiler options.
+#
+# The last argument, QT_misc (also optional) will be copied as-is the .pro
+# file used to guess how to compile Qt apps. You may use it to further tweak
+# the build process of Qt apps if tweaking the QT or CONFIG variables isn't
+# enough for you.
+#
+# RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
+# problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
+# called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
+
+
+# AT_REQUIRE_QT_VERSION(QT_version, RUN-IF-FAILED, RUN-IF-OK)
+# -----------------------------------------------------------
+# Check (using qmake) that Qt's version "matches" QT_version.
+# Must be run AFTER AT_WITH_QT. Requires autoconf 2.60.
+#
+# RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
+# problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
+# called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
+
+
+# _AT_TWEAK_PRO_FILE(QT_VAR, VALUE)
+# ---------------------------
+# @internal. Tweak the variable QT_VAR in the .pro.
+# VALUE is an IFS-separated list of value and each value is rewritten
+# as follows:
+#   +value  => QT_VAR += value
+#   -value  => QT_VAR -= value
+#    value  => QT_VAR += value
+
+
+  echo "$as_me: this is autotroll.m4 serial 4" >&5
+
+  test x"$TROLL" != x && echo 'ViM rox emacs.'
+
+
+# Check whether --with-qt was given.
+if test "${with_qt+set}" = set; then :
+  withval=$with_qt; QT_PATH=$withval
+fi
+
+
+  # this is a hack to get decent flow control with 'break'
+  for _qt_ignored in once; do
+
+  # Find Qt.
+
+  if test -d /usr/local/Trolltech; then
+    # Try to find the latest version.
+    tmp_qt_paths=`echo /usr/local/Trolltech/*/bin | tr ' ' '\n' | sort -nr \
+                                              | xargs | sed 's/  */:/g'`
+  fi
+  # Path to which recent MacPorts (~v1.7) install Qt4.
+  test -d /opt/local/libexec/qt4-mac/bin \
+    && tmp_qt_paths="$tmp_qt_paths:/opt/local/libexec/qt4-mac/bin"
+
+  # Find qmake.
+
+  for ac_prog in qmake qmake-qt4 qmake-qt3
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_QMAKE+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $QMAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_QMAKE="$QMAKE" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$QT_DIR:$QT_PATH:$PATH:$tmp_qt_paths"
+for as_dir in $as_dummy
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_QMAKE="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+QMAKE=$ac_cv_path_QMAKE
+if test -n "$QMAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $QMAKE" >&5
+$as_echo "$QMAKE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$QMAKE" && break
+done
+test -n "$QMAKE" || QMAKE="missing"
+
+  if test x"$QMAKE" = xmissing; then
+    as_fn_error "Cannot find qmake in your PATH. Try using --with-qt." "$LINENO" 5
+    break
+  fi
+
+  # Find moc (Meta Object Compiler).
+
+  for ac_prog in moc moc-qt4 moc-qt3
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_MOC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MOC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_MOC="$MOC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$QT_PATH:$PATH:$tmp_qt_paths"
+for as_dir in $as_dummy
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_MOC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+MOC=$ac_cv_path_MOC
+if test -n "$MOC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MOC" >&5
+$as_echo "$MOC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$MOC" && break
+done
+test -n "$MOC" || MOC="missing"
+
+  if test x"$MOC" = xmissing; then
+    as_fn_error "Cannot find moc (Meta Object Compiler) in your PATH. Try using --with-qt." "$LINENO" 5
+    break
+  fi
+
+  # Find uic (User Interface Compiler).
+
+  for ac_prog in uic uic-qt4 uic-qt3 uic3
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_UIC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $UIC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_UIC="$UIC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$QT_PATH:$PATH:$tmp_qt_paths"
+for as_dir in $as_dummy
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_UIC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+UIC=$ac_cv_path_UIC
+if test -n "$UIC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UIC" >&5
+$as_echo "$UIC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$UIC" && break
+done
+test -n "$UIC" || UIC="missing"
+
+  if test x"$UIC" = xmissing; then
+    as_fn_error "Cannot find uic (User Interface Compiler) in your PATH. Try using --with-qt." "$LINENO" 5
+    break
+  fi
+
+  # Find rcc (Qt Resource Compiler).
+
+  for ac_prog in rcc
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_RCC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $RCC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_RCC="$RCC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$QT_PATH:$PATH:$tmp_qt_paths"
+for as_dir in $as_dummy
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_RCC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+RCC=$ac_cv_path_RCC
+if test -n "$RCC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RCC" >&5
+$as_echo "$RCC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$RCC" && break
+done
+test -n "$RCC" || RCC="false"
+
+  if test x"$UIC" = xfalse; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find rcc (Qt Resource Compiler) in your PATH.\
+  Try using --with-qt." >&5
+$as_echo "$as_me: WARNING: Cannot find rcc (Qt Resource Compiler) in your PATH.\
+  Try using --with-qt." >&2;}
+  fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether host operating system is Darwin" >&5
+$as_echo_n "checking whether host operating system is Darwin... " >&6; }
+  at_darwin=no
+  at_qmake_args=
+  case $host_os in
+    darwin*)
+      at_darwin=yes
+      at_qmake_args='-spec macx-g++'
+      ;;
+  esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_darwin" >&5
+$as_echo "$at_darwin" >&6; }
+
+  # If we don't know the path to Qt, guess it from the path to qmake.
+  if test x"$QT_PATH" = x; then
+    QT_PATH=`dirname "$QMAKE"`
+  fi
+  if test x"$QT_PATH" = x; then
+    as_fn_error "Cannot find the path to your Qt install. Use --with-qt." "$LINENO" 5
+    break
+  fi
+
+
+  # Get ready to build a test-app with Qt.
+  if mkdir conftest.dir && cd conftest.dir; then :; else
+    as_fn_error "Cannot mkdir conftest.dir or cd to that directory." "$LINENO" 5
+    break
+  fi
+
+  cat >conftest.h <<_ASEOF
+#include <QObject>
+
+class Foo: public QObject
+{
+  Q_OBJECT;
+public:
+  Foo();
+  ~Foo() {}
+public Q_SLOTS:
+  void setValue(int value);
+Q_SIGNALS:
+  void valueChanged(int newValue);
+private:
+  int value_;
+};
+_ASEOF
+
+  cat >conftest.cpp <<_ASEOF
+#include "conftest.h"
+Foo::Foo()
+  : value_ (42)
+{
+  connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
+}
+
+void Foo::setValue(int value)
+{
+  value_ = value;
+}
+
+int main()
+{
+  Foo f;
+}
+_ASEOF
+  if $QMAKE -project; then :; else
+    as_fn_error "Calling $QMAKE -project failed." "$LINENO" 5
+    break
+  fi
+
+  # Find the .pro file generated by qmake.
+  pro_file='conftest.dir.pro'
+  test -f $pro_file || pro_file=`echo *.pro`
+  if test -f "$pro_file"; then :; else
+    as_fn_error "Can't find the .pro file generated by Qmake." "$LINENO" 5
+    break
+  fi
+
+ # Tweak the value of QT in the .pro file for +xmlpatterns.
+
+  qt_conf=''
+  for at_mod in +xmlpatterns; do
+    at_mod=`echo "$at_mod" | sed 's/^-//; tough
+                                  s/^+//; beef
+                                  :ough
+                                  s/^/QT -= /;n
+                                  :eef
+                                  s/^/QT += /'`
+    qt_conf="$qt_conf
+$at_mod"
+  done
+  echo "$qt_conf" | sed 1d >>"$pro_file"
+
+
+
+
+
+
+  echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" >&5
+  sed 's/^/| /' "$pro_file" >&5
+
+  if $QMAKE $at_qmake_args; then :; else
+    as_fn_error "Calling $QMAKE $at_qmake_args failed." "$LINENO" 5
+    break
+  fi
+
+  # QMake has a very annoying misfeature: sometimes it generates Makefiles
+  # where all the references to the files from the Qt installation are
+  # relative.  We can't use them as-is because if we take, say, a
+  # -I../../usr/include/Qt from that Makefile, the flag is invalid as soon
+  # as we use it in another (sub) directory.  So what this perl pass does is
+  # that it rewrite all relative paths to absolute paths.  Another problem
+  # when building on Cygwin is that QMake mixes paths with blackslashes and
+  # forward slashes and paths must be handled with extra care because of the
+  # stupid Windows drive letters.
+  echo "$as_me:$LINENO: fixing the Makefiles:" Makefile* >&5
+  cat >fixmk.pl <<\EOF
+use strict;
+use Cwd qw(cwd abs_path);
+# This variable is useful on Cygwin for the following reason: Say that you are
+# in `/' (that is, in fact you are in C:/cygwin, or something like that) if you
+# `cd ..' then obviously you remain in `/' (that is in C:/cygwin).  QMake
+# generates paths that are relative to C:/ (or another driver letter, whatever)
+# so the trick to get the `..' resolved properly is to prepend the absolute
+# path of the current working directory in a Windows-style.  C:/cygwin/../ will
+# properly become C:/.
+my $d = "";
+my $r2a = 0;
+my $b2f = 0;
+
+my $cygwin = 0;
+if ($^O eq "cygwin") {
+  $cygwin = 1;
+  $d = cwd();
+  $d = `cygpath --mixed '$d'`;
+  chomp($d);
+  $d .= "/";
+}
+
+sub rel2abs($)
+{
+  my $p = $d . shift;
+  # print "r2a p=$p";
+  -e $p || return $p;
+  if ($cygwin) {
+    $p = `cygpath --mixed '$p'`;
+    chomp($p);
+  }
+  else {
+    # Do not use abs_path on Cygwin: it incorrectly resolves the paths that are
+    # relative to C:/ rather than `/'.
+    $p = abs_path($p);
+  }
+  # print " -> $p\n";
+  ++$r2a;
+  return $p;
+}
+
+# Only useful on Cygwin.
+sub back2forward($)
+{
+  my $p = shift;
+  # print "b2f p=$p";
+  -e $p || return $p;
+  $p = `cygpath --mixed '$p'`;
+  chomp($p);
+  # print " -> $p\n";
+  ++$b2f;
+  return $p;
+}
+
+foreach my $mk (@ARGV)
+{
+  next if $mk =~ /~$/;
+  open(MK, $mk) or die("open $mk: $!");
+  # print "mk=$mk\n";
+  my $file = join("", <MK>);
+  close(MK) or die("close $mk: $!");
+  rename $mk, $mk . "~" or die("rename $mk: $!");
+  $file =~ s{(?:\.\.[\\/])+(?:[^"'\s:]+)}{rel2abs($&)}gse;
+  $file =~ s{(?:[a-zA-Z]:[\\/])?(?:[^"\s]+\\[^"\s:]+)+}
+            {back2forward($&)}gse if $cygwin;
+  open(MK, ">", $mk) or die("open >$mk: $!");
+  print MK $file;
+  close(MK) or die("close >$mk: $!");
+  print "$mk: updated $r2a relative paths and $b2f backslash-style paths\n";
+  $r2a = 0;
+  $b2f = 0;
+}
+EOF
+
+  perl >&5 -w fixmk.pl Makefile* ||
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: failed to fix the Makefiles generated by $QMAKE" >&5
+$as_echo "$as_me: WARNING: failed to fix the Makefiles generated by $QMAKE" >&2;}
+  rm -f fixmk.pl
+
+  # Try to compile a simple Qt app.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can build a simple Qt app" >&5
+$as_echo_n "checking whether we can build a simple Qt app... " >&6; }
+if test "${at_cv_qt_build+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_qt_build=ko
+  : ${MAKE=make}
+
+  if $MAKE >&5 2>&1; then
+    at_cv_qt_build='ok, looks like Qt 4'
+  else
+    echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
+instead" >&5
+    sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h && mv tmp.h conftest.h
+    if $MAKE >&5 2>&1; then
+      at_cv_qt_build='ok, looks like Qt 3'
+    else
+      # Sometimes (such as on Debian) build will fail because Qt hasn't been
+      # installed in debug mode and qmake tries (by default) to build apps in
+      # debug mode => Try again in release mode.
+      echo "$as_me:$LINENO: Build failed, trying to enforce release mode" \
+            >&5
+
+       # Tweak the value of CONFIG in the .pro file for +release.
+
+  qt_conf=''
+  for at_mod in +release; do
+    at_mod=`echo "$at_mod" | sed 's/^-//; tough
+                                  s/^+//; beef
+                                  :ough
+                                  s/^/CONFIG -= /;n
+                                  :eef
+                                  s/^/CONFIG += /'`
+    qt_conf="$qt_conf
+$at_mod"
+  done
+  echo "$qt_conf" | sed 1d >>"$pro_file"
+
+
+      sed 's/<qobject.h>/<QObject>/' conftest.h > tmp.h && mv tmp.h conftest.h
+      if $MAKE >&5 2>&1; then
+        at_cv_qt_build='ok, looks like Qt 4, release mode forced'
+      else
+        echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
+instead" >&5
+        sed 's/<QObject>/<qobject.h>/' conftest.h >tmp.h && mv tmp.h conftest.h
+        if $MAKE >&5 2>&1; then
+          at_cv_qt_build='ok, looks like Qt 3, release mode forced'
+        else
+          at_cv_qt_build=ko
+          echo "$as_me:$LINENO: failed program was:" >&5
+          sed 's/^/| /' conftest.h >&5
+          echo "$as_me:$LINENO: failed program was:" >&5
+          sed 's/^/| /' conftest.cpp >&5
+        fi # if make with Qt3-style #include and release mode forced.
+      fi # if make with Qt4-style #include and release mode forced.
+    fi # if make with Qt3-style #include.
+  fi # if make with Qt4-style #include.
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_qt_build" >&5
+$as_echo "$at_cv_qt_build" >&6; }
+  if test x"$at_cv_qt_build" = xko; then
+    as_fn_error "Cannot build a test Qt program" "$LINENO" 5
+    break
+  fi
+  QT_VERSION_MAJOR=`echo "$at_cv_qt_build" | sed 's/[^0-9]*//g'`
+
+
+  # This sed filter is applied after an expression of the form: /^FOO.*=/!d;
+  # It starts by removing the beginning of the line, removing references to
+  # SUBLIBS, removing unnecessary whitespaces at the beginning, and prefixes
+  # all variable uses by QT_.
+  qt_sed_filter='s///;
+                 s/$(SUBLIBS)//g;
+                 s/^ *//;
+                 s/\$(\([A-Z_][A-Z_]*\))/$(QT_\1)/g'
+
+  # Find the Makefile (qmake happens to generate a fake Makefile which invokes
+  # a Makefile.Debug or Makefile.Release). We we have both, we'll pick the
+  # Makefile.Release. The reason is that the main difference is that release
+  # uses -Os and debug -g. We can override -Os by passing another -O but we
+  # usually don't override -g.
+  if test -f Makefile.Release; then
+    at_mfile='Makefile.Release'
+  else
+    at_mfile='Makefile'
+  fi
+  if test -f $at_mfile; then :; else
+    as_fn_error "Cannot find the Makefile generated by qmake." "$LINENO" 5
+    break
+  fi
+
+  # Find the DEFINES of Qt (should have been named CPPFLAGS).
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the DEFINES to use with Qt" >&5
+$as_echo_n "checking for the DEFINES to use with Qt... " >&6; }
+if test "${at_cv_env_QT_DEFINES+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_env_QT_DEFINES=`sed "/^DEFINES[^A-Z=]*=/!d;$qt_sed_filter" $at_mfile`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_env_QT_DEFINES" >&5
+$as_echo "$at_cv_env_QT_DEFINES" >&6; }
+  QT_DEFINES=$at_cv_env_QT_DEFINES
+
+
+  # Find the CFLAGS of Qt (We can use Qt in C?!)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the CFLAGS to use with Qt" >&5
+$as_echo_n "checking for the CFLAGS to use with Qt... " >&6; }
+if test "${at_cv_env_QT_CFLAGS+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_env_QT_CFLAGS=`sed "/^CFLAGS[^A-Z=]*=/!d;$qt_sed_filter" $at_mfile`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_env_QT_CFLAGS" >&5
+$as_echo "$at_cv_env_QT_CFLAGS" >&6; }
+  QT_CFLAGS=$at_cv_env_QT_CFLAGS
+
+
+  # Find the CXXFLAGS of Qt.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the CXXFLAGS to use with Qt" >&5
+$as_echo_n "checking for the CXXFLAGS to use with Qt... " >&6; }
+if test "${at_cv_env_QT_CXXFLAGS+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_env_QT_CXXFLAGS=`sed "/^CXXFLAGS[^A-Z=]*=/!d;$qt_sed_filter" $at_mfile`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_env_QT_CXXFLAGS" >&5
+$as_echo "$at_cv_env_QT_CXXFLAGS" >&6; }
+  QT_CXXFLAGS=$at_cv_env_QT_CXXFLAGS
+
+
+  # Find the INCPATH of Qt.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the INCPATH to use with Qt" >&5
+$as_echo_n "checking for the INCPATH to use with Qt... " >&6; }
+if test "${at_cv_env_QT_INCPATH+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_env_QT_INCPATH=`sed "/^INCPATH[^A-Z=]*=/!d;$qt_sed_filter" $at_mfile`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_env_QT_INCPATH" >&5
+$as_echo "$at_cv_env_QT_INCPATH" >&6; }
+  QT_INCPATH=$at_cv_env_QT_INCPATH
+
+
+  QT_CPPFLAGS="$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"
+
+
+  # Find the LFLAGS of Qt (Should have been named LDFLAGS)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the LDFLAGS to use with Qt" >&5
+$as_echo_n "checking for the LDFLAGS to use with Qt... " >&6; }
+if test "${at_cv_env_QT_LDFLAGS+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS[^A-Z=]*=/!d;$qt_sed_filter" $at_mfile`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_env_QT_LDFLAGS" >&5
+$as_echo "$at_cv_env_QT_LDFLAGS" >&6; }
+  QT_LFLAGS=$at_cv_env_QT_LDFLAGS
+
+  QT_LDFLAGS=$at_cv_env_QT_LDFLAGS
+
+
+  # Find the LIBS of Qt.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the LIBS to use with Qt" >&5
+$as_echo_n "checking for the LIBS to use with Qt... " >&6; }
+if test "${at_cv_env_QT_LIBS+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  at_cv_env_QT_LIBS=`sed "/^LIBS[^A-Z]*=/!d;$qt_sed_filter" $at_mfile`
+   if test x$at_darwin = xyes; then
+     # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a) doesn't handle
+     # -F properly. The "bug" has been fixed on 22 October 2006
+     # by Peter O'Gorman but we provide backward compatibility here.
+     at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \
+                             | sed 's/^-F/-Wl,-F/;s/ -F/ -Wl,-F/g'`
+   fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_env_QT_LIBS" >&5
+$as_echo "$at_cv_env_QT_LIBS" >&6; }
+  QT_LIBS=$at_cv_env_QT_LIBS
+
+
+  cd .. && rm -rf conftest.dir
+
+  # Run the user code
+
+
+  done  # end hack (useless for to be able to use break)
+
+
+  # this is a hack to get decent flow control with 'break'
+  for _qt_ignored in once; do
+
+  if test x"$QMAKE" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \$QMAKE is empty.\
+  Did you invoke AT_WITH_QT before AT_REQUIRE_QT_VERSION?" >&5
+$as_echo "$as_me: WARNING: \$QMAKE is empty.\
+  Did you invoke AT_WITH_QT before AT_REQUIRE_QT_VERSION?" >&2;}; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Qt version >= 4.6 is required" >&5
+$as_echo "$as_me: WARNING: Qt version >= 4.6 is required" >&2;}
+    break
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Qt's version" >&5
+$as_echo_n "checking for Qt's version... " >&6; }
+if test "${at_cv_QT_VERSION+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  echo "$as_me:$LINENO: Running $QMAKE --version:" >&5
+  $QMAKE --version >&5 2>&1
+  qmake_version_sed='/^.*\([0-9]\.[0-9]\.[0-9]\).*$/!d;s//\1/'
+  at_cv_QT_VERSION=`$QMAKE --version 2>&1 | sed "$qmake_version_sed"`
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $at_cv_QT_VERSION" >&5
+$as_echo "$at_cv_QT_VERSION" >&6; }
+  if test x"$at_cv_QT_VERSION" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot detect Qt's version." >&5
+$as_echo "$as_me: WARNING: Cannot detect Qt's version." >&2;}; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Qt version >= 4.6 is required" >&5
+$as_echo "$as_me: WARNING: Qt version >= 4.6 is required" >&2;}
+    break
+  fi
+  QT_VERSION=$at_cv_QT_VERSION
+
+  as_arg_v1=$QT_VERSION
+as_arg_v2=4.6
+awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
+case $? in #(
+  1) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This package requires Qt 4.6 or above." >&5
+$as_echo "$as_me: WARNING: This package requires Qt 4.6 or above." >&2;}; { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Qt version >= 4.6 is required" >&5
+$as_echo "$as_me: WARNING: Qt version >= 4.6 is required" >&2;}; break;  ;; #(
+  0) :
+     ;; #(
+  2) :
+     ;; #(
+  *) :
+     ;;
+esac
+
+  # Run the user code
+
+
+  done  # end hack (useless for to be able to use break)
+
+  $as_echo "#define MAGICS_QT 1" >>confdefs.h
+
+  CPPFLAGS="-I/usr/include/qt4 ${CPPFLAGS}"  ### for Ubuntu 11.04
+fi
+
+######################################################################
+#
+#     Qt debug
+#
+######################################################################
+# Check whether --enable-qtdebug was given.
+if test "${enable_qtdebug+set}" = set; then :
+  enableval=$enable_qtdebug; qtdebug=$enableval
+else
+  qtdebug=no
+fi
+
+
+if test "x${qt}" = xyes -a "x${qtdebug}" = xno ; then
+	CXXFLAGS="${CXXFLAGS} -DQT_NO_DEBUG_OUTPUT"
+fi
+
+
+#####################
+###  M E T V I E W
+
+if test "x$metview" = "xyes" ; then
+  allheaders=yes
+  $as_echo "#define MAGICS_METVIEW 1" >>confdefs.h
+
+fi
+
+
+
+
+#
+#  Raster graphics support
+#
+raster=yes
+# Check whether --enable-raster was given.
+if test "${enable_raster+set}" = set; then :
+  enableval=$enable_raster; raster=$enableval
+else
+  raster=yes
+fi
+
+if test "x$raster" = "xyes" ; then
+
+# Check whether --with-gd was given.
+if test "${with_gd+set}" = set; then :
+  withval=$with_gd; CPPFLAGS="-I${with_gd}/include ${CPPFLAGS}";LDFLAGS="-L${with_gd}/${LIBNAME} ${LDFLAGS}"
+
+fi
+
+  ac_fn_c_check_header_mongrel "$LINENO" "gd.h" "ac_cv_header_gd_h" "$ac_includes_default"
+if test "x$ac_cv_header_gd_h" = x""yes; then :
+   have_gd_h="yes"
+else
+   have_gd_h="no"
+fi
+
+
+
+  if test "x$have_gd_h" != "xyes"; then
+   echo
+   echo "   The GD library is required for raster file support in Magics to function."
+   echo "   You can get it from http://www.libgd.org . If your system"
+   echo "   has libgd installed, you probably miss the gd.h header file."
+   raster="no"
+  else
+   $as_echo "#define MAGICS_RASTER 1" >>confdefs.h
+
+  fi
+fi
+
+
+############################################
+#
+#  enable all headers
+#
+if test "x$allheaders" = "xyes" ; then
+  $as_echo "#define MAGICS_ALLHEADERS 1" >>confdefs.h
+
+fi
+
+#
+#  JSON support  --enable-json
+#
+# Check whether --enable-json was given.
+if test "${enable_json+set}" = set; then :
+  enableval=$enable_json; json=$enableval
+else
+  json=yes
+fi
+
+if test "x$json" = "xyes"  ; then
+  $as_echo "#define MAGICS_JSON 1" >>confdefs.h
+
+fi
+
+#
+#  apps compilation --enable-apps
+#
+# Check whether --enable-apps was given.
+if test "${enable_apps+set}" = set; then :
+  enableval=$enable_apps; apps=$enableval
+else
+  apps=yes
+fi
+
+
+#
+#  BUFR support  --enable-bufr
+#
+# Check whether --enable-bufr was given.
+if test "${enable_bufr+set}" = set; then :
+  enableval=$enable_bufr; bufr=$enableval
+else
+  bufr=no
+fi
+
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+##############################################################################
+##
+##  ODB support  --enable-odb
+##
+# Check whether --enable-odb was given.
+if test "${enable_odb+set}" = set; then :
+  enableval=$enable_odb; odb=$enableval
+else
+  odb=no
+fi
+
+
+if test "x$odb" = "xyes" ; then
+  $as_echo "#define MAGICS_ODB 1" >>confdefs.h
+
+  ODB_PATH="/usr/local"
+
+# Check whether --with-odb was given.
+if test "${with_odb+set}" = set; then :
+  withval=$with_odb; ODB_PATH="${with_odb}";CPPFLAGS="-I${with_odb}/include -I${with_odb}/include/eclib -I${with_odb}/include/odb_api ${CPPFLAGS}";LDFLAGS="-L${with_odb}/lib ${LDFLAGS}"
+
+fi
+
+
+#  AC_CHECK_LIB(Ec,link_eclib,,,)
+#  AC_CHECK_LIB(Odb,odb_init,,,)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking Checking for ODB libraries in ${ODB_PATH}/lib/" >&5
+$as_echo_n "checking Checking for ODB libraries in ${ODB_PATH}/lib/... " >&6; }
+  if test -f ${ODB_PATH}/lib/libOdb.so ; then
+    MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -L${ODB_PATH}/lib -lEc -lOdb"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: FAILED" >&5
+$as_echo "FAILED" >&6; }
+    as_fn_error "Could not find ODB library at ${ODB_PATH}/lib/libOdb.so" "$LINENO" 5
+  fi
+fi
+
+
+##############################################################################
+#
+# Update developments for metview (development)
+#
+# Check whether --enable-magnext was given.
+if test "${enable_magnext+set}" = set; then :
+  enableval=$enable_magnext; magnext=$enableval
+else
+  magnext=no
+fi
+
+
+if test "x$magnext" = "xyes" ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: ENABLED EXPERIMENTAL FEATURES FOR METVIEW (ECMWF)" >&5
+$as_echo "$as_me: ENABLED EXPERIMENTAL FEATURES FOR METVIEW (ECMWF)" >&6;}
+  CXXFLAGS="${CXXFLAGS} -DMAG_NEXT"
+fi
+
+
+#
+# freetype
+#
+if test "x$raster" = "xyes" ; then
+
+ac_fn_cxx_check_header_mongrel "$LINENO" "ft2build.h" "ac_cv_header_ft2build_h" "$ac_includes_default"
+if test "x$ac_cv_header_ft2build_h" = x""yes; then :
+  $as_echo "#define MAGICS_TTF 1" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not successfully compile with FreeType2 using the" >&5
+$as_echo "$as_me: WARNING: could not successfully compile with FreeType2 using the" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: default compiler flags; " >&5
+$as_echo "$as_me: WARNING: default compiler flags; " >&2;}
+fi
+
+
+fi
+
+
+#
+# TIFF
+#
+##AC_ARG_ENABLE(tiff, [[  --enable-tiff         enable the TIFF output [default=no]]],
+##tiff=$enableval, tiff=no)
+
+#if test "x$tiff" = "xyes" ; then
+
+#AC_CHECK_HEADER(tiffio.h,,
+#  AC_MSG_WARN([could not successfully compile with TIFF using the])
+#  AC_MSG_WARN([default compiler flags;])
+#  unset ac_cv_header_tiff_h)
+
+#  AC_DEFINE(MAGICS_TIFF, 1)
+#fi
+
+
+#
+# For XML parser expat
+#
+ac_fn_cxx_check_header_mongrel "$LINENO" "expat.h" "ac_cv_header_expat_h" "$ac_includes_default"
+if test "x$ac_cv_header_expat_h" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not successfully compile with expat using the" >&5
+$as_echo "$as_me: WARNING: could not successfully compile with expat using the" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: default compiler flags;" >&5
+$as_echo "$as_me: WARNING: default compiler flags;" >&2;}
+  unset ac_cv_header_expat_h
+fi
+
+
+
+
+#
+# For  B O O S T
+#
+
+
+# Check whether --with-boost was given.
+if test "${with_boost+set}" = set; then :
+  withval=$with_boost;
+    if test "$withval" = "no"; then
+        want_boost="no"
+    elif test "$withval" = "yes"; then
+        want_boost="yes"
+        ac_boost_path=""
+    else
+        want_boost="yes"
+        ac_boost_path="$withval"
+    fi
+
+else
+  want_boost="yes"
+fi
+
+
+
+
+# Check whether --with-boost-libdir was given.
+if test "${with_boost_libdir+set}" = set; then :
+  withval=$with_boost_libdir;
+        if test -d "$withval"
+        then
+                ac_boost_lib_path="$withval"
+        else
+                as_fn_error "--with-boost-libdir expected directory name" "$LINENO" 5
+        fi
+
+else
+  ac_boost_lib_path=""
+
+fi
+
+
+if test "x$want_boost" = "xyes"; then
+    boost_lib_version_req=1.32
+    boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([0-9]*\.[0-9]*\)'`
+    boost_lib_version_req_major=`expr $boost_lib_version_req : '\([0-9]*\)'`
+    boost_lib_version_req_minor=`expr $boost_lib_version_req : '[0-9]*\.\([0-9]*\)'`
+    boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
+    if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+        boost_lib_version_req_sub_minor="0"
+        fi
+    WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for boostlib >= $boost_lib_version_req" >&5
+$as_echo_n "checking for boostlib >= $boost_lib_version_req... " >&6; }
+    succeeded=no
+
+                        libsubdirs="lib"
+    ax_arch=`uname -m`
+    if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then
+        libsubdirs="lib64 lib lib64"
+    fi
+
+                if test "$ac_boost_path" != ""; then
+        BOOST_CPPFLAGS="-I$ac_boost_path/include"
+        for ac_boost_path_tmp in $libsubdirs; do
+                if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
+                        BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
+                        break
+                fi
+        done
+    elif test "$cross_compiling" != yes; then
+        for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+            if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+                for libsubdir in $libsubdirs ; do
+                    if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+                done
+                BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
+                BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+                break;
+            fi
+        done
+    fi
+
+            if test "$ac_boost_lib_path" != ""; then
+       BOOST_LDFLAGS="-L$ac_boost_lib_path"
+    fi
+
+    CPPFLAGS_SAVED="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+    export CPPFLAGS
+
+    LDFLAGS_SAVED="$LDFLAGS"
+    LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+    export LDFLAGS
+
+
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+    #include <boost/version.hpp>
+
+int
+main ()
+{
+
+    #if BOOST_VERSION >= $WANT_BOOST_VERSION
+    // Everything is okay
+    #else
+    #  error Boost version is too old
+    #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    succeeded=yes
+    found_system=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+
+
+            if test "x$succeeded" != "xyes"; then
+        _version=0
+        if test "$ac_boost_path" != ""; then
+            if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+                for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+                    _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+                    V_CHECK=`expr $_version_tmp \> $_version`
+                    if test "$V_CHECK" = "1" ; then
+                        _version=$_version_tmp
+                    fi
+                    VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+                    BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+                done
+            fi
+        else
+            if test "$cross_compiling" != yes; then
+                for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+                    if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+                        for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+                            _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+                            V_CHECK=`expr $_version_tmp \> $_version`
+                            if test "$V_CHECK" = "1" ; then
+                                _version=$_version_tmp
+                                best_path=$ac_boost_path
+                            fi
+                        done
+                    fi
+                done
+
+                VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+                BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+                if test "$ac_boost_lib_path" = ""; then
+                    for libsubdir in $libsubdirs ; do
+                        if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+                    done
+                    BOOST_LDFLAGS="-L$best_path/$libsubdir"
+                fi
+            fi
+
+            if test "x$BOOST_ROOT" != "x"; then
+                for libsubdir in $libsubdirs ; do
+                    if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+                done
+                if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
+                    version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+                    stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+                        stage_version_shorten=`expr $stage_version : '\([0-9]*\.[0-9]*\)'`
+                    V_CHECK=`expr $stage_version_shorten \>\= $_version`
+                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+                        { $as_echo "$as_me:${as_lineno-$LINENO}: We will use a staged boost library from $BOOST_ROOT" >&5
+$as_echo "$as_me: We will use a staged boost library from $BOOST_ROOT" >&6;}
+                        BOOST_CPPFLAGS="-I$BOOST_ROOT"
+                        BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
+                    fi
+                fi
+            fi
+        fi
+
+        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+        export CPPFLAGS
+        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+        export LDFLAGS
+
+        ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+        #include <boost/version.hpp>
+
+int
+main ()
+{
+
+        #if BOOST_VERSION >= $WANT_BOOST_VERSION
+        // Everything is okay
+        #else
+        #  error Boost version is too old
+        #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+        succeeded=yes
+        found_system=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+        ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+    fi
+
+    if test "$succeeded" != "yes" ; then
+        if test "$_version" = "0" ; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation." >&5
+$as_echo "$as_me: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation." >&6;}
+        else
+            { $as_echo "$as_me:${as_lineno-$LINENO}: Your boost libraries seems to old (version $_version)." >&5
+$as_echo "$as_me: Your boost libraries seems to old (version $_version)." >&6;}
+        fi
+        # execute ACTION-IF-NOT-FOUND (if present):
+        as_fn_error "Boost library not found - if you use RPM do not forget boost-devel" "$LINENO" 5
+    else
+
+
+
+$as_echo "#define HAVE_BOOST /**/" >>confdefs.h
+
+        # execute ACTION-IF-FOUND (if present):
+        :
+    fi
+
+    CPPFLAGS="$CPPFLAGS_SAVED"
+    LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+
+ac_fn_cxx_check_header_mongrel "$LINENO" "boost/math/complex.hpp" "ac_cv_header_boost_math_complex_hpp" "$ac_includes_default"
+if test "x$ac_cv_header_boost_math_complex_hpp" = x""yes; then :
+
+else
+  as_fn_error "could not successfully compile with Boost::Math package" "$LINENO" 5
+  unset ac_cv_header_boost_h
+fi
+
+
+
+### Boost.Filesystem
+#AC_CHECK_LIB([boost_system-mt], [main],
+#             [BOOST_FILESYSTEM_LIBS='-lboost_system-mt';LIBS="${LIBS} -lboost_system-mt"],
+#             [AC_MSG_ERROR([Boost.System not found])])
+#AC_CHECK_LIB([boost_filesystem-mt], [main],
+#             [BOOST_FILESYSTEM_LIBS="-lboost_filesystem-mt ${BOOST_FILESYSTEM_LIBS}"],
+#             [AC_MSG_ERROR([Boost.Filesystem not found])])
+#AC_SUBST([BOOST_FILESYSTEM_LIBS])
+#LIBS="$LIBS ${BOOST_FILESYSTEM_LIBS}"
+#MAGICS_3RDPARTY_LIBS="$MAGICS_3RDPARTY_LIBS ${BOOST_FILESYSTEM_LIBS}"
+
+########################################################
+#
+# Check for GRIB API
+#
+# We don't know whether GRIB API was built with jasper or openjeg requirements,
+# so we check for both
+
+# Check whether --enable-grib was given.
+if test "${enable_grib+set}" = set; then :
+  enableval=$enable_grib; grib=$enableval
+else
+  grib=yes
+fi
+
+
+if test "x${grib}" = "xyes" ; then
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jas_stream_memopen in -ljasper" >&5
+$as_echo_n "checking for jas_stream_memopen in -ljasper... " >&6; }
+if test "${ac_cv_lib_jasper_jas_stream_memopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ljasper  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char jas_stream_memopen ();
+int
+main ()
+{
+return jas_stream_memopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_jasper_jas_stream_memopen=yes
+else
+  ac_cv_lib_jasper_jas_stream_memopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jasper_jas_stream_memopen" >&5
+$as_echo "$ac_cv_lib_jasper_jas_stream_memopen" >&6; }
+if test "x$ac_cv_lib_jasper_jas_stream_memopen" = x""yes; then :
+  have_jasper="yes"
+else
+  have_jasper="no"
+fi
+
+if test "${have_jasper}" = "no"
+then
+	echo " "
+	echo "  No Jasper (JPEG 2000) library could be found!"
+	echo "    Your Magics++ programs should work nevertheless as long as"
+	echo "    your GribAPI installed does NOT require it! Compile GribAPI"
+	echo "    without Jasper support."
+	echo " "
+else
+	LIBS="${LIBS} -ljasper"
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for opj_decode in -lopenjpeg" >&5
+$as_echo_n "checking for opj_decode in -lopenjpeg... " >&6; }
+if test "${ac_cv_lib_openjpeg_opj_decode+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lopenjpeg  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opj_decode ();
+int
+main ()
+{
+return opj_decode ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_openjpeg_opj_decode=yes
+else
+  ac_cv_lib_openjpeg_opj_decode=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_openjpeg_opj_decode" >&5
+$as_echo "$ac_cv_lib_openjpeg_opj_decode" >&6; }
+if test "x$ac_cv_lib_openjpeg_opj_decode" = x""yes; then :
+  have_openjpeg="yes"
+else
+  have_openjpeg="no"
+fi
+
+if test "${have_openjpeg}" = "no"
+then
+	echo " "
+	echo "  No openjpeg (JPEG 2000) library could be found!"
+	echo "    Your Magics++ programs should work nevertheless as long as"
+	echo "    your GribAPI installed does NOT require it! Compile GribAPI"
+	echo "    without openjpeg support."
+	echo " "
+else
+	LIBS="${LIBS} -lopenjpeg"
+fi
+
+
+
+
+# Check whether --with-grib-api was given.
+if test "${with_grib_api+set}" = set; then :
+  withval=$with_grib_api; GRIBAPI_ROOT="${with_grib_api}";CPPFLAGS="-I${with_grib_api}/include ${CPPFLAGS}";LDFLAGS="-L${with_grib_api}/${LIBNAME} -L${with_grib_api}/lib ${LDFLAGS}"; GRIBAPI_LIBS="-L${with_grib_api}/${LIBNAME} "
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grib_get_message in -lgrib_api" >&5
+$as_echo_n "checking for grib_get_message in -lgrib_api... " >&6; }
+if test "${ac_cv_lib_grib_api_grib_get_message+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgrib_api  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char grib_get_message ();
+int
+main ()
+{
+return grib_get_message ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_grib_api_grib_get_message=yes
+else
+  ac_cv_lib_grib_api_grib_get_message=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_grib_api_grib_get_message" >&5
+$as_echo "$ac_cv_lib_grib_api_grib_get_message" >&6; }
+if test "x$ac_cv_lib_grib_api_grib_get_message" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGRIB_API 1
+_ACEOF
+
+  LIBS="-lgrib_api $LIBS"
+
+else
+  as_fn_error "Grib API could not be linked! Try setting --with-grib-api or add dependent libraries if necessary to configure call (\"LIBS=-lpng\")." "$LINENO" 5
+fi
+
+
+
+
+$as_echo "#define MAGICS_GRIB 1" >>confdefs.h
+
+fi
+
+#############################################################################################################
+#
+if test "x$bufr" = "xyes" -a "x$windows" = xno; then
+#
+#     E M O S L I B -- always DOUBLE precision !!!
+#
+# check if MvOBS files are prperly linked/copied from Metview
+if test -e src/MvObs/MvBufr.h ; then
+
+
+# Check whether --with-fortran-libraries was given.
+if test "${with_fortran_libraries+set}" = set; then :
+  withval=$with_fortran_libraries; FORTRAN_LIB_PATH=$with_fortran_libraries;LDFLAGS="-L$with_fortran_libraries $LDFLAGS"
+
+fi
+
+
+
+EMOS_LIB_NAME="emosR64"
+
+
+# Check whether --with-emos-libraries was given.
+if test "${with_emos_libraries+set}" = set; then :
+  withval=$with_emos_libraries; LDFLAGS="-L$with_emos_libraries $LDFLAGS"
+
+fi
+
+
+
+# Check whether --with-emos-libname was given.
+if test "${with_emos_libname+set}" = set; then :
+  withval=$with_emos_libname; EMOS_LIB_NAME="$with_emos_libname"
+
+fi
+
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to get verbose linking output from $F77" >&5
+$as_echo_n "checking how to get verbose linking output from $F77... " >&6; }
+if test "${ac_cv_prog_f77_v+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_cv_prog_f77_v=
+# Try some options frequently used verbose output
+for ac_verb in -v -verbose --verbose -V -\#\#\#; do
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+
+# Compile and link our simple test program by passing a flag (argument
+# 1 to this macro) to the Fortran compiler in order to get
+# "verbose" output that we can then parse for the Fortran linker
+# flags.
+ac_save_FFLAGS=$FFLAGS
+FFLAGS="$FFLAGS $ac_verb"
+eval "set x $ac_link"
+shift
+$as_echo "$as_me:${as_lineno-$LINENO}: $*" >&5
+# gfortran 4.3 outputs lines setting COLLECT_GCC_OPTIONS, COMPILER_PATH,
+# LIBRARY_PATH; skip all such settings.
+ac_f77_v_output=`eval $ac_link 5>&1 2>&1 |
+  grep -v 'Driving:' | grep -v "^[_$as_cr_Letters][_$as_cr_alnum]*="`
+$as_echo "$ac_f77_v_output" >&5
+FFLAGS=$ac_save_FFLAGS
+
+rm -rf conftest*
+
+# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
+# /foo, /bar, and /baz are search directories for the Fortran linker.
+# Here, we change these into -L/foo -L/bar -L/baz (and put it first):
+ac_f77_v_output="`echo $ac_f77_v_output |
+	grep 'LPATH is:' |
+	sed 's|.*LPATH is\(: *[^ ]*\).*|\1|;s|: */| -L/|g'` $ac_f77_v_output"
+
+# FIXME: we keep getting bitten by quoted arguments; a more general fix
+#        that detects unbalanced quotes in FLIBS should be implemented
+#        and (ugh) tested at some point.
+case $ac_f77_v_output in
+  # If we are using xlf then replace all the commas with spaces.
+  *xlfentry*)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/,/ /g'` ;;
+
+  # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
+  # $LIBS confuse us, and the libraries appear later in the output anyway).
+  *mGLOB_options_string*)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/"-mGLOB[^"]*"/ /g'` ;;
+
+  # Portland Group compiler has singly- or doubly-quoted -cmdline argument
+  # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4.
+  # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
+  *-cmdline\ * | *-ignore\ * | *-def\ *)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed "\
+	s/-cmdline  *'[^']*'/ /g; s/-cmdline  *\"[^\"]*\"/ /g
+	s/-ignore  *'[^']*'/ /g; s/-ignore  *\"[^\"]*\"/ /g
+	s/-def  *'[^']*'/ /g; s/-def  *\"[^\"]*\"/ /g"` ;;
+
+  # If we are using Cray Fortran then delete quotes.
+  *cft90*)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/"//g'` ;;
+esac
+
+
+  # look for -l* and *.a constructs in the output
+  for ac_arg in $ac_f77_v_output; do
+     case $ac_arg in
+	[\\/]*.a | ?:[\\/]*.a | -[lLRu]*)
+	  ac_cv_prog_f77_v=$ac_verb
+	  break 2 ;;
+     esac
+  done
+done
+if test -z "$ac_cv_prog_f77_v"; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine how to obtain linking information from $F77" >&5
+$as_echo "$as_me: WARNING: cannot determine how to obtain linking information from $F77" >&2;}
+fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compilation failed" >&5
+$as_echo "$as_me: WARNING: compilation failed" >&2;}
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_f77_v" >&5
+$as_echo "$ac_cv_prog_f77_v" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran 77 libraries of $F77" >&5
+$as_echo_n "checking for Fortran 77 libraries of $F77... " >&6; }
+if test "${ac_cv_f77_libs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$FLIBS" != "x"; then
+  ac_cv_f77_libs="$FLIBS" # Let the user override the test.
+else
+
+cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+
+# Compile and link our simple test program by passing a flag (argument
+# 1 to this macro) to the Fortran compiler in order to get
+# "verbose" output that we can then parse for the Fortran linker
+# flags.
+ac_save_FFLAGS=$FFLAGS
+FFLAGS="$FFLAGS $ac_cv_prog_f77_v"
+eval "set x $ac_link"
+shift
+$as_echo "$as_me:${as_lineno-$LINENO}: $*" >&5
+# gfortran 4.3 outputs lines setting COLLECT_GCC_OPTIONS, COMPILER_PATH,
+# LIBRARY_PATH; skip all such settings.
+ac_f77_v_output=`eval $ac_link 5>&1 2>&1 |
+  grep -v 'Driving:' | grep -v "^[_$as_cr_Letters][_$as_cr_alnum]*="`
+$as_echo "$ac_f77_v_output" >&5
+FFLAGS=$ac_save_FFLAGS
+
+rm -rf conftest*
+
+# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
+# /foo, /bar, and /baz are search directories for the Fortran linker.
+# Here, we change these into -L/foo -L/bar -L/baz (and put it first):
+ac_f77_v_output="`echo $ac_f77_v_output |
+	grep 'LPATH is:' |
+	sed 's|.*LPATH is\(: *[^ ]*\).*|\1|;s|: */| -L/|g'` $ac_f77_v_output"
+
+# FIXME: we keep getting bitten by quoted arguments; a more general fix
+#        that detects unbalanced quotes in FLIBS should be implemented
+#        and (ugh) tested at some point.
+case $ac_f77_v_output in
+  # If we are using xlf then replace all the commas with spaces.
+  *xlfentry*)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/,/ /g'` ;;
+
+  # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
+  # $LIBS confuse us, and the libraries appear later in the output anyway).
+  *mGLOB_options_string*)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/"-mGLOB[^"]*"/ /g'` ;;
+
+  # Portland Group compiler has singly- or doubly-quoted -cmdline argument
+  # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4.
+  # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
+  *-cmdline\ * | *-ignore\ * | *-def\ *)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed "\
+	s/-cmdline  *'[^']*'/ /g; s/-cmdline  *\"[^\"]*\"/ /g
+	s/-ignore  *'[^']*'/ /g; s/-ignore  *\"[^\"]*\"/ /g
+	s/-def  *'[^']*'/ /g; s/-def  *\"[^\"]*\"/ /g"` ;;
+
+  # If we are using Cray Fortran then delete quotes.
+  *cft90*)
+    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/"//g'` ;;
+esac
+
+
+
+ac_cv_f77_libs=
+
+# Save positional arguments (if any)
+ac_save_positional="$@"
+
+set X $ac_f77_v_output
+while test $# != 1; do
+  shift
+  ac_arg=$1
+  case $ac_arg in
+	[\\/]*.a | ?:[\\/]*.a)
+	    ac_exists=false
+  for ac_i in $ac_cv_f77_libs; do
+    if test x"$ac_arg" = x"$ac_i"; then
+      ac_exists=true
+      break
+    fi
+  done
+
+  if test x"$ac_exists" = xtrue; then :
+
+else
+  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
+fi
+	  ;;
+	-bI:*)
+	    ac_exists=false
+  for ac_i in $ac_cv_f77_libs; do
+    if test x"$ac_arg" = x"$ac_i"; then
+      ac_exists=true
+      break
+    fi
+  done
+
+  if test x"$ac_exists" = xtrue; then :
+
+else
+  if test "$ac_compiler_gnu" = yes; then
+  for ac_link_opt in $ac_arg; do
+    ac_cv_f77_libs="$ac_cv_f77_libs -Xlinker $ac_link_opt"
+  done
+else
+  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
+fi
+fi
+	  ;;
+	  # Ignore these flags.
+	-lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -little \
+	  |-LANG:=* | -LIST:* | -LNO:*)
+	  ;;
+	-lkernel32)
+	  test x"$CYGWIN" != xyes && ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
+	  ;;
+	-[LRuYz])
+	  # These flags, when seen by themselves, take an argument.
+	  # We remove the space between option and argument and re-iterate
+	  # unless we find an empty arg or a new option (starting with -)
+	  case $2 in
+	     "" | -*);;
+	     *)
+		ac_arg="$ac_arg$2"
+		shift; shift
+		set X $ac_arg "$@"
+		;;
+	  esac
+	  ;;
+	-YP,*)
+	  for ac_j in `$as_echo "$ac_arg" | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
+	      ac_exists=false
+  for ac_i in $ac_cv_f77_libs; do
+    if test x"$ac_j" = x"$ac_i"; then
+      ac_exists=true
+      break
+    fi
+  done
+
+  if test x"$ac_exists" = xtrue; then :
+
+else
+  ac_arg="$ac_arg $ac_j"
+			       ac_cv_f77_libs="$ac_cv_f77_libs $ac_j"
+fi
+	  done
+	  ;;
+	-[lLR]*)
+	    ac_exists=false
+  for ac_i in $ac_cv_f77_libs; do
+    if test x"$ac_arg" = x"$ac_i"; then
+      ac_exists=true
+      break
+    fi
+  done
+
+  if test x"$ac_exists" = xtrue; then :
+
+else
+  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
+fi
+	  ;;
+	-zallextract*| -zdefaultextract)
+	  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
+	  ;;
+	  # Ignore everything else.
+  esac
+done
+# restore positional arguments
+set X $ac_save_positional; shift
+
+# We only consider "LD_RUN_PATH" on Solaris systems.  If this is seen,
+# then we insist that the "run path" must be an absolute path (i.e. it
+# must begin with a "/").
+case `(uname -sr) 2>/dev/null` in
+   "SunOS 5"*)
+      ac_ld_run_path=`$as_echo "$ac_f77_v_output" |
+			sed -n 's,^.*LD_RUN_PATH *= *\(/[^ ]*\).*$,-R\1,p'`
+      test "x$ac_ld_run_path" != x &&
+	if test "$ac_compiler_gnu" = yes; then
+  for ac_link_opt in $ac_ld_run_path; do
+    ac_cv_f77_libs="$ac_cv_f77_libs -Xlinker $ac_link_opt"
+  done
+else
+  ac_cv_f77_libs="$ac_cv_f77_libs $ac_ld_run_path"
+fi
+      ;;
+esac
+fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_f77_libs" >&5
+$as_echo "$ac_cv_f77_libs" >&6; }
+FLIBS="$ac_cv_f77_libs"
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+as_ac_Lib=`$as_echo "ac_cv_lib_${EMOS_LIB_NAME}''_pbopen" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pbopen in -l${EMOS_LIB_NAME}" >&5
+$as_echo_n "checking for pbopen in -l${EMOS_LIB_NAME}... " >&6; }
+if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l${EMOS_LIB_NAME}  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pbopen ();
+int
+main ()
+{
+return pbopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  eval "$as_ac_Lib=yes"
+else
+  eval "$as_ac_Lib=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+eval ac_res=\$$as_ac_Lib
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+eval as_val=\$$as_ac_Lib
+   if test "x$as_val" = x""yes; then :
+  echo "Emoslib found."
+else
+  as_fn_error "The double precision version of Emoslib (${EMOS_LIB_NAME}) could not be linked! Try setting --with-emos-libraries and --with-emos-libname." "$LINENO" 5
+fi
+
+
+$as_echo "#define MAGICS_BUFR 1" >>confdefs.h
+
+MAGICS_3RDPARTY_LIBS="-l${EMOS_LIB_NAME} $MAGICS_3RDPARTY_LIBS"
+
+
+
+else   # MvOBS link failed
+bufr="no"
+echo ""
+echo "  MvOBS source is not linked correctly! BUFR disabled."
+echo ""
+fi
+
+else               # no bufr
+  bufr="no"
+fi
+
+# endif BUFR
+
+
+
+#############################################################################################
+if test "x$SITE_NAME" = 'xecmwf'
+then
+  $as_echo "#define MAGICS_METGRAM 1" >>confdefs.h
+
+  metgram=yes
+
+  ################
+  #
+  #  Spot support  --enable-spot
+  #
+  # Check whether --enable-spot was given.
+if test "${enable_spot+set}" = set; then :
+  enableval=$enable_spot; spot=$enableval
+else
+  spot=no
+fi
+
+
+  if test "x$spot" = "xyes" ; then
+     $as_echo "#define MAGICS_SPOT 1" >>confdefs.h
+
+
+
+# Check whether --with-spot was given.
+if test "${with_spot+set}" = set; then :
+  withval=$with_spot; MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -L${with_spot}/lib"; CPPFLAGS="-I${with_spot}/include ${CPPFLAGS}";LDFLAGS="-L${with_spot}/lib ${LDFLAGS}"
+
+fi
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for spot_open_database in -lspot_database" >&5
+$as_echo_n "checking for spot_open_database in -lspot_database... " >&6; }
+if test "${ac_cv_lib_spot_database_spot_open_database+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lspot_database  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char spot_open_database ();
+int
+main ()
+{
+return spot_open_database ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_spot_database_spot_open_database=yes
+else
+  ac_cv_lib_spot_database_spot_open_database=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_spot_database_spot_open_database" >&5
+$as_echo "$ac_cv_lib_spot_database_spot_open_database" >&6; }
+if test "x$ac_cv_lib_spot_database_spot_open_database" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBSPOT_DATABASE 1
+_ACEOF
+
+  LIBS="-lspot_database $LIBS"
+
+else
+  as_fn_error "spot_database could not be linked! " "$LINENO" 5
+fi
+
+  fi
+
+fi
+###  end ECMWF metgrams
+
+
+############################################
+#
+# Proj4
+#
+# Check whether --enable-proj4 was given.
+if test "${enable_proj4+set}" = set; then :
+  enableval=$enable_proj4; proj4=$enableval
+else
+  proj4=yes
+fi
+
+
+if test "x$proj4" = "xyes" ; then
+
+# Check whether --with-proj4 was given.
+if test "${with_proj4+set}" = set; then :
+  withval=$with_proj4; MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -L${with_proj4}/lib";CPPFLAGS="-I${with_proj4}/include ${CPPFLAGS}";LDFLAGS="-L${with_proj4}/lib ${LDFLAGS}"
+
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pj_init in -lproj" >&5
+$as_echo_n "checking for pj_init in -lproj... " >&6; }
+if test "${ac_cv_lib_proj_pj_init+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lproj  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pj_init ();
+int
+main ()
+{
+return pj_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_proj_pj_init=yes
+else
+  ac_cv_lib_proj_pj_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_proj_pj_init" >&5
+$as_echo "$ac_cv_lib_proj_pj_init" >&6; }
+if test "x$ac_cv_lib_proj_pj_init" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPROJ 1
+_ACEOF
+
+  LIBS="-lproj $LIBS"
+
+else
+  as_fn_error "Proj4 could not be linked! " "$LINENO" 5
+fi
+
+  $as_echo "#define MAGICS_PROJ4 1" >>confdefs.h
+
+fi
+
+
+
+
+############################################
+#
+# Checks for other libraries.
+#
+
+if test "x$raster" = "xyes"  ; then
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gdImagePng in -lgd" >&5
+$as_echo_n "checking for gdImagePng in -lgd... " >&6; }
+if test "${ac_cv_lib_gd_gdImagePng+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gdImagePng ();
+int
+main ()
+{
+return gdImagePng ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_gd_gdImagePng=yes
+else
+  ac_cv_lib_gd_gdImagePng=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gd_gdImagePng" >&5
+$as_echo "$ac_cv_lib_gd_gdImagePng" >&6; }
+if test "x$ac_cv_lib_gd_gdImagePng" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGD 1
+_ACEOF
+
+  LIBS="-lgd $LIBS"
+
+else
+  as_fn_error "gdImagePng not defined - libGD not found or no PNG support" "$LINENO" 5
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gdImageGif in -lgd" >&5
+$as_echo_n "checking for gdImageGif in -lgd... " >&6; }
+if test "${ac_cv_lib_gd_gdImageGif+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gdImageGif ();
+int
+main ()
+{
+return gdImageGif ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_gd_gdImageGif=yes
+else
+  ac_cv_lib_gd_gdImageGif=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gd_gdImageGif" >&5
+$as_echo "$ac_cv_lib_gd_gdImageGif" >&6; }
+if test "x$ac_cv_lib_gd_gdImageGif" = x""yes; then :
+  $as_echo "#define MAGICS_GIF 1" >>confdefs.h
+
+	 have_gifs="yes"
+else
+  have_gifs="no"
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gdImageGifAnimEnd in -lgd" >&5
+$as_echo_n "checking for gdImageGifAnimEnd in -lgd... " >&6; }
+if test "${ac_cv_lib_gd_gdImageGifAnimEnd+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gdImageGifAnimEnd ();
+int
+main ()
+{
+return gdImageGifAnimEnd ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_gd_gdImageGifAnimEnd=yes
+else
+  ac_cv_lib_gd_gdImageGifAnimEnd=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gd_gdImageGifAnimEnd" >&5
+$as_echo "$ac_cv_lib_gd_gdImageGifAnimEnd" >&6; }
+if test "x$ac_cv_lib_gd_gdImageGifAnimEnd" = x""yes; then :
+  $as_echo "#define MAGICS_GIF_ANIMATED 1" >>confdefs.h
+
+	 have_gifs_ani="yes"
+else
+  have_gifs_ani="no"
+fi
+
+
+ if test "${have_gifs}" = "no"
+ then
+	echo " "
+	echo "   You have a old GD library with NO GIF support. Please consider"
+	echo "   upgrading to a more recent version (2.0.28 or newer)."
+	echo "   This version of GD will support only PNG and JPEG output."
+	echo " "
+ else
+ 	MAGICS_OUTPUTS="${MAGICS_OUTPUTS}_GIF"
+ fi
+ if test "${have_gifs_ani}" = "no"
+ then
+	echo " "
+	echo "   You have a oldish GD library with NO animated GIF support. Please consider"
+	echo "   upgrading to a more recent version (2.0.32 or newer)."
+	echo "   This version of GD will support PNG, JPEG and (non-animated) GIF output."
+	echo " "
+ else
+ 	MAGICS_OUTPUTS="${MAGICS_OUTPUTS}_AGIF"
+ fi
+fi
+
+
+ac_fn_cxx_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_zlib_h" = x""yes; then :
+
+else
+  as_fn_error "could not find zlib.h. You might need to install zlib development packges (zlib-devel)" "$LINENO" 5
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5
+$as_echo_n "checking for compress in -lz... " >&6; }
+if test "${ac_cv_lib_z_compress+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lz  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char compress ();
+int
+main ()
+{
+return compress ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_z_compress=yes
+else
+  ac_cv_lib_z_compress=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5
+$as_echo "$ac_cv_lib_z_compress" >&6; }
+if test "x$ac_cv_lib_z_compress" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBZ 1
+_ACEOF
+
+  LIBS="-lz $LIBS"
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FcInitLoadConfigAndFonts in -lfontconfig" >&5
+$as_echo_n "checking for FcInitLoadConfigAndFonts in -lfontconfig... " >&6; }
+if test "${ac_cv_lib_fontconfig_FcInitLoadConfigAndFonts+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lfontconfig  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char FcInitLoadConfigAndFonts ();
+int
+main ()
+{
+return FcInitLoadConfigAndFonts ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_fontconfig_FcInitLoadConfigAndFonts=yes
+else
+  ac_cv_lib_fontconfig_FcInitLoadConfigAndFonts=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_fontconfig_FcInitLoadConfigAndFonts" >&5
+$as_echo "$ac_cv_lib_fontconfig_FcInitLoadConfigAndFonts" >&6; }
+if test "x$ac_cv_lib_fontconfig_FcInitLoadConfigAndFonts" = x""yes; then :
+  ac_fn_cxx_check_header_mongrel "$LINENO" "fontconfig/fontconfig.h" "ac_cv_header_fontconfig_fontconfig_h" "$ac_includes_default"
+if test "x$ac_cv_header_fontconfig_fontconfig_h" = x""yes; then :
+  LIBS="-lfontconfig $LIBS"
+fi
+
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_key_create in -lpthread" >&5
+$as_echo_n "checking for pthread_key_create in -lpthread... " >&6; }
+if test "${ac_cv_lib_pthread_pthread_key_create+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_key_create ();
+int
+main ()
+{
+return pthread_key_create ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_pthread_pthread_key_create=yes
+else
+  ac_cv_lib_pthread_pthread_key_create=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_key_create" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_key_create" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_key_create" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPTHREAD 1
+_ACEOF
+
+  LIBS="-lpthread $LIBS"
+
+fi
+
+
+##AC_CHECK_LIB(tiff, TIFFOpen ,,AC_MSG_ERROR([tiff not found.]))
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML_ParserCreate  in -lexpat" >&5
+$as_echo_n "checking for XML_ParserCreate  in -lexpat... " >&6; }
+if test "${ac_cv_lib_expat_XML_ParserCreate_+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lexpat  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char XML_ParserCreate  ();
+int
+main ()
+{
+return XML_ParserCreate  ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_expat_XML_ParserCreate_=yes
+else
+  ac_cv_lib_expat_XML_ParserCreate_=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_expat_XML_ParserCreate_" >&5
+$as_echo "$ac_cv_lib_expat_XML_ParserCreate_" >&6; }
+if test "x$ac_cv_lib_expat_XML_ParserCreate_" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBEXPAT 1
+_ACEOF
+
+  LIBS="-lexpat $LIBS"
+
+else
+  as_fn_error "expat xml parser library not found." "$LINENO" 5
+fi
+
+
+
+#################################################################################
+#
+#   N E T C D F    (and CURL)
+#
+#################################################################################
+#
+#  netCDF support  --enable-netcdf
+#
+# Check whether --enable-netcdf was given.
+if test "${enable_netcdf+set}" = set; then :
+  enableval=$enable_netcdf; netcdf=$enableval
+else
+  netcdf=yes
+fi
+
+
+if test "x${netcdf}" = "xyes" ; then
+
+###   AC_MSG_NOTICE([for curl library sometimes needed by NetCDF])
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for curl_easy_setopt in -lcurl" >&5
+$as_echo_n "checking for curl_easy_setopt in -lcurl... " >&6; }
+if test "${ac_cv_lib_curl_curl_easy_setopt+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcurl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char curl_easy_setopt ();
+int
+main ()
+{
+return curl_easy_setopt ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_curl_curl_easy_setopt=yes
+else
+  ac_cv_lib_curl_curl_easy_setopt=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curl_curl_easy_setopt" >&5
+$as_echo "$ac_cv_lib_curl_curl_easy_setopt" >&6; }
+if test "x$ac_cv_lib_curl_curl_easy_setopt" = x""yes; then :
+  have_curl="yes"
+else
+  have_curl="no"
+fi
+
+
+  # NetCDF can be built with a dependency on curl. Therefore, we add it to the libraries if it is
+  # installed; otherwise, issue a warning.
+  if test "${have_curl}" = "yes"
+  then
+    CURL_LIBS="${NETCDF_LIBS} -lcurl"
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: No curl library - this is fine as long as your NetCDF library does not require it." >&5
+$as_echo "$as_me: WARNING: No curl library - this is fine as long as your NetCDF library does not require it." >&2;}
+  fi
+
+  #
+  # For netcdf header file
+  #
+
+# Check whether --with-netcdf was given.
+if test "${with_netcdf+set}" = set; then :
+  withval=$with_netcdf; CPPFLAGS="-I${with_netcdf}/include ${CPPFLAGS}";LDFLAGS="-L${with_netcdf}/lib ${LDFLAGS}"; NETCDF_LIBS="-L${with_netcdf}/lib "
+
+fi
+
+  ac_fn_cxx_check_header_mongrel "$LINENO" "netcdfcpp.h" "ac_cv_header_netcdfcpp_h" "$ac_includes_default"
+if test "x$ac_cv_header_netcdfcpp_h" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not successfully compile with netcdfcpp.h!" >&5
+$as_echo "$as_me: WARNING: could not successfully compile with netcdfcpp.h!" >&2;}
+  unset ac_cv_header_netcdf_h
+fi
+
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ncvarid  in -lnetcdf" >&5
+$as_echo_n "checking for ncvarid  in -lnetcdf... " >&6; }
+if test "${ac_cv_lib_netcdf_ncvarid_+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnetcdf  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ncvarid  ();
+int
+main ()
+{
+return ncvarid  ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  ac_cv_lib_netcdf_ncvarid_=yes
+else
+  ac_cv_lib_netcdf_ncvarid_=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netcdf_ncvarid_" >&5
+$as_echo "$ac_cv_lib_netcdf_ncvarid_" >&6; }
+if test "x$ac_cv_lib_netcdf_ncvarid_" = x""yes; then :
+  NETCDF_LIBS="${NETCDF_LIBS}-lnetcdf_c++ -lnetcdf ${CURL_LIBS}"
+else
+  as_fn_error "netcdf library not found." "$LINENO" 5
+fi
+
+  #AC_CHECK_LIB(netcdf_c++, nctypelen        ,echo "",AC_MSG_ERROR([netcdf_c++ library not found.]))
+
+  $as_echo "#define MAGICS_NETCDF 1" >>confdefs.h
+
+fi
+
+#################################################################################
+#
+#  Cairo support  --enable-cairo
+#
+# Check whether --enable-cairo was given.
+if test "${enable_cairo+set}" = set; then :
+  enableval=$enable_cairo; cairo=$enableval
+else
+  cairo=yes
+fi
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=0.9.0
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+		PKG_CONFIG=""
+	fi
+
+fi
+
+if test "x$cairo" = "xyes" ; then
+
+ MAGICS_OUTPUTS="${MAGICS_OUTPUTS}_PNG_CPS_CSVG_X"
+
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CAIRO" >&5
+$as_echo_n "checking for CAIRO... " >&6; }
+
+if test -n "$CAIRO_CFLAGS"; then
+    pkg_cv_CAIRO_CFLAGS="$CAIRO_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_CAIRO_CFLAGS=`$PKG_CONFIG --cflags "pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0" 2>/dev/null`
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$CAIRO_LIBS"; then
+    pkg_cv_CAIRO_LIBS="$CAIRO_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_CAIRO_LIBS=`$PKG_CONFIG --libs "pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0" 2>/dev/null`
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+	        CAIRO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0" 2>&1`
+        else
+	        CAIRO_PKG_ERRORS=`$PKG_CONFIG --print-errors "pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$CAIRO_PKG_ERRORS" >&5
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+    echo ""
+    echo " Cairo/Pango library could not be found!"
+    echo " Please install cairo-devel and pango-devel ."
+    cairo=no
+
+elif test $pkg_failed = untried; then
+
+    echo ""
+    echo " Cairo/Pango library could not be found!"
+    echo " Please install cairo-devel and pango-devel ."
+    cairo=no
+
+else
+	CAIRO_CFLAGS=$pkg_cv_CAIRO_CFLAGS
+	CAIRO_LIBS=$pkg_cv_CAIRO_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+   CFLAGS="$CAIRO_CFLAGS $CFLAGS"
+   CPPFLAGS="$CAIRO_CFLAGS $CPPFLAGS"
+   LIBS="$CAIRO_LIBS $LIBS"
+   LDFLAGS="$CAIRO_LDFLAGS $LDFLAGS"
+   $as_echo "#define MAGICS_CAIRO 1" >>confdefs.h
+
+
+fi
+
+  #
+  # NOT good code:
+  #   required since pkg-config returns non-lib options in LIBS!!!
+  #
+  if test "x${SITE_NAME}" = "xecmwf"; then
+     echo $LIBS > stupid_bug_fix_file_LIBS.txt
+     LIBS=`sed 's/-pthread/ /' stupid_bug_fix_file_LIBS.txt`;
+     rm -f stupid_bug_fix_file_LIBS.txt
+  fi
+
+fi
+
+
+
+#PKG_CHECK_MODULES(GDAL, [gdal >= 1.6.0],
+#  [
+#   CFLAGS="$GDAL_CFLAGS $CFLAGS"
+#   CPPFLAGS="$GDAL_CFLAGS $CPPFLAGS"
+#   LIBS="$GDAL_LIBS $LIBS"
+#   LDFLAGS="$GDAL_LDFLAGS $LDFLAGS"
+#   gdal=yes
+#   AC_DEFINE(MAGICS_GDAL, 1)
+#  ],
+#  [
+#    echo ""
+#    echo " GDAL library could not be found!"
+#    gdal=no
+#  ])
+#AC_SUBST(gdal)
+
+
+# Autoheader
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#############################################################################
+#
+#  P O S T S C R I P T
+#
+
+# Set Ghostscript font directory
+
+# Check whether --with-gs-font-dir was given.
+if test "${with_gs_font_dir+set}" = set; then :
+  withval=$with_gs_font_dir; with_gs_font_dir=$withval
+else
+  with_gs_font_dir='default'
+fi
+
+
+#
+# Check for Display Postscript
+#
+PSDelegateDefault='gs'
+# Extract the first word of ""$PSDelegateDefault"", so it can be a program name with args.
+set dummy "$PSDelegateDefault"; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PSDelegate+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PSDelegate in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PSDelegate="$PSDelegate" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PSDelegate="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_PSDelegate" && ac_cv_path_PSDelegate=""$PSDelegateDefault""
+  ;;
+esac
+fi
+PSDelegate=$ac_cv_path_PSDelegate
+if test -n "$PSDelegate"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PSDelegate" >&5
+$as_echo "$PSDelegate" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+have_gs='no'
+if test "$PSDelegate" != "$PSDelegateDefault"; then have_gs='yes' ; fi
+
+
+#
+# Test for GhostScriptfont directories
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ghostscript fonts directory" >&5
+$as_echo_n "checking for Ghostscript fonts directory... " >&6; }
+ghostscript_font_dir=''
+if test "${with_gs_font_dir}" != 'default'
+then
+  ghostscript_font_dir="${with_gs_font_dir}/"
+else
+    for font_dir in '/usr/share/ghostscript/fonts/' '/usr/share/fonts/default/Type1/' "${prefix}/share/ghostscript/fonts/"
+    do
+      if test -f "${font_dir}/a010013l.pfb"
+      then
+        ghostscript_font_dir="${font_dir}"
+        break 1
+      fi
+    done
+
+    if test "${ghostscript_font_dir}x" = 'x'
+    then
+      if test "$PSDelegate" != 'gs'
+      then
+        ghostscript_font_dir=`echo "$PSDelegate" | sed -e 's:/bin/gs:/share/ghostscript/fonts:'`"/"
+      fi
+    fi
+fi
+
+if test "${ghostscript_font_dir}x" != 'x'
+then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ghostscript_font_dir" >&5
+$as_echo "$ghostscript_font_dir" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found! Some output drivers might NOT work!" >&5
+$as_echo "not found! Some output drivers might NOT work!" >&6; };
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define POSTSCRIPT_FONT_PATH "${ghostscript_font_dir}"
+_ACEOF
+
+
+if test $have_gs = 'yes'
+then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ghostscript version" >&5
+$as_echo_n "checking for Ghostscript version... " >&6; }
+  if GSVersion=`$PSDelegate --version`
+  then
+    :
+  else
+    GSVersion=`$PSDelegate --help | sed -e '1q' | awk '{ print $3 }'`
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GSVersion" >&5
+$as_echo "$GSVersion" >&6; }
+fi
+
+#
+#  P O S T S C R I P T  -  E N D
+#
+
+
+
+MAGICS_3RDPARTY_INCLUDE="$CPPFLAGS"
+MAGICS_3RDPARTY_LIBS="$LIBS $GRIBAPI_LIBS $MAGICS_3RDPARTY_LIBS $NETCDF_LIBS"
+LIBS="$LIBS $NETCDF_LIBS"
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define MAGICS_OUTPUTS "${MAGICS_OUTPUTS}"
+_ACEOF
+
+
+ if test "$metview"   = yes; then
+  MAGICS_METVIEW_TRUE=
+  MAGICS_METVIEW_FALSE='#'
+else
+  MAGICS_METVIEW_TRUE='#'
+  MAGICS_METVIEW_FALSE=
+fi
+
+ if test "$bit"       = yes; then
+  MAGICS_32BIT_TRUE=
+  MAGICS_32BIT_FALSE='#'
+else
+  MAGICS_32BIT_TRUE='#'
+  MAGICS_32BIT_FALSE=
+fi
+
+ if test "$apps"      = yes; then
+  MAGICS_APPS_TRUE=
+  MAGICS_APPS_FALSE='#'
+else
+  MAGICS_APPS_TRUE='#'
+  MAGICS_APPS_FALSE=
+fi
+
+ if test "$bufr"      = yes; then
+  MAGICS_BUFR_TRUE=
+  MAGICS_BUFR_FALSE='#'
+else
+  MAGICS_BUFR_TRUE='#'
+  MAGICS_BUFR_FALSE=
+fi
+
+ if test "$json"      = yes; then
+  MAGICS_JSON_TRUE=
+  MAGICS_JSON_FALSE='#'
+else
+  MAGICS_JSON_TRUE='#'
+  MAGICS_JSON_FALSE=
+fi
+
+ if test "$odb"       = yes; then
+  MAGICS_ODB_TRUE=
+  MAGICS_ODB_FALSE='#'
+else
+  MAGICS_ODB_TRUE='#'
+  MAGICS_ODB_FALSE=
+fi
+
+ if test "$exception" = yes; then
+  MAGICS_EXCEPTION_TRUE=
+  MAGICS_EXCEPTION_FALSE='#'
+else
+  MAGICS_EXCEPTION_TRUE='#'
+  MAGICS_EXCEPTION_FALSE=
+fi
+
+ if test "$spot"      = yes; then
+  MAGICS_SPOT_TRUE=
+  MAGICS_SPOT_FALSE='#'
+else
+  MAGICS_SPOT_TRUE='#'
+  MAGICS_SPOT_FALSE=
+fi
+
+ if test "$grib"      = yes; then
+  MAGICS_GRIB_TRUE=
+  MAGICS_GRIB_FALSE='#'
+else
+  MAGICS_GRIB_TRUE='#'
+  MAGICS_GRIB_FALSE=
+fi
+
+ if test "$netcdf"    = yes; then
+  MAGICS_NETCDF_TRUE=
+  MAGICS_NETCDF_FALSE='#'
+else
+  MAGICS_NETCDF_TRUE='#'
+  MAGICS_NETCDF_FALSE=
+fi
+
+ if test "$metgram"   = yes; then
+  MAGICS_METGRAM_TRUE=
+  MAGICS_METGRAM_FALSE='#'
+else
+  MAGICS_METGRAM_TRUE='#'
+  MAGICS_METGRAM_FALSE=
+fi
+
+ if test "$qt"        = yes; then
+  MAGICS_QT_TRUE=
+  MAGICS_QT_FALSE='#'
+else
+  MAGICS_QT_TRUE='#'
+  MAGICS_QT_FALSE=
+fi
+
+ if test "$qtdebug"   = no; then
+  MAGICS_QTDEBUG_TRUE=
+  MAGICS_QTDEBUG_FALSE='#'
+else
+  MAGICS_QTDEBUG_TRUE='#'
+  MAGICS_QTDEBUG_FALSE=
+fi
+
+ if test "$cairo"     = yes; then
+  MAGICS_CAIRO_TRUE=
+  MAGICS_CAIRO_FALSE='#'
+else
+  MAGICS_CAIRO_TRUE='#'
+  MAGICS_CAIRO_FALSE=
+fi
+
+ if test "$tiff"      = yes; then
+  MAGICS_TIFF_TRUE=
+  MAGICS_TIFF_FALSE='#'
+else
+  MAGICS_TIFF_TRUE='#'
+  MAGICS_TIFF_FALSE=
+fi
+
+ if test "$raster"    = yes; then
+  MAGICS_RASTER_TRUE=
+  MAGICS_RASTER_FALSE='#'
+else
+  MAGICS_RASTER_TRUE='#'
+  MAGICS_RASTER_FALSE=
+fi
+
+ if test "$python"    = yes; then
+  MAGICS_PYTHON_TRUE=
+  MAGICS_PYTHON_FALSE='#'
+else
+  MAGICS_PYTHON_TRUE='#'
+  MAGICS_PYTHON_FALSE=
+fi
+
+#AM_CONDITIONAL(MAGICS_GDAL,	test "$gdal"      = yes)
+ if test "$allheaders"  = yes; then
+  MAGICS_ALLHEADERS_TRUE=
+  MAGICS_ALLHEADERS_FALSE='#'
+else
+  MAGICS_ALLHEADERS_TRUE='#'
+  MAGICS_ALLHEADERS_FALSE=
+fi
+
+ if test "$threads"  = yes; then
+  MAGICS_THREADS_TRUE=
+  MAGICS_THREADS_FALSE='#'
+else
+  MAGICS_THREADS_TRUE='#'
+  MAGICS_THREADS_FALSE=
+fi
+
+ if test "$proj4"  = yes; then
+  MAGICS_PROJ4_TRUE=
+  MAGICS_PROJ4_FALSE='#'
+else
+  MAGICS_PROJ4_TRUE='#'
+  MAGICS_PROJ4_FALSE=
+fi
+
+ if test "$mac"  = yes; then
+  MAGICS_MAC_TRUE=
+  MAGICS_MAC_FALSE='#'
+else
+  MAGICS_MAC_TRUE='#'
+  MAGICS_MAC_FALSE=
+fi
+
+
+ac_config_files="$ac_config_files Makefile magics-config src/Makefile src/xml/Makefile src/common/Makefile src/basic/Makefile src/decoders/Makefile src/drivers/Makefile src/oda/Makefile src/visualisers/Makefile src/terralib/Makefile src/MvObs/Makefile src/libTable/Makefile src/libMagWrapper/Makefile src/web/Makefile tools/Makefile test/Makefile test/fortran/Makefile test/C/Makefile test/MagML/Makefile test/python/Makefile apps/Makefile apps/MagMLInterpretor/Makefile apps/metgram/Makefile [...]
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+	"s/'/'\\\\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_METVIEW_TRUE}" && test -z "${MAGICS_METVIEW_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_METVIEW\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_32BIT_TRUE}" && test -z "${MAGICS_32BIT_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_32BIT\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_APPS_TRUE}" && test -z "${MAGICS_APPS_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_APPS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_BUFR_TRUE}" && test -z "${MAGICS_BUFR_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_BUFR\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_JSON_TRUE}" && test -z "${MAGICS_JSON_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_JSON\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_ODB_TRUE}" && test -z "${MAGICS_ODB_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_ODB\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_EXCEPTION_TRUE}" && test -z "${MAGICS_EXCEPTION_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_EXCEPTION\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_SPOT_TRUE}" && test -z "${MAGICS_SPOT_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_SPOT\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_GRIB_TRUE}" && test -z "${MAGICS_GRIB_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_GRIB\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_NETCDF_TRUE}" && test -z "${MAGICS_NETCDF_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_NETCDF\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_METGRAM_TRUE}" && test -z "${MAGICS_METGRAM_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_METGRAM\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_QT_TRUE}" && test -z "${MAGICS_QT_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_QT\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_QTDEBUG_TRUE}" && test -z "${MAGICS_QTDEBUG_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_QTDEBUG\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_CAIRO_TRUE}" && test -z "${MAGICS_CAIRO_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_CAIRO\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_TIFF_TRUE}" && test -z "${MAGICS_TIFF_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_TIFF\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_RASTER_TRUE}" && test -z "${MAGICS_RASTER_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_RASTER\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_PYTHON_TRUE}" && test -z "${MAGICS_PYTHON_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_PYTHON\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_ALLHEADERS_TRUE}" && test -z "${MAGICS_ALLHEADERS_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_ALLHEADERS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_THREADS_TRUE}" && test -z "${MAGICS_THREADS_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_THREADS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_PROJ4_TRUE}" && test -z "${MAGICS_PROJ4_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_PROJ4\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAGICS_MAC_TRUE}" && test -z "${MAGICS_MAC_FALSE}"; then
+  as_fn_error "conditional \"MAGICS_MAC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by MagPlus $as_me 2, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+MagPlus config.status 2
+configured by $0, generated by GNU Autoconf 2.65,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
+macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
+host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
+host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
+host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
+build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
+build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
+build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
+SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
+Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
+GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
+EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
+FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
+LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
+NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
+LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
+exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
+AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
+GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
+SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
+ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
+need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
+LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
+libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
+version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
+striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+LD_F77='`$ECHO "X$LD_F77" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_F77='`$ECHO "X$old_archive_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_F77='`$ECHO "X$compiler_F77" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_F77='`$ECHO "X$GCC_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_F77='`$ECHO "X$lt_prog_compiler_no_builtin_flag_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_F77='`$ECHO "X$lt_prog_compiler_wl_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_F77='`$ECHO "X$lt_prog_compiler_pic_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_F77='`$ECHO "X$lt_prog_compiler_static_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_F77='`$ECHO "X$lt_cv_prog_compiler_c_o_F77" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_F77='`$ECHO "X$archive_cmds_need_lc_F77" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_F77='`$ECHO "X$enable_shared_with_static_runtimes_F77" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_F77='`$ECHO "X$export_dynamic_flag_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_F77='`$ECHO "X$whole_archive_flag_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_F77='`$ECHO "X$compiler_needs_object_F77" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_F77='`$ECHO "X$old_archive_from_new_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_F77='`$ECHO "X$old_archive_from_expsyms_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_F77='`$ECHO "X$archive_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_F77='`$ECHO "X$archive_expsym_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_F77='`$ECHO "X$module_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_F77='`$ECHO "X$module_expsym_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_F77='`$ECHO "X$with_gnu_ld_F77" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_F77='`$ECHO "X$allow_undefined_flag_F77" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_F77='`$ECHO "X$no_undefined_flag_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_F77='`$ECHO "X$hardcode_libdir_flag_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_F77='`$ECHO "X$hardcode_libdir_flag_spec_ld_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_F77='`$ECHO "X$hardcode_libdir_separator_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_F77='`$ECHO "X$hardcode_direct_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_F77='`$ECHO "X$hardcode_direct_absolute_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_F77='`$ECHO "X$hardcode_minus_L_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_F77='`$ECHO "X$hardcode_shlibpath_var_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_F77='`$ECHO "X$hardcode_automatic_F77" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_F77='`$ECHO "X$inherit_rpath_F77" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_F77='`$ECHO "X$link_all_deplibs_F77" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_F77='`$ECHO "X$fix_srcfile_path_F77" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_F77='`$ECHO "X$always_export_symbols_F77" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_F77='`$ECHO "X$export_symbols_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_F77='`$ECHO "X$exclude_expsyms_F77" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_F77='`$ECHO "X$include_expsyms_F77" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_F77='`$ECHO "X$prelink_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_F77='`$ECHO "X$file_list_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_F77='`$ECHO "X$hardcode_action_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_F77='`$ECHO "X$compiler_lib_search_dirs_F77" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_F77='`$ECHO "X$predep_objects_F77" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_F77='`$ECHO "X$postdep_objects_F77" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_F77='`$ECHO "X$predeps_F77" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_F77='`$ECHO "X$postdeps_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_F77='`$ECHO "X$compiler_lib_search_path_F77" | $Xsed -e "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+OBJDUMP \
+deplibs_check_method \
+file_magic_cmd \
+AR \
+AR_FLAGS \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+SHELL \
+ECHO \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_wl \
+lt_prog_compiler_pic \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_flag_spec_ld \
+hardcode_libdir_separator \
+fix_srcfile_path \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+LD_F77 \
+compiler_CXX \
+compiler_F77 \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_no_builtin_flag_F77 \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_wl_F77 \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_pic_F77 \
+lt_prog_compiler_static_CXX \
+lt_prog_compiler_static_F77 \
+lt_cv_prog_compiler_c_o_CXX \
+lt_cv_prog_compiler_c_o_F77 \
+export_dynamic_flag_spec_CXX \
+export_dynamic_flag_spec_F77 \
+whole_archive_flag_spec_CXX \
+whole_archive_flag_spec_F77 \
+compiler_needs_object_CXX \
+compiler_needs_object_F77 \
+with_gnu_ld_CXX \
+with_gnu_ld_F77 \
+allow_undefined_flag_CXX \
+allow_undefined_flag_F77 \
+no_undefined_flag_CXX \
+no_undefined_flag_F77 \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_flag_spec_F77 \
+hardcode_libdir_flag_spec_ld_CXX \
+hardcode_libdir_flag_spec_ld_F77 \
+hardcode_libdir_separator_CXX \
+hardcode_libdir_separator_F77 \
+fix_srcfile_path_CXX \
+fix_srcfile_path_F77 \
+exclude_expsyms_CXX \
+exclude_expsyms_F77 \
+include_expsyms_CXX \
+include_expsyms_F77 \
+file_list_spec_CXX \
+file_list_spec_F77 \
+compiler_lib_search_dirs_CXX \
+compiler_lib_search_dirs_F77 \
+predep_objects_CXX \
+predep_objects_F77 \
+postdep_objects_CXX \
+postdep_objects_F77 \
+predeps_CXX \
+predeps_F77 \
+postdeps_CXX \
+postdeps_F77 \
+compiler_lib_search_path_CXX \
+compiler_lib_search_path_F77; do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+old_archive_cmds_CXX \
+old_archive_cmds_F77 \
+old_archive_from_new_cmds_CXX \
+old_archive_from_new_cmds_F77 \
+old_archive_from_expsyms_cmds_CXX \
+old_archive_from_expsyms_cmds_F77 \
+archive_cmds_CXX \
+archive_cmds_F77 \
+archive_expsym_cmds_CXX \
+archive_expsym_cmds_F77 \
+module_cmds_CXX \
+module_cmds_F77 \
+module_expsym_cmds_CXX \
+module_expsym_cmds_F77 \
+export_symbols_cmds_CXX \
+export_symbols_cmds_F77 \
+prelink_cmds_CXX \
+prelink_cmds_F77; do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\$0 --fallback-echo"')  lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
+  ;;
+esac
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'
+
+
+
+
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "src/magics_config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/magics_config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "magics-config") CONFIG_FILES="$CONFIG_FILES magics-config" ;;
+    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+    "src/xml/Makefile") CONFIG_FILES="$CONFIG_FILES src/xml/Makefile" ;;
+    "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;;
+    "src/basic/Makefile") CONFIG_FILES="$CONFIG_FILES src/basic/Makefile" ;;
+    "src/decoders/Makefile") CONFIG_FILES="$CONFIG_FILES src/decoders/Makefile" ;;
+    "src/drivers/Makefile") CONFIG_FILES="$CONFIG_FILES src/drivers/Makefile" ;;
+    "src/oda/Makefile") CONFIG_FILES="$CONFIG_FILES src/oda/Makefile" ;;
+    "src/visualisers/Makefile") CONFIG_FILES="$CONFIG_FILES src/visualisers/Makefile" ;;
+    "src/terralib/Makefile") CONFIG_FILES="$CONFIG_FILES src/terralib/Makefile" ;;
+    "src/MvObs/Makefile") CONFIG_FILES="$CONFIG_FILES src/MvObs/Makefile" ;;
+    "src/libTable/Makefile") CONFIG_FILES="$CONFIG_FILES src/libTable/Makefile" ;;
+    "src/libMagWrapper/Makefile") CONFIG_FILES="$CONFIG_FILES src/libMagWrapper/Makefile" ;;
+    "src/web/Makefile") CONFIG_FILES="$CONFIG_FILES src/web/Makefile" ;;
+    "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
+    "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
+    "test/fortran/Makefile") CONFIG_FILES="$CONFIG_FILES test/fortran/Makefile" ;;
+    "test/C/Makefile") CONFIG_FILES="$CONFIG_FILES test/C/Makefile" ;;
+    "test/MagML/Makefile") CONFIG_FILES="$CONFIG_FILES test/MagML/Makefile" ;;
+    "test/python/Makefile") CONFIG_FILES="$CONFIG_FILES test/python/Makefile" ;;
+    "apps/Makefile") CONFIG_FILES="$CONFIG_FILES apps/Makefile" ;;
+    "apps/MagMLInterpretor/Makefile") CONFIG_FILES="$CONFIG_FILES apps/MagMLInterpretor/Makefile" ;;
+    "apps/metgram/Makefile") CONFIG_FILES="$CONFIG_FILES apps/metgram/Makefile" ;;
+    "python/Magics/Makefile") CONFIG_FILES="$CONFIG_FILES python/Magics/Makefile" ;;
+    "python/Magics/setup.py") CONFIG_FILES="$CONFIG_FILES python/Magics/setup.py" ;;
+    "rpms/Makefile") CONFIG_FILES="$CONFIG_FILES rpms/Makefile" ;;
+    "rpms/Magics.spec") CONFIG_FILES="$CONFIG_FILES rpms/Magics.spec" ;;
+    "docs/Magics.dox") CONFIG_FILES="$CONFIG_FILES docs/Magics.dox" ;;
+    "src/magics.pc") CONFIG_FILES="$CONFIG_FILES src/magics.pc" ;;
+
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file" \
+	|| as_fn_error "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$_am_arg" : 'X\(//\)[^/]' \| \
+	 X"$_am_arg" : 'X\(//\)$' \| \
+	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$mf" : 'X\(//\)[^/]' \| \
+	 X"$mf" : 'X\(//\)$' \| \
+	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$file" : 'X\(//\)[^/]' \| \
+	 X"$file" : 'X\(//\)$' \| \
+	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+    "libtool":C)
+
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="CXX F77 "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# An object symbol dumper.
+OBJDUMP=$lt_OBJDUMP
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that does not interpret backslashes.
+ECHO=$lt_ECHO
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking.  This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  case $xsi_shell in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+  func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+  # positional parameters, so assign one to ordinary parameter first.
+  func_stripname_result=${3}
+  func_stripname_result=${func_stripname_result#"${1}"}
+  func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=${1%%=*}
+  func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  case ${1} in
+    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+    *)    func_lo2o_result=${1} ;;
+  esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=$(( $* ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=${#1}
+}
+
+_LT_EOF
+    ;;
+  *) # Bourne compatible functions.
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+  case ${2} in
+    .*) func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+    *)  func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+  esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[^=]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+  func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=`expr "$@"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$1+=\$2"
+}
+_LT_EOF
+    ;;
+  *)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$1=\$$1\$2"
+}
+
+_LT_EOF
+    ;;
+  esac
+
+
+  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+
+    cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
+
+# A language specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking.  This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_CXX
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
+
+
+    cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: F77
+
+# The linker used to build libraries.
+LD=$lt_LD_F77
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_F77
+
+# A language specific compiler.
+CC=$lt_compiler_F77
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_F77
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_F77
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_F77
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_F77
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_F77
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_F77
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_F77
+archive_expsym_cmds=$lt_archive_expsym_cmds_F77
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_F77
+module_expsym_cmds=$lt_module_expsym_cmds_F77
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_F77
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_F77
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_F77
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking.  This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_F77
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_F77
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_F77
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_F77
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_F77
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_F77
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_F77
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_F77
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_F77
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_F77
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_F77
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_F77
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_F77
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_F77
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_F77
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_F77
+postdep_objects=$lt_postdep_objects_F77
+predeps=$lt_predeps_F77
+postdeps=$lt_postdeps_F77
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_F77
+
+# ### END LIBTOOL TAG CONFIG: F77
+_LT_EOF
+
+ ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit $?
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
+
+echo ""
+echo "Magics++ is configured as follows for host type: $host"
+echo ""
+echo "Option            Configure option = Configured value"
+echo "------------------------------------------------------"
+echo "Shared libraries  --enable-shared=$enable_shared"
+echo "Static libraries  --enable-static=$enable_static   (--enable-exception=${exception})"
+echo ""
+echo "Python interface  --enable-python=$python"
+echo ""
+echo "GRIB              --enable-grib=$grib"
+echo "BUFR              --enable-bufr=$bufr"
+echo "netCDF            --enable-netcdf=$netcdf"
+if test "x$SITE_NAME" = 'xecmwf'
+then
+ echo "ODB               --enable-odb=$odb"
+ echo "SPOT              --enable-spot=$spot"
+fi
+echo ""
+
+if test "x${raster}" = "xyes"
+then
+ echo "Raster (GIF,PNG)  --enable-raster=$raster"
+elif test "x${raster}" = "xno"
+then
+ echo "Raster (GIF,PNG)  --enable-raster  FAILED"
+fi
+
+if test "x${cairo}" = "xyes"
+then
+ echo "Cairo & Pango     --enable-cairo=$cairo"
+elif test "x${cairo}" = "xno"
+then
+ echo "Cairo & Pango     --enable-cairo   FAILED"
+fi
+
+echo ""
+if test "x${have_gs}" != 'xno'
+then
+  echo "Ghostscript       $PSDelegate ($GSVersion)"
+else
+  echo "Ghostscript       gs NOT FOUND! Please check, because some functions might not work in the drivers!"
+fi
+if test "${ghostscript_font_dir}x" != 'x'
+then
+  echo "Ghostscript fonts --with-gs-font-dir=$with_gs_font_dir   $ghostscript_font_dir"
+else
+  echo "Ghostscript fonts  NOT FOUND check config.log"
+fi
+
+if test "x${metview}" = 'xyes'
+then
+ echo ""
+ echo "   METVIEW 4 enabled build in ${prefix} !!!"
+ echo ""
+ echo "Qt                --enable-qt=$qt"
+fi
+if test "x${metview}" = 'xyes' -a "x${grib}" = 'xno'
+then
+ echo ""
+ echo "   METVIEW 4 enabled build without Grib_API makes NO sense !!!"
+ echo ""
+fi
+
+echo ""
+echo "Options used to compile and link:"
+echo " CXX     = $CXX"
+echo " CC      = $CC"
+echo " F77     = $F77"
+echo ""
+echo " CFLAGS  = $CFLAGS"
+echo " CPPFLAGS= $CPPFLAGS"
+echo " CXXFLAGS= $CXXFLAGS"
+echo " LDFLAGS = $LDFLAGS"
+echo " LIBS    = $LIBS"
+echo " FLIBS   = $FLIBS"
+echo ""
+echo " MAGICS_3RDPARTY_INCLUDE= $MAGICS_3RDPARTY_INCLUDE"
+echo " MAGICS_3RDPARTY_LIBS   = $MAGICS_3RDPARTY_LIBS"
+echo ""
+echo "Please ensure that the MAGPLUS_HOME environment variable is correctly defined!"
+echo ""
+echo "Magics++ will be installed in   ${prefix}"
+echo ""
+echo "Currently \$MAGPLUS_HOME is     $MAGPLUS_HOME"
+echo ""
+if test "x${cairo}" = "xno"
+then
+echo ""
+echo "  CAIRO LIBRARY NOT FOUND --- PNG and PDF support disabled!"
+echo "     (if you use RPM/DEB you might have forgotten to install cairo-devel and pango-devel packages!)"
+echo ""
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..6d57c13
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,1149 @@
+# Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.59)
+AC_INIT(MagPlus,2)
+
+AC_CONFIG_AUX_DIR(config)
+AC_CONFIG_MACRO_DIR([m4])
+AC_CANONICAL_SYSTEM
+
+# Source file containing package/library versioning information.
+. ${srcdir}/version.sh
+
+MAGICS_OUTPUTS="PS_EPS_PDF_SVG_KML"
+
+SITE_NAME="outside"
+AC_ARG_WITH([site],
+       AS_HELP_STRING([--with-site],[Name of installation site]),
+       [SITE_NAME="$with_site"]
+)
+AC_SUBST(SITE_NAME)
+
+
+if test "x$prefix" != xNONE; then
+  ac_default_prefix=${prefix}
+else
+  prefix=${ac_default_prefix}
+fi
+includedir=${prefix}/include/magics
+
+echo ""
+echo "configuring ${MAGICS_PACKAGE_NAME} ${MAGICS_PACKAGE_VERSION}${MAGICS_PACKAGE_VERSION_ADDENDUM} at ${SITE_NAME}"
+echo ""
+
+AC_SUBST(MAGICS_LIBRARY_CURRENT)dnl
+AC_SUBST(MAGICS_LIBRARY_REVISION)dnl
+AC_SUBST(MAGICS_LIBRARY_AGE)dnl
+
+AC_SUBST(MAGICS_PACKAGE_NAME)dnl
+AC_SUBST(MAGICS_PACKAGE_VERSION)dnl
+AC_SUBST(MAGICS_PACKAGE_RELEASE_DATE)dnl
+AC_SUBST(MAGICS_PACKAGE_COPYRIGHT_PERIOD)dnl
+AC_SUBST(MAGICS_PACKAGE_VERSION_ADDENDUM)dnl
+
+AC_DEFINE_UNQUOTED(MAGICS_VERSION, "${MAGICS_PACKAGE_VERSION}")
+AC_DEFINE_UNQUOTED(MAGICS_NAME, "${MAGICS_PACKAGE_NAME}")
+AC_DEFINE_UNQUOTED(MAGICS_RELEASE_DATE, "${MAGICS_PACKAGE_RELEASE_DATE}")
+AC_DEFINE_UNQUOTED(MAGICS_COPYRIGHT_PERIOD, "${MAGICS_PACKAGE_COPYRIGHT_PERIOD}")
+AC_DEFINE_UNQUOTED(MAGICS_INSTALL_PATH, "${prefix}")
+AC_DEFINE_UNQUOTED(MAGICS_SITE, "${SITE_NAME}")
+AC_DEFINE_UNQUOTED(MAGICS_TTF_PATH, "share/magics/ttf/",[Path to TTF font files.])
+
+AC_SUBST(prefix)
+
+AC_CONFIG_SRCDIR(src/MagicsDouble.cc)
+AM_CONFIG_HEADER(src/magics_config.h)
+
+AM_INIT_AUTOMAKE($MAGICS_PACKAGE_NAME,"${MAGICS_PACKAGE_VERSION}${MAGICS_PACKAGE_VERSION_ADDENDUM}",[http://www.ecmwf.int/publications/manuals/magics/index.html])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+
+AC_DISABLE_STATIC         # TEMPORARY !!!!
+AC_AIX
+LT_INIT
+#AC_PROG_CC([xlc_r icc aCC gcc cc CC])
+: ${CXXFLAGS=""}                            # avoid '-g' - see http://www.gnu.org/software/autoconf/manual/autoconf.html#C_002b_002b-Compiler
+AC_PROG_CXX([xlC_r icpc aC++ g++ c++ CC])
+AC_PROG_F77(ifort gfortran pgf90 pgf77 xlf90_r xlf90 xlf77_r f90 g77)
+
+
+######################
+#
+# Checks for programs.
+#
+
+AC_PROG_LIBTOOL
+#LT_LANG([C++])
+
+#
+#  Generic Metview support  --enable-metview
+#
+AC_ARG_ENABLE(metview, [[  --enable-metview	  enable Metview 4 interface. [default=no]]],
+  metview=$enableval, metview=no)
+
+if test "x$metview" = "xyes" ; then
+
+  qt=yes
+fi
+
+##################################
+#
+#  T H R E A D I N G 
+#
+AC_ARG_ENABLE(threads,,
+  threads=$enableval, threads=yes)
+
+if test "x$threads" = "xyes" ; then
+  AC_DEFINE(MAGICS_THREADS, 1)
+fi
+
+##################################
+#
+#  Enable PKG_CONFIG
+#
+case `${PKG_CONFIG:-pkg-config} --version` in
+[0.?|0.?.?|0.1[0-7]|0.1[0-7].?]) PKGCONFIG_REQUIRES="Requires"; ;;
+*) PKGCONFIG_REQUIRES="Requires.private"; ;;
+esac
+AC_SUBST(PKGCONFIG_REQUIRES)
+
+
+###############################################################################################
+#
+#   P Y T H O N   &   S W I G
+#
+#      --enable-python
+#
+AC_ARG_ENABLE(python, [[  --enable-python	  enable Python interface. [default=no]]],
+  python=$enableval, python=no)
+
+
+if test "x$python" = "xyes"
+then
+  ### search for a python interpreter on the system abort if one not found
+  ### am_path_python sets many python vars - RTFM for more info
+  AM_PATH_PYTHON([2.5])
+
+  AC_MSG_CHECKING(whether numpy is installed)
+   has_numpy=`$PYTHON -c "import numpy;print numpy" 2> /dev/null`
+   if test "x$has_numpy" = "x"
+    then
+       AC_MSG_RESULT(no)
+       AC_MSG_ERROR([NumPy is not installed. Use --disable-python if you want to continue without NumPy.])
+    else
+       AC_MSG_RESULT(yes)
+       NUMPY_INCLUDE=`$PYTHON -c "import numpy;print numpy.get_include()"`
+       CPPFLAGS="-I${NUMPY_INCLUDE} ${CPPFLAGS}"
+       AC_SUBST(NUMPY_INCLUDE)
+    fi
+  AC_DEFINE(MAGICS_PYTHON, 1)
+  AC_SUBST(python)
+fi
+
+#
+#  E N D   P Y T H O N  &  S W I G
+#
+##############################################################################################################
+
+
+
+##################################################
+#
+#  32 bit addressing  --enable-32bit
+#
+AC_ARG_ENABLE([32-bits-addressing-mode],
+        [AC_HELP_STRING([--enable-32-bits-addressing-mode],
+		                [Force 32 bits addressing mode on 64 bits machines])],
+        enable_32_bits_addressing_mode='yes', enable_32_bits_addressing_mode='no')
+
+##################################################
+#
+#  Exception support  --enable-exception
+#
+AC_ARG_ENABLE(exception, [[  --enable-exception	  enable the use of all C++ exceptions (Not recommended for static library using PGF90!) [default=yes]]],
+  exception=$enableval, exception=yes)
+if test "x$exception" = "xyes" ; then
+  AC_DEFINE(MAGICS_EXCEPTION, 1)
+fi
+
+#######################################################################
+#
+# Architecture dependent Compiler options
+#
+windows=no
+SHLIB_EXT=so
+LIBNAME=${LIBNAME:="lib"}
+PLATFORM_DEFINES_MARS=""
+
+
+
+case "${host}" in
+	x86_64*linux*)
+		if test "x$enable_32_bits_addressing_mode" = "xyes" ; then
+		echo " "
+		echo "You are on x86-64 and building a 32 bit version of Magics++."
+		echo " "
+		AXX="-m32"
+		CPPFLAGS="$CPPFLAGS -I/usr/include/freetype2 -I/usr/include -I/usr/X11R6/include -I/usr/local/include"
+		LDFLAGS="$LDFLAGS -L/usr/lib -L/usr/local/lib -L/usr/X11R6/lib"
+		else
+		echo " "
+		echo "You are on x86-64 and building a 64 bit version of Magics++."
+		echo " "
+#		if test "x$SITE_NAME" = xecmwf; then
+#			libdir=${prefix}/lib64
+#		fi
+		AXX="-m64 -fPIC"
+		LIBNAME="lib64"
+		CPPFLAGS="$CPPFLAGS -Dlinux -I/usr/include/freetype2 -I/usr/include -I/usr/X11R6/include -I/usr/local/include"
+		CXXFLAGS="$CXXFLAGS"
+		LDFLAGS="$LDFLAGS -L/usr/local/lib64 -L/usr/X11R6/lib64"
+		PLATFORM_DEFINES_MARS="-DLITTLE -DLITTLE_END -DI64 -DR64 -Dlinux"
+		fi
+		;;
+	# Linux workstations x86
+	*86-*-linux* )
+		CPPFLAGS="$CPPFLAGS -Dlinux -I/usr/include/freetype2 -I/usr/include -I/usr/X11R6/include -I/usr/local/include"
+		LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -L/usr/local/lib"
+		AXX="-m32"
+		PLATFORM_DEFINES_MARS="-DLITTLE -DLITTLE_END -DI32 -DR64 -Dlinux"
+		;;
+	# IBM Server
+	*-ibm-aix* )
+		AXX="-mminimal-toc"
+		CPPFLAGS="${CPPFLAGS} -Daix -DMAGICS_AIX_XLC -I/usr/include/freetype2" # -I/usr/include/freetype2 -I/opt/freeware/include -I/usr/local/include"
+#		LDFLAGS="-L/usr/lib $LDFLAGS"
+		LDFLAGS="-L/usr/lib -Wl,-brtl $LDFLAGS"
+		LIBS="-lfreetype $LIBS -lpng -lz -liconv"  # for terralib
+		MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -lfreetype -lpng"
+		PLATFORM_DEFINES_MARS="-DI32 -DR64 -DREAL_8 -DREAL_BIGGER_THAN_INTEGER -DAIX"
+		;;
+    # MACs
+    *-darwin*)
+        CPPFLAGS="${CPPFLAGS} -DMAGICS_MAC_GCC"
+        LIBS="$LIBS -lpng -lcurl"
+        LDFLAGS="-L/usr/local/lib -L/opt/local/lib $LDFLAGS -lstdc++"
+        CPPFLAGS="-I/usr/local/include -I/opt/local/include $CPPFLAGS"
+        SHLIB_EXT=dylib
+        mac=true
+        AC_DEFINE(MAGICS_MAC, 1)
+        ;;
+    # HP - aCC 
+    *-*-hpux* )
+		#AXX="-AA -Wp,-H30000"
+		PLATFORM_DEFINES_MARS="-DI64 -DR64 -Dhpux"
+		;;
+	*-*-cygwin* | *-*-mingw32*)
+		echo " "
+		echo "You try to install Magics++ on Windows!"
+		echo " "
+		echo " Please be aware that Windows is NOT a supported platform!!!"
+		echo " Following features will NOT work: BUFR decoding"
+		echo " "
+		CPPFLAGS="$CPPFLAGS -DMAGICS_WINDOWS_CYGWIN -I/usr/include/freetype2 -I/usr/include -I/usr/local/include"
+		AXX="-m32"
+		windows=yes
+		;;
+esac
+
+AC_SUBST(AXX)
+AC_SUBST(SHLIB_EXT)
+AC_SUBST(PLATFORM_DEFINES_MARS)
+
+#
+# Compiler dependent Compiler options
+#
+MAGICS_VISIBILITY=""
+
+case "${CXX}" in
+	# GNU GCC
+	g++* )
+		CFLAGS="$CFLAGS $AXX -ansi -std=c99" # -fpermissive
+
+		CXXFLAGS=${CXXFLAGS:="-g -O2 -mtune=native"}
+		CXXFLAGS="$CXXFLAGS $AXX -fno-gnu-keywords -ansi -std=c++98 -Wno-deprecated -Wno-write-strings"
+		CPPLIBS="${CPPLIBS} -lstdc++"
+
+#		AC_LANG([C++])
+#		AC_COMPILE_IFELSE([
+#		#if defined(__GNUC__) && (__GNUC__ < 4 )
+#		#error "GCC < 4.0"
+#		#endif
+#		int main(){return 0;}], gcc4=yes)
+
+#		AC_MSG_RESULT(Test if GCC 4 ${gcc4})
+
+#		if test "x$gcc4" = "xyes" -a "x$metview" = xno; then
+#			  MAGICS_VISIBILITY="-fvisibility=hidden"
+#		fi
+
+		;;
+	# Intel compiler
+	icpc | icc )
+		#  -O3 -xhost -opt-report=3 -vec-report 3
+		#  -O3 -xhost -opt-report=3 -vec-report 3 -parallel -par-report3
+		#  -guide -parallel                                 # produces NO binary output!
+		intel_common="-static-intel -wr654 -wr1125 -wr1011"
+		CFLAGS="$CFLAGS ${intel_common}"
+		CXXFLAGS="$CXXFLAGS ${intel_common}"
+		# -static-intel does the job but if any libraries compiled with g++ are used this is needed  
+		CPPLIBS="${CPPLIBS} -lstdc++"
+		;;
+	# IBM C++ compiler
+	xlC_r | xlC )
+		# -qtune=auto
+		#
+		# -qfuncsect   --> code bloat but later reduction?
+		#
+		# -qmkshrobj   --> no entry point message??? (570 MB)
+		#
+		# -qtemplateregistry=/scratch/graphics/cgm/magics/IBM/templateregistry
+		#
+	#	rm -f ${PWD}/templateregistry
+	#	CXXFLAGS="$CXXFLAGS -O2 -qtune=auto -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000 -qstrict -qtemplateregistry=${PWD}/templateregistry " # 560 MB
+	#	CXXFLAGS="$CXXFLAGS -O2 -qtune=auto -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000 -qtmplinst=none "       # 203 MB - does not work
+	#	CXXFLAGS="$CXXFLAGS -O3 -qsuppress=1540-1101 -DAIX -DNDEBUG -qcpluscmt -qinline=15 -qtune=auto -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000" # 220 MB - works
+		CXXFLAGS="${CXXFLAGS:-"-O3 -DNDEBUG -qinline=15 -qtune=auto"}"     # 21 Apr 2012 - works 174MB
+		CXXFLAGS="${CXXFLAGS:-"-O0 -DDEBUG  -qnoinline  -qNOOPTimize"}"    # 21 Apr 2012 - works 950MB
+		CXXFLAGS="$CXXFLAGS -qxflag=KeepUnqualifiedStaticCandidate -DBOOST_TYPEOF_NATIVE -DBOOST_TYPEOF_KEYWORD=__typeof__ -qsuppress=1540-1101 -DAIX -qcpluscmt -qmaxmem=-1 -qarch=auto -bmaxdata:0x80000000" 
+	#	CXX="xlC $CXXFLAGS"
+		LD=xlC_r
+		CC=xlC_r
+		LDFLAGS="$LDFLAGS -Wl,-bbigtoc"  # -qmkshrobj
+		CFLAGS="$CFLAGS -qtune=auto -qstrict -qmaxmem=-1 -qarch=auto -bmaxdata:0x60000000"
+
+		CPPLIBS="${CPPLIBS} -lC"     # should strictly not nessecary when xlf is used
+		;;
+esac
+
+AC_SUBST(CPPLIBS)
+AC_SUBST(MAGICS_VISIBILITY)
+# end of C++
+
+AC_LANG_PUSH(Fortran)
+
+#
+# Which fortran compiler should be used?
+#
+# FLIBS is determined which Fortran compiler was used for Emoslib!!!
+#
+case "${F77}" in
+	*gfortran* )
+		FLIB="gfortran"
+		FLIBS="-l${FLIB}"
+		FFLAGS="${FFLAGS} ${AXX}"
+		;;
+	# Intel compiler 9.x
+	ifc | ifort)
+		FFLAGS="${FFLAGS}"
+		FLIBS="-lifcore -lifport"
+		;;
+	# Portland C++
+	pgf* )
+		FLIB="pgftnrtl','pgc','rt"             # for Python distutils
+		FLIBS="$FLIBS -lpgftnrtl -lpgc -lrt"   # PGI 7.1
+		case "${host}" in
+			x86_64*linux*)
+				FFLAGS="${FFLAGS} -tp amd64"
+				;;
+			# Linux workstations x86
+			*86-*-linux* )
+				FFLAGS="${FFLAGS} -tp px"
+				;;
+		esac
+		;;
+	# IBM fortran compiler
+	xlf* )
+		FLIB="xlf90"
+		FLIBS="-l${FLIB}"
+		FFLAGS="${FFLAGS} -qfixed=72 -q32"
+		;;
+	# all other C++ compilers ...
+	* )
+		if test "x${F77}" = "x"; then
+			echo "No Fortran compiler defined! Use F77=<name> to set one."
+			FLIBS=""
+		else
+		echo "Oops ... $F77 not supported yet"
+		fi
+		;;
+esac
+AC_SUBST(FLIB)
+AC_SUBST(FLIBS)
+
+AC_LANG_POP
+
+# end of F O R T R A N 
+
+
+
+AC_ARG_ENABLE(allheaders, [[  --enable-allheaders	  install all header files [default=no]]],
+  allheaders=$enableval, allheaders=no)
+
+######################################################################
+#
+#     Qt
+#
+######################################################################
+AC_ARG_ENABLE(qt, [[  --enable-qt             enable Qt-based modules [default=no]]],
+  qt=$enableval)
+
+if test "x$qt" = "xyes" ; then
+  AC_MSG_CHECKING([for Qt])
+  # Qt with AutoTroll.
+  m4_include([m4/autotroll.m4])
+  AT_WITH_QT([+xmlpatterns])
+  AT_REQUIRE_QT_VERSION([4.6],
+       AC_MSG_WARN([Qt version >= 4.6 is required]))
+  AC_DEFINE(MAGICS_QT, 1)
+  CPPFLAGS="-I/usr/include/qt4 ${CPPFLAGS}"  ### for Ubuntu 11.04
+fi
+
+######################################################################
+#
+#     Qt debug
+#
+######################################################################
+AC_ARG_ENABLE(qtdebug, [[  --enable-qtdebug             enable QDebug output in Qt-based modules [default=no]]],
+      qtdebug=$enableval, qtdebug=no)
+
+if test "x${qt}" = xyes -a "x${qtdebug}" = xno ; then
+	CXXFLAGS="${CXXFLAGS} -DQT_NO_DEBUG_OUTPUT"
+fi
+
+
+#####################
+###  M E T V I E W
+
+if test "x$metview" = "xyes" ; then
+  allheaders=yes
+  AC_DEFINE(MAGICS_METVIEW, 1)
+fi
+AC_SUBST(metview)
+AC_SUBST(qt)
+
+
+#
+#  Raster graphics support
+#
+raster=yes
+AC_ARG_ENABLE(raster, [[  --enable-raster         enable the GIF, PNG and JPEG output [default=yes]]],
+  raster=$enableval, raster=yes)
+if test "x$raster" = "xyes" ; then
+  AC_ARG_WITH([gd],
+       [AS_HELP_STRING([--with-gd],
+       [Prefix of GD libraries and headers.])],
+       [CPPFLAGS="-I${with_gd}/include ${CPPFLAGS}";LDFLAGS="-L${with_gd}/${LIBNAME} ${LDFLAGS}"]
+  )
+  AC_CHECK_HEADER( gd.h,[ have_gd_h="yes" ],[ have_gd_h="no" ])
+
+  if test "x$have_gd_h" != "xyes"; then
+   echo
+   echo "   The GD library is required for raster file support in Magics to function."
+   echo "   You can get it from http://www.libgd.org . If your system"
+   echo "   has libgd installed, you probably miss the gd.h header file."
+   raster="no"
+  else
+   AC_DEFINE(MAGICS_RASTER, 1)
+  fi
+fi
+
+
+############################################
+#
+#  enable all headers
+#
+if test "x$allheaders" = "xyes" ; then
+  AC_DEFINE(MAGICS_ALLHEADERS, 1)
+fi
+
+#
+#  JSON support  --enable-json
+#
+AC_ARG_ENABLE(json, [[  --enable-json	          enable the JSON support (JSON) [default=yes]]],
+  json=$enableval, json=yes)
+if test "x$json" = "xyes"  ; then
+  AC_DEFINE(MAGICS_JSON, 1)
+fi
+
+#
+#  apps compilation --enable-apps
+#
+AC_ARG_ENABLE(apps, [[  --enable-apps	          enable the compilation of applications (magml) [default=yes]]],
+  apps=$enableval, apps=yes)
+
+#
+#  BUFR support  --enable-bufr
+#
+AC_ARG_ENABLE(bufr, [[  --enable-bufr	          enable the BUFR support [default=no]]],
+  bufr=$enableval, bufr=no)
+
+
+AC_LANG([C++])
+
+##############################################################################
+##
+##  ODB support  --enable-odb
+##
+AC_ARG_ENABLE(odb, [[  --enable-odb	          enable the ODB support [default=no]]],
+  odb=$enableval, odb=no)
+
+if test "x$odb" = "xyes" ; then
+  AC_DEFINE(MAGICS_ODB, 1)
+  ODB_PATH="/usr/local"
+  AC_ARG_WITH([odb],
+       [AS_HELP_STRING([--with-odb],
+       [Prefix of ODB libraries and headers.])],
+       [ODB_PATH="${with_odb}";CPPFLAGS="-I${with_odb}/include -I${with_odb}/include/eclib -I${with_odb}/include/odb_api ${CPPFLAGS}";LDFLAGS="-L${with_odb}/lib ${LDFLAGS}"]
+  )
+  AC_SUBST(ODB_PATH)
+#  AC_CHECK_LIB(Ec,link_eclib,,,)
+#  AC_CHECK_LIB(Odb,odb_init,,,)
+  AC_MSG_CHECKING([Checking for ODB libraries in ${ODB_PATH}/lib/])
+  if test -f ${ODB_PATH}/lib/libOdb.so ; then
+    MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -L${ODB_PATH}/lib -lEc -lOdb"
+    AC_MSG_RESULT([yes])
+  else
+    AC_MSG_RESULT([FAILED])
+    AC_MSG_ERROR([Could not find ODB library at ${ODB_PATH}/lib/libOdb.so])
+  fi
+fi
+AC_SUBST(odb)
+
+##############################################################################
+#
+# Update developments for metview (development)
+#
+AC_ARG_ENABLE(magnext, [[  --enable-magnext      enable update developments for metview (ECMWF only) [default=false]]],
+magnext=$enableval, magnext=no)
+
+if test "x$magnext" = "xyes" ; then
+  AC_MSG_NOTICE([ENABLED EXPERIMENTAL FEATURES FOR METVIEW (ECMWF)])
+  CXXFLAGS="${CXXFLAGS} -DMAG_NEXT"
+fi
+
+
+#
+# freetype
+#
+if test "x$raster" = "xyes" ; then
+ AC_CHECK_HEADER(ft2build.h,AC_DEFINE(MAGICS_TTF,1),
+  AC_MSG_WARN([could not successfully compile with FreeType2 using the])
+  AC_MSG_WARN([default compiler flags; ]) )
+fi
+
+
+#
+# TIFF
+#
+##AC_ARG_ENABLE(tiff, [[  --enable-tiff         enable the TIFF output [default=no]]],
+##tiff=$enableval, tiff=no)
+
+#if test "x$tiff" = "xyes" ; then
+
+#AC_CHECK_HEADER(tiffio.h,,
+#  AC_MSG_WARN([could not successfully compile with TIFF using the])
+#  AC_MSG_WARN([default compiler flags;])
+#  unset ac_cv_header_tiff_h)
+
+#  AC_DEFINE(MAGICS_TIFF, 1)
+#fi
+
+
+#
+# For XML parser expat
+#
+AC_CHECK_HEADER(expat.h,,
+  AC_MSG_WARN([could not successfully compile with expat using the])
+  AC_MSG_WARN([default compiler flags;])
+  unset ac_cv_header_expat_h)
+
+
+#
+# For  B O O S T 
+#
+AX_BOOST_BASE(1.32,,AC_MSG_ERROR([Boost library not found - if you use RPM do not forget boost-devel]))
+AC_CHECK_HEADER(boost/math/complex.hpp,,
+  AC_MSG_ERROR([could not successfully compile with Boost::Math package])
+  unset ac_cv_header_boost_h)
+
+### Boost.Filesystem
+#AC_CHECK_LIB([boost_system-mt], [main],
+#             [BOOST_FILESYSTEM_LIBS='-lboost_system-mt';LIBS="${LIBS} -lboost_system-mt"],
+#             [AC_MSG_ERROR([Boost.System not found])])
+#AC_CHECK_LIB([boost_filesystem-mt], [main],
+#             [BOOST_FILESYSTEM_LIBS="-lboost_filesystem-mt ${BOOST_FILESYSTEM_LIBS}"],
+#             [AC_MSG_ERROR([Boost.Filesystem not found])])
+#AC_SUBST([BOOST_FILESYSTEM_LIBS])
+#LIBS="$LIBS ${BOOST_FILESYSTEM_LIBS}"
+#MAGICS_3RDPARTY_LIBS="$MAGICS_3RDPARTY_LIBS ${BOOST_FILESYSTEM_LIBS}"
+
+########################################################
+#
+# Check for GRIB API
+#
+# We don't know whether GRIB API was built with jasper or openjeg requirements,
+# so we check for both
+
+AC_ARG_ENABLE(grib, [[  --enable-grib	          enable the GRIB 1/2 support [default=yes]]],
+  grib=$enableval, grib=yes)
+
+if test "x${grib}" = "xyes" ; then
+
+AC_CHECK_LIB(jasper,jas_stream_memopen,[have_jasper="yes"], have_jasper="no")
+if test "${have_jasper}" = "no"
+then
+	echo " "
+	echo "  No Jasper (JPEG 2000) library could be found!"
+	echo "    Your Magics++ programs should work nevertheless as long as"
+	echo "    your GribAPI installed does NOT require it! Compile GribAPI"
+	echo "    without Jasper support."
+	echo " "
+else
+	LIBS="${LIBS} -ljasper"
+fi
+
+
+AC_CHECK_LIB(openjpeg,opj_decode,[have_openjpeg="yes"], have_openjpeg="no")
+if test "${have_openjpeg}" = "no"
+then
+	echo " "
+	echo "  No openjpeg (JPEG 2000) library could be found!"
+	echo "    Your Magics++ programs should work nevertheless as long as"
+	echo "    your GribAPI installed does NOT require it! Compile GribAPI"
+	echo "    without openjpeg support."
+	echo " "
+else
+	LIBS="${LIBS} -lopenjpeg"
+fi
+
+
+
+AC_ARG_WITH([grib-api],
+       [AS_HELP_STRING([--with-grib-api],
+       [Prefix of GRIB API libraries and headers.])],
+       [GRIBAPI_ROOT="${with_grib_api}";CPPFLAGS="-I${with_grib_api}/include ${CPPFLAGS}";LDFLAGS="-L${with_grib_api}/${LIBNAME} -L${with_grib_api}/lib ${LDFLAGS}"; GRIBAPI_LIBS="-L${with_grib_api}/${LIBNAME} "]
+)
+
+AC_CHECK_LIB(grib_api,grib_get_message,,AC_MSG_ERROR([Grib API could not be linked! Try setting --with-grib-api or add dependent libraries if necessary to configure call ("LIBS=-lpng").]))
+AC_SUBST(GRIBAPI_LIBS)
+AC_SUBST(GRIBAPI_ROOT)
+
+AC_DEFINE(MAGICS_GRIB, 1)
+fi
+
+#############################################################################################################
+#
+if test "x$bufr" = "xyes" -a "x$windows" = xno; then 
+#
+#     E M O S L I B -- always DOUBLE precision !!!
+#
+# check if MvOBS files are prperly linked/copied from Metview
+if test -e src/MvObs/MvBufr.h ; then
+
+AC_ARG_WITH([fortran-libraries],
+       [AS_HELP_STRING([--with-fortran-libraries],[Locaction of Fortran runtime libraries required for EMOS library @<:@default is /usr/lib@:>@])],
+       [FORTRAN_LIB_PATH=$with_fortran_libraries;LDFLAGS="-L$with_fortran_libraries $LDFLAGS"]
+)
+AC_SUBST(FORTRAN_LIB_PATH)
+
+EMOS_LIB_NAME="emosR64"
+
+AC_ARG_WITH([emos-libraries],
+       [AS_HELP_STRING([--with-emos-libraries],[Locaction of EMOS library @<:@default is /usr/local/lib@:>@])],
+       [LDFLAGS="-L$with_emos_libraries $LDFLAGS"]
+)
+
+AC_ARG_WITH([emos-libname],
+       [AC_HELP_STRING([--with-emos-libname],[Name of EMOS library @<:@default is emosR64@:>@ ])],
+       [EMOS_LIB_NAME="$with_emos_libname"]
+)
+AC_F77_LIBRARY_LDFLAGS
+AC_CHECK_LIB(${EMOS_LIB_NAME},pbopen,echo "Emoslib found.",
+            AC_MSG_ERROR([The double precision version of Emoslib (${EMOS_LIB_NAME}) could not be linked! Try setting --with-emos-libraries and --with-emos-libname.]))
+
+AC_DEFINE(MAGICS_BUFR, 1)
+MAGICS_3RDPARTY_LIBS="-l${EMOS_LIB_NAME} $MAGICS_3RDPARTY_LIBS"
+AC_SUBST(EMOS_LIB_NAME)
+
+
+else   # MvOBS link failed
+bufr="no"
+echo ""
+echo "  MvOBS source is not linked correctly! BUFR disabled."
+echo ""
+fi
+
+else               # no bufr
+  bufr="no"
+fi
+AC_SUBST(bufr)
+# endif BUFR
+
+
+
+#############################################################################################
+if test "x$SITE_NAME" = 'xecmwf'
+then
+  AC_DEFINE(MAGICS_METGRAM, 1)
+  metgram=yes
+
+  ################
+  #
+  #  Spot support  --enable-spot
+  #
+  AC_ARG_ENABLE(spot, [[  --enable-spot	          enable the SPOT support for metgrams (ECMWF internal) [default=no]]],
+    spot=$enableval, spot=no)
+
+  if test "x$spot" = "xyes" ; then
+     AC_DEFINE(MAGICS_SPOT, 1)
+
+     AC_ARG_WITH([spot],
+       [AS_HELP_STRING([--with-spot],
+       [Prefix of SPOT libraries and headers.])],
+       [MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -L${with_spot}/lib"; CPPFLAGS="-I${with_spot}/include ${CPPFLAGS}";LDFLAGS="-L${with_spot}/lib ${LDFLAGS}"]
+     )
+     AC_CHECK_LIB(spot_database,spot_open_database,,AC_MSG_ERROR([spot_database could not be linked! ]))
+  fi
+  AC_SUBST(spot)
+fi
+###  end ECMWF metgrams
+
+
+############################################
+#
+# Proj4
+#
+AC_ARG_ENABLE(proj4, [[  --enable-proj4	          enable the Proj4 support for projections [default=yes]]], proj4=$enableval, proj4=yes)
+
+if test "x$proj4" = "xyes" ; then
+  AC_ARG_WITH([proj4],
+       [AS_HELP_STRING([--with-proj4],
+       [Prefix of Proj4 libraries and headers.])],
+       [MAGICS_3RDPARTY_LIBS="${MAGICS_3RDPARTY_LIBS} -L${with_proj4}/lib";CPPFLAGS="-I${with_proj4}/include ${CPPFLAGS}";LDFLAGS="-L${with_proj4}/lib ${LDFLAGS}"]
+  )
+  AC_CHECK_LIB(proj,pj_init,,AC_MSG_ERROR([Proj4 could not be linked! ]))
+  AC_DEFINE(MAGICS_PROJ4, 1)
+fi
+AC_SUBST(proj4)
+
+
+
+############################################
+#
+# Checks for other libraries.
+#
+
+if test "x$raster" = "xyes"  ; then
+
+ AC_CHECK_LIB(gd,gdImagePng,,AC_MSG_ERROR([gdImagePng not defined - libGD not found or no PNG support]))
+ AC_CHECK_LIB(gd,gdImageGif,[AC_DEFINE(MAGICS_GIF)
+	 have_gifs="yes"] ,
+	 have_gifs="no")
+ AC_CHECK_LIB(gd,gdImageGifAnimEnd,[AC_DEFINE(MAGICS_GIF_ANIMATED)
+	 have_gifs_ani="yes"] ,
+	 have_gifs_ani="no")
+
+ if test "${have_gifs}" = "no"
+ then
+	echo " "
+	echo "   You have a old GD library with NO GIF support. Please consider"
+	echo "   upgrading to a more recent version (2.0.28 or newer)."
+	echo "   This version of GD will support only PNG and JPEG output."
+	echo " "
+ else
+ 	MAGICS_OUTPUTS="${MAGICS_OUTPUTS}_GIF"
+ fi
+ if test "${have_gifs_ani}" = "no"
+ then
+	echo " "
+	echo "   You have a oldish GD library with NO animated GIF support. Please consider"
+	echo "   upgrading to a more recent version (2.0.32 or newer)."
+	echo "   This version of GD will support PNG, JPEG and (non-animated) GIF output."
+	echo " "
+ else
+ 	MAGICS_OUTPUTS="${MAGICS_OUTPUTS}_AGIF"
+ fi
+fi
+AC_SUBST(raster)
+
+AC_CHECK_HEADER(zlib.h,,AC_MSG_ERROR([could not find zlib.h. You might need to install zlib development packges (zlib-devel)]))
+AC_CHECK_LIB(z, compress)
+
+AC_CHECK_LIB([fontconfig], [FcInitLoadConfigAndFonts], [AC_CHECK_HEADER([fontconfig/fontconfig.h], [LIBS="-lfontconfig $LIBS"])])
+
+AC_CHECK_LIB(pthread,pthread_key_create)
+
+##AC_CHECK_LIB(tiff, TIFFOpen ,,AC_MSG_ERROR([tiff not found.]))
+AC_CHECK_LIB(expat, XML_ParserCreate ,,AC_MSG_ERROR([expat xml parser library not found.]))
+
+
+#################################################################################
+#
+#   N E T C D F    (and CURL)
+#
+#################################################################################
+#
+#  netCDF support  --enable-netcdf
+#
+AC_ARG_ENABLE(netcdf, [[  --enable-netcdf	          enable the netCDF support [default=yes]]],
+  netcdf=$enableval, netcdf=yes)
+
+if test "x${netcdf}" = "xyes" ; then
+
+###   AC_MSG_NOTICE([for curl library sometimes needed by NetCDF])
+  AC_CHECK_LIB(curl,curl_easy_setopt,  [have_curl="yes"], have_curl="no")
+
+  # NetCDF can be built with a dependency on curl. Therefore, we add it to the libraries if it is
+  # installed; otherwise, issue a warning.
+  if test "${have_curl}" = "yes"
+  then
+    CURL_LIBS="${NETCDF_LIBS} -lcurl"
+  else
+    AC_MSG_WARN([No curl library - this is fine as long as your NetCDF library does not require it.])
+  fi
+
+  #
+  # For netcdf header file
+  #
+  AC_ARG_WITH([netcdf],
+       [AS_HELP_STRING([--with-netcdf],
+       [Prefix of NetCDF libraries and headers.])],
+       [CPPFLAGS="-I${with_netcdf}/include ${CPPFLAGS}";LDFLAGS="-L${with_netcdf}/lib ${LDFLAGS}"; NETCDF_LIBS="-L${with_netcdf}/lib "]
+  )
+  AC_CHECK_HEADER(netcdfcpp.h,,
+  AC_MSG_WARN([could not successfully compile with netcdfcpp.h!])
+  unset ac_cv_header_netcdf_h)
+
+  AC_CHECK_LIB(netcdf,ncvarid ,NETCDF_LIBS="${NETCDF_LIBS}-lnetcdf_c++ -lnetcdf ${CURL_LIBS}",AC_MSG_ERROR([netcdf library not found.]))
+  #AC_CHECK_LIB(netcdf_c++, nctypelen        ,echo "",AC_MSG_ERROR([netcdf_c++ library not found.]))
+
+  AC_DEFINE(MAGICS_NETCDF, 1)
+fi
+
+#################################################################################
+#
+#  Cairo support  --enable-cairo
+#
+AC_ARG_ENABLE(cairo,[[  --enable-cairo          enable the Cairo library support [default=yes]]],
+  cairo=$enableval, cairo=yes)
+
+PKG_PROG_PKG_CONFIG
+
+if test "x$cairo" = "xyes" ; then
+
+ MAGICS_OUTPUTS="${MAGICS_OUTPUTS}_PNG_CPS_CSVG_X"
+ 
+  PKG_CHECK_MODULES(CAIRO, [pango >= 1.0.0 pangocairo >= 1.0.0 cairo >= 1.4.0],
+  [
+   CFLAGS="$CAIRO_CFLAGS $CFLAGS"
+   CPPFLAGS="$CAIRO_CFLAGS $CPPFLAGS"
+   LIBS="$CAIRO_LIBS $LIBS"
+   LDFLAGS="$CAIRO_LDFLAGS $LDFLAGS"
+   AC_DEFINE(MAGICS_CAIRO, 1)
+  ],
+  [
+    echo ""
+    echo " Cairo/Pango library could not be found!"
+    echo " Please install cairo-devel and pango-devel ."
+    cairo=no
+  ])  
+  
+  #
+  # NOT good code: 
+  #   required since pkg-config returns non-lib options in LIBS!!!
+  #
+  if test "x${SITE_NAME}" = "xecmwf"; then
+     echo $LIBS > stupid_bug_fix_file_LIBS.txt
+     LIBS=`sed 's/-pthread/ /' stupid_bug_fix_file_LIBS.txt`;
+     rm -f stupid_bug_fix_file_LIBS.txt
+  fi
+
+fi
+AC_SUBST(cairo)
+
+
+#PKG_CHECK_MODULES(GDAL, [gdal >= 1.6.0],
+#  [
+#   CFLAGS="$GDAL_CFLAGS $CFLAGS"
+#   CPPFLAGS="$GDAL_CFLAGS $CPPFLAGS"
+#   LIBS="$GDAL_LIBS $LIBS"
+#   LDFLAGS="$GDAL_LDFLAGS $LDFLAGS"
+#   gdal=yes
+#   AC_DEFINE(MAGICS_GDAL, 1)
+#  ],
+#  [
+#    echo ""
+#    echo " GDAL library could not be found!"
+#    gdal=no
+#  ])
+#AC_SUBST(gdal)
+
+
+# Autoheader
+AH_TEMPLATE(MAGICS_QT,           [Turn on Qt related modules.])
+AH_TEMPLATE(MAGICS_RASTER,       [Turn on raster file format support (GIF&PNG)])
+AH_TEMPLATE(MAGICS_TIFF,         [Turn on TIFF file format support])
+AH_TEMPLATE(MAGICS_CAIRO,        [Turn on the Cairo output support])
+AH_TEMPLATE(MAGICS_OUTPUTS,      [Gives the list of output formats])
+AH_TEMPLATE(MAGICS_TTF,          [Turn on the TTF support])
+AH_TEMPLATE(MAGICS_32BIT,        [Turn on 32 bit addressing])
+AH_TEMPLATE(MAGICS_BUFR,         [Turn off the BUFR support])
+AH_TEMPLATE(MAGICS_JSON,         [Turn on the JSON support])
+AH_TEMPLATE(MAGICS_ODB,          [Turn off the ODB support])
+AH_TEMPLATE(MAGICS_EXCEPTION,    [Turn on the use of Exceptions (not recommended used by Static library!)])
+AH_TEMPLATE(MAGICS_SPOT,         [Turn off the SPOT support])
+AH_TEMPLATE(MAGICS_NETCDF,       [Turn off the netCDF support])
+AH_TEMPLATE(MAGICS_GRIB,         [Turn off the GRIB 1/2 support])
+AH_TEMPLATE(MAGICS_METGRAM,      [Turn on metgram script support])
+AH_TEMPLATE(POSTSCRIPT_FONT_PATH,[Paths to PS fonts.])
+AH_TEMPLATE(MAGICS_VERSION,      [Version of Magics.])
+AH_TEMPLATE(MAGICS_LIBRARY_AGE,      [LIB_AGE of Magics.]) 
+AH_TEMPLATE(MAGICS_LIBRARY_CURRENT,  [LIB_CURRENT of Magics.])
+AH_TEMPLATE(MAGICS_LIBRARY_REVISION, [LIB_REVISION of Magics.])
+AH_TEMPLATE(MAGICS_NAME,         [Name of this package.])
+AH_TEMPLATE(MAGICS_RELEASE_DATE, [Release date of this version.])
+AH_TEMPLATE(MAGICS_COPYRIGHT_PERIOD, [Period of Copyright.])
+AH_TEMPLATE(MAGICS_INSTALL_PATH, [Install path.])
+AH_TEMPLATE(MAGICS_SITE,         [Name of installation site.])
+AH_TEMPLATE(MAGICS_GIF,          [Defines GIF output is supported.])
+AH_TEMPLATE(MAGICS_METVIEW,      [Installation used by metview])
+AH_TEMPLATE(MAGICS_GIF_ANIMATED, [Defines animated GIF output is supported.])
+AH_TEMPLATE(MAGICS_PYTHON,       [Enable Python interface (based on swik).])
+AH_TEMPLATE(MAGICS_ALLHEADERS,   [Install all header files.])
+AH_TEMPLATE(MAGICS_VISIBILITY,   [Sets visibility flags.])
+AH_TEMPLATE(MAGICS_THREADS,      [Turn on/off thread support.])
+AH_TEMPLATE(MAGICS_PROJ4,        [Turn on/off Proj4 support.])
+AH_TEMPLATE(MAGICS_MAC,          [Indicate if Mac is used.])
+
+
+
+#############################################################################
+#
+#  P O S T S C R I P T
+#
+
+# Set Ghostscript font directory
+AC_ARG_WITH(gs-font-dir,[AC_HELP_STRING([--with-gs-font-dir=DIR],[Directory containing Ghostscript fonts.])],
+			[with_gs_font_dir=$withval],[with_gs_font_dir='default'])
+
+#
+# Check for Display Postscript
+#
+PSDelegateDefault='gs'
+AC_PATH_PROG(PSDelegate, "$PSDelegateDefault", "$PSDelegateDefault")
+have_gs='no'
+if test "$PSDelegate" != "$PSDelegateDefault"; then have_gs='yes' ; fi
+
+
+#
+# Test for GhostScriptfont directories
+#
+AC_MSG_CHECKING(for Ghostscript fonts directory)
+ghostscript_font_dir=''
+if test "${with_gs_font_dir}" != 'default'
+then
+  ghostscript_font_dir="${with_gs_font_dir}/"
+else
+    for font_dir in '/usr/share/ghostscript/fonts/' '/usr/share/fonts/default/Type1/' "${prefix}/share/ghostscript/fonts/"
+    do
+      if test -f "${font_dir}/a010013l.pfb"
+      then
+        ghostscript_font_dir="${font_dir}"
+        break 1
+      fi
+    done
+
+    if test "${ghostscript_font_dir}x" = 'x'
+    then
+      if test "$PSDelegate" != 'gs'
+      then
+        ghostscript_font_dir=`echo "$PSDelegate" | sed -e 's:/bin/gs:/share/ghostscript/fonts:'`"/"
+      fi
+    fi
+fi
+
+if test "${ghostscript_font_dir}x" != 'x'
+then
+  AC_MSG_RESULT($ghostscript_font_dir)
+else
+  AC_MSG_RESULT(not found! Some output drivers might NOT work!);
+fi
+AC_SUBST(ghostscript_font_dir)
+AC_DEFINE_UNQUOTED(POSTSCRIPT_FONT_PATH, "${ghostscript_font_dir}")
+
+if test $have_gs = 'yes'
+then
+  AC_MSG_CHECKING(for Ghostscript version)
+  if GSVersion=`$PSDelegate --version`
+  then
+    :
+  else
+    GSVersion=`$PSDelegate --help | sed -e '1q' | awk '{ print $3 }'`
+  fi
+  AC_MSG_RESULT($GSVersion)
+fi
+AC_SUBST(GSVersion)
+#
+#  P O S T S C R I P T  -  E N D
+#
+
+
+
+MAGICS_3RDPARTY_INCLUDE="$CPPFLAGS"
+MAGICS_3RDPARTY_LIBS="$LIBS $GRIBAPI_LIBS $MAGICS_3RDPARTY_LIBS $NETCDF_LIBS"
+LIBS="$LIBS $NETCDF_LIBS"
+
+AC_SUBST(MAGICS_3RDPARTY_INCLUDE)
+AC_SUBST(MAGICS_3RDPARTY_LIBS)
+AC_SUBST(LIBNAME)
+AC_DEFINE_UNQUOTED(MAGICS_OUTPUTS, "${MAGICS_OUTPUTS}")
+
+AM_CONDITIONAL(MAGICS_METVIEW,	test "$metview"   = yes)
+AM_CONDITIONAL(MAGICS_32BIT,	test "$bit"       = yes)
+AM_CONDITIONAL(MAGICS_APPS,     test "$apps"      = yes)
+AM_CONDITIONAL(MAGICS_BUFR,     test "$bufr"      = yes)
+AM_CONDITIONAL(MAGICS_JSON,	test "$json"      = yes)
+AM_CONDITIONAL(MAGICS_ODB,	test "$odb"       = yes)
+AM_CONDITIONAL(MAGICS_EXCEPTION,test "$exception" = yes)
+AM_CONDITIONAL(MAGICS_SPOT,	test "$spot"      = yes)
+AM_CONDITIONAL(MAGICS_GRIB,	test "$grib"      = yes)
+AM_CONDITIONAL(MAGICS_NETCDF,	test "$netcdf"    = yes)
+AM_CONDITIONAL(MAGICS_METGRAM,	test "$metgram"   = yes)
+AM_CONDITIONAL(MAGICS_QT,       test "$qt"        = yes)
+AM_CONDITIONAL(MAGICS_QTDEBUG,  test "$qtdebug"   = no)
+AM_CONDITIONAL(MAGICS_CAIRO,	test "$cairo"     = yes)
+AM_CONDITIONAL(MAGICS_TIFF,	test "$tiff"      = yes)
+AM_CONDITIONAL(MAGICS_RASTER,	test "$raster"    = yes)
+AM_CONDITIONAL(MAGICS_PYTHON,	test "$python"    = yes)
+#AM_CONDITIONAL(MAGICS_GDAL,	test "$gdal"      = yes)
+AM_CONDITIONAL(MAGICS_ALLHEADERS, test "$allheaders"  = yes)
+AM_CONDITIONAL(MAGICS_THREADS, test "$threads"  = yes)
+AM_CONDITIONAL(MAGICS_PROJ4, test "$proj4"  = yes)
+AM_CONDITIONAL(MAGICS_MAC, test "$mac"  = yes)
+
+AC_CONFIG_FILES([Makefile
+		magics-config
+		src/Makefile
+		src/xml/Makefile
+		src/common/Makefile
+		src/basic/Makefile
+		src/decoders/Makefile
+		src/drivers/Makefile
+		src/oda/Makefile
+		src/visualisers/Makefile
+		src/terralib/Makefile
+		src/MvObs/Makefile
+		src/libTable/Makefile
+		src/libMagWrapper/Makefile
+		src/web/Makefile
+		tools/Makefile
+		test/Makefile
+		test/fortran/Makefile
+		test/C/Makefile
+		test/MagML/Makefile
+		test/python/Makefile
+		apps/Makefile
+		apps/MagMLInterpretor/Makefile
+		apps/metgram/Makefile
+		python/Magics/Makefile
+		python/Magics/setup.py
+		rpms/Makefile
+		rpms/Magics.spec
+		docs/Magics.dox
+		src/magics.pc
+		])
+AC_OUTPUT
+
+echo "" 
+echo "Magics++ is configured as follows for host type: $host"
+echo ""
+echo "Option            Configure option = Configured value"
+echo "------------------------------------------------------"
+echo "Shared libraries  --enable-shared=$enable_shared"
+echo "Static libraries  --enable-static=$enable_static   (--enable-exception=${exception})"
+echo ""
+echo "Python interface  --enable-python=$python"
+echo ""
+echo "GRIB              --enable-grib=$grib"
+echo "BUFR              --enable-bufr=$bufr"
+echo "netCDF            --enable-netcdf=$netcdf"
+if test "x$SITE_NAME" = 'xecmwf'
+then
+ echo "ODB               --enable-odb=$odb"
+ echo "SPOT              --enable-spot=$spot"
+fi
+echo ""
+
+if test "x${raster}" = "xyes"
+then
+ echo "Raster (GIF,PNG)  --enable-raster=$raster"
+elif test "x${raster}" = "xno"
+then
+ echo "Raster (GIF,PNG)  --enable-raster  FAILED"
+fi
+
+if test "x${cairo}" = "xyes"
+then
+ echo "Cairo & Pango     --enable-cairo=$cairo"
+elif test "x${cairo}" = "xno"
+then
+ echo "Cairo & Pango     --enable-cairo   FAILED"
+fi
+
+echo ""
+if test "x${have_gs}" != 'xno'
+then
+  echo "Ghostscript       $PSDelegate ($GSVersion)"
+else
+  echo "Ghostscript       gs NOT FOUND! Please check, because some functions might not work in the drivers!"
+fi
+if test "${ghostscript_font_dir}x" != 'x'
+then
+  echo "Ghostscript fonts --with-gs-font-dir=$with_gs_font_dir   $ghostscript_font_dir"
+else
+  echo "Ghostscript fonts  NOT FOUND check config.log"
+fi
+
+if test "x${metview}" = 'xyes'
+then
+ echo ""
+ echo "   METVIEW 4 enabled build in ${prefix} !!!"
+ echo ""
+ echo "Qt                --enable-qt=$qt"
+fi
+if test "x${metview}" = 'xyes' -a "x${grib}" = 'xno'
+then
+ echo ""
+ echo "   METVIEW 4 enabled build without Grib_API makes NO sense !!!"
+ echo ""
+fi
+
+echo ""
+echo "Options used to compile and link:"
+echo " CXX     = $CXX"
+echo " CC      = $CC"
+echo " F77     = $F77"
+echo ""
+echo " CFLAGS  = $CFLAGS"
+echo " CPPFLAGS= $CPPFLAGS"
+echo " CXXFLAGS= $CXXFLAGS"
+echo " LDFLAGS = $LDFLAGS"
+echo " LIBS    = $LIBS"
+echo " FLIBS   = $FLIBS"
+echo ""
+echo " MAGICS_3RDPARTY_INCLUDE= $MAGICS_3RDPARTY_INCLUDE"
+echo " MAGICS_3RDPARTY_LIBS   = $MAGICS_3RDPARTY_LIBS"
+echo ""
+echo "Please ensure that the MAGPLUS_HOME environment variable is correctly defined!"
+echo ""
+echo "Magics++ will be installed in   ${prefix}"
+echo ""
+echo "Currently \$MAGPLUS_HOME is     $MAGPLUS_HOME"
+echo ""
+if test "x${cairo}" = "xno"
+then
+echo ""
+echo "  CAIRO LIBRARY NOT FOUND --- PNG and PDF support disabled!" 
+echo "     (if you use RPM/DEB you might have forgotten to install cairo-devel and pango-devel packages!)" 
+echo ""
+fi
diff --git a/docs/Magics.dox.in b/docs/Magics.dox.in
new file mode 100644
index 0000000..d08c65c
--- /dev/null
+++ b/docs/Magics.dox.in
@@ -0,0 +1,1531 @@
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = @PACKAGE_NAME@
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = @MAGICS_PACKAGE_VERSION@
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = api/
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, 
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = NO
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = @top_srcdir@
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses. 
+# With this tag you can assign which parser to use for a given extension. 
+# Doxygen has a built-in mapping, but you can override or extend it using this tag. 
+# The format is ext=language, where ext is a file extension, and language is one of 
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, 
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat 
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), 
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also make the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen to replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
+# determine which symbols to keep in memory and which to flush to disk. 
+# When the cache is full, less often used symbols will be written to disk. 
+# For small to medium size projects (<1000 input files) the default value is 
+# probably good enough. For larger projects a too small cache size can cause 
+# doxygen to be busy swapping symbols to and from disk most of the time 
+# causing a significant performance penality. 
+# If the system has enough physical memory increasing the cache will improve the 
+# performance by keeping more symbols in memory. Note that the value works on 
+# a logarithmic scale so increasing the size by one will rougly double the 
+# memory usage. The cache size is given by this formula: 
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page. 
+# This will remove the Namespaces entry from the Quick Index 
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by 
+# doxygen. The layout file controls the global structure of the generated output files 
+# in an output format independent way. The create the layout file that represents 
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a 
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name 
+# of the layout file.
+
+LAYOUT_FILE            = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = NO
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = @top_srcdir@/docs/Magics.dox.error.out
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = @top_srcdir@/src
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx 
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cpp \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.py \
+                         *.magml \
+                         *.json
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = @top_srcdir@/terralib
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
+# directories that are symbolic links (a Unix filesystem feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = @top_srcdir@/test/C \
+                         @top_srcdir@/test/MagML \
+                         @top_srcdir@/test/fortran \
+                         @top_srcdir@/test/python
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = *.cc \
+                         *.h \
+                         *.c \
+                         *.f \
+                         *.magml \
+                         *.py
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = YES
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output. 
+# If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis. 
+# Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match. 
+# The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = YES
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = NO
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 
+# link to the source code. 
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded. For this to work a browser that supports 
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox 
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup. 
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER 
+# are set, an additional index file will be generated that can be used as input for 
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated 
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
+# be used to specify the file name of the resulting .qch file. 
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = 
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. 
+# For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see 
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's 
+# filter section matches. 
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
+# be used to specify the location of Qt's qhelpgenerator. 
+# If non-empty doxygen will try to run qhelpgenerator on the generated 
+# .qhp file.
+
+QHG_LOCATION           = 
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
+# structure should be generated to display hierarchical information. 
+# If the tag value is set to FRAME, a side panel will be generated 
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature. Other possible values 
+# for this tag are: HIERARCHIES, which will generate the Groups, Directories, 
+# and Class Hierarchy pages using a tree view instead of an ordered list; 
+# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which 
+# disables this behavior completely. For backwards compatibility with previous 
+# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE 
+# respectively.
+
+GENERATE_TREEVIEW      = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader. 
+# This is useful 
+# if you want to understand what is going on. 
+# On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = @top_srcdir@/src/ \
+			 @top_srcdir@/src/common/ \
+			 @top_srcdir@/src/decoders/ \
+			 @top_srcdir@/src/terralib/
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse 
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#  
+# TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#  
+# TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links. 
+# Note that each tag file must have a unique name 
+# (where the name does NOT include the path) 
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option is superseded by the HAVE_DOT option below. This is only a 
+# fallback. It is recommended to install and use dot, since it yields more 
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = NO
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output 
+# directory and reference it in all dot files that doxygen generates. This 
+# font does not include all possible unicode characters however, so when you need 
+# these (or just want a differently looking font) you can specify the font name 
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font, 
+# which can be done by putting it in a standard location or by setting the 
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the 
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a 
+# different font using DOT_FONTNAME you can set the path where dot 
+# can find it using this tag.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = NO
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include 
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif 
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, because dot on Windows does not 
+# seem to support this out of the box. Warning: Depending on the platform used, 
+# enabling this option may lead to badly anti-aliased labels on the edges of 
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Options related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
diff --git a/m4/autotroll.m4 b/m4/autotroll.m4
new file mode 100644
index 0000000..d7e071e
--- /dev/null
+++ b/m4/autotroll.m4
@@ -0,0 +1,563 @@
+# Build Qt apps with the autotools (Autoconf/Automake).
+# M4 macros.
+# This file is part of AutoTroll.
+# Copyright (C) 2006  Benoit Sigoure <benoit.sigoure at lrde.epita.fr>
+#
+# AutoTroll is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+#
+# In addition, as a special exception, the copyright holders of AutoTroll
+# give you unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the macros of
+# AutoTroll.  You need not follow the terms of the GNU General Public License
+# when using or distributing such scripts, even though portions of the text of
+# AutoTroll appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes AutoTroll.
+#
+# This special exception to the GPL applies to versions of AutoTroll
+# released by the copyright holders of AutoTroll.  Note that people who make
+# modified versions of AutoTroll are not obligated to grant this special
+# exception for their modified versions; it is their choice whether to do so.
+# The GNU General Public License gives permission to release a modified version
+# without this exception; this exception also makes it possible to release a
+# modified version which carries forward this exception.
+
+ # ------------- #
+ # DOCUMENTATION #
+ # ------------- #
+
+# Disclaimer: Never tested with anything else than Qt 4.2! Feedback welcome.
+# Simply invoke AT_WITH_QT in your configure.ac. AT_WITH_QT can take
+# arguments which are documented in depth below. The default arguments are
+# equivalent to the default .pro file generated by qmake.
+#
+# Invoking AT_WITH_QT will do the following:
+#  - Add a --with-qt option to your configure
+#  - Find qmake, moc and uic and save them in the make variables $(QMAKE),
+#    $(MOC), $(UIC).
+#  - Save the path to Qt in $(QT_PATH)
+#  - Find the flags to use Qt, that is:
+#     * $(QT_DEFINES): -D's defined by qmake.
+#     * $(QT_CFLAGS): CFLAGS as defined by qmake (C?!)
+#     * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake.
+#     * $(QT_INCPATH): -I's defined by qmake.
+#     * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH)
+#     * $(QT_LFLAGS): LFLAGS defined by qmake.
+#     * $(QT_LDFLAGS): Same thing as $(QT_LFLAGS).
+#     * $(QT_LIBS): LIBS defined by qmake.
+#
+# You *MUST* invoke $(MOC) and/or $(UIC) where necessary. AutoTroll provides
+# you with Makerules to ease this, here is a sample Makefile.am to use with
+# AutoTroll which builds the code given in the chapter 7 of the Qt Tutorial:
+# http://doc.trolltech.com/4.2/tutorial-t7.html
+#
+# -------------------------------------------------------------------------
+# include $(top_srcdir)/build-aux/autotroll.mk
+#
+# ACLOCAL_AMFLAGS = -I build-aux
+#
+# bin_PROGRAMS = lcdrange
+# lcdrange_SOURCES =  $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp
+# lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS)
+# lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS)
+# lcdrange_LDFLAGS  = $(QT_LDFLAGS) $(LDFLAGS)
+# lcdrange_LDADD    = $(QT_LIBS) $(LDADD)
+#
+# BUILT_SOURCES = lcdrange.moc.cpp
+# -------------------------------------------------------------------------
+#
+# Note that your MOC, UIC and QRC files *MUST* be listed manually in
+# BUILT_SOURCES. If you name them properly (eg: .moc.cc, .qrc.cc, .ui.cc -- of
+# course you can use .cpp or .cxx or .C rather than .cc) AutoTroll will build
+# them automagically for you (using implicit rules defined in autotroll.mk).
+
+m4_define([_AUTOTROLL_SERIAL], [m4_translit([
+# serial 4
+], [#
+], [])])
+
+
+m4_ifdef([AX_INSTEAD_IF], [],
+[AC_DEFUN([AX_INSTEAD_IF],
+  [m4_ifval([$1],
+    [AC_MSG_WARN([$2]); [$1]],
+    [AC_MSG_ERROR([$2])])])])
+
+m4_pattern_forbid([^AT_])dnl
+m4_pattern_forbid([^_AT_])dnl
+
+# AT_WITH_QT([QT_modules], [QT_config], [QT_misc], [RUN-IF-FAILED], [RUN-IF-OK])
+# ------------------------------------------------------------------------------
+# Enable Qt support and add an option --with-qt to the configure script.
+#
+# The QT_modules argument is optional and defines extra modules to enable or
+# disable (it's equivalent to the QT variable in .pro files). Modules can be
+# specified as follows:
+#
+# AT_WITH_QT   => No argument -> No QT value.
+#                                Qmake sets it to "core gui" by default.
+# AT_WITH_QT([xml])   => QT += xml
+# AT_WITH_QT([+xml])  => QT += xml
+# AT_WITH_QT([-gui])  => QT -= gui
+# AT_WITH_QT([xml -gui +sql svg])  => QT += xml sql svg
+#                                     QT -= gui
+#
+# The QT_config argument is also optional and follows the same convention as
+# QT_modules. Instead of changing the QT variable, it changes the CONFIG
+# variable, which is used to tweak configuration and compiler options.
+#
+# The last argument, QT_misc (also optional) will be copied as-is the .pro
+# file used to guess how to compile Qt apps. You may use it to further tweak
+# the build process of Qt apps if tweaking the QT or CONFIG variables isn't
+# enough for you.
+#
+# RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
+# problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
+# called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
+AC_DEFUN([AT_WITH_QT],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_CXX])dnl
+echo "$as_me: this is autotroll.m4[]_AUTOTROLL_SERIAL" >&AS_MESSAGE_LOG_FD
+
+  test x"$TROLL" != x && echo 'ViM rox emacs.'
+
+dnl Memo: AC_ARG_WITH(package, help-string, [if-given], [if-not-given])
+  AC_ARG_WITH([qt],
+              [AS_HELP_STRING([--with-qt],
+                 [Path to Qt @<:@Look in PATH and /usr/local/Trolltech@:>@])],
+              [QT_PATH=$withval])
+
+  # this is a hack to get decent flow control with 'break'
+  for _qt_ignored in once; do
+
+  # Find Qt.
+  AC_ARG_VAR([QT_PATH], [Path to the Qt installation])
+  if test -d /usr/local/Trolltech; then
+    # Try to find the latest version.
+    tmp_qt_paths=`echo /usr/local/Trolltech/*/bin | tr ' ' '\n' | sort -nr \
+                                              | xargs | sed 's/  */:/g'`
+  fi
+  # Path to which recent MacPorts (~v1.7) install Qt4.
+  test -d /opt/local/libexec/qt4-mac/bin \
+    && tmp_qt_paths="$tmp_qt_paths:/opt/local/libexec/qt4-mac/bin"
+
+  # Find qmake.
+  AC_ARG_VAR([QMAKE], [Qt Makefile generator command])
+  AC_PATH_PROGS([QMAKE], [qmake qmake-qt4 qmake-qt3], [missing],
+                [$QT_DIR:$QT_PATH:$PATH:$tmp_qt_paths])
+  if test x"$QMAKE" = xmissing; then
+    AX_INSTEAD_IF([$4], [Cannot find qmake in your PATH. Try using --with-qt.])
+    break
+  fi
+
+  # Find moc (Meta Object Compiler).
+  AC_ARG_VAR([MOC], [Qt Meta Object Compiler command])
+  AC_PATH_PROGS([MOC], [moc moc-qt4 moc-qt3], [missing],
+                [$QT_PATH:$PATH:$tmp_qt_paths])
+  if test x"$MOC" = xmissing; then
+    AX_INSTEAD_IF([$4],
+   [Cannot find moc (Meta Object Compiler) in your PATH. Try using --with-qt.])
+    break
+  fi
+
+  # Find uic (User Interface Compiler).
+  AC_ARG_VAR([UIC], [Qt User Interface Compiler command])
+  AC_PATH_PROGS([UIC], [uic uic-qt4 uic-qt3 uic3], [missing],
+                [$QT_PATH:$PATH:$tmp_qt_paths])
+  if test x"$UIC" = xmissing; then
+    AX_INSTEAD_IF([$4],
+[Cannot find uic (User Interface Compiler) in your PATH. Try using --with-qt.])
+    break
+  fi
+
+  # Find rcc (Qt Resource Compiler).
+  AC_ARG_VAR([RCC], [Qt Resource Compiler command])
+  AC_PATH_PROGS([RCC], [rcc], [false], [$QT_PATH:$PATH:$tmp_qt_paths])
+  if test x"$UIC" = xfalse; then
+    AC_MSG_WARN([Cannot find rcc (Qt Resource Compiler) in your PATH.\
+  Try using --with-qt.])
+  fi
+
+  AC_MSG_CHECKING([whether host operating system is Darwin])
+  at_darwin=no
+  at_qmake_args=
+  case $host_os in
+    darwin*)
+      at_darwin=yes
+      at_qmake_args='-spec macx-g++'
+      ;;
+  esac
+  AC_MSG_RESULT([$at_darwin])
+
+  # If we don't know the path to Qt, guess it from the path to qmake.
+  if test x"$QT_PATH" = x; then
+    QT_PATH=`dirname "$QMAKE"`
+  fi
+  if test x"$QT_PATH" = x; then
+    AX_INSTEAD_IF([$4],
+                  [Cannot find the path to your Qt install. Use --with-qt.])
+    break
+  fi
+  AC_SUBST([QT_PATH])
+
+  # Get ready to build a test-app with Qt.
+  if mkdir conftest.dir && cd conftest.dir; then :; else
+    AX_INSTEAD_IF([$4], [Cannot mkdir conftest.dir or cd to that directory.])
+    break
+  fi
+
+  cat >conftest.h <<_ASEOF
+#include <QObject>
+
+class Foo: public QObject
+{
+  Q_OBJECT;
+public:
+  Foo();
+  ~Foo() {}
+public Q_SLOTS:
+  void setValue(int value);
+Q_SIGNALS:
+  void valueChanged(int newValue);
+private:
+  int value_;
+};
+_ASEOF
+
+  cat >conftest.cpp <<_ASEOF
+#include "conftest.h"
+Foo::Foo()
+  : value_ (42)
+{
+  connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
+}
+
+void Foo::setValue(int value)
+{
+  value_ = value;
+}
+
+int main()
+{
+  Foo f;
+}
+_ASEOF
+  if $QMAKE -project; then :; else
+    AX_INSTEAD_IF([$4], [Calling $QMAKE -project failed.])
+    break
+  fi
+
+  # Find the .pro file generated by qmake.
+  pro_file='conftest.dir.pro'
+  test -f $pro_file || pro_file=`echo *.pro`
+  if test -f "$pro_file"; then :; else
+    AX_INSTEAD_IF([$4], [Can't find the .pro file generated by Qmake.])
+    break
+  fi
+
+dnl Tweak the value of QT in the .pro if have been the 1st arg.
+m4_ifval([$1], [_AT_TWEAK_PRO_FILE([QT], [$1])])
+
+dnl Tweak the value of CONFIG in the .pro if have been given a 2nd arg.
+m4_ifval([$2], [_AT_TWEAK_PRO_FILE([CONFIG], [$2])])
+
+m4_ifval([$3],
+[ # Add the extra-settings the user wants to set in the .pro
+  echo "$3" >>"$pro_file"
+])
+
+  echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" >&AS_MESSAGE_LOG_FD
+  sed 's/^/| /' "$pro_file" >&AS_MESSAGE_LOG_FD
+
+  if $QMAKE $at_qmake_args; then :; else
+    AX_INSTEAD_IF([$4], [Calling $QMAKE $at_qmake_args failed.])
+    break
+  fi
+
+  # QMake has a very annoying misfeature: sometimes it generates Makefiles
+  # where all the references to the files from the Qt installation are
+  # relative.  We can't use them as-is because if we take, say, a
+  # -I../../usr/include/Qt from that Makefile, the flag is invalid as soon
+  # as we use it in another (sub) directory.  So what this perl pass does is
+  # that it rewrite all relative paths to absolute paths.  Another problem
+  # when building on Cygwin is that QMake mixes paths with blackslashes and
+  # forward slashes and paths must be handled with extra care because of the
+  # stupid Windows drive letters.
+  echo "$as_me:$LINENO: fixing the Makefiles:" Makefile* >&AS_MESSAGE_LOG_FD
+  cat >fixmk.pl <<\EOF
+[use strict;
+use Cwd qw(cwd abs_path);
+# This variable is useful on Cygwin for the following reason: Say that you are
+# in `/' (that is, in fact you are in C:/cygwin, or something like that) if you
+# `cd ..' then obviously you remain in `/' (that is in C:/cygwin).  QMake
+# generates paths that are relative to C:/ (or another driver letter, whatever)
+# so the trick to get the `..' resolved properly is to prepend the absolute
+# path of the current working directory in a Windows-style.  C:/cygwin/../ will
+# properly become C:/.
+my $d = "";
+my $r2a = 0;
+my $b2f = 0;
+
+my $cygwin = 0;
+if ($^O eq "cygwin") {
+  $cygwin = 1;
+  $d = cwd();
+  $d = `cygpath --mixed '$d'`;
+  chomp($d);
+  $d .= "/";
+}
+
+sub rel2abs($)
+{
+  my $p = $d . shift;
+  # print "r2a p=$p";
+  -e $p || return $p;
+  if ($cygwin) {
+    $p = `cygpath --mixed '$p'`;
+    chomp($p);
+  }
+  else {
+    # Do not use abs_path on Cygwin: it incorrectly resolves the paths that are
+    # relative to C:/ rather than `/'.
+    $p = abs_path($p);
+  }
+  # print " -> $p\n";
+  ++$r2a;
+  return $p;
+}
+
+# Only useful on Cygwin.
+sub back2forward($)
+{
+  my $p = shift;
+  # print "b2f p=$p";
+  -e $p || return $p;
+  $p = `cygpath --mixed '$p'`;
+  chomp($p);
+  # print " -> $p\n";
+  ++$b2f;
+  return $p;
+}
+
+foreach my $mk (@ARGV)
+{
+  next if $mk =~ /~$/;
+  open(MK, $mk) or die("open $mk: $!");
+  # print "mk=$mk\n";
+  my $file = join("", <MK>);
+  close(MK) or die("close $mk: $!");
+  rename $mk, $mk . "~" or die("rename $mk: $!");
+  $file =~ s{(?:\.\.[\\/])+(?:[^"'\s:]+)}{rel2abs($&)}gse;
+  $file =~ s{(?:[a-zA-Z]:[\\/])?(?:[^"\s]+\\[^"\s:]+)+}
+            {back2forward($&)}gse if $cygwin;
+  open(MK, ">", $mk) or die("open >$mk: $!");
+  print MK $file;
+  close(MK) or die("close >$mk: $!");
+  print "$mk: updated $r2a relative paths and $b2f backslash-style paths\n";
+  $r2a = 0;
+  $b2f = 0;
+}]
+EOF
+
+  perl >&AS_MESSAGE_LOG_FD -w fixmk.pl Makefile* ||
+  AC_MSG_WARN([failed to fix the Makefiles generated by $QMAKE])
+  rm -f fixmk.pl
+
+  # Try to compile a simple Qt app.
+  AC_CACHE_CHECK([whether we can build a simple Qt app], [at_cv_qt_build],
+  [at_cv_qt_build=ko
+  : ${MAKE=make}
+
+  if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
+    at_cv_qt_build='ok, looks like Qt 4'
+  else
+    echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
+instead" >&AS_MESSAGE_LOG_FD
+    sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h && mv tmp.h conftest.h
+    if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
+      at_cv_qt_build='ok, looks like Qt 3'
+    else
+      # Sometimes (such as on Debian) build will fail because Qt hasn't been
+      # installed in debug mode and qmake tries (by default) to build apps in
+      # debug mode => Try again in release mode.
+      echo "$as_me:$LINENO: Build failed, trying to enforce release mode" \
+            >&AS_MESSAGE_LOG_FD
+
+      _AT_TWEAK_PRO_FILE([CONFIG], [+release])
+
+      sed 's/<qobject.h>/<QObject>/' conftest.h > tmp.h && mv tmp.h conftest.h
+      if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
+        at_cv_qt_build='ok, looks like Qt 4, release mode forced'
+      else
+        echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
+instead" >&AS_MESSAGE_LOG_FD
+        sed 's/<QObject>/<qobject.h>/' conftest.h >tmp.h && mv tmp.h conftest.h
+        if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
+          at_cv_qt_build='ok, looks like Qt 3, release mode forced'
+        else
+          at_cv_qt_build=ko
+          echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
+          sed 's/^/| /' conftest.h >&AS_MESSAGE_LOG_FD
+          echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
+          sed 's/^/| /' conftest.cpp >&AS_MESSAGE_LOG_FD
+        fi # if make with Qt3-style #include and release mode forced.
+      fi # if make with Qt4-style #include and release mode forced.
+    fi # if make with Qt3-style #include.
+  fi # if make with Qt4-style #include.
+  ])dnl end: AC_CACHE_CHECK(at_cv_qt_build)
+
+  if test x"$at_cv_qt_build" = xko; then
+    AX_INSTEAD_IF([$4], [Cannot build a test Qt program])
+    break
+  fi
+  QT_VERSION_MAJOR=`echo "$at_cv_qt_build" | sed 's/[[^0-9]]*//g'`
+  AC_SUBST([QT_VERSION_MAJOR])
+
+  # This sed filter is applied after an expression of the form: /^FOO.*=/!d;
+  # It starts by removing the beginning of the line, removing references to
+  # SUBLIBS, removing unnecessary whitespaces at the beginning, and prefixes
+  # all variable uses by QT_.
+  qt_sed_filter='s///;
+                 s/$(SUBLIBS)//g;
+                 s/^ *//;
+                 s/\$(\(@<:@A-Z_@:>@@<:@A-Z_@:>@*\))/$(QT_\1)/g'
+
+  # Find the Makefile (qmake happens to generate a fake Makefile which invokes
+  # a Makefile.Debug or Makefile.Release). We we have both, we'll pick the
+  # Makefile.Release. The reason is that the main difference is that release
+  # uses -Os and debug -g. We can override -Os by passing another -O but we
+  # usually don't override -g.
+  if test -f Makefile.Release; then
+    at_mfile='Makefile.Release'
+  else
+    at_mfile='Makefile'
+  fi
+  if test -f $at_mfile; then :; else
+    AX_INSTEAD_IF([$4], [Cannot find the Makefile generated by qmake.])
+    break
+  fi
+
+  # Find the DEFINES of Qt (should have been named CPPFLAGS).
+  AC_CACHE_CHECK([for the DEFINES to use with Qt], [at_cv_env_QT_DEFINES],
+  [at_cv_env_QT_DEFINES=`sed "/^DEFINES@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
+  AC_SUBST([QT_DEFINES], [$at_cv_env_QT_DEFINES])
+
+  # Find the CFLAGS of Qt (We can use Qt in C?!)
+  AC_CACHE_CHECK([for the CFLAGS to use with Qt], [at_cv_env_QT_CFLAGS],
+  [at_cv_env_QT_CFLAGS=`sed "/^CFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
+  AC_SUBST([QT_CFLAGS], [$at_cv_env_QT_CFLAGS])
+
+  # Find the CXXFLAGS of Qt.
+  AC_CACHE_CHECK([for the CXXFLAGS to use with Qt], [at_cv_env_QT_CXXFLAGS],
+  [at_cv_env_QT_CXXFLAGS=`sed "/^CXXFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
+  AC_SUBST([QT_CXXFLAGS], [$at_cv_env_QT_CXXFLAGS])
+
+  # Find the INCPATH of Qt.
+  AC_CACHE_CHECK([for the INCPATH to use with Qt], [at_cv_env_QT_INCPATH],
+  [at_cv_env_QT_INCPATH=`sed "/^INCPATH@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
+  AC_SUBST([QT_INCPATH], [$at_cv_env_QT_INCPATH])
+
+  AC_SUBST([QT_CPPFLAGS], ["$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"])
+
+  # Find the LFLAGS of Qt (Should have been named LDFLAGS)
+  AC_CACHE_CHECK([for the LDFLAGS to use with Qt], [at_cv_env_QT_LDFLAGS],
+  [at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
+  AC_SUBST([QT_LFLAGS], [$at_cv_env_QT_LDFLAGS])
+  AC_SUBST([QT_LDFLAGS], [$at_cv_env_QT_LDFLAGS])
+
+  # Find the LIBS of Qt.
+  AC_CACHE_CHECK([for the LIBS to use with Qt], [at_cv_env_QT_LIBS],
+  [at_cv_env_QT_LIBS=`sed "/^LIBS@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile`
+   if test x$at_darwin = xyes; then
+     # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a) doesn't handle
+     # -F properly. The "bug" has been fixed on 22 October 2006
+     # by Peter O'Gorman but we provide backward compatibility here.
+     at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \
+                             | sed 's/^-F/-Wl,-F/;s/ -F/ -Wl,-F/g'`
+   fi
+  ])
+  AC_SUBST([QT_LIBS], [$at_cv_env_QT_LIBS])
+
+  cd .. && rm -rf conftest.dir
+
+  # Run the user code
+  $5
+
+  done  # end hack (useless for to be able to use break)
+])
+
+# AT_REQUIRE_QT_VERSION(QT_version, RUN-IF-FAILED, RUN-IF-OK)
+# -----------------------------------------------------------
+# Check (using qmake) that Qt's version "matches" QT_version.
+# Must be run AFTER AT_WITH_QT. Requires autoconf 2.60.
+#
+# RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
+# problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
+# called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
+AC_DEFUN([AT_REQUIRE_QT_VERSION],
+[ AC_PREREQ([2.60])
+  # this is a hack to get decent flow control with 'break'
+  for _qt_ignored in once; do
+
+  if test x"$QMAKE" = x; then
+    AX_INSTEAD_IF([$2],
+                  [\$QMAKE is empty.\
+  Did you invoke AT@&t at _WITH_QT before AT@&t at _REQUIRE_QT_VERSION?])
+    break
+  fi
+  AC_CACHE_CHECK([for Qt's version], [at_cv_QT_VERSION],
+  [echo "$as_me:$LINENO: Running $QMAKE --version:" >&AS_MESSAGE_LOG_FD
+  $QMAKE --version >&AS_MESSAGE_LOG_FD 2>&1
+  qmake_version_sed=['/^.*\([0-9]\.[0-9]\.[0-9]\).*$/!d;s//\1/']
+  at_cv_QT_VERSION=`$QMAKE --version 2>&1 | sed "$qmake_version_sed"`])
+  if test x"$at_cv_QT_VERSION" = x; then
+    AX_INSTEAD_IF([$2], [Cannot detect Qt's version.])
+    break
+  fi
+  AC_SUBST([QT_VERSION], [$at_cv_QT_VERSION])
+  AS_VERSION_COMPARE([$QT_VERSION], [$1],
+    [AX_INSTEAD_IF([$2; break; ], [This package requires Qt $1 or above.])])
+
+  # Run the user code
+  $3
+
+  done  # end hack (useless for to be able to use break)
+])
+
+# _AT_TWEAK_PRO_FILE(QT_VAR, VALUE)
+# ---------------------------
+# @internal. Tweak the variable QT_VAR in the .pro.
+# VALUE is an IFS-separated list of value and each value is rewritten
+# as follows:
+#   +value  => QT_VAR += value
+#   -value  => QT_VAR -= value
+#    value  => QT_VAR += value
+AC_DEFUN([_AT_TWEAK_PRO_FILE],
+[ # Tweak the value of $1 in the .pro file for $2.
+
+  qt_conf=''
+  for at_mod in $2; do
+    at_mod=`echo "$at_mod" | sed 's/^-//; tough
+                                  s/^+//; beef
+                                  :ough
+                                  s/^/$1 -= /;n
+                                  :eef
+                                  s/^/$1 += /'`
+    qt_conf="$qt_conf
+$at_mod"
+  done
+  echo "$qt_conf" | sed 1d >>"$pro_file"
+])
diff --git a/m4/autotroll.mk b/m4/autotroll.mk
new file mode 100644
index 0000000..202693c
--- /dev/null
+++ b/m4/autotroll.mk
@@ -0,0 +1,108 @@
+# Makerules.
+# This file is part of AutoTroll.
+# Copyright (C) 2006, 2007, 2009, 2010  Benoit Sigoure.
+#
+# AutoTroll is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+#
+# In addition, as a special exception, the copyright holders of AutoTroll
+# give you unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the macros of
+# AutoTroll.  You need not follow the terms of the GNU General Public License
+# when using or distributing such scripts, even though portions of the text of
+# AutoTroll appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes AutoTroll.
+#
+# This special exception to the GPL applies to versions of AutoTroll
+# released by the copyright holders of AutoTroll.  Note that people who make
+# modified versions of AutoTroll are not obligated to grant this special
+# exception for their modified versions; it is their choice whether to do so.
+# The GNU General Public License gives permission to release a modified version
+# without this exception; this exception also makes it possible to release a
+# modified version which carries forward this exception.
+
+ # ------------- #
+ # DOCUMENTATION #
+ # ------------- #
+
+# See autotroll.m4 :)
+
+
+SUFFIXES = .moc.cpp .moc.cc .moc.cxx .moc.C .h .hh .hpp \
+			.ui .ui.h .ui.hh .ui.hpp \
+			.qrc .qrc.cpp .qrc.cc .qrc.cxx .qrc.C
+
+# --- #
+# MOC #
+# --- #
+
+.hpp.moc.cpp:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.hh.moc.cpp:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.h.moc.cpp:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+.hpp.moc.cc:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.hh.moc.cc:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.h.moc.cc:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+.hpp.moc.cxx:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.hh.moc.cxx:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.h.moc.cxx:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+.hpp.moc.C:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.hh.moc.C:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+.h.moc.C:
+	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+# --- #
+# UIC #
+# --- #
+
+.ui.ui.hpp:
+	$(UIC) $< -o $@
+
+.ui.ui.hh:
+	$(UIC) $< -o $@
+
+.ui.ui.h:
+	$(UIC) $< -o $@
+
+# --- #
+# RCC #
+# --- #
+
+.qrc.qrc.cpp:
+	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+.qrc.qrc.cc:
+	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+.qrc.qrc.cxx:
+	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+.qrc.qrc.C:
+	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+DISTCLEANFILES = $(BUILT_SOURCES)
diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4
new file mode 100644
index 0000000..54a2a1b
--- /dev/null
+++ b/m4/ax_boost_base.m4
@@ -0,0 +1,258 @@
+# ===========================================================================
+#       http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# DESCRIPTION
+#
+#   Test for the Boost C++ libraries of a particular version (or newer)
+#
+#   If no path to the installed boost library is given the macro searchs
+#   under /usr, /usr/local, /opt and /opt/local and evaluates the
+#   $BOOST_ROOT environment variable. Further documentation is available at
+#   <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+#
+#   And sets:
+#
+#     HAVE_BOOST
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Thomas Porschberg <thomas at randspringer.de>
+#   Copyright (c) 2009 Peter Adolphs
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 20
+
+AC_DEFUN([AX_BOOST_BASE],
+[
+AC_ARG_WITH([boost],
+  [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
+    [use Boost library from a standard location (ARG=yes),
+     from the specified location (ARG=<path>),
+     or disable it (ARG=no)
+     @<:@ARG=yes@:>@ ])],
+    [
+    if test "$withval" = "no"; then
+        want_boost="no"
+    elif test "$withval" = "yes"; then
+        want_boost="yes"
+        ac_boost_path=""
+    else
+        want_boost="yes"
+        ac_boost_path="$withval"
+    fi
+    ],
+    [want_boost="yes"])
+
+
+AC_ARG_WITH([boost-libdir],
+        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
+        [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
+        [
+        if test -d "$withval"
+        then
+                ac_boost_lib_path="$withval"
+        else
+                AC_MSG_ERROR(--with-boost-libdir expected directory name)
+        fi
+        ],
+        [ac_boost_lib_path=""]
+)
+
+if test "x$want_boost" = "xyes"; then
+    boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
+    boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
+    boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
+    boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+    boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+    if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+        boost_lib_version_req_sub_minor="0"
+        fi
+    WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+    AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
+    succeeded=no
+
+    dnl On 64-bit systems check for system libraries in both lib64 and lib.
+    dnl The former is specified by FHS, but e.g. Debian does not adhere to
+    dnl this (as it rises problems for generic multi-arch support).
+    dnl The last entry in the list is chosen by default when no libraries
+    dnl are found, e.g. when only header-only libraries are installed!
+    libsubdirs="lib"
+    ax_arch=`uname -m`
+    if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then
+        libsubdirs="lib64 lib lib64"
+    fi
+
+    dnl first we check the system location for boost libraries
+    dnl this location ist chosen if boost libraries are installed with the --layout=system option
+    dnl or if you install boost with RPM
+    if test "$ac_boost_path" != ""; then
+        BOOST_CPPFLAGS="-I$ac_boost_path/include"
+        for ac_boost_path_tmp in $libsubdirs; do
+                if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
+                        BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
+                        break
+                fi
+        done
+    elif test "$cross_compiling" != yes; then
+        for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+            if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+                for libsubdir in $libsubdirs ; do
+                    if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+                done
+                BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
+                BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+                break;
+            fi
+        done
+    fi
+
+    dnl overwrite ld flags if we have required special directory with
+    dnl --with-boost-libdir parameter
+    if test "$ac_boost_lib_path" != ""; then
+       BOOST_LDFLAGS="-L$ac_boost_lib_path"
+    fi
+
+    CPPFLAGS_SAVED="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+    export CPPFLAGS
+
+    LDFLAGS_SAVED="$LDFLAGS"
+    LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+    export LDFLAGS
+
+    AC_REQUIRE([AC_PROG_CXX])
+    AC_LANG_PUSH(C++)
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+    @%:@include <boost/version.hpp>
+    ]], [[
+    #if BOOST_VERSION >= $WANT_BOOST_VERSION
+    // Everything is okay
+    #else
+    #  error Boost version is too old
+    #endif
+    ]])],[
+        AC_MSG_RESULT(yes)
+    succeeded=yes
+    found_system=yes
+        ],[
+        ])
+    AC_LANG_POP([C++])
+
+
+
+    dnl if we found no boost with system layout we search for boost libraries
+    dnl built and installed without the --layout=system option or for a staged(not installed) version
+    if test "x$succeeded" != "xyes"; then
+        _version=0
+        if test "$ac_boost_path" != ""; then
+            if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+                for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+                    _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+                    V_CHECK=`expr $_version_tmp \> $_version`
+                    if test "$V_CHECK" = "1" ; then
+                        _version=$_version_tmp
+                    fi
+                    VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+                    BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+                done
+            fi
+        else
+            if test "$cross_compiling" != yes; then
+                for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+                    if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+                        for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+                            _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+                            V_CHECK=`expr $_version_tmp \> $_version`
+                            if test "$V_CHECK" = "1" ; then
+                                _version=$_version_tmp
+                                best_path=$ac_boost_path
+                            fi
+                        done
+                    fi
+                done
+
+                VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+                BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+                if test "$ac_boost_lib_path" = ""; then
+                    for libsubdir in $libsubdirs ; do
+                        if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+                    done
+                    BOOST_LDFLAGS="-L$best_path/$libsubdir"
+                fi
+            fi
+
+            if test "x$BOOST_ROOT" != "x"; then
+                for libsubdir in $libsubdirs ; do
+                    if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+                done
+                if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
+                    version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+                    stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+                        stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
+                    V_CHECK=`expr $stage_version_shorten \>\= $_version`
+                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+                        AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
+                        BOOST_CPPFLAGS="-I$BOOST_ROOT"
+                        BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
+                    fi
+                fi
+            fi
+        fi
+
+        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+        export CPPFLAGS
+        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+        export LDFLAGS
+
+        AC_LANG_PUSH(C++)
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        @%:@include <boost/version.hpp>
+        ]], [[
+        #if BOOST_VERSION >= $WANT_BOOST_VERSION
+        // Everything is okay
+        #else
+        #  error Boost version is too old
+        #endif
+        ]])],[
+            AC_MSG_RESULT(yes)
+        succeeded=yes
+        found_system=yes
+            ],[
+            ])
+        AC_LANG_POP([C++])
+    fi
+
+    if test "$succeeded" != "yes" ; then
+        if test "$_version" = "0" ; then
+            AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
+        else
+            AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
+        fi
+        # execute ACTION-IF-NOT-FOUND (if present):
+        ifelse([$3], , :, [$3])
+    else
+        AC_SUBST(BOOST_CPPFLAGS)
+        AC_SUBST(BOOST_LDFLAGS)
+        AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+        # execute ACTION-IF-FOUND (if present):
+        ifelse([$2], , :, [$2])
+    fi
+
+    CPPFLAGS="$CPPFLAGS_SAVED"
+    LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
diff --git a/m4/libtool.m4 b/m4/libtool.m4
new file mode 100644
index 0000000..b1251be
--- /dev/null
+++ b/m4/libtool.m4
@@ -0,0 +1,7356 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 56 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+       [m4_default([$3],
+		   [m4_fatal([Libtool version $1 or higher is required],
+		             63)])],
+       [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+  *\ * | *\	*)
+    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+_LT_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    _LT_PATH_MAGIC
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+                     [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME.  Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+	[m4_ifval([$1], [$1], [$2])])
+    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+    m4_ifval([$4],
+	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+    lt_dict_add_subkey([lt_decl_dict], [$2],
+	[tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+  [0], [m4_fatal([$0: too few arguments: $#])],
+  [1], [m4_fatal([$0: too few arguments: $#: $1])],
+  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+     m4_if([$2], [],
+	   m4_quote(lt_decl_varnames),
+	m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'.  VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly.  In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+#    <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+#    # Some comment about what VAR is for.
+#    visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+					   [description])))[]dnl
+m4_pushdef([_libtool_name],
+    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+    [0], [_libtool_name=[$]$1],
+    [1], [_libtool_name=$lt_[]$1],
+    [2], [_libtool_name=$lt_[]$1],
+    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'.  Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+	dnl If the libtool generation code has been placed in $CONFIG_LT,
+	dnl instead of duplicating it all over again into config.status,
+	dnl then we will have config.status run $CONFIG_LT later, so it
+	dnl needs to know what name is stored there:
+        [AC_CONFIG_COMMANDS([libtool],
+            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+    dnl If the libtool generation code is destined for config.status,
+    dnl expand the accumulated commands and init code now:
+    [AC_CONFIG_COMMANDS([libtool],
+        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+    case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+    *[[\\\\\\\`\\"\\\$]]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\[$]0 --fallback-echo"')dnl "
+  lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+  ;;
+esac
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+cat >"$CONFIG_LT" <<_LTEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate a libtool stub with the current configuration.
+
+lt_cl_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AS_SHELL_SANITIZE
+_AS_PREPARE
+
+exec AS_MESSAGE_FD>&1
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+  echo
+  AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+  -h, --help      print this help, then exit
+  -V, --version   print version number, then exit
+  -q, --quiet     do not print progress messages
+  -d, --debug     don't remove temporary files
+
+Report bugs to <bug-libtool at gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+  case $[1] in
+    --version | --v* | -V )
+      echo "$lt_cl_version"; exit 0 ;;
+    --help | --h* | -h )
+      echo "$lt_cl_help"; exit 0 ;;
+    --debug | --d* | -d )
+      debug=: ;;
+    --quiet | --q* | --silent | --s* | -q )
+      lt_cl_silent=: ;;
+
+    -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+    *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+  esac
+  shift
+done
+
+if $lt_cl_silent; then
+  exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure.  Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+if test "$no_create" != yes; then
+  lt_cl_success=:
+  test "$silent" = yes &&
+    lt_config_lt_args="$lt_config_lt_args --quiet"
+  exec AS_MESSAGE_LOG_FD>/dev/null
+  $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+  exec AS_MESSAGE_LOG_FD>>config.log
+  $lt_cl_success || AS_EXIT(1)
+fi
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars.  Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+  m4_if(_LT_TAG, [C], [
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+  case $host_os in
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
+    ;;
+  esac
+
+  _LT_PROG_LTMAIN
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  _LT_PROG_XSI_SHELLFNS
+
+  sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+    || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+  [C],			[_LT_LANG(C)],
+  [C++],		[_LT_LANG(CXX)],
+  [Java],		[_LT_LANG(GCJ)],
+  [Fortran 77],		[_LT_LANG(F77)],
+  [Fortran],		[_LT_LANG(FC)],
+  [Windows Resource],	[_LT_LANG(RC)],
+  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+    [_LT_LANG($1)],
+    [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+  [LT_SUPPORTED_TAG([$1])dnl
+  m4_append([_LT_TAGS], [$1 ])dnl
+  m4_define([_LT_LANG_]$1[_enabled], [])dnl
+  _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+  [LT_LANG(CXX)],
+  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+  [LT_LANG(F77)],
+  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+  [LT_LANG(FC)],
+  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+  [LT_LANG(GCJ)],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+    [LT_LANG(GCJ)],
+    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+      [LT_LANG(GCJ)],
+      [m4_ifdef([AC_PROG_GCJ],
+	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([A][M_PROG_GCJ],
+	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+       m4_ifdef([LT_PROG_GCJ],
+	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+  [LT_LANG(RC)],
+  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+    AC_CHECK_TOOL([LIPO], [lipo], [:])
+    AC_CHECK_TOOL([OTOOL], [otool], [:])
+    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+    _LT_DECL([], [DSYMUTIL], [1],
+      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+    _LT_DECL([], [NMEDIT], [1],
+      [Tool to change global to local symbols on Mac OS X])
+    _LT_DECL([], [LIPO], [1],
+      [Tool to manipulate fat objects and archives on Mac OS X])
+    _LT_DECL([], [OTOOL], [1],
+      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+    _LT_DECL([], [OTOOL64], [1],
+      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&AS_MESSAGE_LOG_FD
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+	[lt_cv_ld_exported_symbols_list=yes],
+	[lt_cv_ld_exported_symbols_list=no])
+	LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[012]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[[012]]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES
+# --------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_automatic, $1)=yes
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  _LT_TAGVAR(link_all_deplibs, $1)=yes
+  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=echo
+    _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    m4_if([$1], [CXX],
+[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
+],[])
+  else
+  _LT_TAGVAR(ld_shlibs, $1)=no
+  fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX
+# -----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+	     [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+	 [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_SHELL_INIT
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[_LT_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+  ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X[$]1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $ECHO works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<_LT_EOF
+[$]*
+_LT_EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+  if test "X${echo_test_string+set}" != Xset; then
+    # find a string as large as possible, as long as the shell can cope with it
+    for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+      # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+      if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+	 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+      then
+        break
+      fi
+    done
+  fi
+
+  if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+     echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+     test "X$echo_testing_string" = "X$echo_test_string"; then
+    :
+  else
+    # The Solaris, AIX, and Digital Unix default echo programs unquote
+    # backslashes.  This makes it impossible to quote backslashes using
+    #   echo "$something" | sed 's/\\/\\\\/g'
+    #
+    # So, first we look for a working echo in the user's PATH.
+
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for dir in $PATH /usr/ucb; do
+      IFS="$lt_save_ifs"
+      if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+         test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        ECHO="$dir/echo"
+        break
+      fi
+    done
+    IFS="$lt_save_ifs"
+
+    if test "X$ECHO" = Xecho; then
+      # We didn't find a better echo, so look for alternatives.
+      if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+         echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+         test "X$echo_testing_string" = "X$echo_test_string"; then
+        # This shell has a builtin print -r that does the trick.
+        ECHO='print -r'
+      elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+	   test "X$CONFIG_SHELL" != X/bin/ksh; then
+        # If we have ksh, try running configure again with it.
+        ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+        export ORIGINAL_CONFIG_SHELL
+        CONFIG_SHELL=/bin/ksh
+        export CONFIG_SHELL
+        exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+      else
+        # Try using printf.
+        ECHO='printf %s\n'
+        if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+	   echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	  # Cool, printf works
+	  :
+        elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	  export CONFIG_SHELL
+	  SHELL="$CONFIG_SHELL"
+	  export SHELL
+	  ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+        elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	     test "X$echo_testing_string" = 'X\t' &&
+	     echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	     test "X$echo_testing_string" = "X$echo_test_string"; then
+	  ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+        else
+	  # maybe with a smaller string...
+	  prev=:
+
+	  for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+	    if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+	    then
+	      break
+	    fi
+	    prev="$cmd"
+	  done
+
+	  if test "$prev" != 'sed 50q "[$]0"'; then
+	    echo_test_string=`eval $prev`
+	    export echo_test_string
+	    exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+	  else
+	    # Oops.  We lost completely, so just stick with echo.
+	    ECHO=echo
+	  fi
+        fi
+      fi
+    fi
+  fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+   lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(lt_ECHO)
+])
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1],
+    [An echo program that does not interpret backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+  [AS_HELP_STRING([--disable-libtool-lock],
+    [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_i386"
+	    ;;
+	  ppc64-*linux*|powerpc64-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  ppc*-*linux*|powerpc*-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[AC_CHECK_TOOL(AR, ar, false)
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1])
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+    [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+    [Commands used to build an old-style archive])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$5], , :, [$5])
+else
+    m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                  [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    m4_if([$4], , :, [$4])
+else
+    m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+	         = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+    [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+  return status;
+}]
+_LT_EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+    ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+    ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+	  [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	[AC_CHECK_FUNC([dlopen],
+	      [lt_cv_dlopen="dlopen"],
+	  [AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+	    [AC_CHECK_LIB([svld], [dlopen],
+		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+	      [AC_CHECK_LIB([dld], [dld_link],
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+	      ])
+	    ])
+	  ])
+	])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+	  lt_cv_dlopen_self, [dnl
+	  _LT_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+	  lt_cv_dlopen_self_static, [dnl
+	  _LT_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+	 [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+	 [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+	 [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+	[Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+         [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+  [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+    [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+    fi
+    ;;
+  *)
+    AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+	[], [
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[[4-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+       LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+    [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+       [shlibpath_overrides_runpath=yes])])
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+    [Variables whose values should be saved in libtool wrapper scripts and
+    restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+    [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+    [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+    [[List of archive names.  First name is the real one, the rest are links.
+    The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+    [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [postinstall_cmds], [2],
+    [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+    [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+    [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+    [[As "finish_cmds", except a single script fragment to be evaled but
+    not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+    [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+    [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+    [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="m4_if([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_ARG_WITH([gnu-ld],
+    [AS_HELP_STRING([--with-gnu-ld],
+	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_DECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+    [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+    [Command to use when deplibs_check_method == "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
+  AC_SUBST([DUMPBIN])
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+  [lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&AS_MESSAGE_LOG_FD
+  (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
+  cat conftest.out >&AS_MESSAGE_LOG_FD
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+	[Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris*)
+  symcode='[[BDRT]]'
+  ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK ['"\
+"     {last_section=section; section=\$ 3};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx]"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+	  cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+const struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$lt_save_LIBS"
+	  CFLAGS="$lt_save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+    [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+    [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+    [lt_cv_sys_global_symbol_to_c_name_address], [1],
+    [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+    [Transform the output of nm in a C name address pair when lib prefix is needed])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+m4_if([$1], [CXX], [
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[[4-9]]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	else
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	    ;;
+	  ecpc* )
+	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	    ;;
+	  icpc* )
+	    # Intel C++, used to be incompatible with GCC.
+	    # ICC 10 doesn't accept -KPIC any more.
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  xlc* | xlC*)
+	    # IBM XL 8.0 on PPC
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd*)
+	;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+	;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	# +Z the default
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      m4_if([$1], [GCJ], [],
+	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+	;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    rdos*)
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    unicos*)
+      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t at m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+	[How to pass a linker flag through the compiler])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t at m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+	[Additional compiler flags for building library objects])
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+	[Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[[4-9]]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw* | cegcc*)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+], [
+  runpath_var=
+  _LT_TAGVAR(allow_undefined_flag, $1)=
+  _LT_TAGVAR(always_export_symbols, $1)=no
+  _LT_TAGVAR(archive_cmds, $1)=
+  _LT_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_TAGVAR(compiler_needs_object, $1)=no
+  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  _LT_TAGVAR(hardcode_automatic, $1)=no
+  _LT_TAGVAR(hardcode_direct, $1)=no
+  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_TAGVAR(inherit_rpath, $1)=no
+  _LT_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_TAGVAR(module_cmds, $1)=
+  _LT_TAGVAR(module_expsym_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_TAGVAR(whole_archive_flag_spec, $1)=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+  extract_expsyms_cmds=
+
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_TAGVAR(ld_shlibs, $1)=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[[3-9]]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=no
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    interix[[3-9]]*)
+      _LT_TAGVAR(hardcode_direct, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	lf95*)				# Lahey Fortran 8.1
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
+	  tmp_sharedflag='--shared' ;;
+	xl[[cC]]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  _LT_TAGVAR(compiler_needs_object, $1)=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+	  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        _LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	_LT_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix[[4-9]]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_TAGVAR(archive_cmds, $1)=''
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  _LT_TAGVAR(hardcode_direct, $1)=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	  _LT_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        _LT_SYS_MODULE_PATH_AIX
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 _LT_SYS_MODULE_PATH_AIX
+	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            _LT_TAGVAR(archive_expsym_cmds, $1)=''
+        ;;
+      m68k)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[[45]]*)
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      _LT_DARWIN_LINKER_FEATURES($1)
+      ;;
+
+    dgux*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
+	_LT_TAGVAR(hardcode_direct, $1)=yes
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	_LT_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  _LT_TAGVAR(hardcode_direct, $1)=no
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  ;;
+	*)
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        AC_LINK_IFELSE(int foo(void) {},
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+        )
+        LDFLAGS="$save_LDFLAGS"
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(inherit_rpath, $1)=yes
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	_LT_TAGVAR(hardcode_direct, $1)=yes
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	     ;;
+	   *)
+	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	_LT_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    os2*)
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    solaris*)
+      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_direct, $1)=yes
+      _LT_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+	  _LT_TAGVAR(hardcode_direct, $1)=no
+        ;;
+	motorola)
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	_LT_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+    [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+	pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+        _LT_TAGVAR(allow_undefined_flag, $1)=
+        if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+        then
+	  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        else
+	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+        fi
+        _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+    [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+    [enable_shared_with_static_runtimes], [0],
+    [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+    [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+    [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+    [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+    [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+    [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+    [Commands used to build a loadable module if different from building
+    a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+    [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+    [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+    [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+    [Flag to hardcode $libdir into a binary during linking.
+    This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
+    [[If ld is used when linking, flag to hardcode $libdir into a binary
+    during linking.  This must work even if $libdir does not exist]])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+    [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+    DIR into the resulting binary and the resulting library dependency is
+    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+    library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+    into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+    [Set to "yes" if building a shared library automatically hardcodes DIR
+    into the library and all subsequent libraries and executables linked
+    against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+    [Set to yes if linker adds runtime paths of dependent libraries
+    to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+    [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [fix_srcfile_path], [1],
+    [Fix the shell variable $srcfile for the compiler])
+_LT_TAGDECL([], [always_export_symbols], [0],
+    [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+    [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+    [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+    [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+    [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [file_list_spec], [1],
+    [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl    [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_SYS_DYNAMIC_LINKER($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+  LT_SYS_DLOPEN_SELF
+  _LT_CMD_STRIPLIB
+
+  # Report which library types will actually be built
+  AC_MSG_CHECKING([if libtool supports shared libraries])
+  AC_MSG_RESULT([$can_build_shared])
+
+  AC_MSG_CHECKING([whether to build shared libraries])
+  test "$can_build_shared" = "no" && enable_shared=no
+
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
+
+  aix[[4-9]]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  AC_MSG_RESULT([$enable_shared])
+
+  AC_MSG_CHECKING([whether to build static libraries])
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  AC_MSG_RESULT([$enable_static])
+
+  _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_PROG_CXX
+# ------------
+# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
+# compiler, we have our own version here.
+m4_defun([_LT_PROG_CXX],
+[
+pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
+AC_PROG_CXX
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+else
+  _lt_caught_CXX_error=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_CXX
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined.  These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[AC_REQUIRE([_LT_PROG_CXX])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+    else
+      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+    fi
+
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
+
+      LT_PATH_LD
+
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
+
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+	  $GREP 'no-whole-archive' > /dev/null; then
+          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          _LT_TAGVAR(whole_archive_flag_spec, $1)=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
+
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
+
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
+
+    # PORTME: fill in a description of your system's C++ link characteristics
+    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+    _LT_TAGVAR(ld_shlibs, $1)=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+      aix[[4-9]]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
+
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	    for ld_flag in $LDFLAGS; do
+	      case $ld_flag in
+	      *-brtl*)
+	        aix_use_runtimelinking=yes
+	        break
+	        ;;
+	      esac
+	    done
+	    ;;
+          esac
+
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
+
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+        _LT_TAGVAR(archive_cmds, $1)=''
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+        _LT_TAGVAR(link_all_deplibs, $1)=yes
+        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[[012]]|aix4.[[012]].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	    # We have reworked collect2
+	    :
+	  else
+	    # We have old collect2
+	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
+	    # It fails to find uninstalled libraries when the uninstalled
+	    # path is not listed in the libpath.  Setting hardcode_minus_L
+	    # to unsupported forces relinking
+	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+          esac
+          shared_flag='-shared'
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag="$shared_flag "'${wl}-G'
+	  fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	  # chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+          else
+	    if test "$aix_use_runtimelinking" = yes; then
+	      shared_flag='${wl}-G'
+	    else
+	      shared_flag='${wl}-bM:SRE'
+	    fi
+          fi
+        fi
+
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+	# export.
+        _LT_TAGVAR(always_export_symbols, $1)=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          _LT_SYS_MODULE_PATH_AIX
+          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+	    # Determine the default libpath from the value encoded in an
+	    # empty executable.
+	    _LT_SYS_MODULE_PATH_AIX
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    # Warning - without using the other run time loading flags,
+	    # -berok will link without error, but may produce a broken library.
+	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	    # Exported symbols can be pulled into shared objects from archives
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+	    # This is similar to how AIX traditionally builds its shared
+	    # libraries.
+	    _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
+
+      beos*)
+	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	  # support --undefined.  This deserves some investigation.  FIXME
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	else
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+
+      chorus*)
+        case $cc_basename in
+          *)
+	  # FIXME: insert proper C++ library support
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	  ;;
+        esac
+        ;;
+
+      cygwin* | mingw* | pw32* | cegcc*)
+        # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+        # as there is no search path for DLLs.
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+        _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+        _LT_TAGVAR(always_export_symbols, $1)=no
+        _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+        if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+          # If the export-symbols file already is a .def file (1st line
+          # is EXPORTS), use it as is; otherwise, prepend...
+          _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	    cp $export_symbols $output_objdir/$soname.def;
+          else
+	    echo EXPORTS > $output_objdir/$soname.def;
+	    cat $export_symbols >> $output_objdir/$soname.def;
+          fi~
+          $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+        else
+          _LT_TAGVAR(ld_shlibs, $1)=no
+        fi
+        ;;
+      darwin* | rhapsody*)
+        _LT_DARWIN_LINKER_FEATURES($1)
+	;;
+
+      dgux*)
+        case $cc_basename in
+          ec++*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          ghcx*)
+	    # Green Hills C++ Compiler
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
+
+      freebsd[[12]]*)
+        # C++ shared libraries reported to be fairly broken before
+	# switch to ELF
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      freebsd-elf*)
+        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+        ;;
+
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+        ;;
+
+      gnu*)
+        ;;
+
+      hpux9*)
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        _LT_TAGVAR(hardcode_direct, $1)=yes
+        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+				             # but as the default
+				             # location of the library.
+
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            _LT_TAGVAR(ld_shlibs, $1)=no
+            ;;
+          aCC*)
+            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              _LT_TAGVAR(ld_shlibs, $1)=no
+            fi
+            ;;
+        esac
+        ;;
+
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            _LT_TAGVAR(hardcode_direct, $1)=no
+            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+            ;;
+          *)
+            _LT_TAGVAR(hardcode_direct, $1)=yes
+            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+					         # but as the default
+					         # location of the library.
+            ;;
+        esac
+
+        case $cc_basename in
+          CC*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          aCC*)
+	    case $host_cpu in
+	      hppa*64*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      ia64*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      *)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	    esac
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test $with_gnu_ld = no; then
+	        case $host_cpu in
+	          hppa*64*)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          ia64*)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          *)
+	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	        esac
+	      fi
+	    else
+	      # FIXME: insert proper C++ library support
+	      _LT_TAGVAR(ld_shlibs, $1)=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      interix[[3-9]]*)
+	_LT_TAGVAR(hardcode_direct, $1)=no
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+	# Instead, shared libraries are loaded at an image base (0x10000000 by
+	# default) and relocated if they conflict, which is a slow very memory
+	# consuming and fragmenting process.  To avoid this, we pick a random,
+	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	_LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+	    # SGI C++
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test "$with_gnu_ld" = no; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	      else
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+	      fi
+	    fi
+	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+	    ;;
+        esac
+        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+        _LT_TAGVAR(inherit_rpath, $1)=yes
+        ;;
+
+      linux* | k*bsd*-gnu)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    with_gnu_ld=yes
+	    # version 8.0 and above of icpc choke on multiply defined symbols
+	    # if we add $predep_objects and $postdep_objects, however 7.1 and
+	    # earlier do not add the objects themselves.
+	    case `$CC -V 2>&1` in
+	      *"Version 7."*)
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	      *)  # Version 8.0 or newer
+	        tmp_idyn=
+	        case $host_cpu in
+		  ia64*) tmp_idyn=' -i_dynamic';;
+		esac
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	    esac
+	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+	    case `$CC -V` in
+	    *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
+	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+		$RANLIB $oldlib'
+	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    *) # Version 6 will use weak symbols
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    esac
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+	  cxx*)
+	    # Compaq C++
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	    runpath_var=LD_RUN_PATH
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  xl*)
+	    # IBM XL 8.0 on PPC, with GNU ld
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    if test "x$supports_anon_versioning" = xyes; then
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+		echo "local: *; };" >> $output_objdir/$libname.ver~
+		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	    fi
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	      _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+	      # Not sure whether something based on
+	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	      # would be better.
+	      output_verbose_link_cmd='echo'
+
+	      # Archives containing C++ object files must be created using
+	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	      # necessary to make sure instantiated templates are included
+	      # in the archive.
+	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+
+      lynxos*)
+        # FIXME: insert proper C++ library support
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	;;
+
+      m88k*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+	;;
+
+      mvs*)
+        case $cc_basename in
+          cxx*)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+	  *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+	esac
+	;;
+
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+	  wlarc=
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	fi
+	# Workaround some broken pre-1.5 toolchains
+	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+	;;
+
+      *nto* | *qnx*)
+        _LT_TAGVAR(ld_shlibs, $1)=yes
+	;;
+
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+	_LT_TAGVAR(ld_shlibs, $1)=no
+	;;
+
+      openbsd*)
+	if test -f /usr/libexec/ld.so; then
+	  _LT_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  fi
+	  output_verbose_link_cmd=echo
+	else
+	  _LT_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Archives containing C++ object files must be created using
+	    # the KAI C++ compiler.
+	    case $host in
+	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+	    esac
+	    ;;
+          RCC*)
+	    # Rational C++ 2.4.1
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          cxx*)
+	    case $host in
+	      osf3*)
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+		;;
+	      *)
+	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	          echo "-hidden">> $lib.exp~
+	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+	          $RM $lib.exp'
+	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+		;;
+	    esac
+
+	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+	    ;;
+	  *)
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	      case $host in
+	        osf3*)
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	        *)
+	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	      esac
+
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	      # Commands to make compiler produce verbose output that lists
+	      # what "hidden" libraries, object files and flags are used when
+	      # linking a shared library.
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+	    else
+	      # FIXME: insert proper C++ library support
+	      _LT_TAGVAR(ld_shlibs, $1)=no
+	    fi
+	    ;;
+        esac
+        ;;
+
+      psos*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      sunos4*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.x
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          lcc*)
+	    # Lucid
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
+
+      solaris*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	    case $host_os in
+	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	      *)
+		# The compiler driver will combine and reorder linker options,
+		# but understands `-z linker_flag'.
+	        # Supported since Solaris 2.6 (maybe 2.5.1?)
+		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	        ;;
+	    esac
+	    _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+	    output_verbose_link_cmd='echo'
+
+	    # Archives containing C++ object files must be created using
+	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	    ;;
+          gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	    # The C++ compiler must be used to create the archive.
+	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    # GNU C++ compiler with Solaris linker
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      else
+	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # platform.
+	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+	      fi
+
+	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	      case $host_os in
+		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+		*)
+		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  ;;
+	      esac
+	    fi
+	    ;;
+        esac
+        ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      case $cc_basename in
+        CC*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+      esac
+      ;;
+
+      sysv5* | sco3.2v5* | sco5v6*)
+	# Note: We can NOT use -z defs as we might desire, because we do not
+	# link with -lc, and that would cause any symbols used from libc to
+	# always be unresolved, which means just about no library would
+	# ever link correctly.  If we're not using GNU ld we use -z text
+	# though, which does catch some bad symbols but isn't as heavy-handed
+	# as -z defs.
+	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+	_LT_TAGVAR(link_all_deplibs, $1)=yes
+	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+	runpath_var='LD_RUN_PATH'
+
+	case $cc_basename in
+          CC*)
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	  *)
+	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	esac
+      ;;
+
+      tandem*)
+        case $cc_basename in
+          NCC*)
+	    # NonStop-UX NCC 3.20
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    _LT_TAGVAR(ld_shlibs, $1)=no
+	    ;;
+        esac
+        ;;
+
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+
+      *)
+        # FIXME: insert proper C++ library support
+        _LT_TAGVAR(ld_shlibs, $1)=no
+        ;;
+    esac
+
+    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+    _LT_TAGVAR(GCC, $1)="$GXX"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+_LT_EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	   else
+	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+	 else
+	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+	   _LT_TAGVAR(predep_objects, $1)="$p"
+	 else
+	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+	 fi
+       else
+	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+	   _LT_TAGVAR(postdep_objects, $1)="$p"
+	 else
+	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_TAGVAR(predep_objects,$1)=
+  _LT_TAGVAR(postdep_objects,$1)=
+  _LT_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+    [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+    [Dependencies to place before and after the objects being linked to
+    create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+    [The library search path used internally by the compiler when linking
+    a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_PROG_F77
+# ------------
+# Since AC_PROG_F77 is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_F77],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
+AC_PROG_F77
+if test -z "$F77" || test "X$F77" = "Xno"; then
+  _lt_disable_F77=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_F77
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_F77], [])
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_REQUIRE([_LT_PROG_F77])dnl
+AC_LANG_PUSH(Fortran 77)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${F77-"f77"}
+  compiler=$CC
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+  GCC=$G77
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$G77"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_PROG_FC
+# -----------
+# Since AC_PROG_FC is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_FC],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
+AC_PROG_FC
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_FC
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_FC], [])
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_REQUIRE([_LT_PROG_FC])dnl
+AC_LANG_PUSH(Fortran)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+  _LT_TAG_COMPILER
+
+  # save warnings/boilerplate of simple test code
+  _LT_COMPILER_BOILERPLATE
+  _LT_LINKER_BOILERPLATE
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${FC-"f95"}
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
+
+  _LT_TAGVAR(compiler, $1)=$CC
+  _LT_CC_BASENAME([$compiler])
+
+  if test -n "$compiler"; then
+    AC_MSG_CHECKING([if libtool supports shared libraries])
+    AC_MSG_RESULT([$can_build_shared])
+
+    AC_MSG_CHECKING([whether to build shared libraries])
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[[4-9]]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    AC_MSG_RESULT([$enable_shared])
+
+    AC_MSG_CHECKING([whether to build static libraries])
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    AC_MSG_RESULT([$enable_static])
+
+    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+    _LT_TAGVAR(LD, $1)="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    _LT_SYS_HIDDEN_LIBDEPS($1)
+    _LT_COMPILER_PIC($1)
+    _LT_COMPILER_C_O($1)
+    _LT_COMPILER_FILE_LOCKS($1)
+    _LT_LINKER_SHLIBS($1)
+    _LT_SYS_DYNAMIC_LINKER($1)
+    _LT_LINKER_HARDCODE_LIBPATH($1)
+
+    _LT_CONFIG($1)
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC="$lt_save_CC"
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+  :
+  _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+    [AC_CHECK_TOOL(GCJ, gcj,)
+      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+      AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_XSI_SHELLFNS
+# ---------------------
+# Bourne and XSI compatible variants of some useful shell functions.
+m4_defun([_LT_PROG_XSI_SHELLFNS],
+[case $xsi_shell in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+#             add APPEND to the result, otherwise set result
+#             to NONDIR_REPLACEMENT.
+#             value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+#             value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  case ${1} in
+    */*) func_dirname_result="${1%/*}${2}" ;;
+    *  ) func_dirname_result="${3}" ;;
+  esac
+  func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+  # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+  # positional parameters, so assign one to ordinary parameter first.
+  func_stripname_result=${3}
+  func_stripname_result=${func_stripname_result#"${1}"}
+  func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=${1%%=*}
+  func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  case ${1} in
+    *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+    *)    func_lo2o_result=${1} ;;
+  esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=$(( $[*] ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=${#1}
+}
+
+_LT_EOF
+    ;;
+  *) # Bourne compatible functions.
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+    func_dirname_result="${3}"
+  else
+    func_dirname_result="$func_dirname_result${2}"
+  fi
+}
+
+# func_basename file
+func_basename ()
+{
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+dnl func_dirname_and_basename
+dnl A portable version of this function is already defined in general.m4sh
+dnl so there is no need for it here.
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+  case ${2} in
+    .*) func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+    *)  func_stripname_result=`$ECHO "X${3}" \
+           | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+  esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+  func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+  func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+  func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+  func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+  func_arith_result=`expr "$[@]"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+  func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+  yes)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$[1]+=\$[2]"
+}
+_LT_EOF
+    ;;
+  *)
+    cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+  eval "$[1]=\$$[1]\$[2]"
+}
+
+_LT_EOF
+    ;;
+  esac
+])
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
new file mode 100644
index 0000000..34151a3
--- /dev/null
+++ b/m4/ltoptions.m4
@@ -0,0 +1,368 @@
+# Helper functions for option handling.                    -*- Autoconf -*-
+#
+#   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+#   Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+        _LT_MANGLE_DEFUN([$1], [$2]),
+    [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+		      [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME.  If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+    [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+  dnl
+  dnl Simply set some default values (i.e off) if boolean options were not
+  dnl specified:
+  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+  ])
+  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+  ])
+  dnl
+  dnl If no reference was made to various pairs of opposing options, then
+  dnl we run the default mode handler for the pair.  For example, if neither
+  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl archives by default:
+  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+  		   [_LT_ENABLE_FAST_INSTALL])
+  ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS],      [0], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+    _LT_DECL([build_libtool_libs], [enable_shared], [0],
+	[Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+    _LT_DECL([build_old_libs], [enable_static], [0],
+	[Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+	 [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+    [AS_HELP_STRING([--with-pic],
+	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [pic_mode="$withval"],
+    [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+		 [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+		 [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+		 [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+		 [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+		 [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
new file mode 100644
index 0000000..9000a05
--- /dev/null
+++ b/m4/ltsugar.m4
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+       [$#], [2], [[$2]],
+       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+       [$#], 1, [],
+       [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+	     [m4_foreach([_Lt_suffix],
+		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+		 [lt_append([$1], [$2], [$3])$4],
+		 [$5])],
+	  [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+	[$5],
+    [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+  [lt_join(m4_quote(m4_default([$4], [[, ]])),
+           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
new file mode 100644
index 0000000..f3c5309
--- /dev/null
+++ b/m4/ltversion.m4
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers			-*- Autoconf -*-
+#
+#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# Generated from ltversion.in.
+
+# serial 3017 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.2.6b])
+m4_define([LT_PACKAGE_REVISION], [1.3017])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.2.6b'
+macro_revision='1.3017'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
new file mode 100644
index 0000000..637bb20
--- /dev/null
+++ b/m4/lt~obsolete.m4
@@ -0,0 +1,92 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
+#
+#   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+#   Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 4 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else.  This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_RC],		[AC_DEFUN([AC_LIBTOOL_RC])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
diff --git a/m4/magics.m4 b/m4/magics.m4
new file mode 100644
index 0000000..e608758
--- /dev/null
+++ b/m4/magics.m4
@@ -0,0 +1,38 @@
+dnl
+dnl AM_PATH_MAGICS
+dnl
+AC_DEFUN([AM_PATH_MAGICS],
+[
+
+AC_ARG_WITH(magics,
+	AS_HELP_STRING([--with-magics],
+		[Prefix of Magics++ installation (optional, default is $MAGPLUS_HOME)]),
+	[
+	magics_config_prefix=$with_magics
+	],
+	[
+	if test x"${MAGPLUS_HOME}" != x; then
+		magics_config_prefix=$MAGPLUS_HOME
+	fi
+	]
+)
+
+if test x$magics_config_prefix != x ; then
+	MAGICS_CONFIG=$magics_config_prefix/bin/magics-config
+fi
+
+AC_PATH_PROG(MAGICS_CONFIG, magics-config, no)
+if test "$MAGICS_CONFIG" = "no" ; then
+	AC_MSG_ERROR([Cannot find 'magics-config'.])
+fi
+
+MAGICS_CFLAGS=`$MAGICS_CONFIG --cxxflags`
+MAGICS_LIBS=`$MAGICS_CONFIG --libs`
+MAGICS_PREFIX=`$MAGICS_CONFIG --prefix`
+AC_SUBST(MAGICS_CFLAGS)
+AC_SUBST(MAGICS_LIBS)
+AC_SUBST(MAGICS_PREFIX)
+
+magics_version=`$MAGICS_CONFIG --version`
+AC_MSG_RESULT([Using Magics++ version ${magics_version} from ${MAGICS_PREFIX}])
+])
diff --git a/magics-config.in b/magics-config.in
new file mode 100644
index 0000000..2172f29
--- /dev/null
+++ b/magics-config.in
@@ -0,0 +1,308 @@
+#!/bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+F77="@F77@"
+CC="@CC@"
+CXX="@CXX@"
+CXXFLAGS="@CXXFLAGS@" 
+AXX="@AXX@"
+SHLIB_EXT="@SHLIB_EXT@"
+FFLAGS="@FFLAGS@"
+CPPLIBS="@CPPLIBS@"
+py_dir="@PYTHON_SITE_PKG@"
+suffix=""
+
+#
+#  add --print-config
+#
+#
+# test 64bit C/C++ & intel compiler
+#
+#  configure.ac  -  deprecated string option for gcc !!!!
+#
+
+
+
+usage()
+{
+	cat <<EOF
+Usage: magics-config [OPTION] ...
+
+Uses by default version @MAGICS_PACKAGE_VERSION@@MAGICS_PACKAGE_VERSION_ADDENDUM@ of Magics.
+
+Generic options
+  --version     output Magics version information.
+  --help        display this help and exit.
+  --print-setup print how the environment can be set up
+
+Compilation support options
+  --cxxflags    print pre-processor and compiler flags for C/C++
+  --libs        print linking flags for C++
+  --clibs       print linking flags for C
+  --libdir      print directory where libraries are installed
+  --f90static   print library linking information (static)
+  --f90shared   print library linking information (shared)
+
+  --compile     compile simple Magics Fortran programs (default single precision!)  
+                  Example: magics-config --compile=wind.f
+  --compileC    compile simple Magics C programs  
+                  Example: magics-config --compileC=wind.c
+  --suffix      set suffix of Fortran or C code files
+
+  --double      include compiler option for fortran double precision 
+                  (default single - only for interface - internally only double is used)
+  --64bit       include fortran option for 64 bit
+
+C/C++ flags use shared libraries if possible, otherwise static libraries are used. '--double' has 
+NO effect on C/C++ programs.
+
+Install directories Magics was configured to
+  --prefix[=DIR]
+
+EOF
+	exit $1
+}
+
+if test -h ${prefix}; then
+	name=$(readlink -q "${prefix}")
+	if test -d ${name}; then
+		prefix=name
+	else
+		prefix=$(dirname "${prefix}")
+		prefix="${prefix}/${name}"
+	fi
+fi
+
+if test $# -eq 0; then
+	usage 1 1>&2
+fi
+
+while test $# -gt 0; do
+	case "$1" in
+		-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+		*) ;;
+	esac
+
+	case $1 in
+	--prefix=*)
+		prefix=$optarg
+		;;
+	--prefix)
+		echo_prefix=yes
+		;;
+	--version)
+		echo @MAGICS_PACKAGE_VERSION@
+		;;
+	--with-cairo)
+		echo "@cairo@"
+		;;
+	--with-python)
+		echo "@python@"
+		;;
+	--with-odb)
+		echo "@odb@"
+		;;
+	--with-netcdf)
+		echo "@netcdf@"
+		;;
+	--with-metview)
+		echo "@metview@"
+		;;
+	--with-qt)
+		echo "@qt@"
+		;;
+	--with-gd)
+		echo "@raster@"
+		;;
+	--with-bufr)
+		echo "@bufr@"
+		;;
+	--with-spot)
+		echo "@spot@"
+		;;
+	--help)
+		usage 0
+		;;
+	--print-setup)
+		echo ""
+		echo " For sh, ksh, dash and bash:"
+		echo ""
+		echo "   export MAGPLUS_HOME=${prefix}"
+		echo "   export PATH=${prefix}/bin:\$PATH"
+		echo "   export LD_LIBRARY_PATH=${libdir}:\$LD_LIBRARY_PATH"
+		echo "   export PYTHONPATH=\"${py_dir}:\${PYTHONPATH:-/usr/lib}\""
+		echo ""
+		echo " You might want add these lines to your login scripts (.profile, .kshrc or .bashrc)."
+		echo ""
+		;;
+	--cxxflags)
+		echo_cxxflags=yes
+		;;
+	--libs)
+		echo_libs=yes
+		;;
+	--libdir)
+		echo "${libdir}"
+		;;
+	--clibs)
+		echo_libs=yes
+		echo_clibs=yes
+		;;
+	--f90static)
+		echo_static=yes
+		echo_shared=no
+		;;
+	--f90shared)
+		echo_shared=yes
+		echo_static=no
+		;;
+	--suffix=*)
+		suffix=$optarg
+		;;
+	--compile=*)
+		compile=yes
+		f77_file=$optarg
+		;;
+	--compileC=*)
+		compileC=yes
+		c_file=$optarg
+		;;
+	--double)
+		double=yes
+		case "${F77}" in
+			gfortran )
+				FXX="-fdefault-real-8 ${FXX}"
+				;;
+			g77 )
+				echo ""#"NO DOUBLE FLAG in g77"
+				;;
+			# Intel compiler
+			# Portland pgf90
+			# IBM fortran compiler
+			ifc | ifort | pgf90 | pgf77 | xlf | xlf90 | xlf_r | xlf90_r )
+				FXX="-r8 ${FXX}"
+				;;
+		esac
+		;;
+	--odb)
+		odb=no
+		;;
+	--64bit)
+		amd64=yes
+		case "${F77}" in
+			ifc | ifort | gfortran )
+				FXX="-m64 ${FXX}"
+				;;
+			g77 )
+				echo ""#"NO DOUBLE FLAG in g77"
+				;;
+			# Portland pgf90
+			pgf90 | pgf77 )
+				FXX="-tp amd64 ${FXX}"
+				;;
+		esac
+
+		case "${CC}" in
+			icc | icpc | gcc | g++ )
+				CXX="-m64 ${CXX}"
+				;;
+			pgc | pgcpp )
+				CXX="-tp amd64 ${CXX}"
+				;;
+		esac
+		;; 
+	*)
+		usage 1 1>&2
+		;;
+	esac
+	shift
+done
+
+if test "$echo_prefix" = "yes"; then
+	echo $prefix
+fi
+
+if test "$echo_cxxflags" = "yes"; then
+	if test "$includedir" != "/usr/include" ; then
+		my_cxxflags="-I${includedir}"
+	fi
+	echo "${AXX} ${my_cxxflags} @MAGICS_3RDPARTY_INCLUDE@"
+fi
+
+if test "$echo_libs" = "yes"; then
+if test -f ${libdir}/libMagPlus.${SHLIB_EXT} ; then
+		my_libs="-L${libdir} -lMagPlus"
+	else
+		my_libs="${libdir}/libMagPlus.a"
+	fi
+
+	my_libs="${my_libs} @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ @FLIBS@"
+
+	if test "$echo_clibs" = "yes"; then
+		my_libs="${my_libs} $CPPLIBS"
+	fi
+
+	echo "${my_libs}"
+fi
+
+if test "$double" = "yes"; then
+	precision="${FXX} ${libdir}/libMagPlusDouble.a"
+else
+	precision="${FXX} ${libdir}/libMagPlusSingle.a"
+fi
+
+
+if test "$echo_static" = "yes"; then
+	if test -f ${libdir}/libMagPlus.a ; then
+	  static="${precision} ${libdir}/libMagPlus.a -L${libdir} @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ $CPPLIBS"
+	  echo ${static}
+	else
+	  echo "magics-config: NO STATIC LIBRARY available"
+	fi
+fi
+
+if test "$echo_shared" = "yes"; then
+	if test -f ${libdir}/libMagPlus.${SHLIB_EXT} ; then
+	  shared="${precision} -L${libdir} -lMagPlus @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ $CPPLIBS"
+	  echo ${shared}
+	else
+	  echo "magics-config: NO SHARED LIBRARY"
+	fi
+fi
+
+if test "$echo_flibs" = "yes"; then
+	echo @FLIBS@
+fi
+
+if test "$compile" = "yes"; then
+	out=""
+	if test "${suffix}x" = "x"; then
+	   suffix="f"
+	fi
+
+	name="`basename $f77_file .${suffix}`"
+
+	if test ${name} != ${f77_file} ; then
+	      out="-o $name "              ### avoid overriding source file
+	fi
+	echo "$F77 ${out}$f77_file ${FFLAGS} ${precision} -L${libdir} -lMagPlus @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ $CPPLIBS"
+	$F77 ${out}$f77_file ${FFLAGS} ${precision} -L${libdir} -Wl,-rpath,${libdir} -lMagPlus @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ $CPPLIBS
+fi
+
+if test "$compileC" = "yes"; then
+	out=""
+	if test "${suffix}x" = "x"; then
+	   suffix="c"
+	fi
+
+	name="`basename $c_file .${suffix}`"
+
+	if test ${name} != ${c_file} ; then
+	      out="-o $name "              ### avoid overriding source file
+	fi
+	echo "$CC ${out}$c_file ${CFLAGS} -L${libdir} -lMagPlus @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ $CPPLIBS @FLIBS@"
+	$CC ${out}$c_file ${CFLAGS} -I${includedir} -L${libdir} -Wl,-rpath,${libdir} -lMagPlus @LDFLAGS@ @MAGICS_3RDPARTY_LIBS@ $CPPLIBS @FLIBS@
+fi
diff --git a/python/Magics/Magics.i b/python/Magics/Magics.i
new file mode 100755
index 0000000..57c10bd
--- /dev/null
+++ b/python/Magics/Magics.i
@@ -0,0 +1,66 @@
+%module (docstring="This is a Python interface to Magics++") Magics
+
+%{
+#define SWIG_FILE_WITH_INIT
+/* Includes the header in the wrapper code */
+#include "Magics_interface.cc"
+%}
+
+// This tells SWIG to treat char ** as a special case
+//
+//  see http://www.swig.org/Doc1.3/Python.html#Python_nn59
+//
+%typemap(in) (const char **data, const int dim)
+{
+  /* Check if is a list */
+  if (PyList_Check($input))
+  {
+    int size = PyList_Size($input);
+    int i = 0;
+    $1 = (char **) malloc((size+1)*sizeof(char *));
+    $2 = size;
+    for (i = 0; i < size; i++) {
+      PyObject *o = PyList_GetItem($input,i);
+      if (PyString_Check(o))
+	$1[i] = PyString_AsString(PyList_GetItem($input,i));
+      else {
+	PyErr_SetString(PyExc_TypeError,"list must contain strings");
+	free($1);
+	return NULL;
+      }
+    }
+    $1[i] = 0;
+  }
+  else
+  {
+    PyErr_SetString(PyExc_TypeError,"not a list");
+    return NULL;
+  }
+}
+
+// This cleans up the char ** array we malloced before the function call
+%typemap(freearg) (const char **data, int dim)
+{
+  free((char *) $1);
+}
+
+
+/* 
+  N U M E R I C A L   A R R A Y S 
+*/
+%include "numpy.i"
+%init %{
+        import_array();
+%}
+
+%apply(double* IN_ARRAY1, int DIM1) {(double *data, int dim)}
+%apply(int* IN_ARRAY1, int DIM1) {(int *data, int dim)}
+
+%apply(int* IN_ARRAY2, int DIM1, int DIM2) {(int *data, const int dim1, const int dim2)}
+%apply(int* IN_ARRAY2, int DIM1, int DIM2, int DIM3) {(int *data, const int dim1, const int dim2, const int dim3)}
+
+%apply(double* IN_ARRAY2, int DIM1, int DIM2) {(double *data, const int dim1, const int dim2)}
+%apply(double* IN_ARRAY2, int DIM1, int DIM2, int DIM3) {(double *data, const int dim1, const int dim2, const int dim3)}
+
+/* Parse the header file to generate wrappers */
+%include "Magics_interface.cc"
diff --git a/python/Magics/Magics_interface.cc b/python/Magics/Magics_interface.cc
new file mode 100755
index 0000000..eb23e9a
--- /dev/null
+++ b/python/Magics/Magics_interface.cc
@@ -0,0 +1,217 @@
+#include <magics_api.h>
+
+void init() {
+  mag_open ();
+}
+
+void finalize() {
+  mag_close();
+}
+
+void coast() {
+  mag_coast();
+} 
+
+void grib() {
+  mag_grib();
+}
+
+void test() {
+  mag_test();
+}
+void legend() {
+  mag_legend();
+}
+
+void odb() {
+  mag_odb();
+}
+
+void netcdf() {
+  mag_netcdf();
+}
+
+void cont() {
+  mag_cont();
+}
+void minput() {
+  mag_input();
+}
+void obs() {
+  mag_obs();
+}
+
+void raw() {
+  mag_raw();
+}
+
+void image() {
+  mag_image();
+}
+
+void plot() {
+  mag_plot();
+}
+
+void text() {
+  mag_text();
+}
+
+void wind() {
+  mag_wind();
+}
+void line() {
+  mag_line();
+}
+
+void symb() {
+  mag_symb();
+}
+
+void boxplot() {
+  mag_boxplot();
+} 
+void taylor() {
+  mag_taylor();
+} 
+
+void mimport() {
+  mag_import();
+}
+
+void wrepjson() {
+  mag_wrepjson();
+}
+
+void epsgraph() {
+  mag_epsgraph();
+}
+
+void epscloud() {
+  mag_epscloud();
+}
+
+void epswind() {
+  mag_epswind();
+}
+void epswave() {
+  mag_epswave();
+}
+
+void epsbar() {
+  mag_epsbar();
+}
+void epsshading() {
+  mag_epsshading();
+ }
+
+void mapgen() {
+  mag_mapgen();
+}
+
+void new_page(const char* page)
+{
+  mag_new(page);
+}
+
+void reset(const char* name)
+{
+  mag_reset(name);
+}
+
+void setc(const char* name, const char* value)
+{
+  mag_setc(name, value);
+}
+
+void setr(const char* name, const double value)
+{
+  // std::cout << "setr "<<name<<" = "<<value<< std::endl;
+  mag_setr(name, value);
+}
+
+void seti(const char* name, const int value)
+{
+  mag_seti(name, value);
+}
+
+double enqr(const char* name)
+{
+  double value = 0.;
+  mag_enqr (name, &value);
+  return value;
+}
+
+int enqi(const char* name)
+{
+  int value = 0;
+  mag_enqi ( name, &value);
+  return value;
+}
+
+char* enqc (const char* name)
+{
+  char *value = 0;
+  mag_enqc (name, value);
+  // std::cout << "nnn" << name<< "  "<< value << std::endl;
+  return value;
+}
+
+void set1r(const char* name,double *data, const int dim)
+{
+  mag_set1r(name, data, dim);
+}
+
+void set2r(const char* name, double *data, const int dim1, const int dim2)
+{
+ mag_set2r(name, data, dim2, dim1);
+}
+
+void set3r(const char* name, double *data, const int dim1, const int dim2, const int dim3)
+{
+ mag_set3r(name, data, dim1, dim2, dim3);
+}
+
+void set1i(const char* name, int* data, const int dim)
+{
+ mag_set1i(name, data, dim);
+}
+
+void set2i(const char* name, int *data, const int dim1, const int dim2)
+{
+ mag_set2i(name, data, dim1, dim2);
+}
+
+void set3i(const char* name, int *data, const int dim1, const int dim2, const int dim3)
+{
+ mag_set3i(name, data, dim1, dim2, dim3);
+}
+
+void set1c(const char* name, const char** data, const int dim)
+{
+ mag_set1c(name, data, dim);
+}
+
+void pie() {
+ mag_pie();
+}
+
+void graph() {
+  mag_graph();
+}
+
+void axis() {
+  mag_axis();
+}
+
+void geo() {
+  mag_geo();
+}
+
+void eps() {
+  mag_eps();
+}
+
+void info() {
+  mag_info();
+}
diff --git a/python/Magics/Makefile.am b/python/Magics/Makefile.am
new file mode 100644
index 0000000..b5a611a
--- /dev/null
+++ b/python/Magics/Makefile.am
@@ -0,0 +1,35 @@
+# Extra files to go into the distribution
+EXTRA_DIST = setup.py.in \
+	Magics.i numpy.i \
+	Magics_interface.cc \
+	macro.py metgram.py
+
+
+if MAGICS_PYTHON
+
+noinst_SCRIPTS = setup.py
+
+CLEANFILES = $(noinst_SCRIPTS) \
+	Magics.cc \
+	__init__.py \
+	_Magics.so
+
+# What we want to be installed
+pdir = $(libdir)/python$(PYTHON_VERSION)/site-packages/Magics
+p_DATA = \
+	_Magics.so \
+	__init__.py macro.py metgram.py numpy.i
+
+clean-local:
+	-rm -rf build 
+
+# Main call for the compilation of the Python module
+_Magics.so: setup.py 
+	$(PYTHON) setup.py build_ext --inplace
+	cp Magics.py __init__.py
+
+endif
+
+# There is an inherit dependency, we have to disable parallel builds for these
+# files otherwise 'make -j2' or similar is likely to hit the race condition.
+.NOTPARALLEL:
diff --git a/python/Magics/Makefile.in b/python/Magics/Makefile.in
new file mode 100644
index 0000000..4972b3e
--- /dev/null
+++ b/python/Magics/Makefile.in
@@ -0,0 +1,525 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = python/Magics
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/setup.py.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES = setup.py
+CONFIG_CLEAN_VPATH_FILES =
+SCRIPTS = $(noinst_SCRIPTS)
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pdir)"
+DATA = $(p_DATA)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+# Extra files to go into the distribution
+EXTRA_DIST = setup.py.in \
+	Magics.i numpy.i \
+	Magics_interface.cc \
+	macro.py metgram.py
+
+ at MAGICS_PYTHON_TRUE@noinst_SCRIPTS = setup.py
+ at MAGICS_PYTHON_TRUE@CLEANFILES = $(noinst_SCRIPTS) \
+ at MAGICS_PYTHON_TRUE@	Magics.cc \
+ at MAGICS_PYTHON_TRUE@	__init__.py \
+ at MAGICS_PYTHON_TRUE@	_Magics.so
+
+
+# What we want to be installed
+ at MAGICS_PYTHON_TRUE@pdir = $(libdir)/python$(PYTHON_VERSION)/site-packages/Magics
+ at MAGICS_PYTHON_TRUE@p_DATA = \
+ at MAGICS_PYTHON_TRUE@	_Magics.so \
+ at MAGICS_PYTHON_TRUE@	__init__.py macro.py metgram.py numpy.i
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu python/Magics/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu python/Magics/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+setup.py: $(top_builddir)/config.status $(srcdir)/setup.py.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-pDATA: $(p_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(pdir)" || $(MKDIR_P) "$(DESTDIR)$(pdir)"
+	@list='$(p_DATA)'; test -n "$(pdir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(pdir)" || exit $$?; \
+	done
+
+uninstall-pDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(p_DATA)'; test -n "$(pdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(pdir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(pdir)" && rm -f $$files
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS) $(DATA)
+installdirs:
+	for dir in "$(DESTDIR)$(pdir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+ at MAGICS_PYTHON_FALSE@clean-local:
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	clean-local distclean distclean-generic distclean-libtool \
+	distdir dvi dvi-am html html-am info info-am install \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pDATA install-pdf install-pdf-am install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+	ps ps-am uninstall uninstall-am uninstall-pDATA
+
+
+ at MAGICS_PYTHON_TRUE@clean-local:
+ at MAGICS_PYTHON_TRUE@	-rm -rf build 
+
+# Main call for the compilation of the Python module
+ at MAGICS_PYTHON_TRUE@_Magics.so: setup.py 
+ at MAGICS_PYTHON_TRUE@	$(PYTHON) setup.py build_ext --inplace
+ at MAGICS_PYTHON_TRUE@	cp Magics.py __init__.py
+
+# There is an inherit dependency, we have to disable parallel builds for these
+# files otherwise 'make -j2' or similar is likely to hit the race condition.
+.NOTPARALLEL:
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/python/Magics/macro.py b/python/Magics/macro.py
new file mode 100644
index 0000000..ff3add7
--- /dev/null
+++ b/python/Magics/macro.py
@@ -0,0 +1,438 @@
+import os
+import Magics
+import numpy
+
+class Context(object):
+	def __init__(self):
+		self.tmp = []
+		pass
+
+global context
+context  = Context()
+
+actions={
+	"mobs": "pobs",
+	"mcoast": "pcoast",
+	"pcoast": "pcoast",
+	"mtext": "ptext",
+	"ptext": "ptext",
+	"psymb": "psymb",
+	"msymb": "psymb",
+	"pcont": "pcont",
+	"mcont": "pcont",
+	"pgeo": "pgeo",
+	"mgeo": "pgeo",
+	"mlegend": "",
+	"plegend": "",
+	"mgrib": "pgrib",
+	"pgrib": "pgrib",
+	"mwind": "pwind",
+	"pwind": "pwind",
+	"mgraph": "pgraph",
+	"pgraph": "pgraph",
+	"maxis": "paxis",
+	"paxis": "paxis",
+	"minput": "pinput",
+	"pinput": "pinput"
+	}
+
+
+
+
+class Action(object):
+	def __init__(self, verb, action, args):
+		self.verb = verb
+		self.action = action
+		self.args = args
+
+	def __repr__(self):
+		x = ""
+		for key in self.args.keys():
+			x = x + " %s = '%s'\n" % (key, self.args[key])
+		return x
+
+	def inspect(self):
+		print self
+
+	def quote(self, v):
+		return "\"" + v + "\""
+
+	def tohtml(self, file):
+		sep=""
+		val="%s("%self.verb
+
+		for key in self.args.keys():
+			if isinstance(self.args[key], str):
+				if key == 'odb_data':
+					Magics.setc('odb_filename', self.args[key])
+				else:
+					val+= '%s%s = "%s"'%(sep, key, self.args[key])
+			elif isinstance(self.args[key], int):
+				val +=  '%s%s = %d'%(sep, key, self.args[key])
+			elif isinstance(self.args[key], float):
+				val += '%s%s = %0.2f'%(sep, key, self.args[key])
+			elif isinstance(self.args[key], list) :
+				if isinstance (self.args[key][0], str):
+				   vval = ""
+				   vsep = ""
+				   for v in self.args[key]:
+				   		vval += vsep + self.quote(v)
+				   		vsep = ",\n\t\t\t"
+				   vval += ""
+				   val+= '%s%s = [%s]'%(sep, key, vval)
+				elif isinstance(self.args[key][0], int):
+				   vval = ""
+				   vsep = ""
+				   for v in self.args[key]:
+				   		vval += vsep + ("%d"%v)
+				   		vsep = ", "
+				   vval += ""
+				   val+= '%s%s = %s'%(sep, key, vval)
+				elif isinstance(self.args[key][0], float):
+				   vval = ""
+				   vsep = ""
+				   for v in self.args[key]:
+				   		vval += vsep + ("%0.2f"%v)
+				   		vsep = ", \n\t\t\t"
+				   vval += ""
+				   val+= '%s%s = [%s]'%(sep, key, vval)
+			elif isinstance(self.args[key], numpy.ndarray) :
+				type = self.args[key].dtype
+				dim  = len(self.args[key].shape)
+				if isinstance(self.args[key][0], int):
+					if (dim == 2) :
+				   		print "pset2i" 
+					else :
+				   		print "pset1i" 
+				elif ( type == 'float64' or type == 'float32') :
+					if (dim == 2) :
+				   		print "pset2r" 
+					else :
+				   		vval = ""
+				   		vsep = ""
+				   		for v in self.args[key]:
+				   			vval += vsep + ("%0.2f"%v)
+				   			vsep = ", "
+				   		vval += ""
+				   		val+= '%s%s = [%s]'%(sep, key, vval)
+				else :
+					print "type???->", key
+			sep=",\n\t"
+				
+		print >>file, val + ")\n"
+
+	def tomv4(self, file):
+		sep="\t"
+		val="%s,\n"%self.verb.upper()
+
+		for key in self.args.keys():
+			if isinstance(self.args[key], str):
+				if key == 'odb_data':
+					Magics.setc('odb_filename', self.args[key])
+				else:
+					val+= '%s%s = %s'%(sep, key.upper(), self.args[key].upper())
+			elif isinstance(self.args[key], int):
+				val +=  '%s%s = %d'%(sep, key.upper(), self.args[key])
+			elif isinstance(self.args[key], float):
+				val += '%s%s = %0.2f'%(sep, key.upper(), self.args[key])
+			elif isinstance(self.args[key], list) :
+				if isinstance (self.args[key][0], str):
+				   vval = "["
+				   vsep = ""
+				   for v in self.args[key]:
+				   		vval += vsep + v
+				   		vsep = ", "
+				   vval += "]"
+				   val+= '%s%s = %s'%(sep, key.upper(), vval)
+				elif isinstance(self.args[key][0], int):
+				   print "pset1i"
+				elif isinstance(self.args[key][0], float):
+				   print "pset1r" 
+			elif isinstance(self.args[key], numpy.ndarray) :
+				type = self.args[key].dtype
+				dim  = len(self.args[key].shape)
+				if isinstance(self.args[key][0], int):
+					if (dim == 2) :
+				   		print "pset2i" 
+					else :
+				   		print "pset1i" 
+				elif ( type == 'float64' or type == 'float32') :
+					if (dim == 2) :
+				   		print "pset2r" 
+					else :
+				   		vval = "["
+				   		vsep = ""
+				   		for v in self.args[key]:
+				   				vval += vsep + ("%0.2f"%v)
+				   				vsep = ", "
+				   		vval += "]"
+				   		val+= '%s%s = %s'%(sep, key.upper(), vval)
+				   		
+				else :
+					print "type???->", key
+			sep=",\n\t"
+				
+		print >> file, val + "\n"
+
+
+
+
+
+	def tofortran(self, f):
+		if self.action == Magics.new_page :
+			print >> f, '\tcall pnew("page")'
+			return
+		for key in self.args.keys():
+			if isinstance(self.args[key], str):
+				if key == 'odb_data':
+					Magics.setc('odb_filename', self.args[key])
+				else:
+					print >> f, '\tcall psetc("%s", "%s")'%(key, self.args[key])
+			elif isinstance(self.args[key], int):
+				print >>f, '\tcall pseti("%s", %d)'%(key, self.args[key])
+			elif isinstance(self.args[key], float):
+				print >> f, '\tcall psetr("%s", %0.2f)'%(key, self.args[key])
+			elif isinstance(self.args[key], list) :
+				if isinstance (self.args[key][0], str):
+				   nb = 0
+				   for v in self.args[key]:
+				   		nb = max(nb, len(v))
+				   	
+				   val = "(/"
+				   sep = ""
+				   newline = 70
+				   for v in self.args[key]:
+				   		val += sep + self.quote(v.ljust(nb))
+						sep = ", "
+				   		if len(val) > newline  :
+							sep = ",&\n\t\t"
+							newline = newline + 70
+				   val += "/)"
+				   print >>f, '\tcall pset1c("%s", %s, %d)'%(key, val, len(self.args[key]))
+				elif isinstance(self.args[key][0], int):
+				   print "pset1i"
+				elif isinstance(self.args[key][0], float):
+				   	val = "(/"
+				   	sep = ""
+				   	for v in self.args[key]:
+				   		val += sep + ("%0.2f" % v)
+				   		sep = ", "
+				   	val += "/)"
+				   	print >>f, '\tcall pset1r("%s", %s, %d)'%(key, val, len(self.args[key]))
+			elif isinstance(self.args[key], numpy.ndarray) :
+				type = self.args[key].dtype
+				dim  = len(self.args[key].shape)
+				if isinstance(self.args[key][0], int):
+					if (dim == 2) :
+				   		print "pset2i" 
+					else :
+				   		print "pset1i" 
+				elif ( type == 'float64' or type == 'float32') :
+					if (dim == 2) :
+				   		print "pset2r" 
+					else :
+				   		val = "(/"
+				   		sep = ""
+				   		for v in self.args[key]:
+				   			val += sep + ("%0.2f" % v)
+				   			sep = ", "
+				   		val += "/)"
+				   		print >>f, '\tcall pset1r("%s", %s, %d)'%(key, val, len(self.args[key]))
+				elif isinstance(self.args[key][0], int):
+				   		print "pset1r" 
+				else :
+					print "type???->", key
+
+		if self.action != None and actions[self.verb] != "":
+			print >>f, "\tcall %s\n"%actions[self.verb] 
+			for key in self.args.keys():
+				print >>f, "\tcall preset('%s')"%key 
+			print >>f, ""
+
+		else:
+			print >>f, ""
+
+
+
+	def execute(self):
+		for key in self.args.keys():
+			if isinstance(self.args[key], str):
+				if key == 'odb_data':
+					Magics.setc('odb_filename', self.args[key])
+				else:
+					Magics.setc(key, self.args[key])
+			elif isinstance(self.args[key], int):
+				Magics.seti(key, self.args[key])
+			elif isinstance(self.args[key], float):
+				Magics.setr(key, self.args[key])
+			elif isinstance(self.args[key], list) :
+				if isinstance(self.args[key][0], str):
+				   Magics.set1c(key, self.args[key])
+				elif isinstance(self.args[key][0], int):
+				   Magics.set1i(key, numpy.array(self.args[key], dtype='i'))
+				elif isinstance(self.args[key][0], float):
+				   Magics.set1r(key, numpy.array(self.args[key]))
+			elif isinstance(self.args[key], numpy.ndarray) :
+				type = self.args[key].dtype
+				dim  = len(self.args[key].shape)
+				if isinstance(self.args[key][0], int):
+					if (dim == 2) :
+						Magics.set2i(key, self.args[key].copy())
+					else :
+						Magics.set1i(key, self.args[key].copy())
+				elif ( type == 'float64' or type == 'float32') :
+					if (dim == 2) :
+						Magics.set2r(key, self.args[key].copy())
+					else :
+						Magics.set1r(key, self.args[key].copy())
+				else :
+					print "type???->", key
+
+			else:
+				self.args[key].execute(key)
+
+		if self.action != None :
+			if self.action != Magics.new_page :
+				self.action()
+				if self.action != Magics.obs :
+					for key in self.args.keys():
+						Magics.reset(key)
+			else:
+				self.action("page")
+
+def make_action(verb, action):
+	def f(_m = None,**kw):
+		args = {}
+		if _m is not None: 
+			args.update(_m)
+		args.update(kw)
+		return Action(verb, action, args)
+	return f
+
+mcoast = make_action("mcoast", Magics.coast)
+pcoast = make_action("pcoast", Magics.coast)
+maxis = make_action("maxis", Magics.axis)
+paxis = make_action("paxis", Magics.axis)
+mcont = make_action("mcont", Magics.cont)
+pcont = make_action("pcont", Magics.cont)
+msymb = make_action("msymb", Magics.symb)
+psymb = make_action("psymb", Magics.symb)
+pimport = make_action("pimport", Magics.mimport)
+mimport = make_action("mimport", Magics.mimport)
+mtaylor = make_action("mtaylor", Magics.taylor)
+mgeo = make_action("mgeo", Magics.geo)
+pgeo = make_action("pgeo", Magics.geo)
+pgrib = make_action("pgrib", Magics.grib)
+mgrib = make_action("mgrib", Magics.grib)
+pmapgen = make_action("pmapgen", Magics.mapgen)
+mmapgen = make_action("mmapgen", Magics.mapgen)
+pnetcdf = make_action("pnetcdf", Magics.netcdf)
+mnetcdf = make_action("mnetcdf", Magics.netcdf)
+odb_geopoints = make_action("odb_geopoints", Magics.odb)
+odb_geovectors = make_action("odb_geovectors", Magics.odb)
+odb_xypoints = make_action("odb_xypoints", Magics.odb)
+odb_xyvectors = make_action("odb_xyvectors", Magics.odb)
+pmap = make_action("pmap", None)
+mmap = make_action("mmap", None)
+plegend = make_action("plegend", Magics.legend)
+mlegend = make_action("mlegend", Magics.legend)
+ptext = make_action("mtext", Magics.text)
+mtext = make_action("ptext", Magics.text)
+output = make_action("output", None)
+pwind = make_action("pwind", Magics.wind)
+mwind = make_action("mwind", Magics.wind)
+pline = make_action("pline", Magics.line)
+mline = make_action("mline", Magics.line)
+pgraph = make_action("pgraph", Magics.graph)
+mgraph = make_action("mgraph", Magics.graph)
+pboxplot = make_action("pboxplot", Magics.boxplot)
+mboxplot = make_action("mboxplot", Magics.boxplot)
+pobs = make_action("pobs", Magics.obs)
+mobs = make_action("mobs", Magics.obs)
+page = make_action("page", Magics.new_page)
+pinput = make_action("pinput", Magics.minput)
+minput = make_action("minput", Magics.minput)
+
+
+mwrepjson = make_action("mwrepjson", Magics.wrepjson)
+mepscloud = make_action("mepscloud", Magics.epscloud)
+mepsbar = make_action("mepsbar", Magics.epsbar)
+mepswind = make_action("mepswind", Magics.epswind)
+mepswave = make_action("mepswave", Magics.epswave)
+mepsshading = make_action("mepsshading", Magics.epsshading)
+mepsgraph = make_action("mepsgraph", Magics.epsgraph)
+
+
+
+def examine(*args):
+	for n in args:
+		try :
+			n.inspect()
+		except:
+			break
+
+
+def plot(*args):
+	Magics.init()
+	for n in args:
+		if isinstance(n, list):
+			for nn in n:
+				nn.execute()
+		else:
+				n.execute()
+	
+	#Collect the drivers!
+	Magics.finalize()
+	for f in context.tmp:
+		if os.path.exists(f):
+			os.remove(f)
+
+
+def tofortran(file, *args):
+	f = open(file+".f90",'w')
+	print >>f, "\tprogram magics\n"
+	print >>f, "\tcall popen\n"
+	for n in args:
+		n.tofortran(f)
+	print >>f, "\tcall pclose\n"
+	print >>f, "\tend"
+
+
+def tohtml(file, *args):
+	f = open(file+".html",'w')
+	print >>f, "<html>"
+	for n in args:
+		n.tohtml(f)
+	print >>f, "</html>"
+
+def tomv4(file, *args):
+	f = open(file+".mv4",'w')
+	for n in args:
+		n.tomv4(f)
+
+class  odb_filter(object):
+	def __init__(self, _m = None,**kw):
+		args = {}
+		self.verb = "odbfilter"
+		if _m is not None:
+			args.update(_m)
+		self.args = args
+	def execute(self, key):
+		file = "data%d" % numpy.random.randint(1,1000)
+		odb = "%s.odb" % file 
+		context.tmp.append(odb)
+		cmd = "odbsql -q \"" + self.args["query"] + "\" -i " + self.args["path"] + " -f newodb -o " + odb
+		print cmd 
+		if (os.system(cmd)) :
+			print "Error in filtering ODB data... Aborting"
+			os.abort();
+		Magics.setc('odb_filename', odb)
+	def inspect(self):
+		cmd = "odbsql -q \"" + self.args["query"] + "\" -i " + self.args["path"] + " -o data.ascii"
+		if (os.system(cmd)) :
+			print "Error in filtering ODB data... Aborting"
+			os.abort();
+		cmd =  os.environ['ODB_REPORTER'] + " %s" % "data.ascii"
+		if (os.system(cmd)) :
+			print "Error in viewing ODB data... Aborting"
+			os.abort();
diff --git a/python/Magics/metgram.py b/python/Magics/metgram.py
new file mode 100644
index 0000000..56a27cc
--- /dev/null
+++ b/python/Magics/metgram.py
@@ -0,0 +1,322 @@
+import simplejson
+import tempfile
+import os
+
+
+magics = {}
+magics["info"] = "on"
+
+magics["format"] = "a4"
+magics["page"] = []
+magics["orientation"] = "portrait"
+magics["version"] = "3.0"
+last = {}
+
+ps = {}
+ps["format"] = "ps"
+
+drivers=[ps]
+magics["drivers"] = drivers
+
+
+definition = []
+definition.append( {
+	"id" : "haxis",
+	"class" : "horizontal_axis",
+	"axis_type" : "date",
+	"axis_tick_label": "off",
+    "axis_tick_colour": "kelly_green" ,
+    "axis_line_colour":"kelly_green" ,
+    "axis_grid":"on",
+    "axis_grid_line_style":"dash",
+    "axis_grid_colour":"kelly_green"
+})
+
+definition.append({
+	"class" : "horizontal_axis",
+    "id" : "haxis_last",
+    "axis_type" : "date",
+    "axis_tick_label": "on",
+    "axis_tick_colour": "kelly_green" ,
+    "axis_line_colour":"kelly_green" ,
+    "axis_grid":"on",
+    "axis_grid_line_style":"dash",
+    "axis_grid_colour":"kelly_green",
+    "axis_date_type":"days",
+    "axis_minor_tick":"on",
+    "axis_days_label":"both",
+    "axis_days_label_colour":"navy",
+    "axis_days_label_height":"0.35",
+    "axis_months_label_colour":"navy",
+    "axis_months_label_height":"0.3",
+    "axis_years_label_colour":"navy",
+    "axis_years_label_height":"0.3"
+})
+
+
+
+definition.append({
+	"class": "vertical_axis",
+	"id" : "vaxis",
+	"axis_line":"on", 
+    "axis_grid":"on", 
+    "axis_line_colour":"kelly_green" ,
+    "axis_tick_label_colour":"kelly_green",
+    "axis_label_font":"sansserif",
+    "axis_grid_line_style":"dash",
+    "axis_grid_colour":"kelly_green",
+    "axis_tick_colour":"kelly_green"
+})
+magics["definition"] = definition
+pages = []
+
+header = {  "height" : "12%" }
+def page():
+	page = { "height" : "15%",
+	"map" : {
+		"cartesian":
+        {
+          "x_date": { "automatic":"on" },
+          "y_regular": { "automatic":"on" }
+        },
+		"text" : {
+			"left": "0%",
+			"height": "10%",
+			"bottom": "90%",
+			"text_justification": "left",
+			"text_font_size": "0.4",
+			"text_font_style": "bold",
+			"text_font": "sansserif",
+			"text_colour": "navy",
+			"text_border": "off"
+		},
+		"horizontal_axis": { "use_id" : "haxis" },
+		"vertical_axis": { "use_id" : "vaxis" }
+
+		
+	}
+
+	}
+	return page
+
+class humidity(object):
+	
+	def execute(self):
+		humi =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"13003",
+                "epsbufr_parameter_title":"850 hPa Relative Humidity  (%)",
+                "use_id":"station"
+            },
+            "metgraph": { "curve": { } }
+        }
+
+		map = page()
+		humi["epsbufr"]["epsbufr_information"] = magics["info"]
+		magics["info"] = "off"
+		map["map"]["cartesian"] = {
+          "x_date": { "automatic":"on" },
+          "y_regular": { "y_min":"0", "y_max":"100" }
+		  }
+		map["map"]["plot"] = humi
+		magics["page"].append(map)
+		return map
+
+class msl(object):
+	
+	def execute(self):
+		msl =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"10051",
+                "epsbufr_parameter_title":"MSL Pressure (hPa)",
+				"epsbufr_parameter_scaling_factor": "0.01",
+                "use_id":"station"
+            },
+            "metgraph": { "curve": { } }
+        }
+
+		map = page()
+		msl["epsbufr"]["epsbufr_information"] = magics["info"]
+		magics["info"] = "off"
+		map["map"]["plot"] = msl
+		magics["page"].append(map)
+		return map
+
+
+class cloud(object):
+	
+	def execute(self):
+		cloud =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"20010",
+                "epsbufr_parameter_title":"Cloud Amount (%)",
+                "use_id":"station"
+            },
+            "metgraph": { "bar": { } }
+        }
+
+		map = page()
+		cloud["epsbufr"]["epsbufr_information"] = magics["info"]
+		magics["info"] = "off"
+		map["map"]["cartesian"] = {
+          "x_date": { "automatic":"on" },
+          "y_regular": { "y_min":"0", "y_max":"100" }
+		  }
+		map["map"]["plot"] = cloud
+		magics["page"].append(map)
+		return map
+
+class precip(object):
+	
+	def execute(self):
+		precip =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"13011",
+                "epsbufr_parameter_title":"Precipitation",
+                "epsbufr_accumulated_parameter":"on",
+                "use_id":"station"
+            },
+            "metgraph": { "bar": { } }
+        }
+		precip["epsbufr"]["epsbufr_information"] = magics["info"]
+		magics["info"] = "off"
+		map = page()
+		map["map"]["plot"] = precip
+		magics["page"].append(map)
+		return map
+
+class wind(object):
+	
+	def execute(self):
+		wind =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"11003",
+                "epsbufr_parameter_2_descriptor":"11004",
+                "epsbufr_parameter_title":"10m Wind (m/s)",
+                "use_id":"station"
+            },
+            "metgraph": { "flags": { } }
+        }
+		wind["epsbufr"]["epsbufr_information"] = magics["info"]
+		magics["info"] = "off"
+		map = page()
+		map["map"]["plot"] = wind
+		map["height"] = "10%"
+		map["map"]["height"] = "80%"
+		map["map"]["text"]["bottom"] = "70%"
+		map["map"]["vertical_axis"]["axis_tick_label"] = "off"
+		map["map"]["vertical_axis"]["axis_grid"] = "off"
+		map["map"]["vertical_axis"]["axis_tick"] = "off"
+		map["map"]["cartesian"] = {
+          "x_date": { "automatic":"on" },
+          "y_regular": { "y_min":"-1", "y_max":"1" }
+		}
+		magics["page"].append(map)
+		return map
+
+class tempe(object):
+	
+	def execute(self):
+		t850 =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"12001",
+                "epsbufr_parameter_title":"Temperature (C)",
+				"epsbufr_parameter_offset_factor": "-273.15",
+                "use_id":"station"
+            },
+            "metgraph": { 
+				"metgram_plot_style":"curve",
+				"metgram_curve_colour":"blue"
+				}
+        }
+		t850["epsbufr"]["epsbufr_information"] = magics["info"]
+		tempe =  {
+            "epsbufr":
+            {
+                "epsbufr_parameter_descriptor":"12004",
+                "epsbufr_short_title":"off",
+				"epsbufr_information":"off",
+				"epsbufr_parameter_offset_factor": "-273.15",
+                "use_id":"station"
+            },
+            "metgraph": { 
+				"metgram_plot_style":"curve",
+				"metgram_curve_colour":"red"
+				}
+        }
+		t850["epsbufr"]["epsbufr_information"] = magics["info"]
+		magics["info"] = "off"
+		map = page()
+		map["map"]["plot"] = [ t850, tempe]
+		magics["page"].append(map)
+		return map
+
+
+
+
+
+class station(object):
+	def __init__(self, args):	
+		self.definition = args
+		self.definition["id"]= "station"
+		self.definition["class"]= "epsbufr"
+	def execute(self):
+		magics["definition"].append(self.definition)
+		return page()
+
+	
+class ps(object):
+	def __init__(self, args):	
+		self.definition = args
+		self.definition["format"]= "ps"
+	def execute(self):
+		if (magics["drivers"] == None) :
+			magics["drivers"]=[]
+		magics["drivers"].append(self.definition)
+		return page()
+
+	
+
+
+
+
+def metgram(*args):
+
+	magics["page"].append(header)
+	nb = len(args)
+	i = 0
+	haxis="haxis"
+	for n in args:
+		map = n.execute()
+		i += 1
+		if (i == nb) :
+			haxis="haxis_last"
+		map["map"]["horizontal_axis"]["use_id"] = haxis
+		
+			
+	s = simplejson.dumps(magics, indent=4 * ' ')
+	f = tempfile.NamedTemporaryFile()
+	f.write(s)
+	f.flush()
+
+	cmd = "magjson %s" % (f.name)
+
+	error = os.system(cmd)
+	if (error != 0):
+		print "Error found"
+	f.close
+	
+
+cloud = cloud()
+humidity = humidity()
+precip = precip()
+tempe = tempe()
+msl = msl()
+wind = wind()
+
diff --git a/python/Magics/numpy.i b/python/Magics/numpy.i
new file mode 100644
index 0000000..e3ff236
--- /dev/null
+++ b/python/Magics/numpy.i
@@ -0,0 +1,1634 @@
+/* -*- C -*-  (not really, but good for syntax highlighting) */
+#ifdef SWIGPYTHON
+
+%{
+#ifndef SWIG_FILE_WITH_INIT
+#  define NO_IMPORT_ARRAY
+#endif
+#include "stdio.h"
+#include <numpy/arrayobject.h>
+%}
+
+/**********************************************************************/
+
+%fragment("NumPy_Backward_Compatibility", "header")
+{
+/* Support older NumPy data type names
+*/
+%#if NDARRAY_VERSION < 0x01000000
+%#define NPY_BOOL          PyArray_BOOL
+%#define NPY_BYTE          PyArray_BYTE
+%#define NPY_UBYTE         PyArray_UBYTE
+%#define NPY_SHORT         PyArray_SHORT
+%#define NPY_USHORT        PyArray_USHORT
+%#define NPY_INT           PyArray_INT
+%#define NPY_UINT          PyArray_UINT
+%#define NPY_LONG          PyArray_LONG
+%#define NPY_ULONG         PyArray_ULONG
+%#define NPY_LONGLONG      PyArray_LONGLONG
+%#define NPY_ULONGLONG     PyArray_ULONGLONG
+%#define NPY_FLOAT         PyArray_FLOAT
+%#define NPY_DOUBLE        PyArray_DOUBLE
+%#define NPY_LONGDOUBLE    PyArray_LONGDOUBLE
+%#define NPY_CFLOAT        PyArray_CFLOAT
+%#define NPY_CDOUBLE       PyArray_CDOUBLE
+%#define NPY_CLONGDOUBLE   PyArray_CLONGDOUBLE
+%#define NPY_OBJECT        PyArray_OBJECT
+%#define NPY_STRING        PyArray_STRING
+%#define NPY_UNICODE       PyArray_UNICODE
+%#define NPY_VOID          PyArray_VOID
+%#define NPY_NTYPES        PyArray_NTYPES
+%#define NPY_NOTYPE        PyArray_NOTYPE
+%#define NPY_CHAR          PyArray_CHAR
+%#define NPY_USERDEF       PyArray_USERDEF
+%#define npy_intp          intp
+
+%#define NPY_MAX_BYTE      MAX_BYTE
+%#define NPY_MIN_BYTE      MIN_BYTE
+%#define NPY_MAX_UBYTE     MAX_UBYTE
+%#define NPY_MAX_SHORT     MAX_SHORT
+%#define NPY_MIN_SHORT     MIN_SHORT
+%#define NPY_MAX_USHORT    MAX_USHORT
+%#define NPY_MAX_INT       MAX_INT
+%#define NPY_MIN_INT       MIN_INT
+%#define NPY_MAX_UINT      MAX_UINT
+%#define NPY_MAX_LONG      MAX_LONG
+%#define NPY_MIN_LONG      MIN_LONG
+%#define NPY_MAX_ULONG     MAX_ULONG
+%#define NPY_MAX_LONGLONG  MAX_LONGLONG
+%#define NPY_MIN_LONGLONG  MIN_LONGLONG
+%#define NPY_MAX_ULONGLONG MAX_ULONGLONG
+%#define NPY_MAX_INTP      MAX_INTP
+%#define NPY_MIN_INTP      MIN_INTP
+
+%#define NPY_FARRAY        FARRAY
+%#define NPY_F_CONTIGUOUS  F_CONTIGUOUS
+%#endif
+}
+
+/**********************************************************************/
+
+/* The following code originally appeared in
+ * enthought/kiva/agg/src/numeric.i written by Eric Jones.  It was
+ * translated from C++ to C by John Hunter.  Bill Spotz has modified
+ * it to fix some minor bugs, upgrade from Numeric to numpy (all
+ * versions), add some comments and functionality, and convert from
+ * direct code insertion to SWIG fragments.
+ */
+
+%fragment("NumPy_Macros", "header")
+{
+/* Macros to extract array attributes.
+ */
+%#define is_array(a)            ((a) && PyArray_Check((PyArrayObject *)a))
+%#define array_type(a)          (int)(PyArray_TYPE(a))
+%#define array_numdims(a)       (((PyArrayObject *)a)->nd)
+%#define array_dimensions(a)    (((PyArrayObject *)a)->dimensions)
+%#define array_size(a,i)        (((PyArrayObject *)a)->dimensions[i])
+%#define array_data(a)          (((PyArrayObject *)a)->data)
+%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a))
+%#define array_is_native(a)     (PyArray_ISNOTSWAPPED(a))
+%#define array_is_fortran(a)    (PyArray_ISFORTRAN(a))
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Utilities", "header")
+{
+  /* Given a PyObject, return a string describing its type.
+   */
+  const char* pytype_string(PyObject* py_obj) {
+    if (py_obj == NULL          ) return "C NULL value";
+    if (py_obj == Py_None       ) return "Python None" ;
+    if (PyCallable_Check(py_obj)) return "callable"    ;
+    if (PyString_Check(  py_obj)) return "string"      ;
+    if (PyInt_Check(     py_obj)) return "int"         ;
+    if (PyFloat_Check(   py_obj)) return "float"       ;
+    if (PyDict_Check(    py_obj)) return "dict"        ;
+    if (PyList_Check(    py_obj)) return "list"        ;
+    if (PyTuple_Check(   py_obj)) return "tuple"       ;
+    if (PyFile_Check(    py_obj)) return "file"        ;
+    if (PyModule_Check(  py_obj)) return "module"      ;
+    if (PyInstance_Check(py_obj)) return "instance"    ;
+
+    return "unkown type";
+  }
+
+  /* Given a NumPy typecode, return a string describing the type.
+   */
+  const char* typecode_string(int typecode) {
+    static const char* type_names[25] = {"bool", "byte", "unsigned byte",
+                                   "short", "unsigned short", "int",
+                                   "unsigned int", "long", "unsigned long",
+                                   "long long", "unsigned long long",
+                                   "float", "double", "long double",
+                                   "complex float", "complex double",
+                                   "complex long double", "object",
+                                   "string", "unicode", "void", "ntypes",
+                                   "notype", "char", "unknown"};
+    return typecode < 24 ? type_names[typecode] : type_names[24];
+  }
+
+  /* Make sure input has correct numpy type.  Allow character and byte
+   * to match.  Also allow int and long to match.  This is deprecated.
+   * You should use PyArray_EquivTypenums() instead.
+   */
+  int type_match(int actual_type, int desired_type) {
+    return PyArray_EquivTypenums(actual_type, desired_type);
+  }
+}
+
+/**********************************************************************/
+
+%fragment("NumPy_Object_to_Array", "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros",
+          fragment="NumPy_Utilities")
+{
+  /* Given a PyObject pointer, cast it to a PyArrayObject pointer if
+   * legal.  If not, set the python error string appropriately and
+   * return NULL.
+   */
+  PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode)
+  {
+    PyArrayObject* ary = NULL;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input), typecode)))
+    {
+      ary = (PyArrayObject*) input;
+    }
+    else if is_array(input)
+    {
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type  = typecode_string(array_type(input));
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  Array of type '%s' given",
+                   desired_type, actual_type);
+      ary = NULL;
+    }
+    else
+    {
+      const char * desired_type = typecode_string(typecode);
+      const char * actual_type  = pytype_string(input);
+      PyErr_Format(PyExc_TypeError,
+                   "Array of type '%s' required.  A '%s' was given",
+                   desired_type, actual_type);
+      ary = NULL;
+    }
+    return ary;
+  }
+
+  /* Convert the given PyObject to a NumPy array with the given
+   * typecode.  On success, return a valid PyArrayObject* with the
+   * correct type.  On failure, the python error string will be set and
+   * the routine returns NULL.
+   */
+  PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode,
+                                               int* is_new_object)
+  {
+    PyArrayObject* ary = NULL;
+    PyObject* py_obj;
+    if (is_array(input) && (typecode == NPY_NOTYPE ||
+                            PyArray_EquivTypenums(array_type(input),typecode)))
+    {
+      ary = (PyArrayObject*) input;
+      *is_new_object = 0;
+    }
+    else
+    {
+      py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_DEFAULT);
+      /* If NULL, PyArray_FromObject will have set python error value.*/
+      ary = (PyArrayObject*) py_obj;
+      *is_new_object = 1;
+    }
+    return ary;
+  }
+
+  /* Given a PyArrayObject, check to see if it is contiguous.  If so,
+   * return the input pointer and flag it as not a new object.  If it is
+   * not contiguous, create a new PyArrayObject using the original data,
+   * flag it as a new object and return the pointer.
+   */
+  PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object,
+                                 int min_dims, int max_dims)
+  {
+    PyArrayObject* result;
+    if (array_is_contiguous(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary,
+                                                             array_type(ary),
+                                                             min_dims,
+                                                             max_dims);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Given a PyArrayObject, check to see if it is Fortran-contiguous.
+   * If so, return the input pointer, but do not flag it as not a new
+   * object.  If it is not Fortran-contiguous, create a new
+   * PyArrayObject using the original data, flag it as a new object
+   * and return the pointer.
+   */
+  PyArrayObject* make_fortran(PyArrayObject* ary, int* is_new_object,
+                              int min_dims, int max_dims)
+  {
+    PyArrayObject* result;
+    if (array_is_fortran(ary))
+    {
+      result = ary;
+      *is_new_object = 0;
+    }
+    else
+    {
+      Py_INCREF(ary->descr);
+      result = (PyArrayObject*) PyArray_FromArray(ary, ary->descr, NPY_FORTRAN);
+      *is_new_object = 1;
+    }
+    return result;
+  }
+
+  /* Convert a given PyObject to a contiguous PyArrayObject of the
+   * specified type.  If the input object is not a contiguous
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input,
+                                                          int typecode,
+                                                          int* is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_contiguous(ary1, &is_new2, 0, 0);
+      if ( is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+  /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the
+   * specified type.  If the input object is not a Fortran-ordered
+   * PyArrayObject, a new one will be created and the new object flag
+   * will be set.
+   */
+  PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input,
+                                                       int typecode,
+                                                       int* is_new_object)
+  {
+    int is_new1 = 0;
+    int is_new2 = 0;
+    PyArrayObject* ary2;
+    PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode,
+                                                        &is_new1);
+    if (ary1)
+    {
+      ary2 = make_fortran(ary1, &is_new2, 0, 0);
+      if (is_new1 && is_new2)
+      {
+        Py_DECREF(ary1);
+      }
+      ary1 = ary2;
+    }
+    *is_new_object = is_new1 || is_new2;
+    return ary1;
+  }
+
+} /* end fragment */
+
+
+/**********************************************************************/
+
+%fragment("NumPy_Array_Requirements", "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros")
+{
+  /* Test whether a python object is contiguous.  If array is
+   * contiguous, return 1.  Otherwise, set the python error string and
+   * return 0.
+   */
+  int require_contiguous(PyArrayObject* ary)
+  {
+    int contiguous = 1;
+    if (!array_is_contiguous(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must be contiguous.  A non-contiguous array was given");
+      contiguous = 0;
+    }
+    return contiguous;
+  }
+
+  /* Require that a numpy array is not byte-swapped.  If the array is
+   * not byte-swapped, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_native(PyArrayObject* ary)
+  {
+    int native = 1;
+    if (!array_is_native(ary))
+    {
+      PyErr_SetString(PyExc_TypeError,
+                      "Array must have native byteorder.  "
+                      "A byte-swapped array was given");
+      native = 0;
+    }
+    return native;
+  }
+
+  /* Require the given PyArrayObject to have a specified number of
+   * dimensions.  If the array has the specified number of dimensions,
+   * return 1.  Otherwise, set the python error string and return 0.
+   */
+  int require_dimensions(PyArrayObject* ary, int exact_dimensions)
+  {
+    int success = 1;
+    if (array_numdims(ary) != exact_dimensions)
+    {
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %d dimensions.  Given array has %d dimensions",
+                   exact_dimensions, array_numdims(ary));
+      success = 0;
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have one of a list of specified
+   * number of dimensions.  If the array has one of the specified number
+   * of dimensions, return 1.  Otherwise, set the python error string
+   * and return 0.
+   */
+  int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n)
+  {
+    int success = 0;
+    int i;
+    char dims_str[255] = "";
+    char s[255];
+    for (i = 0; i < n && !success; i++)
+    {
+      if (array_numdims(ary) == exact_dimensions[i])
+      {
+        success = 1;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n-1; i++)
+      {
+        sprintf(s, "%d, ", exact_dimensions[i]);
+        strcat(dims_str,s);
+      }
+      sprintf(s, " or %d", exact_dimensions[n-1]);
+      strcat(dims_str,s);
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have %s dimensions.  Given array has %d dimensions",
+                   dims_str, array_numdims(ary));
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to have a specified shape.  If the
+   * array has the specified shape, return 1.  Otherwise, set the python
+   * error string and return 0.
+   */
+  int require_size(PyArrayObject* ary, npy_intp* size, int n)
+  {
+    int i;
+    int success = 1;
+    int len;
+    char desired_dims[255] = "[";
+    char s[255];
+    char actual_dims[255] = "[";
+    for(i=0; i < n;i++)
+    {
+      if (size[i] != -1 &&  size[i] != array_size(ary,i))
+      {
+        success = 0;
+      }
+    }
+    if (!success)
+    {
+      for (i = 0; i < n; i++)
+      {
+        if (size[i] == -1)
+        {
+          sprintf(s, "*,");
+        }
+        else
+        {
+          sprintf(s, "%ld,", (long int)size[i]);
+        }
+        strcat(desired_dims,s);
+      }
+      len = strlen(desired_dims);
+      desired_dims[len-1] = ']';
+      for (i = 0; i < n; i++)
+      {
+        sprintf(s, "%ld,", (long int)array_size(ary,i));
+        strcat(actual_dims,s);
+      }
+      len = strlen(actual_dims);
+      actual_dims[len-1] = ']';
+      PyErr_Format(PyExc_TypeError,
+                   "Array must have shape of %s.  Given array has shape of %s",
+                   desired_dims, actual_dims);
+    }
+    return success;
+  }
+
+  /* Require the given PyArrayObject to to be FORTRAN ordered.  If the
+   * the PyArrayObject is already FORTRAN ordered, do nothing.  Else,
+   * set the FORTRAN ordering flag and recompute the strides.
+   */
+  int require_fortran(PyArrayObject* ary)
+  {
+    int success = 1;
+    int nd = array_numdims(ary);
+    int i;
+    if (array_is_fortran(ary)) return success;
+    /* Set the FORTRAN ordered flag */
+    ary->flags = NPY_FARRAY;
+    /* Recompute the strides */
+    ary->strides[0] = ary->strides[nd-1];
+    for (i=1; i < nd; ++i)
+      ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1);
+    return success;
+  }
+}
+
+/* Combine all NumPy fragments into one for convenience */
+%fragment("NumPy_Fragments", "header",
+          fragment="NumPy_Backward_Compatibility",
+          fragment="NumPy_Macros",
+          fragment="NumPy_Utilities",
+          fragment="NumPy_Object_to_Array",
+          fragment="NumPy_Array_Requirements") { }
+
+/* End John Hunter translation (with modifications by Bill Spotz)
+ */
+
+/* %numpy_typemaps() macro
+ *
+ * This macro defines a family of 41 typemaps that allow C arguments
+ * of the form
+ *
+ *     (DATA_TYPE IN_ARRAY1[ANY])
+ *     (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ *     (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ *
+ *     (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ *     (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ *     (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ *
+ *     (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ *     (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+ *     (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+ *
+ *     (DATA_TYPE INPLACE_ARRAY1[ANY])
+ *     (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ *     (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ *
+ *     (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ *     (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ *     (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ *
+ *     (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ *     (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+ *     (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+ *     (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+ *
+ *     (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ *     (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ *     (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ *
+ *     (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ *
+ *     (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *
+ *     (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ *     (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ *
+ *     (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ *     (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ *
+ *     (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ *     (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+ *     (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ *
+ * where "DATA_TYPE" is any type supported by the NumPy module, and
+ * "DIM_TYPE" is any int-like type suitable for specifying dimensions.
+ * The difference between "ARRAY" typemaps and "FARRAY" typemaps is
+ * that the "FARRAY" typemaps expect FORTRAN ordering of
+ * multidimensional arrays.  In python, the dimensions will not need
+ * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1"
+ * typemaps).  The IN_ARRAYs can be a numpy array or any sequence that
+ * can be converted to a numpy array of the specified type.  The
+ * INPLACE_ARRAYs must be numpy arrays of the appropriate type.  The
+ * ARGOUT_ARRAYs will be returned as new numpy arrays of the
+ * appropriate type.
+ *
+ * These typemaps can be applied to existing functions using the
+ * %apply directive.  For example:
+ *
+ *     %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)};
+ *     double prod(double* series, int length);
+ *
+ *     %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2)
+ *           {(int rows, int cols, double* matrix        )};
+ *     void floor(int rows, int cols, double* matrix, double f);
+ *
+ *     %apply (double IN_ARRAY3[ANY][ANY][ANY])
+ *           {(double tensor[2][2][2]         )};
+ *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *           {(double low[2][2][2]                )};
+ *     %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY])
+ *           {(double upp[2][2][2]                )};
+ *     void luSplit(double tensor[2][2][2],
+ *                  double low[2][2][2],
+ *                  double upp[2][2][2]    );
+ *
+ * or directly with
+ *
+ *     double prod(double* IN_ARRAY1, int DIM1);
+ *
+ *     void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f);
+ *
+ *     void luSplit(double IN_ARRAY3[ANY][ANY][ANY],
+ *                  double ARGOUT_ARRAY3[ANY][ANY][ANY],
+ *                  double ARGOUT_ARRAY3[ANY][ANY][ANY]);
+ */
+
+%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE)
+
+/************************/
+/* Input Array Typemaps */
+/************************/
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY1[ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY1[ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = { $1_dim0 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY1[ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = { -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[1] = {-1};
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 1) ||
+      !require_size(array, size, 1)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { $1_dim0, $1_dim1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY2[ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[2] = { -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 2) ||
+      !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(freearg)
+  (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY])
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* IN_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE,
+                                                &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+%typemap(freearg)
+  (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* IN_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+  $1 = is_array($input) || PySequence_Check($input);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+  (PyArrayObject* array=NULL, int is_new_object=0)
+{
+  npy_intp size[3] = { -1, -1, -1 };
+  array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE,
+                                                   &is_new_object);
+  if (!array || !require_dimensions(array, 3) ||
+      !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+%typemap(freearg)
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3)
+{
+  if (is_new_object$argnum && array$argnum)
+    { Py_DECREF(array$argnum); }
+}
+
+/***************************/
+/* In-Place Array Typemaps */
+/***************************/
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY1[ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY1[ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[1] = { $1_dim0 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
+  (PyArrayObject* array=NULL, int i=1)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = 1;
+  for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
+  (PyArrayObject* array=NULL, int i=0)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,1) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = 1;
+  for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i);
+  $2 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[2] = { $1_dim0, $1_dim1 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,2) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY])
+  (PyArrayObject* array=NULL)
+{
+  npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) ||
+      !require_contiguous(array) || !require_native(array)) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+      !require_native(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_ARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+      || !require_native(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+
+/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2,
+ *                    DIM_TYPE DIM3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array) ||
+      !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+  $2 = (DIM_TYPE) array_size(array,0);
+  $3 = (DIM_TYPE) array_size(array,1);
+  $4 = (DIM_TYPE) array_size(array,2);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3,
+ *                    DATA_TYPE* INPLACE_FARRAY3)
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY,
+           fragment="NumPy_Macros")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+{
+  $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),
+                                                 DATA_TYPECODE);
+}
+%typemap(in,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3)
+  (PyArrayObject* array=NULL)
+{
+  array = obj_to_array_no_conversion($input, DATA_TYPECODE);
+  if (!array || !require_dimensions(array,3) || !require_contiguous(array)
+      || !require_native(array) || !require_fortran(array)) SWIG_fail;
+  $1 = (DIM_TYPE) array_size(array,0);
+  $2 = (DIM_TYPE) array_size(array,1);
+  $3 = (DIM_TYPE) array_size(array,2);
+  $4 = (DATA_TYPE*) array_data(array);
+}
+
+/*************************/
+/* Argout Array Typemaps */
+/*************************/
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY1[ANY])
+  (PyObject * array = NULL)
+{
+  npy_intp dims[1] = { $1_dim0 };
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY1[ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+ */
+%typemap(in,numinputs=1,
+         fragment="NumPy_Fragments")
+  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+  (PyObject * array = NULL)
+{
+  npy_intp dims[1];
+  if (!PyInt_Check($input))
+  {
+    const char* typestring = pytype_string($input);
+    PyErr_Format(PyExc_TypeError,
+                 "Int dimension expected.  '%s' given.",
+                 typestring);
+    SWIG_fail;
+  }
+  $2 = (DIM_TYPE) PyInt_AsLong($input);
+  dims[0] = (npy_intp) $2;
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1)
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+ */
+%typemap(in,numinputs=1,
+         fragment="NumPy_Fragments")
+  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+  (PyObject * array = NULL)
+{
+  npy_intp dims[1];
+  if (!PyInt_Check($input))
+  {
+    const char* typestring = pytype_string($input);
+    PyErr_Format(PyExc_TypeError,
+                 "Int dimension expected.  '%s' given.",
+                 typestring);
+    SWIG_fail;
+  }
+  $1 = (DIM_TYPE) PyInt_AsLong($input);
+  dims[0] = (npy_intp) $1;
+  array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $2 = (DATA_TYPE*) array_data(array);
+}
+%typemap(argout)
+  (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1)
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+  (PyObject * array = NULL)
+{
+  npy_intp dims[2] = { $1_dim0, $1_dim1 };
+  array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+ */
+%typemap(in,numinputs=0,
+         fragment="NumPy_Backward_Compatibility,NumPy_Macros")
+  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+  (PyObject * array = NULL)
+{
+  npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 };
+  array = PyArray_SimpleNew(3, dims, DATA_TYPECODE);
+  if (!array) SWIG_fail;
+  $1 = ($1_ltype) array_data(array);
+}
+%typemap(argout)
+  (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY])
+{
+  $result = SWIG_Python_AppendOutput($result,array$argnum);
+}
+
+/*****************************/
+/* Argoutview Array Typemaps */
+/*****************************/
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1    )
+  (DATA_TYPE*  data_temp        , DIM_TYPE  dim_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1)
+{
+  npy_intp dims[1] = { *$2 };
+  PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1    , DATA_TYPE** ARGOUTVIEW_ARRAY1)
+  (DIM_TYPE  dim_temp, DATA_TYPE*  data_temp        )
+{
+  $1 = &dim_temp;
+  $2 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1)
+{
+  npy_intp dims[1] = { *$1 };
+  PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp        , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_ARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp        )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1     , DIM_TYPE* DIM2     )
+  (DATA_TYPE*  data_temp        , DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2)
+{
+  npy_intp dims[2] = { *$2, *$3 };
+  PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || !require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1     , DIM_TYPE* DIM2     , DATA_TYPE** ARGOUTVIEW_FARRAY2)
+  (DIM_TYPE  dim1_temp, DIM_TYPE  dim2_temp, DATA_TYPE*  data_temp        )
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2)
+{
+  npy_intp dims[2] = { *$1, *$2 };
+  PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || !require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+  (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEW_ARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+  if (!array) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,array);
+}
+
+/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2,
+                      DIM_TYPE* DIM3)
+ */
+%typemap(in,numinputs=0)
+  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+  (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp)
+{
+  $1 = &data_temp;
+  $2 = &dim1_temp;
+  $3 = &dim2_temp;
+  $4 = &dim3_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3)
+{
+  npy_intp dims[3] = { *$2, *$3, *$4 };
+  PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3,
+                      DATA_TYPE** ARGOUTVIEW_FARRAY3)
+ */
+%typemap(in,numinputs=0)
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+  (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp)
+{
+  $1 = &dim1_temp;
+  $2 = &dim2_temp;
+  $3 = &dim3_temp;
+  $4 = &data_temp;
+}
+%typemap(argout,
+         fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements")
+  (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3)
+{
+  npy_intp dims[3] = { *$1, *$2, *$3 };
+  PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3));
+  PyArrayObject * array = (PyArrayObject*) obj;
+  if (!array || require_fortran(array)) SWIG_fail;
+  $result = SWIG_Python_AppendOutput($result,obj);
+}
+
+%enddef    /* %numpy_typemaps() macro */
+/* *************************************************************** */
+
+/* Concrete instances of the %numpy_typemaps() macro: Each invocation
+ * below applies all of the typemaps above to the specified data type.
+ */
+%numpy_typemaps(signed char       , NPY_BYTE     , int)
+%numpy_typemaps(unsigned char     , NPY_UBYTE    , int)
+%numpy_typemaps(short             , NPY_SHORT    , int)
+%numpy_typemaps(unsigned short    , NPY_USHORT   , int)
+%numpy_typemaps(int               , NPY_INT      , int)
+%numpy_typemaps(unsigned int      , NPY_UINT     , int)
+%numpy_typemaps(long              , NPY_LONG     , int)
+%numpy_typemaps(unsigned long     , NPY_ULONG    , int)
+%numpy_typemaps(long long         , NPY_LONGLONG , int)
+%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int)
+%numpy_typemaps(float             , NPY_FLOAT    , int)
+%numpy_typemaps(double            , NPY_DOUBLE   , int)
+
+/* ***************************************************************
+ * The follow macro expansion does not work, because C++ bool is 4
+ * bytes and NPY_BOOL is 1 byte
+ *
+ *    %numpy_typemaps(bool, NPY_BOOL, int)
+ */
+
+/* ***************************************************************
+ * On my Mac, I get the following warning for this macro expansion:
+ * 'swig/python detected a memory leak of type 'long double *', no destructor found.'
+ *
+ *    %numpy_typemaps(long double, NPY_LONGDOUBLE, int)
+ */
+
+/* ***************************************************************
+ * Swig complains about a syntax error for the following macro
+ * expansions:
+ *
+ *    %numpy_typemaps(complex float,  NPY_CFLOAT , int)
+ *
+ *    %numpy_typemaps(complex double, NPY_CDOUBLE, int)
+ *
+ *    %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int)
+ */
+
+#endif /* SWIGPYTHON */
diff --git a/python/Magics/setup.py.in b/python/Magics/setup.py.in
new file mode 100644
index 0000000..8f68404
--- /dev/null
+++ b/python/Magics/setup.py.in
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+from distutils.core import setup, Extension
+import os,sys
+
+lib_list=["MagPlus"]
+libpath_list=["../../src/.libs"]
+runpath_list=["@prefix@/lib","@ODB_PATH@/lib"]
+
+if "@odb@" != "no":
+    lib_list.append('Odb')
+    lib_list.append('Ec')
+    if "@ODB_PATH@":
+       libpath_list.append("@ODB_PATH@/lib")
+
+if "@bufr@" != "no":
+    if "@EMOS_LIB_NAME@":
+       lib_list.append("@EMOS_LIB_NAME@")
+    if "@FLIB@":
+       flibs=['@FLIB@']
+       lib_list += flibs
+    if "@FORTRAN_LIB_PATH@":
+       libpath_list.append("@FORTRAN_LIB_PATH@")
+       runpath_list.append("@FORTRAN_LIB_PATH@")
+
+attdict = dict(
+   sources = ['Magics.i'],
+   swig_opts = ['-c++','-module', 'Magics'],
+   include_dirs = ['.', '../../src/common'],
+   library_dirs = libpath_list + ["%s/lib" % sys.prefix],
+   libraries = lib_list + ["m"],
+   runtime_library_dirs = runpath_list,
+   extra_objects = [],
+)
+
+add_attribute = lambda **args: [list.append(attdict[key],value) for key,value in args.items()]
+
+build_dir = '../'
+
+import glob
+ofiles=glob.glob("%s*.o" % build_dir)
+print "files are %s" % ofiles
+add_attribute(
+    include_dirs = os.path.join(build_dir,'src')
+)
+
+lib_dict = {
+    'grib_api': '@GRIBAPI_ROOT@',
+}
+
+for with_lib in lib_dict:
+    if with_lib:
+        lib_dir = lib_dict[with_lib]
+        if lib_dir and lib_dir != 'system':
+            add_attribute(
+            include_dirs = os.path.join(lib_dir,'include'),
+            library_dirs = os.path.join(lib_dir,'lib')
+        )
+    add_attribute(libraries = with_lib)
+
+    import numpy
+    # Obtain the numpy include directory.  This logic works across numpy versions.
+    try:
+        numpy_include = numpy.get_include()
+    except AttributeError:
+        numpy_include = numpy.get_numpy_include()
+
+    add_attribute(
+        include_dirs = numpy_include,
+    )
+
+api_module = Extension('_Magics',**attdict)
+
+setup (name = '@PACKAGE_NAME@',
+       version = '@MAGICS_PACKAGE_VERSION@',
+       author      = 'ECMWF',
+       description = """Magics++ Python interface""",
+       ext_modules = [api_module],
+       py_modules = ['Magics.macro','Magics.metgram'],
+       package_dir={'Magics': ''},
+       packages=['Magics'],
+      )
diff --git a/rpms/Magics.spec.in b/rpms/Magics.spec.in
new file mode 100644
index 0000000..ae008ac
--- /dev/null
+++ b/rpms/Magics.spec.in
@@ -0,0 +1,183 @@
+Name: @MAGICS_PACKAGE_NAME@
+Version: @MAGICS_PACKAGE_VERSION@
+Release: 1.0
+Summary: Library and tools to visualize meteorological data and statistics
+URL: http://www.ecmwf.int/products/data/software/magics++.html
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
+Source0: %{name}-%{version}.tar.gz
+License: Apache V2.0
+# Copyright 2011 ECMWF
+Group: Productivity/Scientific/Other
+
+Requires: emos
+Requires: grib_api >= 1.9.8
+Requires: cairo    >= 1.4.0
+
+##################################################
+
+#!BuildIgnore: post-build-checks
+BuildRequires: gcc-c++
+BuildRequires: swig
+BuildRequires: perl-XML-Parser
+BuildRequires: cairo-devel
+BuildRequires: pango-devel
+BuildRequires: grib_api-devel
+BuildRequires: libqt4-devel
+BuildRequires: emos
+BuildRequires: boost-devel
+
+%if 0%{?suse_version} > 1120
+BuildRequires: libQtWebKit-devel
+BuildRequires: libqt4-devel
+Requires: netcdf libnetcdf4
+Requires: python
+BuildRequires: python-devel python-numpy-devel swig
+BuildRequires: netcdf libnetcdf4 libnetcdf-devel
+%endif
+
+%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel_version}
+
+BuildRequires: pkgconfig gcc-gfortran
+BuildRequires: expat expat-devel
+
+%else
+BuildRequires: gd gd-devel
+Requires: gd-devel
+BuildRequires: gcc-fortran libexpat-devel
+%if 0%{?suse_version} > 1100
+BuildRequires: libjasper-devel
+%endif
+%endif
+
+
+################################################
+
+%description
+Runtime files for Magics - The library and tools to visualize meteorological data and statistics
+
+%package devel
+Summary: Developing package for Magics
+Group: Development/Libraries/C and C++
+Requires: %{name} grib_api-devel
+Obsoletes: %{name}++-devel
+%description devel
+Header and library files for Magics - The library and tools to visualize meteorological data and statistics
+
+%if 0%{?suse_version} > 1100
+
+%package metview-devel
+Summary: Magics package for Metview 4
+Group: Development/Libraries/C and C++
+Requires: %{name}-devel
+%description metview-devel
+Magics header and library to compile Metview
+
+%endif
+
+Authors:
+--------
+  (ECMWF Meteorological Visualisation Section)
+  Sylvie Lamy-Thepaut
+  Stephan Siemen
+  Fernando Ii
+  Iain Russell
+  Sandor Kertesz
+  Peter Bispham
+
+##############################################
+
+%prep
+%setup -q
+%build
+%if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel_version}
+  ./configure --prefix=/usr --libdir=%_libdir --disable-netcdf --enable-bufr --enable-json --disable-jasper --disable-raster
+%else
+%if 0%{?suse_version} > 1120
+  ./configure --prefix=/usr --libdir=%_libdir --enable-netcdf --enable-bufr --enable-json --enable-metview --enable-python CXXFLAGS="-O2 -mtune=generic" 
+%else
+  ./configure --prefix=/usr --libdir=%_libdir --disable-netcdf --enable-bufr --enable-json
+%endif
+%endif
+
+make
+%install
+# install all files into the BuildRoot
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+# clean up the hard disc after build
+rm -rf $RPM_BUILD_ROOT
+
+
+%post -p /sbin/ldconfig 
+%postun -p /sbin/ldconfig 
+
+###############################################
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS ChangeLog NOTICE LICENSE
+/usr/bin/magmlx
+/usr/bin/magjson
+/usr/bin/magics-config
+/usr/bin/magicsCompatibilityChecker
+/usr/share/magics
+%_libdir/libMagPlus.so.*
+%if 0%{?suse_version} == 1130
+%_libdir/python2.6/site-packages
+%endif
+%if 0%{?suse_version} > 1130
+%_libdir/python2.7/site-packages
+%endif
+
+
+%files devel
+%defattr(-,root,root)
+/usr/include/magics
+/usr/share/aclocal/magics.m4
+%_libdir/pkgconfig/magics.pc
+%_libdir/libMagPlusSingle.a
+%_libdir/libMagPlusDouble.a
+%_libdir/libMagPlus.so
+%_libdir/libMagPlus.la
+
+%if 0%{?suse_version} > 1120
+%files metview-devel
+%defattr(-,root,root)
+%_libdir/libMagPlusQt.la
+%_libdir/libMagPlusQt.so*
+%_libdir/libMagWrapper.a
+%endif
+
+################################################
+
+%changelog
+* Mon Nov 14 2011 - magics at ecmwf.int
+- update to version 2.14.2 (bug fixes, fixes for python interface)
+
+* Thu Oct 26 2011 - magics at ecmwf.int
+- update to version 2.14.1 (new coastlines, new python interface)
+
+* Thu Jun 16 2011 - magics at ecmwf.int
+- update to version 2.12.9 (bug fixes in layout and PostScript output)  
+
+* Thu Apr 15 2011 - magics at ecmwf.int
+- update to version 2.12.7 (remove unnecessary warning messages)  
+
+* Thu Apr 14 2011 - magics at ecmwf.int
+- update to version 2.12.6 (add JSON and Metview 4.0.4 support)  
+
+* Thu Dec 02 2010 - magics at ecmwf.int
+- update to version 2.12.0  
+
+* Fri Nov 20 2010 - magics at ecmwf.int
+- update to version 2.11.5  (threaded contouring, Metview support)
+
+* Fri Jun 25 2010 - magics at ecmwf.int
+- update to version 2.10.2  (improve hatch shading + SVG output)
+
+* Mon May 03 2010 - magics at ecmwf.int
+- update to version 2.10  (add synop plotting)
+
+* Tue Oct 20 2009 - magics at ecmwf.int
+- initial package
diff --git a/rpms/Makefile.am b/rpms/Makefile.am
new file mode 100644
index 0000000..f06bb7b
--- /dev/null
+++ b/rpms/Makefile.am
@@ -0,0 +1,26 @@
+rpmspec=Magics.spec
+
+rpmmacros =\
+	--define="_rpmdir $${PWD}"\
+	--define="_srcrpmdir $${PWD}"\
+	--define="_sourcedir $${PWD}/.."\
+	--define="_specdir $${PWD}"\
+	--define="_builddir $${PWD}"
+
+RPMBUILD = rpmbuild
+RPMFLAGS = --nodeps --buildroot="$${PWD}/_rpm"
+
+rpmcheck:
+	if [ which $(RPMBUILD) &> /dev/null ]; then \
+	  echo "target requires Linux ..."; \
+	  (exit 1); exit 1; \
+	fi
+
+srcrpm: rpmcheck $(rpmspec)
+	$(RPMBUILD) $(RPMFLAGS) -bs $(rpmmacros) $(rpmspec)
+
+
+rpms: rpmcheck $(rpmspec)
+	$(RPMBUILD) $(RPMFLAGS) -ba $(rpmmacros) $(rpmspec)
+
+.PHONY: rpmcheck srcrpm rpms
diff --git a/rpms/Makefile.in b/rpms/Makefile.in
new file mode 100644
index 0000000..b453921
--- /dev/null
+++ b/rpms/Makefile.in
@@ -0,0 +1,465 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = rpms
+DIST_COMMON = $(srcdir)/Magics.spec.in $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES = Magics.spec
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+rpmspec = Magics.spec
+rpmmacros = \
+	--define="_rpmdir $${PWD}"\
+	--define="_srcrpmdir $${PWD}"\
+	--define="_sourcedir $${PWD}/.."\
+	--define="_specdir $${PWD}"\
+	--define="_builddir $${PWD}"
+
+RPMBUILD = rpmbuild
+RPMFLAGS = --nodeps --buildroot="$${PWD}/_rpm"
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu rpms/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu rpms/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+Magics.spec: $(top_builddir)/config.status $(srcdir)/Magics.spec.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
+
+
+rpmcheck:
+	if [ which $(RPMBUILD) &> /dev/null ]; then \
+	  echo "target requires Linux ..."; \
+	  (exit 1); exit 1; \
+	fi
+
+srcrpm: rpmcheck $(rpmspec)
+	$(RPMBUILD) $(RPMFLAGS) -bs $(rpmmacros) $(rpmspec)
+
+rpms: rpmcheck $(rpmspec)
+	$(RPMBUILD) $(RPMFLAGS) -ba $(rpmmacros) $(rpmspec)
+
+.PHONY: rpmcheck srcrpm rpms
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/share/magics/10m/10m_admin_0_boundary_lines_land.dbf b/share/magics/10m/10m_admin_0_boundary_lines_land.dbf
new file mode 100644
index 0000000..e9710a2
Binary files /dev/null and b/share/magics/10m/10m_admin_0_boundary_lines_land.dbf differ
diff --git a/share/magics/10m/10m_admin_0_boundary_lines_land.prj b/share/magics/10m/10m_admin_0_boundary_lines_land.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/10m/10m_admin_0_boundary_lines_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/10m/10m_admin_0_boundary_lines_land.shp b/share/magics/10m/10m_admin_0_boundary_lines_land.shp
new file mode 100644
index 0000000..ddc43a4
Binary files /dev/null and b/share/magics/10m/10m_admin_0_boundary_lines_land.shp differ
diff --git a/share/magics/10m/10m_admin_0_boundary_lines_land.shx b/share/magics/10m/10m_admin_0_boundary_lines_land.shx
new file mode 100644
index 0000000..2d55eb6
Binary files /dev/null and b/share/magics/10m/10m_admin_0_boundary_lines_land.shx differ
diff --git a/share/magics/10m/10m_admin_1_states_provinces_shp.dbf b/share/magics/10m/10m_admin_1_states_provinces_shp.dbf
new file mode 100644
index 0000000..7b8cd7c
Binary files /dev/null and b/share/magics/10m/10m_admin_1_states_provinces_shp.dbf differ
diff --git a/share/magics/10m/10m_admin_1_states_provinces_shp.prj b/share/magics/10m/10m_admin_1_states_provinces_shp.prj
new file mode 100644
index 0000000..b13a717
--- /dev/null
+++ b/share/magics/10m/10m_admin_1_states_provinces_shp.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.017453292519943295]]
\ No newline at end of file
diff --git a/share/magics/10m/10m_admin_1_states_provinces_shp.shp b/share/magics/10m/10m_admin_1_states_provinces_shp.shp
new file mode 100644
index 0000000..be2a867
Binary files /dev/null and b/share/magics/10m/10m_admin_1_states_provinces_shp.shp differ
diff --git a/share/magics/10m/10m_admin_1_states_provinces_shp.shx b/share/magics/10m/10m_admin_1_states_provinces_shp.shx
new file mode 100644
index 0000000..7f50b6f
Binary files /dev/null and b/share/magics/10m/10m_admin_1_states_provinces_shp.shx differ
diff --git a/share/magics/10m/10m_lakes.dbf b/share/magics/10m/10m_lakes.dbf
new file mode 100644
index 0000000..4e9589c
Binary files /dev/null and b/share/magics/10m/10m_lakes.dbf differ
diff --git a/share/magics/10m/10m_lakes.prj b/share/magics/10m/10m_lakes.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/10m/10m_lakes.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/10m/10m_lakes.shp b/share/magics/10m/10m_lakes.shp
new file mode 100644
index 0000000..8830600
Binary files /dev/null and b/share/magics/10m/10m_lakes.shp differ
diff --git a/share/magics/10m/10m_lakes.shx b/share/magics/10m/10m_lakes.shx
new file mode 100644
index 0000000..68691e5
Binary files /dev/null and b/share/magics/10m/10m_lakes.shx differ
diff --git a/share/magics/10m/10m_land.dbf b/share/magics/10m/10m_land.dbf
new file mode 100644
index 0000000..2b21a34
Binary files /dev/null and b/share/magics/10m/10m_land.dbf differ
diff --git a/share/magics/10m/10m_land.prj b/share/magics/10m/10m_land.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/10m/10m_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/10m/10m_land.shp b/share/magics/10m/10m_land.shp
new file mode 100644
index 0000000..5005af2
Binary files /dev/null and b/share/magics/10m/10m_land.shp differ
diff --git a/share/magics/10m/10m_land.shx b/share/magics/10m/10m_land.shx
new file mode 100644
index 0000000..b965bae
Binary files /dev/null and b/share/magics/10m/10m_land.shx differ
diff --git a/share/magics/10m/10m_populated_places_simple.dbf b/share/magics/10m/10m_populated_places_simple.dbf
new file mode 100644
index 0000000..1823111
Binary files /dev/null and b/share/magics/10m/10m_populated_places_simple.dbf differ
diff --git a/share/magics/10m/10m_populated_places_simple.prj b/share/magics/10m/10m_populated_places_simple.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/10m/10m_populated_places_simple.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/10m/10m_populated_places_simple.shp b/share/magics/10m/10m_populated_places_simple.shp
new file mode 100644
index 0000000..90d2b4e
Binary files /dev/null and b/share/magics/10m/10m_populated_places_simple.shp differ
diff --git a/share/magics/10m/10m_populated_places_simple.shx b/share/magics/10m/10m_populated_places_simple.shx
new file mode 100644
index 0000000..28c7910
Binary files /dev/null and b/share/magics/10m/10m_populated_places_simple.shx differ
diff --git a/share/magics/10m/10m_rivers_lake_centerlines.dbf b/share/magics/10m/10m_rivers_lake_centerlines.dbf
new file mode 100644
index 0000000..586c73a
Binary files /dev/null and b/share/magics/10m/10m_rivers_lake_centerlines.dbf differ
diff --git a/share/magics/10m/10m_rivers_lake_centerlines.prj b/share/magics/10m/10m_rivers_lake_centerlines.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/10m/10m_rivers_lake_centerlines.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/10m/10m_rivers_lake_centerlines.shp b/share/magics/10m/10m_rivers_lake_centerlines.shp
new file mode 100644
index 0000000..0d41d10
Binary files /dev/null and b/share/magics/10m/10m_rivers_lake_centerlines.shp differ
diff --git a/share/magics/10m/10m_rivers_lake_centerlines.shx b/share/magics/10m/10m_rivers_lake_centerlines.shx
new file mode 100644
index 0000000..3f4e642
Binary files /dev/null and b/share/magics/10m/10m_rivers_lake_centerlines.shx differ
diff --git a/share/magics/10m_full/10m_admin_0_boundary_lines_land.dbf b/share/magics/10m_full/10m_admin_0_boundary_lines_land.dbf
new file mode 100644
index 0000000..e9710a2
Binary files /dev/null and b/share/magics/10m_full/10m_admin_0_boundary_lines_land.dbf differ
diff --git a/share/magics/10m_full/10m_admin_0_boundary_lines_land.prj b/share/magics/10m_full/10m_admin_0_boundary_lines_land.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/10m_full/10m_admin_0_boundary_lines_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/10m_full/10m_admin_0_boundary_lines_land.shp b/share/magics/10m_full/10m_admin_0_boundary_lines_land.shp
new file mode 100644
index 0000000..ddc43a4
Binary files /dev/null and b/share/magics/10m_full/10m_admin_0_boundary_lines_land.shp differ
diff --git a/share/magics/10m_full/10m_admin_0_boundary_lines_land.shx b/share/magics/10m_full/10m_admin_0_boundary_lines_land.shx
new file mode 100644
index 0000000..2d55eb6
Binary files /dev/null and b/share/magics/10m_full/10m_admin_0_boundary_lines_land.shx differ
diff --git a/share/magics/10m_full/10m_admin_1_states_provinces_shp.dbf b/share/magics/10m_full/10m_admin_1_states_provinces_shp.dbf
new file mode 100644
index 0000000..c55e0ae
Binary files /dev/null and b/share/magics/10m_full/10m_admin_1_states_provinces_shp.dbf differ
diff --git a/share/magics/10m_full/10m_admin_1_states_provinces_shp.prj b/share/magics/10m_full/10m_admin_1_states_provinces_shp.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/10m_full/10m_admin_1_states_provinces_shp.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/10m_full/10m_admin_1_states_provinces_shp.shp b/share/magics/10m_full/10m_admin_1_states_provinces_shp.shp
new file mode 100644
index 0000000..c656806
Binary files /dev/null and b/share/magics/10m_full/10m_admin_1_states_provinces_shp.shp differ
diff --git a/share/magics/10m_full/10m_admin_1_states_provinces_shp.shx b/share/magics/10m_full/10m_admin_1_states_provinces_shp.shx
new file mode 100644
index 0000000..1fccbcf
Binary files /dev/null and b/share/magics/10m_full/10m_admin_1_states_provinces_shp.shx differ
diff --git a/share/magics/10m_full/10m_lakes.dbf b/share/magics/10m_full/10m_lakes.dbf
new file mode 100644
index 0000000..7c280b3
Binary files /dev/null and b/share/magics/10m_full/10m_lakes.dbf differ
diff --git a/share/magics/10m_full/10m_lakes.prj b/share/magics/10m_full/10m_lakes.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/10m_full/10m_lakes.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/10m_full/10m_lakes.shp b/share/magics/10m_full/10m_lakes.shp
new file mode 100644
index 0000000..666030f
Binary files /dev/null and b/share/magics/10m_full/10m_lakes.shp differ
diff --git a/share/magics/10m_full/10m_lakes.shx b/share/magics/10m_full/10m_lakes.shx
new file mode 100644
index 0000000..0fe6e07
Binary files /dev/null and b/share/magics/10m_full/10m_lakes.shx differ
diff --git a/share/magics/10m_full/10m_land.dbf b/share/magics/10m_full/10m_land.dbf
new file mode 100644
index 0000000..73af415
Binary files /dev/null and b/share/magics/10m_full/10m_land.dbf differ
diff --git a/share/magics/10m_full/10m_land.prj b/share/magics/10m_full/10m_land.prj
new file mode 100644
index 0000000..a30c00a
--- /dev/null
+++ b/share/magics/10m_full/10m_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
\ No newline at end of file
diff --git a/share/magics/10m_full/10m_land.shp b/share/magics/10m_full/10m_land.shp
new file mode 100644
index 0000000..72750bd
Binary files /dev/null and b/share/magics/10m_full/10m_land.shp differ
diff --git a/share/magics/10m_full/10m_land.shx b/share/magics/10m_full/10m_land.shx
new file mode 100644
index 0000000..10a8433
Binary files /dev/null and b/share/magics/10m_full/10m_land.shx differ
diff --git a/share/magics/10m_full/10m_rivers_lake_centerlines.dbf b/share/magics/10m_full/10m_rivers_lake_centerlines.dbf
new file mode 100644
index 0000000..34991b9
Binary files /dev/null and b/share/magics/10m_full/10m_rivers_lake_centerlines.dbf differ
diff --git a/share/magics/10m_full/10m_rivers_lake_centerlines.prj b/share/magics/10m_full/10m_rivers_lake_centerlines.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/10m_full/10m_rivers_lake_centerlines.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/10m_full/10m_rivers_lake_centerlines.shp b/share/magics/10m_full/10m_rivers_lake_centerlines.shp
new file mode 100644
index 0000000..6e55a53
Binary files /dev/null and b/share/magics/10m_full/10m_rivers_lake_centerlines.shp differ
diff --git a/share/magics/10m_full/10m_rivers_lake_centerlines.shx b/share/magics/10m_full/10m_rivers_lake_centerlines.shx
new file mode 100644
index 0000000..8d4fbca
Binary files /dev/null and b/share/magics/10m_full/10m_rivers_lake_centerlines.shx differ
diff --git a/share/magics/110m/110m_admin_0_boundary_lines_land.dbf b/share/magics/110m/110m_admin_0_boundary_lines_land.dbf
new file mode 100644
index 0000000..39218a3
Binary files /dev/null and b/share/magics/110m/110m_admin_0_boundary_lines_land.dbf differ
diff --git a/share/magics/110m/110m_admin_0_boundary_lines_land.prj b/share/magics/110m/110m_admin_0_boundary_lines_land.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/110m/110m_admin_0_boundary_lines_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/110m/110m_admin_0_boundary_lines_land.shp b/share/magics/110m/110m_admin_0_boundary_lines_land.shp
new file mode 100644
index 0000000..53a2f1f
Binary files /dev/null and b/share/magics/110m/110m_admin_0_boundary_lines_land.shp differ
diff --git a/share/magics/110m/110m_admin_0_boundary_lines_land.shx b/share/magics/110m/110m_admin_0_boundary_lines_land.shx
new file mode 100644
index 0000000..791fe09
Binary files /dev/null and b/share/magics/110m/110m_admin_0_boundary_lines_land.shx differ
diff --git a/share/magics/110m/110m_admin_1_states_provinces_shp.dbf b/share/magics/110m/110m_admin_1_states_provinces_shp.dbf
new file mode 100644
index 0000000..202134e
Binary files /dev/null and b/share/magics/110m/110m_admin_1_states_provinces_shp.dbf differ
diff --git a/share/magics/110m/110m_admin_1_states_provinces_shp.prj b/share/magics/110m/110m_admin_1_states_provinces_shp.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/110m/110m_admin_1_states_provinces_shp.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/110m/110m_admin_1_states_provinces_shp.shp b/share/magics/110m/110m_admin_1_states_provinces_shp.shp
new file mode 100644
index 0000000..4ba5e68
Binary files /dev/null and b/share/magics/110m/110m_admin_1_states_provinces_shp.shp differ
diff --git a/share/magics/110m/110m_admin_1_states_provinces_shp.shx b/share/magics/110m/110m_admin_1_states_provinces_shp.shx
new file mode 100644
index 0000000..9ea7e19
Binary files /dev/null and b/share/magics/110m/110m_admin_1_states_provinces_shp.shx differ
diff --git a/share/magics/110m/110m_lakes.dbf b/share/magics/110m/110m_lakes.dbf
new file mode 100644
index 0000000..eed23f4
Binary files /dev/null and b/share/magics/110m/110m_lakes.dbf differ
diff --git a/share/magics/110m/110m_lakes.prj b/share/magics/110m/110m_lakes.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/110m/110m_lakes.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/110m/110m_lakes.shp b/share/magics/110m/110m_lakes.shp
new file mode 100644
index 0000000..877312b
Binary files /dev/null and b/share/magics/110m/110m_lakes.shp differ
diff --git a/share/magics/110m/110m_lakes.shx b/share/magics/110m/110m_lakes.shx
new file mode 100644
index 0000000..d8036a0
Binary files /dev/null and b/share/magics/110m/110m_lakes.shx differ
diff --git a/share/magics/110m/110m_land.dbf b/share/magics/110m/110m_land.dbf
new file mode 100644
index 0000000..82697ef
Binary files /dev/null and b/share/magics/110m/110m_land.dbf differ
diff --git a/share/magics/110m/110m_land.prj b/share/magics/110m/110m_land.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/110m/110m_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/110m/110m_land.sbx b/share/magics/110m/110m_land.sbx
new file mode 100644
index 0000000..256b42c
Binary files /dev/null and b/share/magics/110m/110m_land.sbx differ
diff --git a/share/magics/110m/110m_land.shp b/share/magics/110m/110m_land.shp
new file mode 100644
index 0000000..69ce127
Binary files /dev/null and b/share/magics/110m/110m_land.shp differ
diff --git a/share/magics/110m/110m_land.shp.xml b/share/magics/110m/110m_land.shp.xml
new file mode 100644
index 0000000..172bf2b
--- /dev/null
+++ b/share/magics/110m/110m_land.shp.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<!--<!DOCTYPE metadata SYSTEM "http://www.esri.com/metadata/esriprof80.dtd">-->
+<metadata xml:lang="en"><Esri><CreaDate>20100226</CreaDate><CreaTime>03035000</CreaTime><SyncOnce>FALSE</SyncOnce><DataProperties><lineage><Process ToolSource="C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Data Management Tools.tbx\RepairGeometry" Date="20100207" Time="201213">RepairGeometry 110m-admin-0-country DELETE_NULL 110m-admin-0-country</Process><Process ToolSource="C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Data Management Tools.tbx\Dissolve" Date="20100207" Time="204703">Disso [...]
diff --git a/share/magics/110m/110m_land.shx b/share/magics/110m/110m_land.shx
new file mode 100644
index 0000000..0c82e83
Binary files /dev/null and b/share/magics/110m/110m_land.shx differ
diff --git a/share/magics/110m/110m_rivers_lake_centerlines.dbf b/share/magics/110m/110m_rivers_lake_centerlines.dbf
new file mode 100644
index 0000000..f381e9f
Binary files /dev/null and b/share/magics/110m/110m_rivers_lake_centerlines.dbf differ
diff --git a/share/magics/110m/110m_rivers_lake_centerlines.prj b/share/magics/110m/110m_rivers_lake_centerlines.prj
new file mode 100644
index 0000000..a30c00a
--- /dev/null
+++ b/share/magics/110m/110m_rivers_lake_centerlines.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
\ No newline at end of file
diff --git a/share/magics/110m/110m_rivers_lake_centerlines.shp b/share/magics/110m/110m_rivers_lake_centerlines.shp
new file mode 100644
index 0000000..ce7f366
Binary files /dev/null and b/share/magics/110m/110m_rivers_lake_centerlines.shp differ
diff --git a/share/magics/110m/110m_rivers_lake_centerlines.shx b/share/magics/110m/110m_rivers_lake_centerlines.shx
new file mode 100644
index 0000000..4a2adf0
Binary files /dev/null and b/share/magics/110m/110m_rivers_lake_centerlines.shx differ
diff --git a/share/magics/50m/50m_admin_0_boundary_lines_land.dbf b/share/magics/50m/50m_admin_0_boundary_lines_land.dbf
new file mode 100644
index 0000000..d4b04ea
Binary files /dev/null and b/share/magics/50m/50m_admin_0_boundary_lines_land.dbf differ
diff --git a/share/magics/50m/50m_admin_0_boundary_lines_land.prj b/share/magics/50m/50m_admin_0_boundary_lines_land.prj
new file mode 100644
index 0000000..a30c00a
--- /dev/null
+++ b/share/magics/50m/50m_admin_0_boundary_lines_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
\ No newline at end of file
diff --git a/share/magics/50m/50m_admin_0_boundary_lines_land.shp b/share/magics/50m/50m_admin_0_boundary_lines_land.shp
new file mode 100644
index 0000000..1ba5cf9
Binary files /dev/null and b/share/magics/50m/50m_admin_0_boundary_lines_land.shp differ
diff --git a/share/magics/50m/50m_admin_0_boundary_lines_land.shx b/share/magics/50m/50m_admin_0_boundary_lines_land.shx
new file mode 100644
index 0000000..db003f7
Binary files /dev/null and b/share/magics/50m/50m_admin_0_boundary_lines_land.shx differ
diff --git a/share/magics/50m/50m_admin_1_states_provinces_shp.dbf b/share/magics/50m/50m_admin_1_states_provinces_shp.dbf
new file mode 100644
index 0000000..87a0bb6
Binary files /dev/null and b/share/magics/50m/50m_admin_1_states_provinces_shp.dbf differ
diff --git a/share/magics/50m/50m_admin_1_states_provinces_shp.prj b/share/magics/50m/50m_admin_1_states_provinces_shp.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/50m/50m_admin_1_states_provinces_shp.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/50m/50m_admin_1_states_provinces_shp.shp b/share/magics/50m/50m_admin_1_states_provinces_shp.shp
new file mode 100644
index 0000000..4d3c6a5
Binary files /dev/null and b/share/magics/50m/50m_admin_1_states_provinces_shp.shp differ
diff --git a/share/magics/50m/50m_admin_1_states_provinces_shp.shx b/share/magics/50m/50m_admin_1_states_provinces_shp.shx
new file mode 100644
index 0000000..0ea01f0
Binary files /dev/null and b/share/magics/50m/50m_admin_1_states_provinces_shp.shx differ
diff --git a/share/magics/50m/50m_lakes.dbf b/share/magics/50m/50m_lakes.dbf
new file mode 100644
index 0000000..3a4b846
Binary files /dev/null and b/share/magics/50m/50m_lakes.dbf differ
diff --git a/share/magics/50m/50m_lakes.prj b/share/magics/50m/50m_lakes.prj
new file mode 100644
index 0000000..9e35477
--- /dev/null
+++ b/share/magics/50m/50m_lakes.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Longitude", EAST], AXIS["Latitude", NORTH]]
\ No newline at end of file
diff --git a/share/magics/50m/50m_lakes.shp b/share/magics/50m/50m_lakes.shp
new file mode 100644
index 0000000..d74e2b5
Binary files /dev/null and b/share/magics/50m/50m_lakes.shp differ
diff --git a/share/magics/50m/50m_lakes.shx b/share/magics/50m/50m_lakes.shx
new file mode 100644
index 0000000..1250aa9
Binary files /dev/null and b/share/magics/50m/50m_lakes.shx differ
diff --git a/share/magics/50m/50m_land.dbf b/share/magics/50m/50m_land.dbf
new file mode 100644
index 0000000..6919654
Binary files /dev/null and b/share/magics/50m/50m_land.dbf differ
diff --git a/share/magics/50m/50m_land.prj b/share/magics/50m/50m_land.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/50m/50m_land.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/50m/50m_land.shp b/share/magics/50m/50m_land.shp
new file mode 100644
index 0000000..8f0a1e6
Binary files /dev/null and b/share/magics/50m/50m_land.shp differ
diff --git a/share/magics/50m/50m_land.shx b/share/magics/50m/50m_land.shx
new file mode 100644
index 0000000..1dd4b14
Binary files /dev/null and b/share/magics/50m/50m_land.shx differ
diff --git a/share/magics/50m/50m_rivers_lake_centerlines.dbf b/share/magics/50m/50m_rivers_lake_centerlines.dbf
new file mode 100644
index 0000000..48edea4
Binary files /dev/null and b/share/magics/50m/50m_rivers_lake_centerlines.dbf differ
diff --git a/share/magics/50m/50m_rivers_lake_centerlines.prj b/share/magics/50m/50m_rivers_lake_centerlines.prj
new file mode 100644
index 0000000..f45cbad
--- /dev/null
+++ b/share/magics/50m/50m_rivers_lake_centerlines.prj
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
\ No newline at end of file
diff --git a/share/magics/50m/50m_rivers_lake_centerlines.shp b/share/magics/50m/50m_rivers_lake_centerlines.shp
new file mode 100644
index 0000000..cece3d0
Binary files /dev/null and b/share/magics/50m/50m_rivers_lake_centerlines.shp differ
diff --git a/share/magics/50m/50m_rivers_lake_centerlines.shp.xml b/share/magics/50m/50m_rivers_lake_centerlines.shp.xml
new file mode 100644
index 0000000..0caec6a
--- /dev/null
+++ b/share/magics/50m/50m_rivers_lake_centerlines.shp.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<!--<!DOCTYPE metadata SYSTEM "http://www.esri.com/metadata/esriprof80.dtd">-->
+<metadata xml:lang="en"><Esri><MetaID>{3812ED81-D053-4AF8-A10D-6B5BCD28AB4F}</MetaID><CreaDate>20091201</CreaDate><CreaTime>01491200</CreaTime><SyncOnce>FALSE</SyncOnce><SyncDate>20091201</SyncDate><SyncTime>01491300</SyncTime><ModDate>20091201</ModDate><ModTime>01491300</ModTime><DataProperties><lineage><Process ToolSource="C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Data Management Tools.tbx\Dissolve" Date="20091201" Time="014915">Dissolve 50m-rivers-lake-centerlines C:\ProjectFiles\2 [...]
diff --git a/share/magics/50m/50m_rivers_lake_centerlines.shx b/share/magics/50m/50m_rivers_lake_centerlines.shx
new file mode 100644
index 0000000..ac626bd
Binary files /dev/null and b/share/magics/50m/50m_rivers_lake_centerlines.shx differ
diff --git a/share/magics/Fonts.dat b/share/magics/Fonts.dat
new file mode 100644
index 0000000..3ca2110
--- /dev/null
+++ b/share/magics/Fonts.dat
@@ -0,0 +1,29 @@
+Font table for Magics++
+
+ID	MAGICS(PostScript)      PostScript name      PostScriptFontfile  TTF		CSS (SVG) name
+=================================================================================================================
+0	arial_normal		Helvetica		n019003l.pfb    arial.ttf       Arial	 
+1	arial_italic	     	Helvetica-Oblique	n019023l.pfb    ariali.ttf      Arial
+2	arial_bold	     	Helvetica-Bold  	n019004l.pfb    arialbd.ttf     Arial
+3	arial_bolditalic        Helvetica-BoldOblique	n019024l.pfb    arialbi.ttf     Arial
+4	courier_normal		Courier		     	n022003l.pfb    cour.ttf	Courier
+5	courier_italic	        Courier-Oblique	     	n022023l.pfb    couri.ttf       Courier
+6	courier_bold	     	Courier-Bold	     	n022004l.pfb    courbd.ttf      Courier
+7	courier_bolditalic      Courier-BoldOblique  	n022024l.pfb    courbi.ttf      Courier
+8	helvetica_normal	Helvetica	     	n019003l.pfb    arial.ttf       Arial
+9	helvetica_italic        Helvetica-Oblique    	n019023l.pfb    ariali.ttf      Arial
+10	helvetica_bold	     	Helvetica-Bold	     	n019004l.pfb    arialbd.ttf     Arial
+11	helvetica_bolditalic    Helvetica-BoldOblique	n019024l.pfb    arialbi.ttf     Arial
+12	times_normal            Times-Roman	     	n021003l.pfb    times.ttf       Times
+13	times_italic	     	Times-Italic	     	n021023l.pfb    timesi.ttf      Times
+14	times_bold	     	Times-Bold	    	n021004l.pfb    timesbd.ttf     Times
+15	times_bolditalic     	Times-BoldItalic     	n021024l.pfb    timesbi.ttf     Times
+16	symbol_normal		Symbol		     	s050000l.pfb    symbol.ttf      Symbol
+50	sansserif_normal	Helvetica 		n019003l.pfb    DejaVuSans.ttf	             Helvetica	   
+51	sansserif_italic	Helvetica-Oblique 	n019023l.pfb    DejaVuSans-Oblique.ttf       Helvetica
+52	sansserif_bold	     	Helvetica-Bold		n019004l.pfb    DejaVuSans-Bold.ttf	     Helvetica
+53	sansserif_bolditalic    Helvetica-BoldOblique	n019024l.pfb    DejaVuSans-BoldOblique.ttf   Helvetica
+54	serif_normal	     	Times-Roman		n021003l.pfb    DejaVuSerif.ttf	             Times
+55	serif_italic	     	Times-Italic  	    	n021023l.pfb    DejaVuSerif-Oblique.ttf      Times
+56	serif_bold	     	Times-Bold		n021004l.pfb    DejaVuSerif-Bold.ttf         Times
+57	serif_bolditalic     	Times-BoldItalic	n021024l.pfb    DejaVuSerif-BoldOblique.ttf  Times
diff --git a/share/magics/ObstatGribVisDef.txt b/share/magics/ObstatGribVisDef.txt
new file mode 100644
index 0000000..9505817
--- /dev/null
+++ b/share/magics/ObstatGribVisDef.txt
@@ -0,0 +1,1083 @@
+#Inst       Obs        fgdep       bcor       Obstdv       fgdStdv    BcorSTDV      Count     Unit
+#------------------------------------------------------------------------------------------------------
+#NOAA-19/MHS
+ 2230151 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230152 |  100. 10.  1 |  -99  .5 1 |  -99 2.  1 |  0. 2. 1 |     0. .3 1 |   0. 2.  1  |   0 20 1 |  K
+ 2230153 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230154 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230155 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+#NOAA-19/AMSUA
+ 2230031 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230032 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230033 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230034 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230035 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230036 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230037 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230038 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 2230039 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 22300310 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 22300311 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 22300312 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 22300313 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 22300314 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+ 22300315 |  100. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 20 1 |  K
+#MET-9/CSR
+ 0560561 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560562 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560563 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560564 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560565 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560566 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560567 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+ 0560568 |  180. 10.  1 |  -99  .5 1 |  -99 1.5 1 |  0. 2. 1 |     0. .3 1 |   0. 1.5 1  |   0 300 1 |  K
+#NOAA-18/MHS
+ 2090151 |  0.  3.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1 |   0. 1.5 1 |    0 20 1 |  K
+ 2090152 |  0.  2.5 1 |  -99  2. 1 |  -99 2.  1 |  0. 2. 1  |    0. 1.5 1 |   0. 2.  1 |    0 20 1 |  K
+ 2090153 |  0.  3.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1 |   0. 1.5 1 |    0 20 1 |  K
+ 2090154 |  0.  3.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1 |   0. 1.5 1 |    0 20 1 |  K
+ 2090155 |  0.  3.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1 |   0. 1.5 1 |    0 20 1 |  K
+#FY-3/MWRI
+ 5200431  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 5200432  | 100. 10.  1 |  -99  2. 1 |  -99 2.  1 |  0. 2. 1 |     0. 1.5 1  |  0. 2.  1  |   0 200 1 |  K
+ 5200433  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 5200434  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 5200435  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 5200436  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 5200437  | 100. 10.  1 |  -99  2. 1 |  -99 2.  1 |  0. 2. 1 |     0. 1.5 1  |  0. 2.  1  |   0 200 1 |  K
+ 5200438  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 5200439  | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+ 52004310 | 100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |     0. 1.5 1  |  0. 1.5 1  |   0 200 1 |  K
+#FY-3/MWTS
+ 5200401 |  190. 5.   1 |  0.0 0.40 1 | -2.5 0.3 1  |  0. 0.5 1 | 0. 0.1 1  |  0. 0.2 1  |   0 10  1 |  K
+ 5200402 |  190. 5.   1 | -2.0 0.25 1 | -1.5 0.15 1 |  0. 0.5 1 | 0. 0.05 1 |  0. 0.2  1 |   0 10  1 |  K
+ 5200403 |  190. 5.   1 | -0.5 0.25 1 | -0.5 0.05 1 |  0. 0.5 1 | 0. 0.05 1 |  0. 0.1  1 |   0 10  1 |  K
+ 5200404 |  190. 5.   1 | -2.0 0.25 1 | -0.5 0.05 1 |  0. 0.5 1 | 0. 0.03 1 |  0. 0.1  1 |   0 10  1 |  K
+#FY-3/MWHS
+ 5200411 |  170. 5.   1 | -8.5 0.5 1 |  -3 0.1 1   |  0. 1. 1 |  0. 0.3 1 |   0. 0.2 1  |  0 10 1 |  K
+ 5200412 |  170. 5.   1 | -7.5 0.5 1 | -0.5 0.05 1 |  0. 1. 1 |  0. 0.3 1 |   0. 0.2 1  |  0 10 1 |  K
+ 5200413 |  170. 5.   1 |  -.3 .2 1  |  -0.5 0.1 1 |  0. 1. 1 |  0. 0.2 1 |   0. 0.2 1  |  0 10 1 |  K
+ 5200414 |  170. 5.   1 |  -.3 .2 1  |  -0.5 0.1 1 |  0. 1. 1 |  0. 0.2 1 |   0. 0.2 1  |  0 10 1 |  K
+ 5200415 |  170. 5.   1 | -4.0 .3 1  | -2.2 0.2 1  |  0. 1. 1 |  0. 0.2 1 |  0. 0.2 1  |  0 10 1 |  K
+#DMSP-13/SSMI
+ 2460061 |  100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |  0. 1.5 1 |   0. 1.5 1  |  0 200 1 |  K
+ 2460062 |  100. 10.  1 |  -99  2. 1 |  -99 2.  1 |  0. 2. 1 |  0. 1.5 1 |   0. 2.  1  |  0 200 1 |  K
+ 2460063 |  100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |  0. 1.5 1 |   0. 1.5 1  |  0 200 1 |  K
+ 2460064 |  100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |  0. 1.5 1 |   0. 1.5 1  |  0 200 1 |  K
+ 2460065 |  100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |  0. 1.5 1 |   0. 1.5 1  |  0 200 1 |  K
+ 2460066 |  100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |  0. 1.5 1 |   0. 1.5 1  |  0 200 1 |  K
+ 2460067 |  100. 10.  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1 |  0. 1.5 1 |   0. 1.5 1  |  0 200 1 |  K
+#CORIOLIS/WINDSAT
+ 2830301  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830302  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830303  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830304  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830305  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830306  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830307  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830308  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 2830309  | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303010 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303011 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303012 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303013 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303014 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303015 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+ 28303016 | 100. 10.  1 | -99  2. 1 | -99 1.5 1 | 0. 2. 1  |   0. 1.5 1 |  0. 1.5 1  |  0 10 1 | K
+#TERRA MODIS AMV
+ 7830001 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830002 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830003 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830011 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830012 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830013 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830051 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830052 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7830053 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+#AQUA MODIS AMVs
+ 7840001 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840002 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840003 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840011 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840012 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840013 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840051 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840052 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+ 7840053 | 0.0  2.0  1 |  -99  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 10 1 |  m/s
+#MET-9 AMVs
+ 0563011 | 0.0  2.0  1 |  -10  1. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 300 1 |  m/s
+ 0563012 | 0.0  2.0  1 |  -4   0.5 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 100 1 |  m/s
+ 0563013 | 0.0  2.0  1 |  -10  2. 1 |  -99 1.5 1 |  0. 2. 1  |    0. 1.5 1  |  0. 1.5 1 |    0 300 1 |  m/s
+#Ozone NOAA-16
+ 2076241 |   0.2  0.2  1 | -99  0.1 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076242 |   1.0  0.5  1 | -99  0.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076243 |   5.0  1.0  1 | -99  1.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076244 |  10.0  2.5  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076245 |  20.0  5.0  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076246 | 100.0 20.0  1 | -99 15.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0 15.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+#NOAA-16 SBUV
+ 2076241 |   0.2  0.2  1 | -99  0.1 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076242 |   1.0  0.5  1 | -99  0.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076243 |   5.0  1.0  1 | -99  1.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076244 |  10.0  2.5  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076245 |  20.0  5.0  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2076246 | 100.0 20.0  1 | -99 15.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0 15.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+#NOAA-17 SBUV
+ 2086241 |   0.2  0.2  1 | -99  0.1 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2086242 |   1.0  0.5  1 | -99  0.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2086243 |   5.0  1.0  1 | -99  1.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.05 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2086244 |  10.0  2.5  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2086245 |  20.0  5.0  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2086246 | 100.0 20.0  1 | -99 15.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0 15.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+#NOAA-18 SBUV
+ 2096241 |   0.2  0.2  1 | -99  0.1 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2096242 |   1.0  0.5  1 | -99  0.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  0.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2096243 |   5.0  1.0  1 | -99  1.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2096244 |  10.0  2.5  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2096245 |  20.0  5.0  1 | -99  1.5 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0  1.5 1 |  0.0  0.1 1 | 0 2  1 |  DU
+ 2096246 | 100.0 20.0  1 | -99 15.0 1 |  1.0  1.0 1 | 0.0  0.5 1 |  0.0 15.0 1 |  0.0  0.1 1 | 0 2  1 |  DU
+#IASI CO
+ 0042211   |   0.2  0.2  1 | -99  0.1 1 |  1.0  1.0 1 | 0.0  0.05 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 |  kg/m2
+#METOP-A/IASI
+ 00401616 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401638 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401649 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401651 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401655 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401657 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401659 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401661 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401663 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401666 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401670 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401672 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401674 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401679 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 0.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401681 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401683 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401685 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401687 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401689 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401692 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401695 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401697 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00401699 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016101 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016104 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016106 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016109 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016111 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016113 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016116 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016119 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016122 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016125 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016128 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016131 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016133 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016135 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016138 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016141 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016144 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016146 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016148 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016151 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016154 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016157 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016159 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016161 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016163 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016165 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016167 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016170 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016173 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016176 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016178 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016179 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016180 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016183 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016185 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016187 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016189 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016191 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016193 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016195 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016197 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016199 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016201 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016203 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016205 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016207 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016210 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016212 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016214 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016217 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016219 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016222 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016224 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016226 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016228 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016230 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016232 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016234 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016236 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016239 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016241 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016242 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016243 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016246 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016249 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016252 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016254 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016256 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016258 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016260 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016262 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016265 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016267 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016269 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016271 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016272 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016273 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016275 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016278 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016280 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016282 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016284 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016286 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016288 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016290 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016292 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016294 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016296 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016299 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016301 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016303 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016306 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016308 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016310 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016312 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016314 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016316 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016318 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016320 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016323 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016325 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016327 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016329 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016331 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016333 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016335 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016337 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016339 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016341 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016343 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016345 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016347 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016350 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016352 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016354 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016356 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016358 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016360 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016362 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016364 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016366 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016369 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016371 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016373 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016375 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016377 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016379 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016381 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016383 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016386 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016389 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016398 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016401 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016404 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016407 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016410 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016414 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016416 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016426 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016428 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016432 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016434 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016439 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016445 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016457 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016515 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016546 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016552 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016559 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016566 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016571 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016573 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016646 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016662 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016668 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016756 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016867 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016906 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 004016921 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161027 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161046 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161090 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161121 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161133 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161191 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161194 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161271 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161479 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161509 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161513 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161521 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161536 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161574 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161578 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161579 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161585 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161587 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161626 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161639 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161643 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161652 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161658 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161671 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161786 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161805 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161884 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161946 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040161991 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162019 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162094 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162119 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162213 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162239 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162245 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162271 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162321 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162398 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162701 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162741 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162745 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162819 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162889 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162907 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162910 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162919 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162939 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162944 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162948 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162951 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162958 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162977 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162985 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162988 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162991 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040162993 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163002 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163008 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163014 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163027 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163029 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163036 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163047 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163049 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163053 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163058 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163064 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163069 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163087 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163093 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163098 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163105 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163107 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163110 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163127 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163136 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163151 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163160 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163165 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163168 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163175 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163178 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163207 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163228 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163244 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163248 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163252 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163256 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163263 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163281 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163303 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163309 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163312 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163322 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163339 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163375 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163378 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163411 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163438 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163440 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163442 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163444 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163446 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163448 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163450 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163452 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163454 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163458 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163467 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163476 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163484 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163491 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163497 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163499 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163504 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163506 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163509 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163518 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163522 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163527 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163540 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163555 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163575 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163577 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163580 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163582 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163586 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163589 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163599 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163645 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163653 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163658 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163661 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040163943 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040164032 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165130 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165368 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165371 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165379 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165381 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165383 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165397 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165399 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165401 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165403 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165405 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165455 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165480 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165483 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165485 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165492 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165502 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165507 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165509 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165517 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165558 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165988 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165992 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040165994 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166003 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166350 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166458 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166463 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166601 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166962 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166978 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166980 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166982 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166985 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166987 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166989 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166991 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166993 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166995 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040166997 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167001 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167267 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167269 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167389 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167424 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167426 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167428 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040167885 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040168007 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#METOP-A/HIRS
+ 0040001   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040002   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040003   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040004   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040005   |  160. 5.  1 |  -99  0.1 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040006   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040007   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040008   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040009   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400010   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400011   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400012   |  160. 5.  1 |  -99  0.1 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400013   |  160. 5.  1 |  -99  0.2 1 |  -99 1.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400014   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400015   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400016   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400017   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400018   |  160. 5.  1 |  -99  0.2 1 |  -99 0.5 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400019   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400010   |  160. 5.  1 |  -99  0.2 1 |  -99 0.2 1 |  0. .1 1 |  0. 0.05 1 |   0. 1.5 1  |  0 10 1 |  K
+#METOP-A/AMSU-A
+ 0040031   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040032   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040033   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040034   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040035   |  220. 5.  1 |  -.2  .1 1 |  -0.4 0.1 1 |  0. .5 1 |  0. 0.1 1 |   0. 0.1 1  |  0 10 1 |  K
+ 0040036   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040037   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040038   |  160. 5.  1 |  0.  .1 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040039   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400310  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400311  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400312  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400313  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400314  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 00400315  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#NOAA-18/AMSU-A
+ 2090031   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090032   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090033   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090034   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090035   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090036   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090037   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090038   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090039   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 20900310   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 20900311   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 20900312   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 20900313   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 20900314   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 20900315   |  160. 5.  1 |  -99  0.2 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#METOP-A/MHS
+ 0040151   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040152   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040153   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040154   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0040155   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#NOAA-17/AMSUB
+ 2080041   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2080042   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2080043   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2080044   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2080045   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#NOAA-18/MHS
+ 2090041   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090042   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090043   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090044   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 2090045   |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#SIMULOBS 
+2101131 |   0.  0.2  1 | -99  0.1 1 |  0.  1.0 1 | 0.0  0.05 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | 
+#GOME2 
+ 0042201 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+#AURA/OMI 
+7853941 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+#AURA/MLS 
+ 7853871 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853872 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853873 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853874 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853875 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853876 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853877 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853878 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 7853879 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538710 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538711 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538712 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538713 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538714 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538715 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538716 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 78538717 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+#ENVISAT/SCIAMACHY 
+ 601751 |   200. 10.  1 | -99  1. 1 | -99  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+#DMSP-16/SSMIS
+ 2490101 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490102 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490103 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490104 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490105 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490106 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490107 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490108 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2490109 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901010 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901011 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901012 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901013 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901014 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901015 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901016 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901017 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901018 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901019 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901020 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901021 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901022 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901023 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 24901024 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+#DMSP-17/SSMIS
+ 2850101 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850102 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850103 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850104 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850105 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850106 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850107 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850108 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 2850109 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501010 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501011 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501012 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501013 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501014 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501015 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501016 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501017 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501018 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501019 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501020 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501021 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501022 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501023 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+ 28501024 |  200. 5.  1 |  -99  0.5 1 |  -99 .2 1 |  0. 1. 1 |  0. .5 1 |   0. .5 1  |  0 20 1 |  K
+#MET-9/CSR
+ 0561 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0562 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0563 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0564 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0565 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0566 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0567 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 0568 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+#METOP-A/GPSRO
+ 0042021 |  1. 5.  1 |  -99  0.05 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.05 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042022 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042023 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042024 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042025 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042026 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042027 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042028 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 0042029 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420210 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420211 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420212 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420213 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420214 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420215 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420216 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420217 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420218 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420219 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420220 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420221 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420222 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420223 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420224 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420225 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420226 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420227 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420228 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420229 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420230 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420231 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420232 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420233 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420234 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420235 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420236 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420237 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420238 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420239 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420240 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420241 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420242 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420243 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420244 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420245 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420246 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420247 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420248 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420249 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+ 00420250 |  1. 10.  1 |  -99  0.1 1 |  -99 1.5  1 |  0. .5 1 |  0. 0.2 1 |   0. 1.5 1  |  0 100 1 |  Radians
+#Ozone METOP-A/GOME-2 (PROF)
+ 0042201 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042202 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042203 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042204 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042205 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042206 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042207 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042208 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042209 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422010 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422011 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422012 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422013 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422014 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422015 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422016 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422017 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422018 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422020 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422021 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422022 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422023 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422024 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422025 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422026 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422027 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422028 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422030 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422031 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422032 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422033 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422034 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422035 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422036 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422037 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422038 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422039 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 00422040 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042201 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+ 0042201 |   200. 10.  1 | -99  1. 1 |  6.  0.5 1 | 0.0  0.1 1 |  0.0  0.1 1 |  0.0  0.1 1 | 0 2  1 | DU
+# AQUA/AIRS
+ 7840111  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840116  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840117  |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401110 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401111 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401115 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401116 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401117 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401120 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401121 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401122 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401124 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401127 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401128 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401130 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401136 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401139 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401140 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401142 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401151 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401152 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401154 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401155 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401156 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401159 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401162 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401163 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401168 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401169 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401171 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401172 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401173 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401174 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401175 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401176 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401177 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401178 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401179 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401180 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401182 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401183 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401184 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401186 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401192 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401193 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401198 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 78401199 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011101 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011104 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011105 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011108 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011110 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011111 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011113 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011116 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011117 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011123 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011124 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011128 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011129 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011138 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011139 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011144 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011145 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011150 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011151 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011156 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011157 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011159 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011162 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011165 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011168 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011169 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011170 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011172 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011173 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011174 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011175 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011177 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011179 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011180 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011182 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011185 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011186 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011190 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011192 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011193 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011198 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011201 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011204 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011207 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011210 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011213 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011215 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011216 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011218 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011221 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011224 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011226 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011227 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011232 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011239 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011248 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011250 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011251 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011252 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011253 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011256 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011257 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011261 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011262 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011267 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011272 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011295 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011299 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011300 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011305 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011308 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011309 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011310 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011318 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011321 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011325 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011333 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011338 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011355 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011362 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011375 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011453 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011475 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011484 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011497 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011528 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011587 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011672 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011673 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011787 |  180. 5.  1 |  -99  0.2 1 |  -99 0.1 1 |  0. .2 1 |  0. .2 1 |   0. .1 1  |  0 10 1 |  K
+ 784011791 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011843 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011870 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011914 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 784011950 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111003 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111012 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111019 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111024 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111030 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111038 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111048 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111069 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111079 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111082 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111083 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111088 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111090 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111092 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111095 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111104 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111111 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111115 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111116 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111119 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111120 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111123 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111130 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111138 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111142 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111178 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111199 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111206 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111221 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111237 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111252 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111260 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111261 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111263 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111266 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111278 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111285 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111290 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111301 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111304 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111329 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111371 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111382 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111400 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111401 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111402 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111403 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111415 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111424 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111449 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111455 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111466 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111471 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111477 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111479 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111488 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111500 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111519 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111520 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111538 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111545 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111565 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111574 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111583 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111593 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111614 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111627 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111636 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111644 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111652 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111669 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111674 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111681 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111694 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111708 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111717 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111723 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111740 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111748 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111751 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111756 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111763 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111766 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111771 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111777 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111780 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111783 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111794 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111800 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111803 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111806 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111812 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111826 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111843 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111852 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111853 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111865 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111866 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111867 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111868 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111869 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111872 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111873 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111875 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111876 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111877 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111881 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111882 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111883 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111884 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111897 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111901 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111911 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111917 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111918 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111921 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111923 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111924 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111928 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111937 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111938 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111939 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111941 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111946 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111947 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111948 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111958 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111971 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111973 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111988 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840111995 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112084 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112085 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112097 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112098 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112099 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112100 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112101 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112103 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112104 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112106 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112107 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112108 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112109 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112110 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112111 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112112 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112113 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112114 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112115 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112116 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112117 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112118 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112119 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112120 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112121 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112122 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112123 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112128 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112134 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112141 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112145 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112149 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112153 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112164 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112189 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112197 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112209 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112226 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112234 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112280 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112318 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112321 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112325 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112328 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112333 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112339 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112348 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112353 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112355 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112357 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112363 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112370 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112371 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
+ 7840112377 |  160. 5.  1 |  -99  2. 1 |  -99 1.5 1 |  0. .5 1 |  0. 1.5 1 |   0. 1.5 1  |  0 10 1 |  K
diff --git a/share/magics/PostScriptFonts.dat b/share/magics/PostScriptFonts.dat
new file mode 100644
index 0000000..b1de4a7
--- /dev/null
+++ b/share/magics/PostScriptFonts.dat
@@ -0,0 +1,21 @@
+Font table for Magics++
+
+ID	MAGICS(PostScript)      PostScript name      PostScriptFontfile  TTF		CSS (SVG) name
+=================================================================================================================
+0	arial			Arial		     	n019003l.pfb    arial.ttf       Arial	 
+1	arial-italic	     	Arial-Oblique	    	n019023l.pfb    ariali.ttf      Arial;font-style:italic
+2	arial-bold	     	Arial-Bold	     	n019004l.pfb    arialbd.ttf     Arial;font-weight:bold
+3	arial-bolditalic        Arial-BoldOblique    	n019024l.pfb    arialbi.ttf     Arial;font-weight:bold;font-style:italic
+4	courier			Courier		     	n022003l.pfb    cour.ttf	Courier
+5	courier-italic	        Courier-Oblique	     	n022023l.pfb    couri.ttf       Courier;font-style:italic
+6	courier-bold	     	Courier-Bold	     	n022004l.pfb    courbd.ttf      Courier;font-weight:bold
+7	courier-bolditalic      Courier-BoldOblique  	n022024l.pfb    courbi.ttf      Courier;font-weight:bold;font-style:italic
+8	helvetica		Helvetica	     	n019003l.pfb    arial.ttf       Arial
+9	helvetica-italic        Helvetica-Oblique    	n019023l.pfb    ariali.ttf      Arial;font-style:italic
+10	helvetica-bold	     	Helvetica-Bold	     	n019004l.pfb    arialbd.ttf     Arial;font-weight:bold
+11	helvetica-bolditalic    Helvetica-BoldOblique	n019024l.pfb    arialbi.ttf     Arial;font-weight:bold;font-style:italic
+12	times                   Times-Roman	     	n021003l.pfb    times.ttf       Times
+13	times-italic	     	Times-Italic	     	n021023l.pfb    timesi.ttf      Times;font-style:italic
+14	times-bold	     	Times-Bold	    	n021004l.pfb    timesbd.ttf     Times;font-weight:bold
+15	times-bolditalic     	Times-BoldItalic     	n021024l.pfb    timesbi.ttf     Times;font-weight:bold;font-style:italic
+16	symbol			Symbol		     	s050000l.pfb    symbol.ttf      Symbol
diff --git a/share/magics/PostScriptMacro1.ps b/share/magics/PostScriptMacro1.ps
new file mode 100644
index 0000000..3eb6577
--- /dev/null
+++ b/share/magics/PostScriptMacro1.ps
@@ -0,0 +1,51 @@
+/m {moveto} def /st {stroke} def /rl {rlineto} def /ro {rotate} def /cp {closepath} def /d { {rmoveto rlineto} repeat stroke} bind def /gr {grestore} def /gs {gsave} def /n { newpath } def 
+/sa {save} def /lw {setlinewidth } def /ar {arc fill} def /arn {arcn fill} def
+/sd {setdash} def /C { setrgbcolor } def /Y { setcmykcolor } def  /B { moveto rlineto stroke } bind def /BB { moveto lineto stroke } bind def /t { translate } def /s {scale} def /K { /UY exch def /UX exch def /LY exch def 
+/LX exch def gsave newpath LX LY moveto UX LY lineto UX UY lineto LX UY lineto closepath newpath } def /lp { moveto rlineto } bind def /p { moveto {rlineto} repeat stroke} bind def /po { moveto {rlineto} repeat } bind def
+/q {moveto rlineto stroke} bind def /f {moveto {rlineto} repeat fill} bind def /e {moveto {rlineto} repeat eofill} bind def /F {moveto {rlineto} repeat} bind def /E {eofill} bind def /P { closepath } bind def
+/SAVEMT matrix def
+/Degreevec
+[
+	8#100 /at 8#251 /copyright 8#260 /degree 8#306 /AE 8#301 /Aacute 8#304 /Adieresis 8#300 /Agrave 8#305 /Aring 8#303 /Atilde 8#307 /Ccedilla 8#311 /Eacute 8#312 /Ecircumflex 8#313 /Edieresis 8#310 /Egrave
+	8#320 /Eth 8#315 /Iacute 8#316 /Icircumflex 8#317 /Idieresis 8#314 /Igrave 8#321 /Ntilde 8#323 /Oacute 8#325 /Odieresis 8#322 /Ograve 8#330 /Oslash 8#325 /Otilde 8#336 /Thorn 8#332 /Uacute 8#333 /Ucircumflex
+	8#334 /Udieresis 8#331 /Ugrave 8#335 /Yacute 8#341 /aacute 8#342 /acircumflex 8#222 /acute 8#264 /acute 8#344 /adieresis 8#346 /ae 8#340 /agrave 8#345 /aring 8#343 /atilde
+	8#226 /breve 8#246 /brokenbar 8#237 /caron 8#347 /ccedilla 8#270 /cedilla 8#242 /cent 8#223 /circumflex 8#244 /currency 8#250 /dieresis 8#227 /dotaccent 8#220 /dotlessi
+	8#351 /eacute 8#352 /ecircumflex 8#350 /egrave 8#360 /eth 8#241 /exclamdown 8#337 /germandbls 8#221 /grave 8#253 /guillemotleft 8#273 /guillemotright 8#235 /hungarumlaut
+	8#255 /hyphen 8#355 /iacute 8#356 /icircumflex 8#357 /idieresis 8#354 /igrave 8#254 /logicalnot 8#257 /macron 8#265 /mu
+	8#327 /multiply 8#361 /ntilde 8#363 /oacute 8#364 /odieresis 8#236 /ogonek 8#362 /ograve 8#275 /onehalf 8#274 /onequarter 8#271 /onesuperior 8#252 /ordfeminine
+	8#272 /ordmasculine 8#370 /oslash 8#365 /otilde 8#266 /paragraph 8#267 /periodcentered 8#261 /plusminus 8#277 /questiondown 8#256 /registered 8#232 /ring 8#247 /section 8#243 /sterling
+	8#376 /thorn 8#276 /threequarters 8#263 /threesuperior 8#224 /tilde 8#262 /twosuperior 8#372 /uacute 8#373 /ucircumflex 8#374 /udieresis 8#371 /ugrave 8#375 /yacute 8#377 /ydieresis 8#245 /yen
+] def
+/reencsmalldict 12 dict def
+/ReEncodeSmall
+{	reencsmalldict begin
+	/basefontname exch def
+	/basefontdict basefontname findfont def
+	/newfont basefontdict maxlength dict def
+	basefontdict
+	{ exch dup /FID ne
+		{
+			dup /Encoding eq
+			{
+				exch dup length array copy
+				newfont 3 1 roll put
+			}
+		{exch newfont 3 1 roll put}
+	    	ifelse
+	}
+	{ pop pop }
+	ifelse
+	} forall
+	newfont /FontName /Magicsfontname put
+	Degreevec aload pop
+	Degreevec length 2 idiv
+	{newfont /Encoding get 3 1 roll put
+	} repeat
+	/Magicsfontname newfont definefont pop
+	end
+} def
+
+/SF
+{
+/Height exch def
+/Font exch def
diff --git a/share/magics/PostScriptMacro2.ps b/share/magics/PostScriptMacro2.ps
new file mode 100644
index 0000000..cc95d33
--- /dev/null
+++ b/share/magics/PostScriptMacro2.ps
@@ -0,0 +1,58 @@
+ReEncodeSmall /Magicsfontname findfont Height scalefont setfont
+} def
+/SUP
+{ /CHUPY exch def /CHUPX exch def } def
+/ST
+{ /YPOS exch def /XPOS exch def [ CHUPY CHUPX neg CHUPX CHUPY XPOS YPOS ] concat} def
+/SHA
+{ /a exch def a 0 eq { /HA 0 def  } if a 1 eq { /HA -0.5 def } if a 2 eq { /HA -1 def } if } def
+/SVA
+{ /b exch def
+	Font  4 lt { b 0 eq { /VA 0 def } if b 1 eq { /VA -0.7 def } if b 2 eq { /VA -0.6625 def } if b 3 eq { /VA -0.33125 def } if b 4 eq { /VA 0 def } if b 5 eq { /VA 0.0375 def } if
+	} if
+	Font  8 lt { b 0 eq { /VA 0 def } if b 1 eq { /VA -0.76 def } if b 2 eq { /VA -0.725 def } if b 3 eq { /VA -0.3625 def } if b 4 eq { /VA 0 def } if b 5 eq { /VA 0.035 def } if	
+	} if	
+	Font 12 lt { b 0 eq { /VA 0 def } if b 1 eq { /VA -0.7 def } if b 2 eq { /VA -0.6625 def } if b 3 eq { /VA -0.33125 def } if b 4 eq { /VA 0 def } if b 5 eq { /VA 0.0375 def } if
+	} if	
+	Font 12 eq { b 0 eq { /VA 0 def } if b 1 eq { /VA -0.7 def } if b 2 eq { /VA -0.6625 def } if b 3 eq { /VA -0.33125 def } if b 4 eq { /VA 0 def } if b 5 eq { /VA 0.0375 def } if
+	} if
+	Font 12 gt { b 0 eq { /VA 0 def } if b 1 eq { /VA -0.7 def } if b 2 eq { /VA -0.6625 def } if b 3 eq { /VA -0.33125 def } if b 4 eq { /VA 0 def } if b 5 eq { /VA 0.0375 def } if
+	} if
+} def
+/T
+{
+	ST
+	/text exch def
+	text stringwidth pop HA mul VA Height mul moveto
+	text show
+} def
+/TU
+{
+	ST
+	/text exch def
+	text stringwidth pop HA mul VA Height mul moveto
+	text show
+	n
+	text stringwidth pop HA mul VA Height mul moveto
+	text stringwidth rl
+	cp st
+} def
+/TB
+{
+	ST
+	/text exch def
+	text stringwidth
+	4 add /y1 exch def
+	4 add /x1 exch def
+	text stringwidth pop HA mul VA Height mul moveto
+	gs n x1 -2 add HA mul VA Height mul -2 add moveto x1 0 rlineto 0 12 Height add .7 mul rlineto x1 neg 0 rlineto cp 1 setgray fill gr
+	text show
+} def
+/ushow
+{
+	SAVEMT currentmatrix pop
+	/text exch def
+	text show
+	SAVEMT setmatrix
+} def
+%%EndProlog
diff --git a/share/magics/bufr_98.xml b/share/magics/bufr_98.xml
new file mode 100644
index 0000000..7ee2291
--- /dev/null
+++ b/share/magics/bufr_98.xml
@@ -0,0 +1,121 @@
+<!--
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ This file describes BUFR codes for the various parameters and suptypes 
+ as used at ECMWF (098)  
+
+-->
+<centre name='98'>
+  <bufr_identifiers>
+    <wind_direction descriptor='11001'/>
+    <wind_speed descriptor='11002'/>
+    <height_meters  descriptor='10195'/>
+    <dewpoint descriptor='12003'/>
+    <temperature descriptor='12001'/>
+    <pressure_1 descriptor='07004'/>
+    <pressure_2 descriptor='07006'/>
+    <sea_temperature descriptor='22042'/>
+    <u_component descriptor='11192'/>
+    <v_component descriptor='11193'/>
+    <altitude_meters descriptor='07002'/>
+    <virtual_temperature descriptor='12007'/>
+    <water_precip descriptor='13006'/>
+    <total_cloud descriptor='20010'/>
+    <pressure  descriptor='10004'/>  
+    <wind_direction_10meters descriptor='11011'/>
+    <wind_speed_10meters descriptor='11012'/>
+    <horizontal_visibility descriptor='20001'/>
+    <present_weather descriptor='20003'/>
+    <temperature_2meters descriptor='12004'/>
+    <low_cloud descriptor='20012'/>
+    <medium_cloud descriptor='20012'/>
+    <high_cloud descriptor='20012'/>
+    <low_cloud_nebulosity descriptor='20011'/>
+    <medium_cloud_nebulosity descriptor='20011'/>
+    <high_cloud_nebulosity descriptor='20011'/>
+    <low_cloud_height descriptor='20013'/>
+    <medium_cloud_height descriptor='20013'/>
+    <high_cloud_height descriptor='20013'/>
+    <msl_pressure descriptor='10051'/>
+    <pressure_tendency_characteristic descriptor='10063'/>
+    <pressure_tendency_amount descriptor='10061'/>
+    <past_weather_1 descriptor='20004'/>
+    <past_weather_2 descriptor='20005'/>
+    <cloud_amount descriptor='20011'/>
+    <height_of_cloud_base descriptor='20013'/>
+    <dewpoint_2meters descriptor='12006'/>
+    <sea_temperature descriptor='22042'/>
+    <ship_direction descriptor='1012'/>
+    <ship_speed descriptor='1013'/>
+    <total_cloud descriptor='20010'/>
+    <wind_wave_direction descriptor='22002'/>
+    <wind_wave_period descriptor='22012'/>
+    <wind_wave_height descriptor='22022'/>
+    <swell_direction descriptor='22003'/>
+    <swell_period descriptor='22013'/>
+    <swell_heigth descriptor='22023'/>
+    <wave_direction descriptor='22001'/>
+    <wave_period descriptor='22011'/>
+    <wave_height descriptor='22021'/>
+    <hour descriptor='4004'/>
+    <minute descriptor='4005'/>
+    <latitude descriptor='5002'/>
+    <longitude descriptor='6002'/>
+    <latitude_1 descriptor='5001'/>
+    <latitude_2 descriptor='5002'/>
+    <longitude_1 descriptor='6001'/>
+    <longitude_2 descriptor='6002'/>
+    <station_height descriptor='7001'/>
+    <depth_below_land_surface descriptor='7061'/>
+    <soil_temperature descriptor='12030'/>
+    <geopotential descriptor='10003'/>
+	<past_precipitation descriptor='13021'/>
+  </bufr_identifiers>
+
+  <type value='0'>
+	<subtype value='1' template='synop'>synop land</subtype>
+	<subtype value='2' template='synop'>synop land record 2</subtype>
+	<subtype value='3' template='synop'>synop land auto </subtype>
+	<subtype value='4' template='synop'>synop land auto </subtype>
+	<subtype value='140' template='metar'>Metar</subtype>
+  </type>
+
+  <type value='1'>
+	<subtype value='11' template='synop_ship'>synop ship</subtype>
+	<subtype value='21' template='dribu_surface'>dribu surface</subtype>
+  </type>
+
+  <type value='2'>
+	<subtype value='91'>pilot</subtype>
+	<subtype value='101' template='temp'>temp</subtype>
+  </type>
+
+  <type value='4'>
+	<subtype value='142' template='airep'></subtype>
+	<subtype value='145' template='acar'></subtype>
+  </type>
+
+  <type value='5'>
+	<subtype value='82' template='satob'>satob wind</subtype>
+	<subtype value='83' template='satob'>satob wind and temperature</subtype>
+	<subtype value='84' template='satob'>satob section 4</subtype>
+	<subtype value='85' template='satob'>satob section 5</subtype>
+	<subtype value='89' template='unknown'>???</subtype>
+	<subtype value='87' template='unknown'>???</subtype>
+	<subtype value='88' template='unknown'>???</subtype>
+  </type>
+</centre>
diff --git a/share/magics/centre.xml b/share/magics/centre.xml
new file mode 100644
index 0000000..a5415cb
--- /dev/null
+++ b/share/magics/centre.xml
@@ -0,0 +1,21 @@
+<centres>
+    <centre code='98'
+        short_title='ECMWF'
+        long_title='ECMWF'/>
+    <centre code='74'
+        short_title='UK'
+        long_title='UK MetOffice'/>
+    <centre code='85'
+        short_title='France'
+        long_title='Meteo-France'/>
+    <centre code='46'
+        short_title='INPE'
+        long_title='Brasilian Space Agency'/>
+    <centre code='0'
+        short_title='WMO'
+        long_title='World meteorological organisation'/>
+    <centre code='1'
+        short_title='BOM'
+        long_title='Bureau of Meteorology'/>
+</centres>
+
diff --git a/share/magics/ecmwf_logo.gif b/share/magics/ecmwf_logo.gif
new file mode 100644
index 0000000..1c457ea
Binary files /dev/null and b/share/magics/ecmwf_logo.gif differ
diff --git a/share/magics/ecmwf_logo.png b/share/magics/ecmwf_logo.png
new file mode 100644
index 0000000..10ca8fb
Binary files /dev/null and b/share/magics/ecmwf_logo.png differ
diff --git a/share/magics/efi/Africa_All32parameters_0.js b/share/magics/efi/Africa_All32parameters_0.js
new file mode 100644
index 0000000..340f97c
--- /dev/null
+++ b/share/magics/efi/Africa_All32parameters_0.js
@@ -0,0 +1,25 @@
+magics_height = 384; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (-45),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (40)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 578.; 
diff --git a/share/magics/efi/Africa_All32parameters_1.js b/share/magics/efi/Africa_All32parameters_1.js
new file mode 100644
index 0000000..340f97c
--- /dev/null
+++ b/share/magics/efi/Africa_All32parameters_1.js
@@ -0,0 +1,25 @@
+magics_height = 384; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (-45),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (40)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 578.; 
diff --git a/share/magics/efi/Africa_All32parameters_2.js b/share/magics/efi/Africa_All32parameters_2.js
new file mode 100644
index 0000000..340f97c
--- /dev/null
+++ b/share/magics/efi/Africa_All32parameters_2.js
@@ -0,0 +1,25 @@
+magics_height = 384; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (-45),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (40)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 578.; 
diff --git a/share/magics/efi/Africa_All32parameters_3.js b/share/magics/efi/Africa_All32parameters_3.js
new file mode 100644
index 0000000..340f97c
--- /dev/null
+++ b/share/magics/efi/Africa_All32parameters_3.js
@@ -0,0 +1,25 @@
+magics_height = 384; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (-45),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (40)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 578.; 
diff --git a/share/magics/efi/Africa_All32parameters_4.js b/share/magics/efi/Africa_All32parameters_4.js
new file mode 100644
index 0000000..340f97c
--- /dev/null
+++ b/share/magics/efi/Africa_All32parameters_4.js
@@ -0,0 +1,25 @@
+magics_height = 384; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (-45),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (40)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 578.; 
diff --git a/share/magics/efi/Africa_All32parameters_5.js b/share/magics/efi/Africa_All32parameters_5.js
new file mode 100644
index 0000000..340f97c
--- /dev/null
+++ b/share/magics/efi/Africa_All32parameters_5.js
@@ -0,0 +1,25 @@
+magics_height = 384; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (-45),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (40)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 578.; 
diff --git a/share/magics/efi/Asia_All32parameters_0.js b/share/magics/efi/Asia_All32parameters_0.js
new file mode 100644
index 0000000..d9b8ac0
--- /dev/null
+++ b/share/magics/efi/Asia_All32parameters_0.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (55),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 577.; 
diff --git a/share/magics/efi/Asia_All32parameters_1.js b/share/magics/efi/Asia_All32parameters_1.js
new file mode 100644
index 0000000..d9b8ac0
--- /dev/null
+++ b/share/magics/efi/Asia_All32parameters_1.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (55),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 577.; 
diff --git a/share/magics/efi/Asia_All32parameters_2.js b/share/magics/efi/Asia_All32parameters_2.js
new file mode 100644
index 0000000..d9b8ac0
--- /dev/null
+++ b/share/magics/efi/Asia_All32parameters_2.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (55),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 577.; 
diff --git a/share/magics/efi/Asia_All32parameters_3.js b/share/magics/efi/Asia_All32parameters_3.js
new file mode 100644
index 0000000..d9b8ac0
--- /dev/null
+++ b/share/magics/efi/Asia_All32parameters_3.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (55),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 577.; 
diff --git a/share/magics/efi/Asia_All32parameters_4.js b/share/magics/efi/Asia_All32parameters_4.js
new file mode 100644
index 0000000..d9b8ac0
--- /dev/null
+++ b/share/magics/efi/Asia_All32parameters_4.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (55),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 577.; 
diff --git a/share/magics/efi/Asia_All32parameters_5.js b/share/magics/efi/Asia_All32parameters_5.js
new file mode 100644
index 0000000..d9b8ac0
--- /dev/null
+++ b/share/magics/efi/Asia_All32parameters_5.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 50.9091) )
+		return true;
+	if (greater(x, 627.879) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  50.9091 ) * ( 120 /  576.97 ) + (55),
+		lat: ( 96.05 - y) * ( 80 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 577.; 
diff --git a/share/magics/efi/Australia_All32parameters_0.js b/share/magics/efi/Australia_All32parameters_0.js
new file mode 100644
index 0000000..6bc99d6
--- /dev/null
+++ b/share/magics/efi/Australia_All32parameters_0.js
@@ -0,0 +1,25 @@
+magics_height = 371.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 92.6196) )
+		return true;
+	if (greater(y, 463.098) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 110 /  680 ) + (80),
+		lat: ( 92.6196 - y) * ( 60 / 370.479) + (5)
+	}
+}
+; 
+magics_top = 110.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Australia_All32parameters_1.js b/share/magics/efi/Australia_All32parameters_1.js
new file mode 100644
index 0000000..6bc99d6
--- /dev/null
+++ b/share/magics/efi/Australia_All32parameters_1.js
@@ -0,0 +1,25 @@
+magics_height = 371.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 92.6196) )
+		return true;
+	if (greater(y, 463.098) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 110 /  680 ) + (80),
+		lat: ( 92.6196 - y) * ( 60 / 370.479) + (5)
+	}
+}
+; 
+magics_top = 110.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Australia_All32parameters_2.js b/share/magics/efi/Australia_All32parameters_2.js
new file mode 100644
index 0000000..6bc99d6
--- /dev/null
+++ b/share/magics/efi/Australia_All32parameters_2.js
@@ -0,0 +1,25 @@
+magics_height = 371.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 92.6196) )
+		return true;
+	if (greater(y, 463.098) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 110 /  680 ) + (80),
+		lat: ( 92.6196 - y) * ( 60 / 370.479) + (5)
+	}
+}
+; 
+magics_top = 110.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Australia_All32parameters_3.js b/share/magics/efi/Australia_All32parameters_3.js
new file mode 100644
index 0000000..6bc99d6
--- /dev/null
+++ b/share/magics/efi/Australia_All32parameters_3.js
@@ -0,0 +1,25 @@
+magics_height = 371.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 92.6196) )
+		return true;
+	if (greater(y, 463.098) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 110 /  680 ) + (80),
+		lat: ( 92.6196 - y) * ( 60 / 370.479) + (5)
+	}
+}
+; 
+magics_top = 110.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Australia_All32parameters_4.js b/share/magics/efi/Australia_All32parameters_4.js
new file mode 100644
index 0000000..6bc99d6
--- /dev/null
+++ b/share/magics/efi/Australia_All32parameters_4.js
@@ -0,0 +1,25 @@
+magics_height = 371.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 92.6196) )
+		return true;
+	if (greater(y, 463.098) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 110 /  680 ) + (80),
+		lat: ( 92.6196 - y) * ( 60 / 370.479) + (5)
+	}
+}
+; 
+magics_top = 110.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Australia_All32parameters_5.js b/share/magics/efi/Australia_All32parameters_5.js
new file mode 100644
index 0000000..6bc99d6
--- /dev/null
+++ b/share/magics/efi/Australia_All32parameters_5.js
@@ -0,0 +1,25 @@
+magics_height = 371.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 92.6196) )
+		return true;
+	if (greater(y, 463.098) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 110 /  680 ) + (80),
+		lat: ( 92.6196 - y) * ( 60 / 370.479) + (5)
+	}
+}
+; 
+magics_top = 110.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Europe_All32parameters_0.js b/share/magics/efi/Europe_All32parameters_0.js
new file mode 100644
index 0000000..bb567ea
--- /dev/null
+++ b/share/magics/efi/Europe_All32parameters_0.js
@@ -0,0 +1,48 @@
+magics_height = 358.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 89.3861) )
+		return true;
+	if (greater(y, 446.931) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (xd, yd)
+{
+	yd = 446.931  -  yd; 
+	xpc = (xd -  60 ) * ( 9.14838e+06 /  680) + -4.91719e+06;
+	ypc = yd  * ( 4.81581e+06 /   357.545) +  -6.52533e+06;
+	px = xpc - 0;
+	py = ypc - 0;
+	ro = Math.sqrt(px*px + py*py);
+	t = (ro* 1)/(1.18883e+07) ;
+	xx = 1.5708 - 2.*Math.atan(t);
+	yll = xx + 0*Math.sin(2*xx) + 0*Math.sin(4*xx) + 0*Math.sin(6*xx);
+	if (py != 0.) 
+		xll = 0+ Math.atan(px/(-py));
+	if (and(greater(px, 0.), greater(py,0.)))
+		xll = xll + 3.14159;
+	else if (and(smaller(px,0.), greater(py,0.)))
+		xll = xll - 3.14159;
+	else if (and(greater(px, 0.), equal(py,0.)))
+		xll = 0+ 3.14159/ 2.;
+	else if (and(smaller(px, 0.),  equal(py,0.)))
+		xll = 0 - 3.14159/ 2.;
+	else if (and(equal(px,0.), equal(py, 0.)))
+		xll = 0;
+	if (smaller(xll, (-3.14159) )) xll += 2.* 3.14159;
+	else if (greater(xll, 3.14159)  )    xll -= 2.*3.14159;
+	xll = xll * 57.2958;
+	yll = yll * 57.2958;
+
+	return { lon :  xll, lat : yll } ;
+}
+; 
+magics_top = 122.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Europe_All32parameters_1.js b/share/magics/efi/Europe_All32parameters_1.js
new file mode 100644
index 0000000..bb567ea
--- /dev/null
+++ b/share/magics/efi/Europe_All32parameters_1.js
@@ -0,0 +1,48 @@
+magics_height = 358.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 89.3861) )
+		return true;
+	if (greater(y, 446.931) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (xd, yd)
+{
+	yd = 446.931  -  yd; 
+	xpc = (xd -  60 ) * ( 9.14838e+06 /  680) + -4.91719e+06;
+	ypc = yd  * ( 4.81581e+06 /   357.545) +  -6.52533e+06;
+	px = xpc - 0;
+	py = ypc - 0;
+	ro = Math.sqrt(px*px + py*py);
+	t = (ro* 1)/(1.18883e+07) ;
+	xx = 1.5708 - 2.*Math.atan(t);
+	yll = xx + 0*Math.sin(2*xx) + 0*Math.sin(4*xx) + 0*Math.sin(6*xx);
+	if (py != 0.) 
+		xll = 0+ Math.atan(px/(-py));
+	if (and(greater(px, 0.), greater(py,0.)))
+		xll = xll + 3.14159;
+	else if (and(smaller(px,0.), greater(py,0.)))
+		xll = xll - 3.14159;
+	else if (and(greater(px, 0.), equal(py,0.)))
+		xll = 0+ 3.14159/ 2.;
+	else if (and(smaller(px, 0.),  equal(py,0.)))
+		xll = 0 - 3.14159/ 2.;
+	else if (and(equal(px,0.), equal(py, 0.)))
+		xll = 0;
+	if (smaller(xll, (-3.14159) )) xll += 2.* 3.14159;
+	else if (greater(xll, 3.14159)  )    xll -= 2.*3.14159;
+	xll = xll * 57.2958;
+	yll = yll * 57.2958;
+
+	return { lon :  xll, lat : yll } ;
+}
+; 
+magics_top = 122.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Europe_All32parameters_2.js b/share/magics/efi/Europe_All32parameters_2.js
new file mode 100644
index 0000000..bb567ea
--- /dev/null
+++ b/share/magics/efi/Europe_All32parameters_2.js
@@ -0,0 +1,48 @@
+magics_height = 358.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 89.3861) )
+		return true;
+	if (greater(y, 446.931) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (xd, yd)
+{
+	yd = 446.931  -  yd; 
+	xpc = (xd -  60 ) * ( 9.14838e+06 /  680) + -4.91719e+06;
+	ypc = yd  * ( 4.81581e+06 /   357.545) +  -6.52533e+06;
+	px = xpc - 0;
+	py = ypc - 0;
+	ro = Math.sqrt(px*px + py*py);
+	t = (ro* 1)/(1.18883e+07) ;
+	xx = 1.5708 - 2.*Math.atan(t);
+	yll = xx + 0*Math.sin(2*xx) + 0*Math.sin(4*xx) + 0*Math.sin(6*xx);
+	if (py != 0.) 
+		xll = 0+ Math.atan(px/(-py));
+	if (and(greater(px, 0.), greater(py,0.)))
+		xll = xll + 3.14159;
+	else if (and(smaller(px,0.), greater(py,0.)))
+		xll = xll - 3.14159;
+	else if (and(greater(px, 0.), equal(py,0.)))
+		xll = 0+ 3.14159/ 2.;
+	else if (and(smaller(px, 0.),  equal(py,0.)))
+		xll = 0 - 3.14159/ 2.;
+	else if (and(equal(px,0.), equal(py, 0.)))
+		xll = 0;
+	if (smaller(xll, (-3.14159) )) xll += 2.* 3.14159;
+	else if (greater(xll, 3.14159)  )    xll -= 2.*3.14159;
+	xll = xll * 57.2958;
+	yll = yll * 57.2958;
+
+	return { lon :  xll, lat : yll } ;
+}
+; 
+magics_top = 122.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Europe_All32parameters_3.js b/share/magics/efi/Europe_All32parameters_3.js
new file mode 100644
index 0000000..bb567ea
--- /dev/null
+++ b/share/magics/efi/Europe_All32parameters_3.js
@@ -0,0 +1,48 @@
+magics_height = 358.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 89.3861) )
+		return true;
+	if (greater(y, 446.931) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (xd, yd)
+{
+	yd = 446.931  -  yd; 
+	xpc = (xd -  60 ) * ( 9.14838e+06 /  680) + -4.91719e+06;
+	ypc = yd  * ( 4.81581e+06 /   357.545) +  -6.52533e+06;
+	px = xpc - 0;
+	py = ypc - 0;
+	ro = Math.sqrt(px*px + py*py);
+	t = (ro* 1)/(1.18883e+07) ;
+	xx = 1.5708 - 2.*Math.atan(t);
+	yll = xx + 0*Math.sin(2*xx) + 0*Math.sin(4*xx) + 0*Math.sin(6*xx);
+	if (py != 0.) 
+		xll = 0+ Math.atan(px/(-py));
+	if (and(greater(px, 0.), greater(py,0.)))
+		xll = xll + 3.14159;
+	else if (and(smaller(px,0.), greater(py,0.)))
+		xll = xll - 3.14159;
+	else if (and(greater(px, 0.), equal(py,0.)))
+		xll = 0+ 3.14159/ 2.;
+	else if (and(smaller(px, 0.),  equal(py,0.)))
+		xll = 0 - 3.14159/ 2.;
+	else if (and(equal(px,0.), equal(py, 0.)))
+		xll = 0;
+	if (smaller(xll, (-3.14159) )) xll += 2.* 3.14159;
+	else if (greater(xll, 3.14159)  )    xll -= 2.*3.14159;
+	xll = xll * 57.2958;
+	yll = yll * 57.2958;
+
+	return { lon :  xll, lat : yll } ;
+}
+; 
+magics_top = 122.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Europe_All32parameters_4.js b/share/magics/efi/Europe_All32parameters_4.js
new file mode 100644
index 0000000..bb567ea
--- /dev/null
+++ b/share/magics/efi/Europe_All32parameters_4.js
@@ -0,0 +1,48 @@
+magics_height = 358.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 89.3861) )
+		return true;
+	if (greater(y, 446.931) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (xd, yd)
+{
+	yd = 446.931  -  yd; 
+	xpc = (xd -  60 ) * ( 9.14838e+06 /  680) + -4.91719e+06;
+	ypc = yd  * ( 4.81581e+06 /   357.545) +  -6.52533e+06;
+	px = xpc - 0;
+	py = ypc - 0;
+	ro = Math.sqrt(px*px + py*py);
+	t = (ro* 1)/(1.18883e+07) ;
+	xx = 1.5708 - 2.*Math.atan(t);
+	yll = xx + 0*Math.sin(2*xx) + 0*Math.sin(4*xx) + 0*Math.sin(6*xx);
+	if (py != 0.) 
+		xll = 0+ Math.atan(px/(-py));
+	if (and(greater(px, 0.), greater(py,0.)))
+		xll = xll + 3.14159;
+	else if (and(smaller(px,0.), greater(py,0.)))
+		xll = xll - 3.14159;
+	else if (and(greater(px, 0.), equal(py,0.)))
+		xll = 0+ 3.14159/ 2.;
+	else if (and(smaller(px, 0.),  equal(py,0.)))
+		xll = 0 - 3.14159/ 2.;
+	else if (and(equal(px,0.), equal(py, 0.)))
+		xll = 0;
+	if (smaller(xll, (-3.14159) )) xll += 2.* 3.14159;
+	else if (greater(xll, 3.14159)  )    xll -= 2.*3.14159;
+	xll = xll * 57.2958;
+	yll = yll * 57.2958;
+
+	return { lon :  xll, lat : yll } ;
+}
+; 
+magics_top = 122.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Europe_All32parameters_5.js b/share/magics/efi/Europe_All32parameters_5.js
new file mode 100644
index 0000000..bb567ea
--- /dev/null
+++ b/share/magics/efi/Europe_All32parameters_5.js
@@ -0,0 +1,48 @@
+magics_height = 358.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 89.3861) )
+		return true;
+	if (greater(y, 446.931) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (xd, yd)
+{
+	yd = 446.931  -  yd; 
+	xpc = (xd -  60 ) * ( 9.14838e+06 /  680) + -4.91719e+06;
+	ypc = yd  * ( 4.81581e+06 /   357.545) +  -6.52533e+06;
+	px = xpc - 0;
+	py = ypc - 0;
+	ro = Math.sqrt(px*px + py*py);
+	t = (ro* 1)/(1.18883e+07) ;
+	xx = 1.5708 - 2.*Math.atan(t);
+	yll = xx + 0*Math.sin(2*xx) + 0*Math.sin(4*xx) + 0*Math.sin(6*xx);
+	if (py != 0.) 
+		xll = 0+ Math.atan(px/(-py));
+	if (and(greater(px, 0.), greater(py,0.)))
+		xll = xll + 3.14159;
+	else if (and(smaller(px,0.), greater(py,0.)))
+		xll = xll - 3.14159;
+	else if (and(greater(px, 0.), equal(py,0.)))
+		xll = 0+ 3.14159/ 2.;
+	else if (and(smaller(px, 0.),  equal(py,0.)))
+		xll = 0 - 3.14159/ 2.;
+	else if (and(equal(px,0.), equal(py, 0.)))
+		xll = 0;
+	if (smaller(xll, (-3.14159) )) xll += 2.* 3.14159;
+	else if (greater(xll, 3.14159)  )    xll -= 2.*3.14159;
+	xll = xll * 57.2958;
+	yll = yll * 57.2958;
+
+	return { lon :  xll, lat : yll } ;
+}
+; 
+magics_top = 122.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Global_All32parameters_0.js b/share/magics/efi/Global_All32parameters_0.js
new file mode 100644
index 0000000..f425af0
--- /dev/null
+++ b/share/magics/efi/Global_All32parameters_0.js
@@ -0,0 +1,25 @@
+magics_height = 340.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 113.202) )
+		return true;
+	if (greater(y, 452.807) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 360 /  680 ) + (-180),
+		lat: ( 113.202 - y) * ( 180 / 339.605) + (90)
+	}
+}
+; 
+magics_top = 140.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Global_All32parameters_1.js b/share/magics/efi/Global_All32parameters_1.js
new file mode 100644
index 0000000..f425af0
--- /dev/null
+++ b/share/magics/efi/Global_All32parameters_1.js
@@ -0,0 +1,25 @@
+magics_height = 340.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 113.202) )
+		return true;
+	if (greater(y, 452.807) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 360 /  680 ) + (-180),
+		lat: ( 113.202 - y) * ( 180 / 339.605) + (90)
+	}
+}
+; 
+magics_top = 140.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Global_All32parameters_2.js b/share/magics/efi/Global_All32parameters_2.js
new file mode 100644
index 0000000..f425af0
--- /dev/null
+++ b/share/magics/efi/Global_All32parameters_2.js
@@ -0,0 +1,25 @@
+magics_height = 340.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 113.202) )
+		return true;
+	if (greater(y, 452.807) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 360 /  680 ) + (-180),
+		lat: ( 113.202 - y) * ( 180 / 339.605) + (90)
+	}
+}
+; 
+magics_top = 140.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Global_All32parameters_3.js b/share/magics/efi/Global_All32parameters_3.js
new file mode 100644
index 0000000..f425af0
--- /dev/null
+++ b/share/magics/efi/Global_All32parameters_3.js
@@ -0,0 +1,25 @@
+magics_height = 340.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 113.202) )
+		return true;
+	if (greater(y, 452.807) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 360 /  680 ) + (-180),
+		lat: ( 113.202 - y) * ( 180 / 339.605) + (90)
+	}
+}
+; 
+magics_top = 140.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Global_All32parameters_4.js b/share/magics/efi/Global_All32parameters_4.js
new file mode 100644
index 0000000..f425af0
--- /dev/null
+++ b/share/magics/efi/Global_All32parameters_4.js
@@ -0,0 +1,25 @@
+magics_height = 340.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 113.202) )
+		return true;
+	if (greater(y, 452.807) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 360 /  680 ) + (-180),
+		lat: ( 113.202 - y) * ( 180 / 339.605) + (90)
+	}
+}
+; 
+magics_top = 140.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/Global_All32parameters_5.js b/share/magics/efi/Global_All32parameters_5.js
new file mode 100644
index 0000000..f425af0
--- /dev/null
+++ b/share/magics/efi/Global_All32parameters_5.js
@@ -0,0 +1,25 @@
+magics_height = 340.; 
+magics_left = 60; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 60) )
+		return true;
+	if (greater(x, 740) )
+		return true;
+	if (smaller(y, 113.202) )
+		return true;
+	if (greater(y, 452.807) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  60 ) * ( 360 /  680 ) + (-180),
+		lat: ( 113.202 - y) * ( 180 / 339.605) + (90)
+	}
+}
+; 
+magics_top = 140.; 
+magics_version = "2.6.0"; 
+magics_width = 680; 
diff --git a/share/magics/efi/North32America_All32parameters_0.js b/share/magics/efi/North32America_All32parameters_0.js
new file mode 100644
index 0000000..0c28440
--- /dev/null
+++ b/share/magics/efi/North32America_All32parameters_0.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 49.9109) )
+		return true;
+	if (greater(x, 615.567) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  49.9109 ) * ( 125 /  565.657 ) + (-140),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 565.; 
diff --git a/share/magics/efi/North32America_All32parameters_1.js b/share/magics/efi/North32America_All32parameters_1.js
new file mode 100644
index 0000000..0c28440
--- /dev/null
+++ b/share/magics/efi/North32America_All32parameters_1.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 49.9109) )
+		return true;
+	if (greater(x, 615.567) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  49.9109 ) * ( 125 /  565.657 ) + (-140),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 565.; 
diff --git a/share/magics/efi/North32America_All32parameters_2.js b/share/magics/efi/North32America_All32parameters_2.js
new file mode 100644
index 0000000..0c28440
--- /dev/null
+++ b/share/magics/efi/North32America_All32parameters_2.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 49.9109) )
+		return true;
+	if (greater(x, 615.567) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  49.9109 ) * ( 125 /  565.657 ) + (-140),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 565.; 
diff --git a/share/magics/efi/North32America_All32parameters_3.js b/share/magics/efi/North32America_All32parameters_3.js
new file mode 100644
index 0000000..0c28440
--- /dev/null
+++ b/share/magics/efi/North32America_All32parameters_3.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 49.9109) )
+		return true;
+	if (greater(x, 615.567) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  49.9109 ) * ( 125 /  565.657 ) + (-140),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 565.; 
diff --git a/share/magics/efi/North32America_All32parameters_4.js b/share/magics/efi/North32America_All32parameters_4.js
new file mode 100644
index 0000000..0c28440
--- /dev/null
+++ b/share/magics/efi/North32America_All32parameters_4.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 49.9109) )
+		return true;
+	if (greater(x, 615.567) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  49.9109 ) * ( 125 /  565.657 ) + (-140),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 565.; 
diff --git a/share/magics/efi/North32America_All32parameters_5.js b/share/magics/efi/North32America_All32parameters_5.js
new file mode 100644
index 0000000..0c28440
--- /dev/null
+++ b/share/magics/efi/North32America_All32parameters_5.js
@@ -0,0 +1,25 @@
+magics_height = 384.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 49.9109) )
+		return true;
+	if (greater(x, 615.567) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  49.9109 ) * ( 125 /  565.657 ) + (-140),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (80)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 565.; 
diff --git a/share/magics/efi/South32America_All32parameters_0.js b/share/magics/efi/South32America_All32parameters_0.js
new file mode 100644
index 0000000..f8a0a15
--- /dev/null
+++ b/share/magics/efi/South32America_All32parameters_0.js
@@ -0,0 +1,25 @@
+magics_height = 385.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 51.9073) )
+		return true;
+	if (greater(x, 640.19) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  51.9073 ) * ( 130 /  588.283 ) + (-125),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (20)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 590.; 
diff --git a/share/magics/efi/South32America_All32parameters_1.js b/share/magics/efi/South32America_All32parameters_1.js
new file mode 100644
index 0000000..f8a0a15
--- /dev/null
+++ b/share/magics/efi/South32America_All32parameters_1.js
@@ -0,0 +1,25 @@
+magics_height = 385.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 51.9073) )
+		return true;
+	if (greater(x, 640.19) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  51.9073 ) * ( 130 /  588.283 ) + (-125),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (20)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 590.; 
diff --git a/share/magics/efi/South32America_All32parameters_2.js b/share/magics/efi/South32America_All32parameters_2.js
new file mode 100644
index 0000000..f8a0a15
--- /dev/null
+++ b/share/magics/efi/South32America_All32parameters_2.js
@@ -0,0 +1,25 @@
+magics_height = 385.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 51.9073) )
+		return true;
+	if (greater(x, 640.19) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  51.9073 ) * ( 130 /  588.283 ) + (-125),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (20)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 590.; 
diff --git a/share/magics/efi/South32America_All32parameters_3.js b/share/magics/efi/South32America_All32parameters_3.js
new file mode 100644
index 0000000..f8a0a15
--- /dev/null
+++ b/share/magics/efi/South32America_All32parameters_3.js
@@ -0,0 +1,25 @@
+magics_height = 385.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 51.9073) )
+		return true;
+	if (greater(x, 640.19) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  51.9073 ) * ( 130 /  588.283 ) + (-125),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (20)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 590.; 
diff --git a/share/magics/efi/South32America_All32parameters_4.js b/share/magics/efi/South32America_All32parameters_4.js
new file mode 100644
index 0000000..f8a0a15
--- /dev/null
+++ b/share/magics/efi/South32America_All32parameters_4.js
@@ -0,0 +1,25 @@
+magics_height = 385.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 51.9073) )
+		return true;
+	if (greater(x, 640.19) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  51.9073 ) * ( 130 /  588.283 ) + (-125),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (20)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 590.; 
diff --git a/share/magics/efi/South32America_All32parameters_5.js b/share/magics/efi/South32America_All32parameters_5.js
new file mode 100644
index 0000000..f8a0a15
--- /dev/null
+++ b/share/magics/efi/South32America_All32parameters_5.js
@@ -0,0 +1,25 @@
+magics_height = 385.; 
+magics_left = 60.; 
+magics_outside = function (x, y) { 
+	if (smaller(x, 51.9073) )
+		return true;
+	if (greater(x, 640.19) )
+		return true;
+	if (smaller(y, 96.05) )
+		return true;
+	if (greater(y, 480.25) )
+		return true;
+	return false;
+}
+; 
+magics_reprojection = function (x, y)
+{
+	return {
+		lon: (x -  51.9073 ) * ( 130 /  588.283 ) + (-125),
+		lat: ( 96.05 - y) * ( 85 / 384.2) + (20)
+	}
+}
+; 
+magics_top = 96.; 
+magics_version = "2.6.0"; 
+magics_width = 590.; 
diff --git a/share/magics/efi/efi_template.js b/share/magics/efi/efi_template.js
new file mode 100644
index 0000000..e20a765
--- /dev/null
+++ b/share/magics/efi/efi_template.js
@@ -0,0 +1 @@
+HELLO: I am a template! 
diff --git a/share/magics/entities.dtd b/share/magics/entities.dtd
new file mode 100644
index 0000000..b5b761c
--- /dev/null
+++ b/share/magics/entities.dtd
@@ -0,0 +1,255 @@
+
+<!DOCTYPE xml [
+	<!ENTITY AElig "Æ">
+	<!ENTITY Aacute "Á">
+	<!ENTITY Acirc "Â">
+	<!ENTITY Agrave "À">
+	<!ENTITY Alpha "Α">
+	<!ENTITY Aring "Å">
+	<!ENTITY Atilde "Ã">
+	<!ENTITY Auml "Ä">
+	<!ENTITY Beta "Β">
+	<!ENTITY Ccedil "Ç">
+	<!ENTITY Chi "Χ">
+	<!ENTITY Dagger "‡">
+	<!ENTITY Delta "Δ">
+	<!ENTITY ETH "Ð">
+	<!ENTITY Eacute "É">
+	<!ENTITY Ecirc "Ê">
+	<!ENTITY Egrave "È">
+	<!ENTITY Epsilon "Ε">
+	<!ENTITY Eta "Η">
+	<!ENTITY Euml "Ë">
+	<!ENTITY Gamma "Γ">
+	<!ENTITY Iacute "Í">
+	<!ENTITY Icirc "Î">
+	<!ENTITY Igrave "Ì">
+	<!ENTITY Iota "Ι">
+	<!ENTITY Iuml "Ï">
+	<!ENTITY Kappa "Κ">
+	<!ENTITY Lambda "Λ">
+	<!ENTITY Mu "Μ">
+	<!ENTITY Ntilde "Ñ">
+	<!ENTITY Nu "Ν">
+	<!ENTITY OElig "Œ">
+	<!ENTITY Oacute "Ó">
+	<!ENTITY Ocirc "Ô">
+	<!ENTITY Ograve "Ò">
+	<!ENTITY Omega "Ω">
+	<!ENTITY Omicron "Ο">
+	<!ENTITY Oslash "Ø">
+	<!ENTITY Otilde "Õ">
+	<!ENTITY Ouml "Ö">
+	<!ENTITY Phi "Φ">
+	<!ENTITY Pi "Π">
+	<!ENTITY Prime "″">
+	<!ENTITY Psi "Ψ">
+	<!ENTITY Rho "Ρ">
+	<!ENTITY Scaron "Š">
+	<!ENTITY Sigma "Σ">
+	<!ENTITY THORN "Þ">
+	<!ENTITY Tau "Τ">
+	<!ENTITY Theta "Θ">
+	<!ENTITY Uacute "Ú">
+	<!ENTITY Ucirc "Û">
+	<!ENTITY Ugrave "Ù">
+	<!ENTITY Upsilon "Υ">
+	<!ENTITY Uuml "Ü">
+	<!ENTITY Xi "Ξ">
+	<!ENTITY Yacute "Ý">
+	<!ENTITY Yuml "Ÿ">
+	<!ENTITY Zeta "Ζ">
+	<!ENTITY aacute "á">
+	<!ENTITY acirc "â">
+	<!ENTITY acute "´">
+	<!ENTITY aelig "æ">
+	<!ENTITY agrave "à">
+	<!ENTITY alefsym "ℵ">
+	<!ENTITY alpha "α">
+	<!ENTITY amp "&">
+	<!ENTITY and "∧">
+	<!ENTITY ang "∠">
+	<!ENTITY aring "å">
+	<!ENTITY asymp "≈">
+	<!ENTITY atilde "ã">
+	<!ENTITY auml "ä">
+	<!ENTITY bdquo "„">
+	<!ENTITY beta "β">
+	<!ENTITY brvbar "¦">
+	<!ENTITY bull "•">
+	<!ENTITY cap "∩">
+	<!ENTITY ccedil "ç">
+	<!ENTITY cedil "¸">
+	<!ENTITY cent "¢">
+	<!ENTITY chi "χ">
+	<!ENTITY circ "ˆ">
+	<!ENTITY clubs "♣">
+	<!ENTITY cong "≅">
+	<!ENTITY copy "©">
+	<!ENTITY crarr "↵">
+	<!ENTITY cup "∪">
+	<!ENTITY curren "¤">
+	<!ENTITY dArr "⇓">
+	<!ENTITY dagger "†">
+	<!ENTITY darr "↓">
+	<!ENTITY deg "°">
+	<!ENTITY delta "δ">
+	<!ENTITY diams "♦">
+	<!ENTITY divide "÷">
+	<!ENTITY eacute "é">
+	<!ENTITY ecirc "ê">
+	<!ENTITY egrave "è">
+	<!ENTITY empty "∅">
+	<!ENTITY emsp " ">
+	<!ENTITY ensp " ">
+	<!ENTITY epsilon "ε">
+	<!ENTITY equiv "≡">
+	<!ENTITY eta "η">
+	<!ENTITY eth "ð">
+	<!ENTITY euml "ë">
+	<!ENTITY euro "€">
+	<!ENTITY exist "∃">
+	<!ENTITY fnof "ƒ">
+	<!ENTITY forall "∀">
+	<!ENTITY frac12 "½">
+	<!ENTITY frac14 "¼">
+	<!ENTITY frac34 "¾">
+	<!ENTITY frasl "⁄">
+	<!ENTITY gamma "γ">
+	<!ENTITY ge "≥">
+	<!ENTITY gt ">">
+	<!ENTITY hArr "⇔">
+	<!ENTITY harr "↔">
+	<!ENTITY hearts "♥">
+	<!ENTITY hellip "…">
+	<!ENTITY iacute "í">
+	<!ENTITY icirc "î">
+	<!ENTITY iexcl "¡">
+	<!ENTITY igrave "ì">
+	<!ENTITY image "ℑ">
+	<!ENTITY infin "∞">
+	<!ENTITY int "∫">
+	<!ENTITY iota "ι">
+	<!ENTITY iquest "¿">
+	<!ENTITY isin "∈">
+	<!ENTITY iuml "ï">
+	<!ENTITY kappa "κ">
+	<!ENTITY lArr "⇐">
+	<!ENTITY lambda "λ">
+	<!ENTITY lang "〈">
+	<!ENTITY laquo "«">
+	<!ENTITY larr "←">
+	<!ENTITY lceil "⌈">
+	<!ENTITY ldquo "“">
+	<!ENTITY le "≤">
+	<!ENTITY lfloor "⌊">
+	<!ENTITY lowast "∗">
+	<!ENTITY loz "◊">
+	<!ENTITY lrm "‎">
+	<!ENTITY lsaquo "‹">
+	<!ENTITY lsquo "‘">
+	<!ENTITY lt "<">
+	<!ENTITY macr "¯">
+	<!ENTITY mdash "—">
+	<!ENTITY micro "µ">
+	<!ENTITY middot "·">
+	<!ENTITY minus "−">
+	<!ENTITY mu "μ">
+	<!ENTITY nabla "∇">
+	<!ENTITY nbsp " ">
+	<!ENTITY ndash "–">
+	<!ENTITY ne "≠">
+	<!ENTITY ni "∋">
+	<!ENTITY not "¬">
+	<!ENTITY notin "∉">
+	<!ENTITY nsub "⊄">
+	<!ENTITY ntilde "ñ">
+	<!ENTITY nu "ν">
+	<!ENTITY oacute "ó">
+	<!ENTITY ocirc "ô">
+	<!ENTITY oelig "œ">
+	<!ENTITY ograve "ò">
+	<!ENTITY oline "‾">
+	<!ENTITY omega "ω">
+	<!ENTITY omicron "ο">
+	<!ENTITY oplus "⊕">
+	<!ENTITY or "∨">
+	<!ENTITY ordf "ª">
+	<!ENTITY ordm "º">
+	<!ENTITY oslash "ø">
+	<!ENTITY otilde "õ">
+	<!ENTITY otimes "⊗">
+	<!ENTITY ouml "ö">
+	<!ENTITY para "¶">
+	<!ENTITY part "∂">
+	<!ENTITY permil "‰">
+	<!ENTITY perp "⊥">
+	<!ENTITY phi "φ">
+	<!ENTITY pi "π">
+	<!ENTITY piv "ϖ">
+	<!ENTITY plusmn "±">
+	<!ENTITY pound "£">
+	<!ENTITY prime "′">
+	<!ENTITY prod "∏">
+	<!ENTITY prop "∝">
+	<!ENTITY psi "ψ">
+	<!ENTITY quot """>
+	<!ENTITY rArr "⇒">
+	<!ENTITY radic "√">
+	<!ENTITY rang "〉">
+	<!ENTITY raquo "»">
+	<!ENTITY rarr "→">
+	<!ENTITY rceil "⌉">
+	<!ENTITY rdquo "”">
+	<!ENTITY real "ℜ">
+	<!ENTITY reg "®">
+	<!ENTITY rfloor "⌋">
+	<!ENTITY rho "ρ">
+	<!ENTITY rlm "‏">
+	<!ENTITY rsaquo "›">
+	<!ENTITY rsquo "’">
+	<!ENTITY sbquo "‚">
+	<!ENTITY scaron "š">
+	<!ENTITY sdot "⋅">
+	<!ENTITY sect "§">
+	<!ENTITY shy "­">
+	<!ENTITY sigma "σ">
+	<!ENTITY sigmaf "ς">
+	<!ENTITY sim "∼">
+	<!ENTITY spades "♠">
+	<!ENTITY sub "⊂">
+	<!ENTITY sube "⊆">
+	<!ENTITY sum "∑">
+	<!ENTITY sup "⊃">
+	<!ENTITY sup1 "¹">
+	<!ENTITY sup2 "²">
+	<!ENTITY sup3 "³">
+	<!ENTITY supe "⊇">
+	<!ENTITY szlig "ß">
+	<!ENTITY tau "τ">
+	<!ENTITY there4 "∴">
+	<!ENTITY theta "θ">
+	<!ENTITY thetasym "ϑ">
+	<!ENTITY thinsp " ">
+	<!ENTITY thorn "þ">
+	<!ENTITY tilde "˜">
+	<!ENTITY times "×">
+	<!ENTITY trade "™">
+	<!ENTITY uArr "⇑">
+	<!ENTITY uacute "ú">
+	<!ENTITY uarr "↑">
+	<!ENTITY ucirc "û">
+	<!ENTITY ugrave "ù">
+	<!ENTITY uml "¨">
+	<!ENTITY upsih "ϒ">
+	<!ENTITY upsilon "υ">
+	<!ENTITY uuml "ü">
+	<!ENTITY weierp "℘">
+	<!ENTITY xi "ξ">
+	<!ENTITY yacute "ý">
+	<!ENTITY yen "¥">
+	<!ENTITY yuml "ÿ">
+	<!ENTITY zeta "ζ">
+	<!ENTITY zwj "‍">
+	<!ENTITY zwnj "‌">
+]>
\ No newline at end of file
diff --git a/share/magics/epsg.json b/share/magics/epsg.json
new file mode 100644
index 0000000..e43cd2b
--- /dev/null
+++ b/share/magics/epsg.json
@@ -0,0 +1,138 @@
+{
+"definitions" : [
+	{
+		"polar_north" : {
+    		"definition" : "+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -20,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "conic"
+    	}
+    },
+    {
+        "polar_north_america" : {
+    		"definition" : "+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -20,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "conic"
+    	}
+        
+        
+    },
+   {
+		"lambert" : {
+    		"definition" : "+proj=lcc +lon_0=0 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84",
+			"min_longitude" : -180,
+			"min_latitude" : -20,
+			"max_longitude" : +180,
+			"max_latitude" : 90,
+            "method" : "conic"
+    	}
+    },
+    {
+        "EPSG:32661" : {
+    		"definition" : "+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -20,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "conic"
+            
+    	}
+	},
+    {
+        "EPSG:4326" : {
+            "definition" : "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -90,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "simple"
+        }
+    },
+    {
+        "EPSG:3857" : {
+            "definition" : "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -85,
+			"max_longitude" : 180,
+			"max_latitude" : 85,
+            "method" : "simple"
+        }
+    },
+    {
+        "cylindrical" : {
+            "definition" : "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -90,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "simple"
+        }
+    },
+    {
+    "geos" : {
+    		"definition" : "+proj=geos +h=42164000 +ellps=WGS84",
+			"min_longitude" : -70,
+			"min_latitude" : -80,
+			"max_longitude" : 70,
+			"max_latitude" : 80,
+            "method" : "geos"
+    	}
+     },
+     {
+    "goode" : {
+    		"definition" : "+proj=goode +ellps=WGS84",
+			"min_longitude" : -180,
+			"min_latitude" : -90,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "geos"
+    	}
+     }  ,
+       {
+    "collignon" : {
+    		"definition" : "+proj=collg +ellps=WGS84",
+			"min_longitude" : -180,
+			"min_latitude" : -90,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "geos"
+    	}
+     },
+     {
+    "mollweide" : {
+    		"definition" : "+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m",
+			"min_longitude" : -180,
+			"min_latitude" : -90,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "geos"
+    	}
+     },
+	{
+    "google" : {
+    		"definition" : "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m", 
+			"min_longitude" : -180,
+			"min_latitude" : -90,
+			"max_longitude" : 180,
+			"max_latitude" : 90,
+            "method" : "geos"
+    	}
+     },
+      {
+    "bonne" : {
+    		"definition" : "+proj=bonne +lon_0=0 +x_0=0 +y_0=0 +lat_1=60 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
+			"min_longitude" : -180,
+			"min_latitude" : -89,
+			"max_longitude" : 180,
+			"max_latitude" : 89,
+            "method" : "geos"
+    	}
+     }
+    
+]
+}
diff --git a/share/magics/kml_logo.png b/share/magics/kml_logo.png
new file mode 100644
index 0000000..42c2001
Binary files /dev/null and b/share/magics/kml_logo.png differ
diff --git a/share/magics/level.xml b/share/magics/level.xml
new file mode 100644
index 0000000..e28537e
--- /dev/null
+++ b/share/magics/level.xml
@@ -0,0 +1,13 @@
+<levels>
+    <level code='100'
+        short_title='hPa'
+        long_title='hPa'/>
+    <level code='109'
+        short_title='Hybrid'
+        long_title='Hybrid level'/>
+    <level code='1'
+        short_title='Sfc'
+        long_title='Surface'/>
+</levels>   
+   
+   
diff --git a/share/magics/magics_kml_icons.png b/share/magics/magics_kml_icons.png
new file mode 100644
index 0000000..002adfc
Binary files /dev/null and b/share/magics/magics_kml_icons.png differ
diff --git a/share/magics/magics_kml_icons.svg b/share/magics/magics_kml_icons.svg
new file mode 100644
index 0000000..8cc550f
--- /dev/null
+++ b/share/magics/magics_kml_icons.svg
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="640"
+   height="640"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.48.2 r9819"
+   sodipodi:docname="drawing.svg"
+   inkscape:export-filename="/home/cgm/drawing.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <title
+     id="title2987">Magics icons for KML</title>
+  <defs
+     id="defs4">
+    <inkscape:perspective
+       id="perspective10"
+       inkscape:persp3d-origin="300 : 400 : 1"
+       inkscape:vp_z="700 : 600 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="-50 : 600 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <inkscape:perspective
+       id="perspective45"
+       inkscape:persp3d-origin="300 : 400 : 1"
+       inkscape:vp_z="700 : 600 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="-50 : 600 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <inkscape:perspective
+       id="perspective31"
+       inkscape:persp3d-origin="300 : 400 : 1"
+       inkscape:vp_z="700 : 600 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="-50 : 600 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <inkscape:perspective
+       id="perspective10-0"
+       inkscape:persp3d-origin="300 : 400 : 1"
+       inkscape:vp_z="700 : 600 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="-50 : 600 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <linearGradient
+       id="linearGradient1683">
+      <stop
+         id="stop1684"
+         offset="0.0000000"
+         style="stop-color:#68db0c;stop-opacity:1.0000000;" />
+      <stop
+         id="stop1685"
+         offset="1.0000000"
+         style="stop-color:#387606;stop-opacity:1.0000000;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient1694">
+      <stop
+         id="stop1695"
+         offset="0.0000000"
+         style="stop-color:#ffffff;stop-opacity:0.0000000;" />
+      <stop
+         id="stop1696"
+         offset="1.0000000"
+         style="stop-color:#ffffff;stop-opacity:1.0000000;" />
+    </linearGradient>
+    <filter
+       height="3.0366831"
+       y="-1.0183415"
+       width="1.180557"
+       x="-0.090278499"
+       id="filter3347"
+       inkscape:collect="always">
+      <feGaussianBlur
+         id="feGaussianBlur3349"
+         stdDeviation="7.5769449"
+         inkscape:collect="always" />
+    </filter>
+    <inkscape:perspective
+       id="perspective10-1"
+       inkscape:persp3d-origin="300 : 400 : 1"
+       inkscape:vp_z="700 : 600 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="-50 : 600 : 1"
+       sodipodi:type="inkscape:persp3d" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1.24"
+     inkscape:cx="276.63413"
+     inkscape:cy="520"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:window-width="1303"
+     inkscape:window-height="867"
+     inkscape:window-x="578"
+     inkscape:window-y="86"
+     inkscape:window-maximized="0">
+    <inkscape:grid
+       type="xygrid"
+       id="grid2985"
+       empspacing="64"
+       visible="true"
+       enabled="true"
+       snapvisiblegridlinesonly="false"
+       dotted="false" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title>Magics icons for KML</dc:title>
+        <dc:date>2012-07 </dc:date>
+        <dc:creator>
+          <cc:Agent>
+            <dc:title>Stephan Siemen</dc:title>
+          </cc:Agent>
+        </dc:creator>
+        <dc:publisher>
+          <cc:Agent>
+            <dc:title>ECMWF</dc:title>
+          </cc:Agent>
+        </dc:publisher>
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li>KML icons</rdf:li>
+          </rdf:Bag>
+        </dc:subject>
+        <cc:license
+           rdf:resource="Apache License 2.0" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-412.36218)">
+    <path
+       style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.73300004;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 40.853354,466.19405 -18.94546,0 0,-18.64556 -10.385672,4.44864 19.621144,-26.90307 20.703073,25.97351 L 41,447.36218 40.853354,466.19405 z"
+       id="path3369"
+       sodipodi:nodetypes="cccccccc"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.73300003999999985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 104.85335,466.19405 -18.94546,0 0,-18.64556 -10.385672,4.44864 19.621148,-26.90307 20.703074,25.97351 L 105,447.36218 l -0.14665,18.83187 z"
+       id="path3369-0"
+       sodipodi:nodetypes="cccccccc"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.73300003999999985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 167.85335,466.19405 -18.94546,0 0,-18.64556 -10.38567,4.44864 19.62115,-26.90307 20.70307,25.97351 L 168,447.36218 l -0.14665,18.83187 z"
+       id="path3369-0-7"
+       sodipodi:nodetypes="cccccccc"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
diff --git a/share/magics/obs.xml b/share/magics/obs.xml
new file mode 100644
index 0000000..4b13238
--- /dev/null
+++ b/share/magics/obs.xml
@@ -0,0 +1,110 @@
+<!--
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ This file describes the layout of the various observation messages 
+ in WMO and ICAO conventions   
+
+-->
+<observations>
+
+ <obs_template type='pilot' rows='3' columns='3'>
+	<obs_station_ring row='0' column='0'/>
+	<obs_wind/>
+	<obs_identification row='2' column='0'/>
+	<obs_time_plot row='0' column='-1' />
+ </obs_template>
+
+ <obs_template type='metar' rows='3' columns='3'>
+	<obs_wind/>
+	<obs_temperature row='1' column='-1'/>
+	<obs_pressure row='1' column='1'/>
+	<obs_dewpoint row='-1' column='-1'/>
+	<obs_cloud low_row='-1' low_column='0' medium_row='1' medium_column='0' high_row='2' high_column='0'/>
+ </obs_template>
+
+ <obs_template type='dribu_surface' rows='3' columns='3'>
+	<obs_station_ring/>
+ </obs_template>
+
+ <obs_template type='synop' rows='5' columns='5'>
+	<obs_cloud_wind/>
+	<obs_temperature row='1' column='-1'/>
+	<obs_pressure row='1' column='1'/>
+	<obs_pressure_tendency row='0' column='1'/>
+	<obs_dewpoint row='-1' column='-1'/>
+	<obs_visibility row='0' column='-2'/>
+	<obs_present_weather row='0' column='-1'/>
+	<obs_past_weather row='-1' column='1'/>
+	<obs_cloud low_row='-1' low_column='0' medium_row='1' medium_column='0' high_row='2' high_column='0'/>
+ </obs_template>
+
+ <obs_template type='synop_ship' rows='3' columns='3'>
+	<obs_cloud_wind/>
+	<obs_temperature row='1' column='-1'/>
+	<obs_pressure row='1' column='1'/>
+	<obs_pressure_tendency row='0' column='1'/>
+	<obs_dewpoint row='-1' column='-1'/>
+	<obs_visibility row='0' column='-2'/>
+	<obs_present_weather row='0' column='-1'/>
+	<obs_past_weather row='-1' column='1'/>
+	<obs_cloud low_row='-1' low_column='0'
+	medium_row='1' medium_column='0'
+	high_row='2' high_column='0'/>
+ </obs_template>
+
+ <obs_template type='satob' rows='3' columns='3'>
+	<obs_station_ring row='0' column='0'/>
+	<obs_wind/>
+	<obs_temperature row='1' column='-1'/>
+	<obs_pressure_level row='1' column='1'/>	
+	<obs_time_plot row='0' column='-1'/>
+	<obs_identification row='-2' column='-1'/>
+ </obs_template>
+
+ <obs_template type='airep' rows='2' columns='3'>
+	<obs_station_ring row='0' column='0'/>
+	<obs_wind/>
+	<obs_temperature row='1' column='-1'/>
+	<obs_pressure_level row='1' column='1'/>	
+	<obs_time_plot row='0' column='-1'/>
+	<obs_identification row='-1' column='-1'/>
+ </obs_template>
+
+ <obs_template type='temp' rows='4' columns='3'>:
+	<obs_station_ring row='0' column='0'/>
+	<obs_wind/>
+	<obs_temperature row='1' column='-1'/>
+	<obs_dewpoint row='-1' column='-1'/>
+	<obs_height row='1' column='1'/>
+	<obs_thickness row='0' column='1'/>
+	<obs_time_plot row='0' column='-1'/>
+	<obs_identification row='-2' column='-1'/>
+ </obs_template>
+
+ <obs_template type='position' rows='1' columns='1'>:
+     <obs_station_ring row='0' column='0'/>
+ </obs_template>
+
+ <obs_template type='demo' rows='3' columns='3'>:
+     <obs_station_ring row='0' column='0'/>
+     <obs_demo_item_1 row='-1' column='1'/>
+     <obs_demo_item_2 row='1' column='-1'/>
+ </obs_template>
+
+
+
+</observations>
diff --git a/share/magics/satellite.xml b/share/magics/satellite.xml
new file mode 100644
index 0000000..e4696f5
--- /dev/null
+++ b/share/magics/satellite.xml
@@ -0,0 +1,13 @@
+<satellites>
+    <identifier code='52'
+        short_title='Met5'
+        long_title='Meteosat 5'/>
+    <centre code='54'
+        short_title='Met7'
+        long_title='Meteosat 7'/>
+    <centre code='55'
+        short_title='Met8'
+        long_title='Meteosat 8'/>
+    
+</satellites>
+
diff --git a/share/magics/symbols.svg b/share/magics/symbols.svg
new file mode 100644
index 0000000..61ba562
--- /dev/null
+++ b/share/magics/symbols.svg
@@ -0,0 +1,860 @@
+<?xml version='1.0' standalone='no'?>
+<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
+
+<svg width='100%' height='100%' version='1.1' xmlns='http://www.w3.org/2000/svg'>
+   <g id='unknown'>
+	<polyline points='-0.3,0.4 0.3,0.4 0.3,0.1 -0.3,0.1 -0.3,-0.2 0.3,-0.2' fill='none'/>
+	<circle cx='0' cy='-0.4' r='0.1' fill='8'/>
+   </g>
+
+   <g id='box'>
+	<polyline points='-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5' fill='none'/>
+   </g>
+   <g id='circle'>
+   	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   </g>
+   <g id='snowflake'>
+	<snowflake cx='0' cy='0' r='0.3'/>
+   </g>
+   <g id='plus'>
+   	<polyline points='-0.5,0 0.5,0' fill='none'/>
+	<polyline points='0,-0.5 0,0.5' fill='none'/>
+   </g>
+   
+   <g id='magics_0'>
+	<polyline points='-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5' fill='none'/>
+   </g>
+   <g id='magics_1'>
+   	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   </g>
+   <g id='magics_2'>
+   	<polyline points='-0.5,-0.5 0.5,-0.5 0,0.5 -0.5,-0.5' fill='none'/>
+   </g>
+   <g id='magics_3'>
+   	<polyline points='-0.5,0 0.5,0' fill='none'/>
+	<polyline points='0,-0.5 0,0.5' fill='none'/>
+   </g>
+   <g id='magics_4'>
+   	<polyline points='-0.5,-0.5 0.5,0.5' fill='none'/>
+	<polyline points='-0.5,0.5 0.5,-0.5' fill='none'/>
+   </g>
+   <g id='magics_5'>
+   	<polyline points='0,-0.5 0.5,0, 0,0.5 -0.5,0 0,-0.5' fill='none'/>
+   </g>
+   <g id='magics_6'>
+   	<polyline points='-0.5,0.5 0.5,0.5 0,-0.5 -0.5,0.5' fill='none'/>
+   </g>
+   <g id='magics_7'>
+	<polyline points='-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5' fill='none'/>
+   	<polyline points='-0.5,-0.5 0.5,0.5' fill='none'/>
+	<polyline points='-0.5,0.5 0.5,-0.5' fill='none'/>	
+   </g>  
+   <g id='magics_8'>
+      	<polyline points='-0.5,0 0.5,0' fill='none'/>
+   	<polyline points='-0.5,-0.5 0.5,0.5' fill='none'/>
+	<polyline points='-0.5,0.5 0.5,-0.5' fill='none'/>	
+   </g>
+   <g id='magics_9'>
+     	<polyline points='0,-0.5 0.5,0, 0,0.5 -0.5,0 0,-0.5' fill='none'/> 
+   	<polyline points='-0.5,0 0.5,0' fill='none'/>
+	<polyline points='0,-0.5 0,0.5' fill='none'/>   
+   </g>
+   <g id='magics_10'>
+   	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   	<polyline points='-0.5,0 0.5,0' fill='none'/>
+	<polyline points='0,-0.5 0,0.5' fill='none'/>
+   </g>
+   <g id='magics_11'>
+      	<polyline points='-0.5,-0.5 0.5,-0.5 0,0.5 -0.5,-0.5' fill='none'/>
+   	<polyline points='-0.5,0.5 0.5,0.5 0,-0.5 -0.5,0.5' fill='none'/>
+   </g>
+   <g id='magics_12'>
+	<polyline points='-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5' fill='none'/>
+   	<polyline points='-0.5,0 0.5,0' fill='none'/>
+	<polyline points='0,-0.5 0,0.5' fill='none'/>
+   </g>
+   <g id='magics_13'>
+      	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   	<polyline points='-0.5,-0.5 0.5,0.5' fill='none'/>
+	<polyline points='-0.5,0.5 0.5,-0.5' fill='none'/>
+   </g>
+   <g id='magics_14'>
+	<polyline points='-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5' fill='none'/>
+	<polyline points='-0.5,-0.5 0.5,-0.5 0,0.5 -0.5,-0.5' fill='none'/>
+   </g>
+   <g id='magics_15'>
+   	<circle cx='0' cy='0' r='0.5' fill='8'/>
+   </g>
+   <g id='magics_16'>
+      	<polyline points='-0.5,-0.5 0.5,-0.5 0,0.5 -0.5,-0.5' fill='black'/>
+   	<polyline points='-0.5,0.5 0.5,0.5 0,-0.5 -0.5,0.5' fill='black'/>
+   </g>
+   <g id='magics_17'>
+   	<polyline points='0,-0.5 0.5,0, 0,0.5 -0.5,0 0,-0.5' fill='black'/>
+   </g>
+   <g id='magics_18'>
+	<polyline points='-0.5,-0.5 -0.5,0.5 0.5,0.5 0.5,-0.5 -0.5,-0.5' fill='black'/>
+   </g>
+   <g id='magics_19'>
+   	<polyline points='-0.5,-0.5 0.5,-0.5 0,0.5 -0.5,-0.5' fill='black'/>
+   </g>
+   <g id='magics_20'>
+   	<polyline points='-0.5,0.5 0.5,0.5 0,-0.5 -0.5,0.5' fill='black'/>
+   </g>
+   <g id='magics_21'>
+ 	<circle cx='0' cy='0' r='0.5' fill='1'/>
+   </g>
+   <g id='magics_22'>
+ 	<circle cx='0' cy='0' r='0.5' fill='2'/>
+   </g>
+   <g id='magics_23'>
+ 	<circle cx='0' cy='0' r='0.5' fill='3'/>
+   </g>
+   <g id='magics_24'>
+ 	<circle cx='0' cy='0' r='0.5' fill='4'/>
+   </g>
+   <g id='magics_25'>
+ 	<circle cx='0' cy='0' r='0.5' fill='5'/>
+   </g>
+   <g id='magics_26'>
+ 	<circle cx='0' cy='0' r='0.5' fill='6'/>
+   </g>
+   <g id='magics_27'>
+ 	<circle cx='0' cy='0' r='0.5' fill='7'/>
+   </g>
+   <g id='magics_28'>
+ 	<circle cx='0' cy='0' r='0.5' fill='8'/>
+   </g>
+
+   <g id='ww_00'>
+   </g>
+   <g id='ww_01'>
+   </g>
+   <g id='ww_02'>
+   </g>
+   <g id='ww_03'>
+   </g>
+   <g id='ww_04'>
+	<polyline points='-0.3,-0.3 -0.3,0.2 -0.2,0.3 -0.1,0.2 0,0.3 0.1,0.2 0.2,0.3' fill='none'/>
+   </g>
+   <g id='ww_05'>
+	<polyline points='-0.2,-0.2 0.2,0.2 0.35,0.25 0.4,0.21 0.5,0.1 0.5,-0.1 0.4,-0.21 0.35,-0.25 0.2,-0.2 -0.2,0.2 -0.35,0.25 -0.4,0.21 -0.5,0.1 -0.5,-0.1 -0.4,-0.21 -0.35,-0.25 -0.2,-0.2' fill='none'/>
+   </g>
+   <g id='ww_06'>
+	<polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+   </g>
+   <g id='ww_07'>
+	<polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+	<polyline points='0.,0.45 0.,-0.45' fill='none'/>
+   </g>
+   
+   
+   <g id='ww_09'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0 0.38,0' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+	<polyline points='0.39,0.45 0.42,0.35 0.46,0.1 0.46,-0.1 0.42,-0.35 0.39,-0.45' fill='none'/>
+	<polyline points='-0.39,0.45 -0.42,0.35 -0.46,0.1 -0.46,-0.1 -0.42,-0.35 -0.39,-0.45' fill='none'/>
+   </g>
+   <g id='ww_10'>
+        <polyline points='-0.4,0.15 0.4,0.15' fill='none'/>
+        <polyline points='-0.4,-0.15 0.4,-0.15' fill='none'/>
+   </g>
+   <g id='ww_11'>
+        <polyline points='-0.4,0.3 -0.1,0.3' fill='none'/>
+        <polyline points='0.1,0.3  0.4,0.3' fill='none'/>
+        <polyline points='-0.4,0 -0.1,0' fill='none'/>
+        <polyline points='0.1,0  0.4,0' fill='none'/>
+        <polyline points='-0.4,-0.3 -0.1,-0.3' fill='none'/>
+        <polyline points='0.1,-0.3  0.4,-0.3' fill='none'/>
+   </g>
+   <g id='ww_12'>
+        <polyline points='-0.4,0.3 -0.1,0.3' fill='none'/>
+        <polyline points='0.1,0.3  0.4,0.3' fill='none'/>
+        <polyline points='-0.4,0 -0.1,0' fill='none'/>
+        <polyline points='0.1,0  0.4,0' fill='none'/>
+        <polyline points='-0.4,-0.3 0.4,-0.3' fill='none'/>
+   </g>
+   <g id='ww_13'>
+        <polyline points='0.3,0.4 -0.3,0 0.3,-0.4' fill='none'/>
+        <polyline points='0.2,-0.2  0.3,-0.4 0.1,-0.4' fill='none'/>
+   </g>
+   <g id='ww_14'>
+        <circle cx='0' cy='0' r='0.1' fill='8'/>
+	<polyline points='0.4,-0.17 0.35,-0.25 -0.35,-0.25 -0.4,-0.17' fill='none'/>
+   </g>
+   <g id='ww_15'>
+        <circle cx='0' cy='0' r='0.1' fill='8'/>
+        <polyline points='0.33,0.4 0.25,0.35 0.25,-0.35 0.33,-0.4' fill='none'/>
+        <polyline points='-0.33,0.4 -0.25,0.35 -0.25,-0.35 -0.33,-0.4' fill='none'/>
+   </g>
+   <g id='ww_16'>
+        <circle cx='0' cy='0' r='0.1' fill='8'/>
+        <polyline points='0.17,0.4 0.25,0.35 0.25,-0.35 0.17,-0.4' fill='none'/>
+        <polyline points='-0.17,0.4 -0.25,0.35 -0.25,-0.35 -0.17,-0.4' fill='none'/>
+   </g>   
+   <g id='ww_17'>
+	<lightning cx='0' cy='0.3'  r='0.5'/>
+   </g>
+   <g id='ww_18'>
+       <polyline points='0,0.1 0.2,0.2 0,-0.3 -0.2,0.2 0,0.1' fill='none'/>
+   </g>
+   <g id='ww_19'>
+       <polyline points='-0.2,0.4 -0.1,0.3 -0.1,-0.3 -0.2,-0.4' fill='none'/> 
+       <polyline points='0.2,0.4 0.1,0.3 0.1,-0.3 0.2,-0.4' fill='none'/> 
+   </g>
+   <g id='ww_20'>
+        <drizzle cx='0' cy='0' r='0.2'/>
+	<polyline points='0,0.45 0.3,0.45 0.3,-0.45 0,-0.45' fill='none'/>
+   </g>
+   <g id='ww_21'>
+        <circle cx='0' cy='0' r='0.2' fill='8'/>
+	<polyline points='0,0.45 0.3,0.45 0.3,-0.45 0,-0.45' fill='none'/>
+   </g>
+   <g id='ww_22'>
+        <snowflake cx='0' cy='0' r='0.2'/>
+	<polyline points='0,0.45 0.3,0.45 0.3,-0.45 0,-0.45' fill='none'/>
+   </g>
+   <g id='ww_23'>
+        <circle cx='0' cy='0.25' r='0.2' fill='8'/>
+        <snowflake cx='0' cy='-0.25' r='0.2'/>
+	<polyline points='0,0.5 0.3,0.5 0.3,-0.5 0,-0.5' fill='none'/>
+   </g>
+   <g id='ww_24'>
+	<polyline points='0.15,0.5 0.45,0.5 0.45,-0.5 0.15,-0.5' fill='none'/>
+        <polyline points='-0.3,-0.1 -0.35,0.05 -0.32,0.1 -0.25,0.15 -0.18,0.15 -0.13,0.1 0.13,-0.11  0.13,-0.11 0.18,-0.15 0.25,-0.15 0.32,-0.1 0.35,-0.05 0.3,0.1' fill='none'/>
+   </g>
+<g id='ww_25'>
+ <polyline points='0.15,0.5 0.45,0.5 0.45,-0.5 0.15,-0.5' fill='none'/>
+ <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+ <triangle cx='0' cy='-0.3' r='-0.3' fill='0'/>
+</g>
+<g id='ww_26'>
+ <polyline points='0.15,0.5 0.45,0.5 0.45,-0.5 0.15,-0.5' fill='none'/>
+ <snowflake cx='0' cy='0.3' r='0.2'/>
+ <triangle  cx='0' cy='-0.3' r='-0.3' fill='0'/>
+</g>
+<g id='ww_27'>
+ <polyline points='0.15,0.5 0.45,0.5 0.45,-0.5 0.15,-0.5' fill='none'/>
+ <triangle cx='0' cy='0.25' r='0.25' fill='0'/>
+ <triangle cx='0' cy='-0.3' r='-0.3' fill='0'/>
+</g>
+<g id='ww_28'>
+        <polyline points='-0.35,0.3 0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+        <polyline points='0.5,-0.45 0.5,0.45' fill='none'/>
+        <polyline points='0.5,-0.45 0.35,-0.45' fill='none'/>
+        <polyline points='0.5,0.45 0.35,0.45' fill='none'/>
+</g>
+<g id='ww_29'> 
+      <polyline points='0.5,-0.45 0.5,0.45' fill='none'/>
+        <polyline points='0.5,-0.45 0.35,-0.45' fill='none'/>
+        <polyline points='0.5,0.45 0.35,0.45' fill='none'/>
+        <lightning cx='0' cy='0'  r='0.4'/>
+</g>
+   <g id='ww_30'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0 0.38,0' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+	<polyline points='0.46,0.45 0.46,-0.45' fill='none'/>
+   </g>
+   <g id='ww_31'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0 0.38,0' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+   </g>
+   <g id='ww_32'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0 0.38,0' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+	<polyline points='-0.46,0.45 -0.46,-0.45' fill='none'/>
+   </g>
+   <g id='ww_33'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0.05  0.34,0.05' fill='none'/>
+        <polyline points='-0.38,-0.05 0.34,-0.05' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+	<polyline points='0.46,0.45 0.46,-0.45' fill='none'/>
+   </g>
+   <g id='ww_34'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0.05  0.34,0.05' fill='none'/>
+        <polyline points='-0.38,-0.05 0.34,-0.05' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+   </g>
+   <g id='ww_35'>
+        <polyline points='0.2,0.30 0.1,0.38 0,0.4 -0.1,0.38 -0.2,0.27 -0.2,0.20 -0.16,0.14 0,0 0.16,-0.14 0.2,-0.20 0.2,-0.27 0.1,-0.38 0,-0.4 -0.1,-0.38 -0.2,-0.30' fill='none'/>
+        <polyline points='-0.38,0.05  0.34,0.05' fill='none'/>
+        <polyline points='-0.38,-0.05 0.34,-0.05' fill='none'/>
+        <polyline points='0.4,0 0.22,0.13' fill='none'/>
+        <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+	<polyline points='-0.46,0.45 -0.46,-0.45' fill='none'/>
+   </g>
+   <g id='ww_36'>
+       <polyline points='-0.38,0 0.38,0' fill='none'/>
+       <polyline points='0.4,0 0.22,0.13' fill='none'/>
+       <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+       <polyline points='0,-0.4 0,0.38' fill='none'/>
+       <polyline points='0,-0.4 -0.13,-0.22' fill='none'/>
+       <polyline points='0,-0.4  0.13,-0.22' fill='none'/>
+   </g>
+   <g id='ww_37'>
+       <polyline points='-0.38,0.05  0.34,0.05' fill='none'/>
+       <polyline points='-0.38,-0.05 0.34,-0.05' fill='none'/>
+       <polyline points='0.4,0 0.22,0.13' fill='none'/>
+       <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+       <polyline points='0,-0.4 0,0.38' fill='none'/>
+       <polyline points='0,-0.4 -0.13,-0.22' fill='none'/>
+       <polyline points='0,-0.4  0.13,-0.22' fill='none'/>
+   </g>
+   <g id='ww_38'>
+       <polyline points='-0.38,0 0.38,0' fill='none'/>
+       <polyline points='0.4,0 0.22,0.13' fill='none'/>
+       <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+       <polyline points='0,0.4 0,-0.38' fill='none'/>
+       <polyline points='0,0.4 -0.13,0.22' fill='none'/>
+       <polyline points='0,0.4  0.13,0.22' fill='none'/>
+   </g>
+   <g id='ww_39'>
+       <polyline points='-0.38,0.05  0.34,0.05' fill='none'/>
+       <polyline points='-0.38,-0.05 0.34,-0.05' fill='none'/>
+       <polyline points='0.4,0 0.22,0.13' fill='none'/>
+       <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+       <polyline points='0,0.4 0,-0.38' fill='none'/>
+       <polyline points='0,0.4 -0.13,0.22' fill='none'/>
+       <polyline points='0,0.4  0.13,0.22' fill='none'/>
+   </g>
+   <g id='ww_40'>
+        <polyline points='-0.35,0.3 0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+	<polyline points='0.39,0.45 0.42,0.35 0.46,0.1 0.46,-0.1 0.42,-0.35 0.39,-0.45' fill='none'/>
+	<polyline points='-0.39,0.45 -0.42,0.35 -0.46,0.1 -0.46,-0.1 -0.42,-0.35 -0.39,-0.45' fill='none'/>
+   </g>
+   <g id='ww_41'>
+        <polyline points='-0.35,0.3 -0.1,0.3' fill='none'/>
+        <polyline points='0.1,0.3  0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 -0.1,-0.3' fill='none'/>
+        <polyline points='0.1,-0.3  0.35,-0.3' fill='none'/>
+   </g>
+   <g id='ww_42'>
+        <polyline points='-0.35,0.3 -0.1,0.3' fill='none'/>
+        <polyline points='0.1,0.3  0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+        <polyline points='0.5,-0.35 0.5,0.35' fill='none'/>
+   </g>
+   <g id='ww_43'>
+        <polyline points='-0.35,0.3 0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+        <polyline points='0.5,-0.35 0.5,0.35' fill='none'/>
+   </g>
+   <g id='ww_44'>
+        <polyline points='-0.35,0.3 -0.1,0.3' fill='none'/>
+        <polyline points='0.1,0.3 0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+   </g>
+   <g id='ww_45'>
+        <polyline points='-0.35,0.3 0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+   </g>
+   <g id='ww_46'>
+        <polyline points='-0.35,0.3 -0.1,0.3' fill='none'/>
+        <polyline points='0.1,0.3  0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+        <polyline points='-0.5,-0.35 -0.5,0.35' fill='none'/>
+   </g>
+   <g id='ww_47'>
+        <polyline points='-0.35,0.3 0.35,0.3' fill='none'/>
+        <polyline points='-0.35,0 0.35,0' fill='none'/>
+        <polyline points='-0.35,-0.3 0.35,-0.3' fill='none'/>
+        <polyline points='-0.5,-0.35 -0.5,0.35' fill='none'/>
+   </g>
+
+   <g id='ww_50'>
+        <drizzle cx='0' cy='0' r='0.2'/>
+   </g>
+   <g id='ww_51'>
+	<drizzle cx='-0.3' cy='0' r='0.2'/>
+	<drizzle cx='0.3'  cy='0' r='0.2'/>
+   </g>
+   <g id='ww_52'>
+	<drizzle cx='0' cy='-0.3' r='0.2'/>
+	<drizzle cx='0' cy='0.3'  r='0.2'/>
+   </g>
+   <g id='ww_53'>
+        <drizzle cx='0' cy='0.3' r='0.2'/>
+        <drizzle cx='-0.3' cy='-0.3' r='0.2'/>
+        <drizzle cx='0.3' cy='-0.3' r='0.2'/>
+   </g>
+   <g id='ww_54'>
+        <drizzle cx='0' cy='0.45' r='0.2'/>
+        <drizzle cx='0' cy='0' r='0.2'/>
+        <drizzle cx='0' cy='-0.45' r='0.2'/>
+   </g>
+   <g id='ww_55'>
+        <drizzle cx='-0.3' cy='0' r='0.2'/>
+        <drizzle cx='0.3' cy='0' r='0.2'/>
+	<drizzle cx='0' cy='0.45' r='0.2'/>
+	<drizzle cx='0' cy='-0.45' r='0.2'/>
+   </g>
+
+   <g id='ww_58'>
+        <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+        <drizzle cx='0' cy='-0.3' r='0.2'/>
+   </g>
+   <g id='ww_59'>
+        <drizzle cx='0' cy='0.45' r='0.2'/>
+        <circle cx='0' cy='0' r='0.2' fill='8'/>
+        <drizzle cx='0' cy='-0.45' r='0.2'/>
+   </g>
+   <g id='ww_60'>
+        <circle cx='0' cy='0' r='0.2' fill='8'/>
+   </g>
+   <g id='ww_61'>
+        <circle cx='-0.3' cy='0' r='0.2' fill='8'/>
+        <circle cx='0.3' cy='0' r='0.2' fill='8'/>
+   </g>
+   <g id='ww_62'>
+        <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+        <circle cx='0' cy='-0.3' r='0.2' fill='8'/>
+   </g>
+   <g id='ww_63'>
+        <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+        <circle cx='-0.3' cy='-0.3' r='0.2' fill='8'/>
+        <circle cx='0.3' cy='-0.3' r='0.2' fill='8'/>
+   </g>
+   <g id='ww_64'>
+        <circle cx='0' cy='0.45' r='0.2' fill='8'/>
+        <circle cx='0' cy='0' r='0.2' fill='8'/>
+        <circle cx='0' cy='-0.45' r='0.2' fill='8'/>
+   </g>
+   <g id='ww_65'>
+        <circle cx='-0.3' cy='0' r='0.2' fill='8'/>
+        <circle cx='0.3' cy='0' r='0.2' fill='8'/>
+	<circle cx='0' cy='0.45' r='0.2' fill='8'/>
+	<circle cx='0' cy='-0.45' r='0.2' fill='8'/>
+   </g>
+
+   <g id='ww_68'>
+        <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+        <snowflake cx='0' cy='-0.3' r='0.2'/>
+   </g>
+   <g id='ww_69'>
+        <snowflake cx='0' cy='0.45' r='0.2'/>
+        <circle cx='0' cy='0' r='0.2' fill='8'/>
+        <snowflake cx='0' cy='-0.45' r='0.2'/>
+   </g>
+   <g id='ww_70'>
+	<snowflake cx='0' cy='0' r='0.2'/>
+   </g>
+   <g id='ww_71'>
+	<snowflake cx='-0.3' cy='0' r='0.2'/>
+	<snowflake cx='0.3'  cy='0' r='0.2'/>
+   </g>
+   <g id='ww_72'>
+	<snowflake cx='0' cy='-0.3' r='0.2'/>
+	<snowflake cx='0' cy='0.3'  r='0.2'/>
+   </g>
+   <g id='ww_73'>
+        <snowflake cx='0' cy='0.3' r='0.2'/>
+        <snowflake cx='-0.3' cy='-0.3' r='0.2'/>
+        <snowflake cx='0.3' cy='-0.3' r='0.2'/>
+   </g>
+   <g id='ww_74'>
+        <snowflake cx='0' cy='0.45' r='0.2'/>
+        <snowflake cx='0' cy='0' r='0.2'/>
+        <snowflake cx='0' cy='-0.45' r='0.2'/>
+   </g>
+   <g id='ww_75'>
+        <snowflake cx='-0.3' cy='0' r='0.2'/>
+        <snowflake cx='0.3' cy='0' r='0.2'/>
+	<snowflake cx='0' cy='0.45' r='0.2'/>
+	<snowflake cx='0' cy='-0.45' r='0.2'/>
+   </g>
+   <g id='ww_76'>
+	<polyline points='-0.45,0 0.45,0' fill='none'/>
+	<polyline points='-0.3,0.2 -0.45,0. -0.3,-0.2' fill='none'/>
+	<polyline points='0.3,0.2 0.45,0. 0.3,-0.2' fill='none'/>
+   </g>
+   <g id='ww_77'>
+	<triangle cx='0' cy='0' r='0.3' fill='0'/>
+	<polyline points='-0.35,0 0.35,0' fill='none'/>
+   </g>
+   <g id='ww_78'>
+	<snowflake cx='0' cy='0' r='0.2'/>
+	<polyline points='-0.35,0 0.35,0' fill='none'/>
+   </g>
+   <g id='ww_79'>
+	<polyline points='0,0.45 0.4,-0.35 -0.4,-0.35 0,0.45' fill='none'/>
+	<circle cx='0' cy='0' r='0.05' fill='8'/>
+   </g>
+   <g id='ww_80'>
+        <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+	<triangle cx='0' cy='-0.3' r='-0.3' fill='0'/>
+   </g>
+   <g id='ww_81'>
+        <circle cx='0' cy='0.3' r='0.2' fill='8'/>
+	<triangle cx='0' cy='-0.3' r='-0.3' fill='0' line='1'/>
+   </g>
+   <g id='ww_82'>
+        <circle cx='0' cy='0.45' r='0.2' fill='8'/>
+        <circle cx='0' cy='0' r='0.2' fill='8'/>
+        <triangle cx='0' cy='-0.45' r='-0.3' fill='0'/>
+   </g>
+   <g id='ww_83'>
+        <circle cx='0' cy='0.45' r='0.2' fill='8'/>
+        <snowflake cx='0' cy='0' r='0.2'/>
+        <triangle cx='0' cy='-0.45' r='-0.3' fill='0'/>
+   </g>
+   <g id='ww_84'>
+        <circle cx='0' cy='0.45' r='0.2' fill='8'/>
+        <snowflake cx='0' cy='0' r='0.2'/>
+        <triangle cx='0' cy='-0.45' r='-0.3' fill='0' line='1'/>
+   </g>
+<g id='ww_85'>
+  <snowflake cx='0' cy='0.3' r='0.2'/>
+ <triangle  cx='0' cy='-0.3' r='-0.3' fill='0'/>
+</g>
+<g id='ww_86'>
+  <snowflake cx='0' cy='0.3' r='0.2'/>
+  <triangle  cx='0' cy='-0.3' r='-0.3' fill='0' line='1'/>
+</g>
+<g id='ww_87'>
+  <triangle cx='0' cy='0.25' r='0.25' fill='0'/>
+  <triangle cx='0' cy='-0.3' r='-0.3' fill='0'/>
+</g>
+<g id='ww_88'>
+  <triangle cx='0' cy='0.25' r='0.25' fill='0'/>
+  <triangle cx='0' cy='-0.3' r='-0.3' fill='0' line='1'/>
+</g>
+<g id='ww_89'>
+  <triangle cx='0' cy='0.25' r='0.25' fill='1'/>
+  <triangle cx='0' cy='-0.3' r='-0.3' fill='0'/>
+</g>
+<g id='ww_90'>
+  <triangle cx='0' cy='0.25' r='0.25' fill='1'/>
+  <triangle cx='0' cy='-0.3' r='-0.3' fill='0' line='1'/>
+</g>
+
+
+   <g id='N_0'>
+ 	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   </g> 
+   <g id='N_1'>
+	<circle cx='0' cy='0' r='0.5' fill='0'/>
+	<polyline points='0,0.5 0,-0.5' fill='none'/>
+   </g> 
+   <g id='N_2'>
+	<circle cx='0' cy='0' r='0.5' fill='2'/>
+   </g> 
+   <g id='N_3'>
+	<circle cx='0' cy='0' r='0.5' fill='2'/>
+	<polyline points='0,0.5 0,-0.5' fill='none'/>
+   </g>   
+   <g id='N_4'>
+	<circle cx='0' cy='0' r='0.5' fill='4'/>
+   </g> 
+   <g id='N_5'>
+	<circle cx='0' cy='0' r='0.5' fill='4'/>
+	<polyline points='0.5,0 -0.5,0' fill='none'/>
+   </g>    
+   <g id='N_6'>
+	<circle cx='0' cy='0' r='0.5' fill='6'/>
+   </g> 
+   <g id='N_7'>
+	<circle cx='0' cy='0' r='0.5' fill='9'/>
+   </g> 
+   <g id='N_8'>
+	<circle cx='0' cy='0' r='0.5' fill='8'/>
+   </g>
+   <g id='N_9'>
+	<circle cx='0' cy='0' r='0.5' fill='0'/>
+	<polyline points='0.354,0.354 -0.354,-0.354' fill='none'/>
+	<polyline points='-0.354,0.354 0.354,-0.354' fill='none'/>
+   </g>
+   <g id='N_/'>
+      	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   	<polyline points='-0.5,-0.5 0.5,0.5' fill='none'/>
+	<polyline points='-0.5,0.5 0.5,-0.5' fill='none'/>
+   </g>
+
+   <g id='W_0'>
+ 	<circle cx='0' cy='0' r='0.5' fill='0'/>
+   </g> 
+   <g id='W_1'>
+	<circle cx='0' cy='0' r='0.5' fill='4'/>
+   </g>
+   <g id='W_2'>
+	<circle cx='0' cy='0' r='0.5' fill='9'/>
+   </g> 
+   <g id='W_3'>
+       <polyline points='-0.38,0 0.38,0' fill='none'/>
+       <polyline points='0.4,0 0.22,0.13' fill='none'/>
+       <polyline points='0.4,0 0.22,-0.13' fill='none'/>
+       <polyline points='0,0.4 0,-0.38' fill='none'/>
+       <polyline points='0,0.4 -0.13,0.22' fill='none'/>
+       <polyline points='0,0.4  0.13,0.22' fill='none'/>
+   </g>
+   <g id='W_4'>
+        <polyline points='-0.3,0.3 0.3,0.3' fill='none'/>
+        <polyline points='-0.3,0 0.3,0' fill='none'/>
+        <polyline points='-0.3,-0.3 0.3,-0.3' fill='none'/>
+   </g>
+   <g id='W_5'>
+       <drizzle cx='0' cy='0' r='0.2'/> 
+   </g>
+   <g id='W_6'>
+       <circle cx='0' cy='0' r='0.2' fill='8'/> 
+   </g>
+   <g id='W_7'>
+       <snowflake cx='0' cy='0' r='0.2'/> 
+   </g>
+   <g id='W_8'>
+       <polyline points='0.2,0.2 0,-0.3 -0.2,0.2 0.2,0.2 0' fill='none'/>
+   </g>
+   <g id='W_9'>
+	<lightning cx='0' cy='0.3'  r='0.5'/>
+   </g>
+   <g id='W_/'>
+   </g>
+
+   <g id='CL_0'>
+   </g>
+   <g id='CL_1'>
+        <polyline points='-0.5,-0.1 0.5,-0.1 0.4,0.16 0.25,0.3 0.1,0.35  -0.1,0.35 -0.25,0.3 -0.4,0.16 -0.5,-0.1' fill='none'/>   
+   </g>
+   <g id='CL_2'>
+        <polyline points='-0.5,-0.1 0.5,-0.1 0.4,0.16 0.25,0.3 0.1,0.35  -0.1,0.35 -0.25,0.3 -0.4,0.16 -0.5,-0.1' fill='none'/>
+	<polyline points='0.25,0.3 0.27,0.4 0.2,0.51 0.05,0.57  -0.05,0.57 -0.2,0.51 -0.27,0.4 -0.25,0.3' fill='none'/>
+   </g>
+   <g id='CL_3'>
+        <polyline points='-0.5,-0.1 0.5,-0.1 0.4,0.16 0.25,0.3 0.1,0.35  -0.1,0.35 -0.25,0.3 -0.4,0.16 -0.5,-0.1' fill='none'/>
+	<polyline points='0.25,0.3 0.27,0.4 0.2,0.51 0.05,0.57  -0.05,0.57 -0.2,0.51 -0.27,0.4 -0.25,0.3' fill='none'/>
+	<polyline points='0,0.57 0,0.1' fill='none'/>
+   </g>
+   <g id='CL_4'>
+       <polyline points='0.43,-0.1 0.34,0.14 0.25,0.28 0.1,0.33  -0.1,0.33 -0.25,0.28 -0.34,0.14 -0.43,-0.1' fill='none'/>
+       <polyline points='-0.52,-0.1 -0.2,-0.1 -0.1,-0.2 0.1,-0.2 0.2,-0.1 0.52,-0.1' fill='none'/>
+   </g>   
+   <g id='CL_5'>
+       <polyline points='-0.5,0.2 -0.22,0.2 -0.1,0. 0.1,0. 0.22,0.2 0.5,0.2' fill='none'/>
+   </g>
+   <g id='CL_6'>
+       <polyline points='0.3,0 -0.3,0' fill='none'/>
+   </g>
+   <g id='CL_7'>
+       <polyline points='-0.4,0 -0.2,0' fill='none'/>
+       <polyline points='-0.1,0 0.1,0' fill='none'/>
+       <polyline points='0.2,0 0.4,0' fill='none'/>
+   </g>
+   <g id='CL_8'>
+        <polyline points='-0.5,0.5 -0.2,0.5 -0.1,0.4 0.1,0.4 0.2,0.5 0.5,0.5' fill='none'/>
+        <polyline points='-0.5,-0.2 0.5,-0.2 0.4,0.06 0.23,0.2 0.1,0.22 -0.1,0.22 -0.23,0.2 -0.4,0.06 -0.5,-0.2' fill='none'/>
+   </g>
+   <g id='CL_9'>
+        <polyline points='-0.5,-0.1 0.5,-0.1 0.4,0.16 0.25,0.3 0.1,0.35 -0.1,0.35 -0.25,0.3 -0.4,0.16 -0.5,-0.1' fill='none'/>
+	<polyline points='0.25,0.3 0.32,0.55 -0.32,0.55 -0.25,0.3' fill='none'/>
+   </g>
+   <g id='CL_/'>
+   </g>
+
+   <g id='CM_0'>
+   </g>
+   <g id='CM_1'>
+       <polyline points='0.3,0 -0.3,0 0.3,0.3' fill='none'/>
+   </g>
+   <g id='CM_2'>
+       <polyline points='0.3,0 -0.3,0 0.3,0.3' fill='none'/>
+       <polyline points='0,0 0.3,0.15' fill='none'/>
+   </g>
+   <g id='CM_3'>
+       <polyline points='-0.4,0 -0.3,-0.2 -0.1,-0.2 0,0 0.1,-0.2 0.3,-0.2 0.4,0' fill='none'/>
+   </g>
+   <g id='CM_4'>
+       <polyline points='0.2,0.3 -0.4,0 -0.3,-0.2 -0.1,-0.2 0,0' fill='none'/>
+   </g>
+<g id='CM_5'>
+ <polyline points='0.2,0.3 -0.4,0 -0.3,-0.2 -0.1,-0.2 0,0 0.1,-0.2 0.3,-0.2 0.4,0' fill='none'/>
+</g>
+   <g id='CM_6'>
+       <polyline points='-0.4,0.3 -0.3,0.1 -0.1,0.1 0,0.3 0.1,0.1 0.3,0.1 0.4,0.3' fill='none'/>
+       <polyline points='0.5,-0.4 0.4,-0.14 0.23,0 0.1,0.02 -0.1,0.02 -0.23,0 -0.4,-0.14 -0.5,-0.4' fill='none'/>
+   </g>
+   <g id='CM_7'>
+       <polyline points='0.2,0.3 -0.4,0 -0.3,-0.2 -0.1,-0.2 0,0 0.1,-0.2 0.3,-0.2 0.4,0' fill='none'/>
+       <polyline points='-0.4,0 0.4,0' fill='none'/>
+   </g>
+   <g id='CM_8'>
+       <polyline points='-0.3,-0.35 -0.3,0.35 -0.15,0.29 -0.05,0.25 0,0.23 0.05,0.25 0.15,0.29 0.3,0.35 0.3,-0.35' fill='none'/>
+   </g>
+<g id='CM_9'>
+ <polyline points='0.2,0.3 -0.4,0 -0.3,-0.2 -0.1,-0.2 0,0' fill='none'/>
+ <polyline points='-0.45,0 -0.31,-0.25 -0.09,-0.25 0.05,0' fill='none'/>
+</g>
+<g id='CM_/'>
+</g>
+
+<g id='CH_0'>
+</g>
+<g id='CH_1'>
+ <polyline points='-0.3,0 0.28,0 0.29,0.06 0.3,0.1 0.29,0.14 0.28,0.2' fill='none'/>
+</g>
+<g id='CH_2'>
+ <polyline points='-0.3,0 0.28,0 0.29,0.06 0.3,0.1 0.29,0.14 0.28,0.2' fill='none'/>
+ <polyline points='0.18,0 0.19,0.06 0.2,0.1 0.19,0.14 0.18,0.2' fill='none'/>
+</g>
+<g id='CH_3'>
+ <polyline points='-0.3,0 0.28,0 0.29,-0.06 0.3,-0.1 0.29,-0.14 0.28,-0.2' fill='none'/>
+</g>
+
+<g id='CH_5'>
+ <polyline points='-0.3,0.2 -0.29,0.14 -0.28,0.1 -0.29,0.06 -0.3,0 0.3,0' fill='none'/>
+</g>
+
+<g id='CH_7'>
+ <polyline points='-0.3,0.2 -0.29,0.14 -0.28,0.1 -0.29,0.06 -0.3,0 0.3,0 0.29,0.06 0.28,0.1 0.29,0.14 0.3,0.2' fill='none'/>
+</g>
+<g id='CH_8'>
+ <polyline points='-0.3,0 0.3,0 0.29,0.06 0.28,0.1 0.29,0.14 0.3,0.2' fill='none'/>
+</g>
+<g id='CH_9'>
+ <polyline points='0.05,0.3 0.12,0.35 0.2,0.3 -0.4,0 -0.3,-0.2 -0.1,-0.2 0,0 0.1,-0.2 0.3,-0.2 0.4,0' fill='none'/>
+</g>
+<g id='CH_/'>
+</g>
+   
+   <g id='C_4'>
+       <polyline points='0.3,0 -0.3,0 0.3,0.3' fill='none'/>
+       <polyline points='0,0 0.15,0.075' fill='none'/>
+   </g>
+   <g id='C_5'>
+       <polyline points='0.3,0 -0.3,0 0.3,0.3' fill='none'/>
+       <polyline points='0,0 0.3,0.15 0.3,0' fill='none'/>
+   </g>
+   <g id='C_7'>
+       <polyline points='-0.3,0 -0.1,0' fill='none'/>
+       <polyline points='0.1,0 0.3,0' fill='none'/>
+   </g>
+   <g id='C_8'>
+        <polyline points='0.5,-0.1 0.4,0.16 0.25,0.3 0.1,0.35  -0.1,0.35 -0.25,0.3 -0.4,0.16 -0.5,-0.1' fill='none'/>
+	<polyline points='0.25,0.3 0.27,0.4 0.2,0.51 0.05,0.57  -0.05,0.57 -0.2,0.51 -0.27,0.4 -0.25,0.3' fill='none'/>
+   </g>
+   <g id='C_9'>
+        <polyline points='0.5,-0.1 0.4,0.16 0.25,0.3 0.1,0.35  -0.1,0.35 -0.25,0.3 -0.4,0.16 -0.5,-0.1' fill='none'/>
+	<polyline points='0.25,0.3 0.32,0.55  -0.32,0.55 -0.25,0.3' fill='none'/>
+   </g>
+   <g id='C_/'>
+   </g>
+
+   <g id='a_0'>
+       <polyline points='-0.4,-0.4 0.1,0.4 0.3,0.2' fill='none'/>
+   </g>
+   <g id='a_1'>
+       <polyline points='-0.4,-0.4 0.05,0.4 0.35,0.4' fill='none'/>
+   </g>
+   <g id='a_2'>
+       <polyline points='-0.3,-0.4 0.3,0.4' fill='none'/>
+   </g>
+   <g id='a_3'>
+       <polyline points='-0.3,-0.2 -0.05,-0.4 0.4,0.4' fill='none'/>
+   </g>
+   <g id='a_4'>
+   </g>
+   <g id='a_5'>
+       <polyline points='-0.4,0.4 0.05,-0.4 0.3,-0.2' fill='none'/>
+   </g>
+   <g id='a_6'>
+       <polyline points='-0.4,0.4 0.05,-0.4 0.35,-0.4' fill='none'/>
+   </g>
+   <g id='a_7'>
+       <polyline points='-0.3,0.4 0.3,-0.4' fill='none'/>
+   </g>
+   <g id='a_8'>
+       <polyline points='-0.3,0.2 -0.05,0.4 0.4,-0.4' fill='none'/>
+   </g>
+   <g id='a_9'>
+   </g>
+   <g id='a_/'>
+   </g>
+
+   <g id='DS_0'>
+   </g>
+   <g id='DS_1'>
+       <polyline points='-0.4,-0.4 0.4,0.4' fill='none'/>
+       <polyline points='0.4,0.4 0.33,0.12' fill='none'/>
+       <polyline points='0.4,0.4 0.12,0.33' fill='none'/>
+   </g>
+   <g id='DS_2'>
+       <polyline points='-0.4,0 0.4,0' fill='none'/>
+       <polyline points='0.4,0 0.14,0.15' fill='none'/>
+       <polyline points='0.4,0 0.14,-0.15' fill='none'/>
+   </g>
+   <g id='DS_3'>
+       <polyline points='-0.4,0.4 0.4,-0.4' fill='none'/>
+       <polyline points='0.4,-0.4 0.33,-0.12' fill='none'/>
+       <polyline points='0.4,-0.4 0.12,-0.33' fill='none'/>
+   </g>
+   <g id='DS_4'>
+       <polyline points='0,-0.4 0,0.4' fill='none'/>
+       <polyline points='0,-0.4 -0.15,-0.14' fill='none'/>
+       <polyline points='0,-0.4  0.15,-0.14' fill='none'/>
+   </g>
+   <g id='DS_5'>
+       <polyline points='-0.4,-0.4 0.4,0.4' fill='none'/>
+       <polyline points='-0.4,-0.4 -0.33,-0.12' fill='none'/>
+       <polyline points='-0.4,-0.4 -0.12,-0.33' fill='none'/>
+   </g>
+   <g id='DS_6'>
+       <polyline points='-0.4,0 0.4,0' fill='none'/>
+       <polyline points='-0.4,0 -0.14,0.15' fill='none'/>
+       <polyline points='-0.4,0 -0.14,-0.15' fill='none'/>
+   </g>
+   <g id='DS_7'>
+       <polyline points='-0.4,0.4 0.4,-0.4' fill='none'/>
+       <polyline points='-0.4,0.4 -0.33,0.12' fill='none'/>
+       <polyline points='-0.4,0.4 -0.12,0.33' fill='none'/>
+   </g>
+   <g id='DS_8'>
+       <polyline points='0,-0.4 0,0.4' fill='none'/>
+       <polyline points='0,0.4 -0.15,0.14' fill='none'/>
+       <polyline points='0,0.4  0.15,0.14' fill='none'/>
+   </g>
+
+
+   <g id='DS_9'>
+   </g>
+   <g id='DS_/'>
+   </g>
+
+   <g id='logo_ecmwf'>
+       <!-- top -->
+       <polyline points='-3.375,0.125 -3.3,0.325 -3.15,0.5 -3,0.575 -2.85,0.6 -2.75,0.6 -2.5,0.55    -2.25,0.6 -2.2,0.6 -2.05,0.56 -1.85,0.44 -1.725,0.3 -1.675,0.125 -2.025,0.125 -2.125,0.225 -2.25,0.25 -2.375,0.2375 -2.45,0.175 -2.5,0.0875    -2.525,0.0875 -2.5625,0.175 -2.6625,0.2375 -2.775,0.25 -2.9,0.225    -3,0.125 -3.375,0.125' fill='blue'/>
+       <!-- bottom -->
+       <polyline points='-3.375,-0.125 -3.3,-0.325 -3.15,-0.5 -3,-0.575 -2.85,-0.6 -2.75,-0.6 -2.5,-0.55    -2.25,-0.6 -2.2,-0.6 -2.05,-0.56 -1.85,-0.44 -1.725,-0.3 -1.675,-0.125 -2.025,-0.125 -2.125,-0.225 -2.25,-0.25 -2.375,-0.2375 -2.45,-0.175 -2.5,-0.0875    -2.525,-0.0875 -2.5625,-0.175 -2.6625,-0.2375 -2.775,-0.25 -2.9,-0.225    -3,-0.125 -3.375,-0.125' fill='blue'/>
+       <!-- line -->
+       <polyline points='-3.4,-0.065 -3.4,0.065 -2.9,0.065 -2.9,-0.065 -3.4,-0.065' fill='blue'/>
+       <!-- E -->
+       <polyline points='-1.575,-.5 -1.575,.5 -0.825,.5 -0.825,.4 -0.925,.3 -1.2,.3 -1.2,.1 -1,.1 -1,-0.125 -1.2,-0.125 -1.2,-0.275 -0.925,-0.275 -0.825,-0.425 -0.825,-.5 -1.575,-.5' fill='blue'/>
+       <!-- C -->
+       <polyline points='-.025,0.175 -.025,0.45 -0.175,0.5 -0.3,0.51 -0.475,0.51 -0.6625,0.45 -0.75,0.4 -0.875,0.2875 -0.95,0.1    -0.95,-0.075 -0.9,-0.2375 -0.8,-0.375 -0.475,-0.51 -0.35,-0.51 -0.15,-0.495 -.025,-0.425 -.025,-0.1625    -.2,-0.225 -0.4,-0.2375 -0.5375,-0.1625 -.6,-0.075  -.6,0.075  -.5,0.2 -0.375,0.2375 -0.2125,0.225 -.025,0.175' fill='blue'/>
+       <!-- M -->
+       <polyline points='0.028,-0.5 0.028,0.5 0.35,0.5 0.625,0.125 0.9,0.5 1.225,0.5 1.225,-0.5 0.9,-0.5 0.9,0 0.625,-0.325 0.35,0 0.35,-0.5 0.028,-0.5' fill='blue'/>
+       <!-- W -->
+       <polyline points='1.3,0.2 1.3,0.5 1.55,0.5 1.675,0.075 1.8,0.5 2.05,0.5 2.175,0.075 2.3,0.5 2.55,0.5 2.55,0.2 2.275,-0.5 2.05,-0.5 1.925,-0.05 1.8,-0.5 1.575,-0.5 1.3,0.2' fill='blue'/>
+       <!-- F -->
+       <polyline points='2.625,-0.5 2.625,0.5 3.375,0.5 3.375,0.3 3,0.3 3,0.125 3.35,0.125 3.35,-0.1 3,-0.1 3,-0.5 2.625,-0.5' fill='blue'/>
+   </g>
+</svg>
diff --git a/share/magics/table_128.xml b/share/magics/table_128.xml
new file mode 100644
index 0000000..b590beb
--- /dev/null
+++ b/share/magics/table_128.xml
@@ -0,0 +1,1299 @@
+<center code='98'>
+    <table code='128'>
+    <param code='1' mars=''
+           short_title='strm fun'
+           long_title='stream function'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='2' mars=''
+           short_title='vel pot'
+           long_title='velocity potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='3' mars=''
+           short_title='pot temp'
+           long_title='potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='4' mars=''
+           short_title='eq pot temp'
+           long_title='equiv potential temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='5' mars=''
+           short_title='sat eq pot temp'
+           long_title='sat equiv pot temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='11' mars=''
+           short_title='u-com div wind'
+           long_title='u-comp divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='12' mars=''
+           short_title='v-com div wind'
+           long_title='v-comp divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='13' mars=''
+           short_title='u-com rot wind'
+           long_title='u-comp rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='14' mars=''
+           short_title='v-com rot wind'
+           long_title='v-comp rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='21' mars=''
+           short_title='UCTP'
+           long_title='Unbalanced component of temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='22' mars=''
+           short_title='UCLN'
+           long_title='Unbalanced component of logarithm of surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='23' mars=''
+           short_title='UCDV'
+           long_title='Unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='24' mars=''
+           short_title='None'
+           long_title='Reserved for future unbalanced components'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='25' mars=''
+           short_title='None'
+           long_title='Reserved for future unbalanced components'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='26' mars=''
+           short_title='CL'
+           long_title='Lake cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='27' mars=''
+           short_title='low veg cover'
+           long_title='low vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='28' mars=''
+           short_title='high veg cover'
+           long_title='high vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='29' mars=''
+           short_title='type low veg'
+           long_title='type of low vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='30' mars=''
+           short_title='type high veg'
+           long_title='type of high vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='31' mars=''
+           short_title='sea ice cover'
+           long_title='sea ice cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='32' mars=''
+           short_title='snow albedo'
+           long_title='snow albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='33' mars=''
+           short_title='snow density'
+           long_title='snow density'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-3' derived_unit='kg**3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='34' mars=''
+           short_title='sea surf temp'
+           long_title='sea surface temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='35' mars=''
+           short_title='ice surf temp layer1'
+           long_title='ice surface temperature layer 1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='36' mars=''
+           short_title='ice surf temp layer2'
+           long_title='ice surface temperature layer 2'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='37' mars=''
+           short_title='ice surf temp layer3'
+           long_title='ice surface temperature layer 3'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='38' mars=''
+           short_title='ice surf temp layer4'
+           long_title='ice surface temperature layer 4'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='39' mars=''
+           short_title='vol soil water layer1'
+           long_title='volumetric soil water layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='40' mars=''
+           short_title='vol soil water layer2'
+           long_title='volumetric soil water layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='41' mars=''
+           short_title='vol soil water layer3'
+           long_title='volumetric soil water layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='42' mars=''
+           short_title='vol soil water layer4'
+           long_title='volumetric soil water layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='43' mars=''
+           short_title='SLT'
+           long_title='Soil type'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='44' mars=''
+           short_title='evap snow'
+           long_title='evaporation of snow'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='45' mars=''
+           short_title='snow melt'
+           long_title='snow melt'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='46' mars=''
+           short_title='SDUR'
+           long_title='Solar duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='47' mars=''
+           short_title='DSRP'
+           long_title='Direct solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='48' mars=''
+           short_title='MAGSS'
+           long_title='Magnitude of surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='49' mars=''
+           short_title='gust 10m'
+           long_title='wind gust at 10m'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='50' mars=''
+           short_title='LSPF'
+           long_title='Large-scale precipitation fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='51' mars=''
+           short_title='MX2T24'
+           long_title='Maximum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='52' mars=''
+           short_title='MN2T24'
+           long_title='Minimum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='53' mars=''
+           short_title='mont pot'
+           long_title='montgomery potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='54' mars=''
+           short_title='pres'
+           long_title='pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hPa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='55' mars=''
+           short_title='MN2T24'
+           long_title='Mean 2 metre temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='56' mars=''
+           short_title='MN2D24'
+           long_title='Mean 2 metre dewpoint temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='57' mars=''
+           short_title='UVB'
+           long_title='Downward UV radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='58' mars=''
+           short_title='PAR'
+           long_title='Photosynthetically active radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='59' mars=''
+           short_title='CAPE'
+           long_title='Convective available potential energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='60' mars=''
+           short_title='pv'
+           long_title='potential vorticity'
+           scaling='1000000.0' offset='-0.0'
+           original_unit='K m**2 kg**-1 s**-1' derived_unit='pv units'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='61' mars=''
+           short_title='TPO'
+           long_title='Total precipitation from observations'
+           scaling='1.0' offset='-0.0'
+           original_unit='Millimetres*100 + number of stations' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='62' mars=''
+           short_title='OBCT'
+           long_title='Observation count'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='63' mars=''
+           short_title='-'
+           long_title='Start time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='64' mars=''
+           short_title='-'
+           long_title='Finish time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='65' mars=''
+           short_title='-'
+           long_title='Skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='78' mars=''
+           short_title='TCLW'
+           long_title='Total Column Liquid Water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='79' mars=''
+           short_title='TCIW'
+           long_title='Total Column Ice Water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='125' mars=''
+           short_title='-'
+           long_title='Vertically integrated total energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='126' mars=''
+           short_title='-'
+           long_title='Generic parameter for sensitive area prediction'
+           scaling='1.0' offset='-0.0'
+           original_unit='Various' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='127' mars=''
+           short_title='atmos tide'
+           long_title='atmospheric tide'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='128' mars=''
+           short_title='budg val'
+           long_title='budget values'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='129' mars=''
+           short_title='geop'
+           long_title='geopotential height'
+           scaling='0.0101971621297793' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit='dam'
+           vector1='0' vector2='0'
+           contour_interval='8.0' specification='p1'/>
+    <param code='130' mars=''
+           short_title='temp'
+           long_title='temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p2'/>
+    <param code='131' mars=''
+           short_title='u-vel'
+           long_title='u-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p3'/>
+    <param code='132' mars=''
+           short_title='v-vel'
+           long_title='v-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p4'/>
+    <param code='133' mars=''
+           short_title='spec hum'
+           long_title='specific humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p5'/>
+    <param code='134' mars=''
+           short_title='surf pres'
+           long_title='surface pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p6'/>
+    <param code='135' mars=''
+           short_title='vert vel'
+           long_title='vertical velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p7'/>
+    <param code='136' mars=''
+           short_title='tot col wat'
+           long_title='total column water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='137' mars=''
+           short_title='tot col wat vap'
+           long_title='total column water vapour'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='138' mars=''
+           short_title='vort'
+           long_title='vorticity'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p10'/>
+    <param code='139' mars=''
+           short_title='soil temp lyr1'
+           long_title='soil temperature layer1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p11'/>
+    <param code='140' mars=''
+           short_title='soil wet lyr 1'
+           long_title='soil wetness layer 1'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p12'/>
+    <param code='141' mars=''
+           short_title='snow depth'
+           long_title='snow depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='142' mars=''
+           short_title='lge scl prec'
+           long_title='large scale precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p14'/>
+    <param code='143' mars=''
+           short_title='conv prec'
+           long_title='convective precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p15'/>
+    <param code='144' mars=''
+           short_title='snowf'
+           long_title='snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p16'/>
+    <param code='145' mars=''
+           short_title='bound lyr diss'
+           long_title='boundary layer dissip'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p17'/>
+    <param code='146' mars=''
+           short_title='surf sens ht flux'
+           long_title='surf sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p18'/>
+    <param code='147' mars=''
+           short_title='surf lat ht flux'
+           long_title='surf latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p19'/>
+    <param code='148' mars=''
+           short_title='CHNK'
+           long_title='Charnock'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='149' mars=''
+           short_title='SNR'
+           long_title='Surface net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='150' mars=''
+           short_title='TNR'
+           long_title='Top net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='151' mars=''
+           short_title='msl'
+           long_title='mean sea level pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p23'/>
+    <param code='152' mars=''
+           short_title='log surf pres'
+           long_title='log surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p24'/>
+    <param code='153' mars=''
+           short_title='SWHR'
+           long_title='Short-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='154' mars=''
+           short_title='LWHR'
+           long_title='Long-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='155' mars=''
+           short_title='diverg'
+           long_title='divergence'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p27'/>
+    <param code='156' mars=''
+           short_title='hgt (geop)'
+           long_title='height (geopotential)'
+           scaling='1.0' offset='-0.0'
+           original_unit='gpm' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='40.0' specification='p28'/>
+    <param code='157' mars=''
+           short_title='rel hum'
+           long_title='relative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='20.0' specification='p29'/>
+    <param code='158' mars=''
+           short_title='surf press tend'
+           long_title='tendency of surf press'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p30'/>
+    <param code='159' mars=''
+           short_title='bound layer hgt'
+           long_title='boundary layer height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='160' mars=''
+           short_title='stdev orog'
+           long_title='std dev of orography'
+           scaling='100.0' offset='-0.0'
+           original_unit='' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='161' mars=''
+           short_title='anisot sub-grid orog'
+           long_title='anistropy of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='162' mars=''
+           short_title='angle sub-grid orog'
+           long_title='angle of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='rad' derived_unit='rad'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='163' mars=''
+           short_title='slope sub-grid orog'
+           long_title='slope of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='164' mars=''
+           short_title='tot cldcov'
+           long_title='total cloudcover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p36'/>
+    <param code='165' mars=''
+           short_title='10m u'
+           long_title='10 mtr u'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p37'/>
+    <param code='166' mars=''
+           short_title='10m v'
+           long_title='10 mtr v'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p38'/>
+    <param code='167' mars=''
+           short_title='2m temp'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p39'/>
+    <param code='168' mars=''
+           short_title='2m dewp'
+           long_title='2 metre dewpoint temp'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p40'/>
+    <param code='169' mars=''
+           short_title='sur sol rad dwn'
+           long_title='surf solar radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='170' mars=''
+           short_title='soil temp lyr2'
+           long_title='soil temperature layer2'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p42'/>
+    <param code='171' mars=''
+           short_title='soil wet lyr2'
+           long_title='soil wetness layer2'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='172' mars=''
+           short_title='l/sea mask'
+           long_title='land/ sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='0/1'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='173' mars=''
+           short_title='surf rough'
+           long_title='surface roughness'
+           scaling='100.0' offset='-0.0'
+           original_unit='m' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='174' mars=''
+           short_title='albedo'
+           long_title='albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='175' mars=''
+           short_title='sur ther rad dwn'
+           long_title='surf thermal radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='176' mars=''
+           short_title='surf solrad'
+           long_title='surf solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='177' mars=''
+           short_title='surf ther rad'
+           long_title='surf thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='178' mars=''
+           short_title='topsolrad'
+           long_title='top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='179' mars=''
+           short_title='top ther rad'
+           long_title='top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='180' mars=''
+           short_title='u-stress'
+           long_title='u-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='181' mars=''
+           short_title='v-stress'
+           long_title='v-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='182' mars=''
+           short_title='evap'
+           long_title='evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='183' mars=''
+           short_title='soil temp lyr3'
+           long_title='soil temperature layer3'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='184' mars=''
+           short_title='soil wet lyr3'
+           long_title='soil wetness layer3'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='185' mars=''
+           short_title='conv cld cov'
+           long_title='convective cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='186' mars=''
+           short_title='low cld cov'
+           long_title='low cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='187' mars=''
+           short_title='med cld cov'
+           long_title='medium cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='188' mars=''
+           short_title='hi cld cov'
+           long_title='high cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='189' mars=''
+           short_title='sun duration'
+           long_title='sunshine duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='190' mars=''
+           short_title='ew comp subgrid orog var'
+           long_title='ew comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='191' mars=''
+           short_title='ns comp subgrid orog var'
+           long_title='ns comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='192' mars=''
+           short_title='nwse com subgrd orog var'
+           long_title='nwse com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='193' mars=''
+           short_title='nswe com subgrd orog var'
+           long_title='nswe com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='194' mars=''
+           short_title='BTMP'
+           long_title='Brightness temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='195' mars=''
+           short_title='lat comp grav wav stress'
+           long_title='lat comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='196' mars=''
+           short_title='mer comp grav wav stress'
+           long_title='mer comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='197' mars=''
+           short_title='grav wav diss'
+           long_title='gravity wav dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='198' mars=''
+           short_title='skin res cont'
+           long_title='skin reservoir content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='199' mars=''
+           short_title='percent of veg'
+           long_title='percent of vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='200' mars=''
+           short_title='var subgrid-scale orog'
+           long_title='var subgrid-scale orog'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='201' mars=''
+           short_title='max 2m tem'
+           long_title='maximum temp at 2m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='202' mars=''
+           short_title='min 2m  tem'
+           long_title='minimum temp at 2 m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='203' mars=''
+           short_title='oz mass mix rat'
+           long_title='ozone mass mixing ratio'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='204' mars=''
+           short_title='prec anal weights'
+           long_title='precip. analys weights'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='205' mars=''
+           short_title='runoff'
+           long_title='runoff'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='206' mars=''
+           short_title='tot col oz'
+           long_title='total column ozone'
+           scaling='46696.2409526033' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='Dob'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='207' mars=''
+           short_title='10SI'
+           long_title='10 metre wind speed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='208' mars=''
+           short_title='TSRC'
+           long_title='Top net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='209' mars=''
+           short_title='TTRC'
+           long_title='Top net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='210' mars=''
+           short_title='SSRC'
+           long_title='Surface net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='211' mars=''
+           short_title='STRC'
+           long_title='Surface net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='212' mars=''
+           short_title='TISR'
+           long_title='TOA incident solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='214' mars=''
+           short_title='DHR'
+           long_title='Diabatic heating by radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='215' mars=''
+           short_title='DHVD'
+           long_title='Diabatic heating by vertical diffusion'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='216' mars=''
+           short_title='DHCC'
+           long_title='Diabatic heating by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='217' mars=''
+           short_title='DHLC'
+           long_title='Diabatic heating by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='218' mars=''
+           short_title='VDZW'
+           long_title='Vertical diffusion of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='219' mars=''
+           short_title='VDMW'
+           long_title='Vertical diffusion of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='220' mars=''
+           short_title='EWGD'
+           long_title='East-West gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='221' mars=''
+           short_title='NSGD'
+           long_title='North-South gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='222' mars=''
+           short_title='CTZW'
+           long_title='Convective tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='223' mars=''
+           short_title='CTMW'
+           long_title='Convective tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='224' mars=''
+           short_title='VDH'
+           long_title='Vertical diffusion of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='225' mars=''
+           short_title='HTCC'
+           long_title='Humidity tendency by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='226' mars=''
+           short_title='HTLC'
+           long_title='Humidity tendency by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='227' mars=''
+           short_title='CRNH'
+           long_title='Change from removal of negative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='228' mars=''
+           short_title='tot prec'
+           long_title='total precipitation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='229' mars=''
+           short_title='instant e/w surf str'
+           long_title='instant e/w surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='230' mars=''
+           short_title='inst n/s surf str'
+           long_title='instant n/s surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='231' mars=''
+           short_title='inst surf sens heat flux'
+           long_title='inst surf sens heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='w/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='232' mars=''
+           short_title='inst evap'
+           long_title='instant evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s' derived_unit='g/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='233' mars=''
+           short_title='appar surf hum'
+           long_title='apparent surf humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='234' mars=''
+           short_title='log surf rough for heat'
+           long_title='log surf rough for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='235' mars=''
+           short_title='skin temp'
+           long_title='skin temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='236' mars=''
+           short_title='soil temp lyr4'
+           long_title='soil temperature layer4'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='237' mars=''
+           short_title='soil wet lyr 4'
+           long_title='soil wetness layer 4'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='238' mars=''
+           short_title='snow temp'
+           long_title='snow temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='239' mars=''
+           short_title='conv snow'
+           long_title='convective snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='240' mars=''
+           short_title='lge scal snow'
+           long_title='large scale snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='241' mars=''
+           short_title='ACF'
+           long_title='Accumulated cloud fraction tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='242' mars=''
+           short_title='ALW'
+           long_title='Accumulated liquid water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='243' mars=''
+           short_title='fore albedo'
+           long_title='forecast albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='244' mars=''
+           short_title='fore surf rough'
+           long_title='forecast surface roughness'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='245' mars=''
+           short_title='fore log surf rough/heat'
+           long_title='forecast log surface roughness for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='246' mars=''
+           short_title='cloud liq wat con'
+           long_title='cloud liquid water content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='gm/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='247' mars=''
+           short_title='cloud ice wat con'
+           long_title='cloud ice water content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='gm/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='248' mars=''
+           short_title='cloud cov'
+           long_title='cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='249' mars=''
+           short_title='AIW'
+           long_title='Accumulated ice water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='250' mars=''
+           short_title='ice age'
+           long_title='ice age'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='251' mars=''
+           short_title='unbal comp temp'
+           long_title='unbalanced component of temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg C'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='252' mars=''
+           short_title='unbal comp LNSP'
+           long_title='unbalanced component of LNSP'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='253' mars=''
+           short_title='unbal comp div'
+           long_title='unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='254' mars=''
+           short_title='ATMW'
+           long_title='Adiabatic tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_129.xml b/share/magics/table_129.xml
new file mode 100644
index 0000000..bde9c08
--- /dev/null
+++ b/share/magics/table_129.xml
@@ -0,0 +1,1285 @@
+<center code='98'>
+    <table code='129'>
+    <param code='1' mars=''
+           short_title='strm fun'
+           long_title='stream function'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='2' mars=''
+           short_title='vel pot'
+           long_title='velocity potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='3' mars=''
+           short_title='pot temp'
+           long_title='potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='4' mars=''
+           short_title='eq pot temp'
+           long_title='equiv potential temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='5' mars=''
+           short_title='sat eq pot temp'
+           long_title='sat equiv pot temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='11' mars=''
+           short_title='u-com div wind'
+           long_title='u-comp divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='12' mars=''
+           short_title='v-com div wind'
+           long_title='v-comp divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='13' mars=''
+           short_title='u-com rot wind'
+           long_title='u-comp rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='14' mars=''
+           short_title='v-com rot wind'
+           long_title='v-comp rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='21' mars=''
+           short_title='UCTP'
+           long_title='Unbalanced component of temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='22' mars=''
+           short_title='UCLN'
+           long_title='Unbalanced component of logarithm of surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='23' mars=''
+           short_title='UCDV'
+           long_title='Unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='24' mars=''
+           short_title='None'
+           long_title='Reserved for future unbalanced components'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='25' mars=''
+           short_title='None'
+           long_title='Reserved for future unbalanced components'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='26' mars=''
+           short_title='CL'
+           long_title='Lake cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='27' mars=''
+           short_title='CVL'
+           long_title='Low vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='28' mars=''
+           short_title='CVH'
+           long_title='High vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='29' mars=''
+           short_title='TVL'
+           long_title='Type of low vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='30' mars=''
+           short_title='TVH'
+           long_title='Type of high vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='31' mars=''
+           short_title='CI'
+           long_title='Sea-ice cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='32' mars=''
+           short_title='ASN'
+           long_title='Snow albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='33' mars=''
+           short_title='RSN'
+           long_title='Snow density'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='34' mars=''
+           short_title='SSTK'
+           long_title='Sea surface temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='35' mars=''
+           short_title='ISTL1'
+           long_title='Ice surface temperature layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='36' mars=''
+           short_title='ISTL2'
+           long_title='Ice surface temperature layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='37' mars=''
+           short_title='ISTL3'
+           long_title='Ice surface temperature layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='38' mars=''
+           short_title='ISTL4'
+           long_title='Ice surface temperature layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='39' mars=''
+           short_title='SWVL1'
+           long_title='Volumetric soil water layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='40' mars=''
+           short_title='SWVL2'
+           long_title='Volumetric soil water layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='41' mars=''
+           short_title='SWVL3'
+           long_title='Volumetric soil water layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='42' mars=''
+           short_title='SWVL4'
+           long_title='Volumetric soil water layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='43' mars=''
+           short_title='SLT'
+           long_title='Soil type'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='44' mars=''
+           short_title='ES'
+           long_title='Snow evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='45' mars=''
+           short_title='SMLT'
+           long_title='Snowmelt'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='46' mars=''
+           short_title='SDUR'
+           long_title='Solar duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='47' mars=''
+           short_title='DSRP'
+           long_title='Direct solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='48' mars=''
+           short_title='MAGSS'
+           long_title='Magnitude of surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='49' mars=''
+           short_title='10FG'
+           long_title='10 metre wind gust'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='50' mars=''
+           short_title='LSPF'
+           long_title='Large-scale precipitation fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='51' mars=''
+           short_title='MX2T24'
+           long_title='Maximum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='52' mars=''
+           short_title='MN2T24'
+           long_title='Minimum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='53' mars=''
+           short_title='MONT'
+           long_title='Montgomery potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='54' mars=''
+           short_title='PRES'
+           long_title='Pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='55' mars=''
+           short_title='MN2T24'
+           long_title='Mean 2 metre temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='56' mars=''
+           short_title='MN2D24'
+           long_title='Mean 2 metre dewpoint temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='57' mars=''
+           short_title='UVB'
+           long_title='Downward UV radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='58' mars=''
+           short_title='PAR'
+           long_title='Photosynthetically active radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='59' mars=''
+           short_title='CAPE'
+           long_title='Convective available potential energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='60' mars=''
+           short_title='PV'
+           long_title='Potential vorticity'
+           scaling='1.0' offset='-0.0'
+           original_unit='K m**2 kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='61' mars=''
+           short_title='TPO'
+           long_title='Total precipitation from observations'
+           scaling='1.0' offset='-0.0'
+           original_unit='Millimetres*100 + number of stations' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='62' mars=''
+           short_title='OBCT'
+           long_title='Observation count'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='63' mars=''
+           short_title='-'
+           long_title='Start time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='64' mars=''
+           short_title='-'
+           long_title='Finish time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='65' mars=''
+           short_title='-'
+           long_title='Skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='125' mars=''
+           short_title='-'
+           long_title='Vertically integrated total energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='126' mars=''
+           short_title='-'
+           long_title='Generic parameter for sensitive area prediction'
+           scaling='1.0' offset='-0.0'
+           original_unit='Various' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='127' mars=''
+           short_title='atmos tide'
+           long_title='atmospheric tide'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='128' mars=''
+           short_title='budg val'
+           long_title='budget values'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='129' mars=''
+           short_title='geop'
+           long_title='geopotential height'
+           scaling='0.0101971621297793' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit='dam'
+           vector1='0' vector2='0'
+           contour_interval='8.0' specification='p1'/>
+    <param code='130' mars=''
+           short_title='temp'
+           long_title='temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p2'/>
+    <param code='131' mars=''
+           short_title='u-vel'
+           long_title='u-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p3'/>
+    <param code='132' mars=''
+           short_title='v-vel'
+           long_title='v-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p4'/>
+    <param code='133' mars=''
+           short_title='spec hum'
+           long_title='specific humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p5'/>
+    <param code='134' mars=''
+           short_title='surf pres'
+           long_title='surface pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p6'/>
+    <param code='135' mars=''
+           short_title='vert vel'
+           long_title='vertical velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p7'/>
+    <param code='136' mars=''
+           short_title='tot col wat'
+           long_title='total column water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='137' mars=''
+           short_title='tot col wat vap'
+           long_title='total column water vapour'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='138' mars=''
+           short_title='vort'
+           long_title='vorticity'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p10'/>
+    <param code='139' mars=''
+           short_title='soil temp lyr1'
+           long_title='soil temperature layer1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p11'/>
+    <param code='140' mars=''
+           short_title='soil wet lyr 1'
+           long_title='soil wetness layer 1'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p12'/>
+    <param code='141' mars=''
+           short_title='snow depth'
+           long_title='snow depth'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='142' mars=''
+           short_title='lge scl prec'
+           long_title='large scale precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p14'/>
+    <param code='143' mars=''
+           short_title='conv prec'
+           long_title='convective precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p15'/>
+    <param code='144' mars=''
+           short_title='snowf'
+           long_title='snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p16'/>
+    <param code='145' mars=''
+           short_title='bound lyr diss'
+           long_title='boundary layer dissip'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p17'/>
+    <param code='146' mars=''
+           short_title='surf sens ht flux'
+           long_title='surf sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p18'/>
+    <param code='147' mars=''
+           short_title='surf lat ht flux'
+           long_title='surf latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p19'/>
+    <param code='148' mars=''
+           short_title='CHNK'
+           long_title='Charnock'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='149' mars=''
+           short_title='SNR'
+           long_title='Surface net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='150' mars=''
+           short_title='TNR'
+           long_title='Top net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='151' mars=''
+           short_title='msl'
+           long_title='mean sea level pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p23'/>
+    <param code='152' mars=''
+           short_title='log surf pres'
+           long_title='log surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p24'/>
+    <param code='153' mars=''
+           short_title='SWHR'
+           long_title='Short-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='154' mars=''
+           short_title='LWHR'
+           long_title='Long-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='155' mars=''
+           short_title='diverg'
+           long_title='divergence'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p27'/>
+    <param code='156' mars=''
+           short_title='hgt (geop)'
+           long_title='height (geopotential)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='40.0' specification='p28'/>
+    <param code='157' mars=''
+           short_title='rel hum'
+           long_title='relative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='20.0' specification='p29'/>
+    <param code='158' mars=''
+           short_title='surf press tend'
+           long_title='tendency of surf press'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p30'/>
+    <param code='159' mars=''
+           short_title='BLH'
+           long_title='Boundary layer height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='160' mars=''
+           short_title='stdev orog'
+           long_title='std dev of orography'
+           scaling='100.0' offset='-0.0'
+           original_unit='' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='161' mars=''
+           short_title='anisot sub-grid orog'
+           long_title='anistropy of sub-gridscale orography'
+           scaling='0.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='162' mars=''
+           short_title='angle sub-grid orog'
+           long_title='angle of sub-gridscale orography'
+           scaling='0.0' offset='-0.0'
+           original_unit='rad' derived_unit='rad'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='163' mars=''
+           short_title='slope sub-grid orog'
+           long_title='slope of sub-gridscale orography'
+           scaling='0.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='164' mars=''
+           short_title='tot cldcov'
+           long_title='total cloudcover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p36'/>
+    <param code='165' mars=''
+           short_title='10m u'
+           long_title='10 mtr u'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p37'/>
+    <param code='166' mars=''
+           short_title='10m v'
+           long_title='10 mtr v'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p38'/>
+    <param code='167' mars=''
+           short_title='2m temp'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p39'/>
+    <param code='168' mars=''
+           short_title='2m dewp'
+           long_title='2 metre dewpoint temp'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p40'/>
+    <param code='169' mars=''
+           short_title='sur sol rad dwn'
+           long_title='surf solar radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='170' mars=''
+           short_title='soil temp lyr2'
+           long_title='soil temperature layer2'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p42'/>
+    <param code='171' mars=''
+           short_title='soil wet lyr2'
+           long_title='soil wetness layer2'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='172' mars=''
+           short_title='l/sea mask'
+           long_title='land/ sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='0/1'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='173' mars=''
+           short_title='surf rough'
+           long_title='surface roughness'
+           scaling='100.0' offset='-0.0'
+           original_unit='m' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='174' mars=''
+           short_title='albedo'
+           long_title='albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='175' mars=''
+           short_title='sur ther rad dwn'
+           long_title='surf thermal radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='176' mars=''
+           short_title='surf solrad'
+           long_title='surf solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='177' mars=''
+           short_title='surf ther rad'
+           long_title='surf thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='178' mars=''
+           short_title='topsolrad'
+           long_title='top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='179' mars=''
+           short_title='top ther rad'
+           long_title='top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='180' mars=''
+           short_title='u-stress'
+           long_title='u-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='181' mars=''
+           short_title='v-stress'
+           long_title='v-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='182' mars=''
+           short_title='evap'
+           long_title='evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='183' mars=''
+           short_title='soil temp lyr3'
+           long_title='soil temperature layer3'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='184' mars=''
+           short_title='soil wet lyr3'
+           long_title='soil wetness layer3'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='185' mars=''
+           short_title='conv cld cov'
+           long_title='convective cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='186' mars=''
+           short_title='low cld cov'
+           long_title='low cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='187' mars=''
+           short_title='med cld cov'
+           long_title='medium cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='188' mars=''
+           short_title='hi cld cov'
+           long_title='high cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='189' mars=''
+           short_title='SUND'
+           long_title='Sunshine duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='190' mars=''
+           short_title='ew comp subgrid orog var'
+           long_title='ew comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='191' mars=''
+           short_title='ns comp subgrid orog var'
+           long_title='ns comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='192' mars=''
+           short_title='nwse com subgrd orog var'
+           long_title='nwse com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='193' mars=''
+           short_title='nswe com subgrd orog var'
+           long_title='nswe com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='194' mars=''
+           short_title='BTMP'
+           long_title='Brightness temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='195' mars=''
+           short_title='lat comp grav wav stress'
+           long_title='lat comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='196' mars=''
+           short_title='mer comp grav wav stress'
+           long_title='mer comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='197' mars=''
+           short_title='grav wav diss'
+           long_title='gravity wav dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='198' mars=''
+           short_title='skin res cont'
+           long_title='skin reservoir content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='199' mars=''
+           short_title='percent of veg'
+           long_title='percent of vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='200' mars=''
+           short_title='var subgrid-scale orog'
+           long_title='var subgrid-scale orog'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='201' mars=''
+           short_title='max 2m tem'
+           long_title='maximum temp at 2m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='202' mars=''
+           short_title='min 2m  tem'
+           long_title='minimum temp at 2 m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='203' mars=''
+           short_title='O3'
+           long_title='Ozone mass mixing ratio'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='204' mars=''
+           short_title='prec anal weights'
+           long_title='precip. analys weights'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='205' mars=''
+           short_title='runoff'
+           long_title='runoff'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='206' mars=''
+           short_title='TCO3'
+           long_title='Total column ozone'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='207' mars=''
+           short_title='10SI'
+           long_title='10 metre wind speed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='208' mars=''
+           short_title='TSRC'
+           long_title='Top net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='209' mars=''
+           short_title='TTRC'
+           long_title='Top net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='210' mars=''
+           short_title='SSRC'
+           long_title='Surface net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='211' mars=''
+           short_title='STRC'
+           long_title='Surface net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='212' mars=''
+           short_title='TISR'
+           long_title='TOA incident solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='214' mars=''
+           short_title='DHR'
+           long_title='Diabatic heating by radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='215' mars=''
+           short_title='DHVD'
+           long_title='Diabatic heating by vertical diffusion'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='216' mars=''
+           short_title='DHCC'
+           long_title='Diabatic heating by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='217' mars=''
+           short_title='DHLC'
+           long_title='Diabatic heating by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='218' mars=''
+           short_title='VDZW'
+           long_title='Vertical diffusion of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='219' mars=''
+           short_title='VDMW'
+           long_title='Vertical diffusion of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='220' mars=''
+           short_title='EWGD'
+           long_title='East-West gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='221' mars=''
+           short_title='NSGD'
+           long_title='North-South gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='222' mars=''
+           short_title='CTZW'
+           long_title='Convective tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='223' mars=''
+           short_title='CTMW'
+           long_title='Convective tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='224' mars=''
+           short_title='VDH'
+           long_title='Vertical diffusion of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='225' mars=''
+           short_title='HTCC'
+           long_title='Humidity tendency by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='226' mars=''
+           short_title='HTLC'
+           long_title='Humidity tendency by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='227' mars=''
+           short_title='CRNH'
+           long_title='Change from removal of negative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='228' mars=''
+           short_title='tot prec'
+           long_title='total precipitation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='229' mars=''
+           short_title='instant e/w surf str'
+           long_title='instant e/w surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='230' mars=''
+           short_title='inst n/s surf str'
+           long_title='instant n/s surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='231' mars=''
+           short_title='inst surf sens heat flux'
+           long_title='inst surf sens heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='w/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='232' mars=''
+           short_title='inst evap'
+           long_title='instant evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s' derived_unit='g/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='233' mars=''
+           short_title='appar surf hum'
+           long_title='apparent surf humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='234' mars=''
+           short_title='log surf rough for heat'
+           long_title='log surf rough for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='235' mars=''
+           short_title='skin temp'
+           long_title='skin temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='236' mars=''
+           short_title='soil temp lyr4'
+           long_title='soil temperature layer4'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='237' mars=''
+           short_title='soil wet lyr 4'
+           long_title='soil wetness layer 4'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='238' mars=''
+           short_title='snow temp'
+           long_title='snow temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='239' mars=''
+           short_title='conv snow'
+           long_title='convective snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='240' mars=''
+           short_title='lge scal snow'
+           long_title='large scale snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='241' mars=''
+           short_title='ACF'
+           long_title='Accumulated cloud fraction tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='242' mars=''
+           short_title='ALW'
+           long_title='Accumulated liquid water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='243' mars=''
+           short_title='fore albedo'
+           long_title='forecast albedo'
+           scaling='0.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='244' mars=''
+           short_title='fore surf rough'
+           long_title='forecast surface roughness'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='245' mars=''
+           short_title='fore log surf rough/heat'
+           long_title='forecast log surface roughness for heat'
+           scaling='0.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='246' mars=''
+           short_title='cloud liq wat con'
+           long_title='cloud liquid water content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='gm/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='247' mars=''
+           short_title='cloud ice wat con'
+           long_title='cloud ice water content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='gm/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='248' mars=''
+           short_title='cloud cov'
+           long_title='cloud cover'
+           scaling='0.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='249' mars=''
+           short_title='AIW'
+           long_title='Accumulated ice water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='250' mars=''
+           short_title='ice age'
+           long_title='ice age'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='251' mars=''
+           short_title='unbal comp temp'
+           long_title='unbalanced component of temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg C'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='252' mars=''
+           short_title='unbal comp LNSP'
+           long_title='unbalanced component of LNSP'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='253' mars=''
+           short_title='unbal comp div'
+           long_title='unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='254' mars=''
+           short_title='ATMW'
+           long_title='Adiabatic tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_130.xml b/share/magics/table_130.xml
new file mode 100644
index 0000000..c3fdb9f
--- /dev/null
+++ b/share/magics/table_130.xml
@@ -0,0 +1,179 @@
+<center code='98'>
+    <table code='130'>
+    <param code='208' mars=''
+           short_title='TSRU'
+           long_title='Top solar radiation upward'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='209' mars=''
+           short_title='TTRU'
+           long_title='Top thermal radiation upward'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='210' mars=''
+           short_title='TSUC'
+           long_title='Top solar radiation upward, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='211' mars=''
+           short_title='TTUC'
+           long_title='Top thermal radiation upward, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='212' mars=''
+           short_title='CLW'
+           long_title='Cloud liquid water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='213' mars=''
+           short_title='CF'
+           long_title='Cloud fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='214' mars=''
+           short_title='DHR'
+           long_title='Diabatic heating by radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='215' mars=''
+           short_title='DHVD'
+           long_title='Diabatic heating by vertical diffusion'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='216' mars=''
+           short_title='DHCC'
+           long_title='Diabatic heating by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='217' mars=''
+           short_title='DHLC'
+           long_title='Diabatic heating by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='218' mars=''
+           short_title='VDZW'
+           long_title='Vertical diffusion of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='219' mars=''
+           short_title='VDMW'
+           long_title='Vertical diffusion of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='220' mars=''
+           short_title='EWGD'
+           long_title='East-West gravity wave drag'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='221' mars=''
+           short_title='NSGD'
+           long_title='North-South gravity wave drag'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='222' mars=''
+           short_title='CTZW'
+           long_title='Convective tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='223' mars=''
+           short_title='CTMW'
+           long_title='Convective tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='224' mars=''
+           short_title='VDH'
+           long_title='Vertical diffusion of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='225' mars=''
+           short_title='HTCC'
+           long_title='Humidity tendency by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='226' mars=''
+           short_title='HTLC'
+           long_title='Humidity tendency by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='227' mars=''
+           short_title='CRNH'
+           long_title='Change from removal of negative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='228' mars=''
+           short_title='ATT'
+           long_title='Adiabatic tendency of temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='229' mars=''
+           short_title='ATH'
+           long_title='Adiabatic tendency of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='230' mars=''
+           short_title='ATZW'
+           long_title='Adiabatic tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='231' mars=''
+           short_title='ATMWAX'
+           long_title='Adiabatic tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='232' mars=''
+           short_title='MVV'
+           long_title='Mean vertical velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_131.xml b/share/magics/table_131.xml
new file mode 100644
index 0000000..0984502
--- /dev/null
+++ b/share/magics/table_131.xml
@@ -0,0 +1,67 @@
+<center code='98'>
+    <table code='131'>
+    <param code='6' mars=''
+           short_title='tot prec'
+           long_title='Probability total precipitation anomaly of at least 20 mm/week'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='7' mars=''
+           short_title='tot prec'
+           long_title='Probability total precipitation anomaly of at least 10 mm/week'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='49' mars=''
+           short_title='gust 10m'
+           long_title='wind gust at 10m'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='130' mars=''
+           short_title='temp anom'
+           long_title='temperature anomaly'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p2'/>
+    <param code='165' mars=''
+           short_title='10m spd prob'
+           long_title='10m wind speed probability'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p37'/>
+    <param code='167' mars=''
+           short_title='2m tmp prob'
+           long_title='2m temperature probability'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='228' mars=''
+           short_title='tot prec'
+           long_title='total precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='229' mars=''
+           short_title='Hs proba'
+           long_title='significant wave height probability'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='232' mars=''
+           short_title='Period proba'
+           long_title='mean wave period probability'
+           scaling='1.0' offset='-0.0'
+           original_unit='percentage' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+     </table>
+</center>
diff --git a/share/magics/table_132.xml b/share/magics/table_132.xml
new file mode 100644
index 0000000..927769d
--- /dev/null
+++ b/share/magics/table_132.xml
@@ -0,0 +1,32 @@
+<center code='98'>
+    <table code='132'>
+    <param code='49' mars=''
+           short_title='10GP'
+           long_title='Maximum 10 metre wind gust index'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='165' mars=''
+           short_title='10SP'
+           long_title='10 metre speed index'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='167' mars=''
+           short_title='2TP'
+           long_title='2 metre temperature index'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='228' mars=''
+           short_title='TTP'
+           long_title='Total precipitation index'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+     </table>
+</center>
diff --git a/share/magics/table_140.xml b/share/magics/table_140.xml
new file mode 100644
index 0000000..80db9bf
--- /dev/null
+++ b/share/magics/table_140.xml
@@ -0,0 +1,256 @@
+<center code='98'>
+    <table code='140'>
+    <param code='219' mars=''
+           short_title='WMB'
+           long_title='wave model bathymetry'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='220' mars=''
+           short_title='mean wave per (m1)'
+           long_title='mean wave period (m1)'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='221' mars=''
+           short_title='mean wave per (m2)'
+           long_title='mean wave period (m2)'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='222' mars=''
+           short_title='wave spec dir width'
+           long_title='wave spectral dir width'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p43'/>
+    <param code='223' mars=''
+           short_title='mean wave per (m1) wind wav'
+           long_title='mean wave period (m1) wind waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='224' mars=''
+           short_title='mean wave per (m2) wind wav'
+           long_title='mean wave period (m2) wind waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='225' mars=''
+           short_title='wave spec dir width wind wav'
+           long_title='wave spectral dir width of wind waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p43'/>
+    <param code='226' mars=''
+           short_title='mean wave per (m1) swell'
+           long_title='mean wave period (m1) swell'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='227' mars=''
+           short_title='mean wave per (m2) swell'
+           long_title='mean wave period (m2) swell'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='228' mars=''
+           short_title='wave spec dir width swell'
+           long_title='wave spectral dir width of swell'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p43'/>
+    <param code='229' mars=''
+           short_title='sig wave hgt'
+           long_title='significant wave height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='230' mars=''
+           short_title='mean wave dir'
+           long_title='mean wave direction'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees' derived_unit='deg'
+           vector1='0' vector2='0'
+           contour_interval='10.0' specification='p43'/>
+    <param code='231' mars=''
+           short_title='peak per 1d spec'
+           long_title='peak period 1d spectra'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='232' mars=''
+           short_title='mean wave per'
+           long_title='mean wave period'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='233' mars=''
+           short_title='drag coeff with waves'
+           long_title='drag coeff with waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.001' specification='p43'/>
+    <param code='234' mars=''
+           short_title='sig hgt wind waves'
+           long_title='sig height wind waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='235' mars=''
+           short_title='mean dir wind waves'
+           long_title='mean dir wind waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees' derived_unit='deg'
+           vector1='0' vector2='0'
+           contour_interval='10.0' specification='p43'/>
+    <param code='236' mars=''
+           short_title='mean per wind waves'
+           long_title='mean period wind waves'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='237' mars=''
+           short_title='sig hgt prim swell'
+           long_title='sig height prim swell'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='238' mars=''
+           short_title='mean dir prim swell'
+           long_title='mean dir prim swell'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees' derived_unit='deg'
+           vector1='0' vector2='0'
+           contour_interval='10.0' specification='p43'/>
+    <param code='239' mars=''
+           short_title='mean per prim swell'
+           long_title='mean period prim swell'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='240' mars=''
+           short_title='st dev wave hgt'
+           long_title='st dev wave height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='0.5' specification='p43'/>
+    <param code='241' mars=''
+           short_title='mean windspd'
+           long_title='mean windspeed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='242' mars=''
+           short_title='mean wind dir'
+           long_title='mean wind direction'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees' derived_unit='deg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='243' mars=''
+           short_title='st dev 10m windspd'
+           long_title='st dev 10m windspeed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.5' specification='p43'/>
+    <param code='244' mars=''
+           short_title='mean sq slope'
+           long_title='mean square slope'
+           scaling='1.0' offset='-0.0'
+           original_unit='dimensionless' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.01' specification='p43'/>
+    <param code='245' mars=''
+           short_title='windspd mod by wave mod'
+           long_title='wind speed modified by wave model'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='2.0' specification='p43'/>
+    <param code='246' mars=''
+           short_title='gridded alt wave hgt'
+           long_title='gridded altimeter wave height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='247' mars=''
+           short_title='gridded corr alt wave hgt'
+           long_title='gridded corrected altimeter wave height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='248' mars=''
+           short_title='gridded alt range rel corr'
+           long_title='gridded altimeter range relative correction'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='249' mars=''
+           short_title='10m wind dir by wave mod'
+           long_title='10m wind direction by wave model'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees' derived_unit='deg'
+           vector1='0' vector2='0'
+           contour_interval='20.0' specification='p43'/>
+    <param code='250' mars=''
+           short_title='2-d wave spectrum'
+           long_title='2-d wave spectrum'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s radian**-1' derived_unit='m**2s/radiance'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='251' mars=''
+           short_title='log10 2-d wave spec per freq/dir'
+           long_title='log10 of 2-d wave spectrum per freq/dir'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s radian**-1' derived_unit='m**2s/radiance'
+           vector1='0' vector2='0'
+           contour_interval='0.5' specification='p43'/>
+    <param code='252' mars=''
+           short_title='WSK'
+           long_title='Wave spectral kurtosis'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='253' mars=''
+           short_title='BFI'
+           long_title='Benjamin-Feir index'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='254' mars=''
+           short_title='WSP'
+           long_title='Wave spectral peakedness'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_150.xml b/share/magics/table_150.xml
new file mode 100644
index 0000000..5d0f6ae
--- /dev/null
+++ b/share/magics/table_150.xml
@@ -0,0 +1,221 @@
+<center code='98'>
+    <table code='150'>
+    <param code='129' mars=''
+           short_title='NONE'
+           long_title='Ocean potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='130' mars=''
+           short_title='NONE'
+           long_title='Ocean salinity'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='131' mars=''
+           short_title='NONE'
+           long_title='Ocean potential density'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-3 -1000' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='133' mars=''
+           short_title='NONE'
+           long_title='Ocean U velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='134' mars=''
+           short_title='NONE'
+           long_title='Ocean V velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='135' mars=''
+           short_title='NONE'
+           long_title='Ocean W velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='137' mars=''
+           short_title='NONE'
+           long_title='Richardson number'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='139' mars=''
+           short_title='NONE'
+           long_title='U*V product'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='140' mars=''
+           short_title='NONE'
+           long_title='U*T product'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1 deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='141' mars=''
+           short_title='NONE'
+           long_title='V*T product'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1 deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='142' mars=''
+           short_title='NONE'
+           long_title='U*U product'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='143' mars=''
+           short_title='NONE'
+           long_title='V*V product'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='144' mars=''
+           short_title='NONE'
+           long_title='UV - U~V~'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='145' mars=''
+           short_title='NONE'
+           long_title='UT - U~T~'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1 deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='146' mars=''
+           short_title='NONE'
+           long_title='VT - V~T~'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1 deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='147' mars=''
+           short_title='NONE'
+           long_title='UU - U~U~'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='148' mars=''
+           short_title='NONE'
+           long_title='VV - V~V~'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='152' mars=''
+           short_title='NONE'
+           long_title='Sea level'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='153' mars=''
+           short_title='NONE'
+           long_title='Barotropic stream function'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='154' mars=''
+           short_title='NONE'
+           long_title='Mixed layer depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='155' mars=''
+           short_title='NONE'
+           long_title='Depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='NONE'
+           long_title='U stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='169' mars=''
+           short_title='NONE'
+           long_title='V stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='170' mars=''
+           short_title='NONE'
+           long_title='Turbulent kinetic energy input'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='171' mars=''
+           short_title='NONE'
+           long_title='Net surface heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='172' mars=''
+           short_title='NONE'
+           long_title='Surface solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='173' mars=''
+           short_title='NONE'
+           long_title='P-E'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='180' mars=''
+           short_title='NONE'
+           long_title='Diagnosed sea surface temperature error'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='181' mars=''
+           short_title='NONE'
+           long_title='Heat flux correction'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='182' mars=''
+           short_title='NONE'
+           long_title='Observed sea surface temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='183' mars=''
+           short_title='NONE'
+           long_title='Observed heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_151.xml b/share/magics/table_151.xml
new file mode 100644
index 0000000..baff493
--- /dev/null
+++ b/share/magics/table_151.xml
@@ -0,0 +1,312 @@
+<center code='98'>
+    <table code='151'>
+    <param code='129' mars=''
+           short_title='pot temp'
+           long_title='potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='130' mars=''
+           short_title='salin'
+           long_title='salinity'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='131' mars=''
+           short_title='u-vel'
+           long_title='u-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='132' mars=''
+           short_title='v-vel'
+           long_title='v-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='133' mars=''
+           short_title='w-vel'
+           long_title='w-velocity'
+           scaling='1.15740740740741e-05.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/day'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='134' mars=''
+           short_title='mod str rate ten'
+           long_title='mod strain rate tensor'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='135' mars=''
+           short_title='vert vis'
+           long_title='vertical viscosity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='136' mars=''
+           short_title='vert diff'
+           long_title='vertical diffusivity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='137' mars=''
+           short_title='depth'
+           long_title='depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='138' mars=''
+           short_title='sigma-theta'
+           long_title='sigma-theta'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='139' mars=''
+           short_title='rich num'
+           long_title='richarson number'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='145' mars=''
+           short_title='sea level'
+           long_title='sea level (tides removed)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='146' mars=''
+           short_title='sea fl top'
+           long_title='sea floor topography'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='147' mars=''
+           short_title='baro strm fn'
+           long_title='barotropic streamfunction'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 s**-1' derived_unit='sv'
+           vector1='0' vector2='0'
+           contour_interval='1e+10.0' specification=''/>
+    <param code='148' mars=''
+           short_title='mix lay dep'
+           long_title='mixed layer depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='153' mars=''
+           short_title='u-stress'
+           long_title='u-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='154' mars=''
+           short_title='v-stress'
+           long_title='v-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='155' mars=''
+           short_title='tur kin eng inp'
+           long_title='turbulent kinet ener inp'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='156' mars=''
+           short_title='netsur ht flux'
+           long_title='net surface heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='157' mars=''
+           short_title='abs sol rad'
+           long_title='absorbed solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='158' mars=''
+           short_title='prec_evap'
+           long_title='precip _ evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='mm/day'
+           vector1='0' vector2='0'
+           contour_interval='8.64e+07.0' specification=''/>
+    <param code='159' mars=''
+           short_title='spec sst'
+           long_title='specified sst'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='160' mars=''
+           short_title='spec sur ht fluf'
+           long_title='specified surf heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='161' mars=''
+           short_title='diag ssterr'
+           long_title='diagnose sst error'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='162' mars=''
+           short_title='ht flux cor'
+           long_title='heat flux correction'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='163' mars=''
+           short_title='20D'
+           long_title='20 degrees isotherm depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='164' mars=''
+           short_title='TAV300'
+           long_title='Average potential temperature in the upper 300m'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='167' mars=''
+           short_title='ZTR'
+           long_title='Vertically integrated zonal volume transport'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='MTR'
+           long_title='Vertically integrated meridional volume transport'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='169' mars=''
+           short_title='ZHT'
+           long_title='Vertically integrated zonal heat transport'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='170' mars=''
+           short_title='MHT'
+           long_title='Vertically integrated meridional heat transport'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='171' mars=''
+           short_title='UMAX'
+           long_title='U velocity maximum'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='172' mars=''
+           short_title='DUMAX'
+           long_title='Depth of the velocity maximum'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='173' mars=''
+           short_title='SMAX'
+           long_title='Salinity maximum'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='174' mars=''
+           short_title='DSMAX'
+           long_title='Depth of salinity maximum'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='175' mars=''
+           short_title='SAV300'
+           long_title='Average salinity in the upper 300m'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='178' mars=''
+           short_title='PTI'
+           long_title='Potential temperature increment'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='179' mars=''
+           short_title='PTAE'
+           long_title='Potential temperature analysis error'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='180' mars=''
+           short_title='BPT'
+           long_title='Background potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='181' mars=''
+           short_title='APT'
+           long_title='Analysed potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='182' mars=''
+           short_title='PTBE'
+           long_title='Potential temperature background error'
+           scaling='1.0' offset='-0.0'
+           original_unit='deg C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='183' mars=''
+           short_title='AS'
+           long_title='Analysed salinity'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='184' mars=''
+           short_title='SALI'
+           long_title='Salinity increment'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='255' mars=''
+           short_title='NONE'
+           long_title=''
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_160.xml b/share/magics/table_160.xml
new file mode 100644
index 0000000..68c18d4
--- /dev/null
+++ b/share/magics/table_160.xml
@@ -0,0 +1,753 @@
+<center code='98'>
+    <table code='160'>
+    <param code='127' mars=''
+           short_title='atmos tide'
+           long_title='atmospheric tide'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='128' mars=''
+           short_title='budg val'
+           long_title='budget values'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='129' mars=''
+           short_title='geop'
+           long_title='geopotential'
+           scaling='0.0101971621297793' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit='dam'
+           vector1='0' vector2='0'
+           contour_interval='8.0' specification='p1'/>
+    <param code='130' mars=''
+           short_title='temp'
+           long_title='temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p2'/>
+    <param code='131' mars=''
+           short_title='u-vel'
+           long_title='u-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p3'/>
+    <param code='132' mars=''
+           short_title='v-vel'
+           long_title='v-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p4'/>
+    <param code='133' mars=''
+           short_title='spec hum'
+           long_title='specific humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p5'/>
+    <param code='134' mars=''
+           short_title='surf pres'
+           long_title='surface pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p6'/>
+    <param code='135' mars=''
+           short_title='vert vel'
+           long_title='vertical velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p7'/>
+    <param code='136' mars=''
+           short_title='tot col wat'
+           long_title='total column water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p9'/>
+    <param code='137' mars=''
+           short_title='tot col wat vap'
+           long_title='total column water vapour'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p9'/>
+    <param code='138' mars=''
+           short_title='vort'
+           long_title='vorticity'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p10'/>
+    <param code='139' mars=''
+           short_title='soil temp lyr1'
+           long_title='soil temperature layer1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p11'/>
+    <param code='140' mars=''
+           short_title='soil wet lyr 1'
+           long_title='soil wetness layer 1'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p12'/>
+    <param code='141' mars=''
+           short_title='snow depth'
+           long_title='snow depth'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='142' mars=''
+           short_title='lge scl prec'
+           long_title='large scale precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p14'/>
+    <param code='143' mars=''
+           short_title='conv prec'
+           long_title='convective precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p15'/>
+    <param code='144' mars=''
+           short_title='snowf'
+           long_title='snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p16'/>
+    <param code='145' mars=''
+           short_title='bound lyr diss'
+           long_title='boundary layer dissip'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p17'/>
+    <param code='146' mars=''
+           short_title='surf sens ht flux'
+           long_title='surf sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p18'/>
+    <param code='147' mars=''
+           short_title='surf lat ht flux'
+           long_title='surf latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p19'/>
+    <param code='151' mars=''
+           short_title='msl'
+           long_title='mean sea level pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p23'/>
+    <param code='152' mars=''
+           short_title='log surf pres'
+           long_title='log surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p24'/>
+    <param code='155' mars=''
+           short_title='diverg'
+           long_title='divergence'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p27'/>
+    <param code='156' mars=''
+           short_title='hgt (geop)'
+           long_title='height (geopotential)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='40.0' specification='p28'/>
+    <param code='157' mars=''
+           short_title='rel hum'
+           long_title='relative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='20.0' specification='p29'/>
+    <param code='158' mars=''
+           short_title='surf press tend'
+           long_title='tendency of surf press'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p30'/>
+    <param code='164' mars=''
+           short_title='tot cldcov'
+           long_title='total cloudcover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p36'/>
+    <param code='165' mars=''
+           short_title='10m u'
+           long_title='10 mtr u'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p37'/>
+    <param code='166' mars=''
+           short_title='10m v'
+           long_title='10 mtr v'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p38'/>
+    <param code='167' mars=''
+           short_title='2m temp'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p39'/>
+    <param code='168' mars=''
+           short_title='2m dewp'
+           long_title='2 metre dewpoint temp'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p40'/>
+    <param code='170' mars=''
+           short_title='soil temp lyr2'
+           long_title='soil temperature layer2'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p42'/>
+    <param code='171' mars=''
+           short_title='soil wet lyr2'
+           long_title='soil wetness layer2'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='172' mars=''
+           short_title='l/sea mask'
+           long_title='land/ sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='0/1'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='173' mars=''
+           short_title='surf rough'
+           long_title='surface roughness'
+           scaling='100.0' offset='-0.0'
+           original_unit='m' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='174' mars=''
+           short_title='albedo'
+           long_title='albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='176' mars=''
+           short_title='surf solrad'
+           long_title='surf solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='177' mars=''
+           short_title='surf ther rad'
+           long_title='surf thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='178' mars=''
+           short_title='topsolrad'
+           long_title='top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='179' mars=''
+           short_title='top ther rad'
+           long_title='top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='180' mars=''
+           short_title='u-stress'
+           long_title='u-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s**-1' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='181' mars=''
+           short_title='v-stress'
+           long_title='v-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s**-1' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='182' mars=''
+           short_title='evap'
+           long_title='evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='183' mars=''
+           short_title='soil temp lyr3'
+           long_title='soil temperature layer3'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='184' mars=''
+           short_title='soil wet lyr3'
+           long_title='soil wetness layer3'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='185' mars=''
+           short_title='conv cld cov'
+           long_title='convective cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='186' mars=''
+           short_title='low cld cov'
+           long_title='low cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='187' mars=''
+           short_title='med cld cov'
+           long_title='medium cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='188' mars=''
+           short_title='hi cld cov'
+           long_title='high cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='190' mars=''
+           short_title='ew comp subgrid orog var'
+           long_title='ew comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='191' mars=''
+           short_title='ns comp subgrid orog var'
+           long_title='ns comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='192' mars=''
+           short_title='nwse com subgrd orog var'
+           long_title='nwse com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='193' mars=''
+           short_title='nswe com subgrd orog var'
+           long_title='nswe com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='195' mars=''
+           short_title='lat comp grav wav stress'
+           long_title='lat comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='196' mars=''
+           short_title='mer comp grav wav stress'
+           long_title='mer comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='197' mars=''
+           short_title='grav wav diss'
+           long_title='gravity wav dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='198' mars=''
+           short_title='skin res cont'
+           long_title='skin reservoir content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='199' mars=''
+           short_title='percent of veg'
+           long_title='percent of vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='200' mars=''
+           short_title='var subgrid-scale orog'
+           long_title='var subgrid-scale orog'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='201' mars=''
+           short_title='max 2m tem'
+           long_title='maximum temp at 2m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='202' mars=''
+           short_title='min 2m  tem'
+           long_title='minimum temp at 2 m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='204' mars=''
+           short_title='prec anal weights'
+           long_title='precip. analys weights'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='205' mars=''
+           short_title='runoff'
+           long_title='runoff'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='206' mars=''
+           short_title='stdev geop'
+           long_title='stdi dev of geopotential'
+           scaling='0.0101971621297793' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit='dam'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p1'/>
+    <param code='207' mars=''
+           short_title='covar tem/geop'
+           long_title='covariance temp/geopot'
+           scaling='1.0' offset='-0.0'
+           original_unit='K m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='208' mars=''
+           short_title='stdev temp'
+           long_title='std dev of temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='209' mars=''
+           short_title='covar sphum/geop'
+           long_title='covariance spec hum/geop'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='210' mars=''
+           short_title='covar sphum/temp'
+           long_title='covariance spec hum/temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='211' mars=''
+           short_title='stdev spec hum'
+           long_title='std dev spec humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='212' mars=''
+           short_title='covar u-comp/geop'
+           long_title='covariance u-comp/geop'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='213' mars=''
+           short_title='covar u-comp/temp'
+           long_title='covariance u-comp/temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='214' mars=''
+           short_title='covar u-comp/sphum'
+           long_title='covariance u-comp/sp hum'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='215' mars=''
+           short_title='stdev u-vel'
+           long_title='std dev u velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='216' mars=''
+           short_title='covar v-comp/geop'
+           long_title='covariance v-comp/geop'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='217' mars=''
+           short_title='covar v-comp/temp'
+           long_title='covariance v-comp/temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='218' mars=''
+           short_title='covar v-comp/sphum'
+           long_title='covariance v-comp/sp hum'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='219' mars=''
+           short_title='covar v-comp/u-comp'
+           long_title='covariance v-comp/u-comp'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='220' mars=''
+           short_title='stdev v-vel'
+           long_title='std dev v velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='221' mars=''
+           short_title='covar w-comp/geop'
+           long_title='covariance w-comp/geop'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa m**2 s**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='222' mars=''
+           short_title='covar w-comp/temp'
+           long_title='covariance w-comp/temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K Pa s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='223' mars=''
+           short_title='covar w-comp/sphum'
+           long_title='covariance w-comp/sp hum'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='224' mars=''
+           short_title='covar w-comp/u-comp'
+           long_title='covariance w-comp/u-comp'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='225' mars=''
+           short_title='covar w-comp/v-comp'
+           long_title='covariance w-comp/v-comp'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa m s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='226' mars=''
+           short_title='stdev vert-vel'
+           long_title='std dev vert velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='228' mars=''
+           short_title='tot prec'
+           long_title='roral precipitation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='229' mars=''
+           short_title='instant e/w surf str'
+           long_title='instant e/w surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='230' mars=''
+           short_title='inst n/s surf str'
+           long_title='instant n/s surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='231' mars=''
+           short_title='inst surf sens heat flux'
+           long_title='inst surf sens heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='w/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='232' mars=''
+           short_title='inst evap'
+           long_title='instant evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='g/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='233' mars=''
+           short_title='appar surf hum'
+           long_title='apparent surf humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='234' mars=''
+           short_title='log surf rough for heat'
+           long_title='log surf rough for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='235' mars=''
+           short_title='skin temp'
+           long_title='skin temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='236' mars=''
+           short_title='soil temp lyr4'
+           long_title='soil temperature layer4'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='237' mars=''
+           short_title='soil wet lyr 4'
+           long_title='soil wetness layer 4'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='238' mars=''
+           short_title='snow temp'
+           long_title='snow temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='239' mars=''
+           short_title='conv snow'
+           long_title='convective snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='240' mars=''
+           short_title='lge scal snow'
+           long_title='large scale snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s**-1' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='241' mars=''
+           short_title='cl liq wat'
+           long_title='cloud liquid water cont'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='kg/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='242' mars=''
+           short_title='cl cov'
+           long_title='cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='243' mars=''
+           short_title='fc albedo'
+           long_title='forecast albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='244' mars=''
+           short_title='fc surf rough'
+           long_title='forecast surface rough'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='245' mars=''
+           short_title='fc lg surf rough/heat'
+           long_title='fcast log srf rough/heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='246' mars=''
+           short_title='10m wind/spd'
+           long_title='10 metre wind speed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='247' mars=''
+           short_title='mom flux'
+           long_title='momentum flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='249' mars=''
+           short_title='grav wv diss fux'
+           long_title='gravity wave dissip flus'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='w/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='254' mars=''
+           short_title='Heav beta func'
+           long_title='Heaviside (beta) function'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+     </table>
+</center>
diff --git a/share/magics/table_162.xml b/share/magics/table_162.xml
new file mode 100644
index 0000000..c69d509
--- /dev/null
+++ b/share/magics/table_162.xml
@@ -0,0 +1,4 @@
+<center code='98'>
+    <table code='162'>
+     </table>
+</center>
diff --git a/share/magics/table_170.xml b/share/magics/table_170.xml
new file mode 100644
index 0000000..709c31b
--- /dev/null
+++ b/share/magics/table_170.xml
@@ -0,0 +1,116 @@
+<center code='98'>
+    <table code='170'>
+    <param code='129' mars=''
+           short_title='geop'
+           long_title='geopotential height'
+           scaling='0.0101971621297793' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit='dam'
+           vector1='0' vector2='0'
+           contour_interval='8.0' specification='p1'/>
+    <param code='130' mars=''
+           short_title='temp'
+           long_title='temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p2'/>
+    <param code='131' mars=''
+           short_title='u-vel'
+           long_title='u-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p3'/>
+    <param code='132' mars=''
+           short_title='v-vel'
+           long_title='v-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p4'/>
+    <param code='138' mars=''
+           short_title='vort'
+           long_title='vorticity'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p10'/>
+    <param code='140' mars=''
+           short_title='soil wet lyr 1'
+           long_title='soil wetness layer 1'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p12'/>
+    <param code='141' mars=''
+           short_title='snow depth'
+           long_title='snow depth'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='149' mars=''
+           short_title='tot soil moist'
+           long_title='total soil moisture'
+           scaling='100.0' offset='-0.0'
+           original_unit='m' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='151' mars=''
+           short_title='msl'
+           long_title='mean sea level pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p23'/>
+    <param code='155' mars=''
+           short_title='diverg'
+           long_title='divergence'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p27'/>
+    <param code='171' mars=''
+           short_title='soil wet lyr2'
+           long_title='soil wetness layer2'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='179' mars=''
+           short_title='top ther rad'
+           long_title='top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m-2' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='184' mars=''
+           short_title='soil wet lyr3'
+           long_title='soil wetness layer3'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='201' mars=''
+           short_title='max 2m tem'
+           long_title='maximum temp at 2m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='202' mars=''
+           short_title='min 2m  tem'
+           long_title='minimum temp at 2 m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='228' mars=''
+           short_title='tot prec'
+           long_title='total precipitation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+     </table>
+</center>
diff --git a/share/magics/table_171.xml b/share/magics/table_171.xml
new file mode 100644
index 0000000..1d2f8eb
--- /dev/null
+++ b/share/magics/table_171.xml
@@ -0,0 +1,1292 @@
+<center code='98'>
+    <table code='171'>
+    <param code='1' mars=''
+           short_title='-'
+           long_title='Stream function'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='2' mars=''
+           short_title='-'
+           long_title='Velocity potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='3' mars=''
+           short_title='-'
+           long_title='Potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='4' mars=''
+           short_title='-'
+           long_title='Equivalent potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='5' mars=''
+           short_title='-'
+           long_title='Saturated equivalent potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='11' mars=''
+           short_title='-'
+           long_title='U component of divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='12' mars=''
+           short_title='-'
+           long_title='V component of divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='13' mars=''
+           short_title='-'
+           long_title='U component of rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='14' mars=''
+           short_title='-'
+           long_title='V component of rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='21' mars=''
+           short_title='-'
+           long_title='Unbalanced component of temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='22' mars=''
+           short_title='-'
+           long_title='Unbalanced component of logarithm of surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='23' mars=''
+           short_title='-'
+           long_title='Unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='26' mars=''
+           short_title='-'
+           long_title='Lake cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='27' mars=''
+           short_title='-'
+           long_title='Low vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='28' mars=''
+           short_title='-'
+           long_title='High vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='29' mars=''
+           short_title='-'
+           long_title='Type of low vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='30' mars=''
+           short_title='-'
+           long_title='Type of high vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='31' mars=''
+           short_title='-'
+           long_title='Sea-ice cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='32' mars=''
+           short_title='-'
+           long_title='Snow albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='33' mars=''
+           short_title='-'
+           long_title='Snow density'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='34' mars=''
+           short_title='-'
+           long_title='Sea surface temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='35' mars=''
+           short_title='-'
+           long_title='Ice surface temperature layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='36' mars=''
+           short_title='-'
+           long_title='Ice surface temperature layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='37' mars=''
+           short_title='-'
+           long_title='Ice surface temperature layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='38' mars=''
+           short_title='-'
+           long_title='Ice surface temperature layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='39' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='40' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='41' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='42' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='43' mars=''
+           short_title='-'
+           long_title='Soil type'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='44' mars=''
+           short_title='-'
+           long_title='Snow evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='45' mars=''
+           short_title='-'
+           long_title='Snowmelt'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='46' mars=''
+           short_title='-'
+           long_title='Solar duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='47' mars=''
+           short_title='-'
+           long_title='Direct solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='48' mars=''
+           short_title='-'
+           long_title='Magnitude of surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='49' mars=''
+           short_title='-'
+           long_title='10 metre wind gust'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='50' mars=''
+           short_title='-'
+           long_title='Large-scale precipitation fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='51' mars=''
+           short_title='-'
+           long_title='Maximum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='52' mars=''
+           short_title='-'
+           long_title='Minimum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='53' mars=''
+           short_title='-'
+           long_title='Montgomery potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='54' mars=''
+           short_title='-'
+           long_title='Pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='55' mars=''
+           short_title='-'
+           long_title='Mean 2 metre temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='56' mars=''
+           short_title='-'
+           long_title='Mean 2 metre dewpoint temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='57' mars=''
+           short_title='-'
+           long_title='Downward UV radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='58' mars=''
+           short_title='-'
+           long_title='Photosynthetically active radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='59' mars=''
+           short_title='-'
+           long_title='Convective available potential energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='60' mars=''
+           short_title='-'
+           long_title='Potential vorticity'
+           scaling='1.0' offset='-0.0'
+           original_unit='K m**2 kg**-1 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='61' mars=''
+           short_title='-'
+           long_title='Total precipitation from observations'
+           scaling='1.0' offset='-0.0'
+           original_unit='Millimetres*100 + number of stations' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='62' mars=''
+           short_title='-'
+           long_title='Observation count'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='63' mars=''
+           short_title='-'
+           long_title='Start time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='64' mars=''
+           short_title='-'
+           long_title='Finish time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='65' mars=''
+           short_title='-'
+           long_title='Skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='78' mars=''
+           short_title='-'
+           long_title='Total column liquid water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='79' mars=''
+           short_title='-'
+           long_title='Total column ice water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='125' mars=''
+           short_title='-'
+           long_title='Vertically integrated total energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='126' mars=''
+           short_title='-'
+           long_title='Generic parameter for sensitive area prediction'
+           scaling='1.0' offset='-0.0'
+           original_unit='Various' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='127' mars=''
+           short_title='-'
+           long_title='Atmospheric tide'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='128' mars=''
+           short_title='-'
+           long_title='Budget values'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='129' mars=''
+           short_title='-'
+           long_title='Geopotential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='130' mars=''
+           short_title='-'
+           long_title='Temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='131' mars=''
+           short_title='-'
+           long_title='U velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='132' mars=''
+           short_title='-'
+           long_title='V velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='133' mars=''
+           short_title='-'
+           long_title='Specific humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='134' mars=''
+           short_title='-'
+           long_title='Surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='135' mars=''
+           short_title='-'
+           long_title='Vertical velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='136' mars=''
+           short_title='-'
+           long_title='Total column water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='137' mars=''
+           short_title='-'
+           long_title='Total column water vapour'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='138' mars=''
+           short_title='-'
+           long_title='Vorticity (relative)'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='139' mars=''
+           short_title='-'
+           long_title='Soil temperature level 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='140' mars=''
+           short_title='-'
+           long_title='Soil wetness level 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='141' mars=''
+           short_title='-'
+           long_title='Snow depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='142' mars=''
+           short_title='-'
+           long_title='Stratiform precipitation (Large-scale precipitation)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='143' mars=''
+           short_title='-'
+           long_title='Convective precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='144' mars=''
+           short_title='-'
+           long_title='Snowfall (convective + stratiform)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='145' mars=''
+           short_title='-'
+           long_title='Boundary layer dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='146' mars=''
+           short_title='-'
+           long_title='Surface sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='147' mars=''
+           short_title='-'
+           long_title='Surface latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='148' mars=''
+           short_title='-'
+           long_title='Charnock'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='149' mars=''
+           short_title='-'
+           long_title='Surface net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='150' mars=''
+           short_title='-'
+           long_title='Top net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='151' mars=''
+           short_title='-'
+           long_title='Mean sea level pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='152' mars=''
+           short_title='-'
+           long_title='Logarithm of surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='153' mars=''
+           short_title='-'
+           long_title='Short-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='154' mars=''
+           short_title='-'
+           long_title='Long-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='155' mars=''
+           short_title='-'
+           long_title='Divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='156' mars=''
+           short_title='-'
+           long_title='Height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='157' mars=''
+           short_title='-'
+           long_title='Relative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='158' mars=''
+           short_title='-'
+           long_title='Tendency of surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='159' mars=''
+           short_title='-'
+           long_title='Boundary layer height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='160' mars=''
+           short_title='-'
+           long_title='Standard deviation of orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='161' mars=''
+           short_title='-'
+           long_title='Anisotropy of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='162' mars=''
+           short_title='-'
+           long_title='Angle of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='rad' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='163' mars=''
+           short_title='-'
+           long_title='Slope of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='164' mars=''
+           short_title='-'
+           long_title='Total cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='165' mars=''
+           short_title='-'
+           long_title='10 metre U wind component'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='166' mars=''
+           short_title='-'
+           long_title='10 metre V wind component'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='167' mars=''
+           short_title='-'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='-'
+           long_title='2 metre dewpoint temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='169' mars=''
+           short_title='-'
+           long_title='Surface solar radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='170' mars=''
+           short_title='-'
+           long_title='Soil temperature level 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='171' mars=''
+           short_title='-'
+           long_title='Soil wetness level 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='172' mars=''
+           short_title='-'
+           long_title='Land-sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='173' mars=''
+           short_title='-'
+           long_title='Surface roughness'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='174' mars=''
+           short_title='-'
+           long_title='Albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='175' mars=''
+           short_title='-'
+           long_title='Surface thermal radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='176' mars=''
+           short_title='-'
+           long_title='Surface solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='177' mars=''
+           short_title='-'
+           long_title='Surface thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='178' mars=''
+           short_title='-'
+           long_title='Top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='179' mars=''
+           short_title='-'
+           long_title='Top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='180' mars=''
+           short_title='-'
+           long_title='East-West surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='181' mars=''
+           short_title='-'
+           long_title='North-South surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='182' mars=''
+           short_title='-'
+           long_title='Evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='183' mars=''
+           short_title='-'
+           long_title='Soil temperature level 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='184' mars=''
+           short_title='-'
+           long_title='Soil wetness level 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='185' mars=''
+           short_title='-'
+           long_title='Convective cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='186' mars=''
+           short_title='-'
+           long_title='Low cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='187' mars=''
+           short_title='-'
+           long_title='Medium cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='188' mars=''
+           short_title='-'
+           long_title='High cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='189' mars=''
+           short_title='-'
+           long_title='Sunshine duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='190' mars=''
+           short_title='-'
+           long_title='East-West component of sub-gridscale orographic variance'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='191' mars=''
+           short_title='-'
+           long_title='North-South component of sub-gridscale orographic variance'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='192' mars=''
+           short_title='-'
+           long_title='North-West/South-East component of sub-gridscale orographic variance'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='193' mars=''
+           short_title='-'
+           long_title='North-East/South-West component of sub-gridscale orographic variance'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='194' mars=''
+           short_title='-'
+           long_title='Brightness temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='195' mars=''
+           short_title='-'
+           long_title='Latitudinal component of gravity wave stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='196' mars=''
+           short_title='-'
+           long_title='Meridional component of gravity wave stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='197' mars=''
+           short_title='-'
+           long_title='Gravity wave dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='198' mars=''
+           short_title='-'
+           long_title='Skin reservoir content'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='199' mars=''
+           short_title='-'
+           long_title='Vegetation fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='200' mars=''
+           short_title='-'
+           long_title='Variance of sub-gridscale orography'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='201' mars=''
+           short_title='-'
+           long_title='Maximum temperature at 2 metres since previous post-processing'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='202' mars=''
+           short_title='-'
+           long_title='Minimum temperature at 2 metres since previous post-processing'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='203' mars=''
+           short_title='-'
+           long_title='Ozone mass mixing ratio'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='204' mars=''
+           short_title='-'
+           long_title='Precipitation analysis weights'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='205' mars=''
+           short_title='-'
+           long_title='Runoff'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='206' mars=''
+           short_title='-'
+           long_title='Total column ozone'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='207' mars=''
+           short_title='-'
+           long_title='10 metre wind speed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='208' mars=''
+           short_title='-'
+           long_title='Top net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='209' mars=''
+           short_title='-'
+           long_title='Top net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='210' mars=''
+           short_title='-'
+           long_title='Surface net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='211' mars=''
+           short_title='-'
+           long_title='Surface net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='212' mars=''
+           short_title='-'
+           long_title='Solar insolation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='214' mars=''
+           short_title='-'
+           long_title='Diabatic heating by radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='215' mars=''
+           short_title='-'
+           long_title='Diabatic heating by vertical diffusion'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='216' mars=''
+           short_title='-'
+           long_title='Diabatic heating by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='217' mars=''
+           short_title='-'
+           long_title='Diabatic heating by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='218' mars=''
+           short_title='-'
+           long_title='Vertical diffusion of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='219' mars=''
+           short_title='-'
+           long_title='Vertical diffusion of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='220' mars=''
+           short_title='-'
+           long_title='East-West gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='221' mars=''
+           short_title='-'
+           long_title='North-South gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='222' mars=''
+           short_title='-'
+           long_title='Convective tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='223' mars=''
+           short_title='-'
+           long_title='Convective tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='224' mars=''
+           short_title='-'
+           long_title='Vertical diffusion of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='225' mars=''
+           short_title='-'
+           long_title='Humidity tendency by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='226' mars=''
+           short_title='-'
+           long_title='Humidity tendency by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='227' mars=''
+           short_title='-'
+           long_title='Change from removal of negative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='228' mars=''
+           short_title='-'
+           long_title='Total precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='229' mars=''
+           short_title='-'
+           long_title='Instantaneous X surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='230' mars=''
+           short_title='-'
+           long_title='Instantaneous Y surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='231' mars=''
+           short_title='-'
+           long_title='Instantaneous surface heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='232' mars=''
+           short_title='-'
+           long_title='Instantaneous moisture flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='233' mars=''
+           short_title='-'
+           long_title='Apparent surface humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='234' mars=''
+           short_title='-'
+           long_title='Logarithm of surface roughness length for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='235' mars=''
+           short_title='-'
+           long_title='Skin temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='236' mars=''
+           short_title='-'
+           long_title='Soil temperature level 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='237' mars=''
+           short_title='-'
+           long_title='Soil wetness level 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='238' mars=''
+           short_title='-'
+           long_title='Temperature of snow layer'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='239' mars=''
+           short_title='-'
+           long_title='Convective snowfall'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='240' mars=''
+           short_title='-'
+           long_title='Large-scale snowfall'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='241' mars=''
+           short_title='-'
+           long_title='Accumulated cloud fraction tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='242' mars=''
+           short_title='-'
+           long_title='Accumulated liquid water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='243' mars=''
+           short_title='-'
+           long_title='Forecast albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='244' mars=''
+           short_title='-'
+           long_title='Forecast surface roughness'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='245' mars=''
+           short_title='-'
+           long_title='Forecast logarithm of surface roughness for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='246' mars=''
+           short_title='-'
+           long_title='Cloud liquid water content'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='247' mars=''
+           short_title='-'
+           long_title='Cloud ice water content'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='248' mars=''
+           short_title='-'
+           long_title='Cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='249' mars=''
+           short_title='-'
+           long_title='Accumulated ice water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='250' mars=''
+           short_title='-'
+           long_title='Ice age'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='251' mars=''
+           short_title='-'
+           long_title='Adiabatic tendency of temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='252' mars=''
+           short_title='-'
+           long_title='Adiabatic tendency of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='253' mars=''
+           short_title='-'
+           long_title='Adiabatic tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='254' mars=''
+           short_title='-'
+           long_title='Adiabatic tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='255' mars=''
+           short_title='-'
+           long_title='Indicates a missing value'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_172.xml b/share/magics/table_172.xml
new file mode 100644
index 0000000..e78c8a4
--- /dev/null
+++ b/share/magics/table_172.xml
@@ -0,0 +1,256 @@
+<center code='98'>
+    <table code='172'>
+    <param code='44' mars=''
+           short_title='-'
+           long_title='Snow evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='45' mars=''
+           short_title='-'
+           long_title='Snowmelt'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='48' mars=''
+           short_title='-'
+           long_title='Magnitude of surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='50' mars=''
+           short_title='-'
+           long_title='Large-scale precipitation fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='142' mars=''
+           short_title='-'
+           long_title='Stratiform precipitation (Large-scale precipitation)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='143' mars=''
+           short_title='-'
+           long_title='Convective precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='144' mars=''
+           short_title='-'
+           long_title='Snowfall (convective + stratiform)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='145' mars=''
+           short_title='-'
+           long_title='Boundary layer dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='146' mars=''
+           short_title='-'
+           long_title='Surface sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='147' mars=''
+           short_title='-'
+           long_title='Surface latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='149' mars=''
+           short_title='-'
+           long_title='Surface net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='153' mars=''
+           short_title='-'
+           long_title='Short-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='154' mars=''
+           short_title='-'
+           long_title='Long-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='169' mars=''
+           short_title='-'
+           long_title='Surface solar radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='175' mars=''
+           short_title='-'
+           long_title='Surface thermal radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='176' mars=''
+           short_title='-'
+           long_title='Surface solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='177' mars=''
+           short_title='-'
+           long_title='Surface thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='178' mars=''
+           short_title='-'
+           long_title='Top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='179' mars=''
+           short_title='-'
+           long_title='Top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='180' mars=''
+           short_title='-'
+           long_title='East-West surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='181' mars=''
+           short_title='-'
+           long_title='North-South surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='182' mars=''
+           short_title='-'
+           long_title='Evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='189' mars=''
+           short_title='-'
+           long_title='Sunshine duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='195' mars=''
+           short_title='-'
+           long_title='Latitudinal component of gravity wave stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='196' mars=''
+           short_title='-'
+           long_title='Meridional component of gravity wave stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='197' mars=''
+           short_title='-'
+           long_title='Gravity wave dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='205' mars=''
+           short_title='-'
+           long_title='Runoff'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='208' mars=''
+           short_title='-'
+           long_title='Top net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='209' mars=''
+           short_title='-'
+           long_title='Top net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='210' mars=''
+           short_title='-'
+           long_title='Surface net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='211' mars=''
+           short_title='-'
+           long_title='Surface net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='212' mars=''
+           short_title='-'
+           long_title='Solar insolation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='228' mars=''
+           short_title='-'
+           long_title='Total precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='239' mars=''
+           short_title='-'
+           long_title='Convective snowfall'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='240' mars=''
+           short_title='-'
+           long_title='Large-scale snowfall'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='255' mars=''
+           short_title='-'
+           long_title='Indicates a missing value'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_173.xml b/share/magics/table_173.xml
new file mode 100644
index 0000000..34f0c21
--- /dev/null
+++ b/share/magics/table_173.xml
@@ -0,0 +1,4 @@
+<center code='98'>
+    <table code='173'>
+     </table>
+</center>
diff --git a/share/magics/table_174.xml b/share/magics/table_174.xml
new file mode 100644
index 0000000..b9ab057
--- /dev/null
+++ b/share/magics/table_174.xml
@@ -0,0 +1,179 @@
+<center code='98'>
+    <table code='174'>
+    <param code='31' mars=''
+           short_title='-'
+           long_title='Fraction of sea-ice in sea'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='34' mars=''
+           short_title='-'
+           long_title='Open-sea surface temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='39' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='40' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='41' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='42' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='55' mars=''
+           short_title='-'
+           long_title='1.5m temperature - mean over last 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='83' mars=''
+           short_title='-'
+           long_title='Net primary productivity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg C m**-2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='85' mars=''
+           short_title='-'
+           long_title='10m U wind over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='86' mars=''
+           short_title='-'
+           long_title='10m V wind over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='87' mars=''
+           short_title='-'
+           long_title='1.5m temperature over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='88' mars=''
+           short_title='-'
+           long_title='1.5m dewpoint temperature over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='110' mars=''
+           short_title='-'
+           long_title='Ocean ice concentration'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='111' mars=''
+           short_title='-'
+           long_title='Ocean mean ice depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='139' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='164' mars=''
+           short_title='-'
+           long_title='Average potential temperature in upper 293.4m'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='167' mars=''
+           short_title='-'
+           long_title='1.5m temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='-'
+           long_title='1.5m dewpoint temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='170' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='172' mars=''
+           short_title='-'
+           long_title='Fractional land mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='175' mars=''
+           short_title='-'
+           long_title='Average salinity in upper 293.4m'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='183' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='201' mars=''
+           short_title='-'
+           long_title='1.5m temperature - maximum over last 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='202' mars=''
+           short_title='-'
+           long_title='1.5m temperature - minimum over last 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='236' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_175.xml b/share/magics/table_175.xml
new file mode 100644
index 0000000..0de2d12
--- /dev/null
+++ b/share/magics/table_175.xml
@@ -0,0 +1,179 @@
+<center code='98'>
+    <table code='175'>
+    <param code='31' mars=''
+           short_title='-'
+           long_title='Fraction of sea-ice in sea'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='34' mars=''
+           short_title='-'
+           long_title='Open-sea surface temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='39' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='40' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='41' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='42' mars=''
+           short_title='-'
+           long_title='Volumetric soil water layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='55' mars=''
+           short_title='-'
+           long_title='1.5m temperature - mean over last 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='83' mars=''
+           short_title='-'
+           long_title='Net primary productivity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg C m**-2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='85' mars=''
+           short_title='-'
+           long_title='10m U wind over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='86' mars=''
+           short_title='-'
+           long_title='10m V wind over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='87' mars=''
+           short_title='-'
+           long_title='1.5m temperature over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='88' mars=''
+           short_title='-'
+           long_title='1.5m dewpoint temperature over land'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='110' mars=''
+           short_title='-'
+           long_title='Ocean ice concentration'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='111' mars=''
+           short_title='-'
+           long_title='Ocean mean ice depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='139' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='164' mars=''
+           short_title='-'
+           long_title='Average potential temperature in upper 293.4m'
+           scaling='1.0' offset='-0.0'
+           original_unit='degrees C' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='167' mars=''
+           short_title='-'
+           long_title='1.5m temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='-'
+           long_title='1.5m dewpoint temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='170' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='172' mars=''
+           short_title='-'
+           long_title='Fractional land mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='175' mars=''
+           short_title='-'
+           long_title='Average salinity in upper 293.4m'
+           scaling='1.0' offset='-0.0'
+           original_unit='psu' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='183' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='201' mars=''
+           short_title='-'
+           long_title='1.5m temperature - maximum over last 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='202' mars=''
+           short_title='-'
+           long_title='1.5m temperature - minimum over last 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='236' mars=''
+           short_title='-'
+           long_title='Soil temperature layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_180.xml b/share/magics/table_180.xml
new file mode 100644
index 0000000..95a08df
--- /dev/null
+++ b/share/magics/table_180.xml
@@ -0,0 +1,221 @@
+<center code='98'>
+    <table code='180'>
+    <param code='129' mars=''
+           short_title='Z'
+           long_title='Geopotential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='130' mars=''
+           short_title='T'
+           long_title='Temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='131' mars=''
+           short_title='U'
+           long_title='U velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='132' mars=''
+           short_title='V'
+           long_title='V velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='133' mars=''
+           short_title='Q'
+           long_title='Specific humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='134' mars=''
+           short_title='SP'
+           long_title='Surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='137' mars=''
+           short_title='TCWV'
+           long_title='Total column water vapour'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='138' mars=''
+           short_title='VO'
+           long_title='Vorticity (relative)'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='141' mars=''
+           short_title='SD'
+           long_title='Snow depth'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='142' mars=''
+           short_title='LSP'
+           long_title='Large-scale precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='143' mars=''
+           short_title='CP'
+           long_title='Convective precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='144' mars=''
+           short_title='SF'
+           long_title='Snowfall'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='146' mars=''
+           short_title='SSHF'
+           long_title='Surface sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='147' mars=''
+           short_title='SLHF'
+           long_title='Surface latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='149' mars=''
+           short_title='TSW'
+           long_title='Total soil wetness'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='151' mars=''
+           short_title='MSL'
+           long_title='Mean sea level pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='155' mars=''
+           short_title='D'
+           long_title='Divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='164' mars=''
+           short_title='TCC'
+           long_title='Total cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='165' mars=''
+           short_title='10U'
+           long_title='10 metre U wind component'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='166' mars=''
+           short_title='10V'
+           long_title='10 metre V wind component'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='167' mars=''
+           short_title='2T'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='2D'
+           long_title='2 metre dewpoint temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='172' mars=''
+           short_title='LSM'
+           long_title='Land-sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='176' mars=''
+           short_title='SSR'
+           long_title='Surface solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='177' mars=''
+           short_title='STR'
+           long_title='Surface thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='178' mars=''
+           short_title='TSR'
+           long_title='Top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='179' mars=''
+           short_title='TTR'
+           long_title='Top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='180' mars=''
+           short_title='EWSS'
+           long_title='East-West surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='181' mars=''
+           short_title='NSSS'
+           long_title='North-South surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='182' mars=''
+           short_title='E'
+           long_title='Evaporation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m of water' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='205' mars=''
+           short_title='RO'
+           long_title='Runoff'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_190.xml b/share/magics/table_190.xml
new file mode 100644
index 0000000..94781f6
--- /dev/null
+++ b/share/magics/table_190.xml
@@ -0,0 +1,221 @@
+<center code='98'>
+    <table code='190'>
+    <param code='129' mars=''
+           short_title='Z'
+           long_title='Geopotential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='130' mars=''
+           short_title='T'
+           long_title='Temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='C'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='131' mars=''
+           short_title='U'
+           long_title='U-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='132' mars=''
+           short_title='V'
+           long_title='V-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='133' mars=''
+           short_title='Q'
+           long_title='Specific humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='139' mars=''
+           short_title='ST/STL1'
+           long_title='Surface temperature/soil temperature level 1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='C'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p0'/>
+    <param code='141' mars=''
+           short_title='D SNOW'
+           long_title='Snow depth'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='146' mars=''
+           short_title='surf sens ht flux'
+           long_title='surf sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p18'/>
+    <param code='147' mars=''
+           short_title='surf lat ht flux'
+           long_title='surf latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p19'/>
+    <param code='151' mars=''
+           short_title='D MSL'
+           long_title='Mean sea-level pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hPa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='164' mars=''
+           short_title='D CLOUD'
+           long_title='Total cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification=''/>
+    <param code='165' mars=''
+           short_title='D 10M U'
+           long_title='10 metre u wind component'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='166' mars=''
+           short_title='D 10M V'
+           long_title='10 metre v wind component'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='167' mars=''
+           short_title='D 2M T'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='C'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='168' mars=''
+           short_title='D 2M TD'
+           long_title='2 metre dewpoint temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='C'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='169' mars=''
+           short_title='D DSSR'
+           long_title='Downward surface solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s (W m**-2 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='170' mars=''
+           short_title='D CAP'
+           long_title='Field capacity'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='171' mars=''
+           short_title='D WILT'
+           long_title='Wilting points'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='172' mars=''
+           short_title='D LSM'
+           long_title='Land-sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='173' mars=''
+           short_title='D RL'
+           long_title='Roughness length'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='174' mars=''
+           short_title='D AL'
+           long_title='Albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='175' mars=''
+           short_title='D DSLR'
+           long_title='Downward surface longwave radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s (W m**-2 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='176' mars=''
+           short_title='D SNSR'
+           long_title='Surface net solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s (W m**-2 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='177' mars=''
+           short_title='D SNLR'
+           long_title='Surface net longwave radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s (W m**-2 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='178' mars=''
+           short_title='D TNSR'
+           long_title='Top net solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s (W m**-2 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='179' mars=''
+           short_title='D TNLR'
+           long_title='Top net longwave radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s (W m**-2 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='201' mars=''
+           short_title='TMAX'
+           long_title='Maximum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='202' mars=''
+           short_title='TMIN'
+           long_title='Minimum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='228' mars=''
+           short_title='D TP'
+           long_title='Total precipitation'
+           scaling='1.0' offset='-0.0'
+           original_unit='m (m s**-1 for monthly means)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='229' mars=''
+           short_title='D TSM'
+           long_title='Total soil moisture'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='255' mars=''
+           short_title='Missing'
+           long_title=''
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_2.xml b/share/magics/table_2.xml
new file mode 100644
index 0000000..250ca94
--- /dev/null
+++ b/share/magics/table_2.xml
@@ -0,0 +1,10 @@
+<center code='7'>
+    <table code='2'>
+        <param code='11' mars=''
+           short_title='temp'
+           long_title='temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+        />
+    </table>
+</center>
diff --git a/share/magics/table_200.xml b/share/magics/table_200.xml
new file mode 100644
index 0000000..38a5572
--- /dev/null
+++ b/share/magics/table_200.xml
@@ -0,0 +1,1299 @@
+<center code='98'>
+    <table code='200'>
+    <param code='1' mars=''
+           short_title='strm fun'
+           long_title='stream function'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='2' mars=''
+           short_title='vel pot'
+           long_title='velocity potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='3' mars=''
+           short_title='pot temp'
+           long_title='potential temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='4' mars=''
+           short_title='eq pot temp'
+           long_title='equiv potential temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='5' mars=''
+           short_title='sat eq pot temp'
+           long_title='sat equiv pot temp'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit='deg k'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification=''/>
+    <param code='11' mars=''
+           short_title='u-com div wind'
+           long_title='u-comp divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='12' mars=''
+           short_title='v-com div wind'
+           long_title='v-comp divergent wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='13' mars=''
+           short_title='u-com rot wind'
+           long_title='u-comp rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='14' mars=''
+           short_title='v-com rot wind'
+           long_title='v-comp rotational wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='21' mars=''
+           short_title='UCTP'
+           long_title='Unbalanced component of temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='22' mars=''
+           short_title='UCLN'
+           long_title='Unbalanced component of logarithm of surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='23' mars=''
+           short_title='UCDV'
+           long_title='Unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='24' mars=''
+           short_title='None'
+           long_title='Reserved for future unbalanced components'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='25' mars=''
+           short_title='None'
+           long_title='Reserved for future unbalanced components'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='26' mars=''
+           short_title='CL'
+           long_title='Lake cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='27' mars=''
+           short_title='low veg cover'
+           long_title='low vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='28' mars=''
+           short_title='high veg cover'
+           long_title='high vegetation cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='29' mars=''
+           short_title='type low veg'
+           long_title='type of low vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='30' mars=''
+           short_title='type high veg'
+           long_title='type of high vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='31' mars=''
+           short_title='sea ice cover'
+           long_title='sea ice cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='32' mars=''
+           short_title='snow albedo'
+           long_title='snow albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='33' mars=''
+           short_title='snow density'
+           long_title='snow density'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-3' derived_unit='kg**3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='34' mars=''
+           short_title='sea surf temp'
+           long_title='sea surface temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='35' mars=''
+           short_title='ice surf temp layer1'
+           long_title='ice surface temperature layer 1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='36' mars=''
+           short_title='ice surf temp layer2'
+           long_title='ice surface temperature layer 2'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='37' mars=''
+           short_title='ice surf temp layer3'
+           long_title='ice surface temperature layer 3'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='38' mars=''
+           short_title='ice surf temp layer4'
+           long_title='ice surface temperature layer 4'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='39' mars=''
+           short_title='vol soil water layer1'
+           long_title='volumetric soil water layer 1'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='40' mars=''
+           short_title='vol soil water layer2'
+           long_title='volumetric soil water layer 2'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='41' mars=''
+           short_title='vol soil water layer3'
+           long_title='volumetric soil water layer 3'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='42' mars=''
+           short_title='vol soil water layer4'
+           long_title='volumetric soil water layer 4'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**3 m**-3' derived_unit='m3m-3'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='43' mars=''
+           short_title='SLT'
+           long_title='Soil type'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='44' mars=''
+           short_title='evap snow'
+           long_title='evaporation of snow'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='45' mars=''
+           short_title='snow melt'
+           long_title='snow melt'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='46' mars=''
+           short_title='SDUR'
+           long_title='Solar duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='47' mars=''
+           short_title='DSRP'
+           long_title='Direct solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='48' mars=''
+           short_title='MAGSS'
+           long_title='Magnitude of surface stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='49' mars=''
+           short_title='gust 10m'
+           long_title='wind gust at 10m'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='50' mars=''
+           short_title='LSPF'
+           long_title='Large-scale precipitation fraction'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='51' mars=''
+           short_title='MX2T24'
+           long_title='Maximum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='52' mars=''
+           short_title='MN2T24'
+           long_title='Minimum 2 metre temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='53' mars=''
+           short_title='mont pot'
+           long_title='montgomery potential'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='54' mars=''
+           short_title='pres'
+           long_title='pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hPa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='55' mars=''
+           short_title='MN2T24'
+           long_title='Mean 2 metre temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='56' mars=''
+           short_title='MN2D24'
+           long_title='Mean 2 metre dewpoint temperature in past 24 hours'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='57' mars=''
+           short_title='UVB'
+           long_title='Downward UV radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='58' mars=''
+           short_title='PAR'
+           long_title='Photosynthetically active radiation at the surface'
+           scaling='1.0' offset='-0.0'
+           original_unit='w m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='59' mars=''
+           short_title='CAPE'
+           long_title='Convective available potential energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='60' mars=''
+           short_title='pv'
+           long_title='potential vorticity'
+           scaling='1000000.0' offset='-0.0'
+           original_unit='K m**2 kg**-1 s**-1' derived_unit='pv units'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='61' mars=''
+           short_title='TPO'
+           long_title='Total precipitation from observations'
+           scaling='1.0' offset='-0.0'
+           original_unit='Millimetres*100 + number of stations' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='62' mars=''
+           short_title='OBCT'
+           long_title='Observation count'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='63' mars=''
+           short_title='-'
+           long_title='Start time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='64' mars=''
+           short_title='-'
+           long_title='Finish time for skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='65' mars=''
+           short_title='-'
+           long_title='Skin temperature difference'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='78' mars=''
+           short_title='TCLW'
+           long_title='Total Column Liquid Water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='79' mars=''
+           short_title='TCIW'
+           long_title='Total Column Ice Water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='125' mars=''
+           short_title='-'
+           long_title='Vertically integrated total energy'
+           scaling='1.0' offset='-0.0'
+           original_unit='J m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='126' mars=''
+           short_title='-'
+           long_title='Generic parameter for sensitive area prediction'
+           scaling='1.0' offset='-0.0'
+           original_unit='Various' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='127' mars=''
+           short_title='atmos tide'
+           long_title='atmospheric tide'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='128' mars=''
+           short_title='budg val'
+           long_title='budget values'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='129' mars=''
+           short_title='geop'
+           long_title='geopotential height'
+           scaling='0.0101971621297793' offset='-0.0'
+           original_unit='m**2 s**-2' derived_unit='dam'
+           vector1='0' vector2='0'
+           contour_interval='8.0' specification='p1'/>
+    <param code='130' mars=''
+           short_title='temp'
+           long_title='temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p2'/>
+    <param code='131' mars=''
+           short_title='u-vel'
+           long_title='u-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p3'/>
+    <param code='132' mars=''
+           short_title='v-vel'
+           long_title='v-velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p4'/>
+    <param code='133' mars=''
+           short_title='spec hum'
+           long_title='specific humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p5'/>
+    <param code='134' mars=''
+           short_title='surf pres'
+           long_title='surface pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p6'/>
+    <param code='135' mars=''
+           short_title='vert vel'
+           long_title='vertical velocity'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p7'/>
+    <param code='136' mars=''
+           short_title='tot col wat'
+           long_title='total column water'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='137' mars=''
+           short_title='tot col wat vap'
+           long_title='total column water vapour'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='kg/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='138' mars=''
+           short_title='vort'
+           long_title='vorticity'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p10'/>
+    <param code='139' mars=''
+           short_title='soil temp lyr1'
+           long_title='soil temperature layer1'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='4.0' specification='p11'/>
+    <param code='140' mars=''
+           short_title='soil wet lyr 1'
+           long_title='soil wetness layer 1'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p12'/>
+    <param code='141' mars=''
+           short_title='snow depth'
+           long_title='snow depth'
+           scaling='100.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p13'/>
+    <param code='142' mars=''
+           short_title='lge scl prec'
+           long_title='large scale precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p14'/>
+    <param code='143' mars=''
+           short_title='conv prec'
+           long_title='convective precip'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p15'/>
+    <param code='144' mars=''
+           short_title='snowf'
+           long_title='snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p16'/>
+    <param code='145' mars=''
+           short_title='bound lyr diss'
+           long_title='boundary layer dissip'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p17'/>
+    <param code='146' mars=''
+           short_title='surf sens ht flux'
+           long_title='surf sensible heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p18'/>
+    <param code='147' mars=''
+           short_title='surf lat ht flux'
+           long_title='surf latent heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p19'/>
+    <param code='148' mars=''
+           short_title='CHNK'
+           long_title='Charnock'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='149' mars=''
+           short_title='SNR'
+           long_title='Surface net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='150' mars=''
+           short_title='TNR'
+           long_title='Top net radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='151' mars=''
+           short_title='msl'
+           long_title='mean sea level pressure'
+           scaling='0.01' offset='-0.0'
+           original_unit='Pa' derived_unit='hpa'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p23'/>
+    <param code='152' mars=''
+           short_title='log surf pres'
+           long_title='log surface pressure'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p24'/>
+    <param code='153' mars=''
+           short_title='SWHR'
+           long_title='Short-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='154' mars=''
+           short_title='LWHR'
+           long_title='Long-wave heating rate'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='155' mars=''
+           short_title='diverg'
+           long_title='divergence'
+           scaling='100000.0' offset='-0.0'
+           original_unit='s**-1' derived_unit='10**5/sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p27'/>
+    <param code='156' mars=''
+           short_title='hgt (geop)'
+           long_title='height (geopotential)'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='40.0' specification='p28'/>
+    <param code='157' mars=''
+           short_title='rel hum'
+           long_title='relative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='%' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='20.0' specification='p29'/>
+    <param code='158' mars=''
+           short_title='surf press tend'
+           long_title='tendency of surf press'
+           scaling='1.0' offset='-0.0'
+           original_unit='Pa s**-1' derived_unit='pa/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p30'/>
+    <param code='159' mars=''
+           short_title='bound layer hgt'
+           long_title='boundary layer height'
+           scaling='1.0' offset='-0.0'
+           original_unit='m' derived_unit='m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='160' mars=''
+           short_title='stdev orog'
+           long_title='std dev of orography'
+           scaling='100.0' offset='-0.0'
+           original_unit='' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='161' mars=''
+           short_title='anisot sub-grid orog'
+           long_title='anistropy of sub-gridscale orography'
+           scaling='0.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='162' mars=''
+           short_title='angle sub-grid orog'
+           long_title='angle of sub-gridscale orography'
+           scaling='0.0' offset='-0.0'
+           original_unit='rad' derived_unit='rad'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='163' mars=''
+           short_title='slope sub-grid orog'
+           long_title='slope of sub-gridscale orography'
+           scaling='0.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='164' mars=''
+           short_title='tot cldcov'
+           long_title='total cloudcover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.1' specification='p36'/>
+    <param code='165' mars=''
+           short_title='10m u'
+           long_title='10 mtr u'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p37'/>
+    <param code='166' mars=''
+           short_title='10m v'
+           long_title='10 mtr v'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit='m/s'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p38'/>
+    <param code='167' mars=''
+           short_title='2m temp'
+           long_title='2 metre temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p39'/>
+    <param code='168' mars=''
+           short_title='2m dewp'
+           long_title='2 metre dewpoint temp'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p40'/>
+    <param code='169' mars=''
+           short_title='sur sol rad dwn'
+           long_title='surf solar radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='170' mars=''
+           short_title='soil temp lyr2'
+           long_title='soil temperature layer2'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p42'/>
+    <param code='171' mars=''
+           short_title='soil wet lyr2'
+           long_title='soil wetness layer2'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='1.0' specification='p43'/>
+    <param code='172' mars=''
+           short_title='l/sea mask'
+           long_title='land/ sea mask'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='0/1'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='173' mars=''
+           short_title='surf rough'
+           long_title='surface roughness'
+           scaling='100.0' offset='-0.0'
+           original_unit='m' derived_unit='cm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='174' mars=''
+           short_title='albedo'
+           long_title='albedo'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='175' mars=''
+           short_title='sur ther rad dwn'
+           long_title='surf thermal radiation downwards'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='176' mars=''
+           short_title='surf solrad'
+           long_title='surf solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='177' mars=''
+           short_title='surf ther rad'
+           long_title='surf thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='178' mars=''
+           short_title='topsolrad'
+           long_title='top solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='179' mars=''
+           short_title='top ther rad'
+           long_title='top thermal radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='180' mars=''
+           short_title='u-stress'
+           long_title='u-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='181' mars=''
+           short_title='v-stress'
+           long_title='v-stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='182' mars=''
+           short_title='evap'
+           long_title='evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='183' mars=''
+           short_title='soil temp lyr3'
+           long_title='soil temperature layer3'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='184' mars=''
+           short_title='soil wet lyr3'
+           long_title='soil wetness layer3'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='185' mars=''
+           short_title='conv cld cov'
+           long_title='convective cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='186' mars=''
+           short_title='low cld cov'
+           long_title='low cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='187' mars=''
+           short_title='med cld cov'
+           long_title='medium cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='188' mars=''
+           short_title='hi cld cov'
+           long_title='high cloud cover'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='189' mars=''
+           short_title='sun duration'
+           long_title='sunshine duration'
+           scaling='1.0' offset='-0.0'
+           original_unit='s' derived_unit='sec'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='190' mars=''
+           short_title='ew comp subgrid orog var'
+           long_title='ew comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='191' mars=''
+           short_title='ns comp subgrid orog var'
+           long_title='ns comp subgrid orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='192' mars=''
+           short_title='nwse com subgrd orog var'
+           long_title='nwse com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='193' mars=''
+           short_title='nswe com subgrd orog var'
+           long_title='nswe com subgrd orog var'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='194' mars=''
+           short_title='BTMP'
+           long_title='Brightness temperature'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='195' mars=''
+           short_title='lat comp grav wav stress'
+           long_title='lat comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='196' mars=''
+           short_title='mer comp grav wav stress'
+           long_title='mer comp grav wav stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2 s' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='197' mars=''
+           short_title='grav wav diss'
+           long_title='gravity wav dissipation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit='j/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='198' mars=''
+           short_title='skin res cont'
+           long_title='skin reservoir content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='199' mars=''
+           short_title='percent of veg'
+           long_title='percent of vegetation'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='200' mars=''
+           short_title='var subgrid-scale orog'
+           long_title='var subgrid-scale orog'
+           scaling='1.0' offset='-0.0'
+           original_unit='m**2' derived_unit='sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='201' mars=''
+           short_title='max 2m tem'
+           long_title='maximum temp at 2m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='202' mars=''
+           short_title='min 2m  tem'
+           long_title='minimum temp at 2 m'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='203' mars=''
+           short_title='oz mass mix rat'
+           long_title='ozone mass mixing ratio'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='204' mars=''
+           short_title='prec anal weights'
+           long_title='precip. analys weights'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='205' mars=''
+           short_title='runoff'
+           long_title='runoff'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='206' mars=''
+           short_title='tot col oz'
+           long_title='total column ozone'
+           scaling='46696.2409526033' offset='-0.0'
+           original_unit='kg m**-2' derived_unit='Dob'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='207' mars=''
+           short_title='10SI'
+           long_title='10 metre wind speed'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='208' mars=''
+           short_title='TSRC'
+           long_title='Top net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='209' mars=''
+           short_title='TTRC'
+           long_title='Top net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='210' mars=''
+           short_title='SSRC'
+           long_title='Surface net solar radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='211' mars=''
+           short_title='STRC'
+           long_title='Surface net thermal radiation, clear sky'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='212' mars=''
+           short_title='TISR'
+           long_title='TOA incident solar radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2 s' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='214' mars=''
+           short_title='DHR'
+           long_title='Diabatic heating by radiation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='215' mars=''
+           short_title='DHVD'
+           long_title='Diabatic heating by vertical diffusion'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='216' mars=''
+           short_title='DHCC'
+           long_title='Diabatic heating by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='217' mars=''
+           short_title='DHLC'
+           long_title='Diabatic heating by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='K' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='218' mars=''
+           short_title='VDZW'
+           long_title='Vertical diffusion of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='219' mars=''
+           short_title='VDMW'
+           long_title='Vertical diffusion of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='220' mars=''
+           short_title='EWGD'
+           long_title='East-West gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='221' mars=''
+           short_title='NSGD'
+           long_title='North-South gravity wave drag tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='222' mars=''
+           short_title='CTZW'
+           long_title='Convective tendency of zonal wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='223' mars=''
+           short_title='CTMW'
+           long_title='Convective tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='224' mars=''
+           short_title='VDH'
+           long_title='Vertical diffusion of humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='225' mars=''
+           short_title='HTCC'
+           long_title='Humidity tendency by cumulus convection'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='226' mars=''
+           short_title='HTLC'
+           long_title='Humidity tendency by large-scale condensation'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='227' mars=''
+           short_title='CRNH'
+           long_title='Change from removal of negative humidity'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='228' mars=''
+           short_title='tot prec'
+           long_title='total precipitation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='229' mars=''
+           short_title='instant e/w surf str'
+           long_title='instant e/w surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='230' mars=''
+           short_title='inst n/s surf str'
+           long_title='instant n/s surf stress'
+           scaling='1.0' offset='-0.0'
+           original_unit='N m**-2' derived_unit='n/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='231' mars=''
+           short_title='inst surf sens heat flux'
+           long_title='inst surf sens heat flux'
+           scaling='1.0' offset='-0.0'
+           original_unit='W m**-2' derived_unit='w/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='232' mars=''
+           short_title='inst evap'
+           long_title='instant evaporation'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg m**-2 s' derived_unit='g/sq m'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='233' mars=''
+           short_title='appar surf hum'
+           long_title='apparent surf humidity'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='g/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='234' mars=''
+           short_title='log surf rough for heat'
+           long_title='log surf rough for heat'
+           scaling='1.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='235' mars=''
+           short_title='skin temp'
+           long_title='skin temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='236' mars=''
+           short_title='soil temp lyr4'
+           long_title='soil temperature layer4'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='237' mars=''
+           short_title='soil wet lyr 4'
+           long_title='soil wetness layer 4'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='238' mars=''
+           short_title='snow temp'
+           long_title='snow temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg c'
+           vector1='0' vector2='0'
+           contour_interval='5.0' specification='p43'/>
+    <param code='239' mars=''
+           short_title='conv snow'
+           long_title='convective snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='240' mars=''
+           short_title='lge scal snow'
+           long_title='large scale snowfall'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m of water equivalent' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='241' mars=''
+           short_title='ACF'
+           long_title='Accumulated cloud fraction tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='242' mars=''
+           short_title='ALW'
+           long_title='Accumulated liquid water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='243' mars=''
+           short_title='fore albedo'
+           long_title='forecast albedo'
+           scaling='0.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='244' mars=''
+           short_title='fore surf rough'
+           long_title='forecast surface roughness'
+           scaling='1000.0' offset='-0.0'
+           original_unit='m' derived_unit='mm'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='245' mars=''
+           short_title='fore log surf rough/heat'
+           long_title='forecast log surface roughness for heat'
+           scaling='0.0' offset='-0.0'
+           original_unit='' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='246' mars=''
+           short_title='cloud liq wat con'
+           long_title='cloud liquid water content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='gm/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='247' mars=''
+           short_title='cloud ice wat con'
+           long_title='cloud ice water content'
+           scaling='1000.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit='gm/kg'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='248' mars=''
+           short_title='cloud cov'
+           long_title='cloud cover'
+           scaling='0.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='(0 - 1)'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='249' mars=''
+           short_title='AIW'
+           long_title='Accumulated ice water tendency'
+           scaling='1.0' offset='-0.0'
+           original_unit='(-1 to 1)' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+    <param code='250' mars=''
+           short_title='ice age'
+           long_title='ice age'
+           scaling='1.0' offset='-0.0'
+           original_unit='(0 - 1)' derived_unit='%'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='251' mars=''
+           short_title='unbal comp temp'
+           long_title='unbalanced component of temperature'
+           scaling='1.0' offset='-273.16'
+           original_unit='K' derived_unit='deg C'
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='252' mars=''
+           short_title='unbal comp LNSP'
+           long_title='unbalanced component of LNSP'
+           scaling='1.0' offset='-0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='253' mars=''
+           short_title='unbal comp div'
+           long_title='unbalanced component of divergence'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p43'/>
+    <param code='254' mars=''
+           short_title='ATMW'
+           long_title='Adiabatic tendency of meridional wind'
+           scaling='1.0' offset='-0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification=''/>
+     </table>
+</center>
diff --git a/share/magics/table_210.xml b/share/magics/table_210.xml
new file mode 100644
index 0000000..7c66d79
--- /dev/null
+++ b/share/magics/table_210.xml
@@ -0,0 +1,480 @@
+<center code='98'>
+    <table code='210'>
+    <param code='1' mars=''
+           short_title='aermr01'
+           long_title='Aerosol type 1 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='2' mars=''
+           short_title='aermr02'
+           long_title='Aerosol type 2 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='3' mars=''
+           short_title='aermr03'
+           long_title='Aerosol type 3 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='4' mars=''
+           short_title='aermr04'
+           long_title='Aerosol type 4 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='5' mars=''
+           short_title='aermr05'
+           long_title='Aerosol type 5 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='6' mars=''
+           short_title='aermr06'
+           long_title='Aerosol type 6 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='7' mars=''
+           short_title='aermr07'
+           long_title='Aerosol type 7 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='8' mars=''
+           short_title='aermr08'
+           long_title='Aerosol type 8 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='9' mars=''
+           short_title='aermr09'
+           long_title='Aerosol type 9 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='10' mars=''
+           short_title='aermr10'
+           long_title='Aerosol type 10 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='11' mars=''
+           short_title='aermr11'
+           long_title='Aerosol type 11 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='12' mars=''
+           short_title='aermr12'
+           long_title='Aerosol type 12 mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='16' mars=''
+           short_title='aergn01'
+           long_title='Aerosol type 1 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='17' mars=''
+           short_title='aergn02'
+           long_title='Aerosol type 2 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='18' mars=''
+           short_title='aergn03'
+           long_title='Aerosol type 3 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='19' mars=''
+           short_title='aergn04'
+           long_title='Aerosol type 4 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='20' mars=''
+           short_title='aergn05'
+           long_title='Aerosol type 5 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='21' mars=''
+           short_title='aergn06'
+           long_title='Aerosol type 6 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='22' mars=''
+           short_title='aergn07'
+           long_title='Aerosol type 7 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='23' mars=''
+           short_title='aergn08'
+           long_title='Aerosol type 8 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='24' mars=''
+           short_title='aergn09'
+           long_title='Aerosol type 9 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='25' mars=''
+           short_title='aergn10'
+           long_title='Aerosol type 10 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='26' mars=''
+           short_title='aergn11'
+           long_title='Aerosol type 11 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='27' mars=''
+           short_title='aergn12'
+           long_title='Aerosol type 12 source/gain accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='31' mars=''
+           short_title='aerls01'
+           long_title='Aerosol type 1 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='32' mars=''
+           short_title='aerls02'
+           long_title='Aerosol type 2 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='33' mars=''
+           short_title='aerls03'
+           long_title='Aerosol type 3 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='34' mars=''
+           short_title='aerls04'
+           long_title='Aerosol type 4 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='35' mars=''
+           short_title='aerls05'
+           long_title='Aerosol type 5 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='36' mars=''
+           short_title='aerls06'
+           long_title='Aerosol type 6 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='37' mars=''
+           short_title='aerls07'
+           long_title='Aerosol type 7 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='38' mars=''
+           short_title='aerls08'
+           long_title='Aerosol type 8 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='39' mars=''
+           short_title='aerls09'
+           long_title='Aerosol type 9 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='40' mars=''
+           short_title='aerls10'
+           long_title='Aerosol type 10 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='41' mars=''
+           short_title='aerls11'
+           long_title='Aerosol type 11 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='42' mars=''
+           short_title='aerls12'
+           long_title='Aerosol type 12 sink/loss accumulated'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='46' mars=''
+           short_title='aerpr'
+           long_title='Aerosol precursor mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='47' mars=''
+           short_title='aersm'
+           long_title='Aerosol small mode mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='48' mars=''
+           short_title='aerlg'
+           long_title='Aerosol large mode mixing ratio'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='49' mars=''
+           short_title='aodpr'
+           long_title='Aerosol precursor optical depth'
+           scaling='1.0' offset='0.0'
+           original_unit='dimensionless' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='50' mars=''
+           short_title='aodsm'
+           long_title='Aerosol small mode optical depth'
+           scaling='1.0' offset='0.0'
+           original_unit='dimensionless' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='51' mars=''
+           short_title='aodlg'
+           long_title='Aerosol large mode optical depth'
+           scaling='1.0' offset='0.0'
+           original_unit='dimensionless' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='52' mars=''
+           short_title='aerdep'
+           long_title='Dust emission potential'
+           scaling='1.0' offset='0.0'
+           original_unit='kg s**2 m**-5' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='53' mars=''
+           short_title='aerlts'
+           long_title='Lifting threshold speed'
+           scaling='1.0' offset='0.0'
+           original_unit='m s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='54' mars=''
+           short_title='aerscc'
+           long_title='Soil clay content'
+           scaling='1.0' offset='0.0'
+           original_unit='%' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='61' mars=''
+           short_title='co2'
+           long_title='Carbon Dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='62' mars=''
+           short_title='ch4'
+           long_title='Methane'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='63' mars=''
+           short_title='n2o'
+           long_title='Nitrous oxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='64' mars=''
+           short_title='tcco2'
+           long_title='Total column Carbon Dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='65' mars=''
+           short_title='tcch4'
+           long_title='Total column Methane'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='66' mars=''
+           short_title='tcn2o'
+           long_title='Total column Nitrous oxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='67' mars=''
+           short_title='co2of'
+           long_title='Ocean flux of Carbon Dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='68' mars=''
+           short_title='co2nbf'
+           long_title='Natural biosphere flux of Carbon Dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='69' mars=''
+           short_title='co2apf'
+           long_title='Anthoprogenic emissions of Carbon Dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2 s**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='121' mars=''
+           short_title='no2'
+           long_title='Nitrogen dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='122' mars=''
+           short_title='so2'
+           long_title='Sulphur dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='123' mars=''
+           short_title='co'
+           long_title='Carbon monoxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='124' mars=''
+           short_title='hcho'
+           long_title='Formaldehyde'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='125' mars=''
+           short_title='tcno2'
+           long_title='Total column Nitrogen dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='126' mars=''
+           short_title='tcso2'
+           long_title='Total column Sulphur dioxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='127' mars=''
+           short_title='tcco'
+           long_title='Total column Carbon monoxide'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='128' mars=''
+           short_title='tchcho'
+           long_title='Total column Formaldehyde'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='181' mars=''
+           short_title='ra'
+           long_title='Radon'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='182' mars=''
+           short_title='sf6'
+           long_title='Sulphur Hexafluoride'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='183' mars=''
+           short_title='tcra'
+           long_title='Total column Radon'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='184' mars=''
+           short_title='tcsf6'
+           long_title='Total column Sulphur Hexafluoride'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='203' mars=''
+           short_title='go3'
+           long_title='GEMS Ozone'
+           scaling='1.0' offset='0.0'
+           original_unit='kg kg**-1' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+    <param code='206' mars=''
+           short_title='gtco3'
+           long_title='GEMS Total column ozone'
+           scaling='1.0' offset='0.0'
+           original_unit='kg m**-2' derived_unit=''
+           vector1='0' vector2='0'
+           contour_interval='0.0' specification='p0'/>
+     </table>
+</center>
diff --git a/share/magics/table_254.xml b/share/magics/table_254.xml
new file mode 100644
index 0000000..84fadd2
--- /dev/null
+++ b/share/magics/table_254.xml
@@ -0,0 +1,604 @@
+<center code='46'>
+  <table code='254'>
+   <param code='128' mars=''
+      short_title='TP2M'
+      long_title='2 metre temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='129' mars=''
+      short_title='DP2M'
+      long_title='2 metre dewpoint temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='130' mars=''
+      short_title='U10M'
+      long_title='10 metre u-wind component'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='131' mars=''
+      short_title='V10M'
+      long_title='10 metre v-wind component'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='132' mars=''
+      short_title='TOPO'
+      long_title='Topography'
+      scaling='1.0' offset='0.0'
+      original_unit='m' derived_unit='m'/>
+   <param code='133' mars=''
+      short_title='GSFP'
+      long_title='Geometric mean surface pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='134' mars=''
+      short_title='LNSP'
+      long_title='Ln surface pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='135' mars=''
+      short_title='PSLC'
+      long_title='Surface pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='136' mars=''
+      short_title='PMSL'
+      long_title='M S L pressure (mesinger method)'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='137' mars=''
+      short_title='MASK'
+      long_title='Mask'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='Nodim'/>
+   <param code='138' mars=''
+      short_title='MXWU'
+      long_title='Maximum u-wind'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='139' mars=''
+      short_title='MXWV'
+      long_title='Maximum v-wind'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='140' mars=''
+      short_title='CAPE'
+      long_title='Convective avail. Pot.energy'
+      scaling='1.0' offset='0.0'
+      original_unit='J/Kg' derived_unit='J/Kg'/>
+   <param code='141' mars=''
+      short_title='CINE'
+      long_title='Convective inhib. Energy'
+      scaling='1.0' offset='0.0'
+      original_unit='J/Kg' derived_unit='J/Kg'/>
+   <param code='142' mars=''
+      short_title='LHCV'
+      long_title='Convective latent heating'
+      scaling='1.0' offset='0.0'
+      original_unit='K/s' derived_unit='K/s'/>
+   <param code='143' mars=''
+      short_title='MSCV'
+      long_title='Convective moisture source'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='144' mars=''
+      short_title='SCVM'
+      long_title='Shallow conv. Moisture source'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='145' mars=''
+      short_title='SCVH'
+      long_title='Shallow convective heating'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='146' mars=''
+      short_title='MXWP'
+      long_title='Maximum wind press. Lvl'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='147' mars=''
+      short_title='USTR'
+      long_title='Storm motion u-component'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='148' mars=''
+      short_title='VSTR'
+      long_title='Storm motion v-component'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='149' mars=''
+      short_title='CBNT'
+      long_title='Mean cloud cover'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='150' mars=''
+      short_title='PCBS'
+      long_title='Pressure at cloud base'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='151' mars=''
+      short_title='PCTB'
+      long_title='Pressure at cloud top'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='152' mars=''
+      short_title='FZHT'
+      long_title='Freezing level height'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='153' mars=''
+      short_title='FZRH'
+      long_title='Freezing level relative humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='154' mars=''
+      short_title='FDLT'
+      long_title='Flight levels temperature'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='155' mars=''
+      short_title='FDLU'
+      long_title='Flight levels u-wind'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='156' mars=''
+      short_title='FDLV'
+      long_title='Flight levels v-wind'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='157' mars=''
+      short_title='TPPP'
+      long_title='Tropopause pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='158' mars=''
+      short_title='TPPT'
+      long_title='Tropopause temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='159' mars=''
+      short_title='TPPU'
+      long_title='Tropopause u-wind component'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='160' mars=''
+      short_title='TPPV'
+      long_title='Tropopause v-wind component'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='162' mars=''
+      short_title='GVDU'
+      long_title='Gravity wave drag du/dt'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='163' mars=''
+      short_title='GVDS'
+      long_title='Gravity wave drag dv/dt'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='164' mars=''
+      short_title='GVUS'
+      long_title='Grav wave drag sfc zonal stress'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='165' mars=''
+      short_title='GVVS'
+      long_title='Grav wave drag sfc merid stress'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='167' mars=''
+      short_title='DVSH'
+      long_title='Divergence of specific humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='168' mars=''
+      short_title='HMFC'
+      long_title='Horiz. Moisture flux conv.'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='169' mars=''
+      short_title='VMFL'
+      long_title='Vert. Integ moisture flux conv.'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='170' mars=''
+      short_title='VADV'
+      long_title='Vertical moisture advection'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='171' mars=''
+      short_title='NHCM'
+      long_title='Neg. Hum. Corr. Moisture source'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='172' mars=''
+      short_title='LGLH'
+      long_title='Large scale latent heating'
+      scaling='1.0' offset='0.0'
+      original_unit='K/s' derived_unit='K/s'/>
+   <param code='173' mars=''
+      short_title='LGMS'
+      long_title='Large scale moisture source'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='174' mars=''
+      short_title='SMAV'
+      long_title='Soil moisture availability'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='NoDim'/>
+   <param code='175' mars=''
+      short_title='TGRZ'
+      long_title='Soil temperature of root zone'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='176' mars=''
+      short_title='BSLH'
+      long_title='Bare soil latent heat'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='177' mars=''
+      short_title='EVPP'
+      long_title='Potential sfc evaporation'
+      scaling='1.0' offset='0.0'
+      original_unit='m' derived_unit='m'/>
+   <param code='178' mars=''
+      short_title='RNOF'
+      long_title='Runoff'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='NoDim'/>
+   <param code='179' mars=''
+      short_title='PITP'
+      long_title='Interception loss'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='180' mars=''
+      short_title='VPCA'
+      long_title='Vapor press of canopy air space'
+      scaling='1.0' offset='0.0'
+      original_unit='mb' derived_unit='mb'/>
+   <param code='181' mars=''
+      short_title='QSFC'
+      long_title='Surface spec humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='%' derived_unit='%'/>
+   <param code='182' mars=''
+      short_title='USSL'
+      long_title='Soil wetness of surface'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='NoDim'/>
+   <param code='183' mars=''
+      short_title='UZRS'
+      long_title='Soil wetness of root zone'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='NoDim'/>
+   <param code='184' mars=''
+      short_title='UZDS'
+      long_title='Soil wetness of drainage zone'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='NoDim'/>
+   <param code='185' mars=''
+      short_title='AMDL'
+      long_title='Storage on canopy'
+      scaling='1.0' offset='0.0'
+      original_unit='m' derived_unit='m'/>
+   <param code='186' mars=''
+      short_title='AMSL'
+      long_title='Storage on ground'
+      scaling='1.0' offset='0.0'
+      original_unit='m' derived_unit='m'/>
+   <param code='187' mars=''
+      short_title='TSFC'
+      long_title='Surface temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='188' mars=''
+      short_title='TEMS'
+      long_title='Surface absolute temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='189' mars=''
+      short_title='TCAS'
+      long_title='Temperature of canopy air space'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='190' mars=''
+      short_title='CTMP'
+      long_title='Temperature at canopy'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='191' mars=''
+      short_title='TGSC'
+      long_title='Ground/surface cover temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='192' mars=''
+      short_title='UVES'
+      long_title='Surface zonal wind (u)'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='193' mars=''
+      short_title='USST'
+      long_title='Surface zonal wind stress'
+      scaling='1.0' offset='0.0'
+      original_unit='Pa' derived_unit='Pa'/>
+   <param code='194' mars=''
+      short_title='VVES'
+      long_title='Surface meridional wind (v)'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='195' mars=''
+      short_title='VSST'
+      long_title='Surface meridional wind stress'
+      scaling='1.0' offset='0.0'
+      original_unit='Pa' derived_unit='Pa'/>
+   <param code='196' mars=''
+      short_title='SUVF'
+      long_title='Surface momentum flux'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='197' mars=''
+      short_title='ISWF'
+      long_title='Incident short wave flux'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='198' mars=''
+      short_title='GHFL'
+      long_title='Time ave ground ht flx'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='200' mars=''
+      short_title='LWBC'
+      long_title='Net long wave at bottom (clear)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='201' mars=''
+      short_title='LWTC'
+      long_title='Outgoing long wave at top (clear)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='202' mars=''
+      short_title='SWEC'
+      long_title='Short wv absrbd by earth/atm (cl)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='203' mars=''
+      short_title='OCAC'
+      long_title='Short wave absrbd at ground (clr)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='205' mars=''
+      short_title='LWRH'
+      long_title='Long wave radiative heating'
+      scaling='1.0' offset='0.0'
+      original_unit='K/s' derived_unit='K/s'/>
+   <param code='206' mars=''
+      short_title='SWRH'
+      long_title='Short wave radiative heating'
+      scaling='1.0' offset='0.0'
+      original_unit='K/s' derived_unit='K/s'/>
+   <param code='207' mars=''
+      short_title='OLIS'
+      long_title='Downward long wave at bottom'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='208' mars=''
+      short_title='OLIC'
+      long_title='Downward long wave at bottom (cl)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='209' mars=''
+      short_title='OCIS'
+      long_title='Downward short wave at ground'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='210' mars=''
+      short_title='OCIC'
+      long_title='Downward short wave at grd (cl)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='211' mars=''
+      short_title='OLES'
+      long_title='Upward long wave at bottom'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='212' mars=''
+      short_title='OCES'
+      long_title='Upward short wave at ground'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='213' mars=''
+      short_title='SWGC'
+      long_title='Upward short wave at ground (cl)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='214' mars=''
+      short_title='ROCE'
+      long_title='Upward short wave at top'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='215' mars=''
+      short_title='SWTC'
+      long_title='Upward short wave at top (clear)'
+      scaling='1.0' offset='0.0'
+      original_unit='W/m2' derived_unit='W/m2'/>
+   <param code='218' mars=''
+      short_title='HHDF'
+      long_title='Horizontal heating diffusion'
+      scaling='1.0' offset='0.0'
+      original_unit='K/s' derived_unit='K/s'/>
+   <param code='219' mars=''
+      short_title='HMDF'
+      long_title='Horizontal moisture diffusion'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='220' mars=''
+      short_title='HDDF'
+      long_title='Horizontal divergence diffusion'
+      scaling='1.0' offset='0.0'
+      original_unit='s2' derived_unit='s2'/>
+   <param code='221' mars=''
+      short_title='HVDF'
+      long_title='Horizontal vorticity diffusion'
+      scaling='1.0' offset='0.0'
+      original_unit='s2' derived_unit='s2'/>
+   <param code='222' mars=''
+      short_title='VDMS'
+      long_title='Vertical diff. Moisture source'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='223' mars=''
+      short_title='VDFU'
+      long_title='Vertical diffusion du/dt'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='224' mars=''
+      short_title='VDFV'
+      long_title='Vertical diffusion dv/dt'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='225' mars=''
+      short_title='VDFH'
+      long_title='Vertical diffusion heating'
+      scaling='1.0' offset='0.0'
+      original_unit='K/s' derived_unit='K/s'/>
+   <param code='226' mars=''
+      short_title='UMRS'
+      long_title='Surface relative humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='%' derived_unit='%'/>
+   <param code='227' mars=''
+      short_title='VDCC'
+      long_title='Vertical dist total cloud cover'
+      scaling='1.0' offset='0.0'
+      original_unit='%' derived_unit='%'/>
+   <param code='230' mars=''
+      short_title='USMT'
+      long_title='Time mean surface zonal wind (u)'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='231' mars=''
+      short_title='VSMT'
+      long_title='Time mean surface merid wind (v)'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='232' mars=''
+      short_title='TSMT'
+      long_title='Time mean surface absolute temp'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='233' mars=''
+      short_title='RSMT'
+      long_title='Time mean sfc relative humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='%' derived_unit='%'/>
+   <param code='234' mars=''
+      short_title='ATMT'
+      long_title='Time mean absolute temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='235' mars=''
+      short_title='STMT'
+      long_title='Time mean deep soil temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='236' mars=''
+      short_title='OMMT'
+      long_title='Time mean derived omega'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa/s' derived_unit='hPa/s'/>
+   <param code='237' mars=''
+      short_title='DVMT'
+      long_title='Time mean divergence'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='238' mars=''
+      short_title='ZHMT'
+      long_title='Time mean geopotential height'
+      scaling='1.0' offset='0.0'
+      original_unit='m' derived_unit='m'/>
+   <param code='239' mars=''
+      short_title='LNMT'
+      long_title='Time mean log surface pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='ln/cb' derived_unit='ln/cb'/>
+   <param code='240' mars=''
+      short_title='MKMT'
+      long_title='Time mean mask'
+      scaling='1.0' offset='0.0'
+      original_unit='NoDim' derived_unit='NoDim'/>
+   <param code='241' mars=''
+      short_title='VVMT'
+      long_title='Time mean meridional wind (v)'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+   <param code='242' mars=''
+      short_title='OMTM'
+      long_title='Time mean omega'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa/s' derived_unit='hPa/s'/>
+   <param code='243' mars=''
+      short_title='PTMT'
+      long_title='Time mean potential temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='244' mars=''
+      short_title='PCMT'
+      long_title='Time mean precip. Water'
+      scaling='1.0' offset='0.0'
+      original_unit='mm' derived_unit='mm'/>
+   <param code='245' mars=''
+      short_title='RHMT'
+      long_title='Time mean relative humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='%' derived_unit='%'/>
+   <param code='246' mars=''
+      short_title='MPMT'
+      long_title='Time mean sea level pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='247' mars=''
+      short_title='SIMT'
+      long_title='Time mean sigmadot'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='248' mars=''
+      short_title='UEMT'
+      long_title='Time mean specific humidity'
+      scaling='1.0' offset='0.0'
+      original_unit='Kg/Kg' derived_unit='Kg/Kg'/>
+   <param code='249' mars=''
+      short_title='FCMT'
+      long_title='Time mean stream function'
+      scaling='1.0' offset='0.0'
+      original_unit='m2/s' derived_unit='m2/s'/>
+   <param code='250' mars=''
+      short_title='PSMT'
+      long_title='Time mean surface pressure'
+      scaling='1.0' offset='0.0'
+      original_unit='hPa' derived_unit='hPa'/>
+   <param code='251' mars=''
+      short_title='TMMT'
+      long_title='Time mean surface temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='252' mars=''
+      short_title='PVMT'
+      long_title='Time mean velocity potential'
+      scaling='1.0' offset='0.0'
+      original_unit='m2/s' derived_unit='m2/s'/>
+   <param code='253' mars=''
+      short_title='TVMT'
+      long_title='Time mean virtual temperature'
+      scaling='1.0' offset='273.16'
+      original_unit='K' derived_unit='C'/>
+   <param code='254' mars=''
+      short_title='VTMT'
+      long_title='Time mean vorticity'
+      scaling='1.0' offset='0.0'
+      original_unit='s' derived_unit='s'/>
+   <param code='255' mars=''
+      short_title='UVMT'
+      long_title='Time mean zonal wind (u)'
+      scaling='1.0' offset='0.0'
+      original_unit='m/s' derived_unit='m/s'/>
+  </table>
+</center>
diff --git a/share/magics/title_template.xml b/share/magics/title_template.xml
new file mode 100644
index 0000000..484b1df
--- /dev/null
+++ b/share/magics/title_template.xml
@@ -0,0 +1,50 @@
+
+ <!-- Default title  -->
+<title> <centre/> <gribapi key='typeOfGeneratingProcess'/> <base_date format = 'Base Time: %A %d %B %Y %H UTC'/> <parameter/>
+    <!-- OBSTAT -->
+    <title observationDiagnostic=''>Statistics for <gribapi key='codeType'/> from  <gribapi key='platform'/> / <gribapi key='instrument'/> 
+         <newline/><gribapi key='observationDiagnostic'/> [ <gribapi key='units'/> ] ( <gribapi key='dataSelection'/> ) 
+         <newline/>Exp = <gribapi key='experimentVersionNumber'/> Channel =   <gribapi key='scaledValueOfFirstFixedSurface'/> 
+         <newline/>Min: <gribapi key='min'/> Max: <gribapi key='max'/> Mean: <gribapi key='average'/>
+    </title>   	 
+    <title typeOfGeneratingProcess='1'>
+        <base_date format = '%A %d %B %Y %H UTC'/> <centre format = "%s Analysis"/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <title 	timeRangeIndicator='1'>
+        <base_date format = '%A %d %B %Y %H UTC'/> <centre format = "%s Analysis"/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <title typeOfGeneratingProcess='2'>
+        <base_date format = '%A %d %B %Y %H UTC'/> <centre  format = "%s Forecast"/> <step format="t+%s"/> 
+<valid_date format = 'VT:%A %d %B %Y %H UTC'/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <title timeRangeIndicator='0'>
+        <base_date format = '%A %d %B %Y %H UTC'/> <centre  format = "%s Forecast"/> <step format="t+%s"/> 
+<valid_date format = 'VT:%A %d %B %Y %H UTC'/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <title type='fc'>
+        <base_date format = '%A %d %B %Y %H UTC'/> <centre/> <product/> <step format="t+%s"/> 
+<valid_date format = 'VT:%A %d %B %Y %H UTC'/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <!-- EPS Control Forecast forecasts -->
+     <title type='cf'>
+        <base_date format = '%A %d %B %Y %H UTC'/> <centre/> <product/> <step format="t+%s"/> 
+<valid_date format = 'VT:%A %d %B %Y %H UTC'/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <!-- Normal analysis -->
+    <title type='an'>
+        <centre/> <product/> <base_date format = 'VT: %A %d %B %Y %H UTC'/> <level/> <parameter/> <units/> <expver/>  <plot_type/> 
+    </title>
+    <!-- Ensemble means, Standard devs, and perturbed forecast -->
+    <title type='em' stream='enfo'>
+        <base_date format = '%A %d %B %Y %H UTC '/> <centre/> <product/> <step format="t+%s"/> <valid_date format = 'VT:%A %d %B %Y %H UTC'/>
+<newline/><level/><parameter/><units/><expver/><eps_number_info/>
+     </title>
+     <title type='ep' stream='enfo'>
+        <base_date format = '%A %d %B %Y %H UTC '/> <centre/> <product/> <step format="t+%s"/> <valid_date format = 'VT:%A %d %B %Y %H UTC'/>
+<newline/><level/><parameter/><units/><expver/><eps_number_info/>
+     </title>
+     <title type='im'> <satellite/> <channel/> <date format = '%A %d %B %Y %H UTC '/> </title>
+</title>
+ 
+ 
+ 
diff --git a/share/magics/ttf/DejaVuSans-Bold.ttf b/share/magics/ttf/DejaVuSans-Bold.ttf
new file mode 100644
index 0000000..a5e40a9
Binary files /dev/null and b/share/magics/ttf/DejaVuSans-Bold.ttf differ
diff --git a/share/magics/ttf/DejaVuSans-BoldOblique.ttf b/share/magics/ttf/DejaVuSans-BoldOblique.ttf
new file mode 100644
index 0000000..393faf4
Binary files /dev/null and b/share/magics/ttf/DejaVuSans-BoldOblique.ttf differ
diff --git a/share/magics/ttf/DejaVuSans-Oblique.ttf b/share/magics/ttf/DejaVuSans-Oblique.ttf
new file mode 100644
index 0000000..8e86167
Binary files /dev/null and b/share/magics/ttf/DejaVuSans-Oblique.ttf differ
diff --git a/share/magics/ttf/DejaVuSans.ttf b/share/magics/ttf/DejaVuSans.ttf
new file mode 100644
index 0000000..25aeab3
Binary files /dev/null and b/share/magics/ttf/DejaVuSans.ttf differ
diff --git a/share/magics/ttf/DejaVuSerif-Bold.ttf b/share/magics/ttf/DejaVuSerif-Bold.ttf
new file mode 100644
index 0000000..88ebe9c
Binary files /dev/null and b/share/magics/ttf/DejaVuSerif-Bold.ttf differ
diff --git a/share/magics/ttf/DejaVuSerif-BoldOblique.ttf b/share/magics/ttf/DejaVuSerif-BoldOblique.ttf
new file mode 100644
index 0000000..6b1ba0c
Binary files /dev/null and b/share/magics/ttf/DejaVuSerif-BoldOblique.ttf differ
diff --git a/share/magics/ttf/DejaVuSerif-Oblique.ttf b/share/magics/ttf/DejaVuSerif-Oblique.ttf
new file mode 100644
index 0000000..667315b
Binary files /dev/null and b/share/magics/ttf/DejaVuSerif-Oblique.ttf differ
diff --git a/share/magics/ttf/DejaVuSerif.ttf b/share/magics/ttf/DejaVuSerif.ttf
new file mode 100644
index 0000000..507ec19
Binary files /dev/null and b/share/magics/ttf/DejaVuSerif.ttf differ
diff --git a/share/magics/ttf/LICENSE-dejavu-ttf-2.15 b/share/magics/ttf/LICENSE-dejavu-ttf-2.15
new file mode 100644
index 0000000..635e609
--- /dev/null
+++ b/share/magics/ttf/LICENSE-dejavu-ttf-2.15
@@ -0,0 +1,98 @@
+Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. Glyphs imported from Arev fonts are (c) Tavmjung Bah (see below)
+
+Bitstream Vera Fonts Copyright
+------------------------------
+
+Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
+a trademark of Bitstream, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of the fonts accompanying this license ("Fonts") and associated
+documentation files (the "Font Software"), to reproduce and distribute the
+Font Software, including without limitation the rights to use, copy, merge,
+publish, distribute, and/or sell copies of the Font Software, and to permit
+persons to whom the Font Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright and trademark notices and this permission notice shall
+be included in all copies of one or more of the Font Software typefaces.
+
+The Font Software may be modified, altered, or added to, and in particular
+the designs of glyphs or characters in the Fonts may be modified and
+additional glyphs or characters may be added to the Fonts, only if the fonts
+are renamed to names not containing either the words "Bitstream" or the word
+"Vera".
+
+This License becomes null and void to the extent applicable to Fonts or Font
+Software that has been modified and is distributed under the "Bitstream
+Vera" names.
+
+The Font Software may be sold as part of a larger software package but no
+copy of one or more of the Font Software typefaces may be sold by itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
+FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
+ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
+FONT SOFTWARE.
+
+Except as contained in this notice, the names of Gnome, the Gnome
+Foundation, and Bitstream Inc., shall not be used in advertising or
+otherwise to promote the sale, use or other dealings in this Font Software
+without prior written authorization from the Gnome Foundation or Bitstream
+Inc., respectively. For further information, contact: fonts at gnome dot
+org. 
+
+Arev Fonts Copyright
+------------------------------
+
+Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the fonts accompanying this license ("Fonts") and
+associated documentation files (the "Font Software"), to reproduce
+and distribute the modifications to the Bitstream Vera Font Software,
+including without limitation the rights to use, copy, merge, publish,
+distribute, and/or sell copies of the Font Software, and to permit
+persons to whom the Font Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright and trademark notices and this permission notice
+shall be included in all copies of one or more of the Font Software
+typefaces.
+
+The Font Software may be modified, altered, or added to, and in
+particular the designs of glyphs or characters in the Fonts may be
+modified and additional glyphs or characters may be added to the
+Fonts, only if the fonts are renamed to names not containing either
+the words "Tavmjong Bah" or the word "Arev".
+
+This License becomes null and void to the extent applicable to Fonts
+or Font Software that has been modified and is distributed under the 
+"Tavmjong Bah Arev" names.
+
+The Font Software may be sold as part of a larger software package but
+no copy of one or more of the Font Software typefaces may be sold by
+itself.
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
+TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
+
+Except as contained in this notice, the name of Tavmjong Bah shall not
+be used in advertising or otherwise to promote the sale, use or other
+dealings in this Font Software without prior written authorization
+from Tavmjong Bah. For further information, contact: tavmjong @ free
+. fr.
+
+$Id: LICENSE 778 2006-04-20 18:14:24Z moyogo $
diff --git a/share/magics/type.xml b/share/magics/type.xml
new file mode 100644
index 0000000..f24d6e8
--- /dev/null
+++ b/share/magics/type.xml
@@ -0,0 +1,16 @@
+<types>
+    <type code='2'
+        short_title='AN'
+        long_title='Analysis'/>
+     <type code='9'
+        short_title='FC'
+        long_title='Forecast'/>
+     <type code='10'
+        short_title='Eps Cont FC'
+        long_title='EPS Control Forecast'/>
+      <type code='17'
+        short_title='EPS Mean'
+        long_title='EPS Ensemble Mean Forecast'/>
+</types>   
+   
+   
diff --git a/src/MagicsDouble.cc b/src/MagicsDouble.cc
new file mode 100755
index 0000000..5723e3b
--- /dev/null
+++ b/src/MagicsDouble.cc
@@ -0,0 +1,140 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*
+
+   API for double precision versions of Magics++
+
+*/
+
+/*! \mainpage Magics++
+
+ \section intro What is Magics++?
+
+ Magics++ is the second generation of a meteorological graphics 
+ library developed at the <a href="http://www.ecmwf.int"><i>European 
+ Centre for Medium Range Forecasts (ECMWF)</i></a>. This library is 
+ developed in C++ and offers output in various formats such as PostScript, 
+ PDF, PNG, SVG, KML and Qt. 
+
+ \section install How-to install
+
+ Before installation you have to compile Magics++. To do so, simply 
+ unpack the tarball in an appropiate directory and run <i>./configure</i> 
+ followed by <i>make</i>. You can type <i>./configure --help</i> to get all
+ options of configuring Magics++. 
+ 
+ To install type <i>make install</i>. Depending on the 
+ choosen installation directory you need root permission.
+
+ For more information you should read the <a href="">installation guide</a>.
+
+ \section interfaces Magics++ interfaces
+
+ Magics++ offers different interfaces to access its graphics 
+ functionality: C++ (for higher-level applicatiosn such as Metview), C, Fortran 77
+ Python and MagML/MagJson. The Fortran interface is intended to be backwards compatible with older 
+ versions (mainly the the 6.x series) of Magics.
+
+ \section modules More information
+
+ - \ref interpolation "Interpolation and contouring"
+ 
+ - \ref hilo "Computations of High & Lows"
+ 
+ - \ref titles "Automatic titles"
+ 
+ - \ref projections "Geographical projections"
+ 
+ - \ref drivers "Output drivers"
+ 
+ - \ref coastlines "Coastlines"
+ 
+ - \ref colours "Colours"
+ 
+ - \ref obs "Plotting of observations"
+
+- \ref compatibility "Compatibility to MAGICS 6 for deprecated parameters" 
+ 
+ \section links Links
+ 
+ - <a href="http://www.ecmwf.int/publications/manuals/magics/index.html">Magics++ homepage</a>
+ 
+ - <a href="http://www.ecmwf.int/services/computing/training/material/com_mag.html">Training course</a>
+ 
+ - <a href="file:///scratch/graphics/cgi/mpptestsuite/html/test/fortran/timings.html">Magics++ test suite [ECMWF internal]</a>
+ 
+ 
+ \section copyright License
+ 
+  Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License"); 
+  you may not use this file except in compliance with the License. 
+  You may obtain a copy of the License at 
+
+	<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
+
+  Unless required by applicable law or agreed to in writing, software 
+  distributed under the License is distributed on an "AS IS" BASIS, 
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+  See the License for the specific language governing permissions and 
+  limitations under the License.
+
+*/
+
+
+#include <iostream>
+
+extern "C"
+{
+#include <magics_api.h>
+
+
+void psetr_(char* name, double* value, int length)
+{
+	std::string n(name, length);
+	mag_setr(n.c_str(), *value);
+}
+
+void pset1r_(char* name, double* data, int* dim, int length)
+{
+	std::string n(name, length);
+	mag_set1r(n.c_str(), data, *dim);
+}
+
+void pset2r_(char* name, double* data, int *dim, int *dim2, int length)
+{    
+	std::string n(name, length);
+	mag_set2r(n.c_str(), data, *dim, *dim2);
+}
+
+void pset3r_(char* name, double* data, int* dim, int *dim2, int* dim3, int length)
+{    
+	std::string n(name, length);
+	mag_set3r(n.c_str(), data, *dim, *dim2, *dim3);
+}
+
+void penqr_(char* name, double* value, int length)
+{
+	std::string n(name, length);
+	mag_enqr( n.c_str(), value);
+	
+}
+
+}
diff --git a/src/MagicsSingle.cc b/src/MagicsSingle.cc
new file mode 100644
index 0000000..db48c31
--- /dev/null
+++ b/src/MagicsSingle.cc
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*
+
+   API for single precision versions of Magics++
+   
+
+*/
+#include <iostream>
+
+extern "C"
+{
+#include <magics_api.h>
+
+
+void psetr_(char* name, float* value, int length)
+{
+	std::string n(name, length);
+	mag_setr(n.c_str(), *value);
+}
+
+void pset1r_(char* name, float* data, int* dim, int length)
+{
+	std::string n(name, length);
+	double* da = new double [*dim];
+	for(int i=0;i<*dim;i++) da[i] = (double)data[i];
+
+	mag_set1r(n.c_str(), da, *dim);
+	delete [] da;
+}
+
+void pset2r_(char* name, float* data, int *dim, int *dim2, int length)
+{    
+	std::string n(name, length);
+	const long no = (*dim)*(*dim2); 
+	double* da = new double [no];
+	for(int i=0;i<no;i++) da[i] = (double)data[i];
+
+	mag_set2r(n.c_str(), da, *dim, *dim2);
+	delete [] da;
+}
+
+void pset3r_(char* name, float* data, int* dim, int *dim2, int* dim3, int length)
+{    
+	std::string n(name, length);
+	const long no = (*dim)*(*dim2)*(*dim3);
+	double* da = new double [no];
+	for(int i=0;i<no;i++) da[i] = (double)data[i];
+
+	mag_set3r(n.c_str(), da, *dim, *dim2, *dim3);
+	delete [] da;
+}
+
+void penqr_(const char* name, float* value, int length)
+{	
+	std::string n(name, length);
+	double tmp;
+	
+	mag_enqr( n.c_str(), &tmp);
+	*value = float(tmp);
+}
+
+
+}
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..c90482f
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,228 @@
+AUTOMAKE_OPTIONS	= foreign
+
+
+
+if MAGICS_ODB
+MAG_ODB_DIR 		= oda
+oda_lib			= oda/liboda.la
+endif
+
+#if MAGICS_TERRALIB
+MAG_TERRALIB_DIR 	= terralib
+terralib_lib		= terralib/libterralib.la
+#endif
+
+if MAGICS_JSON
+JSON_DIR		= web
+JSON_lib		= web/libWeb.la
+endif
+
+if MAGICS_BUFR
+bufr_dir		= MvObs
+bufr_lib		= MvObs/libMvObs.la
+endif
+
+include_H		= magics_config.h magics_ecmwf_log.h magics.h VectorOfPointers.h
+
+if MAGICS_METVIEW
+mv_dir		= libMagWrapper
+endif 
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= 
+else
+include_HEADERS = 
+noinst_HEADERS	= $(include_H)
+endif
+
+SUBDIRS			= xml basic common drivers decoders visualisers libTable ${MAG_TERRALIB_DIR} ${bufr_dir} ${MAG_ODB_DIR} ${JSON_DIR} ${mv_dir} .
+AM_CPPFLAGS		= ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/terralib/kernel
+
+LIBRARY_CURRENT		= @LIBRARY_CURRENT@
+LIBRARY_REVISION	= @LIBRARY_REVISION@
+LIBRARY_AGE		= @LIBRARY_AGE@
+
+lib_LTLIBRARIES		= libMagPlus.la
+libMagPlus_la_SOURCES	= 
+libMagPlus_la_LDFLAGS	= -no-undefined -version-info $(MAGICS_LIBRARY_CURRENT):$(MAGICS_LIBRARY_REVISION):$(MAGICS_LIBRARY_AGE)
+libMagPlus_la_LIBADD	= basic/libbasic.la common/libcommon.la drivers/libdrivers.la decoders/libdecoders.la visualisers/libvisualisers.la libTable/libTable.la \
+			   ${terralib_lib} ${bufr_lib} ${JSON_lib} ${oda_lib}
+
+#if MAGICS_MAC
+#my_la_LINK      = $(CXXLINK)
+#endif
+#libMagPlus_la_LINK = ${my_la_LINK}
+
+lib_LIBRARIES			= libMagPlusSingle.a libMagPlusDouble.a
+libMagPlusSingle_a_SOURCES	= MagicsSingle.cc
+libMagPlusDouble_a_SOURCES	= MagicsDouble.cc
+
+sharedir		= $(datadir)/magics
+share_DATA		= $(top_srcdir)/share/magics/ecmwf_logo.png \
+			$(top_srcdir)/share/magics/kml_logo.png \
+			$(top_srcdir)/share/magics/magics_kml_icons.png \
+			$(top_srcdir)/share/magics/Fonts.dat \
+			$(top_srcdir)/share/magics/PostScriptFonts.dat \
+			$(top_srcdir)/share/magics/PostScriptMacro1.ps \
+			$(top_srcdir)/share/magics/PostScriptMacro2.ps \
+			$(top_srcdir)/share/magics/symbols.svg \
+			$(top_srcdir)/share/magics/obs.xml \
+			$(top_srcdir)/share/magics/bufr_98.xml \
+			$(top_srcdir)/share/magics/centre.xml \
+			$(top_srcdir)/share/magics/level.xml \
+			$(top_srcdir)/share/magics/table_128.xml \
+			$(top_srcdir)/share/magics/table_129.xml \
+			$(top_srcdir)/share/magics/table_130.xml \
+			$(top_srcdir)/share/magics/table_131.xml \
+			$(top_srcdir)/share/magics/table_132.xml \
+			$(top_srcdir)/share/magics/table_140.xml \
+			$(top_srcdir)/share/magics/table_150.xml \
+			$(top_srcdir)/share/magics/table_151.xml \
+			$(top_srcdir)/share/magics/table_160.xml \
+			$(top_srcdir)/share/magics/table_162.xml \
+			$(top_srcdir)/share/magics/table_170.xml \
+			$(top_srcdir)/share/magics/table_171.xml \
+			$(top_srcdir)/share/magics/table_172.xml \
+			$(top_srcdir)/share/magics/table_173.xml \
+			$(top_srcdir)/share/magics/table_174.xml \
+			$(top_srcdir)/share/magics/table_175.xml \
+			$(top_srcdir)/share/magics/table_180.xml \
+			$(top_srcdir)/share/magics/table_190.xml \
+			$(top_srcdir)/share/magics/table_200.xml \
+			$(top_srcdir)/share/magics/table_210.xml \
+			$(top_srcdir)/share/magics/title_template.xml \
+			$(top_srcdir)/share/magics/epsg.json \
+			$(top_srcdir)/share/magics/type.xml \
+			$(top_srcdir)/share/magics/entities.dtd \
+			$(top_srcdir)/share/magics/ObstatGribVisDef.txt
+
+share10dir		= $(datadir)/magics/10m
+share10_DATA		= \
+			$(top_srcdir)/share/magics/10m/10m_admin_0_boundary_lines_land.dbf \
+			$(top_srcdir)/share/magics/10m/10m_admin_0_boundary_lines_land.shp \
+			$(top_srcdir)/share/magics/10m/10m_admin_0_boundary_lines_land.shx \
+			$(top_srcdir)/share/magics/10m/10m_admin_1_states_provinces_shp.dbf \
+			$(top_srcdir)/share/magics/10m/10m_admin_1_states_provinces_shp.shp \
+			$(top_srcdir)/share/magics/10m/10m_admin_1_states_provinces_shp.shx \
+			$(top_srcdir)/share/magics/10m/10m_lakes.dbf \
+			$(top_srcdir)/share/magics/10m/10m_lakes.shp \
+			$(top_srcdir)/share/magics/10m/10m_lakes.shx \
+			$(top_srcdir)/share/magics/10m/10m_land.dbf \
+			$(top_srcdir)/share/magics/10m/10m_land.shp \
+			$(top_srcdir)/share/magics/10m/10m_land.shx \
+			$(top_srcdir)/share/magics/10m/10m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/10m/10m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/10m/10m_rivers_lake_centerlines.shx \
+			$(top_srcdir)/share/magics/10m/10m_populated_places_simple.dbf \
+			$(top_srcdir)/share/magics/10m/10m_populated_places_simple.shp \
+			$(top_srcdir)/share/magics/10m/10m_populated_places_simple.shx
+
+share10fulldir		= $(datadir)/magics/10m_full
+share10full_DATA	= \
+			$(top_srcdir)/share/magics/10m_full/10m_lakes.dbf \
+			$(top_srcdir)/share/magics/10m_full/10m_lakes.shp \
+			$(top_srcdir)/share/magics/10m_full/10m_lakes.shx \
+			$(top_srcdir)/share/magics/10m_full/10m_land.dbf \
+			$(top_srcdir)/share/magics/10m_full/10m_land.shp \
+			$(top_srcdir)/share/magics/10m_full/10m_land.shx \
+			$(top_srcdir)/share/magics/10m_full/10m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/10m_full/10m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/10m_full/10m_rivers_lake_centerlines.shx
+
+share50dir		= $(datadir)/magics/50m
+share50_DATA		= \
+			$(top_srcdir)/share/magics/50m/50m_admin_0_boundary_lines_land.dbf \
+			$(top_srcdir)/share/magics/50m/50m_admin_0_boundary_lines_land.shp \
+			$(top_srcdir)/share/magics/50m/50m_admin_0_boundary_lines_land.shx \
+			$(top_srcdir)/share/magics/50m/50m_lakes.dbf \
+			$(top_srcdir)/share/magics/50m/50m_lakes.shp \
+			$(top_srcdir)/share/magics/50m/50m_lakes.shx \
+			$(top_srcdir)/share/magics/50m/50m_land.dbf \
+			$(top_srcdir)/share/magics/50m/50m_land.shp \
+			$(top_srcdir)/share/magics/50m/50m_land.shx \
+			$(top_srcdir)/share/magics/50m/50m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/50m/50m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/50m/50m_rivers_lake_centerlines.shx
+
+share110dir		= $(datadir)/magics/110m
+share110_DATA		= \
+			$(top_srcdir)/share/magics/110m/110m_admin_0_boundary_lines_land.dbf \
+			$(top_srcdir)/share/magics/110m/110m_admin_0_boundary_lines_land.shp  \
+			$(top_srcdir)/share/magics/110m/110m_admin_0_boundary_lines_land.shx \
+			$(top_srcdir)/share/magics/110m/110m_lakes.dbf \
+			$(top_srcdir)/share/magics/110m/110m_lakes.shp \
+			$(top_srcdir)/share/magics/110m/110m_lakes.shx \
+			$(top_srcdir)/share/magics/110m/110m_land.dbf \
+			$(top_srcdir)/share/magics/110m/110m_land.shp \
+			$(top_srcdir)/share/magics/110m/110m_land.shx \
+			$(top_srcdir)/share/magics/110m/110m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/110m/110m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/110m/110m_rivers_lake_centerlines.shx
+
+EXTRA_DIST	= 	boost
+
+if MAGICS_RASTER
+sharettfdir		= $(datadir)/magics/ttf
+sharettf_DATA		= $(top_srcdir)/share/magics/ttf/DejaVuSans-BoldOblique.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSans.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSerif-Oblique.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSans-Bold.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSerif-BoldOblique.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSerif.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSans-Oblique.ttf \
+			$(top_srcdir)/share/magics/ttf/DejaVuSerif-Bold.ttf \
+			$(top_srcdir)/share/magics/ttf/LICENSE-dejavu-ttf-2.15
+endif
+
+shareefidir		= $(datadir)/magics/efi
+shareefi_DATA		= $(top_srcdir)/share/magics/efi/Africa_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/efi_template.js
+
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = magics.pc
+
+quiet:
+	make --quiet install
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..22d1aae
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,1282 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/magics.pc.in $(srcdir)/magics_config.h.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = magics_config.h
+CONFIG_CLEAN_FILES = magics.pc
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libdir)" \
+	"$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(sharedir)" \
+	"$(DESTDIR)$(share10dir)" "$(DESTDIR)$(share10fulldir)" \
+	"$(DESTDIR)$(share110dir)" "$(DESTDIR)$(share50dir)" \
+	"$(DESTDIR)$(shareefidir)" "$(DESTDIR)$(sharettfdir)" \
+	"$(DESTDIR)$(includedir)"
+LIBRARIES = $(lib_LIBRARIES)
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_$(V))
+am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
+am__v_AR_0 = @echo "  AR    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+libMagPlusDouble_a_AR = $(AR) $(ARFLAGS)
+libMagPlusDouble_a_LIBADD =
+am_libMagPlusDouble_a_OBJECTS = MagicsDouble.$(OBJEXT)
+libMagPlusDouble_a_OBJECTS = $(am_libMagPlusDouble_a_OBJECTS)
+libMagPlusSingle_a_AR = $(AR) $(ARFLAGS)
+libMagPlusSingle_a_LIBADD =
+am_libMagPlusSingle_a_OBJECTS = MagicsSingle.$(OBJEXT)
+libMagPlusSingle_a_OBJECTS = $(am_libMagPlusSingle_a_OBJECTS)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libMagPlus_la_DEPENDENCIES = basic/libbasic.la common/libcommon.la \
+	drivers/libdrivers.la decoders/libdecoders.la \
+	visualisers/libvisualisers.la libTable/libTable.la \
+	$(terralib_lib) $(bufr_lib) $(JSON_lib) $(oda_lib)
+am_libMagPlus_la_OBJECTS =
+libMagPlus_la_OBJECTS = $(am_libMagPlus_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libMagPlus_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(libMagPlus_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libMagPlusDouble_a_SOURCES) $(libMagPlusSingle_a_SOURCES) \
+	$(libMagPlus_la_SOURCES)
+DIST_SOURCES = $(libMagPlusDouble_a_SOURCES) \
+	$(libMagPlusSingle_a_SOURCES) $(libMagPlus_la_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+DATA = $(pkgconfig_DATA) $(share_DATA) $(share10_DATA) \
+	$(share10full_DATA) $(share110_DATA) $(share50_DATA) \
+	$(shareefi_DATA) $(sharettf_DATA)
+am__include_HEADERS_DIST = magics_config.h magics_ecmwf_log.h magics.h \
+	VectorOfPointers.h
+am__noinst_HEADERS_DIST = magics_config.h magics_ecmwf_log.h magics.h \
+	VectorOfPointers.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = xml basic common drivers decoders visualisers libTable \
+	terralib MvObs oda web libMagWrapper .
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+ at MAGICS_ODB_TRUE@MAG_ODB_DIR = oda
+ at MAGICS_ODB_TRUE@oda_lib = oda/liboda.la
+
+#if MAGICS_TERRALIB
+MAG_TERRALIB_DIR = terralib
+terralib_lib = terralib/libterralib.la
+#endif
+ at MAGICS_JSON_TRUE@JSON_DIR = web
+ at MAGICS_JSON_TRUE@JSON_lib = web/libWeb.la
+ at MAGICS_BUFR_TRUE@bufr_dir = MvObs
+ at MAGICS_BUFR_TRUE@bufr_lib = MvObs/libMvObs.la
+include_H = magics_config.h magics_ecmwf_log.h magics.h VectorOfPointers.h
+ at MAGICS_METVIEW_TRUE@mv_dir = libMagWrapper
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = 
+SUBDIRS = xml basic common drivers decoders visualisers libTable ${MAG_TERRALIB_DIR} ${bufr_dir} ${MAG_ODB_DIR} ${JSON_DIR} ${mv_dir} .
+AM_CPPFLAGS = ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/terralib/kernel
+LIBRARY_CURRENT = @LIBRARY_CURRENT@
+LIBRARY_REVISION = @LIBRARY_REVISION@
+LIBRARY_AGE = @LIBRARY_AGE@
+lib_LTLIBRARIES = libMagPlus.la
+libMagPlus_la_SOURCES = 
+libMagPlus_la_LDFLAGS = -no-undefined -version-info $(MAGICS_LIBRARY_CURRENT):$(MAGICS_LIBRARY_REVISION):$(MAGICS_LIBRARY_AGE)
+libMagPlus_la_LIBADD = basic/libbasic.la common/libcommon.la drivers/libdrivers.la decoders/libdecoders.la visualisers/libvisualisers.la libTable/libTable.la \
+			   ${terralib_lib} ${bufr_lib} ${JSON_lib} ${oda_lib}
+
+
+#if MAGICS_MAC
+#my_la_LINK      = $(CXXLINK)
+#endif
+#libMagPlus_la_LINK = ${my_la_LINK}
+lib_LIBRARIES = libMagPlusSingle.a libMagPlusDouble.a
+libMagPlusSingle_a_SOURCES = MagicsSingle.cc
+libMagPlusDouble_a_SOURCES = MagicsDouble.cc
+sharedir = $(datadir)/magics
+share_DATA = $(top_srcdir)/share/magics/ecmwf_logo.png \
+			$(top_srcdir)/share/magics/kml_logo.png \
+			$(top_srcdir)/share/magics/magics_kml_icons.png \
+			$(top_srcdir)/share/magics/Fonts.dat \
+			$(top_srcdir)/share/magics/PostScriptFonts.dat \
+			$(top_srcdir)/share/magics/PostScriptMacro1.ps \
+			$(top_srcdir)/share/magics/PostScriptMacro2.ps \
+			$(top_srcdir)/share/magics/symbols.svg \
+			$(top_srcdir)/share/magics/obs.xml \
+			$(top_srcdir)/share/magics/bufr_98.xml \
+			$(top_srcdir)/share/magics/centre.xml \
+			$(top_srcdir)/share/magics/level.xml \
+			$(top_srcdir)/share/magics/table_128.xml \
+			$(top_srcdir)/share/magics/table_129.xml \
+			$(top_srcdir)/share/magics/table_130.xml \
+			$(top_srcdir)/share/magics/table_131.xml \
+			$(top_srcdir)/share/magics/table_132.xml \
+			$(top_srcdir)/share/magics/table_140.xml \
+			$(top_srcdir)/share/magics/table_150.xml \
+			$(top_srcdir)/share/magics/table_151.xml \
+			$(top_srcdir)/share/magics/table_160.xml \
+			$(top_srcdir)/share/magics/table_162.xml \
+			$(top_srcdir)/share/magics/table_170.xml \
+			$(top_srcdir)/share/magics/table_171.xml \
+			$(top_srcdir)/share/magics/table_172.xml \
+			$(top_srcdir)/share/magics/table_173.xml \
+			$(top_srcdir)/share/magics/table_174.xml \
+			$(top_srcdir)/share/magics/table_175.xml \
+			$(top_srcdir)/share/magics/table_180.xml \
+			$(top_srcdir)/share/magics/table_190.xml \
+			$(top_srcdir)/share/magics/table_200.xml \
+			$(top_srcdir)/share/magics/table_210.xml \
+			$(top_srcdir)/share/magics/title_template.xml \
+			$(top_srcdir)/share/magics/epsg.json \
+			$(top_srcdir)/share/magics/type.xml \
+			$(top_srcdir)/share/magics/entities.dtd \
+			$(top_srcdir)/share/magics/ObstatGribVisDef.txt
+
+share10dir = $(datadir)/magics/10m
+share10_DATA = \
+			$(top_srcdir)/share/magics/10m/10m_admin_0_boundary_lines_land.dbf \
+			$(top_srcdir)/share/magics/10m/10m_admin_0_boundary_lines_land.shp \
+			$(top_srcdir)/share/magics/10m/10m_admin_0_boundary_lines_land.shx \
+			$(top_srcdir)/share/magics/10m/10m_admin_1_states_provinces_shp.dbf \
+			$(top_srcdir)/share/magics/10m/10m_admin_1_states_provinces_shp.shp \
+			$(top_srcdir)/share/magics/10m/10m_admin_1_states_provinces_shp.shx \
+			$(top_srcdir)/share/magics/10m/10m_lakes.dbf \
+			$(top_srcdir)/share/magics/10m/10m_lakes.shp \
+			$(top_srcdir)/share/magics/10m/10m_lakes.shx \
+			$(top_srcdir)/share/magics/10m/10m_land.dbf \
+			$(top_srcdir)/share/magics/10m/10m_land.shp \
+			$(top_srcdir)/share/magics/10m/10m_land.shx \
+			$(top_srcdir)/share/magics/10m/10m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/10m/10m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/10m/10m_rivers_lake_centerlines.shx \
+			$(top_srcdir)/share/magics/10m/10m_populated_places_simple.dbf \
+			$(top_srcdir)/share/magics/10m/10m_populated_places_simple.shp \
+			$(top_srcdir)/share/magics/10m/10m_populated_places_simple.shx
+
+share10fulldir = $(datadir)/magics/10m_full
+share10full_DATA = \
+			$(top_srcdir)/share/magics/10m_full/10m_lakes.dbf \
+			$(top_srcdir)/share/magics/10m_full/10m_lakes.shp \
+			$(top_srcdir)/share/magics/10m_full/10m_lakes.shx \
+			$(top_srcdir)/share/magics/10m_full/10m_land.dbf \
+			$(top_srcdir)/share/magics/10m_full/10m_land.shp \
+			$(top_srcdir)/share/magics/10m_full/10m_land.shx \
+			$(top_srcdir)/share/magics/10m_full/10m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/10m_full/10m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/10m_full/10m_rivers_lake_centerlines.shx
+
+share50dir = $(datadir)/magics/50m
+share50_DATA = \
+			$(top_srcdir)/share/magics/50m/50m_admin_0_boundary_lines_land.dbf \
+			$(top_srcdir)/share/magics/50m/50m_admin_0_boundary_lines_land.shp \
+			$(top_srcdir)/share/magics/50m/50m_admin_0_boundary_lines_land.shx \
+			$(top_srcdir)/share/magics/50m/50m_lakes.dbf \
+			$(top_srcdir)/share/magics/50m/50m_lakes.shp \
+			$(top_srcdir)/share/magics/50m/50m_lakes.shx \
+			$(top_srcdir)/share/magics/50m/50m_land.dbf \
+			$(top_srcdir)/share/magics/50m/50m_land.shp \
+			$(top_srcdir)/share/magics/50m/50m_land.shx \
+			$(top_srcdir)/share/magics/50m/50m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/50m/50m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/50m/50m_rivers_lake_centerlines.shx
+
+share110dir = $(datadir)/magics/110m
+share110_DATA = \
+			$(top_srcdir)/share/magics/110m/110m_admin_0_boundary_lines_land.dbf \
+			$(top_srcdir)/share/magics/110m/110m_admin_0_boundary_lines_land.shp  \
+			$(top_srcdir)/share/magics/110m/110m_admin_0_boundary_lines_land.shx \
+			$(top_srcdir)/share/magics/110m/110m_lakes.dbf \
+			$(top_srcdir)/share/magics/110m/110m_lakes.shp \
+			$(top_srcdir)/share/magics/110m/110m_lakes.shx \
+			$(top_srcdir)/share/magics/110m/110m_land.dbf \
+			$(top_srcdir)/share/magics/110m/110m_land.shp \
+			$(top_srcdir)/share/magics/110m/110m_land.shx \
+			$(top_srcdir)/share/magics/110m/110m_rivers_lake_centerlines.dbf \
+			$(top_srcdir)/share/magics/110m/110m_rivers_lake_centerlines.shp \
+			$(top_srcdir)/share/magics/110m/110m_rivers_lake_centerlines.shx
+
+EXTRA_DIST = boost
+ at MAGICS_RASTER_TRUE@sharettfdir = $(datadir)/magics/ttf
+ at MAGICS_RASTER_TRUE@sharettf_DATA = $(top_srcdir)/share/magics/ttf/DejaVuSans-BoldOblique.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSans.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSerif-Oblique.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSans-Bold.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSerif-BoldOblique.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSerif.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSans-Oblique.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/DejaVuSerif-Bold.ttf \
+ at MAGICS_RASTER_TRUE@			$(top_srcdir)/share/magics/ttf/LICENSE-dejavu-ttf-2.15
+
+shareefidir = $(datadir)/magics/efi
+shareefi_DATA = $(top_srcdir)/share/magics/efi/Africa_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Africa_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Asia_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Australia_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Europe_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/Global_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/North32America_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_0.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_1.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_2.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_3.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_4.js\
+			$(top_srcdir)/share/magics/efi/South32America_All32parameters_5.js\
+			$(top_srcdir)/share/magics/efi/efi_template.js
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = magics.pc
+all: magics_config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+magics_config.h: stamp-h1
+	@if test ! -f $@; then \
+	  rm -f stamp-h1; \
+	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+	else :; fi
+
+stamp-h1: $(srcdir)/magics_config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status src/magics_config.h
+$(srcdir)/magics_config.h.in:  $(am__configure_deps) 
+	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+	rm -f stamp-h1
+	touch $@
+
+distclean-hdr:
+	-rm -f magics_config.h stamp-h1
+magics.pc: $(top_builddir)/config.status $(srcdir)/magics.pc.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-libLIBRARIES: $(lib_LIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(libdir)'"; \
+	  $(INSTALL_DATA) $$list2 "$(DESTDIR)$(libdir)" || exit $$?; }
+	@$(POST_INSTALL)
+	@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
+	for p in $$list; do \
+	  if test -f $$p; then \
+	    $(am__strip_dir) \
+	    echo " ( cd '$(DESTDIR)$(libdir)' && $(RANLIB) $$f )"; \
+	    ( cd "$(DESTDIR)$(libdir)" && $(RANLIB) $$f ) || exit $$?; \
+	  else :; fi; \
+	done
+
+uninstall-libLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(libdir)' && rm -f "$$files" )"; \
+	cd "$(DESTDIR)$(libdir)" && rm -f $$files
+
+clean-libLIBRARIES:
+	-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+libMagPlusDouble.a: $(libMagPlusDouble_a_OBJECTS) $(libMagPlusDouble_a_DEPENDENCIES) 
+	$(AM_V_at)-rm -f libMagPlusDouble.a
+	$(AM_V_AR)$(libMagPlusDouble_a_AR) libMagPlusDouble.a $(libMagPlusDouble_a_OBJECTS) $(libMagPlusDouble_a_LIBADD)
+	$(AM_V_at)$(RANLIB) libMagPlusDouble.a
+libMagPlusSingle.a: $(libMagPlusSingle_a_OBJECTS) $(libMagPlusSingle_a_DEPENDENCIES) 
+	$(AM_V_at)-rm -f libMagPlusSingle.a
+	$(AM_V_AR)$(libMagPlusSingle_a_AR) libMagPlusSingle.a $(libMagPlusSingle_a_OBJECTS) $(libMagPlusSingle_a_LIBADD)
+	$(AM_V_at)$(RANLIB) libMagPlusSingle.a
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+	}
+
+uninstall-libLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+	done
+
+clean-libLTLIBRARIES:
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libMagPlus.la: $(libMagPlus_la_OBJECTS) $(libMagPlus_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libMagPlus_la_LINK) -rpath $(libdir) $(libMagPlus_la_OBJECTS) $(libMagPlus_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagicsDouble.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagicsSingle.Po at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-pkgconfigDATA: $(pkgconfig_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
+	@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+	done
+
+uninstall-pkgconfigDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files
+install-shareDATA: $(share_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(sharedir)" || $(MKDIR_P) "$(DESTDIR)$(sharedir)"
+	@list='$(share_DATA)'; test -n "$(sharedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sharedir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(sharedir)" || exit $$?; \
+	done
+
+uninstall-shareDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(share_DATA)'; test -n "$(sharedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(sharedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(sharedir)" && rm -f $$files
+install-share10DATA: $(share10_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(share10dir)" || $(MKDIR_P) "$(DESTDIR)$(share10dir)"
+	@list='$(share10_DATA)'; test -n "$(share10dir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(share10dir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(share10dir)" || exit $$?; \
+	done
+
+uninstall-share10DATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(share10_DATA)'; test -n "$(share10dir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(share10dir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(share10dir)" && rm -f $$files
+install-share10fullDATA: $(share10full_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(share10fulldir)" || $(MKDIR_P) "$(DESTDIR)$(share10fulldir)"
+	@list='$(share10full_DATA)'; test -n "$(share10fulldir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(share10fulldir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(share10fulldir)" || exit $$?; \
+	done
+
+uninstall-share10fullDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(share10full_DATA)'; test -n "$(share10fulldir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(share10fulldir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(share10fulldir)" && rm -f $$files
+install-share110DATA: $(share110_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(share110dir)" || $(MKDIR_P) "$(DESTDIR)$(share110dir)"
+	@list='$(share110_DATA)'; test -n "$(share110dir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(share110dir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(share110dir)" || exit $$?; \
+	done
+
+uninstall-share110DATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(share110_DATA)'; test -n "$(share110dir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(share110dir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(share110dir)" && rm -f $$files
+install-share50DATA: $(share50_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(share50dir)" || $(MKDIR_P) "$(DESTDIR)$(share50dir)"
+	@list='$(share50_DATA)'; test -n "$(share50dir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(share50dir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(share50dir)" || exit $$?; \
+	done
+
+uninstall-share50DATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(share50_DATA)'; test -n "$(share50dir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(share50dir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(share50dir)" && rm -f $$files
+install-shareefiDATA: $(shareefi_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(shareefidir)" || $(MKDIR_P) "$(DESTDIR)$(shareefidir)"
+	@list='$(shareefi_DATA)'; test -n "$(shareefidir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(shareefidir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(shareefidir)" || exit $$?; \
+	done
+
+uninstall-shareefiDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(shareefi_DATA)'; test -n "$(shareefidir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(shareefidir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(shareefidir)" && rm -f $$files
+install-sharettfDATA: $(sharettf_DATA)
+	@$(NORMAL_INSTALL)
+	test -z "$(sharettfdir)" || $(MKDIR_P) "$(DESTDIR)$(sharettfdir)"
+	@list='$(sharettf_DATA)'; test -n "$(sharettfdir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sharettfdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(sharettfdir)" || exit $$?; \
+	done
+
+uninstall-sharettfDATA:
+	@$(NORMAL_UNINSTALL)
+	@list='$(sharettf_DATA)'; test -n "$(sharettfdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(sharettfdir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(sharettfdir)" && rm -f $$files
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) magics_config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS) magics_config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) magics_config.h.in $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS) magics_config.h.in $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) $(HEADERS) \
+		magics_config.h
+installdirs: installdirs-recursive
+installdirs-am:
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(sharedir)" "$(DESTDIR)$(share10dir)" "$(DESTDIR)$(share10fulldir)" "$(DESTDIR)$(share110dir)" "$(DESTDIR)$(share50dir)" "$(DESTDIR)$(shareefidir)" "$(DESTDIR)$(sharettfdir)" "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libLIBRARIES clean-libLTLIBRARIES \
+	clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-hdr distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-includeHEADERS install-pkgconfigDATA \
+	install-share10DATA install-share10fullDATA \
+	install-share110DATA install-share50DATA install-shareDATA \
+	install-shareefiDATA install-sharettfDATA
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-libLIBRARIES install-libLTLIBRARIES
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS uninstall-libLIBRARIES \
+	uninstall-libLTLIBRARIES uninstall-pkgconfigDATA \
+	uninstall-share10DATA uninstall-share10fullDATA \
+	uninstall-share110DATA uninstall-share50DATA \
+	uninstall-shareDATA uninstall-shareefiDATA \
+	uninstall-sharettfDATA
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+	ctags-recursive install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic \
+	clean-libLIBRARIES clean-libLTLIBRARIES clean-libtool ctags \
+	ctags-recursive distclean distclean-compile distclean-generic \
+	distclean-hdr distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-includeHEADERS install-info install-info-am \
+	install-libLIBRARIES install-libLTLIBRARIES install-man \
+	install-pdf install-pdf-am install-pkgconfigDATA install-ps \
+	install-ps-am install-share10DATA install-share10fullDATA \
+	install-share110DATA install-share50DATA install-shareDATA \
+	install-shareefiDATA install-sharettfDATA install-strip \
+	installcheck installcheck-am installdirs installdirs-am \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+	uninstall-includeHEADERS uninstall-libLIBRARIES \
+	uninstall-libLTLIBRARIES uninstall-pkgconfigDATA \
+	uninstall-share10DATA uninstall-share10fullDATA \
+	uninstall-share110DATA uninstall-share50DATA \
+	uninstall-shareDATA uninstall-shareefiDATA \
+	uninstall-sharettfDATA
+
+
+quiet:
+	make --quiet install
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/MvObs/Makefile.am b/src/MvObs/Makefile.am
new file mode 100755
index 0000000..b43232f
--- /dev/null
+++ b/src/MvObs/Makefile.am
@@ -0,0 +1,14 @@
+noinst_LTLIBRARIES	= libMvObs.la
+
+include_H	= fmettim.h fdyntime.h fobject.h fsortabl.h fstatime.h MvBufr.h MvLocation.h MvBufrObs.h MvObs.h MvPrepBufrPrep.h MvObsSet.h inc_iostream.h
+
+noinst_HEADERS	= $(include_H)
+# no need to install these headers as only Metview is using the C++ interface and it already has these files
+
+
+libMvObs_la_SOURCES	= fmettim.cc fdyntime.cc fobject.cc fsortabl.cc fstatime.cc MvLocation.cc MvObs.cc MvObsSet.cc MvPrepBufrPrep.cc
+
+libMvObs_la_CXXFLAGS	= -Dfortfloat=double -Dfortint=int -Dboolean=bool -DUSE_NEW_IO -DS4LINUX -DS4MDX -DS4NO_STRNICMP -DXK_MISCELLANY
+libMvObs_la_LDFLAGS	= -no-undefined -no-install
+AM_CPPFLAGS		= -I$(top_srcdir)/src/MvObs
+EXTRA_DIST		=
diff --git a/src/MvObs/Makefile.in b/src/MvObs/Makefile.in
new file mode 100644
index 0000000..70a35b6
--- /dev/null
+++ b/src/MvObs/Makefile.in
@@ -0,0 +1,664 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/MvObs
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libMvObs_la_LIBADD =
+am_libMvObs_la_OBJECTS = libMvObs_la-fmettim.lo \
+	libMvObs_la-fdyntime.lo libMvObs_la-fobject.lo \
+	libMvObs_la-fsortabl.lo libMvObs_la-fstatime.lo \
+	libMvObs_la-MvLocation.lo libMvObs_la-MvObs.lo \
+	libMvObs_la-MvObsSet.lo libMvObs_la-MvPrepBufrPrep.lo
+libMvObs_la_OBJECTS = $(am_libMvObs_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libMvObs_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libMvObs_la_CXXFLAGS) \
+	$(CXXFLAGS) $(libMvObs_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libMvObs_la_SOURCES)
+DIST_SOURCES = $(libMvObs_la_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libMvObs.la
+include_H = fmettim.h fdyntime.h fobject.h fsortabl.h fstatime.h MvBufr.h MvLocation.h MvBufrObs.h MvObs.h MvPrepBufrPrep.h MvObsSet.h inc_iostream.h
+noinst_HEADERS = $(include_H)
+# no need to install these headers as only Metview is using the C++ interface and it already has these files
+libMvObs_la_SOURCES = fmettim.cc fdyntime.cc fobject.cc fsortabl.cc fstatime.cc MvLocation.cc MvObs.cc MvObsSet.cc MvPrepBufrPrep.cc
+libMvObs_la_CXXFLAGS = -Dfortfloat=double -Dfortint=int -Dboolean=bool -DUSE_NEW_IO -DS4LINUX -DS4MDX -DS4NO_STRNICMP -DXK_MISCELLANY
+libMvObs_la_LDFLAGS = -no-undefined -no-install
+AM_CPPFLAGS = -I$(top_srcdir)/src/MvObs
+EXTRA_DIST = 
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/MvObs/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/MvObs/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libMvObs.la: $(libMvObs_la_OBJECTS) $(libMvObs_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libMvObs_la_LINK)  $(libMvObs_la_OBJECTS) $(libMvObs_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-MvLocation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-MvObs.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-MvObsSet.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-MvPrepBufrPrep.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-fdyntime.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-fmettim.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-fobject.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-fsortabl.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libMvObs_la-fstatime.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+libMvObs_la-fmettim.lo: fmettim.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-fmettim.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-fmettim.Tpo -c -o libMvObs_la-fmettim.lo `test -f 'fmettim.cc' || echo '$(srcdir)/'`fmettim.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-fmettim.Tpo $(DEPDIR)/libMvObs_la-fmettim.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='fmettim.cc' object='libMvObs_la-fmettim.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-fmettim.lo `test -f 'fmettim.cc' || echo '$(srcdir)/'`fmettim.cc
+
+libMvObs_la-fdyntime.lo: fdyntime.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-fdyntime.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-fdyntime.Tpo -c -o libMvObs_la-fdyntime.lo `test -f 'fdyntime.cc' || echo '$(srcdir)/'`fdyntime.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-fdyntime.Tpo $(DEPDIR)/libMvObs_la-fdyntime.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='fdyntime.cc' object='libMvObs_la-fdyntime.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-fdyntime.lo `test -f 'fdyntime.cc' || echo '$(srcdir)/'`fdyntime.cc
+
+libMvObs_la-fobject.lo: fobject.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-fobject.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-fobject.Tpo -c -o libMvObs_la-fobject.lo `test -f 'fobject.cc' || echo '$(srcdir)/'`fobject.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-fobject.Tpo $(DEPDIR)/libMvObs_la-fobject.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='fobject.cc' object='libMvObs_la-fobject.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-fobject.lo `test -f 'fobject.cc' || echo '$(srcdir)/'`fobject.cc
+
+libMvObs_la-fsortabl.lo: fsortabl.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-fsortabl.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-fsortabl.Tpo -c -o libMvObs_la-fsortabl.lo `test -f 'fsortabl.cc' || echo '$(srcdir)/'`fsortabl.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-fsortabl.Tpo $(DEPDIR)/libMvObs_la-fsortabl.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='fsortabl.cc' object='libMvObs_la-fsortabl.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-fsortabl.lo `test -f 'fsortabl.cc' || echo '$(srcdir)/'`fsortabl.cc
+
+libMvObs_la-fstatime.lo: fstatime.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-fstatime.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-fstatime.Tpo -c -o libMvObs_la-fstatime.lo `test -f 'fstatime.cc' || echo '$(srcdir)/'`fstatime.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-fstatime.Tpo $(DEPDIR)/libMvObs_la-fstatime.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='fstatime.cc' object='libMvObs_la-fstatime.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-fstatime.lo `test -f 'fstatime.cc' || echo '$(srcdir)/'`fstatime.cc
+
+libMvObs_la-MvLocation.lo: MvLocation.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-MvLocation.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-MvLocation.Tpo -c -o libMvObs_la-MvLocation.lo `test -f 'MvLocation.cc' || echo '$(srcdir)/'`MvLocation.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-MvLocation.Tpo $(DEPDIR)/libMvObs_la-MvLocation.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MvLocation.cc' object='libMvObs_la-MvLocation.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-MvLocation.lo `test -f 'MvLocation.cc' || echo '$(srcdir)/'`MvLocation.cc
+
+libMvObs_la-MvObs.lo: MvObs.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-MvObs.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-MvObs.Tpo -c -o libMvObs_la-MvObs.lo `test -f 'MvObs.cc' || echo '$(srcdir)/'`MvObs.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-MvObs.Tpo $(DEPDIR)/libMvObs_la-MvObs.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MvObs.cc' object='libMvObs_la-MvObs.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-MvObs.lo `test -f 'MvObs.cc' || echo '$(srcdir)/'`MvObs.cc
+
+libMvObs_la-MvObsSet.lo: MvObsSet.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-MvObsSet.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-MvObsSet.Tpo -c -o libMvObs_la-MvObsSet.lo `test -f 'MvObsSet.cc' || echo '$(srcdir)/'`MvObsSet.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-MvObsSet.Tpo $(DEPDIR)/libMvObs_la-MvObsSet.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MvObsSet.cc' object='libMvObs_la-MvObsSet.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-MvObsSet.lo `test -f 'MvObsSet.cc' || echo '$(srcdir)/'`MvObsSet.cc
+
+libMvObs_la-MvPrepBufrPrep.lo: MvPrepBufrPrep.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -MT libMvObs_la-MvPrepBufrPrep.lo -MD -MP -MF $(DEPDIR)/libMvObs_la-MvPrepBufrPrep.Tpo -c -o libMvObs_la-MvPrepBufrPrep.lo `test -f 'MvPrepBufrPrep.cc' || echo '$(srcdir)/'`MvPrepBufrPrep.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libMvObs_la-MvPrepBufrPrep.Tpo $(DEPDIR)/libMvObs_la-MvPrepBufrPrep.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MvPrepBufrPrep.cc' object='libMvObs_la-MvPrepBufrPrep.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libMvObs_la_CXXFLAGS) $(CXXFLAGS) -c -o libMvObs_la-MvPrepBufrPrep.lo `test -f 'MvPrepBufrPrep.cc' || echo '$(srcdir)/'`MvPrepBufrPrep.cc
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/MvObs/MvBufr.h b/src/MvObs/MvBufr.h
new file mode 100644
index 0000000..ad9c482
--- /dev/null
+++ b/src/MvObs/MvBufr.h
@@ -0,0 +1,444 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvBufr.h,   vk Sep94
+//        rev vk 010720
+
+#ifndef MvBufr_DEFINED_
+#define MvBufr_DEFINED_
+
+#include "fdyntime.h"
+#include <map>
+using namespace std;
+
+/*! \file */
+
+//--------------------------------------------------------
+// This constant should be removed into 'Site Dependent Values'...
+//--------------------------------------------------------
+const int BUFR_ORIGINATING_CENTER = 98;   // 98 == ECMWF
+
+
+//------------------------------------------------------//
+// missing value code to be used in C/C++ routines      //
+//------------------------------------------------------//
+const float     kBufrMissingValue = 1.7e38;
+const fortint   kBufrMissingIntValue = 2147483647;
+
+
+//------------------------------------------------------//
+// missing value code returned by FORTRAN routines      //
+//------------------------------------------------------//
+const fortfloat kFortranBufrMissingValue = 1.7e38;
+const fortint   kFortranBufrMissingIntValue = 2147483647;
+
+//--------------------------------------------------------
+// maximum sizes of arrays used in FORTRAN routines
+// NOTE: sizes for arrrays for BUBOX set in MvObs.cc!!!
+// NOTE2: IBM/AIX cannot handle bigger arrays in -q32 mode
+//--------------------------------------------------------
+#if defined(AIX) || defined(MV_USE_SMALL_ARRAYS)
+ const int MAX_KELEM=  40000;  //12000;
+ const int NUM_MAX_KVALS=3;
+ const int aMAX_KVALS[NUM_MAX_KVALS]={90000, 180000, 360000}; // previous max values: 80000
+ //                                      7MB    14MB   27MB
+//                                    (vals*80)/(1024*1024)MB
+ const int MAX_KVALS=aMAX_KVALS[NUM_MAX_KVALS-1]; // biggest entry in aMAX_KVALS
+#else
+ const int MAX_KELEM = 160000; // max allowed is 160,000 !!!  // 80000;  // 40000;   //12000;
+ const int NUM_MAX_KVALS=3;
+ const int aMAX_KVALS[NUM_MAX_KVALS]={600000, 1500000, 4096000};  //360000;   //80000;
+//                                      45MB    115MB   312MB
+//                                    (vals*80)/(1024*1024)MB
+ const int MAX_KVALS=aMAX_KVALS[NUM_MAX_KVALS-1]; // biggest entry in aMAX_KVALS
+#endif
+
+//! \enum EBufrInState Status of a BUFR message being read
+enum  EBufrInState
+{
+   kBufrIn_Error
+ , kBufrIn_Coded
+ , kBufrIn_Sections012Expanded
+ , kBufrIn_DataDecoded
+ , kBufrIn_DataAndDescriptorsDecoded
+};
+
+//! \enum EBufrOutState Status of a BUFR message being created
+enum  EBufrOutState
+{
+   kBufrOut_error
+  ,kBufrOut_noBuffers
+  ,kBufrOut_emptyBuffers
+  ,kBufrOut_formatedBuffers
+  ,kBufrOut_dataInBuffers
+};
+
+//! \enum EElementValueType Values for data element types
+enum EElementValueType
+{
+   kEVT_unknown
+  ,kEVT_missing
+  ,kEVT_numeric
+  ,kEVT_string
+};
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+                                             //  Sections of a BUFR message
+typedef struct
+{
+   unsigned char startStr;       // "B"
+   unsigned char startStr2;      // "U"
+   unsigned char startStr3;      // "F"
+   unsigned char startStr4;      // "R"
+   unsigned char totalLen;    // 24 bits
+   unsigned char totalLen2;
+   unsigned char totalLen3;
+   unsigned char editionNr;
+} TSection0;
+#endif
+
+#if 0
+typedef struct
+{
+   unsigned char len;        // 24;  // 1-3
+   unsigned char len2;       // 24;  // 2
+   unsigned char len3;       // 24;  // 3
+   unsigned char masterTable;//  8;  // 4
+   unsigned char origCentre; // 16;  // 5-6
+   unsigned char origCentre2;// 16;  // 6
+   unsigned char updateSeq;  //  8;  // 7
+
+   unsigned char bitField;   //  8;  // 8...
+   unsigned char msgType;    //  8;
+   unsigned char msgSubtype; //  8;
+   unsigned char masterTableVers; //8;
+
+   unsigned char localTableVers; //8;  // 12...
+   unsigned char yearYY;     //  8;
+   unsigned char month;      //  8;
+   unsigned char day;        //  8;
+
+   unsigned char hour;       //  8;  // 16...
+   unsigned char minute;     //  8;
+} TSection1;
+#endif
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// internal classes, should not be included in Doxygen docs
+
+const unsigned char cOctetMissingIndicator = 255;
+
+class Section1Base
+{
+ public:
+   Section1Base( const unsigned char* octs );
+   Section1Base( const Section1Base* aSec1 );
+   virtual ~Section1Base(){ delete [] octets_; }
+
+   int         len() const { return 65536*octets_[0] + 256*octets_[1] + octets_[2]; }
+   bool        isDifferent( const Section1Base* aSec1 ) const;
+   const unsigned char* start() const { return octets_; }
+
+   virtual bool     hasSection2() = 0;
+   virtual TDynamicTime date() = 0;
+   virtual int      msgType() = 0;
+   virtual int      msgSubtypeWMO() = 0;
+   virtual int      msgSubtypeLocal() = 0;
+   virtual int      msgSubtype() = 0;
+   virtual int      origCentre() = 0;
+   virtual int      origSubCentre() = 0;
+   virtual int      masterTable() = 0;
+   virtual int      masterTableVersion() = 0;
+   virtual int 	    localTableVersion() = 0;
+
+ protected:
+   unsigned char* octets_;
+};
+
+class Section1_preEd4 : public Section1Base
+{
+ public:
+   Section1_preEd4( const unsigned char* octs ) : Section1Base( octs ){};
+   Section1_preEd4( const Section1Base* aSec1 ) : Section1Base( aSec1 ){};
+
+   bool     hasSection2();
+   TDynamicTime date();
+   int      msgType();
+   int      msgSubtypeWMO();
+   int      msgSubtypeLocal();
+   int      msgSubtype();
+   int      origCentre();
+   int      origSubCentre();
+   int      masterTable();
+   int      masterTableVersion();
+   int 	    localTableVersion();
+};
+
+class Section1_Ed4 : public Section1Base
+{
+ public:
+   Section1_Ed4( const unsigned char* octs ) : Section1Base( octs ){};
+   Section1_Ed4( const Section1Base* aSec1 ) : Section1Base( aSec1 ){};
+
+   bool     hasSection2();
+   TDynamicTime date();
+   int      msgType();
+   int      msgSubtypeWMO();
+   int      msgSubtypeLocal();
+   int      msgSubtype();
+   int      origCentre();
+   int      origSubCentre();
+   int      masterTable();
+   int      masterTableVersion();
+   int 	    localTableVersion();
+};
+
+typedef struct
+{
+   unsigned char len;      // : 24;
+   unsigned char len2;
+   unsigned char len3;
+   unsigned char reserved; // :  8;
+} TSection2;
+
+typedef struct
+{
+   unsigned char len;      // : 24;
+   unsigned char len2;
+   unsigned char len3;
+   unsigned char reserved;   //  8;
+   unsigned char subsetCnt;  // 16;
+   unsigned char subsetCnt2;
+   unsigned char bitField;   //  8;
+} TSection3;
+
+typedef struct
+{
+   unsigned char len;      // : 24;
+   unsigned char len2;
+   unsigned char len3;
+   unsigned char reserved; // :  8;
+} TSection4;
+// DOXYGEN_SHOULD_SKIP_THIS
+#endif
+
+//--------------------------------------------------------------- MvBufrBase
+
+class MvObsSet;
+
+//! Wrapper around Fortran 'bufren', base class for MvBufr and MvBufrOut
+/*! This class and its methods are a lower level wrapper around Fortran
+ *  subroutine 'bufren'. This class should be hidden from Metview applications
+ *  and the methods of this class should be called only from MvObs.
+ */
+class MvBufrBase
+{
+ friend class MvBufrOut;  //???
+ //friend class MvObsSet;
+
+ protected:
+	 int  _refCount;
+	long  fMessageNumber;
+
+        long *longptr;
+	char *fMessage;
+	long  fMessageLength;
+   TSection0 *fSec0;
+   Section1Base* Sec1;
+   TSection2 *fSec2;
+   unsigned char *fTotalSec2;
+   TSection3 *fSec3;
+   TSection4 *fSec4;
+
+     fortint  fKERR;
+     fortint *fKSUP;   // [ 9 ];
+     fortint *fKSEC0;  // [ 3 ];
+     fortint *fKSEC1;  // [ 40 ];
+     fortint *fKSEC2;  // [ 64 ];
+     fortint *fKSEC3;  // [ 4 ];
+     fortint *fKSEC4;  // [ 2 ];
+
+ protected:
+	    MvBufrBase( const long len );  //( char *msg, long len );
+	    virtual ~MvBufrBase( void );
+
+      void  attach( void );   // { _refCount++; }
+      void  detach( void );   // { if( --_refCount == 0 ) delete this; }
+      void  createFortranArrays( void );
+    void  createDataArrays( void );
+    void  deleteDataArrays( void );
+      unsigned int unsignedInt( const unsigned char* firstOctet
+                              , int octetCount );
+      int subsetCount(){ return unsignedInt( &(fSec3->subsetCnt), 2); }
+      int totalLen() { return unsignedInt( &(fSec0->totalLen), 3); }
+};
+
+//--------------------------------------------------------------- MvBufr
+
+//! C++ wrapper around Fortran 'bufren', used by MvObs
+/*! This class and its methods are a lower level wrapper around Fortran
+ *   subroutine 'bufren'. These methods should be called only via MvObs class.
+ */
+class MvBufr : public MvBufrBase
+{
+ friend class MvObs;
+ friend class MvObsSet;
+ friend class MvObsSetIterator;
+ friend class MvBufrConfidence;
+ friend class MvBufrOut;
+
+   static long  _bufrIn_ref;
+
+ protected:
+	    MvBufr( char *msg, long len, long aMessageNumber=0 );
+	    ~MvBufr( void );  //?? {} missing??
+
+      void  Decode( void );
+      void  Decode_012( void );
+      void  ExpandDescriptors( int subsetNumber );
+       int  descriptorToFortranIndex( const long aDescr, const int firstIndex = 0 );
+      long  currentBufrRef( void ) const { return _bufrIn_ref; };
+
+ EElementValueType  elementValueType( const int aSubsetNr );
+ EElementValueType  elementValueType( const long aDescriptor, const int aSubsetNr );
+ EElementValueType  elementValueTypeByIndex( const int anIndex, const int aSubsetNr );
+
+ boolean  Value( const long aDescriptor
+		 , const long aSubsetNumber
+		 , fortfloat &aDataValue
+		 , int   firstIndex = 0 );
+     fortfloat  DataValue( const int aDescriptorArrayIndex
+		     , const long aSubsetNumber);
+     fortfloat  PeekDataValue( const int aDescriptorArrayIndex
+		         , const long aSubsetNumber);
+      long  intValue( const long aDescriptor, const int subsetNr );
+
+    double  feedbackValue( int col, int subset );
+    double  feedbackValue( int row, int col, int subset );
+    string   feedbackItemName( int row,int subset );
+    string   feedbackItemUnit( int row,int subset );
+
+  TDynamicTime  obsTime( const int subsetNr ); //- from msg body (section 4)
+  TDynamicTime  msgTime( void );               //- from msg header (section 1)
+
+    string  stringValue( const long aDescriptor, const int aSubsetNr );
+    string  stringValue( const int aSubsetNr );
+    string  stringValueByIndex( const int anIndex, const int aSubsetNr );
+
+    string  unit( const long aDescriptor );
+    string  unit( void );
+    string  unitByIndex( const int anIndex );
+
+    string  name( const long aDescriptor );
+    string  name( void );
+    string  nameByIndex( const int anIndex );
+
+   boolean  SetFirstDescriptor( void );
+   boolean  SetNextDescriptor( void );
+      long  CurrentDescriptor( void ){ return _currentDescr; }
+ fortfloat  CurrentValue( const int aSubsetNr ){ return DataValue( _currentDescrInd, aSubsetNr); }
+
+      bool  printSection(ostream &aStream,int which);
+      bool printSection_012( ostream& aStream,int which);
+      bool  writeBufrBox( int aSubsetNr );
+       int  fillBufrBox( int aSubsetNr );
+      bool  getBufrBoxSize( int& rows, int& cols, int aSubsetNr );
+
+      bool  getDataFromSection2(map<string,string> &data);
+      void  parseSection2(fortint *fKEY,map<string,string> &data);
+
+      void  setSubset( int subsetNumber ){ _lastKnownSubsetValue = subsetNumber; }
+
+ private:
+      void  computeIn_KELEM( void );
+
+ protected:
+  EBufrInState  _inState;
+	  long  _currentDescr;
+	  int   _currentDescrInd;
+	  int   _bufrBoxFilledSubset;
+	  fortint  _lastKnownSubsetValue; //-- Q&D trick, BUSEL2 requires
+};
+
+//--------------------------------------------------------------- MvBufrOut
+// A simple class capable of producing BUFR code only from 'MvObs'
+// objects i.e. usable in filtering applications which read a
+// BUFR file and write a new file with less messages...
+//---------------------------------------------------------------
+
+class MvObsSet;
+class MvObs;
+class MvBufrConfidence;
+
+const int MAX_KDLEN = 2000;  //-- big value needed for some NCEP PrepBUFR files
+
+//! Wrapper around Fortran 'bufren', for (re)encoding
+/*! This class and its methods are a lower level wrapper around Fortran
+ *  subroutine 'bufren'. These methods should be called only via MvObs class.
+ */
+class MvBufrOut : public MvBufrBase
+{
+ friend class MvObs;
+ friend class MvObsSet;
+ friend class MvObsSetIterator;
+
+ protected:
+	    MvBufrOut( const long len, MvObsSet* anOutSet );
+	    ~MvBufrOut( void );
+
+   static long  _bufrOut_ref;
+
+      void  createBuffers();
+      void  resetBuffers( void );
+      void  formatBuffers( const MvObs& anObs );
+      void  write( MvObs& anObs );
+      void  add( MvObs& anObs );
+      void  addIntoBuffers( MvObs& anObs );
+      void  encode( void );
+      void  checkDescriptors( const MvObs& anObs );
+       int  differentDescriptors( void ) const;
+       int  differentHeader( const MvObs& anObs ) const;
+       int  shouldBeWritten( void );
+      void  setSubsetCount( int MaxNrSubsets );
+   boolean  isDelayedDescriptor( const long aDescriptor ) const;
+     // long  msgLength( void ) { return _msgIntLen*sizeof( fortint ); }
+
+ protected:
+       MvObsSet* _outSet;
+            int  _maxNrSubsets;
+	    int  _nextValue;
+	    int  _nextCharParamPos;
+  EBufrOutState  _outState;
+        fortint  _KDLEN;
+        fortint  _KDATA[ MAX_KDLEN ];
+   Section1Base* _currentSec1;
+};
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+//--------------------------------------------------------------- MvBufrParam
+
+class MvBufrParam
+{
+ public:
+        MvBufrParam( const char *aParamName );
+        MvBufrParam( const long anIntAsDescriptor ) {fDescriptor = anIntAsDescriptor;}
+
+  long  Descriptor( void ) const { return fDescriptor; }
+  void  PrintAllKnownParameters( void ) const;
+
+  operator int ( void ) const { return fDescriptor; }
+
+ private:
+     long  fDescriptor;
+};
+// DOXYGEN_SHOULD_SKIP_THIS
+#endif
+
+#endif
+// MvBufr_DEFINED
diff --git a/src/MvObs/MvBufrObs.h b/src/MvObs/MvBufrObs.h
new file mode 100644
index 0000000..fca7e63
--- /dev/null
+++ b/src/MvObs/MvBufrObs.h
@@ -0,0 +1,599 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvObs.h,   vk july94
+//        rev vk 010724
+
+#ifndef MvBufrObs_DEFINED
+#define MvBufrObs_DEFINED
+
+#include <string>
+#include "inc_iostream.h"
+//#include <fstream.h>
+//#include <strstream.h>
+#include "MvBufr.h"
+#include "MvLocation.h"
+#include "fmettim.h"
+
+#ifdef METVIEW
+//#   include "Metview.h"
+#    include "MvDate.h"
+#    include "MvRequest.h"
+#endif
+
+//---------------------------------------------------
+// Function definitions for the FORTRAN BUFR routines
+//---------------------------------------------------
+
+#ifdef FORTRAN_NO_UNDERSCORE
+#define  BUS012   bus012
+#define  BUPRS0   buprs0
+#define  BUPRS1   buprs1
+#define  BUPRS2   buprs2
+#define  BUFREX   bufrex
+#define  BUFREN   bufren
+#define  BUSEL    busel
+#define  BUSEL2   busel2
+#define  BUUKEY   buukey
+#define  BUPRS3   buprs3
+#define  BUBOX    bubox
+#define  BUPRTBOX buprtbox
+#define  FT_OP6   ft_op6
+#define  FT_CLO   ft_clo
+#else
+#define  BUS012   bus012_
+#define  BUPRS0   buprs0_
+#define  BUPRS1   buprs1_
+#define  BUPRS2   buprs2_
+#define  BUFREX   bufrex_
+#define  BUFREN   bufren_
+#define  BUSEL    busel_
+#define  BUSEL2   busel2_
+#define  BUUKEY   buukey_
+#define  BUPRS3   buprs3_
+#define  BUBOX    bubox_
+#define  BUPRTBOX buprtbox_
+#define  FT_OP6   ft_op6_
+#define  FT_CLO   ft_clo_
+#endif
+
+//--------------------------------------------------------------- MvObs
+//! A class to handle one observation report stored in a BUFR message
+/*! This class is used to request data and metadata from a single
+ *  BUFR message (Observation Report). Access to BUFR messages in
+ *  files is done using classes MvObsSet and MvObsSetIterator. \n
+ *
+ * <B>Descriptors</B> \n
+ * Elements within the message body are referenced by BUFR descriptors.
+ * These descriptors are of the form 'ZXXYYY', where Z=0, XX defines
+ * an element class and YYY defines an element within a class.
+ * Descriptor values can be found in "BUFR, User Guide and Reference Manual"
+ * by Milan Dragosavac (ECMWF). \n
+ * A Word of Warning: leave out leading zeroes when writing constants
+ * (such as descriptors) into your code, unless you intend to use
+ * octal constants! \n
+ *
+ * <B>Current Descriptor</B> \n
+ * Some member functions need no descriptor, because they will use
+ * the internal Current Descriptor set by a previously called member
+ * function which had a descriptor parameter. \n
+ *
+ * <B>Missing Values</B> \n
+ * Functions returning values from the message will return const kBufrMissingValue
+ * if the requested value is not available. Another const, called
+ * kBufrMissingIntValue is used for missing integer values.
+ */
+class MvObs
+{
+ friend class MvBufrOut;
+ friend class MvObsSet;
+ friend class MvObsSetIterator;
+
+	void _copy( MvBufr* b );
+	void _copy( const MvObs& b );
+	void _clean();
+
+public:
+//! Constructor
+/*! Arguments are mainly used by MvObsSet and MvObsSetIterator.
+ *  Applications normally call this constructor without arguments.
+ */
+	MvObs( MvBufr* b = NULL, int i = 1 );
+
+//! Copy constructor
+	MvObs( const MvObs&  b );
+
+	~MvObs();
+
+//! Assignment operator
+	MvObs& operator= ( const MvObs& b );
+
+//! Operator to test the validity of a new MvObs
+/*! In this example operator void*() is used implicitly
+ *  in testing the validity of MvObs object returned by
+ *  MvObsSetIterator object:
+ * <PRE>
+ *      MvObsSet mySet("/path/to/my/file");
+ *      MvObsSetIterator myIter(mySet);
+ *      ...
+ *      while(myObs=myIter()) //-- void*() is called here
+ *      {
+ *         ... //-- do the stuff
+ *      }
+ * </PRE>
+ */
+    operator void*();
+
+//! Returns the number of subsets available in this BUFR message
+/*! Use method Advance() to get to the next subset (in a multisubset BUFR message).
+ */
+        int  msgSubsetCount(){ return _bufrIn->subsetCount(); }
+
+//! Returns the current subset number (in a multisubset BUFR message)
+        int  subsetNumber() const { return _subsetNr; }
+
+//! Advances to the next subset in a multisubset BUFR message
+/*! Returns 'false' if current subset is the last (or the only)
+ *  one. Returns 'true' on success.
+ */
+	bool   Advance();
+
+//! Checks whether this MvObs contains a BUFR message or is empty
+    bool  operator! ();
+
+//! Checks that this MvObs contains a valid decodable BUFR message
+    bool  msg_ok() const; // { return _bufr_id == _bufrIn->currentBufrId(); }
+
+    // ----  A P I   f u n c t i o n s :  ---- //
+
+    //-- APIs for requesting parameter values --//
+
+//! Returns the value of an element defined by 'aDescriptor'
+/*! Also sets Current Descriptor.
+ *  Missing value indicator is returned if the observation report
+ *  does not contain elements of type 'aDescriptor', or if the element
+ *  does not have value.
+ */
+      float  value( long aDescriptor );
+
+//! Returns the value of an element defined by 'aDescriptor' as 'long'
+/*! Also sets Current Descriptor.
+ */
+       long  intValue( long aDescriptor );
+
+//! Returns the value of an element defined by 'aDescriptor' as 'string'
+/*! Also sets Current Descriptor.
+ */
+      string stringValue( long aDescriptor );
+
+//! Returns the value of Current Descriptor as a string
+      string stringValue();
+
+//! Returns the value of the next element with the same descriptor
+/*! Uses Current Descriptor to start looking for the next occurrence
+ *  of the same descriptor later in the message.
+ *  Updates Current Descriptor.
+ *  Returns 'kFortranBufrMissingValue' if no such element is found
+ *  or if such an element has no value.
+ */
+      float  nextValue();
+
+//! Returns the value corresponding to the 'n'th occurrence of descriptor 'descr'
+/*! Method searches the current subset from the beginning looking
+ *  for descriptors 'descr'. If BUFR message contains 'n' (or more)
+ *  occurrences of descriptor 'descr', the corresponding data value
+ *  is returned, otherwise 'kFortranBufrMissingValue' is returned.
+ */
+      float  valueByOccurrence( int n, long descr );
+
+//! Index access operator returns the 'n'th data value
+/*! This operator treats BUFR message as an array (as 'bufrdc' does)
+ *  and returns the value of the 'n'th element as 'double'.
+ *  Index 'n' starts from '1', i.e. n=1,2,3,...
+ */
+     double  operator[] ( int n );  //-- n starts from 1: 1,2,...,n
+
+//! Returns the value from the 'col'th feedback column for Current Descriptor
+/*! Uses 'bufrdc' subroutine 'BUBOX()' to arrange feedback values into
+ *  a two dimensional array. Argument 'col' refers to a column in this array.
+ */
+     double  feedbackValue( int col ){ return _bufrIn->feedbackValue( col, _subsetNr ); }
+
+//! Returns the value of the 'row'th element in the 'col'th feedback column
+/*! Uses 'bufrdc' subroutine 'BUBOX()' to arrange feedback values into
+ *  a two dimensional array. Arguments 'row' and 'col' are indices into
+ *  this array.
+ */
+     double  feedbackValue( int row, int col ){ return _bufrIn->feedbackValue( row, col, _subsetNr ); }
+
+     string  feedbackItemName( int row){ return _bufrIn->feedbackItemName( row, _subsetNr ); }
+     string  feedbackItemUnit( int row){ return _bufrIn->feedbackItemUnit( row, _subsetNr ); }
+
+    //-- APIs for requesting parameter metadata --//
+
+//! Returns the name of the data referenced by 'aDescriptor' (from BUFR Table B)
+     string  name( long aDescriptor );
+
+//! Returns the name of the data referenced by Current Descriptor
+     string  name();
+
+//! Returns the unit of the data referenced by 'aDescriptor' (from BUFR Table B)
+     string  unit( long aDescriptor );
+
+//! Returns the unit of the data referenced by Current Descriptor
+     string  unit();
+
+    //-- APIs for iterating through all parameters --//
+
+//! Sets the first expanded descriptor in the message as Current Descriptor
+/*! In case of decoding problems, returns 'false'.
+ */
+       bool  setFirstDescriptor(){ return _bufrIn->SetFirstDescriptor(); }
+
+//! Advances Current Descriptor to the next expanded descriptor in the message
+/*! Returns 'false' if message contains no more data (no more descriptors).
+ */
+       bool  setNextDescriptor(){ return _bufrIn->SetNextDescriptor(); }
+
+//! Returns the data value related to Current Descriptor
+      float  currentValue(){ return _bufrIn->CurrentValue( _subsetNr ); }
+
+//! Returns Current Descriptor
+       long  currentDescriptor(){ return _bufrIn->CurrentDescriptor(); }
+
+    //-- APIs for requesting parameter types --//
+
+//! Returns the type of data related to descriptor 'aDescriptor'
+ EElementValueType  elementValueType( long aDescriptor );
+
+//! Returns the type of data related to Current Descriptor
+ EElementValueType  elementValueType();
+
+    //-- APIs for requesting time and location data --//
+
+//! Returns the time from the observation report (from the data: BUFR section 4)
+        TDynamicTime  obsTime(){ return _bufrIn->obsTime( _subsetNr ); }
+
+//! Returns the time from the message metadata (from BUFR section 1)
+        TDynamicTime  msgTime(){ return _bufrIn->msgTime(); }
+
+//! Returns the location from the observation report (from the data: BUFR section 4)
+      MvLocation  location();
+
+    //-- APIs for message type, subtype, originating centre, etc --//
+
+//! Returns the Message Type code from BUFR section 1
+        int  messageType();
+
+//! Returns the locally defined Message Subtype code from BUFR section 1
+        int  messageSubtypeLocal();
+
+//! Returns the international Message Subtype code (WMO defined) from BUFR section 1
+/*! Note that this code is available only in BUFR Edition 4 messages. For Edition 3
+ *  messages a value of 255 is returned (255 corresponds to an octet with all bits '1').
+ */
+        int  messageSubtypeInternational();
+
+//! Returns either the local or the international message subtype
+/*! In BUFR Edition 3 only the local subtype was available.
+ *  In BUFR Edition 4 the WMO defined international subtype was
+ *  added. Local subtype was left for backwards compatibility.
+ *
+ *  For BUFR Edition 3 messages this function always returns the local subtype.
+ *
+ *  For later Editions this function returns the international subtype if
+ *  it has been set. If not set (has a value 255) then the local subtype
+ *  is returned
+ */
+        int  messageSubtype();
+
+//! Returns the Originating Centre code from BUFR section 1
+        int  originatingCentre();
+
+//! Returns the Originating Subcentre code from BUFR section 1
+        int  originatingSubCentre();
+
+//! Returns the Edition number from BUFR section 0
+        int editionNumber();
+
+//! Returns the Master Table code from BUFR section 1
+/*! Master Table 0 is for Meteorology, 10 is for Oceanography
+ */
+	int masterTable();
+
+//! Returns the Master Table version from BUFR section 1
+	int masterTableVersion();
+
+//! Returns the Local Table version from BUFR section 1
+	int localTableVersion();
+
+    //-- APIs for  --//
+//! Returns the total length of the message from BUFR section 0
+	int messageTotalLen();
+
+    //-- APIs for requesting weather station values --//
+//! Returns the 5 digit WMO station identifier
+/*! Looks for WMO block number 'BB' and station identifier 'SSS'
+ *  and returns the value of 'BBSSS' if found. Returns zero if
+ * 'BB' or 'SSS' is not found.
+ */
+       long  WmoIdentNumber();
+
+//! Returns the 2 digit WMO block identifier 'BB'
+/*! Returns zero if 'BB' not found.
+ */
+        int  WmoBlockNumber();
+
+//! Returns the 3 digit WMO station identifier 'SSS'
+/*! Returns zero if 'SSS' not found.
+ */
+        int  WmoStationNumber();
+
+//! Looks for an ident from the BUFR message
+/*! Looks for the following message identifiers: \n
+ *  - WMO Station Identifier 'BBSSS' \n
+ *  - Ship or mobile land station identifier (001011) \n
+ *  - Buoy/platform identifier (001005) \n
+ *  - Aircraft flight number (001006) \n
+ *  - Satellite identifier (001007) \n
+ *  - Aircraft registration number (001008) \n
+ *  - Stationary buoy platform identifier (001010) \n
+ *  - Storm identifier (001025)
+ *  - WMO storm name (001026)
+ *  - WMO long storm name (001027)
+ *
+ *  and returns the first one found, as a string. If none
+ *  of the above is found, returns "id???".
+ */
+     string  findSomeIdent();
+
+    //-- APIs for accessing replicated parameters --//
+
+//! Returns the number of times level coordinator descriptor 'levelDescriptor' is found
+	int  numberOfLevels( long levelDescriptor );
+
+//! Returns the first value related to 'levelDescriptor', i.e. value of the first level
+      float  firstLevel( long levelDescriptor );
+
+//! Returns the value of the next level related to Current Level Descriptor
+      float  nextLevel();
+
+//! Returns the value of the specified data for the specified level
+/*! First looks for a data block related to level 'aLevel' as the
+ *  value of the data element related to level descriptor 'aLevelDescriptor',
+ *  and then looks for a data element related to descriptor 'aDescriptor'
+ *  within this level.
+ */
+      float  valueByLevel( long  aLevelDescriptor
+                         , float aLevel
+			 , long  aDescriptor );
+			 
+      float  valueByLevelRange( long  aLevelDescriptor
+                         , float firstLevel
+			 , float seconLevel	
+			 , long  aDescriptor );
+			 		 
+//! Returns the number of pressure levels found in the observation report
+/*! Pressure level descriptor is 007004, so this is an alias for member function
+ *  numberOfLevels(7004).
+ */
+	int  numberOfPressureLevels();
+
+//! Returns the value of the first pressure level in hPa
+/*! Original pressure values are stored in Pa, so this is
+ *  the same as 100.0*firstLevel(7004).
+ */
+      float  firstPressureLevel();
+
+//! Returns the value of the next pressure level in hPa
+/*! Original pressure values are stored in Pa, so this is
+ *  the same as 100.0*nextLevel(7004).
+ */
+      float  nextPressureLevel();
+
+//! Returns the value of the data corresponding to 'aDescriptor' on level 'aLevel'
+/*! Here 'aLevel' is given in hPa. Original pressure values are stored in Pa,
+ *  so this is the same as \n
+ * <PRE>
+ *      valueByLevel( 7004, 100.0*aLevel, aDescriptor )
+ * </PRE>
+ */
+      float  valueByPressureLevel( float aLevel, long aDescriptor );
+
+//! Returns the value of the data corresponding to 'aDescriptor' in a layer
+/*! Level values are for the top and the bottom pressure values of a layer
+ *  and they are given in hPa. \n \n
+ *  This method looks for two consecutive pressure coordinate descriptors
+ *  007004 with the given values (hPa is first converted to Pa). If such
+ *  a layer is found and the layer contains 'aDescriptor' then the corresponding
+ *  data value is returned, otherwise 'kBufrMissingValue' is returned.
+ */
+      float  valueByLayer( float firstLevel
+		         , float secondLevel
+		         , long aDescriptor );
+
+    //-- APIs for printing obs --//
+    // Section 0,1,2 and 3 just delegated to bufr class.
+
+//! Prints BUFR section 0 to output stream 'aStream'
+    boolean  printSection0(ostream &aStream = cout)
+      { return _bufrIn->printSection_012(aStream,0); }
+
+//! Prints BUFR section 1 to output stream 'aStream'
+    boolean  printSection1(ostream &aStream = cout)
+      { return _bufrIn->printSection_012(aStream,1); }
+
+//! Prints BUFR section 2 to output stream 'aStream'
+    boolean  printSection2(ostream &aStream = cout)
+      { return _bufrIn->printSection_012(aStream,2); }
+
+//! Prints BUFR section 3 to output stream 'aStream'
+    boolean  printSection3(ostream &aStream = cout)
+      { return _bufrIn->printSection(aStream,3); }
+
+//! Decode BUFR section 2 and place the result into an std::map
+    bool getDataFromSection2(map<string,string> &data)
+	{ return _bufrIn->getDataFromSection2(data); }
+
+//! Prints all data values into standard output
+/*! For output format see method 'writeAllValues' below
+ */
+    boolean  printAllValues();
+
+//! Writes all data values into output stream 'aStream'
+/*! Writes the data, one data value per line. Each line consists of:
+ *  - index of the data
+ *  - data value
+ *  - name of the data
+ *  - unit of the data, in square brackets
+ *  - the corresponding BUFR descriptor, in parenthesis
+ *
+ *  Example output (an extract from a SYNOP report): \n
+ * <PRE>
+ *       1.      10 Wmo Block Number [NUMERIC] (01001)
+ *       2.     500 Wmo Station Number [NUMERIC] (01002)
+ *       3.       1 Type Of Station [CODE TABLE 002001] (02001)
+ *       4.    2007 Year [YEAR] (04001)
+ *       5.      11 Month [MONTH] (04002)
+ *       6.       6 Day [DAY] (04003)
+ *       7.      22 Hour [HOUR] (04004)
+ *       8.       0 Minute [MINUTE] (04005)
+ *       9.   50.97 Latitude (High Accuracy) [DEGREE] (05001)
+ *      10.    6.05 Longitude (High Accuracy) [DEGREE] (06001)
+ *      11.      98 Height Of Station [M] (07001)
+ *     ...
+ * </PRE>
+ */
+    boolean  writeAllValues( ostream& aStream );
+
+//! Writes all data values into file 'aPathName'
+/*! For output format see the version of method 'writeAllValues' above
+ */
+    boolean  writeAllValues( const char* aPathName );
+
+//! Calls 'bufren' routine BUPRTBOX to write feedback data into stream 'aStream'
+    boolean  writeBufrBox( ostream& aStream = cout );
+
+    //-- APIs for accessing original section 1 and 2 headers --//
+
+//	const unsigned char*
+//	         section1Ptr(){ return (unsigned char*)(_bufrIn->Sec1->start()); }
+
+//! Returns 'true' if BUFR message contains local section 2, 'false' if not
+	bool     hasSection2(){ return _bufrIn->fSec2 != NULL; }
+
+//! Returns a pointer to the beginning of local section 2 in BUFR message
+/*! Returns 0 (NULL) if message has no local section 2
+ */
+	const unsigned char*
+	         section2Ptr(){ return _bufrIn->fTotalSec2; }
+
+    //-- APIs for accessing confidence values --//
+
+//! Checks whether the BUFR message contains confidence values or not
+/*! Returns 'true' if operator descriptor 222000 is found in the
+ *  message, otherwise 'false'.
+ */
+       bool  hasConfidences();
+
+//! Returns the confidence value for the current data, if exists
+/*! Otherwise returns -1.
+ */
+        int  confidence();
+
+//! Writes confidence values into stream 'aStream'
+       bool  writeConfidenceValues( ostream& aStream );
+
+ bool  getBufrBoxSize( int& rows, int& cols )
+                 { return _bufrIn->getBufrBoxSize( rows, cols, _subsetNr ); }
+
+     //-- Q&D: valueBySpecifier & specifierIndex made public
+     //--      so that ObsPicker can use them freely (vk/Jul)
+     double  valueBySpecifier( long   aSpecifierDescriptor
+			     , double aSpecifierValue
+		             , long   aDescriptor
+			     , int   firstIndexValue = 0 );
+     int     specifierIndex( long   aSpecifierDescriptor
+		           , double aSpecifierValue
+		           , int    firstIndexValue = 0 );
+
+#ifdef METVIEW
+//! Decodes OPERA BUFR radar data into unsigned char array
+   unsigned char* OperaRadarImage( /* <aki> add arguments? */ );
+//! Retrieves metadata for OPERA radar image
+   bool  OperaRadarMetadata( /* <aki> add arguments? */ );
+#endif
+
+ private:
+ //protected:
+    float  pressureLevel( int firstIndexValue );
+    float  level( long levelDescriptor, int firstIndexValue );
+    boolean writeValues(ostream &aStream,int first, int last);
+
+ private:
+        int  subsetOffset() const;
+
+	const unsigned char*
+	         section1Ptr(){ return (unsigned char*)(_bufrIn->Sec1->start()); }
+
+ protected:
+ 	int     _subsetNr;
+	MvBufr* _bufrIn;
+	long    _bufr_id;
+ 	int     _lastSpecifierIndex; //required???? used by who?????
+	long    _currentLevelCoordinate;
+	int     _currentLevelIndex;
+	MvBufrConfidence* _confidence;
+};
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+//--------------------------------------------------------------- MvBufrConfidence
+// Q&D hack for QC Feed Back using descr operator 222000; vk Apr-95
+
+//! \enum ESelectFilterState Used internally by MvBufrConfidence
+enum EBufrConfState
+{
+   kBCS_unknown
+  ,kBCS_missing
+  ,kBCS_exists
+};
+
+//------------------------------------------------------------------------------
+//! Auxiliary class to handle quality control feedback
+/*! Warning: This is Q&C ("quick&dirty") hack to access
+ *  QC FB data behind operator descriptor 222000.
+ */
+class MvBufrConfidence
+{
+ public:
+          MvBufrConfidence( MvBufr* aBufr, int aSubsetNr );
+          ~MvBufrConfidence();
+
+      bool  hasConfidences();
+       int  confidence( long aDescriptor );
+       int  confidenceByIndex( int anIndex );
+       int  lastDataIndex();
+
+ protected:
+       int  startOfDataPresent();
+       int  startOfConfidences();
+       int  delta( int anIndex );
+
+ private:
+   MvBufr*  _bufr;
+   int      _subsetNr;
+   int      _startOfDataPresent;
+   int      _startOfConfidences;
+   EBufrConfState _state;
+};
+#endif
+
+
+#endif
+// MvBufrObs_DEFINED
diff --git a/src/MvObs/MvLocation.cc b/src/MvObs/MvLocation.cc
new file mode 100644
index 0000000..7dab469
--- /dev/null
+++ b/src/MvObs/MvLocation.cc
@@ -0,0 +1,263 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvLocation.cc,     vk 940901...
+//                rev vk 011025
+
+// classes:  MvLocation, MvArea, MvXSectionLine
+
+
+#include <math.h>
+//#include "Metview.h"
+#include "MvLocation.h"
+
+//_____________________________________________________________________ set
+void
+MvLocation :: set( double aLat, double aLong )
+{
+/*--- to check or not to check: XSection computes values outside the real world!!!
+   if( aLat != MISSING_LOC_VALUE && ( aLat > 90. || aLat < -90. ) )
+   {
+     cerr << " >>> MvLocation::MvLocation: strange latitude value " << aLat << endl;
+     fLatitude = MISSING_LOC_VALUE;
+   }
+   else
+---*/
+   fLatitude = aLat;
+
+/*---
+   if( aLong != MISSING_LOC_VALUE && ( aLong > 360. || aLong < -360. ) )
+   {
+     cerr << " >>> MvLocation::MvLocation: strange longitude value " << aLong << endl;
+     fLongitude = MISSING_LOC_VALUE;
+   }
+   else
+---*/
+   fLongitude = aLong;
+}
+
+//______________________________________________________________ distanceInRadians
+double
+MvLocation :: distanceInRadians( const MvLocation& anOtherLocation ) const
+{
+   const double cDEG2RAD = M_PI / 180.0;
+
+   double lat1 = latitude() * cDEG2RAD;
+   double lat2 = anOtherLocation.latitude() * cDEG2RAD;
+   double lon1 = longitude() * cDEG2RAD;
+   double lon2 = anOtherLocation.longitude() * cDEG2RAD;
+
+   //-- from: http://williams.best.vwh.net/avform.htm (020815/vk) --
+   double d = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2));
+
+   return d;
+}
+
+//_____________________________________________________________ distanceInDegrees
+double
+MvLocation :: distanceInDegrees( const MvLocation& anOtherLocation ) const
+{
+   return distanceInRadians( anOtherLocation ) * 180.0 / M_PI;
+}
+
+//_____________________________________________________________ distanceInMeters
+double
+MvLocation :: distanceInMeters( const MvLocation& anOtherLocation ) const
+{
+  const double cR2NM = 180.0*60.0/M_PI;  //-- radians -> nautical miles
+  const double cNM2M = 1852;             //-- nautical miles -> metres
+
+  double nm = distanceInRadians( anOtherLocation ) * cR2NM;
+  return nm * cNM2M;;
+}
+
+//_____________________________________________________________ operator=
+MvLocation&
+MvLocation :: operator= ( const MvLocation& aLoc )
+{
+   set( aLoc.latitude(), aLoc.longitude() );
+   return *this;
+}
+//_____________________________________________________________ operator<<
+
+ostream& operator<< ( ostream& aStream, const MvLocation& aLocation )
+{
+   aStream << "(" << aLocation.latitude() << "," << aLocation.longitude() << ")";
+/*--- How to get a constant field width + constant nr of decimal digits!?
+   aStream << "(";
+   aStream.width( 6 ); aStream.fill( ' ' );
+   aStream << aLocation.latitude() << ",";
+   aStream.width( 7 ); aStream.fill( ' ' );
+   aStream << aLocation.longitude() << ")";
+---*/
+   return aStream;
+}
+
+//____________________________________________________________________________
+//============================================================================ MvArea
+//____________________________________________________________________________
+
+MvArea :: MvArea( void )
+{
+   MvLocation myLocation;
+   set( myLocation, myLocation );
+}
+//____________________________________________________________________
+
+void
+MvArea :: set( const MvLocation& aLocation1, const MvLocation& aLocation2 )
+{
+   double y1 = aLocation1.latitude();
+   double x1 = aLocation1.longitude();
+   double y2 = aLocation2.latitude();
+   double x2 = aLocation2.longitude();
+   if( y1 > y2 )
+   {
+      double yy = y1; y1 = y2; y2 = yy;
+   }
+   if( x1 > x2 )
+   {
+      double xx = x1; x1 = x2; x2 = xx;
+   }
+   fLowerLeft.set( y1, x1 );
+   fUpperRight.set( y2, x2 );
+}
+//____________________________________________________________________
+
+bool
+MvArea :: inside( const MvLocation& aPoint ) const
+{
+   if( aPoint.latitude() >= fLowerLeft.latitude() &&
+       aPoint.latitude() <= fUpperRight.latitude() &&
+       aPoint.longitude() >= fLowerLeft.longitude() &&
+       aPoint.longitude() <= fUpperRight.longitude()
+      )
+     return true;
+   else
+     return false;
+}
+//____________________________________________________________________
+
+MvArea&
+MvArea :: operator= ( const MvArea& anArea )
+{
+   set( anArea.lowerLeft(), anArea.upperRight() );
+   return *this;
+}
+//____________________________________________________________________
+
+ostream& operator<< ( ostream& aStream, const MvArea& anArea )
+{
+   aStream << anArea.lowerLeft() << "-" << anArea.upperRight();
+   return aStream;
+}
+
+//______________________________________________________________________
+//====================================================================== MvXSectionLine
+//______________________________________________________________________
+
+//_____________________________________________________________ WithinDelta
+bool
+MvXSectionLine :: withinDelta( const MvLocation& aLocation ) const
+{
+   //-- check that max delta has been set
+   if( fMaxDeltaInMeters < 0 )
+      return false;
+
+   //-- check distance from the line going through end points
+   if( deltaInMeters( aLocation ) > fMaxDeltaInMeters )
+      return false;
+
+   //--- check that the distance is from the line between end points
+   return insideXLine( aLocation );
+}
+//_____________________________________________________________ InsideXLine
+bool
+MvXSectionLine :: insideXLine( const MvLocation& aLocation ) const
+{
+   MvLocation myLocation = nearestPointOnXLine( aLocation );
+   MvArea myArea( fLocation1, fLocation2 );
+   return myArea.inside( myLocation );
+}
+//_____________________________________________________________ NearestPointOnXLine
+// Q&D approximation for distance of a point from an XSection
+// line, in degrees true at equator...
+//--------
+// WARNING: calculates distance from a line going through end
+//          points of XSectionLine, NOT ONLY between points!
+//-------------------------------------------------------------
+MvLocation
+MvXSectionLine :: nearestPointOnXLine( const MvLocation& aLocation ) const
+{
+   MvLocation myNearestPointOnXLine;
+
+   double dy = fLocation1.latitude() - fLocation2.latitude();
+   double dx = fLocation1.longitude() - fLocation2.longitude();
+
+   if( dx == 0 )            //-- vertical line --
+   {
+      myNearestPointOnXLine.set( aLocation.latitude(), fLocation1.longitude() );
+   }
+   else if( dy == 0 )       //-- horizontal line --
+      {
+         myNearestPointOnXLine.set( fLocation1.latitude(), aLocation.longitude() );
+      }
+      else                  //-- just a line --
+      {
+         // calculate coefficients for the Xsection line: y=a1*x+b1
+         double a1 = dy / dx;
+         double b1 = fLocation1.latitude() - a1 * fLocation1.longitude();
+
+         // define perpendicular line thru aLocation: y=a2*x+b2
+         double a2 = - 1. / a1;
+         double b2 = aLocation.latitude() - a2 * aLocation.longitude();
+
+         double x = ( b2 - b1 ) / ( a1 - a2 );
+         double y = a1 * x + b1;
+         myNearestPointOnXLine.set( y, x );
+      }
+
+   //-- WARNING: does not check that nearest point is inside XSectionLine !!!!
+   return  myNearestPointOnXLine;
+}
+//_____________________________________________________________ DeltaInDegrees
+double
+MvXSectionLine :: deltaInDegrees( const MvLocation& aLocation ) const
+{
+   return aLocation.distanceInDegrees( nearestPointOnXLine( aLocation ) );
+}
+//_____________________________________________________________ DeltaInMeters
+// Q&D approximation for delta, uses DeltaInDegrees
+//-------------------------------------------------------------
+double
+MvXSectionLine :: deltaInMeters( const MvLocation& aLocation ) const
+{
+   //-- Q&D formula, out of my old used brains, unchecked!!!! (vk 940901) --
+   double degreeIntoMeters = 6370.*1000. * 2. * M_PI / 360.;
+   return deltaInDegrees( aLocation ) * degreeIntoMeters;
+}
+//_____________________________________________________________ operator=
+MvXSectionLine&
+MvXSectionLine :: operator= ( const MvXSectionLine& anXLine )
+{
+   setLine( anXLine.startPoint(), anXLine.endPoint() );
+   setMaxDelta( anXLine.maxDelta() );
+   return *this;
+}
+//_____________________________________________________________ operator<<
+// output format: "(lat1,long1)-(lat2,long2)/delta"
+//-------------------------------------------------
+
+ostream& operator<< ( ostream& aStream, const MvXSectionLine& anXLine )
+{
+   aStream << anXLine.startPoint() << "-" << anXLine.endPoint()
+           << "/" << anXLine.fMaxDeltaInMeters; // << endl;
+   return aStream;
+}
+
diff --git a/src/MvObs/MvLocation.h b/src/MvObs/MvLocation.h
new file mode 100644
index 0000000..ffec53a
--- /dev/null
+++ b/src/MvObs/MvLocation.h
@@ -0,0 +1,187 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvLocation.h,     vk 940901...
+//               rev vk 950303
+
+#ifndef MvLocation_DEFINED_
+#define MvLocation_DEFINED_
+
+#include "inc_iostream.h"
+
+const double MISSING_LOC_VALUE = -99999.;
+
+
+//_________________________________________________________________________ MvLocation
+//! Class for geographical locations
+/*! MvLocation is used to store latitude-longitude location values.
+ *  Class also provides methods to calculate the distance to another
+ *  geographical location
+ */
+class MvLocation
+{
+//! Output operator for MvLocation object
+/*! The output is enclosed in parenthesis and latitude and longitude values
+ *  are separated by a comma, for instance:
+ * <PRE>
+ *      MvLocation loc1(51.46,-1.33);
+ *      MvLocation loc2(60.45,25.0);
+ *      std::cout << "Locations are: " << loc1 << " and " << loc2 << std::endl;
+ * </PRE>
+ *  would output the following line:
+ * <PRE>
+ *      Locations are: (51.46,-1.33) and (60.45,25)
+ * </PRE>
+ */
+ friend ostream& operator<< ( ostream& aStream, const MvLocation& aLocation );
+
+ public:
+	//! Constructor, location is assigned with missing values
+	MvLocation() { fLatitude  = MISSING_LOC_VALUE;
+	               fLongitude = MISSING_LOC_VALUE; }
+
+	//! Constructor for latitude-longitude location
+	MvLocation( double aLat, double aLong ) { set( aLat, aLong); }
+
+   //! Sets new latitude-longitude location
+   void  set( double aLat, double aLong );
+
+   //! Checks that the stored location is a valid geographical point
+   /*! Latitude value must be in interval [-90,90] and longitude
+    *  value in interval [-360,360], in degrees.
+    */
+   bool  ok(){ return (fLatitude  <=  90 && fLatitude >=  -90 &&
+                       fLongitude <= 360 && fLongitude >= -360); }
+
+  //! Returns the latitude value
+  double  latitude() const  { return fLatitude; }
+
+  //! Alias to method latitude()
+  double  y() const         { return fLatitude; }
+
+  //! Returns the longitude value
+  double  longitude() const { return fLongitude; }
+
+  //! Alias to method longitude()
+  double  x() const         { return fLongitude; }
+
+  //! Returns the distance (in radians) to the given point
+  double  distanceInRadians( const MvLocation& anOtherLocation ) const;
+
+  //! Returns the distance (in degrees) to the given point
+  double  distanceInDegrees( const MvLocation& anOtherLocation ) const;
+
+  //! Returns the distance (in metres) to the given point
+  double  distanceInMeters( const MvLocation& anOtherLocation ) const;
+
+  //! Assignment operator
+  MvLocation& operator= ( const MvLocation& aLoc );
+
+ private:
+  double fLatitude;
+  double fLongitude;
+};
+
+//_________________________________________________________________________ MvArea
+//! Class for geographical areas (squares on cylindrical projection)
+/*! This is another incarnation of MvGeoBox class, used mainly by
+ *  MvObsSetIterator. For other usage MvGeoBox is recommended over MvArea.
+ */
+class MvArea
+{
+ friend ostream& operator<< ( ostream& aStream, const MvArea& aArea );
+
+ public:
+         MvArea();
+         MvArea( const MvLocation& aLoc1, const MvLocation& aLoc2 )
+	                                                   { set( aLoc1, aLoc2 ); }
+
+       void  set( const MvLocation& aLoc1, const MvLocation& aLoc2 );
+       bool  inside( const MvLocation& aPoint ) const;
+ MvLocation  lowerLeft( void ) const { return fLowerLeft; }
+ MvLocation  upperRight( void ) const { return fUpperRight; }
+
+  MvArea& operator= ( const MvArea& aLoc );
+
+ private:
+  MvLocation fLowerLeft;
+  MvLocation fUpperRight;
+};
+
+//_____________________________________________________________________ MvXSectionLine
+//! Class for cross section lines (straight lines on cylindrical projection)
+/*! Class can be used to check if any given point is withing the allowed
+ *  distance (max delta) from the given line, i.e. close enough to be
+ *  considered to be within the line.
+ */
+class MvXSectionLine
+{
+ friend ostream& operator<< ( ostream& aStream, const MvXSectionLine& aXSectionLine );
+
+ public:
+	//! Empty constructor creates a missing line
+	MvXSectionLine( void )
+	              { fLocation1.set( MISSING_LOC_VALUE, MISSING_LOC_VALUE );
+	                fLocation2.set( MISSING_LOC_VALUE, MISSING_LOC_VALUE );
+	                fMaxDeltaInMeters = -1;
+	              }
+
+	//! Constructor, only points defined, no max delta given
+	/*! Use method setMaxDelta() to set the maximum allowed distance from the line
+	*/
+	MvXSectionLine( const MvLocation& aLoc1, const MvLocation& aLoc2 )
+	              { fLocation1 = aLoc1; fLocation2 = aLoc2; fMaxDeltaInMeters = -1; }
+
+	//! Constructor, two points and max distance from the line
+	MvXSectionLine( const MvLocation& aLoc1, const MvLocation& aLoc2, double aDelta )
+	              { fLocation1 = aLoc1; fLocation2 = aLoc2; fMaxDeltaInMeters = aDelta; }
+
+	//! Set a new line between points aLoc1 and aLoc2
+	void  setLine( const MvLocation& aLoc1, const MvLocation& aLoc2 )
+	             { fLocation1 = aLoc1; fLocation2 = aLoc2; }
+
+	//! Return the current start point of the line
+	MvLocation  startPoint( void ) const { return fLocation1; }
+
+	//! Return the current end point of the line
+	MvLocation  endPoint( void ) const   { return fLocation2; }
+
+	//! Set the maximum allowed distance from the line
+	void  setMaxDelta( double aDelta ) { fMaxDeltaInMeters = aDelta; }
+
+	//! Return the current maximum allowed distance from the line
+	double  maxDelta( void ) const { return fMaxDeltaInMeters; }
+
+	//! Returns true if the given point is within the given proximity of the line
+	bool  withinDelta( const MvLocation& aLocation ) const;
+
+	//! Returns the distance of the given point from the cross section line (in degrees)
+	double  deltaInDegrees( const MvLocation& aLocation ) const;
+
+	//! Returns the distance of the given point from the cross section line (in meters)
+	double  deltaInMeters( const MvLocation& aLocation ) const;
+
+	//! Assignment operator
+	MvXSectionLine& operator= ( const MvXSectionLine& anXLine );
+
+ private:
+	//! Returns the nearest point on the line through end points
+	MvLocation  nearestPointOnXLine( const MvLocation& aLocation ) const;
+
+	//! Checks that the closest point on the line is between end points
+	bool  insideXLine( const MvLocation& aLocation ) const;
+
+ private:
+  MvLocation  fLocation1;
+  MvLocation  fLocation2;
+      double  fMaxDeltaInMeters;
+};
+
+#endif
+// MvLocation_DEFINED_
diff --git a/src/MvObs/MvObs.cc b/src/MvObs/MvObs.cc
new file mode 100644
index 0000000..e4a3f05
--- /dev/null
+++ b/src/MvObs/MvObs.cc
@@ -0,0 +1,3297 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvObs.cc,     vk 940818...
+//           rev vk 980501
+
+//--------------------------------------------------------------------
+//  A class to hide the complexities of BUFR routines written in
+//  FORTRAN.  'MvObs' tries to wrap these routines into a nicer C++
+//  interface and hide the required data structures.
+//  Headers for the FORTRAN functions are defined in the file 'MvBufr.h'
+//--------------------------------------------------------------------
+//    FORTRAN routines and required data structures are described in:
+//
+//    "Decoding Data Represented in FM 94 BUFR"
+//         by J.K.Gibson and M.Dragosavac
+//
+//             published as PAPER 4 in
+//
+//    "BINARY
+//     UNIVERSAL FORM FOR
+//     DATA REPRESENTATION
+//     ----------------------------------
+//     FM 94 BUFR
+//     Collected papers and specification"
+//
+//            ECMWF February 1988.
+//
+//  and in:
+//
+//     "BUFR User Guide and Reference Manual"
+//         by Milan Dragosavac
+//     European Centre for Medium-Range Weather Forecasts
+//         preprint  12 October 1994
+//--------------------------------------------------------------------
+
+#include "inc_iostream.h"
+#include <sstream>  //-- requires new templated standard io headers!
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <assert.h>
+//F #include "Metview.h"
+#include "MvObs.h"
+#include "MvObsSet.h"
+
+#include <map>
+
+#ifdef METVIEW
+#  include "MvException.h"
+#else
+#  include <exception>
+#endif
+
+// Static int used to duplicate stdout and get it back.
+static int new_fd = -1;
+
+const int MAX_BUBOX_KELEM_LIMIT  = MAX_KELEM;
+
+static string MESSED_UP("[messed messages!]");
+
+static string BBOXNAME("prtbbox.txt"); //for BUPRTBOX output.
+static string redirect_dir(""); // For tmp files from print.
+
+//--------------------------------------------------------
+// Fortran routines expect previous values to be remained
+// (at least in some of the arrays) if new msg has same
+// descriptors as previous msg !!!
+// Thus static arrays, common to all bufr-objects...
+// Added lazy evaluation 980501/vk...
+//--------------------------------------------------------
+static char* In_CNAMES = 0;  //static char In_CNAMES[ MAX_KELEM ][ 64 ]; //- is not updated if same descriptors
+static char* In_CUNITS = 0;  //static char In_CUNITS[ MAX_KELEM ][ 24 ]; //- is not updated if same descriptors
+static char* In_CVALS  = 0;  //static char In_CVALS [ MAX_KVALS ][ 80 ]; //+ rest of the arrays always updated
+static char* Out_CVALS = 0;  //static char Out_CVALS [ MAX_KVALS ][ 80 ];
+
+static fortfloat* In_VALUES = 0;  //static fortfloat  In_VALUES[ MAX_KVALS ];
+static fortfloat* Out_VALUES = 0; //static fortfloat Out_VALUES[ MAX_KVALS ];
+
+static fortint  In_KELEM;
+static fortint  In_KVALS;
+static fortint  Out_KELEM = -1;
+	                                // for BUSEL
+static fortint  In_KTDEXL;
+static fortint* In_KTDEXP = 0;  //static fortint  In_KTDEXP[ MAX_KELEM ];
+static fortint  In_KTDLEN;
+static fortint* In_KTDLST = 0;  //static fortint  In_KTDLST[ MAX_KELEM ];
+static fortint  Out_KTDEXL;
+static fortint* Out_KTDEXP = 0; //static fortint Out_KTDEXP[ MAX_KELEM ];
+static fortint  Out_KTDLEN;
+static fortint* Out_KTDLST = 0; //static fortint Out_KTDLST[ MAX_KELEM ];
+
+static int arraySizeIndex = 0; // incremented each time we try to allocate a new size of arrays
+static int kVals;
+
+long MvBufr::_bufrIn_ref = 0;
+long MvBufrOut::_bufrOut_ref = 0; //not yet implemented...
+
+
+//-- Linux/g++ does not like hardcoded big? arrays (works ok in debugger,
+//-- but crashes inside Metview...) => create arrays dynamically, once!
+//-- These are for BUFR-BOX routines (accessing Feedback info)
+
+static fortint    myKSUB, myKBOX, myKAPP, myKLEN, myKERR;
+static fortint*   myKBOXR = 0;
+static fortfloat* myVALS  = 0;
+static char*      myCBOXN = 0;
+static char*      myCBOXU = 0;
+
+
+const long cPressureCoordinate = 7004L;  // pressure vertical coord. descriptor value
+
+//--------------------------------------------------------
+//  Descriptor mnemonics for class 'MvBufrParam'
+//--------------------------------------------------------
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+typedef struct
+{
+   const char *name;
+   long        descriptor;
+} descriptorStruct;
+
+static descriptorStruct knownParams[] =
+{
+   {"z", 10003}, {"p", 10004},
+   {"ddd", 11001}, {"ff", 11002}, {"u", 11003}, {"v", 11004}, {"w", 11006},
+   {"T", 12001}, {"Td",12003}, {"T(2m)",12004}, {"Td(2m)",12006},
+   {"END",0}
+};
+#endif
+
+//--------------------------------------------------------
+//  Function definitions for the FORTRAN & C BUFR routines
+//--------------------------------------------------------
+
+extern "C" {
+
+ void
+ BUS012( fortint *KBUFL, fortint *KBUFF, fortint *KSUP
+       , fortint *KSEC0, fortint *KSEC1, fortint *KSEC2, fortint *KERR );
+
+ void
+ BUPRS0( fortint *KSEC0 );
+ void
+ BUPRS1( fortint *KSEC1 );
+ void
+ BUPRS2( fortint *KSUP, fortint *KEY);
+
+ void
+ BUFREX( fortint *KBUFL, fortint *KBUFF, fortint *KSUP
+       , fortint *KSEC0, fortint *KSEC1, fortint *KSEC2, fortint *KSEC3, fortint *KSEC4
+       , fortint *KELEM, char *CNAMES,     char *CUNITS
+       , fortint *KVALS, fortfloat *VALUES,  char *CVALS, fortint *KERR );
+
+ void
+ BUFREN( fortint *KSEC0, fortint *KSEC1, fortint *KSEC2, fortint *KSEC3, fortint *KSEC4
+       , fortint *KTDLEN,fortint *KTDLST,fortint *KDLEN, fortint *KDATA
+       , fortint *KELEM, fortint *KVALS, fortfloat *VALUES, char *CVALS
+       , fortint *KBUFL, fortint *KBUFF, fortint *KERR );
+
+ void
+ BUSEL( fortint *KTDLEN, fortint *KTDLST, fortint *KTDEXL, fortint *KTDEXP, fortint *KERR );
+
+ void
+ BUSEL2( fortint *KSUBSET,fortint *KELEM,fortint *KTDLEN,fortint *KTDLST
+       , fortint *KTDEXL, fortint *KTDEXP, char *CUNITSCNAMES, char *CUNITSCUNITS
+       , fortint *KERR);
+
+ void
+ BUUKEY(fortint *KSEC1, fortint *KSEC2, fortint *KEY, fortint *KSUP,fortint *KERR);
+ void
+ BUPRS3( fortint *KSEC3, fortint *KTDLEN, fortint *KTDLST
+       , fortint *KTDEXL, fortint *KTDEXP, fortint *KELEM, char *CNAMES );
+
+ void
+ BUBOX( fortint *KSUB,   fortint *KSUP,      fortint *KELEM
+      , fortint *KWTR,   char *CNAMES, char *CUNITS
+      , fortint *KVALS,  fortfloat *VALUES,  fortint *KBOX
+      , fortint *KAPP,   fortint *KLEN,      fortint *KBOXR
+      , fortfloat *VALS, char* CBOXN,        char* CBOXU
+      , fortint *KERR );
+
+  void
+  BUPRTBOX( fortint *KBOX,   fortint *KAPP,   fortint *KLEN
+          , fortint *KBOXR,  fortfloat *VALS, char* CBOXN
+          , char* CBOXU );
+
+ // Helper functions
+ boolean redirect_6(const char *);  //-- Trick to redirect Fortran unit 6.
+ boolean reconnect_6();
+ boolean file_to_stream(const char *,ostream&,int skip);
+ void delete_print_file(const char *);
+ void eraseWhiteSpaceFromStringEnd(string &str);
+ int CIND(int i) { return i-1;}
+}
+
+static string intToString(int);
+static string floatToString(float);
+static void keyToStringMap(map<string,string> &,string,fortint *,int);
+static void keyToStringMap(map<string,string> &,string,float);
+
+//______________________________________________________________________
+
+Section1Base::Section1Base( const unsigned char* octs )
+{
+   int slen = 65536*octs[0] + 256*octs[1] + octs[2];
+   octets_ = new unsigned char[slen];
+   memcpy( octets_, octs, slen );
+}
+
+Section1Base::Section1Base( const Section1Base* aSec1 )
+{
+   octets_ = new unsigned char[ aSec1->len() ];
+   memcpy( octets_, aSec1->start(), aSec1->len() );
+}
+
+bool
+Section1Base::isDifferent( const Section1Base* aSec1 ) const
+{
+   if( len() != aSec1->len() )
+      return true;
+
+   for( int i=0; i<len(); ++i )
+      if( octets_[i] != aSec1->octets_[i] )
+         return true;
+
+   return false;
+}
+
+bool
+Section1_preEd4::hasSection2()
+{
+   return octets_[7] > 127;   //-- octet 8
+}
+bool
+Section1_Ed4::hasSection2()
+{
+   return octets_[9] > 127;   //-- octet 10
+}
+
+TDynamicTime
+Section1_preEd4::date()
+{
+   //-- octet 13=year, 14=month, etc.
+   return TDynamicTime( octets_[12], octets_[13], octets_[14], octets_[15], octets_[16] );
+}
+TDynamicTime
+Section1_Ed4::date()
+{
+   //-- octet 13=year, 14=month, etc.
+   return TDynamicTime( 256*octets_[15]+octets_[16], octets_[17], octets_[18]
+                  , octets_[19], octets_[20], octets_[21] );
+}
+
+int
+Section1_preEd4::msgType()
+{
+   return octets_[8];         //-- octet 9 in ed.3
+}
+int
+Section1_Ed4::msgType()
+{
+   return octets_[10];         //-- octet 11 in ed.4
+}
+
+int
+Section1_preEd4::msgSubtypeWMO()
+{
+   return cOctetMissingIndicator; //-- not available in ed.3
+}
+int
+Section1_Ed4::msgSubtypeWMO()
+{
+   return octets_[11];         //-- octet 12 in ed.4
+}
+
+int
+Section1_preEd4::msgSubtypeLocal()
+{
+   return octets_[9];         //-- octet 10 in ed.3
+}
+int
+Section1_Ed4::msgSubtypeLocal()
+{
+   return octets_[12];         //-- octet 13 in ed.4
+}
+
+int
+Section1_preEd4::msgSubtype()
+{
+   return msgSubtypeLocal();  //-- only local available in ed.3
+}
+int
+Section1_Ed4::msgSubtype()
+{
+   //-- WMO subtype is the preferred one
+   return msgSubtypeWMO() != cOctetMissingIndicator ? msgSubtypeWMO() : msgSubtypeLocal();
+}
+
+int
+Section1_preEd4::origCentre()
+{
+  return octets_[5]; //-- octet 6
+}
+int
+Section1_Ed4::origCentre()
+{
+   return 256*octets_[4] + octets_[5]; //-- octets 5 and 6
+}
+
+int
+Section1_preEd4::origSubCentre()
+{
+  return octets_[4]; //-- octet 5
+}
+int
+Section1_Ed4::origSubCentre()
+{
+   return 256*octets_[6] + octets_[7]; //-- octets 7 and 8
+}
+
+int
+Section1_preEd4::masterTable()
+{
+   return octets_[3];         //-- octet 4
+}
+int
+Section1_Ed4::masterTable()
+{
+   return octets_[3]; //-- octet 4
+}
+
+int
+Section1_preEd4::masterTableVersion()
+{
+   return octets_[10];         //-- octet 11
+}
+int
+Section1_Ed4::masterTableVersion()
+{
+   return octets_[13]; //-- octet 14
+}
+
+int
+Section1_preEd4::localTableVersion()
+{
+   return octets_[11];         //-- octet 12
+}
+int
+Section1_Ed4::localTableVersion()
+{
+   return octets_[14]; //-- octet 15
+}
+
+
+
+//====================================================================== MvBufrBase
+//______________________________________________________________________
+
+MvBufrBase :: MvBufrBase( const long len ) : Sec1(NULL),fSec2(NULL),fTotalSec2(NULL),fSec3(NULL),fSec4(NULL)
+{
+  _refCount = 0;
+
+  // Make sure the data is correctly aligned.
+  longptr = new long[(len/sizeof(long)) + 1];
+  fMessage = (char *)longptr;
+  //fMessage = new char[ len  + 8 ];    // +8 for an extra "safety word"
+  fMessageLength = len;
+
+  fKSUP  = NULL;
+  fKSEC0 = NULL;
+  fKSEC1 = NULL;
+  fKSEC2 = NULL;
+  fKSEC3 = NULL;
+  fKSEC4 = NULL;
+
+      //-- lazy evaluation: create static arrays when first needed --
+  createDataArrays ();
+    }
+//___________________________________________________________
+
+MvBufrBase :: ~MvBufrBase( void )
+{
+//  delete [] fMessage;
+  delete [] longptr;
+
+  if( fSec2 )
+  {
+    delete fSec2;
+    delete [] fTotalSec2;
+  }
+  delete fSec3;
+  delete fSec4;
+
+  fSec2 = 0;
+  fSec3 = 0;
+  fSec4 = 0;
+  fTotalSec2 = 0;
+
+  if( fKSUP ) delete [] fKSUP;
+  if( fKSEC0 ) delete [] fKSEC0;
+  if( fKSEC1 ) delete [] fKSEC1;
+  if( fKSEC2 ) delete [] fKSEC2;
+  if( fKSEC3 ) delete [] fKSEC3;
+  if( fKSEC4 ) delete [] fKSEC4;
+
+  fKSUP = fKSEC0 = fKSEC1 = fKSEC2 = fKSEC3 = fKSEC4 = 0;
+}
+//___________________________________________________________
+void
+MvBufrBase :: attach( void )
+{
+   _refCount++;
+}
+void
+MvBufrBase :: detach( void )
+{
+   if( --_refCount == 0 )
+     delete this;
+}
+//_________________________________________________________ createFortranArrays
+void
+MvBufrBase :: createFortranArrays( void )
+{
+  fKSUP  = new fortint[  9 ];
+  fKSEC0 = new fortint[  3 ];
+  fKSEC1 = new fortint[ 40 ];
+  fKSEC2 = new fortint[ 4096 ]; //[ 128 ]; //[ 64 ];
+  fKSEC3 = new fortint[  4 ];
+  fKSEC4 = new fortint[  2 ];
+}
+//_________________________________________________________ createDataArrays
+void
+MvBufrBase :: createDataArrays( void )
+{
+    kVals    = aMAX_KVALS[arraySizeIndex];
+    In_KVALS = kVals;
+
+    try
+    {
+        if( In_VALUES == 0 )
+            In_VALUES = new fortfloat[ kVals ];
+
+        if( In_CVALS == 0 )
+            In_CVALS = new char[ kVals * 80 ];
+
+        if( In_CNAMES == 0 )
+            In_CNAMES = new char[ MAX_KELEM * 64 ];
+
+        if( In_CUNITS == 0 )
+            In_CUNITS = new char [ MAX_KELEM * 24 ];
+
+        if( In_KTDEXP == 0 )
+            In_KTDEXP = new fortint[ MAX_KELEM ];
+
+        if( In_KTDLST == 0 )
+            In_KTDLST = new fortint[ MAX_KELEM ];
+    }
+
+    catch(...)
+    {
+        deleteDataArrays ();
+
+#ifdef METVIEW
+        marslog( LOG_EROR, "MvBufrBase::MvBufrBase: out-of-memory!" );
+        throw MvException( "MvBufrBase::MvBufrBase: out-of-memory!" );
+#else
+        cerr << ">>>> MvBufrBase::MvBufrBase: out-of-memory => throw an exception <<<<" << endl;
+        throw std::bad_alloc();
+#endif
+    }
+}
+//_________________________________________________________ createDataArrays
+void
+MvBufrBase :: deleteDataArrays( void )
+{
+    if( In_VALUES != 0 )
+    {
+        delete [] In_VALUES; In_VALUES = 0;
+    }
+
+    if( In_CVALS != 0 )
+    {
+        delete [] In_CVALS;  In_CVALS  = 0;
+    }
+
+    if( In_CNAMES != 0 )
+    {
+        delete [] In_CNAMES; In_CNAMES = 0;
+    }
+
+    if( In_CUNITS != 0 )
+    {
+        delete [] In_CUNITS; In_CUNITS = 0;
+    }
+
+    if( In_KTDEXP != 0 )
+    {
+        delete [] In_KTDEXP; In_KTDEXP = 0;
+    }
+
+    if( In_KTDLST != 0 )
+    {
+        delete [] In_KTDLST; In_KTDLST = 0;
+    }
+}
+//___________________________________________________________
+unsigned int
+MvBufrBase :: unsignedInt( const unsigned char* firstOctet
+                         , int octetCount )
+{
+  unsigned int value = *firstOctet;
+  const unsigned char* anOctet = ++firstOctet;
+  for( int i=octetCount-1; i; --i )
+  {
+    value = 256*value + *anOctet++;
+  }
+  return value;
+}
+
+//______________________________________________________________________
+//====================================================================== MvBufr
+//______________________________________________________________________
+
+//______________________________________________________________________
+
+MvBufr :: MvBufr( char *msg, long len, long aMessageNumber )
+    : MvBufrBase( len )   //( msg, len )
+{
+  _lastKnownSubsetValue = 1; //-- Q&D
+
+  memcpy( fMessage, msg, (int)len );
+
+  const unsigned char* msgStart = (const unsigned char*)fMessage;
+
+  fSec0 = (TSection0 *)fMessage;
+  int offSet = fSec0->editionNr < 2 ? 4 : 8;
+                        // Section 0 was shorter in BUFR editions 0 and 1 !!!!
+                        //                                  rev vk 950802
+  if( fSec0->editionNr > 3 )
+    Sec1 = new Section1_Ed4( msgStart + offSet );
+  else
+    Sec1 = new Section1_preEd4( msgStart + offSet );
+  offSet += Sec1->len();
+
+  if( Sec1->hasSection2() )         // bit 0 <=> Optional Section 2 present?
+  {
+    fSec2 = new TSection2;
+    memcpy( (char *)fSec2, msgStart + offSet, sizeof(TSection2)  );
+
+    int sec2Len = unsignedInt( &(fSec2->len), 3 );
+    fTotalSec2 = new unsigned char[ sec2Len ];
+    memcpy( (char *)fTotalSec2, msgStart + offSet, sec2Len );
+
+    offSet += sec2Len;
+  }
+  else
+  {
+    fSec2 = NULL;
+    fTotalSec2 = NULL;
+  }
+
+  fSec3 = new TSection3;
+  memcpy( (char *)fSec3, msgStart + offSet, sizeof(TSection3)  );
+  offSet += unsignedInt( &(fSec3->len), 3 );
+
+  fSec4 = new TSection4;
+  memcpy( (char *)fSec4, msgStart + offSet, sizeof(TSection4)  );
+  offSet += unsignedInt( &(fSec4->len), 3 );
+
+  computeIn_KELEM ();
+
+  fMessageNumber = aMessageNumber;
+  _currentDescr = 0;
+  _currentDescrInd = -1;
+  _inState = kBufrIn_Coded;
+  _bufrIn_ref++;
+  _bufrBoxFilledSubset = 0;
+}
+//______________________________________________________________________
+
+MvBufr :: ~MvBufr( void ) { }
+
+//____________________________________________________________________ Decode
+void
+MvBufr :: Decode( void )
+{
+   if( _inState == kBufrIn_Error )
+      return;
+
+   if( _inState < kBufrIn_DataDecoded )
+   {
+      createFortranArrays();
+      fortint myKBUFL = fMessageLength / sizeof(fortint) + 1;  // +1 = Q&D
+        bool keepGoing = true;
+
+        // we will try to decode the BUFR a number of times, starting with
+        // relatively small data arrays, then building up to larger ones
+        // (so that we don't waste too much memory)
+
+        while (keepGoing)
+        {
+            keepGoing = false;
+
+      BUFREX(&myKBUFL
+	    , (fortint *)fMessage  // buffer for the BUFR message
+	    , fKSUP          // array for suplementary info
+	    , fKSEC0         // FORTRANized section 0
+	    , fKSEC1         // FORTRANized section 1
+	    , fKSEC2         // FORTRANized section 2 (site dependent)
+	    , fKSEC3         // FORTRANized section 3 (data descriptors)
+	    , fKSEC4         // FORTRANized section 4 (data values)
+	    ,&In_KELEM
+	    , In_CNAMES
+	    , In_CUNITS
+	    ,&In_KVALS
+	    , In_VALUES
+	    , In_CVALS
+	    ,&fKERR );
+
+
+            // if KELEM is not big enough, then we will
+            // try again with a bigger value
+
+            if( fKERR == 25 || fKERR == 14)
+            {
+                cout << "MvBufr :: Decode - kVals of " << kVals << " and In_KELEM of " << In_KELEM
+                     << " is not large enough." << endl;
+
+                if (++arraySizeIndex < NUM_MAX_KVALS)
+                {
+                    cout << "Trying kVals of " << aMAX_KVALS[arraySizeIndex] <<
+                         " (" << (aMAX_KVALS[arraySizeIndex] * 80) / (1024*1024) << "MB)" << endl;
+
+                    deleteDataArrays ();
+                    createDataArrays ();
+                    computeIn_KELEM ();
+
+                    keepGoing = true;
+                }
+                else
+                    arraySizeIndex = NUM_MAX_KVALS - 1; // should not be used, but just in case,
+                                                        // make sure the index is not out of bounds...
+            }
+        }
+
+
+      if( fKERR )
+      {
+	 cerr << "In_KELEM " << In_KELEM << " kvals " << In_KVALS << endl;
+	 cerr << " >>> MvBufr::Decode, bufrmsg " << fMessageNumber
+	      << ": fKERR = " << fKERR << endl;
+
+
+#ifdef METVIEW
+	 marslog(LOG_EROR, "BUFR decoding (BUFREX) failed, status = %d", fKERR );
+	 stringstream sst;
+	 sst << "Unable to decode BUFR message \nBUFR decoding (BUFREX) failed, status =" << fKERR;
+	 throw MvException(sst.str().c_str());
+
+#endif
+	 _inState = kBufrIn_Error;
+	 return;
+      }
+
+      _inState = kBufrIn_DataDecoded;
+   }
+}
+
+//____________________________________________________________________ Decode
+void
+MvBufr :: Decode_012( void )
+{
+   if( _inState == kBufrIn_Error )
+      return;
+
+   if( _inState < kBufrIn_Sections012Expanded)
+   {
+      createFortranArrays();
+      fortint myKBUFL = fMessageLength / sizeof(fortint) + 1;  // +1 = Q&D
+
+      BUS012(&myKBUFL
+	    , (fortint *)fMessage  // buffer for the BUFR message
+	    , fKSUP          // array for suplementary info
+	    , fKSEC0         // FORTRANized section 0
+	    , fKSEC1         // FORTRANized section 1
+	    , fKSEC2         // FORTRANized section 2 (site dependent)
+	    ,&fKERR );
+
+
+
+      if( fKERR )
+      {
+
+	 cerr << " >>> MvBufr::Decode_012, bufrmsg " << fMessageNumber
+	      << ": fKERR = " << fKERR << endl;
+
+#ifdef METVIEW
+	 marslog( LOG_EROR, "BUFR decoding (BUFREX) failed, status = %d", fKERR );
+	 stringstream sst;
+	 sst << "Unable to decode BUFR message \nBUFR decoding (BUFREX) failed, status =" << fKERR;
+	 throw MvException(sst.str().c_str());
+#endif
+	 _inState = kBufrIn_Error;
+	 return;
+      }
+
+      _inState = kBufrIn_Sections012Expanded;
+   }
+}
+
+//___________________________________________________________________ ExpandDescriptors
+void
+MvBufr :: ExpandDescriptors( int subsetNumber )
+{
+  static int mySubsetSavedValue = 0;
+
+   _lastKnownSubsetValue = subsetNumber;
+
+   if( _inState == kBufrIn_Error )
+      return;
+
+//   In_KTDLEN = -1;
+//   In_KTDEXL = -1;
+   fKERR     =  0;
+
+   if( _inState < kBufrIn_DataDecoded )
+      Decode();
+
+   if( ( fKSEC3[3-1] > 1  &&                           //-- if several subsets
+        _lastKnownSubsetValue != mySubsetSavedValue )  //-- AND subset number changed
+                      ||                               //-- OR
+        _inState == kBufrIn_DataDecoded  )             //-- descriptors not yet expanded
+   {
+//cout << "-----> MvBufr::ExpandDescriptors(" << _lastKnownSubsetValue << ") => BUSEL2..." << endl;
+//      CALL BUSEL2(KSUBSET,KELEM,KTDLEN,KTDLST,KTDEXL,KTDEXP,CNAMES,CUNITS,KERR)
+         BUSEL2( &_lastKnownSubsetValue  //-- Q&D variable...
+               , &In_KELEM
+               , &In_KTDLEN      // nr of original data descriptors in Section 3
+               ,  In_KTDLST      // original descriptors
+               , &In_KTDEXL      // nr of expanded data descriptors
+               ,  In_KTDEXP      // expanded descriptors
+               ,  In_CNAMES
+               ,  In_CUNITS
+               , &fKERR
+               );
+
+         mySubsetSavedValue = _lastKnownSubsetValue;
+   }
+   else
+   {
+      if( _inState == kBufrIn_DataDecoded )
+      {
+//cout << "-----> MvBufr::ExpandDescriptors(" << _lastKnownSubsetValue << ") => BUSEL..." << endl;
+         BUSEL( &In_KTDLEN      // nr of original data descriptors in Section 3
+	      ,  In_KTDLST      // original descriptors
+	      , &In_KTDEXL      // nr of expanded data descriptors
+	      ,  In_KTDEXP      // expanded descriptors
+	      , &fKERR
+              );
+      }
+   }
+
+   if( fKERR )
+   {
+      cerr << " >>> MvBufr::ExpandDescriptors: fKERR = " << fKERR << endl;
+
+#ifdef METVIEW
+      marslog( LOG_EROR, "BUFR expansion (BUSEL) failed, status = %d", fKERR );
+#endif
+
+      _inState = kBufrIn_Error;
+   }
+   else
+      _inState = kBufrIn_DataAndDescriptorsDecoded;
+}
+//__________________________________________________________ descriptorToFortranIndex
+int
+MvBufr :: descriptorToFortranIndex( const long aDescr, const int firstIndex )
+{
+   if( _inState == kBufrIn_Error )
+      return -1;
+
+   if( _inState != kBufrIn_DataAndDescriptorsDecoded )
+      ExpandDescriptors( _lastKnownSubsetValue ); //-- Q&D
+
+   if( _inState == kBufrIn_DataAndDescriptorsDecoded )
+   {
+      for( int i=firstIndex; i < In_KTDEXL; i++ )
+      {
+	 if( In_KTDEXP[ i ] == aDescr )
+         {
+	   return i;
+         }
+      }
+   }
+   return -1;
+}
+//__________________________________________________________ computeIn_KELEM
+void
+MvBufr :: computeIn_KELEM( void )
+{
+    if ( subsetCount() > 1 )
+        In_KELEM = kVals / subsetCount();
+    else
+        In_KELEM = MAX_KELEM;
+
+    if( In_KELEM > MAX_BUBOX_KELEM_LIMIT )
+        In_KELEM = MAX_BUBOX_KELEM_LIMIT;
+}
+//__________________________________________________________ DataValue
+//
+// Returns the requested parameter value (or missing value)
+// and updates _currentDescrInd.
+//
+
+fortfloat
+MvBufr :: DataValue( const int aDescrArrayInd, const long aSubsetNumber )
+{
+   _lastKnownSubsetValue = aSubsetNumber;
+
+   if( _inState < kBufrIn_DataDecoded )
+      Decode();
+
+   if( ( aSubsetNumber > subsetCount() ) || ( aDescrArrayInd < 0 ) )
+   {
+      _currentDescr = 0;
+      _currentDescrInd = -1;
+      return kFortranBufrMissingValue;
+   }
+
+   _currentDescrInd = aDescrArrayInd;
+   _currentDescr = In_KTDEXP[ _currentDescrInd ];
+
+   return PeekDataValue( _currentDescrInd, aSubsetNumber );
+}
+//__________________________________________________________ PeekDataValue
+//
+// Returns the requested parameter value (or missing value)
+// without updating _currentDescrInd.
+//
+
+fortfloat
+MvBufr :: PeekDataValue( const int aDescrArrayInd, const long aSubsetNumber )
+{
+   if( ( aSubsetNumber > subsetCount() ) || ( aDescrArrayInd < 0 ) )
+     return kFortranBufrMissingValue;
+   else
+     return In_VALUES[ aDescrArrayInd + ( aSubsetNumber - 1 ) * In_KELEM ];
+}
+//__________________________________________________________ Value
+boolean
+MvBufr :: Value( const long aDescriptor
+	       , const long aSubsetNumber
+	       , fortfloat &aDataValue
+	       , int   firstInd )
+{
+  aDataValue = DataValue( descriptorToFortranIndex( aDescriptor, firstInd )
+			, aSubsetNumber );
+  return aDataValue != kFortranBufrMissingValue ? true : false;
+}
+//__________________________________________________________ intValue
+// returns 'kFortranBufrMissingIntValue' if not found!
+//----------------------------------------------------
+long
+MvBufr :: intValue( const long aDescriptor, const int subsetNr )
+{
+   fortfloat myValue;
+   Value( aDescriptor, subsetNr, myValue );
+
+   if( myValue != kFortranBufrMissingValue )
+     return (long)myValue;
+   else
+     return kFortranBufrMissingIntValue;
+}
+//____________________________________________________________________ feedbackValue
+double
+MvBufr::feedbackValue( int col, int subset )
+{
+   if( _currentDescrInd < 0 )
+      return kBufrMissingValue;
+   else
+      //-- first 6 rows is reserved info, obs report starts on row 7
+      return feedbackValue( _currentDescrInd + 6, col, subset );
+}
+
+double
+MvBufr::feedbackValue( int row, int col, int subset )
+{
+   int err = fillBufrBox( subset );
+
+   assert( row > 0 && row <= myKBOX );
+   assert( col > 0 && col <= myKAPP );
+
+   if( err == 0 )
+      return myVALS[ myKLEN*(col-1) + row - 1 ];
+   else
+      return kBufrMissingValue;
+}
+
+string
+MvBufr::feedbackItemName( int row, int subset )
+{
+   int err = fillBufrBox( subset );
+
+   assert( row > 0 && row <= myKBOX );
+
+   if( err == 0 )
+   {
+      char c[64];
+      strncpy(c,myCBOXN+(row-1)*64,63);
+      c[63]='\0';
+      string s(c);
+      eraseWhiteSpaceFromStringEnd(s);
+      return s;
+   }
+   else
+      return std::string();
+}
+
+string
+MvBufr::feedbackItemUnit( int row, int subset )
+{
+   int err = fillBufrBox( subset );
+
+   assert( row > 0 && row <= myKBOX );;
+
+   if( err == 0 )
+   {
+      char c[24];
+      strncpy(c,myCBOXU+(row-1)*24,23);
+      c[23]='\0';
+      string s(c);
+      eraseWhiteSpaceFromStringEnd(s);
+      return s;
+   }
+   else
+      return std::string();
+}
+
+//____________________________________________________________________ obsTime
+TDynamicTime
+MvBufr :: obsTime( const int subsetNr )
+{
+   fortint myYear  = intValue( 4001L, subsetNr );
+   fortint myMonth = intValue( 4002L, subsetNr );
+   fortint myDay   = intValue( 4003L, subsetNr );
+   fortint myHour  = intValue( 4004L, subsetNr );
+
+   short myMin, mySec;
+   fortfloat myValue;
+
+   if( Value( 4005L, subsetNr, myValue ) )
+      myMin = (short)myValue;
+   else
+      myMin = 0;
+
+   if( Value( 4006L, subsetNr, myValue ) )
+      mySec = (short)myValue;
+   else
+      mySec = 0;
+
+   //-- quirky NCEP PrepBUFR obs may not contain date/time infromation
+   if( myYear  == kBufrMissingIntValue &&   //-- date OK?
+       myMonth == kBufrMissingIntValue &&
+       myDay   == kBufrMissingIntValue  )
+   {                                        //-- if date missing from obs
+      return msgTime();                     //-- then take it from section 1
+   }
+   else                                     //-- OK, take from obs
+   {
+      return TDynamicTime( (short)myYear, (short)myMonth, (short)myDay
+                         , (short)myHour, myMin, mySec );
+   }
+}
+//____________________________________________________________________ msgTime
+TDynamicTime
+MvBufr :: msgTime( void )
+{
+#if 0
+   short myYear  = fSec1->yearYY ;
+   short myMonth = fSec1->month ;
+   short myDay   = fSec1->day ;
+   short myHour  = fSec1->hour ;
+   short myMin   = fSec1->minute ;
+
+   return TDynamicTime( myYear, myMonth, myDay, myHour, myMin, 0 );
+#endif
+
+   return Sec1->date();
+}
+//____________________________________________________________________ stringValue
+string
+MvBufr :: stringValue( const long aDescriptor, const int aSubsetNr )
+{
+   _currentDescrInd = descriptorToFortranIndex( aDescriptor );
+   return stringValueByIndex( _currentDescrInd, aSubsetNr );
+}
+//____________________________________________________________________ stringValue
+string
+MvBufr :: stringValue( const int aSubsetNr )
+{
+   return stringValueByIndex( _currentDescrInd, aSubsetNr );
+}
+//__________________________________________________________ stringValueByIndex
+string
+MvBufr :: stringValueByIndex( const int anIndex, const int aSubsetNr )
+{
+   if( ( anIndex < 0 ) || ( anIndex >= In_KTDEXL ) )
+     {
+       return string( "[string index error!]" );
+     }
+
+   //-- get coded float value --
+   fortfloat myValue = DataValue( anIndex, aSubsetNr );
+
+   //-- here we should be passing subset nr, not index!!! (020307/vk)
+   //-- thus always pass 1:
+
+   if( elementValueType( 1 ) == kEVT_missing )
+     {
+	   return string( "[Missing]" );
+     }
+   else if( elementValueType( 1 ) == kEVT_string )
+     {
+       //-- get pointer and length to In_CVALS array, In_CVALS starts from 0.. --
+       int myIndex = (int)myValue / 1000 - 1;
+       int myLength = (int)myValue % 1000;
+
+       //-- add C-terminator (sacrifice last character if necessary) --
+       int terminatorPos = myLength;
+       if( terminatorPos > 79 )
+	 terminatorPos = 79;
+       //In_CVALS[ myIndex ][ terminatorPos ] = '\0';
+       In_CVALS[ myIndex*80 + terminatorPos ] = '\0';
+
+       return string(In_CVALS + myIndex*80);
+     }
+   else if( elementValueType( 1 ) == kEVT_numeric )
+     {
+       ostringstream oss;
+       oss << myValue;
+
+       return oss.str();
+     }
+
+   return string( "[Internal error]" ); //-- we should never get here!
+}
+//____________________________________________________________________ unit
+string
+MvBufr :: unit( const long aDescriptor )
+{
+   return unitByIndex( descriptorToFortranIndex( aDescriptor ) );
+}
+//____________________________________________________________________ unit
+string
+MvBufr :: unit( void )
+{
+   return unitByIndex( _currentDescrInd );
+}
+//____________________________________________________________________ unitByIndex
+string
+MvBufr :: unitByIndex( const int anIndex )
+{
+   char strbuf[ 25 ];
+
+   if( ( anIndex >= 0 ) && ( anIndex < In_KTDEXL ) )
+   {
+      strbuf[ 24 ] = '\0';               //-- make a copy
+      int pos;
+      for( pos=23; pos>=0; --pos )
+         strbuf[ pos ] = In_CUNITS[ anIndex*24 + pos ];
+         //strbuf[ pos ] = In_CUNITS[ anIndex ][ pos ];
+
+      for( pos=23; pos > 0; pos-- )      //-- remove trailing blanks
+         if( strbuf[ pos ] == ' ' )
+            strbuf[ pos ] = '\0';
+         else
+            break;
+
+      return string( strbuf );
+   }
+   return string( "[Unit not found!]" );
+}
+//____________________________________________________________________ name
+string
+MvBufr :: name( const long aDescriptor )
+{
+   return nameByIndex( descriptorToFortranIndex( aDescriptor ) );
+}
+//____________________________________________________________________ name
+string
+MvBufr :: name( void )
+{
+   return nameByIndex( _currentDescrInd );
+}
+//____________________________________________________________________ nameByIndex
+string
+MvBufr :: nameByIndex( const int anIndex )
+{
+   char strbuf[ 65 ];
+
+   if( ( anIndex >= 0 ) && ( anIndex < In_KTDEXL ) )
+   {
+      strbuf[ 64 ] = '\0';               //-- make copy
+      int pos;
+      for( pos=63; pos>=0; --pos )
+         strbuf[ pos ] = In_CNAMES[ anIndex*64 + pos ];
+        // strbuf[ pos ] = In_CNAMES[ anIndex ][ pos ];
+
+      for( pos=63; pos > 0; pos-- )      //-- remove trailing blanks
+         if( strbuf[ pos ] == ' ' )
+            strbuf[ pos ] = '\0';
+         else
+            break;
+
+      boolean retainCapital = true;      //-- change to lower case
+      for( pos = 0; pos < (int)(strlen( strbuf )); pos++ )
+      {
+         if( isupper( strbuf[ pos ] ) )
+         {
+            if( retainCapital )
+               retainCapital = false;
+            else
+               strbuf[ pos ] = tolower( strbuf[ pos ] );
+          }
+          else
+             retainCapital = true;
+      }
+      return string( strbuf );
+   }
+   else
+      return string( "[Name index error!]" );
+}
+//____________________________________________________________________ elementValueType
+EElementValueType
+MvBufr :: elementValueType( const int aSubsetNr )
+{
+  return elementValueTypeByIndex( _currentDescrInd, aSubsetNr );
+}
+//____________________________________________________________ elementValueType
+EElementValueType
+MvBufr :: elementValueType( const long aDescriptor, const int aSubsetNr )
+{
+  return elementValueTypeByIndex( descriptorToFortranIndex( aDescriptor ), aSubsetNr );
+}
+//_____________________________________________________ elementValueTypeByIndex
+EElementValueType
+MvBufr :: elementValueTypeByIndex( const int anIndex, const int aSubsetNr )
+{
+  fortfloat myValue = DataValue( anIndex, aSubsetNr );
+
+  if( myValue == kFortranBufrMissingValue )
+  {
+    return kEVT_missing;
+  }
+  else
+  {
+    bool isString = unitByIndex( anIndex ) == "CCITTIA5"   //-- ECMWF notation
+                 || unitByIndex( anIndex ) == "CCITT IA5"; //-- WMO & NCEP PrepBUFR notation
+    return isString ? kEVT_string : kEVT_numeric;
+  }
+}
+//______________________________________________________________________
+//
+// Reset descriptor iterator by pointing to the first descriptor.
+// Make sure msg has been expanded!
+//
+
+boolean
+MvBufr :: SetFirstDescriptor( void )
+{
+   if( _inState == kBufrIn_Error )
+      return false;
+
+   if( _inState != kBufrIn_DataAndDescriptorsDecoded )
+      ExpandDescriptors( _lastKnownSubsetValue ); //-- Q&D
+
+   if( _inState == kBufrIn_DataAndDescriptorsDecoded )
+   {
+      _currentDescrInd = 0;
+      _currentDescr = In_KTDEXP[ _currentDescrInd ];
+      return true;
+   }
+   return false;
+}
+//______________________________________________________________________
+//
+// Advance descriptor iterator.
+// Check that it still points ok.
+//
+
+boolean
+MvBufr :: SetNextDescriptor( void )
+{
+  if( _currentDescrInd < 0 )
+     return false;           // SetFirstDescriptor had not been called !
+
+  _currentDescrInd++;
+  if( _currentDescrInd == In_KTDEXL ) // or: fKSUP[ 5 - 1 ]
+  {
+     _currentDescrInd = -1;               //-- end-of-msg reached
+     _currentDescr = 0;                   //-- probably end-of-iteration => issue no msg
+     return false;
+  }
+  else if( _currentDescrInd > In_KTDEXL )
+  {
+     _currentDescrInd = -1;               //-- past end-of-msg
+     _currentDescr = 0;                   //-- must be an error => issue error msg
+
+    cerr << "MvBufr::SetNextDescriptor: _currentDescrInd=" << _currentDescrInd
+         << ", limiting In_KTDEXL=" << In_KTDEXL << endl;
+
+     return false;
+  }
+
+  _currentDescr = In_KTDEXP[ _currentDescrInd ];
+  return true;
+}
+//______________________________________________________________________
+//
+// calls Emoslib routines BUBOX and BUPRTBOX to produce "boxed" output
+//
+int
+MvBufr::fillBufrBox( int aSubsetNr )
+{
+#if 0
+  //-- Linux/g++ does not like hardcoded big? arrays (works ok in debugger,
+  //-- but crashes inside Metview...) => create arrays dynamically, once!
+
+  static fortint    myKSUB, myKBOX, myKAPP, myKLEN, myKERR;
+  static fortint*   myKBOXR = 0;
+  static fortfloat* myVALS  = 0;
+  static char*      myCBOXN = 0;
+  static char*      myCBOXU = 0;
+#endif
+
+  if( _bufrBoxFilledSubset == aSubsetNr )
+     return 0;                               //-- OK, already filled
+
+  if( ! myKBOXR )
+    {
+      try
+	{
+	  myKBOXR = new fortint[ kVals ];
+	  cout << " fillBufrBox: array myKBOXR created" << endl;
+
+	  myVALS  = new fortfloat[ kVals ];
+	  cout << " fillBufrBox: array myVALS  created" << endl;
+
+	  myCBOXN = new char[ kVals * 64 ];
+	  cout << " fillBufrBox: array myCBOXN created" << endl;
+
+	  myCBOXU = new char[ kVals * 24 ];
+	  cout << " fillBufrBox: array myCBOXU created" << endl;
+	}
+      catch(...)
+	{
+	  cout << " >>> fillBufrBox: problems in creating fort arrays <<<" << endl;
+	  delete myKBOXR;  myKBOXR = 0;
+	  delete myVALS;   myVALS  = 0;
+	  delete myCBOXN;  myCBOXN = 0;
+	  delete myCBOXU;  myCBOXU = 0;
+#ifdef METVIEW
+	  marslog( LOG_EROR, "MvBufr::fillBufrBox: out-of-memory?" );
+#endif
+	  return -13;
+	}
+    }
+
+
+  //-- Initialize array given to bubox. bubox will not initialize
+  //-- all values, and this will cause runtime error from buprtbox.
+  for (int i = 0; i < kVals; i++ )
+    myVALS[i] = kFortranBufrMissingValue;
+
+  if( _inState == kBufrIn_Error )
+    {
+      cout << " fillBufrBox: BUFR msg error state, return false" << endl;
+      return -1313;
+    }
+
+  if( _inState < kBufrIn_DataDecoded )
+    {
+      Decode();
+    }
+
+  if( _inState != kBufrIn_DataAndDescriptorsDecoded )
+    {
+      ExpandDescriptors( aSubsetNr );
+    }
+
+  myKSUB = (fortint)aSubsetNr;
+  myKBOX = 0;
+  myKAPP = 0;
+  myKLEN = 0;
+  myKERR = 0;
+
+  BUBOX( &myKSUB     //-- INPUT arguments
+       ,  fKSUP
+       , &In_KELEM
+       ,  In_KTDEXP
+       ,  In_CNAMES
+       ,  In_CUNITS
+       , &In_KVALS
+       ,  In_VALUES
+                      //-- OUTPUT arguments
+       , &myKBOX      //-- number of (valid) elements in 1st column
+       , &myKAPP      //-- number of columns (apps) in the box
+       , &myKLEN      //-- number of rows in the box
+       ,  myKBOXR     //-- Table B descriptors
+       ,  myVALS      //-- boxed values
+       ,  myCBOXN     //-- boxed element names
+       ,  myCBOXU     //-- boxed units
+       , &myKERR );
+
+  if( myKERR == 0 )
+      _bufrBoxFilledSubset = myKSUB;
+
+  return myKERR;
+}
+//______________________________________________________________________
+//
+bool
+MvBufr::writeBufrBox( int aSubsetNr )
+{
+  cout << " writeBufrBox: entering" << endl;
+
+  myKERR = fillBufrBox( aSubsetNr );
+
+  //-- forces Fortran unit 6 into a file
+  if( ! redirect_6(BBOXNAME.c_str()) )
+    {
+      cout << ">>> UNABLE TO REDIRECT stdout <<<" << endl;
+      return false;
+    }
+
+  if( myKERR == 0 )
+  {
+     BUPRTBOX(&myKBOX
+             ,&myKAPP
+             ,&myKLEN
+             , myKBOXR
+             , myVALS
+             , myCBOXN
+             , myCBOXU );
+  }
+
+  //-- closes "unit'ified" unit 6
+  if( ! reconnect_6() )
+    {
+      cerr << ">>> UNABLE TO RECONNECT TO stdout <<<" << endl;
+      cout << ">>> UNABLE TO RECONNECT TO stdout <<<" << endl;
+    }
+
+  return myKERR == 0;
+}
+
+bool
+MvBufr::getBufrBoxSize( int& rows, int& cols, int aSubsetNr )
+{
+  bool status = false;
+
+  myKERR = fillBufrBox( aSubsetNr );
+
+  if( myKERR == 0 )
+  {
+     rows = myKBOX;
+     cols = myKAPP;
+     status = true;
+  }
+  return status;
+}
+
+//------------- Printing functions -----------------
+bool
+MvBufr :: printSection( ostream& aStream,int which)
+{
+  boolean return_val = true;
+  if( _inState == kBufrIn_Error )
+    {
+      aStream << "!!!!!!!!!!! Bad BUFR message " << endl;
+      return false;
+    }
+
+  if ( _inState < kBufrIn_Sections012Expanded )
+    Decode();
+
+  if ( which == 3 && _inState < kBufrIn_DataAndDescriptorsDecoded )
+    ExpandDescriptors( _lastKnownSubsetValue ); //-- Q&D
+
+
+  char sec_name[30];
+  sprintf(sec_name,"prtsec%d.txt",which);
+
+  redirect_6(sec_name);
+  if ( which == 0 )
+    BUPRS0(fKSEC0);
+  else if ( which == 1 )
+    BUPRS1(fKSEC1);
+  else if ( which == 2 )
+    {
+      fortint *fKEY = new fortint[60];
+      BUUKEY(fKSEC1,fKSEC2,fKEY,fKSUP,&fKERR);
+      if ( fKERR )
+	cout << "\nProblems getting key. Maybe non-existent? " << endl;
+      else
+	BUPRS2(fKSUP,fKEY);
+
+      delete [] fKEY;
+    }
+  else
+    BUPRS3(fKSEC3,&In_KTDLEN,In_KTDLST,&In_KTDEXL,In_KTDEXP,&In_KELEM,In_CNAMES);
+
+  reconnect_6();
+  return_val = file_to_stream(sec_name,aStream,1);
+  delete_print_file(sec_name);
+  return return_val;
+}
+
+//------------- Printing functions -----------------
+bool
+MvBufr::getDataFromSection2(map<string,string> &data)
+{
+    bool retval=false;
+
+    if( _inState == kBufrIn_Error )
+    {
+      cout << "!!!!!!!!!!! Bad BUFR message " << endl;
+      return false;
+    }
+
+    if ( _inState < kBufrIn_Sections012Expanded )
+         Decode_012();
+
+      fortint *fKEY = new fortint[60];
+      BUUKEY(fKSEC1,fKSEC2,fKEY,fKSUP,&fKERR);
+      if ( fKERR )
+      {
+		cout << "\nProblems getting key. Maybe non-existent? " << endl;
+		retval=false;
+      }
+      else
+      {
+		parseSection2(fKEY,data);
+		retval=true;
+      }
+
+      delete [] fKEY;
+
+      return retval;
+}
+
+void MvBufr::parseSection2(fortint *fKEY,map<string,string> &data)
+{
+	//fKSUP - global variable
+
+	if(fKSUP[CIND(2)] < 1)
+	{
+		return;
+	}
+
+	int type=0;
+	if(fKEY[CIND(2)] == 2)
+		type = 2;
+	else if(fKEY[CIND(2)] == 3)
+		type = 2;
+	else if(fKEY[CIND(2)] == 12)
+		type = 2;
+	else if(fKEY[CIND(2)] == 8)
+		type = 2;
+
+	if(type == 0 && fKSUP [CIND(6)] > 1)
+		type = 2;
+
+	if(type == 2)
+	{
+		keyToStringMap(data,"RDB DATA TYPE",fKEY,2);
+		keyToStringMap(data,"RDB DATA SUBTYPE",fKEY,3);
+		keyToStringMap(data,"YEAR",fKEY,4);
+		keyToStringMap(data,"MONTH",fKEY,5);
+		keyToStringMap(data,"DAY",fKEY,6);
+		keyToStringMap(data,"HOUR",fKEY,7);
+		keyToStringMap(data,"MINUTE",fKEY,8);
+		keyToStringMap(data,"SECOND",fKEY,9);
+
+		float RLAT1=(fKEY[CIND(11)]-9000000)/100000.;
+         	float RLON1=(fKEY[CIND(10)]-18000000)/100000.;
+		keyToStringMap(data,"LATITUDE 1",RLAT1);
+		keyToStringMap(data,"LONGITUDE 1",RLON1);
+
+		float RLAT2=(fKEY[CIND(13)]-9000000)/100000.;
+         	float RLON2=(fKEY[CIND(12)]-18000000)/100000.;
+		keyToStringMap(data,"LATITUDE 2",RLAT2);
+		keyToStringMap(data,"LONGITUDE 2",RLON2);
+
+		keyToStringMap(data,"NUMBER OF OBSERVATIONS",fKEY,14);
+
+		//char ident[9];
+		//memcpy(ident,&fKEY[CIND(15)],8);
+		//data["IDENTIFIER"]=string(ident);
+
+		keyToStringMap(data,"IDENTIFIER",fKEY,15);
+		keyToStringMap(data,"TOTAL BUFR MESSAGE LENGTH",fKEY,25);
+		keyToStringMap(data,"DAY (RDB INSERTION)",fKEY,26);
+		keyToStringMap(data,"HOUR (RDB INSERTION)",fKEY,27);
+		keyToStringMap(data,"MINUTE (RDB INSERTION)",fKEY,28);
+		keyToStringMap(data,"SECOND (RDB INSERTION)",fKEY,29);
+		keyToStringMap(data,"DAY (MDB ARRIVAL)",fKEY,30);
+		keyToStringMap(data,"HOUR (MDB ARRIVAL)",fKEY,31);
+		keyToStringMap(data,"MINUTE (MDB ARRIVAL",fKEY,32);
+		keyToStringMap(data,"SECOND (MDB ARRIVAL)",fKEY,33);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,34);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,35);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,37);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,38);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,40);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,41);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,43);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,44);
+		keyToStringMap(data,"QUALITY CONTROL % CONF",fKEY,46);
+	}
+	else
+	{
+		keyToStringMap(data,"RDB DATA TYPE",fKEY,2);
+		keyToStringMap(data,"RDB DATA SUBTYPE",fKEY,3);
+		keyToStringMap(data,"YEAR",fKEY,4);
+		keyToStringMap(data,"MONTH",fKEY,5);
+		keyToStringMap(data,"DAY",fKEY,6);
+		keyToStringMap(data,"HOUR",fKEY,7);
+		keyToStringMap(data,"MINUTE",fKEY,8);
+		keyToStringMap(data,"SECOND",fKEY,9);
+
+		float RLAT1=(fKEY[CIND(11)]-9000000)/100000.;
+         	float RLON1=(fKEY[CIND(10)]-18000000)/100000.;
+		keyToStringMap(data,"LATITUDE 1",RLAT1);
+		keyToStringMap(data,"LONGITUDE 1",RLON1);
+
+		//char ident[9];
+		//memcpy(ident,&fKEY[CIND(15)],8);
+		//data["IDENTIFIER"]=string(ident);
+
+		char ident[10];
+		for(int i=16; i <=24; i++ )
+		{
+			ident[i-16]=fKEY[CIND(i)];
+		}
+		ident[9]='\0';
+		data["IDENTIFIER"]=string(ident);
+
+		keyToStringMap(data,"TOTAL BUFR MESSAGE LENGTH",fKEY,25);
+		keyToStringMap(data,"DAY (RDB INSERTION)",fKEY,26);
+		keyToStringMap(data,"HOUR (RDB INSERTION)",fKEY,27);
+		keyToStringMap(data,"MINUTE (RDB INSERTION)",fKEY,28);
+		keyToStringMap(data,"SECOND (RDB INSERTION)",fKEY,29);
+		keyToStringMap(data,"DAY (MDB ARRIVAL)",fKEY,30);
+		keyToStringMap(data,"HOUR (MDB ARRIVAL)",fKEY,31);
+		keyToStringMap(data,"MINUTE (MDB ARRIVAL",fKEY,32);
+		keyToStringMap(data,"SECOND (MDB ARRIVAL)",fKEY,33);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,34);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,35);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,37);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,38);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,40);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,41);
+		keyToStringMap(data,"CORRECTION NUMBER",fKEY,43);
+		keyToStringMap(data,"PART OF MESSAGE",fKEY,44);
+		keyToStringMap(data,"QUALITY CONTROL % CONF",fKEY,46);
+	}
+}
+
+
+
+
+
+
+//------------- Printing functions -----------------
+bool
+MvBufr :: printSection_012( ostream& aStream,int which)
+{
+  if(which <0 || which > 2)
+	return false;
+
+  boolean return_val = true;
+  if( _inState == kBufrIn_Error )
+    {
+      aStream << "!!!!!!!!!!! Bad BUFR message " << endl;
+      return false;
+    }
+
+  if ( _inState < kBufrIn_Sections012Expanded )
+    Decode_012();
+
+  char sec_name[30];
+  sprintf(sec_name,"prtsec%d.txt",which);
+
+  redirect_6(sec_name);
+  if ( which == 0 )
+    BUPRS0(fKSEC0);
+  else if ( which == 1 )
+    BUPRS1(fKSEC1);
+  else if ( which == 2 )
+    {
+      fortint *fKEY = new fortint[60];
+      BUUKEY(fKSEC1,fKSEC2,fKEY,fKSUP,&fKERR);
+      if ( fKERR )
+	cout << "\nProblems getting key. Maybe non-existent? " << endl;
+      else
+	BUPRS2(fKSUP,fKEY);
+
+      delete [] fKEY;
+    }
+
+  reconnect_6();
+  return_val = file_to_stream(sec_name,aStream,1);
+  delete_print_file(sec_name);
+  return return_val;
+}
+
+
+//______________________________________________________________________
+//====================================================================== MvBufrOut
+//______________________________________________________________________
+
+MvBufrOut::MvBufrOut( const long len, MvObsSet* aSet )  //( char *msg, long len, MvObsSet* aSet )
+    : MvBufrBase( len ), _currentSec1( 0 )
+{
+  _outSet = aSet;
+  _maxNrSubsets = 1;
+  Out_KELEM = -1;        // MAX_KELEM / _maxNrSubsets;
+
+  createFortranArrays();
+
+  _outState = kBufrOut_noBuffers;
+  resetBuffers();
+}
+//____________________________________________________________
+
+MvBufrOut :: ~MvBufrOut( void )
+{
+  if(   _outState == kBufrOut_dataInBuffers )
+  {
+    encode();
+  }
+  _outSet->close();
+  delete _currentSec1;
+}
+
+//____________________________________________________________________ createBuffers
+void
+MvBufrOut::createBuffers() // XXX still need more dynamic memory allocation
+{
+  Out_KTDEXL = -1;
+  Out_KELEM = -1;
+  _KDLEN = 0;
+  _nextValue = 0;
+  _nextCharParamPos = 0;
+
+  if( _outState == kBufrOut_noBuffers )
+    {
+      char cbuf[ 120 ];
+
+      try
+	{
+	  cout << "MvBufrOut::createBuffers, checking for memory..." << endl;
+
+	  sprintf( cbuf, "requesting %d new fortints", MAX_KELEM );
+	  cout << cbuf << endl;
+	  Out_KTDLST = new fortint[ MAX_KELEM ];
+
+	  sprintf( cbuf, "requesting %d new fortints", MAX_KELEM );
+	  cout << cbuf << endl;
+	  Out_KTDEXP = new fortint[ MAX_KELEM ];
+
+	  sprintf( cbuf, "requesting %d new fortfloats", MAX_KVALS );
+	  cout << cbuf << endl;
+	  Out_VALUES = new fortfloat[ MAX_KVALS ];
+
+	  sprintf( cbuf, "requesting %d new chars", 80*MAX_KVALS );
+	  cout << cbuf << endl;
+	  Out_CVALS = new char[ MAX_KVALS * 80 ];
+	}
+      catch(...)
+	{
+	  delete [] Out_VALUES; //-- (I)
+	  delete [] Out_CVALS;  //-- (II)
+	  delete [] Out_KTDEXP; //-- (III)
+
+	  Out_VALUES = 0;
+	  Out_CVALS  = 0;
+	  Out_KTDEXP = 0;
+	  Out_KTDLST = 0;
+
+	  _outState = kBufrOut_error;
+
+	  cout << ">>>\n>>> MvBufrOut::createBuffers failed in " << cbuf << "\n>>>" << endl;
+	  cout << "MvBufrOut::createBuffers: throw MvException..." << endl;
+#ifdef METVIEW
+	  marslog( LOG_EROR, "MvBufrOut::createBuffers failed in %s", cbuf );
+	  throw MvException( "MvBufrOut::createBuffers: out-of-memory!" );
+#else
+          throw std::bad_alloc();
+#endif
+	}
+    }
+
+  cout << "MvBufrOut::createBuffers memory ok" << endl;
+
+  _outState = kBufrOut_emptyBuffers;
+}
+//____________________________________________________________________ resetBuffers
+void
+MvBufrOut :: resetBuffers( void )
+{
+  Out_KTDEXL = -1;
+  Out_KELEM = -1;
+  _KDLEN = 0;
+  _nextValue = 0;
+  _nextCharParamPos = 0;
+
+  if( _outState > kBufrOut_emptyBuffers )
+    {
+      _outState = kBufrOut_emptyBuffers;
+    }
+}
+//____________________________________________________________________ write
+void
+MvBufrOut :: write( MvObs& anObs )
+{
+    //-- if no packing into subsets, copy message as is...
+    _outSet->write( anObs._bufrIn->fMessage, (int)anObs._bufrIn->fMessageLength );
+}
+
+//____________________________________________________________________ add
+void
+MvBufrOut :: add( MvObs& anObs )
+{
+  if( _maxNrSubsets == 1 && anObs._bufrIn->subsetCount() == 1 )
+    //-- if no packing into subsets, copy message as is...
+    write( anObs );
+  else
+    addIntoBuffers( anObs );
+}
+
+//____________________________________________________________________ addIntoBuffers
+void
+MvBufrOut::addIntoBuffers( MvObs& anObs )
+{
+  if( _outState <= kBufrOut_noBuffers )
+    {
+      createBuffers();
+    }
+
+  checkDescriptors( anObs );
+
+  if( MAX_KVALS < _nextValue + Out_KTDEXL )
+  {
+    encode();
+    formatBuffers( anObs );
+  }
+
+  //-- in case (non-compressed) multisubset msg, do expanded descriptors here
+  Out_KTDEXL = In_KTDEXL;             // expected nr of data values / expanded descriptors
+  for(int  i=0; i<In_KTDEXL; i++ )    // expanded descriptors
+    Out_KTDEXP[ i ] = In_KTDEXP[ i ]; // no offset
+
+  Out_KELEM = In_KTDEXL;  // In_KELEM;// expected nr of expanded elements (????)
+
+  int elemIndex = _nextValue;
+  for( int i = 0; i < Out_KTDEXL; i++, elemIndex++ )
+  {
+    Out_VALUES[ elemIndex ] = In_VALUES[ anObs.subsetOffset() + i ];
+
+    //-- character data..?
+    if( fKSUP[ 7-1 ] > 0  &&                                 //-- msg contains char data
+        ( strncmp( In_CUNITS + i*24, "CCITTIA5", 8 ) == 0 || //-- ECMWF notation
+          strncmp( In_CUNITS + i*24, "CCITT IA5", 9 ) == 0   //-- WMO & NCEP PrepBUFR notation
+        )
+       )
+    {
+      //-- copy character string value to next available slot --
+      int charInd = (int)Out_VALUES[ elemIndex ] / 1000 - 1;
+      int charLen = (int)Out_VALUES[ elemIndex ] % 1000;
+      strncpy( (Out_CVALS + _nextCharParamPos*80)
+	     , (In_CVALS + charInd*80)
+	     , charLen );
+
+      //-- set "pointer" to this slot --
+      Out_VALUES[ elemIndex ] = 1000*( _nextCharParamPos + 1 ) + charLen;
+      _nextCharParamPos++;
+    }
+    else  //-- if delayed replication factor...
+    {
+      if( isDelayedDescriptor( Out_KTDEXP[ i ] ) )
+      {
+//cerr << "isDelayedDescriptor( " << Out_KTDEXP[ i ] << "), _KDLEN=" << _KDLEN << endl;
+	if( _KDLEN < MAX_KDLEN )
+	{
+	  fortint delayedRepeat = (fortint)Out_VALUES[ elemIndex ];
+	  if( delayedRepeat < 0 )
+	  {
+	    cerr << ">>> MvBufrOut::add: data error - negative delayed repetition " << delayedRepeat
+	         << " (from element " << elemIndex << ")" << endl;
+#ifdef METVIEW
+	    marslog( LOG_EROR, "MvBufrOut::add: data error - negative delayed repetition!" );
+#endif
+	  }
+	  _KDATA[ _KDLEN ] = delayedRepeat;
+	  _KDLEN++;
+	}
+	else
+	  {
+	    cerr << ">>> MvBufrOut::add: array _KDATA overflow! _KDLEN=" << _KDLEN
+	         << ", MAX_KDLEN=" << MAX_KDLEN << endl;
+#ifdef METVIEW
+	    marslog( LOG_EROR, "MvBufrOut::add: array _KDATA overflow!" );
+#endif
+	  }
+      }
+    }
+  }
+  _nextValue += (int)Out_KELEM;
+
+  fKSEC3[ 2 ] += 1;  //-- Nr of Subsets
+  _outState = kBufrOut_dataInBuffers;
+
+  if( shouldBeWritten() )
+    encode();
+}
+//____________________________________________________________________ formatBuffers
+void
+MvBufrOut :: formatBuffers( const MvObs& anObs )
+{
+  delete _currentSec1;
+#if 0
+  _currentSec1 = new TSection1;
+  *_currentSec1 = *(anObs._bufrIn->Sec1);
+#endif
+  if( anObs._bufrIn->fSec0->editionNr > 3 )
+    _currentSec1 = new Section1_Ed4( anObs._bufrIn->Sec1 );
+  else
+    _currentSec1 = new Section1_preEd4( anObs._bufrIn->Sec1 );
+
+  int i;
+
+  fKSEC0[ 0 ] = 0;
+  for( i=1; i<3; i++)
+    fKSEC0[ i ] = anObs._bufrIn->fKSEC0[ i ];
+
+  // fKSEC1[ 0 ] = 0; // ??????????
+  for( i=0; i<40; i++)
+    fKSEC1[ i ] = anObs._bufrIn->fKSEC1[ i ];
+
+#if 0
+  int wmoi = BUFR_ORIGINATING_CENTER;
+  if( getenv( "WMO_SITE_NR" ) )
+    wmoi = atoi( getenv( "WMO_SITE_NR" ) );  //-- change WMO Centre Number if given
+
+  if( wmoi < 0 || wmoi > 255 )
+    wmoi = BUFR_ORIGINATING_CENTER;          //-- fall back to hard coded default
+
+  fKSEC1[ 2 ] = wmoi;                        //-- WMO Originating Centre
+#endif
+
+  fKSEC1[ 3 ] += 1;                          // increment Update Sequence Number!!
+  if( fKSEC1[ 4 ] > 127 )
+    fKSEC1[ 4 ] -= 128;                      // remove section 2 (which one to copy?)
+
+  fKSEC3[ 0 ] = 0;
+  for( i=1; i<4; i++)
+    fKSEC3[ i ] = anObs._bufrIn->fKSEC3[ i ];
+  fKSEC3[ 2 ] = 0;                           // reset nr of Subsets
+
+  fKSEC4[ 0 ] = 0;
+  for( i=1; i<2; i++)
+    fKSEC4[ i ] = anObs._bufrIn->fKSEC4[ i ];
+
+  Out_KTDLEN = In_KTDLEN;             // nr of original data descriptors in Sec 3
+  for( i=0; i<In_KTDLEN; i++ )        // packed descriptors
+    Out_KTDLST[ i ] = In_KTDLST[ i ];
+
+  //-- do this also later because with non-compressed multisubset msgs these vary
+  Out_KTDEXL = In_KTDEXL;             // expected nr of data values / expanded descriptors
+  for( i=0; i<In_KTDEXL; i++ )        // expanded descriptors
+    Out_KTDEXP[ i ] = In_KTDEXP[ i ]; // no offset
+
+  Out_KELEM = In_KTDEXL;  // In_KELEM;// expected nr of expanded elements (????)
+
+  _outState = kBufrOut_formatedBuffers;
+}
+//____________________________________________________________________ encode
+void
+MvBufrOut :: encode( void )
+{
+  if( _outState == kBufrOut_dataInBuffers )
+  {
+    fortint myKERR = 0;
+    fortint myKBUFL = 0;
+
+    BUFREN( fKSEC0, fKSEC1, fKSEC2, fKSEC3, fKSEC4
+	  , &Out_KTDLEN   // &fKTDEXL
+	  , Out_KTDLST    // fKTDEXP   // &fKTDLEN, fKTDLST
+	  , &_KDLEN
+	  , _KDATA
+	  , &Out_KELEM
+	  , &Out_KTDEXL   // was: fKVALS
+	  , Out_VALUES
+	  , Out_CVALS
+	  , &myKBUFL
+	  , (fortint *)fMessage
+	  , &myKERR );
+
+    if( myKERR == 0 )
+      _outSet->write( fMessage, (int)(myKBUFL*sizeof(fortint)) );
+    else
+      {
+	cerr << ">>> MvBufrOut::encode, KERR=" << myKERR << endl;
+#ifdef METVIEW
+	marslog( LOG_EROR, "BUFR encoding (BUFREN) failed, status = %d", myKERR );
+#endif
+      }
+
+    resetBuffers();
+  }
+}
+//_______________________________________________________________ checkDescriptors
+// checks descriptors and also header consistency i.e.
+// to make sure that the new obs fits into the current
+// multisubset message
+//---------------------------------------------------------------
+void
+MvBufrOut :: checkDescriptors( const MvObs& anObs )
+{
+//--  if( anObs._bufrIn->_inState != kBufrIn_DataAndDescriptorsDecoded )
+  //-- expand always, in case non-compressed multisubset msg where exaoanded descriptors vary
+  anObs._bufrIn->ExpandDescriptors( anObs.subsetNumber() );
+
+  if( _outState == kBufrOut_emptyBuffers )
+    formatBuffers( anObs );
+  else
+    if( differentDescriptors() || differentHeader( anObs ) )
+    {
+       encode();
+       formatBuffers( anObs );
+    }
+}
+
+//_______________________________________________________________ differentDescriptors
+// returns 1 if descriptors of the BUFR message in 'anObs' differs
+// from current descriptors.
+// returns 0 if they are equal
+//---------------------------------------------------------------
+int
+MvBufrOut :: differentDescriptors( void ) const
+{
+  if( _outState < kBufrOut_formatedBuffers )
+    return 1;
+
+  if( In_KTDLEN != Out_KTDLEN )
+    return 1;
+
+  for( int i = 0; i < In_KTDLEN; i++ )
+    if( In_KTDLST[ i ] != Out_KTDLST[ i ] )
+      return 1;
+
+  return 0;
+}
+//_______________________________________________________________ differentHeader
+// returns 1 if section 1 header of the BUFR message in 'anObs'
+// differs from current header 1.
+// returns 0 if they are equal
+//---------------------------------------------------------------
+int
+MvBufrOut :: differentHeader( const MvObs& anObs ) const
+{
+#if 0
+  int seclen = 17;  // = unsignedInt( &(_currentSec1->len), 3 );  //syntax error???
+
+  unsigned char* v1 = &(_currentSec1->len);	    //-- start of current section 1
+  unsigned char* v2 = &(anObs._bufrIn->fSec1->len); //-- start of sec 1 in other header
+
+  for( int i=seclen; i>0; --i )
+  {
+     if( *v1 != *v2 )
+        return 1;
+
+     ++v1;  ++v2;
+  }
+
+  return 0;
+#endif
+
+  return _currentSec1->isDifferent( anObs._bufrIn->Sec1 );
+}
+//______________________________________________________________ shouldBeWritten
+int
+MvBufrOut :: shouldBeWritten( void )
+{
+  if( _outState != kBufrOut_dataInBuffers )
+    return 0;
+
+  return fKSEC3[ 2 ] >= _maxNrSubsets;  // Nr of Subsets
+}
+//______________________________________________________________ setSubsetCount
+void
+MvBufrOut :: setSubsetCount( int maxNrSubsets )
+{
+  if( _outState == kBufrOut_dataInBuffers )
+    encode();
+  _maxNrSubsets = maxNrSubsets;
+}
+//______________________________________________________________ isDelayedDescriptor
+boolean
+MvBufrOut :: isDelayedDescriptor( const long aDescr ) const
+{
+//  if( aDescr == 31001 || aDescr == 31002 || aDescr == 31011 || aDescr == 31012 )
+  if( aDescr >= 31000 && aDescr <= 31012 )
+    return true;
+  else
+    return false;
+}
+//______________________________________________________________________
+//====================================================================== MvObs
+//______________________________________________________________________
+
+MvObs :: MvObs( MvBufr *b, int i )
+{
+   _subsetNr = i;
+   _copy( b );
+}
+
+MvObs :: MvObs( const MvObs&  b )
+{
+   _copy( b );
+}
+//___________________________________________________________________
+MvObs :: ~MvObs()
+{
+   _clean();
+}
+//___________________________________________________________________ _copy
+void
+MvObs :: _copy( MvBufr *b )
+{
+   _bufrIn = b;
+   _bufr_id = 0;
+   if( _bufrIn )
+   {
+     _bufrIn->attach();
+     _bufr_id = _bufrIn->currentBufrRef();
+   }
+   _currentLevelCoordinate = cPressureCoordinate;
+   _currentLevelIndex = -1;
+   _confidence = new MvBufrConfidence( _bufrIn, _subsetNr );
+}
+//___________________________________________________________________ _copy
+void
+MvObs :: _copy( const MvObs& b )
+{
+  _subsetNr = b._subsetNr;
+  _copy( b._bufrIn );
+
+}
+//___________________________________________________________________ _clean
+void
+MvObs :: _clean()
+{
+   if( _bufrIn )
+     _bufrIn->detach();
+   _bufrIn = NULL;
+   _bufr_id = 0;
+   delete _confidence;
+   _confidence = 0;
+}
+//___________________________________________________________________ operator=
+
+MvObs&
+MvObs :: operator= ( const MvObs& b )
+{
+   _clean();
+   _copy( b );
+   return *this;
+}
+//___________________________________________________________________ operator void*
+
+MvObs :: operator void* ()
+{
+   return _bufrIn;
+}
+//___________________________________________________________________ operator!
+bool
+MvObs :: operator! ()
+{
+   return !_bufrIn;
+}
+//___________________________________________________________________ msg_ok
+//
+bool
+MvObs :: msg_ok() const
+{
+  if( _bufr_id != _bufrIn->currentBufrRef() )
+  {
+    //-- restriction due to static bufr arrays --
+    cerr << ">>> [MvObs::msg_ok] Static bufr arrays rewritten, not valid any more!" << endl;
+    return false;
+  }
+  return ( _bufrIn && ( _bufrIn->_inState != kBufrIn_Error ) ) ? true : false;
+}
+//___________________________________________________________________ Advance
+bool
+MvObs :: Advance()
+{
+   if( _bufrIn->subsetCount() > 1000 ||
+       _bufrIn->subsetCount() < 1 ) // DEBUG TEST ONLY
+   {
+      cerr << " >>> MvObs::Advance, unbelievable nr of fsubsets ("
+	   << _bufrIn->subsetCount() << ") in msg "
+       << _bufrIn->fMessageNumber << endl;
+   }
+   _subsetNr++;
+   _bufrIn->setSubset( _subsetNr );
+   return  _subsetNr <= _bufrIn->subsetCount();
+}
+
+//_________________________________________________________________ messageType
+int
+MvObs :: messageType()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->msgType();
+}
+//_________________________________________________ messageSubtypeInternational
+int
+MvObs :: messageSubtypeInternational()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->msgSubtypeWMO();
+}
+//_________________________________________________________ messageSubtypeLocal
+int
+MvObs :: messageSubtypeLocal()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->msgSubtypeLocal();
+}
+//______________________________________________________________ messageSubtype
+int
+MvObs :: messageSubtype()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->msgSubtype();
+}
+//___________________________________________________________ originatingCentre
+int
+MvObs::originatingCentre()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->origCentre();
+}
+int
+MvObs::originatingSubCentre()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->origSubCentre();
+}
+//___________________________________________________________ editionNumber
+int
+MvObs::editionNumber()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->fSec0->editionNr;
+}
+//___________________________________________________________ masterTable
+int
+MvObs::masterTable()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->masterTable();
+}
+//___________________________________________________________ masterTableVersion
+int
+MvObs::masterTableVersion()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->masterTableVersion();
+}
+//___________________________________________________________ localTableVersion
+int
+MvObs::localTableVersion()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->Sec1->localTableVersion();
+}
+//_________________________________________________  messageTotalLen()
+int
+MvObs :: messageTotalLen()
+{
+   if( ! msg_ok() )
+      return -1;
+
+   return _bufrIn->totalLen();
+}
+//____________________________________________________________________ operator[]
+double
+MvObs::operator[] ( int index )  //-- index starts from 1: 1,2,...,n
+{
+  return (double)(_bufrIn->DataValue( index-1, _subsetNr ));
+}
+//____________________________________________________________________ value
+// returns 'kBufrMissingValue' if not found!
+//-------------------------------------------------
+float
+MvObs :: value( long aDescriptor )
+{
+   if( ! msg_ok() )
+      return kBufrMissingValue;
+
+   fortfloat myValue;
+   _bufrIn->Value( aDescriptor, _subsetNr, myValue );
+   return myValue == kFortranBufrMissingValue ? kBufrMissingValue : myValue;
+}
+//___________________________________________________________________ nextValue
+// returns 'kBufrMissingValue' if not found!
+//-------------------------------------------------
+float
+MvObs :: nextValue()
+{
+   if( ! msg_ok() )
+      return kBufrMissingValue;
+
+   fortfloat myValue;
+   _bufrIn->Value( _bufrIn->_currentDescr, _subsetNr, myValue, _bufrIn->_currentDescrInd + 1 );
+   return myValue == kFortranBufrMissingValue ? kBufrMissingValue : myValue;
+}
+//___________________________________________________________ valueByOccurrence
+// returns 'kBufrMissingValue' if not found!
+//-------------------------------------------------
+float
+MvObs :: valueByOccurrence( int anOccurrenceIndex, long aDescriptor )
+{
+  fortfloat myValue = value( aDescriptor );
+  for( int myInd = 1; myInd < anOccurrenceIndex; myInd++ )
+    myValue = nextValue();
+  return myValue == kFortranBufrMissingValue ? kBufrMissingValue : myValue;
+}
+//______________________________________________________________ hasConfidences
+bool
+MvObs :: hasConfidences()
+{
+  return  _confidence->hasConfidences();
+}
+//__________________________________________________________________ confidence
+int
+MvObs :: confidence()
+{
+  return _bufrIn->_currentDescrInd > -1 ?
+         _confidence->confidenceByIndex( _bufrIn->_currentDescrInd ) : -1;
+}
+//____________________________________________________________________ intValue
+// returns 'kFortranBufrMissingIntValue' if not found!
+//----------------------------------------------------
+long
+MvObs :: intValue( long aDescriptor )
+{
+  return msg_ok() ? _bufrIn->intValue( aDescriptor, _subsetNr ) : kFortranBufrMissingIntValue;
+}
+//____________________________________________________________________ elementValueType
+EElementValueType
+MvObs :: elementValueType()
+{
+  return _bufrIn->elementValueType( _subsetNr );
+}
+//____________________________________________________________________ elementValueType
+EElementValueType
+MvObs :: elementValueType( long aDescriptor )
+{
+  return _bufrIn->elementValueType( aDescriptor, _subsetNr );
+}
+//____________________________________________________________________ stringValue
+string
+MvObs :: stringValue()
+{
+  if( ! msg_ok() )
+    return MESSED_UP;
+  else
+    return _bufrIn->stringValue( _subsetNr );
+}
+//_________________________________________________________________ stringValue
+string
+MvObs :: stringValue( long aDescriptor )
+{
+  if( ! msg_ok() )
+    return MESSED_UP;
+  else
+    return _bufrIn->stringValue( aDescriptor, _subsetNr );
+}
+//______________________________________________________ numberOfPressureLevels
+int
+MvObs :: numberOfPressureLevels()
+{
+  return numberOfLevels( cPressureCoordinate );
+}
+//______________________________________________________ numberOfLevels
+int
+MvObs :: numberOfLevels( long levelDescriptor )
+{
+  int myCount = 0;
+
+  if( firstLevel( levelDescriptor ) != kBufrMissingValue )
+  {
+    myCount++;
+    while( nextLevel() != kBufrMissingValue )
+      myCount++;
+  }
+
+  _currentLevelIndex = -1;
+  return myCount;
+}
+//__________________________________________________________ firstPressureLevel
+float
+MvObs :: firstPressureLevel()
+{
+  _currentLevelCoordinate = cPressureCoordinate;
+  return pressureLevel( 0 );
+}
+//__________________________________________________________ firstLevel
+float
+MvObs :: firstLevel( long levelDescriptor )
+{
+  _currentLevelCoordinate = levelDescriptor;
+  return level( levelDescriptor, 0 );
+}
+//___________________________________________________________ nextPressureLevel
+float
+MvObs :: nextPressureLevel()
+{
+  return pressureLevel( _currentLevelIndex + 1 );
+}
+//___________________________________________________________ nextLevel
+float
+MvObs :: nextLevel()
+{
+  return level( _currentLevelCoordinate, _currentLevelIndex + 1 );
+}
+//______________________________________________________________ pressureLevel
+float
+MvObs :: pressureLevel( int firstIndexValue )
+{
+  float  myLevelValue = level( cPressureCoordinate, firstIndexValue );
+
+  return myLevelValue == kBufrMissingValue ? kBufrMissingValue : myLevelValue / 100.;
+}
+//______________________________________________________________ level
+float
+MvObs :: level( long levelDescriptor, int firstIndexValue )
+{
+  if( ! msg_ok() )
+     return kBufrMissingValue;
+
+  fortfloat myLevelValue = kFortranBufrMissingValue;
+
+  if( _bufrIn->Value( levelDescriptor, _subsetNr, myLevelValue, firstIndexValue ) )
+    _currentLevelIndex = _bufrIn->_currentDescrInd;
+  else
+    _currentLevelIndex = -1;
+
+  return myLevelValue == kFortranBufrMissingValue ? kBufrMissingValue : myLevelValue;
+}
+
+//______________________________________________________________ specifierIndex
+int
+MvObs :: specifierIndex( long   aSpecifierDescriptor
+		       , double aSpecifierValue
+		       , int    firstIndexValue )
+{
+   if( ! msg_ok() )
+      return -1;
+
+   if( _bufrIn->_inState != kBufrIn_DataAndDescriptorsDecoded )
+      _bufrIn->ExpandDescriptors( _subsetNr );
+
+   if( _bufrIn->_inState == kBufrIn_DataAndDescriptorsDecoded )
+   {
+      //-- search for a specifier data with specified value --
+      for( int index=firstIndexValue; index < In_KTDEXL; index++ )
+	 if( In_KTDEXP[ index ] == aSpecifierDescriptor
+	     && _bufrIn->DataValue( index, _subsetNr ) == aSpecifierValue )
+	 {
+	    _lastSpecifierIndex = index;
+	    return index;
+	 }
+   }
+   return -1;
+}
+//____________________________________________________________ valueBySpecifier
+// A generic function to retrieve repeating data
+// specified by some other data
+// (e.g.  temperature at a certain pressure level)
+//--------------------------------------------------------------------
+double
+MvObs :: valueBySpecifier( long   aSpecifierDescriptor
+			 , double aSpecifierValue
+			 , long   aDescriptor
+			 , int    firstIndexValue )
+{
+   int index = specifierIndex( aSpecifierDescriptor, aSpecifierValue, firstIndexValue );
+   if( index > 0 )
+   {
+     //-- if the coordinate value itself is requested
+     if( aSpecifierDescriptor == aDescriptor )
+     {
+         fortfloat myVal = _bufrIn->DataValue( index, _subsetNr );
+         return myVal == kFortranBufrMissingValue ? kBufrMissingValue : myVal;
+     }
+     //-- search real data before next specifier data --
+     for( int ind=index+1; ind < In_KTDEXL; ind++ )
+     {
+       if( In_KTDEXP[ ind ] == aDescriptor )
+       {
+         fortfloat myVal = _bufrIn->DataValue( ind, _subsetNr );
+         return myVal == kFortranBufrMissingValue ? kBufrMissingValue : myVal;
+       }
+
+       //-- not found if specifier data again --
+       if( In_KTDEXP[ ind ] == aSpecifierDescriptor )
+         break;
+     }
+   }
+   return kBufrMissingValue;   //-- Not Found or Troubled Msg --
+}
+//________________________________________________________ valueByPressureLevel
+float
+MvObs :: valueByPressureLevel( float aLevelValue        // in 'hPa'
+			     , long  aDescriptor )
+{
+   return valueBySpecifier( cPressureCoordinate, aLevelValue*100., aDescriptor );
+}
+//________________________________________________________ valueByLevel
+float
+MvObs :: valueByLevel( long  aLevelDescriptor
+                     , float aLevelValue
+		     , long  aDescriptor )
+{
+   return valueBySpecifier( aLevelDescriptor, aLevelValue, aDescriptor );
+}
+//________________________________________________________ valueByLevel
+float
+MvObs :: valueByLevelRange( long  aLevelDescriptor
+                     , float level1
+	             , float level2    
+		     , long  aDescriptor )
+{
+    
+  float levelVal=firstLevel(aLevelDescriptor);
+  
+  while(levelVal != kBufrMissingValue)
+  {  
+	if(levelVal >= level1 && levelVal <= level2)
+	{
+		for( int ind = _currentLevelIndex + 1; ind < In_KTDEXL; ind++ )
+  		{
+    			if( In_KTDEXP[ ind ] == aDescriptor )
+   			{
+      				fortfloat myValue = _bufrIn->DataValue( ind, _subsetNr );
+				if(myValue != kFortranBufrMissingValue)
+					return myValue;
+				
+      				//return myValue == kFortranBufrMissingValue ? kBufrMissingValue : myValue;
+    			}
+    			
+    			else if(In_KTDEXP[ ind ] ==aLevelDescriptor)
+				break; 	
+		}
+	}
+	
+	levelVal=nextLevel();
+  }	
+	
+  return kBufrMissingValue;
+}  
+ 
+//________________________________________________________________ valueByLayer
+float
+MvObs :: valueByLayer( float firstLevel
+		     , float secondLevel
+		     , long aDescriptor )
+{
+  int firstLevelIndex = specifierIndex( cPressureCoordinate, firstLevel*100., 0 );
+  int secondLevelIndex = -1;
+
+  while( firstLevelIndex > 0 )          //-- loop candidates --
+  {
+    //-- try to find the second level next to the current first one --
+
+    if( In_KTDEXP[ firstLevelIndex - 1 ] == cPressureCoordinate &&
+        _bufrIn->DataValue( firstLevelIndex - 1, _subsetNr ) == secondLevel*100. )
+    {
+      secondLevelIndex = firstLevelIndex - 1;
+      break;
+    }
+    else
+      if( In_KTDEXP[ firstLevelIndex + 1 ] == cPressureCoordinate &&
+          _bufrIn->DataValue( firstLevelIndex + 1, _subsetNr ) == secondLevel*100. )
+      {
+        secondLevelIndex = firstLevelIndex + 1;
+        break;
+      }
+
+    //-- no match, let's find the next candidate --
+
+    firstLevelIndex = specifierIndex( cPressureCoordinate
+				    , firstLevel*100.
+				    , firstLevelIndex + 1 );
+  }
+
+  if( firstLevelIndex < 0 )
+    return kBufrMissingValue;  //-- levels were not found!!!
+
+  //-- search real data before next specifier data --
+
+  int maxim = firstLevelIndex > secondLevelIndex ? firstLevelIndex : secondLevelIndex;
+  for( int ind = maxim + 1; ind < In_KTDEXL; ind++ )
+  {
+    if( In_KTDEXP[ ind ] == aDescriptor )
+    {
+      fortfloat myValue = _bufrIn->DataValue( ind, _subsetNr );
+      return myValue == kFortranBufrMissingValue ? kBufrMissingValue : myValue;
+    }
+
+
+    //-- not found if specifier data again --
+
+    if( In_KTDEXP[ ind ] == cPressureCoordinate )
+      break;
+  }
+  return kBufrMissingValue;   //-- Not Found or Troubled Msg --
+}
+
+
+//______________________________________________________________ printAllValues
+boolean
+MvObs :: printAllValues()
+{
+   ostream* myStream = &cout;
+   return writeAllValues( *myStream );
+}
+//_______________________________________________________________ writeAllValues
+boolean
+MvObs :: writeAllValues( ostream& aStream )
+{
+  if( ! msg_ok() )
+    return false;
+
+  if( _bufrIn->_inState != kBufrIn_DataAndDescriptorsDecoded )
+    _bufrIn->ExpandDescriptors( _subsetNr );
+
+  if( _bufrIn->_inState == kBufrIn_DataAndDescriptorsDecoded )
+    {
+      long  myEndingIndex = _confidence->hasConfidences() ?
+	_confidence->lastDataIndex()+1 : In_KTDEXL;
+      writeValues(aStream,0, myEndingIndex);
+      return true;
+   }
+   return false;
+}
+
+boolean
+MvObs::writeValues(ostream& aStream, int firstIndex, int lastIndex)
+{
+   if( ! msg_ok() )
+      return false;
+
+   if( _bufrIn->_inState != kBufrIn_DataAndDescriptorsDecoded )
+      _bufrIn->ExpandDescriptors( _subsetNr );
+
+   if( _bufrIn->_inState == kBufrIn_DataAndDescriptorsDecoded )
+   {
+      fortfloat myValue;
+      if ( firstIndex < 0 )
+	firstIndex = 0;
+      if (lastIndex > In_KTDEXL )
+	lastIndex = In_KTDEXL;
+
+      for( int i = firstIndex; i < lastIndex; i++ )
+      {
+	 aStream.width( 3 ); aStream.fill( ' ' );      // index
+	 aStream << i+1 << ".  ";
+
+	 myValue = _bufrIn->DataValue( i, _subsetNr ); // get parameter value
+	                                               // = set current parameter!
+	 switch( elementValueType() )                    // print parameter value
+	 {
+	   case kEVT_unknown:
+	      aStream << " ?????";
+	      break;
+
+	   case kEVT_missing:
+	      aStream << "   ~~~";
+	      break;
+
+	   case kEVT_numeric:
+	      aStream.width( 6 ); aStream.fill( ' ' );
+	      aStream << myValue;
+	      break;
+
+	   case kEVT_string:
+	      aStream.width( 6 ); aStream.fill( ' ' );
+	      aStream << stringValue( In_KTDEXP[ i ] );
+	      break;
+	 }
+
+	 aStream << " " << name( In_KTDEXP[ i ] );           // parameter name
+	 aStream << " [" << unit( In_KTDEXP[ i ] ) << "] ("; // parameter unit
+	 aStream.width( 5 ); aStream.fill( '0' );            // parameter descriptor
+	 aStream << In_KTDEXP[ i ] << ")";
+	 aStream << endl;
+      }
+      return true;
+   }
+   return false;
+}
+
+//_______________________________________________________________ writeAllValues
+boolean
+MvObs :: writeAllValues( const char* aPathName )
+{
+  ofstream myStream( aPathName, ios::out );
+  if( ! myStream )
+  {
+    cerr << " >>> MvObs::writeAllValues(char*): error in creating file " << aPathName << endl;
+#ifdef METVIEW
+    marslog( LOG_EROR, "MvObs::writeAllValues: error in creating file %s", aPathName );
+#endif
+    return false;
+  }
+
+  return writeAllValues( myStream );
+}
+//_______________________________________________________________ writeBufrBox
+boolean
+MvObs :: writeBufrBox( ostream& aStream )
+{
+   boolean return_value = true;
+
+   boolean b_ret = _bufrIn->writeBufrBox( _subsetNr );
+   if( ! b_ret )
+   {
+      aStream << "\n   >>> Problems encountered!!! <<<\n" << endl;
+      return_value = false;
+   }
+   else
+     {
+       return_value = file_to_stream(BBOXNAME.c_str(),aStream,0);
+       delete_print_file(BBOXNAME.c_str());
+     }
+   return return_value;
+}
+//______________________________________________________________ WmoIdentNumber
+long
+MvObs :: WmoIdentNumber()
+{
+  return msg_ok() ? WmoBlockNumber()*1000 + WmoStationNumber() : kBufrMissingIntValue;
+}
+//______________________________________________________________ WmoBlockNumber
+int
+MvObs :: WmoBlockNumber()
+{
+   fortfloat myValue;
+
+   if( msg_ok() && _bufrIn->Value( 1001L, _subsetNr, myValue ) )
+      return (long)myValue;
+   else
+      return 0;
+}
+//____________________________________________________________ WmoStationNumber
+int
+MvObs :: WmoStationNumber()
+{
+   fortfloat myValue;
+
+   if( msg_ok() && _bufrIn->Value( 1002L, _subsetNr, myValue ) )
+      return (long)myValue;
+   else
+      return 0;
+}
+//____________________________________________________________ findSomeIdent
+string
+MvObs::findSomeIdent()
+{
+  if( ! msg_ok() )
+    return string( "???" );
+
+                            //-- 5-digit WMO identifier available?
+  if( WmoIdentNumber() > 0 )
+    {
+      ostringstream oss;
+      oss << setw(5) << setfill('0') << WmoIdentNumber();
+      return oss.str();
+    }
+                            //-- No WMO id found, thus look for other candidates,
+                            //-- this is a list of known identifier candidates.
+  const long idList[] =
+    {
+      1011L,    //-- Ship or mobile land station identifier
+      1005L,    //-- Buoy/platform identifier
+      1006L,    //-- Aircraft flight number
+      1007L,    //-- Satellite identifier
+      1008L,    //-- Aircraft registration number
+      1010L,    //-- Stationary buoy platform identifier
+      1025L,    //-- Storm identifier
+      1026L,    //-- WMO storm name
+      1027L     //-- WMO long storm name
+    };
+
+  int idVals = sizeof(idList)/sizeof(idList[0]);
+
+  for( int i=0; i<idVals; ++i )
+    {
+      long descr = idList[i];
+      fortfloat myValue = value( descr );
+
+      if( myValue != kBufrMissingValue )
+	{
+	  return stringValue( descr );
+	}
+    }
+
+  return string( "id???" );
+}
+//____________________________________________________________________ location
+MvLocation
+MvObs :: location()
+{
+   MvLocation myLocation( value( 5001L ), value( 6001L ) ); //-- "high accuracy"
+
+   if( myLocation.latitude() == kBufrMissingValue ||
+       myLocation.longitude() == kBufrMissingValue )
+   {
+      myLocation.set( value( 5002L ), value( 6002L ) );     //-- "coarse accuracy"
+   }                                                        //-- hopefully not missing
+
+   //-- this one is for those quirky NCEP PrepBUFR msgs
+   if( myLocation.latitude() != kBufrMissingValue &&
+       myLocation.longitude() == kBufrMissingValue )
+   {
+      //-- lat OK, try NCEP PrepBUFR local descriptor 0'06'240 for lon
+      myLocation.set( myLocation.latitude(), value( 6240L ) );
+   }
+
+   return myLocation;
+}
+//____________________________________________________________________ unit
+string
+MvObs :: unit( long aDescriptor )
+{
+  return msg_ok() ? _bufrIn->unit( aDescriptor ) : MESSED_UP;
+}
+//____________________________________________________________________ unit
+string
+MvObs :: unit()
+{
+  return msg_ok() ? _bufrIn->unit() : MESSED_UP;
+}
+//____________________________________________________________________ name
+string
+MvObs :: name( long aDescriptor )
+{
+  return msg_ok() ? _bufrIn->name( aDescriptor ) : MESSED_UP;
+}
+//____________________________________________________________________ name
+string
+MvObs :: name()
+{
+  return msg_ok() ? _bufrIn->name() : MESSED_UP;
+}
+//________________________________________________________________ subsetOffset
+int
+MvObs :: subsetOffset() const
+{
+  return ( _subsetNr - 1 ) * In_KELEM;
+}
+//________________________________________________________________ writeConfidenceValues
+bool
+MvObs::writeConfidenceValues(ostream& aStream)
+{
+  if( ! msg_ok() || ! _confidence->hasConfidences() )
+    return false;
+
+  if( _bufrIn->_inState != kBufrIn_DataAndDescriptorsDecoded )
+    _bufrIn->ExpandDescriptors( _subsetNr );
+
+  if( _bufrIn->_inState == kBufrIn_DataAndDescriptorsDecoded )
+    {
+      long  myStartingIndex = _confidence->lastDataIndex()+1;
+      long  myEndingIndex =  In_KTDEXL;
+      writeValues(aStream,myStartingIndex, myEndingIndex);
+      return true;
+   }
+   return false;
+}
+
+#ifdef METVIEW
+//---
+//-- Extracts a 4 or 8 bit OPERA radar image
+//-- from a BUFR message into 'unsigned char' array
+//--
+//-- ( NOTE: U N F I N I S H E D ! ! ! )
+//____________________________________________________________________ OperaRadarImage
+unsigned char*
+MvObs::OperaRadarImage(  )
+{
+   const float cRadarMissingVal = 255;       //-- BUFR radar pixel with no data
+   const float cMyMissingValue = 0;          //-- output radar pixel with no data
+
+   //---
+   //-- Some checks to ensure that we can handle this data
+   //-
+
+   int msgType = messageType();
+   if( msgType != 6 )                        //-- 6 = Radar data
+   {
+      throw MvException( "MvObs::OperaRadarImage: not radar data!" );
+   }
+
+   float val = value( 30021 );               //-- 030021: Number of pixels per row
+   if( val == kBufrMissingValue )
+   {
+      throw MvException( "MvObs::OperaRadarImage: unable to get number-of-rows!" );
+   }
+   int n_rows = val;
+
+   val = value( 30022 );                     //-- 030022: Number of pixels per column
+   if( val == kBufrMissingValue )
+   {
+      throw MvException( "MvObs::OperaRadarImage: unable to get number-of-columns!" );
+   }
+   int n_cols = val;
+
+   //---
+   //-- So far so good, now let's try to locate the first data row
+   //-
+
+   int firstRowStartIndex = _bufrIn->descriptorToFortranIndex( 5031 );
+   if( firstRowStartIndex < 0 )
+   {
+      throw MvException( "MvObs::OperaRadarImage: unable to get Row Number element!" );
+   }
+                                                     //-- "FortranIndex": 0,1,2,...
+   int rowRepeatCount = (*this)[firstRowStartIndex]; //-- operator[i], i=1,2,3,...
+   long currentDescr = currentDescriptor();
+   if( currentDescr != 31002 )
+   {
+      throw MvException( "MvObs::OperaRadarImage: internal error - not 031002" );
+   }
+
+   //---
+   //-- Still OK, now create the pixel array and start decoding the BUFR msg
+   //-
+
+   unsigned char* radimg = new unsigned char[n_rows*n_cols];
+   cout << "radimg size: " << n_rows << "*" << n_cols << " = " << n_rows*n_cols << endl;
+
+   int startPos = firstRowStartIndex - 1;    //-- start of radimg pixels
+   int pixelPos = 0;
+
+   float imax = 0;
+   for( int msgPos = startPos; msgPos < In_KTDEXL; ++msgPos )
+   {
+      float currVal = (*this)[msgPos];       //-- get the value
+      long  currDescr = currentDescriptor(); //-- and it's descriptor
+
+      if( currDescr == 31012 || currDescr == 31011 ) //-- delayed descr & data repetition factor?
+      {
+         int repeatCount = currVal;
+         float repeatVal = (*this)[++msgPos]; //-- get next value (advances to next descriptor)
+
+         //-- Double check that the descriptor that follows is a pixel data descriptor
+         //-- NOTE: Descriptor 30004 (16 bit pixel value) is ignored by this code!
+         //--       We only check for 4 bit (30001) and 8 bit (30002) pixel descriptors
+         long nextCurrDescr = currentDescriptor();
+         if( nextCurrDescr != 30001 && nextCurrDescr != 30002 )
+         {
+            delete [] radimg;                //-- free memory before throwing
+            if( nextCurrDescr == 30004 )     //-- cannot process 16 bit pixels
+            {
+               throw MvException( "MvObs::OperaRadarImage: cannot process 16 bit radar images" );
+            }
+
+            cerr << "MvObs::OperaRadarImage: expected 30001 or 30002, found "
+                 << nextCurrDescr << endl;
+            throw MvException( "MvObs::OperaRadarImage: internal or data error => debug needed" );
+         }
+
+         //---
+         //-- OK, we are processing a repeated pixel value (run-length coding)
+         //-
+         if( repeatVal == cRadarMissingVal )
+            repeatVal = cMyMissingValue;
+         else if( repeatVal > imax )
+            imax = repeatVal;
+
+         for( int i=0; i < repeatCount; ++i )
+         {
+            radimg[pixelPos++] = (unsigned char)repeatVal; //-- repeated data value
+         }
+      }
+      else if( currDescr == 30002 || currDescr == 30001 )
+      {
+         //---
+         //-- this is not a repeated value, just a single value
+         //-
+         if( currVal == cRadarMissingVal )
+            currVal = cMyMissingValue;
+         else if( currVal > imax )
+            imax = currVal;
+
+         radimg[pixelPos++] = (unsigned char)currVal;      //-- individual data value
+      }
+   }
+   cout << "Last pixel pos: " << pixelPos << endl;
+   cout << "Max pixel value: " << imax << endl;
+
+   return radimg;
+}
+//---
+//-- Extracts OPERA radar image metadata that is required
+//-- for instance for geolocating the image
+//--
+//-- ( NOTE: U N F I N I S H E D ! ! ! )
+//____________________________________________________________________ OperaRadarMetadata
+bool
+MvObs::OperaRadarMetadata( /* <aki> arguments? */ )
+{
+   return false;
+}
+#endif
+
+//=============================================================================
+//                                                                 vk April -95
+// Quick&Dirty hack to access Feed Back Quality Control Confidence info:
+//  * works only for QC operator 222000
+//  * uses Data Present Descriptors (031031) and Confidence Descriptors (033007)
+//  * presumes following structure:
+//     - 222000 descriptor exists (and is followed by:)
+//     - 031031 descriptors are all in one group (only first one is used!)
+//     - 033007 descriptors are all in one group (only first one is used!)
+//     - Extended Delayed Descr Replication Factors (031002) are not checked!
+//  * Data Present group is used to define index into Confidence group
+//____________________________________________________________ MvBufrConfidence
+
+MvBufrConfidence :: MvBufrConfidence( MvBufr* aBufr, int aSubsetNr )
+{
+  _bufr = aBufr;
+  if( _bufr )
+    _bufr->attach();
+  _subsetNr = aSubsetNr;
+  _state = kBCS_unknown;
+  _startOfDataPresent = -2;
+  _startOfConfidences = -2;
+}
+//___________________________________________________________ ~MvBufrConfidence
+
+MvBufrConfidence :: ~MvBufrConfidence()
+{
+  if( _bufr )
+    _bufr->detach();
+}
+//______________________________________________________________ hasConfidences
+bool
+MvBufrConfidence :: hasConfidences()
+{
+  if( ! _bufr )
+    return false;
+
+  if( _state == kBCS_unknown )
+    _state = _bufr->descriptorToFortranIndex( 222000L ) > 0 ? kBCS_exists : kBCS_missing;
+
+  return _state == kBCS_exists ? true : false;
+}
+//_______________________________________________________________ confidence
+int
+MvBufrConfidence :: confidence( long aDescr )
+{
+  int myDataIndex = _bufr->descriptorToFortranIndex( aDescr );
+  return myDataIndex > -1 ? confidenceByIndex( myDataIndex ) : -1;
+}
+//___________________________________________________________ confidenceByIndex
+int
+MvBufrConfidence :: confidenceByIndex( int aDataInd )
+{
+  int myConfidenceInd = -1;
+
+  if( hasConfidences() )
+  {
+     //--    case a:        case b:
+     //--        . . .          . . .
+     //--       0xxyyy         0xxyyy    <- 0xxyyy: element descriptors
+     //--       0xxyyy         222000
+     //--       222000         03100x
+     //--       031031         031031    <- startOfDataPresent()
+     //--       031031         031031
+     //--        . . .          . . .
+     //--
+     if( aDataInd < ( startOfDataPresent() - 1 ) &&  //-- skip 222000
+         _bufr->CurrentDescriptor() != 222000L )     //-- if previous was 03100*
+     {
+        if( _bufr->DataValue( aDataInd, _subsetNr ) != kFortranBufrMissingValue )
+           myConfidenceInd = startOfConfidences() + delta( aDataInd );
+     }
+  }
+
+  return myConfidenceInd > -1 ?
+            (int)(_bufr->PeekDataValue( myConfidenceInd, _subsetNr )) : -1;
+}
+//_______________________________________________________________ lastDataIndex
+int
+MvBufrConfidence :: lastDataIndex()
+{
+  return hasConfidences() ? _bufr->descriptorToFortranIndex( 222000L ) - 1 : -1;
+}
+//__________________________________________________________ startOfDataPresent
+// Q&D hack !!!
+
+int
+MvBufrConfidence :: startOfDataPresent()
+{
+  if( _startOfDataPresent == -2 )
+  {
+    if( hasConfidences() )
+    {
+      _startOfDataPresent = _bufr->descriptorToFortranIndex( 31031L );
+      if( _startOfDataPresent < 1 )
+      {
+	cerr << "[MvBufrConfidence::startOfDataPresent] Q&D hack does not work!!" << endl;
+	_state = kBCS_missing;
+      }
+    }
+  }
+
+  return hasConfidences() ? _startOfDataPresent : -1;
+}
+//_______________________________________________________________ startOfConfidences
+// Q&D hack !!!
+
+int
+MvBufrConfidence :: startOfConfidences()
+{
+  if( _startOfConfidences == -2 )
+  {
+    if( hasConfidences() )
+    {
+      _startOfConfidences = _bufr->descriptorToFortranIndex( 33007L );
+      if( _startOfConfidences < 1 )
+      {
+	cerr << "[MvBufrConfidence::startOfConfidences] Q&D hack does not work!!" << endl;
+	_state = kBCS_missing;
+      }
+    }
+  }
+
+  return hasConfidences() ? _startOfConfidences : -1;
+}
+//_______________________________________________________________ delta
+int
+MvBufrConfidence :: delta( int anInd )
+{
+  if( hasConfidences() )
+  {
+    int myDelta = 0;
+
+    for( int i = 0; i < anInd; i++ )
+      if( _bufr->PeekDataValue( startOfDataPresent()+i, _subsetNr ) == 0 )
+	myDelta++;
+
+    return myDelta;
+  }
+  else
+    return -1;
+}
+
+//________________________________________________________________________
+//======================================================================== MvBufrParam
+//________________________________________________________________________
+
+MvBufrParam :: MvBufrParam( const char *aParamName )
+{
+   descriptorStruct *par = knownParams;
+   while( par->descriptor != 0 )
+   {
+      if( strcmp( aParamName, par->name ) == 0 )
+      {
+         fDescriptor = par->descriptor;
+	 return;
+      }
+      ++par;
+   }
+   cerr << " >>> MvBufrParam::MvBufrParam: param not defined: " << aParamName << endl;
+   fDescriptor = 0;
+}
+//_____________________________________________________________ PrintAllKnownParameters
+
+void
+MvBufrParam :: PrintAllKnownParameters() const
+{
+   descriptorStruct *par = knownParams;
+   cout << " The Known Parameters of class MvBufrParam and the corresponding Descriptors:\n";
+   while( par->descriptor != 0 )
+   {
+      cout << "\n";
+      cout.width( 16 );
+      cout.fill( ' ' );
+      cout << par->name << " = ";
+      cout.width( 6 );
+      cout.fill( '0' );
+      cout << par->descriptor;
+      ++par;
+   }
+   cout << endl;
+}
+
+//-------------------- Helper functions to redirect stdout ----------------
+// This function will duplicate the file descriptor for stdout, and keep
+// it for later. Then stdout is connected to the file given as arg.
+// The first time the function is run, it tries to find a temporary dir.
+// to use ( class could be used outside metview ).
+
+boolean redirect_6(const char *fname)
+{
+  cout << " redirect_6: redirect stdout into file " << fname << endl;
+  char *tmp_dir;
+  // Set the output dir. if it's not set.
+  if ( redirect_dir == string("") )
+    {
+      tmp_dir = getenv("METVIEW_TMPDIR");
+      if ( !tmp_dir )
+	{
+	  tmp_dir = getenv("TMPDIR");
+	  if ( !tmp_dir )
+	    redirect_dir = "/usr/tmp";
+	  else
+	    redirect_dir = tmp_dir;
+	}
+      else
+	redirect_dir = tmp_dir;
+    }
+
+  // Flush stdout before redirecting, to get rid of any pending output.
+  fflush(stdout);
+
+  new_fd = dup(STDOUT_FILENO);
+
+  cout << "new_fd: " << new_fd << endl;
+
+  close(STDOUT_FILENO);
+
+  string tmp_name;
+  tmp_name = redirect_dir + "/" + fname;
+  // As 1 is just closed, it will be the fd used.
+  // Will fail if stdin is explicitly closed and no fopens are done
+  if ( ! (fopen(tmp_name.c_str(),"w")) )
+    {
+	    cerr << "Problems opening file " << (const char*)tmp_name.c_str() << " for writing" << endl;
+      return false;
+    }
+
+  else
+    return true;
+}
+
+//
+// Will reconnect stdout by using a file descriptor saved from earlier.
+//
+boolean reconnect_6()
+{
+  // Make sure we get everything before closing.
+  fflush(NULL);
+  close(STDOUT_FILENO);
+
+  int ret = dup2( new_fd, STDOUT_FILENO );
+  close(new_fd);
+  if( ret < 0 )
+    {
+      cerr << " reconnect_6: reconnecting into stdout FAILED!" << endl;
+      cout << " reconnect_6: reconnecting into stdout FAILED!" << endl;
+      return false;
+    }
+  cout << " reconnect_6: reconnected into stdout!" << endl;
+  return ret > 0 ;
+}
+
+//
+// Read a file and write the contents to given stream
+//
+boolean file_to_stream(const char *fname,ostream &aStream,int skip)
+{
+  const int MAX_LINE_LEN = 512;
+  char      supposedToBeANewLine;
+  string    myTmpFileName;
+
+  myTmpFileName = redirect_dir + "/" + fname;
+
+  ifstream myTmpFile( myTmpFileName.c_str() );
+
+  if ( ! myTmpFile )
+    {
+	    aStream << "Can not read file " << (const char*)myTmpFileName.c_str() << endl;
+      return false;
+    }
+
+  char     myLine[ MAX_LINE_LEN ];
+
+  myTmpFile.get( myLine, MAX_LINE_LEN, '\n' );
+  myTmpFile.get( supposedToBeANewLine );
+  int i = 0;
+  while( myTmpFile && !myTmpFile.eof() )
+    {
+      if ( i++ >= skip )
+	aStream << myLine << endl;
+
+      myTmpFile.get( myLine, MAX_LINE_LEN, '\n' );
+      myTmpFile.get( supposedToBeANewLine );
+    }
+
+  myTmpFile.close();
+
+  return true;
+}
+
+void delete_print_file(const char *name)
+{
+  string fname = redirect_dir + "/" + name;
+  unlink(fname.c_str());
+}
+
+void eraseWhiteSpaceFromStringEnd(string &str)
+{
+   static string whitespaces (" \t\f\v\n\r");
+   size_t found=str.find_last_not_of(whitespaces);
+   if (found!=string::npos)
+       str.erase(found+1);
+   else
+       str.clear();
+}
+
+string intToString(int i)
+{
+	stringstream out;
+	out << i;
+	return out.str();
+}
+
+string floatToString(float f)
+{
+	stringstream out;
+	out << f;
+	return out.str();
+}
+
+void keyToStringMap(map<string,string> &data,string keyName,fortint *keyArray,int fortIndex)
+{
+	data[keyName]=intToString(keyArray[fortIndex-1]);
+}
+
+void keyToStringMap(map<string,string> &data,string keyName,float keyValue)
+{
+	data[keyName]=floatToString(keyValue);
+}
diff --git a/src/MvObs/MvObs.h b/src/MvObs/MvObs.h
new file mode 100644
index 0000000..4551648
--- /dev/null
+++ b/src/MvObs/MvObs.h
@@ -0,0 +1,25 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvObs.h,   vk july94
+//        rev vk 010724
+
+#ifndef MvObs_DEFINED_
+#define MvObs_DEFINED_
+
+#include "MvBufr.h"
+#include "MvBufrObs.h"
+#include "MvObsSet.h"
+
+#ifdef METVIEW_PREPBUFR
+# include "MvPrepBufrPrep.h"
+#endif
+
+#endif
+// MvObs_DEFINED_
diff --git a/src/MvObs/MvObsSet.cc b/src/MvObs/MvObsSet.cc
new file mode 100644
index 0000000..74f3f09
--- /dev/null
+++ b/src/MvObs/MvObsSet.cc
@@ -0,0 +1,1011 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvObsSet.cc,   vk July94
+//            rev vk 980306
+
+//--------------------------------------------------------------------
+//  MvObsSet hides the data structures and parameter driven subroutines
+//  needed to access BUFR files by wrapping them to a nicer C++ cover.
+//--------------------------------------------------------------------
+//  Routines and required data structures are described in
+//  ECMWF Meteorological Bulletin:
+//
+//  "Accessing GRIB and BUFR data."
+//       by J.D.Chambers
+//
+//  May 1994 Original version.
+//--------------------------------------------------------------------
+
+#include "inc_iostream.h"
+#include "MvObsSet.h"
+
+#ifdef METVIEW_PREPBUFR
+# include "MvPrepBufrPrep.h"
+#endif
+
+#ifndef METVIEW
+#include "grib_api.h"
+long _readbufr(FILE *f, char *b, long *l)  // from mars/tools.c
+{
+	size_t len = *l;
+	long e =  wmo_read_any_from_file(f,(unsigned char*)b,&len);
+	*l = len;
+	return e;
+}
+#endif
+
+int MAX_MESSAGE_LENGTH = 32000;
+
+const int    cMSG_TYPE_BUFR_TABLES = 11;
+
+static string WRITE("w");  // i/o mode
+
+//____________________________________________________________________
+//==================================================================== MvObsSet
+//____________________________________________________________________
+
+MvObsSet :: MvObsSet( const char *aName )
+ : _minTime( 2247, 6, 20 )
+ , _maxTime( 1799, 12, 31 )
+{
+   _IO_mode = "r";
+   _init( aName );
+}
+//____________________________________________________________________
+
+MvObsSet :: MvObsSet( const char *aName, const char *aMode )
+ : _minTime( 2247, 6, 20 )
+ , _maxTime( 1799, 12, 31 )
+{
+   _IO_mode = aMode;
+   _init( aName );
+}
+//____________________________________________________________________
+#ifdef METVIEW
+MvObsSet :: MvObsSet( MvRequest &aRequest, const char *aMode )
+ : _minTime( 2247, 6, 20 )
+ , _maxTime( 1799, 12, 31 )
+{
+   _IO_mode = aMode;
+   const char *aName = 0;
+   aRequest.getValue( aName, "PATH" );
+   _init( aName );
+}
+#endif
+//____________________________________________________________________
+
+MvObsSet :: ~MvObsSet()
+{
+   close();
+   delete [] _message;    // added 950201/vk
+   if( _bufrOut )
+     delete _bufrOut;
+#ifdef METVIEW_PREPBUFR
+   if( prepBufr_  )
+     delete prepBufr_;
+#endif
+
+}
+//____________________________________________________________________
+void
+MvObsSet :: _init( const  char *aName )
+{
+   _bufrFile = 0;
+   _msgCount = -1;
+   _obsCount = -1;
+   _msgNumber = -1;
+   _msgLen = 0;
+   _minMaxDone = false;
+  // _message = new char[ MAX_MESSAGE_LENGTH ];
+   _IO_buffer_OK = false;
+#ifdef METVIEW_PREPBUFR
+   isPrepBufrFile_ = false;
+   prepBufr_ = 0;
+#endif
+
+   Open( aName );
+
+   if( _IO_mode == WRITE )  //should be two classes!!!!!!! (but this a working one...)
+   {
+     _message = 0;
+     _bufrOut = new MvBufrOut( MAX_MESSAGE_LENGTH, this );  //( _message, MAX_MESSAGE_LENGTH, this );
+   }
+   else
+   {
+     _message = new char[ MAX_MESSAGE_LENGTH ];
+     _bufrOut = 0;
+
+#ifdef METVIEW_PREPBUFR
+#ifdef METVIEW
+     cout << "MvObsSet::_init - PrepBUFR support available, testing if PrepBUFR file..." << endl;
+#endif
+     firstObs_ = next();                    //-- check if PrepBUFR file (contains BUFR tables)
+     isPrepBufrFile_ = ( firstObs_.messageType() == cMSG_TYPE_BUFR_TABLES );
+     rewind();
+
+//aki:
+//  1) test if PrepBUFR tables have already been extracted: MV_PREPBUFR_TABLES_EXTRACTED
+//  2) extract only if not yet extracted
+     if( isPrepBufrFile_ && ! getenv("MV_PREPBUFR_TABLES_EXTRACTED") )
+     {
+        prepBufrFile();
+        putenv("MV_PREPBUFR_TABLES_EXTRACTED=YES");
+     }
+#else
+     cout << "MvObsSet::_init - PrepBUFR support NOT available!!!!" << endl;
+#endif
+   }
+   cout << "in MvObsSet::_init(" << aName << ")" << endl;
+}
+//____________________________________________________________________ setSubsetMax
+void
+MvObsSet :: setSubsetMax( int subsetMax )
+{
+  //_bufrOut->_maxNrSubsets = subsetMax; //replaced vk 941219
+  _bufrOut->setSubsetCount( subsetMax );
+}
+//____________________________________________________________________ Open
+boolean
+MvObsSet :: Open( const char* aFileName )
+{
+   _msgCount = -1;
+   _msgNumber = 0;
+
+   _bufrFile = fopen( aFileName, _IO_mode.c_str() );
+
+   if( _bufrFile )
+      return true;
+   else
+   {
+      cerr << " >>> MvObsSet::Open: file \'" << aFileName << "\', not opened!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "Unable to open file %s", aFileName );
+#endif
+      return false;
+   }
+}
+//____________________________________________________________________ close
+boolean
+MvObsSet :: close()
+{
+   long myReturnValue = -1;
+   if( _bufrFile )
+   {
+     if( _IO_mode == WRITE && _bufrOut->_outState == kBufrOut_dataInBuffers )
+     {
+       _bufrOut->encode();
+     }
+
+     myReturnValue = fclose( _bufrFile);
+     _bufrFile = 0;
+   }
+   _IO_buffer_OK = false;
+   return myReturnValue ? false : true;
+}
+//____________________________________________________________________ rewind
+void
+MvObsSet :: rewind()
+{
+   _msgNumber = 0;
+   if( _bufrFile )
+     ::rewind( _bufrFile );  // execute C command 'rewind'!
+   else
+     cerr << " >>> MvObsSet::rewind: File Unit not valid!" << endl;
+}
+
+//____________________________________________________________________ next
+// Reads next BUFR message and returns an MvObs constructed with it.
+// An MvObs without a message is returned at EOF.
+//------------------------------------------------
+MvObs
+MvObsSet::next()
+{
+   const int EOF_STATUS = -1;
+
+   if( ! _bufrFile )
+     return MvObs( NULL );  // nothing if file not ok
+
+   if( _IO_mode == WRITE )
+     return MvObs( NULL );  // no next when writing !
+
+   _msgLen = MAX_MESSAGE_LENGTH;
+
+   _msgNumber++;
+
+   long lastPos = ftell(_bufrFile);
+   long myError = _readbufr( _bufrFile, _message, &_msgLen );
+
+   if ( myError == -3 )  // Bufr too small
+     {
+
+       // Go back to previous and allocate memory
+       fseek(_bufrFile,lastPos,SEEK_SET);
+       delete [] _message;
+       MAX_MESSAGE_LENGTH = _msgLen + 8;
+       _message = new char[ MAX_MESSAGE_LENGTH ];
+       _msgLen = MAX_MESSAGE_LENGTH;
+
+       if ( ! _message )
+	 {
+	   cerr << "MvObsSet::next: Cannot allocate memory for next BUFR message" << endl;
+#ifdef METVIEW
+	   marslog( LOG_EROR, "Cannot allocate memory for next BUFR message" );
+#endif
+	   _msgLen = MAX_MESSAGE_LENGTH  = 0;
+	   _IO_buffer_OK = false;
+	   return MvObs( NULL );
+	 }
+       else
+	 {
+	   cout << "MvObsSet::next: Allocated more memory for BUFR msg" << endl;
+	   myError = _readbufr( _bufrFile, _message, &_msgLen );
+	 }
+     }
+
+   if( myError )
+     {
+       if( myError != EOF_STATUS )
+	 {
+	   cerr << "MvObsSet::next: Failed reading next BUFR msg, returned status=" << myError << endl;
+#ifdef METVIEW
+	   marslog( LOG_EROR, "Failed reading next BUFR msg, status = %ld", myError );
+#endif
+	 }
+       _IO_buffer_OK = false;
+       return MvObs( NULL );
+     }
+
+#ifdef METVIEW_PREPBUFR
+   //--
+   //-- NCEP PrepBUFR files may contain msgs with ZERO subsets!!!
+   //-- 'bufrex' cannot handle such illegal msgs, if so we must skip it
+   //--
+   MvBufr tmpBufr( _message, _msgLen, _msgNumber  ); //-- make BUFR octets into an object
+   if( tmpBufr.subsetCount() == 0 )
+     {
+       ostringstream os;
+       os << "Original BUFR msg " << _msgNumber
+          << " has ZERO subsets - ignoring (not counting) this illegal msg!"
+          << ends;
+
+       cout << os.str() << endl;
+
+#ifdef METVIEW
+       //-- why this marslog crashes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
+//       marslog( LOG_WARN, "%s", os.str().c_str() );
+       //-- why this marslog crashes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
+#endif
+
+       //-- get next msg and cross your fingers it fits into current _message array
+       _msgLen = MAX_MESSAGE_LENGTH;
+       myError = _readbufr( _bufrFile, _message, &_msgLen );
+
+       //_msgNumber++;
+     }
+#endif
+
+     _IO_buffer_OK = true;
+     return MvObs( new MvBufr( _message, _msgLen, _msgNumber ) );
+}
+
+//____________________________________________________________________ add
+void
+MvObsSet::add( MvObs& anObs )
+{
+   if( _IO_mode != WRITE )
+     return;  // no add when reading !
+
+   _bufrOut->add( anObs );
+   _msgCount++; //??
+}
+//____________________________________________________________________ write
+void
+MvObsSet::write( const char* aMsg, int aMsgLen )
+{
+  if( _IO_mode != WRITE )
+    return;  // no write when reading !
+
+  fwrite( aMsg, sizeof( char ), aMsgLen, _bufrFile );
+  _msgNumber++;
+}
+
+//____________________________________________________________________ messageCount
+// Returns the number of BUFR messages found in the file.
+// WARNING: a packed BUFR message may contain several observations
+//          i.e. the nr of BUFR msgs found <= nr of observation msgs
+//          i.e. messageCount() <= obsCount()
+//------------------------------------------------------------------
+int
+MvObsSet :: messageCount()
+{
+   if( _msgCount < 1 )
+   {
+      if( _bufrFile )
+      {
+         long myOriginalFilePos = ftell( _bufrFile );
+	 rewind();
+
+         _msgCount = 0;
+         while( next() )
+	    _msgCount++;
+
+	 fseek( _bufrFile, myOriginalFilePos, SEEK_SET );
+      }
+   }
+   return _msgCount;
+}
+//____________________________________________________________________ obsCount
+int
+MvObsSet :: obsCount()
+{
+   if( _obsCount < 1 )
+   {
+      if( _bufrFile )
+      {
+         long myOriginalFilePos = ftell( _bufrFile );
+	 rewind();
+
+         _obsCount = 0;
+	 MvObs oneBufrMsg;
+         while( ( oneBufrMsg = next() ) )
+	    _obsCount += oneBufrMsg._bufrIn->subsetCount();
+
+	 fseek( _bufrFile, myOriginalFilePos, SEEK_SET );
+      }
+   }
+   return _obsCount;
+}
+//_________________________________________________________ searchMinMaxTime
+void
+MvObsSet :: searchMinMaxTime()
+{
+   if( ! _minMaxDone )
+   {
+      if( _bufrFile )
+      {
+         long myOriginalFilePos = ftell( _bufrFile );   rewind();
+
+         TDynamicTime msgTime;
+         MvObs myObs;
+         while( ( myObs = next() ) )
+         {
+            msgTime = myObs.msgTime();
+            if( msgTime > _maxTime )
+                _maxTime = msgTime;
+            if( msgTime < _minTime )
+                _minTime = msgTime;
+         }
+
+         fseek( _bufrFile, myOriginalFilePos, SEEK_SET );
+
+      }
+      _minMaxDone = true;
+   }
+}
+#ifdef METVIEW_PREPBUFR
+//____________________________________________________________________ prepBufrFile
+bool
+MvObsSet::prepBufrFile()
+{
+   if( isPrepBufrFile_ )
+   {
+#ifdef METVIEW
+      cout << "in MvObsSet::prepBufrFile()" << endl;
+      marslog( LOG_INFO, "BUFR file contains BUFR tables, processing..." );
+#endif
+                                            //-- create new PrepBUFR table files etc...
+      prepBufr_ = new MvPrepBufrPrep( *this );
+      bool ok = prepBufr_->prepareAll();
+      if( !ok )
+      {
+#ifdef METVIEW
+         marslog( LOG_EROR, "Unable to process PrepBUFR file" );
+#endif
+         cerr << "Errors: unable to process the PrepBUFR file" << endl;
+         return false;
+      }
+   }
+   return isPrepBufrFile_;
+}
+#endif
+
+//____________________________________________________________________ minDate
+#ifdef METVIEW
+MvDate
+MvObsSet :: minDate()
+{
+   searchMinMaxTime();
+   double timfloat = 10000.0L*(double)_minTime.GetYear()
+                     + 100.0L*(double)_minTime.GetMonth()
+                     +        (double)_minTime.GetDay()
+                     +        (double)_minTime.GetHour()/24.0L
+                     +        ((double)_minTime.GetMin()+0.5L)/60.0L/24.0L; //rounded
+   return MvDate( timfloat );
+}
+//____________________________________________________________________ maxDate
+MvDate
+MvObsSet :: maxDate()
+{
+   searchMinMaxTime();
+   double timfloat = 10000.0L*(double)_maxTime.GetYear()
+                     + 100.0L*(double)_maxTime.GetMonth()
+                     +        (double)_maxTime.GetDay()
+                     +        (double)_maxTime.GetHour()/24.0L
+                     +        ((double)_maxTime.GetMin()+0.5L)/60.0L/24.0L; //rounded
+   return MvDate( timfloat );
+}
+#endif
+
+/*-------
+//____________________________________________________________________ operator +=
+// use 'add' member function instead!
+void
+MvObsSet :: operator += ( MvObs anObs )
+{
+   if( _IO_mode == "r" )
+     return;  // no writing for read files !
+
+   cout << "MvObsSet::operator+= not yet implemented..." << endl;
+}
+-------*/
+//___________________________________________________________________
+//=================================================================== MvObsSetIterator
+//___________________________________________________________________
+
+MvObsSetIterator :: MvObsSetIterator( MvObsSet& s)
+{
+   ObsSet = &s;
+
+   _NoFiltersSet = true;
+   _TimeFilterState = kTFS_notSet;
+   _WmoBlockCount = 0;
+   _WmoStationCount = 0;
+   _MsgTypeCount = 0;
+   _MsgSubtypeCount = 0;
+   _SelectState = SF_notSet;
+   _SelectValueCount = 0;
+   useObsTime_ = false;
+}
+//___________________________________________________________________
+
+MvObsSetIterator :: ~MvObsSetIterator()
+{
+}
+//___________________________________________________________________ operator()
+
+
+MvObs MvObsSetIterator :: operator() ( ENextReturn returnType )
+{
+  if( ! current || ( returnType == NR_returnMsg ) || ! current.Advance() )
+    next();
+
+  while( current && ! AcceptedObs( current ) )
+  {
+    if( ! current || ( returnType == NR_returnMsg ) || ! current.Advance() )
+      next();
+  }
+  return current;
+}
+//____________________________________________________________________ next
+
+void
+MvObsSetIterator :: next()
+{
+  static int change_me_with_debugger = 0;
+
+  current = ObsSet->next();
+
+#ifdef METVIEW
+  if( mars.debug && ( ( ObsSet->messageNumber() == 1 ) || change_me_with_debugger ) )
+    current.printAllValues();
+#endif
+}
+//____________________________________________________________________ setTime
+
+void
+MvObsSetIterator :: setTime( const TDynamicTime& anObsTime )
+{
+   setTimeRange( anObsTime, anObsTime );
+}
+//____________________________________________________________________
+
+void
+MvObsSetIterator :: setTimeRange( const TDynamicTime& anObsTime, short deltaInMinutes )
+{
+   fBeginTime = fEndTime = anObsTime;
+   fBeginTime.ChangeByMinutes( -deltaInMinutes );
+   fEndTime.ChangeByMinutes( deltaInMinutes );
+   _TimeFilterState = kTFS_bothSet;
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setTimeRange( const TDynamicTime& aBeginTime, const TDynamicTime& anEndTime )
+{
+   fBeginTime = aBeginTime;
+   fEndTime = anEndTime;
+   _TimeFilterState = kTFS_bothSet;
+   _NoFiltersSet = false;
+}
+//_____________________________________________________________ setTimeRangeWithoutDate
+// add 941229/vk
+//
+// parameters: in format HHMM, i.e. 1200 == 12.00, 15 == 0.15, i.e. 100*hour+min!!!
+//             values are normalized into range [0000..2400)
+//_________________________________________
+void
+MvObsSetIterator :: setTimeRangeWithoutDate( int aBegin, int anEnd )
+{
+   TDynamicTime aTime;  // date part is not used, so let's use today..
+   int myBegin = aBegin;
+   int myEnd   = anEnd;
+
+   while( myBegin < 0 ) myBegin += 2400;
+   aTime.SetTime( myBegin / 100, myBegin % 100, 0 );
+   fBeginTime = aTime;
+
+   while( myEnd >= 2400 ) myEnd -= 2400;
+   aTime.SetTime( myEnd / 100, myEnd % 100, 0 );
+   fEndTime = aTime;
+
+   _TimeFilterState = kTFS_clockSet;
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setWmoBlock( int aWmoBlockNumber )
+{
+   if( _WmoBlockCount >= MAX_FILTER_LIST_ARRAY_SIZE )
+   {
+      cerr << ">>> MvObsIterator::setWmoBlock: array overflow!!!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "MvObsIterator::setWmoBlock: array overflow!" );
+#endif
+      return;
+   }
+   _WmoBlockNumber[ _WmoBlockCount++ ] = aWmoBlockNumber;
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setWmoStation( long aWmoStation )
+{
+   if( _WmoStationCount >= MAX_FILTER_LIST_ARRAY_SIZE )
+   {
+      cerr << ">>> MvObsIterator::setWmoStation: array overflow!!!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "MvObsIterator::setWmoStation: array overflow!" );
+#endif
+      return;
+   }
+   _WmoStation[ _WmoStationCount++ ] = aWmoStation;
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: select( long aDescriptor
+			  , float aValue )
+{
+   if( _SelectValueCount >= MAX_FILTER_LIST_ARRAY_SIZE )
+   {
+      cerr << ">>> MvObsIterator::select: array overflow!!!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "MvObsIterator::select: array overflow!" );
+#endif
+      return;
+   }
+   if( _SelectValueCount > 0 && aDescriptor != _SelectDescriptor )
+   {
+      cerr << ">>> MvObsIterator::select: changing the descriptor while building the list!!!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "MvObsIterator::select: changing the descriptor while building the list!" );
+#endif
+   }
+  _SelectDescriptor = aDescriptor;
+  _SelectValue[ _SelectValueCount++ ] = aValue;
+  _SelectState = SF_listSet;
+  _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: selectRange( long aDescriptor
+			       , float firstValue
+			       , float secondValue )
+{
+  _SelectDescriptor = aDescriptor;
+  _SelectValue[ 0 ] = firstValue < secondValue ? firstValue : secondValue;
+  _SelectValue[ 1 ] = secondValue > firstValue ? secondValue : firstValue;
+  _SelectValueCount = 2;
+  _SelectState = SF_rangeSet;
+  _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: excludeRange( long aDescriptor
+			        , float firstValue
+			        , float secondValue )
+{
+  _SelectDescriptor = aDescriptor;
+  _SelectValue[ 0 ] = firstValue < secondValue ? firstValue : secondValue;
+  _SelectValue[ 1 ] = secondValue > firstValue ? secondValue : firstValue;
+  _SelectValueCount = 2;
+  _SelectState = SF_excludeRangeSet;
+  _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setXSectionLine( const MvLocation& aStartPoint
+			      , const MvLocation& anEndPoint
+			      , float aDeltaInMeters )
+{
+   fXSectionLine.setLine( aStartPoint, anEndPoint );
+   fXSectionLine.setMaxDelta( aDeltaInMeters );
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setArea( const MvLocation& aCorner1, const MvLocation& aCorner2 )
+{
+   fArea.set( aCorner1, aCorner2 );
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setMessageType( int aMsgType )
+{
+   if( _MsgTypeCount >= MAX_FILTER_LIST_ARRAY_SIZE )
+   {
+      cerr << ">>> MvObsIterator::setMessageType: array overflow!!!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "MvObsIterator::setMessageType: array overflow!" );
+#endif
+      return;
+   }
+   _MsgType[ _MsgTypeCount++ ] = aMsgType;
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+void
+MvObsSetIterator :: setMessageSubtype( int aMsgSubtype )
+{
+   if( _MsgSubtypeCount >= MAX_FILTER_LIST_ARRAY_SIZE )
+   {
+      cerr << ">>> MvObsIterator::setMessageSubtype: array overflow!!!" << endl;
+#ifdef METVIEW
+      marslog( LOG_EROR, "MvObsIterator::setMessageSubtype: array overflow!" );
+#endif
+      return;
+   }
+   _MsgSubtype[ _MsgSubtypeCount++ ] = aMsgSubtype;
+   _NoFiltersSet = false;
+}
+//____________________________________________________________________
+float
+MvObsSetIterator :: distanceFromXSectionLine( const MvLocation& aPoint )
+{
+   if( fXSectionLine.startPoint().latitude() == MISSING_LOC_VALUE )
+   {
+      return MISSING_LOC_VALUE;
+   }
+   return fXSectionLine.deltaInMeters( aPoint );
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: TimeOk( MvObs *anObs ) const
+{
+   switch( _TimeFilterState )
+   {
+   case kTFS_notSet:
+     break;   //return true;
+
+   case kTFS_clockSet:
+     {
+       long obsTime;
+       if( useObsTime_ )
+	 obsTime = anObs->obsTime().ClockInSeconds();  //-- need to decode => slow
+       else
+	 obsTime = anObs->msgTime().ClockInSeconds();  //-- use metadata => fast
+
+       long time1 = fBeginTime.ClockInSeconds();
+       long time2 = fEndTime.ClockInSeconds();
+
+       if( time1 <= time2 )        // e.g.  12-18
+       {
+         if( obsTime < time1 || obsTime > time2 )
+	   return false;
+       }
+       else    // time1 > time2       e.g.  21-03
+       {
+          if( obsTime < time1 && obsTime > time2 )
+	    return false;
+       }
+     }
+     break;
+
+   case kTFS_bothSet:
+     {
+       TDynamicTime myTime;
+       if( useObsTime_ )
+	 myTime = anObs->obsTime();  //-- time from obs => decode first => slow
+       else
+	 myTime = anObs->msgTime();  //-- time from sec1 => no decode => fast
+
+       if( myTime < fBeginTime || myTime > fEndTime )
+          return false;
+     }
+     break;
+   }
+
+   return true;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: WmoBlockOk( MvObs *anObs ) const
+{
+  if( _WmoBlockCount < 1 )
+    return true;
+
+  for( int i = 0; i < _WmoBlockCount; i++ )
+    if( anObs->WmoBlockNumber() == _WmoBlockNumber[ i ] )
+      return true;
+
+  return false;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: WmoStationOk( MvObs *anObs ) const
+{
+   if( _WmoStationCount < 1 )
+      return true;
+
+  for( int i = 0; i < _WmoStationCount; i++ )
+    if( anObs->WmoIdentNumber() == _WmoStation[ i ] )
+      return true;
+
+  return false;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: WithinXSectionLine( MvObs *anObs ) const
+{
+   if( fXSectionLine.maxDelta() < 0 )    // not set ?
+      return true;
+
+   if( fXSectionLine.withinDelta( anObs->location() ) )
+     return true;
+   else
+     return false;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: InsideArea( MvObs *anObs ) const
+{
+   if( fArea.lowerLeft().latitude() == MISSING_LOC_VALUE )
+     return true;
+   else
+     return fArea.inside( anObs->location() );
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: msgTypeOk( MvObs *anObs ) const
+{
+   if( _MsgTypeCount < 1 )
+      return true;
+
+  for( int i = 0; i < _MsgTypeCount; i++ )
+    if( anObs->messageType() == _MsgType[ i ] )
+      return true;
+
+  return false;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: msgSubtypeOk( MvObs *anObs ) const
+{
+   if( _MsgSubtypeCount < 1 )
+      return true;
+
+  for( int i = 0; i < _MsgSubtypeCount; i++ )
+    if( anObs->messageSubtype() == _MsgSubtype[ i ] )
+      return true;
+
+  return false;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: selectOk( MvObs *anObs ) const
+{
+  if( _SelectState == SF_notSet )
+    return true;
+
+  float myValue = anObs->value( _SelectDescriptor );
+  if( myValue == kBufrMissingValue )
+    return false;
+
+  switch( _SelectState )
+  {
+    case SF_notSet:
+
+        break;
+
+    case SF_listSet:
+
+        {
+          for( int i = 0; i < _SelectValueCount; i++ )
+            if( myValue == _SelectValue[ i ] )
+              return true;
+        }
+        return false;
+
+    case SF_rangeSet:
+
+        if( myValue < _SelectValue[ 0 ] || myValue > _SelectValue[ 1 ] )
+          return false;
+        break;
+
+    case SF_excludeRangeSet:
+
+        if( myValue >= _SelectValue[ 0 ] && myValue <= _SelectValue[ 1 ] )
+          return false;
+        break;
+
+  }
+  return true;
+}
+//____________________________________________________________________
+boolean
+MvObsSetIterator :: AcceptedObs( MvObs& anObs ) const
+{
+   if( _NoFiltersSet )
+      return true;
+
+   if( ! msgTypeOk( &anObs ) )         // from Section 1: no decoding required
+      return false;
+   if( ! msgSubtypeOk( &anObs ) )      // from Section 1: no decoding required
+      return false;
+
+   if( ! TimeOk( &anObs ) )            // from Section 1: no decoding required
+      return false;
+
+   if( ! WmoBlockOk( &anObs ) )        // others require decoding of the msg
+      return false;
+   if( ! WmoStationOk( &anObs ) )
+      return false;
+
+   if( ! selectOk( &anObs ) )
+      return false;
+
+   if( ! WithinXSectionLine( &anObs ) )
+      return false;
+
+   if( ! InsideArea( &anObs ) )
+      return false;
+
+   return true;
+}
+//_____________________________________________________________ operator<<
+
+ostream& operator<< ( ostream& aStream, const MvObsSetIterator& aFilter )
+{
+ int i;
+
+  aStream << "Observation Filter values set:\n";
+  if( aFilter._NoFiltersSet )
+  {
+    aStream << "   No filter values set!";
+    aStream << endl;
+  }
+  else
+  {
+    if( aFilter._TimeFilterState != kTFS_notSet )
+    {
+      aStream << "   Timerange: ";
+      switch( aFilter._TimeFilterState )
+      {
+      case kTFS_notSet:
+        aStream << "[not set!]";
+        break;
+
+      case kTFS_clockSet:
+        aStream << aFilter.fBeginTime.GetHour() << ".";
+        aStream.width(2); aStream.fill('0');
+        aStream << aFilter.fBeginTime.GetMin();
+        if( aFilter.fBeginTime != aFilter.fEndTime )
+        {
+          aStream << " - " << aFilter.fEndTime.GetHour() << ".";
+          aStream.width(2); aStream.fill('0');
+          aStream << aFilter.fEndTime.GetMin();
+        }
+        break;
+
+      case kTFS_bothSet:
+        aStream << aFilter.fBeginTime;
+        if( aFilter.fBeginTime != aFilter.fEndTime )
+          aStream << " - " << aFilter.fEndTime;
+        break;
+      }
+      aStream << endl;
+    }
+
+    if( aFilter._MsgTypeCount > 0 )
+    {
+      aStream << "   Message types: ";
+      for( i=0; i < aFilter._MsgTypeCount; i++ )
+        aStream << " " << aFilter._MsgType[ i ];
+      aStream << endl;
+    }
+
+    if( aFilter._MsgSubtypeCount > 0 )
+    {
+      aStream << "   Message subtypes: ";
+      for( i=0; i < aFilter._MsgSubtypeCount; i++ )
+        aStream << " " << aFilter._MsgSubtype[ i ];
+      aStream << endl;
+    }
+
+    if( aFilter._WmoBlockCount > 0 )
+    {
+      aStream << "   WMO Blocks:";
+      for( i=0; i < aFilter._WmoBlockCount; i++ )
+        aStream << " " << aFilter._WmoBlockNumber[ i ];
+      aStream << endl;
+    }
+
+    if( aFilter._WmoStationCount > 0 )
+    {
+      aStream << "   WMO Stations:";
+      for( i=0; i < aFilter._WmoStationCount; i++ )
+        aStream << " " << aFilter._WmoStation[ i ];
+      aStream << endl;
+    }
+
+    if( aFilter._SelectState != SF_notSet )
+    {
+      aStream << "   Select ";
+      switch( aFilter._SelectState )
+      {
+       case SF_notSet:
+         aStream << "by values/range: [not set!]";
+         break;
+
+       case SF_listSet:
+         aStream << "by values: ";
+         break;
+
+       case SF_rangeSet:
+         aStream << "by range: ";
+         break;
+
+       case SF_excludeRangeSet:
+         aStream << "by excluding range: ";
+         break;
+      }
+
+      for( i=0; i < aFilter._SelectValueCount; i++ )
+        aStream << aFilter._SelectValue[ i ] << " ";
+      aStream << "(descr. " << aFilter._SelectDescriptor << ")";
+      aStream << endl;
+    }
+
+    if( aFilter.fXSectionLine.startPoint().latitude() != MISSING_LOC_VALUE )
+    {
+      aStream << "   Cross Section Line: " << aFilter.fXSectionLine;
+      aStream << endl;
+    }
+
+    if( aFilter.fArea.lowerLeft().latitude() != MISSING_LOC_VALUE )
+    {
+      aStream << "   Area: " << aFilter.fArea;
+      aStream << endl;
+    }
+   // aStream << endl;  // calling method should add the final 'endl'!
+  }
+  return aStream;
+}
diff --git a/src/MvObs/MvObsSet.h b/src/MvObs/MvObsSet.h
new file mode 100644
index 0000000..fd67393
--- /dev/null
+++ b/src/MvObs/MvObsSet.h
@@ -0,0 +1,337 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvObsSet.h
+
+
+#ifndef MvObsSet_DEFINED
+#define MvObsSet_DEFINED
+
+//-- <aki> temporarily for testing only; should be done via 'configure'
+#define METVIEW_PREPBUFR
+
+#include "MvBufrObs.h"
+
+class MvPrepBufrPrep;
+
+//--------------------------------------------------------------- MvObsSet
+//! A class to access a file containing observation reports
+/*! This class is used to handle a file containing several
+ *  observation reports stored as BUFR messages.
+ */
+class MvObsSet
+{
+ friend class MvObsSetIterator;
+ friend class MvBufrOut;
+
+	// prevent copy
+
+	MvObsSet( const MvObsSet& );
+	void operator= ( const MvObsSet& );
+	void _init( const char* aFile );
+
+ public:
+
+//! Constructor with the input BUFR file name as an argument
+   MvObsSet( const char* fileName );
+
+//! Constructor with a BUFR file name and access mode as arguments
+/*! This constructor can be used for writing to a file, use
+ *  access mode "w" or "a".
+ */
+   MvObsSet( const char* fileName, const char* accessMode );
+
+#ifdef METVIEW
+//! Constructor with a BUFR request and access mode as arguments
+    MvObsSet( MvRequest&, const char* aMode = "r" );
+
+//! Returns the minimum (earliest) date found in MvObsSet
+    MvDate  minDate();
+
+//! Returns the maximum (latest) date found in MvObsSet
+    MvDate  maxDate();
+#endif
+
+//! Destructor
+   ~MvObsSet();
+
+//! Set max subset count for a new file
+      void  setSubsetMax( int subsetMax );
+
+//! Add one observation report to output file
+      void  add( MvObs& anObs );
+
+//! Rewind the input file
+      void  rewind();
+
+//! Returns the number of BUFR messages in the input file
+/*! This number is smaller than returned by method obsCount()
+ *  if the input file contains multisubset BUFR messages.
+ */
+       int  messageCount(); // nr of BUFR-messages in a file
+
+//! Returns the number of observation reports in the input file
+/*! This number is bigger than returned by method messageCount()
+ *  if the input file contains multisubset BUFR messages.
+ */
+       int  obsCount();     // nr of observation messages in a BUFR-file
+
+//! Returns the (running) number of the current BUFR message
+       int  messageNumber(){ return (int)_msgNumber; }
+
+//! Closes the input/output file
+   boolean  close();
+
+//! Prepares 'PrepBUFR' tables if the input file contains BUFR tables
+      bool  prepBufrFile();
+
+            //-- hack for ObsFilter (vk 970729) --
+      void  write( MvObs& anObs ){ if(_bufrOut) _bufrOut->write( anObs ); }
+
+     MvObs& firstObs(){ return firstObs_; }
+
+ protected:
+     MvObs  next();
+   boolean  Open( const char* fileName );  //, char* aMode = "r" );
+      void  write( const char* aMsg, int aMsgLen );
+      void  searchMinMaxTime();
+ //Logical  currentInputBufferOK() {return _IO_buffer_OK;}
+
+ protected:
+     string  _IO_mode;
+       FILE* _bufrFile;
+       long  _msgNumber;
+       long  _msgCount;
+       long  _obsCount;
+   TDynamicTime  _minTime;
+   TDynamicTime  _maxTime;
+    boolean  _minMaxDone;
+       long  _msgLen;
+       char* _message;
+       bool  _IO_buffer_OK;
+
+  MvPrepBufrPrep* prepBufr_;
+       bool  isPrepBufrFile_;
+      MvObs  firstObs_;
+
+  MvBufrOut* _bufrOut;
+};
+
+//------------------------------------------------------------------------------
+
+const int MAX_FILTER_LIST_ARRAY_SIZE = 100;
+
+//! \enum ENextReturn Mnemonic names to define subset access
+/*! Used in MvObsSetIterator::operator() to tell which
+ *  observation report to return. \n \n
+ *  Use NR_returnMsg to skip the remaining observation reports
+ *  in a multisubset BUFR message that does not contain<aki>
+ *  These mnemonics have an effect only on multisubset
+ *  BUFR messages. For single subset BUFR messages both
+ *  mnemonics function the same.
+ */
+enum ENextReturn
+{
+   NR_returnObs  /**< - return the next available subset (from this or the next BUFR msg */
+  ,NR_returnMsg  /**< - return the first subset from the next BUFR message */
+};
+
+//! \enum ESelectFilterState Used internally by MvObsSetIterator
+enum ESelectFilterState
+{
+   SF_notSet
+  ,SF_listSet
+  ,SF_rangeSet
+  ,SF_excludeRangeSet
+};
+
+//! \enum ETimeFilterState Used internally by MvObsSetIterator
+enum ETimeFilterState
+{
+   kTFS_notSet
+  ,kTFS_clockSet
+  ,kTFS_bothSet
+};
+
+//------------------------------------------------------------ MvObsSetIterator
+//! A class to filter a set of observation reports
+/*! This class is used to filter a file containing several
+ *  observation reports stored in BUFR messages. Several
+ *  different filtering criteria are available. When several
+ *  filtering criteria are set the resulting filter will use
+ *  logical AND to combine different criteria.
+ */
+class MvObsSetIterator
+{
+//! Writes the current filtering options of 'anIter' into stream 'aStream'
+ friend ostream& operator<< ( ostream& aStream, const MvObsSetIterator& anIter );
+
+	MvObs     current;
+	MvObsSet* ObsSet;
+
+ public:
+//! Constructor with a MvObset as an argument
+	MvObsSetIterator( MvObsSet& );
+//! Destructor
+	~MvObsSetIterator();
+
+//! Operator that returns the next available valid observation report
+/*! Subset structure is hidden from the calling application.
+ */
+	MvObs operator() () { return operator()( NR_returnObs ); }
+
+//! Operator that returns the next valid observation report
+/*! Using mnemonic argument 'NR_returnMsg' accesses only first
+ *  subsets in multisubset BUFR messages. See enum ENextReturn.
+ */
+	MvObs operator() ( ENextReturn returnType );
+
+//! Returns the sequence number of the current BUFR message
+     int   msgNumber() { return (ObsSet ? (int)ObsSet->_msgNumber : -1); }
+
+//! Returns the subset number of the current observation report in the BUFR message
+     int   subsetNumber() { return current.subsetNumber(); }
+
+//! Defines where the date/time for filtering should be taken from
+/*! Date and time information is always available as metadata in
+ *  BUFR section 1, and normally also in the data (observation report)
+ *  itself. In single subset messages these times should be the same,
+ *  but for some multisubset messages observation reports may come from
+ *  different times. \n \n
+ *  The default is to use date/time from the metadata in section 1 (faster),
+ *  but by calling this method it is possible to change to use date/time
+ *  from the data.
+ */
+     void  useObsTime( bool b = true ){ useObsTime_ = b; }
+
+//! Set the filtering criteria for a single date/time
+     void  setTime( const TDynamicTime& anObsTime );
+
+//! Set the filtering criteria for a date/time range
+/*! Observation reports that have their data/time within the range
+ *  'anObsTime'-'deltaInMinutes' and 'anObsTime'+'deltaInMinutes'
+ *  will be selected.
+ */
+     void  setTimeRange( const TDynamicTime& anObsTime, short deltaInMinutes );
+
+//! Set the filtering criteria for a date/time range
+     void  setTimeRange( const TDynamicTime& aBeginTime, const TDynamicTime& anEndTime );
+
+//! Set the filtering criteria for time range only (date ignored)
+/*! Observation reports that have their time stamp between 'aBeginTime'
+ *  and 'anEndTime' will be selected. \n \n
+ *  Time format is HHMM, i.e. 100*hours+minutes. Thus the value 1500
+ *  signifies 3PM, and the value 15 signifies 15 mins past midnight.
+ */
+     void  setTimeRangeWithoutDate( int aBegin, int anEnd );
+
+//! Set the filtering criteria for accepted WMO block numbers
+/*! This method can be called several times in order to set
+ *  more than one accepted WMO block, i.e. WMO blocks are
+ *  combined with logical OR operator.
+ */
+     void  setWmoBlock( int aWmoBlock );
+
+//! Set the filtering criteria for accepted WMO station numbers
+/*! This method can be called several times in order to set
+ *  more than one accepted WMO station, i.e. WMO stations are
+ *  combined with logical OR operator.
+ */
+     void  setWmoStation( long aWmoStation );
+
+//! Set the filtering criteria for an accepted area
+/*! Observation report locations must be within the given area.
+ */
+     void  setArea( const MvLocation& aCorner1, const MvLocation& aCorner2 );
+
+//! Set filtering criteria for a proximity of a cross section line
+     void  setXSectionLine( const MvLocation& aStartPoint
+			  , const MvLocation& anEndPoint
+			  , float aDeltaInMeters );
+
+//! Set the filtering criteria for accepted BUFR message types
+/*! This method can be called several times in order to set
+ *  more than one accepted BUFR message type, i.e. message types are
+ *  combined with logical OR operator.
+ */
+     void  setMessageType( int aMsgType );
+
+//! Set the filtering criteria for accepted BUFR message local subtypes
+/*! This method can be called several times in order to set
+ *  more than one accepted BUFR message local subtype, i.e. message subtypes
+ *  are combined with logical OR operator.
+ */
+     void  setMessageSubtype( int aMsgSubtype );
+
+//! Set the filtering criteria for data 'aDescriptor' having value 'aValue'
+/*! Observation reports where the data corresponding to descriptor 'aDescriptor'
+ *  has value 'aValue' will be selected.\n \n
+ *  This method can be called several times in order to set more than one
+ *  accepted value for the same 'aDescriptor', i.e. values are
+ *  combined with logical OR operator.
+
+ */
+     void  select( long aDescriptor
+		 , float aValue );
+
+
+//! Set the filtering criteria for the given data having its value within a range
+/*! Observation reports where the data corresponding to descriptor 'aDescriptor'
+ *  has its value in the range 'firstValue'...'secondValue' will be selected.
+ */
+     void  selectRange( long aDescriptor
+		      , float firstValue
+		      , float secondValue );
+
+//! Set the filtering criteria for the given data having its value outside a range
+/*! Observation reports where the data corresponding to descriptor 'aDescriptor'
+ *  has its value outside the range 'firstValue'...'secondValue' will be selected.
+ */
+     void  excludeRange( long aDescriptor
+		       , float firstValue
+		       , float secondValue );
+
+ protected:
+
+     void  next();
+  boolean  AcceptedObs( MvObs& anObs ) const;
+  boolean  TimeOk( MvObs* anObs ) const;
+  boolean  WmoBlockOk( MvObs* anObs ) const;
+  boolean  WmoStationOk( MvObs* anObs ) const;
+  boolean  WithinXSectionLine( MvObs* anObs ) const;
+  boolean  msgTypeOk( MvObs* anObs ) const;
+  boolean  msgSubtypeOk( MvObs* anObs ) const;
+  boolean  InsideArea( MvObs* anObs ) const;
+  boolean  selectOk( MvObs* anObs ) const;
+    float  distanceFromXSectionLine( const MvLocation& aPoint ); //-- used anywhere?
+
+ protected:
+         boolean  _NoFiltersSet;
+	    bool  useObsTime_;
+        TDynamicTime  fBeginTime, fEndTime;
+      // boolean  fTimeFilterSet;
+ETimeFilterState  _TimeFilterState;
+	     int  _WmoBlockCount;
+             int  _WmoBlockNumber[ MAX_FILTER_LIST_ARRAY_SIZE ];
+	     int  _WmoStationCount;
+            long  _WmoStation[ MAX_FILTER_LIST_ARRAY_SIZE ];
+  MvXSectionLine  fXSectionLine;
+          MvArea  fArea;
+	     int  _MsgTypeCount;
+	     int  _MsgType[ MAX_FILTER_LIST_ARRAY_SIZE ];
+	     int  _MsgSubtypeCount;
+	     int  _MsgSubtype[ MAX_FILTER_LIST_ARRAY_SIZE ];
+ ESelectFilterState _SelectState;
+	    long  _SelectDescriptor;
+	   float  _SelectValue[ MAX_FILTER_LIST_ARRAY_SIZE ];
+	     int  _SelectValueCount;
+};
+
+#endif
+// MvObsSet_DEFINED
diff --git a/src/MvObs/MvPrepBufrPrep.cc b/src/MvObs/MvPrepBufrPrep.cc
new file mode 100644
index 0000000..36e6af5
--- /dev/null
+++ b/src/MvObs/MvPrepBufrPrep.cc
@@ -0,0 +1,553 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvPrepBufrPrep.cc
+
+#include <stdlib.h>
+#include <string.h>
+#include <list>
+#include <set>
+#include <unistd.h>  // for AIX to know symlink()
+#include <sys/stat.h>
+#include "MvPrepBufrPrep.h"
+#include "MvObsSet.h"
+
+const string cNoBufrTablesDir("NO_TABLE_DIR");
+const string cCommonNamePart("_prepbufr.txt");
+const string cAUX_TABLE_B("prepbufr_table_B.txt");
+const string cAUX_TABLE_D("prepbufr_table_D.txt");
+
+
+bool compare_tab_B_elems( const TableB_entry* first, const TableB_entry* second )
+{ return first->descr().compare( second->descr() ) < 0; }
+
+bool compare_tab_D_elems( const TableD_entry* first, const TableD_entry* second )
+{ return first->descr().compare( second->descr() ) < 0; }
+
+
+//______________________________________________________________________
+//
+//   MvPrepBufrPrep
+//______________________________________________________________________
+
+MvPrepBufrPrep::~MvPrepBufrPrep()
+{
+  //revertBufrTablesDir(); //-- this would change nothing as BUFR_TABLES
+                           //-- will not be read anymore
+
+  //string remove = "rm -r " + prepBufrTableDir_ + "/*";
+  //cout << "rm command is: " << remove << endl;
+//  int s = system( remove.c_str() );
+}
+
+//______________________________________________________________________
+
+bool
+MvPrepBufrPrep::prepareAll()
+{
+  bool ok = createPrepBufrTableDir();       //-- new unique subdir to play with table links
+  if( ! ok )
+     return false;
+
+  MvObs firstObs = obsSet_.firstObs();      //-- create links to our tables that are
+  ok = createTablesDecodeLinks( firstObs ); //-- needed to decode prepBUFR tables
+  if( ! ok )
+     return false;
+
+  ok = setNewBufrTablesDir();               //-- (re)assign BUFR_TABLES env.var
+  if( ! ok )
+     return false;
+
+  ok = extractPrepBufrTables();             //-- extract PrepBUFR tables using fixed table names
+  if( ! ok )
+     return false;
+
+  ok = createDataDecodeLinks();             //-- 'bufrdc' file names link to fixed name PrepBUFR tables
+  if( ! ok )
+     return false;
+
+  return true;
+}
+
+//______________________________________________________________________
+
+bool
+MvPrepBufrPrep::createPrepBufrTableDir()
+{
+                                            //-- store current value (if any)
+  const char* oldDir = getenv("BUFR_TABLES");
+  origBufrTableDir_ = oldDir ? oldDir : cNoBufrTablesDir;
+  cout << "MvPrepBufrPrep::prepareTempDir: origBufrTableDir_=" << origBufrTableDir_ << endl;
+
+  //char dirTemplate[1024];                   //-- build template for unique subdir name
+  //strcpy( dirTemplate, getenv("METVIEW_TMPDIR") );
+  //strcat( dirTemplate, "/PrepBufrTablesXXXXXX" );
+
+  // to create a unique temporary directory name without using mkdtemp (which does not
+  // work on AIX), we create a temporary file, append '_dir' and create a directory
+  // with that name. This should be safe in almost 100% of cases...
+
+  char *p;
+  p = tempnam(NULL,"PrepBUFR");
+  string tmpfilename(p);
+  free(p);
+  tmpfilename += "_dir";
+  int ok = mkdir(tmpfilename.c_str(), S_IRWXU);
+
+  if (ok != 0)
+  {
+#ifdef METVIEW
+     marslog( LOG_EROR, "MvPrepBufrPrep::createPrepBufrTableDir: Unable to create directory %s", tmpfilename.c_str() );
+#endif
+     cerr << "MvPrepBufrPrep::createPrepBufrTableDir: Unable to create directory "
+          << tmpfilename
+          << endl;
+     return false;
+  }
+
+  prepBufrTableDir_ = tmpfilename;//mkdtemp(dirTemplate); //-- create a unique subdir for PrepBufr tables
+  cout << "MvPrepBufrPrep::prepareTempDir: prepBufrTableDir_=" << prepBufrTableDir_ << endl;
+
+  return true;
+}
+
+//______________________________________________________________________
+//  Build links (using file names required by 'bufrdc') to custom table
+//  files stored in 'etc', needed to extract PrepBUFR Tables from ObsSet.
+//  This is because PrepBUFR table msgs may require non-existing tables.
+
+bool MvPrepBufrPrep::createTablesDecodeLinks( MvObs& firstObs )
+{
+  ostringstream commonPart;                 //-- build part of filename common to both files
+  int centre    = firstObs.originatingCentre();
+  int subCentre = firstObs.originatingSubCentre();
+  int masterTableVer = firstObs.masterTableVersion();
+  int localTableVer  = firstObs.localTableVersion();
+
+  commonPart << "00"                        //-- discipline: 0 = meteorology
+             << setw(6) << setfill('0') << subCentre
+             << setw(5) << setfill('0') << centre
+             << setw(3) << setfill('0') << masterTableVer
+             << setw(3) << setfill('0') << localTableVer
+             << ".TXT"
+             << ends;
+
+  string table_B_name = prepBufrTableDir_ + "/B" + commonPart.str();
+  string table_D_name = prepBufrTableDir_ + "/D" + commonPart.str();
+
+                                            //-- links to the real table files in dir 'etc'
+  string mvShareDir( getenv("METVIEW_DIR_SHARE") );
+  string etc_auxTable_B = mvShareDir + "/etc/AuxPrepBufrTable_B.txt";
+  string etc_auxTable_D = mvShareDir + "/etc/AuxPrepBufrTable_D.txt";
+
+  string auxTable_B = prepBufrTableDir_ + "/" + cAUX_TABLE_B;
+  string auxTable_D = prepBufrTableDir_ + "/" + cAUX_TABLE_D;
+
+  //--  1) copy table file from etc/share and make writable (we need to append PrepBUFR entries)
+  string copyTableB = "cp " + etc_auxTable_B + " " + auxTable_B + "; chmod u+w " + auxTable_B + ";";
+  cout << copyTableB << endl;
+  int ok = system( copyTableB.c_str() );
+
+  //--  2) create 'bufrex' named link to this file
+  ok = symlink( auxTable_B.c_str(), table_B_name.c_str() );
+  if( ok != 0 )
+  {
+#ifdef METVIEW
+     marslog( LOG_EROR, "Unable to copy auxiliary BUFR Table B" );
+#endif
+     cerr << "Unable to copy auxiliary BUFR Table B" << endl;
+     return false;
+  }
+
+  //--  1) copy table file from etc/share and make writable (we need to append PrepBUFR entries)
+  string copyTableD = "cp " + etc_auxTable_D + " " + auxTable_D + "; chmod u+w " + auxTable_D + ";";
+  cout << copyTableD << endl;
+  ok = system( copyTableD.c_str() );
+
+  //--  2) create 'bufrex' named link to this file
+  ok = symlink( auxTable_D.c_str(), table_D_name.c_str() );
+  if( ok != 0 )
+  {
+#ifdef METVIEW
+     marslog( LOG_EROR, "Unable to create a link into auxiliary BUFR Table D" );
+#endif
+     cerr << "Unable to create a link into auxiliary BUFR Table D" << endl;
+     return false;
+  }
+
+  return true;
+}
+//______________________________________________________________________
+//  Assigns BUFR_TABLES to point to the temporary directory which by now
+//  should contain links to auxiliary BUFR tables needed to decode the
+//  prepBUFR tables, and where the prepBUFR tables will be extracted to.
+
+bool MvPrepBufrPrep::setNewBufrTablesDir()
+{
+  const int overWrite = 1;
+  string newEnvVar = prepBufrTableDir_ + "/";
+
+  int ok = setenv( "BUFR_TABLES", newEnvVar.c_str(), overWrite );
+  if( ok != 0 )
+  {
+#ifdef METVIEW
+     marslog( LOG_EROR, "Unable change to BUFR_TABLES env.variable" );
+#endif
+     cerr << "Unable change to BUFR_TABLES env.variable" << endl;
+     return false;
+  }
+
+  cout << "MvPrepBufrPrep::setNewBufrTablesDir: BUFR_TABLES new values is "
+       << newEnvVar << endl;
+
+  return true;
+}
+//______________________________________________________________________
+//  Build file names for temporary PrepBUFR tables and
+//  extract Table B and Table D from the current ObsSet.
+
+bool MvPrepBufrPrep::extractPrepBufrTables()
+{
+  prepBufrTable_B_ = prepBufrTableDir_ + "/" + cAUX_TABLE_B; //-- build table B filename
+  prepBufrTable_D_ = prepBufrTableDir_ + "/" + cAUX_TABLE_D; //-- build table D filename
+
+  MvTableExtract extract( obsSet_ );
+  return extract.extract( prepBufrTable_B_, prepBufrTable_D_ );
+}
+//______________________________________________________________________
+//  Create links (using 'bufrdc' table file names) to temporary PrepBUFR
+//  table files. Make sure that there are links corresponding to all
+//  'bufrdc' table file names that are needed to decode any BUFR data
+//  message in the current ObsSet.
+//  Note that PrepBUFR ObsSet may contain msgs with different table or
+//  local table version, i.e. we may need several different link names.
+
+bool MvPrepBufrPrep::createDataDecodeLinks()
+{
+  set<string> tables;                       //-- keep track of existing table links
+  set<string>::iterator it;
+
+  obsSet_.rewind();
+  MvObsSetIterator iter( obsSet_ );
+  MvObs obs;
+
+  while( obs = iter() )                     //-- search all msgs for the required 'bufrdc' table names
+  {
+     if( obs.messageType() == 11 )          //-- skip if msg contains BUFR tables
+        continue;
+                                            //-- get values used in building table names
+     int centre    = obs.originatingCentre();
+     int subCentre = obs.originatingSubCentre();
+     int masterTableVer = obs.masterTableVersion();
+     int localTableVer  = obs.localTableVersion();
+
+     ostringstream commonPart;              //-- build part of the filename common to both files
+
+     if( localTableVer == 0 )               //-- bufrdc: if no local tables then uses 00 tables
+        commonPart << "00"                  //-- discipline: 0 = meteorology
+	     << setw(6) << setfill('0') << 0  // subCentre
+	     << setw(5) << setfill('0') << 0  // centre
+	     << setw(3) << setfill('0') << masterTableVer
+	     << setw(3) << setfill('0') << 0  // localTableVer
+	     << ".TXT"
+	     << ends;
+     else                                   //-- bufrdc: need site specific tables
+        commonPart << "00"                  //-- discipline: 0 = meteorology
+	     << setw(6) << setfill('0') << subCentre
+	     << setw(5) << setfill('0') << centre
+	     << setw(3) << setfill('0') << masterTableVer
+	     << setw(3) << setfill('0') << localTableVer
+	     << ".TXT"
+	     << ends;
+                                            //-- build 'bufrdc' style Table B name
+     string table_B_name = prepBufrTableDir_ + "/B" + commonPart.str();
+
+     it = tables.find(table_B_name);        //-- link already created?
+     if( it == tables.end() )               //-- if not, then create it now
+     {
+        int ok = symlink( prepBufrTable_B_.c_str(), table_B_name.c_str() );
+        if( ok != 0 )
+        {
+#ifdef METVIEW
+           marslog( LOG_EROR, "Unable to create a link into PrepBUFR Table B, returned %d", ok );
+#endif
+           cerr << "Unable to create a link into PrepBUFR Table B" << endl;
+           return false;
+        }
+                                            //-- build 'bufrdc' style Table D name
+        string table_D_name = prepBufrTableDir_ + "/D" + commonPart.str();
+        ok = symlink( prepBufrTable_D_.c_str(), table_D_name.c_str() );
+        if( ok != 0 )
+        {
+#ifdef METVIEW
+           marslog( LOG_EROR, "Unable to create a link into PrepBUFR Table D, returned %d", ok );
+#endif
+           cerr << "Unable to create a link into PrepBUFR Table D" << endl;
+           return false;
+        }
+
+  cout << " created table link " << table_B_name << endl;
+
+        tables.insert(table_B_name);        //-- signal that link now exists
+     }
+  }
+  obsSet_.rewind();
+  return true;
+}
+
+//______________________________________________________________________
+//  BUFR_TABLES was previously set to point to the temporary table dir.
+//  Now revert it to point back to the original table dir (or unset if
+//  not set previously).
+void
+MvPrepBufrPrep::revertBufrTablesDir()
+{
+  const int overWrite = 1;
+  if( origBufrTableDir_ == cNoBufrTablesDir )
+     unsetenv( "BUFR_TABLES" );
+  else
+     setenv( "BUFR_TABLES", origBufrTableDir_.c_str(), overWrite );
+}
+
+//______________________________________________________________________
+//
+//   TableB_entry
+//______________________________________________________________________
+
+//______________________________________________________________________
+//  Decode one PrepBUFR Table B descriptor and its definition.
+//
+//  'bufrdc' read cmd is:
+//
+//                    1  2  8  9   73 74  98 99 102 103 115 116 ->119
+//      READ(YENTRY,'(1X,I6,1x,64x,1x,24x,1x,I3,1x,I12,1x,I3)')
+//     1                                         NTABBTR(J),NTABBS (J),
+//     1                                         NTABBRV(J),NTABBDW(J)
+
+
+bool
+TableB_entry::getEntry( MvObs& obs )
+{
+  obs.setNextDescriptor();                  //-- build descriptor F+XX+YYY
+  descriptor_ = obs.stringValue().substr(0,1);
+  obs.setNextDescriptor();
+  descriptor_ += obs.stringValue().substr(0,2);
+  obs.setNextDescriptor();
+  descriptor_ += obs.stringValue().substr(0,3);
+
+  obs.setNextDescriptor();                  //-- data name: line 1 + line 2
+  name_ = obs.stringValue().substr(0,32);
+  obs.setNextDescriptor();
+  name_ += obs.stringValue().substr(0,32);
+
+  obs.setNextDescriptor();                  //-- unit name
+  unit_ = obs.stringValue().substr(0,24);
+
+  obs.setNextDescriptor();                  //-- scale: sign + abs value
+  scale_ = obs.stringValue().substr(0,1);
+  obs.setNextDescriptor();
+  scale_ += obs.stringValue().substr(0,3);
+
+  obs.setNextDescriptor();                  //-- reference value: sign + abs value
+  refval_ = obs.stringValue().substr(0,1);
+  obs.setNextDescriptor();
+  refval_ += obs.stringValue().substr(0,10);
+
+  obs.setNextDescriptor();                  //-- bit field width
+  width_ = obs.stringValue().substr(0,3);
+
+  //-- aki: check  OK...                    //-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  return true;
+}
+//______________________________________________________________________
+
+void
+TableB_entry::writeEntry( ofstream& fout )
+{
+  fout << " " << descriptor_
+       << " " << name_
+       << " " << unit_
+       << " " << scale_
+       << " " << refval_
+       << " " << width_
+       << endl;
+}
+//______________________________________________________________________
+//
+//   TableD_entry
+//______________________________________________________________________
+
+//______________________________________________________________________
+//  Decode one PrepBUFR Table D descriptor and its definition
+
+bool
+TableD_entry::getEntry( MvObs& obs )
+{
+  obs.setNextDescriptor();                  //-- build descriptor F+XX+YYY
+  descriptor_ = obs.stringValue().substr(0,1);
+  obs.setNextDescriptor();
+  descriptor_ += obs.stringValue().substr(0,2);
+  obs.setNextDescriptor();
+  descriptor_ += obs.stringValue().substr(0,3);
+
+  obs.setNextDescriptor();                  //-- maybe text...
+  long descr = obs.MvObs::currentDescriptor();
+  if( (descr/1000) == 205 )                 //-- 2'05'yyy: signify character?
+     obs.setNextDescriptor();               //-- is extra text => skip
+
+  cnt_ = obs.currentValue();                //-- nr of descriptors in the sequence
+
+  if( cnt_ > 0 )
+  {
+    for(int d=0; d<cnt_; ++d)
+    {
+       obs.setNextDescriptor();
+       descrlist_.push_back( obs.stringValue().substr(0,6) );
+    }
+  }
+  else
+    descrlist_.push_back( "777777" );
+
+  //-- aki: check  OK...                    //-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  return true;
+}
+//______________________________________________________________________
+
+void
+TableD_entry::writeEntry( ofstream& fout )
+{
+  fout << " " << descriptor_
+       << setw(3) << cnt_
+       << " " << descrlist_[0]
+       << endl;
+
+  if( cnt_ > 0 )
+  {
+    for(int d=1; d<cnt_; ++d)
+       fout << "           " << descrlist_[d] << endl;
+  }
+
+  descrlist_.clear();
+}
+//______________________________________________________________________
+//
+//   MvTableExtract
+//______________________________________________________________________
+
+bool
+MvTableExtract::initTableFiles( string& prepBufrTable_B, string& prepBufrTable_D )
+{
+  //-- use previously copied aux table file and open it in append mode
+  table_B_.open( prepBufrTable_B.c_str(), ios::app ); //-- append to aux table B
+  if( ! table_B_ )
+  {
+#ifdef METVIEW
+     marslog( LOG_EROR, "Unable to open file %s", prepBufrTable_B.c_str() );
+#endif
+     cerr << "Unable to open file " << prepBufrTable_B << endl;
+     return false;
+  }
+
+  //-- use previously copied aux table file and open it in append mode
+  table_D_.open( prepBufrTable_D.c_str(), ios::app ); //-- append to aux table D
+  if( ! table_D_ )
+  {
+#ifdef METVIEW
+     marslog( LOG_EROR, "Unable to open file %s", prepBufrTable_D.c_str() );
+#endif
+     cerr << "Unable to open file " << prepBufrTable_D << endl;
+     return false;
+  }
+
+  return true;
+}
+//______________________________________________________________________
+//  Extract PrepBUFR Table B and Table D entries into memory, sort the
+//  entries ('bufrdc' requirement), and then finally write the sorted
+//  entries to PrepBUFR table files B and D.
+
+bool
+MvTableExtract::extract( string& prepBufrTable_B, string& prepBufrTable_D )
+{
+                                            //-- open/create table B and D files
+  if( ! initTableFiles( prepBufrTable_B, prepBufrTable_D ) )
+  {
+     return false;
+  }
+
+  list<TableB_entry*> tab_B_list;           //-- for collecting PrepBUFR table B entries
+  list<TableD_entry*> tab_D_list;           //-- for collecting PrepBUFR table D entries
+
+  MvObsSetIterator iter(obsSet_);           //-- ObsSet iterator to select only table msgs
+  iter.setMessageType(11);                  //-- 11: "BUFR tables, complete replacement or update"
+  int msgNum = 0;
+
+  tableMsg_ = iter();                       //-- get first BUFR table msg
+
+  while( tableMsg_ )                        //-- iterate though table msgs
+  {
+    ++msgNum;                               //-- table msg number (for error msgs)
+
+    //-- Each table msg contains three delayed replications (0'31'001):
+    //-- 1st is for Table A (we skip), 2nd for Table B, 3rd for Table D
+
+                                            //-- extract possible table B stuff
+    int count_B = (int)tableMsg_.valueByOccurrence( 2, 31001 );
+    for(int b=0; b<count_B; ++b)
+    {
+      TableB_entry* entry_B = new TableB_entry;
+      if( entry_B->getEntry(tableMsg_) )
+         tab_B_list.push_back(entry_B);
+#ifdef METVIEW
+      else
+         marslog( LOG_EROR, "Error in extracting PrepBUFR Table B entry %d in msg %d", b+1, msgNum );
+#endif
+    }
+                                            //-- extract possible table D stuff
+    int count_D = (int)tableMsg_.valueByOccurrence( 3, 31001 );
+    for(int d=0; d<count_D; ++d)
+    {
+      TableD_entry* entry_D = new TableD_entry;
+      if( entry_D->getEntry(tableMsg_) )
+         tab_D_list.push_back(entry_D);
+#ifdef METVIEW
+      else
+         marslog( LOG_EROR, "Error in extracting PrepBUFR Table D entry %d in msg %d", d+1, msgNum );
+#endif
+    }
+
+    tableMsg_ = iter();                     //-- get next BUFR tables msg
+  }
+
+  tab_B_list.sort( compare_tab_B_elems );   //-- sort prepBUFR Table B entries
+
+  list<TableB_entry*>::iterator bit;        //-- write prepBUFR Table B entries
+  for( bit = tab_B_list.begin(); bit != tab_B_list.end(); bit++ )
+    (*bit)->writeEntry( table_B_ );
+
+  tab_D_list.sort( compare_tab_D_elems );   //-- sort prepBUFR Table D entries
+
+  list<TableD_entry*>::iterator dit;        //-- write prepBUFR Table D entries
+  for( dit = tab_D_list.begin(); dit != tab_D_list.end(); dit++ )
+    (*dit)->writeEntry( table_D_ );
+
+  return true; //-- <aki> add failure checks...
+}
+//______________________________________________________________________
+
+#if 0
+int main()
+{
+  MvObsSet       obsSet( "/var/tmp/vesa/Data/bufr/2011-01-17-CPTEC/gdas1.t00z.prepbufr.nr" );
+  MvTableExtract extract( obsSet );
+  extract.extract();
+}
+#endif
diff --git a/src/MvObs/MvPrepBufrPrep.h b/src/MvObs/MvPrepBufrPrep.h
new file mode 100644
index 0000000..f91585e
--- /dev/null
+++ b/src/MvObs/MvPrepBufrPrep.h
@@ -0,0 +1,117 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// MvPrepBufrPrep.h
+
+#ifndef MvPrepBufrPrep_DEFINED
+#define MvPrepBufrPrep_DEFINED
+
+#include <iostream>
+#include <iomanip>
+#include <vector>
+#include "MvBufrObs.h"
+
+using namespace std;
+
+class MvObsSet;
+
+//_____________________________________________________
+
+class MvPrepBufrPrep // : public MvService
+{
+ private:
+    MvPrepBufrPrep();
+    MvPrepBufrPrep( const MvPrepBufrPrep& anOther );
+    void operator= ( const MvPrepBufrPrep& anOther );
+
+ public:
+    MvPrepBufrPrep( MvObsSet& os ) : obsSet_(os) {}
+    ~MvPrepBufrPrep();
+
+    bool  prepareAll();
+
+ protected:
+    bool  createPrepBufrTableDir();
+    bool  createTablesDecodeLinks( MvObs& firstObs );
+    bool  setNewBufrTablesDir();
+    bool  extractPrepBufrTables();
+    bool  createDataDecodeLinks();
+    void  revertBufrTablesDir();
+
+ private:
+    MvObsSet& obsSet_;                       //-- use a reference to MvObsSet
+    string    origBufrTableDir_;
+    string    prepBufrTableDir_;
+    string    prepBufrTable_B_;
+    string    prepBufrTable_D_;
+};
+
+//_____________________________________________________
+
+class MvTableExtract // : public MvService
+{
+ private:
+    MvTableExtract();
+    MvTableExtract( const MvTableExtract& anOther );
+    void operator= ( const MvTableExtract& anOther );
+
+ public:
+    MvTableExtract( MvObsSet& os ) : obsSet_(os) {}
+    ~MvTableExtract(){}
+
+    bool  extract( string& prepBufrTable_B, string& prepBufrTable_D );
+    bool  initTableFiles( string& prepBufrTable_B, string& prepBufrTable_D );
+
+ private:
+    MvObsSet& obsSet_;                       //-- use a reference to MvObsSet
+    MvObs     tableMsg_;
+    ofstream  table_B_;
+    ofstream  table_D_;
+};
+//_____________________________________________________
+
+class TableB_entry
+{
+ public:
+    TableB_entry(){}
+    ~TableB_entry(){}
+
+    bool getEntry( MvObs& obs );
+    void writeEntry( ofstream& fout );
+    string descr() const { return descriptor_; }
+
+ private:
+    string descriptor_;
+    string name_;
+    string unit_;
+    string scale_;
+    string refval_;
+    string width_;
+};
+//_____________________________________________________
+
+class TableD_entry
+{
+ public:
+    TableD_entry(){}
+    ~TableD_entry(){}
+
+    bool getEntry( MvObs& obs );
+    void writeEntry( ofstream& fout );
+    string descr() const { return descriptor_; }
+
+ private:
+    string descriptor_;
+    int    cnt_;
+    vector<string> descrlist_;
+};
+//_____________________________________________________
+
+#endif
+// MvPrepBufrPrep_DEFINED
diff --git a/src/MvObs/fdyntime.cc b/src/MvObs/fdyntime.cc
new file mode 100644
index 0000000..0c47438
--- /dev/null
+++ b/src/MvObs/fdyntime.cc
@@ -0,0 +1,171 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// rev vk 000802 -------------------------
+
+#include "inc_iostream.h"
+#include <time.h>
+
+#include  "fdyntime.h"
+
+
+const
+int firstYear = 1830;         /* oldest comparable year ! */
+
+static
+int
+   monthLength[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+   dayCount [] = {0, 31, 59, 90,120,151,181,212,243,273,304,334,365};
+static
+const char*
+    weekdays [] = {"Monday", "Tuesday", "Wednesday", "Thursday",
+                   "Friday", "Saturday", "Sunday"};
+
+//_________________________________________________________________________
+// Q&D hack to use Metview Date and Time fields in constructor:
+// - datePart should be <= 10 (relative) or in format YYMMDD (absolute)
+// - timePart is interpreted as hours HH when < 24, otherwise in format HHMM
+
+TDynamicTime :: TDynamicTime ( const long datePart, const long timePart )
+{
+  _setCurrent();
+
+  if( datePart <= 10 )
+    ChangeByDays( (short)datePart );
+  else
+  {
+    if( datePart > 101 )
+      SetDate( (short)(datePart / 10000)
+             , (short)((datePart / 100) % 100)
+             , (short)(datePart % 100) );
+  }
+
+  if( timePart < 24 )
+    SetTime( (short)timePart, 0 ,0 );
+  else
+    SetTime( (short)(timePart / 100), (short)(timePart % 100), 0 );
+}
+
+/**-----------------------------------------------------------------------*/
+
+void TDynamicTime :: ChangeByMinutes(const short minutes)
+{
+    DecodeCompareValue (GetCompareValue() + (long)minutes);
+}
+
+void TDynamicTime :: ChangeByHours(const short hours)
+{
+    DecodeCompareValue (GetCompareValue() + 60L * (long)hours);
+}
+
+void TDynamicTime :: ChangeByDays(const short days)
+{
+    DecodeCompareValue (GetCompareValue() + 60L * 24L * (long)days);
+}
+
+
+long TDynamicTime :: DifferenceInMinutes(const TDynamicTime& anotherTime) const
+{
+    return  GetCompareValue() - anotherTime.GetCompareValue();
+}
+
+long TDynamicTime :: DifferenceInHours (const TDynamicTime& anotherTime) const
+{
+    return  DifferenceInMinutes(anotherTime) / 60L;
+}
+
+long TDynamicTime :: DifferenceInDays (const TDynamicTime& anotherTime) const
+{
+    return  DifferenceInMinutes(anotherTime) / 60L / 24L;
+}
+//_______________________________________________________ ClockInSeconds
+// added 941229/vk
+
+long
+TDynamicTime :: ClockInSeconds( void ) const
+{
+   return 3600L*(long)GetHour() + 60L*(long)GetMin() + (long)GetSec();
+}
+//_______________________________________________________ GetWeekday
+
+short TDynamicTime :: GetWeekday(void) const   // mon=1, tue=2,..., sat=6,  sun=7
+{
+ TDynamicTime Sunday((short)1830, (short)1, (short)4);
+
+   return 1 + DifferenceInDays(Sunday) % 7;
+}
+void TDynamicTime :: PrintWeekday(void) const
+{
+   cout << weekdays [ GetWeekday() - 1 ] ;
+}
+
+
+                                           //  p r i v a t e  functions
+long TDynamicTime :: GetCompareValue(void) const
+{
+ long days = 0;
+
+    for (short v = firstYear; v < GetYear(); ++v)
+        days += (long)DaysInYear (v);
+
+    days += (long)dayCount[GetMonth() - 1] + (long)(GetDay() - 1);
+    if (GetMonth() > 2 && DaysInYear(GetYear()) == 366)
+       ++days;
+
+    return  24L*60L*(long)days
+	      + 60L*(long)GetHour()
+		  + (long)GetMin();
+}
+
+void TDynamicTime :: DecodeCompareValue(const long& aCompareValue)
+{
+ short xYear, xMonth;
+ long  aValue = aCompareValue;
+
+    for (short y = firstYear; aValue >= 0; xYear = y++)
+	aValue -= 24L*60L*(long)DaysInYear (y);
+    if (aValue < 0)
+	aValue += 24L*60L*(long)DaysInYear (xYear);
+
+    for (short m = 1; aValue >= 0; xMonth = m++)
+	aValue -= 24L*60L*(long)DaysInMonth (m, xYear);
+    if (aValue < 0)
+	aValue += 24L*60L*(long)DaysInMonth (xMonth, xYear);
+
+    SetYear (xYear);
+    SetMonth (xMonth);
+    SetDay ( (short)(aValue / (60L*24L) + 1));
+
+    aValue %= (60L*24L);
+    SetHour ( (short)(aValue / 60L) );
+
+    aValue %= 60L;
+    SetMin ( (short)aValue );
+}
+
+short TDynamicTime :: DaysInYear (const short aYear) const
+{
+    if ( (aYear % 4) != 0)
+       return 365;
+    else {
+        if (aYear == 1900)
+            return 365;
+        else
+            return 366;
+    }
+}
+
+short TDynamicTime :: DaysInMonth (const short aMonth, const short aYear) const
+{
+    if (aMonth == 2)
+        return monthLength[1] + DaysInYear(aYear) - 365;
+    else
+        return monthLength[aMonth-1];
+}
+
diff --git a/src/MvObs/fdyntime.h b/src/MvObs/fdyntime.h
new file mode 100644
index 0000000..33ad150
--- /dev/null
+++ b/src/MvObs/fdyntime.h
@@ -0,0 +1,52 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// rev vk 941229 ---------------------------- TDynamicTime
+
+#ifndef __TDYNAMICTIME_H__
+#define __TDYNAMICTIME_H__
+
+#include  "fstatime.h"
+
+class TDynamicTime : public TStaticTime
+{
+ public:
+    TDynamicTime () : TStaticTime() { }
+    TDynamicTime (const TStaticTime& aTime) : TStaticTime (aTime) { }
+    TDynamicTime ( const long datePart, const long timePart );
+    TDynamicTime (const short year, const short month, const short day)
+    : TStaticTime (year, month, day) { }
+    TDynamicTime (const short year, const short month, const short day
+	     ,const short hour, const short minute=0, const short sec=0)
+    : TStaticTime (year, month, day, hour, minute, sec) { }
+
+    void  ChangeByMinutes (const short minutes);
+    void  ChangeByHours (const short hours);
+    void  ChangeByDays (const short days);
+
+    long  DifferenceInMinutes (const TDynamicTime& anotherTime) const;
+    long  DifferenceInHours (const TDynamicTime& anotherTime) const;
+    long  DifferenceInDays (const TDynamicTime& anotherTime) const;
+
+    long  ClockInSeconds( void ) const;  // add/vk 941229
+
+    short GetWeekday(void) const;   // mon=1, tue=2,..., sat=6,  sun=7
+    void  PrintWeekday(void) const;
+
+ protected:
+    long  GetCompareValue ( void ) const;
+    void  DecodeCompareValue (const long& aCompareValue);
+    short DaysInYear (const short aYear) const;
+    short DaysInMonth (const short aMonth, const short aYear) const;
+
+ private:
+};
+
+#endif
+//__TDYNAMICTIME_H__
diff --git a/src/MvObs/fmettim.cc b/src/MvObs/fmettim.cc
new file mode 100644
index 0000000..9f7d1d3
--- /dev/null
+++ b/src/MvObs/fmettim.cc
@@ -0,0 +1,210 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// rev vk 940913 -------------------------- fmettim.cc
+
+#include "inc_iostream.h"
+#include <time.h>
+
+#ifndef __FMETTIM_H__
+#include "fmettim.h"
+#endif//__FMETTIM_H__
+
+//__________________________________________________________________
+
+TMetTime :: TMetTime( void ) : TDynamicTime()
+{
+ TDynamicTime aTimeNow;
+
+   ConstructMetTime( 60 );
+   if( *this > aTimeNow )
+   {
+      PreviousMetTime();
+   }
+}
+//__________________________________________________________________
+
+void TMetTime :: ConstructMetTime( const short timeStepInMinutes )
+{
+   fTimeStepInMinutes = timeStepInMinutes;
+   NearestMetTime();
+}
+//__________________________________________________________________
+
+TMetTime& TMetTime :: operator= ( const TMetTime& aTime )
+{
+   TStaticTime::operator= ( aTime );    // retain present time step
+   NearestMetTime( GetTimeStep() );
+   return *this;
+}
+//__________________________________________________________________
+
+ostream& operator<< ( ostream& oStream, const TMetTime& myTime)
+{
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetDay() << ".";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetMonth() << "." << myTime.GetYear() << " ";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetHour() << ":";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetMin();
+   // no seconds for MetTime!
+
+   return oStream;
+}
+
+//__________________________________________________________________
+
+TMetTime TMetTime :: operator++ ( void )              // prefix++
+{
+   NextMetTime( GetTimeStep() );
+   return *this;
+}
+//__________________________________________________________________
+
+TMetTime TMetTime :: operator++ ( int )              // postfix++
+{
+   NextMetTime( GetTimeStep() );
+   return *this;
+}
+//__________________________________________________________________
+
+TMetTime TMetTime :: operator-- ( void )              // prefix++
+{
+   PreviousMetTime( GetTimeStep() );
+   return *this;
+}
+//__________________________________________________________________
+
+TMetTime TMetTime :: operator-- ( int )              // postfix++
+{
+   PreviousMetTime( GetTimeStep() );
+   return *this;
+}
+//__________________________________________________________________
+
+void TMetTime :: NextMetTime( void )
+{
+   NextMetTime( GetTimeStep() );
+}
+//__________________________________________________________________
+
+void TMetTime :: NextMetTime( const short deltaInMinutes )
+{
+ long extraMinutes = ( 60*GetHour() + GetMin() ) % deltaInMinutes;
+
+   // add observation interval and delete extra minutes (if any)
+   DecodeCompareValue( GetCompareValue() + deltaInMinutes - extraMinutes );
+   SetSec( (short) 0 );
+}
+//__________________________________________________________________
+
+void TMetTime :: PreviousMetTime( void )
+{
+   PreviousMetTime( GetTimeStep() );
+}
+//__________________________________________________________________
+
+void TMetTime :: PreviousMetTime( const short deltaInMinutes )
+{
+ long extraMinutes = ( 60*GetHour() + GetMin() ) % deltaInMinutes;
+
+   if( extraMinutes > 0 )
+      // delete only extra minutes
+      DecodeCompareValue( GetCompareValue() -  extraMinutes );
+   else
+      // subtract given interval
+      DecodeCompareValue( GetCompareValue() - deltaInMinutes );
+
+   SetSec( (short) 0 );
+}
+//__________________________________________________________________
+
+void TMetTime :: NearestMetTime( void )
+{
+   NearestMetTime( GetTimeStep() );
+}
+//__________________________________________________________________
+
+void TMetTime :: NearestMetTime( const short deltaInMinutes )
+{
+ long extraMinutes = ( 60*GetHour() + GetMin() ) % deltaInMinutes;
+
+   if( extraMinutes == 0 )  // already a meteorological time!
+      return;               // add vk 940824
+
+   if( extraMinutes < ( deltaInMinutes - extraMinutes ) )
+       PreviousMetTime( deltaInMinutes );
+   else
+       NextMetTime( deltaInMinutes );
+}
+/*
+//__________________________________________________________________ ???
+
+TMetTime TMetTime :: NextObservation (const short deltaInMinutes) const
+{
+ int minutesSoFar = 60*GetHour() + GetMin();
+ TMetTime aNewTime;
+
+   aNewTime.DecodeCompareValue (GetCompareValue() +
+			(long)(deltaInMinutes - (minutesSoFar % deltaInMinutes))
+			       );
+   aNewTime.SetSec((short) 0);
+   return aNewTime;
+}
+//__________________________________________________________________ ???
+
+TMetTime TMetTime :: PreviousObservation (const short deltaInMinutes) const
+{
+ int minutesSoFar = 60*GetHour() + GetMin();
+ TMetTime aNewTime;
+
+   aNewTime.DecodeCompareValue (GetCompareValue() -
+			 (long)(minutesSoFar % deltaInMinutes)
+			       );
+   aNewTime.SetSec((short) 0);
+   return aNewTime;
+}
+//__________________________________________________________________ ???
+
+TMetTime TMetTime :: NearestObservation (const short deltaInMinutes) const
+{
+ int minutesSoFar = 60*GetHour() + GetMin();
+
+   if ( (deltaInMinutes - (minutesSoFar % deltaInMinutes)) <
+	(minutesSoFar % deltaInMinutes))
+       return NextObservation (deltaInMinutes);
+   else
+       return PreviousObservation (deltaInMinutes);
+}
+*/
+//__________________________________________________________________
+
+void TMetTime :: SetTimeStep( const short timeStepInMinutes )
+{
+   fTimeStepInMinutes = timeStepInMinutes;
+}
+//__________________________________________________________________
+
+short TMetTime :: GetTimeStep( void ) const
+{
+   return fTimeStepInMinutes;
+}
+//__________________________________________________________________
+
+short TMetTime :: GetLocalHour () const
+{
+   return (GetHour() + 2) % 24;   //testiarvona vakioero
+}
+
diff --git a/src/MvObs/fmettim.h b/src/MvObs/fmettim.h
new file mode 100644
index 0000000..cd94c50
--- /dev/null
+++ b/src/MvObs/fmettim.h
@@ -0,0 +1,76 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// rev vk 941021 ------------------------- TMetTime
+
+#ifndef __FMETTIM_H__
+#define __FMETTIM_H__
+
+#include  "fdyntime.h"
+
+// TMetTime: Discrete time object for meteorological observations and
+//           forecasts.  Watch out for the "="-operator and constructors
+//           with 'out of phase' times as the TMetTime object will always
+//           try to fit itself into 'the correct phase'!
+
+class TMetTime : public TDynamicTime
+{
+ friend ostream& operator<< ( ostream& oStream, const TMetTime& myTime);
+
+ public:
+    TMetTime( void );                               // latest present MetTime
+             // : TDynamicTime();  // { ConstructMetTime( 60 ); }
+    TMetTime( const int timeStepInMinutes )
+     : TDynamicTime() { ConstructMetTime( timeStepInMinutes ); }
+    TMetTime ( const long datePart, const long timePart )
+    : TDynamicTime ( datePart,  timePart ) { SetTimeStep( 60 ); }
+    TMetTime( const TMetTime& aMetTime )
+     : TDynamicTime( aMetTime ) { SetTimeStep( aMetTime.GetTimeStep() ); }
+
+    TMetTime( const TStaticTime& aTime )
+     : TDynamicTime( aTime ) { ConstructMetTime( 60 ); }
+    TMetTime( const short year, const short month, const short day )
+     : TDynamicTime( year, month, day ) { ConstructMetTime( 60 ); }
+    TMetTime( const short year, const short month, const short day
+	    , const short hour, const short minute=0, const short sec=0 )
+     : TDynamicTime( year, month, day
+	       , hour, minute, sec ) { ConstructMetTime( 60 ); }
+
+    TMetTime& operator= ( const TMetTime& );
+    TMetTime  operator++ ( void );          // prefix
+    TMetTime  operator++ ( int );           // postfix
+    TMetTime  operator-- ( void );          // prefix
+    TMetTime  operator-- ( int );           // postfix
+
+    void NextMetTime( void );
+    void NextMetTime( const short deltaInMinutes );
+    void PreviousMetTime( void );
+    void PreviousMetTime( const short deltaInMinutes );
+    void NearestMetTime( void );
+    void NearestMetTime( const short deltaInMinutes );
+    // I think these should change the internal value of the object, but return the
+    // new value, leaving the object unchanged values! For the sake of clarity, should be
+    // GetNextObservation (), Get ...
+//    TMetTime NextObservation( const short deltaInMinutes ) const;
+//    TMetTime PreviousObservation( const short deltaInMinutes ) const;
+//    TMetTime NearestObservation( const short deltaInMinutes ) const;
+
+    void  SetTimeStep( const short timeStepInMinutes );
+    short GetTimeStep( void ) const;
+
+    short GetLocalHour () const;
+
+ private:
+    void  ConstructMetTime( const short timeStepInMinutes );
+
+ private:
+    short fTimeStepInMinutes;
+};
+
+#endif //__FMETTIM_H__
diff --git a/src/MvObs/fobject.cc b/src/MvObs/fobject.cc
new file mode 100644
index 0000000..2f81576
--- /dev/null
+++ b/src/MvObs/fobject.cc
@@ -0,0 +1,39 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// fobject.cpp
+// rev vk 940824
+
+#include <stddef.h>
+#include "inc_iostream.h"
+
+#include  "fobject.h"
+
+//_________________________________________________________ TFObject
+
+TFObject::TFObject(void)
+{
+}
+//_________________________________________________________ ~TFObject
+
+TFObject::~TFObject(void)
+{
+}
+//_________________________________________________________ operator==
+
+bool TFObject::operator == (const TFObject & aObjTest) const
+{
+  return (IsEqual ( aObjTest ));
+}
+//_________________________________________________________ operator!=
+
+bool TFObject::operator != (const TFObject & aObjTest) const
+{
+  return (bool) ( !(IsEqual ( aObjTest )));
+}
diff --git a/src/MvObs/fobject.h b/src/MvObs/fobject.h
new file mode 100644
index 0000000..bbefb97
--- /dev/null
+++ b/src/MvObs/fobject.h
@@ -0,0 +1,29 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// fobject.h
+// rev vk 940630
+
+#ifndef __TOBJECT_H__
+#define __TOBJECT_H__
+
+
+class TFObject
+{
+ public:
+    TFObject(void);
+    virtual ~TFObject(void);
+
+    virtual bool    IsEqual(const TFObject &) const = 0;
+
+    bool operator == (const TFObject &aObjTest) const;
+    bool operator != (const TFObject &aObjTest) const;
+};
+
+#endif //__TOBJECT_H__
diff --git a/src/MvObs/fsortabl.cc b/src/MvObs/fsortabl.cc
new file mode 100644
index 0000000..f13e641
--- /dev/null
+++ b/src/MvObs/fsortabl.cc
@@ -0,0 +1,40 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// fsortabl.cc
+// rev vk 940824
+
+#include  "fsortabl.h"
+
+bool TSortable::operator <  (const TSortable & aDateObject) const
+{
+  return (IsLessThan(aDateObject) );
+}
+
+
+bool TSortable::operator >  (const TSortable & aDateObject) const
+{
+  return (bool) (!( *this < aDateObject ) &&  (*this != aDateObject));
+}
+
+
+bool TSortable::operator >=  (const TSortable & aDateObject) const
+{
+  return (bool) (!(*this < aDateObject));
+}
+
+bool TSortable::operator <=  (const TSortable & aDateObject) const
+{
+  return (bool) ( *this < aDateObject || *this == aDateObject );
+}
+
+
+
+
+
diff --git a/src/MvObs/fsortabl.h b/src/MvObs/fsortabl.h
new file mode 100644
index 0000000..6256c0e
--- /dev/null
+++ b/src/MvObs/fsortabl.h
@@ -0,0 +1,34 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// fsortabl.h
+// rev vk 940824
+
+#ifndef __TSORTABLE_H__
+#define __TSORTABLE_H__
+
+#include  "fobject.h"
+
+
+class TSortable : public TFObject {
+public:
+
+  virtual bool IsEqual(const TFObject & aDateObject) const = 0;
+  virtual bool IsLessThan(const TFObject & aDateObject) const = 0;
+
+  // methods as 'const', vk 940824
+  bool operator <  (const TSortable&) const;
+  bool operator >  (const TSortable&) const;
+  bool operator >= (const TSortable&) const;
+  bool operator <= (const TSortable&) const;
+
+};
+
+#endif
+//__TSORTABLE_H__
diff --git a/src/MvObs/fstatime.cc b/src/MvObs/fstatime.cc
new file mode 100644
index 0000000..a59a1d2
--- /dev/null
+++ b/src/MvObs/fstatime.cc
@@ -0,0 +1,354 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// rev vk 981001 --------------------- fstatime.cc
+
+#include <time.h>
+#include "inc_iostream.h"
+
+#include  "fstatime.h"
+
+
+static char charValueString[ 100 ];
+
+
+/**-----------------------------------------------------------------------*/
+
+TStaticTime :: TStaticTime (void)
+{
+   _setCurrent();
+}
+//__________________________________________________________________
+
+TStaticTime :: TStaticTime(const TStaticTime &from)
+{
+   fYear = from.fYear;
+   fMonth = from.fMonth;
+   fDay = from.fDay;
+   fHour = from.fHour;
+   fMin = from.fMin;
+   fSec = from.fSec;
+}
+//__________________________________________________________________
+
+TStaticTime :: TStaticTime (const short aY, const short aM, const short aD)
+{
+   SetDate (aY, aM, aD);
+   SetTime (0, 0, 0);
+}
+//__________________________________________________________________
+
+TStaticTime :: TStaticTime (const short aY, const short aM, const short aD
+		           ,const short aH, const short aMin, const short aSec)
+{
+   SetDate (aY, aM, aD);
+   SetTime (aH, aMin, aSec);
+}
+//__________________________________________________________________
+ void
+TStaticTime :: _setCurrent( void )
+{
+time_t     tTime;
+ struct tm *xTime;
+
+   (void) time (&tTime);
+   xTime = localtime (&tTime);
+
+   SetYear (xTime->tm_year + 1900);
+   SetMonth(xTime->tm_mon + 1);
+   SetDay  (xTime->tm_mday);
+   SetHour (xTime->tm_hour);
+   SetMin  (xTime->tm_min);
+   SetSec  (xTime->tm_sec);
+}
+//__________________________________________________________________
+
+TStaticTime& TStaticTime::operator= (const TStaticTime &from)       //   =
+{
+   fYear = from.fYear;
+   fMonth = from.fMonth;
+   fDay = from.fDay;
+   fHour = from.fHour;
+   fMin = from.fMin;
+   fSec = from.fSec;
+   return *this;
+}
+//__________________________________________________________________
+//            "yyyy-mm-dd"
+const char*
+TStaticTime::CharDate() const
+{
+   ostrstream ss( charValueString, sizeof( charValueString ) );
+   ss << setfill( '0' )
+      << setw( 4 ) << GetYear() << "-"
+      << setw( 2 ) << GetMonth() << "-"
+      << setw( 2 ) << GetDay() << ends;
+
+   return charValueString;
+}
+//__________________________________________________________________
+//            "hh:mm"
+const char*
+TStaticTime::CharHhMm() const
+{
+   ostrstream ss( charValueString, sizeof( charValueString ) );
+   ss << setfill( '0' )
+      << setw( 2 ) << GetHour() << ":"
+      << setw( 2 ) << GetMin()  << ends;
+
+   return charValueString;
+}
+//__________________________________________________________________
+//            "yyyy-mm-dd hh:mm:ss"
+const char*
+TStaticTime::CharValue( void ) const
+{
+   ostrstream ss( charValueString, sizeof( charValueString ) );
+   ss << CharDate() << " "
+      << setfill( '0' )
+      << setw( 2 ) << GetHour() << ":"
+      << setw( 2 ) << GetMin() << ":"
+      << setw( 2 ) << GetSec() << ends;
+
+   return charValueString;
+}
+//__________________________________________________________________
+//            "yymmdd hhmm"
+const char*
+TStaticTime::ShorterCharValue( void ) const
+{
+   ostrstream ss( charValueString, sizeof( charValueString ) );
+   ss << setfill( '0' )
+      << setw( 2 ) << ( GetYear() % 100 )
+      << setw( 2 ) << GetMonth()
+      << setw( 2 ) << GetDay() << " "
+      << setw( 2 ) << GetHour()
+      << setw( 2 ) << GetMin() << ends;
+
+   return charValueString;
+}
+//__________________________________________________________________
+
+bool TStaticTime :: IsEqual (const TFObject& anotherTime) const
+{
+   if (GetYear()  != ((const TStaticTime *)&anotherTime)->GetYear())
+      return false;
+
+   if (GetMonth() != ((const TStaticTime *)&anotherTime)->GetMonth())
+      return false;
+
+   if (GetDay()   != ((const TStaticTime *)&anotherTime)->GetDay())
+      return false;
+
+   if (GetHour()  != ((const TStaticTime *)&anotherTime)->GetHour())
+      return false;
+
+   if (GetMin()   != ((const TStaticTime *)&anotherTime)->GetMin())
+      return false;
+
+   if (GetSec()   != ((const TStaticTime *)&anotherTime)->GetSec())
+      return false;
+
+   return true;
+}
+//__________________________________________________________________
+
+bool TStaticTime :: IsLessThan (const TFObject& anotherTime) const
+{
+   if (GetYear()  > ((const TStaticTime *)&anotherTime)->GetYear())
+      return false;
+   else
+   {
+      if (GetYear()  < ((const TStaticTime *)&anotherTime)->GetYear())
+	 return true;
+   }
+
+   if (GetMonth() > ((const TStaticTime *)&anotherTime)->GetMonth())
+      return false;
+   else
+   {
+      if (GetMonth() < ((const TStaticTime *)&anotherTime)->GetMonth())
+	 return true;
+   }
+
+   if (GetDay() > ((const TStaticTime *)&anotherTime)->GetDay())
+      return false;
+   else
+   {
+      if (GetDay() < ((const TStaticTime *)&anotherTime)->GetDay())
+	 return true;
+   }
+
+   if (GetHour() > ((const TStaticTime *)&anotherTime)->GetHour())
+      return false;
+   else
+   {
+      if (GetHour() < ((const TStaticTime *)&anotherTime)->GetHour())
+	 return true;
+   }
+
+   if (GetMin() > ((const TStaticTime *)&anotherTime)->GetMin())
+      return false;
+   else
+   {
+      if (GetMin() < ((const TStaticTime *)&anotherTime)->GetMin())
+	 return true;
+   }
+
+   if (GetSec() < ((const TStaticTime *)&anotherTime)->GetSec())
+      return true;
+
+   return false;
+}
+
+//__________________________________________________________________
+
+void TStaticTime :: SetYear (const short aYear)
+{
+   fYear = aYear;
+
+   if (fYear < 25)
+      fYear += 2000;       //-- assume 2000+
+
+   if (fYear < 200)
+      fYear += 1900;       //-- assume 1900+
+}
+void TStaticTime :: SetMonth (const short aMonth)
+{
+   if (aMonth >= 1 && aMonth <= 12)
+      fMonth = aMonth;
+   else {
+      fMonth = 0;
+      cerr << "'TStaticTime::SetMonth': erroneous month value: "
+	   << aMonth << "\n";
+   }
+}
+void TStaticTime :: SetDay (const short aDay)
+{
+   if (aDay >= 1 && aDay <= 31)
+      fDay = aDay;
+   else {
+      fDay = 0;
+      cerr << "'TStaticTime::SetDay': erroneous day value: "
+	   << aDay << "\n";
+   }
+}
+//__________________________________________________________________
+
+void TStaticTime :: SetHour (const short aHour)
+{
+   if (aHour >= 0 && aHour <=23)
+      fHour = aHour;
+   else {
+      fHour = 0;
+      cerr << "'TStaticTime::SetHour': erroneous hour value: "
+	   << aHour << "\n";
+   }
+}
+
+void TStaticTime :: SetMin (const short aMin)
+{
+   if (aMin >= 0 && aMin <= 59)
+      fMin = aMin;
+   else {
+      fMin = 0;
+      cerr << "'TStaticTime::SetMin': erroneous minutes value: "
+	   << aMin << "\n";
+   }
+}
+
+void TStaticTime :: SetSec (const short aSec)
+{
+   if (aSec >= 0 && aSec <=59)
+      fSec = aSec;
+   else {
+      fSec = 0;
+      cerr << "'TStaticTime::SetSec': erroneous seconds value: "
+	   << aSec << "\n";
+   }
+}
+//__________________________________________________________________
+
+void TStaticTime ::  SetDate(const short year, const short month, const short day)
+{
+   SetYear(year);
+   SetMonth(month);
+   SetDay(day);
+}
+void TStaticTime ::  GetDate(short &year, short &month, short &day) const
+{
+   year = GetYear();
+   month = GetMonth();
+   day = GetDay();
+}
+void TStaticTime ::  SetTime(const short hour, const short minute, const short sec)
+{
+   SetHour(hour);
+   SetMin(minute);
+   SetSec(sec);
+}
+void TStaticTime ::  GetTime(short &hour, short &minute, short &sec) const
+{
+   hour = GetHour();
+   minute = GetMin();
+   sec =GetSec();
+}
+//__________________________________________________________________
+
+void TStaticTime :: ReadDateTime(void)                   // test function!!!!
+{
+ short y,m,d,h;
+   cout << " Input date 'yy mm dd hh': ";
+   cin >> y >> m >> d >> h;
+   SetDate(y,m,d);
+   SetTime(h,0,0);
+}
+//__________________________________________________________________
+
+void TStaticTime :: XPrint(void) const			  // test function!!!!
+{
+    Print();
+}
+void TStaticTime :: XPrint(const char *str) const	          // test function!!!!
+{
+    cout << str << ": ";
+    XPrint();
+}
+//__________________________________________________________________
+
+void TStaticTime :: Print(void) const			  // test function!!!!
+{
+    cout << fDay << "." << fMonth << "." << fYear << " "
+	 << fHour << ":" << fMin   << ":" << fSec ; //<< "\n";
+}
+//__________________________________________________________________
+
+ostream& operator<< ( ostream& oStream, const TStaticTime& myTime)
+{
+   oStream << myTime.CharValue();  //-- ISO date format
+#if 0
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetDay() << ".";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetMonth() << "." << myTime.GetYear() << " ";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetHour() << ":";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetMin() << ":";
+   oStream.width( 2 );
+   oStream.fill( '0' );
+   oStream << myTime.GetSec();
+#endif
+   return oStream;
+}
+
diff --git a/src/MvObs/fstatime.h b/src/MvObs/fstatime.h
new file mode 100644
index 0000000..01560ae
--- /dev/null
+++ b/src/MvObs/fstatime.h
@@ -0,0 +1,80 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// rev vk 970214 -------------------------- TStaticTime
+
+#ifndef __TSTATICTIME_H__
+#define __TSTATICTIME_H__
+
+#include  "inc_iostream.h"
+#include  "fsortabl.h"
+#ifdef METVIEW
+#include  "MvDate.h"
+#endif
+
+
+class TStaticTime : public TSortable
+{
+ friend ostream& operator<< ( ostream& oStream, const TStaticTime& myTime);
+
+ public:
+    TStaticTime ();
+    TStaticTime (const TStaticTime&);
+    TStaticTime (const short year, const short month, const short day);
+    TStaticTime (const short year, const short month, const short day
+		,const short hour, const short minute=0, const short sec=0);
+
+    virtual bool IsEqual (const TFObject& anotherTime) const;
+    virtual bool IsLessThan (const TFObject& anotherTime) const;
+
+    TStaticTime& operator= (const TStaticTime&);
+#ifdef METVIEW
+    operator MvDate( void ) const { return MvDate( CharValue() ); }
+#endif
+    void  SetDate (const short year, const short month, const short day);
+    void  GetDate (short &year, short &month, short &day) const;
+    void  SetTime( const short hour, const short min=0, const short sec=0 );
+    void  GetTime (short &hour, short &min, short &sec) const;
+
+   short  GetYear( void ) const  { return fYear; }
+   short  GetMonth( void ) const { return fMonth; }
+   short  GetDay( void ) const   { return fDay; }
+   short  GetHour( void ) const  { return fHour; }
+   short  GetMin( void ) const   { return fMin; }
+   short  GetSec( void ) const   { return fSec; }
+   // short GetLocalHour () const;
+   const char* CharDate() const;
+   const char* CharHhMm() const;
+   const char* CharValue( void ) const;
+   const char* ShorterCharValue( void ) const;
+
+    void  ReadDateTime ();                     // for testing
+    void  XPrint (void) const;                 // for testing
+    void  XPrint (const char *str) const;      // for testing
+    virtual void Print (void) const;
+
+ protected:
+    void  SetYear (const short year);
+    void  SetMonth (const short month);
+    void  SetDay (const short day);
+    void  SetHour (const short hour);
+    void  SetMin (const short minute);
+    void  SetSec (const short sec);
+    void  _setCurrent( void );
+
+ private:
+    short   fYear;
+    short   fMonth;
+    short   fDay;
+    short   fHour;
+    short   fMin;
+    short   fSec;
+};
+
+#endif //__TSTATICTIME_H__
diff --git a/src/MvObs/inc_iostream.h b/src/MvObs/inc_iostream.h
new file mode 100644
index 0000000..449fd26
--- /dev/null
+++ b/src/MvObs/inc_iostream.h
@@ -0,0 +1,77 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+// inc_iostream.h                                 040727/vk, revised 110812/ir
+
+// include and set up iostream facilities
+
+
+#ifndef _INC_IOSTREAM_H_
+#define _INC_IOSTREAM_H_
+
+# include <iostream>
+# include <fstream>
+# include <sstream>
+# include <strstream>
+# include <iomanip>
+
+ using std::istream;
+ using std::ostream;
+ using std::ifstream;
+ using std::ofstream;
+ using std::istrstream;
+ using std::ostrstream;
+ using std::istringstream;
+ using std::ostringstream;
+ using std::cin;
+ using std::cout;
+ using std::cerr;
+ using std::endl;
+ using std::ends;
+ using std::flush;
+ using std::ios;
+ using std::streambuf;
+ using std::setfill;
+ using std::setw;
+
+// using std:: ;
+
+ typedef ios::openmode tOpenMode;
+
+
+
+// we need to repeat this from mars.h because fstream
+// includes cstdio which redefines these functions and kills the
+// support for >2GB files (on some filesystems). We can detect this by
+// checking whether fopen() has been undefined.
+
+#if !defined(fopen)
+  #ifdef LARGE_FILES_SUPPORT
+    #ifdef linux
+      #define fopen(a,b)   (FILE*)fopen64(a,b)
+    #else
+      #define fopen(a,b)   fopen64(a,b)
+    #endif
+    #define fseek(a,b,c) fseeko64(a,b,c)
+    #define ftell(a)     ftello64(a)
+    #define fsetpos(a,b) fsetpos64(a,b,c)
+    #define fgetpos(a,b) fgetpos64(a,b)
+    #define lseek(a,b,c) lseek64(a,b,c)
+    #define lstat(a,b)   lstat64(a,b)
+    #define fstat(a,b)   fstat64(a,b)
+    #define stat         stat64
+  #endif
+#endif
+
+// end of repeat from mars.h
+
+
+
+#endif
+// _INC_IOSTREAM_H_
diff --git a/src/VectorOfPointers.h b/src/VectorOfPointers.h
new file mode 100644
index 0000000..ff90a6e
--- /dev/null
+++ b/src/VectorOfPointers.h
@@ -0,0 +1,133 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*!
+ \author <a href="http://ootips.org/yonat/4dev/">Yonat Sharon</a>
+
+ * VectorOfPointers - auto-cleaning container of pointers
+ *
+ * Example usage:
+ * {
+ *     VectorOfPointers< std::vector<int*> > v;
+ *     // v can be manipulated like any std::vector<int*>.
+ *
+ *     v.push_back(new int(42));
+ *     v.push_back(new int(17));
+ *     // v now owns the allocated int-s
+ *
+ *     v.erase(v.begin());
+ *     // frees the memory allocated for the int 42, and then removes the
+ *     // first element of v.
+ * }
+ * // v's destructor is called, and it frees the memory allocated for
+ * // the int 17.
+ *
+ * Notes:
+ * 1. Assumes all elements are unique (you don't have two elements
+ *    pointing to the same object, otherwise you might delete it twice).
+ * 2. Not usable with pair associative containers (map and multimap).
+ * 3. For ANSI-challenged compilers, you may want to #define
+ *    NO_MEMBER_TEMPLATES.
+ *
+ * Written 10-Jan-1999 by Yonat Sharon <yonat at ootips.org>
+ * Last updated 07-Feb-1999
+ */
+
+#ifndef VectorOfPointers_H
+#define VectorOfPointers_H
+
+template <typename TContainer>
+class VectorOfPointers : public TContainer
+{
+public:
+	typedef VectorOfPointers<TContainer> its_type;
+
+	VectorOfPointers(){}
+	VectorOfPointers(const TContainer& c):TContainer(c) {}
+	its_type& operator=(const TContainer& c)
+		{TContainer::operator=(c); return *this;}
+	~VectorOfPointers()
+		{clean_all();}
+        void simple_clear(){ TContainer::clear();} //Do nor delete the pointers!
+	void clear()
+		{clean_all(); TContainer::clear();}
+	typename TContainer::iterator erase(typename TContainer::iterator i) 
+		{clean(i); return TContainer::erase(i);}
+	typename TContainer::iterator erase(typename TContainer::iterator f, typename TContainer::iterator l)
+		{clean(f,l); return TContainer::erase(f,l);}
+
+	//! for associative containers: erase() a value
+	typename TContainer::size_type erase(const typename TContainer::value_type& v)
+	{
+		typename TContainer::iterator i = find(v);
+		typename TContainer::size_type found(i != this->end()); // can't have more than 1
+		if (found) erase(i);
+		return found;
+	}
+
+	//! for sequence containers: pop_front(), pop_back(), resize() and assign()
+	void pop_front() {clean(this->begin()); TContainer::pop_front();}
+	void pop_back()  {typename TContainer::iterator i(this->end()); clean(--i); TContainer::pop_back();}
+
+	void resize(typename TContainer::size_type s, typename TContainer::value_type c = typename TContainer::value_type())
+	{
+		if (s < this->size()) clean(this->begin()+s, this->end());
+	typename TContainer::resize(s, c);
+	}
+	
+	template <class InIter> void assign(InIter f, InIter l)
+	{
+		clean_all();
+		TContainer::assign(f,l);
+	}
+	
+	template <class Size, class T> void assign(Size n, const T& t = T())
+	{
+		clean_all();
+		TContainer::assign(n,t);
+	}
+    
+	//! for std::list: remove() and remove_if()
+	void remove(const typename TContainer::value_type& v)
+	{
+		clean( std::find(this->begin(), this->end(), v) );
+		TContainer::remove(v);
+	}
+
+	template <class Pred>
+	void remove_if(Pred pr)
+	{
+		for (typename TContainer::iterator i = this->begin(); i != this->end(); ++i)
+		if (pr(*i)) clean(i);
+		TContainer::remove_if(pr);
+	}
+
+private:
+	void clean(typename TContainer::iterator i)
+		{delete *i;}
+	void clean(typename TContainer::iterator f, typename TContainer::iterator l)
+		{while (f != l) clean(f++);}
+	void clean_all()
+		{clean( this->begin(), this->end() );}
+
+	//! we can't have two VectorOfPointerss own the same objects:
+	VectorOfPointers(const its_type&) {}
+	its_type& operator=(const its_type&) {}
+};
+
+#endif // VectorOfPointers_H
diff --git a/src/basic/BasicGraphicsObject.cc b/src/basic/BasicGraphicsObject.cc
new file mode 100644
index 0000000..dd4499d
--- /dev/null
+++ b/src/basic/BasicGraphicsObject.cc
@@ -0,0 +1,98 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File BasicGraphicsObject.cc
+// Magics Team - ECMWF 2004
+
+#include "BasicGraphicsObject.h"
+#include "BaseDriver.h"
+
+using namespace magics;
+
+BasicGraphicsObject::BasicGraphicsObject() : 
+	parent_(0)
+{
+}
+
+BasicGraphicsObject::~BasicGraphicsObject() 
+{
+
+}
+
+void BasicGraphicsObject::print(ostream& out) const
+{
+	out << "BasicGraphicsObject[";
+	out << "]";
+}
+
+void BasicGraphicsObjectContainer::print(ostream& out) const
+{
+	out << "BasicGraphicsObjectContainer[";
+	for (vector<BasicGraphicsObject*>::const_iterator object = objects_.begin(); object!= objects_.end(); ++object) 
+		out << **object << endl;
+	out << "]";
+}
+
+
+bool BasicGraphicsObjectContainer::buildTree(const Layout& parent, unsigned int frame, const BaseDriver& driver) const
+{
+	bool more = false;
+	for (vector<BasicGraphicsObject*>::const_iterator object = objects_.begin(); object!= objects_.end(); ++object){
+		if ( (*object)->buildTree(parent, frame, driver ) )
+			more = true;
+	}
+	return more;
+}
+
+void BasicGraphicsObjectContainer::visit(const BaseDriver& driver) const
+{
+	for (vector<BasicGraphicsObject*>::const_iterator object = objects_.begin(); object!= objects_.end(); ++object) 
+			(*object)->redisplay(driver);
+	for (vector<BasicGraphicsObject*>::const_iterator object = last_.begin(); object!= last_.end(); ++object)
+				(*object)->redisplay(driver);
+}
+
+BasicGraphicsObjectContainer::~BasicGraphicsObjectContainer()
+{
+	MagLog::debug() << "delete CONTAINER" << objects_.size() << endl;
+	for (vector<BasicGraphicsObject*>::iterator object = objects_.begin(); object!= objects_.end(); ++object) {
+		if (*object)
+			delete *object;
+		*object = 0;
+	}
+	objects_.clear();
+}
+
+void BasicGraphicsObjectContainer::clear()
+{
+	MagLog::debug() << "CLEAR CONTAINER" << objects_.size() << endl;
+	for (vector<BasicGraphicsObject*>::iterator object = objects_.begin(); object!= objects_.end(); ++object) {
+		if (*object) {
+
+			delete *object;
+		}
+		*object = 0;
+	}
+	objects_.clear();
+}
+
+void BasicGraphicsObject::check()
+{
+	if (parent_)
+		parent_->remove(this);
+}
diff --git a/src/basic/BasicGraphicsObject.h b/src/basic/BasicGraphicsObject.h
new file mode 100644
index 0000000..be755b8
--- /dev/null
+++ b/src/basic/BasicGraphicsObject.h
@@ -0,0 +1,193 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BasicGraphicsObject.h
+    \brief Implementation of BasicGraphicsObject class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: March 2004
+
+*/
+#ifndef BasicGraphicsObject_H
+#define BasicGraphicsObject_H
+
+#include "magics.h"
+
+#include "MagLog.h"
+
+
+#include "VectorOfPointers.h"
+
+
+namespace magics {
+
+class BaseDriver;
+
+class Layout;
+class Transformation;
+
+class BasicGraphicsObjectContainer;
+
+class BasicGraphicsObject {
+public:
+	BasicGraphicsObject();	
+	virtual ~BasicGraphicsObject();
+
+	virtual bool reproject(BasicGraphicsObjectContainer&) const 
+	{ MagLog::error() << "BasicGraphicsObject::reproject(...)--->Need to be implemented!\n"; assert(0); return false; }
+
+	virtual void redisplay(const BaseDriver&) const 
+	{ MagLog::dev() << "BasicGraphicsObject::redisplay(...)--->Not yet implemented\n"; }
+
+	void parent(BasicGraphicsObjectContainer* parent)
+	{
+		//assert(parent_ == 0);
+		parent_ = parent; 
+	}
+	void check();
+	BasicGraphicsObjectContainer& parent() { assert(parent_); return *parent_; }
+
+	void makeBrother(const BasicGraphicsObject& brother)
+	{ parent_ = brother.parent_; }
+
+	bool isOrphan() { return parent_== 0; } 
+	void orphan() {	parent_ = 0; }
+
+	void name(const string& name) { name_ = name; }
+	const string& name() const    { return name_; }
+	bool root() { return parent_ == 0; }
+	
+	void widthResolution(int width) { widthResolution_ = width; }
+	void heightResolution(int height) { heightResolution_ = height; }
+	int widthResolution() const { return widthResolution_; }
+	int heightResolution() const { return heightResolution_; }
+
+
+
+	virtual bool buildTree(const Layout&,  unsigned int, const BaseDriver&) const
+	{ return false; }
+
+protected:
+	virtual	void print(ostream&) const;
+	int widthResolution_;
+	int heightResolution_;
+	
+	BasicGraphicsObjectContainer* parent_;  // Just for reference : do not delete!
+	string name_;
+private:
+// No copy allowed
+	//BasicGraphicsObject& operator=(const BasicGraphicsObject&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const BasicGraphicsObject& p)
+		{ p.print(s); return s; }
+};
+
+
+
+/*!
+
+ Inherited by SceneLayer
+ 
+ \sa SceneLayer
+*/
+class BasicGraphicsObjectContainer : public BasicGraphicsObject
+{
+public:
+	BasicGraphicsObjectContainer() {}
+	virtual ~BasicGraphicsObjectContainer();
+	
+	void push_back(BasicGraphicsObject* object)
+	{
+		object->check(); // here we make sure that the object is not in 2 containres!
+		objects_.push_back(object);
+		object->parent(this);
+	}
+	void push_last(BasicGraphicsObject* object)
+		{
+			object->check(); // here we make sure that the object is not in 2 containres!
+			last_.push_back(object);
+			object->parent(this);
+		}
+
+	
+	void clear();
+	bool buildTree(const Layout&,  unsigned int, const BaseDriver&) const;
+	void remove(BasicGraphicsObject* object) {
+		std::remove(objects_.begin(), objects_.end(), object);
+
+	}
+
+
+	void visit(const BaseDriver&) const;
+
+	double absoluteX() const //absolute position from the root
+	{
+		assert(parent_); return parent_->absoluteX();
+	}
+	
+	virtual void getDriverInfo(double& x, double& y, double& width, double& height)
+	{
+		if ( parent_ ) 
+			parent_->getDriverInfo(x, y, width, height);
+	}
+	
+	virtual double absoluteY() const //absolute position from the root
+	{
+		assert(parent_); return parent_->absoluteY();
+	}
+
+	virtual double absoluteWidth()  const //absolute position from the root
+	{
+		assert(parent_); return parent_->absoluteWidth();
+	}
+
+	virtual double absoluteHeight() const //absolute position from the root
+	{
+		assert(parent_); return parent_->absoluteHeight();
+	}
+	
+	virtual double absoluteWidth(double width)  const //absolute position from the root
+	{
+		assert(parent_); return parent_->absoluteWidth(width);
+	}
+
+	virtual double absoluteHeight(double height) const //absolute position from the root
+	{
+		assert(parent_); return parent_->absoluteHeight(height);
+	}
+	
+	virtual const Transformation& transformation() const //returns the Transformation
+	{
+		assert(parent_); return parent_->transformation();
+	}
+	const vector<BasicGraphicsObject*>& objects() { //
+		//first we add
+		for (vector<BasicGraphicsObject*>::iterator l = last_.begin(); l != last_.end(); ++l)
+			objects_.push_back(*l);
+		last_.clear();
+		return objects_;
+	}
+protected:
+	virtual	void print(ostream&) const;
+	vector<BasicGraphicsObject*> objects_;
+	vector<BasicGraphicsObject*> last_;
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/BasicSceneObject.cc b/src/basic/BasicSceneObject.cc
new file mode 100644
index 0000000..2ecfb70
--- /dev/null
+++ b/src/basic/BasicSceneObject.cc
@@ -0,0 +1,211 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BasicSceneObject.cc
+    \brief Implementation of the Template class BasicSceneObject.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 1-Mar-2007
+     
+    Changes:
+    
+*/
+
+
+#include "BasicSceneObject.h"
+#include "BasicSceneVisitor.h"
+#include "Layout.h"
+#include "LayoutManager.h"
+#include "Layer.h"
+
+
+using namespace magics;
+
+BasicSceneObject::BasicSceneObject(BasicSceneObject* parent) : 
+    parent_(parent)
+{
+	if ( parent_ ) 
+		parent_->items_.push_back(this);
+}
+
+
+BasicSceneObject::~BasicSceneObject() 
+{
+	//delete the visitors...
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void BasicSceneObject::print(ostream& out)  const
+{
+	out << "BasicSceneObject[" << name() << endl;
+	string tab = "--->"; 
+	BasicSceneObject* parent = parent_;
+	while ( parent ) {
+		out << tab << parent->name() << endl;
+		tab = "--" + tab;
+		parent = parent->parent_;
+	}
+	out << "]" << endl;
+}
+
+BasicSceneNode::BasicSceneNode() : layout_(0)
+{
+	string type, start, direction;
+	ParameterManager::get("layout", type); 
+	ParameterManager::get("plot_start", start);
+	ParameterManager::get("plot_direction", direction);
+	manager_ = LayoutManager::manager(type, start, direction);
+}
+
+BasicSceneNode::BasicSceneNode(Layout* layout) : layout_(layout)
+{
+	string type, start, direction;
+	ParameterManager::get("layout", type); 
+	ParameterManager::get("plot_start", start);
+	ParameterManager::get("plot_direction", direction);
+	manager_ = LayoutManager::manager(type, start, direction);
+}
+
+BasicSceneNode::~BasicSceneNode() {
+	//if ( layout_ ) delete layout_;		
+	if ( manager_ ) delete manager_;
+}
+
+BasicSceneNode* BasicSceneNode::clone()
+{
+	BasicSceneNode* node = new BasicSceneNode();
+	node->layout_ = layout_->clone();
+	node->manager_ = manager_->clone();
+	return node;
+}
+
+void  BasicSceneObject::resolve()
+{
+	// WE first do a copy of the list...
+	vector<BasicSceneObject*> items;
+	for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item) 
+		items.push_back(*item);
+	for ( vector<BasicSceneObject*>::iterator item = items.begin(); item != items.end(); ++item)
+		(*item)->resolve();
+}
+bool  BasicSceneObject::needLegend()
+{
+	for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item)
+			if ( (*item)->needLegend() )
+				return true;
+	return false;
+}
+BasicSceneNode* BasicSceneNode::newNode(BasicPositionalObject* node)
+{
+	//MagLog::dev() << "BasicSceneNode::clone-->from " << *this << endl;	
+
+	BasicSceneNode* newnode = clone();
+
+	parent_->insert(newnode);
+	(*(newnode->manager_))(newnode, node);
+
+	// The new Node had been inserted in the tree! 
+	return newnode;
+}
+	
+BasicSceneNode* BasicSceneNode::insert(BasicPositionalObject* node)
+{
+	node->parent(this);
+	node->getReady(); //to calcuilate the dimension
+	
+	BasicSceneNode* parent = (*manager_)(this, node);
+	//parent is the node when to push_back the new! 
+	node->orphan();
+	parent->push_back(node);
+ 	return parent;
+}
+
+
+double BasicPositionalObject::adjustDimension(double x, double def, double parent)
+{
+	//MagLog::dev() << *this << endl;	
+	//MagLog::dev() << *parent_ << endl;
+	if ( x == -1) {
+	    MagLog::dev() << "adjustDimension[" << x << ", " << def << ", " << parent << "]=" << def << "%" << endl;
+	    return def;
+	}
+	MagLog::dev() << "adjustDimension[" << x << ", " << def << ", " << parent << "]=" << (x/parent)*100 << "%" << endl;
+	double dim = (x/parent)*100;
+	// can not return more thean 100!
+
+	return dim;
+//	return dim > 100 ? 100 : dim;
+}
+
+double BasicSceneNode::absoluteWidth()    const
+{
+	return (parent_->absoluteWidth()*layout_->width())/100.;
+}
+
+double BasicSceneNode::absoluteHeight()   const
+{
+	return (parent_->absoluteHeight()*layout_->height())/100.;
+}
+
+void BasicSceneNode::newpage()
+{
+	assert(manager_);
+	manager_->newpage();
+}
+
+void BasicSceneNode::getReady()
+{	
+	static int i = 0;
+	ostringstream n;
+	n << "basic" << i;
+	name_ = n.str();
+	i++;
+	MagLog::dev() << "new getReady-->" << name_ << endl;
+
+
+
+	layout_->name(name_);
+}
+
+void EmptySceneObject::visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors)
+{
+	// First we create the layer!
+	// and push It to the parent layer! 
+	StaticLayer* empty = new StaticLayer(this);
+	empty->name("EmptySceneObject");
+	layer.add(empty);
+	// Just set the layout!!!
+	for  (vector<LayoutVisitor*>::iterator visitor = visitors.begin(); visitor != visitors.end(); ++visitor) {
+		empty->set(*visitor);
+	}
+}
+
+EmptySceneObject::EmptySceneObject()
+{
+}
+
+EmptySceneObject::~EmptySceneObject()
+{
+}
+
+void EmptySceneObject::print(ostream&) const
+{
+}
diff --git a/src/basic/BasicSceneObject.h b/src/basic/BasicSceneObject.h
new file mode 100644
index 0000000..418580f
--- /dev/null
+++ b/src/basic/BasicSceneObject.h
@@ -0,0 +1,325 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BasicSceneObject.h
+    \brief Definition of the Template class BasicSceneObject.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 1-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef BasicSceneObject_H
+#define BasicSceneObject_H
+
+#include "magics.h"
+#include "MagLog.h"
+#include "VectorOfPointers.h"
+#include "BasicGraphicsObject.h"
+#include "Layout.h"
+#include "DisplayManager.h"
+#include "MagicsEvent.h"
+
+//#include "SceneVisitor.h"
+
+namespace magics {
+	
+class XmlNode;
+class UserPoint;
+class UserPoint;
+
+class Transformation;
+class AnimationRules;
+
+
+
+
+class DrawingVisitor;
+class TopAxisVisitor;
+class BottomAxisVisitor;
+class LeftAxisVisitor;
+class RightAxisVisitor;
+class BackgroundVisitor;
+class TextVisitor;
+class MetaDataVisitor;
+class LegendVisitor;
+class PreviewVisitor;
+class HistoVisitor;
+class MagnifierVisitor;
+class SceneVisitor;
+class LayoutManager;
+class AnimationStep;
+class SceneLayer;
+
+class MetaDataCollector;
+class MagnifierCollector;
+class ValuesCollector;
+class DataIndexCollector;
+class BinningObject;
+
+class Data;
+class Visdef;
+
+class BasicPositionalObject;
+class BasicSceneNode;
+
+enum MagicsMode { interactif, paper, basic};
+
+class BasicSceneObject : public MetviewIcon {
+
+public:
+	BasicSceneObject(BasicSceneObject* parent = 0);
+	virtual ~BasicSceneObject();
+	
+	virtual void push_back(BasicSceneObject* item) { 
+		item->parent(this); 
+		items_.push_back(item); 
+	}
+	
+	bool items_empty() { return items_.empty(); }
+	
+	virtual void text(TextVisitor* text) { assert(parent_); parent_->text(text); }
+	virtual void legend(LegendVisitor* legend) { assert(parent_); parent_->legend(legend); }
+
+	virtual void binning(BinningObject*)   { MagLog::warning() << "binning(BinningObject*) to be checked" << endl; }
+	virtual void data(Data*)     { MagLog::warning() << "data(Data*) to be checked" << endl; }
+	virtual void visdef(Visdef*) { MagLog::warning() << "visdef(Data*) to be checked" << endl; }
+	
+
+	
+	void addVisitor(SceneVisitor* visitor) { visitors_.push_back(visitor); }
+	
+	void parent(BasicSceneObject* parent) { 
+
+		parent_ = parent;  
+	}
+	void reparent(BasicSceneObject* parent) { 
+			parent_ = parent;  
+	}
+	
+	void orphan() { parent_ = 0; }
+	BasicSceneObject& parent() const { assert(parent_); return *parent_; }
+	virtual void set(const XmlNode&) 
+		{ MagLog::dev() << "Warning:  BasicSceneObject::set(const XmlNode&)-->Not implemented!" << endl; }
+	virtual void resolve();
+	virtual Layout* execute(AnimationStep&,  Layout&)
+		{ MagLog::dev() << "Warning:  BasicGraphicsObject* BasicSceneObject::execute(AnimsationStep&))-->Not implemented!" << endl; return 0;}
+	virtual void getReady() { dispatch(&BasicSceneObject::getReady); }
+	virtual void release() { dispatch(&BasicSceneObject::release); }
+
+	virtual void visit(MetaDataVisitor& meta)  		{ dispatch(meta); } 
+	virtual void visit(PreviewVisitor& preview)  		{ dispatch(preview); }
+	virtual void visit(HistoVisitor& histo)  		{ dispatch(histo); }
+	virtual void visit(MagnifierVisitor& magnifier)  	{ dispatch(magnifier); }
+	
+	virtual void visit(DateDescription& timestamp)  	{ dispatch(timestamp); }
+	virtual void visit(LevelDescription& level)  	{ dispatch(level); }
+
+	virtual void visit(Transformation& transformation)  	{ dispatch(transformation); }
+	virtual void visit(AnimationRules& rules)  { dispatch(rules); }
+	
+	virtual void visit(MetaDataCollector& infos)  { dispatch(infos); }
+	virtual void visit(MagnifierCollector& infos)  { dispatch(infos); }
+	virtual void visit(ValuesCollector& infos)  { dispatch(infos); }
+	virtual void visit(DataIndexCollector& infos)  { dispatch(infos); }
+	
+	virtual void visit(DrawingVisitor& drawing)  { dispatch(drawing); }
+	virtual void visit(TopAxisVisitor& top)  { dispatch(top); }
+	virtual void visit(BottomAxisVisitor& bottom)  { dispatch(bottom); }
+	virtual void visit(LeftAxisVisitor& left)  { dispatch(left); }
+	virtual void visit(RightAxisVisitor& right)  { dispatch(right); }
+	virtual void visit(BackgroundVisitor& background)  { dispatch(background); }
+	
+	virtual void visit(TextVisitor& text)  { dispatch(text); }
+	virtual void visit(LegendVisitor& legend)  { dispatch(legend); }
+	virtual void visit(SceneLayer& tree)  { dispatch(tree); }
+	virtual void visit(BasicGraphicsObjectContainer& tree)  { dispatch(tree); }
+	virtual void visit(AnimationStep& step)  { dispatch(step); }
+	virtual void visit(SceneLayer& visitor, vector<LayoutVisitor*>& args)  { dispatch(visitor, args); }
+
+	virtual bool needLegend();
+
+	virtual void execute()
+	{
+	  assert(parent_); 
+	  return parent_->execute(); 
+	} 
+
+	virtual  BasicGraphicsObject* visualise()
+	{
+		  assert(parent_);
+		  return parent_->visualise();
+	}
+	virtual MagicsMode mode() { assert(parent_); return parent_->mode(); }
+
+	virtual Transformation& transformation() const
+		{ assert(parent_); return parent_->transformation(); } 
+	virtual const Layout& layout() const 
+		{ assert(parent_); return parent_->layout(); } 
+	virtual BasicGraphicsObject* toDisplay()
+		{ assert(parent_); return parent_->toDisplay(); }
+	virtual double absoluteWidth()    const 
+		{ assert ( parent_ ); return  parent_->absoluteWidth(); } 
+   	virtual double absoluteHeight()   const 
+		{ assert ( parent_ ); return  parent_->absoluteHeight(); } 
+   	virtual void absoluteRootWidth(double width)   
+		{ assert ( parent_ ); return  parent_->absoluteRootWidth(width); } 
+   	virtual void absoluteRootHeight(double height)   
+   		{ assert ( parent_ ); return  parent_->absoluteRootHeight(height); }
+ 	virtual int rootWidthResolution()   const
+		{ assert ( parent_ ); return  parent_->rootWidthResolution(); } 
+   	virtual int rootHeightResolution() const   
+   		{ assert ( parent_ ); return  parent_->rootHeightResolution(); }
+   	virtual int widthResolution()   const
+   			{ assert ( parent_ ); return  parent_->rootWidthResolution(); } 
+   	virtual int heightResolution() const   
+   	   		{ assert ( parent_ ); return  parent_->rootHeightResolution(); }
+   
+	const string& name() const { return name_; }
+	void name(const string& name)  { name_ = name; }
+
+	virtual BasicSceneNode* insert(BasicPositionalObject*) { assert (false);  return 0;}
+
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	typedef void (BasicSceneObject::*Function)();
+
+
+
+
+
+	template <class T>
+	void dispatch(T& visitor) {
+		for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item) 
+			(*item)->visit(visitor); 		
+	}
+	template <class T1, class T2>
+		void dispatch(T1& visitor, T2& args) {
+			for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item) 
+				(*item)->visit(visitor, args); 		
+		}
+	void dispatch(Function function)
+	{
+		for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item) 
+			((*item)->*function)(); 		
+	}
+
+
+	VectorOfPointers<vector<BasicSceneObject*> >          items_;
+	vector<SceneVisitor*>     visitors_;	 
+ 
+	 BasicSceneObject* parent_; //Do not delete! Only a reference
+
+	 string name_;
+
+private:
+	BasicSceneObject(const BasicSceneObject&);
+    //! Overloaded << operator to copy - No copy allowed
+	BasicSceneObject& operator=(const BasicSceneObject&);
+	
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BasicSceneObject& p)
+		{ p.print(s); return s; }
+
+};
+
+class BasicPositionalObject : public BasicSceneObject
+{
+public: 
+	BasicPositionalObject() {}
+	virtual ~BasicPositionalObject() {}
+	virtual Layout& layout() const = 0;
+protected:
+	double adjustDimension(double, double, double);
+};
+
+class BasicSceneNode : public BasicPositionalObject 
+{
+public:
+	BasicSceneNode();
+	BasicSceneNode(Layout*);
+	virtual ~BasicSceneNode();
+
+	virtual BasicSceneNode* insert(BasicPositionalObject*); // Return the node tinto which the object has been inserted! 
+	Layout& layout() const
+	{
+	  { assert(layout_); return *layout_; } 
+	}    
+	virtual void getReady();  
+	virtual BasicSceneNode* clone();
+	virtual BasicSceneNode* newNode(BasicPositionalObject*);
+
+	virtual void visit(BasicGraphicsObjectContainer& tree)
+	{
+		tree.push_back(layout_);
+		layout_->blankIt(); 
+		dispatch(*layout_); 
+		layout_->frameIt();  
+	}
+	void newpage();
+	double absoluteWidth()    const;
+	double absoluteHeight()   const;
+
+
+	void manager(LayoutManager* manager) { manager_ = manager; }
+
+protected:
+	Layout* layout_;
+	LayoutManager* manager_;
+	friend class LayoutManager;
+};
+
+class EmptySceneObject: public BasicSceneObject {
+
+public:
+	EmptySceneObject();
+	virtual ~EmptySceneObject();
+    
+ 
+    
+    void visit(SceneLayer&, vector<LayoutVisitor*>&);
+  
+   
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+    
+   
+     
+private:
+    //! Copy constructor - No copy allowed
+	EmptySceneObject(const EmptySceneObject&);
+    //! Overloaded << operator to copy - No copy allowed
+	EmptySceneObject& operator=(const EmptySceneObject&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EmptySceneObject& )
+		{ s << "EmptySceneObject";  return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/BasicSceneVisitor.cc b/src/basic/BasicSceneVisitor.cc
new file mode 100644
index 0000000..acdff02
--- /dev/null
+++ b/src/basic/BasicSceneVisitor.cc
@@ -0,0 +1,35 @@
+/*! \file BasicSceneVisitor.cc
+    \brief Implementation of the Template class BasicSceneVisitor.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Fri 19-Dec-2008
+    
+    Changes:
+    
+*/
+
+
+
+#include "BasicSceneVisitor.h"
+
+using namespace magics;
+
+BasicSceneVisitor::BasicSceneVisitor() 
+{
+}
+
+
+BasicSceneVisitor::~BasicSceneVisitor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void BasicSceneVisitor::print(ostream& out)  const
+{
+	out << "BasicSceneVisitor[";
+	out << "]";
+}
+
diff --git a/src/basic/BasicSceneVisitor.h b/src/basic/BasicSceneVisitor.h
new file mode 100644
index 0000000..b5dc22b
--- /dev/null
+++ b/src/basic/BasicSceneVisitor.h
@@ -0,0 +1,44 @@
+/*! \file BasicSceneVisitor.h
+    \brief Definition of the Template class BasicSceneVisitor.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Fri 19-Dec-2008
+    
+    Changes:
+    
+*/
+
+#ifndef BasicSceneVisitor_H
+#define BasicSceneVisitor_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class BasicSceneVisitor {
+
+public:
+	BasicSceneVisitor();
+	virtual ~BasicSceneVisitor();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	BasicSceneVisitor(const BasicSceneVisitor&);
+    //! Overloaded << operator to copy - No copy allowed
+	BasicSceneVisitor& operator=(const BasicSceneVisitor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BasicSceneVisitor& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/DisplayManager.h b/src/basic/DisplayManager.h
new file mode 100644
index 0000000..131e7c0
--- /dev/null
+++ b/src/basic/DisplayManager.h
@@ -0,0 +1,100 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DisplayManager.h
+    \brief Definition of the Template class DisplayManager.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Fri 9-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef DisplayManager_H
+#define DisplayManager_H
+
+#include "magics.h"
+#include "BasicGraphicsObject.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+namespace magics {
+	
+class BasicSceneObject;
+
+
+
+class DisplayManager {
+
+
+public:
+	DisplayManager();
+	virtual ~DisplayManager();
+	
+	
+	
+	
+	void operator()(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	virtual void addInline(BasicSceneObject&, BasicGraphicsObjectContainer&); // inline mode 
+	virtual void addBlock(BasicSceneObject&, BasicGraphicsObjectContainer&); // block mode 
+
+	void bottomVertical(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	void bottomHorizontal(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	void topVertical(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	void topHorizontal(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	void nothing(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	
+	void style(const string&, const string&, const string&);
+	
+
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	
+	 
+	 
+	 typedef void (DisplayManager::*DisplayFunction)(BasicSceneObject&, BasicGraphicsObjectContainer&);
+	 DisplayFunction  style_;
+	 
+	 
+
+private:
+    //! Copy constructor - No copy allowed
+	DisplayManager(const DisplayManager&);
+    //! Overloaded << operator to copy - No copy allowed
+	DisplayManager& operator=(const DisplayManager&);
+	bool fortran_;
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const DisplayManager& p)
+		{ p.print(s); return s; }
+	double x_;
+	double y_;
+
+};
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/basic/FortranMagics.cc b/src/basic/FortranMagics.cc
new file mode 100644
index 0000000..1fa5a46
--- /dev/null
+++ b/src/basic/FortranMagics.cc
@@ -0,0 +1,1061 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file FortranMagics.cc
+    \brief Implementation of the Template class FortranMagics.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Fri 9-Mar-2007
+
+    Changes:
+    
+*/
+
+
+#include "magics_ecmwf_log.h"
+#include "FortranMagics.h"
+#include "Timer.h"
+
+#include "RootSceneNode.h"
+#include "SceneNode.h"
+#include "ViewNode.h"
+#include "Coastlines.h"
+#include "TextVisitor.h"
+#include "LegendVisitor.h"
+#include "VisualAction.h"
+#ifdef MAGICS_GRIB
+#include "GribDecoder.h"
+#endif
+#include "MapGenDecoder.h"
+#include "GeoPointsDecoder.h"
+#include "Contour.h"
+#include "UserPoint.h"
+#include "SymbolInput.h"
+#include "SymbolPlotting.h"
+#include "Wind.h"
+#include "Axis.h"
+#include "XYList.h"
+#include "GraphPlotting.h"
+#include "InputMatrix.h"
+#include "ImagePlotting.h"
+#include "BoxPlotDecoder.h"
+#include "BoxPlotVisualiser.h"
+#include "SimplePolylineInput.h"
+#include "SimplePolylineVisualiser.h"
+#include "TitleTemplate.h"
+#include "TaylorGrid.h"
+
+#include "ImportAction.h"
+#include "ImportPlot.h"
+#include "ImportObjectHandler.h"
+
+#include "MetaData.h"
+
+#ifdef MAGICS_NETCDF
+#include "NetcdfDecoder.h"
+#endif
+
+#ifdef MAGICS_BUFR
+#include "ObsDecoder.h"
+#endif
+
+#ifdef MAGICS_JSON
+#include "ObsJSon.h"
+#endif
+
+#include "ObsPlotting.h"
+
+using namespace magics;
+
+FortranMagics::FortranMagics() :  drivers_(0), output_(0), geoaction_(0), xyaction_(0), empty_(true),
+		gribindex_(0),legend_todo_(false), symbolinput_todo_ (false), matrixinput_todo_(false), polyinput_todo_(false)
+
+{
+	assert (singleton_ == 0);
+	singleton_ = this;
+
+	writeMagLog("fortran");
+}	
+
+
+FortranMagics::~FortranMagics() 
+{
+	if ( drivers_ ) delete drivers_;
+//	if ( root_ ) delete root_;
+	if ( output_ ) delete output_;
+	singleton_ = 0;
+	
+	/* 
+	ParameterManager::release();
+	TitleTemplate::release();
+
+	GribDecoder::releaseContext();
+	*/
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void FortranMagics::print(ostream& out)  const
+{
+	out << "FortranMagics[";
+	out << "]";
+}
+
+void FortranMagics::popen()
+{
+   MagLog::info() << "popen()" << endl;
+
+   if(getEnvVariable("MAGPLUS_QUIET").empty() )
+   {
+	MagLog::userInfo() << "------------------------------------------------------------------\n";
+	MagLog::userInfo() << "\n";
+	MagLog::userInfo() << "			  "<< getMagicsVersionString() <<"\n";
+	MagLog::userInfo() << "\n";
+	MagLog::userInfo() << " Meteorological Applications Graphics Integrated Colour System\n";
+	MagLog::userInfo() << "\n";
+	MagLog::userInfo() << "			    Developed By\n";	 
+	MagLog::userInfo() << "\n";
+	MagLog::userInfo() << "   The European Centre for Medium-Range Weather Forecasts\n";
+	MagLog::userInfo() << "\n";
+	MagLog::userInfo() << "		      Copyright ECMWF "<<MAGICS_COPYRIGHT_PERIOD<<"\n";
+	MagLog::userInfo() << "\n";
+	MagLog::userInfo() << "------------------------------------------------------------------\n";
+   }
+  // actions_.push(&FortranMagics::legend);
+   actions_.push(&FortranMagics::subpage);	
+   actions_.push(&FortranMagics::page);	
+   actions_.push(&FortranMagics::superpage);	
+   actions_.push(&FortranMagics::drivers);	
+}
+
+/*! \brief Main dispatch method
+  Here is where the real magics is happen. Everything is dispatched, followed 
+  by a comprehensive clean-up.
+*/
+void FortranMagics::pclose()
+{
+	MagLog::info()<< "pclose()" << endl;
+	if (!empty_) {
+		finish();
+		dispatch();
+	}
+
+	if ( root_ && drivers_ ) {
+
+		BasicGraphicsObject* object = root_->close();
+		if ( object ) {
+
+			/***   Start clean-up  ***/
+			drivers_->dispatch(object);
+			drivers_->closeDrivers();
+
+			delete root_;
+			delete drivers_;
+			delete output_;
+
+			drivers_ = 0;
+			root_ = 0;
+			output_ = 0;
+		}
+
+	}
+
+	// the Magics log messages are not broadcast until the next log event - therefore, the
+	// last log message will not be broadcast. We fix that by flushing the message streams
+	// - we only need to do one of them, and all will be flushed behind the scenes.
+	MagLog::info().flush();
+
+	// We reset all the parameters to their default,
+	// then a consecutive call to popen will not be affected by the current values.
+	ParameterManager::reset();
+
+
+	if(getEnvVariable("MAGPLUS_QUIET").empty() )
+	{
+	/*
+		MagLog::userInfo() << "------------------------------------------------------------------\n";
+		MagLog::userInfo() << " Output files generated:\n";
+		stringarray::iterator it = output_resource_list_.begin();
+		stringarray::iterator itend = output_resource_list_.end();
+		for(; it != itend; it++)
+		{
+			MagLog::userInfo() << "  - "<<(*it)<<"\n";  
+		}
+		MagLog::userInfo() << "\n";
+	*/
+		MagLog::userInfo() << "------------------------------------------------------------------\n";
+		MagLog::userInfo() << "    COMPLETED\n";
+		MagLog::userInfo() << "\n";
+		MagLog::userInfo() << "    Any problems or suggestions? Please contact us at\n";
+		MagLog::userInfo() << "                   magics at ecmwf.int\n";
+		MagLog::userInfo() << "------------------------------------------------------------------\n";
+	}
+}
+
+void FortranMagics::drivers()
+{
+	if (!drivers_)  drivers_ = new DriverManager();
+	if (!output_)   output_ = new OutputHandler();
+	output_->set(*drivers_);
+}
+
+void FortranMagics::subpage()
+{
+	axisContainer_ = new FortranViewNode();	
+
+	top()->push_back(axisContainer_);
+	axisContainer_->getReady();
+	push(axisContainer_);
+}
+
+
+void FortranMagics::page()
+{
+	if ( empty() ) return;
+
+	while (top() != root_) {
+		pop(); 
+		if ( empty() ) break;
+	}
+
+
+	FortranSceneNode* node = new FortranSceneNode();
+	root_->insert(node);
+	// Just a test for metadata collection
+	MetaDataVisitor* meta = new MetaDataVisitor();
+	node->push_back(meta);
+	push(node);
+}
+
+
+void FortranMagics::newpage()
+{
+	if ( empty() ) return;
+	BasicSceneObject* to = top();
+	
+	while ( to != root_) {
+		pop();
+		to = top();
+		if ( empty() ) break;
+	}
+
+	root_->newpage();
+
+	//push(node);
+}
+
+
+void FortranMagics::superpage()
+{
+	root_ = new FortranRootSceneNode();
+
+		push(root_);
+
+		root_->getReady();
+		drivers_->setDriversWidth(root_->absoluteWidth());
+			drivers_->setDriversHeight(root_->absoluteHeight());
+			drivers_->openDrivers();
+}
+
+
+void FortranMagics::simplelegend()
+{
+	// used fronm the python interface! 
+	// add a new legend! 
+	legends_.clear();
+
+	legend();
+}
+
+void FortranMagics::legend()
+{
+    if ( legends_.empty() == false ) return;
+    
+    if (!legend_todo_) return;
+
+    legend_todo_ = false;
+    string mode;	
+    ParameterManager::get("legend_box_mode", mode);
+  
+    if (magCompare(mode, "positional") ) 
+    	legends_.push_back(new FortranPositionalLegendVisitor()); 
+    else 
+    	legends_.push_back(new FortranAutomaticLegendVisitor()); 		
+}
+
+
+void FortranMagics::plegend()
+{    
+	legend_todo_ = true;
+	legends_.clear();
+    actions_.push(&FortranMagics::legend);
+}
+
+void FortranMagics::poverlay()
+{    
+	actions();
+
+	if (geographical()) {
+		geoaction_ = new VisualAction();
+		ImportAction* input = new ImportAction();
+		ImportPlot* plot = new ImportPlot();
+		top()->push_back(geoaction_);
+		geoaction_->data(input);
+//		MagLog::dev() << *input << "\n";   
+		geoaction_->visdef(plot);
+	}
+	else {
+		xyaction_ = new VisualAction();
+
+		ImportAction* input = new ImportAction();
+		ImportPlot* plot = new ImportPlot();
+		top()->push_back(xyaction_);
+		xyaction_->data(input);
+//		MagLog::dev() << *input << "\n";   
+		xyaction_->visdef(plot);
+	}
+}
+
+
+void FortranMagics::pimport()
+{
+	ImportObjectHandler* object = new ImportObjectHandler();
+	later_.push_back(object);
+}
+
+
+void FortranMagics::pnew(const string& type)
+{
+	MagLog::info() << "pnew(" << type << ")" << endl;
+	if ( magCompare(type, "subpage") )
+	{
+		if ( empty_ ) return;
+		finish();
+		pop();
+		actions_.push(&FortranMagics::legend);
+		actions_.push(&FortranMagics::subpage);	
+	}
+	if ( magCompare(type, "page") )
+	{
+		   if ( empty_ ) return;
+				finish();
+				dispatch();
+        empty_ = true;
+		pop();
+		actions_.push(&FortranMagics::legend);	
+		actions_.push(&FortranMagics::subpage);	
+		actions_.push(&FortranMagics::page);
+
+	}
+	if ( magCompare(type, "super_page") || magCompare(type, "superpage"))
+	{
+			if ( empty_ ) {
+				actions_.push(&FortranMagics::newpage);
+				return;
+			}
+			finish();
+			dispatch();
+            empty_ = true;
+			actions_.push(&FortranMagics::legend);
+		    actions_.push(&FortranMagics::subpage);	
+		    actions_.push(&FortranMagics::page);	
+			actions_.push(&FortranMagics::newpage);
+
+	}
+	// WE reset ! 
+	axisContainer_ = 0;
+	geoaction_ = 0;
+	xyaction_ = 0;
+	
+	string legend;
+	ParameterManager::get("legend", legend);
+	legend_todo_ = magCompare(legend, "on");
+}
+
+
+void FortranMagics::actions()
+{
+	Timer timer("magics", "setting");
+	while (!actions_.empty())
+	{
+		Action action = actions_.top();
+		(this->*action)();
+		actions_.pop();
+		empty_ = false; 
+	}
+}
+
+
+void FortranMagics::pcoast()
+{
+	actions();
+
+	Coastlines* coastlines = new Coastlines();
+	axisContainer_->push_back(coastlines);
+}
+
+void FortranMagics::ptaylor()
+{
+	actions();		
+
+	TaylorGrid* taylor = new TaylorGrid();
+	top()->push_back(taylor);
+}
+
+void FortranMagics::pobs()
+{
+	actions();
+#ifdef MAGICS_BUFR
+	geoaction_ = new VisualAction();
+	ObsDecoder* obs = new ObsDecoder();
+	if ( obs->defined() ) {
+		geoaction_->data(obs);
+		top()->push_back(geoaction_);
+		geoaction_->visdef(new ObsPlotting());
+		return;
+	}
+#endif
+#ifdef MAGICS_JSON
+	geoaction_ = new VisualAction();
+	geoaction_->data(new ObsJSon());
+	top()->push_back(geoaction_);
+	geoaction_->visdef(new ObsPlotting());
+#endif
+
+}
+
+
+#include "MatrixTestDecoder.h"
+void FortranMagics::ptest()
+{
+	actions();
+	geoaction_ = new VisualAction();
+	geoaction_->data(new MatrixTestDecoder());
+	top()->push_back(geoaction_);
+}
+
+
+/*!  \brief Finish plot by checking axis, legend and texts
+ * 
+*/
+void FortranMagics::finish()
+{
+	if ( !empty_ ) {
+		actions(); // The flag to force the generation of the plot has been set!  
+		while ( !axis_.empty() )
+		{
+			axisContainer_->push_back(axis_.top());
+			axis_.pop();
+		}
+	}
+	
+	if ( !axisContainer_ ) return;
+	// check if we have to add a legend! 
+	if ( !legends_.empty() && axisContainer_ &&  !axisContainer_->items_empty() ) 
+	{
+		legend();
+		for (vector<LegendVisitor* >::iterator legend = legends_.begin();  legend != legends_.end(); ++legend)
+		{
+			top()->legend(*legend);
+		}
+		legends_.clear();
+	}
+
+	// Check any text	
+	for (vector<BasicSceneObject* >::iterator other = later_.begin();  other != later_.end(); ++other)
+	{
+		top()->push_back(*other);
+	}
+	later_.clear();
+	
+	for (vector<FortranTextVisitor* >::iterator text = texts_.begin();  text != texts_.end(); ++text)
+	{
+		top()->text(*text);
+	}
+	texts_.clear();
+}
+
+
+/*!  \brief Dispatch scene graph to drivers
+ * \sa DriverManager::dispatch()
+ * \sa FortranRootSceneNode::visualise()
+*/
+void FortranMagics::dispatch()
+{
+	if ( !root_ )  // Nothing has been done so far!
+		return;
+	drivers_->dispatch(root_->visualise());
+	root_->release();
+}
+
+
+void FortranMagics::pmapgen()
+{
+	actions();
+	if (geographical())
+	{
+		geoaction_ = new VisualAction();
+		geoaction_->data(new MapGenDecoder());
+		top()->push_back(geoaction_);
+	}
+	else {
+		xyaction_ = new VisualAction();
+		xyaction_->data(new MapGenDecoder());
+		top()->push_back(xyaction_);
+	}
+}
+
+#ifdef MAGICS_GRIB
+void FortranMagics::pgrib()
+{
+	actions();
+	geoaction_ = new VisualAction();
+	static string gribfile;
+	
+	string grib;
+	ParameterManager::get("grib_input_file_name", grib);
+	int index;
+	ParameterManager::get("grib_field_position", index);
+	
+	if ( grib == gribfile  )
+	{
+		if ( index == gribindex_ )
+		{
+    		gribindex_++;
+    	}
+		else
+		{
+    		gribindex_ = index;
+    	}
+    	ParameterManager::set("grib_field_position", gribindex_);
+    }
+	else
+	{
+    	gribfile = grib;
+    	gribindex_ = index;
+    }
+    
+	geoaction_->data(new GribDecoder());
+	top()->push_back(geoaction_);
+}
+
+void FortranMagics::pimage()
+{
+	actions();
+
+	if ( geographical() )
+	{
+		if ( !geoaction_ ) {
+			geoaction_ = new VisualAction();
+			geoaction_->data(new GribDecoder());
+		}			
+		geoaction_->visdef(new ImagePlotting());
+	}
+	else {
+		assert(xyaction_);
+		xyaction_->visdef(new ImagePlotting());
+	}
+	geoaction_ = 0;
+	xyaction_ = 0;
+}
+#else
+void FortranMagics::pgrib()
+{
+}
+
+void FortranMagics::pimage()
+{
+}
+#endif
+
+void FortranMagics::pgeo()
+{
+	actions();
+	geoaction_ = new VisualAction();
+	geoaction_->data(new GeoPointsDecoder());
+	top()->push_back(geoaction_);
+}
+
+void FortranMagics::pnetcdf()
+{
+#ifdef MAGICS_NETCDF
+	actions();
+	if (geographical())
+	{
+		geoaction_ = new VisualAction();
+		geoaction_->data(new NetcdfDecoder());
+		top()->push_back(geoaction_);
+	}
+	else {	
+		xyaction_ = new VisualAction();
+		xyaction_->data(new NetcdfDecoder());
+		top()->push_back(xyaction_);
+	}
+#endif
+}
+#include "InputData.h"
+void FortranMagics::pinput()
+{
+
+	actions();
+	if (geographical())
+	{
+		geoaction_ = new VisualAction();
+		geoaction_->data(new InputData());
+		top()->push_back(geoaction_);
+	}
+	else {
+		xyaction_ = new VisualAction();
+		xyaction_->data(new InputData());
+		top()->push_back(xyaction_);
+	}
+
+}
+
+#ifdef MAGICS_ODB
+#include "OdaDecoder.h"
+#endif
+void FortranMagics::podb()
+{
+	actions();
+#ifdef MAGICS_ODB
+
+    if (geographical())
+    {
+    	geoaction_ = new VisualAction();
+    	geoaction_->data(new OdaGeoDecoder());
+    	top()->push_back(geoaction_);
+    }
+    else {
+    	xyaction_ = new VisualAction();
+    	xyaction_->data(new OdaXYDecoder());
+    	top()->push_back(xyaction_);
+    }
+#endif
+}
+
+
+void FortranMagics::data(Data* data)
+{
+	assert ( geoaction_ == 0);
+	geoaction_ = new VisualAction();
+	geoaction_->data(data);
+	top()->push_back(geoaction_);
+}
+
+
+
+bool FortranMagics::geographical()
+{
+	string projection;
+	ParameterManager::get("subpage_map_projection", projection);
+	if ( magCompare(projection, "cartesian") ) return false;
+	if ( magCompare(projection, "taylor") ) return false;
+	return true;
+}
+
+template <class T>
+void param(const string& from, const string& to, T& val)
+{
+	ParameterManager::get(from, val);
+	ParameterManager::set(to,val);
+}
+
+
+void split(VisualAction& action) {
+/*	string split;
+	//ParameterManager::get("contour_line_plotting", split);
+	if ( magCompare(split, "split"))
+	{
+			MagLog::warning() << " contour_line_plotting is deprecated" << endl;
+			double level;
+			ParameterManager::get("contour_split_level", level);
+			double max, min;
+			ParameterManager::get("contour_max_level", max);
+			ParameterManager::get("contour_min_level", min);
+			// set the below contour
+			ParameterManager::set("contour_max_level", level);
+			
+			LineStyle style, highlightstyle;
+			double thickness, highlightthickness;
+			string colour, highlightcolour;
+			
+			param("contour_below_line_style", "contour_line_style", style);
+			param("contour_below_line_thickness", "contour_line_thickness", thickness);
+			param("contour_below_line_colour", "contour_line_colour", colour);
+			param("contour_below_highlight_style", "contour_highlight_line_style", highlightstyle);
+			param("contour_below_highlight_thickness", "contour_highlight_line_thickness", highlightthickness);
+			param("contour_below_highlight_colour", "contour_highlight_line_colour",highlightcolour);
+			
+			action.visdef(new Contour());
+			
+			// set the above contour
+			ParameterManager::set("contour_max_level", max);
+			ParameterManager::set("contour_min_level", level);
+			param("contour_above_line_style", "contour_line_style", style);
+			param("contour_above_line_thickness", "contour_line_thickness", thickness);
+			param("contour_above_line_colour", "contour_line_colour", colour);
+			param("contour_above_highlight_style", "contour_highlight_line_style", style);
+			param("contour_above_highlight_thickness", "contour_highlight_line_thickness", thickness);
+			param("contour_above_highlight_colour", "contour_highlight_line_colour", colour);
+			action.visdef(new Contour());
+			// Should we reset???			
+	}
+	else {   */
+		action.visdef(new Contour());
+//	}
+}
+		
+
+void FortranMagics::pcont()
+{
+	// First check any split contour! I hate it! 
+	Timer timer("pcont", "setting");
+	actions();		
+	if ( geographical() )
+	{
+		if ( !geoaction_  || matrixinput_todo_ )
+		{
+			geoaction_ = new VisualAction();
+			InputMatrix* input = new InputMatrix();
+			matrixinput_todo_ = false;
+			if (input->defined() )
+				geoaction_->data(input);
+			else {
+				delete input;
+#ifdef MAGICS_GRIB
+			// Sylvie: Is this causing GribDecoder MagExceptions when matrx input is faulty?
+				geoaction_->data(new GribDecoder());
+#else
+				MagLog::warning() <<" Attempt to decode data from GRIB, but GRIB support is disabled!"<< endl;
+#endif
+		}
+		top()->push_back(geoaction_);	
+	}
+
+	split(*geoaction_);
+	geoaction_ = 0;
+	}
+	else {
+		if ( !xyaction_ )
+		{
+			xyaction_ = new VisualAction();
+			InputMatrix* input = new InputMatrix();
+			if (input->defined() ) 
+				xyaction_->data(input);						
+			else {
+				MagLog::error() << "No data defined!" << endl;
+				return;
+			}
+			top()->push_back(xyaction_);	
+		}
+		split(*xyaction_);
+		xyaction_ = 0;
+	}
+}
+
+void FortranMagics::pwind()
+{
+	actions();		
+	if ( matrixinput_todo_ ) {
+		geoaction_ = 0;
+	}
+	if ( !geoaction_  )
+	{
+		geoaction_ = new VisualAction();
+		InputMatrix* input = new InputMatrix();
+		matrixinput_todo_ = false;
+		if (input->defined() ) 
+			geoaction_->data(input);						
+		else {
+			delete input;
+#ifdef MAGICS_GRIB
+			// Sylvie: Is this causing GribDecoder MagExceptions when matrx input is faulty?
+			geoaction_->data(new GribDecoder());
+#else
+			MagLog::warning() <<" Attempt to decode Wind from GRIB, but GRIB support is disabled!"<< endl;
+#endif
+		}
+		top()->push_back(geoaction_);	
+	}
+
+	geoaction_->visdef(new Wind());
+	geoaction_ = 0;
+}
+
+
+
+
+
+void FortranMagics::ptext()
+{
+	string mode;
+	ParameterManager::get("text_mode", mode);
+	
+	FortranTextVisitor* node;
+	if ( magCompare(mode, "positional") ) 
+		node = new FortranPositionalTextVisitor(); 
+	else 
+		node = new FortranAutomaticTextVisitor();	
+	
+	texts_.push_back(node);
+	empty_ = false;
+}
+	
+
+void FortranMagics::psymb()
+{
+	actions();	
+ 
+ 	string mode;
+ 	string wind;
+ 	ParameterManager::get("symbol_position_mode", mode);
+ 	ParameterManager::get("symbol_type", wind);
+ 	if ( magCompare(mode, "graph")  )
+	{
+ 		xyaction_ = new VisualAction();
+ 		SymbolInput* input = new SymbolInput();
+		top()->push_back(xyaction_);
+		xyaction_->data(input);
+		MagLog::dev() << *input << "\n";
+		SymbolPlotting* symbol = new SymbolPlotting();
+		MagLog::dev() << *symbol << "\n";
+		xyaction_->visdef(symbol);
+		xyaction_ = 0;
+	}
+	else
+	{
+
+
+		if ( geographical() ) {
+			    if ( !geoaction_ || symbolinput_todo_ ) {
+			    	geoaction_ = new VisualAction();
+			    	SymbolInput* input = new SymbolInput();
+			    	top()->push_back(geoaction_);
+			    	geoaction_->data(input);
+			    	MagLog::dev() << *input << "\n";
+			    	symbolinput_todo_ = false;
+			    }
+			    if (magCompare(wind, "wind")) {
+			    	Wind* wind = new Wind();
+			    	MagLog::dev() << *wind << "\n";
+			    	geoaction_->visdef(wind);
+			    }
+			    else {
+			    	SymbolPlotting* symbol = new SymbolPlotting();
+			    	MagLog::dev() << *symbol << "\n";
+			    	geoaction_->visdef(symbol);
+			    }
+			geoaction_ = 0;
+		}
+		else {
+			
+		    if ( !xyaction_ || symbolinput_todo_ ) {
+		    	xyaction_ = new VisualAction();
+		    	SymbolInput* input = new SymbolInput();
+		    	top()->push_back(xyaction_);
+		    	xyaction_->data(input);
+		    	MagLog::dev() << *input << "\n";
+		    	symbolinput_todo_ = false;
+		    }
+		    if (magCompare(wind, "wind")) {
+		    	Wind* wind = new Wind();
+		    	MagLog::dev() << *wind << "\n";
+		    	xyaction_->visdef(wind);
+		    }
+		    else {
+		    	SymbolPlotting* symbol = new SymbolPlotting();
+		    	MagLog::dev() << *symbol << "\n";
+		    	xyaction_->visdef(symbol);
+		    }
+		    xyaction_ = 0;
+		}
+	}
+}
+
+
+void FortranMagics::pline()
+{
+	actions();
+	if ( polyinput_todo_ )
+		geoaction_ = 0;
+	if (geographical() ) {
+		if ( !geoaction_ ) {
+			geoaction_ = new VisualAction();
+			polyinput_todo_ = false;
+			SimplePolylineInput* input = new SimplePolylineInput();
+			top()->push_back(geoaction_);
+			geoaction_->data(input);
+		}
+		geoaction_->visdef(new SimplePolylineVisualiser());
+
+	}
+	else {
+		MagLog::warning() << "pline is not yet implementde for cartesian projection" << endl;
+	}
+
+}
+
+#include "WrepJSon.h"
+#include "EpsGraph.h"
+void  FortranMagics::wrepjson()
+{
+	actions();
+
+
+	xyaction_ = new VisualAction();
+
+	WrepJSon* wrep = new WrepJSon();
+
+	top()->push_back(xyaction_);
+	xyaction_->data(wrep);
+
+}
+
+void  FortranMagics::epscloud()
+{
+	actions();
+	if ( !xyaction_ ) {
+		MagLog::error() << "epscloud -> No data defined " << endl;
+		exit(1);
+	}
+	EpsCloud* epscloud = new EpsCloud();
+
+	xyaction_->visdef(epscloud);
+}
+
+void FortranMagics::epsgraph()
+{
+	actions();
+	if ( !xyaction_ ) {
+			MagLog::error() << "epscloud -> No data defined " << endl;
+			exit(1);
+		}
+	EpsGraph* epsgraph = new EpsGraph();
+	xyaction_->visdef(epsgraph);
+}
+
+void FortranMagics::epswave()
+{
+	actions();
+	if ( !xyaction_ ) {
+		MagLog::error() << "epscloud -> No data defined " << endl;
+		exit(1);
+	}
+	EpsWave* eps = new EpsWave();
+	xyaction_->visdef(eps);
+}
+
+void FortranMagics::epswind()
+{
+	actions();
+	if ( !xyaction_ ) {
+		MagLog::error() << "epscloud -> No data defined " << endl;
+		exit(1);
+	}
+	EpsWind* epswind = new EpsWind();
+	xyaction_->visdef(epswind);
+}
+
+
+void FortranMagics::epsbar()
+{
+	EpsBar* epsbar = new EpsBar();
+	xyaction_->visdef(epsbar);
+}
+void FortranMagics::epsshading()
+{
+	actions();
+	if ( !xyaction_ ) {
+		MagLog::error() << "epscloud -> No data defined " << endl;
+		exit(1);
+	}
+	EpsShade* eps = new EpsShade();
+	xyaction_->visdef(eps);
+}
+
+void FortranMagics::paxis()
+{
+	try {
+		string orientation;
+		
+		ParameterManager::get("axis_orientation", orientation); 
+//		
+		if (magCompare(orientation, "vertical") ) {
+			Axis* vaxis = new VerticalAxis();		  
+			MagLog::dev() << *vaxis << "\n";
+			axis_.push(vaxis);
+		} 
+		else {			
+			Axis* haxis = new HorizontalAxis();
+			MagLog::dev() << *haxis << "\n";
+			axis_.push(haxis);
+		}
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+ 	empty_= false; // Force the generation of the plot!
+}
+
+void FortranMagics::prepare()
+{
+    actions();
+}
+
+void FortranMagics::pgraph()
+{
+	actions();
+
+	GraphPlotting* graph = new GraphPlotting();
+	// do we need a new Action?
+	// we check the previous one!
+	// if it looks ok we create a new one
+	if ( ( xyaction_ && xyaction_->isValid() ) || !xyaction_ ) {
+		xyaction_ = new VisualAction();
+		top()->push_back(xyaction_);
+		XYList* input = new XYList();
+		xyaction_->data(input);
+		MagLog::dev() << *input << "\n";
+	}
+
+
+
+
+	xyaction_->visdef(graph);
+}
+
+
+void FortranMagics::pboxplot()
+{
+	actions();
+	
+	xyaction_ = new VisualAction();
+	
+ 	BoxPlotDecoder* input = new BoxPlotDecoder();
+ 	BoxPlotVisualiser* plot = new BoxPlotVisualiser();
+	top()->push_back(xyaction_);	
+	xyaction_->data(input);
+	MagLog::dev() << *input << "\n";   
+	xyaction_->visdef(plot);
+}
+
+FortranMagics* FortranMagics::singleton_ = 0;
diff --git a/src/basic/FortranMagics.h b/src/basic/FortranMagics.h
new file mode 100644
index 0000000..4cb9035
--- /dev/null
+++ b/src/basic/FortranMagics.h
@@ -0,0 +1,169 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file FortranMagics.h
+    \brief Definition of the Template class FortranMagics.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Fri 9-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef FortranMagics_H
+#define FortranMagics_H
+
+#include "magics.h"
+
+
+#include "OutputHandler.h"
+#include "DriverManager.h"
+#include "DisplayManager.h"
+namespace magics {
+
+class FortranRootSceneNode;
+class VisualAction;
+class Data;
+
+class UserPoint;
+class UserPoint;
+class Axis;
+class FortranTextVisitor;
+class LegendVisitor;
+
+class FortranMagics : public std::stack<BasicSceneObject*> {
+
+public:
+	FortranMagics();
+	~FortranMagics();
+	typedef void (FortranMagics::*Action)();
+	void popen();
+	void pclose();
+	void pnew(const string&);
+	void pcoast();
+	void prepare();
+	
+	void pgrib();
+	void pmapgen();
+	void pnetcdf();
+	void pgeo();
+	void pinput();
+	void pcont();
+	void ptext();
+	void ptest();
+	void pline();
+	void psymb();
+	void pimage();
+	void pimport();
+	void poverlay();
+	void pobs();
+	void podb();
+	void plegend();
+	void simplelegend();
+
+	//Wrep-Eps family!
+	void wrepjson();
+	void epscloud();
+	void epsgraph();
+	void epswave();
+	void epswind();
+	void epsbar();
+	void epsshading();
+	
+	void pgraph();
+	void pboxplot();
+	
+	void paxis();
+	void ptaylor();
+	
+	void pwind();
+	
+	
+	static FortranMagics& magics() { 
+		if ( !singleton_ ) 
+			singleton_ = new FortranMagics();
+		return *singleton_;
+	}
+	
+	static void close() { 
+		if ( singleton_ ) 
+			delete singleton_;
+		singleton_ = 0;
+	}
+	void subpage();
+	void page();
+	void newpage();
+	
+	void superpage();
+	void legend();
+	void drivers();
+	
+	void actions();
+	
+	bool geographical();
+	
+	void resetGrib() { gribindex_ = 0; } 
+	
+	void data(Data*);
+	
+	void flagInputSymbol() { symbolinput_todo_ = true; }
+	void flagInputMatrix() { matrixinput_todo_ = true; }
+	void flagInputPoly() { polyinput_todo_ = true; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream.
+	 void print(ostream&) const; 
+	 void finish();
+	 void dispatch();
+	 static FortranMagics*    singleton_;
+	 DriverManager*		  drivers_;
+	 FortranRootSceneNode*    root_;
+	 OutputHandler*           output_;
+
+	 stack<Action>            actions_;
+	 vector<FortranTextVisitor*>   texts_;
+	 vector<LegendVisitor*>   legends_;
+	 vector<BasicSceneObject*>   later_;
+	 stack<Axis*>             axis_;
+	 BasicSceneObject* axisContainer_;
+	 VisualAction*    geoaction_;
+	 VisualAction*   xyaction_;
+	 bool empty_;
+	 int gribindex_;
+	 bool legend_todo_;
+
+	 bool symbolinput_todo_;
+	 bool matrixinput_todo_;
+	 bool polyinput_todo_;
+
+private:
+    //! Copy constructor - No copy allowed
+	FortranMagics(const FortranMagics&);
+    //! Overloaded << operator to copy - No copy allowed
+	FortranMagics& operator=(const FortranMagics&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const FortranMagics& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/HistoVisitor.cc b/src/basic/HistoVisitor.cc
new file mode 100644
index 0000000..fa38299
--- /dev/null
+++ b/src/basic/HistoVisitor.cc
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ViewNode.cc
+    \brief Implementation of the Template class ViewNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#include "HistoVisitor.h"
+#include "Transformation.h"
+#include "Layout.h"
+#include "BaseDriver.h"
+
+using namespace magics;
+
+
+
+HistoVisitor::HistoVisitor(): basic_(false) , dataLayoutTransformation_(0)
+{
+	name("histigram");
+}
+
+HistoVisitor::~HistoVisitor()
+{
+
+
+}
+void HistoVisitor::print(ostream& s) const
+{
+	s << "HistoVisitor[";
+	Layout::print(s);
+	s << "]";
+}
+
+void HistoVisitor::visit(BasicGraphicsObjectContainer& tree)
+{
+
+	tree.push_back(this);
+	// the Layout has been added to a Container, it will be delted automatically!
+	
+}
+
+void HistoVisitor::redisplay(const BaseDriver& driver) const { 
+	MagLog::dev() << " I am a HistoVisitor!" << *this << endl;	
+	driver.redisplay(*this);
+}
+
+void HistoVisitor::visit(BasicSceneObject& object) { 
+		object.visit(*this); 
+}
diff --git a/src/basic/HistoVisitor.h b/src/basic/HistoVisitor.h
new file mode 100644
index 0000000..143df48
--- /dev/null
+++ b/src/basic/HistoVisitor.h
@@ -0,0 +1,95 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \brief Definition of the Template class ViewNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef HistoNode_H
+#define HistoNode_H
+
+#include "magics.h"
+#include "SceneVisitor.h"
+#include "Coastlines.h"
+
+
+
+namespace magics {
+
+
+class HistoVisitor: public SceneVisitor, public HistoLayout
+{
+public:
+	HistoVisitor();
+	virtual ~HistoVisitor();
+	virtual void set(const XmlNode&) {}
+	virtual void set(const map<string, string>&) {}
+	virtual bool accept(const string&) { return false;}
+	virtual void toxml(ostream&, int = 0) const {}
+	virtual HistoVisitor* clone() const { return new HistoVisitor();}
+	void visit(BasicGraphicsObjectContainer&);
+	void redisplay(const BaseDriver& driver) const;
+	void visit(BasicSceneObject& object);
+	void basic(bool basic) { basic_ = basic; }
+	bool basic() const { return basic_; }
+	void dataLayoutTransformation(const Transformation* dlt) {dataLayoutTransformation_=dlt;}
+	const Transformation* dataLayoutTransformation() {return dataLayoutTransformation_;}
+	void dataVisdefIcon(const MetviewIcon& icon) {dataVisdefIcon_.icon(icon);}
+	const MetviewIcon& dataVisdefIcon() const {return dataVisdefIcon_;}
+
+protected:
+	virtual void print(ostream& s) const;
+
+	friend ostream& operator<<(ostream& s,const HistoVisitor& p)
+	{
+		p.print(s); 
+		return s;
+	}
+	bool basic_;
+	MetviewIcon dataVisdefIcon_;
+	const Transformation* dataLayoutTransformation_;
+};
+
+
+
+
+template <>
+class MagTranslator<string, HistoVisitor> { 
+public:
+	HistoVisitor* operator()(const string& val )
+	{
+		return SimpleObjectMaker<HistoVisitor>::create(val);
+	}     
+
+	HistoVisitor* magics(const string& param)
+	{
+		HistoVisitor* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/ImportObjectHandler.cc b/src/basic/ImportObjectHandler.cc
new file mode 100644
index 0000000..0d63ced
--- /dev/null
+++ b/src/basic/ImportObjectHandler.cc
@@ -0,0 +1,80 @@
+/*! \file ImportObjectHandler.cc
+    \brief Implementation of the Template class ImportObjectHandler.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Wed 10-Feb-2010
+    
+    Changes:
+    
+*/
+
+#include "ImportObjectHandler.h"
+#include "Dimension.h"
+#include "ImportObject.h"
+#include "Layer.h"
+
+using namespace magics;
+
+ImportObjectHandler::ImportObjectHandler() 
+{
+  BasicSceneObject::name_ = "import";
+}
+
+ImportObjectHandler::~ImportObjectHandler() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ImportObjectHandler::print(ostream& out)  const
+{
+   out << "ImportObjectHandler[";
+   ImportObjectHandlerAttributes::print(out);
+   out << "]";
+}
+
+void ImportObjectHandler::getReady()
+{
+   layout_ = new Layout();
+}
+
+void  ImportObjectHandler::visit(SceneLayer& tree, vector<LayoutVisitor*>&)
+{
+   StaticLayer* import = new StaticLayer(this);
+   import->name(path_);
+   tree.add(import);
+
+   layout_ = new Layout();
+   import->add(layout_);
+   
+   layout_->x(adjustDimension(ImportObjectHandlerAttributes::x_,0., BasicPositionalObject::absoluteWidth()));
+   layout_->y( adjustDimension(ImportObjectHandlerAttributes::y_, 0.,BasicPositionalObject::absoluteHeight()));
+   layout_->width(adjustDimension(ImportObjectHandlerAttributes::width_, 10., BasicPositionalObject::absoluteWidth()));
+   layout_->height(adjustDimension(ImportObjectHandlerAttributes::height_, 10., BasicPositionalObject::absoluteHeight()));
+
+   //layout_->frame(true, true, Colour("blue"), M_DOT, 3);
+   //layout_->frameIt();
+
+   ImportObject* object = new ImportObject();
+   object->setPath(path_);
+   object->setOrigin(PaperPoint(0, 0));
+   object->setWidth(100);
+   object->setHeight(100);
+   object->setFormat(format_);
+   object->setOriginReference(ImportObject::bottom_left);
+   layout_->push_back(object);
+}
+
+void ImportObjectHandler::visit(MetaDataCollector&)
+{
+	/*// jsut look for MV_Format
+	MetaDataCollector::iterator format = collector.find("MV_Format");
+	if ( format != collector.end() ) {
+		format->second = service_;
+	}
+	
+	(*interpretor_).visit(collector);
+	*/
+}
diff --git a/src/basic/ImportObjectHandler.h b/src/basic/ImportObjectHandler.h
new file mode 100644
index 0000000..cdaa727
--- /dev/null
+++ b/src/basic/ImportObjectHandler.h
@@ -0,0 +1,55 @@
+/*! \file ImportObjectHandler.h
+    \brief Definition of the Template class ImportObjectHandler.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Wed 10-Feb-2010
+    
+    Changes:
+    
+*/
+
+#ifndef ImportObjectHandler_H
+#define ImportObjectHandler_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+#include "Layout.h"
+#include "ImportObjectHandlerAttributes.h"
+
+namespace magics {
+
+class ImportObjectHandler: public BasicSceneNode, 
+	public Layout, 
+	public ImportObjectHandlerAttributes 
+{
+
+public:
+	ImportObjectHandler();
+	virtual ~ImportObjectHandler();
+	
+	void getReady();  
+	void visit(SceneLayer&, vector<LayoutVisitor*>&);
+	void visit(MetaDataCollector& collector);
+	void set(const XmlNode& node) { ImportObjectHandlerAttributes::set(node); }
+	void set(const map<string, string>& map) { ImportObjectHandlerAttributes::set(map); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ImportObjectHandler(const ImportObjectHandler&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImportObjectHandler& operator=(const ImportObjectHandler&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImportObjectHandler& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/Layer.cc b/src/basic/Layer.cc
new file mode 100644
index 0000000..6e7496a
--- /dev/null
+++ b/src/basic/Layer.cc
@@ -0,0 +1,1174 @@
+
+/*****************
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+
+ 	http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+ *******************************  LICENSE  *******************************/
+
+#include "Layer.h"
+#include "BaseDriver.h"
+#include "AnimationRules.h"
+
+#include "SceneVisitor.h"
+#include "TextVisitor.h"
+#include "LegendVisitor.h"
+#include "Symbol.h"
+#include "BaseDriver.h"
+
+#include "HistoVisitor.h"
+
+//===================================
+//
+// Layer
+//
+//===================================
+
+Layer::Layer() : 
+visibility_(true),
+zindex_(1),
+transparency_(0),
+state_(new_layer),
+id_(""),
+parent_(0),
+object_(0)
+
+{
+}
+
+Layer::Layer(BasicSceneObject* object) : 
+			visibility_(true),
+			zindex_(1),
+			transparency_(0),
+			state_(new_layer),
+			id_(""),
+			parent_(0),
+			object_(object)
+{
+}
+
+Layer::~Layer()
+{
+}
+
+void Layer::execute(int , const BaseDriver&, const Layout&) const
+{
+	assert(false);
+}
+
+void Layer::getReady(int) const
+{
+}
+void Layer::release()
+{
+	if ( object_ ) object_->release();
+
+	BasicGraphicsObjectContainer::clear();
+}
+void Layer::getReady() const
+{
+}
+
+void  Layer::collect(ValuesCollector&  values)
+{
+	values.clear();
+}
+
+void Layer::newLayer(const BaseDriver& driver)
+{
+	driver.newLayer(*this); 
+}
+
+void Layer::closeLayer(const BaseDriver& driver)
+{
+	driver.closeLayer(*this); 
+}
+
+void Layer::redisplay(const BaseDriver& driver) const 
+{
+	driver.redisplay(*this); 
+}
+
+void Layer::print(ostream& out) const
+{ 
+	out << "layer[" << name_;
+	string sep = "";
+	for (vector<MetviewIcon>::const_iterator icon = icons_.begin(); icon != icons_.end(); ++icon) {
+		out << ", [" << (*icon).iconName() << ", " << (*icon).iconClass()  << ", " << (*icon).iconId() << "]";
+		sep = "]";
+	}
+	out << sep << "]"; 
+}
+
+string Layer::timeStamp(const string& fmt) const
+{
+	return from_.tostring(fmt);
+}
+
+string Layer::timeBegin(const string& fmt) const
+{
+	return from_.tostring(fmt);
+}
+
+string Layer::timeEnd(const string& fmt) const
+{
+	return to_.tostring(fmt);
+}
+
+static string kml("%Y-%m-%dT%H:%M:00Z");
+
+string Layer::kmlTimeBegin() const 
+{ 
+	return timeBegin(kml); 
+}
+
+string Layer::kmlTimeEnd() const 
+{ 
+	return timeEnd(kml);  
+}
+
+string Layer::kmlTimeStamp() const
+{
+	return timeStamp(kml);
+}
+
+void Layer:: execute(const BaseDriver& ) const 
+{
+}
+
+void Layer::collectText(vector<TextVisitor*>& texts, LegendVisitor* legend)
+{
+	if ( !visibility_) return; 
+	if ( !object_) 
+		return;
+
+	for (vector<TextVisitor*>::iterator text = texts.begin(); text != texts.end(); ++text) {
+		(*text)->visit(*object_);
+		myTexts_[*text] = (*text)->texts();
+	}
+	if ( legend)
+		legend->visit(*object_);
+}
+
+const string& Layer::metadata(const string& param)
+{
+	static string empty;
+	map<string, string>::iterator data = metadata_.find(param);
+
+	return (data != metadata_.end() ) ? data->second : empty;
+}
+
+void Layer::metadata(const string& param, const string& value)
+{
+	metadata_[param] = value;
+}
+
+
+
+
+//===================================
+//
+// SingleLayer
+//
+//===================================
+
+SingleLayer::SingleLayer(StepLayer* parent, BasicSceneObject* object) : 
+				Layer(object),
+				objects_(0), parentLayer_(parent)
+{
+}
+
+SingleLayer::~SingleLayer()
+{
+}
+
+void SingleLayer::set(LayoutVisitor* visitor) const	
+{
+	visitor->newLayout();	
+	objects_->push_back(visitor->layoutPtr());
+}
+
+
+
+void SingleLayer::print(ostream& ) const
+{
+}
+
+void SingleLayer::redisplay(const BaseDriver& ) const
+{
+}
+
+void SingleLayer::collect(MetaDataCollector& infos)
+{
+	if(object_)
+		object_->visit(infos);
+}
+
+void SingleLayer::collect(ValuesCollector& values)
+{
+	object_->visit(values);
+}
+
+void SingleLayer::collect(DataIndexCollector& infos)
+{
+	if(object_)
+		object_->visit(infos);
+}
+
+void SingleLayer::magnify(const BaseDriver& driver, float ,float )
+{
+	MagnifierCollector magnifier;
+	for (vector<LayoutVisitor*>::iterator visitor = parentLayer_->firstVisitor(); 
+			visitor != parentLayer_->endVisitor(); ++visitor)
+	{
+		(*visitor)->set(magnifier);
+	}
+	magnifier.setParent(parentLayer_);
+	object_->visit(magnifier);
+	magnifier.visit(driver);
+}
+
+void SingleLayer::execute(const BaseDriver& driver) const
+{
+	if ( !parentLayer_->visibility() )
+		return;
+
+	assert(objects_);
+	objects_->redisplay(driver);
+	const_cast<SingleLayer*>(this)->release();
+	const_cast<SingleLayer*>(this)->objects_->clear();
+}
+
+void SingleLayer::update(const Layout& parent)
+{
+	assert(objects_);
+	objects_->width(parent.width());
+	objects_->height(parent.height());
+	objects_->x(parent.x());
+	objects_->y(parent.y());
+}
+
+void SingleLayer::getReady() const
+{
+	if ( !parentLayer_->visibility() )
+		return;
+	if ( parentLayer_->parent()->state() == geometry_changed) {
+		assert(objects_);
+		objects_->clear();
+	}
+	if ( !objects_ ) {
+		objects_ = new Layout();
+		objects_->name("singlelayer");
+		objects_->parent(parentLayer_->parent());
+		for (vector<LayoutVisitor*>::iterator visitor = parentLayer_->firstVisitor(); 
+				visitor != parentLayer_->endVisitor(); ++visitor) {
+			set(*visitor);
+			(*visitor)->visit(*object_);
+		}
+	}
+}
+
+
+Layer* SingleLayer::baseLayer()
+{ 
+	return parentLayer_;
+}
+
+
+void SingleLayer::histogram(const BaseDriver& driver,const string& visdefName,const string& visdefClass)
+{
+	HistoVisitor histogram;
+	MetviewIcon icon(visdefName,visdefClass);
+	histogram.dataVisdefIcon(icon);
+	object_->visit(histogram);
+	histogram.redisplay(driver);
+}
+
+
+
+//===================================
+//
+// StepLayer
+//
+//===================================
+
+StepLayer::StepLayer() 
+{
+}
+
+StepLayer::~StepLayer() 
+{
+}
+
+void StepLayer::redisplay(const BaseDriver& driver) const 
+{  
+	driver.redisplay(*this); 
+}
+
+void StepLayer::execute(int i, const BaseDriver& driver, const Layout& layout) const
+{  
+	if ( visibility_ && i < steps_.size() ) {
+		steps_[i]->update(layout);
+		steps_[i]->execute(driver);
+	}
+}
+
+void StepLayer::getReady(int i) const
+{  
+	if ( visibility_ )
+		steps_[i]->getReady();
+}
+
+void StepLayer::newLayer(const BaseDriver& driver)
+{
+	driver.newLayer(*this); 
+}
+
+void StepLayer::closeLayer(const BaseDriver& driver)
+{
+	driver.closeLayer(*this); 
+}
+
+int StepLayer::size()
+{
+	return 1;
+}
+
+Layer* StepLayer::get(int i) 
+{
+	return steps_[i];
+}
+
+void StepLayer::addStep(BasicSceneObject* object)
+{
+	static int level = 100;
+	SingleLayer* layer = new SingleLayer(this, object);
+	layer->name(name_);
+	layer->id(id_);
+	static int mod = 0;
+	static DateTime date = DateTime();
+
+	layer->metadata("valid_date", string(date) );
+	layer->metadata("level", tostring(level));
+	level += 100;
+	date = date + Second(6*3600*(mod%2));
+	mod++;
+	steps_.push_back(layer );
+}
+
+void StepLayer::addVisitor(LayoutVisitor* visitor)
+{
+	visitors_.push_back(visitor);
+}
+
+void StepLayer::print(ostream& out) const
+{
+	out << "StepLayer[";
+	out << "]";
+}
+
+//===================================
+//
+// StaticLayer
+//
+//===================================
+
+void StaticLayer::redisplay(const BaseDriver& driver) const 
+{  
+	MagLog::dev() << "Static::redisplay-->" << *this << endl;
+	if ( updateText_ ) {
+		updateText_ = false;
+
+		const_cast<StaticLayer*>(this)->push_back(layer_);
+	}
+
+	driver.redisplay(*this);
+}
+
+void StaticLayer::execute(const BaseDriver& driver) const
+{  
+
+	if ( visibility_ ) 
+		redisplay(driver);
+}
+
+void StaticLayer::getReady() const
+{  
+}
+
+void StaticLayer::collect(MetaDataCollector& infos)
+{
+	if(object_)
+		object_->visit(infos);
+	//layer_->transformation().collect(infos);
+}
+
+void StaticLayer::collect(ValuesCollector& values)
+{
+	if(object_)
+		object_->visit(values);
+}
+
+void StaticLayer::collect(DataIndexCollector& infos)
+{
+	if(object_)
+		object_->visit(infos);
+}
+
+void StaticLayer::newLayer(const BaseDriver& driver)
+{
+	driver.newLayer(*this); 
+}
+
+void StaticLayer::closeLayer(const BaseDriver& driver)
+{
+	driver.closeLayer(*this); 
+}
+
+StaticLayer::StaticLayer() 
+{
+	layer_ = new Layout();
+	layer_->name("staticlayer");
+	updateText_ = true;
+}
+StaticLayer::StaticLayer(const Layout& layout)
+{
+	layer_ = layout.clone();
+	updateText_ = true;
+}
+StaticLayer::StaticLayer(BasicSceneObject* object) : Layer(object) 
+{
+	layer_ = new Layout();
+	layer_->name("staticlayer");
+	updateText_ = true;;
+}
+void StaticLayer::update(const Layout& parent)
+{
+	layer_->name(parent.name());
+	layer_->width(parent.width());
+	layer_->height(parent.height());
+	layer_->x(parent.x());
+	layer_->y(parent.y());
+}
+
+void StaticLayer::clean()
+{
+	layer_->clear();
+}
+
+StaticLayer::~StaticLayer()
+{
+}
+
+void StaticLayer::set(LayoutVisitor* visitor)
+{
+	//if ( layer_->isOrphan() )
+	layer_->parent(parent_);
+
+	visitor->newLayout();
+	layer_->push_back(visitor->layoutPtr());
+}
+
+void StaticLayer::add(BasicGraphicsObject* object)
+{
+	if ( layer_->isOrphan() )
+		layer_->parent(parent_);
+
+	layer_->push_back(object);
+}
+
+void StaticLayer::print(ostream& out) const
+{
+	out << "StaticLayer[";
+	out << "]";
+}
+
+void StaticLayer::histogram(const BaseDriver& driver,const string& visdefName, const string& visdefClass)
+{
+	HistoVisitor histogram;
+	MetviewIcon icon(visdefName,visdefClass);
+	histogram.dataVisdefIcon(icon);
+	object_->visit(histogram);
+	histogram.redisplay(driver);
+}
+
+//===================================
+//
+// NoDataLayer
+//
+//===================================
+
+NoDataLayer::NoDataLayer(BasicSceneObject* object):StaticLayer(object) {}
+
+NoDataLayer::~NoDataLayer() { }
+
+void NoDataLayer::redisplay(const BaseDriver& driver) const 
+{  
+
+	if ( updateText_ ) {
+		updateText_ = false;
+
+		const_cast<NoDataLayer*>(this)->push_back(layer_);
+	}
+
+	driver.redisplay(*this);
+
+}
+
+
+//===================================
+//
+// TextLayer
+//
+//===================================
+
+void TextLayer::getReady() const
+{
+	// Noothing to do!
+}
+
+void TextLayer::execute(const BaseDriver& driver) const
+{
+	// get the text for static later! 
+	Layout* layout = new Layout();
+	layout->parent(parent_);
+	parent_->finishText(*layout);
+
+	layout->redisplay(driver); 
+}
+
+
+
+void TextLayer::getInfo(int i, const BaseDriver&  driver) const
+{
+	// Get the information for a specifi step!
+	parent_->executeInfo(i, driver); // here we get the information!
+
+	Layout* parent = new Layout();
+	parent->parent(parent_);
+	parent->name("Clone of page");
+
+	parent->width(parent_->layoutPtr()->width());
+	parent->height(parent_->layoutPtr()->height());
+	parent->x(parent_->layoutPtr()->x());
+	parent->y(parent_->layoutPtr()->y());
+
+	Layout* layout = new Layout();
+	layout->parent(parent_);
+	parent_->finishText(*layout);
+	parent->push_back(layout);
+
+	LegendVisitor* legend = this->parent()->legend();
+
+	if ( legend ) {
+		Layout* layout = new Layout();
+		layout->parent(parent_);
+
+		legend->finish(*layout);
+		parent->push_back(layout);
+	}
+	parent->redisplay(driver);
+}
+
+void TextLayer::collectText(vector<TextVisitor*>& texts, LegendVisitor* legend)
+{
+	for (vector<TextVisitor*>::iterator text = texts.begin(); text != texts.end(); ++text) {
+		(*text)->visit();
+		myTexts_[*text] = (*text)->texts();
+	}
+}
+
+
+//===================================
+//
+// SceneLayer
+//
+//===================================
+
+SceneLayer::SceneLayer() : rules_(0), currentIndex_(0),legend_(0), currentFrame_(0)
+{
+	layout_ = new Layout();
+}
+
+SceneLayer::~SceneLayer()
+{
+	for (vector<Layer*>::iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+		(*layer)->clear();
+	}
+}
+
+bool SceneLayer::buildTree(const Layout& parent,  unsigned int frame, const BaseDriver& out) const
+{
+	if (frame >= numberOfSteps() ) return false;
+	if ( !currentFrame_ ) {
+		textHandler_.name("Titles");
+		textHandler_.parent(const_cast<SceneLayer*>(this));
+	}
+	layout_->name(parent.name());
+	layout_->width(parent.width());
+	layout_->height(parent.height());
+	layout_->x(parent.x());
+	layout_->y(parent.y());
+
+
+
+	getReady(frame);
+	execute(frame, out);
+	textHandler_.getInfo(frame, out);
+
+
+
+
+	return ( frame+1 < numberOfSteps() );
+}
+void SceneLayer::redisplay(const BaseDriver& driver) const
+{
+	intarray frames = driver.frames();
+	unsigned int nb = frames.size();
+	switch ( mode_) {
+	case paper: {
+		textHandler_.name("Titles");
+		textHandler_.parent(const_cast<SceneLayer*>(this));
+		if ( nb == 0) {
+			for ( int i = 0; i < numberOfSteps(); i++ )
+			{
+				getReady(i);
+				execute(i, driver);
+				textHandler_.getInfo(i, driver);
+			}
+		}
+		else {
+			for (unsigned int n = 0; n < nb; n++) {
+				int i = frames[n] -1 ;
+				if ( i < 0 || i >= numberOfSteps() ) {
+					MagLog::warning() << " Export : could not find page " << i+1 << endl;
+					continue;
+				}
+
+				getReady(i);
+				execute(i, driver);
+				textHandler_.getInfo(i, driver);
+			}
+		}
+	}
+	break;
+	case basic:
+		textHandler_.name("Titles");
+		textHandler_.parent(const_cast<SceneLayer*>(this));
+
+		if ( nb == 0) {
+			for ( int i = 0; i < numberOfSteps(); i++ )
+			{
+				getReady(i);
+				execute(i, driver);
+				textHandler_.getInfo(i, driver);
+			}
+		}
+		else  {
+			for ( unsigned int i = 0; i < nb; i++) {
+				int f =  frames[i];
+				getReady(f);
+				execute(f, driver);
+				textHandler_.getInfo(f, driver);
+			}
+		}
+		break;
+	case interactif:
+		visit(driver);
+		textHandler_.name("Titles");
+		textHandler_.parent(const_cast<SceneLayer*>(this));
+		const_cast<SceneLayer*>(this)->add(&textHandler_);
+		// here we add the Layer dedicated to the text ! ...
+		driver.redisplay(*this);
+		break;
+	}
+
+}
+
+void SceneLayer::print(ostream& out) const
+{
+	out << "SceneLayer[";
+	out << "]";
+}
+
+void SceneLayer::add(Layer* layer)
+{
+	layers_.push_back(layer);
+	layer->parent(this); 
+	layer->zindex(currentIndex_);
+	currentIndex_++;
+}
+
+int SceneLayer::numberOfSteps() const
+{
+	int size =  (rules_) ? rules_->size() : 0;
+	return std::max(1, size);
+}
+
+vector<Layer*>& SceneLayer::prepare(int i) const
+{
+	int size =  (rules_) ? rules_->size() : 0;
+
+	if ( i >= size ) {
+		vector<Layer*>* empty = new vector<Layer*>();
+		return *empty;
+	}
+	map<int, vector<Layer*> >::iterator step = steps_.find(i);
+	if ( step != steps_.end() ) 
+		return step->second;
+	assert(rules_); 
+	steps_.insert(make_pair(i, vector<Layer*>()));
+	if ( i >= (int)(*rules_).size() )
+	{
+		for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+			if ( (*layer)->get() )
+				steps_[i].push_back( (*layer)->get() );
+		}
+		return steps_[i];
+	}
+
+	//std::sort(layers_.begin(), layers_.end());// For the zindex!
+
+	AnimationStep* anim = (*rules_)[i];
+
+	for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+		map<Layer*, int>::iterator l = anim->find(*layer);
+		if ( l == anim->end() ) {
+			if ( (*layer)->get() )
+				steps_[i].push_back( (*layer)->get() );
+		}
+		else
+			steps_[i].push_back( (*layer)->get(l->second));
+	}
+	return steps_[i];
+} 
+
+void  SceneLayer:: execute(int i, const BaseDriver& driver) const 
+{
+	// Look for the step! 
+	int size =  (rules_) ? rules_->size() : 0;
+
+	if ( i >= size )
+	{
+		if ( layers_.empty() ) {
+			StaticLayer* layer = new StaticLayer(*layout_);
+
+			layers_.push_back(layer);
+			layers_.back()->parent(const_cast<SceneLayer*>(this));
+		}
+		for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+			(*layer)->update(*layout_);
+			(*layer)->execute(driver);
+
+		}
+		return;
+	}
+
+	AnimationStep* step = (*rules_)[i];
+
+	for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+		(*layer)->update(*layout_);
+		map<Layer*, int>::iterator l = step->find(*layer);
+		if ( l == step->end() )
+			(*layer)->execute(driver);
+		else
+			(*layer)->execute(l->second, driver, *layout_);
+	}
+}
+
+void  SceneLayer::execute(Layer* stepLayer, int i, const BaseDriver& out) const
+{
+	// Look for the step! 
+	int size =  (rules_) ? rules_->size() : 0;
+	if ( i >= size ) {		
+		// here we have to send the txt!
+		stepLayer->getInfo(i, out);
+		return;
+	}
+	// Make sure that we need to execute this later!
+	bool found=false;
+	for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer)
+	{
+		if(*layer == stepLayer)
+		{
+			found=true;
+			break;
+		}
+	}
+
+	if(!found)
+		return;
+
+
+	// Look for the step! 
+	assert(rules_);    
+	if  ( rules_->size() > i ) {    	
+		AnimationStep* step = (*rules_)[i];
+		map<Layer*, int>::iterator l = step->find(stepLayer);
+		if ( l != step->end() )
+			stepLayer->execute(l->second, out, *layout_);
+		else
+			stepLayer->getInfo(i, out);
+	}
+	else {
+		assert(false);
+		//stepLayer->execute(i, driver);
+	}
+}
+
+Layer*  SceneLayer::findLayer(Layer* stepLayer,int i) const 
+{
+	bool found=false;
+	for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer)
+	{
+		if(*layer == stepLayer)
+		{
+			found=true;
+			break;
+		}
+	}
+
+	if(!found)
+		return 0;
+
+	// Look for the step! 
+	assert(rules_); 
+
+	//Temporary fix!!
+	if(i >= rules_->size())
+		return stepLayer;
+
+	AnimationStep* step = (*rules_)[i];
+
+	map<Layer*, int>::iterator l = step->find(stepLayer);
+	if (l == step->end()) 
+		return 0;
+	else 
+		return stepLayer->get(l->second);
+}
+
+vector<Layer*>::iterator SceneLayer::beginLayer() const
+{
+	//std::sort(layers_.begin(), layers_.end());// For the zindex!
+	return layers_.begin();
+}
+
+vector<Layer*>::iterator SceneLayer::endLayer() const
+{
+	return layers_.end();
+}
+
+void SceneLayer::getReady(int i ) const 
+{
+	if ( legend_ )
+		legend_->clear();
+	// Look for the step!
+	int size =  (rules_) ? rules_->size() : 0;
+	if ( i >=  size )
+		// Only Static Layers!
+	{
+		for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+			(*layer)->getReady();
+		}
+	}
+	else {
+		assert(rules_);
+		AnimationStep* step = (*rules_)[i];
+
+		for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+			map<Layer*, int>::iterator l = step->find(*layer);
+			if ( l != step->end() )
+				(*layer)->getReady(l->second);
+		}
+	}
+}
+
+vector<Layer*>::iterator SceneLayer::beginLayer(int i ) const
+{
+	return prepare(i).begin();
+}
+
+vector<Layer*>::iterator SceneLayer::endLayer(int i ) const
+{
+	return prepare(i).end();
+}
+
+void SceneLayer::redisplayAll(const BaseDriver& driver) const
+{
+	for ( int i = 0; i <= numberOfSteps(); i++ )
+	{
+		getReady(i);
+		execute(i, driver);
+	}
+}
+
+void SceneLayer::finishText(Layout& layout)
+{
+	for (vector<TextVisitor*>::iterator text = textVisitors_.begin(); text != textVisitors_.end(); ++text) 
+		(*text)->finish(layout);
+}
+
+
+void SceneLayer::executeInfo(int i, const BaseDriver&) const
+{
+	// Look for the step! 
+	vector<Layer*> layers;
+	int size =  (rules_) ? rules_->size() : 0;
+	for (vector<TextVisitor*>::iterator text = textVisitors_.begin(); text != textVisitors_.end(); ++text) {
+		// we reset the text entries...
+		(*text)->start();
+	}
+	if ( legend_ )
+		legend_->clear();
+	// We collect the static infos...
+	textHandler_.collectText(textVisitors_, legend_);
+	layers.push_back(&textHandler_);
+	// Then we have to ask all the layers to collect and update the texts entries !
+	if ( i >= size )
+	{
+		// here we have only static layers!
+		for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+			(*layer)->collectText(textVisitors_, legend_);
+			layers.push_back(*layer);
+		}
+
+	}
+	else {
+		assert(rules_);
+
+		if ( rules_->size() > 0 ) {
+			AnimationStep* step = (*rules_)[i];
+
+			for (vector<Layer*>::const_iterator layer = layers_.begin(); layer != layers_.end(); ++layer) {
+				map<Layer*, int>::iterator l = step->find(*layer);
+				if ( l == step->end() ) {
+					// this is a static layer!
+					(*layer)->collectText(textVisitors_, legend_);
+					layers.push_back(*layer);
+
+				}
+				else {
+					(*layer)->get(l->second)-> collectText(textVisitors_, legend_);
+					layers.push_back((*layer)->get(l->second));
+				}
+			}
+		}
+	}
+
+	// All text has been collected now we build the final result
+	for (vector<TextVisitor*>::iterator text = textVisitors_.begin(); text != textVisitors_.end(); ++text)  {
+		// Each line ...
+		vector<string> lines;
+		(*text)->titles(lines);
+		for (vector<string>::reverse_iterator line = lines.rbegin(); line != lines.rend(); ++line) {
+			//for ecah layer!
+
+			for (vector<Layer*>::iterator layer = layers.begin(); layer != layers.end(); ++layer) {
+
+				vector<Text*>& texts = (*layer)->updateText(*text, *line);
+				(*text)->update(texts);
+				texts.clear(); // we have used it.. clear it!
+			}
+		}
+	}
+}
+
+
+//==================================
+//
+// Misc
+//
+//==================================
+
+void MagnifierCollector::visit(const BaseDriver& driver)
+{
+	assert(layout_);
+
+	Symbol* points = new Symbol();
+	points->setSymbol("magics_3"); // A little dot
+	points->setHeight(0.2); 
+	points->setColour(Colour("red")); 				
+
+	for ( iterator point = begin(); point != end(); ++point)
+		points->push_back(*point);
+
+	layout_->push_back(points);
+	layout_->redisplay(driver);
+}
+
+
+void MetviewIcon::visit(Layer& layer)
+{
+	if ( !iconClass_.empty() && !iconName_.empty() )
+	{
+		layer.icon(iconName_,iconClass_,iconId_);	 
+	}
+
+	//if ( !iconClass_.empty() && !iconName_.empty() )
+	//	layer.icon(iconName_, iconClass_);
+
+	layer.id(iconId_);
+}
+
+void MetviewIcon::visit(MetaDataCollector& collector)
+{
+	if(information_.empty())
+		return;
+
+	if(collector.empty())
+	{
+		collector.insert(information_.begin(),information_.end());
+	}
+	else
+	{
+		for (map<string, string>::iterator key = collector.begin(); key != collector.end(); ++key )
+		{
+			if(information_.find(key->first) != information_.end())
+			{
+				key->second = information_[key->first];
+			}
+		}
+	}
+}
+
+
+void LevelDescription::update(const LevelDescription& current) const
+{
+
+	set_ = current.set_;
+	index_ = current.index_;
+}
+
+bool LevelDescription::operator < (const LevelDescription& other) const // DEclaration function in Data.h
+{
+
+
+	if ( this->surface_ ) {
+		if ( other.surface_) {
+			return  this->index_ < other.index_;
+		}
+		else
+			return false;
+	}
+
+
+	if ( this->level_ == other.level_ )
+		if ( this->set_ == other.set_ )
+			return  this->index_ < other.index_;
+
+	return  this->level_ > other.level_;
+}
+
+
+void DateDescription::update(const DateDescription& current) const
+{
+
+	set_ = current.set_;
+	index_ = current.index_;
+}
+
+bool DateDescription::operator < (const DateDescription& other) const // DEclaration function in Data.h
+{
+
+	if ( this->valid_ == other.valid_ )
+		if ( this->set_ == other.set_ )
+			return this->index_ < other.index_;
+
+	return DateTime(this->valid_) <  DateTime(other.valid_);
+}
+
+LevelDescription::LevelDescription(): surface_(true)
+{
+}
+
+LevelDescription::~LevelDescription()
+{
+}
+DateDescription::~DateDescription()
+{
+}
+LevelDescription& SingleLayer::dataLevel() const
+{
+	static LevelDescription level;
+	object_->visit(level_);
+	return level_;
+
+}
+
+DateDescription& SingleLayer::timeStamp() const
+{
+	object_->visit(stamp_);
+
+	return stamp_;
+}
+ValuesCollectorPoint::~ValuesCollectorPoint()
+{
+	while (!empty()) {
+		ValuesCollectorData* data = back();
+		pop_back();
+		//delete data;
+	}
+
+
+}
+
+
+void ValuesCollectorData::print(ostream& out) const
+{
+	out << "ValuesCollectorData[";
+	out << "x=" << x_;
+	out << ", y=" << y_;
+	out << ", value=" << value_;
+	out << ", distance=" << distance_;
+	out << "]";
+}
+
+void ValuesCollectorUVData::print(ostream& out) const
+{
+	out << "ValuesCollectorData[";
+	out << "x=" << x_;
+	out << ", y=" << y_;
+	out << ", xComponent=" << xComponent_;
+	out << ", yComponent=" << yComponent_;
+	out << "]";
+}
+
+void ValuesCollectorSDData::print(ostream& out) const
+{
+	out << "ValuesCollectorData[";
+	out << "x=" << x_;
+	out << ", y=" << y_;
+	out << ", speed=" << speed_;
+	out << ", direction=" << direction_;
+	out << "]";
+}
+void ValuesCollectorVisitor::visit(const ValuesCollectorData& data)
+{
+
+}
+
+void ValuesCollectorVisitor::visit(const ValuesCollectorUVData& data)
+{
+
+}
+
+void ValuesCollectorVisitor::visit(const ValuesCollectorSDData& data)
+{
+
+}
+
+ValuesCollectorVisitor::ValuesCollectorVisitor()
+{
+
+}
+
diff --git a/src/basic/Layer.h b/src/basic/Layer.h
new file mode 100644
index 0000000..2b0880d
--- /dev/null
+++ b/src/basic/Layer.h
@@ -0,0 +1,585 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BasicGraphicsObject.h
+    \brief Implementation of BasicGraphicsObject class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: March 2004
+
+*/
+#ifndef Layer_H
+#define Layer_H
+
+#include "magics.h"
+
+#include "MagLog.h"
+#include "BasicSceneObject.h"
+#include "BasicGraphicsObject.h"
+#include "DateTime.h"
+
+namespace magics {
+
+class SceneLayer;
+class AnimationRules;
+class Text;
+class TextVisitor;
+
+enum LayerState { new_layer, geometry_changed };
+
+class Layer : public BasicGraphicsObjectContainer
+{
+public: 
+	Layer();
+	Layer(BasicSceneObject*);
+	virtual ~Layer();
+	void print(ostream& out) const;
+	void parent(SceneLayer* layer) { parent_ = layer; }
+	SceneLayer* parent() const { return parent_; }
+	virtual void redisplay(const BaseDriver& driver) const ; 
+	virtual void execute(const BaseDriver&) const;
+	virtual void execute(int, const BaseDriver&, const Layout&) const;
+	virtual void getInfo(int, const BaseDriver&) const {} 
+	virtual void getReady(int) const;
+	virtual void getReady() const;
+	//! get the metada for the layer
+	virtual void collect(MetaDataCollector&) {}
+	//! get the values for the list of position ( in user coordinates)
+	virtual void collect(ValuesCollector&  values);
+	//! get the data indexes for the layer
+	virtual void collect(DataIndexCollector&) {}
+	/*! Prepare the list of positions (symbol) of the data points
+	 and send them back to the specified driver! */
+	virtual void magnify(const BaseDriver&, float ,float ) {}
+	/* Prepare Histogram for a layer and send it to the specified driver*/
+	virtual void histogram(const BaseDriver&,const string&,const string&) {}
+	
+	virtual void newLayer(const BaseDriver& driver);
+	virtual void closeLayer(const BaseDriver& driver);
+	virtual Layer* get() 	{ return 0; }
+	virtual Layer* get(int) { return 0; }
+	virtual Layer* baseLayer() { return this; }
+	
+	void visibility(bool visibility) { visibility_ = visibility; }
+	void zindex(int zindex) { zindex_ = zindex; }
+	void transparency(int transparency) { transparency_ = transparency; }
+	void valid(const DateTime& from, const DateTime& to) { from_ = from; to_ = to; }
+	
+	bool visibility() const { return visibility_; }
+	int transparency() const { return transparency_; }
+	int zindex() const { return zindex_; }
+	
+	const string& id() const {  return id_; }
+	void id(const string& id) { id_ = id; }
+	
+	const string& uniqueId() const {  return uniqueId_; }
+	void uniqueId(const string& id) { uniqueId_ = id; }
+
+	const string& name() const {  return name_; }
+	void name(const string& id) { name_ = id; }
+	
+	virtual int size() { return 1; }
+
+
+	bool  operator<(const Layer& other) const {return zindex_ < other.zindex_;}
+
+	void collectText(vector<TextVisitor*>&, LegendVisitor*); // update the text informations!
+	vector<Text*>& updateText(TextVisitor* text, const string& line) 
+	{ return myTexts_[text][line]; }
+	
+	string timeStamp(const string&) const;
+	string timeBegin(const string&) const;
+	string timeEnd(const string&) const;
+
+	string kmlTimeBegin() const;
+	string kmlTimeEnd() const;
+	string kmlTimeStamp() const ;
+	
+	const string& metadata(const string&);
+	void metadata(const string&, const string&);
+	virtual void update(const Layout&) {}
+
+
+
+
+	vector<MetviewIcon >::const_iterator iconsBegin() { return icons_.begin(); }
+	vector<MetviewIcon >::const_iterator iconsEnd() { return icons_.end(); }
+	void  icon(const string& iconname, const string& iconclass,const string& iconid) 
+			{  icons_.push_back(MetviewIcon(iconname, iconclass,iconid)); }
+	
+	//void setInfo(const string& name, const string& value) { information_[name]=value; }
+	//virtual const map<string, string>& getInfos(bool =false) const { return information_; }
+
+	LayerState state() { return state_; }
+	void state(LayerState state) { state_ = state; }
+	virtual void release();
+protected:
+	bool visibility_;
+	int zindex_;
+	int transparency_;
+	string name_;
+	LayerState state_;
+
+
+	// For Metview ...
+	vector<MetviewIcon> icons_;
+
+	map<string, string> metadata_;
+	
+	DateTime from_;
+	DateTime to_;
+	string id_;
+	string uniqueId_;
+	SceneLayer* parent_;
+	BasicSceneObject* object_;	
+
+	mutable map<TextVisitor*, map<string, vector<Text*> > > myTexts_;
+};
+
+
+
+
+/*
+ * A StepLayer maintains animation.
+ */
+class StepLayer;
+
+class SingleLayer : public Layer 
+{
+public:
+	SingleLayer(StepLayer*, BasicSceneObject*);
+	~SingleLayer();
+	
+	void print(ostream& out) const;
+	void redisplay(const BaseDriver& driver) const;
+	void execute(const BaseDriver&) const;
+	void getReady() const;
+	void set(LayoutVisitor*) const;
+	void collect(MetaDataCollector&);
+	void collect(ValuesCollector&);
+	void collect(DataIndexCollector&);
+	//const map<string, string>& getInfos(bool collect=false) const;
+	void magnify(const BaseDriver&, float xres,float yres);
+	void histogram(const BaseDriver&,const string&,const string&);
+	void update(const Layout&);
+	Layer* baseLayer();
+	LevelDescription& dataLevel() const;
+	DateDescription& timeStamp() const;
+
+  protected:
+	mutable Layout* objects_;
+	StepLayer* parentLayer_;
+	mutable LevelDescription level_;
+	mutable DateDescription  stamp_;
+};
+
+
+
+class StepLayer : public Layer
+{
+public:
+	StepLayer();
+	~StepLayer();
+	void print(ostream& out) const;
+	int size();
+	void redisplay(const BaseDriver& driver) const;	
+	void newLayer(const BaseDriver& driver);
+	void closeLayer(const BaseDriver& driver);
+	void execute(int, const BaseDriver&, const Layout&) const;
+	void getReady(int) const;
+	Layer* get(int);
+	
+	void addStep(BasicSceneObject*);
+	vector<SingleLayer*>::iterator firstStep() { return steps_.begin(); }
+	vector<SingleLayer*>::iterator endStep() { return steps_.end(); }	
+	
+	void addVisitor(LayoutVisitor*);
+	vector<LayoutVisitor*>::iterator firstVisitor()  { return visitors_.begin(); }
+	vector<LayoutVisitor*>::iterator endVisitor()  { return visitors_.end(); }
+
+  protected:
+	vector<SingleLayer*> steps_;
+	vector<LayoutVisitor*> visitors_;
+}; 
+
+
+class LayoutVisitor;
+
+
+class StaticLayer : public Layer 
+{
+public:
+	StaticLayer();
+	StaticLayer(BasicSceneObject*);
+	StaticLayer(const Layout&);
+	~StaticLayer();
+	void print(ostream& out) const;
+	
+	void redisplay(const BaseDriver& driver) const; 
+	void newLayer(const BaseDriver& driver);
+	void closeLayer(const BaseDriver& driver);
+
+	void histogram(const BaseDriver& driver,const string&,const string&);
+	void update(const Layout&);
+
+	void execute(const BaseDriver&) const;
+	void getReady() const;
+	Layer* get() { return this; }
+	void clean();
+	void set(LayoutVisitor*);
+	void add(BasicGraphicsObject*);
+	void collect(MetaDataCollector&);
+	void collect(ValuesCollector&);
+	void collect(DataIndexCollector&);
+
+
+protected:
+	Layout* layer_;
+	mutable bool updateText_;
+};
+
+/*
+ * A NoDataLayer is a static layer that do not contain ant data information :ie some driver like KML may 
+ * not need to handle them
+ */
+class NoDataLayer : public StaticLayer
+{
+public:
+	NoDataLayer() {}
+	NoDataLayer(BasicSceneObject*);
+	~NoDataLayer();
+	
+	void redisplay(const BaseDriver&) const;
+	void getReady() const {}
+};
+class TextLayer : public StepLayer
+{
+public:
+	TextLayer() {}
+	~TextLayer() {}
+	void getReady() const;
+	void execute(const BaseDriver&) const;
+	void execute(int, const BaseDriver&) const;
+	void getInfo(int, const BaseDriver&) const;
+	void collectText(vector<TextVisitor*>&, LegendVisitor*); // update the text informations!
+};
+/*
+ * A SceneLayer is attach to a SceneNode...
+ * It contains the list of layers needed to perform a plot.
+ * Some layers can have steps...
+ */
+class SceneLayer  : public  BasicGraphicsObjectContainer
+{
+public:
+	SceneLayer();
+	~SceneLayer();
+	void print(ostream& out) const;
+	// Number of frames in the serie! 
+	int numberOfSteps() const;
+	void rules(AnimationRules* rules) { rules_ = rules; }
+
+	void execute(int, const BaseDriver&) const;
+
+	void execute(Layer* ,int , const BaseDriver&) const;
+
+	Layer*  findLayer(Layer*,int) const; 
+	
+	void legend(LegendVisitor* legend) { legend_ = legend; }
+	void text(TextVisitor* text) { textVisitors_.push_back(text); }
+	
+	void getReady(int) const;
+
+	bool buildTree(const Layout&,  unsigned int, const BaseDriver&) const;
+
+	vector<Layer*>::iterator beginLayer() const;
+	vector<Layer*>::iterator endLayer() const;
+
+	vector<Layer*>::iterator beginLayer(int) const;
+	vector<Layer*>::iterator endLayer(int) const;
+
+	vector<Layer*>& prepare(int) const;
+	void redisplay(const BaseDriver& driver) const;
+	void redisplayAll(const BaseDriver& driver) const;
+	void add(Layer*);
+	Layout* layoutPtr()  { assert (layout_); return layout_; }
+	BasicGraphicsObjectContainer* parent() { return parent_; }
+	void addVisitor(LayoutVisitor* visitor) { visitors_.insert(visitor); }
+	void setMagicsMode(MagicsMode mode) { mode_ = mode; }
+	vector<TextVisitor*>& texts() { return textVisitors_; }
+	void cleanText(); 
+	void finishText(Layout& layout);
+	void collectText();
+	void executeInfo(int, const BaseDriver&) const;
+	
+	LegendVisitor* legend() { return legend_; }
+	LayerState state() { return state_; }
+	void state(LayerState state) { state_ = state; }
+
+protected:
+	mutable Layout* layout_;
+	AnimationRules* rules_;
+	int currentIndex_;
+
+	mutable map<int, vector<Layer*> > steps_;
+	mutable vector<Layer*> layers_;
+	mutable std::set<LayoutVisitor*> visitors_;
+	mutable  vector<TextVisitor*> textVisitors_;
+	mutable TextLayer textHandler_;
+
+	mutable LegendVisitor* legend_;
+	MagicsMode mode_;
+	int currentFrame_;
+	LayerState state_;
+};
+
+
+
+class MagnifierCollector : public vector<PaperPoint>
+{
+public:
+	MagnifierCollector() : transformation_(0), layout_(0) {}
+	~MagnifierCollector() {}
+	void  transformation(const Transformation* transformation) { transformation_ = transformation; }
+	void visit(const BaseDriver&);
+	void setLayout(Layout* layout) { layout_= layout; }
+	void setParent(BasicGraphicsObjectContainer* parent) { layout_->parent(parent); }
+	const Transformation& transformation() { return *transformation_; }
+protected:
+	const Transformation* transformation_;
+	Layout* layout_;
+};
+
+
+class ValuesCollectorData;
+class ValuesCollectorUVData;
+class ValuesCollectorSDData;
+
+class ValuesCollectorVisitor
+{
+public:
+	ValuesCollectorVisitor();
+	virtual void visit(const ValuesCollectorData& data);
+	virtual void visit(const ValuesCollectorUVData& data);
+	virtual void visit(const ValuesCollectorSDData& data);
+};
+
+class ValuesCollectorData
+{
+public:
+	ValuesCollectorData(double x, double y, double value, double distance,int index=-1) :
+	   x_(x), y_(y), value_(value), distance_(distance), missing_(false), index_(index) {}
+	   
+	double x() const {return x_;}
+	double y() const {return y_;}
+  	double value() const {return value_;}
+  	double distance() const {return distance_;}  
+  	void setScaledValue(double d) {scaledValue_=d;}
+  	double scaledValue() const {return scaledValue_;}
+  	bool missing() {return missing_;}
+  	void setMissing(bool b) {missing_=b;}
+  	int index() const {return index_;}
+  	virtual void visit(ValuesCollectorVisitor& visitor) {
+  		 visitor.visit(*this);
+  	}
+
+protected: 
+  	virtual void print(ostream&) const;
+	double x_;
+	double y_;
+	double value_;
+	double distance_;
+	double scaledValue_;
+	bool  missing_;
+	int index_;
+	
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ValuesCollectorData& p)
+		{ p.print(s); return s; }
+};	
+
+class ValuesCollectorUVData : public ValuesCollectorData
+{
+public:
+	ValuesCollectorUVData(double x, double y, double u, double v, double distance,int index=-1) :
+		ValuesCollectorData(x, y, 0, distance,index), xComponent_(u), yComponent_(v) {}
+
+ 	virtual void visit(ValuesCollectorVisitor& visitor)
+ 		{ visitor.visit(*this); }
+
+ 	double  xComponent() const { return xComponent_; }
+ 	double  yComponent() const { return yComponent_; }
+ 	double  scaledXComponent() const { return scaledXComponent_; }
+ 	double  scaledYComponent() const { return scaledYComponent_; }
+
+protected:
+ 	virtual void print(ostream&) const;
+	double xComponent_;
+	double yComponent_;
+	double scaledXComponent_;
+	double scaledYComponent_;	
+};
+
+class ValuesCollectorSDData : public ValuesCollectorData
+{
+public:
+	ValuesCollectorSDData(double x, double y, double s, double d, double distance,int index=-1) :
+		ValuesCollectorData(x, y, 0, distance,index), speed_(s), direction_(d) {}
+ 	virtual void visit(ValuesCollectorVisitor& visitor) {
+  		 visitor.visit(*this);
+  	}
+ 	double  speed() const { return speed_; }
+ 	double  direction() const { return direction_; }
+ 	double  scaledSpeed() const { return scaledSpeed_; }
+ 	double  scaledDirection() const { return scaledDirection_; }
+
+protected:
+ 	virtual void print(ostream&) const;
+	double speed_;
+	double direction_;
+	double scaledSpeed_;
+	double scaledDirection_;
+	
+};
+
+class ValuesCollectorPoint : public vector<ValuesCollectorData*>
+{
+public:
+	enum Mode {PositionMode,IndexMode};
+	
+	ValuesCollectorPoint(double x,double y) : mode_(PositionMode), x_(x), y_(y), index_(-1) {}
+	ValuesCollectorPoint(int index) : mode_(IndexMode), index_(index) {}
+	~ValuesCollectorPoint();
+	
+	Mode mode() const {return mode_;}
+	double x() const {return x_;}
+	double y() const {return y_;}
+	int index() const {return index_;}
+	
+protected:
+  	Mode mode_;
+	double x_;
+	double y_;
+	int index_;
+};
+
+
+class ValuesCollector : public vector<ValuesCollectorPoint> 
+{
+public:
+	ValuesCollector(string name=string()) : name_(name), scaled_(false), collected_(false),
+	              searchRadiusX_(2.),searchRadiusY_(2.), hasValue_(true) {}
+	~ValuesCollector() {}	
+	void  transformation(const Transformation* transformation) { transformation_ = transformation; }
+	const Transformation& transformation() { return *transformation_; }
+	const string& name() {return name_;}
+	const string& scaledUnits() const {return scaledUnits_;}
+	void  setScaledUnits(string s) {scaledUnits_=s;}
+	const string& units() const {return units_;}
+	void  setUnits(string s) {units_=s;}
+	bool  scaled() {return scaled_;}
+	void setScaled(bool b) {scaled_=b;}
+	bool  collected() {return collected_;}
+	void  setCollected(bool b) {collected_=b;}
+	void  setSearchRadius(double rx,double ry) {searchRadiusX_=rx; searchRadiusY_=ry;}
+	double searchRadiusX() {return searchRadiusX_;}
+	double searchRadiusY() {return searchRadiusY_;}
+	void setHasValue(bool b) {hasValue_=b;}
+	bool hasValue() {return hasValue_;}
+
+protected: 
+	const Transformation* transformation_;
+	string name_;
+	string units_;
+	string scaledUnits_;
+	bool scaled_;
+	bool collected_;
+	double searchRadiusX_;
+	double searchRadiusY_;
+	bool hasValue_;
+};
+
+class DataIndexCollector
+{
+public:
+	DataIndexCollector() {}
+	~DataIndexCollector() {}
+	
+        void setDataIndex(const vector<int>& d) {dataIndex_=d;}
+	const vector<int>& dataIndex() const {return dataIndex_;}
+
+protected: 
+  	vector<int> dataIndex_;
+};
+
+/*class MetaDataCollector : public map<string, string>
+{
+public:
+	MetaDataCollector() {}
+	~MetaDataCollector() {}	
+	bool isIntegerItem(const string& s) { return (integerItems_.find(s) != integerItems_.end()) ? true: false;}	
+	void setIntegerItem(const string& s) { integerItems_.insert(s);}
+
+protected:	
+	std::set<string> integerItems_;
+	
+};*/
+
+class MetaDataAttribute
+{
+public:
+   	enum Source {AnySource,InfoSource,GribApiSource};
+	enum Group  {NoGroup,StatsGroup};
+	enum Type   {NumberType,StringType};
+	
+	MetaDataAttribute() : source_(InfoSource), group_(NoGroup), type_(StringType) {};
+	void setSource(Source s) {source_=s;}
+	void setGroup(Group g) {group_=g;}
+	void setType(Type t) {type_=t;}
+	Source source() const {return source_;}
+	Type type() const {return type_;}
+	Group group() const {return group_;}
+
+protected: 
+	Source source_;
+	Group group_;
+	Type type_;
+};
+
+
+
+class MetaDataCollector : public map<string,string>
+{
+public:
+  	MetaDataCollector() : transformation_(0) {};
+	~MetaDataCollector() {};
+	
+	void  transformation(const Transformation* transformation) { transformation_ = transformation; }
+	const Transformation& transformation() { return *transformation_; }
+	void reset() {clear(); attributes_.clear();}	
+	void setAttribute(const string &key,const MetaDataAttribute &attr) {attributes_[key]=attr;}
+	const map<string,MetaDataAttribute>& attributes() {return attributes_;}
+	bool hasAttribute(const string& key) {return (attributes_.find(key) != attributes_.end());}
+	const MetaDataAttribute& attribute(const string& key) { return attributes_[key];}
+
+  protected:
+	map<string,MetaDataAttribute> attributes_;
+	const Transformation* transformation_;
+};  
+
+} // end of namespace
+#endif
diff --git a/src/basic/LayoutManager.cc b/src/basic/LayoutManager.cc
new file mode 100644
index 0000000..ef78212
--- /dev/null
+++ b/src/basic/LayoutManager.cc
@@ -0,0 +1,296 @@
+/*! \file LayoutManager.h
+    \brief Implementation of the Template class LayoutManager.
+    
+    Magics Team - ECMWF 2009
+    
+    Started: Mon 19-Jan-2009
+    
+    Changes:
+    
+*/
+
+
+
+#include "LayoutManager.h"
+#include "BasicSceneObject.h"
+#include "Layout.h"
+
+using namespace magics;
+
+
+LayoutManager::LayoutManager() : newpage_(false)
+{
+}
+
+
+LayoutManager::~LayoutManager() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LayoutManager::print(ostream& out)  const
+{
+	out << "LayoutManager[";
+	out << "]";
+}
+
+BottomVerticalLayoutManager::BottomVerticalLayoutManager()
+{
+	x_ = 0;
+	y_ = 0;
+}
+
+BottomVerticalLayoutManager::~BottomVerticalLayoutManager()
+{
+}
+ 
+BasicSceneNode* MagMLLayoutManager::block(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	Layout& layout = node->layout();
+		// first fits in width! 
+		double width = layout.x() + layout.width();
+		double height = layout.y() + layout.height();
+		if (100 - y_ - height >=  0 ) { 
+		   if ( x_ + width  <=100 ) {
+				// it fits perfectly! we set the postion for the node
+				layout.x(x_ +  layout.x() );				
+				layout.y(100 - y_ - layout.height());
+				//we prepare for another row!
+				x_ = 100;
+				maxy_ = std::max( maxy_,   y_ + height);
+				
+				
+				return parent;
+		   }
+		   else { // create another row!
+			   y_ = maxy_;
+			   x_ = 0;
+			   return inline_display(parent, node);	
+		   }
+		}
+		// Do not fit on this Layout!
+		return parent->newNode(node);
+}
+
+MagMLLayoutManager::MagMLLayoutManager()
+{
+    x_    = 0;
+    y_    = 0;
+    maxy_ = 0; 
+    maxx_ = 0;
+}
+
+BasicSceneNode* MagMLLayoutManager::inline_display(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	Layout& layout = node->layout();
+	// first fits in width! 
+	const double x = ( layout.x() ? layout.x() : x_);
+	const double y = ( layout.y() ? layout.y() : y_);
+	const double width  = x + layout.width();
+	const double height =     layout.height();
+
+	if (100 - y_ - height >=  0 )
+	{ 
+	   if ( width  <=100 )
+	   {
+			x_ = layout.x() ? layout.x() : x_;
+			y_ = layout.x() ? layout.y() : y_;
+			// it fits perfectly! we set the postion for the node
+			layout.x(x_);				
+			layout.y(100 - y_ - layout.height());
+			x_ = width;
+			maxy_ = std::max( maxy_,   y_ + height);
+			return parent;
+	   }
+	   else { // create another row!
+		   y_ = maxy_;
+		   x_ = 0;
+		   return inline_display(parent, node);	
+	   }
+	}
+	// Do not fit on this Layout!
+	return parent->newNode(node);
+}
+
+BasicSceneNode* MagMLLayoutManager::absolute(BasicSceneNode* parent, BasicPositionalObject*)
+{
+	return parent;
+}
+
+std::map<DisplayType, MagMLLayoutManager::Action> MagMLLayoutManager::actions_;
+
+BasicSceneNode* MagMLLayoutManager::operator()(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	 Layout& layout = node->layout();
+	 
+	 DisplayType display = layout.display();
+	 
+	 if ( actions_.empty() ) {
+		 	actions_[INLINE] = &MagMLLayoutManager::inline_display;
+		 	actions_[ABSOLUTE] = &MagMLLayoutManager::absolute;
+		 	actions_[BLOCK] = &MagMLLayoutManager::block;
+	 }
+	 
+	 std::map<DisplayType, Action>::iterator action = actions_.find(display);
+
+	 if ( action == actions_.end() )
+	 {
+		 return inline_display(parent, node);
+	 }
+	 return (this->*action->second)(parent, node);
+}
+ 
+ BasicSceneNode*  BottomVerticalLayoutManager::operator()(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	Layout& layout = node->layout();
+	// first fits in width! 
+	if ( x_ + layout.width()  <=100 ) {
+	   if (y_ +layout.height() <=100 ) { 
+			// it fits perfectly! we set the postion for the node
+			layout.x(x_);
+			layout.y(y_);
+			y_ += layout.height() + gapy_;
+			return parent;
+	   }
+	   else { // create another column
+		   x_ += layout.width() + gapx_;
+		   y_ = 0;
+		   // try again! 
+		   return (*this)(parent, node);	
+	   }
+	}
+	// Nothing to do on this page!
+
+	return parent->newNode(node);
+}
+ 
+BottomHorizontalLayoutManager::BottomHorizontalLayoutManager()
+{
+ 	x_ = 0;
+ 	y_ = 0;
+}
+
+BottomHorizontalLayoutManager::~BottomHorizontalLayoutManager()
+{
+}
+  
+BasicSceneNode*  BottomHorizontalLayoutManager::operator()(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	  Layout& layout = node->layout();
+	// first fits in width! 
+
+	   if (y_ + layout.height() <=  100 ) { 
+		   if ( x_ + layout.width()  <=100 ) {
+			// it fits perfectly! we set the postion for the node
+			layout.x(x_);				
+			x_=  x_ + layout.width();
+			layout.y(y_);
+			return parent;
+	   }
+	   else { // create another row
+		   x_ = 0;
+		  y_ = y_ + layout.height() + gapy_;
+		   return (*this)(parent, node);	
+	   }
+	}
+	// Do not fit on this Layout!
+	return parent->newNode(node);
+}
+
+TopVerticalLayoutManager::TopVerticalLayoutManager()
+{
+	x_ = 0;
+	y_ = 100;
+}
+
+TopVerticalLayoutManager::~TopVerticalLayoutManager()
+{
+}
+
+BasicSceneNode*  LayoutManager::operator()(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	if ( newpage_ ) {
+		newpage_ = false; 
+		return parent->newNode(node);
+	}
+	else 
+		return parent;
+}
+
+TopHorizontalLayoutManager::TopHorizontalLayoutManager()
+{
+	x_ = 0;
+	y_ = 100;
+}
+
+TopHorizontalLayoutManager::~TopHorizontalLayoutManager()
+{ 
+}
+
+BasicSceneNode*  TopHorizontalLayoutManager::operator()(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+	  Layout& layout = node->layout();
+	// first fits in width! 
+
+	   if (y_ - layout.height() >=  0 ) { 
+		   if ( x_ + layout.width()  <=100 ) {
+			// it fits perfectly! we set the postion for the node
+			layout.x(x_);				
+			x_=  x_ + layout.width();
+			layout.y(y_- layout.height());
+			return parent;
+	   }
+	   else { // create another column
+		   x_ = 0;
+		  y_ -= layout.height() - gapy_;
+		   return (*this)(parent, node);	
+	   }
+	}
+	// Do not fit on this Layout!
+	return parent->newNode(node);
+}
+
+ 
+LayoutManager* LayoutManager::manager(const string& type, const string& start, const string& direction)
+{
+	 if ( magCompare(type, "magml") )
+		 return new MagMLLayoutManager();
+	 if ( magCompare(type, "automatic") ) {
+		 if ( magCompare(start, "bottom") ) {
+			 if ( magCompare(direction, "vertical") ) 
+				 return new BottomVerticalLayoutManager();
+			return new BottomHorizontalLayoutManager();
+		 }
+		 
+		if ( magCompare(direction, "vertical") ) 
+				return new TopVerticalLayoutManager(); 
+		return new TopHorizontalLayoutManager();			
+    }
+	 
+
+	 return new LayoutManager();
+}
+ 
+BasicSceneNode*  TopVerticalLayoutManager::operator()(BasicSceneNode* parent, BasicPositionalObject* node)
+{
+ 	Layout& layout = node->layout();
+ 	// first fits in width! 
+ 	if ( x_ + layout.width()  <=100 ) {
+ 	   if (y_ - layout.height() >=  0 ) { 
+ 			// it fits perfectly! we set the postion for the node
+ 			layout.x(x_);				
+ 			y_ -= layout.height() - gapy_;
+ 			layout.y(y_);
+ 			return parent;
+ 	   }
+ 	   else { // create another column
+ 		   x_ += layout.width() + gapx_;
+ 		   y_ = 100;
+ 		   return (*this)(parent, node);	
+ 	   }
+ 	}
+ 	// Do not fit on this Layout!
+ 	return parent->newNode(node);
+}
diff --git a/src/basic/LayoutManager.h b/src/basic/LayoutManager.h
new file mode 100644
index 0000000..7a2601b
--- /dev/null
+++ b/src/basic/LayoutManager.h
@@ -0,0 +1,187 @@
+/*! \file LayoutManager.h
+    \brief Definition of the Template class LayoutManager.
+    
+    Magics Team - ECMWF 2009
+    
+    Started: Mon 19-Jan-2009
+    
+    Changes:
+    
+*/
+
+#ifndef LayoutManager_H
+#define LayoutManager_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class BasicSceneNode; 
+class BasicPositionalObject; 
+
+class LayoutManager {
+
+public:
+	LayoutManager();
+	virtual ~LayoutManager();
+	
+	virtual LayoutManager* clone() { return new LayoutManager(); }
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual LayoutManager* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new LayoutManager();
+    }
+    
+    void newpage() { newpage_ = true; }
+    
+    virtual BasicSceneNode* operator()(BasicSceneNode* parent, BasicPositionalObject* node);
+    
+    static LayoutManager* manager(const string& type, const string& start, const string& direction);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	bool newpage_; 
+
+private:
+    //! Copy constructor - No copy allowed
+	LayoutManager(const LayoutManager&);
+    //! Overloaded << operator to copy - No copy allowed
+	LayoutManager& operator=(const LayoutManager&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LayoutManager& p)
+		{ p.print(s); return s; }
+
+};
+
+class AutomaticLayout : public LayoutManager
+{
+public:
+	 	AutomaticLayout(): x_(0), y_(0), gapx_(0), gapy_(0) {}
+		~ AutomaticLayout() {}
+	
+		void gapx(double gapx) { gapx_ = gapx; }
+		void gapy(double gapy) { gapx_ = gapy; }
+		
+protected:
+	   double x_;
+	   double y_;
+	   double gapx_;
+	   double gapy_;
+};
+
+class MagMLLayoutManager : public AutomaticLayout
+{
+public:
+	    MagMLLayoutManager() ;
+		~ MagMLLayoutManager() {}
+		BasicSceneNode* operator()(BasicSceneNode* parent, BasicPositionalObject* node);
+		virtual LayoutManager* clone() { 
+			MagMLLayoutManager* layout = new MagMLLayoutManager(); 
+					
+					return layout;
+								
+				}
+		
+protected:
+	    BasicSceneNode* block(BasicSceneNode* parent, BasicPositionalObject* node);
+	    BasicSceneNode* inline_display(BasicSceneNode* parent, BasicPositionalObject* node);
+	    BasicSceneNode* absolute(BasicSceneNode* parent, BasicPositionalObject* node);
+	    
+		typedef BasicSceneNode* (MagMLLayoutManager::*Action)(BasicSceneNode* parent, BasicPositionalObject* node);
+		static std::map<DisplayType, Action> actions_;
+		double maxy_;
+		double maxx_;
+};
+
+class BottomVerticalLayoutManager : public AutomaticLayout
+{
+public:
+	BottomVerticalLayoutManager();
+		~ BottomVerticalLayoutManager();
+		BasicSceneNode* operator()(BasicSceneNode* parent, BasicPositionalObject* node);
+		virtual LayoutManager* clone() { 
+			BottomVerticalLayoutManager* layout = new BottomVerticalLayoutManager(); 
+			layout->gapx_ = gapx_;
+			layout->gapy_ = gapy_;
+			return layout;
+						
+		}
+};
+
+class BottomHorizontalLayoutManager : public AutomaticLayout
+{
+public:
+	BottomHorizontalLayoutManager();
+		~ BottomHorizontalLayoutManager();
+		BasicSceneNode* operator()(BasicSceneNode* parent, BasicPositionalObject* node);
+		virtual LayoutManager* clone() { 
+			BottomHorizontalLayoutManager* layout = new BottomHorizontalLayoutManager(); 
+			layout->gapx_ = gapx_;
+			layout->gapy_ = gapy_;
+			return layout;
+						
+		}
+};
+
+class TopHorizontalLayoutManager : public AutomaticLayout
+{
+public:
+	TopHorizontalLayoutManager();
+		~ TopHorizontalLayoutManager();
+		BasicSceneNode* operator()(BasicSceneNode* parent, BasicPositionalObject* node);
+		virtual LayoutManager* clone() { 
+			TopHorizontalLayoutManager* layout = new TopHorizontalLayoutManager(); 
+			layout->gapx_ = gapx_;
+			layout->gapy_ = gapy_;
+			return layout;
+						
+		}
+};
+
+class TopVerticalLayoutManager : public AutomaticLayout
+{
+public:
+	TopVerticalLayoutManager();
+		~ TopVerticalLayoutManager();
+		BasicSceneNode* operator()(BasicSceneNode* parent, BasicPositionalObject* node);
+		virtual LayoutManager* clone() { 
+			TopVerticalLayoutManager* layout = new TopVerticalLayoutManager(); 
+			layout->gapx_ = gapx_;
+			layout->gapy_ = gapy_;
+			return layout;
+						
+		}
+};
+
+
+template <>
+class MagTranslator<string, LayoutManager> { 
+public:
+	LayoutManager* operator()(const string& val )
+	{
+		return SimpleObjectMaker<LayoutManager>::create(val);
+	}     
+
+	LayoutManager* magics(const string& param)
+	{
+		LayoutManager* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/LegendVisitor.cc b/src/basic/LegendVisitor.cc
new file mode 100644
index 0000000..78d1a55
--- /dev/null
+++ b/src/basic/LegendVisitor.cc
@@ -0,0 +1,1302 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! 
+    \brief Implementation of the Template class LegendNode.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Tue 6-Mar-2007
+
+    Changes:
+
+*/
+
+
+#include "LegendVisitor.h"
+#include "Text.h"
+#include "Polyline.h"
+
+#include "Arrow.h"
+#include "Flag.h"
+#include "Symbol.h"
+#include "Transformation.h"
+#include "Dimension.h"
+#include "MagicsFormat.h"
+#include "AnimationRules.h"
+#include "LegendMethod.h"
+
+using namespace magics;
+
+LegendVisitor::LegendVisitor() 
+{
+	static int i = 0;
+	ostringstream n;
+	BasicSceneObject::name(n.str());
+
+	i++;
+	layout_ = new Layout();
+	layout_->name("legend");
+	current_ = layout_;
+    compositions_["both"] = &LegendVisitor::both;
+    compositions_["automatic_text_only"] = &LegendVisitor::automatic_only;
+    compositions_["user_text_only"] = &LegendVisitor::user_only;
+	view_x_ = 5; 
+	view_y_ = 5; 
+	view_width_ = 90; 
+	view_height_=90;
+}
+
+
+LegendVisitor::~LegendVisitor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LegendVisitor::print(ostream& out)  const
+{
+	out << "LegendVisitor[";
+		LayoutVisitor::print(out);
+	out << "]";
+}
+
+
+
+void LegendVisitor::visit(BasicGraphicsObjectContainer&)
+{
+	// Noew populate the layout ...
+	//tree.push_back(current_);
+	// the Layout has been added to a Container, it will be delted automatically!
+}
+
+
+void LegendVisitor::visit(BasicSceneObject& parent)
+{
+	// First visit the parent to collect the legend entry! 
+	parent.visit(*this);
+}
+
+void LegendVisitor:: visit(AnimationStep& )
+{
+}
+PaperPoint LegendEntry::centreSymbolBox(const PaperPoint& middle)
+{
+	// The box is going from x-1 to x+1
+	// The width of the Symbol box is 100-width;
+	PaperPoint point(middle);
+	point.x_ = (middle.x_-1) + ((100-width_)/100);
+	MagLog::dev() << "LegendEntry::centreSymbolBox" << point << endl;
+	return point;
+}
+
+PaperPoint LegendEntry::leftTextBox(const PaperPoint& middle)
+{
+	// The box is going from x-1 to x+1
+	// The width of the Symbol box is 100-width;
+
+	PaperPoint point(middle);
+	point.x_ = (middle.x_-1) + (2*(100-width_)/100);
+	MagLog::dev() << "LegendEntry::leftTextBox" << point << endl;
+	return point;
+}
+double LegendEntry::computeWidth(double width)
+{
+	return ((100-width_)/50)*width;
+}
+
+void LineEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& out)
+{
+	double x = point.x();
+	double y = point.y();
+	double width = 1;
+	line_->push_back(PaperPoint(x- width, y));
+	line_->push_back(PaperPoint(x, y));
+	out.push_back(line_);
+}
+void LineEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& out)
+{
+	set(point, out);
+}
+
+void DoubleLineEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& out)
+{
+	set(point, out);
+}
+void DoubleLineEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& out)
+{
+	set(point, out);
+}
+
+void LegendVisitor::build()
+{
+	vector<pair<float, float> > positions;
+    double xtitle, ytitle;
+
+
+	legend_ = new LegendLayout();
+	
+	legend_->x(view_x_);
+	legend_->y(view_y_);
+	legend_->width(view_width_);
+	legend_->height(view_height_);
+	current_->setCoordinates(0, 100, 0, 100);
+	current_->clear();
+	current_->blankIt();
+	current_->push_back(legend_);
+	
+
+	grid(positions, xtitle, ytitle);
+
+
+	// populate the layout!
+
+	vector<string>::const_iterator label = lines_.begin();		
+	vector<pair<float, float> >::const_iterator position = positions.begin();	
+	if ( title_ )
+	{
+		Text* legend = new Text();
+		MagFont font; 
+		font.size(font_size_);
+		font.colour(Colour(*colour_));	
+		//text->setAngle(( orientation_ == "horizontal" ) ? 0 : angle);
+		legend->setFont(font);
+		legend->setText(title_text_);
+
+		legend_->push_back(legend);
+		if ( magCompare(direction_, "column") ){
+			if  ( magCompare(title_orientation_, "horizontal") ) {
+				(*legend).push_back(PaperPoint(xtitle, ytitle));
+			}
+			else {
+			     legend->setAngle(3*3.14/2.);
+			     (*legend).push_back(PaperPoint(xtitle, ytitle));
+			}
+		}
+		else 
+			(*legend).push_back(PaperPoint(xtitle, ytitle));
+	}
+	
+	if ( use_min_ ) {
+		front()->userText(use_min_text_);
+	}
+	if ( use_max_ ) {
+		back()->userText(use_max_text_);
+	}
+
+	for(vector<LegendEntry*>::const_iterator entry = begin(); entry != end(); ++entry)
+	{
+		(*entry)->width(text_width_);
+		Text* legend = new Text();
+		MagFont font(font_, font_style_, font_size_);
+		font.colour(*colour_);
+		(*entry)->font(font);
+		(*entry)->angle((orientation_/180.)*3.14);
+		(*entry)->borderColour(entry_border_ ? *entry_border_colour_ : Colour("automatic"));
+
+		(*entry)->set(*this);
+		string text;
+		if ( (*entry)->needText() ) {
+			std::map<string, Composition>::iterator composition = compositions_.find(lowerCase(composition_));
+			string user;
+			// if the entry has its own user text we use it in priority!
+			string utext = (*entry)->userText();
+			if ( !utext.empty() )
+				user = utext;
+			else
+				user = ( label != lines_.end() ) ? *label: "";
+			string automatic = (*entry)->label();
+
+			if ( composition == compositions_.end() )
+			{
+				text = both(automatic, user);
+			}
+			else
+				text = (this->*composition->second)(automatic, user);
+
+		}
+
+		legend->setFont(font);
+		legend->setText(text);
+		legend->setAngle((orientation_/180.)*3.14);
+		(*legend).setVerticalAlign(orientation_ ? MBOTTOM : MHALF);
+		if ( ! lines_.empty() ) {
+			++label;		
+			if (label == lines_.end()) --label;
+		}
+		if (text=="ignore") continue;
+	    (magCompare(direction_, "column") ) ? 
+			(*method_).column(**entry, position->first, position->second, *legend, *legend_) :
+			(*method_).row(**entry, position->first, position->second, *legend, *legend_);
+
+
+		++position;
+		legend->setAngle((orientation_/180.)*3.14);
+		legend_->push_back(legend);
+	}
+	current_->frameIt();
+}
+
+
+
+void LegendVisitor::grid(vector<pair<float, float> >& positions, double& xtitle, double& ytitle)
+{
+    if ( magCompare(direction_, "automatic")  ) {
+    	if ( current_->absoluteWidth() <  current_->absoluteHeight() ) 
+    		direction_ = "column";
+	}
+
+	unsigned int count = 0;
+	vector<string>::const_iterator label = lines_.begin();		
+	
+	for(vector<LegendEntry*>::const_iterator entry = begin(); entry != end(); ++entry)
+	{		 
+		
+		(*entry)->set(*this);
+		string text = ( label != lines_.end() && !label->empty() ) ? *label : (*entry)->label();			
+			
+		if ( ! lines_.empty() ) {
+			++label;		
+			if (label == lines_.end()) --label;
+		}
+		if (text=="ignore") continue;
+		count++;
+	}
+	
+	// here we know the number of entries.. count
+	
+	double xmin, ymin, xmax, ymax;
+	if (magCompare(direction_, "column") ){
+		int row = 1;
+		int column = 1;
+		int rows = count/columns_;
+		if ( count % columns_ )
+			rows++;
+
+		// calclate the number of rows we need! 
+		for (unsigned int i = 0; i < count; i++ ) {	
+			MagLog::debug() << "add position [" <<  column << ", " << row << "]" << endl;		 			 
+			positions.push_back(make_pair(column, row));
+			row++;
+			if (row > rows ) {		
+			 	row = 1;
+				column+=2;
+			 }
+		}
+
+		// Check title and orientation...
+		if ( title_ ) {
+			if ( magCompare(title_orientation_, "horizontal") ) {
+				xmin = -0.1;
+				xmax = columns_*2,
+				ymin = 0;
+				ymax = rows + 1.;
+				xtitle = (xmax-xmin)/2;
+				ytitle = ymax - 0.4;
+				if ( magCompare(entry_orientation_, "top_bottom") ) {
+					ytitle = 0.4;
+					ymax= rows;
+					ymin=0;
+				}
+			}
+			else {
+				xmin = -0.8;
+				xmax = columns_*2,
+				ymin = 0.5;
+				ymax = rows + 0.5 ;
+				xtitle = -0.1;
+				ytitle = (ymax-ymin)/2;;
+			}
+		}
+		else {
+			xmin = 0;
+			xmax = columns_*2,
+			ymin = 0.5;
+			ymax = rows+0.5;
+		}
+		legend_->setCoordinates( xmin, xmax, ymin, ymax);
+		if ( magCompare(entry_orientation_, "top_bottom") )
+			legend_->setCoordinates(  xmin, xmax, ymax, ymin);
+	return;
+	}
+
+	int rows = 1;
+	int column = 0;
+
+	for (unsigned int i = 0; i < count; i++ ) {	
+		MagLog::debug() << "add position [" <<  column*2+1 << ", " << rows << "]" << endl;
+		 positions.push_back(make_pair(column*2+1, rows));
+		 column++;
+		 if ( columns_ > 1 && column >= columns_ ) {		
+			column = 0;
+			rows++;
+		 }
+	}
+
+	int nb = ( columns_ > 1) ? columns_: count;
+
+	if ( title_ ) {
+		xtitle = nb;
+		ytitle = 0;
+		legend_->setCoordinates(nb*2 + 0.5, -0.5,  rows + 0.5, -2);
+		legend_->setCoordinates(0, nb*2, rows + 0.5, -1);
+	}
+	else 
+		legend_->setCoordinates(0, nb*2,  rows + 1, 0);
+}
+
+void SymbolEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+	double width = computeWidth(0.8)/2;
+	double height = 0.4;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+
+	double incx=width/3;
+	double incy=height/3;
+
+	Colour colour = ( borderColour_.automatic() ) ? symbol_->getColour() : borderColour_;
+
+	for (float px = x - width; px < x+width; px+=incx )
+		for (float py =y - height+ incy; py < y+height; py+=incy )
+			symbol_->push_back(PaperPoint(px, py));
+
+	 legend.push_back(symbol_);
+}
+
+void SymbolEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+	double width = 1;
+	double height = 0.5;
+
+	double x = point.x();
+	double y = point.y();
+
+	double incx=width/3;
+	double incy=height/6;
+
+
+	Polyline*  frame = new Polyline();
+	Colour colour = ( borderColour_.automatic() ) ? symbol_->getColour() : borderColour_;
+	frame->setColour(Colour("grey"));
+	frame->push_back(PaperPoint(x-width, y-height));
+	frame->push_back(PaperPoint(x-width, y+height));
+	frame->push_back(PaperPoint(x+width, y+height));
+	frame->push_back(PaperPoint(x+width, y-height));
+	frame->push_back(PaperPoint(x-width, y-height));
+	legend.push_back(frame);
+	for (float px = x - width; px < x+width; px+=incx )
+		for (float py =y - height+ incy; py < y+height; py+=incy )
+			symbol_->push_back(PaperPoint(px, py));
+	legend.push_back(symbol_);
+}
+
+void SymbolEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	double width = computeWidth(0.8)/2;
+	double height = 0.2;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+
+	double incx=width/3;
+	double incy=height/3;
+
+
+	Polyline*  frame = new Polyline();
+	Colour colour = ( borderColour_.automatic() ) ? symbol_->getColour() : borderColour_;
+	frame->setColour(Colour("grey"));
+	frame->push_back(PaperPoint(x-width, y-height));
+	frame->push_back(PaperPoint(x-width, y+height));
+	frame->push_back(PaperPoint(x+width, y+height));
+	frame->push_back(PaperPoint(x+width, y-height));
+	frame->push_back(PaperPoint(x-width, y-height));
+	legend.push_back(frame);
+	for (float px = x - width; px < x+width; px+=incx )
+		for (float py =y - height+ incy; py < y+height; py+=incy )
+			symbol_->push_back(PaperPoint(px, py));
+	legend.push_back(symbol_);
+}
+
+Colour SymbolEntry::colour()
+{
+	return symbol_->getColour();
+}
+
+void ArrowEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+
+	PaperPoint pos(centreSymbolBox(point));
+	double width = computeWidth(0.8)/2;
+    pos.x_ -= width;
+	arrow_->push_back(ArrowPoint(arrow_->getScale(), 0, pos));
+	legend.push_back(arrow_);
+}
+void ArrowEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+	set(point, legend);
+	Text* text = new Text();
+	text->addText(label_, font_);
+	text->push_back(leftTextBox(point));
+	text->setJustification(MLEFT);
+	legend.push_back(text);
+}
+void ArrowEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+    PaperPoint pos(centreSymbolBox(point));
+    double width = computeWidth(0.8)/2;
+    pos.x_ -= width;
+	pos.y_ += 0.2;
+	
+    Text* text = new Text();
+	text->addText(label_, font_);
+	text->push_back(pos);
+	text->setJustification(MLEFT);
+	legend.push_back(text);
+
+	
+	pos.y_ -= 0.2;
+	arrow_->push_back(ArrowPoint(arrow_->getScale(), 0, pos));
+	legend.push_back(arrow_);
+}
+
+void FlagEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	PaperPoint pos = centreSymbolBox(point);
+	double width = computeWidth(0.8)/2;
+    pos.x_ -= width;
+	flag_->push_back(ArrowPoint(0, 0, pos));
+	legend.push_back(flag_);
+	flag_->setLength(1.5);
+	flag_->back().set(40, 85);
+
+
+}
+
+void  FlagEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	set(point, legend);
+	Text* text = new Text();
+	text->addText(label_, font_);
+	text->push_back(leftTextBox(point));
+	text->setJustification(MLEFT);
+	legend.push_back(text);
+}
+void  FlagEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	set(point, legend);
+	PaperPoint pos(centreSymbolBox(point));
+    double width = computeWidth(0.8)/2;
+    pos.x_ -= width;
+	pos.y_ += 0.2;
+
+    Text* text = new Text();
+	text->addText(label_, font_);
+	text->push_back(pos);
+	text->setJustification(MLEFT);
+	legend.push_back(text);
+}
+Colour BoxEntry::colour()
+{
+	return box_->getFillColour();
+}
+
+void LegendEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	Polyline*  box = new Polyline();
+	FillShadingProperties* shading = new FillShadingProperties();    
+	box->setFillColour(colour());
+	box->setShading(shading);
+	
+	Polyline*  frame = new Polyline();
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = 0.8;
+	double height = 0.5;
+	double x = point.x();
+	double y = point.y();
+	
+	box->push_back(PaperPoint(x, y-height));
+	box->push_back(PaperPoint(x, y+height));
+	box->push_back(PaperPoint(x+2, y+height));
+	box->push_back(PaperPoint(x+2, y-height));
+	box->push_back(PaperPoint(x-width, y-height));
+	box->setColour(Colour("black"));
+	frame->setColour(Colour("black"));
+	frame->push_back(PaperPoint(x-width, y-height));
+	frame->push_back(PaperPoint(x-width, y+height));
+	frame->push_back(PaperPoint(x+2, y+height));
+	frame->push_back(PaperPoint(x+2, y-height));
+	frame->push_back(PaperPoint(x-width, y-height));
+
+
+	legend.push_back(frame);
+}
+
+
+void LegendEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	Polyline*  box = new Polyline();
+	Colour col = colour();
+	if ( col == "none") {
+		FillShadingProperties* shading = new FillShadingProperties();    
+		box->setFillColour(colour());
+
+		box->setShading(shading);
+	}
+	Polyline*  frame = new Polyline();
+
+	
+	double x = point.x();
+	double y = point.y();
+	double width = 0.4;
+	double height = 0.5;
+	
+	box->push_back(PaperPoint(x-width, y-height));
+	box->push_back(PaperPoint(x-width, y+height));
+	box->push_back(PaperPoint(x, y+height));
+	box->push_back(PaperPoint(x, y-height));
+	box->push_back(PaperPoint(x-width, y-height));
+	box->setColour(Colour("black"));
+	frame->setColour(Colour("black"));
+	frame->push_back(PaperPoint(x-width, y-height));
+	frame->push_back(PaperPoint(x-width, y+height));
+	frame->push_back(PaperPoint(x, y+height));
+	frame->push_back(PaperPoint(x, y-height));
+	frame->push_back(PaperPoint(x-width, y-height));
+	
+	
+	legend.push_back(frame);
+
+	ostringstream top, bottom;
+	top << MagicsFormat(format_, from_); 
+	bottom << MagicsFormat(format_,  to_); 
+
+
+	Text* from = new Text();
+	Text* to = new Text();
+	from->setVerticalAlign(MHALF);
+
+	to->setVerticalAlign(MHALF);		
+	from->addText(top.str(), font_);
+
+	to->addText(bottom.str(), font_);
+
+	to->push_back(PaperPoint(x+0.25, y + height));
+	from->push_back(PaperPoint(x+0.25, y - height));
+
+	legend.push_back(from);
+	legend.push_back(to);
+}
+
+void EmptyEntry::rowBox(const PaperPoint&, BasicGraphicsObjectContainer&)
+{		
+}
+
+void EmptyEntry::columnBox(const PaperPoint& point , BasicGraphicsObjectContainer& legend)
+{
+}
+
+void BoxEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = computeWidth(0.8)/2;
+	double height = 0.4;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+	box_->push_back(PaperPoint(x-width, y-height));
+	box_->push_back(PaperPoint(x-width, y+height));
+	box_->push_back(PaperPoint(x+width, y+height));
+	box_->push_back(PaperPoint(x+width, y-height));
+	box_->push_back(PaperPoint(x-width, y-height));
+	box_->setColour(Colour("black"));
+
+	legend.push_back(box_);	
+}
+
+
+void BoxEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+//	ShadingProperties* shading = box_->getShading();    
+	//Normall the pilyline left the low value on their left!
+
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = 1;
+	double height = 0.4;
+	double x = point.x();
+	double y = point.y();
+
+	if ( text_ ) {
+		Text* from = new Text();
+		from->push_back(PaperPoint(x-width, y - height - 0.25));
+		from->setVerticalAlign(MBOTTOM);
+		from->setAngle(angle_);
+		legend.push_back(from);
+		if ( userText_.empty()  || last_) {
+			ostringstream bottom;
+			bottom << MagicsFormat(format_, from_);
+			from->addText(bottom.str(), font_);
+		}
+		else
+			from->addText(userText_, font_);
+	}
+	if ( last_ ) {		
+		Text* to = new Text();
+		to->setAngle(angle_);
+		to->setVerticalAlign(MBOTTOM);
+		to->push_back(PaperPoint(x+width, y - height- 0.25));
+		legend.push_back(to);
+		if ( userText_.empty()  ) {
+			ostringstream top, bottom;
+			top << MagicsFormat(format_, to_);
+			to->addText(top.str(), font_);
+		}
+		else
+			to->addText(userText_, font_);
+	}
+
+
+	box_->push_back(PaperPoint(x-width, y-height));
+	box_->push_back(PaperPoint(x-width, y+height+height));
+	box_->push_back(PaperPoint(x+width, y+height+height));
+	box_->push_back(PaperPoint(x+width, y-height));
+	box_->push_back(PaperPoint(x-width, y-height));
+	// Small check 
+	Colour colour = ( borderColour_.automatic() ) ? box_->getFillColour() : borderColour_;
+
+	if ( box_->getFillColour() == Colour("none") ) {
+		box_->setFilled(false);
+		colour = Colour("black");
+	}
+	box_->setColour(colour);
+
+
+	legend.push_back(box_);
+}
+
+void BoxEntry::rowHisto(const PaperPoint& point, BasicGraphicsObjectContainer& legend, const Colour& colour)
+{
+//	ShadingProperties* shading = box_->getShading();
+	//Normall the pilyline left the low value on their left!
+
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = 1;
+	double bottom = -0.7;
+	double top = -0.8 + (1. * population_/totalPopulation_);
+
+	double x = point.x();
+	double y = point.y()-1;
+	vector<Polyline*> ticks;
+
+	Colour grid_colour = histogram_->gridColour();
+	int grid_thickness = histogram_->gridThickness();
+	LineStyle grid_style = histogram_->gridStyle();
+
+	if ( text_ ) {
+			Text* from = new Text();
+			from->push_back(PaperPoint(x-width, y + 1.3));
+			from->setVerticalAlign(MTOP);
+			from->setAngle(angle_);
+			legend.push_back(from);
+			if ( userText_.empty()  || last_) {
+				ostringstream bottom;
+				bottom << MagicsFormat(format_, from_);
+				from->addText(bottom.str(), font_);
+			}
+			else
+				from->addText(userText_, font_);
+			Polyline* tick = new Polyline();
+            tick->setLineStyle(M_SOLID);
+			tick->setColour(Colour("black"));
+			tick->push_back(PaperPoint(x-width, y + 1.1));
+			tick->push_back(PaperPoint(x-width,  y + 0.85));
+			ticks.push_back(tick);
+		}
+		if ( last_ ) {
+			Text* to = new Text();
+			to->setAngle(angle_);
+			to->setVerticalAlign(MTOP);
+			to->push_back(PaperPoint(x+width, y + 1.3));
+			legend.push_back(to);
+			if ( userText_.empty()  ) {
+				ostringstream top, bottom;
+				top << MagicsFormat(format_, to_);
+				to->addText(top.str(), font_);
+			}
+			else
+				to->addText(userText_, font_);
+
+			Polyline* axe = new Polyline();
+			axe->setColour(grid_colour);
+			axe->setThickness(grid_thickness);
+			axe->setLineStyle(grid_style);
+			axe->push_back(PaperPoint(x+width, y -0.2));
+			axe->push_back(PaperPoint(x+width,  y + 0.8));
+			legend.push_back(axe);
+			Polyline* tick = new Polyline();
+			tick->setLineStyle(M_SOLID);
+			tick->setColour(Colour("black"));
+			tick->push_back(PaperPoint(x+width, y + 1.1));
+			tick->push_back(PaperPoint(x+width,  y + 0.85));
+			ticks.push_back(tick);
+		}
+	if ( first_ ) {
+		Text* to = new Text();
+		to->setAngle(angle_);
+		to->setVerticalAlign(MBOTTOM);
+		to->setJustification(MRIGHT);
+		to->push_back(PaperPoint(x-width, y - 0.2 ));
+		legend.push_back(to);
+		if ( userText_.empty() && histogram_->max() ) {
+			ostringstream top, bottom;
+			top << MagicsFormat(format_, totalPopulation_);
+			to->addText(top.str(), font_);
+		}
+		else
+			to->addText(userText_, font_);
+		Polyline* axe = new Polyline();
+		axe->setColour(grid_colour);
+		axe->setThickness(grid_thickness);
+		axe->setLineStyle(grid_style);
+		axe->push_back(PaperPoint(x-width, y - 0.2));
+		axe->push_back(PaperPoint(x-width,  y + 0.8));
+        
+		legend.push_back(axe);
+		legend.push_back(to);
+	}
+
+	
+
+	box_->push_back(PaperPoint(x-width, y-bottom));
+	box_->push_back(PaperPoint(x-width, y-top));
+	box_->push_back(PaperPoint(x+width, y-top));
+	box_->push_back(PaperPoint(x+width, y-bottom));
+	box_->push_back(PaperPoint(x-width, y-bottom));
+	// Small check
+
+	Colour border = colour.automatic() ? box_->getFillColour() : colour;
+	if ( border == Colour("none") ) {
+		box_->setFilled(false);
+	}
+
+	box_->setColour(border);
+	legend.push_back(box_);
+	Polyline* box =  box_->getNew();
+	box->setColour(border);
+	box->push_back(PaperPoint(x-width, y + 1.1));
+	box->push_back(PaperPoint(x+width, y + 1.1));
+	box->push_back(PaperPoint(x+width, y + 0.85));
+	box->push_back(PaperPoint(x-width, y + 0.85));
+	box->push_back(PaperPoint(x-width, y + 1.1));
+	legend.push_back(box);
+
+    Polyline* topbox = box_->getNew();
+    topbox->setColour(grid_colour);
+    topbox->setThickness(grid_thickness);
+    topbox->setLineStyle(grid_style);
+    topbox->push_back(PaperPoint(x-width, y + 1.1));
+    topbox->push_back(PaperPoint(x+width, y + 1.1));
+	legend.push_last(topbox);
+
+	Polyline* bottombox = box_->getNew();
+	bottombox->setColour(grid_colour);
+	bottombox->setThickness(grid_thickness);
+	bottombox->setLineStyle(grid_style);
+	bottombox->push_back(PaperPoint(x-width, y + 0.85));
+	bottombox->push_back(PaperPoint(x+width, y + 0.85));
+	legend.push_last(bottombox);
+
+
+    
+    Polyline* topline = new Polyline();
+	topline->setColour(box_->getFillColour());
+    topline->setLineStyle(M_DASH);
+	topline->push_back(PaperPoint(x-width, y  -  0.2));
+	topline->push_back(PaperPoint(x+width,  y - 0.2));
+	
+    legend.push_last(topline);
+    
+    Polyline* bottomline = new Polyline();
+    bottomline->setColour(grid_colour);
+    bottomline->setThickness(grid_thickness);
+    bottomline->setLineStyle(grid_style);
+
+    
+	bottomline->push_back(PaperPoint(x-width, y + 0.8));
+	bottomline->push_back(PaperPoint(x+width,  y + 0.8));
+    legend.push_last(bottomline);
+
+    for (vector<Polyline*>::iterator tick = ticks.begin(); tick != ticks.end(); ++tick)
+    	legend.push_back(*tick);
+
+    if ( histogram_->mean() && meanSet_ ) {
+    	Symbol* symbol = new Symbol();
+
+    	symbol->setColour(histogram_->meanColour());
+    	ostringstream m;
+    	m << "magics_" << histogram_->meanMarker();
+    	symbol->setSymbol(m.str());
+    	
+    	symbol->setHeight(histogram_->meanSize());
+    	double pos = ((2*width)/(to_-from_)) * (meanValue_ - from_) + (x - width);
+    	symbol->push_back(PaperPoint(pos,  y + 1.));
+    	legend.push_last(symbol);
+
+    }
+}
+void BoxEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = computeWidth(0.8)/2;
+	double height = 0.5;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+	PaperPoint pt = leftTextBox(point);
+
+	if ( text_ ) {
+		Text* from = new Text();
+		from->setJustification(MLEFT);
+		from->setVerticalAlign(MHALF);
+		if ( userText_.empty()  || last_) {
+			ostringstream bottom;
+			bottom << MagicsFormat(format_, from_);
+			from->addText(bottom.str(), font_);
+		}
+		else
+			from->addText(userText_, font_);
+		PaperPoint pfrom(pt);
+		pfrom.y_ = y - height;
+		from->push_back(pfrom);
+		from->setAngle(angle_);
+		legend.push_back(from);
+	}
+	if ( last_ ) {
+		Text* to = new Text();
+		to->setVerticalAlign(MHALF);
+		to->setJustification(MLEFT);
+		to->setAngle(angle_);
+		if ( userText_.empty()  ) {
+			ostringstream top, bottom;
+			top << MagicsFormat(format_, to_);
+			to->addText(top.str(), font_);
+		}
+		else
+			to->addText(userText_, font_);
+		PaperPoint pto(pt);
+		pto.y_ =  y + height;
+		to->push_back(pto);
+		legend.push_back(to);
+	}
+	box_->push_back(PaperPoint(x-width, y-height));
+	box_->push_back(PaperPoint(x-width, y+height));
+	box_->push_back(PaperPoint(x+width, y+height));
+	box_->push_back(PaperPoint(x+width, y-height));
+	box_->push_back(PaperPoint(x-width, y-height));
+	Colour colour = ( borderColour_.automatic() ) ? box_->getFillColour() : borderColour_;
+	if ( box_->getFillColour() == Colour("none") ) {
+		box_->setFilled(false);
+	}
+	box_->setColour(colour);
+	legend.push_back(box_);
+}
+void BoxEntry::columnHisto(const PaperPoint& point, BasicGraphicsObjectContainer& legend, const Colour& colour)
+{
+
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = computeWidth(0.8)/2;
+	double height = 0.5;
+//    double bottom = 0.7;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+	PaperPoint pt = leftTextBox(point);
+
+	if ( text_ ) {
+		Text* from = new Text();
+		from->setJustification(MLEFT);
+		from->setVerticalAlign(MHALF);
+		if ( userText_.empty()  || last_) {
+			ostringstream bottom;
+			bottom << MagicsFormat(format_, from_);
+			from->addText(bottom.str(), font_);
+		}
+		else
+			from->addText(userText_, font_);
+		PaperPoint pfrom(pt);
+		pfrom.y_ = y - height;
+		from->push_back(pfrom);
+		from->setAngle(angle_);
+		legend.push_back(from);
+	}
+	if ( last_ ) {
+		Text* to = new Text();
+		to->setVerticalAlign(MHALF);
+		to->setJustification(MLEFT);
+		to->setAngle(angle_);
+		if ( userText_.empty()  ) {
+			ostringstream top, bottom;
+			top << MagicsFormat(format_, to_);
+			to->addText(top.str(), font_);
+		}
+		else
+			to->addText(userText_, font_);
+		PaperPoint pto(pt);
+		pto.y_ =  y + height;
+		to->push_back(pto);
+		legend.push_back(to);
+	}
+	box_->push_back(PaperPoint(x-width, y-height));
+	box_->push_back(PaperPoint(x-width, y+height));
+	box_->push_back(PaperPoint(x+width, y+height));
+	box_->push_back(PaperPoint(x+width, y-height));
+	box_->push_back(PaperPoint(x-width, y-height));
+	Colour border = colour.automatic() ? box_->getFillColour() : colour;
+	if ( border == Colour("none") ) {
+		box_->setFilled(false);
+	}
+	box_->setColour(border);
+	legend.push_back(box_);
+}
+
+Colour LineEntry::colour() 
+{
+	return line_->getColour();
+}
+
+Colour DoubleLineEntry::colour() 
+{
+	return line1_->getColour();
+}
+
+void LineEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+
+	double width = computeWidth(0.8)/2;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+	line_->push_back(PaperPoint(x-width, y)); 
+	line_->push_back(PaperPoint(x+width, y));
+	legend.push_back(line_);
+}
+
+void DoubleLineEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	double width = computeWidth(0.8)/2;
+	double height = (line2_) ? 0.4 : 0;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+	line1_->push_back(PaperPoint(x-width, y-height));
+	line1_->push_back(PaperPoint(x+width, y-height));
+	legend.push_back(line1_);
+	if ( !line2_) 
+		return;
+	line2_->push_back(PaperPoint(x-width, y+height));
+	line2_->push_back(PaperPoint(x+width, y+height));
+	legend.push_back(line2_);
+}
+
+void check(const string& line, vector<string>& lines)
+{
+	if (!line.empty() ) {
+		lines.push_back(line);
+	}
+}
+
+void LegendVisitor::getReady()
+{
+	
+	if ( lines_.empty() == false )
+		return;
+	
+	check(text1_, lines_);
+	check(text2_, lines_);
+	check(text3_, lines_);
+	check(text4_, lines_);
+	check(text5_, lines_);
+	check(text6_, lines_);
+	check(text7_, lines_);
+	check(text8_, lines_);
+	check(text9_, lines_);
+	check(text10_, lines_);	
+    
+    if ( lines_.empty() )
+       check(text_, lines_); 
+
+    if (!lines_.empty() && composition_ == "automatic_text_only" )
+	composition_ = "user_text_only";
+}
+
+
+
+void XmlLegendVisitor::getReady()
+{
+	assert(BasicSceneObject::parent_);
+
+	Dimension bottom(bottom_, BasicSceneObject::parent_->absoluteWidth(), 0);
+	Dimension left(left_, BasicSceneObject::parent_->absoluteHeight(), 0);
+	Dimension width(XmlBasicNodeAttributes::width_, BasicSceneObject::parent_->absoluteWidth(), 100);
+	Dimension height(XmlBasicNodeAttributes::height_, BasicSceneObject::parent_->absoluteHeight(), 100);
+
+	Dimension mb(margin_bottom_, height.absolute(), 0);	
+	Dimension ml(margin_left_, width.absolute(), 10);
+	Dimension mr(margin_right_, width.absolute(), 10);
+	Dimension mt(margin_top_, height.absolute(), 0);
+
+	// We have to calculate the new x, y, width, height
+	double xl = ml.percent()*width.absolute()/100;
+//	double xr = mr.percent()*width.absolute()/100;
+	double yb = mb.percent()*height.absolute()/100;
+//	double yt = mt.percent()*height.absolute()/100;
+	double text_x =  left.percent() + xl *100/BasicSceneObject::parent_->absoluteWidth();
+	double text_y =  bottom.percent()+ yb *100/BasicSceneObject::parent_->absoluteHeight();;
+
+	double text_width = width.percent();
+	double text_height = height.percent();
+	
+	
+
+	if ( ( text_height + text_y ) > 100 ) 
+		text_height = 100 - text_y ;
+	if ( ( text_width + text_x ) > 100 ) 
+			text_width = 100 - text_x ;
+	
+	view_x_ = ml.percent();
+	view_y_ = mb.percent();
+	view_height_ = 100- mb.percent()-mt.percent();
+	view_width_ = 100- ml.percent()-mr.percent();
+	
+	layout_->x( left.percent());
+	layout_->y(bottom.percent());
+	layout_->width(width.percent() );
+	layout_->height(height.percent());
+	
+	// adjust the font size!...	
+	Dimension text(font_dimension_,height.absolute(), 10);
+	font_size_ = text.absolute();
+	
+
+	layout_->frame(XmlBasicNodeAttributes::blanking_, XmlBasicNodeAttributes::border_, 
+			*XmlBasicNodeAttributes::border_colour_, 
+			XmlBasicNodeAttributes::border_style_, 
+			XmlBasicNodeAttributes::border_thickness_);	
+	layout_->display( XmlBasicNodeAttributes::display_);
+    if (!lines_.empty() && composition_ == "automatic_text_only" )
+	composition_ = "user_text_only";
+}
+
+void FortranPositionalLegendVisitor::getReady()
+{
+	MagLog::dev() << "FortranLegendVisitor::getReady()" << endl;
+	LegendVisitor::getReady();
+	layout_->x(box_x_ / BasicPositionalObject::absoluteWidth() *100);
+	layout_->y(box_y_ / BasicPositionalObject::absoluteHeight() *100);
+	layout_->width( box_width_ / BasicPositionalObject::absoluteWidth() *100);
+	layout_->height( box_height_ / BasicPositionalObject::absoluteHeight() *100);
+	
+	// adjust the font size!...	
+	Dimension text(font_dimension_, box_height_, 10);
+	font_size_ = text.absolute();
+	
+	layout_->Layout::frame(blanking_, border_, *border_colour_, border_line_style_, border_thickness_);
+}
+
+
+void LegendVisitor::finish(BasicGraphicsObjectContainer&  parent)
+{
+	newLayout();
+	parent.push_back(current_);
+	
+	build();
+	
+	clear();
+	//parent.push_back(current_);
+}
+
+void FortranAutomaticLegendVisitor::getReady()
+{
+	MagLog::dev() << "FortranAutomaticTextNode::getReady()" << endl;
+	LegendVisitor::getReady();
+	Dimension text(font_dimension_, 1, 10);
+	font_size_ = text.absolute();
+	layout_->Layout::frame(blanking_, border_, *border_colour_, border_line_style_, border_thickness_);
+}
+
+void LegendEntry::set(const LegendVisitor& attributes)
+{
+	format_ = attributes.format();
+
+	
+}
+
+void SimpleSymbolEntry::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	symbol_->push_back(centreSymbolBox(point));
+	legend.push_back(symbol_);
+}
+
+
+
+
+
+const string& LegendEntry::label() const
+{
+	if ( !label_.empty() || !fromto_)
+		return label_;
+
+	if ( from_ == to_ )
+	{
+		ostringstream nice;
+		nice << MagicsFormat(format_, from_); 
+		label_ = nice.str();
+		return label_;
+	}
+	ostringstream nice;
+	nice << MagicsFormat(format_, from_) << "-" << MagicsFormat(format_, to_);
+	label_ = nice.str();
+	return label_;
+}
+void SimpleSymbolEntry::rowBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	Polyline* box = new Polyline();
+	FillShadingProperties* shading = new FillShadingProperties();
+	box->setFillColour(colour());
+	box->setShading(shading);
+	box->setFilled(true);
+	double width = 1;
+		double height = 0.4;
+		double x = point.x();
+		double y = point.y();
+
+		if ( text_ ) {
+			Text* from = new Text();
+			from->push_back(PaperPoint(x-width, y - height - 0.25));
+			from->setVerticalAlign(MBOTTOM);
+			from->setAngle(angle_);
+			legend.push_back(from);
+			if ( userText_.empty()  || last_) {
+				ostringstream bottom;
+				bottom << MagicsFormat(format_, from_);
+				from->addText(bottom.str(), font_);
+			}
+			else
+				from->addText(userText_, font_);
+		}
+		if ( last_ ) {
+			Text* to = new Text();
+			to->setAngle(angle_);
+			to->setVerticalAlign(MBOTTOM);
+			to->push_back(PaperPoint(x+width, y - height- 0.25));
+			legend.push_back(to);
+			if ( userText_.empty()  ) {
+				ostringstream top, bottom;
+				top << MagicsFormat(format_, to_);
+				to->addText(top.str(), font_);
+			}
+			else
+				to->addText(userText_, font_);
+		}
+
+
+		box->push_back(PaperPoint(x-width, y-height));
+		box->push_back(PaperPoint(x-width, y+height+height));
+		box->push_back(PaperPoint(x+width, y+height+height));
+		box->push_back(PaperPoint(x+width, y-height));
+		box->push_back(PaperPoint(x-width, y-height));
+		// Small check
+		Colour colour = ( borderColour_.automatic() ) ? box->getFillColour() : borderColour_;
+
+		if ( box->getFillColour() == Colour("none") ) {
+			box->setFilled(false);
+			colour = Colour("black");
+		}
+		box->setColour(colour);
+
+
+		legend.push_back(box);
+}
+void SimpleSymbolEntry::columnBox(const PaperPoint& point, BasicGraphicsObjectContainer& legend)
+{
+	Polyline* box = new Polyline();
+	FillShadingProperties* shading = new FillShadingProperties();
+	box->setFillColour(colour());
+	box->setShading(shading);
+	box->setFilled(true);
+	MagLog::debug() << "BoxEntry--->set at " << point << endl;
+	double width = computeWidth(0.8)/2;
+	double height = 0.5;
+	PaperPoint p = centreSymbolBox(point);
+	double x = p.x();
+	double y = p.y();
+	PaperPoint pt = leftTextBox(point);
+
+	if ( text_ ) {
+		Text* from = new Text();
+		from->setJustification(MLEFT);
+		from->setVerticalAlign(MHALF);
+		if ( userText_.empty()  || last_) {
+			ostringstream bottom;
+			bottom << MagicsFormat(format_, from_);
+			from->addText(bottom.str(), font_);
+		}
+		else
+			from->addText(userText_, font_);
+		PaperPoint pfrom(pt);
+		pfrom.y_ = y - height;
+		from->push_back(pfrom);
+		from->setAngle(angle_);
+		legend.push_back(from);
+	}
+	if ( last_ ) {
+		Text* to = new Text();
+		to->setVerticalAlign(MHALF);
+		to->setJustification(MLEFT);
+		to->setAngle(angle_);
+		if ( userText_.empty()  ) {
+			ostringstream top, bottom;
+			top << MagicsFormat(format_, to_);
+			to->addText(top.str(), font_);
+		}
+		else
+			to->addText(userText_, font_);
+		PaperPoint pto(pt);
+		pto.y_ =  y + height;
+		to->push_back(pto);
+		legend.push_back(to);
+	}
+	box->push_back(PaperPoint(x-width, y-height));
+	box->push_back(PaperPoint(x-width, y+height));
+	box->push_back(PaperPoint(x+width, y+height));
+	box->push_back(PaperPoint(x+width, y-height));
+	box->push_back(PaperPoint(x-width, y-height));
+	Colour colour = ( borderColour_.automatic() ) ? box->getFillColour() : borderColour_;
+	if ( box->getFillColour() == Colour("none") ) {
+		box->setFilled(false);
+	}
+	box->setColour(colour);
+	legend.push_back(box);
+}
diff --git a/src/basic/LegendVisitor.h b/src/basic/LegendVisitor.h
new file mode 100644
index 0000000..b3e3192
--- /dev/null
+++ b/src/basic/LegendVisitor.h
@@ -0,0 +1,443 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LegendVisitor.h
+    \brief Definition of the Template class LegendNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef LegendNode_H
+#define LegendNode_H
+
+#include "magics.h"
+
+#include "SceneVisitor.h"
+
+#include "PaperPoint.h"
+#include "LegendVisitorAttributes.h"
+#include "LegendBoxAttributes.h"
+#include "XmlBasicNodeAttributes.h"
+#include "XmlNode.h"
+
+namespace magics {
+
+class Arrow;
+class Flag;
+class Text;
+class Symbol;
+class Polyline;
+class HistogramLegendMethod;
+
+class LegendEntry
+{
+public:
+	LegendEntry(const string& label) :
+		last_(false), first_(false), text_(true), label_(label), fromto_(false), borderColour_("black"), meanSet_(false), histogram_(0){}
+	LegendEntry(double label):
+		last_(false), first_(false), text_(true), label_(""),fromto_(false), borderColour_("black"), meanSet_(false), histogram_(0)
+	{ format(label); }
+	LegendEntry(double min, double max):
+		last_(false), first_(false), text_(true), label_(""),fromto_(false), borderColour_("black"), meanSet_(false), histogram_(0)
+	{ format(min, max); }
+	
+	virtual ~LegendEntry() {}
+
+	virtual void set(const PaperPoint&, BasicGraphicsObjectContainer&) {}
+	//! rowBox + columnBox used for a continuous legend... 
+	virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	
+	virtual void rowHisto(const PaperPoint& point, BasicGraphicsObjectContainer& out, const Colour&) {rowBox(point, out);}
+	virtual void columnHisto(const PaperPoint& point, BasicGraphicsObjectContainer& out, const Colour&) {columnBox(point, out);}
+
+	virtual bool needContinuousText() { return false; }
+	virtual bool needText() { return true; }
+	virtual const string& label() const;
+	virtual void interpret(string&) const {}
+	void setArrow(Arrow* arrow) { arrow_ = arrow; }
+	string from()  { return tostring(from_); }
+	string to() { return tostring(to_); }
+	 
+	void userText(const string& text) { userText_ = text; }
+	const string& userText() { return userText_; }
+
+	void font(const MagFont& font) { font_ = font; }
+	void angle(double angle) { angle_ = angle; }
+	void set(const LegendVisitor&); 
+	void last() { last_ = true; }
+	void first() { first_ = true; }
+	void notext() { text_ = false; }
+	void text() { text_ = true; }
+	
+	void width(double width) { width_ = width; }
+	PaperPoint centreSymbolBox(const PaperPoint&);
+	PaperPoint leftTextBox(const PaperPoint&);
+
+	double computeWidth(double);
+
+	// Information needed for histogram mode
+	int population() const { return population_; }
+	int totalPopulation() const { return totalPopulation_; }
+	void  population(int population)  { population_ = population; }
+	void  totalPopulation(int population)  { totalPopulation_ = population; }
+	void  mean(double mean)  { meanValue_ = mean; meanSet_ = true; }
+	void  histogramInformation(HistogramLegendMethod* histo) {histogram_ = histo;}
+	void  borderColour(const Colour& colour)  {  borderColour_ = colour; }
+
+protected:
+	bool last_;
+	bool first_;
+	bool text_;
+	mutable string label_;
+    bool fromto_;
+    Colour borderColour_;
+    bool meanSet_;
+    HistogramLegendMethod* histogram_;
+
+    string userText_;
+	double from_;
+	double to_;
+	string format_;
+	MagFont font_;
+	double angle_;
+	double width_;
+
+	int population_;
+	int totalPopulation_;
+	double meanValue_;
+
+	friend class LegendVisitor;
+	//double textPosition_;
+	virtual Colour colour() { return Colour(); } 
+	void format(double val)
+	{
+		fromto_ = true;
+		from_ = val;
+		to_   = val;
+	}
+
+	void format(double min, double max)
+	{
+		from_ = min;
+		to_ = max;
+		fromto_ = true;
+	}
+    
+	Arrow*  arrow_;
+};
+
+
+class EmptyEntry : public LegendEntry
+{
+public:
+	EmptyEntry() : LegendEntry("") {}
+	~EmptyEntry() {}
+	virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	const string& label() const { static string empty; return empty; }
+	void interpret(string& text) const { text = ""; }
+	bool needText() { return false; }
+};
+
+
+class SymbolEntry : public LegendEntry
+{
+public:
+	SymbolEntry(const string& label, Symbol* symbol = 0 ) : 
+		LegendEntry(label), symbol_(symbol) {}
+	SymbolEntry(double label, Symbol* symbol = 0 ) :  
+		LegendEntry(label), symbol_(symbol) { format(label); }
+	SymbolEntry(double min, double max, Symbol* symbol = 0 ) : 
+		LegendEntry(min, max), symbol_(symbol)
+        { format(min, max); }
+	virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+		virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+    void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+    
+protected:
+	Symbol* symbol_;
+	Colour colour();
+};
+
+
+class SimpleSymbolEntry : public SymbolEntry
+{
+public:
+	SimpleSymbolEntry(const string& label, Symbol* symbol = 0 ) : 
+		SymbolEntry(label, symbol) {}
+	SimpleSymbolEntry(double label, Symbol* symbol = 0 ) :  
+		SymbolEntry(label, symbol) {}
+	SimpleSymbolEntry(double min, double max, Symbol* symbol = 0 ) : 
+		SymbolEntry(min, max, symbol) {}
+    void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+    void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+    void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+};
+
+
+class LineEntry : public LegendEntry
+{
+public:
+	LineEntry(const string label, Polyline* line = 0 ) : 
+		LegendEntry(label), line_(line) {}
+	LineEntry(double label, Polyline* line = 0 ) :  
+		LegendEntry(label), line_(line) { format(label); }
+	LineEntry(double min, double max, Polyline* line = 0 ) : 
+		LegendEntry(min, max), line_(line)
+        { format(min, max); }
+    void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+    virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+protected:
+	Polyline* line_;
+	Colour colour();
+};
+
+
+class DoubleLineEntry : public LegendEntry
+{
+public:
+	DoubleLineEntry(const string label, Polyline* line1 = 0,  Polyline* line2 = 0) : 
+		LegendEntry(label), line1_(line1), line2_(line2){}
+	DoubleLineEntry(double label, Polyline* line1 = 0, Polyline* line2 = 0 ) :  
+		LegendEntry(label), line1_(line1), line2_(line2)
+		{ format(label); }
+	DoubleLineEntry(double min, double max, Polyline* line1 = 0,  Polyline* line2 = 0) :
+		LegendEntry(min, max), line1_(line1), line2_(line2)
+        { format(min, max); }
+    void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+    virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	bool needContinuousText() { return true;  }
+protected:
+	Polyline* line1_;
+	Polyline* line2_;
+	Colour colour();
+};
+
+
+class ArrowEntry : public LegendEntry
+{
+public:
+	ArrowEntry(const string label, Arrow* arrow = 0 ) : 
+		LegendEntry(label), arrow_(arrow) {}
+	ArrowEntry(const double label, Arrow* arrow = 0 ) :  
+		LegendEntry(label), arrow_(arrow) { format(label); }
+	ArrowEntry(const double min, double max, Arrow* arrow = 0 ) : 
+		LegendEntry(min, max), arrow_(arrow)
+        { format(min, max); }
+	void setArrow(Arrow* arrow) { arrow_ = arrow; }
+	void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	bool needContinuousText() { return false;  }
+protected:
+	Arrow*  arrow_;
+};
+
+
+class FlagEntry : public LegendEntry
+{
+public:
+	FlagEntry(const string label, Flag* flag = 0 ) : 
+		LegendEntry(label), flag_(flag) {}
+	FlagEntry(const double label, Flag* flag = 0 ) :  
+		LegendEntry(label), flag_(flag) { format(label); }
+	FlagEntry(const double min, double max, Flag* flag = 0 ) : 
+		LegendEntry(min, max), flag_(flag)
+        { format(min, max); }
+	void setArrow(Flag* flag) { flag_ = flag; }
+	void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+	 virtual void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	virtual void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	bool needContinuousText() { return false;  }
+protected:
+	Flag*  flag_;
+};
+
+
+class BoxEntry : public LegendEntry
+{
+public:
+	BoxEntry(const string label, Polyline* box = 0 ) : 
+		LegendEntry(label), box_(box) {}
+	BoxEntry(const double label, Polyline* box = 0 ) :  
+		LegendEntry(label), box_(box)  { format(label); }
+	BoxEntry(double min, double max, Polyline* box = 0 ) : 
+		LegendEntry(min, max), box_(box)
+        { format(min, max); }
+	void set(const PaperPoint&, BasicGraphicsObjectContainer&);
+	void rowBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	void columnBox(const PaperPoint&, BasicGraphicsObjectContainer&);
+	void rowHisto(const PaperPoint&, BasicGraphicsObjectContainer&, const Colour&);
+	void columnHisto(const PaperPoint&, BasicGraphicsObjectContainer&, const Colour&);
+
+protected:
+	Polyline*  box_;
+	Colour colour();
+};
+
+
+
+class LegendVisitor: public LayoutVisitor, 
+	public LegendVisitorAttributes, 
+	public BasicPositionalObject,
+	public VectorOfPointers<vector<LegendEntry*> > {
+
+public:
+	LegendVisitor();
+	virtual ~LegendVisitor();
+	virtual void getReady();
+	virtual LegendVisitor* clone() { assert(false); return 0; }
+	virtual Layout& layout() const { assert( layout_); return *layout_; }
+	virtual Layout* layoutPtr() const { assert( layout_); return layout_; }
+	//virtual Layout* legend()  { assert( layout_); return this; }
+    
+    void set(const XmlNode& node) { LegendVisitorAttributes::set(node); }	
+    void add(LegendEntry* entry) { VectorOfPointers<vector<LegendEntry*> >::push_back(entry); }
+    void newLegend() { 
+    	if 	(!VectorOfPointers<vector<LegendEntry*> >::empty() ) 
+    		add(new EmptyEntry()); 
+    }
+    double getFont_size() const { return font_size_; }
+    //Layout* execute(AnimationStep& step,  const Layout*);
+    void visit(BasicGraphicsObjectContainer&);
+	void visit(BasicSceneObject&);
+	 void visit(AnimationStep&);
+	bool positional() { return positional_; }
+	void finish(BasicGraphicsObjectContainer&);
+	LegendMethod::LegendType legendType() const { return method_->name(); }
+	void last() {
+		if ( !VectorOfPointers<vector<LegendEntry*> >::empty() )
+			VectorOfPointers<vector<LegendEntry*> >::back()->last();
+	}
+
+	const Transformation& transformation()              { return LayoutVisitor::transformation(); }
+	void transformation(Transformation* transformation) { return LayoutVisitor::transformation(transformation); }
+	string format() const { return format_; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 typedef string (LegendVisitor::*Composition)(const string&, const string&);
+    map<string, Composition> compositions_;
+	// Calculate the grid! 
+	void grid(vector<pair<float, float> >&, double&, double&);
+	void build();
+	bool positional_;
+    LegendLayout* legend_;
+
+    string both(const string& automatic, const string& user) 
+        { return automatic + " " + user; } 
+    string user_only(const string&, const string& user)
+         { return  user; } 
+    string automatic_only(const string& automatic, const string&) 
+        { return automatic; }
+    
+	double view_x_;
+	double view_y_;
+	double view_width_;
+	double view_height_;
+	double font_size_;
+
+private:
+    //! Copy constructor - No copy allowed
+	LegendVisitor(const LegendVisitor&);
+    //! Overloaded << operator to copy - No copy allowed
+	LegendVisitor& operator=(const LegendVisitor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LegendVisitor& p)
+		{ p.print(s); return s; }
+};
+
+
+class XmlLegendVisitor : public LegendVisitor, public XmlBasicNodeAttributes
+{
+public:
+	XmlLegendVisitor() { positional_ = true; }
+	~XmlLegendVisitor() {}
+	void set(const XmlNode& node) {
+		XmlNode view = node;
+		view.name("view");
+		XmlBasicNodeAttributes::set(view); 
+		LegendVisitor::set(node);
+	}
+	void copy(const XmlLegendVisitor& other) {
+		XmlBasicNodeAttributes::copy(other); 
+		LegendVisitor::copy(other);
+	}
+	LegendVisitor* clone()
+	{ 
+		XmlLegendVisitor* legend = new XmlLegendVisitor(); 
+		legend->copy(*this);
+		legend->positional_ = true;
+		return legend;
+	}
+	void getReady();	
+};
+
+
+class FortranPositionalLegendVisitor : public LegendVisitor
+{
+public:
+	FortranPositionalLegendVisitor() { positional_ = true; }
+	~FortranPositionalLegendVisitor() {}
+	void set(const XmlNode& node) {
+		LegendVisitor::set(node);
+	}
+	void getReady();	
+	void copy(const FortranPositionalLegendVisitor& other) {
+			LegendVisitor::copy(other);
+		}
+	LegendVisitor* clone() { 
+		FortranPositionalLegendVisitor* legend = new FortranPositionalLegendVisitor(); 
+		legend->copy(*this);
+		legend->positional_ = true;
+		return legend;
+	}
+};
+ 
+
+
+class FortranAutomaticLegendVisitor : public LegendVisitor
+{
+public:
+	FortranAutomaticLegendVisitor() { positional_ = false; }
+	~FortranAutomaticLegendVisitor() {}
+	void set(const XmlNode& node) {
+		LegendVisitor::set(node);
+	}
+	void getReady();	
+	LegendVisitor* clone() { 
+			FortranAutomaticLegendVisitor* legend = new FortranAutomaticLegendVisitor(); 
+			legend->copy(*this);
+			legend->positional_ = false;
+			return legend;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/LegendVisitorAttributes.h b/src/basic/LegendVisitorAttributes.h
new file mode 100644
index 0000000..dc59340
--- /dev/null
+++ b/src/basic/LegendVisitorAttributes.h
@@ -0,0 +1,129 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LegendVisitorAttributes.h
+    \brief Definition of LegendVisitor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef LegendVisitorAttributes_H
+#define LegendVisitorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "LegendMethod.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LegendVisitorAttributes 
+{
+public:
+//  --  constructor
+    LegendVisitorAttributes();
+    
+//  --  destructor
+    virtual ~LegendVisitorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LegendVisitorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<Colour> colour_;
+	bool title_;
+	string title_text_;
+	string title_orientation_;
+	bool units_;
+	string units_text_;
+	bool use_min_;
+	string use_min_text_;
+	bool use_max_;
+	string use_max_text_;
+	auto_ptr<LegendMethod> method_;
+	string format_;
+	string box_;
+	string font_;
+	string font_style_;
+	string font_dimension_;
+	string text_quality_;
+	double orientation_;
+	stringarray lines_;
+	int columns_;
+	string direction_;
+	string entry_orientation_;
+	string composition_;
+	string text_;
+	string text1_;
+	string text2_;
+	string text3_;
+	string text4_;
+	string text5_;
+	string text6_;
+	string text7_;
+	string text8_;
+	string text9_;
+	string text10_;
+	double box_x_;
+	double box_y_;
+	double box_width_;
+	double box_height_;
+	bool blanking_;
+	bool border_;
+	LineStyle border_line_style_;
+	auto_ptr<Colour> border_colour_;
+	int border_thickness_;
+	bool wrep_;
+	double text_width_;
+	bool entry_border_;
+	auto_ptr<Colour> entry_border_colour_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LegendVisitorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/MagicsEvent.h b/src/basic/MagicsEvent.h
new file mode 100644
index 0000000..03eae7b
--- /dev/null
+++ b/src/basic/MagicsEvent.h
@@ -0,0 +1,287 @@
+
+/*! \file MagicsEvent.h
+    \brief Definition of the Template class MagicsEvent.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 22-Nov-2007
+    
+    Changes:
+    
+*/
+
+#ifndef MagicsEvent_H
+#define MagicsEvent_H
+
+#include "magics.h"
+#include "MagicsObserver.h"
+
+
+namespace magics {
+
+class Layer;
+class MetaDataCollector;
+class DateTime;
+
+class MagicsEvent
+{
+public:
+	MagicsEvent() {}	
+	virtual ~MagicsEvent() {}	
+	virtual void notify(MagicsObserver& ) {}
+	
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { out << "MagicsEvent[]"; } 
+
+private:
+	//! Copy constructor - No copy allowed
+	MagicsEvent(const MagicsEvent&);
+	//! Overloaded << operator to copy - No copy allowed
+	MagicsEvent& operator=(const MagicsEvent&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MagicsEvent& p)
+		{ p.print(s); return s; }
+};
+
+class MagicsCursorEvent : public MagicsEvent
+{
+public:
+	MagicsCursorEvent(const string& cursor = "") : cursor_(cursor) {}	
+	virtual ~MagicsCursorEvent() {}	
+	virtual void notify(MagicsObserver& observer) { observer.notify(*this); }
+	const string& cursor() { return cursor_; }
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { out << "MagicsCursorEvent[cursor : " << cursor_ << "]"; } 
+	string cursor_;
+};
+class MagicsSwapBufferEvent : public MagicsEvent
+{
+public:
+	MagicsSwapBufferEvent() {}	
+	virtual ~MagicsSwapBufferEvent() {}	
+	virtual void notify(MagicsObserver& observer) { observer.notify(*this); }
+		
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { out << "MagicsSwapBufferEvent[]"; } 
+		
+};
+
+class MagicsAntialiasingEvent: public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsAntialiasingEvent(bool set) : set_(set) {}	
+	virtual ~MagicsAntialiasingEvent() {}	
+	virtual void notify(MagicsObserver& observer) { observer.notify(*this); }
+	bool set() const { return set_; }
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		string set = ( set_ ) ? "on" : "false";
+		out << "MagicsAntialiasingEvent[" << set  << "]"; 
+	} 
+	bool set_;		
+};
+
+class MagicsZoomEvent:  public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsZoomEvent(bool set) : set_(set) {}	
+	virtual ~MagicsZoomEvent() {}	
+	void notify(MagicsObserver& observer) { observer.notify(*this); }
+	bool set() const { return set_; }
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		string set = ( set_ ) ? "on" : "false";
+		out << "MagicsZoomEvent[" << set  << "]"; 
+	} 
+	bool set_;		
+};
+
+class MagicsMagnifierEvent:  public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsMagnifierEvent(bool set) : set_(set) {}	
+	virtual ~MagicsMagnifierEvent() {}	
+	void notify(MagicsObserver& observer) { observer.notify(*this); }
+	bool set() const { return set_; }
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		string set = ( set_ ) ? "on" : "false";
+		out << "MagicsMagnifierEvent[" << set  << "]"; 
+	} 
+	bool set_;
+		
+};
+
+class MagicsRestoreFbEvent:  public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsRestoreFbEvent() {}	
+	virtual ~MagicsRestoreFbEvent() {}	
+	void notify(MagicsObserver& observer) { observer.notify(*this); }
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		out << "MagicsRestoreFbEvent[" << "]"; }	
+};
+
+class MagicsAnimationStepData
+{
+public:
+	MagicsAnimationStepData(vector<string>& label, bool /*cached*/) : label_(label), cached_(false) {};
+	const vector<string>& label() const  {return label_;}
+	bool cached() const {return cached_;}	
+	void setLabel(vector<string>& s) {label_=s;}
+	void setCached(bool b) {cached_=b;}
+private:	
+	vector<string> label_;
+	bool           cached_;
+};
+
+
+class MagicsAnimationCurrentStepEvent:  public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsAnimationCurrentStepEvent(int step) : step_(step) {}	
+	virtual ~MagicsAnimationCurrentStepEvent() {}	
+	void notify(MagicsObserver& observer) { observer.notify(*this); }
+	int step() const { return step_; }
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		out << "MagicsAnimationCurrentStepEvent[" << step_ << "]"; }	
+	int step_;
+};
+
+class MagicsAnimationStepsEvent:  public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsAnimationStepsEvent(vector<MagicsAnimationStepData> steps) : steps_(steps) {}	
+	virtual ~MagicsAnimationStepsEvent() {}	
+	void notify(MagicsObserver& observer) { observer.notify(*this); }
+	const vector<MagicsAnimationStepData>& steps() const { return steps_; }
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		out << "MagicsAnimationFramseEvent[" << "]"; }	
+	vector<MagicsAnimationStepData>  steps_;
+};
+
+
+class MagicsLayerUpdateEvent:  public MagicsEvent
+{
+// From Uplot to driver!
+public:
+	MagicsLayerUpdateEvent() {}	
+	virtual ~MagicsLayerUpdateEvent() {}	
+	void notify(MagicsObserver& observer) { observer.notify(*this); }
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { 
+		out << "MagicsLayerUpdateEvent[" << "]"; }	
+};
+
+class LevelDescription
+{
+public:
+	LevelDescription();
+	~LevelDescription();
+	static LevelDescription surface(int set, int index) {
+		LevelDescription level;
+		level.surface_ = true;
+		level.index_ = index;
+		level.set_ = set;
+		return level;
+	}
+	static LevelDescription level(const string& unit, double l, int set, int index) {
+		LevelDescription newlevel;
+		newlevel.surface_ = false;
+		newlevel.unit_ = unit;
+		newlevel.level_ = l;
+		newlevel.set_ = set;
+		newlevel.index_ = index;
+
+		return newlevel;
+	}
+
+	bool operator < (const LevelDescription& other) const; // Code function in Layer.cc
+	void update(const LevelDescription&) const;
+protected:
+	bool surface_;
+	string unit_;
+	double level_;
+	mutable int set_;
+	mutable int index_;
+};
+class DateDescription
+{
+public:
+	DateDescription() {}
+	DateDescription(const string& valid, int set, int index) : valid_(valid), set_(set), index_(index) {}
+	~DateDescription();
+
+
+	void update(const DateDescription&) const;
+	bool operator < (const DateDescription& other) const; // Code function in Layer.cc
+protected:
+	string valid_;
+	mutable int set_;
+	mutable int index_;
+};
+struct MetviewIcon
+{
+public:
+	MetviewIcon(const string& name = "", const string& cname = "", const string& id="unknown") :
+		iconName_(name), iconClass_(cname), iconId_(id) {};
+		
+	void icon(const string& name, const string& cname, const string& id="unknown") {
+		iconName_ = name;
+		iconClass_ = cname;
+		iconId_ = id;
+	}
+	virtual void visit(Layer& layer);
+
+	virtual void visit(MetaDataCollector& collector);
+
+	
+	virtual void initInfo() {}
+	string info(const string& name) {return (information_.find(name) != information_.end())?information_[name]:"";}
+	void setInfo(const string& name, const string& value) { information_[name]=value; }
+	void icon(const MetviewIcon& other) {
+		iconName_ = other.iconName_;
+		iconClass_ = other.iconClass_;
+		iconId_ = other.iconId_;
+	}	
+	string iconName() const {return iconName_;}
+        string iconClass() const {return iconClass_;}
+        string iconId() const {return iconId_;}
+
+
+			
+protected:
+	string iconName_;
+	string iconClass_;
+	string iconId_;
+	map<string, string> information_;
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/MagicsObserver.h b/src/basic/MagicsObserver.h
new file mode 100644
index 0000000..b1c63cf
--- /dev/null
+++ b/src/basic/MagicsObserver.h
@@ -0,0 +1,88 @@
+/*! \file MagicsObserver.h
+    \brief Definition of the Template class MagicsObserver.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 22-Nov-2007
+    
+    Changes:
+    
+*/
+
+#ifndef MagicsObserver_H
+#define MagicsObserver_H
+
+#include "magics.h"
+#include "MagLog.h"
+
+
+namespace magics {
+
+
+class MagicsCursorEvent;
+class MagicsSwapBufferEvent;
+class MagicsZoomEvent;
+class MagicsAntialiasingEvent;
+class MagicsAnimationEvent;
+class MagicsMagnifierEvent;
+class MagicsRestoreFbEvent;
+class MagicsAnimationCurrentStepEvent;
+class MagicsAnimationStepsEvent;
+class MagicsLayerTreeEvent;
+class MagicsLayerUpdateEvent;
+class MagicsLayerSwapEvent;
+class MagicsZoomUpdateEvent;
+class MagicsRenderZoomPreviewEvent;
+
+class MagicsObserver {
+
+public:
+	MagicsObserver() { MagLog::registerObserver(this); }
+	virtual ~MagicsObserver() {MagLog::unregisterObserver(this);}
+	
+	
+	virtual void warningMessage(const string& msg) {cout <<  msg;}  // default behaviour
+	virtual void errorMessage(const string& msg)   {cerr <<  msg;}  // default behaviour
+	virtual void infoMessage(const string& msg)    {cout <<  msg;}  // default behaviour
+	virtual void progressMessage(const string& msg)    {cout <<  msg;}  // default behaviour
+	virtual void notify(MagicsCursorEvent&) {}
+	virtual void notify(MagicsSwapBufferEvent&) {}
+	virtual void notify(MagicsZoomEvent&) {}
+        virtual void notify(MagicsAntialiasingEvent&) {}
+        virtual void notify(MagicsMagnifierEvent&) {}
+	virtual void notify(MagicsRestoreFbEvent&) {}
+	virtual void notify(MagicsAnimationCurrentStepEvent&) {}
+	virtual void notify(MagicsAnimationStepsEvent&) {}
+	virtual void notify(MagicsLayerTreeEvent&) {}
+	virtual void notify(MagicsLayerUpdateEvent&) {}
+	virtual void notify(MagicsLayerSwapEvent&) {}
+    	virtual void notify(MagicsZoomUpdateEvent&) {}
+	virtual void notify(MagicsRenderZoomPreviewEvent&) {}
+
+	//virtual void areaCB(const string&, double ll_x, double ll_y, double ur_x, double ur_y) {}
+	virtual void areaCB(const string&, double, double, double, double) {}
+	virtual void inputCB(const string&, double , double ) {}
+	virtual void zoomCB(const string&, int) {}
+	virtual void zoomControlCB(bool) {}
+	virtual void animationControlCB(bool) {}
+	
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const {} 
+
+private:
+	//! Copy constructor - No copy allowed
+	MagicsObserver(const MagicsObserver&);
+	//! Overloaded << operator to copy - No copy allowed
+	MagicsObserver& operator=(const MagicsObserver&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MagicsObserver& p)
+		{ p.print(s); return s; }
+};
+
+
+
+} // namespace magics
+#endif
diff --git a/src/basic/MagnifierVisitor.cc b/src/basic/MagnifierVisitor.cc
new file mode 100644
index 0000000..07636fb
--- /dev/null
+++ b/src/basic/MagnifierVisitor.cc
@@ -0,0 +1,148 @@
+/*! \file MagnifierVisitor.h
+    \brief Implementation of the Template class MagnifierVisitor.
+    
+    Magics Team - ECMWF 2009
+    
+    Started: Tue 27-Jan-2009
+    
+    Changes:
+    
+*/
+
+
+
+#include "MagnifierVisitor.h"
+#include "BaseDriver.h"
+#include "Transformation.h"
+#include "AnimationRules.h"
+#include "MagicsFormat.h"
+
+using namespace magics;
+
+NoMagnifierVisitor::NoMagnifierVisitor() : owner_(0)
+{
+}
+
+
+NoMagnifierVisitor::~NoMagnifierVisitor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NoMagnifierVisitor::print(ostream& out)  const
+{
+	out << "NoMagnifierVisitor[";
+	out << "]";
+}
+
+MagnifierVisitor::MagnifierVisitor() : values_(0), more_(0)
+{
+	static int count = 0;
+	
+		ostringstream n;
+		n << "Magnifier" << count;
+		name(n.str());
+		count++;
+		
+}
+
+
+MagnifierVisitor::~MagnifierVisitor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MagnifierVisitor::print(ostream& out)  const
+{
+	out << "MagnifierVisitor[";
+	Layout::print(out);
+	out << "]";
+}
+
+void MagnifierVisitor::visit(BasicGraphicsObjectContainer& tree)
+{
+
+	tree.push_back(this);
+	// the Layout has been added to a Container, it will be delted automatically!
+	
+}
+
+void MagnifierVisitor::add(const PaperPoint& point)
+{
+	if ( !values_ ) {
+		values_ = new TextSymbol();
+		MagFont font(text_font_name_);
+		font.colour(*text_font_colour_);
+		font.size(text_font_size_);
+		values_->font(font);
+		values_->position(TextSymbol::M_BELOW);
+		values_->setSymbol(symbol_name_); // A little cross
+		values_->setHeight(symbol_height_); 
+		values_->setColour(*symbol_colour_); 				
+		this->push_back(values_);
+	}
+	ostringstream nice;
+	nice << MagicsFormat(text_format_, point.value());   
+	       
+	values_->push_back(point, nice.str());
+}
+void MagnifierVisitor::addMore(const PaperPoint& point)
+{
+	if ( !more_ ) {
+		more_ = new Symbol();
+		more_->setSymbol(hidden_symbol_name_); // A little dot
+		more_->setHeight(hidden_symbol_height_); 
+		more_->setColour(*hidden_symbol_colour_); 				
+		this->push_back(more_);
+	}
+	more_->push_back(point);
+}
+
+void MagnifierVisitor::redisplay(const BaseDriver& driver) const 
+{
+	
+	
+	driver.redisplay(*this); 
+}
+
+void MagnifierVisitor::redisplay(const BaseDriver& driver, vector<PaperPoint>& pp,float xres,float yres) const
+{
+	   
+	   values_ = 0;
+	   more_ = 0;
+		
+		// Update the view from the transfomation
+		
+		// visit the owner to get the info!
+		assert(owner_);
+		double xmin = pp.front().x();
+		double xmax = pp.front().x();
+		double ymin = pp.front().y();
+	    double ymax = pp.front().y();
+	    
+	    for (vector<PaperPoint>::iterator p = pp.begin(); p != pp.end(); ++p ) {
+	    	xmin = std::min(xmin, p->x());
+	    	xmax = std::max(xmax, p->x());	
+	    	ymin = std::min(ymin, p->y());
+	    	ymax = std::max(ymax, p->y());
+	    }
+	    
+	    	    transformation_->filterView(xmin, xmax, ymin, ymax, xres, yres);
+		
+	    	    owner_->visit(*const_cast<MagnifierVisitor*>(this));
+		if ( more_ ) 
+			driver.redisplay(*more_); 
+		if ( values_ ) 
+			driver.redisplay(*values_); 
+		
+		
+}
+	
+
+
+
+
diff --git a/src/basic/MagnifierVisitor.h b/src/basic/MagnifierVisitor.h
new file mode 100644
index 0000000..b48f794
--- /dev/null
+++ b/src/basic/MagnifierVisitor.h
@@ -0,0 +1,120 @@
+/*! \file MagnifierVisitor.h
+    \brief Definition of the Template class NoMagnifierVisitor.
+    
+    Magics Team - ECMWF 2009
+    
+    Started: Tue 27-Jan-2009
+    
+    Changes:
+    
+*/
+
+#ifndef MagnifierVisitor_H
+#define MagnifierVisitor_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "SceneVisitor.h"
+#include "Layout.h"
+#include "Symbol.h"
+#include "PaperPoint.h"
+#include "MagnifierVisitorAttributes.h"
+
+namespace magics {
+
+
+
+class NoMagnifierVisitor: public SceneVisitor, public MagnifierLayout{
+
+public:
+	NoMagnifierVisitor();
+	virtual ~NoMagnifierVisitor();
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) { return false;}
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual void toxml(ostream&, int = 0) const {}
+    virtual NoMagnifierVisitor* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new NoMagnifierVisitor();
+    }
+    void visit(magics::BasicSceneObject&) {}
+    virtual void add(const PaperPoint&) {}
+    virtual void owner(BasicSceneObject* owner) { owner_ = owner; } 
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 BasicSceneObject* owner_;
+	
+	 
+private:
+    //! Copy constructor - No copy allowed
+	NoMagnifierVisitor(const NoMagnifierVisitor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoMagnifierVisitor& operator=(const NoMagnifierVisitor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoMagnifierVisitor& p)
+		{ p.print(s); return s; }
+
+};
+
+class MagnifierVisitor : public NoMagnifierVisitor, public MagnifierVisitorAttributes
+{
+public:
+	MagnifierVisitor();
+
+	virtual ~MagnifierVisitor(); 
+	void visit(BasicGraphicsObjectContainer&);  
+	virtual NoMagnifierVisitor* clone() const {
+		MagnifierVisitor* visitor = new MagnifierVisitor();
+		visitor->owner_ = owner_;
+		visitor->copy(*this);
+		return visitor;
+	} 
+	virtual void set(const XmlNode& node) {
+		MagnifierVisitorAttributes::set(node);
+	}
+	virtual void set(const map<string, string>& map) {
+		MagnifierVisitorAttributes::set(map);
+	}  
+	void redisplay(const BaseDriver& driver) const;
+	void redisplay(const BaseDriver& driver, vector<PaperPoint>&,float,float) const;
+	void visit(magics::BasicSceneObject& object) { object.visit(*this); }
+	void add(const PaperPoint&);
+	void addMore(const PaperPoint&);
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+	 mutable TextSymbol* values_;
+	 mutable Symbol* more_;
+	 
+};
+
+template <>
+class MagTranslator<string, NoMagnifierVisitor> { 
+public:
+	NoMagnifierVisitor* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoMagnifierVisitor>::create(val);
+	}     
+
+	NoMagnifierVisitor* magics(const string& param)
+	{
+		NoMagnifierVisitor* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/MagnifierVisitorAttributes.h b/src/basic/MagnifierVisitorAttributes.h
new file mode 100644
index 0000000..eab538d
--- /dev/null
+++ b/src/basic/MagnifierVisitorAttributes.h
@@ -0,0 +1,91 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file MagnifierVisitorAttributes.h
+    \brief Definition of MagnifierVisitor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef MagnifierVisitorAttributes_H
+#define MagnifierVisitorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class MagnifierVisitorAttributes 
+{
+public:
+//  --  constructor
+    MagnifierVisitorAttributes();
+    
+//  --  destructor
+    virtual ~MagnifierVisitorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const MagnifierVisitorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string symbol_name_;
+	string hidden_symbol_name_;
+	auto_ptr<Colour> symbol_colour_;
+	auto_ptr<Colour> hidden_symbol_colour_;
+	double symbol_height_;
+	double hidden_symbol_height_;
+	string text_font_name_;
+	double text_font_size_;
+	auto_ptr<Colour> text_font_colour_;
+	string text_format_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const MagnifierVisitorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/Makefile.am b/src/basic/Makefile.am
new file mode 100644
index 0000000..1c11dc8
--- /dev/null
+++ b/src/basic/Makefile.am
@@ -0,0 +1,46 @@
+noinst_LTLIBRARIES	= libbasic.la
+
+ATTRIBUTES		= WrepRootNodeAttributes.cc XmlBasicNodeAttributes.cc XmlSceneNodeAttributes.cc \
+			XmlRootNodeAttributes.cc XmlViewNodeAttributes.cc LegendVisitorAttributes.cc \
+			ImportObjectHandlerAttributes.cc TextVisitorAttributes.cc MagnifierVisitorAttributes.cc
+
+include_H		= MagicsObserver.h MagicsEvent.h ParameterSettings.h \
+			BasicSceneObject.h BasicGraphicsObject.h\
+			RootSceneNode.h SceneNode.h ImportObjectHandler.h\
+			ViewNode.h PreviewVisitor.h MagnifierVisitor.h LegendVisitor.h \
+			TextVisitor.h DisplayManager.h FortranMagics.h Visdef.h  MultiVisdef.h\
+			XmlMagics.h XmlRootNodeAttributes.h WrepRootNodeAttributes.h \
+			ThreadNode.h \
+			TagHandler.h \
+			SceneVisitor.h LayoutManager.h WebFormat.h Layer.h  HistoVisitor.h \
+			XmlSceneNodeAttributes.h MagnifierVisitorAttributes.h XmlBasicNodeAttributes.h XmlViewNodeAttributes.h LegendVisitorAttributes.h  
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= 
+else
+include_HEADERS = 
+noinst_HEADERS	= $(include_H)
+endif
+
+nodist_libbasic_la_SOURCES	= ${ATTRIBUTES}
+
+libbasic_la_SOURCES	= FortranMagics.cc ParameterSettings.cc \
+			BasicSceneObject.cc BasicGraphicsObject.cc ImportObjectHandler.cc\
+			RootSceneNode.cc SceneNode.cc VisualAction.cc MultiVisdef.cc \
+			ViewNode.cc PreviewVisitor.cc MagnifierVisitor.cc LegendVisitor.cc  \
+			TextVisitor.cc  TagHandler.cc SceneVisitor.cc LayoutManager.cc \
+			XmlMagics.cc  WebFormat.cc Layer.cc  HistoVisitor.cc
+later		 =	DisplayManager.ccThreadNode.cc
+interface	 = 	FortranMagics.cc WebFormat.cc \
+			XmlMagics.cc  
+
+libbasic_la_LDFLAGS	= -no-undefined -no-install
+
+AM_CPPFLAGS		= ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/common -I$(top_srcdir)/src/web -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/oda -I$(top_srcdir)/src/decoders -I$(top_srcdir)/include -I$(top_srcdir)/src/libTable
+
+if MAGICS_QT
+AM_CPPFLAGS += $(QT_CPPFLAGS)
+endif
+
+EXTRA_DIST = BasicSceneVisitor.cc  BasicSceneVisitor.h VisualAction.cc VisualAction.h
diff --git a/src/basic/Makefile.in b/src/basic/Makefile.in
new file mode 100644
index 0000000..c9b3958
--- /dev/null
+++ b/src/basic/Makefile.in
@@ -0,0 +1,722 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_QT_TRUE@am__append_1 = $(QT_CPPFLAGS)
+subdir = src/basic
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libbasic_la_LIBADD =
+am_libbasic_la_OBJECTS = FortranMagics.lo ParameterSettings.lo \
+	BasicSceneObject.lo BasicGraphicsObject.lo \
+	ImportObjectHandler.lo RootSceneNode.lo SceneNode.lo \
+	VisualAction.lo MultiVisdef.lo ViewNode.lo PreviewVisitor.lo \
+	MagnifierVisitor.lo LegendVisitor.lo TextVisitor.lo \
+	TagHandler.lo SceneVisitor.lo LayoutManager.lo XmlMagics.lo \
+	WebFormat.lo Layer.lo HistoVisitor.lo
+am__objects_1 = WrepRootNodeAttributes.lo XmlBasicNodeAttributes.lo \
+	XmlSceneNodeAttributes.lo XmlRootNodeAttributes.lo \
+	XmlViewNodeAttributes.lo LegendVisitorAttributes.lo \
+	ImportObjectHandlerAttributes.lo TextVisitorAttributes.lo \
+	MagnifierVisitorAttributes.lo
+nodist_libbasic_la_OBJECTS = $(am__objects_1)
+libbasic_la_OBJECTS = $(am_libbasic_la_OBJECTS) \
+	$(nodist_libbasic_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libbasic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(libbasic_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libbasic_la_SOURCES) $(nodist_libbasic_la_SOURCES)
+DIST_SOURCES = $(libbasic_la_SOURCES)
+am__include_HEADERS_DIST = MagicsObserver.h MagicsEvent.h \
+	ParameterSettings.h BasicSceneObject.h BasicGraphicsObject.h \
+	RootSceneNode.h SceneNode.h ImportObjectHandler.h ViewNode.h \
+	PreviewVisitor.h MagnifierVisitor.h LegendVisitor.h \
+	TextVisitor.h DisplayManager.h FortranMagics.h Visdef.h \
+	MultiVisdef.h XmlMagics.h XmlRootNodeAttributes.h \
+	WrepRootNodeAttributes.h ThreadNode.h TagHandler.h \
+	SceneVisitor.h LayoutManager.h WebFormat.h Layer.h \
+	HistoVisitor.h XmlSceneNodeAttributes.h \
+	MagnifierVisitorAttributes.h XmlBasicNodeAttributes.h \
+	XmlViewNodeAttributes.h LegendVisitorAttributes.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = MagicsObserver.h MagicsEvent.h \
+	ParameterSettings.h BasicSceneObject.h BasicGraphicsObject.h \
+	RootSceneNode.h SceneNode.h ImportObjectHandler.h ViewNode.h \
+	PreviewVisitor.h MagnifierVisitor.h LegendVisitor.h \
+	TextVisitor.h DisplayManager.h FortranMagics.h Visdef.h \
+	MultiVisdef.h XmlMagics.h XmlRootNodeAttributes.h \
+	WrepRootNodeAttributes.h ThreadNode.h TagHandler.h \
+	SceneVisitor.h LayoutManager.h WebFormat.h Layer.h \
+	HistoVisitor.h XmlSceneNodeAttributes.h \
+	MagnifierVisitorAttributes.h XmlBasicNodeAttributes.h \
+	XmlViewNodeAttributes.h LegendVisitorAttributes.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libbasic.la
+ATTRIBUTES = WrepRootNodeAttributes.cc XmlBasicNodeAttributes.cc XmlSceneNodeAttributes.cc \
+			XmlRootNodeAttributes.cc XmlViewNodeAttributes.cc LegendVisitorAttributes.cc \
+			ImportObjectHandlerAttributes.cc TextVisitorAttributes.cc MagnifierVisitorAttributes.cc
+
+include_H = MagicsObserver.h MagicsEvent.h ParameterSettings.h \
+			BasicSceneObject.h BasicGraphicsObject.h\
+			RootSceneNode.h SceneNode.h ImportObjectHandler.h\
+			ViewNode.h PreviewVisitor.h MagnifierVisitor.h LegendVisitor.h \
+			TextVisitor.h DisplayManager.h FortranMagics.h Visdef.h  MultiVisdef.h\
+			XmlMagics.h XmlRootNodeAttributes.h WrepRootNodeAttributes.h \
+			ThreadNode.h \
+			TagHandler.h \
+			SceneVisitor.h LayoutManager.h WebFormat.h Layer.h  HistoVisitor.h \
+			XmlSceneNodeAttributes.h MagnifierVisitorAttributes.h XmlBasicNodeAttributes.h XmlViewNodeAttributes.h LegendVisitorAttributes.h  
+
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = 
+nodist_libbasic_la_SOURCES = ${ATTRIBUTES}
+libbasic_la_SOURCES = FortranMagics.cc ParameterSettings.cc \
+			BasicSceneObject.cc BasicGraphicsObject.cc ImportObjectHandler.cc\
+			RootSceneNode.cc SceneNode.cc VisualAction.cc MultiVisdef.cc \
+			ViewNode.cc PreviewVisitor.cc MagnifierVisitor.cc LegendVisitor.cc  \
+			TextVisitor.cc  TagHandler.cc SceneVisitor.cc LayoutManager.cc \
+			XmlMagics.cc  WebFormat.cc Layer.cc  HistoVisitor.cc
+
+later = DisplayManager.ccThreadNode.cc
+interface = FortranMagics.cc WebFormat.cc \
+			XmlMagics.cc  
+
+libbasic_la_LDFLAGS = -no-undefined -no-install
+AM_CPPFLAGS = ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/common \
+	-I$(top_srcdir)/src/web -I$(top_srcdir)/src/visualisers \
+	-I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/oda \
+	-I$(top_srcdir)/src/decoders -I$(top_srcdir)/include \
+	-I$(top_srcdir)/src/libTable $(am__append_1)
+EXTRA_DIST = BasicSceneVisitor.cc  BasicSceneVisitor.h VisualAction.cc VisualAction.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/basic/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/basic/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libbasic.la: $(libbasic_la_OBJECTS) $(libbasic_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libbasic_la_LINK)  $(libbasic_la_OBJECTS) $(libbasic_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BasicGraphicsObject.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BasicSceneObject.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FortranMagics.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HistoVisitor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImportObjectHandler.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImportObjectHandlerAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Layer.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LayoutManager.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LegendVisitor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LegendVisitorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagnifierVisitor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagnifierVisitorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MultiVisdef.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ParameterSettings.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PreviewVisitor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/RootSceneNode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SceneNode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SceneVisitor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TagHandler.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TextVisitor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TextVisitorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ViewNode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/VisualAction.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WebFormat.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WrepRootNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlBasicNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlMagics.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlRootNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlSceneNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlViewNodeAttributes.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/basic/MultiVisdef.cc b/src/basic/MultiVisdef.cc
new file mode 100644
index 0000000..ed59fbe
--- /dev/null
+++ b/src/basic/MultiVisdef.cc
@@ -0,0 +1,89 @@
+/*! \file MultiVisdef.cc
+    \brief Implementation of the Template class MultiVisdef.
+    
+    Magics Team - ECMWF 2012
+    
+    Started: Wed 25-Jan-2012
+    
+    Changes:
+    
+*/
+
+
+
+#include "MultiVisdef.h"
+
+using namespace magics;
+
+MultiVisdef::MultiVisdef() 
+{
+}
+
+
+MultiVisdef::~MultiVisdef() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MultiVisdef::print(ostream& out)  const
+{
+	out << "MultiVisdef[";
+	out << "]";
+}
+
+void MultiVisdef::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	vector<Visdef*>& visdefs = ( data.dimension() == 1 ) ? one_d_ : two_d_;
+
+	for (vector<Visdef*>::iterator visdef = visdefs.begin(); visdef != visdefs.end(); ++visdef)
+		(**visdef)(data, out);
+
+}
+
+void MultiVisdef::visit(LegendVisitor& legend)
+{
+
+}
+
+void MultiVisdef::visit(Data& data, LegendVisitor& legend)
+{
+	vector<Visdef*>& visdefs = ( data.dimension() == 1 ) ? one_d_ : two_d_;
+	for (vector<Visdef*>::iterator visdef = visdefs.begin(); visdef != visdefs.end(); ++visdef)
+		(**visdef).visit(data, legend);
+}
+
+void MultiVisdef::visit(Data& data, HistoVisitor& visitor)
+{
+	vector<Visdef*>& visdefs = ( data.dimension() == 1 ) ? one_d_ : two_d_;
+
+	if(visdefs.size() > 0)
+		visdefs.at(0)->visit(data,visitor);	
+
+}
+
+void MultiVisdef::visit(MetaDataVisitor& visitor)
+{
+
+}
+
+void MultiVisdef::visit(TopAxisVisitor& top)
+{
+
+}
+
+void MultiVisdef::visit(Transformation&, Data&)
+{
+	assert(false);
+}
+
+void MultiVisdef::visit(Layer& layer)
+{
+
+}
+
+void MultiVisdef::beanInfo(IntervalMap<Colour>& bean)
+{
+
+}
diff --git a/src/basic/MultiVisdef.h b/src/basic/MultiVisdef.h
new file mode 100644
index 0000000..f135942
--- /dev/null
+++ b/src/basic/MultiVisdef.h
@@ -0,0 +1,60 @@
+/*! \file MultiVisdef.h
+    \brief Definition of the Template class MultiVisdef.
+    
+    Magics Team - ECMWF 2012
+    
+    Started: Wed 25-Jan-2012
+    
+    Changes:
+    
+*/
+
+#ifndef MultiVisdef_H
+#define MultiVisdef_H
+
+#include "magics.h"
+
+#include "Visdef.h"
+
+namespace magics {
+
+class MultiVisdef: public Visdef {
+
+public:
+	MultiVisdef();
+	virtual ~MultiVisdef();
+	vector<Visdef*>* oneDimension() { return &one_d_; }
+	vector<Visdef*>* twoDimension() { return &two_d_; }
+
+	virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+		virtual void visit(LegendVisitor&);
+		virtual void visit(Data&, LegendVisitor& legend);
+		virtual void visit(Data&, HistoVisitor&);
+	    virtual void visit(MetaDataVisitor&);
+	    virtual void visit(TopAxisVisitor&);
+	    virtual void visit(Transformation&, Data&);
+	    virtual void visit(Layer& layer);
+	    virtual void beanInfo(IntervalMap<Colour>&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 vector<Visdef*> one_d_;
+	 vector<Visdef*> two_d_;
+
+
+private:
+    //! Copy constructor - No copy allowed
+	MultiVisdef(const MultiVisdef&);
+    //! Overloaded << operator to copy - No copy allowed
+	MultiVisdef& operator=(const MultiVisdef&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MultiVisdef& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/ParameterSettings.cc b/src/basic/ParameterSettings.cc
new file mode 100644
index 0000000..0262775
--- /dev/null
+++ b/src/basic/ParameterSettings.cc
@@ -0,0 +1,120 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ParameterSettings.cc
+    \brief Implementation of parameter settings.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: 2004
+
+*/
+#include <ParameterSettings.h>
+#include <Path.h>
+
+void buildkeys(const vector<string>& roots, const string& name, vector<string>& keys)
+{
+	keys.push_back(name);
+
+	for (vector<string>::const_iterator root = roots.begin(); root != roots.end(); ++root)
+	{
+		string x = name;
+		string::size_type index = x.find(*root);
+
+		if ( index != string::npos)
+		{
+			x.replace(index, (*root).length()+1, "");
+			keys.push_back(x);		
+		}
+	}
+}
+
+void setAttribute(const vector<string>& roots, const string& name, string& param, const map<string, string>& params)
+{
+	vector<string> keys;	
+	buildkeys(roots, name, keys);
+
+	map<string, string>::const_iterator val;
+	for (vector<string>::const_iterator key = keys.begin(); key != keys.end(); ++key)
+	{
+		val = params.find(*key);
+
+		if ( val == params.end() ) continue;
+		MagLog::debug() << "Parameter [" << name << "] set to " << val->second << endl;
+		param = val->second;
+	}
+}
+
+void setAttribute(const vector<string>& roots, const string& name, auto_ptr<Colour>& param, const map<string, string>& params)
+{
+	vector<string> keys;	
+	buildkeys(roots, name, keys);
+
+	map<string, string>::const_iterator val;
+	for (vector<string>::const_iterator key = keys.begin(); key != keys.end(); ++key)
+	{
+		val = params.find(*key);
+		if ( val == params.end() ) continue;
+		MagLog::debug() << "Parameter [" << name << "] set to " << val->second << endl;
+		param = auto_ptr<Colour>(new Colour(val->second));
+	}
+}
+
+void niceprint(ostream& out, const string& val)
+{
+	out << "\"" << val << "\"";
+}
+
+
+
+template <>
+void niceprint(ostream& out, const AxisAutomaticSetting& val )
+//{m_off, m_both, m_min_only, m_max_only};)
+{
+	string cval;
+	switch (val) {
+		case m_off: cval="off";
+				break;
+		case m_both: cval="on";
+				break;
+		case m_min_only: cval="min_only";
+				break;
+		case m_max_only: cval="max_only";
+						break;
+
+	}
+	niceprint(out, cval);
+}
+template <>
+void niceprint(ostream& out, const Colour& val )
+//{m_off, m_both, m_min_only, m_max_only};)
+{
+
+	niceprint(out, val.name());
+}
+
+void toxml(string& out, const map<string, string>& def)
+{
+	ostringstream os;
+	string sep = "";
+	for (map<string, string>::const_iterator entry = def.begin(); entry != def.end(); ++entry ) {
+		os << sep << "\"" << entry->first << "\" : \"" << entry->second << "\"";
+		sep = ",\n";
+	}
+
+	out = os.str();
+}
diff --git a/src/basic/ParameterSettings.h b/src/basic/ParameterSettings.h
new file mode 100644
index 0000000..5a2faeb
--- /dev/null
+++ b/src/basic/ParameterSettings.h
@@ -0,0 +1,123 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ParameterSettings.h
+    \brief Definition of parameter settings.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: 
+
+*/
+#ifndef ParameterSet_H
+#define ParameterSet_H
+
+#include <magics.h>
+#include <MagTranslator.h>
+#include <XmlNode.h>
+#include <Colour.h>
+
+void buildkeys(const vector<string>& roots, const string&, vector<string>& keys);
+void setAttribute(const vector<string>& roots, const string& name, auto_ptr<Colour>&, const map<string, string>&);
+
+template <class T>
+void setMember(const string& value, auto_ptr<T>& object, const XmlNode& from)
+{
+	try{
+		T* new_object = MagTranslator<string, T>()(value);
+		
+        if (new_object == 0 )  {
+            object->set(from);
+            MagLog::dev()<< "OK" << endl;
+            return;
+        }
+        object = auto_ptr<T>(new_object);
+        
+        
+	}
+	catch (...) {
+       
+	}
+	object->set(from);;
+}
+
+template <class T>
+bool acceptNode(const string& node, auto_ptr<T>& object)
+{
+	try {
+		T* new_object = MagTranslator<string, T>()(node);
+        if (new_object == 0) 
+            return object->accept(node);;		
+		delete new_object;
+		return true;
+	}
+	catch (...) {
+		return object->accept(node);
+	}	
+}
+
+template <class T>
+void setMember(const vector<string>& roots, const string& name, auto_ptr<T>& object, const map<string, string>& params)
+{	
+	vector<string> keys;
+	buildkeys(roots, name, keys);
+	map<string, string>::const_iterator val;
+
+	for (vector<string>::const_iterator key = keys.begin(); key != keys.end(); ++key)
+	{
+		val = params.find(*key);
+		if ( val == params.end() ) continue;
+		try {
+			T* new_object = MagTranslator<string, T>()(val->second);
+            if (new_object == 0)  {
+                object->set(params);
+                return;
+            }
+			object = auto_ptr<T>(new_object);
+			MagLog::debug() << "Parameter [" << name << "] set to " << val->second << endl;
+		}
+		catch (...) {
+        }
+	}
+	object->set(params);
+}
+
+template <class T>
+void setAttribute(const vector<string>& roots, const string& name, T& param, const map<string, string>& params)
+{
+	vector<string> keys;	
+	buildkeys(roots, name, keys);
+
+	map<string, string>::const_iterator val;
+	for (vector<string>::const_iterator key = keys.begin(); key != keys.end(); ++key) {
+		val = params.find(*key);
+		
+		if ( val == params.end() ) continue;
+		MagLog::debug() << "Parameter [" << name << "] set to " << val->second << endl;
+		param = MagTranslator<string, T>()(val->second);
+	}	 
+}
+
+template <class T>
+void niceprint(ostream& out, const T& val) {
+	out << val;
+}
+
+void niceprint(ostream& out, const string&); 
+
+void toxml(string&, const map<string, string>&);
+#endif
diff --git a/src/basic/PreviewVisitor.cc b/src/basic/PreviewVisitor.cc
new file mode 100644
index 0000000..65742f4
--- /dev/null
+++ b/src/basic/PreviewVisitor.cc
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ViewNode.cc
+    \brief Implementation of the Template class ViewNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#include "PreviewVisitor.h"
+#include "Transformation.h"
+#include "Layout.h"
+#include "BaseDriver.h"
+
+using namespace magics;
+
+
+
+PreviewVisitor::PreviewVisitor()
+{
+name("preview");
+}
+
+PreviewVisitor::~PreviewVisitor()
+{
+
+
+}
+void PreviewVisitor::print(ostream& s) const
+{
+	s << "PreviewVisitor[]";
+}
+void NoPreviewVisitor::print(ostream& s) const
+{
+	s << "NoPreviewVisitor[]";
+}
+void PreviewVisitor::visit(BasicGraphicsObjectContainer& tree)
+{
+
+	tree.push_back(this);
+	// the Layout has been added to a Container, it will be delted automatically!
+	
+}
+void PreviewVisitor::redisplay(const BaseDriver& driver) const { 
+	MagLog::dev() << " I am a PreviewVisitor!" << endl;	
+	driver.redisplay(*this);
+}
+void PreviewVisitor::visit(BasicSceneObject& object) { 
+		object.visit(*this); 
+}
+
diff --git a/src/basic/PreviewVisitor.h b/src/basic/PreviewVisitor.h
new file mode 100644
index 0000000..09b3633
--- /dev/null
+++ b/src/basic/PreviewVisitor.h
@@ -0,0 +1,101 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \brief Definition of the Template class ViewNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef PreviewNode_H
+#define PreviewNode_H
+
+#include "magics.h"
+#include "SceneVisitor.h"
+#include "Coastlines.h"
+
+
+
+namespace magics {
+
+
+class NoPreviewVisitor: public SceneVisitor, public PreviewLayout
+{
+public:
+	NoPreviewVisitor()  {}
+	virtual ~NoPreviewVisitor() {}
+	virtual void set(const XmlNode&) {}
+	virtual void set(const map<string, string>&) {}
+	virtual bool accept(const string&) { return false;}
+	virtual void toxml(ostream&, int = 0) const {}
+	virtual NoPreviewVisitor* clone() const { return new NoPreviewVisitor();}
+
+	void visit(BasicSceneObject&) {}
+
+protected:
+	virtual void print(ostream& s) const;
+
+	friend ostream& operator<<(ostream& s,const NoPreviewVisitor& p)
+	{
+		p.print(s); 
+		return s;
+	}
+};
+
+
+class PreviewVisitor: public NoPreviewVisitor
+{
+public:
+	PreviewVisitor() ;
+	~PreviewVisitor();
+	NoPreviewVisitor* clone() const { return new PreviewVisitor(); }
+	void visit(BasicGraphicsObjectContainer&);
+	void redisplay(const BaseDriver& driver) const;
+	void visit(BasicSceneObject& object);
+	CoastPlotting& coastlines() { return coastlines_; }
+	
+protected: 
+	void print(ostream& s) const;
+	CoastPlotting coastlines_;
+};
+
+
+template <>
+class MagTranslator<string, NoPreviewVisitor> { 
+public:
+	NoPreviewVisitor* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoPreviewVisitor>::create(val);
+	}     
+
+	NoPreviewVisitor* magics(const string& param)
+	{
+		NoPreviewVisitor* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/RootSceneNode.cc b/src/basic/RootSceneNode.cc
new file mode 100644
index 0000000..39d197a
--- /dev/null
+++ b/src/basic/RootSceneNode.cc
@@ -0,0 +1,442 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file RootSceneNode.cc
+    \brief Implementation of the Template class RootSceneNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 1-Mar-2007
+    
+    Changes:
+    
+*/
+
+
+
+#include "RootSceneNode.h"
+//#include "DisplayManager.h"
+#include "PaperDimension.h"
+#include "SceneNode.h"
+#include "Timer.h"
+#include "LayoutManager.h"
+
+
+using namespace magics;
+
+void RootSceneNode::setPage(Layout& layout)
+{
+
+	if ( newpage_ ) {
+		if ( endpage_ )
+			layout.push_back(new EndPage());
+		layout.push_back(new StartPage());
+		endpage_ = true;
+		newpage_ = false;
+}
+
+}
+
+BasicGraphicsObject* RootSceneNode::close()
+{
+	BasicGraphicsObject* endpage=0;
+	if ( endpage_ ) endpage = new EndPage();
+	endpage_ = false;
+
+	return endpage;
+}
+
+void RootSceneNode::setPage(RootScenePage* node)
+{
+	current_ = node;
+	current_->root(this);
+	current_->getReady();
+	latest_ = node;
+	
+
+	// current_ is a copy of the basic SceneNode with exactly the same dimensions as the Root!  
+	current_->parent(this); 
+	items_.push_back(current_);
+
+}
+
+void FortranRootSceneNode::setPage(RootScenePage* node)
+{
+	current_ = node;
+	current_->root(this);
+	current_->getReady();
+	latest_ = node;
+	// current_ is a copy of the basic SceneNode with exactly the same dimensions as the Root!  
+	current_->parent(this); 
+
+	current_->layout().frame(false, frame_, *colour_, style_, thickness_);
+	current_->layout().resolve(false);
+	items_.push_back(current_);
+}
+
+RootSceneNode::RootSceneNode() : 
+	absoluteWidth_(29.7), absoluteHeight_(21.), current_(0), scale_(1), newpage_(true), endpage_(false)
+{
+	name_ = "root";
+	
+}
+
+RootSceneNode::~RootSceneNode() 
+{
+	delete layout_;
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void RootSceneNode::print(ostream& out)  const
+{
+	out << "RootSceneNode[";
+	out << "]";
+}
+
+MvRootSceneNode::MvRootSceneNode() 
+{
+	setPage(new MvRootScenePage());
+	delete manager_;
+	manager_ = new LayoutManager();
+	// Metview is only using positional layout!
+}
+
+void MvRootSceneNode::getReady() 
+{
+	absoluteWidth_ = FortranRootSceneNodeAttributes::width_;
+	absoluteHeight_ = FortranRootSceneNodeAttributes::height_;
+
+	layout_ = new RootLayout(absoluteWidth_, absoluteHeight_);
+	layout_->name(name_);
+	widthResolution_ = absoluteWidth_*40;
+	heightResolution_ = absoluteHeight_*40;
+}
+
+
+
+MvRootSceneNode::~MvRootSceneNode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MvRootSceneNode::print(ostream& out)  const
+{
+	out << "MvRootSceneNode[";
+	FortranRootSceneNodeAttributes::print(out);
+	out << "]";
+}
+
+FortranRootSceneNode::FortranRootSceneNode() 
+{
+	setPage(new RootScenePage(absoluteWidth_, absoluteHeight_));
+}
+
+void FortranRootSceneNode::getReady() 
+{
+	absoluteWidth_ = FortranRootSceneNodeAttributes::width_;
+	absoluteHeight_ = FortranRootSceneNodeAttributes::height_;
+
+	if (layout_)
+		delete layout_;
+	layout_ = new RootLayout(absoluteWidth_, absoluteHeight_);
+	layout_->name(name_);
+
+	current_->resize(absoluteWidth_, absoluteHeight_);
+
+
+
+	widthResolution_ = absoluteWidth_*40;
+	heightResolution_ = absoluteHeight_*40;
+	mode(basic);
+	//layout_->frame(false, frame_, *colour_, style_, thickness_);
+}
+
+
+
+FortranRootSceneNode::~FortranRootSceneNode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void FortranRootSceneNode::print(ostream& out)  const
+{
+	out << "FortranRootSceneNode[";
+	FortranRootSceneNodeAttributes::print(out);
+	out << "]";
+}
+
+XmlRootSceneNode::XmlRootSceneNode() 
+{
+	setPage(new RootScenePage());
+	absoluteWidth_  = 21.;
+	absoluteHeight_ = 29.7;
+	ParameterManager::set(string("layout"), string("magml")); 
+	mode(basic);
+}
+
+
+XmlRootSceneNode::~XmlRootSceneNode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void XmlRootSceneNode::print(ostream& out)  const
+{
+	out << "RootSceneNode[";
+	out << "]";
+}
+
+void XmlRootSceneNode::getReady()
+{
+	absoluteWidth_ = XmlRootNodeAttributes::width_;
+	absoluteHeight_ = XmlRootNodeAttributes::height_;
+	
+	if ( absoluteWidth_ == -1 || absoluteWidth_ == -1 ) {
+		PaperDimension* dimension = MagTranslator<string, PaperDimension>()(format_);
+		dimension->setOrientation(orientation_);	
+		absoluteWidth_ = dimension->getWidth();
+		absoluteHeight_ = dimension->getHeight();
+	}	
+	if ( layout_ ) delete layout_; 
+	layout_ = new RootLayout(absoluteWidth_, absoluteHeight_);
+	widthResolution_ = absoluteWidth_*40;
+	heightResolution_ = absoluteHeight_*40;
+	layout_->name(name_);
+}
+
+WrepRootSceneNode::WrepRootSceneNode() 
+{
+	
+	absoluteWidth_  = 21.;
+	absoluteHeight_ = 29.7;
+	ParameterManager::set(string("layout"), string("magml")); 
+	ParameterManager::set(string("legend_box_blanking"), string("on")); 
+	ParameterManager::set(string("legend"), string("on")); 
+	ParameterManager::set(string("legend_wrep"), string("on")); 
+	
+	mode(basic);
+}
+
+
+WrepRootSceneNode::~WrepRootSceneNode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void WrepRootSceneNode::print(ostream& out)  const
+{
+	out << "RootSceneNode[";
+	out << "]";
+}
+
+void  WrepRootSceneNode::absoluteRootWidth(double width) 
+{
+	if ( width <  absoluteWidth_ ) {
+		// We need to calculate the new pixel Width!
+		pixel_width_ = width * 800./20.;
+	}
+	scale_ = pixel_width_;
+	absoluteWidth_ = width;
+	absoluteHeight_ = (pixel_height_/pixel_width_)*absoluteWidth_;
+}
+
+void WrepRootSceneNode::getReady()
+{
+	// 300 px by inch! 
+
+	absoluteWidth_ =  (20./800.)*pixel_width_;
+	absoluteHeight_ = (20./800.)*pixel_height_;
+	
+	widthResolution_ = pixel_width_;
+	heightResolution_ = pixel_height_;
+	
+	if ( layout_ ) delete layout_; 
+	layout_ = new RootLayout(absoluteWidth_, absoluteHeight_);
+	widthResolution_ = absoluteWidth_*40;
+	heightResolution_ = absoluteHeight_*40;
+	layout_->name(name_);
+}
+
+
+void  RootSceneNode::execute()
+{
+	Timer timer("execute", "preparation of the graphical tree");
+	
+
+	dispatch(*layout_);
+	
+}
+
+BasicGraphicsObject*  RootSceneNode::visualise()
+{
+	Timer timer("execute", "preparation of the graphical tree");
+
+	return latest_->visualise();
+
+}
+
+void  RootSceneNode::release()
+{
+
+	return latest_->release();
+
+}
+BasicGraphicsObject* RootScenePage::visualise()
+{
+	root_->setPage(*layout_);
+
+
+	dispatch(*layout_);
+	return layout_;
+}
+
+void RootScenePage::release()
+{
+	items_.clear();
+	delete layout_;
+	layout_ = new RootLayout(width_, height_);
+
+
+}
+BasicSceneNode* RootSceneNode::insert(BasicPositionalObject* node) 
+{
+	    getReady();
+	    RootScenePage* last = current_;
+	    current_->insert(node);
+	    if (last != current_) 
+	    	newpage_ = true;
+	    return current_;
+}
+
+BasicSceneNode* RootScenePage::newNode(BasicPositionalObject* node)
+{
+	assert(root_);
+	
+	RootScenePage* page = newPage();
+	page->manager_ = manager_->clone();
+	
+	root_->setPage(page);
+
+	node->orphan();
+	(*(page->manager_))(page, node);
+
+	return page;
+}
+
+	
+BasicSceneNode* RootSceneNode::clone() 
+{ 
+	current_->newNode(0);
+	
+	return current_;
+}
+
+BasicSceneNode* FortranRootSceneNode::clone() 
+{ 
+	current_->newNode(0);
+	current_->layout().frame(false, frame_, *colour_, style_, thickness_);
+	current_->layout().frameIt();
+	current_->layout().resolve(false);
+	return current_;
+}
+
+RootScenePage::RootScenePage(double width, double height) : root_(0), width_(width), height_(height)
+{
+	static int i = 0;
+	ostringstream n;
+	n << "rootpage" << i;
+	name_ = n.str();
+	i++;
+
+	layout_ = new RootLayout(width, height);
+	layout_->name(name_);
+}
+RootScenePage::RootScenePage() : root_(0), width_(0), height_(0)
+{
+	static int i = 0;
+	ostringstream n;
+	n << "rootpage" << i;
+	name_ = n.str();
+	i++;
+
+	layout_ = new Layout();
+	layout_->name(name_);
+}
+RootScenePage::~RootScenePage()
+{
+}
+
+MvRootScenePage::MvRootScenePage()
+{
+	delete manager_;
+	manager_ = new LayoutManager();
+	// Metview is only using positional layout!
+}
+
+MvRootScenePage::~MvRootScenePage()
+{
+}
+
+BasicGraphicsObject* RootSceneNode::root()
+{
+	layout_->resolve(mode_ == paper);
+	return layout_;
+
+}
+void RootScenePage::resize(double width, double height)
+{
+	width_ = width;
+	height_ = height;
+	assert(layout_);
+	layout_->resize(width, height);
+
+}
+
+void MvRootScenePage::getReady()
+{
+	static int i = 0;
+	ostringstream n;
+	n << "basic" << i;
+	name_ = n.str();
+	i++;
+	MagLog::dev() << "new getReady-->" << name_ << endl;
+
+
+	BasicLayout*  basic =  new BasicLayout();;
+
+	basic->parent(layout_);
+
+	layout_ = basic;
+
+
+	layout_->name(name_);
+}
+static SimpleObjectMaker<A4, PaperDimension> a4("a4");
+static SimpleObjectMaker<A3, PaperDimension> a3("a3");
+static SimpleObjectMaker<A5, PaperDimension> a5("a5");
+static SimpleObjectMaker<A6, PaperDimension> a6("a6");
diff --git a/src/basic/RootSceneNode.h b/src/basic/RootSceneNode.h
new file mode 100644
index 0000000..b859394
--- /dev/null
+++ b/src/basic/RootSceneNode.h
@@ -0,0 +1,236 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file RootSceneNode.h
+    \brief Definition of the Template class RootSceneNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 1-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef RootSceneNode_H
+#define RootSceneNode_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+#include "FortranRootSceneNodeAttributes.h"
+#include "XmlRootNodeAttributes.h"
+#include "WrepRootNodeAttributes.h"
+
+namespace magics {
+
+
+class RootSceneNode;
+
+class RootScenePage: public BasicSceneNode 
+{
+public:
+	RootScenePage();
+	RootScenePage(double, double);
+	~RootScenePage();
+
+	BasicSceneNode* clone() 
+	{
+	  return (width_) ? new  RootScenePage(width_, height_) :  new  RootScenePage();
+	}
+	virtual RootScenePage* newPage() {
+		return (width_) ? new  RootScenePage(width_, height_) :  new  RootScenePage();
+	}
+	void visit(BasicGraphicsObjectContainer& tree)
+		{
+			tree.push_back(new StartPage());
+			BasicSceneNode::visit(tree);
+			tree.push_back(new EndPage());
+		}
+	BasicSceneNode* newNode(BasicPositionalObject*);
+	void root(RootSceneNode* root) { root_ = root; }
+	BasicGraphicsObject* visualise();
+	void resize(double width, double height);
+	void release();
+
+protected:
+	RootSceneNode* root_;
+	double width_;
+	double height_;
+
+};
+class MvRootScenePage: public RootScenePage
+{
+public:
+	MvRootScenePage();
+	~MvRootScenePage();
+
+	 RootScenePage* newPage() {
+			return new MvRootScenePage();
+		}
+	void visit(BasicGraphicsObjectContainer& tree)
+	{		
+		    MagLog::dev() << "visit(BasicGraphicsObjectContainer::MvRootScenePage" << endl;
+			BasicSceneNode::visit(tree);		
+	}
+	void getReady();
+
+
+};
+class RootSceneNode: public BasicSceneNode {
+
+public:
+	RootSceneNode();
+
+	virtual ~RootSceneNode();
+	virtual void setPage(RootScenePage* node);
+
+
+	
+	double absoluteWidth() const { return absoluteWidth_; }
+	double absoluteHeight() const { return absoluteHeight_; }
+	virtual void  absoluteRootWidth(double width)  { scale_ = width/absoluteWidth_; if ( scale_ < 1 ) scale_ = 1; absoluteWidth_ = width; }
+	void absoluteRootHeight(double height) { absoluteHeight_ = height; }
+	double scalingFactor() const { return scale_; } // For Magml and wrep ... 
+	virtual BasicSceneNode* clone();
+	BasicGraphicsObject* root();
+	virtual void getReady() {}
+	void execute();
+	BasicGraphicsObject* visualise();
+	BasicGraphicsObject* close();
+	void setPage(Layout&);
+	void release();
+	void newpage() { current_->newpage(); }
+	BasicSceneNode* insert(BasicPositionalObject*);
+	
+	virtual int rootWidthResolution()   const
+			{ return  widthResolution_; } 
+	virtual int rootHeightResolution() const   
+	   		{ return  heightResolution_; }
+	//void push_back(BasicSceneObject* item);
+	
+	virtual void text(TextVisitor*) { }
+	virtual void legend(LegendVisitor*) {  }
+	virtual MagicsMode mode() { return mode_; }
+	void mode(MagicsMode mode) { mode_ = mode; }
+	BasicSceneObject* current() { return current_; }
+	bool needStartPage();
+	bool needEndPage();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 double absoluteWidth_;
+	 double absoluteHeight_;
+	 
+	 int widthResolution_;
+	 int heightResolution_;
+	 
+	 RootScenePage* current_;
+	 RootScenePage* latest_;
+	 double scale_;
+	 MagicsMode mode_;
+	 bool newpage_;
+	 bool endpage_;
+
+	 
+
+private:
+    //! Copy constructor - No copy allowed
+	RootSceneNode(const RootSceneNode&);
+    //! Overloaded << operator to copy - No copy allowed
+	RootSceneNode& operator=(const RootSceneNode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const RootSceneNode& p)
+		{ p.print(s); return s; }
+};
+
+
+
+class FortranRootSceneNode : public RootSceneNode, public FortranRootSceneNodeAttributes
+{
+public:
+	FortranRootSceneNode();
+	~FortranRootSceneNode();
+	void getReady();
+	BasicSceneNode* clone();
+	virtual void setPage(RootScenePage* node);
+
+protected:
+	void print(ostream&) const;
+};
+
+class MvRootSceneNode : public RootSceneNode, public FortranRootSceneNodeAttributes
+{
+public:
+	MvRootSceneNode();
+	~MvRootSceneNode();
+	void getReady();
+protected:
+	void print(ostream&) const;
+};
+
+class XmlRootSceneNode : public RootSceneNode, public XmlRootNodeAttributes
+{
+public:
+	XmlRootSceneNode();
+	~XmlRootSceneNode();
+
+	void set(const map<string, string>& map)
+	{
+		XmlRootNodeAttributes::set(map);
+	}
+
+	void set(const XmlNode& node)
+	{
+		XmlRootNodeAttributes::set(node);
+	}
+
+	void getReady();
+
+protected:
+	void print(ostream&) const; 
+};
+
+class WrepRootSceneNode : public XmlRootSceneNode, public WrepRootNodeAttributes
+{
+public:
+	WrepRootSceneNode();
+	~WrepRootSceneNode();
+
+	void set(const map<string, string>& map)
+	{
+		WrepRootNodeAttributes::set(map);
+	}
+
+	void set(const XmlNode& node)
+	{ 
+		WrepRootNodeAttributes::set(node);
+	}
+
+	void  absoluteRootWidth(double width);
+	void getReady();
+
+protected:
+	void print(ostream&) const; 
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/SceneNode.cc b/src/basic/SceneNode.cc
new file mode 100644
index 0000000..bd550de
--- /dev/null
+++ b/src/basic/SceneNode.cc
@@ -0,0 +1,255 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SceneNode.cc
+    \brief Implementation of the Template class SceneNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Thu 1-Mar-2007
+    
+    Changes:
+    
+*/
+
+
+
+#include "SceneNode.h"
+#include "LayoutManager.h"
+#include "Dimension.h"
+#include "TextVisitor.h"
+#include "LegendVisitor.h"
+#include "Layer.h"
+
+using namespace magics;
+
+SceneNode::SceneNode() : legend_(0)
+{
+	static int i = 0;
+	//displayType_ = INLINE;
+    //margin(0,0,0,0);
+    
+    ostringstream n;
+	n << "Page" << i;
+	name_ = n.str();
+	i++;
+    layout_ = new SceneLayout();
+    layout_->name(name_);
+    layout_->id(iconId_); // For Metview
+}
+
+
+SceneNode::~SceneNode() 
+{
+	
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SceneNode::print(ostream& out)  const
+{
+	out << "SceneNode[" << name_;
+	
+		out << "->" << parent_->name();
+	
+	out << "]";
+}
+void SceneNode::getReady()
+{
+}
+void SceneNode::text(TextVisitor* text)
+{
+	MagLog::dev() << " SceneNode::text -->" << endl;
+	((BasicPositionalObject*)text)->parent(this);
+	text->getReady(); //to calcuilate the dimension
+		
+	 (*manager_)(this, (BasicPositionalObject*)text);
+	texts_.push_back(text);
+}
+
+void SceneNode::legend(LegendVisitor* legend)
+{
+	legend_ = legend; 
+	((BasicPositionalObject*)legend)->parent(this);
+	legend->getReady(); //to calcuilate the dimension
+		
+	(*manager_)(this, (BasicPositionalObject*)legend);
+	
+}
+
+void SceneNode::visit(BasicGraphicsObjectContainer& tree)
+{
+	tree.push_back(layout_);
+	layout_->blankIt(); 
+    SceneLayer* layer = new SceneLayer();
+    for ( vector<TextVisitor*>::iterator text = texts_.begin(); text != texts_.end(); ++text)
+    	layer->text(*text);
+    layer->legend(legend_);
+    layer->setMagicsMode(mode());
+    layout_->push_back(layer);
+    layout_->id(iconId_); // For Metview
+    
+  
+	dispatch(*layer); 
+	
+	layout_->frameIt();  
+	
+}
+
+FortranSceneNode::FortranSceneNode() : sceneLayer_(0)
+{
+
+}
+
+void FortranSceneNode::visit(BasicGraphicsObjectContainer& tree)
+{
+	if ( !sceneLayer_ ) {
+		tree.push_back(layout_);
+		layout_->blankIt();
+		sceneLayer_ = new SceneLayer();
+		sceneLayer_->state(new_layer);
+		sceneLayer_->setMagicsMode(mode());
+		layout_->push_back(sceneLayer_);
+		page_id_->visit(*layout_);
+		layout_->id(iconId_); // For Metview
+	}
+#ifdef MAG_NEXT
+	else 
+    {
+		sceneLayer_->state(geometry_changed);
+		//layout_->clear();
+		//layout_->push_back(sceneLayer_);
+	}
+#endif
+
+	dispatch(*sceneLayer_);
+	
+	layout_->frameIt();  
+	
+}
+
+
+void FortranSceneNode::getReady()
+{	
+	assert(parent_);
+	
+	// Make sure that the dimensions are not bigger that the paper size!
+
+	if ( width_ > parent_->absoluteWidth() )
+		width_ = parent_->absoluteWidth();
+	if ( height_ > parent_->absoluteHeight() )
+			height_ = parent_->absoluteHeight();
+
+
+	double x =  adjustDimension(x_, 0, parent_->absoluteWidth());
+	double y = adjustDimension(y_, 0, parent_->absoluteHeight());
+    double width = adjustDimension(width_, 100, parent_->absoluteWidth());
+	double height = adjustDimension(height_, 100, parent_->absoluteHeight());
+	
+	layout_->x(x);
+	layout_->y(y);
+	layout_->width(width);
+	layout_->height(height);
+	
+    
+	layout_->frame(false, FortranSceneNodeAttributes::frame_,*frame_colour_, frame_line_style_, frame_thickness_);
+  
+	BasicSceneObject::getReady();
+}
+
+FortranSceneNode::~FortranSceneNode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void FortranSceneNode::print(ostream& out)  const
+{
+	out << "FortranSceneNode[";
+	BasicSceneObject::print(out);
+	FortranSceneNodeAttributes::print(out);
+	out << "]";
+}
+
+XmlSceneNode::XmlSceneNode() 
+{
+}
+
+
+XmlSceneNode::~XmlSceneNode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void XmlSceneNode::print(ostream& out)  const
+{
+	out << "XmlSceneNode[";
+	out << "]";
+}
+
+
+
+void XmlSceneNode::getReady()
+{
+	
+	MagLog::dev() << " SceneNode::getReady() \n";
+	MagLog::dev() << "XmlSceneNode::getReady() \n";
+	assert (parent_);
+	Dimension bottom(bottom_, parent_->absoluteWidth(), 0);
+	Dimension left(left_, parent_->absoluteHeight(), 0);
+	Dimension width(width_, parent_->absoluteWidth(), 100);
+	Dimension height(height_, parent_->absoluteHeight(), 100);
+	
+	Dimension mb(margin_bottom_, width.absolute(), 0);
+	Dimension ml(margin_left_, height.absolute(), 0);
+	Dimension mr(margin_right_, width.absolute(), 0);
+	Dimension mt(margin_top_, height.absolute(), 0);
+	
+
+	
+	layout_->x(left.percent()); // Add alos the margin!
+	layout_->y(bottom.percent()); // Add alos the margin!
+	layout_->width(width.percent());
+	layout_->height(height.percent());
+	
+	layout_->display(display_);
+	
+	
+
+	//margin(mt.percent(), mr.percent(), mb.percent(), ml.percent());
+	
+	//push_back(page_id_.clone());
+		
+		
+	//border(0, 0, 0, 0);
+	//padding(0, 0, 0, 0);
+	//ayout_.frame(border_);
+	
+	layout_->frame(false, false, *border_colour_, border_style_, border_thickness_);
+	
+	BasicSceneObject::getReady();
+	
+}
+
+
+
diff --git a/src/basic/SceneNode.h b/src/basic/SceneNode.h
new file mode 100644
index 0000000..fb38739
--- /dev/null
+++ b/src/basic/SceneNode.h
@@ -0,0 +1,108 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SceneNode.h
+    \brief Definition of the Template class SceneNode.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mar-2007
+
+    Changes:
+
+*/
+
+#ifndef SceneNode_H
+#define SceneNode_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+
+#include "FortranSceneNodeAttributes.h"
+#include "XmlSceneNodeAttributes.h"
+
+namespace magics {
+
+class SceneNode: public BasicSceneNode {
+
+public:
+	SceneNode();
+	virtual ~SceneNode();
+	
+	BasicSceneNode* clone() {  
+		   
+			return new SceneNode();
+	}
+
+	void getReady();
+	void text(TextVisitor*);
+	void legend(LegendVisitor*);
+	void visit(BasicGraphicsObjectContainer& tree);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 	
+	 vector<TextVisitor*> texts_;
+	 LegendVisitor* legend_;
+	
+private:
+	SceneNode(const SceneNode&);
+    //! Overloaded << operator to copy - No copy allowed
+	SceneNode& operator=(const SceneNode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SceneNode& p)
+		{ p.print(s); return s; }
+};
+
+class FortranSceneNode: public SceneNode, public FortranSceneNodeAttributes
+{
+public:
+	FortranSceneNode();
+	~FortranSceneNode(); 
+	void getReady();
+	void resize();
+	void visit(BasicGraphicsObjectContainer& tree);
+	BasicSceneNode* clone() {  
+		FortranSceneNode* node = new FortranSceneNode(); 
+		node->copy(*this);	
+		return node;
+	}
+protected:
+	void print(ostream&) const;
+	SceneLayer* sceneLayer_;
+};
+
+
+
+class XmlSceneNode: public SceneNode, public XmlSceneNodeAttributes
+{
+public:
+	XmlSceneNode();
+	~XmlSceneNode();
+	void set(const map<string, string>& map) { XmlSceneNodeAttributes::set(map); }
+	void set(const XmlNode& node) { XmlSceneNodeAttributes::set(node); }
+	void getReady();
+
+protected:
+	void print(ostream&) const;
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/SceneVisitor.cc b/src/basic/SceneVisitor.cc
new file mode 100644
index 0000000..59289e4
--- /dev/null
+++ b/src/basic/SceneVisitor.cc
@@ -0,0 +1,409 @@
+/*! \file SceneVisitor.cc
+    \brief Implementation of the Template class SceneVisitor.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Mon 29-Dec-2008
+    
+    Changes:
+    
+*/
+
+
+
+#include "SceneVisitor.h"
+#include "BaseDriver.h"
+#include "AnimationRules.h"
+#include "Transformation.h"
+#include "Layer.h"
+
+using namespace magics;
+
+SceneVisitor::SceneVisitor() 
+{
+}
+
+SceneVisitor::~SceneVisitor() 
+{
+}
+
+bool SceneVisitor::reproject(BasicGraphicsObjectContainer&) const
+{
+	return true;
+}
+
+void  LayoutVisitor::redisplay(const BaseDriver& driver) const
+{
+	driver.redisplay(*current_);
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SceneVisitor::print(ostream& out)  const
+{
+	out << "SceneVisitor[";
+	out << "]";
+}
+
+DrawingVisitor::DrawingVisitor() 
+{
+	layout_ = new Layout();
+	layout_->name("drawing");
+	layout_->setNavigable();
+}
+
+
+DrawingVisitor::~DrawingVisitor() 
+{
+
+}
+
+
+void LayoutVisitor::print(ostream& out) const
+{
+    out << "LayoutVisitor[";
+    out << *layout_;
+    out << "]";
+}
+
+HorizontalAxisVisitor::HorizontalAxisVisitor(const DrawingVisitor&)
+{
+}
+
+HorizontalAxisVisitor::~HorizontalAxisVisitor()
+{
+}
+
+VerticalAxisVisitor::VerticalAxisVisitor(const DrawingVisitor&)
+{
+}
+
+VerticalAxisVisitor::~VerticalAxisVisitor()
+{
+}
+
+void VerticalAxisVisitor::tick(double&, double&, bool)
+{
+}
+
+void VerticalAxisVisitor::minortick(double&, double&, bool) {}
+double VerticalAxisVisitor::offsetTickLabel(double, double) { return 0; }
+double VerticalAxisVisitor::angleTickLabel() {return 0;}
+double VerticalAxisVisitor::angleTitle() {return 0;}
+double VerticalAxisVisitor::offsetTitle() {return 0;}
+double VerticalAxisVisitor::angleTip() {return 0;}
+double VerticalAxisVisitor::offsetTip() {return 0;}
+
+void HorizontalAxisVisitor::tick(double&, double&, bool) {}
+void HorizontalAxisVisitor::minortick(double&, double&, bool) {}
+double HorizontalAxisVisitor::offsetTickLabel(double, double) {return 0;}
+double HorizontalAxisVisitor::angleTickLabel() {return 0;}
+double HorizontalAxisVisitor::angleTitle() {return 0;}
+double HorizontalAxisVisitor::offsetTitle() {return 0;} 
+double HorizontalAxisVisitor::angleTip() {return 0;}
+double HorizontalAxisVisitor::offsetTip() {return 0;} 
+
+TopAxisVisitor::TopAxisVisitor(const DrawingVisitor& drawing): 
+    HorizontalAxisVisitor(drawing)
+{
+	layout_ = new Layout();
+	layout_->name("top");
+	drawing.transformation(*layout_);
+}
+
+TopAxisVisitor::~TopAxisVisitor()
+{
+}
+
+BottomAxisVisitor::BottomAxisVisitor(const DrawingVisitor& drawing): 
+    HorizontalAxisVisitor(drawing)
+{
+	layout_ = new Layout();
+	layout_->name("bottom");
+	drawing.transformation(*layout_);
+}
+
+BottomAxisVisitor::~BottomAxisVisitor()
+{
+}
+
+RightAxisVisitor::RightAxisVisitor(const DrawingVisitor& drawing): 
+    VerticalAxisVisitor(drawing)
+{
+	layout_ = new Layout();
+	layout_->name("right");
+	drawing.transformation(*layout_);
+}
+
+RightAxisVisitor::~RightAxisVisitor()
+{
+}
+
+LeftAxisVisitor::LeftAxisVisitor(const DrawingVisitor& drawing):
+    VerticalAxisVisitor(drawing)
+{
+	layout_ = new Layout();
+	layout_->name("left");
+	drawing.transformation(*layout_);
+}
+
+LeftAxisVisitor::~LeftAxisVisitor()
+{
+}
+
+void LeftAxisVisitor::tick(double& x1, double& x2, bool)
+{
+	double length =  ((current_->xmax_ - current_->xmin_)/current_->absoluteWidth()) * 0.2; 
+	x2 = current_->xmax_;
+	x1 = current_->xmax_ - length;
+}
+
+void LeftAxisVisitor::minortick(double& x1, double& x2, bool)
+{
+	double length =  ((current_->xmax_ - current_->xmin_)/current_->absoluteWidth()) * 0.1; 
+	x2 = current_->xmax_;
+	x1 = current_->xmax_ - length;
+}
+
+double  LeftAxisVisitor::offsetTickLabel(double height, double from)
+{
+
+	double h =  ((current_->xmax_ - current_->xmin_)/current_->absoluteWidth()) * (2*height);
+
+	return from - h;
+} 
+
+double  LeftAxisVisitor::angleTickLabel()
+{
+	return 0;
+}
+
+double  LeftAxisVisitor::angleTitle()
+{
+	return 3*3.14/2;
+}
+
+double  LeftAxisVisitor::offsetTitle()
+{
+	return current_->xmin_;
+}
+double  LeftAxisVisitor::angleTip()
+{
+	return 3*3.14/2;
+}
+
+double  LeftAxisVisitor::offsetTip()
+{
+	return current_->xmin_;
+}
+
+void RightAxisVisitor::tick(double& x1, double& x2, bool)
+{
+	double length =  ((current_->xmax_ - current_->xmin_)/current_->absoluteWidth()) * 0.2; 
+	x2 = current_->xmin_;
+	x1 = x2 + length;
+}
+
+void RightAxisVisitor::minortick(double& x1, double& x2, bool)
+{
+	double length =  ((current_->xmax_ - current_->xmin_)/current_->absoluteWidth()) * 0.1; 
+	x2 = current_->xmin_;
+	x1 = x2 + length;
+}
+
+double  RightAxisVisitor::offsetTickLabel(double height, double from)
+{
+	double h =  ((current_->xmax_ - current_->xmin_)/current_->absoluteWidth()) * (2*height);
+	return from + h;
+
+}
+
+double  RightAxisVisitor::angleTickLabel()
+{
+	return 0;
+}
+
+double  RightAxisVisitor::angleTitle()
+{
+	return 3.14/2;
+}
+
+double  RightAxisVisitor::offsetTitle()
+{
+	return current_->xmax_;
+}
+double  RightAxisVisitor::angleTip()
+{
+	return 3.14/2;
+}
+
+double  RightAxisVisitor::offsetTip()
+{
+	return current_->xmax_;
+}
+
+void TopAxisVisitor::tick(double& y1, double& y2, bool out)
+{
+	double length =  ((current_->ymax_ - current_->ymin_)/current_->absoluteHeight()) * 0.15;
+	y1 = current_->ymin_;
+	y2 = (out) ? y2 + length : y2 - length;
+}
+
+void TopAxisVisitor::minortick(double& y1, double& y2, bool out)
+{
+	double length =  ((current_->ymax_ - current_->ymin_)/current_->absoluteHeight()) * 0.1; 
+	y2 =current_->ymin_;
+	y1 = (out) ? y2 + length : y2 - length;
+}
+
+double  TopAxisVisitor::offsetTickLabel(double height, double from)
+{
+	double h =  ((current_->ymax_ - current_->ymin_)/current_->absoluteHeight()) * height;
+	return   from + h;
+}
+
+double  TopAxisVisitor::angleTickLabel()
+{
+	return 0;
+}
+
+double  TopAxisVisitor::angleTitle()
+{
+	return 0;
+}
+
+double  TopAxisVisitor::offsetTitle()
+{
+	return current_->ymax_;
+}
+
+double  TopAxisVisitor::angleTip()
+{
+	return 0;
+}
+
+double  TopAxisVisitor::offsetTip()
+{
+	return current_->ymax_;
+}
+
+void BottomAxisVisitor::tick(double& y1, double& y2, bool out )
+{
+	assert(current_);
+	double length =  ((current_->ymax_ - current_->ymin_)/current_->absoluteHeight()) * 0.15; 
+	y2 = current_->ymax_;
+	y1 =  (out) ? y2 - length : y2 + length;
+}
+
+void BottomAxisVisitor::minortick(double& y1, double& y2, bool out)
+{
+	double length =  ((current_->ymax_ - current_->ymin_)/current_->absoluteHeight()) * 0.1; 
+	y2 = current_->ymax_;
+	y1 =  (out) ? y2 - length : y2 + length;
+}
+
+double  BottomAxisVisitor::offsetTickLabel(double height, double from)
+{
+
+
+	double h =  ((current_->ymax_ - current_->ymin_)/current_->absoluteHeight()) * height;
+
+
+	return   from - h;
+}
+
+double  BottomAxisVisitor::angleTickLabel()
+{
+	return 0;
+}
+
+double  BottomAxisVisitor::angleTitle()
+{
+	return 0;
+}
+
+double  BottomAxisVisitor::offsetTitle()
+{
+	return current_->ymin_;
+}
+
+double  BottomAxisVisitor::angleTip()
+{
+	return 0;
+}
+
+double  BottomAxisVisitor::offsetTip()
+{
+	return current_->ymin_;
+}
+
+void LayoutVisitor::push_back(BasicGraphicsObject* object)
+{
+	assert(current_);
+	current_->push_back(object);
+}
+void DrawingVisitor::set(MagnifierCollector& magnifier) 
+{ 
+	newLayout();
+	
+	magnifier.setLayout(current_); 
+}
+
+void LayoutVisitor::newLayout() const { current_ = layout_->clone(); }
+
+Layout&  LayoutVisitor::layout() const { if ( !current_ ) newLayout(); return *current_; }
+Layout*  LayoutVisitor::layoutPtr() const { assert(layout_);  return current_;  }
+Layout*  LayoutVisitor::mainLayout() const { assert(layout_); return layout_; }
+
+Justification TopAxisVisitor::justificationTickLabel(const string& orientation)
+{
+	// horizontal == parallel
+	return ( magCompare(orientation, "vertical") ) ? MLEFT : MCENTRE;
+}
+
+Justification BottomAxisVisitor::justificationTickLabel(const string& orientation)
+{
+	// horizontal == parallel
+	return ( magCompare(orientation, "vertical") ) ? MRIGHT : MCENTRE;
+}
+
+Justification LeftAxisVisitor::justificationTickLabel(const string& orientation)
+{
+	// vertical == parallel
+	return ( magCompare(orientation, "horizontal") ) ? MRIGHT : MCENTRE;
+}
+Justification RightAxisVisitor::justificationTickLabel(const string& orientation)
+{
+	//vertical == parallel
+	return ( magCompare(orientation, "horizontal") ) ? MLEFT : MCENTRE;
+}
+Justification VerticalAxisVisitor::justificationTickLabel(const string& orientation)
+{
+	return MCENTRE;
+}
+
+VerticalAlign TopAxisVisitor::textAlignment(const string& orientation)
+{
+	// horizontal == parallel
+	return ( magCompare(orientation, "vertical") ) ? MHALF : MTOP;
+}
+
+VerticalAlign BottomAxisVisitor::textAlignment(const string& orientation)
+{
+	// horizontal == parallel
+	return ( magCompare(orientation, "vertical") ) ? MHALF : MBOTTOM;
+}
+
+VerticalAlign LeftAxisVisitor::textAlignment(const string& orientation)
+{
+	// vertical == parallel
+	return ( magCompare(orientation, "horizontal") ) ?  MHALF: MBOTTOM;
+}
+VerticalAlign RightAxisVisitor::textAlignment(const string& orientation)
+{
+	// vertical == parallel
+	return ( magCompare(orientation, "horizontal") ) ?  MHALF: MTOP;
+}
+
+
diff --git a/src/basic/SceneVisitor.h b/src/basic/SceneVisitor.h
new file mode 100644
index 0000000..6de28ff
--- /dev/null
+++ b/src/basic/SceneVisitor.h
@@ -0,0 +1,253 @@
+/*! \file SceneVisitor.h
+    \brief Definition of the Template class SceneVisitor.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Mon 29-Dec-2008
+    
+    Changes:
+    
+*/
+
+#ifndef SceneVisitor_H
+#define SceneVisitor_H
+
+#include "magics.h"
+#include "BasicGraphicsObject.h"
+#include "BasicSceneObject.h"
+
+namespace magics {
+class Layout;
+
+
+class SceneVisitor  {
+
+public:
+	SceneVisitor();
+	virtual ~SceneVisitor();
+	bool reproject(BasicGraphicsObjectContainer&) const;
+	virtual void visit(BasicSceneObject& object) = 0;
+	virtual void visit(BasicGraphicsObjectContainer&) {}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	SceneVisitor(const SceneVisitor&);
+    //! Overloaded << operator to copy - No copy allowed
+	SceneVisitor& operator=(const SceneVisitor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SceneVisitor& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+class LayoutVisitor: public SceneVisitor
+{
+public:
+	LayoutVisitor(): layout_(0), current_(0)  {}
+	~LayoutVisitor() {}
+	void redisplay(const BaseDriver& driver) const;
+	
+	virtual void reset() {};
+	virtual void set(MagnifierCollector&) {}
+	virtual void newLayout() const;
+
+	Layout& layout() const;
+	Layout* layoutPtr() const;
+	Layout* mainLayout() const;
+	
+	
+	const Transformation& transformation() const { 
+	    	assert(layout_); 
+	    	return layout_->transformation(); 
+	    }
+	void push_back(BasicGraphicsObject* object);
+	
+	void parent(BasicGraphicsObjectContainer* parent) 
+		{  assert(layout_); layout_->parent(parent); }
+	double minX()  const 
+		{ assert(layout_);  return layout_->minX(); }
+	double maxX()  const 
+		{  assert(layout_); return layout_->maxX(); }
+	double minY()  const
+		{   assert(layout_); return layout_->minY(); }
+	double maxY()  const 
+		{  assert(layout_); return layout_->maxY(); }
+	void width(double width)   
+		{  assert(layout_); return layout_->width(width); }
+	void height(double height)  
+		{  assert(layout_); return layout_->height(height); }
+	void widthResolution(double width)   
+		{  assert(layout_); return layout_->widthResolution(width); }
+	void heightResolution(double height)  
+		{  assert(layout_); return layout_->heightResolution(height); }
+	void x(double x) 
+		{  assert(layout_); return layout_->x(x); }
+	void y(double y) 
+		{  assert(layout_); return layout_->y(y); }
+	 void transformation(Layout& layout) const
+	    { layout.transformation(layout_->transformation_);  }
+	void transformation(Transformation* transformation)   
+		{  assert(layout_); return layout_->transformation(transformation); }
+	void id(const string& id)   {  assert(layout_); return layout_->id(id); }
+	void zoomable(bool zoomable)   {  assert(layout_); return layout_->zoomable(zoomable); }
+	void zoomLevels(int zl)   {  assert(layout_); return layout_->zoomLevels(zl); }
+	void zoomCurrentLevel(int level)   {  assert(layout_); return layout_->zoomCurrentLevel(level); }
+	void frameIt()   {  assert(layout_); return layout_->frameIt(); }
+	void frame(Layout& layout) { assert(layout_); layout_->frame(layout); }
+protected:
+	void print(ostream&) const; 
+	Layout* layout_; 	 
+	mutable Layout* current_;
+};
+
+
+class DrawingVisitor: public LayoutVisitor
+{
+public:
+	DrawingVisitor();
+	~DrawingVisitor();
+	void visit(BasicSceneObject& object) { object.visit(*this); }
+	void set(MagnifierCollector&);
+	//Layout* execute(AnimationStep&, const Layout* visitor);
+	
+	
+protected:
+	
+};
+
+
+class HorizontalAxisVisitor: public LayoutVisitor
+{
+public:
+	HorizontalAxisVisitor(const DrawingVisitor&);
+	~HorizontalAxisVisitor();
+	virtual void tick(double&, double&, bool);
+	virtual void minortick(double&, double&, bool);
+		virtual double offsetTickLabel(double, double);
+		virtual double angleTickLabel();	
+		virtual double angleTitle();
+		virtual double offsetTitle();
+		virtual double angleTip();
+		virtual double offsetTip();
+		virtual VerticalAlign textAlignment(const string&) { return MBOTTOM; }
+	virtual Justification justificationTickLabel(const string&) { return MCENTRE; }
+protected:
+	
+	 
+};
+class VerticalAxisVisitor: public LayoutVisitor
+{
+public:
+	VerticalAxisVisitor(const DrawingVisitor&);
+	~VerticalAxisVisitor();
+	virtual double offsetLine() { return 10; }
+	virtual void tick(double&, double&, bool);
+	virtual void minortick(double&, double&, bool);
+	virtual double offsetTickLabel(double, double);
+	virtual double angleTickLabel();	
+	virtual double angleTitle();
+	virtual double offsetTitle();
+	virtual double angleTip();
+	virtual double offsetTip();
+	virtual Justification justificationTickLabel(const string&);
+	virtual VerticalAlign textAlignment(const string&) { return MHALF; }
+protected:
+	
+	 
+};
+class LeftAxisVisitor: public VerticalAxisVisitor
+{
+public:
+	LeftAxisVisitor(const DrawingVisitor&);
+	~LeftAxisVisitor();
+	void visit(BasicSceneObject& object) { object.visit(*this); }
+	virtual Justification justificationTickLabel(const string&);
+	virtual void tick(double&, double&, bool);
+	virtual void minortick(double&, double&, bool);
+	virtual double offsetTickLabel(double, double);
+	virtual double angleTickLabel();	
+	virtual double angleTitle();
+	virtual double offsetTitle();
+	virtual double angleTip();
+	virtual double offsetTip();
+	virtual VerticalAlign textAlignment(const string&);
+protected:
+	
+	 
+};
+
+class RightAxisVisitor: public VerticalAxisVisitor
+{
+public:
+	RightAxisVisitor(const DrawingVisitor&);
+	~RightAxisVisitor();
+	void visit(BasicSceneObject& object) { object.visit(*this); }
+	virtual Justification justificationTickLabel(const string&);
+	virtual void tick(double&, double&, bool);
+	virtual void minortick(double&, double&, bool);
+	virtual double offsetTickLabel(double, double);
+	virtual double angleTickLabel();	
+	virtual double angleTitle();
+	virtual double offsetTitle();	
+	virtual double angleTip();
+	virtual double offsetTip();
+	virtual VerticalAlign textAlignment(const string&);
+protected:
+	
+	
+};
+
+
+
+class TopAxisVisitor: public HorizontalAxisVisitor
+{
+public:
+	TopAxisVisitor(const DrawingVisitor&);
+	~TopAxisVisitor();
+	void visit(BasicSceneObject& object) { object.visit(*this); }
+	virtual Justification justificationTickLabel(const string&);
+	virtual void tick(double&, double&, bool);
+	virtual void minortick(double&, double&, bool);
+	virtual double offsetTickLabel(double, double);
+	virtual double angleTickLabel();	
+	virtual double angleTitle();
+	virtual double offsetTitle();
+	virtual double angleTip();
+	virtual double offsetTip();
+	virtual VerticalAlign textAlignment(const string&);
+	
+protected:
+	
+};
+
+class BottomAxisVisitor: public HorizontalAxisVisitor
+{
+public:
+	BottomAxisVisitor(const DrawingVisitor&);
+	~BottomAxisVisitor();
+	void visit(BasicSceneObject& object) { object.visit(*this); }
+	virtual void tick(double&, double&, bool);
+	virtual void minortick(double&, double&, bool);
+	virtual Justification justificationTickLabel(const string&);
+	virtual double offsetTickLabel(double, double);
+	virtual double angleTickLabel();	
+	virtual double angleTitle();
+	virtual double offsetTitle();
+	virtual double angleTip();
+	virtual double offsetTip();
+	virtual VerticalAlign textAlignment(const string&);
+protected:
+	
+	
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/TagHandler.cc b/src/basic/TagHandler.cc
new file mode 100644
index 0000000..541fb67
--- /dev/null
+++ b/src/basic/TagHandler.cc
@@ -0,0 +1,400 @@
+/*! \file TagHandler.cc
+    \brief Implementation of the Template class TagHandler.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Mon 27-Oct-2008
+    
+    Changes:
+    
+*/
+
+
+
+#include "TagHandler.h"
+#include "XmlReader.h"
+using namespace magics;
+
+TagHandler::TagHandler()
+{
+}
+
+
+TagHandler::~TagHandler() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TagHandler::print(ostream& out)  const
+{
+	out << "TagHandler[";
+	for (map<string, DefList >::const_iterator fam = definitions_.begin(); fam != definitions_.end(); ++fam) {
+		out << " Famille-> " << fam->first;
+		
+		DefList defs = fam->second;
+		for ( DefList::const_iterator def = defs.begin(); def != defs.end(); ++def) {
+			string sep;
+			string value;
+			for ( std::set<string>::const_iterator v = def->second.begin(); v != def->second.end(); ++v) {
+				if ((*v).empty()) continue;
+				value += sep + *v; 
+				sep ="/";
+			}
+			out << " (" << def->first << "=" << value <<  ")" << endl;
+		}
+	}
+	out << "]";
+}
+
+void TagHandler::update(const string& family, const string& definition, const string& value)
+{
+	map<string, DefList >::iterator fam = definitions_.find(family);
+	if ( fam == definitions_.end()) {
+		definitions_.insert(make_pair(family, DefList()) );
+		fam = definitions_.find(family);
+	}
+	DefList::iterator def = fam->second.find(definition);
+	
+	if ( def == fam->second.end() ) {
+		fam->second.insert(make_pair(definition, std::set<string>()));
+		def = fam->second.find(definition);
+	}
+
+	def->second.insert(value);
+}
+
+
+string TagHandler::get(const string& family, const string& definition)
+{
+	map<string, DefList >::iterator fam = definitions_.find(family);
+
+	if ( fam == definitions_.end() ) return "";
+
+	DefList::iterator def = fam->second.find(definition);
+
+	if ( def == fam->second.end() ) return "";
+
+	string sep = "";
+	string value;
+	for ( std::set<string>::const_iterator v = def->second.begin(); v != def->second.end(); ++v) {
+		if ((*v).empty()) continue;
+		value += sep + *v; 
+		sep ="/";
+	}
+	return value;
+}
+
+TagConverter::TagConverter(TagHandler& owner) : owner_(owner), text_(0) {
+		map_["font"] =  &TagConverter::font;
+		map_["u"] =  &TagConverter::underline;
+		map_["b"] =  &TagConverter::bold;
+		map_["sup"] =  &TagConverter::superscript;
+		map_["sub"] =  &TagConverter::subscript;
+		map_["root"] =  &TagConverter::ignore;
+		map_["xml"] =  &TagConverter::text;
+		map_["data"] =  &TagConverter::data;
+		map_["grib_info"] =  &TagConverter::grib;
+		map_["json_info"] =  &TagConverter::json;
+		map_["netcdf_info"] =  &TagConverter::netcdf;
+		map_["magics_title"] =  &TagConverter::magics;
+		map_["base_date"] =  &TagConverter::base_date;
+		map_["text"] =  &TagConverter::pass;
+		map_["box"] =  &TagConverter::pass;
+		map_["br"] =  &TagConverter::pass;
+	}
+	
+TagConverter::~TagConverter() {}
+
+void TagConverter::visit(const XmlNode& node)
+{		
+	map<string, ConvertFunction>::iterator function = map_.find(node.name());		
+	if ( function != map_.end())  (this->*function->second)(node);			
+	else {
+		MagLog::error() << "Html Text handler: unknown tag [" << node.name() << "]" << endl;
+		MagLog::broadcast();
+	}
+	    
+	// continue the visit...
+		
+}
+void TagConverter::ignore(const XmlNode&) {}
+void TagConverter::encoding(const string& encoding) { encoding_ = encoding; }
+void TagConverter::text(const XmlNode& node) { 
+	push();
+	node.visit(*this);
+
+}
+
+void TagConverter::grib(const XmlNode& node) { 
+	//MagLog::dev()<< "checking grib!" << endl;
+	push();
+	const map<string, string>& attributes = node.attributes();
+	string key =  ( attributes.find("id") != attributes.end() ) ? attributes.find("id")->second : ""; 
+	if (attributes.find("key") != attributes.end() ) {
+		string result = owner_.get("grib"+key, attributes.find("key")->second);
+		if ( result.empty() ) {
+			if ( automatic_ == 1 )
+				automatic_ = 0;
+		}
+		else {
+			if ( automatic_ == 0 )
+				automatic_ = 1;
+			automatic_++;
+			check(owner_.get("grib"+key, attributes.find("key")->second));
+		}
+	}
+	if (attributes.find("definition") != attributes.end() ) {			
+		check(owner_.get("grib"+key, attributes.find("definition")->second)); 
+	}
+	node.visit(*this);
+	pop();	
+	
+	font_ = top().font();
+	elevation_ = top().elevation();
+}
+
+void TagConverter::json(const XmlNode& node) {
+
+	push();
+	const map<string, string>& attributes = node.attributes();
+	if (attributes.find("key") != attributes.end() ) {
+		string result = owner_.get("json", attributes.find("key")->second);
+		check(owner_.get("json", attributes.find("key")->second));
+	}
+	node.visit(*this);
+	pop();
+
+	font_ = top().font();
+	elevation_ = top().elevation();
+}
+
+void TagConverter::netcdf(const XmlNode& node) {
+
+	push();
+	const map<string, string>& attributes = node.attributes();
+	string key =  ( attributes.find("variable") != attributes.end() ) ? attributes.find("variable")->second : "";
+	if (attributes.find("attribute") != attributes.end() ) {
+		string result = owner_.get("netcdf"+key, attributes.find("key")->second);
+		if ( result.empty() ) {
+			if ( automatic_ == 1 )
+				automatic_ = 0;
+		}
+		else {
+			if ( automatic_ == 0 )
+				automatic_ = 1;
+			automatic_++;
+			check(owner_.get("netcdf"+key, attributes.find("key")->second));
+		}
+	}
+	if (attributes.find("definition") != attributes.end() ) {
+		check(owner_.get("netcdf"+key, attributes.find("definition")->second));
+	}
+	node.visit(*this);
+	pop();
+
+	font_ = top().font();
+	elevation_ = top().elevation();
+}
+
+void TagConverter::pass(const XmlNode& node) { 
+	
+	
+	node.visit(*this);
+	check(node.data()); 
+
+	
+}
+void TagConverter::magics(const XmlNode& node) { 
+	//MagLog::dev()<< "checking magics title!" << endl;
+	push();		
+	const map<string, string>& attributes = node.attributes();
+	string key =  ( attributes.find("id") != attributes.end() ) ? attributes.find("id")->second : ""; 
+    
+    check(owner_.get("grib"+key, "magics")); 
+ 
+	node.visit(*this);
+	pop();	
+	
+	font_ = top().font();
+	elevation_ = top().elevation();
+}
+
+void TagConverter::base_date(const XmlNode& node) { 
+	push();		
+    
+    check(owner_.get("grib", "base_date")); 
+ 
+	node.visit(*this);
+	pop();	
+	
+	font_ = top().font();
+	elevation_ = top().elevation();
+}
+
+void TagConverter::data(const XmlNode& node) { 
+	
+	
+	push();
+	const map<string, string>& attributes = node.attributes();
+	if ( attributes.find("data") != attributes.end() ) {
+		    string text = attributes.find("data")->second;
+		    if (!text.empty() ) {		
+		    	top().text(text);		
+		    	label_ += text;
+		    	text_->addNiceText(top());
+		    }
+	}
+	node.visit(*this);
+	pop();	
+	
+	font_ = top().font();
+	elevation_ = top().elevation();
+	
+}
+void TagConverter::font(const XmlNode& node) {
+	const map<string, string>& attributes = node.attributes();
+	
+	if ( attributes.find("colour") != attributes.end() ) {
+		MagLog::debug() << "set colour" << attributes.find("colour")->second << endl;
+		font_.colour(Colour(attributes.find("colour")->second));
+	}
+
+	if ( attributes.find("color") != attributes.end() ) {
+		MagLog::debug() << "set colour" << attributes.find("color")->second << endl;
+		font_.colour(Colour(attributes.find("color")->second));
+	}
+		
+	if ( attributes.find("size") != attributes.end() ) {		
+		font_.size(tonumber(attributes.find("size")->second));	
+		MagLog::debug() << "set size" << attributes.find("size")->second << endl;
+	}
+	
+	if ( attributes.find("style") != attributes.end() ) {		
+		font_.style(attributes.find("style")->second);	
+		MagLog::debug() << "set style" << attributes.find("style")->second << endl;
+	}
+	
+
+	node.visit(*this);
+	
+	
+	
+
+}
+
+void TagConverter::underline(const XmlNode& node) {
+	MagLog::debug() << "uderline" << endl;
+	font_.style("underlined");
+
+	node.visit(*this);
+
+}
+void TagConverter::push()
+{
+	NiceText nice = top();
+	nice.font(font_);
+	nice.elevation(elevation_);
+	stack<NiceText>::push(nice);
+}
+void TagConverter::bold(const XmlNode& node) {
+	MagLog::debug() << "bold" << endl;
+	font_.style("bold");		
+	node.visit(*this);
+
+}
+void TagConverter::superscript(const XmlNode& node) {
+	MagLog::debug() << "superscript" << endl;
+	elevation_ = SUPERSCRIPT;
+	node.visit(*this);
+}
+void TagConverter::subscript(const XmlNode& node) {
+	MagLog::debug() << "subcript" << endl;
+	elevation_ = SUBSCRIPT;
+	node.visit(*this);
+}
+void TagConverter::check(const string& text) {
+	
+
+	if (!text.empty() ) {		
+		TagConverter converter(owner_);
+		converter.font(font_);
+		converter.decode(text, text_);
+	}
+	
+
+	
+}
+
+void TagConverter::entities(ostream& out) 
+{
+	string path = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "entities.dtd";
+
+	try {
+		ifstream in(path.c_str());		
+		char c;
+		while(in.get(c))
+		{
+			out << c;
+		}
+		in.close();
+	}
+	catch (...) { 
+		MagLog::warning() << "Cannot find entities declaration : " << path << " [Ignore them]" << endl;
+	}
+}
+
+bool TagConverter::staticTag(const string& line)
+{
+	static vector<string> keys;
+	if ( keys.empty() ) {
+		keys.push_back("grib_info");
+		keys.push_back("netcdf_info");
+		keys.push_back("json_info");
+		keys.push_back("magics_title");
+	}
+	for ( vector<string> ::iterator key = keys.begin(); key !=keys. end(); ++key)  {
+		string meta = "<" + *key;
+		if ( line.find(meta) != string::npos ) 
+			  return false;
+	}
+	// No MetaTag found!
+	return true;
+}
+
+void TagConverter::decode(const string& line, Text* text)
+{
+	text_ = text;
+	elevation_ = NORMAL;
+	
+	NiceText nice;
+	nice.font(font_);
+	nice.elevation(elevation_);
+	stack<NiceText>::push(nice);
+	XmlReader parser(true);
+	XmlTree tree;	
+
+	ostringstream xml;
+	xml << "<?xml version='1.0' ?> \n";
+	entities(xml);
+	xml << "<xml> \n";
+	xml << line << "\n";
+	xml << "\n</xml>";
+	automatic_ = 1;
+	
+
+	if ( parser.decode(xml.str(), &tree)== 0) {		
+		tree.visit(*this);
+	}
+	else  {
+		label_ += line;
+		text_->addText(line, font_);
+	}	
+	if (automatic_ == 0 ) {
+		text->clear();
+	}
+
+	} 
+
+
diff --git a/src/basic/TagHandler.h b/src/basic/TagHandler.h
new file mode 100644
index 0000000..575c2d7
--- /dev/null
+++ b/src/basic/TagHandler.h
@@ -0,0 +1,105 @@
+/*! \file TagHandler.h
+    \brief Definition of the Template class TagHandler.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Mon 27-Oct-2008
+    
+    Changes:
+    
+*/
+
+#ifndef TagHandler_H
+#define TagHandler_H
+
+#include "magics.h"
+#include "XmlNode.h"
+#include "Text.h"
+
+
+namespace magics {
+
+class TagHandler {
+
+public:
+	TagHandler();
+	virtual ~TagHandler();
+	void update(const string&, const string&, const string&);		
+	string get(const string&, const string&);
+    void reset() { definitions_.erase(definitions_.begin(), definitions_.end()); }
+    virtual void addToTags(const string&, const string&) {}; 
+    
+    bool hasInfos() { return definitions_.empty() == false; }
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 typedef map<string, std::set<string> > DefList;
+	 map<string, DefList > definitions_;
+
+	 
+	 
+	 
+	 
+private:
+    //! Copy constructor - No copy allowed
+	TagHandler(const TagHandler&);
+    //! Overloaded << operator to copy - No copy allowed
+	TagHandler& operator=(const TagHandler&);
+	
+	     
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TagHandler& p)
+		{ p.print(s); return s; }
+
+};
+
+class TagConverter: public XmlNodeVisitor, public stack<NiceText>
+{
+public:
+	TagConverter(TagHandler& owner);	
+	~TagConverter();
+	void visit(const XmlNode&);
+	void ignore(const XmlNode&);
+	void encoding(const string& encoding);
+	void text(const XmlNode&);
+	
+	void grib(const XmlNode&);
+	void netcdf(const XmlNode&);
+	void pass(const XmlNode&);
+	
+	void font(const MagFont& font) { font_ = font; }
+	void magics(const XmlNode&);
+	void base_date(const XmlNode&);
+	void json(const XmlNode&);
+	void data(const XmlNode&);
+	void font(const XmlNode&);
+	void underline(const XmlNode&);
+	void push();
+	void bold(const XmlNode&);
+	void superscript(const XmlNode&);
+	void subscript(const XmlNode&);
+	void check(const string&);
+	void entities(ostream&);
+	void decode(const string& line, Text*);
+	const string& label() { return label_; }
+	bool staticTag(const string&);
+
+protected :
+    TagHandler& owner_;
+	typedef void (TagConverter::*ConvertFunction)(const XmlNode&);
+	map<string, ConvertFunction> map_;
+	MagFont       font_;
+	TextElevation elevation_;
+	string encoding_;
+	Text* text_; 
+	string label_;
+	int automatic_;
+	
+};
+
+
+
+} // namespace magics
+#endif
diff --git a/src/basic/TextVisitor.cc b/src/basic/TextVisitor.cc
new file mode 100644
index 0000000..c270e62
--- /dev/null
+++ b/src/basic/TextVisitor.cc
@@ -0,0 +1,682 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TextVisitor.cc
+    \brief Implementation of the Template class TextVisitor.
+
+    Magics Team - ECMWF 2007
+
+    Started: Tue 6-Mar-2007
+
+    Changes:
+
+ */
+
+
+
+#include "TextVisitor.h"
+#include "Text.h"
+#include "Dimension.h"
+#include "XmlReader.h"
+#include "AnimationRules.h"
+#include "Layer.h"
+#include "MagicsFormat.h"
+
+#include "MetaData.h"
+
+using namespace magics;
+
+/*!
+ \brief Method to relate C++ special characters with XML ones
+
+ \todo write one code to do so 
+
+ \sa PostScriptDriver.cc
+ */
+
+map<string, string> TextVisitor::tags_;
+
+
+
+
+
+
+
+TextVisitor::TextVisitor() :positional_(true)
+{
+
+	static int i = 0;
+	ostringstream n;
+	n << "TextVisitor" << i;
+	name(n.str());
+
+	layout_ = new Layout();
+	layout_->name(n.str());
+	i++;
+	current_ = layout_;
+
+	if (tags_.empty()) {
+		tags_["base_date"] = "grib_info  key='start-date' format='%Y-%m-%d %H:%M:00'";
+		tags_["valid_date"] = "grib_info  key='end-date' format='%A %d %B %Y at %H UTC'";
+	}
+}
+
+
+
+TextVisitor::~TextVisitor() 
+{
+}
+
+
+void TextVisitor::addToTags(const string& line, const string& entry) 
+{
+	add(line, new TextEntry(entry)); 
+}
+/*!
+ Class information are given to the output-stream.
+ */
+void TextVisitor::print(ostream& out)  const
+{
+	out << "TextVisitor[";
+	LayoutVisitor::print(out);
+	out << "]";
+}
+
+void TextVisitor::getReady()
+{	
+}
+
+
+void TextVisitor::visit(MetaDataVisitor& meta){
+	meta.add("magics.title", "\"" + label_ + "\"");
+
+}
+
+
+void  TextVisitor::visit() {
+
+	decode();
+	clear();
+
+	vector<double>::iterator ratio = height_ratios_.begin();
+	currentTexts_.clear();
+
+	for ( vector<string>::iterator line = lines_.begin(); line != lines_.end(); ++line) {
+		double font_size = font_size_;
+		if ( ratio !=  height_ratios_.end() ) {
+			font_size *= *ratio;
+			++ratio;
+		}
+		MagFont font(font_);
+		font.style(font_style_);
+		font.size(font_size);
+		font.colour(font_colour_->name());
+
+		TagConverter converter(*this);
+		converter.font(font);
+		if ( converter.staticTag(*line) ) {
+			Text* text = new Text();
+
+			converter.decode(*line, text);	
+			currentTexts_[*line].push_back(text);
+		}
+	}
+
+
+}
+
+void TextVisitor::visit(BasicSceneObject& parent)
+{
+
+	// Setup the information the automatic title if necessary!
+	decode();
+
+
+	TagHandler::reset();
+	bool automatic = false;
+	clear();
+	parent.visit(*this);
+
+	vector<string>::iterator line = lines_.begin();
+	map<string, vector<string> > lines;
+	vector<string> lineslist; ;
+
+	while ( line != lines_.end() )
+	{
+		lines.insert(make_pair(*line, vector<string>()));
+
+		if ( *line != "<magics_title/>" ) {
+			lines[*line].push_back(*line);
+			(*this)[*line].push_back(new TextEntry(*line));
+		}
+		else {
+			automatic = true;
+			map<string, vector<TextEntry* >  >::iterator key = find(*line);
+			if ( key != end() ) {
+				for (vector<TextEntry* >::iterator entry = key->second.begin(); entry !=  key->second.end(); ++entry)
+					lines[*line].push_back((*entry)->entry_);
+			}
+
+		}
+		++line;
+	}
+	if ( !automatic && !texts_.empty() ) {
+		// Nothing to do the text has already been created!
+		return;
+	}
+
+
+
+
+	vector<string>::reverse_iterator lend = lines_.rend();
+	vector<double>::reverse_iterator ratios = height_ratios_.rbegin();
+	currentTexts_.clear();
+
+	for (vector<string>::reverse_iterator line = lines_.rbegin(); line != lend; ++line)
+	{
+		double ratio =  ( ratios ==  height_ratios_.rend() ) ?  1 : *ratios;
+
+		if ( ratios != height_ratios_.rend() ) 	++ratios;
+		MagFont font(font_);
+		font.style(font_style_);
+		font.size(font_size_*ratio);
+		font.colour(font_colour_->name());
+		TagConverter converter(*this);
+		converter.font(font);
+		if ( converter.staticTag(*line) )
+			continue;
+		if ( !hasInfos() )
+			continue;
+		currentTexts_[*line] = vector<Text*>();
+		map<string,vector<TextEntry* >  >::iterator key = find(*line);
+		if ( key != end() ) {
+
+			for (vector<TextEntry*  >::reverse_iterator entry = key->second.rbegin(); entry !=  key->second.rend(); ++entry) {
+				Text* text = new Text();
+				converter.decode((*entry)->entry_, text);
+				if (text->noText()) {
+					delete text;
+					continue;
+				}
+				if ( currentTexts_.find(*line) == currentTexts_.end() )
+					currentTexts_[*line] = vector<Text*>();
+				currentTexts_[*line].push_back(text);
+			}
+		}
+
+
+	}
+
+}
+void TextVisitor::start()
+{
+
+	texts_.clear();
+}
+void TextVisitor::finish(BasicGraphicsObjectContainer& parent) 
+{
+	// Here we adjustt the position of the text...
+	newLayout();
+	parent.push_back(current_);
+
+	current_->blankIt();
+
+	double absheight = current_->absoluteHeight();
+
+	double height = (font_size_ /absheight)*100;
+	double last = (0.10/absheight)*100; //in %
+	double gap = height*1.2;
+
+
+
+
+	for (vector<Text*>::iterator text = texts_.begin(); text != texts_.end(); ++text)
+	{
+
+		// Calculate the position depending on the jsutification.
+		double x;
+		if (justification_ == MLEFT) x = .1; // 0.1% 
+		else if (justification_ == MRIGHT) x = 98.; //98 %
+		else x = 50.; 
+
+		(*text)->setJustification(justification_);
+		(*text)->setVerticalAlign(MBOTTOM);
+
+		gap = (*text)->noText() ?  height*1.2 : (((*text)->getFontMax()/absheight)*100)*1.2;
+		(*text)->push_back(PaperPoint(x, last)); // approximate position to be improved 
+
+		last += gap;
+
+		current_->push_back(*text);
+
+	}
+	current_->frameIt();
+
+}
+
+void TextVisitor::update(vector<Text*>& texts) 
+{
+
+
+
+	for (vector<Text*>::iterator text = texts.begin(); text != texts.end(); ++text)
+	{
+		texts_.push_back(*text);
+	}
+
+}
+
+
+struct TextHelper : public XmlNodeVisitor, public vector<string>
+{
+	TextHelper() {}
+	~TextHelper() {}
+
+	vector<string>::iterator begin()
+	{
+		push_back(current_.str());
+		return vector<string>::begin();
+	}
+
+	bool  empty()
+	{
+		return 	current_.str().empty();	
+	}
+
+	void visit(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "font") )
+			current_ << node << endl;
+		if ( magCompare(node.name(), "b") )
+			current_ << node << endl;
+		if ( magCompare(node.name(), "magics_title") )
+			current_ << node << endl;
+		if ( magCompare(node.name(), "grib_info") )
+			current_ << node << endl;
+		if ( magCompare(node.name(), "data") )
+			current_ << node << endl;
+
+		if (magCompare(node.name(), "br")) {
+			push_back(current_.str());
+			current_.seekp(ios_base::beg);
+			for (unsigned int n = 0; n < back().size(); n++)
+				current_ << " ";
+			current_.seekp(ios_base::beg);
+		}
+	}
+	ostringstream current_; 
+};
+
+void XmlTextVisitor::set(const XmlNode& node) 
+{ 
+	XmlNode view = node;
+	view.name("view");
+	XmlBasicNodeAttributes::set(view); 
+	TextVisitor::set(node);
+	TextHelper helper;
+	node.visit(helper);
+
+	if ( helper.empty() ) {
+		vector<string> lines;
+
+		lines.push_back(line1_);
+		lines.push_back(line2_);
+		lines.push_back(line3_);
+		lines.push_back(line4_);
+		lines.push_back(line5_);
+		lines.push_back(line6_);
+		lines.push_back(line7_);
+		lines.push_back(line8_);
+		lines.push_back(line9_);
+		lines.push_back(line10_);
+		for (int i = 0; i <count_; i++)
+			lines_.push_back(lines[i]);
+	}
+
+	for (TextHelper::const_iterator line = helper.begin(); line != helper.end(); ++line) {
+		lines_.push_back(*line);
+	}
+}
+
+void XmlTextVisitor::getReady()
+{
+	assert (BasicSceneObject::parent_);
+
+	Dimension bottom(bottom_, BasicSceneObject::parent_->absoluteWidth(), 0);
+	Dimension left(left_, BasicSceneObject::parent_->absoluteHeight(), 0);
+	Dimension width(XmlBasicNodeAttributes::width_, BasicSceneObject::parent_->absoluteWidth(), 100);
+	Dimension height(XmlBasicNodeAttributes::height_, BasicSceneObject::parent_->absoluteHeight(), 100);
+
+	Dimension mb(margin_bottom_, height.absolute(), 0);	
+	Dimension ml(margin_left_, width.absolute(), 5);
+	Dimension mr(margin_right_, width.absolute(), 5);
+	Dimension mt(margin_top_, height.absolute(), 0);
+
+	// We have to calculate the new x, y, width, height
+	const double xl = ml.percent()*width.absolute()*0.01;
+	const double xr = mr.percent()*width.absolute()*0.01;
+	const double yb = mb.percent()*height.absolute()*0.01;
+	const double yt = mt.percent()*height.absolute()*0.01;
+
+	const double text_x =  left.percent()  + xl *100./BasicSceneObject::parent_->absoluteWidth();
+	const double text_y =  bottom.percent()+ yb *100./BasicSceneObject::parent_->absoluteHeight();;
+
+	double text_width  = width.percent();
+	double text_height = height.percent();
+
+	if ( ( text_height + text_y ) > 100 ) 
+		text_height = 100 - text_y ;
+	if ( ( text_width + text_x ) > 100 ) 
+		text_width = 100 - text_x ;
+
+	this->x(text_x);
+	this->y(text_y);
+	this->width (text_width  - xr *100/BasicSceneObject::parent_->absoluteWidth());
+	this->height(text_height - yt *100/BasicSceneObject::parent_->absoluteHeight());
+
+	// adjust the font size!...	
+	Dimension text(font_dimension_,height.absolute(), 10);
+	font_size_ = text.absolute();
+
+	layout_->display( XmlBasicNodeAttributes::display_); 
+	layout_->frame(TextVisitorAttributes::blanking_, TextVisitorAttributes::border_, *TextVisitorAttributes::border_colour_, M_SOLID, 1);
+
+	}
+
+FortranTextVisitor::FortranTextVisitor()
+{
+}
+
+void XmlTextVisitor::decode()
+{
+}
+
+
+void FortranTextVisitor::decode()
+{
+	if (lines_.empty()) {
+
+		stringarray lines;
+		vector<double> ratios;
+
+		interpret(line1_, lines);
+		ratios.push_back(height_ratio_1_);
+		interpret(line2_, lines);
+		ratios.push_back(height_ratio_2_);
+		interpret(line3_, lines);
+		ratios.push_back(height_ratio_3_);
+		interpret(line4_, lines);
+		ratios.push_back(height_ratio_4_);
+		interpret(line5_, lines);
+		ratios.push_back(height_ratio_5_);
+		interpret(line6_, lines);
+		ratios.push_back(height_ratio_6_);
+		interpret(line7_, lines);
+		ratios.push_back(height_ratio_7_);
+		interpret(line8_, lines);
+		ratios.push_back(height_ratio_8_);
+		interpret(line9_, lines);
+		ratios.push_back(height_ratio_9_);
+		interpret(line10_, lines);
+		ratios.push_back(height_ratio_10_);
+
+		if (first_ > 10) {
+			MagLog::warning() << "Invalid value for text_first_line[" << first_ << "] : reset to 1 " << "\n";
+			first_ = 1;
+		}
+
+		if ( count_ > 10) {
+			MagLog::warning() << "Invalid value for text_count_line[" << first_ << "]  reset to  " << count_ << "\n";
+			count_ = 10 - first_ + 1;
+		}
+
+		int last = first_ + count_;
+		if ( last > 10) {
+			count_ = 10 - first_ + 1;
+			MagLog::warning() << "Invalid value (" << last << ") for text_first_line[" << first_ << "] and  text_count_line[" << count_ << "] reset\n";
+			last  = 10;
+		}
+
+		for (int i = 0; i < count_; i++) {
+			if (lines[first_+i-1].empty())
+				lines_.push_back("<magics_title/>"); // Ask for an automatic title...
+			else
+				lines_.push_back(lines[first_+i-1]);
+			height_ratios_.push_back(ratios[first_+i-1]);
+		}
+	}
+
+}
+
+
+void FortranTextVisitor::interpret(string& line, stringarray& lines)
+{
+	map<string, string> getString;
+	map<string, int> getInt;
+	map<string, double> getFloat;
+
+	if ( getString.empty() ) {
+		getString["text_character_1"] = character1_;
+		getString["text_character_2"] = character2_;
+		getString["text_character_3"] = character3_;
+		getString["text_character_4"] = character4_;
+		getString["text_character_5"] = character5_;
+		getString["text_character_6"] = character6_;
+		getString["text_character_7"] = character7_;
+		getString["text_character_8"] = character8_;
+		getString["text_character_9"] = character9_;
+		getString["text_character_10"] = character10_;
+	}
+	if ( getFloat.empty() ) {
+		getFloat["text_real_1"] = real1_;
+		getFloat["text_real_2"] = real2_;
+		getFloat["text_real_3"] = real3_;
+		getFloat["text_real_4"] = real4_;
+		getFloat["text_real_5"] = real5_;
+		getFloat["text_real_6"] = real6_;
+		getFloat["text_real_7"] = real7_;
+		getFloat["text_real_8"] = real8_;
+		getFloat["text_real_9"] = real9_;
+		getFloat["text_real_10"] = real10_;
+	}
+	if ( getInt.empty() ) {
+		getInt["text_integer_1"] = integer1_;
+		getInt["text_integer_2"] = integer2_;
+		getInt["text_integer_3"] = integer3_;
+		getInt["text_integer_4"] = integer4_;
+		getInt["text_integer_5"] = integer5_;
+		getInt["text_integer_6"] = integer6_;
+		getInt["text_integer_7"] = integer7_;
+		getInt["text_integer_8"] = integer8_;
+		getInt["text_integer_9"] = integer9_;
+		getInt["text_integer_10"] = integer10_;
+	}
+
+	string key, format;
+	int where;
+	int howmany;
+
+	vector<KeyInfo> keys;
+
+	extract(line, keys);
+
+	for (vector<KeyInfo>::iterator ikey = keys.begin(); ikey != keys.end(); ++ikey ) {
+		string key = ikey->key_;
+		string format = ikey->format_;
+
+		int where = line.find(ikey->what_);
+
+		int howmany = ikey->what_.size();
+
+
+		// Try to find the key in the string keys
+		map<string, string>::const_iterator text = getString.find(key);
+		if ( text != getString.end() ) {
+			line.replace(where, howmany, text->second);
+		}
+
+
+		//  Try to find the key in the integer keys and apply the Format!
+		map<string, int>::const_iterator integer = getInt.find(key);
+		if ( integer != getInt.end() ) {
+			// Apply format
+			ostringstream value;
+			value << MagicsFormat(format, integer->second);
+			line.replace(where, howmany, value.str());
+		}
+
+		//  Try to find the key in the real keys and apply the Format!
+		//  Try to find the key in the integer keys and apply the Format!
+		map<string, double>::const_iterator real = getFloat.find(key);
+		if ( real != getFloat.end() ) {
+			// Apply format
+			ostringstream value;
+			value << MagicsFormat(format, real->second);
+			line.replace(where, howmany, value.str());
+		}
+	}
+
+	if (html_) {
+		for (map<string, string>::iterator tag = tags_.begin(); tag != tags_.end(); ++tag) {
+			size_t pos = line.find(tag->first);
+			if ( pos != string::npos ) 
+				line.replace(pos, tag->first.length(), tag->second);
+		}
+	}
+	lines.push_back( line );
+}
+
+
+FortranAutomaticTextVisitor::FortranAutomaticTextVisitor()
+{
+	positional_ = false;
+}
+
+
+void FortranAutomaticTextVisitor::getReady()
+{
+	decode();
+	MagLog::dev() << "FortranAutomaticTextVisitor::getReady()" << endl;
+
+	Dimension text(font_dimension_, 1, 10);
+	font_size_ = text.absolute();
+	layout_->frame(blanking_, border_, *border_colour_, border_line_style_, border_thickness_);
+}
+
+
+FortranPositionalTextVisitor::FortranPositionalTextVisitor()
+{
+}
+
+void FortranPositionalTextVisitor::getReady()
+{
+	decode();
+	positional_ = true;
+
+	layout_->x(adjustDimension(TextVisitorAttributes::x_, 7.5, BasicPositionalObject::absoluteWidth()));
+	layout_->y( adjustDimension(TextVisitorAttributes::y_, 5.,BasicPositionalObject::absoluteHeight()));
+	layout_->width(adjustDimension(TextVisitorAttributes::width_, 50., BasicPositionalObject::absoluteWidth()));
+	layout_->height(adjustDimension(TextVisitorAttributes::height_, 20., BasicPositionalObject::absoluteHeight()));
+	Dimension text(font_dimension_, absoluteHeight(), 10);
+	font_size_ = text.absolute();
+	layout_->frame(TextVisitorAttributes::blanking_, TextVisitorAttributes::border_, *border_colour_, border_line_style_, border_thickness_);
+}
+
+
+XmlTextVisitor::XmlTextVisitor() 
+{
+	//displayType_ = BLOCK;
+	//border_ = false;
+	//blanking_= false;
+	//lines_.push_back("<magics_title/>");
+}
+
+void TextVisitor::titles(vector<string>& titles)
+{	
+	//prepare();	
+	for ( vector<string>::const_iterator line = lines_.begin(); line != lines_.end(); ++line)
+		titles.push_back(*line);
+}
+
+
+void TextVisitor::add(const string& line, TextEntry* entry)
+{
+	map<string, vector<TextEntry* >  >::iterator key = find(line);
+	if ( key == end() ) {
+		map<string, vector<TextEntry* >  >::insert(make_pair(line, vector<TextEntry* >()) );
+		key = find(line);
+	}
+	key->second.push_back(entry);
+}
+
+
+void TextVisitor::extract(const string& line, vector<KeyInfo>& keys)
+{
+	int count = 0;
+
+	char escape = *(parameter_escape_.begin());
+	bool special = false;
+
+	KeyInfo key;
+	key.format_= "(automatic)";
+
+
+	string::const_iterator x = line.begin();
+	while ( x != line.end() ) {
+		if (*x == escape)  {
+			if ( special ) { // end of the instruuction
+
+				string::iterator k = key.what_.begin();
+				// Try to extract the format!
+				while ( k != key.what_.end() ) {
+
+					if ( *k == '(' )  {
+						key.format_.clear();
+						while ( k != key.what_.end() ) {
+							key.format_.push_back(*k);
+							if ( *k == ')' )
+								break;
+							++k;
+						}
+					}
+					else
+						key.key_.push_back(*k);
+					++k;
+				}
+
+				key.key_= lowerCase(key.key_);
+				key.what_= escape + key.what_ + escape;
+				keys.push_back(key);
+				key = KeyInfo();
+				key.format_= "(automatic)";
+			}
+			special = !special;
+		}
+		else {
+			if ( special)
+				key.what_.push_back(*x);
+		}
+		++x;
+	}
+}
+
+void TextVisitor::addAutomaticTitle(const string& text)
+{
+	update("grib", "magics", text);
+	add("<magics_title/>", new TextEntry(text));
+}
diff --git a/src/basic/TextVisitor.h b/src/basic/TextVisitor.h
new file mode 100644
index 0000000..2ceae4f
--- /dev/null
+++ b/src/basic/TextVisitor.h
@@ -0,0 +1,175 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TextVisitor.h
+    \brief Definition of the Template class TextNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef TextVisitor_H
+#define TextVisitor_H
+
+#include "magics.h"
+
+#include "SceneVisitor.h"
+#include "XmlBasicNodeAttributes.h"
+#include "TextVisitorAttributes.h"
+#include "TagHandler.h"
+
+namespace magics {
+
+class TextEntry {
+public: 
+    TextEntry(const string entry = "") : entry_(entry) {}
+    ~TextEntry() {}
+    string entry();
+    string entry_;
+    void add(const string& info ) {
+        entry_ += info;
+    }
+};
+
+struct KeyInfo
+{
+	string key_;
+	string what_;
+	string format_;
+
+};
+
+class TextVisitor: public TextVisitorAttributes, 
+	public TagHandler,
+	public LayoutVisitor, 
+	public BasicPositionalObject,
+	public map<string, vector<TextEntry* > >
+{
+
+public:
+	TextVisitor();
+	virtual ~TextVisitor();
+	
+	TextVisitor* clone();
+	void add(const string& line, TextEntry* entry);
+	void add(TextEntry* entry) { add("<magics_title/>", entry); }
+	void addAutomaticTitle(const string&);
+	
+	
+	void addToTags(const string&,  const string&);
+			
+    virtual void titles(vector<string>&);
+	virtual Layout& layout() const { return LayoutVisitor::layout(); }
+	virtual Layout* layoutPtr() const { return LayoutVisitor::layoutPtr(); }
+	
+
+
+    map<string, vector<Text*> > texts() { return currentTexts_; }
+    void visit();
+    void visit(BasicSceneObject&);
+    void finish(BasicGraphicsObjectContainer&);
+    void update(vector<Text*>&);
+    void start();
+    
+    void visit(MetaDataVisitor&);
+    bool positional() const { return positional_; } 
+    virtual void getReady();
+    void update(const string& family, const string& definition, const string& value)
+    	{ TagHandler::update(family, definition, value); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	
+	 virtual void decode() {}
+	 
+	bool positional_;
+	double font_size_;
+	
+	 static map<string, string> tags_;
+	 void extract(const string&, vector<KeyInfo>&);
+
+    
+    void set(const map<string, string>& map ) { TextVisitorAttributes::set(map); }
+	void set(const XmlNode& node ) { TextVisitorAttributes::set(node); }
+	string label_;
+	mutable vector<Text*> texts_;
+	mutable map<string, vector<Text*> > currentTexts_;
+	VectorOfPointers<vector<TextEntry* > > currentLine_;
+	
+     
+private:
+    //! Copy constructor - No copy allowed
+	TextVisitor(const TextVisitor&);
+    //! Overloaded << operator to copy - No copy allowed
+	TextVisitor& operator=(const TextVisitor&);
+
+
+};
+
+class XmlTextVisitor : public TextVisitor, public XmlBasicNodeAttributes
+{
+public:
+	XmlTextVisitor();
+	~XmlTextVisitor() {}
+	void set(const XmlNode&);
+	void getReady();
+	void decode();
+};
+
+class FortranTextVisitor : public TextVisitor
+{
+public:
+	FortranTextVisitor();
+	~FortranTextVisitor() {}
+protected:
+    void decode();
+	void interpret(string&, stringarray&);
+};
+
+class FortranAutomaticTextVisitor : public FortranTextVisitor
+{
+public:
+	FortranAutomaticTextVisitor();
+	~FortranAutomaticTextVisitor() {}
+	void getReady();	
+	
+	 
+};
+
+
+class FortranPositionalTextVisitor : public FortranTextVisitor
+{
+public:
+	FortranPositionalTextVisitor();
+	~FortranPositionalTextVisitor() {}
+	void getReady();	
+};
+/*
+class MvTextVisitor : 
+{
+	MvTextVisitor();
+	~MvTextVisitor()
+		
+}
+*/
+} // namespace magics
+#endif
diff --git a/src/basic/ThreadNode.h b/src/basic/ThreadNode.h
new file mode 100644
index 0000000..4231279
--- /dev/null
+++ b/src/basic/ThreadNode.h
@@ -0,0 +1,44 @@
+/*! \file ThreadNode.h
+    \brief Definition of the Template class ThreadNode.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Tue 23-Sep-2008
+    
+    Changes:
+    
+*/
+
+#ifndef ThreadNode_H
+#define ThreadNode_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+
+namespace magics {
+
+class ThreadNode: public BasicSceneObject {
+
+public:
+	ThreadNode();
+	virtual ~ThreadNode();
+	
+	void visit(BasicGraphicsObjectContainer&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ThreadNode(const ThreadNode&);
+    //! Overloaded << operator to copy - No copy allowed
+	ThreadNode& operator=(const ThreadNode&);
+
+
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/ViewNode.cc b/src/basic/ViewNode.cc
new file mode 100644
index 0000000..e224efa
--- /dev/null
+++ b/src/basic/ViewNode.cc
@@ -0,0 +1,604 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ViewNode.cc
+    \brief Implementation of the Template class ViewNode.
+     
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+
+*/
+
+#include "ViewNode.h"
+#include "Transformation.h"
+#include "Dimension.h"
+#include "Layout.h"
+#include "Layer.h"
+
+#include "SceneVisitor.h"
+#include "LegendVisitor.h"
+#include "TextVisitor.h"
+#include "MetaData.h"
+
+#include "HistoVisitor.h"
+
+#include "AnimationRules.h"
+
+using namespace magics;
+
+
+ViewNode::ViewNode() : viewTransformation_(0), animation_("basic"), vaxis_(2.), haxis_(1.),  rules_(0), legend_(0)
+{
+	static int i = 0;
+	ostringstream n;
+	n << "ViewNode" << i;
+	name_ = n.str();
+	i++;
+	layout_ = new Layout();
+	layout_->name(name_);
+} 
+
+
+ViewNode::~ViewNode() 
+{
+	for ( vector<LayoutVisitor*>::iterator  component = components_.begin(); component != components_.end(); ++component) {
+		delete *component;
+		*component = 0;
+	}
+	components_.clear();
+}
+
+void ViewNode::text(TextVisitor* text)
+{
+	texts_.push_back(text);
+}
+
+void ViewNode::legend(LegendVisitor* legend)
+{
+	legend_ = legend;
+}
+
+void ViewNode::visit(MetaDataVisitor& metadata)
+{
+	double top = 0;
+	double left = 0;
+	double width = 200;
+	double height = 100;
+
+	drawing_->layout().getDriverInfo(left, top, width, height);
+
+    // width and height are the dimensions of the layout!
+
+
+	double imgwidth = width * 100 / (100-drawing_left_-drawing_right_);
+	double imgheight = height * 100 / (100-drawing_top_-drawing_bottom_);
+
+
+
+	viewTransformation_->visit(metadata, left, top, imgwidth, imgheight, width, height);
+
+	BasicSceneObject::visit(metadata);
+	for (vector<TextVisitor*>::iterator text = texts_.begin(); text != texts_.end(); ++text ) 
+			(*text)->visit(metadata);
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ViewNode::print(ostream& out)  const
+{
+	out << "ViewNode[";
+	out << "]";
+}
+
+void ViewNode::getReady()
+{
+	MagLog::dev() << " ViewNode::getReady() \n";
+	BasicSceneObject::getReady();
+}
+
+void ViewNode::visit(PreviewVisitor& preview) 
+{
+	preview.minX(viewTransformation_->getMinPCX());
+	preview.maxX(viewTransformation_->getMaxPCX());
+	preview.minY(viewTransformation_->getMinPCY());
+	preview.maxY(viewTransformation_->getMaxPCY());
+
+	dispatch(preview);
+}
+
+void ViewNode::visit(HistoVisitor& histo) 
+{
+	dispatch(histo);
+}
+
+
+
+
+
+void ViewNode::prepareLayout(SceneLayer& tree)
+{
+
+	updateLayout();
+	LayoutHelper helper;
+	components_.clear();
+	drawing_= new DrawingVisitor();
+
+	const double width  = 100-drawing_left_-drawing_right_;
+	const double height = 100-drawing_top_-drawing_bottom_;
+	double vaxis  = 100/absoluteWidth() *vaxis_;
+	if ( drawing_left_ - vaxis < 0 ) {
+		vaxis = drawing_left_*0.80;
+		MagLog::info() << "Automatically reduce the with of the vertical axis box to fit in the page" << endl;
+	}
+
+	drawing_->transformation(viewTransformation_);
+		drawing_->y(drawing_bottom_);
+		drawing_->x(drawing_left_);
+		drawing_->height(height);
+		drawing_->width(width);
+		drawing_->id(id_);
+		drawing_->widthResolution(widthResolution()*width/100);
+		drawing_->heightResolution(heightResolution()*width/100);
+		drawing_->zoomable(true);
+		drawing_->zoomLevels(zoomLevels_);
+		drawing_->zoomCurrentLevel(zoomCurrentLevel_);
+		drawing_->frame(*layout_);
+		drawing_->frameIt();
+	components_.push_back(drawing_);
+	helper.add(drawing_);
+
+	// Then the axis!
+	leftAxis_ = new LeftAxisVisitor(*drawing_);
+		leftAxis_->width(vaxis);
+		leftAxis_->frameIt();
+	components_.push_back(leftAxis_);
+	helper.attachLeft(leftAxis_);
+
+	rightAxis_ = new RightAxisVisitor(*drawing_);
+		rightAxis_->width(vaxis);
+		rightAxis_->frameIt();
+	helper.attachRight(rightAxis_);
+	components_.push_back(rightAxis_);
+
+	double topaxis  = (viewTransformation_->needTopAxis() ) ? haxis_ : 0.1;
+	topaxis= 100/absoluteHeight()*topaxis;
+	double bottomaxis= 100/absoluteHeight()*haxis_;
+
+	topAxis_ = new TopAxisVisitor(*drawing_);
+	topAxis_->height(topaxis);
+	topAxis_->frameIt();
+	helper.attachTop(topAxis_);
+	components_.push_back(topAxis_);
+	helper.add(topAxis_);
+
+
+
+	bottomAxis_ = new BottomAxisVisitor(*drawing_);
+		bottomAxis_->height(bottomaxis);
+		bottomAxis_->frameIt();
+	components_.push_back(bottomAxis_);
+	helper.attachBottom(bottomAxis_);
+	helper.add(leftAxis_);
+	helper.add(rightAxis_);
+		
+	if ( legend_)
+	{
+		tree.legend(legend_);
+		if ( !legend_->positional())
+		{
+			legend_->height(5);
+			helper.attachTop(legend_);
+			legend_->x(drawing_left_);
+			legend_->width(100-drawing_left_-drawing_right_);
+			helper.add(legend_);
+			legend_->getReady();
+		}
+		else
+		{
+			((BasicSceneObject*)legend_)->parent((BasicSceneObject*)this);
+			legend_->getReady();
+		}
+		components_.push_back(legend_);
+	}
+
+	for (vector<TextVisitor*>::iterator text = texts_.begin(); text != texts_.end(); ++text)
+	{
+		tree.text(*text);
+
+		if ( !(*text)->positional() )
+		{
+			(*text)->height(15);
+			helper.attachTop((*text));
+			(*text)->x(drawing_left_);
+			(*text)->width(100-drawing_left_-drawing_right_);
+			(*text)->getReady();
+		}
+		else {
+			((BasicSceneObject*)(*text))->parent((BasicSceneObject*)this);
+			(*text)->getReady();
+		}
+	}
+}
+
+
+
+void ViewNode::copy(const ViewNode& other)
+{
+	viewTransformation_ = other.viewTransformation_;
+	drawing_bottom_ = other.drawing_bottom_;
+	drawing_top_ = other.drawing_top_;
+	drawing_left_ = other.drawing_left_;
+	drawing_right_ = other.drawing_right_;
+	layout_->frame(*other.layout_);
+}
+
+
+
+void ViewNode::visit(SceneLayer& tree)
+{
+	MagLog::dev() << " ViewNode::visit(GraphicsList&) \n" << endl;
+	viewTransformation_->init();
+	BasicSceneObject::visit(*viewTransformation_); // to set up the automatic style for mapping!
+
+	// drawing_->layout().blankIt();
+	// First the info about the animation overlay! 
+	// Basic instantiation of the Animation rules...
+	
+	if (!rules_) {
+		rules_ = MagTranslator<string, AnimationRules>()(lowerCase(animation_));
+		BasicSceneObject::visit(*rules_);
+	}
+
+	tree.rules(rules_);
+	// Here we checkeing for the legend!
+	bool legend = false;
+	for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item)  {
+			legend = (*item)->needLegend();
+			if ( legend ) break;
+	}
+
+	if ( !legend ) {
+		legend_ = 0;
+	}
+	
+	//Here we have the steps! 	
+	prepareLayout(tree);	
+	if ( items_.empty() )
+	{
+		push_back(new EmptySceneObject() );
+	}
+	for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item)  {
+		(*item)->visit(tree, components_);
+	}
+	if ( drawing_->layoutPtr() )
+	{
+		drawing_->layout().frameIt();
+	}
+
+	if( mode() == interactif )
+	{
+		PreviewVisitor* preview = new PreviewVisitor();
+		tree.push_back(preview);
+
+		preview->transformation(viewTransformation_);
+		preview->height(100-drawing_top_-drawing_bottom_);
+		preview->width(100-drawing_left_-drawing_right_);
+		preview->visit(*this);		
+	}
+	if( mode() == basic || mode() == paper) // trial for batch release in Metview
+	{
+		// We do not need the data animore we clean!
+		for ( vector<BasicSceneObject*>::iterator item = items_.begin(); item != items_.end(); ++item)  {
+			(*item)->release();
+
+		}
+	}
+}
+
+
+
+XmlViewNode::XmlViewNode()
+{
+	//displayType_ = INLINE;
+}
+
+void XmlViewNode::updateLayout()
+{
+//	double width    = 100 - drawing_right_ - drawing_left_;
+//	double height   = 100 - drawing_top_ - drawing_bottom_;
+	
+	drawing_bottom_ = ((drawing_bottom_* layout_->height())/100) + layout_->y();
+	drawing_left_   = ((drawing_left_* layout_->width())/100 ) + layout_->x();
+	double right = 100 - layout_->width() - layout_->x();
+	double top = 100 - layout_->height() - layout_->y();
+	drawing_right_  = ((drawing_right_* layout_->width())/100) + right ;
+	drawing_top_    = ((drawing_top_* layout_->height())/100 ) + top;
+	
+	layout_->x(0);
+	layout_->y(0);
+	layout_->width(100);
+	layout_->height(100);
+}
+
+
+XmlViewNode::~XmlViewNode()
+{
+}
+
+
+void XmlViewNode::getReady()
+{
+	assert (parent_);
+	viewTransformation_ = XmlViewNodeAttributes::transformation_.get();
+
+	Dimension bottom(bottom_, parent_->absoluteHeight(), 0);
+	Dimension left(left_, parent_->absoluteWidth(), 0);
+	Dimension width(XmlBasicNodeAttributes::width_, parent_->absoluteWidth(), 100);
+	Dimension height(XmlBasicNodeAttributes::height_, parent_->absoluteHeight(), 100);
+
+	Dimension mb(margin_bottom_, height.absolute(), 5);
+	Dimension ml(margin_left_, width.absolute(), 7.5);
+	Dimension mr(margin_right_, width.absolute(), 7.5);
+	Dimension mt(margin_top_, height.absolute(), 10);
+
+	drawing_bottom_ =mb.percent();
+	drawing_left_ = ml.percent();
+	
+
+	double wab =  width.absolute()  - mr.absolute() - ml.absolute();
+	double hab =  height.absolute()  - mt.absolute() - mb.absolute();
+	vaxis_ = 1.;
+	haxis_ = 1.;
+	double waa = wab;
+	double haa = hab;
+//	MagLog::dev() << "befor aspect ratio -->[" << waa << ", " << haa << "]" << endl;
+	MagLog::dev() << "after aspect ratio -->[" << waa << ", " << haa << "]" << endl; 
+
+	// could be usefull if we want to add the option compressed layout! 
+	//double w1 = (waa + mr.absolute() + ml.absolute()) / absoluteWidth() *100;
+	//double h1 = (haa +  mt.absolute() + mb.absolute()) / absoluteHeight() *100;
+	
+	double w2 = 100;
+	double h2 =100;
+	
+	if ( fitted_  == "expand" )
+	{
+		viewTransformation_->fill(waa, haa);
+		absoluteRootHeight(haa);
+		absoluteRootWidth(waa); 
+	}
+	if ( fitted_  == "crop" )
+	{
+		viewTransformation_->aspectRatio(waa, haa);
+		absoluteRootWidth(waa); 
+		absoluteRootHeight(haa);
+	}
+	else
+	{
+		viewTransformation_->aspectRatio(waa, haa);
+		w2 = waa / width.absolute() *100;
+		h2 = haa / height.absolute() *100;
+	}
+
+	drawing_top_ = 100 - drawing_bottom_ - h2;	
+	drawing_right_ = 100 - drawing_left_- w2;
+	
+
+	layout_->x(left.percent());
+	layout_->y(bottom.percent());
+	layout_->width(width.percent());
+	layout_->height(height.percent());
+	
+	layout_->display(display_);	
+	layout_->frame(true, border_, *border_colour_, border_style_, border_thickness_);
+
+	BasicSceneObject::getReady();
+}
+void ViewNode::visit(MetaDataCollector&) {
+
+}
+
+void XmlViewNode::print(ostream&) const
+{
+}
+
+
+FortranViewNode::FortranViewNode()
+{
+}
+
+
+FortranViewNode::~FortranViewNode()
+{
+}
+
+
+#define undef(x) x ==-1
+
+class AdjustHelper
+{
+public:
+	AdjustHelper(double top, double bottom, double height, double parent) : 
+		top_(top), bottom_(bottom), height_(height), parent_(parent) {}
+	~AdjustHelper() {}
+
+	void operator()(double& top, double& bottom, double& height)
+	{
+		if ( undef(top))
+		{
+			if ( undef(bottom) )
+			{
+				if ( undef(height) ) {
+					height = height_;
+					bottom = bottom_;
+					top = top_;
+				}
+				else { // we adjust to the top!
+					top = top_;
+					height = height / parent_ *100;
+					double diff = height_ - height;
+					if ( diff < 0 ) {
+						// we try to reduce the top margin... 
+						top += diff;
+						if ( top < 0) {
+							//we reduce the height..
+							height = height_;
+							top = top_;
+						}
+
+					}
+					bottom = 100-top-height;
+				}
+			}
+			else { // bottom is defined
+				if ( undef(height) ) {
+					bottom = bottom / parent_ *100;
+					top = top_;
+					height=100-bottom-top;
+				}
+				else { // we adjust to the top!
+					bottom = bottom / parent_ *100;
+					height=height / parent_ *100;
+					top=100 -height-bottom;
+				}			
+			} 
+		}
+		else { // Top is defined 
+			if ( undef(bottom) )
+			{
+				if ( undef(height) ) {
+					top = top / parent_*100;
+					bottom = bottom_;
+					height = 100-top-bottom;
+				}
+				else {
+					top = top / parent_ *100;
+					height = height / parent_ *100;
+					bottom = 100 -top-height;
+				}
+			}
+			else { // bottom is defined
+				if ( undef(height) ) {
+					 top = top / parent_ *100;
+					 bottom = bottom / parent_ *100;
+					 height=100-bottom-top;
+				}
+				else {
+					top = top / parent_ *100;
+					bottom = bottom / parent_ *100;
+					height=height / parent_ *100;
+				}
+			}
+		}
+	}
+
+protected:
+	double top_;
+	double bottom_;
+	double height_;
+	double parent_;
+};
+
+void FortranViewNode::getReady()
+{
+	assert (parent_);
+	
+	viewTransformation_ = FortranViewNodeAttributes::transformation_.get();
+	viewTransformation_->setDefinition(json_);
+
+//	MagLog::dev()<< *viewTransformation_ << endl;
+	double left =  FortranViewNodeAttributes::left_;
+	double right =  FortranViewNodeAttributes::right_;
+	double top =  FortranViewNodeAttributes::top_;
+	double bottom =  FortranViewNodeAttributes::bottom_;
+	double width = FortranViewNodeAttributes::width_;	
+	double height = FortranViewNodeAttributes::height_;
+	animation_ = overlay_;
+	
+	AdjustHelper vertical(20, 5, 75,  parent_->absoluteHeight());
+	AdjustHelper horizontal(5, 5, 90,  parent_->absoluteWidth());
+	
+	vertical(top, bottom, height);
+	horizontal(left, right, width);
+	
+	double abswidth = width * absoluteWidth()  / 100;
+	double absheight =  height * absoluteHeight()  / 100;
+	double absx = left * absoluteWidth()  / 100;
+	double absy =  bottom * absoluteHeight()  / 100;
+	
+	MagLog::dev() << "[" << abswidth << ", " << absheight << "]" << endl;
+	MagLog::dev() << "[" << width << ", " << height << "]" << endl;
+
+	viewTransformation_->aspectRatio(abswidth, absheight);
+	MagLog::dev() << "after aspect ratio -->[" << abswidth << ", " << absheight << "]" << endl; 
+	MagLog::dev() << "[" << abswidth << ", " << absheight << "]" << endl;
+	MagLog::dev() << "[" << absoluteWidth() << ", " << absoluteWidth() << "]" << endl;
+
+	width = abswidth / absoluteWidth() *100;
+	height = absheight / absoluteHeight() *100;
+
+	MagLog::dev() << "[" << width << ", " << height << "]" << endl;
+	// This is for alignement.. need further test!
+	double x = magCompare(horizontal_, "left") ?  left : 100 - left - width;
+	double y = magCompare(vertical_, "bottom") ?  bottom : 100  - top - height;
+
+	drawing_top_ = 100 - y - height;
+	drawing_bottom_= y;
+	drawing_right_ = 100 - x - width;
+	drawing_left_ = x;
+
+
+	vaxis_ = vertical_axis_with_;
+	haxis_ = horizontal_axis_height_;
+
+	
+	
+	ParameterManager::set("subpage_x_length_internal", abswidth);
+	ParameterManager::set("subpage_y_length_internal", absheight);
+	ParameterManager::set("subpage_x_position_internal", absx);
+	ParameterManager::set("subpage_y_position_internal", absy);
+
+	layout_->frame(true, frame_, *frame_colour_, frame_line_style_, frame_thickness_);
+
+	BasicSceneObject::getReady();
+}
+
+void FortranViewNode::print(ostream& out) const
+{
+	out << "FortranViewNode[";
+	BasicSceneObject::print(out);
+	FortranViewNodeAttributes::print(out);
+	out << "]";
+}
+
+BasicSceneNode* FortranViewNode::clone()
+{
+	FortranViewNode* node = new FortranViewNode();
+	//node->copy(*this);
+	return node;
+}
+static SimpleObjectMaker<NoOverlayAnimationRules, AnimationRules > never("never");
+static SimpleObjectMaker<LevelAnimationRules, AnimationRules > by_level("by_level");
+static SimpleObjectMaker<DateAnimationRules, AnimationRules > by_date("by_date");
+static SimpleObjectMaker<AsIsAnimationRules, AnimationRules > always("always");
+static SimpleObjectMaker<AsIsAnimationRules, AnimationRules > basic("basic");
+static SimpleObjectMaker<NoOverlayAnimationRules, AnimationRules > none("none");
diff --git a/src/basic/ViewNode.h b/src/basic/ViewNode.h
new file mode 100644
index 0000000..a0f6b1b
--- /dev/null
+++ b/src/basic/ViewNode.h
@@ -0,0 +1,176 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ViewNode.h
+    \brief Definition of the Template class ViewNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef ViewNode_H
+#define ViewNode_H
+
+#include "magics.h"
+#include "BasicSceneObject.h"
+#include "FortranViewNodeAttributes.h"
+#include "XmlBasicNodeAttributes.h"
+#include "XmlViewNodeAttributes.h"
+#include "XmlNode.h"
+#include "Layout.h"
+
+
+namespace magics {
+
+class Transformation;
+class AnimationRules;
+
+class ViewNode: public BasicSceneNode {
+
+public:
+	ViewNode();
+	virtual ~ViewNode();
+	void setInteractiveInfo(const string& id, int levels, int level) {
+		name(id);
+		assert(layout_);
+		layout_->id(id);
+		id_ = id;
+		zoomLevels_ = levels;
+		zoomCurrentLevel_ = level;
+		layout_->zoomLevels(levels);
+		layout_->zoomCurrentLevel(level)	;
+	}
+	
+	virtual void text(TextVisitor* text);
+	virtual void legend(LegendVisitor* legend);
+	
+	
+	
+	
+	
+	void visit(MetaDataCollector&);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 void print(ostream&) const; 
+	 void prepareLayout(SceneLayer&);
+	 virtual void updateLayout() {}
+	
+	 void getReady();
+	 
+	 void visit(SceneLayer&);	
+	 void visit(MetaDataVisitor&);
+	 void visit(PreviewVisitor&);
+	 void visit(HistoVisitor&);
+	
+	 virtual void copy(const ViewNode&);
+
+	 Transformation& transformation() const { assert(viewTransformation_); return *viewTransformation_; }
+	 
+	 Transformation* viewTransformation_;
+	 
+	 // The margin are used to position the drawing area, inside the node! 
+	 double drawing_top_; //In automatic mode : The top should always be greater that 15% to allow a space for the automatic title, and automatic legend!
+	 double drawing_bottom_;
+	 double drawing_left_;
+	 double drawing_right_;
+	 string animation_; 
+	 
+	 DrawingVisitor* 		drawing_;
+	 TopAxisVisitor*    		topAxis_;
+	 BottomAxisVisitor*   bottomAxis_;
+	 LeftAxisVisitor*    	leftAxis_;
+	 RightAxisVisitor*    	rightAxis_;
+	 double                 vaxis_;
+	 double                 haxis_;
+	 
+	 AnimationRules*         rules_;
+
+	 LegendVisitor* 		legend_;
+	 vector<TextVisitor*>     texts_;
+	 vector<LayoutVisitor*> components_;
+	
+	
+	 // Infomation about the zoom! 
+	 string id_;
+	 int zoomLevels_;
+	 int zoomCurrentLevel_;
+	
+
+private:
+	 //! Overloaded << operator to copy - No copy allowed
+   ViewNode(const ViewNode&);
+    //! Overloaded << operator to copy - No copy allowed
+	ViewNode& operator=(const ViewNode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ViewNode& p)
+		{ p.print(s); return s; }
+	
+};
+
+class FortranViewNode : public ViewNode, public FortranViewNodeAttributes
+{
+public: 
+	FortranViewNode();
+	~FortranViewNode();
+    
+	BasicSceneNode* clone();
+	
+	void getReady();
+
+
+protected:
+	void print(ostream&) const;
+	
+	
+};
+
+class XmlViewNode : public ViewNode, public XmlBasicNodeAttributes, public XmlViewNodeAttributes
+{
+public: 
+	XmlViewNode();
+	~XmlViewNode();
+	void set(const XmlNode& node) {
+		if ( magCompare(node.name(), "map" ) ) {
+			XmlNode view = node;
+		    view.name("view");
+			XmlBasicNodeAttributes::set(view);
+		}
+		XmlViewNodeAttributes::set(node);
+	}
+
+	
+	void updateLayout();
+	void getReady();
+protected:
+	void print(ostream&) const;
+};
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/basic/Visdef.h b/src/basic/Visdef.h
new file mode 100644
index 0000000..6a819c8
--- /dev/null
+++ b/src/basic/Visdef.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Visdef.h
+    \brief Definition of the Template class Visdef.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Fri 16-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef Visdef_H
+#define Visdef_H
+
+#include "magics.h"
+#include "BasicSceneObject.h"
+#include "Data.h"
+
+
+namespace magics {
+
+class MetaDataVisitor;
+class Transformation;
+class HistoVisitor;
+class Colour;
+template <class T > class IntervalMap;
+
+
+class Visdef : public MetviewIcon  {
+
+public:
+	Visdef() {}
+	virtual ~Visdef() {}
+	
+
+	virtual void operator()(Data&, BasicGraphicsObjectContainer&) = 0;
+	virtual void visit(LegendVisitor&) {}
+	virtual void visit(Data&, LegendVisitor& legend) { this->visit(legend);}
+	virtual void visit(Data&, HistoVisitor&)
+	{ 
+		MagLog::dev() << "Here could build a basic histogram!" << endl; 
+	}
+    virtual void visit(MetaDataVisitor&) {}
+    virtual void visit(TopAxisVisitor&) {}
+    virtual void visit(Transformation&, Data&) {}
+    virtual void visit(Layer& layer) { MetviewIcon::visit(layer); }
+    virtual void beanInfo(IntervalMap<Colour>&) { assert(false); }
+    virtual bool needLegend() { return false; }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { 
+	 	out << "visdef"; 
+	 }
+	 
+private:
+    //! Copy constructor - No copy allowed
+	Visdef(const Visdef&);
+    //! Overloaded << operator to copy - No copy allowed
+	Visdef& operator=(const Visdef&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Visdef& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/VisualAction.cc b/src/basic/VisualAction.cc
new file mode 100644
index 0000000..e1bf1aa
--- /dev/null
+++ b/src/basic/VisualAction.cc
@@ -0,0 +1,348 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file VisualAction.h
+    \brief Implementation of the Template class ActionNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/ 
+
+#include "VisualAction.h"
+#include "LegendVisitor.h"
+#include "Timer.h"
+#include "TextVisitor.h"
+#include "SceneVisitor.h"
+#include "AnimationRules.h"
+#include "Layer.h"
+#include "MagnifierVisitor.h"
+#include "HistoVisitor.h"
+
+using namespace magics;
+
+
+VisualAction::VisualAction() : data_(0)
+{
+}
+
+
+VisualAction::~VisualAction()
+{
+	MagLog::debug() << "delete VisualAction" << endl;
+	if (data_) delete data_;
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void VisualAction::print(ostream& out)  const
+{
+	out << "ActionNode";
+}
+
+
+void VisualAction::getReady()
+{
+	MagLog::dev() << "ActionNode::getReady()\n";
+}
+
+
+void VisualAction::release()
+{
+
+	if ( data_ )
+		data_->release();
+}
+
+void VisualAction::visit(DateDescription& timestamp) {
+	if ( data_ )
+		timestamp = data_->timeStamp();
+}
+
+
+void VisualAction::visit(LevelDescription& level) {
+	if ( data_ )
+		level = data_->level();
+}
+
+
+
+
+void VisualAction::visit(DrawingVisitor& drawing)
+{
+	if ( !data_ || visdefs_.empty() )
+	{
+		MagLog::warning() << " No proper action defined!" << endl;
+		return;
+	}
+	data_->getReady(drawing.transformation());
+
+	for (  vector<Visdef* >::iterator visdef = visdefs_.begin(); visdef != visdefs_.end(); ++visdef)
+	{
+		Timer timer("plotting", "time spent in plotting");
+		(**visdef)(*data_, drawing.layout()); // Now the visualObject ahs the responsability to reproject!
+	}
+}
+
+
+void VisualAction::visit(HistoVisitor& drawing)
+{
+	if ( !visdefs_.empty() ) {
+		// We only send it to the first action...
+
+
+		 
+		drawing.basic(true);
+		drawing.dataLayoutTransformation(&transformation());
+		 
+		for(  vector<Visdef* >::iterator visdef = visdefs_.begin(); visdef != visdefs_.end(); ++visdef)
+		{
+			if((*visdef)->iconName() == drawing.dataVisdefIcon().iconName() &&
+			   (*visdef)->iconClass() == drawing.dataVisdefIcon().iconClass() && 
+			   ! (*visdef)->iconClass().empty())
+			{
+				drawing.basic(false);
+				(*visdef)->visit(*data_, drawing);
+				return;	
+			}  
+			  
+			  	
+		}
+
+
+		visdefs_.front()->visit(*data_, drawing);
+	}
+}
+
+
+
+void VisualAction::visit(Transformation& transformation)
+{
+	if ( !data_ || visdefs_.empty() ) {
+		MagLog::warning() << " No proper action defined!" << endl;
+		return;
+	}
+	data_->visit(transformation);	
+	for ( vector<Visdef* >::iterator visdef = visdefs_.begin(); visdef != visdefs_.end(); ++visdef)
+		(**visdef).visit(transformation, *data_);
+}
+ 
+ 
+
+void VisualAction::visit(LegendVisitor& legend)
+{
+	unsigned int entries = legend.size();
+	bool needEmpty = false;
+	legend.transformation(&transformation());
+	for ( vector<Visdef* >::iterator visdef = visdefs_.begin(); visdef != visdefs_.end(); ++visdef) {
+		if ( needEmpty ) 
+			legend.add(new EmptyEntry() );
+		(**visdef).visit(*data_, legend);
+		needEmpty = ( entries != legend.size() );
+		entries = legend.size();
+	}
+	data_->visit(legend);
+}
+
+
+void VisualAction::visit(TextVisitor& title)
+{
+	if ( data_ ) data_->visit(title);
+}
+
+void VisualAction::visit(TopAxisVisitor& top)
+{
+	for ( vector<Visdef* >::iterator visdef = this->visdefs_.begin(); visdef != this->visdefs_.end(); ++visdef) {
+			(*visdef)->visit(top);
+	}
+}
+
+void VisualAction::visit(MetaDataVisitor& infos)
+{
+	if ( data_ ) data_->visit(infos);
+	for ( vector<Visdef* >::iterator visdef = this->visdefs_.begin(); visdef != this->visdefs_.end(); ++visdef) {
+		(*visdef)->visit(infos);
+	}
+}
+
+
+void VisualAction::visit(MetaDataCollector& infos)
+{
+	infos.transformation(&transformation());
+	if ( data_ ) data_->visit(infos);
+}
+
+
+void VisualAction::visit(ValuesCollector& infos)
+{
+	infos.transformation(&transformation());
+	if ( data_ ) data_->visit(infos);
+}
+
+void VisualAction::visit(DataIndexCollector& infos)
+{
+	if ( data_ ) data_->visit(infos);
+}
+
+void VisualAction::visit(MagnifierCollector& infos)
+{
+	infos.transformation(&transformation());
+	if ( data_ ) data_->visit(infos);
+}
+
+
+void VisualAction::visit(AnimationRules& rules)
+{
+	if ( data_ ) data_->visit(rules);
+}
+
+static string unknown("unknown");
+const string& VisualAction::name()
+{
+
+	return ( data_ ) ? data_->name() : unknown;
+}
+
+
+const string& VisualAction::id() {
+	static string name("unknown");
+	return ( data_ ) ? data_->layerId() : unknown;
+}
+
+
+	
+
+VisualAnimation::VisualAnimation():loop_(0)
+{
+}
+
+
+VisualAnimation::~VisualAnimation()
+{
+	cout << "delete VisualAnimation" << endl;
+	if (loop_) delete loop_;
+}
+
+
+void VisualAnimation::prepare()
+{
+	if ( !this->empty() )
+		return;
+	
+	layer_ = new StepLayer();
+	layer_->name(loop_->name());
+	layer_->id(loop_->name()); 
+	layer_->uniqueId(loop_->iconId());
+	loop_->visit(*layer_);
+	
+	for ( vector<Visdef* >::iterator visdef = this->visdefs_.begin(); visdef != this->visdefs_.end(); ++visdef)
+	{    		
+		(*visdef)->visit(*layer_);
+	}
+				
+	loop_->setToFirst(); 
+	while ( loop_->hasMore() )
+	{
+		MagLog::dev() << "New Frame" << endl; 
+
+		VisualAction* action = new VisualAction();
+		action->parent(this);
+		action->data(loop_->current());
+
+		for ( vector<Visdef* >::iterator visdef = this->visdefs_.begin(); visdef != this->visdefs_.end(); ++visdef) {
+			action->visdef(*visdef);
+		}
+
+		layer_->addStep(action);
+
+
+
+		loop_->next();
+	}
+}
+
+
+
+void VisualAnimation::visit(MetaDataVisitor&)
+{
+}
+
+
+void VisualAnimation::visit(AnimationRules& rules)
+{
+	prepare();
+	for ( iterator entry = this->begin(); entry != this->end(); ++entry)
+		(*entry)->visit(rules);
+	rules.add(*this->layer_);
+}
+
+
+
+void VisualAnimation::visit(Transformation& transformation)
+{
+	assert(loop_);
+	loop_->visit(transformation);
+} 
+
+
+void VisualAnimation::visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors)
+{
+   	layer.add(layer_);
+ 	for  (vector<LayoutVisitor*>::iterator visitor = visitors.begin(); visitor != visitors.end(); ++visitor) {
+   		layer.addVisitor(*visitor); 
+   		layer_->addVisitor(*visitor);  
+   	}
+}
+
+bool VisualAction::needLegend()
+{
+	for(vector<Visdef* >::iterator visdef = this->visdefs_.begin(); visdef != this->visdefs_.end(); ++visdef)
+		{
+			if ( (*visdef)->needLegend() )
+				return true;
+		}
+	return false;
+}
+
+void VisualAction::visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors)
+{
+	StaticLayer* plot = new StaticLayer(this);
+	
+
+	if ( data_ ) 
+		data_->visit(*plot);
+ 	layer.add(plot);
+
+	for  (vector<LayoutVisitor*>::iterator visitor = visitors.begin(); visitor != visitors.end(); ++visitor) {
+		plot->set(*visitor);
+		(*visitor)->visit(*this);
+	}
+
+	for(vector<Visdef* >::iterator visdef = this->visdefs_.begin(); visdef != this->visdefs_.end(); ++visdef)
+	{    
+		(*visdef)->visit(*plot);
+	}
+
+
+}
+
diff --git a/src/basic/VisualAction.h b/src/basic/VisualAction.h
new file mode 100644
index 0000000..6250fbf
--- /dev/null
+++ b/src/basic/VisualAction.h
@@ -0,0 +1,133 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file VisualAction.h
+    \brief Definition of the Template class ActionNode.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 6-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef ActionNode_H
+#define ActionNode_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+#include "Data.h"
+#include "Visdef.h"
+
+namespace magics {
+class FrameLoop;
+class HistoVisitor;
+
+
+
+class VisualAction: public BasicSceneObject {
+
+public:
+	VisualAction();
+	virtual ~VisualAction();
+	
+	void data(Data* data)     { data_ = data; }
+	void visdef(Visdef* visdef) { visdefs_.push_back(visdef); }
+	void binning(BinningObject* binning)     { if (data_) data_->binning(binning); }
+	const string& name();
+    const string& id();
+
+    // A visual Action is valid, if the data have been set and the list of visdef is not empty!
+    bool isValid() const { return data_ && visdefs_.empty() == false; }
+
+    bool needLegend();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+	 void getReady();
+	 void release();
+	 
+	 void visit(DrawingVisitor&);
+	 void visit(TopAxisVisitor&);
+	 void visit(LegendVisitor&); 
+	 void visit(TextVisitor&); 
+	 void visit(MetaDataVisitor&); 
+	 void visit(HistoVisitor&); 
+	 
+	 void visit(Transformation&);
+	 
+	 void visit(AnimationRules&);
+	 
+	 void visit(SceneLayer&, vector<LayoutVisitor*>&);
+	 void visit(MetaDataCollector&);
+	 void visit(ValuesCollector&);
+	 void visit(DataIndexCollector&);
+	 void visit(MagnifierCollector&);
+	 
+	 Data*                       data_;
+	 vector<Visdef*>       visdefs_;
+
+	 void visit(DateDescription&);
+	 void visit(LevelDescription&);
+	
+	 
+private:
+    //! Copy constructor - No copy allowed
+	VisualAction(const VisualAction&);
+    //! Overloaded << operator to copy - No copy allowed
+	VisualAction& operator=(const VisualAction&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const VisualAction& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+class VisualAnimation: public VisualAction,
+	public vector<BasicSceneObject*>  {
+
+public:
+	VisualAnimation();
+	virtual ~VisualAnimation();
+	void loop(DataLoop* data)     { loop_ = data; }
+	DataLoop& loop() { assert(loop_); return *loop_; }
+    
+protected:
+	
+	void visit(MetaDataVisitor&); 
+    void visit(Transformation&);
+    void visit(AnimationRules&);
+    void visit(SceneLayer&, vector<LayoutVisitor*>&);
+    
+    void prepare(); 
+    
+    DataLoop* loop_;
+    StepLayer* layer_;
+    
+    
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/WebFormat.cc b/src/basic/WebFormat.cc
new file mode 100644
index 0000000..5fab67f
--- /dev/null
+++ b/src/basic/WebFormat.cc
@@ -0,0 +1,156 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include "WebFormat.h"
+#ifdef MAGICS_JSON
+#include "MagJSon.h"
+#endif
+using namespace magics;
+
+
+pair<string, string> cut(const string& in)
+{
+	string::const_iterator c = in.begin();
+	string var;
+	string current;
+	
+	while ( c != in.end() )
+	{		
+		if ( *c == '=' ) {			
+			var = current;
+			current = "";
+		}
+		else {
+			current.push_back(*c);
+		}
+		c++;
+	}
+	if ( var.empty() ) {
+		var = current;
+		current = "";
+	}
+	return make_pair(var, current);
+}
+
+
+
+
+
+string replace(const string& in, const map<string, string>& variables)
+{
+	pair<string, string> var = cut(in);
+
+	map<string, string>::const_iterator variable = variables.find(var.first);
+
+	return ( variable != variables.end() ) ? variable->second : var.second;
+}
+
+int findandreplace(string& in, int from, const map<string, string>& variables)
+{
+	for (map<string, string>::const_iterator var = variables.begin(); var != variables.end(); ++var)
+		if ( in.substr(from+1, var->first.size()) == var->first) 
+		{
+			in.replace(from, var->first.size()+1, var->second);
+			return from+var->second.size();
+		}
+	return from;
+}
+static void substitute(string& xml, const map<string, string>& variables) 
+{
+	for (unsigned int i = 0; i < xml.size(); i++)
+	{
+		if ( xml[i] == '$' ) {
+			if ( xml[i+1] == '{' ) {
+				string var;
+				unsigned int last  = i+2;
+			    while ( xml[last] != '}' ) {
+			    	var.push_back(xml[last]);
+			    	last++;
+			    }
+			    last++;
+			    string val = replace(var, variables);
+			    xml.replace(i, last-i, val);
+			    i = i + val.length();
+			}
+			else {
+				i = findandreplace(xml, i, variables);
+			}
+		}
+	}
+}
+
+
+
+void WebFormat::prepare(const string& magml, const map<string, string>& params, TempFile& file)
+{
+	ifstream in(magml.c_str());
+	if ( !in )
+	{
+		MagLog::error() << " Can not open file " << magml << endl;
+		throw (MagicsException("no file"));
+	} 
+
+	ofstream& out = file();
+
+	string s = "";
+	char c;
+	while(in.get(c)) s+=c;
+
+	substitute(s, params);
+	out << s; 
+
+	in.close();
+	out.flush();
+	out.close();
+};
+
+void MagML::execute(const string& magml, const map<string, string>& params)
+{
+	XmlMagics magics;
+	TempFile file;
+	prepare(magml, params, file);	
+	magics.execute(file.name());
+}
+
+WebInterpretor WebInterpretor::web_;
+
+WebInterpretor::WebInterpretor()
+{
+}
+
+WebInterpretor::~WebInterpretor()
+{
+}
+
+void WebInterpretor::magml(const string& file)
+{
+	MagML magml;
+	magml.execute(file, web_);
+	web_.clear(); 
+}
+
+void WebInterpretor::json(const string& file)
+{
+#ifdef MAGICS_JSON
+	MagJSon json;
+	json.execute(file, web_);
+	web_.clear();
+#else
+    MagLog::error() << "No Json support" << endl;
+#endif
+}
diff --git a/src/basic/WebFormat.h b/src/basic/WebFormat.h
new file mode 100644
index 0000000..90d2d14
--- /dev/null
+++ b/src/basic/WebFormat.h
@@ -0,0 +1,127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagML.h
+    \brief Definition of the Template class MagML.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 3-Apr-2007
+    
+    Changes:
+    
+*/
+
+#ifndef MagML_H
+#define MagML_H
+
+
+#include "XmlMagics.h"
+
+namespace magics {
+
+class TempFile
+{
+  public:
+    TempFile() : filename(tmpnam(0)), ofs(filename)
+    {
+        if (!ofs) return;
+    }
+
+    ~TempFile()
+    {
+        ofs.close();
+        remove(filename);
+    }
+
+    ofstream& operator()() { return ofs; }
+    string name() { return filename; }
+
+  private:
+    const char* filename;
+    ofstream ofs;
+};
+
+
+class WebFormat  {
+
+public:
+	WebFormat() {}
+	~WebFormat() {}
+	
+
+	
+	void prepare(const string&, const map<string, string>&, TempFile& file);		
+	
+    virtual void execute(const string&, const map<string, string>&) {}
+	
+	
+	
+	
+
+protected:
+	
+	void print(ostream&) const {}
+     
+private:
+    //! Copy constructor - No copy allowed
+	WebFormat(const WebFormat&);
+    //! Overloaded << operator to copy - No copy allowed
+	WebFormat& operator=(const WebFormat&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const WebFormat& p)
+		{ p.print(s); return s; }
+};
+
+class MagML : public WebFormat {
+
+public:
+	MagML() {}
+	~MagML() {}
+    
+    void execute(const string&, const map<string, string>&);
+    
+protected:	
+	void print(ostream&) const {}
+};
+
+
+
+class WebInterpretor: public map<string, string> 
+{
+public:
+	WebInterpretor();
+	~WebInterpretor();
+	
+	static void magml(const string&);
+	static void json(const string&);
+	static void set(const string& param,  const string& value) {
+		web_.insert(make_pair(param, value)); 
+	}
+	static map<string, string>& parameters() { return web_; }
+	
+	
+protected:
+	static WebInterpretor web_;
+	
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/WrepRootNodeAttributes.h b/src/basic/WrepRootNodeAttributes.h
new file mode 100644
index 0000000..e7a6861
--- /dev/null
+++ b/src/basic/WrepRootNodeAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file WrepRootNodeAttributes.h
+    \brief Definition of WrepRootNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef WrepRootNodeAttributes_H
+#define WrepRootNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class WrepRootNodeAttributes 
+{
+public:
+//  --  constructor
+    WrepRootNodeAttributes();
+    
+//  --  destructor
+    virtual ~WrepRootNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const WrepRootNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double pixel_width_;
+	double pixel_height_;
+	string anchor_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const WrepRootNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/XmlBasicNodeAttributes.h b/src/basic/XmlBasicNodeAttributes.h
new file mode 100644
index 0000000..e9e9d76
--- /dev/null
+++ b/src/basic/XmlBasicNodeAttributes.h
@@ -0,0 +1,110 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file XmlBasicNodeAttributes.h
+    \brief Definition of XmlBasicNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef XmlBasicNodeAttributes_H
+#define XmlBasicNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class XmlBasicNodeAttributes 
+{
+public:
+//  --  constructor
+    XmlBasicNodeAttributes();
+    
+//  --  destructor
+    virtual ~XmlBasicNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const XmlBasicNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	bool standalone_;
+	string standalone_path_;
+	string standalone_format_;
+	double standalone_width_;
+	double standalone_height_;
+	DisplayType display_;
+	string bottom_;
+	string left_;
+	string width_;
+	string height_;
+	string margin_bottom_;
+	string margin_left_;
+	string margin_right_;
+	string margin_top_;
+	auto_ptr<Colour> background_;
+	string border_bottom_;
+	string border_left_;
+	string border_right_;
+	string border_top_;
+	bool border_;
+	bool blanking_;
+	auto_ptr<Colour> border_colour_;
+	LineStyle border_style_;
+	int border_thickness_;
+	string padding_bottom_;
+	string padding_left_;
+	string padding_right_;
+	string padding_top_;
+	auto_ptr<Colour> padding_colour_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const XmlBasicNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/XmlMagics.cc b/src/basic/XmlMagics.cc
new file mode 100644
index 0000000..27cb0e5
--- /dev/null
+++ b/src/basic/XmlMagics.cc
@@ -0,0 +1,907 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlMagics.cc
+    \brief Implementation of the Template class XmlMagics.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Apr-2007
+
+*/
+
+
+#include "magics_ecmwf_log.h"
+#include "XmlMagics.h"
+#include "XmlReader.h"
+#include "MagException.h"
+#include "Timer.h"
+
+#include "RootSceneNode.h"
+#include "SceneNode.h"
+#include "ViewNode.h"
+#include "Coastlines.h"
+#include "BinaryObject.h"
+
+#include "TaylorGrid.h"
+#ifdef MAGICS_GRIB
+#include "GribDecoder.h"
+#endif
+#include "TableDecoder.h"
+#include "VisualAction.h"
+#include "XYList.h"
+#include "LandgramDecoder.h"
+#include "EpsXmlInput.h"
+#ifdef MAGICS_JSON
+#include "WrepJSon.h"
+#endif
+#include "LandgramBox.h"
+#include "ImagePlotting.h"
+#include "SymbolPlotting.h"
+#include "Contour.h"
+#include "Wind.h"
+//#include "Histogram.h"
+
+#include "LegendVisitor.h"
+#include "TextVisitor.h"
+
+#include "UserPoint.h"
+#include "UserPoint.h"
+#include "Axis.h"
+#include "MatrixTestDecoder.h"
+
+#include "SimplePolylineInput.h"
+#include "SimplePolylineVisualiser.h"
+
+#include "MetaData.h"
+#include "ThreadNode.h"
+
+
+#ifdef MAGICS_SPOT
+#include "ClassicMtgDecoder.h"
+#include "EpsgramDecoder.h"
+#include "MetgramGraph.h"
+#endif
+
+#include "EpsGraph.h"
+
+using namespace magics;
+
+XmlMagics::XmlMagics() : root_(0),
+	gribloop_(0), 
+	geographical_(true), 
+	driversToSet_(true)
+{
+	writeMagLog("magml");
+
+	actions_["magics"] = &XmlMagics::magics;
+	actions_["page"] = &XmlMagics::page;
+	
+	actions_["mgb"] = &XmlMagics::binary;
+
+	actions_["text"] = &XmlMagics::text;
+	actions_["map"] = &XmlMagics::map;
+	actions_["matrix"] = &XmlMagics::matrix;
+	actions_["cartesian"] = &XmlMagics::cartesian;
+	actions_["taylor"] = &XmlMagics::cartesian;
+	actions_["cylindrical"] = &XmlMagics::geographical;
+	actions_["polar_stereographic"] = &XmlMagics::geographical;
+
+	actions_["horizontal_axis"] = &XmlMagics::horizontalAxis;
+	actions_["vertical_axis"] = &XmlMagics::verticalAxis;
+	actions_["coastlines"] = &XmlMagics::coastlines;
+	actions_["taylorgrid"] = &XmlMagics::taylor;
+
+	actions_["grib"] = &XmlMagics::grib;
+	actions_["netcdf"] = &XmlMagics::netcdf;
+	actions_["table"] = &XmlMagics::table;
+
+	actions_["odb"] = &XmlMagics::odb;
+	actions_["xyinput"] = &XmlMagics::xyinput;
+	actions_["input"] = &XmlMagics::input;
+	actions_["landgram"] = &XmlMagics::landgram;
+
+	actions_["wind"] = &XmlMagics::wind;
+	actions_["image"] = &XmlMagics::image;
+	actions_["symbol"] = &XmlMagics::symbol;	
+	actions_["contour"] = &XmlMagics::contour;
+	actions_["histogram"] = &XmlMagics::histogram;
+	actions_["landgrambox"] = &XmlMagics::landgrambox;
+	actions_["legend"] = &XmlMagics::legend;
+	actions_["meta"] = &XmlMagics::metadata;
+
+	actions_["drivers"] = &XmlMagics::driver;
+
+	actions_["plot"] = &XmlMagics::layer;
+	actions_["geopoints"] = &XmlMagics::geopoints;
+	actions_["cdfgraph"] = &XmlMagics::cdfgraph;
+	actions_["efigraph"] = &XmlMagics::efigraph;
+	actions_["efigram"] = &XmlMagics::efigram;
+
+	actions_["metgraph"] = &XmlMagics::metgraph;
+	actions_["metgram"] = &XmlMagics::metgram;
+
+	actions_["gribloop"] = &XmlMagics::gribloop;
+
+	actions_["epsxml"] = &XmlMagics::epsxml;
+	actions_["wrepjson"] = &XmlMagics::wrepjson;
+
+	
+	actions_["epsbufr"] = &XmlMagics::epsbufr;
+	actions_["epsgraph"] = &XmlMagics::epsgraph;
+	actions_["epsgram"] = &XmlMagics::epsgram;
+	actions_["epswind"] = &XmlMagics::epswind;
+	actions_["epscloud"] = &XmlMagics::epscloud;
+	actions_["epsbar"] = &XmlMagics::epsbar;
+	actions_["epswave"] = &XmlMagics::epswave;
+	actions_["epsshade"] = &XmlMagics::epsshading;
+	actions_["epsplume"] = &XmlMagics::epsplume;
+	actions_["epsdirection"] = &XmlMagics::epsdirection;
+
+	actions_["mapgen"] = &XmlMagics::mapgen;
+	actions_["graph"] = &XmlMagics::graph;
+
+	actions_["polyline_input"] = &XmlMagics::polyinput;
+	actions_["polyline"] = &XmlMagics::polyline;
+
+	actions_["layer"] = &XmlMagics::split;
+	actions_["thread"] = &XmlMagics::thread;
+	actions_["import"] = &XmlMagics::import;
+}
+
+
+XmlMagics::~XmlMagics() 
+{
+}
+ 
+/*!
+ Class information are given to the output-stream.
+*/		
+void XmlMagics::print(ostream& out)  const
+{
+	out << "XmlMagics[";
+	out << "]";
+}
+
+void XmlMagics::execute(XmlTree& tree) 
+{
+	{
+	Timer timer("Total", "Execution of the tree");
+	try {
+		tree.visit(*this);
+	}
+	catch (MagicsException& e) {
+		MagLog::debug() << e.what() << endl;
+	}
+
+	if ( driversToSet_ ) 
+		output_.set(drivers_);
+
+	assert(root_);
+
+	root_->execute();
+
+	if ( root_->scalingFactor() != 1)  
+		drivers_.setOutputWidth(root_->scalingFactor());
+
+
+	drivers_.setDriversWidth(root_->absoluteWidth());
+	drivers_.setDriversHeight(root_->absoluteHeight());
+
+	{ 
+		Timer timer("drivers", "rendering of the graphical tree");
+		drivers_.openDrivers();
+		drivers_.dispatch(root_->root());
+
+		drivers_.closeDrivers();
+	}
+	}
+	MetaDataVisitor::collect();
+	//root_->metadata(meta);
+	/* later 
+		std::map<string, string>::const_iterator filename = meta.find("filename");
+		if ( filename != meta.end() && !filename->second.empty()) {
+			ofstream file (filename->second.c_str());
+		
+			for (std::map<string, string>::const_iterator d = meta.begin(); d != meta.end(); ++d) {
+				if ( d != filename ) 
+	                file << d->first << " = " << d->second << "; " << endl;
+	        }
+		}
+	*/
+	output_.clear();
+	//ParameterManager::release();
+	delete root_;
+	root_ = 0;
+}
+
+void XmlMagics::execute(const string& file, std::map<string, string>& )
+{
+	
+	XmlReader parser(true);
+	XmlTree tree;	
+	ParameterManager::set(string("layout"), string("magml")); 
+	try {
+		parser.interpret(file, &tree);		
+		execute(tree);
+	}
+	catch (MagicsException& e) {
+		MagLog::debug() << e.what() << endl;
+	}
+}
+
+void XmlMagics::display(const string& file)
+{
+	XmlReader parser(true);
+	XmlTree tree;	
+
+	try {
+		parser.interpret(file, &tree);		
+		tree.visit(*this);
+	}
+	catch (MagicsException& e) {
+			MagLog::debug() << e.what() << endl;
+	}
+	
+	if ( driversToSet_ ) 
+		output_.set(drivers_);
+
+	assert(root_);
+	root_->getReady();
+	drivers_.setDriversWidth(root_->absoluteWidth());
+	drivers_.setDriversHeight(root_->absoluteHeight());
+	
+	root_->execute();
+	drivers_.openDrivers();
+	drivers_.dispatch(root_->root());
+
+	drivers_.closeDrivers();
+}
+	
+void XmlMagics::visit(const XmlNode& node)
+{
+	std::map<string, Action>::iterator action = actions_.find(node.name());
+
+	if ( action == actions_.end() )
+	{
+		MagLog::dev() << " MagML - ignoring tag: " << node.name()<< endl;
+		return;
+	}
+	(this->*action->second)(node);
+}
+
+void XmlMagics::magics(const XmlNode& node)
+{
+	ParameterManager::set(string("layout"), string("magml")); 
+	const float version_ = 3.0;
+	MagLog::debug() << " You are using the " << fixed << setprecision(1) << version_ << " version of the magml interpreter\n";
+	string version = node.getAttribute("version");
+	if ( version.empty() )
+	{
+		MagLog::error() << " No version defined in your magml file\n"
+		             << " Compatibilty issue: check your magml file and add a version number" << endl;
+		return;
+	}
+	float v;
+	std::stringstream sv(version);
+	sv >> v;
+	if ( v < version_ )
+	{
+		MagLog::error() << " The version defined in the file is " << fixed << setprecision(1) << v 
+		             << "\n Compatibilty issue: check your magml file and update the version number" << endl;
+		return;
+	}
+	string method = node.getAttribute("method") ;
+	
+	root_ =  ( method == "wrep" ) ? new  WrepRootSceneNode() : new  XmlRootSceneNode();
+
+	push(root_);
+	root_->set(node);
+	root_->getReady();
+	node.visit(*this);
+}
+
+
+
+void XmlMagics::driver(const XmlNode& node)
+{
+	for ( XmlNode::ElementIterator driver = node.firstElement(); driver != node.lastElement(); ++driver)
+	{
+		output_.set(**driver, drivers_);
+	}
+	driversToSet_ = false;
+}
+
+
+void XmlMagics::split(const XmlNode& node)
+{
+/*
+	LayerNode* layer = new LayerNode();
+	layer->set(node);
+	top()->push_back(layer);
+	push(layer);
+	node.visit(*this);
+	pop();
+*/
+	node.visit(*this);
+}
+
+
+void XmlMagics::thread(const XmlNode& )
+{
+/* later
+	ThreadNode* thread = new ThreadNode();
+	thread->set(node);
+	top()->push_back(thread);
+	push(thread);
+	node.visit(*this);
+	pop();
+*/
+}
+
+void XmlMagics::metadata(const XmlNode& node)
+{
+	MetaDataVisitor* meta = new MetaDataVisitor();
+	meta->set(node);
+	top()->push_back(meta);
+}
+
+
+
+void XmlMagics::page(const XmlNode& node)
+{
+	XmlSceneNode* page = new XmlSceneNode();
+
+	page->set(node);
+	top()->insert(page);
+	push(page);
+	node.visit(*this);
+	pop();
+}
+
+void XmlMagics::legend(const XmlNode& node)
+{
+	LegendVisitor* legend = new XmlLegendVisitor();
+	legend->set(node);
+	
+	top()->legend(legend);	
+	node.visit(*this);
+}
+
+void XmlMagics::text(const XmlNode& node)
+{
+	XmlTextVisitor* text = new XmlTextVisitor();
+	text->set(node);
+	top()->text(text);
+	
+	node.visit(*this);
+}
+
+void XmlMagics::map(const XmlNode& node)
+{
+	XmlViewNode* view = new XmlViewNode();
+	view->set(node);
+	BasicSceneObject* parent = top()->insert(view);
+	if (parent != top() ) {
+		pop();
+		push(parent);
+	}
+
+	push(view);
+	node.visit(*this);
+	pop();
+}
+
+void XmlMagics::binary(const XmlNode& node)
+{	
+	BinaryObject* binary = new BinaryObject();
+	binary->set(node);
+	top()->push_back(binary);
+}
+
+void XmlMagics::coastlines(const XmlNode& node)
+{	
+	Coastlines* coast = new Coastlines();
+	coast->set(node);
+	top()->push_back(coast);
+}
+
+void XmlMagics::taylor(const XmlNode& node)
+{	
+	TaylorGrid* grid = new TaylorGrid();
+	grid->set(node);
+	top()->push_back(grid);
+}
+
+void XmlMagics::horizontalAxis(const XmlNode& node)
+{	
+	HorizontalAxis* axis = new HorizontalAxis();
+	axis->set(node);
+	top()->push_back(axis);
+}
+
+void XmlMagics::verticalAxis(const XmlNode& node)
+{	
+	VerticalAxis* axis = new VerticalAxis();
+	axis->set(node);
+	top()->push_back(axis);
+}
+
+void XmlMagics::cartesian(const XmlNode&)
+{	
+	geographical_ = false;
+}
+
+void XmlMagics::geographical(const XmlNode&)
+{	
+	geographical_ = true;
+}
+
+void XmlMagics::layer(const XmlNode& node)
+{
+	if ( geographical_ )
+	{
+		VisualAction* action = new VisualAction();
+		action->set(node);
+		top()->push_back(action);
+		push(action);	
+	}
+	else {
+		VisualAction* action = new VisualAction();
+		action->set(node);
+		top()->push_back(action);
+		push(action);
+	}
+
+	node.visit(*this);
+	pop();
+}
+
+#ifdef MAGICS_GRIB
+GribDecoder* grib_handler;
+
+void XmlMagics::gribloop(const XmlNode& node)
+{
+	if ( gribloop_) delete gribloop_;
+	gribloop_ = new GribLoop();
+	gribloop_->set(node);
+
+	actions_["grib"] = &XmlMagics::gribinloop;
+	actions_["layer"] = &XmlMagics::splitinloop;
+
+	while ( gribloop_->hasMore() ) {
+		node.visit(*this);
+	}
+}
+
+
+void XmlMagics::splitinloop(const XmlNode& ) 
+{
+	/* later!
+	assert(gribloop_);
+
+	LayerNode* layer = new LayerNode();
+	layer->set(node);
+	gribloop_->set(*layer);
+	top()->push_back(layer);
+	push(layer);
+	this->layer(node);
+	pop();
+	*/
+}
+
+void XmlMagics::gribinloop(const XmlNode&)
+{	
+	assert(gribloop_);
+	top()->data(gribloop_->current());
+}
+
+void XmlMagics::grib(const XmlNode& node)
+{
+	GribDecoder* grib = new GribDecoder();
+	grib->set(node);
+
+	top()->data(grib);
+
+}
+#else
+void XmlMagics::gribloop(const XmlNode&)
+{
+	MagLog::warning() <<" Attempt to call GribLoop but GRIB support is disabled!"<< endl;
+}
+
+void XmlMagics::gribinloop(const XmlNode&)
+{	
+	MagLog::warning() <<" Attempt to call GribInLoop but GRIB support is disabled!"<< endl;
+}
+
+void XmlMagics::grib(const XmlNode&)
+{
+	MagLog::warning() <<" Attempt to call Grib decoding but GRIB support is disabled!"<< endl;
+}
+#endif
+
+
+#include "GeoPointsDecoder.h"
+void XmlMagics::geopoints(const XmlNode& node)
+{	
+	GeoPointsDecoder* geo = new GeoPointsDecoder();
+	geo->set(node);
+	top()->data(geo);
+}
+
+#include "MapGenDecoder.h"
+void XmlMagics::mapgen(const XmlNode& node)
+{	
+	if (geographical_) {
+		MapGenDecoder* mapgen = new MapGenDecoder();
+		mapgen->set(node);
+		top()->data(mapgen);
+	}
+	else {
+		MapGenDecoder* mapgen = new MapGenDecoder();
+		mapgen->set(node);
+		top()->data(mapgen);
+	}
+}
+
+void XmlMagics::xyinput(const XmlNode& node)
+{	
+	if (geographical_) {
+			XYList* list = new XYList();
+			list->set(node);
+			top()->data(list);
+	}
+	else {
+			XYList* list = new XYList();
+			list->set(node);
+			top()->data(list);
+	}
+}
+
+#include "InputData.h"
+void XmlMagics::input(const XmlNode& node)
+{
+	InputData* data = new InputData();
+	data->set(node);
+	top()->data(data);
+
+}
+void XmlMagics::landgram(const XmlNode& node)
+{	
+	LandgramDecoder* list = new LandgramDecoder();
+	list->set(node);
+	top()->data(list);
+}
+
+void XmlMagics::landgrambox(const XmlNode& node)
+{	
+	LandgramBox* box = new LandgramBox();
+	box->set(node);
+	top()->visdef(box);
+}
+
+#include "GraphPlotting.h"
+void XmlMagics::graph(const XmlNode& node)
+{	
+	GraphPlotting* graph =  new GraphPlotting();
+	graph->set(node);
+	top()->visdef(graph);
+}
+
+void XmlMagics::histogram(const XmlNode& node)
+{
+	/*
+	Histogram* histogram =  new Histogram();
+	histogram->set(node);
+	top()->visdef(histogram);
+	*/
+}
+
+
+/***************************************************************************
+
+    O D B / O D A
+
+***************************************************************************/
+
+#ifdef MAGICS_ODB
+#include "OdaDecoder.h"
+#endif
+
+void XmlMagics::odb(const XmlNode& node)
+{
+#ifdef MAGICS_ODB
+	OdaGeoDecoder* odb = new OdaGeoDecoder();
+	odb->set(node);
+	top()->data(odb);
+#else 
+	MagLog::warning() << "ODB support is NOT enabled!\n";
+#endif
+
+}
+
+/* ********************************************************************* */
+
+
+void XmlMagics::efigram(const XmlNode& node)
+{	
+#ifdef MAGICS_SPOT
+	EfigramDecoder* efi = new EfigramDecoder();
+	efi->set(node);
+	top()->data(efi);
+#endif
+}
+
+void XmlMagics::cdfgraph(const XmlNode& node)
+{	
+#ifdef MAGICS_JSON
+	CdfGraph* cdf = new CdfGraph();
+	cdf->set(node);
+	top()->visdef(cdf);
+#endif
+}
+
+void XmlMagics::efigraph(const XmlNode& node)
+{	
+#ifdef MAGICS_JSON
+	EfiGraph* efi = new EfiGraph();
+	efi->set(node);
+	top()->visdef(efi);
+#endif
+}
+
+
+void XmlMagics::epsplume(const XmlNode& node)
+{	
+#ifdef MAGICS_JSON
+	EpsPlume* plume = new EpsPlume();
+	plume->set(node);
+	top()->visdef(plume);
+#endif
+}
+
+void XmlMagics::epsdirection(const XmlNode& node)
+{	
+#ifdef MAGICS_JSON
+	EpsDirection* direction = new EpsDirection();
+	direction->set(node);
+	top()->visdef(direction);
+#endif
+}
+
+void XmlMagics::metgram(const XmlNode& node)
+{	
+#ifdef MAGICS_SPOT
+	ClassicMtgDecoder* metgram = new ClassicMtgDecoder();
+	metgram->set(node);
+	top()->data(metgram);
+#endif
+}
+
+void XmlMagics::metgraph(const XmlNode& node)
+{	
+#ifdef MAGICS_SPOT
+	MetgramGraph* metgraph = new MetgramGraph();
+	metgraph->set(node);
+	top()->visdef(metgraph);
+#endif
+}
+
+
+void XmlMagics::epsgram(const XmlNode& node)
+{	
+#ifdef MAGICS_SPOT
+	EpsgramDecoder* eps = new EpsgramDecoder();
+	eps->set(node);
+	top()->data(eps);
+#endif
+}
+
+void XmlMagics::epsxml(const XmlNode& node)
+{	
+	EpsXmlInput* eps = new EpsXmlInput();
+	eps->set(node);
+	top()->data(eps);
+}
+void XmlMagics::wrepjson(const XmlNode& node)
+{	
+
+#ifdef MAGICS_JSON
+	WrepJSon* wrep = new WrepJSon();
+	wrep->set(node);
+	top()->data(wrep);
+#endif
+}
+
+
+#ifdef MAGICS_BUFR
+#include "EpsBufr.h"
+#endif
+void XmlMagics::epsbufr(const XmlNode& node)
+{	
+#ifdef MAGICS_BUFR
+	EpsBufr* eps = new EpsBufr();
+	eps->set(node);
+	top()->data(eps);
+#endif
+}
+
+void XmlMagics::epsgraph(const XmlNode& node)
+{	
+	EpsGraph* epsgraph = new EpsGraph();
+	epsgraph->set(node);
+	top()->visdef(epsgraph);
+}
+
+void XmlMagics::epswave(const XmlNode& node)
+{	
+	EpsWave* eps = new EpsWave();
+	eps->set(node);
+	top()->visdef(eps);
+}
+
+void XmlMagics::epswind(const XmlNode& node)
+{	
+	EpsWind* epswind = new EpsWind();
+	epswind->set(node);
+	top()->visdef(epswind);
+}
+
+void XmlMagics::epscloud(const XmlNode& node)
+{	
+	EpsCloud* epscloud = new EpsCloud();
+	epscloud->set(node);
+	top()->visdef(epscloud);
+}
+void XmlMagics::epsbar(const XmlNode& node)
+{
+	EpsBar* epsbar = new EpsBar();
+	epsbar->set(node);
+	top()->visdef(epsbar);
+}
+void XmlMagics::epsshading(const XmlNode& node)
+{	
+	EpsShade* eps = new EpsShade();
+	eps->set(node);
+	top()->visdef(eps);
+}
+
+#ifdef MAGICS_NETCDF
+#include "NetcdfDecoder.h"
+#endif
+void XmlMagics::netcdf(const XmlNode& node)
+{
+#ifdef MAGICS_NETCDF
+	if ( geographical_ ) {
+		NetcdfDecoder* netcdf = new NetcdfDecoder();
+		netcdf->set(node);
+		top()->data(netcdf);
+	}
+	else {
+		NetcdfDecoder* netcdf = new NetcdfDecoder();
+		netcdf->set(node);
+		top()->data(netcdf);
+	}
+#endif
+}
+
+void XmlMagics::table(const XmlNode& node)
+{
+	TableDecoder* table = new TableDecoder();
+	table->set(node);
+	top()->data(table);
+}
+
+#include "InputMatrix.h"
+void XmlMagics::matrix(const XmlNode& node)
+{	
+		//MatrixTestDecoder* matrix = new MatrixTestDecoder();
+		//matrix->set(node);
+		if ( geographical_ ) {
+			InputMatrix* data =  new InputMatrix();
+			data->set(node);
+			top()->data(data);
+		}
+		else {
+			InputMatrix* data =  new InputMatrix();
+			data->set(node);
+			top()->data(data);
+		}
+}
+
+void XmlMagics::polyinput(const XmlNode& node)
+{
+	SimplePolylineInput* input = new SimplePolylineInput();
+	input->set(node);
+	top()->data(input);
+}
+
+void XmlMagics::polyline(const XmlNode& node)
+{
+	SimplePolylineVisualiser* poly =  new SimplePolylineVisualiser();
+	poly->set(node);
+	top()->visdef(poly);
+}
+
+
+void  XmlMagics::symbol(const XmlNode& node)
+{	
+	if ( geographical_ ) {
+		SymbolPlotting* symbol =  new SymbolPlotting();
+		symbol->set(node);
+		top()->visdef(symbol);
+	}
+	else {
+		SymbolPlotting* symbol =  new SymbolPlotting();
+		symbol->set(node);
+		top()->visdef(symbol);
+	}
+}
+
+
+void XmlMagics::contour(const XmlNode& node)
+{
+	if ( geographical_ ) {
+		Contour* contour =  new Contour();
+		contour->set(node);
+		top()->visdef(contour);
+	}
+	else {
+		Contour* contour =  new Contour();
+		contour->set(node);
+		top()->visdef(contour);
+	}
+}
+
+
+void XmlMagics::image(const XmlNode& node)
+{
+	if ( geographical_ ) {
+		ImagePlotting* image =  new ImagePlotting();
+		image->set(node);
+		top()->visdef(image);
+	}
+	else {
+		ImagePlotting* image =  new ImagePlotting();
+		image->set(node);
+		top()->visdef(image);
+	}
+}
+
+#include "ImportObjectHandler.h"
+void XmlMagics::import(const XmlNode& node)
+{
+	ImportObjectHandler* object = new ImportObjectHandler();
+	object->set(node);
+	top()->push_back(object);
+
+}
+void XmlMagics::wind(const XmlNode& node)
+{	
+	if ( geographical_ ) {
+		Wind* wind =  new Wind();
+		wind->set(node);
+		top()->visdef(wind);
+	}
+	else {
+		MagLog::warning() << " wind not yet implemented for cartesian system" << endl;
+	}
+#ifdef MAGICS_GRIB
+	if ( gribloop_ ) gribloop_->next();
+#endif
+}
diff --git a/src/basic/XmlMagics.h b/src/basic/XmlMagics.h
new file mode 100644
index 0000000..5d0eeb9
--- /dev/null
+++ b/src/basic/XmlMagics.h
@@ -0,0 +1,169 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlMagics.h
+    \brief Definition of the Template class XmlMagics.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 3-Apr-2007
+    
+    Changes:
+    
+*/
+
+#ifndef XmlMagics_H
+#define XmlMagics_H
+
+#include "magics.h"
+#include "XmlNode.h"
+#include "DriverManager.h"
+#include "OutputHandler.h"
+#include "RootSceneNode.h"
+#include "MagicsObserver.h"
+
+
+
+namespace magics {
+
+class GribLoop;
+class XmlTree;
+
+
+class XmlMagics : public XmlNodeVisitor, 
+	public stack<BasicSceneObject*>, 
+	public vector<MagicsObserver*>
+{
+public:
+	XmlMagics(); 
+	~XmlMagics();
+	
+	void execute(const string&, std::map<string, string>& metadata);
+	void execute(const string& magml)
+	{
+		std::map<string, string> data;
+		execute(magml, data);
+	}
+	void execute(XmlTree& magml);
+	
+	void visit(const XmlNode& node);
+
+	void magics(const XmlNode&);
+
+	void page(const XmlNode&);
+	void binary(const XmlNode&);
+	void import(const XmlNode&);
+	void text(const XmlNode&);
+	void map(const XmlNode&);
+	void coastlines(const XmlNode&);
+	void taylor(const XmlNode&);
+	void landgram(const XmlNode&);
+	void layer(const XmlNode&);
+	void grib(const XmlNode&);
+	void table(const XmlNode&);
+	void geopoints(const XmlNode&);
+	void netcdf(const XmlNode&);
+	void xyinput(const XmlNode&);
+	void input(const XmlNode&);
+	void odb(const XmlNode&);
+	void oda(const XmlNode&);
+	void contour(const XmlNode&);
+	void histogram(const XmlNode&);
+	void wind(const XmlNode&);
+	void symbol(const XmlNode&);
+	void matrix(const XmlNode&);
+	void landgrambox(const XmlNode&);
+	void cartesian(const XmlNode&);
+	void geographical(const XmlNode&);
+
+	void driver(const XmlNode&);
+
+	void legend(const XmlNode&);
+	void image(const XmlNode&);
+
+	void horizontalAxis(const XmlNode&);
+	void verticalAxis(const XmlNode&);
+
+	void efigraph(const XmlNode&);
+	void cdfgraph(const XmlNode&);
+	void efigram(const XmlNode&);
+
+	void metgraph(const XmlNode&);
+	void metgram(const XmlNode&);
+
+	void epsgraph(const XmlNode&);
+	void epsgram(const XmlNode&);
+	void epsbufr(const XmlNode&);
+	void epsxml(const XmlNode&);
+	void wrepjson(const XmlNode&);
+	
+	void epswind(const XmlNode&);
+	void epscloud(const XmlNode&);
+	void epsbar(const XmlNode&);
+	void epswave(const XmlNode&);
+	void epsshading(const XmlNode&);
+	void epsplume(const XmlNode&);
+	void epsdirection(const XmlNode&);
+
+	void polyinput(const XmlNode&);
+	void polyline(const XmlNode&);
+
+	void mapgen(const XmlNode&);
+	
+	void graph(const XmlNode&);
+	
+	void gribloop(const XmlNode&);
+	
+	void gribinloop(const XmlNode&);
+	void splitinloop(const XmlNode&);
+	
+	void metadata(const XmlNode&);
+	void thread(const XmlNode&);
+	void split(const XmlNode&);
+
+	void display(const string&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream.
+	void print(ostream&) const; 
+	DriverManager		 drivers_;
+	XmlRootSceneNode*        root_;
+	OutputHandler            output_;
+	GribLoop*                gribloop_;
+	bool                     geographical_;
+	double                width_;
+
+	typedef void (XmlMagics::*Action)(const XmlNode&);
+
+	std::map<string, Action> actions_;
+	bool driversToSet_;
+
+private:
+	//! Copy constructor - No copy allowed
+	XmlMagics(const XmlMagics&);
+	//! Overloaded << operator to copy - No copy allowed
+	XmlMagics& operator=(const XmlMagics&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const XmlMagics& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/basic/XmlRootNodeAttributes.h b/src/basic/XmlRootNodeAttributes.h
new file mode 100644
index 0000000..7e2b25e
--- /dev/null
+++ b/src/basic/XmlRootNodeAttributes.h
@@ -0,0 +1,90 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file XmlRootNodeAttributes.h
+    \brief Definition of XmlRootNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef XmlRootNodeAttributes_H
+#define XmlRootNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class XmlRootNodeAttributes 
+{
+public:
+//  --  constructor
+    XmlRootNodeAttributes();
+    
+//  --  destructor
+    virtual ~XmlRootNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const XmlRootNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string format_;
+	string orientation_;
+	double width_;
+	double height_;
+	bool border_;
+	auto_ptr<Colour> border_colour_;
+	LineStyle border_style_;
+	int border_thickness_;
+	string application_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const XmlRootNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/XmlSceneNodeAttributes.h b/src/basic/XmlSceneNodeAttributes.h
new file mode 100644
index 0000000..5c83121
--- /dev/null
+++ b/src/basic/XmlSceneNodeAttributes.h
@@ -0,0 +1,106 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file XmlSceneNodeAttributes.h
+    \brief Definition of XmlSceneNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef XmlSceneNodeAttributes_H
+#define XmlSceneNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "PageID.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class XmlSceneNodeAttributes 
+{
+public:
+//  --  constructor
+    XmlSceneNodeAttributes();
+    
+//  --  destructor
+    virtual ~XmlSceneNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const XmlSceneNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	DisplayType display_;
+	string bottom_;
+	string left_;
+	string width_;
+	string height_;
+	string margin_bottom_;
+	string margin_left_;
+	string margin_right_;
+	string margin_top_;
+	auto_ptr<Colour> background_;
+	string border_bottom_;
+	string border_left_;
+	string border_right_;
+	bool border_;
+	string border_top_;
+	auto_ptr<Colour> border_colour_;
+	LineStyle border_style_;
+	int border_thickness_;
+	string padding_bottom_;
+	string padding_left_;
+	string padding_right_;
+	string padding_top_;
+	auto_ptr<Colour> padding_colour_;
+	auto_ptr<NoPageID> page_id_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const XmlSceneNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/basic/XmlViewNodeAttributes.h b/src/basic/XmlViewNodeAttributes.h
new file mode 100644
index 0000000..68aec76
--- /dev/null
+++ b/src/basic/XmlViewNodeAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file XmlViewNodeAttributes.h
+    \brief Definition of XmlViewNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef XmlViewNodeAttributes_H
+#define XmlViewNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Transformation.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class XmlViewNodeAttributes 
+{
+public:
+//  --  constructor
+    XmlViewNodeAttributes();
+    
+//  --  destructor
+    virtual ~XmlViewNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const XmlViewNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string fitted_;
+	auto_ptr<Transformation> transformation_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const XmlViewNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/boost/README.update_boost b/src/boost/README.update_boost
new file mode 100644
index 0000000..51fde66
--- /dev/null
+++ b/src/boost/README.update_boost
@@ -0,0 +1,23 @@
+### PREP
+
+cd /hugetmp/boost-trunk/boost
+svn update
+
+
+### UPDATE
+
+ma
+cd src/boost/
+p4 edit ...
+rm -rf geometry/ range/
+cp -R /hugetmp/boost\-trunk/boost/geometry .
+cp -R /hugetmp/boost\-trunk/boost/range .
+p4 revert -a ...
+
+rm -rf src/boost/*/*/.svn src/boost/*/*/*/.svn src/boost/*/*/*/*/.svn
+rm -rf src/boost/*/*/*/*/*/.svn src/boost/*/*/*/*/*/*/.svn
+
+p4 add */* */*/* */*/*/* */*/*/*/* */*/*/*/*/* */*/*/*/*/*/*
+
+>>> BE AWARE OF  src/boost/geometry/views/reversible_view.hpp
+
diff --git a/src/boost/geometry/algorithms/append.hpp b/src/boost/geometry/algorithms/append.hpp
new file mode 100644
index 0000000..72b2bba
--- /dev/null
+++ b/src/boost/geometry/algorithms/append.hpp
@@ -0,0 +1,233 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_APPEND_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_APPEND_HPP
+
+#include <boost/range.hpp>
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/algorithms/num_interior_rings.hpp>
+#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace append
+{
+
+template <typename Geometry, typename Point>
+struct append_no_action
+{
+    static inline void apply(Geometry& , Point const& ,
+                int = 0, int = 0)
+    {
+    }
+};
+
+template <typename Geometry, typename Point>
+struct append_point
+{
+    static inline void apply(Geometry& geometry, Point const& point,
+                int = 0, int = 0)
+    {
+        typename geometry::point_type<Geometry>::type copy;
+        geometry::detail::conversion::convert_point_to_point(point, copy);
+        traits::push_back<Geometry>::apply(geometry, copy);
+    }
+};
+
+
+template <typename Geometry, typename Range>
+struct append_range
+{
+    typedef typename boost::range_value<Range>::type point_type;
+
+    static inline void apply(Geometry& geometry, Range const& range,
+                int = 0, int = 0)
+    {
+        for (typename boost::range_iterator<Range const>::type
+            it = boost::begin(range);
+             it != boost::end(range);
+             ++it)
+        {
+            append_point<Geometry, point_type>::apply(geometry, *it);
+        }
+    }
+};
+
+
+template <typename Polygon, typename Point>
+struct point_to_polygon
+{
+    typedef typename ring_type<Polygon>::type ring_type;
+
+    static inline void apply(Polygon& polygon, Point const& point,
+                int ring_index, int = 0)
+    {
+        if (ring_index == -1)
+        {
+            append_point<ring_type, Point>::apply(
+                        exterior_ring(polygon), point);
+        }
+        else if (ring_index < int(num_interior_rings(polygon)))
+        {
+            append_point<ring_type, Point>::apply(
+                        interior_rings(polygon)[ring_index], point);
+        }
+    }
+};
+
+
+template <typename Polygon, typename Range>
+struct range_to_polygon
+{
+    typedef typename ring_type<Polygon>::type ring_type;
+
+    static inline void apply(Polygon& polygon, Range const& range,
+                int ring_index, int )
+    {
+        if (ring_index == -1)
+        {
+            append_range<ring_type, Range>::apply(
+                        exterior_ring(polygon), range);
+        }
+        else if (ring_index < int(num_interior_rings(polygon)))
+        {
+            append_range<ring_type, Range>::apply(
+                        interior_rings(polygon)[ring_index], range);
+        }
+    }
+};
+
+
+}} // namespace detail::append
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+namespace splitted_dispatch
+{
+
+template <typename Tag, typename Geometry, typename Point>
+struct append_point
+    : detail::append::append_no_action<Geometry, Point>
+{};
+
+template <typename Geometry, typename Point>
+struct append_point<linestring_tag, Geometry, Point>
+    : detail::append::append_point<Geometry, Point>
+{};
+
+template <typename Geometry, typename Point>
+struct append_point<ring_tag, Geometry, Point>
+    : detail::append::append_point<Geometry, Point>
+{};
+
+
+template <typename Polygon, typename Point>
+struct append_point<polygon_tag, Polygon, Point>
+        : detail::append::point_to_polygon<Polygon, Point>
+{};
+
+
+template <typename Tag, typename Geometry, typename Range>
+struct append_range
+    : detail::append::append_no_action<Geometry, Range>
+{};
+
+template <typename Geometry, typename Range>
+struct append_range<linestring_tag, Geometry, Range>
+    : detail::append::append_range<Geometry, Range>
+{};
+
+template <typename Geometry, typename Range>
+struct append_range<ring_tag, Geometry, Range>
+    : detail::append::append_range<Geometry, Range>
+{};
+
+
+template <typename Polygon, typename Range>
+struct append_range<polygon_tag, Polygon, Range>
+        : detail::append::range_to_polygon<Polygon, Range>
+{};
+
+}
+
+
+// Default: append a range (or linestring or ring or whatever) to any geometry
+template
+<
+    typename Geometry, typename RangeOrPoint,
+    typename TagRangeOrPoint = typename tag<RangeOrPoint>::type
+>
+struct append
+    : splitted_dispatch::append_range<typename tag<Geometry>::type, Geometry, RangeOrPoint>
+{};
+
+// Specialization for point to append a point to any geometry
+template <typename Geometry, typename RangeOrPoint>
+struct append<Geometry, RangeOrPoint, point_tag>
+    : splitted_dispatch::append_point<typename tag<Geometry>::type, Geometry, RangeOrPoint>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Appends one or more points to a linestring, ring, polygon, multi-geometry
+\ingroup append
+\tparam Geometry \tparam_geometry
+\tparam RangeOrPoint Either a range or a point, fullfilling Boost.Range concept or Boost.Geometry Point Concept
+\param geometry \param_geometry
+\param range_or_point The point or range to add
+\param ring_index The index of the ring in case of a polygon:
+    exterior ring (-1, the default) or  interior ring index
+\param multi_index Reserved for multi polygons or multi linestrings
+
+\qbk{[include reference/algorithms/append.qbk]}
+}
+ */
+template <typename Geometry, typename RangeOrPoint>
+inline void append(Geometry& geometry, RangeOrPoint const& range_or_point,
+            int ring_index = -1, int multi_index = 0)
+{
+    concept::check<Geometry>();
+
+    dispatch::append
+        <
+            Geometry,
+            RangeOrPoint
+        >::apply(geometry, range_or_point, ring_index, multi_index);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_APPEND_HPP
diff --git a/src/boost/geometry/algorithms/area.hpp b/src/boost/geometry/algorithms/area.hpp
new file mode 100644
index 0000000..8193200
--- /dev/null
+++ b/src/boost/geometry/algorithms/area.hpp
@@ -0,0 +1,295 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
+
+#include <boost/concept_check.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/detail/calculate_null.hpp>
+#include <boost/geometry/algorithms/detail/calculate_sum.hpp>
+// #include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
+
+#include <boost/geometry/strategies/area.hpp>
+#include <boost/geometry/strategies/default_area_result.hpp>
+
+#include <boost/geometry/strategies/concepts/area_concept.hpp>
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/order_as_direction.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace area
+{
+
+template<typename Box, typename Strategy>
+struct box_area
+{
+    typedef typename coordinate_type<Box>::type return_type;
+
+    static inline return_type apply(Box const& box, Strategy const&)
+    {
+        // Currently only works for 2D Cartesian boxes
+        assert_dimension<Box, 2>();
+
+        return_type const dx = get<max_corner, 0>(box)
+                - get<min_corner, 0>(box);
+        return_type const dy = get<max_corner, 1>(box)
+                - get<min_corner, 1>(box);
+
+        return dx * dy;
+    }
+};
+
+
+template
+<
+    typename Ring,
+    iterate_direction Direction,
+    closure_selector Closure,
+    typename Strategy
+>
+struct ring_area
+{
+    BOOST_CONCEPT_ASSERT( (geometry::concept::AreaStrategy<Strategy>) );
+
+    typedef typename Strategy::return_type type;
+
+    static inline type apply(Ring const& ring, Strategy const& strategy)
+    {
+        assert_dimension<Ring, 2>();
+
+        // Ignore warning (because using static method sometimes) on strategy
+        boost::ignore_unused_variable_warning(strategy);
+
+        // An open ring has at least three points,
+        // A closed ring has at least four points,
+        // if not, there is no (zero) area
+        if (int(boost::size(ring))
+                < core_detail::closure::minimum_ring_size<Closure>::value)
+        {
+            return type();
+        }
+
+        typedef typename reversible_view<Ring const, Direction>::type rview_type;
+        typedef typename closeable_view
+            <
+                rview_type const, Closure
+            >::type view_type;
+        typedef typename boost::range_iterator<view_type const>::type iterator_type;
+
+        rview_type rview(ring);
+        view_type view(rview);
+        typename Strategy::state_type state;
+        iterator_type it = boost::begin(view);
+        iterator_type end = boost::end(view);
+
+        for (iterator_type previous = it++;
+            it != end;
+            ++previous, ++it)
+        {
+            strategy.apply(*previous, *it, state);
+        }
+
+        return strategy.result(state);
+    }
+};
+
+
+}} // namespace detail::area
+
+
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Geometry,
+    typename Strategy = typename strategy::area::services::default_strategy
+                                 <
+                                     typename cs_tag
+                                     <
+                                         typename point_type<Geometry>::type
+                                     >::type,
+                                     typename point_type<Geometry>::type
+                                 >::type,
+    typename Tag = typename tag<Geometry>::type
+>
+struct area
+    : detail::calculate_null
+        <
+            typename Strategy::return_type,
+            Geometry,
+            Strategy
+        > {};
+
+
+template
+<
+    typename Geometry,
+    typename Strategy
+>
+struct area<Geometry, Strategy, box_tag>
+    : detail::area::box_area<Geometry, Strategy>
+{};
+
+
+template
+<
+    typename Ring,
+    typename Strategy
+>
+struct area<Ring, Strategy, ring_tag>
+    : detail::area::ring_area
+        <
+            Ring,
+            order_as_direction<geometry::point_order<Ring>::value>::value,
+            geometry::closure<Ring>::value,
+            Strategy
+        >
+{};
+
+
+template
+<
+    typename Polygon,
+    typename Strategy
+>
+struct area<Polygon, Strategy, polygon_tag>
+    : detail::calculate_polygon_sum
+        <
+            typename Strategy::return_type,
+            Polygon,
+            Strategy,
+            detail::area::ring_area
+                <
+                    typename ring_type<Polygon const>::type,
+                    order_as_direction<geometry::point_order<Polygon>::value>::value,
+                    geometry::closure<Polygon>::value,
+                    Strategy
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+/*!
+\brief \brief_calc{area}
+\ingroup area
+\details \details_calc{area}. \details_default_strategy
+
+The area algorithm calculates the surface area of all geometries having a surface, namely
+box, polygon, ring, multipolygon. The units are the square of the units used for the points
+defining the surface. If subject geometry is defined in meters, then area is calculated
+in square meters.
+
+The area calculation can be done in all three common coordinate systems, Cartesian, Spherical
+and Geographic as well.
+
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{area}
+
+\qbk{[include reference/algorithms/area.qbk]}
+\qbk{[heading Examples]}
+\qbk{[area] [area_output]}
+*/
+template <typename Geometry>
+inline typename default_area_result<Geometry>::type area(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename strategy::area::services::default_strategy
+        <
+            typename cs_tag<point_type>::type,
+            point_type
+        >::type strategy_type;
+
+    // detail::throw_on_empty_input(geometry);
+        
+    return dispatch::area
+        <
+            Geometry
+        >::apply(geometry, strategy_type());
+}
+
+/*!
+\brief \brief_calc{area} \brief_strategy
+\ingroup area
+\details \details_calc{area} \brief_strategy. \details_strategy_reasons
+\tparam Geometry \tparam_geometry
+\tparam Strategy \tparam_strategy{Area}
+\param geometry \param_geometry
+\param strategy \param_strategy{area}
+\return \return_calc{area}
+
+\qbk{distinguish,with strategy}
+
+\qbk{
+[include reference/algorithms/area.qbk]
+
+[heading Example]
+[area_with_strategy]
+[area_with_strategy_output]
+
+[heading Available Strategies]
+\* [link geometry.reference.strategies.strategy_area_surveyor Surveyor (cartesian)]
+\* [link geometry.reference.strategies.strategy_area_huiller Huiller (spherical)]
+}
+ */
+template <typename Geometry, typename Strategy>
+inline typename Strategy::return_type area(
+        Geometry const& geometry, Strategy const& strategy)
+{
+    concept::check<Geometry const>();
+
+    // detail::throw_on_empty_input(geometry);
+    
+    return dispatch::area
+        <
+            Geometry,
+            Strategy
+        >::apply(geometry, strategy);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
diff --git a/src/boost/geometry/algorithms/assign.hpp b/src/boost/geometry/algorithms/assign.hpp
new file mode 100644
index 0000000..8c153c8
--- /dev/null
+++ b/src/boost/geometry/algorithms/assign.hpp
@@ -0,0 +1,171 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_ASSIGN_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_ASSIGN_HPP
+
+
+#include <cstddef>
+
+#include <boost/concept/requires.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
+#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
+#include <boost/geometry/algorithms/detail/assign_values.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/for_each_coordinate.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Assign a range of points to a linestring, ring or polygon
+\note The point-type of the range might be different from the point-type of the geometry
+\ingroup assign
+\tparam Geometry \tparam_geometry
+\tparam Range \tparam_range_point
+\param geometry \param_geometry
+\param range \param_range_point
+
+\qbk{
+[heading Notes]
+[note Assign automatically clears the geometry before assigning (use append if you don't want that)]
+[heading Example]
+[assign_points] [assign_points_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.append append]
+}
+ */
+template <typename Geometry, typename Range>
+inline void assign_points(Geometry& geometry, Range const& range)
+{
+    concept::check<Geometry>();
+
+    clear(geometry);
+    geometry::append(geometry, range, -1, 0);
+}
+
+
+/*!
+\brief assign to a box inverse infinite
+\details The assign_inverse function initialize a 2D or 3D box with large coordinates, the
+min corner is very large, the max corner is very small. This is a convenient starting point to
+collect the minimum bounding box of a geometry.
+\ingroup assign
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+
+\qbk{
+[heading Example]
+[assign_inverse] [assign_inverse_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.make.make_inverse make_inverse]
+}
+ */
+template <typename Geometry>
+inline void assign_inverse(Geometry& geometry)
+{
+    concept::check<Geometry>();
+
+    dispatch::assign_inverse
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::apply(geometry);
+}
+
+/*!
+\brief assign zero values to a box, point
+\ingroup assign
+\details The assign_zero function initializes a 2D or 3D point or box with coordinates of zero
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+
+ */
+template <typename Geometry>
+inline void assign_zero(Geometry& geometry)
+{
+    concept::check<Geometry>();
+
+    dispatch::assign_zero
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::apply(geometry);
+}
+
+/*!
+\brief Assigns one geometry to another geometry
+\details The assign algorithm assigns one geometry, e.g. a BOX, to another geometry, e.g. a RING. This only
+if it is possible and applicable.
+\ingroup assign
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry (target)
+\param geometry2 \param_geometry (source)
+
+\qbk{
+[heading Example]
+[assign] [assign_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.convert convert]
+}
+ */
+template <typename Geometry1, typename Geometry2>
+inline void assign(Geometry1& geometry1, Geometry2 const& geometry2)
+{
+    concept::check_concepts_and_equal_dimensions<Geometry1, Geometry2 const>();
+
+    bool const same_point_order = 
+            point_order<Geometry1>::value == point_order<Geometry2>::value;
+    bool const same_closure = 
+            closure<Geometry1>::value == closure<Geometry2>::value;
+
+    BOOST_MPL_ASSERT_MSG
+        (
+            same_point_order, ASSIGN_IS_NOT_SUPPORTED_FOR_DIFFERENT_POINT_ORDER
+            , (types<Geometry1, Geometry2>)
+        );
+    BOOST_MPL_ASSERT_MSG
+        (
+            same_closure, ASSIGN_IS_NOT_SUPPORTED_FOR_DIFFERENT_CLOSURE
+            , (types<Geometry1, Geometry2>)
+        );
+
+    dispatch::convert<Geometry2, Geometry1>::apply(geometry2, geometry1);
+}
+
+
+}} // namespace boost::geometry
+
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_ASSIGN_HPP
diff --git a/src/boost/geometry/algorithms/buffer.hpp b/src/boost/geometry/algorithms/buffer.hpp
new file mode 100644
index 0000000..e22e36a
--- /dev/null
+++ b/src/boost/geometry/algorithms/buffer.hpp
@@ -0,0 +1,167 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_BUFFER_HPP
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t D, std::size_t N>
+struct box_loop
+{
+    typedef typename coordinate_type<BoxOut>::type coordinate_type;
+
+    static inline void apply(BoxIn const& box_in, T const& distance, BoxOut& box_out)
+    {
+        coordinate_type d = distance;
+        set<C, D>(box_out, get<C, D>(box_in) + d);
+        box_loop<BoxIn, BoxOut, T, C, D + 1, N>::apply(box_in, distance, box_out);
+    }
+};
+
+template <typename BoxIn, typename BoxOut, typename T, std::size_t C, std::size_t N>
+struct box_loop<BoxIn, BoxOut, T, C, N, N>
+{
+    static inline void apply(BoxIn const&, T const&, BoxOut&) {}
+};
+
+// Extends a box with the same amount in all directions
+template<typename BoxIn, typename BoxOut, typename T>
+inline void buffer_box(BoxIn const& box_in, T const& distance, BoxOut& box_out)
+{
+    assert_dimension_equal<BoxIn, BoxOut>();
+
+    static const std::size_t N = dimension<BoxIn>::value;
+
+    box_loop<BoxIn, BoxOut, T, min_corner, 0, N>::apply(box_in, -distance, box_out);
+    box_loop<BoxIn, BoxOut, T, max_corner, 0, N>::apply(box_in, distance, box_out);
+}
+
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename TagIn, typename TagOut, typename Input, typename T, typename Output>
+struct buffer {};
+
+
+template <typename BoxIn, typename T, typename BoxOut>
+struct buffer<box_tag, box_tag, BoxIn, T, BoxOut>
+{
+    static inline void apply(BoxIn const& box_in, T const& distance,
+                T const& , BoxIn& box_out)
+    {
+        detail::buffer::buffer_box(box_in, distance, box_out);
+    }
+};
+
+// Many things to do. Point is easy, other geometries require self intersections
+// For point, note that it should output as a polygon (like the rest). Buffers
+// of a set of geometries are often lateron combined using a "dissolve" operation.
+// Two points close to each other get a combined kidney shaped buffer then.
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_calc{buffer}
+\ingroup buffer
+\details \details_calc{buffer, \det_buffer}.
+\tparam Input \tparam_geometry
+\tparam Output \tparam_geometry
+\tparam Distance \tparam_numeric
+\param geometry_in \param_geometry
+\param geometry_out \param_geometry
+\param distance The distance to be used for the buffer
+\param chord_length (optional) The length of the chord's in the generated arcs around points or bends
+\note Currently only implemented for box, the trivial case, but still useful
+
+\qbk{[include reference/algorithms/buffer.qbk]}
+ */
+template <typename Input, typename Output, typename Distance>
+inline void buffer(Input const& geometry_in, Output& geometry_out,
+            Distance const& distance, Distance const& chord_length = -1)
+{
+    concept::check<Input const>();
+    concept::check<Output>();
+
+    dispatch::buffer
+        <
+            typename tag<Input>::type,
+            typename tag<Output>::type,
+            Input,
+            Distance,
+            Output
+        >::apply(geometry_in, distance, chord_length, geometry_out);
+}
+
+/*!
+\brief \brief_calc{buffer}
+\ingroup buffer
+\details \details_calc{return_buffer, \det_buffer}. \details_return{buffer}.
+\tparam Input \tparam_geometry
+\tparam Output \tparam_geometry
+\tparam Distance \tparam_numeric
+\param geometry \param_geometry
+\param distance The distance to be used for the buffer
+\param chord_length (optional) The length of the chord's in the generated arcs around points or bends
+\return \return_calc{buffer}
+ */
+template <typename Output, typename Input, typename T>
+Output return_buffer(Input const& geometry, T const& distance, T const& chord_length = -1)
+{
+    concept::check<Input const>();
+    concept::check<Output>();
+
+    Output geometry_out;
+
+    dispatch::buffer
+        <
+            typename tag<Input>::type,
+            typename tag<Output>::type,
+            Input,
+            T,
+            Output
+        >::apply(geometry, distance, chord_length, geometry_out);
+
+    return geometry_out;
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_BUFFER_HPP
diff --git a/src/boost/geometry/algorithms/centroid.hpp b/src/boost/geometry/algorithms/centroid.hpp
new file mode 100644
index 0000000..69ad9fe
--- /dev/null
+++ b/src/boost/geometry/algorithms/centroid.hpp
@@ -0,0 +1,470 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_CENTROID_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_CENTROID_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/exception.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/centroid.hpp>
+#include <boost/geometry/strategies/concepts/centroid_concept.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+
+#include <boost/geometry/util/for_each_coordinate.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#if ! defined(BOOST_GEOMETRY_CENTROID_NO_THROW)
+
+/*!
+\brief Centroid Exception
+\ingroup centroid
+\details The centroid_exception is thrown if the free centroid function is called with
+    geometries for which the centroid cannot be calculated. For example: a linestring
+    without points, a polygon without points, an empty multi-geometry.
+\qbk{
+[heading See also]
+\* [link geometry.reference.algorithms.centroid the centroid function]
+}
+
+ */
+class centroid_exception : public geometry::exception
+{
+public:
+
+    inline centroid_exception() {}
+
+    virtual char const* what() const throw()
+    {
+        return "Boost.Geometry Centroid calculation exception";
+    }
+};
+
+#endif
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace centroid
+{
+
+template<typename Point, typename PointCentroid, typename Strategy>
+struct centroid_point
+{
+    static inline void apply(Point const& point, PointCentroid& centroid,
+            Strategy const&)
+    {
+        geometry::convert(point, centroid);
+    }
+};
+
+template
+<
+    typename Box,
+    typename Point,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct centroid_box_calculator
+{
+    typedef typename select_coordinate_type
+        <
+            Box, Point
+        >::type coordinate_type;
+    static inline void apply(Box const& box, Point& centroid)
+    {
+        coordinate_type const c1 = get<min_corner, Dimension>(box);
+        coordinate_type const c2 = get<max_corner, Dimension>(box);
+        coordinate_type m = c1 + c2;
+        m /= 2.0;
+
+        set<Dimension>(centroid, m);
+
+        centroid_box_calculator
+            <
+                Box, Point,
+                Dimension + 1, DimensionCount
+            >::apply(box, centroid);
+    }
+};
+
+
+template<typename Box, typename Point, std::size_t DimensionCount>
+struct centroid_box_calculator<Box, Point, DimensionCount, DimensionCount>
+{
+    static inline void apply(Box const& , Point& )
+    {
+    }
+};
+
+
+template<typename Box, typename Point, typename Strategy>
+struct centroid_box
+{
+    static inline void apply(Box const& box, Point& centroid,
+            Strategy const&)
+    {
+        centroid_box_calculator
+            <
+                Box, Point,
+                0, dimension<Box>::type::value
+            >::apply(box, centroid);
+    }
+};
+
+
+// There is one thing where centroid is different from e.g. within.
+// If the ring has only one point, it might make sense that
+// that point is the centroid.
+template<typename Point, typename Range>
+inline bool range_ok(Range const& range, Point& centroid)
+{
+    std::size_t const n = boost::size(range);
+    if (n > 1)
+    {
+        return true;
+    }
+    else if (n <= 0)
+    {
+#if ! defined(BOOST_GEOMETRY_CENTROID_NO_THROW)
+        throw centroid_exception();
+#endif
+        return false;
+    }
+    else // if (n == 1)
+    {
+        // Take over the first point in a "coordinate neutral way"
+        geometry::convert(*boost::begin(range), centroid);
+        return false;
+    }
+    return true;
+}
+
+
+/*!
+    \brief Calculate the centroid of a ring.
+*/
+template<typename Ring, closure_selector Closure, typename Strategy>
+struct centroid_range_state
+{
+    static inline void apply(Ring const& ring,
+            Strategy const& strategy, typename Strategy::state_type& state)
+    {
+        typedef typename closeable_view<Ring const, Closure>::type view_type;
+
+        typedef typename boost::range_iterator<view_type const>::type iterator_type;
+
+        view_type view(ring);
+        iterator_type it = boost::begin(view);
+        iterator_type end = boost::end(view);
+
+        for (iterator_type previous = it++;
+            it != end;
+            ++previous, ++it)
+        {
+            strategy.apply(*previous, *it, state);
+        }
+    }
+};
+
+template<typename Range, typename Point, closure_selector Closure, typename Strategy>
+struct centroid_range
+{
+    static inline void apply(Range const& range, Point& centroid,
+            Strategy const& strategy)
+    {
+        if (range_ok(range, centroid))
+        {
+            typename Strategy::state_type state;
+            centroid_range_state
+                <
+                    Range,
+                    Closure,
+                    Strategy
+                >::apply(range, strategy, state);
+            strategy.result(state, centroid);
+        }
+    }
+};
+
+
+/*!
+    \brief Centroid of a polygon.
+    \note Because outer ring is clockwise, inners are counter clockwise,
+    triangle approach is OK and works for polygons with rings.
+*/
+template<typename Polygon, typename Strategy>
+struct centroid_polygon_state
+{
+    typedef typename ring_type<Polygon>::type ring_type;
+
+    static inline void apply(Polygon const& poly,
+            Strategy const& strategy, typename Strategy::state_type& state)
+    {
+        typedef centroid_range_state
+            <
+                ring_type,
+                geometry::closure<ring_type>::value,
+                Strategy
+            > per_ring;
+
+        per_ring::apply(exterior_ring(poly), strategy, state);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            per_ring::apply(*it, strategy, state);
+        }
+    }
+};
+
+template<typename Polygon, typename Point, typename Strategy>
+struct centroid_polygon
+{
+    static inline void apply(Polygon const& poly, Point& centroid,
+            Strategy const& strategy)
+    {
+        if (range_ok(exterior_ring(poly), centroid))
+        {
+            typename Strategy::state_type state;
+            centroid_polygon_state
+                <
+                    Polygon,
+                    Strategy
+                >::apply(poly, strategy, state);
+            strategy.result(state, centroid);
+        }
+    }
+};
+
+
+}} // namespace detail::centroid
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename Point,
+    typename Strategy
+>
+struct centroid {};
+
+template
+<
+    typename Geometry,
+    typename Point,
+    typename Strategy
+>
+struct centroid<point_tag, Geometry, Point, Strategy>
+    : detail::centroid::centroid_point<Geometry, Point, Strategy>
+{};
+
+template
+<
+    typename Box,
+    typename Point,
+    typename Strategy
+>
+struct centroid<box_tag, Box, Point, Strategy>
+    : detail::centroid::centroid_box<Box, Point, Strategy>
+{};
+
+template <typename Ring, typename Point, typename Strategy>
+struct centroid<ring_tag, Ring, Point, Strategy>
+    : detail::centroid::centroid_range
+        <
+            Ring,
+            Point,
+            geometry::closure<Ring>::value,
+            Strategy
+        >
+{};
+
+template <typename Linestring, typename Point, typename Strategy>
+struct centroid<linestring_tag, Linestring, Point, Strategy>
+    : detail::centroid::centroid_range
+        <
+            Linestring,
+            Point,
+            closed,
+            Strategy
+        >
+ {};
+
+template <typename Polygon, typename Point, typename Strategy>
+struct centroid<polygon_tag, Polygon, Point, Strategy>
+    : detail::centroid::centroid_polygon<Polygon, Point, Strategy>
+ {};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_calc{centroid} \brief_strategy
+\ingroup centroid
+\details \details_calc{centroid,geometric center (or: center of mass)}. \details_strategy_reasons
+\tparam Geometry \tparam_geometry
+\tparam Point \tparam_point
+\tparam Strategy \tparam_strategy{Centroid}
+\param geometry \param_geometry
+\param c \param_point \param_set{centroid}
+\param strategy \param_strategy{centroid}
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/centroid.qbk]}
+\qbk{[include reference/algorithms/centroid_strategies.qbk]}
+}
+
+*/
+template<typename Geometry, typename Point, typename Strategy>
+inline void centroid(Geometry const& geometry, Point& c,
+        Strategy const& strategy)
+{
+    //BOOST_CONCEPT_ASSERT( (geometry::concept::CentroidStrategy<Strategy>) );
+
+    concept::check_concepts_and_equal_dimensions<Point, Geometry const>();
+
+    typedef typename point_type<Geometry>::type point_type;
+
+    // Call dispatch apply method. That one returns true if centroid
+    // should be taken from state.
+    dispatch::centroid
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Point,
+            Strategy
+        >::apply(geometry, c, strategy);
+}
+
+
+/*!
+\brief \brief_calc{centroid}
+\ingroup centroid
+\details \details_calc{centroid,geometric center (or: center of mass)}. \details_default_strategy
+\tparam Geometry \tparam_geometry
+\tparam Point \tparam_point
+\param geometry \param_geometry
+\param c The calculated centroid will be assigned to this point reference
+
+\qbk{[include reference/algorithms/centroid.qbk]}
+\qbk{
+[heading Example]
+[centroid]
+[centroid_output]
+}
+ */
+template<typename Geometry, typename Point>
+inline void centroid(Geometry const& geometry, Point& c)
+{
+    concept::check_concepts_and_equal_dimensions<Point, Geometry const>();
+
+    typedef typename strategy::centroid::services::default_strategy
+        <
+            typename cs_tag<Geometry>::type,
+            typename tag_cast
+                <
+                    typename tag<Geometry>::type,
+                    pointlike_tag,
+                    linear_tag,
+                    areal_tag
+                >::type,
+            dimension<Geometry>::type::value,
+            Point,
+            Geometry
+        >::type strategy_type;
+
+    centroid(geometry, c, strategy_type());
+}
+
+
+/*!
+\brief \brief_calc{centroid}
+\ingroup centroid
+\details \details_calc{centroid,geometric center (or: center of mass)}. \details_return{centroid}.
+\tparam Point \tparam_point
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{centroid}
+
+\qbk{[include reference/algorithms/centroid.qbk]}
+ */
+template<typename Point, typename Geometry>
+inline Point return_centroid(Geometry const& geometry)
+{
+    concept::check_concepts_and_equal_dimensions<Point, Geometry const>();
+
+    Point c;
+    centroid(geometry, c);
+    return c;
+}
+
+/*!
+\brief \brief_calc{centroid} \brief_strategy
+\ingroup centroid
+\details \details_calc{centroid,geometric center (or: center of mass)}. \details_return{centroid}. \details_strategy_reasons
+\tparam Point \tparam_point
+\tparam Geometry \tparam_geometry
+\tparam Strategy \tparam_strategy{centroid}
+\param geometry \param_geometry
+\param strategy \param_strategy{centroid}
+\return \return_calc{centroid}
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/centroid.qbk]}
+\qbk{[include reference/algorithms/centroid_strategies.qbk]}
+ */
+template<typename Point, typename Geometry, typename Strategy>
+inline Point return_centroid(Geometry const& geometry, Strategy const& strategy)
+{
+    //BOOST_CONCEPT_ASSERT( (geometry::concept::CentroidStrategy<Strategy>) );
+
+    concept::check_concepts_and_equal_dimensions<Point, Geometry const>();
+
+    Point c;
+    centroid(geometry, c, strategy);
+    return c;
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_CENTROID_HPP
diff --git a/src/boost/geometry/algorithms/clear.hpp b/src/boost/geometry/algorithms/clear.hpp
new file mode 100644
index 0000000..d733658
--- /dev/null
+++ b/src/boost/geometry/algorithms/clear.hpp
@@ -0,0 +1,159 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace clear
+{
+
+template <typename Geometry>
+struct collection_clear
+{
+    static inline void apply(Geometry& geometry)
+    {
+        traits::clear<Geometry>::apply(geometry);
+    }
+};
+
+template <typename Polygon>
+struct polygon_clear
+{
+    static inline void apply(Polygon& polygon)
+    {
+        traits::clear
+            <
+                typename boost::remove_reference
+                    <
+                        typename traits::interior_mutable_type<Polygon>::type
+                    >::type
+            >::apply(interior_rings(polygon));
+        traits::clear
+            <
+                typename boost::remove_reference
+                    <
+                        typename traits::ring_mutable_type<Polygon>::type
+                    >::type
+            >::apply(exterior_ring(polygon));
+    }
+};
+
+template <typename Geometry>
+struct no_action
+{
+    static inline void apply(Geometry& )
+    {
+    }
+};
+
+}} // namespace detail::clear
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Geometry,
+    typename Tag = typename tag_cast<typename tag<Geometry>::type, multi_tag>::type
+>
+struct clear
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+// Point/box/segment do not have clear. So specialize to do nothing.
+template <typename Geometry>
+struct clear<Geometry, point_tag>
+    : detail::clear::no_action<Geometry>
+{};
+
+template <typename Geometry>
+struct clear<Geometry, box_tag>
+    : detail::clear::no_action<Geometry>
+{};
+
+template <typename Geometry>
+struct clear<Geometry, segment_tag>
+    : detail::clear::no_action<Geometry>
+{};
+
+template <typename Geometry>
+struct clear<Geometry, linestring_tag>
+    : detail::clear::collection_clear<Geometry>
+{};
+
+template <typename Geometry>
+struct clear<Geometry, ring_tag>
+    : detail::clear::collection_clear<Geometry>
+{};
+
+
+// Polygon can (indirectly) use std for clear
+template <typename Polygon>
+struct clear<Polygon, polygon_tag>
+    : detail::clear::polygon_clear<Polygon>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Clears a linestring, ring or polygon (exterior+interiors) or multi*
+\details Generic function to clear a geometry. All points will be removed from the collection or collections
+    making up the geometry. In most cases this is equivalent to the .clear() method of a std::vector<...>. In
+    the case of a polygon, this clear functionality is automatically called for the exterior ring, and for the
+    interior ring collection. In the case of a point, boxes and segments, nothing will happen.
+\ingroup clear
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry which will be cleared
+\note points and boxes cannot be cleared, instead they can be set to zero by "assign_zero"
+
+\qbk{[include reference/algorithms/clear.qbk]}
+*/
+template <typename Geometry>
+inline void clear(Geometry& geometry)
+{
+    concept::check<Geometry>();
+
+    dispatch::clear<Geometry>::apply(geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP
diff --git a/src/boost/geometry/algorithms/comparable_distance.hpp b/src/boost/geometry/algorithms/comparable_distance.hpp
new file mode 100644
index 0000000..3467045
--- /dev/null
+++ b/src/boost/geometry/algorithms/comparable_distance.hpp
@@ -0,0 +1,74 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
+
+
+#include <boost/geometry/algorithms/distance.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief \brief_calc2{comparable distance measurement}
+\ingroup distance
+\details The free function comparable_distance does not necessarily calculate the distance,
+    but it calculates a distance measure such that two distances are comparable to each other.
+    For example: for the Cartesian coordinate system, Pythagoras is used but the square root
+    is not taken, which makes it faster and the results of two point pairs can still be 
+    compared to each other.
+\tparam Geometry1 first geometry type
+\tparam Geometry2 second geometry type
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return \return_calc{comparable distance}
+
+\qbk{[include reference/algorithms/comparable_distance.qbk]}
+ */
+template <typename Geometry1, typename Geometry2>
+inline typename default_distance_result<Geometry1, Geometry2>::type comparable_distance(
+                Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    typedef typename point_type<Geometry1>::type point1_type;
+    typedef typename point_type<Geometry2>::type point2_type;
+
+    // Define a point-point-distance-strategy
+    // for either the normal case, either the reversed case
+
+    typedef typename strategy::distance::services::comparable_type
+        <
+            typename boost::mpl::if_c
+                <
+                    geometry::reverse_dispatch
+                        <Geometry1, Geometry2>::type::value,
+                    typename strategy::distance::services::default_strategy
+                            <point_tag, point2_type, point1_type>::type,
+                    typename strategy::distance::services::default_strategy
+                            <point_tag, point1_type, point2_type>::type
+                >::type
+        >::type strategy_type;
+
+    return distance(geometry1, geometry2, strategy_type());
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
diff --git a/src/boost/geometry/algorithms/convert.hpp b/src/boost/geometry/algorithms/convert.hpp
new file mode 100644
index 0000000..fbbf74c
--- /dev/null
+++ b/src/boost/geometry/algorithms/convert.hpp
@@ -0,0 +1,411 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_CONVERT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_CONVERT_HPP
+
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/range.hpp>
+#include <boost/type_traits/is_array.hpp>
+
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/algorithms/not_implemented.hpp>
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/for_each.hpp>
+#include <boost/geometry/algorithms/detail/assign_values.hpp>
+#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
+#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
+#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
+#include <boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp>
+
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace conversion
+{
+
+template
+<
+    typename Point,
+    typename Box,
+    std::size_t Index,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct point_to_box
+{
+    static inline void apply(Point const& point, Box& box)
+    {
+        typedef typename coordinate_type<Box>::type coordinate_type;
+
+        set<Index, Dimension>(box,
+                boost::numeric_cast<coordinate_type>(get<Dimension>(point)));
+        point_to_box
+            <
+                Point, Box,
+                Index, Dimension + 1, DimensionCount
+            >::apply(point, box);
+    }
+};
+
+
+template
+<
+    typename Point,
+    typename Box,
+    std::size_t Index,
+    std::size_t DimensionCount
+>
+struct point_to_box<Point, Box, Index, DimensionCount, DimensionCount>
+{
+    static inline void apply(Point const& , Box& )
+    {}
+};
+
+template <typename Box, typename Range, bool Close, bool Reverse>
+struct box_to_range
+{
+    static inline void apply(Box const& box, Range& range)
+    {
+        traits::resize<Range>::apply(range, Close ? 5 : 4);
+        assign_box_corners_oriented<Reverse>(box, range);
+        if (Close)
+        {
+            range[4] = range[0];
+        }
+    }
+};
+
+template <typename Segment, typename Range>
+struct segment_to_range
+{
+    static inline void apply(Segment const& segment, Range& range)
+    {
+        traits::resize<Range>::apply(range, 2);
+
+        typename boost::range_iterator<Range>::type it = boost::begin(range);
+
+        assign_point_from_index<0>(segment, *it);
+        ++it;
+        assign_point_from_index<1>(segment, *it);
+    }
+};
+
+template 
+<
+    typename Range1, 
+    typename Range2, 
+    bool Reverse = false
+>
+struct range_to_range
+{
+    typedef typename reversible_view
+        <
+            Range1 const, 
+            Reverse ? iterate_reverse : iterate_forward
+        >::type rview_type;
+    typedef typename closeable_view
+        <
+            rview_type const, 
+            geometry::closure<Range1>::value
+        >::type view_type;
+
+    static inline void apply(Range1 const& source, Range2& destination)
+    {
+        geometry::clear(destination);
+
+        rview_type rview(source);
+
+        // We consider input always as closed, and skip last
+        // point for open output.
+        view_type view(rview);
+
+        int n = boost::size(view);
+        if (geometry::closure<Range2>::value == geometry::open)
+        {
+            n--;
+        }
+
+        int i = 0;
+        for (typename boost::range_iterator<view_type const>::type it
+            = boost::begin(view);
+            it != boost::end(view) && i < n;
+            ++it, ++i)
+        {
+            geometry::append(destination, *it);
+        }
+    }
+};
+
+template <typename Polygon1, typename Polygon2>
+struct polygon_to_polygon
+{
+    typedef range_to_range
+        <
+            typename geometry::ring_type<Polygon1>::type, 
+            typename geometry::ring_type<Polygon2>::type,
+            geometry::point_order<Polygon1>::value
+                != geometry::point_order<Polygon2>::value
+        > per_ring;
+
+    static inline void apply(Polygon1 const& source, Polygon2& destination)
+    {
+        // Clearing managed per ring, and in the resizing of interior rings
+
+        per_ring::apply(geometry::exterior_ring(source), 
+            geometry::exterior_ring(destination));
+
+        // Container should be resizeable
+        traits::resize
+            <
+                typename boost::remove_reference
+                <
+                    typename traits::interior_mutable_type<Polygon2>::type
+                >::type
+            >::apply(interior_rings(destination), num_interior_rings(source));
+
+        typename interior_return_type<Polygon1 const>::type rings_source
+                    = interior_rings(source);
+        typename interior_return_type<Polygon2>::type rings_dest
+                    = interior_rings(destination);
+
+        BOOST_AUTO_TPL(it_source, boost::begin(rings_source));
+        BOOST_AUTO_TPL(it_dest, boost::begin(rings_dest));
+
+        for ( ; it_source != boost::end(rings_source); ++it_source, ++it_dest)
+        {
+            per_ring::apply(*it_source, *it_dest);
+        }
+    }
+};
+
+
+}} // namespace detail::conversion
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    typename Tag1 = typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
+    typename Tag2 = typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
+    std::size_t DimensionCount = dimension<Geometry1>::type::value,
+    bool UseAssignment = boost::is_same<Geometry1, Geometry2>::value
+                         && !boost::is_array<Geometry1>::value
+>
+struct convert: not_implemented<Tag1, Tag2, mpl::int_<DimensionCount> >
+{};
+
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    typename Tag,
+    std::size_t DimensionCount
+>
+struct convert<Geometry1, Geometry2, Tag, Tag, DimensionCount, true>
+{
+    // Same geometry type -> copy whole geometry
+    static inline void apply(Geometry1 const& source, Geometry2& destination)
+    {
+        destination = source;
+    }
+};
+
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    std::size_t DimensionCount
+>
+struct convert<Geometry1, Geometry2, point_tag, point_tag, DimensionCount, false>
+    : detail::conversion::point_to_point<Geometry1, Geometry2, 0, DimensionCount>
+{};
+
+
+template
+<
+    typename Box1, typename Box2,
+    std::size_t DimensionCount
+>
+struct convert<Box1, Box2, box_tag, box_tag, DimensionCount, false>
+    : detail::conversion::indexed_to_indexed<Box1, Box2, 0, DimensionCount>
+{};
+
+
+template
+<
+    typename Segment1, typename Segment2,
+    std::size_t DimensionCount
+>
+struct convert<Segment1, Segment2, segment_tag, segment_tag, DimensionCount, false>
+    : detail::conversion::indexed_to_indexed<Segment1, Segment2, 0, DimensionCount>
+{};
+
+
+template <typename Segment, typename LineString, std::size_t DimensionCount>
+struct convert<Segment, LineString, segment_tag, linestring_tag, DimensionCount, false>
+    : detail::conversion::segment_to_range<Segment, LineString>
+{};
+
+
+template <typename Ring1, typename Ring2, std::size_t DimensionCount>
+struct convert<Ring1, Ring2, ring_tag, ring_tag, DimensionCount, false>
+    : detail::conversion::range_to_range
+        <   
+            Ring1, 
+            Ring2,
+            geometry::point_order<Ring1>::value
+                != geometry::point_order<Ring2>::value
+        >
+{};
+
+template <typename LineString1, typename LineString2, std::size_t DimensionCount>
+struct convert<LineString1, LineString2, linestring_tag, linestring_tag, DimensionCount, false>
+    : detail::conversion::range_to_range<LineString1, LineString2>
+{};
+
+template <typename Polygon1, typename Polygon2, std::size_t DimensionCount>
+struct convert<Polygon1, Polygon2, polygon_tag, polygon_tag, DimensionCount, false>
+    : detail::conversion::polygon_to_polygon<Polygon1, Polygon2>
+{};
+
+template <typename Box, typename Ring>
+struct convert<Box, Ring, box_tag, ring_tag, 2, false>
+    : detail::conversion::box_to_range
+        <
+            Box, 
+            Ring, 
+            geometry::closure<Ring>::value == closed,
+            geometry::point_order<Ring>::value == counterclockwise
+        >
+{};
+
+
+template <typename Box, typename Polygon>
+struct convert<Box, Polygon, box_tag, polygon_tag, 2, false>
+{
+    static inline void apply(Box const& box, Polygon& polygon)
+    {
+        typedef typename ring_type<Polygon>::type ring_type;
+
+        convert
+            <
+                Box, ring_type,
+                box_tag, ring_tag,
+                2, false
+            >::apply(box, exterior_ring(polygon));
+    }
+};
+
+
+template <typename Point, typename Box, std::size_t DimensionCount>
+struct convert<Point, Box, point_tag, box_tag, DimensionCount, false>
+{
+    static inline void apply(Point const& point, Box& box)
+    {
+        detail::conversion::point_to_box
+            <
+                Point, Box, min_corner, 0, DimensionCount
+            >::apply(point, box);
+        detail::conversion::point_to_box
+            <
+                Point, Box, max_corner, 0, DimensionCount
+            >::apply(point, box);
+    }
+};
+
+
+template <typename Ring, typename Polygon, std::size_t DimensionCount>
+struct convert<Ring, Polygon, ring_tag, polygon_tag, DimensionCount, false>
+{
+    static inline void apply(Ring const& ring, Polygon& polygon)
+    {
+        typedef typename ring_type<Polygon>::type ring_type;
+        convert
+            <
+                Ring, ring_type,
+                ring_tag, ring_tag,
+                DimensionCount, false
+            >::apply(ring, exterior_ring(polygon));
+    }
+};
+
+
+template <typename Polygon, typename Ring, std::size_t DimensionCount>
+struct convert<Polygon, Ring, polygon_tag, ring_tag, DimensionCount, false>
+{
+    static inline void apply(Polygon const& polygon, Ring& ring)
+    {
+        typedef typename ring_type<Polygon>::type ring_type;
+
+        convert
+            <
+                ring_type, Ring,
+                ring_tag, ring_tag,
+                DimensionCount, false
+            >::apply(exterior_ring(polygon), ring);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Converts one geometry to another geometry
+\details The convert algorithm converts one geometry, e.g. a BOX, to another
+geometry, e.g. a RING. This only if it is possible and applicable.
+If the point-order is different, or the closure is different between two 
+geometry types, it will be converted correctly by explicitly reversing the 
+points or closing or opening the polygon rings.
+\ingroup convert
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry (source)
+\param geometry2 \param_geometry (target)
+
+\qbk{[include reference/algorithms/convert.qbk]}
+ */
+template <typename Geometry1, typename Geometry2>
+inline void convert(Geometry1 const& geometry1, Geometry2& geometry2)
+{
+    concept::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2>();
+
+    dispatch::convert<Geometry1, Geometry2>::apply(geometry1, geometry2);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_CONVERT_HPP
diff --git a/src/boost/geometry/algorithms/convex_hull.hpp b/src/boost/geometry/algorithms/convex_hull.hpp
new file mode 100644
index 0000000..56b87c8
--- /dev/null
+++ b/src/boost/geometry/algorithms/convex_hull.hpp
@@ -0,0 +1,275 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_CONVEX_HULL_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_CONVEX_HULL_HPP
+
+#include <boost/array.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/strategies/convex_hull.hpp>
+#include <boost/geometry/strategies/concepts/convex_hull_concept.hpp>
+
+#include <boost/geometry/views/detail/range_type.hpp>
+
+#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/algorithms/detail/as_range.hpp>
+#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace convex_hull
+{
+
+template
+<
+    typename Geometry,
+    order_selector Order,
+    typename Strategy
+>
+struct hull_insert
+{
+
+    // Member template function (to avoid inconvenient declaration
+    // of output-iterator-type, from hull_to_geometry)
+    template <typename OutputIterator>
+    static inline OutputIterator apply(Geometry const& geometry,
+            OutputIterator out, Strategy const& strategy)
+    {
+        typename Strategy::state_type state;
+
+        strategy.apply(geometry, state);
+        strategy.result(state, out, Order == clockwise);
+        return out;
+    }
+};
+
+template
+<
+    typename Geometry,
+    typename Strategy
+>
+struct hull_to_geometry
+{
+    template <typename OutputGeometry>
+    static inline void apply(Geometry const& geometry, OutputGeometry& out,
+            Strategy const& strategy)
+    {
+        hull_insert
+            <
+                Geometry,
+                geometry::point_order<OutputGeometry>::value,
+                Strategy
+            >::apply(geometry,
+                std::back_inserter(
+                    // Handle linestring, ring and polygon the same:
+                    detail::as_range
+                        <
+                            typename range_type<OutputGeometry>::type
+                        >(out)), strategy);
+    }
+};
+
+
+// Helper metafunction for default strategy retrieval
+template <typename Geometry>
+struct default_strategy
+    : strategy_convex_hull
+          <
+              Geometry,
+              typename point_type<Geometry>::type
+          >
+{};
+
+
+}} // namespace detail::convex_hull
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Geometry,
+    typename Strategy = typename detail::convex_hull::default_strategy<Geometry>::type,
+    typename Tag = typename tag<Geometry>::type
+>
+struct convex_hull
+    : detail::convex_hull::hull_to_geometry<Geometry, Strategy>
+{};
+
+template
+<
+    typename Box,
+    typename Strategy
+>
+struct convex_hull<Box, Strategy, box_tag>
+{
+    template <typename OutputGeometry>
+    static inline void apply(Box const& box, OutputGeometry& out,
+            Strategy const& )
+    {
+        static bool const Close
+            = geometry::closure<OutputGeometry>::value == closed;
+        static bool const Reverse
+            = geometry::point_order<OutputGeometry>::value == counterclockwise;
+
+        // A hull for boxes is trivial. Any strategy is (currently) skipped.
+        boost::array<typename point_type<Box>::type, 4> range;
+        geometry::detail::assign_box_corners_oriented<Reverse>(box, range);
+        geometry::append(out, range);
+        if (Close)
+        {
+            geometry::append(out, *boost::begin(range));
+        }
+    }
+};
+
+
+
+template
+<
+    order_selector Order,
+    typename Geometry, typename Strategy
+>
+struct convex_hull_insert
+    : detail::convex_hull::hull_insert<Geometry, Order, Strategy>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template<typename Geometry, typename OutputGeometry, typename Strategy>
+inline void convex_hull(Geometry const& geometry,
+            OutputGeometry& out, Strategy const& strategy)
+{
+    concept::check_concepts_and_equal_dimensions
+        <
+            const Geometry,
+            OutputGeometry
+        >();
+
+    BOOST_CONCEPT_ASSERT( (geometry::concept::ConvexHullStrategy<Strategy>) );
+
+    if (geometry::num_points(geometry) == 0)
+    {
+        // Leave output empty
+        return;
+    }
+
+    dispatch::convex_hull
+        <
+            Geometry,
+            Strategy
+        >::apply(geometry, out, strategy);
+}
+
+
+/*!
+\brief \brief_calc{convex hull}
+\ingroup convex_hull
+\details \details_calc{convex_hull,convex hull}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry \param_geometry,  input geometry
+\param hull \param_geometry \param_set{convex hull}
+
+\qbk{[include reference/algorithms/convex_hull.qbk]}
+ */
+template<typename Geometry, typename OutputGeometry>
+inline void convex_hull(Geometry const& geometry,
+            OutputGeometry& hull)
+{
+    concept::check_concepts_and_equal_dimensions
+        <
+            const Geometry,
+            OutputGeometry
+        >();
+
+    typedef typename detail::convex_hull::default_strategy<Geometry>::type strategy_type;
+
+    convex_hull(geometry, hull, strategy_type());
+}
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace convex_hull
+{
+
+
+template<typename Geometry, typename OutputIterator, typename Strategy>
+inline OutputIterator convex_hull_insert(Geometry const& geometry,
+            OutputIterator out, Strategy const& strategy)
+{
+    // Concept: output point type = point type of input geometry
+    concept::check<Geometry const>();
+    concept::check<typename point_type<Geometry>::type>();
+
+    BOOST_CONCEPT_ASSERT( (geometry::concept::ConvexHullStrategy<Strategy>) );
+
+    return dispatch::convex_hull_insert
+        <
+            geometry::point_order<Geometry>::value,
+            Geometry, Strategy
+        >::apply(geometry, out, strategy);
+}
+
+
+/*!
+\brief Calculate the convex hull of a geometry, output-iterator version
+\ingroup convex_hull
+\tparam Geometry the input geometry type
+\tparam OutputIterator: an output-iterator
+\param geometry the geometry to calculate convex hull from
+\param out an output iterator outputing points of the convex hull
+\note This overloaded version outputs to an output iterator.
+In this case, nothing is known about its point-type or
+    about its clockwise order. Therefore, the input point-type
+    and order are copied
+
+ */
+template<typename Geometry, typename OutputIterator>
+inline OutputIterator convex_hull_insert(Geometry const& geometry,
+            OutputIterator out)
+{
+    // Concept: output point type = point type of input geometry
+    concept::check<Geometry const>();
+    concept::check<typename point_type<Geometry>::type>();
+
+    typedef typename detail::convex_hull::default_strategy<Geometry>::type strategy_type;
+
+    return convex_hull_insert(geometry, out, strategy_type());
+}
+
+
+}} // namespace detail::convex_hull
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_CONVEX_HULL_HPP
diff --git a/src/boost/geometry/algorithms/correct.hpp b/src/boost/geometry/algorithms/correct.hpp
new file mode 100644
index 0000000..583e395
--- /dev/null
+++ b/src/boost/geometry/algorithms/correct.hpp
@@ -0,0 +1,265 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_CORRECT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_CORRECT_HPP
+
+
+#include <algorithm>
+#include <cstddef>
+#include <functional>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/util/order_as_direction.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace correct
+{
+
+template <typename Geometry>
+struct correct_nop
+{
+    static inline void apply(Geometry& )
+    {}
+};
+
+
+template <typename Box, std::size_t Dimension, std::size_t DimensionCount>
+struct correct_box_loop
+{
+    typedef typename coordinate_type<Box>::type coordinate_type;
+
+    static inline void apply(Box& box)
+    {
+        if (get<min_corner, Dimension>(box) > get<max_corner, Dimension>(box))
+        {
+            // Swap the coordinates
+            coordinate_type max_value = get<min_corner, Dimension>(box);
+            coordinate_type min_value = get<max_corner, Dimension>(box);
+            set<min_corner, Dimension>(box, min_value);
+            set<max_corner, Dimension>(box, max_value);
+        }
+
+        correct_box_loop
+            <
+                Box, Dimension + 1, DimensionCount
+            >::apply(box);
+    }
+};
+
+
+
+template <typename Box, std::size_t DimensionCount>
+struct correct_box_loop<Box, DimensionCount, DimensionCount>
+{
+    static inline void apply(Box& )
+    {}
+
+};
+
+
+// Correct a box: make min/max correct
+template <typename Box>
+struct correct_box
+{
+
+    static inline void apply(Box& box)
+    {
+        // Currently only for Cartesian coordinates
+        // (or spherical without crossing dateline)
+        // Future version: adapt using strategies
+        correct_box_loop
+            <
+                Box, 0, dimension<Box>::type::value
+            >::apply(box);
+    }
+};
+
+
+// Close a ring, if not closed
+template <typename Ring, typename Predicate>
+struct correct_ring
+{
+    typedef typename point_type<Ring>::type point_type;
+    typedef typename coordinate_type<Ring>::type coordinate_type;
+
+    typedef typename strategy::area::services::default_strategy
+        <
+            typename cs_tag<point_type>::type,
+            point_type
+        >::type strategy_type;
+
+    typedef detail::area::ring_area
+            <
+                Ring,
+                order_as_direction<geometry::point_order<Ring>::value>::value,
+                geometry::closure<Ring>::value,
+                strategy_type
+            > ring_area_type;
+
+
+    static inline void apply(Ring& r)
+    {
+        // Check close-ness
+        if (boost::size(r) > 2)
+        {
+            // check if closed, if not, close it
+            bool const disjoint = geometry::disjoint(*boost::begin(r), *(boost::end(r) - 1));
+            closure_selector const s = geometry::closure<Ring>::value;
+
+            if (disjoint && (s == closed))
+            {
+                geometry::append(r, *boost::begin(r));
+            }
+            if (! disjoint && geometry::closure<Ring>::value != closed)
+            {
+                // Open it by removing last point
+                geometry::traits::resize<Ring>::apply(r, boost::size(r) - 1);
+            }
+        }
+        // Check area
+        Predicate predicate;
+        typedef typename default_area_result<Ring>::type area_result_type;
+        area_result_type const zero = area_result_type();
+        if (predicate(ring_area_type::apply(r, strategy_type()), zero))
+        {
+            std::reverse(boost::begin(r), boost::end(r));
+        }
+    }
+};
+
+// Correct a polygon: normalizes all rings, sets outer ring clockwise, sets all
+// inner rings counter clockwise (or vice versa depending on orientation)
+template <typename Polygon>
+struct correct_polygon
+{
+    typedef typename ring_type<Polygon>::type ring_type;
+    typedef typename default_area_result<Polygon>::type area_result_type;
+
+    static inline void apply(Polygon& poly)
+    {
+        correct_ring
+            <
+                ring_type,
+                std::less<area_result_type>
+            >::apply(exterior_ring(poly));
+
+        typename interior_return_type<Polygon>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            correct_ring
+                <
+                    ring_type,
+                    std::greater<area_result_type>
+                >::apply(*it);
+        }
+    }
+};
+
+
+}} // namespace detail::correct
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Geometry, typename Tag = typename tag<Geometry>::type>
+struct correct: not_implemented<Tag>
+{};
+
+template <typename Point>
+struct correct<Point, point_tag>
+    : detail::correct::correct_nop<Point>
+{};
+
+template <typename LineString>
+struct correct<LineString, linestring_tag>
+    : detail::correct::correct_nop<LineString>
+{};
+
+template <typename Segment>
+struct correct<Segment, segment_tag>
+    : detail::correct::correct_nop<Segment>
+{};
+
+
+template <typename Box>
+struct correct<Box, box_tag>
+    : detail::correct::correct_box<Box>
+{};
+
+template <typename Ring>
+struct correct<Ring, ring_tag>
+    : detail::correct::correct_ring
+        <
+            Ring,
+            std::less<typename default_area_result<Ring>::type>
+        >
+{};
+
+template <typename Polygon>
+struct correct<Polygon, polygon_tag>
+    : detail::correct::correct_polygon<Polygon>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Corrects a geometry
+\details Corrects a geometry: all rings which are wrongly oriented with respect
+    to their expected orientation are reversed. To all rings which do not have a
+    closing point and are typed as they should have one, the first point is
+    appended. Also boxes can be corrected.
+\ingroup correct
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry which will be corrected if necessary
+
+\qbk{[include reference/algorithms/correct.qbk]}
+*/
+template <typename Geometry>
+inline void correct(Geometry& geometry)
+{
+    concept::check<Geometry const>();
+
+    dispatch::correct<Geometry>::apply(geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_CORRECT_HPP
diff --git a/src/boost/geometry/algorithms/covered_by.hpp b/src/boost/geometry/algorithms/covered_by.hpp
new file mode 100644
index 0000000..c3c406c
--- /dev/null
+++ b/src/boost/geometry/algorithms/covered_by.hpp
@@ -0,0 +1,195 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/algorithms/not_implemented.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Tag1 = typename tag<Geometry1>::type,
+    typename Tag2 = typename tag<Geometry2>::type
+>
+struct covered_by: not_implemented<Tag1, Tag2>
+{};
+
+
+template <typename Point, typename Box>
+struct covered_by<Point, Box, point_tag, box_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
+    {
+        return strategy.apply(point, box);
+    }
+};
+
+template <typename Box1, typename Box2>
+struct covered_by<Box1, Box2, box_tag, box_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
+    {
+        assert_dimension_equal<Box1, Box2>();
+        return strategy.apply(box1, box2);
+    }
+};
+
+
+
+template <typename Point, typename Ring>
+struct covered_by<Point, Ring, point_tag, ring_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, Ring const& ring, Strategy const& strategy)
+    {
+        return detail::within::point_in_ring
+            <
+                Point,
+                Ring,
+                order_as_direction<geometry::point_order<Ring>::value>::value,
+                geometry::closure<Ring>::value,
+                Strategy
+            >::apply(point, ring, strategy) >= 0;
+    }
+};
+
+template <typename Point, typename Polygon>
+struct covered_by<Point, Polygon, point_tag, polygon_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, Polygon const& polygon, Strategy const& strategy)
+    {
+        return detail::within::point_in_polygon
+        <
+            Point,
+            Polygon,
+            order_as_direction<geometry::point_order<Polygon>::value>::value,
+            geometry::closure<Polygon>::value,
+            Strategy
+        >::apply(point, polygon, strategy) >= 0;
+    }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_check12{is inside or on border}
+\ingroup covered_by
+\details \details_check12{covered_by, is inside or on border}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry which might be inside or on the border of the second geometry
+\param geometry2 \param_geometry which might cover the first geometry
+\return true if geometry1 is inside of or on the border of geometry2,
+    else false
+\note The default strategy is used for covered_by detection
+
+\qbk{[include reference/algorithms/covered_by.qbk]}
+
+ */
+template<typename Geometry1, typename Geometry2>
+inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    assert_dimension_equal<Geometry1, Geometry2>();
+
+    typedef typename point_type<Geometry1>::type point_type1;
+    typedef typename point_type<Geometry2>::type point_type2;
+
+    typedef typename strategy::covered_by::services::default_strategy
+        <
+            typename tag<Geometry1>::type,
+            typename tag<Geometry2>::type,
+            typename tag<Geometry1>::type,
+            typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
+            typename tag_cast
+                <
+                    typename cs_tag<point_type1>::type, spherical_tag
+                >::type,
+            typename tag_cast
+                <
+                    typename cs_tag<point_type2>::type, spherical_tag
+                >::type,
+            Geometry1,
+            Geometry2
+        >::type strategy_type;
+
+    return dispatch::covered_by
+        <
+            Geometry1,
+            Geometry2
+        >::apply(geometry1, geometry2, strategy_type());
+}
+
+/*!
+\brief \brief_check12{is inside or on border} \brief_strategy
+\ingroup covered_by
+\details \details_check12{covered_by, is inside or on border}, \brief_strategy. \details_strategy_reasons
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry which might be inside or on the border of the second geometry
+\param geometry2 \param_geometry which might cover the first geometry
+\param strategy strategy to be used
+\return true if geometry1 is inside of or on the border of geometry2,
+    else false
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/covered_by.qbk]}
+
+*/
+template<typename Geometry1, typename Geometry2, typename Strategy>
+inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2,
+        Strategy const& strategy)
+{
+    concept::within::check
+        <
+            typename tag<Geometry1>::type, 
+            typename tag<Geometry2>::type, 
+            typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
+            Strategy
+        >();
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    assert_dimension_equal<Geometry1, Geometry2>();
+
+    return dispatch::covered_by
+        <
+            Geometry1,
+            Geometry2
+        >::apply(geometry1, geometry2, strategy);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
diff --git a/src/boost/geometry/algorithms/detail/as_range.hpp b/src/boost/geometry/algorithms/detail/as_range.hpp
new file mode 100644
index 0000000..d0dfb07
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/as_range.hpp
@@ -0,0 +1,107 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP
+
+
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/util/add_const_if_c.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename GeometryTag, typename Geometry, typename Range, bool IsConst>
+struct as_range
+{
+    static inline typename add_const_if_c<IsConst, Range>::type& get(
+            typename add_const_if_c<IsConst, Geometry>::type& input)
+    {
+        return input;
+    }
+};
+
+
+template <typename Geometry, typename Range, bool IsConst>
+struct as_range<polygon_tag, Geometry, Range, IsConst>
+{
+    static inline typename add_const_if_c<IsConst, Range>::type& get(
+            typename add_const_if_c<IsConst, Geometry>::type& input)
+    {
+        return exterior_ring(input);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+// Will probably be replaced by the more generic "view_as", therefore in detail
+namespace detail
+{
+
+/*!
+\brief Function getting either the range (ring, linestring) itself
+or the outer ring (polygon)
+\details Utility to handle polygon's outer ring as a range
+\ingroup utility
+*/
+template <typename Range, typename Geometry>
+inline Range& as_range(Geometry& input)
+{
+    return dispatch::as_range
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Range,
+            false
+        >::get(input);
+}
+
+
+/*!
+\brief Function getting either the range (ring, linestring) itself
+or the outer ring (polygon), const version
+\details Utility to handle polygon's outer ring as a range
+\ingroup utility
+*/
+template <typename Range, typename Geometry>
+inline Range const& as_range(Geometry const& input)
+{
+    return dispatch::as_range
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Range,
+            true
+        >::get(input);
+}
+
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP
diff --git a/src/boost/geometry/algorithms/detail/assign_box_corners.hpp b/src/boost/geometry/algorithms/detail/assign_box_corners.hpp
new file mode 100644
index 0000000..1fd4173
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/assign_box_corners.hpp
@@ -0,0 +1,93 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_BOX_CORNERS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_BOX_CORNERS_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/algorithms/detail/assign_values.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail 
+{
+// Note: this is moved to namespace detail because the names and parameter orders
+// are not yet 100% clear.
+
+/*!
+\brief Assign the four points of a 2D box
+\ingroup assign
+\note The order is crucial. Most logical is LOWER, UPPER and sub-order LEFT, RIGHT
+    so this is how it is implemented.
+\tparam Box \tparam_box
+\tparam Point \tparam_point
+\param box \param_box
+\param lower_left point being assigned to lower left coordinates of the box
+\param lower_right point being assigned to lower right coordinates of the box
+\param upper_left point being assigned to upper left coordinates of the box
+\param upper_right point being assigned to upper right coordinates of the box
+
+\qbk{
+[heading Example]
+[assign_box_corners] [assign_box_corners_output]
+}
+*/
+template <typename Box, typename Point>
+inline void assign_box_corners(Box const& box,
+        Point& lower_left, Point& lower_right,
+        Point& upper_left, Point& upper_right)
+{
+    concept::check<Box const>();
+    concept::check<Point>();
+
+    detail::assign::assign_box_2d_corner
+            <min_corner, min_corner>(box, lower_left);
+    detail::assign::assign_box_2d_corner
+            <max_corner, min_corner>(box, lower_right);
+    detail::assign::assign_box_2d_corner
+            <min_corner, max_corner>(box, upper_left);
+    detail::assign::assign_box_2d_corner
+            <max_corner, max_corner>(box, upper_right);
+}
+
+template <bool Reverse, typename Box, typename Range>
+inline void assign_box_corners_oriented(Box const& box, Range& corners)
+{
+    if (Reverse)
+    {
+        // make counterclockwise ll,lr,ur,ul
+        assign_box_corners(box, corners[0], corners[1], corners[3], corners[2]);
+    }
+    else
+    {
+        // make clockwise ll,ul,ur,lr
+        assign_box_corners(box, corners[0], corners[3], corners[1], corners[2]);
+    }
+}
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_BOX_CORNERS_HPP
diff --git a/src/boost/geometry/algorithms/detail/assign_indexed_point.hpp b/src/boost/geometry/algorithms/detail/assign_indexed_point.hpp
new file mode 100644
index 0000000..a1cffb8
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/assign_indexed_point.hpp
@@ -0,0 +1,94 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_INDEXED_POINT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_INDEXED_POINT_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/algorithms/detail/assign_values.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail 
+{
+
+/*!
+\brief Assign a box or segment with the value of a point
+\ingroup assign
+\tparam Index indicates which box-corner, min_corner (0) or max_corner (1)
+    or which point of segment (0/1)
+\tparam Point \tparam_point
+\tparam Geometry \tparam_box_or_segment
+\param point \param_point
+\param geometry \param_box_or_segment
+
+\qbk{
+[heading Example]
+[assign_point_to_index] [assign_point_to_index_output]
+}
+*/
+template <std::size_t Index, typename Geometry, typename Point>
+inline void assign_point_to_index(Point const& point, Geometry& geometry)
+{
+    concept::check<Point const>();
+    concept::check<Geometry>();
+
+    detail::assign::assign_point_to_index
+        <
+            Geometry, Point, Index, 0, dimension<Geometry>::type::value
+        >::apply(point, geometry);
+}
+
+
+/*!
+\brief Assign a point with a point of a box or segment
+\ingroup assign
+\tparam Index indicates which box-corner, min_corner (0) or max_corner (1)
+    or which point of segment (0/1)
+\tparam Geometry \tparam_box_or_segment
+\tparam Point \tparam_point
+\param geometry \param_box_or_segment
+\param point \param_point
+
+\qbk{
+[heading Example]
+[assign_point_from_index] [assign_point_from_index_output]
+}
+*/
+template <std::size_t Index, typename Point, typename Geometry>
+inline void assign_point_from_index(Geometry const& geometry, Point& point)
+{
+    concept::check<Geometry const>();
+    concept::check<Point>();
+
+    detail::assign::assign_point_from_index
+        <
+            Geometry, Point, Index, 0, dimension<Geometry>::type::value
+        >::apply(geometry, point);
+}
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_INDEXED_POINT_HPP
diff --git a/src/boost/geometry/algorithms/detail/assign_values.hpp b/src/boost/geometry/algorithms/detail/assign_values.hpp
new file mode 100644
index 0000000..ed47134
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/assign_values.hpp
@@ -0,0 +1,443 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_ASSIGN_VALUES_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_ASSIGN_VALUES_HPP
+
+
+#include <cstddef>
+
+#include <boost/concept/requires.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+#include <boost/geometry/util/for_each_coordinate.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace assign
+{
+
+
+template
+<
+    typename Box, std::size_t Index,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct initialize
+{
+    typedef typename coordinate_type<Box>::type coordinate_type;
+
+    static inline void apply(Box& box, coordinate_type const& value)
+    {
+        geometry::set<Index, Dimension>(box, value);
+        initialize<Box, Index, Dimension + 1, DimensionCount>::apply(box, value);
+    }
+};
+
+
+template <typename Box, std::size_t Index, std::size_t DimensionCount>
+struct initialize<Box, Index, DimensionCount, DimensionCount>
+{
+    typedef typename coordinate_type<Box>::type coordinate_type;
+
+    static inline void apply(Box&,  coordinate_type const& )
+    {}
+};
+
+
+template <typename Point>
+struct assign_zero_point
+{
+    static inline void apply(Point& point)
+    {
+        geometry::assign_value(point, 0);
+    }
+};
+
+
+template <typename BoxOrSegment>
+struct assign_inverse_box_or_segment
+{
+    typedef typename point_type<BoxOrSegment>::type point_type;
+
+    static inline void apply(BoxOrSegment& geometry)
+    {
+        typedef typename coordinate_type<point_type>::type bound_type;
+
+        initialize
+            <
+                BoxOrSegment, 0, 0, dimension<BoxOrSegment>::type::value
+            >::apply(
+            geometry, boost::numeric::bounds<bound_type>::highest());
+        initialize
+            <
+                BoxOrSegment, 1, 0, dimension<BoxOrSegment>::type::value
+            >::apply(
+            geometry, boost::numeric::bounds<bound_type>::lowest());
+    }
+};
+
+
+template <typename BoxOrSegment>
+struct assign_zero_box_or_segment
+{
+    static inline void apply(BoxOrSegment& geometry)
+    {
+        typedef typename coordinate_type<BoxOrSegment>::type coordinate_type;
+
+        initialize
+            <
+                BoxOrSegment, 0, 0, dimension<BoxOrSegment>::type::value
+            >::apply(geometry, coordinate_type());
+        initialize
+            <
+                BoxOrSegment, 1, 0, dimension<BoxOrSegment>::type::value
+            >::apply(geometry, coordinate_type());
+    }
+};
+
+
+template
+<
+    std::size_t Corner1, std::size_t Corner2,
+    typename Box, typename Point
+>
+inline void assign_box_2d_corner(Box const& box, Point& point)
+{
+    // Be sure both are 2-Dimensional
+    assert_dimension<Box, 2>();
+    assert_dimension<Point, 2>();
+
+    // Copy coordinates
+    typedef typename coordinate_type<Point>::type coordinate_type;
+
+    geometry::set<0>(point, boost::numeric_cast<coordinate_type>(get<Corner1, 0>(box)));
+    geometry::set<1>(point, boost::numeric_cast<coordinate_type>(get<Corner2, 1>(box)));
+}
+
+
+
+template
+<
+    typename Geometry, typename Point,
+    std::size_t Index,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct assign_point_to_index
+{
+
+    static inline void apply(Point const& point, Geometry& geometry)
+    {
+        geometry::set<Index, Dimension>(geometry, boost::numeric_cast
+            <
+                typename coordinate_type<Geometry>::type
+            >(geometry::get<Dimension>(point)));
+
+        assign_point_to_index
+            <
+                Geometry, Point, Index, Dimension + 1, DimensionCount
+            >::apply(point, geometry);
+    }
+};
+
+template
+<
+    typename Geometry, typename Point,
+    std::size_t Index,
+    std::size_t DimensionCount
+>
+struct assign_point_to_index
+    <
+        Geometry, Point,
+        Index,
+        DimensionCount, DimensionCount
+    >
+{
+    static inline void apply(Point const& , Geometry& )
+    {
+    }
+};
+
+
+template
+<
+    typename Geometry, typename Point,
+    std::size_t Index,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct assign_point_from_index
+{
+
+    static inline void apply(Geometry const& geometry, Point& point)
+    {
+        geometry::set<Dimension>( point, boost::numeric_cast
+            <
+                typename coordinate_type<Point>::type
+            >(geometry::get<Index, Dimension>(geometry)));
+
+        assign_point_from_index
+            <
+                Geometry, Point, Index, Dimension + 1, DimensionCount
+            >::apply(geometry, point);
+    }
+};
+
+template
+<
+    typename Geometry, typename Point,
+    std::size_t Index,
+    std::size_t DimensionCount
+>
+struct assign_point_from_index
+    <
+        Geometry, Point,
+        Index,
+        DimensionCount, DimensionCount
+    >
+{
+    static inline void apply(Geometry const&, Point&)
+    {
+    }
+};
+
+
+template <typename Geometry>
+struct assign_2d_box_or_segment
+{
+    typedef typename coordinate_type<Geometry>::type coordinate_type;
+
+    // Here we assign 4 coordinates to a box of segment
+    // -> Most logical is: x1,y1,x2,y2
+    // In case the user reverses x1/x2 or y1/y2, for a box, we could reverse them (THAT IS NOT IMPLEMENTED)
+
+    template <typename Type>
+    static inline void apply(Geometry& geometry,
+                Type const& x1, Type const& y1, Type const& x2, Type const& y2)
+    {
+        geometry::set<0, 0>(geometry, boost::numeric_cast<coordinate_type>(x1));
+        geometry::set<0, 1>(geometry, boost::numeric_cast<coordinate_type>(y1));
+        geometry::set<1, 0>(geometry, boost::numeric_cast<coordinate_type>(x2));
+        geometry::set<1, 1>(geometry, boost::numeric_cast<coordinate_type>(y2));
+    }
+};
+
+
+}} // namespace detail::assign
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename GeometryTag, typename Geometry, std::size_t DimensionCount>
+struct assign
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Point>
+struct assign<point_tag, Point, 2>
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+
+    template <typename T>
+    static inline void apply(Point& point, T const& c1, T const& c2)
+    {
+        set<0>(point, boost::numeric_cast<coordinate_type>(c1));
+        set<1>(point, boost::numeric_cast<coordinate_type>(c2));
+    }
+};
+
+template <typename Point>
+struct assign<point_tag, Point, 3>
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+
+    template <typename T>
+    static inline void apply(Point& point, T const& c1, T const& c2, T const& c3)
+    {
+        set<0>(point, boost::numeric_cast<coordinate_type>(c1));
+        set<1>(point, boost::numeric_cast<coordinate_type>(c2));
+        set<2>(point, boost::numeric_cast<coordinate_type>(c3));
+    }
+};
+
+template <typename Box>
+struct assign<box_tag, Box, 2>
+    : detail::assign::assign_2d_box_or_segment<Box>
+{};
+
+template <typename Segment>
+struct assign<segment_tag, Segment, 2>
+    : detail::assign::assign_2d_box_or_segment<Segment>
+{};
+
+
+
+template <typename GeometryTag, typename Geometry>
+struct assign_zero {};
+
+
+template <typename Point>
+struct assign_zero<point_tag, Point>
+    : detail::assign::assign_zero_point<Point>
+{};
+
+template <typename Box>
+struct assign_zero<box_tag, Box>
+    : detail::assign::assign_zero_box_or_segment<Box>
+{};
+
+template <typename Segment>
+struct assign_zero<segment_tag, Segment>
+    : detail::assign::assign_zero_box_or_segment<Segment>
+{};
+
+
+template <typename GeometryTag, typename Geometry>
+struct assign_inverse {};
+
+template <typename Box>
+struct assign_inverse<box_tag, Box>
+    : detail::assign::assign_inverse_box_or_segment<Box>
+{};
+
+template <typename Segment>
+struct assign_inverse<segment_tag, Segment>
+    : detail::assign::assign_inverse_box_or_segment<Segment>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Assign two coordinates to a geometry (usually a 2D point)
+\ingroup assign
+\tparam Geometry \tparam_geometry
+\tparam Type \tparam_numeric to specify the coordinates
+\param geometry \param_geometry
+\param c1 \param_x
+\param c2 \param_y
+
+\qbk{distinguish, 2 coordinate values}
+\qbk{
+[heading Example]
+[assign_2d_point] [assign_2d_point_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.make.make_2_2_coordinate_values make]
+}
+ */
+template <typename Geometry, typename Type>
+inline void assign_values(Geometry& geometry, Type const& c1, Type const& c2)
+{
+    concept::check<Geometry>();
+
+    dispatch::assign
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            geometry::dimension<Geometry>::type::value
+        >::apply(geometry, c1, c2);
+}
+
+/*!
+\brief Assign three values to a geometry (usually a 3D point)
+\ingroup assign
+\tparam Geometry \tparam_geometry
+\tparam Type \tparam_numeric to specify the coordinates
+\param geometry \param_geometry
+\param c1 \param_x
+\param c2 \param_y
+\param c3 \param_z
+
+\qbk{distinguish, 3 coordinate values}
+\qbk{
+[heading Example]
+[assign_3d_point] [assign_3d_point_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.make.make_3_3_coordinate_values make]
+}
+ */
+template <typename Geometry, typename Type>
+inline void assign_values(Geometry& geometry,
+            Type const& c1, Type const& c2, Type const& c3)
+{
+    concept::check<Geometry>();
+
+    dispatch::assign
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            geometry::dimension<Geometry>::type::value
+        >::apply(geometry, c1, c2, c3);
+}
+
+/*!
+\brief Assign four values to a geometry (usually a box or segment)
+\ingroup assign
+\tparam Geometry \tparam_geometry
+\tparam Type \tparam_numeric to specify the coordinates
+\param geometry \param_geometry
+\param c1 First coordinate (usually x1)
+\param c2 Second coordinate (usually y1)
+\param c3 Third coordinate (usually x2)
+\param c4 Fourth coordinate (usually y2)
+
+\qbk{distinguish, 4 coordinate values}
+ */
+template <typename Geometry, typename Type>
+inline void assign_values(Geometry& geometry,
+                Type const& c1, Type const& c2, Type const& c3, Type const& c4)
+{
+    concept::check<Geometry>();
+
+    dispatch::assign
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            geometry::dimension<Geometry>::type::value
+        >::apply(geometry, c1, c2, c3, c4);
+}
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_ASSIGN_VALUES_HPP
diff --git a/src/boost/geometry/algorithms/detail/calculate_null.hpp b/src/boost/geometry/algorithms/detail/calculate_null.hpp
new file mode 100644
index 0000000..4b48d62
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/calculate_null.hpp
@@ -0,0 +1,38 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_NULL_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_NULL_HPP
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template<typename ReturnType, typename Geometry, typename Strategy>
+struct calculate_null
+{
+    static inline ReturnType apply(Geometry const& , Strategy const&)
+    {
+        return ReturnType();
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_NULL_HPP
diff --git a/src/boost/geometry/algorithms/detail/calculate_sum.hpp b/src/boost/geometry/algorithms/detail/calculate_sum.hpp
new file mode 100644
index 0000000..2ad3490
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/calculate_sum.hpp
@@ -0,0 +1,64 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
+
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template
+<
+    typename ReturnType,
+    typename Polygon,
+    typename Strategy,
+    typename Policy
+>
+class calculate_polygon_sum
+{
+    template <typename Rings>
+    static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
+    {
+        ReturnType sum = ReturnType();
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            sum += Policy::apply(*it, strategy);
+        }
+        return sum;
+    }
+
+public :
+    static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
+    {
+        return Policy::apply(exterior_ring(poly), strategy)
+            + sum_interior_rings(interior_rings(poly), strategy)
+            ;
+    }
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
diff --git a/src/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp b/src/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp
new file mode 100644
index 0000000..d39824a
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp
@@ -0,0 +1,80 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP
+
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace conversion
+{
+
+
+template
+<
+    typename Source, 
+    typename Destination, 
+    std::size_t Dimension, 
+    std::size_t DimensionCount
+>
+struct indexed_to_indexed
+{
+    static inline void apply(Source const& source, Destination& destination)
+    {
+        typedef typename coordinate_type<Destination>::type coordinate_type;
+
+        geometry::set<min_corner, Dimension>(destination, 
+            boost::numeric_cast<coordinate_type>(
+                geometry::get<min_corner, Dimension>(source)));
+        geometry::set<max_corner, Dimension>(destination, 
+            boost::numeric_cast<coordinate_type>(
+                geometry::get<max_corner, Dimension>(source)));
+                
+        indexed_to_indexed
+            <
+                Source, Destination, 
+                Dimension + 1, DimensionCount
+            >::apply(source, destination);
+    }
+};
+
+template 
+<
+    typename Source, 
+    typename Destination, 
+    std::size_t DimensionCount
+>
+struct indexed_to_indexed<Source, Destination, DimensionCount, DimensionCount>
+{
+    static inline void apply(Source const& , Destination& )
+    {}
+};
+
+
+}} // namespace detail::conversion
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP
diff --git a/src/boost/geometry/algorithms/detail/convert_point_to_point.hpp b/src/boost/geometry/algorithms/detail/convert_point_to_point.hpp
new file mode 100644
index 0000000..c7d37b6
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/convert_point_to_point.hpp
@@ -0,0 +1,68 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_POINT_TO_POINT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_POINT_TO_POINT_HPP
+
+// Note: extracted from "convert.hpp" to avoid circular references convert/append
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace conversion
+{
+
+
+template <typename Source, typename Destination, std::size_t Dimension, std::size_t DimensionCount>
+struct point_to_point
+{
+    static inline void apply(Source const& source, Destination& destination)
+    {
+        typedef typename coordinate_type<Destination>::type coordinate_type;
+
+        set<Dimension>(destination, boost::numeric_cast<coordinate_type>(get<Dimension>(source)));
+        point_to_point<Source, Destination, Dimension + 1, DimensionCount>::apply(source, destination);
+    }
+};
+
+template <typename Source, typename Destination, std::size_t DimensionCount>
+struct point_to_point<Source, Destination, DimensionCount, DimensionCount>
+{
+    static inline void apply(Source const& , Destination& )
+    {}
+};
+
+
+template <typename Source, typename Destination>
+inline void convert_point_to_point(Source const& source, Destination& destination)
+{
+    point_to_point<Source, Destination, 0, dimension<Destination>::value>::apply(source, destination);
+}
+
+
+
+}} // namespace detail::conversion
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_POINT_TO_POINT_HPP
diff --git a/src/boost/geometry/algorithms/detail/disjoint.hpp b/src/boost/geometry/algorithms/detail/disjoint.hpp
new file mode 100644
index 0000000..2ced5b1
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/disjoint.hpp
@@ -0,0 +1,225 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_HPP
+
+// Note: contrary to most files, the geometry::detail::disjoint namespace
+// is partly implemented in a separate file, to avoid circular references
+// disjoint -> get_turns -> disjoint
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+
+
+#include <boost/geometry/util/math.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace disjoint
+{
+
+
+struct disjoint_interrupt_policy
+{
+    static bool const enabled = true;
+    bool has_intersections;
+
+    inline disjoint_interrupt_policy()
+        : has_intersections(false)
+    {}
+
+    template <typename Range>
+    inline bool apply(Range const& range)
+    {
+        // If there is any IP in the range, it is NOT disjoint
+        if (boost::size(range) > 0)
+        {
+            has_intersections = true;
+            return true;
+        }
+        return false;
+    }
+};
+
+
+
+template
+<
+    typename Point1, typename Point2,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct point_point
+{
+    static inline bool apply(Point1 const& p1, Point2 const& p2)
+    {
+        if (! geometry::math::equals(get<Dimension>(p1), get<Dimension>(p2)))
+        {
+            return true;
+        }
+        return point_point
+            <
+                Point1, Point2,
+                Dimension + 1, DimensionCount
+            >::apply(p1, p2);
+    }
+};
+
+
+template <typename Point1, typename Point2, std::size_t DimensionCount>
+struct point_point<Point1, Point2, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Point1 const& , Point2 const& )
+    {
+        return false;
+    }
+};
+
+
+template
+<
+    typename Point, typename Box,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct point_box
+{
+    static inline bool apply(Point const& point, Box const& box)
+    {
+        if (get<Dimension>(point) < get<min_corner, Dimension>(box)
+            || get<Dimension>(point) > get<max_corner, Dimension>(box))
+        {
+            return true;
+        }
+        return point_box
+            <
+                Point, Box,
+                Dimension + 1, DimensionCount
+            >::apply(point, box);
+    }
+};
+
+
+template <typename Point, typename Box, std::size_t DimensionCount>
+struct point_box<Point, Box, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Point const& , Box const& )
+    {
+        return false;
+    }
+};
+
+
+template
+<
+    typename Box1, typename Box2,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct box_box
+{
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        if (get<max_corner, Dimension>(box1) < get<min_corner, Dimension>(box2))
+        {
+            return true;
+        }
+        if (get<min_corner, Dimension>(box1) > get<max_corner, Dimension>(box2))
+        {
+            return true;
+        }
+        return box_box
+            <
+                Box1, Box2,
+                Dimension + 1, DimensionCount
+            >::apply(box1, box2);
+    }
+};
+
+
+template <typename Box1, typename Box2, std::size_t DimensionCount>
+struct box_box<Box1, Box2, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Box1 const& , Box2 const& )
+    {
+        return false;
+    }
+};
+
+
+
+/*!
+    \brief Internal utility function to detect of boxes are disjoint
+    \note Is used from other algorithms, declared separately
+        to avoid circular references
+ */
+template <typename Box1, typename Box2>
+inline bool disjoint_box_box(Box1 const& box1, Box2 const& box2)
+{
+    return box_box
+        <
+            Box1, Box2,
+            0, dimension<Box1>::type::value
+        >::apply(box1, box2);
+}
+
+
+
+/*!
+    \brief Internal utility function to detect of points are disjoint
+    \note To avoid circular references
+ */
+template <typename Point1, typename Point2>
+inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2)
+{
+    return point_point
+        <
+            Point1, Point2,
+            0, dimension<Point1>::type::value
+        >::apply(point1, point2);
+}
+
+
+}} // namespace detail::disjoint
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace equals
+{
+
+/*!
+    \brief Internal utility function to detect of points are disjoint
+    \note To avoid circular references
+ */
+template <typename Point1, typename Point2>
+inline bool equals_point_point(Point1 const& point1, Point2 const& point2)
+{
+    return ! detail::disjoint::disjoint_point_point(point1, point2);
+}
+
+
+}} // namespace detail::equals
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_HPP
diff --git a/src/boost/geometry/algorithms/detail/equals/collect_vectors.hpp b/src/boost/geometry/algorithms/detail/equals/collect_vectors.hpp
new file mode 100644
index 0000000..9c2fe28
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/equals/collect_vectors.hpp
@@ -0,0 +1,315 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_COLLECT_VECTORS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_COLLECT_VECTORS_HPP
+
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/math.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+// TODO: if Boost.LA of Emil Dotchevski is accepted, adapt this
+template <typename T>
+struct collected_vector
+{
+    typedef T type;
+
+    inline collected_vector()
+    {}
+
+    inline collected_vector(T const& px, T const& py,
+            T const& pdx, T const& pdy)
+        : x(px)
+        , y(py)
+        , dx(pdx)
+        , dy(pdy)
+        , dx_0(T())
+        , dy_0(T())
+    {}
+
+    T x, y;
+    T dx, dy;
+    T dx_0, dy_0;
+
+    // For sorting
+    inline bool operator<(collected_vector<T> const& other) const
+    {
+        if (math::equals(x, other.x))
+        {
+            if (math::equals(y, other.y))
+            {
+                if (math::equals(dx, other.dx))
+                {
+                    return dy < other.dy;
+                }
+                return dx < other.dx;
+            }
+            return y < other.y;
+        }
+        return x < other.x;
+    }
+
+    inline bool same_direction(collected_vector<T> const& other) const
+    {
+        // For high precision arithmetic, we have to be 
+        // more relaxed then using ==
+        // Because 2/sqrt( (0,0)<->(2,2) ) == 1/sqrt( (0,0)<->(1,1) ) 
+        // is not always true (at least, it is not for ttmath)
+        return math::equals_with_epsilon(dx, other.dx)
+            && math::equals_with_epsilon(dy, other.dy);
+    }
+
+    // For std::equals
+    inline bool operator==(collected_vector<T> const& other) const
+    {
+        return math::equals(x, other.x)
+            && math::equals(y, other.y)
+            && same_direction(other);
+    }
+};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace collect_vectors
+{
+
+
+template <typename Range, typename Collection>
+struct range_collect_vectors
+{
+    typedef typename boost::range_value<Collection>::type item_type;
+    typedef typename item_type::type calculation_type;
+
+    static inline void apply(Collection& collection, Range const& range)
+    {
+        if (boost::size(range) < 2)
+        {
+            return;
+        }
+
+        typedef typename boost::range_iterator<Range const>::type iterator;
+
+        bool first = true;
+        iterator it = boost::begin(range);
+
+        for (iterator prev = it++;
+            it != boost::end(range);
+            prev = it++)
+        {
+            typename boost::range_value<Collection>::type v;
+
+            v.x = get<0>(*prev);
+            v.y = get<1>(*prev);
+            v.dx = get<0>(*it) - v.x;
+            v.dy = get<1>(*it) - v.y;
+            v.dx_0 = v.dx;
+            v.dy_0 = v.dy;
+
+            // Normalize the vector -> this results in points+direction
+            // and is comparible between geometries
+            calculation_type magnitude = sqrt(
+                boost::numeric_cast<calculation_type>(v.dx * v.dx + v.dy * v.dy));
+
+            // Avoid non-duplicate points (AND division by zero)
+            if (magnitude > 0)
+            {
+                v.dx /= magnitude;
+                v.dy /= magnitude;
+
+                // Avoid non-direction changing points
+                if (first || ! v.same_direction(collection.back()))
+                {
+                    collection.push_back(v);
+                }
+                first = false;
+            }
+        }
+
+        // If first one has same direction as last one, remove first one
+        if (boost::size(collection) > 1 
+            && collection.front().same_direction(collection.back()))
+        {
+            collection.erase(collection.begin());
+        }
+    }
+};
+
+
+template <typename Box, typename Collection>
+struct box_collect_vectors
+{
+    // Calculate on coordinate type, but if it is integer,
+    // then use double
+    typedef typename boost::range_value<Collection>::type item_type;
+    typedef typename item_type::type calculation_type;
+
+    static inline void apply(Collection& collection, Box const& box)
+    {
+        typename point_type<Box>::type lower_left, lower_right,
+                upper_left, upper_right;
+        geometry::detail::assign_box_corners(box, lower_left, lower_right,
+                upper_left, upper_right);
+
+        typedef typename boost::range_value<Collection>::type item;
+
+        collection.push_back(item(get<0>(lower_left), get<1>(lower_left), 0, 1));
+        collection.push_back(item(get<0>(upper_left), get<1>(upper_left), 1, 0));
+        collection.push_back(item(get<0>(upper_right), get<1>(upper_right), 0, -1));
+        collection.push_back(item(get<0>(lower_right), get<1>(lower_right), -1, 0));
+    }
+};
+
+
+template <typename Polygon, typename Collection>
+struct polygon_collect_vectors
+{
+    static inline void apply(Collection& collection, Polygon const& polygon)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef range_collect_vectors<ring_type, Collection> per_range;
+        per_range::apply(collection, exterior_ring(polygon));
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            per_range::apply(collection, *it);
+        }
+    }
+};
+
+
+template <typename MultiGeometry, typename Collection, typename SinglePolicy>
+struct multi_collect_vectors
+{
+    static inline void apply(Collection& collection, MultiGeometry const& multi)
+    {
+        for (typename boost::range_iterator<MultiGeometry const>::type
+                it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            SinglePolicy::apply(collection, *it);
+        }
+    }
+};
+
+
+}} // namespace detail::collect_vectors
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Collection,
+    typename Geometry
+>
+struct collect_vectors
+{
+    static inline void apply(Collection&, Geometry const&)
+    {}
+};
+
+
+template <typename Collection, typename Box>
+struct collect_vectors<box_tag, Collection, Box>
+    : detail::collect_vectors::box_collect_vectors<Box, Collection>
+{};
+
+
+
+template <typename Collection, typename Ring>
+struct collect_vectors<ring_tag, Collection, Ring>
+    : detail::collect_vectors::range_collect_vectors<Ring, Collection>
+{};
+
+
+template <typename Collection, typename LineString>
+struct collect_vectors<linestring_tag, Collection, LineString>
+    : detail::collect_vectors::range_collect_vectors<LineString, Collection>
+{};
+
+
+template <typename Collection, typename Polygon>
+struct collect_vectors<polygon_tag, Collection, Polygon>
+    : detail::collect_vectors::polygon_collect_vectors<Polygon, Collection>
+{};
+
+
+template <typename Collection, typename MultiPolygon>
+struct collect_vectors<multi_polygon_tag, Collection, MultiPolygon>
+    : detail::collect_vectors::multi_collect_vectors
+        <
+            MultiPolygon,
+            Collection,
+            detail::collect_vectors::polygon_collect_vectors
+            <
+                typename boost::range_value<MultiPolygon>::type,
+                Collection
+            >
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+    \ingroup collect_vectors
+    \tparam Collection Collection type, should be e.g. std::vector<>
+    \tparam Geometry geometry type
+    \param collection the collection of vectors
+    \param geometry the geometry to make collect_vectors
+*/
+template <typename Collection, typename Geometry>
+inline void collect_vectors(Collection& collection, Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    dispatch::collect_vectors
+        <
+            typename tag<Geometry>::type,
+            Collection,
+            Geometry
+        >::apply(collection, geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_COLLECT_VECTORS_HPP
diff --git a/src/boost/geometry/algorithms/detail/for_each_range.hpp b/src/boost/geometry/algorithms/detail/for_each_range.hpp
new file mode 100644
index 0000000..7cb01fa
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/for_each_range.hpp
@@ -0,0 +1,149 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/util/add_const_if_c.hpp>
+#include <boost/geometry/views/box_view.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace for_each
+{
+
+
+template <typename Range, typename Actor, bool IsConst>
+struct fe_range_range
+{
+    static inline void apply(
+                    typename add_const_if_c<IsConst, Range>::type& range,
+                    Actor& actor)
+    {
+        actor.apply(range);
+    }
+};
+
+
+template <typename Polygon, typename Actor, bool IsConst>
+struct fe_range_polygon
+{
+    static inline void apply(
+                    typename add_const_if_c<IsConst, Polygon>::type& polygon,
+                    Actor& actor)
+    {
+        actor.apply(exterior_ring(polygon));
+
+        // TODO: If some flag says true, also do the inner rings.
+        // for convex hull, it's not necessary
+    }
+};
+
+template <typename Box, typename Actor, bool IsConst>
+struct fe_range_box
+{
+    static inline void apply(
+                    typename add_const_if_c<IsConst, Box>::type& box,
+                    Actor& actor)
+    {
+        actor.apply(box_view<Box>(box));
+    }
+};
+
+
+}} // namespace detail::for_each
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename Actor,
+    bool IsConst
+>
+struct for_each_range
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Linestring, typename Actor, bool IsConst>
+struct for_each_range<linestring_tag, Linestring, Actor, IsConst>
+    : detail::for_each::fe_range_range<Linestring, Actor, IsConst>
+{};
+
+
+template <typename Ring, typename Actor, bool IsConst>
+struct for_each_range<ring_tag, Ring, Actor, IsConst>
+    : detail::for_each::fe_range_range<Ring, Actor, IsConst>
+{};
+
+
+template <typename Polygon, typename Actor, bool IsConst>
+struct for_each_range<polygon_tag, Polygon, Actor, IsConst>
+    : detail::for_each::fe_range_polygon<Polygon, Actor, IsConst>
+{};
+
+template <typename Box, typename Actor, bool IsConst>
+struct for_each_range<box_tag, Box, Actor, IsConst>
+    : detail::for_each::fe_range_box<Box, Actor, IsConst>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+namespace detail
+{
+
+template <typename Geometry, typename Actor>
+inline void for_each_range(Geometry const& geometry, Actor& actor)
+{
+    dispatch::for_each_range
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Actor,
+            true
+        >::apply(geometry, actor);
+}
+
+
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
diff --git a/src/boost/geometry/algorithms/detail/get_left_turns.hpp b/src/boost/geometry/algorithms/detail/get_left_turns.hpp
new file mode 100644
index 0000000..62f0f7f
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/get_left_turns.hpp
@@ -0,0 +1,367 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_LEFT_TURNS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_LEFT_TURNS_HPP
+
+#include <boost/geometry/iterators/ever_circling_iterator.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+// TODO: move this to /util/
+template <typename T>
+static inline std::pair<T, T> ordered_pair(T const& first, T const& second)
+{
+    return first < second ? std::make_pair(first, second) : std::make_pair(second, first);
+}
+
+template <typename AngleInfo>
+inline void debug_left_turn(AngleInfo const& ai, AngleInfo const& previous)
+{
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_OCCUPATION
+    std::cout << "Angle: " << (ai.incoming ? "i" : "o") 
+        << " " << si(ai.seg_id) 
+        << " " << (math::r2d * (ai.angle) )
+        << " turn: " << ai.turn_index << "[" << ai.operation_index << "]"
+        ;
+
+    if (ai.turn_index != previous.turn_index
+        || ai.operation_index != previous.operation_index)
+    {
+        std::cout << " diff: " << math::r2d * math::abs(previous.angle - ai.angle);
+    }
+    std::cout << std::endl;
+#endif
+}
+
+template <typename AngleInfo>
+inline void debug_left_turn(std::string const& caption, AngleInfo const& ai, AngleInfo const& previous,
+            int code = -99, int code2 = -99, int code3 = -99, int code4 = -99)
+{
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_OCCUPATION
+    std::cout << " " << caption
+            << " turn: " << ai.turn_index << "[" << ai.operation_index << "]"
+            << " " << si(ai.seg_id) 
+            << " " << (ai.incoming ? "i" : "o") 
+            << " " << (math::r2d * (ai.angle) )
+            << " turn: " << previous.turn_index << "[" << previous.operation_index << "]"
+            << " " << si(previous.seg_id) 
+            << " " << (previous.incoming ? "i" : "o") 
+            << " " << (math::r2d * (previous.angle) )
+            ;
+
+    if (code != -99)
+    {
+        std::cout << " code: " << code << " , " << code2 << " , " << code3 << " , " << code4;
+    }
+    std::cout << std::endl;
+#endif
+}
+
+
+template <typename Operation>
+inline bool include_operation(Operation const& op, 
+                segment_identifier const& outgoing_seg_id,
+                segment_identifier const& incoming_seg_id)
+{
+    return op.seg_id == outgoing_seg_id
+        && op.other_id == incoming_seg_id
+        && (op.operation == detail::overlay::operation_union
+            ||op.operation == detail::overlay::operation_continue)
+            ;
+}
+
+template <typename Turn>
+inline bool process_include(segment_identifier const& outgoing_seg_id, segment_identifier const& incoming_seg_id,
+                int turn_index, Turn& turn,
+                std::set<int>& keep_indices, int priority)
+{
+    bool result = false;
+    for (int i = 0; i < 2; i++)
+    {
+        if (include_operation(turn.operations[i], outgoing_seg_id, incoming_seg_id))
+        {
+            turn.operations[i].include_in_occupation_map = true;
+            if (priority > turn.priority)
+            {
+                turn.priority = priority;
+            }
+            keep_indices.insert(turn_index);
+            result = true;
+        }
+    }
+    return result;
+}
+
+template <typename AngleInfo, typename Turns, typename TurnSegmentIndices>
+inline bool include_left_turn_of_all(
+                AngleInfo const& outgoing, AngleInfo const& incoming,
+                Turns& turns, TurnSegmentIndices const& turn_segment_indices,
+                std::set<int>& keep_indices, int priority)
+{
+    segment_identifier const& outgoing_seg_id = turns[outgoing.turn_index].operations[outgoing.operation_index].seg_id;
+    segment_identifier const& incoming_seg_id = turns[incoming.turn_index].operations[incoming.operation_index].seg_id;
+
+    if (outgoing.turn_index == incoming.turn_index)
+    {
+        return process_include(outgoing_seg_id, incoming_seg_id, outgoing.turn_index, turns[outgoing.turn_index], keep_indices, priority);
+    }
+
+    bool result = false;
+    std::pair<segment_identifier, segment_identifier> pair = ordered_pair(outgoing_seg_id, incoming_seg_id);
+    auto it = turn_segment_indices.find(pair);
+    if (it != turn_segment_indices.end())
+    {
+        for (auto sit = it->second.begin(); sit != it->second.end(); ++sit)
+        {
+            if (process_include(outgoing_seg_id, incoming_seg_id, *sit, turns[*sit], keep_indices, priority))
+            {
+                result = true;
+            }
+        }
+    }
+    return result;
+}
+
+template <std::size_t Index, typename Turn>
+inline bool corresponds(Turn const& turn, segment_identifier const& seg_id)
+{
+    return turn.operations[Index].operation == detail::overlay::operation_union
+        && turn.operations[Index].seg_id == seg_id;
+}
+
+
+template <typename Turns, typename TurnSegmentIndices>
+inline bool prefer_by_other(Turns const& turns,
+            TurnSegmentIndices const& turn_segment_indices,
+            std::set<int>& indices)
+{
+    std::map<segment_identifier, int> map;
+    for (auto sit = indices.begin(); sit != indices.end(); ++sit)
+    {
+        map[turns[*sit].operations[0].seg_id]++;
+        map[turns[*sit].operations[1].seg_id]++;
+    }
+
+    std::set<segment_identifier> segment_occuring_once;
+    for (auto mit = map.begin(); mit != map.end(); ++mit)
+    {
+        if (mit->second == 1)
+        {
+            segment_occuring_once.insert(mit->first);
+        }
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_PREFER
+        std::cout << si(mit->first) << " " << mit->second << std::endl;
+#endif
+    }
+
+    if (segment_occuring_once.size() == 2)
+    {
+        // Try to find within all turns a turn with these two segments
+
+        std::set<segment_identifier>::const_iterator soo_it = segment_occuring_once.begin();
+        segment_identifier front = *soo_it;
+        soo_it++;
+        segment_identifier back = *soo_it;
+
+        std::pair<segment_identifier, segment_identifier> pair = ordered_pair(front, back);
+        auto it = turn_segment_indices.find(pair);
+        if (it != turn_segment_indices.end())
+        {
+            // debug_turns_by_indices("Found", it->second);
+            // Check which is the union/continue
+            segment_identifier good;
+            for (auto sit = it->second.begin(); sit != it->second.end(); ++sit)
+            {
+                if (turns[*sit].operations[0].operation == detail::overlay::operation_union)
+                {
+                    good = turns[*sit].operations[0].seg_id;
+                }
+                else if (turns[*sit].operations[1].operation == detail::overlay::operation_union)
+                {
+                    good = turns[*sit].operations[1].seg_id;
+                }
+            }
+
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_PREFER
+            std::cout << "Good: " << si(good) << std::endl;
+#endif
+
+            // Find in indexes-to-keep this segment with the union. Discard the other one
+            std::set<int> ok_indices;
+            for (auto sit = indices.begin(); sit != indices.end(); ++sit)
+            {
+                if (corresponds<0>(turns[*sit], good) || corresponds<1>(turns[*sit], good))
+                {
+                    ok_indices.insert(*sit);
+                }
+            }
+            if (ok_indices.size() > 0 && ok_indices.size() < indices.size())
+            {
+                indices = ok_indices;
+                std::cout << "^";
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+template <typename Turns>
+inline void prefer_by_priority(Turns const& turns, std::set<int>& indices)
+{
+    // Find max prio
+    int min_prio = 1024, max_prio = 0;
+    for (auto sit = indices.begin(); sit != indices.end(); ++sit)
+    {
+        if (turns[*sit].priority > max_prio)
+        {
+            max_prio = turns[*sit].priority;
+        }
+        if (turns[*sit].priority < min_prio)
+        {
+            min_prio = turns[*sit].priority;
+        }
+    }
+
+    if (min_prio == max_prio)
+    {
+        return;
+    }
+
+    // Only keep indices with high prio
+    std::set<int> ok_indices;
+    for (auto sit = indices.begin(); sit != indices.end(); ++sit)
+    {
+        if (turns[*sit].priority >= max_prio)
+        {
+            ok_indices.insert(*sit);
+        }
+    }
+    if (ok_indices.size() > 0 && ok_indices.size() < indices.size())
+    {
+        indices = ok_indices;
+        std::cout << "%";
+    }
+}
+
+template <typename AngleInfo, typename Angles, typename Turns, typename TurnSegmentIndices>
+inline void calculate_left_turns(Angles const& angles, 
+                Turns& turns, TurnSegmentIndices const& turn_segment_indices,
+                std::set<int>& keep_indices)
+{
+    bool debug_indicate_size = false;
+
+    typedef typename strategy::side::services::default_strategy
+        <
+            typename cs_tag<typename AngleInfo::point_type>::type
+        >::type side_strategy;
+
+    std::size_t i = 0;
+    std::size_t n = boost::size(angles);
+
+    typedef geometry::ever_circling_range_iterator<Angles const> circling_iterator;
+    circling_iterator cit(angles);
+
+    debug_left_turn(*cit, *cit);
+    for(circling_iterator prev = cit++; i < n; prev = cit++, i++)
+    {
+        debug_left_turn(*cit, *prev);
+
+        bool const include = ! geometry::math::equals(prev->angle, cit->angle)
+            && ! prev->incoming
+            && cit->incoming;
+
+        if (include)
+        {
+            // Go back to possibly include more same left outgoing angles:
+            // Because we check on side too we can take a large "epsilon"
+            circling_iterator back = prev - 1;
+
+            typename AngleInfo::angle_type eps = 0.00001;
+            int b = 1;
+            for(std::size_t d = 0; 
+                    math::abs(prev->angle - back->angle) < eps 
+                        && ! back->incoming 
+                        && d < n;
+                d++)
+            {
+                --back;
+                ++b;
+            }
+
+            // Same but forward to possibly include more incoming angles
+            int f = 1;
+            circling_iterator forward = cit + 1;
+            for(std::size_t d = 0;
+                    math::abs(cit->angle - forward->angle) < eps 
+                        && forward->incoming 
+                        && d < n;
+                    d++)
+            {
+                ++forward;
+                ++f;
+            }
+
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_OCCUPATION
+            std::cout << "HANDLE " << b << "/" << f << " ANGLES" << std::endl;
+#endif
+            for(circling_iterator bit = prev; bit != back; --bit)
+            {
+                int code = side_strategy::apply(bit->direction_point, prev->intersection_point, prev->direction_point);
+                int code2 = side_strategy::apply(prev->direction_point, bit->intersection_point, bit->direction_point);
+                for(circling_iterator fit = cit; fit != forward; ++fit)
+                {
+                    int code3 = side_strategy::apply(fit->direction_point, cit->intersection_point, cit->direction_point);
+                    int code4 = side_strategy::apply(cit->direction_point, fit->intersection_point, fit->direction_point);
+
+                    int priority = 2;
+                    if (code == -1 && code2 == 1)
+                    {
+                        // This segment is lying right of the other one.
+                        // Cannot ignore it (because of robustness, see a.o. #rt_p21 from unit test).
+                        // But if we find more we can prefer later by priority
+                        // (a.o. necessary for #rt_o2 from unit test)
+                        priority = 1;
+                    }
+
+                    bool included = include_left_turn_of_all(*bit, *fit, turns, turn_segment_indices, keep_indices, priority);
+                    debug_left_turn(included ? "KEEP" : "SKIP", *fit, *bit, code, code2, code3, code4);
+                }
+            }
+        }
+    }
+
+    if (debug_indicate_size)
+    {
+        std::cout << " size=" << keep_indices.size();
+    }
+
+    if (keep_indices.size() >= 2)
+    {
+        prefer_by_other(turns, turn_segment_indices, keep_indices);
+    }
+    if (keep_indices.size() >= 2)
+    {
+            prefer_by_priority(turns, keep_indices);
+    }
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_LEFT_TURNS_HPP
diff --git a/src/boost/geometry/algorithms/detail/has_self_intersections.hpp b/src/boost/geometry/algorithms/detail/has_self_intersections.hpp
new file mode 100644
index 0000000..1e6215e
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/has_self_intersections.hpp
@@ -0,0 +1,120 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_HAS_SELF_INTERSECTIONS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_HAS_SELF_INTERSECTIONS_HPP
+
+#include <deque>
+
+#include <boost/range.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
+
+#include <boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp>
+
+#ifdef BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS
+#  include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+#  include <boost/geometry/io/dsv/write.hpp>
+#endif
+
+
+namespace boost { namespace geometry
+{
+
+
+#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW)
+
+/*!
+\brief Overlay Invalid Input Exception
+\ingroup overlay
+\details The overlay_invalid_input_exception is thrown at invalid input
+ */
+class overlay_invalid_input_exception : public geometry::exception
+{
+public:
+
+    inline overlay_invalid_input_exception() {}
+
+    virtual char const* what() const throw()
+    {
+        return "Boost.Geometry Overlay invalid input exception";
+    }
+};
+
+#endif
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template <typename Geometry>
+inline bool has_self_intersections(Geometry const& geometry)
+{
+    typedef typename point_type<Geometry>::type point_type;
+    typedef detail::overlay::turn_info<point_type> turn_info;
+    std::deque<turn_info> turns;
+    detail::disjoint::disjoint_interrupt_policy policy;
+    geometry::self_turns<detail::overlay::assign_null_policy>(geometry, turns, policy);
+    
+#ifdef BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS
+    bool first = true;
+#endif    
+    for(typename std::deque<turn_info>::const_iterator it = boost::begin(turns); 
+        it != boost::end(turns); ++it)
+    {
+        turn_info const& info = *it;
+        bool const both_union_turn = 
+            info.operations[0].operation == detail::overlay::operation_union
+            && info.operations[1].operation == detail::overlay::operation_union;
+        bool const both_intersection_turn = 
+            info.operations[0].operation == detail::overlay::operation_intersection
+            && info.operations[1].operation == detail::overlay::operation_intersection;
+
+        bool const valid = (both_union_turn || both_intersection_turn)
+            && (info.method == detail::overlay::method_touch
+                || info.method == detail::overlay::method_touch_interior);
+
+        if (! valid)
+        {
+#ifdef BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS
+            if (first)
+            {
+                std::cout << "turn points: " << std::endl;
+                first = false;
+            }
+            std::cout << method_char(info.method);
+            for (int i = 0; i < 2; i++)
+            {
+                std::cout << " " << operation_char(info.operations[i].operation);
+            }
+            std::cout << " " << geometry::dsv(info.point) << std::endl;
+#endif
+
+#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW)
+            throw overlay_invalid_input_exception();
+#endif
+        }
+
+    }
+    return false;
+}
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_HAS_SELF_INTERSECTIONS_HPP
+
diff --git a/src/boost/geometry/algorithms/detail/not.hpp b/src/boost/geometry/algorithms/detail/not.hpp
new file mode 100644
index 0000000..abc3a4e
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/not.hpp
@@ -0,0 +1,50 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_NOT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_NOT_HPP
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+
+/*!
+\brief Structure negating the result of specified policy
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Policy
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return Negation of the result of the policy
+ */
+template <typename Geometry1, typename Geometry2, typename Policy>
+struct not_
+{
+    static inline bool apply(Geometry1 const &geometry1, Geometry2 const& geometry2)
+    {
+        return ! Policy::apply(geometry1, geometry2);
+    }
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_NOT_HPP
diff --git a/src/boost/geometry/algorithms/detail/occupation_info.hpp b/src/boost/geometry/algorithms/detail/occupation_info.hpp
new file mode 100644
index 0000000..e147ba1
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/occupation_info.hpp
@@ -0,0 +1,329 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OCCUPATION_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OCCUPATION_INFO_HPP
+
+#if ! defined(NDEBUG)
+  #define BOOST_GEOMETRY_DEBUG_BUFFER_OCCUPATION
+#endif
+
+#include <algorithm>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/algorithms/equals.hpp>
+#include <boost/geometry/iterators/closing_iterator.hpp>
+
+#include <boost/geometry/algorithms/detail/get_left_turns.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename P>
+class relaxed_less
+{
+    typedef typename geometry::coordinate_type<P>::type coordinate_type;
+
+    coordinate_type epsilon;
+
+public :
+
+    inline relaxed_less()
+    {
+        // TODO: adapt for ttmath, and maybe build the map in another way 
+        // (e.g. exact constellations of segment-id's), maybe adaptive.
+        epsilon = std::numeric_limits<double>::epsilon() * 100.0;
+    }
+
+    inline bool operator()(P const& a, P const& b) const
+    {
+        coordinate_type const dx = math::abs(geometry::get<0>(a) - geometry::get<0>(b));
+        coordinate_type const dy = math::abs(geometry::get<1>(a) - geometry::get<1>(b));
+
+
+        if (dx < epsilon && dy < epsilon)
+        {
+            return false;
+        }
+        if (dx < epsilon)
+        {
+            return geometry::get<1>(a) < geometry::get<1>(b);
+        }
+
+        return geometry::get<0>(a) < geometry::get<0>(b);
+    }
+
+    inline bool equals(P const& a, P const& b) const
+    {
+        typedef typename geometry::coordinate_type<P>::type coordinate_type;
+
+        coordinate_type const dx = math::abs(geometry::get<0>(a) - geometry::get<0>(b));
+        coordinate_type const dy = math::abs(geometry::get<1>(a) - geometry::get<1>(b));
+
+        return dx < epsilon && dy < epsilon;
+    };
+};
+
+
+template <typename T, typename P1, typename P2>
+inline T calculate_angle(P1 const& from_point, P2 const& to_point)
+{
+    typedef P1 vector_type;
+    vector_type v = from_point;
+    geometry::subtract_point(v, to_point);
+    return atan2(geometry::get<1>(v), geometry::get<0>(v));
+}
+
+template <typename Iterator, typename Vector>
+inline Iterator advance_circular(Iterator it, Vector const& vector, segment_identifier& seg_id, bool forward = true)
+{
+	int const increment = forward ? 1 : -1;
+	if (it == boost::begin(vector) && increment < 0)
+	{
+		it = boost::end(vector);
+        seg_id.segment_index = boost::size(vector);
+	}
+	it += increment;
+    seg_id.segment_index += increment;
+	if (it == boost::end(vector))
+	{
+        seg_id.segment_index = 0;
+		it = boost::begin(vector);
+	}
+	return it;
+}
+
+template <typename Point, typename T>
+struct angle_info
+{
+	typedef T angle_type;
+    typedef Point point_type;
+
+    segment_identifier seg_id;
+    int turn_index;
+    int operation_index;
+    Point intersection_point;
+    Point direction_point;
+    T angle;
+    bool incoming;
+};
+
+template <typename AngleInfo>
+class occupation_info
+{
+	typedef std::vector<AngleInfo> collection_type;
+
+	struct angle_sort
+	{
+		inline bool operator()(AngleInfo const& left, AngleInfo const& right) const
+		{
+			// In this case we can compare even double using equals
+			// return geometry::math::equals(left.angle, right.angle)
+			return left.angle == right.angle
+				? int(left.incoming) < int(right.incoming)
+				: left.angle < right.angle
+				;
+		}
+	};
+
+public :
+    collection_type angles;
+private :
+    bool m_occupied;
+	bool m_calculated;
+
+	inline bool is_occupied()
+	{
+		if (boost::size(angles) <= 1)
+		{
+			return false;
+		}
+
+		std::sort(angles.begin(), angles.end(), angle_sort());
+
+		typedef geometry::closing_iterator<collection_type const> closing_iterator;
+		closing_iterator vit(angles);
+		closing_iterator end(angles, true);
+
+		closing_iterator prev = vit++;
+		for( ; vit != end; prev = vit++)
+		{
+			if (! geometry::math::equals(prev->angle, vit->angle)
+				&& ! prev->incoming
+				&& vit->incoming)
+			{
+				return false;
+			}
+		}
+		return true;
+	}
+
+public :
+    inline occupation_info()
+        : m_occupied(false)
+		, m_calculated(false)
+    {}
+
+	template <typename PointC, typename Point1, typename Point2>
+	inline void add(PointC const& map_point, Point1 const& direction_point, Point2 const& intersection_point,
+                    int turn_index, int operation_index,
+                    segment_identifier const& seg_id, bool incoming)
+	{
+        //std::cout << "-> adding angle " << geometry::wkt(direction_point) << " .. " << geometry::wkt(intersection_point) << " " << int(incoming) << std::endl;
+		if (geometry::equals(direction_point, intersection_point))
+		{
+			//std::cout << "EQUAL! Skipping" << std::endl;
+			return;
+		}
+
+        AngleInfo info;
+        info.incoming = incoming;
+        info.angle = calculate_angle<typename AngleInfo::angle_type>(direction_point, map_point);
+        info.seg_id = seg_id;
+        info.turn_index = turn_index;
+        info.operation_index = operation_index;
+        info.intersection_point = intersection_point;
+        info.direction_point = direction_point;
+        angles.push_back(info);
+
+		m_calculated = false;
+	}
+
+	inline bool occupied()
+	{
+		if (! m_calculated)
+		{
+			m_occupied = is_occupied();
+			m_calculated = true;
+		}
+		return m_occupied;
+	}
+
+    template <typename Turns, typename TurnSegmentIndices>
+    inline void get_left_turns(
+                    Turns& turns, TurnSegmentIndices const& turn_segment_indices,
+                    std::set<int>& keep_indices)
+    {
+        std::sort(angles.begin(), angles.end(), angle_sort());
+        calculate_left_turns<AngleInfo>(angles, turns, turn_segment_indices, keep_indices);
+    }
+};
+
+
+template <typename Point, typename Ring, typename Info>
+inline void add_incoming_and_outgoing_angles(Point const& map_point, Point const& intersection_point,
+				Ring const& ring, 
+                int turn_index,
+                int operation_index,
+                segment_identifier seg_id,
+                Info& info)
+{
+    typedef typename boost::range_iterator
+        <
+            Ring const
+        >::type iterator_type;
+
+	int const n = boost::size(ring);
+	if (seg_id.segment_index >= n || seg_id.segment_index < 0)
+	{
+		return;
+	}
+
+    segment_identifier real_seg_id = seg_id;
+	iterator_type it = boost::begin(ring) + seg_id.segment_index;
+
+    // TODO: if we use turn-info ("to", "middle"), we know if to advance without resorting to equals
+    relaxed_less<Point> comparator;
+
+    if (comparator.equals(intersection_point, *it))
+    {
+		// It should be equal only once. But otherwise we skip it (in "add")
+		it = advance_circular(it, ring, seg_id, false);
+    }
+
+	info.add(map_point, *it, intersection_point, turn_index, operation_index, real_seg_id, true);
+
+    if (comparator.equals(intersection_point, *it))
+    {
+		it = advance_circular(it, ring, real_seg_id);
+	}
+	else
+	{
+		// Don't upgrade the ID
+		it = advance_circular(it, ring, seg_id);
+	}
+    for (int defensive_check = 0; 
+		comparator.equals(intersection_point, *it) && defensive_check < n; 
+		defensive_check++)
+    {
+		it = advance_circular(it, ring, real_seg_id);
+    }
+
+	info.add(map_point, *it, intersection_point, turn_index, operation_index, real_seg_id, false);
+}
+
+
+// Map in two senses of the word: it is a std::map where the key is a point.
+// Per point an "occupation_info" record is kept
+// Used for the buffer (but will also be used for intersections/unions having complex self-tangencies)
+template <typename Point, typename OccupationInfo>
+class occupation_map
+{
+public :
+    typedef std::map<Point, OccupationInfo, relaxed_less<Point> > map_type;
+
+    map_type map;
+	std::set<int> turn_indices;
+
+    inline OccupationInfo& find_or_insert(Point const& point, Point& mapped_point)
+    {
+        typename map_type::iterator it = map.find(point);
+        if (it == boost::end(map))
+        {
+            std::pair<typename map_type::iterator, bool> pair 
+                        = map.insert(std::make_pair(point, OccupationInfo()));
+            it = pair.first;
+        }
+        mapped_point = it->first;
+        return it->second;
+    }
+
+    inline bool contains(Point const& point) const
+    {
+        typename map_type::const_iterator it = map.find(point);
+        return it != boost::end(map);
+    }
+
+    inline bool contains_turn_index(int index) const
+    {
+        return turn_indices.count(index) > 0;
+    }
+
+    inline void insert_turn_index(int index)
+    {
+        turn_indices.insert(index);
+    }
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OCCUPATION_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/add_rings.hpp b/src/boost/geometry/algorithms/detail/overlay/add_rings.hpp
new file mode 100644
index 0000000..74595fe
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/add_rings.hpp
@@ -0,0 +1,160 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ADD_RINGS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ADD_RINGS_HPP
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/detail/overlay/convert_ring.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename RingCollection
+>
+inline void convert_and_add(GeometryOut& result,
+            Geometry1 const& geometry1, Geometry2 const& geometry2,
+            RingCollection const& collection,
+            ring_identifier id,
+            bool reversed, bool append)
+{
+    typedef typename geometry::tag<Geometry1>::type tag1;
+    typedef typename geometry::tag<Geometry2>::type tag2;
+    typedef typename geometry::tag<GeometryOut>::type tag_out;
+
+    if (id.source_index == 0)
+    {
+        convert_ring<tag_out>::apply(result,
+                    get_ring<tag1>::apply(id, geometry1),
+                    append, reversed);
+    }
+    else if (id.source_index == 1)
+    {
+        convert_ring<tag_out>::apply(result,
+                    get_ring<tag2>::apply(id, geometry2),
+                    append, reversed);
+    }
+    else if (id.source_index == 2)
+    {
+        convert_ring<tag_out>::apply(result,
+                    get_ring<void>::apply(id, collection),
+                    append, reversed);
+    }
+}
+
+template
+<
+    typename GeometryOut,
+    typename SelectionMap,
+    typename Geometry1,
+    typename Geometry2,
+    typename RingCollection,
+    typename OutputIterator
+>
+inline OutputIterator add_rings(SelectionMap const& map,
+            Geometry1 const& geometry1, Geometry2 const& geometry2,
+            RingCollection const& collection,
+            OutputIterator out)
+{
+    typedef typename SelectionMap::const_iterator iterator;
+	typedef typename SelectionMap::mapped_type property_type;
+	typedef typename property_type::area_type area_type;
+
+	area_type const zero = 0;
+	std::size_t const min_num_points = core_detail::closure::minimum_ring_size
+		<
+			geometry::closure
+				<
+					typename boost::range_value
+                        <
+                            RingCollection const
+                        >::type
+                >::value
+        >::value;
+
+
+    for (iterator it = boost::begin(map);
+        it != boost::end(map);
+        ++it)
+    {
+        if (! it->second.discarded
+            && it->second.parent.source_index == -1)
+        {
+            GeometryOut result;
+            convert_and_add(result, geometry1, geometry2, collection,
+                    it->first, it->second.reversed, false);
+
+            // Add children
+            for (typename std::vector<ring_identifier>::const_iterator child_it
+                        = it->second.children.begin();
+                child_it != it->second.children.end();
+                ++child_it)
+            {
+                iterator mit = map.find(*child_it);
+                if (mit != map.end()
+                    && ! mit->second.discarded)
+                {
+                    convert_and_add(result, geometry1, geometry2, collection,
+                            *child_it, mit->second.reversed, true);
+                }
+            }
+
+			// Only add rings if they satisfy minimal requirements.
+			// This cannot be done earlier (during traversal), not
+			// everything is figured out yet (sum of positive/negative rings)
+			// TODO: individual rings can still contain less than 3 points.
+			if (geometry::num_points(result) >= min_num_points
+				&& math::larger(geometry::area(result), zero))
+			{
+				*out++ = result;
+			}
+        }
+    }
+    return out;
+}
+
+
+template
+<
+    typename GeometryOut,
+    typename SelectionMap,
+    typename Geometry,
+    typename RingCollection,
+    typename OutputIterator
+>
+inline OutputIterator add_rings(SelectionMap const& map,
+            Geometry const& geometry,
+            RingCollection const& collection,
+            OutputIterator out)
+{
+    Geometry empty;
+    return add_rings<GeometryOut>(map, geometry, empty, collection, out);
+}
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ADD_RINGS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp b/src/boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp
new file mode 100644
index 0000000..2c0f88e
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp
@@ -0,0 +1,53 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPEND_NO_DUPLICATES_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPEND_NO_DUPLICATES_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+template <typename Range, typename Point>
+inline void append_no_duplicates(Range& range, Point const& point, bool force = false)
+{
+    if (boost::size(range) == 0
+        || force 
+        || ! geometry::detail::equals::equals_point_point(*(boost::end(range)-1), point))
+    {
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+        std::cout << "  add: ("
+            << geometry::get<0>(point) << ", " << geometry::get<1>(point) << ")"
+            << std::endl;
+#endif
+        geometry::append(range, point);
+    }
+}
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_APPEND_NO_DUPLICATES_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/assign_parents.hpp b/src/boost/geometry/algorithms/detail/overlay/assign_parents.hpp
new file mode 100644
index 0000000..5063f49
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/assign_parents.hpp
@@ -0,0 +1,338 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ASSIGN_PARENTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ASSIGN_PARENTS_HPP
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/envelope.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/algorithms/detail/partition.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+
+#include <boost/geometry/geometries/box.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+
+template
+<
+    typename Item,
+    typename Geometry1, typename Geometry2,
+    typename RingCollection
+>
+static inline bool within_selected_input(Item const& item2, ring_identifier const& ring_id,
+        Geometry1 const& geometry1, Geometry2 const& geometry2,
+        RingCollection const& collection)
+{
+    typedef typename geometry::tag<Geometry1>::type tag1;
+    typedef typename geometry::tag<Geometry2>::type tag2;
+
+    switch (ring_id.source_index)
+    {
+        case 0 :
+            return geometry::within(item2.point,
+                get_ring<tag1>::apply(ring_id, geometry1));
+            break;
+        case 1 :
+            return geometry::within(item2.point,
+                get_ring<tag2>::apply(ring_id, geometry2));
+            break;
+        case 2 :
+            return geometry::within(item2.point,
+                get_ring<void>::apply(ring_id, collection));
+            break;
+    }
+    return false;
+}
+
+
+template <typename Point>
+struct ring_info_helper
+{
+    typedef typename geometry::default_area_result<Point>::type area_type;
+
+    ring_identifier id;
+    area_type real_area;
+    area_type abs_area;
+    model::box<Point> envelope;
+
+    inline ring_info_helper()
+        : real_area(0), abs_area(0)
+    {}
+
+    inline ring_info_helper(ring_identifier i, area_type a)
+        : id(i), real_area(a), abs_area(geometry::math::abs(a))
+    {}
+};
+
+
+struct ring_info_helper_get_box
+{
+    template <typename Box, typename InputItem>
+    static inline void apply(Box& total, InputItem const& item)
+    {
+        geometry::expand(total, item.envelope);
+    }
+};
+
+struct ring_info_helper_ovelaps_box
+{
+    template <typename Box, typename InputItem>
+    static inline bool apply(Box const& box, InputItem const& item)
+    {
+        return ! geometry::detail::disjoint::disjoint_box_box(box, item.envelope);
+    }
+};
+
+template <typename Geometry1, typename Geometry2, typename Collection, typename RingMap>
+struct assign_visitor
+{
+    typedef typename RingMap::mapped_type ring_info_type;
+
+    Geometry1 const& m_geometry1;
+    Geometry2 const& m_geometry2;
+    Collection const& m_collection;
+    RingMap& m_ring_map;
+    bool m_check_for_orientation;
+
+
+    inline assign_visitor(Geometry1 const& g1, Geometry2 const& g2, Collection const& c,
+                RingMap& map, bool check)
+        : m_geometry1(g1)
+        , m_geometry2(g2)
+        , m_collection(c)
+        , m_ring_map(map)
+        , m_check_for_orientation(check)
+    {}
+
+    template <typename Item>
+    inline void apply(Item const& outer, Item const& inner, bool first = true)
+    {
+        if (first && outer.real_area < 0)
+        {
+            // Reverse arguments
+            apply(inner, outer, false);
+            return;
+        }
+
+        if (math::larger(outer.real_area, 0))
+        {
+            if (inner.real_area < 0 || m_check_for_orientation)
+            {
+                ring_info_type& inner_in_map = m_ring_map[inner.id];
+
+                if (geometry::within(inner_in_map.point, outer.envelope)
+                   && within_selected_input(inner_in_map, outer.id, m_geometry1, m_geometry2, m_collection)
+                   )
+                {
+                    // Only assign parent if that parent is smaller (or if it is the first)
+                    if (inner_in_map.parent.source_index == -1
+                        || outer.abs_area < inner_in_map.parent_area)
+                    {
+                        inner_in_map.parent = outer.id;
+                        inner_in_map.parent_area = outer.abs_area;
+                    }
+                }
+            }
+        }
+    }
+};
+
+
+
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    typename RingCollection,
+    typename RingMap
+>
+inline void assign_parents(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            RingCollection const& collection,
+            RingMap& ring_map,
+            bool check_for_orientation = false)
+{
+    typedef typename geometry::tag<Geometry1>::type tag1;
+    typedef typename geometry::tag<Geometry2>::type tag2;
+
+    typedef typename RingMap::mapped_type ring_info_type;
+    typedef typename ring_info_type::point_type point_type;
+    typedef model::box<point_type> box_type;
+
+    typedef typename RingMap::iterator map_iterator_type;
+
+    {
+        typedef ring_info_helper<point_type> helper;
+        typedef std::vector<helper> vector_type;
+        typedef typename boost::range_iterator<vector_type const>::type vector_iterator_type;
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        boost::timer timer;
+#endif
+
+
+        std::size_t count_total = ring_map.size();
+        std::size_t count_positive = 0;
+        std::size_t index_positive = 0; // only used if count_positive>0
+        std::size_t index = 0;
+
+        // Copy to vector (with new approach this might be obsolete as well, using the map directly)
+        vector_type vector(count_total);
+
+        for (map_iterator_type it = boost::begin(ring_map);
+            it != boost::end(ring_map); ++it, ++index)
+        {
+            vector[index] = helper(it->first, it->second.get_area());
+            helper& item = vector[index];
+            switch(it->first.source_index)
+            {
+                case 0 :
+                    geometry::envelope(get_ring<tag1>::apply(it->first, geometry1),
+                            item.envelope);
+                    break;
+                case 1 :
+                    geometry::envelope(get_ring<tag2>::apply(it->first, geometry2),
+                            item.envelope);
+                    break;
+                case 2 :
+                    geometry::envelope(get_ring<void>::apply(it->first, collection),
+                            item.envelope);
+                    break;
+            }
+            if (item.real_area > 0)
+            {
+                count_positive++;
+                index_positive = index;
+            }
+        }
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << " ap: created helper vector: " << timer.elapsed() << std::endl;
+#endif
+
+        if (! check_for_orientation)
+        {
+            if (count_positive == count_total)
+            {
+                // Optimization for only positive rings
+                // -> no assignment of parents or reversal necessary, ready here.
+                return;
+            }
+
+            if (count_positive == 1)
+            {
+                // Optimization for one outer ring
+                // -> assign this as parent to all others (all interior rings)
+                // In unions, this is probably the most occuring case and gives
+                //    a dramatic improvement (factor 5 for star_comb testcase)
+                ring_identifier id_of_positive = vector[index_positive].id;
+                ring_info_type& outer = ring_map[id_of_positive];
+                std::size_t index = 0;
+                for (vector_iterator_type it = boost::begin(vector);
+                    it != boost::end(vector); ++it, ++index)
+                {
+                    if (index != index_positive)
+                    {
+                        ring_info_type& inner = ring_map[it->id];
+                        inner.parent = id_of_positive;
+                        outer.children.push_back(it->id);
+                    }
+                }
+                return;
+            }
+        }
+
+        assign_visitor
+            <
+                Geometry1, Geometry2,
+                RingCollection, RingMap
+            > visitor(geometry1, geometry2, collection, ring_map, check_for_orientation);
+
+        geometry::partition
+            <
+                box_type, ring_info_helper_get_box, ring_info_helper_ovelaps_box
+            >::apply(vector, visitor);
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << " ap: quadradic loop: " << timer.elapsed() << std::endl;
+        std::cout << " ap: check_for_orientation " << check_for_orientation << std::endl;
+#endif
+    }
+
+    if (check_for_orientation)
+    {
+        for (map_iterator_type it = boost::begin(ring_map);
+            it != boost::end(ring_map); ++it)
+        {
+            if (geometry::math::equals(it->second.get_area(), 0))
+            {
+                it->second.discarded = true;
+            }
+            else if (it->second.parent.source_index >= 0 && it->second.get_area() > 0)
+            {
+                // Discard positive inner ring with parent
+                it->second.discarded = true;
+                it->second.parent.source_index = -1;
+            }
+            else if (it->second.parent.source_index < 0 && it->second.get_area() < 0)
+            {
+                // Reverse negative ring without parent
+                it->second.reversed = true;
+            }
+        }
+    }
+
+    // Assign childlist
+    for (map_iterator_type it = boost::begin(ring_map);
+        it != boost::end(ring_map); ++it)
+    {
+        if (it->second.parent.source_index >= 0)
+        {
+            ring_map[it->second.parent].children.push_back(it->first);
+        }
+    }
+}
+
+template
+<
+    typename Geometry,
+    typename RingCollection,
+    typename RingMap
+>
+inline void assign_parents(Geometry const& geometry,
+            RingCollection const& collection,
+            RingMap& ring_map,
+            bool check_for_orientation)
+{
+    // Call it with an empty geometry
+    // (ring_map should be empty for source_id==1)
+
+    Geometry empty;
+    assign_parents(geometry, empty, collection, ring_map, check_for_orientation);
+}
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ASSIGN_PARENTS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp b/src/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp
new file mode 100644
index 0000000..012b3ac
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp
@@ -0,0 +1,170 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_BACKTRACK_CHECK_SI_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_BACKTRACK_CHECK_SI_HPP
+
+#include <cstddef>
+#include <string>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/has_self_intersections.hpp>
+#if defined(BOOST_GEOMETRY_DEBUG_INTERSECTION) || defined(BOOST_GEOMETRY_OVERLAY_REPORT_WKT)
+#  include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+#  include <boost/geometry/io/wkt/wkt.hpp>
+#endif
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+template <typename Turns>
+inline void clear_visit_info(Turns& turns)
+{
+    typedef typename boost::range_value<Turns>::type tp_type;
+
+    for (typename boost::range_iterator<Turns>::type
+        it = boost::begin(turns);
+        it != boost::end(turns);
+        ++it)
+    {
+        for (typename boost::range_iterator
+            <
+                typename tp_type::container_type
+            >::type op_it = boost::begin(it->operations);
+            op_it != boost::end(it->operations);
+            ++op_it)
+        {
+            op_it->visited.clear();
+        }
+        it->discarded = false;
+    }
+}
+
+struct backtrack_state
+{
+    bool m_good;
+    
+    inline backtrack_state() : m_good(true) {}         
+    inline void reset() { m_good = true; }
+    inline bool good() const { return m_good; }
+};
+
+
+template
+<
+    typename Geometry1,
+    typename Geometry2
+>
+class backtrack_check_self_intersections
+{
+    struct state : public backtrack_state
+    {
+        bool m_checked;
+        inline state()
+            : m_checked()
+        {}
+    };
+public :
+    typedef state state_type;
+
+    template <typename Operation, typename Rings, typename Turns>
+    static inline void apply(std::size_t size_at_start, 
+                Rings& rings, typename boost::range_value<Rings>::type& ring,
+                Turns& turns, Operation& operation,
+                std::string const& ,
+                Geometry1 const& geometry1,
+                Geometry2 const& geometry2,
+                state_type& state
+                )
+    {
+        state.m_good = false;
+        
+        // Check self-intersections and throw exception if appropriate
+        if (! state.m_checked)
+        {
+            state.m_checked = true;
+            has_self_intersections(geometry1);
+            has_self_intersections(geometry2);
+        }
+
+        // Make bad output clean
+        rings.resize(size_at_start);
+        ring.clear();
+
+        // Reject this as a starting point
+        operation.visited.set_rejected();
+
+        // And clear all visit info
+        clear_visit_info(turns);
+    }
+};
+
+#ifdef BOOST_GEOMETRY_OVERLAY_REPORT_WKT
+template
+<
+    typename Geometry1,
+    typename Geometry2
+>
+class backtrack_debug
+{
+public :
+    typedef backtrack_state state_type;
+
+    template <typename Operation, typename Rings, typename Turns>
+    static inline void apply(std::size_t size_at_start, 
+                Rings& rings, typename boost::range_value<Rings>::type& ring,
+                Turns& turns, Operation& operation,
+                std::string const& reason,
+                Geometry1 const& geometry1,
+                Geometry2 const& geometry2,
+                state_type& state
+                )
+    {
+        std::cout << " REJECT " << reason << std::endl;
+        
+        state.m_good = false;
+
+        rings.resize(size_at_start);
+        ring.clear();
+        operation.visited.set_rejected();
+        clear_visit_info(turns);
+
+        int c = 0;
+        for (int i = 0; i < turns.size(); i++)
+        {
+            for (int j = 0; j < 2; j++)
+            {
+                if (turns[i].operations[j].visited.rejected())
+                {
+                    c++;
+                }
+            }
+        }
+        std::cout << "BACKTRACK (" << reason << " )"
+            << " " << c << " of " << turns.size() << " rejected"
+            << std::endl;
+        std::cout
+            << geometry::wkt(geometry1) << std::endl
+            << geometry::wkt(geometry2) << std::endl;
+    }
+};
+#endif // BOOST_GEOMETRY_OVERLAY_REPORT_WKT
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_BACKTRACK_CHECK_SI_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp b/src/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp
new file mode 100644
index 0000000..2003d23
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp
@@ -0,0 +1,64 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CALCULATE_DISTANCE_POLICY_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CALCULATE_DISTANCE_POLICY_HPP
+
+
+#include <boost/geometry/algorithms/comparable_distance.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+/*!
+    \brief Policy calculating distance
+    \details get_turn_info has an optional policy to get some
+        extra information.
+        This policy calculates the distance (using default distance strategy)
+ */
+struct calculate_distance_policy
+{
+    static bool const include_no_turn = false;
+    static bool const include_degenerate = false;
+    static bool const include_opposite = false;
+
+    template 
+	<
+		typename Info,
+		typename Point1,
+		typename Point2,
+		typename IntersectionInfo,
+		typename DirInfo
+	>
+    static inline void apply(Info& info, Point1 const& p1, Point2 const& p2,
+                IntersectionInfo const&, DirInfo const&)
+    {
+        info.operations[0].enriched.distance
+                    = geometry::comparable_distance(info.point, p1);
+        info.operations[1].enriched.distance
+                    = geometry::comparable_distance(info.point, p2);
+    }
+
+};
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CALCULATE_DISTANCE_POLICY_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/check_enrich.hpp b/src/boost/geometry/algorithms/detail/overlay/check_enrich.hpp
new file mode 100644
index 0000000..b210fd0
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/check_enrich.hpp
@@ -0,0 +1,172 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CHECK_ENRICH_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CHECK_ENRICH_HPP
+
+
+#include <cstddef>
+
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+
+
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template<typename Turn>
+struct meta_turn
+{
+    int index;
+    Turn const* turn;
+    bool handled[2];
+
+    inline meta_turn(int i, Turn const& t)
+        : index(i), turn(&t)
+    {
+        handled[0] = false;
+        handled[1] = false;
+    }
+};
+
+
+template <typename MetaTurn>
+inline void display(MetaTurn const& meta_turn, std::string const& reason = "")
+{
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    std::cout << meta_turn.index
+        << "\tMethods: " << method_char(meta_turn.turn->method)
+        << " operations: "  << operation_char(meta_turn.turn->operations[0].operation)
+                << operation_char(meta_turn.turn->operations[1].operation)
+        << " travels to " << meta_turn.turn->operations[0].enriched.travels_to_ip_index
+        << " and " << meta_turn.turn->operations[1].enriched.travels_to_ip_index
+        //<< " -> " << op_index
+        << " " << reason
+        << std::endl;
+#endif
+}
+
+
+template <typename MetaTurns, typename MetaTurn>
+inline void check_detailed(MetaTurns& meta_turns, MetaTurn const& meta_turn,
+            int op_index, int cycle, int start, operation_type for_operation,
+            bool& error)
+{
+    display(meta_turn);
+    int const ip_index = meta_turn.turn->operations[op_index].enriched.travels_to_ip_index;
+    if (ip_index >= 0)
+    {
+        bool found = false;
+
+        if (ip_index == start)
+        {
+            display(meta_turns[ip_index], " FINISH");
+            return;
+        }
+
+        // check on continuing, or on same-operation-on-same-geometry
+        if (! meta_turns[ip_index].handled[op_index]
+            && (meta_turns[ip_index].turn->operations[op_index].operation == operation_continue
+                || meta_turns[ip_index].turn->operations[op_index].operation == for_operation)
+            )
+        {
+            meta_turns[ip_index].handled[op_index] = true;
+            check_detailed(meta_turns, meta_turns[ip_index], op_index, cycle, start, for_operation, error);
+            found = true;
+        }
+        // check on other geometry
+        if (! found)
+        {
+            int const other_index = 1 - op_index;
+            if (! meta_turns[ip_index].handled[other_index]
+                && meta_turns[ip_index].turn->operations[other_index].operation == for_operation)
+            {
+                meta_turns[ip_index].handled[other_index] = true;
+                check_detailed(meta_turns, meta_turns[ip_index], other_index, cycle, start, for_operation, error);
+                found = true;
+            }
+        }
+
+        if (! found)
+        {
+            display(meta_turns[ip_index], " STOP");
+            error = true;
+#ifndef BOOST_GEOMETRY_DEBUG_ENRICH
+            //std::cout << " STOP";
+#endif
+        }
+    }
+}
+
+
+template <typename TurnPoints>
+inline bool check_graph(TurnPoints& turn_points, operation_type for_operation)
+{
+    typedef typename boost::range_value<TurnPoints>::type turn_point_type;
+
+    bool error = false;
+    int index = 0;
+
+    std::vector<meta_turn<turn_point_type> > meta_turns;
+    for (typename boost::range_iterator<TurnPoints const>::type
+            it = boost::begin(turn_points);
+         it != boost::end(turn_points);
+         ++it, ++index)
+    {
+        meta_turns.push_back(meta_turn<turn_point_type>(index, *it));
+    }
+
+    int cycle = 0;
+    for (typename boost::range_iterator<std::vector<meta_turn<turn_point_type> > > ::type
+            it = boost::begin(meta_turns);
+         it != boost::end(meta_turns);
+         ++it)
+    {
+        if (! (it->turn->blocked() || it->turn->is_discarded()))
+        {
+            for (int i = 0 ; i < 2; i++)
+            {
+                if (! it->handled[i]
+                    && it->turn->operations[i].operation == for_operation)
+                {
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+                    std::cout << "CYCLE " << cycle << std::endl;
+#endif
+                    it->handled[i] = true;
+                    check_detailed(meta_turns, *it, i, cycle++, it->index, for_operation, error);
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+                    std::cout <<" END CYCLE " << it->index << std::endl;
+#endif
+                }
+            }
+        }
+    }
+    return error;
+}
+
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CHECK_ENRICH_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp b/src/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp
new file mode 100644
index 0000000..fc4f657
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp
@@ -0,0 +1,242 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CLIP_LINESTRING_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CLIP_LINESTRING_HPP
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace intersection
+{
+
+/*!
+    \brief Strategy: line clipping algorithm after Liang Barsky
+    \ingroup overlay
+    \details The Liang-Barsky line clipping algorithm clips a line with a clipping box.
+    It is slightly adapted in the sense that it returns which points are clipped
+    \tparam B input box type of clipping box
+    \tparam P input/output point-type of segments to be clipped
+    \note The algorithm is currently only implemented for 2D Cartesian points
+    \note Though it is implemented in namespace strategy, and theoretically another
+        strategy could be used, it is not (yet) updated to the general strategy concepts,
+        and not (yet) splitted into a file in folder strategies
+    \author Barend Gehrels, and the following recourses
+    - A tutorial: http://www.skytopia.com/project/articles/compsci/clipping.html
+    - a German applet (link broken): http://ls7-www.cs.uni-dortmund.de/students/projectgroups/acit/lineclip.shtml
+*/
+template<typename Box, typename Point>
+class liang_barsky
+{
+private:
+    typedef model::referring_segment<Point> segment_type;
+
+    template <typename T>
+    inline bool check_edge(T const& p, T const& q, T& t1, T& t2) const
+    {
+        bool visible = true;
+
+        if(p < 0)
+        {
+            T const r = q / p;
+            if (r > t2)
+                visible = false;
+            else if (r > t1)
+                t1 = r;
+        }
+        else if(p > 0)
+        {
+            T const r = q / p;
+            if (r < t1)
+                visible = false;
+            else if (r < t2)
+                t2 = r;
+        }
+        else
+        {
+            if (q < 0)
+                visible = false;
+        }
+
+        return visible;
+    }
+
+public:
+
+    inline bool clip_segment(Box const& b, segment_type& s, bool& sp1_clipped, bool& sp2_clipped) const
+    {
+        typedef typename select_coordinate_type<Box, Point>::type coordinate_type;
+
+        coordinate_type t1 = 0;
+        coordinate_type t2 = 1;
+
+        coordinate_type const dx = get<1, 0>(s) - get<0, 0>(s);
+        coordinate_type const dy = get<1, 1>(s) - get<0, 1>(s);
+
+        coordinate_type const p1 = -dx;
+        coordinate_type const p2 = dx;
+        coordinate_type const p3 = -dy;
+        coordinate_type const p4 = dy;
+
+        coordinate_type const q1 = get<0, 0>(s) - get<min_corner, 0>(b);
+        coordinate_type const q2 = get<max_corner, 0>(b) - get<0, 0>(s);
+        coordinate_type const q3 = get<0, 1>(s) - get<min_corner, 1>(b);
+        coordinate_type const q4 = get<max_corner, 1>(b) - get<0, 1>(s);
+
+        if (check_edge(p1, q1, t1, t2)      // left
+            && check_edge(p2, q2, t1, t2)   // right
+            && check_edge(p3, q3, t1, t2)   // bottom
+            && check_edge(p4, q4, t1, t2))   // top
+        {
+            sp1_clipped = t1 > 0;
+            sp2_clipped = t2 < 1;
+
+            if (sp2_clipped)
+            {
+                set<1, 0>(s, get<0, 0>(s) + t2 * dx);
+                set<1, 1>(s, get<0, 1>(s) + t2 * dy);
+            }
+
+            if(sp1_clipped)
+            {
+                set<0, 0>(s, get<0, 0>(s) + t1 * dx);
+                set<0, 1>(s, get<0, 1>(s) + t1 * dy);
+            }
+
+            return true;
+        }
+
+        return false;
+    }
+
+    template<typename Linestring, typename OutputIterator>
+    inline void apply(Linestring& line_out, OutputIterator out) const
+    {
+        if (!boost::empty(line_out))
+        {
+            *out = line_out;
+            ++out;
+            geometry::clear(line_out);
+        }
+    }
+};
+
+
+}} // namespace strategy::intersection
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace intersection
+{
+
+/*!
+    \brief Clips a linestring with a box
+    \details A linestring is intersected (clipped) by the specified box
+    and the resulting linestring, or pieces of linestrings, are sent to the specified output operator.
+    \tparam OutputLinestring type of the output linestrings
+    \tparam OutputIterator an output iterator which outputs linestrings
+    \tparam Linestring linestring-type, for example a vector of points, matching the output-iterator type,
+         the points should also match the input-iterator type
+    \tparam Box box type
+    \tparam Strategy strategy, a clipping strategy which should implement the methods "clip_segment" and "apply"
+*/
+template
+<
+    typename OutputLinestring,
+    typename OutputIterator,
+    typename Range,
+    typename Box,
+    typename Strategy
+>
+OutputIterator clip_range_with_box(Box const& b, Range const& range,
+            OutputIterator out, Strategy const& strategy)
+{
+    if (boost::begin(range) == boost::end(range))
+    {
+        return out;
+    }
+
+    typedef typename point_type<OutputLinestring>::type point_type;
+
+    OutputLinestring line_out;
+
+    typedef typename boost::range_iterator<Range const>::type iterator_type;
+    iterator_type vertex = boost::begin(range);
+    for(iterator_type previous = vertex++;
+            vertex != boost::end(range);
+            ++previous, ++vertex)
+    {
+        point_type p1, p2;
+        geometry::convert(*previous, p1);
+        geometry::convert(*vertex, p2);
+
+        // Clip the segment. Five situations:
+        // 1. Segment is invisible, finish line if any (shouldn't occur)
+        // 2. Segment is completely visible. Add (p1)-p2 to line
+        // 3. Point 1 is invisible (clipped), point 2 is visible. Start new line from p1-p2...
+        // 4. Point 1 is visible, point 2 is invisible (clipped). End the line with ...p2
+        // 5. Point 1 and point 2 are both invisible (clipped). Start/finish an independant line p1-p2
+        //
+        // This results in:
+        // a. if p1 is clipped, start new line
+        // b. if segment is partly or completely visible, add the segment
+        // c. if p2 is clipped, end the line
+
+        bool c1 = false;
+        bool c2 = false;
+        model::referring_segment<point_type> s(p1, p2);
+
+        if (!strategy.clip_segment(b, s, c1, c2))
+        {
+            strategy.apply(line_out, out);
+        }
+        else
+        {
+            // a. If necessary, finish the line and add a start a new one
+            if (c1)
+            {
+                strategy.apply(line_out, out);
+            }
+
+            // b. Add p1 only if it is the first point, then add p2
+            if (boost::empty(line_out))
+            {
+                detail::overlay::append_no_duplicates(line_out, p1, true);
+            }
+            detail::overlay::append_no_duplicates(line_out, p2);
+
+            // c. If c2 is clipped, finish the line
+            if (c2)
+            {
+                strategy.apply(line_out, out);
+            }
+        }
+
+    }
+
+    // Add last part
+    strategy.apply(line_out, out);
+    return out;
+}
+
+}} // namespace detail::intersection
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CLIP_LINESTRING_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/convert_ring.hpp b/src/boost/geometry/algorithms/detail/overlay/convert_ring.hpp
new file mode 100644
index 0000000..05bd721
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/convert_ring.hpp
@@ -0,0 +1,99 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/range/algorithm/reverse.hpp>
+
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template<typename Tag>
+struct convert_ring
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TAG
+            , (types<Tag>)
+        );
+};
+
+template<>
+struct convert_ring<ring_tag>
+{
+    template<typename Destination, typename Source>
+    static inline void apply(Destination& destination, Source const& source,
+                bool append, bool reverse)
+    {
+        if (! append)
+        {
+            geometry::convert(source, destination);
+            if (reverse)
+            {
+                boost::reverse(destination);
+            }
+        }
+    }
+};
+
+
+template<>
+struct convert_ring<polygon_tag>
+{
+    template<typename Destination, typename Source>
+    static inline void apply(Destination& destination, Source const& source,
+                bool append, bool reverse)
+    {
+        if (! append)
+        {
+            geometry::convert(source, exterior_ring(destination));
+            if (reverse)
+            {
+                boost::reverse(exterior_ring(destination));
+            }
+        }
+        else
+        {
+            interior_rings(destination).resize(
+                        interior_rings(destination).size() + 1);
+            geometry::convert(source, interior_rings(destination).back());
+            if (reverse)
+            {
+                boost::reverse(interior_rings(destination).back());
+            }
+        }
+    }
+};
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp b/src/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
new file mode 100644
index 0000000..5e18d04
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
@@ -0,0 +1,295 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENT_POINT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENT_POINT_HPP
+
+
+#include <boost/array.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace copy_segments
+{
+
+
+template <typename Range, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point_range
+{
+    typedef typename closeable_view
+        <
+            Range const,
+            closure<Range>::value
+        >::type cview_type;
+
+    typedef typename reversible_view
+        <
+            cview_type const,
+            Reverse ? iterate_reverse : iterate_forward
+        >::type rview_type;
+
+    static inline bool apply(Range const& range,
+            SegmentIdentifier const& seg_id, bool second,
+            PointOut& point)
+    {
+        int index = seg_id.segment_index;
+        if (second)
+        {
+            index++;
+            if (index >= int(boost::size(range)))
+            {
+                index = 0;
+            }
+        }
+
+        // Exception?
+        if (index >= int(boost::size(range)))
+        {
+            return false;
+        }
+
+        cview_type cview(range);
+        rview_type view(cview);
+
+
+        geometry::convert(*(boost::begin(view) + index), point);
+        return true;
+    }
+};
+
+
+template <typename Polygon, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point_polygon
+{
+    static inline bool apply(Polygon const& polygon,
+            SegmentIdentifier const& seg_id, bool second,
+            PointOut& point)
+    {
+        // Call ring-version with the right ring
+        return copy_segment_point_range
+            <
+                typename geometry::ring_type<Polygon>::type,
+                Reverse,
+                SegmentIdentifier,
+                PointOut
+            >::apply
+                (
+                    seg_id.ring_index < 0
+                    ? geometry::exterior_ring(polygon)
+                    : geometry::interior_rings(polygon)[seg_id.ring_index],
+                    seg_id, second,
+                    point
+                );
+    }
+};
+
+
+template <typename Box, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point_box
+{
+    static inline bool apply(Box const& box,
+            SegmentIdentifier const& seg_id, bool second,
+            PointOut& point)
+    {
+        int index = seg_id.segment_index;
+        if (second)
+        {
+            index++;
+        }
+
+        boost::array<typename point_type<Box>::type, 4> bp;
+        assign_box_corners_oriented<Reverse>(box, bp);
+        point = bp[index % 4];
+        return true;
+    }
+};
+
+
+
+
+}} // namespace detail::copy_segments
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename GeometryIn,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename PointOut
+>
+struct copy_segment_point
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<GeometryIn>)
+        );
+};
+
+
+template <typename LineString, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point<linestring_tag, LineString, Reverse, SegmentIdentifier, PointOut>
+    : detail::copy_segments::copy_segment_point_range
+        <
+            LineString, Reverse, SegmentIdentifier, PointOut
+        >
+{};
+
+
+template <typename Ring, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point<ring_tag, Ring, Reverse, SegmentIdentifier, PointOut>
+    : detail::copy_segments::copy_segment_point_range
+        <
+            Ring, Reverse, SegmentIdentifier, PointOut
+        >
+{};
+
+template <typename Polygon, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point<polygon_tag, Polygon, Reverse, SegmentIdentifier, PointOut>
+    : detail::copy_segments::copy_segment_point_polygon
+        <
+            Polygon, Reverse, SegmentIdentifier, PointOut
+        >
+{};
+
+
+template <typename Box, bool Reverse, typename SegmentIdentifier, typename PointOut>
+struct copy_segment_point<box_tag, Box, Reverse, SegmentIdentifier, PointOut>
+    : detail::copy_segments::copy_segment_point_box
+        <
+            Box, Reverse, SegmentIdentifier, PointOut
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+
+
+/*!
+    \brief Helper function, copies a point from a segment
+    \ingroup overlay
+ */
+template<bool Reverse, typename Geometry, typename SegmentIdentifier, typename PointOut>
+inline bool copy_segment_point(Geometry const& geometry,
+            SegmentIdentifier const& seg_id, bool second,
+            PointOut& point_out)
+{
+    concept::check<Geometry const>();
+
+    return dispatch::copy_segment_point
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Reverse,
+            SegmentIdentifier,
+            PointOut
+        >::apply(geometry, seg_id, second, point_out);
+}
+
+
+/*!
+    \brief Helper function, to avoid the same construct several times,
+        copies a point, based on a source-index and two geometries
+    \ingroup overlay
+ */
+template
+<
+    bool Reverse1, bool Reverse2,
+    typename Geometry1, typename Geometry2,
+    typename SegmentIdentifier,
+    typename PointOut
+>
+inline bool copy_segment_point(Geometry1 const& geometry1, Geometry2 const& geometry2,
+            SegmentIdentifier const& seg_id, bool second,
+            PointOut& point_out)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    if (seg_id.source_index == 0)
+    {
+        return dispatch::copy_segment_point
+            <
+                typename tag<Geometry1>::type,
+                Geometry1,
+                Reverse1,
+                SegmentIdentifier,
+                PointOut
+            >::apply(geometry1, seg_id, second, point_out);
+    }
+    else if (seg_id.source_index == 1)
+    {
+        return dispatch::copy_segment_point
+            <
+                typename tag<Geometry2>::type,
+                Geometry2,
+                Reverse2,
+                SegmentIdentifier,
+                PointOut
+            >::apply(geometry2, seg_id, second, point_out);
+    }
+    // Exception?
+    return false;
+}
+
+
+/*!
+    \brief Helper function, to avoid the same construct several times,
+        copies a point, based on a source-index and two geometries
+    \ingroup overlay
+ */
+template
+<
+    bool Reverse1, bool Reverse2,
+    typename Geometry1, typename Geometry2,
+    typename SegmentIdentifier,
+    typename PointOut
+>
+inline bool copy_segment_points(Geometry1 const& geometry1, Geometry2 const& geometry2,
+            SegmentIdentifier const& seg_id,
+            PointOut& point1, PointOut& point2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    return copy_segment_point<Reverse1, Reverse2>(geometry1, geometry2, seg_id, false, point1)
+        && copy_segment_point<Reverse1, Reverse2>(geometry1, geometry2, seg_id, true,  point2);
+}
+
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENT_POINT_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/copy_segments.hpp b/src/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
new file mode 100644
index 0000000..805f392
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
@@ -0,0 +1,328 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
+
+
+#include <boost/array.hpp>
+#include <boost/mpl/assert.hpp>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/iterators/ever_circling_iterator.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace copy_segments
+{
+
+
+template
+<
+    typename Ring,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments_ring
+{
+    typedef typename closeable_view
+        <
+            Ring const,
+            closure<Ring>::value
+        >::type cview_type;
+
+    typedef typename reversible_view
+        <
+            cview_type const,
+            Reverse ? iterate_reverse : iterate_forward
+        >::type rview_type;
+
+    typedef typename boost::range_iterator<rview_type const>::type iterator;
+    typedef geometry::ever_circling_iterator<iterator> ec_iterator;
+
+    static inline void apply(Ring const& ring,
+            SegmentIdentifier const& seg_id, int to_index,
+            RangeOut& current_output)
+    {
+        cview_type cview(ring);
+        rview_type view(cview);
+
+        // The problem: sometimes we want to from "3" to "2"
+        // -> end = "3" -> end == begin
+        // This is not convenient with iterators.
+
+        // So we use the ever-circling iterator and determine when to step out
+
+        int const from_index = seg_id.segment_index + 1;
+
+        // Sanity check
+        BOOST_ASSERT(from_index < int(boost::size(view)));
+
+        ec_iterator it(boost::begin(view), boost::end(view),
+                    boost::begin(view) + from_index);
+
+        // [2..4] -> 4 - 2 + 1 = 3 -> {2,3,4} -> OK
+        // [4..2],size=6 -> 6 - 4 + 2 + 1 = 5 -> {4,5,0,1,2} -> OK
+        // [1..1], travel the whole ring round
+        typedef typename boost::range_difference<Ring>::type size_type;
+        size_type const count = from_index <= to_index
+            ? to_index - from_index + 1
+            : int(boost::size(view)) - from_index + to_index + 1;
+
+        for (size_type i = 0; i < count; ++i, ++it)
+        {
+            detail::overlay::append_no_duplicates(current_output, *it);
+        }
+    }
+};
+
+template
+<
+    typename LineString,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments_linestring
+{
+
+    typedef typename boost::range_iterator<LineString const>::type iterator;
+
+    static inline void apply(LineString const& ls,
+            SegmentIdentifier const& seg_id, int to_index,
+            RangeOut& current_output)
+    {
+        int const from_index = seg_id.segment_index + 1;
+
+        // Sanity check
+        if (from_index > to_index || from_index < 0 || to_index >= int(boost::size(ls)))
+        {
+            return;
+        }
+
+        typedef typename boost::range_difference<LineString>::type size_type;
+        size_type const count = to_index - from_index + 1;
+
+        typename boost::range_iterator<LineString const>::type it = boost::begin(ls) + from_index;
+
+        for (size_type i = 0; i < count; ++i, ++it)
+        {
+            detail::overlay::append_no_duplicates(current_output, *it);
+        }
+    }
+};
+
+template
+<
+    typename Polygon,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments_polygon
+{
+    static inline void apply(Polygon const& polygon,
+            SegmentIdentifier const& seg_id, int to_index,
+            RangeOut& current_output)
+    {
+        // Call ring-version with the right ring
+        copy_segments_ring
+            <
+                typename geometry::ring_type<Polygon>::type,
+                Reverse,
+                SegmentIdentifier,
+                RangeOut
+            >::apply
+                (
+                    seg_id.ring_index < 0
+                    ? geometry::exterior_ring(polygon)
+                    : geometry::interior_rings(polygon)[seg_id.ring_index],
+                    seg_id, to_index,
+                    current_output
+                );
+    }
+};
+
+
+template
+<
+    typename Box,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments_box
+{
+    static inline void apply(Box const& box,
+            SegmentIdentifier const& seg_id, int to_index,
+            RangeOut& current_output)
+    {
+        int index = seg_id.segment_index + 1;
+        BOOST_ASSERT(index < 5);
+
+        int const count = index <= to_index
+            ? to_index - index + 1
+            : 5 - index + to_index + 1;
+
+        // Create array of points, the fifth one closes it
+        boost::array<typename point_type<Box>::type, 5> bp;
+        assign_box_corners_oriented<Reverse>(box, bp);
+        bp[4] = bp[0];
+
+        // (possibly cyclic) copy to output
+        //    (see comments in ring-version)
+        for (int i = 0; i < count; i++, index++)
+        {
+            detail::overlay::append_no_duplicates(current_output, bp[index % 5]);
+
+        }
+    }
+};
+
+
+}} // namespace detail::copy_segments
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag,
+    typename GeometryIn,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<GeometryIn>)
+        );
+};
+
+
+template
+<
+    typename Ring,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments<ring_tag, Ring, Reverse, SegmentIdentifier, RangeOut>
+    : detail::copy_segments::copy_segments_ring
+        <
+            Ring, Reverse, SegmentIdentifier, RangeOut
+        >
+{};
+
+
+
+template
+<
+    typename LineString,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments<linestring_tag, LineString, Reverse, SegmentIdentifier, RangeOut>
+    : detail::copy_segments::copy_segments_linestring
+        <
+            LineString, Reverse, SegmentIdentifier, RangeOut
+        >
+{};
+
+template
+<
+    typename Polygon,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments<polygon_tag, Polygon, Reverse, SegmentIdentifier, RangeOut>
+    : detail::copy_segments::copy_segments_polygon
+        <
+            Polygon, Reverse, SegmentIdentifier, RangeOut
+        >
+{};
+
+
+template
+<
+    typename Box,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments<box_tag, Box, Reverse, SegmentIdentifier, RangeOut>
+    : detail::copy_segments::copy_segments_box
+        <
+            Box, Reverse, SegmentIdentifier, RangeOut
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+    \brief Copy segments from a geometry, starting with the specified segment (seg_id)
+        until the specified index (to_index)
+    \ingroup overlay
+ */
+template
+<
+    bool Reverse,
+    typename Geometry,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+inline void copy_segments(Geometry const& geometry,
+            SegmentIdentifier const& seg_id, int to_index,
+            RangeOut& range_out)
+{
+    concept::check<Geometry const>();
+
+    dispatch::copy_segments
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Reverse,
+            SegmentIdentifier,
+            RangeOut
+        >::apply(geometry, seg_id, to_index, range_out);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp b/src/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp
new file mode 100644
index 0000000..0cc3425
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp
@@ -0,0 +1,66 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_DEBUG_TURN_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_DEBUG_TURN_INFO_HPP
+
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/visit_info.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+inline char method_char(detail::overlay::method_type const& method)
+{
+    using namespace detail::overlay;
+    switch(method)
+    {
+        case method_none : return '-';
+        case method_disjoint : return 'd';
+        case method_crosses : return 'i';
+        case method_touch : return 't';
+        case method_touch_interior : return 'm';
+        case method_collinear : return 'c';
+        case method_equal : return 'e';
+        case method_error : return '!';
+        default : return '?';
+    }
+}
+
+inline char operation_char(detail::overlay::operation_type const& operation)
+{
+    using namespace detail::overlay;
+    switch(operation)
+    {
+        case operation_none : return '-';
+        case operation_union : return 'u';
+        case operation_intersection : return 'i';
+        case operation_blocked : return 'x';
+        case operation_continue : return 'c';
+        case operation_opposite : return 'o';
+        default : return '?';
+    }
+}
+
+inline char visited_char(detail::overlay::visit_info const& v)
+{
+    if (v.rejected()) return 'R';
+    if (v.started()) return 's';
+    if (v.visited()) return 'v';
+    if (v.none()) return '-';
+    if (v.finished()) return 'f';
+    return '?';
+}
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_DEBUG_TURN_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/src/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp
new file mode 100644
index 0000000..e4842d3
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp
@@ -0,0 +1,523 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICH_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICH_HPP
+
+#include <cstddef>
+#include <algorithm>
+#include <map>
+#include <set>
+#include <vector>
+
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+#  include <iostream>
+#  include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+#  include <boost/geometry/io/wkt/wkt.hpp>
+#  define BOOST_GEOMETRY_DEBUG_IDENTIFIER
+#endif
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+#include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_relative_order.hpp>
+#include <boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp>
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+#  include <boost/geometry/algorithms/detail/overlay/check_enrich.hpp>
+#endif
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+// Wraps "turn_operation" from turn_info.hpp,
+// giving it extra information
+template <typename TurnOperation>
+struct indexed_turn_operation
+{
+    typedef TurnOperation type;
+
+    int index;
+    int operation_index;
+    bool discarded;
+    TurnOperation subject;
+
+    inline indexed_turn_operation(int i, int oi, TurnOperation const& s)
+        : index(i)
+        , operation_index(oi)
+        , discarded(false)
+        , subject(s)
+    {}
+};
+
+template <typename IndexedTurnOperation>
+struct remove_discarded
+{
+    inline bool operator()(IndexedTurnOperation const& operation) const
+    {
+        return operation.discarded;
+    }
+};
+
+
+template
+<
+    typename TurnPoints,
+    typename Indexed,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Strategy
+>
+struct sort_on_segment_and_distance
+{
+    inline sort_on_segment_and_distance(TurnPoints const& turn_points
+            , Geometry1 const& geometry1
+            , Geometry2 const& geometry2
+            , Strategy const& strategy
+            , bool* clustered)
+        : m_turn_points(turn_points)
+        , m_geometry1(geometry1)
+        , m_geometry2(geometry2)
+        , m_strategy(strategy)
+        , m_clustered(clustered)
+    {
+    }
+
+private :
+
+    TurnPoints const& m_turn_points;
+    Geometry1 const& m_geometry1;
+    Geometry2 const& m_geometry2;
+    Strategy const& m_strategy;
+    mutable bool* m_clustered;
+
+    inline bool consider_relative_order(Indexed const& left,
+                    Indexed const& right) const
+    {
+        typedef typename geometry::point_type<Geometry1>::type point_type;
+        point_type pi, pj, ri, rj, si, sj;
+
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.seg_id,
+            pi, pj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.other_id,
+            ri, rj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            right.subject.other_id,
+            si, sj);
+
+        int const order = get_relative_order
+            <
+                point_type
+            >::apply(pi, pj,ri, rj, si, sj);
+        //debug("r/o", order == -1);
+        return order == -1;
+    }
+
+public :
+
+    // Note that left/right do NOT correspond to m_geometry1/m_geometry2
+    // but to the "indexed_turn_operation"
+    inline bool operator()(Indexed const& left, Indexed const& right) const
+    {
+        segment_identifier const& sl = left.subject.seg_id;
+        segment_identifier const& sr = right.subject.seg_id;
+
+        if (sl == sr
+            && geometry::math::equals(left.subject.enriched.distance
+                    , right.subject.enriched.distance))
+        {
+            // Both left and right are located on the SAME segment.
+
+            // First check "real" intersection (crosses)
+            // -> distance zero due to precision, solve it by sorting
+            if (m_turn_points[left.index].method == method_crosses
+                && m_turn_points[right.index].method == method_crosses)
+            {
+                return consider_relative_order(left, right);
+            }
+
+            // If that is not the case, cluster it later on.
+            // Indicate that this is necessary.
+            *m_clustered = true;
+
+            return left.index < right.index;
+        }
+        return sl == sr
+            ? left.subject.enriched.distance < right.subject.enriched.distance
+            : sl < sr;
+
+    }
+};
+
+
+template<typename Turns, typename Operations>
+inline void update_discarded(Turns& turn_points, Operations& operations)
+{
+    // Vice-versa, set discarded to true for discarded operations;
+    // AND set discarded points to true
+    for (typename boost::range_iterator<Operations>::type it = boost::begin(operations);
+         it != boost::end(operations);
+         ++it)
+    {
+        if (turn_points[it->index].discarded)
+        {
+            it->discarded = true;
+        }
+        else if (it->discarded)
+        {
+            turn_points[it->index].discarded = true;
+        }
+    }
+}
+
+
+// Sorts IP-s of this ring on segment-identifier, and if on same segment,
+//  on distance.
+// Then assigns for each IP which is the next IP on this segment,
+// plus the vertex-index to travel to, plus the next IP
+// (might be on another segment)
+template
+<
+    typename IndexType,
+    bool Reverse1, bool Reverse2,
+    typename Container,
+    typename TurnPoints,
+    typename Geometry1, typename Geometry2,
+    typename Strategy
+>
+inline void enrich_sort(Container& operations,
+            TurnPoints& turn_points,
+            operation_type for_operation,
+            Geometry1 const& geometry1, Geometry2 const& geometry2,
+            Strategy const& strategy)
+{
+    typedef typename IndexType::type operations_type;
+
+    bool clustered = false;
+    std::sort(boost::begin(operations),
+                boost::end(operations),
+                sort_on_segment_and_distance
+                    <
+                        TurnPoints,
+                        IndexType,
+                        Geometry1, Geometry2,
+                        Reverse1, Reverse2,
+                        Strategy
+                    >(turn_points, geometry1, geometry2, strategy, &clustered));
+
+    // DONT'T discard xx / (for union) ix / ii / (for intersection) ux / uu here
+    // It would give way to "lonely" ui turn points, traveling all
+    // the way round. See #105
+
+    if (clustered)
+    {
+        typedef typename boost::range_iterator<Container>::type nc_iterator;
+        nc_iterator it = boost::begin(operations);
+        nc_iterator begin_cluster = boost::end(operations);
+        for (nc_iterator prev = it++;
+            it != boost::end(operations);
+            prev = it++)
+        {
+            operations_type& prev_op = turn_points[prev->index]
+                .operations[prev->operation_index];
+            operations_type& op = turn_points[it->index]
+                .operations[it->operation_index];
+
+            if (prev_op.seg_id == op.seg_id
+                && (turn_points[prev->index].method != method_crosses
+                    || turn_points[it->index].method != method_crosses)
+                && geometry::math::equals(prev_op.enriched.distance,
+                        op.enriched.distance))
+            {
+                if (begin_cluster == boost::end(operations))
+                {
+                    begin_cluster = prev;
+                }
+            }
+            else if (begin_cluster != boost::end(operations))
+            {
+                handle_cluster<IndexType, Reverse1, Reverse2>(begin_cluster, it, turn_points,
+                        for_operation, geometry1, geometry2, strategy);
+                begin_cluster = boost::end(operations);
+            }
+        }
+        if (begin_cluster != boost::end(operations))
+        {
+            handle_cluster<IndexType, Reverse1, Reverse2>(begin_cluster, it, turn_points,
+                    for_operation, geometry1, geometry2, strategy);
+        }
+    }
+
+    update_discarded(turn_points, operations);
+}
+
+
+template
+<
+    typename IndexType,
+    typename Container,
+    typename TurnPoints
+>
+inline void enrich_discard(Container& operations, TurnPoints& turn_points)
+{
+    update_discarded(turn_points, operations);
+
+    // Then delete discarded operations from vector
+    remove_discarded<IndexType> predicate;
+    operations.erase(
+            std::remove_if(boost::begin(operations),
+                    boost::end(operations),
+                    predicate),
+            boost::end(operations));
+}
+
+template
+<
+    typename IndexType,
+    typename Container,
+    typename TurnPoints,
+    typename Geometry1,
+    typename Geometry2,
+    typename Strategy
+>
+inline void enrich_assign(Container& operations,
+            TurnPoints& turn_points,
+            operation_type ,
+            Geometry1 const& , Geometry2 const& ,
+            Strategy const& )
+{
+    typedef typename IndexType::type operations_type;
+    typedef typename boost::range_iterator<Container const>::type iterator_type;
+
+
+    if (operations.size() > 0)
+    {
+        // Assign travel-to-vertex/ip index for each turning point.
+        // Because IP's are circular, PREV starts at the very last one,
+        // being assigned from the first one.
+        // "next ip on same segment" should not be considered circular.
+        bool first = true;
+        iterator_type it = boost::begin(operations);
+        for (iterator_type prev = it + (boost::size(operations) - 1);
+             it != boost::end(operations);
+             prev = it++)
+        {
+            operations_type& prev_op
+                    = turn_points[prev->index].operations[prev->operation_index];
+            operations_type& op
+                    = turn_points[it->index].operations[it->operation_index];
+
+            prev_op.enriched.travels_to_ip_index
+                    = it->index;
+            prev_op.enriched.travels_to_vertex_index
+                    = it->subject.seg_id.segment_index;
+
+            if (! first
+                && prev_op.seg_id.segment_index == op.seg_id.segment_index)
+            {
+                prev_op.enriched.next_ip_index = it->index;
+            }
+            first = false;
+        }
+    }
+
+    // DEBUG
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    {
+        for (iterator_type it = boost::begin(operations);
+             it != boost::end(operations);
+             ++it)
+        {
+            operations_type& op = turn_points[it->index]
+                .operations[it->operation_index];
+
+            std::cout << it->index
+                << " meth: " << method_char(turn_points[it->index].method)
+                << " seg: " << op.seg_id
+                << " dst: " << boost::numeric_cast<double>(op.enriched.distance)
+                << " op: " << operation_char(turn_points[it->index].operations[0].operation)
+                << operation_char(turn_points[it->index].operations[1].operation)
+                << " dsc: " << (turn_points[it->index].discarded ? "T" : "F")
+                << " ->vtx " << op.enriched.travels_to_vertex_index
+                << " ->ip " << op.enriched.travels_to_ip_index
+                << " ->nxt ip " << op.enriched.next_ip_index
+                //<< " vis: " << visited_char(op.visited)
+                << std::endl;
+                ;
+        }
+    }
+#endif
+    // END DEBUG
+
+}
+
+
+template <typename IndexedType, typename TurnPoints, typename MappedVector>
+inline void create_map(TurnPoints const& turn_points, MappedVector& mapped_vector)
+{
+    typedef typename boost::range_value<TurnPoints>::type turn_point_type;
+    typedef typename turn_point_type::container_type container_type;
+
+    int index = 0;
+    for (typename boost::range_iterator<TurnPoints const>::type
+            it = boost::begin(turn_points);
+         it != boost::end(turn_points);
+         ++it, ++index)
+    {
+        // Add operations on this ring, but skip discarded ones
+        if (! it->discarded)
+        {
+            int op_index = 0;
+            for (typename boost::range_iterator<container_type const>::type
+                    op_it = boost::begin(it->operations);
+                op_it != boost::end(it->operations);
+                ++op_it, ++op_index)
+            {
+                // We should NOT skip blocked operations here
+                // because they can be relevant for "the other side"
+                // NOT if (op_it->operation != operation_blocked)
+
+                ring_identifier ring_id
+                    (
+                        op_it->seg_id.source_index,
+                        op_it->seg_id.multi_index,
+                        op_it->seg_id.ring_index
+                    );
+                mapped_vector[ring_id].push_back
+                    (
+                        IndexedType(index, op_index, *op_it)
+                    );
+            }
+        }
+    }
+}
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+
+/*!
+\brief All intersection points are enriched with successor information
+\ingroup overlay
+\tparam TurnPoints type of intersection container
+            (e.g. vector of "intersection/turn point"'s)
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Strategy side strategy type
+\param turn_points container containing intersectionpoints
+\param for_operation operation_type (union or intersection)
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param strategy strategy
+ */
+template
+<
+    bool Reverse1, bool Reverse2,
+    typename TurnPoints,
+    typename Geometry1, typename Geometry2,
+    typename Strategy
+>
+inline void enrich_intersection_points(TurnPoints& turn_points,
+    detail::overlay::operation_type for_operation,
+    Geometry1 const& geometry1, Geometry2 const& geometry2,
+    Strategy const& strategy)
+{
+    typedef typename boost::range_value<TurnPoints>::type turn_point_type;
+    typedef typename turn_point_type::turn_operation_type turn_operation_type;
+    typedef detail::overlay::indexed_turn_operation
+        <
+            turn_operation_type
+        > indexed_turn_operation;
+
+    typedef std::map
+        <
+            ring_identifier,
+            std::vector<indexed_turn_operation>
+        > mapped_vector_type;
+
+    // DISCARD ALL UU
+    // #76 is the reason that this is necessary...
+    // With uu, at all points there is the risk that rings are being traversed twice or more.
+    // Without uu, all rings having only uu will be untouched and gathered by assemble
+    for (typename boost::range_iterator<TurnPoints>::type
+            it = boost::begin(turn_points);
+         it != boost::end(turn_points);
+         ++it)
+    {
+        if (it->both(detail::overlay::operation_union))
+        {
+            it->discarded = true;
+        }
+    }
+
+
+    // Create a map of vectors of indexed operation-types to be able
+    // to sort intersection points PER RING
+    mapped_vector_type mapped_vector;
+
+    detail::overlay::create_map<indexed_turn_operation>(turn_points, mapped_vector);
+
+
+    // No const-iterator; contents of mapped copy is temporary,
+    // and changed by enrich
+    for (typename mapped_vector_type::iterator mit
+        = mapped_vector.begin();
+        mit != mapped_vector.end();
+        ++mit)
+    {
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    std::cout << "ENRICH-sort Ring "
+        << mit->first << std::endl;
+#endif
+        detail::overlay::enrich_sort<indexed_turn_operation, Reverse1, Reverse2>(mit->second, turn_points, for_operation,
+                    geometry1, geometry2, strategy);
+    }
+
+    for (typename mapped_vector_type::iterator mit
+        = mapped_vector.begin();
+        mit != mapped_vector.end();
+        ++mit)
+    {
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    std::cout << "ENRICH-discard Ring "
+        << mit->first << std::endl;
+#endif
+        detail::overlay::enrich_discard<indexed_turn_operation>(mit->second, turn_points);
+    }
+
+    for (typename mapped_vector_type::iterator mit
+        = mapped_vector.begin();
+        mit != mapped_vector.end();
+        ++mit)
+    {
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    std::cout << "ENRICH-assign Ring "
+        << mit->first << std::endl;
+#endif
+        detail::overlay::enrich_assign<indexed_turn_operation>(mit->second, turn_points, for_operation,
+                    geometry1, geometry2, strategy);
+    }
+
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    //detail::overlay::check_graph(turn_points, for_operation);
+#endif
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICH_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp b/src/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp
new file mode 100644
index 0000000..8c8ed96
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp
@@ -0,0 +1,76 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICHMENT_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICHMENT_INFO_HPP
+
+
+#include <boost/geometry/strategies/distance.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+/*!
+\brief Keeps info to enrich intersection info (per source)
+\details Class to keep information necessary for traversal phase (a phase
+    of the overlay process). The information is gathered during the
+    enrichment phase
+ */
+template<typename P>
+struct enrichment_info
+{
+    typedef typename strategy::distance::services::return_type
+        <
+            typename strategy::distance::services::comparable_type
+                <
+                    typename strategy::distance::services::default_strategy
+                        <
+                            point_tag,
+                            P
+                        >::type
+                >::type
+        >::type distance_type;
+
+    inline enrichment_info()
+        : travels_to_vertex_index(-1)
+        , travels_to_ip_index(-1)
+        , next_ip_index(-1)
+        , distance(distance_type())
+    {}
+
+    // vertex to which is free travel after this IP,
+    // so from "segment_index+1" to "travels_to_vertex_index", without IP-s,
+    // can be -1
+    int travels_to_vertex_index;
+
+    // same but now IP index, so "next IP index" but not on THIS segment
+    int travels_to_ip_index;
+
+    // index of next IP on this segment, -1 if there is no one
+    int next_ip_index;
+
+    distance_type distance; // distance-measurement from segment.first to IP
+};
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICHMENT_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/follow.hpp b/src/boost/geometry/algorithms/detail/overlay/follow.hpp
new file mode 100644
index 0000000..b110cc9
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/follow.hpp
@@ -0,0 +1,416 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_FOLLOW_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_FOLLOW_HPP
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
+#include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+
+#include <boost/geometry/algorithms/covered_by.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+namespace following
+{
+    
+template <typename Turn, typename Operation>
+static inline bool is_entering(Turn const& /* TODO remove this parameter */, Operation const& op)
+{
+    // (Blocked means: blocked for polygon/polygon intersection, because
+    // they are reversed. But for polygon/line it is similar to continue)
+    return op.operation == operation_intersection
+        || op.operation == operation_continue
+        || op.operation == operation_blocked
+        ;
+}
+
+template 
+<
+    typename Turn, 
+    typename Operation, 
+    typename LineString, 
+    typename Polygon
+>
+static inline bool last_covered_by(Turn const& turn, Operation const& op, 
+                LineString const& linestring, Polygon const& polygon)
+{
+    // Check any point between the this one and the first IP 
+    typedef typename geometry::point_type<LineString>::type point_type;
+    point_type point_in_between;
+    detail::point_on_border::midpoint_helper
+        <
+            point_type,
+            0, dimension<point_type>::value
+        >::apply(point_in_between, linestring[op.seg_id.segment_index], turn.point);
+
+    return geometry::covered_by(point_in_between, polygon);
+}
+
+
+template 
+<
+    typename Turn, 
+    typename Operation, 
+    typename LineString, 
+    typename Polygon
+>
+static inline bool is_leaving(Turn const& turn, Operation const& op, 
+                bool entered, bool first, 
+                LineString const& linestring, Polygon const& polygon)
+{
+    if (op.operation == operation_union)
+    {
+        return entered 
+            || turn.method == method_crosses
+            || (first && last_covered_by(turn, op, linestring, polygon))
+            ;
+    }
+    return false;
+}
+
+
+template 
+<
+    typename Turn, 
+    typename Operation, 
+    typename LineString, 
+    typename Polygon
+>
+static inline bool is_staying_inside(Turn const& turn, Operation const& op, 
+                bool entered, bool first, 
+                LineString const& linestring, Polygon const& polygon)
+{
+    if (turn.method == method_crosses)
+    {
+        // The normal case, this is completely covered with entering/leaving 
+        // so stay out of this time consuming "covered_by"
+        return false;
+    }
+
+    if (is_entering(turn, op))
+    {
+        return entered || (first && last_covered_by(turn, op, linestring, polygon));
+    }
+
+    return false;
+}
+
+template 
+<
+    typename Turn, 
+    typename Operation, 
+    typename Linestring, 
+    typename Polygon
+>
+static inline bool was_entered(Turn const& turn, Operation const& op, bool first,
+                Linestring const& linestring, Polygon const& polygon)
+{
+    if (first && (turn.method == method_collinear || turn.method == method_equal))
+    {
+        return last_covered_by(turn, op, linestring, polygon);
+    }
+    return false;
+}
+
+
+// Template specialization structure to call the right actions for the right type
+template<overlay_type OverlayType>
+struct action_selector
+{
+    // If you get here the overlay type is not intersection or difference
+    // BOOST_MPL_ASSERT(false);
+};
+
+// Specialization for intersection, containing the implementation
+template<>
+struct action_selector<overlay_intersection>
+{
+    template
+    <
+        typename OutputIterator, 
+        typename LineStringOut, 
+        typename LineString, 
+        typename Point, 
+        typename Operation
+    >
+    static inline void enter(LineStringOut& current_piece,
+                LineString const& , 
+                segment_identifier& segment_id,
+                int , Point const& point,
+                Operation const& operation, OutputIterator& )
+    {
+        // On enter, append the intersection point and remember starting point
+        detail::overlay::append_no_duplicates(current_piece, point);
+        segment_id = operation.seg_id;
+    }
+
+    template
+    <
+        typename OutputIterator, 
+        typename LineStringOut, 
+        typename LineString, 
+        typename Point, 
+        typename Operation
+    >
+    static inline void leave(LineStringOut& current_piece,
+                LineString const& linestring,
+                segment_identifier& segment_id,
+                int index, Point const& point,
+                Operation const& , OutputIterator& out)
+    {
+        // On leave, copy all segments from starting point, append the intersection point
+        // and add the output piece
+        geometry::copy_segments<false>(linestring, segment_id, index, current_piece);
+        detail::overlay::append_no_duplicates(current_piece, point);
+        if (current_piece.size() > 1)
+        {
+            *out++ = current_piece;
+        }
+        current_piece.clear();
+    }
+
+    static inline bool is_entered(bool entered)
+    {
+        return entered;
+    }
+
+    template <typename Point, typename Geometry>
+    static inline bool included(Point const& point, Geometry const& geometry)
+    {
+        return geometry::covered_by(point, geometry);
+    }
+
+};
+
+// Specialization for difference, which reverses these actions
+template<>
+struct action_selector<overlay_difference>
+{
+    typedef action_selector<overlay_intersection> normal_action;
+
+    template
+    <
+        typename OutputIterator, 
+        typename LineStringOut, 
+        typename LineString, 
+        typename Point, 
+        typename Operation
+    >
+    static inline void enter(LineStringOut& current_piece, 
+                LineString const& linestring, 
+                segment_identifier& segment_id, 
+                int index, Point const& point, 
+                Operation const& operation, OutputIterator& out)
+    {
+        normal_action::leave(current_piece, linestring, segment_id, index, 
+                    point, operation, out);
+    }
+
+    template
+    <
+        typename OutputIterator, 
+        typename LineStringOut, 
+        typename LineString, 
+        typename Point, 
+        typename Operation
+    >
+    static inline void leave(LineStringOut& current_piece,
+                LineString const& linestring,
+                segment_identifier& segment_id,
+                int index, Point const& point,
+                Operation const& operation, OutputIterator& out)
+    {
+        normal_action::enter(current_piece, linestring, segment_id, index,
+                    point, operation, out);
+    }
+
+    static inline bool is_entered(bool entered)
+    {
+        return ! normal_action::is_entered(entered);
+    }
+
+    template <typename Point, typename Geometry>
+    static inline bool included(Point const& point, Geometry const& geometry)
+    {
+        return ! normal_action::included(point, geometry);
+    }
+
+};
+
+}
+
+/*!
+\brief Follows a linestring from intersection point to intersection point, outputting which
+    is inside, or outside, a ring or polygon
+\ingroup overlay
+ */
+template
+<
+    typename LineStringOut,
+    typename LineString,
+    typename Polygon,
+    overlay_type OverlayType
+>
+class follow
+{
+
+    template<typename Turn>
+    struct sort_on_segment
+    {
+        // In case of turn point at the same location, we want to have continue/blocked LAST
+        // because that should be followed (intersection) or skipped (difference).
+        inline int operation_order(Turn const& turn) const
+        {
+            operation_type const& operation = turn.operations[0].operation;
+            switch(operation)
+            {
+                case operation_opposite : return 0;
+                case operation_none : return 0;
+                case operation_union : return 1;
+                case operation_intersection : return 2;
+                case operation_blocked : return 3;
+                case operation_continue : return 4;
+            }
+            return -1;
+        };
+
+        inline bool use_operation(Turn const& left, Turn const& right) const
+        {
+            // If they are the same, OK. 
+            return operation_order(left) < operation_order(right);
+        }
+
+        inline bool use_distance(Turn const& left, Turn const& right) const
+        {
+            return geometry::math::equals(left.operations[0].enriched.distance, right.operations[0].enriched.distance)
+                ? use_operation(left, right)
+                : left.operations[0].enriched.distance < right.operations[0].enriched.distance
+                ;
+        }
+
+        inline bool operator()(Turn const& left, Turn const& right) const
+        {
+            segment_identifier const& sl = left.operations[0].seg_id;
+            segment_identifier const& sr = right.operations[0].seg_id;
+
+            return sl == sr
+                ? use_distance(left, right)
+                : sl < sr
+                ;
+
+        }
+    };
+
+
+
+public :
+
+    template <typename Point, typename Geometry>
+    static inline bool included(Point const& point, Geometry const& geometry)
+    {
+        return following::action_selector<OverlayType>::included(point, geometry);
+    }
+
+    template<typename Turns, typename OutputIterator>
+    static inline OutputIterator apply(LineString const& linestring, Polygon const& polygon,
+                detail::overlay::operation_type ,  // TODO: this parameter might be redundant
+                Turns& turns, OutputIterator out)
+    {
+        typedef typename boost::range_iterator<Turns>::type turn_iterator;
+        typedef typename boost::range_value<Turns>::type turn_type;
+        typedef typename boost::range_iterator
+            <
+                typename turn_type::container_type
+            >::type turn_operation_iterator_type;
+
+        typedef following::action_selector<OverlayType> action;
+
+        // Sort intersection points on segments-along-linestring, and distance
+        // (like in enrich is done for poly/poly)
+        std::sort(boost::begin(turns), boost::end(turns), sort_on_segment<turn_type>());
+
+        LineStringOut current_piece;
+        geometry::segment_identifier current_segment_id(0, -1, -1, -1);
+
+        // Iterate through all intersection points (they are ordered along the line)
+        bool entered = false;
+        bool first = true;
+        for (turn_iterator it = boost::begin(turns); it != boost::end(turns); ++it)
+        {
+            turn_operation_iterator_type iit = boost::begin(it->operations);
+
+            if (following::was_entered(*it, *iit, first, linestring, polygon))
+            {
+                debug_traverse(*it, *iit, "-> Was entered");
+                entered = true;
+            }
+
+            if (following::is_staying_inside(*it, *iit, entered, first, linestring, polygon))
+            {
+                debug_traverse(*it, *iit, "-> Staying inside");
+
+                entered = true;
+            }
+            else if (following::is_entering(*it, *iit))
+            {
+                debug_traverse(*it, *iit, "-> Entering");
+
+                entered = true;
+                action::enter(current_piece, linestring, current_segment_id, iit->seg_id.segment_index, it->point, *iit, out);
+            }
+            else if (following::is_leaving(*it, *iit, entered, first, linestring, polygon))
+            {
+                debug_traverse(*it, *iit, "-> Leaving");
+
+                entered = false;
+                action::leave(current_piece, linestring, current_segment_id, iit->seg_id.segment_index, it->point, *iit, out);
+            }
+            first = false;
+        }
+
+        if (action::is_entered(entered))
+        {
+            geometry::copy_segments<false>(linestring, current_segment_id,
+                    boost::size(linestring) - 1,
+                    current_piece);
+        }
+
+        // Output the last one, if applicable
+        if (current_piece.size() > 1)
+        {
+            *out++ = current_piece;
+        }
+        return out;
+    }
+
+};
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_FOLLOW_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp b/src/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp
new file mode 100644
index 0000000..019c3ba
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp
@@ -0,0 +1,146 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace get_intersection_points
+{
+
+
+template
+<
+    typename Point1,
+    typename Point2,
+    typename TurnInfo
+>
+struct get_turn_without_info
+{
+    typedef strategy_intersection
+        <
+            typename cs_tag<typename TurnInfo::point_type>::type,
+            Point1,
+            Point2,
+            typename TurnInfo::point_type
+        > si;
+
+    typedef typename si::segment_intersection_strategy_type strategy;
+
+
+
+    template <typename OutputIterator>
+    static inline OutputIterator apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& pk,
+                Point2 const& qi, Point2 const& qj, Point2 const& qk,
+                TurnInfo const& ,
+                OutputIterator out)
+    {
+        typedef model::referring_segment<Point1 const> segment_type1;
+        typedef model::referring_segment<Point1 const> segment_type2;
+        segment_type1 p1(pi, pj), p2(pj, pk);
+        segment_type2 q1(qi, qj), q2(qj, qk);
+
+        //
+        typename strategy::return_type result = strategy::apply(p1, q1);
+
+        for (std::size_t i = 0; i < result.template get<0>().count; i++)
+        {
+
+            TurnInfo tp;
+            geometry::convert(result.template get<0>().intersections[i], tp.point);
+            *out++ = tp;
+        }
+
+        return out;
+    }
+};
+
+}} // namespace detail::get_intersection_points
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Turns
+>
+inline void get_intersection_points(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            Turns& turns)
+{
+    concept::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>();
+
+    typedef detail::get_intersection_points::get_turn_without_info
+                        <
+                            typename point_type<Geometry1>::type,
+                            typename point_type<Geometry2>::type,
+                            typename boost::range_value<Turns>::type
+                        > TurnPolicy;
+
+    typedef typename strategy_intersection
+        <
+            typename cs_tag<Geometry1>::type,
+            Geometry1,
+            Geometry2,
+            typename boost::range_value<Turns>::type
+        >::segment_intersection_strategy_type segment_intersection_strategy_type;
+
+    detail::get_turns::no_interrupt_policy interrupt_policy;
+
+    boost::mpl::if_c
+        <
+            reverse_dispatch<Geometry1, Geometry2>::type::value,
+            dispatch::get_turns_reversed
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1, Geometry2,
+                false, false,
+                Turns, TurnPolicy,
+                //segment_intersection_strategy_type,
+                detail::get_turns::no_interrupt_policy
+            >,
+            dispatch::get_turns
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1, Geometry2,
+                false, false,
+                Turns, TurnPolicy,
+                //segment_intersection_strategy_type,
+                detail::get_turns::no_interrupt_policy
+            >
+        >::type::apply(
+            0, geometry1,
+            1, geometry2,
+            turns, interrupt_policy);
+}
+
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_INTERSECTION_POINTS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp b/src/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp
new file mode 100644
index 0000000..522ef68
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/get_relative_order.hpp
@@ -0,0 +1,108 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP
+
+
+#include <boost/geometry/algorithms/distance.hpp>
+
+#include <boost/geometry/strategies/intersection.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+/*!
+    \brief Get relative order
+    \details Can indicate which of two segments R and S,
+        both crossing a common segment P, comes first.
+        If the two segments cross P very close (e.g. in a spike),
+        the distance between the intersection points can be zero,
+        but we still need to know which comes first.
+        Therefore, it is useful that using sides we are able to discover this.
+ */
+template <typename Point1>
+struct get_relative_order
+{
+    typedef strategy_intersection
+        <
+            typename cs_tag<Point1>::type,
+            Point1,
+            Point1,
+            Point1
+        > si;
+
+    typedef typename si::side_strategy_type strategy;
+
+    template <typename Point>
+    static inline int value_via_product(Point const& ti, Point const& tj,
+                    Point const& ui, Point const& uj, int factor)
+    {
+        int const side_ti_u = strategy::apply(ti, tj, ui);
+        int const side_tj_u = strategy::apply(ti, tj, uj);
+
+#ifdef BOOST_GEOMETRY_DEBUG_RELATIVE_ORDER
+        std::cout << (factor == 1  ? " r//s " :  " s//r ")
+            << side_ti_u << " / " << side_tj_u;
+#endif
+
+        return side_ti_u * side_tj_u >= 0
+            ? factor * (side_ti_u != 0 ? side_ti_u : side_tj_u)
+            : 0;
+    }
+
+
+    static inline int apply(
+                Point1 const& pi, Point1 const& pj,
+                Point1 const& ri, Point1 const& rj,
+                Point1 const& si, Point1 const& sj)
+    {
+        int const side_ri_p = strategy::apply(pi, pj, ri);
+        int const side_si_p = strategy::apply(pi, pj, si);
+
+#ifdef BOOST_GEOMETRY_DEBUG_RELATIVE_ORDER
+        int const side_rj_p = strategy::apply(pi, pj, rj);
+        int const side_sj_p = strategy::apply(pi, pj, sj);
+        std::cout << "r//p: " << side_ri_p << " / " << side_rj_p;
+        std::cout << " s//p: " << side_si_p << " / " << side_sj_p;
+#endif
+
+        int value = value_via_product(si, sj, ri, rj, 1);
+        if (value == 0)
+        {
+            value = value_via_product(ri, rj, si, sj, -1);
+        }
+
+        int const order = side_ri_p * side_ri_p * side_si_p * value;
+
+#ifdef BOOST_GEOMETRY_DEBUG_RELATIVE_ORDER
+        std::cout
+            << " o: " << order
+            << std::endl << std::endl;
+#endif
+
+        return order;
+    }
+};
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/get_ring.hpp b/src/boost/geometry/algorithms/detail/overlay/get_ring.hpp
new file mode 100644
index 0000000..c2c6980
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/get_ring.hpp
@@ -0,0 +1,102 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
+
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template<typename Tag>
+struct get_ring
+{};
+
+// A container of rings (multi-ring but that does not exist)
+// gets the "void" tag and is dispatched here.
+template<>
+struct get_ring<void>
+{
+    template<typename Container>
+    static inline typename boost::range_value<Container>::type const&
+                apply(ring_identifier const& id, Container const& container)
+    {
+        return container[id.multi_index];
+    }
+};
+
+
+
+
+template<>
+struct get_ring<ring_tag>
+{
+    template<typename Ring>
+    static inline Ring const& apply(ring_identifier const& , Ring const& ring)
+    {
+        return ring;
+    }
+};
+
+
+template<>
+struct get_ring<box_tag>
+{
+    template<typename Box>
+    static inline Box const& apply(ring_identifier const& ,
+                    Box const& box)
+    {
+        return box;
+    }
+};
+
+
+template<>
+struct get_ring<polygon_tag>
+{
+    template<typename Polygon>
+    static inline typename ring_return_type<Polygon const>::type const apply(
+                ring_identifier const& id,
+                Polygon const& polygon)
+    {
+        BOOST_ASSERT
+            (
+                id.ring_index >= -1
+                && id.ring_index < int(boost::size(interior_rings(polygon)))
+            );
+        return id.ring_index < 0
+            ? exterior_ring(polygon)
+            : interior_rings(polygon)[id.ring_index];
+    }
+};
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/src/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp
new file mode 100644
index 0000000..b8320d9
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp
@@ -0,0 +1,1094 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HPP
+
+
+#include <boost/assert.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/strategies/intersection.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW)
+class turn_info_exception : public geometry::exception
+{
+    std::string message;
+public:
+
+    // NOTE: "char" will be replaced by enum in future version
+    inline turn_info_exception(char const method) 
+    {
+        message = "Boost.Geometry Turn exception: ";
+        message += method;
+    }
+
+    virtual ~turn_info_exception() throw()
+    {}
+
+    virtual char const* what() const throw()
+    {
+        return message.c_str();
+    }
+};
+#endif
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+struct base_turn_handler
+{
+    // Returns true if both sides are opposite
+    static inline bool opposite(int side1, int side2)
+    {
+        // We cannot state side1 == -side2, because 0 == -0
+        // So either side1*side2==-1 or side1==-side2 && side1 != 0
+        return side1 * side2 == -1;
+    }
+
+    // Same side of a segment (not being 0)
+    static inline bool same(int side1, int side2)
+    {
+        return side1 * side2 == 1;
+    }
+
+    // Both continue
+    template <typename TurnInfo>
+    static inline void both(TurnInfo& ti, operation_type const op)
+    {
+        ti.operations[0].operation = op;
+        ti.operations[1].operation = op;
+    }
+
+    // If condition, first union/second intersection, else vice versa
+    template <typename TurnInfo>
+    static inline void ui_else_iu(bool condition, TurnInfo& ti)
+    {
+        ti.operations[0].operation = condition
+                    ? operation_union : operation_intersection;
+        ti.operations[1].operation = condition
+                    ? operation_intersection : operation_union;
+    }
+
+    // If condition, both union, else both intersection
+    template <typename TurnInfo>
+    static inline void uu_else_ii(bool condition, TurnInfo& ti)
+    {
+        both(ti, condition ? operation_union : operation_intersection);
+    }
+};
+
+
+template
+<
+    typename TurnInfo,
+    typename SideStrategy
+>
+struct touch_interior : public base_turn_handler
+{
+    // Index: 0, P is the interior, Q is touching and vice versa
+    template
+    <
+        int Index,
+        typename Point1,
+        typename Point2,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& ,
+                Point2 const& qi, Point2 const& qj, Point2 const& qk,
+                TurnInfo& ti,
+                IntersectionInfo const& intersection_info,
+                DirInfo const& dir_info)
+    {
+        ti.method = method_touch_interior;
+        geometry::convert(intersection_info.intersections[0], ti.point);
+
+        // Both segments of q touch segment p somewhere in its interior
+        // 1) We know: if q comes from LEFT or RIGHT
+        // (i.e. dir_info.sides.get<Index,0>() == 1 or -1)
+        // 2) Important is: if q_k goes to LEFT, RIGHT, COLLINEAR
+        //    and, if LEFT/COLL, if it is lying LEFT or RIGHT w.r.t. q_i
+
+        static int const index_p = Index;
+        static int const index_q = 1 - Index;
+
+        int const side_qi_p = dir_info.sides.template get<index_q, 0>();
+        int const side_qk_p = SideStrategy::apply(pi, pj, qk);
+
+        if (side_qi_p == -side_qk_p)
+        {
+            // Q crosses P from left->right or from right->left (test "ML1")
+            // Union: folow P (left->right) or Q (right->left)
+            // Intersection: other turn
+            int index = side_qk_p == -1 ? index_p : index_q;
+            ti.operations[index].operation = operation_union;
+            ti.operations[1 - index].operation = operation_intersection;
+            return;
+        }
+
+        int const side_qk_q = SideStrategy::apply(qi, qj, qk);
+
+        if (side_qi_p == -1 && side_qk_p == -1 && side_qk_q == 1)
+        {
+            // Q turns left on the right side of P (test "MR3")
+            // Both directions for "intersection"
+            both(ti, operation_intersection);
+        }
+        else if (side_qi_p == 1 && side_qk_p == 1 && side_qk_q == -1)
+        {
+            // Q turns right on the left side of P (test "ML3")
+            // Union: take both operation
+            // Intersection: skip
+            both(ti, operation_union);
+        }
+        else if (side_qi_p == side_qk_p && side_qi_p == side_qk_q)
+        {
+            // Q turns left on the left side of P (test "ML2")
+            // or Q turns right on the right side of P (test "MR2")
+            // Union: take left turn (Q if Q turns left, P if Q turns right)
+            // Intersection: other turn
+            int index = side_qk_q == 1 ? index_q : index_p;
+            ti.operations[index].operation = operation_union;
+            ti.operations[1 - index].operation = operation_intersection;
+        }
+        else if (side_qk_p == 0)
+        {
+            // Q intersects on interior of P and continues collinearly
+            if (side_qk_q == side_qi_p)
+            {
+                // Collinearly in the same direction
+                // (Q comes from left of P and turns left,
+                //  OR Q comes from right of P and turns right)
+                // Omit intersection point.
+                // Union: just continue
+                // Intersection: just continue
+                both(ti, operation_continue);
+            }
+            else
+            {
+                // Opposite direction, which is never travelled.
+                // If Q turns left, P continues for intersection
+                // If Q turns right, P continues for union
+                ti.operations[Index].operation = side_qk_q == 1
+                    ? operation_intersection
+                    : operation_union;
+                ti.operations[1 - Index].operation = operation_blocked;
+            }
+        }
+        else
+        {
+            // Should not occur!
+            ti.method = method_error;
+        }
+    }
+};
+
+
+template
+<
+    typename TurnInfo,
+    typename SideStrategy
+>
+struct touch : public base_turn_handler
+{
+    static inline bool between(int side1, int side2, int turn)
+    {
+        return side1 == side2 && ! opposite(side1, turn);
+    }
+
+    /*static inline void block_second(bool block, TurnInfo& ti)
+    {
+        if (block)
+        {
+            ti.operations[1].operation = operation_blocked;
+        }
+    }*/
+
+
+    template
+    <
+        typename Point1,
+        typename Point2,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& pk,
+                Point2 const& qi, Point2 const& qj, Point2 const& qk,
+                TurnInfo& ti,
+                IntersectionInfo const& intersection_info,
+                DirInfo const& dir_info)
+    {
+        ti.method = method_touch;
+        geometry::convert(intersection_info.intersections[0], ti.point);
+
+        int const side_qi_p1 = dir_info.sides.template get<1, 0>();
+        int const side_qk_p1 = SideStrategy::apply(pi, pj, qk);
+
+
+        // If Qi and Qk are both at same side of Pi-Pj,
+        // or collinear (so: not opposite sides)
+        if (! opposite(side_qi_p1, side_qk_p1))
+        {
+            int const side_pk_q2 = SideStrategy::apply(qj, qk, pk);
+            int const side_pk_p  = SideStrategy::apply(pi, pj, pk);
+            int const side_qk_q  = SideStrategy::apply(qi, qj, qk);
+
+            bool const both_continue = side_pk_p == 0 && side_qk_q == 0;
+            bool const robustness_issue_in_continue = both_continue && side_pk_q2 != 0;
+
+            bool const q_turns_left = side_qk_q == 1;
+            bool const block_q = side_qk_p1 == 0
+                        && ! same(side_qi_p1, side_qk_q)
+                        && ! robustness_issue_in_continue
+                        ;
+
+            // If Pk at same side as Qi/Qk
+            // (the "or" is for collinear case)
+            // or Q is fully collinear && P turns not to left
+            if (side_pk_p == side_qi_p1
+                || side_pk_p == side_qk_p1
+                || (side_qi_p1 == 0 && side_qk_p1 == 0 && side_pk_p != -1)
+                )
+            {
+                // Collinear -> lines join, continue
+                // (#BRL2)
+                if (side_pk_q2 == 0 && ! block_q)
+                {
+                    both(ti, operation_continue);
+                    return;
+                }
+
+                int const side_pk_q1 = SideStrategy::apply(qi, qj, pk);
+
+
+                // Collinear opposite case -> block P
+                // (#BRL4, #BLR8)
+                if (side_pk_q1 == 0)
+                {
+                    ti.operations[0].operation = operation_blocked;
+                    // Q turns right -> union (both independent),
+                    // Q turns left -> intersection
+                    ti.operations[1].operation = block_q ? operation_blocked
+                        : q_turns_left ? operation_intersection
+                        : operation_union;
+                    return;
+                }
+
+                // Pk between Qi and Qk
+                // (#BRL3, #BRL7)
+                if (between(side_pk_q1, side_pk_q2, side_qk_q))
+                {
+                    ui_else_iu(q_turns_left, ti);
+                    if (block_q)
+                    {
+                        ti.operations[1].operation = operation_blocked;
+                    }
+                    //block_second(block_q, ti);
+                    return;
+                }
+
+                // Pk between Qk and P, so left of Qk (if Q turns right) and vv
+                // (#BRL1)
+                if (side_pk_q2 == -side_qk_q)
+                {
+                    ui_else_iu(! q_turns_left, ti);
+                    return;
+                }
+
+                //
+                // (#BRL5, #BRL9)
+                if (side_pk_q1 == -side_qk_q)
+                {
+                    uu_else_ii(! q_turns_left, ti);
+                    if (block_q)
+                    {
+                        ti.operations[1].operation = operation_blocked;
+                    }
+                    //block_second(block_q, ti);
+                    return;
+                }
+            }
+            else
+            {
+                // Pk at other side than Qi/Pk
+                int const side_qk_q = SideStrategy::apply(qi, qj, qk);
+                bool const q_turns_left = side_qk_q == 1;
+
+                ti.operations[0].operation = q_turns_left
+                            ? operation_intersection
+                            : operation_union;
+                ti.operations[1].operation = block_q
+                            ? operation_blocked
+                            : side_qi_p1 == 1 || side_qk_p1 == 1
+                            ? operation_union
+                            : operation_intersection;
+
+                return;
+            }
+        }
+        else
+        {
+            // From left to right or from right to left
+            int const side_pk_p  = SideStrategy::apply(pi, pj, pk);
+            bool const right_to_left = side_qk_p1 == 1;
+
+            // If p turns into direction of qi (1,2)
+            if (side_pk_p == side_qi_p1)
+            {
+                int const side_pk_q1 = SideStrategy::apply(qi, qj, pk);
+
+                // Collinear opposite case -> block P
+                if (side_pk_q1 == 0)
+                {
+                    ti.operations[0].operation = operation_blocked;
+                    ti.operations[1].operation = right_to_left
+                                ? operation_union : operation_intersection;
+                    return;
+                }
+
+                if (side_pk_q1 == side_qk_p1)
+                {
+                    uu_else_ii(right_to_left, ti);
+                    return;
+                }
+            }
+
+            // If p turns into direction of qk (4,5)
+            if (side_pk_p == side_qk_p1)
+            {
+                int const side_pk_q2 = SideStrategy::apply(qj, qk, pk);
+
+                // Collinear case -> lines join, continue
+                if (side_pk_q2 == 0)
+                {
+                    both(ti, operation_continue);
+                    return;
+                }
+                if (side_pk_q2 == side_qk_p1)
+                {
+                    ui_else_iu(right_to_left, ti);
+                    return;
+                }
+            }
+            // otherwise (3)
+            ui_else_iu(! right_to_left, ti);
+            return;
+        }
+
+#ifdef BOOST_GEOMETRY_DEBUG_GET_TURNS
+        // Normally a robustness issue.
+        // TODO: more research if still occuring
+        std::cout << "Not yet handled" << std::endl
+            << "pi " << get<0>(pi) << " , " << get<1>(pi)
+            << " pj " << get<0>(pj) << " , " << get<1>(pj)
+            << " pk " << get<0>(pk) << " , " << get<1>(pk)
+            << std::endl
+            << "qi " << get<0>(qi) << " , " << get<1>(qi)
+            << " qj " << get<0>(qj) << " , " << get<1>(qj)
+            << " qk " << get<0>(qk) << " , " << get<1>(qk)
+            << std::endl;
+#endif
+
+    }
+};
+
+
+template
+<
+    typename TurnInfo,
+    typename SideStrategy
+>
+struct equal : public base_turn_handler
+{
+    template
+    <
+        typename Point1,
+        typename Point2,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& pk,
+                Point2 const& , Point2 const& qj, Point2 const& qk,
+                TurnInfo& ti,
+                IntersectionInfo const& intersection_info,
+                DirInfo const& )
+    {
+        ti.method = method_equal;
+        // Copy the SECOND intersection point
+        geometry::convert(intersection_info.intersections[1], ti.point);
+
+        int const side_pk_q2  = SideStrategy::apply(qj, qk, pk);
+        int const side_pk_p = SideStrategy::apply(pi, pj, pk);
+        int const side_qk_p = SideStrategy::apply(pi, pj, qk);
+
+        // If pk is collinear with qj-qk, they continue collinearly.
+        // This can be on either side of p1 (== q1), or collinear
+        // The second condition checks if they do not continue
+        // oppositely
+        if (side_pk_q2 == 0 && side_pk_p == side_qk_p)
+        {
+            both(ti, operation_continue);
+            return;
+        }
+
+
+        // If they turn to same side (not opposite sides)
+        if (! opposite(side_pk_p, side_qk_p))
+        {
+            int const side_pk_q2 = SideStrategy::apply(qj, qk, pk);
+
+            // If pk is left of q2 or collinear: p: union, q: intersection
+            ui_else_iu(side_pk_q2 != -1, ti);
+        }
+        else
+        {
+            // They turn opposite sides. If p turns left (or collinear),
+            // p: union, q: intersection
+            ui_else_iu(side_pk_p != -1, ti);
+        }
+    }
+};
+
+
+template
+<
+    typename TurnInfo,
+    typename AssignPolicy
+>
+struct equal_opposite : public base_turn_handler
+{
+    template
+    <
+        typename Point1,
+        typename Point2,
+        typename OutputIterator,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(Point1 const& pi, Point2 const& qi,
+				/* by value: */ TurnInfo tp,
+                OutputIterator& out,
+                IntersectionInfo const& intersection_info,
+                DirInfo const& dir_info)
+    {
+        // For equal-opposite segments, normally don't do anything.
+		if (AssignPolicy::include_opposite)
+		{
+			tp.method = method_equal;
+			for (int i = 0; i < 2; i++)
+			{
+				tp.operations[i].operation = operation_opposite;
+			}
+			for (unsigned int i = 0; i < intersection_info.count; i++)
+			{
+				geometry::convert(intersection_info.intersections[i], tp.point);
+				AssignPolicy::apply(tp, pi, qi, intersection_info, dir_info);
+				*out++ = tp;
+			}
+		}
+    }
+};
+
+template
+<
+    typename TurnInfo,
+    typename SideStrategy
+>
+struct collinear : public base_turn_handler
+{
+    /*
+        arrival P   pk//p1  qk//q1   product*  case    result
+         1           1                1        CLL1    ui
+        -1                   1       -1        CLL2    iu
+         1           1                1        CLR1    ui
+        -1                  -1        1        CLR2    ui
+
+         1          -1               -1        CRL1    iu
+        -1                   1       -1        CRL2    iu
+         1          -1               -1        CRR1    iu
+        -1                  -1        1        CRR2    ui
+
+         1           0                0        CC1     cc
+        -1                   0        0        CC2     cc
+
+         *product = arrival * (pk//p1 or qk//q1)
+
+         Stated otherwise:
+         - if P arrives: look at turn P
+         - if Q arrives: look at turn Q
+         - if P arrives and P turns left: union for P
+         - if P arrives and P turns right: intersection for P
+         - if Q arrives and Q turns left: union for Q (=intersection for P)
+         - if Q arrives and Q turns right: intersection for Q (=union for P)
+
+         ROBUSTNESS: p and q are collinear, so you would expect
+         that side qk//p1 == pk//q1. But that is not always the case
+         in near-epsilon ranges. Then decision logic is different.
+         If p arrives, q is further, so the angle qk//p1 is (normally) 
+         more precise than pk//p1
+
+    */
+    template
+    <
+        typename Point1,
+        typename Point2,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& pk,
+                Point2 const& qi, Point2 const& qj, Point2 const& qk,
+                TurnInfo& ti,
+                IntersectionInfo const& intersection_info,
+                DirInfo const& dir_info)
+    {
+        ti.method = method_collinear;
+        geometry::convert(intersection_info.intersections[1], ti.point);
+
+        int const arrival = dir_info.arrival[0];
+        // Should not be 0, this is checked before
+        BOOST_ASSERT(arrival != 0);
+
+        int const side_p = SideStrategy::apply(pi, pj, pk);
+        int const side_q = SideStrategy::apply(qi, qj, qk);
+
+        // If p arrives, use p, else use q
+        int const side_p_or_q = arrival == 1
+            ? side_p
+            : side_q
+            ;
+
+        int const side_pk = SideStrategy::apply(qi, qj, pk);
+        int const side_qk = SideStrategy::apply(pi, pj, qk);
+
+        // See comments above,
+        // resulting in a strange sort of mathematic rule here:
+        // The arrival-info multiplied by the relevant side
+        // delivers a consistent result.
+
+        int const product = arrival * side_p_or_q;
+
+        // Robustness: side_p is supposed to be equal to side_pk (because p/q are collinear)
+        // and side_q to side_qk
+        bool const robustness_issue = side_pk != side_p || side_qk != side_q;
+
+        if (robustness_issue)
+        {
+            handle_robustness(ti, arrival, side_p, side_q, side_pk, side_qk);
+        }
+        else if(product == 0)
+        {
+            both(ti, operation_continue);
+        }
+        else
+        {
+            ui_else_iu(product == 1, ti);
+        }
+    }
+
+    static inline void handle_robustness(TurnInfo& ti, int arrival, 
+                    int side_p, int side_q, int side_pk, int side_qk)
+    {
+        // We take the longer one, i.e. if q arrives in p (arrival == -1),
+        // then p exceeds q and we should take p for a union...
+
+        bool use_p_for_union = arrival == -1;
+
+        // ... unless one of the sides consistently directs to the other side
+        int const consistent_side_p = side_p == side_pk ? side_p : 0;
+        int const consistent_side_q = side_q == side_qk ? side_q : 0;
+        if (arrival == -1 && (consistent_side_p == -1 || consistent_side_q == 1))
+        {
+            use_p_for_union = false;
+        }
+        if (arrival == 1 && (consistent_side_p == 1 || consistent_side_q == -1))
+        {
+            use_p_for_union = true;
+        }
+
+        //std::cout << "ROBUSTNESS -> Collinear " 
+        //    << " arr: " << arrival
+        //    << " dir: " << side_p << " " << side_q
+        //    << " rev: " << side_pk << " " << side_qk
+        //    << " cst: " << cside_p << " " << cside_q
+        //    << std::boolalpha << " " << use_p_for_union
+        //    << std::endl;
+
+        ui_else_iu(use_p_for_union, ti);
+    }
+
+};
+
+template
+<
+    typename TurnInfo,
+    typename SideStrategy,
+    typename AssignPolicy
+>
+struct collinear_opposite : public base_turn_handler
+{
+private :
+    /*
+        arrival P  arrival Q  pk//p1   qk//q1  case  result2  result
+        --------------------------------------------------------------
+         1          1          1       -1      CLO1    ix      xu
+         1          1          1        0      CLO2    ix      (xx)
+         1          1          1        1      CLO3    ix      xi
+
+         1          1          0       -1      CCO1    (xx)    xu
+         1          1          0        0      CCO2    (xx)    (xx)
+         1          1          0        1      CCO3    (xx)    xi
+
+         1          1         -1       -1      CRO1    ux      xu
+         1          1         -1        0      CRO2    ux      (xx)
+         1          1         -1        1      CRO3    ux      xi
+
+        -1          1                  -1      CXO1    xu
+        -1          1                   0      CXO2    (xx)
+        -1          1                   1      CXO3    xi
+
+         1         -1          1               CXO1    ix
+         1         -1          0               CXO2    (xx)
+         1         -1         -1               CXO3    ux
+    */
+
+    template
+    <
+        int Index,
+        typename Point,
+        typename IntersectionInfo
+    >
+    static inline bool set_tp(Point const& ri, Point const& rj, Point const& rk,
+                TurnInfo& tp, IntersectionInfo const& intersection_info)
+    {
+        int const side_rk_r = SideStrategy::apply(ri, rj, rk);
+		operation_type blocked = operation_blocked;
+        switch(side_rk_r)
+        {
+
+            case 1 :
+                // Turning left on opposite collinear: intersection
+                tp.operations[Index].operation = operation_intersection;
+                break;
+            case -1 :
+                // Turning right on opposite collinear: union
+                tp.operations[Index].operation = operation_union;
+                break;
+            case 0 :
+                // No turn on opposite collinear: block, do not traverse
+                // But this "xx" is usually ignored, it is useless to include
+                // two operations blocked, so the whole point does not need
+                // to be generated.
+                // So return false to indicate nothing is to be done.
+				if (AssignPolicy::include_opposite)
+				{
+					tp.operations[Index].operation = operation_opposite;
+					blocked = operation_opposite;
+				}
+				else
+				{
+					return false;
+				}
+				break;
+        }
+
+        // The other direction is always blocked when collinear opposite
+        tp.operations[1 - Index].operation = blocked;
+
+        // If P arrives within Q, set info on P (which is done above, index=0),
+        // this turn-info belongs to the second intersection point, index=1
+        // (see e.g. figure CLO1)
+        geometry::convert(intersection_info.intersections[1 - Index], tp.point);
+        return true;
+    }
+
+public:
+    template
+    <
+        typename Point1,
+        typename Point2,
+        typename OutputIterator,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& pk,
+                Point2 const& qi, Point2 const& qj, Point2 const& qk,
+
+                // Opposite collinear can deliver 2 intersection points,
+                TurnInfo const& tp_model,
+                OutputIterator& out,
+
+                IntersectionInfo const& intersection_info,
+                DirInfo const& dir_info)
+    {
+        TurnInfo tp = tp_model;
+
+        tp.method = method_collinear;
+
+        // If P arrives within Q, there is a turn dependent on P
+        if (dir_info.arrival[0] == 1
+            && set_tp<0>(pi, pj, pk, tp, intersection_info))
+        {
+            AssignPolicy::apply(tp, pi, qi, intersection_info, dir_info);
+            *out++ = tp;
+        }
+
+        // If Q arrives within P, there is a turn dependent on Q
+        if (dir_info.arrival[1] == 1
+            && set_tp<1>(qi, qj, qk, tp, intersection_info))
+        {
+            AssignPolicy::apply(tp, pi, qi, intersection_info, dir_info);
+            *out++ = tp;
+        }
+
+		if (AssignPolicy::include_opposite)
+		{
+	        // Handle cases not yet handled above
+			if ((dir_info.arrival[1] == -1 && dir_info.arrival[0] == 0)
+				|| (dir_info.arrival[0] == -1 && dir_info.arrival[1] == 0))
+			{
+				for (int i = 0; i < 2; i++)
+				{
+					tp.operations[i].operation = operation_opposite;
+				}
+				for (unsigned int i = 0; i < intersection_info.count; i++)
+				{
+					geometry::convert(intersection_info.intersections[i], tp.point);
+					AssignPolicy::apply(tp, pi, qi, intersection_info, dir_info);
+					*out++ = tp;
+				}
+			}
+		}
+
+    }
+};
+
+
+template
+<
+    typename TurnInfo,
+    typename SideStrategy
+>
+struct crosses : public base_turn_handler
+{
+    template
+    <
+        typename Point1,
+        typename Point2,
+        typename IntersectionInfo,
+        typename DirInfo
+    >
+    static inline void apply(
+                Point1 const& , Point1 const& , Point1 const& ,
+                Point2 const& , Point2 const& , Point2 const& ,
+                TurnInfo& ti,
+                IntersectionInfo const& intersection_info,
+                DirInfo const& dir_info)
+    {
+        ti.method = method_crosses;
+        geometry::convert(intersection_info.intersections[0], ti.point);
+
+        // In all casees:
+        // If Q crosses P from left to right
+        // Union: take P
+        // Intersection: take Q
+        // Otherwise: vice versa
+        int const side_qi_p1 = dir_info.sides.template get<1, 0>();
+        int const index = side_qi_p1 == 1 ? 0 : 1;
+        ti.operations[index].operation = operation_union;
+        ti.operations[1 - index].operation = operation_intersection;
+    }
+};
+
+template<typename TurnInfo>
+struct only_convert
+{
+    template<typename IntersectionInfo>
+    static inline void apply(TurnInfo& ti, IntersectionInfo const& intersection_info)
+    {
+        ti.method = method_collinear;
+        geometry::convert(intersection_info.intersections[0], ti.point);
+        ti.operations[0].operation = operation_continue;
+        ti.operations[1].operation = operation_continue;
+    }
+};
+
+/*!
+\brief Policy doing nothing
+\details get_turn_info can have an optional policy to get/assign some
+    extra information. By default it does not, and this class
+    is that default.
+ */
+struct assign_null_policy
+{
+    static bool const include_no_turn = false;
+    static bool const include_degenerate = false;
+    static bool const include_opposite = false;
+
+    template 
+	<
+		typename Info,
+		typename Point1,
+		typename Point2,
+		typename IntersectionInfo,
+		typename DirInfo
+	>
+    static inline void apply(Info& , Point1 const& , Point2 const&, IntersectionInfo const&, DirInfo const&)
+    {}
+
+};
+
+
+/*!
+    \brief Turn information: intersection point, method, and turn information
+    \details Information necessary for traversal phase (a phase
+        of the overlay process). The information is gathered during the
+        get_turns (segment intersection) phase.
+    \tparam Point1 point type of first segment
+    \tparam Point2 point type of second segment
+    \tparam TurnInfo type of class getting intersection and turn info
+    \tparam AssignPolicy policy to assign extra info,
+        e.g. to calculate distance from segment's first points
+        to intersection points.
+        It also defines if a certain class of points
+        (degenerate, non-turns) should be included.
+ */
+template
+<
+    typename Point1,
+    typename Point2,
+    typename TurnInfo,
+    typename AssignPolicy
+>
+struct get_turn_info
+{
+    typedef strategy_intersection
+        <
+            typename cs_tag<typename TurnInfo::point_type>::type,
+            Point1,
+            Point2,
+            typename TurnInfo::point_type
+        > si;
+
+    typedef typename si::segment_intersection_strategy_type strategy;
+
+    // Intersect pi-pj with qi-qj
+    // The points pk and qk are only used do determine more information
+    // about the turn.
+    template <typename OutputIterator>
+    static inline OutputIterator apply(
+                Point1 const& pi, Point1 const& pj, Point1 const& pk,
+                Point2 const& qi, Point2 const& qj, Point2 const& qk,
+                TurnInfo const& tp_model,
+                OutputIterator out)
+    {
+        typedef model::referring_segment<Point1 const> segment_type1;
+        typedef model::referring_segment<Point1 const> segment_type2;
+        segment_type1 p1(pi, pj), p2(pj, pk);
+        segment_type2 q1(qi, qj), q2(qj, qk);
+
+        typename strategy::return_type result = strategy::apply(p1, q1);
+
+        char const method = result.template get<1>().how;
+
+        // Copy, to copy possibly extended fields
+        TurnInfo tp = tp_model;
+
+
+        // Select method and apply
+        switch(method)
+        {
+            case 'a' : // collinear, "at"
+            case 'f' : // collinear, "from"
+            case 's' : // starts from the middle
+                if (AssignPolicy::include_no_turn
+                    && result.template get<0>().count > 0)
+                {
+                    only_convert<TurnInfo>::apply(tp,
+                                result.template get<0>());
+                    AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                    *out++ = tp;
+                }
+                break;
+
+            case 'd' : // disjoint: never do anything
+                break;
+
+            case 'm' :
+            {
+                typedef touch_interior
+                    <
+                        TurnInfo,
+                        typename si::side_strategy_type
+                    > policy;
+
+                // If Q (1) arrives (1)
+                if (result.template get<1>().arrival[1] == 1)
+                {
+                    policy::template apply<0>(pi, pj, pk, qi, qj, qk,
+                                tp, result.template get<0>(), result.template get<1>());
+                }
+                else
+                {
+                    // Swap p/q
+                    policy::template apply<1>(qi, qj, qk, pi, pj, pk,
+                                tp, result.template get<0>(), result.template get<1>());
+                }
+                AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                *out++ = tp;
+            }
+            break;
+            case 'i' :
+            {
+                typedef crosses
+                    <
+                        TurnInfo,
+                        typename si::side_strategy_type
+                    > policy;
+
+                policy::apply(pi, pj, pk, qi, qj, qk,
+                    tp, result.template get<0>(), result.template get<1>());
+                AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                *out++ = tp;
+            }
+            break;
+            case 't' :
+            {
+                // Both touch (both arrive there)
+                typedef touch
+                    <
+                        TurnInfo,
+                        typename si::side_strategy_type
+                    > policy;
+
+                policy::apply(pi, pj, pk, qi, qj, qk,
+                    tp, result.template get<0>(), result.template get<1>());
+                AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                *out++ = tp;
+            }
+            break;
+            case 'e':
+            {
+                if (! result.template get<1>().opposite)
+                {
+                    // Both equal
+                    // or collinear-and-ending at intersection point
+                    typedef equal
+                        <
+                            TurnInfo,
+                            typename si::side_strategy_type
+                        > policy;
+
+                    policy::apply(pi, pj, pk, qi, qj, qk,
+                        tp, result.template get<0>(), result.template get<1>());
+                    AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                    *out++ = tp;
+                }
+				else
+				{
+                    equal_opposite
+                        <
+                            TurnInfo,
+                            AssignPolicy
+                        >::apply(pi, qi,
+                            tp, out, result.template get<0>(), result.template get<1>());
+				}
+            }
+            break;
+            case 'c' :
+            {
+                // Collinear
+                if (! result.template get<1>().opposite)
+                {
+
+                    if (result.template get<1>().arrival[0] == 0)
+                    {
+                        // Collinear, but similar thus handled as equal
+                        equal
+                            <
+                                TurnInfo,
+                                typename si::side_strategy_type
+                            >::apply(pi, pj, pk, qi, qj, qk,
+                                tp, result.template get<0>(), result.template get<1>());
+
+                        // override assigned method
+                        tp.method = method_collinear;
+                    }
+                    else
+                    {
+                        collinear
+                            <
+                                TurnInfo,
+                                typename si::side_strategy_type
+                            >::apply(pi, pj, pk, qi, qj, qk,
+                                tp, result.template get<0>(), result.template get<1>());
+                    }
+
+                    AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                    *out++ = tp;
+                }
+                else
+                {
+                    collinear_opposite
+                        <
+                            TurnInfo,
+                            typename si::side_strategy_type,
+                            AssignPolicy
+                        >::apply(pi, pj, pk, qi, qj, qk,
+                            tp, out, result.template get<0>(), result.template get<1>());
+                }
+            }
+            break;
+            case '0' :
+            {
+                // degenerate points
+                if (AssignPolicy::include_degenerate)
+                {
+                    only_convert<TurnInfo>::apply(tp, result.template get<0>());
+                    AssignPolicy::apply(tp, pi, qi, result.template get<0>(), result.template get<1>());
+                    *out++ = tp;
+                }
+            }
+            break;
+            default :
+            {
+#if ! defined(BOOST_GEOMETRY_OVERLAY_NO_THROW)
+                throw turn_info_exception(method);
+#endif
+            }
+            break;
+        }
+
+        return out;
+    }
+};
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURN_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/src/boost/geometry/algorithms/detail/overlay/get_turns.hpp
new file mode 100644
index 0000000..2662904
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/get_turns.hpp
@@ -0,0 +1,873 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP
+
+
+#include <cstddef>
+#include <map>
+
+#include <boost/array.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/tuple/tuple.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+#include <boost/geometry/views/detail/range_type.hpp>
+
+#include <boost/geometry/geometries/box.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+#include <boost/geometry/iterators/ever_circling_iterator.hpp>
+
+#include <boost/geometry/strategies/cartesian/cart_intersect.hpp>
+#include <boost/geometry/strategies/intersection.hpp>
+#include <boost/geometry/strategies/intersection_result.hpp>
+
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/algorithms/detail/partition.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
+
+
+#include <boost/geometry/algorithms/detail/sections/range_by_section.hpp>
+
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/algorithms/detail/sections/sectionalize.hpp>
+
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+#  include <sstream>
+#  include <boost/geometry/io/dsv/write.hpp>
+#endif
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace get_turns
+{
+
+
+struct no_interrupt_policy
+{
+    static bool const enabled = false;
+
+    template <typename Range>
+    static inline bool apply(Range const&)
+    {
+        return false;
+    }
+};
+
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Section1, typename Section2,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+class get_turns_in_sections
+{
+    typedef typename closeable_view
+        <
+            typename range_type<Geometry1>::type const,
+            closure<Geometry1>::value
+        >::type cview_type1;
+    typedef typename closeable_view
+        <
+            typename range_type<Geometry2>::type const,
+            closure<Geometry2>::value
+        >::type cview_type2;
+
+    typedef typename reversible_view
+        <
+            cview_type1 const,
+            Reverse1 ? iterate_reverse : iterate_forward
+        >::type view_type1;
+    typedef typename reversible_view
+        <
+            cview_type2 const,
+            Reverse2 ? iterate_reverse : iterate_forward
+        >::type view_type2;
+
+    typedef typename boost::range_iterator
+        <
+            view_type1 const
+        >::type range1_iterator;
+
+    typedef typename boost::range_iterator
+        <
+            view_type2 const
+        >::type range2_iterator;
+
+
+    template <typename Geometry, typename Section>
+    static inline bool neighbouring(Section const& section,
+            int index1, int index2)
+    {
+        // About n-2:
+        //   (square: range_count=5, indices 0,1,2,3
+        //    -> 0-3 are adjacent, don't check on intersections)
+        // Also tested for open polygons, and/or duplicates
+        // About first condition: will be optimized by compiler (static)
+        // It checks if it is areal (box,ring,(multi)polygon
+        int const n = int(section.range_count);
+        return boost::is_same
+                    <
+                        typename tag_cast
+                            <
+                                typename geometry::point_type<Geometry1>::type, 
+                                areal_tag
+                            >::type, 
+                        areal_tag
+                    >::value
+               && index1 == 0 
+               && index2 >= n - 2
+                ;
+    }
+
+
+public :
+    // Returns true if terminated, false if interrupted
+    static inline bool apply(
+            int source_id1, Geometry1 const& geometry1, Section1 const& sec1,
+            int source_id2, Geometry2 const& geometry2, Section2 const& sec2,
+            bool skip_larger,
+            Turns& turns,
+            InterruptPolicy& interrupt_policy)
+    {
+        cview_type1 cview1(range_by_section(geometry1, sec1));
+        cview_type2 cview2(range_by_section(geometry2, sec2));
+        view_type1 view1(cview1);
+        view_type2 view2(cview2);
+
+        range1_iterator begin_range_1 = boost::begin(view1);
+        range1_iterator end_range_1 = boost::end(view1);
+
+        range2_iterator begin_range_2 = boost::begin(view2);
+        range2_iterator end_range_2 = boost::end(view2);
+
+        int const dir1 = sec1.directions[0];
+        int const dir2 = sec2.directions[0];
+        int index1 = sec1.begin_index;
+        int ndi1 = sec1.non_duplicate_index;
+
+        bool const same_source =
+            source_id1 == source_id2
+                    && sec1.ring_id.multi_index == sec2.ring_id.multi_index
+                    && sec1.ring_id.ring_index == sec2.ring_id.ring_index;
+
+        range1_iterator prev1, it1, end1;
+
+        get_start_point_iterator(sec1, view1, prev1, it1, end1,
+                    index1, ndi1, dir1, sec2.bounding_box);
+
+        // We need a circular iterator because it might run through the closing point.
+        // One circle is actually enough but this one is just convenient.
+        ever_circling_iterator<range1_iterator> next1(begin_range_1, end_range_1, it1, true);
+        next1++;
+
+        // Walk through section and stop if we exceed the other box
+        // section 2:    [--------------]
+        // section 1: |----|---|---|---|---|
+        for (prev1 = it1++, next1++;
+            it1 != end1 && ! exceeding<0>(dir1, *prev1, sec2.bounding_box);
+            ++prev1, ++it1, ++index1, ++next1, ++ndi1)
+        {
+            ever_circling_iterator<range1_iterator> nd_next1(
+                    begin_range_1, end_range_1, next1, true);
+            advance_to_non_duplicate_next(nd_next1, it1, sec1);
+
+            int index2 = sec2.begin_index;
+            int ndi2 = sec2.non_duplicate_index;
+
+            range2_iterator prev2, it2, end2;
+
+            get_start_point_iterator(sec2, view2, prev2, it2, end2,
+                        index2, ndi2, dir2, sec1.bounding_box);
+            ever_circling_iterator<range2_iterator> next2(begin_range_2, end_range_2, it2, true);
+            next2++;
+
+            for (prev2 = it2++, next2++;
+                it2 != end2 && ! exceeding<0>(dir2, *prev2, sec1.bounding_box);
+                ++prev2, ++it2, ++index2, ++next2, ++ndi2)
+            {
+                bool skip = same_source;
+                if (skip)
+                {
+                    // If sources are the same (possibly self-intersecting):
+                    // skip if it is a neighbouring segment.
+                    // (including first-last segment
+                    //  and two segments with one or more degenerate/duplicate
+                    //  (zero-length) segments in between)
+
+                    // Also skip if index1 < index2 to avoid getting all
+                    // intersections twice (only do this on same source!)
+
+                    skip = (skip_larger && index1 >= index2)
+                        || ndi2 == ndi1 + 1
+                        || neighbouring<Geometry1>(sec1, index1, index2)
+                        ;
+                }
+
+                if (! skip)
+                {
+                    // Move to the "non duplicate next"
+                    ever_circling_iterator<range2_iterator> nd_next2(
+                            begin_range_2, end_range_2, next2, true);
+                    advance_to_non_duplicate_next(nd_next2, it2, sec2);
+
+                    typedef typename boost::range_value<Turns>::type turn_info;
+                    typedef typename turn_info::point_type ip;
+
+                    turn_info ti;
+                    ti.operations[0].seg_id = segment_identifier(source_id1,
+                                        sec1.ring_id.multi_index, sec1.ring_id.ring_index, index1),
+                    ti.operations[1].seg_id = segment_identifier(source_id2,
+                                        sec2.ring_id.multi_index, sec2.ring_id.ring_index, index2),
+
+                    ti.operations[0].other_id = ti.operations[1].seg_id;
+                    ti.operations[1].other_id = ti.operations[0].seg_id;
+
+                    std::size_t const size_before = boost::size(turns);
+
+                    TurnPolicy::apply(*prev1, *it1, *nd_next1, *prev2, *it2, *nd_next2,
+                            ti, std::back_inserter(turns));
+
+                    if (InterruptPolicy::enabled)
+                    {
+                        if (interrupt_policy.apply(
+                            std::make_pair(boost::begin(turns) + size_before,
+                                boost::end(turns))))
+                        {
+                            return false;
+                        }
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+
+private :
+    typedef typename geometry::point_type<Geometry1>::type point1_type;
+    typedef typename geometry::point_type<Geometry2>::type point2_type;
+    typedef typename model::referring_segment<point1_type const> segment1_type;
+    typedef typename model::referring_segment<point2_type const> segment2_type;
+
+
+    template <size_t Dim, typename Point, typename Box>
+    static inline bool preceding(int dir, Point const& point, Box const& box)
+    {
+        return (dir == 1  && get<Dim>(point) < get<min_corner, Dim>(box))
+            || (dir == -1 && get<Dim>(point) > get<max_corner, Dim>(box));
+    }
+
+    template <size_t Dim, typename Point, typename Box>
+    static inline bool exceeding(int dir, Point const& point, Box const& box)
+    {
+        return (dir == 1  && get<Dim>(point) > get<max_corner, Dim>(box))
+            || (dir == -1 && get<Dim>(point) < get<min_corner, Dim>(box));
+    }
+
+    template <typename Iterator, typename RangeIterator, typename Section>
+    static inline void advance_to_non_duplicate_next(Iterator& next,
+            RangeIterator const& it, Section const& section)
+    {
+        // To see where the next segments bend to, in case of touch/intersections
+        // on end points, we need (in case of degenerate/duplicate points) an extra
+        // iterator which moves to the REAL next point, so non duplicate.
+        // This needs an extra comparison (disjoint).
+        // (Note that within sections, non duplicate points are already asserted,
+        //   by the sectionalize process).
+
+        // So advance to the "non duplicate next"
+        // (the check is defensive, to avoid endless loops)
+        std::size_t check = 0;
+        while(! detail::disjoint::disjoint_point_point(*it, *next)
+            && check++ < section.range_count)
+        {
+            next++;
+        }
+    }
+
+    // It is NOT possible to have section-iterators here
+    // because of the logistics of "index" (the section-iterator automatically
+    // skips to the begin-point, we loose the index or have to recalculate it)
+    // So we mimic it here
+    template <typename Range, typename Section, typename Box>
+    static inline void get_start_point_iterator(Section & section,
+            Range const& range,
+            typename boost::range_iterator<Range const>::type& it,
+            typename boost::range_iterator<Range const>::type& prev,
+            typename boost::range_iterator<Range const>::type& end,
+            int& index, int& ndi,
+            int dir, Box const& other_bounding_box)
+    {
+        it = boost::begin(range) + section.begin_index;
+        end = boost::begin(range) + section.end_index + 1;
+
+        // Mimic section-iterator:
+        // Skip to point such that section interects other box
+        prev = it++;
+        for(; it != end && preceding<0>(dir, *it, other_bounding_box);
+            prev = it++, index++, ndi++)
+        {}
+        // Go back one step because we want to start completely preceding
+        it = prev;
+    }
+};
+
+struct get_section_box
+{
+    template <typename Box, typename InputItem>
+    static inline void apply(Box& total, InputItem const& item)
+    {
+        geometry::expand(total, item.bounding_box);
+    }
+};
+
+struct ovelaps_section_box
+{
+    template <typename Box, typename InputItem>
+    static inline bool apply(Box const& box, InputItem const& item)
+    {
+        return ! detail::disjoint::disjoint_box_box(box, item.bounding_box);
+    }
+};
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct section_visitor
+{
+    int m_source_id1;
+    Geometry1 const& m_geometry1;
+    int m_source_id2;
+    Geometry2 const& m_geometry2;
+    Turns& m_turns;
+    InterruptPolicy& m_interrupt_policy;
+
+    section_visitor(int id1, Geometry1 const& g1,
+            int id2, Geometry2 const& g2,
+            Turns& turns, InterruptPolicy& ip)
+        : m_source_id1(id1), m_geometry1(g1)
+        , m_source_id2(id2), m_geometry2(g2)
+        , m_turns(turns)
+        , m_interrupt_policy(ip)
+    {}
+
+    template <typename Section>
+    inline bool apply(Section const& sec1, Section const& sec2)
+    {
+        if (! detail::disjoint::disjoint_box_box(sec1.bounding_box, sec2.bounding_box))
+        {
+            return get_turns_in_sections
+                    <
+                        Geometry1,
+                        Geometry2,
+                        Reverse1, Reverse2,
+                        Section, Section,
+                        Turns,
+                        TurnPolicy,
+                        InterruptPolicy
+                    >::apply(
+                            m_source_id1, m_geometry1, sec1,
+                            m_source_id2, m_geometry2, sec2,
+                            false,
+                            m_turns, m_interrupt_policy);
+        }
+        return true;
+    }
+
+};
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+class get_turns_generic
+{
+
+public:
+    static inline void apply(
+            int source_id1, Geometry1 const& geometry1,
+            int source_id2, Geometry2 const& geometry2,
+            Turns& turns, InterruptPolicy& interrupt_policy)
+    {
+        // First create monotonic sections...
+        typedef typename boost::range_value<Turns>::type ip_type;
+        typedef typename ip_type::point_type point_type;
+        typedef model::box<point_type> box_type;
+        typedef typename geometry::sections<box_type, 2> sections_type;
+
+        sections_type sec1, sec2;
+
+        geometry::sectionalize<Reverse1>(geometry1, sec1, 0);
+        geometry::sectionalize<Reverse2>(geometry2, sec2, 1);
+
+        // ... and then partition them, intersecting overlapping sections in visitor method
+        section_visitor
+            <
+                Geometry1, Geometry2,
+                Reverse1, Reverse2,
+                Turns, TurnPolicy, InterruptPolicy
+            > visitor(source_id1, geometry1, source_id2, geometry2, turns, interrupt_policy);
+
+        geometry::partition
+            <
+                box_type, get_section_box, ovelaps_section_box
+            >::apply(sec1, sec2, visitor);
+    }
+};
+
+
+// Get turns for a range with a box, following Cohen-Sutherland (cs) approach
+template
+<
+    typename Range, typename Box,
+    bool ReverseRange, bool ReverseBox,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns_cs
+{
+    typedef typename boost::range_value<Turns>::type turn_info;
+    typedef typename geometry::point_type<Range>::type point_type;
+    typedef typename geometry::point_type<Box>::type box_point_type;
+
+    typedef typename closeable_view
+        <
+            Range const,
+            closure<Range>::value
+        >::type cview_type;
+
+    typedef typename reversible_view
+        <
+            cview_type const,
+            ReverseRange ? iterate_reverse : iterate_forward
+        >::type view_type;
+
+    typedef typename boost::range_iterator
+        <
+            view_type const
+        >::type iterator_type;
+
+
+    static inline void apply(
+                int source_id1, Range const& range,
+                int source_id2, Box const& box,
+                Turns& turns,
+                InterruptPolicy& interrupt_policy,
+                int multi_index = -1, int ring_index = -1)
+    {
+        if (boost::size(range) <= 1)
+        {
+            return;
+        }
+
+        boost::array<box_point_type,4> bp;
+        assign_box_corners_oriented<ReverseBox>(box, bp);
+
+        cview_type cview(range);
+        view_type view(cview);
+
+        iterator_type it = boost::begin(view);
+
+        ever_circling_iterator<iterator_type> next(
+                boost::begin(view), boost::end(view), it, true);
+        next++;
+        next++;
+
+        //bool first = true;
+
+        //char previous_side[2] = {0, 0};
+
+        int index = 0;
+
+        for (iterator_type prev = it++;
+            it != boost::end(view);
+            prev = it++, next++, index++)
+        {
+            segment_identifier seg_id(source_id1,
+                        multi_index, ring_index, index);
+
+            /*if (first)
+            {
+                previous_side[0] = get_side<0>(box, *prev);
+                previous_side[1] = get_side<1>(box, *prev);
+            }
+
+            char current_side[2];
+            current_side[0] = get_side<0>(box, *it);
+            current_side[1] = get_side<1>(box, *it);
+
+            // There can NOT be intersections if
+            // 1) EITHER the two points are lying on one side of the box (! 0 && the same)
+            // 2) OR same in Y-direction
+            // 3) OR all points are inside the box (0)
+            if (! (
+                (current_side[0] != 0 && current_side[0] == previous_side[0])
+                || (current_side[1] != 0 && current_side[1] == previous_side[1])
+                || (current_side[0] == 0
+                        && current_side[1] == 0
+                        && previous_side[0] == 0
+                        && previous_side[1] == 0)
+                  )
+                )*/
+            if (true)
+            {
+                get_turns_with_box(seg_id, source_id2,
+                        *prev, *it, *next,
+                        bp[0], bp[1], bp[2], bp[3],
+                        turns, interrupt_policy);
+                // Future performance enhancement: 
+                // return if told by the interrupt policy 
+            }
+        }
+    }
+
+private:
+    template<std::size_t Index, typename Point>
+    static inline int get_side(Box const& box, Point const& point)
+    {
+        // Inside -> 0
+        // Outside -> -1 (left/below) or 1 (right/above)
+        // On border -> -2 (left/lower) or 2 (right/upper)
+        // The only purpose of the value is to not be the same,
+        // and to denote if it is inside (0)
+
+        typename coordinate_type<Point>::type const& c = get<Index>(point);
+        typename coordinate_type<Box>::type const& left = get<min_corner, Index>(box);
+        typename coordinate_type<Box>::type const& right = get<max_corner, Index>(box);
+
+        if (geometry::math::equals(c, left)) return -2;
+        else if (geometry::math::equals(c, right)) return 2;
+        else if (c < left) return -1;
+        else if (c > right) return 1;
+        else return 0;
+    }
+
+    static inline void get_turns_with_box(segment_identifier const& seg_id, int source_id2,
+            // Points from a range:
+            point_type const& rp0,
+            point_type const& rp1,
+            point_type const& rp2,
+            // Points from the box
+            box_point_type const& bp0,
+            box_point_type const& bp1,
+            box_point_type const& bp2,
+            box_point_type const& bp3,
+            // Output
+            Turns& turns,
+            InterruptPolicy& interrupt_policy)
+    {
+        // Depending on code some relations can be left out
+
+        typedef typename boost::range_value<Turns>::type turn_info;
+
+        turn_info ti;
+        ti.operations[0].seg_id = seg_id;
+        ti.operations[0].other_id = ti.operations[1].seg_id;
+        ti.operations[1].other_id = seg_id;
+
+        ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 0);
+        TurnPolicy::apply(rp0, rp1, rp2, bp0, bp1, bp2,
+                ti, std::back_inserter(turns));
+
+        ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 1);
+        TurnPolicy::apply(rp0, rp1, rp2, bp1, bp2, bp3,
+                ti, std::back_inserter(turns));
+
+        ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 2);
+        TurnPolicy::apply(rp0, rp1, rp2, bp2, bp3, bp0,
+                ti, std::back_inserter(turns));
+
+        ti.operations[1].seg_id = segment_identifier(source_id2, -1, -1, 3);
+        TurnPolicy::apply(rp0, rp1, rp2, bp3, bp0, bp1,
+                ti, std::back_inserter(turns));
+
+        if (InterruptPolicy::enabled)
+        {
+            interrupt_policy.apply(turns);
+        }
+
+    }
+
+};
+
+
+template
+<
+    typename Polygon, typename Box,
+    bool Reverse, bool ReverseBox,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns_polygon_cs
+{
+    static inline void apply(
+            int source_id1, Polygon const& polygon,
+            int source_id2, Box const& box,
+            Turns& turns, InterruptPolicy& interrupt_policy,
+            int multi_index = -1)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef detail::get_turns::get_turns_cs
+            <
+                ring_type, Box,
+                Reverse, ReverseBox,
+                Turns,
+                TurnPolicy,
+                InterruptPolicy
+            > intersector_type;
+
+        intersector_type::apply(
+                source_id1, geometry::exterior_ring(polygon),
+                source_id2, box, turns, interrupt_policy,
+                multi_index, -1);
+
+        int i = 0;
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings);
+            ++it, ++i)
+        {
+            intersector_type::apply(
+                    source_id1, *it,
+                    source_id2, box, turns, interrupt_policy,
+                    multi_index, i);
+        }
+
+    }
+};
+
+}} // namespace detail::get_turns
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// Because this is "detail" method, and most implementations will use "generic",
+// we take the freedom to derive it from "generic".
+template
+<
+    typename GeometryTag1, typename GeometryTag2,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns
+    : detail::get_turns::get_turns_generic
+        <
+            Geometry1, Geometry2,
+            Reverse1, Reverse2,
+            Turns,
+            TurnPolicy,
+            InterruptPolicy
+        >
+{};
+
+
+template
+<
+    typename Polygon, typename Box,
+    bool ReversePolygon, bool ReverseBox,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns
+    <
+        polygon_tag, box_tag,
+        Polygon, Box,
+        ReversePolygon, ReverseBox,
+        Turns,
+        TurnPolicy,
+        InterruptPolicy
+    > : detail::get_turns::get_turns_polygon_cs
+            <
+                Polygon, Box,
+                ReversePolygon, ReverseBox,
+                Turns, TurnPolicy, InterruptPolicy
+            >
+{};
+
+
+template
+<
+    typename Ring, typename Box,
+    bool ReverseRing, bool ReverseBox,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns
+    <
+        ring_tag, box_tag,
+        Ring, Box,
+        ReverseRing, ReverseBox,
+        Turns,
+        TurnPolicy,
+        InterruptPolicy
+    > : detail::get_turns::get_turns_cs
+            <
+                Ring, Box, ReverseRing, ReverseBox,
+                Turns, TurnPolicy, InterruptPolicy
+            >
+
+{};
+
+
+template
+<
+    typename GeometryTag1, typename GeometryTag2,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns_reversed
+{
+    static inline void apply(
+            int source_id1, Geometry1 const& g1,
+            int source_id2, Geometry2 const& g2,
+            Turns& turns, InterruptPolicy& interrupt_policy)
+    {
+        get_turns
+            <
+                GeometryTag2, GeometryTag1,
+                Geometry2, Geometry1,
+                Reverse2, Reverse1,
+                Turns, TurnPolicy,
+                InterruptPolicy
+            >::apply(source_id2, g2, source_id1, g1, turns, interrupt_policy);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+/*!
+\brief \brief_calc2{turn points}
+\ingroup overlay
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Turns type of turn-container (e.g. vector of "intersection/turn point"'s)
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param turns container which will contain turn points
+\param interrupt_policy policy determining if process is stopped
+    when intersection is found
+ */
+template
+<
+    bool Reverse1, bool Reverse2,
+    typename AssignPolicy,
+    typename Geometry1,
+    typename Geometry2,
+    typename Turns,
+    typename InterruptPolicy
+>
+inline void get_turns(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            Turns& turns,
+            InterruptPolicy& interrupt_policy)
+{
+    concept::check_concepts_and_equal_dimensions<Geometry1 const, Geometry2 const>();
+
+    typedef typename strategy_intersection
+        <
+            typename cs_tag<Geometry1>::type,
+            Geometry1,
+            Geometry2,
+            typename boost::range_value<Turns>::type
+        >::segment_intersection_strategy_type segment_intersection_strategy_type;
+
+    typedef detail::overlay::get_turn_info
+        <
+            typename point_type<Geometry1>::type,
+            typename point_type<Geometry2>::type,
+            typename boost::range_value<Turns>::type,
+            AssignPolicy
+        > TurnPolicy;
+
+    boost::mpl::if_c
+        <
+            reverse_dispatch<Geometry1, Geometry2>::type::value,
+            dispatch::get_turns_reversed
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1, Geometry2,
+                Reverse1, Reverse2,
+                Turns, TurnPolicy,
+                InterruptPolicy
+            >,
+            dispatch::get_turns
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1, Geometry2,
+                Reverse1, Reverse2,
+                Turns, TurnPolicy,
+                InterruptPolicy
+            >
+        >::type::apply(
+            0, geometry1,
+            1, geometry2,
+            turns, interrupt_policy);
+}
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp b/src/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp
new file mode 100644
index 0000000..1e878ca
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/handle_tangencies.hpp
@@ -0,0 +1,672 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_TANGENCIES_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_TANGENCIES_HPP
+
+#include <algorithm>
+
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+#include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template
+<
+    typename TurnPoints,
+    typename Indexed,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2,
+    typename Strategy
+>
+struct sort_in_cluster
+{
+    inline sort_in_cluster(TurnPoints const& turn_points
+            , Geometry1 const& geometry1
+            , Geometry2 const& geometry2
+            , Strategy const& strategy)
+        : m_turn_points(turn_points)
+        , m_geometry1(geometry1)
+        , m_geometry2(geometry2)
+        , m_strategy(strategy)
+    {}
+
+private :
+
+    TurnPoints const& m_turn_points;
+    Geometry1 const& m_geometry1;
+    Geometry2 const& m_geometry2;
+    Strategy const& m_strategy;
+
+    typedef typename Indexed::type turn_operation_type;
+    typedef typename geometry::point_type<Geometry1>::type point_type;
+    typedef model::referring_segment<point_type const> segment_type;
+
+    // Determine how p/r and p/s are located.
+    template <typename P>
+    static inline void overlap_info(P const& pi, P const& pj,
+        P const& ri, P const& rj,
+        P const& si, P const& sj,
+        bool& pr_overlap, bool& ps_overlap, bool& rs_overlap)
+    {
+        // Determine how p/r and p/s are located.
+        // One of them is coming from opposite direction.
+
+        typedef strategy::intersection::relate_cartesian_segments
+            <
+                policies::relate::segments_intersection_points
+                    <
+                        segment_type,
+                        segment_type,
+                        segment_intersection_points<point_type>
+                    >
+            > policy;
+
+        segment_type p(pi, pj);
+        segment_type r(ri, rj);
+        segment_type s(si, sj);
+
+        // Get the intersection point (or two points)
+        segment_intersection_points<point_type> pr = policy::apply(p, r);
+        segment_intersection_points<point_type> ps = policy::apply(p, s);
+        segment_intersection_points<point_type> rs = policy::apply(r, s);
+
+        // Check on overlap
+        pr_overlap = pr.count == 2;
+        ps_overlap = ps.count == 2;
+        rs_overlap = rs.count == 2;
+    }
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    inline void debug_consider(int order, Indexed const& left,
+            Indexed const& right, std::string const& header,
+            bool skip = true,
+            std::string const& extra = "", bool ret = false
+        ) const
+    {
+        if (skip) return;
+
+        point_type pi, pj, ri, rj, si, sj;
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.seg_id,
+            pi, pj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.other_id,
+            ri, rj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            right.subject.other_id,
+            si, sj);
+
+        bool prc = false, psc = false, rsc = false;
+        overlap_info(pi, pj, ri, rj, si, sj, prc, psc, rsc);
+
+        int const side_ri_p = m_strategy.apply(pi, pj, ri);
+        int const side_rj_p = m_strategy.apply(pi, pj, rj);
+        int const side_si_p = m_strategy.apply(pi, pj, si);
+        int const side_sj_p = m_strategy.apply(pi, pj, sj);
+        int const side_si_r = m_strategy.apply(ri, rj, si);
+        int const side_sj_r = m_strategy.apply(ri, rj, sj);
+
+        std::cout << "Case: " << header << " for " << left.index << " / " << right.index << std::endl;
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH_MORE
+        std::cout << " Segment p:" << geometry::wkt(pi) << " .. " << geometry::wkt(pj) << std::endl;
+        std::cout << " Segment r:" << geometry::wkt(ri) << " .. " << geometry::wkt(rj) << std::endl;
+        std::cout << " Segment s:" << geometry::wkt(si) << " .. " << geometry::wkt(sj) << std::endl;
+
+        std::cout << " r//p: " << side_ri_p << " / " << side_rj_p << std::endl;
+        std::cout << " s//p: " << side_si_p << " / " << side_sj_p << std::endl;
+        std::cout << " s//r: " << side_si_r << " / " << side_sj_r << std::endl;
+#endif
+
+        std::cout << header
+                //<< " order: " << order
+                << " ops: " << operation_char(left.subject.operation)
+                    << "/" << operation_char(right.subject.operation)
+                << " ri//p: " << side_ri_p
+                << " si//p: " << side_si_p
+                << " si//r: " << side_si_r
+                << " cnts: " << int(prc) << ","  << int(psc) << "," << int(rsc)
+                //<< " idx: " << left.index << "/" << right.index
+                ;
+
+        if (! extra.empty())
+        {
+            std::cout << " " << extra << " " << (ret ? "true" : "false");
+        }
+        std::cout << std::endl;
+    }
+#else
+    inline void debug_consider(int, Indexed const& ,
+            Indexed const& , std::string const& ,
+            bool = true,
+            std::string const& = "", bool = false
+        ) const
+    {}
+#endif
+
+
+    // ux/ux
+    inline bool consider_ux_ux(Indexed const& left,
+            Indexed const& right
+            , std::string const& // header
+        ) const
+    {
+        bool ret = left.index < right.index;
+
+        // In combination of u/x, x/u: take first union, then blocked.
+        // Solves #88, #61, #56, #80
+        if (left.subject.operation == operation_union
+            && right.subject.operation == operation_blocked)
+        {
+            ret = true;
+        }
+        else if (left.subject.operation == operation_blocked
+            && right.subject.operation == operation_union)
+        {
+            ret = false;
+        }
+        else
+        {
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+            std::cout << "ux/ux unhandled" << std::endl;
+#endif
+        }
+
+        //debug_consider(0, left, right, header, false, "-> return ", ret);
+
+        return ret;
+    }
+
+    inline bool consider_iu_ux(Indexed const& left,
+            Indexed const& right,
+            int order // 1: iu first, -1: ux first
+            , std::string const& // header
+        ) const
+    {
+        bool ret = false;
+
+        if (left.subject.operation == operation_union
+            && right.subject.operation == operation_union)
+        {
+            ret = order == 1;
+        }
+        else if (left.subject.operation == operation_union
+            && right.subject.operation == operation_blocked)
+        {
+            ret = true;
+        }
+        else if (right.subject.operation == operation_union
+            && left.subject.operation == operation_blocked)
+        {
+            ret = false;
+        }
+        else if (left.subject.operation == operation_union)
+        {
+            ret = true;
+        }
+        else if (right.subject.operation == operation_union)
+        {
+            ret = false;
+        }
+        else
+        {
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+            // this still happens in the traverse.cpp test
+            std::cout << " iu/ux unhandled" << std::endl;
+#endif
+            ret = order == 1;
+        }
+
+        //debug_consider(0, left, right, header, false, "-> return", ret);
+        return ret;
+    }
+
+    inline bool consider_iu_ix(Indexed const& left,
+            Indexed const& right,
+            int order // 1: iu first, -1: ix first
+            , std::string const& // header
+        ) const
+    {
+        //debug_consider(order, left, right, header, false, "iu/ix");
+
+        return left.subject.operation == operation_intersection
+                && right.subject.operation == operation_intersection ? order == 1
+            : left.subject.operation == operation_intersection ? false
+            : right.subject.operation == operation_intersection ? true
+            : order == 1;
+    }
+
+
+    inline bool consider_iu_iu(Indexed const& left, Indexed const& right,
+                    std::string const& header) const
+    {
+        //debug_consider(0, left, right, header);
+
+        // In general, order it like "union, intersection".
+        if (left.subject.operation == operation_intersection
+            && right.subject.operation == operation_union)
+        {
+            //debug_consider(0, left, right, header, false, "i,u", false);
+            return false;
+        }
+        else if (left.subject.operation == operation_union
+            && right.subject.operation == operation_intersection)
+        {
+            //debug_consider(0, left, right, header, false, "u,i", true);
+            return true;
+        }
+
+        point_type pi, pj, ri, rj, si, sj;
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.seg_id,
+            pi, pj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.other_id,
+            ri, rj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            right.subject.other_id,
+            si, sj);
+
+        int const side_ri_p = m_strategy.apply(pi, pj, ri);
+        int const side_si_p = m_strategy.apply(pi, pj, si);
+        int const side_si_r = m_strategy.apply(ri, rj, si);
+
+        // Both located at same side (#58, pie_21_7_21_0_3)
+        if (side_ri_p * side_si_p == 1 && side_si_r != 0)
+        {
+            // Take the most left one
+            if (left.subject.operation == operation_union
+                && right.subject.operation == operation_union)
+            {
+                bool ret = side_si_r == 1;
+                //debug_consider(0, left, right, header, false, "same side", ret);
+                return ret;
+            }
+        }
+
+
+        // Coming from opposite sides (#59, #99)
+        if (side_ri_p * side_si_p == -1)
+        {
+            bool ret = false;
+
+            {
+                ret = side_ri_p == 1; // #100
+                debug_consider(0, left, right, header, false, "opp.", ret);
+                return ret;
+            }
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+            std::cout << " iu/iu coming from opposite unhandled" << std::endl;
+#endif
+        }
+
+        // We need EXTRA information here: are p/r/s overlapping?
+        bool pr_ov = false, ps_ov = false, rs_ov = false;
+        overlap_info(pi, pj, ri, rj, si, sj, pr_ov, ps_ov, rs_ov);
+
+        // One coming from right (#83,#90)
+        // One coming from left (#90, #94, #95)
+        if (side_si_r != 0 && (side_ri_p != 0 || side_si_p != 0))
+        {
+            bool ret = false;
+
+            if (pr_ov || ps_ov)
+            {
+                int r = side_ri_p != 0 ? side_ri_p : side_si_p;
+                ret = r * side_si_r == 1;
+            }
+            else
+            {
+                ret = side_si_r == 1;
+            }
+
+            debug_consider(0, left, right, header, false, "left or right", ret);
+            return ret;
+        }
+
+        // All aligned (#92, #96)
+        if (side_ri_p == 0 && side_si_p == 0 && side_si_r == 0)
+        {
+            // One of them is coming from opposite direction.
+
+            // Take the one NOT overlapping
+            bool ret = false;
+            bool found = false;
+            if (pr_ov && ! ps_ov)
+            {
+                ret = true;
+                found = true;
+            }
+            else if (!pr_ov && ps_ov)
+            {
+                ret = false;
+                found = true;
+            }
+
+            debug_consider(0, left, right, header, false, "aligned", ret);
+            if (found)
+            {
+                return ret;
+            }
+        }
+
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+        std::cout << " iu/iu unhandled" << std::endl;
+        debug_consider(0, left, right, header, false, "unhandled", left.index < right.index);
+#endif
+        return left.index < right.index;
+    }
+
+    inline bool consider_ii(Indexed const& left, Indexed const& right,
+                    std::string const& header) const
+    {
+        debug_consider(0, left, right, header);
+
+        point_type pi, pj, ri, rj, si, sj;
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.seg_id,
+            pi, pj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            left.subject.other_id,
+            ri, rj);
+        geometry::copy_segment_points<Reverse1, Reverse2>(m_geometry1, m_geometry2,
+            right.subject.other_id,
+            si, sj);
+
+        int const side_ri_p = m_strategy.apply(pi, pj, ri);
+        int const side_si_p = m_strategy.apply(pi, pj, si);
+
+        // Two other points are (mostly) lying both right of the considered segment
+        // Take the most left one
+        int const side_si_r = m_strategy.apply(ri, rj, si);
+        if (side_ri_p == -1
+            && side_si_p == -1
+            && side_si_r != 0)
+        {
+            bool const ret = side_si_r != 1;
+            return ret;
+        }
+        return left.index < right.index;
+    }
+
+
+public :
+    inline bool operator()(Indexed const& left, Indexed const& right) const
+    {
+        bool const default_order = left.index < right.index;
+
+        if ((m_turn_points[left.index].discarded || left.discarded)
+            && (m_turn_points[right.index].discarded || right.discarded))
+        {
+            return default_order;
+        }
+        else if (m_turn_points[left.index].discarded || left.discarded)
+        {
+            // Be careful to sort discarded first, then all others
+            return true;
+        }
+        else if (m_turn_points[right.index].discarded || right.discarded)
+        {
+            // See above so return false here such that right (discarded)
+            // is sorted before left (not discarded)
+            return false;
+        }
+        else if (m_turn_points[left.index].combination(operation_blocked, operation_union)
+                && m_turn_points[right.index].combination(operation_blocked, operation_union))
+        {
+            // ux/ux
+            return consider_ux_ux(left, right, "ux/ux");
+        }
+        else if (m_turn_points[left.index].both(operation_union)
+            && m_turn_points[right.index].both(operation_union))
+        {
+            // uu/uu, Order is arbitrary
+            // Note: uu/uu is discarded now before so this point will
+            //       not be reached.
+            return default_order;
+        }
+        else if (m_turn_points[left.index].combination(operation_intersection, operation_union)
+                && m_turn_points[right.index].combination(operation_intersection, operation_union))
+        {
+            return consider_iu_iu(left, right, "iu/iu");
+        }
+        else if (m_turn_points[left.index].both(operation_intersection)
+                && m_turn_points[right.index].both(operation_intersection))
+        {
+            return consider_ii(left, right, "ii/ii");
+        }
+        else  if (m_turn_points[left.index].combination(operation_union, operation_blocked)
+                && m_turn_points[right.index].combination(operation_intersection, operation_union))
+        {
+            return consider_iu_ux(left, right, -1, "ux/iu");
+        }
+        else if (m_turn_points[left.index].combination(operation_intersection, operation_union)
+                && m_turn_points[right.index].combination(operation_union, operation_blocked))
+        {
+            return consider_iu_ux(left, right, 1, "iu/ux");
+        }
+        else  if (m_turn_points[left.index].combination(operation_intersection, operation_blocked)
+                && m_turn_points[right.index].combination(operation_intersection, operation_union))
+        {
+            return consider_iu_ix(left, right, 1, "ix/iu");
+        }
+        else if (m_turn_points[left.index].combination(operation_intersection, operation_union)
+                && m_turn_points[right.index].combination(operation_intersection, operation_blocked))
+        {
+            return consider_iu_ix(left, right, -1, "iu/ix");
+        }
+        else if (m_turn_points[left.index].method != method_equal
+            && m_turn_points[right.index].method == method_equal
+            )
+        {
+            // If one of them was EQUAL or CONTINUES, it should always come first
+            return false;
+        }
+        else if (m_turn_points[left.index].method == method_equal
+            && m_turn_points[right.index].method != method_equal
+            )
+        {
+            return true;
+        }
+
+        // Now we have no clue how to sort.
+
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+        std::cout << " Consider: " << operation_char(m_turn_points[left.index].operations[0].operation)
+                << operation_char(m_turn_points[left.index].operations[1].operation)
+                << "/" << operation_char(m_turn_points[right.index].operations[0].operation)
+                << operation_char(m_turn_points[right.index].operations[1].operation)
+                << " " << " Take " << left.index << " < " << right.index
+                << std::cout;
+#endif
+
+        return default_order;
+    }
+};
+
+
+
+template
+<
+    typename IndexType,
+    typename Iterator,
+    typename TurnPoints,
+    typename Geometry1,
+    typename Geometry2,
+    typename Strategy
+>
+inline void inspect_cluster(Iterator begin_cluster, Iterator end_cluster,
+            TurnPoints& turn_points,
+            operation_type ,
+            Geometry1 const& , Geometry2 const& ,
+            Strategy const& )
+{
+    int count = 0;
+
+    // Make an analysis about all occuring cases here.
+    std::map<std::pair<operation_type, operation_type>, int> inspection;
+    for (Iterator it = begin_cluster; it != end_cluster; ++it)
+    {
+        operation_type first = turn_points[it->index].operations[0].operation;
+        operation_type second = turn_points[it->index].operations[1].operation;
+        if (first > second)
+        {
+            std::swap(first, second);
+        }
+        inspection[std::make_pair(first, second)]++;
+        count++;
+    }
+
+
+    bool keep_cc = false;
+
+    // Decide about which is going to be discarded here.
+    if (inspection[std::make_pair(operation_union, operation_union)] == 1
+        && inspection[std::make_pair(operation_continue, operation_continue)] == 1)
+    {
+        // In case of uu/cc, discard the uu, that indicates a tangency and
+        // inclusion would disturb the (e.g.) cc-cc-cc ordering
+        // NOTE: uu is now discarded anyhow.
+        keep_cc = true;
+    }
+    else if (count == 2
+        && inspection[std::make_pair(operation_intersection, operation_intersection)] == 1
+        && inspection[std::make_pair(operation_union, operation_intersection)] == 1)
+    {
+        // In case of ii/iu, discard the iu. The ii should always be visited,
+        // Because (in case of not discarding iu) correctly ordering of ii/iu appears impossible
+        for (Iterator it = begin_cluster; it != end_cluster; ++it)
+        {
+            if (turn_points[it->index].combination(operation_intersection, operation_union))
+            {
+                it->discarded = true;
+            }
+        }
+    }
+
+    // Discard any continue turn, unless it is the only thing left
+    //    (necessary to avoid cc-only rings, all being discarded
+    //    e.g. traversal case #75)
+    int nd_count= 0, cc_count = 0;
+    for (Iterator it = begin_cluster; it != end_cluster; ++it)
+    {
+        if (! it->discarded)
+        {
+            nd_count++;
+            if (turn_points[it->index].both(operation_continue))
+            {
+                cc_count++;
+            }
+        }
+    }
+
+    if (nd_count == cc_count)
+    {
+        keep_cc = true;
+    }
+
+    if (! keep_cc)
+    {
+        for (Iterator it = begin_cluster; it != end_cluster; ++it)
+        {
+            if (turn_points[it->index].both(operation_continue))
+            {
+                it->discarded = true;
+            }
+        }
+    }
+}
+
+
+template
+<
+    typename IndexType,
+    bool Reverse1, bool Reverse2,
+    typename Iterator,
+    typename TurnPoints,
+    typename Geometry1,
+    typename Geometry2,
+    typename Strategy
+>
+inline void handle_cluster(Iterator begin_cluster, Iterator end_cluster,
+            TurnPoints& turn_points,
+            operation_type for_operation,
+            Geometry1 const& geometry1, Geometry2 const& geometry2,
+            Strategy const& strategy)
+{
+    // First inspect and (possibly) discard rows
+    inspect_cluster<IndexType>(begin_cluster, end_cluster, turn_points,
+            for_operation, geometry1, geometry2, strategy);
+
+
+    // Then sort this range (discard rows will be ordered first and will be removed in enrich_assign)
+    std::sort(begin_cluster, end_cluster,
+                sort_in_cluster
+                    <
+                        TurnPoints,
+                        IndexType,
+                        Geometry1, Geometry2,
+                        Reverse1, Reverse2,
+                        Strategy
+                    >(turn_points, geometry1, geometry2, strategy));
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
+    typedef typename IndexType::type operations_type;
+    operations_type const& op = turn_points[begin_cluster->index].operations[begin_cluster->operation_index];
+    std::cout << "Clustered points on equal distance " << op.enriched.distance << std::endl;
+    std::cout << "->Indexes ";
+
+    for (Iterator it = begin_cluster; it != end_cluster; ++it)
+    {
+        std::cout << " " << it->index;
+    }
+    std::cout << std::endl << "->Methods: ";
+    for (Iterator it = begin_cluster; it != end_cluster; ++it)
+    {
+        std::cout << " " << method_char(turn_points[it->index].method);
+    }
+    std::cout << std::endl << "->Operations: ";
+    for (Iterator it = begin_cluster; it != end_cluster; ++it)
+    {
+        std::cout << " " << operation_char(turn_points[it->index].operations[0].operation)
+            << operation_char(turn_points[it->index].operations[1].operation);
+    }
+    std::cout << std::endl << "->Discarded: ";
+    for (Iterator it = begin_cluster; it != end_cluster; ++it)
+    {
+        std::cout << " " << (it->discarded ? "true" : "false");
+    }
+    std::cout << std::endl;
+        //<< "\tOn segments: "    << prev_op.seg_id  << " / "  << prev_op.other_id
+        //<< " and "  << op.seg_id << " / " << op.other_id
+        //<< geometry::distance(turn_points[prev->index].point, turn_points[it->index].point)
+#endif
+
+}
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_HANDLE_TANGENCIES_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/src/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp
new file mode 100644
index 0000000..8bca790
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp
@@ -0,0 +1,690 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_INSERT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_INSERT_HPP
+
+
+#include <cstddef>
+
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/range/metafunctions.hpp>
+
+
+#include <boost/geometry/core/is_areal.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+#include <boost/geometry/algorithms/detail/overlay/clip_linestring.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_intersection_points.hpp>
+#include <boost/geometry/algorithms/detail/overlay/overlay.hpp>
+#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
+#include <boost/geometry/algorithms/detail/overlay/follow.hpp>
+#include <boost/geometry/views/segment_view.hpp>
+
+#if defined(BOOST_GEOMETRY_DEBUG_FOLLOW)
+#include <boost/foreach.hpp>
+#endif
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace intersection
+{
+
+template
+<
+    typename Segment1, typename Segment2,
+    typename OutputIterator, typename PointOut,
+    typename Strategy
+>
+struct intersection_segment_segment_point
+{
+    static inline OutputIterator apply(Segment1 const& segment1,
+            Segment2 const& segment2, OutputIterator out,
+            Strategy const& )
+    {
+        typedef typename point_type<PointOut>::type point_type;
+
+        // Get the intersection point (or two points)
+        segment_intersection_points<point_type> is
+            = strategy::intersection::relate_cartesian_segments
+            <
+                policies::relate::segments_intersection_points
+                    <
+                        Segment1,
+                        Segment2,
+                        segment_intersection_points<point_type>
+                    >
+            >::apply(segment1, segment2);
+
+        for (std::size_t i = 0; i < is.count; i++)
+        {
+            PointOut p;
+            geometry::convert(is.intersections[i], p);
+            *out++ = p;
+        }
+        return out;
+    }
+};
+
+template
+<
+    typename Linestring1, typename Linestring2,
+    typename OutputIterator, typename PointOut,
+    typename Strategy
+>
+struct intersection_linestring_linestring_point
+{
+    static inline OutputIterator apply(Linestring1 const& linestring1,
+            Linestring2 const& linestring2, OutputIterator out,
+            Strategy const& )
+    {
+        typedef typename point_type<PointOut>::type point_type;
+
+        typedef detail::overlay::turn_info<point_type> turn_info;
+        std::deque<turn_info> turns;
+
+        geometry::get_intersection_points(linestring1, linestring2, turns);
+
+        for (typename boost::range_iterator<std::deque<turn_info> const>::type
+            it = boost::begin(turns); it != boost::end(turns); ++it)
+        {
+            PointOut p;
+            geometry::convert(it->point, p);
+            *out++ = p;
+        }
+        return out;
+    }
+};
+
+/*!
+\brief Version of linestring with an areal feature (polygon or multipolygon)
+*/
+template
+<
+    typename LineString, typename Areal,
+    bool ReverseAreal,
+    typename OutputIterator, typename LineStringOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_of_linestring_with_areal
+{
+    typedef detail::overlay::follow
+            <
+                LineStringOut,
+                LineString,
+                Areal,
+                OverlayType
+            > follower;
+
+#if defined(BOOST_GEOMETRY_DEBUG_FOLLOW)
+        template <typename Turn, typename Operation>
+        static inline void debug_follow(Turn const& turn, Operation op, 
+                    int index)
+        {
+            std::cout << index
+                << " at " << op.seg_id
+                << " meth: " << method_char(turn.method)
+                << " op: " << operation_char(op.operation)
+                << " vis: " << visited_char(op.visited)
+                << " of:  " << operation_char(turn.operations[0].operation)
+                << operation_char(turn.operations[1].operation)
+                << " " << geometry::wkt(turn.point)
+                << std::endl;
+        }
+#endif
+
+    static inline OutputIterator apply(LineString const& linestring, Areal const& areal,
+            OutputIterator out,
+            Strategy const& )
+    {
+        if (boost::size(linestring) == 0)
+        {
+            return out;
+        }
+
+        typedef typename point_type<LineStringOut>::type point_type;
+
+        typedef detail::overlay::traversal_turn_info<point_type> turn_info;
+        std::deque<turn_info> turns;
+
+        detail::get_turns::no_interrupt_policy policy;
+        geometry::get_turns
+            <
+                false,
+                (OverlayType == overlay_intersection ? ReverseAreal : !ReverseAreal),
+                detail::overlay::calculate_distance_policy
+            >(linestring, areal, turns, policy);
+
+        if (turns.empty())
+        {
+            // No intersection points, it is either completely 
+            // inside (interior + borders)
+            // or completely outside
+
+            // Use border point (on a segment) to check this
+            // (because turn points might skip some cases)
+            point_type border_point;
+            if (! geometry::point_on_border(border_point, linestring, true))
+            {
+                return out;
+            }
+
+
+            if (follower::included(border_point, areal))
+            {
+                LineStringOut copy;
+                geometry::convert(linestring, copy);
+                *out++ = copy;
+            }
+            return out;
+        }
+
+#if defined(BOOST_GEOMETRY_DEBUG_FOLLOW)
+        int index = 0;
+        BOOST_FOREACH(turn_info const& turn, turns)
+        {
+            debug_follow(turn, turn.operations[0], index++);
+        }
+#endif
+
+        return follower::apply
+                (
+                    linestring, areal,
+                    geometry::detail::overlay::operation_intersection,
+                    turns, out
+                );
+    }
+};
+
+
+}} // namespace detail::intersection
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    // tag dispatching:
+    typename TagIn1, typename TagIn2, typename TagOut,
+    // orientation
+    // metafunction finetuning helpers:
+    bool Areal1, bool Areal2, bool ArealOut,
+    // real types
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator,
+    typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPES_OR_ORIENTATIONS
+            , (types<Geometry1, Geometry2, GeometryOut>)
+        );
+};
+
+
+template
+<
+    typename TagIn1, typename TagIn2, typename TagOut,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator,
+    typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        TagIn1, TagIn2, TagOut,
+        true, true, true,
+        Geometry1, Geometry2,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::overlay::overlay
+        <Geometry1, Geometry2, Reverse1, Reverse2, ReverseOut, OutputIterator, GeometryOut, OverlayType, Strategy>
+{};
+
+
+// Any areal type with box:
+template
+<
+    typename TagIn, typename TagOut,
+    typename Geometry, typename Box,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator,
+    typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        TagIn, box_tag, TagOut,
+        true, true, true,
+        Geometry, Box,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::overlay::overlay
+        <Geometry, Box, Reverse1, Reverse2, ReverseOut, OutputIterator, GeometryOut, OverlayType, Strategy>
+{};
+
+
+template
+<
+    typename Segment1, typename Segment2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        segment_tag, segment_tag, point_tag,
+        false, false, false,
+        Segment1, Segment2,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType, Strategy
+    > : detail::intersection::intersection_segment_segment_point
+            <
+                Segment1, Segment2,
+                OutputIterator, GeometryOut,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename Linestring1, typename Linestring2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        linestring_tag, linestring_tag, point_tag,
+        false, false, false,
+        Linestring1, Linestring2,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType, Strategy
+    > : detail::intersection::intersection_linestring_linestring_point
+            <
+                Linestring1, Linestring2,
+                OutputIterator, GeometryOut,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename Linestring, typename Box,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        linestring_tag, box_tag, linestring_tag,
+        false, true, false,
+        Linestring, Box,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    >
+{
+    static inline OutputIterator apply(Linestring const& linestring,
+            Box const& box, OutputIterator out, Strategy const& )
+    {
+        typedef typename point_type<GeometryOut>::type point_type;
+        strategy::intersection::liang_barsky<Box, point_type> lb_strategy;
+        return detail::intersection::clip_range_with_box
+            <GeometryOut>(box, linestring, out, lb_strategy);
+    }
+};
+
+
+template
+<
+    typename Linestring, typename Polygon,
+    bool ReverseLinestring, bool ReversePolygon, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        linestring_tag, polygon_tag, linestring_tag,
+        false, true, false,
+        Linestring, Polygon,
+        ReverseLinestring, ReversePolygon, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_linestring_with_areal
+            <
+                Linestring, Polygon,
+                ReversePolygon,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename Linestring, typename Ring,
+    bool ReverseLinestring, bool ReverseRing, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        linestring_tag, ring_tag, linestring_tag,
+        false, true, false,
+        Linestring, Ring,
+        ReverseLinestring, ReverseRing, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_linestring_with_areal
+            <
+                Linestring, Ring,
+                ReverseRing,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+template
+<
+    typename Segment, typename Box,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        segment_tag, box_tag, linestring_tag,
+        false, true, false,
+        Segment, Box,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    >
+{
+    static inline OutputIterator apply(Segment const& segment,
+            Box const& box, OutputIterator out, Strategy const& )
+    {
+        geometry::segment_view<Segment> range(segment);
+
+        typedef typename point_type<GeometryOut>::type point_type;
+        strategy::intersection::liang_barsky<Box, point_type> lb_strategy;
+        return detail::intersection::clip_range_with_box
+            <GeometryOut>(box, range, out, lb_strategy);
+    }
+};
+
+template
+<
+    typename Tag1, typename Tag2,
+    bool Areal1, bool Areal2,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename PointOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        Tag1, Tag2, point_tag,
+        Areal1, Areal2, false,
+        Geometry1, Geometry2,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, PointOut,
+        OverlayType,
+        Strategy
+    >
+{
+    static inline OutputIterator apply(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, OutputIterator out, Strategy const& )
+    {
+
+        typedef detail::overlay::turn_info<PointOut> turn_info;
+        std::vector<turn_info> turns;
+
+        detail::get_turns::no_interrupt_policy policy;
+        geometry::get_turns
+            <
+                false, false, detail::overlay::assign_null_policy
+            >(geometry1, geometry2, turns, policy);
+        for (typename std::vector<turn_info>::const_iterator it
+            = turns.begin(); it != turns.end(); ++it)
+        {
+            *out++ = it->point;
+        }
+
+        return out;
+    }
+};
+
+
+template
+<
+    typename GeometryTag1, typename GeometryTag2, typename GeometryTag3,
+    bool Areal1, bool Areal2, bool ArealOut,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert_reversed
+{
+    static inline OutputIterator apply(Geometry1 const& g1,
+                Geometry2 const& g2, OutputIterator out,
+                Strategy const& strategy)
+    {
+        return intersection_insert
+            <
+                GeometryTag2, GeometryTag1, GeometryTag3,
+                Areal2, Areal1, ArealOut,
+                Geometry2, Geometry1,
+                Reverse2, Reverse1, ReverseOut,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >::apply(g2, g1, out, strategy);
+    }
+};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace intersection
+{
+
+
+template
+<
+    typename GeometryOut,
+    bool ReverseSecond,
+    overlay_type OverlayType,
+    typename Geometry1, typename Geometry2,
+    typename OutputIterator,
+    typename Strategy
+>
+inline OutputIterator insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out,
+            Strategy const& strategy)
+{
+    return boost::mpl::if_c
+        <
+            geometry::reverse_dispatch<Geometry1, Geometry2>::type::value,
+            geometry::dispatch::intersection_insert_reversed
+            <
+                typename geometry::tag<Geometry1>::type,
+                typename geometry::tag<Geometry2>::type,
+                typename geometry::tag<GeometryOut>::type,
+                geometry::is_areal<Geometry1>::value,
+                geometry::is_areal<Geometry2>::value,
+                geometry::is_areal<GeometryOut>::value,
+                Geometry1, Geometry2,
+                overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
+                overlay::do_reverse<geometry::point_order<Geometry2>::value, ReverseSecond>::value,
+                overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >,
+            geometry::dispatch::intersection_insert
+            <
+                typename geometry::tag<Geometry1>::type,
+                typename geometry::tag<Geometry2>::type,
+                typename geometry::tag<GeometryOut>::type,
+                geometry::is_areal<Geometry1>::value,
+                geometry::is_areal<Geometry2>::value,
+                geometry::is_areal<GeometryOut>::value,
+                Geometry1, Geometry2,
+                geometry::detail::overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
+                geometry::detail::overlay::do_reverse<geometry::point_order<Geometry2>::value, ReverseSecond>::value,
+                geometry::detail::overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+        >::type::apply(geometry1, geometry2, out, strategy);
+}
+
+
+/*!
+\brief \brief_calc2{intersection} \brief_strategy
+\ingroup intersection
+\details \details_calc2{intersection_insert, spatial set theoretic intersection}
+    \brief_strategy. \details_insert{intersection}
+\tparam GeometryOut \tparam_geometry{\p_l_or_c}
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator \tparam_out{\p_l_or_c}
+\tparam Strategy \tparam_strategy_overlay
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{intersection}
+\param strategy \param_strategy{intersection}
+\return \return_out
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/intersection.qbk]}
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator,
+    typename Strategy
+>
+inline OutputIterator intersection_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out,
+            Strategy const& strategy)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    return detail::intersection::insert
+        <
+            GeometryOut, false, overlay_intersection
+        >(geometry1, geometry2, out, strategy);
+}
+
+
+/*!
+\brief \brief_calc2{intersection}
+\ingroup intersection
+\details \details_calc2{intersection_insert, spatial set theoretic intersection}.
+    \details_insert{intersection}
+\tparam GeometryOut \tparam_geometry{\p_l_or_c}
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator \tparam_out{\p_l_or_c}
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{intersection}
+\return \return_out
+
+\qbk{[include reference/algorithms/intersection.qbk]}
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator
+>
+inline OutputIterator intersection_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    typedef strategy_intersection
+        <
+            typename cs_tag<GeometryOut>::type,
+            Geometry1,
+            Geometry2,
+            typename geometry::point_type<GeometryOut>::type
+        > strategy;
+
+    return intersection_insert<GeometryOut>(geometry1, geometry2, out,
+                strategy());
+}
+
+}} // namespace detail::intersection
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_INSERT_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/overlay.hpp b/src/boost/geometry/algorithms/detail/overlay/overlay.hpp
new file mode 100644
index 0000000..41665e0
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/overlay.hpp
@@ -0,0 +1,301 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_HPP
+
+
+#include <deque>
+#include <map>
+
+#include <boost/range.hpp>
+#include <boost/mpl/assert.hpp>
+
+
+#include <boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp>
+#include <boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp>
+#include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
+#include <boost/geometry/algorithms/detail/overlay/traverse.hpp>
+#include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+
+
+#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/algorithms/reverse.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/add_rings.hpp>
+#include <boost/geometry/algorithms/detail/overlay/assign_parents.hpp>
+#include <boost/geometry/algorithms/detail/overlay/ring_properties.hpp>
+#include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
+#  include <boost/geometry/io/dsv/write.hpp>
+#endif
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+// Skip for assemble process
+template <typename TurnInfo>
+inline bool skip(TurnInfo const& turn_info)
+{
+    return (turn_info.discarded || turn_info.both(operation_union))
+        && ! turn_info.any_blocked()
+        && ! turn_info.both(operation_intersection)
+        ;
+}
+
+
+template <typename TurnPoints, typename Map>
+inline void map_turns(Map& map, TurnPoints const& turn_points)
+{
+    typedef typename boost::range_value<TurnPoints>::type turn_point_type;
+    typedef typename turn_point_type::container_type container_type;
+
+    int index = 0;
+    for (typename boost::range_iterator<TurnPoints const>::type
+            it = boost::begin(turn_points);
+         it != boost::end(turn_points);
+         ++it, ++index)
+    {
+        if (! skip(*it))
+        {
+            int op_index = 0;
+            for (typename boost::range_iterator<container_type const>::type
+                    op_it = boost::begin(it->operations);
+                op_it != boost::end(it->operations);
+                ++op_it, ++op_index)
+            {
+                ring_identifier ring_id
+                    (
+                        op_it->seg_id.source_index,
+                        op_it->seg_id.multi_index,
+                        op_it->seg_id.ring_index
+                    );
+                map[ring_id]++;
+            }
+        }
+    }
+}
+
+
+template
+<
+    typename GeometryOut, overlay_type Direction, bool ReverseOut,
+    typename Geometry1, typename Geometry2,
+    typename OutputIterator
+>
+inline OutputIterator return_if_one_input_is_empty(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out)
+{
+    typedef std::deque
+        <
+            typename geometry::ring_type<GeometryOut>::type
+        > ring_container_type;
+
+    typedef ring_properties<typename geometry::point_type<Geometry1>::type> properties;
+
+    // Union: return either of them
+    // Intersection: return nothing
+    // Difference: return first of them
+    if (Direction == overlay_intersection
+        || (Direction == overlay_difference
+            && geometry::num_points(geometry1) == 0))
+    {
+        return out;
+    }
+
+    std::map<ring_identifier, int> empty;
+    std::map<ring_identifier, properties> all_of_one_of_them;
+
+    select_rings<Direction>(geometry1, geometry2, empty, all_of_one_of_them, false);
+    ring_container_type rings;
+    assign_parents(geometry1, geometry2, rings, all_of_one_of_them);
+    return add_rings<GeometryOut>(all_of_one_of_them, geometry1, geometry2, rings, out);
+}
+
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type Direction,
+    typename Strategy
+>
+struct overlay
+{
+    static inline OutputIterator apply(
+                Geometry1 const& geometry1, Geometry2 const& geometry2,
+                OutputIterator out,
+                Strategy const& )
+    {
+        if (geometry::num_points(geometry1) == 0
+            && geometry::num_points(geometry2) == 0)
+        {
+            return out;
+        }
+
+        if (geometry::num_points(geometry1) == 0
+            || geometry::num_points(geometry2) == 0)
+        {
+            return return_if_one_input_is_empty
+                <
+                    GeometryOut, Direction, ReverseOut
+                >(geometry1, geometry2, out);
+        }
+
+        typedef typename geometry::point_type<GeometryOut>::type point_type;
+        typedef detail::overlay::traversal_turn_info<point_type> turn_info;
+        typedef std::deque<turn_info> container_type;
+
+        typedef std::deque
+            <
+                typename geometry::ring_type<GeometryOut>::type
+            > ring_container_type;
+
+        container_type turn_points;
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        boost::timer timer;
+#endif
+
+#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
+std::cout << "get turns" << std::endl;
+#endif
+        detail::get_turns::no_interrupt_policy policy;
+        geometry::get_turns
+            <
+                Reverse1, Reverse2,
+                detail::overlay::calculate_distance_policy
+            >(geometry1, geometry2, turn_points, policy);
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "get_turns: " << timer.elapsed() << std::endl;
+#endif
+
+#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
+std::cout << "enrich" << std::endl;
+#endif
+        typename Strategy::side_strategy_type side_strategy;
+        geometry::enrich_intersection_points<Reverse1, Reverse2>(turn_points,
+                Direction == overlay_union
+                    ? geometry::detail::overlay::operation_union
+                    : geometry::detail::overlay::operation_intersection,
+                    geometry1, geometry2,
+                    side_strategy);
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "enrich_intersection_points: " << timer.elapsed() << std::endl;
+#endif
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_ASSEMBLE
+std::cout << "traverse" << std::endl;
+#endif
+        // Traverse through intersection/turn points and create rings of them.
+        // Note that these rings are always in clockwise order, even in CCW polygons,
+        // and are marked as "to be reversed" below
+        ring_container_type rings;
+        traverse<Reverse1, Reverse2, Geometry1, Geometry2>::apply
+                (
+                    geometry1, geometry2,
+                    Direction == overlay_union
+                        ? geometry::detail::overlay::operation_union
+                        : geometry::detail::overlay::operation_intersection,
+                    turn_points, rings
+                );
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "traverse: " << timer.elapsed() << std::endl;
+#endif
+
+
+        std::map<ring_identifier, int> map;
+        map_turns(map, turn_points);
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "map_turns: " << timer.elapsed() << std::endl;
+#endif
+
+        typedef ring_properties<typename geometry::point_type<GeometryOut>::type> properties;
+
+        std::map<ring_identifier, properties> selected;
+        select_rings<Direction>(geometry1, geometry2, map, selected, ! turn_points.empty());
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "select_rings: " << timer.elapsed() << std::endl;
+#endif
+
+
+        // Add rings created during traversal
+        {
+            ring_identifier id(2, 0, -1);
+            for (typename boost::range_iterator<ring_container_type>::type
+                    it = boost::begin(rings);
+                    it != boost::end(rings);
+                    ++it)
+            {
+                selected[id] = properties(*it, true);
+                selected[id].reversed = ReverseOut;
+                id.multi_index++;
+            }
+        }
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "add traversal rings: " << timer.elapsed() << std::endl;
+#endif
+
+
+        assign_parents(geometry1, geometry2, rings, selected);
+
+#ifdef BOOST_GEOMETRY_TIME_OVERLAY
+        std::cout << "assign_parents: " << timer.elapsed() << std::endl;
+#endif
+
+        return add_rings<GeometryOut>(selected, geometry1, geometry2, rings, out);
+    }
+};
+
+
+// Metafunction helper for intersection and union
+template <order_selector Selector, bool Reverse = false>
+struct do_reverse {};
+
+template <>
+struct do_reverse<clockwise, false> : boost::false_type {};
+
+template <>
+struct do_reverse<clockwise, true> : boost::true_type {};
+
+template <>
+struct do_reverse<counterclockwise, false> : boost::true_type {};
+
+template <>
+struct do_reverse<counterclockwise, true> : boost::false_type {};
+
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/overlay_type.hpp b/src/boost/geometry/algorithms/detail/overlay/overlay_type.hpp
new file mode 100644
index 0000000..af62131
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/overlay_type.hpp
@@ -0,0 +1,29 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_TYPE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_TYPE_HPP
+
+
+
+namespace boost { namespace geometry
+{
+
+enum overlay_type
+{
+    overlay_union,
+    overlay_intersection,
+    overlay_difference,
+    overlay_dissolve
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_TYPE_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/ring_properties.hpp b/src/boost/geometry/algorithms/detail/overlay/ring_properties.hpp
new file mode 100644
index 0000000..a608869
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/ring_properties.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP
+
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+template <typename Point>
+struct ring_properties
+{
+    typedef Point point_type;
+    typedef typename default_area_result<Point>::type area_type;
+
+    // Filled by "select_rings"
+    Point point;
+    area_type area;
+
+    // Filled by "update_selection_map"
+    int within_code;
+    bool reversed;
+
+    // Filled/used by "assign_rings"
+    bool discarded;
+    ring_identifier parent;
+    area_type parent_area;
+    std::vector<ring_identifier> children;
+
+    inline ring_properties()
+        : area(area_type())
+        , within_code(-1)
+        , reversed(false)
+        , discarded(false)
+        , parent_area(-1)
+    {}
+
+    template <typename RingOrBox>
+    inline ring_properties(RingOrBox const& ring_or_box, bool midpoint)
+        : within_code(-1)
+        , reversed(false)
+        , discarded(false)
+        , parent_area(-1)
+    {
+        this->area = geometry::area(ring_or_box);
+        geometry::point_on_border(this->point, ring_or_box, midpoint);
+    }
+
+    inline area_type get_area() const
+    {
+        return reversed ? -area : area;
+    }
+};
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_RING_PROPERTIES_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp b/src/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp
new file mode 100644
index 0000000..007113f
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp
@@ -0,0 +1,91 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP
+
+
+#if defined(BOOST_GEOMETRY_DEBUG_OVERLAY)
+#  define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
+#endif
+
+
+#include <vector>
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+// Internal struct to uniquely identify a segment
+// on a linestring,ring
+// or polygon (needs ring_index)
+// or multi-geometry (needs multi_index)
+struct segment_identifier
+{
+    inline segment_identifier()
+        : source_index(-1)
+        , multi_index(-1)
+        , ring_index(-1)
+        , segment_index(-1)
+    {}
+
+    inline segment_identifier(int src, int mul, int rin, int seg)
+        : source_index(src)
+        , multi_index(mul)
+        , ring_index(rin)
+        , segment_index(seg)
+    {}
+
+    inline bool operator<(segment_identifier const& other) const
+    {
+        return source_index != other.source_index ? source_index < other.source_index
+            : multi_index !=other.multi_index ? multi_index < other.multi_index
+            : ring_index != other.ring_index ? ring_index < other.ring_index
+            : segment_index < other.segment_index
+            ;
+    }
+
+    inline bool operator==(segment_identifier const& other) const
+    {
+        return source_index == other.source_index
+            && segment_index == other.segment_index
+            && ring_index == other.ring_index
+            && multi_index == other.multi_index
+            ;
+    }
+
+#if defined(BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER)
+    friend std::ostream& operator<<(std::ostream &os, segment_identifier const& seg_id)
+    {
+        std::cout
+            << "s:" << seg_id.source_index
+            << ", v:" << seg_id.segment_index // ~vertex
+            ;
+        if (seg_id.ring_index >= 0) std::cout << ", r:" << seg_id.ring_index;
+        if (seg_id.multi_index >= 0) std::cout << ", m:" << seg_id.multi_index;
+        return os;
+    }
+#endif
+
+    int source_index;
+    int multi_index;
+    int ring_index;
+    int segment_index;
+};
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SEGMENT_IDENTIFIER_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/select_rings.hpp b/src/boost/geometry/algorithms/detail/overlay/select_rings.hpp
new file mode 100644
index 0000000..f664b19
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/select_rings.hpp
@@ -0,0 +1,295 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELECT_RINGS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELECT_RINGS_HPP
+
+#include <map>
+
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+#include <boost/geometry/algorithms/detail/overlay/ring_properties.hpp>
+#include <boost/geometry/algorithms/detail/overlay/overlay_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+namespace dispatch
+{
+
+    template <typename Tag, typename Geometry>
+    struct select_rings
+    {};
+
+    template <typename Box>
+    struct select_rings<box_tag, Box>
+    {
+        template <typename Geometry, typename Map>
+        static inline void apply(Box const& box, Geometry const& , 
+                ring_identifier const& id, Map& map, bool midpoint)
+        {
+            map[id] = typename Map::mapped_type(box, midpoint);
+        }
+
+        template <typename Map>
+        static inline void apply(Box const& box, 
+                ring_identifier const& id, Map& map, bool midpoint)
+        {
+            map[id] = typename Map::mapped_type(box, midpoint);
+        }
+    };
+
+    template <typename Ring>
+    struct select_rings<ring_tag, Ring>
+    {
+        template <typename Geometry, typename Map>
+        static inline void apply(Ring const& ring, Geometry const& ,
+                    ring_identifier const& id, Map& map, bool midpoint)
+        {
+            if (boost::size(ring) > 0)
+            {
+                map[id] = typename Map::mapped_type(ring, midpoint);
+            }
+        }
+
+        template <typename Map>
+        static inline void apply(Ring const& ring, 
+                    ring_identifier const& id, Map& map, bool midpoint)
+        {
+            if (boost::size(ring) > 0)
+            {
+                map[id] = typename Map::mapped_type(ring, midpoint);
+            }
+        }
+    };
+
+
+    template <typename Polygon>
+    struct select_rings<polygon_tag, Polygon>
+    {
+        template <typename Geometry, typename Map>
+        static inline void apply(Polygon const& polygon, Geometry const& geometry,
+                    ring_identifier id, Map& map, bool midpoint)
+        {
+            typedef typename geometry::ring_type<Polygon>::type ring_type;
+            typedef select_rings<ring_tag, ring_type> per_ring;
+
+            per_ring::apply(exterior_ring(polygon), geometry, id, map, midpoint);
+
+            typename interior_return_type<Polygon const>::type rings
+                        = interior_rings(polygon);
+            for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+            {
+                id.ring_index++;
+                per_ring::apply(*it, geometry, id, map, midpoint);
+            }
+        }
+
+        template <typename Map>
+        static inline void apply(Polygon const& polygon,
+                ring_identifier id, Map& map, bool midpoint)
+        {
+            typedef typename geometry::ring_type<Polygon>::type ring_type;
+            typedef select_rings<ring_tag, ring_type> per_ring;
+
+            per_ring::apply(exterior_ring(polygon), id, map, midpoint);
+
+            typename interior_return_type<Polygon const>::type rings
+                        = interior_rings(polygon);
+            for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+            {
+                id.ring_index++;
+                per_ring::apply(*it, id, map, midpoint);
+            }
+        }
+    };
+}
+
+
+template<overlay_type OverlayType>
+struct decide
+{};
+
+template<>
+struct decide<overlay_union>
+{
+    template <typename Code>
+    static bool include(ring_identifier const& , Code const& code)
+    {
+        return code.within_code * -1 == 1;
+    }
+
+    template <typename Code>
+    static bool reversed(ring_identifier const& , Code const& )
+    {
+        return false;
+    }
+};
+
+template<>
+struct decide<overlay_difference>
+{
+    template <typename Code>
+    static bool include(ring_identifier const& id, Code const& code)
+    {
+        bool is_first = id.source_index == 0;
+        return code.within_code * -1 * (is_first ? 1 : -1) == 1;
+    }
+
+    template <typename Code>
+    static bool reversed(ring_identifier const& id, Code const& code)
+    {
+        return include(id, code) && id.source_index == 1;
+    }
+};
+
+template<>
+struct decide<overlay_intersection>
+{
+    template <typename Code>
+    static bool include(ring_identifier const& , Code const& code)
+    {
+        return code.within_code * 1 == 1;
+    }
+
+    template <typename Code>
+    static bool reversed(ring_identifier const& , Code const& )
+    {
+        return false;
+    }
+};
+
+
+template
+<
+    overlay_type OverlayType,
+    typename Geometry1, typename Geometry2,
+    typename IntersectionMap, typename SelectionMap
+>
+inline void update_selection_map(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            IntersectionMap const& intersection_map,
+            SelectionMap const& map_with_all, SelectionMap& selection_map)
+{
+    selection_map.clear();
+
+    for (typename SelectionMap::const_iterator it = boost::begin(map_with_all);
+        it != boost::end(map_with_all);
+        ++it)
+    {
+        /*
+        int union_code = it->second.within_code * -1;
+        bool is_first = it->first.source_index == 0;
+        std::cout << it->first << " " << it->second.area
+            << ": " << it->second.within_code
+            << " union: " << union_code
+            << " intersection: " << (it->second.within_code * 1)
+            << " G1-G2: " << (union_code * (is_first ? 1 : -1))
+            << " G2-G1: " << (union_code * (is_first ? -1 : 1))
+            << " -> " << (decide<OverlayType>::include(it->first, it->second) ? "INC" : "")
+            << decide<OverlayType>::reverse(it->first, it->second)
+            << std::endl;
+        */
+
+        bool found = intersection_map.find(it->first) != intersection_map.end();
+        if (! found)
+        {
+            ring_identifier const id = it->first;
+            typename SelectionMap::mapped_type properties = it->second; // Copy by value
+
+            // Calculate the "within code" (previously this was done earlier but is
+            // must efficienter here - it can be even more efficient doing it all at once,
+            // using partition, TODO)
+            // So though this is less elegant than before, it avoids many unused point-in-poly calculations
+            switch(id.source_index)
+            {
+                case 0 :
+                    properties.within_code
+                        = geometry::within(properties.point, geometry2) ? 1 : -1;
+                    break;
+                case 1 :
+                    properties.within_code
+                        = geometry::within(properties.point, geometry1) ? 1 : -1;
+                    break;
+            }
+
+            if (decide<OverlayType>::include(id, properties))
+            {
+                properties.reversed = decide<OverlayType>::reversed(id, properties);
+                selection_map[id] = properties;
+            }
+        }
+    }
+}
+
+
+/*!
+\brief The function select_rings select rings based on the overlay-type (union,intersection)
+*/
+template
+<
+    overlay_type OverlayType,
+    typename Geometry1, typename Geometry2,
+    typename IntersectionMap, typename SelectionMap
+>
+inline void select_rings(Geometry1 const& geometry1, Geometry2 const& geometry2,
+            IntersectionMap const& intersection_map, 
+            SelectionMap& selection_map, bool midpoint)
+{
+    typedef typename geometry::tag<Geometry1>::type tag1;
+    typedef typename geometry::tag<Geometry2>::type tag2;
+
+    SelectionMap map_with_all;
+    dispatch::select_rings<tag1, Geometry1>::apply(geometry1, geometry2,
+                ring_identifier(0, -1, -1), map_with_all, midpoint);
+    dispatch::select_rings<tag2, Geometry2>::apply(geometry2, geometry1,
+                ring_identifier(1, -1, -1), map_with_all, midpoint);
+
+    update_selection_map<OverlayType>(geometry1, geometry2, intersection_map,
+                map_with_all, selection_map);
+}
+
+template
+<
+    overlay_type OverlayType,
+    typename Geometry,
+    typename IntersectionMap, typename SelectionMap
+>
+inline void select_rings(Geometry const& geometry,
+            IntersectionMap const& intersection_map, 
+            SelectionMap& selection_map, bool midpoint)
+{
+    typedef typename geometry::tag<Geometry>::type tag;
+
+    SelectionMap map_with_all;
+    dispatch::select_rings<tag, Geometry>::apply(geometry, 
+                ring_identifier(0, -1, -1), map_with_all, midpoint);
+
+    update_selection_map<OverlayType>(geometry, geometry, intersection_map, 
+                map_with_all, selection_map);
+}
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELECT_RINGS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp b/src/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp
new file mode 100644
index 0000000..9c4c993
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp
@@ -0,0 +1,308 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELF_TURN_POINTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELF_TURN_POINTS_HPP
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/algorithms/detail/partition.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+
+#include <boost/geometry/geometries/box.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace self_get_turn_points
+{
+
+struct no_interrupt_policy
+{
+    static bool const enabled = false;
+    static bool const has_intersections = false;
+
+
+    template <typename Range>
+    static inline bool apply(Range const&)
+    {
+        return false;
+    }
+};
+
+
+
+
+class self_ip_exception : public geometry::exception {};
+
+template
+<
+    typename Geometry,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct self_section_visitor
+{
+    Geometry const& m_geometry;
+    Turns& m_turns;
+    InterruptPolicy& m_interrupt_policy;
+
+    inline self_section_visitor(Geometry const& g,
+            Turns& turns, InterruptPolicy& ip)
+        : m_geometry(g)
+        , m_turns(turns)
+        , m_interrupt_policy(ip)
+    {}
+
+    template <typename Section>
+    inline bool apply(Section const& sec1, Section const& sec2)
+    {
+        if (! detail::disjoint::disjoint_box_box(sec1.bounding_box, sec2.bounding_box)
+                && ! sec1.duplicate
+                && ! sec2.duplicate)
+        {
+            detail::get_turns::get_turns_in_sections
+                    <
+                        Geometry, Geometry,
+                        false, false,
+                        Section, Section,
+                        Turns, TurnPolicy,
+                        InterruptPolicy
+                    >::apply(
+                            0, m_geometry, sec1,
+                            0, m_geometry, sec2,
+                            false,
+                            m_turns, m_interrupt_policy);
+        }
+        if (m_interrupt_policy.has_intersections)
+        {
+            // TODO: we should give partition an interrupt policy.
+            // Now we throw, and catch below, to stop the partition loop.
+            throw self_ip_exception();
+        }
+        return true;
+    }
+
+};
+
+
+
+template
+<
+    typename Geometry,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns
+{
+    static inline bool apply(
+            Geometry const& geometry,
+            Turns& turns,
+            InterruptPolicy& interrupt_policy)
+    {
+        typedef model::box
+            <
+                typename geometry::point_type<Geometry>::type
+            > box_type;
+        typedef typename geometry::sections
+            <
+                box_type, 1
+            > sections_type;
+
+        sections_type sec;
+        geometry::sectionalize<false>(geometry, sec);
+
+        self_section_visitor
+            <
+                Geometry,
+                Turns, TurnPolicy, InterruptPolicy
+            > visitor(geometry, turns, interrupt_policy);
+
+        try
+        {
+            geometry::partition
+                <
+                    box_type, 
+                    detail::get_turns::get_section_box, 
+                    detail::get_turns::ovelaps_section_box
+                >::apply(sec, visitor);
+        }
+        catch(self_ip_exception const& )
+        {
+            return false;
+        }
+
+        return true;
+    }
+};
+
+
+}} // namespace detail::self_get_turn_points
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename GeometryTag,
+    typename Geometry,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct self_get_turn_points
+{
+};
+
+
+template
+<
+    typename Ring,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct self_get_turn_points
+    <
+        ring_tag, Ring,
+        Turns,
+        TurnPolicy,
+        InterruptPolicy
+    >
+    : detail::self_get_turn_points::get_turns
+        <
+            Ring,
+            Turns,
+            TurnPolicy,
+            InterruptPolicy
+        >
+{};
+
+
+template
+<
+    typename Box,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct self_get_turn_points
+    <
+        box_tag, Box,
+        Turns,
+        TurnPolicy,
+        InterruptPolicy
+    >
+{
+    static inline bool apply(
+            Box const& ,
+            Turns& ,
+            InterruptPolicy& )
+    {
+        return true;
+    }
+};
+
+
+template
+<
+    typename Polygon,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct self_get_turn_points
+    <
+        polygon_tag, Polygon,
+        Turns,
+        TurnPolicy,
+        InterruptPolicy
+    >
+    : detail::self_get_turn_points::get_turns
+        <
+            Polygon,
+            Turns,
+            TurnPolicy,
+            InterruptPolicy
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+    \brief Calculate self intersections of a geometry
+    \ingroup overlay
+    \tparam Geometry geometry type
+    \tparam Turns type of intersection container
+                (e.g. vector of "intersection/turn point"'s)
+    \param geometry geometry
+    \param turns container which will contain intersection points
+    \param interrupt_policy policy determining if process is stopped
+        when intersection is found
+ */
+template
+<
+    typename AssignPolicy,
+    typename Geometry,
+    typename Turns,
+    typename InterruptPolicy
+>
+inline void self_turns(Geometry const& geometry,
+            Turns& turns, InterruptPolicy& interrupt_policy)
+{
+    concept::check<Geometry const>();
+
+    typedef typename strategy_intersection
+        <
+            typename cs_tag<Geometry>::type,
+            Geometry,
+            Geometry,
+            typename boost::range_value<Turns>::type
+        >::segment_intersection_strategy_type strategy_type;
+
+    typedef detail::overlay::get_turn_info
+                        <
+                            typename point_type<Geometry>::type,
+                            typename point_type<Geometry>::type,
+                            typename boost::range_value<Turns>::type,
+                            detail::overlay::assign_null_policy
+                        > TurnPolicy;
+
+    dispatch::self_get_turn_points
+            <
+                typename tag<Geometry>::type,
+                Geometry,
+                Turns,
+                TurnPolicy,
+                InterruptPolicy
+            >::apply(geometry, turns, interrupt_policy);
+}
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_SELF_TURN_POINTS_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/stream_info.hpp b/src/boost/geometry/algorithms/detail/overlay/stream_info.hpp
new file mode 100644
index 0000000..eebe381
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/stream_info.hpp
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_STREAM_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_STREAM_INFO_HPP
+
+
+#include <string>
+
+#include <boost/array.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+    static inline std::string dir(int d)
+    {
+        return d == 0 ? "-" : (d == 1 ? "L" : d == -1 ? "R" : "#");
+    }
+    static inline std::string how_str(int h)
+    {
+        return h == 0 ? "-" : (h == 1 ? "A" : "D");
+    }
+
+    template <typename P>
+    std::ostream& operator<<(std::ostream &os, turn_info<P> const& info)
+    {
+        typename geometry::coordinate_type<P>::type d = info.distance;
+        os  << "\t"
+            << " src " << info.seg_id.source_index
+            << " seg " << info.seg_id.segment_index
+            << " (// " << info.other_id.source_index
+                << "." << info.other_id.segment_index << ")"
+            << " how " << info.how
+                << "[" << how_str(info.arrival)
+                << " " << dir(info.direction)
+                << (info.opposite ? " o" : "")
+                << "]"
+            << " sd "
+                << dir(info.sides.get<0,0>())
+                << dir(info.sides.get<0,1>())
+                << dir(info.sides.get<1,0>())
+                << dir(info.sides.get<1,1>())
+            << " nxt seg " << info.travels_to_vertex_index
+            << " , ip " << info.travels_to_ip_index
+            << " , or " << info.next_ip_index
+            << " dst " << double(d)
+            << info.visit_state;
+        if (info.flagged)
+        {
+            os << " FLAGGED";
+        }
+        return os;
+    }
+
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_STREAM_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/traversal_info.hpp b/src/boost/geometry/algorithms/detail/overlay/traversal_info.hpp
new file mode 100644
index 0000000..810a27a
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/traversal_info.hpp
@@ -0,0 +1,47 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSAL_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSAL_INFO_HPP
+
+
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/visit_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template <typename P>
+struct traversal_turn_operation : public turn_operation
+{
+    enrichment_info<P> enriched;
+    visit_info visited;
+};
+
+template <typename P>
+struct traversal_turn_info : public turn_info<P, traversal_turn_operation<P> >
+{};
+
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSAL_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/traverse.hpp b/src/boost/geometry/algorithms/detail/overlay/traverse.hpp
new file mode 100644
index 0000000..12daafa
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/traverse.hpp
@@ -0,0 +1,395 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
+#include <boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
+#include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#if defined(BOOST_GEOMETRY_DEBUG_INTERSECTION) \
+    || defined(BOOST_GEOMETRY_OVERLAY_REPORT_WKT) \
+    || defined(BOOST_GEOMETRY_DEBUG_TRAVERSE)
+#  include <string>
+#  include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+#  include <boost/geometry/io/wkt/wkt.hpp>
+#endif
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+template <typename Turn, typename Operation>
+#ifdef BOOST_GEOMETRY_DEBUG_TRAVERSE
+inline void debug_traverse(Turn const& turn, Operation op, 
+                std::string const& header)
+{
+    std::cout << header
+        << " at " << op.seg_id
+        << " meth: " << method_char(turn.method)
+        << " op: " << operation_char(op.operation)
+        << " vis: " << visited_char(op.visited)
+        << " of:  " << operation_char(turn.operations[0].operation)
+        << operation_char(turn.operations[1].operation)
+        << " " << geometry::wkt(turn.point)
+        << std::endl;
+
+    if (boost::contains(header, "Finished"))
+    {
+        std::cout << std::endl;
+    }
+}
+#else
+inline void debug_traverse(Turn const& , Operation, std::string const& )
+{
+}
+#endif
+
+
+template <typename Info, typename Turn>
+inline void set_visited_for_continue(Info& info, Turn const& turn)
+{
+    // On "continue", set "visited" for ALL directions
+    if (turn.operation == detail::overlay::operation_continue)
+    {
+        for (typename boost::range_iterator
+            <
+                typename Info::container_type
+            >::type it = boost::begin(info.operations);
+            it != boost::end(info.operations);
+            ++it)
+        {
+            if (it->visited.none())
+            {
+                it->visited.set_visited();
+            }
+        }
+    }
+}
+
+
+template
+<
+    bool Reverse1, bool Reverse2,
+    typename GeometryOut,
+    typename G1,
+    typename G2,
+    typename Turns,
+    typename IntersectionInfo
+>
+inline bool assign_next_ip(G1 const& g1, G2 const& g2,
+            Turns& turns,
+            typename boost::range_iterator<Turns>::type& ip,
+            GeometryOut& current_output,
+            IntersectionInfo& info,
+            segment_identifier& seg_id)
+{
+    info.visited.set_visited();
+    set_visited_for_continue(*ip, info);
+
+    // If there is no next IP on this segment
+    if (info.enriched.next_ip_index < 0)
+    {
+        if (info.enriched.travels_to_vertex_index < 0 
+            || info.enriched.travels_to_ip_index < 0)
+        {
+            return false;
+        }
+
+        BOOST_ASSERT(info.enriched.travels_to_vertex_index >= 0);
+        BOOST_ASSERT(info.enriched.travels_to_ip_index >= 0);
+
+        if (info.seg_id.source_index == 0)
+        {
+            geometry::copy_segments<Reverse1>(g1, info.seg_id,
+                    info.enriched.travels_to_vertex_index,
+                    current_output);
+        }
+        else
+        {
+            geometry::copy_segments<Reverse2>(g2, info.seg_id,
+                    info.enriched.travels_to_vertex_index,
+                    current_output);
+        }
+        seg_id = info.seg_id;
+        ip = boost::begin(turns) + info.enriched.travels_to_ip_index;
+    }
+    else
+    {
+        ip = boost::begin(turns) + info.enriched.next_ip_index;
+        seg_id = info.seg_id;
+    }
+
+    detail::overlay::append_no_duplicates(current_output, ip->point);
+    return true;
+}
+
+
+inline bool select_source(operation_type operation, int source1, int source2)
+{
+    return (operation == operation_intersection && source1 != source2)
+        || (operation == operation_union && source1 == source2)
+        ;
+}
+
+
+template
+<
+    typename Turn,
+    typename Iterator
+>
+inline bool select_next_ip(operation_type operation,
+            Turn& turn,
+            segment_identifier const& seg_id,
+            Iterator& selected)
+{
+    if (turn.discarded)
+    {
+        return false;
+    }
+    bool has_tp = false;
+    selected = boost::end(turn.operations);
+    for (Iterator it = boost::begin(turn.operations);
+        it != boost::end(turn.operations);
+        ++it)
+    {
+        if (it->visited.started())
+        {
+            selected = it;
+            //std::cout << " RETURN";
+            return true;
+        }
+
+        // In some cases there are two alternatives.
+        // For "ii", take the other one (alternate)
+        //           UNLESS the other one is already visited
+        // For "uu", take the same one (see above);
+        // For "cc", take either one, but if there is a starting one,
+        //           take that one.
+        if (   (it->operation == operation_continue
+                && (! has_tp || it->visited.started()
+                    )
+                )
+            || (it->operation == operation
+                && ! it->visited.finished()
+                && (! has_tp
+                    || select_source(operation,
+                            it->seg_id.source_index, seg_id.source_index)
+                    )
+                )
+            )
+        {
+            selected = it;
+            debug_traverse(turn, *it, " Candidate");
+            has_tp = true;
+        }
+    }
+
+    if (has_tp)
+    {
+       debug_traverse(turn, *selected, "  Accepted");
+    }
+
+
+    return has_tp;
+}
+
+
+
+/*!
+    \brief Traverses through intersection points / geometries
+    \ingroup overlay
+ */
+template
+<
+    bool Reverse1, bool Reverse2,
+    typename Geometry1,
+    typename Geometry2,
+    typename Backtrack = backtrack_check_self_intersections<Geometry1, Geometry2>
+>
+class traverse
+{
+public :
+    template <typename Turns, typename Rings>
+    static inline void apply(Geometry1 const& geometry1,
+                Geometry2 const& geometry2,
+                detail::overlay::operation_type operation,
+                Turns& turns, Rings& rings)
+    {
+        typedef typename boost::range_iterator<Turns>::type turn_iterator;
+        typedef typename boost::range_value<Turns>::type turn_type;
+        typedef typename boost::range_iterator
+            <
+                typename turn_type::container_type
+            >::type turn_operation_iterator_type;
+
+        std::size_t size_at_start = boost::size(rings);
+
+        typename Backtrack::state_type state;
+        do
+        {
+            state.reset();
+
+            // Iterate through all unvisited points
+            for (turn_iterator it = boost::begin(turns);
+                state.good() && it != boost::end(turns);
+                ++it)
+            {
+                // Skip discarded ones
+                if (! (it->is_discarded() || it->blocked()))
+                {
+                    for (turn_operation_iterator_type iit = boost::begin(it->operations);
+                        state.good() && iit != boost::end(it->operations);
+                        ++iit)
+                    {
+                        if (iit->visited.none()
+                            && ! iit->visited.rejected()
+                            && (iit->operation == operation
+                                || iit->operation == detail::overlay::operation_continue)
+                            )
+                        {
+                            set_visited_for_continue(*it, *iit);
+
+                            typename boost::range_value<Rings>::type current_output;
+                            detail::overlay::append_no_duplicates(current_output, 
+                                        it->point, true);
+
+                            turn_iterator current = it;
+                            turn_operation_iterator_type current_iit = iit;
+                            segment_identifier current_seg_id;
+
+                            if (! detail::overlay::assign_next_ip<Reverse1, Reverse2>(
+                                        geometry1, geometry2,
+                                        turns,
+                                        current, current_output,
+                                        *iit, current_seg_id))
+                            {
+                                Backtrack::apply(
+                                    size_at_start, 
+                                    rings, current_output, turns, *current_iit,
+                                    "No next IP",
+                                    geometry1, geometry2, state);
+                            }
+
+                            if (! detail::overlay::select_next_ip(
+                                            operation,
+                                            *current,
+                                            current_seg_id,
+                                            current_iit))
+                            {
+                                Backtrack::apply(
+                                    size_at_start, 
+                                    rings, current_output, turns, *iit,
+                                    "Dead end at start",
+                                    geometry1, geometry2, state);
+                            }
+                            else
+                            {
+
+                                iit->visited.set_started();
+                                detail::overlay::debug_traverse(*it, *iit, "-> Started");
+                                detail::overlay::debug_traverse(*current, *current_iit, "Selected  ");
+
+
+                                unsigned int i = 0;
+
+                                while (current_iit != iit && state.good())
+                                {
+                                    if (current_iit->visited.visited())
+                                    {
+                                        // It visits a visited node again, without passing the start node.
+                                        // This makes it suspicious for endless loops
+                                        Backtrack::apply(
+                                            size_at_start, 
+                                            rings,  current_output, turns, *iit,
+                                            "Visit again",
+                                            geometry1, geometry2, state);
+                                    }
+                                    else
+                                    {
+
+
+                                        // We assume clockwise polygons only, non self-intersecting, closed.
+                                        // However, the input might be different, and checking validity
+                                        // is up to the library user.
+
+                                        // Therefore we make here some sanity checks. If the input
+                                        // violates the assumptions, the output polygon will not be correct
+                                        // but the routine will stop and output the current polygon, and
+                                        // will continue with the next one.
+
+                                        // Below three reasons to stop.
+                                        detail::overlay::assign_next_ip<Reverse1, Reverse2>(
+                                            geometry1, geometry2,
+                                            turns, current, current_output,
+                                            *current_iit, current_seg_id);
+
+                                        if (! detail::overlay::select_next_ip(
+                                                    operation,
+                                                    *current,
+                                                    current_seg_id,
+                                                    current_iit))
+                                        {
+                                            // Should not occur in valid (non-self-intersecting) polygons
+                                            // Should not occur in self-intersecting polygons without spikes
+                                            // Might occur in polygons with spikes
+                                            Backtrack::apply(
+                                                size_at_start, 
+                                                rings,  current_output, turns, *iit,
+                                                "Dead end",
+                                                geometry1, geometry2, state);
+                                        }
+                                        detail::overlay::debug_traverse(*current, *current_iit, "Selected  ");
+
+                                        if (i++ > 2 + 2 * turns.size())
+                                        {
+                                            // Sanity check: there may be never more loops
+                                            // than turn points.
+                                            // Turn points marked as "ii" can be visited twice.
+                                            Backtrack::apply(
+                                                size_at_start, 
+                                                rings,  current_output, turns, *iit,
+                                                "Endless loop",
+                                                geometry1, geometry2, state);
+                                        }
+                                    }
+                                }
+
+                                if (state.good())
+                                {
+                                    iit->visited.set_finished();
+                                    detail::overlay::debug_traverse(*current, *iit, "->Finished");
+                                    rings.push_back(current_output);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } while (! state.good());
+    }
+};
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TRAVERSE_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/turn_info.hpp b/src/boost/geometry/algorithms/detail/overlay/turn_info.hpp
new file mode 100644
index 0000000..89a60b2
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/turn_info.hpp
@@ -0,0 +1,152 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
+
+
+#include <boost/array.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/segment_identifier.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+enum operation_type
+{
+    operation_none,
+    operation_union,
+    operation_intersection,
+    operation_blocked,
+    operation_continue,
+    operation_opposite
+};
+
+
+enum method_type
+{
+    method_none,
+    method_disjoint,
+    method_crosses,
+    method_touch,
+    method_touch_interior,
+    method_collinear,
+    method_equal,
+    method_error
+};
+
+
+/*!
+    \brief Turn operation: operation
+    \details Information necessary for traversal phase (a phase
+        of the overlay process). The information is gathered during the
+        get_turns (segment intersection) phase.
+        The class is to be included in the turn_info class, either direct
+        or a derived or similar class with more (e.g. enrichment) information.
+ */
+struct turn_operation
+{
+    operation_type operation;
+    segment_identifier seg_id;
+    segment_identifier other_id;
+
+    inline turn_operation()
+        : operation(operation_none)
+    {}
+};
+
+
+/*!
+    \brief Turn information: intersection point, method, and turn information
+    \details Information necessary for traversal phase (a phase
+        of the overlay process). The information is gathered during the
+        get_turns (segment intersection) phase.
+    \tparam Point point type of intersection point
+    \tparam Operation gives classes opportunity to add additional info
+    \tparam Container gives classes opportunity to define how operations are stored
+ */
+template
+<
+    typename Point,
+    typename Operation = turn_operation,
+    typename Container = boost::array<Operation, 2>
+>
+struct turn_info
+{
+    typedef Point point_type;
+    typedef Operation turn_operation_type;
+    typedef Container container_type;
+
+    Point point;
+    method_type method;
+    bool discarded;
+
+
+    Container operations;
+
+    inline turn_info()
+        : method(method_none)
+        , discarded(false)
+    {}
+
+    inline bool both(operation_type type) const
+    {
+        return has12(type, type);
+    }
+    
+    inline bool has(operation_type type) const
+    {
+        return this->operations[0].operation == type
+            || this->operations[1].operation == type;
+    }
+
+    inline bool combination(operation_type type1, operation_type type2) const
+    {
+        return has12(type1, type2) || has12(type2, type1);
+    }
+
+
+    inline bool is_discarded() const { return discarded; }
+    inline bool blocked() const
+    {
+        return both(operation_blocked);
+    }
+    inline bool opposite() const
+    {
+        return both(operation_opposite);
+    }
+    inline bool any_blocked() const
+    {
+        return has(operation_blocked);
+    }
+
+
+private :
+    inline bool has12(operation_type type1, operation_type type2) const
+    {
+        return this->operations[0].operation == type1
+            && this->operations[1].operation == type2
+            ;
+    }
+
+};
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/visit_info.hpp b/src/boost/geometry/algorithms/detail/overlay/visit_info.hpp
new file mode 100644
index 0000000..6be63f4
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/visit_info.hpp
@@ -0,0 +1,136 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP
+
+
+#ifdef BOOST_GEOMETRY_USE_MSM
+#  include <boost/geometry/algorithms/detail/overlay/msm_state.hpp>
+#endif
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+#if ! defined(BOOST_GEOMETRY_USE_MSM)
+
+class visit_info
+{
+private :
+    static const int NONE = 0;
+    static const int STARTED = 1;
+    static const int VISITED = 2;
+    static const int FINISHED = 3;
+    static const int REJECTED = 4;
+
+    int m_visit_code;
+    bool m_rejected;
+
+public:
+    inline visit_info()
+        : m_visit_code(0)
+        , m_rejected(false)
+    {}
+
+    inline void set_visited() { m_visit_code = VISITED; }
+    inline void set_started() { m_visit_code = STARTED; }
+    inline void set_finished() { m_visit_code = FINISHED; }
+    inline void set_rejected()
+    {
+        m_visit_code = REJECTED;
+        m_rejected = true;
+    }
+
+    inline bool none() const { return m_visit_code == NONE; }
+    inline bool visited() const { return m_visit_code == VISITED; }
+    inline bool started() const { return m_visit_code == STARTED; }
+    inline bool finished() const { return m_visit_code == FINISHED; }
+    inline bool rejected() const { return m_rejected; }
+
+    inline void clear()
+    {
+        if (! rejected())
+        {
+            m_visit_code = NONE;
+        }
+    }
+
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+    friend std::ostream& operator<<(std::ostream &os, visit_info const& v)
+    {
+        if (v.m_visit_code != 0)
+        {
+            os << " VIS: " << int(v.m_visit_code);
+        }
+        return os;
+    }
+#endif
+
+};
+
+
+#else
+
+
+class visit_info
+{
+
+private :
+
+#ifndef USE_MSM_MINI
+    mutable
+#endif
+        traverse_state state;
+
+public :
+    inline visit_info()
+    {
+        state.start();
+    }
+
+    inline void set_none() { state.process_event(none()); } // Not Yet Implemented!
+    inline void set_visited() { state.process_event(visit()); }
+    inline void set_started() { state.process_event(starting()); }
+    inline void set_finished() { state.process_event(finish()); }
+
+#ifdef USE_MSM_MINI
+    inline bool none() const { return state.flag_none(); }
+    inline bool visited() const { return state.flag_visited(); }
+    inline bool started() const { return state.flag_started(); }
+#else
+    inline bool none() const { return state.is_flag_active<is_init>(); }
+    inline bool visited() const { return state.is_flag_active<is_visited>(); }
+    inline bool started() const { return state.is_flag_active<is_started>(); }
+#endif
+
+#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
+    friend std::ostream& operator<<(std::ostream &os, visit_info const& v)
+    {
+        return os;
+    }
+#endif
+};
+#endif
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_VISIT_INFO_HPP
diff --git a/src/boost/geometry/algorithms/detail/overlay/within_util.hpp b/src/boost/geometry/algorithms/detail/overlay/within_util.hpp
new file mode 100644
index 0000000..8618b81
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/overlay/within_util.hpp
@@ -0,0 +1,98 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP
+
+
+
+#include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+
+template<typename Tag, typename Point, typename Geometry>
+struct within_code
+{};
+
+template<typename Point, typename Box>
+struct within_code<box_tag, Point, Box>
+{
+    static inline int apply(Point const& point, Box const& box)
+    {
+        // 1. Check outside
+        if (get<0>(point) < get<min_corner, 0>(box)
+            || get<0>(point) > get<max_corner, 0>(box)
+            || get<1>(point) < get<min_corner, 1>(box)
+            || get<1>(point) > get<max_corner, 1>(box))
+        {
+            return -1;
+        }
+        // 2. Check border
+        if (geometry::math::equals(get<0>(point), get<min_corner, 0>(box))
+            || geometry::math::equals(get<0>(point), get<max_corner, 0>(box))
+            || geometry::math::equals(get<1>(point), get<min_corner, 1>(box))
+            || geometry::math::equals(get<1>(point), get<max_corner, 1>(box)))
+        {
+            return 0;
+        }
+        return 1;
+    }
+};
+template<typename Point, typename Ring>
+struct within_code<ring_tag, Point, Ring>
+{
+    static inline int apply(Point const& point, Ring const& ring)
+    {
+        // Same as point_in_ring but here ALWAYS with winding.
+        typedef strategy::within::winding<Point> strategy_type;
+
+        return detail::within::point_in_ring
+            <
+                Point,
+                Ring,
+                order_as_direction<geometry::point_order<Ring>::value>::value,
+                geometry::closure<Ring>::value,
+                strategy_type
+            >::apply(point, ring, strategy_type());
+    }
+};
+
+
+template<typename Point, typename Geometry>
+inline int point_in_ring(Point const& point, Geometry const& geometry)
+{
+    return within_code<typename geometry::tag<Geometry>::type, Point, Geometry>
+        ::apply(point, geometry);
+}
+
+template<typename Point, typename Geometry>
+inline bool within_or_touch(Point const& point, Geometry const& geometry)
+{
+    return within_code<typename geometry::tag<Geometry>::type, Point, Geometry>
+        ::apply(point, geometry) >= 0;
+}
+
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP
diff --git a/src/boost/geometry/algorithms/detail/partition.hpp b/src/boost/geometry/algorithms/detail/partition.hpp
new file mode 100644
index 0000000..45ff52c
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/partition.hpp
@@ -0,0 +1,425 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP
+
+#include <vector>
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace detail { namespace partition
+{
+
+typedef std::vector<std::size_t> index_vector_type;
+
+template <int Dimension, typename Box>
+inline void divide_box(Box const& box, Box& lower_box, Box& upper_box)
+{
+    typedef typename coordinate_type<Box>::type ctype;
+
+    // Divide input box into two parts, e.g. left/right
+    ctype two = 2;
+    ctype mid = (geometry::get<min_corner, Dimension>(box)
+            + geometry::get<max_corner, Dimension>(box)) / two;
+
+    lower_box = box;
+    upper_box = box;
+    geometry::set<max_corner, Dimension>(lower_box, mid);
+    geometry::set<min_corner, Dimension>(upper_box, mid);
+}
+
+// Divide collection into three subsets: lower, upper and oversized
+// (not-fitting) 
+// (lower == left or bottom, upper == right or top)
+template <typename OverlapsPolicy, typename InputCollection, typename Box>
+static inline void divide_into_subsets(Box const& lower_box,
+        Box const& upper_box,
+        InputCollection const& collection,
+        index_vector_type const& input,
+        index_vector_type& lower,
+        index_vector_type& upper,
+        index_vector_type& exceeding)
+{
+    typedef boost::range_iterator
+        <
+            index_vector_type const
+        >::type index_iterator_type;
+
+    for(index_iterator_type it = boost::begin(input);
+        it != boost::end(input);
+        ++it)
+    {
+        bool const lower_overlapping = OverlapsPolicy::apply(lower_box,
+                    collection[*it]);
+        bool const upper_overlapping = OverlapsPolicy::apply(upper_box,
+                    collection[*it]);
+
+        if (lower_overlapping && upper_overlapping)
+        {
+            exceeding.push_back(*it);
+        }
+        else if (lower_overlapping)
+        {
+            lower.push_back(*it);
+        }
+        else if (upper_overlapping)
+        {
+            upper.push_back(*it);
+        }
+        else
+        {
+            // Is nowhere! Should not occur!
+            BOOST_ASSERT(true);
+        }
+    }
+}
+
+// Match collection with itself
+template <typename InputCollection, typename Policy>
+static inline void handle_one(InputCollection const& collection,
+        index_vector_type const& input,
+        Policy& policy)
+{
+    typedef boost::range_iterator<index_vector_type const>::type
+                index_iterator_type;
+    // Quadratic behaviour at lowest level (lowest quad, or all exceeding)
+    for(index_iterator_type it1 = boost::begin(input);
+        it1 != boost::end(input);
+        ++it1)
+    {
+        index_iterator_type it2 = it1;
+        for(++it2; it2 != boost::end(input); ++it2)
+        {
+            policy.apply(collection[*it1], collection[*it2]);
+        }
+    }
+}
+
+// Match collection 1 with collection 2
+template <typename InputCollection, typename Policy>
+static inline void handle_two(
+        InputCollection const& collection1, index_vector_type const& input1,
+        InputCollection const& collection2, index_vector_type const& input2,
+        Policy& policy)
+{
+    typedef boost::range_iterator
+        <
+            index_vector_type const
+        >::type index_iterator_type;
+
+    for(index_iterator_type it1 = boost::begin(input1);
+        it1 != boost::end(input1);
+        ++it1)
+    {
+        for(index_iterator_type it2 = boost::begin(input2);
+            it2 != boost::end(input2);
+            ++it2)
+        {
+            policy.apply(collection1[*it1], collection2[*it2]);
+        }
+    }
+}
+
+template
+<
+    int Dimension,
+    typename Box,
+    typename OverlapsPolicy,
+    typename VisitBoxPolicy
+>
+class partition_one_collection
+{
+    typedef std::vector<std::size_t> index_vector_type;
+    typedef typename coordinate_type<Box>::type ctype;
+    typedef partition_one_collection
+            <
+                1 - Dimension,
+                Box,
+                OverlapsPolicy,
+                VisitBoxPolicy
+            > sub_divide;
+
+    template <typename InputCollection, typename Policy>
+    static inline void next_level(Box const& box,
+            InputCollection const& collection,
+            index_vector_type const& input,
+            int level, std::size_t min_elements,
+            Policy& policy, VisitBoxPolicy& box_policy)
+    {
+        if (boost::size(input) > 0)
+        {
+            if (std::size_t(boost::size(input)) > min_elements && level < 100)
+            {
+                sub_divide::apply(box, collection, input, level + 1,
+                            min_elements, policy, box_policy);
+            }
+            else
+            {
+                handle_one(collection, input, policy);
+            }
+        }
+    }
+
+public :
+    template <typename InputCollection, typename Policy>
+    static inline void apply(Box const& box,
+            InputCollection const& collection,
+            index_vector_type const& input,
+            int level,
+            std::size_t min_elements,
+            Policy& policy, VisitBoxPolicy& box_policy)
+    {
+        box_policy.apply(box, level);
+
+        Box lower_box, upper_box;
+        divide_box<Dimension>(box, lower_box, upper_box);
+
+        index_vector_type lower, upper, exceeding;
+        divide_into_subsets<OverlapsPolicy>(lower_box, upper_box, collection,
+                    input, lower, upper, exceeding);
+
+        if (boost::size(exceeding) > 0)
+        {
+            // All what is not fitting a partition should be combined
+            // with each other, and with all which is fitting.
+            handle_one(collection, exceeding, policy);
+            handle_two(collection, exceeding, collection, lower, policy);
+            handle_two(collection, exceeding, collection, upper, policy);
+        }
+
+        // Recursively call operation both parts
+        next_level(lower_box, collection, lower, level, min_elements,
+                        policy, box_policy);
+        next_level(upper_box, collection, upper, level, min_elements,
+                        policy, box_policy);
+    }
+};
+
+template
+<
+    int Dimension,
+    typename Box,
+    typename OverlapsPolicy,
+    typename VisitBoxPolicy
+>
+class partition_two_collections
+{
+    typedef std::vector<std::size_t> index_vector_type;
+    typedef typename coordinate_type<Box>::type ctype;
+    typedef partition_two_collections
+            <
+                1 - Dimension,
+                Box,
+                OverlapsPolicy,
+                VisitBoxPolicy
+            > sub_divide;
+
+    template <typename InputCollection, typename Policy>
+    static inline void next_level(Box const& box,
+            InputCollection const& collection1,
+            index_vector_type const& input1,
+            InputCollection const& collection2,
+            index_vector_type const& input2,
+            int level, std::size_t min_elements,
+            Policy& policy, VisitBoxPolicy& box_policy)
+    {
+        if (boost::size(input1) > 0 && boost::size(input2) > 0)
+        {
+            if (std::size_t(boost::size(input1)) > min_elements
+                && std::size_t(boost::size(input2)) > min_elements
+                && level < 100)
+            {
+                sub_divide::apply(box, collection1, input1, collection2,
+                                input2, level + 1, min_elements,
+                                policy, box_policy);
+            }
+            else
+            {
+                box_policy.apply(box, level + 1);
+                handle_two(collection1, input1, collection2, input2, policy);
+            }
+        }
+    }
+
+public :
+    template <typename InputCollection, typename Policy>
+    static inline void apply(Box const& box,
+            InputCollection const& collection1, index_vector_type const& input1,
+            InputCollection const& collection2, index_vector_type const& input2,
+            int level,
+            std::size_t min_elements,
+            Policy& policy, VisitBoxPolicy& box_policy)
+    {
+        box_policy.apply(box, level);
+
+        Box lower_box, upper_box;
+        divide_box<Dimension>(box, lower_box, upper_box);
+
+        index_vector_type lower1, upper1, exceeding1;
+        index_vector_type lower2, upper2, exceeding2;
+        divide_into_subsets<OverlapsPolicy>(lower_box, upper_box, collection1,
+                    input1, lower1, upper1, exceeding1);
+        divide_into_subsets<OverlapsPolicy>(lower_box, upper_box, collection2,
+                    input2, lower2, upper2, exceeding2);
+
+        if (boost::size(exceeding1) > 0)
+        {
+            // All exceeding from 1 with 2:
+            handle_two(collection1, exceeding1, collection2, exceeding2,
+                        policy);
+
+            // All exceeding from 1 with lower and upper of 2:
+            handle_two(collection1, exceeding1, collection2, lower2, policy);
+            handle_two(collection1, exceeding1, collection2, upper2, policy);
+        }
+        if (boost::size(exceeding2) > 0)
+        {
+            // All exceeding from 2 with lower and upper of 1:
+            handle_two(collection1, lower1, collection2, exceeding2, policy);
+            handle_two(collection1, upper1, collection2, exceeding2, policy);
+        }
+
+        next_level(lower_box, collection1, lower1, collection2, lower2, level,
+                        min_elements, policy, box_policy);
+        next_level(upper_box, collection1, upper1, collection2, upper2, level,
+                        min_elements, policy, box_policy);
+    }
+};
+
+}} // namespace detail::partition
+
+struct visit_no_policy
+{
+    template <typename Box>
+    static inline void apply(Box const&, int )
+    {}
+};
+
+template
+<
+    typename Box,
+    typename ExpandPolicy,
+    typename OverlapsPolicy,
+    typename VisitBoxPolicy = visit_no_policy
+>
+class partition
+{
+    typedef std::vector<std::size_t> index_vector_type;
+
+    template <typename InputCollection>
+    static inline void expand_to_collection(InputCollection const& collection,
+                Box& total, index_vector_type& index_vector)
+    {
+        std::size_t index = 0;
+        for(typename boost::range_iterator<InputCollection const>::type it
+            = boost::begin(collection);
+            it != boost::end(collection);
+            ++it, ++index)
+        {
+            ExpandPolicy::apply(total, *it);
+            index_vector.push_back(index);
+        }
+    }
+
+public :
+    template <typename InputCollection, typename VisitPolicy>
+    static inline void apply(InputCollection const& collection,
+            VisitPolicy& visitor,
+            std::size_t min_elements = 16,
+            VisitBoxPolicy box_visitor = visit_no_policy()
+            )
+    {
+        if (std::size_t(boost::size(collection)) > min_elements)
+        {
+            index_vector_type index_vector;
+            Box total;
+            assign_inverse(total);
+            expand_to_collection(collection, total, index_vector);
+
+            detail::partition::partition_one_collection
+                <
+                    0, Box,
+                    OverlapsPolicy,
+                    VisitBoxPolicy
+                >::apply(total, collection, index_vector, 0, min_elements,
+                                visitor, box_visitor);
+        }
+        else
+        {
+            typedef typename boost::range_iterator
+                <
+                    InputCollection const
+                >::type iterator_type;
+            for(iterator_type it1 = boost::begin(collection);
+                it1 != boost::end(collection);
+                ++it1)
+            {
+                iterator_type it2 = it1;
+                for(++it2; it2 != boost::end(collection); ++it2)
+                {
+                    visitor.apply(*it1, *it2);
+                }
+            }
+        }
+    }
+
+    template <typename InputCollection, typename VisitPolicy>
+    static inline void apply(InputCollection const& collection1,
+                InputCollection const& collection2,
+                VisitPolicy& visitor,
+                std::size_t min_elements = 16,
+                VisitBoxPolicy box_visitor = visit_no_policy()
+                )
+    {
+        if (std::size_t(boost::size(collection1)) > min_elements
+            && std::size_t(boost::size(collection2)) > min_elements)
+        {
+            index_vector_type index_vector1, index_vector2;
+            Box total;
+            assign_inverse(total);
+            expand_to_collection(collection1, total, index_vector1);
+            expand_to_collection(collection2, total, index_vector2);
+
+            detail::partition::partition_two_collections
+                <
+                    0, Box, OverlapsPolicy, VisitBoxPolicy
+                >::apply(total,
+                    collection1, index_vector1,
+                    collection2, index_vector2,
+                    0, min_elements, visitor, box_visitor);
+        }
+        else
+        {
+            typedef typename boost::range_iterator
+                <
+                    InputCollection const
+                >::type iterator_type;
+            for(iterator_type it1 = boost::begin(collection1);
+                it1 != boost::end(collection1);
+                ++it1)
+            {
+                for(iterator_type it2 = boost::begin(collection2);
+                    it2 != boost::end(collection2);
+                    ++it2)
+                {
+                    visitor.apply(*it1, *it2);
+                }
+            }
+        }
+    }
+
+};
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_PARTITION_HPP
diff --git a/src/boost/geometry/algorithms/detail/point_on_border.hpp b/src/boost/geometry/algorithms/detail/point_on_border.hpp
new file mode 100644
index 0000000..b7e15ba
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/point_on_border.hpp
@@ -0,0 +1,246 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.Dimension. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_ON_BORDER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_ON_BORDER_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace point_on_border
+{
+
+
+template<typename Point>
+struct get_point
+{
+    static inline bool apply(Point& destination, Point const& source, bool)
+    {
+        destination = source;
+        return true;
+    }
+};
+
+template<typename Point, std::size_t Dimension, std::size_t DimensionCount>
+struct midpoint_helper
+{
+    template <typename InputPoint>
+    static inline bool apply(Point& p, InputPoint const& p1, InputPoint const& p2)
+    {
+        typename coordinate_type<Point>::type const two = 2;
+        set<Dimension>(p,
+                    (get<Dimension>(p1) + get<Dimension>(p2)) / two);
+        return midpoint_helper<Point, Dimension + 1, DimensionCount>::apply(p, p1, p2);
+    }
+};
+
+
+template <typename Point, std::size_t DimensionCount>
+struct midpoint_helper<Point, DimensionCount, DimensionCount>
+{
+    template <typename InputPoint>
+    static inline bool apply(Point& , InputPoint const& , InputPoint const& )
+    {
+        return true;
+    }
+};
+
+
+template<typename Point, typename Range>
+struct point_on_range
+{
+    static inline bool apply(Point& point, Range const& range, bool midpoint)
+    {
+        const std::size_t n = boost::size(range);
+        if (midpoint && n > 1)
+        {
+            typedef typename boost::range_iterator
+                <
+                    Range const
+                >::type iterator;
+
+            iterator it = boost::begin(range);
+            iterator prev = it++;
+            while (it != boost::end(range)
+                && detail::equals::equals_point_point(*it, *prev))
+            {
+                prev = it++;
+            }
+            if (it != boost::end(range))
+            {
+                return midpoint_helper
+                    <
+                        Point,
+                        0, dimension<Point>::value
+                    >::apply(point, *prev, *it);
+            }
+        }
+
+        if (n > 0)
+        {
+            geometry::detail::conversion::convert_point_to_point(*boost::begin(range), point);
+            return true;
+        }
+        return false;
+    }
+};
+
+
+template<typename Point, typename Polygon>
+struct point_on_polygon
+{
+    static inline bool apply(Point& point, Polygon const& polygon, bool midpoint)
+    {
+        return point_on_range
+            <
+                Point,
+                typename ring_type<Polygon>::type
+            >::apply(point, exterior_ring(polygon), midpoint);
+    }
+};
+
+
+template<typename Point, typename Box>
+struct point_on_box
+{
+    static inline bool apply(Point& point, Box const& box, bool midpoint)
+    {
+        if (midpoint)
+        {
+            Point p1, p2;
+            detail::assign::assign_box_2d_corner<min_corner, min_corner>(box, p1);
+            detail::assign::assign_box_2d_corner<max_corner, min_corner>(box, p2);
+            midpoint_helper
+                <
+                    Point,
+                    0, dimension<Point>::value
+                >::apply(point, p1, p2);
+        }
+        else
+        {
+            detail::assign::assign_box_2d_corner<min_corner, min_corner>(box, point);
+        }
+
+        return true;
+    }
+};
+
+
+}} // namespace detail::point_on_border
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename GeometryTag,
+    typename Point,
+    typename Geometry
+
+>
+struct point_on_border
+{};
+
+
+template<typename Point>
+struct point_on_border<point_tag, Point, Point>
+    : detail::point_on_border::get_point<Point>
+{};
+
+
+template<typename Point, typename Linestring>
+struct point_on_border<linestring_tag, Point, Linestring>
+    : detail::point_on_border::point_on_range<Point, Linestring>
+{};
+
+
+template<typename Point, typename Ring>
+struct point_on_border<ring_tag, Point, Ring>
+    : detail::point_on_border::point_on_range<Point, Ring>
+{};
+
+
+template<typename Point, typename Polygon>
+struct point_on_border<polygon_tag, Point, Polygon>
+    : detail::point_on_border::point_on_polygon<Point, Polygon>
+{};
+
+
+template<typename Point, typename Box>
+struct point_on_border<box_tag, Point, Box>
+    : detail::point_on_border::point_on_box<Point, Box>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Take point on a border
+\ingroup overlay
+\tparam Geometry geometry type. This also defines the type of the output point
+\param point to assign
+\param geometry geometry to take point from
+\param midpoint boolean flag, true if the point should not be a vertex, but some point
+    in between of two vertices
+\return TRUE if successful, else false.
+    It is only false if polygon/line have no points
+\note for a polygon, it is always a point on the exterior ring
+\note for take_midpoint, it is not taken from two consecutive duplicate vertices,
+    (unless there are no other).
+ */
+template <typename Point, typename Geometry>
+inline bool point_on_border(Point& point,
+            Geometry const& geometry,
+            bool midpoint = false)
+{
+    concept::check<Point>();
+    concept::check<Geometry const>();
+
+    typedef typename point_type<Geometry>::type point_type;
+
+    return dispatch::point_on_border
+            <
+                typename tag<Geometry>::type,
+                Point,
+                Geometry
+            >::apply(point, geometry, midpoint);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_POINT_ON_BORDER_HPP
diff --git a/src/boost/geometry/algorithms/detail/ring_identifier.hpp b/src/boost/geometry/algorithms/detail/ring_identifier.hpp
new file mode 100644
index 0000000..9209ee0
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/ring_identifier.hpp
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
+
+
+namespace boost { namespace geometry
+{
+
+
+// Ring Identifier. It is currently: source,multi,ring
+struct ring_identifier
+{
+
+    inline ring_identifier()
+        : source_index(-1)
+        , multi_index(-1)
+        , ring_index(-1)
+    {}
+
+    inline ring_identifier(int src, int mul, int rin)
+        : source_index(src)
+        , multi_index(mul)
+        , ring_index(rin)
+    {}
+
+    inline bool operator<(ring_identifier const& other) const
+    {
+        return source_index != other.source_index ? source_index < other.source_index
+            : multi_index !=other.multi_index ? multi_index < other.multi_index
+            : ring_index < other.ring_index
+            ;
+    }
+
+    inline bool operator==(ring_identifier const& other) const
+    {
+        return source_index == other.source_index
+            && ring_index == other.ring_index
+            && multi_index == other.multi_index
+            ;
+    }
+
+#if defined(BOOST_GEOMETRY_DEBUG_IDENTIFIER)
+    friend std::ostream& operator<<(std::ostream &os, ring_identifier const& ring_id)
+    {
+        os << "(s:" << ring_id.source_index;
+        if (ring_id.ring_index >= 0) os << ", r:" << ring_id.ring_index;
+        if (ring_id.multi_index >= 0) os << ", m:" << ring_id.multi_index;
+        os << ")";
+        return os;
+    }
+#endif
+
+
+    int source_index;
+    int multi_index;
+    int ring_index;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RING_IDENTIFIER_HPP
diff --git a/src/boost/geometry/algorithms/detail/sections/range_by_section.hpp b/src/boost/geometry/algorithms/detail/sections/range_by_section.hpp
new file mode 100644
index 0000000..ad62f23
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/sections/range_by_section.hpp
@@ -0,0 +1,131 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace section
+{
+
+
+template <typename Range, typename Section>
+struct full_section_range
+{
+    static inline Range const& apply(Range const& range, Section const& )
+    {
+        return range;
+    }
+};
+
+
+template <typename Polygon, typename Section>
+struct full_section_polygon
+{
+    static inline typename ring_return_type<Polygon const>::type apply(Polygon const& polygon, Section const& section)
+    {
+        return section.ring_id.ring_index < 0
+            ? geometry::exterior_ring(polygon)
+            : geometry::interior_rings(polygon)[section.ring_id.ring_index];
+    }
+};
+
+
+}} // namespace detail::section
+#endif
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename Section
+>
+struct range_by_section
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename LineString, typename Section>
+struct range_by_section<linestring_tag, LineString, Section>
+    : detail::section::full_section_range<LineString, Section>
+{};
+
+
+template <typename Ring, typename Section>
+struct range_by_section<ring_tag, Ring, Section>
+    : detail::section::full_section_range<Ring, Section>
+{};
+
+
+template <typename Polygon, typename Section>
+struct range_by_section<polygon_tag, Polygon, Section>
+    : detail::section::full_section_polygon<Polygon, Section>
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+    \brief Get full ring (exterior, one of interiors, one from multi)
+        indicated by the specified section
+    \ingroup sectionalize
+    \tparam Geometry type
+    \tparam Section type of section to get from
+    \param geometry geometry to take section of
+    \param section structure with section
+ */
+template <typename Geometry, typename Section>
+inline typename ring_return_type<Geometry const>::type
+            range_by_section(Geometry const& geometry, Section const& section)
+{
+    concept::check<Geometry const>();
+
+    return dispatch::range_by_section
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Section
+        >::apply(geometry, section);
+}
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
diff --git a/src/boost/geometry/algorithms/detail/sections/sectionalize.hpp b/src/boost/geometry/algorithms/detail/sections/sectionalize.hpp
new file mode 100644
index 0000000..a6e6837
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/sections/sectionalize.hpp
@@ -0,0 +1,648 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_SECTIONALIZE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_SECTIONALIZE_HPP
+
+#include <cstddef>
+#include <vector>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+
+#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/point_order.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+    \brief Structure containing section information
+    \details Section information consists of a bounding box, direction
+        information (if it is increasing or decreasing, per dimension),
+        index information (begin-end, ring, multi) and the number of
+        segments in this section
+
+    \tparam Box box-type
+    \tparam DimensionCount number of dimensions for this section
+    \ingroup sectionalize
+ */
+template <typename Box, std::size_t DimensionCount>
+struct section
+{
+    typedef Box box_type;
+
+    int id; // might be obsolete now, BSG 14-03-2011 TODO decide about this
+
+    int directions[DimensionCount];
+    ring_identifier ring_id;
+    Box bounding_box;
+
+    int begin_index;
+    int end_index;
+    std::size_t count;
+    std::size_t range_count;
+    bool duplicate;
+    int non_duplicate_index;
+
+    inline section()
+        : id(-1)
+        , begin_index(-1)
+        , end_index(-1)
+        , count(0)
+        , range_count(0)
+        , duplicate(false)
+        , non_duplicate_index(-1)
+    {
+        assign_inverse(bounding_box);
+        for (register std::size_t i = 0; i < DimensionCount; i++)
+        {
+            directions[i] = 0;
+        }
+    }
+};
+
+
+/*!
+    \brief Structure containing a collection of sections
+    \note Derived from a vector, proves to be faster than of deque
+    \note vector might be templated in the future
+    \ingroup sectionalize
+ */
+template <typename Box, std::size_t DimensionCount>
+struct sections : std::vector<section<Box, DimensionCount> >
+{
+    typedef Box box_type;
+    static std::size_t const value = DimensionCount;
+};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace sectionalize
+{
+
+template <typename Segment, std::size_t Dimension, std::size_t DimensionCount>
+struct get_direction_loop
+{
+    typedef typename coordinate_type<Segment>::type coordinate_type;
+
+    static inline void apply(Segment const& seg,
+                int directions[DimensionCount])
+    {
+        coordinate_type const diff =
+            geometry::get<1, Dimension>(seg) - geometry::get<0, Dimension>(seg);
+
+        coordinate_type zero = coordinate_type();
+        directions[Dimension] = diff > zero ? 1 : diff < zero ? -1 : 0;
+
+        get_direction_loop
+            <
+                Segment, Dimension + 1, DimensionCount
+            >::apply(seg, directions);
+    }
+};
+
+template <typename Segment, std::size_t DimensionCount>
+struct get_direction_loop<Segment, DimensionCount, DimensionCount>
+{
+    static inline void apply(Segment const&, int [DimensionCount])
+    {}
+};
+
+template <typename T, std::size_t Dimension, std::size_t DimensionCount>
+struct copy_loop
+{
+    static inline void apply(T const source[DimensionCount],
+                T target[DimensionCount])
+    {
+        target[Dimension] = source[Dimension];
+        copy_loop<T, Dimension + 1, DimensionCount>::apply(source, target);
+    }
+};
+
+template <typename T, std::size_t DimensionCount>
+struct copy_loop<T, DimensionCount, DimensionCount>
+{
+    static inline void apply(T const [DimensionCount], T [DimensionCount])
+    {}
+};
+
+template <typename T, std::size_t Dimension, std::size_t DimensionCount>
+struct compare_loop
+{
+    static inline bool apply(T const source[DimensionCount],
+                T const target[DimensionCount])
+    {
+        bool const not_equal = target[Dimension] != source[Dimension];
+
+        return not_equal
+            ? false
+            : compare_loop
+                <
+                    T, Dimension + 1, DimensionCount
+                >::apply(source, target);
+    }
+};
+
+template <typename T, std::size_t DimensionCount>
+struct compare_loop<T, DimensionCount, DimensionCount>
+{
+    static inline bool apply(T const [DimensionCount],
+                T const [DimensionCount])
+    {
+
+        return true;
+    }
+};
+
+
+template <typename Segment, std::size_t Dimension, std::size_t DimensionCount>
+struct check_duplicate_loop
+{
+    typedef typename coordinate_type<Segment>::type coordinate_type;
+
+    static inline bool apply(Segment const& seg)
+    {
+        if (! geometry::math::equals
+                (
+                    geometry::get<0, Dimension>(seg), 
+                    geometry::get<1, Dimension>(seg)
+                )
+            )
+        {
+            return false;
+        }
+
+        return check_duplicate_loop
+            <
+                Segment, Dimension + 1, DimensionCount
+            >::apply(seg);
+    }
+};
+
+template <typename Segment, std::size_t DimensionCount>
+struct check_duplicate_loop<Segment, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Segment const&)
+    {
+        return true;
+    }
+};
+
+template <typename T, std::size_t Dimension, std::size_t DimensionCount>
+struct assign_loop
+{
+    static inline void apply(T dims[DimensionCount], int const value)
+    {
+        dims[Dimension] = value;
+        assign_loop<T, Dimension + 1, DimensionCount>::apply(dims, value);
+    }
+};
+
+template <typename T, std::size_t DimensionCount>
+struct assign_loop<T, DimensionCount, DimensionCount>
+{
+    static inline void apply(T [DimensionCount], int const)
+    {
+    }
+};
+
+/// @brief Helper class to create sections of a part of a range, on the fly
+template
+<
+    typename Range,  // Can be closeable_view
+    typename Point,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize_part
+{
+    typedef model::referring_segment<Point const> segment_type;
+    typedef typename boost::range_value<Sections>::type section_type;
+
+    typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+    static inline void apply(Sections& sections, section_type& section,
+                int& index, int& ndi,
+                Range const& range,
+                ring_identifier ring_id)
+    {
+        if (int(boost::size(range)) <= index)
+        {
+            return;
+        }
+
+        if (index == 0)
+        {
+            ndi = 0;
+        }
+
+        iterator_type it = boost::begin(range);
+        it += index;
+
+        for(iterator_type previous = it++;
+            it != boost::end(range);
+            ++previous, ++it, index++)
+        {
+            segment_type segment(*previous, *it);
+
+            int direction_classes[DimensionCount] = {0};
+            get_direction_loop
+                <
+                    segment_type, 0, DimensionCount
+                >::apply(segment, direction_classes);
+
+            // if "dir" == 0 for all point-dimensions, it is duplicate.
+            // Those sections might be omitted, if wished, lateron
+            bool duplicate = false;
+
+            if (direction_classes[0] == 0)
+            {
+                // Recheck because ALL dimensions should be checked,
+                // not only first one.
+                // (DimensionCount might be < dimension<P>::value)
+                if (check_duplicate_loop
+                    <
+                        segment_type, 0, geometry::dimension<Point>::type::value
+                    >::apply(segment)
+                    )
+                {
+                    duplicate = true;
+
+                    // Change direction-info to force new section
+                    // Note that wo consecutive duplicate segments will generate
+                    // only one duplicate-section.
+                    // Actual value is not important as long as it is not -1,0,1
+                    assign_loop
+                    <
+                        int, 0, DimensionCount
+                    >::apply(direction_classes, -99);
+                }
+            }
+
+            if (section.count > 0
+                && (!compare_loop
+                        <
+                            int, 0, DimensionCount
+                        >::apply(direction_classes, section.directions)
+                    || section.count > MaxCount
+                    )
+                )
+            {
+                sections.push_back(section);
+                section = section_type();
+            }
+
+            if (section.count == 0)
+            {
+                section.begin_index = index;
+                section.ring_id = ring_id;
+                section.duplicate = duplicate;
+                section.non_duplicate_index = ndi;
+                section.range_count = boost::size(range);
+
+                copy_loop
+                    <
+                        int, 0, DimensionCount
+                    >::apply(direction_classes, section.directions);
+                geometry::expand(section.bounding_box, *previous);
+            }
+
+            geometry::expand(section.bounding_box, *it);
+            section.end_index = index + 1;
+            section.count++;
+            if (! duplicate)
+            {
+                ndi++;
+            }
+        }
+    }
+};
+
+
+template
+<
+    typename Range, closure_selector Closure, bool Reverse,
+    typename Point,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize_range
+{
+    typedef typename closeable_view<Range const, Closure>::type cview_type;
+    typedef typename reversible_view
+        <
+            cview_type const,
+            Reverse ? iterate_reverse : iterate_forward
+        >::type view_type;
+
+    static inline void apply(Range const& range, Sections& sections,
+                ring_identifier ring_id)
+    {
+        typedef model::referring_segment<Point const> segment_type;
+
+        cview_type cview(range);
+        view_type view(cview);
+
+        std::size_t const n = boost::size(view);
+        if (n == 0)
+        {
+            // Zero points, no section
+            return;
+        }
+
+        if (n == 1)
+        {
+            // Line with one point ==> no sections
+            return;
+        }
+
+        int index = 0;
+        int ndi = 0; // non duplicate index
+
+        typedef typename boost::range_value<Sections>::type section_type;
+        section_type section;
+
+        sectionalize_part
+            <
+                view_type, Point, Sections,
+                DimensionCount, MaxCount
+            >::apply(sections, section, index, ndi,
+                        view, ring_id);
+
+        // Add last section if applicable
+        if (section.count > 0)
+        {
+            sections.push_back(section);
+        }
+    }
+};
+
+template
+<
+    typename Polygon,
+    bool Reverse,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize_polygon
+{
+    static inline void apply(Polygon const& poly, Sections& sections,
+                ring_identifier ring_id)
+    {
+        typedef typename point_type<Polygon>::type point_type;
+        typedef typename ring_type<Polygon>::type ring_type;
+        typedef sectionalize_range
+            <
+                ring_type, closure<Polygon>::value, Reverse,
+                point_type, Sections, DimensionCount, MaxCount
+            > sectionalizer_type;
+
+        ring_id.ring_index = -1;
+        sectionalizer_type::apply(exterior_ring(poly), sections, ring_id);//-1, multi_index);
+
+        ring_id.ring_index++;
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings);
+             ++it, ++ring_id.ring_index)
+        {
+            sectionalizer_type::apply(*it, sections, ring_id);
+        }
+    }
+};
+
+template
+<
+    typename Box,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize_box
+{
+    static inline void apply(Box const& box, Sections& sections, ring_identifier const& ring_id)
+    {
+        typedef typename point_type<Box>::type point_type;
+
+        assert_dimension<Box, 2>();
+
+        // Add all four sides of the 2D-box as separate section.
+        // Easiest is to convert it to a polygon.
+        // However, we don't have the polygon type
+        // (or polygon would be a helper-type).
+        // Therefore we mimic a linestring/std::vector of 5 points
+
+        // TODO: might be replaced by assign_box_corners_oriented 
+        // or just "convert"
+        point_type ll, lr, ul, ur;
+        geometry::detail::assign_box_corners(box, ll, lr, ul, ur);
+
+        std::vector<point_type> points;
+        points.push_back(ll);
+        points.push_back(ul);
+        points.push_back(ur);
+        points.push_back(lr);
+        points.push_back(ll);
+
+        sectionalize_range
+            <
+                std::vector<point_type>, closed, false,
+                point_type,
+                Sections,
+                DimensionCount,
+                MaxCount
+            >::apply(points, sections, ring_id);
+    }
+};
+
+template <typename Sections>
+inline void set_section_unique_ids(Sections& sections)
+{
+    // Set ID's.
+    int index = 0;
+    for (typename boost::range_iterator<Sections>::type it = boost::begin(sections);
+        it != boost::end(sections);
+        ++it)
+    {
+        it->id = index++;
+    }
+}
+
+
+}} // namespace detail::sectionalize
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    bool Reverse,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template
+<
+    typename Box,
+    bool Reverse,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize<box_tag, Box, Reverse, Sections, DimensionCount, MaxCount>
+    : detail::sectionalize::sectionalize_box
+        <
+            Box,
+            Sections,
+            DimensionCount,
+            MaxCount
+        >
+{};
+
+template
+<
+    typename LineString,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize
+    <
+        linestring_tag,
+        LineString,
+        false,
+        Sections,
+        DimensionCount,
+        MaxCount
+    >
+    : detail::sectionalize::sectionalize_range
+        <
+            LineString, closed, false,
+            typename point_type<LineString>::type,
+            Sections,
+            DimensionCount,
+            MaxCount
+        >
+{};
+
+template
+<
+    typename Ring,
+    bool Reverse,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize<ring_tag, Ring, Reverse, Sections, DimensionCount, MaxCount>
+    : detail::sectionalize::sectionalize_range
+        <
+            Ring, geometry::closure<Ring>::value, Reverse,
+            typename point_type<Ring>::type,
+            Sections,
+            DimensionCount,
+            MaxCount
+        >
+{};
+
+template
+<
+    typename Polygon,
+    bool Reverse,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize<polygon_tag, Polygon, Reverse, Sections, DimensionCount, MaxCount>
+    : detail::sectionalize::sectionalize_polygon
+        <
+            Polygon, Reverse, Sections, DimensionCount, MaxCount
+        >
+{};
+
+} // namespace dispatch
+#endif
+
+
+/*!
+    \brief Split a geometry into monotonic sections
+    \ingroup sectionalize
+    \tparam Geometry type of geometry to check
+    \tparam Sections type of sections to create
+    \param geometry geometry to create sections from
+    \param sections structure with sections
+    \param source_index index to assign to the ring_identifiers
+ */
+template<bool Reverse, typename Geometry, typename Sections>
+inline void sectionalize(Geometry const& geometry, Sections& sections, int source_index = 0)
+{
+    concept::check<Geometry const>();
+
+    // TODO: review use of this constant (see below) as causing problems with GCC 4.6 --mloskot
+    // A maximum of 10 segments per section seems to give the fastest results
+    //static std::size_t const max_segments_per_section = 10;
+    typedef dispatch::sectionalize
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Reverse,
+            Sections,
+            Sections::value,
+            10 // TODO: max_segments_per_section
+        > sectionalizer_type;
+
+    sections.clear();
+    ring_identifier ring_id;
+    ring_id.source_index = source_index;
+    sectionalizer_type::apply(geometry, sections, ring_id);
+    detail::sectionalize::set_section_unique_ids(sections);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_SECTIONALIZE_HPP
diff --git a/src/boost/geometry/algorithms/detail/throw_on_empty_input.hpp b/src/boost/geometry/algorithms/detail/throw_on_empty_input.hpp
new file mode 100644
index 0000000..62328a0
--- /dev/null
+++ b/src/boost/geometry/algorithms/detail/throw_on_empty_input.hpp
@@ -0,0 +1,53 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
+
+#include <boost/geometry/core/exception.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+
+// BSG 2012-02-06: we use this currently only for distance.
+// For other scalar results area,length,perimeter it is commented on purpose.
+// Reason is that for distance there is no other choice. distance of two 
+// empty geometries (or one empty) should NOT return any value.
+// But for area it is no problem to be 0.
+// Suppose: area(intersection(a,b)). We (probably) don't want a throw there...
+
+// So decided that at least for Boost 1.49 this is commented for
+// scalar results, except distance.
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Geometry>
+inline void throw_on_empty_input(Geometry const& geometry)
+{
+#if ! defined(BOOST_GEOMETRY_EMPTY_INPUT_NO_THROW)
+    if (geometry::num_points(geometry) == 0)
+    {
+        throw empty_input_exception();
+    }
+#endif
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_THROW_ON_EMPTY_INPUT_HPP
+
diff --git a/src/boost/geometry/algorithms/difference.hpp b/src/boost/geometry/algorithms/difference.hpp
new file mode 100644
index 0000000..480dd92
--- /dev/null
+++ b/src/boost/geometry/algorithms/difference.hpp
@@ -0,0 +1,160 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
+
+#include <algorithm>
+
+#include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace difference
+{
+
+/*!
+\brief_calc2{difference} \brief_strategy
+\ingroup difference
+\details \details_calc2{difference_insert, spatial set theoretic difference}
+    \brief_strategy. \details_inserter{difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator output iterator
+\tparam Strategy \tparam_strategy_overlay
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\param strategy \param_strategy{difference}
+\return \return_out
+
+\qbk{distinguish,with strategy}
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator,
+    typename Strategy
+>
+inline OutputIterator difference_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, OutputIterator out,
+            Strategy const& strategy)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    concept::check<GeometryOut>();
+    
+    return geometry::dispatch::intersection_insert
+        <
+            typename geometry::tag<Geometry1>::type,
+            typename geometry::tag<Geometry2>::type,
+            typename geometry::tag<GeometryOut>::type,
+            geometry::is_areal<Geometry1>::value,
+            geometry::is_areal<Geometry2>::value,
+            geometry::is_areal<GeometryOut>::value,
+            Geometry1, Geometry2,
+            geometry::detail::overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
+            geometry::detail::overlay::do_reverse<geometry::point_order<Geometry2>::value, true>::value,
+            geometry::detail::overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+            OutputIterator, GeometryOut,
+            overlay_difference,
+            Strategy
+        >::apply(geometry1, geometry2, out, strategy);
+}
+
+/*!
+\brief_calc2{difference}
+\ingroup difference
+\details \details_calc2{difference_insert, spatial set theoretic difference}.
+    \details_insert{difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator output iterator
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\return \return_out
+
+\qbk{[include reference/algorithms/difference_insert.qbk]}
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator
+>
+inline OutputIterator difference_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, OutputIterator out)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    concept::check<GeometryOut>();
+
+    typedef strategy_intersection
+        <
+            typename cs_tag<GeometryOut>::type,
+            Geometry1,
+            Geometry2,
+            typename geometry::point_type<GeometryOut>::type
+        > strategy;
+
+    return difference_insert<GeometryOut>(geometry1, geometry2,
+            out, strategy());
+}
+
+
+}} // namespace detail::difference
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+/*!
+\brief_calc2{difference}
+\ingroup difference
+\details \details_calc2{difference, spatial set theoretic difference}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Collection \tparam_output_collection
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param output_collection the output collection
+
+\qbk{[include reference/algorithms/difference.qbk]}
+*/
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Collection
+>
+inline void difference(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, Collection& output_collection)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    typedef typename boost::range_value<Collection>::type geometry_out;
+    concept::check<geometry_out>();
+
+    detail::difference::difference_insert<geometry_out>(
+            geometry1, geometry2,
+            std::back_inserter(output_collection));
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
diff --git a/src/boost/geometry/algorithms/disjoint.hpp b/src/boost/geometry/algorithms/disjoint.hpp
new file mode 100644
index 0000000..f986cc2
--- /dev/null
+++ b/src/boost/geometry/algorithms/disjoint.hpp
@@ -0,0 +1,301 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DISJOINT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DISJOINT_HPP
+
+#include <cstddef>
+#include <deque>
+
+#include <boost/mpl/if.hpp>
+#include <boost/range.hpp>
+
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/algorithms/detail/for_each_range.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace disjoint
+{
+
+template<typename Geometry>
+struct check_each_ring_for_within
+{
+    bool has_within;
+    Geometry const& m_geometry;
+
+    inline check_each_ring_for_within(Geometry const& g)
+        : has_within(false)
+        , m_geometry(g)
+    {}
+
+    template <typename Range>
+    inline void apply(Range const& range)
+    {
+        typename geometry::point_type<Range>::type p;
+        geometry::point_on_border(p, range);
+        if (geometry::within(p, m_geometry))
+        {
+            has_within = true;
+        }
+    }
+};
+
+template <typename FirstGeometry, typename SecondGeometry>
+inline bool rings_containing(FirstGeometry const& geometry1,
+                SecondGeometry const& geometry2)
+{
+    check_each_ring_for_within<FirstGeometry> checker(geometry1);
+    geometry::detail::for_each_range(geometry2, checker);
+    return checker.has_within;
+}
+
+
+struct assign_disjoint_policy
+{
+    // We want to include all points:
+    static bool const include_no_turn = true;
+    static bool const include_degenerate = true;
+    static bool const include_opposite = true;
+
+    // We don't assign extra info:
+    template 
+	<
+		typename Info,
+		typename Point1,
+		typename Point2,
+		typename IntersectionInfo,
+		typename DirInfo
+	>
+    static inline void apply(Info& , Point1 const& , Point2 const&,
+                IntersectionInfo const&, DirInfo const&)
+    {}
+};
+   
+
+template <typename Geometry1, typename Geometry2>
+struct disjoint_linear
+{
+    static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
+    {
+        typedef typename geometry::point_type<Geometry1>::type point_type;
+
+        typedef overlay::turn_info<point_type> turn_info;
+        std::deque<turn_info> turns;
+
+        // Specify two policies:
+        // 1) Stop at any intersection
+        // 2) In assignment, include also degenerate points (which are normally skipped)
+        disjoint_interrupt_policy policy;
+        geometry::get_turns
+            <
+                false, false, 
+                assign_disjoint_policy
+            >(geometry1, geometry2, turns, policy);
+        if (policy.has_intersections)
+        {
+            return false;
+        }
+
+        return true;
+    }
+};
+
+template <typename Segment1, typename Segment2>
+struct disjoint_segment
+{
+    static inline bool apply(Segment1 const& segment1, Segment2 const& segment2)
+    {
+        typedef typename point_type<Segment1>::type point_type;
+
+        segment_intersection_points<point_type> is
+            = strategy::intersection::relate_cartesian_segments
+            <
+                policies::relate::segments_intersection_points
+                    <
+                        Segment1,
+                        Segment2,
+                        segment_intersection_points<point_type>
+                    >
+            >::apply(segment1, segment2);
+
+        return is.count == 0;
+    }
+};
+
+template <typename Geometry1, typename Geometry2>
+struct general_areal
+{
+    static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
+    {
+        if (! disjoint_linear<Geometry1, Geometry2>::apply(geometry1, geometry2))
+        {
+            return false;
+        }
+
+        // If there is no intersection of segments, they might located
+        // inside each other
+        if (rings_containing(geometry1, geometry2)
+            || rings_containing(geometry2, geometry1))
+        {
+            return false;
+        }
+
+        return true;
+    }
+};
+
+
+}} // namespace detail::disjoint
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename GeometryTag1, typename GeometryTag2,
+    typename Geometry1, typename Geometry2,
+    std::size_t DimensionCount
+>
+struct disjoint
+    : detail::disjoint::general_areal<Geometry1, Geometry2>
+{};
+
+
+template <typename Point1, typename Point2, std::size_t DimensionCount>
+struct disjoint<point_tag, point_tag, Point1, Point2, DimensionCount>
+    : detail::disjoint::point_point<Point1, Point2, 0, DimensionCount>
+{};
+
+
+template <typename Box1, typename Box2, std::size_t DimensionCount>
+struct disjoint<box_tag, box_tag, Box1, Box2, DimensionCount>
+    : detail::disjoint::box_box<Box1, Box2, 0, DimensionCount>
+{};
+
+
+template <typename Point, typename Box, std::size_t DimensionCount>
+struct disjoint<point_tag, box_tag, Point, Box, DimensionCount>
+    : detail::disjoint::point_box<Point, Box, 0, DimensionCount>
+{};
+
+template <typename Linestring1, typename Linestring2>
+struct disjoint<linestring_tag, linestring_tag, Linestring1, Linestring2, 2>
+    : detail::disjoint::disjoint_linear<Linestring1, Linestring2>
+{};
+
+template <typename Linestring1, typename Linestring2>
+struct disjoint<segment_tag, segment_tag, Linestring1, Linestring2, 2>
+    : detail::disjoint::disjoint_segment<Linestring1, Linestring2>
+{};
+
+template <typename Linestring, typename Segment>
+struct disjoint<linestring_tag, segment_tag, Linestring, Segment, 2>
+    : detail::disjoint::disjoint_linear<Linestring, Segment>
+{};
+
+
+template
+<
+    typename GeometryTag1, typename GeometryTag2,
+    typename Geometry1, typename Geometry2,
+    std::size_t DimensionCount
+>
+struct disjoint_reversed
+{
+    static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
+    {
+        return disjoint
+            <
+                GeometryTag2, GeometryTag1,
+                Geometry2, Geometry1,
+                DimensionCount
+            >::apply(g2, g1);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+/*!
+\brief \brief_check2{are disjoint}
+\ingroup disjoint
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return \return_check2{are disjoint}
+
+\qbk{[include reference/algorithms/disjoint.qbk]}
+*/
+template <typename Geometry1, typename Geometry2>
+inline bool disjoint(Geometry1 const& geometry1,
+            Geometry2 const& geometry2)
+{
+    concept::check_concepts_and_equal_dimensions
+        <
+            Geometry1 const,
+            Geometry2 const
+        >();
+
+    return boost::mpl::if_c
+        <
+            reverse_dispatch<Geometry1, Geometry2>::type::value,
+            dispatch::disjoint_reversed
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1,
+                Geometry2,
+                dimension<Geometry1>::type::value
+            >,
+            dispatch::disjoint
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1,
+                Geometry2,
+                dimension<Geometry1>::type::value
+            >
+        >::type::apply(geometry1, geometry2);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DISJOINT_HPP
diff --git a/src/boost/geometry/algorithms/distance.hpp b/src/boost/geometry/algorithms/distance.hpp
new file mode 100644
index 0000000..11c2bc9
--- /dev/null
+++ b/src/boost/geometry/algorithms/distance.hpp
@@ -0,0 +1,591 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/algorithms/not_implemented.hpp>
+#include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/strategies/default_distance_result.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace distance
+{
+
+// To avoid spurious namespaces here:
+using strategy::distance::services::return_type;
+
+template <typename P1, typename P2, typename Strategy>
+struct point_to_point
+{
+    static inline typename return_type<Strategy>::type apply(P1 const& p1,
+                P2 const& p2, Strategy const& strategy)
+    {
+        return strategy.apply(p1, p2);
+    }
+};
+
+
+template<typename Point, typename Segment, typename Strategy>
+struct point_to_segment
+{
+    static inline typename return_type<Strategy>::type apply(Point const& point,
+                Segment const& segment, Strategy const& )
+    {
+        typename strategy::distance::services::default_strategy
+            <
+                segment_tag,
+                Point,
+                typename point_type<Segment>::type,
+                typename cs_tag<Point>::type,
+                typename cs_tag<typename point_type<Segment>::type>::type,
+                Strategy
+            >::type segment_strategy;
+
+        typename point_type<Segment>::type p[2];
+        geometry::detail::assign_point_from_index<0>(segment, p[0]);
+        geometry::detail::assign_point_from_index<1>(segment, p[1]);
+        return segment_strategy.apply(point, p[0], p[1]);
+    }
+};
+
+
+template
+<
+    typename Point,
+    typename Range,
+    closure_selector Closure,
+    typename PPStrategy,
+    typename PSStrategy
+>
+struct point_to_range
+{
+    typedef typename return_type<PSStrategy>::type return_type;
+
+    static inline return_type apply(Point const& point, Range const& range,
+            PPStrategy const& pp_strategy, PSStrategy const& ps_strategy)
+    {
+        return_type const zero = return_type(0);
+
+        if (boost::size(range) == 0)
+        {
+            return zero;
+        }
+
+        typedef typename closeable_view<Range const, Closure>::type view_type;
+
+        view_type view(range);
+
+        // line of one point: return point distance
+        typedef typename boost::range_iterator<view_type const>::type iterator_type;
+        iterator_type it = boost::begin(view);
+        iterator_type prev = it++;
+        if (it == boost::end(view))
+        {
+            return pp_strategy.apply(point, *boost::begin(view));
+        }
+
+        // Create comparable (more efficient) strategy
+        typedef typename strategy::distance::services::comparable_type<PSStrategy>::type eps_strategy_type;
+        eps_strategy_type eps_strategy = strategy::distance::services::get_comparable<PSStrategy>::apply(ps_strategy);
+
+        // start with first segment distance
+        return_type d = eps_strategy.apply(point, *prev, *it);
+        return_type rd = ps_strategy.apply(point, *prev, *it);
+
+        // check if other segments are closer
+        for (++prev, ++it; it != boost::end(view); ++prev, ++it)
+        {
+            return_type const ds = eps_strategy.apply(point, *prev, *it);
+            if (geometry::math::equals(ds, zero))
+            {
+                return ds;
+            }
+            else if (ds < d)
+            {
+                d = ds;
+                rd = ps_strategy.apply(point, *prev, *it);
+            }
+        }
+
+        return rd;
+    }
+};
+
+
+template
+<
+    typename Point,
+    typename Ring,
+    closure_selector Closure,
+    typename PPStrategy,
+    typename PSStrategy
+>
+struct point_to_ring
+{
+    typedef std::pair
+        <
+            typename return_type<PPStrategy>::type, bool
+        > distance_containment;
+
+    static inline distance_containment apply(Point const& point,
+                Ring const& ring,
+                PPStrategy const& pp_strategy, PSStrategy const& ps_strategy)
+    {
+        return distance_containment
+            (
+                point_to_range
+                    <
+                        Point,
+                        Ring,
+                        Closure,
+                        PPStrategy,
+                        PSStrategy
+                    >::apply(point, ring, pp_strategy, ps_strategy),
+                geometry::within(point, ring)
+            );
+    }
+};
+
+
+
+template
+<
+    typename Point,
+    typename Polygon,
+    closure_selector Closure,
+    typename PPStrategy,
+    typename PSStrategy
+>
+struct point_to_polygon
+{
+    typedef typename return_type<PPStrategy>::type return_type;
+    typedef std::pair<return_type, bool> distance_containment;
+
+    static inline distance_containment apply(Point const& point,
+                Polygon const& polygon,
+                PPStrategy const& pp_strategy, PSStrategy const& ps_strategy)
+    {
+        // Check distance to all rings
+        typedef point_to_ring
+            <
+                Point,
+                typename ring_type<Polygon>::type,
+                Closure,
+                PPStrategy,
+                PSStrategy
+            > per_ring;
+
+        distance_containment dc = per_ring::apply(point,
+                        exterior_ring(polygon), pp_strategy, ps_strategy);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            distance_containment dcr = per_ring::apply(point,
+                            *it, pp_strategy, ps_strategy);
+            if (dcr.first < dc.first)
+            {
+                dc.first = dcr.first;
+            }
+            // If it was inside, and also inside inner ring,
+            // turn off the inside-flag, it is outside the polygon
+            if (dc.second && dcr.second)
+            {
+                dc.second = false;
+            }
+        }
+        return dc;
+    }
+};
+
+
+// Helper metafunction for default strategy retrieval
+template <typename Geometry1, typename Geometry2>
+struct default_strategy
+    : strategy::distance::services::default_strategy
+          <
+              point_tag,
+              typename point_type<Geometry1>::type,
+              typename point_type<Geometry2>::type
+          >
+{};
+
+
+}} // namespace detail::distance
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+using strategy::distance::services::return_type;
+
+
+template
+<
+    typename Geometry1, typename Geometry2,
+    typename Strategy = typename detail::distance::default_strategy<Geometry1, Geometry2>::type,
+    typename Tag1 = typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
+    typename Tag2 = typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
+    typename StrategyTag = typename strategy::distance::services::tag<Strategy>::type,
+    bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
+>
+struct distance: not_implemented<Tag1, Tag2>
+{};
+
+
+// If reversal is needed, perform it
+template
+<
+    typename Geometry1, typename Geometry2, typename Strategy,
+    typename Tag1, typename Tag2, typename StrategyTag
+>
+struct distance
+<
+    Geometry1, Geometry2, Strategy,
+    Tag1, Tag2, StrategyTag,
+    true
+>
+    : distance<Geometry2, Geometry1, Strategy, Tag2, Tag1, StrategyTag, false>
+{
+    static inline typename return_type<Strategy>::type apply(
+        Geometry1 const& g1,
+        Geometry2 const& g2,
+        Strategy const& strategy)
+    {
+        return distance
+            <
+                Geometry2, Geometry1, Strategy,
+                Tag2, Tag1, StrategyTag,
+                false
+            >::apply(g2, g1, strategy);
+    }
+};
+
+// If reversal is needed and we got the strategy by default, invert it before
+// proceeding to the reversal.
+template
+<
+    typename Geometry1, typename Geometry2,
+    typename Tag1, typename Tag2, typename StrategyTag
+>
+struct distance
+<
+    Geometry1, Geometry2,
+    typename detail::distance::default_strategy<Geometry1, Geometry2>::type,
+    Tag1, Tag2, StrategyTag,
+    true
+>
+    : distance
+          <
+              Geometry2, Geometry1,
+              typename detail::distance::default_strategy<Geometry2, Geometry1>::type,
+              Tag2, Tag1, StrategyTag,
+              false
+          >
+{
+    typedef typename detail::distance::default_strategy<Geometry2, Geometry1>::type reversed_strategy;
+
+    static inline typename strategy::distance::services::return_type<reversed_strategy>::type apply(
+        Geometry1 const& g1,
+        Geometry2 const& g2,
+        typename detail::distance::default_strategy<Geometry1, Geometry2>::type const&)
+    {
+        return distance
+            <
+                Geometry2, Geometry1, reversed_strategy,
+                Tag2, Tag1, StrategyTag,
+                false
+            >::apply(g2, g1, reversed_strategy());
+    }
+};
+
+
+// Point-point
+template <typename P1, typename P2, typename Strategy>
+struct distance
+    <
+        P1, P2, Strategy,
+        point_tag, point_tag, strategy_tag_distance_point_point,
+        false
+    >
+    : detail::distance::point_to_point<P1, P2, Strategy>
+{};
+
+
+// Point-line version 1, where point-point strategy is specified
+template <typename Point, typename Linestring, typename Strategy>
+struct distance
+<
+    Point, Linestring, Strategy,
+    point_tag, linestring_tag, strategy_tag_distance_point_point,
+    false
+>
+{
+
+    static inline typename return_type<Strategy>::type apply(Point const& point,
+            Linestring const& linestring,
+            Strategy const& strategy)
+    {
+        typedef typename strategy::distance::services::default_strategy
+                    <
+                        segment_tag,
+                        Point,
+                        typename point_type<Linestring>::type
+                    >::type ps_strategy_type;
+
+        return detail::distance::point_to_range
+            <
+                Point, Linestring, closed, Strategy, ps_strategy_type
+            >::apply(point, linestring, strategy, ps_strategy_type());
+    }
+};
+
+
+// Point-line version 2, where point-segment strategy is specified
+template <typename Point, typename Linestring, typename Strategy>
+struct distance
+<
+    Point, Linestring, Strategy,
+    point_tag, linestring_tag, strategy_tag_distance_point_segment,
+    false
+>
+{
+    static inline typename return_type<Strategy>::type apply(Point const& point,
+            Linestring const& linestring,
+            Strategy const& strategy)
+    {
+        typedef typename Strategy::point_strategy_type pp_strategy_type;
+        return detail::distance::point_to_range
+            <
+                Point, Linestring, closed, pp_strategy_type, Strategy
+            >::apply(point, linestring, pp_strategy_type(), strategy);
+    }
+};
+
+// Point-ring , where point-segment strategy is specified
+template <typename Point, typename Ring, typename Strategy>
+struct distance
+<
+    Point, Ring, Strategy,
+    point_tag, ring_tag, strategy_tag_distance_point_point,
+    false
+>
+{
+    typedef typename return_type<Strategy>::type return_type;
+
+    static inline return_type apply(Point const& point,
+            Ring const& ring,
+            Strategy const& strategy)
+    {
+        typedef typename strategy::distance::services::default_strategy
+            <
+                segment_tag,
+                Point,
+                typename point_type<Ring>::type
+            >::type ps_strategy_type;
+
+        std::pair<return_type, bool>
+            dc = detail::distance::point_to_ring
+            <
+                Point, Ring,
+                geometry::closure<Ring>::value,
+                Strategy, ps_strategy_type
+            >::apply(point, ring, strategy, ps_strategy_type());
+
+        return dc.second ? return_type(0) : dc.first;
+    }
+};
+
+
+// Point-polygon , where point-segment strategy is specified
+template <typename Point, typename Polygon, typename Strategy>
+struct distance
+<
+    Point, Polygon, Strategy,
+    point_tag, polygon_tag, strategy_tag_distance_point_point,
+    false
+>
+{
+    typedef typename return_type<Strategy>::type return_type;
+
+    static inline return_type apply(Point const& point,
+            Polygon const& polygon,
+            Strategy const& strategy)
+    {
+        typedef typename strategy::distance::services::default_strategy
+            <
+                segment_tag,
+                Point,
+                typename point_type<Polygon>::type
+            >::type ps_strategy_type;
+
+        std::pair<return_type, bool>
+            dc = detail::distance::point_to_polygon
+            <
+                Point, Polygon,
+                geometry::closure<Polygon>::value,
+                Strategy, ps_strategy_type
+            >::apply(point, polygon, strategy, ps_strategy_type());
+
+        return dc.second ? return_type(0) : dc.first;
+    }
+};
+
+
+
+// Point-segment version 1, with point-point strategy
+template <typename Point, typename Segment, typename Strategy>
+struct distance
+<
+    Point, Segment, Strategy,
+    point_tag, segment_tag, strategy_tag_distance_point_point,
+    false
+> : detail::distance::point_to_segment<Point, Segment, Strategy>
+{};
+
+// Point-segment version 2, with point-segment strategy
+template <typename Point, typename Segment, typename Strategy>
+struct distance
+<
+    Point, Segment, Strategy,
+    point_tag, segment_tag, strategy_tag_distance_point_segment,
+    false
+>
+{
+    static inline typename return_type<Strategy>::type apply(Point const& point,
+                Segment const& segment, Strategy const& strategy)
+    {
+        
+        typename point_type<Segment>::type p[2];
+        geometry::detail::assign_point_from_index<0>(segment, p[0]);
+        geometry::detail::assign_point_from_index<1>(segment, p[1]);
+        return strategy.apply(point, p[0], p[1]);
+    }
+};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+/*!
+\brief \brief_calc2{distance} \brief_strategy
+\ingroup distance
+\details
+\details \details_calc{area}. \brief_strategy. \details_strategy_reasons
+
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Strategy \tparam_strategy{Distance}
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param strategy \param_strategy{distance}
+\return \return_calc{distance}
+\note The strategy can be a point-point strategy. In case of distance point-line/point-polygon
+    it may also be a point-segment strategy.
+
+\qbk{distinguish,with strategy}
+
+\qbk{
+[heading Available Strategies]
+\* [link geometry.reference.strategies.strategy_distance_pythagoras Pythagoras (cartesian)]
+\* [link geometry.reference.strategies.strategy_distance_haversine Haversine (spherical)]
+\* [link geometry.reference.strategies.strategy_distance_cross_track Cross track (spherical\, point-to-segment)]
+\* [link geometry.reference.strategies.strategy_distance_projected_point Projected point (cartesian\, point-to-segment)]
+\* more (currently extensions): Vincenty\, Andoyer (geographic)
+}
+ */
+
+/*
+Note, in case of a Compilation Error:
+if you get:
+ - "Failed to specialize function template ..."
+ - "error: no matching function for call to ..."
+for distance, it is probably so that there is no specialization
+for return_type<...> for your strategy.
+*/
+template <typename Geometry1, typename Geometry2, typename Strategy>
+inline typename strategy::distance::services::return_type<Strategy>::type distance(
+                Geometry1 const& geometry1, Geometry2 const& geometry2,
+                Strategy const& strategy)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    
+    detail::throw_on_empty_input(geometry1);
+    detail::throw_on_empty_input(geometry2);
+
+    return dispatch::distance
+               <
+                   Geometry1,
+                   Geometry2,
+                   Strategy
+               >::apply(geometry1, geometry2, strategy);
+}
+
+
+/*!
+\brief \brief_calc2{distance}
+\ingroup distance
+\details The default strategy is used, corresponding to the coordinate system of the geometries
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return \return_calc{distance}
+
+\qbk{[include reference/algorithms/distance.qbk]}
+ */
+template <typename Geometry1, typename Geometry2>
+inline typename default_distance_result<Geometry1, Geometry2>::type distance(
+                Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    return distance(geometry1, geometry2,
+                    typename detail::distance::default_strategy<Geometry1, Geometry2>::type());
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DISTANCE_HPP
diff --git a/src/boost/geometry/algorithms/envelope.hpp b/src/boost/geometry/algorithms/envelope.hpp
new file mode 100644
index 0000000..da34f6a
--- /dev/null
+++ b/src/boost/geometry/algorithms/envelope.hpp
@@ -0,0 +1,273 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace envelope
+{
+
+
+/// Calculate envelope of an 2D or 3D segment
+template<typename Geometry, typename Box>
+struct envelope_expand_one
+{
+    static inline void apply(Geometry const& geometry, Box& mbr)
+    {
+        assign_inverse(mbr);
+        geometry::expand(mbr, geometry);
+    }
+};
+
+
+/// Iterate through range (also used in multi*)
+template<typename Range, typename Box>
+inline void envelope_range_additional(Range const& range, Box& mbr)
+{
+    typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+    for (iterator_type it = boost::begin(range);
+        it != boost::end(range);
+        ++it)
+    {
+        geometry::expand(mbr, *it);
+    }
+}
+
+
+
+/// Generic range dispatching struct
+template <typename Range, typename Box>
+struct envelope_range
+{
+    /// Calculate envelope of range using a strategy
+    static inline void apply(Range const& range, Box& mbr)
+    {
+        assign_inverse(mbr);
+        envelope_range_additional(range, mbr);
+    }
+};
+
+}} // namespace detail::envelope
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+// Note, the strategy is for future use (less/greater -> compare spherical
+// using other methods), defaults are OK for now.
+// However, they are already in the template methods
+
+template
+<
+    typename Tag1, typename Tag2,
+    typename Geometry, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template
+<
+    typename Point, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        point_tag, box_tag,
+        Point, Box,
+        StrategyLess, StrategyGreater
+    >
+    : detail::envelope::envelope_expand_one<Point, Box>
+{};
+
+
+template
+<
+    typename BoxIn, typename BoxOut,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        box_tag, box_tag,
+        BoxIn, BoxOut,
+        StrategyLess, StrategyGreater
+    >
+    : detail::envelope::envelope_expand_one<BoxIn, BoxOut>
+{};
+
+
+template
+<
+    typename Segment, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        segment_tag, box_tag,
+        Segment, Box,
+        StrategyLess, StrategyGreater
+    >
+    : detail::envelope::envelope_expand_one<Segment, Box>
+{};
+
+
+template
+<
+    typename Linestring, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        linestring_tag, box_tag,
+        Linestring, Box,
+        StrategyLess, StrategyGreater
+    >
+    : detail::envelope::envelope_range<Linestring, Box>
+{};
+
+
+template
+<
+    typename Ring, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        ring_tag, box_tag,
+        Ring, Box,
+        StrategyLess, StrategyGreater
+    >
+    : detail::envelope::envelope_range<Ring, Box>
+{};
+
+
+template
+<
+    typename Polygon, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        polygon_tag, box_tag,
+        Polygon, Box,
+        StrategyLess, StrategyGreater
+    >
+{
+    static inline void apply(Polygon const& poly, Box& mbr)
+    {
+        // For polygon, inspecting outer ring is sufficient
+
+        detail::envelope::envelope_range
+            <
+                typename ring_type<Polygon>::type,
+                Box
+            >::apply(exterior_ring(poly), mbr);
+    }
+
+};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief \brief_calc{envelope}
+\ingroup envelope
+\details \details_calc{envelope,\det_envelope}.
+\tparam Geometry \tparam_geometry
+\tparam Box \tparam_box
+\param geometry \param_geometry
+\param mbr \param_box \param_set{envelope}
+
+\qbk{[include reference/algorithms/envelope.qbk]}
+\qbk{
+[heading Example]
+[envelope] [envelope_output]
+}
+*/
+template<typename Geometry, typename Box>
+inline void envelope(Geometry const& geometry, Box& mbr)
+{
+    concept::check<Geometry const>();
+    concept::check<Box>();
+
+    dispatch::envelope
+        <
+            typename tag<Geometry>::type, typename tag<Box>::type,
+            Geometry, Box,
+            void, void
+        >::apply(geometry, mbr);
+}
+
+
+/*!
+\brief \brief_calc{envelope}
+\ingroup envelope
+\details \details_calc{return_envelope,\det_envelope}. \details_return{envelope}
+\tparam Box \tparam_box
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{envelope}
+
+\qbk{[include reference/algorithms/envelope.qbk]}
+\qbk{
+[heading Example]
+[return_envelope] [return_envelope_output]
+}
+*/
+template<typename Box, typename Geometry>
+inline Box return_envelope(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+    concept::check<Box>();
+
+    Box mbr;
+    dispatch::envelope
+        <
+            typename tag<Geometry>::type, typename tag<Box>::type,
+            Geometry, Box,
+            void, void
+        >::apply(geometry, mbr);
+    return mbr;
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_ENVELOPE_HPP
diff --git a/src/boost/geometry/algorithms/equals.hpp b/src/boost/geometry/algorithms/equals.hpp
new file mode 100644
index 0000000..6b094f7
--- /dev/null
+++ b/src/boost/geometry/algorithms/equals.hpp
@@ -0,0 +1,319 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_EQUALS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_EQUALS_HPP
+
+
+#include <cstddef>
+#include <vector>
+
+#include <boost/mpl/if.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/algorithms/detail/not.hpp>
+
+// For trivial checks
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/length.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+#include <boost/geometry/algorithms/detail/equals/collect_vectors.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace equals
+{
+
+
+template
+<
+    typename Box1,
+    typename Box2,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct box_box
+{
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        if (!geometry::math::equals(get<min_corner, Dimension>(box1), get<min_corner, Dimension>(box2))
+            || !geometry::math::equals(get<max_corner, Dimension>(box1), get<max_corner, Dimension>(box2)))
+        {
+            return false;
+        }
+        return box_box<Box1, Box2, Dimension + 1, DimensionCount>::apply(box1, box2);
+    }
+};
+
+template <typename Box1, typename Box2, std::size_t DimensionCount>
+struct box_box<Box1, Box2, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Box1 const& , Box2 const& )
+    {
+        return true;
+    }
+};
+
+
+struct area_check
+{
+    template <typename Geometry1, typename Geometry2>
+    static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
+    {
+        return geometry::math::equals(
+                geometry::area(geometry1),
+                geometry::area(geometry2));
+    }
+};
+
+
+struct length_check
+{
+    template <typename Geometry1, typename Geometry2>
+    static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
+    {
+        return geometry::math::equals(
+                geometry::length(geometry1),
+                geometry::length(geometry2));
+    }
+};
+
+
+template <typename Geometry1, typename Geometry2, typename TrivialCheck>
+struct equals_by_collection
+{
+    static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2)
+    {
+        if (! TrivialCheck::apply(geometry1, geometry2))
+        {
+            return false;
+        }
+
+        typedef typename geometry::select_most_precise
+            <
+                typename select_coordinate_type
+                    <
+                        Geometry1, Geometry2
+                    >::type,
+                double
+            >::type calculation_type;
+
+        typedef std::vector<collected_vector<calculation_type> > v;
+        v c1, c2;
+
+        geometry::collect_vectors(c1, geometry1);
+        geometry::collect_vectors(c2, geometry2);
+
+        if (boost::size(c1) != boost::size(c2))
+        {
+            return false;
+        }
+
+        std::sort(c1.begin(), c1.end());
+        std::sort(c2.begin(), c2.end());
+
+        // Just check if these vectors are equal.
+        return std::equal(c1.begin(), c1.end(), c2.begin());
+    }
+};
+
+
+}} // namespace detail::equals
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag1, typename Tag2,
+    typename Geometry1,
+    typename Geometry2,
+    std::size_t DimensionCount
+>
+struct equals
+{};
+
+
+template <typename P1, typename P2, std::size_t DimensionCount>
+struct equals<point_tag, point_tag, P1, P2, DimensionCount>
+    : geometry::detail::not_
+        <
+            P1,
+            P2,
+            detail::disjoint::point_point<P1, P2, 0, DimensionCount>
+        >
+{};
+
+
+template <typename Box1, typename Box2, std::size_t DimensionCount>
+struct equals<box_tag, box_tag, Box1, Box2, DimensionCount>
+    : detail::equals::box_box<Box1, Box2, 0, DimensionCount>
+{};
+
+
+template <typename Ring1, typename Ring2>
+struct equals<ring_tag, ring_tag, Ring1, Ring2, 2>
+    : detail::equals::equals_by_collection
+        <
+            Ring1, Ring2,
+            detail::equals::area_check
+        >
+{};
+
+
+template <typename Polygon1, typename Polygon2>
+struct equals<polygon_tag, polygon_tag, Polygon1, Polygon2, 2>
+    : detail::equals::equals_by_collection
+        <
+            Polygon1, Polygon2,
+            detail::equals::area_check
+        >
+{};
+
+
+template <typename LineString1, typename LineString2>
+struct equals<linestring_tag, linestring_tag, LineString1, LineString2, 2>
+    : detail::equals::equals_by_collection
+        <
+            LineString1, LineString2,
+            detail::equals::length_check
+        >
+{};
+
+
+template <typename Polygon, typename Ring>
+struct equals<polygon_tag, ring_tag, Polygon, Ring, 2>
+    : detail::equals::equals_by_collection
+        <
+            Polygon, Ring,
+            detail::equals::area_check
+        >
+{};
+
+
+template <typename Ring, typename Box>
+struct equals<ring_tag, box_tag, Ring, Box, 2>
+    : detail::equals::equals_by_collection
+        <
+            Ring, Box,
+            detail::equals::area_check
+        >
+{};
+
+
+template <typename Polygon, typename Box>
+struct equals<polygon_tag, box_tag, Polygon, Box, 2>
+    : detail::equals::equals_by_collection
+        <
+            Polygon, Box,
+            detail::equals::area_check
+        >
+{};
+
+
+template
+<
+    typename Tag1, typename Tag2,
+    typename Geometry1,
+    typename Geometry2,
+    std::size_t DimensionCount
+>
+struct equals_reversed
+{
+    static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
+    {
+        return equals
+            <
+                Tag2, Tag1,
+                Geometry2, Geometry1,
+                DimensionCount
+            >::apply(g2, g1);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_check{are spatially equal}
+\details \details_check12{equals, is spatially equal}. Spatially equal means 
+    that the same point set is included. A box can therefore be spatially equal
+    to a ring or a polygon, or a linestring can be spatially equal to a 
+    multi-linestring or a segment. This only theoretically, not all combinations
+    are implemented yet.
+\ingroup equals
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return \return_check2{are spatially equal}
+
+\qbk{[include reference/algorithms/equals.qbk]}
+
+ */
+template <typename Geometry1, typename Geometry2>
+inline bool equals(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check_concepts_and_equal_dimensions
+        <
+            Geometry1 const,
+            Geometry2 const
+        >();
+
+    return boost::mpl::if_c
+        <
+            reverse_dispatch<Geometry1, Geometry2>::type::value,
+            dispatch::equals_reversed
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1,
+                Geometry2,
+                dimension<Geometry1>::type::value
+            >,
+            dispatch::equals
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                Geometry1,
+                Geometry2,
+                dimension<Geometry1>::type::value
+            >
+        >::type::apply(geometry1, geometry2);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_EQUALS_HPP
+
diff --git a/src/boost/geometry/algorithms/expand.hpp b/src/boost/geometry/algorithms/expand.hpp
new file mode 100644
index 0000000..da7442b
--- /dev/null
+++ b/src/boost/geometry/algorithms/expand.hpp
@@ -0,0 +1,319 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_EXPAND_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_EXPAND_HPP
+
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+#include <boost/geometry/strategies/compare.hpp>
+#include <boost/geometry/policies/compare.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace expand
+{
+
+
+template
+<
+    typename Box, typename Point,
+    typename StrategyLess, typename StrategyGreater,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct point_loop
+{
+    typedef typename strategy::compare::detail::select_strategy
+        <
+            StrategyLess, 1, Point, Dimension
+        >::type less_type;
+
+    typedef typename strategy::compare::detail::select_strategy
+        <
+            StrategyGreater, -1, Point, Dimension
+        >::type greater_type;
+
+    typedef typename select_coordinate_type<Point, Box>::type coordinate_type;
+
+    static inline void apply(Box& box, Point const& source)
+    {
+        less_type less;
+        greater_type greater;
+
+        coordinate_type const coord = get<Dimension>(source);
+
+        if (less(coord, get<min_corner, Dimension>(box)))
+        {
+            set<min_corner, Dimension>(box, coord);
+        }
+
+        if (greater(coord, get<max_corner, Dimension>(box)))
+        {
+            set<max_corner, Dimension>(box, coord);
+        }
+
+        point_loop
+            <
+                Box, Point,
+                StrategyLess, StrategyGreater,
+                Dimension + 1, DimensionCount
+            >::apply(box, source);
+    }
+};
+
+
+template
+<
+    typename Box, typename Point,
+    typename StrategyLess, typename StrategyGreater,
+    std::size_t DimensionCount
+>
+struct point_loop
+    <
+        Box, Point,
+        StrategyLess, StrategyGreater,
+        DimensionCount, DimensionCount
+    >
+{
+    static inline void apply(Box&, Point const&) {}
+};
+
+
+template
+<
+    typename Box, typename Geometry,
+    typename StrategyLess, typename StrategyGreater,
+    std::size_t Index,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct indexed_loop
+{
+    typedef typename strategy::compare::detail::select_strategy
+        <
+            StrategyLess, 1, Box, Dimension
+        >::type less_type;
+
+    typedef typename strategy::compare::detail::select_strategy
+        <
+            StrategyGreater, -1, Box, Dimension
+        >::type greater_type;
+
+    typedef typename select_coordinate_type
+            <
+                Box,
+                Geometry
+            >::type coordinate_type;
+
+
+    static inline void apply(Box& box, Geometry const& source)
+    {
+        less_type less;
+        greater_type greater;
+
+        coordinate_type const coord = get<Index, Dimension>(source);
+
+        if (less(coord, get<min_corner, Dimension>(box)))
+        {
+            set<min_corner, Dimension>(box, coord);
+        }
+
+        if (greater(coord, get<max_corner, Dimension>(box)))
+        {
+            set<max_corner, Dimension>(box, coord);
+        }
+
+        indexed_loop
+            <
+                Box, Geometry,
+                StrategyLess, StrategyGreater,
+                Index, Dimension + 1, DimensionCount
+            >::apply(box, source);
+    }
+};
+
+
+template
+<
+    typename Box, typename Geometry,
+    typename StrategyLess, typename StrategyGreater,
+    std::size_t Index, std::size_t DimensionCount
+>
+struct indexed_loop
+    <
+        Box, Geometry,
+        StrategyLess, StrategyGreater,
+        Index, DimensionCount, DimensionCount
+    >
+{
+    static inline void apply(Box&, Geometry const&) {}
+};
+
+
+
+// Changes a box such that the other box is also contained by the box
+template
+<
+    typename Box, typename Geometry,
+    typename StrategyLess, typename StrategyGreater
+>
+struct expand_indexed
+{
+    static inline void apply(Box& box, Geometry const& geometry)
+    {
+        indexed_loop
+            <
+                Box, Geometry,
+                StrategyLess, StrategyGreater,
+                0, 0, dimension<Geometry>::type::value
+            >::apply(box, geometry);
+
+        indexed_loop
+            <
+                Box, Geometry,
+                StrategyLess, StrategyGreater,
+                1, 0, dimension<Geometry>::type::value
+            >::apply(box, geometry);
+    }
+};
+
+}} // namespace detail::expand
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag,
+    typename BoxOut, typename Geometry,
+    typename StrategyLess, typename StrategyGreater
+>
+struct expand
+{};
+
+
+// Box + point -> new box containing also point
+template
+<
+    typename BoxOut, typename Point,
+    typename StrategyLess, typename StrategyGreater
+>
+struct expand<point_tag, BoxOut, Point, StrategyLess, StrategyGreater>
+    : detail::expand::point_loop
+        <
+            BoxOut, Point,
+            StrategyLess, StrategyGreater,
+            0, dimension<Point>::type::value
+        >
+{};
+
+
+// Box + box -> new box containing two input boxes
+template
+<
+    typename BoxOut, typename BoxIn,
+    typename StrategyLess, typename StrategyGreater
+>
+struct expand<box_tag, BoxOut, BoxIn, StrategyLess, StrategyGreater>
+    : detail::expand::expand_indexed
+        <BoxOut, BoxIn, StrategyLess, StrategyGreater>
+{};
+
+template
+<
+    typename Box, typename Segment,
+    typename StrategyLess, typename StrategyGreater
+>
+struct expand<segment_tag, Box, Segment, StrategyLess, StrategyGreater>
+    : detail::expand::expand_indexed
+        <Box, Segment, StrategyLess, StrategyGreater>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/***
+*!
+\brief Expands a box using the extend (envelope) of another geometry (box, point)
+\ingroup expand
+\tparam Box type of the box
+\tparam Geometry of second geometry, to be expanded with the box
+\param box box to expand another geometry with, might be changed
+\param geometry other geometry
+\param strategy_less
+\param strategy_greater
+\note Strategy is currently ignored
+ *
+template
+<
+    typename Box, typename Geometry,
+    typename StrategyLess, typename StrategyGreater
+>
+inline void expand(Box& box, Geometry const& geometry,
+            StrategyLess const& strategy_less,
+            StrategyGreater const& strategy_greater)
+{
+    concept::check_concepts_and_equal_dimensions<Box, Geometry const>();
+
+    dispatch::expand
+        <
+            typename tag<Geometry>::type,
+            Box,
+            Geometry,
+            StrategyLess, StrategyGreater
+        >::apply(box, geometry);
+}
+***/
+
+
+/*!
+\brief Expands a box using the bounding box (envelope) of another geometry (box, point)
+\ingroup expand
+\tparam Box type of the box
+\tparam Geometry \tparam_geometry
+\param box box to be expanded using another geometry, mutable
+\param geometry \param_geometry geometry which envelope (bounding box) will be added to the box
+
+\qbk{[include reference/algorithms/expand.qbk]}
+ */
+template <typename Box, typename Geometry>
+inline void expand(Box& box, Geometry const& geometry)
+{
+    concept::check_concepts_and_equal_dimensions<Box, Geometry const>();
+
+    dispatch::expand
+        <
+            typename tag<Geometry>::type,
+            Box, Geometry,
+            strategy::compare::default_strategy,
+            strategy::compare::default_strategy
+        >::apply(box, geometry);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_EXPAND_HPP
diff --git a/src/boost/geometry/algorithms/for_each.hpp b/src/boost/geometry/algorithms/for_each.hpp
new file mode 100644
index 0000000..671f26a
--- /dev/null
+++ b/src/boost/geometry/algorithms/for_each.hpp
@@ -0,0 +1,358 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_FOR_EACH_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_FOR_EACH_HPP
+
+
+#include <algorithm>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+
+#include <boost/geometry/util/add_const_if_c.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace for_each
+{
+
+
+template <typename Point, typename Functor, bool IsConst>
+struct fe_point_per_point
+{
+    static inline Functor apply(
+                typename add_const_if_c<IsConst, Point>::type& point, Functor f)
+    {
+        f(point);
+        return f;
+    }
+};
+
+
+template <typename Point, typename Functor, bool IsConst>
+struct fe_point_per_segment
+{
+    static inline Functor apply(
+                typename add_const_if_c<IsConst, Point>::type& , Functor f)
+    {
+        // TODO: if non-const, we should extract the points from the segment
+        // and call the functor on those two points
+        return f;
+    }
+};
+
+
+template <typename Range, typename Functor, bool IsConst>
+struct fe_range_per_point
+{
+    static inline Functor apply(
+                    typename add_const_if_c<IsConst, Range>::type& range,
+                    Functor f)
+    {
+        return (std::for_each(boost::begin(range), boost::end(range), f));
+    }
+};
+
+
+template <typename Range, typename Functor, bool IsConst>
+struct fe_range_per_segment
+{
+    static inline Functor apply(
+                typename add_const_if_c<IsConst, Range>::type& range,
+                Functor f)
+    {
+        typedef typename add_const_if_c
+            <
+                IsConst,
+                typename point_type<Range>::type
+            >::type point_type;
+
+        BOOST_AUTO_TPL(it, boost::begin(range));
+        BOOST_AUTO_TPL(previous, it++);
+        while(it != boost::end(range))
+        {
+            model::referring_segment<point_type> s(*previous, *it);
+            f(s);
+            previous = it++;
+        }
+
+        return f;
+    }
+};
+
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct fe_polygon_per_point
+{
+    typedef typename add_const_if_c<IsConst, Polygon>::type poly_type;
+
+    static inline Functor apply(poly_type& poly, Functor f)
+    {
+        typedef fe_range_per_point
+                <
+                    typename ring_type<Polygon>::type,
+                    Functor,
+                    IsConst
+                > per_ring;
+
+        f = per_ring::apply(exterior_ring(poly), f);
+
+        typename interior_return_type<poly_type>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            f = per_ring::apply(*it, f);
+        }
+
+        return f;
+    }
+
+};
+
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct fe_polygon_per_segment
+{
+    typedef typename add_const_if_c<IsConst, Polygon>::type poly_type;
+
+    static inline Functor apply(poly_type& poly, Functor f)
+    {
+        typedef fe_range_per_segment
+            <
+                typename ring_type<Polygon>::type,
+                Functor,
+                IsConst
+            > per_ring;
+
+        f = per_ring::apply(exterior_ring(poly), f);
+
+        typename interior_return_type<poly_type>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            f = per_ring::apply(*it, f);
+        }
+
+        return f;
+    }
+
+};
+
+
+}} // namespace detail::for_each
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename Functor,
+    bool IsConst
+>
+struct for_each_point {};
+
+
+template <typename Point, typename Functor, bool IsConst>
+struct for_each_point<point_tag, Point, Functor, IsConst>
+    : detail::for_each::fe_point_per_point<Point, Functor, IsConst>
+{};
+
+
+template <typename Linestring, typename Functor, bool IsConst>
+struct for_each_point<linestring_tag, Linestring, Functor, IsConst>
+    : detail::for_each::fe_range_per_point<Linestring, Functor, IsConst>
+{};
+
+
+template <typename Ring, typename Functor, bool IsConst>
+struct for_each_point<ring_tag, Ring, Functor, IsConst>
+    : detail::for_each::fe_range_per_point<Ring, Functor, IsConst>
+{};
+
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct for_each_point<polygon_tag, Polygon, Functor, IsConst>
+    : detail::for_each::fe_polygon_per_point<Polygon, Functor, IsConst>
+{};
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename Functor,
+    bool IsConst
+>
+struct for_each_segment {};
+
+template <typename Point, typename Functor, bool IsConst>
+struct for_each_segment<point_tag, Point, Functor, IsConst>
+    : detail::for_each::fe_point_per_segment<Point, Functor, IsConst>
+{};
+
+
+template <typename Linestring, typename Functor, bool IsConst>
+struct for_each_segment<linestring_tag, Linestring, Functor, IsConst>
+    : detail::for_each::fe_range_per_segment<Linestring, Functor, IsConst>
+{};
+
+
+template <typename Ring, typename Functor, bool IsConst>
+struct for_each_segment<ring_tag, Ring, Functor, IsConst>
+    : detail::for_each::fe_range_per_segment<Ring, Functor, IsConst>
+{};
+
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct for_each_segment<polygon_tag, Polygon, Functor, IsConst>
+    : detail::for_each::fe_polygon_per_segment<Polygon, Functor, IsConst>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brf_for_each{point}
+\details \det_for_each{point}
+\ingroup for_each
+\param geometry \param_geometry
+\param f \par_for_each_f{const point}
+\tparam Geometry \tparam_geometry
+\tparam Functor \tparam_functor
+
+\qbk{distinguish,const version}
+\qbk{[include reference/algorithms/for_each_point.qbk]}
+\qbk{[heading Example]}
+\qbk{[for_each_point_const] [for_each_point_const_output]}
+*/
+template<typename Geometry, typename Functor>
+inline Functor for_each_point(Geometry const& geometry, Functor f)
+{
+    concept::check<Geometry const>();
+
+    return dispatch::for_each_point
+        <
+            typename tag_cast<typename tag<Geometry>::type, multi_tag>::type,
+            Geometry,
+            Functor,
+            true
+        >::apply(geometry, f);
+}
+
+
+/*!
+\brief \brf_for_each{point}
+\details \det_for_each{point}
+\ingroup for_each
+\param geometry \param_geometry
+\param f \par_for_each_f{point}
+\tparam Geometry \tparam_geometry
+\tparam Functor \tparam_functor
+
+\qbk{[include reference/algorithms/for_each_point.qbk]}
+\qbk{[heading Example]}
+\qbk{[for_each_point] [for_each_point_output]}
+*/
+template<typename Geometry, typename Functor>
+inline Functor for_each_point(Geometry& geometry, Functor f)
+{
+    concept::check<Geometry>();
+
+    return dispatch::for_each_point
+        <
+            typename tag_cast<typename tag<Geometry>::type, multi_tag>::type,
+            Geometry,
+            Functor,
+            false
+        >::apply(geometry, f);
+}
+
+
+/*!
+\brief \brf_for_each{segment}
+\details \det_for_each{segment}
+\ingroup for_each
+\param geometry \param_geometry
+\param f \par_for_each_f{const segment}
+\tparam Geometry \tparam_geometry
+\tparam Functor \tparam_functor
+
+\qbk{distinguish,const version}
+\qbk{[include reference/algorithms/for_each_segment.qbk]}
+\qbk{[heading Example]}
+\qbk{[for_each_segment_const] [for_each_segment_const_output]}
+*/
+template<typename Geometry, typename Functor>
+inline Functor for_each_segment(Geometry const& geometry, Functor f)
+{
+    concept::check<Geometry const>();
+
+    return dispatch::for_each_segment
+        <
+            typename tag_cast<typename tag<Geometry>::type, multi_tag>::type,
+            Geometry,
+            Functor,
+            true
+        >::apply(geometry, f);
+}
+
+
+/*!
+\brief \brf_for_each{segment}
+\details \det_for_each{segment}
+\ingroup for_each
+\param geometry \param_geometry
+\param f \par_for_each_f{segment}
+\tparam Geometry \tparam_geometry
+\tparam Functor \tparam_functor
+
+\qbk{[include reference/algorithms/for_each_segment.qbk]}
+*/
+template<typename Geometry, typename Functor>
+inline Functor for_each_segment(Geometry& geometry, Functor f)
+{
+    concept::check<Geometry>();
+
+    return dispatch::for_each_segment
+        <
+            typename tag_cast<typename tag<Geometry>::type, multi_tag>::type,
+            Geometry,
+            Functor,
+            false
+        >::apply(geometry, f);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_FOR_EACH_HPP
diff --git a/src/boost/geometry/algorithms/intersection.hpp b/src/boost/geometry/algorithms/intersection.hpp
new file mode 100644
index 0000000..8d3dd68
--- /dev/null
+++ b/src/boost/geometry/algorithms/intersection.hpp
@@ -0,0 +1,237 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_INTERSECTION_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_INTERSECTION_HPP
+
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
+#include <boost/geometry/algorithms/intersects.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace intersection
+{
+
+template
+<
+    typename Box1, typename Box2,
+    typename BoxOut,
+    typename Strategy,
+    std::size_t Dimension, std::size_t DimensionCount
+>
+struct intersection_box_box
+{
+    static inline bool apply(Box1 const& box1,
+            Box2 const& box2, BoxOut& box_out,
+            Strategy const& strategy)
+    {
+        typedef typename coordinate_type<BoxOut>::type ct;
+
+        ct min1 = get<min_corner, Dimension>(box1);
+        ct min2 = get<min_corner, Dimension>(box2);
+        ct max1 = get<max_corner, Dimension>(box1);
+        ct max2 = get<max_corner, Dimension>(box2);
+
+        if (max1 < min2 || max2 < min1)
+        {
+            return false;
+        }
+        // Set dimensions of output coordinate
+        set<min_corner, Dimension>(box_out, min1 < min2 ? min2 : min1);
+        set<max_corner, Dimension>(box_out, max1 > max2 ? max2 : max1);
+
+        return intersection_box_box
+            <
+                Box1, Box2, BoxOut, Strategy,
+                Dimension + 1, DimensionCount
+            >::apply(box1, box2, box_out, strategy);
+    }
+};
+
+template
+<
+    typename Box1, typename Box2,
+    typename BoxOut,
+    typename Strategy,
+    std::size_t DimensionCount
+>
+struct intersection_box_box<Box1, Box2, BoxOut, Strategy, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Box1 const&, Box2 const&, BoxOut&, Strategy const&)
+    {
+        return true;
+    }
+};
+
+
+}} // namespace detail::intersection
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// By default, all is forwarded to the intersection_insert-dispatcher
+template
+<
+    typename Tag1, typename Tag2, typename TagOut,
+    typename Geometry1, typename Geometry2,
+    typename GeometryOut,
+    typename Strategy
+>
+struct intersection
+{
+    typedef std::back_insert_iterator<GeometryOut> output_iterator;
+
+    static inline bool apply(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            GeometryOut& geometry_out,
+            Strategy const& strategy)
+    {
+        typedef typename boost::range_value<GeometryOut>::type OneOut;
+
+        intersection_insert
+        <
+            Tag1, Tag2, typename geometry::tag<OneOut>::type,
+            geometry::is_areal<Geometry1>::value,
+            geometry::is_areal<Geometry2>::value,
+            geometry::is_areal<OneOut>::value,
+            Geometry1, Geometry2,
+            detail::overlay::do_reverse<geometry::point_order<Geometry1>::value, false>::value,
+            detail::overlay::do_reverse<geometry::point_order<Geometry2>::value, false>::value,
+            detail::overlay::do_reverse<geometry::point_order<OneOut>::value>::value,
+            output_iterator, OneOut,
+            overlay_intersection,
+            Strategy
+        >::apply(geometry1, geometry2, std::back_inserter(geometry_out), strategy);
+
+        return true;
+    }
+
+};
+
+
+template
+<
+    typename Box1, typename Box2,
+    typename BoxOut,
+    typename Strategy
+>
+struct intersection
+    <
+        box_tag, box_tag, box_tag,
+        Box1, Box2, BoxOut,
+        Strategy
+    > : public detail::intersection::intersection_box_box
+            <
+                Box1, Box2, BoxOut,
+                Strategy,
+                0, geometry::dimension<Box1>::value
+            >
+{};
+
+
+template
+<
+    typename Tag1, typename Tag2, typename TagOut,
+    typename Geometry1, typename Geometry2,
+    typename GeometryOut,
+    typename Strategy
+>
+struct intersection_reversed
+{
+    static inline bool apply(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            GeometryOut& geometry_out,
+            Strategy const& strategy)
+    {
+        return intersection
+            <
+                Tag2, Tag1, TagOut,
+                Geometry2, Geometry1,
+                GeometryOut, Strategy
+            >::apply(geometry2, geometry1, geometry_out, strategy);
+    }
+};
+
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_calc2{intersection}
+\ingroup intersection
+\details \details_calc2{intersection, spatial set theoretic intersection}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam GeometryOut Collection of geometries (e.g. std::vector, std::deque, boost::geometry::multi*) of which
+    the value_type fulfills a \p_l_or_c concept, or it is the output geometry (e.g. for a box)
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param geometry_out The output geometry, either a multi_point, multi_polygon,
+    multi_linestring, or a box (for intersection of two boxes)
+
+\qbk{[include reference/algorithms/intersection.qbk]}
+*/
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename GeometryOut
+>
+inline bool intersection(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            GeometryOut& geometry_out)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    typedef strategy_intersection
+        <
+            typename cs_tag<Geometry1>::type,
+            Geometry1,
+            Geometry2,
+            typename geometry::point_type<Geometry1>::type
+        > strategy;
+
+
+    return boost::mpl::if_c
+        <
+            geometry::reverse_dispatch<Geometry1, Geometry2>::type::value,
+            dispatch::intersection_reversed
+            <
+                    typename geometry::tag<Geometry1>::type,
+                    typename geometry::tag<Geometry2>::type,
+                    typename geometry::tag<GeometryOut>::type,
+                    Geometry1, Geometry2, GeometryOut, strategy
+            >,
+            dispatch::intersection
+            <
+                    typename geometry::tag<Geometry1>::type,
+                    typename geometry::tag<Geometry2>::type,
+                    typename geometry::tag<GeometryOut>::type,
+                    Geometry1, Geometry2, GeometryOut, strategy
+            >
+        >::type::apply(geometry1, geometry2, geometry_out, strategy());
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_INTERSECTION_HPP
diff --git a/src/boost/geometry/algorithms/intersects.hpp b/src/boost/geometry/algorithms/intersects.hpp
new file mode 100644
index 0000000..f367f2e
--- /dev/null
+++ b/src/boost/geometry/algorithms/intersects.hpp
@@ -0,0 +1,106 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_INTERSECTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_INTERSECTS_HPP
+
+
+#include <deque>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
+#include <boost/geometry/algorithms/disjoint.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief \brief_check{has at least one intersection (crossing or self-tangency)}
+\note This function can be called for one geometry (self-intersection) and
+    also for two geometries (intersection)
+\ingroup intersects
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_check{is self-intersecting}
+
+\qbk{distinguish,one geometry}
+\qbk{[def __one_parameter__]}
+\qbk{[include reference/algorithms/intersects.qbk]}
+*/
+template <typename Geometry>
+inline bool intersects(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+
+    typedef detail::overlay::turn_info
+        <
+            typename geometry::point_type<Geometry>::type
+        > turn_info;
+    std::deque<turn_info> turns;
+
+    typedef typename strategy_intersection
+        <
+            typename cs_tag<Geometry>::type,
+            Geometry,
+            Geometry,
+            typename geometry::point_type<Geometry>::type
+        >::segment_intersection_strategy_type segment_intersection_strategy_type;
+
+    typedef detail::overlay::get_turn_info
+        <
+            typename point_type<Geometry>::type,
+            typename point_type<Geometry>::type,
+            turn_info,
+            detail::overlay::assign_null_policy
+        > TurnPolicy;
+
+    detail::disjoint::disjoint_interrupt_policy policy;
+    detail::self_get_turn_points::get_turns
+            <
+                Geometry,
+                std::deque<turn_info>,
+                TurnPolicy,
+                detail::disjoint::disjoint_interrupt_policy
+            >::apply(geometry, turns, policy);
+    return policy.has_intersections;
+}
+
+
+/*!
+\brief \brief_check2{have at least one intersection}
+\ingroup intersects
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return \return_check2{intersect each other}
+
+\qbk{distinguish,two geometries}
+\qbk{[include reference/algorithms/intersects.qbk]}
+ */
+template <typename Geometry1, typename Geometry2>
+inline bool intersects(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    return ! geometry::disjoint(geometry1, geometry2);
+}
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_INTERSECTS_HPP
diff --git a/src/boost/geometry/algorithms/length.hpp b/src/boost/geometry/algorithms/length.hpp
new file mode 100644
index 0000000..de53a39
--- /dev/null
+++ b/src/boost/geometry/algorithms/length.hpp
@@ -0,0 +1,204 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_LENGTH_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_LENGTH_HPP
+
+#include <iterator>
+
+#include <boost/range.hpp>
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/detail/calculate_null.hpp>
+// #include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/strategies/default_length_result.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace length
+{
+
+
+template<typename Segment, typename Strategy>
+struct segment_length
+{
+    static inline typename default_length_result<Segment>::type apply(
+            Segment const& segment, Strategy const& strategy)
+    {
+        typedef typename point_type<Segment>::type point_type;
+        point_type p1, p2;
+        geometry::detail::assign_point_from_index<0>(segment, p1);
+        geometry::detail::assign_point_from_index<1>(segment, p2);
+        return strategy.apply(p1, p2);
+    }
+};
+
+/*!
+\brief Internal, calculates length of a linestring using iterator pairs and
+    specified strategy
+\note for_each could be used here, now that point_type is changed by boost
+    range iterator
+*/
+template<typename Range, typename Strategy, closure_selector Closure>
+struct range_length
+{
+    typedef typename default_length_result<Range>::type return_type;
+
+    static inline return_type apply(
+            Range const& range, Strategy const& strategy)
+    {
+        typedef typename closeable_view<Range const, Closure>::type view_type;
+        typedef typename boost::range_iterator
+            <
+                view_type const
+            >::type iterator_type;
+
+        return_type sum = return_type();
+        view_type view(range);
+        iterator_type it = boost::begin(view), end = boost::end(view);
+        if(it != end)
+        {
+            for(iterator_type previous = it++;
+                    it != end;
+                    ++previous, ++it)
+            {
+                // Add point-point distance using the return type belonging
+                // to strategy
+                sum += strategy.apply(*previous, *it);
+            }
+        }
+
+        return sum;
+    }
+};
+
+
+}} // namespace detail::length
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Tag, typename Geometry, typename Strategy>
+struct length : detail::calculate_null
+    <
+        typename default_length_result<Geometry>::type,
+        Geometry,
+        Strategy
+    >
+{};
+
+
+template <typename Geometry, typename Strategy>
+struct length<linestring_tag, Geometry, Strategy>
+    : detail::length::range_length<Geometry, Strategy, closed>
+{};
+
+
+// RING: length is currently 0; it might be argued that it is the "perimeter"
+
+
+template <typename Geometry, typename Strategy>
+struct length<segment_tag, Geometry, Strategy>
+    : detail::length::segment_length<Geometry, Strategy>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_calc{length}
+\ingroup length
+\details \details_calc{length, length (the sum of distances between consecutive points)}. \details_default_strategy
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{length}
+
+\qbk{[include reference/algorithms/length.qbk]}
+\qbk{[length] [length_output]}
+ */
+template<typename Geometry>
+inline typename default_length_result<Geometry>::type length(
+        Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    // detail::throw_on_empty_input(geometry);
+
+    typedef typename strategy::distance::services::default_strategy
+        <
+            point_tag, typename point_type<Geometry>::type
+        >::type strategy_type;
+
+    return dispatch::length
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            strategy_type
+        >::apply(geometry, strategy_type());
+}
+
+
+/*!
+\brief \brief_calc{length} \brief_strategy
+\ingroup length
+\details \details_calc{length, length (the sum of distances between consecutive points)} \brief_strategy. \details_strategy_reasons
+\tparam Geometry \tparam_geometry
+\tparam Strategy \tparam_strategy{distance}
+\param geometry \param_geometry
+\param strategy \param_strategy{distance}
+\return \return_calc{length}
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/length.qbk]}
+\qbk{[length_with_strategy] [length_with_strategy_output]}
+ */
+template<typename Geometry, typename Strategy>
+inline typename default_length_result<Geometry>::type length(
+        Geometry const& geometry, Strategy const& strategy)
+{
+    concept::check<Geometry const>();
+
+    // detail::throw_on_empty_input(geometry);
+    
+    return dispatch::length
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Strategy
+        >::apply(geometry, strategy);
+}
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_LENGTH_HPP
diff --git a/src/boost/geometry/algorithms/make.hpp b/src/boost/geometry/algorithms/make.hpp
new file mode 100644
index 0000000..d0e3092
--- /dev/null
+++ b/src/boost/geometry/algorithms/make.hpp
@@ -0,0 +1,200 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
+
+#include <boost/geometry/algorithms/assign.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace make
+{
+
+/*!
+\brief Construct a geometry
+\ingroup make
+\tparam Geometry \tparam_geometry
+\tparam Range \tparam_range_point
+\param range \param_range_point
+\return The constructed geometry, here: a linestring or a ring
+
+\qbk{distinguish, with a range}
+\qbk{
+[heading Example]
+[make_with_range] [make_with_range_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.assign.assign_points assign]
+}
+ */
+template <typename Geometry, typename Range>
+inline Geometry make_points(Range const& range)
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    geometry::append(geometry, range);
+    return geometry;
+}
+
+}} // namespace detail::make
+#endif // DOXYGEN_NO_DETAIL
+
+/*!
+\brief Construct a geometry
+\ingroup make
+\details
+\note It does not work with array-point types, like int[2]
+\tparam Geometry \tparam_geometry
+\tparam Type \tparam_numeric to specify the coordinates
+\param c1 \param_x
+\param c2 \param_y
+\return The constructed geometry, here: a 2D point
+
+\qbk{distinguish, 2 coordinate values}
+\qbk{
+[heading Example]
+[make_2d_point] [make_2d_point_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.assign.assign_values_3_2_coordinate_values assign]
+}
+*/
+template <typename Geometry, typename Type>
+inline Geometry make(Type const& c1, Type const& c2)
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    dispatch::assign
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            geometry::dimension<Geometry>::type::value
+        >::apply(geometry, c1, c2);
+    return geometry;
+}
+
+/*!
+\brief Construct a geometry
+\ingroup make
+\tparam Geometry \tparam_geometry
+\tparam Type \tparam_numeric to specify the coordinates
+\param c1 \param_x
+\param c2 \param_y
+\param c3 \param_z
+\return The constructed geometry, here: a 3D point
+
+\qbk{distinguish, 3 coordinate values}
+\qbk{
+[heading Example]
+[make_3d_point] [make_3d_point_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.assign.assign_values_4_3_coordinate_values assign]
+}
+ */
+template <typename Geometry, typename Type>
+inline Geometry make(Type const& c1, Type const& c2, Type const& c3)
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    dispatch::assign
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            geometry::dimension<Geometry>::type::value
+        >::apply(geometry, c1, c2, c3);
+    return geometry;
+}
+
+template <typename Geometry, typename Type>
+inline Geometry make(Type const& c1, Type const& c2, Type const& c3, Type const& c4)
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    dispatch::assign
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            geometry::dimension<Geometry>::type::value
+        >::apply(geometry, c1, c2, c3, c4);
+    return geometry;
+}
+
+
+
+
+
+/*!
+\brief Construct a box with inverse infinite coordinates
+\ingroup make
+\details The make_inverse function initializes a 2D or 3D box with large coordinates, the
+    min corner is very large, the max corner is very small. This is useful e.g. in combination
+    with the expand function, to determine the bounding box of a series of geometries.
+\tparam Geometry \tparam_geometry
+\return The constructed geometry, here: a box
+
+\qbk{
+[heading Example]
+[make_inverse] [make_inverse_output]
+
+[heading See also]
+\* [link geometry.reference.algorithms.assign.assign_inverse assign_inverse]
+}
+ */
+template <typename Geometry>
+inline Geometry make_inverse()
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    dispatch::assign_inverse
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::apply(geometry);
+    return geometry;
+}
+
+/*!
+\brief Construct a geometry with its coordinates initialized to zero
+\ingroup make
+\details The make_zero function initializes a 2D or 3D point or box with coordinates of zero
+\tparam Geometry \tparam_geometry
+\return The constructed and zero-initialized geometry
+ */
+template <typename Geometry>
+inline Geometry make_zero()
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    dispatch::assign_zero
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::apply(geometry);
+    return geometry;
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
diff --git a/src/boost/geometry/algorithms/not_implemented.hpp b/src/boost/geometry/algorithms/not_implemented.hpp
new file mode 100644
index 0000000..008f111
--- /dev/null
+++ b/src/boost/geometry/algorithms/not_implemented.hpp
@@ -0,0 +1,117 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_NOT_IMPLEMENTED_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_NOT_IMPLEMENTED_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace info
+{
+    struct UNRECOGNIZED_GEOMETRY_TYPE {};
+    struct POINT {};
+    struct LINESTRING {};
+    struct POLYGON {};
+    struct RING {};
+    struct BOX {};
+    struct SEGMENT {};
+    struct MULTI_POINT {};
+    struct MULTI_LINESTRING {};
+    struct MULTI_POLYGON {};
+    struct GEOMETRY_COLLECTION {};
+    template <size_t D> struct DIMENSION {};
+}
+
+
+namespace nyi
+{
+
+
+struct not_implemented_tag {};
+
+template
+<
+    typename Term1,
+    typename Term2,
+    typename Term3
+>
+struct not_implemented_error
+{
+
+#ifndef BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD
+# define BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD false
+#endif
+
+    BOOST_MPL_ASSERT_MSG
+        (
+            BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD,
+            THIS_OPERATION_IS_NOT_OR_NOT_YET_IMPLEMENTED,
+            (
+                types<Term1, Term2, Term3>
+            )
+        );
+};
+
+template <typename Tag>
+struct tag_to_term
+{
+    typedef Tag type;
+};
+
+template <> struct tag_to_term<geometry_not_recognized_tag> { typedef info::UNRECOGNIZED_GEOMETRY_TYPE type; };
+template <> struct tag_to_term<point_tag>                   { typedef info::POINT type; };
+template <> struct tag_to_term<linestring_tag>              { typedef info::LINESTRING type; };
+template <> struct tag_to_term<polygon_tag>                 { typedef info::POLYGON type; };
+template <> struct tag_to_term<ring_tag>                    { typedef info::RING type; };
+template <> struct tag_to_term<box_tag>                     { typedef info::BOX type; };
+template <> struct tag_to_term<segment_tag>                 { typedef info::SEGMENT type; };
+template <> struct tag_to_term<multi_point_tag>             { typedef info::MULTI_POINT type; };
+template <> struct tag_to_term<multi_linestring_tag>        { typedef info::MULTI_LINESTRING type; };
+template <> struct tag_to_term<multi_polygon_tag>           { typedef info::MULTI_POLYGON type; };
+template <> struct tag_to_term<geometry_collection_tag>     { typedef info::GEOMETRY_COLLECTION type; };
+template <int D> struct tag_to_term<mpl::int_<D> >  { typedef info::DIMENSION<D> type; };
+
+
+}
+
+
+template
+<
+    typename Term1 = void,
+    typename Term2 = void,
+    typename Term3 = void
+>
+struct not_implemented
+    : nyi::not_implemented_tag,
+      nyi::not_implemented_error
+      <
+          typename mpl::identity<typename nyi::tag_to_term<Term1>::type>::type,
+          typename mpl::identity<typename nyi::tag_to_term<Term2>::type>::type,
+          typename mpl::identity<typename nyi::tag_to_term<Term3>::type>::type
+      >
+{};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_NOT_IMPLEMENTED_HPP
diff --git a/src/boost/geometry/algorithms/num_geometries.hpp b/src/boost/geometry/algorithms/num_geometries.hpp
new file mode 100644
index 0000000..20f35e9
--- /dev/null
+++ b/src/boost/geometry/algorithms/num_geometries.hpp
@@ -0,0 +1,95 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Tag, typename Geometry>
+struct num_geometries
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Geometry>
+struct num_geometries<single_tag, Geometry>
+{
+    static inline std::size_t apply(Geometry const&)
+    {
+        return 1;
+    }
+};
+
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief \brief_calc{number of geometries}
+\ingroup num_geometries
+\details \details_calc{num_geometries, number of geometries}.
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{number of geometries}
+
+\qbk{[include reference/algorithms/num_geometries.qbk]}
+*/
+template <typename Geometry>
+inline std::size_t num_geometries(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    return dispatch::num_geometries
+        <
+            typename tag_cast
+                <
+                    typename tag<Geometry>::type,
+                    single_tag,
+                    multi_tag
+                >::type,
+            Geometry
+        >::apply(geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
diff --git a/src/boost/geometry/algorithms/num_interior_rings.hpp b/src/boost/geometry/algorithms/num_interior_rings.hpp
new file mode 100644
index 0000000..2149f46
--- /dev/null
+++ b/src/boost/geometry/algorithms/num_interior_rings.hpp
@@ -0,0 +1,88 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Tag, typename Geometry>
+struct num_interior_rings
+{
+    static inline std::size_t apply(Geometry const& )
+    {
+        return 0;
+    }
+};
+
+
+
+template <typename Polygon>
+struct num_interior_rings<polygon_tag, Polygon>
+{
+    static inline std::size_t apply(Polygon const& polygon)
+    {
+        return boost::size(geometry::interior_rings(polygon));
+    }
+
+};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief \brief_calc{number of interior rings}
+\ingroup num_interior_rings
+\details \details_calc{num_interior_rings, number of interior rings}.
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{number of interior rings}
+
+\qbk{[include reference/algorithms/num_interior_rings.qbk]}
+
+\note Defined by OGC as "numInteriorRing". To be consistent with "numPoints"
+    letter "s" is appended
+*/
+template <typename Geometry>
+inline std::size_t num_interior_rings(Geometry const& geometry)
+{
+    return dispatch::num_interior_rings
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::apply(geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
diff --git a/src/boost/geometry/algorithms/num_points.hpp b/src/boost/geometry/algorithms/num_points.hpp
new file mode 100644
index 0000000..c480068
--- /dev/null
+++ b/src/boost/geometry/algorithms/num_points.hpp
@@ -0,0 +1,171 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_POINTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_NUM_POINTS_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace num_points
+{
+
+
+template <typename Range>
+struct range_count
+{
+    static inline std::size_t apply(Range const& range, bool add_for_open)
+    {
+        std::size_t n = boost::size(range);
+        if (add_for_open && n > 0)
+        {
+            closure_selector const s = geometry::closure<Range>::value;
+
+            if (s == open)
+            {
+                if (geometry::disjoint(*boost::begin(range), *(boost::begin(range) + n - 1)))
+                {
+                    return n + 1;
+                }
+            }
+        }
+        return n;
+    }
+};
+
+template <typename Geometry, std::size_t D>
+struct other_count
+{
+    static inline std::size_t apply(Geometry const&, bool)
+    {
+        return D;
+    }
+};
+
+template <typename Polygon>
+struct polygon_count
+{
+    static inline std::size_t apply(Polygon const& poly, bool add_for_open)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        std::size_t n = range_count<ring_type>::apply(
+                    exterior_ring(poly), add_for_open);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            n += range_count<ring_type>::apply(*it, add_for_open);
+        }
+
+        return n;
+    }
+};
+
+}} // namespace detail::num_points
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename GeometryTag, typename Geometry>
+struct num_points
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Geometry>
+struct num_points<point_tag, Geometry>
+        : detail::num_points::other_count<Geometry, 1>
+{};
+
+template <typename Geometry>
+struct num_points<box_tag, Geometry>
+        : detail::num_points::other_count<Geometry, 4>
+{};
+
+template <typename Geometry>
+struct num_points<segment_tag, Geometry>
+        : detail::num_points::other_count<Geometry, 2>
+{};
+
+template <typename Geometry>
+struct num_points<linestring_tag, Geometry>
+        : detail::num_points::range_count<Geometry>
+{};
+
+template <typename Geometry>
+struct num_points<ring_tag, Geometry>
+        : detail::num_points::range_count<Geometry>
+{};
+
+template <typename Geometry>
+struct num_points<polygon_tag, Geometry>
+        : detail::num_points::polygon_count<Geometry>
+{};
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief \brief_calc{number of points}
+\ingroup num_points
+\details \details_calc{num_points, number of points}.
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\param add_for_open add one for open geometries (i.e. polygon types which are not closed)
+\return \return_calc{number of points}
+
+\qbk{[include reference/algorithms/num_points.qbk]}
+*/
+template <typename Geometry>
+inline std::size_t num_points(Geometry const& geometry, bool add_for_open = false)
+{
+    concept::check<Geometry const>();
+
+    return dispatch::num_points
+        <
+            typename tag_cast<typename tag<Geometry>::type, multi_tag>::type,
+            Geometry
+        >::apply(geometry, add_for_open);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_NUM_POINTS_HPP
diff --git a/src/boost/geometry/algorithms/overlaps.hpp b/src/boost/geometry/algorithms/overlaps.hpp
new file mode 100644
index 0000000..2f854b4
--- /dev/null
+++ b/src/boost/geometry/algorithms/overlaps.hpp
@@ -0,0 +1,202 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_OVERLAPS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_OVERLAPS_HPP
+
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/core/access.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlaps
+{
+
+template
+<
+    typename Box1,
+    typename Box2,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct box_box_loop
+{
+    static inline void apply(Box1 const& b1, Box2 const& b2,
+            bool& overlaps, bool& one_in_two, bool& two_in_one)
+    {
+        assert_dimension_equal<Box1, Box2>();
+
+        typedef typename coordinate_type<Box1>::type coordinate_type1;
+        typedef typename coordinate_type<Box2>::type coordinate_type2;
+
+        coordinate_type1 const& min1 = get<min_corner, Dimension>(b1);
+        coordinate_type1 const& max1 = get<max_corner, Dimension>(b1);
+        coordinate_type2 const& min2 = get<min_corner, Dimension>(b2);
+        coordinate_type2 const& max2 = get<max_corner, Dimension>(b2);
+
+        // We might use the (not yet accepted) Boost.Interval
+        // submission in the future
+
+        // If:
+        // B1: |-------|
+        // B2:           |------|
+        // in any dimension -> no overlap
+        if (max1 <= min2 || min1 >= max2)
+        {
+            overlaps = false;
+            return;
+        }
+
+        // If:
+        // B1: |--------------------|
+        // B2:   |-------------|
+        // in all dimensions -> within, then no overlap
+        // B1: |--------------------|
+        // B2: |-------------|
+        // this is "within-touch" -> then no overlap. So use < and >
+        if (min1 < min2 || max1 > max2)
+        {
+            one_in_two = false;
+        }
+        // Same other way round
+        if (min2 < min1 || max2 > max1)
+        {
+            two_in_one = false;
+        }
+
+        box_box_loop
+            <
+                Box1,
+                Box2,
+                Dimension + 1,
+                DimensionCount
+            >::apply(b1, b2, overlaps, one_in_two, two_in_one);
+    }
+};
+
+template
+<
+    typename Box1,
+    typename Box2,
+    std::size_t DimensionCount
+>
+struct box_box_loop<Box1, Box2, DimensionCount, DimensionCount>
+{
+    static inline void apply(Box1 const& , Box2 const&, bool&, bool&, bool&)
+    {
+    }
+};
+
+template
+<
+    typename Box1,
+    typename Box2
+>
+struct box_box
+{
+    static inline bool apply(Box1 const& b1, Box2 const& b2)
+    {
+        bool overlaps = true;
+        bool within1 = true;
+        bool within2 = true;
+        box_box_loop
+            <
+                Box1,
+                Box2,
+                0,
+                dimension<Box1>::type::value
+            >::apply(b1, b2, overlaps, within1, within2);
+
+        /*
+        \see http://docs.codehaus.org/display/GEOTDOC/02+Geometry+Relationships#02GeometryRelationships-Overlaps
+        where is stated that "inside" is not an "overlap",
+        this is true and is implemented as such.
+        */
+        return overlaps && ! within1 && ! within2;
+    }
+};
+
+
+
+}} // namespace detail::overlaps
+#endif // DOXYGEN_NO_DETAIL
+
+//struct not_implemented_for_this_geometry_type : public boost::false_type {};
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag1,
+    typename Tag2,
+    typename Geometry1,
+    typename Geometry2
+>
+struct overlaps
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry1, Geometry2>)
+        );
+};
+
+
+template <typename Box1, typename Box2>
+struct overlaps<box_tag, box_tag, Box1, Box2>
+    : detail::overlaps::box_box<Box1, Box2>
+{};
+
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_check2{overlap}
+\ingroup overlaps
+\return \return_check2{overlap}
+
+\qbk{[include reference/algorithms/overlaps.qbk]}
+*/
+template <typename Geometry1, typename Geometry2>
+inline bool overlaps(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    return dispatch::overlaps
+        <
+            typename tag<Geometry1>::type,
+            typename tag<Geometry2>::type,
+            Geometry1,
+            Geometry2
+        >::apply(geometry1, geometry2);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_OVERLAPS_HPP
diff --git a/src/boost/geometry/algorithms/perimeter.hpp b/src/boost/geometry/algorithms/perimeter.hpp
new file mode 100644
index 0000000..adeb0b0
--- /dev/null
+++ b/src/boost/geometry/algorithms/perimeter.hpp
@@ -0,0 +1,144 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_PERIMETER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_PERIMETER_HPP
+
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/default_length_result.hpp>
+#include <boost/geometry/algorithms/length.hpp>
+#include <boost/geometry/algorithms/detail/calculate_null.hpp>
+#include <boost/geometry/algorithms/detail/calculate_sum.hpp>
+// #include <boost/geometry/algorithms/detail/throw_on_empty_input.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// Default perimeter is 0.0, specializations implement calculated values
+template <typename Tag, typename Geometry, typename Strategy>
+struct perimeter : detail::calculate_null
+    <
+        typename default_length_result<Geometry>::type,
+        Geometry,
+        Strategy
+    >
+{};
+
+template <typename Geometry, typename Strategy>
+struct perimeter<ring_tag, Geometry, Strategy>
+    : detail::length::range_length
+        <
+            Geometry,
+            Strategy,
+            closure<Geometry>::value
+        >
+{};
+
+template <typename Polygon, typename Strategy>
+struct perimeter<polygon_tag, Polygon, Strategy>
+    : detail::calculate_polygon_sum
+        <
+            typename default_length_result<Polygon>::type,
+            Polygon,
+            Strategy,
+            detail::length::range_length
+                <
+                    typename ring_type<Polygon>::type,
+                    Strategy,
+                    closure<Polygon>::value
+                >
+        >
+{};
+
+
+// box,n-sphere: to be implemented
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_calc{perimeter}
+\ingroup perimeter
+\details The function perimeter returns the perimeter of a geometry,
+    using the default distance-calculation-strategy
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_calc{perimeter}
+
+\qbk{[include reference/algorithms/perimeter.qbk]}
+ */
+template<typename Geometry>
+inline typename default_length_result<Geometry>::type perimeter(
+        Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename strategy::distance::services::default_strategy
+        <
+            point_tag, point_type
+        >::type strategy_type;
+
+    // detail::throw_on_empty_input(geometry);
+        
+    return dispatch::perimeter
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            strategy_type
+        >::apply(geometry, strategy_type());
+}
+
+/*!
+\brief \brief_calc{perimeter} \brief_strategy
+\ingroup perimeter
+\details The function perimeter returns the perimeter of a geometry,
+    using specified strategy
+\tparam Geometry \tparam_geometry
+\tparam Strategy \tparam_strategy{distance}
+\param geometry \param_geometry
+\param strategy strategy to be used for distance calculations.
+\return \return_calc{perimeter}
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/perimeter.qbk]}
+ */
+template<typename Geometry, typename Strategy>
+inline typename default_length_result<Geometry>::type perimeter(
+        Geometry const& geometry, Strategy const& strategy)
+{
+    concept::check<Geometry const>();
+
+    // detail::throw_on_empty_input(geometry);
+    
+    return dispatch::perimeter
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Strategy
+        >::apply(geometry, strategy);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_PERIMETER_HPP
+
diff --git a/src/boost/geometry/algorithms/reverse.hpp b/src/boost/geometry/algorithms/reverse.hpp
new file mode 100644
index 0000000..bf0ef2d
--- /dev/null
+++ b/src/boost/geometry/algorithms/reverse.hpp
@@ -0,0 +1,134 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP
+
+#include <algorithm>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace reverse
+{
+
+
+template <typename Range>
+struct range_reverse
+{
+    static inline void apply(Range& range)
+    {
+        std::reverse(boost::begin(range), boost::end(range));
+    }
+};
+
+
+template <typename Polygon>
+struct polygon_reverse
+{
+    static inline void apply(Polygon& polygon)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef range_reverse<ring_type> per_range;
+        per_range::apply(exterior_ring(polygon));
+
+        typename interior_return_type<Polygon>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            per_range::apply(*it);
+        }
+    }
+};
+
+
+}} // namespace detail::reverse
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry
+>
+struct reverse
+{
+    static inline void apply(Geometry&)
+    {}
+};
+
+
+template <typename Ring>
+struct reverse<ring_tag, Ring>
+    : detail::reverse::range_reverse<Ring>
+{};
+
+
+template <typename LineString>
+struct reverse<linestring_tag, LineString>
+    : detail::reverse::range_reverse<LineString>
+{};
+
+
+template <typename Polygon>
+struct reverse<polygon_tag, Polygon>
+    : detail::reverse::polygon_reverse<Polygon>
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief Reverses the points within a geometry
+\details Generic function to reverse a geometry. It resembles the std::reverse
+   functionality, but it takes the geometry type into account. Only for a ring
+   or for a linestring it is the same as the std::reverse.
+\ingroup reverse
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry which will be reversed
+
+\qbk{[include reference/algorithms/reverse.qbk]}
+*/
+template <typename Geometry>
+inline void reverse(Geometry& geometry)
+{
+    concept::check<Geometry>();
+
+    dispatch::reverse
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::apply(geometry);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_REVERSE_HPP
diff --git a/src/boost/geometry/algorithms/simplify.hpp b/src/boost/geometry/algorithms/simplify.hpp
new file mode 100644
index 0000000..225321d
--- /dev/null
+++ b/src/boost/geometry/algorithms/simplify.hpp
@@ -0,0 +1,405 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_SIMPLIFY_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_SIMPLIFY_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp>
+#include <boost/geometry/strategies/concepts/simplify_concept.hpp>
+
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/num_interior_rings.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace simplify
+{
+
+template<typename Range, typename Strategy>
+struct simplify_range_insert
+{
+    template <typename OutputIterator, typename Distance>
+    static inline void apply(Range const& range, OutputIterator out,
+                    Distance const& max_distance, Strategy const& strategy)
+    {
+        if (boost::size(range) <= 2 || max_distance < 0)
+        {
+            std::copy(boost::begin(range), boost::end(range), out);
+        }
+        else
+        {
+            strategy.apply(range, out, max_distance);
+        }
+    }
+};
+
+
+template<typename Range, typename Strategy>
+struct simplify_copy
+{
+    template <typename Distance>
+    static inline void apply(Range const& range, Range& out,
+                    Distance const& , Strategy const& )
+    {
+        std::copy
+            (
+                boost::begin(range), boost::end(range), std::back_inserter(out)
+            );
+    }
+};
+
+
+template<typename Range, typename Strategy, std::size_t Minimum>
+struct simplify_range
+{
+    template <typename Distance>
+    static inline void apply(Range const& range, Range& out,
+                    Distance const& max_distance, Strategy const& strategy)
+    {
+        // Call do_container for a linestring / ring
+
+        /* For a RING:
+            The first/last point (the closing point of the ring) should maybe
+            be excluded because it lies on a line with second/one but last.
+            Here it is never excluded.
+
+            Note also that, especially if max_distance is too large,
+            the output ring might be self intersecting while the input ring is
+            not, although chances are low in normal polygons
+
+            Finally the inputring might have 3 (open) or 4 (closed) points (=correct),
+                the output < 3 or 4(=wrong)
+        */
+
+        if (boost::size(range) <= int(Minimum) || max_distance < 0.0)
+        {
+            simplify_copy<Range, Strategy>::apply
+                (
+                    range, out, max_distance, strategy
+                );
+        }
+        else
+        {
+            simplify_range_insert<Range, Strategy>::apply
+                (
+                    range, std::back_inserter(out), max_distance, strategy
+                );
+        }
+    }
+};
+
+template<typename Polygon, typename Strategy>
+struct simplify_polygon
+{
+    template <typename Distance>
+    static inline void apply(Polygon const& poly_in, Polygon& poly_out,
+                    Distance const& max_distance, Strategy const& strategy)
+    {
+        typedef typename ring_type<Polygon>::type ring_type;
+
+        int const Minimum = core_detail::closure::minimum_ring_size
+            <
+                geometry::closure<Polygon>::value
+            >::value;
+
+        // Note that if there are inner rings, and distance is too large,
+        // they might intersect with the outer ring in the output,
+        // while it didn't in the input.
+        simplify_range<ring_type, Strategy, Minimum>::apply(exterior_ring(poly_in),
+                        exterior_ring(poly_out),
+                        max_distance, strategy);
+
+        traits::resize
+            <
+                typename boost::remove_reference
+                <
+                    typename traits::interior_mutable_type<Polygon>::type
+                >::type
+            >::apply(interior_rings(poly_out), num_interior_rings(poly_in));
+
+        typename interior_return_type<Polygon const>::type rings_in
+                    = interior_rings(poly_in);
+        typename interior_return_type<Polygon>::type rings_out
+                    = interior_rings(poly_out);
+        BOOST_AUTO_TPL(it_out, boost::begin(rings_out));
+        for (BOOST_AUTO_TPL(it_in,  boost::begin(rings_in));
+            it_in != boost::end(rings_in);
+            ++it_in, ++it_out)
+        {
+            simplify_range<ring_type, Strategy, Minimum>::apply(*it_in,
+                        *it_out, max_distance, strategy);
+        }
+    }
+};
+
+
+}} // namespace detail::simplify
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry, typename Strategy>
+struct simplify
+{
+};
+
+template <typename Point, typename Strategy>
+struct simplify<point_tag, Point, Strategy>
+{
+    template <typename Distance>
+    static inline void apply(Point const& point, Point& out,
+                    Distance const& , Strategy const& )
+    {
+        geometry::convert(point, out);
+    }
+};
+
+
+template <typename Linestring, typename Strategy>
+struct simplify<linestring_tag, Linestring, Strategy>
+    : detail::simplify::simplify_range
+            <
+                Linestring,
+                Strategy,
+                2
+            >
+{};
+
+template <typename Ring, typename Strategy>
+struct simplify<ring_tag, Ring, Strategy>
+    : detail::simplify::simplify_range
+            <
+                Ring,
+                Strategy,
+                core_detail::closure::minimum_ring_size
+                    <
+                        geometry::closure<Ring>::value
+                    >::value
+            >
+{};
+
+template <typename Polygon, typename Strategy>
+struct simplify<polygon_tag, Polygon, Strategy>
+    : detail::simplify::simplify_polygon
+            <
+                Polygon,
+                Strategy
+            >
+{};
+
+
+template <typename Tag, typename Geometry, typename Strategy>
+struct simplify_insert
+{
+};
+
+
+template <typename Linestring, typename Strategy>
+struct simplify_insert<linestring_tag, Linestring, Strategy>
+    : detail::simplify::simplify_range_insert
+            <
+                Linestring,
+                Strategy
+            >
+{};
+
+template <typename Ring, typename Strategy>
+struct simplify_insert<ring_tag, Ring, Strategy>
+    : detail::simplify::simplify_range_insert
+            <
+                Ring,
+                Strategy
+            >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Simplify a geometry using a specified strategy
+\ingroup simplify
+\tparam Geometry \tparam_geometry
+\tparam Distance A numerical distance measure
+\tparam Strategy A type fulfilling a SimplifyStrategy concept
+\param strategy A strategy to calculate simplification
+\param geometry input geometry, to be simplified
+\param out output geometry, simplified version of the input geometry
+\param max_distance distance (in units of input coordinates) of a vertex
+    to other segments to be removed
+\param strategy simplify strategy to be used for simplification, might
+    include point-distance strategy
+
+\image html svg_simplify_country.png "The image below presents the simplified country"
+\qbk{distinguish,with strategy}
+*/
+template<typename Geometry, typename Distance, typename Strategy>
+inline void simplify(Geometry const& geometry, Geometry& out,
+                     Distance const& max_distance, Strategy const& strategy)
+{
+    concept::check<Geometry>();
+
+    BOOST_CONCEPT_ASSERT( (geometry::concept::SimplifyStrategy<Strategy>) );
+
+    geometry::clear(out);
+
+    dispatch::simplify
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Strategy
+        >::apply(geometry, out, max_distance, strategy);
+}
+
+
+
+
+/*!
+\brief Simplify a geometry
+\ingroup simplify
+\tparam Geometry \tparam_geometry
+\tparam Distance \tparam_numeric
+\note This version of simplify simplifies a geometry using the default
+    strategy (Douglas Peucker),
+\param geometry input geometry, to be simplified
+\param out output geometry, simplified version of the input geometry
+\param max_distance distance (in units of input coordinates) of a vertex
+    to other segments to be removed
+
+\qbk{[include reference/algorithms/simplify.qbk]}
+ */
+template<typename Geometry, typename Distance>
+inline void simplify(Geometry const& geometry, Geometry& out,
+                     Distance const& max_distance)
+{
+    concept::check<Geometry>();
+
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename strategy::distance::services::default_strategy
+            <
+                segment_tag, point_type
+            >::type ds_strategy_type;
+
+    typedef strategy::simplify::douglas_peucker
+        <
+            point_type, ds_strategy_type
+        > strategy_type;
+
+    simplify(geometry, out, max_distance, strategy_type());
+}
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace simplify
+{
+
+
+/*!
+\brief Simplify a geometry, using an output iterator
+    and a specified strategy
+\ingroup simplify
+\tparam Geometry \tparam_geometry
+\param geometry input geometry, to be simplified
+\param out output iterator, outputs all simplified points
+\param max_distance distance (in units of input coordinates) of a vertex
+    to other segments to be removed
+\param strategy simplify strategy to be used for simplification,
+    might include point-distance strategy
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/simplify.qbk]}
+*/
+template<typename Geometry, typename OutputIterator, typename Distance, typename Strategy>
+inline void simplify_insert(Geometry const& geometry, OutputIterator out,
+                              Distance const& max_distance, Strategy const& strategy)
+{
+    concept::check<Geometry const>();
+    BOOST_CONCEPT_ASSERT( (geometry::concept::SimplifyStrategy<Strategy>) );
+
+    dispatch::simplify_insert
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Strategy
+        >::apply(geometry, out, max_distance, strategy);
+}
+
+/*!
+\brief Simplify a geometry, using an output iterator
+\ingroup simplify
+\tparam Geometry \tparam_geometry
+\param geometry input geometry, to be simplified
+\param out output iterator, outputs all simplified points
+\param max_distance distance (in units of input coordinates) of a vertex
+    to other segments to be removed
+
+\qbk{[include reference/algorithms/simplify_insert.qbk]}
+ */
+template<typename Geometry, typename OutputIterator, typename Distance>
+inline void simplify_insert(Geometry const& geometry, OutputIterator out,
+                              Distance const& max_distance)
+{
+    typedef typename point_type<Geometry>::type point_type;
+
+    // Concept: output point type = point type of input geometry
+    concept::check<Geometry const>();
+    concept::check<point_type>();
+
+    typedef typename strategy::distance::services::default_strategy
+        <
+            segment_tag, point_type
+        >::type ds_strategy_type;
+
+    typedef strategy::simplify::douglas_peucker
+        <
+            point_type, ds_strategy_type
+        > strategy_type;
+
+    dispatch::simplify_insert
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            strategy_type
+        >::apply(geometry, out, max_distance, strategy_type());
+}
+
+}} // namespace detail::simplify
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_SIMPLIFY_HPP
diff --git a/src/boost/geometry/algorithms/sym_difference.hpp b/src/boost/geometry/algorithms/sym_difference.hpp
new file mode 100644
index 0000000..6394576
--- /dev/null
+++ b/src/boost/geometry/algorithms/sym_difference.hpp
@@ -0,0 +1,177 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_SYM_DIFFERENCE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_SYM_DIFFERENCE_HPP
+
+#include <algorithm>
+
+
+#include <boost/geometry/algorithms/intersection.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace sym_difference
+{
+
+
+
+/*!
+\brief \brief_calc2{symmetric difference}  \brief_strategy
+\ingroup sym_difference
+\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}
+    \brief_strategy. \details_insert{sym_difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Strategy \tparam_strategy_overlay
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\param strategy \param_strategy{difference}
+\return \return_out
+
+\qbk{distinguish,with strategy}
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator,
+    typename Strategy
+>
+inline OutputIterator sym_difference_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, OutputIterator out,
+            Strategy const& strategy)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    concept::check<GeometryOut>();
+
+    out = geometry::dispatch::intersection_insert
+        <
+            typename geometry::tag<Geometry1>::type,
+            typename geometry::tag<Geometry2>::type,
+            typename geometry::tag<GeometryOut>::type,
+            geometry::is_areal<Geometry1>::value,
+            geometry::is_areal<Geometry2>::value,
+            geometry::is_areal<GeometryOut>::value,
+            Geometry1, Geometry2,
+            geometry::detail::overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
+            geometry::detail::overlay::do_reverse<geometry::point_order<Geometry2>::value, true>::value,
+            geometry::detail::overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+            OutputIterator, GeometryOut,
+            overlay_difference,
+            Strategy
+        >::apply(geometry1, geometry2, out, strategy);
+    out = geometry::dispatch::intersection_insert
+        <
+            typename geometry::tag<Geometry2>::type,
+            typename geometry::tag<Geometry1>::type,
+            typename geometry::tag<GeometryOut>::type,
+            geometry::is_areal<Geometry2>::value,
+            geometry::is_areal<Geometry1>::value,
+            geometry::is_areal<GeometryOut>::value,
+            Geometry2, Geometry1,
+            geometry::detail::overlay::do_reverse<geometry::point_order<Geometry2>::value>::value,
+            geometry::detail::overlay::do_reverse<geometry::point_order<Geometry1>::value, true>::value,
+            geometry::detail::overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+            OutputIterator, GeometryOut,
+            overlay_difference,
+            Strategy
+        >::apply(geometry2, geometry1, out, strategy);
+    return out;
+}
+
+
+/*!
+\brief \brief_calc2{symmetric difference}
+\ingroup sym_difference
+\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}
+    \details_insert{sym_difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\return \return_out
+
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator
+>
+inline OutputIterator sym_difference_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, OutputIterator out)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    concept::check<GeometryOut>();
+
+    typedef strategy_intersection
+        <
+            typename cs_tag<GeometryOut>::type,
+            Geometry1,
+            Geometry2,
+            typename geometry::point_type<GeometryOut>::type
+        > strategy_type;
+
+    return sym_difference_insert<GeometryOut>(geometry1, geometry2, out, strategy_type());
+}
+
+}} // namespace detail::sym_difference
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief \brief_calc2{symmetric difference}
+\ingroup sym_difference
+\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Collection output collection, either a multi-geometry,
+    or a std::vector<Geometry> / std::deque<Geometry> etc
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param output_collection the output collection
+
+\qbk{[include reference/algorithms/sym_difference.qbk]}
+*/
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Collection
+>
+inline void sym_difference(Geometry1 const& geometry1,
+            Geometry2 const& geometry2, Collection& output_collection)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    typedef typename boost::range_value<Collection>::type geometry_out;
+    concept::check<geometry_out>();
+
+    detail::sym_difference::sym_difference_insert<geometry_out>(
+            geometry1, geometry2,
+            std::back_inserter(output_collection));
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_SYM_DIFFERENCE_HPP
diff --git a/src/boost/geometry/algorithms/touches.hpp b/src/boost/geometry/algorithms/touches.hpp
new file mode 100644
index 0000000..7d424af
--- /dev/null
+++ b/src/boost/geometry/algorithms/touches.hpp
@@ -0,0 +1,181 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_TOUCHES_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_TOUCHES_HPP
+
+
+#include <deque>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/algorithms/intersects.hpp>
+#include <boost/geometry/algorithms/num_geometries.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace detail { namespace touches 
+{
+
+template <typename Turn>
+inline bool ok_for_touch(Turn const& turn)
+{
+    return turn.both(detail::overlay::operation_union)
+        || turn.both(detail::overlay::operation_blocked)
+        || turn.combination(detail::overlay::operation_union, detail::overlay::operation_blocked)
+        ;
+}
+
+template <typename Turns>
+inline bool has_only_turns(Turns const& turns)
+{
+    bool has_touch = false;
+    typedef typename boost::range_iterator<Turns const>::type iterator_type;
+    for (iterator_type it = boost::begin(turns); it != boost::end(turns); ++it)
+    {
+        if (it->has(detail::overlay::operation_intersection))
+        {
+            return false;
+        }
+
+        switch(it->method)
+        {
+            case detail::overlay::method_crosses: 
+                return false;
+            case detail::overlay::method_equal: 
+                // Segment spatially equal means: at the right side
+                // the polygon internally overlaps. So return false.
+                return false;
+            case detail::overlay::method_touch: 
+            case detail::overlay::method_touch_interior: 
+            case detail::overlay::method_collinear: 
+                if (ok_for_touch(*it))
+                {
+                    has_touch = true;
+                }
+                else
+                {
+                    return false;
+                }
+                break;
+            case detail::overlay::method_none :
+            case detail::overlay::method_disjoint :
+            case detail::overlay::method_error :
+                break;
+        }
+    }
+    return has_touch;
+}
+
+}}
+
+/*!
+\brief \brief_check{has at least one touching point (self-tangency)}
+\note This function can be called for one geometry (self-tangency) and
+    also for two geometries (touch)
+\ingroup touches
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry
+\return \return_check{is self-touching}
+
+\qbk{distinguish,one geometry}
+\qbk{[def __one_parameter__]}
+\qbk{[include reference/algorithms/touches.qbk]}
+*/
+template <typename Geometry>
+inline bool touches(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    typedef detail::overlay::turn_info
+        <
+            typename geometry::point_type<Geometry>::type
+        > turn_info;
+
+    typedef detail::overlay::get_turn_info
+        <
+            typename point_type<Geometry>::type,
+            typename point_type<Geometry>::type,
+            turn_info,
+            detail::overlay::assign_null_policy
+        > policy_type;
+
+    std::deque<turn_info> turns;
+    detail::self_get_turn_points::no_interrupt_policy policy;
+    detail::self_get_turn_points::get_turns
+            <
+                Geometry,
+                std::deque<turn_info>,
+                policy_type,
+                detail::self_get_turn_points::no_interrupt_policy
+            >::apply(geometry, turns, policy);
+
+    return detail::touches::has_only_turns(turns);
+}
+
+
+/*!
+\brief \brief_check2{have at least one touching point (tangent - non overlapping)}
+\ingroup touches
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return \return_check2{touch each other}
+
+\qbk{distinguish,two geometries}
+\qbk{[include reference/algorithms/touches.qbk]}
+ */
+template <typename Geometry1, typename Geometry2>
+inline bool touches(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+
+    typedef detail::overlay::turn_info
+        <
+            typename geometry::point_type<Geometry1>::type
+        > turn_info;
+
+    typedef detail::overlay::get_turn_info
+        <
+            typename point_type<Geometry1>::type,
+            typename point_type<Geometry2>::type,
+            turn_info,
+            detail::overlay::assign_null_policy
+        > policy_type;
+
+    std::deque<turn_info> turns;
+    detail::get_turns::no_interrupt_policy policy;
+    boost::geometry::get_turns
+            <
+                false, false,
+                detail::overlay::assign_null_policy
+            >(geometry1, geometry2, turns, policy);
+
+    return detail::touches::has_only_turns(turns)
+        && ! geometry::detail::disjoint::rings_containing(geometry1, geometry2)
+        && ! geometry::detail::disjoint::rings_containing(geometry2, geometry1)
+        ;
+}
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_TOUCHES_HPP
diff --git a/src/boost/geometry/algorithms/transform.hpp b/src/boost/geometry/algorithms/transform.hpp
new file mode 100644
index 0000000..22b45dc
--- /dev/null
+++ b/src/boost/geometry/algorithms/transform.hpp
@@ -0,0 +1,351 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_TRANSFORM_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_TRANSFORM_HPP
+
+#include <cmath>
+#include <iterator>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/num_interior_rings.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/transform.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace transform
+{
+
+template <typename Point1, typename Point2, typename Strategy>
+struct transform_point
+{
+    static inline bool apply(Point1 const& p1, Point2& p2,
+                Strategy const& strategy)
+    {
+        return strategy.apply(p1, p2);
+    }
+};
+
+
+template <typename Box1, typename Box2, typename Strategy>
+struct transform_box
+{
+    static inline bool apply(Box1 const& b1, Box2& b2,
+                Strategy const& strategy)
+    {
+        typedef typename point_type<Box1>::type point_type1;
+        typedef typename point_type<Box2>::type point_type2;
+
+        point_type1 lower_left, upper_right;
+        detail::assign::assign_box_2d_corner<min_corner, min_corner>(
+                    b1, lower_left);
+        detail::assign::assign_box_2d_corner<max_corner, max_corner>(
+                    b1, upper_right);
+
+        point_type2 p1, p2;
+        if (strategy.apply(lower_left, p1) && strategy.apply(upper_right, p2))
+        {
+            // Create a valid box and therefore swap if necessary
+            typedef typename coordinate_type<point_type2>::type coordinate_type;
+            coordinate_type x1 = geometry::get<0>(p1)
+                    , y1  = geometry::get<1>(p1)
+                    , x2  = geometry::get<0>(p2)
+                    , y2  = geometry::get<1>(p2);
+
+            if (x1 > x2) { std::swap(x1, x2); }
+            if (y1 > y2) { std::swap(y1, y2); }
+
+            set<min_corner, 0>(b2, x1);
+            set<min_corner, 1>(b2, y1);
+            set<max_corner, 0>(b2, x2);
+            set<max_corner, 1>(b2, y2);
+
+            return true;
+        }
+        return false;
+    }
+};
+
+template <typename Geometry1, typename Geometry2, typename Strategy>
+struct transform_box_or_segment
+{
+    static inline bool apply(Geometry1 const& source, Geometry2& target,
+                Strategy const& strategy)
+    {
+        typedef typename point_type<Geometry1>::type point_type1;
+        typedef typename point_type<Geometry2>::type point_type2;
+
+        point_type1 source_point[2];
+        geometry::detail::assign_point_from_index<0>(source, source_point[0]);
+        geometry::detail::assign_point_from_index<1>(source, source_point[1]);
+
+        point_type2 target_point[2];
+        if (strategy.apply(source_point[0], target_point[0])
+            && strategy.apply(source_point[1], target_point[1]))
+        {
+            geometry::detail::assign_point_to_index<0>(target_point[0], target);
+            geometry::detail::assign_point_to_index<1>(target_point[1], target);
+            return true;
+        }
+        return false;
+    }
+};
+
+
+template
+<
+    typename PointOut,
+    typename OutputIterator,
+    typename Range,
+    typename Strategy
+>
+inline bool transform_range_out(Range const& range,
+    OutputIterator out, Strategy const& strategy)
+{
+    PointOut point_out;
+    for(typename boost::range_iterator<Range const>::type
+        it = boost::begin(range);
+        it != boost::end(range);
+        ++it)
+    {
+        if (! transform_point
+                <
+                    typename point_type<Range>::type,
+                    PointOut,
+                    Strategy
+                >::apply(*it, point_out, strategy))
+        {
+            return false;
+        }
+        *out++ = point_out;
+    }
+    return true;
+}
+
+
+template <typename Polygon1, typename Polygon2, typename Strategy>
+struct transform_polygon
+{
+    static inline bool apply(Polygon1 const& poly1, Polygon2& poly2,
+                Strategy const& strategy)
+    {
+        typedef typename ring_type<Polygon1>::type ring1_type;
+        typedef typename ring_type<Polygon2>::type ring2_type;
+        typedef typename point_type<Polygon2>::type point2_type;
+
+        geometry::clear(poly2);
+
+        if (!transform_range_out<point2_type>(exterior_ring(poly1),
+                    std::back_inserter(exterior_ring(poly2)), strategy))
+        {
+            return false;
+        }
+
+        // Note: here a resizeable container is assumed.
+        traits::resize
+            <
+                typename boost::remove_reference
+                <
+                    typename traits::interior_mutable_type<Polygon2>::type
+                >::type
+            >::apply(interior_rings(poly2), num_interior_rings(poly1));
+
+        typename interior_return_type<Polygon1 const>::type rings1
+                    = interior_rings(poly1);
+        typename interior_return_type<Polygon2>::type rings2
+                    = interior_rings(poly2);
+        BOOST_AUTO_TPL(it1, boost::begin(rings1));
+        BOOST_AUTO_TPL(it2, boost::begin(rings2));
+        for ( ; it1 != boost::end(interior_rings(poly1)); ++it1, ++it2)
+        {
+            if (!transform_range_out<point2_type>(*it1,
+                std::back_inserter(*it2), strategy))
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+};
+
+
+template <typename Point1, typename Point2>
+struct select_strategy
+{
+    typedef typename strategy::transform::services::default_strategy
+        <
+            typename cs_tag<Point1>::type,
+            typename cs_tag<Point2>::type,
+            typename coordinate_system<Point1>::type,
+            typename coordinate_system<Point2>::type,
+            dimension<Point1>::type::value,
+            dimension<Point2>::type::value,
+            typename point_type<Point1>::type,
+            typename point_type<Point2>::type
+        >::type type;
+};
+
+template <typename Range1, typename Range2, typename Strategy>
+struct transform_range
+{
+    static inline bool apply(Range1 const& range1,
+            Range2& range2, Strategy const& strategy)
+    {
+        typedef typename point_type<Range2>::type point_type;
+
+        // Should NOT be done here!
+        // geometry::clear(range2);
+        return transform_range_out<point_type>(range1,
+                std::back_inserter(range2), strategy);
+    }
+};
+
+}} // namespace detail::transform
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Tag1, typename Tag2,
+    typename Geometry1, typename Geometry2,
+    typename Strategy
+>
+struct transform {};
+
+template <typename Point1, typename Point2, typename Strategy>
+struct transform<point_tag, point_tag, Point1, Point2, Strategy>
+    : detail::transform::transform_point<Point1, Point2, Strategy>
+{
+};
+
+
+template <typename Linestring1, typename Linestring2, typename Strategy>
+struct transform
+    <
+        linestring_tag, linestring_tag,
+        Linestring1, Linestring2, Strategy
+    >
+    : detail::transform::transform_range<Linestring1, Linestring2, Strategy>
+{
+};
+
+template <typename Range1, typename Range2, typename Strategy>
+struct transform<ring_tag, ring_tag, Range1, Range2, Strategy>
+    : detail::transform::transform_range<Range1, Range2, Strategy>
+{
+};
+
+template <typename Polygon1, typename Polygon2, typename Strategy>
+struct transform<polygon_tag, polygon_tag, Polygon1, Polygon2, Strategy>
+    : detail::transform::transform_polygon<Polygon1, Polygon2, Strategy>
+{
+};
+
+template <typename Box1, typename Box2, typename Strategy>
+struct transform<box_tag, box_tag, Box1, Box2, Strategy>
+    : detail::transform::transform_box<Box1, Box2, Strategy>
+{
+};
+
+template <typename Segment1, typename Segment2, typename Strategy>
+struct transform<segment_tag, segment_tag, Segment1, Segment2, Strategy>
+    : detail::transform::transform_box_or_segment<Segment1, Segment2, Strategy>
+{
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Transforms from one geometry to another geometry  \brief_strategy
+\ingroup transform
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Strategy strategy
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param strategy The strategy to be used for transformation
+\return True if the transformation could be done
+
+\qbk{distinguish,with strategy}
+
+\qbk{[include reference/algorithms/transform_with_strategy.qbk]}
+ */
+template <typename Geometry1, typename Geometry2, typename Strategy>
+inline bool transform(Geometry1 const& geometry1, Geometry2& geometry2,
+            Strategy const& strategy)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2>();
+
+    typedef dispatch::transform
+        <
+            typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
+            typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
+            Geometry1,
+            Geometry2,
+            Strategy
+        > transform_type;
+
+    return transform_type::apply(geometry1, geometry2, strategy);
+}
+
+
+/*!
+\brief Transforms from one geometry to another geometry using a strategy
+\ingroup transform
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\return True if the transformation could be done
+
+\qbk{[include reference/algorithms/transform.qbk]}
+ */
+template <typename Geometry1, typename Geometry2>
+inline bool transform(Geometry1 const& geometry1, Geometry2& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2>();
+
+    typename detail::transform::select_strategy<Geometry1, Geometry2>::type strategy;
+    return transform(geometry1, geometry2, strategy);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_TRANSFORM_HPP
diff --git a/src/boost/geometry/algorithms/union.hpp b/src/boost/geometry/algorithms/union.hpp
new file mode 100644
index 0000000..28d8e5d
--- /dev/null
+++ b/src/boost/geometry/algorithms/union.hpp
@@ -0,0 +1,284 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_UNION_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_UNION_HPP
+
+
+#include <boost/mpl/if.hpp>
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/is_areal.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/reverse_dispatch.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/algorithms/detail/overlay/overlay.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    // tag dispatching:
+    typename TagIn1, typename TagIn2, typename TagOut,
+    // metafunction finetuning helpers:
+    bool Areal1, bool Areal2, bool ArealOut,
+    // real types
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator,
+    typename GeometryOut,
+    typename Strategy
+>
+struct union_insert
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPES
+            , (types<Geometry1, Geometry2, GeometryOut>)
+        );
+};
+
+
+template
+<
+    typename TagIn1, typename TagIn2, typename TagOut,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator,
+    typename GeometryOut,
+    typename Strategy
+>
+struct union_insert
+    <
+        TagIn1, TagIn2, TagOut,
+        true, true, true,
+        Geometry1, Geometry2,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        Strategy
+    > : detail::overlay::overlay
+        <Geometry1, Geometry2, Reverse1, Reverse2, ReverseOut, OutputIterator, GeometryOut, overlay_union, Strategy>
+{};
+
+
+
+template
+<
+    typename GeometryTag1, typename GeometryTag2, typename GeometryTag3,
+    bool Areal1, bool Areal2, bool ArealOut,
+    typename Geometry1, typename Geometry2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    typename Strategy
+>
+struct union_insert_reversed
+{
+    static inline OutputIterator apply(Geometry1 const& g1,
+            Geometry2 const& g2, OutputIterator out,
+            Strategy const& strategy)
+    {
+        return union_insert
+            <
+                GeometryTag2, GeometryTag1, GeometryTag3,
+                Areal2, Areal1, ArealOut,
+                Geometry2, Geometry1,
+                Reverse2, Reverse1, ReverseOut,
+                OutputIterator, GeometryOut,
+                Strategy
+            >::apply(g2, g1, out, strategy);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace union_
+{
+
+template
+<
+    typename GeometryOut,
+    typename Geometry1, typename Geometry2,
+    typename OutputIterator,
+    typename Strategy
+>
+inline OutputIterator insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out,
+            Strategy const& strategy)
+{
+    return boost::mpl::if_c
+        <
+            geometry::reverse_dispatch<Geometry1, Geometry2>::type::value,
+            dispatch::union_insert_reversed
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                typename tag<GeometryOut>::type,
+                geometry::is_areal<Geometry1>::value,
+                geometry::is_areal<Geometry2>::value,
+                geometry::is_areal<GeometryOut>::value,
+                Geometry1, Geometry2,
+                overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
+                overlay::do_reverse<geometry::point_order<Geometry2>::value>::value,
+                overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+                OutputIterator, GeometryOut,
+                Strategy
+            >,
+            dispatch::union_insert
+            <
+                typename tag<Geometry1>::type,
+                typename tag<Geometry2>::type,
+                typename tag<GeometryOut>::type,
+                geometry::is_areal<Geometry1>::value,
+                geometry::is_areal<Geometry2>::value,
+                geometry::is_areal<GeometryOut>::value,
+                Geometry1, Geometry2,
+                overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
+                overlay::do_reverse<geometry::point_order<Geometry2>::value>::value,
+                overlay::do_reverse<geometry::point_order<GeometryOut>::value>::value,
+                OutputIterator, GeometryOut,
+                Strategy
+            >
+        >::type::apply(geometry1, geometry2, out, strategy);
+}
+
+/*!
+\brief_calc2{union} \brief_strategy
+\ingroup union
+\details \details_calc2{union_insert, spatial set theoretic union}
+    \brief_strategy. details_insert{union}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator output iterator
+\tparam Strategy \tparam_strategy_overlay
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{union}
+\param strategy \param_strategy{union}
+\return \return_out
+
+\qbk{distinguish,with strategy}
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator,
+    typename Strategy
+>
+inline OutputIterator union_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out,
+            Strategy const& strategy)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    concept::check<GeometryOut>();
+
+    return detail::union_::insert<GeometryOut>(geometry1, geometry2, out, strategy);
+}
+
+/*!
+\brief_calc2{union}
+\ingroup union
+\details \details_calc2{union_insert, spatial set theoretic union}.
+    \details_insert{union}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator output iterator
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{union}
+\return \return_out
+*/
+template
+<
+    typename GeometryOut,
+    typename Geometry1,
+    typename Geometry2,
+    typename OutputIterator
+>
+inline OutputIterator union_insert(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            OutputIterator out)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    concept::check<GeometryOut>();
+
+    typedef strategy_intersection
+        <
+            typename cs_tag<GeometryOut>::type,
+            Geometry1,
+            Geometry2,
+            typename geometry::point_type<GeometryOut>::type
+        > strategy;
+
+    return union_insert<GeometryOut>(geometry1, geometry2, out, strategy());
+}
+
+
+}} // namespace detail::union_
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+
+/*!
+\brief Combines two geometries which each other
+\ingroup union
+\details \details_calc2{union, spatial set theoretic union}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Collection output collection, either a multi-geometry,
+    or a std::vector<Geometry> / std::deque<Geometry> etc
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param output_collection the output collection
+\note Called union_ because union is a reserved word.
+
+\qbk{[include reference/algorithms/union.qbk]}
+*/
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Collection
+>
+inline void union_(Geometry1 const& geometry1,
+            Geometry2 const& geometry2,
+            Collection& output_collection)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+
+    typedef typename boost::range_value<Collection>::type geometry_out;
+    concept::check<geometry_out>();
+
+    detail::union_::union_insert<geometry_out>(geometry1, geometry2,
+                std::back_inserter(output_collection));
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_UNION_HPP
diff --git a/src/boost/geometry/algorithms/unique.hpp b/src/boost/geometry/algorithms/unique.hpp
new file mode 100644
index 0000000..3bbf479
--- /dev/null
+++ b/src/boost/geometry/algorithms/unique.hpp
@@ -0,0 +1,153 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP
+
+#include <algorithm>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/policies/compare.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace unique
+{
+
+
+template <typename Range, typename ComparePolicy>
+struct range_unique
+{
+    static inline void apply(Range& range, ComparePolicy const& policy)
+    {
+        typename boost::range_iterator<Range>::type it
+            = std::unique
+                (
+                    boost::begin(range),
+                    boost::end(range),
+                    policy
+                );
+
+        traits::resize<Range>::apply(range, it - boost::begin(range));
+    }
+};
+
+
+template <typename Polygon, typename ComparePolicy>
+struct polygon_unique
+{
+    static inline void apply(Polygon& polygon, ComparePolicy const& policy)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef range_unique<ring_type, ComparePolicy> per_range;
+        per_range::apply(exterior_ring(polygon), policy);
+
+        typename interior_return_type<Polygon>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            per_range::apply(*it, policy);
+        }
+    }
+};
+
+
+
+}} // namespace detail::unique
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename ComparePolicy
+>
+struct unique
+{
+    static inline void apply(Geometry&, ComparePolicy const& )
+    {}
+};
+
+
+template <typename Ring, typename ComparePolicy>
+struct unique<ring_tag, Ring, ComparePolicy>
+    : detail::unique::range_unique<Ring, ComparePolicy>
+{};
+
+
+template <typename LineString, typename ComparePolicy>
+struct unique<linestring_tag, LineString, ComparePolicy>
+    : detail::unique::range_unique<LineString, ComparePolicy>
+{};
+
+
+template <typename Polygon, typename ComparePolicy>
+struct unique<polygon_tag, Polygon, ComparePolicy>
+    : detail::unique::polygon_unique<Polygon, ComparePolicy>
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief \brief_calc{minimal set}
+\ingroup unique
+\details \details_calc{unique,minimal set (where duplicate consecutive points are removed)}.
+\tparam Geometry \tparam_geometry
+\param geometry \param_geometry which will be made unique
+
+\qbk{[include reference/algorithms/unique.qbk]}
+*/
+template <typename Geometry>
+inline void unique(Geometry& geometry)
+{
+    concept::check<Geometry>();
+
+    // Default strategy is the default point-comparison policy
+    typedef geometry::equal_to
+        <
+            typename geometry::point_type<Geometry>::type
+        > policy;
+
+
+    dispatch::unique
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            policy
+        >::apply(geometry, policy());
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP
diff --git a/src/boost/geometry/algorithms/within.hpp b/src/boost/geometry/algorithms/within.hpp
new file mode 100644
index 0000000..f1f0993
--- /dev/null
+++ b/src/boost/geometry/algorithms/within.hpp
@@ -0,0 +1,344 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_WITHIN_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_WITHIN_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/algorithms/make.hpp>
+#include <boost/geometry/algorithms/not_implemented.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/within.hpp>
+#include <boost/geometry/strategies/concepts/within_concept.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/order_as_direction.hpp>
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace within
+{
+
+
+template
+<
+    typename Point,
+    typename Ring,
+    iterate_direction Direction,
+    closure_selector Closure,
+    typename Strategy
+>
+struct point_in_ring
+{
+    BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategyPolygonal<Strategy>) );
+
+    static inline int apply(Point const& point, Ring const& ring,
+            Strategy const& strategy)
+    {
+        if (int(boost::size(ring))
+                < core_detail::closure::minimum_ring_size<Closure>::value)
+        {
+            return -1;
+        }
+
+        typedef typename reversible_view<Ring const, Direction>::type rev_view_type;
+        typedef typename closeable_view
+            <
+                rev_view_type const, Closure
+            >::type cl_view_type;
+        typedef typename boost::range_iterator<cl_view_type const>::type iterator_type;
+
+        rev_view_type rev_view(ring);
+        cl_view_type view(rev_view);
+        typename Strategy::state_type state;
+        iterator_type it = boost::begin(view);
+        iterator_type end = boost::end(view);
+
+        bool stop = false;
+        for (iterator_type previous = it++;
+            it != end && ! stop;
+            ++previous, ++it)
+        {
+            if (! strategy.apply(point, *previous, *it, state))
+            {
+                stop = true;
+            }
+        }
+
+        return strategy.result(state);
+    }
+};
+
+
+// Polygon: in exterior ring, and if so, not within interior ring(s)
+template
+<
+    typename Point,
+    typename Polygon,
+    iterate_direction Direction,
+    closure_selector Closure,
+    typename Strategy
+>
+struct point_in_polygon
+{
+    BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategyPolygonal<Strategy>) );
+
+    static inline int apply(Point const& point, Polygon const& poly,
+            Strategy const& strategy)
+    {
+        int const code = point_in_ring
+            <
+                Point,
+                typename ring_type<Polygon>::type,
+                Direction,
+                Closure,
+                Strategy
+            >::apply(point, exterior_ring(poly), strategy);
+
+        if (code == 1)
+        {
+            typename interior_return_type<Polygon const>::type rings
+                        = interior_rings(poly);
+            for (BOOST_AUTO_TPL(it, boost::begin(rings));
+                it != boost::end(rings);
+                ++it)
+            {
+                int const interior_code = point_in_ring
+                    <
+                        Point,
+                        typename ring_type<Polygon>::type,
+                        Direction,
+                        Closure,
+                        Strategy
+                    >::apply(point, *it, strategy);
+
+                if (interior_code != -1)
+                {
+                    // If 0, return 0 (touch)
+                    // If 1 (inside hole) return -1 (outside polygon)
+                    // If -1 (outside hole) check other holes if any
+                    return -interior_code;
+                }
+            }
+        }
+        return code;
+    }
+};
+
+}} // namespace detail::within
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Tag1 = typename tag<Geometry1>::type,
+    typename Tag2 = typename tag<Geometry2>::type
+>
+struct within: not_implemented<Tag1, Tag2>
+{};
+
+
+template <typename Point, typename Box>
+struct within<Point, Box, point_tag, box_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
+    {
+        return strategy.apply(point, box);
+    }
+};
+
+template <typename Box1, typename Box2>
+struct within<Box1, Box2, box_tag, box_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
+    {
+        assert_dimension_equal<Box1, Box2>();
+        return strategy.apply(box1, box2);
+    }
+};
+
+
+
+template <typename Point, typename Ring>
+struct within<Point, Ring, point_tag, ring_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, Ring const& ring, Strategy const& strategy)
+    {
+        return detail::within::point_in_ring
+            <
+                Point,
+                Ring,
+                order_as_direction<geometry::point_order<Ring>::value>::value,
+                geometry::closure<Ring>::value,
+                Strategy
+            >::apply(point, ring, strategy) == 1;
+    }
+};
+
+template <typename Point, typename Polygon>
+struct within<Point, Polygon, point_tag, polygon_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, Polygon const& polygon, Strategy const& strategy)
+    {
+        return detail::within::point_in_polygon
+            <
+                Point,
+                Polygon,
+                order_as_direction<geometry::point_order<Polygon>::value>::value,
+                geometry::closure<Polygon>::value,
+                Strategy
+            >::apply(point, polygon, strategy) == 1;
+    }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_check12{is completely inside}
+\ingroup within
+\details \details_check12{within, is completely inside}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry which might be within the second geometry
+\param geometry2 \param_geometry which might contain the first geometry
+\return true if geometry1 is completely contained within geometry2,
+    else false
+\note The default strategy is used for within detection
+
+
+\qbk{[include reference/algorithms/within.qbk]}
+
+\qbk{
+[heading Example]
+[within]
+[within_output]
+}
+ */
+template<typename Geometry1, typename Geometry2>
+inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    assert_dimension_equal<Geometry1, Geometry2>();
+
+    typedef typename point_type<Geometry1>::type point_type1;
+    typedef typename point_type<Geometry2>::type point_type2;
+
+    typedef typename strategy::within::services::default_strategy
+        <
+            typename tag<Geometry1>::type,
+            typename tag<Geometry2>::type,
+            typename tag<Geometry1>::type,
+            typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
+            typename tag_cast
+                <
+                    typename cs_tag<point_type1>::type, spherical_tag
+                >::type,
+            typename tag_cast
+                <
+                    typename cs_tag<point_type2>::type, spherical_tag
+                >::type,
+            Geometry1,
+            Geometry2
+        >::type strategy_type;
+
+    return dispatch::within
+        <
+            Geometry1,
+            Geometry2
+        >::apply(geometry1, geometry2, strategy_type());
+}
+
+/*!
+\brief \brief_check12{is completely inside} \brief_strategy
+\ingroup within
+\details \details_check12{within, is completely inside}, \brief_strategy. \details_strategy_reasons
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry which might be within the second geometry
+\param geometry2 \param_geometry which might contain the first geometry
+\param strategy strategy to be used
+\return true if geometry1 is completely contained within geometry2,
+    else false
+
+\qbk{distinguish,with strategy}
+\qbk{[include reference/algorithms/within.qbk]}
+\qbk{
+[heading Available Strategies]
+\* [link geometry.reference.strategies.strategy_within_winding Winding (coordinate system agnostic)]
+\* [link geometry.reference.strategies.strategy_within_franklin Franklin (cartesian)]
+\* [link geometry.reference.strategies.strategy_within_crossings_multiply Crossings Multiply (cartesian)]
+
+[heading Example]
+[within_strategy]
+[within_strategy_output]
+
+}
+*/
+template<typename Geometry1, typename Geometry2, typename Strategy>
+inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2,
+        Strategy const& strategy)
+{
+    concept::within::check
+        <
+            typename tag<Geometry1>::type, 
+            typename tag<Geometry2>::type, 
+            typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
+            Strategy
+        >();
+    concept::check<Geometry1 const>();
+    concept::check<Geometry2 const>();
+    assert_dimension_equal<Geometry1, Geometry2>();
+
+    return dispatch::within
+        <
+            Geometry1,
+            Geometry2
+        >::apply(geometry1, geometry2, strategy);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_WITHIN_HPP
diff --git a/src/boost/geometry/arithmetic/arithmetic.hpp b/src/boost/geometry/arithmetic/arithmetic.hpp
new file mode 100644
index 0000000..6479ecc
--- /dev/null
+++ b/src/boost/geometry/arithmetic/arithmetic.hpp
@@ -0,0 +1,281 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
+#define BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
+
+#include <functional>
+
+#include <boost/call_traits.hpp>
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/util/for_each_coordinate.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template <typename P>
+struct param
+{
+    typedef typename boost::call_traits
+        <
+            typename coordinate_type<P>::type
+        >::param_type type;
+};
+
+
+template <typename C, template <typename> class Function>
+struct value_operation
+{
+    C m_value;
+
+    inline value_operation(C const &value)
+        : m_value(value)
+    {}
+
+    template <typename P, int I>
+    inline void apply(P& point) const
+    {
+        set<I>(point, Function<C>()(get<I>(point), m_value));
+    }
+};
+
+template <typename PointSrc, template <typename> class Function>
+struct point_operation
+{
+    typedef typename coordinate_type<PointSrc>::type coordinate_type;
+    PointSrc const& m_source_point;
+
+    inline point_operation(PointSrc const& point)
+        : m_source_point(point)
+    {}
+
+    template <typename PointDst, int I>
+    inline void apply(PointDst& dest_point) const
+    {
+        set<I>(dest_point,
+            Function<coordinate_type>()(get<I>(dest_point), get<I>(m_source_point)));
+    }
+};
+
+
+template <typename C>
+struct value_assignment
+{
+    C m_value;
+
+    inline value_assignment(C const &value)
+        : m_value(value)
+    {}
+
+    template <typename P, int I>
+    inline void apply(P& point) const
+    {
+        set<I>(point, m_value);
+    }
+};
+
+template <typename PointSrc>
+struct point_assignment
+{
+    PointSrc const& m_source_point;
+
+    inline point_assignment(PointSrc const& point)
+        : m_source_point(point)
+    {}
+
+    template <typename PointDst, int I>
+    inline void apply(PointDst& dest_point) const
+    {
+        set<I>(dest_point, get<I>(m_source_point));
+    }
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+/*!
+    \brief Adds the same value to each coordinate of a point
+    \ingroup arithmetic
+    \details
+    \param p point
+    \param value value to add
+ */
+template <typename Point>
+inline void add_value(Point& p, typename detail::param<Point>::type value)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    for_each_coordinate(p, detail::value_operation<typename coordinate_type<Point>::type, std::plus>(value));
+}
+
+/*!
+    \brief Adds a point to another
+    \ingroup arithmetic
+    \details The coordinates of the second point will be added to those of the first point.
+             The second point is not modified.
+    \param p1 first point
+    \param p2 second point
+ */
+template <typename Point1, typename Point2>
+inline void add_point(Point1& p1, Point2 const& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point2>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
+
+    for_each_coordinate(p1, detail::point_operation<Point2, std::plus>(p2));
+}
+
+/*!
+    \brief Subtracts the same value to each coordinate of a point
+    \ingroup arithmetic
+    \details
+    \param p point
+    \param value value to subtract
+ */
+template <typename Point>
+inline void subtract_value(Point& p, typename detail::param<Point>::type value)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    for_each_coordinate(p, detail::value_operation<typename coordinate_type<Point>::type, std::minus>(value));
+}
+
+/*!
+    \brief Subtracts a point to another
+    \ingroup arithmetic
+    \details The coordinates of the second point will be subtracted to those of the first point.
+             The second point is not modified.
+    \param p1 first point
+    \param p2 second point
+ */
+template <typename Point1, typename Point2>
+inline void subtract_point(Point1& p1, Point2 const& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point2>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
+
+    for_each_coordinate(p1, detail::point_operation<Point2, std::minus>(p2));
+}
+
+/*!
+    \brief Multiplies each coordinate of a point by the same value
+    \ingroup arithmetic
+    \details
+    \param p point
+    \param value value to multiply by
+ */
+template <typename Point>
+inline void multiply_value(Point& p, typename detail::param<Point>::type value)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    for_each_coordinate(p, detail::value_operation<typename coordinate_type<Point>::type, std::multiplies>(value));
+}
+
+/*!
+    \brief Multiplies a point by another
+    \ingroup arithmetic
+    \details The coordinates of the first point will be multiplied by those of the second point.
+             The second point is not modified.
+    \param p1 first point
+    \param p2 second point
+    \note This is *not* a dot, cross or wedge product. It is a mere field-by-field multiplication.
+ */
+template <typename Point1, typename Point2>
+inline void multiply_point(Point1& p1, Point2 const& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point2>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
+
+    for_each_coordinate(p1, detail::point_operation<Point2, std::multiplies>(p2));
+}
+
+/*!
+    \brief Divides each coordinate of the same point by a value
+    \ingroup arithmetic
+    \details
+    \param p point
+    \param value value to divide by
+ */
+template <typename Point>
+inline void divide_value(Point& p, typename detail::param<Point>::type value)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    for_each_coordinate(p, detail::value_operation<typename coordinate_type<Point>::type, std::divides>(value));
+}
+
+/*!
+    \brief Divides a point by another
+    \ingroup arithmetic
+    \details The coordinates of the first point will be divided by those of the second point.
+             The second point is not modified.
+    \param p1 first point
+    \param p2 second point
+ */
+template <typename Point1, typename Point2>
+inline void divide_point(Point1& p1, Point2 const& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point2>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
+
+    for_each_coordinate(p1, detail::point_operation<Point2, std::divides>(p2));
+}
+
+/*!
+    \brief Assign each coordinate of a point the same value
+    \ingroup arithmetic
+    \details
+    \param p point
+    \param value value to assign
+ */
+template <typename Point>
+inline void assign_value(Point& p, typename detail::param<Point>::type value)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    for_each_coordinate(p, detail::value_assignment<typename coordinate_type<Point>::type>(value));
+}
+
+/*!
+    \brief Assign a point with another
+    \ingroup arithmetic
+    \details The coordinates of the first point will be assigned those of the second point.
+             The second point is not modified.
+    \param p1 first point
+    \param p2 second point
+ */
+template <typename Point1, typename Point2>
+inline void assign_point(Point1& p1, const Point2& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point2>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
+
+    for_each_coordinate(p1, detail::point_assignment<Point2>(p2));
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ARITHMETIC_ARITHMETIC_HPP
diff --git a/src/boost/geometry/arithmetic/determinant.hpp b/src/boost/geometry/arithmetic/determinant.hpp
new file mode 100644
index 0000000..db3b867
--- /dev/null
+++ b/src/boost/geometry/arithmetic/determinant.hpp
@@ -0,0 +1,76 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
+#define BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename ReturnType, typename U, typename V>
+class calculate_determinant
+{
+    template <typename T>
+    static inline ReturnType rt(T const& v)
+    {
+        return boost::numeric_cast<ReturnType>(v);
+    }
+
+public :
+
+    static inline ReturnType apply(U const& ux, U const& uy
+                                 , V const& vx, V const& vy)
+    {
+        return rt(ux) * rt(vy) - rt(uy) * rt(vx);
+    }
+};
+
+template <typename ReturnType, typename U, typename V>
+inline ReturnType determinant(U const& ux, U const& uy
+                            , V const& vx, V const& vy)
+{
+    return calculate_determinant
+        <
+            ReturnType, U, V
+        >::apply(ux, uy, vx, vy);
+}
+
+
+template <typename ReturnType, typename U, typename V>
+inline ReturnType determinant(U const& u, V const& v)
+{
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<U>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<V>) );
+
+    return calculate_determinant
+        <
+            ReturnType, 
+            typename geometry::coordinate_type<U>::type,
+            typename geometry::coordinate_type<V>::type
+        >::apply(get<0>(u), get<1>(u), get<0>(v), get<1>(v));
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ARITHMETIC_DETERMINANT_HPP
diff --git a/src/boost/geometry/arithmetic/dot_product.hpp b/src/boost/geometry/arithmetic/dot_product.hpp
new file mode 100644
index 0000000..13fe968
--- /dev/null
+++ b/src/boost/geometry/arithmetic/dot_product.hpp
@@ -0,0 +1,82 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
+#define BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
+
+
+#include <cstddef>
+
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename P1, typename P2, std::size_t Dimension, std::size_t DimensionCount>
+struct dot_product_maker
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+    static inline coordinate_type apply(P1 const& p1, P2 const& p2)
+    {
+        return get<Dimension>(p1) * get<Dimension>(p2)
+            + dot_product_maker<P1, P2, Dimension+1, DimensionCount>::apply(p1, p2);
+    }
+};
+
+template <typename P1, typename P2, std::size_t DimensionCount>
+struct dot_product_maker<P1, P2, DimensionCount, DimensionCount>
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+    static inline coordinate_type apply(P1 const& p1, P2 const& p2)
+    {
+        return get<DimensionCount>(p1) * get<DimensionCount>(p2);
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+    \brief Computes the dot product (or scalar product) of 2 vectors (points).
+    \ingroup arithmetic
+    \param p1 first point
+    \param p2 second point
+    \return the dot product
+ */
+template <typename P1, typename P2>
+inline typename select_coordinate_type<P1, P2>::type dot_product(
+        P1 const& p1, P2 const& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P1>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P2>) );
+
+    return detail::dot_product_maker
+        <
+            P1, P2,
+            0, dimension<P1>::type::value - 1
+        >::apply(p1, p2);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ARITHMETIC_DOT_PRODUCT_HPP
diff --git a/src/boost/geometry/core/access.hpp b/src/boost/geometry/core/access.hpp
new file mode 100644
index 0000000..a463b8c
--- /dev/null
+++ b/src/boost/geometry/core/access.hpp
@@ -0,0 +1,324 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_ACCESS_HPP
+#define BOOST_GEOMETRY_CORE_ACCESS_HPP
+
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/// Index of minimum corner of the box.
+int const min_corner = 0;
+
+/// Index of maximum corner of the box.
+int const max_corner = 1;
+
+namespace traits
+{
+
+/*!
+\brief Traits class which gives access (get,set) to points.
+\ingroup traits
+\par Geometries:
+///     @li point
+\par Specializations should provide, per Dimension
+///     @li static inline T get(G const&)
+///     @li static inline void set(G&, T const&)
+\tparam Geometry geometry-type
+\tparam Dimension dimension to access
+*/
+template <typename Geometry, std::size_t Dimension, typename Enable = void>
+struct access
+{
+   BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Geometry>)
+        );
+};
+
+
+/*!
+\brief Traits class defining "get" and "set" to get
+    and set point coordinate values
+\tparam Geometry geometry (box, segment)
+\tparam Index index (min_corner/max_corner for box, 0/1 for segment)
+\tparam Dimension dimension
+\par Geometries:
+    - box
+    - segment
+\par Specializations should provide:
+    - static inline T get(G const&)
+    - static inline void set(G&, T const&)
+\ingroup traits
+*/
+template <typename Geometry, std::size_t Index, std::size_t Dimension>
+struct indexed_access {};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename
+    CoordinateType, std::size_t Dimension
+>
+struct access
+{
+    //static inline T get(G const&) {}
+    //static inline void set(G& g, T const& value) {}
+};
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename CoordinateType,
+    std::size_t Index,
+    std::size_t Dimension
+>
+struct indexed_access
+{
+    //static inline T get(G const&) {}
+    //static inline void set(G& g, T const& value) {}
+};
+
+template <typename Point, typename CoordinateType, std::size_t Dimension>
+struct access<point_tag, Point, CoordinateType, Dimension>
+{
+    static inline CoordinateType get(Point const& point)
+    {
+        return traits::access<Point, Dimension>::get(point);
+    }
+    static inline void set(Point& p, CoordinateType const& value)
+    {
+        traits::access<Point, Dimension>::set(p, value);
+    }
+};
+
+template
+<
+    typename Box,
+    typename CoordinateType,
+    std::size_t Index,
+    std::size_t Dimension
+>
+struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension>
+{
+    static inline CoordinateType get(Box const& box)
+    {
+        return traits::indexed_access<Box, Index, Dimension>::get(box);
+    }
+    static inline void set(Box& b, CoordinateType const& value)
+    {
+        traits::indexed_access<Box, Index, Dimension>::set(b, value);
+    }
+};
+
+template
+<
+    typename Segment,
+    typename CoordinateType,
+    std::size_t Index,
+    std::size_t Dimension
+>
+struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension>
+{
+    static inline CoordinateType get(Segment const& segment)
+    {
+        return traits::indexed_access<Segment, Index, Dimension>::get(segment);
+    }
+    static inline void set(Segment& segment, CoordinateType const& value)
+    {
+        traits::indexed_access<Segment, Index, Dimension>::set(segment, value);
+    }
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+// Two dummy tags to distinguish get/set variants below.
+// They don't have to be specified by the user. The functions are distinguished
+// by template signature also, but for e.g. GCC this is not enough. So give them
+// a different signature.
+struct signature_getset_dimension {};
+struct signature_getset_index_dimension {};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief Get coordinate value of a geometry (usually a point)
+\details \details_get_set
+\ingroup get
+\tparam Dimension \tparam_dimension_required
+\tparam Geometry \tparam_geometry (usually a Point Concept)
+\param geometry \param_geometry (usually a point)
+\param dummy \qbk_skip
+\return The coordinate value of specified dimension of specified geometry
+\qbk{[include reference/core/get_point.qbk]}
+*/
+template <std::size_t Dimension, typename Geometry>
+inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
+        , detail::signature_getset_dimension* dummy = 0
+        )
+{
+    boost::ignore_unused_variable_warning(dummy);
+
+    typedef typename boost::remove_const<Geometry>::type ncg_type;
+
+    typedef core_dispatch::access
+        <
+            typename tag<Geometry>::type,
+            ncg_type,
+            typename coordinate_type<ncg_type>::type,
+            Dimension
+        > coord_access_type;
+
+    return coord_access_type::get(geometry);
+}
+
+
+/*!
+\brief Set coordinate value of a geometry (usually a point)
+\details \details_get_set
+\tparam Dimension \tparam_dimension_required
+\tparam Geometry \tparam_geometry (usually a Point Concept)
+\param geometry geometry to assign coordinate to
+\param geometry \param_geometry (usually a point)
+\param value The coordinate value to set
+\param dummy \qbk_skip
+\ingroup set
+
+\qbk{[include reference/core/set_point.qbk]}
+*/
+template <std::size_t Dimension, typename Geometry>
+inline void set(Geometry& geometry
+        , typename coordinate_type<Geometry>::type const& value
+        , detail::signature_getset_dimension* dummy = 0
+        )
+{
+    boost::ignore_unused_variable_warning(dummy);
+
+    typedef typename boost::remove_const<Geometry>::type ncg_type;
+
+    typedef core_dispatch::access
+        <
+            typename tag<Geometry>::type,
+            ncg_type,
+            typename coordinate_type<ncg_type>::type,
+            Dimension
+        > coord_access_type;
+
+    coord_access_type::set(geometry, value);
+}
+
+
+/*!
+\brief get coordinate value of a Box or Segment
+\details \details_get_set
+\tparam Index \tparam_index_required
+\tparam Dimension \tparam_dimension_required
+\tparam Geometry \tparam_box_or_segment
+\param geometry \param_geometry
+\param dummy \qbk_skip
+\return coordinate value
+\ingroup get
+
+\qbk{distinguish,with index}
+\qbk{[include reference/core/get_box.qbk]}
+*/
+template <std::size_t Index, std::size_t Dimension, typename Geometry>
+inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
+        , detail::signature_getset_index_dimension* dummy = 0
+        )
+{
+    boost::ignore_unused_variable_warning(dummy);
+
+    typedef typename boost::remove_const<Geometry>::type ncg_type;
+
+    typedef core_dispatch::indexed_access
+        <
+            typename tag<Geometry>::type,
+            ncg_type,
+            typename coordinate_type<ncg_type>::type,
+            Index,
+            Dimension
+        > coord_access_type;
+
+    return coord_access_type::get(geometry);
+}
+
+/*!
+\brief set coordinate value of a Box / Segment
+\details \details_get_set
+\tparam Index \tparam_index_required
+\tparam Dimension \tparam_dimension_required
+\tparam Geometry \tparam_box_or_segment
+\param geometry geometry to assign coordinate to
+\param geometry \param_geometry
+\param value The coordinate value to set
+\param dummy \qbk_skip
+\ingroup set
+
+\qbk{distinguish,with index}
+\qbk{[include reference/core/set_box.qbk]}
+*/
+template <std::size_t Index, std::size_t Dimension, typename Geometry>
+inline void set(Geometry& geometry
+        , typename coordinate_type<Geometry>::type const& value
+        , detail::signature_getset_index_dimension* dummy = 0
+        )
+{
+    boost::ignore_unused_variable_warning(dummy);
+
+    typedef typename boost::remove_const<Geometry>::type ncg_type;
+
+    typedef core_dispatch::indexed_access
+        <
+            typename tag<Geometry>::type, ncg_type,
+            typename coordinate_type<ncg_type>::type,
+            Index,
+            Dimension
+        > coord_access_type;
+
+    coord_access_type::set(geometry, value);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_ACCESS_HPP
diff --git a/src/boost/geometry/core/closure.hpp b/src/boost/geometry/core/closure.hpp
new file mode 100644
index 0000000..aab02e7
--- /dev/null
+++ b/src/boost/geometry/core/closure.hpp
@@ -0,0 +1,180 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_CLOSURE_HPP
+#define BOOST_GEOMETRY_CORE_CLOSURE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/range.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief Enumerates options for defining if polygons are open or closed
+\ingroup enum
+\details The enumeration closure_selector describes options for if a polygon is
+    open or closed. In a closed polygon the very first point (per ring) should 
+    be equal to the very last point.
+    The specific closing property of a polygon type is defined by the closure 
+    metafunction. The closure metafunction defines a value, which is one of the 
+    values enumerated in the closure_selector
+
+\qbk{
+[heading See also]
+[link geometry.reference.core.closure The closure metafunction]
+}
+*/
+enum closure_selector
+{
+    /// Rings are open: first point and last point are different, algorithms 
+    /// close them explicitly on the fly
+    open = 0,
+    /// Rings are closed: first point and last point must be the same
+    closed = 1,
+    /// (Not yet implemented): algorithms first figure out if ring must be 
+    /// closed on the fly
+    closure_undertermined = -1
+};
+
+namespace traits
+{
+
+/*!
+    \brief Traits class indicating if points within a
+        ring or (multi)polygon are closed (last point == first point),
+        open or not known.
+    \ingroup traits
+    \par Geometries:
+        - ring
+    \tparam G geometry
+*/
+template <typename G>
+struct closure
+{
+    static const closure_selector value = closed;
+};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace core_detail { namespace closure
+{
+
+struct closed
+{
+    static const closure_selector value = geometry::closed;
+};
+
+
+/// Metafunction to define the minimum size of a ring:
+/// 3 for open rings, 4 for closed rings
+template <closure_selector Closure>
+struct minimum_ring_size {};
+
+template <>
+struct minimum_ring_size<geometry::closed> : boost::mpl::int_<4> {};
+
+template <>
+struct minimum_ring_size<geometry::open> : boost::mpl::int_<3> {};
+
+
+}} // namespace detail::point_order
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct closure
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Box>
+struct closure<point_tag, Box> : public core_detail::closure::closed {};
+
+template <typename Box>
+struct closure<box_tag, Box> : public core_detail::closure::closed {};
+
+template <typename Box>
+struct closure<segment_tag, Box> : public core_detail::closure::closed {};
+
+template <typename LineString>
+struct closure<linestring_tag, LineString> 
+    : public core_detail::closure::closed {};
+
+
+template <typename Ring>
+struct closure<ring_tag, Ring>
+{
+    static const closure_selector value 
+        = geometry::traits::closure<Ring>::value;
+};
+
+// Specialization for polygon: the closure is the closure of its rings
+template <typename Polygon>
+struct closure<polygon_tag, Polygon>
+{
+    static const closure_selector value = core_dispatch::closure
+        <
+            ring_tag,
+            typename ring_type<polygon_tag, Polygon>::type
+        >::value ;
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_meta{value, closure (clockwise\, counterclockwise), 
+    \meta_geometry_type}
+\tparam Geometry \tparam_geometry
+\ingroup core
+
+\qbk{[include reference/core/closure.qbk]}
+*/
+template <typename Geometry>
+struct closure
+{
+    static const closure_selector value = core_dispatch::closure
+        <
+            typename tag<Geometry>::type,
+            typename boost::remove_const<Geometry>::type
+        >::value;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_CLOSURE_HPP
diff --git a/src/boost/geometry/core/coordinate_dimension.hpp b/src/boost/geometry/core/coordinate_dimension.hpp
new file mode 100644
index 0000000..84c11e2
--- /dev/null
+++ b/src/boost/geometry/core/coordinate_dimension.hpp
@@ -0,0 +1,126 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP
+#define BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP
+
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/equal_to.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+\brief Traits class indicating the number of dimensions of a point
+\par Geometries:
+    - point
+\par Specializations should provide:
+    - value (should be derived from boost::mpl::int_<D>
+\ingroup traits
+*/
+template <typename Point, typename Enable = void>
+struct dimension
+{
+   BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
+        );
+};
+
+} // namespace traits
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+// Base class derive from its own specialization of point-tag
+template <typename T, typename G>
+struct dimension : dimension<point_tag, typename point_type<T, G>::type> {};
+
+template <typename P>
+struct dimension<point_tag, P> : traits::dimension<P> {};
+
+} // namespace core_dispatch
+#endif
+
+/*!
+\brief \brief_meta{value, number of coordinates (the number of axes of any geometry), \meta_point_type}
+\tparam Geometry \tparam_geometry
+\ingroup core
+
+\qbk{[include reference/core/coordinate_dimension.qbk]}
+*/
+template <typename Geometry>
+struct dimension
+    : core_dispatch::dimension
+        <
+            typename tag<Geometry>::type,
+            typename boost::remove_const<Geometry>::type
+        >
+{};
+
+/*!
+\brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected
+\ingroup utility
+*/
+template <typename Geometry, int Dimensions>
+inline void assert_dimension()
+{
+    BOOST_STATIC_ASSERT((
+        boost::mpl::equal_to
+        <
+            geometry::dimension<Geometry>,
+            boost::mpl::int_<Dimensions>
+        >::type::value
+        ));
+}
+
+/*!
+\brief assert_dimension, enables compile-time checking if coordinate dimensions are as expected
+\ingroup utility
+*/
+template <typename Geometry, int Dimensions>
+inline void assert_dimension_less_equal()
+{
+    BOOST_STATIC_ASSERT(( dimension<Geometry>::type::value <= Dimensions ));
+}
+
+template <typename Geometry, int Dimensions>
+inline void assert_dimension_greater_equal()
+{
+    BOOST_STATIC_ASSERT(( dimension<Geometry>::type::value >= Dimensions ));
+}
+
+/*!
+\brief assert_dimension_equal, enables compile-time checking if coordinate dimensions of two geometries are equal
+\ingroup utility
+*/
+template <typename G1, typename G2>
+inline void assert_dimension_equal()
+{
+    BOOST_STATIC_ASSERT(( dimension<G1>::type::value == dimension<G2>::type::value ));
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_COORDINATE_DIMENSION_HPP
diff --git a/src/boost/geometry/core/coordinate_system.hpp b/src/boost/geometry/core/coordinate_system.hpp
new file mode 100644
index 0000000..c23b8af
--- /dev/null
+++ b/src/boost/geometry/core/coordinate_system.hpp
@@ -0,0 +1,97 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP
+#define BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace traits
+{
+
+/*!
+\brief Traits class defining the coordinate system of a point, important for strategy selection
+\ingroup traits
+\par Geometries:
+    - point
+\par Specializations should provide:
+    - typedef CS type; (cs::cartesian, cs::spherical, etc)
+*/
+template <typename Point, typename Enable = void>
+struct coordinate_system
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
+        );
+};
+
+} // namespace traits
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+    template <typename GeometryTag, typename G>
+    struct coordinate_system
+    {
+        typedef typename point_type<GeometryTag, G>::type P;
+
+        // Call its own specialization on point-tag
+        typedef typename coordinate_system<point_tag, P>::type type;
+    };
+
+
+    template <typename P>
+    struct coordinate_system<point_tag, P>
+    {
+        typedef typename traits::coordinate_system<P>::type type;
+    };
+
+
+} // namespace core_dispatch
+#endif
+
+
+/*!
+\brief \brief_meta{type, coordinate system (cartesian\, spherical\, etc), \meta_point_type}
+\tparam Geometry \tparam_geometry
+\ingroup core
+
+\qbk{[include reference/core/coordinate_system.qbk]}
+*/
+template <typename Geometry>
+struct coordinate_system
+{
+    typedef typename boost::remove_const<Geometry>::type ncg;
+    typedef typename core_dispatch::coordinate_system
+        <
+            typename tag<Geometry>::type,
+            ncg
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_COORDINATE_SYSTEM_HPP
diff --git a/src/boost/geometry/core/coordinate_type.hpp b/src/boost/geometry/core/coordinate_type.hpp
new file mode 100644
index 0000000..0f901d3
--- /dev/null
+++ b/src/boost/geometry/core/coordinate_type.hpp
@@ -0,0 +1,102 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
+#define BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/util/promote_floating_point.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+\brief Traits class which indicate the coordinate type (double,float,...) of a point
+\ingroup traits
+\par Geometries:
+    - point
+\par Specializations should provide:
+    - typedef T type; (double,float,int,etc)
+*/
+template <typename Point, typename Enable = void>
+struct coordinate_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Point>)
+        );
+};
+
+} // namespace traits
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename GeometryTag, typename Geometry>
+struct coordinate_type
+{
+    typedef typename point_type<GeometryTag, Geometry>::type point_type;
+
+    // Call its own specialization on point-tag
+    typedef typename coordinate_type<point_tag, point_type>::type type;
+};
+
+template <typename Point>
+struct coordinate_type<point_tag, Point>
+{
+    typedef typename traits::coordinate_type<Point>::type type;
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+/*!
+\brief \brief_meta{type, coordinate type (int\, float\, double\, etc), \meta_point_type}
+\tparam Geometry \tparam_geometry
+\ingroup core
+
+\qbk{[include reference/core/coordinate_type.qbk]}
+*/
+template <typename Geometry>
+struct coordinate_type
+{
+    typedef typename core_dispatch::coordinate_type
+        <
+            typename tag<Geometry>::type,
+            typename boost::remove_const<Geometry>::type
+        >::type type;
+};
+
+template <typename Geometry>
+struct fp_coordinate_type
+{
+    typedef typename promote_floating_point
+        <
+            typename coordinate_type<Geometry>::type
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP
diff --git a/src/boost/geometry/core/cs.hpp b/src/boost/geometry/core/cs.hpp
new file mode 100644
index 0000000..3588ed1
--- /dev/null
+++ b/src/boost/geometry/core/cs.hpp
@@ -0,0 +1,220 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_CS_HPP
+#define BOOST_GEOMETRY_CORE_CS_HPP
+
+#include <cstddef>
+
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/coordinate_system.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Unit of plane angle: Degrees
+\details Tag defining the unit of plane angle for spherical coordinate systems.
+    This tag specifies that coordinates are defined in degrees (-180 .. 180). 
+    It has to be specified for some coordinate systems.
+\qbk{[include reference/core/degree_radian.qbk]}
+*/
+struct degree {};
+
+
+/*!
+\brief Unit of plane angle: Radians
+\details Tag defining the unit of plane angle for spherical coordinate systems.
+    This tag specifies that coordinates are defined in radians (-PI .. PI). 
+    It has to be specified for some coordinate systems.
+\qbk{[include reference/core/degree_radian.qbk]}
+*/
+struct radian {};
+
+
+namespace cs
+{
+
+/*!
+\brief Cartesian coordinate system
+\details Defines the Cartesian or rectangular coordinate system
+    where points are defined in 2 or 3 (or more)
+dimensions and usually (but not always) known as x,y,z
+\see http://en.wikipedia.org/wiki/Cartesian_coordinate_system
+\ingroup cs
+*/
+struct cartesian {};
+
+
+
+
+/*!
+\brief Geographic coordinate system, in degree or in radian
+\details Defines the geographic coordinate system where points
+    are defined in two angles and usually
+known as lat,long or lo,la or phi,lambda
+\see http://en.wikipedia.org/wiki/Geographic_coordinate_system
+\ingroup cs
+\note might be moved to extensions/gis/geographic
+*/
+template<typename DegreeOrRadian>
+struct geographic
+{
+    typedef DegreeOrRadian units;
+};
+
+
+
+/*!
+\brief Spherical (polar) coordinate system, in degree or in radian
+\details Defines the spherical coordinate system where points are
+    defined in two angles
+    and an optional radius usually known as r, theta, phi
+\par Coordinates:
+- coordinate 0:
+    0 <= phi < 2pi is the angle between the positive x-axis and the
+        line from the origin to the P projected onto the xy-plane.
+- coordinate 1:
+    0 <= theta <= pi is the angle between the positive z-axis and the
+        line formed between the origin and P.
+- coordinate 2 (if specified):
+    r >= 0 is the distance from the origin to a given point P.
+
+\see http://en.wikipedia.org/wiki/Spherical_coordinates
+\ingroup cs
+*/
+template<typename DegreeOrRadian>
+struct spherical
+{
+    typedef DegreeOrRadian units;
+};
+
+
+/*!
+\brief Spherical equatorial coordinate system, in degree or in radian
+\details This one resembles the geographic coordinate system, and has latitude
+    up from zero at the equator, to 90 at the pole 
+    (opposite to the spherical(polar) coordinate system).
+    Used in astronomy and in GIS (but there is also the geographic)
+
+\see http://en.wikipedia.org/wiki/Spherical_coordinates
+\ingroup cs
+*/
+template<typename DegreeOrRadian>
+struct spherical_equatorial
+{
+    typedef DegreeOrRadian units;
+};
+
+
+
+/*!
+\brief Polar coordinate system
+\details Defines the polar coordinate system "in which each point
+    on a plane is determined by an angle and a distance"
+\see http://en.wikipedia.org/wiki/Polar_coordinates
+\ingroup cs
+*/
+template<typename DegreeOrRadian>
+struct polar
+{
+    typedef DegreeOrRadian units;
+};
+
+
+} // namespace cs
+
+
+namespace traits
+{
+
+/*!
+\brief Traits class defining coordinate system tag, bound to coordinate system
+\ingroup traits
+\tparam CoordinateSystem coordinate system
+*/
+template <typename CoordinateSystem>
+struct cs_tag
+{
+};
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+template<typename DegreeOrRadian>
+struct cs_tag<cs::geographic<DegreeOrRadian> >
+{
+    typedef geographic_tag type;
+};
+
+template<typename DegreeOrRadian>
+struct cs_tag<cs::spherical<DegreeOrRadian> >
+{
+    typedef spherical_polar_tag type;
+};
+
+template<typename DegreeOrRadian>
+struct cs_tag<cs::spherical_equatorial<DegreeOrRadian> >
+{
+    typedef spherical_equatorial_tag type;
+};
+
+
+template<>
+struct cs_tag<cs::cartesian>
+{
+    typedef cartesian_tag type;
+};
+
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+} // namespace traits
+
+/*!
+\brief Meta-function returning coordinate system tag (cs family) of any geometry
+\ingroup core
+*/
+template <typename G>
+struct cs_tag
+{
+    typedef typename traits::cs_tag
+        <
+            typename geometry::coordinate_system<G>::type
+        >::type type;
+};
+
+
+/*!
+\brief Meta-function to verify if a coordinate system is radian
+\ingroup core
+*/
+template <typename CoordinateSystem>
+struct is_radian : boost::true_type {};
+
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+// Specialization for any degree coordinate systems
+template <template<typename> class CoordinateSystem>
+struct is_radian< CoordinateSystem<degree> > : boost::false_type
+{
+};
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_CS_HPP
diff --git a/src/boost/geometry/core/exception.hpp b/src/boost/geometry/core/exception.hpp
new file mode 100644
index 0000000..97d249e
--- /dev/null
+++ b/src/boost/geometry/core/exception.hpp
@@ -0,0 +1,60 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_EXCEPTION_HPP
+#define BOOST_GEOMETRY_CORE_EXCEPTION_HPP
+
+#include <exception>
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Base exception class for Boost.Geometry algorithms
+\ingroup core
+\details This class is never thrown. All exceptions thrown in Boost.Geometry
+    are derived from exception, so it might be convenient to catch it.
+*/
+class exception : public std::exception
+{};
+
+
+/*!
+\brief Empty Input Exception
+\ingroup core
+\details The empty_input_exception is thrown if free functions, e.g. distance,
+    are called with empty geometries, e.g. a linestring
+    without points, a polygon without points, an empty multi-geometry.
+\qbk{
+[heading See also]
+\* [link geometry.reference.algorithms.area the area function]
+\* [link geometry.reference.algorithms.distance the distance function]
+\* [link geometry.reference.algorithms.length the length function]
+}
+ */
+class empty_input_exception : public geometry::exception
+{
+public:
+
+    inline empty_input_exception() {}
+
+    virtual char const* what() const throw()
+    {
+        return "Boost.Geometry Empty-Input exception";
+    }
+};
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_EXCEPTION_HPP
diff --git a/src/boost/geometry/core/exterior_ring.hpp b/src/boost/geometry/core/exterior_ring.hpp
new file mode 100644
index 0000000..70012c2
--- /dev/null
+++ b/src/boost/geometry/core/exterior_ring.hpp
@@ -0,0 +1,144 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP
+#define BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/util/add_const_if_c.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+
+/*!
+    \brief Traits class defining access to exterior_ring of a polygon
+    \details Should define const and non const access
+    \ingroup traits
+    \tparam Polygon the polygon type
+    \par Geometries:
+        - polygon
+    \par Specializations should provide:
+        - static inline RING& get(POLY& )
+        - static inline RING const& get(POLY const& )
+*/
+template <typename Polygon>
+struct exterior_ring
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POLYGON_TYPE
+            , (types<Polygon>)
+        );
+};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename Tag, typename Geometry>
+struct exterior_ring
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Polygon>
+struct exterior_ring<polygon_tag, Polygon>
+{
+    static
+    typename geometry::ring_return_type<Polygon>::type
+        apply(typename add_const_if_c
+            <
+                boost::is_const<Polygon>::type::value,
+                Polygon
+            >::type& polygon)
+    {
+        return traits::exterior_ring
+            <
+                typename boost::remove_const<Polygon>::type
+            >::get(polygon);
+    }
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+    \brief Function to get the exterior_ring ring of a polygon
+    \ingroup exterior_ring
+    \note OGC compliance: instead of ExteriorRing
+    \tparam P polygon type
+    \param polygon the polygon to get the exterior ring from
+    \return a reference to the exterior ring
+*/
+template <typename Polygon>
+inline typename ring_return_type<Polygon>::type exterior_ring(Polygon& polygon)
+{
+    return core_dispatch::exterior_ring
+        <
+            typename tag<Polygon>::type,
+            Polygon
+        >::apply(polygon);
+}
+
+
+/*!
+\brief Function to get the exterior ring of a polygon (const version)
+\ingroup exterior_ring
+\note OGC compliance: instead of ExteriorRing
+\tparam Polygon polygon type
+\param polygon the polygon to get the exterior ring from
+\return a const reference to the exterior ring
+
+\qbk{distinguish,const version}
+*/
+template <typename Polygon>
+inline typename ring_return_type<Polygon const>::type exterior_ring(
+        Polygon const& polygon)
+{
+    return core_dispatch::exterior_ring
+        <
+            typename tag<Polygon>::type,
+            Polygon const
+        >::apply(polygon);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_EXTERIOR_RING_HPP
diff --git a/src/boost/geometry/core/geometry_id.hpp b/src/boost/geometry/core/geometry_id.hpp
new file mode 100644
index 0000000..369c5cf
--- /dev/null
+++ b/src/boost/geometry/core/geometry_id.hpp
@@ -0,0 +1,94 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
+#define BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/type_traits.hpp>
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename GeometryTag>
+struct geometry_id
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<GeometryTag>)
+        );
+};
+
+
+template <>
+struct geometry_id<point_tag>      : boost::mpl::int_<1> {};
+
+
+template <>
+struct geometry_id<linestring_tag> : boost::mpl::int_<2> {};
+
+
+template <>
+struct geometry_id<polygon_tag>    : boost::mpl::int_<3> {};
+
+
+template <>
+struct geometry_id<segment_tag>    : boost::mpl::int_<92> {};
+
+
+template <>
+struct geometry_id<ring_tag>       : boost::mpl::int_<93> {};
+
+
+template <>
+struct geometry_id<box_tag>        : boost::mpl::int_<94> {};
+
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+/*!
+\brief Meta-function returning the id of a geometry type
+\details The meta-function geometry_id defines a numerical ID (based on 
+    boost::mpl::int_<...> ) for each geometry concept. A numerical ID is 
+    sometimes useful, and within Boost.Geometry it is used for the 
+    reverse_dispatch metafuntion.
+\note Used for e.g. reverse meta-function
+\ingroup core
+*/
+template <typename Geometry>
+struct geometry_id : core_dispatch::geometry_id<typename tag<Geometry>::type>
+{};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_GEOMETRY_ID_HPP
diff --git a/src/boost/geometry/core/interior_rings.hpp b/src/boost/geometry/core/interior_rings.hpp
new file mode 100644
index 0000000..10af2ae
--- /dev/null
+++ b/src/boost/geometry/core/interior_rings.hpp
@@ -0,0 +1,139 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
+#define BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/interior_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+
+/*!
+    \brief Traits class defining access to interior_rings of a polygon
+    \details defines access (const and non const) to interior ring
+    \ingroup traits
+    \par Geometries:
+        - polygon
+    \par Specializations should provide:
+        - static inline INTERIOR& get(POLY&)
+        - static inline const INTERIOR& get(POLY const&)
+    \tparam Geometry geometry
+*/
+template <typename Geometry>
+struct interior_rings
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+} // namespace traits
+
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template
+<
+    typename GeometryTag,
+    typename Geometry
+>
+struct interior_rings {};
+
+
+template <typename Polygon>
+struct interior_rings<polygon_tag, Polygon>
+{
+    static inline
+    typename geometry::interior_return_type<Polygon>::type
+                apply(Polygon& polygon)
+    {
+        return traits::interior_rings
+            <
+                typename boost::remove_const<Polygon>::type
+            >::get(polygon);
+    }
+};
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+/*!
+\brief Function to get the interior rings of a polygon (non const version)
+\ingroup interior_rings
+\note OGC compliance: instead of InteriorRingN
+\tparam Polygon polygon type
+\param polygon the polygon to get the interior rings from
+\return the interior rings (possibly a reference)
+*/
+
+template <typename Polygon>
+inline typename interior_return_type<Polygon>::type interior_rings(Polygon& polygon)
+{
+    return core_dispatch::interior_rings
+        <
+            typename tag<Polygon>::type,
+            Polygon
+        >::apply(polygon);
+}
+
+
+/*!
+\brief Function to get the interior rings of a polygon (const version)
+\ingroup interior_rings
+\note OGC compliance: instead of InteriorRingN
+\tparam Polygon polygon type
+\param polygon the polygon to get the interior rings from
+\return the interior rings (possibly a const reference)
+
+\qbk{distinguish,const version}
+*/
+template <typename Polygon>
+inline typename interior_return_type<Polygon const>::type interior_rings(
+            Polygon const& polygon)
+{
+    return core_dispatch::interior_rings
+        <
+            typename tag<Polygon>::type,
+            Polygon const
+        >::apply(polygon);
+}
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_INTERIOR_RINGS_HPP
diff --git a/src/boost/geometry/core/interior_type.hpp b/src/boost/geometry/core/interior_type.hpp
new file mode 100644
index 0000000..0232837
--- /dev/null
+++ b/src/boost/geometry/core/interior_type.hpp
@@ -0,0 +1,161 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP
+#define BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+\brief Traits class indicating interior container type of a polygon
+\details defines inner container type, so the container containing
+        the interior rings
+\ingroup traits
+\par Geometries:
+    - polygon
+\par Specializations should provide:
+    - typedef X type ( e.g. std::vector<myring<P>> )
+\tparam Geometry geometry
+*/
+template <typename Geometry>
+struct interior_const_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Geometry>
+struct interior_mutable_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+} // namespace traits
+
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename GeometryTag, typename Geometry>
+struct interior_return_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Polygon>
+struct interior_return_type<polygon_tag, Polygon>
+{
+    typedef typename boost::remove_const<Polygon>::type nc_polygon_type;
+
+    typedef typename mpl::if_
+        <
+            boost::is_const<Polygon>,
+            typename traits::interior_const_type<nc_polygon_type>::type,
+            typename traits::interior_mutable_type<nc_polygon_type>::type
+        >::type type;
+};
+
+
+
+
+template <typename GeometryTag, typename Geometry>
+struct interior_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Polygon>
+struct interior_type<polygon_tag, Polygon>
+{
+    typedef typename boost::remove_reference
+        <
+            typename interior_return_type<polygon_tag, Polygon>::type
+        >::type type;
+};
+
+
+} // namespace core_dispatch
+#endif
+
+
+/*!
+\brief \brief_meta{type, interior_type (container type
+    of inner rings), \meta_geometry_type}
+\details Interior rings should be organized as a container
+    (std::vector, std::deque, boost::array) with
+    Boost.Range support. This metafunction defines the type
+    of the container.
+\tparam Geometry A type fullfilling the Polygon or MultiPolygon concept.
+\ingroup core
+
+\qbk{[include reference/core/interior_type.qbk]}
+*/
+template <typename Geometry>
+struct interior_type
+{
+    typedef typename core_dispatch::interior_type
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::type type;
+};
+
+template <typename Geometry>
+struct interior_return_type
+{
+    typedef typename core_dispatch::interior_return_type
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_INTERIOR_TYPE_HPP
diff --git a/src/boost/geometry/core/is_areal.hpp b/src/boost/geometry/core/is_areal.hpp
new file mode 100644
index 0000000..5ddfa75
--- /dev/null
+++ b/src/boost/geometry/core/is_areal.hpp
@@ -0,0 +1,60 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_IS_AREAL_HPP
+#define BOOST_GEOMETRY_CORE_IS_AREAL_HPP
+
+
+#include <boost/type_traits.hpp>
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename GeometryTag> struct is_areal : boost::false_type {};
+
+template <> struct is_areal<ring_tag> : boost::true_type {};
+template <> struct is_areal<box_tag> : boost::true_type {};
+template <> struct is_areal<polygon_tag> : boost::true_type {};
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+/*!
+    \brief Meta-function defining "true" for areal types (box, (multi)polygon, ring),
+    \note Used for tag dispatching and meta-function finetuning
+    \note Also a "ring" has areal properties within Boost.Geometry
+    \ingroup core
+*/
+template <typename Geometry>
+struct is_areal : core_dispatch::is_areal<typename tag<Geometry>::type>
+{};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_IS_AREAL_HPP
diff --git a/src/boost/geometry/core/mutable_range.hpp b/src/boost/geometry/core/mutable_range.hpp
new file mode 100644
index 0000000..9b53e40
--- /dev/null
+++ b/src/boost/geometry/core/mutable_range.hpp
@@ -0,0 +1,98 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP
+#define BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP
+
+
+#include <cstddef>
+
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/range.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace traits
+{
+
+/*!
+\brief Metafunction to define the argument passed to the three
+    traits classes clear, push_back and resize
+\ingroup mutable_range
+ */
+template <typename Range>
+struct rvalue_type
+{
+    typedef typename boost::remove_reference<Range>::type& type;
+};
+
+
+/*!
+\brief Traits class to clear a geometry
+\ingroup mutable_range
+ */
+template <typename Range>
+struct clear
+{
+    static inline void apply(typename rvalue_type<Range>::type range)
+    {
+        range.clear();
+    }
+};
+
+
+/*!
+\brief Traits class to append a point to a range (ring, linestring, multi*)
+\ingroup mutable_range
+ */
+template <typename Range>
+struct push_back
+{
+    typedef typename boost::range_value
+        <
+            typename boost::remove_reference<Range>::type
+        >::type item_type;
+
+    static inline void apply(typename rvalue_type<Range>::type range,
+                 item_type const& item)
+    {
+        range.push_back(item);
+    }
+};
+
+
+/*!
+\brief Traits class to append a point to a range (ring, linestring, multi*)
+\ingroup mutable_range
+ */
+template <typename Range>
+struct resize
+{
+    static inline void apply(typename rvalue_type<Range>::type range,
+                std::size_t new_size)
+    {
+        range.resize(new_size);
+    }
+};
+
+
+} // namespace traits
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP
diff --git a/src/boost/geometry/core/point_order.hpp b/src/boost/geometry/core/point_order.hpp
new file mode 100644
index 0000000..f09086a
--- /dev/null
+++ b/src/boost/geometry/core/point_order.hpp
@@ -0,0 +1,162 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_POINT_ORDER_HPP
+#define BOOST_GEOMETRY_CORE_POINT_ORDER_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Enumerates options for the order of points within polygons
+\ingroup enum
+\details The enumeration order_selector describes options for the order of 
+    points within a polygon. Polygons can be ordered either clockwise or 
+    counterclockwise. The specific order of a polygon type is defined by the 
+    point_order metafunction. The point_order metafunction defines a value, 
+    which is one of the values enumerated in the order_selector
+
+\qbk{
+[heading See also]
+[link geometry.reference.core.point_order The point_order metafunction]
+}
+*/
+enum order_selector
+{
+    /// Points are ordered clockwise
+    clockwise = 1,
+    /// Points are ordered counter clockwise
+    counterclockwise = 2,
+    /// Points might be stored in any order, algorithms will determine it on the
+    /// fly (not yet supported)
+    order_undetermined = 0
+};
+
+namespace traits
+{
+
+/*!
+\brief Traits class indicating the order of contained points within a
+    ring or (multi)polygon, clockwise, counter clockwise or not known.
+\ingroup traits
+\tparam Ring ring
+*/
+template <typename Ring>
+struct point_order
+{
+    static const order_selector value = clockwise;
+};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace point_order
+{
+
+struct clockwise
+{
+    static const order_selector value = geometry::clockwise;
+};
+
+
+}} // namespace detail::point_order
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct point_order
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Point>
+struct point_order<point_tag, Point>
+    : public detail::point_order::clockwise {};
+
+template <typename Segment>
+struct point_order<segment_tag, Segment>
+    : public detail::point_order::clockwise {};
+
+
+template <typename Box>
+struct point_order<box_tag, Box>
+    : public detail::point_order::clockwise {};
+
+template <typename LineString>
+struct point_order<linestring_tag, LineString>
+    : public detail::point_order::clockwise {};
+
+
+template <typename Ring>
+struct point_order<ring_tag, Ring>
+{
+    static const order_selector value 
+        = geometry::traits::point_order<Ring>::value;
+};
+
+// Specialization for polygon: the order is the order of its rings
+template <typename Polygon>
+struct point_order<polygon_tag, Polygon>
+{
+    static const order_selector value = core_dispatch::point_order
+        <
+            ring_tag,
+            typename ring_type<polygon_tag, Polygon>::type
+        >::value ;
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_meta{value, point order (clockwise\, counterclockwise), 
+    \meta_geometry_type}
+\tparam Geometry \tparam_geometry
+\ingroup core
+
+\qbk{[include reference/core/point_order.qbk]}
+*/
+template <typename Geometry>
+struct point_order
+{
+    static const order_selector value = core_dispatch::point_order
+        <
+            typename tag<Geometry>::type,
+            typename boost::remove_const<Geometry>::type
+        >::value;
+};
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_POINT_ORDER_HPP
diff --git a/src/boost/geometry/core/point_type.hpp b/src/boost/geometry/core/point_type.hpp
new file mode 100644
index 0000000..f49a43c
--- /dev/null
+++ b/src/boost/geometry/core/point_type.hpp
@@ -0,0 +1,130 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_POINT_TYPE_HPP
+#define BOOST_GEOMETRY_CORE_POINT_TYPE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+\brief Traits class indicating the type of contained points
+\ingroup traits
+\par Geometries:
+    - all geometries except point
+\par Specializations should provide:
+    - typedef P type (where P should fulfil the Point concept)
+\tparam Geometry geometry
+*/
+template <typename Geometry>
+struct point_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE, (types<Geometry>)
+        );
+};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct point_type
+{
+    // Default: call traits to get point type
+    typedef typename boost::remove_const
+        <
+            typename traits::point_type<Geometry>::type
+        >::type type;
+};
+
+
+// Specialization for point: the point itself
+template <typename Point>
+struct point_type<point_tag, Point>
+{
+    typedef Point type;
+};
+
+
+// Specializations for linestring/ring, via boost::range
+template <typename Linestring>
+struct point_type<linestring_tag, Linestring>
+{
+    typedef typename boost::range_value<Linestring>::type type;
+};
+
+
+template <typename Ring>
+struct point_type<ring_tag, Ring>
+{
+    typedef typename boost::range_value<Ring>::type type;
+};
+
+
+// Specialization for polygon: the point-type is the point-type of its rings
+template <typename Polygon>
+struct point_type<polygon_tag, Polygon>
+{
+    typedef typename point_type
+        <
+            ring_tag,
+            typename ring_type<polygon_tag, Polygon>::type
+        >::type type;
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief \brief_meta{type, point_type, \meta_geometry_type}
+\tparam Geometry \tparam_geometry 
+\ingroup core
+
+\qbk{[include reference/core/point_type.qbk]}
+*/
+template <typename Geometry>
+struct point_type
+{
+    typedef typename boost::remove_const<Geometry>::type ncg;
+    typedef typename core_dispatch::point_type
+        <
+            typename tag<Geometry>::type,
+            ncg
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_POINT_TYPE_HPP
diff --git a/src/boost/geometry/core/radian_access.hpp b/src/boost/geometry/core/radian_access.hpp
new file mode 100644
index 0000000..bac77d7
--- /dev/null
+++ b/src/boost/geometry/core/radian_access.hpp
@@ -0,0 +1,152 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_RADIAN_ACCESS_HPP
+#define BOOST_GEOMETRY_CORE_RADIAN_ACCESS_HPP
+
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+
+#include <boost/geometry/util/math.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template<std::size_t Dimension, typename Geometry>
+struct degree_radian_converter
+{
+    typedef typename fp_coordinate_type<Geometry>::type coordinate_type;
+
+    static inline coordinate_type get(Geometry const& geometry)
+    {
+        return boost::numeric_cast
+            <
+                coordinate_type
+            >(geometry::get<Dimension>(geometry) * geometry::math::d2r);
+    }
+
+    static inline void set(Geometry& geometry, coordinate_type const& radians)
+    {
+        geometry::set<Dimension>(geometry, boost::numeric_cast
+            <
+                coordinate_type
+            >(radians * geometry::math::r2d));
+    }
+
+};
+
+
+// Default, radian (or any other coordinate system) just works like "get"
+template <std::size_t Dimension, typename Geometry, typename DegreeOrRadian>
+struct radian_access
+{
+    typedef typename fp_coordinate_type<Geometry>::type coordinate_type;
+
+    static inline coordinate_type get(Geometry const& geometry)
+    {
+        return geometry::get<Dimension>(geometry);
+    }
+
+    static inline void set(Geometry& geometry, coordinate_type const& radians)
+    {
+        geometry::set<Dimension>(geometry, radians);
+    }
+};
+
+// Specialize, any "degree" coordinate system will be converted to radian
+// but only for dimension 0,1 (so: dimension 2 and heigher are untouched)
+
+template
+<
+    typename Geometry,
+    template<typename> class CoordinateSystem
+>
+struct radian_access<0, Geometry, CoordinateSystem<degree> >
+    : degree_radian_converter<0, Geometry>
+{};
+
+
+template
+<
+    typename Geometry,
+    template<typename> class CoordinateSystem
+>
+struct radian_access<1, Geometry, CoordinateSystem<degree> >
+    : degree_radian_converter<1, Geometry>
+{};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief get coordinate value of a point, result is in Radian
+\details Result is in Radian, even if source coordinate system
+    is in Degrees
+\return coordinate value
+\ingroup get
+\tparam Dimension dimension
+\tparam Geometry geometry
+\param geometry geometry to get coordinate value from
+\note Only applicable to coordinate systems templatized by units,
+    e.g. spherical or geographic coordinate systems
+*/
+template <std::size_t Dimension, typename Geometry>
+inline typename fp_coordinate_type<Geometry>::type get_as_radian(Geometry const& geometry)
+{
+    return detail::radian_access<Dimension, Geometry,
+            typename coordinate_system<Geometry>::type>::get(geometry);
+}
+
+
+/*!
+\brief set coordinate value (in radian) to a point
+\details Coordinate value will be set correctly, if coordinate system of
+    point is in Degree, Radian value will be converted to Degree
+\ingroup set
+\tparam Dimension dimension
+\tparam Geometry geometry
+\param geometry geometry to assign coordinate to
+\param radians coordinate value to assign
+\note Only applicable to coordinate systems templatized by units,
+    e.g. spherical or geographic coordinate systems
+*/
+template <std::size_t Dimension, typename Geometry>
+inline void set_from_radian(Geometry& geometry,
+            typename fp_coordinate_type<Geometry>::type const& radians)
+{
+    detail::radian_access<Dimension, Geometry,
+            typename coordinate_system<Geometry>::type>::set(geometry, radians);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_RADIAN_ACCESS_HPP
diff --git a/src/boost/geometry/core/reverse_dispatch.hpp b/src/boost/geometry/core/reverse_dispatch.hpp
new file mode 100644
index 0000000..2e4fb80
--- /dev/null
+++ b/src/boost/geometry/core/reverse_dispatch.hpp
@@ -0,0 +1,67 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_REVERSE_DISPATCH_HPP
+#define BOOST_GEOMETRY_CORE_REVERSE_DISPATCH_HPP
+
+
+#include <cstddef>
+
+#include <boost/type_traits.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/greater.hpp>
+
+#include <boost/geometry/core/geometry_id.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+// Different geometries: reverse_dispatch if second ID < first ID
+template <std::size_t GeometryId1, std::size_t GeometryId2>
+struct reverse_dispatch : boost::mpl::if_c
+    <
+        (GeometryId1 > GeometryId2),
+        boost::true_type,
+        boost::false_type
+    >
+{};
+
+
+// Same geometry: never reverse_dispatch
+template <std::size_t GeometryId>
+struct reverse_dispatch<GeometryId, GeometryId> : boost::false_type {};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+template <typename Geometry1, typename Geometry2>
+struct reverse_dispatch : detail::reverse_dispatch
+    <
+        geometry_id<Geometry1>::type::value,
+        geometry_id<Geometry2>::type::value
+    >
+{};
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_REVERSE_DISPATCH_HPP
diff --git a/src/boost/geometry/core/ring_type.hpp b/src/boost/geometry/core/ring_type.hpp
new file mode 100644
index 0000000..9b984fa
--- /dev/null
+++ b/src/boost/geometry/core/ring_type.hpp
@@ -0,0 +1,170 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_RING_TYPE_HPP
+#define BOOST_GEOMETRY_CORE_RING_TYPE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+
+/*!
+\brief Traits class to indicate ring-type  of a polygon's exterior ring/interior rings
+\ingroup traits
+\par Geometries:
+    - polygon
+\par Specializations should provide:
+    - typedef XXX type ( e.g. ring<P> )
+\tparam Geometry geometry
+*/
+template <typename Geometry>
+struct ring_const_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Geometry>
+struct ring_mutable_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename GeometryTag, typename Geometry>
+struct ring_return_type
+{};
+
+
+template <typename LineString>
+struct ring_return_type<linestring_tag, LineString>
+{
+    typedef LineString& type;
+};
+
+
+template <typename Ring>
+struct ring_return_type<ring_tag, Ring>
+{
+    typedef Ring& type;
+};
+
+
+template <typename Polygon>
+struct ring_return_type<polygon_tag, Polygon>
+{
+    typedef typename boost::remove_const<Polygon>::type nc_polygon_type;
+
+    typedef typename mpl::if_
+        <
+            boost::is_const<Polygon>,
+            typename traits::ring_const_type<nc_polygon_type>::type,
+            typename traits::ring_mutable_type<nc_polygon_type>::type
+        >::type type;
+};
+
+
+template <typename GeometryTag, typename Geometry>
+struct ring_type
+{};
+
+
+template <typename Ring>
+struct ring_type<ring_tag, Ring>
+{
+    typedef Ring type;
+};
+
+
+template <typename Polygon>
+struct ring_type<polygon_tag, Polygon>
+{
+    typedef typename boost::remove_reference
+        <
+            typename ring_return_type<polygon_tag, Polygon>::type
+        >::type type;
+};
+
+
+
+
+
+} // namespace core_dispatch
+#endif
+
+
+/*!
+\brief \brief_meta{type, ring_type, \meta_geometry_type}
+\details A polygon contains one exterior ring
+    and zero or more interior rings (holes).
+    This metafunction retrieves the type of the rings.
+    Exterior ring and each of the interior rings all have the same ring_type.
+\tparam Geometry A type fullfilling the Ring, Polygon or MultiPolygon concept.
+\ingroup core
+
+\qbk{[include reference/core/ring_type.qbk]}
+*/
+template <typename Geometry>
+struct ring_type
+{
+    typedef typename core_dispatch::ring_type
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::type type;
+};
+
+
+template <typename Geometry>
+struct ring_return_type
+{
+    typedef typename core_dispatch::ring_return_type
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_RING_TYPE_HPP
diff --git a/src/boost/geometry/core/tag.hpp b/src/boost/geometry/core/tag.hpp
new file mode 100644
index 0000000..5a99c97
--- /dev/null
+++ b/src/boost/geometry/core/tag.hpp
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_TAG_HPP
+#define BOOST_GEOMETRY_CORE_TAG_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+\brief Traits class to attach a tag to a geometry
+\details All geometries should implement a traits::tag<G>::type metafunction to indicate their
+    own geometry type.
+\ingroup traits
+\par Geometries:
+    - all geometries
+\par Specializations should provide:
+    - typedef XXX_tag type; (point_tag, box_tag, ...)
+\tparam Geometry geometry
+*/
+template <typename Geometry, typename Enable = void>
+struct tag
+{
+    typedef void type;
+};
+
+} // namespace traits
+
+
+/*!
+\brief \brief_meta{type, tag, \meta_geometry_type}
+\details With Boost.Geometry, tags are the driving force of the tag dispatching
+    mechanism. The tag metafunction is therefore used in every free function.
+\tparam Geometry \tparam_geometry 
+\ingroup core
+
+\qbk{[include reference/core/tag.qbk]}
+*/
+template <typename Geometry>
+struct tag
+{
+    typedef typename traits::tag
+        <
+            typename boost::remove_const<Geometry>::type
+        >::type type;
+};
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_TAG_HPP
diff --git a/src/boost/geometry/core/tag_cast.hpp b/src/boost/geometry/core/tag_cast.hpp
new file mode 100644
index 0000000..47a2e83
--- /dev/null
+++ b/src/boost/geometry/core/tag_cast.hpp
@@ -0,0 +1,84 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_TAG_CAST_HPP
+#define BOOST_GEOMETRY_CORE_TAG_CAST_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Metafunction defining a type being either the specified tag, or one
+    of the specified basetags if the type inherits from them.
+\details Tags can inherit each other. A multi_point inherits, for example,
+    both the multi_tag and the pointlike tag. Often behaviour can be shared
+    between different geometry types. A tag, found by the metafunction tag,
+    can be casted to a more basic tag, and then dispatched by that tag.
+\ingroup core    
+\tparam Tag The tag to be casted to one of the base tags
+\tparam BaseTag First base tag
+\tparam BaseTag2 Optional second base tag
+\tparam BaseTag3 Optional third base tag
+\tparam BaseTag4 Optional fourth base tag
+\tparam BaseTag5 Optional fifth base tag
+\tparam BaseTag6 Optional sixth base tag
+\tparam BaseTag7 Optional seventh base tag
+
+\qbk{[include reference/core/tag_cast.qbk]}
+*/
+template
+<
+    typename Tag,
+    typename BaseTag,
+    typename BaseTag2 = void,
+    typename BaseTag3 = void,
+    typename BaseTag4 = void,
+    typename BaseTag5 = void,
+    typename BaseTag6 = void,
+    typename BaseTag7 = void
+>
+struct tag_cast
+{
+    typedef typename boost::mpl::if_
+        <
+          typename boost::is_base_of<BaseTag, Tag>::type,
+          BaseTag,
+          // Try next one in line:
+          typename tag_cast
+            <
+                Tag, BaseTag2, BaseTag3, BaseTag4,
+                BaseTag5, BaseTag6, BaseTag7, void
+            >::type
+        >::type type;
+};
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+// Specialization for last one
+template <typename Tag>
+struct tag_cast<Tag, void, void, void, void, void, void, void>
+{
+    // If not found, take specified tag, so do not cast
+    typedef Tag type;
+};
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_TAG_CAST_HPP
diff --git a/src/boost/geometry/core/tags.hpp b/src/boost/geometry/core/tags.hpp
new file mode 100644
index 0000000..9272858
--- /dev/null
+++ b/src/boost/geometry/core/tags.hpp
@@ -0,0 +1,94 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_TAGS_HPP
+#define BOOST_GEOMETRY_CORE_TAGS_HPP
+
+
+namespace boost { namespace geometry
+{
+
+// Tags defining strategies linked to coordinate systems
+
+/// Tag used for casting spherical/geographic coordinate systems
+struct spherical_tag {};
+
+
+/// Tag indicating Cartesian coordinate system family (cartesian,epsg)
+struct cartesian_tag {};
+
+/// Tag indicating Spherical polar coordinate system family
+struct spherical_polar_tag : spherical_tag {};
+
+/// Tag indicating Spherical equatorial coordinate system family
+struct spherical_equatorial_tag : spherical_tag {};
+
+/// Tag indicating Geographic coordinate system family (geographic)
+struct geographic_tag : spherical_tag {};
+
+
+
+// Tags defining tag hierarchy
+
+/// For single-geometries (point, linestring, polygon, box, ring, segment)
+struct single_tag {};
+
+
+/// For multiple-geometries (multi_point, multi_linestring, multi_polygon)
+struct multi_tag {};
+
+/// For point-like types (point, multi_point)
+struct pointlike_tag {};
+
+/// For linear types (linestring, multi-linestring, segment)
+struct linear_tag {};
+
+/// For areal types (polygon, multi_polygon, box, ring)
+struct areal_tag {};
+
+// Subset of areal types (polygon, multi_polygon, ring)
+struct polygonal_tag : areal_tag {}; 
+
+/// For volume types (also box (?), polyhedron)
+struct volumetric_tag {};
+
+
+// Tags defining geometry types
+
+
+/// "default" tag
+struct geometry_not_recognized_tag {};
+
+/// OGC Point identifying tag
+struct point_tag : single_tag, pointlike_tag {};
+
+/// OGC Linestring identifying tag
+struct linestring_tag : single_tag, linear_tag {};
+
+/// OGC Polygon identifying tag
+struct polygon_tag : single_tag, polygonal_tag {};
+
+/// Convenience (linear) ring identifying tag
+struct ring_tag : single_tag, polygonal_tag {};
+
+/// Convenience 2D or 3D box (mbr / aabb) identifying tag
+struct box_tag : single_tag, areal_tag {};
+
+/// Convenience segment (2-points) identifying tag
+struct segment_tag : single_tag, linear_tag {};
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_TAGS_HPP
diff --git a/src/boost/geometry/core/topological_dimension.hpp b/src/boost/geometry/core/topological_dimension.hpp
new file mode 100644
index 0000000..02f1ed3
--- /dev/null
+++ b/src/boost/geometry/core/topological_dimension.hpp
@@ -0,0 +1,88 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
+#define BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
+
+
+#include <boost/mpl/int.hpp>
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename GeometryTag>
+struct top_dim {};
+
+
+template <>
+struct top_dim<point_tag>      : boost::mpl::int_<0> {};
+
+
+template <>
+struct top_dim<linestring_tag> : boost::mpl::int_<1> {};
+
+
+template <>
+struct top_dim<segment_tag>    : boost::mpl::int_<1> {};
+
+
+// ring: topological dimension of two, but some people say: 1 !!
+template <>
+struct top_dim<ring_tag>       : boost::mpl::int_<2> {};
+
+
+template <>
+struct top_dim<box_tag>        : boost::mpl::int_<2> {};
+
+
+template <>
+struct top_dim<polygon_tag>    : boost::mpl::int_<2> {};
+
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+
+
+/*!
+    \brief Meta-function returning the topological dimension of a geometry
+    \details The topological dimension defines a point as 0-dimensional,
+        a linestring as 1-dimensional,
+        and a ring or polygon as 2-dimensional.
+    \see http://www.math.okstate.edu/mathdept/dynamics/lecnotes/node36.html
+    \ingroup core
+*/
+template <typename Geometry>
+struct topological_dimension
+    : core_dispatch::top_dim<typename tag<Geometry>::type> {};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_TOPOLOGICAL_DIMENSION_HPP
diff --git a/src/boost/geometry/domains/gis/io/io.hpp b/src/boost/geometry/domains/gis/io/io.hpp
new file mode 100644
index 0000000..39703e3
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/io.hpp
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_HPP
+
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp>
+
+namespace boost { namespace geometry
+{
+
+struct format_wkt {};
+struct format_wkb {};
+struct format_dsv {};
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct read
+{
+};
+
+template <typename Geometry>
+struct read<format_wkt, Geometry>
+{
+    static inline void apply(Geometry& geometry, std::string const& wkt)
+    {
+        read_wkt<typename tag<Geometry>::type, Geometry>::apply(wkt, geometry);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+template <typename Format, typename Geometry>
+inline void read(Geometry& geometry, std::string const& wkt)
+{
+    geometry::concept::check<Geometry>();
+    dispatch::read<Format, Geometry>::apply(geometry, wkt);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/detail/wkt.hpp b/src/boost/geometry/domains/gis/io/wkt/detail/wkt.hpp
new file mode 100644
index 0000000..576a168
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/detail/wkt.hpp
@@ -0,0 +1,49 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_HPP
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt {
+
+
+struct prefix_point
+{
+    static inline const char* apply() { return "POINT"; }
+};
+
+struct prefix_polygon
+{
+    static inline const char* apply() { return "POLYGON"; }
+};
+
+struct prefix_linestring
+{
+    static inline const char* apply() { return "LINESTRING"; }
+};
+
+
+
+}} // namespace wkt::impl
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/detail/wkt_multi.hpp b/src/boost/geometry/domains/gis/io/wkt/detail/wkt_multi.hpp
new file mode 100644
index 0000000..abfbd28
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/detail/wkt_multi.hpp
@@ -0,0 +1,56 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_MULTI_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_MULTI_HPP
+
+
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt {
+
+struct prefix_null
+{
+    static inline const char* apply() { return ""; }
+};
+
+struct prefix_multipoint
+{
+    static inline const char* apply() { return "MULTIPOINT"; }
+};
+
+struct prefix_multilinestring
+{
+    static inline const char* apply() { return "MULTILINESTRING"; }
+};
+
+struct prefix_multipolygon
+{
+    static inline const char* apply() { return "MULTIPOLYGON"; }
+};
+
+
+
+}} // namespace wkt::impl
+#endif
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_MULTI_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/read_wkt.hpp b/src/boost/geometry/domains/gis/io/wkt/read_wkt.hpp
new file mode 100644
index 0000000..bc534a2
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/read_wkt.hpp
@@ -0,0 +1,692 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_READ_WKT_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_READ_WKT_HPP
+
+#include <string>
+
+#include <boost/lexical_cast.hpp>
+#include <boost/tokenizer.hpp>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/range.hpp>
+
+
+#include <boost/type_traits.hpp>
+
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/exception.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/geometry_id.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/coordinate_cast.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/detail/wkt.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+
+/*!
+\brief Exception showing things wrong with WKT parsing
+\ingroup wkt
+*/
+struct read_wkt_exception : public geometry::exception
+{
+    template <typename Iterator>
+    read_wkt_exception(std::string const& msg,
+            Iterator const& it, Iterator const& end, std::string const& wkt)
+        : message(msg)
+        , wkt(wkt)
+    {
+        if (it != end)
+        {
+            source = " at '";
+            source += it->c_str();
+            source += "'";
+        }
+        complete = message + source + " in '" + wkt.substr(0, 100) + "'";
+    }
+
+    read_wkt_exception(std::string const& msg, std::string const& wkt)
+        : message(msg)
+        , wkt(wkt)
+    {
+        complete = message + "' in (" + wkt.substr(0, 100) + ")";
+    }
+
+    virtual ~read_wkt_exception() throw() {}
+
+    virtual const char* what() const throw()
+    {
+        return complete.c_str();
+    }
+private :
+    std::string source;
+    std::string message;
+    std::string wkt;
+    std::string complete;
+};
+
+
+
+#ifndef DOXYGEN_NO_DETAIL
+// (wkt: Well Known Text, defined by OGC for all geometries and implemented by e.g. databases (MySQL, PostGIS))
+namespace detail { namespace wkt {
+
+typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+
+template <typename Point, std::size_t Dimension, std::size_t DimensionCount>
+struct parsing_assigner
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+            Point& point, std::string const& wkt)
+    {
+        typedef typename coordinate_type<Point>::type coordinate_type;
+
+        // Stop at end of tokens, or at "," ot ")"
+        bool finished = (it == end || *it == "," || *it == ")");
+
+        try
+        {
+            // Initialize missing coordinates to default constructor (zero)
+            // OR
+            // Use lexical_cast for conversion to double/int
+            // Note that it is much slower than atof. However, it is more standard
+            // and in parsing the change in performance falls probably away against
+            // the tokenizing
+            set<Dimension>(point, finished
+                    ? coordinate_type()
+                    : coordinate_cast<coordinate_type>::apply(*it));
+        }
+        catch(boost::bad_lexical_cast const& blc)
+        {
+            throw read_wkt_exception(blc.what(), it, end, wkt);
+        }
+        catch(std::exception const& e)
+        {
+            throw read_wkt_exception(e.what(), it, end, wkt);
+        }
+        catch(...)
+        {
+            throw read_wkt_exception("", it, end, wkt);
+        }
+
+        parsing_assigner<Point, Dimension + 1, DimensionCount>::apply(
+                        (finished ? it : ++it), end, point, wkt);
+    }
+};
+
+template <typename Point, std::size_t DimensionCount>
+struct parsing_assigner<Point, DimensionCount, DimensionCount>
+{
+    static inline void apply(tokenizer::iterator&, tokenizer::iterator, Point&,
+                std::string const&)
+    {
+    }
+};
+
+
+
+template <typename Iterator>
+inline void handle_open_parenthesis(Iterator& it,
+            Iterator const& end, std::string const& wkt)
+{
+    if (it == end || *it != "(")
+    {
+        throw read_wkt_exception("Expected '('", it, end, wkt);
+    }
+    ++it;
+}
+
+
+template <typename Iterator>
+inline void handle_close_parenthesis(Iterator& it,
+            Iterator const& end, std::string const& wkt)
+{
+    if (it != end && *it == ")")
+    {
+        ++it;
+    }
+    else
+    {
+        throw read_wkt_exception("Expected ')'", it, end, wkt);
+    }
+}
+
+template <typename Iterator>
+inline void check_end(Iterator& it,
+            Iterator const& end, std::string const& wkt)
+{
+    if (it != end)
+    {
+        throw read_wkt_exception("Too much tokens", it, end, wkt);
+    }
+}
+
+/*!
+\brief Internal, parses coordinate sequences, strings are formated like "(1 2,3 4,...)"
+\param it token-iterator, should be pre-positioned at "(", is post-positions after last ")"
+\param end end-token-iterator
+\param out Output itererator receiving coordinates
+*/
+template <typename Point>
+struct container_inserter
+{
+    // Version with output iterator
+    template <typename OutputIterator>
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, OutputIterator out)
+    {
+        handle_open_parenthesis(it, end, wkt);
+
+        Point point;
+
+        // Parse points until closing parenthesis
+
+        while (it != end && *it != ")")
+        {
+            parsing_assigner
+                <
+                    Point,
+                    0,
+                    dimension<Point>::value
+                >::apply(it, end, point, wkt);
+            out = point;
+            ++out;
+            if (it != end && *it == ",")
+            {
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+
+// Geometry is a value-type or reference-type
+template <typename Geometry>
+struct container_appender
+{
+    typedef typename geometry::point_type
+        <
+            typename boost::remove_reference<Geometry>::type
+        >::type point_type;
+
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, Geometry out)
+    {
+        handle_open_parenthesis(it, end, wkt);
+
+        point_type point;
+
+        // Parse points until closing parenthesis
+
+        while (it != end && *it != ")")
+        {
+            parsing_assigner
+                <
+                    point_type,
+                    0,
+                    dimension<point_type>::value
+                >::apply(it, end, point, wkt);
+
+            geometry::append(out, point);
+            if (it != end && *it == ",")
+            {
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+/*!
+\brief Internal, parses a point from a string like this "(x y)"
+\note used for parsing points and multi-points
+*/
+template <typename P>
+struct point_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, P& point)
+    {
+        handle_open_parenthesis(it, end, wkt);
+        parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt);
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+
+template <typename Geometry>
+struct linestring_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+                std::string const& wkt, Geometry& geometry)
+    {
+        container_appender<Geometry&>::apply(it, end, wkt, geometry);
+    }
+};
+
+
+template <typename Ring>
+struct ring_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+                std::string const& wkt, Ring& ring)
+    {
+        // A ring should look like polygon((x y,x y,x y...))
+        // So handle the extra opening/closing parentheses
+        // and in between parse using the container-inserter
+        handle_open_parenthesis(it, end, wkt);
+        container_appender<Ring&>::apply(it, end, wkt, ring);
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+
+
+
+/*!
+\brief Internal, parses a polygon from a string like this "((x y,x y),(x y,x y))"
+\note used for parsing polygons and multi-polygons
+*/
+template <typename Polygon>
+struct polygon_parser
+{
+    typedef typename ring_return_type<Polygon>::type ring_return_type;
+    typedef container_appender<ring_return_type> appender;
+
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+                std::string const& wkt, Polygon& poly)
+    {
+
+        handle_open_parenthesis(it, end, wkt);
+
+        int n = -1;
+
+        // Stop at ")"
+        while (it != end && *it != ")")
+        {
+            // Parse ring
+            if (++n == 0)
+            {
+                appender::apply(it, end, wkt, exterior_ring(poly));
+            }
+            else
+            {
+                typename ring_type<Polygon>::type ring;
+                appender::apply(it, end, wkt, ring);
+                traits::push_back
+                    <
+                        typename boost::remove_reference
+                        <
+                            typename traits::interior_mutable_type<Polygon>::type
+                        >::type
+                    >::apply(interior_rings(poly), ring);
+            }
+
+            if (it != end && *it == ",")
+            {
+                // Skip "," after ring is parsed
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+inline bool one_of(tokenizer::iterator const& it, std::string const& value,
+            bool& is_present)
+{
+    if (boost::iequals(*it, value))
+    {
+        is_present = true;
+        return true;
+    }
+    return false;
+}
+
+inline bool one_of(tokenizer::iterator const& it, std::string const& value,
+            bool& present1, bool& present2)
+{
+    if (boost::iequals(*it, value))
+    {
+        present1 = true;
+        present2 = true;
+        return true;
+    }
+    return false;
+}
+
+
+inline void handle_empty_z_m(tokenizer::iterator& it, tokenizer::iterator end,
+            bool& has_empty, bool& has_z, bool& has_m)
+{
+    has_empty = false;
+    has_z = false;
+    has_m = false;
+
+    // WKT can optionally have Z and M (measured) values as in
+    // POINT ZM (1 1 5 60), POINT M (1 1 80), POINT Z (1 1 5)
+    // GGL supports any of them as coordinate values, but is not aware
+    // of any Measured value.
+    while (it != end
+           && (one_of(it, "M", has_m)
+               || one_of(it, "Z", has_z)
+               || one_of(it, "EMPTY", has_empty)
+               || one_of(it, "MZ", has_m, has_z)
+               || one_of(it, "ZM", has_z, has_m)
+               )
+           )
+    {
+        ++it;
+    }
+}
+
+/*!
+\brief Internal, starts parsing
+\param tokens boost tokens, parsed with separator " " and keeping separator "()"
+\param geometry string to compare with first token
+*/
+template <typename Geometry>
+inline bool initialize(tokenizer const& tokens,
+            std::string const& geometry_name, std::string const& wkt,
+            tokenizer::iterator& it)
+{
+    it = tokens.begin();
+    if (it != tokens.end() && boost::iequals(*it++, geometry_name))
+    {
+        bool has_empty, has_z, has_m;
+
+        handle_empty_z_m(it, tokens.end(), has_empty, has_z, has_m);
+
+        if (has_z && dimension<Geometry>::type::value < 3)
+        {
+            throw read_wkt_exception("Z only allowed for 3 or more dimensions", wkt);
+        }
+        if (has_empty)
+        {
+            check_end(it, tokens.end(), wkt);
+            return false;
+        }
+        // M is ignored at all.
+
+        return true;
+    }
+    throw read_wkt_exception(std::string("Should start with '") + geometry_name + "'", wkt);
+}
+
+
+template <typename Geometry, template<typename> class Parser, typename PrefixPolicy>
+struct geometry_parser
+{
+    static inline void apply(std::string const& wkt, Geometry& geometry)
+    {
+        geometry::clear(geometry);
+
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it;
+        if (initialize<Geometry>(tokens, PrefixPolicy::apply(), wkt, it))
+        {
+            Parser<Geometry>::apply(it, tokens.end(), wkt, geometry);
+            check_end(it, tokens.end(), wkt);
+        }
+    }
+};
+
+
+
+
+
+/*!
+\brief Supports box parsing
+\note OGC does not define the box geometry, and WKT does not support boxes.
+    However, to be generic GGL supports reading and writing from and to boxes.
+    Boxes are outputted as a standard POLYGON. GGL can read boxes from
+    a standard POLYGON, from a POLYGON with 2 points of from a BOX
+\tparam Box the box
+*/
+template <typename Box>
+struct box_parser
+{
+    static inline void apply(std::string const& wkt, Box& box)
+    {
+        bool should_close = false;
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it = tokens.begin();
+        tokenizer::iterator end = tokens.end();
+        if (it != end && boost::iequals(*it, "POLYGON"))
+        {
+            ++it;
+            bool has_empty, has_z, has_m;
+            handle_empty_z_m(it, end, has_empty, has_z, has_m);
+            if (has_empty)
+            {
+                assign_zero(box);
+                return;
+            }
+            handle_open_parenthesis(it, end, wkt);
+            should_close = true;
+        }
+        else if (it != end && boost::iequals(*it, "BOX"))
+        {
+            ++it;
+        }
+        else
+        {
+            throw read_wkt_exception("Should start with 'POLYGON' or 'BOX'", wkt);
+        }
+
+        typedef typename point_type<Box>::type point_type;
+        std::vector<point_type> points;
+        container_inserter<point_type>::apply(it, end, wkt, std::back_inserter(points));
+
+        if (should_close)
+        {
+            handle_close_parenthesis(it, end, wkt);
+        }
+        check_end(it, end, wkt);
+
+        int index = 0;
+        int n = boost::size(points);
+        if (n == 2)
+        {
+            index = 1;
+        }
+        else if (n == 4 || n == 5)
+        {
+            // In case of 4 or 5 points, we do not check the other ones, just
+            // take the opposite corner which is always 2
+            index = 2;
+        }
+        else
+        {
+            throw read_wkt_exception("Box should have 2,4 or 5 points", wkt);
+        }
+
+        geometry::detail::assign_point_to_index<min_corner>(points.front(), box);
+        geometry::detail::assign_point_to_index<max_corner>(points[index], box);
+    }
+};
+
+
+/*!
+\brief Supports segment parsing
+\note OGC does not define the segment, and WKT does not support segmentes.
+    However, it is useful to implement it, also for testing purposes
+\tparam Segment the segment
+*/
+template <typename Segment>
+struct segment_parser
+{
+    static inline void apply(std::string const& wkt, Segment& segment)
+    {
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it = tokens.begin();
+        tokenizer::iterator end = tokens.end();
+        if (it != end &&
+            (boost::iequals(*it, "SEGMENT")
+            || boost::iequals(*it, "LINESTRING") ))
+        {
+            ++it;
+        }
+        else
+        {
+            throw read_wkt_exception("Should start with 'LINESTRING' or 'SEGMENT'", wkt);
+        }
+
+        typedef typename point_type<Segment>::type point_type;
+        std::vector<point_type> points;
+        container_inserter<point_type>::apply(it, end, wkt, std::back_inserter(points));
+
+        check_end(it, end, wkt);
+
+        if (boost::size(points) == 2)
+        {
+            geometry::detail::assign_point_to_index<0>(points.front(), segment);
+            geometry::detail::assign_point_to_index<1>(points.back(), segment);
+        }
+        else
+        {
+            throw read_wkt_exception("Segment should have 2 points", wkt);
+        }
+
+    }
+};
+
+
+
+}} // namespace detail::wkt
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct read_wkt {};
+
+
+template <typename Point>
+struct read_wkt<point_tag, Point>
+    : detail::wkt::geometry_parser
+        <
+            Point,
+            detail::wkt::point_parser,
+            detail::wkt::prefix_point
+        >
+{};
+
+
+template <typename L>
+struct read_wkt<linestring_tag, L>
+    : detail::wkt::geometry_parser
+        <
+            L,
+            detail::wkt::linestring_parser,
+            detail::wkt::prefix_linestring
+        >
+{};
+
+template <typename Ring>
+struct read_wkt<ring_tag, Ring>
+    : detail::wkt::geometry_parser
+        <
+            Ring,
+            detail::wkt::ring_parser,
+            detail::wkt::prefix_polygon
+        >
+{};
+
+template <typename Geometry>
+struct read_wkt<polygon_tag, Geometry>
+    : detail::wkt::geometry_parser
+        <
+            Geometry,
+            detail::wkt::polygon_parser,
+            detail::wkt::prefix_polygon
+        >
+{};
+
+
+// Box (Non-OGC)
+template <typename Box>
+struct read_wkt<box_tag, Box>
+    : detail::wkt::box_parser<Box>
+{};
+
+// Segment (Non-OGC)
+template <typename Segment>
+struct read_wkt<segment_tag, Segment>
+    : detail::wkt::segment_parser<Segment>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Parses OGC Well-Known Text (\ref WKT) into a geometry (any geometry)
+\ingroup wkt
+\param wkt string containing \ref WKT
+\param geometry output geometry
+\par Example:
+\note It is case insensitive and can have the WKT forms "point", "point m", "point z", "point zm", "point mz"
+\note Empty sequences can have forms as "LINESTRING ()" or "POLYGON(())"
+Small example showing how to use read_wkt to build a point
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_point
+\line {
+\until }
+\par Example:
+Small example showing how to use read_wkt to build a linestring
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_linestring
+\line {
+\until }
+\par Example:
+Small example showing how to use read_wkt to build a polygon
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_polygon
+\line {
+\until }
+*/
+template <typename Geometry>
+inline void read_wkt(std::string const& wkt, Geometry& geometry)
+{
+    geometry::concept::check<Geometry>();
+    dispatch::read_wkt<typename tag<Geometry>::type, Geometry>::apply(wkt, geometry);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_READ_WKT_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp b/src/boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp
new file mode 100644
index 0000000..379a9fa
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp
@@ -0,0 +1,112 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_READ_WKT_MULTI_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_READ_WKT_MULTI_HPP
+
+#include <string>
+
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/detail/wkt_multi.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace detail { namespace wkt {
+
+template <typename MultiGeometry, template<typename> class Parser, typename PrefixPolicy>
+struct multi_parser
+{
+    static inline void apply(std::string const& wkt, MultiGeometry& geometry)
+    {
+        traits::clear<MultiGeometry>::apply(geometry);
+
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it;
+        if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it))
+        {
+            handle_open_parenthesis(it, tokens.end(), wkt);
+
+            // Parse sub-geometries
+            while(it != tokens.end() && *it != ")")
+            {
+                traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1);
+                Parser
+                    <
+                        typename boost::range_value<MultiGeometry>::type
+                    >::apply(it, tokens.end(), wkt, geometry.back());
+                if (it != tokens.end() && *it == ",")
+                {
+                    // Skip "," after multi-element is parsed
+                    ++it;
+                }
+            }
+
+            handle_close_parenthesis(it, tokens.end(), wkt);
+        }
+    }
+};
+
+
+
+
+}} // namespace detail::wkt
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiGeometry>
+struct read_wkt<multi_point_tag, MultiGeometry>
+    : detail::wkt::multi_parser
+            <
+                MultiGeometry,
+                detail::wkt::point_parser,
+                detail::wkt::prefix_multipoint
+            >
+{};
+
+
+template <typename MultiGeometry>
+struct read_wkt<multi_linestring_tag, MultiGeometry>
+    : detail::wkt::multi_parser
+            <
+                MultiGeometry,
+                detail::wkt::linestring_parser,
+                detail::wkt::prefix_multilinestring
+            >
+{};
+
+
+template <typename MultiGeometry>
+struct read_wkt<multi_polygon_tag, MultiGeometry>
+    : detail::wkt::multi_parser
+            <
+                MultiGeometry,
+                detail::wkt::polygon_parser,
+                detail::wkt::prefix_multipolygon
+            >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_READ_WKT_MULTI_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/wkt.hpp b/src/boost/geometry/domains/gis/io/wkt/wkt.hpp
new file mode 100644
index 0000000..420e816
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/wkt.hpp
@@ -0,0 +1,25 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WKT_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WKT_HPP
+
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp>
+
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WKT_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/write_wkt.hpp b/src/boost/geometry/domains/gis/io/wkt/write_wkt.hpp
new file mode 100644
index 0000000..7bf52c1
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/write_wkt.hpp
@@ -0,0 +1,394 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WRITE_WKT_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WRITE_WKT_HPP
+
+#include <ostream>
+#include <string>
+
+#include <boost/array.hpp>
+#include <boost/concept/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/detail/wkt.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+template <typename P, int I, int Count>
+struct stream_coordinate
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os, P const& p)
+    {
+        os << (I > 0 ? " " : "") << get<I>(p);
+        stream_coordinate<P, I + 1, Count>::apply(os, p);
+    }
+};
+
+template <typename P, int Count>
+struct stream_coordinate<P, Count, Count>
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>&, P const&)
+    {}
+};
+
+struct prefix_linestring_par
+{
+    static inline const char* apply() { return "LINESTRING("; }
+};
+
+struct prefix_ring_par_par
+{
+    // Note, double parentheses are intentional, indicating WKT ring begin/end
+    static inline const char* apply() { return "POLYGON(("; }
+};
+
+struct opening_parenthesis
+{
+    static inline const char* apply() { return "("; }
+};
+
+struct closing_parenthesis
+{
+    static inline const char* apply() { return ")"; }
+};
+
+struct double_closing_parenthesis
+{
+    static inline const char* apply() { return "))"; }
+};
+
+
+
+
+/*!
+\brief Stream points as \ref WKT
+*/
+template <typename Point, typename Policy>
+struct wkt_point
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os, Point const& p)
+    {
+        os << Policy::apply() << "(";
+        stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p);
+        os << ")";
+    }
+};
+
+/*!
+\brief Stream ranges as WKT
+\note policy is used to stream prefix/postfix, enabling derived classes to override this
+*/
+template <typename Range, typename PrefixPolicy, typename SuffixPolicy>
+struct wkt_range
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Range const& range)
+    {
+        typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+        bool first = true;
+
+        os << PrefixPolicy::apply();
+
+        // TODO: check EMPTY here
+
+        for (iterator_type it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            os << (first ? "" : ",");
+            stream_coordinate
+                <
+                    point_type, 0, dimension<point_type>::type::value
+                >::apply(os, *it);
+            first = false;
+        }
+
+        os << SuffixPolicy::apply();
+    }
+
+private:
+    typedef typename boost::range_value<Range>::type point_type;
+};
+
+/*!
+\brief Stream sequence of points as WKT-part, e.g. (1 2),(3 4)
+\note Used in polygon, all multi-geometries
+*/
+
+
+
+template <typename Range>
+struct wkt_sequence
+    : wkt_range
+        <
+            Range,
+            opening_parenthesis,
+            closing_parenthesis
+        >
+{};
+
+
+template <typename Polygon, typename PrefixPolicy>
+struct wkt_poly
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Polygon const& poly)
+    {
+        typedef typename ring_type<Polygon const>::type ring;
+
+        os << PrefixPolicy::apply();
+        // TODO: check EMPTY here
+        os << "(";
+        wkt_sequence<ring>::apply(os, exterior_ring(poly));
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            os << ",";
+            wkt_sequence<ring>::apply(os, *it);
+        }
+        os << ")";
+    }
+};
+
+
+template <typename Box>
+struct wkt_box
+{
+    typedef typename point_type<Box>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Box const& box)
+    {
+        // Convert to ring, then stream
+        typedef model::ring<point_type> ring_type;
+        ring_type ring;
+        geometry::convert(box, ring);
+        os << "POLYGON(";
+        wkt_sequence<ring_type>::apply(os, ring);
+        os << ")";
+    }
+
+    private:
+
+        inline wkt_box()
+        {
+            // Only streaming of boxes with two dimensions is support, otherwise it is a polyhedron!
+            //assert_dimension<B, 2>();
+        }
+};
+
+
+template <typename Segment>
+struct wkt_segment
+{
+    typedef typename point_type<Segment>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Segment const& segment)
+    {
+        // Convert to two points, then stream
+        typedef boost::array<point_type, 2> sequence;
+
+        sequence points;
+        geometry::detail::assign_point_from_index<0>(segment, points[0]);
+        geometry::detail::assign_point_from_index<1>(segment, points[1]);
+
+        // In Boost.Geometry a segment is represented
+        // in WKT-format like (for 2D): LINESTRING(x y,x y)
+        os << "LINESTRING";
+        wkt_sequence<sequence>::apply(os, points);
+    }
+
+    private:
+
+        inline wkt_segment()
+        {}
+};
+
+}} // namespace detail::wkt
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct wkt
+{
+   BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Point>
+struct wkt<point_tag, Point>
+    : detail::wkt::wkt_point
+        <
+            Point,
+            detail::wkt::prefix_point
+        >
+{};
+
+
+template <typename Linestring>
+struct wkt<linestring_tag, Linestring>
+    : detail::wkt::wkt_range
+        <
+            Linestring,
+            detail::wkt::prefix_linestring_par,
+            detail::wkt::closing_parenthesis
+        >
+{};
+
+
+/*!
+\brief Specialization to stream a box as WKT
+\details A "box" does not exist in WKT.
+It is therefore streamed as a polygon
+*/
+template <typename Box>
+struct wkt<box_tag, Box>
+    : detail::wkt::wkt_box<Box>
+{};
+
+template <typename Segment>
+struct wkt<segment_tag, Segment>
+    : detail::wkt::wkt_segment<Segment>
+{};
+
+
+/*!
+\brief Specialization to stream a ring as WKT
+\details A ring or "linear_ring" does not exist in WKT.
+A ring is equivalent to a polygon without inner rings
+It is therefore streamed as a polygon
+*/
+template <typename Ring>
+struct wkt<ring_tag, Ring>
+    : detail::wkt::wkt_range
+        <
+            Ring,
+            detail::wkt::prefix_ring_par_par,
+            detail::wkt::double_closing_parenthesis
+        >
+{};
+
+
+/*!
+\brief Specialization to stream polygon as WKT
+*/
+template <typename Polygon>
+struct wkt<polygon_tag, Polygon>
+    : detail::wkt::wkt_poly
+        <
+            Polygon,
+            detail::wkt::prefix_polygon
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Generic geometry template manipulator class, takes corresponding output class from traits class
+\ingroup wkt
+\details Stream manipulator, streams geometry classes as \ref WKT streams
+\par Example:
+Small example showing how to use the wkt class
+\dontinclude doxygen_1.cpp
+\skip example_as_wkt_point
+\line {
+\until }
+*/
+template <typename Geometry>
+class wkt_manipulator
+{
+public:
+
+    inline wkt_manipulator(Geometry const& g)
+        : m_geometry(g)
+    {}
+
+    template <typename Char, typename Traits>
+    inline friend std::basic_ostream<Char, Traits>& operator<<(
+            std::basic_ostream<Char, Traits>& os,
+            wkt_manipulator const& m)
+    {
+        dispatch::wkt
+            <
+                typename tag<Geometry>::type,
+                Geometry
+            >::apply(os, m.m_geometry);
+        os.flush();
+        return os;
+    }
+
+private:
+    Geometry const& m_geometry;
+};
+
+/*!
+\brief Main WKT-streaming function
+\ingroup wkt
+\par Example:
+Small example showing how to use the wkt helper function
+\dontinclude doxygen_1.cpp
+\skip example_as_wkt_vector
+\line {
+\until }
+*/
+template <typename Geometry>
+inline wkt_manipulator<Geometry> wkt(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    return wkt_manipulator<Geometry>(geometry);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WRITE_WKT_HPP
diff --git a/src/boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp b/src/boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp
new file mode 100644
index 0000000..f7ee47d
--- /dev/null
+++ b/src/boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp
@@ -0,0 +1,117 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WRITE_WKT_MULTI_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WRITE_WKT_MULTI_HPP
+
+
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/detail/wkt_multi.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+
+template <typename Multi, typename StreamPolicy, typename PrefixPolicy>
+struct wkt_multi
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Multi const& geometry)
+    {
+        os << PrefixPolicy::apply();
+        // TODO: check EMPTY here
+        os << "(";
+
+        for (typename boost::range_iterator<Multi const>::type
+                    it = boost::begin(geometry);
+            it != boost::end(geometry);
+            ++it)
+        {
+            if (it != boost::begin(geometry))
+            {
+                os << ",";
+            }
+            StreamPolicy::apply(os, *it);
+        }
+
+        os << ")";
+    }
+};
+
+}} // namespace wkt::impl
+#endif
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Multi>
+struct wkt<multi_point_tag, Multi>
+    : detail::wkt::wkt_multi
+        <
+            Multi,
+            detail::wkt::wkt_point
+                <
+                    typename boost::range_value<Multi>::type,
+                    detail::wkt::prefix_null
+                >,
+            detail::wkt::prefix_multipoint
+        >
+{};
+
+
+template <typename Multi>
+struct wkt<multi_linestring_tag, Multi>
+    : detail::wkt::wkt_multi
+        <
+            Multi,
+            detail::wkt::wkt_sequence
+                <
+                    typename boost::range_value<Multi>::type
+                >,
+            detail::wkt::prefix_multilinestring
+        >
+{};
+
+
+template <typename Multi>
+struct wkt<multi_polygon_tag, Multi>
+    : detail::wkt::wkt_multi
+        <
+            Multi,
+            detail::wkt::wkt_poly
+                <
+                    typename boost::range_value<Multi>::type,
+                    detail::wkt::prefix_null
+                >,
+            detail::wkt::prefix_multipolygon
+        >
+{};
+
+} // namespace dispatch
+#endif
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_WRITE_WKT_MULTI_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/intersecting_inserter.hpp b/src/boost/geometry/extensions/algorithms/buffer/intersecting_inserter.hpp
new file mode 100644
index 0000000..674f689
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/intersecting_inserter.hpp
@@ -0,0 +1,93 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_INTERSECTING_INSERTER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_INTERSECTING_INSERTER_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template
+<
+    typename Collection  // usually collection of rings
+>
+struct intersecting_inserter
+{
+    typedef typename boost::range_value<Collection>::type item_type;
+    typedef typename geometry::ring_type<item_type>::type ring_type;
+    typedef typename geometry::point_type<ring_type>::type point_type;
+
+    intersecting_inserter(Collection& c)
+        : m_collection(c)
+        , m_index(0)
+    {}
+
+    inline void start_ring()
+    {
+        // clear current ring
+        m_ring.clear();
+        m_index = 0;
+    }
+
+    inline ring_type& get_ring()
+    {
+        return m_ring;
+    }
+
+
+    inline void insert(point_type const& point)
+    {
+        m_ring.push_back(point);
+    }
+
+
+    inline void close_and_insert_ring()
+    {
+        if (boost::size(m_ring) > 0)
+        {
+            // Close the ring
+            point_type p = m_ring.front();
+            insert(p);
+
+            item_type poly;
+            poly.outer() = m_ring;
+            m_collection.push_back(poly);
+        }
+    }
+
+
+private :
+    Collection& m_collection;
+    ring_type m_ring;
+    std::size_t m_index;
+};
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_INTERSECTING_INSERTER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp b/src/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp
new file mode 100644
index 0000000..d0db8c3
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp
@@ -0,0 +1,84 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP
+
+
+#include <boost/geometry/util/math.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+// TODO: once change this to proper strategy
+// It is different from current segment intersection because these are not segments but lines
+// If we have the Line concept, we can create a strategy
+template <typename Point, typename Line1, typename Line2 = Line1>
+struct line_line_intersection
+{
+    template <typename A, typename B, typename C, typename D>
+    static inline A det(A const& a, B const& b, C const& c, D const& d)
+    {
+        return a * d - b * c;
+    }
+
+    static inline bool apply(Line1 const& line1, Line2 const& line2, Point& p)
+    {
+        // See http://mathworld.wolfram.com/Line-LineIntersection.html
+        typedef typename coordinate_type<Point>::type coordinate_type;
+        coordinate_type x1 = get<0,0>(line1), y1 = get<0,1>(line1);
+        coordinate_type x2 = get<1,0>(line1), y2 = get<1,1>(line1);
+        coordinate_type x3 = get<0,0>(line2), y3 = get<0,1>(line2);
+        coordinate_type x4 = get<1,0>(line2), y4 = get<1,1>(line2);
+
+        coordinate_type denominator = det(x1 - x2, y1 - y2, x3 - x4, y3 - y4);
+
+        // If denominator is zero, segments are parallel.
+        // We have context information, so know that it should then
+        // be the case that line1.p2 == line2.p1, and that is the
+        // intersection point.
+        if (geometry::math::equals(denominator, 0.0))
+        {
+            set<0>(p, x2);
+            set<1>(p, y2);
+            return true;
+        }
+
+        coordinate_type d1 = det(x1, y1, x2, y2);
+        coordinate_type d2 = det(x3, y3, x4, y4);
+        coordinate_type px = det(d1, x1 - x2, d2, x3 - x4) / denominator;
+        coordinate_type py = det(d1, y1 - y2, d2, y3 - y4) / denominator;
+
+        set<0>(p, px);
+        set<1>(p, py);
+
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER
+        if (geometry::math::abs(denominator) < 1.0e-7)
+        {
+            std::cout << "small " << denominator << std::endl;
+        }
+#endif
+        return geometry::math::abs(denominator) > 1.0e-7;
+    }
+};
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINE_LINE_INTERSECTION_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/linestring_buffer.hpp b/src/boost/geometry/extensions/algorithms/buffer/linestring_buffer.hpp
new file mode 100644
index 0000000..5fa08f0
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/linestring_buffer.hpp
@@ -0,0 +1,223 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINESTRING_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINESTRING_BUFFER_HPP
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+
+#include <boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/intersecting_inserter.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template
+<
+    typename Linestring,
+    typename Polygon,
+    typename DistanceStrategy,
+    typename JoinStrategy
+>
+struct linestring_buffer
+{
+    typedef typename coordinate_type<Polygon>::type coordinate_type;
+    typedef typename point_type<Polygon>::type output_point_type;
+    typedef model::referring_segment<output_point_type const> segment_type;
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    typedef typename ring_type<Polygon>::type ring_type;
+#endif
+
+    template
+    <
+        typename Inserter,
+        typename Iterator
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+        , typename Mapper
+#endif
+    >
+    static inline void iterate(Inserter& inserter,
+                Iterator begin, Iterator end,
+                buffer_side_selector side,
+                DistanceStrategy const& distance,
+                JoinStrategy const& join
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                , Mapper& mapper
+#endif
+            )
+    {
+        output_point_type previous_p1, previous_p2;
+        output_point_type first_p1, first_p2;
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+        int index = 0;
+#endif
+
+        bool first = true;
+
+        Iterator it = begin;
+        for (Iterator prev = it++; it != end; ++it)
+        {
+            if (! detail::equals::equals_point_point(*prev, *it))
+            {
+                bool skip = false;
+
+                // Simulate a vector d (dx,dy)
+                coordinate_type dx = get<0>(*it) - get<0>(*prev);
+                coordinate_type dy = get<1>(*it) - get<1>(*prev);
+
+                // For normalization [0,1] (=dot product d.d, sqrt)
+                coordinate_type length = sqrt(dx * dx + dy * dy);
+
+                // Because coordinates are not equal, length should not be zero
+                BOOST_ASSERT((! geometry::math::equals(length, 0)));
+
+                // Generate the normalized perpendicular p, to the left (ccw)
+                coordinate_type px = -dy / length;
+                coordinate_type py = dx / length;
+
+                output_point_type p1, p2;
+
+                coordinate_type d = distance.apply(*prev, *it, side);
+
+                set<0>(p2, get<0>(*it) + px * d);
+                set<1>(p2, get<1>(*it) + py * d);
+
+                set<0>(p1, get<0>(*prev) + px * d);
+                set<1>(p1, get<1>(*prev) + py * d);
+
+                {
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                    ring_type block;
+                    block.push_back(*prev);
+                    block.push_back(*it);
+                    block.push_back(p2);
+                    block.push_back(p1);
+                    block.push_back(*prev);
+
+                    mapper.map(block, "opacity:0.4;fill:rgb(0,255,0);stroke:rgb(0,0,0);stroke-width:1");
+#endif
+                }
+
+                if (! first)
+                {
+                    output_point_type p;
+                    segment_type s1(p1, p2);
+                    segment_type s2(previous_p1, previous_p2);
+                    if (line_line_intersection<output_point_type, segment_type>::apply(s1, s2, p))
+                    {
+                        join.apply(p, *prev, previous_p2, p1,
+                                    distance.apply(*prev, *it, side),
+                                    inserter.get_ring());
+                        {
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                            mapper.map(p, "fill:rgb(0,0,0);", 3);
+
+                            std::ostringstream out;
+                            out << index++;
+                            mapper.text(p, out.str(), "fill:rgb(0,0,0);font-family='Arial';", 5, 5);
+#endif
+                        }
+                    }
+                    else
+                    {
+                        skip = false;
+                    }
+                }
+                else
+                {
+                    first = false;
+                    first_p1 = p1;
+                    first_p2 = p2;
+
+                    inserter.insert(p1);
+                }
+
+                if (! skip)
+                {
+                    previous_p1 = p1;
+                    previous_p2 = p2;
+                    prev = it;
+                }
+            }
+        }
+
+        // Last one
+        inserter.insert(previous_p2);
+    }
+
+
+    template
+    <
+        typename Inserter
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+        , typename Mapper
+#endif
+    >
+    static inline void apply(Linestring const& linestring, Inserter& inserter,
+            DistanceStrategy const& distance,
+            JoinStrategy const& join
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            , Mapper& mapper
+#endif
+            )
+    {
+        typedef typename boost::range_iterator
+            <
+                Linestring const
+            >::type iterator_type;
+
+        inserter.start_ring();
+
+        iterate(inserter, boost::begin(linestring), boost::end(linestring),
+            buffer_side_left,
+            distance, join
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            , mapper
+#endif
+            );
+
+        iterate(inserter, boost::rbegin(linestring), boost::rend(linestring),
+            buffer_side_right, distance, join
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            , mapper
+#endif
+            );
+
+        inserter.close_and_insert_ring();
+    }
+};
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_LINESTRING_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/polygon_buffer.hpp b/src/boost/geometry/extensions/algorithms/buffer/polygon_buffer.hpp
new file mode 100644
index 0000000..101de1f
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/polygon_buffer.hpp
@@ -0,0 +1,231 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_POLYGON_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_POLYGON_BUFFER_HPP
+
+#include <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp>
+
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template <typename RingInput, typename RingOutput, typename JoinStrategy>
+struct ring_buffer
+{
+    typedef typename point_type<RingOutput>::type output_point_type;
+    typedef typename coordinate_type<output_point_type>::type coordinate_type;
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    template <typename Mapper>
+#endif
+    static inline void apply(RingInput const& ring, RingOutput& buffered,
+            coordinate_type distance,
+            JoinStrategy const& join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            , Mapper& mapper
+#endif
+            )
+    {
+        typedef model::referring_segment<output_point_type const> segment_type;
+        typedef typename boost::range_iterator
+            <
+                RingInput const
+            >::type iterator_type;
+
+        output_point_type previous_p1, previous_p2;
+        output_point_type first_p1, first_p2;
+        bool first = true;
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+        int index = 0;
+#endif
+
+        iterator_type it = boost::begin(ring);
+        for (iterator_type prev = it++;
+            it != boost::end(ring); ++it)
+        {
+            if (! detail::equals::equals_point_point(*prev, *it))
+            {
+                bool skip = false;
+
+                // Generate a block along (int most cases to the left of) the segment
+
+                // Simulate a vector d (dx,dy)
+                coordinate_type dx = get<0>(*it) - get<0>(*prev);
+                coordinate_type dy = get<1>(*it) - get<1>(*prev);
+
+
+                // For normalization [0,1] (=dot product d.d, sqrt)
+                coordinate_type length = sqrt(dx * dx + dy * dy);
+
+                // Because coordinates are not equal, length should not be zero
+                BOOST_ASSERT((! geometry::math::equals(length, 0)));
+
+                // Generate the normalized perpendicular p, to the left (ccw)
+                coordinate_type px = -dy / length;
+                coordinate_type py = dx / length;
+
+                output_point_type p1, p2;
+
+                coordinate_type d = distance;
+
+                set<0>(p2, get<0>(*it) + px * d);
+                set<1>(p2, get<1>(*it) + py * d);
+
+                set<0>(p1, get<0>(*prev) + px * d);
+                set<1>(p1, get<1>(*prev) + py * d);
+
+                {
+                    RingOutput block;
+                    block.push_back(*prev);
+                    block.push_back(*it);
+                    block.push_back(p2);
+                    block.push_back(p1);
+                    block.push_back(*prev);
+
+    #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                    mapper.map(block, "opacity:0.4;fill:rgb(255,128,0);stroke:rgb(0,0,0);stroke-width:1");
+    #endif
+                }
+
+                if (! first)
+                {
+                    output_point_type p;
+                    segment_type s1(p1, p2);
+                    segment_type s2(previous_p1, previous_p2);
+                    if (line_line_intersection<output_point_type, segment_type>::apply(s1, s2, p))
+                    {
+                        join_strategy.apply(p, *prev, previous_p2, p1, distance, buffered);
+                        {
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                            mapper.map(p, "fill:rgb(0,0,0);", 3);
+
+                            std::ostringstream out;
+                            out << index++;
+                            mapper.text(p, out.str(), "fill:rgb(0,0,0);font-family='Arial';", 5, 5);
+#endif
+                        }
+                    }
+                    else
+                    {
+                        skip = false;
+                    }
+                }
+                else
+                {
+                    first = false;
+                    first_p1 = p1;
+                    first_p2 = p2;
+                }
+
+                if (! skip)
+                {
+                    previous_p1 = p1;
+                    previous_p2 = p2;
+                    prev = it;
+                }
+            }
+        }
+
+        // Last one
+        {
+            output_point_type p;
+            segment_type s1(previous_p1, previous_p2);
+            segment_type s2(first_p1, first_p2);
+            line_line_intersection<output_point_type, segment_type>::apply(s1, s2, p);
+
+            join_strategy.apply(p, *boost::begin(ring), previous_p2, first_p1, distance, buffered);
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            mapper.map(p, "fill:rgb(0,0,0);", 3);
+            std::ostringstream out;
+            out << index++;
+            mapper.text(p, out.str(), "fill:rgb(0,0,0);font-family='Arial';", 5, 5);
+#endif
+        }
+
+        // Close the generated buffer
+        {
+            output_point_type p = *boost::begin(buffered);
+            buffered.push_back(p);
+        }
+    }
+};
+
+
+
+template <typename PolygonInput, typename PolygonOutput, typename JoinStrategy>
+struct polygon_buffer
+{
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    template <typename Mapper>
+#endif
+    static inline void apply(PolygonInput const& polygon, PolygonOutput& buffered,
+            typename coordinate_type<PolygonOutput>::type distance,
+            JoinStrategy const& join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            , Mapper& mapper
+#endif
+            )
+    {
+        geometry::clear(buffered);
+
+        typedef typename ring_type<PolygonInput>::type input_ring_type;
+        typedef typename ring_type<PolygonOutput>::type output_ring_type;
+
+        typedef ring_buffer<input_ring_type, output_ring_type, JoinStrategy> policy;
+        policy::apply(exterior_ring(polygon), exterior_ring(buffered),
+                distance, join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                , mapper
+#endif
+                );
+
+        typename interior_return_type<PolygonInput const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            output_ring_type ring;
+            policy::apply(*it, ring, distance, join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                , mapper
+#endif
+                );
+            interior_rings(buffered).push_back(ring);
+        }
+    }
+};
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_POLYGON_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/remove_within_distance.hpp b/src/boost/geometry/extensions/algorithms/buffer/remove_within_distance.hpp
new file mode 100644
index 0000000..e0f88e1
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/remove_within_distance.hpp
@@ -0,0 +1,151 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHM_REMOVE_WITHIN_DISTANCE_HPP
+#define BOOST_GEOMETRY_ALGORITHM_REMOVE_WITHIN_DISTANCE_HPP
+
+
+#include <algorithm>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template<typename Geometry, typename GeometryInput, typename T>
+struct remove_false_ring_predicate
+{
+private :
+    typedef typename point_type<Geometry>::type point_type;
+
+    GeometryInput const& m_input;
+    T m_distance;
+
+public :
+    remove_false_ring_predicate(GeometryInput const& input,
+            T const& distance)
+        : m_input(input)
+        , m_distance(distance)
+    {
+    }
+
+    inline bool operator()(Geometry const& geometry)
+    {
+        point_type point, point_input;
+        if (geometry::point_on_border(point, geometry, false)
+            && geometry::point_on_border(point_input, m_input, false))
+        {
+            if (m_distance > T())
+            {
+                // If the input is within the output, it is acceptable
+                if (geometry::within(point_input, geometry))
+                {
+                    return false;
+                }
+
+                // Check the distance to the input geometry
+                // (for a polygon, this is: the distance from OUTSIDE
+                // to the border
+                T d = geometry::distance(point, m_input);
+                if (d < m_distance)
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+};
+
+
+
+template<typename Polygon, typename Geometry>
+struct polygon_remove_false_rings
+{
+    template <typename T>
+    static inline void apply(Polygon& polygon, Geometry const& input, T const& distance)
+    {
+        interior_rings(polygon).erase
+            (
+                std::remove_if
+                    (
+                        boost::begin(interior_rings(polygon)),
+                        boost::end(interior_rings(polygon)),
+                        remove_false_ring_predicate
+                            <
+                                typename ring_type<Polygon>::type,
+                                Geometry,
+                                T
+                            >(input, distance)
+                    ),
+                boost::end(interior_rings(polygon))
+            );
+
+    }
+};
+
+
+template<typename Collection, typename Geometry, typename T>
+inline void collection_remove_within_distance(Collection& dissolved,
+            Geometry const& input,
+            T const& distance)
+{
+    typedef typename boost::range_value<Collection>::type polygon_type;
+    // 1: remove all polygons which are false positive (positive,
+    //    but too close to the input geometry
+    dissolved.erase
+        (
+            std::remove_if(boost::begin(dissolved), boost::end(dissolved),
+                remove_false_ring_predicate
+                    <
+                        polygon_type,
+                        Geometry,
+                        T
+                    >(input, distance)),
+            boost::end(dissolved)
+        );
+
+    // 2: within all polygons, remove false negative interior rings
+    for (typename boost::range_iterator<Collection>::type
+        it = boost::begin(dissolved);
+        it != boost::end(dissolved);
+        ++it)
+    {
+        polygon_remove_false_rings
+            <
+                typename boost::range_value<Collection>::type,
+                Geometry
+            >::apply(*it, input, distance);
+    }
+}
+
+
+}} // namespace detail::buffer
+
+
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHM_REMOVE_WITHIN_DISTANCE_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/sectionalizing_buffer.hpp b/src/boost/geometry/extensions/algorithms/buffer/sectionalizing_buffer.hpp
new file mode 100644
index 0000000..7e7d3a5
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/sectionalizing_buffer.hpp
@@ -0,0 +1,167 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SECTIONALIZING_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SECTIONALIZING_BUFFER_HPP
+
+#include <cstddef>
+
+#include <boost/foreach.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+#include <boost/geometry/extensions/algorithms/detail/buffer/intersecting_inserter.hpp>
+#include <boost/geometry/extensions/algorithms/detail/buffer/linestring_buffer.hpp>
+#include <boost/geometry/extensions/algorithms/detail/buffer/line_line_intersection.hpp>
+
+#include <boost/geometry/algorithms/detail/sections/range_by_section.hpp>
+#include <boost/geometry/algorithms/detail/sections/sectionalize.hpp>
+
+#include <boost/geometry/extensions/algorithms/dissolve.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+
+template
+<
+    typename GeometryOut, typename Geometry,
+    typename DistanceStrategy,
+    typename JoinStrategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , typename Mapper
+#endif
+>
+void sectionalizing_buffer(Geometry const& geometry,
+    std::vector<GeometryOut>& buffered,
+    DistanceStrategy const& distance_strategy,
+    JoinStrategy const& join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , Mapper& mapper
+#endif
+    )
+{
+    typedef typename point_type<Geometry>::type point_type;
+    typedef geometry::box<point_type> box_type;
+    typedef geometry::sections<box_type, 2> sections_type;
+    typedef typename geometry::ring_type<GeometryOut>::type ring_type;
+
+    // TEMPORARY
+    typedef intersecting_inserter
+        <
+            std::vector<GeometryOut>
+        > inserter_type;
+
+
+    sections_type sections;
+    geometry::sectionalize(geometry, sections);
+
+
+
+    // Buffer all sections separately, and put them in a temporary vector
+    std::vector<GeometryOut> buffered_sections;
+    BOOST_FOREACH(typename sections_type::value_type const& section, sections)
+    {
+        if (! section.duplicate)
+        {
+            typedef typename boost::range_iterator
+                <
+                    typename geometry::detail::range_type<Geometry>::type const
+                >::type iterator_type;
+
+
+            inserter_type inserter(buffered_sections);
+
+            iterator_type begin, end;
+            typedef std::pair<iterator_type, iterator_type> section_range;
+
+TODO: UPDATE: get _ section IS OBSOLETE NOW AND DISCARDED.
+TAKE range_by_section AND ADD section.begin_index/section.end_index
+
+            geometry::get _ section(geometry, section, begin, end); // get_section is DISCARDED
+            geometry::detail::buffer::linestring_buffer
+                <
+                    section_range, ring_type, DistanceStrategy, JoinStrategy
+                >::apply(std::make_pair(begin, end), inserter,
+                            distance_strategy,
+                            join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+                            , mapper
+#endif
+                            );
+        }
+    }
+
+    // IF there are bowl-like shapes, there can still be self-intersections
+    std::vector<GeometryOut> dissolved;
+    BOOST_FOREACH(GeometryOut const& p, buffered_sections)
+    {
+        geometry::dissolve(p, dissolved);
+    }
+
+    /*BOOST_FOREACH(GeometryOut const& p, buffered_sections)
+    {
+        if (geometry::intersects(p))
+        {
+            //std::cout << ".";
+        }
+    }*/
+
+    // TEMP
+    //buffered.swap(dissolved);
+    //return;
+    // END TEMP
+
+
+    BOOST_FOREACH(GeometryOut const& p, dissolved)
+    {
+        if (buffered.empty())
+        {
+            buffered.push_back(p);
+            //geometry::union_inserter<GeometryOut>(geometry, p, std::back_inserter(buffered));
+        }
+        else if (boost::size(buffered) == 1)
+        {
+            std::vector<GeometryOut> unioned;
+            geometry::union_inserter<GeometryOut>(buffered.front(), p, std::back_inserter(unioned));
+            buffered.swap(unioned);
+        }
+        else
+        {
+            std::cerr << " D " << buffered.size();
+            /*std::vector<GeometryOut> dissolved;
+            dissolved.push_back(p);
+            geometry::dissolver(buffered, dissolved);
+            dissolved.swap(buffered);*/
+        }
+    }
+
+    // Output
+}
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SECTIONALIZING_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp b/src/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp
new file mode 100644
index 0000000..7b99a74
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/segmenting_buffer.hpp
@@ -0,0 +1,350 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SEGMENTING_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SEGMENTING_BUFFER_HPP
+
+
+#include <cstddef>
+#include <vector>
+
+#include <boost/foreach.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+#include <boost/geometry/extensions/strategies/buffer_join_round.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+
+
+#include <boost/geometry/extensions/algorithms/dissolve.hpp>
+
+
+// TEMPORARY do not use yet.
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template <typename Point, typename PointOut, typename DistanceType>
+inline bool calculate_parallels(Point const& point1, Point const& point2,
+            PointOut& p1, PointOut& p2, DistanceType const& distance)
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+
+    // Simulate a vector d (dx,dy)
+    coordinate_type dx = get<0>(point2) - get<0>(point1);
+    coordinate_type dy = get<1>(point2) - get<1>(point1);
+
+    // For normalization [0,1] (=dot product d.d, sqrt)
+    // TODO: promote to non-integer
+    coordinate_type length = sqrt(dx * dx + dy * dy);
+
+    // Because coordinates are not equal, should been checked before, length should not be zero
+    if(geometry::math::equals(length, 0))
+    {
+        return false;
+    }
+
+    // Generate the normalized perpendicular p, to the left (ccw)
+    coordinate_type px = -dy / length;
+    coordinate_type py = dx / length;
+
+    set<0>(p1, get<0>(point1) + px * distance);
+    set<1>(p1, get<1>(point1) + py * distance);
+
+    set<0>(p2, get<0>(point2) + px * distance);
+    set<1>(p2, get<1>(point2) + py * distance);
+    return true;
+}
+
+
+
+template
+<
+    typename GeometryOut, typename Range,
+    typename DistanceStrategy,
+    typename JoinStrategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , typename Mapper
+#endif
+>
+struct per_segment_buffer
+{
+    typedef typename point_type<Range>::type input_point_type;
+    typedef typename point_type<GeometryOut>::type point_type;
+    typedef typename coordinate_type<point_type>::type coordinate_type;
+    typedef coordinate_type distance_type; // TODO promote to FP
+    typedef model::segment<point_type const> segment_type;
+    typedef typename geometry::ring_type<GeometryOut>::type ring_type;
+    typedef typename strategy::side::services::default_strategy<typename cs_tag<point_type>::type>::type side;
+
+    typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+
+    static inline void calculate_tail(input_point_type const& tail, input_point_type const& head,
+            point_type& tail_left, point_type& tail_right,
+            distance_type& distance_left,
+            distance_type& distance_right,
+            distance_type& buffered_length)
+    {
+        coordinate_type ext_x = get<0>(head) - get<0>(tail);
+        coordinate_type ext_y = get<1>(head) - get<1>(tail);
+        distance_type segment_length = sqrt(ext_x * ext_x + ext_y * ext_y);
+
+        if (buffered_length < geometry::math::abs(distance_left))
+        {
+            distance_left = buffered_length * distance_left < 0 ? -1.0 : 1.0;
+        }
+        if (buffered_length < geometry::math::abs(distance_right))
+        {
+            distance_right = buffered_length * distance_right < 0 ? -1.0 : 1.0;
+        }
+
+        distance_type prop_left = geometry::math::abs(distance_left) / segment_length;
+        distance_type prop_right = geometry::math::abs(distance_right) / segment_length;
+
+        set<0>(tail_left, get<0>(tail) - ext_x * prop_left);
+        set<1>(tail_left, get<1>(tail) - ext_y * prop_left);
+        set<0>(tail_right, get<0>(tail) - ext_x * prop_right);
+        set<1>(tail_right, get<1>(tail) - ext_y * prop_right);
+
+        buffered_length += segment_length;
+    }
+
+
+    static inline void calculate_head(input_point_type const& tail, input_point_type const& head,
+            point_type& head_left, point_type& head_right,
+            distance_type& distance_left,
+            distance_type& distance_right,
+            distance_type const& rest_length)
+    {
+        coordinate_type ext_x = get<0>(head) - get<0>(tail);
+        coordinate_type ext_y = get<1>(head) - get<1>(tail);
+        distance_type segment_length = sqrt(ext_x * ext_x + ext_y * ext_y);
+
+        if (rest_length < distance_left)
+        {
+            distance_left = rest_length;
+        }
+        if (rest_length < distance_right)
+        {
+            distance_right = rest_length;
+        }
+
+        distance_type prop_left = distance_left / segment_length;
+        distance_type prop_right = distance_right / segment_length;
+
+        set<0>(head_left, get<0>(head) + ext_x * prop_left);
+        set<1>(head_left, get<1>(head) + ext_y * prop_left);
+        set<0>(head_right, get<0>(head) + ext_x * prop_right);
+        set<1>(head_right, get<1>(head) + ext_y * prop_right);
+    }
+
+    static inline void apply(Range const& range,
+        std::vector<GeometryOut>& buffered,
+        DistanceStrategy const& distance_strategy,
+        JoinStrategy const& join_strategy
+    #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+        , Mapper& mapper
+    #endif
+        )
+    {
+        // Buffer all segments separately, and put them in a temporary vector
+        std::vector<GeometryOut> buffered_pieces;
+
+        bool first = true;
+
+        strategy::buffer::join_round2<point_type> new_join;
+        //strategy::buffer::join_none<point_type> new_join;
+
+        distance_type range_length = geometry::length(range);
+        distance_type buffered_length = coordinate_type();
+
+        iterator_type it = boost::begin(range);
+        //iterator_type it_c = boost::end(range);
+        for (iterator_type previous = it++;
+            it != boost::end(range);
+            ++it)
+        {
+            bool const last = it + 1 == boost::end(range);
+
+            distance_type distance_left = distance_strategy.apply(
+                            *previous, *it, buffer_side_left);
+            distance_type distance_right = distance_strategy.apply(
+                            *previous, *it, buffer_side_right);
+
+            point_type left_ab_p1, left_ab_p2, right_ab_p1, right_ab_p2;
+
+            if (detail::disjoint::disjoint_point_point(*previous, *it)
+                && calculate_parallels(*previous, *it, left_ab_p1, left_ab_p2,
+                        distance_left)
+                && calculate_parallels(*previous, *it, right_ab_p1, right_ab_p2,
+                        -distance_right)
+                )
+            {
+                {
+                    point_type tail_left, tail_right, head_left, head_right;
+
+                    // For flat buffers, generate corners only if outside range of buffer_distance
+                    distance_type distance_tail_left = distance_left;
+                    distance_type distance_tail_right = distance_right;
+                    distance_type distance_head_left = distance_left;
+                    distance_type distance_head_right = distance_right;
+
+                    calculate_tail(*previous, *it,
+                            tail_left, tail_right,
+                            distance_tail_left, distance_tail_right,
+                            buffered_length);
+
+                    distance_type const rest_length = range_length - buffered_length;
+
+                    calculate_head(*previous, *it,
+                            head_left, head_right,
+                            distance_head_left, distance_head_right,
+                            rest_length);
+
+                    // Add non-axis aligned rectangle
+                    buffered_pieces.resize(buffered_pieces.size() + 1);
+                    ring_type& ring = exterior_ring(buffered_pieces.back());
+                    ring.push_back(left_ab_p1);
+                    ring.push_back(left_ab_p2);
+
+                    if (! last)
+                    {
+                        new_join.apply(*it, left_ab_p2, left_ab_p2, head_left,
+                                    distance_left, distance_head_left,
+                                    std::back_inserter(ring));
+
+                        ring.push_back(head_left);
+                        ring.push_back(head_right);
+
+                        new_join.apply(*it, right_ab_p2, head_right, right_ab_p2,
+                                    distance_right, distance_head_right,
+                                    std::back_inserter(ring));
+                    }
+
+                    ring.push_back(right_ab_p2);
+                    ring.push_back(right_ab_p1);
+
+                    if (! first)
+                    {
+                        new_join.apply(*previous, right_ab_p1, right_ab_p1, tail_right,
+                                    distance_right, distance_tail_right,
+                                    std::back_inserter(ring));
+
+                        ring.push_back(tail_right);
+                        ring.push_back(tail_left);
+
+                        new_join.apply(*previous, left_ab_p1, tail_left, left_ab_p1,
+                                    distance_left, distance_tail_left,
+                                    std::back_inserter(ring));
+                    }
+
+                    ring.push_back(left_ab_p1);
+                }
+
+                previous = it;
+
+                first = false;
+            }
+        }
+
+        // TEMP, uncomment to see what was actually generated
+        //buffered.swap(buffered_pieces);
+        //return;
+        // END TEMP
+
+
+
+        BOOST_FOREACH(GeometryOut const& p, buffered_pieces)
+        {
+            if (buffered.empty())
+            {
+                buffered.push_back(p);
+            }
+            else if (boost::size(buffered) == 1)
+            {
+                std::vector<GeometryOut> unioned;
+                geometry::union_inserter<GeometryOut>(buffered.front(), p, std::back_inserter(unioned));
+                buffered.swap(unioned);
+            }
+            else
+            {
+                std::cerr << " D " << buffered.size();
+                /*std::vector<GeometryOut> dissolved;
+                dissolved.push_back(p);
+                geometry::dissolver(buffered, dissolved);
+                dissolved.swap(buffered);*/
+            }
+        }
+
+        /***
+        std::vector<GeometryOut> dissolved;
+        BOOST_FOREACH(GeometryOut const& p, buffered)
+        {
+            geometry::dissolve(p, dissolved);
+        }
+        dissolved.swap(buffered);
+        ***/
+
+        // Output
+    }
+};
+
+
+
+template
+<
+    typename GeometryOut, typename Geometry,
+    typename DistanceStrategy,
+    typename JoinStrategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , typename Mapper
+#endif
+>
+inline void segmenting_buffer(Geometry const& geometry,
+        std::vector<GeometryOut>& buffered,
+        DistanceStrategy const& distance_strategy,
+        JoinStrategy const& join_strategy
+    #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+        , Mapper& mapper
+    #endif
+        )
+{
+    per_segment_buffer
+        <
+            GeometryOut, Geometry,
+            DistanceStrategy, JoinStrategy
+        >::apply(geometry, buffered, distance_strategy, join_strategy);
+}
+
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SEGMENTING_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/splitting_buffer.hpp b/src/boost/geometry/extensions/algorithms/buffer/splitting_buffer.hpp
new file mode 100644
index 0000000..9514b22
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/splitting_buffer.hpp
@@ -0,0 +1,116 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SPLITTING_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SPLITTING_BUFFER_HPP
+
+#include <cstddef>
+
+#include <boost/foreach.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+#include <boost/geometry/extensions/algorithms/detail/buffer/intersecting_inserter.hpp>
+#include <boost/geometry/extensions/algorithms/detail/buffer/linestring_buffer.hpp>
+#include <boost/geometry/extensions/algorithms/detail/buffer/line_line_intersection.hpp>
+
+
+#include <boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp>
+#include <boost/geometry/extensions/algorithms/detail/overlay/split_rings.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template
+<
+    typename GeometryOut, typename Geometry,
+    typename DistanceStrategy,
+    typename JoinStrategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , typename Mapper
+#endif
+>
+inline void splitting_buffer(Geometry const& geometry,
+    std::vector<GeometryOut>& buffered,
+    DistanceStrategy const& distance_strategy,
+    JoinStrategy const& join_strategy
+
+    , int option
+    )
+{
+    typedef typename ring_type<GeometryOut>::type ring_type;
+    typedef detail::buffer::intersecting_inserter
+        <
+            std::vector<GeometryOut>
+        > inserter_type;
+
+
+    inserter_type inserter(buffered);
+
+    detail::buffer::linestring_buffer
+        <
+            Geometry, GeometryOut, DistanceStrategy, JoinStrategy
+        >::apply(geometry, inserter, distance_strategy, join_strategy);
+
+    if (option == 0)
+    {
+        return;
+    }
+
+    std::vector<ring_type> rings;
+    BOOST_FOREACH(GeometryOut const& polygon, buffered)
+    {
+//std::cout << geometry::wkt(polygon) << " ; POLYGON" << std::endl;
+        geometry::split_rings(polygon, rings);
+    }
+
+    if (option == 1)
+    {
+        buffered.resize(rings.size());
+        int i = 0;
+        BOOST_FOREACH(ring_type const& ring, rings)
+        {
+            exterior_ring(buffered[i++]) = ring;
+        }
+        return;
+    }
+
+    std::vector<GeometryOut> buffered_and_unioned;
+    geometry::dissolver(rings, buffered_and_unioned);
+
+    std::vector<GeometryOut> buffered_and_assembled;
+    detail::overlay::assemble<GeometryOut>(buffered_and_unioned,
+            std::map<ring_identifier, int>(),
+            buffered_and_unioned[0], buffered_and_unioned[0], 1, true, true,
+            std::back_inserter(buffered_and_assembled));
+
+    buffered = buffered_and_assembled;
+}
+
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_SPLITTING_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/buffer/traversing_buffer.hpp b/src/boost/geometry/extensions/algorithms/buffer/traversing_buffer.hpp
new file mode 100644
index 0000000..b64129c
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/buffer/traversing_buffer.hpp
@@ -0,0 +1,89 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TRAVERSING_BUFFER_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TRAVERSING_BUFFER_HPP
+
+#include <cstddef>
+
+#include <boost/foreach.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/intersecting_inserter.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/linestring_buffer.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp>
+
+
+#include <boost/geometry/extensions/algorithms/dissolve.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace buffer
+{
+
+
+template
+<
+    typename GeometryOut, typename Geometry,
+    typename DistanceStrategy,
+    typename JoinStrategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , typename Mapper
+#endif
+>
+inline void traversing_buffer(Geometry const& geometry,
+    std::vector<GeometryOut>& buffered,
+    DistanceStrategy const& distance_strategy,
+    JoinStrategy const& join_strategy
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+    , Mapper& mapper
+#endif
+    )
+{
+    typedef typename ring_type<GeometryOut>::type ring_type;
+    typedef detail::buffer::intersecting_inserter
+        <
+            std::vector<GeometryOut>
+        > inserter_type;
+
+
+    inserter_type inserter(buffered);
+
+    detail::buffer::linestring_buffer
+        <
+            Geometry, GeometryOut, DistanceStrategy, JoinStrategy
+        >::apply(geometry, inserter, distance_strategy, join_strategy);
+
+    std::vector<GeometryOut> buffered_and_assembled;
+    detail::overlay::assemble<GeometryOut>(buffered,
+            std::map<ring_identifier, int>(),
+            buffered[0], buffered[0], 1, true, true,
+            std::back_inserter(buffered_and_assembled));
+
+    buffered = buffered_and_assembled;
+}
+
+
+}} // namespace detail::buffer
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_TRAVERSING_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/connect.hpp b/src/boost/geometry/extensions/algorithms/connect.hpp
new file mode 100644
index 0000000..0464a1a
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/connect.hpp
@@ -0,0 +1,581 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_CONNECT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_CONNECT_HPP
+
+#include <map>
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/comparable_distance.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/strategies/default_distance_result.hpp>
+#include <boost/geometry/policies/compare.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/io/dsv/write.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace connect
+{
+
+
+template <typename Point>
+struct node
+{
+    int index;
+    bool is_from;
+    Point point;
+
+    node(int i, bool f, Point const& p)
+        : index(i)
+        , is_from(f)
+        , point(p)
+    {}
+
+    node()
+        : index(-1)
+        , is_from(false)
+    {}
+};
+
+template <typename Point>
+struct map_policy
+{
+    typedef typename strategy::distance::services::default_strategy
+        <
+            point_tag, Point
+        >::type strategy_type;
+
+    // Have a map<point, <index,start/end> > such that we can find
+    // the corresponding point on each end. Note that it uses the
+    // default "equals" for the point-type
+    typedef std::map
+        <
+            Point,
+            std::vector<node<Point> >,
+            geometry::less<Point>
+        > map_type;
+
+    typedef typename map_type::const_iterator map_iterator_type;
+    typedef typename std::vector<node<Point> >::const_iterator vector_iterator_type;
+
+    typedef Point point_type;
+    typedef typename default_distance_result<Point>::type distance_result_type;
+
+
+    map_type map;
+
+
+    inline bool find_start(node<Point>& object,
+            std::map<int, bool>& included,
+            int expected_count = 1)
+    {
+        for (map_iterator_type it = map.begin();
+            it != map.end();
+            ++it)
+        {
+            if ((expected_count == 1 && boost::size(it->second) == 1)
+                || (expected_count > 1 && boost::size(it->second) > 1))
+            {
+                for (vector_iterator_type vit = it->second.begin();
+                    vit != it->second.end();
+                    ++vit)
+                {
+                    if (! included[vit->index])
+                    {
+                        included[vit->index] = true;
+                        object = *vit;
+                        return true;
+                    }
+                }
+            }
+        }
+
+        // Not found with one point, try one with two points
+        // to find rings
+        if (expected_count == 1)
+        {
+            return find_start(object, included, 2);
+        }
+
+        return false;
+    }
+
+    inline void add(int index, Point const& p, bool is_from)
+    {
+        map[p].push_back(node<Point>(index, is_from, p));
+    }
+
+
+    template <typename LineString>
+    inline void add(int index, LineString const& ls)
+    {
+        if (boost::size(ls) > 0)
+        {
+            add(index, *boost::begin(ls), true);
+            add(index, *(boost::end(ls) - 1), false);
+        }
+    }
+
+    inline node<Point> find_closest(Point const& p1, std::map<int, bool>& included)
+    {
+        std::vector<node<Point> > const& range = map[p1];
+
+        node<Point> closest;
+
+
+        // Alternatively, we might look for the closest points
+        if (boost::size(range) == 0)
+        {
+            std::cout << "nothing found" << std::endl;
+            return closest;
+        }
+
+        // 2c: for all candidates get closest one
+        strategy_type strategy;
+
+        distance_result_type min_dist = strategy::distance::services
+            ::result_from_distance<strategy_type>::apply(strategy, 100);
+
+        for (vector_iterator_type it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            if (! included[it->index])
+            {
+                distance_result_type d = geometry::comparable_distance(p1, it->point);
+                if (d < min_dist)
+                {
+                    closest = *it;
+                    min_dist = d;
+
+                    //std::cout << "TO " << geometry::wkt(p2) << std::endl;
+                }
+            }
+        }
+        return closest;
+    }
+
+};
+
+
+template <typename Point>
+struct fuzzy_policy
+{
+    typedef typename strategy::distance::services::default_strategy
+        <
+            point_tag, Point
+        >::type strategy_type;
+
+    // Have a map<point, <index,start/end> > such that we can find
+    // the corresponding point on each end. Note that it uses the
+    // default "equals" for the point-type
+    typedef std::vector
+        <
+            std::pair
+                <
+                    Point,
+                    std::vector<node<Point> >
+                >
+        > map_type;
+
+    typedef typename map_type::const_iterator map_iterator_type;
+    typedef typename std::vector<node<Point> >::const_iterator vector_iterator_type;
+
+    typedef Point point_type;
+    typedef typename default_distance_result<Point>::type distance_result_type;
+
+
+    map_type map;
+    typename coordinate_type<Point>::type m_limit;
+
+
+    fuzzy_policy(typename coordinate_type<Point>::type limit)
+        : m_limit(limit)
+    {}
+
+    inline bool find_start(node<Point>& object,
+            std::map<int, bool>& included,
+            int expected_count = 1)
+    {
+        for (map_iterator_type it = map.begin();
+            it != map.end();
+            ++it)
+        {
+            if ((expected_count == 1 && boost::size(it->second) == 1)
+                || (expected_count > 1 && boost::size(it->second) > 1))
+            {
+                for (vector_iterator_type vit = it->second.begin();
+                    vit != it->second.end();
+                    ++vit)
+                {
+                    if (! included[vit->index])
+                    {
+                        included[vit->index] = true;
+                        object = *vit;
+                        return true;
+                    }
+                }
+            }
+        }
+
+        // Not found with one point, try one with two points
+        // to find rings
+        if (expected_count == 1)
+        {
+            return find_start(object, included, 2);
+        }
+
+        return false;
+    }
+
+    inline typename boost::range_iterator<map_type>::type fuzzy_closest(Point const& p)
+    {
+        typename boost::range_iterator<map_type>::type closest = boost::end(map);
+
+        for (typename boost::range_iterator<map_type>::type it = boost::begin(map);
+            it != boost::end(map);
+            ++it)
+        {
+            distance_result_type d = geometry::distance(p, it->first);
+            if (d < m_limit)
+            {
+                if (closest == boost::end(map))
+                {
+                    closest = it;
+                }
+                else
+                {
+                    distance_result_type dc = geometry::distance(p, closest->first);
+                    if (d < dc)
+                    {
+                        closest = it;
+                    }
+                }
+            }
+        }
+        return closest;
+    }
+
+
+    inline void add(int index, Point const& p, bool is_from)
+    {
+        // Iterate through all points and get the closest one.
+        typename boost::range_iterator<map_type>::type it = fuzzy_closest(p);
+        if (it == map.end())
+        {
+            map.resize(map.size() + 1);
+            map.back().first = p;
+            it = map.end() - 1;
+        }
+        it->second.push_back(node<Point>(index, is_from, p));
+    }
+
+
+    template <typename LineString>
+    inline void add(int index, LineString const& ls)
+    {
+        if (boost::size(ls) > 0)
+        {
+            add(index, *boost::begin(ls), true);
+            add(index, *(boost::end(ls) - 1), false);
+        }
+    }
+
+    inline node<Point> find_closest(Point const& p1, std::map<int, bool>& included)
+    {
+        namespace services = strategy::distance::services;
+
+        node<Point> closest;
+
+        typename boost::range_iterator<map_type>::type it = fuzzy_closest(p1);
+        if (it == map.end())
+        {
+            return closest;
+        }
+
+        std::vector<node<Point> > const& range = it->second;
+
+
+
+        // Alternatively, we might look for the closest points
+        if (boost::size(range) == 0)
+        {
+            std::cout << "nothing found" << std::endl;
+            return closest;
+        }
+
+        // 2c: for all candidates get closest one
+        strategy_type strategy;
+        distance_result_type min_dist = strategy::distance::services
+            ::result_from_distance<strategy_type>::apply(strategy, 100);
+
+        for (vector_iterator_type it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            if (! included[it->index])
+            {
+                distance_result_type d = geometry::comparable_distance(p1, it->point);
+                if (d < min_dist)
+                {
+                    closest = *it;
+                    min_dist = d;
+
+                    //std::cout << "TO " << geometry::wkt(p2) << std::endl;
+                }
+            }
+        }
+        return closest;
+    }
+};
+
+template <typename Policy>
+inline void debug(Policy const& policy)
+{
+    std::cout << "MAP" << std::endl;
+    typedef typename Policy::map_type::const_iterator iterator;
+    typedef typename Policy::point_type point_type;
+
+    for (iterator it=policy.map.begin(); it != policy.map.end(); ++it)
+    {
+        std::cout << geometry::dsv(it->first) << " => " ;
+        std::vector<node<point_type> > const& range =it->second;
+        for (typename std::vector<node<point_type> >::const_iterator
+            vit = boost::begin(range); vit != boost::end(range); ++vit)
+        {
+            std::cout
+                << " (" << vit->index
+                << ", " << (vit->is_from ? "F" : "T")
+                << ")"
+                ;
+        }
+        std::cout << std::endl;
+    }
+}
+
+
+
+
+// Dissolve on multi_linestring tries to create larger linestrings from input,
+// or closed rings.
+
+template <typename Multi, typename GeometryOut, typename Policy>
+struct connect_multi_linestring
+{
+    typedef typename point_type<Multi>::type point_type;
+    typedef typename boost::range_iterator<Multi const>::type iterator_type;
+    typedef typename boost::range_value<Multi>::type linestring_type;
+
+
+    static inline void copy(linestring_type const& ls,
+            GeometryOut& target,
+            bool copy_forward)
+    {
+        if (copy_forward)
+        {
+            std::copy(boost::begin(ls), boost::end(ls),
+                std::back_inserter(target));
+        }
+        else
+        {
+            std::reverse_copy(boost::begin(ls), boost::end(ls),
+                std::back_inserter(target));
+        }
+    }
+
+
+    template <typename OutputIterator>
+    static inline OutputIterator apply(Multi const& multi, Policy& policy, OutputIterator out)
+    {
+        if (boost::size(multi) <= 0)
+        {
+            return out;
+        }
+
+        // 1: fill the map.
+        int index = 0;
+        for (iterator_type it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it, ++index)
+        {
+            policy.add(index, *it);
+        }
+
+        debug(policy);
+
+        std::map<int, bool> included;
+
+        // 2: connect the lines
+
+        // 2a: start with one having a unique starting point
+        node<point_type> starting_point;
+        if (! policy.find_start(starting_point, included))
+        {
+            return out;
+        }
+
+        GeometryOut current;
+        copy(multi[starting_point.index], current, starting_point.is_from);
+
+        bool found = true;
+        while(found)
+        {
+            // 2b: get all candidates, by asking multi-map for range
+            point_type const& p1 = *(boost::end(current) - 1);
+
+            node<point_type> closest = policy.find_closest(p1, included);
+
+            found = false;
+
+            // 2d: if there is a closest one add it
+            if (closest.index >= 0)
+            {
+                found = true;
+                included[closest.index] = true;
+                copy(multi[closest.index], current, closest.is_from);
+            }
+            else if ((included.size() != std::size_t(boost::size(multi))))
+            {
+                // Get one which is NOT found and go again
+                node<point_type> next;
+                if (policy.find_start(next, included))
+                {
+                    found = true;
+
+                    *out++ = current;
+                    geometry::clear(current);
+
+                    copy(multi[next.index], current, next.is_from);
+                }
+            }
+        }
+        if (boost::size(current) > 0)
+        {
+            *out++ = current;
+        }
+
+        return out;
+    }
+};
+
+}} // namespace detail::connect
+#endif
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename GeometryTag,
+    typename GeometryOutTag,
+    typename Geometry,
+    typename GeometryOut,
+    typename Policy
+>
+struct connect
+{};
+
+
+template<typename Multi, typename GeometryOut, typename Policy>
+struct connect<multi_linestring_tag, linestring_tag, Multi, GeometryOut, Policy>
+    : detail::connect::connect_multi_linestring
+        <
+            Multi,
+            GeometryOut,
+            Policy
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template
+<
+    typename Geometry,
+    typename Collection
+>
+inline void connect(Geometry const& geometry, Collection& output_collection)
+{
+    typedef typename boost::range_value<Collection>::type geometry_out;
+
+    concept::check<Geometry const>();
+    concept::check<geometry_out>();
+
+    typedef detail::connect::map_policy
+        <
+            typename point_type<Geometry>::type
+        > policy_type;
+
+    policy_type policy;
+
+    dispatch::connect
+    <
+        typename tag<Geometry>::type,
+        typename tag<geometry_out>::type,
+        Geometry,
+        geometry_out,
+        policy_type
+    >::apply(geometry, policy, std::back_inserter(output_collection));
+}
+
+
+
+template
+<
+    typename Geometry,
+    typename Collection
+>
+inline void connect(Geometry const& geometry, Collection& output_collection,
+            typename coordinate_type<Geometry>::type const& limit)
+{
+    typedef typename boost::range_value<Collection>::type geometry_out;
+
+    concept::check<Geometry const>();
+    concept::check<geometry_out>();
+
+    typedef detail::connect::fuzzy_policy
+        <
+            typename point_type<Geometry>::type
+        > policy_type;
+
+    policy_type policy(limit);
+
+    dispatch::connect
+    <
+        typename tag<Geometry>::type,
+        typename tag<geometry_out>::type,
+        Geometry,
+        geometry_out,
+        policy_type
+    >::apply(geometry, policy, std::back_inserter(output_collection));
+}
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_CONNECT_HPP
diff --git a/src/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp b/src/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp
new file mode 100644
index 0000000..0744429
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp
@@ -0,0 +1,640 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DETAIL_OVERLAY_DISSOLVER_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DETAIL_OVERLAY_DISSOLVER_HPP
+
+
+#include <deque>
+#include <vector>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+
+#include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/intersection.hpp>
+#include <boost/geometry/algorithms/union.hpp>
+#include <boost/geometry/algorithms/reverse.hpp>
+
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+
+namespace detail { namespace inserter
+{
+
+
+template<typename Tag1, typename Tag2>
+struct insert_geometry
+{};
+
+template<>
+struct insert_geometry<ring_tag, polygon_tag>
+{
+    template<typename Ring, typename Collection>
+    static inline void apply(Ring const& ring, Collection& collection)
+    {
+        collection.resize(collection.size() + 1);
+        geometry::exterior_ring(collection.back()) = ring;
+    }
+};
+
+
+
+
+template<>
+struct insert_geometry<polygon_tag, polygon_tag>
+{
+    template<typename Geometry, typename Collection>
+    static inline void apply(Geometry const& geometry, Collection& collection)
+    {
+        collection.push_back(geometry);
+    }
+};
+
+template<typename Geometry, typename Collection>
+inline void insert(Geometry const& geometry, Collection& collection)
+{
+    insert_geometry
+        <
+            typename geometry::tag<Geometry>::type,
+            typename geometry::tag
+                <
+                    typename boost::range_value<Collection>::type
+                >::type
+        >::apply(geometry, collection);
+}
+
+}} // namespace detail::inserter
+
+
+
+namespace detail { namespace dissolver
+{
+
+class plusmin_policy
+{
+    template
+    <
+        typename Geometry1,
+        typename Geometry2,
+        typename OutputCollection
+    >
+    static inline bool check_negative(Geometry1 a, Geometry2 b,
+                    OutputCollection& output_collection)
+    {
+        // Precondition: a = positive, b = negative
+
+        // 1: make b positive to get proper intersection
+        geometry::reverse(b);
+        {
+            // 2: Check if there is overlap
+            OutputCollection difference;
+            geometry::intersection(a, b, difference);
+            if(difference.size() <= 0)
+            {
+                return false;
+            }
+        }
+
+        // There is overlap and we want to remove it, by subtracting it from b
+
+        //negative = true;
+
+        typedef typename geometry::point_type<Geometry2>::type point_type;
+        typedef overlay::turn_info<point_type> turn_info;
+        std::deque<turn_info> turns;
+
+        // Get (and stop on) any intersection
+        detail::disjoint::disjoint_interrupt_policy policy;
+        geometry::get_turns
+            <
+                false, false,
+                overlay::assign_null_policy
+            >(a, b, turns, policy);
+
+        if (! policy.has_intersections)
+        {
+            // There is overlap but no intersections -> b is inside a.
+            // So keep A and keep B, do not change anything
+            return false;
+        }
+
+        // There are intersections.
+        // 3: make a negative
+        geometry::reverse(a); // now negative
+
+        // This will calculate B minus A, result is then positive
+        OutputCollection difference;
+        geometry::intersection(a, b, difference);
+
+        // Add original a to output (NOT necessary! TODO avoid this)
+        {
+            geometry::reverse(a); // positive again
+            detail::inserter::insert(a, output_collection);
+        }
+
+
+        // Make negative output negative again
+        typedef typename boost::range_iterator<OutputCollection>::type iterator_type;
+        for(iterator_type it = boost::begin(difference);
+            it != boost::end(difference);
+            ++it)
+        {
+            geometry::reverse(*it);
+            detail::inserter::insert(*it, output_collection);
+        }
+        return true;
+    }
+
+
+public :
+
+    template
+    <
+        typename Geometry1,
+        typename Geometry2,
+        typename OutputCollection
+    >
+    static inline bool apply(Geometry1 const& a, Geometry2 const& b,
+                    OutputCollection& output_collection)
+    {
+        typedef typename geometry::coordinate_type<Geometry2>::type coordinate_type;
+        coordinate_type area_a = geometry::area(a);
+        coordinate_type area_b = geometry::area(b);
+
+        // DEBUG
+        /*
+        int n = boost::size(output_collection);
+        typedef typename geometry::point_type<Geometry2>::type point_type;
+        std::cout << "Combine "
+            << area_a << " with " << " " << area_b
+            << " { " << geometry::wkt(geometry::return_centroid<point_type>(a))
+            << geometry::wkt(geometry::return_centroid<point_type>(b)) << " }"
+             << std::endl;
+        */
+        // END DEBUG
+
+        coordinate_type zero = coordinate_type();
+        if (area_a > zero && area_b > zero)
+        {
+            geometry::union_(a, b, output_collection);
+            return true;
+        }
+        else if (area_a > zero && area_b < zero)
+        {
+            return check_negative(a, b, output_collection);
+        }
+        else if (area_a < zero && area_b > zero)
+        {
+            return check_negative(b, a, output_collection);
+        }
+
+        // both negative (?) TODO
+        // DEBUG
+        /*
+        for (int i = n; i < boost::size(output_collection); i++)
+        {
+            typedef typename geometry::point_type<Geometry2>::type point_type;
+            std::cout << "Result "
+                << geometry::area(output_collection[i])
+                << " " << geometry::wkt(geometry::return_centroid<point_type>(output_collection[i]))
+                << std::endl;
+        }
+        */
+        // END DEBUG
+        return false;
+
+    }
+
+};
+
+
+template <typename CombinePolicy>
+struct dissolver_generic
+{
+
+
+    // Small structure to access elements by index;
+    // this avoids copying or accessing elements by address (pointer)
+    template <typename Box>
+    struct dissolve_helper
+    {
+        int source; // 0,1
+        int index; // index in the original array
+        bool dissolved;
+        Box box;
+        double area;
+
+        dissolve_helper()
+        {}
+
+        dissolve_helper(int i, Box b, double a, int s)
+            : source(s)
+            , index(i)
+            , dissolved(false)
+            , box(b)
+            , area(a)
+        {}
+    };
+
+
+    struct get_geometry
+    {
+        template <typename Range>
+        inline static typename boost::range_value<Range>::type const& apply(
+            Range const& range, int index)
+        {
+            return range[index];
+        }
+    };
+
+    template
+    <
+        typename Vector,
+        typename HelperVector
+    >
+    static inline void init_helper(Vector const& v, HelperVector& helper,
+        int index = 0, int source = 0)
+    {
+        typedef typename boost::range_value<Vector>::type value_type;
+        typedef typename geometry::point_type<value_type>::type point_type;
+        typedef model::box<point_type> box_type;
+        for(typename boost::range_iterator<Vector const>::type
+            it = boost::begin(v);
+            it != boost::end(v);
+            ++it, ++index)
+        {
+            helper.push_back(dissolve_helper<box_type>(index,
+                    geometry::return_envelope<box_type>(*it),
+                    geometry::area(*it),
+                    source));
+        }
+    }
+
+    template
+    <
+        typename Element,
+        typename Geometry1, typename Geometry2,
+        typename OutputCollection
+    >
+    static inline bool call_policy(
+            Element const& element1, Element const& element2,
+            Geometry1 const& geometry1, Geometry2 const& geometry2
+                , OutputCollection& output_collection)
+    {
+        if (! geometry::disjoint(geometry1, geometry2))
+        {
+            /*std::cout << "Process " << element1.source << "/" << element1.index
+                << " and " << element2.source << "/" << element2.index
+                << "  (" << element2.dissolved << "," << element2.dissolved << ")"
+                << std::endl;
+            */
+            return CombinePolicy::apply(geometry1, geometry2,
+                            output_collection);
+        }
+        return false;
+    }
+
+
+    template
+    <
+        int Dimension,
+        typename HelperVector,
+        typename IndexVector,
+        typename InputRange,
+        typename OutputCollection,
+        typename Box
+    >
+    static inline bool divide_and_conquer(HelperVector& helper_vector
+                , IndexVector& index_vector
+                , InputRange const& input_range
+                , OutputCollection& output_collection
+                , Box const& total_box
+                , bool& changed
+                , int iteration = 0
+                )
+    {
+        //std::cout << "divide_and_conquer " << iteration << std::endl;
+        typedef typename geometry::coordinate_type<Box>::type coordinate_type;
+        typedef typename boost::range_value<HelperVector>::type helper_type;
+        typedef typename boost::range_iterator<IndexVector const>::type iterator_type;
+
+        //if (boost::size(index_vector) >= 16 && iteration < 100)
+        // Not yet using divide and conquer
+        if (false)
+        {
+            // 1: separate box into 2 (either horizontally or vertically)
+            Box lower_box = total_box, upper_box = total_box;
+            coordinate_type two = 2.0;
+            coordinate_type mid
+                = (geometry::get<min_corner, Dimension>(total_box)
+                    + geometry::get<max_corner, Dimension>(total_box)) / two;
+
+            geometry::set<max_corner, Dimension>(lower_box, mid);
+            geometry::set<min_corner, Dimension>(upper_box, mid);
+
+            // 2: divide indices into two sublists
+            IndexVector lower_list, upper_list;
+            for(iterator_type it = boost::begin(index_vector);
+                it != boost::end(index_vector);
+                ++it)
+            {
+                helper_type const& element = helper_vector[*it];
+                if (! geometry::disjoint(lower_box, element.box))
+                {
+                    lower_list.push_back(*it);
+                }
+                if (! geometry::disjoint(upper_box, element.box))
+                {
+                    upper_list.push_back(*it);
+                }
+            }
+
+            //std::cout << lower_list.size() << ", " << upper_list.size()<< std::endl;
+
+            // 3: recursively call function (possibly divide in other dimension)
+            divide_and_conquer<1 - Dimension>(helper_vector,
+                lower_list, input_range, output_collection, lower_box, changed, iteration + 1);
+            divide_and_conquer<1 - Dimension>(helper_vector,
+                upper_list, input_range, output_collection, upper_box, changed, iteration + 1);
+            return changed;
+        }
+
+        // There are less then 16 elements, handle them quadraticly
+
+        int n = boost::size(output_collection);
+
+        for(iterator_type it1 = boost::begin(index_vector);
+            it1 != boost::end(index_vector);
+            ++it1)
+        {
+            helper_type& element1 = helper_vector[*it1];
+
+            bool unioned = false;
+            for(iterator_type it2 = boost::begin(index_vector);
+                ! unioned && it2 != it1;
+                ++it2)
+            {
+                helper_type& element2 = helper_vector[*it2];
+
+                // If they are NOT disjoint, union them
+                if (! element1.dissolved
+                    && ! element2.dissolved
+                    && ! geometry::disjoint(element1.box, element2.box))
+                {
+                    // Runtime type check here...
+                    if ((element1.source == 0 && element2.source == 0
+                        && call_policy
+                            (
+                                element1, element2,
+                                get_geometry::apply(input_range, element1.index),
+                                get_geometry::apply(input_range, element2.index),
+                                output_collection
+                            )
+                        )
+                        || (element1.source == 0 && element2.source == 1
+                        && call_policy
+                            (
+                                element1, element2,
+                                get_geometry::apply(input_range, element1.index),
+                                get_geometry::apply(output_collection, element2.index),
+                                output_collection
+                            )
+                        )
+                        || (element1.source == 1 && element2.source == 0
+                        && call_policy
+                            (
+                                element1, element2,
+                                get_geometry::apply(output_collection, element1.index),
+                                get_geometry::apply(input_range, element2.index),
+                                output_collection
+                            )
+                        )
+                        || (element1.source == 1 && element2.source == 1
+                        && call_policy
+                            (
+                                element1, element2,
+                                get_geometry::apply(output_collection, element1.index),
+                                get_geometry::apply(output_collection, element2.index),
+                                output_collection
+                            )
+                        )
+                        )
+                    {
+                        changed = true;
+                        element1.dissolved = true;
+                        element2.dissolved = true;
+
+                        unioned = true;
+/*std::cout << "Assign " << element1.source << "/" << element1.index
+<< " and " << element2.source << "/" << element2.index
+<< "  (" << element2.dissolved << "," << element2.dissolved << ")"
+<< std::endl;
+*/
+                    }
+                }
+            }
+        }
+
+        // Append new records in output collection to helper class
+        init_helper(std::make_pair(boost::begin(output_collection) + n,
+            boost::end(output_collection)), helper_vector, n, 1);
+
+        return changed;
+    }
+
+    template <typename T>
+    static inline bool helper_dissolved(T const& t)
+    {
+      return t.dissolved;
+    }
+
+
+
+    template
+    <
+        typename InputRange,
+        typename OutputCollection
+    >
+    static inline void apply(InputRange const& input_range
+                , OutputCollection& output_collection
+                )
+    {
+        typedef typename boost::range_value<OutputCollection>::type output_type;
+
+        typedef typename geometry::point_type<output_type>::type point_type;
+        typedef model::box<point_type> box_type;
+        typedef dissolve_helper<box_type> dissolve_helper_type;
+        typedef std::vector<dissolve_helper_type> helper_vector_type;
+
+        // Vector with indices to both input_range (source 0) and output_collection (source 1)
+        helper_vector_type helper_vector;
+
+        // Vector with indices to helper-vector, for divide and conquer
+        std::vector<int> index_vector;
+
+
+        init_helper(input_range, helper_vector);
+
+        // Fill intrusive list with copies, and determine bounding box
+        box_type total_box;
+        geometry::assign_inverse(total_box);
+        int index = 0;
+        for(typename boost::range_iterator<helper_vector_type const>::type
+            it = boost::begin(helper_vector);
+            it != boost::end(helper_vector);
+            ++it, ++index)
+        {
+            index_vector.push_back(index);
+            geometry::expand(total_box, it->box);
+        }
+
+        std::vector<output_type> unioned_collection;
+
+        int size = 0, previous_size = 0;
+        int n = 0;
+
+        bool changed = false;
+        while(divide_and_conquer<1>
+            (helper_vector, index_vector, input_range, unioned_collection, total_box, changed) && n < 5)
+        {
+            // Remove everything which is already dissolved.
+            helper_vector.erase
+                (
+                    std::remove_if
+                        (
+                            helper_vector.begin(),
+                            helper_vector.end(),
+                            helper_dissolved<dissolve_helper_type>
+                        ),
+                    helper_vector.end()
+                );
+
+            previous_size = size;
+            size = helper_vector.size();
+            n = previous_size == size ? n + 1 : 0;
+
+            // Re-initialize the list
+            index_vector.clear();
+            int index = 0;
+            for(typename boost::range_iterator<helper_vector_type const>::type
+                it = boost::begin(helper_vector);
+                it != boost::end(helper_vector);
+                ++it, ++index)
+            {
+                index_vector.push_back(index);
+            }
+
+            changed = false;
+
+            //std::cout << " " << size;
+        }
+
+        // Add input+output to real output
+        typedef typename boost::range_iterator<helper_vector_type>::type iterator_type;
+        for(iterator_type it = boost::begin(helper_vector);
+            it != boost::end(helper_vector);
+            ++it)
+        {
+            if (! it->dissolved)
+            {
+                switch(it->source)
+                {
+                    case 0 :
+                        detail::inserter::insert(
+                            get_geometry::apply(input_range, it->index),
+                            output_collection);
+                        break;
+                    case 1 :
+                        detail::inserter::insert(
+                            get_geometry::apply(unioned_collection, it->index),
+                            output_collection);
+                        break;
+                }
+            }
+        }
+    }
+};
+
+
+}} // namespace detail::dissolver
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename GeometryTag1,
+    typename GeometryTag2,
+    typename Policy
+>
+struct dissolver
+{};
+
+
+template<typename Policy>
+struct dissolver<ring_tag, polygon_tag, Policy>
+    : detail::dissolver::dissolver_generic<Policy>
+{};
+
+template<typename Policy>
+struct dissolver<polygon_tag, polygon_tag, Policy>
+    : detail::dissolver::dissolver_generic<Policy>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template
+<
+    typename InputRange,
+    typename OutputCollection
+>
+inline void dissolver(InputRange const& input_range,
+        OutputCollection& output_collection)
+{
+    typedef typename boost::range_value<InputRange>::type geometry_in;
+    typedef typename boost::range_value<OutputCollection>::type geometry_out;
+    concept::check<geometry_in const>();
+    concept::check<geometry_out>();
+
+    dispatch::dissolver
+    <
+        typename tag<geometry_in>::type,
+        typename tag<geometry_out>::type,
+        detail::dissolver::plusmin_policy
+    >::apply(input_range, output_collection);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DETAIL_OVERLAY_DISSOLVER_HPP
diff --git a/src/boost/geometry/extensions/algorithms/detail/overlay/msm_state.hpp b/src/boost/geometry/extensions/algorithms/detail/overlay/msm_state.hpp
new file mode 100644
index 0000000..1cff563
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/detail/overlay/msm_state.hpp
@@ -0,0 +1,187 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_MSM_STATE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_MSM_STATE_HPP
+
+
+
+#ifdef USE_MSM_MINI
+
+#  include <boost/msm/back/mini_state_machine.hpp>
+#  include <boost/fusion/include/vector.hpp>
+
+#else
+
+#  include <boost/msm/back/state_machine.hpp>
+#  include <boost/msm/front/state_machine_def.hpp>
+
+#endif
+
+
+
+// Events
+struct starting {};
+struct visit {};
+struct finish {};
+
+
+// Flags
+struct is_init {};
+struct is_visited {};
+
+enum StatesEnum
+{
+    STATE_NONE=0,
+    STATE_IS_INIT=1,
+    STATE_IS_VISITED=2
+};
+
+
+
+#ifndef USE_MSM_MINI
+
+// front-end: define the FSM structure
+struct traverse_state_ : public boost::msm::front::state_machine_def<traverse_state_>
+{
+    traverse_state_():m_state(STATE_IS_INIT){}
+    // The list of FSM states
+    struct Init : public boost::msm::front::state<>
+    {
+        typedef boost::mpl::vector1<is_init> flag_list;
+        //template <class Event,class FSM>
+        //void on_entry(Event const&,FSM& fsm) {fsm.m_state=STATE_IS_INIT;}
+    };
+
+    struct Started : public boost::msm::front::state<>
+    {
+        //template <class Event,class FSM>
+        //void on_entry(Event const&,FSM& fsm) {fsm.m_state=STATE_NONE;}
+    };
+
+    struct Visited : public boost::msm::front::state<>
+    {
+        typedef boost::mpl::vector1<is_visited> flag_list;
+        //template <class Event,class FSM>
+        //void on_entry(Event const&,FSM& fsm) {fsm.m_state=STATE_IS_VISITED;}
+    };
+
+    struct Finished : public boost::msm::front::state<>
+    {
+        typedef boost::mpl::vector1<is_visited> flag_list;
+        //template <class Event,class FSM>
+        //void on_entry(Event const&,FSM& fsm) {fsm.m_state=STATE_IS_VISITED;}
+    };
+
+
+    // the initial state of the player SM. Must be defined
+    typedef Init initial_state;
+
+    // transition actions
+    void start_traverse(starting const&)      {m_state=STATE_NONE;}
+    void finish_after_visit(finish const&)    {m_state=STATE_IS_VISITED;}
+    void do_finish(finish const&)             {m_state=STATE_IS_VISITED;}
+    void do_visit(visit const&)               {m_state=STATE_IS_VISITED;}
+    void do_visit2(visit const&)              {m_state=STATE_IS_VISITED;}
+    void do_nothing(finish const&)            {m_state=STATE_IS_VISITED;}
+
+
+    typedef traverse_state_ p; // makes transition table cleaner
+
+    // Transition table for player
+    struct transition_table : mpl::vector
+        <
+            //    Start     Event         Next      Action               Guard
+            //  +---------+-------------+---------+---------------------+----------------------+
+          a_row < Init   , starting  , Started    , &p::start_traverse                    >,
+          a_row < Init   , visit  , Visited    , &p::do_visit                    >,
+          a_row < Init   ,  finish  , Finished  , &p::do_nothing                 >,
+          a_row < Started   , finish  , Finished    , &p::do_finish                    >,
+          a_row < Started   , visit  , Visited    , &p::do_visit2                    >,
+            //  +---------+-------------+---------+---------------------+----------------------+
+          a_row < Visited , finish        , Finished , &p::finish_after_visit                       >
+            //  +---------+-------------+---------+---------------------+----------------------+
+        > {};
+
+    // Replaces the default no-transition response.
+    template <class Machine, class Event>
+    void no_transition(Event const& e, Machine&, int state)
+    {
+        //std::cout << "no transition from state " << state << " on event " << typeid(e).name() << std::endl;
+    }
+
+    typedef int no_exception_thrown;
+    typedef int no_message_queue;
+    StatesEnum m_state;
+
+};
+
+
+typedef boost::msm::back::state_machine<traverse_state_> traverse_state;
+
+#else
+
+// mini-back-end
+
+
+struct traverse_state : public boost::msm::back::mini::state_machine<traverse_state>
+{
+    traverse_state():m_state(STATE_IS_INIT){}
+
+    // The list of FSM states
+    enum states
+    {
+        Init, Started, Visited, Finished
+        , initial_state = Init
+    };
+
+      friend class boost::msm::back::mini::state_machine<traverse_state>;
+      typedef traverse_state p; // makes transition table cleaner
+
+      // transition actions
+      void start_traverse(starting const&)      {m_state=STATE_NONE;}
+      void finish_after_visit(finish const&)    {m_state=STATE_IS_VISITED;}
+      void do_finish(finish const&)             {m_state=STATE_IS_VISITED;}
+      void do_visit(visit const&)               {m_state=STATE_IS_VISITED;}
+      void do_visit2(visit const&)              {m_state=STATE_IS_VISITED;}
+      void do_nothing(finish const&)            {m_state=STATE_IS_VISITED;}
+
+        bool flag_none() const { return m_state == STATE_IS_INIT; }
+        bool flag_visited() const { return m_state == STATE_IS_VISITED; }
+
+
+      // Transition table
+      struct transition_table : mpl::vector6<
+          //    Start     Event         Next      Action
+          //  +---------+-------------+---------+---------------------+
+          row < Init    , starting    , Started , &p::start_traverse  >,
+          row < Init    , visit       , Visited , &p::do_visit        >,
+          row < Init    ,  finish     , Finished, &p::do_nothing      >,
+          row < Started , finish      , Finished, &p::do_finish       >,
+          row < Started , visit       , Visited , &p::do_visit2       >,
+          row < Visited , finish      , Finished, &p::finish_after_visit>
+          //  +---------+-------------+---------+---------------------+
+      > {};
+
+      // Replaces the default no-transition response.
+      template <class Event>
+      int no_transition(int state, Event const& e)
+      {
+          std::cout << "no transition from state " << state
+                    << " on event " << typeid(e).name() << std::endl;
+          return state;
+      }
+      StatesEnum m_state;
+
+};
+
+#endif
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_MSM_STATE_HPP
diff --git a/src/boost/geometry/extensions/algorithms/detail/overlay/split_rings.hpp b/src/boost/geometry/extensions/algorithms/detail/overlay/split_rings.hpp
new file mode 100644
index 0000000..af8e0f8
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/detail/overlay/split_rings.hpp
@@ -0,0 +1,547 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DETAIL_OVERLAY_SPLIT_RINGS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DETAIL_OVERLAY_SPLIT_RINGS_HPP
+
+#define BOOST_GEOMETRY_CHECK_SPLIT_RINGS
+
+#include <deque>
+#include <string>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/algorithms/intersects.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#if defined(BOOST_GEOMETRY_DEBUG_SPLIT_RINGS) || defined(BOOST_GEOMETRY_CHECK_SPLIT_RINGS)
+#  include <boost/geometry/io/wkt/wkt.hpp>
+#endif
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace split_rings
+{
+
+template <typename Range>
+struct split_range
+{
+/*
+
+   1             2
+   +-------------+
+   |      4     /
+   |       |\  /
+   |       | \/____ IP
+   |       | /\
+   |       |/  \
+   |      3     \
+   +-------------+
+  0,6            5
+
+  - we want to split the range at the IP into two rings
+  - At the IP: we have segment_indices 2,4 (result of get_turns_in_sections)
+  - We want to copy and remove vertices 3,4
+  --> count=4-2
+  --> copy [3,5) -> copy(begin()+id1+1, begin()+id1+count+1)
+  --> erase: idem
+  --> insert(begin()+id1+1)
+
+  --> we use id1+1
+
+  After that, we need to update all indices AFTER IP.
+  We removed two vertices here (4-2), and added one (the IP)
+
+*/
+    static inline void apply(Range& range, Range& output
+        , segment_identifier const& id1
+        , segment_identifier const& id2
+        , typename geometry::point_type<Range>::type const& point
+        )
+    {
+        if (id1.ring_index == id2.ring_index
+            && id1.multi_index == id2.multi_index)
+        {
+            int mn = (std::min)(id1.segment_index, id2.segment_index);
+            mn++;
+
+            typename boost::range_iterator<Range>::type first = range.begin();
+            first += mn;
+
+            typename boost::range_iterator<Range>::type last = first;
+            last += geometry::math::abs(id2.segment_index - id1.segment_index);
+
+            // Create splitted ring
+            output.push_back(point);
+            std::copy(first, last, std::back_inserter(output));
+            output.push_back(point);
+
+            // Remove the loop from the range
+            range.erase(first, last);
+
+            // Iterator is invalid because of erasure, construct again
+            range.insert(range.begin() + mn, point);
+        }
+    }
+};
+
+
+/*template <typename Polygon>
+struct split_polygon
+{
+    typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+    static inline void apply(Polygon& polygon, ring_type& splitted
+        , segment_identifier const& id1
+        , segment_identifier const& id2
+        , typename geometry::point_type<Polygon>::type const& point
+        )
+    {
+        if (id1.ring_index == id2.ring_index
+            && id1.multi_index == id2.multi_index)
+        {
+            ring_type& ring = id1.ring_index < 0
+                ? geometry::exterior_ring(polygon)
+                : geometry::interior_rings(polygon)[id1.ring_index];
+
+            split_range<ring_type>::apply(ring, splitted, id1, id2, point);
+        }
+    }
+};*/
+
+
+template <typename Tag, typename Geometry>
+struct split
+{};
+
+
+template <typename Ring>
+struct split<ring_tag, Ring> : split_range<Ring>
+{};
+
+
+//template <typename Polygon>
+//struct split<polygon_tag, Polygon> : split_polygon<Polygon>
+//{};
+
+
+
+
+
+
+template <typename Tag, typename RingCollection, typename Geometry>
+struct insert_rings
+{};
+
+
+template <typename RingCollection, typename Ring>
+struct insert_rings<ring_tag, RingCollection, Ring>
+{
+    static inline void apply(RingCollection& ring_collection, Ring const& ring)
+    {
+#ifdef BOOST_GEOMETRY_DEBUG_SPLIT_RINGS
+std::cout << geometry::wkt(ring)
+        << " ; " << geometry::area(ring)
+        << " " << ring.size()
+        //<< " at " << geometry::wkt(first.point)
+        << std::endl;
+/*std::cout << "geometry "
+    << " " << geometry::area(geometry)
+    << std::endl;*/
+#endif
+
+        ring_collection.push_back(ring);
+    }
+};
+
+
+template <typename RingCollection, typename Polygon>
+struct insert_rings<polygon_tag, RingCollection, Polygon>
+{
+    static inline void apply(RingCollection& ring_collection, Polygon const& polygon)
+    {
+        ring_collection.push_back(exterior_ring(polygon));
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+#ifdef BOOST_GEOMETRY_DEBUG_SPLIT_RINGS
+std::cout << geometry::wkt(*it)
+        << " ; " << geometry::area(*it)
+        << " " << it->size()
+        //<< " at " << geometry::wkt(first.point)
+        << std::endl;
+/*std::cout << "geometry "
+    << " " << geometry::area(geometry)
+    << std::endl;*/
+#endif
+
+            ring_collection.push_back(*it);
+        }
+    }
+};
+
+
+/// Sorts vector of turns (results from get_turns)
+template <typename Turn>
+struct sorter
+{
+    inline bool operator()(Turn const& left, Turn const& right) const
+    {
+        if (left.count_between != right.count_between)
+        {
+            return left.count_between < right.count_between;
+        }
+
+        if (left.operations[0].seg_id.segment_index
+                == right.operations[0].seg_id.segment_index)
+        {
+            return left.operations[0].distance < right.operations[0].distance;
+        }
+        return left.operations[0].seg_id.segment_index
+                    < right.operations[0].seg_id.segment_index;
+    }
+};
+
+/// Turn operation with additional distance field
+template <typename P>
+struct split_turn_operation : public detail::overlay::turn_operation
+{
+   inline split_turn_operation()
+        : detail::overlay::turn_operation()
+        , distance(geometry::return_distance_result<distance_type>(0))
+    {}
+
+    typedef typename default_distance_result<P, P>::type distance_type;
+    distance_type distance; // distance-measurement from segment.first to IP
+};
+
+
+/// Turn information with distance fields, plus "count_between"  field
+template <typename P>
+struct split_turn_info : detail::overlay::turn_info
+            <
+                P, split_turn_operation<P>
+            >
+{
+    //std::string history;
+    int count_between; // counts number of segments between ring in intersection
+
+    split_turn_info()
+        : count_between(0)
+    {}
+};
+
+
+/// Policy to calculate distance
+struct split_calculate_distance_policy
+{
+    template <typename Point1, typename Point2, typename Info>
+    static inline void apply(Info& info, Point1 const& p1, Point2 const& p2)
+    {
+        info.operations[0].distance
+                    = geometry::distance(info.point, p1);
+        info.operations[1].distance
+                    = geometry::distance(info.point, p2);
+    }
+
+};
+
+
+template <typename Range, typename RingCollection>
+class range_split_rings
+{
+    typedef typename geometry::tag<Range>::type tag;
+    typedef typename geometry::point_type<Range>::type point_type;
+
+    typedef typename geometry::ring_type<Range>::type ring_type;
+
+
+    typedef typename strategy_intersection
+        <
+            typename cs_tag<point_type>::type,
+            point_type,
+            point_type,
+            point_type
+        >::segment_intersection_strategy_type strategy;
+
+
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_SPLIT_RINGS
+    template <typename Turns>
+    static void report(Turns const& turns, std::string const& header)
+    {
+        if (turns.empty())
+        {
+            return;
+        }
+        std::cout << header << std::endl;
+        BOOST_FOREACH(typename boost::range_value<Turns>::type const& turn, turns)
+        {
+            std::cout
+                << "I at " << turn.operations[0].seg_id.segment_index
+                << "/" << turn.operations[1].seg_id.segment_index
+                << " (" << turn.count_between
+                << ") " << turn.operations[0].distance
+                << "/" << turn.operations[1].distance
+                << " " << geometry::wkt(turn.point) << std::endl;
+        }
+    }
+#endif
+
+    template <typename Operation>
+    static bool adapt(Operation& op, Operation const& first, Operation const& second)
+    {
+        if (first.seg_id.segment_index > second.seg_id.segment_index)
+        {
+            return adapt(op, second, first);
+        }
+        if (op.seg_id.segment_index > first.seg_id.segment_index
+            || (op.seg_id.segment_index == first.seg_id.segment_index
+                && op.distance > first.distance)
+            )
+        {
+            if (op.seg_id.segment_index < second.seg_id.segment_index
+                || (op.seg_id.segment_index == second.seg_id.segment_index
+                    && op.distance < second.distance)
+                )
+            {
+                // mark for deletion
+                op.seg_id.segment_index = -1;
+                return true;
+            }
+            else
+            {
+                op.seg_id.segment_index -= (second.seg_id.segment_index - first.seg_id.segment_index - 1);
+            }
+        }
+        return false;
+    }
+
+
+    static void call(Range range, RingCollection& ring_collection)
+    {
+        typedef split_turn_info<point_type> turn_info;
+
+        typedef std::deque<turn_info> turns_type;
+        turns_type turns;
+
+        detail::get_turns::no_interrupt_policy policy;
+        geometry::get_turns
+            <
+                split_calculate_distance_policy
+            >(range, turns, policy);
+
+        //report(turns, "intersected");
+
+        // Make operations[0].seg_id always the smallest, to sort properly
+        // Also calculate the number of segments in between
+        for (typename boost::range_iterator<turns_type>::type
+            it = boost::begin(turns);
+            it != boost::end(turns);
+            ++it)
+        {
+            turn_info& turn = *it;
+            if (turn.operations[0].seg_id.segment_index > turn.operations[1].seg_id.segment_index)
+            {
+                std::swap(turn.operations[0], turn.operations[1]);
+            }
+            // ...[1] > ...[0]
+            // check count
+            int const between1 = turn.operations[1].seg_id.segment_index
+                - turn.operations[0].seg_id.segment_index;
+            /*
+            NOTE: if we would use between2 here, we have to adapt other code as well,
+                    such as adaption of the indexes; splitting of the range, etc.
+            int between2 = boost::size(range) + turn.operations[0].seg_id.segment_index
+                    - turn.operations[1].seg_id.segment_index;
+            turn.count_between = (std::min)(between1, between2);
+            */
+
+            turn.count_between = between1;
+        }
+        //report(turns, "swapped");
+
+        std::sort(turns.begin(), turns.end(), sorter<turn_info>());
+        //report(turns, "sorted");
+
+        while(turns.size() > 0)
+        {
+            // Process first turn
+            turn_info const& turn = turns.front();
+
+            split_turn_operation<point_type> const& first_op = turn.operations[0];
+            split_turn_operation<point_type> const& second_op = turn.operations[1];
+            bool do_split = first_op.seg_id.segment_index >= 0
+                    && second_op.seg_id.segment_index >= 0;
+
+            if (do_split)
+            {
+#ifdef BOOST_GEOMETRY_CHECK_SPLIT_RINGS
+                ring_type copy = range; // TEMP, for check
+#endif
+                ring_collection.resize(ring_collection.size() + 1);
+                split<ring_tag, Range>::apply(range, ring_collection.back(),
+                        turn.operations[0].seg_id, turn.operations[1].seg_id,
+                        turn.point);
+
+#ifdef BOOST_GEOMETRY_CHECK_SPLIT_RINGS
+                {
+                    std::deque<turn_info> splitted_turns;
+                    geometry::get_turns
+                        <
+                            split_calculate_distance_policy
+                        >(ring_collection.back(),
+                            splitted_turns,
+                            detail::get_turns::no_interrupt_policy());
+
+                    if (splitted_turns.size() > 0)
+                    {
+                        std::cout << "TODO Still intersecting! " << splitted_turns.size() << std::endl;
+                        //std::cout << "       " << geometry::wkt(copy) << std::endl;
+                        //std::cout << "       " << geometry::wkt(splitted) << std::endl;
+                        //report(splitted_turns, "NOT OK");
+                        //std::cout << std::endl;
+                    }
+                }
+#endif
+
+            }
+
+            turns.pop_front();
+
+
+            if (do_split)
+            {
+                for (typename boost::range_iterator<turns_type>::type
+                    rest = boost::begin(turns);
+                    rest != boost::end(turns);
+                    ++rest)
+                {
+                    //turn_info copy = turn;
+                    if (adapt(rest->operations[0], first_op, second_op)
+                        || adapt(rest->operations[1], first_op, second_op))
+                    {
+                        /**
+                        std::cout << " ADAPTED "
+                            << copy.operations[0].seg_id.segment_index << "/" << copy.operations[1].seg_id.segment_index
+                            << " "
+                            << geometry::wkt(copy.point) << std::endl;
+                        **/
+                    }
+                }
+            }
+            while(turns.size() > 0
+                && (turns.front().operations[0].seg_id.segment_index < 0
+                    || turns.front().operations[1].seg_id.segment_index < 0))
+            {
+                turns.pop_front();
+            }
+        }
+
+        // Add the (possibly untouched) input range
+        insert_rings<ring_tag, RingCollection, Range>::apply(ring_collection, range);
+    }
+
+public :
+    // Copy by value of range is intentional, copy is modified here
+    static inline void apply(Range range, RingCollection& ring_collection)
+    {
+        call(range, ring_collection);
+    }
+};
+
+template <typename Polygon, typename RingCollection>
+struct polygon_split_rings
+{
+  typedef range_split_rings
+        <
+            typename ring_type<Polygon>::type,
+            RingCollection
+        > per_ring;
+
+    static inline void apply(Polygon const& polygon, RingCollection& ring_collection)
+    {
+        per_ring::apply(exterior_ring(polygon), ring_collection);
+        for (BOOST_AUTO_TPL(it, boost::begin(interior_rings(polygon)));
+             it != boost::end(interior_rings(polygon));
+             ++it)
+        {
+            per_ring::apply(*it, ring_collection);
+        }
+    }
+};
+
+
+}} // namespace detail::split_rings
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename GeometryTag,
+    typename Geometry,
+    typename RingCollection
+>
+struct split_rings
+{};
+
+
+template<typename Polygon, typename RingCollection>
+struct split_rings<polygon_tag, Polygon, RingCollection>
+    : detail::split_rings::polygon_split_rings<Polygon, RingCollection>
+{};
+
+
+template<typename Ring, typename RingCollection>
+struct split_rings<ring_tag, Ring, RingCollection>
+    : detail::split_rings::range_split_rings<Ring, RingCollection>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template
+<
+    typename Geometry,
+    typename RingCollection
+>
+inline void split_rings(Geometry const& geometry, RingCollection& out)
+{
+    concept::check<Geometry const>();
+    concept::check<typename boost::range_value<RingCollection>::type>();
+
+    dispatch::split_rings
+    <
+        typename tag<Geometry>::type,
+        Geometry,
+        RingCollection
+    >::apply(geometry, out);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DETAIL_OVERLAY_SPLIT_RINGS_HPP
diff --git a/src/boost/geometry/extensions/algorithms/dissolve.hpp b/src/boost/geometry/extensions/algorithms/dissolve.hpp
new file mode 100644
index 0000000..94be38e
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/dissolve.hpp
@@ -0,0 +1,293 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DISSOLVE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DISSOLVE_HPP
+
+
+#include <map>
+#include <vector>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp>
+
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp>
+#include <boost/geometry/algorithms/detail/overlay/traverse.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/add_rings.hpp>
+#include <boost/geometry/algorithms/detail/overlay/assign_parents.hpp>
+#include <boost/geometry/algorithms/detail/overlay/ring_properties.hpp>
+#include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dissolve
+{
+
+struct no_interrupt_policy
+{
+    static bool const enabled = false;
+    static bool const has_intersections = false;
+
+
+    template <typename Range>
+    static inline bool apply(Range const&)
+    {
+        return false;
+    }
+};
+
+
+template<typename Geometry>
+class backtrack_for_dissolve
+{
+public :
+    typedef detail::overlay::backtrack_state state_type;
+
+    template <typename Operation, typename Rings, typename Turns>
+    static inline void apply(std::size_t size_at_start, 
+                Rings& rings, typename boost::range_value<Rings>::type& ring,
+                Turns& turns, Operation& operation,
+                std::string const& ,
+                Geometry const& ,
+                Geometry const& ,
+                state_type& state
+                )
+    {
+        state.m_good = false;
+        
+        // Make bad output clean
+        rings.resize(size_at_start);
+        ring.clear();
+
+        // Reject this as a starting point
+        operation.visited.set_rejected();
+
+        // And clear all visit info
+        clear_visit_info(turns);
+    }
+};
+
+
+template <typename Geometry, typename GeometryOut>
+struct dissolve_ring_or_polygon
+{
+    template <typename OutputIterator>
+    static inline OutputIterator apply(Geometry const& geometry,
+                OutputIterator out)
+    {
+        // Get the self-intersection points, including turns
+        typedef detail::overlay::traversal_turn_info
+            <
+                typename point_type<Geometry>::type
+            > turn_info;
+
+        std::vector<turn_info> turns;
+        detail::dissolve::no_interrupt_policy policy;
+        geometry::self_turns
+            <
+                detail::overlay::calculate_distance_policy
+            >(geometry, turns, policy);
+
+        // The dissolve process is not necessary if there are no turns at all
+
+        if (boost::size(turns) > 0)
+        {
+            typedef typename ring_type<Geometry>::type ring_type;
+            typedef std::vector<ring_type> out_vector;
+            out_vector rings;
+
+            // Enrich the turns
+            typedef typename strategy::side::services::default_strategy
+            <
+                typename cs_tag<Geometry>::type
+            >::type side_strategy_type;
+
+            enrich_intersection_points<false, false>(turns,
+                        detail::overlay::operation_union,
+                        geometry, geometry,
+                        side_strategy_type());
+
+            typedef detail::overlay::traverse
+                <
+                    false, false, 
+                    Geometry, Geometry,
+                    backtrack_for_dissolve<Geometry>
+                > traverser;
+
+
+            // Traverse the polygons twice for union...
+            traverser::apply(geometry, geometry,
+                            detail::overlay::operation_union,
+                            turns, rings);
+
+            clear_visit_info(turns);
+
+            enrich_intersection_points<false, false>(turns,
+                        detail::overlay::operation_intersection,
+                        geometry, geometry,
+                        side_strategy_type());
+
+
+            // ... and for intersection
+            traverser::apply(geometry, geometry,
+                            detail::overlay::operation_intersection,
+                            turns, rings);
+
+            std::map<ring_identifier, int> map;
+            map_turns(map, turns);
+
+            typedef detail::overlay::ring_properties<typename geometry::point_type<Geometry>::type> properties;
+
+            std::map<ring_identifier, properties> selected;
+
+            detail::overlay::select_rings<overlay_union>(geometry, map, selected, true);
+
+            // Add intersected rings
+            {
+                ring_identifier id(2, 0, -1);
+                for (typename boost::range_iterator<std::vector<ring_type> const>::type
+                        it = boost::begin(rings);
+                        it != boost::end(rings);
+                        ++it)
+                {
+                    selected[id] = properties(*it, true);
+                    id.multi_index++;
+                }
+            }
+
+            detail::overlay::assign_parents(geometry, rings, selected);
+            return detail::overlay::add_rings<GeometryOut>(selected, geometry, rings, out);
+
+        }
+        else
+        {
+            GeometryOut g;
+            geometry::convert(geometry, g);
+            *out++ = g;
+            return out;
+        }
+    }
+};
+
+
+
+}} // namespace detail::dissolve
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename GeometryTag,
+    typename GeometryOutTag,
+    typename Geometry,
+    typename GeometryOut
+>
+struct dissolve
+{};
+
+
+template<typename Polygon, typename PolygonOut>
+struct dissolve<polygon_tag, polygon_tag, Polygon, PolygonOut>
+    : detail::dissolve::dissolve_ring_or_polygon<Polygon, PolygonOut>
+{};
+
+
+template<typename Ring, typename RingOut>
+struct dissolve<ring_tag, ring_tag, Ring, RingOut>
+    : detail::dissolve::dissolve_ring_or_polygon<Ring, RingOut>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+/*!
+    \brief Removes self intersections from a geometry
+    \ingroup overlay
+    \tparam Geometry geometry type
+    \tparam OutputIterator type of intersection container
+        (e.g. vector of "intersection/turn point"'s)
+    \param geometry first geometry
+    \param out output iterator getting dissolved geometry
+    \note Currently dissolve with a (multi)linestring does NOT remove internal
+        overlap, it only tries to connect multiple line end-points.
+        TODO: we should change this behaviour and add a separate "connect"
+        algorithm, and let dissolve work like polygon.
+ */
+template
+<
+    typename GeometryOut,
+    typename Geometry,
+    typename OutputIterator
+>
+inline OutputIterator dissolve_inserter(Geometry const& geometry, OutputIterator out)
+{
+    concept::check<Geometry const>();
+    concept::check<GeometryOut>();
+
+    return dispatch::dissolve
+    <
+        typename tag<Geometry>::type,
+        typename tag<GeometryOut>::type,
+        Geometry,
+        GeometryOut
+    >::apply(geometry, out);
+}
+
+
+template
+<
+    typename Geometry,
+    typename Collection
+>
+inline void dissolve(Geometry const& geometry, Collection& output_collection)
+{
+    concept::check<Geometry const>();
+
+    typedef typename boost::range_value<Collection>::type geometry_out;
+
+    concept::check<geometry_out>();
+
+    dispatch::dissolve
+    <
+        typename tag<Geometry>::type,
+        typename tag<geometry_out>::type,
+        Geometry,
+        geometry_out
+    >::apply(geometry, std::back_inserter(output_collection));
+}
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_DISSOLVE_HPP
diff --git a/src/boost/geometry/extensions/algorithms/mark_spikes.hpp b/src/boost/geometry/extensions/algorithms/mark_spikes.hpp
new file mode 100644
index 0000000..f1c0a3c
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/mark_spikes.hpp
@@ -0,0 +1,516 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MARK_SPIKES_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MARK_SPIKES_HPP
+
+#include <algorithm>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
+#include <boost/geometry/strategies/cartesian/area_surveyor.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/algorithms/detail/sections/sectionalize.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/buffer.hpp>
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/perimeter.hpp>
+
+#include <boost/geometry/geometries/box.hpp>
+
+
+/*
+Mark spikes in a ring/polygon.
+Ring
++---------+
+|         |
+|         |
+|   +=====  ^this "indentation" or "intrusion" or "spikey feature" is marked
+|   ||    |
+|   ||    |
+|   ++    |
++---------+
+(the actualy determination if it is marked is done by a policy)
+(things are only marked, removal is done afterwards)
+
+*/
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace mark_spikes
+{
+
+template <typename Range, typename Iterator>
+inline Iterator circular_next(Range const& range, Iterator it)
+{
+    ++it;
+    if (it == boost::end(range))
+    {
+        it = boost::begin(range);
+    }
+    return it;
+}
+
+inline std::size_t circular_next_i(std::size_t i, std::size_t const n)
+{
+    if (++i == n)
+    {
+        i = 0;
+    }
+    return i;
+}
+
+
+// Calculate the distance over the ring, in the range [it1 .. it2]
+// if it1 < it2: walk from it1 .. it2
+// if it1 > it2: walk from it1 .. end(ring) and from begin(ring) to it2
+// Do NOT call this using begin(ring), end(ring) or 0.0 will be returned
+template
+<
+    typename Range,
+    typename Iterator,
+    typename AreaStrategy,
+    typename DistanceStrategy
+>
+inline void part_area_and_perimeter(Range const& range,
+            Iterator it1, Iterator it2,
+            AreaStrategy const& area_strategy,
+            DistanceStrategy const& distance_strategy,
+            double& area, double& perimeter, int& count)
+{
+    perimeter = 0;
+    area = 0;
+    count = 0;
+    if (it1 == boost::end(range) || it2 == boost::end(range) || it1 == it2)
+    {
+        return;
+    }
+
+    typename AreaStrategy::state_type area_state;
+    Iterator it = circular_next(range, it1), previous = it1;
+    Iterator end = circular_next(range, it2);
+    while (it != end)
+    {
+        area_strategy.apply(*previous, *it, area_state);
+        perimeter += distance_strategy.apply(*previous, *it);
+        previous = it;
+        it = circular_next(range, it);
+        count++;
+    }
+
+    // Close the ring, for area
+    area_strategy.apply(*it2, *it1, area_state);
+    // Do the same for distance to get correct ratio (though this might be discussed)
+    perimeter += distance_strategy.apply(*it2, *it1);
+
+    area = abs(area_strategy.result(area_state));
+}
+
+
+template <typename Iterator>
+struct helper
+{
+    helper(int i1, int i2, Iterator t1, Iterator t2,
+        double g, double a, double p, int c)
+        : index1(i1)
+        , index2(i2)
+        , it1(t1)
+        , it2(t2)
+        , gap_distance(g)
+        , area(a)
+        , perimeter(p)
+        , count(c)
+    {
+    }
+
+    int index1, index2;
+    Iterator it1, it2;
+    double area, perimeter, gap_distance;
+    int count;
+
+    inline bool operator<(helper<Iterator> const& other) const
+    {
+        return this->count > other.count;
+    }
+};
+
+
+template <typename Range, typename MarkMap, typename Policy>
+struct range_mark_spikes
+{
+    typedef typename point_type<Range>::type point_type;
+
+    typedef typename strategy::side::services::default_strategy
+    <
+        typename cs_tag<Range>::type
+    >::type side_strategy_type;
+
+    typedef typename strategy::area::services::default_strategy
+        <
+            typename cs_tag<point_type>::type,
+            point_type
+        >::type area_strategy_type;
+
+    typedef typename strategy::distance::services::default_strategy
+        <
+            point_tag,
+            point_type,
+            point_type
+        >::type distance_strategy_type;
+
+    static inline void apply(Range const& range, ring_identifier id,
+                    MarkMap& mark_map, Policy const& policy)
+    {
+        std::size_t const n = boost::size(range);
+        if (n < 5)
+        {
+            return;
+        }
+
+        typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+        // Divide polygon in monotonic sections (in two directions)
+        typedef model::box<point_type> box_type;
+        typedef geometry::sections<box_type, 2> sections_type;
+        sections_type sections;
+        geometry::sectionalize<false>(range, sections);
+
+        for (typename boost::range_iterator<sections_type>::type it = boost::begin(sections);
+            it != boost::end(sections);
+            ++it)
+        {
+            // Enlarge each box with the wished max with of the gap to be sure that
+            // when walking through sections all point-pairs are considered
+            geometry::buffer(it->bounding_box, it->bounding_box, policy.gap_width() * 1.001);
+        }
+
+        double const whole_area = geometry::area(range);
+
+
+        typedef typename boost::range_iterator<sections_type>::type section_iterator_type;
+
+
+        // Find pair-of-points lying the most close to each other,
+        // where:
+        // - it is in another section
+        // - the distance over the ring-part is larger than X
+        // - the area of the polygon formed by that ring-part smaller than X
+
+        typedef helper<iterator_type> helper_type;
+        typedef std::vector<helper_type> helper_vector_type;
+        helper_vector_type candidates;
+
+        // Quadratic loop over all sections (note this normally does not result in a quadratic loop
+        // over all points).
+        for(section_iterator_type sit1 = boost::begin(sections); sit1 != boost::end(sections); ++sit1)
+        {
+            // Note, even though combination sit1/sit2 is handled, the combination sit2/sit1 travels
+            // another part over the ring and should be handled as well
+            for(section_iterator_type sit2 = boost::begin(sections); sit2 != boost::end(sections); ++sit2)
+            {
+                if (sit1->id != sit2->id
+                    && ! geometry::disjoint(sit1->bounding_box, sit2->bounding_box))
+                {
+                    // Check all point combinations in these boxes
+                    int index1 = sit1->begin_index;
+                    iterator_type it1 = boost::begin(range) + sit1->begin_index;
+                    for (unsigned int i = 0; i < sit1->count; i++, ++it1, ++index1)
+                    {
+                        iterator_type it2 = boost::begin(range) + sit2->begin_index;
+                        int index2 = sit2->begin_index;
+                        for (unsigned int j = 0; j < sit2->count; j++, ++it2, ++index2)
+                        {
+                            double dg = geometry::distance(*it1, *it2);
+                            if (dg < policy.gap_width())
+                            {
+                                double area, perimeter;
+                                int count;
+                                part_area_and_perimeter(range, it1, it2,
+                                    area_strategy_type(), distance_strategy_type(),
+                                    area, perimeter, count);
+
+                                if (count >= 2
+                                    && policy.apply(dg, whole_area, count, area, perimeter))
+                                {
+                                    candidates.push_back(
+                                        helper_type(index1, index2, it1, it2, dg, area, perimeter, count));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (boost::size(candidates) == 0)
+        {
+            return;
+        }
+
+        std::sort(candidates.begin(), candidates.end());
+
+        /***
+        if (boost::size(candidates) > 1)
+        {
+
+            // Remove overlaps
+            bool first = true;
+            typename boost::range_iterator<helper_vector_type>::type it = boost::begin(candidates);
+            typename boost::range_iterator<helper_vector_type>::type prev = it;
+            ++it;
+            while (it != boost::end(candidates))
+            {
+
+                if ((it->index1 >= prev->index1 && it->index2 <= prev->index2)
+
+                    )
+                {
+                    candidates.erase(it);
+                    it = prev + 1;
+                }
+                else
+                {
+                    prev = it;
+                }
+            }
+        }
+        ***/
+
+        // Check if some index combinations refer to larger combinations
+#if defined(BOOST_GEOMETRY_DEBUG_MARK_SPIKES)
+        for(typename boost::range_iterator<helper_vector_type>::type it
+            = boost::begin(candidates); it != boost::end(candidates); ++it)
+        {
+            std::cout << it->count << " " << it->index1 << " " << it->index2
+                << " gd=" << it->gap_distance
+                << " a=" << it->area << " p=" << it->perimeter
+                << " r=" << (it->perimeter > 0 ? it->area / it->perimeter : 0)
+                // << " p1=" << geometry::wkt(*it->it1) << " p2=" << geometry::wkt(*it->it2)
+                << std::endl;
+        }
+#endif
+
+        typedef typename MarkMap::mapped_type bit_vector_type;
+
+        // Add new vector to map if necessary
+        if (mark_map.find(id) == mark_map.end())
+        {
+            // Add one to vector
+            mark_map[id] = bit_vector_type();
+
+            // Initialize it
+            bit_vector_type& bits = mark_map[id];
+            for (std::size_t i = 0; i < n; i++)
+            {
+                bits.push_back(false);
+            }
+        }
+
+        bit_vector_type& bits = mark_map[id];
+
+        // Mark this range or these ranges
+        // TODO: we might use the fact that it is sorted and that ranges are inside others,
+        // so skip those...
+        for(typename boost::range_iterator<helper_vector_type const>::type it
+            = boost::begin(candidates); it != boost::end(candidates); ++it)
+        {
+            iterator_type pit = boost::begin(range) + it->index1;
+            iterator_type end = boost::begin(range) + it->index2;
+            int i = it->index1;
+            while (pit != end)
+            {
+                if (i != it->index1 && i != it->index2)
+                {
+                    bits[i] = true;
+                }
+                pit = circular_next(range, pit);
+                i = circular_next_i(i, n);
+            }
+        }
+    }
+};
+
+
+template <typename Polygon, typename MarkMap, typename Policy>
+struct polygon_mark_spikes
+{
+    static inline void apply(Polygon const& polygon, ring_identifier id,
+                    MarkMap& mark_map, Policy const& policy)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef range_mark_spikes<ring_type, MarkMap, Policy> per_range;
+
+        // Exterior ring (-1)
+        id.ring_index = -1;
+        per_range::apply(exterior_ring(polygon), id, mark_map, policy);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            // Interior ring (zero based)
+            id.ring_index++;
+            per_range::apply(*it, id, mark_map, policy);
+        }
+    }
+};
+
+
+template <typename MultiGeometry, typename MarkMap, typename Policy, typename SinglePolicy>
+struct multi_mark_spikes
+{
+    static inline void apply(MultiGeometry const& multi, ring_identifier id,
+                    MarkMap& mark_map, Policy const& policy)
+    {
+        id.multi_index = 0;
+        for (typename boost::range_iterator<MultiGeometry const>::type
+                it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            SinglePolicy::apply(*it, id, mark_map, policy);
+            id.multi_index++;
+        }
+    }
+};
+
+
+}} // namespace detail::mark_spikes
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename MarkMap,
+    typename Policy
+>
+struct mark_spikes
+{
+    static inline void apply(Geometry&, Policy const&)
+    {}
+};
+
+
+template <typename Ring, typename MarkMap, typename Policy>
+struct mark_spikes<ring_tag, Ring, MarkMap, Policy>
+    : detail::mark_spikes::range_mark_spikes<Ring, MarkMap, Policy>
+{};
+
+
+
+template <typename Polygon, typename MarkMap, typename Policy>
+struct mark_spikes<polygon_tag, Polygon, MarkMap, Policy>
+    : detail::mark_spikes::polygon_mark_spikes<Polygon, MarkMap, Policy>
+{};
+
+
+template <typename MultiPolygon, typename MarkMap, typename Policy>
+struct mark_spikes<multi_polygon_tag, MultiPolygon, MarkMap, Policy>
+    : detail::mark_spikes::multi_mark_spikes
+        <
+            MultiPolygon,
+            MarkMap,
+            Policy,
+            detail::mark_spikes::polygon_mark_spikes
+            <
+                typename boost::range_value<MultiPolygon>::type,
+                MarkMap,
+                Policy
+            >
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+    \ingroup mark_spikes
+    \tparam Geometry geometry type
+    \param geometry the geometry to make mark_spikes
+*/
+template <typename Geometry, typename MarkMap, typename Policy>
+inline bool mark_spikes(Geometry const& geometry,
+        MarkMap& mark_map,
+        Policy const& policy)
+{
+    concept::check<Geometry const>();
+
+    ring_identifier id;
+
+    dispatch::mark_spikes
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            MarkMap,
+            Policy
+        >::apply(geometry, id, mark_map, policy);
+    return mark_map.size() > 0;
+}
+
+template <typename T = double>
+class select_gapped_spike
+{
+public :
+    inline select_gapped_spike(T const gap_width, T const ratio = 0.1)
+        : m_gap_width(gap_width)
+        , m_ratio(ratio)
+    {}
+
+
+    inline T gap_width() const
+    {
+        return m_gap_width;
+    }
+
+    inline bool apply(T const gap_distance, T const whole_area,
+                int count, T const area, T const perimeter) const
+    {
+        T const ratio = perimeter == 0 ? 0 : area / perimeter;
+        return
+            perimeter > gap_distance
+            && area < whole_area / 10.0
+            && ratio < m_ratio;
+    }
+
+
+private :
+    T m_gap_width;
+    T m_ratio;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MARK_SPIKES_HPP
diff --git a/src/boost/geometry/extensions/algorithms/midpoints.hpp b/src/boost/geometry/extensions/algorithms/midpoints.hpp
new file mode 100644
index 0000000..6c669d7
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/midpoints.hpp
@@ -0,0 +1,131 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MIDPOINTS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MIDPOINTS_HPP
+
+// Renamed from "intermediate" to "midpoints"
+
+#include <cstddef>
+#include <iterator>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace midpoints {
+
+template <typename Src, typename Dst, std::size_t Dimension, std::size_t DimensionCount>
+struct calculate_coordinate
+{
+    static inline void apply(Src const& p1, Src const& p2, Dst& p)
+    {
+        geometry::set<Dimension>(p,
+                    (geometry::get<Dimension>(p1) + geometry::get<Dimension>(p2)) / 2.0);
+        calculate_coordinate<Src, Dst, Dimension + 1, DimensionCount>::apply(p1, p2, p);
+    }
+};
+
+template <typename Src, typename Dst, std::size_t DimensionCount>
+struct calculate_coordinate<Src, Dst, DimensionCount, DimensionCount>
+{
+    static inline void apply(Src const&, Src const&, Dst&)
+    {
+    }
+};
+
+template<typename Range, typename Iterator>
+struct range_midpoints
+{
+    static inline void apply(Range const& range,
+            bool start_and_end, Iterator out)
+    {
+        typedef typename point_type<Range>::type point_type;
+        typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+        iterator_type it = boost::begin(range);
+
+        if (start_and_end)
+        {
+            *out++ = *it;
+        }
+
+        iterator_type prev = it++;
+        for (; it != boost::end(range); prev = it++)
+        {
+            point_type p;
+            calculate_coordinate
+                <
+                    point_type,
+                    point_type,
+                    0,
+                    dimension<point_type>::type::value
+                >::apply(*prev, *it, p);
+            *out++ = p;
+        }
+
+        if (start_and_end)
+        {
+            *out++ = *prev;
+        }
+    }
+};
+
+}} // namespace detail::midpoints
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename GeometryTag, typename G, typename Iterator>
+struct midpoints  {};
+
+template <typename G, typename Iterator>
+struct midpoints<ring_tag, G, Iterator>
+        : detail::midpoints::range_midpoints<G, Iterator> {};
+
+template <typename G, typename Iterator>
+struct midpoints<linestring_tag, G, Iterator>
+        : detail::midpoints::range_midpoints<G, Iterator> {};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+    \brief Calculate midpoints of a geometry
+    \ingroup midpoints
+ */
+template<typename Geometry, typename Iterator>
+inline void midpoints(Geometry const& geometry,
+        bool start_and_end, Iterator out)
+{
+    concept::check<Geometry const>();
+
+    dispatch::midpoints
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Iterator
+        >::apply(geometry, start_and_end, out);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MIDPOINTS_HPP
diff --git a/src/boost/geometry/extensions/algorithms/offset.hpp b/src/boost/geometry/extensions/algorithms/offset.hpp
new file mode 100644
index 0000000..bbbce8a
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/offset.hpp
@@ -0,0 +1,204 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_OFFSET_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_OFFSET_HPP
+
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/extensions/algorithms/buffer/line_line_intersection.hpp>
+#include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/geometries/segment.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace offset
+{
+
+
+template
+<
+    typename Range,
+    typename RangeOut,
+    typename JoinStrategy,
+    typename Distance
+>
+struct offset_range
+{
+    typedef typename coordinate_type<RangeOut>::type coordinate_type;
+    typedef typename point_type<RangeOut>::type output_point_type;
+    typedef model::referring_segment<output_point_type const> segment_type;
+    typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+    static inline void apply(Range const& range,
+                RangeOut& out,
+                JoinStrategy const& join,
+                Distance const& distance)
+    {
+        output_point_type previous_p1, previous_p2;
+        output_point_type first_p1, first_p2;
+
+        bool first = true;
+
+        iterator_type it = boost::begin(range);
+        for (iterator_type prev = it++; it != boost::end(range); ++it)
+        {
+            if (! detail::equals::equals_point_point(*prev, *it))
+            {
+                bool skip = false;
+
+                // Simulate a vector d (dx,dy)
+                coordinate_type dx = get<0>(*it) - get<0>(*prev);
+                coordinate_type dy = get<1>(*it) - get<1>(*prev);
+
+                // For normalization [0,1] (=dot product d.d, sqrt)
+                coordinate_type length = sqrt(dx * dx + dy * dy);
+
+                // Because coordinates are not equal, length should not be zero
+                BOOST_ASSERT((! geometry::math::equals(length, 0)));
+
+                // Generate the normalized perpendicular p, to the left (ccw)
+                coordinate_type px = -dy / length;
+                coordinate_type py = dx / length;
+
+                output_point_type p1, p2;
+
+                set<0>(p2, get<0>(*it) + px * distance);
+                set<1>(p2, get<1>(*it) + py * distance);
+
+                set<0>(p1, get<0>(*prev) + px * distance);
+                set<1>(p1, get<1>(*prev) + py * distance);
+
+                if (! first)
+                {
+                    output_point_type p;
+                    segment_type s1(p1, p2);
+                    segment_type s2(previous_p1, previous_p2);
+                    if (detail::buffer::line_line_intersection<output_point_type, segment_type>::apply(s1, s2, p))
+                    {
+                        join.apply(p, *prev, previous_p2, p1, distance, out);
+                    }
+                    else
+                    {
+                        skip = false;
+                    }
+                }
+                else
+                {
+                    first = false;
+                    first_p1 = p1;
+                    first_p2 = p2;
+
+                    out.push_back(p1);
+                }
+
+                if (! skip)
+                {
+                    previous_p1 = p1;
+                    previous_p2 = p2;
+                    prev = it;
+                }
+            }
+        }
+
+        // Last one
+        out.push_back(previous_p2);
+
+    }
+};
+
+}} // namespace detail::offset
+#endif
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename GeometryTag,
+    typename GeometryOutTag,
+    typename Geometry,
+    typename GeometryOut,
+    typename JoinStrategy,
+    typename Distance
+>
+struct offset
+{};
+
+
+template
+<
+    typename Geometry,
+    typename GeometryOut,
+    typename JoinStrategy,
+    typename Distance
+>
+struct offset
+    <
+        linestring_tag,
+        linestring_tag,
+        Geometry,
+        GeometryOut,
+        JoinStrategy,
+        Distance
+    >
+    : detail::offset::offset_range
+        <
+            Geometry,
+            GeometryOut,
+            JoinStrategy,
+            Distance
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template
+<
+    typename Geometry,
+    typename GeometryOut,
+    typename JoinStrategy,
+    typename Distance
+>
+inline void offset(Geometry const& geometry, GeometryOut& out,
+            JoinStrategy const& join,
+            Distance const& distance)
+{
+    concept::check<Geometry const>();
+    concept::check<GeometryOut>();
+
+    dispatch::offset
+    <
+        typename tag<Geometry>::type,
+        typename tag<GeometryOut>::type,
+        Geometry,
+        GeometryOut,
+        JoinStrategy,
+        Distance
+    >::apply(geometry, out, join, distance);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_OFFSET_HPP
diff --git a/src/boost/geometry/extensions/algorithms/parse.hpp b/src/boost/geometry/extensions/algorithms/parse.hpp
new file mode 100644
index 0000000..db2d75c
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/parse.hpp
@@ -0,0 +1,123 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_PARSE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_PARSE_HPP
+
+#include <string>
+
+
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp>
+#include <boost/geometry/extensions/strategies/parse.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+template <typename Tag, typename G>
+struct parsing
+{
+};
+
+template <typename Point>
+struct parsing<point_tag, Point>
+{
+    template <typename S>
+    static inline void parse(Point& point, std::string const& c1, std::string const& c2, S const& strategy)
+    {
+        assert_dimension<Point, 2>();
+        dms_result r1 = strategy(c1.c_str());
+        dms_result r2 = strategy(c2.c_str());
+
+        if (0 == r1.axis())
+            set<0>(point, r1);
+        else
+            set<1>(point, r1);
+
+        if (0 == r2.axis())
+            set<0>(point, r2);
+        else
+            set<1>(point, r2);
+    }
+
+    static inline void parse(Point& point, std::string const& c1, std::string const& c2)
+    {
+        // strategy-parser corresponding to degree/radian
+        typename strategy_parse
+            <
+            typename cs_tag<Point>::type,
+            typename coordinate_system<Point>::type
+            >::type strategy;
+
+        parse(point, c1, c2, strategy);
+    }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+    \brief parse two strings to a spherical/geographic point, using W/E/N/S
+    \ingroup parse
+ */
+template <typename Geometry>
+inline void parse(Geometry& geometry, std::string const& c1, std::string const& c2)
+{
+    concept::check<Geometry>();
+    dispatch::parsing<typename tag<Geometry>::type, Geometry>::parse(geometry, c1, c2);
+}
+
+/*!
+    \brief parse two strings to a spherical/geographic point, using a specified strategy
+    \details user can use N/E/S/O or N/O/Z/W or other formats
+    \ingroup parse
+ */
+template <typename Geometry, typename S>
+inline void parse(Geometry& geometry, std::string const& c1,
+        std::string const& c2, S const& strategy)
+{
+    concept::check<Geometry>();
+    dispatch::parsing<typename tag<Geometry>::type, Geometry>::parse(geometry, c1, c2, strategy);
+}
+
+// There will be a parsing function with three arguments (ANGLE,ANGLE,RADIUS)
+
+template <typename Geometry>
+inline Geometry parse(std::string const& c1, std::string const& c2)
+{
+    concept::check<Geometry>();
+
+    Geometry geometry;
+    dispatch::parsing<typename tag<Geometry>::type, Geometry>::parse(geometry, c1, c2);
+    return geometry;
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_PARSE_HPP
diff --git a/src/boost/geometry/extensions/algorithms/point_on_line.hpp b/src/boost/geometry/extensions/algorithms/point_on_line.hpp
new file mode 100644
index 0000000..77bb23f
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/point_on_line.hpp
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_POINT_ON_LINE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_POINT_ON_LINE_HPP
+
+
+#include <boost/geometry/algorithms/distance.hpp>
+
+namespace boost { namespace geometry
+{
+
+//----------------------------------------------------------------------
+// Function     : point_on_linestring -> rename to alongLine NO, different
+//----------------------------------------------------------------------
+// Purpose      : Calculates coordinates of a point along a given line
+//                on a specified distance
+// Parameters   : const L& : line,
+//                float position: position to calculate point
+//                P& point: point to calculate
+// Return       : true if point lies on line
+//----------------------------------------------------------------------
+// Author       : Barend, Geodan BV Amsterdam
+// Date         : spring 1996
+//----------------------------------------------------------------------
+template <typename P, typename L>
+bool point_on_linestring(L const& line, double const& position, P& point)
+{
+    double current_distance = 0.0;
+    if (line.size() < 2)
+    {
+        return false;
+    }
+
+    typename L::const_iterator vertex = line.begin();
+    typename L::const_iterator previous = vertex++;
+
+    while (vertex != line.end())
+    {
+        double const dist = distance(*previous, *vertex);
+        current_distance += dist;
+
+        if (current_distance > position)
+        {
+            // It is not possible that dist == 0 here because otherwise
+            // the current_distance > position would not become true (current_distance is increased by dist)
+            double const fraction = 1.0 - ((current_distance - position) / dist);
+
+            // point i is too far, point i-1 to near, add fraction of
+            // distance in each direction
+            point.x ( previous->x() + (vertex->x() - previous->x()) * fraction);
+            point.y ( previous->y() + (vertex->y() - previous->y()) * fraction);
+
+            return true;
+        }
+        previous = vertex++;
+    }
+
+    // point at specified position does not lie on line
+    return false;
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_POINT_ON_LINE_HPP
diff --git a/src/boost/geometry/extensions/algorithms/remove_holes_if.hpp b/src/boost/geometry/extensions/algorithms/remove_holes_if.hpp
new file mode 100644
index 0000000..c187168
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/remove_holes_if.hpp
@@ -0,0 +1,166 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHM_REMOVE_HOLES_IF_HPP
+#define BOOST_GEOMETRY_ALGORITHM_REMOVE_HOLES_IF_HPP
+
+#include <algorithm>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/perimeter.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/multi/core/closure.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace remove_holes_if
+{
+
+
+template<typename Polygon, typename Predicate>
+struct polygon_remove_holes_if
+{
+    static inline void apply(Polygon& poly, Predicate const& predicate)
+    {
+        // TODO: evaluate this behaviour w.r.t. writable concepts
+        typename interior_return_type<Polygon>::type rings = interior_rings(poly);
+
+        // Remove rings using erase-remove-idiom
+        // http://en.wikipedia.org/wiki/Erase-remove_idiom
+        rings.erase(
+            std::remove_if(boost::begin(rings), boost::end(rings), predicate),
+            boost::end(rings));
+    }
+};
+
+}} // namespace detail::remove_holes_if
+
+
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// Default implementation does nothing
+template <typename Tag, typename Geometry, typename Predicate>
+struct remove_holes_if
+{};
+
+
+
+template <typename Geometry, typename Predicate>
+struct remove_holes_if<polygon_tag, Geometry, Predicate>
+    : detail::remove_holes_if::polygon_remove_holes_if<Geometry, Predicate>
+{};
+
+
+template <typename MultiPolygon, typename Predicate>
+struct remove_holes_if<multi_polygon_tag, MultiPolygon, Predicate>
+    : detail::multi_modify_with_predicate
+        <
+            MultiPolygon,
+            Predicate,
+            detail::remove_holes_if::polygon_remove_holes_if
+                <
+                    typename boost::range_value<MultiPolygon>::type, Predicate
+                >
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+/*!
+    \brief Remove holes from a geometry (polygon, multi-polygon) using a specified condition
+ */
+template <typename Geometry, typename Predicate>
+inline void remove_holes_if(Geometry& geometry, Predicate const& predicate)
+{
+    concept::check<Geometry>();
+
+    dispatch::remove_holes_if
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Predicate
+        >::apply(geometry, predicate);
+}
+
+
+
+
+
+
+
+// CONVENIENT PREDICATES might be moved elsewhere
+template <typename Ring>
+struct elongated_hole
+{
+    inline elongated_hole(double ratio)
+        : m_ratio(ratio)
+    {}
+
+    inline bool operator()(Ring const& ring) const
+    {
+        if (ring.size() >=
+                core_detail::closure::minimum_ring_size
+                    <
+                       geometry::closure<Ring>::value
+                    >::value)
+        {
+            double a = area(ring);
+            double p = perimeter(ring);
+            return geometry::math::abs(a / p) < m_ratio;
+        }
+        // Rings with less then 4 points (including closing)
+        // are also considered as small and thus removed
+        return true;
+    }
+private :
+    double m_ratio;
+};
+
+
+template <typename Ring>
+struct invalid_hole
+{
+    inline bool operator()(Ring const& ring) const
+    {
+        return ring.size()
+                < core_detail::closure::minimum_ring_size
+                        <
+                            geometry::closure<Ring>::value
+                        >::value;
+    }
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHM_REMOVE_HOLES_IF_HPP
diff --git a/src/boost/geometry/extensions/algorithms/remove_marked.hpp b/src/boost/geometry/extensions/algorithms/remove_marked.hpp
new file mode 100644
index 0000000..4f39b41
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/remove_marked.hpp
@@ -0,0 +1,224 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_REMOVE_MARKED_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_REMOVE_MARKED_HPP
+
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/perimeter.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace remove_marked
+{
+
+
+template <typename Range, typename MarkMap>
+struct range_remove_marked
+{
+    typedef typename strategy::side::services::default_strategy
+    <
+        typename cs_tag<Range>::type
+    >::type side_strategy_type;
+
+    typedef typename coordinate_type<Range>::type coordinate_type;
+
+
+    static inline void apply(Range const& range_in, ring_identifier id,
+                    Range& range_out, MarkMap const& mark_map)
+    {
+        typename MarkMap::const_iterator mit = mark_map.find(id);
+        if (mit == mark_map.end())
+        {
+            range_out = range_in;
+            return;
+        }
+        typedef typename MarkMap::mapped_type bit_vector_type;
+
+        if (boost::size(range_in) != boost::size(mit->second))
+        {
+            throw std::runtime_error("ERROR in size of mark_map");
+            return;
+        }
+
+        range_out.clear();
+
+        typename boost::range_iterator<bit_vector_type const>::type bit = boost::begin(mit->second);
+        for (typename boost::range_iterator<Range const>::type it = boost::begin(range_in);
+            it != boost::end(range_in); ++it, ++bit)
+        {
+            bool const& marked = *bit;
+            if (! marked)
+            {
+                range_out.push_back(*it);
+            }
+        }
+    }
+};
+
+
+template <typename Polygon, typename MarkMap>
+struct polygon_remove_marked
+{
+    static inline void apply(Polygon const& polygon_in, ring_identifier id,
+                Polygon& polygon_out, MarkMap const& mark_map)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef range_remove_marked<ring_type, MarkMap> per_range;
+        id.ring_index = -1;
+        per_range::apply(exterior_ring(polygon_in), id, exterior_ring(polygon_out), mark_map);
+
+
+        typename interior_return_type<Polygon const>::type rings_in
+                    = interior_rings(polygon_in);
+        typename interior_return_type<Polygon>::type rings_out
+                    = interior_rings(polygon_out);
+
+        rings_out.resize(boost::size(interior_rings(polygon_in)));
+        BOOST_AUTO_TPL(out, boost::begin(rings_out));
+
+        for (BOOST_AUTO_TPL(it, boost::begin(rings_in));
+            it != boost::end(rings_in);
+            ++it, ++out)
+        {
+            id.ring_index++;
+            per_range::apply(*it, id, *out, mark_map);
+        }
+    }
+};
+
+
+template <typename MultiGeometry, typename MarkMap, typename SinglePolicy>
+struct multi_remove_marked
+{
+    static inline void apply(MultiGeometry const& multi_in, ring_identifier id,
+                MultiGeometry& multi_out, MarkMap const& mark_map)
+    {
+        id.multi_index = 0;
+
+        multi_out.resize(boost::size(multi_in));
+
+        typename boost::range_iterator<MultiGeometry>::type out = boost::begin(multi_out);
+        for (typename boost::range_iterator<MultiGeometry const>::type
+                it = boost::begin(multi_in);
+            it != boost::end(multi_in);
+            ++it, ++out)
+        {
+            SinglePolicy::apply(*it, id, *out, mark_map);
+            id.multi_index++;
+        }
+    }
+};
+
+
+}} // namespace detail::remove_marked
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename MarkMap
+>
+struct remove_marked
+{
+    static inline void apply(Geometry const&, ring_identifier, Geometry&, MarkMap const&)
+    {}
+};
+
+
+template <typename Ring, typename MarkMap>
+struct remove_marked<ring_tag, Ring, MarkMap>
+    : detail::remove_marked::range_remove_marked<Ring, MarkMap>
+{};
+
+
+
+template <typename Polygon, typename MarkMap>
+struct remove_marked<polygon_tag, Polygon, MarkMap>
+    : detail::remove_marked::polygon_remove_marked<Polygon, MarkMap>
+{};
+
+
+template <typename MultiPolygon, typename MarkMap>
+struct remove_marked<multi_polygon_tag, MultiPolygon, MarkMap>
+    : detail::remove_marked::multi_remove_marked
+        <
+            MultiPolygon,
+            MarkMap,
+            detail::remove_marked::polygon_remove_marked
+            <
+                typename boost::range_value<MultiPolygon>::type,
+                MarkMap
+            >
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+    \ingroup remove_marked
+    \tparam Geometry geometry type
+    \param geometry the geometry to make remove_marked
+*/
+template <typename Geometry, typename MarkMap>
+inline void remove_marked(Geometry const& geometry_in, Geometry& geometry_out,
+            MarkMap const& mark_map)
+{
+    concept::check<Geometry>();
+
+    ring_identifier id;
+    dispatch::remove_marked
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            MarkMap
+        >::apply(geometry_in, id, geometry_out, mark_map);
+}
+
+
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_REMOVE_MARKED_HPP
diff --git a/src/boost/geometry/extensions/algorithms/remove_spikes.hpp b/src/boost/geometry/extensions/algorithms/remove_spikes.hpp
new file mode 100644
index 0000000..aea900d
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/remove_spikes.hpp
@@ -0,0 +1,378 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_REMOVE_SPIKES_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_REMOVE_SPIKES_HPP
+
+// NOTE: obsolete by "mark_spikes"
+
+#include <algorithm>
+#include <deque>
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/perimeter.hpp>
+
+#include <boost/geometry/iterators/ever_circling_iterator.hpp>
+
+#include <boost/geometry/geometries/ring.hpp>
+
+
+/*
+Remove spikes from a ring/polygon.
+Ring (having 8 vertices, including closing vertex)
++------+
+|      |
+|      +--+
+|      |  ^this "spike" is removed, can be located outside/inside the ring
++------+
+(the actualy determination if it is removed is done by a strategy)
+
+*/
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace remove_spikes
+{
+
+
+template <typename Range, typename Policy>
+struct range_remove_spikes
+{
+    typedef typename strategy::side::services::default_strategy
+    <
+        typename cs_tag<Range>::type
+    >::type side_strategy_type;
+
+    typedef typename coordinate_type<Range>::type coordinate_type;
+
+
+    static inline void apply(Range& range, Policy const& policy)
+    {
+        std::size_t n = boost::size(range);
+        if (n < 3)
+        {
+            return;
+        }
+
+        typedef typename boost::range_iterator<Range>::type iterator;
+        ever_circling_iterator<iterator> it(boost::begin(range), boost::end(range), true);
+        ever_circling_iterator<iterator> next(boost::begin(range), boost::end(range), true);
+        ever_circling_iterator<iterator> prev(boost::begin(range), boost::end(range), true);
+        // If it is "closed", skip the last (or actually the first coming after last) one.
+        n--;
+
+        it++;
+        next++;
+        next++;
+
+        bool close = false;
+
+        std::deque<std::size_t> vertices;
+        for (std::size_t i = 0;
+            i < n;
+            ++i, ++it, ++next)
+        {
+            if (policy(*prev, *it, *next))
+            {
+                // It is collinear, middle point (i == 1) will be removed below
+                vertices.push_back(i + 1);
+                if (i == n - 1)
+                {
+                    vertices.push_front(0);
+                    close = true;
+                }
+            }
+            else
+            {
+                prev = it;
+            }
+        }
+        for (std::deque<std::size_t>::reverse_iterator rit = vertices.rbegin();
+            rit != vertices.rend(); ++rit)
+        {
+            range.erase(range.begin() + *rit);
+        }
+        if (close)
+        {
+            typename point_type<Range>::type p = range.front();
+            range.push_back(p);
+        }
+    }
+};
+
+
+template <typename Polygon, typename Policy>
+struct polygon_remove_spikes
+{
+    static inline void apply(Polygon& polygon, Policy const& policy)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        typedef range_remove_spikes<ring_type, Policy> per_range;
+        per_range::apply(exterior_ring(polygon), policy);
+
+        typename interior_return_type<Polygon>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            per_range::apply(*it, policy);
+        }
+    }
+};
+
+
+template <typename MultiGeometry, typename Policy, typename SinglePolicy>
+struct multi_remove_spikes
+{
+    static inline void apply(MultiGeometry& multi, Policy const& policy)
+    {
+        for (typename boost::range_iterator<MultiGeometry>::type
+                it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            SinglePolicy::apply(*it, policy);
+        }
+    }
+};
+
+
+}} // namespace detail::remove_spikes
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Tag,
+    typename Geometry,
+    typename Policy
+>
+struct remove_spikes
+{
+    static inline void apply(Geometry&, Policy const&)
+    {}
+};
+
+
+template <typename Ring, typename Policy>
+struct remove_spikes<ring_tag, Ring, Policy>
+    : detail::remove_spikes::range_remove_spikes<Ring, Policy>
+{};
+
+
+
+template <typename Polygon, typename Policy>
+struct remove_spikes<polygon_tag, Polygon, Policy>
+    : detail::remove_spikes::polygon_remove_spikes<Polygon, Policy>
+{};
+
+
+template <typename MultiPolygon, typename Policy>
+struct remove_spikes<multi_polygon_tag, MultiPolygon, Policy>
+    : detail::remove_spikes::multi_remove_spikes
+        <
+            MultiPolygon,
+            Policy,
+            detail::remove_spikes::polygon_remove_spikes
+            <
+                typename boost::range_value<MultiPolygon>::type,
+                Policy
+            >
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+    \ingroup remove_spikes
+    \tparam Geometry geometry type
+    \param geometry the geometry to make remove_spikes
+*/
+template <typename Geometry, typename Policy>
+inline void remove_spikes(Geometry& geometry, Policy const& policy)
+{
+    concept::check<Geometry>();
+
+    dispatch::remove_spikes
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            Policy
+        >::apply(geometry, policy);
+}
+
+
+
+template <typename Point>
+struct remove_elongated_spikes
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+    coordinate_type m_area_div_peri;
+    coordinate_type m_dist_div_peri;
+    coordinate_type m_area_limit;
+    coordinate_type m_distance_limit;
+    coordinate_type m_zero;
+
+
+    inline remove_elongated_spikes(coordinate_type const& area_div_peri = 0.001
+        , coordinate_type const& dist_div_peri = 0.001
+        , coordinate_type const& area_limit = 0.01
+        , coordinate_type const& distance_limit = 1
+        )
+            : m_area_div_peri(area_div_peri)
+            , m_dist_div_peri(dist_div_peri)
+            , m_area_limit(area_limit)
+            , m_distance_limit(distance_limit)
+            , m_zero(coordinate_type())
+    {}
+
+
+    inline bool operator()(Point const& prev,
+                Point const& current, Point const& next) const
+    {
+        coordinate_type d1 = geometry::distance(prev, current);
+        if (d1 < m_distance_limit)
+        {
+            geometry::model::ring<Point> triangle;
+            triangle.push_back(prev);
+            triangle.push_back(current);
+            triangle.push_back(next);
+            triangle.push_back(prev);
+
+            coordinate_type p = geometry::perimeter(triangle);
+            if (p > m_zero)
+            {
+                coordinate_type a = abs(geometry::area(triangle));
+                coordinate_type prop1 = a / p;
+                coordinate_type prop2 = d1 / p;
+
+                bool remove = prop1 < m_area_div_peri
+                    && prop2 < m_dist_div_peri
+                    && a < m_area_limit;
+
+                /*
+                {
+                    coordinate_type d2 = geometry::distance(prev, next);
+                    std::cout << std::endl;
+                    std::cout << "Distance1: "  << d1 << std::endl;
+                    std::cout << "Distance2: "  << d2 << std::endl;
+                    std::cout << "Area:      "  << a << std::endl;
+                    std::cout << "Perimeter: "  << p << std::endl;
+                    std::cout << "Prop1:     "  << prop1 << std::endl;
+                    std::cout << "Prop2:     "  << prop2 << std::endl;
+                    std::cout << "Remove:    "  << (remove ? "true" : "false") << std::endl;
+                }
+                */
+
+                return remove;
+            }
+        }
+        return false;
+    }
+};
+
+
+template <typename Point>
+class remove_by_normalized
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+    coordinate_type m_zero;
+    coordinate_type m_limit;
+
+public :
+    inline remove_by_normalized(coordinate_type const& lm = 1.0e-7)
+        : m_zero(coordinate_type())
+        , m_limit(lm)
+    {}
+
+    inline bool operator()(Point const& prev,
+                Point const& current, Point const& next) const
+    {
+        coordinate_type const x1 = get<0>(prev);
+        coordinate_type const y1 = get<1>(prev);
+        coordinate_type const x2 = get<0>(current);
+        coordinate_type const y2 = get<1>(current);
+
+        coordinate_type dx1 = x2 - x1;
+        coordinate_type dy1 = y2 - y1;
+
+        // Duplicate points (can be created by removing spikes)
+        // can be removed as well. (Can be seen as a spike without length)
+        if (geometry::math::equals(dx1, 0) && geometry::math::equals(dy1, 0))
+        {
+            return true;
+        }
+
+        coordinate_type dx2 = get<0>(next) - x2;
+        coordinate_type dy2 = get<1>(next) - y2;
+
+        // If middle point is duplicate with next, also.
+        if (geometry::math::equals(dx2, 0) && geometry::math::equals(dy2, 0))
+        {
+            return true;
+        }
+
+        // Normalize the vectors -> this results in points+direction
+        // and is comparible between geometries
+        coordinate_type const magnitude1 = sqrt(dx1 * dx1 + dy1 * dy1);
+        coordinate_type const magnitude2 = sqrt(dx2 * dx2 + dy2 * dy2);
+
+        if (magnitude1 > m_zero && magnitude2 > m_zero)
+        {
+            dx1 /= magnitude1;
+            dy1 /= magnitude1;
+            dx2 /= magnitude2;
+            dy2 /= magnitude2;
+
+            // If the directions are opposite, it can be removed
+            if (geometry::math::abs(dx1 + dx2) < m_limit
+                && geometry::math::abs(dy1 + dy2) < m_limit)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_REMOVE_SPIKES_HPP
diff --git a/src/boost/geometry/extensions/algorithms/selected.hpp b/src/boost/geometry/extensions/algorithms/selected.hpp
new file mode 100644
index 0000000..0b1a1e3
--- /dev/null
+++ b/src/boost/geometry/extensions/algorithms/selected.hpp
@@ -0,0 +1,278 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_SELECTED_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_SELECTED_HPP
+
+#include <cmath>
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/topological_dimension.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+    \ingroup impl
+ */
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace selected
+{
+
+/*!
+\details Checks, per dimension, if d[I] not larger than search distance. If true for all
+dimensions then returns true. If larger stops immediately and returns false.
+Calculate during this process the sum, which is only valid if returning true
+*/
+template <typename P1, typename P2, typename T, std::size_t D, std::size_t N>
+struct differences_loop
+{
+    static inline bool apply(P1 const& p1, P2 const& p2, T const& distance, T& sum)
+    {
+        typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+        coordinate_type const c1 = boost::numeric_cast<coordinate_type>(get<D>(p1));
+        coordinate_type const c2 = boost::numeric_cast<coordinate_type>(get<D>(p2));
+
+        T const d = geometry::math::abs(c1 - c2);
+        if (d > distance)
+        {
+            return false;
+        }
+        sum += d * d;
+        return differences_loop<P1, P2, T, D + 1, N>::apply(p1, p2, distance, sum);
+    }
+};
+
+template <typename P1, typename P2, typename T, std::size_t N>
+struct differences_loop<P1, P2, T, N, N>
+{
+    static inline bool apply(P1 const&, P2 const&, T const&, T&)
+    {
+        return true;
+    }
+};
+
+
+
+template <typename PS, typename P, typename T, std::size_t D, std::size_t N>
+struct outside_loop
+{
+    static inline bool apply(PS const& seg1, PS const& seg2, P const& point, T const& distance)
+    {
+        typedef typename select_coordinate_type<PS, P>::type coordinate_type;
+
+        coordinate_type const v = boost::numeric_cast<coordinate_type>(get<D>(point));
+        coordinate_type const s1 = get<D>(seg1);
+        coordinate_type const s2 = get<D>(seg2);
+
+        // Out of reach if left/bottom or right/top of both points making up the segment
+        // I know and currently accept that these comparisons/calculations are done twice per point
+
+        if ((v < s1 - distance && v < s2 - distance) || (v > s1 + distance && v > s2 + distance))
+        {
+            return true;
+        }
+        return outside_loop<PS, P, T, D + 1, N>::apply(seg1, seg2, point, distance);
+    }
+};
+
+template <typename PS, typename P, typename T, std::size_t N>
+struct outside_loop<PS, P, T, N, N>
+{
+    static inline bool apply(PS const&, PS const&, P const&, T const&)
+    {
+        return false;
+    }
+};
+
+
+template <typename P1, typename P2, typename T>
+struct close_to_point
+{
+    static inline bool apply(P1 const& point, P1 const& selection_point, T const& search_radius)
+    {
+        assert_dimension_equal<P1, P2>();
+
+        T sum = 0;
+        if (differences_loop
+                <
+                    P1, P2, T, 0, dimension<P1>::type::value
+                >::apply(point, selection_point, search_radius, sum))
+        {
+            return sum <= search_radius * search_radius;
+        }
+
+        return false;
+    }
+};
+
+template <typename PS, typename P, typename T>
+struct close_to_segment
+{
+    static inline bool apply(PS const& seg1, PS const& seg2, P const& selection_point, T const& search_radius)
+    {
+        assert_dimension_equal<PS, P>();
+
+        if (! outside_loop
+                <
+                    PS, P, T, 0, dimension<P>::type::value
+                >::apply(seg1, seg2, selection_point, search_radius))
+        {
+            // Not outside, calculate dot product/square distance to segment.
+            // Call corresponding strategy
+            typedef typename strategy::distance::services::default_strategy
+                <
+                    segment_tag, P, PS
+                >::type strategy_type;
+            typedef typename strategy::distance::services::return_type<strategy_type>::type return_type;
+
+            strategy_type strategy;
+            return_type result = strategy.apply(selection_point, seg1, seg2);
+            return result < search_radius;
+        }
+
+        return false;
+    }
+};
+
+template <typename R, typename P, typename T>
+struct close_to_range
+{
+    static inline bool apply(R const& range, P const& selection_point, T const& search_radius)
+    {
+        assert_dimension_equal<R, P>();
+
+        std::size_t const n = boost::size(range);
+        if (n == 0)
+        {
+            // Line with zero points, never close
+            return false;
+        }
+
+        typedef typename point_type<R>::type point_type;
+        typedef typename boost::range_iterator<R const>::type iterator_type;
+
+        iterator_type it = boost::begin(range);
+        if (n == 1)
+        {
+            // Line with one point ==> close to point
+            return close_to_point<P, point_type, T>::apply(*it, selection_point, search_radius);
+        }
+
+        iterator_type previous = it++;
+        while(it != boost::end(range))
+        {
+            //typedef segment<point_type const> segment_type;
+            //segment_type s(*previous, *it);
+            if (close_to_segment
+                    <
+                        point_type, P, T
+                    >::apply(*previous, *it, selection_point, search_radius))
+            {
+                return true;
+            }
+            previous = it++;
+        }
+
+        return false;
+    }
+};
+
+template <typename Tag, typename G, typename P, typename T>
+struct use_within
+{
+    static inline bool apply(G const& geometry, P const& selection_point, T const& search_radius)
+    {
+        return geometry::within(selection_point, geometry);
+    }
+};
+
+}} // namespace detail::selected
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+/*!
+    \tparam TD topological dimension
+ */
+template <typename Tag, typename G, std::size_t D, typename P, typename T>
+struct selected
+{
+};
+
+template <typename P1, typename P2, typename T>
+struct selected<point_tag, P1, 0, P2, T> : detail::selected::close_to_point<P1, P2, T> { };
+
+// SEGMENT, TODO HERE (close_to_segment)
+
+template <typename L, typename P, typename T>
+struct selected<linestring_tag, L, 1, P, T> : detail::selected::close_to_range<L, P, T> { };
+
+template <typename Tag, typename G, typename P, typename T>
+struct selected<Tag, G, 2, P, T> : detail::selected::use_within<Tag, G, P, T> { };
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+    \brief Checks if one geometry is selected by a point lying within or in the neighborhood of that geometry
+    \ingroup selected
+    \tparam Geometry type of geometry to check
+    \tparam Point type of point to check
+    \tparam T type of search radius
+    \param geometry geometry which might be located in the neighborhood
+    \param selection_point point to select the geometry
+    \param search_radius for points/linestrings: defines radius of "neighborhood" to find things in
+    \return true if point is within or close to the other geometry
+
+ */
+template<typename Geometry, typename Point, typename RadiusType>
+inline bool selected(Geometry const& geometry,
+        Point const& selection_point,
+        RadiusType const& search_radius)
+{
+    concept::check<Geometry const>();
+    concept::check<Point const>();
+
+    typedef dispatch::selected
+        <
+            typename tag<Geometry>::type,
+            Geometry,
+            topological_dimension<Geometry>::value,
+            Point,
+            RadiusType
+        > selector_type;
+
+    return selector_type::apply(geometry, selection_point, search_radius);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_SELECTED_HPP
diff --git a/src/boost/geometry/extensions/arithmetic/cross_product.hpp b/src/boost/geometry/extensions/arithmetic/cross_product.hpp
new file mode 100644
index 0000000..fcf4ec2
--- /dev/null
+++ b/src/boost/geometry/extensions/arithmetic/cross_product.hpp
@@ -0,0 +1,109 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ARITHMETIC_CROSS_PRODUCT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ARITHMETIC_CROSS_PRODUCT_HPP
+
+
+#include <cstddef>
+
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename P1, typename P2, std::size_t Dimension>
+struct cross_product
+{
+    // We define cross product only for 2d (see Wolfram) and 3d.
+    // In Math, it is also well-defined for 7-dimension.
+    // Generalisation of cross product to n-dimension is defined as
+    // wedge product but it is not direct analogue to binary cross product.
+};
+
+template <typename P1, typename P2>
+struct cross_product<P1, P2, 2>
+{
+    typedef P1 return_type;
+
+    static inline return_type apply(P1 const& p1, P2 const& p2)
+    {
+        assert_dimension<P1, 2>();
+        assert_dimension<P2, 2>();
+
+        // For 2-dimensions, analog of the cross product U(x,y) and V(x,y) is
+        // Ux * Vy - Uy * Vx
+        // which is returned as 0-component (or X) of 2d vector, 1-component is undefined.
+        return_type v;
+        set<0>(v, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
+        return v;
+    }
+};
+
+template <typename P1, typename P2>
+struct cross_product<P1, P2, 3>
+{
+    typedef P1 return_type;
+
+    static inline return_type apply(P1 const& p1, P2 const& p2)
+    {
+        assert_dimension<P1, 3>();
+        assert_dimension<P2, 3>();
+
+        return_type v;
+        set<0>(v, get<1>(p1) * get<2>(p2) - get<2>(p1) * get<1>(p2));
+        set<1>(v, get<2>(p1) * get<0>(p2) - get<0>(p1) * get<2>(p2));
+        set<2>(v, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
+        return v;
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+// TODO: This is a simple draft. If relevant, it can be extended to:
+// - accept vectors of different coordinate_type, but common coordinate_system
+// - if vectors are of mixed 2d and 3d, lower dimension is used
+// - define result_type that will generate type of vector based on:
+// -- select_coordinate_type
+// -- selection of lower dimension
+
+/*!
+    \brief Computes the cross product of two vector.
+    \details Both vectors shall be of the same type.
+             This type also determines type of result vector.
+    \ingroup arithmetic
+    \param p1 first vector
+    \param p2 second vector
+    \return the cross product vector
+ */
+template <typename P1, typename P2>
+inline P1 cross_product(P1 const& p1, P2 const& p2)
+{
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P1>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P2>) );
+
+    return detail::cross_product
+        <
+            P1, P2,
+            dimension<P1>::type::value
+        >::apply(p1, p2);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ARITHMETIC_CROSS_PRODUCT_HPP
diff --git a/src/boost/geometry/extensions/astronomy/core/cs.hpp b/src/boost/geometry/extensions/astronomy/core/cs.hpp
new file mode 100644
index 0000000..c5833a3
--- /dev/null
+++ b/src/boost/geometry/extensions/astronomy/core/cs.hpp
@@ -0,0 +1,53 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSION_ASTRONOMY_CORE_CS_HPP
+#define BOOST_GEOMETRY_EXTENSION_ASTRONOMY_CORE_CS_HPP
+
+#include <boost/geometry/core/coordinate_system.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace cs
+{
+
+
+namespace celestial
+{
+
+/*!
+    \brief Ecliptic (celestial) coordinate system
+    \details Defines the astronomical ecliptic coordinate system "that uses the ecliptic for its fundamental plane"
+    It uses Beta and Lambda as its latitude and longitude.
+    \see http://en.wikipedia.org/wiki/Ecliptic_coordinate_system
+    \ingroup cs
+*/
+template<typename DegreeOrRadian>
+struct ecliptic
+{
+    typedef DegreeOrRadian units;
+};
+
+
+} // namespace celestial
+
+} // namespace cs
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSION_ASTRONOMY_CORE_CS_HPP
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmath.h b/src/boost/geometry/extensions/contrib/ttmath/ttmath.h
new file mode 100644
index 0000000..37c971f
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmath.h
@@ -0,0 +1,2849 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2010, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef headerfilettmathmathtt
+#define headerfilettmathmathtt
+
+/*!
+	\file ttmath.h
+    \brief Mathematics functions.
+*/
+
+#ifdef _MSC_VER
+//warning C4127: conditional expression is constant
+#pragma warning( disable: 4127 )
+//warning C4702: unreachable code
+#pragma warning( disable: 4702 )
+//warning C4800: forcing value to bool 'true' or 'false' (performance warning)
+#pragma warning( disable: 4800 )
+#endif
+
+
+#include "ttmathbig.h"
+#include "ttmathobjects.h"
+
+
+namespace ttmath
+{
+	/*
+ 	 *
+	 *  functions defined here are used only with Big<> types
+	 *
+	 *
+	 */
+
+
+	/*
+ 	 *
+	 *  functions for rounding
+	 *
+	 *
+	 */
+
+
+	/*!
+		this function skips the fraction from x
+		e.g  2.2  = 2
+		     2.7  = 2
+			 -2.2 = 2
+			 -2.7 = 2
+	*/
+	template<class ValueType>
+	ValueType SkipFraction(const ValueType & x)
+	{
+		ValueType result( x );
+		result.SkipFraction();
+
+	return result;
+	}
+
+
+	/*!
+		this function rounds to the nearest integer value
+		e.g  2.2  = 2
+		     2.7  = 3
+			 -2.2 = -2
+			 -2.7 = -3
+	*/
+	template<class ValueType>
+	ValueType Round(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType result( x );
+		uint c = result.Round();
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+
+	/*!
+		this function returns a value representing the smallest integer
+		that is greater than or equal to x
+
+		Ceil(-3.7) = -3
+		Ceil(-3.1) = -3
+		Ceil(-3.0) = -3
+		Ceil(4.0)  = 4
+		Ceil(4.2)  = 5
+		Ceil(4.8)  = 5
+	*/
+	template<class ValueType>
+	ValueType Ceil(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType result(x);
+		uint c = 0;
+
+		result.SkipFraction();
+
+		if( result != x )
+		{
+			// x is with fraction
+			// if x is negative we don't have to do anything
+			if( !x.IsSign() )
+			{
+				ValueType one;
+				one.SetOne();
+
+				c += result.Add(one);
+			}
+		}
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;	
+	}
+
+
+	/*!
+		this function returns a value representing the largest integer
+		that is less than or equal to x
+
+		Floor(-3.6) = -4
+		Floor(-3.1) = -4
+		Floor(-3)   = -3
+		Floor(2)    = 2
+		Floor(2.3)  = 2
+		Floor(2.8)  = 2
+	*/
+	template<class ValueType>
+	ValueType Floor(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType result(x);
+		uint c = 0;
+
+		result.SkipFraction();
+
+		if( result != x )
+		{
+			// x is with fraction
+			// if x is positive we don't have to do anything
+			if( x.IsSign() )
+			{
+				ValueType one;
+				one.SetOne();
+
+				c += result.Sub(one);
+			}
+		}
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;	
+	}
+
+
+
+	/*
+ 	 *
+	 *  logarithms and the exponent
+	 *
+	 *
+	 */
+
+	
+	/*!
+		this function calculates the natural logarithm (logarithm with the base 'e')
+	*/
+	template<class ValueType>
+	ValueType Ln(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType result;
+		uint state = result.Ln(x);
+
+		if( err )
+		{
+			switch( state )
+			{
+			case 0:
+				*err = err_ok;
+				break;
+			case 1:
+				*err = err_overflow;
+				break;
+			case 2:
+				*err = err_improper_argument;
+				break;
+			default:
+				*err = err_internal_error;
+				break;
+			}
+		}
+
+
+	return result;
+	}
+
+
+	/*!
+		this function calculates the logarithm
+	*/
+	template<class ValueType>
+	ValueType Log(const ValueType & x, const ValueType & base, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err ) *err = err_improper_argument;
+			return x;
+		}
+
+		if( base.IsNan() )
+		{
+			if( err ) *err = err_improper_argument;
+			return base;
+		}
+
+		ValueType result;
+		uint state = result.Log(x, base);
+
+		if( err )
+		{
+			switch( state )
+			{
+			case 0:
+				*err = err_ok;
+				break;
+			case 1:
+				*err = err_overflow;
+				break;
+			case 2:
+			case 3:
+				*err = err_improper_argument;
+				break;
+			default:
+				*err = err_internal_error;
+				break;
+			}
+		}
+
+	return result;
+	}
+
+
+	/*!
+		this function calculates the expression e^x
+	*/
+	template<class ValueType>
+	ValueType Exp(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType result;
+		uint c = result.Exp(x);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+	*
+	*	trigonometric functions
+	*
+	*/
+
+
+	/*
+		this namespace consists of auxiliary functions
+		(something like 'private' in a class)
+	*/
+	namespace auxiliaryfunctions
+	{
+
+	/*!
+		an auxiliary function for calculating the Sine
+		(you don't have to call this function) 
+	*/
+	template<class ValueType>
+	uint PrepareSin(ValueType & x, bool & change_sign)
+	{
+	ValueType temp;
+
+		change_sign = false;
+	
+		if( x.IsSign() )
+		{
+			// we're using the formula 'sin(-x) = -sin(x)'
+			change_sign = !change_sign;
+			x.ChangeSign();
+		}
+	
+		// we're reducing the period 2*PI
+		// (for big values there'll always be zero)
+		temp.Set2Pi();
+		
+		if( x.Mod(temp) )
+			return 1;
+		
+
+		// we're setting 'x' as being in the range of <0, 0.5PI>
+
+		temp.SetPi();
+
+		if( x > temp )
+		{
+			// x is in (pi, 2*pi>
+			x.Sub( temp );
+			change_sign = !change_sign;
+		}
+		
+		temp.Set05Pi();
+
+		if( x > temp )
+		{
+			// x is in (0.5pi, pi>
+			x.Sub( temp );
+			x = temp - x;
+		}
+
+	return 0;
+	}
+
+	
+	/*!
+		an auxiliary function for calculating the Sine
+		(you don't have to call this function) 
+
+		it returns Sin(x) where 'x' is from <0, PI/2>
+		we're calculating the Sin with using Taylor series in zero or PI/2
+		(depending on which point of these two points is nearer to the 'x')
+
+		Taylor series:
+		sin(x) = sin(a) + cos(a)*(x-a)/(1!)
+		         - sin(a)*((x-a)^2)/(2!) - cos(a)*((x-a)^3)/(3!)
+				 + sin(a)*((x-a)^4)/(4!) + ...
+
+		when a=0 it'll be:
+		sin(x) = (x)/(1!) - (x^3)/(3!) + (x^5)/(5!) - (x^7)/(7!) + (x^9)/(9!) ...
+
+		and when a=PI/2:
+		sin(x) = 1 - ((x-PI/2)^2)/(2!) + ((x-PI/2)^4)/(4!) - ((x-PI/2)^6)/(6!) ...
+	*/
+	template<class ValueType>
+	ValueType Sin0pi05(const ValueType & x)
+	{
+	ValueType result;
+	ValueType numerator, denominator;
+	ValueType d_numerator, d_denominator;
+	ValueType one, temp, old_result;
+
+		// temp = pi/4
+		temp.Set05Pi();
+		temp.exponent.SubOne();
+
+		one.SetOne();
+
+		if( x < temp ) 
+		{	
+			// we're using the Taylor series with a=0
+			result    = x;
+			numerator = x;
+			denominator = one;
+
+			// d_numerator = x^2
+			d_numerator = x;
+			d_numerator.Mul(x);
+
+			d_denominator = 2;
+		}
+		else
+		{
+			// we're using the Taylor series with a=PI/2
+			result = one;
+			numerator = one;
+			denominator = one;
+
+			// d_numerator = (x-pi/2)^2
+			ValueType pi05;
+			pi05.Set05Pi();
+
+			temp = x;
+			temp.Sub( pi05 );
+			d_numerator = temp;
+			d_numerator.Mul( temp );
+
+			d_denominator = one;
+		}
+
+		uint c = 0;
+		bool addition = false;
+
+		old_result = result;
+		for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
+		{
+			// we're starting from a second part of the formula
+			c += numerator.    Mul( d_numerator );
+			c += denominator.  Mul( d_denominator );
+			c += d_denominator.Add( one );
+			c += denominator.  Mul( d_denominator );
+			c += d_denominator.Add( one );
+			temp = numerator;
+			c += temp.Div(denominator);
+
+			if( c )
+				// Sin is from <-1,1> and cannot make an overflow
+				// but the carry can be from the Taylor series
+				// (then we only break our calculations)
+				break;
+
+			if( addition )
+				result.Add( temp );
+			else
+				result.Sub( temp );
+
+
+			addition = !addition;
+	
+			// we're testing whether the result has changed after adding
+			// the next part of the Taylor formula, if not we end the loop
+			// (it means 'x' is zero or 'x' is PI/2 or this part of the formula
+			// is too small)
+			if( result == old_result )
+				break;
+
+			old_result = result;
+		}
+
+	return result;
+	}
+
+	} // namespace auxiliaryfunctions
+
+
+
+	/*!
+		this function calculates the Sine
+	*/
+	template<class ValueType>
+	ValueType Sin(ValueType x, ErrorCode * err = 0)
+	{
+	using namespace auxiliaryfunctions;
+
+	ValueType one, result;
+	bool change_sign;	
+	
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		if( err )
+			*err = err_ok;
+
+		if( PrepareSin( x, change_sign ) )
+		{
+			// x is too big, we cannnot reduce the 2*PI period
+			// prior to version 0.8.5 the result was zero
+			
+			// result has NaN flag set by default
+
+			if( err )
+				*err = err_overflow; // maybe another error code? err_improper_argument?
+
+		return result; // NaN is set by default
+		}
+
+		result = Sin0pi05( x );
+	
+		one.SetOne();
+
+		// after calculations there can be small distortions in the result
+		if( result > one )
+			result = one;
+		else
+		if( result.IsSign() )
+			// we've calculated the sin from <0, pi/2> and the result
+			// should be positive
+			result.SetZero();
+
+		if( change_sign )
+			result.ChangeSign();	
+		
+	return result;
+	}
+
+	
+	/*!
+		this function calulates the Cosine
+		we're using the formula cos(x) = sin(x + PI/2)
+	*/
+	template<class ValueType>
+	ValueType Cos(ValueType x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType pi05;
+		pi05.Set05Pi();
+
+		uint c = x.Add( pi05 );
+
+		if( c )
+		{
+			if( err )
+				*err = err_overflow;
+	
+		return ValueType(); // result is undefined (NaN is set by default)
+		}
+
+	return Sin(x, err);
+	}
+	
+
+	/*!
+		this function calulates the Tangent
+		we're using the formula tan(x) = sin(x) / cos(x)
+
+		it takes more time than calculating the Tan directly
+		from for example Taylor series but should be a bit preciser
+		because Tan receives its values from -infinity to +infinity
+		and when we calculate it from any series then we can make
+		a greater mistake than calculating 'sin/cos'
+	*/
+	template<class ValueType>
+	ValueType Tan(const ValueType & x, ErrorCode * err = 0)
+	{
+		ValueType result = Cos(x, err);
+		
+		if( err && *err != err_ok )
+			return result;
+
+		if( result.IsZero() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			result.SetNan();
+
+		return result;
+		}
+
+	return Sin(x, err) / result;
+	}
+
+
+	/*!
+		this function calulates the Tangent
+		look at the description of Tan(...)
+
+		(the abbreviation of Tangent can be 'tg' as well)
+	*/
+	template<class ValueType>
+	ValueType Tg(const ValueType & x, ErrorCode * err = 0)
+	{
+		return Tan(x, err);
+	}
+
+
+	/*!
+		this function calulates the Cotangent
+		we're using the formula tan(x) = cos(x) / sin(x)
+
+		(why do we make it in this way? 
+		look at information in Tan() function)
+	*/
+	template<class ValueType>
+	ValueType Cot(const ValueType & x, ErrorCode * err = 0)
+	{
+		ValueType result = Sin(x, err);
+
+		if( err && *err != err_ok )
+			return result;
+
+		if( result.IsZero() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			result.SetNan();
+
+		return result;
+		}
+	
+	return Cos(x, err) / result;
+	}
+
+
+	/*!
+		this function calulates the Cotangent
+		look at the description of Cot(...)
+
+		(the abbreviation of Cotangent can be 'ctg' as well)
+	*/
+	template<class ValueType>
+	ValueType Ctg(const ValueType & x, ErrorCode * err = 0)
+	{
+		return Cot(x, err);
+	}
+
+
+	/*
+ 	 *
+	 *  inverse trigonometric functions
+	 *
+	 *
+	 */
+
+	namespace auxiliaryfunctions
+	{
+
+	/*!
+		an auxiliary function for calculating the Arc Sine
+
+		we're calculating asin from the following formula:
+		asin(x) = x + (1*x^3)/(2*3) + (1*3*x^5)/(2*4*5) + (1*3*5*x^7)/(2*4*6*7) + ... 
+		where abs(x) <= 1
+
+		we're using this formula when x is from <0, 1/2>
+	*/
+	template<class ValueType>
+	ValueType ASin_0(const ValueType & x)
+	{
+	ValueType nominator, denominator, nominator_add, nominator_x, denominator_add, denominator_x;
+	ValueType two, result(x), x2(x);
+	ValueType nominator_temp, denominator_temp, old_result = result;
+	uint c = 0;
+
+	x2.Mul(x);
+	two = 2;
+
+	nominator.SetOne();
+	denominator     = two;
+	nominator_add   = nominator;
+	denominator_add = denominator;
+	nominator_x     = x;
+	denominator_x   = 3;
+
+		for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
+		{
+			c += nominator_x.Mul(x2);
+			nominator_temp = nominator_x;	
+			c += nominator_temp.Mul(nominator);
+			denominator_temp = denominator;
+			c += denominator_temp.Mul(denominator_x);
+			c += nominator_temp.Div(denominator_temp);
+
+			// if there is a carry somewhere we only break the calculating
+			// the result should be ok -- it's from <-pi/2, pi/2>
+			if( c ) 
+				break;
+
+			result.Add(nominator_temp);
+			
+			if( result == old_result )
+				 // there's no sense to calculate more
+				break;
+
+			old_result = result;
+
+
+			c += nominator_add.Add(two);
+			c += denominator_add.Add(two);
+			c += nominator.Mul(nominator_add);
+			c += denominator.Mul(denominator_add);
+			c += denominator_x.Add(two);
+		}
+
+	return result;
+	}
+
+
+
+	/*!
+		an auxiliary function for calculating the Arc Sine
+
+		we're calculating asin from the following formula:
+		asin(x) = pi/2 - sqrt(2)*sqrt(1-x) * asin_temp
+		asin_temp = 1 + (1*(1-x))/((2*3)*(2)) + (1*3*(1-x)^2)/((2*4*5)*(4)) + (1*3*5*(1-x)^3)/((2*4*6*7)*(8)) + ... 
+
+		where abs(x) <= 1
+
+		we're using this formula when x is from (1/2, 1>
+	*/
+	template<class ValueType>
+	ValueType ASin_1(const ValueType & x)
+	{
+	ValueType nominator, denominator, nominator_add, nominator_x, nominator_x_add, denominator_add, denominator_x;
+	ValueType denominator2;
+	ValueType one, two, result;
+	ValueType nominator_temp, denominator_temp, old_result;
+	uint c = 0;
+
+	two = 2;
+
+	one.SetOne();
+	nominator		= one;
+	result			= one;
+	old_result		= result;
+	denominator     = two;
+	nominator_add   = nominator;
+	denominator_add = denominator;
+	nominator_x     = one;
+	nominator_x.Sub(x);
+	nominator_x_add = nominator_x;
+	denominator_x   = 3;
+	denominator2	= two;
+
+
+		for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
+		{
+			nominator_temp = nominator_x;	
+			c += nominator_temp.Mul(nominator);
+			denominator_temp = denominator;
+			c += denominator_temp.Mul(denominator_x);
+			c += denominator_temp.Mul(denominator2);
+			c += nominator_temp.Div(denominator_temp);
+
+			// if there is a carry somewhere we only break the calculating
+			// the result should be ok -- it's from <-pi/2, pi/2>
+			if( c ) 
+				break;
+
+			result.Add(nominator_temp);
+			
+			if( result == old_result )
+				 // there's no sense to calculate more
+				break;
+
+			old_result = result;
+
+			c += nominator_x.Mul(nominator_x_add);
+			c += nominator_add.Add(two);
+			c += denominator_add.Add(two);
+			c += nominator.Mul(nominator_add);
+			c += denominator.Mul(denominator_add);
+			c += denominator_x.Add(two);
+			c += denominator2.Mul(two);
+		}
+
+		
+		nominator_x_add.exponent.AddOne(); // *2
+		one.exponent.SubOne(); // =0.5
+		nominator_x_add.Pow(one); // =sqrt(nominator_x_add)
+		result.Mul(nominator_x_add);
+
+		one.Set05Pi();
+		one.Sub(result);
+
+	return one;
+	}
+
+
+	} // namespace auxiliaryfunctions
+
+
+	/*!
+		this function calculates the Arc Sine
+		x is from <-1,1>
+	*/
+	template<class ValueType>
+	ValueType ASin(ValueType x, ErrorCode * err = 0)
+	{
+	using namespace auxiliaryfunctions;
+
+		ValueType result, one;
+		one.SetOne();
+		bool change_sign = false;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		if( x.GreaterWithoutSignThan(one) )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			return result; // NaN is set by default
+		}
+
+		if( x.IsSign() )
+		{
+			change_sign = true;
+			x.Abs();
+		}
+
+		one.exponent.SubOne(); // =0.5
+
+		// asin(-x) = -asin(x)
+		if( x.GreaterWithoutSignThan(one) )
+			result = ASin_1(x);	
+		else
+			result = ASin_0(x);
+
+		if( change_sign )
+			result.ChangeSign();
+
+		if( err )
+			*err = err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		this function calculates the Arc Cosine
+
+		we're using the formula:
+		acos(x) = pi/2 - asin(x)
+	*/
+	template<class ValueType>
+	ValueType ACos(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType temp;
+
+		temp.Set05Pi();
+		temp.Sub(ASin(x, err));
+
+	return temp;
+	}
+
+
+
+	namespace auxiliaryfunctions
+	{
+
+	/*!
+		an auxiliary function for calculating the Arc Tangent
+
+		arc tan (x) where x is in <0; 0.5)
+		(x can be in (-0.5 ; 0.5) too)
+
+		we're using the Taylor series expanded in zero:
+		atan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 + ...
+	*/
+	template<class ValueType>
+	ValueType ATan0(const ValueType & x)
+	{
+		ValueType nominator, denominator, nominator_add, denominator_add, temp;
+		ValueType result, old_result;
+		bool adding = false;
+		uint c = 0;
+
+		result        = x;
+		old_result    = result;
+		nominator     = x;
+		nominator_add = x;
+		nominator_add.Mul(x);
+
+		denominator.SetOne();
+		denominator_add = 2;
+
+		for(uint i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
+		{
+			c += nominator.Mul(nominator_add);
+			c += denominator.Add(denominator_add);
+	
+			temp = nominator;
+			c += temp.Div(denominator);
+
+			if( c )
+				// the result should be ok
+				break;
+
+			if( adding )
+				result.Add(temp);
+			else
+				result.Sub(temp);
+
+			if( result == old_result )
+				 // there's no sense to calculate more
+				break;
+
+			old_result = result;
+			adding     = !adding;
+		}
+
+	return result;
+	}
+
+
+	/*!
+		an auxiliary function for calculating the Arc Tangent
+
+		where x is in <0 ; 1>
+	*/
+	template<class ValueType>
+	ValueType ATan01(const ValueType & x)
+	{
+		ValueType half;
+		half.Set05();
+
+		/*
+			it would be better if we chose about sqrt(2)-1=0.41... instead of 0.5 here
+
+			because as you can see below:
+			when x = sqrt(2)-1
+			abs(x) = abs( (x-1)/(1+x) )
+			so when we're calculating values around x
+			then they will be better converged to each other
+
+			for example if we have x=0.4999 then during calculating ATan0(0.4999)
+			we have to make about 141 iterations but when we have x=0.5
+			then during calculating ATan0( (x-1)/(1+x) ) we have to make 
+			only about 89 iterations (both for Big<3,9>)
+
+			in the future this 0.5 can be changed
+		*/
+		if( x.SmallerWithoutSignThan(half) )
+			return ATan0(x);
+
+
+		/*
+			x>=0.5 and x<=1
+			(x can be even smaller than 0.5)
+
+			y = atac(x)
+			x = tan(y)
+
+			tan(y-b) = (tan(y)-tab(b)) / (1+tan(y)*tan(b))
+			y-b      = atan( (tan(y)-tab(b)) / (1+tan(y)*tan(b)) )
+			y        = b + atan( (x-tab(b)) / (1+x*tan(b)) )
+
+			let b = pi/4
+			tan(b) = tan(pi/4) = 1
+			y = pi/4 + atan( (x-1)/(1+x) )
+
+			so
+			atac(x) = pi/4 + atan( (x-1)/(1+x) )
+			when x->1 (x converges to 1) the (x-1)/(1+x) -> 0
+			and we can use ATan0() function here
+		*/
+
+		ValueType n(x),d(x),one,result;
+
+		one.SetOne();
+		n.Sub(one);
+		d.Add(one);
+		n.Div(d);
+
+		result = ATan0(n);
+
+		n.Set05Pi();
+		n.exponent.SubOne(); // =pi/4
+		result.Add(n);
+
+	return result;
+	}
+
+
+	/*!
+		an auxiliary function for calculating the Arc Tangent
+		where x > 1
+
+		we're using the formula:
+		atan(x) = pi/2 - atan(1/x) for x>0
+	*/
+	template<class ValueType>
+	ValueType ATanGreaterThanPlusOne(const ValueType & x)
+	{
+	ValueType temp, atan;
+
+		temp.SetOne();
+		
+		if( temp.Div(x) )
+		{
+			// if there was a carry here that means x is very big
+			// and atan(1/x) fast converged to 0
+			atan.SetZero();
+		}
+		else
+			atan = ATan01(temp);
+		
+		temp.Set05Pi();
+		temp.Sub(atan);
+
+	return temp;
+	}
+
+	} // namespace auxiliaryfunctions
+
+
+	/*!
+		this function calculates the Arc Tangent
+	*/
+	template<class ValueType>
+	ValueType ATan(ValueType x)
+	{
+	using namespace auxiliaryfunctions;
+
+		ValueType one, result;
+		one.SetOne();
+		bool change_sign = false;
+
+		if( x.IsNan() )
+			return x;
+
+		// if x is negative we're using the formula:
+		// atan(-x) = -atan(x)
+		if( x.IsSign() )
+		{
+			change_sign = true;
+			x.Abs();
+		}
+
+		if( x.GreaterWithoutSignThan(one) )
+			result = ATanGreaterThanPlusOne(x);
+		else
+			result = ATan01(x);
+
+		if( change_sign )
+			result.ChangeSign();
+
+	return result;
+	}
+
+
+	/*!
+		this function calculates the Arc Tangent
+		look at the description of ATan(...)
+
+		(the abbreviation of Arc Tangent can be 'atg' as well)
+	*/
+	template<class ValueType>
+	ValueType ATg(const ValueType & x)
+	{
+		return ATan(x);
+	}
+
+
+	/*!
+		this function calculates the Arc Cotangent
+	
+		we're using the formula:
+		actan(x) = pi/2 - atan(x)
+	*/
+	template<class ValueType>
+	ValueType ACot(const ValueType & x)
+	{
+	ValueType result;
+
+		result.Set05Pi();
+		result.Sub(ATan(x));
+
+	return result;
+	}
+
+
+	/*!
+		this function calculates the Arc Cotangent
+		look at the description of ACot(...)
+
+		(the abbreviation of Arc Cotangent can be 'actg' as well)
+	*/
+	template<class ValueType>
+	ValueType ACtg(const ValueType & x)
+	{
+		return ACot(x);
+	}
+
+
+	/*
+ 	 *
+	 *  hyperbolic functions
+	 *
+	 *
+	 */
+
+
+	/*!
+		this function calculates the Hyperbolic Sine
+
+		we're using the formula sinh(x)= ( e^x - e^(-x) ) / 2
+	*/
+	template<class ValueType>
+	ValueType Sinh(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType ex, emx;
+		uint c = 0;
+
+		c += ex.Exp(x);
+		c += emx.Exp(-x);
+
+		c += ex.Sub(emx);
+		c += ex.exponent.SubOne();
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return ex;
+	}
+
+
+	/*!
+		this function calculates the Hyperbolic Cosine
+
+		we're using the formula cosh(x)= ( e^x + e^(-x) ) / 2
+	*/
+	template<class ValueType>
+	ValueType Cosh(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType ex, emx;
+		uint c = 0;
+
+		c += ex.Exp(x);
+		c += emx.Exp(-x);
+
+		c += ex.Add(emx);
+		c += ex.exponent.SubOne();
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return ex;
+	}
+
+
+	/*!
+		this function calculates the Hyperbolic Tangent
+
+		we're using the formula tanh(x)= ( e^x - e^(-x) ) / ( e^x + e^(-x) )
+	*/
+	template<class ValueType>
+	ValueType Tanh(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType ex, emx, nominator, denominator;
+		uint c = 0;
+
+		c += ex.Exp(x);
+		c += emx.Exp(-x);
+
+		nominator = ex;
+		c += nominator.Sub(emx);
+		denominator = ex;
+		c += denominator.Add(emx);
+		
+		c += nominator.Div(denominator);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return nominator;
+	}
+
+
+	/*!
+		this function calculates the Hyperbolic Tangent
+		look at the description of Tanh(...)
+
+		(the abbreviation of Hyperbolic Tangent can be 'tgh' as well)
+	*/
+	template<class ValueType>
+	ValueType Tgh(const ValueType & x, ErrorCode * err = 0)
+	{
+		return Tanh(x, err);
+	}
+
+	/*!
+		this function calculates the Hyperbolic Cotangent
+
+		we're using the formula coth(x)= ( e^x + e^(-x) ) / ( e^x - e^(-x) )
+	*/
+	template<class ValueType>
+	ValueType Coth(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		if( x.IsZero() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			return ValueType(); // NaN is set by default
+		}
+
+		ValueType ex, emx, nominator, denominator;
+		uint c = 0;
+
+		c += ex.Exp(x);
+		c += emx.Exp(-x);
+
+		nominator = ex;
+		c += nominator.Add(emx);
+		denominator = ex;
+		c += denominator.Sub(emx);
+		
+		c += nominator.Div(denominator);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return nominator;
+	}
+
+
+	/*!
+		this function calculates the Hyperbolic Cotangent
+		look at the description of Coth(...)
+
+		(the abbreviation of Hyperbolic Cotangent can be 'ctgh' as well)
+	*/
+	template<class ValueType>
+	ValueType Ctgh(const ValueType & x, ErrorCode * err = 0)
+	{
+		return Coth(x, err);
+	}
+
+
+	/*
+ 	 *
+	 *  inverse hyperbolic functions
+	 *
+	 *
+	 */
+
+
+	/*!
+		inverse hyperbolic sine
+
+		asinh(x) = ln( x + sqrt(x^2 + 1) )
+	*/
+	template<class ValueType>
+	ValueType ASinh(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType xx(x), one, result;
+		uint c = 0;
+		one.SetOne();
+
+		c += xx.Mul(x);
+		c += xx.Add(one);
+		one.exponent.SubOne(); // one=0.5
+		// xx is >= 1 
+		c += xx.PowFrac(one); // xx=sqrt(xx)
+		c += xx.Add(x);
+		c += result.Ln(xx); // xx > 0
+
+		// here can only be a carry
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		inverse hyperbolic cosine
+
+		acosh(x) = ln( x + sqrt(x^2 - 1) )  x in <1, infinity)
+	*/
+	template<class ValueType>
+	ValueType ACosh(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType xx(x), one, result;
+		uint c = 0;
+		one.SetOne();
+
+		if( x < one )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return result; // NaN is set by default
+		}
+
+		c += xx.Mul(x);
+		c += xx.Sub(one);
+		// xx is >= 0
+		// we can't call a PowFrac when the 'x' is zero
+		// if x is 0 the sqrt(0) is 0
+		if( !xx.IsZero() )
+		{
+			one.exponent.SubOne(); // one=0.5
+			c += xx.PowFrac(one); // xx=sqrt(xx)
+		}
+		c += xx.Add(x);
+		c += result.Ln(xx); // xx >= 1
+
+		// here can only be a carry
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		inverse hyperbolic tangent
+
+		atanh(x) = 0.5 * ln( (1+x) / (1-x) )  x in (-1, 1)
+	*/
+	template<class ValueType>
+	ValueType ATanh(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType nominator(x), denominator, one, result;
+		uint c = 0;
+		one.SetOne();
+
+		if( !x.SmallerWithoutSignThan(one) )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return result; // NaN is set by default
+		}
+
+		c += nominator.Add(one);
+		denominator = one;
+		c += denominator.Sub(x);
+		c += nominator.Div(denominator);
+		c += result.Ln(nominator);
+		c += result.exponent.SubOne();
+
+		// here can only be a carry
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		inverse hyperbolic tantent
+	*/
+	template<class ValueType>
+	ValueType ATgh(const ValueType & x, ErrorCode * err = 0)
+	{
+		return ATanh(x, err);
+	}
+
+
+	/*!
+		inverse hyperbolic cotangent
+
+		acoth(x) = 0.5 * ln( (x+1) / (x-1) )  x in (-infinity, -1) or (1, infinity)
+	*/
+	template<class ValueType>
+	ValueType ACoth(const ValueType & x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x; // NaN
+		}
+
+		ValueType nominator(x), denominator(x), one, result;
+		uint c = 0;
+		one.SetOne();
+
+		if( !x.GreaterWithoutSignThan(one) )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return result; // NaN is set by default
+		}
+
+		c += nominator.Add(one);
+		c += denominator.Sub(one);
+		c += nominator.Div(denominator);
+		c += result.Ln(nominator);
+		c += result.exponent.SubOne();
+
+		// here can only be a carry
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		inverse hyperbolic cotantent
+	*/
+	template<class ValueType>
+	ValueType ACtgh(const ValueType & x, ErrorCode * err = 0)
+	{
+		return ACoth(x, err);
+	}
+
+
+
+
+
+	/*
+ 	 *
+	 *  functions for converting between degrees, radians and gradians
+	 *
+	 *
+	 */
+
+
+	/*!
+		this function converts degrees to radians
+		
+		it returns: x * pi / 180
+	*/
+	template<class ValueType>
+	ValueType DegToRad(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType result, temp;
+	uint c = 0;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		result = x;
+
+		// it is better to make division first and then multiplication
+		// the result is more accurate especially when x is: 90,180,270 or 360
+		temp = 180;
+		c += result.Div(temp);
+
+		temp.SetPi();
+		c += result.Mul(temp);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		this function converts radians to degrees
+		
+		it returns: x * 180 / pi
+	*/
+	template<class ValueType>
+	ValueType RadToDeg(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType result, delimiter;
+	uint c = 0;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		result = 180;
+		c += result.Mul(x);
+
+		delimiter.SetPi();
+		c += result.Div(delimiter);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		this function converts degrees in the long format into one value
+
+		long format: (degrees, minutes, seconds)
+		minutes and seconds must be greater than or equal zero
+
+		result: 
+		if d>=0 : result= d + ((s/60)+m)/60
+		if d<0  : result= d - ((s/60)+m)/60
+
+		((s/60)+m)/60 = (s+60*m)/3600 (second version is faster because 
+		there's only one division)
+
+		for example:
+		DegToDeg(10, 30, 0) = 10.5
+		DegToDeg(10, 24, 35.6)=10.4098(8)
+	*/
+	template<class ValueType>
+	ValueType DegToDeg(	const ValueType & d, const ValueType & m, const ValueType & s,
+						ErrorCode * err = 0)
+	{
+	ValueType delimiter, multipler;
+	uint c = 0;
+
+		if( d.IsNan() || m.IsNan() || s.IsNan() || m.IsSign() || s.IsSign() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			delimiter.SetZeroNan(); // not needed, only to get rid of GCC warning about an uninitialized variable
+
+		return delimiter;
+		}
+
+		multipler = 60;
+		delimiter = 3600;
+
+		c += multipler.Mul(m);
+		c += multipler.Add(s);
+		c += multipler.Div(delimiter);
+
+		if( d.IsSign() )
+			multipler.ChangeSign();
+
+		c += multipler.Add(d);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return multipler;
+	}
+
+
+	/*!
+		this function converts degrees in the long format to radians
+	*/
+	template<class ValueType>
+	ValueType DegToRad(	const ValueType & d, const ValueType & m, const ValueType & s,
+						ErrorCode * err = 0)
+	{
+		ValueType temp_deg = DegToDeg(d,m,s,err);
+
+		if( err && *err!=err_ok )
+			return temp_deg;
+
+	return DegToRad(temp_deg, err);
+	}
+
+
+	/*!
+		this function converts gradians to radians
+		
+		it returns: x * pi / 200
+	*/
+	template<class ValueType>
+	ValueType GradToRad(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType result, temp;
+	uint c = 0;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		result = x;
+
+		// it is better to make division first and then multiplication
+		// the result is more accurate especially when x is: 100,200,300 or 400
+		temp = 200;
+		c += result.Div(temp);
+
+		temp.SetPi();
+		c += result.Mul(temp);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		this function converts radians to gradians
+		
+		it returns: x * 200 / pi
+	*/
+	template<class ValueType>
+	ValueType RadToGrad(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType result, delimiter;
+	uint c = 0;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		result = 200;
+		c += result.Mul(x);
+
+		delimiter.SetPi();
+		c += result.Div(delimiter);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		this function converts degrees to gradians
+		
+		it returns: x * 200 / 180
+	*/
+	template<class ValueType>
+	ValueType DegToGrad(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType result, temp;
+	uint c = 0;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		result = x;
+
+		temp = 200;
+		c += result.Mul(temp);
+
+		temp = 180;
+		c += result.Div(temp);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+	/*!
+		this function converts degrees in the long format to gradians
+	*/
+	template<class ValueType>
+	ValueType DegToGrad( const ValueType & d, const ValueType & m, const ValueType & s,
+						 ErrorCode * err = 0)
+	{
+		ValueType temp_deg = DegToDeg(d,m,s,err);
+
+		if( err && *err!=err_ok )
+			return temp_deg;
+
+	return DegToGrad(temp_deg, err);
+	}
+
+
+	/*!
+		this function converts degrees to gradians
+		
+		it returns: x * 180 / 200
+	*/
+	template<class ValueType>
+	ValueType GradToDeg(const ValueType & x, ErrorCode * err = 0)
+	{
+	ValueType result, temp;
+	uint c = 0;
+
+		if( x.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return x;
+		}
+
+		result = x;
+
+		temp = 180;
+		c += result.Mul(temp);
+
+		temp = 200;
+		c += result.Div(temp);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return result;
+	}
+
+
+
+
+	/*
+ 	 *
+	 *  another functions
+	 *
+	 *
+	 */
+
+
+	/*!
+		this function calculates the square root
+
+		Sqrt(9) = 3
+	*/
+	template<class ValueType>
+	ValueType Sqrt(ValueType x, ErrorCode * err = 0)
+	{
+		if( x.IsNan() || x.IsSign() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			x.SetNan();
+
+		return x;
+		}
+
+		uint c = x.Sqrt();
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return x;
+	}
+
+
+
+	namespace auxiliaryfunctions
+	{
+
+	template<class ValueType>
+	bool RootCheckIndexSign(ValueType & x, const ValueType & index, ErrorCode * err)
+	{
+		if( index.IsSign() )
+		{
+			// index cannot be negative
+			if( err )
+				*err = err_improper_argument;
+
+			x.SetNan();
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	bool RootCheckIndexZero(ValueType & x, const ValueType & index, ErrorCode * err)
+	{
+		if( index.IsZero() )
+		{
+			if( x.IsZero() )
+			{
+				// there isn't root(0;0) - we assume it's not defined
+				if( err )
+					*err = err_improper_argument;
+
+				x.SetNan();
+
+			return true;
+			}
+	
+			// root(x;0) is 1 (if x!=0)
+			x.SetOne();
+
+			if( err )
+				*err = err_ok;
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	bool RootCheckIndexOne(const ValueType & index, ErrorCode * err)
+	{
+		ValueType one;
+		one.SetOne();
+
+		if( index == one )
+		{
+			//root(x;1) is x
+			// we do it because if we used the PowFrac function
+			// we would lose the precision
+			if( err )
+				*err = err_ok;
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	bool RootCheckIndexTwo(ValueType & x, const ValueType & index, ErrorCode * err)
+	{
+		if( index == 2 )
+		{
+			x = Sqrt(x, err);
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	bool RootCheckIndexFrac(ValueType & x, const ValueType & index, ErrorCode * err)
+	{
+		if( !index.IsInteger() )
+		{
+			// index must be integer
+			if( err )
+				*err = err_improper_argument;
+
+			x.SetNan();
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	bool RootCheckXZero(ValueType & x, ErrorCode * err)
+	{
+		if( x.IsZero() )
+		{
+			// root(0;index) is zero (if index!=0)
+			// RootCheckIndexZero() must be called beforehand
+			x.SetZero();
+
+			if( err )
+				*err = err_ok;
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	bool RootCheckIndex(ValueType & x, const ValueType & index, ErrorCode * err, bool * change_sign)
+	{
+		*change_sign = false;
+
+		if( index.Mod2() )
+		{
+			// index is odd (1,3,5...)
+			if( x.IsSign() )
+			{
+				*change_sign = true;
+				x.Abs();
+			}
+		}
+		else
+		{
+			// index is even
+			// x cannot be negative
+			if( x.IsSign() )
+			{
+				if( err )
+					*err = err_improper_argument;
+
+				x.SetNan();
+
+				return true;
+			}
+		}
+
+	return false;
+	}
+
+
+	template<class ValueType>
+	uint RootCorrectInteger(ValueType & old_x, ValueType & x, const ValueType & index)
+	{
+		if( !old_x.IsInteger() || x.IsInteger() || !index.exponent.IsSign() )
+			return 0;
+
+		// old_x is integer,
+		// x is not integer,
+		// index is relatively small (index.exponent<0 or index.exponent<=0)
+		// (because we're using a special powering algorithm Big::PowUInt())
+
+		uint c = 0;
+
+		ValueType temp(x);
+		c += temp.Round();
+
+		ValueType temp_round(temp);
+		c += temp.PowUInt(index);
+
+		if( temp == old_x )
+			x = temp_round;
+
+	return (c==0)? 0 : 1;
+	}
+
+
+
+	} // namespace auxiliaryfunctions 
+
+
+
+	/*!
+		indexth Root of x
+		index must be integer and not negative <0;1;2;3....)
+
+		if index==0 the result is one
+		if x==0 the result is zero and we assume root(0;0) is not defined
+
+		if index is even (2;4;6...) the result is x^(1/index) and x>0
+		if index is odd (1;2;3;...) the result is either 
+			-(abs(x)^(1/index)) if x<0    or
+			       x^(1/index)) if x>0
+
+		(for index==1 the result is equal x)
+	*/
+	template<class ValueType>
+	ValueType Root(ValueType x, const ValueType & index, ErrorCode * err = 0)
+	{
+		using namespace auxiliaryfunctions;
+
+		if( x.IsNan() || index.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			x.SetNan();
+
+		return x;
+		}
+
+		if( RootCheckIndexSign(x, index, err) ) return x;
+		if( RootCheckIndexZero(x, index, err) ) return x;
+		if( RootCheckIndexOne (   index, err) ) return x;
+		if( RootCheckIndexTwo (x, index, err) ) return x;
+		if( RootCheckIndexFrac(x, index, err) ) return x;
+		if( RootCheckXZero    (x,        err) ) return x;
+
+		// index integer and index!=0
+		// x!=0
+
+		ValueType old_x(x);
+		bool change_sign;
+
+		if( RootCheckIndex(x, index, err, &change_sign ) ) return x;
+
+		ValueType temp;
+		uint c = 0;
+
+		// we're using the formula: root(x ; n) = exp( ln(x) / n )
+		c += temp.Ln(x);
+		c += temp.Div(index);
+		c += x.Exp(temp);
+
+		if( change_sign )
+		{
+			// x is different from zero
+			x.SetSign();
+		}
+
+		c += RootCorrectInteger(old_x, x, index);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return x;
+	}
+
+
+
+	/*!
+		absolute value of x
+		e.g.  -2 = 2 
+		       2 = 2
+	*/
+	template<class ValueType>
+	ValueType Abs(const ValueType & x)
+	{
+		ValueType result( x );
+		result.Abs();
+
+	return result;
+	}
+
+
+	/*!
+		it returns the sign of the value
+		e.g.  -2 = -1 
+		       0 = 0
+		      10 = 1
+	*/
+	template<class ValueType>
+	ValueType Sgn(ValueType x)
+	{
+		x.Sgn();
+
+	return x;
+	}
+
+
+	/*!
+		the remainder from a division
+
+		e.g.
+		mod( 12.6 ;  3) =  0.6   because 12.6  = 3*4 + 0.6
+		mod(-12.6 ;  3) = -0.6   bacause -12.6 = 3*(-4) + (-0.6)
+		mod( 12.6 ; -3) =  0.6
+		mod(-12.6 ; -3) = -0.6
+	*/
+	template<class ValueType>
+	ValueType Mod(ValueType a, const ValueType & b, ErrorCode * err = 0)
+	{
+		if( a.IsNan() || b.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			a.SetNan();
+
+		return a;
+		}
+
+		uint c = a.Mod(b);
+
+		if( err )
+			*err = c ? err_overflow : err_ok;
+
+	return a;
+	}
+
+
+
+	namespace auxiliaryfunctions
+	{
+
+	/*!
+		this function is used to store factorials in a given container
+		'more' means how many values should be added at the end
+
+			e.g.
+			std::vector<ValueType> fact;
+			SetFactorialSequence(fact, 3);
+			// now the container has three values: 1  1  2
+
+			SetFactorialSequence(fact, 2);
+			// now the container has five values:  1  1  2  6  24
+	*/
+	template<class ValueType>
+	void SetFactorialSequence(std::vector<ValueType> & fact, uint more = 20)
+	{
+		if( more == 0 )
+			more = 1;
+
+		uint start = static_cast<uint>(fact.size());
+		fact.resize(fact.size() + more);
+
+		if( start == 0 )
+		{
+			fact[0] = 1;
+			++start;
+		}
+
+		for(uint i=start ; i<fact.size() ; ++i)
+		{
+			fact[i] = fact[i-1];
+			fact[i].MulInt(i);
+		}
+	}
+
+
+	/*!
+		an auxiliary function used to calculate Bernoulli numbers
+
+		this function returns a sum:
+		sum(m) = sum_{k=0}^{m-1} {2^k * (m k) * B(k)}    k in [0, m-1]   (m k) means binomial coefficient = (m! / (k! * (m-k)!))
+
+		you should have sufficient factorials in cgamma.fact
+		(cgamma.fact should have at least m items)
+
+		n_ should be equal 2
+	*/
+	template<class ValueType>
+	ValueType SetBernoulliNumbersSum(CGamma<ValueType> & cgamma, const ValueType & n_, uint m,
+									  const volatile StopCalculating * stop = 0)
+	{
+	ValueType k_, temp, temp2, temp3, sum;
+
+		sum.SetZero();
+		
+		for(uint k=0 ; k<m ; ++k)			// k<m means k<=m-1
+		{
+			if( stop && (k & 15)==0 )		// means: k % 16 == 0
+				if( stop->WasStopSignal() )
+					return ValueType();		// NaN
+
+			if( k>1 && (k & 1) == 1 )		// for that k the Bernoulli number is zero
+				continue;
+
+			k_ = k;
+
+			temp = n_;				// n_ is equal 2
+			temp.Pow(k_);
+			// temp = 2^k
+
+			temp2 = cgamma.fact[m];
+			temp3 = cgamma.fact[k];
+			temp3.Mul(cgamma.fact[m-k]);
+			temp2.Div(temp3);
+			// temp2 = (m k) = m! / ( k! * (m-k)! )
+
+			temp.Mul(temp2);
+			temp.Mul(cgamma.bern[k]);
+
+			sum.Add(temp);
+			// sum += 2^k * (m k) * B(k)
+
+			if( sum.IsNan() )
+				break;
+		}
+
+	return sum;
+	}
+
+
+	/*!
+		an auxiliary function used to calculate Bernoulli numbers
+		start is >= 2
+
+		we use the recurrence formula: 
+		   B(m) = 1 / (2*(1 - 2^m)) * sum(m)
+		   where sum(m) is calculated by SetBernoulliNumbersSum()
+	*/
+	template<class ValueType>
+	bool SetBernoulliNumbersMore(CGamma<ValueType> & cgamma, uint start, const volatile StopCalculating * stop = 0)
+	{
+	ValueType denominator, temp, temp2, temp3, m_, sum, sum2, n_, k_;
+
+		const uint n = 2;
+		n_ = n;
+
+		// start is >= 2
+		for(uint m=start ; m<cgamma.bern.size() ; ++m)
+		{
+			if( (m & 1) == 1 )
+			{
+				cgamma.bern[m].SetZero();
+			}
+			else
+			{
+				m_ = m;
+
+				temp = n_;				// n_ = 2
+				temp.Pow(m_);
+				// temp = 2^m
+
+				denominator.SetOne();
+				denominator.Sub(temp);
+				if( denominator.exponent.AddOne() ) // it means: denominator.MulInt(2)
+					denominator.SetNan();
+
+				// denominator = 2 * (1 - 2^m)
+
+				cgamma.bern[m] = SetBernoulliNumbersSum(cgamma, n_, m, stop);
+
+				if( stop && stop->WasStopSignal() )
+				{
+					cgamma.bern.resize(m);		// valid numbers are in [0, m-1]
+					return false;
+				}
+
+				cgamma.bern[m].Div(denominator);
+			}
+		}
+
+	return true;
+	}
+
+
+	/*!
+		this function is used to calculate Bernoulli numbers,
+		returns false if there was a stop signal,
+		'more' means how many values should be added at the end
+
+			e.g.
+			typedef Big<1,2> MyBig;
+			CGamma<MyBig> cgamma;
+			SetBernoulliNumbers(cgamma, 3);
+			// now we have three first Bernoulli numbers:  1  -0.5  0.16667
+			
+			SetBernoulliNumbers(cgamma, 4);
+			// now we have 7 Bernoulli numbers:  1  -0.5  0.16667   0   -0.0333   0   0.0238
+	*/
+	template<class ValueType>
+	bool SetBernoulliNumbers(CGamma<ValueType> & cgamma, uint more = 20, const volatile StopCalculating * stop = 0)
+	{
+		if( more == 0 )
+			more = 1;
+
+		uint start = static_cast<uint>(cgamma.bern.size());
+		cgamma.bern.resize(cgamma.bern.size() + more);
+
+		if( start == 0 )
+		{
+			cgamma.bern[0].SetOne();
+			++start;
+		}
+
+		if( cgamma.bern.size() == 1 )
+			return true;
+
+		if( start == 1 )
+		{
+			cgamma.bern[1].Set05();
+			cgamma.bern[1].ChangeSign();
+			++start;
+		}
+
+		// we should have sufficient factorials in cgamma.fact
+		if( cgamma.fact.size() < cgamma.bern.size() )
+			SetFactorialSequence(cgamma.fact, static_cast<uint>(cgamma.bern.size() - cgamma.fact.size()));
+
+
+	return SetBernoulliNumbersMore(cgamma, start, stop);
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+
+		we calculate a sum:
+		   sum(n) = sum_{m=2} { B(m) / ( (m^2 - m) * n^(m-1) )  } = 1/(12*n) - 1/(360*n^3) + 1/(1260*n^5) + ...
+	       B(m) means a mth Bernoulli number
+		   the sum starts from m=2, we calculate as long as the value will not change after adding a next part
+	*/
+	template<class ValueType>
+	ValueType GammaFactorialHighSum(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err,
+									const volatile StopCalculating * stop)
+	{
+	ValueType temp, temp2, denominator, sum, oldsum;
+
+		sum.SetZero();
+
+		for(uint m=2 ; m<TTMATH_ARITHMETIC_MAX_LOOP ; m+=2)
+		{
+			if( stop && (m & 3)==0 ) // (m & 3)==0 means: (m % 4)==0
+				if( stop->WasStopSignal() )
+				{
+					err = err_interrupt;
+					return ValueType(); // NaN
+				}
+
+			temp = (m-1);
+			denominator = n;
+			denominator.Pow(temp);
+			// denominator = n ^ (m-1)
+
+			temp = m;
+			temp2 = temp;
+			temp.Mul(temp2);
+			temp.Sub(temp2);
+			// temp = m^2 - m
+
+			denominator.Mul(temp);
+			// denominator = (m^2 - m) * n ^ (m-1)
+
+			if( m >= cgamma.bern.size() )
+			{
+				if( !SetBernoulliNumbers(cgamma, m - cgamma.bern.size() + 1 + 3, stop) ) // 3 more than needed
+				{
+					// there was the stop signal
+					err = err_interrupt;
+					return ValueType(); // NaN
+				}
+			}
+
+			temp = cgamma.bern[m];
+			temp.Div(denominator);
+
+			oldsum = sum;
+			sum.Add(temp);
+
+			if( sum.IsNan() || oldsum==sum )
+				break;
+		}
+
+	return sum;
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+
+		we calculate a helper function GammaFactorialHigh() by using Stirling's series:
+		   n! = (n/e)^n * sqrt(2*pi*n) * exp( sum(n) )
+		   where n is a real number (not only an integer) and is sufficient large (greater than TTMATH_GAMMA_BOUNDARY)
+		   and sum(n) is calculated by GammaFactorialHighSum()
+	*/
+	template<class ValueType>
+	ValueType GammaFactorialHigh(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err,
+								 const volatile StopCalculating * stop)
+	{
+	ValueType temp, temp2, temp3, denominator, sum;
+
+		temp.Set2Pi();
+		temp.Mul(n);
+		temp2 = Sqrt(temp);
+		// temp2 = sqrt(2*pi*n)
+
+		temp = n;
+		temp3.SetE();
+		temp.Div(temp3);
+		temp.Pow(n);
+		// temp = (n/e)^n
+
+		sum = GammaFactorialHighSum(n, cgamma, err, stop);
+		temp3.Exp(sum);
+		// temp3 = exp(sum)
+
+		temp.Mul(temp2);
+		temp.Mul(temp3);
+
+	return temp;
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+
+		Gamma(x) = GammaFactorialHigh(x-1)
+	*/
+	template<class ValueType>
+	ValueType GammaPlusHigh(ValueType n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
+	{
+	ValueType one;
+
+		one.SetOne();
+		n.Sub(one);
+
+	return GammaFactorialHigh(n, cgamma, err, stop);
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+	
+		we use this function when n is integer and a small value (from 0 to TTMATH_GAMMA_BOUNDARY]
+		we use the formula:
+		   gamma(n) = (n-1)! = 1 * 2 * 3 * ... * (n-1) 
+	*/
+	template<class ValueType>
+	ValueType GammaPlusLowIntegerInt(uint n, CGamma<ValueType> & cgamma)
+	{
+		TTMATH_ASSERT( n > 0 )
+
+		if( n - 1 < static_cast<uint>(cgamma.fact.size()) )
+			return cgamma.fact[n - 1];
+
+		ValueType res;
+		uint start = 2;
+
+		if( cgamma.fact.size() < 2 )
+		{
+			res.SetOne();
+		}
+		else
+		{
+			start = static_cast<uint>(cgamma.fact.size());
+			res   = cgamma.fact[start-1];
+		}
+
+		for(uint i=start ; i<n ; ++i)
+			res.MulInt(i);
+
+	return res;
+	}
+	
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+
+		we use this function when n is integer and a small value (from 0 to TTMATH_GAMMA_BOUNDARY]
+	*/
+	template<class ValueType>
+	ValueType GammaPlusLowInteger(const ValueType & n, CGamma<ValueType> & cgamma)
+	{
+	sint n_;
+
+		n.ToInt(n_);
+
+	return GammaPlusLowIntegerInt(n_, cgamma);
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+
+		we use this function when n is a small value (from 0 to TTMATH_GAMMA_BOUNDARY]
+		we use a recurrence formula:
+		   gamma(z+1) = z * gamma(z)
+		   then: gamma(z) = gamma(z+1) / z
+
+		   e.g.
+		   gamma(3.89) = gamma(2001.89) / ( 3.89 * 4.89 * 5.89 * ... * 1999.89 * 2000.89 )
+	*/
+	template<class ValueType>
+	ValueType GammaPlusLow(ValueType n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
+	{
+	ValueType one, denominator, temp, boundary;
+
+		if( n.IsInteger() )
+			return GammaPlusLowInteger(n, cgamma);
+
+		one.SetOne();
+		denominator = n;
+		boundary    = TTMATH_GAMMA_BOUNDARY;
+
+		while( n < boundary )
+		{
+			n.Add(one);
+			denominator.Mul(n);
+		}
+
+		n.Add(one);
+
+		// now n is sufficient big
+		temp = GammaPlusHigh(n, cgamma, err, stop);
+		temp.Div(denominator);
+
+	return temp;
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+	*/
+	template<class ValueType>
+	ValueType GammaPlus(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
+	{
+		if( n > TTMATH_GAMMA_BOUNDARY )
+			return GammaPlusHigh(n, cgamma, err, stop);
+
+	return GammaPlusLow(n, cgamma, err, stop);
+	}
+
+
+	/*!
+		an auxiliary function used to calculate the Gamma() function
+
+		this function is used when n is negative
+		we use the reflection formula:
+		   gamma(1-z) * gamma(z) = pi / sin(pi*z)
+		   then: gamma(z) = pi / (sin(pi*z) * gamma(1-z))
+
+	*/
+	template<class ValueType>
+	ValueType GammaMinus(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode & err, const volatile StopCalculating * stop)
+	{
+	ValueType pi, denominator, temp, temp2;
+
+		if( n.IsInteger() )
+		{
+			// gamma function is not defined when n is negative and integer
+			err = err_improper_argument;
+			return temp; // NaN
+		}
+
+		pi.SetPi();
+
+		temp = pi;
+		temp.Mul(n);
+		temp2 = Sin(temp);
+		// temp2 = sin(pi * n)
+
+		temp.SetOne();
+		temp.Sub(n);
+		temp = GammaPlus(temp, cgamma, err, stop);
+		// temp = gamma(1 - n)
+
+		temp.Mul(temp2);
+		pi.Div(temp);
+
+	return pi;
+	}
+
+	} // namespace auxiliaryfunctions
+
+
+
+	/*!
+		this function calculates the Gamma function
+
+		it's multithread safe, you should create a CGamma<> object and use it whenever you call the Gamma()
+		e.g.
+			typedef Big<1,2> MyBig;
+			MyBig x=234, y=345.53;
+			CGamma<MyBig> cgamma;
+			std::cout << Gamma(x, cgamma) << std::endl;
+			std::cout << Gamma(y, cgamma) << std::endl;
+		in the CGamma<> object the function stores some coefficients (factorials, Bernoulli numbers),
+		and they will be reused in next calls to the function
+
+		each thread should have its own CGamma<> object, and you can use these objects with Factorial() function too
+	*/
+	template<class ValueType>
+	ValueType Gamma(const ValueType & n, CGamma<ValueType> & cgamma, ErrorCode * err = 0,
+					const volatile StopCalculating * stop = 0)
+	{
+	using namespace auxiliaryfunctions;
+
+	ValueType result;
+	ErrorCode err_tmp;
+
+		if( n.IsNan() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+		return n;
+		}
+
+		if( cgamma.history.Get(n, result, err_tmp) )
+		{
+			if( err )
+				*err = err_tmp;
+
+			return result;
+		}
+
+		err_tmp = err_ok;
+
+		if( n.IsSign() )
+		{
+			result = GammaMinus(n, cgamma, err_tmp, stop);
+		}
+		else
+		if( n.IsZero() )
+		{
+			err_tmp = err_improper_argument;
+			result.SetNan();
+		}
+		else
+		{
+			result = GammaPlus(n, cgamma, err_tmp, stop);
+		}
+
+		if( result.IsNan() && err_tmp==err_ok )
+			err_tmp = err_overflow;
+
+		if( err )
+			*err = err_tmp;
+
+		if( stop && !stop->WasStopSignal() )
+			cgamma.history.Add(n, result, err_tmp);
+
+	return result;
+	}
+
+
+	/*!
+		this function calculates the Gamma function
+
+		note: this function should be used only in a single-thread environment
+	*/
+	template<class ValueType>
+	ValueType Gamma(const ValueType & n, ErrorCode * err = 0)
+	{
+	// warning: this static object is not thread safe
+	static CGamma<ValueType> cgamma;
+
+	return Gamma(n, cgamma, err);
+	}
+
+
+
+	namespace auxiliaryfunctions
+	{
+
+	/*!
+		an auxiliary function for calculating the factorial function
+
+		we use the formula:
+		   x! = gamma(x+1)
+	*/
+	template<class ValueType>
+	ValueType Factorial2(ValueType x,
+						 CGamma<ValueType> * cgamma = 0,
+						 ErrorCode * err = 0,
+						 const volatile StopCalculating * stop = 0)
+	{
+	ValueType result, one;
+
+		if( x.IsNan() || x.IsSign() || !x.IsInteger() )
+		{
+			if( err )
+				*err = err_improper_argument;
+
+			x.SetNan();
+
+		return x;
+		}
+
+		one.SetOne();
+		x.Add(one);
+
+		if( cgamma )
+			return Gamma(x, *cgamma, err, stop);
+
+	return Gamma(x, err);
+	}
+	
+	} // namespace auxiliaryfunctions
+
+
+
+	/*!
+		the factorial from given 'x'
+		e.g.
+		Factorial(4) = 4! = 1*2*3*4
+
+		it's multithread safe, you should create a CGamma<> object and use it whenever you call the Factorial()
+		e.g.
+			typedef Big<1,2> MyBig;
+			MyBig x=234, y=54345;
+			CGamma<MyBig> cgamma;
+			std::cout << Factorial(x, cgamma) << std::endl;
+			std::cout << Factorial(y, cgamma) << std::endl;
+		in the CGamma<> object the function stores some coefficients (factorials, Bernoulli numbers),
+		and they will be reused in next calls to the function
+
+		each thread should have its own CGamma<> object, and you can use these objects with Gamma() function too
+	*/
+	template<class ValueType>
+	ValueType Factorial(const ValueType & x, CGamma<ValueType> & cgamma, ErrorCode * err = 0,
+						const volatile StopCalculating * stop = 0)
+	{
+		return auxiliaryfunctions::Factorial2(x, &cgamma, err, stop);
+	}
+
+
+	/*!
+		the factorial from given 'x'
+		e.g.
+		Factorial(4) = 4! = 1*2*3*4
+
+		note: this function should be used only in a single-thread environment
+	*/
+	template<class ValueType>
+	ValueType Factorial(const ValueType & x, ErrorCode * err = 0)
+	{
+		return auxiliaryfunctions::Factorial2(x, (CGamma<ValueType>*)0, err, 0);
+	}
+
+
+	/*!
+		this method prepares some coefficients: factorials and Bernoulli numbers
+		stored in 'fact' and 'bern' objects
+
+		we're defining the method here because we're using Gamma() function which
+		is not available in ttmathobjects.h
+
+		read the doc info in ttmathobjects.h file where CGamma<> struct is declared
+	*/
+	template<class ValueType>
+	void CGamma<ValueType>::InitAll()
+	{
+		ValueType x = TTMATH_GAMMA_BOUNDARY + 1;
+		
+		// history.Remove(x) removes only one object
+		// we must be sure that there are not others objects with the key 'x'
+		while( history.Remove(x) )
+		{
+		}
+
+		// the simplest way to initialize is to call the Gamma function with (TTMATH_GAMMA_BOUNDARY + 1)
+		// when x is larger then fewer coefficients we need
+		Gamma(x, *this);
+	}
+
+
+
+} // namespace
+
+
+/*!
+	this is for convenience for the user
+	he can only use '#include <ttmath/ttmath.h>' even if he uses the parser
+*/
+#include "ttmathparser.h"
+
+
+#ifdef _MSC_VER
+//warning C4127: conditional expression is constant
+#pragma warning( default: 4127 )
+//warning C4702: unreachable code
+#pragma warning( default: 4702 )
+//warning C4800: forcing value to bool 'true' or 'false' (performance warning)
+#pragma warning( default: 4800 )
+#endif
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathbig.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathbig.h
new file mode 100644
index 0000000..dc3e98c
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathbig.h
@@ -0,0 +1,6064 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2011, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef headerfilettmathbig
+#define headerfilettmathbig
+
+/*!
+	\file ttmathbig.h
+    \brief A Class for representing floating point numbers
+*/
+
+#include "ttmathint.h"
+#include "ttmaththreads.h"
+
+#include <iostream>
+
+#ifdef TTMATH_MULTITHREADS
+#include <signal.h>
+#endif
+
+namespace ttmath
+{
+
+
+/*!
+	\brief Big implements the floating point numbers
+*/
+template <uint exp, uint man>
+class Big
+{
+
+/*
+	value = mantissa * 2^exponent	
+
+	exponent - an integer value with a sign
+	mantissa - an integer value without a sing
+
+	mantissa must be pushed into the left side that is the highest bit from 
+	mantissa must be one (of course if there's another value than zero) -- this job
+	(pushing bits into the left side) making Standardizing() method
+
+	for example:
+	if we want to store value one (1) into our Big object we must:
+		set mantissa to 1
+		set exponent to 0
+		set info to 0
+		and call method Standardizing()
+*/
+
+
+public:
+
+Int<exp>  exponent;
+UInt<man> mantissa;
+unsigned char info;
+
+
+/*!
+	Sign
+	the mask of a bit from 'info' which means that there is a sign
+	(when the bit is set)
+*/
+#define TTMATH_BIG_SIGN 128
+
+
+/*!
+	Not a number
+	if this bit is set that there is not a valid number
+*/
+#define TTMATH_BIG_NAN  64
+
+
+/*!
+	Zero
+	if this bit is set that there is value zero
+	mantissa should be zero and exponent should be zero too
+	(the Standardizing() method does this)
+*/
+#define TTMATH_BIG_ZERO  32
+
+
+	/*!
+		this method sets NaN if there was a carry (and returns 1 in such a case)
+
+		c can be 0, 1 or other value different from zero
+	*/
+	uint CheckCarry(uint c)
+	{
+		if( c != 0 )
+		{
+			SetNan();
+			return 1;
+		}
+
+	return 0;
+	}
+
+public:
+
+
+	/*!
+		returning the string represents the currect type of the library
+		we have following types:
+		  asm_vc_32   - with asm code designed for Microsoft Visual C++ (32 bits)
+		  asm_gcc_32  - with asm code designed for GCC (32 bits)
+		  asm_vc_64   - with asm for VC (64 bit)
+		  asm_gcc_64  - with asm for GCC (64 bit)
+		  no_asm_32   - pure C++ version (32 bit) - without any asm code
+		  no_asm_64   - pure C++ version (64 bit) - without any asm code
+	*/
+	static const char * LibTypeStr()
+	{
+		return UInt<man>::LibTypeStr();
+	}
+
+
+	/*!
+		returning the currect type of the library
+	*/
+	static LibTypeCode LibType()
+	{
+		return UInt<man>::LibType();
+	}
+
+
+
+	/*!
+		this method moves all bits from mantissa into its left side
+		(suitably changes the exponent) or if the mantissa is zero
+		it sets the exponent to zero as well
+		(and clears the sign bit and sets the zero bit)
+
+		it can return a carry
+		the carry will be when we don't have enough space in the exponent
+
+		you don't have to use this method if you don't change the mantissa
+		and exponent directly
+	*/
+	uint Standardizing()
+	{
+		if( mantissa.IsTheHighestBitSet() )
+		{
+			ClearInfoBit(TTMATH_BIG_ZERO);
+			return 0;
+		}
+
+		if( CorrectZero() )
+			return 0;
+
+		uint comp = mantissa.CompensationToLeft();
+
+	return exponent.Sub( comp );
+	}
+
+
+private:
+
+	/*!
+		if the mantissa is equal zero this method sets exponent to zero and
+		info without the sign
+
+		it returns true if there was the correction
+	*/
+	bool CorrectZero()
+	{
+		if( mantissa.IsZero() )
+		{
+			SetInfoBit(TTMATH_BIG_ZERO);
+			ClearInfoBit(TTMATH_BIG_SIGN);
+			exponent.SetZero();
+
+			return true;
+		}
+		else
+		{
+			ClearInfoBit(TTMATH_BIG_ZERO);
+		}
+
+	return false;
+	}
+
+
+public:
+
+	/*!
+		this method clears a specific bit in the 'info' variable
+
+		bit is one of: TTMATH_BIG_SIGN, TTMATH_BIG_NAN etc.
+	*/
+	void ClearInfoBit(unsigned char bit)
+	{
+		info = info & (~bit);
+	}
+
+
+	/*!
+		this method sets a specific bit in the 'info' variable
+
+		bit is one of: TTMATH_BIG_SIGN, TTMATH_BIG_NAN etc.
+
+	*/
+	void SetInfoBit(unsigned char bit)
+	{
+		info = info | bit;
+	}
+
+
+	/*!
+		this method returns true if a specific bit in the 'info' variable is set
+
+		bit is one of: TTMATH_BIG_SIGN, TTMATH_BIG_NAN etc.
+	*/
+	bool IsInfoBit(unsigned char bit) const
+	{
+		return (info & bit) != 0;
+	}
+
+
+	/*!
+		this method sets zero
+	*/
+	void SetZero()
+	{
+		info = TTMATH_BIG_ZERO;
+		exponent.SetZero();
+		mantissa.SetZero();
+
+		/*
+			we don't have to compensate zero
+		*/
+	}
+
+	
+	/*!
+		this method sets one
+	*/
+	void SetOne()
+	{
+		info = 0;
+		mantissa.SetZero();
+		mantissa.table[man-1] = TTMATH_UINT_HIGHEST_BIT;
+		exponent = -sint(man * TTMATH_BITS_PER_UINT - 1);
+
+		// don't have to Standardize() - the last bit from mantissa is set
+	}
+
+
+	/*!
+		this method sets value 0.5
+	*/
+	void Set05()
+	{
+		SetOne();
+		exponent.SubOne();
+	}
+
+
+	/*!
+		this method sets NaN flag (Not a Number)
+		when this flag is set that means there is no a valid number
+	*/
+	void SetNan()
+	{
+		SetInfoBit(TTMATH_BIG_NAN);
+	}
+
+
+	/*!
+		this method sets NaN flag (Not a Number)
+		also clears the mantissa and exponent (similarly as it would be a zero value)
+	*/
+	void SetZeroNan()
+	{
+		SetZero();
+		SetNan();
+	}
+
+
+	/*!
+		this method swappes this for an argument
+	*/
+	void Swap(Big<exp, man> & ss2)
+	{
+		unsigned char info_temp = info;
+		info = ss2.info;
+		ss2.info = info_temp;
+
+		exponent.Swap(ss2.exponent);
+		mantissa.Swap(ss2.mantissa);
+	}
+
+
+private:
+
+	/*!
+		this method sets the mantissa of the value of pi
+	*/
+	void SetMantissaPi()
+	{
+	// this is a static table which represents the value of Pi (mantissa of it)
+	// (first is the highest word)
+	// we must define this table as 'unsigned int' because 
+	// both on 32bit and 64bit platforms this table is 32bit
+	static const unsigned int temp_table[] = {
+		0xc90fdaa2, 0x2168c234, 0xc4c6628b, 0x80dc1cd1, 0x29024e08, 0x8a67cc74, 0x020bbea6, 0x3b139b22, 
+		0x514a0879, 0x8e3404dd, 0xef9519b3, 0xcd3a431b, 0x302b0a6d, 0xf25f1437, 0x4fe1356d, 0x6d51c245, 
+		0xe485b576, 0x625e7ec6, 0xf44c42e9, 0xa637ed6b, 0x0bff5cb6, 0xf406b7ed, 0xee386bfb, 0x5a899fa5, 
+		0xae9f2411, 0x7c4b1fe6, 0x49286651, 0xece45b3d, 0xc2007cb8, 0xa163bf05, 0x98da4836, 0x1c55d39a, 
+		0x69163fa8, 0xfd24cf5f, 0x83655d23, 0xdca3ad96, 0x1c62f356, 0x208552bb, 0x9ed52907, 0x7096966d, 
+		0x670c354e, 0x4abc9804, 0xf1746c08, 0xca18217c, 0x32905e46, 0x2e36ce3b, 0xe39e772c, 0x180e8603, 
+		0x9b2783a2, 0xec07a28f, 0xb5c55df0, 0x6f4c52c9, 0xde2bcbf6, 0x95581718, 0x3995497c, 0xea956ae5, 
+		0x15d22618, 0x98fa0510, 0x15728e5a, 0x8aaac42d, 0xad33170d, 0x04507a33, 0xa85521ab, 0xdf1cba64, 
+		0xecfb8504, 0x58dbef0a, 0x8aea7157, 0x5d060c7d, 0xb3970f85, 0xa6e1e4c7, 0xabf5ae8c, 0xdb0933d7, 
+		0x1e8c94e0, 0x4a25619d, 0xcee3d226, 0x1ad2ee6b, 0xf12ffa06, 0xd98a0864, 0xd8760273, 0x3ec86a64, 
+		0x521f2b18, 0x177b200c, 0xbbe11757, 0x7a615d6c, 0x770988c0, 0xbad946e2, 0x08e24fa0, 0x74e5ab31, 
+		0x43db5bfc, 0xe0fd108e, 0x4b82d120, 0xa9210801, 0x1a723c12, 0xa787e6d7, 0x88719a10, 0xbdba5b26, 
+		0x99c32718, 0x6af4e23c, 0x1a946834, 0xb6150bda, 0x2583e9ca, 0x2ad44ce8, 0xdbbbc2db, 0x04de8ef9, 
+		0x2e8efc14, 0x1fbecaa6, 0x287c5947, 0x4e6bc05d, 0x99b2964f, 0xa090c3a2, 0x233ba186, 0x515be7ed, 
+		0x1f612970, 0xcee2d7af, 0xb81bdd76, 0x2170481c, 0xd0069127, 0xd5b05aa9, 0x93b4ea98, 0x8d8fddc1, 
+		0x86ffb7dc, 0x90a6c08f, 0x4df435c9, 0x34028492, 0x36c3fab4, 0xd27c7026, 0xc1d4dcb2, 0x602646de, 
+		0xc9751e76, 0x3dba37bd, 0xf8ff9406, 0xad9e530e, 0xe5db382f, 0x413001ae, 0xb06a53ed, 0x9027d831, 
+		0x179727b0, 0x865a8918, 0xda3edbeb, 0xcf9b14ed, 0x44ce6cba, 0xced4bb1b, 0xdb7f1447, 0xe6cc254b, 
+		0x33205151, 0x2bd7af42, 0x6fb8f401, 0x378cd2bf, 0x5983ca01, 0xc64b92ec, 0xf032ea15, 0xd1721d03, 
+		0xf482d7ce, 0x6e74fef6, 0xd55e702f, 0x46980c82, 0xb5a84031, 0x900b1c9e, 0x59e7c97f, 0xbec7e8f3, 
+		0x23a97a7e, 0x36cc88be, 0x0f1d45b7, 0xff585ac5, 0x4bd407b2, 0x2b4154aa, 0xcc8f6d7e, 0xbf48e1d8, 
+		0x14cc5ed2, 0x0f8037e0, 0xa79715ee, 0xf29be328, 0x06a1d58b, 0xb7c5da76, 0xf550aa3d, 0x8a1fbff0, 
+		0xeb19ccb1, 0xa313d55c, 0xda56c9ec, 0x2ef29632, 0x387fe8d7, 0x6e3c0468, 0x043e8f66, 0x3f4860ee, 
+		0x12bf2d5b, 0x0b7474d6, 0xe694f91e, 0x6dbe1159, 0x74a3926f, 0x12fee5e4, 0x38777cb6, 0xa932df8c, 
+		0xd8bec4d0, 0x73b931ba, 0x3bc832b6, 0x8d9dd300, 0x741fa7bf, 0x8afc47ed, 0x2576f693, 0x6ba42466, 
+		0x3aab639c, 0x5ae4f568, 0x3423b474, 0x2bf1c978, 0x238f16cb, 0xe39d652d, 0xe3fdb8be, 0xfc848ad9, 
+		0x22222e04, 0xa4037c07, 0x13eb57a8, 0x1a23f0c7, 0x3473fc64, 0x6cea306b, 0x4bcbc886, 0x2f8385dd, 
+		0xfa9d4b7f, 0xa2c087e8, 0x79683303, 0xed5bdd3a, 0x062b3cf5, 0xb3a278a6, 0x6d2a13f8, 0x3f44f82d, 
+		0xdf310ee0, 0x74ab6a36, 0x4597e899, 0xa0255dc1, 0x64f31cc5, 0x0846851d, 0xf9ab4819, 0x5ded7ea1, 
+		0xb1d510bd, 0x7ee74d73, 0xfaf36bc3, 0x1ecfa268, 0x359046f4, 0xeb879f92, 0x4009438b, 0x481c6cd7, 
+		0x889a002e, 0xd5ee382b, 0xc9190da6, 0xfc026e47, 0x9558e447, 0x5677e9aa, 0x9e3050e2, 0x765694df, 
+		0xc81f56e8, 0x80b96e71, 0x60c980dd, 0x98a573ea, 0x4472065a, 0x139cd290, 0x6cd1cb72, 0x9ec52a53 // last one was: 0x9ec52a52
+		//0x86d44014, ...
+		// (the last word 0x9ec52a52 was rounded up because the next one is 0x86d44014 -- first bit is one 0x8..)
+		// 256 32bit words for the mantissa -- about 2464 valid decimal digits
+		};
+		// the value of PI is comming from the website http://zenwerx.com/pi.php
+		// 3101 digits were taken from this website
+		//  (later the digits were compared with:
+		//   http://www.eveandersson.com/pi/digits/1000000 and http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html )
+		// and they were set into Big<1,400> type (using operator=(const char*) on a 32bit platform)
+		// and then the first 256 words were taken into this table
+		// (TTMATH_BUILTIN_VARIABLES_SIZE on 32bit platform should have the value 256,
+		// and on 64bit platform value 128 (256/2=128))
+	
+		mantissa.SetFromTable(temp_table, sizeof(temp_table) / sizeof(int));
+	}
+
+public:
+
+
+	/*!
+		this method sets the value of pi
+	*/
+	void SetPi()
+	{
+		SetMantissaPi();
+		info = 0;
+		exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT) + 2;
+	}
+
+
+	/*!
+		this method sets the value of 0.5 * pi
+	*/
+	void Set05Pi()
+	{
+		SetMantissaPi();
+		info = 0;
+		exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT) + 1;
+	}
+
+
+	/*!
+		this method sets the value of 2 * pi
+	*/
+	void Set2Pi()
+	{
+		SetMantissaPi();
+		info = 0;
+		exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT) + 3;
+	}
+
+
+	/*!
+		this method sets the value of e
+		(the base of the natural logarithm)
+	*/
+	void SetE()
+	{
+	static const unsigned int temp_table[] = {
+		0xadf85458, 0xa2bb4a9a, 0xafdc5620, 0x273d3cf1, 0xd8b9c583, 0xce2d3695, 0xa9e13641, 0x146433fb, 
+		0xcc939dce, 0x249b3ef9, 0x7d2fe363, 0x630c75d8, 0xf681b202, 0xaec4617a, 0xd3df1ed5, 0xd5fd6561, 
+		0x2433f51f, 0x5f066ed0, 0x85636555, 0x3ded1af3, 0xb557135e, 0x7f57c935, 0x984f0c70, 0xe0e68b77, 
+		0xe2a689da, 0xf3efe872, 0x1df158a1, 0x36ade735, 0x30acca4f, 0x483a797a, 0xbc0ab182, 0xb324fb61, 
+		0xd108a94b, 0xb2c8e3fb, 0xb96adab7, 0x60d7f468, 0x1d4f42a3, 0xde394df4, 0xae56ede7, 0x6372bb19, 
+		0x0b07a7c8, 0xee0a6d70, 0x9e02fce1, 0xcdf7e2ec, 0xc03404cd, 0x28342f61, 0x9172fe9c, 0xe98583ff, 
+		0x8e4f1232, 0xeef28183, 0xc3fe3b1b, 0x4c6fad73, 0x3bb5fcbc, 0x2ec22005, 0xc58ef183, 0x7d1683b2, 
+		0xc6f34a26, 0xc1b2effa, 0x886b4238, 0x611fcfdc, 0xde355b3b, 0x6519035b, 0xbc34f4de, 0xf99c0238, 
+		0x61b46fc9, 0xd6e6c907, 0x7ad91d26, 0x91f7f7ee, 0x598cb0fa, 0xc186d91c, 0xaefe1309, 0x85139270, 
+		0xb4130c93, 0xbc437944, 0xf4fd4452, 0xe2d74dd3, 0x64f2e21e, 0x71f54bff, 0x5cae82ab, 0x9c9df69e, 
+		0xe86d2bc5, 0x22363a0d, 0xabc52197, 0x9b0deada, 0x1dbf9a42, 0xd5c4484e, 0x0abcd06b, 0xfa53ddef, 
+		0x3c1b20ee, 0x3fd59d7c, 0x25e41d2b, 0x669e1ef1, 0x6e6f52c3, 0x164df4fb, 0x7930e9e4, 0xe58857b6, 
+		0xac7d5f42, 0xd69f6d18, 0x7763cf1d, 0x55034004, 0x87f55ba5, 0x7e31cc7a, 0x7135c886, 0xefb4318a, 
+		0xed6a1e01, 0x2d9e6832, 0xa907600a, 0x918130c4, 0x6dc778f9, 0x71ad0038, 0x092999a3, 0x33cb8b7a, 
+		0x1a1db93d, 0x7140003c, 0x2a4ecea9, 0xf98d0acc, 0x0a8291cd, 0xcec97dcf, 0x8ec9b55a, 0x7f88a46b, 
+		0x4db5a851, 0xf44182e1, 0xc68a007e, 0x5e0dd902, 0x0bfd64b6, 0x45036c7a, 0x4e677d2c, 0x38532a3a, 
+		0x23ba4442, 0xcaf53ea6, 0x3bb45432, 0x9b7624c8, 0x917bdd64, 0xb1c0fd4c, 0xb38e8c33, 0x4c701c3a, 
+		0xcdad0657, 0xfccfec71, 0x9b1f5c3e, 0x4e46041f, 0x388147fb, 0x4cfdb477, 0xa52471f7, 0xa9a96910, 
+		0xb855322e, 0xdb6340d8, 0xa00ef092, 0x350511e3, 0x0abec1ff, 0xf9e3a26e, 0x7fb29f8c, 0x183023c3, 
+		0x587e38da, 0x0077d9b4, 0x763e4e4b, 0x94b2bbc1, 0x94c6651e, 0x77caf992, 0xeeaac023, 0x2a281bf6, 
+		0xb3a739c1, 0x22611682, 0x0ae8db58, 0x47a67cbe, 0xf9c9091b, 0x462d538c, 0xd72b0374, 0x6ae77f5e, 
+		0x62292c31, 0x1562a846, 0x505dc82d, 0xb854338a, 0xe49f5235, 0xc95b9117, 0x8ccf2dd5, 0xcacef403, 
+		0xec9d1810, 0xc6272b04, 0x5b3b71f9, 0xdc6b80d6, 0x3fdd4a8e, 0x9adb1e69, 0x62a69526, 0xd43161c1, 
+		0xa41d570d, 0x7938dad4, 0xa40e329c, 0xcff46aaa, 0x36ad004c, 0xf600c838, 0x1e425a31, 0xd951ae64, 
+		0xfdb23fce, 0xc9509d43, 0x687feb69, 0xedd1cc5e, 0x0b8cc3bd, 0xf64b10ef, 0x86b63142, 0xa3ab8829, 
+		0x555b2f74, 0x7c932665, 0xcb2c0f1c, 0xc01bd702, 0x29388839, 0xd2af05e4, 0x54504ac7, 0x8b758282, 
+		0x2846c0ba, 0x35c35f5c, 0x59160cc0, 0x46fd8251, 0x541fc68c, 0x9c86b022, 0xbb709987, 0x6a460e74, 
+		0x51a8a931, 0x09703fee, 0x1c217e6c, 0x3826e52c, 0x51aa691e, 0x0e423cfc, 0x99e9e316, 0x50c1217b, 
+		0x624816cd, 0xad9a95f9, 0xd5b80194, 0x88d9c0a0, 0xa1fe3075, 0xa577e231, 0x83f81d4a, 0x3f2fa457, 
+		0x1efc8ce0, 0xba8a4fe8, 0xb6855dfe, 0x72b0a66e, 0xded2fbab, 0xfbe58a30, 0xfafabe1c, 0x5d71a87e, 
+		0x2f741ef8, 0xc1fe86fe, 0xa6bbfde5, 0x30677f0d, 0x97d11d49, 0xf7a8443d, 0x0822e506, 0xa9f4614e, 
+		0x011e2a94, 0x838ff88c, 0xd68c8bb7, 0xc51eef6d, 0x49ea8ab4, 0xf2c3df5b, 0xb4e0735a, 0xb0d68749
+		// 0x2fe26dd4, ...
+		// 256 32bit words for the mantissa -- about 2464 valid decimal digits
+		};
+
+		// above value was calculated using Big<1,400> type on a 32bit platform
+		// and then the first 256 words were taken,
+		// the calculating was made by using ExpSurrounding0(1) method
+		// which took 1420 iterations
+		// (the result was compared with e taken from http://antwrp.gsfc.nasa.gov/htmltest/gifcity/e.2mil)
+		// (TTMATH_BUILTIN_VARIABLES_SIZE on 32bit platform should have the value 256,
+		// and on 64bit platform value 128 (256/2=128))
+
+		mantissa.SetFromTable(temp_table, sizeof(temp_table) / sizeof(int));
+		exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT) + 2;
+		info = 0;
+	}
+
+
+	/*!
+		this method sets the value of ln(2)
+		the natural logarithm from 2
+	*/
+	void SetLn2()
+	{
+	static const unsigned int temp_table[] = {
+		0xb17217f7, 0xd1cf79ab, 0xc9e3b398, 0x03f2f6af, 0x40f34326, 0x7298b62d, 0x8a0d175b, 0x8baafa2b, 
+		0xe7b87620, 0x6debac98, 0x559552fb, 0x4afa1b10, 0xed2eae35, 0xc1382144, 0x27573b29, 0x1169b825, 
+		0x3e96ca16, 0x224ae8c5, 0x1acbda11, 0x317c387e, 0xb9ea9bc3, 0xb136603b, 0x256fa0ec, 0x7657f74b, 
+		0x72ce87b1, 0x9d6548ca, 0xf5dfa6bd, 0x38303248, 0x655fa187, 0x2f20e3a2, 0xda2d97c5, 0x0f3fd5c6, 
+		0x07f4ca11, 0xfb5bfb90, 0x610d30f8, 0x8fe551a2, 0xee569d6d, 0xfc1efa15, 0x7d2e23de, 0x1400b396, 
+		0x17460775, 0xdb8990e5, 0xc943e732, 0xb479cd33, 0xcccc4e65, 0x9393514c, 0x4c1a1e0b, 0xd1d6095d, 
+		0x25669b33, 0x3564a337, 0x6a9c7f8a, 0x5e148e82, 0x074db601, 0x5cfe7aa3, 0x0c480a54, 0x17350d2c, 
+		0x955d5179, 0xb1e17b9d, 0xae313cdb, 0x6c606cb1, 0x078f735d, 0x1b2db31b, 0x5f50b518, 0x5064c18b, 
+		0x4d162db3, 0xb365853d, 0x7598a195, 0x1ae273ee, 0x5570b6c6, 0x8f969834, 0x96d4e6d3, 0x30af889b, 
+		0x44a02554, 0x731cdc8e, 0xa17293d1, 0x228a4ef9, 0x8d6f5177, 0xfbcf0755, 0x268a5c1f, 0x9538b982, 
+		0x61affd44, 0x6b1ca3cf, 0x5e9222b8, 0x8c66d3c5, 0x422183ed, 0xc9942109, 0x0bbb16fa, 0xf3d949f2, 
+		0x36e02b20, 0xcee886b9, 0x05c128d5, 0x3d0bd2f9, 0x62136319, 0x6af50302, 0x0060e499, 0x08391a0c, 
+		0x57339ba2, 0xbeba7d05, 0x2ac5b61c, 0xc4e9207c, 0xef2f0ce2, 0xd7373958, 0xd7622658, 0x901e646a, 
+		0x95184460, 0xdc4e7487, 0x156e0c29, 0x2413d5e3, 0x61c1696d, 0xd24aaebd, 0x473826fd, 0xa0c238b9, 
+		0x0ab111bb, 0xbd67c724, 0x972cd18b, 0xfbbd9d42, 0x6c472096, 0xe76115c0, 0x5f6f7ceb, 0xac9f45ae, 
+		0xcecb72f1, 0x9c38339d, 0x8f682625, 0x0dea891e, 0xf07afff3, 0xa892374e, 0x175eb4af, 0xc8daadd8, 
+		0x85db6ab0, 0x3a49bd0d, 0xc0b1b31d, 0x8a0e23fa, 0xc5e5767d, 0xf95884e0, 0x6425a415, 0x26fac51c, 
+		0x3ea8449f, 0xe8f70edd, 0x062b1a63, 0xa6c4c60c, 0x52ab3316, 0x1e238438, 0x897a39ce, 0x78b63c9f, 
+		0x364f5b8a, 0xef22ec2f, 0xee6e0850, 0xeca42d06, 0xfb0c75df, 0x5497e00c, 0x554b03d7, 0xd2874a00, 
+		0x0ca8f58d, 0x94f0341c, 0xbe2ec921, 0x56c9f949, 0xdb4a9316, 0xf281501e, 0x53daec3f, 0x64f1b783, 
+		0x154c6032, 0x0e2ff793, 0x33ce3573, 0xfacc5fdc, 0xf1178590, 0x3155bbd9, 0x0f023b22, 0x0224fcd8, 
+		0x471bf4f4, 0x45f0a88a, 0x14f0cd97, 0x6ea354bb, 0x20cdb5cc, 0xb3db2392, 0x88d58655, 0x4e2a0e8a, 
+		0x6fe51a8c, 0xfaa72ef2, 0xad8a43dc, 0x4212b210, 0xb779dfe4, 0x9d7307cc, 0x846532e4, 0xb9694eda, 
+		0xd162af05, 0x3b1751f3, 0xa3d091f6, 0x56658154, 0x12b5e8c2, 0x02461069, 0xac14b958, 0x784934b8, 
+		0xd6cce1da, 0xa5053701, 0x1aa4fb42, 0xb9a3def4, 0x1bda1f85, 0xef6fdbf2, 0xf2d89d2a, 0x4b183527, 
+		0x8fd94057, 0x89f45681, 0x2b552879, 0xa6168695, 0xc12963b0, 0xff01eaab, 0x73e5b5c1, 0x585318e7, 
+		0x624f14a5, 0x1a4a026b, 0x68082920, 0x57fd99b6, 0x6dc085a9, 0x8ac8d8ca, 0xf9eeeea9, 0x8a2400ca, 
+		0xc95f260f, 0xd10036f9, 0xf91096ac, 0x3195220a, 0x1a356b2a, 0x73b7eaad, 0xaf6d6058, 0x71ef7afb, 
+		0x80bc4234, 0x33562e94, 0xb12dfab4, 0x14451579, 0xdf59eae0, 0x51707062, 0x4012a829, 0x62c59cab, 
+		0x347f8304, 0xd889659e, 0x5a9139db, 0x14efcc30, 0x852be3e8, 0xfc99f14d, 0x1d822dd6, 0xe2f76797, 
+		0xe30219c8, 0xaa9ce884, 0x8a886eb3, 0xc87b7295, 0x988012e8, 0x314186ed, 0xbaf86856, 0xccd3c3b6, 
+		0xee94e62f, 0x110a6783, 0xd2aae89c, 0xcc3b76fc, 0x435a0ce1, 0x34c2838f, 0xd571ec6c, 0x1366a993 // last one was: 0x1366a992
+		//0xcbb9ac40, ...
+		// (the last word 0x1366a992 was rounded up because the next one is 0xcbb9ac40 -- first bit is one 0xc..)
+		// 256 32bit words for the mantissa -- about 2464 valid decimal digits
+		};	
+
+		// above value was calculated using Big<1,400> type on a 32bit platform
+		// and then the first 256 words were taken,
+		// the calculating was made by using LnSurrounding1(2) method
+		// which took 4035 iterations
+		// (the result was compared with ln(2) taken from http://ja0hxv.calico.jp/pai/estart.html)
+		// (TTMATH_BUILTIN_VARIABLES_SIZE on 32bit platform should have the value 256,
+		// and on 64bit platform value 128 (256/2=128))
+
+		mantissa.SetFromTable(temp_table, sizeof(temp_table) / sizeof(int));
+		exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT);
+		info = 0;
+	}
+
+
+	/*!
+		this method sets the value of ln(10)
+		the natural logarithm from 10
+
+		I introduced this constant especially to make the conversion ToString()
+		being faster. In fact the method ToString() is keeping values of logarithms
+		it has calculated but it must calculate the logarithm at least once.
+		If a program, which uses this library, is running for a long time this
+		would be ok, but for programs which are running shorter, for example for
+		CGI applications which only once are printing values, this would be much
+		inconvenience. Then if we're printing with base (radix) 10 and the mantissa
+		of our value is smaller than or equal to TTMATH_BUILTIN_VARIABLES_SIZE
+		we don't calculate the logarithm but take it from this constant.
+	*/
+	void SetLn10()
+	{
+	static const unsigned int temp_table[] = {
+		0x935d8ddd, 0xaaa8ac16, 0xea56d62b, 0x82d30a28, 0xe28fecf9, 0xda5df90e, 0x83c61e82, 0x01f02d72, 
+		0x962f02d7, 0xb1a8105c, 0xcc70cbc0, 0x2c5f0d68, 0x2c622418, 0x410be2da, 0xfb8f7884, 0x02e516d6, 
+		0x782cf8a2, 0x8a8c911e, 0x765aa6c3, 0xb0d831fb, 0xef66ceb0, 0x4ab3c6fa, 0x5161bb49, 0xd219c7bb, 
+		0xca67b35b, 0x23605085, 0x8e93368d, 0x44789c4f, 0x5b08b057, 0xd5ede20f, 0x469ea58e, 0x9305e981, 
+		0xe2478fca, 0xad3aee98, 0x9cd5b42e, 0x6a271619, 0xa47ecb26, 0x978c5d4f, 0xdb1d28ea, 0x57d4fdc0, 
+		0xe40bf3cc, 0x1e14126a, 0x45765cde, 0x268339db, 0xf47fa96d, 0xeb271060, 0xaf88486e, 0xa9b7401e, 
+		0x3dfd3c51, 0x748e6d6e, 0x3848c8d2, 0x5faf1bca, 0xe88047f1, 0x7b0d9b50, 0xa949eaaa, 0xdf69e8a5, 
+		0xf77e3760, 0x4e943960, 0xe38a5700, 0xffde2db1, 0xad6bfbff, 0xd821ba0a, 0x4cb0466d, 0x61ba648e, 
+		0xef99c8e5, 0xf6974f36, 0x3982a78c, 0xa45ddfc8, 0x09426178, 0x19127a6e, 0x3b70fcda, 0x2d732d47, 
+		0xb5e4b1c8, 0xc0e5a10a, 0xaa6604a5, 0x324ec3dc, 0xbc64ea80, 0x6e198566, 0x1f1d366c, 0x20663834, 
+		0x4d5e843f, 0x20642b97, 0x0a62d18e, 0x478f7bd5, 0x8fcd0832, 0x4a7b32a6, 0xdef85a05, 0xeb56323a, 
+		0x421ef5e0, 0xb00410a0, 0xa0d9c260, 0x794a976f, 0xf6ff363d, 0xb00b6b33, 0xf42c58de, 0xf8a3c52d, 
+		0xed69b13d, 0xc1a03730, 0xb6524dc1, 0x8c167e86, 0x99d6d20e, 0xa2defd2b, 0xd006f8b4, 0xbe145a2a, 
+		0xdf3ccbb3, 0x189da49d, 0xbc1261c8, 0xb3e4daad, 0x6a36cecc, 0xb2d5ae5b, 0x89bf752f, 0xb5dfb353, 
+		0xff3065c4, 0x0cfceec8, 0x1be5a9a9, 0x67fddc57, 0xc4b83301, 0x006bf062, 0x4b40ed7a, 0x56c6cdcd, 
+		0xa2d6fe91, 0x388e9e3e, 0x48a93f5f, 0x5e3b6eb4, 0xb81c4a5b, 0x53d49ea6, 0x8e668aea, 0xba83c7f8, 
+		0xfb5f06c3, 0x58ac8f70, 0xfa9d8c59, 0x8c574502, 0xbaf54c96, 0xc84911f0, 0x0482d095, 0x1a0af022, 
+		0xabbab080, 0xec97efd3, 0x671e4e0e, 0x52f166b6, 0xcd5cd226, 0x0dc67795, 0x2e1e34a3, 0xf799677f, 
+		0x2c1d48f1, 0x2944b6c5, 0x2ba1307e, 0x704d67f9, 0x1c1035e4, 0x4e927c63, 0x03cf12bf, 0xe2cd2e31, 
+		0xf8ee4843, 0x344d51b0, 0xf37da42b, 0x9f0b0fd9, 0x134fb2d9, 0xf815e490, 0xd966283f, 0x23962766, 
+		0xeceab1e4, 0xf3b5fc86, 0x468127e2, 0xb606d10d, 0x3a45f4b6, 0xb776102d, 0x2fdbb420, 0x80c8fa84, 
+		0xd0ff9f45, 0xc58aef38, 0xdb2410fd, 0x1f1cebad, 0x733b2281, 0x52ca5f36, 0xddf29daa, 0x544334b8, 
+		0xdeeaf659, 0x4e462713, 0x1ed485b4, 0x6a0822e1, 0x28db471c, 0xa53938a8, 0x44c3bef7, 0xf35215c8, 
+		0xb382bc4e, 0x3e4c6f15, 0x6285f54c, 0x17ab408e, 0xccbf7f5e, 0xd16ab3f6, 0xced2846d, 0xf457e14f, 
+		0xbb45d9c5, 0x646ad497, 0xac697494, 0x145de32e, 0x93907128, 0xd263d521, 0x79efb424, 0xd64651d6, 
+		0xebc0c9f0, 0xbb583a44, 0xc6412c84, 0x85bb29a6, 0x4d31a2cd, 0x92954469, 0xa32b1abd, 0xf7f5202c, 
+		0xa4aa6c93, 0x2e9b53cf, 0x385ab136, 0x2741f356, 0x5de9c065, 0x6009901c, 0x88abbdd8, 0x74efcf73, 
+		0x3f761ad4, 0x35f3c083, 0xfd6b8ee0, 0x0bef11c7, 0xc552a89d, 0x58ce4a21, 0xd71e54f2, 0x4157f6c7, 
+		0xd4622316, 0xe98956d7, 0x450027de, 0xcbd398d8, 0x4b98b36a, 0x0724c25c, 0xdb237760, 0xe9324b68, 
+		0x7523e506, 0x8edad933, 0x92197f00, 0xb853a326, 0xb330c444, 0x65129296, 0x34bc0670, 0xe177806d, 
+		0xe338dac4, 0x5537492a, 0xe19add83, 0xcf45000f, 0x5b423bce, 0x6497d209, 0xe30e18a1, 0x3cbf0687, 
+		0x67973103, 0xd9485366, 0x81506bba, 0x2e93a9a4, 0x7dd59d3f, 0xf17cd746, 0x8c2075be, 0x552a4348 // last one was: 0x552a4347
+		// 0xb4a638ef, ...
+		//(the last word 0x552a4347 was rounded up because the next one is 0xb4a638ef -- first bit is one 0xb..)
+		// 256 32bit words for the mantissa -- about 2464 valid digits (decimal)
+		};	
+
+		// above value was calculated using Big<1,400> type on a 32bit platform
+		// and then the first 256 32bit words were taken,
+		// the calculating was made by using LnSurrounding1(10) method
+		// which took 22080 iterations
+		// (the result was compared with ln(10) taken from http://ja0hxv.calico.jp/pai/estart.html)
+		// (the formula used in LnSurrounding1(x) converges badly when
+	    // the x is greater than one but in fact we can use it, only the
+		// number of iterations will be greater)
+		// (TTMATH_BUILTIN_VARIABLES_SIZE on 32bit platform should have the value 256,
+		// and on 64bit platform value 128 (256/2=128))
+
+		mantissa.SetFromTable(temp_table, sizeof(temp_table) / sizeof(int));
+		exponent = -sint(man)*sint(TTMATH_BITS_PER_UINT) + 2;
+		info = 0;
+	}
+
+
+	/*!
+		this method sets the maximum value which can be held in this type
+	*/
+	void SetMax()
+	{
+		info = 0;
+		mantissa.SetMax();
+		exponent.SetMax();
+
+		// we don't have to use 'Standardizing()' because the last bit from
+		// the mantissa is set
+	}
+
+
+	/*!
+		this method sets the minimum value which can be held in this type
+	*/
+	void SetMin()
+	{
+		info = 0;
+
+		mantissa.SetMax();
+		exponent.SetMax();
+		SetSign();
+
+		// we don't have to use 'Standardizing()' because the last bit from
+		// the mantissa is set
+	}
+
+
+	/*!
+		testing whether there is a value zero or not
+	*/
+	bool IsZero() const
+	{
+		return IsInfoBit(TTMATH_BIG_ZERO);
+	}
+
+
+	/*!
+		this method returns true when there's the sign set
+		also we don't check the NaN flag
+	*/
+	bool IsSign() const
+	{
+		return IsInfoBit(TTMATH_BIG_SIGN);
+	}
+
+
+	/*!
+		this method returns true when there is not a valid number
+	*/
+	bool IsNan() const
+	{
+		return IsInfoBit(TTMATH_BIG_NAN);
+	}
+
+
+
+	/*!
+		this method clears the sign
+		(there'll be an absolute value)
+
+			e.g.
+			-1 -> 1
+			2  -> 2
+	*/
+	void Abs()
+	{
+		ClearInfoBit(TTMATH_BIG_SIGN);
+	}
+
+
+	/*!
+		this method remains the 'sign' of the value
+		e.g.  -2 = -1 
+		       0 = 0
+		      10 = 1
+	*/
+	void Sgn()
+	{
+		// we have to check the NaN flag, because the next SetOne() method would clear it
+		if( IsNan() )
+			return;
+
+		if( IsSign() )
+		{
+			SetOne();
+			SetSign();
+		}
+		else
+		if( IsZero() )
+			SetZero(); // !! is nedeed here?
+		else
+			SetOne();
+	}
+
+
+
+	/*!
+		this method sets the sign
+
+			e.g.
+			-1 -> -1
+			2  -> -2
+
+		we do not check whether there is a zero or not, if you're using this method
+		you must be sure that the value is (or will be afterwards) different from zero
+	*/
+	void SetSign()
+	{
+		SetInfoBit(TTMATH_BIG_SIGN);
+	}
+
+
+	/*!
+		this method changes the sign
+		when there is a value of zero then the sign is not changed
+
+			e.g.
+			-1 -> 1
+			2  -> -2
+	*/
+	void ChangeSign()
+	{
+		// we don't have to check the NaN flag here
+
+		if( IsZero() )
+			return;
+
+		if( IsSign() )
+			ClearInfoBit(TTMATH_BIG_SIGN);
+		else
+			SetInfoBit(TTMATH_BIG_SIGN);
+	}
+
+
+
+private:
+
+	/*!
+		this method does the half-to-even rounding (banker's rounding)
+
+		if is_half is:
+		  true  - that means the rest was equal the half (0.5 decimal)
+		  false - that means the rest was greater than a half (greater than 0.5 decimal)
+
+	    if the rest was less than a half then don't call this method
+		(the rounding should does nothing then)
+	*/
+	uint RoundHalfToEven(bool is_half, bool rounding_up = true)
+	{
+	uint c = 0;
+
+		if( !is_half || mantissa.IsTheLowestBitSet() )
+		{
+			if( rounding_up )
+			{
+				if( mantissa.AddOne() )
+				{
+					mantissa.Rcr(1, 1);
+					c = exponent.AddOne();
+				}
+			}
+			else
+			{
+				#ifdef TTMATH_DEBUG
+				uint c_from_zero =
+				#endif
+				mantissa.SubOne();
+
+				// we're using rounding_up=false in Add() when the mantissas have different signs
+				// mantissa can be zero only when previous mantissa was equal to ss2.mantissa
+				// but in such a case 'last_bit_set' will not be set and consequently 'do_rounding' will be false
+				TTMATH_ASSERT( c_from_zero == 0 )
+			}
+		}
+
+	return c;
+	}
+
+
+
+
+
+	/*!
+	*
+	*	basic mathematic functions
+	*
+	*/
+
+
+	/*!
+		this method adds one to the existing value
+	*/
+	uint AddOne()
+	{
+	Big<exp, man> one;
+
+		one.SetOne();
+
+	return Add(one);
+	}
+
+
+	/*!
+		this method subtracts one from the existing value
+	*/
+	uint SubOne()
+	{
+	Big<exp, man> one;
+
+		one.SetOne();
+
+	return Sub(one);
+	}
+
+
+private:
+
+
+	/*!
+		an auxiliary method for adding
+	*/
+	void AddCheckExponents(	Big<exp, man> & ss2,
+							Int<exp> & exp_offset,
+							bool & last_bit_set,
+							bool & rest_zero,
+							bool & do_adding,
+							bool & do_rounding)
+	{
+	Int<exp> mantissa_size_in_bits( man * TTMATH_BITS_PER_UINT );
+
+		if( exp_offset == mantissa_size_in_bits )
+		{
+			last_bit_set = ss2.mantissa.IsTheHighestBitSet();
+			rest_zero    = ss2.mantissa.AreFirstBitsZero(man*TTMATH_BITS_PER_UINT - 1);
+			do_rounding  = true;	// we'are only rounding
+		}
+		else
+		if( exp_offset < mantissa_size_in_bits )
+		{
+			uint moved = exp_offset.ToInt(); // how many times we must move ss2.mantissa
+			rest_zero  = true;
+
+			if( moved > 0 )
+			{
+				last_bit_set = static_cast<bool>( ss2.mantissa.GetBit(moved-1) );
+
+				if( moved > 1 )
+					rest_zero = ss2.mantissa.AreFirstBitsZero(moved - 1);
+			
+				// (2) moving 'exp_offset' times
+				ss2.mantissa.Rcr(moved, 0);
+			}
+
+			do_adding    = true; 
+			do_rounding  = true;
+		}
+
+		// if exp_offset is greater than mantissa_size_in_bits then we do nothing
+		// ss2 is too small for taking into consideration in the sum
+	}
+
+
+	/*!
+		an auxiliary method for adding
+	*/
+	uint AddMantissas(	Big<exp, man> & ss2,
+						bool & last_bit_set,
+						bool & rest_zero)
+	{
+	uint c = 0;
+
+		if( IsSign() == ss2.IsSign() )
+		{
+			// values have the same signs
+			if( mantissa.Add(ss2.mantissa) )
+			{
+				// we have one bit more from addition (carry)
+				// now rest_zero means the old rest_zero with the old last_bit_set
+				rest_zero    = (!last_bit_set && rest_zero);
+				last_bit_set = mantissa.Rcr(1,1);
+				c += exponent.AddOne();
+			}
+		}
+		else
+		{
+			// values have different signs
+			// there shouldn't be a carry here because
+			// (1) (2) guarantee that the mantissa of this
+			// is greater than or equal to the mantissa of the ss2
+
+			#ifdef TTMATH_DEBUG
+			uint c_temp =
+			#endif
+			mantissa.Sub(ss2.mantissa);
+
+			TTMATH_ASSERT( c_temp == 0 )
+		}
+
+	return c;
+	}
+
+
+public:
+
+
+	/*!
+		Addition this = this + ss2
+
+		it returns carry if the sum is too big
+	*/
+	uint Add(Big<exp, man> ss2, bool round = true, bool adding = true)
+	{
+	bool last_bit_set, rest_zero, do_adding, do_rounding, rounding_up;
+	Int<exp> exp_offset( exponent );
+	uint c = 0;
+
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( !adding )
+			ss2.ChangeSign(); // subtracting
+
+		exp_offset.Sub( ss2.exponent );
+		exp_offset.Abs();
+
+		// (1) abs(this) will be >= abs(ss2)
+		if( SmallerWithoutSignThan(ss2) )
+			Swap(ss2);
+	
+		if( ss2.IsZero() )
+			return 0;
+
+		last_bit_set = rest_zero = do_adding = do_rounding = false;
+		rounding_up = (IsSign() == ss2.IsSign());
+
+		AddCheckExponents(ss2, exp_offset, last_bit_set, rest_zero, do_adding, do_rounding);
+
+		if( do_adding )
+			c += AddMantissas(ss2, last_bit_set, rest_zero);
+
+		if( !round || !last_bit_set )
+			do_rounding = false;
+
+		if( do_rounding )
+			c += RoundHalfToEven(rest_zero, rounding_up);
+
+		if( do_adding || do_rounding )
+			c += Standardizing();
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		Subtraction this = this - ss2
+
+		it returns carry if the result is too big
+	*/
+	uint Sub(const Big<exp, man> & ss2, bool round = true)
+	{
+		return Add(ss2, round, false);
+	}
+		
+
+	/*!
+		bitwise AND
+
+		this and ss2 must be >= 0
+		return values:
+			0 - ok
+			1 - carry
+			2 - this or ss2 was negative
+	*/
+	uint BitAnd(Big<exp, man> ss2)
+	{
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( IsSign() || ss2.IsSign() )
+		{
+			SetNan();
+			return 2;
+		}
+
+		if( IsZero() )
+			return 0;
+
+		if( ss2.IsZero() )
+		{
+			SetZero();
+			return 0;
+		}
+
+		Int<exp> exp_offset( exponent );
+		Int<exp> mantissa_size_in_bits( man * TTMATH_BITS_PER_UINT );
+
+		uint c = 0;
+
+		exp_offset.Sub( ss2.exponent );
+		exp_offset.Abs();
+
+		// abs(this) will be >= abs(ss2)
+		if( SmallerWithoutSignThan(ss2) )
+			Swap(ss2);
+
+		if( exp_offset >= mantissa_size_in_bits )
+		{
+			// the second value is too small
+			SetZero();
+			return 0;
+		}
+
+		// exp_offset < mantissa_size_in_bits, moving 'exp_offset' times
+		ss2.mantissa.Rcr( exp_offset.ToInt(), 0 );
+		mantissa.BitAnd(ss2.mantissa);
+
+		c += Standardizing();
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		bitwise OR
+
+		this and ss2 must be >= 0
+		return values:
+			0 - ok
+			1 - carry
+			2 - this or ss2 was negative
+	*/
+	uint BitOr(Big<exp, man> ss2)
+	{
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( IsSign() || ss2.IsSign() )
+		{
+			SetNan();
+			return 2;
+		}
+		
+		if( IsZero() )
+		{
+			*this = ss2;
+			return 0;
+		}
+
+		if( ss2.IsZero() )
+			return 0;
+
+		Int<exp> exp_offset( exponent );
+		Int<exp> mantissa_size_in_bits( man * TTMATH_BITS_PER_UINT );
+
+		uint c = 0;
+
+		exp_offset.Sub( ss2.exponent );
+		exp_offset.Abs();
+
+		// abs(this) will be >= abs(ss2)
+		if( SmallerWithoutSignThan(ss2) )
+			Swap(ss2);
+
+		if( exp_offset >= mantissa_size_in_bits )
+			// the second value is too small
+			return 0;
+
+		// exp_offset < mantissa_size_in_bits, moving 'exp_offset' times
+		ss2.mantissa.Rcr( exp_offset.ToInt(), 0 );
+		mantissa.BitOr(ss2.mantissa);
+
+		c += Standardizing();
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		bitwise XOR
+
+		this and ss2 must be >= 0
+		return values:
+			0 - ok
+			1 - carry
+			2 - this or ss2 was negative
+	*/
+	uint BitXor(Big<exp, man> ss2)
+	{
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( IsSign() || ss2.IsSign() )
+		{
+			SetNan();
+			return 2;
+		}
+		
+		if( ss2.IsZero() )
+			return 0;
+
+		if( IsZero() )
+		{
+			*this = ss2;
+			return 0;
+		}
+
+		Int<exp> exp_offset( exponent );
+		Int<exp> mantissa_size_in_bits( man * TTMATH_BITS_PER_UINT );
+
+		uint c = 0;
+
+		exp_offset.Sub( ss2.exponent );
+		exp_offset.Abs();
+
+		// abs(this) will be >= abs(ss2)
+		if( SmallerWithoutSignThan(ss2) )
+			Swap(ss2);
+
+		if( exp_offset >= mantissa_size_in_bits )
+			// the second value is too small
+			return 0;
+
+		// exp_offset < mantissa_size_in_bits, moving 'exp_offset' times
+		ss2.mantissa.Rcr( exp_offset.ToInt(), 0 );
+		mantissa.BitXor(ss2.mantissa);
+
+		c += Standardizing();
+
+	return CheckCarry(c);
+	}
+
+
+
+	/*!
+		Multiplication this = this * ss2 (ss2 is uint)
+
+		ss2 without a sign
+	*/
+	uint MulUInt(uint ss2)
+	{
+	UInt<man+1> man_result;
+	uint i,c = 0;
+
+		if( IsNan() )
+			return 1;
+
+		if( IsZero() )
+			return 0;
+
+		if( ss2 == 0 )
+		{
+			SetZero();
+			return 0;
+		}
+
+		// man_result = mantissa * ss2.mantissa
+		mantissa.MulInt(ss2, man_result);
+
+		sint bit = UInt<man>::FindLeadingBitInWord(man_result.table[man]); // man - last word
+		
+		if( bit!=-1 && uint(bit) > (TTMATH_BITS_PER_UINT/2) )
+		{
+			// 'i' will be from 0 to TTMATH_BITS_PER_UINT
+			i = man_result.CompensationToLeft();
+			c = exponent.Add( TTMATH_BITS_PER_UINT - i );
+
+			for(i=0 ; i<man ; ++i)
+				mantissa.table[i] = man_result.table[i+1];
+		}
+		else
+		{
+			if( bit != -1 )
+			{
+				man_result.Rcr(bit+1, 0);
+				c += exponent.Add(bit+1);
+			}
+
+			for(i=0 ; i<man ; ++i)
+				mantissa.table[i] = man_result.table[i];
+		}
+
+		c += Standardizing();
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		Multiplication this = this * ss2 (ss2 is sint)
+
+		ss2 with a sign
+	*/
+	uint MulInt(sint ss2)
+	{
+		if( IsNan() )
+			return 1;
+
+		if( ss2 == 0 )
+		{
+			SetZero();
+			return 0;
+		}
+
+		if( IsZero() )
+			return 0;
+
+		if( IsSign() == (ss2<0) )
+		{
+			// the signs are the same (both are either - or +), the result is positive
+			Abs();
+		}
+		else
+		{
+			// the signs are different, the result is negative
+			SetSign();
+		}
+
+		if( ss2<0 )
+			ss2 = -ss2;
+
+
+	return MulUInt( uint(ss2) );
+	}
+
+
+private:
+
+
+	/*!
+		this method checks whether a table pointed by 'tab' and 'len'
+		has the value 0.5 decimal
+		(it is treated as the comma operator would be before the highest bit)
+		call this method only if the highest bit is set - you have to test it beforehand
+
+		return:
+		  true  - tab was equal the half (0.5 decimal)
+		  false - tab was greater than a half (greater than 0.5 decimal)
+
+	*/
+	bool CheckGreaterOrEqualHalf(uint * tab, uint len)
+	{
+	uint i;
+
+		TTMATH_ASSERT( len>0 && (tab[len-1] & TTMATH_UINT_HIGHEST_BIT)!=0 )
+
+		for(i=0 ; i<len-1 ; ++i)
+			if( tab[i] != 0 )
+				return false;
+
+		if( tab[i] != TTMATH_UINT_HIGHEST_BIT )
+			return false;
+
+	return true;
+	}
+
+
+private:
+
+	/*!
+		multiplication this = this * ss2
+		this method returns a carry
+	*/
+	uint MulRef(const Big<exp, man> & ss2, bool round = true)
+	{
+	TTMATH_REFERENCE_ASSERT( ss2 )
+
+	UInt<man*2> man_result;
+	uint c = 0;
+	uint i;
+
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( IsZero() )
+			return 0;
+
+		if( ss2.IsZero() )
+		{
+			SetZero();
+			return 0;
+		}
+
+		// man_result = mantissa * ss2.mantissa
+		mantissa.MulBig(ss2.mantissa, man_result);
+
+		// 'i' will be from 0 to man*TTMATH_BITS_PER_UINT
+		// because mantissa and ss2.mantissa are standardized 
+		// (the highest bit in man_result is set to 1 or
+		// if there is a zero value in man_result the method CompensationToLeft()
+		// returns 0 but we'll correct this at the end in Standardizing() method)
+		i = man_result.CompensationToLeft();
+		uint exp_add = man * TTMATH_BITS_PER_UINT - i;
+
+		if( exp_add )
+			c += exponent.Add( exp_add );
+
+		c += exponent.Add( ss2.exponent );
+
+		for(i=0 ; i<man ; ++i)
+			mantissa.table[i] = man_result.table[i+man];
+
+		if( round && (man_result.table[man-1] & TTMATH_UINT_HIGHEST_BIT) != 0 )
+		{
+			bool is_half = CheckGreaterOrEqualHalf(man_result.table, man);
+			c += RoundHalfToEven(is_half);		
+		}
+
+		if( IsSign() == ss2.IsSign() )
+		{
+			// the signs are the same, the result is positive
+			Abs();
+		}
+		else
+		{
+			// the signs are different, the result is negative
+			// if the value is zero it will be corrected later in Standardizing method
+			SetSign();
+		}
+
+		c += Standardizing();
+
+	return CheckCarry(c);
+	}
+	
+
+public:
+
+
+	/*!
+		multiplication this = this * ss2
+		this method returns a carry
+	*/
+	uint Mul(const Big<exp, man> & ss2, bool round = true)
+	{
+		if( this == &ss2 )
+		{
+			Big<exp, man> copy_ss2(ss2);
+			return MulRef(copy_ss2, round);
+		}
+		else
+		{
+			return MulRef(ss2, round);
+		}
+	}
+
+
+private:
+
+	/*!
+		division this = this / ss2
+
+		return value:
+		0 - ok
+		1 - carry (in a division carry can be as well)
+		2 - improper argument (ss2 is zero)
+	*/
+	uint DivRef(const Big<exp, man> & ss2, bool round = true)
+	{
+	TTMATH_REFERENCE_ASSERT( ss2 )
+
+	UInt<man*2> man1;
+	UInt<man*2> man2;
+	uint i,c = 0;
+		
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( ss2.IsZero() )
+		{
+			SetNan();
+			return 2;
+		}
+
+		if( IsZero() )
+			return 0;
+
+		// !! this two loops can be joined together
+
+		for(i=0 ; i<man ; ++i)
+		{
+			man1.table[i+man] = mantissa.table[i];
+			man2.table[i]     = ss2.mantissa.table[i];
+		}
+
+		for(i=0 ; i<man ; ++i)
+		{
+			man1.table[i] = 0;
+			man2.table[i+man] = 0;
+		}
+
+		man1.Div(man2);
+
+		i = man1.CompensationToLeft();
+
+		if( i )
+			c += exponent.Sub(i);
+
+		c += exponent.Sub(ss2.exponent);
+		
+		for(i=0 ; i<man ; ++i)
+			mantissa.table[i] = man1.table[i+man];
+
+		if( round && (man1.table[man-1] & TTMATH_UINT_HIGHEST_BIT) != 0 )
+		{
+			bool is_half = CheckGreaterOrEqualHalf(man1.table, man);
+			c += RoundHalfToEven(is_half);
+		}
+
+		if( IsSign() == ss2.IsSign() )
+			Abs();
+		else
+			SetSign(); // if there is a zero it will be corrected in Standardizing()
+
+		c += Standardizing();
+
+	return CheckCarry(c);
+	}
+
+
+public:
+
+	/*!
+		division this = this / ss2
+
+		return value:
+		0 - ok
+		1 - carry (in a division carry can be as well)
+		2 - improper argument (ss2 is zero)
+	*/
+	uint Div(const Big<exp, man> & ss2, bool round = true)
+	{
+		if( this == &ss2 )
+		{
+			Big<exp, man> copy_ss2(ss2);
+			return DivRef(copy_ss2, round);
+		}
+		else
+		{
+			return DivRef(ss2, round);
+		}
+	}
+
+
+private:
+
+	/*!
+		the remainder from a division
+	*/
+	uint ModRef(const Big<exp, man> & ss2)
+	{
+	TTMATH_REFERENCE_ASSERT( ss2 )
+
+	uint c = 0;
+
+		if( IsNan() || ss2.IsNan() )
+			return CheckCarry(1);
+
+		if( ss2.IsZero() )
+		{
+			SetNan();
+			return 2;
+		}
+
+		if( !SmallerWithoutSignThan(ss2) )
+		{
+			Big<exp, man> temp(*this);
+
+			c = temp.Div(ss2);
+			temp.SkipFraction();
+			c += temp.Mul(ss2);
+			c += Sub(temp);
+
+			if( !SmallerWithoutSignThan( ss2 ) )
+				c += 1;
+		}
+
+	return CheckCarry(c);
+	}
+
+
+public:
+
+	/*!
+		the remainder from a division
+
+		e.g.
+		 12.6 mod  3 =  0.6   because  12.6 = 3*4 + 0.6
+		-12.6 mod  3 = -0.6   bacause -12.6 = 3*(-4) + (-0.6)
+		 12.6 mod -3 =  0.6
+		-12.6 mod -3 = -0.6
+
+		it means:
+		in other words: this(old) = ss2 * q + this(new)
+
+		return value:
+		0 - ok
+		1 - carry
+		2 - improper argument (ss2 is zero)
+	*/
+	uint Mod(const Big<exp, man> & ss2)
+	{
+		if( this == &ss2 )
+		{
+			Big<exp, man> copy_ss2(ss2);
+			return ModRef(copy_ss2);
+		}
+		else
+		{
+			return ModRef(ss2);
+		}
+	}
+
+
+	/*!
+		this method returns: 'this' mod 2
+		(either zero or one)
+
+		this method is much faster than using Mod( object_with_value_two )
+	*/
+	uint Mod2() const
+	{
+		if( exponent>sint(0) || exponent<=-sint(man*TTMATH_BITS_PER_UINT) )
+			return 0;
+
+		sint exp_int = exponent.ToInt();
+		// 'exp_int' is negative (or zero), we set it as positive
+		exp_int = -exp_int;
+
+	return mantissa.GetBit(exp_int);
+	}
+
+
+	/*!
+		power this = this ^ pow
+		(pow without a sign)
+
+		binary algorithm (r-to-l)
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect arguments (0^0)
+	*/
+	template<uint pow_size>
+	uint Pow(UInt<pow_size> pow)
+	{
+		if( IsNan() )
+			return 1;
+
+		if( IsZero() )
+		{
+			if( pow.IsZero() )
+			{
+				// we don't define zero^zero
+				SetNan();
+				return 2;
+			}
+
+			// 0^(+something) is zero
+			return 0;
+		}
+
+		Big<exp, man> start(*this);
+		Big<exp, man> result;
+		result.SetOne();
+		uint c = 0;
+
+		while( !c )
+		{
+			if( pow.table[0] & 1 )
+				c += result.Mul(start);
+
+			pow.Rcr(1);
+
+			if( pow.IsZero() )
+				break;
+
+			c += start.Mul(start);
+		}
+
+		*this = result;
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		power this = this ^ pow
+		p can be negative
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect arguments 0^0 or 0^(-something)
+	*/
+	template<uint pow_size>
+	uint Pow(Int<pow_size> pow)
+	{
+		if( IsNan() )
+			return 1;
+
+		if( !pow.IsSign() )
+			return Pow( UInt<pow_size>(pow) );
+
+		if( IsZero() )
+		{
+			// if 'p' is negative then
+			// 'this' must be different from zero
+			SetNan();
+			return 2;
+		}
+
+		uint c = pow.ChangeSign();
+
+		Big<exp, man> t(*this);
+		c += t.Pow( UInt<pow_size>(pow) ); // here can only be a carry (return:1)
+
+		SetOne();
+		c += Div(t);
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		power this = this ^ abs([pow])
+		pow is treated as a value without a sign and without a fraction
+		 if pow has a sign then the method pow.Abs() is used
+		 if pow has a fraction the fraction is skipped (not used in calculation)
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect arguments (0^0)
+	*/
+	uint PowUInt(Big<exp, man> pow)
+	{
+		if( IsNan() || pow.IsNan() )
+			return CheckCarry(1);
+
+		if( IsZero() )
+		{
+			if( pow.IsZero() )
+			{
+				SetNan();
+				return 2;
+			}
+
+			// 0^(+something) is zero
+			return 0;
+		}
+
+		if( pow.IsSign() )
+			pow.Abs();
+
+		Big<exp, man> start(*this);
+		Big<exp, man> result;
+		Big<exp, man> one;
+		uint c = 0;
+		one.SetOne();
+		result = one;
+
+		while( !c )
+		{
+			if( pow.Mod2() )
+				c += result.Mul(start);
+
+			c += pow.exponent.SubOne();
+
+			if( pow < one )
+				break;
+
+			c += start.Mul(start);
+		}
+
+		*this = result;
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		power this = this ^ [pow]
+		pow is treated as a value without a fraction
+		pow can be negative
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect arguments 0^0 or 0^(-something)
+	*/
+	uint PowInt(const Big<exp, man> & pow)
+	{
+		if( IsNan() || pow.IsNan() )
+			return CheckCarry(1);
+
+		if( !pow.IsSign() )
+			return PowUInt(pow);
+
+		if( IsZero() )
+		{
+			// if 'pow' is negative then
+			// 'this' must be different from zero
+			SetNan();
+			return 2;
+		}
+
+		Big<exp, man> temp(*this);
+		uint c = temp.PowUInt(pow); // here can only be a carry (result:1)
+
+		SetOne();
+		c += Div(temp);
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		power this = this ^ pow
+		this must be greater than zero (this > 0)
+		pow can be negative and with fraction
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect argument ('this' <= 0)
+	*/
+	uint PowFrac(const Big<exp, man> & pow)
+	{
+		if( IsNan() || pow.IsNan() )
+			return CheckCarry(1);
+
+		Big<exp, man> temp;
+		uint c = temp.Ln(*this);
+
+		if( c != 0 ) // can be 2 from Ln()
+		{
+			SetNan();
+			return c;
+		}
+
+		c += temp.Mul(pow);
+		c += Exp(temp);
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		power this = this ^ pow
+		pow can be negative and with fraction
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect argument ('this' or 'pow')
+	*/
+	uint Pow(const Big<exp, man> & pow)
+	{
+		if( IsNan() || pow.IsNan() )
+			return CheckCarry(1);
+
+		if( IsZero() )
+		{
+			// 0^pow will be 0 only for pow>0
+			if( pow.IsSign() || pow.IsZero() )
+			{
+				SetNan();
+				return 2;
+			}
+
+			SetZero();
+
+		return 0;
+		}
+
+		if( pow.exponent>-sint(man*TTMATH_BITS_PER_UINT) && pow.exponent<=0 )
+		{
+			if( pow.IsInteger() )
+				return PowInt( pow );
+		}
+
+	return PowFrac(pow);
+	}
+
+
+	/*!
+		this function calculates the square root
+		e.g. let this=9 then this.Sqrt() gives 3
+
+		return: 0 - ok
+				1 - carry
+		        2 - improper argument (this<0 or NaN)
+	*/
+	uint Sqrt()
+	{
+		if( IsNan() || IsSign() )
+		{
+			SetNan();
+			return 2;
+		}
+
+		if( IsZero() )
+			return 0;
+
+		Big<exp, man> old(*this);
+		Big<exp, man> ln;
+		uint c = 0;
+
+		// we're using the formula: sqrt(x) = e ^ (ln(x) / 2)
+		c += ln.Ln(*this);
+		c += ln.exponent.SubOne(); // ln = ln / 2
+		c += Exp(ln);
+
+		// above formula doesn't give accurate results for some integers
+		// e.g. Sqrt(81) would not be 9 but a value very closed to 9
+		// we're rounding the result, calculating result*result and comparing
+		// with the old value, if they are equal then the result is an integer too
+
+		if( !c && old.IsInteger() && !IsInteger() )
+		{
+			Big<exp, man> temp(*this);
+			c += temp.Round();
+
+			Big<exp, man> temp2(temp);
+			c += temp.Mul(temp2);
+
+			if( temp == old )
+				*this = temp2;
+		}
+
+	return CheckCarry(c);
+	}
+
+
+private:
+
+#ifdef TTMATH_CONSTANTSGENERATOR
+public:
+#endif
+
+	/*!
+		Exponent this = exp(x) = e^x where x is in (-1,1)
+
+		we're using the formula exp(x) = 1 + (x)/(1!) + (x^2)/(2!) + (x^3)/(3!) + ...
+	*/
+	void ExpSurrounding0(const Big<exp,man> & x, uint * steps = 0)
+	{
+		TTMATH_REFERENCE_ASSERT( x )
+
+		Big<exp,man> denominator, denominator_i;
+		Big<exp,man> one, old_value, next_part;
+		Big<exp,man> numerator = x;
+		
+		SetOne();
+		one.SetOne();
+		denominator.SetOne();
+		denominator_i.SetOne();
+
+		uint i;
+		old_value = *this;
+
+		// we begin from 1 in order to not test at the beginning
+	#ifdef TTMATH_CONSTANTSGENERATOR
+		for(i=1 ; true ; ++i)
+	#else
+		for(i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
+	#endif
+		{
+			bool testing = ((i & 3) == 0); // it means '(i % 4) == 0'
+
+			next_part = numerator;
+
+			if( next_part.Div( denominator ) )
+				// if there is a carry here we only break the loop 
+				// however the result we return as good
+				// it means there are too many parts of the formula
+				break;
+
+			// there shouldn't be a carry here
+			Add( next_part );
+
+			if( testing )
+			{
+				if( old_value == *this )
+					// we've added next few parts of the formula but the result
+					// is still the same then we break the loop
+					break;
+				else
+					old_value = *this;
+			}
+
+			// we set the denominator and the numerator for a next part of the formula
+			if( denominator_i.Add(one) )
+				// if there is a carry here the result we return as good
+				break;
+
+			if( denominator.Mul(denominator_i) )
+				break;
+
+			if( numerator.Mul(x) )
+				break;
+		}
+
+		if( steps )
+			*steps = i;
+	}
+
+public:
+
+
+	/*!
+		Exponent this = exp(x) = e^x
+
+		we're using the fact that our value is stored in form of:
+			x = mantissa * 2^exponent
+		then
+			e^x = e^(mantissa* 2^exponent) or
+			e^x = (e^mantissa)^(2^exponent)
+
+		'Exp' returns a carry if we can't count the result ('x' is too big)
+	*/
+	uint Exp(const Big<exp,man> & x)
+	{
+	uint c = 0;
+		
+		if( x.IsNan() )
+			return CheckCarry(1);
+
+		if( x.IsZero() )
+		{
+			SetOne();
+		return 0;
+		}
+
+		// m will be the value of the mantissa in range (-1,1)
+		Big<exp,man> m(x);
+		m.exponent = -sint(man*TTMATH_BITS_PER_UINT);
+
+		// 'e_' will be the value of '2^exponent'
+		//   e_.mantissa.table[man-1] = TTMATH_UINT_HIGHEST_BIT;  and
+		//   e_.exponent.Add(1) mean:
+		//     e_.mantissa.table[0] = 1;
+		//     e_.Standardizing();
+		//     e_.exponent.Add(man*TTMATH_BITS_PER_UINT)
+		//     (we must add 'man*TTMATH_BITS_PER_UINT' because we've taken it from the mantissa)
+		Big<exp,man> e_(x);
+		e_.mantissa.SetZero();
+		e_.mantissa.table[man-1] = TTMATH_UINT_HIGHEST_BIT;
+		c += e_.exponent.Add(1);
+		e_.Abs();
+
+		/*
+			now we've got:
+			m - the value of the mantissa in range (-1,1)
+			e_ - 2^exponent
+
+			e_ can be as:
+			...2^-2, 2^-1, 2^0, 2^1, 2^2 ...
+			...1/4 , 1/2 , 1  , 2  , 4   ...
+
+			above one e_ is integer
+
+			if e_ is greater than 1 we calculate the exponent as:
+				e^(m * e_) = ExpSurrounding0(m) ^ e_
+			and if e_ is smaller or equal one we calculate the exponent in this way:
+				e^(m * e_) = ExpSurrounding0(m* e_)
+			because if e_ is smaller or equal 1 then the product of m*e_ is smaller or equal m
+		*/
+
+		if( e_ <= 1 )
+		{
+			m.Mul(e_);
+			ExpSurrounding0(m);
+		}
+		else
+		{
+			ExpSurrounding0(m);
+			c += PowUInt(e_);
+		}
+	
+	return CheckCarry(c);
+	}
+
+
+
+
+private:
+
+#ifdef TTMATH_CONSTANTSGENERATOR
+public:
+#endif
+
+	/*!
+		Natural logarithm this = ln(x) where x in range <1,2)
+
+		we're using the formula:
+		ln x = 2 * [ (x-1)/(x+1) + (1/3)((x-1)/(x+1))^3 + (1/5)((x-1)/(x+1))^5 + ... ]
+	*/
+	void LnSurrounding1(const Big<exp,man> & x, uint * steps = 0)
+	{
+		Big<exp,man> old_value, next_part, denominator, one, two, x1(x), x2(x);
+
+		one.SetOne();
+
+		if( x == one )
+		{
+			// LnSurrounding1(1) is 0
+			SetZero();
+			return;
+		}
+
+		two = 2;
+
+		x1.Sub(one);
+		x2.Add(one);
+
+		x1.Div(x2);
+		x2 = x1;
+		x2.Mul(x1);
+
+		denominator.SetOne();
+		SetZero();
+
+		old_value = *this;
+		uint i;
+
+
+	#ifdef TTMATH_CONSTANTSGENERATOR
+		for(i=1 ; true ; ++i)
+	#else
+		// we begin from 1 in order to not test at the beginning
+		for(i=1 ; i<=TTMATH_ARITHMETIC_MAX_LOOP ; ++i)
+	#endif
+		{
+			bool testing = ((i & 3) == 0); // it means '(i % 4) == 0'
+
+			next_part = x1;
+
+			if( next_part.Div(denominator) )
+				// if there is a carry here we only break the loop 
+				// however the result we return as good
+				// it means there are too many parts of the formula
+				break;
+
+			// there shouldn't be a carry here
+			Add(next_part);
+
+			if( testing )
+			{
+				if( old_value == *this )
+					// we've added next (step_test) parts of the formula but the result
+					// is still the same then we break the loop
+					break;
+				else
+					old_value = *this;
+			}
+
+			if( x1.Mul(x2) )
+				// if there is a carry here the result we return as good
+				break;
+
+			if( denominator.Add(two) )
+				break;
+		}
+
+		// this = this * 2
+		// ( there can't be a carry here because we calculate the logarithm between <1,2) )
+		exponent.AddOne();
+
+		if( steps )
+			*steps = i;
+	}
+
+
+
+
+public:
+
+
+	/*!
+		Natural logarithm this = ln(x)
+		(a logarithm with the base equal 'e')
+
+		we're using the fact that our value is stored in form of:
+			x = mantissa * 2^exponent
+		then
+			ln(x) = ln (mantissa * 2^exponent) = ln (mantissa) + (exponent * ln (2))
+
+		the mantissa we'll show as a value from range <1,2) because the logarithm
+		is decreasing too fast when 'x' is going to 0
+
+		return values:
+			0 - ok
+			1 - overflow (carry)
+			2 - incorrect argument (x<=0)
+	*/
+	uint Ln(const Big<exp,man> & x)
+	{
+		if( x.IsNan() )
+			return CheckCarry(1);
+
+		if( x.IsSign() || x.IsZero() )
+		{
+			SetNan();
+			return 2;
+		}
+
+		Big<exp,man> exponent_temp;
+		exponent_temp.FromInt( x.exponent );
+
+		// m will be the value of the mantissa in range <1,2)
+		Big<exp,man> m(x);
+		m.exponent = -sint(man*TTMATH_BITS_PER_UINT - 1);
+
+		// we must add 'man*TTMATH_BITS_PER_UINT-1' because we've taken it from the mantissa
+		uint c = exponent_temp.Add(man*TTMATH_BITS_PER_UINT-1);
+
+	    LnSurrounding1(m);
+
+		Big<exp,man> ln2;
+		ln2.SetLn2();
+		c += exponent_temp.Mul(ln2);
+		c += Add(exponent_temp);
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		Logarithm from 'x' with a 'base'
+
+		we're using the formula:
+			Log(x) with 'base' = ln(x) / ln(base)
+
+		return values:
+			0 - ok
+			1 - overflow
+			2 - incorrect argument (x<=0)
+			3 - incorrect base (a<=0 lub a=1)
+	*/
+	uint Log(const Big<exp,man> & x, const Big<exp,man> & base)
+	{
+		if( x.IsNan() || base.IsNan() )
+			return CheckCarry(1);
+
+		if( x.IsSign() || x.IsZero() )
+		{
+			SetNan();
+			return 2;
+		}
+
+		Big<exp,man> denominator;;
+		denominator.SetOne();
+
+		if( base.IsSign() || base.IsZero() || base==denominator )
+		{
+			SetNan();
+			return 3;
+		}
+		
+		if( x == denominator ) // (this is: if x == 1)
+		{
+			// log(1) is 0
+			SetZero();
+			return 0;
+		}
+
+		// another error values we've tested at the beginning
+		// there can only be a carry
+		uint c = Ln(x);
+
+		c += denominator.Ln(base);
+		c += Div(denominator);
+
+	return CheckCarry(c);
+	}
+
+
+
+
+	/*!
+	*
+	*	converting methods
+	*
+	*/
+
+
+	/*!
+		converting from another type of a Big object
+	*/
+	template<uint another_exp, uint another_man>
+	uint FromBig(const Big<another_exp, another_man> & another)
+	{
+		info = another.info;
+
+		if( IsNan() )
+			return 1;
+
+		if( exponent.FromInt(another.exponent) )
+		{
+			SetNan();
+			return 1;
+		}
+
+		uint man_len_min = (man < another_man)? man : another_man;
+		uint i;
+		uint c = 0;
+
+		for( i = 0 ; i<man_len_min ; ++i )
+			mantissa.table[man-1-i] = another.mantissa.table[another_man-1-i];
+	
+		for( ; i<man ; ++i )
+			mantissa.table[man-1-i] = 0;
+
+
+		// MS Visual Express 2005 reports a warning (in the lines with 'uint man_diff = ...'):
+		// warning C4307: '*' : integral constant overflow
+		// but we're using 'if( man > another_man )' and 'if( man < another_man )' and there'll be no such situation here
+		#ifdef _MSC_VER
+		#pragma warning( disable: 4307 )
+		#endif
+
+		if( man > another_man )
+		{
+			uint man_diff = (man - another_man) * TTMATH_BITS_PER_UINT;
+			c += exponent.SubInt(man_diff, 0);
+		}
+		else
+		if( man < another_man )
+		{
+			uint man_diff = (another_man - man) * TTMATH_BITS_PER_UINT;
+			c += exponent.AddInt(man_diff, 0);
+		}
+		
+		#ifdef _MSC_VER
+		#pragma warning( default: 4307 )
+		#endif
+
+		// mantissa doesn't have to be standardized (either the highest bit is set or all bits are equal zero)
+		CorrectZero();
+
+	return CheckCarry(c);
+	}
+
+
+private:
+
+	/*!
+		an auxiliary method for converting 'this' into 'result'
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToUIntOrInt(uint & result) const
+	{
+		result = 0;
+
+		if( IsZero() )
+			return 0;
+
+		sint maxbit = -sint(man*TTMATH_BITS_PER_UINT);
+
+		if( exponent > maxbit + sint(TTMATH_BITS_PER_UINT) )
+			// if exponent > (maxbit + sint(TTMATH_BITS_PER_UINT)) the value can't be passed
+			// into the 'sint' type (it's too big)
+			return 1;
+
+		if( exponent <= maxbit )
+			// our value is from the range of (-1,1) and we return zero
+			return 0;
+
+		// exponent is from a range of (maxbit, maxbit + sint(TTMATH_BITS_PER_UINT) >
+		// and [maxbit + sint(TTMATH_BITS_PER_UINT] <= 0
+		sint how_many_bits = exponent.ToInt();
+
+		// how_many_bits is negative, we'll make it positive
+		how_many_bits = -how_many_bits;
+	
+		result = (mantissa.table[man-1] >> (how_many_bits % TTMATH_BITS_PER_UINT));
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		this method converts 'this' into uint
+	*/
+	uint ToUInt() const
+	{
+	uint result;
+
+		ToUInt(result);
+
+	return result;
+	}
+
+
+	/*!
+		this method converts 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToUInt(uint & result) const
+	{
+		if( ToUIntOrInt(result) )
+			return 1;
+
+		if( IsSign() )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts 'this' into sint
+	*/
+	sint ToInt() const
+	{
+	sint result;
+
+		ToInt(result);
+
+	return result;
+	}
+
+
+	/*!
+		this method converts 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToInt(uint & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToInt(sint & result) const
+	{
+	uint result_uint;
+
+		uint c = ToUIntOrInt(result_uint);
+		result = sint(result_uint);
+
+		if( c )
+			return 1;
+
+		uint mask = 0;
+
+		if( IsSign() )
+		{
+			mask = TTMATH_UINT_MAX_VALUE;
+			result = -result;
+		}
+
+	return ((result & TTMATH_UINT_HIGHEST_BIT) == (mask & TTMATH_UINT_HIGHEST_BIT)) ? 0 : 1;
+	}
+
+
+private:
+
+	/*!
+		an auxiliary method for converting 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	template<uint int_size>
+	uint ToUIntOrInt(UInt<int_size> & result) const
+	{
+		result.SetZero();
+
+		if( IsZero() )
+			return 0;
+		
+		sint maxbit = -sint(man*TTMATH_BITS_PER_UINT);
+
+		if( exponent > maxbit + sint(int_size*TTMATH_BITS_PER_UINT) )
+			// if exponent > (maxbit + sint(int_size*TTMATH_BITS_PER_UINT)) the value can't be passed
+			// into the 'UInt<int_size>' type (it's too big)
+			return 1;
+
+		if( exponent <= maxbit )
+			// our value is from range (-1,1) and we return zero
+			return 0;
+
+		sint how_many_bits = exponent.ToInt();
+
+		if( how_many_bits < 0 )
+		{
+			how_many_bits = -how_many_bits;
+			uint index    = how_many_bits / TTMATH_BITS_PER_UINT;
+
+			UInt<man> mantissa_temp(mantissa);
+			mantissa_temp.Rcr( how_many_bits % TTMATH_BITS_PER_UINT, 0 );
+
+			for(uint i=index, a=0 ; i<man ; ++i,++a)
+				result.table[a] = mantissa_temp.table[i];
+		}
+		else
+		{
+			uint index = how_many_bits / TTMATH_BITS_PER_UINT;
+
+			if( index + (man-1) < int_size )
+			{
+				// above 'if' is always true
+				// this is only to get rid of a warning "warning: array subscript is above array bounds"
+				// (from gcc)
+				// we checked the condition there: "if( exponent > maxbit + sint(int_size*TTMATH_BITS_PER_UINT) )"
+				// but gcc doesn't understand our types - exponent is Int<>
+
+				for(uint i=0 ; i<man ; ++i)
+					result.table[index+i] = mantissa.table[i];
+			}
+
+			result.Rcl( how_many_bits % TTMATH_BITS_PER_UINT, 0 );
+		}
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		this method converts 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	template<uint int_size>
+	uint ToUInt(UInt<int_size> & result) const
+	{
+		uint c = ToUIntOrInt(result);
+
+		if( c )
+			return 1;
+
+		if( IsSign() )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	template<uint int_size>
+	uint ToInt(UInt<int_size> & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts 'this' into 'result'
+
+		if the value is too big this method returns a carry (1)
+	*/
+	template<uint int_size>
+	uint ToInt(Int<int_size> & result) const
+	{
+		uint c = ToUIntOrInt(result);
+
+		if( c )
+			return 1;
+
+		uint mask = 0;
+
+		if( IsSign() )
+		{
+			result.ChangeSign();
+			mask = TTMATH_UINT_MAX_VALUE;
+		}
+
+	return ((result.table[int_size-1] & TTMATH_UINT_HIGHEST_BIT) == (mask & TTMATH_UINT_HIGHEST_BIT))? 0 : 1;
+	}
+
+
+	/*!
+		a method for converting 'uint' to this class
+	*/
+	uint FromUInt(uint value)
+	{
+		if( value == 0 )
+		{
+			SetZero();
+			return 0;
+		}
+
+		info = 0;
+
+		for(uint i=0 ; i<man-1 ; ++i)
+			mantissa.table[i] = 0;
+
+		mantissa.table[man-1] = value;
+		exponent = -sint(man-1) * sint(TTMATH_BITS_PER_UINT);
+
+		// there shouldn't be a carry because 'value' has the 'uint' type 
+		Standardizing();
+
+	return 0;
+	}
+
+
+	/*!
+		a method for converting 'uint' to this class
+	*/
+	uint FromInt(uint value)
+	{
+		return FromUInt(value);
+	}
+
+
+	/*!
+		a method for converting 'sint' to this class
+	*/
+	uint FromInt(sint value)
+	{
+	bool is_sign = false;
+
+		if( value < 0 )
+		{
+			value   = -value;
+			is_sign = true;
+		}
+
+		FromUInt(uint(value));
+
+		if( is_sign )
+			SetSign();
+
+	return 0;
+	}
+
+
+
+	/*!
+		this method converts from standard double into this class
+
+		standard double means IEEE-754 floating point value with 64 bits
+		it is as follows (from http://www.psc.edu/general/software/packages/ieee/ieee.html):
+
+		The IEEE double precision floating point standard representation requires
+		a 64 bit word, which may be represented as numbered from 0 to 63, left to
+		right. The first bit is the sign bit, S, the next eleven bits are the
+		exponent bits, 'E', and the final 52 bits are the fraction 'F':
+
+		S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+		0 1        11 12                                                63
+
+		The value V represented by the word may be determined as follows:
+
+		* If E=2047 and F is nonzero, then V=NaN ("Not a number")
+		* If E=2047 and F is zero and S is 1, then V=-Infinity
+		* If E=2047 and F is zero and S is 0, then V=Infinity
+		* If 0<E<2047 then V=(-1)**S * 2 ** (E-1023) * (1.F) where "1.F" is intended
+		  to represent the binary number created by prefixing F with an implicit
+		  leading 1 and a binary point.
+		* If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-1022) * (0.F) These are
+		  "unnormalized" values.
+		* If E=0 and F is zero and S is 1, then V=-0
+		* If E=0 and F is zero and S is 0, then V=0 
+	*/
+
+#ifdef TTMATH_PLATFORM32
+
+	uint FromDouble(double value)
+	{
+		// I am not sure what will be on a platform which has 
+		// a different endianness... but we use this library only
+		// on x86 and amd (intel) 64 bits (as there's a lot of assembler code)
+		union 
+		{
+			double d;
+			uint u[2]; // two 32bit words
+		} temp;
+
+		temp.d = value;
+
+		sint e  = ( temp.u[1] & 0x7FF00000u) >> 20;
+		uint m1 = ((temp.u[1] &    0xFFFFFu) << 11) | (temp.u[0] >> 21);
+		uint m2 = temp.u[0] << 11;
+		
+		if( e == 2047 )
+		{
+			// If E=2047 and F is nonzero, then V=NaN ("Not a number")
+			// If E=2047 and F is zero and S is 1, then V=-Infinity
+			// If E=2047 and F is zero and S is 0, then V=Infinity
+
+			// we do not support -Infinity and +Infinity
+			// we assume that there is always NaN 
+
+			SetNan();
+		}
+		else
+		if( e > 0 )
+		{
+			// If 0<E<2047 then
+			// V=(-1)**S * 2 ** (E-1023) * (1.F)
+			// where "1.F" is intended to represent the binary number
+			// created by prefixing F with an implicit leading 1 and a binary point.
+			
+			FromDouble_SetExpAndMan((temp.u[1] & 0x80000000u) != 0,
+									e - 1023 - man*TTMATH_BITS_PER_UINT + 1, 0x80000000u,
+									m1, m2);
+
+			// we do not have to call Standardizing() here
+			// because the mantissa will have the highest bit set
+		}
+		else
+		{
+			// e == 0
+
+			if( m1 != 0 || m2 != 0 )
+			{
+				// If E=0 and F is nonzero,
+				// then V=(-1)**S * 2 ** (-1022) * (0.F)
+				// These are "unnormalized" values.
+
+				UInt<2> m;
+				m.table[1] = m1;
+				m.table[0] = m2;
+				uint moved = m.CompensationToLeft();
+
+				FromDouble_SetExpAndMan((temp.u[1] & 0x80000000u) != 0,
+										e - 1022 - man*TTMATH_BITS_PER_UINT + 1 - moved, 0,
+										m.table[1], m.table[2]);
+			}
+			else
+			{
+				// If E=0 and F is zero and S is 1, then V=-0
+				// If E=0 and F is zero and S is 0, then V=0 
+
+				// we do not support -0 or 0, only is one 0
+				SetZero();
+			}
+		}
+
+	return 0; // never be a carry
+	}
+
+
+private:
+
+	void FromDouble_SetExpAndMan(bool is_sign, int e, uint mhighest, uint m1, uint m2)
+	{
+		exponent = e;
+
+		if( man > 1 )
+		{
+			mantissa.table[man-1] = m1 | mhighest;
+			mantissa.table[sint(man-2)] = m2;
+			// although man>1 we're using casting into sint
+			// to get rid from a warning which generates Microsoft Visual:
+			// warning C4307: '*' : integral constant overflow
+
+			for(uint i=0 ; i<man-2 ; ++i)
+				mantissa.table[i] = 0;
+		}
+		else
+		{
+			mantissa.table[0] = m1 | mhighest;
+		}
+
+		info = 0;
+	
+		// the value should be different from zero
+		TTMATH_ASSERT( mantissa.IsZero() == false )
+
+		if( is_sign )
+			SetSign();
+	}
+
+
+#else
+
+public:
+
+	// 64bit platforms
+	uint FromDouble(double value)
+	{
+		// I am not sure what will be on a plaltform which has 
+		// a different endianness... but we use this library only
+		// on x86 and amd (intel) 64 bits (as there's a lot of assembler code)
+		union 
+		{
+			double d;
+			uint u; // one 64bit word
+		} temp;
+
+		temp.d = value;
+                          
+		sint e = (temp.u & 0x7FF0000000000000ul) >> 52;
+		uint m = (temp.u &    0xFFFFFFFFFFFFFul) << 11;
+		
+		if( e == 2047 )
+		{
+			// If E=2047 and F is nonzero, then V=NaN ("Not a number")
+			// If E=2047 and F is zero and S is 1, then V=-Infinity
+			// If E=2047 and F is zero and S is 0, then V=Infinity
+
+			// we do not support -Infinity and +Infinity
+			// we assume that there is always NaN 
+
+			SetNan();
+		}
+		else
+		if( e > 0 )
+		{
+			// If 0<E<2047 then
+			// V=(-1)**S * 2 ** (E-1023) * (1.F)
+			// where "1.F" is intended to represent the binary number
+			// created by prefixing F with an implicit leading 1 and a binary point.
+			
+			FromDouble_SetExpAndMan((temp.u & 0x8000000000000000ul) != 0,
+									e - 1023 - man*TTMATH_BITS_PER_UINT + 1,
+									0x8000000000000000ul, m);
+
+			// we do not have to call Standardizing() here
+			// because the mantissa will have the highest bit set
+		}
+		else
+		{
+			// e == 0
+
+			if( m != 0 )
+			{
+				// If E=0 and F is nonzero,
+				// then V=(-1)**S * 2 ** (-1022) * (0.F)
+				// These are "unnormalized" values.
+
+				FromDouble_SetExpAndMan(bool(temp.u & 0x8000000000000000ul),
+										e - 1022 - man*TTMATH_BITS_PER_UINT + 1, 0, m);
+				Standardizing();
+			}
+			else
+			{
+				// If E=0 and F is zero and S is 1, then V=-0
+				// If E=0 and F is zero and S is 0, then V=0 
+
+				// we do not support -0 or 0, only is one 0
+				SetZero();
+			}
+		}
+
+	return 0; // never be a carry
+	}
+
+private:
+
+	void FromDouble_SetExpAndMan(bool is_sign, sint e, uint mhighest, uint m)
+	{
+		exponent = e;
+		mantissa.table[man-1] = m | mhighest;
+
+		for(uint i=0 ; i<man-1 ; ++i)
+			mantissa.table[i] = 0;
+
+		info = 0;
+
+		// the value should be different from zero
+		TTMATH_ASSERT( mantissa.IsZero() == false )
+
+		if( is_sign )
+			SetSign();
+	}
+
+#endif
+
+
+public:
+
+
+	/*!
+		this method converts from float to this class
+	*/
+	uint FromFloat(float value)
+	{
+		return FromDouble(double(value));
+	}
+
+
+	/*!
+		this method converts from this class into the 'double'
+
+		if the value is too big:
+			'result' will be +/-infinity (depending on the sign)
+		if the value is too small:
+			'result' will be 0
+	*/
+	double ToDouble() const
+	{
+	double result;
+
+		ToDouble(result);
+
+	return result;
+	}
+
+
+private:
+
+
+	/*!
+		an auxiliary method to check if the float value is +/-infinity
+		we provide this method because isinf(float) in only in C99 language
+
+		description taken from: http://www.psc.edu/general/software/packages/ieee/ieee.php
+
+		The IEEE single precision floating point standard representation requires a 32 bit word,
+		which may be represented as numbered from 0 to 31, left to right.
+		The first bit is the sign bit, S, the next eight bits are the exponent bits, 'E',
+		and the final 23 bits are the fraction 'F':
+
+		S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
+		0 1      8 9                    31
+
+		The value V represented by the word may be determined as follows:
+
+			* If E=255 and F is nonzero, then V=NaN ("Not a number")
+			* If E=255 and F is zero and S is 1, then V=-Infinity
+			* If E=255 and F is zero and S is 0, then V=Infinity
+			* If 0<E<255 then V=(-1)**S * 2 ** (E-127) * (1.F) where "1.F" is intended to represent
+			  the binary number created by prefixing F with an implicit leading 1 and a binary point.
+			* If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-126) * (0.F) These are "unnormalized" values.
+			* If E=0 and F is zero and S is 1, then V=-0
+			* If E=0 and F is zero and S is 0, then V=0 		
+	*/
+	bool IsInf(float value) const
+	{
+		// need testing on a 64 bit machine
+
+		union 
+		{
+			float d;
+			uint u;
+		} temp;
+
+		temp.d = value;
+
+		if( ((temp.u >> 23) & 0xff) == 0xff )
+		{
+			if( (temp.u & 0x7FFFFF) == 0 )
+				return true; // +/- infinity
+		}
+
+	return false;
+	}
+
+
+public:
+
+	/*!
+		this method converts from this class into the 'float'
+
+		if the value is too big:
+			'result' will be +/-infinity (depending on the sign)
+		if the value is too small:
+			'result' will be 0
+	*/
+	float ToFloat() const
+	{
+	float result;
+
+		ToFloat(result);
+
+	return result;
+	}
+
+
+	/*!
+		this method converts from this class into the 'float'
+
+		if the value is too big:
+			'result' will be +/-infinity (depending on the sign)
+			and the method returns 1
+		if the value is too small:
+			'result' will be 0
+			and the method returns 1
+	*/
+	uint ToFloat(float & result) const
+	{
+	double result_double;
+
+		uint c = ToDouble(result_double);
+		result = float(result_double);
+		
+		if( result == -0.0f )
+			result = 0.0f;
+
+		if( c )
+			return 1;
+
+		// although the result_double can have a correct value
+		// but after converting to float there can be infinity
+
+		if( IsInf(result) )
+			return 1;
+
+		if( result == 0.0f && result_double != 0.0 )
+			// result_double was too small for float
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts from this class into the 'double'
+
+		if the value is too big:
+			'result' will be +/-infinity (depending on the sign)
+			and the method returns 1
+		if the value is too small:
+			'result' will be 0
+			and the method returns 1
+	*/
+	uint ToDouble(double & result) const
+	{
+		if( IsZero() )
+		{
+			result = 0.0;
+			return 0;
+		}
+
+		if( IsNan() )
+		{
+			result = ToDouble_SetDouble( false, 2047, 0, false, true);
+
+		return 0;
+		}
+
+		sint e_correction = sint(man*TTMATH_BITS_PER_UINT) - 1;
+
+		if( exponent >= 1024 - e_correction )
+		{
+			// +/- infinity
+			result = ToDouble_SetDouble( IsSign(), 2047, 0, true);
+
+		return 1;
+		}
+		else
+		if( exponent <= -1023 - 52 - e_correction )
+		{
+			// too small value - we assume that there'll be a zero
+			result = 0;
+
+			// and return a carry
+		return 1;
+		}
+		
+		sint e = exponent.ToInt() + e_correction;
+
+		if( e <= -1023 )
+		{
+			// -1023-52 < e <= -1023  (unnormalized value)
+			result = ToDouble_SetDouble( IsSign(), 0, -(e + 1023));
+		}
+		else
+		{
+			// -1023 < e < 1024
+			result = ToDouble_SetDouble( IsSign(), e + 1023, -1);
+		}
+
+	return 0;
+	}
+
+private:
+
+#ifdef TTMATH_PLATFORM32
+
+	// 32bit platforms
+	double ToDouble_SetDouble(bool is_sign, uint e, sint move, bool infinity = false, bool nan = false) const
+	{
+		union 
+		{
+			double d;
+			uint u[2]; // two 32bit words
+		} temp;
+
+		temp.u[0] = temp.u[1] = 0;
+
+		if( is_sign )
+			temp.u[1] |= 0x80000000u;
+
+		temp.u[1] |= (e << 20) & 0x7FF00000u;
+
+		if( nan )
+		{
+			temp.u[0] |= 1;
+			return temp.d;
+		}
+
+		if( infinity )
+			return temp.d;
+
+		UInt<2> m;
+		m.table[1] = mantissa.table[man-1];
+		m.table[0] = ( man > 1 ) ? mantissa.table[sint(man-2)] : 0;
+		// although man>1 we're using casting into sint
+		// to get rid from a warning which generates Microsoft Visual:
+		// warning C4307: '*' : integral constant overflow
+
+		m.Rcr( 12 + move );
+		m.table[1] &= 0xFFFFFu; // cutting the 20 bit (when 'move' was -1)
+
+		temp.u[1] |= m.table[1];
+		temp.u[0] |= m.table[0];
+
+	return temp.d;
+	}
+
+#else
+
+	// 64bit platforms
+	double ToDouble_SetDouble(bool is_sign, uint e, sint move, bool infinity = false, bool nan = false) const
+	{
+		union 
+		{
+			double d;
+			uint u; // 64bit word
+		} temp;
+
+		temp.u = 0;
+		
+		if( is_sign )
+			temp.u |= 0x8000000000000000ul;
+		                
+		temp.u |= (e << 52) & 0x7FF0000000000000ul;
+
+		if( nan )
+		{
+			temp.u |= 1;
+			return temp.d;
+		}
+
+		if( infinity )
+			return temp.d;
+
+		uint m = mantissa.table[man-1];
+
+		m >>= ( 12 + move );
+		m &= 0xFFFFFFFFFFFFFul; // cutting the 20 bit (when 'move' was -1)
+		temp.u |= m;
+
+	return temp.d;
+	}
+
+#endif
+
+
+public:
+
+
+	/*!
+		an operator= for converting 'sint' to this class
+	*/
+	Big<exp, man> & operator=(sint value)
+	{
+		FromInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		an operator= for converting 'uint' to this class
+	*/
+	Big<exp, man> & operator=(uint value)
+	{
+		FromUInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		an operator= for converting 'float' to this class
+	*/
+	Big<exp, man> & operator=(float value)
+	{
+		FromFloat(value);
+
+	return *this;
+	}
+
+
+	/*!
+		an operator= for converting 'double' to this class
+	*/
+	Big<exp, man> & operator=(double value)
+	{
+		FromDouble(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 'sint' to this class
+	*/
+	Big(sint value)
+	{
+		FromInt(value);
+	}
+
+	/*!
+		a constructor for converting 'uint' to this class
+	*/
+	Big(uint value)
+	{	
+		FromUInt(value);
+	}
+	
+
+	/*!
+		a constructor for converting 'double' to this class
+	*/
+	Big(double value)
+	{
+		FromDouble(value);
+	}
+
+
+	/*!
+		a constructor for converting 'float' to this class
+	*/
+	Big(float value)
+	{
+		FromFloat(value);
+	}
+
+
+#ifdef TTMATH_PLATFORM32
+
+	/*!
+		this method converts 'this' into 'result' (64 bit unsigned integer)
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToUInt(ulint & result) const
+	{
+	UInt<2> temp; // 64 bits container
+
+		uint c = ToUInt(temp);
+		temp.ToUInt(result);
+
+	return c;
+	}
+
+
+	/*!
+		this method converts 'this' into 'result' (64 bit unsigned integer)
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToInt(ulint & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts 'this' into 'result' (64 bit unsigned integer)
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToInt(slint & result) const
+	{
+	Int<2> temp; // 64 bits container
+
+		uint c = ToInt(temp);
+		temp.ToInt(result);
+
+	return c;
+	}
+
+
+	/*!
+		a method for converting 'ulint' (64bit unsigned integer) to this class
+	*/
+	uint FromUInt(ulint value)
+	{
+		if( value == 0 )
+		{
+			SetZero();
+			return 0;
+		}
+
+		info = 0;
+
+		if( man == 1 )
+		{
+			sint bit = mantissa.FindLeadingBitInWord(uint(value >> TTMATH_BITS_PER_UINT));
+
+			if( bit != -1 )
+			{
+				// the highest word from value is different from zero
+				bit += 1;
+				value >>= bit;
+				exponent = bit;
+			}
+			else
+			{
+				exponent.SetZero();
+			}
+
+			mantissa.table[0] = uint(value);
+		}
+		else
+		{
+		#ifdef _MSC_VER
+		//warning C4307: '*' : integral constant overflow
+		#pragma warning( disable: 4307 )
+		#endif
+
+			// man >= 2
+			mantissa.table[man-1] = uint(value >> TTMATH_BITS_PER_UINT);
+			mantissa.table[man-2] = uint(value);
+
+		#ifdef _MSC_VER
+		//warning C4307: '*' : integral constant overflow
+		#pragma warning( default: 4307 )
+		#endif
+
+			exponent = -sint(man-2) * sint(TTMATH_BITS_PER_UINT);
+
+			for(uint i=0 ; i<man-2 ; ++i)
+				mantissa.table[i] = 0;
+		}
+
+		// there shouldn't be a carry because 'value' has the 'ulint' type 
+		// (we have	sufficient exponent)
+		Standardizing();
+
+	return 0;
+	}
+
+
+	/*!
+		a method for converting 'ulint' (64bit unsigned integer) to this class
+	*/
+	uint FromInt(ulint value)
+	{
+		return FromUInt(value);
+	}
+
+
+	/*!
+		a method for converting 'slint' (64bit signed integer) to this class
+	*/
+	uint FromInt(slint value)
+	{
+	bool is_sign = false;
+
+		if( value < 0 )
+		{
+			value   = -value;
+			is_sign = true;
+		}
+
+		FromUInt(ulint(value));
+
+		if( is_sign )
+			SetSign();
+
+	return 0;
+	}
+
+
+	/*!
+		a constructor for converting 'ulint' (64bit unsigned integer) to this class
+	*/
+	Big(ulint value)
+	{	
+		FromUInt(value);
+	}
+
+
+	/*!
+		an operator for converting 'ulint' (64bit unsigned integer) to this class
+	*/
+	Big<exp, man> & operator=(ulint value)
+	{	
+		FromUInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 'slint' (64bit signed integer) to this class
+	*/
+	Big(slint value)
+	{	
+		FromInt(value);
+	}
+
+
+	/*!
+		an operator for converting 'slint' (64bit signed integer) to this class
+	*/
+	Big<exp, man> & operator=(slint value)
+	{	
+		FromInt(value);
+
+	return *this;
+	}
+
+#endif
+
+
+
+#ifdef TTMATH_PLATFORM64
+
+
+	/*!
+		this method converts 'this' into 'result' (32 bit unsigned integer)
+		***this method is created only on a 64bit platform***
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToUInt(unsigned int & result) const
+	{
+	uint result_uint;
+
+		uint c = ToUInt(result_uint);
+		result = (unsigned int)result_uint;
+
+		if( c || result_uint != uint(result) )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts 'this' into 'result' (32 bit unsigned integer)
+		***this method is created only on a 64bit platform***
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToInt(unsigned int & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts 'this' into 'result' (32 bit signed integer)
+		***this method is created only on a 64bit platform***
+		if the value is too big this method returns a carry (1)
+	*/
+	uint ToInt(signed int & result) const
+	{
+	sint result_sint;
+
+		uint c = ToInt(result_sint);
+		result = (signed int)result_sint;
+
+		if( c || result_sint != sint(result) )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*
+		this method converts 32 bit unsigned int to this class
+		***this method is created only on a 64bit platform***
+	*/
+	uint FromUInt(unsigned int value)
+	{
+		return FromUInt(uint(value));
+	}
+
+
+	/*
+		this method converts 32 bit unsigned int to this class
+		***this method is created only on a 64bit platform***
+	*/
+	uint FromInt(unsigned int value)
+	{
+		return FromUInt(uint(value));
+	}
+
+
+	/*
+		this method converts 32 bit signed int to this class
+		***this method is created only on a 64bit platform***
+	*/
+	uint FromInt(signed int value)
+	{
+		return FromInt(sint(value));
+	}
+
+
+	/*!
+		an operator= for converting 32 bit unsigned int to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	Big<exp, man> & operator=(unsigned int value)
+	{
+		FromUInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 32 bit unsigned int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	Big(unsigned int value)
+	{
+		FromUInt(value);
+	}
+
+
+	/*!
+		an operator for converting 32 bit signed int to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	Big<exp, man> & operator=(signed int value)
+	{
+		FromInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 32 bit signed int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	Big(signed int value)
+	{
+		FromInt(value);
+	}
+
+#endif
+
+
+private:
+
+	/*!
+		an auxiliary method for converting from UInt and Int
+
+		we assume that there'll never be a carry here
+		(we have an exponent and the value in Big can be bigger than
+		that one from the UInt)
+	*/
+	template<uint int_size>
+	uint FromUIntOrInt(const UInt<int_size> & value, sint compensation)
+	{
+		uint minimum_size = (int_size < man)? int_size : man;
+		exponent          = (sint(int_size)-sint(man)) * sint(TTMATH_BITS_PER_UINT) - compensation;
+
+		// copying the highest words
+		uint i;
+		for(i=1 ; i<=minimum_size ; ++i)
+			mantissa.table[man-i] = value.table[int_size-i];
+
+		// setting the rest of mantissa.table into zero (if some has left)
+		for( ; i<=man ; ++i)
+			mantissa.table[man-i] = 0;
+
+		// the highest bit is either one or zero (when the whole mantissa is zero)
+		// we can only call CorrectZero()
+		CorrectZero();
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		a method for converting from 'UInt<int_size>' to this class
+	*/
+	template<uint int_size>
+	uint FromUInt(UInt<int_size> value)
+	{
+		info = 0;
+		sint compensation = (sint)value.CompensationToLeft();
+	
+	return FromUIntOrInt(value, compensation);
+	}
+
+
+	/*!
+		a method for converting from 'UInt<int_size>' to this class
+	*/
+	template<uint int_size>
+	uint FromInt(const UInt<int_size> & value)
+	{
+		return FromUInt(value);
+	}
+
+		
+	/*!
+		a method for converting from 'Int<int_size>' to this class
+	*/
+	template<uint int_size>
+	uint FromInt(Int<int_size> value)
+	{
+		info = 0;
+		bool is_sign = false;
+
+		if( value.IsSign() )
+		{
+			value.ChangeSign();
+			is_sign = true;
+		}
+		
+		sint compensation = (sint)value.CompensationToLeft();
+		FromUIntOrInt(value, compensation);
+
+		if( is_sign )
+			SetSign();
+
+	return 0;
+	}
+
+
+	/*!
+		an operator= for converting from 'Int<int_size>' to this class
+	*/
+	template<uint int_size>
+	Big<exp,man> & operator=(const Int<int_size> & value)
+	{
+		FromInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting from 'Int<int_size>' to this class
+	*/
+	template<uint int_size>
+	Big(const Int<int_size> & value)
+	{
+		FromInt(value);
+	}
+
+
+	/*!
+		an operator= for converting from 'UInt<int_size>' to this class
+	*/
+	template<uint int_size>
+	Big<exp,man> & operator=(const UInt<int_size> & value)
+	{
+		FromUInt(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting from 'UInt<int_size>' to this class
+	*/
+	template<uint int_size>
+	Big(const UInt<int_size> & value)
+	{
+		FromUInt(value);
+	}
+
+
+	/*!
+		an operator= for converting from 'Big<another_exp, another_man>' to this class
+	*/
+	template<uint another_exp, uint another_man>
+	Big<exp,man> & operator=(const Big<another_exp, another_man> & value)
+	{
+		FromBig(value);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting from 'Big<another_exp, another_man>' to this class
+	*/
+	template<uint another_exp, uint another_man>
+	Big(const Big<another_exp, another_man> & value)
+	{
+		FromBig(value);
+	}
+
+
+	/*!
+		a default constructor
+
+		by default we don't set any of the members to zero
+		only NaN flag is set
+
+		if you want the mantissa and exponent to be set to zero 
+		define TTMATH_BIG_DEFAULT_CLEAR macro
+		(useful for debug purposes)
+	*/
+	Big()
+	{
+		#ifdef TTMATH_BIG_DEFAULT_CLEAR
+
+			SetZeroNan();
+
+		#else
+
+			info = TTMATH_BIG_NAN;
+			// we're directly setting 'info' (instead of calling SetNan())
+			// in order to get rid of a warning saying that 'info' is uninitialized
+
+		#endif
+	}
+
+
+	/*!
+		a destructor
+	*/
+	~Big()
+	{
+	}
+
+
+	/*!
+		the default assignment operator
+	*/
+	Big<exp,man> & operator=(const Big<exp,man> & value)
+	{
+		info     = value.info;
+		exponent = value.exponent;
+		mantissa = value.mantissa;
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for copying from another object of this class
+	*/
+	
+	Big(const Big<exp,man> & value)
+	{
+		operator=(value);
+	}
+	
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+
+		output:
+			return value:
+			0 - ok and 'result' will be an object of type std::string (or std::wstring) which holds the value
+			1 - if there is a carry (it shoudn't be in a normal situation - if it is that means there
+			    is somewhere an error in the library)
+	*/
+	uint ToString(	std::string & result,
+					uint base         = 10,
+					bool scient       = false,
+					sint scient_from  = 15,
+					sint round        = -1,
+					bool trim_zeroes  = true,
+					char comma     = '.' ) const
+	{
+		Conv conv;
+
+		conv.base         = base;
+		conv.scient       = scient;
+		conv.scient_from  = scient_from;
+		conv.round        = round;
+		conv.trim_zeroes  = trim_zeroes;
+		conv.comma        = static_cast<uint>(comma);
+
+	return ToStringBase<std::string, char>(result, conv);
+	}
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	uint ToString(std::string & result, const Conv & conv) const
+	{
+		return ToStringBase<std::string, char>(result, conv);
+	}
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	std::string ToString(const Conv & conv) const
+	{
+		std::string result;
+		ToStringBase<std::string, char>(result, conv);
+		
+	return result;
+	}
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	std::string ToString(uint base = 10) const
+	{
+		Conv conv;
+		conv.base = base;
+
+	return ToString(conv);
+	}
+
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	uint ToString(	std::wstring & result,
+					uint base         = 10,
+					bool scient       = false,
+					sint scient_from  = 15,
+					sint round        = -1,
+					bool trim_zeroes  = true,
+					wchar_t comma     = '.' ) const
+	{
+		Conv conv;
+
+		conv.base         = base;
+		conv.scient       = scient;
+		conv.scient_from  = scient_from;
+		conv.round        = round;
+		conv.trim_zeroes  = trim_zeroes;
+		conv.comma        = static_cast<uint>(comma);
+
+	return ToStringBase<std::wstring, wchar_t>(result, conv);
+	}
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	uint ToString(std::wstring & result, const Conv & conv) const
+	{
+		return ToStringBase<std::wstring, wchar_t>(result, conv);
+	}
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	std::wstring ToWString(const Conv & conv) const
+	{
+		std::wstring result;
+		ToStringBase<std::wstring, wchar_t>(result, conv);
+		
+	return result;
+	}
+
+
+	/*!
+		a method for converting into a string
+		struct Conv is defined in ttmathtypes.h, look there for more information about parameters
+	*/
+	std::wstring ToWString(uint base = 10) const
+	{
+		Conv conv;
+		conv.base = base;
+
+	return ToWString(conv);
+	}
+
+#endif
+
+
+
+private:
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	uint ToStringBase(string_type & result, const Conv & conv) const
+	{
+		static char error_overflow_msg[] = "overflow";
+		static char error_nan_msg[]      = "NaN";
+		result.erase();
+
+		if( IsNan() )
+		{
+			Misc::AssignString(result, error_nan_msg);
+			return 0;
+		}
+
+		if( conv.base<2 || conv.base>16 )
+		{
+			Misc::AssignString(result, error_overflow_msg);
+			return 1;
+		}
+	
+		if( IsZero() )
+		{
+			result = '0';
+
+		return 0;
+		}
+
+		/*
+			since 'base' is greater or equal 2 that 'new_exp' of type 'Int<exp>' should
+			hold the new value of exponent but we're using 'Int<exp+1>' because
+			if the value for example would be 'max()' then we couldn't show it
+
+				max() ->  11111111 * 2 ^ 11111111111  (bin)(the mantissa and exponent have all bits set)
+				if we were using 'Int<exp>' we couldn't show it in this format:
+				1,1111111 * 2 ^ 11111111111  (bin)
+				because we have to add something to the mantissa and because 
+				mantissa is full we can't do it and it'll be a carry
+				(look at ToString_SetCommaAndExponent(...))
+
+				when the base would be greater than two (for example 10) 
+				we could use 'Int<exp>' here
+		*/
+		Int<exp+1> new_exp;
+
+		if( ToString_CreateNewMantissaAndExponent<string_type, char_type>(result, conv, new_exp) )
+		{
+			Misc::AssignString(result, error_overflow_msg);
+			return 1;
+		}
+
+			
+		if( ToString_SetCommaAndExponent<string_type, char_type>(result, conv, new_exp) )
+		{
+			Misc::AssignString(result, error_overflow_msg);
+			return 1;
+		}
+
+		if( IsSign() )
+			result.insert(result.begin(), '-');
+
+
+	// converted successfully
+	return 0;
+	}
+
+
+
+	/*!
+		in the method 'ToString_CreateNewMantissaAndExponent()' we're using 
+		type 'Big<exp+1,man>' and we should have the ability to use some
+		necessary methods from that class (methods which are private here)
+	*/
+	friend class Big<exp-1,man>;
+
+
+	/*!
+		an auxiliary method for converting into the string
+
+		input:
+			base - the base in range <2,16>
+
+		output:
+			return values:
+				0 - ok
+				1 - if there was a carry
+			new_man - the new mantissa for 'base'
+			new_exp - the new exponent for 'base'
+
+		mathematic part:
+
+		the value is stored as:
+			value = mantissa * 2^exponent
+		we want to show 'value' as:
+			value = new_man * base^new_exp
+
+		then 'new_man' we'll print using the standard method from UInt<> type for printing
+		and 'new_exp' is the offset of the comma operator in a system of a base 'base'
+
+		value = mantissa * 2^exponent
+		value = mantissa * 2^exponent * (base^new_exp / base^new_exp)
+		value = mantissa * (2^exponent / base^new_exp) * base^new_exp
+
+		look at the part (2^exponent / base^new_exp), there'll be good if we take
+		a 'new_exp' equal that value when the (2^exponent / base^new_exp) will be equal one
+
+		on account of the 'base' is not as power of 2 (can be from 2 to 16),
+		this formula will not be true for integer 'new_exp' then in our case we take 
+		'base^new_exp' _greater_ than '2^exponent' 
+
+		if 'base^new_exp' were smaller than '2^exponent' the new mantissa could be
+		greater than the max value of the container UInt<man>
+
+		value = mantissa * (2^exponent / base^new_exp) * base^new_exp
+		  let M = mantissa * (2^exponent / base^new_exp) then
+		value = M * base^new_exp
+
+		in our calculation we treat M as floating value showing it as:
+			M = mm * 2^ee where ee will be <= 0 
+
+		next we'll move all bits of mm into the right when ee is equal zero
+		abs(ee) must not be too big that only few bits from mm we can leave
+
+		then we'll have:
+			M = mmm * 2^0
+		'mmm' is the new_man which we're looking for
+
+
+		new_exp we calculate in this way:
+			2^exponent <= base^new_exp
+			new_exp >= log base (2^exponent)   <- logarithm with the base 'base' from (2^exponent)
+			
+			but we need new_exp as integer then we test:
+			if new_exp is greater than zero and with fraction we add one to new_exp
+			  new_exp = new_exp + 1    (if new_exp>0 and with fraction)
+			and at the end we take the integer part:
+			  new_exp = int(new_exp)
+	*/
+	template<class string_type, class char_type>
+	uint ToString_CreateNewMantissaAndExponent(	string_type & new_man, const Conv & conv,
+												Int<exp+1> & new_exp) const
+	{
+	uint c = 0;
+
+		if( conv.base<2 || conv.base>16 )
+			return 1;
+	
+		// special method for base equal 2
+		if( conv.base == 2 )
+			return ToString_CreateNewMantissaAndExponent_Base2(new_man, new_exp);
+
+		// special method for base equal 4
+		if( conv.base == 4 )
+			return ToString_CreateNewMantissaAndExponent_BasePow2(new_man, new_exp, 2);
+
+		// special method for base equal 8
+		if( conv.base == 8 )
+			return ToString_CreateNewMantissaAndExponent_BasePow2(new_man, new_exp, 3);
+
+		// special method for base equal 16
+		if( conv.base == 16 )
+			return ToString_CreateNewMantissaAndExponent_BasePow2(new_man, new_exp, 4);
+
+
+		// this = mantissa * 2^exponent
+
+		// temp = +1 * 2^exponent  
+		// we're using a bigger type than 'big<exp,man>' (look below)
+		Big<exp+1,man> temp;
+		temp.info = 0;
+		temp.exponent = exponent;
+		temp.mantissa.SetOne();
+		c += temp.Standardizing();
+
+		// new_exp_ = log base (2^exponent)   
+		// if new_exp_ is positive and with fraction then we add one 
+		Big<exp+1,man> new_exp_;
+		c += new_exp_.ToString_Log(temp, conv.base); // this logarithm isn't very complicated
+
+		// rounding up to the nearest integer
+		if( !new_exp_.IsInteger() )
+		{
+			if( !new_exp_.IsSign() )
+				c += new_exp_.AddOne(); // new_exp_ > 0 and with fraction
+
+			new_exp_.SkipFraction();
+		}
+
+		if( ToString_CreateNewMantissaTryExponent<string_type, char_type>(new_man, conv, new_exp_, new_exp) )
+		{
+			// in very rare cases there can be an overflow from ToString_CreateNewMantissaTryExponent
+			// it means that new_exp_ was too small (the problem comes from floating point numbers precision)
+			// so we increse new_exp_ and try again
+			new_exp_.AddOne();
+			c += ToString_CreateNewMantissaTryExponent<string_type, char_type>(new_man, conv, new_exp_, new_exp);
+		}
+
+	return (c==0)? 0 : 1;
+	}
+
+
+
+	/*!
+		an auxiliary method for converting into the string
+
+		trying to calculate new_man for given exponent (new_exp_)
+		if there is a carry it can mean that new_exp_ is too small
+	*/
+	template<class string_type, class char_type>
+	uint ToString_CreateNewMantissaTryExponent(	string_type & new_man, const Conv & conv,
+												const Big<exp+1,man> & new_exp_, Int<exp+1> & new_exp) const
+	{
+	uint c = 0;
+
+		// because 'base^new_exp' is >= '2^exponent' then 
+		// because base is >= 2 then we've got:
+		// 'new_exp_' must be smaller or equal 'new_exp'
+		// and we can pass it into the Int<exp> type
+		// (in fact we're using a greater type then it'll be ok)
+		c += new_exp_.ToInt(new_exp);
+
+		// base_ = base
+		Big<exp+1,man> base_(conv.base);
+
+		// base_ = base_ ^ new_exp_
+		c += base_.Pow( new_exp_ ); // use new_exp_ so Pow(Big<> &) version will be used
+		// if we hadn't used a bigger type than 'Big<exp,man>' then the result
+		// of this formula 'Pow(...)' would have been with an overflow
+
+		// temp = mantissa * 2^exponent / base_^new_exp_
+		Big<exp+1,man> temp;
+		temp.info = 0;
+		temp.mantissa = mantissa;
+		temp.exponent = exponent;
+		c += temp.Div(base_);
+
+		// moving all bits of the mantissa into the right 
+		// (how many times to move depend on the exponent)
+		c += temp.ToString_MoveMantissaIntoRight();
+
+		// because we took 'new_exp' as small as it was
+		// possible ([log base (2^exponent)] + 1) that after the division 
+		// (temp.Div( base_ )) the value of exponent should be equal zero or 
+		// minimum smaller than zero then we've got the mantissa which has 
+		// maximum valid bits
+		temp.mantissa.ToString(new_man, conv.base);
+
+		if( IsInteger() )
+		{
+			// making sure the new mantissa will be without fraction (integer)
+			ToString_CheckMantissaInteger<string_type, char_type>(new_man, new_exp);
+		}
+		else
+		if( conv.base_round )
+		{
+			c += ToString_BaseRound<string_type, char_type>(new_man, conv, new_exp);
+		}
+
+	return (c==0)? 0 : 1;
+	}
+
+
+	/*!
+		this method calculates the logarithm
+		it is used by ToString_CreateNewMantissaAndExponent() method
+
+		it's not too complicated
+		because x=+1*2^exponent (mantissa is one) then during the calculation
+		the Ln(x) will not be making the long formula from LnSurrounding1()
+		and only we have to calculate 'Ln(base)' but it'll be calculated
+		only once, the next time we will get it from the 'history'
+
+        x is greater than 0
+		base is in <2,16> range
+	*/
+	uint ToString_Log(const Big<exp,man> & x, uint base)
+	{
+		TTMATH_REFERENCE_ASSERT( x )
+		TTMATH_ASSERT( base>=2 && base<=16 )
+
+		Big<exp,man> temp;
+		temp.SetOne();
+
+		if( x == temp )
+		{
+			// log(1) is 0
+			SetZero();
+
+		return 0;
+		}
+
+		// there can be only a carry
+		// because the 'x' is in '1+2*exponent' form then 
+		// the long formula from LnSurrounding1() will not be calculated
+		// (LnSurrounding1() will return one immediately)
+		uint c = Ln(x);
+
+		if( base==10 && man<=TTMATH_BUILTIN_VARIABLES_SIZE )
+		{
+			// for the base equal 10 we're using SetLn10() instead of calculating it
+			// (only if we have the constant sufficient big)
+			temp.SetLn10();
+		}
+		else
+		{
+			c += ToString_LogBase(base, temp);
+		}
+
+		c += Div( temp );
+
+	return (c==0)? 0 : 1;
+	}
+
+
+#ifndef TTMATH_MULTITHREADS
+
+	/*!
+		this method calculates the logarithm of 'base'
+		it's used in single thread environment
+	*/
+	uint ToString_LogBase(uint base, Big<exp,man> & result)
+	{
+		TTMATH_ASSERT( base>=2 && base<=16 )
+
+		// this guardians are initialized before the program runs (static POD types)
+		static int guardians[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+		static Big<exp,man> log_history[15];
+		uint index = base - 2;
+		uint c = 0;
+	
+		if( guardians[index] == 0 )
+		{
+			Big<exp,man> base_(base);
+			c += log_history[index].Ln(base_);
+			guardians[index] = 1;
+		}
+
+		result = log_history[index];
+
+	return (c==0)? 0 : 1;
+	}
+
+#else
+
+	/*!
+		this method calculates the logarithm of 'base'
+		it's used in multi-thread environment
+	*/
+	uint ToString_LogBase(uint base, Big<exp,man> & result)
+	{
+		TTMATH_ASSERT( base>=2 && base<=16 )
+
+		// this guardians are initialized before the program runs (static POD types)
+		volatile static sig_atomic_t guardians[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+		static Big<exp,man> * plog_history;
+		uint index = base - 2;
+		uint c = 0;
+	
+		// double-checked locking
+		if( guardians[index] == 0 )
+		{
+			ThreadLock thread_lock;
+
+			// locking
+			if( thread_lock.Lock() )
+			{
+				static Big<exp,man> log_history[15];
+
+				if( guardians[index] == 0 )
+				{
+					plog_history = log_history;
+				
+					Big<exp,man> base_(base);
+					c += log_history[index].Ln(base_);
+					guardians[index] = 1;
+				}
+			}
+			else
+			{
+				// there was a problem with locking, we store the result directly in 'result' object
+				Big<exp,man> base_(base);
+				c += result.Ln(base_);
+				
+			return (c==0)? 0 : 1;
+			}
+
+			// automatically unlocking
+		}
+
+		result = plog_history[index];
+
+	return (c==0)? 0 : 1;
+	}
+
+#endif
+
+	/*!
+		an auxiliary method for converting into the string (private)
+
+		this method moving all bits from mantissa into the right side
+		the exponent tell us how many times moving (the exponent is <=0)
+	*/
+	uint ToString_MoveMantissaIntoRight()
+	{
+		if( exponent.IsZero() )
+			return 0;
+		
+		// exponent can't be greater than zero
+		// because we would cat the highest bits of the mantissa
+		if( !exponent.IsSign() )
+			return 1;
+
+
+		if( exponent <= -sint(man*TTMATH_BITS_PER_UINT) )
+			// if 'exponent' is <= than '-sint(man*TTMATH_BITS_PER_UINT)'
+			// it means that we must cut the whole mantissa
+			// (there'll not be any of the valid bits)
+			return 1;
+
+		// e will be from (-man*TTMATH_BITS_PER_UINT, 0>
+		sint e = -( exponent.ToInt() );
+		mantissa.Rcr(e,0);
+
+	return 0;
+	}
+
+
+	/*!
+		a special method similar to the 'ToString_CreateNewMantissaAndExponent'
+		when the 'base' is equal 2
+
+		we use it because if base is equal 2 we don't have to make those
+		complicated calculations and the output is directly from the source
+		(there will not be any small distortions)
+	*/
+	template<class string_type>
+	uint ToString_CreateNewMantissaAndExponent_Base2(	string_type & new_man,
+														Int<exp+1> & new_exp     ) const
+	{
+		for( sint i=man-1 ; i>=0 ; --i )
+		{
+			uint value = mantissa.table[i]; 
+
+			for( uint bit=0 ; bit<TTMATH_BITS_PER_UINT ; ++bit )
+			{
+				if( (value & TTMATH_UINT_HIGHEST_BIT) != 0 )
+					new_man += '1';
+				else
+					new_man += '0';
+
+				value <<= 1;
+			}
+		}
+
+		new_exp = exponent;
+
+	return 0;
+	}
+
+
+	/*!
+		a special method used to calculate the new mantissa and exponent
+		when the 'base' is equal 4, 8 or 16
+
+		when base is 4 then bits is 2
+		when base is 8 then bits is 3
+		when base is 16 then bits is 4
+		(and the algorithm can be used with a base greater than 16)
+	*/
+	template<class string_type>
+	uint ToString_CreateNewMantissaAndExponent_BasePow2(	string_type & new_man,
+															Int<exp+1> & new_exp,
+															uint bits) const
+	{
+		sint move;							// how many times move the mantissa
+		UInt<man+1> man_temp(mantissa);		// man+1 for moving
+		new_exp = exponent;
+		new_exp.DivInt((sint)bits, move);
+
+		if( move != 0 )
+		{
+			// we're moving the man_temp to left-hand side
+			if( move < 0 )
+			{
+				move = sint(bits) + move;
+				new_exp.SubOne();			// when move is < than 0 then new_exp is < 0 too
+			}
+
+			man_temp.Rcl(move);
+		}
+
+
+		if( bits == 3 )
+		{
+			// base 8
+			// now 'move' is greater than or equal 0
+			uint len = man*TTMATH_BITS_PER_UINT + move;
+			return ToString_CreateNewMantissaAndExponent_Base8(new_man, man_temp, len, bits);
+		}
+		else
+		{
+			// base 4 or 16
+			return ToString_CreateNewMantissaAndExponent_Base4or16(new_man, man_temp, bits);
+		}
+	}
+
+
+	/*!
+		a special method used to calculate the new mantissa
+		when the 'base' is equal 8
+
+		bits is always 3
+
+		we can use this algorithm when the base is 4 or 16 too
+		but we have a faster method ToString_CreateNewMantissaAndExponent_Base4or16()
+	*/
+	template<class string_type>
+	uint ToString_CreateNewMantissaAndExponent_Base8(	string_type & new_man,
+														UInt<man+1> & man_temp,
+														uint len,
+														uint bits) const
+	{
+		uint shift = TTMATH_BITS_PER_UINT - bits;
+		uint mask  = TTMATH_UINT_MAX_VALUE >> shift;
+		uint i;
+
+		for( i=0 ; i<len ; i+=bits )
+		{
+			uint digit = man_temp.table[0] & mask;
+			new_man.insert(new_man.begin(), static_cast<char>(Misc::DigitToChar(digit)));
+
+			man_temp.Rcr(bits);
+		}
+
+		TTMATH_ASSERT( man_temp.IsZero() )
+
+	return 0;
+	}
+
+
+	/*!
+		a special method used to calculate the new mantissa
+		when the 'base' is equal 4 or 16
+
+		when the base is equal 4 or 16 the bits is 2 or 4
+		and because TTMATH_BITS_PER_UINT (32 or 64) is divisible by 2 (or 4)
+		then we can get digits from the end of our mantissa
+	*/
+	template<class string_type>
+	uint ToString_CreateNewMantissaAndExponent_Base4or16(	string_type & new_man,
+															UInt<man+1> & man_temp,
+															uint bits) const
+	{
+		TTMATH_ASSERT( TTMATH_BITS_PER_UINT % 2 == 0 )
+		TTMATH_ASSERT( TTMATH_BITS_PER_UINT % 4 == 0 )
+
+		uint shift = TTMATH_BITS_PER_UINT - bits;
+		uint mask  = TTMATH_UINT_MAX_VALUE << shift;
+		uint digit;
+
+		 // table[man] - last word - is different from zero if we moved man_temp
+		digit = man_temp.table[man];
+
+		if( digit != 0 )
+			new_man += static_cast<char>(Misc::DigitToChar(digit));
+
+
+		for( int i=man-1 ; i>=0 ; --i )
+		{
+			uint shift_local = shift;
+			uint mask_local  = mask;
+
+			while( mask_local != 0 )
+			{
+				digit = man_temp.table[i] & mask_local;
+
+				if( shift_local != 0 )
+					digit = digit >> shift_local;
+
+				new_man    += static_cast<char>(Misc::DigitToChar(digit));
+				mask_local  = mask_local >> bits;
+				shift_local = shift_local - bits;
+			}
+		}
+
+	return 0;
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	bool ToString_RoundMantissaWouldBeInteger(string_type & new_man, const Conv & conv, Int<exp+1> & new_exp) const
+	{
+		// if new_exp is greater or equal to zero then we have an integer value,
+		// if new_exp is equal -1 then we have only one digit after the comma
+		// and after rounding it would be an integer value
+		if( !new_exp.IsSign() || new_exp == -1 )
+			return true;
+
+		if( new_man.size() >= TTMATH_UINT_HIGHEST_BIT || new_man.size() < 2 )
+			return true; // oops, the mantissa is too large for calculating (or too small) - we are not doing the base rounding
+		
+		uint i = 0;
+		char_type digit;
+
+		if( new_exp >= -sint(new_man.size()) )
+		{
+			uint new_exp_abs = -new_exp.ToInt();
+			i = new_man.size() - new_exp_abs; // start from the first digit after the comma operator
+		}
+		
+		if( Misc::CharToDigit(new_man[new_man.size()-1]) >= conv.base/2 )
+		{
+			if( new_exp < -sint(new_man.size()) )
+			{
+				// there are some zeroes after the comma operator
+				// (between the comma and the first digit from the mantissa)
+				// and the result value will never be an integer
+				return false;
+			}
+
+			digit = static_cast<char_type>( Misc::DigitToChar(conv.base-1) );
+		}
+		else
+		{
+			digit = '0';
+		}
+
+		for( ; i < new_man.size()-1 ; ++i)
+			if( new_man[i] != digit )
+				return false; // it will not be an integer
+
+	return true; // it will be integer after rounding
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+		(when this is integer)
+
+		after floating point calculating the new mantissa can consist of some fraction
+		so if our value is integer we should check the new mantissa
+		(after the decimal point there should be only zeroes)
+		
+		often this is a last digit different from zero
+		ToString_BaseRound would not get rid of it because the method make a test against 
+		an integer value (ToString_RoundMantissaWouldBeInteger) and returns immediately
+	*/
+	template<class string_type, class char_type>
+	void ToString_CheckMantissaInteger(string_type & new_man, const Int<exp+1> & new_exp) const
+	{
+		if( !new_exp.IsSign() )
+			return; // return if new_exp >= 0
+		
+		uint i = 0;
+		uint man_size = new_man.size();
+
+		if( man_size >= TTMATH_UINT_HIGHEST_BIT )
+			return; // ops, the mantissa is too long
+
+		sint sman_size = -sint(man_size);
+
+		if( new_exp >= sman_size )
+		{
+			sint e = new_exp.ToInt();
+			e = -e;
+			// now e means how many last digits from the mantissa should be equal zero
+
+			i = man_size - uint(e);
+		}
+
+		for( ; i<man_size ; ++i)
+			new_man[i] = '0';
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+
+		this method is used for base!=2, base!=4, base!=8 and base!=16
+		we do the rounding when the value has fraction (is not an integer)
+	*/
+	template<class string_type, class char_type>
+	uint ToString_BaseRound(string_type & new_man, const Conv & conv, Int<exp+1> & new_exp) const
+	{
+		// we must have minimum two characters
+		if( new_man.size() < 2 )
+			return 0;
+
+		// assert that there will not be an integer after rounding
+		if( ToString_RoundMantissaWouldBeInteger<string_type, char_type>(new_man, conv, new_exp) )
+			return 0;
+
+		typename string_type::size_type i = new_man.length() - 1;
+
+		// we're erasing the last character
+		uint digit = Misc::CharToDigit( new_man[i] );
+		new_man.erase(i, 1);
+		uint c = new_exp.AddOne();
+
+		// if the last character is greater or equal 'base/2'
+		// we are adding one into the new mantissa
+		if( digit >= conv.base / 2 )
+			ToString_RoundMantissa_AddOneIntoMantissa<string_type, char_type>(new_man, conv);
+
+	return c;
+	}
+	
+
+	/*!
+		an auxiliary method for converting into the string
+
+		this method addes one into the new mantissa
+	*/
+	template<class string_type, class char_type>
+	void ToString_RoundMantissa_AddOneIntoMantissa(string_type & new_man, const Conv & conv) const
+	{
+		if( new_man.empty() )
+			return;
+
+		sint i = sint( new_man.length() ) - 1;
+		bool was_carry = true;
+
+		for( ; i>=0 && was_carry ; --i )
+		{
+			// we can have the comma as well because
+			// we're using this method later in ToString_CorrectDigitsAfterComma_Round()
+			// (we're only ignoring it)
+			if( new_man[i] == static_cast<char_type>(conv.comma) )
+				continue;
+
+			// we're adding one
+			uint digit = Misc::CharToDigit( new_man[i] ) + 1;
+
+			if( digit == conv.base )
+				digit = 0;
+			else
+				was_carry = false;
+
+			new_man[i] = static_cast<char_type>( Misc::DigitToChar(digit) );
+		}
+
+		if( i<0 && was_carry )
+			new_man.insert( new_man.begin() , '1' );
+	}
+
+
+
+	/*!
+		an auxiliary method for converting into the string
+
+		this method sets the comma operator and/or puts the exponent
+		into the string
+	*/
+	template<class string_type, class char_type>
+	uint ToString_SetCommaAndExponent(string_type & new_man, const Conv & conv, Int<exp+1> & new_exp) const
+	{
+	uint carry = 0;
+
+		if( new_man.empty() )
+			return carry;
+
+		Int<exp+1> scientific_exp( new_exp );
+
+		// 'new_exp' depends on the 'new_man' which is stored like this e.g:
+		//  32342343234 (the comma is at the end)
+		// we'd like to show it in this way:
+		//  3.2342343234 (the 'scientific_exp' is connected with this example)
+
+		sint offset = sint( new_man.length() ) - 1;
+		carry += scientific_exp.Add( offset );
+		// there shouldn't have been a carry because we're using
+		// a greater type -- 'Int<exp+1>' instead of 'Int<exp>'
+
+		bool print_scientific = conv.scient;
+
+		if( !print_scientific )
+		{
+			if( scientific_exp > conv.scient_from || scientific_exp < -sint(conv.scient_from) )
+				print_scientific = true;
+		}
+
+		if( !print_scientific )
+			ToString_SetCommaAndExponent_Normal<string_type, char_type>(new_man, conv, new_exp);
+		else
+			// we're passing the 'scientific_exp' instead of 'new_exp' here
+			ToString_SetCommaAndExponent_Scientific<string_type, char_type>(new_man, conv, scientific_exp);
+
+	return (carry==0)? 0 : 1;
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_SetCommaAndExponent_Normal(string_type & new_man,	const Conv & conv, Int<exp+1> & new_exp ) const
+	{
+		if( !new_exp.IsSign() ) // it means: if( new_exp >= 0 )
+			ToString_SetCommaAndExponent_Normal_AddingZero<string_type, char_type>(new_man, new_exp);
+		else
+			ToString_SetCommaAndExponent_Normal_SetCommaInside<string_type, char_type>(new_man, conv, new_exp);
+
+
+		ToString_Group_man<string_type, char_type>(new_man, conv);
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_SetCommaAndExponent_Normal_AddingZero(string_type & new_man,
+														Int<exp+1> & new_exp) const
+	{
+		// we're adding zero characters at the end
+		// 'i' will be smaller than 'when_scientific' (or equal)
+		uint i = new_exp.ToInt();
+		
+		if( new_man.length() + i > new_man.capacity() )
+			// about 6 characters more (we'll need it for the comma or something)
+			new_man.reserve( new_man.length() + i + 6 );
+		
+		for( ; i>0 ; --i)
+			new_man += '0';
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_SetCommaAndExponent_Normal_SetCommaInside(
+															string_type & new_man,
+															const Conv & conv,
+															Int<exp+1> & new_exp ) const
+	{
+		// new_exp is < 0 
+
+		sint new_man_len = sint(new_man.length()); // 'new_man_len' with a sign
+		sint e = -( new_exp.ToInt() ); // 'e' will be positive
+
+		if( new_exp > -new_man_len )
+		{
+			// we're setting the comma within the mantissa
+			
+			sint index = new_man_len - e;
+			new_man.insert( new_man.begin() + index, static_cast<char_type>(conv.comma));
+		}
+		else
+		{
+			// we're adding zero characters before the mantissa
+
+			uint how_many = e - new_man_len;
+			string_type man_temp(how_many+1, '0');
+
+			man_temp.insert( man_temp.begin()+1, static_cast<char_type>(conv.comma));
+			new_man.insert(0, man_temp);
+		}
+
+		ToString_CorrectDigitsAfterComma<string_type, char_type>(new_man, conv);
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_SetCommaAndExponent_Scientific(	string_type & new_man,
+													const Conv & conv,
+													Int<exp+1> & scientific_exp ) const
+	{
+		if( new_man.empty() )
+			return;
+		
+		if( new_man.size() > 1 )
+		{
+			new_man.insert( new_man.begin()+1, static_cast<char_type>(conv.comma) );
+			ToString_CorrectDigitsAfterComma<string_type, char_type>(new_man, conv);
+		}
+
+		ToString_Group_man<string_type, char_type>(new_man, conv);
+
+		if( conv.base == 10 )
+		{
+			new_man += 'e';
+
+			if( !scientific_exp.IsSign() )
+				new_man += '+';
+		}
+		else
+		{
+			// the 10 here is meant as the base 'base'
+			// (no matter which 'base' we're using there'll always be 10 here)
+			Misc::AddString(new_man, "*10^");
+		}
+
+		string_type temp_exp;
+		scientific_exp.ToString( temp_exp, conv.base );
+
+		new_man += temp_exp;
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_Group_man(string_type & new_man, const Conv & conv) const
+	{
+		typedef typename string_type::size_type StrSize;
+
+		if( conv.group == 0 )
+			return;
+
+		// first we're looking for the comma operator
+		StrSize index = new_man.find(static_cast<char_type>(conv.comma), 0);
+
+		if( index == string_type::npos )
+			index = new_man.size();	
+
+		ToString_Group_man_before_comma<string_type, char_type>(new_man, conv, index);
+		ToString_Group_man_after_comma<string_type, char_type>(new_man, conv, index+1);
+	}
+
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_Group_man_before_comma(	string_type & new_man, const Conv & conv,
+											typename string_type::size_type & index) const
+	{
+	typedef typename string_type::size_type StrSize;
+
+		uint group = 0;
+		StrSize i = index;
+		uint group_digits = conv.group_digits;
+
+		if( group_digits < 1 )
+			group_digits = 1;
+
+		// adding group characters before the comma operator
+		// i>0 because on the first position we don't put any additional grouping characters
+		for( ; i>0 ; --i, ++group)
+		{
+			if( group >= group_digits )
+			{
+				group = 0;
+				new_man.insert(i, 1, static_cast<char_type>(conv.group));
+				++index;
+			}
+		}
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_Group_man_after_comma(string_type & new_man, const Conv & conv,
+										typename string_type::size_type index) const
+	{
+		uint group = 0;
+		uint group_digits = conv.group_digits;
+
+		if( group_digits < 1 )
+			group_digits = 1;
+
+		for( ; index<new_man.size() ; ++index, ++group)
+		{
+			if( group >= group_digits )
+			{
+				group = 0;
+				new_man.insert(index, 1, static_cast<char_type>(conv.group));
+				++index;
+			}
+		}
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_CorrectDigitsAfterComma(	string_type & new_man,
+											const Conv & conv ) const
+	{
+		if( conv.round >= 0 )
+			ToString_CorrectDigitsAfterComma_Round<string_type, char_type>(new_man, conv);
+
+		if( conv.trim_zeroes )
+			ToString_CorrectDigitsAfterComma_CutOffZeroCharacters<string_type, char_type>(new_man, conv);
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_CorrectDigitsAfterComma_CutOffZeroCharacters(
+												string_type & new_man,
+												const Conv & conv) const
+	{
+		// minimum two characters
+		if( new_man.length() < 2 )
+			return;
+
+		// we're looking for the index of the last character which is not zero
+		uint i = uint( new_man.length() ) - 1;
+		for( ; i>0 && new_man[i]=='0' ; --i );
+
+		// if there is another character than zero at the end
+		// we're finishing
+		if( i == new_man.length() - 1 )
+			return;
+
+		// we must have a comma 
+		// (the comma can be removed by ToString_CorrectDigitsAfterComma_Round
+		// which is called before)
+		if( new_man.find_last_of(static_cast<char_type>(conv.comma), i) == string_type::npos )
+			return;
+
+		// if directly before the first zero is the comma operator
+		// we're cutting it as well
+		if( i>0 && new_man[i]==static_cast<char_type>(conv.comma) )
+			--i;
+
+		new_man.erase(i+1, new_man.length()-i-1);
+	}
+
+
+	/*!
+		an auxiliary method for converting into the string
+	*/
+	template<class string_type, class char_type>
+	void ToString_CorrectDigitsAfterComma_Round(
+											string_type & new_man,
+											const Conv & conv ) const
+	{
+		typedef typename string_type::size_type StrSize;
+
+		// first we're looking for the comma operator
+		StrSize index = new_man.find(static_cast<char_type>(conv.comma), 0);
+
+		if( index == string_type::npos )
+			// nothing was found (actually there can't be this situation)
+			return;
+
+		// we're calculating how many digits there are at the end (after the comma)
+		// 'after_comma' will be greater than zero because at the end
+		// we have at least one digit
+		StrSize after_comma = new_man.length() - index - 1;
+
+		// if 'max_digit_after_comma' is greater than 'after_comma' (or equal)
+		// we don't have anything for cutting
+		if( static_cast<StrSize>(conv.round) >= after_comma )
+			return;
+
+		uint last_digit = Misc::CharToDigit( new_man[ index + conv.round + 1 ], conv.base );
+
+		// we're cutting the rest of the string
+		new_man.erase(index + conv.round + 1, after_comma - conv.round);
+
+		if( conv.round == 0 )
+		{
+			// we're cutting the comma operator as well
+			// (it's not needed now because we've cut the whole rest after the comma)
+			new_man.erase(index, 1);
+		}
+
+		if( last_digit >= conv.base / 2 )
+			// we must round here
+			ToString_RoundMantissa_AddOneIntoMantissa<string_type, char_type>(new_man, conv);
+	}
+
+
+
+public:
+
+	/*!
+		a method for converting a string into its value
+
+		it returns 1 if the value is too big -- we cannot pass it into the range
+		of our class Big<exp,man> (or if the base is incorrect)
+
+		that means only digits before the comma operator can make this value too big, 
+		all digits after the comma we can ignore
+
+		'source' - pointer to the string for parsing
+
+		if 'after_source' is set that when this method finishes
+		it sets the pointer to the new first character after parsed value
+
+		'value_read' - if the pointer is provided that means the value_read will be true
+		only when a value has been actually read, there can be situation where only such
+		a string '-' or '+' will be parsed -- 'after_source' will be different from 'source' but
+		no value has been read (there are no digits)
+		on other words if 'value_read' is true -- there is at least one digit in the string
+	*/
+	uint FromString(const char * source, uint base = 10, const char ** after_source = 0, bool * value_read = 0)
+	{
+		Conv conv;
+		conv.base = base;
+
+		return FromStringBase(source, conv, after_source, value_read);
+	}
+
+
+	/*!
+		a method for converting a string into its value
+	*/
+	uint FromString(const char * source, const Conv & conv, const char ** after_source = 0, bool * value_read = 0)
+	{
+		return FromStringBase(source, conv, after_source, value_read);
+	}
+
+
+	/*!
+		a method for converting a string into its value		
+	*/
+	uint FromString(const std::string & string, uint base = 10, const char ** after_source = 0, bool * value_read = 0)
+	{
+		return FromString(string.c_str(), base, after_source, value_read);
+	}
+
+
+	/*!
+		a method for converting a string into its value		
+	*/
+	uint FromString(const std::string & string, const Conv & conv, const char ** after_source = 0, bool * value_read = 0)
+	{
+		return FromString(string.c_str(), conv, after_source, value_read);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		a method for converting a string into its value
+	*/
+	uint FromString(const wchar_t * source, uint base = 10, const wchar_t ** after_source = 0, bool * value_read = 0)
+	{
+		Conv conv;
+		conv.base = base;
+
+		return FromStringBase(source, conv, after_source, value_read);
+	}
+
+
+	/*!
+		a method for converting a string into its value
+	*/
+	uint FromString(const wchar_t * source, const Conv & conv, const wchar_t ** after_source = 0, bool * value_read = 0)
+	{
+		return FromStringBase(source, conv, after_source, value_read);
+	}
+
+
+	/*!
+		a method for converting a string into its value		
+	*/
+	uint FromString(const std::wstring & string, uint base = 10, const wchar_t ** after_source = 0, bool * value_read = 0)
+	{
+		return FromString(string.c_str(), base, after_source, value_read);
+	}
+
+
+	/*!
+		a method for converting a string into its value		
+	*/
+	uint FromString(const std::wstring & string, const Conv & conv, const wchar_t ** after_source = 0, bool * value_read = 0)
+	{
+		return FromString(string.c_str(), conv, after_source, value_read);
+	}
+
+#endif
+
+
+private:
+
+
+	/*!
+		an auxiliary method for converting from a string
+	*/
+	template<class char_type>
+	uint FromStringBase(const char_type * source, const Conv & conv, const char_type ** after_source = 0, bool * value_read = 0)
+	{
+	bool is_sign;
+	bool value_read_temp = false;
+
+		if( conv.base<2 || conv.base>16 )
+		{
+			SetNan();
+
+			if( after_source )
+				*after_source = source;
+
+			if( value_read )
+				*value_read = value_read_temp;
+
+			return 1;
+		}
+
+		SetZero();
+		FromString_TestSign( source, is_sign );
+
+		uint c = FromString_ReadPartBeforeComma( source, conv, value_read_temp );
+
+		if( FromString_TestCommaOperator(source, conv) )
+			c += FromString_ReadPartAfterComma( source, conv, value_read_temp );
+
+		if( value_read_temp && conv.base == 10 )
+			c += FromString_ReadScientificIfExists( source );
+
+		if( is_sign && !IsZero() )
+			ChangeSign();
+
+		if( after_source )
+			*after_source = source;
+
+		if( value_read )
+			*value_read = value_read_temp;
+
+	return CheckCarry(c);
+	}
+
+
+	/*!
+		we're testing whether the value is with the sign
+
+		(this method is used from 'FromString_ReadPartScientific' too)
+	*/
+	template<class char_type>
+	void FromString_TestSign( const char_type * & source, bool & is_sign )
+	{
+		Misc::SkipWhiteCharacters(source);
+
+		is_sign = false;
+
+		if( *source == '-' )
+		{
+			is_sign = true;
+			++source;
+		}
+		else
+		if( *source == '+' )
+		{
+			++source;
+		}
+	}
+
+
+	/*!
+		we're testing whether there's a comma operator
+	*/
+	template<class char_type>
+	bool FromString_TestCommaOperator(const char_type * & source, const Conv & conv)
+	{
+		if( (*source == static_cast<char_type>(conv.comma)) || 
+			(*source == static_cast<char_type>(conv.comma2) && conv.comma2 != 0 ) )
+		{
+			++source;
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	/*!
+		this method reads the first part of a string
+		(before the comma operator)
+	*/
+	template<class char_type>
+	uint FromString_ReadPartBeforeComma( const char_type * & source, const Conv & conv, bool & value_read )
+	{
+		sint character;
+		Big<exp, man> temp;
+		Big<exp, man> base_( conv.base );
+		
+		Misc::SkipWhiteCharacters( source );
+
+		for( ; true ; ++source )
+		{
+			if( conv.group!=0 && *source==static_cast<char>(conv.group) )
+				continue;
+
+			character = Misc::CharToDigit(*source, conv.base);
+
+			if( character == -1 )
+				break;
+
+			value_read = true;
+			temp = character;
+
+			if( Mul(base_) )
+				return 1;
+
+			if( Add(temp) )
+				return 1;
+		}
+
+	return 0;
+	}
+
+
+	/*!
+		this method reads the second part of a string
+		(after the comma operator)
+	*/
+	template<class char_type>
+	uint FromString_ReadPartAfterComma( const char_type * & source, const Conv & conv, bool & value_read )
+	{
+	sint character;
+	uint c = 0, index = 1;
+	Big<exp, man> sum, part, power, old_value, base_( conv.base );
+
+		// we don't remove any white characters here
+
+		// this is only to avoid getting a warning about an uninitialized object 'old_value' which GCC reports
+		// (in fact we will initialize it later when the condition 'testing' is fulfilled)
+		old_value.SetZero();
+
+		power.SetOne();
+		sum.SetZero();
+
+		for( ; true ; ++source, ++index )
+		{
+			if( conv.group!=0 && *source==static_cast<char>(conv.group) )
+				continue;
+			
+			character = Misc::CharToDigit(*source, conv.base);
+
+			if( character == -1 )
+				break;
+
+			value_read = true;
+
+			part = character;
+
+			if( power.Mul( base_ ) )
+				// there's no sens to add the next parts, but we can't report this
+				// as an error (this is only inaccuracy)
+				break;
+
+			if( part.Div( power ) )
+				break;
+
+			// every 5 iteration we make a test whether the value will be changed or not
+			// (character must be different from zero to this test)
+			bool testing = (character != 0 && (index % 5) == 0);
+
+			if( testing )
+				old_value = sum;
+
+			// there actually shouldn't be a carry here
+			c += sum.Add( part );
+
+			if( testing && old_value == sum )
+				// after adding 'part' the value has not been changed
+				// there's no sense to add any next parts
+				break;
+		}
+
+		// we could break the parsing somewhere in the middle of the string,
+		// but the result (value) still can be good
+		// we should set a correct value of 'source' now
+		for( ; Misc::CharToDigit(*source, conv.base) != -1 ; ++source );
+
+		c += Add(sum);
+
+	return (c==0)? 0 : 1;
+	}
+
+
+	/*!
+		this method checks whether there is a scientific part: [e|E][-|+]value
+
+		it is called when the base is 10 and some digits were read before
+	*/
+	template<class char_type>
+	uint FromString_ReadScientificIfExists(const char_type * & source)
+	{
+	uint c = 0;
+
+		bool scientific_read = false;
+		const char_type * before_scientific = source;
+
+		if( FromString_TestScientific(source) )
+			c += FromString_ReadPartScientific( source, scientific_read );
+
+		if( !scientific_read )
+			source = before_scientific;
+
+	return (c==0)? 0 : 1;
+	}
+
+
+
+	/*!
+		we're testing whether is there the character 'e'
+
+		this character is only allowed when we're using the base equals 10
+	*/
+	template<class char_type>
+	bool FromString_TestScientific(const char_type * & source)
+	{
+		Misc::SkipWhiteCharacters(source);
+
+		if( *source=='e' || *source=='E' )
+		{
+			++source;
+
+		return true;
+		}
+
+	return false;
+	}
+
+
+	/*!
+		this method reads the exponent (after 'e' character) when there's a scientific
+		format of value and only when we're using the base equals 10
+	*/
+	template<class char_type>
+	uint FromString_ReadPartScientific( const char_type * & source, bool & scientific_read )
+	{
+	uint c = 0;
+	Big<exp, man> new_exponent, temp;
+	bool was_sign = false;
+
+		FromString_TestSign( source, was_sign );
+		c += FromString_ReadPartScientific_ReadExponent( source, new_exponent, scientific_read );
+
+		if( scientific_read )
+		{
+			if( was_sign )
+				new_exponent.ChangeSign();
+
+			temp = 10;
+			c += temp.Pow( new_exponent );
+			c += Mul(temp);
+		}
+
+	return (c==0)? 0 : 1;
+	}
+
+
+	/*!
+		this method reads the value of the extra exponent when scientific format is used
+		(only when base == 10)
+	*/
+	template<class char_type>
+	uint FromString_ReadPartScientific_ReadExponent( const char_type * & source, Big<exp, man> & new_exponent, bool & scientific_read )
+	{
+	sint character;
+	Big<exp, man> base, temp;
+
+		Misc::SkipWhiteCharacters(source);
+
+		new_exponent.SetZero();
+		base = 10;
+
+		for( ; (character=Misc::CharToDigit(*source, 10)) != -1 ; ++source )
+		{
+			scientific_read = true;
+
+			temp = character;
+
+			if( new_exponent.Mul(base) )
+				return 1;
+
+			if( new_exponent.Add(temp) )
+				return 1;
+		}
+
+	return 0;
+	}
+
+
+public:
+
+
+	/*!
+		a constructor for converting a string into this class
+	*/
+	Big(const char * string)
+	{
+		FromString( string );
+	}
+
+
+	/*!
+		a constructor for converting a string into this class
+	*/
+	Big(const std::string & string)
+	{
+		FromString( string.c_str() );
+	}
+
+
+	/*!
+		an operator= for converting a string into its value
+	*/
+	Big<exp, man> & operator=(const char * string)
+	{
+		FromString( string );
+
+	return *this;
+	}
+
+
+	/*!
+		an operator= for converting a string into its value
+	*/
+	Big<exp, man> & operator=(const std::string & string)
+	{
+		FromString( string.c_str() );
+
+	return *this;
+	}
+
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		a constructor for converting a string into this class
+	*/
+	Big(const wchar_t * string)
+	{
+		FromString( string );
+	}
+
+
+	/*!
+		a constructor for converting a string into this class
+	*/
+	Big(const std::wstring & string)
+	{
+		FromString( string.c_str() );
+	}
+
+
+	/*!
+		an operator= for converting a string into its value
+	*/
+	Big<exp, man> & operator=(const wchar_t * string)
+	{
+		FromString( string );
+
+	return *this;
+	}
+
+
+	/*!
+		an operator= for converting a string into its value
+	*/
+	Big<exp, man> & operator=(const std::wstring & string)
+	{
+		FromString( string.c_str() );
+
+	return *this;
+	}
+
+
+#endif
+
+
+
+	/*!
+	*
+	*	methods for comparing
+	*
+	*/
+
+
+	/*!
+		this method performs the formula 'abs(this) < abs(ss2)'
+		and returns the result
+
+		(in other words it treats 'this' and 'ss2' as values without a sign)
+		we don't check the NaN flag
+	*/
+	bool SmallerWithoutSignThan(const Big<exp,man> & ss2) const
+	{
+		if( IsZero() )
+		{
+			if( ss2.IsZero() )
+				// we've got two zeroes
+				return false;
+			else
+				// this==0 and ss2!=0
+				return true;
+		}
+
+		if( ss2.IsZero() )
+			// this!=0 and ss2==0
+			return false;
+
+		// we're using the fact that all bits in mantissa are pushed
+		// into the left side -- Standardizing()
+		if( exponent == ss2.exponent )
+			return mantissa < ss2.mantissa;
+
+	return exponent < ss2.exponent;
+	}
+
+
+	/*!
+		this method performs the formula 'abs(this) > abs(ss2)'
+		and returns the result
+
+		(in other words it treats 'this' and 'ss2' as values without a sign)
+		we don't check the NaN flag
+	*/
+	bool GreaterWithoutSignThan(const Big<exp,man> & ss2) const
+	{
+		if( IsZero() )
+		{
+			if( ss2.IsZero() )
+				// we've got two zeroes
+				return false;
+			else
+				// this==0 and ss2!=0
+				return false;
+		}
+
+		if( ss2.IsZero() )
+			// this!=0 and ss2==0
+			return true;
+
+		// we're using the fact that all bits in mantissa are pushed
+		// into the left side -- Standardizing()
+		if( exponent == ss2.exponent )
+			return mantissa > ss2.mantissa;
+
+	return exponent > ss2.exponent;
+	}
+
+
+	/*!
+		this method performs the formula 'abs(this) == abs(ss2)'
+		and returns the result
+
+		(in other words it treats 'this' and 'ss2' as values without a sign)
+		we don't check the NaN flag
+	*/
+	bool EqualWithoutSign(const Big<exp,man> & ss2) const
+	{
+		if( IsZero() )
+		{
+			if( ss2.IsZero() )
+				// we've got two zeroes
+				return true;
+			else
+				// this==0 and ss2!=0
+				return false;
+		}
+
+		if( ss2.IsZero() )
+			// this!=0 and ss2==0
+			return false;
+
+		if( exponent==ss2.exponent && mantissa==ss2.mantissa )
+			return true;
+
+	return false;
+	}
+
+
+	bool operator<(const Big<exp,man> & ss2) const
+	{
+		if( IsSign() && !ss2.IsSign() )
+			// this<0 and ss2>=0
+			return true;
+
+		if( !IsSign() && ss2.IsSign() )
+			// this>=0 and ss2<0
+			return false;
+
+		// both signs are the same
+
+		if( IsSign() )
+			return ss2.SmallerWithoutSignThan( *this );
+
+	return SmallerWithoutSignThan( ss2 );
+	}
+
+
+	bool operator==(const Big<exp,man> & ss2) const
+	{
+		if( IsSign() != ss2.IsSign() )
+			return false;
+
+	return EqualWithoutSign( ss2 );
+	}
+
+
+	bool operator>(const Big<exp,man> & ss2) const
+	{
+		if( IsSign() && !ss2.IsSign() )
+			// this<0 and ss2>=0
+			return false;
+
+		if( !IsSign() && ss2.IsSign() )
+			// this>=0 and ss2<0
+			return true;
+
+		// both signs are the same
+
+		if( IsSign() )
+			return ss2.GreaterWithoutSignThan( *this );
+
+	return GreaterWithoutSignThan( ss2 );
+	}
+
+
+	bool operator>=(const Big<exp,man> & ss2) const
+	{
+		return !operator<( ss2 );
+	}
+
+
+	bool operator<=(const Big<exp,man> & ss2) const
+	{
+		return !operator>( ss2 );
+	}
+
+
+	bool operator!=(const Big<exp,man> & ss2) const
+	{
+		return !operator==(ss2);
+	}
+
+
+
+
+
+	/*!
+	*
+	*	standard mathematical operators 
+	*
+	*/
+
+
+	/*!
+		an operator for changing the sign
+
+		this method is not changing 'this' but the changed value is returned
+	*/
+	Big<exp,man> operator-() const
+	{
+		Big<exp,man> temp(*this);
+
+		temp.ChangeSign();
+
+	return temp;
+	}
+
+
+	Big<exp,man> operator-(const Big<exp,man> & ss2) const
+	{
+	Big<exp,man> temp(*this);
+
+		temp.Sub(ss2);
+
+	return temp;
+	}
+
+	Big<exp,man> & operator-=(const Big<exp,man> & ss2)
+	{
+		Sub(ss2);
+
+	return *this;
+	}
+
+
+	Big<exp,man> operator+(const Big<exp,man> & ss2) const
+	{
+	Big<exp,man> temp(*this);
+
+		temp.Add(ss2);
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator+=(const Big<exp,man> & ss2)
+	{
+		Add(ss2);
+
+	return *this;
+	}
+
+
+	Big<exp,man> operator*(const Big<exp,man> & ss2) const
+	{
+	Big<exp,man> temp(*this);
+
+		temp.Mul(ss2);
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator*=(const Big<exp,man> & ss2)
+	{
+		Mul(ss2);
+
+	return *this;
+	}
+
+
+	Big<exp,man> operator/(const Big<exp,man> & ss2) const
+	{
+	Big<exp,man> temp(*this);
+
+		temp.Div(ss2);
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator/=(const Big<exp,man> & ss2)
+	{
+		Div(ss2);
+
+	return *this;
+	}
+
+
+	/*!
+		Prefix operator e.g ++variable
+	*/
+	Big<exp,man> & operator++()
+	{
+		AddOne();
+
+	return *this;
+	}
+
+
+	/*!
+		Postfix operator e.g variable++
+	*/
+	Big<exp,man> operator++(int)
+	{
+	Big<exp,man> temp( *this );
+
+		AddOne();
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator--()
+	{
+		SubOne();
+
+	return *this;
+	}
+
+
+	Big<exp,man> operator--(int)
+	{
+	Big<exp,man> temp( *this );
+
+		SubOne();
+
+	return temp;
+	}
+
+
+
+	/*!
+	*
+	*	bitwise operators
+	*   (we do not define bitwise not)
+	*/
+
+
+	Big<exp,man> operator&(const Big<exp,man> & p2) const
+	{
+		Big<exp,man> temp( *this );
+
+		temp.BitAnd(p2);
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator&=(const Big<exp,man> & p2)
+	{
+		BitAnd(p2);
+
+	return *this;
+	}
+
+
+	Big<exp,man> operator|(const Big<exp,man> & p2) const
+	{
+		Big<exp,man> temp( *this );
+
+		temp.BitOr(p2);
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator|=(const Big<exp,man> & p2)
+	{
+		BitOr(p2);
+
+	return *this;
+	}
+
+
+	Big<exp,man> operator^(const Big<exp,man> & p2) const
+	{
+		Big<exp,man> temp( *this );
+
+		temp.BitXor(p2);
+
+	return temp;
+	}
+
+
+	Big<exp,man> & operator^=(const Big<exp,man> & p2)
+	{
+		BitXor(p2);
+
+	return *this;
+	}
+
+
+
+
+
+
+	/*!
+		this method makes an integer value by skipping any fractions
+
+		for example:
+			10.7 will be 10
+			12.1  -- 12
+			-20.2 -- 20
+			-20.9 -- 20
+			-0.7  -- 0
+			0.8   -- 0
+	*/
+	void SkipFraction()
+	{
+		if( IsNan() || IsZero() )
+			return;
+
+		if( !exponent.IsSign() )
+			// exponent >=0 -- the value don't have any fractions
+			return;
+
+		if( exponent <= -sint(man*TTMATH_BITS_PER_UINT) )
+		{
+			// the value is from (-1,1), we return zero
+			SetZero();
+			return;
+		}
+
+		// exponent is in range (-man*TTMATH_BITS_PER_UINT, 0)
+		sint e = exponent.ToInt();
+	
+		mantissa.ClearFirstBits( -e );
+		
+		// we don't have to standardize 'Standardizing()' the value because
+		// there's at least one bit in the mantissa
+		// (the highest bit which we didn't touch)
+	}
+
+
+	/*!
+		this method remains only a fraction from the value
+
+		for example:
+			30.56 will be 0.56
+			-12.67 -- -0.67
+	*/
+	void RemainFraction()
+	{
+		if( IsNan() || IsZero() )
+			return;
+
+		if( !exponent.IsSign() )
+		{
+			// exponent >= 0 -- the value doesn't have any fractions
+			// we return zero
+			SetZero();
+			return;
+		}
+
+		if( exponent <= -sint(man*TTMATH_BITS_PER_UINT) )
+		{
+			// the value is from (-1,1)
+			// we don't make anything with the value
+			return;
+		}
+
+		// e will be from (-man*TTMATH_BITS_PER_UINT, 0)
+		sint e = exponent.ToInt();
+
+		sint how_many_bits_leave = sint(man*TTMATH_BITS_PER_UINT) + e; // there'll be a subtraction -- e is negative
+		mantissa.Rcl( how_many_bits_leave, 0);
+
+		// there'll not be a carry because the exponent is too small
+		exponent.Sub( how_many_bits_leave );
+
+		// we must call Standardizing() here
+		Standardizing();
+	}
+
+
+
+	/*!
+		this method returns true if the value is integer
+		(there is no a fraction)
+
+		(we don't check nan)
+	*/
+	bool IsInteger() const
+	{
+		if( IsZero() )
+			return true;
+
+		if( !exponent.IsSign() )
+			// exponent >=0 -- the value don't have any fractions
+			return true;
+
+		if( exponent <= -sint(man*TTMATH_BITS_PER_UINT) )
+			// the value is from (-1,1)
+			return false;
+
+		// exponent is in range (-man*TTMATH_BITS_PER_UINT, 0)
+		sint e = exponent.ToInt();
+		e = -e; // e means how many bits we must check
+
+		uint len  = e / TTMATH_BITS_PER_UINT;
+		uint rest = e % TTMATH_BITS_PER_UINT;
+		uint i    = 0;
+
+		for( ; i<len ; ++i )
+			if( mantissa.table[i] != 0 )
+				return false;
+
+		if( rest > 0 )
+		{
+			uint rest_mask = TTMATH_UINT_MAX_VALUE >> (TTMATH_BITS_PER_UINT - rest);
+			if( (mantissa.table[i] & rest_mask) != 0 )
+				return false;
+		}
+
+	return true;
+	}
+
+
+	/*!
+		this method rounds to the nearest integer value
+		(it returns a carry if it was)
+
+		for example:
+			2.3 = 2
+			2.8 = 3
+
+			-2.3 = -2
+			-2.8 = 3
+	*/
+	uint Round()
+	{
+	Big<exp,man> half;
+	uint c;
+
+		if( IsNan() )
+			return 1;
+
+		if( IsZero() )
+			return 0;
+
+		half.Set05();
+
+		if( IsSign() )
+		{
+			// 'this' is < 0
+			c = Sub( half );
+		}
+		else
+		{
+			// 'this' is > 0
+			c = Add( half );
+		}
+
+		SkipFraction();
+
+	return CheckCarry(c);
+	}
+
+	
+
+	/*!
+	*
+	*	input/output operators for standard streams
+	*
+	*/
+
+private:
+
+	/*!
+		an auxiliary method for outputing to standard streams
+	*/
+	template<class ostream_type, class string_type>
+	static ostream_type & OutputToStream(ostream_type & s, const Big<exp,man> & l)
+	{
+	string_type ss;
+
+		l.ToString(ss);
+		s << ss;
+
+	return s;
+	}
+
+
+public:
+
+
+	/*!
+		output to standard streams
+	*/
+	friend std::ostream & operator<<(std::ostream & s,  const Big<exp,man> & l)
+	{
+		return OutputToStream<std::ostream, std::string>(s, l);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		output to standard streams
+	*/
+	friend std::wostream & operator<<(std::wostream & s,  const Big<exp,man> & l)
+	{
+		return OutputToStream<std::wostream, std::wstring>(s, l);
+	}
+
+#endif
+
+
+
+private:
+
+	/*!
+		an auxiliary method for converting from a string
+	*/
+	template<class istream_type, class string_type, class char_type>
+	static istream_type & InputFromStream(istream_type & s, Big<exp,man> & l)
+	{
+	string_type ss;
+	
+	// char or wchar_t for operator>>
+	char_type z, old_z;
+	bool was_comma = false;
+	bool was_e     = false;
+	
+
+		// operator>> omits white characters if they're set for ommiting
+		s >> z;
+
+		if( z=='-' || z=='+' )
+		{
+			ss += z;
+			s >> z; // we're reading a next character (white characters can be ommited)
+		}
+		
+		old_z = 0;
+
+		// we're reading only digits (base=10) and only one comma operator
+		for( ; s.good() ; z=static_cast<char_type>(s.get()) )
+		{
+			if( z=='.' ||  z==',' )
+			{
+				if( was_comma || was_e )
+					// second comma operator or comma operator after 'e' character
+					break;
+
+				was_comma = true;
+			}
+			else
+			if( z == 'e' || z == 'E' )
+			{
+				if( was_e )
+					// second 'e' character
+					break;
+
+				was_e = true;
+			}
+			else
+			if( z == '+' || z == '-' )
+			{
+				if( old_z != 'e' && old_z != 'E' )
+					// '+' or '-' is allowed only after 'e' character
+					break;
+			}
+			else
+			if( Misc::CharToDigit(z, 10) < 0 )
+				break;
+
+
+			ss   += z;
+			old_z = z;
+		}
+
+		// we're leaving the last read character
+		// (it's not belonging to the value)
+		s.unget();
+
+		l.FromString( ss );
+
+	return s;
+	}
+
+
+
+public:
+
+	/*!
+		input from standard streams
+	*/
+	friend std::istream & operator>>(std::istream & s, Big<exp,man> & l)
+	{
+		return InputFromStream<std::istream, std::string, char>(s, l);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		input from standard streams
+	*/
+	friend std::wistream & operator>>(std::wistream & s, Big<exp,man> & l)
+	{
+		return InputFromStream<std::wistream, std::wstring, wchar_t>(s, l);
+	}
+
+#endif
+
+};
+
+
+} // namespace
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathint.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathint.h
new file mode 100644
index 0000000..ad306f0
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathint.h
@@ -0,0 +1,1922 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2011, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef headerfilettmathint
+#define headerfilettmathint
+
+/*!
+	\file ttmathint.h
+    \brief template class Int<uint>
+*/
+
+#include "ttmathuint.h"
+
+namespace ttmath
+{
+
+
+/*!
+	\brief Int implements a big integer value with a sign
+
+	value_size - how many bytes specify our value
+		on 32bit platforms: value_size=1 -> 4 bytes -> 32 bits
+		on 64bit platforms: value_size=1 -> 8 bytes -> 64 bits
+	value_size = 1,2,3,4,5,6....
+*/
+template<uint value_size>
+class Int : public UInt<value_size>
+{
+public:
+
+	/*!
+		this method sets the max value which this class can hold
+		(all bits will be one besides the last one)
+	*/
+	void SetMax()
+	{
+		UInt<value_size>::SetMax();
+		UInt<value_size>::table[value_size-1] = ~ TTMATH_UINT_HIGHEST_BIT;
+	}
+
+
+	/*!
+		this method sets the min value which this class can hold
+		(all bits will be zero besides the last one which is one)
+	*/
+	void SetMin()
+	{
+		UInt<value_size>::SetZero();
+		UInt<value_size>::table[value_size-1] = TTMATH_UINT_HIGHEST_BIT;
+	}
+
+
+	/*!
+		this method sets -1 as the value
+		(-1 is equal the max value in an unsigned type)
+	*/
+	void SetSignOne()
+	{
+		UInt<value_size>::SetMax();
+	}
+
+
+	/*!
+		we change the sign of the value
+
+		if it isn't possible to change the sign this method returns 1
+		else return 0 and changing the sign
+	*/
+	uint ChangeSign()
+	{
+		/*
+			if the value is equal that one which has been returned from SetMin
+			(only the highest bit is set) that means we can't change sign
+			because the value is too big (bigger about one)
+
+			e.g. when value_size = 1 and value is -2147483648 we can't change it to the
+			2147483648 because the max value which can be held is 2147483647
+
+			we don't change the value and we're using this fact somewhere in some methods
+			(if we look on our value without the sign we get the correct value 
+			eg. -2147483648 in Int<1> will be 2147483648 on the UInt<1> type)
+		*/
+		if( UInt<value_size>::IsOnlyTheHighestBitSet() )
+			return 1;
+
+		UInt<value_size> temp(*this);
+		UInt<value_size>::SetZero();
+		UInt<value_size>::Sub(temp);
+
+	return 0;
+	}
+
+
+
+	/*!	
+		this method sets the sign
+
+		e.g. 1  -> -1
+		     -2 -> -2
+		
+		from a positive value we make a negative value,
+		if the value is negative we do nothing
+	*/
+	void SetSign()
+	{
+		if( IsSign() )
+			return;
+
+		ChangeSign();
+	}
+
+
+
+	/*!
+		this method returns true if there's the sign
+
+		(the highest bit will be converted to the bool)
+	*/
+	bool IsSign() const
+	{
+		return UInt<value_size>::IsTheHighestBitSet();
+	}
+
+
+
+	/*!
+		it sets an absolute value
+
+		it can return carry (1) (look on ChangeSign() for details)
+	*/
+	uint Abs()
+	{
+		if( !IsSign() )
+			return 0;
+
+	return ChangeSign();
+	}
+
+
+
+
+	/*!
+	*
+	*	basic mathematic functions
+	*
+	*/
+
+private:
+
+	uint CorrectCarryAfterAdding(bool p1_is_sign, bool p2_is_sign)
+	{
+		if( !p1_is_sign && !p2_is_sign )
+		{
+			if( UInt<value_size>::IsTheHighestBitSet() )
+				return 1;
+		}
+
+		if( p1_is_sign && p2_is_sign )
+		{	
+			if( ! UInt<value_size>::IsTheHighestBitSet() )
+				return 1;
+		}
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		this method adds two value with a sign and returns a carry
+
+		we're using methods from the base class because values are stored with U2
+		we must only make the carry correction
+
+		this = p1(=this) + p2
+
+		when p1>=0 i p2>=0 carry is set when the highest bit of value is set
+		when p1<0  i p2<0  carry is set when the highest bit of value is clear
+		when p1>=0 i p2<0  carry will never be set
+		when p1<0  i p2>=0 carry will never be set
+	*/
+	uint Add(const Int<value_size> & ss2)
+	{
+		bool p1_is_sign = IsSign();
+		bool p2_is_sign = ss2.IsSign();
+
+		UInt<value_size>::Add(ss2);		
+
+	return CorrectCarryAfterAdding(p1_is_sign, p2_is_sign);
+	}
+
+
+	/*!
+		this method adds one *unsigned* word (at a specific position)
+		and returns a carry (if it was)
+
+		look at a description in UInt<>::AddInt(...)
+	*/
+	uint AddInt(uint value, uint index = 0)
+	{
+		bool p1_is_sign = IsSign();
+
+		UInt<value_size>::AddInt(value, index);		
+
+	return CorrectCarryAfterAdding(p1_is_sign, false);
+	}
+
+
+	/*!
+		this method adds two *unsigned* words to the existing value
+		and these words begin on the 'index' position
+
+		index should be equal or smaller than value_size-2 (index <= value_size-2)
+		x1 - lower word, x2 - higher word
+
+		look at a description in UInt<>::AddTwoInts(...)
+	*/
+	uint AddTwoInts(uint x2, uint x1, uint index)
+	{
+		bool p1_is_sign = IsSign();
+
+		UInt<value_size>::AddTwoInts(x2, x1, index);		
+
+	return CorrectCarryAfterAdding(p1_is_sign, false);
+	}
+
+private:
+
+	uint CorrectCarryAfterSubtracting(bool p1_is_sign, bool p2_is_sign)
+	{
+		if( !p1_is_sign && p2_is_sign )
+		{
+			if( UInt<value_size>::IsTheHighestBitSet() )
+				return 1;
+		}
+
+		if( p1_is_sign && !p2_is_sign )
+		{	
+			if( ! UInt<value_size>::IsTheHighestBitSet() )
+				return 1;
+		}
+
+	return 0;
+	}
+
+public:
+
+	/*!	
+		this method subtracts two values with a sign
+
+		we don't use the previous Add because the method ChangeSign can
+		sometimes return carry 
+
+		this = p1(=this) - p2
+
+		when p1>=0 i p2>=0 carry will never be set
+		when p1<0  i p2<0  carry will never be set
+		when p1>=0 i p2<0  carry is set when the highest bit of value is set
+		when p1<0  i p2>=0 carry is set when the highest bit of value is clear
+	*/
+	uint Sub(const Int<value_size> & ss2)
+	{
+		bool p1_is_sign = IsSign();
+		bool p2_is_sign = ss2.IsSign();
+
+		UInt<value_size>::Sub(ss2);		
+
+	return CorrectCarryAfterSubtracting(p1_is_sign, p2_is_sign);
+	}
+
+
+	/*!
+		this method subtracts one *unsigned* word (at a specific position)
+		and returns a carry (if it was)
+	*/
+	uint SubInt(uint value, uint index = 0)
+	{
+		bool p1_is_sign = IsSign();
+
+		UInt<value_size>::SubInt(value, index);		
+
+	return CorrectCarryAfterSubtracting(p1_is_sign, false);
+	}
+
+
+	/*!
+		this method adds one to the value and returns carry
+	*/
+	uint AddOne()
+	{
+		bool p1_is_sign = IsSign();
+
+		UInt<value_size>::AddOne();		
+
+	return CorrectCarryAfterAdding(p1_is_sign, false);
+	}
+
+
+	/*!
+		this method subtracts one from the value and returns carry
+	*/
+	uint SubOne()
+	{
+		bool p1_is_sign = IsSign();
+
+		UInt<value_size>::SubOne();		
+
+	return CorrectCarryAfterSubtracting(p1_is_sign, false);
+	}
+
+
+private:
+
+
+	uint CheckMinCarry(bool ss1_is_sign, bool ss2_is_sign)
+	{
+		/*
+			we have to examine the sign of the result now
+			but if the result is with the sign then:
+				1. if the signs were the same that means the result is too big
+				(the result must be without a sign)
+				2. if the signs were different that means if the result
+				is different from that one which has been returned from SetMin()
+				that is carry (result too big) but if the result is equal SetMin()
+				there'll be ok (and the next SetSign will has no effect because
+				the value is actually negative -- look at description of that case
+				in ChangeSign())
+		*/
+		if( IsSign() )
+		{
+			if( ss1_is_sign != ss2_is_sign )
+			{
+				/*
+					there can be one case where signs are different and
+					the result will be equal the value from SetMin() (only the highest bit is set)
+					(this situation is ok)
+				*/
+				if( !UInt<value_size>::IsOnlyTheHighestBitSet() )
+					return 1;
+			}
+			else
+			{
+				// signs were the same
+				return 1;
+			}
+		}
+
+	return 0;
+	}
+
+
+public:
+
+
+	/*!
+		multiplication: this = this * ss2
+
+		it can return a carry
+	*/
+	uint MulInt(sint ss2)
+	{
+	bool ss1_is_sign, ss2_is_sign;
+	uint c;
+
+		ss1_is_sign = IsSign();
+
+		/*
+			we don't have to check the carry from Abs (values will be correct
+			because next we're using the method MulInt from the base class UInt
+			which is without a sign)
+		*/
+		Abs();
+
+		if( ss2 < 0 )
+		{
+			ss2 = -ss2;
+			ss2_is_sign = true;
+		}
+		else
+		{
+			ss2_is_sign = false;
+		}
+
+		c  = UInt<value_size>::MulInt((uint)ss2);
+		c += CheckMinCarry(ss1_is_sign, ss2_is_sign);
+
+		if( ss1_is_sign != ss2_is_sign )
+			SetSign();
+
+	return c;
+	}
+
+
+
+	/*!
+		multiplication this = this * ss2
+
+		it returns carry if the result is too big
+		(we're using the method from the base class but we have to make
+		one correction in account of signs)
+	*/
+	uint Mul(Int<value_size> ss2)
+	{
+	bool ss1_is_sign, ss2_is_sign;
+	uint c;
+
+		ss1_is_sign = IsSign();
+		ss2_is_sign = ss2.IsSign();
+
+		/*
+			we don't have to check the carry from Abs (values will be correct
+			because next we're using the method Mul from the base class UInt
+			which is without a sign)
+		*/
+		Abs();
+		ss2.Abs();
+
+		c  = UInt<value_size>::Mul(ss2);
+		c += CheckMinCarry(ss1_is_sign, ss2_is_sign);
+
+		if( ss1_is_sign != ss2_is_sign )
+			SetSign();
+
+	return c;
+	}
+
+
+	/*!
+		division this = this / ss2
+		returned values:
+			0 - ok
+			1 - division by zero
+
+		for example: (result means 'this')
+			 20 /  3 --> result:  6   remainder:  2
+			-20 /  3 --> result: -6   remainder: -2
+			 20 / -3 --> result: -6   remainder:  2
+			-20 / -3 --> result:  6   remainder: -2
+
+		in other words: this(old) = ss2 * this(new)(result) + remainder
+	*/
+	uint Div(Int<value_size> ss2, Int<value_size> * remainder = 0)
+	{
+	bool ss1_is_sign, ss2_is_sign;
+
+		ss1_is_sign = IsSign();
+		ss2_is_sign = ss2.IsSign();
+
+		/*
+			we don't have to test the carry from Abs as well as in Mul
+		*/
+		Abs();
+		ss2.Abs();
+
+		uint c = UInt<value_size>::Div(ss2, remainder);
+
+		if( ss1_is_sign != ss2_is_sign )
+			SetSign();
+
+		if( ss1_is_sign && remainder )
+			remainder->SetSign();
+
+	return c;
+	}
+	
+	uint Div(const Int<value_size> & ss2, Int<value_size> & remainder)
+	{
+		return Div(ss2, &remainder);
+	}
+
+
+	/*!
+		division this = this / ss2  (ss2 is int)
+		returned values:
+			0 - ok
+			1 - division by zero
+
+		for example: (result means 'this')
+			 20 /  3 --> result:  6   remainder:  2
+			-20 /  3 --> result: -6   remainder: -2
+			 20 / -3 --> result: -6   remainder:  2
+			-20 / -3 --> result:  6   remainder: -2
+
+		in other words: this(old) = ss2 * this(new)(result) + remainder
+	*/
+	uint DivInt(sint ss2, sint * remainder = 0)
+	{
+	bool ss1_is_sign, ss2_is_sign;
+
+		ss1_is_sign = IsSign();
+
+		/*
+			we don't have to test the carry from Abs as well as in Mul
+		*/
+		Abs();
+
+		if( ss2 < 0 )
+		{
+			ss2 = -ss2;
+			ss2_is_sign = true;
+		}
+		else
+		{
+			ss2_is_sign = false;
+		}
+
+		uint rem;
+		uint c = UInt<value_size>::DivInt((uint)ss2, &rem);
+
+		if( ss1_is_sign != ss2_is_sign )
+			SetSign();
+
+		if( remainder )
+		{
+			if( ss1_is_sign )
+				*remainder = -sint(rem);
+			else
+				*remainder = sint(rem);
+		}
+
+	return c;
+	}
+
+
+	uint DivInt(sint ss2, sint & remainder)
+	{
+		return DivInt(ss2, &remainder);
+	}
+
+
+private:
+
+
+	/*!
+		power this = this ^ pow
+		this can be negative
+		pow is >= 0
+	*/
+	uint Pow2(const Int<value_size> & pow)
+	{
+		bool was_sign = IsSign();
+		uint c = 0;
+
+		if( was_sign )
+			c += Abs();
+
+		uint c_temp = UInt<value_size>::Pow(pow);
+		if( c_temp > 0 )
+			return c_temp; // c_temp can be: 0, 1 or 2
+		
+		if( was_sign && (pow.table[0] & 1) == 1 )
+			// negative value to the power of odd number is negative
+			c += ChangeSign();
+
+	return (c==0)? 0 : 1;
+	}
+
+
+public:
+
+
+	/*!
+		power this = this ^ pow
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect arguments 0^0 or 0^(-something)
+	*/
+	uint Pow(Int<value_size> pow)
+	{
+		if( !pow.IsSign() )
+			return Pow2(pow);
+
+		if( UInt<value_size>::IsZero() )
+			// if 'pow' is negative then
+			// 'this' must be different from zero
+			return 2;
+
+		if( pow.ChangeSign() )
+			return 1;
+
+		Int<value_size> t(*this);
+		uint c_temp = t.Pow2(pow);
+		if( c_temp > 0 )
+			return c_temp;
+
+		UInt<value_size>::SetOne();
+		if( Div(t) )
+			return 1;
+
+	return 0;
+	}
+
+
+
+	/*!
+	*
+	*	convertion methods
+	*
+	*/
+private:
+
+
+	/*!
+		an auxiliary method for converting both from UInt and Int
+	*/
+	template<uint argument_size>
+	uint FromUIntOrInt(const UInt<argument_size> & p, bool UInt_type)
+	{
+		uint min_size = (value_size < argument_size)? value_size : argument_size;
+		uint i;
+
+		for(i=0 ; i<min_size ; ++i)
+			UInt<value_size>::table[i] = p.table[i];
+
+
+		if( value_size > argument_size )
+		{	
+			uint fill;
+
+			if( UInt_type )
+				fill = 0;
+			else
+				fill = (p.table[argument_size-1] & TTMATH_UINT_HIGHEST_BIT)?
+														TTMATH_UINT_MAX_VALUE : 0;
+
+			// 'this' is longer than 'p'
+			for( ; i<value_size ; ++i)
+				UInt<value_size>::table[i] = fill;
+		}
+		else
+		{
+			uint test = (UInt<value_size>::table[value_size-1] & TTMATH_UINT_HIGHEST_BIT)?
+																TTMATH_UINT_MAX_VALUE : 0;
+
+			if( UInt_type && test!=0 )
+				return 1;
+
+			for( ; i<argument_size ; ++i)
+				if( p.table[i] != test )
+					return 1;
+		}
+
+	return 0;
+	}
+
+public:
+
+	/*!
+		this method converts an Int<another_size> type into this class
+
+		this operation has mainly sense if the value from p
+		can be held in this type
+
+		it returns a carry if the value 'p' is too big
+	*/
+	template<uint argument_size>
+	uint FromInt(const Int<argument_size> & p)
+	{
+		return FromUIntOrInt(p, false);
+	}
+
+
+	/*!
+		this method converts the sint type into this class
+	*/
+	uint FromInt(sint value)
+	{
+	uint fill = ( value<0 ) ? TTMATH_UINT_MAX_VALUE : 0;
+
+		for(uint i=1 ; i<value_size ; ++i)
+			UInt<value_size>::table[i] = fill;
+
+		UInt<value_size>::table[0] = uint(value);
+	
+		// there'll never be a carry here
+	return 0;
+	}
+
+
+	/*!
+		this method converts UInt<another_size> into this class
+	*/
+	template<uint argument_size>
+	uint FromUInt(const UInt<argument_size> & p)
+	{
+		return FromUIntOrInt(p, true);
+	}
+
+
+	/*!
+		this method converts UInt<another_size> into this class
+	*/
+	template<uint argument_size>
+	uint FromInt(const UInt<argument_size> & p)
+	{
+		return FromUIntOrInt(p, true);
+	}
+
+
+	/*!
+		this method converts the uint type into this class
+	*/
+	uint FromUInt(uint value)
+	{
+		for(uint i=1 ; i<value_size ; ++i)
+			UInt<value_size>::table[i] = 0;
+
+		UInt<value_size>::table[0] = value;
+
+		// there can be a carry here when the size of this value is equal one word
+		// and the 'value' has the highest bit set
+		if( value_size==1 && (value & TTMATH_UINT_HIGHEST_BIT)!=0 )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts the uint type into this class
+	*/
+	uint FromInt(uint value)
+	{
+		return FromUInt(value);
+	}
+
+
+	/*!
+		the default assignment operator
+	*/
+	Int<value_size> & operator=(const Int<value_size> & p)
+	{
+		FromInt(p);
+
+	return *this;
+	}
+
+
+	/*!
+		this operator converts an Int<another_size> type to this class
+
+		it doesn't return a carry
+	*/
+	template<uint argument_size>
+	Int<value_size> & operator=(const Int<argument_size> & p)
+	{
+		FromInt(p);
+
+	return *this;
+	}
+
+
+	/*!
+		this method converts the sint type to this class
+	*/
+	Int<value_size> & operator=(sint i)
+	{
+		FromInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting the uint to this class
+	*/
+	Int(sint i)
+	{
+		FromInt(i);
+	}
+
+
+	/*!
+		a copy constructor
+	*/
+	Int(const Int<value_size> & u)
+	{
+		FromInt(u);
+	}
+
+
+	/*!
+		a constructor for copying from another types
+	*/
+	template<uint argument_size>
+	Int(const Int<argument_size> & u)
+	{
+		// look that 'size' we still set as 'value_size' and not as u.value_size
+		FromInt(u);
+	}
+
+
+
+	/*!
+		this operator converts an UInt<another_size> type to this class
+
+		it doesn't return a carry
+	*/
+	template<uint argument_size>
+	Int<value_size> & operator=(const UInt<argument_size> & p)
+	{
+		FromUInt(p);
+
+	return *this;
+	}
+
+
+	/*!
+		this method converts the Uint type to this class
+	*/
+	Int<value_size> & operator=(uint i)
+	{
+		FromUInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting the uint to this class
+	*/
+	Int(uint i)
+	{
+		FromUInt(i);
+	}
+
+
+	/*!
+		a constructor for copying from another types
+	*/
+	template<uint argument_size>
+	Int(const UInt<argument_size> & u)
+	{
+		// look that 'size' we still set as 'value_size' and not as u.value_size
+		FromUInt(u);
+	}
+ 
+
+
+#ifdef TTMATH_PLATFORM32
+
+
+	/*!
+		this method converts unsigned 64 bit int type to this class
+		***this method is created only on a 32bit platform***
+	*/
+	uint FromUInt(ulint n)
+	{
+		uint c = UInt<value_size>::FromUInt(n);
+
+		if( c )
+			return 1;
+
+		if( value_size == 1 )
+			return ((UInt<value_size>::table[0] & TTMATH_UINT_HIGHEST_BIT) == 0) ? 0 : 1;
+		
+		if( value_size == 2 )
+			return ((UInt<value_size>::table[1] & TTMATH_UINT_HIGHEST_BIT) == 0) ? 0 : 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts unsigned 64 bit int type to this class
+		***this method is created only on a 32bit platform***
+	*/
+	uint FromInt(ulint n)
+	{
+		return FromUInt(n);
+	}
+
+		
+	/*!
+		this method converts signed 64 bit int type to this class
+		***this method is created only on a 32bit platform***
+	*/
+	uint FromInt(slint n)
+	{
+	uint mask = (n < 0) ? TTMATH_UINT_MAX_VALUE : 0;
+
+		UInt<value_size>::table[0] = (uint)(ulint)n;
+
+		if( value_size == 1 )
+		{
+			if( uint(ulint(n) >> 32) != mask )
+				return 1;
+
+			return ((UInt<value_size>::table[0] & TTMATH_UINT_HIGHEST_BIT) == (mask & TTMATH_UINT_HIGHEST_BIT)) ? 0 : 1;
+		}
+
+		UInt<value_size>::table[1] = (uint)(ulint(n) >> 32);
+
+		for(uint i=2 ; i<value_size ; ++i)
+			UInt<value_size>::table[i] = mask;
+
+	return 0;
+	}
+
+
+	/*!
+		this operator converts unsigned 64 bit int type to this class
+		***this operator is created only on a 32bit platform***
+	*/
+	Int<value_size> & operator=(ulint n)
+	{
+		FromUInt(n);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting unsigned 64 bit int to this class
+		***this constructor is created only on a 32bit platform***
+	*/
+	Int(ulint n)
+	{
+		FromUInt(n);
+	}
+
+
+	/*!
+		this operator converts signed 64 bit int type to this class
+		***this operator is created only on a 32bit platform***
+	*/
+	Int<value_size> & operator=(slint n)
+	{
+		FromInt(n);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting signed 64 bit int to this class
+		***this constructor is created only on a 32bit platform***
+	*/
+	Int(slint n)
+	{
+		FromInt(n);
+	}
+
+#endif
+
+
+
+
+#ifdef TTMATH_PLATFORM64
+
+	/*!
+		this method converts 32 bit unsigned int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	uint FromUInt(unsigned int i)
+	{
+		return FromUInt(uint(i));
+	}
+
+
+	/*!
+		this method converts 32 bit unsigned int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	uint FromInt(unsigned int i)
+	{
+		return FromUInt(i);
+	}
+
+
+	/*!
+		this method converts 32 bit signed int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	uint FromInt(signed int i)
+	{
+		return FromInt(sint(i));
+	}
+
+
+	/*!
+		this method converts 32 bit unsigned int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	Int<value_size> & operator=(unsigned int i)
+	{
+		FromUInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 32 bit unsigned int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	Int(unsigned int i)
+	{
+		FromUInt(i);
+	}
+
+
+	/*!
+		this operator converts 32 bit signed int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	Int<value_size> & operator=(signed int i)
+	{
+		FromInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 32 bit signed int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	Int(signed int i)
+	{
+		FromInt(i);
+	}
+
+#endif
+
+
+
+	/*!
+		a constructor for converting string to this class (with the base=10)
+	*/
+	Int(const char * s)
+	{
+		FromString(s);
+	}
+
+
+	/*!
+		a constructor for converting a string to this class (with the base=10)
+	*/
+	Int(const std::string & s)
+	{
+		FromString( s.c_str() );
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		a constructor for converting string to this class (with the base=10)
+	*/
+	Int(const wchar_t * s)
+	{
+		FromString(s);
+	}
+
+
+	/*!
+		a constructor for converting a string to this class (with the base=10)
+	*/
+	Int(const std::wstring & s)
+	{
+		FromString( s.c_str() );
+	}
+
+#endif
+
+
+	/*!
+		a default constructor
+
+		we don't clear table etc.
+	*/
+	Int()
+	{
+	}
+
+
+	/*!
+		the destructor
+	*/
+	~Int()
+	{
+	}
+
+
+	/*!
+		this method returns the lowest value from table with a sign
+
+		we must be sure when we using this method whether the value
+		will hold in an sint type or not (the rest value from table must be zero or -1)
+	*/
+	sint ToInt() const
+	{
+		return sint( UInt<value_size>::table[0] );
+	}
+
+
+	/*!
+		this method converts the value to uint type
+		can return a carry if the value is too long to store it in uint type
+	*/
+	uint ToUInt(uint & result) const
+	{
+		uint c = UInt<value_size>::ToUInt(result);
+
+		if( value_size == 1 )
+			return (result & TTMATH_UINT_HIGHEST_BIT) == 0 ? 0 : 1;
+
+	return c;
+	}
+
+
+	/*!
+		this method converts the value to uint type
+		can return a carry if the value is too long to store it in uint type
+	*/
+	uint ToInt(uint & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts the value to sint type
+		can return a carry if the value is too long to store it in sint type
+	*/
+	uint ToInt(sint & result) const
+	{
+		result = sint( UInt<value_size>::table[0] );
+		uint mask = IsSign() ? TTMATH_UINT_MAX_VALUE : 0;
+
+		if( (result & TTMATH_UINT_HIGHEST_BIT) != (mask & TTMATH_UINT_HIGHEST_BIT) )
+			return 1;
+
+		for(uint i=1 ; i<value_size ; ++i)
+			if( UInt<value_size>::table[i] != mask )
+				return 1;
+
+	return 0;
+	}
+
+
+#ifdef TTMATH_PLATFORM32
+
+	/*!
+		this method converts the value to ulint type (64 bit unsigned integer)
+		can return a carry if the value is too long to store it in ulint type
+		*** this method is created only on a 32 bit platform ***
+	*/
+	uint ToUInt(ulint & result) const
+	{
+		uint c = UInt<value_size>::ToUInt(result);
+
+		if( value_size == 1 )
+			return (UInt<value_size>::table[0] & TTMATH_UINT_HIGHEST_BIT) == 0 ? 0 : 1;
+
+		if( value_size == 2 )
+			return (UInt<value_size>::table[1] & TTMATH_UINT_HIGHEST_BIT) == 0 ? 0 : 1;
+
+	return c;
+	}
+
+
+	/*!
+		this method converts the value to ulint type (64 bit unsigned integer)
+		can return a carry if the value is too long to store it in ulint type
+		*** this method is created only on a 32 bit platform ***
+	*/
+	uint ToInt(ulint & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts the value to slint type (64 bit signed integer)
+		can return a carry if the value is too long to store it in slint type
+		*** this method is created only on a 32 bit platform ***
+	*/
+	uint ToInt(slint & result) const
+	{
+		if( value_size == 1 )
+		{
+			result = slint(sint(UInt<value_size>::table[0]));
+		}
+		else
+		{
+			uint low  = UInt<value_size>::table[0];
+			uint high = UInt<value_size>::table[1];
+
+			result = low;
+			result |= (ulint(high) << TTMATH_BITS_PER_UINT);
+
+			uint mask = IsSign() ? TTMATH_UINT_MAX_VALUE : 0;
+
+			if( (high & TTMATH_UINT_HIGHEST_BIT) != (mask & TTMATH_UINT_HIGHEST_BIT) )
+				return 1;
+
+			for(uint i=2 ; i<value_size ; ++i)
+				if( UInt<value_size>::table[i] != mask )
+					return 1;
+		}
+
+	return 0;
+	}
+
+#endif
+
+
+
+#ifdef TTMATH_PLATFORM64
+
+	/*!
+		this method converts the value to a 32 bit unsigned integer
+		can return a carry if the value is too long to store it in this type
+		*** this method is created only on a 64 bit platform ***
+	*/
+	uint ToUInt(unsigned int & result) const
+	{
+		uint c = UInt<value_size>::ToUInt(result);
+
+		if( c || IsSign() )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts the value to a 32 bit unsigned integer
+		can return a carry if the value is too long to store it in this type
+		*** this method is created only on a 64 bit platform ***
+	*/
+	uint ToInt(unsigned int & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts the value to a 32 bit signed integer
+		can return a carry if the value is too long to store it in this type
+		*** this method is created only on a 64 bit platform ***
+	*/
+	uint ToInt(int & result) const
+	{
+		uint first = UInt<value_size>::table[0];
+
+		result = int(first);
+		uint mask = IsSign() ? TTMATH_UINT_MAX_VALUE : 0;
+	
+		if( (first >> 31) != (mask >> 31) )
+			return 1;
+
+		for(uint i=1 ; i<value_size ; ++i)
+			if( UInt<value_size>::table[i] != mask )
+				return 1;
+
+	return 0;
+	}
+
+#endif
+
+
+
+
+private:
+
+	/*!	
+		an auxiliary method for converting to a string
+	*/
+	template<class string_type>
+	void ToStringBase(string_type & result, uint b = 10) const
+	{
+		if( IsSign() )
+		{
+			Int<value_size> temp(*this);
+			temp.Abs();
+			temp.UInt<value_size>::ToStringBase(result, b, true);
+		}
+		else
+		{
+			UInt<value_size>::ToStringBase(result, b, false);
+		}
+	}
+
+public:
+
+	/*!	
+		this method converts the value to a string with a base equal 'b'
+	*/
+	void ToString(std::string & result, uint b = 10) const
+	{
+		return ToStringBase(result, b);
+	}
+
+
+	/*!	
+		this method converts the value to a string with a base equal 'b'
+	*/
+	std::string ToString(uint b = 10) const
+	{
+		std::string result;
+		ToStringBase(result, b);
+
+	return result;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!	
+		this method converts the value to a string with a base equal 'b'
+	*/
+	void ToString(std::wstring & result, uint b = 10) const
+	{
+		return ToStringBase(result, b);
+	}
+
+
+	/*!	
+		this method converts the value to a string with a base equal 'b'
+	*/
+	std::wstring ToWString(uint b = 10) const
+	{
+		std::wstring result;
+		ToStringBase(result, b);
+
+	return result;
+	}
+
+#endif
+
+
+
+private:
+
+	/*!
+		an auxiliary method for converting from a string
+	*/
+	template<class char_type>
+	uint FromStringBase(const char_type * s, uint b = 10, const char_type ** after_source = 0, bool * value_read = 0)
+	{
+	bool is_sign = false;
+	
+		Misc::SkipWhiteCharacters(s);
+
+		if( *s == '-' )
+		{
+			is_sign = true;
+			Misc::SkipWhiteCharacters(++s);
+		}
+		else
+		if( *s == '+' )
+		{
+			Misc::SkipWhiteCharacters(++s);
+		}
+
+		if( UInt<value_size>::FromString(s,b,after_source,value_read) )
+			return 1;
+
+		if( is_sign )
+		{
+		Int<value_size> mmin;
+
+			mmin.SetMin();
+
+			/*
+				the reference to mmin will be automatically converted to the reference
+				to UInt type
+				(this value can be equal mmin -- look at a description in ChangeSign())
+			*/
+			if( UInt<value_size>::operator>( mmin ) )
+				return 1;
+
+			/*
+				if the value is equal mmin the method ChangeSign() does nothing (only returns 1 but we ignore it)
+			*/
+			ChangeSign();
+		}
+		else
+		{
+		Int<value_size> mmax;
+
+			mmax.SetMax();
+
+			if( UInt<value_size>::operator>( mmax ) )
+					return 1;
+		}
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		this method converts a string into its value
+		it returns carry=1 if the value will be too big or an incorrect base 'b' is given
+
+		string is ended with a non-digit value, for example:
+			"-12" will be translated to -12
+			as well as:
+			"- 12foo" will be translated to -12 too
+
+		existing first white characters will be ommited
+		(between '-' and a first digit can be white characters too)
+
+		after_source (if exists) is pointing at the end of the parsed string
+
+		value_read (if exists) tells whether something has actually been read (at least one digit)
+	*/
+	uint FromString(const char * s, uint b = 10, const char ** after_source = 0, bool * value_read = 0)
+	{
+		return FromStringBase(s, b, after_source, value_read);
+	}
+
+
+	/*!
+		this method converts a string into its value
+	*/
+	uint FromString(const wchar_t * s, uint b = 10, const wchar_t ** after_source = 0, bool * value_read = 0)
+	{
+		return FromStringBase(s, b, after_source, value_read);
+	}
+
+
+	/*!
+		this method converts a string into its value
+		it returns carry=1 if the value will be too big or an incorrect base 'b' is given
+	*/
+	uint FromString(const std::string & s, uint b = 10)
+	{
+		return FromString( s.c_str(), b );
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	Int<value_size> & operator=(const char * s)
+	{
+		FromString(s);
+
+	return *this;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+
+	/*!
+		this method converts a string into its value
+		it returns carry=1 if the value will be too big or an incorrect base 'b' is given
+	*/
+	uint FromString(const std::wstring & s, uint b = 10)
+	{
+		return FromString( s.c_str(), b );
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	Int<value_size> & operator=(const wchar_t * s)
+	{
+		FromString(s);
+
+	return *this;
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	Int<value_size> & operator=(const std::wstring & s)
+	{
+		FromString( s.c_str() );
+
+	return *this;
+	}
+
+#endif
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	Int<value_size> & operator=(const std::string & s)
+	{
+		FromString( s.c_str() );
+
+	return *this;
+	}
+
+
+
+	/*!
+	*
+	*	methods for comparing
+	*
+	*
+	*/
+
+	bool operator==(const Int<value_size> & l) const
+	{
+		return UInt<value_size>::operator==(l);
+	}
+
+	bool operator!=(const Int<value_size> & l) const
+	{
+		return UInt<value_size>::operator!=(l);
+	}
+
+	bool operator<(const Int<value_size> & l) const
+	{
+		sint i=value_size-1;
+
+		sint a1 = sint(UInt<value_size>::table[i]);
+		sint a2 = sint(l.table[i]);
+
+		if( a1 != a2 )
+			return a1 < a2;
+
+
+		for(--i ; i>=0 ; --i)
+		{
+			if( UInt<value_size>::table[i] != l.table[i] )
+				// comparison as unsigned int
+				return UInt<value_size>::table[i] < l.table[i];
+		}
+
+	// they're equal
+	return false;
+	}
+
+
+	bool operator>(const Int<value_size> & l) const
+	{
+		sint i=value_size-1;
+
+		sint a1 = sint(UInt<value_size>::table[i]);
+		sint a2 = sint(l.table[i]);
+
+		if( a1 != a2 )
+			return a1 > a2;
+
+
+		for(--i ; i>=0 ; --i)
+		{
+			if( UInt<value_size>::table[i] != l.table[i] )
+				// comparison as unsigned int
+				return UInt<value_size>::table[i] > l.table[i];
+		}
+
+	// they're equal
+	return false;
+	}
+
+
+	bool operator<=(const Int<value_size> & l) const
+	{
+		sint i=value_size-1;
+
+		sint a1 = sint(UInt<value_size>::table[i]);
+		sint a2 = sint(l.table[i]);
+
+		if( a1 != a2 )
+			return a1 < a2;
+
+
+		for(--i ; i>=0 ; --i)
+		{
+			if( UInt<value_size>::table[i] != l.table[i] )
+				// comparison as unsigned int
+				return UInt<value_size>::table[i] < l.table[i];
+		}
+
+	// they're equal
+	return true;
+	}
+
+
+	bool operator>=(const Int<value_size> & l) const
+	{
+		sint i=value_size-1;
+
+		sint a1 = sint(UInt<value_size>::table[i]);
+		sint a2 = sint(l.table[i]);
+
+		if( a1 != a2 )
+			return a1 > a2;
+
+
+		for(--i ; i>=0 ; --i)
+		{
+			if( UInt<value_size>::table[i] != l.table[i] )
+				// comparison as unsigned int
+				return UInt<value_size>::table[i] > l.table[i];
+		}
+
+	// they're equal
+	return true;
+	}
+
+
+
+	/*!
+	*
+	*	standard mathematical operators 
+	*
+	*/
+
+
+	/*!
+		an operator for changing the sign
+
+		it's not changing 'this' but the changed value will be returned
+	*/
+	Int<value_size> operator-() const
+	{
+	Int<value_size> temp(*this);
+
+		temp.ChangeSign();
+		
+	return temp;
+	}
+
+
+	Int<value_size> operator-(const Int<value_size> & p2) const
+	{
+	Int<value_size> temp(*this);
+
+		temp.Sub(p2);
+
+	return temp;
+	}
+
+
+	Int<value_size> & operator-=(const Int<value_size> & p2)
+	{
+		Sub(p2);
+
+	return *this;
+	}
+
+
+	Int<value_size> operator+(const Int<value_size> & p2) const
+	{
+	Int<value_size> temp(*this);
+
+		temp.Add(p2);
+
+	return temp;
+	}
+
+
+	Int<value_size> & operator+=(const Int<value_size> & p2)
+	{
+		Add(p2);
+
+	return *this;
+	}
+
+
+	Int<value_size> operator*(const Int<value_size> & p2) const
+	{
+	Int<value_size> temp(*this);
+
+		temp.Mul(p2);
+
+	return temp;
+	}
+
+
+	Int<value_size> & operator*=(const Int<value_size> & p2)
+	{
+		Mul(p2);
+
+	return *this;
+	}
+
+
+	Int<value_size> operator/(const Int<value_size> & p2) const
+	{
+	Int<value_size> temp(*this);
+
+		temp.Div(p2);
+
+	return temp;
+	}
+
+
+	Int<value_size> & operator/=(const Int<value_size> & p2)
+	{
+		Div(p2);
+
+	return *this;
+	}
+
+
+	Int<value_size> operator%(const Int<value_size> & p2) const
+	{
+	Int<value_size> temp(*this);
+	Int<value_size> remainder;
+	
+		temp.Div(p2, remainder);
+
+	return remainder;
+	}
+
+
+	Int<value_size> & operator%=(const Int<value_size> & p2)
+	{
+	Int<value_size> remainder;
+	
+		Div(p2, remainder);
+		operator=(remainder);
+
+	return *this;
+	}
+
+
+	/*!
+		Prefix operator e.g. ++variable
+	*/
+	UInt<value_size> & operator++()
+	{
+		AddOne();
+
+	return *this;
+	}
+
+
+	/*!
+		Postfix operator e.g. variable++
+	*/
+	UInt<value_size> operator++(int)
+	{
+	UInt<value_size> temp( *this );
+
+		AddOne();
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator--()
+	{
+		SubOne();
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator--(int)
+	{
+	UInt<value_size> temp( *this );
+
+		SubOne();
+
+	return temp;
+	}
+
+
+
+	/*!
+	*
+	*	input/output operators for standard streams
+	*
+	*/
+
+private:
+
+	/*!
+		an auxiliary method for outputing to standard streams
+	*/
+	template<class ostream_type, class string_type>
+	static ostream_type & OutputToStream(ostream_type & s, const Int<value_size> & l)
+	{
+	string_type ss;
+
+		l.ToString(ss);
+		s << ss;
+
+	return s;
+	}
+
+
+
+public:
+
+
+	/*!
+		output to standard streams
+	*/
+	friend std::ostream & operator<<(std::ostream & s, const Int<value_size> & l)
+	{
+		return OutputToStream<std::ostream, std::string>(s, l);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		output to standard streams
+	*/
+	friend std::wostream & operator<<(std::wostream & s, const Int<value_size> & l)
+	{
+		return OutputToStream<std::wostream, std::wstring>(s, l);
+	}
+
+#endif
+
+
+
+private:
+
+	/*!
+		an auxiliary method for converting from a string
+	*/
+	template<class istream_type, class string_type, class char_type>
+	static istream_type & InputFromStream(istream_type & s, Int<value_size> & l)
+	{
+	string_type ss;
+	
+	// char or wchar_t for operator>>
+	char_type z;
+	
+		// operator>> omits white characters if they're set for ommiting
+		s >> z;
+
+		if( z=='-' || z=='+' )
+		{
+			ss += z;
+			s >> z; // we're reading a next character (white characters can be ommited)
+		}
+
+		// we're reading only digits (base=10)
+		while( s.good() && Misc::CharToDigit(z, 10)>=0 )
+		{
+			ss += z;
+			z = static_cast<char_type>(s.get());
+		}
+
+		// we're leaving the last readed character
+		// (it's not belonging to the value)
+		s.unget();
+
+		l.FromString(ss);
+
+	return s;
+	}
+
+
+public:
+
+	/*!
+		input from standard streams
+	*/
+	friend std::istream & operator>>(std::istream & s, Int<value_size> & l)
+	{
+		return InputFromStream<std::istream, std::string, char>(s, l);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		input from standard streams
+	*/
+	friend std::wistream & operator>>(std::wistream & s, Int<value_size> & l)
+	{
+		return InputFromStream<std::wistream, std::wstring, wchar_t>(s, l);
+	}
+#endif
+
+
+};
+
+} // namespace
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathmisc.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathmisc.h
new file mode 100644
index 0000000..330a43a
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathmisc.h
@@ -0,0 +1,250 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2010, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef headerfilettmathmisc
+#define headerfilettmathmisc
+
+
+/*!
+	\file ttmathmisc.h
+    \brief some helpful functions
+*/
+
+
+#include <string>
+
+
+namespace ttmath
+{
+
+/*!
+	some helpful functions
+*/
+class Misc
+{
+public:
+
+
+/*
+ *
+ *	AssignString(result, str)
+ *	result = str
+ *
+ */
+
+/*!
+	result = str
+*/
+static void AssignString(std::string & result, const char * str)
+{
+	result = str;
+}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+/*!
+	result = str
+*/
+static void AssignString(std::wstring & result, const char * str)
+{
+	result.clear();
+
+	for( ; *str ; ++str )
+		result += *str;
+}
+
+
+/*!
+	result = str
+*/
+static void AssignString(std::wstring & result, const std::string & str)
+{
+	return AssignString(result, str.c_str());
+}
+
+
+/*!
+	result = str
+*/
+static void AssignString(std::string & result, const wchar_t * str)
+{
+	result.clear();
+
+	for( ; *str ; ++str )
+		result += static_cast<char>(*str);
+}
+
+
+/*!
+	result = str
+*/
+static void AssignString(std::string & result, const std::wstring & str)
+{
+	return AssignString(result, str.c_str());
+}
+
+#endif
+
+
+/*
+ *
+ *	AddString(result, str)
+ *	result += str
+ *
+ */
+
+
+/*!
+	result += str
+*/
+static void AddString(std::string & result, const char * str)
+{
+	result += str;
+}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+/*!
+	result += str
+*/
+static void AddString(std::wstring & result, const char * str)
+{
+	for( ; *str ; ++str )
+		result += *str;
+}
+
+#endif
+
+
+/*
+	this method omits any white characters from the string
+	char_type is char or wchar_t
+*/
+template<class char_type>
+static void SkipWhiteCharacters(const char_type * & c)
+{
+	// 13 is at the end in a DOS text file (\r\n)
+	while( (*c==' ' ) || (*c=='\t') || (*c==13 ) || (*c=='\n') )
+		++c;
+}
+
+
+
+
+/*!
+	this static method converts one character into its value
+
+	for example:
+		1 -> 1
+		8 -> 8
+		A -> 10
+		f -> 15
+
+	this method don't check whether c is correct or not
+*/
+static uint CharToDigit(uint c)
+{
+	if(c>='0' && c<='9')
+		return c-'0';
+
+	if(c>='a' && c<='z')
+		return c-'a'+10;
+
+return c-'A'+10;
+}
+
+
+/*!
+	this method changes a character 'c' into its value
+	(if there can't be a correct value it returns -1)
+
+	for example:
+	c=2, base=10 -> function returns 2
+	c=A, base=10 -> function returns -1
+	c=A, base=16 -> function returns 10
+*/
+static sint CharToDigit(uint c, uint base)
+{
+	if( c>='0' && c<='9' )
+		c=c-'0';
+	else
+	if( c>='a' && c<='z' )
+		c=c-'a'+10;
+	else
+	if( c>='A' && c<='Z' )
+		c=c-'A'+10;
+	else
+		return -1;
+
+
+	if( c >= base )
+		return -1;
+
+
+return sint(c);
+}
+
+
+
+/*!
+	this method converts a digit into a char
+	digit should be from <0,F>
+	(we don't have to get a base)
+	
+	for example:
+		1  -> 1
+		8  -> 8
+		10 -> A
+		15 -> F
+*/
+static uint DigitToChar(uint digit)
+{
+	if( digit < 10 )
+		return digit + '0';
+
+return digit - 10 + 'A';
+}
+
+
+}; // struct Misc
+
+}
+
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathobjects.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathobjects.h
new file mode 100644
index 0000000..c35026b
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathobjects.h
@@ -0,0 +1,809 @@
+/*
+ * This file is a part of TTMath Mathematical Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2010, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef headerfilettmathobject
+#define headerfilettmathobject
+
+/*!
+	\file ttmathobjects.h
+    \brief Mathematic functions.
+*/
+
+#include <string>
+#include <vector>
+#include <list>
+#include <map>
+
+#include "ttmathtypes.h"
+#include "ttmathmisc.h"
+
+
+namespace ttmath
+{
+
+/*!
+	objects of this class are used with the mathematical parser
+	they hold variables or functions defined by a user
+
+	each object has its own table in which we're keeping variables or functions
+*/
+class Objects
+{
+public:
+
+
+	/*!
+		one item (variable or function)
+		'items' will be on the table
+	*/
+	struct Item
+	{
+		// name of a variable of a function
+		// internally we store variables and funcions as std::string (not std::wstring even when wide characters are used)
+		std::string value;
+
+		// number of parameters required by the function
+		// (if there's a variable this 'param' is ignored)
+		int param;
+
+		Item() {}
+		Item(const std::string & v, int p) : value(v), param(p) {}
+	};
+
+	// 'Table' is the type of our table
+	typedef std::map<std::string, Item> Table;
+	typedef	Table::iterator Iterator;
+	typedef	Table::const_iterator CIterator;
+
+
+
+	/*!
+		this method returns true if a character 'c' is a character
+		which can be in a name
+		
+		if 'can_be_digit' is true that means when the 'c' is a digit this 
+		method returns true otherwise it returns false
+	*/
+	static bool CorrectCharacter(int c, bool can_be_digit)
+	{
+		if( (c>='a' && c<='z') || (c>='A' && c<='Z') )
+			return true;
+
+		if( can_be_digit && ((c>='0' && c<='9') || c=='_') )
+			return true;
+
+	return false;
+	}
+
+
+	/*!
+		this method returns true if the name can be as a name of an object
+	*/
+	template<class string_type>
+	static bool IsNameCorrect(const string_type & name)
+	{
+		if( name.empty() )
+			return false;
+
+		if( !CorrectCharacter(name[0], false) )
+			return false;
+
+		typename string_type::const_iterator i = name.begin();
+
+		for(++i ; i!=name.end() ; ++i)
+			if( !CorrectCharacter(*i, true) )
+				return false;
+		
+	return true;
+	}
+
+
+	/*!
+		this method returns true if such an object is defined (name exists)
+	*/
+	bool IsDefined(const std::string & name)
+	{
+		Iterator i = table.find(name);
+
+		if( i != table.end() )
+			// we have this object in our table
+			return true;
+
+	return false;
+	}
+
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		this method returns true if such an object is defined (name exists)
+	*/
+	bool IsDefined(const std::wstring & name)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return false;
+
+		Misc::AssignString(str_tmp1, name);
+
+	return IsDefined(str_tmp1);
+	}
+
+#endif
+
+
+	/*!
+		this method adds one object (variable of function) into the table
+	*/
+	ErrorCode Add(const std::string & name, const std::string & value, int param = 0)
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Iterator i = table.find(name);
+
+		if( i != table.end() )
+			// we have this object in our table
+			return err_object_exists;
+
+		table.insert( std::make_pair(name, Item(value, param)) );
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		this method adds one object (variable of function) into the table
+	*/
+	ErrorCode Add(const std::wstring & name, const std::wstring & value, int param = 0)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+		Misc::AssignString(str_tmp2, value);
+		
+	return Add(str_tmp1, str_tmp2, param);
+	}
+
+#endif
+
+
+	/*!
+		this method returns 'true' if the table is empty
+	*/
+	bool Empty() const
+	{
+		return table.empty();
+	}
+
+
+	/*!
+		this method clears the table
+	*/
+	void Clear()
+	{
+		return table.clear();
+	}
+
+
+	/*!
+		this method returns 'const_iterator' on the first item on the table
+	*/
+	CIterator Begin() const
+	{
+		return table.begin();
+	}
+
+
+	/*!
+		this method returns 'const_iterator' pointing at the space after last item
+		(returns table.end())
+	*/
+	CIterator End() const
+	{
+		return table.end();
+	}
+
+
+	/*!
+		this method changes the value and the number of parameters for a specific object
+	*/
+	ErrorCode EditValue(const std::string & name, const std::string & value, int param = 0)
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Iterator i = table.find(name);
+
+		if( i == table.end() )
+			return err_unknown_object;
+	
+		i->second.value = value;
+		i->second.param = param;
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+
+	/*!
+		this method changes the value and the number of parameters for a specific object
+	*/
+	ErrorCode EditValue(const std::wstring & name, const std::wstring & value, int param = 0)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+		Misc::AssignString(str_tmp2, value);
+		
+	return EditValue(str_tmp1, str_tmp2, param);
+	}
+
+#endif
+
+
+	/*!
+		this method changes the name of a specific object
+	*/
+	ErrorCode EditName(const std::string & old_name, const std::string & new_name)
+	{
+		if( !IsNameCorrect(old_name) || !IsNameCorrect(new_name) )
+			return err_incorrect_name;
+
+		Iterator old_i = table.find(old_name);
+		if( old_i == table.end() )
+			return err_unknown_object;
+		
+		if( old_name == new_name )
+			// the new name is the same as the old one
+			// we treat it as a normal situation
+			return err_ok;
+
+		ErrorCode err = Add(new_name, old_i->second.value, old_i->second.param);
+		
+		if( err == err_ok ) 
+		{
+			old_i = table.find(old_name);
+			TTMATH_ASSERT( old_i != table.end() )
+
+			table.erase(old_i);
+		}
+
+	return err;
+	}
+
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+
+	/*!
+		this method changes the name of a specific object
+	*/
+	ErrorCode EditName(const std::wstring & old_name, const std::wstring & new_name)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(old_name) || !IsNameCorrect(new_name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, old_name);
+		Misc::AssignString(str_tmp2, new_name);
+
+	return EditName(str_tmp1, str_tmp2);
+	}
+
+#endif
+
+
+	/*!
+		this method deletes an object
+	*/
+	ErrorCode Delete(const std::string & name)
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Iterator i = table.find(name);
+
+		if( i == table.end() )
+			return err_unknown_object;
+
+		table.erase( i );
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+
+	/*!
+		this method deletes an object
+	*/
+	ErrorCode Delete(const std::wstring & name)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+
+	return Delete(str_tmp1);
+	}	
+		
+#endif
+
+
+	/*!
+		this method gets the value of a specific object
+	*/
+	ErrorCode GetValue(const std::string & name, std::string & value) const
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		CIterator i = table.find(name);
+
+		if( i == table.end() )
+		{
+			value.clear();
+			return err_unknown_object;
+		}
+
+		value = i->second.value;
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		this method gets the value of a specific object
+	*/
+	ErrorCode GetValue(const std::wstring & name, std::wstring & value)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+		ErrorCode err = GetValue(str_tmp1, str_tmp2);
+		Misc::AssignString(value, str_tmp2);
+
+	return err;
+	}
+
+#endif
+
+
+	/*!
+		this method gets the value of a specific object
+		(this version is used for not copying the whole string)
+	*/
+	ErrorCode GetValue(const std::string & name, const char ** value) const
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		CIterator i = table.find(name);
+
+		if( i == table.end() )
+		{
+			*value = 0;
+			return err_unknown_object;
+		}
+
+		*value = i->second.value.c_str();
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		this method gets the value of a specific object
+		(this version is used for not copying the whole string)
+	*/
+	ErrorCode GetValue(const std::wstring & name, const char ** value)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+
+	return GetValue(str_tmp1, value);
+	}
+
+#endif
+
+
+	/*!
+		this method gets the value and the number of parameters
+		of a specific object
+	*/
+	ErrorCode GetValueAndParam(const std::string & name, std::string & value, int * param) const
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		CIterator i = table.find(name);
+
+		if( i == table.end() )
+		{
+			value.empty();
+			*param = 0;
+			return err_unknown_object;
+		}
+
+		value = i->second.value;
+		*param = i->second.param;
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		this method gets the value and the number of parameters
+		of a specific object
+	*/
+	ErrorCode GetValueAndParam(const std::wstring & name, std::wstring & value, int * param)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+		ErrorCode err = GetValueAndParam(str_tmp1, str_tmp2, param);
+		Misc::AssignString(value, str_tmp2);
+
+	return err;
+	}
+
+#endif
+
+
+	/*!
+		this method sets the value and the number of parameters
+		of a specific object
+		(this version is used for not copying the whole string)
+	*/
+	ErrorCode GetValueAndParam(const std::string & name, const char ** value, int * param) const
+	{
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		CIterator i = table.find(name);
+
+		if( i == table.end() )
+		{
+			*value = 0;
+			*param = 0;
+			return err_unknown_object;
+		}
+
+		*value = i->second.value.c_str();
+		*param = i->second.param;
+
+	return err_ok;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+
+	/*!
+		this method sets the value and the number of parameters
+		of a specific object
+		(this version is used for not copying the whole string
+		but in fact we make one copying during AssignString())
+	*/
+	ErrorCode GetValueAndParam(const std::wstring & name, const char ** value, int * param)
+	{
+		// we should check whether the name (in wide characters) are correct
+		// before calling AssignString() function
+		if( !IsNameCorrect(name) )
+			return err_incorrect_name;
+
+		Misc::AssignString(str_tmp1, name);
+
+	return GetValueAndParam(str_tmp1, value, param);
+	}
+
+
+#endif
+
+
+	/*!
+		this method returns a pointer into the table
+	*/
+	Table * GetTable()
+	{
+		return &table;
+	}
+
+
+private:
+
+	Table table;
+	std::string str_tmp1, str_tmp2;
+
+}; // end of class Objects
+
+
+
+
+
+
+
+/*!
+	objects of the class History are used to keep values in functions
+	which take a lot of time during calculating, for instance in the 
+	function Factorial(x)
+
+	it means that when we're calculating e.g. Factorial(1000) and the 
+	Factorial finds that we have calculated it before, the value (result)
+	is taken from the history
+*/
+template<class ValueType>
+class History
+{
+	/*!
+		one item in the History's object holds a key, a value for the key
+		and a corresponding error code
+	*/
+	struct Item
+	{
+		ValueType key, value;
+		ErrorCode err;
+	};
+
+
+	/*!
+		we use std::list for simply deleting the first item
+		but because we're searching through the whole container
+		(in the method Get) the container should not be too big
+		(linear time of searching)
+	*/
+	typedef std::list<Item> buffer_type;
+	buffer_type buffer;
+	typename buffer_type::size_type buffer_max_size;
+
+public:
+	
+	/*!
+		default constructor
+		default max size of the History's container is 15 items
+	*/
+	History()
+	{
+		buffer_max_size = 15;
+	}
+
+
+	/*!
+		a constructor which takes another value of the max size
+		of the History's container
+	*/
+	History(typename buffer_type::size_type new_size)
+	{
+		buffer_max_size = new_size;
+	}
+
+
+	/*!
+		this method adds one item into the History
+		if the size of the container is greater than buffer_max_size
+		the first item will be removed
+	*/
+	void Add(const ValueType & key, const ValueType & value, ErrorCode err)
+	{
+		Item item;
+		item.key   = key;
+		item.value = value;
+		item.err   = err;
+
+		buffer.insert( buffer.end(), item );
+
+		if( buffer.size() > buffer_max_size )
+			buffer.erase(buffer.begin());
+	}
+
+
+	/*!
+		this method checks whether we have an item which has the key equal 'key'
+
+		if there's such item the method sets the 'value' and the 'err'
+		and returns true otherwise it returns false and 'value' and 'err'
+		remain unchanged
+	*/
+	bool Get(const ValueType & key, ValueType & value, ErrorCode & err)
+	{
+		typename buffer_type::iterator i = buffer.begin();
+
+		for( ; i != buffer.end() ; ++i )
+		{
+			if( i->key == key )
+			{
+				value = i->value;
+				err   = i->err;
+				return true;
+			}
+		}
+
+	return false;
+	}
+
+
+	/*!
+		this methods deletes an item
+
+		we assume that there is only one item with the 'key'
+		(this methods removes the first one)
+	*/
+	bool Remove(const ValueType & key)
+	{
+		typename buffer_type::iterator i = buffer.begin();
+
+		for( ; i != buffer.end() ; ++i )
+		{
+			if( i->key == key )
+			{
+				buffer.erase(i);
+				return true;
+			}
+		}
+
+	return false;
+	}
+
+
+}; // end of class History
+
+
+
+/*!
+	this is an auxiliary class used when calculating Gamma() or Factorial()
+
+	in multithreaded environment you can provide an object of this class to
+	the Gamma() or Factorial() function, e.g;
+		typedef Big<1, 3> MyBig;
+		MyBig x = 123456;
+		CGamma<MyBig> cgamma;
+		std::cout << Gamma(x, cgamma);
+	each thread should have its own CGamma<> object
+
+	in a single-thread environment a CGamma<> object is a static variable
+	in a second version of Gamma() and you don't have to explicitly use it, e.g.
+		typedef Big<1, 3> MyBig;
+		MyBig x = 123456;
+		std::cout << Gamma(x);
+*/
+template<class ValueType>
+struct CGamma
+{
+	/*!
+		this table holds factorials
+			1
+			1
+			2
+			6
+			24
+			120
+			720
+			.......
+	*/
+	std::vector<ValueType> fact;
+
+
+	/*!
+		this table holds Bernoulli numbers
+			1
+			-0.5
+			0.166666666666666666666666667
+			0
+			-0.0333333333333333333333333333
+			0
+			0.0238095238095238095238095238
+			0
+			-0.0333333333333333333333333333
+			0
+			0.075757575757575757575757576
+			.....
+	*/
+	std::vector<ValueType> bern;
+
+
+	/*!
+		here we store some calculated values
+		(this is for speeding up, if the next argument of Gamma() or Factorial()
+		is in the 'history' then the result we are not calculating but simply
+		return from the 'history' object)
+	*/
+	History<ValueType> history;
+
+
+	/*!
+		this method prepares some coefficients: factorials and Bernoulli numbers
+		stored in 'fact' and 'bern' objects
+		
+		how many values should be depends on the size of the mantissa - if
+		the mantissa is larger then we must calculate more values
+		    for a mantissa which consists of 256 bits (8 words on a 32bit platform)
+			we have to calculate about 30 values (the size of fact and bern will be 30),
+			and for a 2048 bits mantissa we have to calculate 306 coefficients
+
+		you don't have to call this method, these coefficients will be automatically calculated
+		when they are needed
+
+		you must note that calculating these coefficients is a little time-consuming operation,
+		(especially when the mantissa is large) and first call to Gamma() or Factorial()
+		can take more time than next calls, and in the end this is the point when InitAll()
+		comes in handy: you can call this method somewhere at the beginning of your program
+	*/
+	void InitAll();
+	// definition is in ttmath.h
+};
+
+
+
+
+} // namespace
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathparser.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathparser.h
new file mode 100644
index 0000000..4b2243f
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathparser.h
@@ -0,0 +1,2777 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2010, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef headerfilettmathparser
+#define headerfilettmathparser
+
+/*!
+	\file ttmathparser.h
+    \brief A mathematical parser
+*/
+
+#include <cstdio>
+#include <vector>
+#include <map>
+#include <set>
+
+#include "ttmath.h"
+#include "ttmathobjects.h"
+#include "ttmathmisc.h"
+
+
+
+namespace ttmath
+{
+
+/*! 
+	\brief Mathematical parser
+
+	let x will be an input string meaning an expression for converting:
+	
+	x = [+|-]Value[operator[+|-]Value][operator[+|-]Value]...
+	where:
+		an operator can be:
+			^ (pow)   (the heighest priority)
+
+			* (mul)   (or multiplication without an operator -- short mul)
+			/ (div)   (* and / have the same priority)
+
+			+ (add)
+			- (sub)   (+ and - have the same priority)
+
+			< (lower than)
+			> (greater than)
+			<= (lower or equal than)
+			>= (greater or equal than)
+			== (equal)
+			!= (not equal)   (all above logical operators have the same priority)
+			
+			&& (logical and)
+
+			|| (logical or) (the lowest priority)
+
+		short mul:
+ 		 if the second Value (Var below) is either a variable or function there might not be 
+		 an operator between them, e.g.
+	        "[+|-]Value Var" is treated as "[+|-]Value * Var" and the multiplication
+	        has the same priority as a normal multiplication:
+			4x       = 4 * x
+			2^3m     = (2^3)* m
+			6h^3     = 6 * (h^3)
+	        2sin(pi) = 2 * sin(pi)
+			etc.
+
+		Value can be:
+			constant e.g. 100, can be preceded by operators for changing the base (radix): [#|&]
+			                   # - hex
+							   & - bin
+							   sample: #10  = 16
+							           &10  = 2
+			variable e.g. pi
+			another expression between brackets e.g (x)
+			function e.g. sin(x)
+
+	for example a correct input string can be:
+		"1"
+		"2.1234"
+		"2,1234"    (they are the same, by default we can either use a comma or a dot)
+		"1 + 2"
+		"(1 + 2) * 3"
+		"pi"
+		"sin(pi)"
+		"(1+2)*(2+3)"
+		"log(2;1234)"    there's a semicolon here (not a comma), we use it in functions
+		                 for separating parameters
+	    "1 < 2"  (the result will be: 1)
+	    "4 < 3"  (the result will be: 0)
+		"2+x"    (of course if the variable 'x' is defined)
+		"4x+10"
+		"#20+10"     = 32 + 10 = 42
+		"10 ^ -&101" = 10 ^ -5 = 0.00001
+		"8 * -&10"   = 8 * -2  = -16
+		etc.
+
+	we can also use a semicolon for separating any 'x' input strings
+	for example:
+		"1+2;4+5"
+	the result will be on the stack as follows:
+		stack[0].value=3
+		stack[1].value=9
+*/
+template<class ValueType>
+class Parser
+{
+private:
+
+/*!
+	there are 5 mathematical operators as follows (with their standard priorities):
+		add (+)
+		sub (-)
+		mul (*)
+		div (/)
+		pow (^)
+		and 'shortmul' used when there is no any operators between
+		a first parameter and a variable or function
+		(the 'shortmul' has the same priority as the normal multiplication )
+*/
+	class MatOperator
+	{
+	public:
+
+		enum Type
+		{
+			none,add,sub,mul,div,pow,lt,gt,let,get,eq,neq,lor,land,shortmul
+		};
+
+		enum Assoc
+		{
+			right,		// right-associative
+			non_right	// associative or left-associative
+		};
+
+		Type  GetType()     const { return type; }
+		int   GetPriority() const { return priority; }
+		Assoc GetAssoc()    const { return assoc; }
+
+		void SetType(Type t)
+		{
+			type  = t;
+			assoc = non_right;
+
+			switch( type )
+			{		
+			case lor:
+				priority = 4;
+				break;
+
+			case land:
+				priority = 5;
+				break;
+
+			case eq:
+			case neq:
+			case lt:
+			case gt:
+			case let:
+			case get:
+				priority = 7;
+				break;
+
+			case add:
+			case sub:
+				priority = 10;
+				break;
+
+			case mul:
+			case shortmul:
+			case div:
+				priority = 12;
+				break;
+
+			case pow:
+				priority = 14;
+				assoc    = right;
+				break;
+
+			default:
+				Error( err_internal_error );
+				break;
+			}
+		}
+
+		MatOperator(): type(none), priority(0), assoc(non_right)
+		{
+		}
+
+	private:
+
+		Type  type;
+		int   priority;
+		Assoc assoc;
+	}; // end of MatOperator class
+
+
+
+public:
+
+
+
+	/*!
+		Objects of type 'Item' we are keeping on our stack
+	*/
+	struct Item
+	{
+		enum Type
+		{
+			none, numerical_value, mat_operator, first_bracket,
+			last_bracket, variable, semicolon
+		};
+
+		// The kind of type which we're keeping
+		Type type;
+
+		// if type == numerical_value
+		ValueType value;
+
+		// if type == mat_operator
+		MatOperator moperator;
+
+		/*
+			if type == first_bracket
+
+			if 'function' is set to true it means that the first recognized bracket
+			was the bracket from function in other words we must call a function when
+			we'll find the 'last' bracket
+		*/
+		bool function;
+
+		// if function is true
+		std::string function_name;
+
+		/*
+			the sign of value
+
+			it can be for type==numerical_value or type==first_bracket
+			when it's true it means e.g. that value is equal -value
+		*/
+		bool sign;
+
+		Item(): type(none), function(false), sign(false)
+		{
+		}
+
+	}; // end of Item struct
+
+
+/*!
+	stack on which we're keeping the Items
+
+	at the end of parsing we'll have the result here
+	the result don't have to be one value, it can be
+	more than one if we have used a semicolon in the global space
+	e.g. such input string "1+2;3+4" will generate a result:
+	 stack[0].value=3
+	 stack[1].value=7
+
+	you should check if the stack is not empty, because if there was
+	a syntax error in the input string then we do not have any results
+	on the stack 
+*/
+std::vector<Item> stack;
+
+
+private:
+
+
+/*!
+	size of the stack when we're starting parsing of the string
+
+	if it's to small while parsing the stack will be automatically resized
+*/
+const int default_stack_size;
+
+
+
+/*!
+	index of an object in our stack
+	it's pointing on the place behind the last element
+	for example at the beginning of parsing its value is zero
+*/
+unsigned int stack_index;
+
+
+/*!
+	code of the last error
+*/
+ErrorCode error;
+
+
+/*!
+	pointer to the currently reading char
+	when an error has occurred it may be used to count the index of the wrong character
+*/
+const char * pstring;
+
+
+/*!
+	the base (radix) of the mathematic system (for example it may be '10')
+*/
+int base;
+
+
+/*!
+	the unit of angles used in: sin,cos,tan,cot,asin,acos,atan,acot
+	0 - deg
+	1 - rad (default)
+	2 - grad
+*/
+int deg_rad_grad;
+
+
+
+/*!
+	a pointer to an object which tell us whether we should stop calculating or not
+*/
+const volatile StopCalculating * pstop_calculating;
+
+
+
+/*!
+	a pointer to the user-defined variables' table
+*/
+const Objects * puser_variables;
+
+/*!
+	a pointer to the user-defined functions' table
+*/
+const Objects * puser_functions;
+
+
+typedef std::map<std::string, ValueType> FunctionLocalVariables;
+
+/*!
+	a pointer to the local variables of a function
+*/
+const FunctionLocalVariables * pfunction_local_variables;
+
+
+/*!
+	a temporary set using during parsing user defined variables
+*/
+std::set<std::string> visited_variables;
+
+
+/*!
+	a temporary set using during parsing user defined functions
+*/
+std::set<std::string> visited_functions;
+
+
+
+
+/*!
+	pfunction is the type of pointer to a mathematic function
+
+	these mathematic functions are private members of this class,
+	they are the wrappers for standard mathematics function
+
+	'pstack' is the pointer to the first argument on our stack
+	'amount_of_arg' tell us how many argument there are in our stack
+	'result' is the reference for result of function 
+*/
+typedef void (Parser<ValueType>::*pfunction)(int pstack, int amount_of_arg, ValueType & result);
+
+
+/*!
+	pfunction is the type of pointer to a method which returns value of variable
+*/
+typedef void (ValueType::*pfunction_var)();
+
+
+/*!
+	table of mathematic functions
+
+	this map consists of:
+		std::string - function's name
+		pfunction - pointer to specific function
+*/
+typedef std::map<std::string, pfunction> FunctionsTable;
+FunctionsTable functions_table;
+
+
+/*!
+	table of mathematic operators
+
+	this map consists of:
+		std::string - operators's name
+		MatOperator::Type - type of the operator
+*/
+typedef std::map<std::string, typename MatOperator::Type> OperatorsTable;
+OperatorsTable operators_table;
+
+
+/*!
+	table of mathematic variables
+
+	this map consists of:
+		std::string     - variable's name
+		pfunction_var - pointer to specific function which returns value of variable
+*/
+typedef std::map<std::string, pfunction_var> VariablesTable;
+VariablesTable variables_table;
+
+
+/*!
+	some coefficients used when calculating the gamma (or factorial) function
+*/
+CGamma<ValueType> cgamma;
+
+
+/*!
+	temporary object for a whole string when Parse(std::wstring) is used
+*/
+std::string wide_to_ansi;
+
+
+/*!
+	group character (used when parsing)
+	default zero (not used)
+*/
+int group;
+
+
+/*!
+	characters used as a comma
+	default: '.' and ','
+	comma2 can be zero (it means it is not used)
+*/
+int comma, comma2;
+
+
+/*!
+	an additional character used as a separator between function parameters
+	(semicolon is used always)
+*/
+int param_sep;
+
+
+/*!
+	true if something was calculated (at least one mathematical operator was used or a function or a variable)
+*/
+bool calculated;
+
+
+
+/*!
+	we're using this method for reporting an error
+*/
+static void Error(ErrorCode code)
+{
+	throw code;
+}
+
+
+/*!
+	this method skips the white character from the string
+
+	it's moving the 'pstring' to the first no-white character
+*/
+void SkipWhiteCharacters()
+{
+	while( (*pstring==' ' ) || (*pstring=='\t') )
+		++pstring;
+}
+
+
+/*!
+	an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
+*/
+void RecurrenceParsingVariablesOrFunction_CheckStopCondition(bool variable, const std::string & name)
+{
+	if( variable )
+	{
+		if( visited_variables.find(name) != visited_variables.end() )
+			Error( err_variable_loop );
+	}
+	else
+	{
+		if( visited_functions.find(name) != visited_functions.end() )
+			Error( err_functions_loop );
+	}
+}
+
+
+/*!
+	an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
+*/
+void RecurrenceParsingVariablesOrFunction_AddName(bool variable, const std::string & name)
+{
+	if( variable )
+		visited_variables.insert( name );
+	else
+		visited_functions.insert( name );
+}
+
+
+/*!
+	an auxiliary method for RecurrenceParsingVariablesOrFunction(...)
+*/
+void RecurrenceParsingVariablesOrFunction_DeleteName(bool variable, const std::string & name)
+{
+	if( variable )
+		visited_variables.erase( name );
+	else
+		visited_functions.erase( name );
+}
+
+
+/*!
+	this method returns the value of a variable or function
+	by creating a new instance of the mathematical parser 
+	and making the standard parsing algorithm on the given string
+
+	this method is used only during parsing user defined variables or functions
+
+	(there can be a recurrence here therefore we're using 'visited_variables'
+	and 'visited_functions' sets to make a stop condition)
+*/
+ValueType RecurrenceParsingVariablesOrFunction(bool variable, const std::string & name, const char * new_string,
+											   FunctionLocalVariables * local_variables = 0)
+{
+	RecurrenceParsingVariablesOrFunction_CheckStopCondition(variable, name);
+	RecurrenceParsingVariablesOrFunction_AddName(variable, name);
+
+	Parser<ValueType> NewParser(*this);
+	ErrorCode err;
+
+	NewParser.pfunction_local_variables = local_variables;
+
+	try
+	{
+		err = NewParser.Parse(new_string);
+	}
+	catch(...)
+	{
+		RecurrenceParsingVariablesOrFunction_DeleteName(variable, name);
+
+	throw;
+	}
+
+	RecurrenceParsingVariablesOrFunction_DeleteName(variable, name);
+
+	if( err != err_ok )
+		Error( err );
+
+	if( NewParser.stack.size() != 1 )
+		Error( err_must_be_only_one_value );
+
+	if( NewParser.stack[0].type != Item::numerical_value )
+		// I think there shouldn't be this error here
+		Error( err_incorrect_value );
+
+return NewParser.stack[0].value;
+}
+
+
+public:
+
+
+/*!
+	this method returns the user-defined value of a variable
+*/
+bool GetValueOfUserDefinedVariable(const std::string & variable_name,ValueType & result)
+{
+	if( !puser_variables )
+		return false;
+
+	const char * string_value;
+
+	if( puser_variables->GetValue(variable_name, &string_value) != err_ok )
+		return false;
+
+	result = RecurrenceParsingVariablesOrFunction(true, variable_name, string_value);
+	calculated = true;
+
+return true;
+}
+
+
+/*!
+	this method returns the value of a local variable of a function
+*/
+bool GetValueOfFunctionLocalVariable(const std::string & variable_name, ValueType & result)
+{
+	if( !pfunction_local_variables )
+		return false;
+
+	typename FunctionLocalVariables::const_iterator i = pfunction_local_variables->find(variable_name);
+
+	if( i == pfunction_local_variables->end() )
+		return false;
+
+	result = i->second;
+
+return true;
+}
+
+
+/*!
+	this method returns the value of a variable from variables' table
+
+	we make an object of type ValueType then call a method which 
+	sets the correct value in it and finally we'll return the object
+*/
+ValueType GetValueOfVariable(const std::string & variable_name)
+{
+ValueType result;
+
+	if( GetValueOfFunctionLocalVariable(variable_name, result) )
+		return result;
+
+	if( GetValueOfUserDefinedVariable(variable_name, result) )
+		return result;
+
+
+	typename std::map<std::string, pfunction_var>::iterator i =
+													variables_table.find(variable_name);
+
+	if( i == variables_table.end() )
+		Error( err_unknown_variable );
+
+	(result.*(i->second))();
+	calculated = true;
+
+return result;
+}
+
+
+private:
+
+/*!
+	wrappers for mathematic functions
+
+	'sindex' is pointing on the first argument on our stack 
+			 (the second argument has 'sindex+2'
+			 because 'sindex+1' is guaranted for the 'semicolon' operator)
+			 the third artument has of course 'sindex+4' etc.
+
+	'result' will be the result of the function
+
+	(we're using exceptions here for example when function gets an improper argument)
+*/
+
+
+/*!
+	used by: sin,cos,tan,cot
+*/
+ValueType ConvertAngleToRad(const ValueType & input)
+{
+	if( deg_rad_grad == 1 ) // rad
+		return input;
+
+	ValueType result;
+	ErrorCode err;
+
+	if( deg_rad_grad == 0 ) // deg
+		result = ttmath::DegToRad(input, &err);
+	else // grad
+		result = ttmath::GradToRad(input, &err);
+
+	if( err != err_ok )
+		Error( err );
+
+return result;
+}
+
+
+/*!
+	used by: asin,acos,atan,acot
+*/
+ValueType ConvertRadToAngle(const ValueType & input)
+{
+	if( deg_rad_grad == 1 ) // rad
+		return input;
+
+	ValueType result;
+	ErrorCode err;
+
+	if( deg_rad_grad == 0 ) // deg
+		result = ttmath::RadToDeg(input, &err);
+	else // grad
+		result = ttmath::RadToGrad(input, &err);
+
+	if( err != err_ok )
+		Error( err );
+
+return result;
+}
+
+
+void Gamma(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	
+	result = ttmath::Gamma(stack[sindex].value, cgamma, &err, pstop_calculating);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+
+/*!
+	factorial
+	result = 1 * 2 * 3 * 4 * .... * x
+*/
+void Factorial(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+
+	result = ttmath::Factorial(stack[sindex].value, cgamma, &err, pstop_calculating);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+
+void Abs(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = ttmath::Abs(stack[sindex].value);
+}
+
+void Sin(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Sin( ConvertAngleToRad(stack[sindex].value), &err );
+
+	if(err != err_ok)
+		Error( err );
+}
+
+void Cos(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Cos( ConvertAngleToRad(stack[sindex].value), &err );
+
+	if(err != err_ok)
+		Error( err );
+}
+
+void Tan(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Tan(ConvertAngleToRad(stack[sindex].value), &err);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+void Cot(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Cot(ConvertAngleToRad(stack[sindex].value), &err);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+void Int(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = ttmath::SkipFraction(stack[sindex].value);
+}
+
+
+void Round(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = stack[sindex].value;
+
+	if( result.Round() )
+		Error( err_overflow );
+}
+
+
+void Ln(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Ln(stack[sindex].value, &err);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+void Log(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 2 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Log(stack[sindex].value, stack[sindex+2].value, &err);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+void Exp(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Exp(stack[sindex].value, &err);
+
+	if(err != err_ok)
+		Error( err );
+}
+
+
+void Max(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args == 0 )
+	{
+		result.SetMax();
+
+	return;
+	}
+
+	result = stack[sindex].value;
+
+	for(int i=1 ; i<amount_of_args ; ++i)
+	{
+		if( result < stack[sindex + i*2].value )
+			result = stack[sindex + i*2].value;
+	}
+}
+
+
+void Min(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args == 0 )
+	{
+		result.SetMin();
+
+	return;
+	}
+
+	result = stack[sindex].value;
+
+	for(int i=1 ; i<amount_of_args ; ++i)
+	{
+		if( result > stack[sindex + i*2].value )
+			result = stack[sindex + i*2].value;
+	}
+}
+
+
+void ASin(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	ValueType temp = ttmath::ASin(stack[sindex].value, &err);
+
+	if(err != err_ok)
+		Error( err );
+
+	result = ConvertRadToAngle(temp);
+}
+
+
+void ACos(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	ValueType temp = ttmath::ACos(stack[sindex].value, &err);
+
+	if(err != err_ok)
+		Error( err );
+
+	result = ConvertRadToAngle(temp);
+}
+
+
+void ATan(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = ConvertRadToAngle(ttmath::ATan(stack[sindex].value));
+}
+
+
+void ACot(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = ConvertRadToAngle(ttmath::ACot(stack[sindex].value));
+}
+
+
+void Sgn(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = ttmath::Sgn(stack[sindex].value);
+}
+
+
+void Mod(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 2 )
+		Error( err_improper_amount_of_arguments );
+
+	if( stack[sindex+2].value.IsZero() )
+		Error( err_improper_argument );
+
+	result = stack[sindex].value;
+	uint c = result.Mod(stack[sindex+2].value);
+
+	if( c )
+		Error( err_overflow );
+}
+
+
+void If(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 3 )
+		Error( err_improper_amount_of_arguments );
+
+
+	if( !stack[sindex].value.IsZero() )
+		result = stack[sindex+2].value;
+	else
+		result = stack[sindex+4].value;
+}
+
+
+void Or(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args < 2 )
+		Error( err_improper_amount_of_arguments );
+
+	for(int i=0 ; i<amount_of_args ; ++i)
+	{
+		if( !stack[sindex+i*2].value.IsZero() )
+		{
+			result.SetOne();
+			return;
+		}
+	}
+
+	result.SetZero();
+}
+
+
+void And(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args < 2 )
+		Error( err_improper_amount_of_arguments );
+
+	for(int i=0 ; i<amount_of_args ; ++i)
+	{
+		if( stack[sindex+i*2].value.IsZero() )
+		{
+			result.SetZero();
+			return;
+		}
+	}
+
+	result.SetOne();
+}
+
+
+void Not(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+
+	if( stack[sindex].value.IsZero() )
+		result.SetOne();
+	else
+		result.SetZero();
+}
+
+
+void DegToRad(int sindex, int amount_of_args, ValueType & result)
+{
+	ErrorCode err = err_ok;
+
+	if( amount_of_args == 1 )
+	{
+		result = ttmath::DegToRad(stack[sindex].value, &err);
+	}
+	else
+	if( amount_of_args == 3 )
+	{
+		result = ttmath::DegToRad(	stack[sindex].value, stack[sindex+2].value,
+									stack[sindex+4].value, &err);
+	}
+	else
+		Error( err_improper_amount_of_arguments );
+
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void RadToDeg(int sindex, int amount_of_args, ValueType & result)
+{
+	ErrorCode err;
+
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+	
+	result = ttmath::RadToDeg(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void DegToDeg(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 3 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::DegToDeg(	stack[sindex].value, stack[sindex+2].value,
+								stack[sindex+4].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void GradToRad(int sindex, int amount_of_args, ValueType & result)
+{
+	ErrorCode err;
+
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+	
+	result = ttmath::GradToRad(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void RadToGrad(int sindex, int amount_of_args, ValueType & result)
+{
+	ErrorCode err;
+
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+	
+	result = ttmath::RadToGrad(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void DegToGrad(int sindex, int amount_of_args, ValueType & result)
+{
+	ErrorCode err = err_ok;
+
+	if( amount_of_args == 1 )
+	{
+		result = ttmath::DegToGrad(stack[sindex].value, &err);
+	}
+	else
+	if( amount_of_args == 3 )
+	{
+		result = ttmath::DegToGrad(	stack[sindex].value, stack[sindex+2].value,
+									stack[sindex+4].value, &err);
+	}
+	else
+		Error( err_improper_amount_of_arguments );
+
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void GradToDeg(int sindex, int amount_of_args, ValueType & result)
+{
+	ErrorCode err;
+
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+	
+	result = ttmath::GradToDeg(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Ceil(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Ceil(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Floor(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Floor(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+void Sqrt(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Sqrt(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Sinh(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Sinh(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Cosh(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Cosh(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Tanh(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Tanh(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Coth(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Coth(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void Root(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 2 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::Root(stack[sindex].value, stack[sindex+2].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+
+void ASinh(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::ASinh(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void ACosh(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::ACosh(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void ATanh(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::ATanh(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void ACoth(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	ErrorCode err;
+	result = ttmath::ACoth(stack[sindex].value, &err);
+
+	if( err != err_ok )
+		Error( err );
+}
+
+
+void BitAnd(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 2 )
+		Error( err_improper_amount_of_arguments );
+
+	uint err;
+	result = stack[sindex].value;
+	err = result.BitAnd(stack[sindex+2].value);
+
+	switch(err)
+	{
+	case 1:
+		Error( err_overflow );
+		break;
+	case 2:
+		Error( err_improper_argument );
+		break;
+	}
+}
+
+void BitOr(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 2 )
+		Error( err_improper_amount_of_arguments );
+
+	uint err;
+	result = stack[sindex].value;
+	err = result.BitOr(stack[sindex+2].value);
+
+	switch(err)
+	{
+	case 1:
+		Error( err_overflow );
+		break;
+	case 2:
+		Error( err_improper_argument );
+		break;
+	}
+}
+
+
+void BitXor(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 2 )
+		Error( err_improper_amount_of_arguments );
+
+	uint err;
+	result = stack[sindex].value;
+	err = result.BitXor(stack[sindex+2].value);
+
+	switch(err)
+	{
+	case 1:
+		Error( err_overflow );
+		break;
+	case 2:
+		Error( err_improper_argument );
+		break;
+	}
+}
+
+
+void Sum(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args == 0 )
+		Error( err_improper_amount_of_arguments );
+
+	result = stack[sindex].value;
+
+	for(int i=1 ; i<amount_of_args ; ++i )
+		if( result.Add( stack[ sindex + i*2 ].value ) )
+			Error( err_overflow );
+}	
+
+void Avg(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args == 0 )
+		Error( err_improper_amount_of_arguments );
+
+	result = stack[sindex].value;
+
+	for(int i=1 ; i<amount_of_args ; ++i )
+		if( result.Add( stack[ sindex + i*2 ].value ) )
+			Error( err_overflow );
+
+	if( result.Div( amount_of_args ) )
+		Error( err_overflow );
+}	
+
+
+void Frac(int sindex, int amount_of_args, ValueType & result)
+{
+	if( amount_of_args != 1 )
+		Error( err_improper_amount_of_arguments );
+
+	result = stack[sindex].value;
+	result.RemainFraction();
+}
+
+
+
+
+/*!
+	we use such a method because 'wvsprintf' is not everywhere defined
+*/
+void Sprintf(char * buffer, int par)
+{
+char buf[30]; // char, not wchar_t
+int i;
+
+	#ifdef _MSC_VER
+	#pragma warning( disable: 4996 )
+	//warning C4996: 'sprintf': This function or variable may be unsafe.
+	#endif
+
+	sprintf(buf, "%d", par);
+	for(i=0 ; buf[i] != 0 ; ++i)
+		buffer[i] = buf[i];
+
+	buffer[i] = 0;
+
+	#ifdef _MSC_VER
+	#pragma warning( default: 4996 )
+	#endif
+}
+
+
+
+
+/*!
+	this method returns the value from a user-defined function
+
+	(look at the description in 'CallFunction(...)')
+*/
+bool GetValueOfUserDefinedFunction(const std::string & function_name, int amount_of_args, int sindex)
+{
+	if( !puser_functions )
+		return false;
+
+	const char * string_value;
+	int param;
+
+	if( puser_functions->GetValueAndParam(function_name, &string_value, &param) != err_ok )
+		return false;
+
+	if( param != amount_of_args )
+		Error( err_improper_amount_of_arguments );
+
+
+	FunctionLocalVariables local_variables;
+
+	if( amount_of_args > 0 )
+	{
+		char buffer[30];
+
+		// x = x1
+		buffer[0] = 'x';
+		buffer[1] = 0;
+		local_variables.insert( std::make_pair(buffer, stack[sindex].value) );
+
+		for(int i=0 ; i<amount_of_args ; ++i)
+		{
+			buffer[0] = 'x';
+			Sprintf(buffer+1, i+1);
+			local_variables.insert( std::make_pair(buffer, stack[sindex + i*2].value) );
+		}
+	}
+
+	stack[sindex-1].value = RecurrenceParsingVariablesOrFunction(false, function_name, string_value, &local_variables);
+	calculated = true;
+
+return true;
+}
+
+
+/*
+	we're calling a specific function
+
+	function_name  - name of the function
+	amount_of_args - how many arguments there are on our stack
+					 (function must check whether this is a correct value or not)
+	sindex         - index of the first argument on the stack (sindex is greater than zero)
+  					 if there aren't any arguments on the stack 'sindex' pointing on
+					 a non existend element (after the first bracket)
+
+	result will be stored in 'stack[sindex-1].value'
+	(we don't have to set the correct type of this element, it'll be set later)
+*/
+void CallFunction(const std::string & function_name, int amount_of_args, int sindex)
+{
+	if( GetValueOfUserDefinedFunction(function_name, amount_of_args, sindex) )
+		return;
+
+	typename FunctionsTable::iterator i = functions_table.find( function_name );
+
+	if( i == functions_table.end() )
+		Error( err_unknown_function );
+
+	/*
+		calling the specify function
+	*/
+	(this->*(i->second))(sindex, amount_of_args, stack[sindex-1].value);
+	calculated = true;
+}
+
+
+
+
+
+/*!
+	inserting a function to the functions' table
+
+	function_name - name of the function
+	pf - pointer to the function (to the wrapper)
+*/
+void InsertFunctionToTable(const char * function_name, pfunction pf)
+{
+	std::string str;
+	Misc::AssignString(str, function_name);
+
+	functions_table.insert( std::make_pair(str, pf) );
+}
+
+
+
+/*!
+	inserting a function to the variables' table
+	(this function returns value of variable)
+
+	variable_name - name of the function
+	pf - pointer to the function
+*/
+void InsertVariableToTable(const char * variable_name, pfunction_var pf)
+{
+	std::string str;
+	Misc::AssignString(str, variable_name);
+
+	variables_table.insert( std::make_pair(str, pf) );
+}
+
+
+/*!
+	this method creates the table of functions
+*/
+void CreateFunctionsTable()
+{
+	InsertFunctionToTable("gamma",		&Parser<ValueType>::Gamma);
+	InsertFunctionToTable("factorial",	&Parser<ValueType>::Factorial);
+	InsertFunctionToTable("abs",   		&Parser<ValueType>::Abs);
+	InsertFunctionToTable("sin",   		&Parser<ValueType>::Sin);
+	InsertFunctionToTable("cos",   		&Parser<ValueType>::Cos);
+	InsertFunctionToTable("tan",   		&Parser<ValueType>::Tan);
+	InsertFunctionToTable("tg",			&Parser<ValueType>::Tan);
+	InsertFunctionToTable("cot",  		&Parser<ValueType>::Cot);
+	InsertFunctionToTable("ctg",  		&Parser<ValueType>::Cot);
+	InsertFunctionToTable("int",	   	&Parser<ValueType>::Int);
+	InsertFunctionToTable("round",	 	&Parser<ValueType>::Round);
+	InsertFunctionToTable("ln",			&Parser<ValueType>::Ln);
+	InsertFunctionToTable("log",	   	&Parser<ValueType>::Log);
+	InsertFunctionToTable("exp",	   	&Parser<ValueType>::Exp);
+	InsertFunctionToTable("max",	   	&Parser<ValueType>::Max);
+	InsertFunctionToTable("min",	   	&Parser<ValueType>::Min);
+	InsertFunctionToTable("asin",   	&Parser<ValueType>::ASin);
+	InsertFunctionToTable("acos",   	&Parser<ValueType>::ACos);
+	InsertFunctionToTable("atan",   	&Parser<ValueType>::ATan);
+	InsertFunctionToTable("atg",	   	&Parser<ValueType>::ATan);
+	InsertFunctionToTable("acot",   	&Parser<ValueType>::ACot);
+	InsertFunctionToTable("actg",   	&Parser<ValueType>::ACot);
+	InsertFunctionToTable("sgn",   		&Parser<ValueType>::Sgn);
+	InsertFunctionToTable("mod",   		&Parser<ValueType>::Mod);
+	InsertFunctionToTable("if",   		&Parser<ValueType>::If);
+	InsertFunctionToTable("or",   		&Parser<ValueType>::Or);
+	InsertFunctionToTable("and",  		&Parser<ValueType>::And);
+	InsertFunctionToTable("not",  		&Parser<ValueType>::Not);
+	InsertFunctionToTable("degtorad",	&Parser<ValueType>::DegToRad);
+	InsertFunctionToTable("radtodeg",	&Parser<ValueType>::RadToDeg);
+	InsertFunctionToTable("degtodeg",	&Parser<ValueType>::DegToDeg);
+	InsertFunctionToTable("gradtorad",	&Parser<ValueType>::GradToRad);
+	InsertFunctionToTable("radtograd",	&Parser<ValueType>::RadToGrad);
+	InsertFunctionToTable("degtograd",	&Parser<ValueType>::DegToGrad);
+	InsertFunctionToTable("gradtodeg",	&Parser<ValueType>::GradToDeg);
+	InsertFunctionToTable("ceil",		&Parser<ValueType>::Ceil);
+	InsertFunctionToTable("floor",		&Parser<ValueType>::Floor);
+	InsertFunctionToTable("sqrt",		&Parser<ValueType>::Sqrt);
+	InsertFunctionToTable("sinh",		&Parser<ValueType>::Sinh);
+	InsertFunctionToTable("cosh",		&Parser<ValueType>::Cosh);
+	InsertFunctionToTable("tanh",		&Parser<ValueType>::Tanh);
+	InsertFunctionToTable("tgh",		&Parser<ValueType>::Tanh);
+	InsertFunctionToTable("coth",		&Parser<ValueType>::Coth);
+	InsertFunctionToTable("ctgh",		&Parser<ValueType>::Coth);
+	InsertFunctionToTable("root",		&Parser<ValueType>::Root);
+	InsertFunctionToTable("asinh",		&Parser<ValueType>::ASinh);
+	InsertFunctionToTable("acosh",		&Parser<ValueType>::ACosh);
+	InsertFunctionToTable("atanh",		&Parser<ValueType>::ATanh);
+	InsertFunctionToTable("atgh",		&Parser<ValueType>::ATanh);
+	InsertFunctionToTable("acoth",		&Parser<ValueType>::ACoth);
+	InsertFunctionToTable("actgh",		&Parser<ValueType>::ACoth);
+	InsertFunctionToTable("bitand",		&Parser<ValueType>::BitAnd);
+	InsertFunctionToTable("bitor",		&Parser<ValueType>::BitOr);
+	InsertFunctionToTable("bitxor",		&Parser<ValueType>::BitXor);
+	InsertFunctionToTable("band",		&Parser<ValueType>::BitAnd);
+	InsertFunctionToTable("bor",		&Parser<ValueType>::BitOr);
+	InsertFunctionToTable("bxor",		&Parser<ValueType>::BitXor);
+	InsertFunctionToTable("sum",		&Parser<ValueType>::Sum);
+	InsertFunctionToTable("avg",		&Parser<ValueType>::Avg);
+	InsertFunctionToTable("frac",		&Parser<ValueType>::Frac);
+}
+
+
+/*!
+	this method creates the table of variables
+*/
+void CreateVariablesTable()
+{
+	InsertVariableToTable("pi", &ValueType::SetPi);
+	InsertVariableToTable("e",  &ValueType::SetE);
+}
+
+
+/*!
+	converting from a big letter to a small one
+*/
+int ToLowerCase(int c)
+{
+	if( c>='A' && c<='Z' )
+		return c - 'A' + 'a';
+
+return c;
+}
+
+
+/*!
+	this method read the name of a variable or a function
+	
+		'result' will be the name of a variable or a function
+		function return 'false' if this name is the name of a variable
+		or function return 'true' if this name is the name of a function
+
+	what should be returned is tested just by a '(' character that means if there's
+	a '(' character after a name that function returns 'true'
+*/
+bool ReadName(std::string & result)
+{
+int character;
+
+
+	result.erase();
+	character = *pstring;
+
+	/*
+		the first letter must be from range 'a' - 'z' or 'A' - 'Z'
+	*/
+	if( ! (( character>='a' && character<='z' ) || ( character>='A' && character<='Z' )) )
+		Error( err_unknown_character );
+
+
+	do
+	{
+		result   += static_cast<char>( character );
+		character = * ++pstring;
+	}
+	while(	(character>='a' && character<='z') ||
+			(character>='A' && character<='Z') ||
+			(character>='0' && character<='9') ||
+			character=='_' );
+	
+
+	SkipWhiteCharacters();
+	
+
+	/*
+		if there's a character '(' that means this name is a name of a function
+	*/
+	if( *pstring == '(' )
+	{
+		++pstring;
+		return true;
+	}
+	
+	
+return false;
+}
+
+
+/*!
+	we're checking whether the first character is '-' or '+'
+	if it is we'll return 'true' and if it is equally '-' we'll set the 'sign' member of 'result'
+*/
+bool TestSign(Item & result)
+{
+	SkipWhiteCharacters();
+	result.sign = false;
+
+	if( *pstring == '-' || *pstring == '+' )
+	{
+		if( *pstring == '-' )
+			result.sign = true;
+
+		++pstring;
+
+	return true;
+	}
+
+return false;
+}
+
+
+/*!
+	we're reading the name of a variable or a function
+	if is there a function we'll return 'true'
+*/
+bool ReadVariableOrFunction(Item & result)
+{
+std::string name;
+bool is_it_name_of_function = ReadName(name);
+
+	if( is_it_name_of_function )
+	{
+		/*
+			we've read the name of a function
+		*/
+		result.function_name = name;
+		result.type     = Item::first_bracket;
+		result.function = true;
+	}
+	else
+	{
+		/*
+			we've read the name of a variable and we're getting its value now
+		*/
+		result.value = GetValueOfVariable( name );
+	}
+
+return is_it_name_of_function;
+}
+
+
+
+
+/*!
+	we're reading a numerical value directly from the string
+*/
+void ReadValue(Item & result, int reading_base)
+{
+const char * new_stack_pointer;
+bool value_read;
+Conv conv;
+
+	conv.base   = reading_base;
+	conv.comma  = comma;
+	conv.comma2 = comma2;
+	conv.group  = group;
+
+	uint carry = result.value.FromString(pstring, conv, &new_stack_pointer, &value_read);
+	pstring    = new_stack_pointer;
+
+	if( carry )
+		Error( err_overflow );
+
+	if( !value_read )
+		Error( err_unknown_character );
+}
+
+
+/*!
+	this method returns true if 'character' is a proper first digit for the value (or a comma -- can be first too)
+*/
+bool ValueStarts(int character, int base)
+{
+	if( character == comma )
+		return true;
+
+	if( comma2!=0 && character==comma2 )
+		return true;
+
+	if( Misc::CharToDigit(character, base) != -1 )
+		return true;
+
+return false;
+}
+
+
+/*!
+	we're reading the item
+  
+	return values:
+		0 - all ok, the item is successfully read
+		1 - the end of the string (the item is not read)
+		2 - the final bracket ')'
+*/
+int ReadValueVariableOrFunction(Item & result)
+{
+bool it_was_sign = false;
+int  character;
+
+
+	if( TestSign(result) )
+		// 'result.sign' was set as well
+		it_was_sign = true;
+
+	SkipWhiteCharacters();
+	character = ToLowerCase( *pstring );
+
+
+	if( character == 0 )
+	{
+		if( it_was_sign )
+			// at the end of the string a character like '-' or '+' has left
+			Error( err_unexpected_end );
+
+		// there's the end of the string here
+		return 1;
+	}
+	else
+	if( character == '(' )
+	{
+		// we've got a normal bracket (not a function)
+		result.type = Item::first_bracket;
+		result.function = false;
+		++pstring;
+
+	return 0;
+	}
+	else
+	if( character == ')' )
+	{
+		// we've got a final bracket
+		// (in this place we can find a final bracket only when there are empty brackets
+		// without any values inside or with a sign '-' or '+' inside)
+
+		if( it_was_sign )
+			Error( err_unexpected_final_bracket );
+
+		result.type = Item::last_bracket;
+
+		// we don't increment 'pstring', this final bracket will be read next by the 
+		// 'ReadOperatorAndCheckFinalBracket(...)' method
+
+	return 2;
+	}
+	else
+	if( character == '#' )
+	{
+		++pstring;
+		SkipWhiteCharacters();
+
+		// after '#' character we do not allow '-' or '+' (can be white characters)
+		if(	ValueStarts(*pstring, 16) )
+			ReadValue( result, 16 );
+		else
+			Error( err_unknown_character );
+	}
+	else
+	if( character == '&' )
+	{
+		++pstring;
+		SkipWhiteCharacters();
+
+		// after '&' character we do not allow '-' or '+' (can be white characters)
+		if(	ValueStarts(*pstring, 2) )
+			ReadValue( result, 2 );
+		else
+			Error( err_unknown_character );
+	}
+	else
+	if(	ValueStarts(character, base) )
+	{
+		ReadValue( result, base );
+	}
+	else
+	if( character>='a' && character<='z' )
+	{
+		if( ReadVariableOrFunction(result) )
+			// we've read the name of a function
+			return 0;
+	}
+	else
+		Error( err_unknown_character );
+
+
+
+	/*
+		we've got a value in the 'result'
+		this value is from a variable or directly from the string
+	*/
+	result.type = Item::numerical_value;
+	
+	if( result.sign )
+	{
+		result.value.ChangeSign();
+		result.sign = false;
+	}
+	
+
+return 0;
+}
+
+
+void InsertOperatorToTable(const char * name, typename MatOperator::Type type)
+{
+	operators_table.insert( std::make_pair(std::string(name), type) );
+}
+
+
+/*!
+	this method creates the table of operators
+*/
+void CreateMathematicalOperatorsTable()
+{
+	InsertOperatorToTable("||", MatOperator::lor);
+	InsertOperatorToTable("&&", MatOperator::land);
+	InsertOperatorToTable("!=", MatOperator::neq);
+	InsertOperatorToTable("==", MatOperator::eq);
+	InsertOperatorToTable(">=", MatOperator::get);
+	InsertOperatorToTable("<=", MatOperator::let);
+	InsertOperatorToTable(">",  MatOperator::gt);
+	InsertOperatorToTable("<",  MatOperator::lt);
+	InsertOperatorToTable("-",  MatOperator::sub);
+	InsertOperatorToTable("+",  MatOperator::add);
+	InsertOperatorToTable("/",  MatOperator::div);
+	InsertOperatorToTable("*",  MatOperator::mul);
+	InsertOperatorToTable("^",  MatOperator::pow);
+}
+
+
+/*!
+	returns true if 'str2' is the substring of str1
+
+	e.g.
+	true when str1="test" and str2="te"
+*/
+bool IsSubstring(const std::string & str1, const std::string & str2)
+{
+	if( str2.length() > str1.length() )
+		return false;
+
+	for(typename std::string::size_type i=0 ; i<str2.length() ; ++i)
+		if( str1[i] != str2[i] )
+			return false;
+
+return true;
+}
+
+
+/*!
+	this method reads a mathematical (or logical) operator
+*/
+void ReadMathematicalOperator(Item & result)
+{
+std::string oper;
+typename OperatorsTable::iterator iter_old, iter_new;
+
+	iter_old = operators_table.end();
+
+	for( ; true ; ++pstring )
+	{
+		oper += *pstring;
+		iter_new = operators_table.lower_bound(oper);
+		
+		if( iter_new == operators_table.end() || !IsSubstring(iter_new->first, oper) )
+		{
+			oper.erase( --oper.end() ); // we've got mininum one element
+
+			if( iter_old != operators_table.end() && iter_old->first == oper )
+			{
+				result.type = Item::mat_operator;
+				result.moperator.SetType( iter_old->second );
+				break;
+			}
+			
+			Error( err_unknown_operator );
+		}
+	
+		iter_old = iter_new;
+	}
+}
+
+
+/*!
+	this method makes a calculation for the percentage operator
+	e.g.
+	1000-50% = 1000-(1000*0,5) = 500
+*/
+void OperatorPercentage()
+{
+	if( stack_index < 3										||
+		stack[stack_index-1].type != Item::numerical_value	||
+		stack[stack_index-2].type != Item::mat_operator		||
+		stack[stack_index-3].type != Item::numerical_value	)
+		Error(err_percent_from);
+
+	++pstring;
+	SkipWhiteCharacters();
+
+	uint c = 0;
+	c += stack[stack_index-1].value.Div(100);
+	c += stack[stack_index-1].value.Mul(stack[stack_index-3].value);
+
+	if( c )
+		Error(err_overflow);
+}
+
+
+/*!
+	this method reads a mathematic operators
+	or the final bracket or the semicolon operator
+
+	return values:
+		0 - ok
+		1 - the string is finished
+*/
+int ReadOperator(Item & result)
+{
+	SkipWhiteCharacters();
+
+	if( *pstring == '%' )
+		OperatorPercentage();
+
+
+	if( *pstring == 0 )
+		return 1;
+	else
+	if( *pstring == ')' )
+	{
+		result.type = Item::last_bracket;
+		++pstring;
+	}
+	else
+	if( *pstring == ';' || (param_sep!=0 && *pstring==param_sep) )
+	{
+		result.type = Item::semicolon;
+		++pstring;
+	}
+	else
+	if( (*pstring>='a' && *pstring<='z') || (*pstring>='A' && *pstring<='Z') )
+	{
+		// short mul (without any operators)
+
+		result.type = Item::mat_operator;
+		result.moperator.SetType( MatOperator::shortmul );
+	}
+	else
+		ReadMathematicalOperator(result);
+
+return 0;
+}
+
+
+
+/*!
+	this method is making the standard mathematic operation like '-' '+' '*' '/' and '^'
+
+	the operation is made between 'value1' and 'value2'
+	the result of this operation is stored in the 'value1'
+*/
+void MakeStandardMathematicOperation(ValueType & value1, typename MatOperator::Type mat_operator,
+									const ValueType & value2)
+{
+uint res;
+
+	calculated = true;
+
+	switch( mat_operator )
+	{
+	case MatOperator::land:
+		(!value1.IsZero() && !value2.IsZero()) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::lor:
+		(!value1.IsZero() || !value2.IsZero()) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::eq:
+		(value1 == value2) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::neq:
+		(value1 != value2) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::lt:
+		(value1 < value2) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::gt:
+		(value1 > value2) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::let:
+		(value1 <= value2) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::get:
+		(value1 >= value2) ? value1.SetOne() : value1.SetZero();
+		break;
+
+	case MatOperator::sub:
+		if( value1.Sub(value2) ) Error( err_overflow );
+		break;
+
+	case MatOperator::add:
+		if( value1.Add(value2) ) Error( err_overflow );
+		break;
+
+	case MatOperator::mul:
+	case MatOperator::shortmul:
+		if( value1.Mul(value2) ) Error( err_overflow );
+		break;
+
+	case MatOperator::div:
+		if( value2.IsZero() )    Error( err_division_by_zero );
+		if( value1.Div(value2) ) Error( err_overflow );
+		break;
+
+	case MatOperator::pow:
+		res = value1.Pow( value2 );
+
+		if( res == 1 ) Error( err_overflow );
+		else
+		if( res == 2 ) Error( err_improper_argument );
+
+		break;
+
+	default:
+		/*
+			on the stack left an unknown operator but we had to recognize its before
+			that means there's an error in our algorithm
+		*/
+		Error( err_internal_error );
+	}
+}
+
+
+
+
+/*!
+	this method is trying to roll the stack up with the operator's priority
+
+	for example if there are:
+		"1 - 2 +" 
+	we can subtract "1-2" and the result store on the place where is '1' and copy the last
+	operator '+', that means there'll be '-1+' on our stack
+
+	but if there are:
+		"1 - 2 *"
+	we can't roll the stack up because the operator '*' has greater priority than '-'
+*/
+void TryRollingUpStackWithOperatorPriority()
+{
+	while(	stack_index>=4 &&
+			stack[stack_index-4].type == Item::numerical_value &&
+			stack[stack_index-3].type == Item::mat_operator    &&
+			stack[stack_index-2].type == Item::numerical_value &&
+			stack[stack_index-1].type == Item::mat_operator    &&
+			(
+				(
+					// the first operator has greater priority
+					stack[stack_index-3].moperator.GetPriority() > stack[stack_index-1].moperator.GetPriority()
+				) ||
+				(
+					// or both operators have the same priority and the first operator is not right associative
+					stack[stack_index-3].moperator.GetPriority() == stack[stack_index-1].moperator.GetPriority() &&
+					stack[stack_index-3].moperator.GetAssoc()    == MatOperator::non_right
+				)
+			)
+		 )
+	{
+		MakeStandardMathematicOperation(stack[stack_index-4].value,
+										stack[stack_index-3].moperator.GetType(),
+										stack[stack_index-2].value);
+
+
+		/*
+			copying the last operator and setting the stack pointer to the correct value
+		*/
+		stack[stack_index-3] = stack[stack_index-1];
+		stack_index -= 2;
+	}
+}
+
+
+/*!
+	this method is trying to roll the stack up without testing any operators
+
+	for example if there are:
+		"1 - 2" 
+	there'll be "-1" on our stack
+*/
+void TryRollingUpStack()
+{
+	while(	stack_index >= 3 &&
+			stack[stack_index-3].type == Item::numerical_value &&
+			stack[stack_index-2].type == Item::mat_operator &&
+			stack[stack_index-1].type == Item::numerical_value )
+	{
+		MakeStandardMathematicOperation(	stack[stack_index-3].value,
+											stack[stack_index-2].moperator.GetType(),
+											stack[stack_index-1].value );
+
+		stack_index -= 2;
+	}
+}
+
+
+/*!
+	this method is reading a value or a variable or a function
+	(the normal first bracket as well) and push it into the stack
+*/
+int ReadValueVariableOrFunctionAndPushItIntoStack(Item & temp)
+{
+int code = ReadValueVariableOrFunction( temp );
+	
+	if( code == 0 )
+	{
+		if( stack_index < stack.size() )
+			stack[stack_index] = temp;
+		else
+			stack.push_back( temp );
+
+		++stack_index;
+	}
+
+	if( code == 2 )
+		// there was a final bracket, we didn't push it into the stack 
+		// (it'll be read by the 'ReadOperatorAndCheckFinalBracket' method next)
+		code = 0;
+
+
+return code;
+}
+
+
+
+/*!
+	this method calculate how many parameters there are on the stack
+	and the index of the first parameter
+
+	if there aren't any parameters on the stack this method returns
+	'size' equals zero and 'index' pointing after the first bracket
+	(on non-existend element)
+*/
+void HowManyParameters(int & size, int & index)
+{
+	size  = 0;
+	index = stack_index;
+
+	if( index == 0 )
+		// we haven't put a first bracket on the stack
+		Error( err_unexpected_final_bracket );
+
+
+	if( stack[index-1].type == Item::first_bracket )
+		// empty brackets
+		return;
+
+	for( --index ; index>=1 ; index-=2 )
+	{
+		if( stack[index].type != Item::numerical_value )
+		{
+			/*
+				this element must be 'numerical_value', if not that means 
+				there's an error in our algorithm
+			*/
+			Error( err_internal_error );
+		}
+
+		++size;
+
+		if( stack[index-1].type != Item::semicolon )
+			break;
+	}
+
+	if( index<1 || stack[index-1].type != Item::first_bracket )
+	{
+		/*
+			we haven't put a first bracket on the stack
+		*/
+		Error( err_unexpected_final_bracket );
+	}
+}
+
+
+/*!
+	this method is being called when the final bracket ')' is being found
+
+	this method's rolling the stack up, counting how many parameters there are
+	on the stack and if there was a function it's calling the function
+*/
+void RollingUpFinalBracket()
+{
+int amount_of_parameters;
+int index;
+
+	
+	if( stack_index<1 ||
+		(stack[stack_index-1].type != Item::numerical_value &&
+		 stack[stack_index-1].type != Item::first_bracket)
+	  )
+		Error( err_unexpected_final_bracket );
+	
+
+	TryRollingUpStack();
+	HowManyParameters(amount_of_parameters, index);
+
+	// 'index' will be greater than zero
+	// 'amount_of_parameters' can be zero
+
+
+	if( amount_of_parameters==0 && !stack[index-1].function )
+		Error( err_unexpected_final_bracket );
+
+
+	bool was_sign = stack[index-1].sign;
+
+
+	if( stack[index-1].function )
+	{
+		// the result of a function will be on 'stack[index-1]'
+		// and then at the end we'll set the correct type (numerical value) of this element
+		CallFunction(stack[index-1].function_name, amount_of_parameters, index);
+	}
+	else
+	{
+		/*
+			there was a normal bracket (not a funcion)
+		*/
+		if( amount_of_parameters != 1 )
+			Error( err_unexpected_semicolon_operator );
+
+
+		/*
+			in the place where is the bracket we put the result
+		*/
+		stack[index-1] = stack[index];
+	}
+
+
+	/*
+		if there was a '-' character before the first bracket
+		we change the sign of the expression
+	*/
+	stack[index-1].sign = false;
+
+	if( was_sign )
+		stack[index-1].value.ChangeSign();
+
+	stack[index-1].type = Item::numerical_value;
+
+
+	/*
+		the pointer of the stack will be pointing on the next (non-existing now) element
+	*/
+	stack_index = index;
+}
+
+
+/*!
+	this method is putting the operator on the stack
+*/
+
+void PushOperatorIntoStack(Item & temp)
+{
+	if( stack_index < stack.size() )
+		stack[stack_index] = temp;
+	else
+		stack.push_back( temp );
+
+	++stack_index;
+}
+
+
+
+/*!
+	this method is reading a operator and if it's a final bracket
+	it's calling RollingUpFinalBracket() and reading a operator again
+*/
+int ReadOperatorAndCheckFinalBracket(Item & temp)
+{
+	do
+	{
+		if( ReadOperator(temp) == 1 )
+		{
+			/*
+				the string is finished
+			*/
+		return 1;
+		}
+
+		if( temp.type == Item::last_bracket )
+			RollingUpFinalBracket();
+
+	}
+	while( temp.type == Item::last_bracket );
+
+return 0;
+}
+
+
+/*!
+	we check wheter there are only numerical value's or 'semicolon' operators on the stack
+*/
+void CheckIntegrityOfStack()
+{
+	for(unsigned int i=0 ; i<stack_index; ++i)
+	{
+		if( stack[i].type != Item::numerical_value &&
+			stack[i].type != Item::semicolon)
+		{
+			/*
+				on the stack we must only have 'numerical_value' or 'semicolon' operator
+				if there is something another that means
+				we probably didn't close any of the 'first' bracket
+			*/
+			Error( err_stack_not_clear );
+		}
+	}
+}
+
+
+
+/*!
+	the main loop of parsing
+*/
+void Parse()
+{
+Item item;	
+int result_code;
+
+
+	while( true )
+	{
+		if( pstop_calculating && pstop_calculating->WasStopSignal() )
+			Error( err_interrupt );
+
+		result_code = ReadValueVariableOrFunctionAndPushItIntoStack( item );
+
+		if( result_code == 0 )
+		{
+			if( item.type == Item::first_bracket )
+				continue;
+			
+			result_code = ReadOperatorAndCheckFinalBracket( item );
+		}
+	
+		
+		if( result_code==1 || item.type==Item::semicolon )
+		{
+			/*
+				the string is finished or the 'semicolon' operator has appeared
+			*/
+
+			if( stack_index == 0 )
+				Error( err_nothing_has_read );
+			
+			TryRollingUpStack();
+
+			if( result_code == 1 )
+			{
+				CheckIntegrityOfStack();
+
+			return;
+			}
+		}			
+	
+
+		PushOperatorIntoStack( item );
+		TryRollingUpStackWithOperatorPriority();
+	}
+}
+
+/*!
+	this method is called at the end of the parsing process
+
+	on our stack we can have another value than 'numerical_values' for example
+	when someone use the operator ';' in the global scope or there was an error during
+	parsing and the parser hasn't finished its job
+
+	if there was an error the stack is cleaned up now
+	otherwise we resize stack and leave on it only 'numerical_value' items
+*/
+void NormalizeStack()
+{
+	if( error!=err_ok || stack_index==0 )
+	{
+		stack.clear();
+		return;
+	}
+	
+	
+	/*
+		'stack_index' tell us how many elements there are on the stack,
+		we must resize the stack now because 'stack_index' is using only for parsing
+		and stack has more (or equal) elements than value of 'stack_index'
+	*/
+	stack.resize( stack_index );
+
+	for(uint i=stack_index-1 ; i!=uint(-1) ; --i)
+	{
+		if( stack[i].type != Item::numerical_value )
+			stack.erase( stack.begin() + i );
+	}
+}
+
+
+public:
+
+
+/*!
+	the default constructor
+*/
+Parser(): default_stack_size(100)
+{
+	pstop_calculating = 0;
+	puser_variables   = 0;
+	puser_functions   = 0;
+	pfunction_local_variables = 0;
+	base              = 10;
+	deg_rad_grad      = 1;
+	error             = err_ok;
+	group             = 0;
+	comma             = '.';
+	comma2            = ',';
+	param_sep         = 0;
+
+	CreateFunctionsTable();
+	CreateVariablesTable();
+	CreateMathematicalOperatorsTable();
+}
+
+
+/*!
+	the assignment operator
+*/
+Parser<ValueType> & operator=(const Parser<ValueType> & p)
+{
+	pstop_calculating = p.pstop_calculating;
+	puser_variables   = p.puser_variables;
+	puser_functions   = p.puser_functions;
+	pfunction_local_variables = 0;
+	base              = p.base;
+	deg_rad_grad      = p.deg_rad_grad;
+	error             = p.error;
+	group             = p.group;
+	comma             = p.comma;
+	comma2            = p.comma2;
+	param_sep         = p.param_sep;
+
+	/*
+		we don't have to call 'CreateFunctionsTable()' etc.
+		we can only copy these tables
+	*/
+	functions_table   = p.functions_table;
+	variables_table   = p.variables_table;
+	operators_table   = p.operators_table;
+
+	visited_variables = p.visited_variables;
+	visited_functions = p.visited_functions;
+
+return *this;
+}
+
+
+/*!
+	the copying constructor
+*/
+Parser(const Parser<ValueType> & p): default_stack_size(p.default_stack_size)
+{
+	operator=(p);
+}
+
+
+/*!
+	the new base of mathematic system
+	default is 10
+*/
+void SetBase(int b)
+{
+	if( b>=2 && b<=16 )
+		base = b;
+}
+
+
+/*!
+	the unit of angles used in: sin,cos,tan,cot,asin,acos,atan,acot
+	0 - deg
+	1 - rad (default)
+	2 - grad
+*/
+void SetDegRadGrad(int angle)
+{
+	if( angle >= 0 || angle <= 2 )
+		deg_rad_grad = angle;
+}
+
+/*!
+	this method sets a pointer to the object which tell us whether we should stop
+	calculations
+*/
+void SetStopObject(const volatile StopCalculating * ps)
+{
+	pstop_calculating = ps;
+}
+
+
+/*!
+	this method sets the new table of user-defined variables
+	if you don't want any other variables just put zero value into the 'puser_variables' variable
+
+	(you can have only one table at the same time)
+*/
+void SetVariables(const Objects * pv)
+{
+	puser_variables = pv;
+}
+
+
+/*!
+	this method sets the new table of user-defined functions
+	if you don't want any other functions just put zero value into the 'puser_functions' variable
+
+	(you can have only one table at the same time)
+*/
+void SetFunctions(const Objects * pf)
+{
+	puser_functions = pf;
+}
+
+
+/*!
+	setting the group character
+	default zero (not used)
+*/
+void SetGroup(int g)
+{
+	group = g;
+}
+
+
+/*!
+	setting the main comma operator and the additional comma operator
+	the additional operator can be zero (which means it is not used)
+	default are: '.' and ','
+*/
+void SetComma(int c, int c2 = 0)
+{
+	comma  = c;
+	comma2 = c2;
+}
+
+
+/*!
+	setting an additional character which is used as a parameters separator
+	the main parameters separator is a semicolon (is used always)
+
+	this character is used also as a global separator
+*/
+void SetParamSep(int s)
+{
+	param_sep = s;
+}
+
+
+/*!
+	the main method using for parsing string
+*/
+ErrorCode Parse(const char * str)
+{
+	stack_index  = 0;
+	pstring      = str;
+	error        = err_ok;
+	calculated   = false;
+
+	stack.resize( default_stack_size );
+
+	try
+	{
+		Parse();
+	}
+	catch(ErrorCode c)
+	{
+		error = c;
+		calculated = false;
+	}
+
+	NormalizeStack();
+
+return error;
+}
+
+
+/*!
+	the main method using for parsing string
+*/
+ErrorCode Parse(const std::string & str)
+{
+	return Parse(str.c_str());
+}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+/*!
+	the main method using for parsing string
+*/
+ErrorCode Parse(const wchar_t * str)
+{
+	Misc::AssignString(wide_to_ansi, str);
+
+return Parse(wide_to_ansi.c_str());
+
+	// !! wide_to_ansi clearing can be added here
+}
+
+
+/*!
+	the main method using for parsing string
+*/
+ErrorCode Parse(const std::wstring & str)
+{
+	return Parse(str.c_str());
+}
+
+#endif
+
+
+/*!
+	this method returns true is something was calculated
+	(at least one mathematical operator was used or a function or variable)
+	e.g. true if the string to Parse() looked like this:
+	"1+1"
+	"2*3"
+	"sin(5)"
+
+	if the string was e.g. "678" the result is false
+*/
+bool Calculated()
+{
+	return calculated;
+}
+
+
+/*!
+	initializing coefficients used when calculating the gamma (or factorial) function
+	this speed up the next calculations
+	you don't have to call this method explicitly
+	these coefficients will be calculated when needed
+*/
+void InitCGamma()
+{
+	cgamma.InitAll();
+}
+
+
+};
+
+
+
+} // namespace
+
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmaththreads.h b/src/boost/geometry/extensions/contrib/ttmath/ttmaththreads.h
new file mode 100644
index 0000000..586227f
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmaththreads.h
@@ -0,0 +1,250 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2009, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef headerfilettmaththreads
+#define headerfilettmaththreads
+
+#include "ttmathtypes.h"
+
+#ifdef TTMATH_WIN32_THREADS
+#include <windows.h>
+#include <cstdio>
+#endif
+
+#ifdef TTMATH_POSIX_THREADS
+#include <pthread.h>
+#endif
+
+
+
+/*!
+	\file ttmaththreads.h
+    \brief Some objects used in multithreads environment
+*/
+
+
+/*
+	this is a simple skeleton of a program in multithreads environment:
+
+	#define TTMATH_MULTITHREADS
+	#include<ttmath/ttmath.h>
+	
+	TTMATH_MULTITHREADS_HELPER
+
+	int main()
+	{
+	[...]
+	}
+
+	make sure that macro TTMATH_MULTITHREADS is defined and (somewhere in *.cpp file)
+	use TTMATH_MULTITHREADS_HELPER macro (outside of any classes/functions/namespaces scope)
+*/
+
+
+namespace ttmath
+{
+
+
+#ifdef TTMATH_WIN32_THREADS
+
+	/*
+		we use win32 threads
+	*/
+
+
+	/*!
+		in multithreads environment you should use TTMATH_MULTITHREADS_HELPER macro
+		somewhere in *.cpp file
+
+		(at the moment in win32 this macro does nothing)
+	*/
+	#define TTMATH_MULTITHREADS_HELPER
+
+
+	/*!
+		objects of this class are used to synchronize
+	*/
+	class ThreadLock
+	{
+		HANDLE mutex_handle;
+
+
+		void CreateName(char * buffer) const
+		{
+			#ifdef _MSC_VER
+			#pragma warning (disable : 4996)
+			// warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead.
+			#endif
+
+			sprintf(buffer, "TTMATH_LOCK_%ul", (unsigned long)GetCurrentProcessId());
+
+			#ifdef _MSC_VER
+			#pragma warning (default : 4996)
+			#endif
+		}
+
+
+	public:
+
+		bool Lock()
+		{
+		char buffer[50];
+
+			CreateName(buffer);
+			mutex_handle = CreateMutexA(0, false, buffer);
+
+			if( mutex_handle == 0 )
+				return false;
+
+			WaitForSingleObject(mutex_handle, INFINITE);
+
+		return true;
+		}
+
+
+		ThreadLock()
+		{
+			mutex_handle = 0;
+		}
+
+
+		~ThreadLock()
+		{
+			if( mutex_handle != 0 )
+			{
+				ReleaseMutex(mutex_handle);
+				CloseHandle(mutex_handle);
+			}
+		}
+	};
+
+#endif  // #ifdef TTMATH_WIN32_THREADS
+
+
+
+
+
+#ifdef TTMATH_POSIX_THREADS
+
+	/*
+		we use posix threads
+	*/
+
+
+	/*!
+		in multithreads environment you should use TTMATH_MULTITHREADS_HELPER macro
+		somewhere in *.cpp file
+		(this macro defines a pthread_mutex_t object used by TTMath library)
+	*/
+	#define TTMATH_MULTITHREADS_HELPER                          \
+	namespace ttmath                                            \
+	{                                                           \
+	pthread_mutex_t ttmath_mutex = PTHREAD_MUTEX_INITIALIZER;   \
+	}
+
+
+	/*!
+		ttmath_mutex will be defined by TTMATH_MULTITHREADS_HELPER macro 
+	*/
+	extern pthread_mutex_t ttmath_mutex;
+
+
+	/*!
+		objects of this class are used to synchronize
+	*/
+	class ThreadLock
+	{
+	public:
+
+		bool Lock()
+		{
+			if( pthread_mutex_lock(&ttmath_mutex) != 0 )
+				return false;
+
+		return true;
+		}
+
+
+		~ThreadLock()
+		{
+			pthread_mutex_unlock(&ttmath_mutex);
+		}
+	};
+
+#endif // #ifdef TTMATH_POSIX_THREADS
+
+
+
+
+#if !defined(TTMATH_POSIX_THREADS) && !defined(TTMATH_WIN32_THREADS)
+
+	/*!
+		we don't use win32 and pthreads
+	*/
+
+	/*!
+	*/
+	#define TTMATH_MULTITHREADS_HELPER
+
+
+	/*!
+		objects of this class are used to synchronize
+		actually we don't synchronize, the method Lock() returns always 'false'
+	*/
+	class ThreadLock
+	{
+	public:
+
+		bool Lock()
+		{
+			return false;
+		}
+	};
+
+
+#endif // #if !defined(TTMATH_POSIX_THREADS) && !defined(TTMATH_WIN32_THREADS)
+
+
+
+
+
+} // namespace
+
+#endif
+
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathtypes.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathtypes.h
new file mode 100644
index 0000000..539c100
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathtypes.h
@@ -0,0 +1,675 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2011, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef headerfilettmathtypes
+#define headerfilettmathtypes
+
+/*!
+	\file ttmathtypes.h
+    \brief constants used in the library
+    
+    As our library is written in header files (templates) we cannot use
+	constants like 'const int' etc. because we should have some source files
+	*.cpp to define this variables. Only what we can have are constants
+	defined by #define preprocessor macros.
+
+	All macros are preceded by TTMATH_ prefix
+*/
+
+
+#include <stdexcept>
+#include <sstream>
+#include <vector>
+
+#ifndef _MSC_VER
+#include <stdint.h>
+// for uint64_t and int64_t on a 32 bit platform
+#endif
+
+
+
+/*!
+	the version of the library
+
+	TTMATH_PRERELEASE_VER is either zero or one
+	zero means that this is the release version of the library
+	(one means something like beta)
+*/
+#define TTMATH_MAJOR_VER		0
+#define TTMATH_MINOR_VER		9
+#define TTMATH_REVISION_VER		3
+
+#define TTMATH_PRERELEASE_VER	1
+
+
+
+/*!
+	you can define a platform explicitly by defining either
+	TTMATH_PLATFORM32 or TTMATH_PLATFORM64 macro
+*/
+#if !defined TTMATH_PLATFORM32 && !defined TTMATH_PLATFORM64
+
+	#if !defined _M_X64 && !defined __x86_64__
+
+		/*
+			other platforms than x86 and amd64 are not recognized at the moment
+			so you should set TTMATH_PLATFORMxx manually
+		*/
+
+		// we're using a 32bit platform
+		#define TTMATH_PLATFORM32
+
+	#else
+
+		//	we're using a 64bit platform
+		#define TTMATH_PLATFORM64
+
+	#endif
+
+#endif
+
+
+/*!
+	asm version of the library is available by default only for:
+	x86 and amd64 platforms and for Microsoft Visual and GCC compilers
+
+	but you can force using asm version (the same asm as for Microsoft Visual)
+	by defining TTMATH_FORCEASM macro
+	you have to be sure that your compiler accept such an asm format
+*/
+#ifndef TTMATH_FORCEASM
+
+	#if !defined __i386__  && !defined _X86_ && !defined  _M_IX86 && !defined __x86_64__  && !defined _M_X64
+		/*!
+			x86 architecture:
+			__i386__    defined by GNU C
+			_X86_  	    defined by MinGW32
+			_M_IX86     defined by Visual Studio, Intel C/C++, Digital Mars and Watcom C/C++
+
+			amd64 architecture:
+			__x86_64__  defined by GNU C and Sun Studio
+			_M_X64  	defined by Visual Studio
+
+			asm version is available only for x86 or amd64 platforms
+		*/
+		#define TTMATH_NOASM
+	#endif
+
+
+
+	#if !defined _MSC_VER && !defined __GNUC__
+		/*!
+			another compilers than MS VC or GCC by default use no asm version
+		*/
+		#define TTMATH_NOASM
+	#endif
+
+#endif
+
+
+namespace ttmath
+{
+
+
+#ifdef TTMATH_PLATFORM32
+
+	/*!
+		on 32bit platforms one word (uint, sint) will be equal 32bits
+	*/
+	typedef unsigned int uint;
+	typedef signed   int sint;
+
+	/*!
+		on 32 bit platform ulint and slint will be equal 64 bits
+	*/
+	#ifdef _MSC_VER
+		// long long on MS Windows (Visual and GCC mingw compilers) have 64 bits
+		// stdint.h is not available on Visual Studio prior to VS 2010 version
+		typedef unsigned long long int ulint;
+		typedef signed   long long int slint;
+	#else
+		// we do not use 'long' here because there is a difference in unix and windows
+		// environments: in unix 'long' has 64 bits but in windows it has only 32 bits
+		typedef uint64_t ulint;
+		typedef int64_t  slint;
+	#endif
+
+	/*!
+		how many bits there are in the uint type
+	*/
+	#define TTMATH_BITS_PER_UINT 32u
+
+	/*!
+		the mask for the highest bit in the unsigned 32bit word (2^31)
+	*/
+	#define TTMATH_UINT_HIGHEST_BIT 2147483648u
+
+	/*!
+		the max value of the unsigned 32bit word (2^32 - 1)
+		(all bits equal one)
+	*/
+	#define TTMATH_UINT_MAX_VALUE 4294967295u
+
+	/*!
+		the number of words (32bit words on 32bit platform)
+		which are kept in built-in variables for a Big<> type
+		(these variables are defined in ttmathbig.h)
+	*/
+	#define TTMATH_BUILTIN_VARIABLES_SIZE 256u
+
+	/*!
+		this macro returns the number of machine words 
+		capable to hold min_bits bits
+		e.g. TTMATH_BITS(128) returns 4
+	*/
+	#define TTMATH_BITS(min_bits) ((min_bits-1)/32 + 1)
+
+#else
+
+	/*!
+		on 64bit platforms one word (uint, sint) will be equal 64bits
+	*/
+	#ifdef _MSC_VER
+		/* in VC 'long' type has 32 bits, __int64 is VC extension */
+		typedef unsigned __int64 uint;
+		typedef signed   __int64 sint;
+	#else
+		typedef unsigned long uint;
+		typedef signed   long sint;
+	#endif 
+
+	/*!
+		on 64bit platforms we do not define ulint and slint
+	*/
+
+	/*!
+		how many bits there are in the uint type
+	*/
+	#define TTMATH_BITS_PER_UINT 64ul
+
+	/*!
+		the mask for the highest bit in the unsigned 64bit word (2^63)
+	*/
+	#define TTMATH_UINT_HIGHEST_BIT 9223372036854775808ul
+
+	/*!
+		the max value of the unsigned 64bit word (2^64 - 1)
+		(all bits equal one)
+	*/
+	#define TTMATH_UINT_MAX_VALUE 18446744073709551615ul
+
+	/*!
+		the number of words (64bit words on 64bit platforms)
+		which are kept in built-in variables for a Big<> type
+		(these variables are defined in ttmathbig.h)
+	*/
+	#define TTMATH_BUILTIN_VARIABLES_SIZE 128ul
+
+	/*!
+		this macro returns the number of machine words 
+		capable to hold min_bits bits
+		e.g. TTMATH_BITS(128) returns 2
+	*/
+	#define TTMATH_BITS(min_bits) ((min_bits-1)/64 + 1)
+
+#endif
+}
+
+
+#if defined(TTMATH_MULTITHREADS) && !defined(TTMATH_MULTITHREADS_NOSYNC)
+	#if !defined(TTMATH_POSIX_THREADS) && !defined(TTMATH_WIN32_THREADS)
+
+		#if defined(_WIN32)
+			#define TTMATH_WIN32_THREADS
+		#elif defined(unix) || defined(__unix__) || defined(__unix)
+			#define TTMATH_POSIX_THREADS
+		#endif
+
+	#endif
+#endif
+
+
+
+/*!
+	this variable defines how many iterations are performed
+	during some kind of calculating when we're making any long formulas
+	(for example Taylor series)
+
+	it's used in ExpSurrounding0(...), LnSurrounding1(...), Sin0pi05(...), etc.
+
+	note! there'll not be so many iterations, iterations are stopped when
+	there is no sense to continue calculating (for example when the result
+	still remains unchanged after adding next series and we know that the next
+	series are smaller than previous ones)
+*/
+#define TTMATH_ARITHMETIC_MAX_LOOP 10000
+
+
+
+/*!
+	this is a limit when calculating Karatsuba multiplication
+	if the size of a vector is smaller than TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE
+	the Karatsuba algorithm will use standard schoolbook multiplication
+*/
+#ifdef TTMATH_DEBUG_LOG
+	// if TTMATH_DEBUG_LOG is defined then we should use the same size regardless of the compiler
+	#define TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE 3
+#else
+	#ifdef __GNUC__
+		#define TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE 3
+	#else
+		#define TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE 5
+	#endif
+#endif
+
+
+/*!
+	this is a special value used when calculating the Gamma(x) function
+	if x is greater than this value then the Gamma(x) will be calculated using
+	some kind of series
+
+	don't use smaller values than about 100
+*/
+#define TTMATH_GAMMA_BOUNDARY 2000
+
+
+
+
+
+namespace ttmath
+{
+
+	/*!
+		lib type codes:
+		  asm_vc_32   - with asm code designed for Microsoft Visual C++ (32 bits)
+		  asm_gcc_32  - with asm code designed for GCC (32 bits)
+		  asm_vc_64   - with asm for VC (64 bit)
+		  asm_gcc_64  - with asm for GCC (64 bit)
+		  no_asm_32   - pure C++ version (32 bit) - without any asm code
+		  no_asm_64   - pure C++ version (64 bit) - without any asm code
+	*/
+	enum LibTypeCode
+	{
+	  asm_vc_32 = 0,
+	  asm_gcc_32,
+	  asm_vc_64,
+	  asm_gcc_64,
+	  no_asm_32,
+	  no_asm_64
+	};
+
+
+	/*!
+		error codes
+	*/
+	enum ErrorCode
+	{
+		err_ok = 0,
+		err_nothing_has_read,
+		err_unknown_character,
+		err_unexpected_final_bracket,
+		err_stack_not_clear,
+		err_unknown_variable,
+		err_division_by_zero,
+		err_interrupt,
+		err_overflow,
+		err_unknown_function,
+		err_unknown_operator,
+		err_unexpected_semicolon_operator,
+		err_improper_amount_of_arguments,
+		err_improper_argument,
+		err_unexpected_end,
+		err_internal_error,
+		err_incorrect_name,
+		err_incorrect_value,
+		err_variable_exists,
+		err_variable_loop,
+		err_functions_loop,
+		err_must_be_only_one_value,
+		err_object_exists,
+		err_unknown_object,
+		err_still_calculating,
+		err_in_short_form_used_function,
+		err_percent_from
+	};
+
+
+	/*!
+		this struct is used when converting to/from a string
+		/temporarily only in Big::ToString() and Big::FromString()/
+	*/
+	struct Conv
+	{
+		/*!
+			base (radix) on which the value will be shown (or read)
+			default: 10
+		*/
+		uint base;
+
+
+		/*!
+			used only in Big::ToString()
+			if true the value will be always shown in the scientific mode, e.g: 123e+30
+			default: false
+		*/
+		bool scient;
+
+
+		/*!
+			used only in Big::ToString()
+			if scient is false then the value will be printed in the scientific mode
+			only if the exponent is greater than scien_from
+			default: 15
+		*/
+		sint scient_from;
+
+
+		/*!
+			if 'base_round' is true and 'base' is different from 2, 4, 8, or 16
+			and the result value is not an integer then we make an additional rounding
+			(after converting the last digit from the result is skipped)
+			default: true
+
+			e.g.
+			Conv c;
+			c.base_round = false;
+			Big<1, 1> a = "0.1";                       // decimal input
+			std::cout << a.ToString(c) << std::endl;   // the result is: 0.099999999
+		*/
+		bool base_round;
+
+
+		/*!
+			used only in Big::ToString()
+			tells how many digits after comma are possible
+			default: -1 which means all digits are printed
+
+			set it to zero if you want integer value only
+
+			for example when the value is:
+				12.345678 and 'round' is 4
+			then the result will be 
+				12.3457   (the last digit was rounded)
+		*/
+		sint round;
+
+
+		/*!
+			if true that not mattered digits in the mantissa will be cut off
+			(zero characters at the end -- after the comma operator)
+			e.g. 1234,78000 will be: 1234,78
+			default: true
+		*/
+		bool trim_zeroes;
+
+
+		/*!
+			the main comma operator (used when reading and writing)
+			default is a dot '.'
+		*/
+		uint comma;
+
+
+		/*!
+			additional comma operator (used only when reading) 
+			if you don't want it just set it to zero
+			default is a comma ','
+
+			this allowes you to convert from a value:
+			123.45 as well as from 123,45
+		*/
+		uint comma2;
+
+
+		/*!
+			it sets the character which is used for grouping
+			if group=' ' then: 1234,56789 will be printed as: 1 234,567 89
+
+			if you don't want grouping just set it to zero (which is default)
+		*/
+		uint group;
+
+
+		/*!
+			how many digits should be grouped (it is used if 'group' is non zero)
+			default: 3
+		*/
+		uint group_digits;
+
+
+		/*!
+		*/
+		uint group_exp; // not implemented yet
+
+
+
+
+		Conv()
+		{
+			// default values
+			base         = 10;
+			scient       = false;
+			scient_from  = 15;
+			base_round   = true;
+			round        = -1;
+			trim_zeroes  = true;
+			comma        = '.';
+			comma2       = ',';
+			group        = 0;
+			group_digits = 3;
+			group_exp    = 0;
+		}
+	};
+
+
+
+	/*!
+		this simple class can be used in multithreading model
+		(you can write your own class derived from this one)
+
+		for example: in some functions like Factorial() 
+		/at the moment only Factorial/ you can give a pointer to 
+		the 'stop object', if the method WasStopSignal() of this 
+		object returns true that means we should break the calculating
+		and return
+	*/
+	class StopCalculating
+	{
+	public:
+		virtual bool WasStopSignal() const volatile { return false; }
+		virtual ~StopCalculating(){}
+	};
+
+
+	/*!
+		a small class which is useful when compiling with gcc
+
+		object of this type holds the name and the line of a file
+		in which the macro TTMATH_ASSERT or TTMATH_REFERENCE_ASSERT was used
+	*/
+	class ExceptionInfo
+	{
+	const char * file;
+	int line;
+
+	public:
+		ExceptionInfo() : file(0), line(0) {}
+		ExceptionInfo(const char * f, int l) : file(f), line(l) {}
+
+		std::string Where() const
+		{
+			if( !file )
+				return "unknown";
+
+			std::ostringstream result;
+			result << file << ":" << line;
+
+		return result.str();
+		}
+	};
+
+
+	/*!
+		A small class used for reporting 'reference' errors
+
+		In the library is used macro TTMATH_REFERENCE_ASSERT which
+		can throw an exception of this type
+
+		** from version 0.9.2 this macro is removed from all methods
+		   in public interface so you don't have to worry about it **
+
+		If you compile with gcc you can get a small benefit 
+		from using method Where() (it returns std::string) with
+		the name and the line of a file where the macro TTMATH_REFERENCE_ASSERT
+		was used)
+	*/
+	class ReferenceError : public std::logic_error, public ExceptionInfo
+	{
+	public:
+
+		ReferenceError() : std::logic_error("reference error")
+		{
+		}
+
+		ReferenceError(const char * f, int l) :
+							std::logic_error("reference error"), ExceptionInfo(f,l)
+		{
+		}
+
+		std::string Where() const
+		{
+			return ExceptionInfo::Where();
+		}
+	};
+
+
+	/*!
+		a small class used for reporting errors
+
+		in the library is used macro TTMATH_ASSERT which
+		(if the condition in it is false) throw an exception
+		of this type
+
+		if you compile with gcc you can get a small benefit 
+		from using method Where() (it returns std::string) with
+		the name and the line of a file where the macro TTMATH_ASSERT
+		was used)
+	*/
+	class RuntimeError : public std::runtime_error, public ExceptionInfo
+	{
+	public:
+
+		RuntimeError() : std::runtime_error("internal error")
+		{
+		}
+
+		RuntimeError(const char * f, int l) :
+						std::runtime_error("internal error"), ExceptionInfo(f,l)
+		{
+		}
+
+		std::string Where() const
+		{
+			return ExceptionInfo::Where();
+		}
+	};
+
+
+
+	/*!
+		TTMATH_DEBUG
+		this macro enables further testing during writing your code
+		you don't have to define it in a release mode
+
+		if this macro is set then macros TTMATH_ASSERT and TTMATH_REFERENCE_ASSERT
+		are set as well	and these macros can throw an exception if a condition in it
+		is not fulfilled (look at the definition of TTMATH_ASSERT and TTMATH_REFERENCE_ASSERT)
+
+		TTMATH_DEBUG is set automatically if DEBUG or _DEBUG are defined
+	*/
+	#if defined DEBUG || defined _DEBUG
+		#define TTMATH_DEBUG
+	#endif
+
+
+	#ifdef TTMATH_DEBUG
+
+		#if defined(__FILE__) && defined(__LINE__)
+
+			#define TTMATH_REFERENCE_ASSERT(expression) \
+				if( &(expression) == this ) throw ttmath::ReferenceError(__FILE__, __LINE__);
+
+			#define TTMATH_ASSERT(expression) \
+				if( !(expression) ) throw ttmath::RuntimeError(__FILE__, __LINE__);
+
+		#else
+
+			#define TTMATH_REFERENCE_ASSERT(expression) \
+				if( &(expression) == this ) throw ReferenceError();
+
+			#define TTMATH_ASSERT(expression) \
+				if( !(expression) ) throw RuntimeError();
+		#endif
+
+	#else
+		#define TTMATH_REFERENCE_ASSERT(expression)
+		#define TTMATH_ASSERT(expression)
+	#endif
+
+
+
+	#ifdef TTMATH_DEBUG_LOG
+		#define TTMATH_LOG(msg)                             PrintLog(msg, std::cout);
+		#define TTMATH_LOGC(msg, carry)                     PrintLog(msg, carry, std::cout);
+		#define TTMATH_VECTOR_LOG(msg, vector, len)         PrintVectorLog(msg, std::cout, vector, len);
+		#define TTMATH_VECTOR_LOGC(msg, carry, vector, len) PrintVectorLog(msg, carry, std::cout, vector, len);
+	#else
+		#define TTMATH_LOG(msg)
+		#define TTMATH_LOGC(msg, carry)
+		#define TTMATH_VECTOR_LOG(msg, vector, len)
+		#define TTMATH_VECTOR_LOGC(msg, carry, vector, len)
+	#endif
+
+
+
+
+} // namespace
+
+
+#endif
+
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathuint.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint.h
new file mode 100644
index 0000000..d0f6df1
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint.h
@@ -0,0 +1,4121 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2011, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef headerfilettmathuint
+#define headerfilettmathuint
+
+
+/*!
+	\file ttmathuint.h
+    \brief template class UInt<uint>
+*/
+
+#include <iostream>
+#include <iomanip>
+
+
+#include "ttmathtypes.h"
+#include "ttmathmisc.h"
+
+
+
+/*!
+    \brief a namespace for the TTMath library
+*/
+namespace ttmath
+{
+
+/*! 
+	\brief UInt implements a big integer value without a sign
+
+	value_size - how many bytes specify our value
+		on 32bit platforms: value_size=1 -> 4 bytes -> 32 bits
+		on 64bit platforms: value_size=1 -> 8 bytes -> 64 bits
+	value_size = 1,2,3,4,5,6....
+*/
+template<uint value_size>
+class UInt
+{
+public:
+
+	/*!
+		buffer for the integer value
+		  table[0] - the lowest word of the value
+	*/
+	uint table[value_size];
+
+
+
+	/*!
+		some methods used for debugging purposes
+	*/
+
+
+	/*!
+		this method is only for debugging purposes or when we want to make
+		a table of a variable (constant) in ttmathbig.h
+
+		it prints the table in a nice form of several columns
+	*/
+	template<class ostream_type>
+	void PrintTable(ostream_type & output) const
+	{
+		// how many columns there'll be
+		const int columns = 8;
+
+		int c = 1;
+		for(int i=value_size-1 ; i>=0 ; --i)
+		{
+			output << "0x" << std::setfill('0');
+			
+			#ifdef TTMATH_PLATFORM32
+				output << std::setw(8);
+			#else
+				output << std::setw(16);
+			#endif
+				
+			output << std::hex << table[i];
+			
+			if( i>0 )
+			{
+				output << ", ";		
+			
+				if( ++c > columns )
+				{
+					output << std::endl;
+					c = 1;
+				}
+			}
+		}
+		
+		output << std::dec << std::endl;
+	}
+
+
+	/*!
+		this method is used when macro TTMATH_DEBUG_LOG is defined
+	*/
+	template<class char_type, class ostream_type>
+	static void PrintVectorLog(const char_type * msg, ostream_type & output, const uint * vector, uint vector_len)
+	{
+		output << msg << std::endl;
+
+		for(uint i=0 ; i<vector_len ; ++i)
+			output << " table[" << i << "]: " << vector[i] << std::endl;
+	}
+
+
+	/*!
+		this method is used when macro TTMATH_DEBUG_LOG is defined
+	*/
+	template<class char_type, class ostream_type>
+	static void PrintVectorLog(const char_type * msg, uint carry, ostream_type & output, const uint * vector, uint vector_len)
+	{
+		PrintVectorLog(msg, output, vector, vector_len);
+		output << " carry: " << carry << std::endl;
+	}
+
+
+	/*!
+		this method is used when macro TTMATH_DEBUG_LOG is defined
+	*/
+	template<class char_type, class ostream_type>
+	void PrintLog(const char_type * msg, ostream_type & output) const
+	{
+		PrintVectorLog(msg, output, table, value_size);
+	}
+
+
+	/*!
+		this method is used when macro TTMATH_DEBUG_LOG is defined
+	*/
+	template<class char_type, class ostream_type>
+	void PrintLog(const char_type * msg, uint carry, ostream_type & output) const
+	{
+		PrintVectorLog(msg, output, table, value_size);
+		output << " carry: " << carry << std::endl;
+	}
+
+
+	/*!
+		this method returns the size of the table
+	*/
+	uint Size() const
+	{
+		return value_size;
+	}
+
+
+	/*!
+		this method sets zero
+	*/
+	void SetZero()
+	{
+		// in the future here can be 'memset'
+
+		for(uint i=0 ; i<value_size ; ++i)
+			table[i] = 0;
+
+		TTMATH_LOG("UInt::SetZero")
+	}
+
+
+	/*!
+		this method sets one
+	*/
+	void SetOne()
+	{
+		SetZero();
+		table[0] = 1;
+
+		TTMATH_LOG("UInt::SetOne")
+	}
+
+
+	/*!
+		this method sets the max value which this class can hold
+		(all bits will be one)
+	*/
+	void SetMax()
+	{
+		for(uint i=0 ; i<value_size ; ++i)
+			table[i] = TTMATH_UINT_MAX_VALUE;
+
+		TTMATH_LOG("UInt::SetMax")
+	}
+
+
+	/*!
+		this method sets the min value which this class can hold
+		(for an unsigned integer value the zero is the smallest value)
+	*/
+	void SetMin()
+	{
+		SetZero();
+
+		TTMATH_LOG("UInt::SetMin")
+	}
+
+
+	/*!
+		this method swappes this for an argument
+	*/
+	void Swap(UInt<value_size> & ss2)
+	{
+		for(uint i=0 ; i<value_size ; ++i)
+		{
+			uint temp = table[i];
+			table[i] = ss2.table[i];
+			ss2.table[i] = temp;
+		}
+	}
+
+
+#ifdef TTMATH_PLATFORM32
+
+	/*!
+		this method copies the value stored in an another table
+		(warning: first values in temp_table are the highest words -- it's different
+		from our table)
+
+		we copy as many words as it is possible
+		
+		if temp_table_len is bigger than value_size we'll try to round 
+		the lowest word from table depending on the last not used bit in temp_table
+		(this rounding isn't a perfect rounding -- look at the description below)
+
+		and if temp_table_len is smaller than value_size we'll clear the rest words
+		in the table
+	*/
+	void SetFromTable(const uint * temp_table, uint temp_table_len)
+	{
+		uint temp_table_index = 0;
+		sint i; // 'i' with a sign
+
+		for(i=value_size-1 ; i>=0 && temp_table_index<temp_table_len; --i, ++temp_table_index)
+			table[i] = temp_table[ temp_table_index ];
+
+
+		// rounding mantissa
+		if( temp_table_index < temp_table_len )
+		{
+			if( (temp_table[temp_table_index] & TTMATH_UINT_HIGHEST_BIT) != 0 )
+			{
+				/*
+					very simply rounding
+					if the bit from not used last word from temp_table is set to one
+					we're rouding the lowest word in the table
+
+					in fact there should be a normal addition but
+					we don't use Add() or AddTwoInts() because these methods 
+					can set a carry and then there'll be a small problem
+					for optimization
+				*/
+				if( table[0] != TTMATH_UINT_MAX_VALUE )
+					++table[0];
+			}
+		}
+
+		// cleaning the rest of the mantissa
+		for( ; i>=0 ; --i)
+			table[i] = 0;
+
+
+		TTMATH_LOG("UInt::SetFromTable")
+	}
+
+#endif
+
+
+#ifdef TTMATH_PLATFORM64
+	/*!
+		this method copies the value stored in an another table
+		(warning: first values in temp_table are the highest words -- it's different
+		from our table)
+
+		***this method is created only on a 64bit platform***
+
+		we copy as many words as it is possible
+		
+		if temp_table_len is bigger than value_size we'll try to round 
+		the lowest word from table depending on the last not used bit in temp_table
+		(this rounding isn't a perfect rounding -- look at the description below)
+
+		and if temp_table_len is smaller than value_size we'll clear the rest words
+		in the table
+
+		warning: we're using 'temp_table' as a pointer at 32bit words
+	*/
+	void SetFromTable(const unsigned int * temp_table, uint temp_table_len)
+	{
+		uint temp_table_index = 0;
+		sint i; // 'i' with a sign
+
+		for(i=value_size-1 ; i>=0 && temp_table_index<temp_table_len; --i, ++temp_table_index)
+		{
+			table[i] = uint(temp_table[ temp_table_index ]) << 32;
+
+			++temp_table_index;
+
+			if( temp_table_index<temp_table_len )
+				table[i] |= temp_table[ temp_table_index ];
+		}
+
+
+		// rounding mantissa
+		if( temp_table_index < temp_table_len )
+		{
+			if( (temp_table[temp_table_index] & TTMATH_UINT_HIGHEST_BIT) != 0 )
+			{
+				/*
+					very simply rounding
+					if the bit from not used last word from temp_table is set to one
+					we're rouding the lowest word in the table
+
+					in fact there should be a normal addition but
+					we don't use Add() or AddTwoInts() because these methods 
+					can set a carry and then there'll be a small problem
+					for optimization
+				*/
+				if( table[0] != TTMATH_UINT_MAX_VALUE )
+					++table[0];
+			}
+		}
+
+		// cleaning the rest of the mantissa
+		for( ; i >= 0 ; --i)
+			table[i] = 0;
+
+		TTMATH_LOG("UInt::SetFromTable")
+	}
+
+#endif
+
+
+
+
+
+	/*!
+	*
+	*	basic mathematic functions
+	*
+	*/
+
+
+
+
+	/*!
+		this method adds one to the existing value
+	*/
+	uint AddOne()
+	{
+		return AddInt(1);
+	}
+
+
+	/*!
+		this method subtracts one from the existing value
+	*/
+	uint SubOne()
+	{
+		return SubInt(1);
+	}
+
+
+private:
+
+
+	/*!    
+		an auxiliary method for moving bits into the left hand side
+
+		this method moves only words
+	*/
+	void RclMoveAllWords(uint & rest_bits, uint & last_c, uint bits, uint c)
+	{
+		rest_bits      = bits % TTMATH_BITS_PER_UINT;
+		uint all_words = bits / TTMATH_BITS_PER_UINT;
+		uint mask      = ( c ) ? TTMATH_UINT_MAX_VALUE : 0;
+
+
+		if( all_words >= value_size )
+		{
+			if( all_words == value_size && rest_bits == 0 )
+				last_c = table[0] & 1;
+			// else: last_c is default set to 0
+
+			// clearing
+			for(uint i = 0 ; i<value_size ; ++i)
+				table[i] = mask;
+
+			rest_bits = 0;
+		}
+		else
+		if( all_words > 0 )  
+		{
+			// 0 < all_words < value_size
+	
+			sint first, second;
+			last_c = table[value_size - all_words] & 1; // all_words is greater than 0
+
+			// copying the first part of the value
+			for(first = value_size-1, second=first-all_words ; second>=0 ; --first, --second)
+				table[first] = table[second];
+
+			// setting the rest to 'c'
+			for( ; first>=0 ; --first )
+				table[first] = mask;
+		}
+
+		TTMATH_LOG("UInt::RclMoveAllWords")
+	}
+	
+public:
+
+	/*!
+		moving all bits into the left side 'bits' times
+		return value <- this <- C
+
+		bits is from a range of <0, man * TTMATH_BITS_PER_UINT>
+		or it can be even bigger then all bits will be set to 'c'
+
+		the value c will be set into the lowest bits
+		and the method returns state of the last moved bit
+	*/
+	uint Rcl(uint bits, uint c=0)
+	{
+	uint last_c    = 0;
+	uint rest_bits = bits;
+
+		if( bits == 0 )
+			return 0;
+
+		if( bits >= TTMATH_BITS_PER_UINT )
+			RclMoveAllWords(rest_bits, last_c, bits, c);
+
+		if( rest_bits == 0 )
+		{
+			TTMATH_LOG("UInt::Rcl")
+			return last_c;
+		}
+
+		// rest_bits is from 1 to TTMATH_BITS_PER_UINT-1 now
+		if( rest_bits == 1 )
+		{
+			last_c = Rcl2_one(c);
+		}
+		else if( rest_bits == 2 )
+		{
+			// performance tests showed that for rest_bits==2 it's better to use Rcl2_one twice instead of Rcl2(2,c)
+			Rcl2_one(c);
+			last_c = Rcl2_one(c);
+		}
+		else
+		{
+			last_c = Rcl2(rest_bits, c);
+		}
+
+		TTMATH_LOGC("UInt::Rcl", last_c)
+
+	return last_c;
+	}
+
+private:
+
+	/*!    
+		an auxiliary method for moving bits into the right hand side
+
+		this method moves only words
+	*/
+	void RcrMoveAllWords(uint & rest_bits, uint & last_c, uint bits, uint c)
+	{
+		rest_bits      = bits % TTMATH_BITS_PER_UINT;
+		uint all_words = bits / TTMATH_BITS_PER_UINT;
+		uint mask      = ( c ) ? TTMATH_UINT_MAX_VALUE : 0;
+
+
+		if( all_words >= value_size )
+		{
+			if( all_words == value_size && rest_bits == 0 )
+				last_c = (table[value_size-1] & TTMATH_UINT_HIGHEST_BIT) ? 1 : 0;
+			// else: last_c is default set to 0
+
+			// clearing
+			for(uint i = 0 ; i<value_size ; ++i)
+				table[i] = mask;
+
+			rest_bits = 0;
+		}
+		else if( all_words > 0 )
+		{
+			// 0 < all_words < value_size
+
+			uint first, second;
+			last_c = (table[all_words - 1] & TTMATH_UINT_HIGHEST_BIT) ? 1 : 0; // all_words is > 0
+
+			// copying the first part of the value
+			for(first=0, second=all_words ; second<value_size ; ++first, ++second)
+				table[first] = table[second];
+
+			// setting the rest to 'c'
+			for( ; first<value_size ; ++first )
+				table[first] = mask;
+		}
+
+		TTMATH_LOG("UInt::RcrMoveAllWords")
+	}
+
+public:
+
+	/*!
+		moving all bits into the right side 'bits' times
+		c -> this -> return value
+
+		bits is from a range of <0, man * TTMATH_BITS_PER_UINT>
+		or it can be even bigger then all bits will be set to 'c'
+
+		the value c will be set into the highest bits
+		and the method returns state of the last moved bit
+	*/
+	uint Rcr(uint bits, uint c=0)
+	{
+	uint last_c    = 0;
+	uint rest_bits = bits;
+	
+		if( bits == 0 )
+			return 0;
+
+		if( bits >= TTMATH_BITS_PER_UINT )
+			RcrMoveAllWords(rest_bits, last_c, bits, c);
+
+		if( rest_bits == 0 )
+		{
+			TTMATH_LOG("UInt::Rcr")
+			return last_c;
+		}
+
+		// rest_bits is from 1 to TTMATH_BITS_PER_UINT-1 now
+		if( rest_bits == 1 )
+		{
+			last_c = Rcr2_one(c);
+		}
+		else if( rest_bits == 2 )
+		{
+			// performance tests showed that for rest_bits==2 it's better to use Rcr2_one twice instead of Rcr2(2,c)
+			Rcr2_one(c);
+			last_c = Rcr2_one(c);
+		}
+		else
+		{
+			last_c = Rcr2(rest_bits, c);
+		}
+
+		TTMATH_LOGC("UInt::Rcr", last_c)
+
+	return last_c;
+	}
+
+
+	/*!
+		this method moves all bits into the left side
+		(it returns value how many bits have been moved)
+	*/
+	uint CompensationToLeft()
+	{
+		uint moving = 0;
+
+		// a - index a last word which is different from zero
+		sint a;
+		for(a=value_size-1 ; a>=0 && table[a]==0 ; --a);
+
+		if( a < 0 )
+			return moving; // all words in table have zero
+
+		if( a != value_size-1 )
+		{
+			moving += ( value_size-1 - a ) * TTMATH_BITS_PER_UINT;
+
+			// moving all words
+			sint i;
+			for(i=value_size-1 ; a>=0 ; --i, --a)
+				table[i] = table[a];
+
+			// setting the rest word to zero
+			for(; i>=0 ; --i)
+				table[i] = 0;
+		}
+
+		uint moving2 = FindLeadingBitInWord( table[value_size-1] );
+		// moving2 is different from -1 because the value table[value_size-1]
+		// is not zero
+
+		moving2 = TTMATH_BITS_PER_UINT - moving2 - 1;
+		Rcl(moving2);
+
+		TTMATH_LOG("UInt::CompensationToLeft")
+
+	return moving + moving2;
+	}
+
+
+	/*!
+		this method looks for the highest set bit
+		
+		result:
+			if 'this' is not zero:
+				return value - true
+				'table_id'   - the index of a word <0..value_size-1>
+				'index'      - the index of this set bit in the word <0..TTMATH_BITS_PER_UINT)
+
+			if 'this' is zero: 
+				return value - false
+				both 'table_id' and 'index' are zero
+	*/
+	bool FindLeadingBit(uint & table_id, uint & index) const
+	{
+		for(table_id=value_size-1 ; table_id!=0 && table[table_id]==0 ; --table_id);
+
+		if( table_id==0 && table[table_id]==0 )
+		{
+			// is zero
+			index = 0;
+
+		return false;
+		}
+		
+		// table[table_id] is different from 0
+		index = FindLeadingBitInWord( table[table_id] );
+
+	return true;
+	}
+
+
+	/*!
+		this method looks for the smallest set bit
+		
+		result:
+			if 'this' is not zero:
+				return value - true
+				'table_id'   - the index of a word <0..value_size-1>
+				'index'      - the index of this set bit in the word <0..TTMATH_BITS_PER_UINT)
+
+			if 'this' is zero: 
+				return value - false
+				both 'table_id' and 'index' are zero
+	*/
+	bool FindLowestBit(uint & table_id, uint & index) const
+	{
+		for(table_id=0 ; table_id<value_size && table[table_id]==0 ; ++table_id);
+
+		if( table_id >= value_size )
+		{
+			// is zero
+			index    = 0;
+			table_id = 0;
+
+		return false;
+		}
+		
+		// table[table_id] is different from 0
+		index = FindLowestBitInWord( table[table_id] );
+
+	return true;
+	}
+
+
+	/*!
+		getting the 'bit_index' bit
+
+		bit_index bigger or equal zero
+	*/
+	uint GetBit(uint bit_index) const
+	{
+		TTMATH_ASSERT( bit_index < value_size * TTMATH_BITS_PER_UINT )
+
+		uint index = bit_index / TTMATH_BITS_PER_UINT;
+		uint bit   = bit_index % TTMATH_BITS_PER_UINT;
+
+		uint temp = table[index];
+		uint res  = SetBitInWord(temp, bit);
+
+	return res;
+	}
+
+
+	/*!
+		setting the 'bit_index' bit
+		and returning the last state of the bit
+
+		bit_index bigger or equal zero
+	*/
+	uint SetBit(uint bit_index)
+	{
+		TTMATH_ASSERT( bit_index < value_size * TTMATH_BITS_PER_UINT )
+
+		uint index = bit_index / TTMATH_BITS_PER_UINT;
+		uint bit   = bit_index % TTMATH_BITS_PER_UINT;
+		uint res   = SetBitInWord(table[index], bit);
+
+		TTMATH_LOG("UInt::SetBit")
+
+	return res;
+	}
+
+
+	/*!
+		this method performs a bitwise operation AND 
+	*/
+	void BitAnd(const UInt<value_size> & ss2)
+	{
+		for(uint x=0 ; x<value_size ; ++x)
+			table[x] &= ss2.table[x];
+
+		TTMATH_LOG("UInt::BitAnd")
+	}
+
+
+	/*!
+		this method performs a bitwise operation OR 
+	*/
+	void BitOr(const UInt<value_size> & ss2)
+	{
+		for(uint x=0 ; x<value_size ; ++x)
+			table[x] |= ss2.table[x];
+
+		TTMATH_LOG("UInt::BitOr")
+	}
+
+
+	/*!
+		this method performs a bitwise operation XOR 
+	*/
+	void BitXor(const UInt<value_size> & ss2)
+	{
+		for(uint x=0 ; x<value_size ; ++x)
+			table[x] ^= ss2.table[x];
+
+		TTMATH_LOG("UInt::BitXor")
+	}
+
+
+	/*!
+		this method performs a bitwise operation NOT
+	*/
+	void BitNot()
+	{
+		for(uint x=0 ; x<value_size ; ++x)
+			table[x] = ~table[x];
+
+		TTMATH_LOG("UInt::BitNot")
+	}
+
+
+	/*!
+		this method performs a bitwise operation NOT but only
+		on the range of <0, leading_bit>
+
+		for example:
+			BitNot2(8) = BitNot2( 1000(bin) ) = 111(bin) = 7
+	*/
+	void BitNot2()
+	{
+	uint table_id, index;
+
+		if( FindLeadingBit(table_id, index) )
+		{
+			for(uint x=0 ; x<table_id ; ++x)
+				table[x] = ~table[x];
+
+			uint mask  = TTMATH_UINT_MAX_VALUE;
+			uint shift = TTMATH_BITS_PER_UINT - index - 1;
+
+			if(shift)
+				mask >>= shift;
+
+			table[table_id] ^= mask;
+		}
+		else
+			table[0] = 1;
+
+
+		TTMATH_LOG("UInt::BitNot2")
+	}
+
+
+
+	/*!
+	 *
+	 * Multiplication
+	 *
+	 *
+	*/
+
+public:
+
+	/*!
+		multiplication: this = this * ss2
+
+		it can return a carry
+	*/
+	uint MulInt(uint ss2)
+	{
+	uint r1, r2, x1;
+	uint c = 0;
+
+		UInt<value_size> u(*this);
+		SetZero();
+
+		if( ss2 == 0 )
+		{
+			TTMATH_LOGC("UInt::MulInt(uint)", 0)
+			return 0;
+		}
+
+		for(x1=0 ; x1<value_size-1 ; ++x1)
+		{
+			MulTwoWords(u.table[x1], ss2, &r2, &r1);
+			c += AddTwoInts(r2,r1,x1);
+		}
+
+		// x1 = value_size-1  (last word)
+		MulTwoWords(u.table[x1], ss2, &r2, &r1);
+		c += (r2!=0) ? 1 : 0;
+		c += AddInt(r1, x1);
+
+		TTMATH_LOGC("UInt::MulInt(uint)", c)
+
+	return (c==0)? 0 : 1;
+	}
+
+
+	/*!
+		multiplication: result = this * ss2
+
+		we're using this method only when result_size is greater than value_size
+		if so there will not be a carry
+	*/
+	template<uint result_size>
+	void MulInt(uint ss2, UInt<result_size> & result) const
+	{
+	TTMATH_ASSERT( result_size > value_size )
+
+	uint r2,r1;
+	uint x1size=value_size;
+	uint x1start=0;
+
+		result.SetZero();
+
+		if( ss2 == 0 )
+		{
+			TTMATH_VECTOR_LOG("UInt::MulInt(uint, UInt<>)", result.table, result_size)
+			return;
+		}
+
+		if( value_size > 2 )
+		{	
+			// if the value_size is smaller than or equal to 2
+			// there is no sense to set x1size and x1start to another values
+
+			for(x1size=value_size ; x1size>0 && table[x1size-1]==0 ; --x1size);
+
+			if( x1size == 0 )
+			{
+				TTMATH_VECTOR_LOG("UInt::MulInt(uint, UInt<>)", result.table, result_size)
+				return;
+			}
+
+			for(x1start=0 ; x1start<x1size && table[x1start]==0 ; ++x1start);
+		}
+
+		for(uint x1=x1start ; x1<x1size ; ++x1)
+		{
+			MulTwoWords(table[x1], ss2, &r2, &r1 );
+			result.AddTwoInts(r2,r1,x1);
+		}
+
+		TTMATH_VECTOR_LOG("UInt::MulInt(uint, UInt<>)", result.table, result_size)
+
+	return;
+	}
+
+
+
+	/*!
+		the multiplication 'this' = 'this' * ss2
+
+		algorithm: 100 - means automatically choose the fastest algorithm
+	*/
+	uint Mul(const UInt<value_size> & ss2, uint algorithm = 100)
+	{
+		switch( algorithm )
+		{
+		case 1:
+			return Mul1(ss2);
+
+		case 2:
+			return Mul2(ss2);
+
+		case 3:
+			return Mul3(ss2);
+
+		case 100:
+		default:
+			return MulFastest(ss2);
+		}
+	}
+
+
+	/*!
+		the multiplication 'result' = 'this' * ss2
+
+		since the 'result' is twice bigger than 'this' and 'ss2' 
+		this method never returns a carry
+
+		algorithm: 100 - means automatically choose the fastest algorithm
+	*/
+	void MulBig(const UInt<value_size> & ss2,
+				UInt<value_size*2> & result, 
+				uint algorithm = 100)
+	{
+		switch( algorithm )
+		{
+		case 1:
+			return Mul1Big(ss2, result);
+
+		case 2:
+			return Mul2Big(ss2, result);
+
+		case 3:
+			return Mul3Big(ss2, result);
+
+		case 100:
+		default:
+			return MulFastestBig(ss2, result);
+		}
+	}
+
+
+
+	/*!
+		the first version of the multiplication algorithm
+	*/
+
+private:
+
+	/*!
+		multiplication: this = this * ss2
+
+		it returns carry if it has been
+	*/
+	uint Mul1Ref(const UInt<value_size> & ss2)
+	{
+	TTMATH_REFERENCE_ASSERT( ss2 )
+
+	UInt<value_size> ss1( *this );
+	SetZero();	
+
+		for(uint i=0; i < value_size*TTMATH_BITS_PER_UINT ; ++i)
+		{
+			if( Add(*this) )
+			{
+				TTMATH_LOGC("UInt::Mul1", 1)
+				return 1;
+			}
+
+			if( ss1.Rcl(1) )
+				if( Add(ss2) )
+				{
+					TTMATH_LOGC("UInt::Mul1", 1)
+					return 1;
+				}
+		}
+
+		TTMATH_LOGC("UInt::Mul1", 0)
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		multiplication: this = this * ss2
+		can return carry
+	*/
+	uint Mul1(const UInt<value_size> & ss2)
+	{
+		if( this == &ss2 )
+		{
+			UInt<value_size> copy_ss2(ss2);
+			return Mul1Ref(copy_ss2);
+		}
+		else
+		{
+			return Mul1Ref(ss2);
+		}
+	}
+
+	
+	/*!
+		multiplication: result = this * ss2
+
+		result is twice bigger than 'this' and 'ss2'
+		this method never returns carry			
+	*/
+	void Mul1Big(const UInt<value_size> & ss2_, UInt<value_size*2> & result)
+	{
+	UInt<value_size*2> ss2;
+	uint i;
+
+		// copying *this into result and ss2_ into ss2
+		for(i=0 ; i<value_size ; ++i)
+		{
+			result.table[i] = table[i];
+			ss2.table[i]    = ss2_.table[i];
+		}
+
+		// cleaning the highest bytes in result and ss2
+		for( ; i < value_size*2 ; ++i)
+		{
+			result.table[i] = 0;
+			ss2.table[i]    = 0;
+		}
+
+		// multiply
+		// (there will not be a carry)
+		result.Mul1( ss2 );
+
+		TTMATH_LOG("UInt::Mul1Big")
+	}
+
+
+
+	/*!
+		the second version of the multiplication algorithm
+
+		this algorithm is similar to the 'schoolbook method' which is done by hand
+	*/
+
+	/*!
+		multiplication: this = this * ss2
+
+		it returns carry if it has been
+	*/
+	uint Mul2(const UInt<value_size> & ss2)
+	{
+	UInt<value_size*2> result;
+	uint i, c = 0;
+
+		Mul2Big(ss2, result);
+	
+		// copying result
+		for(i=0 ; i<value_size ; ++i)
+			table[i] = result.table[i];
+
+		// testing carry
+		for( ; i<value_size*2 ; ++i)
+			if( result.table[i] != 0 )
+			{
+				c = 1;
+				break;
+			}
+
+		TTMATH_LOGC("UInt::Mul2", c)
+
+	return c;
+	}
+
+
+	/*!
+		multiplication: result = this * ss2
+
+		result is twice bigger than this and ss2
+		this method never returns carry			
+	*/
+	void Mul2Big(const UInt<value_size> & ss2, UInt<value_size*2> & result)
+	{
+		Mul2Big2<value_size>(table, ss2.table, result);
+
+		TTMATH_LOG("UInt::Mul2Big")
+	}
+
+
+private:
+
+	/*!
+		an auxiliary method for calculating the multiplication 
+
+		arguments we're taking as pointers (this is to improve the Mul3Big2()- avoiding
+		unnecessary copying objects), the result should be taken as a pointer too,
+		but at the moment there is no method AddTwoInts() which can operate on pointers
+	*/
+	template<uint ss_size>
+	void Mul2Big2(const uint * ss1, const uint * ss2, UInt<ss_size*2> & result)
+	{
+	uint x1size  = ss_size, x2size  = ss_size;
+	uint x1start = 0,       x2start = 0;
+
+		if( ss_size > 2 )
+		{	
+			// if the ss_size is smaller than or equal to 2
+			// there is no sense to set x1size (and others) to another values
+
+			for(x1size=ss_size ; x1size>0 && ss1[x1size-1]==0 ; --x1size);
+			for(x2size=ss_size ; x2size>0 && ss2[x2size-1]==0 ; --x2size);
+
+			for(x1start=0 ; x1start<x1size && ss1[x1start]==0 ; ++x1start);
+			for(x2start=0 ; x2start<x2size && ss2[x2start]==0 ; ++x2start);
+		}
+
+		Mul2Big3<ss_size>(ss1, ss2, result, x1start, x1size, x2start, x2size);
+	}
+
+
+
+	/*!
+		an auxiliary method for calculating the multiplication 
+	*/
+	template<uint ss_size>
+	void Mul2Big3(const uint * ss1, const uint * ss2, UInt<ss_size*2> & result, uint x1start, uint x1size, uint x2start, uint x2size)
+	{
+	uint r2, r1;
+
+		result.SetZero();
+
+		if( x1size==0 || x2size==0 )
+			return;
+
+		for(uint x1=x1start ; x1<x1size ; ++x1)
+		{
+			for(uint x2=x2start ; x2<x2size ; ++x2)
+			{
+				MulTwoWords(ss1[x1], ss2[x2], &r2, &r1);
+				result.AddTwoInts(r2, r1, x2+x1);
+				// here will never be a carry
+			}
+		}
+	}
+
+
+public:
+
+
+	/*!
+		multiplication: this = this * ss2
+
+		This is Karatsuba Multiplication algorithm, we're using it when value_size is greater than
+		or equal to TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE macro (defined in ttmathuint.h).
+		If value_size is smaller then we're using Mul2Big() instead.
+
+		Karatsuba multiplication:
+		Assume we have:
+			this = x = x1*B^m + x0
+			ss2  = y = y1*B^m + y0
+		where x0 and y0 are less than B^m
+		the product from multiplication we can show as:
+	    x*y = (x1*B^m + x0)(y1*B^m + y0) = z2*B^(2m) + z1*B^m + z0
+		where
+		    z2 = x1*y1
+			z1 = x1*y0 + x0*y1
+			z0 = x0*y0 
+		this is standard schoolbook algorithm with O(n^2), Karatsuba observed that z1 can be given in other form:
+			z1 = (x1 + x0)*(y1 + y0) - z2 - z0    / z1 = (x1*y1 + x1*y0 + x0*y1 + x0*y0) - x1*y1 - x0*y0 = x1*y0 + x0*y1 /
+		and to calculate the multiplication we need only three multiplications (with some additions and subtractions)			
+
+		Our objects 'this' and 'ss2' we divide into two parts and by using recurrence we calculate the multiplication.
+		Karatsuba multiplication has O( n^(ln(3)/ln(2)) )
+	*/
+	uint Mul3(const UInt<value_size> & ss2)
+	{
+	UInt<value_size*2> result;
+	uint i, c = 0;
+
+		Mul3Big(ss2, result);
+	
+		// copying result
+		for(i=0 ; i<value_size ; ++i)
+			table[i] = result.table[i];
+
+		// testing carry
+		for( ; i<value_size*2 ; ++i)
+			if( result.table[i] != 0 )
+			{
+				c = 1;
+				break;
+			}
+
+		TTMATH_LOGC("UInt::Mul3", c)
+
+	return c;
+	}
+
+
+
+	/*!
+		multiplication: result = this * ss2
+
+		result is twice bigger than this and ss2,
+		this method never returns carry,
+		(Karatsuba multiplication)
+	*/
+	void Mul3Big(const UInt<value_size> & ss2, UInt<value_size*2> & result)
+	{
+		Mul3Big2<value_size>(table, ss2.table, result.table);
+
+		TTMATH_LOG("UInt::Mul3Big")
+	}
+
+
+
+private:
+
+	/*!
+		an auxiliary method for calculating the Karatsuba multiplication
+
+		result_size is equal ss_size*2
+	*/
+	template<uint ss_size>
+	void Mul3Big2(const uint * ss1, const uint * ss2, uint * result)
+	{
+	const uint * x1, * x0, * y1, * y0;
+
+
+		if( ss_size>1 && ss_size<TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE )
+		{
+			UInt<ss_size*2> res;
+			Mul2Big2<ss_size>(ss1, ss2, res);
+
+			for(uint i=0 ; i<ss_size*2 ; ++i)
+				result[i] = res.table[i];
+
+		return;
+		}
+		else
+		if( ss_size == 1 )
+		{
+			return MulTwoWords(*ss1, *ss2, &result[1], &result[0]);
+		}
+
+
+		if( (ss_size & 1) == 1 )
+		{
+			// ss_size is odd
+			x0 = ss1;
+			y0 = ss2;
+			x1 = ss1 + ss_size / 2 + 1;
+			y1 = ss2 + ss_size / 2 + 1;
+
+			// the second vectors (x1 and y1) are smaller about one from the first ones (x0 and y0)
+			Mul3Big3<ss_size/2 + 1, ss_size/2, ss_size*2>(x1, x0, y1, y0, result);
+		}
+		else
+		{
+			// ss_size is even
+			x0 = ss1;
+			y0 = ss2;
+			x1 = ss1 + ss_size / 2;
+			y1 = ss2 + ss_size / 2;
+			
+			// all four vectors (x0 x1 y0 y1) are equal in size
+			Mul3Big3<ss_size/2, ss_size/2, ss_size*2>(x1, x0, y1, y0, result);
+		}
+	}
+
+
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4717)
+//warning C4717: recursive on all control paths, function will cause runtime stack overflow
+//we have the stop point in Mul3Big2() method
+#endif
+
+
+	/*!
+		an auxiliary method for calculating the Karatsuba multiplication
+
+			x = x1*B^m + x0
+			y = y1*B^m + y0
+
+			first_size  - is the size of vectors: x0 and y0
+			second_size - is the size of vectors: x1 and y1 (can be either equal first_size or smaller about one from first_size)
+
+			x*y = (x1*B^m + x0)(y1*B^m + y0) = z2*B^(2m) + z1*B^m + z0
+		      where
+			   z0 = x0*y0 
+			   z2 = x1*y1
+			   z1 = (x1 + x0)*(y1 + y0) - z2 - z0
+	*/
+	template<uint first_size, uint second_size, uint result_size>
+	void Mul3Big3(const uint * x1, const uint * x0, const uint * y1, const uint * y0, uint * result)
+	{
+	uint i, c, xc, yc;
+
+		UInt<first_size>   temp, temp2;
+		UInt<first_size*3> z1;
+
+		// z0 and z2 we store directly in the result (we don't use any temporary variables)
+		Mul3Big2<first_size>(x0, y0, result);                  // z0
+		Mul3Big2<second_size>(x1, y1, result+first_size*2);    // z2
+
+		// now we calculate z1
+		// temp  = (x0 + x1)
+		// temp2 = (y0 + y1)
+		// we're using temp and temp2 with UInt<first_size>, although there can be a carry but 
+		// we simple remember it in xc and yc (xc and yc can be either 0 or 1),
+		// and (x0 + x1)*(y0 + y1) we calculate in this way (schoolbook algorithm):
+		// 
+		//                 xc     |     temp
+		//                 yc     |     temp2
+		//               --------------------
+		//               (temp    *   temp2)
+		//               xc*temp2 |
+		//               yc*temp  |
+		//       xc*yc |                     
+		//       ----------     z1     --------
+		//
+		// and the result is never larger in size than 3*first_size
+
+		xc = AddVector(x0, x1, first_size, second_size, temp.table);
+		yc = AddVector(y0, y1, first_size, second_size, temp2.table);
+
+		Mul3Big2<first_size>(temp.table, temp2.table, z1.table);
+
+		// clearing the rest of z1
+		for(i=first_size*2 ; i<first_size*3 ; ++i)
+			z1.table[i] = 0;
+
+		
+		if( xc )
+		{
+			c = AddVector(z1.table+first_size, temp2.table, first_size*3-first_size, first_size, z1.table+first_size);
+			TTMATH_ASSERT( c==0 )
+		}
+
+		if( yc )
+		{
+			c = AddVector(z1.table+first_size, temp.table, first_size*3-first_size, first_size, z1.table+first_size);
+			TTMATH_ASSERT( c==0 )
+		}
+
+
+		if( xc && yc )
+		{
+			for( i=first_size*2 ; i<first_size*3 ; ++i )
+				if( ++z1.table[i] != 0 )
+					break;  // break if there was no carry 
+		}
+
+		// z1 = z1 - z2
+		c = SubVector(z1.table, result+first_size*2, first_size*3, second_size*2, z1.table);
+		TTMATH_ASSERT(c==0)
+
+		// z1 = z1 - z0
+		c = SubVector(z1.table, result, first_size*3, first_size*2, z1.table);
+		TTMATH_ASSERT(c==0)
+
+		// here we've calculated the z1
+		// now we're adding it to the result
+
+		if( first_size > second_size )
+		{
+			uint z1_size = result_size - first_size;
+			TTMATH_ASSERT( z1_size <= first_size*3 )
+
+			for(i=z1_size ; i<first_size*3 ; ++i)
+			{
+				TTMATH_ASSERT( z1.table[i] == 0 )
+			}
+			
+			c = AddVector(result+first_size, z1.table, result_size-first_size, z1_size, result+first_size);
+			TTMATH_ASSERT(c==0)
+		}
+		else
+		{
+			c = AddVector(result+first_size, z1.table, result_size-first_size, first_size*3, result+first_size);
+			TTMATH_ASSERT(c==0)
+		}
+	}
+
+
+
+#ifdef _MSC_VER
+#pragma warning (default : 4717)
+#endif
+
+
+public:
+
+
+	/*!
+		multiplication this = this * ss2
+	*/
+	uint MulFastest(const UInt<value_size> & ss2)
+	{
+	UInt<value_size*2> result;
+	uint i, c = 0;
+
+		MulFastestBig(ss2, result);
+	
+		// copying result
+		for(i=0 ; i<value_size ; ++i)
+			table[i] = result.table[i];
+
+		// testing carry
+		for( ; i<value_size*2 ; ++i)
+			if( result.table[i] != 0 )
+			{
+				c = 1;
+				break;
+			}
+
+		TTMATH_LOGC("UInt::MulFastest", c)
+
+	return c;
+	}
+
+
+	/*!
+		multiplication result = this * ss2
+
+		this method is trying to select the fastest algorithm
+		(in the future this method can be improved)
+	*/
+	void MulFastestBig(const UInt<value_size> & ss2, UInt<value_size*2> & result)
+	{
+		if( value_size < TTMATH_USE_KARATSUBA_MULTIPLICATION_FROM_SIZE )
+			return Mul2Big(ss2, result);
+
+		uint x1size  = value_size, x2size  = value_size;
+		uint x1start = 0,          x2start = 0;
+
+		for(x1size=value_size ; x1size>0 && table[x1size-1]==0 ; --x1size);
+		for(x2size=value_size ; x2size>0 && ss2.table[x2size-1]==0 ; --x2size);
+
+		if( x1size==0 || x2size==0 )
+		{
+			// either 'this' or 'ss2' is equal zero - the result is zero too
+			result.SetZero();
+			return;
+		}
+
+		for(x1start=0 ; x1start<x1size && table[x1start]==0 ; ++x1start);
+		for(x2start=0 ; x2start<x2size && ss2.table[x2start]==0 ; ++x2start);
+
+		uint distancex1 = x1size - x1start;
+		uint distancex2 = x2size - x2start;
+
+		if( distancex1 < 3 || distancex2 < 3 )
+			// either 'this' or 'ss2' have only 2 (or 1) items different from zero (side by side)
+			// (this condition in the future can be improved)
+			return Mul2Big3<value_size>(table, ss2.table, result, x1start, x1size, x2start, x2size);
+
+
+		// Karatsuba multiplication
+		Mul3Big(ss2, result);
+
+		TTMATH_LOG("UInt::MulFastestBig")
+	}
+
+
+	/*!
+	 *
+	 * Division
+	 *
+	 *
+	*/
+	
+public:
+
+
+	/*!
+		division by one unsigned word
+
+		returns 1 when divisor is zero
+	*/
+	uint DivInt(uint divisor, uint * remainder = 0)
+	{
+		if( divisor == 0 )
+		{
+			if( remainder )
+				*remainder = 0; // this is for convenience, without it the compiler can report that 'remainder' is uninitialized
+
+			TTMATH_LOG("UInt::DivInt")
+
+		return 1;
+		}
+
+		if( divisor == 1 )
+		{
+			if( remainder )
+				*remainder = 0;
+
+			TTMATH_LOG("UInt::DivInt")
+
+		return 0;
+		}
+
+		UInt<value_size> dividend(*this);
+		SetZero();
+		
+		sint i;  // i must be with a sign
+		uint r = 0;
+
+		// we're looking for the last word in ss1
+		for(i=value_size-1 ; i>0 && dividend.table[i]==0 ; --i);
+
+		for( ; i>=0 ; --i)
+			DivTwoWords(r, dividend.table[i], divisor, &table[i], &r);
+
+		if( remainder )
+			*remainder = r;
+
+		TTMATH_LOG("UInt::DivInt")
+
+	return 0;
+	}
+
+	uint DivInt(uint divisor, uint & remainder)
+	{
+		return DivInt(divisor, &remainder);
+	}
+
+
+
+	/*!
+		division this = this / ss2
+		
+		return values:
+			 0 - ok
+			 1 - division by zero
+			'this' will be the quotient
+			'remainder' - remainder
+	*/
+	uint Div(	const UInt<value_size> & divisor,
+				UInt<value_size> * remainder = 0,
+				uint algorithm = 3)
+	{
+		switch( algorithm )
+		{
+		case 1:
+			return Div1(divisor, remainder);
+
+		case 2:
+			return Div2(divisor, remainder);
+
+		case 3:
+		default:
+			return Div3(divisor, remainder);
+		}
+	}
+
+	uint Div(const UInt<value_size> & divisor, UInt<value_size> & remainder, uint algorithm = 3)
+	{
+		return Div(divisor, &remainder, algorithm);
+	}
+
+
+
+private:
+
+	/*!
+		return values:
+		0 - none has to be done
+		1 - division by zero
+		2 - division should be made
+	*/
+	uint Div_StandardTest(	const UInt<value_size> & v,
+							uint & m, uint & n,
+							UInt<value_size> * remainder = 0)
+	{
+		switch( Div_CalculatingSize(v, m, n) )
+		{
+		case 4: // 'this' is equal v
+			if( remainder )
+				remainder->SetZero();
+
+			SetOne();
+			TTMATH_LOG("UInt::Div_StandardTest")
+			return 0;
+
+		case 3: // 'this' is smaller than v
+			if( remainder )
+				*remainder = *this;
+
+			SetZero();
+			TTMATH_LOG("UInt::Div_StandardTest")
+			return 0;
+
+		case 2: // 'this' is zero
+			if( remainder )
+				remainder->SetZero();
+
+			SetZero();
+			TTMATH_LOG("UInt::Div_StandardTest")
+			return 0;
+
+		case 1: // v is zero
+			TTMATH_LOG("UInt::Div_StandardTest")
+			return 1;
+		}
+
+		TTMATH_LOG("UInt::Div_StandardTest")
+
+	return 2;
+	}
+
+
+
+	/*!
+		return values:
+		0 - ok 
+			'm' - is the index (from 0) of last non-zero word in table ('this')
+			'n' - is the index (from 0) of last non-zero word in v.table
+		1 - v is zero 
+		2 - 'this' is zero
+		3 - 'this' is smaller than v
+		4 - 'this' is equal v
+
+		if the return value is different than zero the 'm' and 'n' are undefined
+	*/
+	uint Div_CalculatingSize(const UInt<value_size> & v, uint & m, uint & n)
+	{
+		m = n = value_size-1;
+
+		for( ; n!=0 && v.table[n]==0 ; --n);
+
+		if( n==0 && v.table[n]==0 )
+			return 1;
+
+		for( ; m!=0 && table[m]==0 ; --m);
+
+		if( m==0 && table[m]==0 )
+			return 2;
+
+		if( m < n )
+			return 3;
+		else
+		if( m == n )
+		{
+			uint i;
+			for(i = n ; i!=0 && table[i]==v.table[i] ; --i);
+			
+			if( table[i] < v.table[i] )
+				return 3;
+			else
+			if (table[i] == v.table[i] )
+				return 4;
+		}
+
+	return 0;
+	}
+
+
+public:
+
+	/*!
+		the first division algorithm
+		radix 2
+	*/
+	uint Div1(const UInt<value_size> & divisor, UInt<value_size> * remainder = 0)
+	{
+	uint m,n, test;
+
+		test = Div_StandardTest(divisor, m, n, remainder);
+		if( test < 2 )
+			return test;
+
+		if( !remainder )
+		{
+			UInt<value_size> rem;
+	
+		return Div1_Calculate(divisor, rem);
+		}
+
+	return Div1_Calculate(divisor, *remainder);
+	}
+
+
+	/*!
+		the first division algorithm
+		radix 2
+	*/
+	uint Div1(const UInt<value_size> & divisor, UInt<value_size> & remainder)
+	{
+		return Div1(divisor, &remainder);
+	}
+
+
+private:
+
+	uint Div1_Calculate(const UInt<value_size> & divisor, UInt<value_size> & rest)
+	{
+		if( this == &divisor )
+		{
+			UInt<value_size> divisor_copy(divisor);
+			return Div1_CalculateRef(divisor_copy, rest);
+		}
+		else
+		{
+			return Div1_CalculateRef(divisor, rest);
+		}
+	}
+
+
+	uint Div1_CalculateRef(const UInt<value_size> & divisor, UInt<value_size> & rest)
+	{
+	TTMATH_REFERENCE_ASSERT( divisor )
+	
+	sint loop;
+	sint c;
+
+		rest.SetZero();
+		loop = value_size * TTMATH_BITS_PER_UINT;
+		c = 0;
+
+		
+	div_a:
+		c = Rcl(1, c);
+		c = rest.Add(rest,c);
+		c = rest.Sub(divisor,c);
+
+		c = !c;
+
+		if(!c)
+			goto div_d;
+
+
+	div_b:
+		--loop;
+		if(loop)
+			goto div_a;
+
+		c = Rcl(1, c);
+		TTMATH_LOG("UInt::Div1_Calculate")
+		return 0;
+
+
+	div_c:
+		c = Rcl(1, c);
+		c = rest.Add(rest,c);
+		c = rest.Add(divisor);
+
+		if(c)
+			goto div_b;
+
+
+	div_d:
+		--loop;
+		if(loop)
+			goto div_c;
+
+		c = Rcl(1, c);
+		c = rest.Add(divisor);
+
+		TTMATH_LOG("UInt::Div1_Calculate")
+
+	return 0;
+	}
+	
+
+public:
+
+	/*!
+		the second division algorithm
+
+		return values:
+			0 - ok
+			1 - division by zero
+	*/
+	uint Div2(const UInt<value_size> & divisor, UInt<value_size> * remainder = 0)
+	{
+		if( this == &divisor )
+		{
+			UInt<value_size> divisor_copy(divisor);
+			return Div2Ref(divisor_copy, remainder);
+		}
+		else
+		{
+			return Div2Ref(divisor, remainder);
+		}
+	}
+
+
+	/*!
+		the second division algorithm
+
+		return values:
+			0 - ok
+			1 - division by zero
+	*/
+	uint Div2(const UInt<value_size> & divisor, UInt<value_size> & remainder)
+	{
+		return Div2(divisor, &remainder);
+	}
+
+
+private:
+
+	/*!
+		the second division algorithm
+
+		return values:
+			0 - ok
+			1 - division by zero
+	*/
+	uint Div2Ref(const UInt<value_size> & divisor, UInt<value_size> * remainder = 0)
+	{
+		uint bits_diff;
+		uint status = Div2_Calculate(divisor, remainder, bits_diff);
+		if( status < 2 )
+			return status;
+
+		if( CmpBiggerEqual(divisor) )
+		{
+			Div2(divisor, remainder);
+			SetBit(bits_diff);
+		}
+		else
+		{
+			if( remainder )
+				*remainder = *this;
+
+			SetZero();
+			SetBit(bits_diff);
+		}
+
+		TTMATH_LOG("UInt::Div2")
+
+	return 0;
+	}
+
+
+	/*!
+		return values:
+			0 - we've calculated the division
+			1 - division by zero
+			2 - we have to still calculate
+
+	*/
+	uint Div2_Calculate(const UInt<value_size> & divisor, UInt<value_size> * remainder,
+															uint & bits_diff)
+	{
+	uint table_id, index;
+	uint divisor_table_id, divisor_index;
+
+		uint status = Div2_FindLeadingBitsAndCheck(	divisor, remainder,
+													table_id, index,
+													divisor_table_id, divisor_index);
+
+		if( status < 2 )
+		{
+			TTMATH_LOG("UInt::Div2_Calculate")
+			return status;
+		}
+		
+		// here we know that 'this' is greater than divisor
+		// then 'index' is greater or equal 'divisor_index'
+		bits_diff = index - divisor_index;
+
+		UInt<value_size> divisor_copy(divisor);
+		divisor_copy.Rcl(bits_diff, 0);
+
+		if( CmpSmaller(divisor_copy, table_id) )
+		{
+			divisor_copy.Rcr(1);
+			--bits_diff;
+		}
+
+		Sub(divisor_copy, 0);
+
+		TTMATH_LOG("UInt::Div2_Calculate")
+
+	return 2;
+	}
+
+
+	/*!
+		return values:
+			0 - we've calculated the division
+			1 - division by zero
+			2 - we have to still calculate
+	*/
+	uint Div2_FindLeadingBitsAndCheck(	const UInt<value_size> & divisor,
+										UInt<value_size> * remainder,
+										uint & table_id, uint & index,
+										uint & divisor_table_id, uint & divisor_index)
+	{
+		if( !divisor.FindLeadingBit(divisor_table_id, divisor_index) )
+		{
+			// division by zero
+			TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
+			return 1;
+		}
+
+		if(	!FindLeadingBit(table_id, index) )
+		{
+			// zero is divided by something
+			
+			SetZero();
+
+			if( remainder )
+				remainder->SetZero();
+
+			TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
+
+		return 0;
+		}
+	
+		divisor_index += divisor_table_id * TTMATH_BITS_PER_UINT;
+		index         += table_id         * TTMATH_BITS_PER_UINT;
+
+		if( divisor_table_id == 0 )
+		{
+			// dividor has only one 32-bit word
+
+			uint r;
+			DivInt(divisor.table[0], &r);
+
+			if( remainder )
+			{
+				remainder->SetZero();
+				remainder->table[0] = r;
+			}
+
+			TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
+
+		return 0;
+		}
+	
+
+		if( Div2_DivisorGreaterOrEqual(	divisor, remainder,
+										table_id, index,
+										divisor_index) )
+		{
+			TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
+			return 0;
+		}
+
+
+		TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
+
+	return 2;
+	}
+
+
+	/*!
+		return values:
+			true if divisor is equal or greater than 'this'
+	*/
+	bool Div2_DivisorGreaterOrEqual(	const UInt<value_size> & divisor,
+										UInt<value_size> * remainder, 
+										uint table_id, uint index,
+										uint divisor_index  )
+	{
+		if( divisor_index > index )
+		{
+			// divisor is greater than this
+
+			if( remainder )
+				*remainder = *this;
+
+			SetZero();
+
+			TTMATH_LOG("UInt::Div2_DivisorGreaterOrEqual")
+
+		return true;
+		}
+
+		if( divisor_index == index )
+		{
+			// table_id == divisor_table_id as well
+
+			uint i;
+			for(i = table_id ; i!=0 && table[i]==divisor.table[i] ; --i);
+			
+			if( table[i] < divisor.table[i] )
+			{
+				// divisor is greater than 'this'
+
+				if( remainder )
+					*remainder = *this;
+
+				SetZero();
+
+				TTMATH_LOG("UInt::Div2_DivisorGreaterOrEqual")
+
+			return true;
+			}
+			else
+			if( table[i] == divisor.table[i] )
+			{
+				// divisor is equal 'this'
+
+				if( remainder )
+					remainder->SetZero();
+
+				SetOne();
+
+				TTMATH_LOG("UInt::Div2_DivisorGreaterOrEqual")
+
+			return true;
+			}
+		}
+
+		TTMATH_LOG("UInt::Div2_DivisorGreaterOrEqual")
+
+	return false;
+	}
+
+
+public:
+
+	/*!
+		the third division algorithm
+	*/
+	uint Div3(const UInt<value_size> & ss2, UInt<value_size> * remainder = 0)
+	{
+		if( this == &ss2 )
+		{
+			UInt<value_size> copy_ss2(ss2);
+			return Div3Ref(copy_ss2, remainder);
+		}
+		else
+		{
+			return Div3Ref(ss2, remainder);
+		}
+	}
+
+
+	/*!
+		the third division algorithm
+	*/
+	uint Div3(const UInt<value_size> & ss2, UInt<value_size> & remainder)
+	{
+		return Div3(ss2, &remainder);
+	}
+
+
+private:
+
+	/*!
+		the third division algorithm
+
+		this algorithm is described in the following book:
+			"The art of computer programming 2" (4.3.1 page 272)
+			Donald E. Knuth 
+		!! give the description here (from the book)
+	*/
+	uint Div3Ref(const UInt<value_size> & v, UInt<value_size> * remainder = 0)
+	{
+	uint m,n, test;
+
+		test = Div_StandardTest(v, m, n, remainder);
+		if( test < 2 )
+			return test;
+
+		if( n == 0 )
+		{
+			uint r;
+			DivInt( v.table[0], &r );
+
+			if( remainder )
+			{
+				remainder->SetZero();
+				remainder->table[0] = r;
+			}
+
+			TTMATH_LOG("UInt::Div3")
+
+		return 0;
+		}
+
+
+		// we can only use the third division algorithm when 
+		// the divisor is greater or equal 2^32 (has more than one 32-bit word)
+		++m;
+		++n;
+		m = m - n; 
+		Div3_Division(v, remainder, m, n);
+
+		TTMATH_LOG("UInt::Div3")
+
+	return 0;
+	}
+
+
+
+private:
+
+
+	void Div3_Division(UInt<value_size> v, UInt<value_size> * remainder, uint m, uint n)
+	{
+	TTMATH_ASSERT( n>=2 )
+
+	UInt<value_size+1> uu, vv;
+	UInt<value_size> q;
+	uint d, u_value_size, u0, u1, u2, v1, v0, j=m;	
+	
+		u_value_size = Div3_Normalize(v, n, d);
+
+		if( j+n == value_size )
+			u2 = u_value_size;
+		else
+			u2 = table[j+n];
+
+		Div3_MakeBiggerV(v, vv);
+
+		for(uint i = j+1 ; i<value_size ; ++i)
+			q.table[i] = 0;
+
+		while( true )
+		{
+			u1 = table[j+n-1];
+			u0 = table[j+n-2];
+			v1 = v.table[n-1];
+			v0 = v.table[n-2];
+
+			uint qp = Div3_Calculate(u2,u1,u0, v1,v0);
+
+			Div3_MakeNewU(uu, j, n, u2);
+			Div3_MultiplySubtract(uu, vv, qp);
+			Div3_CopyNewU(uu, j, n);
+
+			q.table[j] = qp;
+
+			// the next loop
+			if( j-- == 0 )
+				break;
+
+			u2 = table[j+n];
+		}
+
+		if( remainder )
+			Div3_Unnormalize(remainder, n, d);
+
+	*this = q;
+
+	TTMATH_LOG("UInt::Div3_Division")
+	}
+
+
+	void Div3_MakeNewU(UInt<value_size+1> & uu, uint j, uint n, uint u_max)
+	{
+	uint i;
+
+		for(i=0 ; i<n ; ++i, ++j)
+			uu.table[i] = table[j];
+
+		// 'n' is from <1..value_size> so and 'i' is from <0..value_size>
+		// then table[i] is always correct (look at the declaration of 'uu')
+		uu.table[i] = u_max;
+
+		for( ++i ; i<value_size+1 ; ++i)
+			uu.table[i] = 0;
+
+		TTMATH_LOG("UInt::Div3_MakeNewU")
+	}
+
+
+	void Div3_CopyNewU(const UInt<value_size+1> & uu, uint j, uint n)
+	{
+	uint i;
+
+		for(i=0 ; i<n ; ++i)
+			table[i+j] = uu.table[i];
+
+		if( i+j < value_size )
+			table[i+j] = uu.table[i];
+
+		TTMATH_LOG("UInt::Div3_CopyNewU")
+	}
+
+
+	/*!
+		we're making the new 'vv' 
+		the value is actually the same but the 'table' is bigger (value_size+1)
+	*/
+	void Div3_MakeBiggerV(const UInt<value_size> & v, UInt<value_size+1> & vv)
+	{
+		for(uint i=0 ; i<value_size ; ++i)
+			vv.table[i] = v.table[i];
+
+		vv.table[value_size] = 0;
+
+		TTMATH_LOG("UInt::Div3_MakeBiggerV")
+	}
+	
+
+	/*!
+		we're moving all bits from 'v' into the left side of the n-1 word
+		(the highest bit at v.table[n-1] will be equal one,
+		the bits from 'this' we're moving the same times as 'v')
+
+		return values:
+		  d - how many times we've moved
+		  return - the next-left value from 'this' (that after table[value_size-1])
+	*/
+	uint Div3_Normalize(UInt<value_size> & v, uint n, uint & d)
+	{
+		// v.table[n-1] is != 0
+
+		uint bit  = (uint)FindLeadingBitInWord(v.table[n-1]);
+		uint move = (TTMATH_BITS_PER_UINT - bit - 1);
+		uint res  = table[value_size-1];
+		d         = move;
+
+		if( move > 0 )
+		{
+			v.Rcl(move, 0);
+			Rcl(move, 0);
+			res = res >> (bit + 1);
+		}
+		else
+		{
+			res = 0;
+		}
+
+		TTMATH_LOG("UInt::Div3_Normalize")
+
+	return res;
+	}
+
+
+	void Div3_Unnormalize(UInt<value_size> * remainder, uint n, uint d)
+	{
+		for(uint i=n ; i<value_size ; ++i)
+			table[i] = 0;
+
+		Rcr(d,0);
+
+		*remainder = *this;
+
+		TTMATH_LOG("UInt::Div3_Unnormalize")
+	}
+
+
+	uint Div3_Calculate(uint u2, uint u1, uint u0, uint v1, uint v0)
+	{	
+	UInt<2> u_temp;
+	uint rp;
+	bool next_test;
+
+		TTMATH_ASSERT( v1 != 0 )
+
+		u_temp.table[1] = u2;
+		u_temp.table[0] = u1;
+		u_temp.DivInt(v1, &rp);
+
+		TTMATH_ASSERT( u_temp.table[1]==0 || u_temp.table[1]==1 )
+
+		do
+		{
+			bool decrease = false;
+
+			if( u_temp.table[1] == 1 )
+				decrease = true;
+			else
+			{
+				UInt<2> temp1, temp2;
+
+				UInt<2>::MulTwoWords(u_temp.table[0], v0, temp1.table+1, temp1.table);
+				temp2.table[1] = rp;
+				temp2.table[0] = u0;
+
+				if( temp1 > temp2 )
+					decrease = true;
+			}
+
+			next_test = false;
+
+			if( decrease )
+			{
+				u_temp.SubOne();
+
+				rp += v1;
+
+				if( rp >= v1 ) // it means that there wasn't a carry (r<b from the book)
+					next_test = true;
+			}
+		}
+		while( next_test );
+
+		TTMATH_LOG("UInt::Div3_Calculate")
+
+	return u_temp.table[0];
+	}
+
+
+
+	void Div3_MultiplySubtract(	UInt<value_size+1> & uu,
+								const UInt<value_size+1> & vv, uint & qp)
+	{
+		// D4 (in the book)
+
+		UInt<value_size+1> vv_temp(vv);
+		vv_temp.MulInt(qp);
+
+		if( uu.Sub(vv_temp) )  
+		{
+			// there was a carry
+			
+			//
+			// !!! this part of code was not tested
+			//
+
+			--qp;
+			uu.Add(vv);
+
+			// can be a carry from this additions but it should be ignored 
+			// because it cancels with the borrow from uu.Sub(vv_temp)
+		}
+
+		TTMATH_LOG("UInt::Div3_MultiplySubtract")
+	}
+
+
+
+
+
+
+public:
+
+
+	/*!
+		power this = this ^ pow
+		binary algorithm (r-to-l)
+
+		return values:
+		0 - ok
+		1 - carry
+		2 - incorrect argument (0^0)
+	*/
+	uint Pow(UInt<value_size> pow)
+	{
+		if(pow.IsZero() && IsZero())
+			// we don't define zero^zero
+			return 2;
+
+		UInt<value_size> start(*this);
+		UInt<value_size> result;
+		result.SetOne();
+		uint c = 0;
+
+		while( !c )
+		{
+			if( pow.table[0] & 1 )
+				c += result.Mul(start);
+
+			pow.Rcr2_one(0);
+			if( pow.IsZero() )
+				break;
+
+			c += start.Mul(start);
+		}
+
+		*this = result;
+
+		TTMATH_LOGC("UInt::Pow(UInt<>)", c)
+
+	return (c==0)? 0 : 1;
+	}
+
+
+	/*!
+		square root
+		e.g. Sqrt(9) = 3
+		('digit-by-digit' algorithm)
+	*/
+	void Sqrt()
+	{
+	UInt<value_size> bit, temp;
+
+		if( IsZero() )
+			return;
+
+		UInt<value_size> value(*this);
+
+		SetZero();
+		bit.SetZero();
+		bit.table[value_size-1] = (TTMATH_UINT_HIGHEST_BIT >> 1);
+		
+		while( bit > value )
+			bit.Rcr(2);
+
+		while( !bit.IsZero() )
+		{
+			temp = *this;
+			temp.Add(bit);
+
+			if( value >= temp )
+			{
+				value.Sub(temp);
+				Rcr(1);
+				Add(bit);
+			}
+			else
+			{
+				Rcr(1);
+			}
+
+			bit.Rcr(2);
+		}
+
+		TTMATH_LOG("UInt::Sqrt")
+	}
+
+
+
+	/*!
+		this method sets n first bits to value zero
+
+		For example:
+		let n=2 then if there's a value 111 (bin) there'll be '100' (bin)
+	*/
+	void ClearFirstBits(uint n)
+	{
+		if( n >= value_size*TTMATH_BITS_PER_UINT )
+		{
+			SetZero();
+			TTMATH_LOG("UInt::ClearFirstBits")
+			return;
+		}
+
+		uint * p = table;
+
+		// first we're clearing the whole words
+		while( n >= TTMATH_BITS_PER_UINT )
+		{
+			*p++ = 0;
+			n   -= TTMATH_BITS_PER_UINT;
+		}
+
+		if( n == 0 )
+		{
+			TTMATH_LOG("UInt::ClearFirstBits")
+			return;
+		}
+
+		// and then we're clearing one word which has left
+		// mask -- all bits are set to one
+		uint mask = TTMATH_UINT_MAX_VALUE;
+
+		mask = mask << n;
+
+		(*p) &= mask;
+
+		TTMATH_LOG("UInt::ClearFirstBits")
+	}
+
+
+	/*!
+		this method returns true if the highest bit of the value is set
+	*/
+	bool IsTheHighestBitSet() const
+	{
+		return (table[value_size-1] & TTMATH_UINT_HIGHEST_BIT) != 0;
+	}
+
+
+	/*!
+		this method returns true if the lowest bit of the value is set
+	*/
+	bool IsTheLowestBitSet() const
+	{
+		return (*table & 1) != 0;
+	}
+
+
+	/*!
+		returning true if only the highest bit is set
+	*/
+	bool IsOnlyTheHighestBitSet() const
+	{
+		for(uint i=0 ; i<value_size-1 ; ++i)
+			if( table[i] != 0 )
+				return false;
+
+		if( table[value_size-1] != TTMATH_UINT_HIGHEST_BIT )
+			return false;
+
+	return true;
+	}
+
+
+	/*!
+		returning true if only the lowest bit is set
+	*/
+	bool IsOnlyTheLowestBitSet() const
+	{
+		if( table[0] != 1 )
+			return false;
+
+		for(uint i=1 ; i<value_size ; ++i)
+			if( table[i] != 0 )
+				return false;
+
+	return true;
+	}
+
+
+	/*!
+		this method returns true if the value is equal zero
+	*/
+	bool IsZero() const
+	{
+		for(uint i=0 ; i<value_size ; ++i)
+			if(table[i] != 0)
+				return false;
+
+	return true;
+	}
+
+
+	/*!
+		returning true if first 'bits' bits are equal zero
+	*/
+	bool AreFirstBitsZero(uint bits) const
+	{
+		TTMATH_ASSERT( bits <= value_size * TTMATH_BITS_PER_UINT )
+
+		uint index = bits / TTMATH_BITS_PER_UINT;
+		uint rest  = bits % TTMATH_BITS_PER_UINT;
+		uint i;
+
+		for(i=0 ; i<index ; ++i)
+			if(table[i] != 0 )
+				return false;
+
+		if( rest == 0 )
+			return true;
+
+		uint mask = TTMATH_UINT_MAX_VALUE >> (TTMATH_BITS_PER_UINT - rest);
+
+	return (table[i] & mask) == 0;
+	}
+
+
+
+	/*!
+	*
+	*	conversion methods
+	*
+	*/
+
+
+
+	/*!
+		this method converts an UInt<another_size> type to this class
+
+		this operation has mainly sense if the value from p is 
+		equal or smaller than that one which is returned from UInt<value_size>::SetMax()
+
+		it returns a carry if the value 'p' is too big
+	*/
+	template<uint argument_size>
+	uint FromUInt(const UInt<argument_size> & p)
+	{
+		uint min_size = (value_size < argument_size)? value_size : argument_size;
+		uint i;
+
+		for(i=0 ; i<min_size ; ++i)
+			table[i] = p.table[i];
+
+
+		if( value_size > argument_size )
+		{	
+			// 'this' is longer than 'p'
+
+			for( ; i<value_size ; ++i)
+				table[i] = 0;
+		}
+		else
+		{
+			for( ; i<argument_size ; ++i)
+				if( p.table[i] != 0 )
+				{
+					TTMATH_LOGC("UInt::FromUInt(UInt<>)", 1)
+					return 1;
+				}
+		}
+
+		TTMATH_LOGC("UInt::FromUInt(UInt<>)", 0)
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts an UInt<another_size> type to this class
+
+		this operation has mainly sense if the value from p is 
+		equal or smaller than that one which is returned from UInt<value_size>::SetMax()
+
+		it returns a carry if the value 'p' is too big
+	*/
+	template<uint argument_size>
+	uint FromInt(const UInt<argument_size> & p)
+	{
+		return FromUInt(p);
+	}
+
+
+	/*!
+		this method converts the uint type to this class
+	*/
+	uint FromUInt(uint value)
+	{
+		for(uint i=1 ; i<value_size ; ++i)
+			table[i] = 0;
+
+		table[0] = value;
+
+		TTMATH_LOG("UInt::FromUInt(uint)")
+
+		// there'll never be a carry here
+	return 0;
+	}
+
+
+	/*!
+		this method converts the uint type to this class
+	*/
+	uint FromInt(uint value)
+	{
+		return FromUInt(value);
+	}
+
+
+	/*!
+		this method converts the sint type to this class
+	*/
+	uint FromInt(sint value)
+	{
+		uint c = FromUInt(uint(value));
+
+		if( c || value < 0 )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this operator converts an UInt<another_size> type to this class
+
+		it doesn't return a carry
+	*/
+	template<uint argument_size>
+	UInt<value_size> & operator=(const UInt<argument_size> & p)
+	{
+		FromUInt(p);
+
+	return *this;
+	}
+
+
+	/*!
+		the assignment operator
+	*/
+	UInt<value_size> & operator=(const UInt<value_size> & p)
+	{
+		for(uint i=0 ; i<value_size ; ++i)
+			table[i] = p.table[i];
+
+		TTMATH_LOG("UInt::operator=(UInt<>)")
+
+		return *this;
+	}
+
+
+	/*!
+		this method converts the uint type to this class
+	*/
+	UInt<value_size> & operator=(uint i)
+	{
+		FromUInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting the uint to this class
+	*/
+	UInt(uint i)
+	{
+		FromUInt(i);
+	}
+
+
+	/*!
+		this method converts the sint type to this class
+	*/
+	UInt<value_size> & operator=(sint i)
+	{
+		FromInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting the sint to this class
+
+		look at the description of UInt::operator=(sint)
+	*/
+	UInt(sint i)
+	{
+		FromInt(i);
+	}
+
+
+#ifdef TTMATH_PLATFORM32
+
+
+	/*!
+		this method converts unsigned 64 bit int type to this class
+		***this method is created only on a 32bit platform***
+	*/
+	uint FromUInt(ulint n)
+	{
+		table[0] = (uint)n;
+
+		if( value_size == 1 )
+		{
+			uint c = ((n >> TTMATH_BITS_PER_UINT) == 0) ? 0 : 1;
+
+			TTMATH_LOGC("UInt::FromUInt(ulint)", c)
+			return c;
+		}
+
+		table[1] = (uint)(n >> TTMATH_BITS_PER_UINT);
+
+		for(uint i=2 ; i<value_size ; ++i)
+			table[i] = 0;
+
+		TTMATH_LOG("UInt::FromUInt(ulint)")
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts unsigned 64 bit int type to this class
+		***this method is created only on a 32bit platform***
+	*/
+	uint FromInt(ulint n)
+	{
+		return FromUInt(n);
+	}
+
+
+	/*!
+		this method converts signed 64 bit int type to this class
+		***this method is created only on a 32bit platform***
+	*/
+	uint FromInt(slint n)
+	{
+		uint c = FromUInt(ulint(n));
+
+		if( c || n < 0 )
+			return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this operator converts unsigned 64 bit int type to this class
+		***this operator is created only on a 32bit platform***
+	*/
+	UInt<value_size> & operator=(ulint n)
+	{
+		FromUInt(n);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting unsigned 64 bit int to this class
+		***this constructor is created only on a 32bit platform***
+	*/
+	UInt(ulint n)
+	{
+		FromUInt(n);
+	}
+
+
+	/*!
+		this operator converts signed 64 bit int type to this class
+		***this operator is created only on a 32bit platform***
+	*/
+	UInt<value_size> & operator=(slint n)
+	{
+		FromInt(n);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting signed 64 bit int to this class
+		***this constructor is created only on a 32bit platform***
+	*/
+	UInt(slint n)
+	{
+		FromInt(n);
+	}
+
+#endif
+
+
+
+#ifdef TTMATH_PLATFORM64
+
+
+	/*!
+		this method converts 32 bit unsigned int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	uint FromUInt(unsigned int i)
+	{
+		return FromUInt(uint(i));
+	}
+
+	/*!
+		this method converts 32 bit unsigned int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	uint FromInt(unsigned int i)
+	{
+		return FromUInt(uint(i));
+	}
+
+
+	/*!
+		this method converts 32 bit signed int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	uint FromInt(signed int i)
+	{
+		return FromInt(sint(i));
+	}
+
+
+	/*!
+		this operator converts 32 bit unsigned int type to this class
+		***this operator is created only on a 64bit platform***
+	*/
+	UInt<value_size> & operator=(unsigned int i)
+	{
+		FromUInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 32 bit unsigned int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	UInt(unsigned int i)
+	{
+		FromUInt(i);
+	}
+
+
+	/*!
+		an operator for converting 32 bit signed int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	UInt<value_size> & operator=(signed int i)
+	{
+		FromInt(i);
+
+	return *this;
+	}
+
+
+	/*!
+		a constructor for converting 32 bit signed int to this class
+		***this constructor is created only on a 64bit platform***
+	*/
+	UInt(signed int i)
+	{
+		FromInt(i);
+	}
+
+
+#endif
+
+
+
+
+
+	/*!
+		a constructor for converting a string to this class (with the base=10)
+	*/
+	UInt(const char * s)
+	{
+		FromString(s);
+	}
+
+
+	/*!
+		a constructor for converting a string to this class (with the base=10)
+	*/
+	UInt(const std::string & s)
+	{
+		FromString( s.c_str() );
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		a constructor for converting a string to this class (with the base=10)
+	*/
+	UInt(const wchar_t * s)
+	{
+		FromString(s);
+	}
+
+
+	/*!
+		a constructor for converting a string to this class (with the base=10)
+	*/
+	UInt(const std::wstring & s)
+	{
+		FromString( s.c_str() );
+	}
+
+#endif
+
+
+
+
+	/*!
+		a default constructor
+
+		we don't clear the table
+	*/
+	UInt()
+	{
+	// when macro TTMATH_DEBUG_LOG is defined
+	// we set special values to the table
+	// in order to be everywhere the same value of the UInt object
+	// without this it would be difficult to analyse the log file
+	#ifdef TTMATH_DEBUG_LOG
+		#ifdef TTMATH_PLATFORM32
+				for(uint i=0 ; i<value_size ; ++i)
+					table[i] = 0xc1c1c1c1;
+		#else
+				for(uint i=0 ; i<value_size ; ++i)
+					table[i] = 0xc1c1c1c1c1c1c1c1;
+		#endif
+	#endif
+	}
+
+
+	/*!
+		a copy constructor
+	*/
+	UInt(const UInt<value_size> & u)
+	{
+		for(uint i=0 ; i<value_size ; ++i)
+			table[i] = u.table[i];
+
+		TTMATH_LOG("UInt::UInt(UInt<>)")
+	}
+
+
+
+	/*!
+		a template for producting constructors for copying from another types
+	*/
+	template<uint argument_size>
+	UInt(const UInt<argument_size> & u)
+	{
+		// look that 'size' we still set as 'value_size' and not as u.value_size
+		FromUInt(u);
+	}
+
+
+
+
+	/*!
+		a destructor
+	*/
+	~UInt()
+	{
+	}
+
+
+	/*!
+		this method returns the lowest value from table
+
+		we must be sure when we using this method whether the value
+		will hold in an uint type or not (the rest value from the table must be zero)
+	*/
+	uint ToUInt() const
+	{
+		return table[0];
+	}
+
+
+	/*!
+		this method converts the value to uint type
+		can return a carry if the value is too long to store it in uint type
+	*/
+	uint ToUInt(uint & result) const
+	{
+		result = table[0];
+
+		for(uint i=1 ; i<value_size ; ++i)
+			if( table[i] != 0 )
+				return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts the value to uint type
+		can return a carry if the value is too long to store it in uint type
+	*/
+	uint ToInt(uint & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts the value to sint type (signed integer)
+		can return a carry if the value is too long to store it in sint type
+	*/
+	uint ToInt(sint & result) const
+	{
+		result = sint(table[0]);
+
+		if( (result & TTMATH_UINT_HIGHEST_BIT) != 0 )
+			return 1;
+
+		for(uint i=1 ; i<value_size ; ++i)
+			if( table[i] != 0 )
+				return 1;
+
+	return 0;
+	}
+
+
+#ifdef TTMATH_PLATFORM32
+
+	/*!
+		this method converts the value to ulint type (64 bit unsigned integer)
+		can return a carry if the value is too long to store it in ulint type
+		*** this method is created only on a 32 bit platform ***
+	*/
+	uint ToUInt(ulint & result) const
+	{
+		if( value_size == 1 )
+		{
+			result = table[0];
+		}
+		else
+		{
+			uint low  = table[0];
+			uint high = table[1];
+
+			result = low;
+			result |= (ulint(high) << TTMATH_BITS_PER_UINT);
+
+			for(uint i=2 ; i<value_size ; ++i)
+				if( table[i] != 0 )
+					return 1;
+		}
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts the value to ulint type (64 bit unsigned integer)
+		can return a carry if the value is too long to store it in ulint type
+		*** this method is created only on a 32 bit platform ***
+	*/
+	uint ToInt(ulint & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts the value to slint type (64 bit signed integer)
+		can return a carry if the value is too long to store it in slint type
+		*** this method is created only on a 32 bit platform ***
+	*/
+	uint ToInt(slint & result) const
+	{
+	ulint temp;
+
+		uint c = ToUInt(temp);
+		result = slint(temp);
+
+		if( c || result < 0 )
+			return 1;
+
+	return 0;
+	}
+
+#endif
+
+
+
+#ifdef TTMATH_PLATFORM64
+
+	/*!
+		this method converts the value to a 32 unsigned integer
+		can return a carry if the value is too long to store it in this type
+		*** this method is created only on a 64 bit platform ***
+	*/
+	uint ToUInt(unsigned int & result) const
+	{
+		result = (unsigned int)table[0];
+
+		if( (table[0] >> 32) != 0 )
+			return 1;
+
+		for(uint i=1 ; i<value_size ; ++i)
+			if( table[i] != 0 )
+				return 1;
+
+	return 0;
+	}
+
+
+	/*!
+		this method converts the value to a 32 unsigned integer
+		can return a carry if the value is too long to store it in this type
+		*** this method is created only on a 64 bit platform ***
+	*/
+	uint ToInt(unsigned int & result) const
+	{
+		return ToUInt(result);
+	}
+
+
+	/*!
+		this method converts the value to a 32 signed integer
+		can return a carry if the value is too long to store it in this type
+		*** this method is created only on a 64 bit platform ***
+	*/
+	uint ToInt(int & result) const
+	{
+	unsigned int temp;
+
+		uint c = ToUInt(temp);
+		result = int(temp);
+
+		if( c || result < 0 )
+			return 1;
+
+	return 0;
+	}
+
+
+#endif
+
+
+
+
+protected:
+
+	/*!
+		an auxiliary method for converting into the string
+		it returns the log (with the base 2) from x
+		where x is in <2;16>
+	*/
+	double ToStringLog2(uint x) const
+	{
+		static double log_tab[] = {
+			1.000000000000000000,
+			0.630929753571457437,
+			0.500000000000000000,
+			0.430676558073393050,
+			0.386852807234541586,
+			0.356207187108022176,
+			0.333333333333333333,
+			0.315464876785728718,
+			0.301029995663981195,
+			0.289064826317887859,
+			0.278942945651129843,
+			0.270238154427319741,
+			0.262649535037193547,
+			0.255958024809815489,
+			0.250000000000000000
+		};
+
+		if( x<2 || x>16 )
+			return 0;
+
+	return log_tab[x-2];
+	}
+
+
+	/*!	
+		an auxiliary method for converting to a string
+		it's used from Int::ToString() too (negative is set true then)
+	*/
+	template<class string_type>
+	void ToStringBase(string_type & result, uint b = 10, bool negative = false) const
+	{
+	UInt<value_size> temp(*this);
+	uint rest, table_id, index, digits;
+	double digits_d;
+	char character;
+
+		result.clear();
+
+		if( b<2 || b>16 )
+			return;
+
+		if( !FindLeadingBit(table_id, index) )
+		{
+			result = '0';
+			return;
+		}
+
+		if( negative )
+			result = '-';
+
+		digits_d  = table_id; // for not making an overflow in uint type
+		digits_d *= TTMATH_BITS_PER_UINT;
+		digits_d += index + 1;
+		digits_d *= ToStringLog2(b);
+		digits = static_cast<uint>(digits_d) + 3; // plus some epsilon
+
+		if( result.capacity() < digits )
+			result.reserve(digits);
+
+		do
+		{
+			temp.DivInt(b, &rest);
+			character = static_cast<char>(Misc::DigitToChar(rest));
+			result.insert(result.end(), character);
+		}
+		while( !temp.IsZero() );
+
+		size_t i1 = negative ? 1 : 0; // the first is a hyphen (when negative is true)
+		size_t i2 = result.size() - 1;
+
+		for( ; i1 < i2 ; ++i1, --i2 )
+		{
+			char tempc = static_cast<char>(result[i1]);
+			result[i1] = result[i2];
+			result[i2] = tempc;
+		}
+	}
+
+
+
+public:
+
+	/*!	
+		this method converts the value to a string with a base equal 'b'
+	*/
+	void ToString(std::string & result, uint b = 10) const
+	{
+		return ToStringBase(result, b);
+	}
+
+
+	std::string ToString(uint b = 10) const
+	{
+		std::string result;
+		ToStringBase(result, b);
+	
+	return result;
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	void ToString(std::wstring & result, uint b = 10) const
+	{
+		return ToStringBase(result, b);
+	}
+
+	std::wstring ToWString(uint b = 10) const
+	{
+		std::wstring result;
+		ToStringBase(result, b);
+	
+	return result;
+	}
+
+#endif
+
+
+
+private:
+
+	/*!
+		an auxiliary method for converting from a string
+	*/
+	template<class char_type>
+	uint FromStringBase(const char_type * s, uint b = 10, const char_type ** after_source = 0, bool * value_read = 0)
+	{
+	UInt<value_size> base( b );
+	UInt<value_size> temp;
+	sint z;
+	uint c = 0;
+
+		SetZero();
+		temp.SetZero();
+		Misc::SkipWhiteCharacters(s);
+
+		if( after_source )
+			*after_source = s;
+
+		if( value_read )
+			*value_read = false;
+
+		if( b<2 || b>16 )
+			return 1;
+
+
+		for( ; (z=Misc::CharToDigit(*s, b)) != -1 ; ++s)
+		{
+			if( value_read )
+				*value_read = true;
+
+			if( c == 0 )
+			{
+				temp.table[0] = z;
+
+				c += Mul(base);
+				c += Add(temp);
+			}
+		}		
+
+		if( after_source )
+			*after_source = s;
+
+		TTMATH_LOGC("UInt::FromString", c)
+
+	return (c==0)? 0 : 1;
+	}
+
+
+public:
+
+
+	/*!
+		this method converts a string into its value
+		it returns carry=1 if the value will be too big or an incorrect base 'b' is given
+
+		string is ended with a non-digit value, for example:
+			"12" will be translated to 12
+			as well as:
+			"12foo" will be translated to 12 too
+
+		existing first white characters will be ommited
+
+		if the value from s is too large the rest digits will be skipped
+
+		after_source (if exists) is pointing at the end of the parsed string
+
+		value_read (if exists) tells whether something has actually been read (at least one digit)
+	*/
+	uint FromString(const char * s, uint b = 10, const char ** after_source = 0, bool * value_read = 0)
+	{
+		return FromStringBase(s, b, after_source, value_read);
+	}
+
+
+	/*!
+		this method converts a string into its value
+
+		(it returns carry=1 if the value will be too big or an incorrect base 'b' is given)
+	*/
+	uint FromString(const std::string & s, uint b = 10)
+	{
+		return FromString( s.c_str(), b );
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	UInt<value_size> & operator=(const char * s)
+	{
+		FromString(s);
+
+	return *this;
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	UInt<value_size> & operator=(const std::string & s)
+	{
+		FromString( s.c_str() );
+
+	return *this;
+	}
+
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		this method converts a string into its value
+	*/
+	uint FromString(const wchar_t * s, uint b = 10, const wchar_t ** after_source = 0, bool * value_read = 0)
+	{
+		return FromStringBase(s, b, after_source, value_read);
+	}
+
+
+	/*!
+		this method converts a string into its value
+
+		(it returns carry=1 if the value will be too big or an incorrect base 'b' is given)
+	*/
+	uint FromString(const std::wstring & s, uint b = 10)
+	{
+		return FromString( s.c_str(), b );
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	UInt<value_size> & operator=(const wchar_t * s)
+	{
+		FromString(s);
+
+	return *this;
+	}
+
+
+	/*!
+		this operator converts a string into its value (with base = 10)
+	*/
+	UInt<value_size> & operator=(const std::wstring & s)
+	{
+		FromString( s.c_str() );
+
+	return *this;
+	}
+
+#endif
+
+
+	/*!
+	*
+	*	methods for comparing
+	*
+	*/
+
+
+	/*!
+		this method returns true if 'this' is smaller than 'l'
+
+		'index' is an index of the first word from will be the comparison performed
+		(note: we start the comparison from back - from the last word, when index is -1 /default/
+		it is automatically set into the last word)
+		I introduced it for some kind of optimization made in the second division algorithm (Div2)
+	*/
+	bool CmpSmaller(const UInt<value_size> & l, sint index = -1) const
+	{
+	sint i;
+
+		if( index==-1 || index>=sint(value_size) )
+			i = value_size - 1;
+		else
+			i = index;
+
+
+		for( ; i>=0 ; --i)
+		{
+			if( table[i] != l.table[i] )
+				return table[i] < l.table[i];
+		}
+
+	// they're equal
+	return false;
+	}
+
+
+
+	/*!
+		this method returns true if 'this' is bigger than 'l'
+
+		'index' is an index of the first word from will be the comparison performed
+		(note: we start the comparison from back - from the last word, when index is -1 /default/
+		it is automatically set into the last word)
+
+		I introduced it for some kind of optimization made in the second division algorithm (Div2)
+	*/
+	bool CmpBigger(const UInt<value_size> & l, sint index = -1) const
+	{
+	sint i;
+
+		if( index==-1 || index>=sint(value_size) )
+			i = value_size - 1;
+		else
+			i = index;
+
+
+		for( ; i>=0 ; --i)
+		{
+			if( table[i] != l.table[i] )
+				return table[i] > l.table[i];
+		}
+
+	// they're equal
+	return false;
+	}
+
+
+	/*!
+		this method returns true if 'this' is equal 'l'
+
+		'index' is an index of the first word from will be the comparison performed
+		(note: we start the comparison from back - from the last word, when index is -1 /default/
+		it is automatically set into the last word)
+	*/
+	bool CmpEqual(const UInt<value_size> & l, sint index = -1) const
+	{
+	sint i;
+
+		if( index==-1 || index>=sint(value_size) )
+			i = value_size - 1;
+		else
+			i = index;
+
+
+		for( ; i>=0 ; --i)
+			if( table[i] != l.table[i] )
+				return false;
+
+	return true;
+	}
+
+
+
+	/*!
+		this method returns true if 'this' is smaller than or equal 'l'
+
+		'index' is an index of the first word from will be the comparison performed
+		(note: we start the comparison from back - from the last word, when index is -1 /default/
+		it is automatically set into the last word)
+	*/
+	bool CmpSmallerEqual(const UInt<value_size> & l, sint index=-1) const
+	{
+	sint i;
+
+		if( index==-1 || index>=sint(value_size) )
+			i = value_size - 1;
+		else
+			i = index;
+
+
+		for( ; i>=0 ; --i)
+		{
+			if( table[i] != l.table[i] )
+				return table[i] < l.table[i];
+		}
+
+	// they're equal
+	return true;
+	}
+
+
+
+	/*!
+		this method returns true if 'this' is bigger than or equal 'l'
+
+		'index' is an index of the first word from will be the comparison performed
+		(note: we start the comparison from back - from the last word, when index is -1 /default/
+		it is automatically set into the last word)
+	*/
+	bool CmpBiggerEqual(const UInt<value_size> & l, sint index=-1) const
+	{
+	sint i;
+
+		if( index==-1 || index>=sint(value_size) )
+			i = value_size - 1;
+		else
+			i = index;
+
+
+		for( ; i>=0 ; --i)
+		{
+			if( table[i] != l.table[i] )
+				return table[i] > l.table[i];
+		}
+
+	// they're equal
+	return true;
+	}
+
+
+	/*
+		operators for comparising
+	*/
+
+	bool operator<(const UInt<value_size> & l) const
+	{
+		return CmpSmaller(l);
+	}
+
+
+	bool operator>(const UInt<value_size> & l) const
+	{
+		return CmpBigger(l);
+	}
+
+
+	bool operator==(const UInt<value_size> & l) const
+	{
+		return CmpEqual(l);
+	}
+
+
+	bool operator!=(const UInt<value_size> & l) const
+	{
+		return !operator==(l);
+	}
+
+
+	bool operator<=(const UInt<value_size> & l) const
+	{
+		return CmpSmallerEqual(l);
+	}
+
+	bool operator>=(const UInt<value_size> & l) const
+	{
+		return CmpBiggerEqual(l);
+	}
+
+
+	/*!
+	*
+	*	standard mathematical operators 
+	*
+	*/
+
+	UInt<value_size> operator-(const UInt<value_size> & p2) const
+	{
+	UInt<value_size> temp(*this);
+
+		temp.Sub(p2);
+
+	return temp;
+	}
+
+	UInt<value_size> & operator-=(const UInt<value_size> & p2)
+	{
+		Sub(p2);
+
+	return *this;
+	}
+
+	UInt<value_size> operator+(const UInt<value_size> & p2) const
+	{
+	UInt<value_size> temp(*this);
+
+		temp.Add(p2);
+
+	return temp;
+	}
+
+	UInt<value_size> & operator+=(const UInt<value_size> & p2)
+	{
+		Add(p2);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator*(const UInt<value_size> & p2) const
+	{
+	UInt<value_size> temp(*this);
+
+		temp.Mul(p2);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator*=(const UInt<value_size> & p2)
+	{
+		Mul(p2);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator/(const UInt<value_size> & p2) const
+	{
+	UInt<value_size> temp(*this);
+
+		temp.Div(p2);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator/=(const UInt<value_size> & p2)
+	{
+		Div(p2);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator%(const UInt<value_size> & p2) const
+	{
+	UInt<value_size> temp(*this);
+	UInt<value_size> remainder;
+	
+		temp.Div( p2, remainder );
+
+	return remainder;
+	}
+
+
+	UInt<value_size> & operator%=(const UInt<value_size> & p2)
+	{
+	UInt<value_size> remainder;
+	
+		Div( p2, remainder );
+		operator=(remainder);
+
+	return *this;
+	}
+
+
+	/*!
+		Prefix operator e.g ++variable
+	*/
+	UInt<value_size> & operator++()
+	{
+		AddOne();
+
+	return *this;
+	}
+
+
+	/*!
+		Postfix operator e.g variable++
+	*/
+	UInt<value_size> operator++(int)
+	{
+	UInt<value_size> temp( *this );
+
+		AddOne();
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator--()
+	{
+		SubOne();
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator--(int)
+	{
+	UInt<value_size> temp( *this );
+
+		SubOne();
+
+	return temp;
+	}
+
+
+
+	/*!
+	*
+	*	bitwise operators
+	*
+	*/
+
+	UInt<value_size> operator~() const
+	{
+		UInt<value_size> temp( *this );
+
+		temp.BitNot();
+
+	return temp;
+	}
+
+
+	UInt<value_size> operator&(const UInt<value_size> & p2) const
+	{
+		UInt<value_size> temp( *this );
+
+		temp.BitAnd(p2);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator&=(const UInt<value_size> & p2)
+	{
+		BitAnd(p2);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator|(const UInt<value_size> & p2) const
+	{
+		UInt<value_size> temp( *this );
+
+		temp.BitOr(p2);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator|=(const UInt<value_size> & p2)
+	{
+		BitOr(p2);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator^(const UInt<value_size> & p2) const
+	{
+		UInt<value_size> temp( *this );
+
+		temp.BitXor(p2);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator^=(const UInt<value_size> & p2)
+	{
+		BitXor(p2);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator>>(int move) const
+	{
+	UInt<value_size> temp( *this );
+
+		temp.Rcr(move);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator>>=(int move)
+	{
+		Rcr(move);
+
+	return *this;
+	}
+
+
+	UInt<value_size> operator<<(int move) const
+	{
+	UInt<value_size> temp( *this );
+
+		temp.Rcl(move);
+
+	return temp;
+	}
+
+
+	UInt<value_size> & operator<<=(int move)
+	{
+		Rcl(move);
+
+	return *this;
+	}
+
+
+	/*!
+	*
+	*	input/output operators for standard streams
+	*	
+	*	(they are very simple, in the future they should be changed)
+	*
+	*/
+
+
+private:
+
+
+	/*!
+		an auxiliary method for outputing to standard streams
+	*/
+	template<class ostream_type, class string_type>
+	static ostream_type & OutputToStream(ostream_type & s, const UInt<value_size> & l)
+	{
+	string_type ss;
+
+		l.ToString(ss);
+		s << ss;
+
+	return s;
+	}
+
+
+public:
+
+
+	/*!
+		output to standard streams
+	*/
+	friend std::ostream & operator<<(std::ostream & s, const UInt<value_size> & l)
+	{
+		return OutputToStream<std::ostream, std::string>(s, l);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		output to standard streams
+	*/
+	friend std::wostream & operator<<(std::wostream & s, const UInt<value_size> & l)
+	{
+		return OutputToStream<std::wostream, std::wstring>(s, l);
+	}
+
+#endif
+
+
+
+private:
+
+	/*!
+		an auxiliary method for reading from standard streams
+	*/
+	template<class istream_type, class string_type, class char_type>
+	static istream_type & InputFromStream(istream_type & s, UInt<value_size> & l)
+	{
+	string_type ss;
+	
+	// char or wchar_t for operator>>
+	char_type z;
+	
+		// operator>> omits white characters if they're set for ommiting
+		s >> z;
+
+		// we're reading only digits (base=10)
+		while( s.good() && Misc::CharToDigit(z, 10)>=0 )
+		{
+			ss += z;
+			z = static_cast<char_type>(s.get());
+		}
+
+		// we're leaving the last read character
+		// (it's not belonging to the value)
+		s.unget();
+
+		l.FromString(ss);
+
+	return s;
+	}
+
+public:
+
+
+	/*!
+		input from standard streams
+	*/
+	friend std::istream & operator>>(std::istream & s, UInt<value_size> & l)
+	{
+		return InputFromStream<std::istream, std::string, char>(s, l);
+	}
+
+
+#ifndef TTMATH_DONT_USE_WCHAR
+
+	/*!
+		input from standard streams
+	*/
+	friend std::wistream & operator>>(std::wistream & s, UInt<value_size> & l)
+	{
+		return InputFromStream<std::wistream, std::wstring, wchar_t>(s, l);
+	}
+
+#endif
+
+
+	/*
+		following methods are defined in:
+			ttmathuint_x86.h
+			ttmathuint_x86_64.h
+			ttmathuint_noasm.h
+	*/
+
+#ifdef TTMATH_NOASM
+	static uint AddTwoWords(uint a, uint b, uint carry, uint * result);
+	static uint SubTwoWords(uint a, uint b, uint carry, uint * result);
+
+#ifdef TTMATH_PLATFORM64
+
+	union uint_
+	{
+		struct 
+		{
+			unsigned int low;  // 32 bit 
+			unsigned int high; // 32 bit
+		} u_;
+
+		uint u;                // 64 bit
+	};
+
+
+	static void DivTwoWords2(uint a,uint b, uint c, uint * r, uint * rest);
+	static uint DivTwoWordsNormalize(uint_ & a_, uint_ & b_, uint_ & c_);
+	static uint DivTwoWordsUnnormalize(uint u, uint d);
+	static unsigned int DivTwoWordsCalculate(uint_ u_, unsigned int u3, uint_ v_);
+	static void MultiplySubtract(uint_ & u_, unsigned int & u3, unsigned int & q, uint_ v_);
+
+#endif // TTMATH_PLATFORM64
+#endif // TTMATH_NOASM
+
+
+private:
+	uint Rcl2_one(uint c);
+	uint Rcr2_one(uint c);
+	uint Rcl2(uint bits, uint c);
+	uint Rcr2(uint bits, uint c);
+
+public:
+	static const char * LibTypeStr();
+	static LibTypeCode LibType();
+	uint Add(const UInt<value_size> & ss2, uint c=0);
+	uint AddInt(uint value, uint index = 0);
+	uint AddTwoInts(uint x2, uint x1, uint index);
+	static uint AddVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result);
+	uint Sub(const UInt<value_size> & ss2, uint c=0);
+	uint SubInt(uint value, uint index = 0);
+	static uint SubVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result);
+	static sint FindLeadingBitInWord(uint x);
+	static sint FindLowestBitInWord(uint x);
+	static uint SetBitInWord(uint & value, uint bit);
+	static void MulTwoWords(uint a, uint b, uint * result_high, uint * result_low);
+	static void DivTwoWords(uint a,uint b, uint c, uint * r, uint * rest);
+
+};
+
+
+
+/*!
+	this specialization is needed in order to not confused the compiler "error: ISO C++ forbids zero-size array"
+	when compiling Mul3Big2() method
+*/
+template<>
+class UInt<0>
+{
+public:
+	uint table[1];
+
+	void Mul2Big(const UInt<0> &, UInt<0> &) { TTMATH_ASSERT(false) };
+	void SetZero() { TTMATH_ASSERT(false) };
+	uint AddTwoInts(uint, uint, uint) { TTMATH_ASSERT(false) return 0; };
+};
+
+
+} //namespace
+
+
+#include "ttmathuint_x86.h"
+#include "ttmathuint_x86_64.h"
+#include "ttmathuint_noasm.h"
+
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_noasm.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_noasm.h
new file mode 100644
index 0000000..07c73fc
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_noasm.h
@@ -0,0 +1,1017 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2010, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef headerfilettmathuint_noasm
+#define headerfilettmathuint_noasm
+
+
+#ifdef TTMATH_NOASM
+
+/*!
+	\file ttmathuint_noasm.h
+    \brief template class UInt<uint> with methods without any assembler code
+
+	this file is included at the end of ttmathuint.h
+*/
+
+
+namespace ttmath
+{
+
+	/*!
+		returning the string represents the currect type of the library
+		we have following types:
+		  asm_vc_32   - with asm code designed for Microsoft Visual C++ (32 bits)
+		  asm_gcc_32  - with asm code designed for GCC (32 bits)
+		  asm_vc_64   - with asm for VC (64 bit)
+		  asm_gcc_64  - with asm for GCC (64 bit)
+		  no_asm_32   - pure C++ version (32 bit) - without any asm code
+		  no_asm_64   - pure C++ version (64 bit) - without any asm code
+	*/
+	template<uint value_size>
+	const char * UInt<value_size>::LibTypeStr()
+	{
+		#ifdef TTMATH_PLATFORM32
+			static const char info[] = "no_asm_32";
+		#endif		
+
+		#ifdef TTMATH_PLATFORM64
+			static const char info[] = "no_asm_64";
+		#endif
+
+	return info;
+	}
+
+	
+	/*!
+		returning the currect type of the library
+	*/
+	template<uint value_size>
+	LibTypeCode UInt<value_size>::LibType()
+	{
+		#ifdef TTMATH_PLATFORM32
+			LibTypeCode info = no_asm_32;
+		#endif		
+
+		#ifdef TTMATH_PLATFORM64
+			LibTypeCode info = no_asm_64;
+		#endif
+
+	return info;
+	}
+
+
+	/*!
+		this method adds two words together
+		returns carry
+
+		this method is created only when TTMATH_NOASM macro is defined
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddTwoWords(uint a, uint b, uint carry, uint * result)
+	{
+	uint temp;
+
+		if( carry == 0 )
+		{
+			temp = a + b;
+
+			if( temp < a )
+				carry = 1;
+		}
+		else
+		{
+			carry = 1;
+			temp  = a + b + carry;
+
+			if( temp > a ) // !(temp<=a)
+				carry = 0;
+		}
+
+		*result = temp;
+
+	return carry;
+	}
+
+
+
+	/*!
+		this method adding ss2 to the this and adding carry if it's defined
+		(this = this + ss2 + c)
+
+		c must be zero or one (might be a bigger value than 1)
+		function returns carry (1) (if it was)
+	*/
+	
+	template<uint value_size>
+	uint UInt<value_size>::Add(const UInt<value_size> & ss2, uint c)
+	{
+	uint i;
+
+		for(i=0 ; i<value_size ; ++i)
+			c = AddTwoWords(table[i], ss2.table[i], c, &table[i]);
+
+		TTMATH_LOGC("UInt::Add", c)
+	
+	return c;
+	}
+
+
+	/*!
+		this method adds one word (at a specific position)
+		and returns a carry (if it was)
+
+		if we've got (value_size=3):
+			table[0] = 10;
+			table[1] = 30;
+			table[2] = 5;	
+		and we call:
+			AddInt(2,1)
+		then it'll be:
+			table[0] = 10;
+			table[1] = 30 + 2;
+			table[2] = 5;
+
+		of course if there was a carry from table[2] it would be returned
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddInt(uint value, uint index)
+	{
+	uint i, c;
+
+		TTMATH_ASSERT( index < value_size )
+
+
+		c = AddTwoWords(table[index], value, 0, &table[index]);
+
+		for(i=index+1 ; i<value_size && c ; ++i)
+			c = AddTwoWords(table[i], 0, c, &table[i]);
+
+		TTMATH_LOGC("UInt::AddInt", c)
+	
+	return c;
+	}
+
+
+
+
+
+	/*!
+		this method adds only two unsigned words to the existing value
+		and these words begin on the 'index' position
+		(it's used in the multiplication algorithm 2)
+
+		index should be equal or smaller than value_size-2 (index <= value_size-2)
+		x1 - lower word, x2 - higher word
+
+		for example if we've got value_size equal 4 and:
+			table[0] = 3
+			table[1] = 4
+			table[2] = 5
+			table[3] = 6
+		then let
+			x1 = 10
+			x2 = 20
+		and
+			index = 1
+
+		the result of this method will be:
+			table[0] = 3
+			table[1] = 4 + x1 = 14
+			table[2] = 5 + x2 = 25
+			table[3] = 6
+		
+		and no carry at the end of table[3]
+
+		(of course if there was a carry in table[2](5+20) then 
+		this carry would be passed to the table[3] etc.)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddTwoInts(uint x2, uint x1, uint index)
+	{
+	uint i, c;
+
+		TTMATH_ASSERT( index < value_size - 1 )
+
+
+		c = AddTwoWords(table[index],   x1, 0, &table[index]);
+		c = AddTwoWords(table[index+1], x2, c, &table[index+1]);
+
+		for(i=index+2 ; i<value_size && c ; ++i)
+			c = AddTwoWords(table[i], 0, c, &table[i]);
+
+		TTMATH_LOGC("UInt::AddTwoInts", c)
+	
+	return c;
+	}
+
+
+
+	/*!
+		this static method addes one vector to the other
+		'ss1' is larger in size or equal to 'ss2'
+
+		ss1 points to the first (larger) vector
+		ss2 points to the second vector
+		ss1_size - size of the ss1 (and size of the result too)
+		ss2_size - size of the ss2
+		result - is the result vector (which has size the same as ss1: ss1_size)
+
+		Example:  ss1_size is 5, ss2_size is 3
+		ss1:      ss2:   result (output):
+		  5        1         5+1
+		  4        3         4+3
+		  2        7         2+7
+		  6                  6
+		  9                  9
+	  of course the carry is propagated and will be returned from the last item
+	  (this method is used by the Karatsuba multiplication algorithm)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result)
+	{
+	uint i, c = 0;
+
+		TTMATH_ASSERT( ss1_size >= ss2_size )
+		
+		for(i=0 ; i<ss2_size ; ++i)
+			c = AddTwoWords(ss1[i], ss2[i], c, &result[i]);
+
+		for( ; i<ss1_size ; ++i)
+			c = AddTwoWords(ss1[i], 0, c, &result[i]);
+
+		TTMATH_VECTOR_LOGC("UInt::AddVector", c, result, ss1_size)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		this method subtractes one word from the other
+		returns carry
+
+		this method is created only when TTMATH_NOASM macro is defined
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubTwoWords(uint a, uint b, uint carry, uint * result)
+	{
+		if( carry == 0 )
+		{
+			*result = a - b;
+
+			if( a < b )
+				carry = 1;
+		}
+		else
+		{
+			carry   = 1;
+			*result = a - b - carry;
+
+			if( a > b ) // !(a <= b )
+				carry = 0;
+		}
+
+	return carry;
+	}
+
+
+
+
+	/*!
+		this method's subtracting ss2 from the 'this' and subtracting
+		carry if it has been defined
+		(this = this - ss2 - c)
+
+		c must be zero or one (might be a bigger value than 1)
+		function returns carry (1) (if it was)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Sub(const UInt<value_size> & ss2, uint c)
+	{
+	uint i;
+
+		for(i=0 ; i<value_size ; ++i)
+			c = SubTwoWords(table[i], ss2.table[i], c, &table[i]);
+
+		TTMATH_LOGC("UInt::Sub", c)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		this method subtracts one word (at a specific position)
+		and returns a carry (if it was)
+
+		if we've got (value_size=3):
+			table[0] = 10;
+			table[1] = 30;
+			table[2] = 5;	
+		and we call:
+			SubInt(2,1)
+		then it'll be:
+			table[0] = 10;
+			table[1] = 30 - 2;
+			table[2] = 5;
+
+		of course if there was a carry from table[2] it would be returned
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubInt(uint value, uint index)
+	{
+	uint i, c;
+
+		TTMATH_ASSERT( index < value_size )
+
+
+		c = SubTwoWords(table[index], value, 0, &table[index]);
+
+		for(i=index+1 ; i<value_size && c ; ++i)
+			c = SubTwoWords(table[i], 0, c, &table[i]);
+
+		TTMATH_LOGC("UInt::SubInt", c)
+	
+	return c;
+	}
+
+
+	/*!
+		this static method subtractes one vector from the other
+		'ss1' is larger in size or equal to 'ss2'
+
+		ss1 points to the first (larger) vector
+		ss2 points to the second vector
+		ss1_size - size of the ss1 (and size of the result too)
+		ss2_size - size of the ss2
+		result - is the result vector (which has size the same as ss1: ss1_size)
+
+		Example:  ss1_size is 5, ss2_size is 3
+		ss1:      ss2:   result (output):
+		  5        1         5-1
+		  4        3         4-3
+		  2        7         2-7
+		  6                  6-1  (the borrow from previous item)
+		  9                  9
+		                 return (carry): 0
+	  of course the carry (borrow) is propagated and will be returned from the last item
+	  (this method is used by the Karatsuba multiplication algorithm)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result)
+	{
+	uint i, c = 0;
+
+		TTMATH_ASSERT( ss1_size >= ss2_size )
+		
+		for(i=0 ; i<ss2_size ; ++i)
+			c = SubTwoWords(ss1[i], ss2[i], c, &result[i]);
+
+		for( ; i<ss1_size ; ++i)
+			c = SubTwoWords(ss1[i], 0, c, &result[i]);
+
+		TTMATH_VECTOR_LOGC("UInt::SubVector", c, result, ss1_size)
+
+	return c;
+	}
+
+
+
+	/*!
+		this method moves all bits into the left hand side
+		return value <- this <- c
+
+		the lowest *bit* will be held the 'c' and
+		the state of one additional bit (on the left hand side)
+		will be returned
+
+		for example:
+		let this is 001010000
+		after Rcl2_one(1) there'll be 010100001 and Rcl2_one returns 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcl2_one(uint c)
+	{
+	uint i, new_c;
+
+		if( c != 0 )
+			c = 1;
+
+		for(i=0 ; i<value_size ; ++i)
+		{
+			new_c    = (table[i] & TTMATH_UINT_HIGHEST_BIT) ? 1 : 0;
+			table[i] = (table[i] << 1) | c;
+			c        = new_c;
+		}
+
+		TTMATH_LOGC("UInt::Rcl2_one", c)
+
+	return c;
+	}
+
+
+
+
+
+
+
+	/*!
+		this method moves all bits into the right hand side
+		c -> this -> return value
+
+		the highest *bit* will be held the 'c' and
+		the state of one additional bit (on the right hand side)
+		will be returned
+
+		for example:
+		let this is 000000010
+		after Rcr2_one(1) there'll be 100000001 and Rcr2_one returns 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcr2_one(uint c)
+	{
+	sint i; // signed i
+	uint new_c;
+
+		if( c != 0 )
+			c = TTMATH_UINT_HIGHEST_BIT;
+
+		for(i=sint(value_size)-1 ; i>=0 ; --i)
+		{
+			new_c    = (table[i] & 1) ? TTMATH_UINT_HIGHEST_BIT : 0;
+			table[i] = (table[i] >> 1) | c;
+			c        = new_c;
+		}
+
+		c = (c != 0)? 1 : 0;
+
+		TTMATH_LOGC("UInt::Rcr2_one", c)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		this method moves all bits into the left hand side
+		return value <- this <- c
+
+		the lowest *bits* will be held the 'c' and
+		the state of one additional bit (on the left hand side)
+		will be returned
+
+		for example:
+		let this is 001010000
+		after Rcl2(3, 1) there'll be 010000111 and Rcl2 returns 1
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcl2(uint bits, uint c)
+	{
+		TTMATH_ASSERT( bits>0 && bits<TTMATH_BITS_PER_UINT )
+
+		uint move = TTMATH_BITS_PER_UINT - bits;
+		uint i, new_c;
+
+		if( c != 0 )
+			c = TTMATH_UINT_MAX_VALUE >> move;
+
+		for(i=0 ; i<value_size ; ++i)
+		{
+			new_c    = table[i] >> move;
+			table[i] = (table[i] << bits) | c;
+			c        = new_c;
+		}
+
+		TTMATH_LOGC("UInt::Rcl2", (c & 1))
+
+	return (c & 1);
+	}
+
+
+
+
+	/*!
+		this method moves all bits into the right hand side
+		C -> this -> return value
+
+		the highest *bits* will be held the 'c' and
+		the state of one additional bit (on the right hand side)
+		will be returned
+
+		for example:
+		let this is 000000010
+		after Rcr2(2, 1) there'll be 110000000 and Rcr2 returns 1
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcr2(uint bits, uint c)
+	{
+		TTMATH_ASSERT( bits>0 && bits<TTMATH_BITS_PER_UINT )
+
+		uint move = TTMATH_BITS_PER_UINT - bits;
+		sint i; // signed
+		uint new_c;
+
+		if( c != 0 )
+			c = TTMATH_UINT_MAX_VALUE << move;
+
+		for(i=value_size-1 ; i>=0 ; --i)
+		{
+			new_c    = table[i] << move;
+			table[i] = (table[i] >> bits) | c;
+			c        = new_c;
+		}
+
+		c = (c & TTMATH_UINT_HIGHEST_BIT) ? 1 : 0;
+
+		TTMATH_LOGC("UInt::Rcr2", c)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		this method returns the number of the highest set bit in x
+		if the 'x' is zero this method returns '-1'
+	*/
+	template<uint value_size>
+	sint UInt<value_size>::FindLeadingBitInWord(uint x)
+	{
+		if( x == 0 )
+			return -1;
+
+		uint bit = TTMATH_BITS_PER_UINT - 1;
+		
+		while( (x & TTMATH_UINT_HIGHEST_BIT) == 0 )
+		{
+			x = x << 1;
+			--bit;
+		}
+
+	return bit;
+	}
+
+
+
+	/*!
+		this method returns the number of the highest set bit in x
+		if the 'x' is zero this method returns '-1'
+	*/
+	template<uint value_size>
+	sint UInt<value_size>::FindLowestBitInWord(uint x)
+	{
+		if( x == 0 )
+			return -1;
+
+		uint bit = 0;
+		
+		while( (x & 1) == 0 )
+		{
+			x = x >> 1;
+			++bit;
+		}
+
+	return bit;
+	}
+
+
+
+	/*!
+		this method sets a special bit in the 'value'
+		and returns the last state of the bit (zero or one)
+
+		bit is from <0,TTMATH_BITS_PER_UINT-1>
+
+		e.g.
+		 uint x = 100;
+		 uint bit = SetBitInWord(x, 3);
+		 now: x = 108 and bit = 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SetBitInWord(uint & value, uint bit)
+	{
+		TTMATH_ASSERT( bit < TTMATH_BITS_PER_UINT )
+
+		uint mask = 1;
+
+		if( bit > 0 )
+			mask = mask << bit;
+
+		uint last = value & mask;
+		value     = value | mask;
+
+	return (last != 0) ? 1 : 0;
+	}
+
+
+
+
+
+
+	/*!
+	 *
+	 * Multiplication
+	 *
+	 *
+	*/
+
+
+	/*!
+		multiplication: result_high:result_low = a * b
+		result_high - higher word of the result
+		result_low  - lower word of the result
+	
+		this methos never returns a carry
+		this method is used in the second version of the multiplication algorithms
+	*/
+	template<uint value_size>
+	void UInt<value_size>::MulTwoWords(uint a, uint b, uint * result_high, uint * result_low)
+	{
+	#ifdef TTMATH_PLATFORM32
+
+		/*
+			on 32bit platforms we have defined 'unsigned long long int' type known as 'ulint' in ttmath namespace
+			this type has 64 bits, then we're using only one multiplication: 32bit * 32bit = 64bit
+		*/
+
+		union uint_
+		{
+			struct
+			{
+				uint low;  // 32 bits
+				uint high; // 32 bits
+			} u_;
+
+			ulint u;       // 64 bits
+		} res;
+
+		res.u = ulint(a) * ulint(b);     // multiply two 32bit words, the result has 64 bits
+
+		*result_high = res.u_.high;
+		*result_low  = res.u_.low;
+
+	#else
+
+		/*
+			64 bits platforms
+
+			we don't have a native type which has 128 bits
+			then we're splitting 'a' and 'b' to 4 parts (high and low halves)
+			and using 4 multiplications (with additions and carry correctness)
+		*/
+
+		uint_ a_;
+		uint_ b_;
+		uint_ res_high1, res_high2;
+		uint_ res_low1,  res_low2;
+		
+		a_.u = a;
+		b_.u = b;
+
+		/*
+			the multiplication is as follows (schoolbook algorithm with O(n^2) ):
+
+                                                   32 bits         32 bits
+
+                                             +--------------------------------+
+                                             |   a_.u_.high   |   a_.u_.low   |
+                                             +--------------------------------+
+                                             |   b_.u_.high   |   b_.u_.low   |
+            +--------------------------------+--------------------------------+
+            |           res_high1.u          |           res_low1.u           |
+            +--------------------------------+--------------------------------+
+            |           res_high2.u          |           res_low2.u           |
+            +--------------------------------+--------------------------------+
+
+                          64 bits                          64 bits
+		*/
+
+
+		uint_ temp;
+
+		res_low1.u        = uint(b_.u_.low) * uint(a_.u_.low);
+
+		temp.u            = uint(res_low1.u_.high) + uint(b_.u_.low) * uint(a_.u_.high);
+		res_low1.u_.high  = temp.u_.low;
+		res_high1.u_.low  = temp.u_.high;
+		res_high1.u_.high = 0;
+
+		res_low2.u_.low   = 0;
+		temp.u            = uint(b_.u_.high) * uint(a_.u_.low);
+		res_low2.u_.high  = temp.u_.low;
+
+		res_high2.u       = uint(b_.u_.high) * uint(a_.u_.high) + uint(temp.u_.high);
+
+		uint c = AddTwoWords(res_low1.u, res_low2.u, 0, &res_low2.u);
+		AddTwoWords(res_high1.u, res_high2.u, c, &res_high2.u);                 // there is no carry from here
+
+		*result_high = res_high2.u;
+		*result_low  = res_low2.u;
+
+	#endif
+	}
+
+
+
+
+	/*!
+	 *
+	 * Division
+	 *
+	 *
+	*/
+	
+
+	/*!
+		this method calculates 64bits word a:b / 32bits c (a higher, b lower word)
+		r = a:b / c and rest - remainder
+		
+		*
+		* WARNING:
+		* the c has to be suitably large for the result being keeped in one word,
+		* if c is equal zero there'll be a hardware interruption (0)
+		* and probably the end of your program
+		*
+	*/
+	template<uint value_size>
+	void UInt<value_size>::DivTwoWords(uint a, uint b, uint c, uint * r, uint * rest)
+	{
+	// (a < c ) for the result to be one word
+	TTMATH_ASSERT( c != 0 && a < c )
+
+	#ifdef TTMATH_PLATFORM32
+
+		union
+		{
+			struct
+			{
+				uint low;  // 32 bits
+				uint high; // 32 bits
+			} u_;
+
+			ulint u;       // 64 bits
+		} ab;
+
+		ab.u_.high = a;
+		ab.u_.low  = b;
+
+		*r    = uint(ab.u / c);
+		*rest = uint(ab.u % c);
+
+	#else
+
+		uint_ c_;
+		c_.u = c;
+
+
+		if( a == 0 )
+		{
+			*r    = b / c;
+			*rest = b % c;
+		}
+		else
+		if( c_.u_.high == 0 )
+		{
+			// higher half of 'c' is zero
+			// then higher half of 'a' is zero too (look at the asserts at the beginning - 'a' is smaller than 'c')
+			uint_ a_, b_, res_, temp1, temp2;
+
+			a_.u = a;
+			b_.u = b;
+
+			temp1.u_.high = a_.u_.low;
+			temp1.u_.low  = b_.u_.high;
+
+			res_.u_.high  = (unsigned int)(temp1.u / c);
+			temp2.u_.high = (unsigned int)(temp1.u % c);
+			temp2.u_.low  = b_.u_.low;
+			
+			res_.u_.low  = (unsigned int)(temp2.u / c);
+			*rest        = temp2.u % c;
+
+			*r = res_.u;
+		}
+		else
+		{
+			return DivTwoWords2(a, b, c,  r,  rest);
+		}
+
+	#endif
+	}
+
+
+#ifdef TTMATH_PLATFORM64
+
+
+	/*!
+		this method is available only on 64bit platforms
+		
+		the same algorithm like the third division algorithm in ttmathuint.h
+		but now with the radix=2^32
+	*/
+	template<uint value_size>
+	void UInt<value_size>::DivTwoWords2(uint a, uint b, uint c, uint * r, uint * rest)
+	{
+		// a is not zero
+		// c_.u_.high is not zero
+
+		uint_ a_, b_, c_, u_, q_;
+		unsigned int u3; // 32 bit
+
+		a_.u  = a;
+		b_.u  = b;
+		c_.u  = c;
+
+		// normalizing
+		uint d = DivTwoWordsNormalize(a_, b_, c_);
+
+		// loop from j=1 to j=0
+		//   the first step (for j=2) is skipped because our result is only in one word,
+		//   (first 'q' were 0 and nothing would be changed)
+		u_.u_.high = a_.u_.high;
+		u_.u_.low  = a_.u_.low;
+		u3         = b_.u_.high;
+		q_.u_.high = DivTwoWordsCalculate(u_, u3, c_);
+		MultiplySubtract(u_, u3, q_.u_.high, c_);
+		
+		u_.u_.high = u_.u_.low;
+		u_.u_.low  = u3;
+		u3         = b_.u_.low;
+		q_.u_.low  = DivTwoWordsCalculate(u_, u3, c_);
+		MultiplySubtract(u_, u3, q_.u_.low, c_);
+
+		*r = q_.u;
+
+		// unnormalizing for the remainder
+		u_.u_.high = u_.u_.low;
+		u_.u_.low  = u3;
+		*rest = DivTwoWordsUnnormalize(u_.u, d);
+	}
+
+
+
+	
+	template<uint value_size>
+	uint UInt<value_size>::DivTwoWordsNormalize(uint_ & a_, uint_ & b_, uint_ & c_)
+	{
+		uint d = 0;
+
+		for( ; (c_.u & TTMATH_UINT_HIGHEST_BIT) == 0 ; ++d )
+		{
+			c_.u = c_.u << 1;
+			
+			uint bc = b_.u & TTMATH_UINT_HIGHEST_BIT; // carry from 'b'
+
+			b_.u = b_.u << 1;
+			a_.u = a_.u << 1; // carry bits from 'a' are simply skipped 
+
+			if( bc )
+				a_.u = a_.u | 1;
+		}
+
+	return d;
+	}
+
+
+	template<uint value_size>
+	uint UInt<value_size>::DivTwoWordsUnnormalize(uint u, uint d)
+	{
+		if( d == 0 )
+			return u;
+
+		u = u >> d;
+
+	return u;
+	}
+
+
+	template<uint value_size>
+	unsigned int UInt<value_size>::DivTwoWordsCalculate(uint_ u_, unsigned int u3, uint_ v_)
+	{
+	bool next_test;
+	uint_ qp_, rp_, temp_;
+
+		qp_.u = u_.u / uint(v_.u_.high);
+		rp_.u = u_.u % uint(v_.u_.high);
+
+		TTMATH_ASSERT( qp_.u_.high==0 || qp_.u_.high==1 )
+
+		do
+		{
+			bool decrease = false;
+
+			if( qp_.u_.high == 1 )
+				decrease = true;
+			else
+			{
+				temp_.u_.high = rp_.u_.low;
+				temp_.u_.low  = u3;
+
+				if( qp_.u * uint(v_.u_.low) > temp_.u )
+					decrease = true;
+			}
+			
+			next_test = false;
+
+			if( decrease )
+			{
+				--qp_.u;
+				rp_.u += v_.u_.high;
+
+				if( rp_.u_.high == 0 ) 
+					next_test = true;
+			}
+		}
+		while( next_test );
+
+	return qp_.u_.low;
+	}
+
+
+	template<uint value_size>
+	void UInt<value_size>::MultiplySubtract(uint_ & u_, unsigned int & u3, unsigned int & q, uint_ v_)
+	{
+	uint_ temp_;
+		
+		uint res_high;
+		uint res_low;
+
+		MulTwoWords(v_.u, q, &res_high, &res_low);
+
+		uint_ sub_res_high_;
+		uint_ sub_res_low_;
+
+		temp_.u_.high = u_.u_.low;
+		temp_.u_.low  = u3;
+
+		uint c = SubTwoWords(temp_.u, res_low, 0, &sub_res_low_.u);
+			
+		temp_.u_.high = 0;
+		temp_.u_.low  = u_.u_.high;
+		c = SubTwoWords(temp_.u, res_high, c, &sub_res_high_.u);
+
+		if( c )
+		{
+			--q;
+
+			c = AddTwoWords(sub_res_low_.u, v_.u, 0, &sub_res_low_.u);
+			AddTwoWords(sub_res_high_.u, 0, c, &sub_res_high_.u);
+		}
+
+		u_.u_.high = sub_res_high_.u_.low;
+		u_.u_.low  = sub_res_low_.u_.high;
+		u3         = sub_res_low_.u_.low;
+	}
+
+#endif // #ifdef TTMATH_PLATFORM64
+
+
+
+} //namespace
+
+
+#endif //ifdef TTMATH_NOASM
+#endif
+
+
+
+
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86.h
new file mode 100644
index 0000000..1dd087f
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86.h
@@ -0,0 +1,1602 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2009, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifndef headerfilettmathuint_x86
+#define headerfilettmathuint_x86
+
+
+#ifndef TTMATH_NOASM
+#ifdef TTMATH_PLATFORM32
+
+
+/*!
+	\file ttmathuint_x86.h
+    \brief template class UInt<uint> with assembler code for 32bit x86 processors
+
+	this file is included at the end of ttmathuint.h
+*/
+
+
+
+/*!
+    \brief a namespace for the TTMath library
+*/
+namespace ttmath
+{
+
+	/*!
+		returning the string represents the currect type of the library
+		we have following types:
+		  asm_vc_32   - with asm code designed for Microsoft Visual C++ (32 bits)
+		  asm_gcc_32  - with asm code designed for GCC (32 bits)
+		  asm_vc_64   - with asm for VC (64 bit)
+		  asm_gcc_64  - with asm for GCC (64 bit)
+		  no_asm_32   - pure C++ version (32 bit) - without any asm code
+		  no_asm_64   - pure C++ version (64 bit) - without any asm code
+	*/
+	template<uint value_size>
+	const char * UInt<value_size>::LibTypeStr()
+	{
+		#ifndef __GNUC__
+			static const char info[] = "asm_vc_32";
+		#endif		
+
+		#ifdef __GNUC__
+			static const char info[] = "asm_gcc_32";
+		#endif
+
+	return info;
+	}
+
+
+	/*!
+		returning the currect type of the library
+	*/
+	template<uint value_size>
+	LibTypeCode UInt<value_size>::LibType()
+	{
+		#ifndef __GNUC__
+			LibTypeCode info = asm_vc_32;
+		#endif		
+
+		#ifdef __GNUC__
+			LibTypeCode info = asm_gcc_32;
+		#endif
+
+	return info;
+	}
+
+
+
+	/*!
+	*
+	*	basic mathematic functions
+	*
+	*/
+
+
+	/*!
+		adding ss2 to the this and adding carry if it's defined
+		(this = this + ss2 + c)
+
+		c must be zero or one (might be a bigger value than 1)
+		function returns carry (1) (if it has been)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Add(const UInt<value_size> & ss2, uint c)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint * p2 = const_cast<uint*>(ss2.table);
+
+		// we don't have to use TTMATH_REFERENCE_ASSERT here
+		// this algorithm doesn't require it
+
+		#ifndef __GNUC__
+			
+			//	this part might be compiled with for example visual c
+
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+				push esi
+
+				mov ecx,[b]
+				
+				mov ebx,[p1]
+				mov esi,[p2]
+
+				xor edx,edx          // edx=0
+				mov eax,[c]
+				neg eax              // CF=1 if rax!=0 , CF=0 if rax==0
+
+			ttmath_loop:
+				mov eax,[esi+edx*4]
+				adc [ebx+edx*4],eax
+
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+				adc ecx, ecx
+				mov [c], ecx
+
+				pop esi
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+			}
+
+
+
+		#endif		
+			
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+			//	this part should be compiled with gcc
+			
+			__asm__ __volatile__(
+
+				"xorl %%edx, %%edx				\n"
+				"negl %%eax						\n"  // CF=1 if rax!=0 , CF=0 if rax==0
+
+			"1:									\n"
+				"movl (%%esi,%%edx,4), %%eax	\n"
+				"adcl %%eax, (%%ebx,%%edx,4)	\n"
+			
+				"incl %%edx						\n"
+				"decl %%ecx						\n"
+			"jnz 1b								\n"
+
+				"adc %%ecx, %%ecx				\n"
+
+				: "=c" (c), "=a" (dummy), "=d" (dummy2)
+				: "0" (b),  "1" (c), "b" (p1), "S" (p2)
+				: "cc", "memory" );
+		#endif
+
+		TTMATH_LOGC("UInt::Add", c)
+
+	return c;
+	}
+
+
+
+	/*!
+		adding one word (at a specific position)
+		and returning a carry (if it has been)
+
+		e.g.
+
+		if we've got (value_size=3):
+			table[0] = 10;
+			table[1] = 30;
+			table[2] = 5;	
+		and we call:
+			AddInt(2,1)
+		then it'll be:
+			table[0] = 10;
+			table[1] = 30 + 2;
+			table[2] = 5;
+
+		of course if there was a carry from table[2] it would be returned
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddInt(uint value, uint index)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint c;
+
+		TTMATH_ASSERT( index < value_size )
+
+		#ifndef __GNUC__
+
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+
+				mov ecx, [b]
+				sub ecx, [index]				
+
+				mov edx, [index]
+				mov ebx, [p1]
+
+				mov eax, [value]
+
+			ttmath_loop:
+				add [ebx+edx*4], eax
+			jnc ttmath_end
+
+				mov eax, 1
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+			ttmath_end:
+				setc al
+				movzx edx, al
+				mov [c], edx
+
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+			}
+
+		#endif		
+			
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			__asm__ __volatile__(
+			
+				"subl %%edx, %%ecx 				\n"
+
+			"1:									\n"
+				"addl %%eax, (%%ebx,%%edx,4)	\n"
+			"jnc 2f								\n"
+				
+				"movl $1, %%eax					\n"
+				"incl %%edx						\n"
+				"decl %%ecx						\n"
+			"jnz 1b								\n"
+
+			"2:									\n"
+				"setc %%al						\n"
+				"movzx %%al, %%edx				\n"
+
+				: "=d" (c),    "=a" (dummy), "=c" (dummy2)
+				: "0" (index), "1" (value),  "2" (b), "b" (p1)
+				: "cc", "memory" );
+
+		#endif
+	
+		TTMATH_LOGC("UInt::AddInt", c)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		adding only two unsigned words to the existing value
+		and these words begin on the 'index' position
+		(it's used in the multiplication algorithm 2)
+
+		index should be equal or smaller than value_size-2 (index <= value_size-2)
+		x1 - lower word, x2 - higher word
+
+		for example if we've got value_size equal 4 and:
+			table[0] = 3
+			table[1] = 4
+			table[2] = 5
+			table[3] = 6
+		then let
+			x1 = 10
+			x2 = 20
+		and
+			index = 1
+
+		the result of this method will be:
+			table[0] = 3
+			table[1] = 4 + x1 = 14
+			table[2] = 5 + x2 = 25
+			table[3] = 6
+		
+		and no carry at the end of table[3]
+
+		(of course if there was a carry in table[2](5+20) then 
+		this carry would be passed to the table[3] etc.)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddTwoInts(uint x2, uint x1, uint index)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint c;
+
+		TTMATH_ASSERT( index < value_size - 1 )
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+
+				mov ecx, [b]
+				sub ecx, [index]				
+
+				mov ebx, [p1]
+				mov edx, [index]
+
+				mov eax, [x1]
+				add [ebx+edx*4], eax
+				inc edx
+				dec ecx
+
+				mov eax, [x2]
+			
+			ttmath_loop:
+				adc [ebx+edx*4], eax
+			jnc ttmath_end
+
+				mov eax, 0
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+			ttmath_end:
+				setc al
+				movzx edx, al
+				mov [c], edx
+				
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+
+			}
+		#endif		
+			
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			__asm__ __volatile__(
+			
+				"subl %%edx, %%ecx 				\n"
+				
+				"addl %%esi, (%%ebx,%%edx,4) 	\n"
+				"incl %%edx						\n"
+				"decl %%ecx						\n"
+
+			"1:									\n"
+				"adcl %%eax, (%%ebx,%%edx,4)	\n"
+			"jnc 2f								\n"
+
+				"mov $0, %%eax					\n"
+				"incl %%edx						\n"
+				"decl %%ecx						\n"
+			"jnz 1b								\n"
+
+			"2:									\n"
+				"setc %%al						\n"
+				"movzx %%al, %%eax				\n"
+
+				: "=a" (c), "=c" (dummy), "=d" (dummy2)
+				: "0" (x2), "1" (b),      "2" (index), "b" (p1), "S" (x1)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::AddTwoInts", c)
+	
+	return c;
+	}
+
+
+
+	/*!
+		this static method addes one vector to the other
+		'ss1' is larger in size or equal to 'ss2'
+
+		ss1 points to the first (larger) vector
+		ss2 points to the second vector
+		ss1_size - size of the ss1 (and size of the result too)
+		ss2_size - size of the ss2
+		result - is the result vector (which has size the same as ss1: ss1_size)
+
+		Example:  ss1_size is 5, ss2_size is 3
+		ss1:      ss2:   result (output):
+		  5        1         5+1
+		  4        3         4+3
+		  2        7         2+7
+		  6                  6
+		  9                  9
+	  of course the carry is propagated and will be returned from the last item
+	  (this method is used by the Karatsuba multiplication algorithm)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result)
+	{
+		TTMATH_ASSERT( ss1_size >= ss2_size )
+
+		uint rest = ss1_size - ss2_size;
+		uint c;
+
+		#ifndef __GNUC__
+
+			//	this part might be compiled with for example visual c
+			__asm
+			{
+				pushad
+
+				mov ecx, [ss2_size]
+				xor edx, edx               // edx = 0, cf = 0
+
+				mov esi, [ss1]
+				mov ebx, [ss2]
+				mov edi, [result]
+
+			ttmath_loop:
+				mov eax, [esi+edx*4]
+				adc eax, [ebx+edx*4]
+				mov [edi+edx*4], eax
+
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+				adc ecx, ecx             // ecx has the cf state
+
+				mov ebx, [rest]
+				or ebx, ebx
+				jz ttmath_end
+				
+				xor ebx, ebx             // ebx = 0
+				neg ecx                  // setting cf from ecx
+				mov ecx, [rest]          // ecx is != 0
+			
+			ttmath_loop2:
+				mov eax, [esi+edx*4]
+				adc eax, ebx 
+				mov [edi+edx*4], eax
+
+				inc edx
+				dec ecx
+			jnz ttmath_loop2
+
+				adc ecx, ecx
+
+			ttmath_end:
+				mov [c], ecx
+
+				popad
+			}
+
+		#endif		
+			
+
+		#ifdef __GNUC__
+			
+		//	this part should be compiled with gcc
+		uint dummy1, dummy2, dummy3;
+
+			__asm__ __volatile__(
+				"push %%edx							\n"
+				"xor %%edx, %%edx					\n"   // edx = 0, cf = 0
+			"1:										\n"
+				"mov (%%esi,%%edx,4), %%eax			\n"
+				"adc (%%ebx,%%edx,4), %%eax			\n"
+				"mov %%eax, (%%edi,%%edx,4)			\n"
+
+				"inc %%edx							\n"
+				"dec %%ecx							\n"
+			"jnz 1b									\n"
+
+				"adc %%ecx, %%ecx					\n"   // ecx has the cf state
+				"pop %%eax							\n"   // eax = rest
+
+				"or %%eax, %%eax					\n"
+				"jz 3f								\n"
+				
+				"xor %%ebx, %%ebx					\n"   // ebx = 0
+				"neg %%ecx							\n"   // setting cf from ecx
+				"mov %%eax, %%ecx					\n"   // ecx=rest and is != 0
+			"2:										\n"
+				"mov (%%esi, %%edx, 4), %%eax		\n"
+				"adc %%ebx, %%eax 					\n"
+				"mov %%eax, (%%edi, %%edx, 4)		\n"
+
+				"inc %%edx							\n"
+				"dec %%ecx							\n"
+			"jnz 2b									\n"
+
+				"adc %%ecx, %%ecx					\n"
+			"3:										\n"
+
+				: "=a" (dummy1), "=b" (dummy2), "=c" (c),       "=d" (dummy3)
+				:                "1" (ss2),     "2" (ss2_size), "3" (rest),   "S" (ss1),  "D" (result)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_VECTOR_LOGC("UInt::AddVector", c, result, ss1_size)
+
+	return c;
+	}
+
+
+	/*!
+		subtracting ss2 from the 'this' and subtracting
+		carry if it has been defined
+		(this = this - ss2 - c)
+
+		c must be zero or one (might be a bigger value than 1)
+		function returns carry (1) (if it has been)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Sub(const UInt<value_size> & ss2, uint c)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint * p2 = const_cast<uint*>(ss2.table);
+
+		// we don't have to use TTMATH_REFERENCE_ASSERT here
+		// this algorithm doesn't require it
+
+		#ifndef __GNUC__
+
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+				push esi
+
+				mov ecx,[b]
+				
+				mov ebx,[p1]
+				mov esi,[p2]
+
+				xor edx,edx          // edx=0
+				mov eax,[c]
+				neg eax              // CF=1 if rax!=0 , CF=0 if rax==0
+
+			ttmath_loop:
+				mov eax,[esi+edx*4]
+				sbb [ebx+edx*4],eax
+
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+				adc ecx, ecx
+				mov [c], ecx
+
+				pop esi
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+			}
+
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			__asm__  __volatile__(
+
+				"xorl %%edx, %%edx				\n"
+				"negl %%eax						\n"  // CF=1 if rax!=0 , CF=0 if rax==0
+
+			"1:									\n"
+				"movl (%%esi,%%edx,4), %%eax	\n"
+				"sbbl %%eax, (%%ebx,%%edx,4)	\n"
+			
+				"incl %%edx						\n"
+				"decl %%ecx						\n"
+			"jnz 1b								\n"
+
+				"adc %%ecx, %%ecx				\n"
+
+				: "=c" (c), "=a" (dummy), "=d" (dummy2)
+				: "0" (b),  "1" (c), "b" (p1), "S" (p2)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Sub", c)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		this method subtracts one word (at a specific position)
+		and returns a carry (if it was)
+
+		e.g.
+
+		if we've got (value_size=3):
+			table[0] = 10;
+			table[1] = 30;
+			table[2] = 5;	
+		and we call:
+			SubInt(2,1)
+		then it'll be:
+			table[0] = 10;
+			table[1] = 30 - 2;
+			table[2] = 5;
+
+		of course if there was a carry from table[2] it would be returned
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubInt(uint value, uint index)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint c;
+
+		TTMATH_ASSERT( index < value_size )
+
+		#ifndef __GNUC__
+
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+
+				mov ecx, [b]
+				sub ecx, [index]				
+
+				mov edx, [index]
+				mov ebx, [p1]
+
+				mov eax, [value]
+
+			ttmath_loop:
+				sub [ebx+edx*4], eax
+			jnc ttmath_end
+
+				mov eax, 1
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+			ttmath_end:
+				setc al
+				movzx edx, al
+				mov [c], edx
+
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+			}
+
+		#endif		
+			
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			__asm__ __volatile__(
+			
+				"subl %%edx, %%ecx 				\n"
+
+			"1:									\n"
+				"subl %%eax, (%%ebx,%%edx,4)	\n"
+			"jnc 2f								\n"
+				
+				"movl $1, %%eax					\n"
+				"incl %%edx						\n"
+				"decl %%ecx						\n"
+			"jnz 1b								\n"
+
+			"2:									\n"
+				"setc %%al						\n"
+				"movzx %%al, %%edx				\n"
+
+				: "=d" (c),    "=a" (dummy), "=c" (dummy2)
+				: "0" (index), "1" (value),  "2" (b), "b" (p1)
+				: "cc", "memory" );
+
+		#endif
+		
+		TTMATH_LOGC("UInt::SubInt", c)
+	
+	return c;
+	}
+
+
+
+	/*!
+		this static method subtractes one vector from the other
+		'ss1' is larger in size or equal to 'ss2'
+
+		ss1 points to the first (larger) vector
+		ss2 points to the second vector
+		ss1_size - size of the ss1 (and size of the result too)
+		ss2_size - size of the ss2
+		result - is the result vector (which has size the same as ss1: ss1_size)
+
+		Example:  ss1_size is 5, ss2_size is 3
+		ss1:      ss2:   result (output):
+		  5        1         5-1
+		  4        3         4-3
+		  2        7         2-7
+		  6                  6-1  (the borrow from previous item)
+		  9                  9
+		              return (carry): 0
+	  of course the carry (borrow) is propagated and will be returned from the last item
+	  (this method is used by the Karatsuba multiplication algorithm)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result)
+	{
+		TTMATH_ASSERT( ss1_size >= ss2_size )
+
+		uint rest = ss1_size - ss2_size;
+		uint c;
+
+		#ifndef __GNUC__
+			
+			//	this part might be compiled with for example visual c
+
+			/*
+				the asm code is nearly the same as in AddVector
+				only two instructions 'adc' are changed to 'sbb'
+			*/
+			__asm
+			{
+				pushad
+
+				mov ecx, [ss2_size]
+				xor edx, edx               // edx = 0, cf = 0
+
+				mov esi, [ss1]
+				mov ebx, [ss2]
+				mov edi, [result]
+
+			ttmath_loop:
+				mov eax, [esi+edx*4]
+				sbb eax, [ebx+edx*4]
+				mov [edi+edx*4], eax
+
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+				adc ecx, ecx             // ecx has the cf state
+
+				mov ebx, [rest]
+				or ebx, ebx
+				jz ttmath_end
+				
+				xor ebx, ebx             // ebx = 0
+				neg ecx                  // setting cf from ecx
+				mov ecx, [rest]          // ecx is != 0
+
+			ttmath_loop2:
+				mov eax, [esi+edx*4]
+				sbb eax, ebx 
+				mov [edi+edx*4], eax
+
+				inc edx
+				dec ecx
+			jnz ttmath_loop2
+
+				adc ecx, ecx
+
+			ttmath_end:
+				mov [c], ecx
+
+				popad
+			}
+
+		#endif		
+			
+
+		#ifdef __GNUC__
+			
+		//	this part should be compiled with gcc
+		uint dummy1, dummy2, dummy3;
+
+			__asm__ __volatile__(
+				"push %%edx							\n"
+				"xor %%edx, %%edx					\n"   // edx = 0, cf = 0
+			"1:										\n"
+				"mov (%%esi,%%edx,4), %%eax			\n"
+				"sbb (%%ebx,%%edx,4), %%eax			\n"
+				"mov %%eax, (%%edi,%%edx,4)			\n"
+
+				"inc %%edx							\n"
+				"dec %%ecx							\n"
+			"jnz 1b									\n"
+
+				"adc %%ecx, %%ecx					\n"   // ecx has the cf state
+				"pop %%eax							\n"   // eax = rest
+
+				"or %%eax, %%eax					\n"
+				"jz 3f								\n"
+				
+				"xor %%ebx, %%ebx					\n"   // ebx = 0
+				"neg %%ecx							\n"   // setting cf from ecx
+				"mov %%eax, %%ecx					\n"   // ecx=rest and is != 0
+			"2:										\n"
+				"mov (%%esi, %%edx, 4), %%eax		\n"
+				"sbb %%ebx, %%eax 					\n"
+				"mov %%eax, (%%edi, %%edx, 4)		\n"
+
+				"inc %%edx							\n"
+				"dec %%ecx							\n"
+			"jnz 2b									\n"
+
+				"adc %%ecx, %%ecx					\n"
+			"3:										\n"
+
+				: "=a" (dummy1), "=b" (dummy2), "=c" (c),       "=d" (dummy3)
+				:                "1" (ss2),     "2" (ss2_size), "3" (rest),   "S" (ss1),  "D" (result)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_VECTOR_LOGC("UInt::SubVector", c, result, ss1_size)
+
+	return c;
+	}
+
+
+
+	/*!
+		this method moves all bits into the left hand side
+		return value <- this <- c
+
+		the lowest *bit* will be held the 'c' and
+		the state of one additional bit (on the left hand side)
+		will be returned
+
+		for example:
+		let this is 001010000
+		after Rcl2_one(1) there'll be 010100001 and Rcl2_one returns 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcl2_one(uint c)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push ebx
+				push ecx
+				push edx
+
+				mov ebx, [p1]
+				xor edx, edx
+				mov ecx, [c]
+				neg ecx
+				mov ecx, [b]
+
+			ttmath_loop:
+				rcl dword ptr [ebx+edx*4], 1
+				
+				inc edx
+				dec ecx
+			jnz ttmath_loop
+
+				adc ecx, ecx
+				mov [c], ecx
+				
+				pop edx
+				pop ecx
+				pop ebx
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+		__asm__  __volatile__(
+
+			"xorl %%edx, %%edx			\n"   // edx=0
+			"negl %%eax					\n"   // CF=1 if eax!=0 , CF=0 if eax==0
+
+		"1:								\n"
+			"rcll $1, (%%ebx, %%edx, 4)	\n"
+
+			"incl %%edx					\n"
+			"decl %%ecx					\n"
+		"jnz 1b							\n"
+
+			"adcl %%ecx, %%ecx			\n"
+
+			: "=c" (c), "=a" (dummy), "=d" (dummy2)
+			: "0" (b),  "1" (c), "b" (p1)
+			: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcl2_one", c)
+
+	return c;
+	}
+
+
+
+	/*!
+		this method moves all bits into the right hand side
+		c -> this -> return value
+
+		the highest *bit* will be held the 'c' and
+		the state of one additional bit (on the right hand side)
+		will be returned
+
+		for example:
+		let this is 000000010
+		after Rcr2_one(1) there'll be 100000001 and Rcr2_one returns 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcr2_one(uint c)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push ebx
+				push ecx
+
+				mov ebx, [p1]
+				mov ecx, [c]
+				neg ecx
+				mov ecx, [b]
+
+			ttmath_loop:
+				rcr dword ptr [ebx+ecx*4-4], 1
+				
+				dec ecx
+			jnz ttmath_loop
+
+				adc ecx, ecx
+				mov [c], ecx
+
+				pop ecx
+				pop ebx
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy;
+
+		__asm__  __volatile__(
+
+			"negl %%eax						\n"   // CF=1 if eax!=0 , CF=0 if eax==0
+
+		"1:									\n"
+			"rcrl $1, -4(%%ebx, %%ecx, 4)	\n"
+
+			"decl %%ecx						\n"
+		"jnz 1b								\n"
+
+			"adcl %%ecx, %%ecx				\n"
+
+			: "=c" (c), "=a" (dummy)
+			: "0" (b),  "1" (c), "b" (p1)
+			: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcr2_one", c)
+
+	return c;
+	}
+
+
+
+#ifdef _MSC_VER
+#pragma warning (disable : 4731)
+//warning C4731: frame pointer register 'ebp' modified by inline assembly code
+#endif
+	
+
+
+	/*!
+		this method moves all bits into the left hand side
+		return value <- this <- c
+
+		the lowest *bits* will be held the 'c' and
+		the state of one additional bit (on the left hand side)
+		will be returned
+
+		for example:
+		let this is 001010000
+		after Rcl2(3, 1) there'll be 010000111 and Rcl2 returns 1
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcl2(uint bits, uint c)
+	{
+	TTMATH_ASSERT( bits>0 && bits<TTMATH_BITS_PER_UINT )
+		
+	uint b = value_size;
+	uint * p1 = table;
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+				push esi
+				push edi
+				push ebp
+
+				mov edi, [b]
+
+				mov ecx, 32
+				sub ecx, [bits]
+				mov edx, -1
+				shr edx, cl
+
+				mov ecx, [bits]
+				mov ebx, [p1]
+				mov eax, [c]
+
+				mov ebp, edx         // ebp = mask (modified ebp - don't read/write to variables)
+
+				xor edx, edx         // edx = 0
+				mov esi, edx
+				or eax, eax
+				cmovnz esi, ebp      // if(c) esi=mask else esi=0
+
+			ttmath_loop:
+				rol dword ptr [ebx+edx*4], cl
+				
+				mov eax, [ebx+edx*4]
+				and eax, ebp
+				xor [ebx+edx*4], eax // clearing bits
+				or [ebx+edx*4], esi  // saving old value
+				mov esi, eax
+
+				inc edx
+				dec edi
+			jnz ttmath_loop
+
+				pop ebp              // restoring ebp
+
+				and eax, 1
+				mov [c], eax
+
+				pop edi
+				pop esi
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2, dummy3;
+
+		__asm__  __volatile__(
+
+			"push %%ebp						\n"
+			
+			"movl %%ecx, %%esi				\n"
+			"movl $32, %%ecx				\n"
+			"subl %%esi, %%ecx				\n"    // ecx = 32 - bits
+			"movl $-1, %%edx				\n"    // edx = -1 (all bits set to one)
+			"shrl %%cl, %%edx				\n"    // shifting (0 -> edx -> cf)  (cl times)
+			"movl %%edx, %%ebp				\n"    // ebp = edx = mask
+			"movl %%esi, %%ecx				\n"
+
+			"xorl %%edx, %%edx				\n"
+			"movl %%edx, %%esi				\n"
+			"orl %%eax, %%eax				\n"
+			"cmovnz %%ebp, %%esi			\n"    // if(c) esi=mask else esi=0
+
+		"1:									\n"
+			"roll %%cl, (%%ebx,%%edx,4)		\n"
+
+			"movl (%%ebx,%%edx,4), %%eax	\n"
+			"andl %%ebp, %%eax				\n"
+			"xorl %%eax, (%%ebx,%%edx,4)	\n"
+			"orl  %%esi, (%%ebx,%%edx,4)	\n"
+			"movl %%eax, %%esi				\n"
+			
+			"incl %%edx						\n"
+			"decl %%edi						\n"
+		"jnz 1b								\n"
+			
+			"and $1, %%eax					\n"
+
+			"pop %%ebp						\n"
+
+			: "=a" (c), "=D" (dummy), "=S" (dummy2), "=d" (dummy3)
+			: "0" (c),  "1" (b), "b" (p1), "c" (bits)
+			: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcl2", c)
+
+	return c;
+	}
+
+
+
+
+	/*!
+		this method moves all bits into the right hand side
+		C -> this -> return value
+
+		the highest *bits* will be held the 'c' and
+		the state of one additional bit (on the right hand side)
+		will be returned
+
+		for example:
+		let this is 000000010
+		after Rcr2(2, 1) there'll be 110000000 and Rcr2 returns 1
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcr2(uint bits, uint c)
+	{
+	TTMATH_ASSERT( bits>0 && bits<TTMATH_BITS_PER_UINT )
+
+	uint b = value_size;
+	uint * p1 = table;
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push eax
+				push ebx
+				push ecx
+				push edx
+				push esi
+				push edi
+				push ebp
+
+				mov edi, [b]
+
+				mov ecx, 32
+				sub ecx, [bits]
+				mov edx, -1
+				shl edx, cl
+
+				mov ecx, [bits]
+				mov ebx, [p1]
+				mov eax, [c]
+
+				mov ebp, edx         // ebp = mask (modified ebp - don't read/write to variables)
+
+				xor edx, edx         // edx = 0
+				mov esi, edx
+				add edx, edi
+				dec edx              // edx is pointing at the end of the table (on last word)
+				or eax, eax
+				cmovnz esi, ebp      // if(c) esi=mask else esi=0
+
+			ttmath_loop:
+				ror dword ptr [ebx+edx*4], cl
+				
+				mov eax, [ebx+edx*4]
+				and eax, ebp 
+				xor [ebx+edx*4], eax // clearing bits
+				or [ebx+edx*4], esi  // saving old value
+				mov esi, eax
+
+				dec edx
+				dec edi
+			jnz ttmath_loop
+
+				pop ebp              // restoring ebp
+
+				rol eax, 1           // 31bit will be first
+				and eax, 1  
+				mov [c], eax
+
+				pop edi
+				pop esi
+				pop edx
+				pop ecx
+				pop ebx
+				pop eax
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2, dummy3;
+
+			__asm__  __volatile__(
+
+			"push %%ebp						\n"
+			
+			"movl %%ecx, %%esi				\n"
+			"movl $32, %%ecx				\n"
+			"subl %%esi, %%ecx				\n"    // ecx = 32 - bits
+			"movl $-1, %%edx				\n"    // edx = -1 (all bits set to one)
+			"shll %%cl, %%edx				\n"    // shifting (cf <- edx <- 0)  (cl times)
+			"movl %%edx, %%ebp				\n"    // ebp = edx = mask
+			"movl %%esi, %%ecx				\n"
+
+			"xorl %%edx, %%edx				\n"
+			"movl %%edx, %%esi				\n"
+			"addl %%edi, %%edx				\n"
+			"decl %%edx						\n"    // edx is pointing at the end of the table (on last word)
+			"orl %%eax, %%eax				\n"
+			"cmovnz %%ebp, %%esi			\n"    // if(c) esi=mask else esi=0
+
+		"1:									\n"
+			"rorl %%cl, (%%ebx,%%edx,4)		\n"
+
+			"movl (%%ebx,%%edx,4), %%eax	\n"
+			"andl %%ebp, %%eax				\n"
+			"xorl %%eax, (%%ebx,%%edx,4)	\n"
+			"orl  %%esi, (%%ebx,%%edx,4)	\n"
+			"movl %%eax, %%esi				\n"
+			
+			"decl %%edx						\n"
+			"decl %%edi						\n"
+		"jnz 1b								\n"
+			
+			"roll $1, %%eax					\n"
+			"andl $1, %%eax					\n"
+
+			"pop %%ebp						\n"
+
+			: "=a" (c), "=D" (dummy), "=S" (dummy2), "=d" (dummy3)
+			: "0" (c),  "1" (b), "b" (p1), "c" (bits)
+			: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcr2", c)
+
+	return c;
+	}
+
+
+#ifdef _MSC_VER
+#pragma warning (default : 4731)
+#endif
+
+
+	/*
+		this method returns the number of the highest set bit in one 32-bit word
+		if the 'x' is zero this method returns '-1'
+	*/
+	template<uint value_size>
+	sint UInt<value_size>::FindLeadingBitInWord(uint x)
+	{
+	sint result;
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push eax
+				push edx
+
+				mov edx,-1
+				bsr eax,[x]
+				cmovz eax,edx
+				mov [result], eax
+
+				pop edx
+				pop eax
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy;
+
+				__asm__ (
+
+				"movl $-1, %1          \n"
+				"bsrl %2, %0           \n"
+				"cmovz %1, %0          \n"
+
+				: "=r" (result), "=&r" (dummy)
+				: "r" (x)
+				: "cc" );
+
+		#endif
+
+	return result;
+	}
+
+
+
+	/*
+		this method returns the number of the smallest set bit in one 32-bit word
+		if the 'x' is zero this method returns '-1'
+	*/
+	template<uint value_size>
+	sint UInt<value_size>::FindLowestBitInWord(uint x)
+	{
+	sint result;
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push eax
+				push edx
+
+				mov edx,-1
+				bsf eax,[x]
+				cmovz eax,edx
+				mov [result], eax
+
+				pop edx
+				pop eax
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy;
+
+				__asm__ (
+
+				"movl $-1, %1          \n"
+				"bsfl %2, %0           \n"
+				"cmovz %1, %0          \n"
+
+				: "=r" (result), "=&r" (dummy)
+				: "r" (x)
+				: "cc" );
+
+		#endif
+
+	return result;
+	}
+
+
+
+	/*!
+		this method sets a special bit in the 'value'
+		and returns the last state of the bit (zero or one)
+
+		bit is from <0,31>
+		e.g.
+		 uint x = 100;
+		 uint bit = SetBitInWord(x, 3);
+		 now: x = 108 and bit = 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SetBitInWord(uint & value, uint bit)
+	{
+		TTMATH_ASSERT( bit < TTMATH_BITS_PER_UINT )
+
+		uint old_bit;
+		uint v = value;
+
+		#ifndef __GNUC__
+			__asm
+			{
+			push ebx
+			push eax
+
+			mov eax, [v]
+			mov ebx, [bit]
+			bts eax, ebx
+			mov [v], eax
+
+			setc bl
+			movzx ebx, bl
+			mov [old_bit], ebx
+
+			pop eax
+			pop ebx
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+			__asm__ (
+
+			"btsl %%ebx, %%eax		\n"
+			"setc %%bl				\n"
+			"movzx %%bl, %%ebx		\n"
+			
+			: "=a" (v), "=b" (old_bit)
+			: "0" (v),  "1" (bit)
+			: "cc" );
+
+		#endif
+
+		value = v;
+
+	return old_bit;
+	}
+
+
+
+
+	/*!
+		multiplication: result_high:result_low = a * b
+		result_high - higher word of the result
+		result_low  - lower word of the result
+	
+		this methos never returns a carry
+		this method is used in the second version of the multiplication algorithms
+	*/
+	template<uint value_size>
+	void UInt<value_size>::MulTwoWords(uint a, uint b, uint * result_high, uint * result_low)
+	{
+	/*
+		we must use these temporary variables in order to inform the compilator
+		that value pointed with result1 and result2 has changed
+
+		this has no effect in visual studio but it's useful when
+		using gcc and options like -Ox
+	*/
+	uint result1_;
+	uint result2_;
+
+		#ifndef __GNUC__
+
+			__asm
+			{
+			push eax
+			push edx
+
+			mov eax, [a]
+			mul dword ptr [b]
+
+			mov [result2_], edx
+			mov [result1_], eax
+
+			pop edx
+			pop eax
+			}
+
+		#endif
+
+
+		#ifdef __GNUC__
+
+		__asm__ (
+		
+			"mull %%edx			\n"
+
+			: "=a" (result1_), "=d" (result2_)
+			: "0" (a),         "1" (b)
+			: "cc" );
+
+		#endif
+
+
+		*result_low  = result1_;
+		*result_high = result2_;
+	}
+
+
+
+
+
+	/*!
+	 *
+	 * Division
+	 *
+	 *
+	*/
+	
+
+
+
+	/*!
+		this method calculates 64bits word a:b / 32bits c (a higher, b lower word)
+		r = a:b / c and rest - remainder
+
+		*
+		* WARNING:
+		* if r (one word) is too small for the result or c is equal zero
+		* there'll be a hardware interruption (0)
+		* and probably the end of your program
+		*
+	*/
+	template<uint value_size>
+	void UInt<value_size>::DivTwoWords(uint a, uint b, uint c, uint * r, uint * rest)
+	{
+		uint r_;
+		uint rest_;
+		/*
+			these variables have similar meaning like those in
+			the multiplication algorithm MulTwoWords
+		*/
+
+		TTMATH_ASSERT( c != 0 )
+
+		#ifndef __GNUC__
+			__asm
+			{
+				push eax
+				push edx
+
+				mov edx, [a]
+				mov eax, [b]
+				div dword ptr [c]
+
+				mov [r_], eax
+				mov [rest_], edx
+
+				pop edx
+				pop eax
+			}
+		#endif
+
+
+		#ifdef __GNUC__
+		
+			__asm__ (
+
+			"divl %%ecx				\n"
+
+			: "=a" (r_), "=d" (rest_)
+			: "0" (b),   "1" (a), "c" (c)
+			: "cc" );
+
+		#endif
+
+
+		*r = r_;
+		*rest = rest_;
+
+	}
+
+
+
+} //namespace
+
+
+
+#endif //ifdef TTMATH_PLATFORM32
+#endif //ifndef TTMATH_NOASM
+#endif
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86_64.h b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86_64.h
new file mode 100644
index 0000000..188fc5e
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86_64.h
@@ -0,0 +1,1146 @@
+/*
+ * This file is a part of TTMath Bignum Library
+ * and is distributed under the (new) BSD licence.
+ * Author: Tomasz Sowa <t.sowa at ttmath.org>
+ */
+
+/* 
+ * Copyright (c) 2006-2010, Tomasz Sowa
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *    
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *    
+ *  * Neither the name Tomasz Sowa nor the names of contributors to this
+ *    project may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef headerfilettmathuint_x86_64
+#define headerfilettmathuint_x86_64
+
+
+#ifndef TTMATH_NOASM
+#ifdef TTMATH_PLATFORM64
+
+
+/*!
+	\file ttmathuint_x86_64.h
+    \brief template class UInt<uint> with assembler code for 64bit x86_64 processors
+
+	this file is included at the end of ttmathuint.h
+*/
+
+#ifndef __GNUC__
+#include <intrin.h>
+#endif
+
+
+namespace ttmath
+{
+
+	#ifndef __GNUC__
+
+		extern "C"
+			{
+			uint __fastcall ttmath_adc_x64(uint* p1, const uint* p2, uint nSize, uint c);
+			uint __fastcall ttmath_addindexed_x64(uint* p1, uint nSize, uint nPos, uint nValue);
+			uint __fastcall ttmath_addindexed2_x64(uint* p1, uint nSize, uint nPos, uint nValue1, uint nValue2);
+			uint __fastcall ttmath_addvector_x64(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result);
+			uint __fastcall ttmath_sbb_x64(uint* p1, const uint* p2, uint nSize, uint c);
+			uint __fastcall ttmath_subindexed_x64(uint* p1, uint nSize, uint nPos, uint nValue);
+			uint __fastcall ttmath_subvector_x64(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result);
+			uint __fastcall ttmath_rcl_x64(uint* p1, uint nSize, uint nLowestBit);
+			uint __fastcall ttmath_rcr_x64(uint* p1, uint nSize, uint nLowestBit);
+			uint __fastcall ttmath_div_x64(uint* pnValHi, uint* pnValLo, uint nDiv);
+			uint __fastcall ttmath_rcl2_x64(uint* p1, uint nSize, uint nBits, uint c);
+			uint __fastcall ttmath_rcr2_x64(uint* p1, uint nSize, uint nBits, uint c);
+			};
+	#endif
+
+
+	/*!
+		returning the string represents the currect type of the library
+		we have following types:
+		  asm_vc_32   - with asm code designed for Microsoft Visual C++ (32 bits)
+		  asm_gcc_32  - with asm code designed for GCC (32 bits)
+		  asm_vc_64   - with asm for VC (64 bit)
+		  asm_gcc_64  - with asm for GCC (64 bit)
+		  no_asm_32   - pure C++ version (32 bit) - without any asm code
+		  no_asm_64   - pure C++ version (64 bit) - without any asm code
+	*/
+	template<uint value_size>
+	const char * UInt<value_size>::LibTypeStr()
+	{
+		#ifndef __GNUC__
+			static const char info[] = "asm_vc_64";
+		#endif		
+
+		#ifdef __GNUC__
+			static const char info[] = "asm_gcc_64";
+		#endif
+
+	return info;
+	}
+
+
+	/*!
+		returning the currect type of the library
+	*/
+	template<uint value_size>
+	LibTypeCode UInt<value_size>::LibType()
+	{
+		#ifndef __GNUC__
+			LibTypeCode info = asm_vc_64;
+		#endif		
+
+		#ifdef __GNUC__
+			LibTypeCode info = asm_gcc_64;
+		#endif
+
+	return info;
+	}
+
+
+	/*!
+	*
+	*	basic mathematic functions
+	*
+	*/
+
+
+
+	/*!
+		this method adding ss2 to the this and adding carry if it's defined
+		(this = this + ss2 + c)
+
+		***this method is created only on a 64bit platform***
+
+		c must be zero or one (might be a bigger value than 1)
+		function returns carry (1) (if it was)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Add(const UInt<value_size> & ss2, uint c)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	const uint * p2 = ss2.table;
+
+		// we don't have to use TTMATH_REFERENCE_ASSERT here
+		// this algorithm doesn't require it
+
+		#ifndef __GNUC__
+			c = ttmath_adc_x64(p1,p2,b,c);
+		#endif
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			/*
+				this part should be compiled with gcc
+			*/
+			__asm__ __volatile__(
+	
+				"xorq %%rdx, %%rdx				\n"
+				"negq %%rax						\n"     // CF=1 if rax!=0 , CF=0 if rax==0
+
+			"1:									\n"
+				"movq (%%rsi,%%rdx,8), %%rax	\n"
+				"adcq %%rax, (%%rbx,%%rdx,8)	\n"
+			
+				"incq %%rdx						\n"
+				"decq %%rcx						\n"
+			"jnz 1b								\n"
+
+				"adcq %%rcx, %%rcx				\n"
+
+				: "=c" (c), "=a" (dummy), "=d" (dummy2)
+				: "0" (b),  "1" (c), "b" (p1), "S" (p2)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Add", c)
+	
+	return c;
+	}
+
+
+
+	/*!
+		this method adds one word (at a specific position)
+		and returns a carry (if it was)
+
+		***this method is created only on a 64bit platform***
+
+
+		if we've got (value_size=3):
+			table[0] = 10;
+			table[1] = 30;
+			table[2] = 5;	
+		and we call:
+			AddInt(2,1)
+		then it'll be:
+			table[0] = 10;
+			table[1] = 30 + 2;
+			table[2] = 5;
+
+		of course if there was a carry from table[2] it would be returned
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddInt(uint value, uint index)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint c;
+
+		TTMATH_ASSERT( index < value_size )
+
+		#ifndef __GNUC__
+			c = ttmath_addindexed_x64(p1,b,index,value);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+	
+			__asm__ __volatile__(
+
+				"subq %%rdx, %%rcx 				\n"
+
+			"1:									\n"
+				"addq %%rax, (%%rbx,%%rdx,8)	\n"
+			"jnc 2f								\n"
+				
+				"movq $1, %%rax					\n"
+				"incq %%rdx						\n"
+				"decq %%rcx						\n"
+			"jnz 1b								\n"
+
+			"2:									\n"
+				"setc %%al						\n"
+				"movzx %%al, %%rdx				\n"
+
+				: "=d" (c),    "=a" (dummy), "=c" (dummy2)
+				: "0" (index), "1" (value),  "2" (b), "b" (p1)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::AddInt", c)
+	
+	return c;
+	}
+
+
+
+	/*!
+		this method adds only two unsigned words to the existing value
+		and these words begin on the 'index' position
+		(it's used in the multiplication algorithm 2)
+
+		***this method is created only on a 64bit platform***
+
+		index should be equal or smaller than value_size-2 (index <= value_size-2)
+		x1 - lower word, x2 - higher word
+
+		for example if we've got value_size equal 4 and:
+			table[0] = 3
+			table[1] = 4
+			table[2] = 5
+			table[3] = 6
+		then let
+			x1 = 10
+			x2 = 20
+		and
+			index = 1
+
+		the result of this method will be:
+			table[0] = 3
+			table[1] = 4 + x1 = 14
+			table[2] = 5 + x2 = 25
+			table[3] = 6
+		
+		and no carry at the end of table[3]
+
+		(of course if there was a carry in table[2](5+20) then 
+		this carry would be passed to the table[3] etc.)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddTwoInts(uint x2, uint x1, uint index)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint c;
+
+		TTMATH_ASSERT( index < value_size - 1 )
+
+		#ifndef __GNUC__
+			c = ttmath_addindexed2_x64(p1,b,index,x1,x2);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			__asm__ __volatile__(
+			
+				"subq %%rdx, %%rcx 				\n"
+				
+				"addq %%rsi, (%%rbx,%%rdx,8) 	\n"
+				"incq %%rdx						\n"
+				"decq %%rcx						\n"
+
+			"1:									\n"
+				"adcq %%rax, (%%rbx,%%rdx,8)	\n"
+			"jnc 2f								\n"
+
+				"mov $0, %%rax					\n"
+				"incq %%rdx						\n"
+				"decq %%rcx						\n"
+			"jnz 1b								\n"
+
+			"2:									\n"
+				"setc %%al						\n"
+				"movzx %%al, %%rax				\n"
+
+				: "=a" (c), "=c" (dummy), "=d" (dummy2)
+				: "0" (x2), "1" (b),      "2" (index), "b" (p1), "S" (x1)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::AddTwoInts", c)
+
+	return c;
+	}
+
+
+
+	/*!
+		this static method addes one vector to the other
+		'ss1' is larger in size or equal to 'ss2'
+
+		ss1 points to the first (larger) vector
+		ss2 points to the second vector
+		ss1_size - size of the ss1 (and size of the result too)
+		ss2_size - size of the ss2
+		result - is the result vector (which has size the same as ss1: ss1_size)
+
+		Example:  ss1_size is 5, ss2_size is 3
+		ss1:      ss2:   result (output):
+		  5        1         5+1
+		  4        3         4+3
+		  2        7         2+7
+		  6                  6
+		  9                  9
+	  of course the carry is propagated and will be returned from the last item
+	  (this method is used by the Karatsuba multiplication algorithm)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::AddVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result)
+	{
+		TTMATH_ASSERT( ss1_size >= ss2_size )
+
+		uint c;
+
+		#ifndef __GNUC__
+			 c = ttmath_addvector_x64(ss1, ss2, ss1_size, ss2_size, result);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy1, dummy2, dummy3;	
+		uint rest = ss1_size - ss2_size;
+			
+			//	this part should be compiled with gcc
+		
+			__asm__ __volatile__(
+				"mov %%rdx, %%r8					\n"
+				"xor %%rdx, %%rdx					\n"   // rdx = 0, cf = 0
+			"1:										\n"
+				"mov (%%rsi,%%rdx,8), %%rax			\n"
+				"adc (%%rbx,%%rdx,8), %%rax			\n"
+				"mov %%rax, (%%rdi,%%rdx,8)			\n"
+
+				"inc %%rdx							\n"
+				"dec %%rcx							\n"
+			"jnz 1b									\n"
+
+				"adc %%rcx, %%rcx					\n"   // rcx has the cf state
+
+				"or %%r8, %%r8						\n"
+				"jz 3f								\n"
+				
+				"xor %%rbx, %%rbx					\n"   // ebx = 0
+				"neg %%rcx							\n"   // setting cf from rcx
+				"mov %%r8, %%rcx					\n"   // rcx=rest and is != 0
+			"2:										\n"
+				"mov (%%rsi, %%rdx, 8), %%rax		\n"
+				"adc %%rbx, %%rax 					\n"
+				"mov %%rax, (%%rdi, %%rdx, 8)		\n"
+
+				"inc %%rdx							\n"
+				"dec %%rcx							\n"
+			"jnz 2b									\n"
+
+				"adc %%rcx, %%rcx					\n"
+			"3:										\n"
+
+				: "=a" (dummy1), "=b" (dummy2), "=c" (c),       "=d" (dummy3)
+				:                "1" (ss2),     "2" (ss2_size), "3" (rest),   "S" (ss1),  "D" (result)
+				: "%r8", "cc", "memory" );
+
+		#endif
+
+		TTMATH_VECTOR_LOGC("UInt::AddVector", c, result, ss1_size)
+
+	return c;
+	}
+
+
+
+	/*!
+		this method's subtracting ss2 from the 'this' and subtracting
+		carry if it has been defined
+		(this = this - ss2 - c)
+
+		***this method is created only on a 64bit platform***
+
+		c must be zero or one (might be a bigger value than 1)
+		function returns carry (1) (if it was)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Sub(const UInt<value_size> & ss2, uint c)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	const uint * p2 = ss2.table;
+	
+		// we don't have to use TTMATH_REFERENCE_ASSERT here
+		// this algorithm doesn't require it
+
+		#ifndef __GNUC__
+			c = ttmath_sbb_x64(p1,p2,b,c);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+			__asm__  __volatile__(
+	
+				"xorq %%rdx, %%rdx				\n"
+				"negq %%rax						\n"     // CF=1 if rax!=0 , CF=0 if rax==0
+
+			"1:									\n"
+				"movq (%%rsi,%%rdx,8), %%rax	\n"
+				"sbbq %%rax, (%%rbx,%%rdx,8)	\n"
+			
+				"incq %%rdx						\n"
+				"decq %%rcx						\n"
+			"jnz 1b								\n"
+
+				"adcq %%rcx, %%rcx				\n"
+
+				: "=c" (c), "=a" (dummy), "=d" (dummy2)
+				: "0" (b),  "1" (c), "b" (p1), "S" (p2)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Sub", c)
+
+	return c;
+	}
+
+
+
+	/*!
+		this method subtracts one word (at a specific position)
+		and returns a carry (if it was)
+
+		***this method is created only on a 64bit platform***
+
+		if we've got (value_size=3):
+			table[0] = 10;
+			table[1] = 30;
+			table[2] = 5;	
+		and we call:
+			SubInt(2,1)
+		then it'll be:
+			table[0] = 10;
+			table[1] = 30 - 2;
+			table[2] = 5;
+
+		of course if there was a carry from table[2] it would be returned
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubInt(uint value, uint index)
+	{
+	uint b = value_size;
+	uint * p1 = table;
+	uint c;
+
+		TTMATH_ASSERT( index < value_size )
+
+		#ifndef __GNUC__
+			c = ttmath_subindexed_x64(p1,b,index,value);
+		#endif
+
+
+		#ifdef __GNUC__
+			uint dummy, dummy2;
+
+			__asm__ __volatile__(
+			
+				"subq %%rdx, %%rcx 				\n"
+
+			"1:									\n"
+				"subq %%rax, (%%rbx,%%rdx,8)	\n"
+			"jnc 2f								\n"
+				
+				"movq $1, %%rax					\n"
+				"incq %%rdx						\n"
+				"decq %%rcx						\n"
+			"jnz 1b								\n"
+
+			"2:									\n"
+				"setc %%al						\n"
+				"movzx %%al, %%rdx				\n"
+
+				: "=d" (c),    "=a" (dummy), "=c" (dummy2)
+				: "0" (index), "1" (value),  "2" (b), "b" (p1)
+				: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::SubInt", c)
+
+	return c;
+	}
+
+
+	/*!
+		this static method subtractes one vector from the other
+		'ss1' is larger in size or equal to 'ss2'
+
+		ss1 points to the first (larger) vector
+		ss2 points to the second vector
+		ss1_size - size of the ss1 (and size of the result too)
+		ss2_size - size of the ss2
+		result - is the result vector (which has size the same as ss1: ss1_size)
+
+		Example:  ss1_size is 5, ss2_size is 3
+		ss1:      ss2:   result (output):
+		  5        1         5-1
+		  4        3         4-3
+		  2        7         2-7
+		  6                  6-1  (the borrow from previous item)
+		  9                  9
+		               return (carry): 0
+	  of course the carry (borrow) is propagated and will be returned from the last item
+	  (this method is used by the Karatsuba multiplication algorithm)
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SubVector(const uint * ss1, const uint * ss2, uint ss1_size, uint ss2_size, uint * result)
+	{
+		TTMATH_ASSERT( ss1_size >= ss2_size )
+
+		uint c;
+
+		#ifndef __GNUC__
+			c = ttmath_subvector_x64(ss1, ss2, ss1_size, ss2_size, result);
+		#endif
+
+
+		#ifdef __GNUC__
+		
+		//	the asm code is nearly the same as in AddVector
+		//	only two instructions 'adc' are changed to 'sbb'
+		
+		uint dummy1, dummy2, dummy3;
+		uint rest = ss1_size - ss2_size;
+
+			__asm__ __volatile__(
+				"mov %%rdx, %%r8					\n"
+				"xor %%rdx, %%rdx					\n"   // rdx = 0, cf = 0
+			"1:										\n"
+				"mov (%%rsi,%%rdx,8), %%rax			\n"
+				"sbb (%%rbx,%%rdx,8), %%rax			\n"
+				"mov %%rax, (%%rdi,%%rdx,8)			\n"
+
+				"inc %%rdx							\n"
+				"dec %%rcx							\n"
+			"jnz 1b									\n"
+
+				"adc %%rcx, %%rcx					\n"   // rcx has the cf state
+
+				"or %%r8, %%r8						\n"
+				"jz 3f								\n"
+				
+				"xor %%rbx, %%rbx					\n"   // ebx = 0
+				"neg %%rcx							\n"   // setting cf from rcx
+				"mov %%r8, %%rcx					\n"   // rcx=rest and is != 0
+			"2:										\n"
+				"mov (%%rsi, %%rdx, 8), %%rax		\n"
+				"sbb %%rbx, %%rax 					\n"
+				"mov %%rax, (%%rdi, %%rdx, 8)		\n"
+
+				"inc %%rdx							\n"
+				"dec %%rcx							\n"
+			"jnz 2b									\n"
+
+				"adc %%rcx, %%rcx					\n"
+			"3:										\n"
+
+				: "=a" (dummy1), "=b" (dummy2), "=c" (c),       "=d" (dummy3)
+				:                "1" (ss2),     "2" (ss2_size), "3" (rest),   "S" (ss1),  "D" (result)
+				: "%r8", "cc", "memory" );
+
+		#endif
+
+		TTMATH_VECTOR_LOGC("UInt::SubVector", c, result, ss1_size)
+
+	return c;
+	}
+
+
+	/*!
+		this method moves all bits into the left hand side
+		return value <- this <- c
+
+		the lowest *bit* will be held the 'c' and
+		the state of one additional bit (on the left hand side)
+		will be returned
+
+		for example:
+		let this is 001010000
+		after Rcl2_one(1) there'll be 010100001 and Rcl2_one returns 0
+	
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcl2_one(uint c)
+	{
+	sint b = value_size;
+	uint * p1 = table;
+
+
+		#ifndef __GNUC__
+			c = ttmath_rcl_x64(p1,b,c);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2;
+
+		__asm__  __volatile__(
+		
+			"xorq %%rdx, %%rdx			\n"   // rdx=0
+			"negq %%rax					\n"   // CF=1 if rax!=0 , CF=0 if rax==0
+
+		"1:								\n"
+			"rclq $1, (%%rbx, %%rdx, 8)	\n"
+
+			"incq %%rdx					\n"
+			"decq %%rcx					\n"
+		"jnz 1b							\n"
+
+			"adcq %%rcx, %%rcx			\n"
+
+			: "=c" (c), "=a" (dummy), "=d" (dummy2)
+			: "0" (b),  "1" (c), "b" (p1)
+			: "cc", "memory" );
+	
+		#endif
+
+		TTMATH_LOGC("UInt::Rcl2_one", c)
+
+	return c;
+	}
+
+
+	/*!
+		this method moves all bits into the right hand side
+		c -> this -> return value
+
+		the highest *bit* will be held the 'c' and
+		the state of one additional bit (on the right hand side)
+		will be returned
+
+		for example:
+		let this is 000000010
+		after Rcr2_one(1) there'll be 100000001 and Rcr2_one returns 0
+
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcr2_one(uint c)
+	{
+	sint b = value_size;
+	uint * p1 = table;
+	
+
+		#ifndef __GNUC__
+			c = ttmath_rcr_x64(p1,b,c);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy;
+
+		__asm__  __volatile__(
+
+			"negq %%rax						\n"   // CF=1 if rax!=0 , CF=0 if rax==0
+
+		"1:									\n"
+			"rcrq $1, -8(%%rbx, %%rcx, 8)	\n"
+
+			"decq %%rcx						\n"
+		"jnz 1b								\n"
+
+			"adcq %%rcx, %%rcx				\n"
+
+			: "=c" (c), "=a" (dummy)
+			: "0" (b),  "1" (c), "b" (p1)
+			: "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcr2_one", c)
+
+	return c;
+	}
+
+
+
+	/*!
+		this method moves all bits into the left hand side
+		return value <- this <- c
+
+		the lowest *bits* will be held the 'c' and
+		the state of one additional bit (on the left hand side)
+		will be returned
+
+		for example:
+		let this is 001010000
+		after Rcl2(3, 1) there'll be 010000111 and Rcl2 returns 1
+	
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcl2(uint bits, uint c)
+	{
+	TTMATH_ASSERT( bits>0 && bits<TTMATH_BITS_PER_UINT )
+
+	uint b = value_size;
+	uint * p1 = table;
+
+
+		#ifndef __GNUC__
+			c = ttmath_rcl2_x64(p1,b,bits,c);
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy, dummy2, dummy3;
+
+		__asm__  __volatile__(
+		
+			"movq %%rcx, %%rsi				\n"
+			"movq $64, %%rcx				\n"
+			"subq %%rsi, %%rcx				\n"
+			"movq $-1, %%rdx				\n"
+			"shrq %%cl, %%rdx				\n"
+			"movq %%rdx, %%r8 				\n"
+			"movq %%rsi, %%rcx				\n"
+
+			"xorq %%rdx, %%rdx				\n"
+			"movq %%rdx, %%rsi				\n"
+			"orq %%rax, %%rax				\n"
+			"cmovnz %%r8, %%rsi				\n"
+
+		"1:									\n"
+			"rolq %%cl, (%%rbx,%%rdx,8)		\n"
+
+			"movq (%%rbx,%%rdx,8), %%rax	\n"
+			"andq %%r8, %%rax				\n"
+			"xorq %%rax, (%%rbx,%%rdx,8)	\n"
+			"orq  %%rsi, (%%rbx,%%rdx,8)	\n"
+			"movq %%rax, %%rsi				\n"
+			
+			"incq %%rdx						\n"
+			"decq %%rdi						\n"
+		"jnz 1b								\n"
+			
+			"and $1, %%rax					\n"
+
+			: "=a" (c), "=D" (dummy), "=S" (dummy2), "=d" (dummy3)
+			: "0" (c),  "1" (b), "b" (p1), "c" (bits)
+			: "%r8", "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcl2", c)
+
+	return c;
+	}
+
+
+	/*!
+		this method moves all bits into the right hand side
+		C -> this -> return value
+
+		the highest *bits* will be held the 'c' and
+		the state of one additional bit (on the right hand side)
+		will be returned
+
+		for example:
+		let this is 000000010
+		after Rcr2(2, 1) there'll be 110000000 and Rcr2 returns 1
+
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::Rcr2(uint bits, uint c)
+	{
+	TTMATH_ASSERT( bits>0 && bits<TTMATH_BITS_PER_UINT )
+
+	sint b = value_size;
+	uint * p1 = table;
+
+
+		#ifndef __GNUC__
+			c = ttmath_rcr2_x64(p1,b,bits,c);
+		#endif
+
+
+		#ifdef __GNUC__
+			uint dummy, dummy2, dummy3;
+
+			__asm__  __volatile__(
+
+			"movq %%rcx, %%rsi				\n"
+			"movq $64, %%rcx				\n"
+			"subq %%rsi, %%rcx				\n"
+			"movq $-1, %%rdx				\n"
+			"shlq %%cl, %%rdx				\n"
+			"movq %%rdx, %%R8				\n"
+			"movq %%rsi, %%rcx				\n"
+
+			"xorq %%rdx, %%rdx				\n"
+			"movq %%rdx, %%rsi				\n"
+			"addq %%rdi, %%rdx				\n"
+			"decq %%rdx						\n"
+			"orq %%rax, %%rax				\n"
+			"cmovnz %%R8, %%rsi				\n"
+
+		"1:									\n"
+			"rorq %%cl, (%%rbx,%%rdx,8)		\n"
+
+			"movq (%%rbx,%%rdx,8), %%rax	\n"
+			"andq %%R8, %%rax				\n"
+			"xorq %%rax, (%%rbx,%%rdx,8)	\n"
+			"orq  %%rsi, (%%rbx,%%rdx,8)	\n"
+			"movq %%rax, %%rsi				\n"
+			
+			"decq %%rdx						\n"
+			"decq %%rdi						\n"
+		"jnz 1b								\n"
+			
+			"rolq $1, %%rax					\n"
+			"andq $1, %%rax					\n"
+
+			: "=a" (c), "=D" (dummy), "=S" (dummy2), "=d" (dummy3)
+			: "0" (c), "1" (b), "b" (p1), "c" (bits)
+			: "%r8", "cc", "memory" );
+
+		#endif
+
+		TTMATH_LOGC("UInt::Rcr2", c)
+
+	return c;
+	}
+
+
+	/*
+		this method returns the number of the highest set bit in one 64-bit word
+		if the 'x' is zero this method returns '-1'
+
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	sint UInt<value_size>::FindLeadingBitInWord(uint x)
+	{
+	sint result;
+
+	
+		#ifndef __GNUC__
+
+			unsigned long nIndex = 0;
+
+			if( _BitScanReverse64(&nIndex,x) == 0 )
+				result = -1;
+			else
+				result = nIndex;
+
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy;
+
+				__asm__ (
+
+				"movq $-1, %1          \n"
+				"bsrq %2, %0           \n"
+				"cmovz %1, %0          \n"
+
+				: "=r" (result), "=&r" (dummy)
+				: "r" (x)
+				: "cc" );
+
+		#endif
+
+
+	return result;
+	}
+
+
+	/*
+		this method returns the number of the highest set bit in one 64-bit word
+		if the 'x' is zero this method returns '-1'
+
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	sint UInt<value_size>::FindLowestBitInWord(uint x)
+	{
+	sint result;
+
+	
+		#ifndef __GNUC__
+
+			unsigned long nIndex = 0;
+
+			if( _BitScanForward64(&nIndex,x) == 0 )
+				result = -1;
+			else
+				result = nIndex;
+
+		#endif
+
+
+		#ifdef __GNUC__
+		uint dummy;
+
+				__asm__ (
+
+				"movq $-1, %1          \n"
+				"bsfq %2, %0           \n"
+				"cmovz %1, %0          \n"
+
+				: "=r" (result), "=&r" (dummy)
+				: "r" (x)
+				: "cc" );
+
+		#endif
+
+
+	return result;
+	}
+
+
+	/*!
+		this method sets a special bit in the 'value'
+		and returns the last state of the bit (zero or one)
+
+		***this method is created only on a 64bit platform***
+
+		bit is from <0,63>
+
+		e.g.
+		 uint x = 100;
+		 uint bit = SetBitInWord(x, 3);
+		 now: x = 108 and bit = 0
+	*/
+	template<uint value_size>
+	uint UInt<value_size>::SetBitInWord(uint & value, uint bit)
+	{
+		TTMATH_ASSERT( bit < TTMATH_BITS_PER_UINT )
+		
+		uint old_bit;
+		uint v = value;
+
+
+		#ifndef __GNUC__
+			old_bit = _bittestandset64((__int64*)&value,bit) != 0;
+		#endif
+
+
+		#ifdef __GNUC__
+
+			__asm__ (
+
+			"btsq %%rbx, %%rax		\n"
+			"setc %%bl				\n"
+			"movzx %%bl, %%rbx		\n"
+			
+			: "=a" (v), "=b" (old_bit)
+			: "0" (v),  "1" (bit)
+			: "cc" );
+
+		#endif
+
+		value = v;
+
+	return old_bit;
+	}
+
+
+	/*!
+	 *
+	 * Multiplication
+	 *
+	 *
+	*/
+
+
+	/*!
+		multiplication: result_high:result_low = a * b
+		result_high - higher word of the result
+		result_low  - lower word of the result
+	
+		this methos never returns a carry
+		this method is used in the second version of the multiplication algorithms
+
+		***this method is created only on a 64bit platform***
+	*/
+	template<uint value_size>
+	void UInt<value_size>::MulTwoWords(uint a, uint b, uint * result_high, uint * result_low)
+	{
+	/*
+		we must use these temporary variables in order to inform the compilator
+		that value pointed with result1 and result2 has changed
+
+		this has no effect in visual studio but it's usefull when
+		using gcc and options like -O
+	*/
+	uint result1_;
+	uint result2_;
+
+
+		#ifndef __GNUC__
+			result1_ = _umul128(a,b,&result2_);
+		#endif
+
+
+		#ifdef __GNUC__
+
+		__asm__ (
+		
+			"mulq %%rdx			\n"
+
+			: "=a" (result1_), "=d" (result2_)
+			: "0" (a),         "1" (b)
+			: "cc" );
+
+		#endif
+
+
+		*result_low  = result1_;
+		*result_high = result2_;
+	}
+
+
+
+
+	/*!
+	 *
+	 * Division
+	 *
+	 *
+	*/
+	
+
+	/*!
+		this method calculates 64bits word a:b / 32bits c (a higher, b lower word)
+		r = a:b / c and rest - remainder
+		
+		***this method is created only on a 64bit platform***
+
+		*
+		* WARNING:
+		* if r (one word) is too small for the result or c is equal zero
+		* there'll be a hardware interruption (0)
+		* and probably the end of your program
+		*
+	*/
+	template<uint value_size>
+	void UInt<value_size>::DivTwoWords(uint a,uint b, uint c, uint * r, uint * rest)
+	{
+		uint r_;
+		uint rest_;
+		/*
+			these variables have similar meaning like those in
+			the multiplication algorithm MulTwoWords
+		*/
+
+		TTMATH_ASSERT( c != 0 )
+
+
+		#ifndef __GNUC__
+
+			ttmath_div_x64(&a,&b,c);
+			r_    = a;
+			rest_ = b;
+			
+		#endif
+
+
+		#ifdef __GNUC__
+		
+			__asm__ (
+
+			"divq %%rcx				\n"
+
+			: "=a" (r_), "=d" (rest_)
+			: "d" (a), "a" (b), "c" (c)
+			: "cc" );
+
+		#endif
+
+
+		*r = r_;
+		*rest = rest_;
+	}
+
+} //namespace
+
+
+#endif //ifdef TTMATH_PLATFORM64
+#endif //ifndef TTMATH_NOASM
+#endif
+
+
diff --git a/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86_64_msvc.asm b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86_64_msvc.asm
new file mode 100644
index 0000000..b7c85c2
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath/ttmathuint_x86_64_msvc.asm
@@ -0,0 +1,548 @@
+;
+; This file is a part of TTMath Bignum Library
+; and is distributed under the (new) BSD licence.
+; Author: Christian Kaiser <chk at online.de>
+;
+
+; 
+; Copyright (c) 2009, Christian Kaiser
+; All rights reserved.
+; 
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions are met:
+; 
+;  * Redistributions of source code must retain the above copyright notice,
+;    this list of conditions and the following disclaimer.
+;    
+;  * Redistributions in binary form must reproduce the above copyright
+;    notice, this list of conditions and the following disclaimer in the
+;    documentation and/or other materials provided with the distribution.
+;    
+;  * Neither the name Christian Kaiser nor the names of contributors to this
+;    project may be used to endorse or promote products derived
+;    from this software without specific prior written permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+; THE POSSIBILITY OF SUCH DAMAGE.
+;
+
+;
+; compile with debug info:    ml64.exe /c /Zd /Zi ttmathuint_x86_64_msvc.asm
+; compile without debug info: ml64.exe /c ttmathuint_x86_64_msvc.asm
+; this creates ttmathuint_x86_64_msvc.obj file which can be linked with your program
+;
+
+PUBLIC	ttmath_adc_x64
+PUBLIC	ttmath_addindexed_x64
+PUBLIC	ttmath_addindexed2_x64
+PUBLIC	ttmath_addvector_x64
+
+PUBLIC	ttmath_sbb_x64
+PUBLIC	ttmath_subindexed_x64
+PUBLIC	ttmath_subvector_x64
+
+PUBLIC	ttmath_rcl_x64
+PUBLIC	ttmath_rcr_x64
+
+PUBLIC	ttmath_rcl2_x64
+PUBLIC	ttmath_rcr2_x64
+
+PUBLIC	ttmath_div_x64
+
+;
+; Microsoft x86_64 convention: http://msdn.microsoft.com/en-us/library/9b372w95.aspx
+;
+;	"rax, rcx, rdx, r8-r11 are volatile."
+;	"rbx, rbp, rdi, rsi, r12-r15 are nonvolatile."
+;
+
+
+.CODE
+
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_adc_x64				PROC
+        ; rcx = p1
+        ; rdx = p2
+        ; r8 = nSize
+        ; r9 = nCarry
+
+        xor		rax, rax
+        xor		r11, r11
+        sub		rax, r9		; sets CARRY if r9 != 0
+
+		ALIGN 16
+ loop1:
+		mov		rax,qword ptr [rdx + r11 * 8]
+		adc		qword ptr [rcx + r11 * 8], rax
+		lea		r11, [r11+1]
+		dec		r8
+		jnz		loop1
+
+		setc	al
+		movzx	rax, al
+
+		ret
+
+ttmath_adc_x64				ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_addindexed_x64	PROC
+
+        ; rcx = p1
+        ; rdx = nSize
+        ; r8 = nPos
+        ; r9 = nValue
+
+		xor		rax, rax			; rax = result
+		sub		rdx, r8				; rdx = remaining count of uints
+
+		add		qword ptr [rcx + r8 * 8], r9
+		jc		next1
+
+		ret
+
+next1:
+		mov		r9, 1
+
+		ALIGN 16
+loop1:
+		dec		rdx
+		jz		done_with_cy
+		lea		r8, [r8+1]
+		add		qword ptr [rcx + r8 * 8], r9
+		jc		loop1
+
+		ret
+
+done_with_cy:
+		lea		rax, [rax+1]		; rax = 1
+
+		ret
+
+ttmath_addindexed_x64	ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_addindexed2_x64	PROC
+
+        ; rcx = p1 (pointer)
+        ; rdx = b  (value size)
+        ; r8 = nPos
+        ; r9 = nValue1
+        ; [esp+0x28] = nValue2
+
+		xor		rax, rax			; return value
+		mov		r11, rcx			; table
+		sub		rdx, r8				; rdx = remaining count of uints
+		mov		r10, [esp+028h]		; r10 = nValue2
+
+		add		qword ptr [r11 + r8 * 8], r9
+		lea		r8, [r8+1]
+		lea		rdx, [rdx-1]
+		adc		qword ptr [r11 + r8 * 8], r10
+		jc		next
+		ret
+
+		ALIGN 16
+loop1:
+		lea		r8, [r8+1]
+		add		qword ptr [r11 + r8 * 8], 1
+		jc		next
+		ret
+
+next:
+		dec		rdx					; does not modify CY too...
+		jnz		loop1
+		lea		rax, [rax+1]
+		ret
+
+ttmath_addindexed2_x64	ENDP
+
+
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+
+ttmath_addvector_x64				PROC
+        ; rcx = ss1
+        ; rdx = ss2
+        ; r8 = ss1_size
+        ; r9 = ss2_size
+        ; [esp+0x28] = result
+
+		mov		r10, [esp+028h]
+		sub		r8, r9
+        xor		r11, r11				; r11=0, cf=0
+
+		ALIGN 16
+ loop1:
+		mov		rax, qword ptr [rcx + r11 * 8]
+		adc		rax, qword ptr [rdx + r11 * 8]
+		mov		qword ptr [r10 + r11 * 8], rax
+		inc		r11
+		dec		r9
+		jnz		loop1
+
+		adc		r9, r9					; r9 has the cf state
+
+		or		r8, r8
+		jz		done
+
+		neg		r9						; setting cf from r9
+		mov		r9, 0					; don't use xor here (cf is used)
+ loop2:
+		mov		rax, qword ptr [rcx + r11 * 8]
+		adc		rax, r9
+		mov		qword ptr [r10 + r11 * 8], rax
+		inc		r11
+		dec		r8
+		jnz		loop2
+
+		adc		r8, r8
+		mov		rax, r8
+		
+		ret
+
+done:
+		mov		rax, r9
+		ret
+
+ttmath_addvector_x64				ENDP
+
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_sbb_x64				PROC
+
+        ; rcx = p1
+        ; rdx = p2
+        ; r8 = nCount
+        ; r9 = nCarry
+
+        xor		rax, rax
+        xor		r11, r11
+        sub		rax, r9				; sets CARRY if r9 != 0
+
+		ALIGN 16
+ loop1:
+		mov		rax,qword ptr [rdx + r11 * 8]
+		sbb		qword ptr [rcx + r11 * 8], rax
+		lea		r11, [r11+1]
+		dec		r8
+		jnz		loop1
+
+		setc	al
+		movzx	rax, al
+
+		ret
+
+ttmath_sbb_x64				ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_subindexed_x64	PROC
+        ; rcx = p1
+        ; rdx = nSize
+        ; r8 = nPos
+        ; r9 = nValue
+
+		sub		rdx, r8				; rdx = remaining count of uints
+
+		ALIGN 16
+loop1:
+		sub		qword ptr [rcx + r8 * 8], r9
+		jnc		done
+
+		lea		r8, [r8+1]
+		mov		r9, 1
+		dec		rdx
+		jnz		loop1
+
+		mov		rax, 1
+		ret
+
+done:
+		xor		rax, rax
+		ret
+
+ttmath_subindexed_x64	ENDP
+
+
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+;	the same asm code as in addvector_x64 only two instructions 'adc' changed to 'sbb'
+
+ttmath_subvector_x64				PROC
+        ; rcx = ss1
+        ; rdx = ss2
+        ; r8 = ss1_size
+        ; r9 = ss2_size
+        ; [esp+0x28] = result
+
+		mov		r10, [esp+028h]
+		sub		r8, r9
+        xor		r11, r11				; r11=0, cf=0
+
+		ALIGN 16
+ loop1:
+		mov		rax, qword ptr [rcx + r11 * 8]
+		sbb		rax, qword ptr [rdx + r11 * 8]
+		mov		qword ptr [r10 + r11 * 8], rax
+		inc		r11
+		dec		r9
+		jnz		loop1
+
+		adc		r9, r9					; r9 has the cf state
+
+		or		r8, r8
+		jz		done
+
+		neg		r9						; setting cf from r9
+		mov		r9, 0					; don't use xor here (cf is used)
+ loop2:
+		mov		rax, qword ptr [rcx + r11 * 8]
+		sbb		rax, r9
+		mov		qword ptr [r10 + r11 * 8], rax
+		inc		r11
+		dec		r8
+		jnz		loop2
+
+		adc		r8, r8
+		mov		rax, r8
+		
+		ret
+
+done:
+		mov		rax, r9
+		ret
+
+ttmath_subvector_x64				ENDP
+
+
+
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_rcl_x64	PROC
+        ; rcx = p1
+        ; rdx = b
+        ; r8 = nLowestBit
+
+		mov		r11, rcx			; table
+		xor		r10, r10
+		neg		r8					; CY set if r8 <> 0
+
+		ALIGN 16
+loop1:
+		rcl		qword ptr [r11 + r10 * 8], 1
+		lea		r10, [r10+1]
+		dec		rdx
+		jnz		loop1
+
+		setc	al
+		movzx	rax, al
+
+        ret
+
+ttmath_rcl_x64	ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_rcr_x64	PROC
+        ; rcx = p1
+        ; rdx = nSize
+        ; r8 = nLowestBit
+
+		xor		r10, r10
+		neg		r8					; CY set if r8 <> 0
+
+		ALIGN 16
+loop1:
+		rcr		qword ptr -8[rcx + rdx * 8], 1
+		dec		rdx
+		jnz		loop1
+
+		setc	al
+		movzx	rax, al
+
+        ret
+
+ttmath_rcr_x64	ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_div_x64	PROC
+
+        ; rcx = &Hi
+        ; rdx = &Lo
+        ; r8 = nDiv
+
+        mov		r11, rcx
+        mov		r10, rdx
+
+        mov		rdx, qword ptr [r11]
+        mov		rax, qword ptr [r10]
+        div		r8
+        mov		qword ptr [r10], rdx ; remainder
+        mov		qword ptr [r11], rax ; value
+
+        ret
+
+ttmath_div_x64	ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_rcl2_x64	PROC
+        ; rcx = p1
+        ; rdx = nSize
+        ; r8 = bits
+        ; r9 = c
+
+        push	rbx
+
+        mov		r10, rcx	; r10 = p1
+        xor		rax, rax
+
+        mov		rcx, 64
+        sub		rcx, r8
+
+        mov		r11, -1
+        shr		r11, cl		; r11 = mask
+
+		mov		rcx, r8		; rcx = count of bits
+
+		mov		rbx, rax	; rbx = old value = 0
+		or		r9, r9
+		cmovnz	rbx, r11	; if (c) then old value = mask
+
+        mov		r9, rax		; r9 = index (0..nSize-1)
+
+		ALIGN 16
+loop1:
+		rol		qword ptr [r10+r9*8], cl
+		mov		rax, qword ptr [r10+r9*8]
+		and		rax, r11
+		xor		qword ptr [r10+r9*8], rax
+		or		qword ptr [r10+r9*8], rbx
+		mov		rbx, rax
+
+		lea		r9, [r9+1]
+		dec		rdx
+
+		jnz		loop1
+
+		and		rax, 1
+		pop		rbx
+        ret
+
+ttmath_rcl2_x64	ENDP
+
+;----------------------------------------
+
+        ALIGN       8
+
+;----------------------------------------
+
+ttmath_rcr2_x64	PROC
+        ; rcx = p1
+        ; rdx = nSize
+        ; r8 = bits
+        ; r9 = c
+
+        push	rbx
+        mov		r10, rcx	; r10 = p1
+        xor		rax, rax
+
+        mov		rcx, 64
+        sub		rcx, r8
+
+        mov		r11, -1
+        shl		r11, cl		; r11 = mask
+
+		mov		rcx, r8		; rcx = count of bits
+
+		mov		rbx, rax	; rbx = old value = 0
+		or		r9, r9
+		cmovnz	rbx, r11	; if (c) then old value = mask
+
+        mov		r9, rdx		; r9 = index (0..nSize-1)
+		lea		r9, [r9-1]
+
+		ALIGN 16
+loop1:
+		ror		qword ptr [r10+r9*8], cl
+		mov		rax, qword ptr [r10+r9*8]
+		and		rax, r11
+		xor		qword ptr [r10+r9*8], rax
+		or		qword ptr [r10+r9*8], rbx
+		mov		rbx, rax
+
+		lea		r9, [r9-1]
+		dec		rdx
+
+		jnz		loop1
+
+		rol		rax, 1
+		and		rax, 1
+		pop		rbx
+
+        ret
+
+ttmath_rcr2_x64	ENDP
+
+END
diff --git a/src/boost/geometry/extensions/contrib/ttmath_stub.hpp b/src/boost/geometry/extensions/contrib/ttmath_stub.hpp
new file mode 100644
index 0000000..50da4c0
--- /dev/null
+++ b/src/boost/geometry/extensions/contrib/ttmath_stub.hpp
@@ -0,0 +1,293 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef TTMATH_STUB
+#define TTMATH_STUB
+
+#include <boost/math/constants/constants.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/coordinate_cast.hpp>
+
+
+#include <ttmath.h>
+namespace ttmath
+{
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> sqrt(Big<Exponent, Mantissa> const& v)
+    {
+        return Sqrt(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> abs(Big<Exponent, Mantissa> const& v)
+    {
+        return Abs(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> ceil(Big<Exponent, Mantissa> const& v)
+    {
+        return Ceil(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> floor(Big<Exponent, Mantissa> const& v)
+    {
+        return Floor(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> asin(Big<Exponent, Mantissa> const& v)
+    {
+        return ASin(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> sin(Big<Exponent, Mantissa> const& v)
+    {
+        return Sin(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> cos(Big<Exponent, Mantissa> const& v)
+    {
+        return Cos(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> tan(Big<Exponent, Mantissa> const& v)
+    {
+        return Tan(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> atan(Big<Exponent, Mantissa> const& v)
+    {
+        return ATan(v);
+    }
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> acos(Big<Exponent, Mantissa> const& v)
+    {
+        return ACos(v);
+    }
+
+
+    template <uint Exponent, uint Mantissa>
+    inline Big<Exponent, Mantissa> atan2(Big<Exponent, Mantissa> const& y, Big<Exponent, Mantissa> const& x)
+    {
+        // return ATan2(y, 2); does not (yet) exist in ttmath...
+
+        // See http://en.wikipedia.org/wiki/Atan2
+
+        Big<Exponent, Mantissa> const zero(0);
+        Big<Exponent, Mantissa> const two(2);
+
+        if (y == zero)
+        {
+            // return x >= 0 ? 0 : pi and pi=2*arccos(0)
+            return x >= zero ? zero : two * ACos(zero);
+        }
+
+        return two * ATan((sqrt(x * x + y * y) - x) / y);
+    }
+
+}
+
+// Specific structure implementing constructor
+// (WHICH IS NECESSARY FOR Boost.Geometry because it enables using T() !! )
+struct ttmath_big : ttmath::Big<1,4>
+{
+    ttmath_big(double v = 0)
+        : ttmath::Big<1,4>(v)
+    {}
+    ttmath_big(ttmath::Big<1,4> const& v)
+        : ttmath::Big<1,4>(v)
+    {}
+
+    /*
+    inline operator double() const
+    {
+        return atof(this->ToString().c_str());
+    }
+
+    inline operator int() const
+    {
+        return atol(ttmath::Round(*this).ToString().c_str());
+    }
+    */
+};
+
+namespace boost{ namespace geometry { namespace math
+{
+
+namespace detail
+{
+    // Workaround for boost::math::constants::pi:
+    // 1) lexical cast -> stack overflow and
+    // 2) because it is implemented as a function, generic implementation not possible
+
+    // Partial specialization for ttmath
+    template <ttmath::uint Exponent, ttmath::uint Mantissa>
+    struct define_pi<ttmath::Big<Exponent, Mantissa> >
+    {
+        static inline ttmath::Big<Exponent, Mantissa> apply()
+        {
+            static ttmath::Big<Exponent, Mantissa> const the_pi(
+                "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196");
+            return the_pi;
+        }
+    };
+
+    template <>
+    struct define_pi<ttmath_big>
+            : public define_pi<ttmath::Big<1,4> > 
+    {};
+    
+    template <ttmath::uint Exponent, ttmath::uint Mantissa>
+    struct equals_with_epsilon<ttmath::Big<Exponent, Mantissa>, false>
+    {
+        static inline bool apply(ttmath::Big<Exponent, Mantissa> const& a, ttmath::Big<Exponent, Mantissa> const& b)
+        {
+            // See implementation in util/math.hpp
+            // But here borrow the tolerance for double, to avoid exact comparison
+            ttmath::Big<Exponent, Mantissa> const epsilon = std::numeric_limits<double>::epsilon();
+            return ttmath::Abs(a - b) <= epsilon * ttmath::Abs(a);
+        }
+    };
+    
+    template <>
+    struct equals_with_epsilon<ttmath_big, false> 
+            : public equals_with_epsilon<ttmath::Big<1, 4>, false> 
+    {};
+
+} // detail
+
+} // ttmath
+
+
+namespace detail
+{
+
+template <ttmath::uint Exponent, ttmath::uint Mantissa>
+struct coordinate_cast<ttmath::Big<Exponent, Mantissa> >
+{
+    static inline ttmath::Big<Exponent, Mantissa> apply(std::string const& source)
+    {
+        return ttmath::Big<Exponent, Mantissa> (source);
+    }
+};
+
+
+template <>
+struct coordinate_cast<ttmath_big>
+{
+    static inline ttmath_big apply(std::string const& source)
+    {
+        return ttmath_big(source);
+    }
+};
+
+} // namespace detail
+
+
+}} // boost::geometry
+
+
+
+
+// Support for boost::numeric_cast to int and to double (necessary for SVG-mapper)
+namespace boost { namespace numeric
+{
+
+template
+<
+    ttmath::uint Exponent, ttmath::uint Mantissa,
+    typename Traits,
+    typename OverflowHandler,
+    typename Float2IntRounder,
+    typename RawConverter,
+    typename UserRangeChecker
+>
+struct converter<int, ttmath::Big<Exponent, Mantissa>, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker>
+{
+    static inline int convert(ttmath::Big<Exponent, Mantissa> arg)
+    {
+        int v;
+        arg.ToInt(v);
+        return v;
+    }
+};
+
+template
+<
+    ttmath::uint Exponent, ttmath::uint Mantissa,
+    typename Traits,
+    typename OverflowHandler,
+    typename Float2IntRounder,
+    typename RawConverter,
+    typename UserRangeChecker
+>
+struct converter<double, ttmath::Big<Exponent, Mantissa>, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker>
+{
+    static inline double convert(ttmath::Big<Exponent, Mantissa> arg)
+    {
+        double v;
+        arg.ToDouble(v);
+        return v;
+    }
+};
+
+
+template
+<
+    typename Traits,
+    typename OverflowHandler,
+    typename Float2IntRounder,
+    typename RawConverter,
+    typename UserRangeChecker
+>
+struct converter<int, ttmath_big, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker>
+{
+    static inline int convert(ttmath_big arg)
+    {
+        int v;
+        arg.ToInt(v);
+        return v;
+    }
+};
+
+template
+<
+    typename Traits,
+    typename OverflowHandler,
+    typename Float2IntRounder,
+    typename RawConverter,
+    typename UserRangeChecker
+>
+struct converter<double, ttmath_big, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker>
+{
+    static inline double convert(ttmath_big arg)
+    {
+        double v;
+        arg.ToDouble(v);
+        return v;
+    }
+};
+
+
+}}
+
+
+#endif
diff --git a/src/boost/geometry/extensions/geometries/quantity_point.hpp b/src/boost/geometry/extensions/geometries/quantity_point.hpp
new file mode 100644
index 0000000..ebfd894
--- /dev/null
+++ b/src/boost/geometry/extensions/geometries/quantity_point.hpp
@@ -0,0 +1,134 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GEOMETRIES_QUANTITY_POINT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GEOMETRIES_QUANTITY_POINT_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/int.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/geometries/point.hpp>
+
+#include <boost/units/quantity.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace cs
+{
+
+template <typename Unit>
+struct units_cartesian {};
+
+}
+
+namespace traits
+{
+
+template<typename U>
+struct cs_tag<cs::units_cartesian<U> >
+{
+    typedef cartesian_tag type;
+};
+
+}
+
+
+namespace model
+{
+
+// Define a point type to interoperate with Boost.Units, having
+// 1. a constructor taking quantities
+// 2. defining a quantified coordinate system
+// Note that all values are still stored in "normal" types as double
+template
+<
+    typename Units,
+    std::size_t DimensionCount = 2,
+    typename CoordinateType = double,
+    typename CoordinateSystem = cs::units_cartesian<Units>
+>
+class quantity_point
+    : public model::point<CoordinateType, DimensionCount, CoordinateSystem>
+{
+    typedef boost::units::quantity<Units, CoordinateType> qtype;
+
+public :
+
+    // Templated constructor to allow constructing with other units then qtype,
+    // e.g. to convert from centimeters to meters
+    template <typename Quantity>
+    inline quantity_point(Quantity const& x, Quantity const& y)
+        : model::point<CoordinateType, DimensionCount, CoordinateSystem>(
+            qtype(x).value(),
+            qtype(y).value())
+    {}
+};
+
+}
+
+
+// Adapt quantity_point to the Point Concept
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename Units, std::size_t DimensionCount, typename CoordinateType, typename CoordinateSystem>
+struct tag<model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem> >
+{
+    typedef point_tag type;
+};
+
+template<typename Units, std::size_t DimensionCount, typename CoordinateType, typename CoordinateSystem>
+struct coordinate_type<model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem> >
+{
+    typedef CoordinateType type;
+};
+
+template<typename Units, std::size_t DimensionCount, typename CoordinateType, typename CoordinateSystem>
+struct coordinate_system<model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem> >
+{
+    typedef CoordinateSystem type;
+};
+
+template<typename Units, std::size_t DimensionCount, typename CoordinateType, typename CoordinateSystem>
+struct dimension<model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem> >
+    : boost::mpl::int_<DimensionCount>
+{};
+
+template<typename Units, std::size_t DimensionCount, typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
+struct access<model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem>, Dimension >
+{
+    static inline CoordinateType get(
+        model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem> const& p)
+    {
+        return p.template get<Dimension>();
+    }
+
+    static inline void set(model::quantity_point<Units, DimensionCount, CoordinateType, CoordinateSystem>& p,
+        CoordinateType const& value)
+    {
+        p.template set<Dimension>(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GEOMETRIES_QUANTITY_POINT_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/core/cs.hpp b/src/boost/geometry/extensions/gis/geographic/core/cs.hpp
new file mode 100644
index 0000000..878241e
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/core/cs.hpp
@@ -0,0 +1,81 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_CORE_CS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_CORE_CS_HPP
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace cs
+{
+
+/*!
+    \brief EPSG Cartesian coordinate system
+    \details EPSG (European Petrol Survey Group) has a standard list of projections,
+        each having a code
+    \see
+    \ingroup cs
+    \tparam Code the EPSG code
+    \todo Maybe derive from boost::mpl::int_<EpsgCode>
+*/
+template<std::size_t Code>
+struct epsg
+{
+    static const std::size_t epsg_code = Code;
+};
+
+
+
+/*!
+    \brief Earth Centered, Earth Fixed
+    \details Defines a Cartesian coordinate system x,y,z with the center of the earth as its origin,
+        going through the Greenwich
+    \see http://en.wikipedia.org/wiki/ECEF
+    \see http://en.wikipedia.org/wiki/Geodetic_system
+    \note Also known as "Geocentric", but geocentric is also an astronomic coordinate system
+    \ingroup cs
+*/
+struct ecef
+{
+};
+
+
+} // namespace cs
+
+namespace traits
+{
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+template<>
+struct cs_tag<cs::ecef>
+{
+    typedef cartesian_tag type;
+};
+
+template <std::size_t C>
+struct cs_tag<cs::epsg<C> >
+{
+    typedef cartesian_tag type;
+};
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+} // namespace traits
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_CORE_CS_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp b/src/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp
new file mode 100644
index 0000000..b7b3c69
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP
+
+
+namespace boost { namespace geometry { namespace detail
+{
+
+
+/*!
+    \brief Defines ellipsoid values for use in distance calculations
+    \details They have a constructor with the earth radius
+    \note Will be moved / merged with projections
+    \todo Optionally specify earth model, defaulting to WGS84
+    - See http://en.wikipedia.org/wiki/Figure_of_the_Earth
+    - and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
+    \note
+*/
+template <typename T>
+class ellipsoid
+{
+    public :
+        ellipsoid(T const& a, T const& b)
+            : m_a(a)
+            , m_b(b)
+            , m_f((a - b) / a)
+        {}
+        ellipsoid()
+            : m_a(T(6378137.0))
+            , m_b(T(6356752.314245))
+            , m_f((m_a - m_b) / m_a)
+        {}
+        // Unit sphere
+        ellipsoid(T const& f)
+            : m_a(1.0)
+            , m_f(f)
+        {}
+
+        T a() const { return m_a; }
+        T b() const { return m_b; }
+        T f() const { return m_f; }
+
+    private :
+        T m_a, m_b, m_f; // equatorial radius, polar radius, flattening
+};
+
+
+
+
+}}} // namespace boost::geometry::detail
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp b/src/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp
new file mode 100644
index 0000000..0834ba6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp
@@ -0,0 +1,224 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_ANDOYER_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_ANDOYER_HPP
+
+
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/promote_floating_point.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace distance
+{
+
+
+/*!
+\brief Point-point distance approximation taking flattening into account
+\ingroup distance
+\tparam Point1 \tparam_first_point
+\tparam Point2 \tparam_second_point
+\tparam CalculationType \tparam_calculation
+\author After Andoyer, 19xx, republished 1950, republished by Meeus, 1999
+\note Although not so well-known, the approximation is very good: in all cases the results
+are about the same as Vincenty. In my (Barend's) testcases the results didn't differ more than 6 m
+\see http://nacc.upc.es/tierra/node16.html
+\see http://sci.tech-archive.net/Archive/sci.geo.satellite-nav/2004-12/2724.html
+\see http://home.att.net/~srschmitt/great_circle_route.html (implementation)
+\see http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115 (implementation)
+\see http://futureboy.homeip.net/frinksamp/navigation.frink (implementation)
+\see http://www.voidware.com/earthdist.htm (implementation)
+*/
+template
+<
+    typename Point1,
+    typename Point2 = Point1,
+    typename CalculationType = void
+>
+class andoyer
+{
+    public :
+    typedef typename promote_floating_point
+        <
+            typename select_calculation_type
+                <
+                    Point1,
+                    Point2,
+                    CalculationType
+                >::type
+        >::type calculation_type;
+
+        inline andoyer()
+            : m_ellipsoid()
+        {}
+
+        explicit inline andoyer(calculation_type f)
+            : m_ellipsoid(f)
+        {}
+
+        explicit inline andoyer(geometry::detail::ellipsoid<calculation_type> const& e)
+            : m_ellipsoid(e)
+        {}
+
+
+        inline calculation_type apply(Point1 const& point1, Point2 const& point2) const
+        {
+            return calc(get_as_radian<0>(point1), get_as_radian<1>(point1),
+                            get_as_radian<0>(point2), get_as_radian<1>(point2));
+        }
+
+        inline geometry::detail::ellipsoid<calculation_type> ellipsoid() const
+        {
+            return m_ellipsoid;
+        }
+
+        inline calculation_type radius() const
+        {
+            return m_ellipsoid.a();
+        }
+
+
+    private :
+        geometry::detail::ellipsoid<calculation_type> m_ellipsoid;
+
+        inline calculation_type calc(calculation_type const& lon1,
+                    calculation_type const& lat1,
+                    calculation_type const& lon2,
+                    calculation_type const& lat2) const
+        {
+            calculation_type const G = (lat1 - lat2) / 2.0;
+            calculation_type const lambda = (lon1 - lon2) / 2.0;
+
+            if (geometry::math::equals(lambda, 0.0)
+                && geometry::math::equals(G, 0.0))
+            {
+                return 0.0;
+            }
+
+            calculation_type const F = (lat1 + lat2) / 2.0;
+
+            calculation_type const sinG2 = math::sqr(sin(G));
+            calculation_type const cosG2 = math::sqr(cos(G));
+            calculation_type const sinF2 = math::sqr(sin(F));
+            calculation_type const cosF2 = math::sqr(cos(F));
+            calculation_type const sinL2 = math::sqr(sin(lambda));
+            calculation_type const cosL2 = math::sqr(cos(lambda));
+
+            calculation_type const S = sinG2 * cosL2 + cosF2 * sinL2;
+            calculation_type const C = cosG2 * cosL2 + sinF2 * sinL2;
+
+            calculation_type const c0 = 0;
+            calculation_type const c1 = 1;
+            calculation_type const c2 = 2;
+            calculation_type const c3 = 3;
+
+            if (geometry::math::equals(S, c0) || geometry::math::equals(C, c0))
+            {
+                return c0;
+            }
+
+            calculation_type const omega = atan(sqrt(S / C));
+            calculation_type const r3 = c3 * sqrt(S * C) / omega; // not sure if this is r or greek nu
+            calculation_type const D = c2 * omega * m_ellipsoid.a();
+            calculation_type const H1 = (r3 - c1) / (c2 * C);
+            calculation_type const H2 = (r3 + c1) / (c2 * S);
+            calculation_type const f = m_ellipsoid.f();
+
+            return D * (c1 + f * H1 * sinF2 * cosG2 - f * H2 * cosF2 * sinG2);
+        }
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename Point1, typename Point2>
+struct tag<strategy::distance::andoyer<Point1, Point2> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+template <typename Point1, typename Point2>
+struct return_type<strategy::distance::andoyer<Point1, Point2> >
+{
+    typedef typename strategy::distance::andoyer<Point1, Point2>::calculation_type type;
+};
+
+
+template <typename Point1, typename Point2, typename P1, typename P2>
+struct similar_type<andoyer<Point1, Point2>, P1, P2>
+{
+    typedef andoyer<P1, P2> type;
+};
+
+
+template <typename Point1, typename Point2, typename P1, typename P2>
+struct get_similar<andoyer<Point1, Point2>, P1, P2>
+{
+    static inline andoyer<P1, P2> apply(andoyer<Point1, Point2> const& input)
+    {
+        return andoyer<P1, P2>(input.ellipsoid());
+    }
+};
+
+template <typename Point1, typename Point2>
+struct comparable_type<andoyer<Point1, Point2> >
+{
+    typedef andoyer<Point1, Point2> type;
+};
+
+
+template <typename Point1, typename Point2>
+struct get_comparable<andoyer<Point1, Point2> >
+{
+    static inline andoyer<Point1, Point2> apply(andoyer<Point1, Point2> const& input)
+    {
+        return input;
+    }
+};
+
+template <typename Point1, typename Point2>
+struct result_from_distance<andoyer<Point1, Point2> >
+{
+    template <typename T>
+    static inline typename return_type<andoyer<Point1, Point2> >::type apply(andoyer<Point1, Point2> const& , T const& value)
+    {
+        return value;
+    }
+};
+
+
+template <typename Point1, typename Point2>
+struct default_strategy<point_tag, Point1, Point2, geographic_tag, geographic_tag>
+{
+    typedef strategy::distance::andoyer<Point1, Point2> type;
+};
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_ANDOYER_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/strategies/area_huiller_earth.hpp b/src/boost/geometry/extensions/gis/geographic/strategies/area_huiller_earth.hpp
new file mode 100644
index 0000000..8116279
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/strategies/area_huiller_earth.hpp
@@ -0,0 +1,64 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_AREA_HUILLER_EARTH_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_AREA_HUILLER_EARTH_HPP
+
+
+
+#include <boost/geometry/strategies/spherical/area_huiller.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace area
+{
+
+template
+<
+    typename PointOfSegment,
+    typename CalculationType = void
+>
+class huiller_earth
+    : public huiller<PointOfSegment, CalculationType>
+{
+public :
+    // By default the average earth radius.
+    // Uses can specify another radius.
+    // Note that the earth is still handled spherically
+    inline huiller_earth(double radius = 6372795.0)
+        : huiller<PointOfSegment, CalculationType>(radius)
+    {}
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+
+template <typename Point>
+struct default_strategy<geographic_tag, Point>
+{
+    typedef huiller_earth<Point> type;
+};
+
+} // namespace services
+
+
+#endif
+
+
+}} // namespace strategy::area
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_AREA_HUILLER_EARTH_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/strategies/distance_cross_track.hpp b/src/boost/geometry/extensions/gis/geographic/strategies/distance_cross_track.hpp
new file mode 100644
index 0000000..fbec0a5
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/strategies/distance_cross_track.hpp
@@ -0,0 +1,72 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+
+#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
+
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace distance
+{
+
+namespace services
+{
+
+
+template <typename Point, typename PointOfSegment, typename Strategy>
+struct default_strategy<segment_tag, Point, PointOfSegment, geographic_tag, geographic_tag, Strategy>
+{
+    typedef cross_track
+        <
+            Point,
+            PointOfSegment,
+            void,
+            typename boost::mpl::if_
+                <
+                    boost::is_void<Strategy>,
+                    typename default_strategy
+                        <
+                            point_tag, Point, PointOfSegment,
+                            geographic_tag, geographic_tag
+                        >::type,
+                    Strategy
+                >::type
+        > type;
+};
+
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp b/src/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp
new file mode 100644
index 0000000..5db5fcb
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp
@@ -0,0 +1,267 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_DMS_PARSER_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_DMS_PARSER_HPP
+
+// This file is totally revised from PROJ4 dmstor.c
+
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <string>
+
+#include <boost/static_assert.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/extensions/strategies/parse.hpp>
+
+#include <boost/geometry/util/math.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+struct dms_result
+{
+    enum axis_selector {axis_lat = 1, axis_lon = 0};
+
+    private :
+        typedef double T;
+        T m_angle;
+        axis_selector m_axis;
+
+    public :
+
+        explicit dms_result(T const& v, axis_selector ax)
+            : m_angle(v)
+            , m_axis(ax)
+        {}
+
+        inline axis_selector axis() const { return m_axis; }
+
+        inline operator double() const { return m_angle; }
+
+        template <typename CH, typename TR>
+        inline friend std::basic_ostream<CH, TR>& operator<<(std::basic_ostream<CH, TR>& os,
+                        const dms_result& d)
+        {
+            os << d.m_angle;
+            return os;
+        }
+
+};
+
+
+namespace strategy
+{
+
+    template <bool as_radian = true
+            , char N = 'N', char E = 'E', char S = 'S', char W = 'W' // translatable
+            , char MIN = '\'', char SEC = '"' // other char's possible
+            , char D = 'D', char R = 'R' // degree sign might be small o
+            >
+    struct dms_parser
+    {
+
+
+        // Question from Barend: can we compile-time select that it is case-sensitive/case-insensitive?
+        // We have to change the switch then -> specializations
+
+        // For now: make it (compile-time) case sensitive
+        static const int diff = 'a' - 'A';
+#ifndef __GNUC__
+        BOOST_STATIC_ASSERT((diff > 0)); // make sure we've the right assumption. GCC does not accept this here.
+#endif
+        static const char n_alter = N <= 'Z' ? N + diff : N - diff;
+        static const char e_alter = E <= 'Z' ? E + diff : E - diff;
+        static const char s_alter = S <= 'Z' ? S + diff : S - diff;
+        static const char w_alter = W <= 'Z' ? W + diff : W - diff;
+
+        static const char r_alter = R <= 'Z' ? R + diff : R - diff;
+
+        // degree is normally D (proj4) but might be superscript o
+        // Note d_alter is not correct then, so map it to NULL now, guarded by the while
+        static const char d_alter =
+            ((D >= 'A' && D <= 'Z') || (D >= 'a' && D <= 'z')) ? (D <= 'Z' ? D + diff : D - diff) : '\0';
+
+
+        struct dms_value
+        {
+            double dms[3];
+            bool has_dms[3];
+
+            dms_value()
+            {
+                memset(this, 0, sizeof(dms_value));
+            }
+        };
+
+
+        template <size_t I>
+        static inline void assign_dms(dms_value& dms, std::string& value, bool& has_value)
+        {
+            dms.dms[I] = boost::lexical_cast<double>(value.c_str());
+            dms.has_dms[I] = true;
+            has_value = false;
+            value.clear();
+        }
+
+        static inline void process(dms_value& dms, std::string& value, bool& has_value)
+        {
+            if (has_value)
+            {
+                // Assign last one, sequentially
+                if (! dms.has_dms[0]) assign_dms<0>(dms, value, has_value);
+                else if (! dms.has_dms[1]) assign_dms<1>(dms, value, has_value);
+                else if (! dms.has_dms[2]) assign_dms<2>(dms, value, has_value);
+            }
+        }
+
+
+        dms_result operator()(const char* is) const
+        {
+            dms_value dms;
+            bool has_value = false;
+            std::string value;
+
+            double factor = 1.0; // + denotes N/E values, -1 denotes S/W values
+            dms_result::axis_selector axis = dms_result::axis_lon; // true denotes N/S values
+            bool in_radian = false; // true denotes values as "0.1R"
+
+            while(*is)
+            {
+                switch(*is)
+                {
+                    case '-' :
+                        if (! has_value && ! dms.has_dms[0])
+                        {
+                            factor = -factor;
+                        }
+                        break;
+                    case N :
+                    case n_alter :
+                        axis = dms_result::axis_lat;
+                        break;
+                    case S :
+                    case s_alter :
+                        axis = dms_result::axis_lat;
+                        factor = -factor;
+                        break;
+                    case E :
+                    case e_alter :
+                        axis = dms_result::axis_lon;
+                        break;
+                    case W :
+                    case w_alter :
+                        axis = dms_result::axis_lon;
+                        factor = -factor;
+                        break;
+                    case D :
+                    case d_alter :
+                        if (! dms.has_dms[0] && has_value)
+                        {
+                            assign_dms<0>(dms, value, has_value);
+                        }
+                        break;
+                    case R :
+                    case r_alter :
+                        if (! dms.has_dms[0] && has_value)
+                        {
+                            // specified value is in radian!
+                            in_radian = true;
+                            assign_dms<0>(dms, value, has_value);
+                        }
+                        break;
+                    case MIN:
+                        if (! dms.has_dms[1] && has_value)
+                        {
+                            assign_dms<1>(dms, value, has_value);
+                        }
+                        break;
+                    case SEC :
+                        if (! dms.has_dms[2] && has_value)
+                        {
+                            assign_dms<2>(dms, value, has_value);
+                        }
+                        break;
+                    case ' ' :
+                    case '\t' :
+                    case '\n' :
+                        process(dms, value, has_value);
+                        break;
+                    default :
+                        value += *is;
+                        has_value = true;
+                        break;
+                }
+                is++;
+            }
+
+            // Assign last one, if any
+            process(dms, value, has_value);
+
+            return dms_result(factor *
+                (in_radian && as_radian
+                        ? dms.dms[0]
+                : in_radian && ! as_radian
+                        ? dms.dms[0] * math::r2d
+                : ! in_radian && as_radian
+                        ? dms.dms[0] * math::d2r + dms.dms[1] * math::d2r / 60.0 + dms.dms[2] * math::d2r / 3600.0
+                        : dms.dms[0] + dms.dms[1] / 60.0 + dms.dms[2] / 3600.0)
+                , axis);
+        }
+    };
+
+}
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+template <template<typename> class CS>
+struct strategy_parse<geographic_tag, CS<degree> >
+{
+    typedef strategy::dms_parser<false> type;
+};
+
+
+template <template<typename> class CS>
+struct strategy_parse<geographic_tag, CS<radian> >
+{
+    typedef strategy::dms_parser<true> type;
+};
+
+#endif
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_DMS_PARSER_HPP
diff --git a/src/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp b/src/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp
new file mode 100644
index 0000000..9b9b887
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp
@@ -0,0 +1,262 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP
+
+#include <boost/math/constants/constants.hpp>
+
+
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/promote_floating_point.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp>
+
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace distance
+{
+
+/*!
+\brief Distance calculation formulae on latlong coordinates, after Vincenty, 1975
+\ingroup distance
+\tparam Point1 \tparam_first_point
+\tparam Point2 \tparam_second_point
+\tparam CalculationType \tparam_calculation
+\author See http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
+\author Adapted from various implementations to get it close to the original document
+    - http://www.movable-type.co.uk/scripts/LatLongVincenty.html
+    - http://exogen.case.edu/projects/geopy/source/geopy.distance.html
+    - http://futureboy.homeip.net/fsp/colorize.fsp?fileName=navigation.frink
+
+*/
+template
+<
+    typename Point1,
+    typename Point2 = Point1,
+    typename CalculationType = void
+>
+class vincenty
+{
+public :
+    typedef typename promote_floating_point
+        <
+            typename select_most_precise
+                <
+                    typename select_calculation_type
+                        <
+                            Point1,
+                            Point2,
+                            CalculationType
+                        >::type,
+                    double // to avoid bad results in float
+                >::type
+        >::type calculation_type;
+
+    inline vincenty()
+    {}
+
+    explicit inline vincenty(geometry::detail::ellipsoid<calculation_type> const& e)
+        : m_ellipsoid(e)
+    {}
+
+    inline calculation_type apply(Point1 const& p1, Point2 const& p2) const
+    {
+        return calculate(get_as_radian<0>(p1), get_as_radian<1>(p1),
+                        get_as_radian<0>(p2), get_as_radian<1>(p2));
+    }
+
+    inline geometry::detail::ellipsoid<calculation_type> ellipsoid() const
+    {
+        return m_ellipsoid;
+    }
+
+
+private :
+    geometry::detail::ellipsoid<calculation_type> m_ellipsoid;
+
+    inline calculation_type calculate(calculation_type const& lon1,
+                calculation_type const& lat1,
+                calculation_type const& lon2,
+                calculation_type const& lat2) const
+    {
+        calculation_type const c2 = 2;
+        calculation_type const pi = geometry::math::pi<calculation_type>();
+        calculation_type const two_pi = c2 * pi;
+
+        // lambda: difference in longitude on an auxiliary sphere
+        calculation_type L = lon2 - lon1;
+        calculation_type lambda = L;
+
+        if (L < -pi) L += two_pi;
+        if (L > pi) L -= two_pi;
+
+        if (math::equals(lat1, lat2) && math::equals(lon1, lon2))
+        {
+            return calculation_type(0);
+        }
+
+        // U: reduced latitude, defined by tan U = (1-f) tan phi
+        calculation_type const c1 = 1;
+        calculation_type const one_min_f = c1 - m_ellipsoid.f();
+
+        calculation_type const U1 = atan(one_min_f * tan(lat1)); // above (1)
+        calculation_type const U2 = atan(one_min_f * tan(lat2)); // above (1)
+
+        calculation_type const cos_U1 = cos(U1);
+        calculation_type const cos_U2 = cos(U2);
+        calculation_type const sin_U1 = sin(U1);
+        calculation_type const sin_U2 = sin(U2);
+
+        // alpha: azimuth of the geodesic at the equator
+        calculation_type cos2_alpha;
+        calculation_type sin_alpha;
+
+        // sigma: angular distance p1,p2 on the sphere
+        // sigma1: angular distance on the sphere from the equator to p1
+        // sigma_m: angular distance on the sphere from the equator to the midpoint of the line
+        calculation_type sigma;
+        calculation_type sin_sigma;
+        calculation_type cos2_sigma_m;
+
+        calculation_type previous_lambda;
+
+        calculation_type const c3 = 3;
+        calculation_type const c4 = 4;
+        calculation_type const c6 = 6;
+        calculation_type const c16 = 16;
+
+        calculation_type const c_e_12 = 1e-12;
+
+        do
+        {
+            previous_lambda = lambda; // (13)
+            calculation_type sin_lambda = sin(lambda);
+            calculation_type cos_lambda = cos(lambda);
+            sin_sigma = sqrt(math::sqr(cos_U2 * sin_lambda) + math::sqr(cos_U1 * sin_U2 - sin_U1 * cos_U2 * cos_lambda)); // (14)
+            calculation_type cos_sigma = sin_U1 * sin_U2 + cos_U1 * cos_U2 * cos_lambda; // (15)
+            sin_alpha = cos_U1 * cos_U2 * sin_lambda / sin_sigma; // (17)
+            cos2_alpha = c1 - math::sqr(sin_alpha);
+            cos2_sigma_m = math::equals(cos2_alpha, 0) ? 0 : cos_sigma - c2 * sin_U1 * sin_U2 / cos2_alpha; // (18)
+
+            calculation_type C = m_ellipsoid.f()/c16 * cos2_alpha * (c4 + m_ellipsoid.f() * (c4 - c3 * cos2_alpha)); // (10)
+            sigma = atan2(sin_sigma, cos_sigma); // (16)
+            lambda = L + (c1 - C) * m_ellipsoid.f() * sin_alpha *
+                (sigma + C * sin_sigma * ( cos2_sigma_m + C * cos_sigma * (-c1 + c2 * math::sqr(cos2_sigma_m)))); // (11)
+
+        } while (geometry::math::abs(previous_lambda - lambda) > c_e_12
+                && geometry::math::abs(lambda) < pi);
+
+        calculation_type sqr_u = cos2_alpha * (math::sqr(m_ellipsoid.a()) - math::sqr(m_ellipsoid.b())) / math::sqr(m_ellipsoid.b()); // above (1)
+
+        // Oops getting hard here
+        // (again, problem is that ttmath cannot divide by doubles, which is OK)
+        calculation_type const c47 = 47;
+        calculation_type const c74 = 74;
+        calculation_type const c128 = 128;
+        calculation_type const c256 = 256;
+        calculation_type const c175 = 175;
+        calculation_type const c320 = 320;
+        calculation_type const c768 = 768;
+        calculation_type const c1024 = 1024;
+        calculation_type const c4096 = 4096;
+        calculation_type const c16384 = 16384;
+
+        calculation_type A = c1 + sqr_u/c16384 * (c4096 + sqr_u * (-c768 + sqr_u * (c320 - c175 * sqr_u))); // (3)
+        calculation_type B = sqr_u/c1024 * (c256 + sqr_u * ( -c128 + sqr_u * (c74 - c47 * sqr_u))); // (4)
+        calculation_type delta_sigma = B * sin_sigma * ( cos2_sigma_m + (B/c4) * (cos(sigma)* (-c1 + c2 * cos2_sigma_m)
+                - (B/c6) * cos2_sigma_m * (-c3 + c4 * math::sqr(sin_sigma)) * (-c3 + c4 * cos2_sigma_m))); // (6)
+
+        return m_ellipsoid.b() * A * (sigma - delta_sigma); // (19)
+    }
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename Point1, typename Point2>
+struct tag<strategy::distance::vincenty<Point1, Point2> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+template <typename Point1, typename Point2>
+struct return_type<strategy::distance::vincenty<Point1, Point2> >
+{
+    typedef typename strategy::distance::vincenty<Point1, Point2>::calculation_type type;
+};
+
+
+template <typename Point1, typename Point2, typename P1, typename P2>
+struct similar_type<vincenty<Point1, Point2>, P1, P2>
+{
+    typedef vincenty<P1, P2> type;
+};
+
+
+template <typename Point1, typename Point2, typename P1, typename P2>
+struct get_similar<vincenty<Point1, Point2>, P1, P2>
+{
+    static inline vincenty<P1, P2> apply(vincenty<Point1, Point2> const& input)
+    {
+        return vincenty<P1, P2>(input.ellipsoid());
+    }
+};
+
+template <typename Point1, typename Point2>
+struct comparable_type<vincenty<Point1, Point2> >
+{
+    typedef vincenty<Point1, Point2> type;
+};
+
+
+template <typename Point1, typename Point2>
+struct get_comparable<vincenty<Point1, Point2> >
+{
+    static inline vincenty<Point1, Point2> apply(vincenty<Point1, Point2> const& input)
+    {
+        return input;
+    }
+};
+
+template <typename Point1, typename Point2>
+struct result_from_distance<vincenty<Point1, Point2> >
+{
+    template <typename T>
+    static inline typename return_type<vincenty<Point1, Point2> >::type apply(vincenty<Point1, Point2> const& , T const& value)
+    {
+        return value;
+    }
+};
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+// We might add a vincenty-like strategy also for point-segment distance, but to calculate the projected point is not trivial
+
+
+
+}} // namespace strategy::distance
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP
diff --git a/src/boost/geometry/extensions/gis/io/shapelib/dbf_write_attribute.hpp b/src/boost/geometry/extensions/gis/io/shapelib/dbf_write_attribute.hpp
new file mode 100644
index 0000000..4ed21de
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/shapelib/dbf_write_attribute.hpp
@@ -0,0 +1,87 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_DBF_WRITE_ATTRIBUTE_HPP
+#define BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_DBF_WRITE_ATTRIBUTE_HPP
+
+
+
+
+// Should be somewhere in your include path
+#include "shapefil.h"
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace detail
+{
+
+// Called with promote so not all cases necessary
+template <typename T> struct DBFFieldType {};
+template <> struct DBFFieldType<int> { static ::DBFFieldType const value = FTInteger; };
+template <> struct DBFFieldType<double> { static ::DBFFieldType const value = FTDouble; };
+template <> struct DBFFieldType<std::string> { static ::DBFFieldType const value = FTString; };
+
+// Also called with promote
+template <typename T> struct DBFWriteAttribute
+{
+};
+
+template <> struct DBFWriteAttribute<int>
+{
+    template <typename T>
+    inline static void apply(DBFHandle dbf, int row_index, int field_index,
+                    T const& value)
+    {
+        DBFWriteIntegerAttribute(dbf, row_index, field_index, value);
+    }
+};
+
+template <> struct DBFWriteAttribute<double>
+{
+    template <typename T>
+    inline static void apply(DBFHandle dbf, int row_index, int field_index,
+                    T const& value)
+    {
+        DBFWriteDoubleAttribute(dbf, row_index, field_index, value);
+    }
+};
+
+template <> struct DBFWriteAttribute<std::string>
+{
+    inline static void apply(DBFHandle dbf, int row_index, int field_index,
+                    std::string const& value)
+    {
+        DBFWriteStringAttribute(dbf, row_index, field_index, value.c_str());
+    }
+};
+
+// Derive char* variants from std::string,
+// implicitly casting to a temporary std::string
+// (note that boost::remove_const does not remove const from "const char*")
+template <int N>
+struct DBFWriteAttribute<char[N]> : DBFWriteAttribute<std::string> {};
+
+template <int N>
+struct DBFWriteAttribute<const char[N]> : DBFWriteAttribute<std::string> {};
+
+template <>
+struct DBFWriteAttribute<const char*> : DBFWriteAttribute<std::string> {};
+
+template <>
+struct DBFWriteAttribute<char*> : DBFWriteAttribute<std::string> {};
+
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_DBF_WRITE_ATTRIBUTE_HPP
diff --git a/src/boost/geometry/extensions/gis/io/shapelib/shape_creator.hpp b/src/boost/geometry/extensions/gis/io/shapelib/shape_creator.hpp
new file mode 100644
index 0000000..eeabbc8
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/shapelib/shape_creator.hpp
@@ -0,0 +1,154 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHAPE_CREATOR_HPP
+#define BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHAPE_CREATOR_HPP
+
+#include <fstream>
+#include "shapefil.h"
+
+#include <boost/noncopyable.hpp>
+#include <boost/type_traits/promote.hpp>
+
+#include <boost/geometry/io/wkt/wkt.hpp>
+
+#include <boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp>
+#include <boost/geometry/extensions/gis/io/shapelib/shp_create_object_multi.hpp>
+#include <boost/geometry/extensions/gis/io/shapelib/dbf_write_attribute.hpp>
+
+namespace boost { namespace geometry
+{
+
+class shapelib_file_create_exception : public geometry::exception
+{
+public:
+
+    inline shapelib_file_create_exception(std::string const& filename)
+        : m_filename(filename)
+    {}
+
+    virtual char const* what() const throw()
+    {
+        return m_filename.c_str();
+    }
+private :
+    std::string m_filename;
+};
+
+namespace detail
+{
+
+template <typename Tag>
+struct SHPType
+{
+};
+
+template <> struct SHPType<point_tag> { static int const value = SHPT_POINT; };
+template <> struct SHPType<segment_tag> { static int const value = SHPT_ARC; };
+template <> struct SHPType<linestring_tag> { static int const value = SHPT_ARC; };
+template <> struct SHPType<polygon_tag> { static int const value = SHPT_POLYGON; };
+template <> struct SHPType<ring_tag> { static int const value = SHPT_POLYGON; };
+template <> struct SHPType<box_tag> { static int const value = SHPT_POLYGON; };
+
+template <> struct SHPType<multi_point_tag> { static int const value = SHPT_MULTIPOINT; };
+template <> struct SHPType<multi_linestring_tag> { static int const value = SHPT_ARC; };
+template <> struct SHPType<multi_polygon_tag> { static int const value = SHPT_POLYGON; };
+
+} // namespace detail
+
+template
+<
+    typename Geometry,
+    int ShapeType = detail::SHPType
+        <
+            typename geometry::tag<Geometry>::type
+        >::value
+>
+class shape_creator : public boost::noncopyable
+{
+public :
+    shape_creator(std::string const& name)
+    {
+        m_shp = ::SHPCreate((name + ".shp").c_str(), ShapeType);
+        m_dbf = ::DBFCreate((name + ".dbf").c_str());
+        m_prj_name = name + ".prj";
+
+        if (m_shp == NULL || m_dbf == NULL)
+        {
+            throw shapelib_file_create_exception(name);
+        }
+    }
+
+    virtual ~shape_creator()
+    {
+        if (m_shp) ::SHPClose(m_shp);
+        if (m_dbf) ::DBFClose(m_dbf);
+    }
+
+    // Returns: index in shapefile
+    inline int AddShape(Geometry const& geometry)
+    {
+        // Note: we MIGHT design a small wrapper class which destroys in destructor
+        ::SHPObject* obj = SHPCreateObject(geometry);
+        int result = SHPWriteObject(m_shp, -1, obj );
+        ::SHPDestroyObject( obj );
+        return result;
+    }
+
+    template <typename T>
+    inline void AddField(std::string const& name, int width = 16, int decimals = 0)
+    {
+        ::DBFAddField(m_dbf, name.c_str(),
+            detail::DBFFieldType
+                <
+                    typename boost::promote<T>::type
+                >::value,
+            width, decimals);
+    }
+
+    template <typename T>
+    inline void WriteField(int row_index, int field_index, T const& value)
+    {
+        detail::DBFWriteAttribute
+            <
+                typename boost::promote<T>::type
+            >::apply(m_dbf, row_index, field_index, value);
+    }
+
+    inline void SetSrid(int srid)
+    {
+        if (srid == 28992)
+        {
+            std::ofstream out(m_prj_name.c_str());
+            out << "PROJCS[\"RD_New\""
+                << ",GEOGCS[\"GCS_Amersfoort\""
+                << ",DATUM[\"D_Amersfoort\""
+                << ",SPHEROID[\"Bessel_1841\",6377397.155,299.1528128]]"
+                << ",PRIMEM[\"Greenwich\",0]"
+                << ",UNIT[\"Degree\",0.0174532925199432955]]"
+                << ",PROJECTION[\"Double_Stereographic\"]"
+                << ",PARAMETER[\"False_Easting\",155000]"
+                << ",PARAMETER[\"False_Northing\",463000]"
+                << ",PARAMETER[\"Central_Meridian\",5.38763888888889]"
+                << ",PARAMETER[\"Scale_Factor\",0.9999079]"
+                << ",PARAMETER[\"Latitude_Of_Origin\",52.15616055555555]"
+                << ",UNIT[\"Meter\",1]]"
+                << std::endl;
+        }
+    }
+
+private :
+    ::SHPHandle m_shp;
+    ::DBFHandle m_dbf;
+    std::string m_prj_name;
+
+};
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHAPE_CREATOR_HPP
diff --git a/src/boost/geometry/extensions/gis/io/shapelib/shape_reader.hpp b/src/boost/geometry/extensions/gis/io/shapelib/shape_reader.hpp
new file mode 100644
index 0000000..4c1ca7b
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/shapelib/shape_reader.hpp
@@ -0,0 +1,72 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHAPE_READER_HPP
+#define BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHAPE_READER_HPP
+
+#include <fstream>
+#include "shapefil.h"
+
+
+#include <boost/noncopyable.hpp>
+#include <boost/type_traits/promote.hpp>
+
+#include <boost/geometry/extensions/gis/io/shapelib/shp_read_object.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+namespace detail
+{
+
+
+template<typename Geometry>
+class shape_reader : public boost::noncopyable
+{
+public :
+    shape_reader(std::string const& name)
+    {
+        m_shp = ::SHPOpen((name + ".shp").c_str(), "rb");
+        m_dbf = ::DBFOpen((name + ".dbf").c_str(), "rb");
+
+        if (m_shp == NULL || m_dbf == NULL)
+        {
+            throw shapelib_file_open_exception(name);
+        }
+
+        double adfMinBound[4], adfMaxBound[4];
+        SHPGetInfo(m_shp, &m_count, &m_shape_type, adfMinBound, adfMaxBound );
+
+    }
+    virtual ~shape_reader()
+    {
+        if (m_shp) ::SHPClose(m_shp);
+        if (m_dbf) ::DBFClose(m_dbf);
+    }
+
+    inline int count() const { return m_count; }
+
+
+
+
+private :
+    ::SHPHandle m_shp;
+    ::DBFHandle m_dbf;
+    int m_count;
+    int m_shape_type;
+
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHAPE_READER_HPP
diff --git a/src/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp b/src/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp
new file mode 100644
index 0000000..2e88de0
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp
@@ -0,0 +1,227 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_CREATE_OBJECT_HPP
+#define BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_CREATE_OBJECT_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/scoped_array.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/algorithms/num_interior_rings.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/views/box_view.hpp>
+#include <boost/geometry/views/segment_view.hpp>
+
+
+// Should be somewhere in your include path
+#include "shapefil.h"
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace shp_create_object
+{
+
+template <typename Point>
+struct shape_create_point
+{
+
+    static inline SHPObject* apply(Point const& point)
+    {
+        double x = get<0>(point);
+        double y = get<1>(point);
+
+        int const parts = 0;
+
+        return ::SHPCreateObject(SHPT_POINT, -1, 1, &parts, NULL,
+                                    1, &x, &y, NULL, NULL);
+    }
+};
+
+
+template <typename Range>
+static inline int range_to_part(Range const& range, double* x, double* y, int offset = 0)
+{
+    x += offset;
+    y += offset;
+
+    for (typename boost::range_iterator<Range const>::type
+        it = boost::begin(range);
+        it != boost::end(range);
+        ++it, ++x, ++y)
+    {
+        *x = get<0>(*it);
+        *y = get<1>(*it);
+        offset++;
+    }
+    return offset;
+}
+
+
+template <typename Range, int ShapeType>
+struct shape_create_range
+{
+    static inline SHPObject* apply(Range const& range)
+    {
+        int const n = boost::size(range);
+
+        boost::scoped_array<double> x(new double[n]);
+        boost::scoped_array<double> y(new double[n]);
+
+        range_to_part(range, x.get(), y.get());
+
+        int const parts = 0;
+
+        return ::SHPCreateObject(ShapeType, -1, 1, &parts, NULL,
+                                    n, x.get(), y.get(), NULL, NULL);
+    }
+};
+
+
+template <typename Polygon>
+struct shape_create_polygon
+{
+    static inline void process_polygon(Polygon const& polygon,
+            double* xp, double* yp, int* parts,
+            int& offset, int& ring)
+    {
+        parts[ring++] = offset;
+        offset = range_to_part(geometry::exterior_ring(polygon), xp, yp, offset);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(polygon);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            parts[ring++] = offset;
+            offset = range_to_part(*it, xp, yp, offset);
+        }
+    }
+
+    static inline SHPObject* apply(Polygon const& polygon)
+    {
+        int const n = geometry::num_points(polygon);
+        int const ring_count = 1 + geometry::num_interior_rings(polygon);
+
+        boost::scoped_array<double> x(new double[n]);
+        boost::scoped_array<double> y(new double[n]);
+        boost::scoped_array<int> parts(new int[ring_count]);
+
+        int ring = 0;
+        int offset = 0;
+
+        process_polygon(polygon, x.get(), y.get(), parts.get(), offset, ring);
+
+        return ::SHPCreateObject(SHPT_POLYGON, -1, ring_count, parts.get(), NULL,
+                                    n, x.get(), y.get(), NULL, NULL);
+    }
+};
+
+template <typename Geometry, typename AdaptedRange, int ShapeType>
+struct shape_create_adapted_range
+{
+    static inline SHPObject* apply(Geometry const& geometry)
+    {
+        return shape_create_range<AdaptedRange, ShapeType>::apply(AdaptedRange(geometry));
+    }
+};
+
+
+
+}} // namespace detail::shp_create_object
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Tag, typename Geometry>
+struct shp_create_object
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (Geometry)
+        );
+};
+
+
+template <typename Point>
+struct shp_create_object<point_tag, Point>
+    : detail::shp_create_object::shape_create_point<Point>
+{};
+
+
+template <typename LineString>
+struct shp_create_object<linestring_tag, LineString>
+    : detail::shp_create_object::shape_create_range<LineString, SHPT_ARC>
+{};
+
+
+template <typename Ring>
+struct shp_create_object<ring_tag, Ring>
+    : detail::shp_create_object::shape_create_range<Ring, SHPT_POLYGON>
+{};
+
+
+template <typename Polygon>
+struct shp_create_object<polygon_tag, Polygon>
+    : detail::shp_create_object::shape_create_polygon<Polygon>
+{};
+
+template <typename Box>
+struct shp_create_object<box_tag, Box>
+    : detail::shp_create_object::shape_create_adapted_range
+        <
+            Box,
+            box_view<Box>,
+            SHPT_POLYGON
+        >
+{};
+
+template <typename Segment>
+struct shp_create_object<segment_tag, Segment>
+    : detail::shp_create_object::shape_create_adapted_range
+        <
+            Segment,
+            segment_view<Segment>,
+            SHPT_ARC
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+// Redirect shapelib's SHPCreateObject to this boost::geometry::SHPCreateObject.
+// The only difference is their parameters, one just accepts a geometry
+template <typename Geometry>
+inline SHPObject* SHPCreateObject(Geometry const& geometry)
+{
+    return dispatch::shp_create_object
+        <
+            typename tag<Geometry>::type, Geometry
+        >::apply(geometry);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_CREATE_OBJECT_HPP
diff --git a/src/boost/geometry/extensions/gis/io/shapelib/shp_create_object_multi.hpp b/src/boost/geometry/extensions/gis/io/shapelib/shp_create_object_multi.hpp
new file mode 100644
index 0000000..9dd911f
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/shapelib/shp_create_object_multi.hpp
@@ -0,0 +1,147 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_CREATE_OBJECT_MULTI_HPP
+#define BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_CREATE_OBJECT_MULTI_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/scoped_array.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+#include <boost/geometry/multi/algorithms/num_interior_rings.hpp>
+
+#include <boost/geometry/extensions/gis/io/shapelib/shp_create_object.hpp>
+
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace shp_create_object
+{
+
+
+template <typename MultiPoint>
+struct shape_create_multi_point
+{
+    static inline SHPObject* apply(MultiPoint const& multi)
+    {
+        int const n = boost::size(multi);
+        boost::scoped_array<double> x(new double[n]);
+        boost::scoped_array<double> y(new double[n]);
+
+        range_to_part(multi, x.get(), y.get());
+
+        int const parts = 0;
+        return ::SHPCreateObject(SHPT_MULTIPOINT, -1, 1, &parts, NULL,
+                                    n, x.get(), y.get(), NULL, NULL);
+    }
+};
+
+
+
+template <typename MultiLinestring>
+struct shape_create_multi_linestring
+{
+    static inline SHPObject* apply(MultiLinestring const& multi)
+    {
+        int const n = geometry::num_points(multi);
+        int const part_count = boost::size(multi);
+
+        boost::scoped_array<double> x(new double[n]);
+        boost::scoped_array<double> y(new double[n]);
+        boost::scoped_array<int> parts(new int[part_count]);
+
+        int ring = 0;
+        int offset = 0;
+
+        for (typename boost::range_iterator<MultiLinestring const>::type
+                    it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            parts[ring++] = offset;
+            offset = range_to_part(*it, x.get(), y.get(), offset);
+        }
+
+        return ::SHPCreateObject(SHPT_ARC, -1, part_count, parts.get(), NULL,
+                                    n, x.get(), y.get(), NULL, NULL);
+    }
+};
+
+
+template <typename MultiPolygon>
+struct shape_create_multi_polygon
+{
+    static inline SHPObject* apply(MultiPolygon const& multi)
+    {
+        int const n = geometry::num_points(multi);
+        int const ring_count = boost::size(multi) + geometry::num_interior_rings(multi);
+
+        boost::scoped_array<double> x(new double[n]);
+        boost::scoped_array<double> y(new double[n]);
+        boost::scoped_array<int> parts(new int[ring_count]);
+
+        int ring = 0;
+        int offset = 0;
+
+        typedef typename boost::range_value<MultiPolygon>::type polygon_type;
+        for (typename boost::range_iterator<MultiPolygon const>::type
+                    it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            shape_create_polygon<polygon_type>::process_polygon(*it, x.get(), y.get(), parts.get(),
+                offset, ring);
+        }
+
+        return ::SHPCreateObject(SHPT_POLYGON, -1, ring_count, parts.get(), NULL,
+                                    n, x.get(), y.get(), NULL, NULL);
+    }
+};
+
+
+}} // namespace detail::shp_create_object
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiPoint>
+struct shp_create_object<multi_point_tag, MultiPoint>
+    : detail::shp_create_object::shape_create_multi_point<MultiPoint>
+{};
+
+
+template <typename MultiLinestring>
+struct shp_create_object<multi_linestring_tag, MultiLinestring>
+    : detail::shp_create_object::shape_create_multi_linestring<MultiLinestring>
+{};
+
+
+template <typename MultiPolygon>
+struct shp_create_object<multi_polygon_tag, MultiPolygon>
+    : detail::shp_create_object::shape_create_multi_polygon<MultiPolygon>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_CREATE_OBJECT_MULTI_HPP
diff --git a/src/boost/geometry/extensions/gis/io/shapelib/shp_read_object.hpp b/src/boost/geometry/extensions/gis/io/shapelib/shp_read_object.hpp
new file mode 100644
index 0000000..73204a9
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/shapelib/shp_read_object.hpp
@@ -0,0 +1,225 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_READ_OBJECT_HPP
+#define BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_READ_OBJECT_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/scoped_array.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+
+
+// Should be somewhere in your include path
+#include "shapefil.h"
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace shp_read_object
+{
+
+
+template <typename Pair>
+struct sort_on_area_desc
+{
+    inline bool operator()(Pair const& left, Pair const& right)
+    {
+        return left.second > right.second;
+    }
+};
+
+
+
+template <typename LineString>
+struct read_linestring
+{
+    static inline SHPObject* apply(LineString const& linestring)
+    {
+        typedef typename geometry::point_type<Linestring>::type point_type;
+
+        if (shape.nSHPType == SHPT_ARCZ && shape.nParts == 1)
+        {
+            double* const x = shape.padfX;
+            double* const y = shape.padfY;
+
+            for (int i = 0; i < shape.nVertices; i++)
+            {
+                point_type point;
+                geometry::set<0>(point, x[i]);
+                geometry::set<1>(point, y[i]);
+
+                linestring.push_back(point);
+            }
+            return true;
+        }
+        return false;
+
+    }
+};
+
+
+template <typename Polygon>
+struct read_polygon
+{
+    static inline SHPObject* apply(Polygon const& polygon)
+    {
+        typedef typename geometry::point_type<Polygon>::type point_type;
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+
+        if (shape.nSHPType == SHPT_POLYGON)
+        {
+            //std::cout << shape.nParts << " " << shape.nVertices << std::endl;
+
+            double* const x = shape.padfX;
+            double* const y = shape.padfY;
+
+            typedef std::pair<ring_type, double> ring_plus_area;
+            std::vector<ring_plus_area> rings;
+            rings.resize(shape.nParts);
+
+            int v = 0;
+            for (int p = 0; p < shape.nParts; p++)
+            {
+                int const first = shape.panPartStart[p];
+                int const last = p + 1 < shape.nParts
+                    ? shape.panPartStart[p + 1]
+                    : shape.nVertices;
+
+                for (v = first; v < last; v++)
+                {
+                    point_type point;
+                    geometry::set<0>(point, x[v]);
+                    geometry::set<1>(point, y[v]);
+                    rings[p].first.push_back(point);
+                }
+                rings[p].second = geometry::math::abs(geometry::area(rings[p].first));
+            }
+
+            if (rings.size() > 1)
+            {
+                // Sort rings on area
+                std::sort(rings.begin(), rings.end(),
+                        sort_on_area_desc<ring_plus_area>());
+                // Largest area (either positive or negative) is outer ring
+                // Rest of the rings are holes
+                geometry::exterior_ring(polygon) = rings.front().first;
+                for (int i = 1; i < rings.size(); i++)
+                {
+                    geometry::interior_rings(polygon).push_back(rings[i].first);
+                    if (! geometry::within(rings[i].first.front(), geometry::exterior_ring(polygon))
+                        && ! geometry::within(rings[i].first.at(1), geometry::exterior_ring(polygon))
+                        )
+                    {
+    #if ! defined(NDEBUG)
+                        std::cout << "Error: inconsistent ring!" << std::endl;
+                        BOOST_FOREACH(ring_plus_area const& r, rings)
+                        {
+                            std::cout << geometry::area(r.first) << " "
+                                << geometry::wkt(r.first.front()) << " "
+                                << std::endl;
+                        }
+    #endif
+                    }
+                }
+            }
+            else if (rings.size() == 1)
+            {
+                geometry::exterior_ring(polygon) = rings.front().first;
+            }
+            return true;
+        }
+        return false;
+    }
+};
+
+
+
+}} // namespace detail::shp_read_object
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Tag, typename Geometry>
+struct shp_read_object
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (Geometry)
+        );
+};
+
+
+template <typename LineString>
+struct shp_read_object<linestring_tag, LineString>
+    : detail::shp_read_object::read_linestring<LineString>
+{};
+
+
+
+
+template <typename Polygon>
+struct shp_read_object<polygon_tag, Polygon>
+    : detail::shp_read_object::read_polygon<Polygon>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template <typename Geometry>
+inline void read_shapefile(std::string const& filename,
+                    std::vector<Geometry>& geometries)
+{
+
+    try
+    {
+        // create shape_reader
+
+        for (int i = 0; i < shape_reader.Count(); i++)
+        {
+            SHPObject* psShape = SHPReadObject(shp_handle, i);
+            Geometry geometry;
+            if (dispatch::shp_read_object<Geometry>(*psShape, geometry))
+            {
+                geometries.push_back(geometry);
+            }
+            SHPDestroyObject( psShape );
+        }
+
+    }
+    catch(std::string s)
+    {
+        throw s;
+    }
+    catch(...)
+    {
+        throw std::string("Other exception");
+    }
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXT_GIS_IO_SHAPELIB_SHP_READ_OBJECT_HPP
diff --git a/src/boost/geometry/extensions/gis/io/veshape/write_veshape.hpp b/src/boost/geometry/extensions/gis/io/veshape/write_veshape.hpp
new file mode 100644
index 0000000..4b4caff
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/veshape/write_veshape.hpp
@@ -0,0 +1,281 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_VESHAPE_WRITE_VESHAPE_HPP
+#define BOOST_GEOMETRY_IO_VESHAPE_WRITE_VESHAPE_HPP
+
+#include <ostream>
+#include <string>
+
+#include <boost/concept/assert.hpp>
+#include <boost/range.hpp>
+
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace veshape
+{
+
+
+// Define the coordinate streamer, specialized for either 2 or 3 dimensions.
+// Any other number of dimensions make no sense for VE, and we have to take care about
+// the order lat,long (--> y,x)
+template <typename P, std::size_t D>
+struct stream_coordinate {};
+
+
+template <typename P>
+struct stream_coordinate<P, 2>
+{
+    template <typename Char, typename Traits>
+    static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
+    {
+        os << geometry::get<1>(p) << "," << geometry::get<0>(p);
+    }
+};
+
+template <typename P>
+struct stream_coordinate<P, 3>
+{
+    template <typename Char, typename Traits>
+    static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
+    {
+        stream_coordinate<P, 2>::stream(os, p);
+        os << "," << geometry::get<2>(p);
+    }
+};
+
+
+template <typename P>
+struct stream_point
+{
+    template <typename Char, typename Traits>
+    static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
+    {
+        os << "new VELatLong(";
+        stream_coordinate<P, dimension<P>::value>::stream(os, p);
+        os << ")";
+    }
+};
+
+
+
+struct prefix_point
+{
+    static inline const char* prefix()
+    { return "new VEShape(VEShapeType.Pushpin, "; }
+
+    static inline const char* postfix()
+    { return ")"; }
+};
+
+struct prefix_linestring
+{
+    static inline const char* prefix()
+    { return "new VEShape(VEShapeType.Polyline, "; }
+
+    static inline const char* postfix()
+    { return ")"; }
+};
+
+
+struct prefix_polygon
+{
+    static inline const char* prefix()
+    { return "new VEShape(VEShapeType.Polygon, "; }
+
+    static inline const char* postfix()
+    { return ")"; }
+};
+
+/*!
+\brief Stream points as \ref VEShape
+*/
+template <typename P, typename Policy>
+struct veshape_point
+{
+    template <typename Char, typename Traits>
+    static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
+    {
+        os << Policy::prefix();
+        stream_point<P>::stream(os, p);
+        os << Policy::postfix();
+    }
+
+    private:
+        BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P>) );
+};
+
+/*!
+\brief Stream ranges as VEShape
+\note policy is used to stream prefix/postfix, enabling derived classes to override this
+*/
+template <typename R, typename Policy>
+struct veshape_range
+{
+    template <typename Char, typename Traits>
+    static inline void stream(std::basic_ostream<Char, Traits>& os, R const& range)
+    {
+        typedef typename boost::range_iterator<R const>::type iterator;
+
+        bool first = true;
+
+        os << Policy::prefix() << "new Array(";
+
+        for (iterator it = boost::begin(range); it != boost::end(range); ++it)
+        {
+            os << (first ? "" : ", ");
+            stream_point<point>::stream(os, *it);
+            first = false;
+        }
+
+        os << ")" << Policy::postfix();
+    }
+
+    private:
+        typedef typename boost::range_value<R>::type point;
+        BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point>) );
+};
+
+
+
+template <typename P, typename Policy>
+struct veshape_poly
+{
+    template <typename Char, typename Traits>
+    static inline void stream(std::basic_ostream<Char, Traits>& os, P const& poly)
+    {
+        typedef typename ring_type<P>::type ring;
+
+        veshape_range<ring, Policy>::stream(os, exterior_ring(poly));
+
+        // For VE shapes: inner rings are not supported or undocumented
+        /***
+        for (iterator it = boost::begin(interior_rings(poly));
+            it != boost::end(interior_rings(poly)); it++)
+        {
+            os << ",";
+            veshape_range<ring, null>::stream(os, *it);
+        }
+        os << ")";
+        ***/
+    }
+
+    private:
+        BOOST_CONCEPT_ASSERT( (concept::ConstPoint<typename point_type<P>::type>) );
+};
+
+
+
+}} // namespace detail::veshape
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+/*!
+\brief Dispatching base struct for VEShape streaming, specialized below per geometry type
+\details Specializations should implement a static method "stream" to stream a geometry
+The static method should have the signature:
+
+template <typename Char, typename Traits>
+static inline void stream(std::basic_ostream<Char, Traits>& os, G const& geometry)
+*/
+template <typename T, typename G>
+struct veshape
+{};
+
+
+template <typename P>
+struct veshape<point_tag, P>
+    : detail::veshape::veshape_point<P, detail::veshape::prefix_point>
+{};
+
+
+template <typename R>
+struct veshape<linestring_tag, R>
+    : detail::veshape::veshape_range<R, detail::veshape::prefix_linestring>
+{};
+
+
+template <typename R>
+struct veshape<ring_tag, R>
+    : detail::veshape::veshape_range<R, detail::veshape::prefix_polygon>
+{};
+
+
+template <typename P>
+struct veshape<polygon_tag, P>
+    : detail::veshape::veshape_poly<P, detail::veshape::prefix_polygon>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Generic geometry template manipulator class, takes corresponding output class from traits class
+\ingroup veshape
+\details Stream manipulator, streams geometry classes as Virtual Earth shape
+*/
+template <typename G>
+class veshape_manip
+{
+public:
+
+    inline veshape_manip(G const& g)
+        : m_geometry(g)
+    {}
+
+    template <typename Char, typename Traits>
+    inline friend std::basic_ostream<Char, Traits>& operator<<(
+                    std::basic_ostream<Char, Traits>& os, veshape_manip const& m)
+    {
+        dispatch::veshape<typename tag<G>::type, G>::stream(os, m.m_geometry);
+        os.flush();
+        return os;
+    }
+
+private:
+    G const& m_geometry;
+};
+
+/*!
+\brief Object generator to conveniently stream objects without including streamveshape
+\ingroup veshape
+\par Example:
+Small example showing how to use the veshape helper function
+\dontinclude doxygen_1.cpp
+\skip example_as_veshape_vector
+\line {
+\until }
+*/
+template <typename T>
+inline veshape_manip<T> veshape(T const& t)
+{
+    return veshape_manip<T>(t);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_VESHAPE_WRITE_VESHAPE_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkb/detail/endian.hpp b/src/boost/geometry/extensions/gis/io/wkb/detail/endian.hpp
new file mode 100644
index 0000000..dbf0602
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkb/detail/endian.hpp
@@ -0,0 +1,262 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// Load/Store values from/to stream of bytes across different endianness.
+
+// Original design of unrolled_byte_loops templates based on
+// endian utility library from Boost C++ Libraries,
+// source: boost/spirit/home/support/detail/integer/endian.hpp
+// Copyright Darin Adler 2000
+// Copyright Beman Dawes 2006, 2009
+// Distributed under the Boost Software License, Version 1.0.
+
+#ifndef BOOST_GEOMETRY_DETAIL_ENDIAN_HPP
+#define BOOST_GEOMETRY_DETAIL_ENDIAN_HPP
+
+#include <cassert>
+#include <climits>
+#include <cstring>
+#include <cstddef>
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/endian.hpp>
+#include <boost/type_traits/is_signed.hpp>
+
+#if CHAR_BIT != 8
+#error Platforms with CHAR_BIT != 8 are not supported
+#endif
+
+// TODO: mloskot - add static asserts to validate compile-time pre-conditions
+
+namespace boost { namespace geometry
+{
+
+namespace detail { namespace endian
+{
+
+// Endianness tag used to indicate load/store directoin
+
+struct big_endian_tag {};
+struct little_endian_tag {};
+
+#ifdef BOOST_BIG_ENDIAN
+typedef big_endian_tag native_endian_tag;
+#else
+typedef little_endian_tag native_endian_tag;
+#endif
+
+// Unrolled loops for loading and storing streams of bytes.
+
+template <typename T, std::size_t N, bool Sign = boost::is_signed<T>::value>
+struct unrolled_byte_loops
+{
+    typedef unrolled_byte_loops<T, N - 1, Sign> next;
+
+    template <typename Iterator>
+    static T load_forward(Iterator& bytes)
+    {
+        T const value = *bytes;
+        ++bytes;
+        return value | (next::load_forward(bytes) << 8);
+    }
+
+    template <typename Iterator>
+    static T load_backward(Iterator& bytes)
+    {
+        T const value = *(bytes - 1);
+        --bytes;
+        return value | (next::load_backward(bytes) << 8);
+    }
+
+    template <typename Iterator>
+    static void store_forward(Iterator& bytes, T value)
+    {
+        *bytes = static_cast<char>(value);
+        next::store_forward(++bytes, value >> 8);
+    }
+
+    template <typename Iterator>
+    static void store_backward(Iterator& bytes, T value)
+    {
+        *(bytes - 1) = static_cast<char>(value);
+        next::store_backward(--bytes, value >> 8);
+    }
+};
+
+template <typename T>
+struct unrolled_byte_loops<T, 1, false>
+{
+    template <typename Iterator>
+    static T load_forward(Iterator& bytes)
+    {
+        return *bytes;
+    }
+
+    template <typename Iterator>
+    static T load_backward(Iterator& bytes)
+    {
+        return *(bytes - 1);
+    }
+
+    template <typename Iterator>
+    static void store_forward(Iterator& bytes, T value)
+    {
+        // typename Iterator::value_type
+        *bytes = static_cast<char>(value);
+    }
+
+    template <typename Iterator>
+    static void store_backward(Iterator& bytes, T value)
+    {
+        *(bytes - 1) = static_cast<char>(value);
+    }
+};
+
+template <typename T>
+struct unrolled_byte_loops<T, 1, true>
+{
+    template <typename Iterator>
+    static T load_forward(Iterator& bytes)
+    {
+        return *reinterpret_cast<const signed char*>(&*bytes);
+    }
+
+    template <typename Iterator>
+    static T load_backward(Iterator& bytes)
+    {
+        return *reinterpret_cast<const signed char*>(&*(bytes - 1));
+    }
+
+    template <typename Iterator>
+    static void store_forward(Iterator& bytes, T value)
+    {
+        BOOST_STATIC_ASSERT((boost::is_signed<typename Iterator::value_type>::value));
+
+        *bytes = static_cast<typename Iterator::value_type>(value);
+    }
+
+    template <typename Iterator>
+    static void store_backward(Iterator& bytes, T value)
+    {
+        BOOST_STATIC_ASSERT((boost::is_signed<typename Iterator::value_type>::value));
+
+        *(bytes - 1) = static_cast<typename Iterator::value_type>(value);
+    }
+};
+
+// load/store operation dispatch
+// E, E - source and target endianness is the same
+// E1, E2 - source and target endianness is different (big-endian <-> little-endian)
+
+template <typename T, std::size_t N, typename Iterator, typename E>
+T load_dispatch(Iterator& bytes, E, E)
+{
+    return unrolled_byte_loops<T, N>::load_forward(bytes);
+}
+
+template <typename T, std::size_t N, typename Iterator, typename E1, typename E2>
+T load_dispatch(Iterator& bytes, E1, E2)
+{
+    std::advance(bytes, N);
+    return unrolled_byte_loops<T, N>::load_backward(bytes);
+}
+
+template <typename T, std::size_t N, typename Iterator, typename E>
+void store_dispatch(Iterator& bytes, T value, E, E)
+{
+    return unrolled_byte_loops<T, N>::store_forward(bytes, value);
+}
+
+template <typename T, std::size_t N, typename Iterator, typename E1, typename E2>
+void store_dispatch(Iterator& bytes, T value, E1, E2)
+{
+    std::advance(bytes, N);
+    return unrolled_byte_loops<T, N>::store_backward(bytes, value);
+}
+
+// numeric value holder for load/store operation
+
+template <typename T>
+struct endian_value_base
+{
+    typedef T value_type;
+    typedef native_endian_tag endian_type;
+
+    endian_value_base() : value(T()) {}
+    explicit endian_value_base(T value) : value(value) {}
+
+    operator T() const
+    {
+        return value;
+    }
+
+protected:
+    T value;
+};
+
+template <typename T, std::size_t N = sizeof(T)>
+struct endian_value : public endian_value_base<T>
+{
+    typedef endian_value_base<T> base;
+
+    endian_value() {}
+    explicit endian_value(T value) : base(value) {}
+
+    template <typename E, typename Iterator>
+    void load(Iterator bytes)
+    {
+        base::value = load_dispatch<T, N>(bytes, typename base::endian_type(), E());
+    }
+
+    template <typename E, typename Iterator>
+    void store(Iterator bytes)
+    {
+        store_dispatch<T, N>(bytes, base::value, typename base::endian_type(), E());
+    }
+};
+
+template <>
+struct endian_value<double, 8> : public endian_value_base<double>
+{
+    typedef endian_value_base<double> base;
+
+    endian_value() {}
+    explicit endian_value(double value) : base(value) {}
+
+    template <typename E, typename Iterator>
+    void load(Iterator bytes)
+    {
+        endian_value<boost::uint64_t, 8> raw;
+        raw.load<E>(bytes);
+
+        double& target_value = base::value;
+        std::memcpy(&target_value, &raw, sizeof(double));
+    }
+
+    template <typename E, typename Iterator>
+    void store(Iterator bytes)
+    {
+        boost::uint64_t raw;
+        double const& source_value = base::value;
+        std::memcpy(&raw, &source_value, sizeof(boost::uint64_t));
+
+        store_dispatch
+            <
+            boost::uint64_t,
+            sizeof(boost::uint64_t)
+            >(bytes, raw, typename base::endian_type(), E());
+    }
+};
+
+}} // namespace detail::endian
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_DETAIL_ENDIAN_HPP
+
diff --git a/src/boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp b/src/boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp
new file mode 100644
index 0000000..34cd533
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp
@@ -0,0 +1,86 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKB_DETAIL_OGC_HPP
+#define BOOST_GEOMETRY_IO_WKB_DETAIL_OGC_HPP
+
+#include <boost/cstdint.hpp>
+
+namespace boost { namespace geometry
+{
+
+// The well-known binary representation for OGC geometry (WKBGeometry),
+// provides a portable representation of a geometry value as a contiguous
+// stream of bytes. It permits geometry values to be exchanged between
+// a client application and an SQL database in binary form.
+//
+// Basic Type definitions
+// byte : 1 byte
+// uint32 : 32 bit unsigned integer (4 bytes)
+// double : double precision number (8 bytes)
+//
+// enum wkbByteOrder
+// {
+//   wkbXDR = 0, // Big Endian
+//   wkbNDR = 1  // Little Endian
+// };
+//
+// enum wkbGeometryType
+// {
+//   wkbPoint = 1,
+//   wkbLineString = 2,
+//   wkbPolygon = 3,
+//   wkbMultiPoint = 4,
+//   wkbMultiLineString = 5,
+//   wkbMultiPolygon = 6,
+//   wkbGeometryCollection = 7
+// };
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkb
+{
+
+// TODO: Replace 'struct' with scoped enum from <boost/detail/scoped_enum_emulation.hpp>
+// For older Boost, copy
+// <boost/spirit/home/support/detail/scoped_enum_emulation.hpp>
+// to
+// <boost/geometry/detail/scoped_enum_emulation.hpp>
+// and use it.
+
+struct byte_order_type
+{
+    enum enum_t
+    {
+        xdr     = 0, // wkbXDR, bit-endian
+        ndr     = 1, // wkbNDR, little-endian
+        unknown = 2  // not defined by OGC
+    };
+};
+
+struct geometry_type
+{
+    enum enum_t
+    {
+        point      = 1,
+        linestring = 2,
+        polygon    = 3
+
+        // TODO: Not implemented
+        //multipoint = 4,
+        //multilinestring = 5,
+        //multipolygon = 6,
+        //collection = 7
+    };
+};
+
+}} // namespace detail::endian
+#endif // DOXYGEN_NO_IMPL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKB_DETAIL_OGC_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkb/detail/parser.hpp b/src/boost/geometry/extensions/gis/io/wkb/detail/parser.hpp
new file mode 100644
index 0000000..48e4d52
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkb/detail/parser.hpp
@@ -0,0 +1,315 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKB_DETAIL_PARSER_HPP
+#define BOOST_GEOMETRY_IO_WKB_DETAIL_PARSER_HPP
+
+#include <cassert>
+#include <cstddef>
+#include <algorithm>
+#include <iterator>
+#include <limits>
+
+#include <boost/concept_check.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/extensions/gis/io/wkb/detail/endian.hpp>
+#include <boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkb
+{
+
+template <typename T>
+struct value_parser
+{
+    typedef T value_type;
+
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, T& value, byte_order_type::enum_t order)
+    {
+        // Very basic pre-conditions check on stream of bytes passed in
+        BOOST_STATIC_ASSERT((
+            boost::is_integral<typename std::iterator_traits<Iterator>::value_type>::value
+        ));
+        BOOST_STATIC_ASSERT((sizeof(boost::uint8_t) ==
+            sizeof(typename std::iterator_traits<Iterator>::value_type)
+        ));
+
+        typedef typename std::iterator_traits<Iterator>::difference_type diff_type;
+        diff_type const required_size = sizeof(T);
+        if (it != end && std::distance(it, end) >= required_size)
+        {
+            typedef endian::endian_value<T> parsed_value_type;
+            parsed_value_type parsed_value;
+
+            // Decide on direcion of endianness translation, detault to native
+            if (byte_order_type::xdr == order)
+            {
+                parsed_value.template load<endian::big_endian_tag>(it);
+            }
+            else if (byte_order_type::ndr == order)
+            {
+                parsed_value.template load<endian::little_endian_tag>(it);
+            }
+            else
+            {
+                parsed_value.template load<endian::native_endian_tag>(it);
+            }
+
+            value = parsed_value;
+            std::advance(it, required_size);
+            return true;
+        }
+
+        return false;
+    }
+};
+
+struct byte_order_parser
+{
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, byte_order_type::enum_t& order)
+    {
+        boost::uint8_t value;
+        if (value_parser<boost::uint8_t>::parse(it, end, value, byte_order_type::unknown))
+        {
+            if (byte_order_type::unknown > value)
+            {
+                order = byte_order_type::enum_t(value);
+            }
+            return true;
+        }
+        return false;
+    }
+};
+
+struct geometry_type_parser
+{
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, geometry_type::enum_t& type,
+        byte_order_type::enum_t order)
+    {
+        boost::uint32_t value;
+        if (value_parser<boost::uint32_t>::parse(it, end, value, order))
+        {
+            // TODO: Refine the test when multi* geometries are supported
+
+            boost::uint32_t id = value & 0xff;
+            if (geometry_type::polygon >= id)
+            {
+                type = geometry_type::enum_t(id);
+                return true;
+            }
+        }
+        return false;
+    }
+};
+
+template <typename P, int I, int N>
+struct parsing_assigner
+{
+    template <typename Iterator>
+    static void run(Iterator& it, Iterator end, P& point, byte_order_type::enum_t order)
+    {
+        typedef typename coordinate_type<P>::type coordinate_type;
+
+        // coordinate type in WKB is always double
+        double value(0);
+        if (value_parser<double>::parse(it, end, value, order))
+        {
+            // actual coordinate type of point may be different
+            set<I>(point, static_cast<coordinate_type>(value));
+        }
+        else
+        {
+            // TODO: mloskot - Report premature termination at coordinate level
+            //throw failed to read coordinate value
+
+            // default initialized value as fallback
+            set<I>(point, coordinate_type());
+        }
+        parsing_assigner<P, I+1, N>::run(it, end, point, order);
+    }
+};
+
+template <typename P, int N>
+struct parsing_assigner<P, N, N>
+{
+    template <typename Iterator>
+    static void run(Iterator& it, Iterator end, P& point, byte_order_type::enum_t order)
+    {
+        // terminate
+        boost::ignore_unused_variable_warning(it);
+        boost::ignore_unused_variable_warning(end);
+        boost::ignore_unused_variable_warning(point);
+        boost::ignore_unused_variable_warning(order);
+    }
+};
+
+template <typename P>
+struct point_parser
+{
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, P& point, byte_order_type::enum_t order)
+    {
+        // TODO: mloskot - Add assert on point dimension, 2d only
+
+        geometry_type::enum_t type;
+        if (geometry_type_parser::parse(it, end, type, order))
+        {
+            if (geometry_type::point == type && it != end)
+            {
+                parsing_assigner<P, 0, dimension<P>::value>::run(it, end, point, order);
+            }
+            return true;
+        }
+        return false;
+    }
+};
+
+template <typename C>
+struct point_container_parser
+{
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, C& container, byte_order_type::enum_t order)
+    {
+        typedef typename point_type<C>::type point_type;
+
+        boost::uint32_t num_points(0);
+        if (!value_parser<boost::uint32_t>::parse(it, end, num_points, order))
+        {
+            return false;
+        }
+
+        typedef typename std::iterator_traits<Iterator>::difference_type size_type;
+        assert(num_points <= boost::uint32_t( (std::numeric_limits<size_type>::max)() ) );
+
+        size_type const container_size = static_cast<size_type>(num_points);
+        size_type const point_size = dimension<point_type>::value * sizeof(double);
+
+        if (std::distance(it, end) >= (container_size * point_size))
+        {
+            point_type point_buffer;
+            std::back_insert_iterator<C> output(std::back_inserter(container));
+
+            // Read coordinates into point and append point to line (ring)
+            size_type points_parsed = 0;
+            while (points_parsed < container_size && it != end)
+            {
+                parsing_assigner<point_type, 0, dimension<point_type>::value>::run(it, end, point_buffer, order);
+                output = point_buffer;
+                ++output;
+                ++points_parsed;
+            }
+
+            if (container_size != points_parsed)
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+};
+
+template <typename L>
+struct linestring_parser
+{
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, L& linestring, byte_order_type::enum_t order)
+    {
+        typedef typename point_type<L>::type point_type;
+
+        geometry_type::enum_t type;
+        if (!geometry_type_parser::parse(it, end, type, order))
+        {
+            return false;
+        }
+
+        if (geometry_type::linestring != type)
+        {
+            return false;
+        }
+
+        assert(it != end);
+        return point_container_parser<L>::parse(it, end, linestring, order);
+    }
+};
+
+template <typename Polygon>
+struct polygon_parser
+{
+    template <typename Iterator>
+    static bool parse(Iterator& it, Iterator end, Polygon& polygon, byte_order_type::enum_t order)
+    {
+        geometry_type::enum_t type;
+        if (!geometry_type_parser::parse(it, end, type, order))
+        {
+            return false;
+        }
+
+        boost::uint32_t num_rings(0);
+        if (geometry_type::polygon != type ||
+            !value_parser<boost::uint32_t>::parse(it, end, num_rings, order))
+        {
+            return false;
+        }
+
+        typedef typename ring_type<Polygon>::type ring_type;
+
+        std::size_t rings_parsed = 0;
+        while (rings_parsed < num_rings && it != end) //while (rings_parsed < num_rings && it != end)
+        {
+            if (0 == rings_parsed)
+            {
+                ring_type& ring0 = exterior_ring(polygon);
+                if (!point_container_parser<ring_type>::parse(it, end, ring0, order))
+                {
+                    return false;
+                }
+            }
+            else
+            {
+                interior_rings(polygon).resize(rings_parsed);
+                ring_type& ringN = interior_rings(polygon).back();
+                if (!point_container_parser<ring_type>::parse(it, end, ringN, order))
+                {
+                    return false;
+                }
+            }
+            ++rings_parsed;
+        }
+
+        if (num_rings != rings_parsed)
+        {
+            return false;
+        }
+
+        return true;
+    }
+};
+
+}} // namespace detail::wkb
+#endif // DOXYGEN_NO_IMPL
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_IO_WKB_DETAIL_PARSER_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkb/read_wkb.hpp b/src/boost/geometry/extensions/gis/io/wkb/read_wkb.hpp
new file mode 100644
index 0000000..69662b5
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkb/read_wkb.hpp
@@ -0,0 +1,108 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKB_READ_WKB_HPP
+#define BOOST_GEOMETRY_IO_WKB_READ_WKB_HPP
+
+#include <iterator>
+
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/extensions/gis/io/wkb/detail/parser.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename G>
+struct read_wkb {};
+
+template <typename G>
+struct read_wkb<point_tag, G>
+{
+    template <typename Iterator>
+    static inline bool parse(Iterator& it, Iterator end, G& geometry,
+        detail::wkb::byte_order_type::enum_t order)
+    {
+        return detail::wkb::point_parser<G>::parse(it, end, geometry, order);
+    }
+};
+
+template <typename G>
+struct read_wkb<linestring_tag, G>
+{
+    template <typename Iterator>
+    static inline bool parse(Iterator& it, Iterator end, G& geometry,
+        detail::wkb::byte_order_type::enum_t order)
+    {
+        geometry::clear(geometry);
+        return detail::wkb::linestring_parser<G>::parse(it, end, geometry, order);
+    }
+};
+
+template <typename G>
+struct read_wkb<polygon_tag, G>
+{
+    template <typename Iterator>
+    static inline bool parse(Iterator& it, Iterator end, G& geometry,
+        detail::wkb::byte_order_type::enum_t order)
+    {
+        geometry::clear(geometry);
+        return detail::wkb::polygon_parser<G>::parse(it, end, geometry, order);
+    }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template <typename Iterator, typename G>
+inline bool read_wkb(Iterator begin, Iterator end, G& geometry)
+{
+    // Stream of bytes can only be parsed using random access iterator.
+    BOOST_STATIC_ASSERT((
+        boost::is_convertible
+        <
+            typename std::iterator_traits<Iterator>::iterator_category,
+            const std::random_access_iterator_tag&
+        >::value));
+
+    detail::wkb::byte_order_type::enum_t byte_order;
+    if (detail::wkb::byte_order_parser::parse(begin, end, byte_order))
+    {
+        return dispatch::read_wkb
+            <
+            typename tag<G>::type,
+            G
+            >::parse(begin, end, geometry, byte_order);
+    }
+
+    return false;
+}
+
+template <typename ByteType, typename G>
+inline bool read_wkb(ByteType const* bytes, std::size_t length, G& geometry)
+{
+    BOOST_STATIC_ASSERT((boost::is_integral<ByteType>::value));
+    BOOST_STATIC_ASSERT((sizeof(boost::uint8_t) == sizeof(ByteType)));
+
+    ByteType const* begin = bytes;
+    ByteType const* const end = bytes + length;
+
+    return read_wkb(begin, end, geometry);
+}
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKB_READ_WKB_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkb/utility.hpp b/src/boost/geometry/extensions/gis/io/wkb/utility.hpp
new file mode 100644
index 0000000..fd5e1dc
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkb/utility.hpp
@@ -0,0 +1,92 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKB_UTILITY_HPP
+#define BOOST_GEOMETRY_IO_WKB_UTILITY_HPP
+
+#include <iomanip>
+#include <iterator>
+#include <sstream>
+#include <string>
+
+#include <boost/cstdint.hpp>
+
+namespace boost { namespace geometry
+{
+
+// TODO: Waiting for errors handling design, eventually return bool
+// may be replaced to throw exception.
+
+template <typename OutputIterator>
+bool hex2wkb(std::string const& hex, OutputIterator bytes)
+{
+    // Bytes can be only written to output iterator.
+    BOOST_STATIC_ASSERT((boost::is_convertible<
+        typename std::iterator_traits<OutputIterator>::iterator_category,
+        const std::output_iterator_tag&>::value));
+
+    std::string::size_type const byte_size = 2;
+    if (0 != hex.size() % byte_size)
+    {
+        return false;
+    }
+
+    std::string::size_type const size = hex.size() / byte_size;
+    for (std::string::size_type i = 0; i < size; ++i)
+    {
+        // TODO: This is confirmed performance killer - to be replaced with static char-to-byte map --mloskot
+        std::istringstream iss(hex.substr(i * byte_size, byte_size));
+        unsigned int byte(0);
+        if (!(iss >> std::hex >> byte))
+        {
+            return false;
+        }
+        *bytes = static_cast<boost::uint8_t>(byte);
+        ++bytes;
+    }
+
+    return true;
+}
+
+template <typename Iterator>
+bool wkb2hex(Iterator begin, Iterator end, std::string& hex)
+{
+    // Stream of bytes can only be passed using random access iterator.
+    BOOST_STATIC_ASSERT((boost::is_convertible<
+        typename std::iterator_traits<Iterator>::iterator_category,
+        const std::random_access_iterator_tag&>::value));
+
+    const char hexalpha[] = "0123456789ABCDEF";
+    char hexbyte[3] = { 0 };
+    std::ostringstream oss;
+
+    Iterator it = begin;
+    while (it != end)
+    {
+        boost::uint8_t byte = static_cast<boost::uint8_t>(*it);
+        hexbyte[0] = hexalpha[(byte >> 4) & 0xf];
+        hexbyte[1] = hexalpha[byte & 0xf];
+        hexbyte[2] = '\0';
+        oss << std::setw(2) << hexbyte;
+        ++it;
+    }
+
+    // TODO: Binary streams can be big.
+    // Does it make sense to request stream buffer of proper (large) size or
+    // use incremental appends within while-loop?
+    hex = oss.str();
+
+    // Poor-man validation, no performance penalty expected
+    // because begin/end always are random access iterators.
+    return hex.size() == (2 * std::distance(begin, end));
+}
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKB_UTILITY_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp b/src/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp
new file mode 100644
index 0000000..e3e58d7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp
@@ -0,0 +1,68 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_READ_WKT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_READ_WKT_HPP
+
+
+#if defined(BOOST_MSVC_FULL_VER)
+#pragma message ("WARNING: wkt is moved to boost/geometry/domains/gis/io/wkt, please update include file")
+#else
+#warning "wkt is moved to boost/geometry/domains/gis/io/wkt, please update include file"
+#endif
+
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief Parses OGC Well-Known Text (\ref WKT) and outputs using an output iterator
+\ingroup wkt
+\param wkt string containing \ref WKT
+\param out output iterator
+\note This function is deprecated!
+\note Because the output iterator doesn't always have the type value_type, it should be
+specified in the function call.
+\par Example:
+Small example showing how to use read_wkt with an output iterator
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_output_iterator
+\line {
+\until }
+*/
+template <typename Geometry, typename OutputIterator>
+inline void read_wkt(std::string const& wkt, OutputIterator out)
+{
+    geometry::concept::check<Geometry>();
+
+    typedef typename point_type<Geometry>::type point_type;
+
+    std::string const& tag =
+        geometry_id<Geometry>::value == 2 ? "linestring" : "polygon";
+
+    detail::wkt::tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+    detail::wkt::tokenizer::iterator it;
+    if (detail::wkt::initialize<point_type>(tokens, tag, wkt, it))
+    {
+        detail::wkt::container_inserter<point_type>::apply(it, tokens.end(), wkt, out);
+    }
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_READ_WKT_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkt/readme.txt b/src/boost/geometry/extensions/gis/io/wkt/readme.txt
new file mode 100644
index 0000000..2094d1a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkt/readme.txt
@@ -0,0 +1,15 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+Note, the wkt is moved to /boost/geometry/domains/gis/io/wkt
diff --git a/src/boost/geometry/extensions/gis/io/wkt/stream_wkt.hpp b/src/boost/geometry/extensions/gis/io/wkt/stream_wkt.hpp
new file mode 100644
index 0000000..7de5523
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkt/stream_wkt.hpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_STREAM_WKT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_STREAM_WKT_HPP
+
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+
+// This short file contains only one manipulator, streaming as WKT
+// Don't move contents to as_wkt, developers must be able to choose how to stream
+
+// Don't use namespace boost::geometry, to enable the library to stream custom geometries which
+// are living outside the namespace boost { namespace geometry
+
+//namespace boost { namespace geometry
+//{
+
+
+/*!
+\brief Streams a geometry as Well-Known Text
+\ingroup wkt
+*/
+template<typename Char, typename Traits, typename Geometry>
+inline std::basic_ostream<Char,Traits>& operator<<
+    (
+        std::basic_ostream<Char,Traits> &os,
+        Geometry const& geom
+    )
+{
+    os << boost::geometry::wkt(geom);
+    return os;
+}
+
+//}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_STREAM_WKT_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkt/wkt.hpp b/src/boost/geometry/extensions/gis/io/wkt/wkt.hpp
new file mode 100644
index 0000000..cb7c995
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkt/wkt.hpp
@@ -0,0 +1,32 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_WKT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_WKT_HPP
+
+
+#if defined(BOOST_MSVC_FULL_VER)
+#pragma message ("WARNING: wkt is moved to boost/geometry/domains/gis/io/wkt, please update include file")
+#else
+#warning "wkt is moved to boost/geometry/domains/gis/io/wkt, please update include file"
+#endif
+
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>
+#include <boost/geometry/domains/gis/io/wkt/write_wkt_multi.hpp>
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_WKT_HPP
diff --git a/src/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp b/src/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp
new file mode 100644
index 0000000..c1bfdb2
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/io/wkt/write_wkt.hpp
@@ -0,0 +1,44 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_WRITE_WKT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_WRITE_WKT_HPP
+
+
+#if defined(BOOST_MSVC_FULL_VER)
+#pragma message ("WARNING: wkt is moved to boost/geometry/domains/gis/io/wkt, please update include file")
+#else
+#warning "wkt is moved to boost/geometry/domains/gis/io/wkt, please update include file"
+#endif
+
+
+#include <boost/geometry/domains/gis/io/wkt/write_wkt.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+// Backward compatibility - NOTE THIS IS DEPRECATED
+template <typename Geometry>
+inline wkt_manipulator<Geometry> make_wkt(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    return wkt_manipulator<Geometry>(geometry);
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_IO_WKT_WRITE_WKT_HPP
diff --git a/src/boost/geometry/extensions/gis/latlong/detail/graticule.hpp b/src/boost/geometry/extensions/gis/latlong/detail/graticule.hpp
new file mode 100644
index 0000000..84f519e
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/latlong/detail/graticule.hpp
@@ -0,0 +1,238 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_DETAIL_GRATICULE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_DETAIL_GRATICULE_HPP
+
+#include <cmath>
+#include <sstream>
+#include <string>
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+    \brief Cardinal directions.
+    \ingroup cs
+    \details They are used in the dms-class. When specified by the library user,
+    north/east/south/west is, in general, enough. When parsed or received by an algorithm,
+    the user knows it it is lat/long but not more
+*/
+enum cd_selector
+{
+    /*cd_none, */
+    north,
+    east,
+    south,
+    west,
+    cd_lat,
+    cd_lon
+};
+
+/*!
+    \brief Utility class to assign poinst with degree,minute,second
+    \ingroup cs
+    \note Normally combined with latitude and longitude classes
+    \tparam CardinalDir selects if it is north/south/west/east
+    \tparam coordinate value, double/float
+    \par Example:
+    Example showing how to use the dms class
+    \dontinclude doxygen_1.cpp
+    \skip example_dms
+    \line {
+    \until }
+*/
+template <cd_selector CardinalDir, typename T = double>
+class dms
+{
+public:
+
+    /// Constructs with a value
+    inline explicit dms(T v)
+        : m_value(v)
+    {}
+
+    /// Constructs with a degree, minute, optional second
+    inline explicit dms(int d, int m, T s = 0.0)
+    {
+        double v = ((CardinalDir == west || CardinalDir == south) ? -1.0 : 1.0)
+                    * (double(d) + (m / 60.0) + (s / 3600.0));
+
+        m_value = boost::numeric_cast<T>(v);
+    }
+
+    // Prohibit automatic conversion to T
+    // because this would enable lon(dms<south>)
+    // inline operator T() const { return m_value; }
+
+    /// Explicit conversion to T (double/float)
+    inline const T& as_value() const
+    {
+        return m_value;
+    }
+
+    /// Get degrees as integer, minutes as integer, seconds as double.
+    inline void get_dms(int& d, int& m, double& s,
+                        bool& positive, char& cardinal) const
+    {
+        double value = m_value;
+
+        // Set to normal earth latlong coordinates
+        while (value < -180)
+        {
+            value += 360;
+        }
+        while (value > 180)
+        {
+            value -= 360;
+        }
+        // Make positive and indicate this
+        positive = value > 0;
+
+        // Todo: we might implement template/specializations here
+        // Todo: if it is "west" and "positive", make east? or keep minus sign then?
+
+        cardinal = ((CardinalDir == cd_lat && positive) ? 'N'
+            :  (CardinalDir == cd_lat && !positive) ? 'S'
+            :  (CardinalDir == cd_lon && positive) ? 'E'
+            :  (CardinalDir == cd_lon && !positive) ? 'W'
+            :  (CardinalDir == east) ? 'E'
+            :  (CardinalDir == west) ? 'W'
+            :  (CardinalDir == north) ? 'N'
+            :  (CardinalDir == south) ? 'S'
+            : ' ');
+
+        value = geometry::math::abs(value);
+
+        // Calculate the values
+        double fraction = 0;
+        double integer = 0;
+        fraction = std::modf(value, &integer);
+        d = int(integer);
+        s = 60.0 * std::modf(fraction * 60.0, &integer);
+        m = int(integer);
+    }
+
+    /// Get degrees, minutes, seconds as a string, separators can be specified optionally
+    inline std::string get_dms(std::string const& ds = " ",
+        const std::string& ms = "'",
+        const std::string& ss = "\"") const
+    {
+        double s = 0;
+        int d = 0;
+        int m = 0;
+        bool positive = false;
+        char cardinal = 0;
+        get_dms(d, m, s, positive, cardinal);
+        std::ostringstream out;
+        out << d << ds << m << ms << s << ss << " " << cardinal;
+
+        return out.str();
+    }
+
+private:
+
+    T m_value;
+};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+/*!
+    \brief internal base class for latitude and longitude classes
+    \details The latitude longitude classes define different types for lat and lon. This is convenient
+    to construct latlong class without ambiguity.
+    \note It is called graticule, after <em>"This latitude/longitude "webbing" is known as the common
+    graticule" (http://en.wikipedia.org/wiki/Geographic_coordinate_system)</em>
+    \tparam S latitude/longitude
+    \tparam T coordinate type, double float or int
+*/
+template <typename T>
+class graticule
+{
+public:
+
+    // TODO: Pass 'v' by const-ref
+    inline explicit graticule(T v) : m_v(v) {}
+    inline operator T() const { return m_v; }
+
+private:
+
+    T m_v;
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+/*!
+    \brief Utility class to assign points with latitude value (north/south)
+    \ingroup cs
+    \tparam T coordinate type, double / float
+    \note Often combined with dms class
+*/
+template <typename T = double>
+class latitude : public detail::graticule<T>
+{
+public:
+
+    /// Can be constructed with a value
+    inline explicit latitude(T v)
+        : detail::graticule<T>(v)
+    {}
+
+    /// Can be constructed with a NORTH dms-class
+    inline explicit latitude(dms<north,T> const& v)
+        : detail::graticule<T>(v.as_value())
+    {}
+
+    /// Can be constructed with a SOUTH dms-class
+    inline explicit latitude(dms<south,T> const& v)
+       : detail::graticule<T>(v.as_value())
+   {}
+};
+
+/*!
+\brief Utility class to assign points with longitude value (west/east)
+\ingroup cs
+\tparam T coordinate type, double / float
+\note Often combined with dms class
+*/
+template <typename T = double>
+class longitude : public detail::graticule<T>
+{
+public:
+
+    /// Can be constructed with a value
+    inline explicit longitude(T v)
+        : detail::graticule<T>(v)
+    {}
+
+    /// Can be constructed with a WEST dms-class
+    inline explicit longitude(dms<west, T> const& v)
+        : detail::graticule<T>(v.as_value())
+    {}
+
+    /// Can be constructed with an EAST dms-class
+    inline explicit longitude(dms<east, T> const& v)
+        : detail::graticule<T>(v.as_value())
+    {}
+};
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_DETAIL_GRATICULE_HPP
diff --git a/src/boost/geometry/extensions/gis/latlong/latlong.hpp b/src/boost/geometry/extensions/gis/latlong/latlong.hpp
new file mode 100644
index 0000000..4b354ca
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/latlong/latlong.hpp
@@ -0,0 +1,54 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_HPP
+
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/extensions/gis/latlong/point_ll.hpp>
+
+
+#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp>
+#include <boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp>
+#include <boost/geometry/extensions/gis/geographic/strategies/distance_cross_track.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*
+DEPRECATED
+namespace model
+{
+
+typedef point_ll<double, cs::geographic<degree> > point_ll_deg;
+typedef linestring<point_ll_deg> linestring_ll_deg;
+typedef linear_ring<point_ll_deg> ring_ll_deg;
+typedef polygon<point_ll_deg> polygon_ll_deg;
+typedef box<point_ll_deg> box_ll_deg;
+typedef segment<point_ll_deg> segment_ll_deg;
+
+typedef point_ll<double, cs::geographic<radian> > point_ll_rad;
+typedef linestring<point_ll_rad> linestring_ll_rad;
+typedef linear_ring<point_ll_rad> ring_ll_rad;
+typedef polygon<point_ll_rad> polygon_ll_rad;
+typedef box<point_ll_rad> box_ll_rad;
+typedef segment<point_ll_rad> segment_ll_rad;
+
+} // namespace model
+*/
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_HPP
diff --git a/src/boost/geometry/extensions/gis/latlong/point_ll.hpp b/src/boost/geometry/extensions/gis/latlong/point_ll.hpp
new file mode 100644
index 0000000..1740d1a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/latlong/point_ll.hpp
@@ -0,0 +1,269 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_POINT_LL_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_POINT_LL_HPP
+
+#include <cstddef>
+#include <sstream>
+#include <string>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/geometries/point.hpp>
+
+#include <boost/geometry/extensions/gis/latlong/detail/graticule.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+namespace model { namespace ll
+{
+
+/*!
+    \brief Point using spherical coordinates \a lat and \a lon, on Earth
+    \ingroup Geometry
+    \details The point_ll class implements a point with lat and lon functions.
+    It can be constructed using latitude and longitude classes. The latlong
+    class can be defined in degrees or in radians. There is a conversion method
+    from degree to radian, and from radian to degree.
+    \tparam Units units,defaults to degree
+    \tparam CoordinateType coordinate type, double (the default) or float
+        (it might be int as well)
+    \tparam CoordinateSystem coordinate system, should include NOT degree/radian
+        indication, should be e.g. cs::geographic or cs::spherical
+    \tparam Dimensions number of dimensions
+    \note There is NO constructor with two values to avoid
+        exchanging lat and long
+    \note Construction with latitude and longitude can be done in both orders,
+        so lat/long and long/lat
+    \par Example:
+    Example showing how the point_ll class can be constructed. Note that it
+        can also be constructed using
+    decimal degrees (43.123).
+    \dontinclude doxygen_1.cpp
+    \skip example_point_ll_construct
+    \line {
+    \until }
+*/
+template
+<
+    typename Units = degree,
+    typename CoordinateType = double,
+    template<typename> class CoordinateSystem = cs::geographic,
+    std::size_t Dimensions = 2
+>
+class point : public model::point
+                <
+                    CoordinateType,
+                    Dimensions,
+                    CoordinateSystem<Units>
+                >
+{
+    typedef model::point
+        <
+            CoordinateType,
+            Dimensions,
+            CoordinateSystem<Units>
+        >
+        base_type;
+public:
+
+    /// Default constructor, does not initialize anything
+    inline point() : base_type() {}
+
+    /// Constructor with longitude/latitude
+    inline point(longitude<CoordinateType> const& lo,
+                latitude<CoordinateType> const& la)
+        : base_type(lo, la) {}
+
+    /// Constructor with latitude/longitude
+    inline point(latitude<CoordinateType> const& la,
+                longitude<CoordinateType> const& lo)
+        : base_type(lo, la) {}
+
+    /// Get longitude
+    inline CoordinateType const& lon() const
+    { return this->template get<0>(); }
+
+    /// Get latitude
+    inline CoordinateType const& lat() const
+    { return this->template get<1>(); }
+
+    /// Set longitude
+    inline void lon(CoordinateType const& v)
+    { this->template set<0>(v); }
+
+    /// Set latitude
+    inline void lat(CoordinateType const& v)
+    { this->template set<1>(v); }
+
+    /// Set longitude using dms class
+    inline void lon(dms<east, CoordinateType> const& v)
+    {
+        this->template set<0>(v.as_value());
+    }
+    inline void lon(dms<west, CoordinateType> const& v)
+    {
+        this->template set<0>(v.as_value());
+    }
+
+    inline void lat(dms<north, CoordinateType> const& v)
+    {
+        this->template set<1>(v.as_value());
+    }
+    inline void lat(dms<south, CoordinateType> const& v)
+    {
+        this->template set<1>(v.as_value());
+    }
+};
+
+
+}} // namespace model::ll
+
+// Adapt the point_ll to the concept
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename Units,
+    typename CoordinateType,
+    template<typename> class CoordinateSystem,
+    std::size_t DimensionCount
+>
+struct tag
+        <
+            model::ll::point
+            <
+                Units,
+                CoordinateType,
+                CoordinateSystem,
+                DimensionCount
+            >
+        >
+{
+    typedef point_tag type;
+};
+
+template
+<
+    typename Units,
+    typename CoordinateType,
+    template<typename> class CoordinateSystem,
+    std::size_t DimensionCount
+>
+struct coordinate_type
+        <
+            model::ll::point
+            <
+                Units,
+                CoordinateType,
+                CoordinateSystem,
+                DimensionCount
+            >
+        >
+{
+    typedef CoordinateType type;
+};
+
+template
+<
+    typename Units,
+    typename CoordinateType,
+    template<typename> class CoordinateSystem,
+    std::size_t DimensionCount
+>
+struct coordinate_system
+        <
+            model::ll::point
+            <
+                Units,
+                CoordinateType,
+                CoordinateSystem,
+                DimensionCount
+            >
+        >
+{
+    typedef CoordinateSystem<Units> type;
+};
+
+template
+<
+    typename Units,
+    typename CoordinateType,
+    template<typename> class CoordinateSystem,
+    std::size_t DimensionCount
+>
+struct dimension
+        <
+            model::ll::point
+            <
+                Units,
+                CoordinateType,
+                CoordinateSystem,
+                DimensionCount
+            >
+        >
+    : boost::mpl::int_<DimensionCount>
+{};
+
+template
+<
+    typename Units,
+    typename CoordinateType,
+    template<typename> class CoordinateSystem,
+    std::size_t DimensionCount,
+    std::size_t Dimension
+>
+struct access
+        <
+            model::ll::point
+            <
+                Units,
+                CoordinateType,
+                CoordinateSystem,
+                DimensionCount
+            >,
+            Dimension
+        >
+{
+    typedef model::ll::point
+            <
+                Units,
+                CoordinateType,
+                CoordinateSystem,
+                DimensionCount
+            > type;
+
+    static inline CoordinateType get(type const& p)
+    {
+        return p.template get<Dimension>();
+    }
+
+    static inline void set(type& p, CoordinateType const& value)
+    {
+        p.template set<Dimension>(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_POINT_LL_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/epsg.hpp b/src/boost/geometry/extensions/gis/projections/epsg.hpp
new file mode 100644
index 0000000..46501b3
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/epsg.hpp
@@ -0,0 +1,3568 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_EPGS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_EPGS_HPP
+
+
+#include <boost/geometry/extensions/gis/projections/parameters.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_init.hpp>
+
+// This file is OPTIONAL
+// Only to be included if EPSG codes are necessary.
+// It is not included automatically
+
+namespace boost { namespace geometry { namespace projection
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+    inline std::string code_to_string(int code)
+    {
+        switch(code)
+        {
+
+            case 2000 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +units=m";
+            case 2001 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +units=m";
+            case 2002 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=725,685,536,0,0,0,0 +units=m";
+            case 2003 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=72,213.7,93,0,0,0,0 +units=m";
+            case 2004 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=174,359,365,0,0,0,0 +units=m";
+            case 2005 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +units=m";
+            case 2006 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=-149,128,296,0,0,0,0 +units=m";
+            case 2007 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=195.671,332.517,274.607,0,0,0,0 +units=m";
+            case 2008 : return "+proj=tmerc +lat_0=0 +lon_0=-55.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2009 : return "+proj=tmerc +lat_0=0 +lon_0=-58.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2010 : return "+proj=tmerc +lat_0=0 +lon_0=-61.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2011 : return "+proj=tmerc +lat_0=0 +lon_0=-64.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2012 : return "+proj=tmerc +lat_0=0 +lon_0=-67.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2013 : return "+proj=tmerc +lat_0=0 +lon_0=-70.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2014 : return "+proj=tmerc +lat_0=0 +lon_0=-73.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2015 : return "+proj=tmerc +lat_0=0 +lon_0=-76.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2016 : return "+proj=tmerc +lat_0=0 +lon_0=-79.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2017 : return "+proj=tmerc +lat_0=0 +lon_0=-73.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2018 : return "+proj=tmerc +lat_0=0 +lon_0=-76.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2019 : return "+proj=tmerc +lat_0=0 +lon_0=-79.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2020 : return "+proj=tmerc +lat_0=0 +lon_0=-82.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2021 : return "+proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2022 : return "+proj=tmerc +lat_0=0 +lon_0=-84 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2023 : return "+proj=tmerc +lat_0=0 +lon_0=-87 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2024 : return "+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2025 : return "+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2026 : return "+proj=tmerc +lat_0=0 +lon_0=-96 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +units=m";
+            case 2027 : return "+proj=utm +zone=15 +ellps=clrk66 +units=m";
+            case 2028 : return "+proj=utm +zone=16 +ellps=clrk66 +units=m";
+            case 2029 : return "+proj=utm +zone=17 +ellps=clrk66 +units=m";
+            case 2030 : return "+proj=utm +zone=18 +ellps=clrk66 +units=m";
+            case 2031 : return "+proj=utm +zone=17 +ellps=clrk66 +units=m";
+            case 2032 : return "+proj=utm +zone=18 +ellps=clrk66 +units=m";
+            case 2033 : return "+proj=utm +zone=19 +ellps=clrk66 +units=m";
+            case 2034 : return "+proj=utm +zone=20 +ellps=clrk66 +units=m";
+            case 2035 : return "+proj=utm +zone=21 +ellps=clrk66 +units=m";
+            case 2036 : return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=2500000 +y_0=7500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2037 : return "+proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2038 : return "+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2039 : return "+proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +towgs84=-48,55,52,0,0,0,0 +units=m";
+            case 2040 : return "+proj=utm +zone=30 +ellps=clrk80 +towgs84=-125,53,467,0,0,0,0 +units=m";
+            case 2041 : return "+proj=utm +zone=30 +ellps=clrk80 +towgs84=-124.76,53,466.79,0,0,0,0 +units=m";
+            case 2042 : return "+proj=utm +zone=29 +ellps=clrk80 +towgs84=-125,53,467,0,0,0,0 +units=m";
+            case 2043 : return "+proj=utm +zone=29 +ellps=clrk80 +towgs84=-124.76,53,466.79,0,0,0,0 +units=m";
+            case 2044 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=18500000 +y_0=0 +ellps=krass +towgs84=-17.51,-108.32,-62.39,0,0,0,0 +units=m";
+            case 2045 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=19500000 +y_0=0 +ellps=krass +towgs84=-17.51,-108.32,-62.39,0,0,0,0 +units=m";
+            case 2056 : return "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m";
+            case 2057 : return "+proj=omerc +lat_0=27.51882880555555 +lonc=52.60353916666667 +alpha=0.5716611944444444 +k=0.999895934 +x_0=658377.437 +y_0=3044969.194 +ellps=intl +towgs84=-133.63,-157.5,-158.62,0,0,0,0 +units=m";
+            case 2058 : return "+proj=utm +zone=38 +ellps=intl +units=m";
+            case 2059 : return "+proj=utm +zone=39 +ellps=intl +units=m";
+            case 2060 : return "+proj=utm +zone=40 +ellps=intl +units=m";
+            case 2061 : return "+proj=utm +zone=41 +ellps=intl +units=m";
+            case 2062 : return "+proj=lcc +lat_1=40 +lat_0=40 +lon_0=0 +k_0=0.9988085293 +x_0=600000 +y_0=600000 +a=6378298.3 +b=6356657.142669561 +pm=madrid +units=m";
+            case 2063 : return "+proj=utm +zone=28 +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0 +units=m";
+            case 2064 : return "+proj=utm +zone=29 +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0 +units=m";
+            case 2065 : return "+proj=krovak +lat_0=49.5 +lon_0=42.5 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 2066 : return "+proj=cass +lat_0=11.25217861111111 +lon_0=-60.68600888888889 +x_0=37718.66159325 +y_0=36209.91512952 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.201166195164";
+            case 2067 : return "+proj=utm +zone=20 +ellps=intl +units=m";
+            case 2068 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2069 : return "+proj=tmerc +lat_0=0 +lon_0=11 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2070 : return "+proj=tmerc +lat_0=0 +lon_0=13 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2071 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2072 : return "+proj=tmerc +lat_0=0 +lon_0=17 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2073 : return "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2074 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2075 : return "+proj=tmerc +lat_0=0 +lon_0=23 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2076 : return "+proj=tmerc +lat_0=0 +lon_0=25 +k=0.9999 +x_0=200000 +y_0=0 +ellps=intl +units=m";
+            case 2077 : return "+proj=utm +zone=32 +ellps=intl +units=m";
+            case 2078 : return "+proj=utm +zone=33 +ellps=intl +units=m";
+            case 2079 : return "+proj=utm +zone=34 +ellps=intl +units=m";
+            case 2080 : return "+proj=utm +zone=35 +ellps=intl +units=m";
+            case 2081 : return "+proj=tmerc +lat_0=-90 +lon_0=-69 +k=1 +x_0=2500000 +y_0=0 +ellps=intl +units=m";
+            case 2082 : return "+proj=tmerc +lat_0=-90 +lon_0=-69 +k=1 +x_0=2500000 +y_0=0 +ellps=intl +towgs84=27.5,14,186.4,0,0,0,0 +units=m";
+            case 2083 : return "+proj=tmerc +lat_0=-90 +lon_0=-69 +k=1 +x_0=2500000 +y_0=0 +ellps=intl +units=m";
+            case 2084 : return "+proj=utm +zone=19 +south +ellps=intl +units=m";
+            case 2085 : return "+proj=lcc +lat_1=22.35 +lat_0=22.35 +lon_0=-81 +k_0=0.99993602 +x_0=500000 +y_0=280296.016 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 2086 : return "+proj=lcc +lat_1=20.71666666666667 +lat_0=20.71666666666667 +lon_0=-76.83333333333333 +k_0=0.99994848 +x_0=500000 +y_0=229126.939 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 2087 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=0.9996 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2088 : return "+proj=tmerc +lat_0=0 +lon_0=11 +k=0.9996 +x_0=500000 +y_0=0 +a=6378249.2 +b=6356515 +units=m";
+            case 2089 : return "+proj=utm +zone=38 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2090 : return "+proj=utm +zone=39 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2091 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +towgs84=-76,-138,67,0,0,0,0 +units=m";
+            case 2092 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=9500000 +y_0=0 +ellps=krass +towgs84=-76,-138,67,0,0,0,0 +units=m";
+            case 2093 : return "+proj=tmerc +lat_0=0 +lon_0=106 +k=1 +x_0=500000 +y_0=0 +ellps=krass +towgs84=-17.51,-108.32,-62.39,0,0,0,0 +units=m";
+            case 2094 : return "+proj=tmerc +lat_0=0 +lon_0=106 +k=0.9996 +x_0=500000 +y_0=0 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 2095 : return "+proj=utm +zone=28 +ellps=intl +towgs84=-173,253,27,0,0,0,0 +units=m";
+            case 2096 : return "+proj=tmerc +lat_0=38 +lon_0=129 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m";
+            case 2097 : return "+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m";
+            case 2098 : return "+proj=tmerc +lat_0=38 +lon_0=125 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m";
+            case 2099 : return "+proj=cass +lat_0=25.38236111111111 +lon_0=50.76138888888889 +x_0=100000 +y_0=100000 +ellps=helmert +units=m";
+            case 2100 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=-199.87,74.79,246.62,0,0,0,0 +units=m";
+            case 2101 : return "+proj=lcc +lat_1=10.16666666666667 +lat_0=10.16666666666667 +lon_0=-71.60561777777777 +k_0=1 +x_0=0 +y_0=-52684.972 +ellps=intl +units=m";
+            case 2102 : return "+proj=lcc +lat_1=10.16666666666667 +lat_0=10.16666666666667 +lon_0=-71.60561777777777 +k_0=1 +x_0=200000 +y_0=147315.028 +ellps=intl +units=m";
+            case 2103 : return "+proj=lcc +lat_1=10.16666666666667 +lat_0=10.16666666666667 +lon_0=-71.60561777777777 +k_0=1 +x_0=500000 +y_0=447315.028 +ellps=intl +units=m";
+            case 2104 : return "+proj=lcc +lat_1=10.16666666666667 +lat_0=10.16666666666667 +lon_0=-71.60561777777777 +k_0=1 +x_0=-17044 +y_0=-23139.97 +ellps=intl +units=m";
+            case 2105 : return "+proj=tmerc +lat_0=-36.87972222222222 +lon_0=174.7641666666667 +k=0.9999 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2106 : return "+proj=tmerc +lat_0=-37.76111111111111 +lon_0=176.4661111111111 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2107 : return "+proj=tmerc +lat_0=-38.62444444444444 +lon_0=177.8855555555556 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2108 : return "+proj=tmerc +lat_0=-39.65083333333333 +lon_0=176.6736111111111 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2109 : return "+proj=tmerc +lat_0=-39.13555555555556 +lon_0=174.2277777777778 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2110 : return "+proj=tmerc +lat_0=-39.51222222222222 +lon_0=175.64 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2111 : return "+proj=tmerc +lat_0=-40.24194444444444 +lon_0=175.4880555555555 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2112 : return "+proj=tmerc +lat_0=-40.92527777777777 +lon_0=175.6472222222222 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2113 : return "+proj=tmerc +lat_0=-41.3011111111111 +lon_0=174.7763888888889 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2114 : return "+proj=tmerc +lat_0=-40.71472222222223 +lon_0=172.6719444444444 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2115 : return "+proj=tmerc +lat_0=-41.27444444444444 +lon_0=173.2991666666667 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2116 : return "+proj=tmerc +lat_0=-41.28972222222222 +lon_0=172.1088888888889 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2117 : return "+proj=tmerc +lat_0=-41.81055555555555 +lon_0=171.5811111111111 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2118 : return "+proj=tmerc +lat_0=-42.33361111111111 +lon_0=171.5497222222222 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2119 : return "+proj=tmerc +lat_0=-42.68888888888888 +lon_0=173.01 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2120 : return "+proj=tmerc +lat_0=-41.54444444444444 +lon_0=173.8019444444444 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2121 : return "+proj=tmerc +lat_0=-42.88611111111111 +lon_0=170.9797222222222 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2122 : return "+proj=tmerc +lat_0=-43.11 +lon_0=170.2608333333333 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2123 : return "+proj=tmerc +lat_0=-43.97777777777778 +lon_0=168.6061111111111 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2124 : return "+proj=tmerc +lat_0=-43.59055555555556 +lon_0=172.7269444444445 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2125 : return "+proj=tmerc +lat_0=-43.74861111111111 +lon_0=171.3605555555555 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2126 : return "+proj=tmerc +lat_0=-44.40194444444445 +lon_0=171.0572222222222 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2127 : return "+proj=tmerc +lat_0=-44.735 +lon_0=169.4675 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2128 : return "+proj=tmerc +lat_0=-45.13277777777778 +lon_0=168.3986111111111 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2129 : return "+proj=tmerc +lat_0=-45.56361111111111 +lon_0=167.7386111111111 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2130 : return "+proj=tmerc +lat_0=-45.81611111111111 +lon_0=170.6283333333333 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2131 : return "+proj=tmerc +lat_0=-45.86138888888889 +lon_0=170.2825 +k=0.99996 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2132 : return "+proj=tmerc +lat_0=-46.6 +lon_0=168.3427777777778 +k=1 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2133 : return "+proj=utm +zone=58 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2134 : return "+proj=utm +zone=59 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2135 : return "+proj=utm +zone=60 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2136 : return "+proj=tmerc +lat_0=4.666666666666667 +lon_0=-1 +k=0.99975 +x_0=274319.7391633579 +y_0=0 +a=6378300 +b=6356751.689189189 +towgs84=-199,32,322,0,0,0,0 +to_meter=0.3047997101815088";
+            case 2137 : return "+proj=tmerc +lat_0=0 +lon_0=-1 +k=0.9996 +x_0=500000 +y_0=0 +a=6378300 +b=6356751.689189189 +towgs84=-199,32,322,0,0,0,0 +units=m";
+            case 2138 : return "+proj=lcc +lat_1=60 +lat_2=46 +lat_0=44 +lon_0=-68.5 +x_0=0 +y_0=0 +ellps=clrk66 +units=m";
+            case 2139 : return "+proj=tmerc +lat_0=0 +lon_0=-55.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2140 : return "+proj=tmerc +lat_0=0 +lon_0=-58.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2141 : return "+proj=tmerc +lat_0=0 +lon_0=-61.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2142 : return "+proj=tmerc +lat_0=0 +lon_0=-64.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2143 : return "+proj=tmerc +lat_0=0 +lon_0=-67.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2144 : return "+proj=tmerc +lat_0=0 +lon_0=-70.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2145 : return "+proj=tmerc +lat_0=0 +lon_0=-73.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2146 : return "+proj=tmerc +lat_0=0 +lon_0=-76.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2147 : return "+proj=tmerc +lat_0=0 +lon_0=-79.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2148 : return "+proj=utm +zone=21 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2149 : return "+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2150 : return "+proj=utm +zone=17 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2151 : return "+proj=utm +zone=13 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2152 : return "+proj=utm +zone=12 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2153 : return "+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2154 : return "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2155 : return "+proj=lcc +lat_1=-14.26666666666667 +lat_0=-14.26666666666667 +lon_0=170 +k_0=1 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +towgs84=-115,118,426,0,0,0,0 +to_meter=0.3048006096012192";
+            case 2156 : return "+proj=utm +zone=59 +south +ellps=GRS80 +units=m";
+            case 2157 : return "+proj=tmerc +lat_0=53.5 +lon_0=-8 +k=0.99982 +x_0=600000 +y_0=750000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2158 : return "+proj=utm +zone=29 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2159 : return "+proj=tmerc +lat_0=6.666666666666667 +lon_0=-12 +k=1 +x_0=152399.8550907544 +y_0=0 +a=6378300 +b=6356751.689189189 +to_meter=0.3047997101815088";
+            case 2160 : return "+proj=tmerc +lat_0=6.666666666666667 +lon_0=-12 +k=1 +x_0=243839.7681452071 +y_0=182879.8261089053 +a=6378300 +b=6356751.689189189 +to_meter=0.3047997101815088";
+            case 2161 : return "+proj=utm +zone=28 +ellps=clrk80 +towgs84=-88,4,101,0,0,0,0 +units=m";
+            case 2162 : return "+proj=utm +zone=29 +ellps=clrk80 +towgs84=-88,4,101,0,0,0,0 +units=m";
+            case 2163 : return "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m";
+            case 2164 : return "+proj=tmerc +lat_0=0 +lon_0=-5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=clrk80 +towgs84=-125,53,467,0,0,0,0 +units=m";
+            case 2165 : return "+proj=tmerc +lat_0=0 +lon_0=-5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=clrk80 +towgs84=-124.76,53,466.79,0,0,0,0 +units=m";
+            case 2166 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m";
+            case 2167 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m";
+            case 2168 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m";
+            case 2169 : return "+proj=tmerc +lat_0=49.83333333333334 +lon_0=6.166666666666667 +k=1 +x_0=80000 +y_0=100000 +ellps=intl +towgs84=-193,13.7,-39.3,-0.41,-2.933,2.688,0.43 +units=m";
+            case 2170 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9999 +x_0=500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 2171 : return "+proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5647000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 2172 : return "+proj=sterea +lat_0=53.00194444444445 +lon_0=21.50277777777778 +k=0.9998 +x_0=4603000 +y_0=5806000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 2173 : return "+proj=sterea +lat_0=53.58333333333334 +lon_0=17.00833333333333 +k=0.9998 +x_0=3501000 +y_0=5999000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 2174 : return "+proj=sterea +lat_0=51.67083333333333 +lon_0=16.67222222222222 +k=0.9998 +x_0=3703000 +y_0=5627000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 2175 : return "+proj=tmerc +lat_0=0 +lon_0=18.95833333333333 +k=0.999983 +x_0=237000 +y_0=-4700000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 2176 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.999923 +x_0=5500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2177 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=0.999923 +x_0=6500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2178 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=0.999923 +x_0=7500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2179 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.999923 +x_0=8500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2180 : return "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m";
+            case 2188 : return "+proj=utm +zone=25 +ellps=intl +units=m";
+            case 2189 : return "+proj=utm +zone=26 +ellps=intl +towgs84=-104,167,-38,0,0,0,0 +units=m";
+            case 2190 : return "+proj=utm +zone=26 +ellps=intl +towgs84=-203,141,53,0,0,0,0 +units=m";
+            case 2191 : return "+proj=utm +zone=28 +ellps=intl +units=m";
+            case 2192 : return "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=2.337229166666667 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +ellps=intl +units=m";
+            case 2193 : return "+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2194 : return "+proj=lcc +lat_1=-14.26666666666667 +lat_0=-14.26666666666667 +lon_0=-170 +k_0=1 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +towgs84=-115,118,426,0,0,0,0 +to_meter=0.3048006096012192";
+            case 2195 : return "+proj=utm +zone=2 +south +ellps=GRS80 +units=m";
+            case 2196 : return "+proj=tmerc +lat_0=0 +lon_0=9.5 +k=0.99995 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2197 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=0.99995 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2198 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=900000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2199 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m";
+            case 2200 : return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=300000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2201 : return "+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2202 : return "+proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2203 : return "+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2204 : return "+proj=lcc +lat_1=35.25 +lat_2=36.41666666666666 +lat_0=34.66666666666666 +lon_0=-86 +x_0=609601.2192024384 +y_0=30480.06096012192 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 2205 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 2206 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=9500000 +y_0=0 +ellps=intl +units=m";
+            case 2207 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=10500000 +y_0=0 +ellps=intl +units=m";
+            case 2208 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=11500000 +y_0=0 +ellps=intl +units=m";
+            case 2209 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=1 +x_0=12500000 +y_0=0 +ellps=intl +units=m";
+            case 2210 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=13500000 +y_0=0 +ellps=intl +units=m";
+            case 2211 : return "+proj=tmerc +lat_0=0 +lon_0=42 +k=1 +x_0=14500000 +y_0=0 +ellps=intl +units=m";
+            case 2212 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=15500000 +y_0=0 +ellps=intl +units=m";
+            case 2213 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2214 : return "+proj=tmerc +lat_0=0 +lon_0=10.5 +k=0.999 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=-206.1,-174.7,-87.7,0,0,0,0 +units=m";
+            case 2215 : return "+proj=utm +zone=32 +a=6378249.2 +b=6356515 +towgs84=-70.9,-151.8,-41.4,0,0,0,0 +units=m";
+            case 2216 : return "+proj=utm +zone=22 +ellps=intl +units=m";
+            case 2217 : return "+proj=utm +zone=23 +ellps=intl +units=m";
+            case 2219 : return "+proj=utm +zone=19 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2220 : return "+proj=utm +zone=20 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2222 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2223 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2224 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=213360 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2225 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2226 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2227 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2228 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2229 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2230 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2231 : return "+proj=lcc +lat_1=40.78333333333333 +lat_2=39.71666666666667 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2232 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2233 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2234 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=304800.6096012192 +y_0=152400.3048006096 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2235 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2236 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2237 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2238 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2239 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2240 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=699999.9998983998 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2241 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2242 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2243 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=800000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2244 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=99999.99989839978 +y_0=249364.9987299975 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2245 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=249364.9987299975 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2246 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2247 : return "+proj=lcc +lat_1=37.93333333333333 +lat_2=36.73333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=500000.0001016001 +y_0=500000.0001016001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2248 : return "+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=399999.9998983998 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2249 : return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000.0001016002 +y_0=750000 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2250 : return "+proj=lcc +lat_1=41.48333333333333 +lat_2=41.28333333333333 +lat_0=41 +lon_0=-70.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2251 : return "+proj=lcc +lat_1=47.08333333333334 +lat_2=45.48333333333333 +lat_0=44.78333333333333 +lon_0=-87 +x_0=7999999.999968001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2252 : return "+proj=lcc +lat_1=45.7 +lat_2=44.18333333333333 +lat_0=43.31666666666667 +lon_0=-84.36666666666666 +x_0=5999999.999976001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2253 : return "+proj=lcc +lat_1=43.66666666666666 +lat_2=42.1 +lat_0=41.5 +lon_0=-84.36666666666666 +x_0=3999999.999984 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2254 : return "+proj=tmerc +lat_0=29.5 +lon_0=-88.83333333333333 +k=0.99995 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2255 : return "+proj=tmerc +lat_0=29.5 +lon_0=-90.33333333333333 +k=0.99995 +x_0=699999.9998983998 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2256 : return "+proj=lcc +lat_1=49 +lat_2=45 +lat_0=44.25 +lon_0=-109.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2257 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=165000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2258 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2259 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=830000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2260 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2261 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=249999.9998983998 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2262 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2263 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2264 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.2192024384 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2265 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.43333333333333 +lat_0=47 +lon_0=-100.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2266 : return "+proj=lcc +lat_1=47.48333333333333 +lat_2=46.18333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2267 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=35.56666666666667 +lat_0=35 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2268 : return "+proj=lcc +lat_1=35.23333333333333 +lat_2=33.93333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2269 : return "+proj=lcc +lat_1=46 +lat_2=44.33333333333334 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000.0001424 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2270 : return "+proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000.0001464 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2271 : return "+proj=lcc +lat_1=41.95 +lat_2=40.88333333333333 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2272 : return "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2273 : return "+proj=lcc +lat_1=34.83333333333334 +lat_2=32.5 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609600 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2274 : return "+proj=lcc +lat_1=36.41666666666666 +lat_2=35.25 +lat_0=34.33333333333334 +lon_0=-86 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2275 : return "+proj=lcc +lat_1=36.18333333333333 +lat_2=34.65 +lat_0=34 +lon_0=-101.5 +x_0=200000.0001016002 +y_0=999999.9998983998 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2276 : return "+proj=lcc +lat_1=33.96666666666667 +lat_2=32.13333333333333 +lat_0=31.66666666666667 +lon_0=-98.5 +x_0=600000 +y_0=2000000.0001016 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2277 : return "+proj=lcc +lat_1=31.88333333333333 +lat_2=30.11666666666667 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=699999.9998983998 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2278 : return "+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=3999999.9998984 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2279 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=300000.0000000001 +y_0=5000000.0001016 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2280 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000.0001504 +y_0=999999.9999960001 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2281 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000.0001504 +y_0=1999999.999992 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2282 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000.0001504 +y_0=2999999.999988 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2283 : return "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=2000000.0001016 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2284 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=999999.9998983998 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2285 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2286 : return "+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2287 : return "+proj=lcc +lat_1=46.76666666666667 +lat_2=45.56666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2288 : return "+proj=lcc +lat_1=45.5 +lat_2=44.25 +lat_0=43.83333333333334 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2289 : return "+proj=lcc +lat_1=44.06666666666667 +lat_2=42.73333333333333 +lat_0=42 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2290 : return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=700000 +y_0=400000 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2291 : return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2292 : return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2294 : return "+proj=tmerc +lat_0=0 +lon_0=-61.5 +k=0.9999 +x_0=4500000 +y_0=0 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2295 : return "+proj=tmerc +lat_0=0 +lon_0=-64.5 +k=0.9999 +x_0=5500000 +y_0=0 +a=6378135 +b=6356750.304921594 +units=m";
+            case 2308 : return "+proj=tmerc +lat_0=0 +lon_0=109 +k=0.9996 +x_0=500000 +y_0=10000000 +ellps=bessel +units=m";
+            case 2309 : return "+proj=tmerc +lat_0=0 +lon_0=116 +k=0.9996 +x_0=500000 +y_0=10000000 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 2310 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=0.9996 +x_0=500000 +y_0=10000000 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 2311 : return "+proj=tmerc +lat_0=0 +lon_0=6 +k=0.9996 +x_0=500000 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 2312 : return "+proj=utm +zone=33 +ellps=clrk80 +units=m";
+            case 2313 : return "+proj=utm +zone=33 +ellps=clrk80 +units=m";
+            case 2314 : return "+proj=cass +lat_0=10.44166666666667 +lon_0=-61.33333333333334 +x_0=86501.46392052001 +y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654";
+            case 2315 : return "+proj=utm +zone=19 +south +ellps=intl +units=m";
+            case 2316 : return "+proj=utm +zone=20 +south +ellps=intl +units=m";
+            case 2317 : return "+proj=lcc +lat_1=9 +lat_2=3 +lat_0=6 +lon_0=-66 +x_0=1000000 +y_0=1000000 +ellps=intl +units=m";
+            case 2318 : return "+proj=lcc +lat_1=17 +lat_2=33 +lat_0=25.08951 +lon_0=48 +x_0=0 +y_0=0 +ellps=intl +units=m";
+            case 2319 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2320 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2321 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2322 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2323 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2324 : return "+proj=tmerc +lat_0=0 +lon_0=42 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2325 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 2326 : return "+proj=tmerc +lat_0=22.31213333333334 +lon_0=114.1785555555556 +k=1 +x_0=836694.05 +y_0=819069.8 +ellps=intl +towgs84=-162.619,-276.959,-161.764,0.067753,-2.24365,-1.15883,-1.09425 +units=m";
+            case 2327 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=13500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2328 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=14500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2329 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=15500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2330 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=16500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2331 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=17500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2332 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=18500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2333 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=19500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2334 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=20500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2335 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=21500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2336 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=22500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2337 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=23500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2338 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2339 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2340 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2341 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2342 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2343 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2344 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2345 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2346 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2347 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2348 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2349 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=25500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2350 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=26500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2351 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=27500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2352 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=28500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2353 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=29500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2354 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=30500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2355 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=31500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2356 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=32500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2357 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=33500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2358 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=34500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2359 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=35500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2360 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=36500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2361 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2362 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2363 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2364 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2365 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=41500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2366 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=42500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2367 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=43500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2368 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=44500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2369 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=45500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2370 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2371 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2372 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2373 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2374 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2375 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2376 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2377 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2378 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2379 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2380 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2381 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2382 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2383 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2384 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2385 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2386 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2387 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2388 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2389 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2390 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +a=6378140 +b=6356755.288157528 +units=m";
+            case 2391 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=1500000 +y_0=0 +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964 +units=m";
+            case 2392 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=2500000 +y_0=0 +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964 +units=m";
+            case 2393 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964 +units=m";
+            case 2394 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=4500000 +y_0=0 +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964 +units=m";
+            case 2395 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +towgs84=-76,-138,67,0,0,0,0 +units=m";
+            case 2396 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=9500000 +y_0=0 +ellps=krass +towgs84=-76,-138,67,0,0,0,0 +units=m";
+            case 2397 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m";
+            case 2398 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m";
+            case 2399 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m";
+            case 2400 : return "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 2401 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=25500000 +y_0=0 +ellps=krass +units=m";
+            case 2402 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=26500000 +y_0=0 +ellps=krass +units=m";
+            case 2403 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=27500000 +y_0=0 +ellps=krass +units=m";
+            case 2404 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=28500000 +y_0=0 +ellps=krass +units=m";
+            case 2405 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=29500000 +y_0=0 +ellps=krass +units=m";
+            case 2406 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=30500000 +y_0=0 +ellps=krass +units=m";
+            case 2407 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=31500000 +y_0=0 +ellps=krass +units=m";
+            case 2408 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=32500000 +y_0=0 +ellps=krass +units=m";
+            case 2409 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=33500000 +y_0=0 +ellps=krass +units=m";
+            case 2410 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=34500000 +y_0=0 +ellps=krass +units=m";
+            case 2411 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=35500000 +y_0=0 +ellps=krass +units=m";
+            case 2412 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=36500000 +y_0=0 +ellps=krass +units=m";
+            case 2413 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +ellps=krass +units=m";
+            case 2414 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +ellps=krass +units=m";
+            case 2415 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=krass +units=m";
+            case 2416 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=krass +units=m";
+            case 2417 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=41500000 +y_0=0 +ellps=krass +units=m";
+            case 2418 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=42500000 +y_0=0 +ellps=krass +units=m";
+            case 2419 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=43500000 +y_0=0 +ellps=krass +units=m";
+            case 2420 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=44500000 +y_0=0 +ellps=krass +units=m";
+            case 2421 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=45500000 +y_0=0 +ellps=krass +units=m";
+            case 2422 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2423 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2424 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2425 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2426 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2427 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2428 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2429 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2430 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2431 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2432 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2433 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2434 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2435 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2436 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2437 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2438 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2439 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2440 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2441 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2442 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2443 : return "+proj=tmerc +lat_0=33 +lon_0=129.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2444 : return "+proj=tmerc +lat_0=33 +lon_0=131 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2445 : return "+proj=tmerc +lat_0=36 +lon_0=132.1666666666667 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2446 : return "+proj=tmerc +lat_0=33 +lon_0=133.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2447 : return "+proj=tmerc +lat_0=36 +lon_0=134.3333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2448 : return "+proj=tmerc +lat_0=36 +lon_0=136 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2449 : return "+proj=tmerc +lat_0=36 +lon_0=137.1666666666667 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2450 : return "+proj=tmerc +lat_0=36 +lon_0=138.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2451 : return "+proj=tmerc +lat_0=36 +lon_0=139.8333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2452 : return "+proj=tmerc +lat_0=40 +lon_0=140.8333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2453 : return "+proj=tmerc +lat_0=44 +lon_0=140.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2454 : return "+proj=tmerc +lat_0=44 +lon_0=142.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2455 : return "+proj=tmerc +lat_0=44 +lon_0=144.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2456 : return "+proj=tmerc +lat_0=26 +lon_0=142 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2457 : return "+proj=tmerc +lat_0=26 +lon_0=127.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2458 : return "+proj=tmerc +lat_0=26 +lon_0=124 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2459 : return "+proj=tmerc +lat_0=26 +lon_0=131 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2460 : return "+proj=tmerc +lat_0=20 +lon_0=136 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2461 : return "+proj=tmerc +lat_0=26 +lon_0=154 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2462 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m";
+            case 2463 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2464 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2465 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2466 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2467 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2468 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2469 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2470 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2471 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2472 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2473 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2474 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2475 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2476 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2477 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2478 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2479 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2480 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2481 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2482 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2483 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2484 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2485 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2486 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2487 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2488 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2489 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2490 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2491 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2492 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2493 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2494 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2495 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2496 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2497 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2498 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2499 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2500 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2501 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2502 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2503 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2504 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2505 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2506 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2507 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2508 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2509 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2510 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2511 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2512 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2513 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2514 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2515 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2516 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2517 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2518 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2519 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2520 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2521 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2522 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2523 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=7500000 +y_0=0 +ellps=krass +units=m";
+            case 2524 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +units=m";
+            case 2525 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=9500000 +y_0=0 +ellps=krass +units=m";
+            case 2526 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=10500000 +y_0=0 +ellps=krass +units=m";
+            case 2527 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=11500000 +y_0=0 +ellps=krass +units=m";
+            case 2528 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=1 +x_0=12500000 +y_0=0 +ellps=krass +units=m";
+            case 2529 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=13500000 +y_0=0 +ellps=krass +units=m";
+            case 2530 : return "+proj=tmerc +lat_0=0 +lon_0=42 +k=1 +x_0=14500000 +y_0=0 +ellps=krass +units=m";
+            case 2531 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=15500000 +y_0=0 +ellps=krass +units=m";
+            case 2532 : return "+proj=tmerc +lat_0=0 +lon_0=48 +k=1 +x_0=16500000 +y_0=0 +ellps=krass +units=m";
+            case 2533 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=17500000 +y_0=0 +ellps=krass +units=m";
+            case 2534 : return "+proj=tmerc +lat_0=0 +lon_0=54 +k=1 +x_0=18500000 +y_0=0 +ellps=krass +units=m";
+            case 2535 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=19500000 +y_0=0 +ellps=krass +units=m";
+            case 2536 : return "+proj=tmerc +lat_0=0 +lon_0=60 +k=1 +x_0=20500000 +y_0=0 +ellps=krass +units=m";
+            case 2537 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=21500000 +y_0=0 +ellps=krass +units=m";
+            case 2538 : return "+proj=tmerc +lat_0=0 +lon_0=66 +k=1 +x_0=22500000 +y_0=0 +ellps=krass +units=m";
+            case 2539 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=23500000 +y_0=0 +ellps=krass +units=m";
+            case 2540 : return "+proj=tmerc +lat_0=0 +lon_0=72 +k=1 +x_0=24500000 +y_0=0 +ellps=krass +units=m";
+            case 2541 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=25500000 +y_0=0 +ellps=krass +units=m";
+            case 2542 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=26500000 +y_0=0 +ellps=krass +units=m";
+            case 2543 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=27500000 +y_0=0 +ellps=krass +units=m";
+            case 2544 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=28500000 +y_0=0 +ellps=krass +units=m";
+            case 2545 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=29500000 +y_0=0 +ellps=krass +units=m";
+            case 2546 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=30500000 +y_0=0 +ellps=krass +units=m";
+            case 2547 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=31500000 +y_0=0 +ellps=krass +units=m";
+            case 2548 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=32500000 +y_0=0 +ellps=krass +units=m";
+            case 2549 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=33500000 +y_0=0 +ellps=krass +units=m";
+            case 2550 : return "+proj=utm +zone=50 +south +ellps=bessel +towgs84=-404.78,685.68,45.47,0,0,0,0 +units=m";
+            case 2551 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=34500000 +y_0=0 +ellps=krass +units=m";
+            case 2552 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=35500000 +y_0=0 +ellps=krass +units=m";
+            case 2553 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=36500000 +y_0=0 +ellps=krass +units=m";
+            case 2554 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +ellps=krass +units=m";
+            case 2555 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +ellps=krass +units=m";
+            case 2556 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=krass +units=m";
+            case 2557 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=krass +units=m";
+            case 2558 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=41500000 +y_0=0 +ellps=krass +units=m";
+            case 2559 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=42500000 +y_0=0 +ellps=krass +units=m";
+            case 2560 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=43500000 +y_0=0 +ellps=krass +units=m";
+            case 2561 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=44500000 +y_0=0 +ellps=krass +units=m";
+            case 2562 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=45500000 +y_0=0 +ellps=krass +units=m";
+            case 2563 : return "+proj=tmerc +lat_0=0 +lon_0=138 +k=1 +x_0=46500000 +y_0=0 +ellps=krass +units=m";
+            case 2564 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=47500000 +y_0=0 +ellps=krass +units=m";
+            case 2565 : return "+proj=tmerc +lat_0=0 +lon_0=144 +k=1 +x_0=48500000 +y_0=0 +ellps=krass +units=m";
+            case 2566 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=49500000 +y_0=0 +ellps=krass +units=m";
+            case 2567 : return "+proj=tmerc +lat_0=0 +lon_0=150 +k=1 +x_0=50500000 +y_0=0 +ellps=krass +units=m";
+            case 2568 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=51500000 +y_0=0 +ellps=krass +units=m";
+            case 2569 : return "+proj=tmerc +lat_0=0 +lon_0=156 +k=1 +x_0=52500000 +y_0=0 +ellps=krass +units=m";
+            case 2570 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=53500000 +y_0=0 +ellps=krass +units=m";
+            case 2571 : return "+proj=tmerc +lat_0=0 +lon_0=162 +k=1 +x_0=54500000 +y_0=0 +ellps=krass +units=m";
+            case 2572 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=55500000 +y_0=0 +ellps=krass +units=m";
+            case 2573 : return "+proj=tmerc +lat_0=0 +lon_0=168 +k=1 +x_0=56500000 +y_0=0 +ellps=krass +units=m";
+            case 2574 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=57500000 +y_0=0 +ellps=krass +units=m";
+            case 2575 : return "+proj=tmerc +lat_0=0 +lon_0=174 +k=1 +x_0=58500000 +y_0=0 +ellps=krass +units=m";
+            case 2576 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=59500000 +y_0=0 +ellps=krass +units=m";
+            case 2577 : return "+proj=tmerc +lat_0=0 +lon_0=180 +k=1 +x_0=60000000 +y_0=0 +ellps=krass +units=m";
+            case 2578 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=61500000 +y_0=0 +ellps=krass +units=m";
+            case 2579 : return "+proj=tmerc +lat_0=0 +lon_0=-174 +k=1 +x_0=62500000 +y_0=0 +ellps=krass +units=m";
+            case 2580 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=63500000 +y_0=0 +ellps=krass +units=m";
+            case 2581 : return "+proj=tmerc +lat_0=0 +lon_0=-168 +k=1 +x_0=64500000 +y_0=0 +ellps=krass +units=m";
+            case 2582 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2583 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2584 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2585 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2586 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2587 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2588 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2589 : return "+proj=tmerc +lat_0=0 +lon_0=42 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2590 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2591 : return "+proj=tmerc +lat_0=0 +lon_0=48 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2592 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2593 : return "+proj=tmerc +lat_0=0 +lon_0=54 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2594 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2595 : return "+proj=tmerc +lat_0=0 +lon_0=60 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2596 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2597 : return "+proj=tmerc +lat_0=0 +lon_0=66 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2598 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2599 : return "+proj=tmerc +lat_0=0 +lon_0=72 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2600 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9998 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2601 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2602 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2603 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2604 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2605 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2606 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2607 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2608 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2609 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2610 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2611 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2612 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2613 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2614 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2615 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2616 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2617 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2618 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2619 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2620 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2621 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2622 : return "+proj=tmerc +lat_0=0 +lon_0=138 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2623 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2624 : return "+proj=tmerc +lat_0=0 +lon_0=144 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2625 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2626 : return "+proj=tmerc +lat_0=0 +lon_0=150 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2627 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2628 : return "+proj=tmerc +lat_0=0 +lon_0=156 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2629 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2630 : return "+proj=tmerc +lat_0=0 +lon_0=162 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2631 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2632 : return "+proj=tmerc +lat_0=0 +lon_0=168 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2633 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2634 : return "+proj=tmerc +lat_0=0 +lon_0=174 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2635 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2636 : return "+proj=tmerc +lat_0=0 +lon_0=180 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2637 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2638 : return "+proj=tmerc +lat_0=0 +lon_0=-174 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2639 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2640 : return "+proj=tmerc +lat_0=0 +lon_0=-168 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2641 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=7500000 +y_0=0 +ellps=krass +units=m";
+            case 2642 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +units=m";
+            case 2643 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=9500000 +y_0=0 +ellps=krass +units=m";
+            case 2644 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=10500000 +y_0=0 +ellps=krass +units=m";
+            case 2645 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=11500000 +y_0=0 +ellps=krass +units=m";
+            case 2646 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=1 +x_0=12500000 +y_0=0 +ellps=krass +units=m";
+            case 2647 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=13500000 +y_0=0 +ellps=krass +units=m";
+            case 2648 : return "+proj=tmerc +lat_0=0 +lon_0=42 +k=1 +x_0=14500000 +y_0=0 +ellps=krass +units=m";
+            case 2649 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=15500000 +y_0=0 +ellps=krass +units=m";
+            case 2650 : return "+proj=tmerc +lat_0=0 +lon_0=48 +k=1 +x_0=16500000 +y_0=0 +ellps=krass +units=m";
+            case 2651 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=17500000 +y_0=0 +ellps=krass +units=m";
+            case 2652 : return "+proj=tmerc +lat_0=0 +lon_0=54 +k=1 +x_0=18500000 +y_0=0 +ellps=krass +units=m";
+            case 2653 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=19500000 +y_0=0 +ellps=krass +units=m";
+            case 2654 : return "+proj=tmerc +lat_0=0 +lon_0=60 +k=1 +x_0=20500000 +y_0=0 +ellps=krass +units=m";
+            case 2655 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=21500000 +y_0=0 +ellps=krass +units=m";
+            case 2656 : return "+proj=tmerc +lat_0=0 +lon_0=66 +k=1 +x_0=22500000 +y_0=0 +ellps=krass +units=m";
+            case 2657 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=23500000 +y_0=0 +ellps=krass +units=m";
+            case 2658 : return "+proj=tmerc +lat_0=0 +lon_0=72 +k=1 +x_0=24500000 +y_0=0 +ellps=krass +units=m";
+            case 2659 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=25500000 +y_0=0 +ellps=krass +units=m";
+            case 2660 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=26500000 +y_0=0 +ellps=krass +units=m";
+            case 2661 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=27500000 +y_0=0 +ellps=krass +units=m";
+            case 2662 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=28500000 +y_0=0 +ellps=krass +units=m";
+            case 2663 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=29500000 +y_0=0 +ellps=krass +units=m";
+            case 2664 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=30500000 +y_0=0 +ellps=krass +units=m";
+            case 2665 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=31500000 +y_0=0 +ellps=krass +units=m";
+            case 2666 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=32500000 +y_0=0 +ellps=krass +units=m";
+            case 2667 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=33500000 +y_0=0 +ellps=krass +units=m";
+            case 2668 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=34500000 +y_0=0 +ellps=krass +units=m";
+            case 2669 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=35500000 +y_0=0 +ellps=krass +units=m";
+            case 2670 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=36500000 +y_0=0 +ellps=krass +units=m";
+            case 2671 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +ellps=krass +units=m";
+            case 2672 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +ellps=krass +units=m";
+            case 2673 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=krass +units=m";
+            case 2674 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=krass +units=m";
+            case 2675 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=41500000 +y_0=0 +ellps=krass +units=m";
+            case 2676 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=42500000 +y_0=0 +ellps=krass +units=m";
+            case 2677 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=43500000 +y_0=0 +ellps=krass +units=m";
+            case 2678 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=44500000 +y_0=0 +ellps=krass +units=m";
+            case 2679 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=45500000 +y_0=0 +ellps=krass +units=m";
+            case 2680 : return "+proj=tmerc +lat_0=0 +lon_0=138 +k=1 +x_0=46500000 +y_0=0 +ellps=krass +units=m";
+            case 2681 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=47500000 +y_0=0 +ellps=krass +units=m";
+            case 2682 : return "+proj=tmerc +lat_0=0 +lon_0=144 +k=1 +x_0=48500000 +y_0=0 +ellps=krass +units=m";
+            case 2683 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=49500000 +y_0=0 +ellps=krass +units=m";
+            case 2684 : return "+proj=tmerc +lat_0=0 +lon_0=150 +k=1 +x_0=50500000 +y_0=0 +ellps=krass +units=m";
+            case 2685 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=51500000 +y_0=0 +ellps=krass +units=m";
+            case 2686 : return "+proj=tmerc +lat_0=0 +lon_0=156 +k=1 +x_0=52500000 +y_0=0 +ellps=krass +units=m";
+            case 2687 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=53500000 +y_0=0 +ellps=krass +units=m";
+            case 2688 : return "+proj=tmerc +lat_0=0 +lon_0=162 +k=1 +x_0=54500000 +y_0=0 +ellps=krass +units=m";
+            case 2689 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=55500000 +y_0=0 +ellps=krass +units=m";
+            case 2690 : return "+proj=tmerc +lat_0=0 +lon_0=168 +k=1 +x_0=56500000 +y_0=0 +ellps=krass +units=m";
+            case 2691 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=57500000 +y_0=0 +ellps=krass +units=m";
+            case 2692 : return "+proj=tmerc +lat_0=0 +lon_0=174 +k=1 +x_0=58500000 +y_0=0 +ellps=krass +units=m";
+            case 2693 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=59500000 +y_0=0 +ellps=krass +units=m";
+            case 2694 : return "+proj=tmerc +lat_0=0 +lon_0=180 +k=1 +x_0=60000000 +y_0=0 +ellps=krass +units=m";
+            case 2695 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=61500000 +y_0=0 +ellps=krass +units=m";
+            case 2696 : return "+proj=tmerc +lat_0=0 +lon_0=-174 +k=1 +x_0=62500000 +y_0=0 +ellps=krass +units=m";
+            case 2697 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=63500000 +y_0=0 +ellps=krass +units=m";
+            case 2698 : return "+proj=tmerc +lat_0=0 +lon_0=-168 +k=1 +x_0=64500000 +y_0=0 +ellps=krass +units=m";
+            case 2699 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2700 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2701 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2702 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2703 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2704 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2705 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2706 : return "+proj=tmerc +lat_0=0 +lon_0=42 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2707 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2708 : return "+proj=tmerc +lat_0=0 +lon_0=48 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2709 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2710 : return "+proj=tmerc +lat_0=0 +lon_0=54 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2711 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2712 : return "+proj=tmerc +lat_0=0 +lon_0=60 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2713 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2714 : return "+proj=tmerc +lat_0=0 +lon_0=66 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2715 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2716 : return "+proj=tmerc +lat_0=0 +lon_0=72 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2717 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2718 : return "+proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2719 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2720 : return "+proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2721 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2722 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2723 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2724 : return "+proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2725 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2726 : return "+proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2727 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2728 : return "+proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2729 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2730 : return "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2731 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2732 : return "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2733 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2734 : return "+proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2735 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2736 : return "+proj=utm +zone=36 +south +ellps=clrk66 +units=m";
+            case 2737 : return "+proj=utm +zone=37 +south +ellps=clrk66 +units=m";
+            case 2738 : return "+proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2739 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2740 : return "+proj=tmerc +lat_0=0 +lon_0=138 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2741 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2742 : return "+proj=tmerc +lat_0=0 +lon_0=144 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2743 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2744 : return "+proj=tmerc +lat_0=0 +lon_0=150 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2745 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2746 : return "+proj=tmerc +lat_0=0 +lon_0=156 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2747 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2748 : return "+proj=tmerc +lat_0=0 +lon_0=162 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2749 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2750 : return "+proj=tmerc +lat_0=0 +lon_0=168 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2751 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2752 : return "+proj=tmerc +lat_0=0 +lon_0=174 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2753 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2754 : return "+proj=tmerc +lat_0=0 +lon_0=180 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2755 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2756 : return "+proj=tmerc +lat_0=0 +lon_0=-174 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2757 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2758 : return "+proj=tmerc +lat_0=0 +lon_0=-168 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 2759 : return "+proj=tmerc +lat_0=30.5 +lon_0=-85.83333333333333 +k=0.99996 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2760 : return "+proj=tmerc +lat_0=30 +lon_0=-87.5 +k=0.999933333 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2761 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +units=m";
+            case 2762 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +units=m";
+            case 2763 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=213360 +y_0=0 +ellps=GRS80 +units=m";
+            case 2764 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2765 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=400000 +y_0=400000 +ellps=GRS80 +units=m";
+            case 2766 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=2000000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2767 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2768 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2769 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=2000000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2770 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2771 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=2000000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2772 : return "+proj=lcc +lat_1=40.78333333333333 +lat_2=39.71666666666667 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +units=m";
+            case 2773 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +units=m";
+            case 2774 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +units=m";
+            case 2775 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=304800.6096 +y_0=152400.3048 +ellps=GRS80 +units=m";
+            case 2776 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2777 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2778 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2779 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2780 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2781 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=700000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2782 : return "+proj=tmerc +lat_0=18.83333333333333 +lon_0=-155.5 +k=0.999966667 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2783 : return "+proj=tmerc +lat_0=20.33333333333333 +lon_0=-156.6666666666667 +k=0.999966667 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2784 : return "+proj=tmerc +lat_0=21.16666666666667 +lon_0=-158 +k=0.99999 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2785 : return "+proj=tmerc +lat_0=21.83333333333333 +lon_0=-159.5 +k=0.99999 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2786 : return "+proj=tmerc +lat_0=21.66666666666667 +lon_0=-160.1666666666667 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2787 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2788 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2789 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=800000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2790 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2791 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=700000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2792 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=100000 +y_0=250000 +ellps=GRS80 +units=m";
+            case 2793 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=250000 +ellps=GRS80 +units=m";
+            case 2794 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=1500000 +y_0=1000000 +ellps=GRS80 +units=m";
+            case 2795 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2796 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2797 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=400000 +y_0=400000 +ellps=GRS80 +units=m";
+            case 2798 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2799 : return "+proj=lcc +lat_1=37.93333333333333 +lat_2=36.73333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=500000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 2800 : return "+proj=lcc +lat_1=32.66666666666666 +lat_2=31.16666666666667 +lat_0=30.5 +lon_0=-92.5 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2801 : return "+proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2802 : return "+proj=tmerc +lat_0=43.66666666666666 +lon_0=-68.5 +k=0.9999 +x_0=300000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2803 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.16666666666667 +k=0.999966667 +x_0=900000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2804 : return "+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2805 : return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +units=m";
+            case 2806 : return "+proj=lcc +lat_1=41.48333333333333 +lat_2=41.28333333333333 +lat_0=41 +lon_0=-70.5 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2807 : return "+proj=lcc +lat_1=47.08333333333334 +lat_2=45.48333333333333 +lat_0=44.78333333333333 +lon_0=-87 +x_0=8000000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2808 : return "+proj=lcc +lat_1=45.7 +lat_2=44.18333333333333 +lat_0=43.31666666666667 +lon_0=-84.36666666666666 +x_0=6000000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2809 : return "+proj=lcc +lat_1=43.66666666666666 +lat_2=42.1 +lat_0=41.5 +lon_0=-84.36666666666666 +x_0=4000000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2810 : return "+proj=lcc +lat_1=48.63333333333333 +lat_2=47.03333333333333 +lat_0=46.5 +lon_0=-93.09999999999999 +x_0=800000 +y_0=100000 +ellps=GRS80 +units=m";
+            case 2811 : return "+proj=lcc +lat_1=47.05 +lat_2=45.61666666666667 +lat_0=45 +lon_0=-94.25 +x_0=800000 +y_0=100000 +ellps=GRS80 +units=m";
+            case 2812 : return "+proj=lcc +lat_1=45.21666666666667 +lat_2=43.78333333333333 +lat_0=43 +lon_0=-94 +x_0=800000 +y_0=100000 +ellps=GRS80 +units=m";
+            case 2813 : return "+proj=tmerc +lat_0=29.5 +lon_0=-88.83333333333333 +k=0.99995 +x_0=300000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2814 : return "+proj=tmerc +lat_0=29.5 +lon_0=-90.33333333333333 +k=0.99995 +x_0=700000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2815 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.999933333 +x_0=250000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2816 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-92.5 +k=0.999933333 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2817 : return "+proj=tmerc +lat_0=36.16666666666666 +lon_0=-94.5 +k=0.999941177 +x_0=850000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2818 : return "+proj=lcc +lat_1=49 +lat_2=45 +lat_0=44.25 +lon_0=-109.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2819 : return "+proj=lcc +lat_1=43 +lat_2=40 +lat_0=39.83333333333334 +lon_0=-100 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2820 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=200000 +y_0=8000000 +ellps=GRS80 +units=m";
+            case 2821 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=500000 +y_0=6000000 +ellps=GRS80 +units=m";
+            case 2822 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=800000 +y_0=4000000 +ellps=GRS80 +units=m";
+            case 2823 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=300000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2824 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2825 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=165000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2826 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2827 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=830000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2828 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2829 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=250000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2830 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2831 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2832 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.43333333333333 +lat_0=47 +lon_0=-100.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2833 : return "+proj=lcc +lat_1=47.48333333333333 +lat_2=46.18333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2834 : return "+proj=lcc +lat_1=41.7 +lat_2=40.43333333333333 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2835 : return "+proj=lcc +lat_1=40.03333333333333 +lat_2=38.73333333333333 +lat_0=38 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2836 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=35.56666666666667 +lat_0=35 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2837 : return "+proj=lcc +lat_1=35.23333333333333 +lat_2=33.93333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2838 : return "+proj=lcc +lat_1=46 +lat_2=44.33333333333334 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2839 : return "+proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2840 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.99999375 +x_0=100000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2841 : return "+proj=lcc +lat_1=45.68333333333333 +lat_2=44.41666666666666 +lat_0=43.83333333333334 +lon_0=-100 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2842 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2843 : return "+proj=lcc +lat_1=36.41666666666666 +lat_2=35.25 +lat_0=34.33333333333334 +lon_0=-86 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2844 : return "+proj=lcc +lat_1=36.18333333333333 +lat_2=34.65 +lat_0=34 +lon_0=-101.5 +x_0=200000 +y_0=1000000 +ellps=GRS80 +units=m";
+            case 2845 : return "+proj=lcc +lat_1=33.96666666666667 +lat_2=32.13333333333333 +lat_0=31.66666666666667 +lon_0=-98.5 +x_0=600000 +y_0=2000000 +ellps=GRS80 +units=m";
+            case 2846 : return "+proj=lcc +lat_1=31.88333333333333 +lat_2=30.11666666666667 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=700000 +y_0=3000000 +ellps=GRS80 +units=m";
+            case 2847 : return "+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +units=m";
+            case 2848 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=300000 +y_0=5000000 +ellps=GRS80 +units=m";
+            case 2849 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000 +y_0=1000000 +ellps=GRS80 +units=m";
+            case 2850 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000 +y_0=2000000 +ellps=GRS80 +units=m";
+            case 2851 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000 +y_0=3000000 +ellps=GRS80 +units=m";
+            case 2852 : return "+proj=tmerc +lat_0=42.5 +lon_0=-72.5 +k=0.999964286 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2853 : return "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000 +y_0=2000000 +ellps=GRS80 +units=m";
+            case 2854 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000 +y_0=1000000 +ellps=GRS80 +units=m";
+            case 2855 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2856 : return "+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2857 : return "+proj=lcc +lat_1=40.25 +lat_2=39 +lat_0=38.5 +lon_0=-79.5 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2858 : return "+proj=lcc +lat_1=38.88333333333333 +lat_2=37.48333333333333 +lat_0=37 +lon_0=-81 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2859 : return "+proj=lcc +lat_1=46.76666666666667 +lat_2=45.56666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2860 : return "+proj=lcc +lat_1=45.5 +lat_2=44.25 +lat_0=43.83333333333334 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2861 : return "+proj=lcc +lat_1=44.06666666666667 +lat_2=42.73333333333333 +lat_0=42 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2862 : return "+proj=tmerc +lat_0=40.5 +lon_0=-105.1666666666667 +k=0.9999375 +x_0=200000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2863 : return "+proj=tmerc +lat_0=40.5 +lon_0=-107.3333333333333 +k=0.9999375 +x_0=400000 +y_0=100000 +ellps=GRS80 +units=m";
+            case 2864 : return "+proj=tmerc +lat_0=40.5 +lon_0=-108.75 +k=0.9999375 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2865 : return "+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 +x_0=800000 +y_0=100000 +ellps=GRS80 +units=m";
+            case 2866 : return "+proj=lcc +lat_1=18.43333333333333 +lat_2=18.03333333333333 +lat_0=17.83333333333333 +lon_0=-66.43333333333334 +x_0=200000 +y_0=200000 +ellps=GRS80 +units=m";
+            case 2867 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2868 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2869 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=213360 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2870 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2871 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2872 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2873 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2874 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2875 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2876 : return "+proj=lcc +lat_1=40.78333333333333 +lat_2=39.71666666666667 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2877 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2878 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2879 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=304800.6096012192 +y_0=152400.3048006096 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2880 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2881 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2882 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2883 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2884 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2885 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=699999.9998983998 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2886 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2887 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2888 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=800000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2889 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=99999.99989839978 +y_0=249364.9987299975 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2890 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=249364.9987299975 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2891 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2892 : return "+proj=lcc +lat_1=37.93333333333333 +lat_2=36.73333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=500000.0001016001 +y_0=500000.0001016001 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2893 : return "+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=399999.9998983998 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2894 : return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000.0001016002 +y_0=750000 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2895 : return "+proj=lcc +lat_1=41.48333333333333 +lat_2=41.28333333333333 +lat_0=41 +lon_0=-70.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2896 : return "+proj=lcc +lat_1=47.08333333333334 +lat_2=45.48333333333333 +lat_0=44.78333333333333 +lon_0=-87 +x_0=7999999.999968001 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2897 : return "+proj=lcc +lat_1=45.7 +lat_2=44.18333333333333 +lat_0=43.31666666666667 +lon_0=-84.36666666666666 +x_0=5999999.999976001 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2898 : return "+proj=lcc +lat_1=43.66666666666666 +lat_2=42.1 +lat_0=41.5 +lon_0=-84.36666666666666 +x_0=3999999.999984 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2899 : return "+proj=tmerc +lat_0=29.5 +lon_0=-88.83333333333333 +k=0.99995 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2900 : return "+proj=tmerc +lat_0=29.5 +lon_0=-90.33333333333333 +k=0.99995 +x_0=699999.9998983998 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2901 : return "+proj=lcc +lat_1=49 +lat_2=45 +lat_0=44.25 +lon_0=-109.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2902 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=165000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2903 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2904 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=830000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2905 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2906 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=249999.9998983998 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2907 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2908 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2909 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.43333333333333 +lat_0=47 +lon_0=-100.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2910 : return "+proj=lcc +lat_1=47.48333333333333 +lat_2=46.18333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2911 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=35.56666666666667 +lat_0=35 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2912 : return "+proj=lcc +lat_1=35.23333333333333 +lat_2=33.93333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2913 : return "+proj=lcc +lat_1=46 +lat_2=44.33333333333334 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000.0001424 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2914 : return "+proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000.0001464 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2915 : return "+proj=lcc +lat_1=36.41666666666666 +lat_2=35.25 +lat_0=34.33333333333334 +lon_0=-86 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2916 : return "+proj=lcc +lat_1=36.18333333333333 +lat_2=34.65 +lat_0=34 +lon_0=-101.5 +x_0=200000.0001016002 +y_0=999999.9998983998 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2917 : return "+proj=lcc +lat_1=33.96666666666667 +lat_2=32.13333333333333 +lat_0=31.66666666666667 +lon_0=-98.5 +x_0=600000 +y_0=2000000.0001016 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2918 : return "+proj=lcc +lat_1=31.88333333333333 +lat_2=30.11666666666667 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=699999.9998983998 +y_0=3000000 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2919 : return "+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=3999999.9998984 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2920 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=300000.0000000001 +y_0=5000000.0001016 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2921 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000.0001504 +y_0=999999.9999960001 +ellps=GRS80 +to_meter=0.3048";
+            case 2922 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000.0001504 +y_0=1999999.999992 +ellps=GRS80 +to_meter=0.3048";
+            case 2923 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000.0001504 +y_0=2999999.999988 +ellps=GRS80 +to_meter=0.3048";
+            case 2924 : return "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=2000000.0001016 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2925 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=999999.9998983998 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2926 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2927 : return "+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2928 : return "+proj=lcc +lat_1=46.76666666666667 +lat_2=45.56666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2929 : return "+proj=lcc +lat_1=45.5 +lat_2=44.25 +lat_0=43.83333333333334 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2930 : return "+proj=lcc +lat_1=44.06666666666667 +lat_2=42.73333333333333 +lat_0=42 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2931 : return "+proj=tmerc +lat_0=0 +lon_0=13 +k=0.9996 +x_0=500000 +y_0=0 +a=6378249.2 +b=6356515 +towgs84=-106,-87,188,0,0,0,0 +units=m";
+            case 2932 : return "+proj=tmerc +lat_0=24.45 +lon_0=51.21666666666667 +k=0.99999 +x_0=200000 +y_0=300000 +ellps=intl +towgs84=-119.425,-303.659,-11.0006,1.1643,0.174458,1.09626,3.65706 +units=m";
+            case 2933 : return "+proj=utm +zone=50 +south +ellps=bessel +units=m";
+            case 2934 : return "+proj=merc +lon_0=110 +k=0.997 +x_0=3900000 +y_0=900000 +ellps=bessel +pm=jakarta +units=m";
+            case 2935 : return "+proj=tmerc +lat_0=0.1166666666666667 +lon_0=41.53333333333333 +k=1 +x_0=1300000 +y_0=0 +ellps=krass +units=m";
+            case 2936 : return "+proj=tmerc +lat_0=0.1166666666666667 +lon_0=44.53333333333333 +k=1 +x_0=2300000 +y_0=0 +ellps=krass +units=m";
+            case 2937 : return "+proj=tmerc +lat_0=0.1166666666666667 +lon_0=47.53333333333333 +k=1 +x_0=3300000 +y_0=0 +ellps=krass +units=m";
+            case 2938 : return "+proj=tmerc +lat_0=0.1166666666666667 +lon_0=50.53333333333333 +k=1 +x_0=4300000 +y_0=0 +ellps=krass +units=m";
+            case 2939 : return "+proj=tmerc +lat_0=0.1333333333333333 +lon_0=50.76666666666667 +k=1 +x_0=2300000 +y_0=0 +ellps=krass +units=m";
+            case 2940 : return "+proj=tmerc +lat_0=0.1333333333333333 +lon_0=53.76666666666667 +k=1 +x_0=3300000 +y_0=0 +ellps=krass +units=m";
+            case 2941 : return "+proj=tmerc +lat_0=0.1333333333333333 +lon_0=56.76666666666667 +k=1 +x_0=4300000 +y_0=0 +ellps=krass +units=m";
+            case 2942 : return "+proj=utm +zone=28 +ellps=intl +towgs84=-499,-249,314,0,0,0,0 +units=m";
+            case 2943 : return "+proj=utm +zone=28 +ellps=intl +units=m";
+            case 2944 : return "+proj=tmerc +lat_0=0 +lon_0=-55.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2945 : return "+proj=tmerc +lat_0=0 +lon_0=-58.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2946 : return "+proj=tmerc +lat_0=0 +lon_0=-61.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2947 : return "+proj=tmerc +lat_0=0 +lon_0=-64.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2948 : return "+proj=tmerc +lat_0=0 +lon_0=-67.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2949 : return "+proj=tmerc +lat_0=0 +lon_0=-70.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2950 : return "+proj=tmerc +lat_0=0 +lon_0=-73.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2951 : return "+proj=tmerc +lat_0=0 +lon_0=-76.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2952 : return "+proj=tmerc +lat_0=0 +lon_0=-79.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +units=m";
+            case 2953 : return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=2500000 +y_0=7500000 +ellps=GRS80 +units=m";
+            case 2954 : return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +units=m";
+            case 2955 : return "+proj=utm +zone=11 +ellps=GRS80 +units=m";
+            case 2956 : return "+proj=utm +zone=12 +ellps=GRS80 +units=m";
+            case 2957 : return "+proj=utm +zone=13 +ellps=GRS80 +units=m";
+            case 2958 : return "+proj=utm +zone=17 +ellps=GRS80 +units=m";
+            case 2959 : return "+proj=utm +zone=18 +ellps=GRS80 +units=m";
+            case 2960 : return "+proj=utm +zone=19 +ellps=GRS80 +units=m";
+            case 2961 : return "+proj=utm +zone=20 +ellps=GRS80 +units=m";
+            case 2962 : return "+proj=utm +zone=21 +ellps=GRS80 +units=m";
+            case 2964 : return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 2965 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=99999.99989839978 +y_0=249999.9998983998 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2966 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=249999.9998983998 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 2967 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=99999.99989839978 +y_0=249999.9998983998 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2968 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=249999.9998983998 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 2969 : return "+proj=utm +zone=20 +ellps=intl +towgs84=137,248,-430,0,0,0,0 +units=m";
+            case 2970 : return "+proj=utm +zone=20 +ellps=intl +units=m";
+            case 2971 : return "+proj=utm +zone=22 +ellps=intl +towgs84=-186,230,110,0,0,0,0 +units=m";
+            case 2972 : return "+proj=utm +zone=22 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m";
+            case 2973 : return "+proj=utm +zone=20 +ellps=intl +units=m";
+            case 2975 : return "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2976 : return "+proj=utm +zone=6 +south +ellps=intl +towgs84=162,117,154,0,0,0,0 +units=m";
+            case 2977 : return "+proj=utm +zone=5 +south +ellps=intl +units=m";
+            case 2978 : return "+proj=utm +zone=7 +south +ellps=intl +units=m";
+            case 2979 : return "+proj=utm +zone=42 +south +ellps=intl +towgs84=145,-187,103,0,0,0,0 +units=m";
+            case 2980 : return "+proj=utm +zone=38 +south +ellps=intl +towgs84=-382,-59,-262,0,0,0,0 +units=m";
+            case 2981 : return "+proj=utm +zone=58 +south +ellps=intl +units=m";
+            case 2982 : return "+proj=utm +zone=58 +south +ellps=intl +units=m";
+            case 2983 : return "+proj=utm +zone=58 +south +ellps=intl +towgs84=-122.383,-188.696,103.344,3.5107,-4.9668,-5.7047,4.4798 +units=m";
+            case 2984 : return "+proj=lcc +lat_1=-20.66666666666667 +lat_2=-22.33333333333333 +lat_0=-21.5 +lon_0=166 +x_0=400000 +y_0=300000 +ellps=intl +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2987 : return "+proj=utm +zone=21 +ellps=clrk66 +towgs84=30,430,368,0,0,0,0 +units=m";
+            case 2988 : return "+proj=utm +zone=1 +south +ellps=intl +units=m";
+            case 2989 : return "+proj=utm +zone=20 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 2990 : return "+proj=tmerc +lat_0=-21.11666666666667 +lon_0=55.53333333333333 +k=1 +x_0=50000 +y_0=160000 +ellps=intl +units=m";
+            case 2991 : return "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 2992 : return "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=399999.9999984 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048";
+            case 2993 : return "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
+            case 2994 : return "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=399999.9999984 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 2995 : return "+proj=utm +zone=58 +south +ellps=intl +units=m";
+            case 2996 : return "+proj=utm +zone=58 +south +ellps=intl +units=m";
+            case 2997 : return "+proj=utm +zone=58 +south +ellps=intl +towgs84=-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7 +units=m";
+            case 2998 : return "+proj=utm +zone=58 +south +ellps=intl +units=m";
+            case 2999 : return "+proj=utm +zone=38 +south +ellps=intl +units=m";
+            case 3000 : return "+proj=merc +lon_0=110 +k=0.997 +x_0=3900000 +y_0=900000 +ellps=bessel +units=m";
+            case 3001 : return "+proj=merc +lon_0=110 +k=0.997 +x_0=3900000 +y_0=900000 +ellps=bessel +units=m";
+            case 3002 : return "+proj=merc +lon_0=110 +k=0.997 +x_0=3900000 +y_0=900000 +ellps=bessel +towgs84=-587.8,519.75,145.76,0,0,0,0 +units=m";
+            case 3003 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +units=m";
+            case 3004 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl +units=m";
+            case 3005 : return "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3006 : return "+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3007 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3008 : return "+proj=tmerc +lat_0=0 +lon_0=13.5 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3009 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3010 : return "+proj=tmerc +lat_0=0 +lon_0=16.5 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3011 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3012 : return "+proj=tmerc +lat_0=0 +lon_0=14.25 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3013 : return "+proj=tmerc +lat_0=0 +lon_0=15.75 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3014 : return "+proj=tmerc +lat_0=0 +lon_0=17.25 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3015 : return "+proj=tmerc +lat_0=0 +lon_0=18.75 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3016 : return "+proj=tmerc +lat_0=0 +lon_0=20.25 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3017 : return "+proj=tmerc +lat_0=0 +lon_0=21.75 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3018 : return "+proj=tmerc +lat_0=0 +lon_0=23.25 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3019 : return "+proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3020 : return "+proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3021 : return "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3022 : return "+proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3023 : return "+proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3024 : return "+proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3025 : return "+proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3026 : return "+proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3027 : return "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3028 : return "+proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3029 : return "+proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3030 : return "+proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 3031 : return "+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3032 : return "+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=70 +k=1 +x_0=6000000 +y_0=6000000 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3033 : return "+proj=lcc +lat_1=-68.5 +lat_2=-74.5 +lat_0=-50 +lon_0=70 +x_0=6000000 +y_0=6000000 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3034 : return "+proj=lcc +lat_1=35 +lat_2=65 +lat_0=52 +lon_0=10 +x_0=4000000 +y_0=2800000 +ellps=GRS80 +units=m";
+            case 3035 : return "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m";
+            case 3036 : return "+proj=utm +zone=36 +south +ellps=WGS84 +towgs84=0,0,0,-0,-0,-0,0 +units=m";
+            case 3037 : return "+proj=utm +zone=37 +south +ellps=WGS84 +towgs84=0,0,0,-0,-0,-0,0 +units=m";
+            case 3038 : return "+proj=utm +zone=26 +ellps=GRS80 +units=m";
+            case 3039 : return "+proj=utm +zone=27 +ellps=GRS80 +units=m";
+            case 3040 : return "+proj=utm +zone=28 +ellps=GRS80 +units=m";
+            case 3041 : return "+proj=utm +zone=29 +ellps=GRS80 +units=m";
+            case 3042 : return "+proj=utm +zone=30 +ellps=GRS80 +units=m";
+            case 3043 : return "+proj=utm +zone=31 +ellps=GRS80 +units=m";
+            case 3044 : return "+proj=utm +zone=32 +ellps=GRS80 +units=m";
+            case 3045 : return "+proj=utm +zone=33 +ellps=GRS80 +units=m";
+            case 3046 : return "+proj=utm +zone=34 +ellps=GRS80 +units=m";
+            case 3047 : return "+proj=utm +zone=35 +ellps=GRS80 +units=m";
+            case 3048 : return "+proj=utm +zone=36 +ellps=GRS80 +units=m";
+            case 3049 : return "+proj=utm +zone=37 +ellps=GRS80 +units=m";
+            case 3050 : return "+proj=utm +zone=38 +ellps=GRS80 +units=m";
+            case 3051 : return "+proj=utm +zone=39 +ellps=GRS80 +units=m";
+            case 3054 : return "+proj=utm +zone=26 +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +units=m";
+            case 3055 : return "+proj=utm +zone=27 +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +units=m";
+            case 3056 : return "+proj=utm +zone=28 +ellps=intl +towgs84=-73,46,-86,0,0,0,0 +units=m";
+            case 3057 : return "+proj=lcc +lat_1=64.25 +lat_2=65.75 +lat_0=65 +lon_0=-19 +x_0=500000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3058 : return "+proj=tmerc +lat_0=0 +lon_0=-8.5 +k=1 +x_0=50000 +y_0=-7800000 +ellps=intl +towgs84=982.609,552.753,-540.873,32.3934,-153.257,-96.2266,16.805 +units=m";
+            case 3059 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=-6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3060 : return "+proj=utm +zone=58 +south +ellps=intl +units=m";
+            case 3061 : return "+proj=utm +zone=28 +ellps=intl +units=m";
+            case 3062 : return "+proj=utm +zone=26 +ellps=intl +units=m";
+            case 3063 : return "+proj=utm +zone=26 +ellps=intl +units=m";
+            case 3064 : return "+proj=utm +zone=32 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3065 : return "+proj=utm +zone=33 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3066 : return "+proj=tmerc +lat_0=0 +lon_0=37 +k=0.9998 +x_0=500000 +y_0=-3000000 +ellps=intl +units=m";
+            case 3067 : return "+proj=utm +zone=35 +ellps=GRS80 +units=m";
+            case 3068 : return "+proj=cass +lat_0=52.41864827777778 +lon_0=13.62720366666667 +x_0=40000 +y_0=10000 +ellps=bessel +datum=potsdam +units=m";
+            case 3069 : return "+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9996 +x_0=500000 +y_0=-4500000 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 3070 : return "+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9996 +x_0=520000 +y_0=-4480000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3071 : return "+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9996 +x_0=520000 +y_0=-4480000 +ellps=GRS80 +units=m";
+            case 3072 : return "+proj=tmerc +lat_0=43.83333333333334 +lon_0=-67.875 +k=0.99998 +x_0=700000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3073 : return "+proj=tmerc +lat_0=43 +lon_0=-69.125 +k=0.99998 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3074 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.375 +k=0.99998 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3075 : return "+proj=tmerc +lat_0=43.83333333333334 +lon_0=-67.875 +k=0.99998 +x_0=700000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3076 : return "+proj=tmerc +lat_0=43 +lon_0=-69.125 +k=0.99998 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3077 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.375 +k=0.99998 +x_0=300000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3078 : return "+proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3079 : return "+proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +ellps=GRS80 +units=m";
+            case 3080 : return "+proj=lcc +lat_1=27.41666666666667 +lat_2=34.91666666666666 +lat_0=31.16666666666667 +lon_0=-100 +x_0=914400 +y_0=914400 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048";
+            case 3081 : return "+proj=lcc +lat_1=27.41666666666667 +lat_2=34.91666666666666 +lat_0=31.16666666666667 +lon_0=-100 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3082 : return "+proj=lcc +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=5000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3083 : return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3084 : return "+proj=lcc +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=5000000 +ellps=GRS80 +units=m";
+            case 3085 : return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +units=m";
+            case 3086 : return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3087 : return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3088 : return "+proj=lcc +lat_1=37.08333333333334 +lat_2=38.66666666666666 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=1500000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3089 : return "+proj=lcc +lat_1=37.08333333333334 +lat_2=38.66666666666666 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=1500000 +y_0=999999.9998983998 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3090 : return "+proj=lcc +lat_1=37.08333333333334 +lat_2=38.66666666666666 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=1500000 +y_0=1000000 +ellps=GRS80 +units=m";
+            case 3091 : return "+proj=lcc +lat_1=37.08333333333334 +lat_2=38.66666666666666 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=1500000 +y_0=999999.9998983998 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3092 : return "+proj=utm +zone=51 +ellps=bessel +units=m";
+            case 3093 : return "+proj=utm +zone=52 +ellps=bessel +units=m";
+            case 3094 : return "+proj=utm +zone=53 +ellps=bessel +units=m";
+            case 3095 : return "+proj=utm +zone=54 +ellps=bessel +units=m";
+            case 3096 : return "+proj=utm +zone=55 +ellps=bessel +units=m";
+            case 3097 : return "+proj=utm +zone=51 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3098 : return "+proj=utm +zone=52 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3099 : return "+proj=utm +zone=53 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3100 : return "+proj=utm +zone=54 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3101 : return "+proj=utm +zone=55 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3102 : return "+proj=lcc +lat_1=-14.26666666666667 +lat_0=-14.26666666666667 +lon_0=-170 +k_0=1 +x_0=152400.3048006096 +y_0=95169.31165862332 +ellps=clrk66 +towgs84=-115,118,426,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3103 : return "+proj=utm +zone=28 +ellps=clrk80 +units=m";
+            case 3104 : return "+proj=utm +zone=29 +ellps=clrk80 +units=m";
+            case 3105 : return "+proj=utm +zone=30 +ellps=clrk80 +units=m";
+            case 3106 : return "+proj=tmerc +lat_0=0 +lon_0=90 +k=0.9996 +x_0=500000 +y_0=0 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 3107 : return "+proj=lcc +lat_1=-28 +lat_2=-36 +lat_0=-32 +lon_0=135 +x_0=1000000 +y_0=2000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3108 : return "+proj=tmerc +lat_0=49.5 +lon_0=-2.416666666666667 +k=0.999997 +x_0=47000 +y_0=50000 +ellps=GRS80 +units=m";
+            case 3109 : return "+proj=tmerc +lat_0=49.225 +lon_0=-2.135 +k=0.9999999000000001 +x_0=40000 +y_0=70000 +ellps=GRS80 +units=m";
+            case 3110 : return "+proj=lcc +lat_1=-36 +lat_2=-38 +lat_0=-37 +lon_0=145 +x_0=2500000 +y_0=4500000 +ellps=aust_SA +units=m";
+            case 3111 : return "+proj=lcc +lat_1=-36 +lat_2=-38 +lat_0=-37 +lon_0=145 +x_0=2500000 +y_0=2500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3112 : return "+proj=lcc +lat_1=-18 +lat_2=-36 +lat_0=0 +lon_0=134 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3113 : return "+proj=tmerc +lat_0=-28 +lon_0=153 +k=0.99999 +x_0=50000 +y_0=100000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3114 : return "+proj=tmerc +lat_0=4.596200416666666 +lon_0=-80.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3115 : return "+proj=tmerc +lat_0=4.596200416666666 +lon_0=-77.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3116 : return "+proj=tmerc +lat_0=4.596200416666666 +lon_0=-74.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3117 : return "+proj=tmerc +lat_0=4.596200416666666 +lon_0=-71.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3118 : return "+proj=tmerc +lat_0=4.596200416666666 +lon_0=-68.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3119 : return "+proj=tmerc +lat_0=0 +lon_0=10.5 +k=0.999 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=-206.1,-174.7,-87.7,0,0,0,0 +units=m";
+            case 3120 : return "+proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5467000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3121 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m";
+            case 3122 : return "+proj=tmerc +lat_0=0 +lon_0=119 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m";
+            case 3123 : return "+proj=tmerc +lat_0=0 +lon_0=121 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m";
+            case 3124 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m";
+            case 3125 : return "+proj=tmerc +lat_0=0 +lon_0=125 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m";
+            case 3126 : return "+proj=tmerc +lat_0=0 +lon_0=19 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3127 : return "+proj=tmerc +lat_0=0 +lon_0=20 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3128 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3129 : return "+proj=tmerc +lat_0=0 +lon_0=22 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3130 : return "+proj=tmerc +lat_0=0 +lon_0=23 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3131 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3132 : return "+proj=tmerc +lat_0=0 +lon_0=25 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3133 : return "+proj=tmerc +lat_0=0 +lon_0=26 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3134 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3135 : return "+proj=tmerc +lat_0=0 +lon_0=28 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3136 : return "+proj=tmerc +lat_0=0 +lon_0=29 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3137 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3138 : return "+proj=tmerc +lat_0=0 +lon_0=31 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3140 : return "+proj=cass +lat_0=-18 +lon_0=178 +x_0=109435.392 +y_0=141622.272 +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0 +to_meter=0.201168";
+            case 3141 : return "+proj=utm +zone=60 +south +ellps=intl +towgs84=265.025,384.929,-194.046,0,0,0,0 +units=m";
+            case 3142 : return "+proj=utm +zone=1 +south +ellps=intl +towgs84=265.025,384.929,-194.046,0,0,0,0 +units=m";
+            case 3143 : return "+proj=tmerc +lat_0=-17 +lon_0=178.75 +k=0.99985 +x_0=2000000 +y_0=4000000 +ellps=WGS72 +units=m";
+            case 3146 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=6500000 +y_0=0 +ellps=krass +units=m";
+            case 3147 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 3148 : return "+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 3149 : return "+proj=utm +zone=49 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 3150 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=6500000 +y_0=0 +ellps=krass +units=m";
+            case 3151 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 3152 : return "+proj=tmerc +lat_0=0 +lon_0=18.05779 +k=0.99999425 +x_0=100178.1808 +y_0=-6500614.7836 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3153 : return "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3154 : return "+proj=utm +zone=7 +ellps=GRS80 +units=m";
+            case 3155 : return "+proj=utm +zone=8 +ellps=GRS80 +units=m";
+            case 3156 : return "+proj=utm +zone=9 +ellps=GRS80 +units=m";
+            case 3157 : return "+proj=utm +zone=10 +ellps=GRS80 +units=m";
+            case 3158 : return "+proj=utm +zone=14 +ellps=GRS80 +units=m";
+            case 3159 : return "+proj=utm +zone=15 +ellps=GRS80 +units=m";
+            case 3160 : return "+proj=utm +zone=16 +ellps=GRS80 +units=m";
+            case 3161 : return "+proj=lcc +lat_1=44.5 +lat_2=53.5 +lat_0=0 +lon_0=-85 +x_0=930000 +y_0=6430000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3162 : return "+proj=lcc +lat_1=44.5 +lat_2=53.5 +lat_0=0 +lon_0=-85 +x_0=930000 +y_0=6430000 +ellps=GRS80 +units=m";
+            case 3163 : return "+proj=lcc +lat_1=-20.66666666666667 +lat_2=-22.33333333333333 +lat_0=-21.5 +lon_0=166 +x_0=400000 +y_0=300000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3164 : return "+proj=utm +zone=58 +south +ellps=WGS84 +towgs84=-56.263,16.136,-22.856,0,0,0,0 +units=m";
+            case 3165 : return "+proj=lcc +lat_1=-22.24469175 +lat_2=-22.29469175 +lat_0=-22.26969175 +lon_0=166.44242575 +x_0=0.66 +y_0=1.02 +ellps=intl +units=m";
+            case 3166 : return "+proj=lcc +lat_1=-22.24472222222222 +lat_2=-22.29472222222222 +lat_0=-22.26972222222222 +lon_0=166.4425 +x_0=8.313000000000001 +y_0=-2.354 +ellps=intl +units=m";
+            case 3167 : return "+proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257905 +k=0.99984 +x_0=40000 +y_0=0 +a=6377295.664 +b=6356094.667915204 +to_meter=20.116756";
+            case 3168 : return "+proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257905 +k=0.99984 +x_0=804670.24 +y_0=0 +a=6377295.664 +b=6356094.667915204 +units=m";
+            case 3169 : return "+proj=utm +zone=57 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3170 : return "+proj=utm +zone=58 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3171 : return "+proj=utm +zone=59 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3172 : return "+proj=utm +zone=59 +south +ellps=intl +units=m";
+            case 3174 : return "+proj=aea +lat_1=42.122774 +lat_2=49.01518 +lat_0=45.568977 +lon_0=-84.455955 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3175 : return "+proj=aea +lat_1=42.122774 +lat_2=49.01518 +lat_0=45.568977 +lon_0=-83.248627 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3176 : return "+proj=tmerc +lat_0=0 +lon_0=106 +k=0.9996 +x_0=500000 +y_0=0 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 3177 : return "+proj=tmerc +lat_0=0 +lon_0=17 +k=0.9965000000000001 +x_0=1000000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3178 : return "+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3179 : return "+proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3180 : return "+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3181 : return "+proj=utm +zone=21 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3182 : return "+proj=utm +zone=22 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3183 : return "+proj=utm +zone=23 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3184 : return "+proj=utm +zone=24 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3185 : return "+proj=utm +zone=25 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3186 : return "+proj=utm +zone=26 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3187 : return "+proj=utm +zone=27 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3188 : return "+proj=utm +zone=28 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3189 : return "+proj=utm +zone=29 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3190 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3191 : return "+proj=tmerc +lat_0=0 +lon_0=11 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3192 : return "+proj=tmerc +lat_0=0 +lon_0=13 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3193 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3194 : return "+proj=tmerc +lat_0=0 +lon_0=17 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3195 : return "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3196 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3197 : return "+proj=tmerc +lat_0=0 +lon_0=23 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3198 : return "+proj=tmerc +lat_0=0 +lon_0=25 +k=0.99995 +x_0=200000 +y_0=0 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3199 : return "+proj=utm +zone=32 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3200 : return "+proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=45 +k_0=0.9987864078000001 +x_0=1500000 +y_0=1166200 +ellps=clrk80 +units=m";
+            case 3201 : return "+proj=utm +zone=33 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3202 : return "+proj=utm +zone=34 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3203 : return "+proj=utm +zone=35 +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0 +units=m";
+            case 3204 : return "+proj=lcc +lat_1=-60.66666666666666 +lat_2=-63.33333333333334 +lat_0=-90 +lon_0=-66 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3205 : return "+proj=lcc +lat_1=-60.66666666666666 +lat_2=-63.33333333333334 +lat_0=-90 +lon_0=-54 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3206 : return "+proj=lcc +lat_1=-60.66666666666666 +lat_2=-63.33333333333334 +lat_0=-90 +lon_0=-42 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3207 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=-174 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3208 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=-66 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3209 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=-54 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3210 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=42 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3211 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=54 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3212 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=66 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3213 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=78 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3214 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=90 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3215 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=102 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3216 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=114 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3217 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=126 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3218 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=138 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3219 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=150 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3220 : return "+proj=lcc +lat_1=-64.66666666666667 +lat_2=-67.33333333333333 +lat_0=-90 +lon_0=162 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3221 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=-102 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3222 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=-90 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3223 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=-78 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3224 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=-66 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3225 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=-18 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3226 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=-6 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3227 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=6 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3228 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=18 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3229 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=30 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3230 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=42 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3231 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=54 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3232 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=66 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3233 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=78 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3234 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=90 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3235 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=102 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3236 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=114 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3237 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=126 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3238 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=138 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3239 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=150 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3240 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=162 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3241 : return "+proj=lcc +lat_1=-68.66666666666667 +lat_2=-71.33333333333333 +lat_0=-90 +lon_0=174 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3242 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-153 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3243 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-135 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3244 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-117 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3245 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-99 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3246 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-81 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3247 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-63 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3248 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-27 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3249 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=-9 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3250 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=9 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3251 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=27 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3252 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=45 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3253 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=63 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3254 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=81 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3255 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=99 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3256 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=117 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3257 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=135 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3258 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=153 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3259 : return "+proj=lcc +lat_1=-72.66666666666667 +lat_2=-75.33333333333333 +lat_0=-90 +lon_0=171 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3260 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-168 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3261 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-144 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3262 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-120 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3263 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-96 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3264 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-72 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3265 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-48 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3266 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-24 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3267 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3268 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=24 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3269 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=48 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3270 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=72 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3271 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=96 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3272 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=120 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3273 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=144 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3274 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=168 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3275 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-165 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3276 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-135 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3277 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-105 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3278 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-75 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3279 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3280 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-15 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3281 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=15 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3282 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=45 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3283 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=75 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3284 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=105 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3285 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=135 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3286 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=165 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3287 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-150 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3288 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-90 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3289 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=-30 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3290 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=30 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3291 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=90 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3292 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=150 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3293 : return "+proj=stere +lat_0=-90 +lat_ts=-80.23861111111111 +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3294 : return "+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-78 +lon_0=162 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3296 : return "+proj=utm +zone=5 +south +ellps=GRS80 +units=m";
+            case 3297 : return "+proj=utm +zone=6 +south +ellps=GRS80 +units=m";
+            case 3298 : return "+proj=utm +zone=7 +south +ellps=GRS80 +units=m";
+            case 3299 : return "+proj=utm +zone=8 +south +ellps=GRS80 +units=m";
+            case 3300 : return "+proj=lcc +lat_1=59.33333333333334 +lat_2=58 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0.055,-0.541,-0.185,0.0183,-0.0003,-0.007,-0.014 +units=m";
+            case 3301 : return "+proj=lcc +lat_1=59.33333333333334 +lat_2=58 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3302 : return "+proj=utm +zone=7 +south +ellps=intl +units=m";
+            case 3303 : return "+proj=utm +zone=7 +south +ellps=intl +towgs84=347.103,1078.12,2623.92,-33.8875,70.6773,-9.3943,186.074 +units=m";
+            case 3304 : return "+proj=utm +zone=6 +south +ellps=intl +units=m";
+            case 3305 : return "+proj=utm +zone=6 +south +ellps=intl +towgs84=215.525,149.593,176.229,-3.2624,-1.692,-1.1571,10.4773 +units=m";
+            case 3306 : return "+proj=utm +zone=5 +south +ellps=intl +towgs84=217.037,86.959,23.956,0,0,0,0 +units=m";
+            case 3307 : return "+proj=utm +zone=39 +ellps=WGS84 +towgs84=0,-0.15,0.68,0,0,0,0 +units=m";
+            case 3308 : return "+proj=lcc +lat_1=-30.75 +lat_2=-35.75 +lat_0=-33.25 +lon_0=147 +x_0=9300000 +y_0=4500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3309 : return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 3310 : return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3311 : return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +units=m";
+            case 3312 : return "+proj=utm +zone=21 +ellps=intl +towgs84=-186,230,110,0,0,0,0 +units=m";
+            case 3313 : return "+proj=utm +zone=21 +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0 +units=m";
+            case 3314 : return "+proj=lcc +lat_1=-6.5 +lat_2=-11.5 +lat_0=0 +lon_0=26 +x_0=0 +y_0=0 +ellps=clrk66 +units=m";
+            case 3315 : return "+proj=tmerc +lat_0=-9 +lon_0=26 +k=0.9998 +x_0=0 +y_0=0 +ellps=clrk66 +units=m";
+            case 3316 : return "+proj=tmerc +lat_0=0 +lon_0=22 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3317 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3318 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3319 : return "+proj=tmerc +lat_0=0 +lon_0=14 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3320 : return "+proj=tmerc +lat_0=0 +lon_0=16 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3321 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3322 : return "+proj=tmerc +lat_0=0 +lon_0=20 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3323 : return "+proj=tmerc +lat_0=0 +lon_0=22 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3324 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3325 : return "+proj=tmerc +lat_0=0 +lon_0=26 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3326 : return "+proj=tmerc +lat_0=0 +lon_0=28 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3327 : return "+proj=tmerc +lat_0=0 +lon_0=30 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 3328 : return "+proj=sterea +lat_0=52.16666666666666 +lon_0=19.16666666666667 +k=0.999714 +x_0=500000 +y_0=500000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3329 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3330 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=6500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3331 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=7500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3332 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3333 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=3500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3334 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3335 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+            case 3336 : return "+proj=utm +zone=42 +south +ellps=intl +towgs84=145,-187,103,0,0,0,0 +units=m";
+            case 3337 : return "+proj=lcc +lat_1=-20.19506944444445 +lat_0=-20.19506944444445 +lon_0=57.52182777777778 +k_0=1 +x_0=1000000 +y_0=1000000 +ellps=clrk80 +towgs84=-770.1,158.4,-498.2,0,0,0,0 +units=m";
+            case 3338 : return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3339 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +towgs84=-79.9,-158,-168.9,0,0,0,0 +units=m";
+            case 3340 : return "+proj=tmerc +lat_0=0 +lon_0=14 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +towgs84=-79.9,-158,-168.9,0,0,0,0 +units=m";
+            case 3341 : return "+proj=tmerc +lat_0=0 +lon_0=16 +k=0.9999 +x_0=500000 +y_0=10000000 +ellps=clrk80 +towgs84=-79.9,-158,-168.9,0,0,0,0 +units=m";
+            case 3342 : return "+proj=utm +zone=33 +south +ellps=clrk80 +towgs84=-79.9,-158,-168.9,0,0,0,0 +units=m";
+            case 3343 : return "+proj=utm +zone=28 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3344 : return "+proj=utm +zone=29 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3345 : return "+proj=utm +zone=30 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3346 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9998 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3347 : return "+proj=lcc +lat_1=49 +lat_2=77 +lat_0=63.390675 +lon_0=-91.86666666666666 +x_0=6200000 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3348 : return "+proj=lcc +lat_1=49 +lat_2=77 +lat_0=63.390675 +lon_0=-91.86666666666666 +x_0=6200000 +y_0=3000000 +ellps=GRS80 +units=m";
+            case 3349 : return "+proj=merc +lon_0=-150 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3350 : return "+proj=tmerc +lat_0=0.1 +lon_0=21.95 +k=1 +x_0=250000 +y_0=0 +ellps=krass +units=m";
+            case 3351 : return "+proj=tmerc +lat_0=0.1 +lon_0=24.95 +k=1 +x_0=1250000 +y_0=0 +ellps=krass +units=m";
+            case 3352 : return "+proj=tmerc +lat_0=0.1 +lon_0=27.95 +k=1 +x_0=2250000 +y_0=0 +ellps=krass +units=m";
+            case 3353 : return "+proj=utm +zone=32 +south +ellps=intl +units=m";
+            case 3354 : return "+proj=utm +zone=32 +south +ellps=intl +units=m";
+            case 3355 : return "+proj=tmerc +lat_0=30 +lon_0=31 +k=1 +x_0=615000 +y_0=810000 +ellps=helmert +towgs84=-146.21,112.63,4.05,0,0,0,0 +units=m";
+            case 3356 : return "+proj=utm +zone=17 +ellps=clrk66 +towgs84=67.8,106.1,138.8,0,0,0,0 +units=m";
+            case 3357 : return "+proj=utm +zone=17 +ellps=clrk66 +units=m";
+            case 3358 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80 +units=m";
+            case 3359 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.2192024385 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 3360 : return "+proj=lcc +lat_1=34.83333333333334 +lat_2=32.5 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609600 +y_0=0 +ellps=GRS80 +units=m";
+            case 3361 : return "+proj=lcc +lat_1=34.83333333333334 +lat_2=32.5 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609600 +y_0=0 +ellps=GRS80 +to_meter=0.3048";
+            case 3362 : return "+proj=lcc +lat_1=41.95 +lat_2=40.88333333333333 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3363 : return "+proj=lcc +lat_1=41.95 +lat_2=40.88333333333333 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3364 : return "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3365 : return "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3366 : return "+proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +units=m";
+            case 3367 : return "+proj=utm +zone=28 +ellps=clrk80 +units=m";
+            case 3368 : return "+proj=utm +zone=29 +ellps=clrk80 +units=m";
+            case 3369 : return "+proj=utm +zone=30 +ellps=clrk80 +units=m";
+            case 3370 : return "+proj=utm +zone=59 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 3371 : return "+proj=utm +zone=60 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 3372 : return "+proj=utm +zone=59 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3373 : return "+proj=utm +zone=60 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3374 : return "+proj=utm +zone=29 +ellps=intl +units=m";
+            case 3375 : return "+proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257964666666 +k=0.99984 +x_0=804671 +y_0=0 +ellps=GRS80 +units=m";
+            case 3376 : return "+proj=omerc +lat_0=4 +lonc=115 +alpha=53.31580995 +k=0.99984 +x_0=0 +y_0=0 +ellps=GRS80 +units=m";
+            case 3377 : return "+proj=cass +lat_0=2.121679744444445 +lon_0=103.4279362361111 +x_0=-14810.562 +y_0=8758.32 +ellps=GRS80 +units=m";
+            case 3378 : return "+proj=cass +lat_0=2.682347636111111 +lon_0=101.9749050416667 +x_0=3673.785 +y_0=-4240.573 +ellps=GRS80 +units=m";
+            case 3379 : return "+proj=cass +lat_0=3.769388088888889 +lon_0=102.3682989833333 +x_0=-7368.228 +y_0=6485.858 +ellps=GRS80 +units=m";
+            case 3380 : return "+proj=cass +lat_0=3.68464905 +lon_0=101.3891079138889 +x_0=-34836.161 +y_0=56464.049 +ellps=GRS80 +units=m";
+            case 3381 : return "+proj=cass +lat_0=4.9762852 +lon_0=103.070275625 +x_0=19594.245 +y_0=3371.895 +ellps=GRS80 +units=m";
+            case 3382 : return "+proj=cass +lat_0=5.421517541666667 +lon_0=100.3443769638889 +x_0=-23.414 +y_0=62.283 +ellps=GRS80 +units=m";
+            case 3383 : return "+proj=cass +lat_0=5.964672713888889 +lon_0=100.6363711111111 +x_0=0 +y_0=0 +ellps=GRS80 +units=m";
+            case 3384 : return "+proj=cass +lat_0=4.859063022222222 +lon_0=100.8154105861111 +x_0=-1.769 +y_0=133454.779 +ellps=GRS80 +units=m";
+            case 3385 : return "+proj=cass +lat_0=5.972543658333334 +lon_0=102.2952416694444 +x_0=13227.851 +y_0=8739.894 +ellps=GRS80 +units=m";
+            case 3386 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=500000 +y_0=0 +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964 +units=m";
+            case 3387 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=5500000 +y_0=0 +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964 +units=m";
+            case 3388 : return "+proj=merc +lon_0=51 +k=1 +x_0=0 +y_0=0 +ellps=krass +units=m";
+            case 3389 : return "+proj=tmerc +lat_0=0 +lon_0=180 +k=1 +x_0=60500000 +y_0=0 +ellps=krass +units=m";
+            case 3390 : return "+proj=tmerc +lat_0=0 +lon_0=180 +k=1 +x_0=60500000 +y_0=0 +ellps=krass +units=m";
+            case 3391 : return "+proj=utm +zone=37 +ellps=clrk80 +towgs84=84.1,-320.1,218.7,0,0,0,0 +units=m";
+            case 3392 : return "+proj=utm +zone=38 +ellps=clrk80 +towgs84=84.1,-320.1,218.7,0,0,0,0 +units=m";
+            case 3393 : return "+proj=utm +zone=39 +ellps=clrk80 +towgs84=84.1,-320.1,218.7,0,0,0,0 +units=m";
+            case 3394 : return "+proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=45 +k_0=0.9987864078000001 +x_0=1500000 +y_0=1166200 +ellps=clrk80 +units=m";
+            case 3395 : return "+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3396 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +units=m";
+            case 3397 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +units=m";
+            case 3398 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +units=m";
+            case 3399 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=bessel +units=m";
+            case 3400 : return "+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3401 : return "+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3402 : return "+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3403 : return "+proj=tmerc +lat_0=0 +lon_0=-115 +k=0.9992 +x_0=0 +y_0=0 +ellps=GRS80 +units=m";
+            case 3404 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.2192024384 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3405 : return "+proj=utm +zone=48 +ellps=WGS84 +units=m";
+            case 3406 : return "+proj=utm +zone=49 +ellps=WGS84 +units=m";
+            case 3407 : return "+proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654";
+            case 3408 : return "+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m";
+            case 3409 : return "+proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +a=6371228 +b=6371228 +units=m";
+            case 3411 : return "+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m";
+            case 3412 : return "+proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m";
+            case 3413 : return "+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3414 : return "+proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m";
+            case 3415 : return "+proj=lcc +lat_1=18 +lat_2=24 +lat_0=21 +lon_0=114 +x_0=500000 +y_0=500000 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 3416 : return "+proj=lcc +lat_1=49 +lat_2=46 +lat_0=47.5 +lon_0=13.33333333333333 +x_0=400000 +y_0=400000 +ellps=GRS80 +units=m";
+            case 3417 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=1500000 +y_0=999999.9999898402 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3418 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=500000.00001016 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3419 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3420 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=399999.99998984 +y_0=399999.99998984 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3421 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=200000.00001016 +y_0=8000000.000010163 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3422 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=500000.00001016 +y_0=6000000 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3423 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=800000.0000101599 +y_0=3999999.99998984 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3424 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3425 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=1500000 +y_0=999999.9999898402 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3426 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=500000.00001016 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3427 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3428 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=399999.99998984 +y_0=399999.99998984 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3429 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=200000.00001016 +y_0=8000000.000010163 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3430 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=500000.00001016 +y_0=6000000 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3431 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=800000.0000101599 +y_0=3999999.99998984 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3432 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3433 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3434 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=399999.99998984 +y_0=399999.99998984 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3435 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3436 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=699999.9999898402 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3437 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3438 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.99999375 +x_0=99999.99998983997 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3439 : return "+proj=utm +zone=39 +ellps=clrk80 +units=m";
+            case 3440 : return "+proj=utm +zone=40 +ellps=clrk80 +units=m";
+            case 3441 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3442 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=399999.99998984 +y_0=399999.99998984 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3443 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3444 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=699999.9999898402 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3445 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3446 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.99999375 +x_0=99999.99998983997 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3447 : return "+proj=lcc +lat_1=49.83333333333334 +lat_2=51.16666666666666 +lat_0=50.797815 +lon_0=4.359215833333333 +x_0=150328 +y_0=166262 +ellps=GRS80 +units=m";
+            case 3448 : return "+proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77 +k_0=1 +x_0=750000 +y_0=650000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3449 : return "+proj=utm +zone=17 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3450 : return "+proj=utm +zone=18 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3451 : return "+proj=lcc +lat_1=32.66666666666666 +lat_2=31.16666666666667 +lat_0=30.5 +lon_0=-92.5 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3452 : return "+proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3453 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.5 +lon_0=-91.33333333333333 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3454 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3455 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3456 : return "+proj=lcc +lat_1=32.66666666666666 +lat_2=31.16666666666667 +lat_0=30.5 +lon_0=-92.5 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3457 : return "+proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3458 : return "+proj=lcc +lat_1=45.68333333333333 +lat_2=44.41666666666666 +lat_0=43.83333333333334 +lon_0=-100 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3459 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3460 : return "+proj=tmerc +lat_0=-17 +lon_0=178.75 +k=0.99985 +x_0=2000000 +y_0=4000000 +ellps=WGS72 +units=m";
+            case 3461 : return "+proj=utm +zone=28 +a=6378249.2 +b=6356515 +towgs84=-83,37,124,0,0,0,0 +units=m";
+            case 3462 : return "+proj=utm +zone=29 +a=6378249.2 +b=6356515 +towgs84=-83,37,124,0,0,0,0 +units=m";
+            case 3463 : return "+proj=tmerc +lat_0=43.5 +lon_0=-69.125 +k=0.99998 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3464 : return "+proj=tmerc +lat_0=43.5 +lon_0=-69.125 +k=0.99998 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 3465 : return "+proj=tmerc +lat_0=30.5 +lon_0=-85.83333333333333 +k=0.99996 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3466 : return "+proj=tmerc +lat_0=30 +lon_0=-87.5 +k=0.999933333 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3467 : return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3468 : return "+proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000 +y_0=-5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3469 : return "+proj=tmerc +lat_0=54 +lon_0=-142 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3470 : return "+proj=tmerc +lat_0=54 +lon_0=-146 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3471 : return "+proj=tmerc +lat_0=54 +lon_0=-150 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3472 : return "+proj=tmerc +lat_0=54 +lon_0=-154 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3473 : return "+proj=tmerc +lat_0=54 +lon_0=-158 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3474 : return "+proj=tmerc +lat_0=54 +lon_0=-162 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3475 : return "+proj=tmerc +lat_0=54 +lon_0=-166 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3476 : return "+proj=tmerc +lat_0=54 +lon_0=-170 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3477 : return "+proj=lcc +lat_1=53.83333333333334 +lat_2=51.83333333333334 +lat_0=51 +lon_0=-176 +x_0=1000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3478 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3479 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3480 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3481 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3482 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=213360 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3483 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=213360 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3484 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3485 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3486 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=400000 +y_0=400000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3487 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=399999.99998984 +y_0=399999.99998984 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3488 : return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3489 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3490 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3491 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3492 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3493 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3494 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3495 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3496 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3497 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3498 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3499 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=2000000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3500 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=2000000.0001016 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3501 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3502 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3503 : return "+proj=lcc +lat_1=40.78333333333333 +lat_2=39.71666666666667 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3504 : return "+proj=lcc +lat_1=40.78333333333333 +lat_2=39.71666666666667 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3505 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3506 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=914401.8288036576 +y_0=304800.6096012192 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3507 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=304800.6096 +y_0=152400.3048 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3508 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=304800.6096012192 +y_0=152400.3048006096 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3509 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3510 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3511 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3512 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3513 : return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3514 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3515 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3516 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3517 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3518 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3519 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3520 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=700000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3521 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=699999.9998983998 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3522 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3523 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3524 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3525 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=200000.0001016002 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3526 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=800000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3527 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=800000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3528 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3529 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3530 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=700000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3531 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=699999.9999898402 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3532 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=100000 +y_0=250000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3533 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=99999.99989839978 +y_0=249999.9998983998 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3534 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=250000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3535 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=249999.9998983998 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3536 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=1500000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3537 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=1500000 +y_0=999999.9999898402 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3538 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3539 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=500000.00001016 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3540 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3541 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=399999.99998984 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3542 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=400000 +y_0=400000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3543 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=399999.99998984 +y_0=399999.99998984 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3544 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3545 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3546 : return "+proj=lcc +lat_1=37.08333333333334 +lat_2=38.66666666666666 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=1500000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3547 : return "+proj=lcc +lat_1=37.08333333333334 +lat_2=38.66666666666666 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=1500000 +y_0=999999.9998983998 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3548 : return "+proj=lcc +lat_1=37.93333333333333 +lat_2=36.73333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=500000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3549 : return "+proj=lcc +lat_1=37.93333333333333 +lat_2=36.73333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=500000.0001016001 +y_0=500000.0001016001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3550 : return "+proj=lcc +lat_1=32.66666666666666 +lat_2=31.16666666666667 +lat_0=30.5 +lon_0=-92.5 +x_0=1000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3551 : return "+proj=lcc +lat_1=32.66666666666666 +lat_2=31.16666666666667 +lat_0=30.5 +lon_0=-92.5 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3552 : return "+proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=1000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3553 : return "+proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=999999.9999898402 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3554 : return "+proj=tmerc +lat_0=43.5 +lon_0=-69.125 +k=0.99998 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3555 : return "+proj=tmerc +lat_0=43.83333333333334 +lon_0=-67.875 +k=0.99998 +x_0=700000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3556 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.375 +k=0.99998 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3557 : return "+proj=tmerc +lat_0=43.66666666666666 +lon_0=-68.5 +k=0.9999 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3558 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.16666666666667 +k=0.999966667 +x_0=900000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3559 : return "+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3560 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000.00001016 +y_0=999999.9999898402 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3561 : return "+proj=tmerc +lat_0=18.83333333333333 +lon_0=-155.5 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +to_meter=0.3048006096012192";
+            case 3562 : return "+proj=tmerc +lat_0=20.33333333333333 +lon_0=-156.6666666666667 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +to_meter=0.3048006096012192";
+            case 3563 : return "+proj=tmerc +lat_0=21.16666666666667 +lon_0=-158 +k=0.99999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +to_meter=0.3048006096012192";
+            case 3564 : return "+proj=tmerc +lat_0=21.83333333333333 +lon_0=-159.5 +k=0.99999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +to_meter=0.3048006096012192";
+            case 3565 : return "+proj=tmerc +lat_0=21.66666666666667 +lon_0=-160.1666666666667 +k=1 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +to_meter=0.3048006096012192";
+            case 3566 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000.00001016 +y_0=2000000.00001016 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3567 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000.00001016 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3568 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000.00001016 +y_0=999999.9999898402 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3569 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000.00001016 +y_0=2000000.00001016 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3570 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000.00001016 +y_0=3000000 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3571 : return "+proj=laea +lat_0=90 +lon_0=180 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3572 : return "+proj=laea +lat_0=90 +lon_0=-150 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3573 : return "+proj=laea +lat_0=90 +lon_0=-100 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3574 : return "+proj=laea +lat_0=90 +lon_0=-40 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3575 : return "+proj=laea +lat_0=90 +lon_0=10 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3576 : return "+proj=laea +lat_0=90 +lon_0=90 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3577 : return "+proj=aea +lat_1=-18 +lat_2=-36 +lat_0=0 +lon_0=132 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3578 : return "+proj=aea +lat_1=61.66666666666666 +lat_2=68 +lat_0=59 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3579 : return "+proj=aea +lat_1=61.66666666666666 +lat_2=68 +lat_0=59 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +units=m";
+            case 3580 : return "+proj=lcc +lat_1=62 +lat_2=70 +lat_0=0 +lon_0=-112 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 3581 : return "+proj=lcc +lat_1=62 +lat_2=70 +lat_0=0 +lon_0=-112 +x_0=0 +y_0=0 +ellps=GRS80 +units=m";
+            case 3582 : return "+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=399999.9998983998 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3583 : return "+proj=lcc +lat_1=41.48333333333333 +lat_2=41.28333333333333 +lat_0=41 +lon_0=-70.5 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3584 : return "+proj=lcc +lat_1=41.48333333333333 +lat_2=41.28333333333333 +lat_0=41 +lon_0=-70.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3585 : return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3586 : return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000.0001016002 +y_0=750000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3587 : return "+proj=lcc +lat_1=45.7 +lat_2=44.18333333333333 +lat_0=43.31666666666667 +lon_0=-84.36666666666666 +x_0=6000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3588 : return "+proj=lcc +lat_1=45.7 +lat_2=44.18333333333333 +lat_0=43.31666666666667 +lon_0=-84.36666666666666 +x_0=5999999.999976001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3589 : return "+proj=lcc +lat_1=47.08333333333334 +lat_2=45.48333333333333 +lat_0=44.78333333333333 +lon_0=-87 +x_0=8000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3590 : return "+proj=lcc +lat_1=47.08333333333334 +lat_2=45.48333333333333 +lat_0=44.78333333333333 +lon_0=-87 +x_0=7999999.999968001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3591 : return "+proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3592 : return "+proj=lcc +lat_1=43.66666666666666 +lat_2=42.1 +lat_0=41.5 +lon_0=-84.36666666666666 +x_0=4000000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3593 : return "+proj=lcc +lat_1=43.66666666666666 +lat_2=42.1 +lat_0=41.5 +lon_0=-84.36666666666666 +x_0=3999999.999984 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3594 : return "+proj=lcc +lat_1=47.05 +lat_2=45.61666666666667 +lat_0=45 +lon_0=-94.25 +x_0=800000 +y_0=100000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3595 : return "+proj=lcc +lat_1=48.63333333333333 +lat_2=47.03333333333333 +lat_0=46.5 +lon_0=-93.09999999999999 +x_0=800000 +y_0=100000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3596 : return "+proj=lcc +lat_1=45.21666666666667 +lat_2=43.78333333333333 +lat_0=43 +lon_0=-94 +x_0=800000 +y_0=100000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3597 : return "+proj=tmerc +lat_0=29.5 +lon_0=-88.83333333333333 +k=0.99995 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3598 : return "+proj=tmerc +lat_0=29.5 +lon_0=-88.83333333333333 +k=0.99995 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3599 : return "+proj=tmerc +lat_0=29.5 +lon_0=-90.33333333333333 +k=0.99995 +x_0=700000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3600 : return "+proj=tmerc +lat_0=29.5 +lon_0=-90.33333333333333 +k=0.99995 +x_0=699999.9998983998 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3601 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-92.5 +k=0.999933333 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3602 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.999933333 +x_0=250000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3603 : return "+proj=tmerc +lat_0=36.16666666666666 +lon_0=-94.5 +k=0.999941177 +x_0=850000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3604 : return "+proj=lcc +lat_1=49 +lat_2=45 +lat_0=44.25 +lon_0=-109.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3605 : return "+proj=lcc +lat_1=49 +lat_2=45 +lat_0=44.25 +lon_0=-109.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3606 : return "+proj=lcc +lat_1=43 +lat_2=40 +lat_0=39.83333333333334 +lon_0=-100 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3607 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=500000 +y_0=6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3608 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=500000.00001016 +y_0=6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3609 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=200000 +y_0=8000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3610 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=200000.00001016 +y_0=8000000.000010163 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3611 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=800000 +y_0=4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3612 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=800000.0000101599 +y_0=3999999.99998984 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3613 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3614 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3615 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3616 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3617 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3618 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3619 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=165000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3620 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=165000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3621 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=830000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3622 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=830000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3623 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=250000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3624 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=249999.9998983998 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3625 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3626 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3627 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3628 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3629 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3630 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3631 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3632 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.2192024384 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3633 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.43333333333333 +lat_0=47 +lon_0=-100.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3634 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.43333333333333 +lat_0=47 +lon_0=-100.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3635 : return "+proj=lcc +lat_1=47.48333333333333 +lat_2=46.18333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3636 : return "+proj=lcc +lat_1=47.48333333333333 +lat_2=46.18333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=599999.9999976 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3637 : return "+proj=lcc +lat_1=41.7 +lat_2=40.43333333333333 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3638 : return "+proj=lcc +lat_1=40.03333333333333 +lat_2=38.73333333333333 +lat_0=38 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3639 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=35.56666666666667 +lat_0=35 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3640 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=35.56666666666667 +lat_0=35 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3641 : return "+proj=lcc +lat_1=35.23333333333333 +lat_2=33.93333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3642 : return "+proj=lcc +lat_1=35.23333333333333 +lat_2=33.93333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3643 : return "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3644 : return "+proj=lcc +lat_1=43 +lat_2=45.5 +lat_0=41.75 +lon_0=-120.5 +x_0=399999.9999984 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3645 : return "+proj=lcc +lat_1=46 +lat_2=44.33333333333334 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3646 : return "+proj=lcc +lat_1=46 +lat_2=44.33333333333334 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000.0001424 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3647 : return "+proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3648 : return "+proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000.0001464 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3649 : return "+proj=lcc +lat_1=41.95 +lat_2=40.88333333333333 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3650 : return "+proj=lcc +lat_1=41.95 +lat_2=40.88333333333333 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3651 : return "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3652 : return "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3653 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.99999375 +x_0=100000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3654 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.99999375 +x_0=99999.99998983997 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3655 : return "+proj=lcc +lat_1=34.83333333333334 +lat_2=32.5 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609600 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3656 : return "+proj=lcc +lat_1=34.83333333333334 +lat_2=32.5 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609600 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3657 : return "+proj=lcc +lat_1=45.68333333333333 +lat_2=44.41666666666666 +lat_0=43.83333333333334 +lon_0=-100 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3658 : return "+proj=lcc +lat_1=45.68333333333333 +lat_2=44.41666666666666 +lat_0=43.83333333333334 +lon_0=-100 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3659 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3660 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3661 : return "+proj=lcc +lat_1=36.41666666666666 +lat_2=35.25 +lat_0=34.33333333333334 +lon_0=-86 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3662 : return "+proj=lcc +lat_1=36.41666666666666 +lat_2=35.25 +lat_0=34.33333333333334 +lon_0=-86 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3663 : return "+proj=lcc +lat_1=31.88333333333333 +lat_2=30.11666666666667 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=700000 +y_0=3000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3664 : return "+proj=lcc +lat_1=31.88333333333333 +lat_2=30.11666666666667 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=699999.9998983998 +y_0=3000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3665 : return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3666 : return "+proj=lcc +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3667 : return "+proj=lcc +lat_1=36.18333333333333 +lat_2=34.65 +lat_0=34 +lon_0=-101.5 +x_0=200000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3668 : return "+proj=lcc +lat_1=36.18333333333333 +lat_2=34.65 +lat_0=34 +lon_0=-101.5 +x_0=200000.0001016002 +y_0=999999.9998983998 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3669 : return "+proj=lcc +lat_1=33.96666666666667 +lat_2=32.13333333333333 +lat_0=31.66666666666667 +lon_0=-98.5 +x_0=600000 +y_0=2000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3670 : return "+proj=lcc +lat_1=33.96666666666667 +lat_2=32.13333333333333 +lat_0=31.66666666666667 +lon_0=-98.5 +x_0=600000 +y_0=2000000.0001016 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3671 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=300000 +y_0=5000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3672 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=300000.0000000001 +y_0=5000000.0001016 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3673 : return "+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3674 : return "+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=3999999.9998984 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3675 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000 +y_0=2000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3676 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000.0001504 +y_0=1999999.999992 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3677 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000.00001016 +y_0=2000000.00001016 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3678 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3679 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000.0001504 +y_0=999999.9999960001 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3680 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000.00001016 +y_0=999999.9999898402 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3681 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000 +y_0=3000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3682 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000.0001504 +y_0=2999999.999988 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048";
+            case 3683 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000.00001016 +y_0=3000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3684 : return "+proj=tmerc +lat_0=42.5 +lon_0=-72.5 +k=0.999964286 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3685 : return "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000 +y_0=2000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3686 : return "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=2000000.0001016 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3687 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3688 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000.0001016 +y_0=999999.9998983998 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3689 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3690 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3691 : return "+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3692 : return "+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3693 : return "+proj=lcc +lat_1=40.25 +lat_2=39 +lat_0=38.5 +lon_0=-79.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3694 : return "+proj=lcc +lat_1=38.88333333333333 +lat_2=37.48333333333333 +lat_0=37 +lon_0=-81 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3695 : return "+proj=lcc +lat_1=45.5 +lat_2=44.25 +lat_0=43.83333333333334 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3696 : return "+proj=lcc +lat_1=45.5 +lat_2=44.25 +lat_0=43.83333333333334 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3697 : return "+proj=lcc +lat_1=46.76666666666667 +lat_2=45.56666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3698 : return "+proj=lcc +lat_1=46.76666666666667 +lat_2=45.56666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3699 : return "+proj=lcc +lat_1=44.06666666666667 +lat_2=42.73333333333333 +lat_0=42 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3700 : return "+proj=lcc +lat_1=44.06666666666667 +lat_2=42.73333333333333 +lat_0=42 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3701 : return "+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9996 +x_0=520000 +y_0=-4480000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3702 : return "+proj=tmerc +lat_0=40.5 +lon_0=-105.1666666666667 +k=0.9999375 +x_0=200000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3703 : return "+proj=tmerc +lat_0=40.5 +lon_0=-107.3333333333333 +k=0.9999375 +x_0=400000 +y_0=100000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3704 : return "+proj=tmerc +lat_0=40.5 +lon_0=-108.75 +k=0.9999375 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3705 : return "+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 +x_0=800000 +y_0=100000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3706 : return "+proj=utm +zone=59 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3707 : return "+proj=utm +zone=60 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3708 : return "+proj=utm +zone=1 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3709 : return "+proj=utm +zone=2 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3710 : return "+proj=utm +zone=3 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3711 : return "+proj=utm +zone=4 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3712 : return "+proj=utm +zone=5 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3713 : return "+proj=utm +zone=6 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3714 : return "+proj=utm +zone=7 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3715 : return "+proj=utm +zone=8 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3716 : return "+proj=utm +zone=9 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3717 : return "+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3718 : return "+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3719 : return "+proj=utm +zone=12 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3720 : return "+proj=utm +zone=13 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3721 : return "+proj=utm +zone=14 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3722 : return "+proj=utm +zone=15 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3723 : return "+proj=utm +zone=16 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3724 : return "+proj=utm +zone=17 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3725 : return "+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3726 : return "+proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 3727 : return "+proj=tmerc +lat_0=-21.11666666666667 +lon_0=55.53333333333333 +k=1 +x_0=160000 +y_0=50000 +ellps=intl +units=m";
+            case 3728 : return "+proj=lcc +lat_1=41.7 +lat_2=40.43333333333333 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3729 : return "+proj=lcc +lat_1=40.03333333333333 +lat_2=38.73333333333333 +lat_0=38 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3730 : return "+proj=tmerc +lat_0=40.5 +lon_0=-105.1666666666667 +k=0.9999375 +x_0=200000.00001016 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3731 : return "+proj=tmerc +lat_0=40.5 +lon_0=-107.3333333333333 +k=0.9999375 +x_0=399999.99998984 +y_0=99999.99998983997 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3732 : return "+proj=tmerc +lat_0=40.5 +lon_0=-108.75 +k=0.9999375 +x_0=600000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3733 : return "+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 +x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3734 : return "+proj=lcc +lat_1=41.7 +lat_2=40.43333333333333 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3735 : return "+proj=lcc +lat_1=40.03333333333333 +lat_2=38.73333333333333 +lat_0=38 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3736 : return "+proj=tmerc +lat_0=40.5 +lon_0=-105.1666666666667 +k=0.9999375 +x_0=200000.00001016 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3737 : return "+proj=tmerc +lat_0=40.5 +lon_0=-107.3333333333333 +k=0.9999375 +x_0=399999.99998984 +y_0=99999.99998983997 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3738 : return "+proj=tmerc +lat_0=40.5 +lon_0=-108.75 +k=0.9999375 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3739 : return "+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 +x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3740 : return "+proj=utm +zone=10 +ellps=GRS80 +units=m";
+            case 3741 : return "+proj=utm +zone=11 +ellps=GRS80 +units=m";
+            case 3742 : return "+proj=utm +zone=12 +ellps=GRS80 +units=m";
+            case 3743 : return "+proj=utm +zone=13 +ellps=GRS80 +units=m";
+            case 3744 : return "+proj=utm +zone=14 +ellps=GRS80 +units=m";
+            case 3745 : return "+proj=utm +zone=15 +ellps=GRS80 +units=m";
+            case 3746 : return "+proj=utm +zone=16 +ellps=GRS80 +units=m";
+            case 3747 : return "+proj=utm +zone=17 +ellps=GRS80 +units=m";
+            case 3748 : return "+proj=utm +zone=18 +ellps=GRS80 +units=m";
+            case 3749 : return "+proj=utm +zone=19 +ellps=GRS80 +units=m";
+            case 3750 : return "+proj=utm +zone=4 +ellps=GRS80 +units=m";
+            case 3751 : return "+proj=utm +zone=5 +ellps=GRS80 +units=m";
+            case 3752 : return "+proj=merc +lon_0=100 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3753 : return "+proj=lcc +lat_1=41.7 +lat_2=40.43333333333333 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3754 : return "+proj=lcc +lat_1=40.03333333333333 +lat_2=38.73333333333333 +lat_0=38 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3755 : return "+proj=tmerc +lat_0=40.5 +lon_0=-105.1666666666667 +k=0.9999375 +x_0=200000.00001016 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3756 : return "+proj=tmerc +lat_0=40.5 +lon_0=-107.3333333333333 +k=0.9999375 +x_0=399999.99998984 +y_0=99999.99998983997 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3757 : return "+proj=tmerc +lat_0=40.5 +lon_0=-108.75 +k=0.9999375 +x_0=600000 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3758 : return "+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 +x_0=800000.0000101599 +y_0=99999.99998983997 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3759 : return "+proj=tmerc +lat_0=21.16666666666667 +lon_0=-158 +k=0.99999 +x_0=500000.00001016 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 3760 : return "+proj=tmerc +lat_0=21.16666666666667 +lon_0=-158 +k=0.99999 +x_0=500000.00001016 +y_0=0 +ellps=GRS80 +to_meter=0.3048006096012192";
+            case 3761 : return "+proj=utm +zone=22 +ellps=GRS80 +units=m";
+            case 3762 : return "+proj=lcc +lat_1=-54 +lat_2=-54.75 +lat_0=-55 +lon_0=-37 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 3920 : return "+proj=utm +zone=20 +ellps=clrk66 +towgs84=11,72,-101,0,0,0,0 +units=m";
+            case 3991 : return "+proj=lcc +lat_1=18.43333333333333 +lat_2=18.03333333333333 +lat_0=17.83333333333333 +lon_0=-66.43333333333334 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +towgs84=11,72,-101,0,0,0,0 +to_meter=0.3048006096012192";
+            case 3992 : return "+proj=lcc +lat_1=18.43333333333333 +lat_2=18.03333333333333 +lat_0=17.83333333333333 +lon_0=-66.43333333333334 +x_0=152400.3048006096 +y_0=30480.06096012192 +ellps=clrk66 +towgs84=11,72,-101,0,0,0,0 +to_meter=0.3048006096012192";
+            case 4001 : return "+proj=longlat +ellps=airy";
+            case 4002 : return "+proj=longlat +a=6377340.189 +b=6356034.447938534";
+            case 4003 : return "+proj=longlat +ellps=aust_SA";
+            case 4004 : return "+proj=longlat +ellps=bessel";
+            case 4005 : return "+proj=longlat +a=6377492.018 +b=6356173.508712696";
+            case 4006 : return "+proj=longlat +ellps=bess_nam";
+            case 4007 : return "+proj=longlat +a=6378293.645208759 +b=6356617.987679838";
+            case 4008 : return "+proj=longlat +ellps=clrk66";
+            case 4009 : return "+proj=longlat +a=6378450.047548896 +b=6356826.621488444";
+            case 4010 : return "+proj=longlat +a=6378300.789 +b=6356566.435";
+            case 4011 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4012 : return "+proj=longlat +ellps=clrk80";
+            case 4013 : return "+proj=longlat +a=6378249.145 +b=6356514.966398753";
+            case 4014 : return "+proj=longlat +a=6378249.2 +b=6356514.996941779";
+            case 4015 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024";
+            case 4016 : return "+proj=longlat +ellps=evrstSS";
+            case 4018 : return "+proj=longlat +a=6377304.063 +b=6356103.038993155";
+            case 4019 : return "+proj=longlat +ellps=GRS80";
+            case 4020 : return "+proj=longlat +ellps=helmert";
+            case 4021 : return "+proj=longlat +a=6378160 +b=6356774.50408554";
+            case 4022 : return "+proj=longlat +ellps=intl";
+            case 4024 : return "+proj=longlat +ellps=krass";
+            case 4025 : return "+proj=longlat +ellps=WGS66";
+            case 4027 : return "+proj=longlat +a=6376523 +b=6355862.933255573";
+            case 4028 : return "+proj=longlat +a=6378298.3 +b=6356657.142669561";
+            case 4029 : return "+proj=longlat +a=6378300 +b=6356751.689189189";
+            case 4030 : return "+proj=longlat +ellps=WGS84";
+            case 4031 : return "+proj=longlat +ellps=WGS84";
+            case 4032 : return "+proj=longlat +a=6378136.2 +b=6356751.516927429";
+            case 4033 : return "+proj=longlat +a=6378136.3 +b=6356751.616592146";
+            case 4034 : return "+proj=longlat +ellps=clrk80";
+            case 4035 : return "+proj=longlat +a=6371000 +b=6371000";
+            case 4036 : return "+proj=longlat +ellps=GRS67";
+            case 4041 : return "+proj=longlat +a=6378135 +b=6356750.304921594";
+            case 4042 : return "+proj=longlat +a=6377299.36559538 +b=6356098.357204818";
+            case 4043 : return "+proj=longlat +ellps=WGS72";
+            case 4044 : return "+proj=longlat +a=6377301.243 +b=6356100.230165384";
+            case 4045 : return "+proj=longlat +a=6377299.151 +b=6356098.145120132";
+            case 4047 : return "+proj=longlat +a=6371007 +b=6371007";
+            case 4052 : return "+proj=longlat +a=6370997 +b=6370997";
+            case 4053 : return "+proj=longlat +a=6371228 +b=6371228";
+            case 4054 : return "+proj=longlat +a=6378273 +b=6356889.449";
+            case 4120 : return "+proj=longlat +ellps=bessel";
+            case 4121 : return "+proj=longlat +ellps=GRS80 +towgs84=-199.87,74.79,246.62,0,0,0,0";
+            case 4122 : return "+proj=longlat +a=6378135 +b=6356750.304921594";
+            case 4123 : return "+proj=longlat +ellps=intl +towgs84=-96.0617,-82.4278,-121.743,4.80107,0.34543,-1.37646,1.4964";
+            case 4124 : return "+proj=longlat +ellps=bessel";
+            case 4125 : return "+proj=longlat +ellps=bessel +towgs84=-404.78,685.68,45.47,0,0,0,0";
+            case 4126 : return "+proj=longlat +ellps=GRS80";
+            case 4127 : return "+proj=longlat +ellps=clrk66";
+            case 4128 : return "+proj=longlat +ellps=clrk66";
+            case 4129 : return "+proj=longlat +ellps=clrk66";
+            case 4130 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,-0,-0,-0,0";
+            case 4131 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024";
+            case 4132 : return "+proj=longlat +ellps=clrk80";
+            case 4133 : return "+proj=longlat +ellps=GRS80 +towgs84=0.055,-0.541,-0.185,0.0183,-0.0003,-0.007,-0.014";
+            case 4134 : return "+proj=longlat +ellps=clrk80";
+            case 4135 : return "+proj=longlat +ellps=clrk66";
+            case 4136 : return "+proj=longlat +ellps=clrk66";
+            case 4137 : return "+proj=longlat +ellps=clrk66";
+            case 4138 : return "+proj=longlat +ellps=clrk66";
+            case 4139 : return "+proj=longlat +ellps=clrk66 +towgs84=11,72,-101,0,0,0,0";
+            case 4140 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4141 : return "+proj=longlat +ellps=GRS80 +towgs84=-48,55,52,0,0,0,0";
+            case 4142 : return "+proj=longlat +ellps=clrk80 +towgs84=-125,53,467,0,0,0,0";
+            case 4143 : return "+proj=longlat +ellps=clrk80 +towgs84=-124.76,53,466.79,0,0,0,0";
+            case 4144 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024";
+            case 4145 : return "+proj=longlat +a=6377301.243 +b=6356100.230165384";
+            case 4146 : return "+proj=longlat +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0";
+            case 4147 : return "+proj=longlat +ellps=krass +towgs84=-17.51,-108.32,-62.39,0,0,0,0";
+            case 4148 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4149 : return "+proj=longlat +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0";
+            case 4150 : return "+proj=longlat +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0";
+            case 4151 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4152 : return "+proj=longlat +ellps=GRS80";
+            case 4153 : return "+proj=longlat +ellps=intl +towgs84=-133.63,-157.5,-158.62,0,0,0,0";
+            case 4154 : return "+proj=longlat +ellps=intl";
+            case 4155 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-83,37,124,0,0,0,0";
+            case 4156 : return "+proj=longlat +ellps=bessel";
+            case 4157 : return "+proj=longlat +a=6378293.645208759 +b=6356617.987679838";
+            case 4158 : return "+proj=longlat +ellps=intl";
+            case 4159 : return "+proj=longlat +ellps=intl";
+            case 4160 : return "+proj=longlat +ellps=intl";
+            case 4161 : return "+proj=longlat +ellps=intl +towgs84=27.5,14,186.4,0,0,0,0";
+            case 4162 : return "+proj=longlat +ellps=bessel";
+            case 4163 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4164 : return "+proj=longlat +ellps=krass +towgs84=-76,-138,67,0,0,0,0";
+            case 4165 : return "+proj=longlat +ellps=intl +towgs84=-173,253,27,0,0,0,0";
+            case 4166 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4167 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4168 : return "+proj=longlat +a=6378300 +b=6356751.689189189 +towgs84=-199,32,322,0,0,0,0";
+            case 4169 : return "+proj=longlat +ellps=clrk66 +towgs84=-115,118,426,0,0,0,0";
+            case 4170 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4171 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4172 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4173 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4174 : return "+proj=longlat +a=6378300 +b=6356751.689189189";
+            case 4175 : return "+proj=longlat +ellps=clrk80 +towgs84=-88,4,101,0,0,0,0";
+            case 4176 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4178 : return "+proj=longlat +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1";
+            case 4179 : return "+proj=longlat +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84";
+            case 4180 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4181 : return "+proj=longlat +ellps=intl +towgs84=-193,13.7,-39.3,-0.41,-2.933,2.688,0.43";
+            case 4182 : return "+proj=longlat +ellps=intl";
+            case 4183 : return "+proj=longlat +ellps=intl +towgs84=-104,167,-38,0,0,0,0";
+            case 4184 : return "+proj=longlat +ellps=intl +towgs84=-203,141,53,0,0,0,0";
+            case 4185 : return "+proj=longlat +ellps=intl";
+            case 4188 : return "+proj=longlat +ellps=airy +towgs84=482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15";
+            case 4189 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4190 : return "+proj=longlat +ellps=GRS80";
+            case 4191 : return "+proj=longlat +ellps=krass";
+            case 4192 : return "+proj=longlat +ellps=intl +towgs84=-206.1,-174.7,-87.7,0,0,0,0";
+            case 4193 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-70.9,-151.8,-41.4,0,0,0,0";
+            case 4194 : return "+proj=longlat +ellps=intl";
+            case 4195 : return "+proj=longlat +ellps=intl +towgs84=105,326,-102.5,0,0,0.814,-0.6";
+            case 4196 : return "+proj=longlat +ellps=intl +towgs84=-45,417,-3.5,0,0,0.814,-0.6";
+            case 4197 : return "+proj=longlat +ellps=clrk80";
+            case 4198 : return "+proj=longlat +ellps=clrk80";
+            case 4199 : return "+proj=longlat +ellps=intl";
+            case 4200 : return "+proj=longlat +ellps=krass";
+            case 4201 : return "+proj=longlat +ellps=clrk80";
+            case 4202 : return "+proj=longlat +ellps=aust_SA";
+            case 4203 : return "+proj=longlat +ellps=aust_SA";
+            case 4204 : return "+proj=longlat +ellps=intl";
+            case 4205 : return "+proj=longlat +ellps=krass +towgs84=-43,-163,45,0,0,0,0";
+            case 4206 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4207 : return "+proj=longlat +ellps=intl";
+            case 4208 : return "+proj=longlat +ellps=intl";
+            case 4209 : return "+proj=longlat +a=6378249.145 +b=6356514.966398753";
+            case 4210 : return "+proj=longlat +ellps=clrk80";
+            case 4211 : return "+proj=longlat +ellps=bessel";
+            case 4212 : return "+proj=longlat +ellps=clrk80 +towgs84=31.95,300.99,419.19,0,0,0,0";
+            case 4213 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-106,-87,188,0,0,0,0";
+            case 4214 : return "+proj=longlat +ellps=krass";
+            case 4215 : return "+proj=longlat +ellps=intl";
+            case 4216 : return "+proj=longlat +ellps=clrk66 +towgs84=-73,213,296,0,0,0,0";
+            case 4218 : return "+proj=longlat +ellps=intl +towgs84=307,304,-318,0,0,0,0";
+            case 4219 : return "+proj=longlat +ellps=bessel +towgs84=-384,664,-48,0,0,0,0";
+            case 4220 : return "+proj=longlat +ellps=clrk80";
+            case 4221 : return "+proj=longlat +ellps=intl";
+            case 4222 : return "+proj=longlat +a=6378249.145 +b=6356514.966398753";
+            case 4223 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4224 : return "+proj=longlat +ellps=intl +towgs84=-134,229,-29,0,0,0,0";
+            case 4225 : return "+proj=longlat +ellps=intl +towgs84=-206,172,-6,0,0,0,0";
+            case 4226 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4227 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4228 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4229 : return "+proj=longlat +ellps=helmert";
+            case 4230 : return "+proj=longlat +ellps=intl";
+            case 4231 : return "+proj=longlat +ellps=intl";
+            case 4232 : return "+proj=longlat +ellps=clrk80";
+            case 4233 : return "+proj=longlat +ellps=intl +towgs84=-133,-321,50,0,0,0,0";
+            case 4234 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4235 : return "+proj=longlat +ellps=intl";
+            case 4236 : return "+proj=longlat +ellps=intl +towgs84=-637,-549,-203,0,0,0,0";
+            case 4237 : return "+proj=longlat +ellps=GRS67";
+            case 4238 : return "+proj=longlat +a=6378160 +b=6356774.50408554";
+            case 4239 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024 +towgs84=217,823,299,0,0,0,0";
+            case 4240 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024";
+            case 4241 : return "+proj=longlat +ellps=clrk80";
+            case 4242 : return "+proj=longlat +ellps=clrk66";
+            case 4243 : return "+proj=longlat +a=6377299.36559538 +b=6356098.357204818";
+            case 4244 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024 +towgs84=-97,787,86,0,0,0,0";
+            case 4245 : return "+proj=longlat +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0";
+            case 4246 : return "+proj=longlat +ellps=clrk80 +towgs84=-294.7,-200.1,525.5,0,0,0,0";
+            case 4247 : return "+proj=longlat +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0";
+            case 4248 : return "+proj=longlat +ellps=intl";
+            case 4249 : return "+proj=longlat +ellps=intl";
+            case 4250 : return "+proj=longlat +ellps=clrk80 +towgs84=-130,29,364,0,0,0,0";
+            case 4251 : return "+proj=longlat +ellps=clrk80 +towgs84=-90,40,88,0,0,0,0";
+            case 4252 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4253 : return "+proj=longlat +ellps=clrk66";
+            case 4254 : return "+proj=longlat +ellps=intl";
+            case 4255 : return "+proj=longlat +ellps=intl +towgs84=-333,-222,114,0,0,0,0";
+            case 4256 : return "+proj=longlat +ellps=clrk80 +towgs84=41,-220,-134,0,0,0,0";
+            case 4257 : return "+proj=longlat +ellps=bessel +towgs84=-587.8,519.75,145.76,0,0,0,0";
+            case 4258 : return "+proj=longlat +ellps=GRS80";
+            case 4259 : return "+proj=longlat +ellps=intl";
+            case 4260 : return "+proj=longlat +ellps=clrk80 +towgs84=-70.9,-151.8,-41.4,0,0,0,0";
+            case 4261 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0";
+            case 4262 : return "+proj=longlat +ellps=bessel +towgs84=639,405,60,0,0,0,0";
+            case 4263 : return "+proj=longlat +ellps=clrk80";
+            case 4264 : return "+proj=longlat +ellps=intl +towgs84=-252.95,-4.11,-96.38,0,0,0,0";
+            case 4265 : return "+proj=longlat +ellps=intl";
+            case 4266 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4267 : return "+proj=longlat +ellps=clrk66 +datum=NAD27";
+            case 4268 : return "+proj=longlat +a=6378450.047548896 +b=6356826.621488444";
+            case 4269 : return "+proj=longlat +ellps=GRS80 +datum=NAD83";
+            case 4270 : return "+proj=longlat +ellps=clrk80";
+            case 4271 : return "+proj=longlat +ellps=intl";
+            case 4272 : return "+proj=longlat +ellps=intl +datum=nzgd49";
+            case 4273 : return "+proj=longlat +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21";
+            case 4274 : return "+proj=longlat +ellps=intl";
+            case 4275 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0";
+            case 4276 : return "+proj=longlat +ellps=WGS66";
+            case 4277 : return "+proj=longlat +ellps=airy +datum=OSGB36";
+            case 4278 : return "+proj=longlat +ellps=airy";
+            case 4279 : return "+proj=longlat +ellps=airy";
+            case 4280 : return "+proj=longlat +ellps=bessel";
+            case 4281 : return "+proj=longlat +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1";
+            case 4282 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4283 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4284 : return "+proj=longlat +ellps=krass";
+            case 4285 : return "+proj=longlat +ellps=intl";
+            case 4286 : return "+proj=longlat +ellps=helmert";
+            case 4287 : return "+proj=longlat +ellps=intl +towgs84=164,138,-189,0,0,0,0";
+            case 4288 : return "+proj=longlat +ellps=intl";
+            case 4289 : return "+proj=longlat +ellps=bessel";
+            case 4291 : return "+proj=longlat +ellps=GRS67";
+            case 4292 : return "+proj=longlat +ellps=intl +towgs84=-355,21,72,0,0,0,0";
+            case 4293 : return "+proj=longlat +ellps=bess_nam";
+            case 4294 : return "+proj=longlat +ellps=bessel";
+            case 4295 : return "+proj=longlat +ellps=bessel";
+            case 4296 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4297 : return "+proj=longlat +ellps=intl +towgs84=-189,-242,-91,0,0,0,0";
+            case 4298 : return "+proj=longlat +ellps=evrstSS";
+            case 4299 : return "+proj=longlat +a=6377340.189 +b=6356034.447938534";
+            case 4300 : return "+proj=longlat +a=6377340.189 +b=6356034.447938534";
+            case 4301 : return "+proj=longlat +ellps=bessel";
+            case 4302 : return "+proj=longlat +a=6378293.645208759 +b=6356617.987679838";
+            case 4303 : return "+proj=longlat +ellps=helmert";
+            case 4304 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-73,-247,227,0,0,0,0";
+            case 4306 : return "+proj=longlat +ellps=bessel";
+            case 4307 : return "+proj=longlat +ellps=clrk80";
+            case 4308 : return "+proj=longlat +ellps=bessel";
+            case 4309 : return "+proj=longlat +ellps=intl +towgs84=-155,171,37,0,0,0,0";
+            case 4310 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4311 : return "+proj=longlat +ellps=intl +towgs84=-265,120,-358,0,0,0,0";
+            case 4312 : return "+proj=longlat +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232";
+            case 4313 : return "+proj=longlat +ellps=intl +towgs84=106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1";
+            case 4314 : return "+proj=longlat +ellps=bessel +datum=potsdam";
+            case 4315 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0";
+            case 4316 : return "+proj=longlat +ellps=intl";
+            case 4317 : return "+proj=longlat +ellps=krass";
+            case 4318 : return "+proj=longlat +ellps=WGS84 +towgs84=-3.2,-5.7,2.8,0,0,0,0";
+            case 4319 : return "+proj=longlat +ellps=GRS80";
+            case 4322 : return "+proj=longlat +ellps=WGS72";
+            case 4324 : return "+proj=longlat +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38";
+            case 4326 : return "+proj=longlat +ellps=WGS84 +datum=WGS84";
+            case 4600 : return "+proj=longlat +ellps=clrk80";
+            case 4601 : return "+proj=longlat +ellps=clrk80";
+            case 4602 : return "+proj=longlat +ellps=clrk80 +towgs84=725,685,536,0,0,0,0";
+            case 4603 : return "+proj=longlat +ellps=clrk80 +towgs84=72,213.7,93,0,0,0,0";
+            case 4604 : return "+proj=longlat +ellps=clrk80 +towgs84=174,359,365,0,0,0,0";
+            case 4605 : return "+proj=longlat +ellps=clrk80";
+            case 4606 : return "+proj=longlat +ellps=clrk80 +towgs84=-149,128,296,0,0,0,0";
+            case 4607 : return "+proj=longlat +ellps=clrk80 +towgs84=195.671,332.517,274.607,0,0,0,0";
+            case 4608 : return "+proj=longlat +ellps=clrk66";
+            case 4609 : return "+proj=longlat +ellps=clrk66";
+            case 4610 : return "+proj=longlat +a=6378140 +b=6356755.288157528";
+            case 4611 : return "+proj=longlat +ellps=intl +towgs84=-162.619,-276.959,-161.764,0.067753,-2.24365,-1.15883,-1.09425";
+            case 4612 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4613 : return "+proj=longlat +ellps=bessel";
+            case 4614 : return "+proj=longlat +ellps=intl +towgs84=-119.425,-303.659,-11.0006,1.1643,0.174458,1.09626,3.65706";
+            case 4615 : return "+proj=longlat +ellps=intl +towgs84=-499,-249,314,0,0,0,0";
+            case 4616 : return "+proj=longlat +ellps=intl";
+            case 4617 : return "+proj=longlat +ellps=GRS80";
+            case 4618 : return "+proj=longlat +ellps=aust_SA";
+            case 4619 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4620 : return "+proj=longlat +ellps=clrk80 +towgs84=-106,-129,165,0,0,0,0";
+            case 4621 : return "+proj=longlat +ellps=intl +towgs84=137,248,-430,0,0,0,0";
+            case 4622 : return "+proj=longlat +ellps=intl";
+            case 4623 : return "+proj=longlat +ellps=intl +towgs84=-186,230,110,0,0,0,0";
+            case 4624 : return "+proj=longlat +ellps=GRS80 +towgs84=2,2,-2,0,0,0,0";
+            case 4625 : return "+proj=longlat +ellps=intl";
+            case 4626 : return "+proj=longlat +ellps=intl";
+            case 4627 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4628 : return "+proj=longlat +ellps=intl +towgs84=162,117,154,0,0,0,0";
+            case 4629 : return "+proj=longlat +ellps=intl";
+            case 4630 : return "+proj=longlat +ellps=intl";
+            case 4631 : return "+proj=longlat +ellps=intl +towgs84=145,-187,103,0,0,0,0";
+            case 4632 : return "+proj=longlat +ellps=intl +towgs84=-382,-59,-262,0,0,0,0";
+            case 4633 : return "+proj=longlat +ellps=intl";
+            case 4634 : return "+proj=longlat +ellps=intl";
+            case 4635 : return "+proj=longlat +ellps=intl +towgs84=-122.383,-188.696,103.344,3.5107,-4.9668,-5.7047,4.4798";
+            case 4636 : return "+proj=longlat +ellps=intl +towgs84=365,194,166,0,0,0,0";
+            case 4637 : return "+proj=longlat +ellps=intl +towgs84=325,154,172,0,0,0,0";
+            case 4638 : return "+proj=longlat +ellps=clrk66 +towgs84=30,430,368,0,0,0,0";
+            case 4639 : return "+proj=longlat +ellps=intl";
+            case 4640 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4641 : return "+proj=longlat +ellps=intl";
+            case 4642 : return "+proj=longlat +ellps=intl";
+            case 4643 : return "+proj=longlat +ellps=intl +towgs84=-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7";
+            case 4644 : return "+proj=longlat +ellps=intl";
+            case 4645 : return "+proj=longlat +ellps=intl +towgs84=0,0,0,0,0,0,0";
+            case 4646 : return "+proj=longlat +ellps=intl";
+            case 4657 : return "+proj=longlat +a=6377019.27 +b=6355762.5391 +towgs84=-28,199,5,0,0,0,0";
+            case 4658 : return "+proj=longlat +ellps=intl +towgs84=-73,46,-86,0,0,0,0";
+            case 4659 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4660 : return "+proj=longlat +ellps=intl +towgs84=982.609,552.753,-540.873,32.3934,-153.257,-96.2266,16.805";
+            case 4661 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4662 : return "+proj=longlat +ellps=intl";
+            case 4663 : return "+proj=longlat +ellps=intl";
+            case 4664 : return "+proj=longlat +ellps=intl";
+            case 4665 : return "+proj=longlat +ellps=intl";
+            case 4666 : return "+proj=longlat +ellps=bessel";
+            case 4667 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4668 : return "+proj=longlat +ellps=intl +towgs84=-86,-98,-119,0,0,0,0";
+            case 4669 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4670 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4671 : return "+proj=longlat +a=6378249.2 +b=6356515";
+            case 4672 : return "+proj=longlat +ellps=intl +towgs84=175,-38,113,0,0,0,0";
+            case 4673 : return "+proj=longlat +ellps=intl +towgs84=174.05,-25.49,112.57,-0,-0,0.554,0.2263";
+            case 4674 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4675 : return "+proj=longlat +ellps=clrk66 +towgs84=-100,-248,259,0,0,0,0";
+            case 4676 : return "+proj=longlat +ellps=krass";
+            case 4677 : return "+proj=longlat +ellps=krass";
+            case 4678 : return "+proj=longlat +ellps=krass +towgs84=44.585,-131.212,-39.544,0,0,0,0";
+            case 4679 : return "+proj=longlat +ellps=clrk80 +towgs84=-80.01,253.26,291.19,0,0,0,0";
+            case 4680 : return "+proj=longlat +ellps=clrk80 +towgs84=124.5,-63.5,-281,0,0,0,0";
+            case 4681 : return "+proj=longlat +ellps=clrk80";
+            case 4682 : return "+proj=longlat +a=6377276.345 +b=6356075.41314024";
+            case 4683 : return "+proj=longlat +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06";
+            case 4684 : return "+proj=longlat +ellps=intl +towgs84=-133,-321,50,0,0,0,0";
+            case 4685 : return "+proj=longlat +ellps=intl";
+            case 4686 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4687 : return "+proj=longlat +ellps=GRS80";
+            case 4688 : return "+proj=longlat +ellps=intl +towgs84=347.103,1078.12,2623.92,-33.8875,70.6773,-9.3943,186.074";
+            case 4689 : return "+proj=longlat +ellps=intl";
+            case 4690 : return "+proj=longlat +ellps=intl";
+            case 4691 : return "+proj=longlat +ellps=intl +towgs84=215.525,149.593,176.229,-3.2624,-1.692,-1.1571,10.4773";
+            case 4692 : return "+proj=longlat +ellps=intl +towgs84=217.037,86.959,23.956,0,0,0,0";
+            case 4693 : return "+proj=longlat +ellps=WGS84 +towgs84=0,-0.15,0.68,0,0,0,0";
+            case 4694 : return "+proj=longlat +ellps=GRS80";
+            case 4695 : return "+proj=longlat +ellps=clrk66";
+            case 4696 : return "+proj=longlat +ellps=clrk80";
+            case 4697 : return "+proj=longlat +ellps=clrk80";
+            case 4698 : return "+proj=longlat +ellps=intl +towgs84=145,-187,103,0,0,0,0";
+            case 4699 : return "+proj=longlat +ellps=clrk80 +towgs84=-770.1,158.4,-498.2,0,0,0,0";
+            case 4700 : return "+proj=longlat +ellps=clrk80";
+            case 4701 : return "+proj=longlat +ellps=clrk80 +towgs84=-79.9,-158,-168.9,0,0,0,0";
+            case 4702 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4703 : return "+proj=longlat +ellps=clrk80";
+            case 4704 : return "+proj=longlat +ellps=intl";
+            case 4705 : return "+proj=longlat +ellps=intl";
+            case 4706 : return "+proj=longlat +ellps=helmert +towgs84=-146.21,112.63,4.05,0,0,0,0";
+            case 4707 : return "+proj=longlat +ellps=intl +towgs84=114,-116,-333,0,0,0,0";
+            case 4708 : return "+proj=longlat +ellps=aust_SA +towgs84=-491,-22,435,0,0,0,0";
+            case 4709 : return "+proj=longlat +ellps=intl +towgs84=145,75,-272,0,0,0,0";
+            case 4710 : return "+proj=longlat +ellps=intl +towgs84=-320,550,-494,0,0,0,0";
+            case 4711 : return "+proj=longlat +ellps=intl +towgs84=124,-234,-25,0,0,0,0";
+            case 4712 : return "+proj=longlat +ellps=intl +towgs84=-205,107,53,0,0,0,0";
+            case 4713 : return "+proj=longlat +ellps=clrk80 +towgs84=-79,-129,145,0,0,0,0";
+            case 4714 : return "+proj=longlat +ellps=intl +towgs84=-127,-769,472,0,0,0,0";
+            case 4715 : return "+proj=longlat +ellps=intl +towgs84=-104,-129,239,0,0,0,0";
+            case 4716 : return "+proj=longlat +ellps=intl +towgs84=298,-304,-375,0,0,0,0";
+            case 4717 : return "+proj=longlat +ellps=clrk66 +towgs84=-2,151,181,0,0,0,0";
+            case 4718 : return "+proj=longlat +ellps=intl";
+            case 4719 : return "+proj=longlat +ellps=intl +towgs84=211,147,111,0,0,0,0";
+            case 4720 : return "+proj=longlat +ellps=WGS72";
+            case 4721 : return "+proj=longlat +ellps=intl +towgs84=265.025,384.929,-194.046,0,0,0,0";
+            case 4722 : return "+proj=longlat +ellps=intl +towgs84=-794,119,-298,0,0,0,0";
+            case 4723 : return "+proj=longlat +ellps=clrk66 +towgs84=67.8,106.1,138.8,0,0,0,0";
+            case 4724 : return "+proj=longlat +ellps=intl +towgs84=208,-435,-229,0,0,0,0";
+            case 4725 : return "+proj=longlat +ellps=intl +towgs84=189,-79,-202,0,0,0,0";
+            case 4726 : return "+proj=longlat +ellps=clrk66";
+            case 4727 : return "+proj=longlat +ellps=intl";
+            case 4728 : return "+proj=longlat +ellps=intl +towgs84=-307,-92,127,0,0,0,0";
+            case 4729 : return "+proj=longlat +ellps=intl +towgs84=185,165,42,0,0,0,0";
+            case 4730 : return "+proj=longlat +ellps=intl +towgs84=170,42,84,0,0,0,0";
+            case 4731 : return "+proj=longlat +ellps=clrk80 +towgs84=51,391,-36,0,0,0,0";
+            case 4732 : return "+proj=longlat +a=6378270 +b=6356794.343434343 +towgs84=102,52,-38,0,0,0,0";
+            case 4733 : return "+proj=longlat +ellps=intl +towgs84=276,-57,149,0,0,0,0";
+            case 4734 : return "+proj=longlat +ellps=intl +towgs84=-632,438,-609,0,0,0,0";
+            case 4735 : return "+proj=longlat +ellps=intl +towgs84=647,1777,-1124,0,0,0,0";
+            case 4736 : return "+proj=longlat +ellps=clrk80 +towgs84=260,12,-147,0,0,0,0";
+            case 4737 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4738 : return "+proj=longlat +a=6378293.645208759 +b=6356617.987679838";
+            case 4739 : return "+proj=longlat +ellps=intl +towgs84=-156,-271,-189,0,0,0,0";
+            case 4740 : return "+proj=longlat +a=6378136 +b=6356751.361745712 +towgs84=0,0,1.5,-0,-0,0.076,0";
+            case 4741 : return "+proj=longlat +ellps=intl";
+            case 4742 : return "+proj=longlat +ellps=GRS80";
+            case 4743 : return "+proj=longlat +ellps=clrk80 +towgs84=84.1,-320.1,218.7,0,0,0,0";
+            case 4744 : return "+proj=longlat +ellps=clrk80";
+            case 4745 : return "+proj=longlat +ellps=bessel";
+            case 4746 : return "+proj=longlat +ellps=bessel";
+            case 4747 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4748 : return "+proj=longlat +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0";
+            case 4749 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4750 : return "+proj=longlat +ellps=WGS84 +towgs84=-56.263,16.136,-22.856,0,0,0,0";
+            case 4751 : return "+proj=longlat +a=6377295.664 +b=6356094.667915204";
+            case 4752 : return "+proj=longlat +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0";
+            case 4753 : return "+proj=longlat +ellps=intl";
+            case 4754 : return "+proj=longlat +ellps=intl +towgs84=-208.406,-109.878,-2.5764,0,0,0,0";
+            case 4755 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4756 : return "+proj=longlat +ellps=WGS84";
+            case 4757 : return "+proj=longlat +ellps=WGS84";
+            case 4758 : return "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0";
+            case 4759 : return "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0";
+            case 4760 : return "+proj=longlat +ellps=WGS66";
+            case 4801 : return "+proj=longlat +ellps=bessel +pm=bern";
+            case 4802 : return "+proj=longlat +ellps=intl +pm=bogota";
+            case 4803 : return "+proj=longlat +ellps=intl +pm=lisbon";
+            case 4804 : return "+proj=longlat +ellps=bessel +towgs84=-587.8,519.75,145.76,0,0,0,0 +pm=jakarta";
+            case 4805 : return "+proj=longlat +ellps=bessel +pm=ferro";
+            case 4806 : return "+proj=longlat +ellps=intl +pm=rome";
+            case 4807 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris";
+            case 4808 : return "+proj=longlat +ellps=bessel +pm=jakarta";
+            case 4809 : return "+proj=longlat +ellps=intl +pm=brussels";
+            case 4810 : return "+proj=longlat +ellps=intl +towgs84=-189,-242,-91,0,0,0,0 +pm=paris";
+            case 4811 : return "+proj=longlat +a=6378249.2 +b=6356515 +towgs84=-73,-247,227,0,0,0,0 +pm=paris";
+            case 4813 : return "+proj=longlat +ellps=bessel +pm=jakarta";
+            case 4814 : return "+proj=longlat +ellps=bessel +pm=stockholm";
+            case 4815 : return "+proj=longlat +ellps=bessel +pm=athens";
+            case 4816 : return "+proj=longlat +a=6378249.2 +b=6356515 +pm=paris";
+            case 4817 : return "+proj=longlat +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo";
+            case 4818 : return "+proj=longlat +ellps=bessel +pm=ferro";
+            case 4819 : return "+proj=longlat +ellps=clrk80 +pm=paris";
+            case 4820 : return "+proj=longlat +ellps=bessel +pm=jakarta";
+            case 4821 : return "+proj=longlat +a=6378249.2 +b=6356515 +pm=paris";
+            case 4901 : return "+proj=longlat +a=6376523 +b=6355862.933255573 +pm=paris";
+            case 4902 : return "+proj=longlat +a=6376523 +b=6355862.933255573 +pm=paris";
+            case 4903 : return "+proj=longlat +a=6378298.3 +b=6356657.142669561 +pm=madrid";
+            case 4904 : return "+proj=longlat +ellps=bessel +pm=lisbon";
+            case 20004 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m";
+            case 20005 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +units=m";
+            case 20006 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=6500000 +y_0=0 +ellps=krass +units=m";
+            case 20007 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=7500000 +y_0=0 +ellps=krass +units=m";
+            case 20008 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +units=m";
+            case 20009 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=9500000 +y_0=0 +ellps=krass +units=m";
+            case 20010 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=10500000 +y_0=0 +ellps=krass +units=m";
+            case 20011 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=11500000 +y_0=0 +ellps=krass +units=m";
+            case 20012 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=12500000 +y_0=0 +ellps=krass +units=m";
+            case 20013 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=13500000 +y_0=0 +ellps=krass +units=m";
+            case 20014 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=14500000 +y_0=0 +ellps=krass +units=m";
+            case 20015 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=15500000 +y_0=0 +ellps=krass +units=m";
+            case 20016 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=16500000 +y_0=0 +ellps=krass +units=m";
+            case 20017 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=17500000 +y_0=0 +ellps=krass +units=m";
+            case 20018 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=18500000 +y_0=0 +ellps=krass +units=m";
+            case 20019 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=19500000 +y_0=0 +ellps=krass +units=m";
+            case 20020 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=20500000 +y_0=0 +ellps=krass +units=m";
+            case 20021 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=21500000 +y_0=0 +ellps=krass +units=m";
+            case 20022 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=22500000 +y_0=0 +ellps=krass +units=m";
+            case 20023 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=23500000 +y_0=0 +ellps=krass +units=m";
+            case 20024 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=24500000 +y_0=0 +ellps=krass +units=m";
+            case 20025 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=25500000 +y_0=0 +ellps=krass +units=m";
+            case 20026 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=26500000 +y_0=0 +ellps=krass +units=m";
+            case 20027 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=27500000 +y_0=0 +ellps=krass +units=m";
+            case 20028 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=28500000 +y_0=0 +ellps=krass +units=m";
+            case 20029 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=29500000 +y_0=0 +ellps=krass +units=m";
+            case 20030 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=30500000 +y_0=0 +ellps=krass +units=m";
+            case 20031 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=31500000 +y_0=0 +ellps=krass +units=m";
+            case 20032 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=32500000 +y_0=0 +ellps=krass +units=m";
+            case 20064 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20065 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20066 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20067 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20068 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20069 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20070 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20071 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20072 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20073 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20074 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20075 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20076 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20077 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20078 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20079 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20080 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20081 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20082 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20083 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20084 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20085 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20086 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20087 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20088 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20089 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20090 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20091 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20092 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 20135 : return "+proj=utm +zone=35 +ellps=clrk80 +units=m";
+            case 20136 : return "+proj=utm +zone=36 +ellps=clrk80 +units=m";
+            case 20137 : return "+proj=utm +zone=37 +ellps=clrk80 +units=m";
+            case 20138 : return "+proj=utm +zone=38 +ellps=clrk80 +units=m";
+            case 20248 : return "+proj=utm +zone=48 +south +ellps=aust_SA +units=m";
+            case 20249 : return "+proj=utm +zone=49 +south +ellps=aust_SA +units=m";
+            case 20250 : return "+proj=utm +zone=50 +south +ellps=aust_SA +units=m";
+            case 20251 : return "+proj=utm +zone=51 +south +ellps=aust_SA +units=m";
+            case 20252 : return "+proj=utm +zone=52 +south +ellps=aust_SA +units=m";
+            case 20253 : return "+proj=utm +zone=53 +south +ellps=aust_SA +units=m";
+            case 20254 : return "+proj=utm +zone=54 +south +ellps=aust_SA +units=m";
+            case 20255 : return "+proj=utm +zone=55 +south +ellps=aust_SA +units=m";
+            case 20256 : return "+proj=utm +zone=56 +south +ellps=aust_SA +units=m";
+            case 20257 : return "+proj=utm +zone=57 +south +ellps=aust_SA +units=m";
+            case 20258 : return "+proj=utm +zone=58 +south +ellps=aust_SA +units=m";
+            case 20348 : return "+proj=utm +zone=48 +south +ellps=aust_SA +units=m";
+            case 20349 : return "+proj=utm +zone=49 +south +ellps=aust_SA +units=m";
+            case 20350 : return "+proj=utm +zone=50 +south +ellps=aust_SA +units=m";
+            case 20351 : return "+proj=utm +zone=51 +south +ellps=aust_SA +units=m";
+            case 20352 : return "+proj=utm +zone=52 +south +ellps=aust_SA +units=m";
+            case 20353 : return "+proj=utm +zone=53 +south +ellps=aust_SA +units=m";
+            case 20354 : return "+proj=utm +zone=54 +south +ellps=aust_SA +units=m";
+            case 20355 : return "+proj=utm +zone=55 +south +ellps=aust_SA +units=m";
+            case 20356 : return "+proj=utm +zone=56 +south +ellps=aust_SA +units=m";
+            case 20357 : return "+proj=utm +zone=57 +south +ellps=aust_SA +units=m";
+            case 20358 : return "+proj=utm +zone=58 +south +ellps=aust_SA +units=m";
+            case 20436 : return "+proj=utm +zone=36 +ellps=intl +units=m";
+            case 20437 : return "+proj=utm +zone=37 +ellps=intl +units=m";
+            case 20438 : return "+proj=utm +zone=38 +ellps=intl +units=m";
+            case 20439 : return "+proj=utm +zone=39 +ellps=intl +units=m";
+            case 20440 : return "+proj=utm +zone=40 +ellps=intl +units=m";
+            case 20499 : return "+proj=utm +zone=39 +ellps=intl +units=m";
+            case 20538 : return "+proj=utm +zone=38 +ellps=krass +towgs84=-43,-163,45,0,0,0,0 +units=m";
+            case 20539 : return "+proj=utm +zone=39 +ellps=krass +towgs84=-43,-163,45,0,0,0,0 +units=m";
+            case 20790 : return "+proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1 +x_0=200000 +y_0=300000 +ellps=intl +pm=lisbon +units=m";
+            case 20791 : return "+proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1 +x_0=0 +y_0=0 +ellps=intl +pm=lisbon +units=m";
+            case 20822 : return "+proj=utm +zone=22 +south +ellps=intl +units=m";
+            case 20823 : return "+proj=utm +zone=23 +south +ellps=intl +units=m";
+            case 20824 : return "+proj=utm +zone=24 +south +ellps=intl +units=m";
+            case 20934 : return "+proj=utm +zone=34 +south +a=6378249.145 +b=6356514.966398753 +units=m";
+            case 20935 : return "+proj=utm +zone=35 +south +a=6378249.145 +b=6356514.966398753 +units=m";
+            case 20936 : return "+proj=utm +zone=36 +south +a=6378249.145 +b=6356514.966398753 +units=m";
+            case 21035 : return "+proj=utm +zone=35 +south +ellps=clrk80 +units=m";
+            case 21036 : return "+proj=utm +zone=36 +south +ellps=clrk80 +units=m";
+            case 21037 : return "+proj=utm +zone=37 +south +ellps=clrk80 +units=m";
+            case 21095 : return "+proj=utm +zone=35 +ellps=clrk80 +units=m";
+            case 21096 : return "+proj=utm +zone=36 +ellps=clrk80 +units=m";
+            case 21097 : return "+proj=utm +zone=37 +ellps=clrk80 +units=m";
+            case 21100 : return "+proj=merc +lon_0=110 +k=0.997 +x_0=3900000 +y_0=900000 +ellps=bessel +pm=jakarta +units=m";
+            case 21148 : return "+proj=utm +zone=48 +south +ellps=bessel +units=m";
+            case 21149 : return "+proj=utm +zone=49 +south +ellps=bessel +units=m";
+            case 21150 : return "+proj=utm +zone=50 +south +ellps=bessel +units=m";
+            case 21291 : return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=31.95,300.99,419.19,0,0,0,0 +units=m";
+            case 21292 : return "+proj=tmerc +lat_0=13.17638888888889 +lon_0=-59.55972222222222 +k=0.9999986 +x_0=30000 +y_0=75000 +ellps=clrk80 +towgs84=31.95,300.99,419.19,0,0,0,0 +units=m";
+            case 21413 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=13500000 +y_0=0 +ellps=krass +units=m";
+            case 21414 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=14500000 +y_0=0 +ellps=krass +units=m";
+            case 21415 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=15500000 +y_0=0 +ellps=krass +units=m";
+            case 21416 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=16500000 +y_0=0 +ellps=krass +units=m";
+            case 21417 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=17500000 +y_0=0 +ellps=krass +units=m";
+            case 21418 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=18500000 +y_0=0 +ellps=krass +units=m";
+            case 21419 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=19500000 +y_0=0 +ellps=krass +units=m";
+            case 21420 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=20500000 +y_0=0 +ellps=krass +units=m";
+            case 21421 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=21500000 +y_0=0 +ellps=krass +units=m";
+            case 21422 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=22500000 +y_0=0 +ellps=krass +units=m";
+            case 21423 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=23500000 +y_0=0 +ellps=krass +units=m";
+            case 21453 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21454 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21455 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21456 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21457 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21458 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21459 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21460 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21461 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21462 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21463 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21473 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21474 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21475 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21476 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21477 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21478 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21479 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21480 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21481 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21482 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21483 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 21500 : return "+proj=lcc +lat_1=49.83333333333334 +lat_2=51.16666666666666 +lat_0=90 +lon_0=0 +x_0=150000 +y_0=5400000 +ellps=intl +pm=brussels +units=m";
+            case 21780 : return "+proj=somerc +lat_0=46.95240555555556 +lon_0=0 +x_0=0 +y_0=0 +ellps=bessel +pm=bern +units=m";
+            case 21781 : return "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m";
+            case 21817 : return "+proj=utm +zone=17 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21818 : return "+proj=utm +zone=18 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21891 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-77.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21892 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21893 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-71.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21894 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-68.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21896 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-77.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21897 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21898 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-71.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 21899 : return "+proj=tmerc +lat_0=4.599047222222222 +lon_0=-68.08091666666667 +k=1 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m";
+            case 22032 : return "+proj=utm +zone=32 +south +ellps=clrk80 +units=m";
+            case 22033 : return "+proj=utm +zone=33 +south +ellps=clrk80 +units=m";
+            case 22091 : return "+proj=tmerc +lat_0=0 +lon_0=11.5 +k=0.9996 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 22092 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=0.9996 +x_0=500000 +y_0=10000000 +ellps=clrk80 +units=m";
+            case 22171 : return "+proj=tmerc +lat_0=-90 +lon_0=-72 +k=1 +x_0=1500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22172 : return "+proj=tmerc +lat_0=-90 +lon_0=-69 +k=1 +x_0=2500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22173 : return "+proj=tmerc +lat_0=-90 +lon_0=-66 +k=1 +x_0=3500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22174 : return "+proj=tmerc +lat_0=-90 +lon_0=-63 +k=1 +x_0=4500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22175 : return "+proj=tmerc +lat_0=-90 +lon_0=-60 +k=1 +x_0=5500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22176 : return "+proj=tmerc +lat_0=-90 +lon_0=-57 +k=1 +x_0=6500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22177 : return "+proj=tmerc +lat_0=-90 +lon_0=-54 +k=1 +x_0=7500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22181 : return "+proj=tmerc +lat_0=-90 +lon_0=-72 +k=1 +x_0=1500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22182 : return "+proj=tmerc +lat_0=-90 +lon_0=-69 +k=1 +x_0=2500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22183 : return "+proj=tmerc +lat_0=-90 +lon_0=-66 +k=1 +x_0=3500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22184 : return "+proj=tmerc +lat_0=-90 +lon_0=-63 +k=1 +x_0=4500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22185 : return "+proj=tmerc +lat_0=-90 +lon_0=-60 +k=1 +x_0=5500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22186 : return "+proj=tmerc +lat_0=-90 +lon_0=-57 +k=1 +x_0=6500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22187 : return "+proj=tmerc +lat_0=-90 +lon_0=-54 +k=1 +x_0=7500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 22191 : return "+proj=tmerc +lat_0=-90 +lon_0=-72 +k=1 +x_0=1500000 +y_0=0 +ellps=intl +units=m";
+            case 22192 : return "+proj=tmerc +lat_0=-90 +lon_0=-69 +k=1 +x_0=2500000 +y_0=0 +ellps=intl +units=m";
+            case 22193 : return "+proj=tmerc +lat_0=-90 +lon_0=-66 +k=1 +x_0=3500000 +y_0=0 +ellps=intl +units=m";
+            case 22194 : return "+proj=tmerc +lat_0=-90 +lon_0=-63 +k=1 +x_0=4500000 +y_0=0 +ellps=intl +units=m";
+            case 22195 : return "+proj=tmerc +lat_0=-90 +lon_0=-60 +k=1 +x_0=5500000 +y_0=0 +ellps=intl +units=m";
+            case 22196 : return "+proj=tmerc +lat_0=-90 +lon_0=-57 +k=1 +x_0=6500000 +y_0=0 +ellps=intl +units=m";
+            case 22197 : return "+proj=tmerc +lat_0=-90 +lon_0=-54 +k=1 +x_0=7500000 +y_0=0 +ellps=intl +units=m";
+            case 22234 : return "+proj=utm +zone=34 +south +a=6378249.145 +b=6356514.966398753 +units=m";
+            case 22235 : return "+proj=utm +zone=35 +south +a=6378249.145 +b=6356514.966398753 +units=m";
+            case 22236 : return "+proj=utm +zone=36 +south +a=6378249.145 +b=6356514.966398753 +units=m";
+            case 22332 : return "+proj=utm +zone=32 +a=6378249.2 +b=6356515 +units=m";
+            case 22391 : return "+proj=lcc +lat_1=36 +lat_0=36 +lon_0=9.9 +k_0=0.999625544 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +units=m";
+            case 22392 : return "+proj=lcc +lat_1=33.3 +lat_0=33.3 +lon_0=9.9 +k_0=0.999625769 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +units=m";
+            case 22521 : return "+proj=utm +zone=21 +south +ellps=intl +towgs84=-206,172,-6,0,0,0,0 +units=m";
+            case 22522 : return "+proj=utm +zone=22 +south +ellps=intl +towgs84=-206,172,-6,0,0,0,0 +units=m";
+            case 22523 : return "+proj=utm +zone=23 +south +ellps=intl +towgs84=-206,172,-6,0,0,0,0 +units=m";
+            case 22524 : return "+proj=utm +zone=24 +south +ellps=intl +towgs84=-206,172,-6,0,0,0,0 +units=m";
+            case 22525 : return "+proj=utm +zone=25 +south +ellps=intl +towgs84=-206,172,-6,0,0,0,0 +units=m";
+            case 22700 : return "+proj=lcc +lat_1=34.65 +lat_0=34.65 +lon_0=37.35 +k_0=0.9996256 +x_0=300000 +y_0=300000 +a=6378249.2 +b=6356515 +units=m";
+            case 22770 : return "+proj=lcc +lat_1=34.65 +lat_0=34.65 +lon_0=37.35 +k_0=0.9996256 +x_0=300000 +y_0=300000 +a=6378249.2 +b=6356515 +units=m";
+            case 22780 : return "+proj=sterea +lat_0=34.2 +lon_0=39.15 +k=0.9995341 +x_0=0 +y_0=0 +a=6378249.2 +b=6356515 +units=m";
+            case 22832 : return "+proj=utm +zone=32 +a=6378249.2 +b=6356515 +units=m";
+            case 22991 : return "+proj=tmerc +lat_0=30 +lon_0=35 +k=1 +x_0=300000 +y_0=1100000 +ellps=helmert +units=m";
+            case 22992 : return "+proj=tmerc +lat_0=30 +lon_0=31 +k=1 +x_0=615000 +y_0=810000 +ellps=helmert +units=m";
+            case 22993 : return "+proj=tmerc +lat_0=30 +lon_0=27 +k=1 +x_0=700000 +y_0=200000 +ellps=helmert +units=m";
+            case 22994 : return "+proj=tmerc +lat_0=30 +lon_0=27 +k=1 +x_0=700000 +y_0=1200000 +ellps=helmert +units=m";
+            case 23028 : return "+proj=utm +zone=28 +ellps=intl +units=m";
+            case 23029 : return "+proj=utm +zone=29 +ellps=intl +units=m";
+            case 23030 : return "+proj=utm +zone=30 +ellps=intl +units=m";
+            case 23031 : return "+proj=utm +zone=31 +ellps=intl +units=m";
+            case 23032 : return "+proj=utm +zone=32 +ellps=intl +units=m";
+            case 23033 : return "+proj=utm +zone=33 +ellps=intl +units=m";
+            case 23034 : return "+proj=utm +zone=34 +ellps=intl +units=m";
+            case 23035 : return "+proj=utm +zone=35 +ellps=intl +units=m";
+            case 23036 : return "+proj=utm +zone=36 +ellps=intl +units=m";
+            case 23037 : return "+proj=utm +zone=37 +ellps=intl +units=m";
+            case 23038 : return "+proj=utm +zone=38 +ellps=intl +units=m";
+            case 23090 : return "+proj=tmerc +lat_0=0 +lon_0=0 +k=0.9996 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 23095 : return "+proj=tmerc +lat_0=0 +lon_0=5 +k=0.9996 +x_0=500000 +y_0=0 +ellps=intl +units=m";
+            case 23239 : return "+proj=utm +zone=39 +ellps=clrk80 +units=m";
+            case 23240 : return "+proj=utm +zone=40 +ellps=clrk80 +units=m";
+            case 23433 : return "+proj=utm +zone=33 +a=6378249.2 +b=6356515 +units=m";
+            case 23700 : return "+proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +x_0=650000 +y_0=200000 +ellps=GRS67 +units=m";
+            case 23830 : return "+proj=tmerc +lat_0=0 +lon_0=94.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23831 : return "+proj=tmerc +lat_0=0 +lon_0=97.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23832 : return "+proj=tmerc +lat_0=0 +lon_0=100.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23833 : return "+proj=tmerc +lat_0=0 +lon_0=103.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23834 : return "+proj=tmerc +lat_0=0 +lon_0=106.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23835 : return "+proj=tmerc +lat_0=0 +lon_0=109.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23836 : return "+proj=tmerc +lat_0=0 +lon_0=112.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23837 : return "+proj=tmerc +lat_0=0 +lon_0=115.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23838 : return "+proj=tmerc +lat_0=0 +lon_0=118.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23839 : return "+proj=tmerc +lat_0=0 +lon_0=121.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23840 : return "+proj=tmerc +lat_0=0 +lon_0=124.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23841 : return "+proj=tmerc +lat_0=0 +lon_0=127.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23842 : return "+proj=tmerc +lat_0=0 +lon_0=130.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23843 : return "+proj=tmerc +lat_0=0 +lon_0=133.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23844 : return "+proj=tmerc +lat_0=0 +lon_0=136.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23845 : return "+proj=tmerc +lat_0=0 +lon_0=139.5 +k=0.9999 +x_0=200000 +y_0=1500000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23846 : return "+proj=utm +zone=46 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23847 : return "+proj=utm +zone=47 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23848 : return "+proj=utm +zone=48 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23849 : return "+proj=utm +zone=49 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23850 : return "+proj=utm +zone=50 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23851 : return "+proj=utm +zone=51 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23852 : return "+proj=utm +zone=52 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23853 : return "+proj=utm +zone=53 +a=6378160 +b=6356774.50408554 +units=m";
+            case 23866 : return "+proj=utm +zone=46 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23867 : return "+proj=utm +zone=47 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23868 : return "+proj=utm +zone=48 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23869 : return "+proj=utm +zone=49 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23870 : return "+proj=utm +zone=50 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23871 : return "+proj=utm +zone=51 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23872 : return "+proj=utm +zone=52 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23877 : return "+proj=utm +zone=47 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23878 : return "+proj=utm +zone=48 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23879 : return "+proj=utm +zone=49 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23880 : return "+proj=utm +zone=50 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23881 : return "+proj=utm +zone=51 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23882 : return "+proj=utm +zone=52 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23883 : return "+proj=utm +zone=53 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23884 : return "+proj=utm +zone=54 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 23886 : return "+proj=utm +zone=46 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23887 : return "+proj=utm +zone=47 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23888 : return "+proj=utm +zone=48 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23889 : return "+proj=utm +zone=49 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23890 : return "+proj=utm +zone=50 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23891 : return "+proj=utm +zone=51 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23892 : return "+proj=utm +zone=52 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23893 : return "+proj=utm +zone=53 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23894 : return "+proj=utm +zone=54 +south +a=6378160 +b=6356774.50408554 +units=m";
+            case 23946 : return "+proj=utm +zone=46 +a=6377276.345 +b=6356075.41314024 +towgs84=217,823,299,0,0,0,0 +units=m";
+            case 23947 : return "+proj=utm +zone=47 +a=6377276.345 +b=6356075.41314024 +towgs84=217,823,299,0,0,0,0 +units=m";
+            case 23948 : return "+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +towgs84=217,823,299,0,0,0,0 +units=m";
+            case 24047 : return "+proj=utm +zone=47 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 24048 : return "+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 24100 : return "+proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77 +k_0=1 +x_0=167638.49597 +y_0=121918.90616 +ellps=clrk80 +to_meter=0.3047972654";
+            case 24200 : return "+proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77 +k_0=1 +x_0=250000 +y_0=150000 +ellps=clrk66 +units=m";
+            case 24305 : return "+proj=utm +zone=45 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 24306 : return "+proj=utm +zone=46 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 24311 : return "+proj=utm +zone=41 +a=6377301.243 +b=6356100.230165384 +units=m";
+            case 24312 : return "+proj=utm +zone=42 +a=6377301.243 +b=6356100.230165384 +units=m";
+            case 24313 : return "+proj=utm +zone=43 +a=6377301.243 +b=6356100.230165384 +units=m";
+            case 24342 : return "+proj=utm +zone=42 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24343 : return "+proj=utm +zone=43 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24344 : return "+proj=utm +zone=44 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24345 : return "+proj=utm +zone=45 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24346 : return "+proj=utm +zone=46 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24347 : return "+proj=utm +zone=47 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24370 : return "+proj=lcc +lat_1=39.5 +lat_0=39.5 +lon_0=68 +k_0=0.99846154 +x_0=2153865.73916853 +y_0=2368292.194628102 +a=6377299.36559538 +b=6356098.357204818 +to_meter=0.9143985307444408";
+            case 24371 : return "+proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=68 +k_0=0.99878641 +x_0=2743195.592233322 +y_0=914398.5307444407 +a=6377299.36559538 +b=6356098.357204818 +to_meter=0.9143985307444408";
+            case 24372 : return "+proj=lcc +lat_1=26 +lat_0=26 +lon_0=74 +k_0=0.99878641 +x_0=2743195.592233322 +y_0=914398.5307444407 +a=6377299.36559538 +b=6356098.357204818 +to_meter=0.9143985307444408";
+            case 24373 : return "+proj=lcc +lat_1=19 +lat_0=19 +lon_0=80 +k_0=0.99878641 +x_0=2743195.592233322 +y_0=914398.5307444407 +a=6377299.36559538 +b=6356098.357204818 +to_meter=0.9143985307444408";
+            case 24374 : return "+proj=lcc +lat_1=12 +lat_0=12 +lon_0=80 +k_0=0.99878641 +x_0=2743195.592233322 +y_0=914398.5307444407 +a=6377299.36559538 +b=6356098.357204818 +to_meter=0.9143985307444408";
+            case 24375 : return "+proj=lcc +lat_1=26 +lat_0=26 +lon_0=90 +k_0=0.99878641 +x_0=2743185.69 +y_0=914395.23 +a=6377276.345 +b=6356075.41314024 +units=m";
+            case 24376 : return "+proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=68 +k_0=0.99878641 +x_0=2743196.4 +y_0=914398.8 +a=6377301.243 +b=6356100.230165384 +units=m";
+            case 24377 : return "+proj=lcc +lat_1=26 +lat_0=26 +lon_0=74 +k_0=0.99878641 +x_0=2743196.4 +y_0=914398.8 +a=6377301.243 +b=6356100.230165384 +units=m";
+            case 24378 : return "+proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=68 +k_0=0.99878641 +x_0=2743195.5 +y_0=914398.5 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24379 : return "+proj=lcc +lat_1=26 +lat_0=26 +lon_0=74 +k_0=0.99878641 +x_0=2743195.5 +y_0=914398.5 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24380 : return "+proj=lcc +lat_1=26 +lat_0=26 +lon_0=90 +k_0=0.99878641 +x_0=2743195.5 +y_0=914398.5 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24381 : return "+proj=lcc +lat_1=19 +lat_0=19 +lon_0=80 +k_0=0.99878641 +x_0=2743195.5 +y_0=914398.5 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24382 : return "+proj=lcc +lat_1=26 +lat_0=26 +lon_0=90 +k_0=0.99878641 +x_0=2743195.592233322 +y_0=914398.5307444407 +a=6377299.36559538 +b=6356098.357204818 +to_meter=0.9143985307444408";
+            case 24383 : return "+proj=lcc +lat_1=12 +lat_0=12 +lon_0=80 +k_0=0.99878641 +x_0=2743195.5 +y_0=914398.5 +a=6377299.151 +b=6356098.145120132 +towgs84=295,736,257,0,0,0,0 +units=m";
+            case 24500 : return "+proj=cass +lat_0=1.287646666666667 +lon_0=103.8530022222222 +x_0=30000 +y_0=30000 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m";
+            case 24547 : return "+proj=utm +zone=47 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m";
+            case 24548 : return "+proj=utm +zone=48 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m";
+            case 24571 : return "+proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257905 +k=0.99984 +x_0=804671.2997750348 +y_0=0 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +to_meter=20.11678249437587";
+            case 24600 : return "+proj=lcc +lat_1=32.5 +lat_0=32.5 +lon_0=45 +k_0=0.9987864078000001 +x_0=1500000 +y_0=1166200 +ellps=clrk80 +towgs84=-294.7,-200.1,525.5,0,0,0,0 +units=m";
+            case 24718 : return "+proj=utm +zone=18 +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0 +units=m";
+            case 24719 : return "+proj=utm +zone=19 +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0 +units=m";
+            case 24720 : return "+proj=utm +zone=20 +ellps=intl +towgs84=-273.5,110.6,-357.9,0,0,0,0 +units=m";
+            case 24817 : return "+proj=utm +zone=17 +ellps=intl +units=m";
+            case 24818 : return "+proj=utm +zone=18 +ellps=intl +units=m";
+            case 24819 : return "+proj=utm +zone=19 +ellps=intl +units=m";
+            case 24820 : return "+proj=utm +zone=20 +ellps=intl +units=m";
+            case 24821 : return "+proj=utm +zone=21 +ellps=intl +units=m";
+            case 24877 : return "+proj=utm +zone=17 +south +ellps=intl +units=m";
+            case 24878 : return "+proj=utm +zone=18 +south +ellps=intl +units=m";
+            case 24879 : return "+proj=utm +zone=19 +south +ellps=intl +units=m";
+            case 24880 : return "+proj=utm +zone=20 +south +ellps=intl +units=m";
+            case 24881 : return "+proj=utm +zone=21 +south +ellps=intl +units=m";
+            case 24882 : return "+proj=utm +zone=22 +south +ellps=intl +units=m";
+            case 24891 : return "+proj=tmerc +lat_0=-6 +lon_0=-80.5 +k=0.99983008 +x_0=222000 +y_0=1426834.743 +ellps=intl +units=m";
+            case 24892 : return "+proj=tmerc +lat_0=-9.5 +lon_0=-76 +k=0.99932994 +x_0=720000 +y_0=1039979.159 +ellps=intl +units=m";
+            case 24893 : return "+proj=tmerc +lat_0=-9.5 +lon_0=-70.5 +k=0.99952992 +x_0=1324000 +y_0=1040084.558 +ellps=intl +units=m";
+            case 25000 : return "+proj=tmerc +lat_0=4.666666666666667 +lon_0=-1 +k=0.99975 +x_0=274319.51 +y_0=0 +ellps=clrk80 +towgs84=-130,29,364,0,0,0,0 +units=m";
+            case 25231 : return "+proj=utm +zone=31 +a=6378249.2 +b=6356515 +units=m";
+            case 25391 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +units=m";
+            case 25392 : return "+proj=tmerc +lat_0=0 +lon_0=119 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +units=m";
+            case 25393 : return "+proj=tmerc +lat_0=0 +lon_0=121 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +units=m";
+            case 25394 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +units=m";
+            case 25395 : return "+proj=tmerc +lat_0=0 +lon_0=125 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +units=m";
+            case 25700 : return "+proj=merc +lon_0=110 +k=0.997 +x_0=3900000 +y_0=900000 +ellps=bessel +towgs84=-587.8,519.75,145.76,0,0,0,0 +pm=jakarta +units=m";
+            case 25828 : return "+proj=utm +zone=28 +ellps=GRS80 +units=m";
+            case 25829 : return "+proj=utm +zone=29 +ellps=GRS80 +units=m";
+            case 25830 : return "+proj=utm +zone=30 +ellps=GRS80 +units=m";
+            case 25831 : return "+proj=utm +zone=31 +ellps=GRS80 +units=m";
+            case 25832 : return "+proj=utm +zone=32 +ellps=GRS80 +units=m";
+            case 25833 : return "+proj=utm +zone=33 +ellps=GRS80 +units=m";
+            case 25834 : return "+proj=utm +zone=34 +ellps=GRS80 +units=m";
+            case 25835 : return "+proj=utm +zone=35 +ellps=GRS80 +units=m";
+            case 25836 : return "+proj=utm +zone=36 +ellps=GRS80 +units=m";
+            case 25837 : return "+proj=utm +zone=37 +ellps=GRS80 +units=m";
+            case 25838 : return "+proj=utm +zone=38 +ellps=GRS80 +units=m";
+            case 25884 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 25932 : return "+proj=utm +zone=32 +south +ellps=intl +units=m";
+            case 26191 : return "+proj=lcc +lat_1=33.3 +lat_0=33.3 +lon_0=-5.4 +k_0=0.999625769 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +units=m";
+            case 26192 : return "+proj=lcc +lat_1=29.7 +lat_0=29.7 +lon_0=-5.4 +k_0=0.9996155960000001 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +units=m";
+            case 26193 : return "+proj=lcc +lat_1=26.1 +lat_0=26.1 +lon_0=-5.4 +k_0=0.9996 +x_0=1200000 +y_0=400000 +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +units=m";
+            case 26194 : return "+proj=lcc +lat_1=26.1 +lat_0=26.1 +lon_0=-5.4 +k_0=0.999616304 +x_0=1200000 +y_0=400000 +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +units=m";
+            case 26195 : return "+proj=lcc +lat_1=22.5 +lat_0=22.5 +lon_0=-5.4 +k_0=0.999616437 +x_0=1500000 +y_0=400000 +a=6378249.2 +b=6356515 +towgs84=31,146,47,0,0,0,0 +units=m";
+            case 26237 : return "+proj=utm +zone=37 +ellps=bessel +towgs84=639,405,60,0,0,0,0 +units=m";
+            case 26331 : return "+proj=utm +zone=31 +ellps=clrk80 +units=m";
+            case 26332 : return "+proj=utm +zone=32 +ellps=clrk80 +units=m";
+            case 26391 : return "+proj=tmerc +lat_0=4 +lon_0=4.5 +k=0.99975 +x_0=230738.26 +y_0=0 +ellps=clrk80 +units=m";
+            case 26392 : return "+proj=tmerc +lat_0=4 +lon_0=8.5 +k=0.99975 +x_0=670553.98 +y_0=0 +ellps=clrk80 +units=m";
+            case 26393 : return "+proj=tmerc +lat_0=4 +lon_0=12.5 +k=0.99975 +x_0=1110369.7 +y_0=0 +ellps=clrk80 +units=m";
+            case 26432 : return "+proj=utm +zone=32 +south +ellps=intl +towgs84=-252.95,-4.11,-96.38,0,0,0,0 +units=m";
+            case 26591 : return "+proj=tmerc +lat_0=0 +lon_0=-3.45233333333333 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +pm=rome +units=m";
+            case 26592 : return "+proj=tmerc +lat_0=0 +lon_0=2.54766666666666 +k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl +pm=rome +units=m";
+            case 26632 : return "+proj=utm +zone=32 +a=6378249.2 +b=6356515 +units=m";
+            case 26692 : return "+proj=utm +zone=32 +south +a=6378249.2 +b=6356515 +units=m";
+            case 26701 : return "+proj=utm +zone=1 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26702 : return "+proj=utm +zone=2 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26703 : return "+proj=utm +zone=3 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26704 : return "+proj=utm +zone=4 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26705 : return "+proj=utm +zone=5 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26706 : return "+proj=utm +zone=6 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26707 : return "+proj=utm +zone=7 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26708 : return "+proj=utm +zone=8 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26709 : return "+proj=utm +zone=9 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26710 : return "+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26711 : return "+proj=utm +zone=11 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26712 : return "+proj=utm +zone=12 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26713 : return "+proj=utm +zone=13 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26714 : return "+proj=utm +zone=14 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26715 : return "+proj=utm +zone=15 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26716 : return "+proj=utm +zone=16 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26717 : return "+proj=utm +zone=17 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26718 : return "+proj=utm +zone=18 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26719 : return "+proj=utm +zone=19 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26720 : return "+proj=utm +zone=20 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26721 : return "+proj=utm +zone=21 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26722 : return "+proj=utm +zone=22 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 26729 : return "+proj=tmerc +lat_0=30.5 +lon_0=-85.83333333333333 +k=0.99996 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26730 : return "+proj=tmerc +lat_0=30 +lon_0=-87.5 +k=0.999933333 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26731 : return "+proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000.001016002 +y_0=-5000000.001016002 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26732 : return "+proj=tmerc +lat_0=54 +lon_0=-142 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26733 : return "+proj=tmerc +lat_0=54 +lon_0=-146 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26734 : return "+proj=tmerc +lat_0=54 +lon_0=-150 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26735 : return "+proj=tmerc +lat_0=54 +lon_0=-154 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26736 : return "+proj=tmerc +lat_0=54 +lon_0=-158 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26737 : return "+proj=tmerc +lat_0=54 +lon_0=-162 +k=0.9999 +x_0=213360.4267208534 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26738 : return "+proj=tmerc +lat_0=54 +lon_0=-166 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26739 : return "+proj=tmerc +lat_0=54 +lon_0=-170 +k=0.9999 +x_0=182880.3657607315 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26740 : return "+proj=lcc +lat_1=53.83333333333334 +lat_2=51.83333333333334 +lat_0=51 +lon_0=-176 +x_0=914401.8288036576 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26741 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26742 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26743 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26744 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26745 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26746 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26747 : return "+proj=lcc +lat_1=34.41666666666666 +lat_2=33.86666666666667 +lat_0=34.13333333333333 +lon_0=-118.3333333333333 +x_0=1276106.450596901 +y_0=127079.524511049 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26748 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26749 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26750 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26751 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26752 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26753 : return "+proj=lcc +lat_1=39.71666666666667 +lat_2=40.78333333333333 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26754 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26755 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26756 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=182880.3657607315 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26757 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26758 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26759 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26760 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26766 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26767 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26768 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26769 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26770 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26771 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26772 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26773 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26774 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26775 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26776 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26777 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26778 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26779 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=38.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26780 : return "+proj=lcc +lat_1=36.73333333333333 +lat_2=37.93333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26781 : return "+proj=lcc +lat_1=31.16666666666667 +lat_2=32.66666666666666 +lat_0=30.66666666666667 +lon_0=-92.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26782 : return "+proj=lcc +lat_1=29.3 +lat_2=30.7 +lat_0=28.66666666666667 +lon_0=-91.33333333333333 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26783 : return "+proj=tmerc +lat_0=43.83333333333334 +lon_0=-68.5 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26784 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.16666666666667 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26785 : return "+proj=lcc +lat_1=38.3 +lat_2=39.45 +lat_0=37.83333333333334 +lon_0=-77 +x_0=243840.4876809754 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26786 : return "+proj=lcc +lat_1=41.71666666666667 +lat_2=42.68333333333333 +lat_0=41 +lon_0=-71.5 +x_0=182880.3657607315 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26787 : return "+proj=lcc +lat_1=41.28333333333333 +lat_2=41.48333333333333 +lat_0=41 +lon_0=-70.5 +x_0=60960.12192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26791 : return "+proj=lcc +lat_1=47.03333333333333 +lat_2=48.63333333333333 +lat_0=46.5 +lon_0=-93.09999999999999 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26792 : return "+proj=lcc +lat_1=45.61666666666667 +lat_2=47.05 +lat_0=45 +lon_0=-94.25 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26793 : return "+proj=lcc +lat_1=43.78333333333333 +lat_2=45.21666666666667 +lat_0=43 +lon_0=-94 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26794 : return "+proj=tmerc +lat_0=29.66666666666667 +lon_0=-88.83333333333333 +k=0.99996 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26795 : return "+proj=tmerc +lat_0=30.5 +lon_0=-90.33333333333333 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26796 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.999933333 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26797 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-92.5 +k=0.999933333 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26798 : return "+proj=tmerc +lat_0=36.16666666666666 +lon_0=-94.5 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26799 : return "+proj=lcc +lat_1=34.41666666666666 +lat_2=33.86666666666667 +lat_0=34.13333333333333 +lon_0=-118.3333333333333 +x_0=1276106.450596901 +y_0=1268253.006858014 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 26801 : return "+proj=tmerc +lat_0=41.5 +lon_0=-83.66666666666667 +k=0.999942857 +x_0=152400.3048006096 +y_0=0 +a=6378450.047548896 +b=6356826.621488444 +to_meter=0.3048006096012192";
+            case 26802 : return "+proj=tmerc +lat_0=41.5 +lon_0=-85.75 +k=0.999909091 +x_0=152400.3048006096 +y_0=0 +a=6378450.047548896 +b=6356826.621488444 +to_meter=0.3048006096012192";
+            case 26803 : return "+proj=tmerc +lat_0=41.5 +lon_0=-88.75 +k=0.999909091 +x_0=152400.3048006096 +y_0=0 +a=6378450.047548896 +b=6356826.621488444 +to_meter=0.3048006096012192";
+            case 26811 : return "+proj=lcc +lat_1=45.48333333333333 +lat_2=47.08333333333334 +lat_0=44.78333333333333 +lon_0=-87 +x_0=609601.2192024384 +y_0=0 +a=6378450.047548896 +b=6356826.621488444 +to_meter=0.3048006096012192";
+            case 26812 : return "+proj=lcc +lat_1=44.18333333333333 +lat_2=45.7 +lat_0=43.31666666666667 +lon_0=-84.33333333333333 +x_0=609601.2192024384 +y_0=0 +a=6378450.047548896 +b=6356826.621488444 +to_meter=0.3048006096012192";
+            case 26813 : return "+proj=lcc +lat_1=42.1 +lat_2=43.66666666666666 +lat_0=41.5 +lon_0=-84.33333333333333 +x_0=609601.2192024384 +y_0=0 +a=6378450.047548896 +b=6356826.621488444 +to_meter=0.3048006096012192";
+            case 26901 : return "+proj=utm +zone=1 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26902 : return "+proj=utm +zone=2 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26903 : return "+proj=utm +zone=3 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26904 : return "+proj=utm +zone=4 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26905 : return "+proj=utm +zone=5 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26906 : return "+proj=utm +zone=6 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26907 : return "+proj=utm +zone=7 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26908 : return "+proj=utm +zone=8 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26909 : return "+proj=utm +zone=9 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26910 : return "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26911 : return "+proj=utm +zone=11 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26912 : return "+proj=utm +zone=12 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26913 : return "+proj=utm +zone=13 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26914 : return "+proj=utm +zone=14 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26915 : return "+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26916 : return "+proj=utm +zone=16 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26917 : return "+proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26918 : return "+proj=utm +zone=18 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26919 : return "+proj=utm +zone=19 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26920 : return "+proj=utm +zone=20 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26921 : return "+proj=utm +zone=21 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26922 : return "+proj=utm +zone=22 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26923 : return "+proj=utm +zone=23 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26929 : return "+proj=tmerc +lat_0=30.5 +lon_0=-85.83333333333333 +k=0.99996 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26930 : return "+proj=tmerc +lat_0=30 +lon_0=-87.5 +k=0.999933333 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26931 : return "+proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000 +y_0=-5000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26932 : return "+proj=tmerc +lat_0=54 +lon_0=-142 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26933 : return "+proj=tmerc +lat_0=54 +lon_0=-146 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26934 : return "+proj=tmerc +lat_0=54 +lon_0=-150 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26935 : return "+proj=tmerc +lat_0=54 +lon_0=-154 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26936 : return "+proj=tmerc +lat_0=54 +lon_0=-158 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26937 : return "+proj=tmerc +lat_0=54 +lon_0=-162 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26938 : return "+proj=tmerc +lat_0=54 +lon_0=-166 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26939 : return "+proj=tmerc +lat_0=54 +lon_0=-170 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26940 : return "+proj=lcc +lat_1=53.83333333333334 +lat_2=51.83333333333334 +lat_0=51 +lon_0=-176 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26941 : return "+proj=lcc +lat_1=41.66666666666666 +lat_2=40 +lat_0=39.33333333333334 +lon_0=-122 +x_0=2000000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26942 : return "+proj=lcc +lat_1=39.83333333333334 +lat_2=38.33333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26943 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.06666666666667 +lat_0=36.5 +lon_0=-120.5 +x_0=2000000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26944 : return "+proj=lcc +lat_1=37.25 +lat_2=36 +lat_0=35.33333333333334 +lon_0=-119 +x_0=2000000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26945 : return "+proj=lcc +lat_1=35.46666666666667 +lat_2=34.03333333333333 +lat_0=33.5 +lon_0=-118 +x_0=2000000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26946 : return "+proj=lcc +lat_1=33.88333333333333 +lat_2=32.78333333333333 +lat_0=32.16666666666666 +lon_0=-116.25 +x_0=2000000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26948 : return "+proj=tmerc +lat_0=31 +lon_0=-110.1666666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26949 : return "+proj=tmerc +lat_0=31 +lon_0=-111.9166666666667 +k=0.9999 +x_0=213360 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26950 : return "+proj=tmerc +lat_0=31 +lon_0=-113.75 +k=0.999933333 +x_0=213360 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26951 : return "+proj=lcc +lat_1=36.23333333333333 +lat_2=34.93333333333333 +lat_0=34.33333333333334 +lon_0=-92 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26952 : return "+proj=lcc +lat_1=34.76666666666667 +lat_2=33.3 +lat_0=32.66666666666666 +lon_0=-92 +x_0=400000 +y_0=400000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26953 : return "+proj=lcc +lat_1=40.78333333333333 +lat_2=39.71666666666667 +lat_0=39.33333333333334 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26954 : return "+proj=lcc +lat_1=39.75 +lat_2=38.45 +lat_0=37.83333333333334 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26955 : return "+proj=lcc +lat_1=38.43333333333333 +lat_2=37.23333333333333 +lat_0=36.66666666666666 +lon_0=-105.5 +x_0=914401.8289 +y_0=304800.6096 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26956 : return "+proj=lcc +lat_1=41.86666666666667 +lat_2=41.2 +lat_0=40.83333333333334 +lon_0=-72.75 +x_0=304800.6096 +y_0=152400.3048 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26957 : return "+proj=tmerc +lat_0=38 +lon_0=-75.41666666666667 +k=0.999995 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26958 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-81 +k=0.999941177 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26959 : return "+proj=tmerc +lat_0=24.33333333333333 +lon_0=-82 +k=0.999941177 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26960 : return "+proj=lcc +lat_1=30.75 +lat_2=29.58333333333333 +lat_0=29 +lon_0=-84.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26961 : return "+proj=tmerc +lat_0=18.83333333333333 +lon_0=-155.5 +k=0.999966667 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26962 : return "+proj=tmerc +lat_0=20.33333333333333 +lon_0=-156.6666666666667 +k=0.999966667 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26963 : return "+proj=tmerc +lat_0=21.16666666666667 +lon_0=-158 +k=0.99999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26964 : return "+proj=tmerc +lat_0=21.83333333333333 +lon_0=-159.5 +k=0.99999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26965 : return "+proj=tmerc +lat_0=21.66666666666667 +lon_0=-160.1666666666667 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26966 : return "+proj=tmerc +lat_0=30 +lon_0=-82.16666666666667 +k=0.9999 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26967 : return "+proj=tmerc +lat_0=30 +lon_0=-84.16666666666667 +k=0.9999 +x_0=700000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26968 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-112.1666666666667 +k=0.9999473679999999 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26969 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-114 +k=0.9999473679999999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26970 : return "+proj=tmerc +lat_0=41.66666666666666 +lon_0=-115.75 +k=0.999933333 +x_0=800000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26971 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26972 : return "+proj=tmerc +lat_0=36.66666666666666 +lon_0=-90.16666666666667 +k=0.999941177 +x_0=700000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26973 : return "+proj=tmerc +lat_0=37.5 +lon_0=-85.66666666666667 +k=0.999966667 +x_0=100000 +y_0=250000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26974 : return "+proj=tmerc +lat_0=37.5 +lon_0=-87.08333333333333 +k=0.999966667 +x_0=900000 +y_0=250000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26975 : return "+proj=lcc +lat_1=43.26666666666667 +lat_2=42.06666666666667 +lat_0=41.5 +lon_0=-93.5 +x_0=1500000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26976 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.61666666666667 +lat_0=40 +lon_0=-93.5 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26977 : return "+proj=lcc +lat_1=39.78333333333333 +lat_2=38.71666666666667 +lat_0=38.33333333333334 +lon_0=-98 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26978 : return "+proj=lcc +lat_1=38.56666666666667 +lat_2=37.26666666666667 +lat_0=36.66666666666666 +lon_0=-98.5 +x_0=400000 +y_0=400000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26979 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=37.96666666666667 +lat_0=37.5 +lon_0=-84.25 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26980 : return "+proj=lcc +lat_1=37.93333333333333 +lat_2=36.73333333333333 +lat_0=36.33333333333334 +lon_0=-85.75 +x_0=500000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26981 : return "+proj=lcc +lat_1=32.66666666666666 +lat_2=31.16666666666667 +lat_0=30.5 +lon_0=-92.5 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26982 : return "+proj=lcc +lat_1=30.7 +lat_2=29.3 +lat_0=28.5 +lon_0=-91.33333333333333 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26983 : return "+proj=tmerc +lat_0=43.66666666666666 +lon_0=-68.5 +k=0.9999 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26984 : return "+proj=tmerc +lat_0=42.83333333333334 +lon_0=-70.16666666666667 +k=0.999966667 +x_0=900000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26985 : return "+proj=lcc +lat_1=39.45 +lat_2=38.3 +lat_0=37.66666666666666 +lon_0=-77 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26986 : return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26987 : return "+proj=lcc +lat_1=41.48333333333333 +lat_2=41.28333333333333 +lat_0=41 +lon_0=-70.5 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26988 : return "+proj=lcc +lat_1=47.08333333333334 +lat_2=45.48333333333333 +lat_0=44.78333333333333 +lon_0=-87 +x_0=8000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26989 : return "+proj=lcc +lat_1=45.7 +lat_2=44.18333333333333 +lat_0=43.31666666666667 +lon_0=-84.36666666666666 +x_0=6000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26990 : return "+proj=lcc +lat_1=43.66666666666666 +lat_2=42.1 +lat_0=41.5 +lon_0=-84.36666666666666 +x_0=4000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26991 : return "+proj=lcc +lat_1=48.63333333333333 +lat_2=47.03333333333333 +lat_0=46.5 +lon_0=-93.09999999999999 +x_0=800000 +y_0=100000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26992 : return "+proj=lcc +lat_1=47.05 +lat_2=45.61666666666667 +lat_0=45 +lon_0=-94.25 +x_0=800000 +y_0=100000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26993 : return "+proj=lcc +lat_1=45.21666666666667 +lat_2=43.78333333333333 +lat_0=43 +lon_0=-94 +x_0=800000 +y_0=100000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26994 : return "+proj=tmerc +lat_0=29.5 +lon_0=-88.83333333333333 +k=0.99995 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26995 : return "+proj=tmerc +lat_0=29.5 +lon_0=-90.33333333333333 +k=0.99995 +x_0=700000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26996 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.999933333 +x_0=250000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26997 : return "+proj=tmerc +lat_0=35.83333333333334 +lon_0=-92.5 +k=0.999933333 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 26998 : return "+proj=tmerc +lat_0=36.16666666666666 +lon_0=-94.5 +k=0.999941177 +x_0=850000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 27037 : return "+proj=utm +zone=37 +ellps=clrk80 +units=m";
+            case 27038 : return "+proj=utm +zone=38 +ellps=clrk80 +units=m";
+            case 27039 : return "+proj=utm +zone=39 +ellps=clrk80 +units=m";
+            case 27040 : return "+proj=utm +zone=40 +ellps=clrk80 +units=m";
+            case 27120 : return "+proj=utm +zone=20 +ellps=intl +units=m";
+            case 27200 : return "+proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +ellps=intl +datum=nzgd49 +units=m";
+            case 27205 : return "+proj=tmerc +lat_0=-36.87986527777778 +lon_0=174.7643393611111 +k=0.9999 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27206 : return "+proj=tmerc +lat_0=-37.76124980555556 +lon_0=176.46619725 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27207 : return "+proj=tmerc +lat_0=-38.62470277777778 +lon_0=177.8856362777778 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27208 : return "+proj=tmerc +lat_0=-39.65092930555556 +lon_0=176.6736805277778 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27209 : return "+proj=tmerc +lat_0=-39.13575830555556 +lon_0=174.22801175 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27210 : return "+proj=tmerc +lat_0=-39.51247038888889 +lon_0=175.6400368055556 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27211 : return "+proj=tmerc +lat_0=-40.24194713888889 +lon_0=175.4880996111111 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27212 : return "+proj=tmerc +lat_0=-40.92553263888889 +lon_0=175.6473496666667 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27213 : return "+proj=tmerc +lat_0=-41.30131963888888 +lon_0=174.7766231111111 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27214 : return "+proj=tmerc +lat_0=-40.71475905555556 +lon_0=172.6720465 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27215 : return "+proj=tmerc +lat_0=-41.27454472222222 +lon_0=173.2993168055555 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27216 : return "+proj=tmerc +lat_0=-41.28991152777778 +lon_0=172.1090281944444 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27217 : return "+proj=tmerc +lat_0=-41.81080286111111 +lon_0=171.5812600555556 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27218 : return "+proj=tmerc +lat_0=-42.33369427777778 +lon_0=171.5497713055556 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27219 : return "+proj=tmerc +lat_0=-42.68911658333333 +lon_0=173.0101333888889 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27220 : return "+proj=tmerc +lat_0=-41.54448666666666 +lon_0=173.8020741111111 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27221 : return "+proj=tmerc +lat_0=-42.88632236111111 +lon_0=170.9799935 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27222 : return "+proj=tmerc +lat_0=-43.11012813888889 +lon_0=170.2609258333333 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27223 : return "+proj=tmerc +lat_0=-43.97780288888889 +lon_0=168.606267 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27224 : return "+proj=tmerc +lat_0=-43.59063758333333 +lon_0=172.7271935833333 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27225 : return "+proj=tmerc +lat_0=-43.74871155555556 +lon_0=171.3607484722222 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27226 : return "+proj=tmerc +lat_0=-44.40222036111111 +lon_0=171.0572508333333 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27227 : return "+proj=tmerc +lat_0=-44.73526797222222 +lon_0=169.4677550833333 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27228 : return "+proj=tmerc +lat_0=-45.13290258333333 +lon_0=168.3986411944444 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27229 : return "+proj=tmerc +lat_0=-45.56372616666666 +lon_0=167.7388617777778 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27230 : return "+proj=tmerc +lat_0=-45.81619661111111 +lon_0=170.6285951666667 +k=1 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27231 : return "+proj=tmerc +lat_0=-45.86151336111111 +lon_0=170.2825891111111 +k=0.99996 +x_0=300000 +y_0=700000 +ellps=intl +datum=nzgd49 +units=m";
+            case 27232 : return "+proj=tmerc +lat_0=-46.60000961111111 +lon_0=168.342872 +k=1 +x_0=300002.66 +y_0=699999.58 +ellps=intl +datum=nzgd49 +units=m";
+            case 27258 : return "+proj=utm +zone=58 +south +ellps=intl +datum=nzgd49 +units=m";
+            case 27259 : return "+proj=utm +zone=59 +south +ellps=intl +datum=nzgd49 +units=m";
+            case 27260 : return "+proj=utm +zone=60 +south +ellps=intl +datum=nzgd49 +units=m";
+            case 27291 : return "+proj=tmerc +lat_0=-39 +lon_0=175.5 +k=1 +x_0=274319.5243848086 +y_0=365759.3658464114 +ellps=intl +datum=nzgd49 +to_meter=0.9143984146160287";
+            case 27292 : return "+proj=tmerc +lat_0=-44 +lon_0=171.5 +k=1 +x_0=457199.2073080143 +y_0=457199.2073080143 +ellps=intl +datum=nzgd49 +to_meter=0.9143984146160287";
+            case 27391 : return "+proj=tmerc +lat_0=58 +lon_0=-4.666666666666667 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27392 : return "+proj=tmerc +lat_0=58 +lon_0=-2.333333333333333 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27393 : return "+proj=tmerc +lat_0=58 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27394 : return "+proj=tmerc +lat_0=58 +lon_0=2.5 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27395 : return "+proj=tmerc +lat_0=58 +lon_0=6.166666666666667 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27396 : return "+proj=tmerc +lat_0=58 +lon_0=10.16666666666667 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27397 : return "+proj=tmerc +lat_0=58 +lon_0=14.16666666666667 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27398 : return "+proj=tmerc +lat_0=58 +lon_0=18.33333333333333 +k=1 +x_0=0 +y_0=0 +a=6377492.018 +b=6356173.508712696 +towgs84=278.3,93,474.5,7.889,0.05,-6.61,6.21 +pm=oslo +units=m";
+            case 27429 : return "+proj=utm +zone=29 +ellps=intl +units=m";
+            case 27492 : return "+proj=tmerc +lat_0=39.66666666666666 +lon_0=-8.131906111111112 +k=1 +x_0=180.598 +y_0=-86.98999999999999 +ellps=intl +units=m";
+            case 27500 : return "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=5.399999999999999 +k_0=0.99950908 +x_0=500000 +y_0=300000 +a=6376523 +b=6355862.933255573 +pm=paris +units=m";
+            case 27561 : return "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27562 : return "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27563 : return "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27564 : return "+proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.99994471 +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27571 : return "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27572 : return "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27573 : return "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=3200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27574 : return "+proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.99994471 +x_0=234.358 +y_0=4185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27581 : return "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27582 : return "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27583 : return "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=3200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27584 : return "+proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.99994471 +x_0=234.358 +y_0=4185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27591 : return "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27592 : return "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27593 : return "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27594 : return "+proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.99994471 +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
+            case 27700 : return "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m";
+            case 28191 : return "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
+            case 28192 : return "+proj=tmerc +lat_0=31.73409694444445 +lon_0=35.21208055555556 +k=1 +x_0=170251.555 +y_0=1126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
+            case 28193 : return "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=1126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
+            case 28232 : return "+proj=utm +zone=32 +south +a=6378249.2 +b=6356515 +units=m";
+            case 28348 : return "+proj=utm +zone=48 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28349 : return "+proj=utm +zone=49 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28350 : return "+proj=utm +zone=50 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28351 : return "+proj=utm +zone=51 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28352 : return "+proj=utm +zone=52 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28353 : return "+proj=utm +zone=53 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28354 : return "+proj=utm +zone=54 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28355 : return "+proj=utm +zone=55 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28356 : return "+proj=utm +zone=56 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28357 : return "+proj=utm +zone=57 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28358 : return "+proj=utm +zone=58 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 28402 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=2500000 +y_0=0 +ellps=krass +units=m";
+            case 28403 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=3500000 +y_0=0 +ellps=krass +units=m";
+            case 28404 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m";
+            case 28405 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +units=m";
+            case 28406 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=6500000 +y_0=0 +ellps=krass +units=m";
+            case 28407 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=7500000 +y_0=0 +ellps=krass +units=m";
+            case 28408 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=8500000 +y_0=0 +ellps=krass +units=m";
+            case 28409 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=9500000 +y_0=0 +ellps=krass +units=m";
+            case 28410 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=10500000 +y_0=0 +ellps=krass +units=m";
+            case 28411 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=11500000 +y_0=0 +ellps=krass +units=m";
+            case 28412 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=12500000 +y_0=0 +ellps=krass +units=m";
+            case 28413 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=13500000 +y_0=0 +ellps=krass +units=m";
+            case 28414 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=14500000 +y_0=0 +ellps=krass +units=m";
+            case 28415 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=15500000 +y_0=0 +ellps=krass +units=m";
+            case 28416 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=16500000 +y_0=0 +ellps=krass +units=m";
+            case 28417 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=17500000 +y_0=0 +ellps=krass +units=m";
+            case 28418 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=18500000 +y_0=0 +ellps=krass +units=m";
+            case 28419 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=19500000 +y_0=0 +ellps=krass +units=m";
+            case 28420 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=20500000 +y_0=0 +ellps=krass +units=m";
+            case 28421 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=21500000 +y_0=0 +ellps=krass +units=m";
+            case 28422 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=22500000 +y_0=0 +ellps=krass +units=m";
+            case 28423 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=23500000 +y_0=0 +ellps=krass +units=m";
+            case 28424 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=24500000 +y_0=0 +ellps=krass +units=m";
+            case 28425 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=25500000 +y_0=0 +ellps=krass +units=m";
+            case 28426 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=26500000 +y_0=0 +ellps=krass +units=m";
+            case 28427 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=27500000 +y_0=0 +ellps=krass +units=m";
+            case 28428 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=28500000 +y_0=0 +ellps=krass +units=m";
+            case 28429 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=29500000 +y_0=0 +ellps=krass +units=m";
+            case 28430 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=30500000 +y_0=0 +ellps=krass +units=m";
+            case 28431 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=31500000 +y_0=0 +ellps=krass +units=m";
+            case 28432 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=32500000 +y_0=0 +ellps=krass +units=m";
+            case 28462 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28463 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28464 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28465 : return "+proj=tmerc +lat_0=0 +lon_0=27 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28466 : return "+proj=tmerc +lat_0=0 +lon_0=33 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28467 : return "+proj=tmerc +lat_0=0 +lon_0=39 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28468 : return "+proj=tmerc +lat_0=0 +lon_0=45 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28469 : return "+proj=tmerc +lat_0=0 +lon_0=51 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28470 : return "+proj=tmerc +lat_0=0 +lon_0=57 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28471 : return "+proj=tmerc +lat_0=0 +lon_0=63 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28472 : return "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28473 : return "+proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28474 : return "+proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28475 : return "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28476 : return "+proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28477 : return "+proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28478 : return "+proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28479 : return "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28480 : return "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28481 : return "+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28482 : return "+proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28483 : return "+proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28484 : return "+proj=tmerc +lat_0=0 +lon_0=141 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28485 : return "+proj=tmerc +lat_0=0 +lon_0=147 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28486 : return "+proj=tmerc +lat_0=0 +lon_0=153 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28487 : return "+proj=tmerc +lat_0=0 +lon_0=159 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28488 : return "+proj=tmerc +lat_0=0 +lon_0=165 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28489 : return "+proj=tmerc +lat_0=0 +lon_0=171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28490 : return "+proj=tmerc +lat_0=0 +lon_0=177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28491 : return "+proj=tmerc +lat_0=0 +lon_0=-177 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28492 : return "+proj=tmerc +lat_0=0 +lon_0=-171 +k=1 +x_0=500000 +y_0=0 +ellps=krass +units=m";
+            case 28600 : return "+proj=tmerc +lat_0=24.45 +lon_0=51.21666666666667 +k=0.99999 +x_0=200000 +y_0=300000 +ellps=intl +units=m";
+            case 28991 : return "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 28992 : return "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m";
+            case 29100 : return "+proj=poly +lat_0=0 +lon_0=-54 +x_0=5000000 +y_0=10000000 +ellps=GRS67 +units=m";
+            case 29101 : return "+proj=poly +lat_0=0 +lon_0=-54 +x_0=5000000 +y_0=10000000 +ellps=aust_SA +units=m";
+            case 29118 : return "+proj=utm +zone=18 +ellps=GRS67 +units=m";
+            case 29119 : return "+proj=utm +zone=19 +ellps=GRS67 +units=m";
+            case 29120 : return "+proj=utm +zone=20 +ellps=GRS67 +units=m";
+            case 29121 : return "+proj=utm +zone=21 +ellps=GRS67 +units=m";
+            case 29122 : return "+proj=utm +zone=22 +ellps=GRS67 +units=m";
+            case 29168 : return "+proj=utm +zone=18 +ellps=aust_SA +units=m";
+            case 29169 : return "+proj=utm +zone=19 +ellps=aust_SA +units=m";
+            case 29170 : return "+proj=utm +zone=20 +ellps=aust_SA +units=m";
+            case 29171 : return "+proj=utm +zone=21 +ellps=aust_SA +units=m";
+            case 29172 : return "+proj=utm +zone=22 +ellps=aust_SA +units=m";
+            case 29177 : return "+proj=utm +zone=17 +south +ellps=GRS67 +units=m";
+            case 29178 : return "+proj=utm +zone=18 +south +ellps=GRS67 +units=m";
+            case 29179 : return "+proj=utm +zone=19 +south +ellps=GRS67 +units=m";
+            case 29180 : return "+proj=utm +zone=20 +south +ellps=GRS67 +units=m";
+            case 29181 : return "+proj=utm +zone=21 +south +ellps=GRS67 +units=m";
+            case 29182 : return "+proj=utm +zone=22 +south +ellps=GRS67 +units=m";
+            case 29183 : return "+proj=utm +zone=23 +south +ellps=GRS67 +units=m";
+            case 29184 : return "+proj=utm +zone=24 +south +ellps=GRS67 +units=m";
+            case 29185 : return "+proj=utm +zone=25 +south +ellps=GRS67 +units=m";
+            case 29187 : return "+proj=utm +zone=17 +south +ellps=aust_SA +units=m";
+            case 29188 : return "+proj=utm +zone=18 +south +ellps=aust_SA +units=m";
+            case 29189 : return "+proj=utm +zone=19 +south +ellps=aust_SA +units=m";
+            case 29190 : return "+proj=utm +zone=20 +south +ellps=aust_SA +units=m";
+            case 29191 : return "+proj=utm +zone=21 +south +ellps=aust_SA +units=m";
+            case 29192 : return "+proj=utm +zone=22 +south +ellps=aust_SA +units=m";
+            case 29193 : return "+proj=utm +zone=23 +south +ellps=aust_SA +units=m";
+            case 29194 : return "+proj=utm +zone=24 +south +ellps=aust_SA +units=m";
+            case 29195 : return "+proj=utm +zone=25 +south +ellps=aust_SA +units=m";
+            case 29220 : return "+proj=utm +zone=20 +south +ellps=intl +towgs84=-355,21,72,0,0,0,0 +units=m";
+            case 29221 : return "+proj=utm +zone=21 +south +ellps=intl +towgs84=-355,21,72,0,0,0,0 +units=m";
+            case 29333 : return "+proj=utm +zone=33 +south +ellps=bess_nam +units=m";
+            case 29635 : return "+proj=utm +zone=35 +a=6378249.2 +b=6356515 +units=m";
+            case 29636 : return "+proj=utm +zone=36 +a=6378249.2 +b=6356515 +units=m";
+            case 29700 : return "+proj=omerc +lat_0=-18.9 +lonc=44.10000000000001 +alpha=18.9 +k=0.9995000000000001 +x_0=400000 +y_0=800000 +ellps=intl +towgs84=-189,-242,-91,0,0,0,0 +pm=paris +units=m";
+            case 29702 : return "+proj=omerc +lat_0=-18.9 +lonc=44.10000000000001 +alpha=18.9 +k=0.9995000000000001 +x_0=400000 +y_0=800000 +ellps=intl +towgs84=-189,-242,-91,0,0,0,0 +pm=paris +units=m";
+            case 29738 : return "+proj=utm +zone=38 +south +ellps=intl +towgs84=-189,-242,-91,0,0,0,0 +units=m";
+            case 29739 : return "+proj=utm +zone=39 +south +ellps=intl +towgs84=-189,-242,-91,0,0,0,0 +units=m";
+            case 29849 : return "+proj=utm +zone=49 +ellps=evrstSS +units=m";
+            case 29850 : return "+proj=utm +zone=50 +ellps=evrstSS +units=m";
+            case 29871 : return "+proj=omerc +lat_0=4 +lonc=115 +alpha=53.31582047222222 +k=0.99984 +x_0=590476.8714630401 +y_0=442857.653094361 +ellps=evrstSS +to_meter=20.11676512155263";
+            case 29872 : return "+proj=omerc +lat_0=4 +lonc=115 +alpha=53.31582047222222 +k=0.99984 +x_0=590476.8727431979 +y_0=442857.6545573985 +ellps=evrstSS +to_meter=0.3047994715386762";
+            case 29873 : return "+proj=omerc +lat_0=4 +lonc=115 +alpha=53.31582047222222 +k=0.99984 +x_0=590476.87 +y_0=442857.65 +ellps=evrstSS +units=m";
+            case 29900 : return "+proj=tmerc +lat_0=53.5 +lon_0=-8 +k=1.000035 +x_0=200000 +y_0=250000 +a=6377340.189 +b=6356034.447938534 +units=m";
+            case 29901 : return "+proj=tmerc +lat_0=53.5 +lon_0=-8 +k=1 +x_0=200000 +y_0=250000 +ellps=airy +towgs84=482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15 +units=m";
+            case 29902 : return "+proj=tmerc +lat_0=53.5 +lon_0=-8 +k=1.000035 +x_0=200000 +y_0=250000 +a=6377340.189 +b=6356034.447938534 +units=m";
+            case 29903 : return "+proj=tmerc +lat_0=53.5 +lon_0=-8 +k=1.000035 +x_0=200000 +y_0=250000 +a=6377340.189 +b=6356034.447938534 +units=m";
+            case 30161 : return "+proj=tmerc +lat_0=33 +lon_0=129.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30162 : return "+proj=tmerc +lat_0=33 +lon_0=131 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30163 : return "+proj=tmerc +lat_0=36 +lon_0=132.1666666666667 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30164 : return "+proj=tmerc +lat_0=33 +lon_0=133.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30165 : return "+proj=tmerc +lat_0=36 +lon_0=134.3333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30166 : return "+proj=tmerc +lat_0=36 +lon_0=136 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30167 : return "+proj=tmerc +lat_0=36 +lon_0=137.1666666666667 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30168 : return "+proj=tmerc +lat_0=36 +lon_0=138.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30169 : return "+proj=tmerc +lat_0=36 +lon_0=139.8333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30170 : return "+proj=tmerc +lat_0=40 +lon_0=140.8333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30171 : return "+proj=tmerc +lat_0=44 +lon_0=140.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30172 : return "+proj=tmerc +lat_0=44 +lon_0=142.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30173 : return "+proj=tmerc +lat_0=44 +lon_0=144.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30174 : return "+proj=tmerc +lat_0=26 +lon_0=142 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30175 : return "+proj=tmerc +lat_0=26 +lon_0=127.5 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30176 : return "+proj=tmerc +lat_0=26 +lon_0=124 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30177 : return "+proj=tmerc +lat_0=26 +lon_0=131 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30178 : return "+proj=tmerc +lat_0=20 +lon_0=136 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30179 : return "+proj=tmerc +lat_0=26 +lon_0=154 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+            case 30200 : return "+proj=cass +lat_0=10.44166666666667 +lon_0=-61.33333333333334 +x_0=86501.46392051999 +y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.201166195164";
+            case 30339 : return "+proj=utm +zone=39 +ellps=helmert +units=m";
+            case 30340 : return "+proj=utm +zone=40 +ellps=helmert +units=m";
+            case 30491 : return "+proj=lcc +lat_1=36 +lat_0=36 +lon_0=2.7 +k_0=0.999625544 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +towgs84=-73,-247,227,0,0,0,0 +units=m";
+            case 30492 : return "+proj=lcc +lat_1=33.3 +lat_0=33.3 +lon_0=2.7 +k_0=0.999625769 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +towgs84=-73,-247,227,0,0,0,0 +units=m";
+            case 30493 : return "+proj=lcc +lat_1=36 +lat_0=36 +lon_0=2.7 +k_0=0.999625544 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +units=m";
+            case 30494 : return "+proj=lcc +lat_1=33.3 +lat_0=33.3 +lon_0=2.7 +k_0=0.999625769 +x_0=500000 +y_0=300000 +a=6378249.2 +b=6356515 +units=m";
+            case 30729 : return "+proj=utm +zone=29 +ellps=clrk80 +units=m";
+            case 30730 : return "+proj=utm +zone=30 +ellps=clrk80 +units=m";
+            case 30731 : return "+proj=utm +zone=31 +ellps=clrk80 +units=m";
+            case 30732 : return "+proj=utm +zone=32 +ellps=clrk80 +units=m";
+            case 30791 : return "+proj=lcc +lat_1=36 +lat_0=36 +lon_0=2.7 +k_0=0.999625544 +x_0=500135 +y_0=300090 +ellps=clrk80 +units=m";
+            case 30792 : return "+proj=lcc +lat_1=33.3 +lat_0=33.3 +lon_0=2.7 +k_0=0.999625769 +x_0=500135 +y_0=300090 +ellps=clrk80 +units=m";
+            case 30800 : return "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m";
+            case 31028 : return "+proj=utm +zone=28 +a=6378249.2 +b=6356515 +units=m";
+            case 31121 : return "+proj=utm +zone=21 +ellps=intl +towgs84=-265,120,-358,0,0,0,0 +units=m";
+            case 31154 : return "+proj=tmerc +lat_0=0 +lon_0=-54 +k=0.9996 +x_0=500000 +y_0=0 +ellps=intl +towgs84=-265,120,-358,0,0,0,0 +units=m";
+            case 31170 : return "+proj=tmerc +lat_0=0 +lon_0=-55.68333333333333 +k=0.9996 +x_0=500000 +y_0=0 +ellps=intl +towgs84=-265,120,-358,0,0,0,0 +units=m";
+            case 31171 : return "+proj=tmerc +lat_0=0 +lon_0=-55.68333333333333 +k=0.9999 +x_0=500000 +y_0=0 +ellps=intl +towgs84=-265,120,-358,0,0,0,0 +units=m";
+            case 31251 : return "+proj=tmerc +lat_0=0 +lon_0=28 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +pm=ferro +units=m";
+            case 31252 : return "+proj=tmerc +lat_0=0 +lon_0=31 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +pm=ferro +units=m";
+            case 31253 : return "+proj=tmerc +lat_0=0 +lon_0=34 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +pm=ferro +units=m";
+            case 31254 : return "+proj=tmerc +lat_0=0 +lon_0=10.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31255 : return "+proj=tmerc +lat_0=0 +lon_0=13.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31256 : return "+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31257 : return "+proj=tmerc +lat_0=0 +lon_0=10.33333333333333 +k=1 +x_0=150000 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31258 : return "+proj=tmerc +lat_0=0 +lon_0=13.33333333333333 +k=1 +x_0=450000 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31259 : return "+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=750000 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31265 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31266 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=1 +x_0=6500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31267 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=1 +x_0=7500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31268 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=1 +x_0=8500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31275 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9999 +x_0=5500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31276 : return "+proj=tmerc +lat_0=0 +lon_0=18 +k=0.9999 +x_0=6500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31277 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=0.9999 +x_0=7500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31278 : return "+proj=tmerc +lat_0=0 +lon_0=21 +k=0.9999 +x_0=7500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31279 : return "+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9999 +x_0=8500000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31281 : return "+proj=tmerc +lat_0=0 +lon_0=28 +k=1 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31282 : return "+proj=tmerc +lat_0=0 +lon_0=31 +k=1 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31283 : return "+proj=tmerc +lat_0=0 +lon_0=34 +k=1 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31284 : return "+proj=tmerc +lat_0=0 +lon_0=10.33333333333333 +k=1 +x_0=150000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31285 : return "+proj=tmerc +lat_0=0 +lon_0=13.33333333333333 +k=1 +x_0=450000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31286 : return "+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=750000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31287 : return "+proj=lcc +lat_1=49 +lat_2=46 +lat_0=47.5 +lon_0=13.33333333333333 +x_0=400000 +y_0=400000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31288 : return "+proj=tmerc +lat_0=0 +lon_0=28 +k=1 +x_0=150000 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31289 : return "+proj=tmerc +lat_0=0 +lon_0=31 +k=1 +x_0=450000 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31290 : return "+proj=tmerc +lat_0=0 +lon_0=34 +k=1 +x_0=750000 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31291 : return "+proj=tmerc +lat_0=0 +lon_0=28 +k=1 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31292 : return "+proj=tmerc +lat_0=0 +lon_0=31 +k=1 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31293 : return "+proj=tmerc +lat_0=0 +lon_0=34 +k=1 +x_0=0 +y_0=0 +ellps=bessel +pm=ferro +units=m";
+            case 31294 : return "+proj=tmerc +lat_0=0 +lon_0=10.33333333333333 +k=1 +x_0=150000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31295 : return "+proj=tmerc +lat_0=0 +lon_0=13.33333333333333 +k=1 +x_0=450000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31296 : return "+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=750000 +y_0=0 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31297 : return "+proj=lcc +lat_1=49 +lat_2=46 +lat_0=47.5 +lon_0=13.33333333333333 +x_0=400000 +y_0=400000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m";
+            case 31300 : return "+proj=lcc +lat_1=49.83333333333334 +lat_2=51.16666666666666 +lat_0=90 +lon_0=4.356939722222222 +x_0=150000.01256 +y_0=5400088.4378 +ellps=intl +towgs84=106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1 +units=m";
+            case 31370 : return "+proj=lcc +lat_1=51.16666723333333 +lat_2=49.8333339 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1 +units=m";
+            case 31461 : return "+proj=tmerc +lat_0=0 +lon_0=3 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31462 : return "+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31463 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31464 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31465 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31466 : return "+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31467 : return "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31468 : return "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31469 : return "+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m";
+            case 31528 : return "+proj=utm +zone=28 +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0 +units=m";
+            case 31529 : return "+proj=utm +zone=29 +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0 +units=m";
+            case 31600 : return "+proj=sterea +lat_0=45.9 +lon_0=25.39246588888889 +k=0.9996667 +x_0=500000 +y_0=500000 +ellps=intl +units=m";
+            case 31700 : return "+proj=sterea +lat_0=46 +lon_0=25 +k=0.99975 +x_0=500000 +y_0=500000 +ellps=krass +units=m";
+            case 31838 : return "+proj=utm +zone=38 +ellps=WGS84 +towgs84=-3.2,-5.7,2.8,0,0,0,0 +units=m";
+            case 31839 : return "+proj=utm +zone=39 +ellps=WGS84 +towgs84=-3.2,-5.7,2.8,0,0,0,0 +units=m";
+            case 31900 : return "+proj=tmerc +lat_0=0 +lon_0=48 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 31901 : return "+proj=tmerc +lat_0=0 +lon_0=48 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m";
+            case 31965 : return "+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31966 : return "+proj=utm +zone=12 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31967 : return "+proj=utm +zone=13 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31968 : return "+proj=utm +zone=14 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31969 : return "+proj=utm +zone=15 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31970 : return "+proj=utm +zone=16 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31971 : return "+proj=utm +zone=17 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31972 : return "+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31973 : return "+proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31974 : return "+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31975 : return "+proj=utm +zone=21 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31976 : return "+proj=utm +zone=22 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31977 : return "+proj=utm +zone=17 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31978 : return "+proj=utm +zone=18 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31979 : return "+proj=utm +zone=19 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31980 : return "+proj=utm +zone=20 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31981 : return "+proj=utm +zone=21 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31982 : return "+proj=utm +zone=22 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31983 : return "+proj=utm +zone=23 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31984 : return "+proj=utm +zone=24 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31985 : return "+proj=utm +zone=25 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31986 : return "+proj=utm +zone=17 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31987 : return "+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31988 : return "+proj=utm +zone=19 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31989 : return "+proj=utm +zone=20 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31990 : return "+proj=utm +zone=21 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31991 : return "+proj=utm +zone=22 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31992 : return "+proj=utm +zone=17 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31993 : return "+proj=utm +zone=18 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31994 : return "+proj=utm +zone=19 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31995 : return "+proj=utm +zone=20 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31996 : return "+proj=utm +zone=21 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31997 : return "+proj=utm +zone=22 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31998 : return "+proj=utm +zone=23 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 31999 : return "+proj=utm +zone=24 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 32000 : return "+proj=utm +zone=25 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+            case 32001 : return "+proj=lcc +lat_1=48.71666666666667 +lat_2=47.85 +lat_0=47 +lon_0=-109.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32002 : return "+proj=lcc +lat_1=47.88333333333333 +lat_2=46.45 +lat_0=45.83333333333334 +lon_0=-109.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32003 : return "+proj=lcc +lat_1=46.4 +lat_2=44.86666666666667 +lat_0=44 +lon_0=-109.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32005 : return "+proj=lcc +lat_1=41.85 +lat_2=42.81666666666667 +lat_0=41.33333333333334 +lon_0=-100 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32006 : return "+proj=lcc +lat_1=40.28333333333333 +lat_2=41.71666666666667 +lat_0=39.66666666666666 +lon_0=-99.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32007 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32008 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32009 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32010 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32011 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.66666666666667 +k=0.9999749999999999 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32012 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32013 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32014 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32015 : return "+proj=tmerc +lat_0=40 +lon_0=-74.33333333333333 +k=0.999966667 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32016 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32017 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32018 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.5 +lon_0=-74 +x_0=304800.6096012192 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32019 : return "+proj=lcc +lat_1=34.33333333333334 +lat_2=36.16666666666666 +lat_0=33.75 +lon_0=-79 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32020 : return "+proj=lcc +lat_1=47.43333333333333 +lat_2=48.73333333333333 +lat_0=47 +lon_0=-100.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32021 : return "+proj=lcc +lat_1=46.18333333333333 +lat_2=47.48333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32022 : return "+proj=lcc +lat_1=40.43333333333333 +lat_2=41.7 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32023 : return "+proj=lcc +lat_1=38.73333333333333 +lat_2=40.03333333333333 +lat_0=38 +lon_0=-82.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32024 : return "+proj=lcc +lat_1=35.56666666666667 +lat_2=36.76666666666667 +lat_0=35 +lon_0=-98 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32025 : return "+proj=lcc +lat_1=33.93333333333333 +lat_2=35.23333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32026 : return "+proj=lcc +lat_1=44.33333333333334 +lat_2=46 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32027 : return "+proj=lcc +lat_1=42.33333333333334 +lat_2=44 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32028 : return "+proj=lcc +lat_1=40.88333333333333 +lat_2=41.95 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32029 : return "+proj=lcc +lat_1=39.93333333333333 +lat_2=40.8 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32030 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.9999938 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32031 : return "+proj=lcc +lat_1=33.76666666666667 +lat_2=34.96666666666667 +lat_0=33 +lon_0=-81 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32033 : return "+proj=lcc +lat_1=32.33333333333334 +lat_2=33.66666666666666 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32034 : return "+proj=lcc +lat_1=44.41666666666666 +lat_2=45.68333333333333 +lat_0=43.83333333333334 +lon_0=-100 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32035 : return "+proj=lcc +lat_1=42.83333333333334 +lat_2=44.4 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32036 : return "+proj=lcc +lat_1=35.25 +lat_2=36.41666666666666 +lat_0=34.66666666666666 +lon_0=-86 +x_0=30480.06096012192 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32037 : return "+proj=lcc +lat_1=34.65 +lat_2=36.18333333333333 +lat_0=34 +lon_0=-101.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32038 : return "+proj=lcc +lat_1=32.13333333333333 +lat_2=33.96666666666667 +lat_0=31.66666666666667 +lon_0=-97.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32039 : return "+proj=lcc +lat_1=30.11666666666667 +lat_2=31.88333333333333 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32040 : return "+proj=lcc +lat_1=28.38333333333333 +lat_2=30.28333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32041 : return "+proj=lcc +lat_1=26.16666666666667 +lat_2=27.83333333333333 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32042 : return "+proj=lcc +lat_1=40.71666666666667 +lat_2=41.78333333333333 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32043 : return "+proj=lcc +lat_1=39.01666666666667 +lat_2=40.65 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32044 : return "+proj=lcc +lat_1=37.21666666666667 +lat_2=38.35 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32045 : return "+proj=tmerc +lat_0=42.5 +lon_0=-72.5 +k=0.999964286 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32046 : return "+proj=lcc +lat_1=38.03333333333333 +lat_2=39.2 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32047 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=37.96666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32048 : return "+proj=lcc +lat_1=47.5 +lat_2=48.73333333333333 +lat_0=47 +lon_0=-120.8333333333333 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32049 : return "+proj=lcc +lat_1=45.83333333333334 +lat_2=47.33333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32050 : return "+proj=lcc +lat_1=39 +lat_2=40.25 +lat_0=38.5 +lon_0=-79.5 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32051 : return "+proj=lcc +lat_1=37.48333333333333 +lat_2=38.88333333333333 +lat_0=37 +lon_0=-81 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32052 : return "+proj=lcc +lat_1=45.56666666666667 +lat_2=46.76666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32053 : return "+proj=lcc +lat_1=44.25 +lat_2=45.5 +lat_0=43.83333333333334 +lon_0=-90 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32054 : return "+proj=lcc +lat_1=42.73333333333333 +lat_2=44.06666666666667 +lat_0=42 +lon_0=-90 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32055 : return "+proj=tmerc +lat_0=40.66666666666666 +lon_0=-105.1666666666667 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32056 : return "+proj=tmerc +lat_0=40.66666666666666 +lon_0=-107.3333333333333 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32057 : return "+proj=tmerc +lat_0=40.66666666666666 +lon_0=-108.75 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32058 : return "+proj=tmerc +lat_0=40.66666666666666 +lon_0=-110.0833333333333 +k=0.999941177 +x_0=152400.3048006096 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32061 : return "+proj=lcc +lat_1=16.81666666666667 +lat_0=16.81666666666667 +lon_0=-90.33333333333333 +k_0=0.99992226 +x_0=500000 +y_0=292209.579 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32062 : return "+proj=lcc +lat_1=14.9 +lat_0=14.9 +lon_0=-90.33333333333333 +k_0=0.99989906 +x_0=500000 +y_0=325992.681 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32064 : return "+proj=tmerc +lat_0=0 +lon_0=-99 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32065 : return "+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32066 : return "+proj=tmerc +lat_0=0 +lon_0=-87 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32067 : return "+proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32074 : return "+proj=tmerc +lat_0=0 +lon_0=-99 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32075 : return "+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32076 : return "+proj=tmerc +lat_0=0 +lon_0=-87 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32077 : return "+proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32081 : return "+proj=tmerc +lat_0=0 +lon_0=-53 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32082 : return "+proj=tmerc +lat_0=0 +lon_0=-56 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32083 : return "+proj=tmerc +lat_0=0 +lon_0=-58.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32084 : return "+proj=tmerc +lat_0=0 +lon_0=-61.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32085 : return "+proj=tmerc +lat_0=0 +lon_0=-64.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32086 : return "+proj=tmerc +lat_0=0 +lon_0=-67.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32098 : return "+proj=lcc +lat_1=60 +lat_2=46 +lat_0=44 +lon_0=-68.5 +x_0=0 +y_0=0 +ellps=clrk66 +datum=NAD27 +units=m";
+            case 32099 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-91.33333333333333 +x_0=609601.2192024384 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+            case 32100 : return "+proj=lcc +lat_1=49 +lat_2=45 +lat_0=44.25 +lon_0=-109.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32104 : return "+proj=lcc +lat_1=43 +lat_2=40 +lat_0=39.83333333333334 +lon_0=-100 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32107 : return "+proj=tmerc +lat_0=34.75 +lon_0=-115.5833333333333 +k=0.9999 +x_0=200000 +y_0=8000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32108 : return "+proj=tmerc +lat_0=34.75 +lon_0=-116.6666666666667 +k=0.9999 +x_0=500000 +y_0=6000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32109 : return "+proj=tmerc +lat_0=34.75 +lon_0=-118.5833333333333 +k=0.9999 +x_0=800000 +y_0=4000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32110 : return "+proj=tmerc +lat_0=42.5 +lon_0=-71.66666666666667 +k=0.999966667 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32111 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32112 : return "+proj=tmerc +lat_0=31 +lon_0=-104.3333333333333 +k=0.999909091 +x_0=165000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32113 : return "+proj=tmerc +lat_0=31 +lon_0=-106.25 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32114 : return "+proj=tmerc +lat_0=31 +lon_0=-107.8333333333333 +k=0.999916667 +x_0=830000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32115 : return "+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32116 : return "+proj=tmerc +lat_0=40 +lon_0=-76.58333333333333 +k=0.9999375 +x_0=250000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32117 : return "+proj=tmerc +lat_0=40 +lon_0=-78.58333333333333 +k=0.9999375 +x_0=350000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32118 : return "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.66666666666666 +lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32119 : return "+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32120 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.43333333333333 +lat_0=47 +lon_0=-100.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32121 : return "+proj=lcc +lat_1=47.48333333333333 +lat_2=46.18333333333333 +lat_0=45.66666666666666 +lon_0=-100.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32122 : return "+proj=lcc +lat_1=41.7 +lat_2=40.43333333333333 +lat_0=39.66666666666666 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32123 : return "+proj=lcc +lat_1=40.03333333333333 +lat_2=38.73333333333333 +lat_0=38 +lon_0=-82.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32124 : return "+proj=lcc +lat_1=36.76666666666667 +lat_2=35.56666666666667 +lat_0=35 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32125 : return "+proj=lcc +lat_1=35.23333333333333 +lat_2=33.93333333333333 +lat_0=33.33333333333334 +lon_0=-98 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32126 : return "+proj=lcc +lat_1=46 +lat_2=44.33333333333334 +lat_0=43.66666666666666 +lon_0=-120.5 +x_0=2500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32127 : return "+proj=lcc +lat_1=44 +lat_2=42.33333333333334 +lat_0=41.66666666666666 +lon_0=-120.5 +x_0=1500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32128 : return "+proj=lcc +lat_1=41.95 +lat_2=40.88333333333333 +lat_0=40.16666666666666 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32129 : return "+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32130 : return "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.99999375 +x_0=100000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32133 : return "+proj=lcc +lat_1=34.83333333333334 +lat_2=32.5 +lat_0=31.83333333333333 +lon_0=-81 +x_0=609600 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32134 : return "+proj=lcc +lat_1=45.68333333333333 +lat_2=44.41666666666666 +lat_0=43.83333333333334 +lon_0=-100 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32135 : return "+proj=lcc +lat_1=44.4 +lat_2=42.83333333333334 +lat_0=42.33333333333334 +lon_0=-100.3333333333333 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32136 : return "+proj=lcc +lat_1=36.41666666666666 +lat_2=35.25 +lat_0=34.33333333333334 +lon_0=-86 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32137 : return "+proj=lcc +lat_1=36.18333333333333 +lat_2=34.65 +lat_0=34 +lon_0=-101.5 +x_0=200000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32138 : return "+proj=lcc +lat_1=33.96666666666667 +lat_2=32.13333333333333 +lat_0=31.66666666666667 +lon_0=-98.5 +x_0=600000 +y_0=2000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32139 : return "+proj=lcc +lat_1=31.88333333333333 +lat_2=30.11666666666667 +lat_0=29.66666666666667 +lon_0=-100.3333333333333 +x_0=700000 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32140 : return "+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32141 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.66666666666667 +lon_0=-98.5 +x_0=300000 +y_0=5000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32142 : return "+proj=lcc +lat_1=41.78333333333333 +lat_2=40.71666666666667 +lat_0=40.33333333333334 +lon_0=-111.5 +x_0=500000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32143 : return "+proj=lcc +lat_1=40.65 +lat_2=39.01666666666667 +lat_0=38.33333333333334 +lon_0=-111.5 +x_0=500000 +y_0=2000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32144 : return "+proj=lcc +lat_1=38.35 +lat_2=37.21666666666667 +lat_0=36.66666666666666 +lon_0=-111.5 +x_0=500000 +y_0=3000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32145 : return "+proj=tmerc +lat_0=42.5 +lon_0=-72.5 +k=0.999964286 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32146 : return "+proj=lcc +lat_1=39.2 +lat_2=38.03333333333333 +lat_0=37.66666666666666 +lon_0=-78.5 +x_0=3500000 +y_0=2000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32147 : return "+proj=lcc +lat_1=37.96666666666667 +lat_2=36.76666666666667 +lat_0=36.33333333333334 +lon_0=-78.5 +x_0=3500000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32148 : return "+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32149 : return "+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32150 : return "+proj=lcc +lat_1=40.25 +lat_2=39 +lat_0=38.5 +lon_0=-79.5 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32151 : return "+proj=lcc +lat_1=38.88333333333333 +lat_2=37.48333333333333 +lat_0=37 +lon_0=-81 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32152 : return "+proj=lcc +lat_1=46.76666666666667 +lat_2=45.56666666666667 +lat_0=45.16666666666666 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32153 : return "+proj=lcc +lat_1=45.5 +lat_2=44.25 +lat_0=43.83333333333334 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32154 : return "+proj=lcc +lat_1=44.06666666666667 +lat_2=42.73333333333333 +lat_0=42 +lon_0=-90 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32155 : return "+proj=tmerc +lat_0=40.5 +lon_0=-105.1666666666667 +k=0.9999375 +x_0=200000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32156 : return "+proj=tmerc +lat_0=40.5 +lon_0=-107.3333333333333 +k=0.9999375 +x_0=400000 +y_0=100000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32157 : return "+proj=tmerc +lat_0=40.5 +lon_0=-108.75 +k=0.9999375 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32158 : return "+proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +k=0.9999375 +x_0=800000 +y_0=100000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32161 : return "+proj=lcc +lat_1=18.43333333333333 +lat_2=18.03333333333333 +lat_0=17.83333333333333 +lon_0=-66.43333333333334 +x_0=200000 +y_0=200000 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32164 : return "+proj=tmerc +lat_0=0 +lon_0=-99 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 32165 : return "+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 32166 : return "+proj=tmerc +lat_0=0 +lon_0=-87 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 32167 : return "+proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192";
+            case 32180 : return "+proj=tmerc +lat_0=0 +lon_0=-55.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32181 : return "+proj=tmerc +lat_0=0 +lon_0=-53 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32182 : return "+proj=tmerc +lat_0=0 +lon_0=-56 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32183 : return "+proj=tmerc +lat_0=0 +lon_0=-58.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32184 : return "+proj=tmerc +lat_0=0 +lon_0=-61.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32185 : return "+proj=tmerc +lat_0=0 +lon_0=-64.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32186 : return "+proj=tmerc +lat_0=0 +lon_0=-67.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32187 : return "+proj=tmerc +lat_0=0 +lon_0=-70.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32188 : return "+proj=tmerc +lat_0=0 +lon_0=-73.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32189 : return "+proj=tmerc +lat_0=0 +lon_0=-76.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32190 : return "+proj=tmerc +lat_0=0 +lon_0=-79.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32191 : return "+proj=tmerc +lat_0=0 +lon_0=-82.5 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32192 : return "+proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32193 : return "+proj=tmerc +lat_0=0 +lon_0=-84 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32194 : return "+proj=tmerc +lat_0=0 +lon_0=-87 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32195 : return "+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32196 : return "+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32197 : return "+proj=tmerc +lat_0=0 +lon_0=-96 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32198 : return "+proj=lcc +lat_1=60 +lat_2=46 +lat_0=44 +lon_0=-68.5 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32199 : return "+proj=lcc +lat_1=27.83333333333333 +lat_2=26.16666666666667 +lat_0=25.5 +lon_0=-91.33333333333333 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+            case 32201 : return "+proj=utm +zone=1 +ellps=WGS72 +units=m";
+            case 32202 : return "+proj=utm +zone=2 +ellps=WGS72 +units=m";
+            case 32203 : return "+proj=utm +zone=3 +ellps=WGS72 +units=m";
+            case 32204 : return "+proj=utm +zone=4 +ellps=WGS72 +units=m";
+            case 32205 : return "+proj=utm +zone=5 +ellps=WGS72 +units=m";
+            case 32206 : return "+proj=utm +zone=6 +ellps=WGS72 +units=m";
+            case 32207 : return "+proj=utm +zone=7 +ellps=WGS72 +units=m";
+            case 32208 : return "+proj=utm +zone=8 +ellps=WGS72 +units=m";
+            case 32209 : return "+proj=utm +zone=9 +ellps=WGS72 +units=m";
+            case 32210 : return "+proj=utm +zone=10 +ellps=WGS72 +units=m";
+            case 32211 : return "+proj=utm +zone=11 +ellps=WGS72 +units=m";
+            case 32212 : return "+proj=utm +zone=12 +ellps=WGS72 +units=m";
+            case 32213 : return "+proj=utm +zone=13 +ellps=WGS72 +units=m";
+            case 32214 : return "+proj=utm +zone=14 +ellps=WGS72 +units=m";
+            case 32215 : return "+proj=utm +zone=15 +ellps=WGS72 +units=m";
+            case 32216 : return "+proj=utm +zone=16 +ellps=WGS72 +units=m";
+            case 32217 : return "+proj=utm +zone=17 +ellps=WGS72 +units=m";
+            case 32218 : return "+proj=utm +zone=18 +ellps=WGS72 +units=m";
+            case 32219 : return "+proj=utm +zone=19 +ellps=WGS72 +units=m";
+            case 32220 : return "+proj=utm +zone=20 +ellps=WGS72 +units=m";
+            case 32221 : return "+proj=utm +zone=21 +ellps=WGS72 +units=m";
+            case 32222 : return "+proj=utm +zone=22 +ellps=WGS72 +units=m";
+            case 32223 : return "+proj=utm +zone=23 +ellps=WGS72 +units=m";
+            case 32224 : return "+proj=utm +zone=24 +ellps=WGS72 +units=m";
+            case 32225 : return "+proj=utm +zone=25 +ellps=WGS72 +units=m";
+            case 32226 : return "+proj=utm +zone=26 +ellps=WGS72 +units=m";
+            case 32227 : return "+proj=utm +zone=27 +ellps=WGS72 +units=m";
+            case 32228 : return "+proj=utm +zone=28 +ellps=WGS72 +units=m";
+            case 32229 : return "+proj=utm +zone=29 +ellps=WGS72 +units=m";
+            case 32230 : return "+proj=utm +zone=30 +ellps=WGS72 +units=m";
+            case 32231 : return "+proj=utm +zone=31 +ellps=WGS72 +units=m";
+            case 32232 : return "+proj=utm +zone=32 +ellps=WGS72 +units=m";
+            case 32233 : return "+proj=utm +zone=33 +ellps=WGS72 +units=m";
+            case 32234 : return "+proj=utm +zone=34 +ellps=WGS72 +units=m";
+            case 32235 : return "+proj=utm +zone=35 +ellps=WGS72 +units=m";
+            case 32236 : return "+proj=utm +zone=36 +ellps=WGS72 +units=m";
+            case 32237 : return "+proj=utm +zone=37 +ellps=WGS72 +units=m";
+            case 32238 : return "+proj=utm +zone=38 +ellps=WGS72 +units=m";
+            case 32239 : return "+proj=utm +zone=39 +ellps=WGS72 +units=m";
+            case 32240 : return "+proj=utm +zone=40 +ellps=WGS72 +units=m";
+            case 32241 : return "+proj=utm +zone=41 +ellps=WGS72 +units=m";
+            case 32242 : return "+proj=utm +zone=42 +ellps=WGS72 +units=m";
+            case 32243 : return "+proj=utm +zone=43 +ellps=WGS72 +units=m";
+            case 32244 : return "+proj=utm +zone=44 +ellps=WGS72 +units=m";
+            case 32245 : return "+proj=utm +zone=45 +ellps=WGS72 +units=m";
+            case 32246 : return "+proj=utm +zone=46 +ellps=WGS72 +units=m";
+            case 32247 : return "+proj=utm +zone=47 +ellps=WGS72 +units=m";
+            case 32248 : return "+proj=utm +zone=48 +ellps=WGS72 +units=m";
+            case 32249 : return "+proj=utm +zone=49 +ellps=WGS72 +units=m";
+            case 32250 : return "+proj=utm +zone=50 +ellps=WGS72 +units=m";
+            case 32251 : return "+proj=utm +zone=51 +ellps=WGS72 +units=m";
+            case 32252 : return "+proj=utm +zone=52 +ellps=WGS72 +units=m";
+            case 32253 : return "+proj=utm +zone=53 +ellps=WGS72 +units=m";
+            case 32254 : return "+proj=utm +zone=54 +ellps=WGS72 +units=m";
+            case 32255 : return "+proj=utm +zone=55 +ellps=WGS72 +units=m";
+            case 32256 : return "+proj=utm +zone=56 +ellps=WGS72 +units=m";
+            case 32257 : return "+proj=utm +zone=57 +ellps=WGS72 +units=m";
+            case 32258 : return "+proj=utm +zone=58 +ellps=WGS72 +units=m";
+            case 32259 : return "+proj=utm +zone=59 +ellps=WGS72 +units=m";
+            case 32260 : return "+proj=utm +zone=60 +ellps=WGS72 +units=m";
+            case 32301 : return "+proj=utm +zone=1 +south +ellps=WGS72 +units=m";
+            case 32302 : return "+proj=utm +zone=2 +south +ellps=WGS72 +units=m";
+            case 32303 : return "+proj=utm +zone=3 +south +ellps=WGS72 +units=m";
+            case 32304 : return "+proj=utm +zone=4 +south +ellps=WGS72 +units=m";
+            case 32305 : return "+proj=utm +zone=5 +south +ellps=WGS72 +units=m";
+            case 32306 : return "+proj=utm +zone=6 +south +ellps=WGS72 +units=m";
+            case 32307 : return "+proj=utm +zone=7 +south +ellps=WGS72 +units=m";
+            case 32308 : return "+proj=utm +zone=8 +south +ellps=WGS72 +units=m";
+            case 32309 : return "+proj=utm +zone=9 +south +ellps=WGS72 +units=m";
+            case 32310 : return "+proj=utm +zone=10 +south +ellps=WGS72 +units=m";
+            case 32311 : return "+proj=utm +zone=11 +south +ellps=WGS72 +units=m";
+            case 32312 : return "+proj=utm +zone=12 +south +ellps=WGS72 +units=m";
+            case 32313 : return "+proj=utm +zone=13 +south +ellps=WGS72 +units=m";
+            case 32314 : return "+proj=utm +zone=14 +south +ellps=WGS72 +units=m";
+            case 32315 : return "+proj=utm +zone=15 +south +ellps=WGS72 +units=m";
+            case 32316 : return "+proj=utm +zone=16 +south +ellps=WGS72 +units=m";
+            case 32317 : return "+proj=utm +zone=17 +south +ellps=WGS72 +units=m";
+            case 32318 : return "+proj=utm +zone=18 +south +ellps=WGS72 +units=m";
+            case 32319 : return "+proj=utm +zone=19 +south +ellps=WGS72 +units=m";
+            case 32320 : return "+proj=utm +zone=20 +south +ellps=WGS72 +units=m";
+            case 32321 : return "+proj=utm +zone=21 +south +ellps=WGS72 +units=m";
+            case 32322 : return "+proj=utm +zone=22 +south +ellps=WGS72 +units=m";
+            case 32323 : return "+proj=utm +zone=23 +south +ellps=WGS72 +units=m";
+            case 32324 : return "+proj=utm +zone=24 +south +ellps=WGS72 +units=m";
+            case 32325 : return "+proj=utm +zone=25 +south +ellps=WGS72 +units=m";
+            case 32326 : return "+proj=utm +zone=26 +south +ellps=WGS72 +units=m";
+            case 32327 : return "+proj=utm +zone=27 +south +ellps=WGS72 +units=m";
+            case 32328 : return "+proj=utm +zone=28 +south +ellps=WGS72 +units=m";
+            case 32329 : return "+proj=utm +zone=29 +south +ellps=WGS72 +units=m";
+            case 32330 : return "+proj=utm +zone=30 +south +ellps=WGS72 +units=m";
+            case 32331 : return "+proj=utm +zone=31 +south +ellps=WGS72 +units=m";
+            case 32332 : return "+proj=utm +zone=32 +south +ellps=WGS72 +units=m";
+            case 32333 : return "+proj=utm +zone=33 +south +ellps=WGS72 +units=m";
+            case 32334 : return "+proj=utm +zone=34 +south +ellps=WGS72 +units=m";
+            case 32335 : return "+proj=utm +zone=35 +south +ellps=WGS72 +units=m";
+            case 32336 : return "+proj=utm +zone=36 +south +ellps=WGS72 +units=m";
+            case 32337 : return "+proj=utm +zone=37 +south +ellps=WGS72 +units=m";
+            case 32338 : return "+proj=utm +zone=38 +south +ellps=WGS72 +units=m";
+            case 32339 : return "+proj=utm +zone=39 +south +ellps=WGS72 +units=m";
+            case 32340 : return "+proj=utm +zone=40 +south +ellps=WGS72 +units=m";
+            case 32341 : return "+proj=utm +zone=41 +south +ellps=WGS72 +units=m";
+            case 32342 : return "+proj=utm +zone=42 +south +ellps=WGS72 +units=m";
+            case 32343 : return "+proj=utm +zone=43 +south +ellps=WGS72 +units=m";
+            case 32344 : return "+proj=utm +zone=44 +south +ellps=WGS72 +units=m";
+            case 32345 : return "+proj=utm +zone=45 +south +ellps=WGS72 +units=m";
+            case 32346 : return "+proj=utm +zone=46 +south +ellps=WGS72 +units=m";
+            case 32347 : return "+proj=utm +zone=47 +south +ellps=WGS72 +units=m";
+            case 32348 : return "+proj=utm +zone=48 +south +ellps=WGS72 +units=m";
+            case 32349 : return "+proj=utm +zone=49 +south +ellps=WGS72 +units=m";
+            case 32350 : return "+proj=utm +zone=50 +south +ellps=WGS72 +units=m";
+            case 32351 : return "+proj=utm +zone=51 +south +ellps=WGS72 +units=m";
+            case 32352 : return "+proj=utm +zone=52 +south +ellps=WGS72 +units=m";
+            case 32353 : return "+proj=utm +zone=53 +south +ellps=WGS72 +units=m";
+            case 32354 : return "+proj=utm +zone=54 +south +ellps=WGS72 +units=m";
+            case 32355 : return "+proj=utm +zone=55 +south +ellps=WGS72 +units=m";
+            case 32356 : return "+proj=utm +zone=56 +south +ellps=WGS72 +units=m";
+            case 32357 : return "+proj=utm +zone=57 +south +ellps=WGS72 +units=m";
+            case 32358 : return "+proj=utm +zone=58 +south +ellps=WGS72 +units=m";
+            case 32359 : return "+proj=utm +zone=59 +south +ellps=WGS72 +units=m";
+            case 32360 : return "+proj=utm +zone=60 +south +ellps=WGS72 +units=m";
+            case 32401 : return "+proj=utm +zone=1 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32402 : return "+proj=utm +zone=2 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32403 : return "+proj=utm +zone=3 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32404 : return "+proj=utm +zone=4 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32405 : return "+proj=utm +zone=5 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32406 : return "+proj=utm +zone=6 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32407 : return "+proj=utm +zone=7 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32408 : return "+proj=utm +zone=8 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32409 : return "+proj=utm +zone=9 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32410 : return "+proj=utm +zone=10 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32411 : return "+proj=utm +zone=11 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32412 : return "+proj=utm +zone=12 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32413 : return "+proj=utm +zone=13 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32414 : return "+proj=utm +zone=14 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32415 : return "+proj=utm +zone=15 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32416 : return "+proj=utm +zone=16 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32417 : return "+proj=utm +zone=17 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32418 : return "+proj=utm +zone=18 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32419 : return "+proj=utm +zone=19 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32420 : return "+proj=utm +zone=20 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32421 : return "+proj=utm +zone=21 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32422 : return "+proj=utm +zone=22 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32423 : return "+proj=utm +zone=23 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32424 : return "+proj=utm +zone=24 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32425 : return "+proj=utm +zone=25 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32426 : return "+proj=utm +zone=26 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32427 : return "+proj=utm +zone=27 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32428 : return "+proj=utm +zone=28 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32429 : return "+proj=utm +zone=29 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32430 : return "+proj=utm +zone=30 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32431 : return "+proj=utm +zone=31 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32432 : return "+proj=utm +zone=32 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32433 : return "+proj=utm +zone=33 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32434 : return "+proj=utm +zone=34 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32435 : return "+proj=utm +zone=35 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32436 : return "+proj=utm +zone=36 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32437 : return "+proj=utm +zone=37 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32438 : return "+proj=utm +zone=38 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32439 : return "+proj=utm +zone=39 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32440 : return "+proj=utm +zone=40 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32441 : return "+proj=utm +zone=41 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32442 : return "+proj=utm +zone=42 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32443 : return "+proj=utm +zone=43 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32444 : return "+proj=utm +zone=44 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32445 : return "+proj=utm +zone=45 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32446 : return "+proj=utm +zone=46 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32447 : return "+proj=utm +zone=47 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32448 : return "+proj=utm +zone=48 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32449 : return "+proj=utm +zone=49 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32450 : return "+proj=utm +zone=50 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32451 : return "+proj=utm +zone=51 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32452 : return "+proj=utm +zone=52 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32453 : return "+proj=utm +zone=53 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32454 : return "+proj=utm +zone=54 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32455 : return "+proj=utm +zone=55 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32456 : return "+proj=utm +zone=56 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32457 : return "+proj=utm +zone=57 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32458 : return "+proj=utm +zone=58 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32459 : return "+proj=utm +zone=59 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32460 : return "+proj=utm +zone=60 +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32501 : return "+proj=utm +zone=1 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32502 : return "+proj=utm +zone=2 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32503 : return "+proj=utm +zone=3 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32504 : return "+proj=utm +zone=4 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32505 : return "+proj=utm +zone=5 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32506 : return "+proj=utm +zone=6 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32507 : return "+proj=utm +zone=7 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32508 : return "+proj=utm +zone=8 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32509 : return "+proj=utm +zone=9 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32510 : return "+proj=utm +zone=10 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32511 : return "+proj=utm +zone=11 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32512 : return "+proj=utm +zone=12 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32513 : return "+proj=utm +zone=13 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32514 : return "+proj=utm +zone=14 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32515 : return "+proj=utm +zone=15 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32516 : return "+proj=utm +zone=16 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32517 : return "+proj=utm +zone=17 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32518 : return "+proj=utm +zone=18 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32519 : return "+proj=utm +zone=19 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32520 : return "+proj=utm +zone=20 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32521 : return "+proj=utm +zone=21 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32522 : return "+proj=utm +zone=22 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32523 : return "+proj=utm +zone=23 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32524 : return "+proj=utm +zone=24 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32525 : return "+proj=utm +zone=25 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32526 : return "+proj=utm +zone=26 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32527 : return "+proj=utm +zone=27 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32528 : return "+proj=utm +zone=28 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32529 : return "+proj=utm +zone=29 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32530 : return "+proj=utm +zone=30 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32531 : return "+proj=utm +zone=31 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32532 : return "+proj=utm +zone=32 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32533 : return "+proj=utm +zone=33 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32534 : return "+proj=utm +zone=34 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32535 : return "+proj=utm +zone=35 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32536 : return "+proj=utm +zone=36 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32537 : return "+proj=utm +zone=37 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32538 : return "+proj=utm +zone=38 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32539 : return "+proj=utm +zone=39 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32540 : return "+proj=utm +zone=40 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32541 : return "+proj=utm +zone=41 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32542 : return "+proj=utm +zone=42 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32543 : return "+proj=utm +zone=43 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32544 : return "+proj=utm +zone=44 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32545 : return "+proj=utm +zone=45 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32546 : return "+proj=utm +zone=46 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32547 : return "+proj=utm +zone=47 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32548 : return "+proj=utm +zone=48 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32549 : return "+proj=utm +zone=49 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32550 : return "+proj=utm +zone=50 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32551 : return "+proj=utm +zone=51 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32552 : return "+proj=utm +zone=52 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32553 : return "+proj=utm +zone=53 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32554 : return "+proj=utm +zone=54 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32555 : return "+proj=utm +zone=55 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32556 : return "+proj=utm +zone=56 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32557 : return "+proj=utm +zone=57 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32558 : return "+proj=utm +zone=58 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32559 : return "+proj=utm +zone=59 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32560 : return "+proj=utm +zone=60 +south +ellps=WGS72 +towgs84=0,0,1.9,0,0,0.814,-0.38 +units=m";
+            case 32601 : return "+proj=utm +zone=1 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32602 : return "+proj=utm +zone=2 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32603 : return "+proj=utm +zone=3 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32604 : return "+proj=utm +zone=4 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32605 : return "+proj=utm +zone=5 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32606 : return "+proj=utm +zone=6 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32607 : return "+proj=utm +zone=7 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32608 : return "+proj=utm +zone=8 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32609 : return "+proj=utm +zone=9 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32610 : return "+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32611 : return "+proj=utm +zone=11 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32612 : return "+proj=utm +zone=12 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32613 : return "+proj=utm +zone=13 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32614 : return "+proj=utm +zone=14 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32615 : return "+proj=utm +zone=15 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32616 : return "+proj=utm +zone=16 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32617 : return "+proj=utm +zone=17 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32618 : return "+proj=utm +zone=18 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32619 : return "+proj=utm +zone=19 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32620 : return "+proj=utm +zone=20 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32621 : return "+proj=utm +zone=21 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32622 : return "+proj=utm +zone=22 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32623 : return "+proj=utm +zone=23 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32624 : return "+proj=utm +zone=24 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32625 : return "+proj=utm +zone=25 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32626 : return "+proj=utm +zone=26 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32627 : return "+proj=utm +zone=27 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32628 : return "+proj=utm +zone=28 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32629 : return "+proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32630 : return "+proj=utm +zone=30 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32631 : return "+proj=utm +zone=31 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32632 : return "+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32633 : return "+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32634 : return "+proj=utm +zone=34 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32635 : return "+proj=utm +zone=35 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32636 : return "+proj=utm +zone=36 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32637 : return "+proj=utm +zone=37 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32638 : return "+proj=utm +zone=38 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32639 : return "+proj=utm +zone=39 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32640 : return "+proj=utm +zone=40 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32641 : return "+proj=utm +zone=41 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32642 : return "+proj=utm +zone=42 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32643 : return "+proj=utm +zone=43 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32644 : return "+proj=utm +zone=44 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32645 : return "+proj=utm +zone=45 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32646 : return "+proj=utm +zone=46 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32647 : return "+proj=utm +zone=47 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32648 : return "+proj=utm +zone=48 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32649 : return "+proj=utm +zone=49 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32650 : return "+proj=utm +zone=50 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32651 : return "+proj=utm +zone=51 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32652 : return "+proj=utm +zone=52 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32653 : return "+proj=utm +zone=53 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32654 : return "+proj=utm +zone=54 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32655 : return "+proj=utm +zone=55 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32656 : return "+proj=utm +zone=56 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32657 : return "+proj=utm +zone=57 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32658 : return "+proj=utm +zone=58 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32659 : return "+proj=utm +zone=59 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32660 : return "+proj=utm +zone=60 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32661 : return "+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32662 : return "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32664 : return "+proj=tmerc +lat_0=0 +lon_0=-99 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 +datum=WGS84 +to_meter=0.3048006096012192";
+            case 32665 : return "+proj=tmerc +lat_0=0 +lon_0=-93 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 +datum=WGS84 +to_meter=0.3048006096012192";
+            case 32666 : return "+proj=tmerc +lat_0=0 +lon_0=-87 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 +datum=WGS84 +to_meter=0.3048006096012192";
+            case 32667 : return "+proj=tmerc +lat_0=0 +lon_0=-81 +k=0.9996 +x_0=500000.001016002 +y_0=0 +ellps=WGS84 +datum=WGS84 +to_meter=0.3048006096012192";
+            case 32701 : return "+proj=utm +zone=1 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32702 : return "+proj=utm +zone=2 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32703 : return "+proj=utm +zone=3 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32704 : return "+proj=utm +zone=4 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32705 : return "+proj=utm +zone=5 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32706 : return "+proj=utm +zone=6 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32707 : return "+proj=utm +zone=7 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32708 : return "+proj=utm +zone=8 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32709 : return "+proj=utm +zone=9 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32710 : return "+proj=utm +zone=10 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32711 : return "+proj=utm +zone=11 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32712 : return "+proj=utm +zone=12 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32713 : return "+proj=utm +zone=13 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32714 : return "+proj=utm +zone=14 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32715 : return "+proj=utm +zone=15 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32716 : return "+proj=utm +zone=16 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32717 : return "+proj=utm +zone=17 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32718 : return "+proj=utm +zone=18 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32719 : return "+proj=utm +zone=19 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32720 : return "+proj=utm +zone=20 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32721 : return "+proj=utm +zone=21 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32722 : return "+proj=utm +zone=22 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32723 : return "+proj=utm +zone=23 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32724 : return "+proj=utm +zone=24 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32725 : return "+proj=utm +zone=25 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32726 : return "+proj=utm +zone=26 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32727 : return "+proj=utm +zone=27 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32728 : return "+proj=utm +zone=28 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32729 : return "+proj=utm +zone=29 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32730 : return "+proj=utm +zone=30 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32731 : return "+proj=utm +zone=31 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32732 : return "+proj=utm +zone=32 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32733 : return "+proj=utm +zone=33 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32734 : return "+proj=utm +zone=34 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32735 : return "+proj=utm +zone=35 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32736 : return "+proj=utm +zone=36 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32737 : return "+proj=utm +zone=37 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32738 : return "+proj=utm +zone=38 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32739 : return "+proj=utm +zone=39 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32740 : return "+proj=utm +zone=40 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32741 : return "+proj=utm +zone=41 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32742 : return "+proj=utm +zone=42 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32743 : return "+proj=utm +zone=43 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32744 : return "+proj=utm +zone=44 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32745 : return "+proj=utm +zone=45 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32746 : return "+proj=utm +zone=46 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32747 : return "+proj=utm +zone=47 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32748 : return "+proj=utm +zone=48 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32749 : return "+proj=utm +zone=49 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32750 : return "+proj=utm +zone=50 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32751 : return "+proj=utm +zone=51 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32752 : return "+proj=utm +zone=52 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32753 : return "+proj=utm +zone=53 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32754 : return "+proj=utm +zone=54 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32755 : return "+proj=utm +zone=55 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32756 : return "+proj=utm +zone=56 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32757 : return "+proj=utm +zone=57 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32758 : return "+proj=utm +zone=58 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32759 : return "+proj=utm +zone=59 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32760 : return "+proj=utm +zone=60 +south +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32761 : return "+proj=stere +lat_0=-90 +lat_ts=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m";
+            case 32766 : return "+proj=tmerc +lat_0=0 +lon_0=36 +k=0.9996 +x_0=500000 +y_0=10000000 +ellps=WGS84 +datum=WGS84 +units=m";
+        }
+        return "";
+    }
+
+}
+#endif // DOXYGEN_NO_DETAIL
+
+// Overloaded function
+inline parameters init(int epsg_code)
+{
+    std::string args = detail::code_to_string(epsg_code);
+    return detail::pj_init_plus(args, false);
+}
+
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/epsg_traits.hpp b/src/boost/geometry/extensions/gis/projections/epsg_traits.hpp
new file mode 100644
index 0000000..0556653
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/epsg_traits.hpp
@@ -0,0 +1,43 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_EPSG_TRAITS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_EPSG_TRAITS_HPP
+
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+
+namespace boost { namespace geometry { namespace projection
+{
+
+/*!
+    \brief EPSG traits
+    \details With help of the EPSG traits library users can statically use projections
+        or coordinate systems specifying an EPSG code. The correct projections for transformations
+        are used automically then, still keeping static polymorphism.
+    \ingroup projection
+    \tparam EPSG epsg code
+    \tparam LL latlong point type
+    \tparam XY xy point type
+    \tparam PAR parameter type, normally not specified
+*/
+template <size_t EPSG, typename LLR, typename XY, typename PAR = parameters>
+struct epsg_traits
+{
+    // Specializations define:
+    // - type to get projection type
+    // - function par to get parameters
+};
+
+
+}}} // namespace boost::geometry::projection
+
+
+#endif
+
diff --git a/src/boost/geometry/extensions/gis/projections/factory.hpp b/src/boost/geometry/extensions/gis/projections/factory.hpp
new file mode 100644
index 0000000..38acfe7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/factory.hpp
@@ -0,0 +1,255 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
+
+#include <map>
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/parameters.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/aea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/aeqd.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/airy.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/aitoff.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/august.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/bacon.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/bipc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/boggs.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/bonne.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/cass.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/cc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/cea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/chamb.hpp>  // control points XY
+#include <boost/geometry/extensions/gis/projections/proj/collg.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/crast.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/denoy.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eck1.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eck2.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eck3.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eck4.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eck5.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eqc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/eqdc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/fahey.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/fouc_s.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/gall.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/geocent.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/geos.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/gins8.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/gnom.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/goode.hpp> // includes two other projections
+#include <boost/geometry/extensions/gis/projections/proj/gstmerc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/hammer.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/hatano.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/krovak.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/imw_p.hpp> // xy functions after inverse
+#include <boost/geometry/extensions/gis/projections/proj/laea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/labrd.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/lagrng.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/larr.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/lask.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/latlong.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/lcc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/lcca.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/loxim.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/lsat.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/merc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/mill.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/mod_ster.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/moll.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/nell.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/nell_h.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/nocol.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/nsper.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/nzmg.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/ob_tran.hpp> // includes other projection
+#include <boost/geometry/extensions/gis/projections/proj/ocea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/oea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/omerc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/ortho.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/poly.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/putp2.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/putp3.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/putp4p.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/putp5.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/putp6.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/robin.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/rouss.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/rpoly.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/sconics.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/somerc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/stere.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/sterea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/sts.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/tcc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/tcea.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/tmerc.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/tpeqd.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/urm5.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/urmfps.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/vandg.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/vandg2.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/vandg4.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/wag2.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/wag3.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/wag7.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/wink1.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/wink2.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+template <typename LatLong, typename Cartesian, typename Parameters = parameters>
+class factory : public detail::base_factory<LatLong, Cartesian, Parameters>
+{
+private:
+
+    typedef std::map
+        <
+            std::string,
+            boost::shared_ptr
+                <
+                    detail::factory_entry
+                        <
+                            LatLong,
+                            Cartesian,
+                            Parameters
+                        >
+                >
+        > prj_registry;
+    prj_registry m_registry;
+
+public:
+
+    factory()
+    {
+        detail::aea_init(*this);
+        detail::aeqd_init(*this);
+        detail::airy_init(*this);
+        detail::aitoff_init(*this);
+        detail::august_init(*this);
+        detail::bacon_init(*this);
+        detail::bipc_init(*this);
+        detail::boggs_init(*this);
+        detail::bonne_init(*this);
+        detail::cass_init(*this);
+        detail::cc_init(*this);
+        detail::cea_init(*this);
+        detail::chamb_init(*this);
+        detail::collg_init(*this);
+        detail::crast_init(*this);
+        detail::denoy_init(*this);
+        detail::eck1_init(*this);
+        detail::eck2_init(*this);
+        detail::eck3_init(*this);
+        detail::eck4_init(*this);
+        detail::eck5_init(*this);
+        detail::eqc_init(*this);
+        detail::eqdc_init(*this);
+        detail::fahey_init(*this);
+        detail::fouc_s_init(*this);
+        detail::gall_init(*this);
+        detail::geocent_init(*this);
+        detail::geos_init(*this);
+        detail::gins8_init(*this);
+        detail::gn_sinu_init(*this);
+        detail::gnom_init(*this);
+        detail::goode_init(*this);
+        detail::gstmerc_init(*this);
+        detail::hammer_init(*this);
+        detail::hatano_init(*this);
+        detail::krovak_init(*this);
+        detail::imw_p_init(*this);
+        detail::labrd_init(*this);
+        detail::laea_init(*this);
+        detail::lagrng_init(*this);
+        detail::larr_init(*this);
+        detail::lask_init(*this);
+        detail::latlong_init(*this);
+        detail::lcc_init(*this);
+        detail::lcca_init(*this);
+        detail::loxim_init(*this);
+        detail::lsat_init(*this);
+        detail::mbtfpp_init(*this);
+        detail::mbtfpq_init(*this);
+        detail::mbt_fps_init(*this);
+        detail::merc_init(*this);
+        detail::mill_init(*this);
+        detail::mod_ster_init(*this);
+        detail::moll_init(*this);
+        detail::nell_init(*this);
+        detail::nell_h_init(*this);
+        detail::nocol_init(*this);
+        detail::nsper_init(*this);
+        detail::nzmg_init(*this);
+        detail::ob_tran_init(*this);
+        detail::ocea_init(*this);
+        detail::oea_init(*this);
+        detail::omerc_init(*this);
+        detail::ortho_init(*this);
+        detail::poly_init(*this);
+        detail::putp2_init(*this);
+        detail::putp3_init(*this);
+        detail::putp4p_init(*this);
+        detail::putp5_init(*this);
+        detail::putp6_init(*this);
+        detail::robin_init(*this);
+        detail::rouss_init(*this);
+        detail::rpoly_init(*this);
+        detail::sconics_init(*this);
+        detail::somerc_init(*this);
+        detail::stere_init(*this);
+        detail::sterea_init(*this);
+        detail::sts_init(*this);
+        detail::tcc_init(*this);
+        detail::tcea_init(*this);
+        detail::tmerc_init(*this);
+        detail::tpeqd_init(*this);
+        detail::urm5_init(*this);
+        detail::urmfps_init(*this);
+        detail::vandg_init(*this);
+        detail::vandg2_init(*this);
+        detail::vandg4_init(*this);
+        detail::wag2_init(*this);
+        detail::wag3_init(*this);
+        detail::wag7_init(*this);
+        detail::wink1_init(*this);
+        detail::wink2_init(*this);
+    }
+
+    virtual ~factory() {}
+
+    virtual void add_to_factory(std::string const& name,
+                    detail::factory_entry<LatLong, Cartesian, Parameters>* sub)
+    {
+        m_registry[name].reset(sub);
+    }
+
+    inline projection<LatLong, Cartesian>* create_new(Parameters const& parameters)
+    {
+        typename prj_registry::iterator it = m_registry.find(parameters.name);
+        if (it != m_registry.end())
+        {
+            return it->second->create_new(parameters);
+        }
+
+        return 0;
+    }
+};
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/aasincos.hpp b/src/boost/geometry/extensions/gis/projections/impl/aasincos.hpp
new file mode 100644
index 0000000..dfad0d6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/aasincos.hpp
@@ -0,0 +1,107 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
+
+
+#include <cmath>
+
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry { namespace projection
+{
+
+namespace detail
+{
+
+namespace aasincos
+{
+    static const double ONE_TOL= 1.00000000000001;
+    //static const double TOL = 0.000000001;
+    static const double ATOL = 1e-50;
+}
+
+inline double aasin(double v)
+{
+    double av = 0;
+
+    if ((av = geometry::math::abs(v)) >= 1.0)
+    {
+        if (av > aasincos::ONE_TOL)
+        {
+            throw proj_exception(-19);
+        }
+        return (v < 0.0 ? -HALFPI : HALFPI);
+    }
+
+    return asin(v);
+}
+
+inline double aacos(double v)
+{
+    double av = 0;
+
+    if ((av = geometry::math::abs(v)) >= 1.0)
+    {
+        if (av > aasincos::ONE_TOL)
+        {
+            throw proj_exception(-19);
+        }
+        return (v < 0.0 ? PI : 0.0);
+    }
+
+    return acos(v);
+}
+
+inline double asqrt(double v)
+{
+    return ((v <= 0) ? 0 : sqrt(v));
+}
+
+inline double aatan2(double n, double d)
+{
+    return ((geometry::math::abs(n) < aasincos::ATOL
+        && geometry::math::abs(d) < aasincos::ATOL) ? 0.0 : atan2(n, d));
+}
+
+
+} // namespace detail
+
+
+}}} // namespace boost::geometry::projection
+
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/adjlon.hpp b/src/boost/geometry/extensions/gis/projections/impl/adjlon.hpp
new file mode 100644
index 0000000..2eb4dd6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/adjlon.hpp
@@ -0,0 +1,73 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
+
+#include <cmath>
+
+#include <boost/math/constants/constants.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+namespace detail
+{
+
+/* reduce argument to range +/- PI */
+inline double adjlon (double lon)
+{
+    static const double SPI = 3.14159265359;
+    static const double TWOPI = 6.2831853071795864769;
+    static const double ONEPI = 3.14159265358979323846;
+
+    if (geometry::math::abs(lon) <= SPI)
+    {
+        return lon;
+    }
+
+    lon += ONEPI;  /* adjust to 0..2pi rad */
+    lon -= TWOPI * std::floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
+    lon -= ONEPI;  /* adjust back to -pi..pi rad */
+
+    return lon;
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp b/src/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp
new file mode 100644
index 0000000..bfb98f3
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp
@@ -0,0 +1,106 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_DYNAMIC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_DYNAMIC_HPP
+
+#include <string>
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/extensions/gis/projections/projection.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+// Base-virtual-forward
+template <typename C, typename LL, typename XY, typename P>
+class base_v_f : public projection<LL, XY>
+{
+protected:
+
+    typedef typename projection<LL, XY>::LL_T LL_T;
+    typedef typename projection<LL, XY>::XY_T XY_T;
+
+public:
+
+    base_v_f(P const& params) : m_proj(params) {}
+
+    virtual P params() const {return m_proj.params();}
+
+    virtual bool forward(LL const& ll, XY& xy) const
+    {
+        return m_proj.forward(ll, xy);
+    }
+
+    virtual void fwd(LL_T& lp_lon, LL_T& lp_lat, XY_T& xy_x, XY_T& xy_y) const
+    {
+        m_proj.fwd(lp_lon, lp_lat, xy_x, xy_y);
+    }
+
+    virtual bool inverse(XY const& xy, LL& ll) const
+    {
+        boost::ignore_unused_variable_warning(xy);
+        boost::ignore_unused_variable_warning(ll);
+
+        // exception?
+        return false;
+    }
+    virtual void inv(XY_T& xy_x, XY_T& xy_y, LL_T& lp_lon, LL_T& lp_lat) const
+    {
+        boost::ignore_unused_variable_warning(xy_x);
+        boost::ignore_unused_variable_warning(xy_y);
+        boost::ignore_unused_variable_warning(lp_lon);
+        boost::ignore_unused_variable_warning(lp_lat);
+        // exception?
+    }
+
+    virtual std::string name() const
+    {
+        return m_proj.name();
+    }
+
+protected:
+
+    C m_proj;
+};
+
+// Base-virtual-forward/inverse
+template <typename C, typename LL, typename XY, typename P>
+class base_v_fi : public base_v_f<C, LL, XY, P>
+{
+private:
+
+    typedef typename base_v_f<C, LL, XY, P>::LL_T LL_T;
+    typedef typename base_v_f<C, LL, XY, P>::XY_T XY_T;
+
+public :
+
+    base_v_fi(P const& params) : base_v_f<C, LL, XY, P>(params) {}
+
+    virtual bool inverse(XY const& xy, LL& ll) const
+    {
+        return this->m_proj.inverse(xy, ll);
+    }
+
+    void inv(XY_T& xy_x, XY_T& xy_y, LL_T& lp_lon, LL_T& lp_lat) const
+    {
+        this->m_proj.inv(xy_x, xy_y, lp_lon, lp_lat);
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_DYNAMIC_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/base_static.hpp b/src/boost/geometry/extensions/gis/projections/impl/base_static.hpp
new file mode 100644
index 0000000..284ca88
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/base_static.hpp
@@ -0,0 +1,105 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP
+
+#if defined(_MSC_VER)
+// For CRTP, *this is acceptable in constructor -> turn warning off
+#pragma warning( disable : 4355 )
+#endif // defined(_MSC_VER)
+
+
+#include <string>
+
+#include <boost/geometry/extensions/gis/projections/impl/pj_fwd.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_inv.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+// Base-template-forward
+template <typename Prj, typename LL, typename XY, typename P>
+struct base_t_f
+{
+public:
+
+    inline base_t_f(Prj const& prj, P const& params)
+        : m_par(params), m_prj(prj)
+    {}
+
+    inline P params() const {return m_par;}
+
+    inline bool forward(LL const& lp, XY& xy) const
+    {
+        try
+        {
+            pj_fwd(m_prj, m_par, lp, xy);
+            return true;
+        }
+        catch(...)
+        {
+            return false;
+        }
+    }
+
+    inline std::string name() const
+    {
+        return this->m_par.name;
+    }
+
+protected:
+
+    // Some projections do not work with float -> wrong results
+    // TODO: make traits which select <double> from int/float/double and else selects T
+
+    //typedef typename geometry::coordinate_type<LL>::type LL_T;
+    //typedef typename geometry::coordinate_type<XY>::type XY_T;
+    typedef double LL_T;
+    typedef double XY_T;
+
+    P m_par;
+    const Prj& m_prj;
+};
+
+// Base-template-forward/inverse
+template <typename Prj, typename LL, typename XY, typename P>
+struct base_t_fi : public base_t_f<Prj, LL, XY, P>
+{
+public :
+    inline base_t_fi(Prj const& prj, P const& params)
+        : base_t_f<Prj, LL, XY, P>(prj, params)
+    {}
+
+    inline bool inverse(XY const& xy, LL& lp) const
+    {
+        try
+        {
+            pj_inv(this->m_prj, this->m_par, xy, lp);
+            return true;
+        }
+        catch(...)
+        {
+            return false;
+        }
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}}} // namespace boost::geometry::projection
+
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/factory_entry.hpp b/src/boost/geometry/extensions/gis/projections/impl/factory_entry.hpp
new file mode 100644
index 0000000..2fea892
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/factory_entry.hpp
@@ -0,0 +1,43 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_FACTORY_ENTRY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_FACTORY_ENTRY_HPP
+
+#include <string>
+
+#include <boost/geometry/extensions/gis/projections/projection.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+namespace detail
+{
+
+template <typename LL, typename XY, typename P>
+class factory_entry
+{
+public:
+
+    virtual ~factory_entry() {}
+    virtual projection<LL, XY>* create_new(P const& par) const = 0;
+};
+
+template <typename LL, typename XY, typename P>
+class base_factory
+{
+public:
+
+    virtual ~base_factory() {}
+    virtual void add_to_factory(std::string const& name, factory_entry<LL, XY, P>* sub) = 0;
+};
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_FACTORY_ENTRY_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/function_overloads.hpp b/src/boost/geometry/extensions/gis/projections/impl/function_overloads.hpp
new file mode 100644
index 0000000..0163a4c
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/function_overloads.hpp
@@ -0,0 +1,35 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_FUNCTION_OVERLOADS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_FUNCTION_OVERLOADS_HPP
+
+#include <cmath>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+// Functions to resolve ambiguity when compiling with coordinates of different types
+/*inline double atan2(double a, double b)
+{
+    return std::atan2(a, b);
+}
+inline double pow(double a, double b)
+{
+    return std::pow(a, b);
+}
+*/
+
+inline int int_floor(double f)
+{
+    return int(std::floor(f));
+}
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_FUNCTION_OVERLOADS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp
new file mode 100644
index 0000000..65c59a5
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp
@@ -0,0 +1,85 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_AUTH_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_AUTH_HPP
+
+#include <cassert>
+#include <cmath>
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+static const double P00 = .33333333333333333333;
+static const double P01 = .17222222222222222222;
+static const double P02 = .10257936507936507936;
+static const double P10 = .06388888888888888888;
+static const double P11 = .06640211640211640211;
+static const double P20 = .01641501294219154443;
+static const int APA_SIZE = 3;
+
+/* determine latitude from authalic latitude */
+inline void pj_authset(double es, double* APA)
+{
+    assert(0 != APA);
+
+    double t = 0;
+
+    // if (APA = (double *)pj_malloc(APA_SIZE * sizeof(double)))
+    {
+        APA[0] = es * P00;
+        t = es * es;
+        APA[0] += t * P01;
+        APA[1] = t * P10;
+        t *= es;
+        APA[0] += t * P02;
+        APA[1] += t * P11;
+        APA[2] = t * P20;
+    }
+}
+
+inline double pj_authlat(double beta, const double* APA)
+{
+    assert(0 != APA);
+
+    double const t = beta + beta;
+
+    return(beta + APA[0] * sin(t) + APA[1] * sin(t + t) + APA[2] * sin(t + t + t));
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_AUTH_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_datum_set.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_datum_set.hpp
new file mode 100644
index 0000000..0e889ef
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_datum_set.hpp
@@ -0,0 +1,167 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUM_SET_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUM_SET_HPP
+
+#include <string>
+#include <vector>
+
+#include <boost/algorithm/string.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/pj_datums.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_param.hpp>
+#include <boost/geometry/extensions/gis/projections/parameters.hpp>
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+
+/* SEC_TO_RAD = Pi/180/3600 */
+const double SEC_TO_RAD = 4.84813681109535993589914102357e-6;
+
+/************************************************************************/
+/*                            pj_datum_set()                            */
+/************************************************************************/
+
+inline void pj_datum_set(std::vector<pvalue>& pvalues, parameters& projdef)
+{
+    std::string name, towgs84, nadgrids;
+
+    projdef.datum_type = PJD_UNKNOWN;
+
+    /* -------------------------------------------------------------------- */
+    /*      Is there a datum definition in the parameter list?  If so,     */
+    /*      add the defining values to the parameter list.  Note that       */
+    /*      this will append the ellipse definition as well as the          */
+    /*      towgs84= and related parameters.  It should also be pointed     */
+    /*      out that the addition is permanent rather than temporary        */
+    /*      like most other keyword expansion so that the ellipse           */
+    /*      definition will last into the pj_ell_set() function called      */
+    /*      after this one.                                                 */
+    /* -------------------------------------------------------------------- */
+    name = pj_param(pvalues, "sdatum").s;
+    if(! name.empty())
+    {
+        /* find the datum definition */
+        const int n = sizeof(pj_datums) / sizeof(pj_datums[0]);
+        int index = -1;
+        for (int i = 0; i < n && index == -1; i++)
+        {
+            if(pj_datums[i].id == name)
+            {
+                index = i;
+            }
+        }
+
+        if (index == -1)
+        {
+            throw proj_exception(-9);
+        }
+
+        if(! pj_datums[index].ellipse_id.empty())
+        {
+            std::string entry("ellps=");
+            entry +=pj_datums[index].ellipse_id;
+            pvalues.push_back(pj_mkparam(entry));
+        }
+
+        if(! pj_datums[index].defn.empty())
+        {
+            pvalues.push_back(pj_mkparam(pj_datums[index].defn));
+        }
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Check for nadgrids parameter.                                   */
+/* -------------------------------------------------------------------- */
+    nadgrids = pj_param(pvalues, "snadgrids").s;
+    towgs84 = pj_param(pvalues, "stowgs84").s;
+    if(! nadgrids.empty())
+    {
+        /* We don't actually save the value separately.  It will continue
+           to exist int he param list for use in pj_apply_gridshift.c */
+
+        projdef.datum_type = PJD_GRIDSHIFT;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Check for towgs84 parameter.                                    */
+/* -------------------------------------------------------------------- */
+    else if(! towgs84.empty())
+    {
+        int parm_count = 0;
+
+        int n = sizeof(projdef.datum_params) / sizeof(projdef.datum_params[0]);
+
+        /* parse out the pvalues */
+        std::vector<std::string> parm;
+        boost::split(parm, towgs84, boost::is_any_of(" ,"));
+        for (std::vector<std::string>::const_iterator it = parm.begin();
+            it != parm.end() && parm_count < n;
+            ++it)
+        {
+            projdef.datum_params[parm_count++] = atof(it->c_str());
+        }
+
+        if( projdef.datum_params[3] != 0.0
+            || projdef.datum_params[4] != 0.0
+            || projdef.datum_params[5] != 0.0
+            || projdef.datum_params[6] != 0.0 )
+        {
+            projdef.datum_type = PJD_7PARAM;
+
+            /* transform from arc seconds to radians */
+            projdef.datum_params[3] *= SEC_TO_RAD;
+            projdef.datum_params[4] *= SEC_TO_RAD;
+            projdef.datum_params[5] *= SEC_TO_RAD;
+            /* transform from parts per million to scaling factor */
+            projdef.datum_params[6] =
+                (projdef.datum_params[6]/1000000.0) + 1;
+        }
+        else
+        {
+            projdef.datum_type = PJD_3PARAM;
+        }
+
+        /* Note that pj_init() will later switch datum_type to
+           PJD_WGS84 if shifts are all zero, and ellipsoid is WGS84 or GRS80 */
+    }
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUM_SET_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_datums.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_datums.hpp
new file mode 100644
index 0000000..31244c7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_datums.hpp
@@ -0,0 +1,106 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+/*
+ * The ellipse code must match one from pj_ellps.c.  The datum id should
+ * be kept to 12 characters or less if possible.  Use the official OGC
+ * datum name for the comments if available.
+ */
+
+static const PJ_DATUMS pj_datums[] =
+{
+    /* id          definition        ellipse  comments */
+    /* --          ----------        -------  -------- */
+    { "WGS84",     "towgs84=0,0,0",  "WGS84", "" },
+
+    { "GGRS87",    "towgs84=-199.87,74.79,246.62",
+                                     "GRS80", "Greek_Geodetic_Reference_System_1987" },
+
+    { "NAD83",     "towgs84=0,0,0",  "GRS80","North_American_Datum_1983" },
+
+    { "NAD27",     "nadgrids=@conus, at alaska, at ntv2_0.gsb, at ntv1_can.dat",
+                                     "clrk66", "North_American_Datum_1927" },
+
+    { "potsdam",   "towgs84=606.0,23.0,413.0",
+                                     "bessel",  "Potsdam Rauenberg 1950 DHDN" },
+
+    { "carthage",  "towgs84=-263.0,6.0,431.0",
+                                     "clark80",  "Carthage 1934 Tunisia" },
+
+    { "hermannskogel", "towgs84=653.0,-212.0,449.0",
+                                     "bessel",  "Hermannskogel" },
+
+    { "ire65",     "towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
+                                     "mod_airy",  "Ireland 1965" },
+
+    { "nzgd49",    "towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
+                                     "intl", "New Zealand Geodetic Datum 1949" },
+
+    { "OSGB36",    "towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
+                                     "airy", "Airy 1830" }
+};
+
+
+static const PJ_PRIME_MERIDIANS pj_prime_meridians[] =
+{
+    /* id          definition */
+    /* --          ---------- */
+    { "greenwich", "0dE" },
+    { "lisbon",    "9d07'54.862\"W" },
+    { "paris",     "2d20'14.025\"E" },
+    { "bogota",    "74d04'51.3\"W" },
+    { "madrid",    "3d41'16.58\"W" },
+    { "rome",      "12d27'8.4\"E" },
+    { "bern",      "7d26'22.5\"E" },
+    { "jakarta",   "106d48'27.79\"E" },
+    { "ferro",     "17d40'W" },
+    { "brussels",  "4d22'4.71\"E" },
+    { "stockholm", "18d3'29.8\"E" },
+    { "athens",    "23d42'58.815\"E" },
+    { "oslo",      "10d43'22.5\"E" }
+};
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp
new file mode 100644
index 0000000..7983358
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp
@@ -0,0 +1,155 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
+
+#include <string>
+#include <vector>
+
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/pj_ellps.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_param.hpp>
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+/* set ellipsoid parameters a and es */
+static const double SIXTH =  .1666666666666666667; /* 1/6 */
+static const double RA4 = .04722222222222222222; /* 17/360 */
+static const double RA6 = .02215608465608465608; /* 67/3024 */
+static const double RV4 = .06944444444444444444; /* 5/72 */
+static const double RV6 = .04243827160493827160; /* 55/1296 */
+
+/* initialize geographic shape parameters */
+inline void pj_ell_set(std::vector<pvalue>& parameters, double &a, double &es)
+{
+    int i = 0;
+    double b = 0.0;
+    double e = 0.0;
+    std::string name;
+
+    /* check for varying forms of ellipsoid input */
+    a = es = 0.;
+
+    /* R takes precedence */
+    if (pj_param(parameters, "tR").i)
+        a = pj_param(parameters, "dR").f;
+    else { /* probable elliptical figure */
+
+        /* check if ellps present and temporarily append its values to pl */
+        name = pj_param(parameters, "sellps").s;
+        if (! name.empty())
+        {
+            const int n = sizeof(pj_ellps) / sizeof(pj_ellps[0]);
+            int index = -1;
+            for (int i = 0; i < n && index == -1; i++)
+            {
+                if(pj_ellps[i].id == name)
+                {
+                    index = i;
+                }
+            }
+
+            if (index == -1) { throw proj_exception(-9); }
+
+            parameters.push_back(pj_mkparam(pj_ellps[index].major));
+            parameters.push_back(pj_mkparam(pj_ellps[index].ell));
+        }
+        a = pj_param(parameters, "da").f;
+        if (pj_param(parameters, "tes").i) /* eccentricity squared */
+            es = pj_param(parameters, "des").f;
+        else if (pj_param(parameters, "te").i) { /* eccentricity */
+            e = pj_param(parameters, "de").f;
+            es = e * e;
+        } else if (pj_param(parameters, "trf").i) { /* recip flattening */
+            es = pj_param(parameters, "drf").f;
+            if (!es) {
+                throw proj_exception(-10);
+            }
+            es = 1./ es;
+            es = es * (2. - es);
+        } else if (pj_param(parameters, "tf").i) { /* flattening */
+            es = pj_param(parameters, "df").f;
+            es = es * (2. - es);
+        } else if (pj_param(parameters, "tb").i) { /* minor axis */
+            b = pj_param(parameters, "db").f;
+            es = 1. - (b * b) / (a * a);
+        }     /* else es == 0. and sphere of radius a */
+        if (!b)
+            b = a * sqrt(1. - es);
+        /* following options turn ellipsoid into equivalent sphere */
+        if (pj_param(parameters, "bR_A").i) { /* sphere--area of ellipsoid */
+            a *= 1. - es * (SIXTH + es * (RA4 + es * RA6));
+            es = 0.;
+        } else if (pj_param(parameters, "bR_V").i) { /* sphere--vol. of ellipsoid */
+            a *= 1. - es * (SIXTH + es * (RV4 + es * RV6));
+            es = 0.;
+        } else if (pj_param(parameters, "bR_a").i) { /* sphere--arithmetic mean */
+            a = .5 * (a + b);
+            es = 0.;
+        } else if (pj_param(parameters, "bR_g").i) { /* sphere--geometric mean */
+            a = sqrt(a * b);
+            es = 0.;
+        } else if (pj_param(parameters, "bR_h").i) { /* sphere--harmonic mean */
+            a = 2. * a * b / (a + b);
+            es = 0.;
+        } else if ((i = pj_param(parameters, "tR_lat_a").i) || /* sphere--arith. */
+            pj_param(parameters, "tR_lat_g").i) { /* or geom. mean at latitude */
+            double tmp;
+
+            tmp = sin(pj_param(parameters, i ? "rR_lat_a" : "rR_lat_g").f);
+            if (geometry::math::abs(tmp) > HALFPI) {
+                throw proj_exception(-11);
+            }
+            tmp = 1. - es * tmp * tmp;
+            a *= i ? .5 * (1. - es + tmp) / ( tmp * sqrt(tmp)) :
+                sqrt(1. - es) / tmp;
+            es = 0.;
+        }
+    }
+
+    /* some remaining checks */
+    if (es < 0.)
+        { throw proj_exception(-12); }
+    if (a <= 0.)
+        { throw proj_exception(-13); }
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_ellps.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_ellps.hpp
new file mode 100644
index 0000000..31b93d8
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_ellps.hpp
@@ -0,0 +1,93 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELLPS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELLPS_HPP
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+static const PJ_ELLPS pj_ellps[] =
+{
+    { "MERIT",    "a=6378137.0",   "rf=298.257",        "MERIT 1983" },
+    { "SGS85",    "a=6378136.0",   "rf=298.257",        "Soviet Geodetic System 85" },
+    { "GRS80",    "a=6378137.0",   "rf=298.257222101",  "GRS 1980(IUGG, 1980)" },
+    { "IAU76",    "a=6378140.0",   "rf=298.257",        "IAU 1976" },
+    { "airy",     "a=6377563.396", "b=6356256.910",     "Airy 1830" },
+    { "APL4.9",   "a=6378137.0.",  "rf=298.25",         "Appl. Physics. 1965" },
+    { "NWL9D",    "a=6378145.0.",  "rf=298.25",         "Naval Weapons Lab., 1965" },
+    { "mod_airy", "a=6377340.189", "b=6356034.446",     "Modified Airy" },
+    { "andrae",   "a=6377104.43",  "rf=300.0",          "Andrae 1876 (Den., Iclnd.)" },
+    { "aust_SA",  "a=6378160.0",   "rf=298.25",         "Australian Natl & S. Amer. 1969" },
+    { "GRS67",    "a=6378160.0",   "rf=298.2471674270", "GRS 67(IUGG 1967)" },
+    { "bessel",   "a=6377397.155", "rf=299.1528128",    "Bessel 1841" },
+    { "bess_nam", "a=6377483.865", "rf=299.1528128",    "Bessel 1841 (Namibia)" },
+    { "clrk66",   "a=6378206.4",   "b=6356583.8",  "Clarke 1866" },
+    { "clrk80",   "a=6378249.145", "rf=293.4663",  "Clarke 1880 mod." },
+    { "CPM",      "a=6375738.7",   "rf=334.29",    "Comm. des Poids et Mesures 1799" },
+    { "delmbr",   "a=6376428.",    "rf=311.5",     "Delambre 1810 (Belgium)" },
+    { "engelis",  "a=6378136.05",  "rf=298.2566",  "Engelis 1985" },
+    { "evrst30",  "a=6377276.345", "rf=300.8017",  "Everest 1830" },
+    { "evrst48",  "a=6377304.063", "rf=300.8017",  "Everest 1948" },
+    { "evrst56",  "a=6377301.243", "rf=300.8017",  "Everest 1956" },
+    { "evrst69",  "a=6377295.664", "rf=300.8017",  "Everest 1969" },
+    { "evrstSS",  "a=6377298.556", "rf=300.8017",  "Everest (Sabah & Sarawak)" },
+    { "fschr60",  "a=6378166.",    "rf=298.3", "Fischer (Mercury Datum) 1960" },
+    { "fschr60m", "a=6378155.",    "rf=298.3", "Modified Fischer 1960" },
+    { "fschr68",  "a=6378150.",    "rf=298.3", "Fischer 1968" },
+    { "helmert",  "a=6378200.",    "rf=298.3", "Helmert 1906" },
+    { "hough",    "a=6378270.0",   "rf=297.",  "Hough" },
+    { "intl",     "a=6378388.0",   "rf=297.",  "International 1909 (Hayford)" },
+    { "krass",    "a=6378245.0",   "rf=298.3", "Krassovsky, 1942" },
+    { "kaula",    "a=6378163.",    "rf=298.24",  "Kaula 1961" },
+    { "lerch",    "a=6378139.",    "rf=298.257", "Lerch 1979" },
+    { "mprts",    "a=6397300.",    "rf=191.",    "Maupertius 1738" },
+    { "new_intl", "a=6378157.5",   "b=6356772.2","New International 1967" },
+    { "plessis",  "a=6376523.",    "b=6355863.", "Plessis 1817 (France)" },
+    { "SEasia",   "a=6378155.0",   "b=6356773.3205", "Southeast Asia" },
+    { "walbeck",  "a=6376896.0",   "b=6355834.8467", "Walbeck" },
+    { "WGS60",    "a=6378165.0",   "rf=298.3",  "WGS 60" },
+    { "WGS66",    "a=6378145.0",   "rf=298.25", "WGS 66" },
+    { "WGS72",    "a=6378135.0",   "rf=298.26", "WGS 72" },
+    { "WGS84",    "a=6378137.0",   "rf=298.257223563", "WGS 84" },
+    { "sphere",   "a=6370997.0",   "b=6370997.0", "Normal Sphere (r=6370997)" }
+};
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELLPS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_fwd.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_fwd.hpp
new file mode 100644
index 0000000..6218dc6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_fwd.hpp
@@ -0,0 +1,98 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
+
+#include <cmath>
+
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/adjlon.hpp>
+
+/* general forward projection */
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+namespace forwrd
+{
+    static const double EPS = 1.0e-12;
+}
+
+/* forward projection entry */
+template <typename Prj, typename LL, typename XY, typename P>
+inline void pj_fwd(Prj const& prj, P const& par, LL const& ll, XY& xy)
+{
+    using namespace detail;
+
+    double lp_lon = geometry::get_as_radian<0>(ll);
+    double lp_lat = geometry::get_as_radian<1>(ll);
+    const double t = geometry::math::abs(lp_lat) - HALFPI;
+
+    /* check for forward and latitude or longitude overange */
+    if (t > forwrd::EPS || geometry::math::abs(lp_lon) > 10.)
+    {
+        throw proj_exception();
+    }
+
+    if (geometry::math::abs(t) <= forwrd::EPS)
+    {
+        lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+    }
+    else if (par.geoc)
+    {
+        lp_lat = atan(par.rone_es * tan(lp_lat));
+    }
+
+    lp_lon -= par.lam0;    /* compute del lp.lam */
+    if (! par.over)
+    {
+        lp_lon = adjlon(lp_lon); /* post_forward del longitude */
+    }
+
+    double x = 0;
+    double y = 0;
+
+    prj.fwd(lp_lon, lp_lat, x, y);
+    geometry::set<0>(xy, par.fr_meter * (par.a * x + par.x0));
+    geometry::set<1>(xy, par.fr_meter * (par.a * y + par.y0));
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_gauss.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_gauss.hpp
new file mode 100644
index 0000000..8ace7c6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_gauss.hpp
@@ -0,0 +1,130 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GAUSS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GAUSS_HPP
+
+
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail { namespace gauss {
+
+
+static const int MAX_ITER = 20;
+
+struct GAUSS
+{
+    double C;
+    double K;
+    double e;
+    double ratexp;
+};
+
+static const double DEL_TOL = 1e-14;
+
+inline double srat(double esinp, double exp)
+{
+    return (pow((1.0 - esinp) / (1.0 + esinp), exp));
+}
+
+inline GAUSS gauss_ini(double e, double phi0, double &chi, double &rc)
+{
+    using std::asin;
+    using std::cos;
+    using std::sin;
+    using std::sqrt;
+    using std::tan;
+
+    double sphi = 0;
+    double cphi = 0;
+    double es = 0;
+
+    GAUSS en;
+    es = e * e;
+    en.e = e;
+    sphi = sin(phi0);
+    cphi = cos(phi0);
+    cphi *= cphi;
+
+    rc = sqrt(1.0 - es) / (1.0 - es * sphi * sphi);
+    en.C = sqrt(1.0 + es * cphi * cphi / (1.0 - es));
+    chi = asin(sphi / en.C);
+    en.ratexp = 0.5 * en.C * e;
+    en.K = tan(0.5 * chi + detail::FORTPI)
+           / (pow(tan(0.5 * phi0 + detail::FORTPI), en.C) * srat(en.e * sphi, en.ratexp));
+
+    return en;
+}
+
+template <typename T>
+inline void gauss(GAUSS const& en, T& lam, T& phi)
+{
+    phi = 2.0 * atan(en.K * pow(tan(0.5 * phi + FORTPI), en.C)
+          * srat(en.e * sin(phi), en.ratexp) ) - HALFPI;
+
+    lam *= en.C;
+}
+
+template <typename T>
+inline void inv_gauss(GAUSS const& en, T& lam, T& phi)
+{
+    lam /= en.C;
+    const double num = pow(tan(0.5 * phi + FORTPI) / en.K, 1.0 / en.C);
+
+    int i = 0;
+    for (i = MAX_ITER; i; --i)
+    {
+        const double elp_phi = 2.0 * atan(num * srat(en.e * sin(phi), - 0.5 * en.e)) - HALFPI;
+
+        if (geometry::math::abs(elp_phi - phi) < DEL_TOL)
+        {
+            break;
+        }
+        phi = elp_phi;
+    }
+
+    /* convergence failed */
+    if (!i)
+    {
+        throw proj_exception(-17);
+    }
+}
+
+}} // namespace detail::gauss
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GAUSS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_init.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_init.hpp
new file mode 100644
index 0000000..7c618d1
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_init.hpp
@@ -0,0 +1,301 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_INIT_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_INIT_HPP
+
+#include <string>
+#include <vector>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/util/math.hpp>
+
+
+#include <boost/geometry/extensions/gis/projections/impl/pj_datum_set.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_datums.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_param.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_units.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/parameters.hpp>
+
+#include <boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp>
+
+
+namespace boost { namespace geometry { namespace projection
+{
+
+
+namespace detail
+{
+
+/************************************************************************/
+/*                              pj_init()                               */
+/*                                                                      */
+/*      Main entry point for initialing a PJ projections                */
+/*      definition.  Note that the projection specific function is      */
+/*      called to do the initial allocation so it can be created        */
+/*      large enough to hold projection specific parameters.            */
+/************************************************************************/
+template <typename R>
+parameters pj_init(R const& arguments, bool use_defaults = true)
+{
+    parameters pin;
+    for (std::vector<std::string>::const_iterator it = boost::begin(arguments);
+        it != boost::end(arguments); it++)
+    {
+        pin.params.push_back(pj_mkparam(*it));
+    }
+
+    /* check if +init present */
+    if (pj_param(pin.params, "tinit").i)
+    {
+        // maybe TODO: handle "init" parameter
+        //if (!(curr = get_init(&arguments, curr, pj_param(pin.params, "sinit").s)))
+    }
+
+    // find projection -> implemented in projection factory
+    pin.name = pj_param(pin.params, "sproj").s;
+    //if (pin.name.empty())
+    //{ throw proj_exception(-4); }
+
+
+    // set defaults, unless inhibited
+    // GL-Addition, if use_defaults is false then defaults are ignored
+    if (use_defaults && ! pj_param(pin.params, "bno_defs").i)
+    {
+        // proj4 gets defaults from "proj_def.dat", file of 94/02/23 with a few defaults.
+        // Here manually
+        if (pin.name == "lcc")
+        {
+            pin.params.push_back(pj_mkparam("lat_1=33"));
+            pin.params.push_back(pj_mkparam("lat_2=45"));
+        }
+        else if (pin.name == "aea")
+        {
+            pin.params.push_back(pj_mkparam("lat_1=29.5"));
+            pin.params.push_back(pj_mkparam("lat_2=45.5 "));
+        }
+        else
+        {
+            //<general>ellps=WGS84
+        }
+        //curr = get_defaults(&arguments, curr, name);
+    }
+
+    /* allocate projection structure */
+    // done by constructor:
+    // pin.is_latlong = 0;
+    // pin.is_geocent = 0;
+    // pin.long_wrap_center = 0.0;
+
+    /* set datum parameters */
+    pj_datum_set(pin.params, pin);
+
+    /* set ellipsoid/sphere parameters */
+    pj_ell_set(pin.params, pin.a, pin.es);
+
+    pin.a_orig = pin.a;
+    pin.es_orig = pin.es;
+
+    pin.e = sqrt(pin.es);
+    pin.ra = 1. / pin.a;
+    pin.one_es = 1. - pin.es;
+    if (pin.one_es == 0.) { throw proj_exception(-6); }
+    pin.rone_es = 1./pin.one_es;
+
+    /* Now that we have ellipse information check for WGS84 datum */
+    if( pin.datum_type == PJD_3PARAM
+        && pin.datum_params[0] == 0.0
+        && pin.datum_params[1] == 0.0
+        && pin.datum_params[2] == 0.0
+        && pin.a == 6378137.0
+        && geometry::math::abs(pin.es - 0.006694379990) < 0.000000000050 )/*WGS84/GRS80*/
+    {
+        pin.datum_type = PJD_WGS84;
+    }
+
+    /* set pin.geoc coordinate system */
+    pin.geoc = (pin.es && pj_param(pin.params, "bgeoc").i);
+
+    /* over-ranging flag */
+    pin.over = pj_param(pin.params, "bover").i;
+
+    /* longitude center for wrapping */
+    pin.long_wrap_center = pj_param(pin.params, "rlon_wrap").f;
+
+    /* central meridian */
+    pin.lam0 = pj_param(pin.params, "rlon_0").f;
+
+    /* central latitude */
+    pin.phi0 = pj_param(pin.params, "rlat_0").f;
+
+    /* false easting and northing */
+    pin.x0 = pj_param(pin.params, "dx_0").f;
+    pin.y0 = pj_param(pin.params, "dy_0").f;
+
+    /* general scaling factor */
+    if (pj_param(pin.params, "tk_0").i)
+        pin.k0 = pj_param(pin.params, "dk_0").f;
+    else if (pj_param(pin.params, "tk").i)
+        pin.k0 = pj_param(pin.params, "dk").f;
+    else
+        pin.k0 = 1.;
+    if (pin.k0 <= 0.) {
+        throw proj_exception(-31);
+    }
+
+    /* set units */
+    std::string s;
+    std::string units = pj_param(pin.params, "sunits").s;
+    if (! units.empty())
+    {
+        const int n = sizeof(pj_units) / sizeof(pj_units[0]);
+        int index = -1;
+        for (int i = 0; i < n && index == -1; i++)
+        {
+            if(pj_units[i].id == units)
+            {
+                index = i;
+            }
+        }
+
+        if (index == -1) { throw proj_exception(-7); }
+        s = pj_units[index].to_meter;
+    }
+
+    if (s.empty())
+    {
+        s = pj_param(pin.params, "sto_meter").s;
+    }
+
+    if (! s.empty())
+    {
+        // TODO: IMPLEMENT SPLIT
+        pin.to_meter = atof(s.c_str());
+        //if (*s == '/') /* ratio number */
+        //    pin.to_meter /= strtod(++s, 0);
+        pin.fr_meter = 1. / pin.to_meter;
+    }
+    else
+    {
+        pin.to_meter = pin.fr_meter = 1.;
+    }
+
+    /* prime meridian */
+    s.clear();
+    std::string pm = pj_param(pin.params, "spm").s;
+    if (! pm.empty())
+    {
+        std::string value;
+
+        int n = sizeof(pj_prime_meridians) / sizeof(pj_prime_meridians[0]);
+        int index = -1;
+        for (int i = 0; i < n && index == -1; i++)
+        {
+            if(pj_prime_meridians[i].id == pm)
+            {
+                value = pj_prime_meridians[i].defn;
+                index = i;
+            }
+        }
+
+        if (index == -1) { throw proj_exception(-7); }
+        if (value.empty()) { throw proj_exception(-46); }
+
+        geometry::strategy::dms_parser<true> parser;
+        pin.from_greenwich = parser(value.c_str());
+    }
+    else
+    {
+        pin.from_greenwich = 0.0;
+    }
+
+    return pin;
+}
+
+/************************************************************************/
+/*                            pj_init_plus()                            */
+/*                                                                      */
+/*      Same as pj_init() except it takes one argument string with      */
+/*      individual arguments preceeded by '+', such as "+proj=utm       */
+/*      +zone=11 +ellps=WGS84".                                         */
+/************************************************************************/
+
+inline parameters pj_init_plus(std::string const& definition, bool use_defaults = true)
+{
+    static const char* sep = " +";
+
+    /* split into arguments based on '+' and trim white space */
+
+    // boost::split splits on one character, here it should be on " +", so implementation below
+    // todo: put in different routine or sort out
+    std::vector<std::string> arguments;
+    std::string def = boost::trim_copy(definition);
+    boost::trim_left_if(def, boost::is_any_of(sep));
+
+    std::string::size_type loc = def.find(sep);
+    while (loc != std::string::npos)
+    {
+        std::string par = def.substr(0, loc);
+        boost::trim(par);
+        if (! par.empty())
+        {
+            arguments.push_back(par);
+        }
+
+        def.erase(0, loc);
+        boost::trim_left_if(def, boost::is_any_of(sep));
+        loc = def.find(sep);
+    }
+
+    if (! def.empty())
+    {
+        arguments.push_back(def);
+    }
+
+    /*boost::split(arguments, definition, boost::is_any_of("+"));
+    for (std::vector<std::string>::iterator it = arguments.begin(); it != arguments.end(); it++)
+    {
+        boost::trim(*it);
+    }*/
+    return pj_init(arguments, use_defaults);
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_INIT_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp
new file mode 100644
index 0000000..70ec6e6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp
@@ -0,0 +1,80 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_INV_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PJ_INV_HPP
+
+
+
+#include <boost/geometry/extensions/gis/projections/impl/adjlon.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/util/math.hpp>
+
+/* general inverse projection */
+
+namespace boost { namespace geometry { namespace projection
+{
+
+namespace detail
+{
+
+namespace inv
+{
+    static const double EPS = 1.0e-12;
+}
+
+ /* inverse projection entry */
+template <typename PRJ, typename LL, typename XY, typename PAR>
+void pj_inv(PRJ const& prj, PAR const& par, XY const& xy, LL& ll)
+{
+    /* can't do as much preliminary checking as with forward */
+    /* descale and de-offset */
+    double xy_x = (geometry::get<0>(xy) * par.to_meter - par.x0) * par.ra;
+    double xy_y = (geometry::get<1>(xy) * par.to_meter - par.y0) * par.ra;
+    double lon = 0, lat = 0;
+    prj.inv(xy_x, xy_y, lon, lat); /* inverse project */
+    lon += par.lam0; /* reduce from del lp.lam */
+    if (!par.over)
+        lon = adjlon(lon); /* adjust longitude to CM */
+    if (par.geoc && geometry::math::abs(fabs(lat)-HALFPI) > inv::EPS)
+        lat = atan(par.one_es * tan(lat));
+
+    geometry::set_from_radian<0>(ll, lon);
+    geometry::set_from_radian<1>(ll, lat);
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp
new file mode 100644
index 0000000..8dc554a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp
@@ -0,0 +1,111 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_MLFN_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PJ_MLFN_HPP
+
+
+
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+/* meridinal distance for ellipsoid and inverse
+**    8th degree - accurate to < 1e-5 meters when used in conjuction
+**        with typical major axis values.
+**    Inverse determines phi to EPS (1e-11) radians, about 1e-6 seconds.
+*/
+static const double C00 = 1.;
+static const double C02 = .25;
+static const double C04 = .046875;
+static const double C06 = .01953125;
+static const double C08 = .01068115234375;
+static const double C22 = .75;
+static const double C44 = .46875;
+static const double C46 = .01302083333333333333;
+static const double C48 = .00712076822916666666;
+static const double C66 = .36458333333333333333;
+static const double C68 = .00569661458333333333;
+static const double C88 = .3076171875;
+static const double EPS = 1e-11;
+static const int MAX_ITER = 10;
+static const int EN_SIZE = 5;
+
+inline void pj_enfn(double es, double* en)
+{
+    double t; //, *en;
+
+    //if (en = (double *)pj_malloc(EN_SIZE * sizeof(double)))
+    {
+        en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08)));
+        en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08)));
+        en[2] = (t = es * es) * (C44 - es * (C46 + es * C48));
+        en[3] = (t *= es) * (C66 - es * C68);
+        en[4] = t * es * C88;
+    }
+    // return en;
+}
+
+inline double pj_mlfn(double phi, double sphi, double cphi, const double *en)
+{
+    cphi *= sphi;
+    sphi *= sphi;
+    return(en[0] * phi - cphi * (en[1] + sphi*(en[2]
+        + sphi*(en[3] + sphi*en[4]))));
+}
+
+inline double pj_inv_mlfn(double arg, double es, const double *en)
+{
+    double s, t, phi, k = 1./(1.-es);
+    int i;
+
+    phi = arg;
+    for (i = MAX_ITER; i ; --i) { /* rarely goes over 2 iterations */
+        s = sin(phi);
+        t = 1. - es * s * s;
+        phi -= t = (pj_mlfn(phi, s, cos(phi), en) - arg) * (t * sqrt(t)) * k;
+        if (geometry::math::abs(t) < EPS)
+            return phi;
+    }
+    throw proj_exception(-17);
+    return phi;
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp
new file mode 100644
index 0000000..d4c102e
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp
@@ -0,0 +1,54 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_MSFN_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PJ_MSFN_HPP
+
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+
+/* determine constant small m */
+inline double pj_msfn(double sinphi, double cosphi, double es)
+{
+    return (cosphi / sqrt (1. - es * sinphi * sinphi));
+}
+
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_param.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_param.hpp
new file mode 100644
index 0000000..e42c0ff
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_param.hpp
@@ -0,0 +1,155 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_PARAM_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PJ_PARAM_HPP
+
+
+#include <string>
+#include <vector>
+
+#include <boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+
+namespace boost { namespace geometry { namespace projection {
+
+namespace detail {
+
+
+
+/* create pvalue list entry */
+inline pvalue pj_mkparam(std::string const& str)
+{
+    std::string name = str;
+    std::string value;
+    boost::trim_left_if(name, boost::is_any_of("+"));
+    std::string::size_type loc = name.find("=");
+    if (loc != std::string::npos)
+    {
+        value = name.substr(loc + 1);
+        name.erase(loc);
+    }
+
+
+    pvalue newitem;
+    newitem.param = name;
+    newitem.s = value;
+    newitem.used = 0;
+    newitem.i = atoi(value.c_str());
+    newitem.f = atof(value.c_str());
+    return newitem;
+}
+
+/************************************************************************/
+/*                              pj_param()                              */
+/*                                                                      */
+/*      Test for presence or get pvalue value.  The first            */
+/*      character in `opt' is a pvalue type which can take the       */
+/*      values:                                                         */
+/*                                                                      */
+/*       `t' - test for presence, return TRUE/FALSE in pvalue.i         */
+/*       `i' - integer value returned in pvalue.i                       */
+/*       `d' - simple valued real input returned in pvalue.f            */
+/*       `r' - degrees (DMS translation applied), returned as           */
+/*             radians in pvalue.f                                      */
+/*       `s' - string returned in pvalue.s                              */
+/*       `b' - test for t/T/f/F, return in pvalue.i                     */
+/*                                                                      */
+/************************************************************************/
+
+inline pvalue pj_param(std::vector<pvalue> const& pl, std::string opt)
+{
+    char type = opt[0];
+    opt.erase(opt.begin());
+
+    pvalue value;
+
+    /* simple linear lookup */
+    for (std::vector<pvalue>::const_iterator it = pl.begin(); it != pl.end(); it++)
+    {
+        if (it->param == opt)
+        {
+            //it->used = 1;
+            switch (type)
+            {
+            case 't':
+                value.i = 1;
+                break;
+            case 'i':    /* integer input */
+                value.i = atoi(it->s.c_str());
+                break;
+            case 'd':    /* simple real input */
+                value.f = atof(it->s.c_str());
+                break;
+            case 'r':    /* degrees input */
+                {
+                    geometry::strategy::dms_parser<true> parser;
+                    value.f = parser(it->s.c_str());
+                }
+                break;
+            case 's':    /* char string */
+                value.s = it->s;
+                break;
+            case 'b':    /* boolean */
+                switch (it->s[0])
+                {
+                case 'F': case 'f':
+                    value.i = 0;
+                    break;
+                case '\0': case 'T': case 't':
+                    value.i = 1;
+                    break;
+                default:
+                    value.i = 0;
+                    break;
+                }
+                break;
+            }
+            return value;
+        }
+
+    }
+
+    value.i = 0;
+    value.f = 0.0;
+    value.s = "";
+    return value;
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp
new file mode 100644
index 0000000..4e9db63
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp
@@ -0,0 +1,73 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PHI2_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PHI2_HPP
+
+
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry { namespace projection {
+namespace detail {
+
+namespace phi2
+{
+    static const double TOL = 1.0e-10;
+    static const int N_ITER = 15;
+}
+
+inline double pj_phi2(double ts, double e)
+{
+    double eccnth, Phi, con, dphi;
+    int i;
+
+    eccnth = .5 * e;
+    Phi = HALFPI - 2. * atan (ts);
+    i = phi2::N_ITER;
+    do {
+        con = e * sin (Phi);
+        dphi = HALFPI - 2. * atan (ts * pow((1. - con) /
+           (1. + con), eccnth)) - Phi;
+        Phi += dphi;
+    } while ( geometry::math::abs(dphi) > phi2::TOL && --i);
+    if (i <= 0)
+        throw proj_exception(-18);
+    return Phi;
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp
new file mode 100644
index 0000000..fe251dc
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp
@@ -0,0 +1,84 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_QSFN_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PJ_QSFN_HPP
+
+
+namespace boost { namespace geometry { namespace projection
+{ namespace detail {
+
+/* determine small q */
+inline double pj_qsfn(double sinphi, double e, double one_es)
+{
+    static const double EPSILON = 1.0e-7;
+
+    if (e >= EPSILON)
+    {
+        double con = e * sinphi;
+        return (one_es * (sinphi / (1. - con * con) -
+           (.5 / e) * log ((1. - con) / (1. + con))));
+    } else
+        return (sinphi + sinphi);
+}
+
+
+#define MAX_C 9
+struct AUTHALIC
+{
+    double C[MAX_C], CP[MAX_C], CQ[MAX_C];
+};
+
+/**
+ * @brief determine authalic latitude
+ * @param[in] phi geographic latitude
+ * @param[in] a initialized structure pointer
+ * @return authalic latitude
+ */
+inline double proj_qsfn(double phi, const AUTHALIC& a)
+{
+    double s, s2, sum;
+    int i = MAX_C;
+
+    s = sin(phi);
+    s2 = s * s;
+    sum = a.CQ[MAX_C - 1];
+    while (--i) sum = a.CQ[i] + s2 * sum;
+    return(s * sum);
+}
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp
new file mode 100644
index 0000000..1b0e23a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp
@@ -0,0 +1,54 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_TSFN_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PJ_TSFN_HPP
+
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+namespace boost { namespace geometry { namespace projection {
+namespace detail {
+
+    /* determine small t */
+    inline double pj_tsfn(double phi, double sinphi, double e)
+    {
+        sinphi *= e;
+        return (tan (.5 * (HALFPI - phi)) /
+           pow((1. - sinphi) / (1. + sinphi), .5 * e));
+    }
+
+} // namespace detail
+}}} // namespace boost::geometry::projection
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_units.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_units.hpp
new file mode 100644
index 0000000..e16647e
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_units.hpp
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_UNITS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_UNITS_HPP
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+namespace boost { namespace geometry { namespace projection {
+namespace detail {
+
+/* Field 2 that contains the multiplier to convert named units to meters
+** may be expressed by either a simple floating point constant or a
+** numerator/denomenator values (e.g. 1/1000) */
+
+static const PJ_UNITS pj_units[] =
+{
+    { "km",     "1000.",    "Kilometer" },
+    { "m",      "1.",       "Meter" },
+    { "dm",     "1/10",     "Decimeter" },
+    { "cm",     "1/100",    "Centimeter" },
+    { "mm",     "1/1000",   "Millimeter" },
+    { "kmi",    "1852.0",   "International Nautical Mile" },
+    { "in",     "0.0254",   "International Inch" },
+    { "ft",     "0.3048",   "International Foot" },
+    { "yd",     "0.9144",   "International Yard" },
+    { "mi",     "1609.344", "International Statute Mile" },
+    { "fath",   "1.8288",   "International Fathom" },
+    { "ch",     "20.1168",  "International Chain" },
+    { "link",   "0.201168", "International Link" },
+    { "us-in",  "1./39.37", "U.S. Surveyor's Inch" },
+    { "us-ft",  "0.304800609601219", "U.S. Surveyor's Foot" },
+    { "us-yd",  "0.914401828803658", "U.S. Surveyor's Yard" },
+    { "us-ch",  "20.11684023368047", "U.S. Surveyor's Chain" },
+    { "us-mi",  "1609.347218694437", "U.S. Surveyor's Statute Mile" },
+    { "ind-yd", "0.91439523",        "Indian Yard" },
+    { "ind-ft", "0.30479841",        "Indian Foot" },
+    { "ind-ch", "20.11669506",       "Indian Chain" }
+};
+
+} // detail
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_UNITS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/impl/pj_zpoly1.hpp b/src/boost/geometry/extensions/gis/projections/impl/pj_zpoly1.hpp
new file mode 100644
index 0000000..787e651
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/pj_zpoly1.hpp
@@ -0,0 +1,100 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ZPOLY1_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ZPOLY1_HPP
+
+
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+
+namespace boost { namespace geometry { namespace projection { namespace detail {
+
+    /* evaluate complex polynomial */
+
+    /* note: coefficients are always from C_1 to C_n
+    **    i.e. C_0 == (0., 0)
+    **    n should always be >= 1 though no checks are made
+    */
+    inline COMPLEX
+    pj_zpoly1(COMPLEX z, COMPLEX *C, int n)
+    {
+        COMPLEX a;
+        double t;
+
+        a = *(C += n);
+        while (n-- > 0)
+        {
+            a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
+            a.i = C->i + z.r * a.i + z.i * t;
+        }
+        a.r = z.r * (t = a.r) - z.i * a.i;
+        a.i = z.r * a.i + z.i * t;
+        return a;
+    }
+
+    /* evaluate complex polynomial and derivative */
+    inline COMPLEX
+    pj_zpolyd1(COMPLEX z, COMPLEX *C, int n, COMPLEX *der)
+    {
+        double t;
+        bool first = true;
+
+        COMPLEX a = *(C += n);
+        COMPLEX b = a;
+        while (n-- > 0)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                b.r = a.r + z.r * (t = b.r) - z.i * b.i;
+                b.i = a.i + z.r * b.i + z.i * t;
+            }
+            a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
+            a.i = C->i + z.r * a.i + z.i * t;
+        }
+        b.r = a.r + z.r * (t = b.r) - z.i * b.i;
+        b.i = a.i + z.r * b.i + z.i * t;
+        a.r = z.r * (t = a.r) - z.i * a.i;
+        a.i = z.r * a.i + z.i * t;
+        *der = b;
+        return a;
+    }
+
+}}}} // namespace boost::geometry::projection::impl
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp b/src/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp
new file mode 100644
index 0000000..c9768d2
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp
@@ -0,0 +1,137 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PROJ_MDIST_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PROJ_MDIST_HPP
+
+
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry { namespace projection
+{
+namespace detail
+{
+    static const int MDIST_MAX_ITER = 20;
+
+    struct MDIST
+    {
+        int nb;
+        double es;
+        double E;
+        double b[MDIST_MAX_ITER];
+    };
+
+    inline void proj_mdist_ini(double es, MDIST& b)
+    {
+        double numf, numfi, twon1, denf, denfi, ens, T, twon;
+        double den, El, Es;
+        double E[MDIST_MAX_ITER];
+        int i, j;
+
+        /* generate E(e^2) and its terms E[] */
+        ens = es;
+        numf = twon1 = denfi = 1.;
+        denf = 1.;
+        twon = 4.;
+        Es = El = E[0] = 1.;
+        for (i = 1; i < MDIST_MAX_ITER ; ++i)
+        {
+            numf *= (twon1 * twon1);
+            den = twon * denf * denf * twon1;
+            T = numf/den;
+            Es -= (E[i] = T * ens);
+            ens *= es;
+            twon *= 4.;
+            denf *= ++denfi;
+            twon1 += 2.;
+            if (Es == El) /* jump out if no change */
+                break;
+            El = Es;
+        }
+        b.nb = i - 1;
+        b.es = es;
+        b.E = Es;
+        /* generate b_n coefficients--note: collapse with prefix ratios */
+        b.b[0] = Es = 1. - Es;
+        numf = denf = 1.;
+        numfi = 2.;
+        denfi = 3.;
+        for (j = 1; j < i; ++j)
+        {
+            Es -= E[j];
+            numf *= numfi;
+            denf *= denfi;
+            b.b[j] = Es * numf / denf;
+            numfi += 2.;
+            denfi += 2.;
+        }
+    }
+    inline double proj_mdist(double phi, double sphi, double cphi, const MDIST& b)
+    {
+        double sc, sum, sphi2, D;
+        int i;
+
+        sc = sphi * cphi;
+        sphi2 = sphi * sphi;
+        D = phi * b.E - b.es * sc / sqrt(1. - b.es * sphi2);
+        sum = b.b[i = b.nb];
+        while (i) sum = b.b[--i] + sphi2 * sum;
+        return(D + sc * sum);
+    }
+    inline double proj_inv_mdist(double dist, const MDIST& b)
+    {
+        static const double TOL = 1e-14;
+        double s, t, phi, k;
+        int i;
+
+        k = 1./(1.- b.es);
+        i = MDIST_MAX_ITER;
+        phi = dist;
+        while ( i-- ) {
+            s = sin(phi);
+            t = 1. - b.es * s * s;
+            phi -= t = (proj_mdist(phi, s, cos(phi), b) - dist) *
+                (t * sqrt(t)) * k;
+            if (geometry::math::abs(t) < TOL) /* that is no change */
+                return phi;
+        }
+            /* convergence failed */
+        throw proj_exception(-17);
+    }
+} // namespace detail
+
+}}} // namespace boost::geometry::projection
+
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/impl/projects.hpp b/src/boost/geometry/extensions/gis/projections/impl/projects.hpp
new file mode 100644
index 0000000..c9d17e2
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/impl/projects.hpp
@@ -0,0 +1,184 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// This file is manually converted from PROJ4 (projects.h)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
+
+#include <cstring>
+#include <string>
+#include <vector>
+
+#include <boost/concept_check.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+/* some useful constants */
+static const double HALFPI = 1.5707963267948966;
+static const double FORTPI = 0.78539816339744833;
+static const double PI = 3.14159265358979323846;
+static const double TWOPI = 6.2831853071795864769;
+
+static const double RAD_TO_DEG = 57.29577951308232;
+static const double DEG_TO_RAD = .0174532925199432958;
+
+static const int PJD_UNKNOWN =0;
+static const int PJD_3PARAM = 1;
+static const int PJD_7PARAM = 2;
+static const int PJD_GRIDSHIFT = 3;
+static const int PJD_WGS84 = 4;   /* WGS84 (or anything considered equivelent) */
+
+
+struct pvalue
+{
+    std::string param;
+    int used;
+
+    int i;
+    double f;
+    std::string s;
+};
+
+struct pj_const_pod
+{
+    int over;   /* over-range flag */
+    int geoc;   /* geocentric latitude flag */
+    int is_latlong; /* proj=latlong ... not really a projection at all */
+    int is_geocent; /* proj=geocent ... not really a projection at all */
+    double
+        a,  /* major axis or radius if es==0 */
+        a_orig, /* major axis before any +proj related adjustment */
+        es, /* e ^ 2 */
+        es_orig, /* es before any +proj related adjustment */
+        e,  /* eccentricity */
+        ra, /* 1/A */
+        one_es, /* 1 - e^2 */
+        rone_es, /* 1/one_es */
+        lam0, phi0, /* central longitude, latitude */
+        x0, y0, /* easting and northing */
+        k0,    /* general scaling factor */
+        to_meter, fr_meter; /* cartesian scaling */
+
+    int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
+    double  datum_params[7];
+    double  from_greenwich; /* prime meridian offset (in radians) */
+    double  long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
+
+    // Initialize all variables to zero
+    pj_const_pod()
+    {
+        std::memset(this, 0, sizeof(pj_const_pod));
+    }
+};
+
+// PROJ4 complex. Might be replaced with std::complex
+struct COMPLEX { double r, i; };
+
+struct PJ_ELLPS
+{
+    std::string id;    /* ellipse keyword name */
+    std::string major;    /* a= value */
+    std::string ell;    /* elliptical parameter */
+    std::string name;    /* comments */
+};
+
+struct PJ_DATUMS
+{
+    std::string id;     /* datum keyword */
+    std::string defn;   /* ie. "to_wgs84=..." */
+    std::string ellipse_id; /* ie from ellipse table */
+    std::string comments; /* EPSG code, etc */
+};
+
+struct PJ_PRIME_MERIDIANS
+{
+    std::string id;     /* prime meridian keyword */
+    std::string defn;   /* offset from greenwich in DMS format. */
+};
+
+struct PJ_UNITS
+{
+    std::string id;    /* units keyword */
+    std::string to_meter;    /* multiply by value to get meters */
+    std::string name;    /* comments */
+};
+
+struct DERIVS
+{
+    double x_l, x_p; /* derivatives of x for lambda-phi */
+    double y_l, y_p; /* derivatives of y for lambda-phi */
+};
+
+struct FACTORS
+{
+    struct DERIVS der;
+    double h, k;    /* meridinal, parallel scales */
+    double omega, thetap;    /* angular distortion, theta prime */
+    double conv;    /* convergence */
+    double s;        /* areal scale factor */
+    double a, b;    /* max-min scale error */
+    int code;        /* info as to analytics, see following */
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+/*!
+    \brief parameters, projection parameters
+    \details This structure initializes all projections
+    \ingroup projection
+*/
+struct parameters : public detail::pj_const_pod
+{
+    std::string name;
+    std::vector<detail::pvalue> params;
+};
+
+// TODO: derived from boost::exception / make more for forward/inverse/init/setup
+class proj_exception
+{
+public:
+
+    proj_exception(int code = 0)
+    {
+        boost::ignore_unused_variable_warning(code);
+    }
+};
+
+}}} // namespace boost::geometry::projection
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/parameters.hpp b/src/boost/geometry/extensions/gis/projections/parameters.hpp
new file mode 100644
index 0000000..22c5106
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/parameters.hpp
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PARAMETERS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PARAMETERS_HPP
+
+
+#include <string>
+#include <vector>
+
+
+#include <boost/geometry/extensions/gis/projections/impl/pj_init.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+
+namespace boost { namespace geometry { namespace projection {
+
+template <typename R>
+inline parameters init(const R& arguments)
+{
+    return detail::pj_init(arguments);
+}
+
+/*!
+\ingroup projection
+\brief Initializes a projection as a string, using the format with + and =
+\details The projection can be initialized with a string (with the same format as the PROJ4 package) for
+  convenient initialization from, for example, the command line
+\par Example
+    <tt>+proj=labrd +ellps=intl +lon_0=46d26'13.95E +lat_0=18d54S +azi=18d54 +k_0=.9995 +x_0=400000 +y_0=800000</tt>
+    for the Madagascar projection.
+\note Parameters are described in the group
+*/
+inline parameters init(const std::string& arguments)
+{
+    return detail::pj_init_plus(arguments);
+}
+
+/*!
+\ingroup projection
+\brief Overload using a const char*
+*/
+inline parameters init(const char* arguments)
+{
+    return detail::pj_init_plus(arguments);
+}
+
+
+// todo:
+/*
+parameters init(const std::map<std::string, std::string>& arguments)
+{
+    return detail::pj_init_plus(arguments);
+}
+*/
+
+
+
+}}} // namespace boost::geometry::projection
+#endif
diff --git a/src/boost/geometry/extensions/gis/projections/proj/aea.hpp b/src/boost/geometry/extensions/gis/projections/proj/aea.hpp
new file mode 100644
index 0000000..30296ca
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/aea.hpp
@@ -0,0 +1,525 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_AEA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_AEA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace aea{
+            static const double EPS10 = 1.e-10;
+            static const double TOL7 = 1.e-7;
+            static const int N_ITER = 15;
+            static const double EPSILON = 1.0e-7;
+            static const double TOL = 1.0e-10;
+
+            struct par_aea
+            {
+                double    ec;
+                double    n;
+                double    c;
+                double    dd;
+                double    n2;
+                double    rho0;
+                double    rho;
+                double    phi1;
+                double    phi2;
+                double    en[EN_SIZE];
+                int        ellips;
+            };
+
+
+
+
+
+            /* determine latitude angle phi-1 */
+                inline double
+            phi1_(double qs, double Te, double Tone_es) {
+                int i;
+                double Phi, sinpi, cospi, con, com, dphi;
+
+                Phi = asin (.5 * qs);
+                if (Te < EPSILON)
+                    return( Phi );
+                i = N_ITER;
+                do {
+                    sinpi = sin (Phi);
+                    cospi = cos (Phi);
+                    con = Te * sinpi;
+                    com = 1. - con * con;
+                    dphi = .5 * com * com / cospi * (qs / Tone_es -
+                       sinpi / com + .5 / Te * log ((1. - con) /
+                       (1. + con)));
+                    Phi += dphi;
+                } while (fabs(dphi) > TOL && --i);
+                return( i ? Phi : HUGE_VAL );
+            }
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_aea_ellipsoid : public base_t_fi<base_aea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                mutable par_aea m_proj_parm;
+
+                inline base_aea_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_aea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if ((this->m_proj_parm.rho = this->m_proj_parm.c - (this->m_proj_parm.ellips ? this->m_proj_parm.n * pj_qsfn(sin(lp_lat),
+                        this->m_par.e, this->m_par.one_es) : this->m_proj_parm.n2 * sin(lp_lat))) < 0.) throw proj_exception();
+                    this->m_proj_parm.rho = this->m_proj_parm.dd * sqrt(this->m_proj_parm.rho);
+                    xy_x = this->m_proj_parm.rho * sin( lp_lon *= this->m_proj_parm.n );
+                    xy_y = this->m_proj_parm.rho0 - this->m_proj_parm.rho * cos(lp_lon);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    if( (this->m_proj_parm.rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) {
+                        if (this->m_proj_parm.n < 0.) {
+                            this->m_proj_parm.rho = -this->m_proj_parm.rho;
+                            xy_x = -xy_x;
+                            xy_y = -xy_y;
+                        }
+                        lp_lat =  this->m_proj_parm.rho / this->m_proj_parm.dd;
+                        if (this->m_proj_parm.ellips) {
+                            lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n;
+                            if (fabs(this->m_proj_parm.ec - fabs(lp_lat)) > TOL7) {
+                                if ((lp_lat = phi1_(lp_lat, this->m_par.e, this->m_par.one_es)) == HUGE_VAL)
+                                    throw proj_exception();
+                            } else
+                                lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+                        } else if (fabs(lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n2) <= 1.)
+                            lp_lat = asin(lp_lat);
+                        else
+                            lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+                        lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
+                    } else {
+                        lp_lon = 0.;
+                        lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI;
+                    }
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_aea& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                double cosphi, sinphi;
+                int secant;
+                if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21);
+                proj_parm.n = sinphi = sin(proj_parm.phi1);
+                cosphi = cos(proj_parm.phi1);
+                secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10;
+                if( (proj_parm.ellips = (par.es > 0.))) {
+                    double ml1, m1;
+                    pj_enfn(par.es, proj_parm.en);
+                    m1 = pj_msfn(sinphi, cosphi, par.es);
+                    ml1 = pj_qsfn(sinphi, par.e, par.one_es);
+                    if (secant) { /* secant cone */
+                        double ml2, m2;
+                        sinphi = sin(proj_parm.phi2);
+                        cosphi = cos(proj_parm.phi2);
+                        m2 = pj_msfn(sinphi, cosphi, par.es);
+                        ml2 = pj_qsfn(sinphi, par.e, par.one_es);
+                        proj_parm.n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
+                    }
+                    proj_parm.ec = 1. - .5 * par.one_es * log((1. - par.e) /
+                        (1. + par.e)) / par.e;
+                    proj_parm.c = m1 * m1 + proj_parm.n * ml1;
+                    proj_parm.dd = 1. / proj_parm.n;
+                    proj_parm.rho0 = proj_parm.dd * sqrt(proj_parm.c - proj_parm.n * pj_qsfn(sin(par.phi0),
+                        par.e, par.one_es));
+                } else {
+                    if (secant) proj_parm.n = .5 * (proj_parm.n + sin(proj_parm.phi2));
+                    proj_parm.n2 = proj_parm.n + proj_parm.n;
+                    proj_parm.c = cosphi * cosphi + proj_parm.n2 * sinphi;
+                    proj_parm.dd = 1. / proj_parm.n;
+                    proj_parm.rho0 = proj_parm.dd * sqrt(proj_parm.c - proj_parm.n2 * sin(par.phi0));
+                }
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+
+            // Albers Equal Area
+            template <typename Parameters>
+            void setup_aea(Parameters& par, par_aea& proj_parm)
+            {
+                proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
+                proj_parm.phi2 = pj_param(par.params, "rlat_2").f;
+                setup(par, proj_parm);
+            }
+
+            // Lambert Equal Area Conic
+            template <typename Parameters>
+            void setup_leac(Parameters& par, par_aea& proj_parm)
+            {
+                proj_parm.phi2 = pj_param(par.params, "rlat_1").f;
+                proj_parm.phi1 = pj_param(par.params, "bsouth").i ? - HALFPI: HALFPI;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::aea
+    #endif // doxygen
+
+    /*!
+        \brief Albers Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_1= lat_2=
+        \par Example
+        \image html ex_aea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct aea_ellipsoid : public detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline aea_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aea::setup_aea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Lambert Equal Area Conic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_1= south
+        \par Example
+        \image html ex_leac.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct leac_ellipsoid : public detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline leac_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aea::setup_leac(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class aea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<aea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class leac_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<leac_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void aea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("aea", new aea_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("leac", new leac_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    // Create EPSG specializations
+    // (Proof of Concept, only for some)
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2964, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3005, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3083, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3085, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3086, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3087, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3153, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3174, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=42.122774 +lat_2=49.01518 +lat_0=45.568977 +lon_0=-84.455955 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3175, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=42.122774 +lat_2=49.01518 +lat_0=45.568977 +lon_0=-83.248627 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3309, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=clrk66 +datum=NAD27 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3310, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3311, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3338, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3467, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3488, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3513, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3577, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=-18 +lat_2=-36 +lat_0=0 +lon_0=132 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3578, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=61.66666666666666 +lat_2=68 +lat_0=59 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3579, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=61.66666666666666 +lat_2=68 +lat_0=59 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3665, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_AEA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/aeqd.hpp b/src/boost/geometry/extensions/gis/projections/proj/aeqd.hpp
new file mode 100644
index 0000000..ab4e9aa
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/aeqd.hpp
@@ -0,0 +1,454 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/aasincos.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace aeqd{
+            static const double EPS10 = 1.e-10;
+            static const double TOL = 1.e-14;
+            static const int N_POLE = 0;
+            static const int S_POLE = 1;
+            static const int EQUIT = 2;
+            static const int OBLIQ = 3;
+
+            struct par_aeqd
+            {
+                double    sinph0;
+                double    cosph0;
+                double    en[EN_SIZE];
+                double    M1;
+                double    N1;
+                double    Mp;
+                double    He;
+                double    G;
+                int        mode;
+            };
+
+
+
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_aeqd_ellipsoid : public base_t_fi<base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_aeqd m_proj_parm;
+
+                inline base_aeqd_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  coslam, cosphi, sinphi, rho, s, H, H2, c, Az, t, ct, st, cA, sA;
+
+                    coslam = cos(lp_lon);
+                    cosphi = cos(lp_lat);
+                    sinphi = sin(lp_lat);
+                    switch (this->m_proj_parm.mode) {
+                    case N_POLE:
+                        coslam = - coslam;
+                    case S_POLE:
+                        xy_x = (rho = fabs(this->m_proj_parm.Mp - pj_mlfn(lp_lat, sinphi, cosphi, this->m_proj_parm.en))) *
+                            sin(lp_lon);
+                        xy_y = rho * coslam;
+                        break;
+                    case EQUIT:
+                    case OBLIQ:
+                        if (fabs(lp_lon) < EPS10 && fabs(lp_lat - this->m_par.phi0) < EPS10) {
+                            xy_x = xy_y = 0.;
+                            break;
+                        }
+                        t = atan2(this->m_par.one_es * sinphi + this->m_par.es * this->m_proj_parm.N1 * this->m_proj_parm.sinph0 *
+                            sqrt(1. - this->m_par.es * sinphi * sinphi), cosphi);
+                        ct = cos(t); st = sin(t);
+                        Az = atan2(sin(lp_lon) * ct, this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct);
+                        cA = cos(Az); sA = sin(Az);
+                        s = aasin( fabs(sA) < TOL ?
+                            (this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct) / cA :
+                            sin(lp_lon) * ct / sA );
+                        H = this->m_proj_parm.He * cA;
+                        H2 = H * H;
+                        c = this->m_proj_parm.N1 * s * (1. + s * s * (- H2 * (1. - H2)/6. +
+                            s * ( this->m_proj_parm.G * H * (1. - 2. * H2 * H2) / 8. +
+                            s * ((H2 * (4. - 7. * H2) - 3. * this->m_proj_parm.G * this->m_proj_parm.G * (1. - 7. * H2)) /
+                            120. - s * this->m_proj_parm.G * H / 48.))));
+                        xy_x = c * sA;
+                        xy_y = c * cA;
+                        break;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double c, Az, cosAz, A, B, D, E, F, psi, t;
+
+                    if ((c = boost::math::hypot(xy_x, xy_y)) < EPS10) {
+                        lp_lat = this->m_par.phi0;
+                        lp_lon = 0.;
+                            return;
+                    }
+                    if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
+                        cosAz = cos(Az = atan2(xy_x, xy_y));
+                        t = this->m_proj_parm.cosph0 * cosAz;
+                        B = this->m_par.es * t / this->m_par.one_es;
+                        A = - B * t;
+                        B *= 3. * (1. - A) * this->m_proj_parm.sinph0;
+                        D = c / this->m_proj_parm.N1;
+                        E = D * (1. - D * D * (A * (1. + A) / 6. + B * (1. + 3.*A) * D / 24.));
+                        F = 1. - E * E * (A / 2. + B * E / 6.);
+                        psi = aasin(this->m_proj_parm.sinph0 * cos(E) + t * sin(E));
+                        lp_lon = aasin(sin(Az) * sin(E) / cos(psi));
+                        if ((t = fabs(psi)) < EPS10)
+                            lp_lat = 0.;
+                        else if (fabs(t - HALFPI) < 0.)
+                            lp_lat = HALFPI;
+                        else
+                            lp_lat = atan((1. - this->m_par.es * F * this->m_proj_parm.sinph0 / sin(psi)) * tan(psi) /
+                                this->m_par.one_es);
+                    } else { /* Polar */
+                        lp_lat = pj_inv_mlfn(this->m_proj_parm.mode == N_POLE ? this->m_proj_parm.Mp - c : this->m_proj_parm.Mp + c,
+                            this->m_par.es, this->m_proj_parm.en);
+                        lp_lon = atan2(xy_x, this->m_proj_parm.mode == N_POLE ? -xy_y : xy_y);
+                    }
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_aeqd_guam : public base_t_fi<base_aeqd_guam<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_aeqd m_proj_parm;
+
+                inline base_aeqd_guam(const Parameters& par)
+                    : base_t_fi<base_aeqd_guam<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  cosphi, sinphi, t;
+
+                    cosphi = cos(lp_lat);
+                    sinphi = sin(lp_lat);
+                    t = 1. / sqrt(1. - this->m_par.es * sinphi * sinphi);
+                    xy_x = lp_lon * cosphi * t;
+                    xy_y = pj_mlfn(lp_lat, sinphi, cosphi, this->m_proj_parm.en) - this->m_proj_parm.M1 +
+                        .5 * lp_lon * lp_lon * cosphi * sinphi * t;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double x2, t;
+                    int i;
+
+                    x2 = 0.5 * xy_x * xy_x;
+                    lp_lat = this->m_par.phi0;
+                    for (i = 0; i < 3; ++i) {
+                        t = this->m_par.e * sin(lp_lat);
+                        lp_lat = pj_inv_mlfn(this->m_proj_parm.M1 + xy_y -
+                            x2 * tan(lp_lat) * (t = sqrt(1. - t * t)), this->m_par.es, this->m_proj_parm.en);
+                    }
+                    lp_lon = xy_x * t / cos(lp_lat);
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_aeqd_spheroid : public base_t_fi<base_aeqd_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_aeqd m_proj_parm;
+
+                inline base_aeqd_spheroid(const Parameters& par)
+                    : base_t_fi<base_aeqd_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  coslam, cosphi, sinphi;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        xy_y = cosphi * coslam;
+                        goto oblcon;
+                    case OBLIQ:
+                        xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam;
+                oblcon:
+                        if (fabs(fabs(xy_y) - 1.) < TOL)
+                            if (xy_y < 0.)
+                                throw proj_exception();
+                            else
+                                xy_x = xy_y = 0.;
+                        else {
+                            xy_y = acos(xy_y);
+                            xy_y /= sin(xy_y);
+                            xy_x = xy_y * cosphi * sin(lp_lon);
+                            xy_y *= (this->m_proj_parm.mode == EQUIT) ? sinphi :
+                                   this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam;
+                        }
+                        break;
+                    case N_POLE:
+                        lp_lat = -lp_lat;
+                        coslam = -coslam;
+                    case S_POLE:
+                        if (fabs(lp_lat - HALFPI) < EPS10) throw proj_exception();;
+                        xy_x = (xy_y = (HALFPI + lp_lat)) * sin(lp_lon);
+                        xy_y *= coslam;
+                        break;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double cosc, c_rh, sinc;
+
+                    if ((c_rh = boost::math::hypot(xy_x, xy_y)) > PI) {
+                        if (c_rh - EPS10 > PI) throw proj_exception();;
+                        c_rh = PI;
+                    } else if (c_rh < EPS10) {
+                        lp_lat = this->m_par.phi0;
+                        lp_lon = 0.;
+                            return;
+                    }
+                    if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
+                        sinc = sin(c_rh);
+                        cosc = cos(c_rh);
+                        if (this->m_proj_parm.mode == EQUIT) {
+                            lp_lat = aasin(xy_y * sinc / c_rh);
+                            xy_x *= sinc;
+                            xy_y = cosc * c_rh;
+                        } else {
+                            lp_lat = aasin(cosc * this->m_proj_parm.sinph0 + xy_y * sinc * this->m_proj_parm.cosph0 /
+                                c_rh);
+                            xy_y = (cosc - this->m_proj_parm.sinph0 * sin(lp_lat)) * c_rh;
+                            xy_x *= sinc * this->m_proj_parm.cosph0;
+                        }
+                        lp_lon = xy_y == 0. ? 0. : atan2(xy_x, xy_y);
+                    } else if (this->m_proj_parm.mode == N_POLE) {
+                        lp_lat = HALFPI - c_rh;
+                        lp_lon = atan2(xy_x, -xy_y);
+                    } else {
+                        lp_lat = c_rh - HALFPI;
+                        lp_lon = atan2(xy_x, xy_y);
+                    }
+                }
+            };
+
+            // Azimuthal Equidistant
+            template <typename Parameters>
+            void setup_aeqd(Parameters& par, par_aeqd& proj_parm)
+            {
+                par.phi0 = pj_param(par.params, "rlat_0").f;
+                if (fabs(fabs(par.phi0) - HALFPI) < EPS10) {
+                    proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
+                    proj_parm.sinph0 = par.phi0 < 0. ? -1. : 1.;
+                    proj_parm.cosph0 = 0.;
+                } else if (fabs(par.phi0) < EPS10) {
+                    proj_parm.mode = EQUIT;
+                    proj_parm.sinph0 = 0.;
+                    proj_parm.cosph0 = 1.;
+                } else {
+                    proj_parm.mode = OBLIQ;
+                    proj_parm.sinph0 = sin(par.phi0);
+                    proj_parm.cosph0 = cos(par.phi0);
+                }
+                if (! par.es) {
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                } else {
+                    pj_enfn(par.es, proj_parm.en);
+                    if (pj_param(par.params, "bguam").i) {
+                        proj_parm.M1 = pj_mlfn(par.phi0, proj_parm.sinph0, proj_parm.cosph0, proj_parm.en);
+                // par.inv = e_guam_inv;
+                // par.fwd = e_guam_fwd;
+                    } else {
+                        switch (proj_parm.mode) {
+                        case N_POLE:
+                            proj_parm.Mp = pj_mlfn(HALFPI, 1., 0., proj_parm.en);
+                            break;
+                        case S_POLE:
+                            proj_parm.Mp = pj_mlfn(-HALFPI, -1., 0., proj_parm.en);
+                            break;
+                        case EQUIT:
+                        case OBLIQ:
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                            proj_parm.N1 = 1. / sqrt(1. - par.es * proj_parm.sinph0 * proj_parm.sinph0);
+                            proj_parm.G = proj_parm.sinph0 * (proj_parm.He = par.e / sqrt(par.one_es));
+                            proj_parm.He *= proj_parm.cosph0;
+                            break;
+                        }
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                    }
+                }
+            }
+
+        }} // namespace detail::aeqd
+    #endif // doxygen
+
+    /*!
+        \brief Azimuthal Equidistant projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - lat_0 guam
+        \par Example
+        \image html ex_aeqd.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct aeqd_ellipsoid : public detail::aeqd::base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline aeqd_ellipsoid(const Parameters& par) : detail::aeqd::base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Azimuthal Equidistant projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - lat_0 guam
+        \par Example
+        \image html ex_aeqd.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct aeqd_guam : public detail::aeqd::base_aeqd_guam<Geographic, Cartesian, Parameters>
+    {
+        inline aeqd_guam(const Parameters& par) : detail::aeqd::base_aeqd_guam<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Azimuthal Equidistant projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - lat_0 guam
+        \par Example
+        \image html ex_aeqd.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct aeqd_spheroid : public detail::aeqd::base_aeqd_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline aeqd_spheroid(const Parameters& par) : detail::aeqd::base_aeqd_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class aeqd_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (! par.es)
+                        return new base_v_fi<aeqd_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else if (pj_param(par.params, "bguam").i)
+                        return new base_v_fi<aeqd_guam<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<aeqd_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void aeqd_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("aeqd", new aeqd_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/airy.hpp b/src/boost/geometry/extensions/gis/projections/proj/airy.hpp
new file mode 100644
index 0000000..8bbf199
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/airy.hpp
@@ -0,0 +1,217 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace airy{
+            static const double EPS = 1.e-10;
+            static const int N_POLE = 0;
+            static const int S_POLE = 1;
+            static const int EQUIT = 2;
+            static const int OBLIQ = 3;
+
+            struct par_airy
+            {
+                double    p_halfpi;
+                double    sinph0;
+                double    cosph0;
+                double    Cb;
+                int        mode;
+                int        no_cut;    /* do not cut at hemisphere limit */
+            };
+
+
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_airy_spheroid : public base_t_f<base_airy_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_airy m_proj_parm;
+
+                inline base_airy_spheroid(const Parameters& par)
+                    : base_t_f<base_airy_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz;
+
+                    sinlam = sin(lp_lon);
+                    coslam = cos(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                    case OBLIQ:
+                        sinphi = sin(lp_lat);
+                        cosphi = cos(lp_lat);
+                        cosz = cosphi * coslam;
+                        if (this->m_proj_parm.mode == OBLIQ)
+                            cosz = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosz;
+                        if (!this->m_proj_parm.no_cut && cosz < -EPS)
+                            throw proj_exception();;
+                        if (fabs(s = 1. - cosz) > EPS) {
+                            t = 0.5 * (1. + cosz);
+                            Krho = -log(t)/s - this->m_proj_parm.Cb / t;
+                        } else
+                            Krho = 0.5 - this->m_proj_parm.Cb;
+                        xy_x = Krho * cosphi * sinlam;
+                        if (this->m_proj_parm.mode == OBLIQ)
+                            xy_y = Krho * (this->m_proj_parm.cosph0 * sinphi -
+                                this->m_proj_parm.sinph0 * cosphi * coslam);
+                        else
+                            xy_y = Krho * sinphi;
+                        break;
+                    case S_POLE:
+                    case N_POLE:
+                        lp_lat = fabs(this->m_proj_parm.p_halfpi - lp_lat);
+                        if (!this->m_proj_parm.no_cut && (lp_lat - EPS) > HALFPI)
+                            throw proj_exception();;
+                        if ((lp_lat *= 0.5) > EPS) {
+                            t = tan(lp_lat);
+                            Krho = -2.*(log(cos(lp_lat)) / t + t * this->m_proj_parm.Cb);
+                            xy_x = Krho * sinlam;
+                            xy_y = Krho * coslam;
+                            if (this->m_proj_parm.mode == N_POLE)
+                                xy_y = -xy_y;
+                        } else
+                            xy_x = xy_y = 0.;
+                    }
+                }
+            };
+
+            // Airy
+            template <typename Parameters>
+            void setup_airy(Parameters& par, par_airy& proj_parm)
+            {
+                double beta;
+                proj_parm.no_cut = pj_param(par.params, "bno_cut").i;
+                beta = 0.5 * (HALFPI - pj_param(par.params, "rlat_b").f);
+                if (fabs(beta) < EPS)
+                    proj_parm.Cb = -0.5;
+                else {
+                    proj_parm.Cb = 1./tan(beta);
+                    proj_parm.Cb *= proj_parm.Cb * log(cos(beta));
+                }
+                if (fabs(fabs(par.phi0) - HALFPI) < EPS)
+                    if (par.phi0 < 0.) {
+                        proj_parm.p_halfpi = -HALFPI;
+                        proj_parm.mode = S_POLE;
+                    } else {
+                        proj_parm.p_halfpi =  HALFPI;
+                        proj_parm.mode = N_POLE;
+                    }
+                else {
+                    if (fabs(par.phi0) < EPS)
+                        proj_parm.mode = EQUIT;
+                    else {
+                        proj_parm.mode = OBLIQ;
+                        proj_parm.sinph0 = sin(par.phi0);
+                        proj_parm.cosph0 = cos(par.phi0);
+                    }
+                }
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::airy
+    #endif // doxygen
+
+    /*!
+        \brief Airy projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+         - no_cut lat_b=
+        \par Example
+        \image html ex_airy.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct airy_spheroid : public detail::airy::base_airy_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline airy_spheroid(const Parameters& par) : detail::airy::base_airy_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::airy::setup_airy(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class airy_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<airy_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void airy_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("airy", new airy_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/src/boost/geometry/extensions/gis/projections/proj/aitoff.hpp
new file mode 100644
index 0000000..8e864c3
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/aitoff.hpp
@@ -0,0 +1,210 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace aitoff{
+
+            struct par_aitoff
+            {
+                double    cosphi1;
+                int        mode;
+            };
+
+
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_aitoff_spheroid : public base_t_f<base_aitoff_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_aitoff m_proj_parm;
+
+                inline base_aitoff_spheroid(const Parameters& par)
+                    : base_t_f<base_aitoff_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double c, d;
+
+                    if((d = acos(cos(lp_lat) * cos(c = 0.5 * lp_lon)))) {/* basic Aitoff */
+                        xy_x = 2. * d * cos(lp_lat) * sin(c) * (xy_y = 1. / sin(d));
+                        xy_y *= d * sin(lp_lat);
+                    } else
+                        xy_x = xy_y = 0.;
+                    if (this->m_proj_parm.mode) { /* Winkel Tripel */
+                        xy_x = (xy_x + lp_lon * this->m_proj_parm.cosphi1) * 0.5;
+                        xy_y = (xy_y + lp_lat) * 0.5;
+                    }
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_aitoff& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                // par.inv = 0;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+
+            // Aitoff
+            template <typename Parameters>
+            void setup_aitoff(Parameters& par, par_aitoff& proj_parm)
+            {
+                proj_parm.mode = 0;
+                setup(par, proj_parm);
+            }
+
+            // Winkel Tripel
+            template <typename Parameters>
+            void setup_wintri(Parameters& par, par_aitoff& proj_parm)
+            {
+                proj_parm.mode = 1;
+                if (pj_param(par.params, "tlat_1").i)
+                    {
+                    if ((proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_1").f)) == 0.)
+                        throw proj_exception(-22);
+                    }
+                else /* 50d28' or acos(2/pi) */
+                    proj_parm.cosphi1 = 0.636619772367581343;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::aitoff
+    #endif // doxygen
+
+    /*!
+        \brief Aitoff projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+        \par Example
+        \image html ex_aitoff.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct aitoff_spheroid : public detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline aitoff_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aitoff::setup_aitoff(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Winkel Tripel projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - lat_1
+        \par Example
+        \image html ex_wintri.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wintri_spheroid : public detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wintri_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::aitoff::setup_wintri(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class aitoff_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<aitoff_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wintri_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<wintri_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void aitoff_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("aitoff", new aitoff_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("wintri", new wintri_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/august.hpp b/src/boost/geometry/extensions/gis/projections/proj/august.hpp
new file mode 100644
index 0000000..ae1877b
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/august.hpp
@@ -0,0 +1,141 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace august{
+            static const double M = 1.333333333333333;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_august_spheroid : public base_t_f<base_august_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_august_spheroid(const Parameters& par)
+                    : base_t_f<base_august_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double t, c1, c, x1, x12, y1, y12;
+
+                    t = tan(.5 * lp_lat);
+                    c1 = sqrt(1. - t * t);
+                    c = 1. + c1 * cos(lp_lon *= .5);
+                    x1 = sin(lp_lon) *  c1 / c;
+                    y1 =  t / c;
+                    xy_x = M * x1 * (3. + (x12 = x1 * x1) - 3. * (y12 = y1 *  y1));
+                    xy_y = M * y1 * (3. + 3. * x12 - y12);
+                }
+            };
+
+            // August Epicycloidal
+            template <typename Parameters>
+            void setup_august(Parameters& par)
+            {
+                // par.inv = 0;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::august
+    #endif // doxygen
+
+    /*!
+        \brief August Epicycloidal projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_august.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct august_spheroid : public detail::august::base_august_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline august_spheroid(const Parameters& par) : detail::august::base_august_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::august::setup_august(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class august_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<august_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void august_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("august", new august_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/bacon.hpp b/src/boost/geometry/extensions/gis/projections/proj/bacon.hpp
new file mode 100644
index 0000000..f36d0ec
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/bacon.hpp
@@ -0,0 +1,238 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace bacon{
+            static const double HLFPI2 = 2.46740110027233965467;
+            static const double EPS = 1e-10;
+
+            struct par_bacon
+            {
+                int bacn;
+                int ortl;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_bacon_spheroid : public base_t_f<base_bacon_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_bacon m_proj_parm;
+
+                inline base_bacon_spheroid(const Parameters& par)
+                    : base_t_f<base_bacon_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double ax, f;
+
+                    xy_y = this->m_proj_parm.bacn ? HALFPI * sin(lp_lat) : lp_lat;
+                    if ((ax = fabs(lp_lon)) >= EPS) {
+                        if (this->m_proj_parm.ortl && ax >= HALFPI)
+                            xy_x = sqrt(HLFPI2 - lp_lat * lp_lat + EPS) + ax - HALFPI;
+                        else {
+                            f = 0.5 * (HLFPI2 / ax + ax);
+                            xy_x = ax - f + sqrt(f * f - xy_y * xy_y);
+                        }
+                        if (lp_lon < 0.) xy_x = - xy_x;
+                    } else
+                        xy_x = 0.;
+                }
+            };
+
+            // Apian Globular I
+            template <typename Parameters>
+            void setup_apian(Parameters& par, par_bacon& proj_parm)
+            {
+                proj_parm.bacn = proj_parm.ortl = 0;
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+            // Ortelius Oval
+            template <typename Parameters>
+            void setup_ortel(Parameters& par, par_bacon& proj_parm)
+            {
+                proj_parm.bacn = 0;
+                proj_parm.ortl = 1;
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+            // Bacon Globular
+            template <typename Parameters>
+            void setup_bacon(Parameters& par, par_bacon& proj_parm)
+            {
+                proj_parm.bacn = 1;
+                proj_parm.ortl = 0;
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::bacon
+    #endif // doxygen
+
+    /*!
+        \brief Apian Globular I projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_apian.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct apian_spheroid : public detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline apian_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::bacon::setup_apian(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Ortelius Oval projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_ortel.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline ortel_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::bacon::setup_ortel(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Bacon Globular projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_bacon.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline bacon_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::bacon::setup_bacon(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class apian_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<apian_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class ortel_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<ortel_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class bacon_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<bacon_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void bacon_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("apian", new apian_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("ortel", new ortel_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("bacon", new bacon_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/bipc.hpp b/src/boost/geometry/extensions/gis/projections/proj/bipc.hpp
new file mode 100644
index 0000000..3badf22
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/bipc.hpp
@@ -0,0 +1,253 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace bipc{
+            static const double EPS = 1e-10;
+            static const double EPS10 = 1e-10;
+            static const double ONEEPS = 1.000000001;
+            static const int NITER = 10;
+            static const double lamB = -.34894976726250681539;
+            static const double n = .63055844881274687180;
+            static const double F = 1.89724742567461030582;
+            static const double Azab = .81650043674686363166;
+            static const double Azba = 1.82261843856185925133;
+            static const double T = 1.27246578267089012270;
+            static const double rhoc = 1.20709121521568721927;
+            static const double cAzc = .69691523038678375519;
+            static const double sAzc = .71715351331143607555;
+            static const double C45 = .70710678118654752469;
+            static const double S45 = .70710678118654752410;
+            static const double C20 = .93969262078590838411;
+            static const double S20 = -.34202014332566873287;
+            static const double R110 = 1.91986217719376253360;
+            static const double R104 = 1.81514242207410275904;
+
+            struct par_bipc
+            {
+                int    noskew;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_bipc_spheroid : public base_t_fi<base_bipc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_bipc m_proj_parm;
+
+                inline base_bipc_spheroid(const Parameters& par)
+                    : base_t_fi<base_bipc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double cphi, sphi, tphi, t, al, Az, z, Av, cdlam, sdlam, r;
+                    int tag;
+
+                    cphi = cos(lp_lat);
+                    sphi = sin(lp_lat);
+                    cdlam = cos(sdlam = lamB - lp_lon);
+                    sdlam = sin(sdlam);
+                    if (fabs(fabs(lp_lat) - HALFPI) < EPS10) {
+                        Az = lp_lat < 0. ? PI : 0.;
+                        tphi = HUGE_VAL;
+                    } else {
+                        tphi = sphi / cphi;
+                        Az = atan2(sdlam , C45 * (tphi - cdlam));
+                    }
+                    if( (tag = (Az > Azba)) ) {
+                        cdlam = cos(sdlam = lp_lon + R110);
+                        sdlam = sin(sdlam);
+                        z = S20 * sphi + C20 * cphi * cdlam;
+                        if (fabs(z) > 1.) {
+                            if (fabs(z) > ONEEPS) throw proj_exception();
+                            else z = z < 0. ? -1. : 1.;
+                        } else
+                            z = acos(z);
+                        if (tphi != HUGE_VAL)
+                            Az = atan2(sdlam, (C20 * tphi - S20 * cdlam));
+                        Av = Azab;
+                        xy_y = rhoc;
+                    } else {
+                        z = S45 * (sphi + cphi * cdlam);
+                        if (fabs(z) > 1.) {
+                            if (fabs(z) > ONEEPS) throw proj_exception();
+                            else z = z < 0. ? -1. : 1.;
+                        } else
+                            z = acos(z);
+                        Av = Azba;
+                        xy_y = -rhoc;
+                    }
+                    if (z < 0.) throw proj_exception();;
+                    r = F * (t = pow(tan(.5 * z), n));
+                    if ((al = .5 * (R104 - z)) < 0.) throw proj_exception();;
+                    al = (t + pow(al, n)) / T;
+                    if (fabs(al) > 1.) {
+                        if (fabs(al) > ONEEPS) throw proj_exception();
+                        else al = al < 0. ? -1. : 1.;
+                    } else
+                        al = acos(al);
+                    if (fabs(t = n * (Av - Az)) < al)
+                        r /= cos(al + (tag ? t : -t));
+                    xy_x = r * sin(t);
+                    xy_y += (tag ? -r : r) * cos(t);
+                    if (this->m_proj_parm.noskew) {
+                        t = xy_x;
+                        xy_x = -xy_x * cAzc - xy_y * sAzc;
+                        xy_y = -xy_y * cAzc + t * sAzc;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t, r, rp, rl, al, z, fAz, Az, s, c, Av;
+                    int neg, i;
+
+                    if (this->m_proj_parm.noskew) {
+                        t = xy_x;
+                        xy_x = -xy_x * cAzc + xy_y * sAzc;
+                        xy_y = -xy_y * cAzc - t * sAzc;
+                    }
+                    if( (neg = (xy_x < 0.)) ) {
+                        xy_y = rhoc - xy_y;
+                        s = S20;
+                        c = C20;
+                        Av = Azab;
+                    } else {
+                        xy_y += rhoc;
+                        s = S45;
+                        c = C45;
+                        Av = Azba;
+                    }
+                    rl = rp = r = boost::math::hypot(xy_x, xy_y);
+                    fAz = fabs(Az = atan2(xy_x, xy_y));
+                    for (i = NITER; i ; --i) {
+                        z = 2. * atan(pow(r / F,1 / n));
+                        al = acos((pow(tan(.5 * z), n) +
+                           pow(tan(.5 * (R104 - z)), n)) / T);
+                        if (fAz < al)
+                            r = rp * cos(al + (neg ? Az : -Az));
+                        if (fabs(rl - r) < EPS)
+                            break;
+                        rl = r;
+                    }
+                    if (! i) throw proj_exception();;
+                    Az = Av - Az / n;
+                    lp_lat = asin(s * cos(z) + c * sin(z) * cos(Az));
+                    lp_lon = atan2(sin(Az), c / tan(z) - s * cos(Az));
+                    if (neg)
+                        lp_lon -= R110;
+                    else
+                        lp_lon = lamB - lp_lon;
+                }
+            };
+
+            // Bipolar conic of western hemisphere
+            template <typename Parameters>
+            void setup_bipc(Parameters& par, par_bipc& proj_parm)
+            {
+                proj_parm.noskew = pj_param(par.params, "bns").i;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::bipc
+    #endif // doxygen
+
+    /*!
+        \brief Bipolar conic of western hemisphere projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+        \par Example
+        \image html ex_bipc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct bipc_spheroid : public detail::bipc::base_bipc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline bipc_spheroid(const Parameters& par) : detail::bipc::base_bipc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::bipc::setup_bipc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class bipc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<bipc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void bipc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("bipc", new bipc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/boggs.hpp b/src/boost/geometry/extensions/gis/projections/proj/boggs.hpp
new file mode 100644
index 0000000..e4276e7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/boggs.hpp
@@ -0,0 +1,154 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace boggs{
+            static const int NITER = 20;
+            static const double EPS = 1e-7;
+            static const double ONETOL = 1.000001;
+            static const double FXC = 2.00276;
+            static const double FXC2 = 1.11072;
+            static const double FYC = 0.49931;
+            static const double FYC2 = 1.41421356237309504880;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_boggs_spheroid : public base_t_f<base_boggs_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_boggs_spheroid(const Parameters& par)
+                    : base_t_f<base_boggs_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double theta, th1, c;
+                    int i;
+
+                    theta = lp_lat;
+                    if (fabs(fabs(lp_lat) - HALFPI) < EPS)
+                        xy_x = 0.;
+                    else {
+                        c = sin(theta) * PI;
+                        for (i = NITER; i; --i) {
+                            theta -= th1 = (theta + sin(theta) - c) /
+                                (1. + cos(theta));
+                            if (fabs(th1) < EPS) break;
+                        }
+                        theta *= 0.5;
+                        xy_x = FXC * lp_lon / (1. / cos(lp_lat) + FXC2 / cos(theta));
+                    }
+                    xy_y = FYC * (lp_lat + FYC2 * sin(theta));
+                }
+            };
+
+            // Boggs Eumorphic
+            template <typename Parameters>
+            void setup_boggs(Parameters& par)
+            {
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::boggs
+    #endif // doxygen
+
+    /*!
+        \brief Boggs Eumorphic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - no inverse
+         - Spheroid
+        \par Example
+        \image html ex_boggs.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct boggs_spheroid : public detail::boggs::base_boggs_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline boggs_spheroid(const Parameters& par) : detail::boggs::base_boggs_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::boggs::setup_boggs(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class boggs_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<boggs_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void boggs_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("boggs", new boggs_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/bonne.hpp b/src/boost/geometry/extensions/gis/projections/proj/bonne.hpp
new file mode 100644
index 0000000..853ae13
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/bonne.hpp
@@ -0,0 +1,246 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace bonne{
+            static const double EPS10 = 1e-10;
+
+            struct par_bonne
+            {
+                double phi1;
+                double cphi1;
+                double am1;
+                double m1;
+                double en[EN_SIZE];
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_bonne_ellipsoid : public base_t_fi<base_bonne_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_bonne m_proj_parm;
+
+                inline base_bonne_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_bonne_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double rh, E, c;
+
+                    rh = this->m_proj_parm.am1 + this->m_proj_parm.m1 - pj_mlfn(lp_lat, E = sin(lp_lat), c = cos(lp_lat), this->m_proj_parm.en);
+                    E = c * lp_lon / (rh * sqrt(1. - this->m_par.es * E * E));
+                    xy_x = rh * sin(E);
+                    xy_y = this->m_proj_parm.am1 - rh * cos(E);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double s, rh;
+
+                    rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.am1 - xy_y);
+                    lp_lat = pj_inv_mlfn(this->m_proj_parm.am1 + this->m_proj_parm.m1 - rh, this->m_par.es, this->m_proj_parm.en);
+                    if ((s = fabs(lp_lat)) < HALFPI) {
+                        s = sin(lp_lat);
+                        lp_lon = rh * atan2(xy_x, xy_y) *
+                           sqrt(1. - this->m_par.es * s * s) / cos(lp_lat);
+                    } else if (fabs(s - HALFPI) <= EPS10)
+                        lp_lon = 0.;
+                    else throw proj_exception();;
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_bonne_spheroid : public base_t_fi<base_bonne_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_bonne m_proj_parm;
+
+                inline base_bonne_spheroid(const Parameters& par)
+                    : base_t_fi<base_bonne_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double E, rh;
+
+                    rh = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - lp_lat;
+                    if (fabs(rh) > EPS10) {
+                        xy_x = rh * sin(E = lp_lon * cos(lp_lat) / rh);
+                        xy_y = this->m_proj_parm.cphi1 - rh * cos(E);
+                    } else
+                        xy_x = xy_y = 0.;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double rh;
+
+                    rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.cphi1 - xy_y);
+                    lp_lat = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - rh;
+                    if (fabs(lp_lat) > HALFPI) throw proj_exception();;
+                    if (fabs(fabs(lp_lat) - HALFPI) <= EPS10)
+                        lp_lon = 0.;
+                    else
+                        lp_lon = rh * atan2(xy_x, xy_y) / cos(lp_lat);
+                }
+            };
+
+            // Bonne (Werner lat_1=90)
+            template <typename Parameters>
+            void setup_bonne(Parameters& par, par_bonne& proj_parm)
+            {
+                double c;
+                proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
+                if (fabs(proj_parm.phi1) < EPS10) throw proj_exception(-23);
+                if (par.es) {
+                    pj_enfn(par.es, proj_parm.en);
+                    proj_parm.m1 = pj_mlfn(proj_parm.phi1, proj_parm.am1 = sin(proj_parm.phi1),
+                        c = cos(proj_parm.phi1), proj_parm.en);
+                    proj_parm.am1 = c / (sqrt(1. - par.es * proj_parm.am1 * proj_parm.am1) * proj_parm.am1);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    if (fabs(proj_parm.phi1) + EPS10 >= HALFPI)
+                        proj_parm.cphi1 = 0.;
+                    else
+                        proj_parm.cphi1 = 1. / tan(proj_parm.phi1);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::bonne
+    #endif // doxygen
+
+    /*!
+        \brief Bonne (Werner lat_1=90) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_1=
+        \par Example
+        \image html ex_bonne.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct bonne_ellipsoid : public detail::bonne::base_bonne_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline bonne_ellipsoid(const Parameters& par) : detail::bonne::base_bonne_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::bonne::setup_bonne(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Bonne (Werner lat_1=90) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_1=
+        \par Example
+        \image html ex_bonne.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct bonne_spheroid : public detail::bonne::base_bonne_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline bonne_spheroid(const Parameters& par) : detail::bonne::base_bonne_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::bonne::setup_bonne(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class bonne_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<bonne_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<bonne_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void bonne_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("bonne", new bonne_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/cass.hpp b/src/boost/geometry/extensions/gis/projections/proj/cass.hpp
new file mode 100644
index 0000000..1d1603c
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/cass.hpp
@@ -0,0 +1,465 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_CASS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_CASS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace cass{
+            static const double EPS10 = 1e-10;
+            static const double C1 = .16666666666666666666;
+            static const double C2 = .00833333333333333333;
+            static const double C3 = .04166666666666666666;
+            static const double C4 = .33333333333333333333;
+            static const double C5 = .06666666666666666666;
+
+            struct par_cass
+            {
+                double m0;
+                double n;
+                double t;
+                double a1;
+                double c;
+                double r;
+                double dd;
+                double d2;
+                double a2;
+                double tn;
+                double en[EN_SIZE];
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_cass_ellipsoid : public base_t_fi<base_cass_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                mutable par_cass m_proj_parm;
+
+                inline base_cass_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_cass_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_y = pj_mlfn(lp_lat, this->m_proj_parm.n = sin(lp_lat), this->m_proj_parm.c = cos(lp_lat), this->m_proj_parm.en);
+                    this->m_proj_parm.n = 1./sqrt(1. - this->m_par.es * this->m_proj_parm.n * this->m_proj_parm.n);
+                    this->m_proj_parm.tn = tan(lp_lat); this->m_proj_parm.t = this->m_proj_parm.tn * this->m_proj_parm.tn;
+                    this->m_proj_parm.a1 = lp_lon * this->m_proj_parm.c;
+                    this->m_proj_parm.c *= this->m_par.es * this->m_proj_parm.c / (1 - this->m_par.es);
+                    this->m_proj_parm.a2 = this->m_proj_parm.a1 * this->m_proj_parm.a1;
+                    xy_x = this->m_proj_parm.n * this->m_proj_parm.a1 * (1. - this->m_proj_parm.a2 * this->m_proj_parm.t *
+                        (C1 - (8. - this->m_proj_parm.t + 8. * this->m_proj_parm.c) * this->m_proj_parm.a2 * C2));
+                    xy_y -= this->m_proj_parm.m0 - this->m_proj_parm.n * this->m_proj_parm.tn * this->m_proj_parm.a2 *
+                        (.5 + (5. - this->m_proj_parm.t + 6. * this->m_proj_parm.c) * this->m_proj_parm.a2 * C3);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double ph1;
+
+                    ph1 = pj_inv_mlfn(this->m_proj_parm.m0 + xy_y, this->m_par.es, this->m_proj_parm.en);
+                    this->m_proj_parm.tn = tan(ph1); this->m_proj_parm.t = this->m_proj_parm.tn * this->m_proj_parm.tn;
+                    this->m_proj_parm.n = sin(ph1);
+                    this->m_proj_parm.r = 1. / (1. - this->m_par.es * this->m_proj_parm.n * this->m_proj_parm.n);
+                    this->m_proj_parm.n = sqrt(this->m_proj_parm.r);
+                    this->m_proj_parm.r *= (1. - this->m_par.es) * this->m_proj_parm.n;
+                    this->m_proj_parm.dd = xy_x / this->m_proj_parm.n;
+                    this->m_proj_parm.d2 = this->m_proj_parm.dd * this->m_proj_parm.dd;
+                    lp_lat = ph1 - (this->m_proj_parm.n * this->m_proj_parm.tn / this->m_proj_parm.r) * this->m_proj_parm.d2 *
+                        (.5 - (1. + 3. * this->m_proj_parm.t) * this->m_proj_parm.d2 * C3);
+                    lp_lon = this->m_proj_parm.dd * (1. + this->m_proj_parm.t * this->m_proj_parm.d2 *
+                        (-C4 + (1. + 3. * this->m_proj_parm.t) * this->m_proj_parm.d2 * C5)) / cos(ph1);
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_cass_spheroid : public base_t_fi<base_cass_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                mutable par_cass m_proj_parm;
+
+                inline base_cass_spheroid(const Parameters& par)
+                    : base_t_fi<base_cass_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = asin(cos(lp_lat) * sin(lp_lon));
+                    xy_y = atan2(tan(lp_lat) , cos(lp_lon)) - this->m_par.phi0;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = asin(sin(this->m_proj_parm.dd = xy_y + this->m_par.phi0) * cos(xy_x));
+                    lp_lon = atan2(tan(xy_x), cos(this->m_proj_parm.dd));
+                }
+            };
+
+            // Cassini
+            template <typename Parameters>
+            void setup_cass(Parameters& par, par_cass& proj_parm)
+            {
+                if (par.es) {
+                    pj_enfn(par.es, proj_parm.en);
+                    proj_parm.m0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::cass
+    #endif // doxygen
+
+    /*!
+        \brief Cassini projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_cass.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct cass_ellipsoid : public detail::cass::base_cass_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline cass_ellipsoid(const Parameters& par) : detail::cass::base_cass_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::cass::setup_cass(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Cassini projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_cass.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct cass_spheroid : public detail::cass::base_cass_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline cass_spheroid(const Parameters& par) : detail::cass::base_cass_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::cass::setup_cass(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class cass_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<cass_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<cass_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void cass_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("cass", new cass_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    // Create EPSG specializations
+    // (Proof of Concept, only for some)
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2066, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=11.25217861111111 +lon_0=-60.68600888888889 +x_0=37718.66159325 +y_0=36209.91512952 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.201166195164";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2099, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=25.38236111111111 +lon_0=50.76138888888889 +x_0=100000 +y_0=100000 +ellps=helmert +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2314, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=10.44166666666667 +lon_0=-61.33333333333334 +x_0=86501.46392052001 +y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3068, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=52.41864827777778 +lon_0=13.62720366666667 +x_0=40000 +y_0=10000 +ellps=bessel +datum=potsdam +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3140, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=-18 +lon_0=178 +x_0=109435.392 +y_0=141622.272 +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0 +to_meter=0.201168";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3366, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3377, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=2.121679744444445 +lon_0=103.4279362361111 +x_0=-14810.562 +y_0=8758.32 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3378, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=2.682347636111111 +lon_0=101.9749050416667 +x_0=3673.785 +y_0=-4240.573 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3379, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=3.769388088888889 +lon_0=102.3682989833333 +x_0=-7368.228 +y_0=6485.858 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3380, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=3.68464905 +lon_0=101.3891079138889 +x_0=-34836.161 +y_0=56464.049 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3381, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=4.9762852 +lon_0=103.070275625 +x_0=19594.245 +y_0=3371.895 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3382, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=5.421517541666667 +lon_0=100.3443769638889 +x_0=-23.414 +y_0=62.283 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3383, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=5.964672713888889 +lon_0=100.6363711111111 +x_0=0 +y_0=0 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3384, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=4.859063022222222 +lon_0=100.8154105861111 +x_0=-1.769 +y_0=133454.779 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3385, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=5.972543658333334 +lon_0=102.2952416694444 +x_0=13227.851 +y_0=8739.894 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3407, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<24500, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=1.287646666666667 +lon_0=103.8530022222222 +x_0=30000 +y_0=30000 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<28191, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<28193, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=1126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<30200, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=cass +lat_0=10.44166666666667 +lon_0=-61.33333333333334 +x_0=86501.46392051999 +y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.201166195164";
+        }
+    };
+
+
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_CASS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/cc.hpp b/src/boost/geometry/extensions/gis/projections/proj/cc.hpp
new file mode 100644
index 0000000..0945297
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/cc.hpp
@@ -0,0 +1,145 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_CC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_CC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace cc{
+            static const double EPS10 = 1.e-10;
+
+            struct par_cc
+            {
+                double ap;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_cc_spheroid : public base_t_fi<base_cc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_cc m_proj_parm;
+
+                inline base_cc_spheroid(const Parameters& par)
+                    : base_t_fi<base_cc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception();;
+                    xy_x = lp_lon;
+                    xy_y = tan(lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = atan(xy_y);
+                    lp_lon = xy_x;
+                }
+            };
+
+            // Central Cylindrical
+            template <typename Parameters>
+            void setup_cc(Parameters& par, par_cc& proj_parm)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::cc
+    #endif // doxygen
+
+    /*!
+        \brief Central Cylindrical projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_cc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct cc_spheroid : public detail::cc::base_cc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline cc_spheroid(const Parameters& par) : detail::cc::base_cc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::cc::setup_cc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class cc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<cc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void cc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("cc", new cc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_CC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/cea.hpp b/src/boost/geometry/extensions/gis/projections/proj/cea.hpp
new file mode 100644
index 0000000..cd0b6dc
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/cea.hpp
@@ -0,0 +1,224 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_CEA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_CEA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_auth.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace cea{
+            static const double EPS = 1e-10;
+
+            struct par_cea
+            {
+                double qp;
+                double apa[APA_SIZE];
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_cea_ellipsoid : public base_t_fi<base_cea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_cea m_proj_parm;
+
+                inline base_cea_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_cea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = this->m_par.k0 * lp_lon;
+                    xy_y = .5 * pj_qsfn(sin(lp_lat), this->m_par.e, this->m_par.one_es) / this->m_par.k0;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = pj_authlat(asin( 2. * xy_y * this->m_par.k0 / this->m_proj_parm.qp), this->m_proj_parm.apa);
+                    lp_lon = xy_x / this->m_par.k0;
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_cea_spheroid : public base_t_fi<base_cea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_cea m_proj_parm;
+
+                inline base_cea_spheroid(const Parameters& par)
+                    : base_t_fi<base_cea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = this->m_par.k0 * lp_lon;
+                    xy_y = sin(lp_lat) / this->m_par.k0;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t;
+
+                    if ((t = fabs(xy_y *= this->m_par.k0)) - EPS <= 1.) {
+                        if (t >= 1.)
+                            lp_lat = xy_y < 0. ? -HALFPI : HALFPI;
+                        else
+                            lp_lat = asin(xy_y);
+                        lp_lon = xy_x / this->m_par.k0;
+                    } else throw proj_exception();;
+                }
+            };
+
+            // Equal Area Cylindrical
+            template <typename Parameters>
+            void setup_cea(Parameters& par, par_cea& proj_parm)
+            {
+                double t;
+                if (pj_param(par.params, "tlat_ts").i &&
+                    (par.k0 = cos(t = pj_param(par.params, "rlat_ts").f)) < 0.) throw proj_exception(-24);
+                else
+                    t = 0.;
+                if (par.es) {
+                    t = sin(t);
+                    par.k0 /= sqrt(1. - par.es * t * t);
+                    par.e = sqrt(par.es);
+                    pj_authset(par.es, proj_parm.apa);
+                    proj_parm.qp = pj_qsfn(1., par.e, par.one_es);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::cea
+    #endif // doxygen
+
+    /*!
+        \brief Equal Area Cylindrical projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+         - lat_ts=
+        \par Example
+        \image html ex_cea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct cea_ellipsoid : public detail::cea::base_cea_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline cea_ellipsoid(const Parameters& par) : detail::cea::base_cea_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::cea::setup_cea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Equal Area Cylindrical projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+         - lat_ts=
+        \par Example
+        \image html ex_cea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct cea_spheroid : public detail::cea::base_cea_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline cea_spheroid(const Parameters& par) : detail::cea::base_cea_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::cea::setup_cea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class cea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<cea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<cea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void cea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("cea", new cea_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_CEA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/chamb.hpp b/src/boost/geometry/extensions/gis/projections/proj/chamb.hpp
new file mode 100644
index 0000000..e9f3977
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/chamb.hpp
@@ -0,0 +1,242 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <cstdio>
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/aasincos.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace chamb{
+            static const double THIRD = 0.333333333333333333;
+            static const double TOL = 1e-9;
+
+            struct VECT { double r, Az; };
+            struct CXY { double x, y; }; // x/y for chamb
+
+            struct par_chamb
+            {
+                struct { /* control point data */
+                double phi, lam;
+                double cosphi, sinphi;
+                VECT v;
+                CXY    p;
+                double Az;
+                } c[3];
+                CXY p;
+                double beta_0, beta_1, beta_2;
+            };
+                inline VECT /* distance and azimuth from point 1 to point 2 */
+            vect(double dphi, double c1, double s1, double c2, double s2, double dlam) {
+                VECT v;
+                double cdl, dp, dl;
+
+                cdl = cos(dlam);
+                if (fabs(dphi) > 1. || fabs(dlam) > 1.)
+                    v.r = aacos(s1 * s2 + c1 * c2 * cdl);
+                else { /* more accurate for smaller distances */
+                    dp = sin(.5 * dphi);
+                    dl = sin(.5 * dlam);
+                    v.r = 2. * aasin(sqrt(dp * dp + c1 * c2 * dl * dl));
+                }
+                if (fabs(v.r) > TOL)
+                    v.Az = atan2(c2 * sin(dlam), c1 * s2 - s1 * c2 * cdl);
+                else
+                    v.r = v.Az = 0.;
+                return v;
+            }
+                inline double /* law of cosines */
+            lc(double b,double c,double a) {
+                return aacos(.5 * (b * b + c * c - a * a) / (b * c));
+            }
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_chamb_spheroid : public base_t_f<base_chamb_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_chamb m_proj_parm;
+
+                inline base_chamb_spheroid(const Parameters& par)
+                    : base_t_f<base_chamb_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double sinphi, cosphi, a;
+                    VECT v[3];
+                    int i, j;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    for (i = 0; i < 3; ++i) { /* dist/azimiths from control */
+                        v[i] = vect(lp_lat - this->m_proj_parm.c[i].phi, this->m_proj_parm.c[i].cosphi, this->m_proj_parm.c[i].sinphi,
+                            cosphi, sinphi, lp_lon - this->m_proj_parm.c[i].lam);
+                        if ( ! v[i].r)
+                            break;
+                        v[i].Az = adjlon(v[i].Az - this->m_proj_parm.c[i].v.Az);
+                    }
+                    if (i < 3) /* current point at control point */
+                        { xy_x = this->m_proj_parm.c[i].p.x; xy_y = this->m_proj_parm.c[i].p.y; }
+                    else { /* point mean of intersepts */
+                        { xy_x = this->m_proj_parm.p.x; xy_y = this->m_proj_parm.p.y; }
+                        for (i = 0; i < 3; ++i) {
+                            j = i == 2 ? 0 : i + 1;
+                            a = lc(this->m_proj_parm.c[i].v.r, v[i].r, v[j].r);
+                            if (v[i].Az < 0.)
+                                a = -a;
+                            if (! i) { /* coord comp unique to each arc */
+                                xy_x += v[i].r * cos(a);
+                                xy_y -= v[i].r * sin(a);
+                            } else if (i == 1) {
+                                a = this->m_proj_parm.beta_1 - a;
+                                xy_x -= v[i].r * cos(a);
+                                xy_y -= v[i].r * sin(a);
+                            } else {
+                                a = this->m_proj_parm.beta_2 - a;
+                                xy_x += v[i].r * cos(a);
+                                xy_y += v[i].r * sin(a);
+                            }
+                        }
+                        xy_x *= THIRD; /* mean of arc intercepts */
+                        xy_y *= THIRD;
+                    }
+                }
+            };
+
+            // Chamberlin Trimetric
+            template <typename Parameters>
+            void setup_chamb(Parameters& par, par_chamb& proj_parm)
+            {
+                int i, j;
+                char line[10];
+                for (i = 0;
+             i < 3;
+             ++i) { /* get control point locations */
+                    (void)sprintf(line, "rlat_%d", i+1);
+                    proj_parm.c[i].phi = pj_param(par.params, line).f;
+                    (void)sprintf(line, "rlon_%d", i+1);
+                    proj_parm.c[i].lam = pj_param(par.params, line).f;
+                    proj_parm.c[i].lam = adjlon(proj_parm.c[i].lam - par.lam0);
+                    proj_parm.c[i].cosphi = cos(proj_parm.c[i].phi);
+                    proj_parm.c[i].sinphi = sin(proj_parm.c[i].phi);
+                }
+                for (i = 0;
+             i < 3;
+             ++i) { /* inter ctl pt. distances and azimuths */
+                    j = i == 2 ? 0 : i + 1;
+                    proj_parm.c[i].v = vect(proj_parm.c[j].phi - proj_parm.c[i].phi, proj_parm.c[i].cosphi, proj_parm.c[i].sinphi,
+                        proj_parm.c[j].cosphi, proj_parm.c[j].sinphi, proj_parm.c[j].lam - proj_parm.c[i].lam);
+                    if (! proj_parm.c[i].v.r) throw proj_exception(-25);
+                    /* co-linearity problem ignored for now */
+                }
+                proj_parm.beta_0 = lc(proj_parm.c[0].v.r, proj_parm.c[2].v.r, proj_parm.c[1].v.r);
+                proj_parm.beta_1 = lc(proj_parm.c[0].v.r, proj_parm.c[1].v.r, proj_parm.c[2].v.r);
+                proj_parm.beta_2 = PI - proj_parm.beta_0;
+                proj_parm.p.y = 2. * (proj_parm.c[0].p.y = proj_parm.c[1].p.y = proj_parm.c[2].v.r * sin(proj_parm.beta_0));
+                proj_parm.c[2].p.y = 0.;
+                proj_parm.c[0].p.x = - (proj_parm.c[1].p.x = 0.5 * proj_parm.c[0].v.r);
+                proj_parm.p.x = proj_parm.c[2].p.x = proj_parm.c[0].p.x + proj_parm.c[2].v.r * cos(proj_parm.beta_0);
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::chamb
+    #endif // doxygen
+
+    /*!
+        \brief Chamberlin Trimetric projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+         - lat_1= lon_1= lat_2= lon_2= lat_3= lon_3=
+        \par Example
+        \image html ex_chamb.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct chamb_spheroid : public detail::chamb::base_chamb_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline chamb_spheroid(const Parameters& par) : detail::chamb::base_chamb_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::chamb::setup_chamb(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class chamb_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<chamb_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void chamb_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("chamb", new chamb_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/collg.hpp b/src/boost/geometry/extensions/gis/projections/proj/collg.hpp
new file mode 100644
index 0000000..048e1ec
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/collg.hpp
@@ -0,0 +1,152 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace collg{
+            static const double FXC = 1.12837916709551257390;
+            static const double FYC = 1.77245385090551602729;
+            static const double ONEEPS = 1.0000001;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_collg_spheroid : public base_t_fi<base_collg_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_collg_spheroid(const Parameters& par)
+                    : base_t_fi<base_collg_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if ((xy_y = 1. - sin(lp_lat)) <= 0.)
+                        xy_y = 0.;
+                    else
+                        xy_y = sqrt(xy_y);
+                    xy_x = FXC * lp_lon * xy_y;
+                    xy_y = FYC * (1. - xy_y);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / FYC - 1.;
+                    if (fabs(lp_lat = 1. - lp_lat * lp_lat) < 1.)
+                        lp_lat = asin(lp_lat);
+                    else if (fabs(lp_lat) > ONEEPS) throw proj_exception();
+                    else    lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+                    if ((lp_lon = 1. - sin(lp_lat)) <= 0.)
+                        lp_lon = 0.;
+                    else
+                        lp_lon = xy_x / (FXC * sqrt(lp_lon));
+                }
+            };
+
+            // Collignon
+            template <typename Parameters>
+            void setup_collg(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::collg
+    #endif // doxygen
+
+    /*!
+        \brief Collignon projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_collg.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct collg_spheroid : public detail::collg::base_collg_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline collg_spheroid(const Parameters& par) : detail::collg::base_collg_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::collg::setup_collg(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class collg_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<collg_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void collg_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("collg", new collg_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/crast.hpp b/src/boost/geometry/extensions/gis/projections/proj/crast.hpp
new file mode 100644
index 0000000..360fd46
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/crast.hpp
@@ -0,0 +1,144 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace crast{
+            static const double XM = 0.97720502380583984317;
+            static const double RXM = 1.02332670794648848847;
+            static const double YM = 3.06998012383946546542;
+            static const double RYM = 0.32573500793527994772;
+            static const double THIRD = 0.333333333333333333;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_crast_spheroid : public base_t_fi<base_crast_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_crast_spheroid(const Parameters& par)
+                    : base_t_fi<base_crast_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    lp_lat *= THIRD;
+                    xy_x = XM * lp_lon * (2. * cos(lp_lat + lp_lat) - 1.);
+                    xy_y = YM * sin(lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = 3. * asin(xy_y * RYM);
+                    lp_lon = xy_x * RXM / (2. * cos((lp_lat + lp_lat) * THIRD) - 1);
+                }
+            };
+
+            // Craster Parabolic (Putnins P4)
+            template <typename Parameters>
+            void setup_crast(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::crast
+    #endif // doxygen
+
+    /*!
+        \brief Craster Parabolic (Putnins P4) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_crast.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct crast_spheroid : public detail::crast::base_crast_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline crast_spheroid(const Parameters& par) : detail::crast::base_crast_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::crast::setup_crast(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class crast_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<crast_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void crast_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("crast", new crast_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/denoy.hpp b/src/boost/geometry/extensions/gis/projections/proj/denoy.hpp
new file mode 100644
index 0000000..5d696f8
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/denoy.hpp
@@ -0,0 +1,140 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace denoy{
+            static const double C0 = 0.95;
+            static const double C1 = -.08333333333333333333;
+            static const double C3 = .00166666666666666666;
+            static const double D1 = 0.9;
+            static const double D5 = 0.03;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_denoy_spheroid : public base_t_f<base_denoy_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_denoy_spheroid(const Parameters& par)
+                    : base_t_f<base_denoy_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_y = lp_lat;
+                    xy_x = lp_lon;
+                    lp_lon = fabs(lp_lon);
+                    xy_x *= cos((C0 + lp_lon * (C1 + lp_lon * lp_lon * C3)) *
+                        (lp_lat * (D1 + D5 * lp_lat * lp_lat * lp_lat * lp_lat)));
+                }
+            };
+
+            // Denoyer Semi-Elliptical
+            template <typename Parameters>
+            void setup_denoy(Parameters& par)
+            {
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::denoy
+    #endif // doxygen
+
+    /*!
+        \brief Denoyer Semi-Elliptical projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - no inverse
+         - Spheroid
+        \par Example
+        \image html ex_denoy.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct denoy_spheroid : public detail::denoy::base_denoy_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline denoy_spheroid(const Parameters& par) : detail::denoy::base_denoy_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::denoy::setup_denoy(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class denoy_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<denoy_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void denoy_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("denoy", new denoy_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eck1.hpp b/src/boost/geometry/extensions/gis/projections/proj/eck1.hpp
new file mode 100644
index 0000000..91644ef
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eck1.hpp
@@ -0,0 +1,140 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eck1{
+            static const double FC = .92131773192356127802;
+            static const double RP = .31830988618379067154;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eck1_spheroid : public base_t_fi<base_eck1_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_eck1_spheroid(const Parameters& par)
+                    : base_t_fi<base_eck1_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = FC * lp_lon * (1. - RP * fabs(lp_lat));
+                    xy_y = FC * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / FC;
+                    lp_lon = xy_x / (FC * (1. - RP * fabs(lp_lat)));
+                }
+            };
+
+            // Eckert I
+            template <typename Parameters>
+            void setup_eck1(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::eck1
+    #endif // doxygen
+
+    /*!
+        \brief Eckert I projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_eck1.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eck1_spheroid : public detail::eck1::base_eck1_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eck1_spheroid(const Parameters& par) : detail::eck1::base_eck1_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck1::setup_eck1(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eck1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eck1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eck1_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eck1", new eck1_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eck2.hpp b/src/boost/geometry/extensions/gis/projections/proj/eck2.hpp
new file mode 100644
index 0000000..4070b33
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eck2.hpp
@@ -0,0 +1,151 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eck2{
+            static const double FXC = 0.46065886596178063902;
+            static const double FYC = 1.44720250911653531871;
+            static const double C13 = 0.33333333333333333333;
+            static const double ONEEPS = 1.0000001;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eck2_spheroid : public base_t_fi<base_eck2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_eck2_spheroid(const Parameters& par)
+                    : base_t_fi<base_eck2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = FXC * lp_lon * (xy_y = sqrt(4. - 3. * sin(fabs(lp_lat))));
+                    xy_y = FYC * (2. - xy_y);
+                    if ( lp_lat < 0.) xy_y = -xy_y;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lon = xy_x / (FXC * ( lp_lat = 2. - fabs(xy_y) / FYC) );
+                    lp_lat = (4. - lp_lat * lp_lat) * C13;
+                    if (fabs(lp_lat) >= 1.) {
+                        if (fabs(lp_lat) > ONEEPS)    throw proj_exception();
+                        else
+                            lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+                    } else
+                        lp_lat = asin(lp_lat);
+                    if (xy_y < 0)
+                        lp_lat = -lp_lat;
+                }
+            };
+
+            // Eckert II
+            template <typename Parameters>
+            void setup_eck2(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::eck2
+    #endif // doxygen
+
+    /*!
+        \brief Eckert II projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_eck2.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eck2_spheroid : public detail::eck2::base_eck2_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eck2_spheroid(const Parameters& par) : detail::eck2::base_eck2_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck2::setup_eck2(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eck2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eck2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eck2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eck2", new eck2_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eck3.hpp b/src/boost/geometry/extensions/gis/projections/proj/eck3.hpp
new file mode 100644
index 0000000..697a3e7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eck3.hpp
@@ -0,0 +1,286 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eck3{
+
+            struct par_eck3
+            {
+                double C_x, C_y, A, B;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eck3_spheroid : public base_t_fi<base_eck3_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_eck3 m_proj_parm;
+
+                inline base_eck3_spheroid(const Parameters& par)
+                    : base_t_fi<base_eck3_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_y = this->m_proj_parm.C_y * lp_lat;
+                    xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / this->m_proj_parm.C_y;
+                    lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat)));
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_eck3& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Eckert III
+            template <typename Parameters>
+            void setup_eck3(Parameters& par, par_eck3& proj_parm)
+            {
+                proj_parm.C_x = .42223820031577120149;
+                proj_parm.C_y = .84447640063154240298;
+                proj_parm.A = 1.;
+                proj_parm.B = 0.4052847345693510857755;
+                setup(par, proj_parm);
+            }
+
+            // Putnins P1
+            template <typename Parameters>
+            void setup_putp1(Parameters& par, par_eck3& proj_parm)
+            {
+                proj_parm.C_x = 1.89490;
+                proj_parm.C_y = 0.94745;
+                proj_parm.A = -0.5;
+                proj_parm.B = 0.30396355092701331433;
+                setup(par, proj_parm);
+            }
+
+            // Wagner VI
+            template <typename Parameters>
+            void setup_wag6(Parameters& par, par_eck3& proj_parm)
+            {
+                proj_parm.C_x = proj_parm.C_y = 0.94745;
+                proj_parm.A = 0.;
+                proj_parm.B = 0.30396355092701331433;
+                setup(par, proj_parm);
+            }
+
+            // Kavraisky VII
+            template <typename Parameters>
+            void setup_kav7(Parameters& par, par_eck3& proj_parm)
+            {
+                proj_parm.C_x = 0.2632401569273184856851;
+                proj_parm.C_x = 0.8660254037844;
+                proj_parm.C_y = 1.;
+                proj_parm.A = 0.;
+                proj_parm.B = 0.30396355092701331433;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::eck3
+    #endif // doxygen
+
+    /*!
+        \brief Eckert III projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_eck3.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eck3_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eck3_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck3::setup_eck3(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Putnins P1 projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp1.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp1_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp1_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck3::setup_putp1(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Wagner VI projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_wag6.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag6_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag6_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck3::setup_wag6(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Kavraisky VII projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_kav7.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct kav7_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline kav7_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck3::setup_kav7(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eck3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eck3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag6_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wag6_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class kav7_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<kav7_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eck3_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eck3", new eck3_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("putp1", new putp1_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("wag6", new wag6_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("kav7", new kav7_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eck4.hpp b/src/boost/geometry/extensions/gis/projections/proj/eck4.hpp
new file mode 100644
index 0000000..38c67f1
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eck4.hpp
@@ -0,0 +1,167 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eck4{
+            static const double C_x = .42223820031577120149;
+            static const double C_y = 1.32650042817700232218;
+            static const double RC_y = .75386330736002178205;
+            static const double C_p = 3.57079632679489661922;
+            static const double RC_p = .28004957675577868795;
+            static const double EPS = 1e-7;
+            static const int NITER = 6;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eck4_spheroid : public base_t_fi<base_eck4_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_eck4_spheroid(const Parameters& par)
+                    : base_t_fi<base_eck4_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double p, V, s, c;
+                    int i;
+
+                    p = C_p * sin(lp_lat);
+                    V = lp_lat * lp_lat;
+                    lp_lat *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
+                    for (i = NITER; i ; --i) {
+                        c = cos(lp_lat);
+                        s = sin(lp_lat);
+                        lp_lat -= V = (lp_lat + s * (c + 2.) - p) /
+                            (1. + c * (c + 2.) - s * s);
+                        if (fabs(V) < EPS)
+                            break;
+                    }
+                    if (!i) {
+                        xy_x = C_x * lp_lon;
+                        xy_y = lp_lat < 0. ? -C_y : C_y;
+                    } else {
+                        xy_x = C_x * lp_lon * (1. + cos(lp_lat));
+                        xy_y = C_y * sin(lp_lat);
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double c;
+
+                    lp_lat = aasin(xy_y / C_y);
+                    lp_lon = xy_x / (C_x * (1. + (c = cos(lp_lat))));
+                    lp_lat = aasin((lp_lat + sin(lp_lat) * (c + 2.)) / C_p);
+                }
+            };
+
+            // Eckert IV
+            template <typename Parameters>
+            void setup_eck4(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::eck4
+    #endif // doxygen
+
+    /*!
+        \brief Eckert IV projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_eck4.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eck4_spheroid : public detail::eck4::base_eck4_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eck4_spheroid(const Parameters& par) : detail::eck4::base_eck4_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck4::setup_eck4(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eck4_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eck4_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eck4_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eck4", new eck4_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eck5.hpp b/src/boost/geometry/extensions/gis/projections/proj/eck5.hpp
new file mode 100644
index 0000000..15032dd
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eck5.hpp
@@ -0,0 +1,141 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eck5{
+            static const double XF = 0.44101277172455148219;
+            static const double RXF = 2.26750802723822639137;
+            static const double YF = 0.88202554344910296438;
+            static const double RYF = 1.13375401361911319568;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eck5_spheroid : public base_t_fi<base_eck5_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_eck5_spheroid(const Parameters& par)
+                    : base_t_fi<base_eck5_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = XF * (1. + cos(lp_lat)) * lp_lon;
+                    xy_y = YF * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lon = RXF * xy_x / (1. + cos( lp_lat = RYF * xy_y));
+                }
+            };
+
+            // Eckert V
+            template <typename Parameters>
+            void setup_eck5(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::eck5
+    #endif // doxygen
+
+    /*!
+        \brief Eckert V projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_eck5.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eck5_spheroid : public detail::eck5::base_eck5_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eck5_spheroid(const Parameters& par) : detail::eck5::base_eck5_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eck5::setup_eck5(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eck5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eck5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eck5_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eck5", new eck5_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eqc.hpp b/src/boost/geometry/extensions/gis/projections/proj/eqc.hpp
new file mode 100644
index 0000000..f66f803
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eqc.hpp
@@ -0,0 +1,146 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_EQC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_EQC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eqc{
+
+            struct par_eqc
+            {
+                double rc;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eqc_spheroid : public base_t_fi<base_eqc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_eqc m_proj_parm;
+
+                inline base_eqc_spheroid(const Parameters& par)
+                    : base_t_fi<base_eqc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = this->m_proj_parm.rc * lp_lon;
+                    xy_y = lp_lat - this->m_par.phi0;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lon = xy_x / this->m_proj_parm.rc;
+                    lp_lat = xy_y + this->m_par.phi0;
+                }
+            };
+
+            // Equidistant Cylindrical (Plate Caree)
+            template <typename Parameters>
+            void setup_eqc(Parameters& par, par_eqc& proj_parm)
+            {
+                if ((proj_parm.rc = cos(pj_param(par.params, "rlat_ts").f)) <= 0.) throw proj_exception(-24);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::eqc
+    #endif // doxygen
+
+    /*!
+        \brief Equidistant Cylindrical (Plate Caree) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - lat_ts=[
+         - lat_0=0]
+        \par Example
+        \image html ex_eqc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eqc_spheroid : public detail::eqc::base_eqc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eqc_spheroid(const Parameters& par) : detail::eqc::base_eqc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eqc::setup_eqc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eqc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eqc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eqc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eqc", new eqc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_EQC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/eqdc.hpp b/src/boost/geometry/extensions/gis/projections/proj/eqdc.hpp
new file mode 100644
index 0000000..7b5f681
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/eqdc.hpp
@@ -0,0 +1,212 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace eqdc{
+            static const double EPS10 = 1.e-10;
+
+            struct par_eqdc
+            {
+                double phi1;
+                double phi2;
+                double n;
+                double rho;
+                double rho0;
+                double c;
+                double en[EN_SIZE];
+                int        ellips;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_eqdc_ellipsoid : public base_t_fi<base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                mutable par_eqdc m_proj_parm;
+
+                inline base_eqdc_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    this->m_proj_parm.rho = this->m_proj_parm.c - (this->m_proj_parm.ellips ? pj_mlfn(lp_lat, sin(lp_lat),
+                        cos(lp_lat), this->m_proj_parm.en) : lp_lat);
+                    xy_x = this->m_proj_parm.rho * sin( lp_lon *= this->m_proj_parm.n );
+                    xy_y = this->m_proj_parm.rho0 - this->m_proj_parm.rho * cos(lp_lon);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    if ((this->m_proj_parm.rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) {
+                        if (this->m_proj_parm.n < 0.) {
+                            this->m_proj_parm.rho = -this->m_proj_parm.rho;
+                            xy_x = -xy_x;
+                            xy_y = -xy_y;
+                        }
+                        lp_lat = this->m_proj_parm.c - this->m_proj_parm.rho;
+                        if (this->m_proj_parm.ellips)
+                            lp_lat = pj_inv_mlfn(lp_lat, this->m_par.es, this->m_proj_parm.en);
+                        lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
+                    } else {
+                        lp_lon = 0.;
+                        lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI;
+                    }
+                }
+
+                #ifdef SPECIAL_FACTORS_NOT_CONVERTED
+                inline void fac(Geographic lp, Factors &fac) const
+                {
+                    double sinphi, cosphi;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    this->m_fac.code |= IS_ANAL_HK;
+                    this->m_fac.h = 1.;
+                    this->m_fac.k = this->m_proj_parm.n * (this->m_proj_parm.c - (this->m_proj_parm.ellips ? pj_mlfn(lp_lat, sinphi,
+                        cosphi, this->m_proj_parm.en) : lp_lat)) / pj_msfn(sinphi, cosphi, this->m_par.es);
+                }
+                #endif
+            };
+
+            // Equidistant Conic
+            template <typename Parameters>
+            void setup_eqdc(Parameters& par, par_eqdc& proj_parm)
+            {
+                double cosphi, sinphi;
+                int secant;
+                proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
+                proj_parm.phi2 = pj_param(par.params, "rlat_2").f;
+                if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21);
+                    pj_enfn(par.es, proj_parm.en);
+
+                proj_parm.n = sinphi = sin(proj_parm.phi1);
+                cosphi = cos(proj_parm.phi1);
+                secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10;
+                if( (proj_parm.ellips = (par.es > 0.)) ) {
+                    double ml1, m1;
+                    m1 = pj_msfn(sinphi, cosphi, par.es);
+                    ml1 = pj_mlfn(proj_parm.phi1, sinphi, cosphi, proj_parm.en);
+                    if (secant) { /* secant cone */
+                        sinphi = sin(proj_parm.phi2);
+                        cosphi = cos(proj_parm.phi2);
+                        proj_parm.n = (m1 - pj_msfn(sinphi, cosphi, par.es)) /
+                            (pj_mlfn(proj_parm.phi2, sinphi, cosphi, proj_parm.en) - ml1);
+                    }
+                    proj_parm.c = ml1 + m1 / proj_parm.n;
+                    proj_parm.rho0 = proj_parm.c - pj_mlfn(par.phi0, sin(par.phi0),
+                        cos(par.phi0), proj_parm.en);
+                } else {
+                    if (secant)
+                        proj_parm.n = (cosphi - cos(proj_parm.phi2)) / (proj_parm.phi2 - proj_parm.phi1);
+                    proj_parm.c = proj_parm.phi1 + cos(proj_parm.phi1) / proj_parm.n;
+                    proj_parm.rho0 = proj_parm.c - par.phi0;
+                }
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                // par.spc = fac;
+            }
+
+        }} // namespace detail::eqdc
+    #endif // doxygen
+
+    /*!
+        \brief Equidistant Conic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_1= lat_2=
+        \par Example
+        \image html ex_eqdc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eqdc_ellipsoid : public detail::eqdc::base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline eqdc_ellipsoid(const Parameters& par) : detail::eqdc::base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::eqdc::setup_eqdc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eqdc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eqdc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void eqdc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("eqdc", new eqdc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/fahey.hpp b/src/boost/geometry/extensions/gis/projections/proj/fahey.hpp
new file mode 100644
index 0000000..499a955
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/fahey.hpp
@@ -0,0 +1,140 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace fahey{
+            static const double TOL = 1e-6;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_fahey_spheroid : public base_t_fi<base_fahey_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_fahey_spheroid(const Parameters& par)
+                    : base_t_fi<base_fahey_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_y = 1.819152 * ( xy_x = tan(0.5 * lp_lat) );
+                    xy_x = 0.819152 * lp_lon * asqrt(1 - xy_x * xy_x);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = 2. * atan(xy_y /= 1.819152);
+                    lp_lon = fabs(xy_y = 1. - xy_y * xy_y) < TOL ? 0. :
+                        xy_x / (0.819152 * sqrt(xy_y));
+                }
+            };
+
+            // Fahey
+            template <typename Parameters>
+            void setup_fahey(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::fahey
+    #endif // doxygen
+
+    /*!
+        \brief Fahey projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_fahey.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct fahey_spheroid : public detail::fahey::base_fahey_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline fahey_spheroid(const Parameters& par) : detail::fahey::base_fahey_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::fahey::setup_fahey(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class fahey_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<fahey_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void fahey_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("fahey", new fahey_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp b/src/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp
new file mode 100644
index 0000000..179a373
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp
@@ -0,0 +1,167 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace fouc_s{
+            static const int MAX_ITER = 10;
+            static const double LOOP_TOL = 1e-7;
+
+            struct par_fouc_s
+            {
+                double n, n1;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_fouc_s_spheroid : public base_t_fi<base_fouc_s_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_fouc_s m_proj_parm;
+
+                inline base_fouc_s_spheroid(const Parameters& par)
+                    : base_t_fi<base_fouc_s_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double t;
+
+                    t = cos(lp_lat);
+                    xy_x = lp_lon * t / (this->m_proj_parm.n + this->m_proj_parm.n1 * t);
+                    xy_y = this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double V;
+                    int i;
+
+                    if (this->m_proj_parm.n) {
+                        lp_lat = xy_y;
+                        for (i = MAX_ITER; i ; --i) {
+                            lp_lat -= V = (this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat) - xy_y ) /
+                                (this->m_proj_parm.n + this->m_proj_parm.n1 * cos(lp_lat));
+                            if (fabs(V) < LOOP_TOL)
+                                break;
+                        }
+                        if (!i)
+                            lp_lat = xy_y < 0. ? -HALFPI : HALFPI;
+                    } else
+                        lp_lat = aasin(xy_y);
+                    V = cos(lp_lat);
+                    lp_lon = xy_x * (this->m_proj_parm.n + this->m_proj_parm.n1 * V) / V;
+                }
+            };
+
+            // Foucaut Sinusoidal
+            template <typename Parameters>
+            void setup_fouc_s(Parameters& par, par_fouc_s& proj_parm)
+            {
+                proj_parm.n = pj_param(par.params, "dn").f;
+                if (proj_parm.n < 0. || proj_parm.n > 1.)
+                    throw proj_exception(-99);
+                proj_parm.n1 = 1. - proj_parm.n;
+                par.es = 0;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::fouc_s
+    #endif // doxygen
+
+    /*!
+        \brief Foucaut Sinusoidal projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_fouc_s.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct fouc_s_spheroid : public detail::fouc_s::base_fouc_s_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline fouc_s_spheroid(const Parameters& par) : detail::fouc_s::base_fouc_s_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::fouc_s::setup_fouc_s(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class fouc_s_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<fouc_s_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void fouc_s_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("fouc_s", new fouc_s_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/gall.hpp b/src/boost/geometry/extensions/gis/projections/proj/gall.hpp
new file mode 100644
index 0000000..f6713ab
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/gall.hpp
@@ -0,0 +1,142 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GALL_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GALL_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace gall{
+            static const double YF = 1.70710678118654752440;
+            static const double XF = 0.70710678118654752440;
+            static const double RYF = 0.58578643762690495119;
+            static const double RXF = 1.41421356237309504880;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_gall_spheroid : public base_t_fi<base_gall_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_gall_spheroid(const Parameters& par)
+                    : base_t_fi<base_gall_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = XF * lp_lon;
+                    xy_y = YF * tan(.5 * lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lon = RXF * xy_x;
+                    lp_lat = 2. * atan(xy_y * RYF);
+                }
+            };
+
+            // Gall (Gall Stereographic)
+            template <typename Parameters>
+            void setup_gall(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::gall
+    #endif // doxygen
+
+    /*!
+        \brief Gall (Gall Stereographic) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_gall.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gall_spheroid : public detail::gall::base_gall_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline gall_spheroid(const Parameters& par) : detail::gall::base_gall_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gall::setup_gall(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gall_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<gall_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void gall_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("gall", new gall_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GALL_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/geocent.hpp b/src/boost/geometry/extensions/gis/projections/proj/geocent.hpp
new file mode 100644
index 0000000..56ff6e7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/geocent.hpp
@@ -0,0 +1,143 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace geocent{
+
+
+
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_geocent_other : public base_t_fi<base_geocent_other<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_geocent_other(const Parameters& par)
+                    : base_t_fi<base_geocent_other<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                        xy_x = lp_lon;
+                        xy_y = lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                        lp_lat = xy_y;
+                        lp_lon = xy_x;
+                }
+            };
+
+            // Geocentric
+            template <typename Parameters>
+            void setup_geocent(Parameters& par)
+            {
+                par.is_geocent = 1;
+
+                par.x0 = 0.0;
+                par.y0 = 0.0;
+                // par.inv = inverse;
+                // par.fwd = forward;
+            }
+
+        }} // namespace detail::geocent
+    #endif // doxygen
+
+    /*!
+        \brief Geocentric projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+        \par Example
+        \image html ex_geocent.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct geocent_other : public detail::geocent::base_geocent_other<Geographic, Cartesian, Parameters>
+    {
+        inline geocent_other(const Parameters& par) : detail::geocent::base_geocent_other<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::geocent::setup_geocent(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class geocent_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<geocent_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void geocent_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("geocent", new geocent_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/geos.hpp b/src/boost/geometry/extensions/gis/projections/proj/geos.hpp
new file mode 100644
index 0000000..712c159
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/geos.hpp
@@ -0,0 +1,280 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace geos{
+
+            struct par_geos
+            {
+                double    h;
+                double  radius_p;
+                double  radius_p2;
+                double  radius_p_inv2;
+                double  radius_g;
+                double  radius_g_1;
+                double  C;
+            };
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_geos_ellipsoid : public base_t_fi<base_geos_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_geos m_proj_parm;
+
+                inline base_geos_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_geos_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double r, Vx, Vy, Vz, tmp;
+
+                /* Calculation of geocentric latitude. */
+                    lp_lat = atan (this->m_proj_parm.radius_p2 * tan (lp_lat));
+                /* Calculation of the three components of the vector from satellite to
+                ** position on earth surface (lon,lat).*/
+                    r = (this->m_proj_parm.radius_p) / boost::math::hypot(this->m_proj_parm.radius_p * cos (lp_lat), sin (lp_lat));
+                    Vx = r * cos (lp_lon) * cos (lp_lat);
+                    Vy = r * sin (lp_lon) * cos (lp_lat);
+                    Vz = r * sin (lp_lat);
+                /* Check visibility. */
+                    if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * this->m_proj_parm.radius_p_inv2) < 0.)
+                        throw proj_exception();;
+                /* Calculation based on view angles from satellite. */
+                    tmp = this->m_proj_parm.radius_g - Vx;
+                    xy_x = this->m_proj_parm.radius_g_1 * atan (Vy / tmp);
+                    xy_y = this->m_proj_parm.radius_g_1 * atan (Vz / boost::math::hypot (Vy, tmp));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double Vx, Vy, Vz, a, b, det, k;
+
+                /* Setting three components of vector from satellite to position.*/
+                    Vx = -1.0;
+                    Vy = tan (xy_x / this->m_proj_parm.radius_g_1);
+                    Vz = tan (xy_y / this->m_proj_parm.radius_g_1) * boost::math::hypot(1.0, Vy);
+                /* Calculation of terms in cubic equation and determinant.*/
+                    a = Vz / this->m_proj_parm.radius_p;
+                    a   = Vy * Vy + a * a + Vx * Vx;
+                    b   = 2 * this->m_proj_parm.radius_g * Vx;
+                    if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception();;
+                /* Calculation of three components of vector from satellite to position.*/
+                    k  = (-b - sqrt(det)) / (2. * a);
+                    Vx = this->m_proj_parm.radius_g + k * Vx;
+                    Vy *= k;
+                    Vz *= k;
+                /* Calculation of longitude and latitude.*/
+                    lp_lon  = atan2 (Vy, Vx);
+                    lp_lat = atan (Vz * cos (lp_lon) / Vx);
+                    lp_lat = atan (this->m_proj_parm.radius_p_inv2 * tan (lp_lat));
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_geos_spheroid : public base_t_fi<base_geos_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_geos m_proj_parm;
+
+                inline base_geos_spheroid(const Parameters& par)
+                    : base_t_fi<base_geos_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double Vx, Vy, Vz, tmp;
+
+                /* Calculation of the three components of the vector from satellite to
+                ** position on earth surface (lon,lat).*/
+                    tmp = cos(lp_lat);
+                    Vx = cos (lp_lon) * tmp;
+                    Vy = sin (lp_lon) * tmp;
+                    Vz = sin (lp_lat);
+                /* Check visibility.*/
+                    if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) throw proj_exception();;
+                /* Calculation based on view angles from satellite.*/
+                    tmp = this->m_proj_parm.radius_g - Vx;
+                    xy_x = this->m_proj_parm.radius_g_1 * atan(Vy / tmp);
+                    xy_y = this->m_proj_parm.radius_g_1 * atan(Vz / boost::math::hypot(Vy, tmp));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double Vx, Vy, Vz, a, b, det, k;
+
+                /* Setting three components of vector from satellite to position.*/
+                    Vx = -1.0;
+                    Vy = tan (xy_x / (this->m_proj_parm.radius_g - 1.0));
+                    Vz = tan (xy_y / (this->m_proj_parm.radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
+                /* Calculation of terms in cubic equation and determinant.*/
+                    a   = Vy * Vy + Vz * Vz + Vx * Vx;
+                    b   = 2 * this->m_proj_parm.radius_g * Vx;
+                    if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception();;
+                /* Calculation of three components of vector from satellite to position.*/
+                    k  = (-b - sqrt(det)) / (2 * a);
+                    Vx = this->m_proj_parm.radius_g + k * Vx;
+                    Vy *= k;
+                    Vz *= k;
+                /* Calculation of longitude and latitude.*/
+                    lp_lon = atan2 (Vy, Vx);
+                    lp_lat = atan (Vz * cos (lp_lon) / Vx);
+                }
+            };
+
+            // Geostationary Satellite View
+            template <typename Parameters>
+            void setup_geos(Parameters& par, par_geos& proj_parm)
+            {
+                if ((proj_parm.h = pj_param(par.params, "dh").f) <= 0.) throw proj_exception(-30);
+                if (par.phi0) throw proj_exception(-46);
+                proj_parm.radius_g = 1. + (proj_parm.radius_g_1 = proj_parm.h / par.a);
+                proj_parm.C  = proj_parm.radius_g * proj_parm.radius_g - 1.0;
+                if (par.es) {
+                    proj_parm.radius_p      = sqrt (par.one_es);
+                    proj_parm.radius_p2     = par.one_es;
+                    proj_parm.radius_p_inv2 = par.rone_es;
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    proj_parm.radius_p = proj_parm.radius_p2 = proj_parm.radius_p_inv2 = 1.0;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::geos
+    #endif // doxygen
+
+    /*!
+        \brief Geostationary Satellite View projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - h=
+        \par Example
+        \image html ex_geos.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct geos_ellipsoid : public detail::geos::base_geos_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline geos_ellipsoid(const Parameters& par) : detail::geos::base_geos_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::geos::setup_geos(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Geostationary Satellite View projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - h=
+        \par Example
+        \image html ex_geos.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct geos_spheroid : public detail::geos::base_geos_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline geos_spheroid(const Parameters& par) : detail::geos::base_geos_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::geos::setup_geos(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class geos_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<geos_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<geos_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void geos_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("geos", new geos_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/gins8.hpp b/src/boost/geometry/extensions/gis/projections/proj/gins8.hpp
new file mode 100644
index 0000000..6ab6a22
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/gins8.hpp
@@ -0,0 +1,140 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace gins8{
+            static const double Cl = 0.000952426;
+            static const double Cp = 0.162388;
+            static const double C12 = 0.08333333333333333;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_gins8_spheroid : public base_t_f<base_gins8_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_gins8_spheroid(const Parameters& par)
+                    : base_t_f<base_gins8_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double t = lp_lat * lp_lat;
+
+                    xy_y = lp_lat * (1. + t * C12);
+                    xy_x = lp_lon * (1. - Cp * t);
+                    t = lp_lon * lp_lon;
+                    xy_x *= (0.87 - Cl * t * t);
+                }
+            };
+
+            // Ginsburg VIII (TsNIIGAiK)
+            template <typename Parameters>
+            void setup_gins8(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = 0;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::gins8
+    #endif // doxygen
+
+    /*!
+        \brief Ginsburg VIII (TsNIIGAiK) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_gins8.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gins8_spheroid : public detail::gins8::base_gins8_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline gins8_spheroid(const Parameters& par) : detail::gins8::base_gins8_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gins8::setup_gins8(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gins8_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<gins8_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void gins8_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("gins8", new gins8_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/src/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp
new file mode 100644
index 0000000..fcc037a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp
@@ -0,0 +1,380 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace gn_sinu{
+            static const double EPS10 = 1e-10;
+            static const int MAX_ITER = 8;
+            static const double LOOP_TOL = 1e-7;
+
+            struct par_gn_sinu
+            {
+                double    en[EN_SIZE];
+                double    m, n, C_x, C_y;
+            };
+            /* Ellipsoidal Sinusoidal only */
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_gn_sinu_ellipsoid : public base_t_fi<base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_gn_sinu m_proj_parm;
+
+                inline base_gn_sinu_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double s, c;
+
+                    xy_y = pj_mlfn(lp_lat, s = sin(lp_lat), c = cos(lp_lat), this->m_proj_parm.en);
+                    xy_x = lp_lon * c / sqrt(1. - this->m_par.es * s * s);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double s; boost::ignore_unused_variable_warning(s);
+
+                    if ((s = fabs(lp_lat = pj_inv_mlfn(xy_y, this->m_par.es, this->m_proj_parm.en))) < HALFPI) {
+                        s = sin(lp_lat);
+                        lp_lon = xy_x * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat);
+                    } else if ((s - EPS10) < HALFPI)
+                        lp_lon = 0.;
+                    else throw proj_exception();;
+                            return;
+                }
+                /* General spherical sinusoidals */
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_gn_sinu_spheroid : public base_t_fi<base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_gn_sinu m_proj_parm;
+
+                inline base_gn_sinu_spheroid(const Parameters& par)
+                    : base_t_fi<base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if (!this->m_proj_parm.m)
+                        lp_lat = this->m_proj_parm.n != 1. ? aasin(this->m_proj_parm.n * sin(lp_lat)): lp_lat;
+                    else {
+                        double k, V;
+                        int i;
+
+                        k = this->m_proj_parm.n * sin(lp_lat);
+                        for (i = MAX_ITER; i ; --i) {
+                            lp_lat -= V = (this->m_proj_parm.m * lp_lat + sin(lp_lat) - k) /
+                                (this->m_proj_parm.m + cos(lp_lat));
+                            if (fabs(V) < LOOP_TOL)
+                                break;
+                        }
+                        if (!i)
+                            throw proj_exception();
+                    }
+                    xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.m + cos(lp_lat));
+                    xy_y = this->m_proj_parm.C_y * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double s; boost::ignore_unused_variable_warning(s);
+
+                    xy_y /= this->m_proj_parm.C_y;
+                    lp_lat = this->m_proj_parm.m ? aasin((this->m_proj_parm.m * xy_y + sin(xy_y)) / this->m_proj_parm.n) :
+                        ( this->m_proj_parm.n != 1. ? aasin(sin(xy_y) / this->m_proj_parm.n) : xy_y );
+                    lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.m + cos(xy_y)));
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_gn_sinu& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0;
+                proj_parm.C_x = (proj_parm.C_y = sqrt((proj_parm.m + 1.) / proj_parm.n))/(proj_parm.m + 1.);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // General Sinusoidal Series
+            template <typename Parameters>
+            void setup_gn_sinu(Parameters& par, par_gn_sinu& proj_parm)
+            {
+                if (pj_param(par.params, "tn").i && pj_param(par.params, "tm").i) {
+                    proj_parm.n = pj_param(par.params, "dn").f;
+                    proj_parm.m = pj_param(par.params, "dm").f;
+                } else
+                    throw proj_exception(-99);
+                setup(par, proj_parm);
+            }
+
+            // Sinusoidal (Sanson-Flamsteed)
+            template <typename Parameters>
+            void setup_sinu(Parameters& par, par_gn_sinu& proj_parm)
+            {
+                    pj_enfn(par.es, proj_parm.en);
+
+                if (par.es) {
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    proj_parm.n = 1.;
+                    proj_parm.m = 0.;
+                    setup(par, proj_parm);
+                }
+            }
+
+            // Eckert VI
+            template <typename Parameters>
+            void setup_eck6(Parameters& par, par_gn_sinu& proj_parm)
+            {
+                proj_parm.m = 1.;
+                proj_parm.n = 2.570796326794896619231321691;
+                setup(par, proj_parm);
+            }
+
+            // McBryde-Thomas Flat-Polar Sinusoidal
+            template <typename Parameters>
+            void setup_mbtfps(Parameters& par, par_gn_sinu& proj_parm)
+            {
+                proj_parm.m = 0.5;
+                proj_parm.n = 1.785398163397448309615660845;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::gn_sinu
+    #endif // doxygen
+
+    /*!
+        \brief Sinusoidal (Sanson-Flamsteed) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_sinu.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct sinu_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline sinu_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gn_sinu::setup_sinu(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief General Sinusoidal Series projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - m= n=
+        \par Example
+        \image html ex_gn_sinu.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gn_sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline gn_sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gn_sinu::setup_gn_sinu(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Sinusoidal (Sanson-Flamsteed) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_sinu.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gn_sinu::setup_sinu(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Eckert VI projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_eck6.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct eck6_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline eck6_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gn_sinu::setup_eck6(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief McBryde-Thomas Flat-Polar Sinusoidal projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_mbtfps.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mbtfps_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline mbtfps_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gn_sinu::setup_mbtfps(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gn_sinu_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<gn_sinu_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class sinu_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<sinu_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<sinu_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class eck6_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<eck6_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mbtfps_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mbtfps_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void gn_sinu_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("gn_sinu", new gn_sinu_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("sinu", new sinu_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("eck6", new eck6_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("mbtfps", new mbtfps_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/gnom.hpp b/src/boost/geometry/extensions/gis/projections/proj/gnom.hpp
new file mode 100644
index 0000000..3b8e599
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/gnom.hpp
@@ -0,0 +1,227 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace gnom{
+            static const double EPS10 = 1.e-10;
+            static const int N_POLE = 0;
+            static const int S_POLE = 1;
+            static const int EQUIT = 2;
+            static const int OBLIQ = 3;
+
+            struct par_gnom
+            {
+                double    sinph0;
+                double    cosph0;
+                int        mode;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_gnom_spheroid : public base_t_fi<base_gnom_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_gnom m_proj_parm;
+
+                inline base_gnom_spheroid(const Parameters& par)
+                    : base_t_fi<base_gnom_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  coslam, cosphi, sinphi;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        xy_y = cosphi * coslam;
+                        break;
+                    case OBLIQ:
+                        xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam;
+                        break;
+                    case S_POLE:
+                        xy_y = - sinphi;
+                        break;
+                    case N_POLE:
+                        xy_y = sinphi;
+                        break;
+                    }
+                    if (xy_y <= EPS10) throw proj_exception();;
+                    xy_x = (xy_y = 1. / xy_y) * cosphi * sin(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        xy_y *= sinphi;
+                        break;
+                    case OBLIQ:
+                        xy_y *= this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam;
+                        break;
+                    case N_POLE:
+                        coslam = - coslam;
+                    case S_POLE:
+                        xy_y *= cosphi * coslam;
+                        break;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double  rh, cosz, sinz;
+
+                    rh = boost::math::hypot(xy_x, xy_y);
+                    sinz = sin(lp_lat = atan(rh));
+                    cosz = sqrt(1. - sinz * sinz);
+                    if (fabs(rh) <= EPS10) {
+                        lp_lat = this->m_par.phi0;
+                        lp_lon = 0.;
+                    } else {
+                        switch (this->m_proj_parm.mode) {
+                        case OBLIQ:
+                            lp_lat = cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh;
+                            if (fabs(lp_lat) >= 1.)
+                                lp_lat = lp_lat > 0. ? HALFPI : - HALFPI;
+                            else
+                                lp_lat = asin(lp_lat);
+                            xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh;
+                            xy_x *= sinz * this->m_proj_parm.cosph0;
+                            break;
+                        case EQUIT:
+                            lp_lat = xy_y * sinz / rh;
+                            if (fabs(lp_lat) >= 1.)
+                                lp_lat = lp_lat > 0. ? HALFPI : - HALFPI;
+                            else
+                                lp_lat = asin(lp_lat);
+                            xy_y = cosz * rh;
+                            xy_x *= sinz;
+                            break;
+                        case S_POLE:
+                            lp_lat -= HALFPI;
+                            break;
+                        case N_POLE:
+                            lp_lat = HALFPI - lp_lat;
+                            xy_y = -xy_y;
+                            break;
+                        }
+                        lp_lon = atan2(xy_x, xy_y);
+                    }
+                }
+            };
+
+            // Gnomonic
+            template <typename Parameters>
+            void setup_gnom(Parameters& par, par_gnom& proj_parm)
+            {
+                if (fabs(fabs(par.phi0) - HALFPI) < EPS10)
+                    proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
+                else if (fabs(par.phi0) < EPS10)
+                    proj_parm.mode = EQUIT;
+                else {
+                    proj_parm.mode = OBLIQ;
+                    proj_parm.sinph0 = sin(par.phi0);
+                    proj_parm.cosph0 = cos(par.phi0);
+                }
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::gnom
+    #endif // doxygen
+
+    /*!
+        \brief Gnomonic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+        \par Example
+        \image html ex_gnom.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gnom_spheroid : public detail::gnom::base_gnom_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline gnom_spheroid(const Parameters& par) : detail::gnom::base_gnom_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gnom::setup_gnom(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gnom_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<gnom_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void gnom_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("gnom", new gnom_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/goode.hpp b/src/boost/geometry/extensions/gis/projections/proj/goode.hpp
new file mode 100644
index 0000000..41d4727
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/goode.hpp
@@ -0,0 +1,160 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+#include <boost/geometry/extensions/gis/projections/proj/moll.hpp>
+#include <boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace goode{
+            static const double Y_COR = 0.05280;
+            static const double PHI_LIM = .71093078197902358062;
+
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct par_goode
+            {
+                sinu_ellipsoid<Geographic, Cartesian, Parameters>    sinu;
+                moll_spheroid<Geographic, Cartesian, Parameters>    moll;
+
+                par_goode(const Parameters& par) : sinu(par), moll(par) {}
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_goode_spheroid : public base_t_fi<base_goode_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_goode<Geographic, Cartesian, Parameters> m_proj_parm;
+
+                inline base_goode_spheroid(const Parameters& par)
+                    : base_t_fi<base_goode_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par), m_proj_parm(par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if (fabs(lp_lat) <= PHI_LIM)
+                        this->m_proj_parm.sinu.fwd(lp_lon, lp_lat, xy_x, xy_y);
+                    else {
+                        this->m_proj_parm.moll.fwd(lp_lon, lp_lat, xy_x, xy_y);
+                        xy_y -= lp_lat >= 0.0 ? Y_COR : -Y_COR;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    if (fabs(xy_y) <= PHI_LIM)
+                        this->m_proj_parm.sinu.inv(xy_x, xy_y, lp_lon, lp_lat);
+                    else {
+                        xy_y += xy_y >= 0.0 ? Y_COR : -Y_COR;
+                        this->m_proj_parm.moll.inv(xy_x, xy_y, lp_lon, lp_lat);
+                    }
+                }
+            };
+
+            // Goode Homolosine
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            void setup_goode(Parameters& par, par_goode<Geographic, Cartesian, Parameters>& proj_parm)
+            {
+                par.es = 0.;
+                // par.fwd = s_forward;
+                // par.inv = s_inverse;
+            }
+
+        }} // namespace detail::goode
+    #endif // doxygen
+
+    /*!
+        \brief Goode Homolosine projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_goode.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct goode_spheroid : public detail::goode::base_goode_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline goode_spheroid(const Parameters& par) : detail::goode::base_goode_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::goode::setup_goode(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class goode_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<goode_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void goode_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("goode", new goode_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp b/src/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp
new file mode 100644
index 0000000..ac48e0b
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp
@@ -0,0 +1,176 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace gstmerc{
+
+            struct par_gstmerc
+            {
+                double lamc;
+                double phic;
+                double c;
+                double n1;
+                double n2;
+                double XS;
+                double YS;
+            };
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_gstmerc_spheroid : public base_t_fi<base_gstmerc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_gstmerc m_proj_parm;
+
+                inline base_gstmerc_spheroid(const Parameters& par)
+                    : base_t_fi<base_gstmerc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double L, Ls, sinLs1, Ls1;
+                    L= this->m_proj_parm.n1*lp_lon;
+                    Ls= this->m_proj_parm.c+this->m_proj_parm.n1*log(pj_tsfn(-1.0*lp_lat,-1.0*sin(lp_lat),this->m_par.e));
+                    sinLs1= sin(L)/cosh(Ls);
+                    Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
+                    xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1)*this->m_par.ra;
+                    xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L)))*this->m_par.ra;
+                    /*fprintf(stderr,"fwd:\nL      =%16.13f\nLs     =%16.13f\nLs1    =%16.13f\nLP(%16.13f,%16.13f)=XY(%16.4f,%16.4f)\n",L,Ls,Ls1,lp_lon+this->m_par.lam0,lp_lat,(xy_x*this->m_par.a + this->m_par.x0)*this->m_par.to_meter,(xy_y*this->m_par.a + this->m_par.y0)*this->m_par.to_meter);*/
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double L, LC, sinC;
+                    L= atan(sinh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2)/cos((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2));
+                    sinC= sin((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)/cosh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2);
+                    LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
+                    lp_lon= L/this->m_proj_parm.n1;
+                    lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1),this->m_par.e);
+                    /*fprintf(stderr,"inv:\nL      =%16.13f\nsinC   =%16.13f\nLC     =%16.13f\nXY(%16.4f,%16.4f)=LP(%16.13f,%16.13f)\n",L,sinC,LC,((xy_x/this->m_par.ra)+this->m_par.x0)/this->m_par.to_meter,((xy_y/this->m_par.ra)+this->m_par.y0)/this->m_par.to_meter,lp_lon+this->m_par.lam0,lp_lat);*/
+                }
+            };
+
+            // Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)
+            template <typename Parameters>
+            void setup_gstmerc(Parameters& par, par_gstmerc& proj_parm)
+            {
+                proj_parm.lamc= par.lam0;
+                proj_parm.n1= sqrt(1.0+par.es*pow(cos(par.phi0),4.0)/(1.0-par.es));
+                proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1);
+                proj_parm.c=       log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0))
+                     -proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e));
+                proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0));
+                proj_parm.XS= 0;
+            /* -par.x0 */
+                proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;
+            /* -par.y0 */
+                // par.inv= s_inverse;
+                // par.fwd= s_forward;
+                /*fprintf(stderr,"a  (m) =%16.4f\ne      =%16.13f\nl0(rad)=%16.13f\np0(rad)=%16.13f\nk0     =%16.4f\nX0  (m)=%16.4f\nY0  (m)=%16.4f\n\nlC(rad)=%16.13f\npC(rad)=%16.13f\nc      =%16.13f\nn1     =%16.13f\nn2 (m) =%16.4f\nXS (m) =%16.4f\nYS (m) =%16.4f\n", par.a, par.e, par.lam0, par.phi0, par.k0, par.x0, par.y0, proj_parm.lamc, proj_parm.phic, proj_parm.c, proj_parm.n1, proj_parm.n2, proj_parm.XS +par.x0, proj_parm.YS + par.y0);
+            */
+            }
+
+        }} // namespace detail::gstmerc
+    #endif // doxygen
+
+    /*!
+        \brief Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+         - lat_0= lon_0= k_0=
+        \par Example
+        \image html ex_gstmerc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline gstmerc_spheroid(const Parameters& par) : detail::gstmerc::base_gstmerc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::gstmerc::setup_gstmerc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gstmerc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<gstmerc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void gstmerc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("gstmerc", new gstmerc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/hammer.hpp b/src/boost/geometry/extensions/gis/projections/proj/hammer.hpp
new file mode 100644
index 0000000..70bcc5d
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/hammer.hpp
@@ -0,0 +1,152 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace hammer{
+
+            struct par_hammer
+            {
+                double w;
+                double m, rm;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_hammer_spheroid : public base_t_f<base_hammer_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_hammer m_proj_parm;
+
+                inline base_hammer_spheroid(const Parameters& par)
+                    : base_t_f<base_hammer_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double cosphi, d;
+
+                    d = sqrt(2./(1. + (cosphi = cos(lp_lat)) * cos(lp_lon *= this->m_proj_parm.w)));
+                    xy_x = this->m_proj_parm.m * d * cosphi * sin(lp_lon);
+                    xy_y = this->m_proj_parm.rm * d * sin(lp_lat);
+                }
+            };
+
+            // Hammer & Eckert-Greifendorff
+            template <typename Parameters>
+            void setup_hammer(Parameters& par, par_hammer& proj_parm)
+            {
+                if (pj_param(par.params, "tW").i) {
+                    if ((proj_parm.w = fabs(pj_param(par.params, "dW").f)) <= 0.) throw proj_exception(-27);
+                } else
+                    proj_parm.w = .5;
+                if (pj_param(par.params, "tM").i) {
+                    if ((proj_parm.m = fabs(pj_param(par.params, "dM").f)) <= 0.) throw proj_exception(-27);
+                } else
+                    proj_parm.m = 1.;
+                proj_parm.rm = 1. / proj_parm.m;
+                proj_parm.m /= proj_parm.w;
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::hammer
+    #endif // doxygen
+
+    /*!
+        \brief Hammer & Eckert-Greifendorff projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+         - W= M=
+        \par Example
+        \image html ex_hammer.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct hammer_spheroid : public detail::hammer::base_hammer_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline hammer_spheroid(const Parameters& par) : detail::hammer::base_hammer_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::hammer::setup_hammer(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class hammer_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<hammer_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void hammer_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("hammer", new hammer_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/hatano.hpp b/src/boost/geometry/extensions/gis/projections/proj/hatano.hpp
new file mode 100644
index 0000000..4e16660
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/hatano.hpp
@@ -0,0 +1,173 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace hatano{
+            static const int NITER = 20;
+            static const double EPS = 1e-7;
+            static const double ONETOL = 1.000001;
+            static const double CN = 2.67595;
+            static const double CS = 2.43763;
+            static const double RCN = 0.37369906014686373063;
+            static const double RCS = 0.41023453108141924738;
+            static const double FYCN = 1.75859;
+            static const double FYCS = 1.93052;
+            static const double RYCN = 0.56863737426006061674;
+            static const double RYCS = 0.51799515156538134803;
+            static const double FXC = 0.85;
+            static const double RXC = 1.17647058823529411764;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_hatano_spheroid : public base_t_fi<base_hatano_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_hatano_spheroid(const Parameters& par)
+                    : base_t_fi<base_hatano_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double th1, c;
+                    int i;
+
+                    c = sin(lp_lat) * (lp_lat < 0. ? CS : CN);
+                    for (i = NITER; i; --i) {
+                        lp_lat -= th1 = (lp_lat + sin(lp_lat) - c) / (1. + cos(lp_lat));
+                        if (fabs(th1) < EPS) break;
+                    }
+                    xy_x = FXC * lp_lon * cos(lp_lat *= .5);
+                    xy_y = sin(lp_lat) * (lp_lat < 0. ? FYCS : FYCN);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double th;
+
+                    th = xy_y * ( xy_y < 0. ? RYCS : RYCN);
+                    if (fabs(th) > 1.)
+                        if (fabs(th) > ONETOL)    throw proj_exception();
+                        else            th = th > 0. ? HALFPI : - HALFPI;
+                    else
+                        th = asin(th);
+                    lp_lon = RXC * xy_x / cos(th);
+                    th += th;
+                    lp_lat = (th + sin(th)) * (xy_y < 0. ? RCS : RCN);
+                    if (fabs(lp_lat) > 1.)
+                        if (fabs(lp_lat) > ONETOL)    throw proj_exception();
+                        else            lp_lat = lp_lat > 0. ? HALFPI : - HALFPI;
+                    else
+                        lp_lat = asin(lp_lat);
+                }
+            };
+
+            // Hatano Asymmetrical Equal Area
+            template <typename Parameters>
+            void setup_hatano(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::hatano
+    #endif // doxygen
+
+    /*!
+        \brief Hatano Asymmetrical Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_hatano.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct hatano_spheroid : public detail::hatano::base_hatano_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline hatano_spheroid(const Parameters& par) : detail::hatano::base_hatano_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::hatano::setup_hatano(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class hatano_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<hatano_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void hatano_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("hatano", new hatano_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/imw_p.hpp b/src/boost/geometry/extensions/gis/projections/proj/imw_p.hpp
new file mode 100644
index 0000000..3270fbe
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/imw_p.hpp
@@ -0,0 +1,281 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace imw_p{
+            static const double TOL = 1e-10;
+            static const double EPS = 1e-10;
+
+            struct PXY { double x, y; }; // x/y projection specific
+
+            struct par_imw_p
+            {
+                double    P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2;
+                double    phi_1, phi_2, lam_1;
+                double    en[EN_SIZE];
+                int    mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */
+            };
+            template <typename Parameters>
+                inline int
+            phi12(Parameters& par, par_imw_p& proj_parm, double *del, double *sig) {
+                int err = 0;
+
+                if (!pj_param(par.params, "tlat_1").i ||
+                    !pj_param(par.params, "tlat_2").i) {
+                    err = -41;
+                } else {
+                    proj_parm.phi_1 = pj_param(par.params, "rlat_1").f;
+                    proj_parm.phi_2 = pj_param(par.params, "rlat_2").f;
+                    *del = 0.5 * (proj_parm.phi_2 - proj_parm.phi_1);
+                    *sig = 0.5 * (proj_parm.phi_2 + proj_parm.phi_1);
+                    err = (fabs(*del) < EPS || fabs(*sig) < EPS) ? -42 : 0;
+                }
+                return err;
+            }
+            template <typename Parameters>
+                inline PXY
+            loc_for(double const& lp_lam, double const& lp_phi, const Parameters& par, par_imw_p const& proj_parm, double *yc) {
+                PXY xy;
+
+                if (! lp_phi) {
+                    xy.x = lp_lam;
+                    xy.y = 0.;
+                } else {
+                    double xa, ya, xb, yb, xc, D, B, m, sp, t, R, C;
+
+                    sp = sin(lp_phi);
+                    m = pj_mlfn(lp_phi, sp, cos(lp_phi), proj_parm.en);
+                    xa = proj_parm.Pp + proj_parm.Qp * m;
+                    ya = proj_parm.P + proj_parm.Q * m;
+                    R = 1. / (tan(lp_phi) * sqrt(1. - par.es * sp * sp));
+                    C = sqrt(R * R - xa * xa);
+                    if (lp_phi < 0.) C = - C;
+                    C += ya - R;
+                    if (proj_parm.mode < 0) {
+                        xb = lp_lam;
+                        yb = proj_parm.C2;
+                    } else {
+                        t = lp_lam * proj_parm.sphi_2;
+                        xb = proj_parm.R_2 * sin(t);
+                        yb = proj_parm.C2 + proj_parm.R_2 * (1. - cos(t));
+                    }
+                    if (proj_parm.mode > 0) {
+                        xc = lp_lam;
+                        *yc = 0.;
+                    } else {
+                        t = lp_lam * proj_parm.sphi_1;
+                        xc = proj_parm.R_1 * sin(t);
+                        *yc = proj_parm.R_1 * (1. - cos(t));
+                    }
+                    D = (xb - xc)/(yb - *yc);
+                    B = xc + D * (C + R - *yc);
+                    xy.x = D * sqrt(R * R * (1 + D * D) - B * B);
+                    if (lp_phi > 0)
+                        xy.x = - xy.x;
+                    xy.x = (B + xy.x) / (1. + D * D);
+                    xy.y = sqrt(R * R - xy.x * xy.x);
+                    if (lp_phi > 0)
+                        xy.y = - xy.y;
+                    xy.y += C + R;
+                }
+                return (xy);
+            }
+
+            template <typename Parameters>
+            inline void
+            xy(Parameters& par, par_imw_p& proj_parm, double phi, double *x, double *y, double *sp, double *R) {
+                double F;
+
+                *sp = sin(phi);
+                *R = 1./(tan(phi) * sqrt(1. - par.es * *sp * *sp ));
+                F = proj_parm.lam_1 * *sp;
+                *y = *R * (1 - cos(F));
+                *x = *R * sin(F);
+            }
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_imw_p_ellipsoid : public base_t_fi<base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_imw_p m_proj_parm;
+
+                inline base_imw_p_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double yc = 0;
+                    PXY xy = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc);
+                    xy_x = xy.x; xy_y = xy.y;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    PXY t;
+                    double yc = 0;
+
+                    lp_lat = this->m_proj_parm.phi_2;
+                    lp_lon = xy_x / cos(lp_lat);
+                    do {
+                        t = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc);
+                        lp_lat = ((lp_lat - this->m_proj_parm.phi_1) * (xy_y - yc) / (t.y - yc)) + this->m_proj_parm.phi_1;
+                        lp_lon = lp_lon * xy_x / t.x;
+                    } while (fabs(t.x - xy_x) > TOL || fabs(t.y - xy_y) > TOL);
+                }
+            };
+
+            // International Map of the World Polyconic
+            template <typename Parameters>
+            void setup_imw_p(Parameters& par, par_imw_p& proj_parm)
+            {
+                double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
+                int i;
+                    pj_enfn(par.es, proj_parm.en);
+                if( (i = phi12(par, proj_parm, &del, &sig)) != 0)
+                    throw proj_exception(i);
+                if (proj_parm.phi_2 < proj_parm.phi_1) { /* make sure proj_parm.phi_1 most southerly */
+                    del = proj_parm.phi_1;
+                    proj_parm.phi_1 = proj_parm.phi_2;
+                    proj_parm.phi_2 = del;
+                }
+                if (pj_param(par.params, "tlon_1").i)
+                    proj_parm.lam_1 = pj_param(par.params, "rlon_1").f;
+                else { /* use predefined based upon latitude */
+                    sig = fabs(sig * RAD_TO_DEG);
+                    if (sig <= 60)        sig = 2.;
+                    else if (sig <= 76) sig = 4.;
+                    else                sig = 8.;
+                    proj_parm.lam_1 = sig * DEG_TO_RAD;
+                }
+                proj_parm.mode = 0;
+                if (proj_parm.phi_1) xy(par, proj_parm, proj_parm.phi_1, &x1, &y1, &proj_parm.sphi_1, &proj_parm.R_1);
+                else {
+                    proj_parm.mode = 1;
+                    y1 = 0.;
+                    x1 = proj_parm.lam_1;
+                }
+                if (proj_parm.phi_2) xy(par, proj_parm, proj_parm.phi_2, &x2, &T2, &proj_parm.sphi_2, &proj_parm.R_2);
+                else {
+                    proj_parm.mode = -1;
+                    T2 = 0.;
+                    x2 = proj_parm.lam_1;
+                }
+                m1 = pj_mlfn(proj_parm.phi_1, proj_parm.sphi_1, cos(proj_parm.phi_1), proj_parm.en);
+                m2 = pj_mlfn(proj_parm.phi_2, proj_parm.sphi_2, cos(proj_parm.phi_2), proj_parm.en);
+                t = m2 - m1;
+                s = x2 - x1;
+                y2 = sqrt(t * t - s * s) + y1;
+                proj_parm.C2 = y2 - T2;
+                t = 1. / t;
+                proj_parm.P = (m2 * y1 - m1 * y2) * t;
+                proj_parm.Q = (y2 - y1) * t;
+                proj_parm.Pp = (m2 * x1 - m1 * x2) * t;
+                proj_parm.Qp = (x2 - x1) * t;
+                // par.fwd = e_forward;
+                // par.inv = e_inverse;
+            }
+
+        }} // namespace detail::imw_p
+    #endif // doxygen
+
+    /*!
+        \brief International Map of the World Polyconic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Mod Polyconic
+         - Ellipsoid
+         - lat_1= and lat_2= [lon_1=]
+        \par Example
+        \image html ex_imw_p.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct imw_p_ellipsoid : public detail::imw_p::base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline imw_p_ellipsoid(const Parameters& par) : detail::imw_p::base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::imw_p::setup_imw_p(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class imw_p_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<imw_p_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void imw_p_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("imw_p", new imw_p_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/krovak.hpp b/src/boost/geometry/extensions/gis/projections/proj/krovak.hpp
new file mode 100644
index 0000000..39b4a94
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/krovak.hpp
@@ -0,0 +1,338 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace krovak{
+
+            struct par_krovak
+            {
+                double    C_x;
+            };
+
+
+
+
+
+            /**
+               NOTES: According to EPSG the full Krovak projection method should have
+                      the following parameters.  Within PROJ.4 the azimuth, and pseudo
+                      standard parallel are hardcoded in the algorithm and can't be
+                      altered from outside.  The others all have defaults to match the
+                      common usage with Krovak projection.
+
+              lat_0 = latitude of centre of the projection
+
+              lon_0 = longitude of centre of the projection
+
+              ** = azimuth (true) of the centre line passing through the centre of the projection
+
+              ** = latitude of pseudo standard parallel
+
+              k  = scale factor on the pseudo standard parallel
+
+              x_0 = False Easting of the centre of the projection at the apex of the cone
+
+              y_0 = False Northing of the centre of the projection at the apex of the cone
+
+             **/
+
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_krovak_ellipsoid : public base_t_fi<base_krovak_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_krovak m_proj_parm;
+
+                inline base_krovak_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_krovak_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                /* calculate xy from lat/lon */
+
+
+
+
+                /* Constants, identical to inverse transform function */
+                    double s45, s90, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n;
+                    double gfi, u, fi0, deltav, s, d, eps, ro;
+
+
+                    s45 = 0.785398163397448;    /* 45 DEG */
+                    s90 = 2 * s45;
+                    fi0 = this->m_par.phi0;    /* Latitude of projection centre 49 DEG 30' */
+
+                   /* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must
+                      be set to 1 here.
+                      Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
+                      e2=0.006674372230614;
+                   */
+                    a =  1; /* 6377397.155; */
+                    /* e2 = this->m_par.es;*/       /* 0.006674372230614; */
+                    e2 = 0.006674372230614;
+                    e = sqrt(e2);
+
+                    alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2));
+
+                    uq = 1.04216856380474;      /* DU(2, 59, 42, 42.69689) */
+                    u0 = asin(sin(fi0) / alfa);
+                    g = pow(   (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2.  );
+
+                    k = tan( u0 / 2. + s45) / pow  (tan(fi0 / 2. + s45) , alfa) * g;
+
+                    k1 = this->m_par.k0;
+                    n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2));
+                    s0 = 1.37008346281555;       /* Latitude of pseudo standard parallel 78 DEG 30'00" N */
+                    n = sin(s0);
+                    ro0 = k1 * n0 / tan(s0);
+                    ad = s90 - uq;
+
+                /* Transformation */
+
+                    gfi =pow ( ((1. + e * sin(lp_lat)) /
+                               (1. - e * sin(lp_lat))) , (alfa * e / 2.));
+
+                    u= 2. * (atan(k * pow( tan(lp_lat / 2. + s45), alfa) / gfi)-s45);
+
+                    deltav = - lp_lon * alfa;
+
+                    s = asin(cos(ad) * sin(u) + sin(ad) * cos(u) * cos(deltav));
+                    d = asin(cos(u) * sin(deltav) / cos(s));
+                    eps = n * d;
+                    ro = ro0 * pow(tan(s0 / 2. + s45) , n) / pow(tan(s / 2. + s45) , n)   ;
+
+                   /* x and y are reverted! */
+                    xy_y = ro * cos(eps) / a;
+                    xy_x = ro * sin(eps) / a;
+
+                        if( !pj_param(this->m_par.params, "tczech").i )
+                      {
+                        xy_y *= -1.0;
+                        xy_x *= -1.0;
+                      }
+
+                            return;
+                }
+
+
+
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    /* calculate lat/lon from xy */
+
+                /* Constants, identisch wie in der Umkehrfunktion */
+                    double s45, s90, fi0, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n;
+                    double u, deltav, s, d, eps, ro, fi1, xy0;
+                    int ok;
+
+                    s45 = 0.785398163397448;    /* 45 DEG */
+                    s90 = 2 * s45;
+                    fi0 = this->m_par.phi0;    /* Latitude of projection centre 49 DEG 30' */
+
+
+                   /* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must
+                      be set to 1 here.
+                      Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
+                      e2=0.006674372230614;
+                   */
+                    a = 1; /* 6377397.155; */
+                    /* e2 = this->m_par.es; */      /* 0.006674372230614; */
+                    e2 = 0.006674372230614;
+                    e = sqrt(e2);
+
+                    alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2));
+                    uq = 1.04216856380474;      /* DU(2, 59, 42, 42.69689) */
+                    u0 = asin(sin(fi0) / alfa);
+                    g = pow(   (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2.  );
+
+                    k = tan( u0 / 2. + s45) / pow  (tan(fi0 / 2. + s45) , alfa) * g;
+
+                    k1 = this->m_par.k0;
+                    n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2));
+                    s0 = 1.37008346281555;       /* Latitude of pseudo standard parallel 78 DEG 30'00" N */
+                    n = sin(s0);
+                    ro0 = k1 * n0 / tan(s0);
+                    ad = s90 - uq;
+
+
+                /* Transformation */
+                   /* revert y, x*/
+                    xy0=xy_x;
+                    xy_x=xy_y;
+                    xy_y=xy0;
+
+                        if( !pj_param(this->m_par.params, "tczech").i )
+                      {
+                        xy_x *= -1.0;
+                        xy_y *= -1.0;
+                      }
+
+                    ro = sqrt(xy_x * xy_x + xy_y * xy_y);
+                    eps = atan2(xy_y, xy_x);
+                    d = eps / sin(s0);
+                    s = 2. * (atan(  pow(ro0 / ro, 1. / n) * tan(s0 / 2. + s45)) - s45);
+
+                    u = asin(cos(ad) * sin(s) - sin(ad) * cos(s) * cos(d));
+                    deltav = asin(cos(s) * sin(d) / cos(u));
+
+                    lp_lon = this->m_par.lam0 - deltav / alfa;
+
+                /* ITERATION FOR lp_lat */
+                   fi1 = u;
+
+                   ok = 0;
+                   do
+                   {
+                       lp_lat = 2. * ( atan( pow( k, -1. / alfa)  *
+                                            pow( tan(u / 2. + s45) , 1. / alfa)  *
+                                            pow( (1. + e * sin(fi1)) / (1. - e * sin(fi1)) , e / 2.)
+                                           )  - s45);
+
+                      if (fabs(fi1 - lp_lat) < 0.000000000000001) ok=1;
+                      fi1 = lp_lat;
+
+                   }
+                   while (ok==0);
+
+                   lp_lon -= this->m_par.lam0;
+
+                            return;
+                }
+
+            };
+
+            // Krovak
+            template <typename Parameters>
+            void setup_krovak(Parameters& par, par_krovak& proj_parm)
+            {
+                double ts;
+                /* read some Parameters,
+                 * here Latitude Truescale */
+                ts = pj_param(par.params, "rlat_ts").f;
+                proj_parm.C_x = ts;
+
+                /* we want Bessel as fixed ellipsoid */
+                par.a = 6377397.155;
+                par.e = sqrt(par.es = 0.006674372230614);
+                    /* if latitude of projection center is not set, use 49d30'N */
+                if (!pj_param(par.params, "tlat_0").i)
+                        par.phi0 = 0.863937979737193;
+
+                    /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
+                    /* that will correspond to using longitudes relative to greenwich    */
+                    /* as input and output, instead of lat/long relative to Ferro */
+                if (!pj_param(par.params, "tlon_0").i)
+                        par.lam0 = 0.7417649320975901 - 0.308341501185665;
+                    /* if scale not set default to 0.9999 */
+                if (!pj_param(par.params, "tk").i)
+                        par.k0 = 0.9999;
+                /* always the same */
+                // par.inv = e_inverse;
+
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::krovak
+    #endif // doxygen
+
+    /*!
+        \brief Krovak projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Ellps
+        \par Example
+        \image html ex_krovak.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct krovak_ellipsoid : public detail::krovak::base_krovak_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline krovak_ellipsoid(const Parameters& par) : detail::krovak::base_krovak_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::krovak::setup_krovak(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class krovak_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<krovak_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void krovak_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("krovak", new krovak_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/labrd.hpp b/src/boost/geometry/extensions/gis/projections/proj/labrd.hpp
new file mode 100644
index 0000000..8f180d7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/labrd.hpp
@@ -0,0 +1,231 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace labrd{
+            static const double EPS = 1.e-10;
+
+            struct par_labrd
+            {
+                double    Az, kRg, p0s, A, C, Ca, Cb, Cc, Cd;
+                int        rot;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_labrd_ellipsoid : public base_t_fi<base_labrd_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_labrd m_proj_parm;
+
+                inline base_labrd_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_labrd_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double V1, V2, ps, sinps, cosps, sinps2, cosps2, I1, I2, I3, I4, I5, I6,
+                        x2, y2, t;
+
+                    V1 = this->m_proj_parm.A * log( tan(FORTPI + .5 * lp_lat) );
+                    t = this->m_par.e * sin(lp_lat);
+                    V2 = .5 * this->m_par.e * this->m_proj_parm.A * log ((1. + t)/(1. - t));
+                    ps = 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - FORTPI);
+                    I1 = ps - this->m_proj_parm.p0s;
+                    cosps = cos(ps);    cosps2 = cosps * cosps;
+                    sinps = sin(ps);    sinps2 = sinps * sinps;
+                    I4 = this->m_proj_parm.A * cosps;
+                    I2 = .5 * this->m_proj_parm.A * I4 * sinps;
+                    I3 = I2 * this->m_proj_parm.A * this->m_proj_parm.A * (5. * cosps2 - sinps2) / 12.;
+                    I6 = I4 * this->m_proj_parm.A * this->m_proj_parm.A;
+                    I5 = I6 * (cosps2 - sinps2) / 6.;
+                    I6 *= this->m_proj_parm.A * this->m_proj_parm.A *
+                        (5. * cosps2 * cosps2 + sinps2 * (sinps2 - 18. * cosps2)) / 120.;
+                    t = lp_lon * lp_lon;
+                    xy_x = this->m_proj_parm.kRg * lp_lon * (I4 + t * (I5 + t * I6));
+                    xy_y = this->m_proj_parm.kRg * (I1 + t * (I2 + t * I3));
+                    x2 = xy_x * xy_x;
+                    y2 = xy_y * xy_y;
+                    V1 = 3. * xy_x * y2 - xy_x * x2;
+                    V2 = xy_y * y2 - 3. * x2 * xy_y;
+                    xy_x += this->m_proj_parm.Ca * V1 + this->m_proj_parm.Cb * V2;
+                    xy_y += this->m_proj_parm.Ca * V2 - this->m_proj_parm.Cb * V1;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double x2, y2, V1, V2, V3, V4, t, t2, ps, pe, tpe, s,
+                        I7, I8, I9, I10, I11, d, Re;
+                    int i;
+
+                    x2 = xy_x * xy_x;
+                    y2 = xy_y * xy_y;
+                    V1 = 3. * xy_x * y2 - xy_x * x2;
+                    V2 = xy_y * y2 - 3. * x2 * xy_y;
+                    V3 = xy_x * (5. * y2 * y2 + x2 * (-10. * y2 + x2 ));
+                    V4 = xy_y * (5. * x2 * x2 + y2 * (-10. * x2 + y2 ));
+                    xy_x += - this->m_proj_parm.Ca * V1 - this->m_proj_parm.Cb * V2 + this->m_proj_parm.Cc * V3 + this->m_proj_parm.Cd * V4;
+                    xy_y +=   this->m_proj_parm.Cb * V1 - this->m_proj_parm.Ca * V2 - this->m_proj_parm.Cd * V3 + this->m_proj_parm.Cc * V4;
+                    ps = this->m_proj_parm.p0s + xy_y / this->m_proj_parm.kRg;
+                    pe = ps + this->m_par.phi0 - this->m_proj_parm.p0s;
+                    for ( i = 20; i; --i) {
+                        V1 = this->m_proj_parm.A * log(tan(FORTPI + .5 * pe));
+                        tpe = this->m_par.e * sin(pe);
+                        V2 = .5 * this->m_par.e * this->m_proj_parm.A * log((1. + tpe)/(1. - tpe));
+                        t = ps - 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - FORTPI);
+                        pe += t;
+                        if (fabs(t) < EPS)
+                            break;
+                    }
+                /*
+                    if (!i) {
+                    } else {
+                    }
+                */
+                    t = this->m_par.e * sin(pe);
+                    t = 1. - t * t;
+                    Re = this->m_par.one_es / ( t * sqrt(t) );
+                    t = tan(ps);
+                    t2 = t * t;
+                    s = this->m_proj_parm.kRg * this->m_proj_parm.kRg;
+                    d = Re * this->m_par.k0 * this->m_proj_parm.kRg;
+                    I7 = t / (2. * d);
+                    I8 = t * (5. + 3. * t2) / (24. * d * s);
+                    d = cos(ps) * this->m_proj_parm.kRg * this->m_proj_parm.A;
+                    I9 = 1. / d;
+                    d *= s;
+                    I10 = (1. + 2. * t2) / (6. * d);
+                    I11 = (5. + t2 * (28. + 24. * t2)) / (120. * d * s);
+                    x2 = xy_x * xy_x;
+                    lp_lat = pe + x2 * (-I7 + I8 * x2);
+                    lp_lon = xy_x * (I9 + x2 * (-I10 + x2 * I11));
+                }
+            };
+
+            // Laborde
+            template <typename Parameters>
+            void setup_labrd(Parameters& par, par_labrd& proj_parm)
+            {
+                double Az, sinp, R, N, t;
+                proj_parm.rot    = pj_param(par.params, "bno_rot").i == 0;
+                Az = pj_param(par.params, "razi").f;
+                sinp = sin(par.phi0);
+                t = 1. - par.es * sinp * sinp;
+                N = 1. / sqrt(t);
+                R = par.one_es * N / t;
+                proj_parm.kRg = par.k0 * sqrt( N * R );
+                proj_parm.p0s = atan( sqrt(R / N) * tan(par.phi0) );
+                proj_parm.A = sinp / sin(proj_parm.p0s);
+                t = par.e * sinp;
+                proj_parm.C = .5 * par.e * proj_parm.A * log((1. + t)/(1. - t)) +
+                    - proj_parm.A * log( tan(FORTPI + .5 * par.phi0))
+                    + log( tan(FORTPI + .5 * proj_parm.p0s));
+                t = Az + Az;
+                proj_parm.Ca = (1. - cos(t)) * ( proj_parm.Cb = 1. / (12. * proj_parm.kRg * proj_parm.kRg) );
+                proj_parm.Cb *= sin(t);
+                proj_parm.Cc = 3. * (proj_parm.Ca * proj_parm.Ca - proj_parm.Cb * proj_parm.Cb);
+                proj_parm.Cd = 6. * proj_parm.Ca * proj_parm.Cb;
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::labrd
+    #endif // doxygen
+
+    /*!
+        \brief Laborde projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Special for Madagascar
+        \par Example
+        \image html ex_labrd.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct labrd_ellipsoid : public detail::labrd::base_labrd_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline labrd_ellipsoid(const Parameters& par) : detail::labrd::base_labrd_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::labrd::setup_labrd(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class labrd_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<labrd_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void labrd_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("labrd", new labrd_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/laea.hpp b/src/boost/geometry/extensions/gis/projections/proj/laea.hpp
new file mode 100644
index 0000000..7eb9193
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/laea.hpp
@@ -0,0 +1,391 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_auth.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace laea{
+            static const double EPS10 = 1.e-10;
+            static const int NITER = 20;
+            static const double CONV = 1.e-10;
+            static const int N_POLE = 0;
+            static const int S_POLE = 1;
+            static const int EQUIT = 2;
+            static const int OBLIQ = 3;
+
+            struct par_laea
+            {
+                double    sinb1;
+                double    cosb1;
+                double    xmf;
+                double    ymf;
+                double    mmf;
+                double    qp;
+                double    dd;
+                double    rq;
+                double    apa[APA_SIZE];
+                int        mode;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_laea_ellipsoid : public base_t_fi<base_laea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_laea m_proj_parm;
+
+                inline base_laea_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_laea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0;
+
+                    coslam = cos(lp_lon);
+                    sinlam = sin(lp_lon);
+                    sinphi = sin(lp_lat);
+                    q = pj_qsfn(sinphi, this->m_par.e, this->m_par.one_es);
+                    if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
+                        sinb = q / this->m_proj_parm.qp;
+                        cosb = sqrt(1. - sinb * sinb);
+                    }
+                    switch (this->m_proj_parm.mode) {
+                    case OBLIQ:
+                        b = 1. + this->m_proj_parm.sinb1 * sinb + this->m_proj_parm.cosb1 * cosb * coslam;
+                        break;
+                    case EQUIT:
+                        b = 1. + cosb * coslam;
+                        break;
+                    case N_POLE:
+                        b = HALFPI + lp_lat;
+                        q = this->m_proj_parm.qp - q;
+                        break;
+                    case S_POLE:
+                        b = lp_lat - HALFPI;
+                        q = this->m_proj_parm.qp + q;
+                        break;
+                    }
+                    if (fabs(b) < EPS10) throw proj_exception();;
+                    switch (this->m_proj_parm.mode) {
+                    case OBLIQ:
+                        xy_y = this->m_proj_parm.ymf * ( b = sqrt(2. / b) )
+                           * (this->m_proj_parm.cosb1 * sinb - this->m_proj_parm.sinb1 * cosb * coslam);
+                        goto eqcon;
+                        break;
+                    case EQUIT:
+                        xy_y = (b = sqrt(2. / (1. + cosb * coslam))) * sinb * this->m_proj_parm.ymf;
+                eqcon:
+                        xy_x = this->m_proj_parm.xmf * b * cosb * sinlam;
+                        break;
+                    case N_POLE:
+                    case S_POLE:
+                        if (q >= 0.) {
+                            xy_x = (b = sqrt(q)) * sinlam;
+                            xy_y = coslam * (this->m_proj_parm.mode == S_POLE ? b : -b);
+                        } else
+                            xy_x = xy_y = 0.;
+                        break;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double cCe, sCe, q, rho, ab=0.0;
+
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                    case OBLIQ:
+                        if ((rho = boost::math::hypot(xy_x /= this->m_proj_parm.dd, xy_y *=  this->m_proj_parm.dd)) < EPS10) {
+                            lp_lon = 0.;
+                            lp_lat = this->m_par.phi0;
+                            return;
+                        }
+                        cCe = cos(sCe = 2. * asin(.5 * rho / this->m_proj_parm.rq));
+                        xy_x *= (sCe = sin(sCe));
+                        if (this->m_proj_parm.mode == OBLIQ) {
+                            q = this->m_proj_parm.qp * (ab = cCe * this->m_proj_parm.sinb1 + xy_y * sCe * this->m_proj_parm.cosb1 / rho);
+                            xy_y = rho * this->m_proj_parm.cosb1 * cCe - xy_y * this->m_proj_parm.sinb1 * sCe;
+                        } else {
+                            q = this->m_proj_parm.qp * (ab = xy_y * sCe / rho);
+                            xy_y = rho * cCe;
+                        }
+                        break;
+                    case N_POLE:
+                        xy_y = -xy_y;
+                    case S_POLE:
+                        if (!(q = (xy_x * xy_x + xy_y * xy_y)) ) {
+                            lp_lon = 0.;
+                            lp_lat = this->m_par.phi0;
+                            return;
+                        }
+                        /*
+                        q = this->m_proj_parm.qp - q;
+                        */
+                        ab = 1. - q / this->m_proj_parm.qp;
+                        if (this->m_proj_parm.mode == S_POLE)
+                            ab = - ab;
+                        break;
+                    }
+                    lp_lon = atan2(xy_x, xy_y);
+                    lp_lat = pj_authlat(asin(ab), this->m_proj_parm.apa);
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_laea_spheroid : public base_t_fi<base_laea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_laea m_proj_parm;
+
+                inline base_laea_spheroid(const Parameters& par)
+                    : base_t_fi<base_laea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  coslam, cosphi, sinphi;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        xy_y = 1. + cosphi * coslam;
+                        goto oblcon;
+                    case OBLIQ:
+                        xy_y = 1. + this->m_proj_parm.sinb1 * sinphi + this->m_proj_parm.cosb1 * cosphi * coslam;
+                oblcon:
+                        if (xy_y <= EPS10) throw proj_exception();;
+                        xy_x = (xy_y = sqrt(2. / xy_y)) * cosphi * sin(lp_lon);
+                        xy_y *= this->m_proj_parm.mode == EQUIT ? sinphi :
+                           this->m_proj_parm.cosb1 * sinphi - this->m_proj_parm.sinb1 * cosphi * coslam;
+                        break;
+                    case N_POLE:
+                        coslam = -coslam;
+                    case S_POLE:
+                        if (fabs(lp_lat + this->m_par.phi0) < EPS10) throw proj_exception();;
+                        xy_y = FORTPI - lp_lat * .5;
+                        xy_y = 2. * (this->m_proj_parm.mode == S_POLE ? cos(xy_y) : sin(xy_y));
+                        xy_x = xy_y * sin(lp_lon);
+                        xy_y *= coslam;
+                        break;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double  cosz=0.0, rh, sinz=0.0;
+
+                    rh = boost::math::hypot(xy_x, xy_y);
+                    if ((lp_lat = rh * .5 ) > 1.) throw proj_exception();;
+                    lp_lat = 2. * asin(lp_lat);
+                    if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
+                        sinz = sin(lp_lat);
+                        cosz = cos(lp_lat);
+                    }
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        lp_lat = fabs(rh) <= EPS10 ? 0. : asin(xy_y * sinz / rh);
+                        xy_x *= sinz;
+                        xy_y = cosz * rh;
+                        break;
+                    case OBLIQ:
+                        lp_lat = fabs(rh) <= EPS10 ? this->m_par.phi0 :
+                           asin(cosz * this->m_proj_parm.sinb1 + xy_y * sinz * this->m_proj_parm.cosb1 / rh);
+                        xy_x *= sinz * this->m_proj_parm.cosb1;
+                        xy_y = (cosz - sin(lp_lat) * this->m_proj_parm.sinb1) * rh;
+                        break;
+                    case N_POLE:
+                        xy_y = -xy_y;
+                        lp_lat = HALFPI - lp_lat;
+                        break;
+                    case S_POLE:
+                        lp_lat -= HALFPI;
+                        break;
+                    }
+                    lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == EQUIT || this->m_proj_parm.mode == OBLIQ)) ?
+                        0. : atan2(xy_x, xy_y);
+                }
+            };
+
+            // Lambert Azimuthal Equal Area
+            template <typename Parameters>
+            void setup_laea(Parameters& par, par_laea& proj_parm)
+            {
+                double t;
+                if (fabs((t = fabs(par.phi0)) - HALFPI) < EPS10)
+                    proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
+                else if (fabs(t) < EPS10)
+                    proj_parm.mode = EQUIT;
+                else
+                    proj_parm.mode = OBLIQ;
+                if (par.es) {
+                    double sinphi;
+                    par.e = sqrt(par.es);
+                    proj_parm.qp = pj_qsfn(1., par.e, par.one_es);
+                    proj_parm.mmf = .5 / (1. - par.es);
+                    pj_authset(par.es, proj_parm.apa);
+                    switch (proj_parm.mode) {
+                    case N_POLE:
+                    case S_POLE:
+                        proj_parm.dd = 1.;
+                        break;
+                    case EQUIT:
+                        proj_parm.dd = 1. / (proj_parm.rq = sqrt(.5 * proj_parm.qp));
+                        proj_parm.xmf = 1.;
+                        proj_parm.ymf = .5 * proj_parm.qp;
+                        break;
+                    case OBLIQ:
+                        proj_parm.rq = sqrt(.5 * proj_parm.qp);
+                        sinphi = sin(par.phi0);
+                        proj_parm.sinb1 = pj_qsfn(sinphi, par.e, par.one_es) / proj_parm.qp;
+                        proj_parm.cosb1 = sqrt(1. - proj_parm.sinb1 * proj_parm.sinb1);
+                        proj_parm.dd = cos(par.phi0) / (sqrt(1. - par.es * sinphi * sinphi) *
+                           proj_parm.rq * proj_parm.cosb1);
+                        proj_parm.ymf = (proj_parm.xmf = proj_parm.rq) / proj_parm.dd;
+                        proj_parm.xmf *= proj_parm.dd;
+                        break;
+                    }
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    if (proj_parm.mode == OBLIQ) {
+                        proj_parm.sinb1 = sin(par.phi0);
+                        proj_parm.cosb1 = cos(par.phi0);
+                    }
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::laea
+    #endif // doxygen
+
+    /*!
+        \brief Lambert Azimuthal Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_laea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct laea_ellipsoid : public detail::laea::base_laea_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline laea_ellipsoid(const Parameters& par) : detail::laea::base_laea_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::laea::setup_laea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Lambert Azimuthal Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_laea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct laea_spheroid : public detail::laea::base_laea_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline laea_spheroid(const Parameters& par) : detail::laea::base_laea_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::laea::setup_laea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class laea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<laea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<laea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void laea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("laea", new laea_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/lagrng.hpp b/src/boost/geometry/extensions/gis/projections/proj/lagrng.hpp
new file mode 100644
index 0000000..24749ef
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/lagrng.hpp
@@ -0,0 +1,158 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace lagrng{
+            static const double TOL = 1e-10;
+
+            struct par_lagrng
+            {
+                double    hrw;
+                double    rw;
+                double    a1;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_lagrng_spheroid : public base_t_f<base_lagrng_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_lagrng m_proj_parm;
+
+                inline base_lagrng_spheroid(const Parameters& par)
+                    : base_t_f<base_lagrng_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double v, c;
+
+                    if (fabs(fabs(lp_lat) - HALFPI) < TOL) {
+                        xy_x = 0;
+                        xy_y = lp_lat < 0 ? -2. : 2.;
+                    } else {
+                        lp_lat = sin(lp_lat);
+                        v = this->m_proj_parm.a1 * pow((1. + lp_lat)/(1. - lp_lat), this->m_proj_parm.hrw);
+                        if ((c = 0.5 * (v + 1./v) + cos(lp_lon *= this->m_proj_parm.rw)) < TOL)
+                            throw proj_exception();;
+                        xy_x = 2. * sin(lp_lon) / c;
+                        xy_y = (v - 1./v) / c;
+                    }
+                }
+            };
+
+            // Lagrange
+            template <typename Parameters>
+            void setup_lagrng(Parameters& par, par_lagrng& proj_parm)
+            {
+                double phi1;
+                if ((proj_parm.rw = pj_param(par.params, "dW").f) <= 0) throw proj_exception(-27);
+                proj_parm.hrw = 0.5 * (proj_parm.rw = 1. / proj_parm.rw);
+                phi1 = pj_param(par.params, "rlat_1").f;
+                if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) throw proj_exception(-22);
+                proj_parm.a1 = pow((1. - phi1)/(1. + phi1), proj_parm.hrw);
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::lagrng
+    #endif // doxygen
+
+    /*!
+        \brief Lagrange projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+         - W=
+        \par Example
+        \image html ex_lagrng.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lagrng_spheroid : public detail::lagrng::base_lagrng_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline lagrng_spheroid(const Parameters& par) : detail::lagrng::base_lagrng_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::lagrng::setup_lagrng(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lagrng_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<lagrng_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void lagrng_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("lagrng", new lagrng_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/larr.hpp b/src/boost/geometry/extensions/gis/projections/proj/larr.hpp
new file mode 100644
index 0000000..f851f42
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/larr.hpp
@@ -0,0 +1,134 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LARR_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LARR_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace larr{
+            static const double SIXTH = .16666666666666666;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_larr_spheroid : public base_t_f<base_larr_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_larr_spheroid(const Parameters& par)
+                    : base_t_f<base_larr_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = 0.5 * lp_lon * (1. + sqrt(cos(lp_lat)));
+                    xy_y = lp_lat / (cos(0.5 * lp_lat) * cos(SIXTH * lp_lon));
+                }
+            };
+
+            // Larrivee
+            template <typename Parameters>
+            void setup_larr(Parameters& par)
+            {
+                // par.fwd = s_forward;
+                // par.inv = 0;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::larr
+    #endif // doxygen
+
+    /*!
+        \brief Larrivee projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_larr.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct larr_spheroid : public detail::larr::base_larr_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline larr_spheroid(const Parameters& par) : detail::larr::base_larr_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::larr::setup_larr(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class larr_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<larr_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void larr_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("larr", new larr_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LARR_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/lask.hpp b/src/boost/geometry/extensions/gis/projections/proj/lask.hpp
new file mode 100644
index 0000000..e3c8bf0
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/lask.hpp
@@ -0,0 +1,148 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LASK_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LASK_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace lask{
+            static const double a10 = 0.975534;
+            static const double a12 = -0.119161;
+            static const double a32 = -0.0143059;
+            static const double a14 = -0.0547009;
+            static const double b01 = 1.00384;
+            static const double b21 = 0.0802894;
+            static const double b03 = 0.0998909;
+            static const double b41 = 0.000199025;
+            static const double b23 = -0.0285500;
+            static const double b05 = -0.0491032;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_lask_spheroid : public base_t_f<base_lask_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_lask_spheroid(const Parameters& par)
+                    : base_t_f<base_lask_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double l2, p2;
+
+                    l2 = lp_lon * lp_lon;
+                    p2 = lp_lat * lp_lat;
+                    xy_x = lp_lon * (a10 + p2 * (a12 + l2 * a32 + p2 * a14));
+                    xy_y = lp_lat * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) +
+                        p2 * (b03 + p2 * b05));
+                }
+            };
+
+            // Laskowski
+            template <typename Parameters>
+            void setup_lask(Parameters& par)
+            {
+                // par.fwd = s_forward;
+                // par.inv = 0;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::lask
+    #endif // doxygen
+
+    /*!
+        \brief Laskowski projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_lask.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lask_spheroid : public detail::lask::base_lask_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline lask_spheroid(const Parameters& par) : detail::lask::base_lask_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::lask::setup_lask(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lask_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<lask_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void lask_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("lask", new lask_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LASK_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/latlong.hpp b/src/boost/geometry/extensions/gis/projections/proj/latlong.hpp
new file mode 100644
index 0000000..6f39a5d
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/latlong.hpp
@@ -0,0 +1,282 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace latlong{
+
+
+            /* very loosely based upon DMA code by Bradford W. Drew */
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_latlong_other : public base_t_fi<base_latlong_other<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_latlong_other(const Parameters& par)
+                    : base_t_fi<base_latlong_other<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+
+                        xy_x = lp_lon / this->m_par.a;
+                        xy_y = lp_lat / this->m_par.a;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+
+                        lp_lat = xy_y * this->m_par.a;
+                        lp_lon = xy_x * this->m_par.a;
+                }
+            };
+
+            // Lat/long (Geodetic)
+            template <typename Parameters>
+            void setup_lonlat(Parameters& par)
+            {
+                    par.is_latlong = 1;
+                    par.x0 = 0.0;
+                    par.y0 = 0.0;
+                // par.inv = inverse;
+                // par.fwd = forward;
+            }
+
+            // Lat/long (Geodetic alias)
+            template <typename Parameters>
+            void setup_latlon(Parameters& par)
+            {
+                    par.is_latlong = 1;
+                    par.x0 = 0.0;
+                    par.y0 = 0.0;
+                // par.inv = inverse;
+                // par.fwd = forward;
+            }
+
+            // Lat/long (Geodetic alias)
+            template <typename Parameters>
+            void setup_latlong(Parameters& par)
+            {
+                    par.is_latlong = 1;
+                    par.x0 = 0.0;
+                    par.y0 = 0.0;
+                // par.inv = inverse;
+                // par.fwd = forward;
+            }
+
+            // Lat/long (Geodetic alias)
+            template <typename Parameters>
+            void setup_longlat(Parameters& par)
+            {
+                    par.is_latlong = 1;
+                    par.x0 = 0.0;
+                    par.y0 = 0.0;
+                // par.inv = inverse;
+                // par.fwd = forward;
+            }
+
+        }} // namespace detail::latlong
+    #endif // doxygen
+
+    /*!
+        \brief Lat/long (Geodetic) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+        \par Example
+        \image html ex_lonlat.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lonlat_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
+    {
+        inline lonlat_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::latlong::setup_lonlat(this->m_par);
+        }
+    };
+
+    /*!
+        \brief Lat/long (Geodetic alias) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+        \par Example
+        \image html ex_latlon.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct latlon_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
+    {
+        inline latlon_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::latlong::setup_latlon(this->m_par);
+        }
+    };
+
+    /*!
+        \brief Lat/long (Geodetic alias) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+        \par Example
+        \image html ex_latlong.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct latlong_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
+    {
+        inline latlong_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::latlong::setup_latlong(this->m_par);
+        }
+    };
+
+    /*!
+        \brief Lat/long (Geodetic alias) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+        \par Example
+        \image html ex_longlat.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct longlat_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
+    {
+        inline longlat_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::latlong::setup_longlat(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lonlat_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<lonlat_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class latlon_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<latlon_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class latlong_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<latlong_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class longlat_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<longlat_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void latlong_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("lonlat", new lonlat_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("latlon", new latlon_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("latlong", new latlong_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("longlat", new longlat_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    // Create EPSG specializations
+    // (Proof of Concept, only for some)
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<4326, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef longlat_other<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=longlat +ellps=WGS84 +datum=WGS84";
+        }
+    };
+
+
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/lcc.hpp b/src/boost/geometry/extensions/gis/projections/proj/lcc.hpp
new file mode 100644
index 0000000..395d46a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/lcc.hpp
@@ -0,0 +1,249 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LCC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LCC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
+
+#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace lcc{
+            static const double EPS10 = 1.e-10;
+
+            struct par_lcc
+            {
+                double    phi1;
+                double    phi2;
+                double    n;
+                double    rho0;
+                double    c;
+                int        ellips;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_lcc_ellipsoid : public base_t_fi<base_lcc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                mutable par_lcc m_proj_parm;
+
+                inline base_lcc_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_lcc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                        double rho;
+                    if (fabs(fabs(lp_lat) - HALFPI) < EPS10) {
+                        if ((lp_lat * this->m_proj_parm.n) <= 0.) throw proj_exception();;
+                        rho = 0.;
+                        }
+                    else
+                        rho = this->m_proj_parm.c * (this->m_proj_parm.ellips ? pow(pj_tsfn(lp_lat, sin(lp_lat),
+                            this->m_par.e), this->m_proj_parm.n) : pow(tan(FORTPI + .5 * lp_lat), -this->m_proj_parm.n));
+                    xy_x = this->m_par.k0 * (rho * sin( lp_lon *= this->m_proj_parm.n ) );
+                    xy_y = this->m_par.k0 * (this->m_proj_parm.rho0 - rho * cos(lp_lon) );
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                        double rho;
+                    xy_x /= this->m_par.k0;
+                    xy_y /= this->m_par.k0;
+                    if( (rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0) {
+                        if (this->m_proj_parm.n < 0.) {
+                            rho = -rho;
+                            xy_x = -xy_x;
+                            xy_y = -xy_y;
+                        }
+                        if (this->m_proj_parm.ellips) {
+                            if ((lp_lat = pj_phi2(pow(rho / this->m_proj_parm.c, 1./this->m_proj_parm.n), this->m_par.e))
+                                == HUGE_VAL)
+                                throw proj_exception();;
+                        } else
+                            lp_lat = 2. * atan(pow(this->m_proj_parm.c / rho, 1./this->m_proj_parm.n)) - HALFPI;
+                        lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
+                    } else {
+                        lp_lon = 0.;
+                        lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI;
+                    }
+                }
+
+                #ifdef SPECIAL_FACTORS_NOT_CONVERTED
+                inline void fac(Geographic lp, Factors &fac) const
+                {
+                        double rho;
+                    if (fabs(fabs(lp_lat) - HALFPI) < EPS10) {
+                        if ((lp_lat * this->m_proj_parm.n) <= 0.) return;
+                        rho = 0.;
+                    } else
+                        rho = this->m_proj_parm.c * (this->m_proj_parm.ellips ? pow(pj_tsfn(lp_lat, sin(lp_lat),
+                            this->m_par.e), this->m_proj_parm.n) : pow(tan(FORTPI + .5 * lp_lat), -this->m_proj_parm.n));
+                    this->m_fac.code |= IS_ANAL_HK + IS_ANAL_CONV;
+                    this->m_fac.k = this->m_fac.h = this->m_par.k0 * this->m_proj_parm.n * rho /
+                        pj_msfn(sin(lp_lat), cos(lp_lat), this->m_par.es);
+                    this->m_fac.conv = - this->m_proj_parm.n * lp_lon;
+                }
+                #endif
+            };
+
+            // Lambert Conformal Conic
+            template <typename Parameters>
+            void setup_lcc(Parameters& par, par_lcc& proj_parm)
+            {
+                double cosphi, sinphi;
+                int secant;
+                proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
+                if (pj_param(par.params, "tlat_2").i)
+                    proj_parm.phi2 = pj_param(par.params, "rlat_2").f;
+                else {
+                    proj_parm.phi2 = proj_parm.phi1;
+                    if (!pj_param(par.params, "tlat_0").i)
+                        par.phi0 = proj_parm.phi1;
+                }
+                if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21);
+                proj_parm.n = sinphi = sin(proj_parm.phi1);
+                cosphi = cos(proj_parm.phi1);
+                secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10;
+                if( (proj_parm.ellips = (par.es != 0.)) ) {
+                    double ml1, m1;
+                    par.e = sqrt(par.es);
+                    m1 = pj_msfn(sinphi, cosphi, par.es);
+                    ml1 = pj_tsfn(proj_parm.phi1, sinphi, par.e);
+                    if (secant) { /* secant cone */
+                        proj_parm.n = log(m1 /
+                           pj_msfn(sinphi = sin(proj_parm.phi2), cos(proj_parm.phi2), par.es));
+                        proj_parm.n /= log(ml1 / pj_tsfn(proj_parm.phi2, sinphi, par.e));
+                    }
+                    proj_parm.c = (proj_parm.rho0 = m1 * pow(ml1, -proj_parm.n) / proj_parm.n);
+                    proj_parm.rho0 *= (fabs(fabs(par.phi0) - HALFPI) < EPS10) ? 0. :
+                        pow(pj_tsfn(par.phi0, sin(par.phi0), par.e), proj_parm.n);
+                } else {
+                    if (secant)
+                        proj_parm.n = log(cosphi / cos(proj_parm.phi2)) /
+                           log(tan(FORTPI + .5 * proj_parm.phi2) /
+                           tan(FORTPI + .5 * proj_parm.phi1));
+                    proj_parm.c = cosphi * pow(tan(FORTPI + .5 * proj_parm.phi1), proj_parm.n) / proj_parm.n;
+                    proj_parm.rho0 = (fabs(fabs(par.phi0) - HALFPI) < EPS10) ? 0. :
+                        proj_parm.c * pow(tan(FORTPI + .5 * par.phi0), -proj_parm.n);
+                }
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                // par.spc = fac;
+            }
+
+        }} // namespace detail::lcc
+    #endif // doxygen
+
+    /*!
+        \brief Lambert Conformal Conic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_1= and lat_2= or lat_0
+        \par Example
+        \image html ex_lcc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lcc_ellipsoid : public detail::lcc::base_lcc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline lcc_ellipsoid(const Parameters& par) : detail::lcc::base_lcc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::lcc::setup_lcc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lcc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<lcc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void lcc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("lcc", new lcc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    // Create EPSG specializations
+    // (Proof of Concept, only for some)
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2805, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef lcc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LCC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/src/boost/geometry/extensions/gis/projections/proj/lcca.hpp
new file mode 100644
index 0000000..30d05f5
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/lcca.hpp
@@ -0,0 +1,191 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace lcca{
+            static const int MAX_ITER = 10;
+            static const double DEL_TOL = 1e-12;
+
+            struct par_lcca
+            {
+                double    en[EN_SIZE];
+                double    r0, l, M0;
+                double    C;
+            };
+
+
+                inline double /* func to compute dr */
+            fS(double S, double C) {
+                    return(S * ( 1. + S * S * C));
+            }
+                inline double /* deriv of fs */
+            fSp(double S, double C) {
+                return(1. + 3.* S * S * C);
+            }
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_lcca_ellipsoid : public base_t_fi<base_lcca_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_lcca m_proj_parm;
+
+                inline base_lcca_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_lcca_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double S, r, dr;
+
+                    S = pj_mlfn(lp_lat, sin(lp_lat), cos(lp_lat), this->m_proj_parm.en) - this->m_proj_parm.M0;
+                    dr = fS(S, this->m_proj_parm.C);
+                    r = this->m_proj_parm.r0 - dr;
+                    xy_x = this->m_par.k0 * (r * sin( lp_lon *= this->m_proj_parm.l ) );
+                    xy_y = this->m_par.k0 * (this->m_proj_parm.r0 - r * cos(lp_lon) );
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double theta, dr, S, dif;
+                    int i;
+
+                    xy_x /= this->m_par.k0;
+                    xy_y /= this->m_par.k0;
+                    theta = atan2(xy_x , this->m_proj_parm.r0 - xy_y);
+                    dr = xy_y - xy_x * tan(0.5 * theta);
+                    lp_lon = theta / this->m_proj_parm.l;
+                    S = dr;
+                    for (i = MAX_ITER; i ; --i) {
+                        S -= (dif = (fS(S, this->m_proj_parm.C) - dr) / fSp(S, this->m_proj_parm.C));
+                        if (fabs(dif) < DEL_TOL) break;
+                    }
+                    if (!i) throw proj_exception();
+                    lp_lat = pj_inv_mlfn(S + this->m_proj_parm.M0, this->m_par.es, this->m_proj_parm.en);
+                }
+            };
+
+            // Lambert Conformal Conic Alternative
+            template <typename Parameters>
+            void setup_lcca(Parameters& par, par_lcca& proj_parm)
+            {
+                double s2p0, N0, R0, tan0, tan20;
+                    pj_enfn(par.es, proj_parm.en);
+                if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50);
+                if (par.phi0 == 0.) throw proj_exception(51);
+                proj_parm.l = sin(par.phi0);
+                proj_parm.M0 = pj_mlfn(par.phi0, proj_parm.l, cos(par.phi0), proj_parm.en);
+                s2p0 = proj_parm.l * proj_parm.l;
+                R0 = 1. / (1. - par.es * s2p0);
+                N0 = sqrt(R0);
+                R0 *= par.one_es * N0;
+                tan0 = tan(par.phi0);
+                tan20 = tan0 * tan0;
+                proj_parm.r0 = N0 / tan0;
+                proj_parm.C = 1. / (6. * R0 * N0);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::lcca
+    #endif // doxygen
+
+    /*!
+        \brief Lambert Conformal Conic Alternative projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+         - lat_0=
+        \par Example
+        \image html ex_lcca.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lcca_ellipsoid : public detail::lcca::base_lcca_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline lcca_ellipsoid(const Parameters& par) : detail::lcca::base_lcca_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::lcca::setup_lcca(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lcca_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<lcca_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void lcca_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("lcca", new lcca_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/loxim.hpp b/src/boost/geometry/extensions/gis/projections/proj/loxim.hpp
new file mode 100644
index 0000000..3c5249e
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/loxim.hpp
@@ -0,0 +1,164 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace loxim{
+            static const double EPS = 1e-8;
+
+            struct par_loxim
+            {
+                double phi1;
+                double cosphi1;
+                double tanphi1;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_loxim_spheroid : public base_t_fi<base_loxim_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_loxim m_proj_parm;
+
+                inline base_loxim_spheroid(const Parameters& par)
+                    : base_t_fi<base_loxim_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_y = lp_lat - this->m_proj_parm.phi1;
+                    if (fabs(xy_y) < EPS)
+                        xy_x = lp_lon * this->m_proj_parm.cosphi1;
+                    else {
+                        xy_x = FORTPI + 0.5 * lp_lat;
+                        if (fabs(xy_x) < EPS || fabs(fabs(xy_x) - HALFPI) < EPS)
+                            xy_x = 0.;
+                        else
+                            xy_x = lp_lon * xy_y / log( tan(xy_x) / this->m_proj_parm.tanphi1 );
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y + this->m_proj_parm.phi1;
+                    if (fabs(xy_y) < EPS)
+                        lp_lon = xy_x / this->m_proj_parm.cosphi1;
+                    else
+                        if (fabs( lp_lon = FORTPI + 0.5 * lp_lat ) < EPS ||
+                            fabs(fabs(lp_lon) - HALFPI) < EPS)
+                            lp_lon = 0.;
+                        else
+                            lp_lon = xy_x * log( tan(lp_lon) / this->m_proj_parm.tanphi1 ) / xy_y ;
+                }
+            };
+
+            // Loximuthal
+            template <typename Parameters>
+            void setup_loxim(Parameters& par, par_loxim& proj_parm)
+            {
+                proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
+                if ((proj_parm.cosphi1 = cos(proj_parm.phi1)) < EPS) throw proj_exception(-22);
+                proj_parm.tanphi1 = tan(FORTPI + 0.5 * proj_parm.phi1);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::loxim
+    #endif // doxygen
+
+    /*!
+        \brief Loximuthal projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_loxim.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct loxim_spheroid : public detail::loxim::base_loxim_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline loxim_spheroid(const Parameters& par) : detail::loxim::base_loxim_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::loxim::setup_loxim(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class loxim_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<loxim_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void loxim_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("loxim", new loxim_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/lsat.hpp b/src/boost/geometry/extensions/gis/projections/proj/lsat.hpp
new file mode 100644
index 0000000..7b6f8c2
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/lsat.hpp
@@ -0,0 +1,299 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace lsat{
+            static const double TOL = 1e-7;
+            static const double PI_HALFPI = 4.71238898038468985766;
+            static const double TWOPI_HALFPI = 7.85398163397448309610;
+
+            struct par_lsat
+            {
+                double a2, a4, b, c1, c3;
+                double q, t, u, w, p22, sa, ca, xj, rlm, rlm2;
+            };
+            /* based upon Snyder and Linck, USGS-NMD */
+            template <typename Parameters>
+                inline void
+            seraz0(double lam, double mult, Parameters& par, par_lsat& proj_parm) {
+                double sdsq, h, s, fc, sd, sq, d__1;
+
+                lam *= DEG_TO_RAD;
+                sd = sin(lam);
+                sdsq = sd * sd;
+                s = proj_parm.p22 * proj_parm.sa * cos(lam) * sqrt((1. + proj_parm.t * sdsq) / ((
+                    1. + proj_parm.w * sdsq) * (1. + proj_parm.q * sdsq)));
+                d__1 = 1. + proj_parm.q * sdsq;
+                h = sqrt((1. + proj_parm.q * sdsq) / (1. + proj_parm.w * sdsq)) * ((1. +
+                    proj_parm.w * sdsq) / (d__1 * d__1) - proj_parm.p22 * proj_parm.ca);
+                sq = sqrt(proj_parm.xj * proj_parm.xj + s * s);
+                proj_parm.b += fc = mult * (h * proj_parm.xj - s * s) / sq;
+                proj_parm.a2 += fc * cos(lam + lam);
+                proj_parm.a4 += fc * cos(lam * 4.);
+                fc = mult * s * (h + proj_parm.xj) / sq;
+                proj_parm.c1 += fc * cos(lam);
+                proj_parm.c3 += fc * cos(lam * 3.);
+            }
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_lsat_ellipsoid : public base_t_fi<base_lsat_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_lsat m_proj_parm;
+
+                inline base_lsat_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_lsat_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    int l, nn;
+                    double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph,
+                        lamtp, cl, sd, sp, fac, sav, tanphi;
+
+                    if (lp_lat > HALFPI)
+                        lp_lat = HALFPI;
+                    else if (lp_lat < -HALFPI)
+                        lp_lat = -HALFPI;
+                    lampp = lp_lat >= 0. ? HALFPI : PI_HALFPI;
+                    tanphi = tan(lp_lat);
+                    for (nn = 0;;) {
+                        sav = lampp;
+                        lamtp = lp_lon + this->m_proj_parm.p22 * lampp;
+                        cl = cos(lamtp);
+                        if (fabs(cl) < TOL)
+                            lamtp -= TOL;
+                        fac = lampp - sin(lampp) * (cl < 0. ? -HALFPI : HALFPI);
+                        for (l = 50; l; --l) {
+                            lamt = lp_lon + this->m_proj_parm.p22 * sav;
+                            if (fabs(c = cos(lamt)) < TOL)
+                                lamt -= TOL;
+                            xlam = (this->m_par.one_es * tanphi * this->m_proj_parm.sa + sin(lamt) * this->m_proj_parm.ca) / c;
+                            lamdp = atan(xlam) + fac;
+                            if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
+                                break;
+                            sav = lamdp;
+                        }
+                        if (!l || ++nn >= 3 || (lamdp > this->m_proj_parm.rlm && lamdp < this->m_proj_parm.rlm2))
+                            break;
+                        if (lamdp <= this->m_proj_parm.rlm)
+                            lampp = TWOPI_HALFPI;
+                        else if (lamdp >= this->m_proj_parm.rlm2)
+                            lampp = HALFPI;
+                    }
+                    if (l) {
+                        sp = sin(lp_lat);
+                        phidp = aasin((this->m_par.one_es * this->m_proj_parm.ca * sp - this->m_proj_parm.sa * cos(lp_lat) *
+                            sin(lamt)) / sqrt(1. - this->m_par.es * sp * sp));
+                        tanph = log(tan(FORTPI + .5 * phidp));
+                        sd = sin(lamdp);
+                        sdsq = sd * sd;
+                        s = this->m_proj_parm.p22 * this->m_proj_parm.sa * cos(lamdp) * sqrt((1. + this->m_proj_parm.t * sdsq)
+                             / ((1. + this->m_proj_parm.w * sdsq) * (1. + this->m_proj_parm.q * sdsq)));
+                        d = sqrt(this->m_proj_parm.xj * this->m_proj_parm.xj + s * s);
+                        xy_x = this->m_proj_parm.b * lamdp + this->m_proj_parm.a2 * sin(2. * lamdp) + this->m_proj_parm.a4 *
+                            sin(lamdp * 4.) - tanph * s / d;
+                        xy_y = this->m_proj_parm.c1 * sd + this->m_proj_parm.c3 * sin(lamdp * 3.) + tanph * this->m_proj_parm.xj / d;
+                    } else
+                        xy_x = xy_y = HUGE_VAL;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    int nn;
+                    double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
+
+                    lamdp = xy_x / this->m_proj_parm.b;
+                    nn = 50;
+                    do {
+                        sav = lamdp;
+                        sd = sin(lamdp);
+                        sdsq = sd * sd;
+                        s = this->m_proj_parm.p22 * this->m_proj_parm.sa * cos(lamdp) * sqrt((1. + this->m_proj_parm.t * sdsq)
+                             / ((1. + this->m_proj_parm.w * sdsq) * (1. + this->m_proj_parm.q * sdsq)));
+                        lamdp = xy_x + xy_y * s / this->m_proj_parm.xj - this->m_proj_parm.a2 * sin(
+                            2. * lamdp) - this->m_proj_parm.a4 * sin(lamdp * 4.) - s / this->m_proj_parm.xj * (
+                            this->m_proj_parm.c1 * sin(lamdp) + this->m_proj_parm.c3 * sin(lamdp * 3.));
+                        lamdp /= this->m_proj_parm.b;
+                    } while (fabs(lamdp - sav) >= TOL && --nn);
+                    sl = sin(lamdp);
+                    fac = exp(sqrt(1. + s * s / this->m_proj_parm.xj / this->m_proj_parm.xj) * (xy_y -
+                        this->m_proj_parm.c1 * sl - this->m_proj_parm.c3 * sin(lamdp * 3.)));
+                    phidp = 2. * (atan(fac) - FORTPI);
+                    dd = sl * sl;
+                    if (fabs(cos(lamdp)) < TOL)
+                        lamdp -= TOL;
+                    spp = sin(phidp);
+                    sppsq = spp * spp;
+                    lamt = atan(((1. - sppsq * this->m_par.rone_es) * tan(lamdp) *
+                        this->m_proj_parm.ca - spp * this->m_proj_parm.sa * sqrt((1. + this->m_proj_parm.q * dd) * (
+                        1. - sppsq) - sppsq * this->m_proj_parm.u) / cos(lamdp)) / (1. - sppsq
+                        * (1. + this->m_proj_parm.u)));
+                    sl = lamt >= 0. ? 1. : -1.;
+                    scl = cos(lamdp) >= 0. ? 1. : -1;
+                    lamt -= HALFPI * (1. - scl) * sl;
+                    lp_lon = lamt - this->m_proj_parm.p22 * lamdp;
+                    if (fabs(this->m_proj_parm.sa) < TOL)
+                        lp_lat = aasin(spp / sqrt(this->m_par.one_es * this->m_par.one_es + this->m_par.es * sppsq));
+                    else
+                        lp_lat = atan((tan(lamdp) * cos(lamt) - this->m_proj_parm.ca * sin(lamt)) /
+                            (this->m_par.one_es * this->m_proj_parm.sa));
+                }
+            };
+
+            // Space oblique for LANDSAT
+            template <typename Parameters>
+            void setup_lsat(Parameters& par, par_lsat& proj_parm)
+            {
+                int land, path;
+                double lam, alf, esc, ess;
+                land = pj_param(par.params, "ilsat").i;
+                if (land <= 0 || land > 5) throw proj_exception(-28);
+                path = pj_param(par.params, "ipath").i;
+                if (path <= 0 || path > (land <= 3 ? 251 : 233)) throw proj_exception(-29);
+                if (land <= 3) {
+                    par.lam0 = DEG_TO_RAD * 128.87 - TWOPI / 251. * path;
+                    proj_parm.p22 = 103.2669323;
+                    alf = DEG_TO_RAD * 99.092;
+                } else {
+                    par.lam0 = DEG_TO_RAD * 129.3 - TWOPI / 233. * path;
+                    proj_parm.p22 = 98.8841202;
+                    alf = DEG_TO_RAD * 98.2;
+                }
+                proj_parm.p22 /= 1440.;
+                proj_parm.sa = sin(alf);
+                proj_parm.ca = cos(alf);
+                if (fabs(proj_parm.ca) < 1e-9)
+                    proj_parm.ca = 1e-9;
+                esc = par.es * proj_parm.ca * proj_parm.ca;
+                ess = par.es * proj_parm.sa * proj_parm.sa;
+                proj_parm.w = (1. - esc) * par.rone_es;
+                proj_parm.w = proj_parm.w * proj_parm.w - 1.;
+                proj_parm.q = ess * par.rone_es;
+                proj_parm.t = ess * (2. - par.es) * par.rone_es * par.rone_es;
+                proj_parm.u = esc * par.rone_es;
+                proj_parm.xj = par.one_es * par.one_es * par.one_es;
+                proj_parm.rlm = PI * (1. / 248. + .5161290322580645);
+                proj_parm.rlm2 = proj_parm.rlm + TWOPI;
+                proj_parm.a2 = proj_parm.a4 = proj_parm.b = proj_parm.c1 = proj_parm.c3 = 0.;
+                seraz0(0., 1., par, proj_parm);
+                for (lam = 9.;
+             lam <= 81.0001;
+             lam += 18.)
+                    seraz0(lam, 4., par, proj_parm);
+                for (lam = 18;
+             lam <= 72.0001;
+             lam += 18.)
+                    seraz0(lam, 2., par, proj_parm);
+                seraz0(90., 1., par, proj_parm);
+                proj_parm.a2 /= 30.;
+                proj_parm.a4 /= 60.;
+                proj_parm.b /= 30.;
+                proj_parm.c1 /= 15.;
+                proj_parm.c3 /= 45.;
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::lsat
+    #endif // doxygen
+
+    /*!
+        \brief Space oblique for LANDSAT projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+         - lsat= path=
+        \par Example
+        \image html ex_lsat.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lsat_ellipsoid : public detail::lsat::base_lsat_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline lsat_ellipsoid(const Parameters& par) : detail::lsat::base_lsat_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::lsat::setup_lsat(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lsat_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<lsat_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void lsat_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("lsat", new lsat_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp b/src/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp
new file mode 100644
index 0000000..391dd6b
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp
@@ -0,0 +1,161 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace mbt_fps{
+            static const int MAX_ITER = 10;
+            static const double LOOP_TOL = 1e-7;
+            static const double C1 = 0.45503;
+            static const double C2 = 1.36509;
+            static const double C3 = 1.41546;
+            static const double C_x = 0.22248;
+            static const double C_y = 1.44492;
+            static const double C1_2 = 0.33333333333333333333333333;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_mbt_fps_spheroid : public base_t_fi<base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_mbt_fps_spheroid(const Parameters& par)
+                    : base_t_fi<base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double k, V, t;
+                    int i;
+
+                    k = C3 * sin(lp_lat);
+                    for (i = MAX_ITER; i ; --i) {
+                        t = lp_lat / C2;
+                        lp_lat -= V = (C1 * sin(t) + sin(lp_lat) - k) /
+                            (C1_2 * cos(t) + cos(lp_lat));
+                        if (fabs(V) < LOOP_TOL)
+                            break;
+                    }
+                    t = lp_lat / C2;
+                    xy_x = C_x * lp_lon * (1. + 3. * cos(lp_lat)/cos(t) );
+                    xy_y = C_y * sin(t);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t;
+
+                    lp_lat = C2 * (t = aasin(xy_y / C_y));
+                    lp_lon = xy_x / (C_x * (1. + 3. * cos(lp_lat)/cos(t)));
+                    lp_lat = aasin((C1 * sin(t) + sin(lp_lat)) / C3);
+                }
+            };
+
+            // McBryde-Thomas Flat-Pole Sine (No. 2)
+            template <typename Parameters>
+            void setup_mbt_fps(Parameters& par)
+            {
+                par.es = 0;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::mbt_fps
+    #endif // doxygen
+
+    /*!
+        \brief McBryde-Thomas Flat-Pole Sine (No. 2) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_mbt_fps.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mbt_fps_spheroid : public detail::mbt_fps::base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline mbt_fps_spheroid(const Parameters& par) : detail::mbt_fps::base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mbt_fps::setup_mbt_fps(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mbt_fps_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mbt_fps_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void mbt_fps_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("mbt_fps", new mbt_fps_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp b/src/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp
new file mode 100644
index 0000000..b543997
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp
@@ -0,0 +1,155 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace mbtfpp{
+            static const double CS = .95257934441568037152;
+            static const double FXC = .92582009977255146156;
+            static const double FYC = 3.40168025708304504493;
+            static const double C23 = .66666666666666666666;
+            static const double C13 = .33333333333333333333;
+            static const double ONEEPS = 1.0000001;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_mbtfpp_spheroid : public base_t_fi<base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_mbtfpp_spheroid(const Parameters& par)
+                    : base_t_fi<base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    lp_lat = asin(CS * sin(lp_lat));
+                    xy_x = FXC * lp_lon * (2. * cos(C23 * lp_lat) - 1.);
+                    xy_y = FYC * sin(C13 * lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / FYC;
+                    if (fabs(lp_lat) >= 1.) {
+                        if (fabs(lp_lat) > ONEEPS)    throw proj_exception();
+                        else    lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
+                    } else
+                        lp_lat = asin(lp_lat);
+                    lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) );
+                    if (fabs(lp_lat = sin(lp_lat) / CS) >= 1.) {
+                        if (fabs(lp_lat) > ONEEPS)    throw proj_exception();
+                        else    lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
+                    } else
+                        lp_lat = asin(lp_lat);
+                }
+            };
+
+            // McBride-Thomas Flat-Polar Parabolic
+            template <typename Parameters>
+            void setup_mbtfpp(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::mbtfpp
+    #endif // doxygen
+
+    /*!
+        \brief McBride-Thomas Flat-Polar Parabolic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_mbtfpp.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mbtfpp_spheroid : public detail::mbtfpp::base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline mbtfpp_spheroid(const Parameters& par) : detail::mbtfpp::base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mbtfpp::setup_mbtfpp(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mbtfpp_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mbtfpp_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void mbtfpp_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("mbtfpp", new mbtfpp_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp b/src/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp
new file mode 100644
index 0000000..6bdc861
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp
@@ -0,0 +1,170 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace mbtfpq{
+            static const int NITER = 20;
+            static const double EPS = 1e-7;
+            static const double ONETOL = 1.000001;
+            static const double C = 1.70710678118654752440;
+            static const double RC = 0.58578643762690495119;
+            static const double FYC = 1.87475828462269495505;
+            static const double RYC = 0.53340209679417701685;
+            static const double FXC = 0.31245971410378249250;
+            static const double RXC = 3.20041258076506210122;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_mbtfpq_spheroid : public base_t_fi<base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_mbtfpq_spheroid(const Parameters& par)
+                    : base_t_fi<base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double th1, c;
+                    int i;
+
+                    c = C * sin(lp_lat);
+                    for (i = NITER; i; --i) {
+                        lp_lat -= th1 = (sin(.5*lp_lat) + sin(lp_lat) - c) /
+                            (.5*cos(.5*lp_lat)  + cos(lp_lat));
+                        if (fabs(th1) < EPS) break;
+                    }
+                    xy_x = FXC * lp_lon * (1.0 + 2. * cos(lp_lat)/cos(0.5 * lp_lat));
+                    xy_y = FYC * sin(0.5 * lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t;
+
+                    lp_lat = RYC * xy_y;
+                    if (fabs(lp_lat) > 1.) {
+                        if (fabs(lp_lat) > ONETOL)    throw proj_exception();
+                        else if (lp_lat < 0.) { t = -1.; lp_lat = -PI; }
+                        else { t = 1.; lp_lat = PI; }
+                    } else
+                        lp_lat = 2. * asin(t = lp_lat);
+                    lp_lon = RXC * xy_x / (1. + 2. * cos(lp_lat)/cos(0.5 * lp_lat));
+                    lp_lat = RC * (t + sin(lp_lat));
+                    if (fabs(lp_lat) > 1.)
+                        if (fabs(lp_lat) > ONETOL)    throw proj_exception();
+                        else            lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+                    else
+                        lp_lat = asin(lp_lat);
+                }
+            };
+
+            // McBryde-Thomas Flat-Polar Quartic
+            template <typename Parameters>
+            void setup_mbtfpq(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::mbtfpq
+    #endif // doxygen
+
+    /*!
+        \brief McBryde-Thomas Flat-Polar Quartic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_mbtfpq.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mbtfpq_spheroid : public detail::mbtfpq::base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline mbtfpq_spheroid(const Parameters& par) : detail::mbtfpq::base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mbtfpq::setup_mbtfpq(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mbtfpq_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mbtfpq_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void mbtfpq_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("mbtfpq", new mbtfpq_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/merc.hpp b/src/boost/geometry/extensions/gis/projections/proj/merc.hpp
new file mode 100644
index 0000000..f82fec0
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/merc.hpp
@@ -0,0 +1,213 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MERC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MERC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace merc{
+            static const double EPS10 = 1.e-10;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_merc_ellipsoid : public base_t_fi<base_merc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_merc_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_merc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception();;
+                    xy_x = this->m_par.k0 * lp_lon;
+                    xy_y = - this->m_par.k0 * log(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    if ((lp_lat = pj_phi2(exp(- xy_y / this->m_par.k0), this->m_par.e)) == HUGE_VAL) throw proj_exception();;
+                    lp_lon = xy_x / this->m_par.k0;
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_merc_spheroid : public base_t_fi<base_merc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_merc_spheroid(const Parameters& par)
+                    : base_t_fi<base_merc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception();;
+                    xy_x = this->m_par.k0 * lp_lon;
+                    xy_y = this->m_par.k0 * log(tan(FORTPI + .5 * lp_lat));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = HALFPI - 2. * atan(exp(-xy_y / this->m_par.k0));
+                    lp_lon = xy_x / this->m_par.k0;
+                }
+            };
+
+            // Mercator
+            template <typename Parameters>
+            void setup_merc(Parameters& par)
+            {
+                double phits=0.0;
+                int is_phits;
+                if( (is_phits = pj_param(par.params, "tlat_ts").i) ) {
+                    phits = fabs(pj_param(par.params, "rlat_ts").f);
+                    if (phits >= HALFPI) throw proj_exception(-24);
+                }
+                if (par.es) { /* ellipsoid */
+                    if (is_phits)
+                        par.k0 = pj_msfn(sin(phits), cos(phits), par.es);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else { /* sphere */
+                    if (is_phits)
+                        par.k0 = cos(phits);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::merc
+    #endif // doxygen
+
+    /*!
+        \brief Mercator projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+         - lat_ts=
+        \par Example
+        \image html ex_merc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct merc_ellipsoid : public detail::merc::base_merc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline merc_ellipsoid(const Parameters& par) : detail::merc::base_merc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::merc::setup_merc(this->m_par);
+        }
+    };
+
+    /*!
+        \brief Mercator projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+         - lat_ts=
+        \par Example
+        \image html ex_merc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct merc_spheroid : public detail::merc::base_merc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline merc_spheroid(const Parameters& par) : detail::merc::base_merc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::merc::setup_merc(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class merc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<merc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<merc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void merc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("merc", new merc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MERC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/mill.hpp b/src/boost/geometry/extensions/gis/projections/proj/mill.hpp
new file mode 100644
index 0000000..d7ecdd4
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/mill.hpp
@@ -0,0 +1,138 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MILL_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MILL_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace mill{
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_mill_spheroid : public base_t_fi<base_mill_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_mill_spheroid(const Parameters& par)
+                    : base_t_fi<base_mill_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = lp_lon;
+                    xy_y = log(tan(FORTPI + lp_lat * .4)) * 1.25;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lon = xy_x;
+                    lp_lat = 2.5 * (atan(exp(.8 * xy_y)) - FORTPI);
+                }
+            };
+
+            // Miller Cylindrical
+            template <typename Parameters>
+            void setup_mill(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::mill
+    #endif // doxygen
+
+    /*!
+        \brief Miller Cylindrical projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_mill.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mill_spheroid : public detail::mill::base_mill_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline mill_spheroid(const Parameters& par) : detail::mill::base_mill_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mill::setup_mill(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mill_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mill_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void mill_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("mill", new mill_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MILL_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp b/src/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp
new file mode 100644
index 0000000..fe90b41
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp
@@ -0,0 +1,474 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_zpoly1.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace mod_ster{
+            static const double EPSLN = 1e-10;
+
+            struct par_mod_ster
+            {
+                COMPLEX    *zcoeff;
+                double    cchio, schio;
+                int        n;
+            };
+            /* based upon Snyder and Linck, USGS-NMD */
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_mod_ster_ellipsoid : public base_t_fi<base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_mod_ster m_proj_parm;
+
+                inline base_mod_ster_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double sinlon, coslon, esphi, chi, schi, cchi, s;
+                    COMPLEX p;
+
+                    sinlon = sin(lp_lon);
+                    coslon = cos(lp_lon);
+                    esphi = this->m_par.e * sin(lp_lat);
+                    chi = 2. * atan(tan((HALFPI + lp_lat) * .5) *
+                        pow((1. - esphi) / (1. + esphi), this->m_par.e * .5)) - HALFPI;
+                    schi = sin(chi);
+                    cchi = cos(chi);
+                    s = 2. / (1. + this->m_proj_parm.schio * schi + this->m_proj_parm.cchio * cchi * coslon);
+                    p.r = s * cchi * sinlon;
+                    p.i = s * (this->m_proj_parm.cchio * schi - this->m_proj_parm.schio * cchi * coslon);
+                    p = pj_zpoly1(p, this->m_proj_parm.zcoeff, this->m_proj_parm.n);
+                    xy_x = p.r;
+                    xy_y = p.i;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    int nn;
+                    COMPLEX p, fxy, fpxy, dp;
+                    double den, rh = 0, z, sinz = 0, cosz = 0, chi, phi = 0, dphi, esphi;
+
+                    p.r = xy_x;
+                    p.i = xy_y;
+                    for (nn = 20; nn ;--nn) {
+                        fxy = pj_zpolyd1(p, this->m_proj_parm.zcoeff, this->m_proj_parm.n, &fpxy);
+                        fxy.r -= xy_x;
+                        fxy.i -= xy_y;
+                        den = fpxy.r * fpxy.r + fpxy.i * fpxy.i;
+                        dp.r = -(fxy.r * fpxy.r + fxy.i * fpxy.i) / den;
+                        dp.i = -(fxy.i * fpxy.r - fxy.r * fpxy.i) / den;
+                        p.r += dp.r;
+                        p.i += dp.i;
+                        if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
+                            break;
+                    }
+                    if (nn) {
+                        rh = boost::math::hypot(p.r, p.i);
+                        z = 2. * atan(.5 * rh);
+                        sinz = sin(z);
+                        cosz = cos(z);
+                        lp_lon = this->m_par.lam0;
+                        if (fabs(rh) <= EPSLN) {
+                            lp_lat = this->m_par.phi0;
+                            return;
+                        }
+                        chi = aasin(cosz * this->m_proj_parm.schio + p.i * sinz * this->m_proj_parm.cchio / rh);
+                        phi = chi;
+                        for (nn = 20; nn ;--nn) {
+                            esphi = this->m_par.e * sin(phi);
+                            dphi = 2. * atan(tan((HALFPI + chi) * .5) *
+                                pow((1. + esphi) / (1. - esphi), this->m_par.e * .5)) - HALFPI - phi;
+                            phi += dphi;
+                            if (fabs(dphi) <= EPSLN)
+                                break;
+                        }
+                    }
+                    if (nn) {
+                        lp_lat = phi;
+                        lp_lon = atan2(p.r * sinz, rh * this->m_proj_parm.cchio * cosz - p.i *
+                            this->m_proj_parm.schio * sinz);
+                    } else
+                        lp_lon = lp_lat = HUGE_VAL;
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_mod_ster& proj_parm)  /* general initialization */
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                double esphi, chio;
+                if (par.es) {
+                    esphi = par.e * sin(par.phi0);
+                    chio = 2. * atan(tan((HALFPI + par.phi0) * .5) *
+                        pow((1. - esphi) / (1. + esphi), par.e * .5)) - HALFPI;
+                } else
+                    chio = par.phi0;
+                proj_parm.schio = sin(chio);
+                proj_parm.cchio = cos(chio);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+
+            // Miller Oblated Stereographic
+            template <typename Parameters>
+            void setup_mil_os(Parameters& par, par_mod_ster& proj_parm)
+            {
+                static COMPLEX /* Miller Oblated Stereographic */
+            AB[] = {
+                {0.924500,    0.},
+                {0.,            0.},
+                {0.019430,    0.}
+            };
+                proj_parm.n = 2;
+                par.lam0 = DEG_TO_RAD * 20.;
+                par.phi0 = DEG_TO_RAD * 18.;
+                proj_parm.zcoeff = AB;
+                par.es = 0.;
+                setup(par, proj_parm);
+            }
+
+            // Lee Oblated Stereographic
+            template <typename Parameters>
+            void setup_lee_os(Parameters& par, par_mod_ster& proj_parm)
+            {
+                static COMPLEX /* Lee Oblated Stereographic */
+            AB[] = {
+                {0.721316,    0.},
+                {0.,            0.},
+                    {-0.0088162,     -0.00617325}
+            };
+                proj_parm.n = 2;
+                par.lam0 = DEG_TO_RAD * -165.;
+                par.phi0 = DEG_TO_RAD * -10.;
+                proj_parm.zcoeff = AB;
+                par.es = 0.;
+                setup(par, proj_parm);
+            }
+
+            // Mod. Stererographics of 48 U.S.
+            template <typename Parameters>
+            void setup_gs48(Parameters& par, par_mod_ster& proj_parm)
+            {
+                static COMPLEX /* 48 United States */
+            AB[] = {
+                {0.98879,    0.},
+                {0.,        0.},
+                {-0.050909,    0.},
+                {0.,        0.},
+                    {0.075528,    0.}
+            };
+                proj_parm.n = 4;
+                par.lam0 = DEG_TO_RAD * -96.;
+                par.phi0 = DEG_TO_RAD * -39.;
+                proj_parm.zcoeff = AB;
+                par.es = 0.;
+                par.a = 6370997.;
+                setup(par, proj_parm);
+            }
+
+            // Mod. Stererographics of Alaska
+            template <typename Parameters>
+            void setup_alsk(Parameters& par, par_mod_ster& proj_parm)
+            {
+                static COMPLEX
+            ABe[] = { /* Alaska ellipsoid */
+                {.9945303,    0.},
+                {.0052083,    -.0027404},
+                {.0072721,    .0048181},
+                {-.0151089,    -.1932526},
+                {.0642675,    -.1381226},
+                {.3582802,    -.2884586}},
+            ABs[] = { /* Alaska sphere */
+                {.9972523,    0.},
+                {.0052513,    -.0041175},
+                {.0074606,    .0048125},
+                {-.0153783,    -.1968253},
+                {.0636871,    -.1408027},
+                    {.3660976,    -.2937382}
+            };
+                proj_parm.n = 5;
+                par.lam0 = DEG_TO_RAD * -152.;
+                par.phi0 = DEG_TO_RAD * 64.;
+                if (par.es) { /* fixed ellipsoid/sphere */
+                    proj_parm.zcoeff = ABe;
+                    par.a = 6378206.4;
+                    par.e = sqrt(par.es = 0.00676866);
+                } else {
+                    proj_parm.zcoeff = ABs;
+                    par.a = 6370997.;
+                }
+                setup(par, proj_parm);
+            }
+
+            // Mod. Stererographics of 50 U.S.
+            template <typename Parameters>
+            void setup_gs50(Parameters& par, par_mod_ster& proj_parm)
+            {
+                static COMPLEX
+            ABe[] = { /* GS50 ellipsoid */
+                {.9827497,    0.},
+                {.0210669,    .0053804},
+                {-.1031415,    -.0571664},
+                {-.0323337,    -.0322847},
+                {.0502303,    .1211983},
+                {.0251805,    .0895678},
+                {-.0012315,    -.1416121},
+                {.0072202,    -.1317091},
+                {-.0194029,    .0759677},
+                    {-.0210072,    .0834037}
+            },
+            ABs[] = { /* GS50 sphere */
+                {.9842990,    0.},
+                {.0211642,    .0037608},
+                {-.1036018,    -.0575102},
+                {-.0329095,    -.0320119},
+                {.0499471,    .1223335},
+                {.0260460,    .0899805},
+                {.0007388,    -.1435792},
+                {.0075848,    -.1334108},
+                {-.0216473,    .0776645},
+                    {-.0225161,    .0853673}
+            };
+                proj_parm.n = 9;
+                par.lam0 = DEG_TO_RAD * -120.;
+                par.phi0 = DEG_TO_RAD * 45.;
+                if (par.es) { /* fixed ellipsoid/sphere */
+                    proj_parm.zcoeff = ABe;
+                    par.a = 6378206.4;
+                    par.e = sqrt(par.es = 0.00676866);
+                } else {
+                    proj_parm.zcoeff = ABs;
+                    par.a = 6370997.;
+                }
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::mod_ster
+    #endif // doxygen
+
+    /*!
+        \brief Miller Oblated Stereographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azi(mod)
+        \par Example
+        \image html ex_mil_os.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mil_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline mil_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mod_ster::setup_mil_os(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Lee Oblated Stereographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azi(mod)
+        \par Example
+        \image html ex_lee_os.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct lee_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline lee_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mod_ster::setup_lee_os(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Mod. Stererographics of 48 U.S. projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azi(mod)
+        \par Example
+        \image html ex_gs48.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gs48_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline gs48_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mod_ster::setup_gs48(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Mod. Stererographics of Alaska projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azi(mod)
+        \par Example
+        \image html ex_alsk.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct alsk_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline alsk_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mod_ster::setup_alsk(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Mod. Stererographics of 50 U.S. projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azi(mod)
+        \par Example
+        \image html ex_gs50.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct gs50_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline gs50_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::mod_ster::setup_gs50(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mil_os_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mil_os_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class lee_os_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<lee_os_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gs48_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<gs48_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class alsk_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<alsk_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class gs50_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<gs50_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void mod_ster_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("mil_os", new mil_os_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("lee_os", new lee_os_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("gs48", new gs48_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("alsk", new alsk_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("gs50", new gs50_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/moll.hpp b/src/boost/geometry/extensions/gis/projections/proj/moll.hpp
new file mode 100644
index 0000000..df5bf47
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/moll.hpp
@@ -0,0 +1,262 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace moll{
+            static const int MAX_ITER = 10;
+            static const double LOOP_TOL = 1e-7;
+
+            struct par_moll
+            {
+                double    C_x, C_y, C_p;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_moll_spheroid : public base_t_fi<base_moll_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_moll m_proj_parm;
+
+                inline base_moll_spheroid(const Parameters& par)
+                    : base_t_fi<base_moll_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double k, V;
+                    int i;
+
+                    k = this->m_proj_parm.C_p * sin(lp_lat);
+                    for (i = MAX_ITER; i ; --i) {
+                        lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
+                            (1. + cos(lp_lat));
+                        if (fabs(V) < LOOP_TOL)
+                            break;
+                    }
+                    if (!i)
+                        lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
+                    else
+                        lp_lat *= 0.5;
+                    xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat);
+                    xy_y = this->m_proj_parm.C_y * sin(lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+
+
+                    lp_lat = aasin(xy_y / this->m_proj_parm.C_y);
+                    lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat));
+                    lp_lat += lp_lat;
+                    lp_lat = aasin((lp_lat + sin(lp_lat)) / this->m_proj_parm.C_p);
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_moll& proj_parm, double p)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                double r, sp, p2 = p + p;
+                par.es = 0;
+                sp = sin(p);
+                r = sqrt(TWOPI * sp / (p2 + sin(p2)));
+                proj_parm.C_x = 2. * r / PI;
+                proj_parm.C_y = r / sp;
+                proj_parm.C_p = p2 + sin(p2);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Mollweide
+            template <typename Parameters>
+            void setup_moll(Parameters& par, par_moll& proj_parm)
+            {
+                setup(par, proj_parm, HALFPI);
+            }
+
+            // Wagner IV
+            template <typename Parameters>
+            void setup_wag4(Parameters& par, par_moll& proj_parm)
+            {
+                setup(par, proj_parm, PI/3.);
+            }
+
+            // Wagner V
+            template <typename Parameters>
+            void setup_wag5(Parameters& par, par_moll& proj_parm)
+            {
+                par.es = 0;
+                proj_parm.C_x = 0.90977;
+                proj_parm.C_y = 1.65014;
+                proj_parm.C_p = 3.00896;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::moll
+    #endif // doxygen
+
+    /*!
+        \brief Mollweide projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_moll.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct moll_spheroid : public detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline moll_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::moll::setup_moll(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Wagner IV projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_wag4.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag4_spheroid : public detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag4_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::moll::setup_wag4(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Wagner V projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_wag5.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag5_spheroid : public detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag5_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::moll::setup_wag5(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class moll_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<moll_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag4_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wag4_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wag5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void moll_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("moll", new moll_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("wag4", new wag4_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("wag5", new wag5_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/nell.hpp b/src/boost/geometry/extensions/gis/projections/proj/nell.hpp
new file mode 100644
index 0000000..2cee423
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/nell.hpp
@@ -0,0 +1,154 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_NELL_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace nell{
+            static const int MAX_ITER = 10;
+            static const double LOOP_TOL = 1e-7;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_nell_spheroid : public base_t_fi<base_nell_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_nell_spheroid(const Parameters& par)
+                    : base_t_fi<base_nell_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double k, V;
+                    int i;
+
+                    k = 2. * sin(lp_lat);
+                    V = lp_lat * lp_lat;
+                    lp_lat *= 1.00371 + V * (-0.0935382 + V * -0.011412);
+                    for (i = MAX_ITER; i ; --i) {
+                        lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
+                            (1. + cos(lp_lat));
+                        if (fabs(V) < LOOP_TOL)
+                            break;
+                    }
+                    xy_x = 0.5 * lp_lon * (1. + cos(lp_lat));
+                    xy_y = lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+
+
+                    lp_lon = 2. * xy_x / (1. + cos(xy_y));
+                    lp_lat = aasin(0.5 * (xy_y + sin(xy_y)));
+                }
+            };
+
+            // Nell
+            template <typename Parameters>
+            void setup_nell(Parameters& par)
+            {
+                par.es = 0;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::nell
+    #endif // doxygen
+
+    /*!
+        \brief Nell projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_nell.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct nell_spheroid : public detail::nell::base_nell_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline nell_spheroid(const Parameters& par) : detail::nell::base_nell_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::nell::setup_nell(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class nell_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<nell_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void nell_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("nell", new nell_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_NELL_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/nell_h.hpp b/src/boost/geometry/extensions/gis/projections/proj/nell_h.hpp
new file mode 100644
index 0000000..456c8f3
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/nell_h.hpp
@@ -0,0 +1,153 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace nell_h{
+            static const int NITER = 9;
+            static const double EPS = 1e-7;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_nell_h_spheroid : public base_t_fi<base_nell_h_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_nell_h_spheroid(const Parameters& par)
+                    : base_t_fi<base_nell_h_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = 0.5 * lp_lon * (1. + cos(lp_lat));
+                    xy_y = 2.0 * (lp_lat - tan(0.5 *lp_lat));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double V, c, p;
+                    int i;
+
+                    p = 0.5 * xy_y;
+                    for (i = NITER; i ; --i) {
+                        c = cos(0.5 * lp_lat);
+                        lp_lat -= V = (lp_lat - tan(lp_lat/2) - p)/(1. - 0.5/(c*c));
+                        if (fabs(V) < EPS)
+                            break;
+                    }
+                    if (!i) {
+                        lp_lat = p < 0. ? -HALFPI : HALFPI;
+                        lp_lon = 2. * xy_x;
+                    } else
+                        lp_lon = 2. * xy_x / (1. + cos(lp_lat));
+                }
+            };
+
+            // Nell-Hammer
+            template <typename Parameters>
+            void setup_nell_h(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::nell_h
+    #endif // doxygen
+
+    /*!
+        \brief Nell-Hammer projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_nell_h.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct nell_h_spheroid : public detail::nell_h::base_nell_h_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline nell_h_spheroid(const Parameters& par) : detail::nell_h::base_nell_h_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::nell_h::setup_nell_h(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class nell_h_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<nell_h_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void nell_h_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("nell_h", new nell_h_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/nocol.hpp b/src/boost/geometry/extensions/gis/projections/proj/nocol.hpp
new file mode 100644
index 0000000..e8e5a1e
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/nocol.hpp
@@ -0,0 +1,160 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace nocol{
+            static const double EPS = 1e-10;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_nocol_spheroid : public base_t_f<base_nocol_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_nocol_spheroid(const Parameters& par)
+                    : base_t_f<base_nocol_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    if (fabs(lp_lon) < EPS) {
+                        xy_x = 0;
+                        xy_y = lp_lat;
+                    } else if (fabs(lp_lat) < EPS) {
+                        xy_x = lp_lon;
+                        xy_y = 0.;
+                    } else if (fabs(fabs(lp_lon) - HALFPI) < EPS) {
+                        xy_x = lp_lon * cos(lp_lat);
+                        xy_y = HALFPI * sin(lp_lat);
+                    } else if (fabs(fabs(lp_lat) - HALFPI) < EPS) {
+                        xy_x = 0;
+                        xy_y = lp_lat;
+                    } else {
+                        double tb, c, d, m, n, r2, sp;
+
+                        tb = HALFPI / lp_lon - lp_lon / HALFPI;
+                        c = lp_lat / HALFPI;
+                        d = (1 - c * c)/((sp = sin(lp_lat)) - c);
+                        r2 = tb / d;
+                        r2 *= r2;
+                        m = (tb * sp / d - 0.5 * tb)/(1. + r2);
+                        n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
+                        xy_x = cos(lp_lat);
+                        xy_x = sqrt(m * m + xy_x * xy_x / (1. + r2));
+                        xy_x = HALFPI * ( m + (lp_lon < 0. ? -xy_x : xy_x));
+                        xy_y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
+                            (1. + 1./r2));
+                        xy_y = HALFPI * ( n + (lp_lat < 0. ? xy_y : -xy_y ));
+                    }
+                }
+            };
+
+            // Nicolosi Globular
+            template <typename Parameters>
+            void setup_nicol(Parameters& par)
+            {
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::nocol
+    #endif // doxygen
+
+    /*!
+        \brief Nicolosi Globular projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_nicol.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct nicol_spheroid : public detail::nocol::base_nocol_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline nicol_spheroid(const Parameters& par) : detail::nocol::base_nocol_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::nocol::setup_nicol(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class nicol_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<nicol_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void nocol_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("nicol", new nicol_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/nsper.hpp b/src/boost/geometry/extensions/gis/projections/proj/nsper.hpp
new file mode 100644
index 0000000..e9e46b9
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/nsper.hpp
@@ -0,0 +1,317 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace nsper{
+            static const double EPS10 = 1.e-10;
+            static const int N_POLE = 0;
+            static const int S_POLE = 1;
+            static const int EQUIT = 2;
+            static const int OBLIQ = 3;
+
+            struct par_nsper
+            {
+                double    height;
+                double    sinph0;
+                double    cosph0;
+                double    p;
+                double    rp;
+                double    pn1;
+                double    pfact;
+                double    h;
+                double    cg;
+                double    sg;
+                double    sw;
+                double    cw;
+                int        mode;
+                int        tilt;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_nsper_spheroid : public base_t_fi<base_nsper_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_nsper m_proj_parm;
+
+                inline base_nsper_spheroid(const Parameters& par)
+                    : base_t_fi<base_nsper_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  coslam, cosphi, sinphi;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case OBLIQ:
+                        xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam;
+                        break;
+                    case EQUIT:
+                        xy_y = cosphi * coslam;
+                        break;
+                    case S_POLE:
+                        xy_y = - sinphi;
+                        break;
+                    case N_POLE:
+                        xy_y = sinphi;
+                        break;
+                    }
+                    if (xy_y < this->m_proj_parm.rp) throw proj_exception();;
+                    xy_y = this->m_proj_parm.pn1 / (this->m_proj_parm.p - xy_y);
+                    xy_x = xy_y * cosphi * sin(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case OBLIQ:
+                        xy_y *= (this->m_proj_parm.cosph0 * sinphi -
+                           this->m_proj_parm.sinph0 * cosphi * coslam);
+                        break;
+                    case EQUIT:
+                        xy_y *= sinphi;
+                        break;
+                    case N_POLE:
+                        coslam = - coslam;
+                    case S_POLE:
+                        xy_y *= cosphi * coslam;
+                        break;
+                    }
+                    if (this->m_proj_parm.tilt) {
+                        double yt, ba;
+
+                        yt = xy_y * this->m_proj_parm.cg + xy_x * this->m_proj_parm.sg;
+                        ba = 1. / (yt * this->m_proj_parm.sw * this->m_proj_parm.h + this->m_proj_parm.cw);
+                        xy_x = (xy_x * this->m_proj_parm.cg - xy_y * this->m_proj_parm.sg) * this->m_proj_parm.cw * ba;
+                        xy_y = yt * ba;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double  rh, cosz, sinz;
+
+                    if (this->m_proj_parm.tilt) {
+                        double bm, bq, yt;
+
+                        yt = 1./(this->m_proj_parm.pn1 - xy_y * this->m_proj_parm.sw);
+                        bm = this->m_proj_parm.pn1 * xy_x * yt;
+                        bq = this->m_proj_parm.pn1 * xy_y * this->m_proj_parm.cw * yt;
+                        xy_x = bm * this->m_proj_parm.cg + bq * this->m_proj_parm.sg;
+                        xy_y = bq * this->m_proj_parm.cg - bm * this->m_proj_parm.sg;
+                    }
+                    rh = boost::math::hypot(xy_x, xy_y);
+                    if ((sinz = 1. - rh * rh * this->m_proj_parm.pfact) < 0.) throw proj_exception();;
+                    sinz = (this->m_proj_parm.p - sqrt(sinz)) / (this->m_proj_parm.pn1 / rh + rh / this->m_proj_parm.pn1);
+                    cosz = sqrt(1. - sinz * sinz);
+                    if (fabs(rh) <= EPS10) {
+                        lp_lon = 0.;
+                        lp_lat = this->m_par.phi0;
+                    } else {
+                        switch (this->m_proj_parm.mode) {
+                        case OBLIQ:
+                            lp_lat = asin(cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh);
+                            xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh;
+                            xy_x *= sinz * this->m_proj_parm.cosph0;
+                            break;
+                        case EQUIT:
+                            lp_lat = asin(xy_y * sinz / rh);
+                            xy_y = cosz * rh;
+                            xy_x *= sinz;
+                            break;
+                        case N_POLE:
+                            lp_lat = asin(cosz);
+                            xy_y = -xy_y;
+                            break;
+                        case S_POLE:
+                            lp_lat = - asin(cosz);
+                            break;
+                        }
+                        lp_lon = atan2(xy_x, xy_y);
+                    }
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_nsper& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                if ((proj_parm.height = pj_param(par.params, "dh").f) <= 0.) throw proj_exception(-30);
+                if (fabs(fabs(par.phi0) - HALFPI) < EPS10)
+                    proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
+                else if (fabs(par.phi0) < EPS10)
+                    proj_parm.mode = EQUIT;
+                else {
+                    proj_parm.mode = OBLIQ;
+                    proj_parm.sinph0 = sin(par.phi0);
+                    proj_parm.cosph0 = cos(par.phi0);
+                }
+                proj_parm.pn1 = proj_parm.height / par.a;
+             /* normalize by radius */
+                proj_parm.p = 1. + proj_parm.pn1;
+                proj_parm.rp = 1. / proj_parm.p;
+                proj_parm.h = 1. / proj_parm.pn1;
+                proj_parm.pfact = (proj_parm.p + 1.) * proj_parm.h;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+
+            // Near-sided perspective
+            template <typename Parameters>
+            void setup_nsper(Parameters& par, par_nsper& proj_parm)
+            {
+                proj_parm.tilt = 0;
+                setup(par, proj_parm);
+            }
+
+            // Tilted perspective
+            template <typename Parameters>
+            void setup_tpers(Parameters& par, par_nsper& proj_parm)
+            {
+                double omega, gamma;
+                omega = pj_param(par.params, "dtilt").f * DEG_TO_RAD;
+                gamma = pj_param(par.params, "dazi").f * DEG_TO_RAD;
+                proj_parm.tilt = 1;
+                proj_parm.cg = cos(gamma);
+             proj_parm.sg = sin(gamma);
+                proj_parm.cw = cos(omega);
+             proj_parm.sw = sin(omega);
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::nsper
+    #endif // doxygen
+
+    /*!
+        \brief Near-sided perspective projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - h=
+        \par Example
+        \image html ex_nsper.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct nsper_spheroid : public detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline nsper_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::nsper::setup_nsper(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Tilted perspective projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - tilt= azi= h=
+        \par Example
+        \image html ex_tpers.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tpers_spheroid : public detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline tpers_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::nsper::setup_tpers(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class nsper_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<nsper_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class tpers_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<tpers_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void nsper_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("nsper", new nsper_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("tpers", new tpers_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/nzmg.hpp b/src/boost/geometry/extensions/gis/projections/proj/nzmg.hpp
new file mode 100644
index 0000000..e0a9589
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/nzmg.hpp
@@ -0,0 +1,196 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace nzmg{
+            static const double EPSLN = 1e-10;
+            static const double SEC5_TO_RAD = 0.4848136811095359935899141023;
+            static const double RAD_TO_SEC5 = 2.062648062470963551564733573;
+            static const int Nbf = 5;
+            static const int Ntpsi = 9;
+            static const int Ntphi = 8;
+
+
+
+
+
+                static COMPLEX
+            bf[] = {
+                {.7557853228,    0.0},
+                {.249204646,    .003371507},
+                {-.001541739,    .041058560},
+                {-.10162907,    .01727609},
+                {-.26623489,    -.36249218},
+                {-.6870983,    -1.1651967} };
+                static double
+            tphi[] = { 1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594,
+                .007317, .01220, .00394, -.0013 },
+            tpsi[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879,
+                -.0055161, .0026906, -.001333, .00067, -.00034 };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_nzmg_ellipsoid : public base_t_fi<base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_nzmg_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    COMPLEX p;
+                    double *C;
+                    int i;
+
+                    lp_lat = (lp_lat - this->m_par.phi0) * RAD_TO_SEC5;
+                    for (p.r = *(C = tpsi + (i = Ntpsi)); i ; --i)
+                        p.r = *--C + lp_lat * p.r;
+                    p.r *= lp_lat;
+                    p.i = lp_lon;
+                    p = pj_zpoly1(p, bf, Nbf);
+                    xy_x = p.i;
+                    xy_y = p.r;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    int nn, i;
+                    COMPLEX p, f, fp, dp;
+                    double den, *C;
+
+                    p.r = xy_y;
+                    p.i = xy_x;
+                    for (nn = 20; nn ;--nn) {
+                        f = pj_zpolyd1(p, bf, Nbf, &fp);
+                        f.r -= xy_y;
+                        f.i -= xy_x;
+                        den = fp.r * fp.r + fp.i * fp.i;
+                        p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den;
+                        p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den;
+                        if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
+                            break;
+                    }
+                    if (nn) {
+                        lp_lon = p.i;
+                        for (lp_lat = *(C = tphi + (i = Ntphi)); i ; --i)
+                            lp_lat = *--C + p.r * lp_lat;
+                        lp_lat = this->m_par.phi0 + p.r * lp_lat * SEC5_TO_RAD;
+                    } else
+                        lp_lon = lp_lat = HUGE_VAL;
+                }
+            };
+
+            // New Zealand Map Grid
+            template <typename Parameters>
+            void setup_nzmg(Parameters& par)
+            {
+                /* force to International major axis */
+                par.ra = 1. / (par.a = 6378388.0);
+                par.lam0 = DEG_TO_RAD * 173.;
+                par.phi0 = DEG_TO_RAD * -41.;
+                par.x0 = 2510000.;
+                par.y0 = 6023150.;
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::nzmg
+    #endif // doxygen
+
+    /*!
+        \brief New Zealand Map Grid projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - fixed Earth
+        \par Example
+        \image html ex_nzmg.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct nzmg_ellipsoid : public detail::nzmg::base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline nzmg_ellipsoid(const Parameters& par) : detail::nzmg::base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::nzmg::setup_nzmg(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class nzmg_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<nzmg_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void nzmg_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("nzmg", new nzmg_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp b/src/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp
new file mode 100644
index 0000000..6e2f313
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp
@@ -0,0 +1,318 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/shared_ptr.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+    template <typename Geographic, typename Cartesian, typename Parameters> class factory;
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace ob_tran{
+            static const double TOL = 1e-10;
+
+            template <typename Geographic, typename Cartesian>
+            struct par_ob_tran
+            {
+                boost::shared_ptr<projection<Geographic, Cartesian> > link;
+                double    lamp;
+                double    cphip, sphip;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_ob_tran_oblique : public base_t_fi<base_ob_tran_oblique<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_ob_tran<Geographic, Cartesian> m_proj_parm;
+
+                inline base_ob_tran_oblique(const Parameters& par)
+                    : base_t_fi<base_ob_tran_oblique<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double coslam, sinphi, cosphi;
+
+
+
+                    coslam = cos(lp_lon);
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), this->m_proj_parm.sphip * cosphi * coslam +
+                        this->m_proj_parm.cphip * sinphi) + this->m_proj_parm.lamp);
+                    lp_lat = aasin(this->m_proj_parm.sphip * sinphi - this->m_proj_parm.cphip * cosphi * coslam);
+                    m_proj_parm.link->fwd(lp_lon, lp_lat, xy_x, xy_y);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double coslam, sinphi, cosphi;
+
+                    m_proj_parm.link->inv(xy_x, xy_y, lp_lon, lp_lat);
+                    if (lp_lon != HUGE_VAL) {
+                        coslam = cos(lp_lon -= this->m_proj_parm.lamp);
+                        sinphi = sin(lp_lat);
+                        cosphi = cos(lp_lat);
+                        lp_lat = aasin(this->m_proj_parm.sphip * sinphi + this->m_proj_parm.cphip * cosphi * coslam);
+                        lp_lon = aatan2(cosphi * sin(lp_lon), this->m_proj_parm.sphip * cosphi * coslam -
+                            this->m_proj_parm.cphip * sinphi);
+                    }
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_ob_tran_transverse : public base_t_fi<base_ob_tran_transverse<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_ob_tran<Geographic, Cartesian> m_proj_parm;
+
+                inline base_ob_tran_transverse(const Parameters& par)
+                    : base_t_fi<base_ob_tran_transverse<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double cosphi, coslam;
+
+
+
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), sin(lp_lat)) + this->m_proj_parm.lamp);
+                    lp_lat = aasin(- cosphi * coslam);
+                    m_proj_parm.link->fwd(lp_lon, lp_lat, xy_x, xy_y);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double cosphi, t;
+
+                    m_proj_parm.link->inv(xy_x, xy_y, lp_lon, lp_lat);
+                    if (lp_lon != HUGE_VAL) {
+                        cosphi = cos(lp_lat);
+                        t = lp_lon - this->m_proj_parm.lamp;
+                        lp_lon = aatan2(cosphi * sin(t), - sin(lp_lat));
+                        lp_lat = aasin(cosphi * cos(t));
+                    }
+                }
+            };
+
+            // General Oblique Transformation
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            double setup_ob_tran(Parameters& par, par_ob_tran<Geographic, Cartesian>& proj_parm, bool create = true)
+            {
+                int i;
+                double phip;
+
+
+                Parameters pj;
+                /* copy existing header into new */
+                par.es = 0.;
+             /* force to spherical */
+                pj.params = par.params;
+                pj.over = par.over;
+                pj.geoc = par.geoc;
+                pj.a = par.a;
+                pj.es = par.es;
+                pj.ra = par.ra;
+                pj.lam0 = par.lam0;
+                pj.phi0 = par.phi0;
+                pj.x0 = par.x0;
+                pj.y0 = par.y0;
+                pj.k0 = par.k0;
+                /* force spherical earth */
+                pj.one_es = pj.rone_es = 1.;
+                pj.es = pj.e = 0.;
+                pj.name = pj_param(par.params, "so_proj").s;
+
+                factory<Geographic, Cartesian, Parameters> fac;
+                if (create)
+                {
+                    proj_parm.link.reset(fac.create_new(pj));
+                    if (! proj_parm.link.get()) throw proj_exception(-26);
+                }
+                if (pj_param(par.params, "to_alpha").i) {
+                    double lamc, phic, alpha;
+                    lamc    = pj_param(par.params, "ro_lon_c").f;
+                    phic    = pj_param(par.params, "ro_lat_c").f;
+                    alpha    = pj_param(par.params, "ro_alpha").f;
+            /*
+                    if (fabs(phic) <= TOL ||
+                        fabs(fabs(phic) - HALFPI) <= TOL ||
+                        fabs(fabs(alpha) - HALFPI) <= TOL)
+            */
+                    if (fabs(fabs(phic) - HALFPI) <= TOL)
+                        throw proj_exception(-32);
+                    proj_parm.lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
+                    phip = aasin(cos(phic) * sin(alpha));
+                } else if (pj_param(par.params, "to_lat_p").i) { /* specified new pole */
+                    proj_parm.lamp = pj_param(par.params, "ro_lon_p").f;
+                    phip = pj_param(par.params, "ro_lat_p").f;
+                } else { /* specified new "equator" points */
+                    double lam1, lam2, phi1, phi2, con;
+                    lam1 = pj_param(par.params, "ro_lon_1").f;
+                    phi1 = pj_param(par.params, "ro_lat_1").f;
+                    lam2 = pj_param(par.params, "ro_lon_2").f;
+                    phi2 = pj_param(par.params, "ro_lat_2").f;
+                    if (fabs(phi1 - phi2) <= TOL ||
+                        (con = fabs(phi1)) <= TOL ||
+                        fabs(con - HALFPI) <= TOL ||
+                        fabs(fabs(phi2) - HALFPI) <= TOL) throw proj_exception(-33);
+                    proj_parm.lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
+                        sin(phi1) * cos(phi2) * cos(lam2),
+                        sin(phi1) * cos(phi2) * sin(lam2) -
+                        cos(phi1) * sin(phi2) * sin(lam1));
+                    phip = atan(-cos(proj_parm.lamp - lam1) / tan(phi1));
+                }
+                if (fabs(phip) > TOL) { /* oblique */
+                    proj_parm.cphip = cos(phip);
+                    proj_parm.sphip = sin(phip);
+                // par.fwd = o_forward;
+                // par.inv = pj.inv ? o_inverse : 0;
+                } else { /* transverse */
+                // par.fwd = t_forward;
+                // par.inv = pj.inv ? t_inverse : 0;
+                }
+                boost::ignore_unused_variable_warning(i);
+                // return phip to choose model
+                return phip;
+            }
+
+        }} // namespace detail::ob_tran
+    #endif // doxygen
+
+    /*!
+        \brief General Oblique Transformation projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - o_proj= plus parameters for projection
+         - o_lat_p= o_lon_p= (new pole) or
+         - o_alpha= o_lon_c= o_lat_c= or
+         - o_lon_1= o_lat_1= o_lon_2= o_lat_2=
+        \par Example
+        \image html ex_ob_tran.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<Geographic, Cartesian, Parameters>
+    {
+        inline ob_tran_oblique(const Parameters& par) : detail::ob_tran::base_ob_tran_oblique<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief General Oblique Transformation projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - o_proj= plus parameters for projection
+         - o_lat_p= o_lon_p= (new pole) or
+         - o_alpha= o_lon_c= o_lat_c= or
+         - o_lon_1= o_lat_1= o_lon_2= o_lat_2=
+        \par Example
+        \image html ex_ob_tran.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<Geographic, Cartesian, Parameters>
+    {
+        inline ob_tran_transverse(const Parameters& par) : detail::ob_tran::base_ob_tran_transverse<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class ob_tran_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    detail::ob_tran::par_ob_tran<Geographic, Cartesian> proj_parm;
+                    Parameters p = par;
+                    double phip = setup_ob_tran(p, proj_parm, false);
+                    if (fabs(phip) > detail::ob_tran::TOL)
+                        return new base_v_fi<ob_tran_oblique<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<ob_tran_transverse<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void ob_tran_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("ob_tran", new ob_tran_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/ocea.hpp b/src/boost/geometry/extensions/gis/projections/proj/ocea.hpp
new file mode 100644
index 0000000..2cf4d50
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/ocea.hpp
@@ -0,0 +1,189 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace ocea{
+
+            struct par_ocea
+            {
+                double    rok;
+                double    rtk;
+                double    sinphi;
+                double    cosphi;
+                double    singam;
+                double    cosgam;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_ocea_spheroid : public base_t_fi<base_ocea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_ocea m_proj_parm;
+
+                inline base_ocea_spheroid(const Parameters& par)
+                    : base_t_fi<base_ocea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double t;
+
+                    xy_y = sin(lp_lon);
+                /*
+                    xy_x = atan2((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) , cos(lp_lon));
+                */
+                    t = cos(lp_lon);
+                    xy_x = atan((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) / t);
+                    if (t < 0.)
+                        xy_x += PI;
+                    xy_x *= this->m_proj_parm.rtk;
+                    xy_y = this->m_proj_parm.rok * (this->m_proj_parm.sinphi * sin(lp_lat) - this->m_proj_parm.cosphi * cos(lp_lat) * xy_y);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t, s;
+
+                    xy_y /= this->m_proj_parm.rok;
+                    xy_x /= this->m_proj_parm.rtk;
+                    t = sqrt(1. - xy_y * xy_y);
+                    lp_lat = asin(xy_y * this->m_proj_parm.sinphi + t * this->m_proj_parm.cosphi * (s = sin(xy_x)));
+                    lp_lon = atan2(t * this->m_proj_parm.sinphi * s - xy_y * this->m_proj_parm.cosphi,
+                        t * cos(xy_x));
+                }
+            };
+
+            // Oblique Cylindrical Equal Area
+            template <typename Parameters>
+            void setup_ocea(Parameters& par, par_ocea& proj_parm)
+            {
+                double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
+                proj_parm.rok = par.a / par.k0;
+                proj_parm.rtk = par.a * par.k0;
+                if ( pj_param(par.params, "talpha").i) {
+                    alpha    = pj_param(par.params, "ralpha").f;
+                    lonz = pj_param(par.params, "rlonc").f;
+                    proj_parm.singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
+                    proj_parm.sinphi = asin(cos(phi_0) * sin(alpha));
+                } else {
+                    phi_1 = pj_param(par.params, "rlat_1").f;
+                    phi_2 = pj_param(par.params, "rlat_2").f;
+                    lam_1 = pj_param(par.params, "rlon_1").f;
+                    lam_2 = pj_param(par.params, "rlon_2").f;
+                    proj_parm.singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
+                        sin(phi_1) * cos(phi_2) * cos(lam_2),
+                        sin(phi_1) * cos(phi_2) * sin(lam_2) -
+                        cos(phi_1) * sin(phi_2) * sin(lam_1) );
+                    proj_parm.sinphi = atan(-cos(proj_parm.singam - lam_1) / tan(phi_1));
+                }
+                par.lam0 = proj_parm.singam + HALFPI;
+                proj_parm.cosphi = cos(proj_parm.sinphi);
+                proj_parm.sinphi = sin(proj_parm.sinphi);
+                proj_parm.cosgam = cos(proj_parm.singam);
+                proj_parm.singam = sin(proj_parm.singam);
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::ocea
+    #endif // doxygen
+
+    /*!
+        \brief Oblique Cylindrical Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Sph lonc= alpha= or
+         - lat_1= lat_2= lon_1= lon_2=
+        \par Example
+        \image html ex_ocea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::ocea::setup_ocea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class ocea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<ocea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void ocea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("ocea", new ocea_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/oea.hpp b/src/boost/geometry/extensions/gis/projections/proj/oea.hpp
new file mode 100644
index 0000000..238bc37
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/oea.hpp
@@ -0,0 +1,181 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace oea{
+
+            struct par_oea
+            {
+                double    theta;
+                double    m, n;
+                double    two_r_m, two_r_n, rm, rn, hm, hn;
+                double    cp0, sp0;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_oea_spheroid : public base_t_fi<base_oea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_oea m_proj_parm;
+
+                inline base_oea_spheroid(const Parameters& par)
+                    : base_t_fi<base_oea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double Az, M, N, cp, sp, cl, shz;
+
+                    cp = cos(lp_lat);
+                    sp = sin(lp_lat);
+                    cl = cos(lp_lon);
+                    Az = aatan2(cp * sin(lp_lon), this->m_proj_parm.cp0 * sp - this->m_proj_parm.sp0 * cp * cl) + this->m_proj_parm.theta;
+                    shz = sin(0.5 * aacos(this->m_proj_parm.sp0 * sp + this->m_proj_parm.cp0 * cp * cl));
+                    M = aasin(shz * sin(Az));
+                    N = aasin(shz * cos(Az) * cos(M) / cos(M * this->m_proj_parm.two_r_m));
+                    xy_y = this->m_proj_parm.n * sin(N * this->m_proj_parm.two_r_n);
+                    xy_x = this->m_proj_parm.m * sin(M * this->m_proj_parm.two_r_m) * cos(N) / cos(N * this->m_proj_parm.two_r_n);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double N, M, xp, yp, z, Az, cz, sz, cAz;
+
+                    N = this->m_proj_parm.hn * aasin(xy_y * this->m_proj_parm.rn);
+                    M = this->m_proj_parm.hm * aasin(xy_x * this->m_proj_parm.rm * cos(N * this->m_proj_parm.two_r_n) / cos(N));
+                    xp = 2. * sin(M);
+                    yp = 2. * sin(N) * cos(M * this->m_proj_parm.two_r_m) / cos(M);
+                    cAz = cos(Az = aatan2(xp, yp) - this->m_proj_parm.theta);
+                    z = 2. * aasin(0.5 * boost::math::hypot(xp, yp));
+                    sz = sin(z);
+                    cz = cos(z);
+                    lp_lat = aasin(this->m_proj_parm.sp0 * cz + this->m_proj_parm.cp0 * sz * cAz);
+                    lp_lon = aatan2(sz * sin(Az),
+                        this->m_proj_parm.cp0 * cz - this->m_proj_parm.sp0 * sz * cAz);
+                }
+            };
+
+            // Oblated Equal Area
+            template <typename Parameters>
+            void setup_oea(Parameters& par, par_oea& proj_parm)
+            {
+                if (((proj_parm.n = pj_param(par.params, "dn").f) <= 0.) ||
+                    ((proj_parm.m = pj_param(par.params, "dm").f) <= 0.))
+                    throw proj_exception(-39);
+                else {
+                    proj_parm.theta = pj_param(par.params, "rtheta").f;
+                    proj_parm.sp0 = sin(par.phi0);
+                    proj_parm.cp0 = cos(par.phi0);
+                    proj_parm.rn = 1./ proj_parm.n;
+                    proj_parm.rm = 1./ proj_parm.m;
+                    proj_parm.two_r_n = 2. * proj_parm.rn;
+                    proj_parm.two_r_m = 2. * proj_parm.rm;
+                    proj_parm.hm = 0.5 * proj_parm.m;
+                    proj_parm.hn = 0.5 * proj_parm.n;
+                // par.fwd = s_forward;
+                // par.inv = s_inverse;
+                    par.es = 0.;
+                }
+            }
+
+        }} // namespace detail::oea
+    #endif // doxygen
+
+    /*!
+        \brief Oblated Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - n= m= theta=
+        \par Example
+        \image html ex_oea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct oea_spheroid : public detail::oea::base_oea_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline oea_spheroid(const Parameters& par) : detail::oea::base_oea_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::oea::setup_oea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class oea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<oea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void oea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("oea", new oea_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_OEA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/omerc.hpp b/src/boost/geometry/extensions/gis/projections/proj/omerc.hpp
new file mode 100644
index 0000000..4f578d1
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/omerc.hpp
@@ -0,0 +1,295 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace omerc{
+            static const double TOL = 1.e-7;
+            static const double EPS = 1.e-10;
+
+                inline double TSFN0(double x)
+                    {return tan(.5 * (HALFPI - (x))); }
+
+
+            struct par_omerc
+            {
+                double    A, B, E, AB, ArB, BrA, rB, singam, cosgam, sinrot, cosrot;
+                double  v_pole_n, v_pole_s, u_0;
+                int no_rot;
+            };
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_omerc_ellipsoid : public base_t_fi<base_omerc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_omerc m_proj_parm;
+
+                inline base_omerc_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_omerc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  Q, S, T, U, V, temp, u, v;
+
+                    if (fabs(fabs(lp_lat) - HALFPI) > EPS) {
+                        Q = this->m_proj_parm.E / pow(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e), this->m_proj_parm.B);
+                        temp = 1. / Q;
+                        S = .5 * (Q - temp);
+                        T = .5 * (Q + temp);
+                        V = sin(this->m_proj_parm.B * lp_lon);
+                        U = (S * this->m_proj_parm.singam - V * this->m_proj_parm.cosgam) / T;
+                        if (fabs(fabs(U) - 1.0) < EPS)
+                            throw proj_exception();;
+                        v = 0.5 * this->m_proj_parm.ArB * log((1. - U)/(1. + U));
+                        temp = cos(this->m_proj_parm.B * lp_lon);
+                        u = (fabs(temp) < TOL) ? this->m_proj_parm.AB * lp_lon :
+                            this->m_proj_parm.ArB * atan2((S * this->m_proj_parm.cosgam + V * this->m_proj_parm.singam) , temp);
+                    } else {
+                        v = lp_lat > 0 ? this->m_proj_parm.v_pole_n : this->m_proj_parm.v_pole_s;
+                        u = this->m_proj_parm.ArB * lp_lat;
+                    }
+                    if (this->m_proj_parm.no_rot) {
+                        xy_x = u;
+                        xy_y = v;
+                    } else {
+                        u -= this->m_proj_parm.u_0;
+                        xy_x = v * this->m_proj_parm.cosrot + u * this->m_proj_parm.sinrot;
+                        xy_y = u * this->m_proj_parm.cosrot - v * this->m_proj_parm.sinrot;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double  u, v, Qp, Sp, Tp, Vp, Up;
+
+                    if (this->m_proj_parm.no_rot) {
+                        v = xy_y;
+                        u = xy_x;
+                    } else {
+                        v = xy_x * this->m_proj_parm.cosrot - xy_y * this->m_proj_parm.sinrot;
+                        u = xy_y * this->m_proj_parm.cosrot + xy_x * this->m_proj_parm.sinrot + this->m_proj_parm.u_0;
+                    }
+                    Qp = exp(- this->m_proj_parm.BrA * v);
+                    Sp = .5 * (Qp - 1. / Qp);
+                    Tp = .5 * (Qp + 1. / Qp);
+                    Vp = sin(this->m_proj_parm.BrA * u);
+                    Up = (Vp * this->m_proj_parm.cosgam + Sp * this->m_proj_parm.singam) / Tp;
+                    if (fabs(fabs(Up) - 1.) < EPS) {
+                        lp_lon = 0.;
+                        lp_lat = Up < 0. ? -HALFPI : HALFPI;
+                    } else {
+                        lp_lat = this->m_proj_parm.E / sqrt((1. + Up) / (1. - Up));
+                        if ((lp_lat = pj_phi2(pow(lp_lat, 1. / this->m_proj_parm.B), this->m_par.e)) == HUGE_VAL)
+                            throw proj_exception();;
+                        lp_lon = - this->m_proj_parm.rB * atan2((Sp * this->m_proj_parm.cosgam -
+                            Vp * this->m_proj_parm.singam), cos(this->m_proj_parm.BrA * u));
+                    }
+                }
+            };
+
+            // Oblique Mercator
+            template <typename Parameters>
+            void setup_omerc(Parameters& par, par_omerc& proj_parm)
+            {
+                double con, com, cosph0, D, F, H, L, sinph0, p, J, gamma,
+                    gamma0, lamc, lam1, lam2, phi1, phi2, alpha_c;
+                int alp, gam, no_off = 0;
+                proj_parm.no_rot = pj_param(par.params, "tno_rot").i;
+                if ((alp = pj_param(par.params, "talpha").i))
+                    alpha_c = pj_param(par.params, "ralpha").f;
+                if ((gam = pj_param(par.params, "tgamma").i))
+                    gamma = pj_param(par.params, "rgamma").f;
+                if (alp || gam) {
+                    lamc    = pj_param(par.params, "rlonc").f;
+                    no_off = pj_param(par.params, "tno_off").i;
+                } else {
+                    lam1 = pj_param(par.params, "rlon_1").f;
+                    phi1 = pj_param(par.params, "rlat_1").f;
+                    lam2 = pj_param(par.params, "rlon_2").f;
+                    phi2 = pj_param(par.params, "rlat_2").f;
+                    if (fabs(phi1 - phi2) <= TOL ||
+                        (con = fabs(phi1)) <= TOL ||
+                        fabs(con - HALFPI) <= TOL ||
+                        fabs(fabs(par.phi0) - HALFPI) <= TOL ||
+                        fabs(fabs(phi2) - HALFPI) <= TOL) throw proj_exception(-33);
+                }
+                com = sqrt(par.one_es);
+                if (fabs(par.phi0) > EPS) {
+                    sinph0 = sin(par.phi0);
+                    cosph0 = cos(par.phi0);
+                    con = 1. - par.es * sinph0 * sinph0;
+                    proj_parm.B = cosph0 * cosph0;
+                    proj_parm.B = sqrt(1. + par.es * proj_parm.B * proj_parm.B / par.one_es);
+                    proj_parm.A = proj_parm.B * par.k0 * com / con;
+                    D = proj_parm.B * com / (cosph0 * sqrt(con));
+                    if ((F = D * D - 1.) <= 0.)
+                        F = 0.;
+                    else {
+                        F = sqrt(F);
+                        if (par.phi0 < 0.)
+                            F = -F;
+                    }
+                    proj_parm.E = F += D;
+                    proj_parm.E *= pow(pj_tsfn(par.phi0, sinph0, par.e), proj_parm.B);
+                } else {
+                    proj_parm.B = 1. / com;
+                    proj_parm.A = par.k0;
+                    proj_parm.E = D = F = 1.;
+                }
+                if (alp || gam) {
+                    if (alp) {
+                        gamma0 = asin(sin(alpha_c) / D);
+                        if (!gam)
+                            gamma = alpha_c;
+                    } else
+                        alpha_c = asin(D*sin(gamma0 = gamma));
+                    if ((con = fabs(alpha_c)) <= TOL ||
+                        fabs(con - PI) <= TOL ||
+                        fabs(fabs(par.phi0) - HALFPI) <= TOL)
+                        throw proj_exception(-32);
+                    par.lam0 = lamc - asin(.5 * (F - 1. / F) *
+                       tan(gamma0)) / proj_parm.B;
+                } else {
+                    H = pow(pj_tsfn(phi1, sin(phi1), par.e), proj_parm.B);
+                    L = pow(pj_tsfn(phi2, sin(phi2), par.e), proj_parm.B);
+                    F = proj_parm.E / H;
+                    p = (L - H) / (L + H);
+                    J = proj_parm.E * proj_parm.E;
+                    J = (J - L * H) / (J + L * H);
+                    if ((con = lam1 - lam2) < -PI)
+                        lam2 -= TWOPI;
+                    else if (con > PI)
+                        lam2 += TWOPI;
+                    par.lam0 = adjlon(.5 * (lam1 + lam2) - atan(
+                       J * tan(.5 * proj_parm.B * (lam1 - lam2)) / p) / proj_parm.B);
+                    gamma0 = atan(2. * sin(proj_parm.B * adjlon(lam1 - par.lam0)) /
+                       (F - 1. / F));
+                    gamma = alpha_c = asin(D * sin(gamma0));
+                }
+                proj_parm.singam = sin(gamma0);
+                proj_parm.cosgam = cos(gamma0);
+                proj_parm.sinrot = sin(gamma);
+                proj_parm.cosrot = cos(gamma);
+                proj_parm.BrA = 1. / (proj_parm.ArB = proj_parm.A * (proj_parm.rB = 1. / proj_parm.B));
+                proj_parm.AB = proj_parm.A * proj_parm.B;
+                if (no_off)
+                    proj_parm.u_0 = 0;
+                else {
+                    proj_parm.u_0 = fabs(proj_parm.ArB * atan2(sqrt(D * D - 1.), cos(alpha_c)));
+                    if (par.phi0 < 0.)
+                        proj_parm.u_0 = - proj_parm.u_0;
+                }
+                F = 0.5 * gamma0;
+                proj_parm.v_pole_n = proj_parm.ArB * log(tan(FORTPI - F));
+                proj_parm.v_pole_s = proj_parm.ArB * log(tan(FORTPI + F));
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::omerc
+    #endif // doxygen
+
+    /*!
+        \brief Oblique Mercator projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ell no_rot
+         - alpha= [gamma=] [no_off] lonc= or
+         - lon_1= lat_1= lon_2= lat_2=
+        \par Example
+        \image html ex_omerc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct omerc_ellipsoid : public detail::omerc::base_omerc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline omerc_ellipsoid(const Parameters& par) : detail::omerc::base_omerc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::omerc::setup_omerc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class omerc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<omerc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void omerc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("omerc", new omerc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_OMERC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/ortho.hpp b/src/boost/geometry/extensions/gis/projections/proj/ortho.hpp
new file mode 100644
index 0000000..6064b27
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/ortho.hpp
@@ -0,0 +1,219 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace ortho{
+            static const double EPS10 = 1.e-10;
+            static const int N_POLE = 0;
+            static const int S_POLE = 1;
+            static const int EQUIT = 2;
+            static const int OBLIQ = 3;
+
+            struct par_ortho
+            {
+                double    sinph0;
+                double    cosph0;
+                int        mode;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_ortho_spheroid : public base_t_fi<base_ortho_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_ortho m_proj_parm;
+
+                inline base_ortho_spheroid(const Parameters& par)
+                    : base_t_fi<base_ortho_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  coslam, cosphi, sinphi;
+
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        if (cosphi * coslam < - EPS10) throw proj_exception();;
+                        xy_y = sin(lp_lat);
+                        break;
+                    case OBLIQ:
+                        if (this->m_proj_parm.sinph0 * (sinphi = sin(lp_lat)) +
+                           this->m_proj_parm.cosph0 * cosphi * coslam < - EPS10) throw proj_exception();;
+                        xy_y = this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam;
+                        break;
+                    case N_POLE:
+                        coslam = - coslam;
+                    case S_POLE:
+                        if (fabs(lp_lat - this->m_par.phi0) - EPS10 > HALFPI) throw proj_exception();;
+                        xy_y = cosphi * coslam;
+                        break;
+                    }
+                    xy_x = cosphi * sin(lp_lon);
+                            return;
+                }
+
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double  rh, cosc, sinc;
+
+                    if ((sinc = (rh = boost::math::hypot(xy_x, xy_y))) > 1.) {
+                        if ((sinc - 1.) > EPS10) throw proj_exception();;
+                        sinc = 1.;
+                    }
+                    cosc = sqrt(1. - sinc * sinc); /* in this range OK */
+                    if (fabs(rh) <= EPS10) {
+                        lp_lat = this->m_par.phi0;
+                        lp_lon = 0.0;
+                    } else {
+                        switch (this->m_proj_parm.mode) {
+                        case N_POLE:
+                            xy_y = -xy_y;
+                            lp_lat = acos(sinc);
+                            break;
+                        case S_POLE:
+                            lp_lat = - acos(sinc);
+                            break;
+                        case EQUIT:
+                            lp_lat = xy_y * sinc / rh;
+                            xy_x *= sinc;
+                            xy_y = cosc * rh;
+                            goto sinchk;
+                        case OBLIQ:
+                            lp_lat = cosc * this->m_proj_parm.sinph0 + xy_y * sinc * this->m_proj_parm.cosph0 /rh;
+                            xy_y = (cosc - this->m_proj_parm.sinph0 * lp_lat) * rh;
+                            xy_x *= sinc * this->m_proj_parm.cosph0;
+                        sinchk:
+                            if (fabs(lp_lat) >= 1.)
+                                lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
+                            else
+                                lp_lat = asin(lp_lat);
+                            break;
+                        }
+                        lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT))
+                             ? (xy_x == 0. ? 0. : xy_x < 0. ? -HALFPI : HALFPI)
+                                           : atan2(xy_x, xy_y);
+                    }
+                            return;
+                }
+
+            };
+
+            // Orthographic
+            template <typename Parameters>
+            void setup_ortho(Parameters& par, par_ortho& proj_parm)
+            {
+                if (fabs(fabs(par.phi0) - HALFPI) <= EPS10)
+                    proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
+                else if (fabs(par.phi0) > EPS10) {
+                    proj_parm.mode = OBLIQ;
+                    proj_parm.sinph0 = sin(par.phi0);
+                    proj_parm.cosph0 = cos(par.phi0);
+                } else
+                    proj_parm.mode = EQUIT;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::ortho
+    #endif // doxygen
+
+    /*!
+        \brief Orthographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+        \par Example
+        \image html ex_ortho.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct ortho_spheroid : public detail::ortho::base_ortho_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline ortho_spheroid(const Parameters& par) : detail::ortho::base_ortho_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::ortho::setup_ortho(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class ortho_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<ortho_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void ortho_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("ortho", new ortho_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ORTHO_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/poly.hpp b/src/boost/geometry/extensions/gis/projections/proj/poly.hpp
new file mode 100644
index 0000000..917ad6c
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/poly.hpp
@@ -0,0 +1,266 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_POLY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_POLY_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace poly{
+            static const double TOL = 1e-10;
+            static const double CONV = 1e-10;
+            static const int N_ITER = 10;
+            static const int I_ITER = 20;
+            static const double ITOL = 1.e-12;
+
+            struct par_poly
+            {
+                double ml0;
+                double en[EN_SIZE];
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_poly_ellipsoid : public base_t_fi<base_poly_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_poly m_proj_parm;
+
+                inline base_poly_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_poly_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  ms, sp, cp;
+
+                    if (fabs(lp_lat) <= TOL) { xy_x = lp_lon; xy_y = -this->m_proj_parm.ml0; }
+                    else {
+                        sp = sin(lp_lat);
+                        ms = fabs(cp = cos(lp_lat)) > TOL ? pj_msfn(sp, cp, this->m_par.es) / sp : 0.;
+                        xy_x = ms * sin(lp_lon *= sp);
+                        xy_y = (pj_mlfn(lp_lat, sp, cp, this->m_proj_parm.en) - this->m_proj_parm.ml0) + ms * (1. - cos(lp_lon));
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    xy_y += this->m_proj_parm.ml0;
+                    if (fabs(xy_y) <= TOL) { lp_lon = xy_x; lp_lat = 0.; }
+                    else {
+                        double r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi;
+                        int i;
+
+                        r = xy_y * xy_y + xy_x * xy_x;
+                        for (lp_lat = xy_y, i = I_ITER; i ; --i) {
+                            sp = sin(lp_lat);
+                            s2ph = sp * ( cp = cos(lp_lat));
+                            if (fabs(cp) < ITOL)
+                                throw proj_exception();;
+                            c = sp * (mlp = sqrt(1. - this->m_par.es * sp * sp)) / cp;
+                            ml = pj_mlfn(lp_lat, sp, cp, this->m_proj_parm.en);
+                            mlb = ml * ml + r;
+                            mlp = this->m_par.one_es / (mlp * mlp * mlp);
+                            lp_lat += ( dPhi =
+                                ( ml + ml + c * mlb - 2. * xy_y * (c * ml + 1.) ) / (
+                                this->m_par.es * s2ph * (mlb - 2. * xy_y * ml) / c +
+                                2.* (xy_y - ml) * (c * mlp - 1. / s2ph) - mlp - mlp ));
+                            if (fabs(dPhi) <= ITOL)
+                                break;
+                        }
+                        if (!i)
+                            throw proj_exception();;
+                        c = sin(lp_lat);
+                        lp_lon = asin(xy_x * tan(lp_lat) * sqrt(1. - this->m_par.es * c * c)) / sin(lp_lat);
+                    }
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_poly_spheroid : public base_t_fi<base_poly_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_poly m_proj_parm;
+
+                inline base_poly_spheroid(const Parameters& par)
+                    : base_t_fi<base_poly_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  cot, E;
+
+                    if (fabs(lp_lat) <= TOL) { xy_x = lp_lon; xy_y = this->m_proj_parm.ml0; }
+                    else {
+                        cot = 1. / tan(lp_lat);
+                        xy_x = sin(E = lp_lon * sin(lp_lat)) * cot;
+                        xy_y = lp_lat - this->m_par.phi0 + cot * (1. - cos(E));
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double B, dphi, tp;
+                    int i;
+
+                    if (fabs(xy_y = this->m_par.phi0 + xy_y) <= TOL) { lp_lon = xy_x; lp_lat = 0.; }
+                    else {
+                        lp_lat = xy_y;
+                        B = xy_x * xy_x + xy_y * xy_y;
+                        i = N_ITER;
+                        do {
+                            tp = tan(lp_lat);
+                            lp_lat -= (dphi = (xy_y * (lp_lat * tp + 1.) - lp_lat -
+                                .5 * ( lp_lat * lp_lat + B) * tp) /
+                                ((lp_lat - xy_y) / tp - 1.));
+                        } while (fabs(dphi) > CONV && --i);
+                        if (! i) throw proj_exception();;
+                        lp_lon = asin(xy_x * tan(lp_lat)) / sin(lp_lat);
+                    }
+                }
+            };
+
+            // Polyconic (American)
+            template <typename Parameters>
+            void setup_poly(Parameters& par, par_poly& proj_parm)
+            {
+                if (par.es) {
+                    pj_enfn(par.es, proj_parm.en);
+                    proj_parm.ml0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    proj_parm.ml0 = -par.phi0;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+        }} // namespace detail::poly
+    #endif // doxygen
+
+    /*!
+        \brief Polyconic (American) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_poly.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct poly_ellipsoid : public detail::poly::base_poly_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline poly_ellipsoid(const Parameters& par) : detail::poly::base_poly_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::poly::setup_poly(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Polyconic (American) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_poly.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct poly_spheroid : public detail::poly::base_poly_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline poly_spheroid(const Parameters& par) : detail::poly::base_poly_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::poly::setup_poly(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class poly_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<poly_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<poly_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void poly_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("poly", new poly_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_POLY_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/putp2.hpp b/src/boost/geometry/extensions/gis/projections/proj/putp2.hpp
new file mode 100644
index 0000000..2cadc58
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/putp2.hpp
@@ -0,0 +1,163 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace putp2{
+            static const double C_x = 1.89490;
+            static const double C_y = 1.71848;
+            static const double C_p = 0.6141848493043784;
+            static const double EPS = 1e-10;
+            static const int NITER = 10;
+            static const double PI_DIV_3 = 1.0471975511965977;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_putp2_spheroid : public base_t_fi<base_putp2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_putp2_spheroid(const Parameters& par)
+                    : base_t_fi<base_putp2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double p, c, s, V;
+                    int i;
+
+                    p = C_p * sin(lp_lat);
+                    s = lp_lat * lp_lat;
+                    lp_lat *= 0.615709 + s * ( 0.00909953 + s * 0.0046292 );
+                    for (i = NITER; i ; --i) {
+                        c = cos(lp_lat);
+                        s = sin(lp_lat);
+                        lp_lat -= V = (lp_lat + s * (c - 1.) - p) /
+                            (1. + c * (c - 1.) - s * s);
+                        if (fabs(V) < EPS)
+                            break;
+                    }
+                    if (!i)
+                        lp_lat = lp_lat < 0 ? - PI_DIV_3 : PI_DIV_3;
+                    xy_x = C_x * lp_lon * (cos(lp_lat) - 0.5);
+                    xy_y = C_y * sin(lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double c;
+
+                    lp_lat = aasin(xy_y / C_y);
+                    lp_lon = xy_x / (C_x * ((c = cos(lp_lat)) - 0.5));
+                    lp_lat = aasin((lp_lat + sin(lp_lat) * (c - 1.)) / C_p);
+                }
+            };
+
+            // Putnins P2
+            template <typename Parameters>
+            void setup_putp2(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::putp2
+    #endif // doxygen
+
+    /*!
+        \brief Putnins P2 projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp2.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp2_spheroid : public detail::putp2::base_putp2_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp2_spheroid(const Parameters& par) : detail::putp2::base_putp2_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp2::setup_putp2(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void putp2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("putp2", new putp2_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_PUTP2_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/putp3.hpp b/src/boost/geometry/extensions/gis/projections/proj/putp3.hpp
new file mode 100644
index 0000000..36623ed
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/putp3.hpp
@@ -0,0 +1,197 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace putp3{
+            static const double C = 0.79788456;
+            static const double RPISQ = 0.1013211836;
+
+            struct par_putp3
+            {
+                double    A;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_putp3_spheroid : public base_t_fi<base_putp3_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_putp3 m_proj_parm;
+
+                inline base_putp3_spheroid(const Parameters& par)
+                    : base_t_fi<base_putp3_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = C * lp_lon * (1. - this->m_proj_parm.A * lp_lat * lp_lat);
+                    xy_y = C * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / C;
+                    lp_lon = xy_x / (C * (1. - this->m_proj_parm.A * lp_lat * lp_lat));
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_putp3& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Putnins P3
+            template <typename Parameters>
+            void setup_putp3(Parameters& par, par_putp3& proj_parm)
+            {
+                proj_parm.A = 4. * RPISQ;
+                setup(par, proj_parm);
+            }
+
+            // Putnins P3'
+            template <typename Parameters>
+            void setup_putp3p(Parameters& par, par_putp3& proj_parm)
+            {
+                proj_parm.A = 2. * RPISQ;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::putp3
+    #endif // doxygen
+
+    /*!
+        \brief Putnins P3 projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp3.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp3_spheroid : public detail::putp3::base_putp3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp3_spheroid(const Parameters& par) : detail::putp3::base_putp3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp3::setup_putp3(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Putnins P3' projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - no inverse
+         - Spheroid
+        \par Example
+        \image html ex_putp3p.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp3p_spheroid : public detail::putp3::base_putp3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp3p_spheroid(const Parameters& par) : detail::putp3::base_putp3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp3::setup_putp3p(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp3p_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp3p_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void putp3_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("putp3", new putp3_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("putp3p", new putp3p_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_PUTP3_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/putp4p.hpp b/src/boost/geometry/extensions/gis/projections/proj/putp4p.hpp
new file mode 100644
index 0000000..32bf3a5
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/putp4p.hpp
@@ -0,0 +1,201 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace putp4p{
+
+            struct par_putp4p
+            {
+                double    C_x, C_y;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_putp4p_spheroid : public base_t_fi<base_putp4p_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_putp4p m_proj_parm;
+
+                inline base_putp4p_spheroid(const Parameters& par)
+                    : base_t_fi<base_putp4p_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    lp_lat = aasin(0.883883476 * sin(lp_lat));
+                    xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat);
+                    xy_x /= cos(lp_lat *= 0.333333333333333);
+                    xy_y = this->m_proj_parm.C_y * sin(lp_lat);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = aasin(xy_y / this->m_proj_parm.C_y);
+                    lp_lon = xy_x * cos(lp_lat) / this->m_proj_parm.C_x;
+                    lp_lat *= 3.;
+                    lp_lon /= cos(lp_lat);
+                    lp_lat = aasin(1.13137085 * sin(lp_lat));
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_putp4p& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Putnins P4'
+            template <typename Parameters>
+            void setup_putp4p(Parameters& par, par_putp4p& proj_parm)
+            {
+                proj_parm.C_x = 0.874038744;
+                proj_parm.C_y = 3.883251825;
+                setup(par, proj_parm);
+            }
+
+            // Werenskiold I
+            template <typename Parameters>
+            void setup_weren(Parameters& par, par_putp4p& proj_parm)
+            {
+                proj_parm.C_x = 1.;
+                proj_parm.C_y = 4.442882938;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::putp4p
+    #endif // doxygen
+
+    /*!
+        \brief Putnins P4' projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp4p.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp4p_spheroid : public detail::putp4p::base_putp4p_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp4p_spheroid(const Parameters& par) : detail::putp4p::base_putp4p_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp4p::setup_putp4p(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Werenskiold I projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_weren.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct weren_spheroid : public detail::putp4p::base_putp4p_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline weren_spheroid(const Parameters& par) : detail::putp4p::base_putp4p_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp4p::setup_weren(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp4p_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp4p_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class weren_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<weren_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void putp4p_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("putp4p", new putp4p_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("weren", new weren_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_PUTP4P_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/putp5.hpp b/src/boost/geometry/extensions/gis/projections/proj/putp5.hpp
new file mode 100644
index 0000000..959a0a1
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/putp5.hpp
@@ -0,0 +1,198 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace putp5{
+            static const double C = 1.01346;
+            static const double D = 1.2158542;
+
+            struct par_putp5
+            {
+                double    A, B;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_putp5_spheroid : public base_t_fi<base_putp5_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_putp5 m_proj_parm;
+
+                inline base_putp5_spheroid(const Parameters& par)
+                    : base_t_fi<base_putp5_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = C * lp_lon * (this->m_proj_parm.A - this->m_proj_parm.B * sqrt(1. + D * lp_lat * lp_lat));
+                    xy_y = C * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / C;
+                    lp_lon = xy_x / (C * (this->m_proj_parm.A - this->m_proj_parm.B * sqrt(1. + D * lp_lat * lp_lat)));
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_putp5& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Putnins P5
+            template <typename Parameters>
+            void setup_putp5(Parameters& par, par_putp5& proj_parm)
+            {
+                proj_parm.A = 2.;
+                proj_parm.B = 1.;
+                setup(par, proj_parm);
+            }
+
+            // Putnins P5'
+            template <typename Parameters>
+            void setup_putp5p(Parameters& par, par_putp5& proj_parm)
+            {
+                proj_parm.A = 1.5;
+                proj_parm.B = 0.5;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::putp5
+    #endif // doxygen
+
+    /*!
+        \brief Putnins P5 projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp5.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp5_spheroid : public detail::putp5::base_putp5_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp5_spheroid(const Parameters& par) : detail::putp5::base_putp5_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp5::setup_putp5(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Putnins P5' projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp5p.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp5p_spheroid : public detail::putp5::base_putp5_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp5p_spheroid(const Parameters& par) : detail::putp5::base_putp5_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp5::setup_putp5p(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp5p_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp5p_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void putp5_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("putp5", new putp5_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("putp5p", new putp5p_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_PUTP5_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/putp6.hpp b/src/boost/geometry/extensions/gis/projections/proj/putp6.hpp
new file mode 100644
index 0000000..425c8d9
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/putp6.hpp
@@ -0,0 +1,223 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace putp6{
+            static const double EPS = 1e-10;
+            static const int NITER = 10;
+            static const double CON_POLE = 1.732050807568877;
+
+            struct par_putp6
+            {
+                double C_x, C_y, A, B, D;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_putp6_spheroid : public base_t_fi<base_putp6_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_putp6 m_proj_parm;
+
+                inline base_putp6_spheroid(const Parameters& par)
+                    : base_t_fi<base_putp6_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double p, r, V;
+                    int i;
+
+                    p = this->m_proj_parm.B * sin(lp_lat);
+                    lp_lat *=  1.10265779;
+                    for (i = NITER; i ; --i) {
+                        r = sqrt(1. + lp_lat * lp_lat);
+                        lp_lat -= V = ( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) - p ) /
+                            (this->m_proj_parm.A - 2. * r);
+                        if (fabs(V) < EPS)
+                            break;
+                    }
+                    if (!i)
+                        lp_lat = p < 0. ? -CON_POLE : CON_POLE;
+                    xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.D - sqrt(1. + lp_lat * lp_lat));
+                    xy_y = this->m_proj_parm.C_y * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double r;
+
+                    lp_lat = xy_y / this->m_proj_parm.C_y;
+                    r = sqrt(1. + lp_lat * lp_lat);
+                    lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.D - r));
+                    lp_lat = aasin( ( (this->m_proj_parm.A - r) * lp_lat - log(lp_lat + r) ) / this->m_proj_parm.B);
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_putp6& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Putnins P6
+            template <typename Parameters>
+            void setup_putp6(Parameters& par, par_putp6& proj_parm)
+            {
+                proj_parm.C_x = 1.01346;
+                proj_parm.C_y = 0.91910;
+                proj_parm.A   = 4.;
+                proj_parm.B   = 2.1471437182129378784;
+                proj_parm.D   = 2.;
+                setup(par, proj_parm);
+            }
+
+            // Putnins P6'
+            template <typename Parameters>
+            void setup_putp6p(Parameters& par, par_putp6& proj_parm)
+            {
+                proj_parm.C_x = 0.44329;
+                proj_parm.C_y = 0.80404;
+                proj_parm.A   = 6.;
+                proj_parm.B   = 5.61125;
+                proj_parm.D   = 3.;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::putp6
+    #endif // doxygen
+
+    /*!
+        \brief Putnins P6 projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp6.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp6_spheroid : public detail::putp6::base_putp6_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp6_spheroid(const Parameters& par) : detail::putp6::base_putp6_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp6::setup_putp6(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Putnins P6' projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_putp6p.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct putp6p_spheroid : public detail::putp6::base_putp6_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline putp6p_spheroid(const Parameters& par) : detail::putp6::base_putp6_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::putp6::setup_putp6p(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp6_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp6_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class putp6p_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<putp6p_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void putp6_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("putp6", new putp6_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("putp6p", new putp6p_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_PUTP6_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/robin.hpp b/src/boost/geometry/extensions/gis/projections/proj/robin.hpp
new file mode 100644
index 0000000..44bd2be
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/robin.hpp
@@ -0,0 +1,232 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/function_overloads.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace robin{
+            static const double FXC = 0.8487;
+            static const double FYC = 1.3523;
+            static const double C1 = 11.45915590261646417544;
+            static const double RC1 = 0.08726646259971647884;
+            static const int NODES = 18;
+            static const double ONEEPS = 1.000001;
+            static const double EPS = 1e-8;
+
+            /* note: following terms based upon 5 deg. intervals in degrees. */
+            static struct COEFS {
+                double c0, c1, c2, c3;
+            } X[] = {
+            {1,    -5.67239e-12,    -7.15511e-05,    3.11028e-06},
+            {0.9986,    -0.000482241,    -2.4897e-05,    -1.33094e-06},
+            {0.9954,    -0.000831031,    -4.4861e-05,    -9.86588e-07},
+            {0.99,    -0.00135363,    -5.96598e-05,    3.67749e-06},
+            {0.9822,    -0.00167442,    -4.4975e-06,    -5.72394e-06},
+            {0.973,    -0.00214869,    -9.03565e-05,    1.88767e-08},
+            {0.96,    -0.00305084,    -9.00732e-05,    1.64869e-06},
+            {0.9427,    -0.00382792,    -6.53428e-05,    -2.61493e-06},
+            {0.9216,    -0.00467747,    -0.000104566,    4.8122e-06},
+            {0.8962,    -0.00536222,    -3.23834e-05,    -5.43445e-06},
+            {0.8679,    -0.00609364,    -0.0001139,    3.32521e-06},
+            {0.835,    -0.00698325,    -6.40219e-05,    9.34582e-07},
+            {0.7986,    -0.00755337,    -5.00038e-05,    9.35532e-07},
+            {0.7597,    -0.00798325,    -3.59716e-05,    -2.27604e-06},
+            {0.7186,    -0.00851366,    -7.0112e-05,    -8.63072e-06},
+            {0.6732,    -0.00986209,    -0.000199572,    1.91978e-05},
+            {0.6213,    -0.010418,    8.83948e-05,    6.24031e-06},
+            {0.5722,    -0.00906601,    0.000181999,    6.24033e-06},
+            {0.5322, 0.,0.,0.  }},
+            Y[] = {
+            {0,    0.0124,    3.72529e-10,    1.15484e-09},
+            {0.062,    0.0124001,    1.76951e-08,    -5.92321e-09},
+            {0.124,    0.0123998,    -7.09668e-08,    2.25753e-08},
+            {0.186,    0.0124008,    2.66917e-07,    -8.44523e-08},
+            {0.248,    0.0123971,    -9.99682e-07,    3.15569e-07},
+            {0.31,    0.0124108,    3.73349e-06,    -1.1779e-06},
+            {0.372,    0.0123598,    -1.3935e-05,    4.39588e-06},
+            {0.434,    0.0125501,    5.20034e-05,    -1.00051e-05},
+            {0.4968,    0.0123198,    -9.80735e-05,    9.22397e-06},
+            {0.5571,    0.0120308,    4.02857e-05,    -5.2901e-06},
+            {0.6176,    0.0120369,    -3.90662e-05,    7.36117e-07},
+            {0.6769,    0.0117015,    -2.80246e-05,    -8.54283e-07},
+            {0.7346,    0.0113572,    -4.08389e-05,    -5.18524e-07},
+            {0.7903,    0.0109099,    -4.86169e-05,    -1.0718e-06},
+            {0.8435,    0.0103433,    -6.46934e-05,    5.36384e-09},
+            {0.8936,    0.00969679,    -6.46129e-05,    -8.54894e-06},
+            {0.9394,    0.00840949,    -0.000192847,    -4.21023e-06},
+            {0.9761,    0.00616525,    -0.000256001,    -4.21021e-06},
+            {1., 0.,0.,0 }};
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_robin_spheroid : public base_t_fi<base_robin_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_robin_spheroid(const Parameters& par)
+                    : base_t_fi<base_robin_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline double  V(COEFS const& C, double z) const
+                { return (C.c0 + z * (C.c1 + z * (C.c2 + z * C.c3))); }
+                inline double DV(COEFS const& C, double z) const
+                { return (C.c1 + z * (C.c2 + C.c2 + z * 3. * C.c3)); }
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    int i;
+                    double dphi;
+
+                    i = int_floor((dphi = fabs(lp_lat)) * C1);
+                    if (i >= NODES) i = NODES - 1;
+                    dphi = RAD_TO_DEG * (dphi - RC1 * i);
+                    xy_x = V(X[i], dphi) * FXC * lp_lon;
+                    xy_y = V(Y[i], dphi) * FYC;
+                    if (lp_lat < 0.) xy_y = -xy_y;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    int i;
+                    double t, t1;
+                    struct COEFS T;
+
+                    lp_lon = xy_x / FXC;
+                    lp_lat = fabs(xy_y / FYC);
+                    if (lp_lat >= 1.) { /* simple pathologic cases */
+                        if (lp_lat > ONEEPS) throw proj_exception();
+                        else {
+                            lp_lat = xy_y < 0. ? -HALFPI : HALFPI;
+                            lp_lon /= X[NODES].c0;
+                        }
+                    } else { /* general problem */
+                        /* in Y space, reduce to table interval */
+                        for (i = int_floor(lp_lat * NODES);;) {
+                            if (Y[i].c0 > lp_lat) --i;
+                            else if (Y[i+1].c0 <= lp_lat) ++i;
+                            else break;
+                        }
+                        T = Y[i];
+                        /* first guess, linear interp */
+                        t = 5. * (lp_lat - T.c0)/(Y[i+1].c0 - T.c0);
+                        /* make into root */
+                        T.c0 -= lp_lat;
+                        for (;;) { /* Newton-Raphson reduction */
+                            t -= t1 = V(T,t) / DV(T,t);
+                            if (fabs(t1) < EPS)
+                                break;
+                        }
+                        lp_lat = (5 * i + t) * DEG_TO_RAD;
+                        if (xy_y < 0.) lp_lat = -lp_lat;
+                        lp_lon /= V(X[i], t);
+                    }
+                }
+            };
+
+            // Robinson
+            template <typename Parameters>
+            void setup_robin(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::robin
+    #endif // doxygen
+
+    /*!
+        \brief Robinson projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_robin.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct robin_spheroid : public detail::robin::base_robin_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline robin_spheroid(const Parameters& par) : detail::robin::base_robin_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::robin::setup_robin(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class robin_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<robin_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void robin_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("robin", new robin_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ROBIN_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/rouss.hpp b/src/boost/geometry/extensions/gis/projections/proj/rouss.hpp
new file mode 100644
index 0000000..5813d49
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/rouss.hpp
@@ -0,0 +1,211 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace rouss{
+
+            struct par_rouss
+            {
+                double s0;
+                double A1, A2, A3, A4, A5, A6;
+                double B1, B2, B3, B4, B5, B6, B7, B8;
+                double C1, C2, C3, C4, C5, C6, C7, C8;
+                double D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11;
+                MDIST en;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_rouss_ellipsoid : public base_t_fi<base_rouss_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_rouss m_proj_parm;
+
+                inline base_rouss_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_rouss_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double s, al, cp, sp, al2, s2;
+
+                    cp = cos(lp_lat);
+                    sp = sin(lp_lat);
+                    s = proj_mdist(lp_lat, sp, cp,  this->m_proj_parm.en) - this->m_proj_parm.s0;
+                    s2 = s * s;
+                    al = lp_lon * cp / sqrt(1. - this->m_par.es * sp * sp);
+                    al2 = al * al;
+                    xy_x = this->m_par.k0 * al*(1.+s2*(this->m_proj_parm.A1+s2*this->m_proj_parm.A4)-al2*(this->m_proj_parm.A2+s*this->m_proj_parm.A3+s2*this->m_proj_parm.A5
+                                +al2*this->m_proj_parm.A6));
+                    xy_y = this->m_par.k0 * (al2*(this->m_proj_parm.B1+al2*this->m_proj_parm.B4)+
+                        s*(1.+al2*(this->m_proj_parm.B3-al2*this->m_proj_parm.B6)+s2*(this->m_proj_parm.B2+s2*this->m_proj_parm.B8)+
+                        s*al2*(this->m_proj_parm.B5+s*this->m_proj_parm.B7)));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double s, al, x = xy_x / this->m_par.k0, y = xy_y / this->m_par.k0, x2, y2;;
+
+                    x2 = x * x;
+                    y2 = y * y;
+                    al = x*(1.-this->m_proj_parm.C1*y2+x2*(this->m_proj_parm.C2+this->m_proj_parm.C3*y-this->m_proj_parm.C4*x2+this->m_proj_parm.C5*y2-this->m_proj_parm.C7*x2*y)
+                        +y2*(this->m_proj_parm.C6*y2-this->m_proj_parm.C8*x2*y));
+                    s = this->m_proj_parm.s0 + y*(1.+y2*(-this->m_proj_parm.D2+this->m_proj_parm.D8*y2))+
+                        x2*(-this->m_proj_parm.D1+y*(-this->m_proj_parm.D3+y*(-this->m_proj_parm.D5+y*(-this->m_proj_parm.D7+y*this->m_proj_parm.D11)))+
+                        x2*(this->m_proj_parm.D4+y*(this->m_proj_parm.D6+y*this->m_proj_parm.D10)-x2*this->m_proj_parm.D9));
+                    lp_lat=proj_inv_mdist(s, this->m_proj_parm.en);
+                    s = sin(lp_lat);
+                    lp_lon=al * sqrt(1. - this->m_par.es * s * s)/cos(lp_lat);
+                }
+            };
+
+            // Roussilhe Stereographic
+            template <typename Parameters>
+            void setup_rouss(Parameters& par, par_rouss& proj_parm)
+            {
+                double N0, es2, t, t2, R_R0_2, R_R0_4;
+                proj_mdist_ini(par.es, proj_parm.en);
+
+                es2 = sin(par.phi0);
+                proj_parm.s0 = proj_mdist(par.phi0, es2, cos(par.phi0), proj_parm.en);
+                t = 1. - (es2 = par.es * es2 * es2);
+                N0 = 1./sqrt(t);
+                R_R0_2 = t * t / par.one_es;
+                R_R0_4 = R_R0_2 * R_R0_2;
+                t = tan(par.phi0);
+                t2 = t * t;
+                proj_parm.C1 = proj_parm.A1 = R_R0_2 / 4.;
+                proj_parm.C2 = proj_parm.A2 = R_R0_2 * (2 * t2 - 1. - 2. * es2) / 12.;
+                proj_parm.A3 = R_R0_2 * t * (1. + 4. * t2)/ ( 12. * N0);
+                proj_parm.A4 = R_R0_4 / 24.;
+                proj_parm.A5 = R_R0_4 * ( -1. + t2 * (11. + 12. * t2))/24.;
+                proj_parm.A6 = R_R0_4 * ( -2. + t2 * (11. - 2. * t2))/240.;
+                proj_parm.B1 = t / (2. * N0);
+                proj_parm.B2 = R_R0_2 / 12.;
+                proj_parm.B3 = R_R0_2 * (1. + 2. * t2 - 2. * es2)/4.;
+                proj_parm.B4 = R_R0_2 * t * (2. - t2)/(24. * N0);
+                proj_parm.B5 = R_R0_2 * t * (5. + 4.* t2)/(8. * N0);
+                proj_parm.B6 = R_R0_4 * (-2. + t2 * (-5. + 6. * t2))/48.;
+                proj_parm.B7 = R_R0_4 * (5. + t2 * (19. + 12. * t2))/24.;
+                proj_parm.B8 = R_R0_4 / 120.;
+                proj_parm.C3 = R_R0_2 * t * (1. + t2)/(3. * N0);
+                proj_parm.C4 = R_R0_4 * (-3. + t2 * (34. + 22. * t2))/240.;
+                proj_parm.C5 = R_R0_4 * (4. + t2 * (13. + 12. * t2))/24.;
+                proj_parm.C6 = R_R0_4 / 16.;
+                proj_parm.C7 = R_R0_4 * t * (11. + t2 * (33. + t2 * 16.))/(48. * N0);
+                proj_parm.C8 = R_R0_4 * t * (1. + t2 * 4.)/(36. * N0);
+                proj_parm.D1 = t / (2. * N0);
+                proj_parm.D2 = R_R0_2 / 12.;
+                proj_parm.D3 = R_R0_2 * (2 * t2 + 1. - 2. * es2) / 4.;
+                proj_parm.D4 = R_R0_2 * t * (1. + t2)/(8. * N0);
+                proj_parm.D5 = R_R0_2 * t * (1. + t2 * 2.)/(4. * N0);
+                proj_parm.D6 = R_R0_4 * (1. + t2 * (6. + t2 * 6.))/16.;
+                proj_parm.D7 = R_R0_4 * t2 * (3. + t2 * 4.)/8.;
+                proj_parm.D8 = R_R0_4 / 80.;
+                proj_parm.D9 = R_R0_4 * t * (-21. + t2 * (178. - t2 * 26.))/720.;
+                proj_parm.D10 = R_R0_4 * t * (29. + t2 * (86. + t2 * 48.))/(96. * N0);
+                proj_parm.D11 = R_R0_4 * t * (37. + t2 * 44.)/(96. * N0);
+                // par.fwd = e_forward;
+                // par.inv = e_inverse;
+            }
+
+        }} // namespace detail::rouss
+    #endif // doxygen
+
+    /*!
+        \brief Roussilhe Stereographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Ellps
+        \par Example
+        \image html ex_rouss.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct rouss_ellipsoid : public detail::rouss::base_rouss_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline rouss_ellipsoid(const Parameters& par) : detail::rouss::base_rouss_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::rouss::setup_rouss(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class rouss_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<rouss_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void rouss_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("rouss", new rouss_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_ROUSS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/rpoly.hpp b/src/boost/geometry/extensions/gis/projections/proj/rpoly.hpp
new file mode 100644
index 0000000..1dc8087
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/rpoly.hpp
@@ -0,0 +1,158 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace rpoly{
+            static const double EPS = 1e-9;
+
+            struct par_rpoly
+            {
+                double    phi1;
+                double    fxa;
+                double    fxb;
+                int        mode;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_rpoly_spheroid : public base_t_f<base_rpoly_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_rpoly m_proj_parm;
+
+                inline base_rpoly_spheroid(const Parameters& par)
+                    : base_t_f<base_rpoly_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double fa;
+
+                    if (this->m_proj_parm.mode)
+                        fa = tan(lp_lon * this->m_proj_parm.fxb) * this->m_proj_parm.fxa;
+                    else
+                        fa = 0.5 * lp_lon;
+                    if (fabs(lp_lat) < EPS) {
+                        xy_x = fa + fa;
+                        xy_y = - this->m_par.phi0;
+                    } else {
+                        xy_y = 1. / tan(lp_lat);
+                        xy_x = sin(fa = 2. * atan(fa * sin(lp_lat))) * xy_y;
+                        xy_y = lp_lat - this->m_par.phi0 + (1. - cos(fa)) * xy_y;
+                    }
+                }
+            };
+
+            // Rectangular Polyconic
+            template <typename Parameters>
+            void setup_rpoly(Parameters& par, par_rpoly& proj_parm)
+            {
+                if ((proj_parm.mode = (proj_parm.phi1 = fabs(pj_param(par.params, "rlat_ts").f)) > EPS)) {
+                    proj_parm.fxb = 0.5 * sin(proj_parm.phi1);
+                    proj_parm.fxa = 0.5 / proj_parm.fxb;
+                }
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::rpoly
+    #endif // doxygen
+
+    /*!
+        \brief Rectangular Polyconic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - no inverse
+         - lat_ts=
+        \par Example
+        \image html ex_rpoly.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct rpoly_spheroid : public detail::rpoly::base_rpoly_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline rpoly_spheroid(const Parameters& par) : detail::rpoly::base_rpoly_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::rpoly::setup_rpoly(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class rpoly_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<rpoly_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void rpoly_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("rpoly", new rpoly_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_RPOLY_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/sconics.hpp b/src/boost/geometry/extensions/gis/projections/proj/sconics.hpp
new file mode 100644
index 0000000..cf75ff1
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/sconics.hpp
@@ -0,0 +1,511 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace sconics{
+            static const int EULER = 0;
+            static const int MURD1 = 1;
+            static const int MURD2 = 2;
+            static const int MURD3 = 3;
+            static const int PCONIC = 4;
+            static const int TISSOT = 5;
+            static const int VITK1 = 6;
+            static const double EPS10 = 1.e-10;
+            static const double EPS = 1e-10;
+
+            struct par_sconics
+            {
+                double  n;
+                double  rho_c;
+                double  rho_0;
+                double  sig;
+                double  c1, c2;
+                int     type;
+            };
+            /* get common factors for simple conics */
+            template <typename Parameters>
+                inline int
+            phi12(Parameters& par, par_sconics& proj_parm, double *del) {
+                double p1, p2;
+                int err = 0;
+
+                if (!pj_param(par.params, "tlat_1").i ||
+                    !pj_param(par.params, "tlat_2").i) {
+                    err = -41;
+                } else {
+                    p1 = pj_param(par.params, "rlat_1").f;
+                    p2 = pj_param(par.params, "rlat_2").f;
+                    *del = 0.5 * (p2 - p1);
+                    proj_parm.sig = 0.5 * (p2 + p1);
+                    err = (fabs(*del) < EPS || fabs(proj_parm.sig) < EPS) ? -42 : 0;
+                    *del = *del;
+                }
+                return err;
+            }
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_sconics_spheroid : public base_t_fi<base_sconics_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_sconics m_proj_parm;
+
+                inline base_sconics_spheroid(const Parameters& par)
+                    : base_t_fi<base_sconics_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double rho;
+
+                    switch (this->m_proj_parm.type) {
+                    case MURD2:
+                        rho = this->m_proj_parm.rho_c + tan(this->m_proj_parm.sig - lp_lat);
+                        break;
+                    case PCONIC:
+                        rho = this->m_proj_parm.c2 * (this->m_proj_parm.c1 - tan(lp_lat - this->m_proj_parm.sig));
+                        break;
+                    default:
+                        rho = this->m_proj_parm.rho_c - lp_lat;
+                        break;
+                    }
+                    xy_x = rho * sin( lp_lon *= this->m_proj_parm.n );
+                    xy_y = this->m_proj_parm.rho_0 - rho * cos(lp_lon);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double rho;
+
+                    rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho_0 - xy_y);
+                    if (this->m_proj_parm.n < 0.) {
+                        rho = - rho;
+                        xy_x = - xy_x;
+                        xy_y = - xy_y;
+                    }
+                    lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
+                    switch (this->m_proj_parm.type) {
+                    case PCONIC:
+                        lp_lat = atan(this->m_proj_parm.c1 - rho / this->m_proj_parm.c2) + this->m_proj_parm.sig;
+                        break;
+                    case MURD2:
+                        lp_lat = this->m_proj_parm.sig - atan(rho - this->m_proj_parm.rho_c);
+                        break;
+                    default:
+                        lp_lat = this->m_proj_parm.rho_c - rho;
+                    }
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_sconics& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                double del, cs;
+                int i;
+                if( (i = phi12(par, proj_parm, &del)) )
+                    throw proj_exception(i);
+                switch (proj_parm.type) {
+                case TISSOT:
+                    proj_parm.n = sin(proj_parm.sig);
+                    cs = cos(del);
+                    proj_parm.rho_c = proj_parm.n / cs + cs / proj_parm.n;
+                    proj_parm.rho_0 = sqrt((proj_parm.rho_c - 2 * sin(par.phi0))/proj_parm.n);
+                    break;
+                case MURD1:
+                    proj_parm.rho_c = sin(del)/(del * tan(proj_parm.sig)) + proj_parm.sig;
+                    proj_parm.rho_0 = proj_parm.rho_c - par.phi0;
+                    proj_parm.n = sin(proj_parm.sig);
+                    break;
+                case MURD2:
+                    proj_parm.rho_c = (cs = sqrt(cos(del))) / tan(proj_parm.sig);
+                    proj_parm.rho_0 = proj_parm.rho_c + tan(proj_parm.sig - par.phi0);
+                    proj_parm.n = sin(proj_parm.sig) * cs;
+                    break;
+                case MURD3:
+                    proj_parm.rho_c = del / (tan(proj_parm.sig) * tan(del)) + proj_parm.sig;
+                    proj_parm.rho_0 = proj_parm.rho_c - par.phi0;
+                    proj_parm.n = sin(proj_parm.sig) * sin(del) * tan(del) / (del * del);
+                    break;
+                case EULER:
+                    proj_parm.n = sin(proj_parm.sig) * sin(del) / del;
+                    del *= 0.5;
+                    proj_parm.rho_c = del / (tan(del) * tan(proj_parm.sig)) + proj_parm.sig;
+                    proj_parm.rho_0 = proj_parm.rho_c - par.phi0;
+                    break;
+                case PCONIC:
+                    proj_parm.n = sin(proj_parm.sig);
+                    proj_parm.c2 = cos(del);
+                    proj_parm.c1 = 1./tan(proj_parm.sig);
+                    if (fabs(del = par.phi0 - proj_parm.sig) - EPS10 >= HALFPI)
+                        throw proj_exception(-43);
+                    proj_parm.rho_0 = proj_parm.c2 * (proj_parm.c1 - tan(del));
+                    break;
+                case VITK1:
+                    proj_parm.n = (cs = tan(del)) * sin(proj_parm.sig) / del;
+                    proj_parm.rho_c = del / (cs * tan(proj_parm.sig)) + proj_parm.sig;
+                    proj_parm.rho_0 = proj_parm.rho_c - par.phi0;
+                    break;
+                }
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0;
+            }
+
+
+            // Tissot
+            template <typename Parameters>
+            void setup_tissot(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = TISSOT;
+                setup(par, proj_parm);
+            }
+
+            // Murdoch I
+            template <typename Parameters>
+            void setup_murd1(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = MURD1;
+                setup(par, proj_parm);
+            }
+
+            // Murdoch II
+            template <typename Parameters>
+            void setup_murd2(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = MURD2;
+                setup(par, proj_parm);
+            }
+
+            // Murdoch III
+            template <typename Parameters>
+            void setup_murd3(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = MURD3;
+                setup(par, proj_parm);
+            }
+
+            // Euler
+            template <typename Parameters>
+            void setup_euler(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = EULER;
+                setup(par, proj_parm);
+            }
+
+            // Perspective Conic
+            template <typename Parameters>
+            void setup_pconic(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = PCONIC;
+                setup(par, proj_parm);
+            }
+
+            // Vitkovsky I
+            template <typename Parameters>
+            void setup_vitk1(Parameters& par, par_sconics& proj_parm)
+            {
+                proj_parm.type = VITK1;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::sconics
+    #endif // doxygen
+
+    /*!
+        \brief Tissot projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_tissot.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tissot_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline tissot_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_tissot(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Murdoch I projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_murd1.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct murd1_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline murd1_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_murd1(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Murdoch II projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_murd2.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct murd2_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline murd2_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_murd2(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Murdoch III projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_murd3.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct murd3_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline murd3_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_murd3(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Euler projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_euler.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct euler_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline euler_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_euler(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Perspective Conic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_pconic.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct pconic_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline pconic_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_pconic(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Vitkovsky I projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Conic
+         - Spheroid
+         - lat_1= and lat_2=
+        \par Example
+        \image html ex_vitk1.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct vitk1_spheroid : public detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline vitk1_spheroid(const Parameters& par) : detail::sconics::base_sconics_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sconics::setup_vitk1(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class tissot_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<tissot_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class murd1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<murd1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class murd2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<murd2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class murd3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<murd3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class euler_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<euler_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class pconic_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<pconic_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class vitk1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<vitk1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void sconics_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("tissot", new tissot_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("murd1", new murd1_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("murd2", new murd2_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("murd3", new murd3_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("euler", new euler_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("pconic", new pconic_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("vitk1", new vitk1_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_SCONICS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/somerc.hpp b/src/boost/geometry/extensions/gis/projections/proj/somerc.hpp
new file mode 100644
index 0000000..c73e315
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/somerc.hpp
@@ -0,0 +1,188 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace somerc{
+            static const double EPS = 1.e-10;
+            static const int NITER = 6;
+
+            struct par_somerc
+            {
+                double    K, c, hlf_e, kR, cosp0, sinp0;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_somerc_ellipsoid : public base_t_fi<base_somerc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_somerc m_proj_parm;
+
+                inline base_somerc_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_somerc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double phip, lamp, phipp, lampp, sp, cp;
+
+                    sp = this->m_par.e * sin(lp_lat);
+                    phip = 2.* atan( exp( this->m_proj_parm.c * (
+                        log(tan(FORTPI + 0.5 * lp_lat)) - this->m_proj_parm.hlf_e * log((1. + sp)/(1. - sp)))
+                        + this->m_proj_parm.K)) - HALFPI;
+                    lamp = this->m_proj_parm.c * lp_lon;
+                    cp = cos(phip);
+                    phipp = aasin(this->m_proj_parm.cosp0 * sin(phip) - this->m_proj_parm.sinp0 * cp * cos(lamp));
+                    lampp = aasin(cp * sin(lamp) / cos(phipp));
+                    xy_x = this->m_proj_parm.kR * lampp;
+                    xy_y = this->m_proj_parm.kR * log(tan(FORTPI + 0.5 * phipp));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double phip, lamp, phipp, lampp, cp, esp, con, delp;
+                    int i;
+
+                    phipp = 2. * (atan(exp(xy_y / this->m_proj_parm.kR)) - FORTPI);
+                    lampp = xy_x / this->m_proj_parm.kR;
+                    cp = cos(phipp);
+                    phip = aasin(this->m_proj_parm.cosp0 * sin(phipp) + this->m_proj_parm.sinp0 * cp * cos(lampp));
+                    lamp = aasin(cp * sin(lampp) / cos(phip));
+                    con = (this->m_proj_parm.K - log(tan(FORTPI + 0.5 * phip)))/this->m_proj_parm.c;
+                    for (i = NITER; i ; --i) {
+                        esp = this->m_par.e * sin(phip);
+                        delp = (con + log(tan(FORTPI + 0.5 * phip)) - this->m_proj_parm.hlf_e *
+                            log((1. + esp)/(1. - esp)) ) *
+                            (1. - esp * esp) * cos(phip) * this->m_par.rone_es;
+                        phip -= delp;
+                        if (fabs(delp) < EPS)
+                            break;
+                    }
+                    if (i) {
+                        lp_lat = phip;
+                        lp_lon = lamp / this->m_proj_parm.c;
+                    } else
+                        throw proj_exception();
+                }
+            };
+
+            // Swiss. Obl. Mercator
+            template <typename Parameters>
+            void setup_somerc(Parameters& par, par_somerc& proj_parm)
+            {
+                double cp, phip0, sp;
+                proj_parm.hlf_e = 0.5 * par.e;
+                cp = cos(par.phi0);
+                cp *= cp;
+                proj_parm.c = sqrt(1 + par.es * cp * cp * par.rone_es);
+                sp = sin(par.phi0);
+                proj_parm.cosp0 = cos( phip0 = aasin(proj_parm.sinp0 = sp / proj_parm.c) );
+                sp *= par.e;
+                proj_parm.K = log(tan(FORTPI + 0.5 * phip0)) - proj_parm.c * (
+                    log(tan(FORTPI + 0.5 * par.phi0)) - proj_parm.hlf_e *
+                    log((1. + sp) / (1. - sp)));
+                proj_parm.kR = par.k0 * sqrt(par.one_es) / (1. - sp * sp);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::somerc
+    #endif // doxygen
+
+    /*!
+        \brief Swiss. Obl. Mercator projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Ellipsoid
+         - For CH1903
+        \par Example
+        \image html ex_somerc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct somerc_ellipsoid : public detail::somerc::base_somerc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline somerc_ellipsoid(const Parameters& par) : detail::somerc::base_somerc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::somerc::setup_somerc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class somerc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<somerc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void somerc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("somerc", new somerc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_SOMERC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/stere.hpp b/src/boost/geometry/extensions/gis/projections/proj/stere.hpp
new file mode 100644
index 0000000..18183d9
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/stere.hpp
@@ -0,0 +1,451 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_STERE_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_STERE_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace stere{
+            static const double EPS10 = 1.e-10;
+            static const double TOL = 1.e-8;
+            static const int NITER = 8;
+            static const double CONV = 1.e-10;
+            static const int S_POLE = 0;
+            static const int N_POLE = 1;
+            static const int OBLIQ = 2;
+            static const int EQUIT = 3;
+
+            struct par_stere
+            {
+                double phits;
+                double sinX1;
+                double cosX1;
+                double akm1;
+                int    mode;
+            };
+                inline double
+            ssfn_(double phit, double sinphi, double eccen) {
+                sinphi *= eccen;
+                return (tan (.5 * (HALFPI + phit)) *
+                   pow((1. - sinphi) / (1. + sinphi), .5 * eccen));
+            }
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_stere_ellipsoid : public base_t_fi<base_stere_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_stere m_proj_parm;
+
+                inline base_stere_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_stere_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double coslam, sinlam, sinX=0.0, cosX=0.0, X, A, sinphi;
+
+                    coslam = cos(lp_lon);
+                    sinlam = sin(lp_lon);
+                    sinphi = sin(lp_lat);
+                    if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
+                        sinX = sin(X = 2. * atan(ssfn_(lp_lat, sinphi, this->m_par.e)) - HALFPI);
+                        cosX = cos(X);
+                    }
+                    switch (this->m_proj_parm.mode) {
+                    case OBLIQ:
+                        A = this->m_proj_parm.akm1 / (this->m_proj_parm.cosX1 * (1. + this->m_proj_parm.sinX1 * sinX +
+                           this->m_proj_parm.cosX1 * cosX * coslam));
+                        xy_y = A * (this->m_proj_parm.cosX1 * sinX - this->m_proj_parm.sinX1 * cosX * coslam);
+                        goto xmul;
+                    case EQUIT:
+                        A = 2. * this->m_proj_parm.akm1 / (1. + cosX * coslam);
+                        xy_y = A * sinX;
+                xmul:
+                        xy_x = A * cosX;
+                        break;
+                    case S_POLE:
+                        lp_lat = -lp_lat;
+                        coslam = - coslam;
+                        sinphi = -sinphi;
+                    case N_POLE:
+                        xy_x = this->m_proj_parm.akm1 * pj_tsfn(lp_lat, sinphi, this->m_par.e);
+                        xy_y = - xy_x * coslam;
+                        break;
+                    }
+                    xy_x = xy_x * sinlam;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0;
+                    int i;
+
+                    rho = boost::math::hypot(xy_x, xy_y);
+                    switch (this->m_proj_parm.mode) {
+                    case OBLIQ:
+                    case EQUIT:
+                        cosphi = cos( tp = 2. * atan2(rho * this->m_proj_parm.cosX1 , this->m_proj_parm.akm1) );
+                        sinphi = sin(tp);
+                                if( rho == 0.0 )
+                            phi_l = asin(cosphi * this->m_proj_parm.sinX1);
+                                else
+                            phi_l = asin(cosphi * this->m_proj_parm.sinX1 + (xy_y * sinphi * this->m_proj_parm.cosX1 / rho));
+
+                        tp = tan(.5 * (HALFPI + phi_l));
+                        xy_x *= sinphi;
+                        xy_y = rho * this->m_proj_parm.cosX1 * cosphi - xy_y * this->m_proj_parm.sinX1* sinphi;
+                        halfpi = HALFPI;
+                        halfe = .5 * this->m_par.e;
+                        break;
+                    case N_POLE:
+                        xy_y = -xy_y;
+                    case S_POLE:
+                        phi_l = HALFPI - 2. * atan(tp = - rho / this->m_proj_parm.akm1);
+                        halfpi = -HALFPI;
+                        halfe = -.5 * this->m_par.e;
+                        break;
+                    }
+                    for (i = NITER; i--; phi_l = lp_lat) {
+                        sinphi = this->m_par.e * sin(phi_l);
+                        lp_lat = 2. * atan(tp * pow((1.+sinphi)/(1.-sinphi),
+                           halfe)) - halfpi;
+                        if (fabs(phi_l - lp_lat) < CONV) {
+                            if (this->m_proj_parm.mode == S_POLE)
+                                lp_lat = -lp_lat;
+                            lp_lon = (xy_x == 0. && xy_y == 0.) ? 0. : atan2(xy_x, xy_y);
+                            return;
+                        }
+                    }
+                    throw proj_exception();;
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_stere_spheroid : public base_t_fi<base_stere_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_stere m_proj_parm;
+
+                inline base_stere_spheroid(const Parameters& par)
+                    : base_t_fi<base_stere_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  sinphi, cosphi, coslam, sinlam;
+
+                    sinphi = sin(lp_lat);
+                    cosphi = cos(lp_lat);
+                    coslam = cos(lp_lon);
+                    sinlam = sin(lp_lon);
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        xy_y = 1. + cosphi * coslam;
+                        goto oblcon;
+                    case OBLIQ:
+                        xy_y = 1. + this->m_proj_parm.sinX1 * sinphi + this->m_proj_parm.cosX1 * cosphi * coslam;
+                oblcon:
+                        if (xy_y <= EPS10) throw proj_exception();;
+                        xy_x = (xy_y = this->m_proj_parm.akm1 / xy_y) * cosphi * sinlam;
+                        xy_y *= (this->m_proj_parm.mode == EQUIT) ? sinphi :
+                           this->m_proj_parm.cosX1 * sinphi - this->m_proj_parm.sinX1 * cosphi * coslam;
+                        break;
+                    case N_POLE:
+                        coslam = - coslam;
+                        lp_lat = - lp_lat;
+                    case S_POLE:
+                        if (fabs(lp_lat - HALFPI) < TOL) throw proj_exception();;
+                        xy_x = sinlam * ( xy_y = this->m_proj_parm.akm1 * tan(FORTPI + .5 * lp_lat) );
+                        xy_y *= coslam;
+                        break;
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double  c, rh, sinc, cosc;
+
+                    sinc = sin(c = 2. * atan((rh = boost::math::hypot(xy_x, xy_y)) / this->m_proj_parm.akm1));
+                    cosc = cos(c);
+                    lp_lon = 0.;
+                    switch (this->m_proj_parm.mode) {
+                    case EQUIT:
+                        if (fabs(rh) <= EPS10)
+                            lp_lat = 0.;
+                        else
+                            lp_lat = asin(xy_y * sinc / rh);
+                        if (cosc != 0. || xy_x != 0.)
+                            lp_lon = atan2(xy_x * sinc, cosc * rh);
+                        break;
+                    case OBLIQ:
+                        if (fabs(rh) <= EPS10)
+                            lp_lat = this->m_par.phi0;
+                        else
+                            lp_lat = asin(cosc * this->m_proj_parm.sinX1 + xy_y * sinc * this->m_proj_parm.cosX1 / rh);
+                        if ((c = cosc - this->m_proj_parm.sinX1 * sin(lp_lat)) != 0. || xy_x != 0.)
+                            lp_lon = atan2(xy_x * sinc * this->m_proj_parm.cosX1, c * rh);
+                        break;
+                    case N_POLE:
+                        xy_y = -xy_y;
+                    case S_POLE:
+                        if (fabs(rh) <= EPS10)
+                            lp_lat = this->m_par.phi0;
+                        else
+                            lp_lat = asin(this->m_proj_parm.mode == S_POLE ? - cosc : cosc);
+                        lp_lon = (xy_x == 0. && xy_y == 0.) ? 0. : atan2(xy_x, xy_y);
+                        break;
+                    }
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_stere& proj_parm)  /* general initialization */
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                double t;
+                if (fabs((t = fabs(par.phi0)) - HALFPI) < EPS10)
+                    proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
+                else
+                    proj_parm.mode = t > EPS10 ? OBLIQ : EQUIT;
+                proj_parm.phits = fabs(proj_parm.phits);
+                if (par.es) {
+                    double X;
+                    switch (proj_parm.mode) {
+                    case N_POLE:
+                    case S_POLE:
+                        if (fabs(proj_parm.phits - HALFPI) < EPS10)
+                            proj_parm.akm1 = 2. * par.k0 /
+                               sqrt(pow(1+par.e,1+par.e)*pow(1-par.e,1-par.e));
+                        else {
+                            proj_parm.akm1 = cos(proj_parm.phits) /
+                               pj_tsfn(proj_parm.phits, t = sin(proj_parm.phits), par.e);
+                            t *= par.e;
+                            proj_parm.akm1 /= sqrt(1. - t * t);
+                        }
+                        break;
+                    case EQUIT:
+                        proj_parm.akm1 = 2. * par.k0;
+                        break;
+                    case OBLIQ:
+                        t = sin(par.phi0);
+                        X = 2. * atan(ssfn_(par.phi0, t, par.e)) - HALFPI;
+                        t *= par.e;
+                        proj_parm.akm1 = 2. * par.k0 * cos(par.phi0) / sqrt(1. - t * t);
+                        proj_parm.sinX1 = sin(X);
+                        proj_parm.cosX1 = cos(X);
+                        break;
+                    }
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    switch (proj_parm.mode) {
+                    case OBLIQ:
+                        proj_parm.sinX1 = sin(par.phi0);
+                        proj_parm.cosX1 = cos(par.phi0);
+                    case EQUIT:
+                        proj_parm.akm1 = 2. * par.k0;
+                        break;
+                    case S_POLE:
+                    case N_POLE:
+                        proj_parm.akm1 = fabs(proj_parm.phits - HALFPI) >= EPS10 ?
+                           cos(proj_parm.phits) / tan(FORTPI - .5 * proj_parm.phits) :
+                           2. * par.k0 ;
+                        break;
+                    }
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+
+            // Stereographic
+            template <typename Parameters>
+            void setup_stere(Parameters& par, par_stere& proj_parm)
+            {
+                proj_parm.phits = pj_param(par.params, "tlat_ts").i ?
+                    pj_param(par.params, "rlat_ts").f : HALFPI;
+                setup(par, proj_parm);
+            }
+
+            // Universal Polar Stereographic
+            template <typename Parameters>
+            void setup_ups(Parameters& par, par_stere& proj_parm)
+            {
+                /* International Ellipsoid */
+                par.phi0 = pj_param(par.params, "bsouth").i ? - HALFPI: HALFPI;
+                if (!par.es) throw proj_exception(-34);
+                par.k0 = .994;
+                par.x0 = 2000000.;
+                par.y0 = 2000000.;
+                proj_parm.phits = HALFPI;
+                par.lam0 = 0.;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::stere
+    #endif // doxygen
+
+    /*!
+        \brief Stereographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - lat_ts=
+        \par Example
+        \image html ex_stere.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct stere_ellipsoid : public detail::stere::base_stere_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline stere_ellipsoid(const Parameters& par) : detail::stere::base_stere_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::stere::setup_stere(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Universal Polar Stereographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - south
+        \par Example
+        \image html ex_ups.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct ups_ellipsoid : public detail::stere::base_stere_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline ups_ellipsoid(const Parameters& par) : detail::stere::base_stere_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::stere::setup_ups(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Stereographic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+         - lat_ts=
+        \par Example
+        \image html ex_stere.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct stere_spheroid : public detail::stere::base_stere_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline stere_spheroid(const Parameters& par) : detail::stere::base_stere_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::stere::setup_stere(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class stere_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<stere_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<stere_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class ups_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<ups_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void stere_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("stere", new stere_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("ups", new ups_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_STERE_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/sterea.hpp b/src/boost/geometry/extensions/gis/projections/proj/sterea.hpp
new file mode 100644
index 0000000..1d5454d
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/sterea.hpp
@@ -0,0 +1,381 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_gauss.hpp>
+
+#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace sterea{
+            static const double DEL_TOL = 1.e-14;
+            static const int MAX_ITER = 10;
+
+            struct par_sterea
+            {
+                double phic0;
+                double cosc0, sinc0;
+                double R2;
+                gauss::GAUSS en;
+            };
+
+
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_sterea_ellipsoid : public base_t_fi<base_sterea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_sterea m_proj_parm;
+
+                inline base_sterea_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_sterea_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double cosc, sinc, cosl, k;
+
+                    detail::gauss::gauss(m_proj_parm.en, lp_lon, lp_lat);
+                    sinc = sin(lp_lat);
+                    cosc = cos(lp_lat);
+                    cosl = cos(lp_lon);
+                    k = this->m_par.k0 * this->m_proj_parm.R2 / (1. + this->m_proj_parm.sinc0 * sinc + this->m_proj_parm.cosc0 * cosc * cosl);
+                    xy_x = k * cosc * sin(lp_lon);
+                    xy_y = k * (this->m_proj_parm.cosc0 * sinc - this->m_proj_parm.sinc0 * cosc * cosl);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double rho, c, sinc, cosc;
+
+                    xy_x /= this->m_par.k0;
+                    xy_y /= this->m_par.k0;
+                    if((rho = boost::math::hypot(xy_x, xy_y))) {
+                        c = 2. * atan2(rho, this->m_proj_parm.R2);
+                        sinc = sin(c);
+                        cosc = cos(c);
+                        lp_lat = asin(cosc * this->m_proj_parm.sinc0 + xy_y * sinc * this->m_proj_parm.cosc0 / rho);
+                        lp_lon = atan2(xy_x * sinc, rho * this->m_proj_parm.cosc0 * cosc -
+                            xy_y * this->m_proj_parm.sinc0 * sinc);
+                    } else {
+                        lp_lat = this->m_proj_parm.phic0;
+                        lp_lon = 0.;
+                    }
+                    detail::gauss::inv_gauss(m_proj_parm.en, lp_lon, lp_lat);
+                }
+            };
+
+            // Oblique Stereographic Alternative
+            template <typename Parameters>
+            void setup_sterea(Parameters& par, par_sterea& proj_parm)
+            {
+                double R;
+                proj_parm.en = detail::gauss::gauss_ini(par.e, par.phi0, proj_parm.phic0, R);
+                proj_parm.sinc0 = sin(proj_parm.phic0);
+                proj_parm.cosc0 = cos(proj_parm.phic0);
+                proj_parm.R2 = 2. * R;
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+            }
+
+        }} // namespace detail::sterea
+    #endif // doxygen
+
+    /*!
+        \brief Oblique Stereographic Alternative projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Azimuthal
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_sterea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct sterea_ellipsoid : public detail::sterea::base_sterea_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline sterea_ellipsoid(const Parameters& par) : detail::sterea::base_sterea_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sterea::setup_sterea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class sterea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<sterea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void sterea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("sterea", new sterea_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    // Create EPSG specializations
+    // (Proof of Concept, only for some)
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2036, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=2500000 +y_0=7500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2171, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5647000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2172, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=53.00194444444445 +lon_0=21.50277777777778 +k=0.9998 +x_0=4603000 +y_0=5806000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2173, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=53.58333333333334 +lon_0=17.00833333333333 +k=0.9998 +x_0=3501000 +y_0=5999000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2174, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=51.67083333333333 +lon_0=16.67222222222222 +k=0.9998 +x_0=3703000 +y_0=5627000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2200, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=300000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2290, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=700000 +y_0=400000 +a=6378135 +b=6356750.304921594 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2291, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +a=6378135 +b=6356750.304921594 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2292, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2953, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=46.5 +lon_0=-66.5 +k=0.999912 +x_0=2500000 +y_0=7500000 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2954, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=47.25 +lon_0=-63 +k=0.999912 +x_0=400000 +y_0=800000 +ellps=GRS80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3120, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5467000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<3328, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=52.16666666666666 +lon_0=19.16666666666667 +k=0.999714 +x_0=500000 +y_0=500000 +ellps=krass +towgs84=33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<22780, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=34.2 +lon_0=39.15 +k=0.9995341 +x_0=0 +y_0=0 +a=6378249.2 +b=6356515 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<28991, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=0 +y_0=0 +ellps=bessel +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<28992, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<31600, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=45.9 +lon_0=25.39246588888889 +k=0.9996667 +x_0=500000 +y_0=500000 +ellps=intl +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<31700, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef sterea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=sterea +lat_0=46 +lon_0=25 +k=0.99975 +x_0=500000 +y_0=500000 +ellps=krass +units=m";
+        }
+    };
+
+
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_STEREA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/sts.hpp b/src/boost/geometry/extensions/gis/projections/proj/sts.hpp
new file mode 100644
index 0000000..6a3cf04
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/sts.hpp
@@ -0,0 +1,294 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_STS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_STS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace sts{
+
+            struct par_sts
+            {
+                double C_x, C_y, C_p;
+                int tan_mode;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_sts_spheroid : public base_t_fi<base_sts_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_sts m_proj_parm;
+
+                inline base_sts_spheroid(const Parameters& par)
+                    : base_t_fi<base_sts_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double c;
+
+                    xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat);
+                    xy_y = this->m_proj_parm.C_y;
+                    lp_lat *= this->m_proj_parm.C_p;
+                    c = cos(lp_lat);
+                    if (this->m_proj_parm.tan_mode) {
+                        xy_x *= c * c;
+                        xy_y *= tan(lp_lat);
+                    } else {
+                        xy_x /= c;
+                        xy_y *= sin(lp_lat);
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double c;
+
+                    xy_y /= this->m_proj_parm.C_y;
+                    c = cos(lp_lat = this->m_proj_parm.tan_mode ? atan(xy_y) : aasin(xy_y));
+                    lp_lat /= this->m_proj_parm.C_p;
+                    lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat));
+                    if (this->m_proj_parm.tan_mode)
+                        lp_lon /= c * c;
+                    else
+                        lp_lon *= c;
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_sts& proj_parm, double p, double q, int mode)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                proj_parm.C_x = q / p;
+                proj_parm.C_y = p;
+                proj_parm.C_p = 1/ q;
+                proj_parm.tan_mode = mode;
+            }
+
+
+            // Kavraisky V
+            template <typename Parameters>
+            void setup_kav5(Parameters& par, par_sts& proj_parm)
+            {
+                setup(par, proj_parm, 1.50488, 1.35439, 0);
+            }
+
+            // Quartic Authalic
+            template <typename Parameters>
+            void setup_qua_aut(Parameters& par, par_sts& proj_parm)
+            {
+                setup(par, proj_parm, 2., 2., 0);
+            }
+
+            // McBryde-Thomas Flat-Polar Sine (No. 1)
+            template <typename Parameters>
+            void setup_mbt_s(Parameters& par, par_sts& proj_parm)
+            {
+                setup(par, proj_parm, 1.48875, 1.36509, 0);
+            }
+
+            // Foucaut
+            template <typename Parameters>
+            void setup_fouc(Parameters& par, par_sts& proj_parm)
+            {
+                setup(par, proj_parm, 2., 2., 1);
+            }
+
+        }} // namespace detail::sts
+    #endif // doxygen
+
+    /*!
+        \brief Kavraisky V projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_kav5.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct kav5_spheroid : public detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline kav5_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sts::setup_kav5(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Quartic Authalic projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_qua_aut.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct qua_aut_spheroid : public detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline qua_aut_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sts::setup_qua_aut(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief McBryde-Thomas Flat-Polar Sine (No. 1) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_mbt_s.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct mbt_s_spheroid : public detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline mbt_s_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sts::setup_mbt_s(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Foucaut projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_fouc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct fouc_spheroid : public detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline fouc_spheroid(const Parameters& par) : detail::sts::base_sts_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::sts::setup_fouc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class kav5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<kav5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class qua_aut_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<qua_aut_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class mbt_s_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<mbt_s_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class fouc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<fouc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void sts_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("kav5", new kav5_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("qua_aut", new qua_aut_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("mbt_s", new mbt_s_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("fouc", new fouc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_STS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/tcc.hpp b/src/boost/geometry/extensions/gis/projections/proj/tcc.hpp
new file mode 100644
index 0000000..5fa22d4
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/tcc.hpp
@@ -0,0 +1,142 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_TCC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_TCC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace tcc{
+            static const double EPS10 = 1.e-10;
+
+            struct par_tcc
+            {
+                double ap;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_tcc_spheroid : public base_t_f<base_tcc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_tcc m_proj_parm;
+
+                inline base_tcc_spheroid(const Parameters& par)
+                    : base_t_f<base_tcc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double b, bt;
+
+                    b = cos(lp_lat) * sin(lp_lon);
+                    if ((bt = 1. - b * b) < EPS10) throw proj_exception();;
+                    xy_x = b / sqrt(bt);
+                    xy_y = atan2(tan(lp_lat) , cos(lp_lon));
+                }
+            };
+
+            // Transverse Central Cylindrical
+            template <typename Parameters>
+            void setup_tcc(Parameters& par, par_tcc& proj_parm)
+            {
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::tcc
+    #endif // doxygen
+
+    /*!
+        \brief Transverse Central Cylindrical projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_tcc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tcc_spheroid : public detail::tcc::base_tcc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline tcc_spheroid(const Parameters& par) : detail::tcc::base_tcc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::tcc::setup_tcc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class tcc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<tcc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void tcc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("tcc", new tcc_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_TCC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/tcea.hpp b/src/boost/geometry/extensions/gis/projections/proj/tcea.hpp
new file mode 100644
index 0000000..9b6d2f9
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/tcea.hpp
@@ -0,0 +1,149 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace tcea{
+
+            struct par_tcea
+            {
+                double rk0;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_tcea_spheroid : public base_t_fi<base_tcea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_tcea m_proj_parm;
+
+                inline base_tcea_spheroid(const Parameters& par)
+                    : base_t_fi<base_tcea_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = this->m_proj_parm.rk0 * cos(lp_lat) * sin(lp_lon);
+                    xy_y = this->m_par.k0 * (atan2(tan(lp_lat), cos(lp_lon)) - this->m_par.phi0);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t;
+
+                    xy_y = xy_y * this->m_proj_parm.rk0 + this->m_par.phi0;
+                    xy_x *= this->m_par.k0;
+                    t = sqrt(1. - xy_x * xy_x);
+                    lp_lat = asin(t * sin(xy_y));
+                    lp_lon = atan2(xy_x, t * cos(xy_y));
+                }
+            };
+
+            // Transverse Cylindrical Equal Area
+            template <typename Parameters>
+            void setup_tcea(Parameters& par, par_tcea& proj_parm)
+            {
+                proj_parm.rk0 = 1 / par.k0;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::tcea
+    #endif // doxygen
+
+    /*!
+        \brief Transverse Cylindrical Equal Area projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+        \par Example
+        \image html ex_tcea.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tcea_spheroid : public detail::tcea::base_tcea_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline tcea_spheroid(const Parameters& par) : detail::tcea::base_tcea_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::tcea::setup_tcea(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class tcea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<tcea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void tcea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("tcea", new tcea_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_TCEA_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/src/boost/geometry/extensions/gis/projections/proj/tmerc.hpp
new file mode 100644
index 0000000..b419386
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/tmerc.hpp
@@ -0,0 +1,458 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/function_overloads.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
+
+#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace tmerc{
+            static const double EPS10 = 1.e-10;
+            static const double FC1 = 1.;
+            static const double FC2 = .5;
+            static const double FC3 = .16666666666666666666;
+            static const double FC4 = .08333333333333333333;
+            static const double FC5 = .05;
+            static const double FC6 = .03333333333333333333;
+            static const double FC7 = .02380952380952380952;
+            static const double FC8 = .01785714285714285714;
+
+            struct par_tmerc
+            {
+                double    esp;
+                double    ml0;
+                double    en[EN_SIZE];
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_tmerc_ellipsoid : public base_t_fi<base_tmerc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_tmerc m_proj_parm;
+
+                inline base_tmerc_ellipsoid(const Parameters& par)
+                    : base_t_fi<base_tmerc_ellipsoid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double al, als, n, cosphi, sinphi, t;
+
+                        /*
+                         * Fail if our longitude is more than 90 degrees from the
+                         * central meridian since the results are essentially garbage.
+                         * Is error -20 really an appropriate return value?
+                         *
+                         *  http://trac.osgeo.org/proj/ticket/5
+                         */
+                        if( lp_lon < -HALFPI || lp_lon > HALFPI )
+                        {
+                            xy_x = HUGE_VAL;
+                            xy_y = HUGE_VAL;
+                            throw proj_exception(  -14);
+                            return;
+                        }
+
+                    sinphi = sin(lp_lat); cosphi = cos(lp_lat);
+                    t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.;
+                    t *= t;
+                    al = cosphi * lp_lon;
+                    als = al * al;
+                    al /= sqrt(1. - this->m_par.es * sinphi * sinphi);
+                    n = this->m_proj_parm.esp * cosphi * cosphi;
+                    xy_x = this->m_par.k0 * al * (FC1 +
+                        FC3 * als * (1. - t + n +
+                        FC5 * als * (5. + t * (t - 18.) + n * (14. - 58. * t)
+                        + FC7 * als * (61. + t * ( t * (179. - t) - 479. ) )
+                        )));
+                    xy_y = this->m_par.k0 * (pj_mlfn(lp_lat, sinphi, cosphi, this->m_proj_parm.en) - this->m_proj_parm.ml0 +
+                        sinphi * al * lp_lon * FC2 * ( 1. +
+                        FC4 * als * (5. - t + n * (9. + 4. * n) +
+                        FC6 * als * (61. + t * (t - 58.) + n * (270. - 330 * t)
+                        + FC8 * als * (1385. + t * ( t * (543. - t) - 3111.) )
+                        ))));
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double n, con, cosphi, d, ds, sinphi, t;
+
+                    lp_lat = pj_inv_mlfn(this->m_proj_parm.ml0 + xy_y / this->m_par.k0, this->m_par.es, this->m_proj_parm.en);
+                    if (fabs(lp_lat) >= HALFPI) {
+                        lp_lat = xy_y < 0. ? -HALFPI : HALFPI;
+                        lp_lon = 0.;
+                    } else {
+                        sinphi = sin(lp_lat);
+                        cosphi = cos(lp_lat);
+                        t = fabs(cosphi) > 1e-10 ? sinphi/cosphi : 0.;
+                        n = this->m_proj_parm.esp * cosphi * cosphi;
+                        d = xy_x * sqrt(con = 1. - this->m_par.es * sinphi * sinphi) / this->m_par.k0;
+                        con *= t;
+                        t *= t;
+                        ds = d * d;
+                        lp_lat -= (con * ds / (1.-this->m_par.es)) * FC2 * (1. -
+                            ds * FC4 * (5. + t * (3. - 9. *  n) + n * (1. - 4 * n) -
+                            ds * FC6 * (61. + t * (90. - 252. * n +
+                                45. * t) + 46. * n
+                           - ds * FC8 * (1385. + t * (3633. + t * (4095. + 1574. * t)) )
+                            )));
+                        lp_lon = d*(FC1 -
+                            ds*FC3*( 1. + 2.*t + n -
+                            ds*FC5*(5. + t*(28. + 24.*t + 8.*n) + 6.*n
+                           - ds * FC7 * (61. + t * (662. + t * (1320. + 720. * t)) )
+                        ))) / cosphi;
+                    }
+                }
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_tmerc_spheroid : public base_t_fi<base_tmerc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_tmerc m_proj_parm;
+
+                inline base_tmerc_spheroid(const Parameters& par)
+                    : base_t_fi<base_tmerc_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double b, cosphi;
+
+                        /*
+                         * Fail if our longitude is more than 90 degrees from the
+                         * central meridian since the results are essentially garbage.
+                         * Is error -20 really an appropriate return value?
+                         *
+                         *  http://trac.osgeo.org/proj/ticket/5
+                         */
+                        if( lp_lon < -HALFPI || lp_lon > HALFPI )
+                        {
+                            xy_x = HUGE_VAL;
+                            xy_y = HUGE_VAL;
+                            throw proj_exception(  -14);
+                            return;
+                        }
+
+                    b = (cosphi = cos(lp_lat)) * sin(lp_lon);
+                    if (fabs(fabs(b) - 1.) <= EPS10) throw proj_exception();;
+                    xy_x = this->m_proj_parm.ml0 * log((1. + b) / (1. - b));
+                    if ((b = fabs( xy_y = cosphi * cos(lp_lon) / sqrt(1. - b * b) )) >= 1.) {
+                        if ((b - 1.) > EPS10) throw proj_exception();
+                        else xy_y = 0.;
+                    } else
+                        xy_y = acos(xy_y);
+                    if (lp_lat < 0.) xy_y = -xy_y;
+                    xy_y = this->m_proj_parm.esp * (xy_y - this->m_par.phi0);
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double h, g;
+
+                    h = exp(xy_x / this->m_proj_parm.esp);
+                    g = .5 * (h - 1. / h);
+                    h = cos(this->m_par.phi0 + xy_y / this->m_proj_parm.esp);
+                    lp_lat = asin(sqrt((1. - h * h) / (1. + g * g)));
+                    if (xy_y < 0.) lp_lat = -lp_lat;
+                    lp_lon = (g || h) ? atan2(g, h) : 0.;
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_tmerc& proj_parm)  /* general initialization */
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                if (par.es) {
+                    pj_enfn(par.es, proj_parm.en);
+
+                    proj_parm.ml0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en);
+                    proj_parm.esp = par.es / (1. - par.es);
+                // par.inv = e_inverse;
+                // par.fwd = e_forward;
+                } else {
+                    proj_parm.esp = par.k0;
+                    proj_parm.ml0 = .5 * proj_parm.esp;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                }
+            }
+
+
+            // Transverse Mercator
+            template <typename Parameters>
+            void setup_tmerc(Parameters& par, par_tmerc& proj_parm)
+            {
+                setup(par, proj_parm);
+            }
+
+            // Universal Transverse Mercator (UTM)
+            template <typename Parameters>
+            void setup_utm(Parameters& par, par_tmerc& proj_parm)
+            {
+                int zone;
+                if (!par.es) throw proj_exception(-34);
+                par.y0 = pj_param(par.params, "bsouth").i ? 10000000. : 0.;
+                par.x0 = 500000.;
+                if (pj_param(par.params, "tzone").i) /* zone input ? */
+                    if ((zone = pj_param(par.params, "izone").i) > 0 && zone <= 60)
+                        --zone;
+                    else
+                        throw proj_exception(-35);
+                else /* nearest central meridian input */
+                    if ((zone = int_floor((adjlon(par.lam0) + PI) * 30. / PI)) < 0)
+                        zone = 0;
+                    else if (zone >= 60)
+                        zone = 59;
+                par.lam0 = (zone + .5) * PI / 30. - PI;
+                par.k0 = 0.9996;
+                par.phi0 = 0.;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::tmerc
+    #endif // doxygen
+
+    /*!
+        \brief Transverse Mercator projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_tmerc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tmerc_ellipsoid : public detail::tmerc::base_tmerc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline tmerc_ellipsoid(const Parameters& par) : detail::tmerc::base_tmerc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::tmerc::setup_tmerc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Universal Transverse Mercator (UTM) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - zone= south
+        \par Example
+        \image html ex_utm.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct utm_ellipsoid : public detail::tmerc::base_tmerc_ellipsoid<Geographic, Cartesian, Parameters>
+    {
+        inline utm_ellipsoid(const Parameters& par) : detail::tmerc::base_tmerc_ellipsoid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::tmerc::setup_utm(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Transverse Mercator projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Cylindrical
+         - Spheroid
+         - Ellipsoid
+        \par Example
+        \image html ex_tmerc.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tmerc_spheroid : public detail::tmerc::base_tmerc_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline tmerc_spheroid(const Parameters& par) : detail::tmerc::base_tmerc_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::tmerc::setup_tmerc(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class tmerc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    if (par.es)
+                        return new base_v_fi<tmerc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                    else
+                        return new base_v_fi<tmerc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class utm_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<utm_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void tmerc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("tmerc", new tmerc_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("utm", new utm_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    // Create EPSG specializations
+    // (Proof of Concept, only for some)
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2000, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef tmerc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2001, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef tmerc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2002, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef tmerc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=725,685,536,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2003, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef tmerc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=tmerc +lat_0=0 +lon_0=-62 +k=0.9995000000000001 +x_0=400000 +y_0=0 +ellps=clrk80 +towgs84=72,213.7,93,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<2039, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef tmerc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +towgs84=-48,55,52,0,0,0,0 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<29118, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef utm_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=utm +zone=18 +ellps=GRS67 +units=m";
+        }
+    };
+
+
+    template<typename LatLongRadian, typename Cartesian, typename Parameters>
+    struct epsg_traits<29119, LatLongRadian, Cartesian, Parameters>
+    {
+        typedef utm_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
+        static inline std::string par()
+        {
+            return "+proj=utm +zone=19 +ellps=GRS67 +units=m";
+        }
+    };
+
+
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp b/src/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp
new file mode 100644
index 0000000..aa26534
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp
@@ -0,0 +1,198 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace tpeqd{
+
+            struct par_tpeqd
+            {
+                double cp1, sp1, cp2, sp2, ccs, cs, sc, r2z0, z02, dlam2;
+                double hz0, thz0, rhshz0, ca, sa, lp, lamc;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_tpeqd_spheroid : public base_t_fi<base_tpeqd_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_tpeqd m_proj_parm;
+
+                inline base_tpeqd_spheroid(const Parameters& par)
+                    : base_t_fi<base_tpeqd_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double t, z1, z2, dl1, dl2, sp, cp;
+
+                    sp = sin(lp_lat);
+                    cp = cos(lp_lat);
+                    z1 = aacos(this->m_proj_parm.sp1 * sp + this->m_proj_parm.cp1 * cp * cos(dl1 = lp_lon + this->m_proj_parm.dlam2));
+                    z2 = aacos(this->m_proj_parm.sp2 * sp + this->m_proj_parm.cp2 * cp * cos(dl2 = lp_lon - this->m_proj_parm.dlam2));
+                    z1 *= z1;
+                    z2 *= z2;
+                    xy_x = this->m_proj_parm.r2z0 * (t = z1 - z2);
+                    t = this->m_proj_parm.z02 - t;
+                    xy_y = this->m_proj_parm.r2z0 * asqrt(4. * this->m_proj_parm.z02 * z2 - t * t);
+                    if ((this->m_proj_parm.ccs * sp - cp * (this->m_proj_parm.cs * sin(dl1) - this->m_proj_parm.sc * sin(dl2))) < 0.)
+                        xy_y = -xy_y;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double cz1, cz2, s, d, cp, sp;
+
+                    cz1 = cos(boost::math::hypot(xy_y, xy_x + this->m_proj_parm.hz0));
+                    cz2 = cos(boost::math::hypot(xy_y, xy_x - this->m_proj_parm.hz0));
+                    s = cz1 + cz2;
+                    d = cz1 - cz2;
+                    lp_lon = - atan2(d, (s * this->m_proj_parm.thz0));
+                    lp_lat = aacos(boost::math::hypot(this->m_proj_parm.thz0 * s, d) * this->m_proj_parm.rhshz0);
+                    if ( xy_y < 0. )
+                        lp_lat = - lp_lat;
+                    /* lam--phi now in system relative to P1--P2 base equator */
+                    sp = sin(lp_lat);
+                    cp = cos(lp_lat);
+                    lp_lat = aasin(this->m_proj_parm.sa * sp + this->m_proj_parm.ca * cp * (s = cos(lp_lon -= this->m_proj_parm.lp)));
+                    lp_lon = atan2(cp * sin(lp_lon), this->m_proj_parm.sa * cp * s - this->m_proj_parm.ca * sp) + this->m_proj_parm.lamc;
+                }
+            };
+
+            // Two Point Equidistant
+            template <typename Parameters>
+            void setup_tpeqd(Parameters& par, par_tpeqd& proj_parm)
+            {
+                double lam_1, lam_2, phi_1, phi_2, A12, pp;
+                /* get control point locations */
+                phi_1 = pj_param(par.params, "rlat_1").f;
+                lam_1 = pj_param(par.params, "rlon_1").f;
+                phi_2 = pj_param(par.params, "rlat_2").f;
+                lam_2 = pj_param(par.params, "rlon_2").f;
+                if (phi_1 == phi_2 && lam_1 == lam_2) throw proj_exception(-25);
+                par.lam0 = adjlon(0.5 * (lam_1 + lam_2));
+                proj_parm.dlam2 = adjlon(lam_2 - lam_1);
+                proj_parm.cp1 = cos(phi_1);
+                proj_parm.cp2 = cos(phi_2);
+                proj_parm.sp1 = sin(phi_1);
+                proj_parm.sp2 = sin(phi_2);
+                proj_parm.cs = proj_parm.cp1 * proj_parm.sp2;
+                proj_parm.sc = proj_parm.sp1 * proj_parm.cp2;
+                proj_parm.ccs = proj_parm.cp1 * proj_parm.cp2 * sin(proj_parm.dlam2);
+                proj_parm.z02 = aacos(proj_parm.sp1 * proj_parm.sp2 + proj_parm.cp1 * proj_parm.cp2 * cos(proj_parm.dlam2));
+                proj_parm.hz0 = .5 * proj_parm.z02;
+                A12 = atan2(proj_parm.cp2 * sin(proj_parm.dlam2),
+                    proj_parm.cp1 * proj_parm.sp2 - proj_parm.sp1 * proj_parm.cp2 * cos(proj_parm.dlam2));
+                proj_parm.ca = cos(pp = aasin(proj_parm.cp1 * sin(A12)));
+                proj_parm.sa = sin(pp);
+                proj_parm.lp = adjlon(atan2(proj_parm.cp1 * cos(A12), proj_parm.sp1) - proj_parm.hz0);
+                proj_parm.dlam2 *= .5;
+                proj_parm.lamc = HALFPI - atan2(sin(A12) * proj_parm.sp1, cos(A12)) - proj_parm.dlam2;
+                proj_parm.thz0 = tan(proj_parm.hz0);
+                proj_parm.rhshz0 = .5 / sin(proj_parm.hz0);
+                proj_parm.r2z0 = 0.5 / proj_parm.z02;
+                proj_parm.z02 *= proj_parm.z02;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::tpeqd
+    #endif // doxygen
+
+    /*!
+        \brief Two Point Equidistant projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - lat_1= lon_1= lat_2= lon_2=
+        \par Example
+        \image html ex_tpeqd.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct tpeqd_spheroid : public detail::tpeqd::base_tpeqd_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline tpeqd_spheroid(const Parameters& par) : detail::tpeqd::base_tpeqd_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::tpeqd::setup_tpeqd(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class tpeqd_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<tpeqd_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void tpeqd_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("tpeqd", new tpeqd_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_TPEQD_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/urm5.hpp b/src/boost/geometry/extensions/gis/projections/proj/urm5.hpp
new file mode 100644
index 0000000..157dd10
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/urm5.hpp
@@ -0,0 +1,149 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_URM5_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_URM5_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace urm5{
+
+            struct par_urm5
+            {
+                double m, rmn, q3, n;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_urm5_spheroid : public base_t_f<base_urm5_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_urm5 m_proj_parm;
+
+                inline base_urm5_spheroid(const Parameters& par)
+                    : base_t_f<base_urm5_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double t;
+
+                    t = lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat));
+                    xy_x = this->m_proj_parm.m * lp_lon * cos(lp_lat);
+                    t *= t;
+                    xy_y = lp_lat * (1. + t * this->m_proj_parm.q3) * this->m_proj_parm.rmn;
+                }
+            };
+
+            // Urmaev V
+            template <typename Parameters>
+            void setup_urm5(Parameters& par, par_urm5& proj_parm)
+            {
+                double alpha, t;
+                proj_parm.n = pj_param(par.params, "dn").f;
+                proj_parm.q3 = pj_param(par.params, "dq").f / 3.;
+                alpha = pj_param(par.params, "ralpha").f;
+                t = proj_parm.n * sin(alpha);
+                proj_parm.m = cos(alpha) / sqrt(1. - t * t);
+                proj_parm.rmn = 1. / (proj_parm.m * proj_parm.n);
+                par.es = 0.;
+                // par.inv = 0;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::urm5
+    #endif // doxygen
+
+    /*!
+        \brief Urmaev V projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - n= q= alphi=
+        \par Example
+        \image html ex_urm5.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct urm5_spheroid : public detail::urm5::base_urm5_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline urm5_spheroid(const Parameters& par) : detail::urm5::base_urm5_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::urm5::setup_urm5(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class urm5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<urm5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void urm5_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("urm5", new urm5_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_URM5_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/urmfps.hpp b/src/boost/geometry/extensions/gis/projections/proj/urmfps.hpp
new file mode 100644
index 0000000..e2375a6
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/urmfps.hpp
@@ -0,0 +1,205 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/concept_check.hpp>
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace urmfps{
+            static const double C_x = 0.8773826753;
+            static const double Cy = 1.139753528477;
+
+            struct par_urmfps
+            {
+                double    n, C_y;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_urmfps_spheroid : public base_t_fi<base_urmfps_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_urmfps m_proj_parm;
+
+                inline base_urmfps_spheroid(const Parameters& par)
+                    : base_t_fi<base_urmfps_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    lp_lat = aasin(this->m_proj_parm.n * sin(lp_lat));
+                    xy_x = C_x * lp_lon * cos(lp_lat);
+                    xy_y = this->m_proj_parm.C_y * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    xy_y /= this->m_proj_parm.C_y;
+                    lp_lat = aasin(sin(xy_y) / this->m_proj_parm.n);
+                    lp_lon = xy_x / (C_x * cos(xy_y));
+                }
+            };
+
+            template <typename Parameters>
+            void setup(Parameters& par, par_urmfps& proj_parm)
+            {
+                boost::ignore_unused_variable_warning(par);
+                boost::ignore_unused_variable_warning(proj_parm);
+                proj_parm.C_y = Cy / proj_parm.n;
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+
+            // Urmaev Flat-Polar Sinusoidal
+            template <typename Parameters>
+            void setup_urmfps(Parameters& par, par_urmfps& proj_parm)
+            {
+                if (pj_param(par.params, "tn").i) {
+                    proj_parm.n = pj_param(par.params, "dn").f;
+                    if (proj_parm.n <= 0. || proj_parm.n > 1.)
+                        throw proj_exception(-40);
+                } else
+                    throw proj_exception(-40);
+                setup(par, proj_parm);
+            }
+
+            // Wagner I (Kavraisky VI)
+            template <typename Parameters>
+            void setup_wag1(Parameters& par, par_urmfps& proj_parm)
+            {
+                proj_parm.n = 0.8660254037844386467637231707;
+                setup(par, proj_parm);
+            }
+
+        }} // namespace detail::urmfps
+    #endif // doxygen
+
+    /*!
+        \brief Urmaev Flat-Polar Sinusoidal projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - n=
+        \par Example
+        \image html ex_urmfps.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct urmfps_spheroid : public detail::urmfps::base_urmfps_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline urmfps_spheroid(const Parameters& par) : detail::urmfps::base_urmfps_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::urmfps::setup_urmfps(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief Wagner I (Kavraisky VI) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_wag1.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag1_spheroid : public detail::urmfps::base_urmfps_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag1_spheroid(const Parameters& par) : detail::urmfps::base_urmfps_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::urmfps::setup_wag1(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class urmfps_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<urmfps_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wag1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void urmfps_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("urmfps", new urmfps_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("wag1", new wag1_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_URMFPS_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/vandg.hpp b/src/boost/geometry/extensions/gis/projections/proj/vandg.hpp
new file mode 100644
index 0000000..12225d5
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/vandg.hpp
@@ -0,0 +1,201 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace vandg{
+            static const double TOL = 1.e-10;
+            static const double THIRD = .33333333333333333333;
+            static const double TWO_THRD = .66666666666666666666;
+            static const double C2_27 = .07407407407407407407;
+            static const double PI4_3 = 4.18879020478639098458;
+            static const double PISQ = 9.86960440108935861869;
+            static const double TPISQ = 19.73920880217871723738;
+            static const double HPISQ = 4.93480220054467930934;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_vandg_spheroid : public base_t_fi<base_vandg_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_vandg_spheroid(const Parameters& par)
+                    : base_t_fi<base_vandg_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double  al, al2, g, g2, p2;
+
+                    p2 = fabs(lp_lat / HALFPI);
+                    if ((p2 - TOL) > 1.) throw proj_exception();;
+                    if (p2 > 1.)
+                        p2 = 1.;
+                    if (fabs(lp_lat) <= TOL) {
+                        xy_x = lp_lon;
+                        xy_y = 0.;
+                    } else if (fabs(lp_lon) <= TOL || fabs(p2 - 1.) < TOL) {
+                        xy_x = 0.;
+                        xy_y = PI * tan(.5 * asin(p2));
+                        if (lp_lat < 0.) xy_y = -xy_y;
+                    } else {
+                        al = .5 * fabs(PI / lp_lon - lp_lon / PI);
+                        al2 = al * al;
+                        g = sqrt(1. - p2 * p2);
+                        g = g / (p2 + g - 1.);
+                        g2 = g * g;
+                        p2 = g * (2. / p2 - 1.);
+                        p2 = p2 * p2;
+                        xy_x = g - p2; g = p2 + al2;
+                        xy_x = PI * (al * xy_x + sqrt(al2 * xy_x * xy_x - g * (g2 - p2))) / g;
+                        if (lp_lon < 0.) xy_x = -xy_x;
+                        xy_y = fabs(xy_x / PI);
+                        xy_y = 1. - xy_y * (xy_y + 2. * al);
+                        if (xy_y < -TOL) throw proj_exception();;
+                        if (xy_y < 0.)    xy_y = 0.;
+                        else        xy_y = sqrt(xy_y) * (lp_lat < 0. ? -PI : PI);
+                    }
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    double t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2;
+
+                    x2 = xy_x * xy_x;
+                    if ((ay = fabs(xy_y)) < TOL) {
+                        lp_lat = 0.;
+                        t = x2 * x2 + TPISQ * (x2 + HPISQ);
+                        lp_lon = fabs(xy_x) <= TOL ? 0. :
+                           .5 * (x2 - PISQ + sqrt(t)) / xy_x;
+                            return;
+                    }
+                    y2 = xy_y * xy_y;
+                    r = x2 + y2;    r2 = r * r;
+                    c1 = - PI * ay * (r + PISQ);
+                    c3 = r2 + TWOPI * (ay * r + PI * (y2 + PI * (ay + HALFPI)));
+                    c2 = c1 + PISQ * (r - 3. *  y2);
+                    c0 = PI * ay;
+                    c2 /= c3;
+                    al = c1 / c3 - THIRD * c2 * c2;
+                    m = 2. * sqrt(-THIRD * al);
+                    d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3;
+                    if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) {
+                        d = t > 1. ? (d > 0. ? 0. : PI) : acos(d);
+                        lp_lat = PI * (m * cos(d * THIRD + PI4_3) - THIRD * c2);
+                        if (xy_y < 0.) lp_lat = -lp_lat;
+                        t = r2 + TPISQ * (x2 - y2 + HPISQ);
+                        lp_lon = fabs(xy_x) <= TOL ? 0. :
+                           .5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy_x;
+                    } else
+                        throw proj_exception();;
+                }
+            };
+
+            // van der Grinten (I)
+            template <typename Parameters>
+            void setup_vandg(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::vandg
+    #endif // doxygen
+
+    /*!
+        \brief van der Grinten (I) projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+        \par Example
+        \image html ex_vandg.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct vandg_spheroid : public detail::vandg::base_vandg_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline vandg_spheroid(const Parameters& par) : detail::vandg::base_vandg_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::vandg::setup_vandg(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class vandg_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<vandg_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void vandg_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("vandg", new vandg_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_VANDG_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/vandg2.hpp b/src/boost/geometry/extensions/gis/projections/proj/vandg2.hpp
new file mode 100644
index 0000000..b5ca977
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/vandg2.hpp
@@ -0,0 +1,205 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace vandg2{
+            static const double TOL = 1e-10;
+            static const double TWORPI = 0.63661977236758134308;
+
+            struct par_vandg2
+            {
+                int    vdg3;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_vandg2_spheroid : public base_t_f<base_vandg2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_vandg2 m_proj_parm;
+
+                inline base_vandg2_spheroid(const Parameters& par)
+                    : base_t_f<base_vandg2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double x1, at, bt, ct;
+
+                    bt = fabs(TWORPI * lp_lat);
+                    if ((ct = 1. - bt * bt) < 0.)
+                        ct = 0.;
+                    else
+                        ct = sqrt(ct);
+                    if (fabs(lp_lon) < TOL) {
+                        xy_x = 0.;
+                        xy_y = PI * (lp_lat < 0. ? -bt : bt) / (1. + ct);
+                    } else {
+                        at = 0.5 * fabs(PI / lp_lon - lp_lon / PI);
+                        if (this->m_proj_parm.vdg3) {
+                            x1 = bt / (1. + ct);
+                            xy_x = PI * (sqrt(at * at + 1. - x1 * x1) - at);
+                            xy_y = PI * x1;
+                        } else {
+                            x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
+                                (1. + at * at * bt * bt);
+                            xy_x = PI * x1;
+                            xy_y = PI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
+                        }
+                        if ( lp_lon < 0.) xy_x = -xy_x;
+                        if ( lp_lat < 0.) xy_y = -xy_y;
+                    }
+                }
+            };
+
+            // van der Grinten II
+            template <typename Parameters>
+            void setup_vandg2(Parameters& par, par_vandg2& proj_parm)
+            {
+                proj_parm.vdg3 = 0;
+                // par.inv = 0;
+                // par.fwd = s_forward;
+            }
+
+            // van der Grinten III
+            template <typename Parameters>
+            void setup_vandg3(Parameters& par, par_vandg2& proj_parm)
+            {
+                proj_parm.vdg3 = 1;
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::vandg2
+    #endif // doxygen
+
+    /*!
+        \brief van der Grinten II projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_vandg2.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct vandg2_spheroid : public detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline vandg2_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::vandg2::setup_vandg2(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    /*!
+        \brief van der Grinten III projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_vandg3.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct vandg3_spheroid : public detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline vandg3_spheroid(const Parameters& par) : detail::vandg2::base_vandg2_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::vandg2::setup_vandg3(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class vandg2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<vandg2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class vandg3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<vandg3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void vandg2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("vandg2", new vandg2_entry<Geographic, Cartesian, Parameters>);
+            factory.add_to_factory("vandg3", new vandg3_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_VANDG2_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/vandg4.hpp b/src/boost/geometry/extensions/gis/projections/proj/vandg4.hpp
new file mode 100644
index 0000000..dab62bf
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/vandg4.hpp
@@ -0,0 +1,163 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace vandg4{
+            static const double TOL = 1e-10;
+            static const double TWORPI = 0.63661977236758134308;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_vandg4_spheroid : public base_t_f<base_vandg4_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_vandg4_spheroid(const Parameters& par)
+                    : base_t_f<base_vandg4_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double x1, t, bt, ct, ft, bt2, ct2, dt, dt2;
+
+                    if (fabs(lp_lat) < TOL) {
+                        xy_x = lp_lon;
+                        xy_y = 0.;
+                    } else if (fabs(lp_lon) < TOL || fabs(fabs(lp_lat) - HALFPI) < TOL) {
+                        xy_x = 0.;
+                        xy_y = lp_lat;
+                    } else {
+                        bt = fabs(TWORPI * lp_lat);
+                        bt2 = bt * bt;
+                        ct = 0.5 * (bt * (8. - bt * (2. + bt2)) - 5.)
+                            / (bt2 * (bt - 1.));
+                        ct2 = ct * ct;
+                        dt = TWORPI * lp_lon;
+                        dt = dt + 1. / dt;
+                        dt = sqrt(dt * dt - 4.);
+                        if ((fabs(lp_lon) - HALFPI) < 0.) dt = -dt;
+                        dt2 = dt * dt;
+                        x1 = bt + ct; x1 *= x1;
+                        t = bt + 3.*ct;
+                        ft = x1 * (bt2 + ct2 * dt2 - 1.) + (1.-bt2) * (
+                            bt2 * (t * t + 4. * ct2) +
+                            ct2 * (12. * bt * ct + 4. * ct2) );
+                        x1 = (dt*(x1 + ct2 - 1.) + 2.*sqrt(ft)) /
+                            (4.* x1 + dt2);
+                        xy_x = HALFPI * x1;
+                        xy_y = HALFPI * sqrt(1. + dt * fabs(x1) - x1 * x1);
+                        if (lp_lon < 0.) xy_x = -xy_x;
+                        if (lp_lat < 0.) xy_y = -xy_y;
+                    }
+                }
+            };
+
+            // van der Grinten IV
+            template <typename Parameters>
+            void setup_vandg4(Parameters& par)
+            {
+                par.es = 0.;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::vandg4
+    #endif // doxygen
+
+    /*!
+        \brief van der Grinten IV projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_vandg4.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct vandg4_spheroid : public detail::vandg4::base_vandg4_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline vandg4_spheroid(const Parameters& par) : detail::vandg4::base_vandg4_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::vandg4::setup_vandg4(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class vandg4_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<vandg4_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void vandg4_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("vandg4", new vandg4_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_VANDG4_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/wag2.hpp b/src/boost/geometry/extensions/gis/projections/proj/wag2.hpp
new file mode 100644
index 0000000..3a1bd51
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/wag2.hpp
@@ -0,0 +1,144 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace wag2{
+            static const double C_x = 0.92483;
+            static const double C_y = 1.38725;
+            static const double C_p1 = 0.88022;
+            static const double C_p2 = 0.88550;
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_wag2_spheroid : public base_t_fi<base_wag2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_wag2_spheroid(const Parameters& par)
+                    : base_t_fi<base_wag2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    lp_lat = aasin(C_p1 * sin(C_p2 * lp_lat));
+                    xy_x = C_x * lp_lon * cos(lp_lat);
+                    xy_y = C_y * lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y / C_y;
+                    lp_lon = xy_x / (C_x * cos(lp_lat));
+                    lp_lat = aasin(sin(lp_lat) / C_p1) / C_p2;
+                }
+            };
+
+            // Wagner II
+            template <typename Parameters>
+            void setup_wag2(Parameters& par)
+            {
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::wag2
+    #endif // doxygen
+
+    /*!
+        \brief Wagner II projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+        \par Example
+        \image html ex_wag2.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag2_spheroid : public detail::wag2::base_wag2_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag2_spheroid(const Parameters& par) : detail::wag2::base_wag2_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::wag2::setup_wag2(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wag2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void wag2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("wag2", new wag2_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_WAG2_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/wag3.hpp b/src/boost/geometry/extensions/gis/projections/proj/wag3.hpp
new file mode 100644
index 0000000..ecc4ce7
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/wag3.hpp
@@ -0,0 +1,148 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace wag3{
+            static const double TWOTHIRD = 0.6666666666666666666667;
+
+            struct par_wag3
+            {
+                double    C_x;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_wag3_spheroid : public base_t_fi<base_wag3_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_wag3 m_proj_parm;
+
+                inline base_wag3_spheroid(const Parameters& par)
+                    : base_t_fi<base_wag3_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = this->m_proj_parm.C_x * lp_lon * cos(TWOTHIRD * lp_lat);
+                    xy_y = lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y;
+                    lp_lon = xy_x / (this->m_proj_parm.C_x * cos(TWOTHIRD * lp_lat));
+                }
+            };
+
+            // Wagner III
+            template <typename Parameters>
+            void setup_wag3(Parameters& par, par_wag3& proj_parm)
+            {
+                double ts;
+                ts = pj_param(par.params, "rlat_ts").f;
+                proj_parm.C_x = cos(ts) / cos(2.*ts/3.);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::wag3
+    #endif // doxygen
+
+    /*!
+        \brief Wagner III projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - lat_ts=
+        \par Example
+        \image html ex_wag3.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag3_spheroid : public detail::wag3::base_wag3_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag3_spheroid(const Parameters& par) : detail::wag3::base_wag3_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::wag3::setup_wag3(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wag3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void wag3_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("wag3", new wag3_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_WAG3_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/wag7.hpp b/src/boost/geometry/extensions/gis/projections/proj/wag7.hpp
new file mode 100644
index 0000000..b957c99
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/wag7.hpp
@@ -0,0 +1,137 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace wag7{
+
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_wag7_spheroid : public base_t_f<base_wag7_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+
+                inline base_wag7_spheroid(const Parameters& par)
+                    : base_t_f<base_wag7_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double theta, ct, D;
+
+                    theta = asin(xy_y = 0.90630778703664996 * sin(lp_lat));
+                    xy_x = 2.66723 * (ct = cos(theta)) * sin(lp_lon /= 3.);
+                    xy_y *= 1.24104 * (D = 1/(sqrt(0.5 * (1 + ct * cos(lp_lon)))));
+                    xy_x *= D;
+                }
+            };
+
+            // Wagner VII
+            template <typename Parameters>
+            void setup_wag7(Parameters& par)
+            {
+                // par.fwd = s_forward;
+                // par.inv = 0;
+                par.es = 0.;
+            }
+
+        }} // namespace detail::wag7
+    #endif // doxygen
+
+    /*!
+        \brief Wagner VII projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Miscellaneous
+         - Spheroid
+         - no inverse
+        \par Example
+        \image html ex_wag7.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wag7_spheroid : public detail::wag7::base_wag7_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wag7_spheroid(const Parameters& par) : detail::wag7::base_wag7_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::wag7::setup_wag7(this->m_par);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wag7_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<wag7_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void wag7_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("wag7", new wag7_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_WAG7_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/wink1.hpp b/src/boost/geometry/extensions/gis/projections/proj/wink1.hpp
new file mode 100644
index 0000000..38d8156
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/wink1.hpp
@@ -0,0 +1,145 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace wink1{
+
+            struct par_wink1
+            {
+                double    cosphi1;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_wink1_spheroid : public base_t_fi<base_wink1_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_wink1 m_proj_parm;
+
+                inline base_wink1_spheroid(const Parameters& par)
+                    : base_t_fi<base_wink1_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    xy_x = .5 * lp_lon * (this->m_proj_parm.cosphi1 + cos(lp_lat));
+                    xy_y = lp_lat;
+                }
+
+                inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
+                {
+                    lp_lat = xy_y;
+                    lp_lon = 2. * xy_x / (this->m_proj_parm.cosphi1 + cos(lp_lat));
+                }
+            };
+
+            // Winkel I
+            template <typename Parameters>
+            void setup_wink1(Parameters& par, par_wink1& proj_parm)
+            {
+                proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_ts").f);
+                par.es = 0.;
+                // par.inv = s_inverse;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::wink1
+    #endif // doxygen
+
+    /*!
+        \brief Winkel I projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - lat_ts=
+        \par Example
+        \image html ex_wink1.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wink1_spheroid : public detail::wink1::base_wink1_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wink1_spheroid(const Parameters& par) : detail::wink1::base_wink1_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::wink1::setup_wink1(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wink1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_fi<wink1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void wink1_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("wink1", new wink1_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_WINK1_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/proj/wink2.hpp b/src/boost/geometry/extensions/gis/projections/proj/wink2.hpp
new file mode 100644
index 0000000..a7d48f0
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/proj/wink2.hpp
@@ -0,0 +1,159 @@
+#ifndef BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
+
+// Boost.Geometry - extensions-gis-projections (based on PROJ4)
+// This file is automatically generated. DO NOT EDIT.
+
+// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// This file is converted from PROJ4, http://trac.osgeo.org/proj
+// PROJ4 is originally written by Gerald Evenden (then of the USGS)
+// PROJ4 is maintained by Frank Warmerdam
+// PROJ4 is converted to Boost.Geometry by Barend Gehrels (Geodan, Amsterdam)
+
+// Original copyright notice:
+
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+#include <boost/math/special_functions/hypot.hpp>
+
+#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail { namespace wink2{
+            static const int MAX_ITER = 10;
+            static const double LOOP_TOL = 1e-7;
+            static const double TWO_D_PI = 0.636619772367581343;
+
+            struct par_wink2
+            {
+                double    cosphi1;
+            };
+
+            // template class, using CRTP to implement forward/inverse
+            template <typename Geographic, typename Cartesian, typename Parameters>
+            struct base_wink2_spheroid : public base_t_f<base_wink2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>
+            {
+
+                 typedef double geographic_type;
+                 typedef double cartesian_type;
+
+                par_wink2 m_proj_parm;
+
+                inline base_wink2_spheroid(const Parameters& par)
+                    : base_t_f<base_wink2_spheroid<Geographic, Cartesian, Parameters>,
+                     Geographic, Cartesian, Parameters>(*this, par) {}
+
+                inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
+                {
+                    double k, V;
+                    int i;
+
+                    xy_y = lp_lat * TWO_D_PI;
+                    k = PI * sin(lp_lat);
+                    lp_lat *= 1.8;
+                    for (i = MAX_ITER; i ; --i) {
+                        lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
+                            (1. + cos(lp_lat));
+                        if (fabs(V) < LOOP_TOL)
+                            break;
+                    }
+                    if (!i)
+                        lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
+                    else
+                        lp_lat *= 0.5;
+                    xy_x = 0.5 * lp_lon * (cos(lp_lat) + this->m_proj_parm.cosphi1);
+                    xy_y = FORTPI * (sin(lp_lat) + xy_y);
+                }
+            };
+
+            // Winkel II
+            template <typename Parameters>
+            void setup_wink2(Parameters& par, par_wink2& proj_parm)
+            {
+                proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_1").f);
+                par.es = 0.;
+                // par.inv = 0;
+                // par.fwd = s_forward;
+            }
+
+        }} // namespace detail::wink2
+    #endif // doxygen
+
+    /*!
+        \brief Winkel II projection
+        \ingroup projections
+        \tparam Geographic latlong point type
+        \tparam Cartesian xy point type
+        \tparam Parameters parameter type
+        \par Projection characteristics
+         - Pseudocylindrical
+         - Spheroid
+         - no inverse
+         - lat_1=
+        \par Example
+        \image html ex_wink2.gif
+    */
+    template <typename Geographic, typename Cartesian, typename Parameters = parameters>
+    struct wink2_spheroid : public detail::wink2::base_wink2_spheroid<Geographic, Cartesian, Parameters>
+    {
+        inline wink2_spheroid(const Parameters& par) : detail::wink2::base_wink2_spheroid<Geographic, Cartesian, Parameters>(par)
+        {
+            detail::wink2::setup_wink2(this->m_par, this->m_proj_parm);
+        }
+    };
+
+    #ifndef DOXYGEN_NO_DETAIL
+    namespace detail
+    {
+
+        // Factory entry(s)
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        class wink2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
+        {
+            public :
+                virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
+                {
+                    return new base_v_f<wink2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
+                }
+        };
+
+        template <typename Geographic, typename Cartesian, typename Parameters>
+        inline void wink2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
+        {
+            factory.add_to_factory("wink2", new wink2_entry<Geographic, Cartesian, Parameters>);
+        }
+
+    } // namespace detail
+    #endif // doxygen
+
+}}} // namespace boost::geometry::projection
+
+#endif // BOOST_GEOMETRY_PROJECTIONS_WINK2_HPP
+
diff --git a/src/boost/geometry/extensions/gis/projections/project_inverse_transformer.hpp b/src/boost/geometry/extensions/gis/projections/project_inverse_transformer.hpp
new file mode 100644
index 0000000..832fa8a
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/project_inverse_transformer.hpp
@@ -0,0 +1,73 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGY_PROJECT_INVERSE_TRANSFORMER_HPP
+#define BOOST_GEOMETRY_STRATEGY_PROJECT_INVERSE_TRANSFORMER_HPP
+
+
+#include <boost/shared_ptr.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/extensions/gis/projections/factory.hpp>
+#include <boost/geometry/extensions/gis/projections/parameters.hpp>
+
+
+namespace boost { namespace geometry { namespace projection
+{
+
+
+/*!
+    \brief Transformation strategy to do transform using a Map Projection
+    \ingroup transform
+    \tparam Cartesian first point type
+    \tparam LatLong second point type
+ */
+template <typename Cartesian, typename LatLong>
+struct project_inverse_transformer
+{
+    typedef boost::shared_ptr<projection<LatLong, Cartesian> > projection_ptr;
+
+    projection_ptr m_prj;
+
+    /// Constructor using a shared-pointer-to-projection_ptr
+    inline project_inverse_transformer(projection_ptr& prj)
+        : m_prj(prj)
+    {}
+
+    /// Constructor using a string
+    inline project_inverse_transformer(std::string const& par)
+    {
+        factory<LatLong, Cartesian, parameters> fac;
+        m_prj.reset(fac.create_new(init(par)));
+    }
+
+    /// Constructor using Parameters
+    template <typename Parameters>
+    inline project_inverse_transformer(Parameters const& par)
+    {
+        factory<LatLong, Cartesian, Parameters> fac;
+        m_prj.reset(fac.create_new(par));
+    }
+
+    /// Transform operator
+    inline bool apply(Cartesian const& p1, LatLong& p2) const
+    {
+        // Latlong (LL -> XY) will be projected, rest will be copied.
+        // So first copy third or higher dimensions
+        geometry::detail::convert::point_to_point<Cartesian, LatLong, 2,
+                geometry::dimension<Cartesian>::value> ::copy(p1, p2);
+        return m_prj->inverse(p1, p2);
+    }
+
+};
+
+}}} // namespace boost::geometry::projection
+
+
+#endif // BOOST_GEOMETRY_STRATEGY_PROJECT_INVERSE_TRANSFORMER_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/project_transformer.hpp b/src/boost/geometry/extensions/gis/projections/project_transformer.hpp
new file mode 100644
index 0000000..02ddff4
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/project_transformer.hpp
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGY_PROJECT_TRANSFORMER_HPP
+#define BOOST_GEOMETRY_STRATEGY_PROJECT_TRANSFORMER_HPP
+
+
+#include <boost/shared_ptr.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/extensions/gis/projections/factory.hpp>
+#include <boost/geometry/extensions/gis/projections/parameters.hpp>
+
+
+
+namespace boost { namespace geometry { namespace projection
+{
+/*!
+    \brief Transformation strategy to do transform using a Map Projection
+    \ingroup transform
+    \tparam LatLong first point type
+    \tparam Cartesian second point type
+
+    See also \link p03_projmap_example.cpp the projmap example \endlink
+    where this last one plus a transformation using a projection are used.
+
+ */
+template <typename LatLong, typename Cartesian>
+struct project_transformer
+{
+    typedef boost::shared_ptr<projection<LatLong, Cartesian> > projection_ptr;
+
+    projection_ptr m_prj;
+
+    inline project_transformer(projection_ptr& prj)
+        : m_prj(prj)
+    {}
+
+    inline project_transformer(std::string const& par)
+    {
+        factory<LatLong, Cartesian, parameters> fac;
+        m_prj.reset(fac.create_new(init(par)));
+    }
+
+    inline bool apply(LatLong const& p1, Cartesian& p2) const
+    {
+        // Latlong (LatLong -> Cartesian) will be projected, rest will be copied.
+        // So first copy third or higher dimensions
+        geometry::detail::convert::point_to_point<LatLong, Cartesian, 2,
+                geometry::dimension<Cartesian>::value> ::copy(p1, p2);
+        return m_prj->forward(p1, p2);
+    }
+
+};
+
+}}} // namespace boost::geometry::projection
+
+
+#endif // BOOST_GEOMETRY_STRATEGY_PROJECT_TRANSFORMER_HPP
diff --git a/src/boost/geometry/extensions/gis/projections/projection.hpp b/src/boost/geometry/extensions/gis/projections/projection.hpp
new file mode 100644
index 0000000..fc0dfcd
--- /dev/null
+++ b/src/boost/geometry/extensions/gis/projections/projection.hpp
@@ -0,0 +1,65 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_PROJECTIONS_PROJECTION_HPP
+#define BOOST_GEOMETRY_PROJECTIONS_PROJECTION_HPP
+
+
+#include <string>
+#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
+
+namespace boost { namespace geometry { namespace projection
+{
+
+/*!
+    \brief projection virtual base class
+    \details class containing virtual methods
+    \ingroup projection
+    \tparam LL latlong point type
+    \tparam XY xy point type
+*/
+
+template <typename LL, typename XY>
+class projection
+{
+    protected :
+        // see comment above
+        //typedef typename geometry::coordinate_type<LL>::type LL_T;
+        //typedef typename geometry::coordinate_type<XY>::type XY_T;
+        typedef double LL_T;
+        typedef double XY_T;
+
+    public :
+        /// Forward projection, from Latitude-Longitude to Cartesian
+        virtual bool forward(LL const& lp, XY& xy) const = 0;
+
+        /// Inverse projection, from Cartesian to Latitude-Longitude
+        virtual bool inverse(XY const& xy, LL& lp) const = 0;
+
+        /// Forward projection using lon / lat and x / y separately
+        virtual void fwd(LL_T& lp_lon, LL_T& lp_lat, XY_T& xy_x, XY_T& xy_y) const = 0;
+
+        /// Inverse projection using x / y and lon / lat
+        virtual void inv(XY_T& xy_x, XY_T& xy_y, LL_T& lp_lon, LL_T& lp_lat) const = 0;
+
+        /// Returns name of projection
+        virtual std::string name() const = 0;
+
+        /// Returns parameters of projection
+        virtual parameters params() const = 0;
+
+        virtual ~projection() {}
+
+};
+
+}}} // namespace boost::geometry::projection
+
+
+
+#endif
+
diff --git a/src/boost/geometry/extensions/index/rtree/helpers.hpp b/src/boost/geometry/extensions/index/rtree/helpers.hpp
new file mode 100644
index 0000000..45a71f3
--- /dev/null
+++ b/src/boost/geometry/extensions/index/rtree/helpers.hpp
@@ -0,0 +1,68 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Boost.SpatialIndex - geometry helper functions
+//
+// Copyright 2008 Federico J. Fernandez.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GGL_INDEX_RTREE_HELPERS_HPP
+#define BOOST_GEOMETRY_GGL_INDEX_RTREE_HELPERS_HPP
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+namespace boost { namespace geometry { namespace index {
+
+/**
+ * \brief Given two boxes, returns the minimal box that contains them
+ */
+// TODO: use geometry::expand
+template <typename Box>
+inline Box enlarge_box(Box const& b1, Box const& b2)
+{
+    // TODO: mloskot - Refactor to readable form. Fix VC++8.0 min/max warnings:
+    //  warning C4002: too many actual parameters for macro 'min
+
+    typedef typename geometry::point_type<Box>::type point_type;
+
+    point_type pmin(
+        geometry::get<min_corner, 0>(b1) < geometry::get<min_corner, 0>(b2)
+            ? geometry::get<min_corner, 0>(b1) : geometry::get<min_corner, 0>(b2),
+        geometry::get<min_corner, 1>(b1) < geometry::get<min_corner, 1>(b2)
+            ? geometry::get<min_corner, 1>(b1) : geometry::get<min_corner, 1>(b2));
+
+    point_type pmax(
+        geometry::get<max_corner, 0>(b1) > geometry::get<max_corner, 0>(b2)
+            ? geometry::get<max_corner, 0>(b1) : geometry::get<max_corner, 0>(b2),
+        geometry::get<max_corner, 1>(b1) > geometry::get<max_corner, 1>(b2)
+            ? geometry::get<max_corner, 1>(b1) : geometry::get<max_corner, 1>(b2));
+
+    return Box(pmin, pmax);
+}
+
+/**
+ * \brief Compute the area of the union of b1 and b2
+ */
+template <typename Box>
+inline typename default_area_result<Box>::type compute_union_area(Box const& b1, Box const& b2)
+{
+    Box enlarged_box = enlarge_box(b1, b2);
+    return geometry::area(enlarged_box);
+}
+
+/**
+ * \brief Checks if boxes intersects
+ */
+// TODO: move to geometry::intersects
+template <typename Box>
+inline bool is_overlapping(Box const& b1, Box const& b2)
+{
+    return ! geometry::disjoint(b1, b2);
+}
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_GGL_INDEX_RTREE_HELPERS_HPP
diff --git a/src/boost/geometry/extensions/index/rtree/rtree.hpp b/src/boost/geometry/extensions/index/rtree/rtree.hpp
new file mode 100644
index 0000000..4a06bd6
--- /dev/null
+++ b/src/boost/geometry/extensions/index/rtree/rtree.hpp
@@ -0,0 +1,774 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Boost.SpatialIndex - rtree implementation
+//
+// Copyright 2008 Federico J. Fernandez.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
+
+#include <cstddef>
+#include <iostream> // TODO: Remove if print() is removed
+#include <stdexcept>
+#include <utility>
+#include <vector>
+
+#include <boost/concept_check.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+
+#include <boost/geometry/extensions/index/rtree/rtree_node.hpp>
+#include <boost/geometry/extensions/index/rtree/rtree_leaf.hpp>
+
+namespace boost { namespace geometry { namespace index
+{
+
+template <typename Box, typename Value >
+class rtree
+{
+public:
+
+    typedef boost::shared_ptr<rtree_node<Box, Value> > node_pointer;
+    typedef boost::shared_ptr<rtree_leaf<Box, Value> > leaf_pointer;
+
+    /**
+     * \brief Creates a rtree with 'maximum' elements per node and 'minimum'.
+     */
+    rtree(unsigned int const& maximum, unsigned int const& minimum)
+        : m_count(0)
+        , m_min_elems_per_node(minimum)
+        , m_max_elems_per_node(maximum)
+        , m_root(new rtree_node<Box, Value>(node_pointer(), 1))
+    {
+    }
+
+    /**
+     * \brief Creates a rtree with maximum elements per node
+     *        and minimum (box is ignored).
+     */
+    rtree(Box const& box, unsigned int const& maximum, unsigned int const& minimum)
+        : m_count(0)
+        , m_min_elems_per_node(minimum)
+        , m_max_elems_per_node(maximum)
+        , m_root(new rtree_node<Box, Value>(node_pointer(), 1))
+    {
+        boost::ignore_unused_variable_warning(box);
+    }
+
+    /**
+     * \brief destructor (virtual because we have virtual functions)
+     */
+    virtual ~rtree() {}
+
+
+    /**
+     * \brief Remove elements inside the 'box'
+     */
+    inline void remove(Box const& box)
+    {
+        try
+        {
+            node_pointer leaf(choose_exact_leaf(box));
+            typename rtree_leaf<Box, Value>::leaf_map q_leaves;
+
+            leaf->remove(box);
+
+            if (leaf->elements() < m_min_elems_per_node && elements() > m_min_elems_per_node)
+            {
+                q_leaves = leaf->get_leaves();
+
+                // we remove the leaf_node in the parent node because now it's empty
+                leaf->get_parent()->remove(leaf->get_parent()->get_box(leaf));
+            }
+
+            typename rtree_node<Box, Value>::node_map q_nodes;
+            condense_tree(leaf, q_nodes);
+
+            std::vector<std::pair<Box, Value> > s;
+            for (typename rtree_node<Box, Value>::node_map::const_iterator it = q_nodes.begin();
+                 it != q_nodes.end(); ++it)
+            {
+                typename rtree_leaf<Box, Value>::leaf_map leaves = it->second->get_leaves();
+
+                // reinserting leaves from nodes
+                for (typename rtree_leaf<Box, Value>::leaf_map::const_iterator itl = leaves.begin();
+                     itl != leaves.end(); ++itl)
+                {
+                    s.push_back(*itl);
+                }
+            }
+
+            for (typename std::vector<std::pair<Box, Value> >::const_iterator it = s.begin(); it != s.end(); ++it)
+            {
+                m_count--;
+                insert(it->first, it->second);
+            }
+
+            // if the root has only one child and the child is not a leaf,
+            // make it the root
+            if (m_root->elements() == 1)
+            {
+                if (!m_root->first_element()->is_leaf())
+                {
+                    m_root = m_root->first_element();
+                }
+            }
+            // reinserting leaves
+            for (typename rtree_leaf<Box, Value>::leaf_map::const_iterator it = q_leaves.begin();
+                 it != q_leaves.end(); ++it)
+            {
+                m_count--;
+                insert(it->first, it->second);
+            }
+
+            m_count--;
+        }
+        catch(std::logic_error & e)
+        {
+            // TODO: mloskot - replace with Boost.Geometry exception
+
+            // not found
+            std::cerr << e.what() << std::endl;
+            return;
+        }
+    }
+
+    /**
+     * \brief Remove element inside the box with value
+     */
+    void remove(Box const& box, Value const& value)
+    {
+        try
+        {
+            node_pointer leaf;
+
+            // find possible leaves
+            typedef typename std::vector<node_pointer > node_type;
+            node_type nodes;
+            m_root->find_leaves(box, nodes);
+
+            // refine the result
+            for (typename node_type::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
+            {
+                leaf = *it;
+                try
+                {
+                    leaf->remove(value);
+                    break;
+                } catch (...)
+                {
+                    leaf = node_pointer();
+                }
+            }
+
+            if (!leaf)
+                return;
+
+            typename rtree_leaf < Box, Value >::leaf_map q_leaves;
+
+            if (leaf->elements() < m_min_elems_per_node && elements() > m_min_elems_per_node)
+            {
+                q_leaves = leaf->get_leaves();
+
+                // we remove the leaf_node in the parent node because now it's empty
+                leaf->get_parent()->remove(leaf->get_parent()->get_box(leaf));
+            }
+
+            typename rtree_node<Box, Value>::node_map q_nodes;
+            condense_tree(leaf, q_nodes);
+
+            std::vector<std::pair<Box, Value> > s;
+            for (typename rtree_node<Box, Value>::node_map::const_iterator it = q_nodes.begin();
+                 it != q_nodes.end(); ++it)
+            {
+                typename rtree_leaf<Box, Value>::leaf_map leaves = it->second->get_leaves();
+
+                // reinserting leaves from nodes
+                for (typename rtree_leaf<Box, Value>::leaf_map::const_iterator itl = leaves.begin();
+                     itl != leaves.end(); ++itl)
+                {
+                    s.push_back(*itl);
+                }
+            }
+
+            for (typename std::vector<std::pair<Box, Value> >::const_iterator it = s.begin(); it != s.end(); ++it)
+            {
+                m_count--;
+                insert(it->first, it->second);
+            }
+
+            // if the root has only one child and the child is not a leaf,
+            // make it the root
+            if (m_root->elements() == 1)
+            {
+                if (!m_root->first_element()->is_leaf())
+                {
+                    m_root = m_root->first_element();
+                }
+            }
+
+            // reinserting leaves
+            for (typename rtree_leaf<Box, Value>::leaf_map::const_iterator it = q_leaves.begin();
+                 it != q_leaves.end(); ++it)
+            {
+                m_count--;
+                insert(it->first, it->second);
+            }
+
+            m_count--;
+
+        }
+        catch(std::logic_error & e)
+        {
+            // TODO: mloskot - ggl exception
+
+            // not found
+            std::cerr << e.what() << std::endl;
+            return;
+        }
+    }
+
+    /**
+     * \brief Returns the number of elements.
+     */
+    inline unsigned int elements() const
+    {
+        return m_count;
+    }
+
+
+    /**
+     * \brief Inserts an element with 'box' as key with value.
+     */
+    inline void insert(Box const& box, Value const& value)
+    {
+        m_count++;
+
+        node_pointer leaf(choose_corresponding_leaf(box));
+
+        // check if the selected leaf is full to do the split if necessary
+        if (leaf->elements() >= m_max_elems_per_node)
+        {
+            leaf->insert(box, value);
+
+            // split!
+            node_pointer n1(new rtree_leaf<Box, Value>(leaf->get_parent()));
+            node_pointer n2(new rtree_leaf<Box, Value>(leaf->get_parent()));
+
+            split_node(leaf, n1, n2);
+            adjust_tree(leaf, n1, n2);
+        }
+        else
+        {
+            leaf->insert(box, value);
+            adjust_tree(leaf);
+        }
+    }
+
+
+    /**
+     * \brief Returns all the values inside 'box'
+     */
+    inline std::deque<Value> find(Box const& box) const
+    {
+        std::deque<Value> result;
+        m_root->find(box, result, false);
+        return result;
+    }
+
+    /**
+     * \brief Print Rtree (mainly for debug)
+     */
+    inline void print()
+    {
+        std::cerr << "===================================" << std::endl;
+        std::cerr << " Min/Max: " << m_min_elems_per_node << " / " << m_max_elems_per_node << std::endl;
+        std::cerr << "Leaves: " << m_root->get_leaves().size() << std::endl;
+        m_root->print();
+        std::cerr << "===================================" << std::endl;
+    }
+
+private:
+
+    /// number of elements
+    unsigned int m_count;
+
+    /// minimum number of elements per node
+    unsigned int m_min_elems_per_node;
+
+    /// maximum number of elements per node
+    unsigned int m_max_elems_per_node;
+
+    /// tree root
+    node_pointer m_root;
+
+    /**
+     * \brief Reorganize the tree after a removal. It tries to
+     *        join nodes with less elements than m.
+     */
+    void condense_tree(node_pointer const& leaf,
+        typename rtree_node<Box, Value>::node_map& q_nodes)
+    {
+        if (leaf.get() == m_root.get())
+        {
+            // if it's the root we are done
+            return;
+        }
+
+        node_pointer parent = leaf->get_parent();
+        parent->adjust_box(leaf);
+
+        if (parent->elements() < m_min_elems_per_node)
+        {
+            if (parent.get() == m_root.get())
+            {
+                // if the parent is underfull and it's the root we just exit
+                return;
+            }
+
+            // get the nodes that we should reinsert
+            typename rtree_node<Box, Value>::node_map this_nodes = parent->get_nodes();
+            for(typename rtree_node<Box, Value>::node_map::const_iterator it = this_nodes.begin();
+                it != this_nodes.end(); ++it)
+            {
+                q_nodes.push_back(*it);
+            }
+
+            // we remove the node in the parent node because now it should be
+            // re inserted
+            parent->get_parent()->remove(parent->get_parent()->get_box(parent));
+        }
+
+        condense_tree(parent, q_nodes);
+    }
+
+    /**
+     * \brief After an insertion splits nodes with more than 'maximum' elements.
+     */
+    inline void adjust_tree(node_pointer& node)
+    {
+        if (node.get() == m_root.get())
+        {
+            // we finished the adjust
+            return;
+        }
+
+        // as there are no splits just adjust the box of the parent and go on
+        node_pointer parent = node->get_parent();
+        parent->adjust_box(node);
+        adjust_tree(parent);
+    }
+
+    /**
+     * \brief After an insertion splits nodes with more than maximum elements
+     *        (recursive step with subtrees 'n1' and 'n2' to be joined).
+     */
+    void adjust_tree(node_pointer& leaf, node_pointer& n1, node_pointer& n2)
+    {
+        // check if we are in the root and do the split
+        if (leaf.get() == m_root.get())
+        {
+            node_pointer new_root(new rtree_node<Box,Value>(node_pointer (), leaf->get_level() + 1));
+            new_root->add_node(n1->compute_box(), n1);
+            new_root->add_node(n2->compute_box(), n2);
+
+            n1->set_parent(new_root);
+            n2->set_parent(new_root);
+
+            n1->update_parent(n1);
+            n2->update_parent(n2);
+
+            m_root = new_root;
+            return;
+        }
+
+        node_pointer parent = leaf->get_parent();
+
+        parent->replace_node(leaf, n1);
+        parent->add_node(n2->compute_box(), n2);
+
+        // if parent is full, split and readjust
+        if (parent->elements() > m_max_elems_per_node)
+        {
+            node_pointer p1(new rtree_node<Box, Value>(parent->get_parent(), parent->get_level()));
+            node_pointer p2(new rtree_node<Box, Value>(parent->get_parent(), parent->get_level()));
+
+            split_node(parent, p1, p2);
+            adjust_tree(parent, p1, p2);
+        }
+        else
+        {
+            adjust_tree(parent);
+        }
+    }
+
+    /**
+     * \brief Splits 'n' in 'n1' and 'n2'
+     */
+    void split_node(node_pointer const& n, node_pointer& n1, node_pointer& n2) const
+    {
+        unsigned int seed1 = 0;
+        unsigned int seed2 = 0;
+        std::vector<Box> boxes = n->get_boxes();
+
+        n1->set_parent(n->get_parent());
+        n2->set_parent(n->get_parent());
+
+        linear_pick_seeds(n, seed1, seed2);
+
+        if (n->is_leaf())
+        {
+            n1->add_value(boxes[seed1], n->get_value(seed1));
+            n2->add_value(boxes[seed2], n->get_value(seed2));
+        }
+        else
+        {
+            n1->add_node(boxes[seed1], n->get_node(seed1));
+            n2->add_node(boxes[seed2], n->get_node(seed2));
+        }
+
+        unsigned int index = 0;
+
+        if (n->is_leaf())
+        {
+            // TODO: mloskot - add assert(node.size() >= 2); or similar
+
+            typename rtree_leaf<Box, Value>::leaf_map nodes = n->get_leaves();
+            unsigned int remaining = nodes.size() - 2;
+
+            for (typename rtree_leaf<Box, Value>::leaf_map::const_iterator it = nodes.begin();
+                 it != nodes.end(); ++it, index++)
+            {
+                if (index != seed1 && index != seed2)
+                {
+                    if (n1->elements() + remaining == m_min_elems_per_node)
+                    {
+                        n1->add_value(it->first, it->second);
+                        continue;
+                    }
+                    if (n2->elements() + remaining == m_min_elems_per_node)
+                    {
+                        n2->add_value(it->first, it->second);
+                        continue;
+                    }
+
+                    remaining--;
+
+                    /// current boxes of each group
+                    Box b1, b2;
+
+                    /// enlarged boxes of each group
+                    Box eb1, eb2;
+                    b1 = n1->compute_box();
+                    b2 = n2->compute_box();
+
+                    /// areas
+                    typedef typename coordinate_type<Box>::type coordinate_type;
+                    coordinate_type b1_area, b2_area;
+                    coordinate_type eb1_area, eb2_area;
+                    b1_area = geometry::area(b1);
+                    b2_area = geometry::area(b2);
+                    eb1_area = compute_union_area(b1, it->first);
+                    eb2_area = compute_union_area(b2, it->first);
+
+                    if (eb1_area - b1_area > eb2_area - b2_area)
+                    {
+                        n2->add_value(it->first, it->second);
+                    }
+                    if (eb1_area - b1_area < eb2_area - b2_area)
+                    {
+                        n1->add_value(it->first, it->second);
+                    }
+                    if (eb1_area - b1_area == eb2_area - b2_area)
+                    {
+                        if (b1_area < b2_area)
+                        {
+                            n1->add_value(it->first, it->second);
+                        }
+                        if (b1_area > b2_area)
+                        {
+                            n2->add_value(it->first, it->second);
+                        }
+                        if (b1_area == b2_area)
+                        {
+                            if (n1->elements() > n2->elements())
+                            {
+                                n2->add_value(it->first, it->second);
+                            }
+                            else
+                            {
+                                n1->add_value(it->first, it->second);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        else
+        {
+            // TODO: mloskot - add assert(node.size() >= 2); or similar
+
+            typename rtree_node<Box, Value>::node_map nodes = n->get_nodes();
+            unsigned int remaining = nodes.size() - 2;
+            for(typename rtree_node<Box, Value>::node_map::const_iterator it = nodes.begin();
+                it != nodes.end(); ++it, index++)
+            {
+
+                if (index != seed1 && index != seed2)
+                {
+
+                    if (n1->elements() + remaining == m_min_elems_per_node)
+                    {
+                        n1->add_node(it->first, it->second);
+                        continue;
+                    }
+                    if (n2->elements() + remaining == m_min_elems_per_node)
+                    {
+                        n2->add_node(it->first, it->second);
+                        continue;
+                    }
+
+                    remaining--;
+
+                    /// current boxes of each group
+                    Box b1, b2;
+
+                    /// enlarged boxes of each group
+                    Box eb1, eb2;
+                    b1 = n1->compute_box();
+                    b2 = n2->compute_box();
+
+                    /// areas
+                    typedef typename coordinate_type<Box>::type coordinate_type;
+                    coordinate_type b1_area, b2_area;
+                    coordinate_type eb1_area, eb2_area;
+                    b1_area = geometry::area(b1);
+                    b2_area = geometry::area(b2);
+
+                    eb1_area = compute_union_area(b1, it->first);
+                    eb2_area = compute_union_area(b2, it->first);
+
+                    if (eb1_area - b1_area > eb2_area - b2_area)
+                    {
+                        n2->add_node(it->first, it->second);
+                    }
+                    if (eb1_area - b1_area < eb2_area - b2_area)
+                    {
+                        n1->add_node(it->first, it->second);
+                    }
+                    if (eb1_area - b1_area == eb2_area - b2_area)
+                    {
+                        if (b1_area < b2_area)
+                        {
+                            n1->add_node(it->first, it->second);
+                        }
+                        if (b1_area > b2_area)
+                        {
+                            n2->add_node(it->first, it->second);
+                        }
+                        if (b1_area == b2_area)
+                        {
+                            if (n1->elements() > n2->elements())
+                            {
+                                n2->add_node(it->first, it->second);
+                            }
+                            else
+                            {
+                                n1->add_node(it->first, it->second);
+                            }
+                        }
+                    }
+
+                }
+            }
+        }
+    }
+
+    /**
+     * \brief Choose initial values for the split algorithm (linear version)
+     */
+    void linear_pick_seeds(node_pointer const& n, unsigned int &seed1, unsigned int &seed2) const
+    {
+        // get boxes from the node
+        std::vector<Box>boxes = n->get_boxes();
+        if (boxes.size() == 0)
+        {
+            // TODO: mloskot - throw ggl exception
+            throw std::logic_error("Empty Node trying to Pick Seeds");
+        }
+
+        // only two dim for now
+        // unsigned int dimensions =
+        //   geometry::point_traits<Point>::coordinate_count;
+
+        // find the first two elements
+        typedef typename coordinate_type<Box>::type coordinate_type;
+        coordinate_type separation_x, separation_y;
+        unsigned int first_x, second_x;
+        unsigned int first_y, second_y;
+        find_normalized_separations<0u>(boxes, separation_x, first_x, second_x);
+        find_normalized_separations<1u>(boxes, separation_y, first_y, second_y);
+
+        if (separation_x > separation_y)
+        {
+            seed1 = first_x;
+            seed2 = second_x;
+        }
+        else
+        {
+            seed1 = first_y;
+            seed2 = second_y;
+        }
+    }
+
+    /**
+     * \brief Find distances between possible initial values for the
+     *        pick_seeds algorithm.
+     */
+    template <std::size_t D, typename T>
+    void find_normalized_separations(std::vector<Box> const& boxes, T& separation,
+        unsigned int& first, unsigned int& second) const
+    {
+        if (boxes.size() < 2)
+        {
+            throw std::logic_error("At least two boxes needed to split");
+        }
+
+        // find the lowest high
+        typename std::vector<Box>::const_iterator it = boxes.begin();
+        typedef typename coordinate_type<Box>::type coordinate_type;
+        coordinate_type lowest_high = geometry::get<max_corner, D>(*it);
+        unsigned int lowest_high_index = 0;
+        unsigned int index = 1;
+        ++it;
+        for(; it != boxes.end(); ++it)
+        {
+            if (geometry::get<max_corner, D>(*it) < lowest_high)
+            {
+                lowest_high = geometry::get<max_corner, D>(*it);
+                lowest_high_index = index;
+            }
+            index++;
+        }
+
+        // find the highest low
+        coordinate_type highest_low = 0;
+        unsigned int highest_low_index = 0;
+        if (lowest_high_index == 0)
+        {
+            highest_low = geometry::get<min_corner, D>(boxes[1]);
+            highest_low_index = 1;
+        }
+        else
+        {
+            highest_low = geometry::get<min_corner, D>(boxes[0]);
+            highest_low_index = 0;
+        }
+
+        index = 0;
+        for (typename std::vector<Box>::const_iterator it = boxes.begin();
+             it != boxes.end(); ++it, index++)
+        {
+            if (geometry::get<min_corner, D>(*it) >= highest_low && index != lowest_high_index)
+            {
+                highest_low = geometry::get<min_corner, D>(*it);
+                highest_low_index = index;
+            }
+        }
+
+        // find the lowest low
+        it = boxes.begin();
+        coordinate_type lowest_low = geometry::get<min_corner, D>(*it);
+        ++it;
+        for(; it != boxes.end(); ++it)
+        {
+            if (geometry::get<min_corner, D>(*it) < lowest_low)
+            {
+                lowest_low = geometry::get<min_corner, D>(*it);
+            }
+        }
+
+        // find the highest high
+        it = boxes.begin();
+        coordinate_type highest_high = geometry::get<max_corner, D>(*it);
+        ++it;
+        for(; it != boxes.end(); ++it)
+        {
+            if (geometry::get<max_corner, D>(*it) > highest_high)
+            {
+                highest_high = geometry::get<max_corner, D>(*it);
+            }
+        }
+
+        coordinate_type const width = highest_high - lowest_low;
+
+        separation = (highest_low - lowest_high) / width;
+        first = highest_low_index;
+        second = lowest_high_index;
+    }
+
+    /**
+     * \brief Choose one of the possible leaves to make an insertion
+     */
+    inline node_pointer choose_corresponding_leaf(Box const& e)
+    {
+        node_pointer node = m_root;
+
+        // if the tree is empty add an initial leaf
+        if (m_root->elements() == 0)
+        {
+            leaf_pointer new_leaf(new rtree_leaf<Box, Value>(m_root));
+            m_root->add_leaf_node(Box (), new_leaf);
+
+            return new_leaf;
+        }
+
+        while (!node->is_leaf())
+        {
+            /// traverse node's map to see which node we should select
+            node = node->choose_node(e);
+        }
+        return node;
+    }
+
+    /**
+     * \brief Choose the exact leaf where an insertion should be done
+     */
+    node_pointer choose_exact_leaf(Box const&e) const
+    {
+        // find possible leaves
+        typedef typename std::vector<node_pointer> node_type;
+        node_type nodes;
+        m_root->find_leaves(e, nodes);
+
+        // refine the result
+        for (typename node_type::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
+        {
+            typedef std::vector<std::pair<Box, Value> > leaves_type;
+            leaves_type leaves = (*it)->get_leaves();
+
+            for (typename leaves_type::const_iterator itl = leaves.begin();
+                 itl != leaves.end(); ++itl)
+            {
+
+                if (itl->first.max_corner() == e.max_corner()
+                    && itl->first.min_corner() == e.min_corner())
+                {
+                    return *it;
+                }
+            }
+        }
+
+        // TODO: mloskot - ggl exception
+        throw std::logic_error("Leaf not found");
+    }
+};
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_HPP
+
diff --git a/src/boost/geometry/extensions/index/rtree/rtree_leaf.hpp b/src/boost/geometry/extensions/index/rtree/rtree_leaf.hpp
new file mode 100644
index 0000000..95d1a86
--- /dev/null
+++ b/src/boost/geometry/extensions/index/rtree/rtree_leaf.hpp
@@ -0,0 +1,253 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Boost.SpatialIndex - rtree leaf implementation
+//
+// Copyright 2008 Federico J. Fernandez.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP
+
+#include <deque>
+#include <iostream> // TODO: Remove if print() is removed
+#include <stdexcept>
+#include <utility>
+#include <vector>
+
+#include <boost/shared_ptr.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+
+#include <boost/geometry/extensions/index/rtree/rtree_node.hpp>
+
+namespace boost { namespace geometry { namespace index
+{
+
+template <typename Box, typename Value >
+class rtree_leaf : public rtree_node<Box, Value>
+{
+public:
+
+    /// container type for the leaves
+    typedef boost::shared_ptr<rtree_node<Box, Value> > node_pointer;
+    typedef std::vector<std::pair<Box, Value> > leaf_map;
+
+    /**
+     * \brief Creates an empty leaf
+     */
+    inline rtree_leaf()
+    {
+    }
+
+    /**
+     * \brief Creates a new leaf, with 'parent' as parent
+     */
+    inline rtree_leaf(node_pointer const& parent)
+        : rtree_node<Box, Value> (parent, 0)
+    {
+    }
+
+    /**
+     * \brief Search for elements in 'box' in the Rtree. Add them to 'result'.
+     *        If exact_match is true only return the elements having as
+     *        key the 'box'. Otherwise return everything inside 'box'.
+     */
+    virtual void find(Box const& box, std::deque<Value>& result, bool const exact_match)
+    {
+        for (typename leaf_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (exact_match)
+            {
+                if (geometry::equals(it->first, box))
+                {
+                    result.push_back(it->second);
+                }
+            }
+            else
+            {
+                if (is_overlapping(it->first, box))
+                {
+                    result.push_back(it->second);
+                }
+            }
+        }
+    }
+
+    /**
+     * \brief Compute bounding box for this leaf
+     */
+    virtual Box compute_box() const
+    {
+        if (m_nodes.empty())
+        {
+            return Box ();
+        }
+
+        Box r;
+        geometry::assign_inverse(r);
+        for(typename leaf_map::const_iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+        {
+            geometry::expand(r, it->first);
+        }
+        return r;
+    }
+
+    /**
+     * \brief True if we are a leaf
+     */
+    virtual bool is_leaf() const
+    {
+        return true;
+    }
+
+    /**
+     * \brief Number of elements in the tree
+     */
+    virtual unsigned int elements() const
+    {
+        return m_nodes.size();
+    }
+
+    /**
+     * \brief Insert a new element, with key 'box' and value 'v'
+     */
+    virtual void insert(Box const& box, Value const& v)
+    {
+        m_nodes.push_back(std::make_pair(box, v));
+    }
+
+    /**
+     * \brief Proyect leaves of this node.
+     */
+    virtual std::vector< std::pair<Box, Value> > get_leaves() const
+    {
+        return m_nodes;
+    }
+
+    /**
+     * \brief Add a new child (node) to this node
+     */
+    virtual void add_node(Box const&, node_pointer const&)
+    {
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("Can't add node to leaf node.");
+    }
+
+    /**
+     * \brief Add a new leaf to this node
+     */
+    virtual void add_value(Box const& box, Value const& v)
+    {
+        m_nodes.push_back(std::make_pair(box, v));
+    }
+
+
+    /**
+     * \brief Proyect value in position 'index' in the nodes container
+     */
+    virtual Value get_value(unsigned int index) const
+    {
+        return m_nodes[index].second;
+    }
+
+    /**
+     * \brief Box projector for leaf
+     */
+    virtual Box get_box(unsigned int index) const
+    {
+        return m_nodes[index].first;
+    }
+
+    /**
+     * \brief Remove value with key 'box' in this leaf
+     */
+    virtual void remove(Box const& box)
+    {
+
+        for (typename leaf_map::iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (geometry::equals(it->first, box))
+            {
+                m_nodes.erase(it);
+                return;
+            }
+        }
+
+        // TODO: mloskot - use GGL exception
+        throw std::logic_error("Node not found.");
+    }
+
+    /**
+     * \brief Remove value in this leaf
+     */
+    virtual void remove(Value const& v)
+    {
+        for (typename leaf_map::iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (it->second == v)
+            {
+                m_nodes.erase(it);
+                return;
+            }
+        }
+
+        // TODO: mloskot - use GGL exception
+        throw std::logic_error("Node not found.");
+    }
+
+    /**
+    * \brief Proyect boxes from this node
+    */
+    virtual std::vector<Box> get_boxes() const
+    {
+        std::vector<Box> result;
+        for (typename leaf_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            result.push_back(it->first);
+        }
+
+        return result;
+    }
+
+    /**
+    * \brief Print leaf (mainly for debug)
+    */
+    virtual void print() const
+    {
+        std::cerr << "\t" << " --> Leaf --------" << std::endl;
+        std::cerr << "\t" << "  Size: " << m_nodes.size() << std::endl;
+        for (typename leaf_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            std::cerr << "\t" << "  | ";
+            std::cerr << "( " << geometry::get<min_corner, 0>
+                (it->first) << " , " << geometry::get<min_corner, 1>
+                (it->first) << " ) x ";
+            std::cerr << "( " << geometry::get<max_corner, 0>
+                (it->first) << " , " << geometry::get<max_corner, 1>
+                (it->first) << " )";
+            std::cerr << " -> ";
+            std::cerr << it->second;
+            std::cerr << " | " << std::endl;;
+        }
+        std::cerr << "\t" << " --< Leaf --------" << std::endl;
+    }
+
+private:
+
+    /// leaves of this node
+    leaf_map m_nodes;
+};
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_LEAF_HPP
+
diff --git a/src/boost/geometry/extensions/index/rtree/rtree_node.hpp b/src/boost/geometry/extensions/index/rtree/rtree_node.hpp
new file mode 100644
index 0000000..de35ef2
--- /dev/null
+++ b/src/boost/geometry/extensions/index/rtree/rtree_node.hpp
@@ -0,0 +1,493 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Boost.SpatialIndex - rtree node implementation
+//
+// Copyright 2008 Federico J. Fernandez.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_NODE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_NODE_HPP
+
+#include <deque>
+#include <iostream> // TODO: Remove if print() is removed
+#include <stdexcept>
+#include <utility>
+#include <vector>
+
+#include <boost/shared_ptr.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/equals.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+
+#include <boost/geometry/extensions/index/rtree/helpers.hpp>
+
+namespace boost { namespace geometry { namespace index
+{
+
+/// forward declaration
+template <typename Box, typename Value>
+class rtree_leaf;
+
+template <typename Box, typename Value>
+class rtree_node
+{
+public:
+
+    typedef boost::shared_ptr<rtree_node<Box, Value> > node_pointer;
+    typedef boost::shared_ptr<rtree_leaf<Box, Value> > leaf_pointer;
+
+    /// type for the node map
+    typedef std::vector<std::pair<Box, node_pointer > > node_map;
+
+    /**
+     * \brief Creates a default node (needed for the containers)
+     */
+    rtree_node()
+    {
+    }
+
+    /**
+     * \brief Creates a node with 'parent' as parent and 'level' as its level
+     */
+    rtree_node(node_pointer const& parent, unsigned int const& level)
+        : m_parent(parent), m_level(level)
+    {
+    }
+
+    /**
+     * \brief destructor (virtual because we have virtual functions)
+     */
+    virtual ~rtree_node()
+    {
+    }
+
+    /**
+     * \brief Level projector
+     */
+    virtual unsigned int get_level() const
+    {
+        return m_level;
+    }
+
+    /**
+     * \brief Number of elements in the subtree
+     */
+    virtual unsigned int elements() const
+    {
+        return m_nodes.size();
+    }
+
+    /**
+     * \brief Project first element, to replace root in case of condensing
+     */
+    inline node_pointer first_element() const
+    {
+        if (0 == m_nodes.size())
+        {
+            // TODO: mloskot - define & use GGL exception
+            throw std::logic_error("first_element in empty node");
+        }
+        return m_nodes.begin()->second;
+    }
+
+    /**
+     * \brief True if it is a leaf node
+     */
+    virtual bool is_leaf() const
+    {
+        return false;
+    }
+
+    /**
+     * \brief Proyector for the 'i' node
+     */
+    node_pointer get_node(unsigned int index)
+    {
+        return m_nodes[index].second;
+    }
+
+    /**
+     * \brief Search for elements in 'box' in the Rtree. Add them to 'result'.
+     *        If exact_match is true only return the elements having as
+     *        key the box 'box'. Otherwise return everything inside 'box'.
+     */
+    virtual void find(Box const& box, std::deque<Value>& result, bool const exact_match)
+    {
+        for (typename node_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (is_overlapping(it->first, box))
+            {
+                it->second->find(box, result, exact_match);
+            }
+        }
+    }
+
+    /**
+     * \brief Return in 'result' all the leaves inside 'box'
+     */
+    void find_leaves(Box const& box, typename std::vector<node_pointer>& result) const
+    {
+        for (typename node_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (is_overlapping(it->first, box))
+            {
+                if (it->second->is_leaf())
+                {
+                    result.push_back(it->second);
+                }
+                else
+                {
+                    it->second->find_leaves(box, result);
+                }
+            }
+        }
+    }
+
+    /**
+    * \brief Compute bounding box for this node
+    */
+    virtual Box compute_box() const
+    {
+        if (m_nodes.empty())
+        {
+            return Box();
+        }
+
+        Box result;
+        geometry::assign_inverse(result);
+        for(typename node_map::const_iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+        {
+            geometry::expand(result, it->first);
+        }
+
+        return result;
+    }
+
+    /**
+     * \brief Insert a value (not allowed for a node, only on leaves)
+     */
+    virtual void insert(Box const&, Value const&)
+    {
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("Insert in node!");
+    }
+
+    /**
+     * \brief Get the envelopes of a node
+     */
+    virtual std::vector<Box> get_boxes() const
+    {
+        std::vector<Box> result;
+        for(typename node_map::const_iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+        {
+            result.push_back(it->first);
+        }
+        return result;
+    }
+
+    /**
+     * \brief Recompute the bounding box
+     */
+    void adjust_box(node_pointer const& node)
+    {
+        unsigned int index = 0;
+        for (typename node_map::iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it, index++)
+        {
+            if (it->second.get() == node.get())
+            {
+                m_nodes[index] = std::make_pair(node->compute_box(), node);
+                return;
+            }
+        }
+    }
+
+    /**
+     * \brief Remove elements inside the 'box'
+     */
+    virtual void remove(Box const& box)
+    {
+        for (typename node_map::iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (geometry::equals(it->first, box))
+            {
+                m_nodes.erase(it);
+                return;
+            }
+        }
+    }
+
+    /**
+     * \brief Remove value in this leaf
+     */
+    virtual void remove(Value const&)
+    {
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("Can't remove a non-leaf node by value.");
+    }
+
+    /**
+     * \brief Replace the node in the m_nodes vector and recompute the box
+     */
+    void replace_node(node_pointer const& leaf, node_pointer& new_leaf)
+    {
+        unsigned int index = 0;
+        for(typename node_map::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it, index++)
+        {
+            if (it->second.get() == leaf.get())
+            {
+                m_nodes[index] = std::make_pair(new_leaf->compute_box(), new_leaf);
+                new_leaf->update_parent(new_leaf);
+                return;
+            }
+        }
+
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("Node not found.");
+    }
+
+    /**
+     * \brief Add a child to this node
+     */
+    virtual void add_node(Box const& box, node_pointer const& node)
+    {
+        m_nodes.push_back(std::make_pair(box, node));
+        node->update_parent(node);
+    }
+
+    /**
+     * \brief add a value (not allowed in nodes, only on leaves)
+     */
+    virtual void add_value(Box const&, Value const&)
+    {
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("Can't add value to non-leaf node.");
+    }
+
+    /**
+     * \brief Add a child leaf to this node
+     */
+    inline void add_leaf_node(Box const& box, leaf_pointer const& leaf)
+    {
+        m_nodes.push_back(std::make_pair(box, leaf));
+    }
+
+    /**
+     * \brief Choose a node suitable for adding 'box'
+     */
+    node_pointer choose_node(Box const& box)
+    {
+        if (m_nodes.size() == 0)
+        {
+            // TODO: mloskot - define & use GGL exception
+            throw std::logic_error("Empty node trying to choose the least enlargement node.");
+        }
+
+        typedef typename coordinate_type<Box>::type coordinate_type;
+
+        bool first = true;
+        coordinate_type min_area = 0;
+        coordinate_type min_diff_area = 0;
+        node_pointer chosen_node;
+
+        // check for the least enlargement
+        for (typename node_map::const_iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+        {
+            coordinate_type const
+                diff_area = coordinate_type(compute_union_area(box, it->first))
+                    - geometry::area(it->first);
+
+            if (first)
+            {
+                // it's the first time, we keep the first
+                min_diff_area = diff_area;
+                min_area = geometry::area(it->first);
+                chosen_node = it->second;
+
+                first = false;
+            }
+            else
+            {
+                if (diff_area < min_diff_area)
+                {
+                    min_diff_area = diff_area;
+                    min_area = geometry::area(it->first);
+                    chosen_node = it->second;
+                }
+                else
+                {
+                    if (diff_area == min_diff_area)
+                    {
+                        if (geometry::area(it->first) < min_area)
+                        {
+                            min_diff_area = diff_area;
+                            min_area = geometry::area(it->first);
+                            chosen_node = it->second;
+                        }
+                    }
+                }
+            }
+        }
+
+        return chosen_node;
+    }
+
+    /**
+     * \brief Empty the node
+     */
+    virtual void empty_nodes()
+    {
+        m_nodes.clear();
+    }
+
+    /**
+     * \brief Projector for parent
+     */
+    inline node_pointer get_parent() const
+    {
+        return m_parent;
+    }
+
+    /**
+     * \brief Update the parent of all the childs
+     */
+    void update_parent(node_pointer const& node)
+    {
+        for (typename node_map::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+        {
+            it->second->set_parent(node);
+        }
+    }
+
+    /**
+     * \brief Set parent
+     */
+    void set_parent(node_pointer const& node)
+    {
+        m_parent = node;
+    }
+
+    /**
+     * \brief Value projector for leaf_node (not allowed for non-leaf nodes)
+     */
+    virtual Value get_value(unsigned int) const
+    {
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("No values in a non-leaf node.");
+    }
+
+    /**
+     * \brief Box projector for node 'index'
+     */
+    virtual Box get_box(unsigned int index) const
+    {
+        return m_nodes[index].first;
+    }
+
+    /**
+     * \brief Box projector for node pointed by 'leaf'
+     */
+    virtual Box get_box(node_pointer const& leaf) const
+    {
+        for (typename node_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            if (it->second.get() == leaf.get())
+            {
+                return it->first;
+            }
+        }
+
+        // TODO: mloskot - define & use GGL exception
+        throw std::logic_error("Node not found");
+    }
+
+    /**
+     * \brief Children projector
+     */
+    node_map get_nodes() const
+    {
+        return m_nodes;
+    }
+
+    /**
+    * \brief Get leaves for a node
+    */
+    virtual std::vector<std::pair<Box, Value> > get_leaves() const
+    {
+        typedef std::vector<std::pair<Box, Value> > leaf_type;
+        leaf_type leaf;
+
+        for (typename node_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            leaf_type this_leaves = it->second->get_leaves();
+
+            for (typename leaf_type::iterator it_leaf = this_leaves.begin();
+                it_leaf != this_leaves.end(); ++it_leaf)
+            {
+                leaf.push_back(*it_leaf);
+            }
+        }
+
+        return leaf;
+    }
+
+    /**
+     * \brief Print Rtree subtree (mainly for debug)
+     */
+    virtual void print() const
+    {
+        std::cerr << " --> Node --------" << std::endl;
+        std::cerr << "  Address: " << this << std::endl;
+        std::cerr << "  Level: " << m_level << std::endl;
+        std::cerr << "  Size: " << m_nodes.size() << std::endl;
+        std::cerr << "  | ";
+        for(typename node_map::const_iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
+        {
+            if (this != it->second->get_parent().get())
+            {
+                std::cerr << "ERROR - " << this << " is not  " << it->second->get_parent().get() << " ";
+            }
+
+            std::cerr << "( " << geometry::get<min_corner, 0>(it->first) << " , "
+                << geometry::get<min_corner, 1>(it->first) << " ) x ";
+            std::cerr << "( " << geometry::get<max_corner, 0>(it->first) << " , "
+                << geometry::get<max_corner, 1>(it->first) << " )";
+            std::cerr << " | ";
+        }
+        std::cerr << std::endl;
+        std::cerr << " --< Node --------" << std::endl;
+
+        // print child nodes
+        std::cerr << " Children: " << std::endl;
+        for (typename node_map::const_iterator it = m_nodes.begin();
+             it != m_nodes.end(); ++it)
+        {
+            it->second->print();
+        }
+    }
+
+private:
+
+    /// parent node
+    node_pointer m_parent;
+
+    /// level of this node
+    // TODO: mloskot - Why not std::size_t or node_map::size_type, same with member functions?
+    unsigned int m_level;
+
+    /// child nodes
+    node_map m_nodes;
+};
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RTREE_NODE_HPP
diff --git a/src/boost/geometry/extensions/io/svg/svg_mapper.hpp b/src/boost/geometry/extensions/io/svg/svg_mapper.hpp
new file mode 100644
index 0000000..de96796
--- /dev/null
+++ b/src/boost/geometry/extensions/io/svg/svg_mapper.hpp
@@ -0,0 +1,347 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_SVG_MAPPER_HPP
+#define BOOST_GEOMETRY_IO_SVG_MAPPER_HPP
+
+#include <cstdio>
+
+#include <vector>
+
+#include <boost/mpl/assert.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
+
+
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/algorithms/envelope.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/algorithms/transform.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/strategies/transform.hpp>
+#include <boost/geometry/strategies/transform/map_transformer.hpp>
+#include <boost/geometry/views/segment_view.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/algorithms/envelope.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+
+#include <boost/geometry/extensions/io/svg/write_svg.hpp>
+
+// Helper geometries (all points are transformed to integer-points)
+#include <boost/geometry/geometries/geometries.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace svg
+{
+    typedef model::point<int, 2, cs::cartesian> svg_point_type;
+}}
+#endif
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+
+template <typename GeometryTag, typename Geometry>
+struct svg_map
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (Geometry)
+        );
+};
+
+
+template <typename Point>
+struct svg_map<point_tag, Point>
+{
+    template <typename TransformStrategy>
+    static inline void apply(std::ostream& stream,
+                    std::string const& style, int size,
+                    Point const& point, TransformStrategy const& strategy)
+    {
+        detail::svg::svg_point_type ipoint;
+        geometry::transform(point, ipoint, strategy);
+        stream << geometry::svg(ipoint, style, size) << std::endl;
+    }
+};
+
+template <typename Box>
+struct svg_map<box_tag, Box>
+{
+    template <typename TransformStrategy>
+    static inline void apply(std::ostream& stream,
+                    std::string const& style, int size,
+                    Box const& box, TransformStrategy const& strategy)
+    {
+        model::box<detail::svg::svg_point_type> ibox;
+        geometry::transform(box, ibox, strategy);
+
+        stream << geometry::svg(ibox, style, size) << std::endl;
+    }
+};
+
+
+template <typename Range1, typename Range2>
+struct svg_map_range
+{
+    template <typename TransformStrategy>
+    static inline void apply(std::ostream& stream,
+                std::string const& style, int size,
+                Range1 const& range, TransformStrategy const& strategy)
+    {
+        Range2 irange;
+        geometry::transform(range, irange, strategy);
+        stream << geometry::svg(irange, style, size) << std::endl;
+    }
+};
+
+template <typename Segment>
+struct svg_map<segment_tag, Segment>
+{
+    template <typename TransformStrategy>
+    static inline void apply(std::ostream& stream,
+                    std::string const& style, int size,
+                    Segment const& segment, TransformStrategy const& strategy)
+    {
+        typedef segment_view<Segment> view_type;
+        view_type range(segment);
+        svg_map_range
+            <
+                view_type,
+                model::linestring<detail::svg::svg_point_type>
+            >::apply(stream, style, size, range, strategy);
+    }
+};
+
+
+template <typename Ring>
+struct svg_map<ring_tag, Ring>
+    : svg_map_range<Ring, model::ring<detail::svg::svg_point_type> >
+{};
+
+
+template <typename Linestring>
+struct svg_map<linestring_tag, Linestring>
+    : svg_map_range<Linestring, model::linestring<detail::svg::svg_point_type> >
+{};
+
+
+template <typename Polygon>
+struct svg_map<polygon_tag, Polygon>
+{
+    template <typename TransformStrategy>
+    static inline void apply(std::ostream& stream,
+                    std::string const& style, int size,
+                    Polygon const& polygon, TransformStrategy const& strategy)
+    {
+        model::polygon<detail::svg::svg_point_type> ipoly;
+        geometry::transform(polygon, ipoly, strategy);
+        stream << geometry::svg(ipoly, style, size) << std::endl;
+    }
+};
+
+
+template <typename Multi>
+struct svg_map<multi_tag, Multi>
+{
+    typedef typename single_tag_of
+      <
+          typename geometry::tag<Multi>::type
+      >::type stag;
+
+    template <typename TransformStrategy>
+    static inline void apply(std::ostream& stream,
+                    std::string const& style, int size,
+                    Multi const& multi, TransformStrategy const& strategy)
+    {
+        for (typename boost::range_iterator<Multi const>::type it
+            = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            svg_map
+                <
+                    stag,
+                    typename boost::range_value<Multi>::type
+                >::apply(stream, style, size, *it, strategy);
+        }
+    }
+};
+
+
+} // namespace dispatch
+#endif
+
+
+template <typename Geometry, typename TransformStrategy>
+inline void svg_map(std::ostream& stream,
+            std::string const& style, int size,
+            Geometry const& geometry, TransformStrategy const& strategy)
+{
+    dispatch::svg_map
+        <
+            typename tag_cast
+                <
+                    typename tag<Geometry>::type,
+                    multi_tag
+                >::type,
+            typename boost::remove_const<Geometry>::type
+        >::apply(stream, style, size, geometry, strategy);
+}
+
+
+template <typename Point, bool SameScale = true>
+class svg_mapper : boost::noncopyable
+{
+    typedef strategy::transform::map_transformer
+        <
+            Point,
+            detail::svg::svg_point_type,
+            true,
+            SameScale
+        > transformer_type;
+
+    model::box<Point> m_bounding_box;
+    boost::scoped_ptr<transformer_type> m_matrix;
+    std::ostream& m_stream;
+    int m_width, m_height;
+    std::string m_width_height; // for <svg> tag only, defaults to 2x 100%
+
+    void init_matrix()
+    {
+        if (! m_matrix)
+        {
+            m_matrix.reset(new transformer_type(m_bounding_box,
+                            m_width, m_height));
+
+            m_stream << "<?xml version=\"1.0\" standalone=\"no\"?>"
+                << std::endl
+                << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\""
+                << std::endl
+                << "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">"
+                << std::endl
+                << "<svg " << m_width_height << " version=\"1.1\""
+                << std::endl
+                << "xmlns=\"http://www.w3.org/2000/svg\">"
+                << std::endl;
+        }
+    }
+
+public :
+    svg_mapper(std::ostream& s, int w, int h
+        , std::string const& width_height = "width=\"100%\" height=\"100%\"")
+        : m_stream(s)
+        , m_width(w)
+        , m_height(h)
+        , m_width_height(width_height)
+    {
+        assign_inverse(m_bounding_box);
+    }
+
+    virtual ~svg_mapper()
+    {
+        m_stream << "</svg>" << std::endl;
+    }
+
+    template <typename Geometry>
+    void add(Geometry const& geometry)
+    {
+        if (num_points(geometry) > 0)
+        {
+            expand(m_bounding_box,
+                return_envelope
+                    <
+                        model::box<Point>
+                    >(geometry));
+        }
+    }
+
+    template <typename Geometry>
+    void map(Geometry const& geometry, std::string const& style,
+                int size = -1)
+    {
+        BOOST_MPL_ASSERT_MSG
+        (
+            ( boost::is_same
+                <
+                    Point,
+                    typename point_type<Geometry>::type
+                >::value )
+            , POINT_TYPES_ARE_NOT_SAME_FOR_MAPPER_AND_MAP
+            , (types<Point, typename point_type<Geometry>::type>)
+        );
+
+
+        init_matrix();
+        svg_map(m_stream, style, size, geometry, *m_matrix);
+    }
+
+    template <typename TextPoint>
+    void text(TextPoint const& point, std::string const& s,
+                std::string const& style,
+                int offset_x = 0, int offset_y = 0, int lineheight = 10)
+    {
+        init_matrix();
+        detail::svg::svg_point_type map_point;
+        transform(point, map_point, *m_matrix);
+        m_stream
+            << "<text style=\"" << style << "\""
+            << " x=\"" << get<0>(map_point) + offset_x << "\""
+            << " y=\"" << get<1>(map_point) + offset_y << "\""
+            << ">";
+        if (s.find("\n") == std::string::npos)
+        {
+             m_stream  << s;
+        }
+        else
+        {
+            // Multi-line modus
+
+            std::vector<std::string> splitted;
+            boost::split(splitted, s, boost::is_any_of("\n"));
+            for (std::vector<std::string>::const_iterator it
+                = splitted.begin();
+                it != splitted.end();
+                ++it, offset_y += lineheight)
+            {
+                 m_stream
+                    << "<tspan x=\"" << get<0>(map_point) + offset_x
+                    << "\""
+                    << " y=\"" << get<1>(map_point) + offset_y
+                    << "\""
+                    << ">" << *it << "</tspan>";
+            }
+        }
+        m_stream << "</text>" << std::endl;
+    }
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_IO_SVG_MAPPER_HPP
diff --git a/src/boost/geometry/extensions/io/svg/write_svg.hpp b/src/boost/geometry/extensions/io/svg/write_svg.hpp
new file mode 100644
index 0000000..3cc2cda
--- /dev/null
+++ b/src/boost/geometry/extensions/io/svg/write_svg.hpp
@@ -0,0 +1,272 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_SVG_WRITE_SVG_HPP
+#define BOOST_GEOMETRY_IO_SVG_WRITE_SVG_HPP
+
+#include <ostream>
+#include <string>
+
+#include <boost/config.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace svg
+{
+
+
+template <typename Point>
+struct svg_point
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Point const& p, std::string const& style, int size)
+    {
+        os << "<circle cx=\"" << geometry::get<0>(p)
+            << "\" cy=\"" << geometry::get<1>(p)
+            << "\" r=\"" << (size < 0 ? 5 : size)
+            << "\" style=\"" << style << "\"/>";
+    }
+};
+
+
+template <typename Box>
+struct svg_box
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Box const& box, std::string const& style, int size)
+    {
+        // Prevent invisible boxes, making them >=1, using "max"
+        BOOST_USING_STD_MAX();
+
+        typedef typename coordinate_type<Box>::type ct;
+        ct x = geometry::get<geometry::min_corner, 0>(box);
+        ct y = geometry::get<geometry::min_corner, 1>(box);
+        ct width = max BOOST_PREVENT_MACRO_SUBSTITUTION(1,
+                    geometry::get<geometry::max_corner, 0>(box) - x);
+        ct height = max BOOST_PREVENT_MACRO_SUBSTITUTION (1,
+                    geometry::get<geometry::max_corner, 1>(box) - y);
+
+        os << "<rect x=\"" << x << "\" y=\"" << y
+           << "\" width=\"" << width << "\" height=\"" << height
+           << "\" style=\"" << style << "\"/>";
+    }
+};
+
+
+/*!
+\brief Stream ranges as SVG
+\note policy is used to select type (polyline/polygon)
+*/
+template <typename Range, typename Policy>
+struct svg_range
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+        Range const& range, std::string const& style, int size)
+    {
+        typedef typename boost::range_iterator<Range const>::type iterator;
+
+        bool first = true;
+
+        os << "<" << Policy::prefix() << " points=\"";
+
+        for (iterator it = boost::begin(range);
+            it != boost::end(range);
+            ++it, first = false)
+        {
+            os << (first ? "" : " " )
+                << geometry::get<0>(*it)
+                << ","
+                << geometry::get<1>(*it);
+        }
+        os << "\" style=\"" << style << Policy::style() << "\"/>";
+    }
+};
+
+
+
+template <typename Polygon>
+struct svg_poly
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+        Polygon const& polygon, std::string const& style, int size)
+    {
+        typedef typename geometry::ring_type<Polygon>::type ring_type;
+        typedef typename boost::range_iterator<ring_type const>::type iterator_type;
+
+        bool first = true;
+        os << "<g fill-rule=\"evenodd\"><path d=\"";
+
+        ring_type const& ring = geometry::exterior_ring(polygon);
+        for (iterator_type it = boost::begin(ring);
+            it != boost::end(ring);
+            ++it, first = false)
+        {
+            os << (first ? "M" : " L") << " "
+                << geometry::get<0>(*it)
+                << ","
+                << geometry::get<1>(*it);
+        }
+
+        // Inner rings:
+        {
+            typename interior_return_type<Polygon const>::type rings
+                        = interior_rings(polygon);
+            for (BOOST_AUTO_TPL(rit, boost::begin(rings));
+                rit != boost::end(rings); ++rit)
+            {
+                first = true;
+                for (BOOST_AUTO_TPL(it, boost::begin(*rit)); it != boost::end(*rit);
+                    ++it, first = false)
+                {
+                    os << (first ? "M" : " L") << " "
+                        << geometry::get<0>(*it)
+                        << ","
+                        << geometry::get<1>(*it);
+                }
+            }
+        }
+        os << " z \" style=\"" << style << "\"/></g>";
+
+    }
+};
+
+
+
+struct prefix_linestring
+{
+    static inline const char* prefix() { return "polyline"; }
+    static inline const char* style() { return ";fill:none"; }
+};
+
+
+struct prefix_ring
+{
+    static inline const char* prefix() { return "polygon"; }
+    static inline const char* style() { return ""; }
+};
+
+
+
+}} // namespace detail::svg
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+/*!
+\brief Dispatching base struct for SVG streaming, specialized below per geometry type
+\details Specializations should implement a static method "stream" to stream a geometry
+The static method should have the signature:
+
+template <typename Char, typename Traits>
+static inline void apply(std::basic_ostream<Char, Traits>& os, G const& geometry)
+*/
+template <typename GeometryTag, typename Geometry>
+struct svg
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (Geometry)
+        );
+};
+
+template <typename Point>
+struct svg<point_tag, Point> : detail::svg::svg_point<Point> {};
+
+template <typename Box>
+struct svg<box_tag, Box> : detail::svg::svg_box<Box> {};
+
+template <typename Linestring>
+struct svg<linestring_tag, Linestring>
+    : detail::svg::svg_range<Linestring, detail::svg::prefix_linestring> {};
+
+template <typename Ring>
+struct svg<ring_tag, Ring>
+    : detail::svg::svg_range<Ring, detail::svg::prefix_ring> {};
+
+template <typename Polygon>
+struct svg<polygon_tag, Polygon>
+    : detail::svg::svg_poly<Polygon> {};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Generic geometry template manipulator class, takes corresponding output class from traits class
+\ingroup svg
+\details Stream manipulator, streams geometry classes as Virtual Earth shape
+*/
+template <typename G>
+class svg_manipulator
+{
+public:
+
+    inline svg_manipulator(G const& g, std::string const& style, int size)
+        : m_geometry(g)
+        , m_style(style)
+        , m_size(size)
+    {}
+
+    template <typename Char, typename Traits>
+    inline friend std::basic_ostream<Char, Traits>& operator<<(
+                    std::basic_ostream<Char, Traits>& os, svg_manipulator const& m)
+    {
+        dispatch::svg
+            <
+                typename tag<G>::type, G
+            >::apply(os, m.m_geometry, m.m_style, m.m_size);
+        os.flush();
+        return os;
+    }
+
+private:
+    G const& m_geometry;
+    std::string const& m_style;
+    int m_size;
+};
+
+/*!
+\brief Main svg function to stream geometries as SVG
+\ingroup svg
+*/
+template <typename Geometry>
+inline svg_manipulator<Geometry> svg(Geometry const& t, std::string const& style, int size = -1)
+{
+    concept::check<Geometry const>();
+
+    return svg_manipulator<Geometry>(t, style, size);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_SVG_WRITE_SVG_HPP
diff --git a/src/boost/geometry/extensions/io/svg/write_svg_multi.hpp b/src/boost/geometry/extensions/io/svg/write_svg_multi.hpp
new file mode 100644
index 0000000..3ca2c62
--- /dev/null
+++ b/src/boost/geometry/extensions/io/svg/write_svg_multi.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_SVG_WRITE_SVG_MULTI_HPP
+#define BOOST_GEOMETRY_IO_SVG_WRITE_SVG_MULTI_HPP
+
+
+#include <boost/geometry/extensions/io/svg/write_svg.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace svg
+{
+
+
+template <typename MultiGeometry, typename Policy>
+struct svg_multi
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+        MultiGeometry const& multi, std::string const& style, int size)
+    {
+        for (typename boost::range_iterator<MultiGeometry const>::type
+                    it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            Policy::apply(os, *it, style, size);
+        }
+
+    }
+
+};
+
+
+
+}} // namespace detail::svg
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename MultiPolygon>
+struct svg<multi_polygon_tag, MultiPolygon>
+    : detail::svg::svg_multi
+        <
+            MultiPolygon,
+            detail::svg::svg_poly
+                <
+                    typename boost::range_value<MultiPolygon>::type
+                >
+
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_IO_SVG_WRITE_SVG_MULTI_HPP
diff --git a/src/boost/geometry/extensions/iterators/circular_iterator.hpp b/src/boost/geometry/extensions/iterators/circular_iterator.hpp
new file mode 100644
index 0000000..31ae5ce
--- /dev/null
+++ b/src/boost/geometry/extensions/iterators/circular_iterator.hpp
@@ -0,0 +1,121 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ITERATORS_CIRCULAR_ITERATOR_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ITERATORS_CIRCULAR_ITERATOR_HPP
+
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+
+#include <boost/geometry/iterators/base.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+    \brief Iterator which goes circular through a range, starting at a point, ending at that point
+    \tparam Iterator iterator on which this class is based on
+    \ingroup iterators
+*/
+template <typename Iterator>
+struct circular_iterator :
+    public detail::iterators::iterator_base
+    <
+        circular_iterator<Iterator>,
+        Iterator
+    >
+{
+    friend class boost::iterator_core_access;
+
+    explicit inline circular_iterator(Iterator begin, Iterator end, Iterator start)
+        : m_begin(begin)
+        , m_end(end)
+        , m_start(start)
+    {
+        this->base_reference() = start;
+    }
+
+    // Constructor to indicate the end of a range, to enable e.g. std::copy
+    explicit inline circular_iterator(Iterator end)
+        : m_begin(end)
+        , m_end(end)
+        , m_start(end)
+    {
+        this->base_reference() = end;
+    }
+
+    /// Navigate to a certain position, should be in [start .. end], it at end
+    /// it will circle again.
+    inline void moveto(Iterator it)
+    {
+        this->base_reference() = it;
+        check_end();
+    }
+
+private:
+
+    inline void increment()
+    {
+        if (this->base() != m_end)
+        {
+            (this->base_reference())++;
+            check_end();
+        }
+    }
+    inline void decrement()
+    {
+        if (this->base() != m_end)
+        {
+            // If at begin, go back to end (assumed this is possible...)
+            if (this->base() == m_begin)
+            {
+                this->base_reference() = this->m_end;
+            }
+
+            // Decrement
+            (this->base_reference())--;
+
+            // If really back at start, go to end == end of iteration
+            if (this->base() == m_start)
+            {
+                this->base_reference() = this->m_end;
+            }
+        }
+    }
+
+
+    inline void check_end()
+    {
+        if (this->base() == this->m_end)
+        {
+            this->base_reference() = this->m_begin;
+        }
+
+        if (this->base() == m_start)
+        {
+            this->base_reference() = this->m_end;
+        }
+    }
+
+    Iterator m_begin;
+    Iterator m_end;
+    Iterator m_start;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ITERATORS_CIRCULAR_ITERATOR_HPP
diff --git a/src/boost/geometry/extensions/iterators/section_iterators.hpp b/src/boost/geometry/extensions/iterators/section_iterators.hpp
new file mode 100644
index 0000000..d0751f6
--- /dev/null
+++ b/src/boost/geometry/extensions/iterators/section_iterators.hpp
@@ -0,0 +1,233 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ITERATORS_SECTION_ITERATORS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ITERATORS_SECTION_ITERATORS_HPP
+
+// 24-04-2010, Moved to extensions/iterators
+//             because it was not yet used in the part.
+
+// FILE WILL BE SPLITTED
+
+
+#include <iterator>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/iterators/base.hpp>
+#include <boost/geometry/algorithms/overlaps.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace detail
+{
+
+    template <size_t D, typename P, typename B>
+    inline bool exceeding(short int dir, P const& point, B const& box)
+    {
+        return (dir == 1  && get<D>(point) > get<1, D>(box))
+            || (dir == -1 && get<D>(point) < get<0, D>(box));
+    }
+
+    template <size_t D, typename P, typename B>
+    inline bool preceding(short int dir, P const& point, B const& box)
+    {
+        return (dir == 1  && get<D>(point) < get<0, D>(box))
+            || (dir == -1 && get<D>(point) > get<1, D>(box));
+    }
+}
+
+
+// Iterator walking through ring/sections, delivering only those points of the ring
+// which are inside the specified box (using the sections)
+template<typename G, typename S, typename B, size_t D>
+struct section_iterator : public detail::iterators::iterator_base<
+                    section_iterator<G, S, B, D>,
+                    typename boost::range_iterator<G const>::type
+                >
+{
+    friend class boost::iterator_core_access;
+
+    inline section_iterator(G const& ring, S const& sections, B const& box)
+        : m_ring(ring)
+        , m_sections(sections)
+        , m_box(box)
+        , m_section_iterator(boost::begin(m_sections))
+    {
+        stay_within_box();
+    }
+
+
+private :
+
+    inline void increment()
+    {
+        (this->base_reference())++;
+
+        // If end or exceeding specified box, go to next section
+        if (this->base() == m_end
+                || detail::exceeding<D>(m_section_iterator->directions[0], *this->base(), m_box))
+        {
+            m_section_iterator++;
+            stay_within_box();
+        }
+
+    }
+
+    // Check if iterator is still in box and if not, go to the next section and advance until it is in box
+    void stay_within_box()
+    {
+        // Find section having overlap with specified box
+        while (m_section_iterator != boost::end(m_sections)
+                && ! overlaps(m_section_iterator->bounding_box, m_box))
+        {
+            m_section_iterator++;
+        }
+        if (m_section_iterator != boost::end(m_sections))
+        {
+            this->base_reference() = boost::begin(m_ring) + m_section_iterator->begin_index;
+            m_end = boost::begin(m_ring) + m_section_iterator->end_index + 1;
+
+            // While not yet at box, advance
+            while(this->base() != m_end
+                && detail::preceding<D>(m_section_iterator->directions[0], *this->base(), m_box))
+            {
+                ++(this->base_reference());
+            }
+
+            if (this->base() == m_end)
+            {
+                // This should actually not occur because of bbox check, but to be sure
+                m_section_iterator++;
+                stay_within_box();
+            }
+        }
+        else
+        {
+            this->base_reference() = boost::end(m_ring);
+            m_end = boost::end(m_ring);
+        }
+    }
+
+
+    typedef typename boost::range_iterator<G const>::type IT;
+    typedef typename boost::range_iterator<S const>::type SIT;
+
+    G const& m_ring;
+    S const& m_sections;
+    B const& m_box;
+
+    IT m_end;
+    SIT m_section_iterator;
+};
+
+
+// Iterator walking through ring/sections, delivering only those points of the ring
+// which are inside the specified box (using the sections)
+template<typename G, typename SEC, typename B, size_t D>
+struct one_section_segment_iterator : public detail::iterators::iterator_base<
+                one_section_segment_iterator<G, SEC, B, D>
+                , typename boost::range_iterator<G const>::type>
+{
+    friend class boost::iterator_core_access;
+    typedef typename boost::range_iterator<G const>::type normal_iterator;
+
+    inline one_section_segment_iterator(G const& ring, SEC const& section, B const& box)
+        : m_box(&box)
+        , m_dir(section.directions[0])
+    {
+        init(section, ring);
+    }
+
+    inline one_section_segment_iterator(normal_iterator end)
+        : m_section_end(end)
+        , m_ring_end(end)
+        , m_box(NULL)
+        , m_dir(0)
+    {
+        this->base_reference() = end;
+    }
+
+
+private :
+
+    inline void increment()
+    {
+        m_previous = (this->base_reference())++;
+
+        if (this->base() == m_section_end
+            || detail::exceeding<D>(m_dir, *m_previous, *m_box))
+        {
+            this->base_reference() = m_ring_end;
+        }
+    }
+
+    // Check if iterator is still in box and if not, go to the next section and advance until it is in box
+    void init(SEC const& section, G const& ring)
+    {
+        //this->base_reference();
+        m_section_end = boost::begin(ring) + section.end_index + 1;
+        m_ring_end = boost::end(ring);
+
+        this->base_reference() = boost::begin(ring) + section.begin_index;
+
+        /* Performance, TO BE CHECKED!
+        normal_iterator next = boost::begin(ring) + section.begin_index;
+        if (next != m_section_end && next != m_ring_end)
+        {
+
+            // While (not end and) not yet at box, advance
+            normal_iterator it = next++;
+            while(next != m_section_end && next != m_ring_end
+                    && detail::preceding<D>(m_dir, *next, *m_box))
+            {
+                it = next++;
+            }
+
+
+            if (it == m_section_end)
+            {
+                this->base_reference() = m_ring_end;
+            }
+            else
+            {
+                this->base_reference() = it;
+            }
+        }
+        else
+        {
+            this->base_reference() = m_ring_end;
+        }
+        */
+
+        m_previous = this->base();
+    }
+
+
+    const B* m_box;
+    short int m_dir;
+
+    normal_iterator m_previous;
+    normal_iterator m_section_end;
+    normal_iterator m_ring_end;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ITERATORS_SECTION_ITERATORS_HPP
diff --git a/src/boost/geometry/extensions/iterators/segment_returning_iterator.hpp b/src/boost/geometry/extensions/iterators/segment_returning_iterator.hpp
new file mode 100644
index 0000000..c92df37
--- /dev/null
+++ b/src/boost/geometry/extensions/iterators/segment_returning_iterator.hpp
@@ -0,0 +1,139 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_ITERATORS_SEGMENT_RETURNING_ITERATOR_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_ITERATORS_SEGMENT_RETURNING_ITERATOR_HPP
+
+// TODO: This is very experimental version of input iterator
+// reading collection of points as segments - proof of concept.
+// --mloskot
+
+// TODO: Move to boost::iterator_adaptor
+
+#include <iterator>
+
+#include <boost/assert.hpp>
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+
+#include <boost/geometry/algorithms/equals.hpp>
+
+// Helper geometry
+#include <boost/geometry/geometries/segment.hpp>
+
+namespace boost { namespace geometry
+{
+
+template <typename Base, typename Point>
+struct segment_returning_iterator
+{
+    typedef Base base_type;
+    typedef Point point_type;
+    typedef typename model::referring_segment<Point> segment_type;
+
+    typedef std::input_iterator_tag iterator_category;
+    typedef typename std::iterator_traits<Base>::difference_type difference_type;
+    typedef segment_type value_type;
+    typedef segment_type* pointer;
+    typedef segment_type& reference;
+
+    explicit segment_returning_iterator(Base const& end)
+        : m_segment(p1 , p2)
+        , m_prev(end)
+        , m_it(end)
+        , m_end(end)
+    {
+    }
+
+    segment_returning_iterator(Base const& it, Base const& end)
+        : m_segment(p1 , p2)
+        , m_prev(it)
+        , m_it(it)
+        , m_end(end)
+    {
+        if (m_it != m_end)
+        {
+            BOOST_ASSERT(m_prev != m_end);
+            ++m_it;
+        }
+    }
+
+    reference operator*()
+    {
+        BOOST_ASSERT(m_it != m_end && m_prev != m_end);
+
+        p1 = *m_prev;
+        p2 = *m_it;
+
+        return m_segment;
+    }
+
+    pointer operator->()
+    {
+        return &(operator*());
+    }
+
+    segment_returning_iterator& operator++()
+    {
+        ++m_prev;
+        ++m_it;
+        return *this;
+    }
+
+    segment_returning_iterator operator++(int)
+    {
+        segment_returning_iterator it(*this);
+        ++(*this);
+        return it;
+    }
+
+    Base const& base() const { return m_it; }
+
+private:
+
+    point_type p1;
+    point_type p2;
+    segment_type m_segment;
+
+    Base m_prev;
+    Base m_it;
+    Base m_end;
+};
+
+template <typename Base, typename Point>
+bool operator==(segment_returning_iterator<Base, Point> const& lhs,
+                segment_returning_iterator<Base, Point> const& rhs)
+{
+    return (lhs.base() == rhs.base());
+}
+
+template <typename Base, typename Point>
+bool operator!=(segment_returning_iterator<Base, Point> const& lhs,
+                segment_returning_iterator<Base, Point> const& rhs)
+{
+    return (lhs.base() != rhs.base());
+}
+
+template <typename C>
+inline segment_returning_iterator
+<
+    typename C::iterator,
+    typename C::value_type
+>
+make_segment_returning_iterator(C& c)
+{
+    typedef typename C::iterator base_iterator;
+    typedef typename C::value_type point_type;
+    return segment_returning_iterator<base_iterator, point_type>(c.begin(), c.end());
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_ITERATORS_SEGMENT_RETURNING_ITERATOR_HPP
diff --git a/src/boost/geometry/extensions/multi/algorithms/dissolve.hpp b/src/boost/geometry/extensions/multi/algorithms/dissolve.hpp
new file mode 100644
index 0000000..a6f5d60
--- /dev/null
+++ b/src/boost/geometry/extensions/multi/algorithms/dissolve.hpp
@@ -0,0 +1,99 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_MULTI_ALGORITHMS_DISSOLVE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_MULTI_ALGORITHMS_DISSOLVE_HPP
+
+
+#include <vector>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+
+#include <boost/geometry/algorithms/union.hpp>
+
+#include <boost/geometry/extensions/algorithms/dissolve.hpp>
+#include <boost/geometry/extensions/algorithms/detail/overlay/dissolver.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dissolve
+{
+
+template <typename Multi, typename GeometryOut>
+struct dissolve_multi
+{
+    template <typename OutputIterator>
+    static inline OutputIterator apply(Multi const& multi, OutputIterator out)
+    {
+        typedef typename boost::range_value<Multi>::type polygon_type;
+        typedef typename boost::range_iterator<Multi const>::type iterator_type;
+
+        // Step 1: dissolve all polygons in the multi-polygon, independantly
+        std::vector<GeometryOut> step1;
+        for (iterator_type it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            dissolve_ring_or_polygon
+                <
+                    polygon_type,
+                    GeometryOut
+                >::apply(*it, std::back_inserter(step1));
+        }
+
+        // Step 2: remove mutual overlap
+        {
+            std::vector<GeometryOut> step2; // TODO avoid this, output to "out", if possible
+            detail::dissolver::dissolver_generic<detail::dissolver::plusmin_policy>::apply(step1, step2);
+            for (typename std::vector<GeometryOut>::const_iterator it = step2.begin();
+                it != step2.end(); ++it)
+            {
+                *out++ = *it;
+            }
+        }
+
+        return out;
+    }
+};
+
+// Dissolving multi-linestring is currently moved to extensions/algorithms/connect,
+// because it is actually different from dissolving of polygons.
+// To be decided what the final behaviour/name is.
+
+}} // namespace detail::dissolve
+#endif
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template<typename Multi, typename GeometryOut>
+struct dissolve<multi_polygon_tag, polygon_tag, Multi, GeometryOut>
+    : detail::dissolve::dissolve_multi<Multi, GeometryOut>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_MULTI_ALGORITHMS_DISSOLVE_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/append.hpp b/src/boost/geometry/extensions/nsphere/algorithms/append.hpp
new file mode 100644
index 0000000..3a271b2
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/append.hpp
@@ -0,0 +1,45 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_APPEND_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_APPEND_HPP
+
+
+#include <boost/geometry/algorithms/append.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// This file is probably obsolete
+
+//template <typename TagRoP, typename N, typename RoP, bool Std>
+//struct append<nsphere_tag, TagRoP, N, RoP, Std> {};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_APPEND_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/area.hpp b/src/boost/geometry/extensions/nsphere/algorithms/area.hpp
new file mode 100644
index 0000000..f3fce16
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/area.hpp
@@ -0,0 +1,82 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_AREA_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_AREA_HPP
+
+#include <boost/math/constants/constants.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace area
+{
+
+template<typename C, typename S>
+struct circle_area
+{
+    typedef typename coordinate_type<C>::type coordinate_type;
+
+    // Returning the coordinate precision, but if integer, returning a double
+    typedef typename boost::mpl::if_c
+            <
+                boost::is_integral<coordinate_type>::type::value,
+                double,
+                coordinate_type
+            >::type return_type;
+
+    static inline return_type apply(C const& c, S const&)
+    {
+        // Currently only works for Cartesian circles
+        // Todo: use strategy
+        // Todo: use concept
+        assert_dimension<C, 2>();
+
+        return_type r = get_radius<0>(c);
+        r *= r * boost::math::constants::pi<return_type>();
+        return r;
+    }
+};
+
+
+
+}} // namespace detail::area
+
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Geometry, typename Strategy>
+struct area<nsphere_tag, Geometry, Strategy>
+    : detail::area::circle_area<Geometry, Strategy>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_AREA_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/assign.hpp b/src/boost/geometry/extensions/nsphere/algorithms/assign.hpp
new file mode 100644
index 0000000..0d83fa6
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/assign.hpp
@@ -0,0 +1,93 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_ASSIGN_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_ASSIGN_HPP
+
+#include <boost/geometry/algorithms/assign.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+#include <boost/geometry/extensions/nsphere/core/radius.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename S>
+struct assign<nsphere_tag, S, 2>
+{
+    typedef typename coordinate_type<S>::type coordinate_type;
+    typedef typename radius_type<S>::type radius_type;
+
+    /// 2-value version for an n-sphere is valid for circle and sets the center
+    template <typename T>
+    static inline void apply(S& sphercle, T const& c1, T const& c2)
+    {
+        set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
+        set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
+    }
+
+    template <typename T, typename R>
+    static inline void apply(S& sphercle, T const& c1,
+        T const& c2, R const& radius)
+    {
+        set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
+        set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
+        set_radius<0>(sphercle, boost::numeric_cast<radius_type>(radius));
+    }
+};
+
+template <typename S>
+struct assign<nsphere_tag, S, 3>
+{
+    typedef typename coordinate_type<S>::type coordinate_type;
+    typedef typename radius_type<S>::type radius_type;
+
+    /// 4-value version for an n-sphere is valid for a sphere and sets the center and the radius
+    template <typename T>
+    static inline void apply(S& sphercle, T const& c1, T const& c2, T const& c3)
+    {
+        set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
+        set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
+        set<2>(sphercle, boost::numeric_cast<coordinate_type>(c3));
+    }
+
+    /// 4-value version for an n-sphere is valid for a sphere and sets the center and the radius
+    template <typename T, typename R>
+    static inline void apply(S& sphercle, T const& c1,
+        T const& c2, T const& c3, R const& radius)
+    {
+
+        set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
+        set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
+        set<2>(sphercle, boost::numeric_cast<coordinate_type>(c3));
+        set_radius<0>(sphercle, boost::numeric_cast<radius_type>(radius));
+    }
+
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_ASSIGN_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/clear.hpp b/src/boost/geometry/extensions/nsphere/algorithms/clear.hpp
new file mode 100644
index 0000000..c59f7e8
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/clear.hpp
@@ -0,0 +1,47 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_CLEAR_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_CLEAR_HPP
+
+
+#include <boost/geometry/algorithms/clear.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+
+template <typename Geometry>
+struct clear<nsphere_tag, Geometry>
+    : detail::clear::no_action<Geometry>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_CLEAR_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/envelope.hpp b/src/boost/geometry/extensions/nsphere/algorithms/envelope.hpp
new file mode 100644
index 0000000..f265f16
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/envelope.hpp
@@ -0,0 +1,83 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_ENVELOPE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_ENVELOPE_HPP
+
+
+#include <boost/geometry/algorithms/envelope.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace envelope
+{
+
+/// Calculate envelope of an n-sphere, circle or sphere (currently only for Cartesian 2D points)
+template<typename Box, typename Nsphere, typename Strategy>
+struct envelope_nsphere
+{
+    static inline void apply(Nsphere const& nsphere, Box& mbr, Strategy const&)
+    {
+        assert_dimension<Nsphere, 2>();
+        assert_dimension<Box, 2>();
+
+        typename radius_type<Nsphere>::type radius = get_radius<0>(nsphere);
+        set<min_corner, 0>(mbr, get<0>(nsphere) - radius);
+        set<min_corner, 1>(mbr, get<1>(nsphere) - radius);
+        set<max_corner, 0>(mbr, get<0>(nsphere) + radius);
+        set<max_corner, 1>(mbr, get<1>(nsphere) + radius);
+    }
+};
+
+
+}} // namespace detail::envelope
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename Nsphere,
+    typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope
+    <
+        nsphere_tag, box_tag,
+        Nsphere, Box,
+        StrategyLess, StrategyGreater
+    >
+    : detail::envelope::envelope_nsphere
+        <
+            Nsphere, Box,
+            StrategyLess
+        >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_ENVELOPE_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/num_points.hpp b/src/boost/geometry/extensions/nsphere/algorithms/num_points.hpp
new file mode 100644
index 0000000..5525bfd
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/num_points.hpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_NUM_POINTS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_NUM_POINTS_HPP
+
+#include <boost/geometry/algorithms/num_points.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Geometry>
+struct num_points<nsphere_tag, false, Geometry>
+        : detail::num_points::other_count<Geometry, 1>
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_NUM_POINTS_HPP
diff --git a/src/boost/geometry/extensions/nsphere/algorithms/within.hpp b/src/boost/geometry/extensions/nsphere/algorithms/within.hpp
new file mode 100644
index 0000000..088548e
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/algorithms/within.hpp
@@ -0,0 +1,209 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_WITHIN_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_WITHIN_HPP
+
+
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/make.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/strategies/distance.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/access.hpp>
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/assign.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace within
+{
+
+
+
+//-------------------------------------------------------------------------------------------------------
+// Implementation for n-spheres. Supports circles or spheres, in 2 or 3 dimensions, in Euclidian system
+// Circle center might be of other point-type as geometry
+// Todo: implement as strategy
+//-------------------------------------------------------------------------------------------------------
+template<typename P, typename C>
+inline bool point_in_circle(P const& p, C const& c)
+{
+    namespace services = strategy::distance::services;
+
+    assert_dimension<C, 2>();
+
+    typedef typename point_type<C>::type point_type;
+    typedef typename services::default_strategy
+        <
+            point_tag, P, point_type
+        >::type strategy_type;
+    typedef typename services::return_type<strategy_type>::type return_type;
+
+    strategy_type strategy;
+
+    P const center = geometry::make<P>(get<0>(c), get<1>(c));
+    return_type const r = geometry::distance(p, center, strategy);
+    return_type const rad = services::result_from_distance
+        <
+            strategy_type
+        >::apply(strategy, get_radius<0>(c));
+
+    return r < rad;
+}
+/// 2D version
+template<typename T, typename C>
+inline bool point_in_circle(T const& c1, T const& c2, C const& c)
+{
+    typedef typename point_type<C>::type point_type;
+
+    point_type p = geometry::make<point_type>(c1, c2);
+    return point_in_circle(p, c);
+}
+
+template<typename B, typename C>
+inline bool box_in_circle(B const& b, C const& c)
+{
+    typedef typename point_type<B>::type point_type;
+
+    // Currently only implemented for 2d geometries
+    assert_dimension<point_type, 2>();
+    assert_dimension<C, 2>();
+
+    // Box: all four points must lie within circle
+
+    // Check points lower-left and upper-right, then lower-right and upper-left
+    return point_in_circle(get<min_corner, 0>(b), get<min_corner, 1>(b), c)
+        && point_in_circle(get<max_corner, 0>(b), get<max_corner, 1>(b), c)
+        && point_in_circle(get<min_corner, 0>(b), get<max_corner, 1>(b), c)
+        && point_in_circle(get<max_corner, 0>(b), get<min_corner, 1>(b), c);
+}
+
+// Generic "range-in-circle", true if all points within circle
+template<typename R, typename C>
+inline bool range_in_circle(R const& range, C const& c)
+{
+    assert_dimension<R, 2>();
+    assert_dimension<C, 2>();
+
+    for (typename boost::range_iterator<R const>::type it = boost::begin(range);
+         it != boost::end(range); ++it)
+    {
+        if (! point_in_circle(*it, c))
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+template<typename Y, typename C>
+inline bool polygon_in_circle(Y const& poly, C const& c)
+{
+    return range_in_circle(exterior_ring(poly), c);
+}
+
+
+
+template<typename I, typename C>
+inline bool multi_polygon_in_circle(I const& m, C const& c)
+{
+    for (typename I::const_iterator i = m.begin(); i != m.end(); i++)
+    {
+        if (! polygon_in_circle(*i, c))
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+
+
+}} // namespace detail::within
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename P, typename Circle, typename Strategy>
+struct within<point_tag, nsphere_tag, P, Circle, Strategy>
+{
+    static inline bool apply(P const& p, Circle const& c, Strategy const&)
+    {
+        return detail::within::point_in_circle(p, c);
+    }
+};
+
+template <typename Box, typename Circle, typename Strategy>
+struct within<box_tag, nsphere_tag, Box, Circle, Strategy>
+{
+    static inline bool apply(Box const& b, Circle const& c, Strategy const&)
+    {
+        return detail::within::box_in_circle(b, c);
+    }
+};
+
+template <typename Linestring, typename Circle, typename Strategy>
+struct within<linestring_tag, nsphere_tag, Linestring, Circle, Strategy>
+{
+    static inline bool apply(Linestring const& ln, Circle const& c, Strategy const&)
+    {
+        return detail::within::range_in_circle(ln, c);
+    }
+};
+
+template <typename Ring, typename Circle, typename Strategy>
+struct within<ring_tag, nsphere_tag, Ring, Circle, Strategy>
+{
+    static inline bool apply(Ring const& r, Circle const& c, Strategy const&)
+    {
+        return detail::within::range_in_circle(r, c);
+    }
+};
+
+template <typename Polygon, typename Circle, typename Strategy>
+struct within<polygon_tag, nsphere_tag, Polygon, Circle, Strategy>
+{
+    static inline bool apply(Polygon const& poly, Circle const& c, Strategy const&)
+    {
+        return detail::within::polygon_in_circle(poly, c);
+    }
+};
+
+template <typename M, typename C, typename Strategy>
+struct within<multi_polygon_tag, nsphere_tag, M, C, Strategy>
+{
+    static inline bool apply(M const& m, C const& c)
+    {
+        return detail::within::multi_polygon_in_circle(m, c, Strategy const&);
+    }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_ALGORITHMS_WITHIN_HPP
diff --git a/src/boost/geometry/extensions/nsphere/core/access.hpp b/src/boost/geometry/extensions/nsphere/core/access.hpp
new file mode 100644
index 0000000..6e82e8a
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/core/access.hpp
@@ -0,0 +1,52 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_ACCESS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_ACCESS_HPP
+
+
+
+#include <boost/geometry/core/access.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Nsphere, typename CoordinateType, std::size_t Dimension>
+struct access<nsphere_tag, Nsphere, CoordinateType, Dimension>
+{
+    static inline CoordinateType get(Nsphere const& nsphere)
+    {
+        return traits::access<Nsphere, Dimension>::get(nsphere);
+    }
+    static inline void set(Nsphere& s, CoordinateType const& value)
+    {
+        traits::access<Nsphere, Dimension>::set(s, value);
+    }
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_ACCESS_HPP
diff --git a/src/boost/geometry/extensions/nsphere/core/geometry_id.hpp b/src/boost/geometry/extensions/nsphere/core/geometry_id.hpp
new file mode 100644
index 0000000..ccf5cf8
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/core/geometry_id.hpp
@@ -0,0 +1,47 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_GEOMETRY_ID_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_GEOMETRY_ID_HPP
+
+
+#include <boost/geometry/core/geometry_id.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <>
+struct geometry_id<nsphere_tag>    : boost::mpl::int_<91> {};
+
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_GEOMETRY_ID_HPP
diff --git a/src/boost/geometry/extensions/nsphere/core/radius.hpp b/src/boost/geometry/extensions/nsphere/core/radius.hpp
new file mode 100644
index 0000000..4670ad2
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/core/radius.hpp
@@ -0,0 +1,160 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_RADIUS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_RADIUS_HPP
+
+
+#include <cstddef>
+
+
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+    \brief Traits class to get/set radius of a circle/sphere/(ellipse)
+    \details the radius access meta-functions give read/write access to the radius of a circle or a sphere,
+    or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid.
+
+    It should be specialized per geometry, in namespace core_dispatch. Those specializations should
+    forward the call via traits to the geometry class, which could be specified by the user.
+
+    There is a corresponding generic radius_get and radius_set function
+    \par Geometries:
+        - n-sphere (circle,sphere)
+        - upcoming ellipse
+    \par Specializations should provide:
+        - inline static T get(G const& geometry)
+        - inline static void set(G& geometry, T const& radius)
+    \ingroup traits
+*/
+template <typename G, typename T, std::size_t D>
+struct radius_access {};
+
+
+/*!
+    \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere
+    \par Geometries:
+        - n-sphere (circle,sphere)
+        - upcoming ellipse
+    \par Specializations should provide:
+        - typedef T type (double,float,int,etc)
+    \ingroup traits
+*/
+template <typename G>
+struct radius_type {};
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename G>
+struct radius_type
+{
+    //typedef core_dispatch_specialization_required type;
+};
+
+/*!
+    \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse.
+*/
+template <typename Tag, typename G, typename T, std::size_t D>
+struct radius_access
+{
+    //static inline T get(G const& ) {}
+    //static inline void set(G& g, T const& value) {}
+};
+
+template <typename S>
+struct radius_type<nsphere_tag, S>
+{
+    typedef typename traits::radius_type<S>::type type;
+};
+
+template <typename S, typename T, std::size_t D>
+struct radius_access<nsphere_tag, S, T, D>
+{
+    BOOST_STATIC_ASSERT((D == 0));
+    static inline T get(S const& s)
+    {
+        return traits::radius_access<S, T, D>::get(s);
+    }
+    static inline void set(S& s, T const& radius)
+    {
+        traits::radius_access<S, T, D>::set(s, radius);
+    }
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template <typename G>
+struct radius_type
+{
+    typedef typename boost::remove_const<G>::type rconst;
+    typedef typename core_dispatch::radius_type<typename tag<G>::type, rconst>::type type;
+};
+
+/*!
+    \brief Function to get radius
+    \return radius of a circle / sphere / ellipse
+    \ingroup access
+    \param geometry the geometry to get the radius from
+    \tparam I index, for circle/sphere always zero, for ellipse major/minor axis,
+        for ellipsoid one of the 3 equatorial radii
+*/
+template <std::size_t I, typename G>
+inline typename radius_type<G>::type get_radius(G const& geometry)
+{
+    typedef typename boost::remove_const<G>::type rconst;
+
+    return core_dispatch::radius_access<typename tag<G>::type, rconst,
+           typename radius_type<G>::type, I>::get(geometry);
+}
+
+/*!
+    \brief Function to set the radius of a circle / sphere / (ellipse)
+    \ingroup access
+    \tparam I index, for circle/sphere always zero, for ellipse major/minor axis,
+        for ellipsoid one of the 3 equatorial radii
+    \param geometry the geometry to change
+    \param radius the radius to set
+*/
+template <std::size_t I, typename G>
+inline void set_radius(G& geometry, typename radius_type<G>::type const& radius)
+{
+    typedef typename boost::remove_const<G>::type rconst;
+
+    core_dispatch::radius_access<typename tag<G>::type, G,
+        typename radius_type<G>::type, I>::set(geometry, radius);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_RADIUS_HPP
diff --git a/src/boost/geometry/extensions/nsphere/core/replace_point_type.hpp b/src/boost/geometry/extensions/nsphere/core/replace_point_type.hpp
new file mode 100644
index 0000000..ecc2a16
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/core/replace_point_type.hpp
@@ -0,0 +1,48 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_REPLACE_POINT_TYPE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_REPLACE_POINT_TYPE_HPP
+
+
+#include <boost/geometry/core/replace_point_type.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+#include <boost/geometry/extensions/nsphere/geometries/nsphere.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<nsphere_tag, Geometry, NewPointType>
+{
+    typedef typename geometry::coordinate_type<Geometry>::type coortype;
+    typedef model::nsphere<NewPointType, coortype> type;
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_REPLACE_POINT_TYPE_HPP
diff --git a/src/boost/geometry/extensions/nsphere/core/tags.hpp b/src/boost/geometry/extensions/nsphere/core/tags.hpp
new file mode 100644
index 0000000..beac11f
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/core/tags.hpp
@@ -0,0 +1,29 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_TAGS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_TAGS_HPP
+
+
+namespace boost { namespace geometry
+{
+
+
+/// Convenience 2D (circle) or 3D (sphere) n-sphere identifying tag
+struct nsphere_tag {};
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_TAGS_HPP
diff --git a/src/boost/geometry/extensions/nsphere/core/topological_dimension.hpp b/src/boost/geometry/extensions/nsphere/core/topological_dimension.hpp
new file mode 100644
index 0000000..f0e7c9c
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/core/topological_dimension.hpp
@@ -0,0 +1,50 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_TOPOLOGICAL_DIMENSION_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_TOPOLOGICAL_DIMENSION_HPP
+
+
+#include <boost/geometry/core/topological_dimension.hpp>
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+
+// nsphere: 2, but there is discussion. Is it CLOSED? Then 2, but
+// then it should be called "disk"...
+template <>
+struct top_dim<nsphere_tag>    : boost::mpl::int_<2> {};
+
+
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_CORE_TOPOLOGICAL_DIMENSION_HPP
diff --git a/src/boost/geometry/extensions/nsphere/geometries/concepts/check.hpp b/src/boost/geometry/extensions/nsphere/geometries/concepts/check.hpp
new file mode 100644
index 0000000..944eb0d
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/geometries/concepts/check.hpp
@@ -0,0 +1,42 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_CONCEPTS_CHECK_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_CONCEPTS_CHECK_HPP
+
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+
+
+} // namespace dispatch
+#endif
+
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_CONCEPTS_CHECK_HPP
diff --git a/src/boost/geometry/extensions/nsphere/geometries/concepts/nsphere_concept.hpp b/src/boost/geometry/extensions/nsphere/geometries/concepts/nsphere_concept.hpp
new file mode 100644
index 0000000..03decb4
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/geometries/concepts/nsphere_concept.hpp
@@ -0,0 +1,122 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_CONCEPTS_NSPHERE_CONCEPT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_CONCEPTS_NSPHERE_CONCEPT_HPP
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/extensions/nsphere/core/radius.hpp>
+
+namespace boost { namespace geometry { namespace concept {
+
+/*!
+    \brief Checks Nsphere concept (const version)
+    \ingroup concepts
+    \details The ConstNsphere concept check the same as the Nsphere concept,
+    but does not check write access.
+*/
+template <typename Geometry>
+class ConstNsphere
+{
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename radius_type<Geometry>::type radius_type;
+
+
+    template <size_t Dimension, size_t DimensionCount>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            typedef typename coordinate_type<Geometry>::type coordinate_type;
+            const Geometry* s = 0;
+            coordinate_type coord(geometry::get<Dimension>(*s));
+            boost::ignore_unused_variable_warning(coord);
+            dimension_checker<Dimension + 1, DimensionCount>::apply();
+        }
+    };
+
+    template <size_t DimensionCount>
+    struct dimension_checker<DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstNsphere)
+    {
+        static const size_t n = dimension<Geometry>::value;
+        dimension_checker<0, n>::apply();
+        dimension_checker<0, n>::apply();
+
+        // Check radius access
+        Geometry const* s = 0;
+        radius_type coord(geometry::get_radius<0>(*s));
+        boost::ignore_unused_variable_warning(coord);
+    }
+};
+
+
+/*!
+    \brief Checks nsphere concept
+    \ingroup concepts
+*/
+template <typename Geometry>
+class Nsphere
+{
+    BOOST_CONCEPT_ASSERT( (concept::ConstNsphere<Geometry>) );
+
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename radius_type<Geometry>::type radius_type;
+
+
+    template <size_t Dimension, size_t DimensionCount>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            Geometry* s;
+            geometry::set<Dimension>(*s, geometry::get<Dimension>(*s));
+            dimension_checker<Dimension + 1, DimensionCount>::apply();
+        }
+    };
+
+    template <size_t DimensionCount>
+    struct dimension_checker<DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public :
+
+    BOOST_CONCEPT_USAGE(Nsphere)
+    {
+        static const size_t n = dimension<Geometry>::type::value;
+        dimension_checker<0, n>::apply();
+        dimension_checker<0, n>::apply();
+
+        // Check radius access
+        Geometry* s = 0;
+        set_radius<0>(*s, get_radius<0>(*s));
+    }
+};
+
+
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_CONCEPTS_NSPHERE_CONCEPT_HPP
diff --git a/src/boost/geometry/extensions/nsphere/geometries/nsphere.hpp b/src/boost/geometry/extensions/nsphere/geometries/nsphere.hpp
new file mode 100644
index 0000000..a4ea8af
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/geometries/nsphere.hpp
@@ -0,0 +1,144 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_NSPHERE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_NSPHERE_HPP
+
+#include <cstddef>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/assign.hpp>
+#include <boost/geometry/extensions/nsphere/geometries/concepts/nsphere_concept.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+
+/*!
+    \brief Class nsphere: defines a circle or a sphere: a point with radius
+    \ingroup Geometry
+    \details The name nsphere is quite funny but the best description of the class. It can be a circle (2D),
+    a sphere (3D), or higher (hypersphere) or lower. According to Wikipedia this name is the most appropriate.
+    It was mentioned on the Boost list.
+    An alternative is the more fancy name "sphercle" but that might be a bit too much an invention.
+    \note Circle is currently used for selections, for example polygon_in_circle. Currently not all
+    algorithms are implemented for n-spheres.
+    \tparam P point type of the center
+    \tparam T number type of the radius
+ */
+template <typename P, typename T>
+class nsphere
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<P>) );
+
+public:
+
+    typedef T radius_type;
+    typedef typename coordinate_type<P>::type coordinate_type;
+
+    nsphere()
+        : m_radius(0)
+    {
+        detail::assign::assign_value(m_center, coordinate_type());
+    }
+
+    nsphere(P const& center, T const& radius)
+        : m_radius(radius)
+    {
+        geometry::convert(center, m_center);
+    }
+
+    inline P const& center() const { return m_center; }
+    inline T const& radius() const { return m_radius; }
+
+    inline void radius(T const& r) { m_radius = r; }
+    inline P& center() { return m_center; }
+
+private:
+
+    P m_center;
+    T m_radius;
+};
+
+
+} // namespace model
+
+// Traits specializations for n-sphere above
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename Point, typename RadiusType>
+struct tag<model::nsphere<Point, RadiusType> >
+{
+    typedef nsphere_tag type;
+};
+
+template <typename Point, typename RadiusType>
+struct point_type<model::nsphere<Point, RadiusType> >
+{
+    typedef Point type;
+};
+
+template <typename Point, typename RadiusType>
+struct radius_type<model::nsphere<Point, RadiusType> >
+{
+    typedef RadiusType type;
+};
+
+template <typename Point, typename CoordinateType, std::size_t Dimension>
+struct access<model::nsphere<Point, CoordinateType>,  Dimension>
+{
+    typedef model::nsphere<Point, CoordinateType> nsphere_type;
+
+    static inline CoordinateType get(nsphere_type const& s)
+    {
+        return geometry::get<Dimension>(s.center());
+    }
+
+    static inline void set(nsphere_type& s, CoordinateType const& value)
+    {
+        geometry::set<Dimension>(s.center(), value);
+    }
+};
+
+template <typename Point, typename RadiusType>
+struct radius_access<model::nsphere<Point, RadiusType>, RadiusType, 0>
+{
+    typedef model::nsphere<Point, RadiusType> nsphere_type;
+
+    static inline RadiusType get(nsphere_type const& s)
+    {
+        return s.radius();
+    }
+
+    static inline void set(nsphere_type& s, RadiusType const& value)
+    {
+        s.radius(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_GEOMETRIES_NSPHERE_HPP
diff --git a/src/boost/geometry/extensions/nsphere/nsphere.hpp b/src/boost/geometry/extensions/nsphere/nsphere.hpp
new file mode 100644
index 0000000..04d67d2
--- /dev/null
+++ b/src/boost/geometry/extensions/nsphere/nsphere.hpp
@@ -0,0 +1,37 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_NSPHERE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_NSPHERE_HPP
+
+#include <boost/geometry/extensions/nsphere/core/access.hpp>
+#include <boost/geometry/extensions/nsphere/core/geometry_id.hpp>
+#include <boost/geometry/extensions/nsphere/core/radius.hpp>
+#include <boost/geometry/extensions/nsphere/core/replace_point_type.hpp>
+#include <boost/geometry/extensions/nsphere/core/tags.hpp>
+#include <boost/geometry/extensions/nsphere/core/topological_dimension.hpp>
+
+#include <boost/geometry/extensions/nsphere/geometries/concepts/check.hpp>
+#include <boost/geometry/extensions/nsphere/geometries/concepts/nsphere_concept.hpp>
+
+#include <boost/geometry/extensions/nsphere/geometries/nsphere.hpp>
+
+#include <boost/geometry/extensions/nsphere/algorithms/append.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/area.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/assign.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/clear.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/envelope.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/num_points.hpp>
+#include <boost/geometry/extensions/nsphere/algorithms/within.hpp>
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_NSPHERE_HPP
diff --git a/src/boost/geometry/extensions/strategies/buffer.hpp b/src/boost/geometry/extensions/strategies/buffer.hpp
new file mode 100644
index 0000000..96f94c9
--- /dev/null
+++ b/src/boost/geometry/extensions/strategies/buffer.hpp
@@ -0,0 +1,396 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_HPP
+
+
+// Buffer strategies
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/strategies/tags.hpp>
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+
+
+#define BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+namespace strategy { namespace buffer
+{
+
+
+
+/*
+
+   A Buffer-join strategy gets 4 input points.
+   On the two consecutive segments s1 and s2 (joining at vertex v):
+
+   The lines from parallel at s1, s2 (at buffer-distance) end/start
+   in two points perpendicular to the segments: p1 and p2.
+   These parallel lines interesct in point ip
+
+             (s2)
+              |
+              |
+              ^
+              |
+        (p2)  |(v)
+        *     +----<--- (s1)
+
+        x(ip) *(p1)
+
+
+    So, in clockwise order:
+        v : vertex point
+        p1: perpendicular on left side of segment1<1> (perp1)
+        ip: intersection point
+        p2: perpendicular on left side of segment2<0> (perp2)
+*/
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+template
+<
+    typename PointIn, typename Mapper
+>
+struct join_mapper
+{
+    Mapper const& m_mapper;
+    join_mapper(Mapper const& mapper)
+        : m_mapper(mapper)
+    {}
+
+    template <typename Ring>
+    inline void map(PointIn const& ip, PointIn const& vertex,
+                PointIn const& perp1, PointIn const& perp2) const
+    {
+        Ring corner;
+        corner.push_back(vertex);
+        corner.push_back(perp1);
+        corner.push_back(ip);
+        corner.push_back(perp2);
+        corner.push_back(vertex);
+
+        const_cast<Mapper&>(m_mapper).map(corner,
+            "opacity:0.4;fill:rgb(255,0,0);stroke:rgb(0,0,0);stroke-width:1");
+    }
+};
+#endif
+
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+// Forget this, it will go
+template<typename PointIn, typename PointOut, typename Mapper>
+struct join_miter : public join_mapper<PointIn, Mapper>
+{
+    join_miter(Mapper const& mapper) : join_mapper(mapper) {}
+#else
+
+
+template
+<
+    typename PointIn,
+    typename PointOut
+>
+struct join_miter
+{
+
+#endif
+    typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
+    typedef typename coordinate_type<PointIn>::type coordinate_type;
+
+
+    template <typename Ring>
+    inline void apply(PointIn const& ip, PointIn const& vertex,
+                PointIn const& perp1, PointIn const& perp2,
+                coordinate_type const& buffer_distance,
+                Ring& buffered) const
+    {
+        coordinate_type zero = 0;
+        int signum = buffer_distance > zero
+            ? 1
+            : buffer_distance < zero
+                ? -1
+                : 0;
+
+        if (side::apply(perp1, ip, perp2) == signum)
+        {
+
+#ifdef BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+            // Because perp1 crosses perp2 at IP, it is not necessary to
+            // include IP
+            buffered.push_back(ip);
+#else
+            // If it is concave (corner to left), add helperline
+            // The helper-line IS essential for buffering holes. Without,
+            // holes might be generated, while they should NOT be there.
+            // DOES NOT WORK ALWAYS buffered.push_back(ip);
+            // We might consider to make it optional (because more efficient)
+            buffered.push_back(perp1);
+            buffered.push_back(perp2);
+#endif
+        }
+        else
+        {
+            PointIn p = ip;
+
+            // Normalize it and give it X*dist.
+            coordinate_type dx = get<0>(ip) - get<0>(vertex);
+            coordinate_type dy = get<1>(ip) - get<1>(vertex);
+
+            coordinate_type length = sqrt(dx * dx + dy * dy);
+
+            // TODO: make max-mitre-limit flexible
+            coordinate_type ten = 10.0;
+            coordinate_type zero_seven = 0.7;
+
+            coordinate_type max = ten * geometry::math::abs(buffer_distance);
+
+            if (length > max)
+            {
+
+                coordinate_type prop = zero_seven * buffer_distance;
+                prop /= length;
+                set<0>(p, get<0>(vertex) + dx * prop);
+                set<1>(p, get<1>(vertex) + dy * prop);
+
+#ifdef BOOST_GEOMETRY_DEBUG_BUFFER
+                std::cout << length << std::endl;
+#endif
+            }
+
+            buffered.push_back(p);
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            map<Ring>(ip, vertex, perp1, perp2);
+#endif
+        }
+
+
+    }
+};
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+// Forget this, it will go
+template<typename PointIn, typename PointOut, typename Mapper>
+struct join_bevel : public join_mapper<PointIn, Mapper>
+{
+    join_bevel(Mapper const& mapper) : join_mapper(mapper) {}
+#else
+
+
+template
+<
+    typename PointIn,
+    typename PointOut
+>
+struct join_bevel
+{
+#endif
+
+
+    typedef typename coordinate_type<PointIn>::type coordinate_type;
+
+    template <typename Ring>
+    inline void apply(PointIn const& ip, PointIn const& vertex,
+                PointIn const& perp1, PointIn const& perp2,
+                coordinate_type const& buffer_distance,
+                Ring& buffered) const
+    {
+        buffered.push_back(perp1);
+        buffered.push_back(perp2);
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            map<Ring>(ip, vertex, perp1, perp2);
+#endif
+    }
+};
+
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+// Forget this, it will go
+template<typename PointIn, typename PointOut, typename Mapper>
+struct join_round : public join_mapper<PointIn, Mapper>
+{
+    join_round(Mapper const& mapper, int max_level = 4)
+        : join_mapper(mapper)
+        , m_max_level(max_level)
+    {}
+#else
+
+
+template
+<
+    typename PointIn,
+    typename PointOut
+>
+struct join_round
+{
+    inline join_round(int max_level = 4)
+        : m_max_level(max_level)
+    {}
+#endif
+
+    typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
+    typedef typename coordinate_type<PointOut>::type coordinate_type;
+    int m_max_level;
+
+
+    template <typename Ring>
+    inline void mid_points(PointIn const& vertex,
+                PointIn const& p1, PointIn const& p2,
+                coordinate_type const& buffer_distance,
+                Ring& buffered,
+                int level = 1) const
+    {
+        // Generate 'vectors'
+        coordinate_type vp1_x = get<0>(p1) - get<0>(vertex);
+        coordinate_type vp1_y = get<1>(p1) - get<1>(vertex);
+
+        coordinate_type vp2_x = (get<0>(p2) - get<0>(vertex));
+        coordinate_type vp2_y = (get<1>(p2) - get<1>(vertex));
+
+        // Average them to generate vector in between
+        coordinate_type two = 2;
+        coordinate_type v_x = (vp1_x + vp2_x) / two;
+        coordinate_type v_y = (vp1_y + vp2_y) / two;
+
+        coordinate_type length2 = sqrt(v_x * v_x + v_y * v_y);
+
+        coordinate_type prop = buffer_distance / length2;
+
+        PointIn mid_point;
+        set<0>(mid_point, get<0>(vertex) + v_x * prop);
+        set<1>(mid_point, get<1>(vertex) + v_y * prop);
+
+        if (level < m_max_level)
+        {
+            mid_points(vertex, p1, mid_point, buffer_distance, buffered, level + 1);
+        }
+        buffered.push_back(mid_point);
+        if (level < m_max_level)
+        {
+            mid_points(vertex, mid_point, p2, buffer_distance, buffered, level + 1);
+        }
+
+    }
+
+
+    template <typename Ring>
+    inline void apply(PointIn const& ip, PointIn const& vertex,
+                PointIn const& perp1, PointIn const& perp2,
+                coordinate_type const& buffer_distance,
+                Ring& buffered) const
+    {
+        coordinate_type zero = 0;
+        int signum = buffer_distance > zero
+            ? 1
+            : buffer_distance < zero
+                ? -1
+                : 0;
+
+        if (side::apply(perp1, ip, perp2) == signum)
+        {
+#ifdef BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+            buffered.push_back(ip);
+#else
+            // If it is concave (corner to left), add helperline
+            buffered.push_back(perp1);
+            buffered.push_back(perp2);
+#endif
+        }
+        else
+        {
+            // Generate 'vectors'
+            coordinate_type vix = (get<0>(ip) - get<0>(vertex));
+            coordinate_type viy = (get<1>(ip) - get<1>(vertex));
+
+            coordinate_type length_i = sqrt(vix * vix + viy * viy);
+
+
+            coordinate_type const bd = geometry::math::abs(buffer_distance);
+            coordinate_type prop = bd / length_i;
+
+            PointIn bp;
+            set<0>(bp, get<0>(vertex) + vix * prop);
+            set<1>(bp, get<1>(vertex) + viy * prop);
+
+            if (m_max_level <= 1)
+            {
+                buffered.push_back(perp1);
+                if (m_max_level == 1)
+                {
+                    buffered.push_back(bp);
+                }
+                buffered.push_back(perp2);
+            }
+            else
+            {
+                buffered.push_back(perp1);
+                mid_points(vertex, perp1, bp, bd, buffered);
+                mid_points(vertex, bp, perp2, bd, buffered);
+                buffered.push_back(perp2);
+            }
+
+#ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER
+            map<Ring>(bp, vertex, perp1, perp2);
+#endif
+        }
+    }
+};
+
+
+
+template
+<
+    typename CoordinateType
+>
+class distance_assymetric
+{
+public :
+    distance_assymetric(CoordinateType const& left,
+                CoordinateType const& right)
+        : m_left(left)
+        , m_right(right)
+    {}
+
+    template <typename Point>
+    inline CoordinateType apply(Point const& , Point const& ,
+                buffer_side_selector side)  const
+    {
+        return side == buffer_side_left ? m_left : m_right;
+    }
+
+private :
+    CoordinateType m_left;
+    CoordinateType m_right;
+};
+
+
+}} // namespace strategy::buffer
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_HPP
diff --git a/src/boost/geometry/extensions/strategies/buffer_join_round.hpp b/src/boost/geometry/extensions/strategies/buffer_join_round.hpp
new file mode 100644
index 0000000..5e4549c
--- /dev/null
+++ b/src/boost/geometry/extensions/strategies/buffer_join_round.hpp
@@ -0,0 +1,176 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_JOIN_ROUND_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_JOIN_ROUND_HPP
+
+
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/arithmetic/dot_product.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/strategies/tags.hpp>
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/extensions/strategies/buffer_side.hpp>
+
+
+#define BOOST_GEOMETRY_BUFFER_NO_HELPER_POINTS
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+namespace strategy { namespace buffer
+{
+
+
+
+
+template<typename PointOut>
+struct join_round2
+{
+    typedef PointOut vector_type;
+
+    template <typename Vector, typename Point1, typename Point2>
+    static inline Vector create_vector(Point1 const& p1, Point2 const& p2)
+    {
+        Vector v;
+        geometry::convert(p1, v);
+        subtract_point(v, p2);
+        return v;
+    }
+
+    inline join_round2(int max_level = 4)
+        : m_max_level(max_level)
+    {}
+
+    typedef typename coordinate_type<PointOut>::type coordinate_type;
+    int m_max_level;
+
+
+    template <typename OutputIterator, typename Point, typename PointP, typename Point1, typename Point2>
+    inline void mid_points(Point const& vertex, PointP const& perpendicular,
+                Point1 const& p1, Point2 const& p2,
+                coordinate_type const& buffer_distance,
+                coordinate_type const& max_distance,
+                OutputIterator out,
+                int level = 1) const
+    {
+        // Generate 'vectors'
+        coordinate_type vp1_x = get<0>(p1) - get<0>(vertex);
+        coordinate_type vp1_y = get<1>(p1) - get<1>(vertex);
+
+        coordinate_type vp2_x = (get<0>(p2) - get<0>(vertex));
+        coordinate_type vp2_y = (get<1>(p2) - get<1>(vertex));
+
+        // Average them to generate vector in between
+        coordinate_type two = 2;
+        coordinate_type v_x = (vp1_x + vp2_x) / two;
+        coordinate_type v_y = (vp1_y + vp2_y) / two;
+
+        coordinate_type between_length = sqrt(v_x * v_x + v_y * v_y);
+
+        coordinate_type const positive_buffer_distance = geometry::math::abs(buffer_distance);
+        coordinate_type prop = positive_buffer_distance / between_length;
+
+        PointOut mid_point;
+        set<0>(mid_point, get<0>(vertex) + v_x * prop);
+        set<1>(mid_point, get<1>(vertex) + v_y * prop);
+
+        if (buffer_distance > max_distance)
+        {
+            // Calculate point projected on original perpendicular segment,
+            // using vector maths
+            vector_type v = create_vector<vector_type>(perpendicular, vertex);
+            vector_type w = create_vector<vector_type>(mid_point, vertex);
+
+            coordinate_type c1 = dot_product(w, v);
+            if (c1 > 0)
+            {
+                coordinate_type c2 = dot_product(v, v);
+                if (c2 > c1)
+                {
+                    coordinate_type b = c1 / c2;
+
+                    PointOut projected_point;
+
+                    multiply_value(v, b);
+                    geometry::convert(vertex, projected_point);
+                    add_point(projected_point, v);
+
+                    coordinate_type projected_distance = geometry::distance(projected_point, mid_point);
+
+                    if (projected_distance > max_distance)
+                    {
+                        // Do not generate from here on.
+                        return;
+                    }
+                }
+            }
+        }
+
+        if (level < m_max_level)
+        {
+            mid_points(vertex, perpendicular, p1, mid_point, positive_buffer_distance, max_distance, out, level + 1);
+        }
+        *out++ = mid_point;
+        if (level < m_max_level)
+        {
+            mid_points(vertex, perpendicular, mid_point, p2, positive_buffer_distance, max_distance, out, level + 1);
+        }
+    }
+
+
+    template <typename OutputIterator, typename Point, typename Point2>
+    inline OutputIterator apply(Point const& vertex,
+                Point2 const& perpendicular,
+                Point2 const& p1, Point2 const& p2,
+                coordinate_type const& buffer_distance,
+                coordinate_type const& max_distance,
+                OutputIterator out) const
+    {
+        mid_points(vertex, perpendicular, p1, p2, buffer_distance, max_distance, out);
+        return out;
+    }
+};
+
+
+template<typename PointOut>
+struct join_none
+{
+    template <typename OutputIterator, typename Point, typename Point2,
+        typename DistanceType>
+    inline OutputIterator apply(Point const& ,
+                Point2 const& ,
+                Point2 const& , Point2 const& ,
+                DistanceType const& ,
+                DistanceType const& ,
+                OutputIterator out) const
+    {
+        return out;
+    }
+};
+
+
+}} // namespace strategy::buffer
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_JOIN_ROUND_HPP
diff --git a/src/boost/geometry/extensions/strategies/buffer_side.hpp b/src/boost/geometry/extensions/strategies/buffer_side.hpp
new file mode 100644
index 0000000..33e658d
--- /dev/null
+++ b/src/boost/geometry/extensions/strategies/buffer_side.hpp
@@ -0,0 +1,31 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_SIDE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_SIDE_HPP
+
+
+
+namespace boost { namespace geometry
+{
+
+
+// TODO: consider if this enum can be placed in another headerfile
+// or probably there will be more enum's or constants for the buffer
+enum buffer_side_selector { buffer_side_left, buffer_side_right };
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_SIDE_HPP
diff --git a/src/boost/geometry/extensions/strategies/parse.hpp b/src/boost/geometry/extensions/strategies/parse.hpp
new file mode 100644
index 0000000..de0cdc2
--- /dev/null
+++ b/src/boost/geometry/extensions/strategies/parse.hpp
@@ -0,0 +1,41 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_EXTENSIONS_PARSE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_EXTENSIONS_PARSE_HPP
+
+#include <boost/geometry/strategies/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+/*!
+    \brief Tagraits class binding a parsing strategy to a coordinate system
+    \ingroup parse
+    \tparam Tag tag of coordinate system of point-type
+    \tparam CoordinateSystem coordinate system
+*/
+template <typename Tag, typename CoordinateSystem>
+struct strategy_parse
+{
+    typedef strategy::not_implemented type;
+};
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_EXTENSIONS_PARSE_HPP
diff --git a/src/boost/geometry/extensions/util/get_cs_as_radian.hpp b/src/boost/geometry/extensions/util/get_cs_as_radian.hpp
new file mode 100644
index 0000000..03a20e5
--- /dev/null
+++ b/src/boost/geometry/extensions/util/get_cs_as_radian.hpp
@@ -0,0 +1,55 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_UTIL_GET_CS_AS_RADIAN_HPP
+#define BOOST_GEOMETRY_UTIL_GET_CS_AS_RADIAN_HPP
+
+// obsolete? It is not used anymore (get_as_radian is usually OK)
+
+#include <boost/geometry/core/cs.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+    /*!
+        \brief Small meta-function defining the specified coordinate system,
+        but then in radian units
+    */
+    template <typename CoordinateSystem>
+    struct get_cs_as_radian {};
+
+    template <typename Units>
+    struct get_cs_as_radian<cs::geographic<Units> >
+    {
+        typedef cs::geographic<radian> type;
+    };
+
+    template <typename Units>
+    struct get_cs_as_radian<cs::spherical<Units> >
+    {
+        typedef cs::spherical<radian> type;
+    };
+
+} // namespace detail
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_GET_CS_AS_RADIAN_HPP
diff --git a/src/boost/geometry/extensions/util/replace_point_type.hpp b/src/boost/geometry/extensions/util/replace_point_type.hpp
new file mode 100644
index 0000000..f1300f2
--- /dev/null
+++ b/src/boost/geometry/extensions/util/replace_point_type.hpp
@@ -0,0 +1,98 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_EXTENSIONS_UTIL_REPLACE_POINT_TYPE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_UTIL_REPLACE_POINT_TYPE_HPP
+
+
+#include <boost/type_traits/remove_const.hpp>
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+// For now: use ggl-provided geometries
+// TODO: figure out how to get the class and replace the type
+// TODO: take "const" into account
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+template <typename GeometryTag, typename Geometry, typename NewPointType>
+struct replace_point_type {};
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<point_tag, Geometry, NewPointType>
+{
+    typedef NewPointType type;
+};
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<linestring_tag, Geometry, NewPointType>
+{
+    typedef model::linestring<NewPointType> type;
+};
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<segment_tag, Geometry, NewPointType>
+{
+    typedef model::segment<NewPointType> type;
+};
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<ring_tag, Geometry, NewPointType>
+{
+    typedef model::ring<NewPointType> type;
+};
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<box_tag, Geometry, NewPointType>
+{
+    typedef model::box<NewPointType> type;
+};
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type<polygon_tag, Geometry, NewPointType>
+{
+    typedef model::polygon<NewPointType> type;
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template <typename Geometry, typename NewPointType>
+struct replace_point_type : core_dispatch::replace_point_type
+        <
+            typename tag<Geometry>::type,
+            typename boost::remove_const<Geometry>::type,
+            NewPointType
+        >
+{};
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_UTIL_REPLACE_POINT_TYPE_HPP
diff --git a/src/boost/geometry/extensions/views/enveloped_view.hpp b/src/boost/geometry/extensions/views/enveloped_view.hpp
new file mode 100644
index 0000000..0e654cd
--- /dev/null
+++ b/src/boost/geometry/extensions/views/enveloped_view.hpp
@@ -0,0 +1,126 @@
+// Boost.Range (aka GGL, Generic Range Library)
+//
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_ENVELOPED_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_ENVELOPED_VIEW_HPP
+
+
+// Note the addition of this whole file was committed to SVN by accident,
+// probably obsolete
+
+#include <boost/mpl/if.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+template <typename Range, typename Box, std::size_t Dimension>
+class enveloped_view
+{
+public :
+    typedef typename boost::range_iterator<Range const>::type const_iterator;
+    typedef typename boost::range_iterator<Range>::type iterator;
+
+    explicit enveloped_view(Range& range, Box const& box, int dir)
+        : m_begin(boost::begin(range))
+        , m_end(boost::end(range))
+    {
+        find_first(dir, m_begin, m_end, box);
+        find_last(dir, m_begin, m_end, box);
+
+        // Assignment of const iterator to iterator seems no problem,
+        // at least not for MSVC and GCC
+        m_const_begin = m_begin;
+        m_const_end = m_end;
+        // Otherwise: repeat
+        //find_first(dir, m_const_begin, m_const_end);
+        //find_last(dir, m_const_begin, m_const_end);
+    }
+
+    const_iterator begin() const { return m_const_begin; }
+    const_iterator end() const { return m_const_end; }
+
+    iterator begin() { return m_begin; }
+    iterator end() { return m_end; }
+
+private :
+    const_iterator m_const_begin, m_const_end;
+    iterator m_begin, m_end;
+
+    template <typename Point>
+    inline bool preceding(short int dir, Point const& point, Box const& box)
+    {
+        return (dir == 1  && get<Dimension>(point) < get<0, Dimension>(box))
+            || (dir == -1 && get<Dimension>(point) > get<1, Dimension>(box));
+    }
+
+    template <typename Point>
+    inline bool exceeding(short int dir, Point const& point, Box const& box)
+    {
+        return (dir == 1  && get<Dimension>(point) > get<1, Dimension>(box))
+            || (dir == -1 && get<Dimension>(point) < get<0, Dimension>(box));
+    }
+
+    template <typename Iterator>
+    void find_first(int dir, Iterator& begin, Iterator const end, Box const& box)
+    {
+        if (begin != end)
+        {
+            if (exceeding(dir, *begin, box))
+            {
+                // First obvious check
+                begin = end;
+                return;
+            }
+
+            iterator it = begin;
+            iterator prev = it++;
+            for(; it != end && preceding(dir, *it, box); ++it, ++prev) {}
+            begin = prev;
+        }
+    }
+
+    template <typename Iterator>
+    void find_last(int dir, Iterator& begin, Iterator& end, Box const& box)
+    {
+        if (begin != end)
+        {
+            iterator it = begin;
+            iterator prev = it++;
+            for(; it != end && ! exceeding(dir, *prev, box); ++it, ++prev) {}
+            if (it == end && prev != end && preceding(dir, *prev, box))
+            {
+                // Last obvious check (not done before to not refer to *(end-1))
+                begin = end;
+            }
+            else
+            {
+                end = it;
+            }
+        }
+    }
+
+};
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_ENVELOPED_VIEW_HPP
diff --git a/src/boost/geometry/extensions/views/section_view.hpp b/src/boost/geometry/extensions/views/section_view.hpp
new file mode 100644
index 0000000..8e0dcce
--- /dev/null
+++ b/src/boost/geometry/extensions/views/section_view.hpp
@@ -0,0 +1,73 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_SECTION_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_SECTION_VIEW_HPP
+
+// Note the addition of this whole file was committed to SVN by accident,
+// probably obsolete
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/util/add_const_if_c.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+template <typename Geometry, typename Section>
+class section_view
+{
+    typedef typename detail::range_type<Geometry>::type range_type;
+public :
+    typedef typename boost::range_iterator
+        <
+            range_type
+        >::type iterator;
+    typedef typename boost::range_iterator
+        <
+            range_type const
+        >::type const_iterator;
+
+    explicit section_view(Geometry& geometry, Section const& section)
+    {
+        get_section(geometry, section, m_begin, m_end);
+    }
+
+    const_iterator begin() const { return m_begin; }
+    const_iterator end() const { return m_end; }
+    iterator begin() { return m_begin; }
+    iterator end() { return m_end; }
+
+private :
+    // Might be replaced declaring as BOOST_AUTO
+    typedef typename boost::range_iterator
+        <
+            typename add_const_if_c
+                <
+                    boost::is_const<Geometry>::value,
+                    range_type
+                >::type
+        >::type iterator_type;
+
+    iterator_type m_begin, m_end;
+};
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_SECTION_VIEW_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_array.hpp b/src/boost/geometry/geometries/adapted/boost_array.hpp
new file mode 100644
index 0000000..275ccb5
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_array.hpp
@@ -0,0 +1,120 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010 Alfredo Correa
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
+
+
+#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED
+#error Include either "boost_array_as_point" or \
+    "boost_array_as_linestring" or "boost_array_as_ring" \
+    or "boost_array_as_multi_point" to adapt a boost_array
+#endif
+
+#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED
+
+
+#include <cstddef>
+
+#include <boost/type_traits/is_arithmetic.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/array.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+// Create class and specialization to indicate the tag
+// for normal cases and the case that the type of the c-array is arithmetic
+template <bool>
+struct boost_array_tag
+{
+    typedef geometry_not_recognized_tag type;
+};
+
+
+template <>
+struct boost_array_tag<true>
+{
+    typedef point_tag type;
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+// Assign the point-tag, preventing arrays of points getting a point-tag
+template <typename CoordinateType, std::size_t DimensionCount>
+struct tag<boost::array<CoordinateType, DimensionCount> >
+    : detail::boost_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
+
+
+template <typename CoordinateType, std::size_t DimensionCount>
+struct coordinate_type<boost::array<CoordinateType, DimensionCount> >
+{
+    typedef CoordinateType type;
+};
+
+
+template <typename CoordinateType, std::size_t DimensionCount>
+struct dimension<boost::array<CoordinateType, DimensionCount> >: boost::mpl::int_<DimensionCount> {};
+
+
+template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
+struct access<boost::array<CoordinateType, DimensionCount>, Dimension>
+{
+    static inline CoordinateType get(boost::array<CoordinateType, DimensionCount> const& a)
+    {
+        return a[Dimension];
+    }
+
+    static inline void set(boost::array<CoordinateType, DimensionCount>& a,
+        CoordinateType const& value)
+    {
+        a[Dimension] = value;
+    }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#define BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(CoordinateSystem) \
+    namespace boost { namespace geometry { namespace traits { \
+    template <class T, std::size_t N> \
+    struct coordinate_system<boost::array<T, N> > \
+    { \
+        typedef CoordinateSystem type; \
+    }; \
+    }}}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_fusion.hpp b/src/boost/geometry/geometries/adapted/boost_fusion.hpp
new file mode 100644
index 0000000..a9aba91
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_fusion.hpp
@@ -0,0 +1,172 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2011-2012 Akira Takahashi
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP
+
+
+#include <cstddef>
+
+#include <boost/fusion/include/is_sequence.hpp>
+#include <boost/fusion/include/size.hpp>
+#include <boost/fusion/include/tag_of.hpp>
+#include <boost/fusion/include/front.hpp>
+#include <boost/fusion/include/at.hpp>
+#include <boost/utility/enable_if.hpp>
+
+#include <boost/fusion/mpl.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/count_if.hpp>
+#include <boost/mpl/pop_front.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/front.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_system.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace fusion_adapt_detail
+{
+
+template <class Sequence>
+struct all_same :
+    boost::mpl::bool_<
+        boost::mpl::count_if<
+            Sequence,
+            boost::is_same<
+                typename boost::mpl::front<Sequence>::type,
+                boost::mpl::_
+            >
+        >::value == boost::mpl::size<Sequence>::value
+    >
+{};
+
+template <class Sequence>
+struct is_coordinate_size : boost::mpl::bool_<
+            boost::fusion::result_of::size<Sequence>::value == 2 ||
+            boost::fusion::result_of::size<Sequence>::value == 3> {};
+
+template<typename Sequence>
+struct is_fusion_sequence
+    : mpl::and_<boost::fusion::traits::is_sequence<Sequence>,
+                fusion_adapt_detail::is_coordinate_size<Sequence>,
+                fusion_adapt_detail::all_same<Sequence> >
+{};
+
+
+} // namespace fusion_adapt_detail
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+// Boost Fusion Sequence, 2D or 3D
+template <typename Sequence>
+struct coordinate_type
+    <
+        Sequence,
+        typename boost::enable_if
+            <
+                fusion_adapt_detail::is_fusion_sequence<Sequence>
+            >::type
+    >
+{
+    typedef typename boost::mpl::front<Sequence>::type type;
+};
+
+
+template <typename Sequence>
+struct dimension
+    <
+        Sequence,
+        typename boost::enable_if
+            <
+                fusion_adapt_detail::is_fusion_sequence<Sequence>
+            >::type
+    > : boost::mpl::size<Sequence>
+{};
+
+
+template <typename Sequence, std::size_t Dimension>
+struct access
+    <
+        Sequence,
+        Dimension,
+        typename boost::enable_if
+            <
+                fusion_adapt_detail::is_fusion_sequence<Sequence>
+            >::type
+    >
+{
+    typedef typename coordinate_type<Sequence>::type ctype;
+
+    static inline ctype get(Sequence const& point)
+    {
+        return boost::fusion::at_c<Dimension>(point);
+    }
+
+    template <class CoordinateType>
+    static inline void set(Sequence& point, CoordinateType const& value)
+    {
+        boost::fusion::at_c<Dimension>(point) = value;
+    }
+};
+
+
+template <typename Sequence>
+struct tag
+    <
+        Sequence,
+        typename boost::enable_if
+            <
+                fusion_adapt_detail::is_fusion_sequence<Sequence>
+            >::type
+    >
+{
+    typedef point_tag type;
+};
+
+
+} // namespace traits
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+// Convenience registration macro to bind a Fusion sequence to a CS
+#define BOOST_GEOMETRY_REGISTER_BOOST_FUSION_CS(CoordinateSystem) \
+    namespace boost { namespace geometry { namespace traits { \
+    template <typename Sequence> \
+    struct coordinate_system \
+               < \
+                   Sequence, \
+                   typename boost::enable_if \
+                       < \
+                           fusion_adapt_detail::is_fusion_sequence<Sequence> \
+                       >::type \
+               > \
+    { typedef CoordinateSystem type; }; \
+    }}}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon.hpp b/src/boost/geometry/geometries/adapted/boost_polygon.hpp
new file mode 100644
index 0000000..fed2362
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon.hpp
@@ -0,0 +1,18 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HPP
+
+#include <boost/geometry/geometries/adapted/boost_polygon/point.hpp>
+#include <boost/geometry/geometries/adapted/boost_polygon/box.hpp>
+#include <boost/geometry/geometries/adapted/boost_polygon/ring.hpp>
+#include <boost/geometry/geometries/adapted/boost_polygon/polygon.hpp>
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/box.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/box.hpp
new file mode 100644
index 0000000..87c3b60
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/box.hpp
@@ -0,0 +1,141 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::rectangle_data -> boost::geometry::box
+
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+template <typename CoordinateType>
+struct tag<boost::polygon::rectangle_data<CoordinateType> >
+{
+    typedef box_tag type;
+};
+
+
+template <typename CoordinateType>
+struct point_type<boost::polygon::rectangle_data<CoordinateType> >
+{
+    // Not sure what to do here. Boost.Polygon's rectangle does NOT define its
+    // point_type (but uses it...)
+    typedef boost::polygon::point_data<CoordinateType> type;
+};
+
+
+template <typename CoordinateType>
+struct indexed_access
+<
+    boost::polygon::rectangle_data<CoordinateType>,
+    min_corner, 0
+>
+{
+    typedef boost::polygon::rectangle_data<CoordinateType> box_type;
+
+    static inline CoordinateType get(box_type const& b)
+    {
+        return boost::polygon::xl(b);
+    }
+
+    static inline void set(box_type& b, CoordinateType const& value)
+    {
+        boost::polygon::xl(b, value);
+    }
+};
+
+
+template <typename CoordinateType>
+struct indexed_access
+<
+    boost::polygon::rectangle_data<CoordinateType>,
+    min_corner, 1
+>
+{
+    typedef boost::polygon::rectangle_data<CoordinateType> box_type;
+
+    static inline CoordinateType get(box_type const& b)
+    {
+        return boost::polygon::yl(b);
+    }
+
+    static inline void set(box_type& b, CoordinateType const& value)
+    {
+        boost::polygon::yl(b, value);
+    }
+};
+
+
+template <typename CoordinateType>
+struct indexed_access
+<
+    boost::polygon::rectangle_data<CoordinateType>,
+    max_corner, 0
+>
+{
+    typedef boost::polygon::rectangle_data<CoordinateType> box_type;
+
+    static inline CoordinateType get(box_type const& b)
+    {
+        return boost::polygon::xh(b);
+    }
+
+    static inline void set(box_type& b, CoordinateType const& value)
+    {
+        boost::polygon::xh(b, value);
+    }
+};
+
+
+template <typename CoordinateType>
+struct indexed_access
+<
+    boost::polygon::rectangle_data<CoordinateType>,
+    max_corner, 1
+>
+{
+    typedef boost::polygon::rectangle_data<CoordinateType> box_type;
+
+    static inline CoordinateType get(box_type const& b)
+    {
+        return boost::polygon::yh(b);
+    }
+
+    static inline void set(box_type& b, CoordinateType const& value)
+    {
+        boost::polygon::yh(b, value);
+    }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp
new file mode 100644
index 0000000..c9c1bc7
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp
@@ -0,0 +1,84 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
+//   hole_iterator  -> returning ring_proxy's instead of normal polygon_data
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace adapt { namespace bp
+{
+
+
+template <typename Polygon, typename RingProxy>
+class hole_iterator
+    : public ::boost::iterator_facade
+        <
+            hole_iterator<Polygon, RingProxy>,
+            RingProxy, // value type
+            boost::forward_traversal_tag,
+            RingProxy // reference type
+        >
+{
+public :
+    typedef typename boost::polygon::polygon_with_holes_traits
+        <
+            Polygon
+        >::iterator_holes_type ith_type;
+
+    explicit inline hole_iterator(Polygon& polygon, ith_type const it)
+        : m_polygon(polygon)
+        , m_base(it)
+    {
+    }
+
+    typedef std::ptrdiff_t difference_type;
+
+private:
+    friend class boost::iterator_core_access;
+
+    inline RingProxy dereference() const
+    {
+        return RingProxy(m_polygon, this->m_base);
+    }
+
+    inline void increment() { ++m_base; }
+    inline void decrement() { --m_base; }
+    inline void advance(difference_type n)
+    {
+        for (int i = 0; i < n; i++)
+        {
+            ++m_base;
+        }
+    }
+
+    inline bool equal(hole_iterator<Polygon, RingProxy> const& other) const
+    {
+        return this->m_base == other.m_base;
+    }
+
+    Polygon& m_polygon;
+    ith_type m_base;
+};
+
+
+}}}}
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp
new file mode 100644
index 0000000..c2a6a44
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp
@@ -0,0 +1,204 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
+//   pair{begin_holes, begin_holes} -> interior_proxy
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp>
+#include <boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace adapt { namespace bp
+{
+
+
+// Polygon should implement the boost::polygon::polygon_with_holes_concept
+// Specify constness in the template parameter if necessary
+template<typename Polygon>
+struct holes_proxy
+{
+    typedef ring_proxy
+        <
+            typename boost::mpl::if_
+                <
+                    typename boost::is_const<Polygon>,
+                    Polygon const,
+                    Polygon
+                >::type
+        > proxy_type;
+    typedef hole_iterator<Polygon, proxy_type> iterator_type;
+
+    // The next line does not work probably because coordinate_type is part of the
+    // polygon_traits, but not of the polygon_with_holes_traits
+    // typedef typename boost::polygon::polygon_traits<Polygon>::coordinate_type coordinate_type;
+
+    // So we use:
+    typedef typename Polygon::coordinate_type coordinate_type;
+
+    inline holes_proxy(Polygon& p)
+        : polygon(p)
+    {}
+
+    inline void clear()
+    {
+        Polygon empty;
+        // Clear the holes
+        polygon.set_holes
+            (
+                boost::polygon::begin_holes(empty),
+                boost::polygon::end_holes(empty)
+            );
+    }
+
+    inline void resize(std::size_t new_size)
+    {
+        std::vector<boost::polygon::polygon_data<coordinate_type> > temporary_copy
+            (
+                boost::polygon::begin_holes(polygon),
+                boost::polygon::end_holes(polygon)
+            );
+        temporary_copy.resize(new_size);
+        polygon.set_holes(temporary_copy.begin(), temporary_copy.end());
+    }
+
+    template <typename Ring>
+    inline void push_back(Ring const& ring)
+    {
+        std::vector<boost::polygon::polygon_data<coordinate_type> > temporary_copy
+            (
+                boost::polygon::begin_holes(polygon),
+                boost::polygon::end_holes(polygon)
+            );
+        boost::polygon::polygon_data<coordinate_type> added;
+        boost::polygon::set_points(added, ring.begin(), ring.end());
+        temporary_copy.push_back(added);
+        polygon.set_holes(temporary_copy.begin(), temporary_copy.end());
+    }
+
+
+    Polygon& polygon;
+};
+
+
+// Support holes_proxy for Boost.Range ADP
+
+// Const versions
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
+            range_begin(boost::geometry::adapt::bp::holes_proxy<Polygon const> const& proxy)
+{
+    typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
+            begin(proxy.polygon, boost::polygon::begin_holes(proxy.polygon));
+    return begin;
+}
+
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
+            range_end(boost::geometry::adapt::bp::holes_proxy<Polygon const> const& proxy)
+{
+    typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
+            end(proxy.polygon, boost::polygon::end_holes(proxy.polygon));
+    return end;
+}
+
+// Mutable versions
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
+            range_begin(boost::geometry::adapt::bp::holes_proxy<Polygon>& proxy)
+{
+    typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
+            begin(proxy.polygon, boost::polygon::begin_holes(proxy.polygon));
+    return begin;
+}
+
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
+            range_end(boost::geometry::adapt::bp::holes_proxy<Polygon>& proxy)
+{
+    typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
+            end(proxy.polygon, boost::polygon::end_holes(proxy.polygon));
+    return end;
+}
+
+
+}}
+
+namespace traits
+{
+
+template <typename Polygon>
+struct rvalue_type<adapt::bp::holes_proxy<Polygon> >
+{
+    typedef adapt::bp::holes_proxy<Polygon> type;
+};
+
+
+template <typename Polygon>
+struct clear<adapt::bp::holes_proxy<Polygon> >
+{
+    static inline void apply(adapt::bp::holes_proxy<Polygon> proxy)
+    {
+        proxy.clear();
+    }
+};
+
+template <typename Polygon>
+struct resize<adapt::bp::holes_proxy<Polygon> >
+{
+    static inline void apply(adapt::bp::holes_proxy<Polygon> proxy, std::size_t new_size)
+    {
+        proxy.resize(new_size);
+    }
+};
+
+template <typename Polygon>
+struct push_back<adapt::bp::holes_proxy<Polygon> >
+{
+    template <typename Ring>
+    static inline void apply(adapt::bp::holes_proxy<Polygon> proxy, Ring const& ring)
+    {
+        proxy.push_back(ring);
+    }
+};
+
+
+
+} // namespace traits
+
+
+}}
+
+
+// Specialize holes_proxy for Boost.Range
+namespace boost
+{
+    template<typename Polygon>
+    struct range_mutable_iterator<geometry::adapt::bp::holes_proxy<Polygon> >
+    {
+        typedef typename geometry::adapt::bp::holes_proxy<Polygon>::iterator_type type;
+    };
+
+    template<typename Polygon>
+    struct range_const_iterator<geometry::adapt::bp::holes_proxy<Polygon> >
+    {
+        typedef typename geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type type;
+    };
+
+} // namespace boost
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/point.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/point.hpp
new file mode 100644
index 0000000..2aabb56
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/point.hpp
@@ -0,0 +1,102 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::point_data -> boost::geometry::point
+
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+template <typename CoordinateType>
+struct tag<boost::polygon::point_data<CoordinateType> >
+{
+    typedef point_tag type;
+};
+
+
+template <typename CoordinateType>
+struct coordinate_type<boost::polygon::point_data<CoordinateType> >
+{
+    typedef CoordinateType type;
+};
+
+
+template <typename CoordinateType>
+struct coordinate_system<boost::polygon::point_data<CoordinateType> >
+{
+    typedef cs::cartesian type;
+};
+
+
+template <typename CoordinateType>
+struct dimension<boost::polygon::point_data<CoordinateType> >
+            : boost::mpl::int_<2>
+{};
+
+
+template <typename CoordinateType>
+struct access<boost::polygon::point_data<CoordinateType>, 0>
+{
+    typedef boost::polygon::point_data<CoordinateType> point_type;
+
+    static inline CoordinateType get(point_type const& p)
+    {
+        return p.x();
+    }
+
+    static inline void set(point_type& p, CoordinateType const& value)
+    {
+        p.x(value);
+    }
+};
+
+
+template <typename CoordinateType>
+struct access<boost::polygon::point_data<CoordinateType>, 1>
+{
+    typedef boost::polygon::point_data<CoordinateType> point_type;
+
+    static inline CoordinateType get(point_type const& p)
+    {
+        return p.y();
+    }
+
+    static inline void set(point_type& p, CoordinateType const& value)
+    {
+        p.y(value);
+    }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/polygon.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/polygon.hpp
new file mode 100644
index 0000000..5703601
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/polygon.hpp
@@ -0,0 +1,111 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+
+#include <boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp>
+#include <boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp>
+#include <boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename CoordinateType>
+struct tag<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef polygon_tag type;
+};
+
+template <typename CoordinateType>
+struct ring_const_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef adapt::bp::ring_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> const> type;
+};
+
+template <typename CoordinateType>
+struct ring_mutable_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef adapt::bp::ring_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> > type;
+};
+
+template <typename CoordinateType>
+struct interior_const_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef adapt::bp::holes_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> const> type;
+};
+
+template <typename CoordinateType>
+struct interior_mutable_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef adapt::bp::holes_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> > type;
+};
+
+
+template <typename CoordinateType>
+struct exterior_ring<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef boost::polygon::polygon_with_holes_data<CoordinateType> polygon_type;
+    typedef adapt::bp::ring_proxy<polygon_type> proxy;
+    typedef adapt::bp::ring_proxy<polygon_type const> const_proxy;
+
+    static inline proxy get(polygon_type& p)
+    {
+        return proxy(p);
+    }
+
+    static inline const_proxy get(polygon_type const& p)
+    {
+        return const_proxy(p);
+    }
+};
+
+template <typename CoordinateType>
+struct interior_rings<boost::polygon::polygon_with_holes_data<CoordinateType> >
+{
+    typedef boost::polygon::polygon_with_holes_data<CoordinateType> polygon_type;
+    typedef adapt::bp::holes_proxy<polygon_type> proxy;
+    typedef adapt::bp::holes_proxy<polygon_type const> const_proxy;
+
+    static inline proxy get(polygon_type& p)
+    {
+        return proxy(p);
+    }
+
+    static inline const_proxy get(polygon_type const& p)
+    {
+        return const_proxy(p);
+    }
+};
+
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/ring.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/ring.hpp
new file mode 100644
index 0000000..93b21fe
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/ring.hpp
@@ -0,0 +1,163 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::polygon_data -> boost::geometry::ring
+
+#include <cstddef>
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template <typename CoordinateType>
+struct tag<boost::polygon::polygon_data<CoordinateType> >
+{
+    typedef ring_tag type;
+};
+
+template <typename CoordinateType>
+struct clear<boost::polygon::polygon_data<CoordinateType> >
+{
+    static inline void apply(boost::polygon::polygon_data<CoordinateType>& data)
+    {
+        // There is no "clear" function but we can assign
+        // a newly (and therefore empty) constructed polygon
+        boost::polygon::assign(data, boost::polygon::polygon_data<CoordinateType>());
+    }
+};
+
+template <typename CoordinateType>
+struct push_back<boost::polygon::polygon_data<CoordinateType> >
+{
+    typedef boost::polygon::point_data<CoordinateType> point_type;
+
+    static inline void apply(boost::polygon::polygon_data<CoordinateType>& data,
+         point_type const& point)
+    {
+        // Boost.Polygon's polygons are not appendable. So create a temporary vector,
+        // add a record and set it to the original. Of course: this is not efficient.
+        // But there seems no other way (without using a wrapper)
+        std::vector<point_type> temporary_vector
+            (
+                boost::polygon::begin_points(data),
+                boost::polygon::end_points(data)
+            );
+        temporary_vector.push_back(point);
+        data.set(temporary_vector.begin(), temporary_vector.end());
+    }
+};
+
+
+
+
+} // namespace traits
+
+}} // namespace boost::geometry
+
+
+// Adapt Boost.Polygon's polygon_data to Boost.Range
+// This just translates to
+// polygon_data.begin() and polygon_data.end()
+namespace boost
+{
+    template<typename CoordinateType>
+    struct range_mutable_iterator<boost::polygon::polygon_data<CoordinateType> >
+    {
+        typedef typename boost::polygon::polygon_traits
+            <
+                boost::polygon::polygon_data<CoordinateType>
+            >::iterator_type type;
+    };
+
+    template<typename CoordinateType>
+    struct range_const_iterator<boost::polygon::polygon_data<CoordinateType> >
+    {
+        typedef typename boost::polygon::polygon_traits
+            <
+                boost::polygon::polygon_data<CoordinateType>
+            >::iterator_type type;
+    };
+
+    template<typename CoordinateType>
+    struct range_size<boost::polygon::polygon_data<CoordinateType> >
+    {
+        typedef std::size_t type;
+    };
+
+} // namespace boost
+
+
+// Support Boost.Polygon's polygon_data for Boost.Range ADP
+namespace boost { namespace polygon
+{
+
+template<typename CoordinateType>
+inline typename polygon_traits
+        <
+            polygon_data<CoordinateType>
+        >::iterator_type range_begin(polygon_data<CoordinateType>& polygon)
+{
+    return polygon.begin();
+}
+
+template<typename CoordinateType>
+inline typename polygon_traits
+        <
+            polygon_data<CoordinateType>
+        >::iterator_type range_begin(polygon_data<CoordinateType> const& polygon)
+{
+    return polygon.begin();
+}
+
+template<typename CoordinateType>
+inline typename polygon_traits
+        <
+            polygon_data<CoordinateType>
+        >::iterator_type range_end(polygon_data<CoordinateType>& polygon)
+{
+    return polygon.end();
+}
+
+template<typename CoordinateType>
+inline typename polygon_traits
+        <
+            polygon_data<CoordinateType>
+        >::iterator_type range_end(polygon_data<CoordinateType> const& polygon)
+{
+    return polygon.end();
+}
+
+template<typename CoordinateType>
+inline std::size_t range_calculate_size(polygon_data<CoordinateType> const& polygon)
+{
+    return polygon.size();
+}
+
+}}
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp b/src/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp
new file mode 100644
index 0000000..825ef80
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp
@@ -0,0 +1,301 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
+//   pair{begin_points, end_points} -> ring_proxy
+
+#include <boost/polygon/polygon.hpp>
+#include <boost/range.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace adapt { namespace bp
+{
+
+namespace detail
+{
+
+template <bool Mutable>
+struct modify
+{};
+
+template <>
+struct modify<true>
+{
+    template <typename Ring, typename Point>
+    static inline void push_back(Ring& ring, Point const& point)
+    {
+        // Boost.Polygon's polygons are not appendable. So create a temporary vector,
+        // add a record and set it to the original. Of course: this is not efficient.
+        // But there seems no other way (without using a wrapper)
+        std::vector<Point> temporary_vector
+            (
+                boost::polygon::begin_points(ring),
+                boost::polygon::end_points(ring)
+            );
+        temporary_vector.push_back(point);
+        boost::polygon::set_points(ring, temporary_vector.begin(), temporary_vector.end());
+    }
+
+};
+
+template <>
+struct modify<false>
+{
+    template <typename Ring, typename Point>
+    static inline void push_back(Ring& ring, Point const& point)
+    {
+    }
+
+};
+
+
+}
+
+
+// Polygon should implement the boost::polygon::polygon_with_holes_concept
+// Specify constness in the template parameter if necessary
+template<typename Polygon>
+class ring_proxy
+{
+public :
+    typedef typename boost::polygon::polygon_traits
+        <
+            typename boost::remove_const<Polygon>::type
+        >::iterator_type iterator_type;
+
+    typedef typename boost::polygon::polygon_with_holes_traits
+        <
+            typename boost::remove_const<Polygon>::type
+        >::iterator_holes_type hole_iterator_type;
+
+    static const bool is_mutable = !boost::is_const<Polygon>::type::value;
+
+    inline ring_proxy(Polygon& p)
+        : m_polygon_pointer(&p)
+        , m_do_hole(false)
+    {}
+
+    // Constructor used from hole_iterator
+    inline ring_proxy(Polygon& p, hole_iterator_type hole_it)
+        : m_polygon_pointer(&p)
+        , m_do_hole(true)
+        , m_hole_it(hole_it)
+    {}
+
+    // Default constructor, for mutable polygons / appending (interior) rings
+    inline ring_proxy()
+        : m_polygon_pointer(&m_polygon_for_default_constructor)
+        , m_do_hole(false)
+    {}
+
+
+    iterator_type begin() const
+    {
+        return m_do_hole
+            ? boost::polygon::begin_points(*m_hole_it)
+            : boost::polygon::begin_points(*m_polygon_pointer)
+            ;
+    }
+
+    iterator_type begin()
+    {
+        return m_do_hole
+            ? boost::polygon::begin_points(*m_hole_it)
+            : boost::polygon::begin_points(*m_polygon_pointer)
+            ;
+    }
+
+    iterator_type end() const
+    {
+        return m_do_hole
+            ? boost::polygon::end_points(*m_hole_it)
+            : boost::polygon::end_points(*m_polygon_pointer)
+            ;
+    }
+
+    iterator_type end()
+    {
+        return m_do_hole
+            ? boost::polygon::end_points(*m_hole_it)
+            : boost::polygon::end_points(*m_polygon_pointer)
+            ;
+    }
+
+    // Mutable
+    void clear()
+    {
+        Polygon p;
+        if (m_do_hole)
+        {
+            // Does NOT work see comment above
+        }
+        else
+        {
+            boost::polygon::set_points(*m_polygon_pointer,
+                boost::polygon::begin_points(p),
+                boost::polygon::end_points(p));
+        }
+    }
+
+    void resize(std::size_t new_size)
+    {
+        if (m_do_hole)
+        {
+            // Does NOT work see comment above
+        }
+        else
+        {
+            // TODO: implement this by resizing the container
+        }
+    }
+
+
+
+    template <typename Point>
+    void push_back(Point const& point)
+    {
+        if (m_do_hole)
+        {
+            //detail::modify<is_mutable>::push_back(*m_hole_it, point);
+            //std::cout << "HOLE: " << typeid(*m_hole_it).name() << std::endl;
+            //std::cout << "HOLE: " << typeid(m_hole_it).name() << std::endl;
+            //std::cout << "HOLE: " << typeid(hole_iterator_type).name() << std::endl;
+
+            // Note, ths does NOT work because hole_iterator_type is defined
+            // as a const_iterator by Boost.Polygon
+
+        }
+        else
+        {
+            detail::modify<is_mutable>::push_back(*m_polygon_pointer, point);
+        }
+    }
+
+private :
+    Polygon* m_polygon_pointer;
+    bool m_do_hole;
+    hole_iterator_type m_hole_it;
+
+    Polygon m_polygon_for_default_constructor;
+};
+
+
+
+
+// Support geometry::adapt::bp::ring_proxy for Boost.Range ADP
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::ring_proxy<Polygon>::iterator_type
+            range_begin(boost::geometry::adapt::bp::ring_proxy<Polygon>& proxy)
+{
+    return proxy.begin();
+}
+
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::ring_proxy<Polygon const>::iterator_type
+            range_begin(boost::geometry::adapt::bp::ring_proxy<Polygon const> const& proxy)
+{
+    return proxy.begin();
+}
+
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::ring_proxy<Polygon>::iterator_type
+            range_end(boost::geometry::adapt::bp::ring_proxy<Polygon>& proxy)
+{
+    return proxy.end();
+}
+
+template<typename Polygon>
+inline typename boost::geometry::adapt::bp::ring_proxy<Polygon const>::iterator_type
+            range_end(boost::geometry::adapt::bp::ring_proxy<Polygon const> const& proxy)
+{
+    return proxy.end();
+}
+
+
+
+
+}} // namespace adapt::bp
+
+
+namespace traits
+{
+
+template <typename Polygon>
+struct tag<adapt::bp::ring_proxy<Polygon> >
+{
+    typedef ring_tag type;
+};
+
+
+template <typename Polygon>
+struct rvalue_type<adapt::bp::ring_proxy<Polygon> >
+{
+    typedef adapt::bp::ring_proxy<Polygon> type;
+};
+
+template <typename Polygon>
+struct clear<adapt::bp::ring_proxy<Polygon> >
+{
+    static inline void apply(adapt::bp::ring_proxy<Polygon> proxy)
+    {
+        proxy.clear();
+    }
+};
+
+
+template <typename Polygon>
+struct resize<adapt::bp::ring_proxy<Polygon> >
+{
+    static inline void apply(adapt::bp::ring_proxy<Polygon> proxy, std::size_t new_size)
+    {
+        proxy.resize(new_size);
+    }
+};
+
+template <typename Polygon>
+struct push_back<adapt::bp::ring_proxy<Polygon> >
+{
+    static inline void apply(adapt::bp::ring_proxy<Polygon> proxy,
+        typename boost::polygon::polygon_traits<Polygon>::point_type const& point)
+    {
+        proxy.push_back(point);
+    }
+};
+
+
+} // namespace traits
+
+}} // namespace boost::geometry
+
+// Specialize ring_proxy for Boost.Range
+namespace boost
+{
+    template<typename Polygon>
+    struct range_mutable_iterator<geometry::adapt::bp::ring_proxy<Polygon> >
+    {
+        typedef typename geometry::adapt::bp::ring_proxy<Polygon>::iterator_type type;
+    };
+
+    template<typename Polygon>
+    struct range_const_iterator<geometry::adapt::bp::ring_proxy<Polygon> >
+    {
+        typedef typename geometry::adapt::bp::ring_proxy<Polygon const>::iterator_type type;
+    };
+
+} // namespace boost
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP
diff --git a/src/boost/geometry/geometries/adapted/boost_range/adjacent_filtered.hpp b/src/boost/geometry/geometries/adapted/boost_range/adjacent_filtered.hpp
new file mode 100644
index 0000000..496dbea
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_range/adjacent_filtered.hpp
@@ -0,0 +1,40 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP
+
+
+#include <boost/range/adaptor/adjacent_filtered.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template<typename Filter, typename Geometry, bool DefaultPass>
+#if BOOST_VERSION > 104500
+struct tag<boost::adjacent_filtered_range<Filter, Geometry, DefaultPass> >
+#else
+struct tag<boost::range_detail::adjacent_filter_range<Filter, Geometry, DefaultPass> >
+#endif
+{
+    typedef typename geometry::tag<Geometry>::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_range/filtered.hpp b/src/boost/geometry/geometries/adapted/boost_range/filtered.hpp
new file mode 100644
index 0000000..990d608
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_range/filtered.hpp
@@ -0,0 +1,40 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP
+
+
+#include <boost/range/adaptor/filtered.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template<typename Filter, typename Geometry>
+#if BOOST_VERSION > 104500
+struct tag<boost::filtered_range<Filter, Geometry> >
+#else
+struct tag<boost::range_detail::filter_range<Filter, Geometry> >
+#endif
+{
+    typedef typename geometry::tag<Geometry>::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_range/reversed.hpp b/src/boost/geometry/geometries/adapted/boost_range/reversed.hpp
new file mode 100644
index 0000000..3c8601f
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_range/reversed.hpp
@@ -0,0 +1,40 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP
+
+
+#include <boost/range/adaptor/reversed.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template<typename Geometry>
+#if BOOST_VERSION > 104500
+struct tag<boost::reversed_range<Geometry> >
+#else
+struct tag<boost::range_detail::reverse_range<Geometry> >
+#endif
+{
+    typedef typename geometry::tag<Geometry>::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_range/sliced.hpp b/src/boost/geometry/geometries/adapted/boost_range/sliced.hpp
new file mode 100644
index 0000000..7018981
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_range/sliced.hpp
@@ -0,0 +1,36 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP
+
+
+#include <boost/range/adaptor/sliced.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template<typename Geometry>
+struct tag<boost::adaptors::sliced_range<Geometry> >
+{
+    typedef typename geometry::tag<Geometry>::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_range/strided.hpp b/src/boost/geometry/geometries/adapted/boost_range/strided.hpp
new file mode 100644
index 0000000..5c9cdd6
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_range/strided.hpp
@@ -0,0 +1,36 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP
+
+
+#include <boost/range/adaptor/strided.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template<typename Geometry>
+struct tag<boost::strided_range<Geometry> >
+{
+    typedef typename geometry::tag<Geometry>::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_range/uniqued.hpp b/src/boost/geometry/geometries/adapted/boost_range/uniqued.hpp
new file mode 100644
index 0000000..beb51fe
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_range/uniqued.hpp
@@ -0,0 +1,40 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP
+
+
+#include <boost/range/adaptor/uniqued.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template<typename Geometry>
+#if BOOST_VERSION > 104500
+struct tag<boost::uniqued_range<Geometry> >
+#else
+struct tag<boost::range_detail::unique_range<Geometry> >
+#endif
+{
+    typedef typename geometry::tag<Geometry>::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP
+
diff --git a/src/boost/geometry/geometries/adapted/boost_tuple.hpp b/src/boost/geometry/geometries/adapted/boost_tuple.hpp
new file mode 100644
index 0000000..58065fe
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/boost_tuple.hpp
@@ -0,0 +1,109 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_TUPLE_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_TUPLE_HPP
+
+
+#include <cstddef>
+
+#include <boost/tuple/tuple.hpp>
+
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8, typename T9, typename T10>
+struct tag<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
+{
+    typedef point_tag type;
+};
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8, typename T9, typename T10>
+struct coordinate_type<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
+{
+    typedef T1 type;
+};
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8, typename T9, typename T10>
+struct dimension<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
+    : boost::mpl::int_
+          <
+              boost::tuples::length
+                  <
+                      boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
+                  >::value
+          >
+{};
+
+
+template <typename T1, typename T2, typename T3, typename T4, typename T5,
+          typename T6, typename T7, typename T8, typename T9, typename T10,
+          std::size_t Dimension>
+struct access
+    <
+        boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>,
+        Dimension
+    >
+{
+    static inline T1 get(
+        boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> const& point)
+    {
+        return point.template get<Dimension>();
+    }
+
+    static inline void set(
+        boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& point,
+        T1 const& value)
+    {
+        point.template get<Dimension>() = value;
+    }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+// Convenience registration macro to bind boost::tuple to a CS
+#define BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(CoordinateSystem) \
+    namespace boost { namespace geometry { namespace traits { \
+    template <typename T1, typename T2, typename T3, typename T4, typename T5, \
+              typename T6, typename T7, typename T8, typename T9, typename T10> \
+    struct coordinate_system<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > \
+    { \
+        typedef CoordinateSystem type; \
+    }; \
+    }}}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP
diff --git a/src/boost/geometry/geometries/adapted/c_array.hpp b/src/boost/geometry/geometries/adapted/c_array.hpp
new file mode 100644
index 0000000..1b4523d
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/c_array.hpp
@@ -0,0 +1,111 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
+
+#include <cstddef>
+
+#include <boost/type_traits/is_arithmetic.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+// Create class and specialization to indicate the tag
+// for normal cases and the case that the type of the c-array is arithmetic
+template <bool>
+struct c_array_tag
+{
+    typedef geometry_not_recognized_tag type;
+};
+
+
+template <>
+struct c_array_tag<true>
+{
+    typedef point_tag type;
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+// Assign the point-tag, preventing arrays of points getting a point-tag
+template <typename CoordinateType, std::size_t DimensionCount>
+struct tag<CoordinateType[DimensionCount]>
+    : detail::c_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
+
+
+template <typename CoordinateType, std::size_t DimensionCount>
+struct coordinate_type<CoordinateType[DimensionCount]>
+{
+    typedef CoordinateType type;
+};
+
+
+template <typename CoordinateType, std::size_t DimensionCount>
+struct dimension<CoordinateType[DimensionCount]>: boost::mpl::int_<DimensionCount> {};
+
+
+template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
+struct access<CoordinateType[DimensionCount], Dimension>
+{
+    static inline CoordinateType get(CoordinateType const p[DimensionCount])
+    {
+        return p[Dimension];
+    }
+
+    static inline void set(CoordinateType p[DimensionCount],
+        CoordinateType const& value)
+    {
+        p[Dimension] = value;
+    }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#define BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(CoordinateSystem) \
+    namespace boost { namespace geometry { namespace traits { \
+    template <typename T, std::size_t N> \
+    struct coordinate_system<T[N]> \
+    { \
+        typedef CoordinateSystem type; \
+    }; \
+    }}}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
diff --git a/src/boost/geometry/geometries/adapted/std_pair_as_segment.hpp b/src/boost/geometry/geometries/adapted/std_pair_as_segment.hpp
new file mode 100644
index 0000000..e9200e0
--- /dev/null
+++ b/src/boost/geometry/geometries/adapted/std_pair_as_segment.hpp
@@ -0,0 +1,98 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
+
+// Only possible if the std::pair is not used for iterator/pair
+// (maybe it is possible to avoid that by detecting in the other file
+//  if an iterator was used in the pair)
+
+#ifdef BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED
+#error Include only one headerfile to register tag for adapted std:: containers or iterator pair
+#endif
+
+#define BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED
+
+
+#include <cstddef>
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+template <typename Point>
+struct tag<std::pair<Point, Point> >
+{
+    typedef segment_tag type;
+};
+
+template <typename Point>
+struct point_type<std::pair<Point, Point> >
+{
+    typedef Point type;
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<std::pair<Point, Point>, 0, Dimension>
+{
+    typedef typename geometry::coordinate_type<Point>::type coordinate_type;
+
+    static inline coordinate_type get(std::pair<Point, Point> const& s)
+    {
+        return geometry::get<Dimension>(s.first);
+    }
+
+    static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(s.first, value);
+    }
+};
+
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<std::pair<Point, Point>, 1, Dimension>
+{
+    typedef typename geometry::coordinate_type<Point>::type coordinate_type;
+
+    static inline coordinate_type get(std::pair<Point, Point> const& s)
+    {
+        return geometry::get<Dimension>(s.second);
+    }
+
+    static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(s.second, value);
+    }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
diff --git a/src/boost/geometry/geometries/box.hpp b/src/boost/geometry/geometries/box.hpp
new file mode 100644
index 0000000..a2e3d4f
--- /dev/null
+++ b/src/boost/geometry/geometries/box.hpp
@@ -0,0 +1,134 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_BOX_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_BOX_HPP
+
+#include <cstddef>
+
+#include <boost/concept/assert.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+
+/*!
+    \brief Class box: defines a box made of two describing points
+    \ingroup geometries
+    \details Box is always described by a min_corner() and a max_corner() point. If another
+        rectangle is used, use linear_ring or polygon.
+    \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms
+    are implemented for box. Boxes are also used in Spatial Indexes.
+    \tparam Point point type. The box takes a point type as template parameter.
+    The point type can be any point type.
+    It can be 2D but can also be 3D or more dimensional.
+    The box can also take a latlong point type as template parameter.
+ */
+
+template<typename Point>
+class box
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+public:
+
+    inline box() {}
+
+    /*!
+        \brief Constructor taking the minimum corner point and the maximum corner point
+    */
+    inline box(Point const& min_corner, Point const& max_corner)
+    {
+        geometry::convert(min_corner, m_min_corner);
+        geometry::convert(max_corner, m_max_corner);
+    }
+
+    inline Point const& min_corner() const { return m_min_corner; }
+    inline Point const& max_corner() const { return m_max_corner; }
+
+    inline Point& min_corner() { return m_min_corner; }
+    inline Point& max_corner() { return m_max_corner; }
+
+private:
+
+    Point m_min_corner;
+    Point m_max_corner;
+};
+
+
+} // namespace model
+
+
+// Traits specializations for box above
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename Point>
+struct tag<model::box<Point> >
+{
+    typedef box_tag type;
+};
+
+template <typename Point>
+struct point_type<model::box<Point> >
+{
+    typedef Point type;
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<model::box<Point>, min_corner, Dimension>
+{
+    typedef typename geometry::coordinate_type<Point>::type coordinate_type;
+
+    static inline coordinate_type get(model::box<Point> const& b)
+    {
+        return geometry::get<Dimension>(b.min_corner());
+    }
+
+    static inline void set(model::box<Point>& b, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(b.min_corner(), value);
+    }
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<model::box<Point>, max_corner, Dimension>
+{
+    typedef typename geometry::coordinate_type<Point>::type coordinate_type;
+
+    static inline coordinate_type get(model::box<Point> const& b)
+    {
+        return geometry::get<Dimension>(b.max_corner());
+    }
+
+    static inline void set(model::box<Point>& b, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(b.max_corner(), value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_BOX_HPP
diff --git a/src/boost/geometry/geometries/concepts/box_concept.hpp b/src/boost/geometry/geometries/concepts/box_concept.hpp
new file mode 100644
index 0000000..ea0d84c
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/box_concept.hpp
@@ -0,0 +1,136 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
+
+
+#include <cstddef>
+
+#include <boost/concept_check.hpp>
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief Box concept
+\ingroup concepts
+\par Formal definition:
+The box concept is defined as following:
+- there must be a specialization of traits::tag defining box_tag as type
+- there must be a specialization of traits::point_type to define the
+  underlying point type (even if it does not consist of points, it should define
+  this type, to indicate the points it can work with)
+- there must be a specialization of traits::indexed_access, per index
+  (min_corner, max_corner) and per dimension, with two functions:
+  - get to get a coordinate value
+  - set to set a coordinate value (this one is not checked for ConstBox)
+*/
+template <typename Geometry>
+class Box
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+
+
+    template
+    <
+        std::size_t Index,
+        std::size_t Dimension,
+        std::size_t DimensionCount
+    >
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            Geometry* b = 0;
+            geometry::set<Index, Dimension>(*b, geometry::get<Index, Dimension>(*b));
+            dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
+        }
+    };
+
+    template <std::size_t Index, std::size_t DimensionCount>
+    struct dimension_checker<Index, DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(Box)
+    {
+        static const std::size_t n = dimension<Geometry>::type::value;
+        dimension_checker<min_corner, 0, n>::apply();
+        dimension_checker<max_corner, 0, n>::apply();
+    }
+#endif
+};
+
+
+/*!
+\brief Box concept (const version)
+\ingroup const_concepts
+\details The ConstBox concept apply the same as the Box concept,
+but does not apply write access.
+*/
+template <typename Geometry>
+class ConstBox
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename coordinate_type<Geometry>::type coordinate_type;
+
+    template
+    <
+        std::size_t Index,
+        std::size_t Dimension,
+        std::size_t DimensionCount
+    >
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            const Geometry* b = 0;
+            coordinate_type coord(geometry::get<Index, Dimension>(*b));
+            boost::ignore_unused_variable_warning(coord);
+            dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
+        }
+    };
+
+    template <std::size_t Index, std::size_t DimensionCount>
+    struct dimension_checker<Index, DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(ConstBox)
+    {
+        static const std::size_t n = dimension<Geometry>::type::value;
+        dimension_checker<min_corner, 0, n>::apply();
+        dimension_checker<max_corner, 0, n>::apply();
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
diff --git a/src/boost/geometry/geometries/concepts/check.hpp b/src/boost/geometry/geometries/concepts/check.hpp
new file mode 100644
index 0000000..f8001f0
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/check.hpp
@@ -0,0 +1,171 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/concept/requires.hpp>
+
+#include <boost/type_traits/is_const.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+
+#include <boost/geometry/geometries/concepts/box_concept.hpp>
+#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/geometries/concepts/polygon_concept.hpp>
+#include <boost/geometry/geometries/concepts/ring_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace concept_check
+{
+
+template <typename Concept>
+class check
+{
+    BOOST_CONCEPT_ASSERT((Concept ));
+};
+
+}} // namespace detail::concept_check
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename GeometryTag, typename Geometry, bool IsConst>
+struct check
+{};
+
+
+template <typename Geometry>
+struct check<point_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstPoint<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<point_tag, Geometry, false>
+    : detail::concept_check::check<concept::Point<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<linestring_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstLinestring<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<linestring_tag, Geometry, false>
+    : detail::concept_check::check<concept::Linestring<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<polygon_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstPolygon<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<polygon_tag, Geometry, false>
+    : detail::concept_check::check<concept::Polygon<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<box_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstBox<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<box_tag, Geometry, false>
+    : detail::concept_check::check<concept::Box<Geometry> >
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+
+
+namespace concept
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template <typename Geometry, bool IsConst>
+struct checker : dispatch::check
+    <
+        typename tag<Geometry>::type,
+        Geometry,
+        IsConst
+    >
+{};
+
+
+}
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+    \brief Checks, in compile-time, the concept of any geometry
+    \ingroup concepts
+*/
+template <typename Geometry>
+inline void check()
+{
+    detail::checker<Geometry, boost::is_const<Geometry>::type::value> c;
+    boost::ignore_unused_variable_warning(c);
+}
+
+
+/*!
+    \brief Checks, in compile-time, the concept of two geometries, and if they
+        have equal dimensions
+    \ingroup concepts
+*/
+template <typename Geometry1, typename Geometry2>
+inline void check_concepts_and_equal_dimensions()
+{
+    check<Geometry1>();
+    check<Geometry2>();
+    assert_dimension_equal<Geometry1, Geometry2>();
+}
+
+
+} // namespace concept
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP
diff --git a/src/boost/geometry/geometries/concepts/linestring_concept.hpp b/src/boost/geometry/geometries/concepts/linestring_concept.hpp
new file mode 100644
index 0000000..091336f
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/linestring_concept.hpp
@@ -0,0 +1,125 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief Linestring concept
+\ingroup concepts
+\par Formal definition:
+The linestring concept is defined as following:
+- there must be a specialization of traits::tag defining linestring_tag as type
+- it must behave like a Boost.Range
+- it must implement a std::back_insert_iterator
+    - either by implementing push_back
+    - or by specializing std::back_insert_iterator
+
+\note to fulfill the concepts, no traits class has to be specialized to
+define the point type.
+
+\par Example:
+
+A custom linestring, defining the necessary specializations to fulfill to the concept.
+
+Suppose that the following linestring is defined:
+\dontinclude doxygen_5.cpp
+\skip custom_linestring1
+\until };
+
+It can then be adapted to the concept as following:
+\dontinclude doxygen_5.cpp
+\skip adapt custom_linestring1
+\until }}
+
+\note
+- There is also the registration macro BOOST_GEOMETRY_REGISTER_LINESTRING
+- For registration of std::vector<P> (and deque, and list) it is enough to
+include the header-file geometries/adapted/std_as_linestring.hpp. That registers
+a vector as a linestring (so it cannot be registered as a linear ring then,
+in the same source code).
+
+
+*/
+
+template <typename Geometry>
+class Linestring
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+public :
+
+    BOOST_CONCEPT_USAGE(Linestring)
+    {
+        Geometry* ls = 0;
+        traits::clear<Geometry>::apply(*ls);
+        traits::resize<Geometry>::apply(*ls, 0);
+        point_type* point = 0;
+        traits::push_back<Geometry>::apply(*ls, *point);
+    }
+#endif
+};
+
+
+/*!
+\brief Linestring concept (const version)
+\ingroup const_concepts
+\details The ConstLinestring concept check the same as the Linestring concept,
+but does not check write access.
+*/
+template <typename Geometry>
+class ConstLinestring
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+    //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+    // Relaxed the concept.
+    BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstLinestring)
+    {
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
diff --git a/src/boost/geometry/geometries/concepts/point_concept.hpp b/src/boost/geometry/geometries/concepts/point_concept.hpp
new file mode 100644
index 0000000..1e1b31e
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/point_concept.hpp
@@ -0,0 +1,176 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
+
+#include <cstddef>
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_system.hpp>
+
+
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+/*!
+\brief Point concept.
+\ingroup concepts
+
+\par Formal definition:
+The point concept is defined as following:
+- there must be a specialization of traits::tag defining point_tag as type
+- there must be a specialization of traits::coordinate_type defining the type
+  of its coordinates
+- there must be a specialization of traits::coordinate_system defining its
+  coordinate system (cartesian, spherical, etc)
+- there must be a specialization of traits::dimension defining its number
+  of dimensions (2, 3, ...) (derive it conveniently
+  from boost::mpl::int_<X> for X-D)
+- there must be a specialization of traits::access, per dimension,
+  with two functions:
+  - \b get to get a coordinate value
+  - \b set to set a coordinate value (this one is not checked for ConstPoint)
+
+\par Example:
+
+A legacy point, defining the necessary specializations to fulfil to the concept.
+
+Suppose that the following point is defined:
+\dontinclude doxygen_5.cpp
+\skip legacy_point1
+\until };
+
+It can then be adapted to the concept as following:
+\dontinclude doxygen_5.cpp
+\skip adapt legacy_point1
+\until }}
+
+Note that it is done like above to show the system. Users will normally use the registration macro.
+
+\par Example:
+
+A read-only legacy point, using a macro to fulfil to the ConstPoint concept.
+It cannot be modified by the library but can be used in all algorithms where
+points are not modified.
+
+The point looks like the following:
+
+\dontinclude doxygen_5.cpp
+\skip legacy_point2
+\until };
+
+It uses the macro as following:
+\dontinclude doxygen_5.cpp
+\skip adapt legacy_point2
+\until end adaptation
+
+*/
+
+template <typename Geometry>
+class Point
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    typedef typename coordinate_type<Geometry>::type ctype;
+    typedef typename coordinate_system<Geometry>::type csystem;
+
+    enum { ccount = dimension<Geometry>::value };
+
+
+    template <typename P, std::size_t Dimension, std::size_t DimensionCount>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            P* p = 0;
+            geometry::set<Dimension>(*p, geometry::get<Dimension>(*p));
+            dimension_checker<P, Dimension+1, DimensionCount>::apply();
+        }
+    };
+
+
+    template <typename P, std::size_t DimensionCount>
+    struct dimension_checker<P, DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public:
+
+    /// BCCL macro to apply the Point concept
+    BOOST_CONCEPT_USAGE(Point)
+    {
+        dimension_checker<Geometry, 0, ccount>::apply();
+    }
+#endif
+};
+
+
+/*!
+\brief point concept (const version).
+
+\ingroup const_concepts
+
+\details The ConstPoint concept apply the same as the Point concept,
+but does not apply write access.
+
+*/
+template <typename Geometry>
+class ConstPoint
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    typedef typename coordinate_type<Geometry>::type ctype;
+    typedef typename coordinate_system<Geometry>::type csystem;
+
+    enum { ccount = dimension<Geometry>::value };
+
+
+    template <typename P, std::size_t Dimension, std::size_t DimensionCount>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            const P* p = 0;
+            ctype coord(geometry::get<Dimension>(*p));
+            boost::ignore_unused_variable_warning(coord);
+            dimension_checker<P, Dimension+1, DimensionCount>::apply();
+        }
+    };
+
+
+    template <typename P, std::size_t DimensionCount>
+    struct dimension_checker<P, DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public:
+
+    /// BCCL macro to apply the ConstPoint concept
+    BOOST_CONCEPT_USAGE(ConstPoint)
+    {
+        dimension_checker<Geometry, 0, ccount>::apply();
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
diff --git a/src/boost/geometry/geometries/concepts/polygon_concept.hpp b/src/boost/geometry/geometries/concepts/polygon_concept.hpp
new file mode 100644
index 0000000..b478a22
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/polygon_concept.hpp
@@ -0,0 +1,135 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
+
+#include <boost/concept_check.hpp>
+#include <boost/range/concepts.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/geometries/concepts/ring_concept.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+/*!
+\brief Checks polygon concept
+\ingroup concepts
+*/
+template <typename PolygonType>
+class Polygon
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::remove_const<PolygonType>::type polygon_type;
+
+    typedef typename traits::ring_const_type<polygon_type>::type ring_const_type;
+    typedef typename traits::ring_mutable_type<polygon_type>::type ring_mutable_type;
+    typedef typename traits::interior_const_type<polygon_type>::type interior_const_type;
+    typedef typename traits::interior_mutable_type<polygon_type>::type interior_mutable_type;
+
+    typedef typename point_type<PolygonType>::type point_type;
+    typedef typename ring_type<PolygonType>::type ring_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+    BOOST_CONCEPT_ASSERT( (concept::Ring<ring_type>) );
+
+    //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
+
+    struct checker
+    {
+        static inline void apply()
+        {
+            polygon_type* poly = 0;
+            polygon_type const* cpoly = poly;
+
+            ring_mutable_type e = traits::exterior_ring<PolygonType>::get(*poly);
+            interior_mutable_type i = traits::interior_rings<PolygonType>::get(*poly);
+            ring_const_type ce = traits::exterior_ring<PolygonType>::get(*cpoly);
+            interior_const_type ci = traits::interior_rings<PolygonType>::get(*cpoly);
+
+            boost::ignore_unused_variable_warning(e);
+            boost::ignore_unused_variable_warning(i);
+            boost::ignore_unused_variable_warning(ce);
+            boost::ignore_unused_variable_warning(ci);
+            boost::ignore_unused_variable_warning(poly);
+            boost::ignore_unused_variable_warning(cpoly);
+        }
+    };
+
+public:
+
+    BOOST_CONCEPT_USAGE(Polygon)
+    {
+        checker::apply();
+    }
+#endif
+};
+
+
+/*!
+\brief Checks polygon concept (const version)
+\ingroup const_concepts
+*/
+template <typename PolygonType>
+class ConstPolygon
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    typedef typename boost::remove_const<PolygonType>::type const_polygon_type;
+
+    typedef typename traits::ring_const_type<const_polygon_type>::type ring_const_type;
+    typedef typename traits::interior_const_type<const_polygon_type>::type interior_const_type;
+
+    typedef typename point_type<const_polygon_type>::type point_type;
+    typedef typename ring_type<const_polygon_type>::type ring_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstRing<ring_type>) );
+
+    ////BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
+
+    struct checker
+    {
+        static inline void apply()
+        {
+            const_polygon_type const* cpoly = 0;
+
+            ring_const_type ce = traits::exterior_ring<const_polygon_type>::get(*cpoly);
+            interior_const_type ci = traits::interior_rings<const_polygon_type>::get(*cpoly);
+
+            boost::ignore_unused_variable_warning(ce);
+            boost::ignore_unused_variable_warning(ci);
+            boost::ignore_unused_variable_warning(cpoly);
+        }
+    };
+
+public:
+
+    BOOST_CONCEPT_USAGE(ConstPolygon)
+    {
+        checker::apply();
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
diff --git a/src/boost/geometry/geometries/concepts/ring_concept.hpp b/src/boost/geometry/geometries/concepts/ring_concept.hpp
new file mode 100644
index 0000000..02a36c9
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/ring_concept.hpp
@@ -0,0 +1,99 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief ring concept
+\ingroup concepts
+\par Formal definition:
+The ring concept is defined as following:
+- there must be a specialization of traits::tag defining ring_tag as type
+- it must behave like a Boost.Range
+- there can optionally be a specialization of traits::point_order defining the
+  order or orientation of its points, clockwise or counterclockwise.
+- it must implement a std::back_insert_iterator
+  (This is the same as the for the concept Linestring, and described there)
+
+\note to fulfill the concepts, no traits class has to be specialized to
+define the point type.
+*/
+template <typename Geometry>
+class Ring
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+public :
+
+    BOOST_CONCEPT_USAGE(Ring)
+    {
+        Geometry* ring = 0;
+        traits::clear<Geometry>::apply(*ring);
+        traits::resize<Geometry>::apply(*ring, 0);
+        point_type* point = 0;
+        traits::push_back<Geometry>::apply(*ring, *point);
+    }
+#endif
+};
+
+
+/*!
+\brief (linear) ring concept (const version)
+\ingroup const_concepts
+\details The ConstLinearRing concept check the same as the Geometry concept,
+but does not check write access.
+*/
+template <typename Geometry>
+class ConstRing
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstRing)
+    {
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
diff --git a/src/boost/geometry/geometries/concepts/segment_concept.hpp b/src/boost/geometry/geometries/concepts/segment_concept.hpp
new file mode 100644
index 0000000..8d2d300
--- /dev/null
+++ b/src/boost/geometry/geometries/concepts/segment_concept.hpp
@@ -0,0 +1,135 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief Segment concept.
+\ingroup concepts
+\details Formal definition:
+The segment concept is defined as following:
+- there must be a specialization of traits::tag defining segment_tag as type
+- there must be a specialization of traits::point_type to define the
+  underlying point type (even if it does not consist of points, it should define
+  this type, to indicate the points it can work with)
+- there must be a specialization of traits::indexed_access, per index
+  and per dimension, with two functions:
+  - get to get a coordinate value
+  - set to set a coordinate value (this one is not checked for ConstSegment)
+
+\note The segment concept is similar to the box concept, defining another tag.
+However, the box concept assumes the index as min_corner, max_corner, while
+for the segment concept there is no assumption.
+*/
+template <typename Geometry>
+class Segment
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+
+
+    template <size_t Index, size_t Dimension, size_t DimensionCount>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            Geometry* s = 0;
+            geometry::set<Index, Dimension>(*s, geometry::get<Index, Dimension>(*s));
+            dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
+        }
+    };
+
+    template <size_t Index, size_t DimensionCount>
+    struct dimension_checker<Index, DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public :
+
+    BOOST_CONCEPT_USAGE(Segment)
+    {
+        static const size_t n = dimension<point_type>::type::value;
+        dimension_checker<0, 0, n>::apply();
+        dimension_checker<1, 0, n>::apply();
+    }
+#endif
+};
+
+
+/*!
+\brief Segment concept (const version).
+\ingroup const_concepts
+\details The ConstSegment concept verifies the same as the Segment concept,
+but does not verify write access.
+*/
+template <typename Geometry>
+class ConstSegment
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename coordinate_type<Geometry>::type coordinate_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+
+
+    template <size_t Index, size_t Dimension, size_t DimensionCount>
+    struct dimension_checker
+    {
+        static void apply()
+        {
+            const Geometry* s = 0;
+            coordinate_type coord(geometry::get<Index, Dimension>(*s));
+            boost::ignore_unused_variable_warning(coord);
+            dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
+        }
+    };
+
+    template <size_t Index, size_t DimensionCount>
+    struct dimension_checker<Index, DimensionCount, DimensionCount>
+    {
+        static void apply() {}
+    };
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstSegment)
+    {
+        static const size_t n = dimension<point_type>::type::value;
+        dimension_checker<0, 0, n>::apply();
+        dimension_checker<1, 0, n>::apply();
+    }
+#endif
+};
+
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
diff --git a/src/boost/geometry/geometries/geometries.hpp b/src/boost/geometry/geometries/geometries.hpp
new file mode 100644
index 0000000..cda55c1
--- /dev/null
+++ b/src/boost/geometry/geometries/geometries.hpp
@@ -0,0 +1,25 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_HPP
+
+#include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+
+#include <boost/geometry/geometries/box.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_HPP
diff --git a/src/boost/geometry/geometries/linestring.hpp b/src/boost/geometry/geometries/linestring.hpp
new file mode 100644
index 0000000..38bc3d4
--- /dev/null
+++ b/src/boost/geometry/geometries/linestring.hpp
@@ -0,0 +1,95 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP
+
+#include <memory>
+#include <vector>
+
+#include <boost/concept/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+/*!
+\brief A linestring (named so by OGC) is a collection (default a vector) of points.
+\ingroup geometries
+\tparam Point \tparam_point
+\tparam Container \tparam_container
+\tparam Allocator \tparam_allocator
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_linestring Linestring Concept]
+}
+
+*/
+template
+<
+    typename Point,
+    template<typename,typename> class Container = std::vector,
+    template<typename> class Allocator = std::allocator
+>
+class linestring : public Container<Point, Allocator<Point> >
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    typedef Container<Point, Allocator<Point> > base_type;
+
+public :
+    /// \constructor_default{linestring}
+    inline linestring()
+        : base_type()
+    {}
+
+    /// \constructor_begin_end{linestring}
+    template <typename Iterator>
+    inline linestring(Iterator begin, Iterator end)
+        : base_type(begin, end)
+    {}
+};
+
+} // namespace model
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename Point,
+    template<typename,typename> class Container,
+    template<typename> class Allocator
+>
+struct tag<model::linestring<Point, Container, Allocator> >
+{
+    typedef linestring_tag type;
+};
+} // namespace traits
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP
diff --git a/src/boost/geometry/geometries/point.hpp b/src/boost/geometry/geometries/point.hpp
new file mode 100644
index 0000000..b40a473
--- /dev/null
+++ b/src/boost/geometry/geometries/point.hpp
@@ -0,0 +1,178 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_POINT_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/int.hpp>
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/coordinate_system.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/util/math.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+namespace model
+{
+
+/*!
+\brief Basic point class, having coordinates defined in a neutral way
+\details Defines a neutral point class, fulfilling the Point Concept.
+    Library users can use this point class, or use their own point classes.
+    This point class is used in most of the samples and tests of Boost.Geometry
+    This point class is used occasionally within the library, where a temporary
+    point class is necessary.
+\ingroup geometries
+\tparam CoordinateType \tparam_numeric
+\tparam DimensionCount number of coordinates, usually 2 or 3
+\tparam CoordinateSystem coordinate system, for example cs::cartesian
+
+\qbk{[include reference/geometries/point.qbk]}
+\qbk{before.synopsis, [heading Model of]}
+\qbk{before.synopsis, [link geometry.reference.concepts.concept_point Point Concept]}
+
+
+*/
+template
+<
+    typename CoordinateType,
+    std::size_t DimensionCount,
+    typename CoordinateSystem
+>
+class point
+{
+public:
+
+    /// @brief Default constructor, no initialization
+    inline point()
+    {}
+
+    /// @brief Constructor to set one, two or three values
+    inline point(CoordinateType const& v0, CoordinateType const& v1 = 0, CoordinateType const& v2 = 0)
+    {
+        if (DimensionCount >= 1) m_values[0] = v0;
+        if (DimensionCount >= 2) m_values[1] = v1;
+        if (DimensionCount >= 3) m_values[2] = v2;
+    }
+
+    /// @brief Get a coordinate
+    /// @tparam K coordinate to get
+    /// @return the coordinate
+    template <std::size_t K>
+    inline CoordinateType const& get() const
+    {
+        BOOST_STATIC_ASSERT(K < DimensionCount);
+        return m_values[K];
+    }
+
+    /// @brief Set a coordinate
+    /// @tparam K coordinate to set
+    /// @param value value to set
+    template <std::size_t K>
+    inline void set(CoordinateType const& value)
+    {
+        BOOST_STATIC_ASSERT(K < DimensionCount);
+        m_values[K] = value;
+    }
+
+private:
+
+    CoordinateType m_values[DimensionCount];
+};
+
+
+} // namespace model
+
+// Adapt the point to the concept
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+template
+<
+    typename CoordinateType,
+    std::size_t DimensionCount,
+    typename CoordinateSystem
+>
+struct tag<model::point<CoordinateType, DimensionCount, CoordinateSystem> >
+{
+    typedef point_tag type;
+};
+
+template
+<
+    typename CoordinateType,
+    std::size_t DimensionCount,
+    typename CoordinateSystem
+>
+struct coordinate_type<model::point<CoordinateType, DimensionCount, CoordinateSystem> >
+{
+    typedef CoordinateType type;
+};
+
+template
+<
+    typename CoordinateType,
+    std::size_t DimensionCount,
+    typename CoordinateSystem
+>
+struct coordinate_system<model::point<CoordinateType, DimensionCount, CoordinateSystem> >
+{
+    typedef CoordinateSystem type;
+};
+
+template
+<
+    typename CoordinateType,
+    std::size_t DimensionCount,
+    typename CoordinateSystem
+>
+struct dimension<model::point<CoordinateType, DimensionCount, CoordinateSystem> >
+    : boost::mpl::int_<DimensionCount>
+{};
+
+template
+<
+    typename CoordinateType,
+    std::size_t DimensionCount,
+    typename CoordinateSystem,
+    std::size_t Dimension
+>
+struct access<model::point<CoordinateType, DimensionCount, CoordinateSystem>, Dimension>
+{
+    static inline CoordinateType get(
+        model::point<CoordinateType, DimensionCount, CoordinateSystem> const& p)
+    {
+        return p.template get<Dimension>();
+    }
+
+    static inline void set(
+        model::point<CoordinateType, DimensionCount, CoordinateSystem>& p,
+        CoordinateType const& value)
+    {
+        p.template set<Dimension>(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_POINT_HPP
diff --git a/src/boost/geometry/geometries/point_xy.hpp b/src/boost/geometry/geometries/point_xy.hpp
new file mode 100644
index 0000000..6529306
--- /dev/null
+++ b/src/boost/geometry/geometries/point_xy.hpp
@@ -0,0 +1,128 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/int.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/geometries/point.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace model { namespace d2
+{
+
+/*!
+\brief 2D point in Cartesian coordinate system
+\tparam CoordinateType numeric type, for example, double, float, int
+\tparam CoordinateSystem coordinate system, defaults to cs::cartesian
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_point Point Concept]
+}
+
+\qbk{[include reference/geometries/point_assign_warning.qbk]}
+
+*/
+template<typename CoordinateType, typename CoordinateSystem = cs::cartesian>
+class point_xy : public model::point<CoordinateType, 2, CoordinateSystem>
+{
+public:
+
+    /// Default constructor, does not initialize anything
+    inline point_xy()
+        : model::point<CoordinateType, 2, CoordinateSystem>()
+    {}
+
+    /// Constructor with x/y values
+    inline point_xy(CoordinateType const& x, CoordinateType const& y)
+        : model::point<CoordinateType, 2, CoordinateSystem>(x, y)
+    {}
+
+    /// Get x-value
+    inline CoordinateType const& x() const
+    { return this->template get<0>(); }
+
+    /// Get y-value
+    inline CoordinateType const& y() const
+    { return this->template get<1>(); }
+
+    /// Set x-value
+    inline void x(CoordinateType const& v)
+    { this->template set<0>(v); }
+
+    /// Set y-value
+    inline void y(CoordinateType const& v)
+    { this->template set<1>(v); }
+};
+
+
+}} // namespace model::d2
+
+
+// Adapt the point_xy to the concept
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename CoordinateType, typename CoordinateSystem>
+struct tag<model::d2::point_xy<CoordinateType, CoordinateSystem> >
+{
+    typedef point_tag type;
+};
+
+template<typename CoordinateType, typename CoordinateSystem>
+struct coordinate_type<model::d2::point_xy<CoordinateType, CoordinateSystem> >
+{
+    typedef CoordinateType type;
+};
+
+template<typename CoordinateType, typename CoordinateSystem>
+struct coordinate_system<model::d2::point_xy<CoordinateType, CoordinateSystem> >
+{
+    typedef CoordinateSystem type;
+};
+
+template<typename CoordinateType, typename CoordinateSystem>
+struct dimension<model::d2::point_xy<CoordinateType, CoordinateSystem> >
+    : boost::mpl::int_<2>
+{};
+
+template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
+struct access<model::d2::point_xy<CoordinateType, CoordinateSystem>, Dimension >
+{
+    static inline CoordinateType get(
+        model::d2::point_xy<CoordinateType, CoordinateSystem> const& p)
+    {
+        return p.template get<Dimension>();
+    }
+
+    static inline void set(model::d2::point_xy<CoordinateType, CoordinateSystem>& p,
+        CoordinateType const& value)
+    {
+        p.template set<Dimension>(value);
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
diff --git a/src/boost/geometry/geometries/polygon.hpp b/src/boost/geometry/geometries/polygon.hpp
new file mode 100644
index 0000000..ec8d1ec
--- /dev/null
+++ b/src/boost/geometry/geometries/polygon.hpp
@@ -0,0 +1,319 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP
+
+#include <memory>
+#include <vector>
+
+#include <boost/concept/assert.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+/*!
+\brief The polygon contains an outer ring and zero or more inner rings.
+\ingroup geometries
+\tparam Point point type
+\tparam ClockWise true for clockwise direction,
+            false for CounterClockWise direction
+\tparam Closed true for closed polygons (last point == first point),
+            false open points
+\tparam PointList container type for points,
+            for example std::vector, std::list, std::deque
+\tparam RingList container type for inner rings,
+            for example std::vector, std::list, std::deque
+\tparam PointAlloc container-allocator-type, for the points
+\tparam RingAlloc container-allocator-type, for the rings
+\note The container collecting the points in the rings can be different
+    from the container collecting the inner rings. They all default to vector.
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_polygon Polygon Concept]
+}
+
+
+*/
+template
+<
+    typename Point,
+    bool ClockWise = true,
+    bool Closed = true,
+    template<typename, typename> class PointList = std::vector,
+    template<typename, typename> class RingList = std::vector,
+    template<typename> class PointAlloc = std::allocator,
+    template<typename> class RingAlloc = std::allocator
+>
+class polygon
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+public:
+
+    // Member types
+    typedef Point point_type;
+    typedef ring<Point, ClockWise, Closed, PointList, PointAlloc> ring_type;
+    typedef RingList<ring_type , RingAlloc<ring_type > > inner_container_type;
+
+    inline ring_type const& outer() const { return m_outer; }
+    inline inner_container_type const& inners() const { return m_inners; }
+
+    inline ring_type& outer() { return m_outer; }
+    inline inner_container_type & inners() { return m_inners; }
+
+    /// Utility method, clears outer and inner rings
+    inline void clear()
+    {
+        m_outer.clear();
+        m_inners.clear();
+    }
+
+private:
+
+    ring_type m_outer;
+    inner_container_type m_inners;
+};
+
+
+} // namespace model
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct tag
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList, PointAlloc, RingAlloc
+        >
+>
+{
+    typedef polygon_tag type;
+};
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct ring_const_type
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList, PointAlloc, RingAlloc
+        >
+>
+{
+    typedef typename model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >::ring_type const& type;
+};
+
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct ring_mutable_type
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList, PointAlloc, RingAlloc
+        >
+>
+{
+    typedef typename model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >::ring_type& type;
+};
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct interior_const_type
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >
+>
+{
+    typedef typename model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >::inner_container_type const& type;
+};
+
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct interior_mutable_type
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >
+>
+{
+    typedef typename model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >::inner_container_type& type;
+};
+
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct exterior_ring
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList, PointAlloc, RingAlloc
+        >
+>
+{
+    typedef model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        > polygon_type;
+
+    static inline typename polygon_type::ring_type& get(polygon_type& p)
+    {
+        return p.outer();
+    }
+
+    static inline typename polygon_type::ring_type const& get(
+                    polygon_type const& p)
+    {
+        return p.outer();
+    }
+};
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class PointList,
+    template<typename, typename> class RingList,
+    template<typename> class PointAlloc,
+    template<typename> class RingAlloc
+>
+struct interior_rings
+<
+    model::polygon
+        <
+            Point, ClockWise, Closed,
+            PointList, RingList,
+            PointAlloc, RingAlloc
+        >
+>
+{
+    typedef model::polygon
+        <
+            Point, ClockWise, Closed, PointList, RingList,
+            PointAlloc, RingAlloc
+        > polygon_type;
+
+    static inline typename polygon_type::inner_container_type& get(
+                    polygon_type& p)
+    {
+        return p.inners();
+    }
+
+    static inline typename polygon_type::inner_container_type const& get(
+                    polygon_type const& p)
+    {
+        return p.inners();
+    }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP
diff --git a/src/boost/geometry/geometries/register/box.hpp b/src/boost/geometry/geometries/register/box.hpp
new file mode 100644
index 0000000..838c2bb
--- /dev/null
+++ b/src/boost/geometry/geometries/register/box.hpp
@@ -0,0 +1,179 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP
+
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS(Box, Point, MinCorner, MaxCorner) \
+template <size_t D> \
+struct indexed_access<Box, min_corner, D> \
+{ \
+    typedef typename coordinate_type<Point>::type ct; \
+    static inline ct get(Box const& b) \
+    { return geometry::get<D>(b. MinCorner);  } \
+    static inline void set(Box& b, ct const& value) \
+    { geometry::set<D>(b. MinCorner, value);  } \
+}; \
+template <size_t D> \
+struct indexed_access<Box, max_corner, D> \
+{ \
+    typedef typename coordinate_type<Point>::type ct; \
+    static inline ct get(Box const& b) \
+    { return geometry::get<D>(b. MaxCorner);  } \
+    static inline void set(Box& b, ct const& value) \
+    { geometry::set<D>(b. MaxCorner, value);  } \
+};
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_TEMPLATED(Box, MinCorner, MaxCorner) \
+template <typename P, size_t D> \
+struct indexed_access<Box<P>, min_corner, D> \
+{ \
+    typedef typename coordinate_type<P>::type ct; \
+    static inline ct get(Box<P> const& b) \
+    { return geometry::get<D>(b. MinCorner);  } \
+    static inline void set(Box<P>& b, ct const& value) \
+    { geometry::set<D>(b. MinCorner, value);  } \
+}; \
+template <typename P, size_t D> \
+struct indexed_access<Box<P>, max_corner, D> \
+{ \
+    typedef typename coordinate_type<P>::type ct; \
+    static inline ct get(Box<P> const& b) \
+    { return geometry::get<D>(b. MaxCorner);  } \
+    static inline void set(Box<P>& b, ct const& value) \
+    { geometry::set<D>(b. MaxCorner, value);  } \
+};
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_4VALUES(Box, Point, Left, Bottom, Right, Top) \
+template <> struct indexed_access<Box, min_corner, 0> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Box const& b) { return b. Left;  } \
+    static inline void set(Box& b, ct const& value) { b. Left = value; } \
+}; \
+template <> struct indexed_access<Box, min_corner, 1> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Box const& b) { return b. Bottom;  } \
+    static inline void set(Box& b, ct const& value) { b. Bottom = value; } \
+}; \
+template <> struct indexed_access<Box, max_corner, 0> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Box const& b) { return b. Right;  } \
+    static inline void set(Box& b, ct const& value) { b. Right = value; } \
+}; \
+template <> struct indexed_access<Box, max_corner, 1> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Box const& b) { return b. Top; } \
+    static inline void set(Box& b, ct const& value) { b. Top = value; } \
+};
+
+
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, PointType) \
+    template<> struct tag<Box > { typedef box_tag type; }; \
+    template<> struct point_type<Box > { typedef PointType type; };
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS_TEMPLATED(Box) \
+    template<typename P> struct tag<Box<P> > { typedef box_tag type; }; \
+    template<typename P> struct point_type<Box<P> > { typedef P type; };
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+
+
+/*!
+\brief \brief_macro{box}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_BOX, box} The 
+    box may contain template parameters, which must be specified then.
+\param Box \param_macro_type{Box}
+\param Point Point type on which box is based. Might be two or three-dimensional
+\param MinCorner minimum corner (should be public member or method)
+\param MaxCorner maximum corner (should be public member or method)
+
+\qbk{
+[heading Example]
+[register_box]
+[register_box_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_BOX(Box, Point, MinCorner, MaxCorner) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, Point) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS(Box, Point, MinCorner, MaxCorner) \
+}}}
+
+
+/*!
+\brief \brief_macro{box}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED, box} 
+    \details_macro_templated{box, point}
+\param Box \param_macro_type{Box}
+\param MinCorner minimum corner (should be public member or method)
+\param MaxCorner maximum corner (should be public member or method)
+
+\qbk{
+[heading Example]
+[register_box_templated]
+[register_box_templated_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED(Box, MinCorner, MaxCorner) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS_TEMPLATED(Box) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_TEMPLATED(Box, MinCorner, MaxCorner) \
+}}}
+
+/*!
+\brief \brief_macro{box}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES, box} 
+\param Box \param_macro_type{Box}
+\param Point Point type reported as point_type by box. Must be two dimensional.
+    Note that these box tyeps do not contain points, but they must have a 
+    related point_type
+\param Left Left side (must be public member or method)
+\param Bottom Bottom side (must be public member or method)
+\param Right Right side (must be public member or method)
+\param Top Top side (must be public member or method)
+
+\qbk{
+[heading Example]
+[register_box_2d_4values]
+[register_box_2d_4values_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(Box, Point, Left, Bottom, Right, Top) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, Point) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_4VALUES(Box, Point, Left, Bottom, Right, Top) \
+}}}
+
+
+
+// CONST versions are for boxes probably not that common. Postponed.
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP
diff --git a/src/boost/geometry/geometries/register/linestring.hpp b/src/boost/geometry/geometries/register/linestring.hpp
new file mode 100644
index 0000000..b064398
--- /dev/null
+++ b/src/boost/geometry/geometries/register/linestring.hpp
@@ -0,0 +1,60 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_LINESTRING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_LINESTRING_HPP
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+/*!
+\brief \brief_macro{linestring}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_LINESTRING, linestring} The 
+    linestring may contain template parameters, which must be specified then.
+\param Linestring \param_macro_type{linestring}
+
+\qbk{
+[heading Example]
+[register_linestring]
+[register_linestring_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_LINESTRING(Linestring) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<> struct tag<Linestring> { typedef linestring_tag type; }; \
+}}}
+
+
+/*!
+\brief \brief_macro{templated linestring}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED, templated linestring} 
+    \details_macro_templated{linestring, point}
+\param Linestring \param_macro_type{linestring (without template parameters)}
+
+\qbk{
+[heading Example]
+[register_linestring_templated]
+[register_linestring_templated_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(Linestring) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<typename P> struct tag< Linestring<P> > { typedef linestring_tag type; }; \
+}}}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_LINESTRING_HPP
diff --git a/src/boost/geometry/geometries/register/point.hpp b/src/boost/geometry/geometries/register/point.hpp
new file mode 100644
index 0000000..6765825
--- /dev/null
+++ b/src/boost/geometry/geometries/register/point.hpp
@@ -0,0 +1,173 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP
+
+
+#include <cstddef>
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+// Starting point, specialize basic traits necessary to register a point
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, Dim, CoordinateType, CoordinateSystem) \
+    template<> struct tag<Point> { typedef point_tag type; }; \
+    template<> struct dimension<Point> : boost::mpl::int_<Dim> {}; \
+    template<> struct coordinate_type<Point> { typedef CoordinateType type; }; \
+    template<> struct coordinate_system<Point> { typedef CoordinateSystem type; };
+
+// Specialize access class per dimension
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, Dim, CoordinateType, Get, Set) \
+    template<> struct access<Point, Dim> \
+    { \
+        static inline CoordinateType get(Point const& p) { return p. Get; } \
+        static inline void set(Point& p, CoordinateType const& value) { p. Set = value; } \
+    };
+
+// Const version
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, Dim, CoordinateType, Get) \
+    template<> struct access<Point, Dim> \
+    { \
+        static inline CoordinateType get(Point const& p) { return p. Get; } \
+    };
+
+
+// Getter/setter version
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, Dim, CoordinateType, Get, Set) \
+    template<> struct access<Point, Dim> \
+    { \
+        static inline CoordinateType get(Point const& p) \
+        { return  p. Get (); } \
+        static inline void set(Point& p, CoordinateType const& value) \
+        { p. Set ( value ); } \
+    };
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+
+/*!
+\brief \brief_macro{2D point type}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D, two-dimensional point type}
+\param Point \param_macro_type{Point}
+\param CoordinateType \param_macro_coortype{point}
+\param CoordinateSystem \param_macro_coorsystem
+\param Field0 \param_macro_member{\macro_x}
+\param Field1 \param_macro_member{\macro_y}
+
+\qbk{[include reference/geometries/register/point.qbk]}
+*/
+#define BOOST_GEOMETRY_REGISTER_POINT_2D(Point, CoordinateType, CoordinateSystem, Field0, Field1) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 0, CoordinateType, Field0, Field0) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 1, CoordinateType, Field1, Field1) \
+}}}
+
+/*!
+\brief \brief_macro{3D point type}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D, three-dimensional point type}
+\param Point \param_macro_type{Point}
+\param CoordinateType \param_macro_coortype{point}
+\param CoordinateSystem \param_macro_coorsystem
+\param Field0 \param_macro_member{\macro_x}
+\param Field1 \param_macro_member{\macro_y}
+\param Field2 \param_macro_member{\macro_z}
+*/
+#define BOOST_GEOMETRY_REGISTER_POINT_3D(Point, CoordinateType, CoordinateSystem, Field0, Field1, Field2) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 0, CoordinateType, Field0, Field0) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 1, CoordinateType, Field1, Field1) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 2, CoordinateType, Field2, Field2) \
+}}}
+
+/*!
+\brief \brief_macro{2D point type} \brief_macro_const
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D_CONST, two-dimensional point type}. \details_macro_const
+\param Point \param_macro_type{Point}
+\param CoordinateType \param_macro_coortype{point}
+\param CoordinateSystem \param_macro_coorsystem
+\param Field0 \param_macro_member{\macro_x}
+\param Field1 \param_macro_member{\macro_y}
+*/
+#define BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(Point, CoordinateType, CoordinateSystem, Field0, Field1) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 0, CoordinateType, Field0) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 1, CoordinateType, Field1) \
+}}}
+
+/*!
+\brief \brief_macro{3D point type} \brief_macro_const
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D_CONST, three-dimensional point type}. \details_macro_const
+\param Point \param_macro_type{Point}
+\param CoordinateType \param_macro_coortype{point}
+\param CoordinateSystem \param_macro_coorsystem
+\param Field0 \param_macro_member{\macro_x}
+\param Field1 \param_macro_member{\macro_y}
+\param Field2 \param_macro_member{\macro_z}
+*/
+#define BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(Point, CoordinateType, CoordinateSystem, Field0, Field1, Field2) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 0, CoordinateType, Field0) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 1, CoordinateType, Field1) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 2, CoordinateType, Field2) \
+}}}
+
+/*!
+\brief \brief_macro{2D point type} \brief_macro_getset
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET, two-dimensional point type}. \details_macro_getset
+\param Point \param_macro_type{Point}
+\param CoordinateType \param_macro_coortype{point}
+\param CoordinateSystem \param_macro_coorsystem
+\param Get0 \param_macro_getset{get, \macro_x}
+\param Get1 \param_macro_getset{get, \macro_y}
+\param Set0 \param_macro_getset{set, \macro_x}
+\param Set1 \param_macro_getset{set, \macro_y}
+*/
+#define BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(Point, CoordinateType, CoordinateSystem, Get0, Get1, Set0, Set1) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 0, CoordinateType, Get0, Set0) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 1, CoordinateType, Get1, Set1) \
+}}}
+
+/*!
+\brief \brief_macro{3D point type} \brief_macro_getset
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET, three-dimensional point type}. \details_macro_getset
+\param Point \param_macro_type{Point}
+\param CoordinateType \param_macro_coortype{point}
+\param CoordinateSystem \param_macro_coorsystem
+\param Get0 \param_macro_getset{get, \macro_x}
+\param Get1 \param_macro_getset{get, \macro_y}
+\param Get2 \param_macro_getset{get, \macro_z}
+\param Set0 \param_macro_getset{set, \macro_x}
+\param Set1 \param_macro_getset{set, \macro_y}
+\param Set2 \param_macro_getset{set, \macro_z}
+*/
+#define BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET(Point, CoordinateType, CoordinateSystem, Get0, Get1, Get2, Set0, Set1, Set2) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 0, CoordinateType, Get0, Set0) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 1, CoordinateType, Get1, Set1) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 2, CoordinateType, Get2, Set2) \
+}}}
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP
diff --git a/src/boost/geometry/geometries/register/ring.hpp b/src/boost/geometry/geometries/register/ring.hpp
new file mode 100644
index 0000000..fb6cb67
--- /dev/null
+++ b/src/boost/geometry/geometries/register/ring.hpp
@@ -0,0 +1,60 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_RING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_RING_HPP
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+/*!
+\brief \brief_macro{ring}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_RING, ring} The 
+    ring may contain template parameters, which must be specified then.
+\param Ring \param_macro_type{ring}
+
+\qbk{
+[heading Example]
+[register_ring]
+[register_ring_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_RING(Ring) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<> struct tag<Ring> { typedef ring_tag type; }; \
+}}}
+
+
+/*!
+\brief \brief_macro{templated ring}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_RING_TEMPLATED, templated ring} 
+    \details_macro_templated{ring, point}
+\param Ring \param_macro_type{ring (without template parameters)}
+
+\qbk{
+[heading Example]
+[register_ring_templated]
+[register_ring_templated_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(Ring) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<typename P> struct tag< Ring<P> > { typedef ring_tag type; }; \
+}}}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_RING_HPP
diff --git a/src/boost/geometry/geometries/register/segment.hpp b/src/boost/geometry/geometries/register/segment.hpp
new file mode 100644
index 0000000..6ea88c0
--- /dev/null
+++ b/src/boost/geometry/geometries/register/segment.hpp
@@ -0,0 +1,129 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
+
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, Point, Index0, Index1) \
+template <size_t D> \
+struct indexed_access<Segment, min_corner, D> \
+{ \
+    typedef typename coordinate_type<Point>::type ct; \
+    static inline ct get(Segment const& b) \
+    { return geometry::get<D>(b. Index0);  } \
+    static inline void set(Segment& b, ct const& value) \
+    { geometry::set<D>(b. Index0, value);  } \
+}; \
+template <size_t D> \
+struct indexed_access<Segment, max_corner, D> \
+{ \
+    typedef typename coordinate_type<Point>::type ct; \
+    static inline ct get(Segment const& b) \
+    { return geometry::get<D>(b. Index1);  } \
+    static inline void set(Segment& b, ct const& value) \
+    { geometry::set<D>(b. Index1, value);  } \
+};
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \
+template <typename P, size_t D> \
+struct indexed_access<Segment<P>, min_corner, D> \
+{ \
+    typedef typename coordinate_type<P>::type ct; \
+    static inline ct get(Segment<P> const& b) \
+    { return geometry::get<D>(b. Index0);  } \
+    static inline void set(Segment<P>& b, ct const& value) \
+    { geometry::set<D>(b. Index0, value);  } \
+}; \
+template <typename P, size_t D> \
+struct indexed_access<Segment<P>, max_corner, D> \
+{ \
+    typedef typename coordinate_type<P>::type ct; \
+    static inline ct get(Segment<P> const& b) \
+    { return geometry::get<D>(b. Index1);  } \
+    static inline void set(Segment<P>& b, ct const& value) \
+    { geometry::set<D>(b. Index1, value);  } \
+};
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, Point, Left, Bottom, Right, Top) \
+template <> struct indexed_access<Segment, min_corner, 0> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Segment const& b) { return b. Left;  } \
+    static inline void set(Segment& b, ct const& value) { b. Left = value; } \
+}; \
+template <> struct indexed_access<Segment, min_corner, 1> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Segment const& b) { return b. Bottom;  } \
+    static inline void set(Segment& b, ct const& value) { b. Bottom = value; } \
+}; \
+template <> struct indexed_access<Segment, max_corner, 0> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Segment const& b) { return b. Right;  } \
+    static inline void set(Segment& b, ct const& value) { b. Right = value; } \
+}; \
+template <> struct indexed_access<Segment, max_corner, 1> \
+{ \
+    typedef coordinate_type<Point>::type ct; \
+    static inline ct get(Segment const& b) { return b. Top; } \
+    static inline void set(Segment& b, ct const& value) { b. Top = value; } \
+};
+
+
+
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
+    template<> struct tag<Segment > { typedef segment_tag type; }; \
+    template<> struct point_type<Segment > { typedef PointType type; };
+
+#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \
+    template<typename P> struct tag<Segment<P> > { typedef segment_tag type; }; \
+    template<typename P> struct point_type<Segment<P> > { typedef P type; };
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+
+
+#define BOOST_GEOMETRY_REGISTER_SEGMENT(Segment, PointType, Index0, Index1) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, PointType, Index0, Index1) \
+}}}
+
+
+#define BOOST_GEOMETRY_REGISTER_SEGMENT_TEMPLATIZED(Segment, Index0, Index1) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \
+}}}
+
+#define BOOST_GEOMETRY_REGISTER_SEGMENT_2D_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \
+namespace boost { namespace geometry { namespace traits {  \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \
+    BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \
+}}}
+
+
+
+// CONST versions are for segments probably not that common. Postponed.
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP
diff --git a/src/boost/geometry/geometries/ring.hpp b/src/boost/geometry/geometries/ring.hpp
new file mode 100644
index 0000000..9986197
--- /dev/null
+++ b/src/boost/geometry/geometries/ring.hpp
@@ -0,0 +1,153 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_RING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_RING_HPP
+
+#include <memory>
+#include <vector>
+
+#include <boost/concept/assert.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+/*!
+\brief A ring (aka linear ring) is a closed line which should not be selfintersecting
+\ingroup geometries
+\tparam Point point type
+\tparam ClockWise true for clockwise direction,
+            false for CounterClockWise direction
+\tparam Closed true for closed polygons (last point == first point),
+            false open points
+\tparam Container container type, for example std::vector, std::deque
+\tparam Allocator container-allocator-type
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_ring Ring Concept]
+}
+*/
+template
+<
+    typename Point,
+    bool ClockWise = true, bool Closed = true,
+    template<typename, typename> class Container = std::vector,
+    template<typename> class Allocator = std::allocator
+>
+class ring : public Container<Point, Allocator<Point> >
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    typedef Container<Point, Allocator<Point> > base_type;
+
+public :
+    /// \constructor_default{ring}
+    inline ring()
+        : base_type()
+    {}
+
+    /// \constructor_begin_end{ring}
+    template <typename Iterator>
+    inline ring(Iterator begin, Iterator end)
+        : base_type(begin, end)
+    {}
+};
+
+} // namespace model
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename Point,
+    bool ClockWise, bool Closed,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct tag<model::ring<Point, ClockWise, Closed, Container, Allocator> >
+{
+    typedef ring_tag type;
+};
+
+
+template
+<
+    typename Point,
+    bool Closed,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct point_order<model::ring<Point, false, Closed, Container, Allocator> >
+{
+    static const order_selector value = counterclockwise;
+};
+
+
+template
+<
+    typename Point,
+    bool Closed,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct point_order<model::ring<Point, true, Closed, Container, Allocator> >
+{
+    static const order_selector value = clockwise;
+};
+
+template
+<
+    typename Point,
+    bool PointOrder,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct closure<model::ring<Point, PointOrder, true, Container, Allocator> >
+{
+    static const closure_selector value = closed;
+};
+
+template
+<
+    typename Point,
+    bool PointOrder,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct closure<model::ring<Point, PointOrder, false, Container, Allocator> >
+{
+    static const closure_selector value = open;
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_RING_HPP
diff --git a/src/boost/geometry/geometries/segment.hpp b/src/boost/geometry/geometries/segment.hpp
new file mode 100644
index 0000000..3f47f79
--- /dev/null
+++ b/src/boost/geometry/geometries/segment.hpp
@@ -0,0 +1,203 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRIES_SEGMENT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_SEGMENT_HPP
+
+#include <cstddef>
+
+#include <boost/concept/assert.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_const.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+/*!
+\brief Class segment: small class containing two points
+\ingroup geometries
+\details From Wikipedia: In geometry, a line segment is a part of a line that is bounded
+ by two distinct end points, and contains every point on the line between its end points.
+\note There is also a point-referring-segment, class referring_segment,
+   containing point references, where points are NOT copied
+*/
+template<typename Point>
+class segment : public std::pair<Point, Point>
+{
+public :
+    inline segment()
+    {}
+
+    inline segment(Point const& p1, Point const& p2)
+    {
+        this->first = p1;
+        this->second = p2;
+    }
+};
+
+
+/*!
+\brief Class segment: small class containing two (templatized) point references
+\ingroup geometries
+\details From Wikipedia: In geometry, a line segment is a part of a line that is bounded
+ by two distinct end points, and contains every point on the line between its end points.
+\note The structure is like std::pair, and can often be used interchangeable.
+Difference is that it refers to points, does not have points.
+\note Like std::pair, points are public available.
+\note type is const or non const, so geometry::segment<P> or geometry::segment<P const>
+\note We cannot derive from std::pair<P&, P&> because of
+reference assignments.
+\tparam ConstOrNonConstPoint point type of the segment, maybe a point or a const point
+*/
+template<typename ConstOrNonConstPoint>
+class referring_segment
+{
+    BOOST_CONCEPT_ASSERT( (
+        typename boost::mpl::if_
+            <
+                boost::is_const<ConstOrNonConstPoint>,
+                concept::Point<ConstOrNonConstPoint>,
+                concept::ConstPoint<ConstOrNonConstPoint>
+            >
+    ) );
+
+    typedef ConstOrNonConstPoint point_type;
+
+public:
+
+    point_type& first;
+    point_type& second;
+
+    inline referring_segment(point_type& p1, point_type& p2)
+        : first(p1)
+        , second(p2)
+    {}
+};
+
+
+} // namespace model
+
+
+// Traits specializations for segment above
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename Point>
+struct tag<model::segment<Point> >
+{
+    typedef segment_tag type;
+};
+
+template <typename Point>
+struct point_type<model::segment<Point> >
+{
+    typedef Point type;
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<model::segment<Point>, 0, Dimension>
+{
+    typedef model::segment<Point> segment_type;
+    typedef typename geometry::coordinate_type<segment_type>::type coordinate_type;
+
+    static inline coordinate_type get(segment_type const& s)
+    {
+        return geometry::get<Dimension>(s.first);
+    }
+
+    static inline void set(segment_type& s, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(s.first, value);
+    }
+};
+
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<model::segment<Point>, 1, Dimension>
+{
+    typedef model::segment<Point> segment_type;
+    typedef typename geometry::coordinate_type<segment_type>::type coordinate_type;
+
+    static inline coordinate_type get(segment_type const& s)
+    {
+        return geometry::get<Dimension>(s.second);
+    }
+
+    static inline void set(segment_type& s, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(s.second, value);
+    }
+};
+
+
+template <typename ConstOrNonConstPoint>
+struct tag<model::referring_segment<ConstOrNonConstPoint> >
+{
+    typedef segment_tag type;
+};
+
+template <typename ConstOrNonConstPoint>
+struct point_type<model::referring_segment<ConstOrNonConstPoint> >
+{
+    typedef ConstOrNonConstPoint type;
+};
+
+template <typename ConstOrNonConstPoint, std::size_t Dimension>
+struct indexed_access<model::referring_segment<ConstOrNonConstPoint>, 0, Dimension>
+{
+    typedef model::referring_segment<ConstOrNonConstPoint> segment_type;
+    typedef typename geometry::coordinate_type<segment_type>::type coordinate_type;
+
+    static inline coordinate_type get(segment_type const& s)
+    {
+        return geometry::get<Dimension>(s.first);
+    }
+
+    static inline void set(segment_type& s, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(s.first, value);
+    }
+};
+
+
+template <typename ConstOrNonConstPoint, std::size_t Dimension>
+struct indexed_access<model::referring_segment<ConstOrNonConstPoint>, 1, Dimension>
+{
+    typedef model::referring_segment<ConstOrNonConstPoint> segment_type;
+    typedef typename geometry::coordinate_type<segment_type>::type coordinate_type;
+
+    static inline coordinate_type get(segment_type const& s)
+    {
+        return geometry::get<Dimension>(s.second);
+    }
+
+    static inline void set(segment_type& s, coordinate_type const& value)
+    {
+        geometry::set<Dimension>(s.second, value);
+    }
+};
+
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_SEGMENT_HPP
diff --git a/src/boost/geometry/geometry.hpp b/src/boost/geometry/geometry.hpp
new file mode 100644
index 0000000..b696b65
--- /dev/null
+++ b/src/boost/geometry/geometry.hpp
@@ -0,0 +1,91 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_HPP
+#define BOOST_GEOMETRY_GEOMETRY_HPP
+
+// Shortcut to include all header files
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+// Core algorithms
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/core/topological_dimension.hpp>
+
+
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/arithmetic/dot_product.hpp>
+
+#include <boost/geometry/strategies/strategies.hpp>
+
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/buffer.hpp>
+#include <boost/geometry/algorithms/centroid.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/comparable_distance.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/algorithms/convex_hull.hpp>
+#include <boost/geometry/algorithms/correct.hpp>
+#include <boost/geometry/algorithms/covered_by.hpp>
+#include <boost/geometry/algorithms/difference.hpp>
+#include <boost/geometry/algorithms/disjoint.hpp>
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/envelope.hpp>
+#include <boost/geometry/algorithms/equals.hpp>
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/algorithms/for_each.hpp>
+#include <boost/geometry/algorithms/intersection.hpp>
+#include <boost/geometry/algorithms/intersects.hpp>
+#include <boost/geometry/algorithms/length.hpp>
+#include <boost/geometry/algorithms/make.hpp>
+#include <boost/geometry/algorithms/num_geometries.hpp>
+#include <boost/geometry/algorithms/num_interior_rings.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+#include <boost/geometry/algorithms/overlaps.hpp>
+#include <boost/geometry/algorithms/perimeter.hpp>
+#include <boost/geometry/algorithms/reverse.hpp>
+#include <boost/geometry/algorithms/simplify.hpp>
+#include <boost/geometry/algorithms/sym_difference.hpp>
+#include <boost/geometry/algorithms/touches.hpp>
+#include <boost/geometry/algorithms/transform.hpp>
+#include <boost/geometry/algorithms/union.hpp>
+#include <boost/geometry/algorithms/unique.hpp>
+#include <boost/geometry/algorithms/within.hpp>
+
+// Include multi a.o. because it can give weird effects
+// if you don't (e.g. area=0 of a multipolygon)
+#include <boost/geometry/multi/multi.hpp>
+
+// check includes all concepts
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/for_each_coordinate.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/io/dsv/write.hpp>
+
+#include <boost/geometry/views/box_view.hpp>
+#include <boost/geometry/views/segment_view.hpp>
+
+#include <boost/geometry/io/io.hpp>
+
+#endif // BOOST_GEOMETRY_GEOMETRY_HPP
diff --git a/src/boost/geometry/io/dsv/write.hpp b/src/boost/geometry/io/dsv/write.hpp
new file mode 100644
index 0000000..62929f8
--- /dev/null
+++ b/src/boost/geometry/io/dsv/write.hpp
@@ -0,0 +1,375 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_DSV_WRITE_HPP
+#define BOOST_GEOMETRY_IO_DSV_WRITE_HPP
+
+#include <cstddef>
+#include <ostream>
+#include <string>
+
+#include <boost/concept_check.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv
+{
+
+struct dsv_settings
+{
+    std::string coordinate_separator;
+    std::string point_open;
+    std::string point_close;
+    std::string point_separator;
+    std::string list_open;
+    std::string list_close;
+    std::string list_separator;
+
+    dsv_settings(std::string const& sep
+            , std::string const& open
+            , std::string const& close
+            , std::string const& psep
+            , std::string const& lopen
+            , std::string const& lclose
+            , std::string const& lsep
+            )
+        : coordinate_separator(sep)
+        , point_open(open)
+        , point_close(close)
+        , point_separator(psep)
+        , list_open(lopen)
+        , list_close(lclose)
+        , list_separator(lsep)
+    {}
+};
+
+/*!
+\brief Stream coordinate of a point as \ref DSV
+*/
+template <typename Point, std::size_t Dimension, std::size_t Count>
+struct stream_coordinate
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Point const& point,
+            dsv_settings const& settings)
+    {
+        os << (Dimension > 0 ? settings.coordinate_separator : "")
+            << get<Dimension>(point);
+
+        stream_coordinate
+            <
+                Point, Dimension + 1, Count
+            >::apply(os, point, settings);
+    }
+};
+
+template <typename Point, std::size_t Count>
+struct stream_coordinate<Point, Count, Count>
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>&,
+            Point const&,
+            dsv_settings const& )
+    {
+    }
+};
+
+/*!
+\brief Stream indexed coordinate of a box/segment as \ref DSV
+*/
+template
+<
+    typename Geometry,
+    std::size_t Index,
+    std::size_t Dimension,
+    std::size_t Count
+>
+struct stream_indexed
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Geometry const& geometry,
+            dsv_settings const& settings)
+    {
+        os << (Dimension > 0 ? settings.coordinate_separator : "")
+            << get<Index, Dimension>(geometry);
+        stream_indexed
+            <
+                Geometry, Index, Dimension + 1, Count
+            >::apply(os, geometry, settings);
+    }
+};
+
+template <typename Geometry, std::size_t Index, std::size_t Count>
+struct stream_indexed<Geometry, Index, Count, Count>
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>&, Geometry const&,
+            dsv_settings const& )
+    {
+    }
+};
+
+/*!
+\brief Stream points as \ref DSV
+*/
+template <typename Point>
+struct dsv_point
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Point const& p,
+            dsv_settings const& settings)
+    {
+        os << settings.point_open;
+        stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p, settings);
+        os << settings.point_close;
+    }
+};
+
+/*!
+\brief Stream ranges as DSV
+\note policy is used to stream prefix/postfix, enabling derived classes to override this
+*/
+template <typename Range>
+struct dsv_range
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Range const& range,
+            dsv_settings const& settings)
+    {
+        typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+        bool first = true;
+
+        os << settings.list_open;
+
+        for (iterator_type it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            os << (first ? "" : settings.point_separator)
+                << settings.point_open;
+
+            stream_coordinate
+                <
+                    point_type, 0, dimension<point_type>::type::value
+                >::apply(os, *it, settings);
+            os << settings.point_close;
+
+            first = false;
+        }
+
+        os << settings.list_close;
+    }
+
+private:
+    typedef typename boost::range_value<Range>::type point_type;
+};
+
+/*!
+\brief Stream sequence of points as DSV-part, e.g. (1 2),(3 4)
+\note Used in polygon, all multi-geometries
+*/
+
+template <typename Polygon>
+struct dsv_poly
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Polygon const& poly,
+                dsv_settings const& settings)
+    {
+        typedef typename ring_type<Polygon>::type ring;
+
+        os << settings.list_open;
+
+        dsv_range<ring>::apply(os, exterior_ring(poly), settings);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            os << settings.list_separator;
+            dsv_range<ring>::apply(os, *it, settings);
+        }
+        os << settings.list_close;
+    }
+};
+
+template <typename Geometry, std::size_t Index>
+struct dsv_per_index
+{
+    typedef typename point_type<Geometry>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Geometry const& geometry,
+            dsv_settings const& settings)
+    {
+        os << settings.point_open;
+        stream_indexed
+            <
+                Geometry, Index, 0, dimension<Geometry>::type::value
+            >::apply(os, geometry, settings);
+        os << settings.point_close;
+    }
+};
+
+template <typename Geometry>
+struct dsv_indexed
+{
+    typedef typename point_type<Geometry>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Geometry const& geometry,
+            dsv_settings const& settings)
+    {
+        os << settings.list_open;
+        dsv_per_index<Geometry, 0>::apply(os, geometry, settings);
+        os << settings.point_separator;
+        dsv_per_index<Geometry, 1>::apply(os, geometry, settings);
+        os << settings.list_close;
+    }
+};
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct dsv {};
+
+template <typename Point>
+struct dsv<point_tag, Point>
+    : detail::dsv::dsv_point<Point>
+{};
+
+template <typename Linestring>
+struct dsv<linestring_tag, Linestring>
+    : detail::dsv::dsv_range<Linestring>
+{};
+
+template <typename Box>
+struct dsv<box_tag, Box>
+    : detail::dsv::dsv_indexed<Box>
+{};
+
+template <typename Segment>
+struct dsv<segment_tag, Segment>
+    : detail::dsv::dsv_indexed<Segment>
+{};
+
+template <typename Ring>
+struct dsv<ring_tag, Ring>
+    : detail::dsv::dsv_range<Ring>
+{};
+
+template <typename Polygon>
+struct dsv<polygon_tag, Polygon>
+    : detail::dsv::dsv_poly<Polygon>
+{};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv
+{
+
+// FIXME: This class is not copyable/assignable but it is used as such --mloskot
+template <typename Geometry>
+class dsv_manipulator
+{
+public:
+
+    inline dsv_manipulator(Geometry const& g,
+            dsv_settings const& settings)
+        : m_geometry(g)
+        , m_settings(settings)
+    {}
+
+    template <typename Char, typename Traits>
+    inline friend std::basic_ostream<Char, Traits>& operator<<(
+            std::basic_ostream<Char, Traits>& os,
+            dsv_manipulator const& m)
+    {
+        dispatch::dsv
+            <
+                typename tag_cast
+                    <
+                        typename tag<Geometry>::type,
+                        multi_tag
+                    >::type,
+                Geometry
+            >::apply(os, m.m_geometry, m.m_settings);
+        os.flush();
+        return os;
+    }
+
+private:
+    Geometry const& m_geometry;
+    dsv_settings m_settings;
+};
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+/*!
+\brief Main DSV-streaming function
+\details DSV stands for Delimiter Separated Values. Geometries can be streamed
+    as DSV. There are defaults for all separators.
+\note Useful for examples and testing purposes
+\note With this function GeoJSON objects can be created, using the right
+    delimiters
+\ingroup utility
+*/
+template <typename Geometry>
+inline detail::dsv::dsv_manipulator<Geometry> dsv(Geometry const& geometry
+    , std::string const& coordinate_separator = ", "
+    , std::string const& point_open = "("
+    , std::string const& point_close = ")"
+    , std::string const& point_separator = ", "
+    , std::string const& list_open = "("
+    , std::string const& list_close = ")"
+    , std::string const& list_separator = ", "
+    )
+{
+    concept::check<Geometry const>();
+
+    return detail::dsv::dsv_manipulator<Geometry>(geometry,
+        detail::dsv::dsv_settings(coordinate_separator,
+            point_open, point_close, point_separator,
+            list_open, list_close, list_separator));
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_DSV_WRITE_HPP
diff --git a/src/boost/geometry/io/io.hpp b/src/boost/geometry/io/io.hpp
new file mode 100644
index 0000000..9340060
--- /dev/null
+++ b/src/boost/geometry/io/io.hpp
@@ -0,0 +1,58 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_HPP
+#define BOOST_GEOMETRY_IO_HPP
+
+#include <boost/geometry/io/wkt/read.hpp>
+#include <boost/geometry/io/wkt/write.hpp>
+
+namespace boost { namespace geometry
+{
+
+struct format_wkt {};
+struct format_wkb {}; // TODO
+struct format_dsv {}; // TODO
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+template <typename Tag, typename Geometry>
+struct read
+{
+};
+
+template <typename Geometry>
+struct read<format_wkt, Geometry>
+{
+    static inline void apply(Geometry& geometry, std::string const& wkt)
+    {
+        read_wkt<typename tag<Geometry>::type, Geometry>::apply(wkt, geometry);
+    }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+template <typename Format, typename Geometry>
+inline void read(Geometry& geometry, std::string const& wkt)
+{
+    geometry::concept::check<Geometry>();
+    dispatch::read<Format, Geometry>::apply(geometry, wkt);
+}
+
+// TODO: wriite
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_HPP
diff --git a/src/boost/geometry/io/wkt/detail/prefix.hpp b/src/boost/geometry/io/wkt/detail/prefix.hpp
new file mode 100644
index 0000000..45e43b8
--- /dev/null
+++ b/src/boost/geometry/io/wkt/detail/prefix.hpp
@@ -0,0 +1,45 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKT_DETAIL_PREFIX_HPP
+#define BOOST_GEOMETRY_IO_WKT_DETAIL_PREFIX_HPP
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+struct prefix_point
+{
+    static inline const char* apply() { return "POINT"; }
+};
+
+struct prefix_polygon
+{
+    static inline const char* apply() { return "POLYGON"; }
+};
+
+struct prefix_linestring
+{
+    static inline const char* apply() { return "LINESTRING"; }
+};
+
+}} // namespace wkt::impl
+#endif
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKT_DETAIL_PREFIX_HPP
diff --git a/src/boost/geometry/io/wkt/detail/wkt_multi.hpp b/src/boost/geometry/io/wkt/detail/wkt_multi.hpp
new file mode 100644
index 0000000..0e5abbc
--- /dev/null
+++ b/src/boost/geometry/io/wkt/detail/wkt_multi.hpp
@@ -0,0 +1,57 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_MULTI_HPP
+#define BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_MULTI_HPP
+
+
+#include <boost/geometry/domains/gis/io/wkt/write.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+struct prefix_null
+{
+    static inline const char* apply() { return ""; }
+};
+
+struct prefix_multipoint
+{
+    static inline const char* apply() { return "MULTIPOINT"; }
+};
+
+struct prefix_multilinestring
+{
+    static inline const char* apply() { return "MULTILINESTRING"; }
+};
+
+struct prefix_multipolygon
+{
+    static inline const char* apply() { return "MULTIPOLYGON"; }
+};
+
+
+
+}} // namespace wkt::impl
+#endif
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_DOMAINS_GIS_IO_WKT_DETAIL_WKT_MULTI_HPP
diff --git a/src/boost/geometry/io/wkt/iomanip.hpp b/src/boost/geometry/io/wkt/iomanip.hpp
new file mode 100644
index 0000000..4221a1e
--- /dev/null
+++ b/src/boost/geometry/io/wkt/iomanip.hpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKT_IOMANIP_HPP
+#define BOOST_GEOMETRY_IO_WKT_IOMANIP_HPP
+
+#include <boost/geometry/io/wkt/write.hpp>
+
+// This short file contains only one manipulator, streaming as WKT
+// Don't move contents to as_wkt, developers must be able to choose how to stream
+
+// Don't use namespace boost::geometry, to enable the library to stream custom geometries which
+// are living outside the namespace boost { namespace geometry
+
+//namespace boost { namespace geometry
+//{
+
+
+/*!
+\brief Streams a geometry as Well-Known Text
+\ingroup wkt
+*/
+template<typename Char, typename Traits, typename Geometry>
+inline std::basic_ostream<Char,Traits>& operator<<
+    (
+        std::basic_ostream<Char,Traits> &os,
+        Geometry const& geom
+    )
+{
+    os << boost::geometry::wkt(geom);
+    return os;
+}
+
+//}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKT_IOMANIP_HPP
diff --git a/src/boost/geometry/io/wkt/read.hpp b/src/boost/geometry/io/wkt/read.hpp
new file mode 100644
index 0000000..e926939
--- /dev/null
+++ b/src/boost/geometry/io/wkt/read.hpp
@@ -0,0 +1,686 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKT_READ_HPP
+#define BOOST_GEOMETRY_IO_WKT_READ_HPP
+
+#include <string>
+
+#include <boost/lexical_cast.hpp>
+#include <boost/tokenizer.hpp>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/range.hpp>
+
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/append.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/exception.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/geometry_id.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/mutable_range.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+#include <boost/geometry/util/coordinate_cast.hpp>
+
+#include <boost/geometry/io/wkt/detail/prefix.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Exception showing things wrong with WKT parsing
+\ingroup wkt
+*/
+struct read_wkt_exception : public geometry::exception
+{
+    template <typename Iterator>
+    read_wkt_exception(std::string const& msg,
+            Iterator const& it, Iterator const& end, std::string const& wkt)
+        : message(msg)
+        , wkt(wkt)
+    {
+        if (it != end)
+        {
+            source = " at '";
+            source += it->c_str();
+            source += "'";
+        }
+        complete = message + source + " in '" + wkt.substr(0, 100) + "'";
+    }
+
+    read_wkt_exception(std::string const& msg, std::string const& wkt)
+        : message(msg)
+        , wkt(wkt)
+    {
+        complete = message + "' in (" + wkt.substr(0, 100) + ")";
+    }
+
+    virtual ~read_wkt_exception() throw() {}
+
+    virtual const char* what() const throw()
+    {
+        return complete.c_str();
+    }
+private :
+    std::string source;
+    std::string message;
+    std::string wkt;
+    std::string complete;
+};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+// (wkt: Well Known Text, defined by OGC for all geometries and implemented by e.g. databases (MySQL, PostGIS))
+namespace detail { namespace wkt
+{
+
+typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
+
+template <typename Point, std::size_t Dimension, std::size_t DimensionCount>
+struct parsing_assigner
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+            Point& point, std::string const& wkt)
+    {
+        typedef typename coordinate_type<Point>::type coordinate_type;
+
+        // Stop at end of tokens, or at "," ot ")"
+        bool finished = (it == end || *it == "," || *it == ")");
+
+        try
+        {
+            // Initialize missing coordinates to default constructor (zero)
+            // OR
+            // Use lexical_cast for conversion to double/int
+            // Note that it is much slower than atof. However, it is more standard
+            // and in parsing the change in performance falls probably away against
+            // the tokenizing
+            set<Dimension>(point, finished
+                    ? coordinate_type()
+                    : coordinate_cast<coordinate_type>::apply(*it));
+        }
+        catch(boost::bad_lexical_cast const& blc)
+        {
+            throw read_wkt_exception(blc.what(), it, end, wkt);
+        }
+        catch(std::exception const& e)
+        {
+            throw read_wkt_exception(e.what(), it, end, wkt);
+        }
+        catch(...)
+        {
+            throw read_wkt_exception("", it, end, wkt);
+        }
+
+        parsing_assigner<Point, Dimension + 1, DimensionCount>::apply(
+                        (finished ? it : ++it), end, point, wkt);
+    }
+};
+
+template <typename Point, std::size_t DimensionCount>
+struct parsing_assigner<Point, DimensionCount, DimensionCount>
+{
+    static inline void apply(tokenizer::iterator&, tokenizer::iterator, Point&,
+                std::string const&)
+    {
+    }
+};
+
+
+
+template <typename Iterator>
+inline void handle_open_parenthesis(Iterator& it,
+            Iterator const& end, std::string const& wkt)
+{
+    if (it == end || *it != "(")
+    {
+        throw read_wkt_exception("Expected '('", it, end, wkt);
+    }
+    ++it;
+}
+
+
+template <typename Iterator>
+inline void handle_close_parenthesis(Iterator& it,
+            Iterator const& end, std::string const& wkt)
+{
+    if (it != end && *it == ")")
+    {
+        ++it;
+    }
+    else
+    {
+        throw read_wkt_exception("Expected ')'", it, end, wkt);
+    }
+}
+
+template <typename Iterator>
+inline void check_end(Iterator& it,
+            Iterator const& end, std::string const& wkt)
+{
+    if (it != end)
+    {
+        throw read_wkt_exception("Too much tokens", it, end, wkt);
+    }
+}
+
+/*!
+\brief Internal, parses coordinate sequences, strings are formated like "(1 2,3 4,...)"
+\param it token-iterator, should be pre-positioned at "(", is post-positions after last ")"
+\param end end-token-iterator
+\param out Output itererator receiving coordinates
+*/
+template <typename Point>
+struct container_inserter
+{
+    // Version with output iterator
+    template <typename OutputIterator>
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, OutputIterator out)
+    {
+        handle_open_parenthesis(it, end, wkt);
+
+        Point point;
+
+        // Parse points until closing parenthesis
+
+        while (it != end && *it != ")")
+        {
+            parsing_assigner
+                <
+                    Point,
+                    0,
+                    dimension<Point>::value
+                >::apply(it, end, point, wkt);
+            out = point;
+            ++out;
+            if (it != end && *it == ",")
+            {
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+
+// Geometry is a value-type or reference-type
+template <typename Geometry>
+struct container_appender
+{
+    typedef typename geometry::point_type
+        <
+            typename boost::remove_reference<Geometry>::type
+        >::type point_type;
+
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, Geometry out)
+    {
+        handle_open_parenthesis(it, end, wkt);
+
+        point_type point;
+
+        // Parse points until closing parenthesis
+
+        while (it != end && *it != ")")
+        {
+            parsing_assigner
+                <
+                    point_type,
+                    0,
+                    dimension<point_type>::value
+                >::apply(it, end, point, wkt);
+
+            geometry::append(out, point);
+            if (it != end && *it == ",")
+            {
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+/*!
+\brief Internal, parses a point from a string like this "(x y)"
+\note used for parsing points and multi-points
+*/
+template <typename P>
+struct point_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, P& point)
+    {
+        handle_open_parenthesis(it, end, wkt);
+        parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt);
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+
+template <typename Geometry>
+struct linestring_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+                std::string const& wkt, Geometry& geometry)
+    {
+        container_appender<Geometry&>::apply(it, end, wkt, geometry);
+    }
+};
+
+
+template <typename Ring>
+struct ring_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+                std::string const& wkt, Ring& ring)
+    {
+        // A ring should look like polygon((x y,x y,x y...))
+        // So handle the extra opening/closing parentheses
+        // and in between parse using the container-inserter
+        handle_open_parenthesis(it, end, wkt);
+        container_appender<Ring&>::apply(it, end, wkt, ring);
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+
+
+
+/*!
+\brief Internal, parses a polygon from a string like this "((x y,x y),(x y,x y))"
+\note used for parsing polygons and multi-polygons
+*/
+template <typename Polygon>
+struct polygon_parser
+{
+    typedef typename ring_return_type<Polygon>::type ring_return_type;
+    typedef container_appender<ring_return_type> appender;
+
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+                std::string const& wkt, Polygon& poly)
+    {
+
+        handle_open_parenthesis(it, end, wkt);
+
+        int n = -1;
+
+        // Stop at ")"
+        while (it != end && *it != ")")
+        {
+            // Parse ring
+            if (++n == 0)
+            {
+                appender::apply(it, end, wkt, exterior_ring(poly));
+            }
+            else
+            {
+                typename ring_type<Polygon>::type ring;
+                appender::apply(it, end, wkt, ring);
+                traits::push_back
+                    <
+                        typename boost::remove_reference
+                        <
+                            typename traits::interior_mutable_type<Polygon>::type
+                        >::type
+                    >::apply(interior_rings(poly), ring);
+            }
+
+            if (it != end && *it == ",")
+            {
+                // Skip "," after ring is parsed
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
+inline bool one_of(tokenizer::iterator const& it, std::string const& value,
+            bool& is_present)
+{
+    if (boost::iequals(*it, value))
+    {
+        is_present = true;
+        return true;
+    }
+    return false;
+}
+
+inline bool one_of(tokenizer::iterator const& it, std::string const& value,
+            bool& present1, bool& present2)
+{
+    if (boost::iequals(*it, value))
+    {
+        present1 = true;
+        present2 = true;
+        return true;
+    }
+    return false;
+}
+
+
+inline void handle_empty_z_m(tokenizer::iterator& it, tokenizer::iterator end,
+            bool& has_empty, bool& has_z, bool& has_m)
+{
+    has_empty = false;
+    has_z = false;
+    has_m = false;
+
+    // WKT can optionally have Z and M (measured) values as in
+    // POINT ZM (1 1 5 60), POINT M (1 1 80), POINT Z (1 1 5)
+    // GGL supports any of them as coordinate values, but is not aware
+    // of any Measured value.
+    while (it != end
+           && (one_of(it, "M", has_m)
+               || one_of(it, "Z", has_z)
+               || one_of(it, "EMPTY", has_empty)
+               || one_of(it, "MZ", has_m, has_z)
+               || one_of(it, "ZM", has_z, has_m)
+               )
+           )
+    {
+        ++it;
+    }
+}
+
+/*!
+\brief Internal, starts parsing
+\param tokens boost tokens, parsed with separator " " and keeping separator "()"
+\param geometry string to compare with first token
+*/
+template <typename Geometry>
+inline bool initialize(tokenizer const& tokens,
+            std::string const& geometry_name, std::string const& wkt,
+            tokenizer::iterator& it)
+{
+    it = tokens.begin();
+    if (it != tokens.end() && boost::iequals(*it++, geometry_name))
+    {
+        bool has_empty, has_z, has_m;
+
+        handle_empty_z_m(it, tokens.end(), has_empty, has_z, has_m);
+
+        if (has_z && dimension<Geometry>::type::value < 3)
+        {
+            throw read_wkt_exception("Z only allowed for 3 or more dimensions", wkt);
+        }
+        if (has_empty)
+        {
+            check_end(it, tokens.end(), wkt);
+            return false;
+        }
+        // M is ignored at all.
+
+        return true;
+    }
+    throw read_wkt_exception(std::string("Should start with '") + geometry_name + "'", wkt);
+}
+
+
+template <typename Geometry, template<typename> class Parser, typename PrefixPolicy>
+struct geometry_parser
+{
+    static inline void apply(std::string const& wkt, Geometry& geometry)
+    {
+        geometry::clear(geometry);
+
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it;
+        if (initialize<Geometry>(tokens, PrefixPolicy::apply(), wkt, it))
+        {
+            Parser<Geometry>::apply(it, tokens.end(), wkt, geometry);
+            check_end(it, tokens.end(), wkt);
+        }
+    }
+};
+
+
+
+
+
+/*!
+\brief Supports box parsing
+\note OGC does not define the box geometry, and WKT does not support boxes.
+    However, to be generic GGL supports reading and writing from and to boxes.
+    Boxes are outputted as a standard POLYGON. GGL can read boxes from
+    a standard POLYGON, from a POLYGON with 2 points of from a BOX
+\tparam Box the box
+*/
+template <typename Box>
+struct box_parser
+{
+    static inline void apply(std::string const& wkt, Box& box)
+    {
+        bool should_close = false;
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it = tokens.begin();
+        tokenizer::iterator end = tokens.end();
+        if (it != end && boost::iequals(*it, "POLYGON"))
+        {
+            ++it;
+            bool has_empty, has_z, has_m;
+            handle_empty_z_m(it, end, has_empty, has_z, has_m);
+            if (has_empty)
+            {
+                assign_zero(box);
+                return;
+            }
+            handle_open_parenthesis(it, end, wkt);
+            should_close = true;
+        }
+        else if (it != end && boost::iequals(*it, "BOX"))
+        {
+            ++it;
+        }
+        else
+        {
+            throw read_wkt_exception("Should start with 'POLYGON' or 'BOX'", wkt);
+        }
+
+        typedef typename point_type<Box>::type point_type;
+        std::vector<point_type> points;
+        container_inserter<point_type>::apply(it, end, wkt, std::back_inserter(points));
+
+        if (should_close)
+        {
+            handle_close_parenthesis(it, end, wkt);
+        }
+        check_end(it, end, wkt);
+
+        int index = 0;
+        int n = boost::size(points);
+        if (n == 2)
+        {
+            index = 1;
+        }
+        else if (n == 4 || n == 5)
+        {
+            // In case of 4 or 5 points, we do not check the other ones, just
+            // take the opposite corner which is always 2
+            index = 2;
+        }
+        else
+        {
+            throw read_wkt_exception("Box should have 2,4 or 5 points", wkt);
+        }
+
+        geometry::detail::assign_point_to_index<min_corner>(points.front(), box);
+        geometry::detail::assign_point_to_index<max_corner>(points[index], box);
+    }
+};
+
+
+/*!
+\brief Supports segment parsing
+\note OGC does not define the segment, and WKT does not support segmentes.
+    However, it is useful to implement it, also for testing purposes
+\tparam Segment the segment
+*/
+template <typename Segment>
+struct segment_parser
+{
+    static inline void apply(std::string const& wkt, Segment& segment)
+    {
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it = tokens.begin();
+        tokenizer::iterator end = tokens.end();
+        if (it != end &&
+            (boost::iequals(*it, "SEGMENT")
+            || boost::iequals(*it, "LINESTRING") ))
+        {
+            ++it;
+        }
+        else
+        {
+            throw read_wkt_exception("Should start with 'LINESTRING' or 'SEGMENT'", wkt);
+        }
+
+        typedef typename point_type<Segment>::type point_type;
+        std::vector<point_type> points;
+        container_inserter<point_type>::apply(it, end, wkt, std::back_inserter(points));
+
+        check_end(it, end, wkt);
+
+        if (boost::size(points) == 2)
+        {
+            geometry::detail::assign_point_to_index<0>(points.front(), segment);
+            geometry::detail::assign_point_to_index<1>(points.back(), segment);
+        }
+        else
+        {
+            throw read_wkt_exception("Segment should have 2 points", wkt);
+        }
+
+    }
+};
+
+
+
+}} // namespace detail::wkt
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct read_wkt {};
+
+
+template <typename Point>
+struct read_wkt<point_tag, Point>
+    : detail::wkt::geometry_parser
+        <
+            Point,
+            detail::wkt::point_parser,
+            detail::wkt::prefix_point
+        >
+{};
+
+
+template <typename L>
+struct read_wkt<linestring_tag, L>
+    : detail::wkt::geometry_parser
+        <
+            L,
+            detail::wkt::linestring_parser,
+            detail::wkt::prefix_linestring
+        >
+{};
+
+template <typename Ring>
+struct read_wkt<ring_tag, Ring>
+    : detail::wkt::geometry_parser
+        <
+            Ring,
+            detail::wkt::ring_parser,
+            detail::wkt::prefix_polygon
+        >
+{};
+
+template <typename Geometry>
+struct read_wkt<polygon_tag, Geometry>
+    : detail::wkt::geometry_parser
+        <
+            Geometry,
+            detail::wkt::polygon_parser,
+            detail::wkt::prefix_polygon
+        >
+{};
+
+
+// Box (Non-OGC)
+template <typename Box>
+struct read_wkt<box_tag, Box>
+    : detail::wkt::box_parser<Box>
+{};
+
+// Segment (Non-OGC)
+template <typename Segment>
+struct read_wkt<segment_tag, Segment>
+    : detail::wkt::segment_parser<Segment>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+/*!
+\brief Parses OGC Well-Known Text (\ref WKT) into a geometry (any geometry)
+\ingroup wkt
+\param wkt string containing \ref WKT
+\param geometry output geometry
+\par Example:
+\note It is case insensitive and can have the WKT forms "point", "point m", "point z", "point zm", "point mz"
+\note Empty sequences can have forms as "LINESTRING ()" or "POLYGON(())"
+Small example showing how to use read_wkt to build a point
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_point
+\line {
+\until }
+\par Example:
+Small example showing how to use read_wkt to build a linestring
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_linestring
+\line {
+\until }
+\par Example:
+Small example showing how to use read_wkt to build a polygon
+\dontinclude doxygen_1.cpp
+\skip example_from_wkt_polygon
+\line {
+\until }
+*/
+template <typename Geometry>
+inline void read_wkt(std::string const& wkt, Geometry& geometry)
+{
+    geometry::concept::check<Geometry>();
+    dispatch::read_wkt<typename tag<Geometry>::type, Geometry>::apply(wkt, geometry);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKT_READ_HPP
diff --git a/src/boost/geometry/io/wkt/stream.hpp b/src/boost/geometry/io/wkt/stream.hpp
new file mode 100644
index 0000000..86e49fd
--- /dev/null
+++ b/src/boost/geometry/io/wkt/stream.hpp
@@ -0,0 +1,40 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKT_STREAM_HPP
+#define BOOST_GEOMETRY_IO_WKT_STREAM_HPP
+
+#include <boost/geometry/io/wkt/write.hpp>
+
+// This short file contains only one manipulator, streaming as WKT
+// Don't include this in any standard-included header file.
+
+// Don't use namespace boost::geometry, to enable the library to stream custom
+// geometries which are living outside the namespace boost::geometry
+
+/*!
+\brief Streams a geometry as Well-Known Text
+\ingroup wkt
+*/
+template<typename Char, typename Traits, typename Geometry>
+inline std::basic_ostream<Char, Traits>& operator<<
+    (
+        std::basic_ostream<Char, Traits> &os,
+        Geometry const& geom
+    )
+{
+    os << boost::geometry::wkt(geom);
+    return os;
+}
+
+#endif // BOOST_GEOMETRY_IO_WKT_STREAM_HPP
diff --git a/src/boost/geometry/io/wkt/wkt.hpp b/src/boost/geometry/io/wkt/wkt.hpp
new file mode 100644
index 0000000..28bd1e4
--- /dev/null
+++ b/src/boost/geometry/io/wkt/wkt.hpp
@@ -0,0 +1,25 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKT_WKT_HPP
+#define BOOST_GEOMETRY_IO_WKT_WKT_HPP
+
+#include <boost/geometry/io/wkt/read.hpp>
+#include <boost/geometry/io/wkt/write.hpp>
+
+// BSG 2011-02-03
+// We don't include stream.hpp by default. That tries to stream anything not known
+// by default (such as ttmath) and reports errors.
+// Users can include stream.hpp themselves (if they want to)
+
+#endif // BOOST_GEOMETRY_IO_WKT_WKT_HPP
diff --git a/src/boost/geometry/io/wkt/write.hpp b/src/boost/geometry/io/wkt/write.hpp
new file mode 100644
index 0000000..a3e3173
--- /dev/null
+++ b/src/boost/geometry/io/wkt/write.hpp
@@ -0,0 +1,376 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_IO_WKT_WRITE_HPP
+#define BOOST_GEOMETRY_IO_WKT_WRITE_HPP
+
+#include <ostream>
+#include <string>
+
+#include <boost/array.hpp>
+#include <boost/concept/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+
+#include <boost/geometry/io/wkt/detail/prefix.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+template <typename P, int I, int Count>
+struct stream_coordinate
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os, P const& p)
+    {
+        os << (I > 0 ? " " : "") << get<I>(p);
+        stream_coordinate<P, I + 1, Count>::apply(os, p);
+    }
+};
+
+template <typename P, int Count>
+struct stream_coordinate<P, Count, Count>
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>&, P const&)
+    {}
+};
+
+struct prefix_linestring_par
+{
+    static inline const char* apply() { return "LINESTRING("; }
+};
+
+struct prefix_ring_par_par
+{
+    // Note, double parentheses are intentional, indicating WKT ring begin/end
+    static inline const char* apply() { return "POLYGON(("; }
+};
+
+struct opening_parenthesis
+{
+    static inline const char* apply() { return "("; }
+};
+
+struct closing_parenthesis
+{
+    static inline const char* apply() { return ")"; }
+};
+
+struct double_closing_parenthesis
+{
+    static inline const char* apply() { return "))"; }
+};
+
+/*!
+\brief Stream points as \ref WKT
+*/
+template <typename Point, typename Policy>
+struct wkt_point
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os, Point const& p)
+    {
+        os << Policy::apply() << "(";
+        stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p);
+        os << ")";
+    }
+};
+
+/*!
+\brief Stream ranges as WKT
+\note policy is used to stream prefix/postfix, enabling derived classes to override this
+*/
+template <typename Range, typename PrefixPolicy, typename SuffixPolicy>
+struct wkt_range
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Range const& range)
+    {
+        typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+        bool first = true;
+
+        os << PrefixPolicy::apply();
+
+        // TODO: check EMPTY here
+
+        for (iterator_type it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            os << (first ? "" : ",");
+            stream_coordinate
+                <
+                    point_type, 0, dimension<point_type>::type::value
+                >::apply(os, *it);
+            first = false;
+        }
+
+        os << SuffixPolicy::apply();
+    }
+
+private:
+    typedef typename boost::range_value<Range>::type point_type;
+};
+
+/*!
+\brief Stream sequence of points as WKT-part, e.g. (1 2),(3 4)
+\note Used in polygon, all multi-geometries
+*/
+template <typename Range>
+struct wkt_sequence
+    : wkt_range
+        <
+            Range,
+            opening_parenthesis,
+            closing_parenthesis
+        >
+{};
+
+template <typename Polygon, typename PrefixPolicy>
+struct wkt_poly
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Polygon const& poly)
+    {
+        typedef typename ring_type<Polygon const>::type ring;
+
+        os << PrefixPolicy::apply();
+        // TODO: check EMPTY here
+        os << "(";
+        wkt_sequence<ring>::apply(os, exterior_ring(poly));
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            os << ",";
+            wkt_sequence<ring>::apply(os, *it);
+        }
+        os << ")";
+    }
+};
+
+template <typename Box>
+struct wkt_box
+{
+    typedef typename point_type<Box>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Box const& box)
+    {
+        // Convert to ring, then stream
+        typedef model::ring<point_type> ring_type;
+        ring_type ring;
+        geometry::convert(box, ring);
+        os << "POLYGON(";
+        wkt_sequence<ring_type>::apply(os, ring);
+        os << ")";
+    }
+
+    private:
+
+        inline wkt_box()
+        {
+            // Only streaming of boxes with two dimensions is support, otherwise it is a polyhedron!
+            //assert_dimension<B, 2>();
+        }
+};
+
+
+template <typename Segment>
+struct wkt_segment
+{
+    typedef typename point_type<Segment>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Segment const& segment)
+    {
+        // Convert to two points, then stream
+        typedef boost::array<point_type, 2> sequence;
+
+        sequence points;
+        geometry::detail::assign_point_from_index<0>(segment, points[0]);
+        geometry::detail::assign_point_from_index<1>(segment, points[1]);
+
+        // In Boost.Geometry a segment is represented
+        // in WKT-format like (for 2D): LINESTRING(x y,x y)
+        os << "LINESTRING";
+        wkt_sequence<sequence>::apply(os, points);
+    }
+
+    private:
+
+        inline wkt_segment()
+        {}
+};
+
+}} // namespace detail::wkt
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct wkt
+{
+   BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+template <typename Point>
+struct wkt<point_tag, Point>
+    : detail::wkt::wkt_point
+        <
+            Point,
+            detail::wkt::prefix_point
+        >
+{};
+
+template <typename Linestring>
+struct wkt<linestring_tag, Linestring>
+    : detail::wkt::wkt_range
+        <
+            Linestring,
+            detail::wkt::prefix_linestring_par,
+            detail::wkt::closing_parenthesis
+        >
+{};
+
+/*!
+\brief Specialization to stream a box as WKT
+\details A "box" does not exist in WKT.
+It is therefore streamed as a polygon
+*/
+template <typename Box>
+struct wkt<box_tag, Box>
+    : detail::wkt::wkt_box<Box>
+{};
+
+template <typename Segment>
+struct wkt<segment_tag, Segment>
+    : detail::wkt::wkt_segment<Segment>
+{};
+
+/*!
+\brief Specialization to stream a ring as WKT
+\details A ring or "linear_ring" does not exist in WKT.
+A ring is equivalent to a polygon without inner rings
+It is therefore streamed as a polygon
+*/
+template <typename Ring>
+struct wkt<ring_tag, Ring>
+    : detail::wkt::wkt_range
+        <
+            Ring,
+            detail::wkt::prefix_ring_par_par,
+            detail::wkt::double_closing_parenthesis
+        >
+{};
+
+/*!
+\brief Specialization to stream polygon as WKT
+*/
+template <typename Polygon>
+struct wkt<polygon_tag, Polygon>
+    : detail::wkt::wkt_poly
+        <
+            Polygon,
+            detail::wkt::prefix_polygon
+        >
+{};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+/*!
+\brief Generic geometry template manipulator class, takes corresponding output class from traits class
+\ingroup wkt
+\details Stream manipulator, streams geometry classes as \ref WKT streams
+\par Example:
+Small example showing how to use the wkt class
+\dontinclude doxygen_1.cpp
+\skip example_as_wkt_point
+\line {
+\until }
+*/
+template <typename Geometry>
+class wkt_manipulator
+{
+public:
+
+    inline wkt_manipulator(Geometry const& g)
+        : m_geometry(g)
+    {}
+
+    template <typename Char, typename Traits>
+    inline friend std::basic_ostream<Char, Traits>& operator<<(
+            std::basic_ostream<Char, Traits>& os,
+            wkt_manipulator const& m)
+    {
+        dispatch::wkt
+            <
+                typename tag<Geometry>::type,
+                Geometry
+            >::apply(os, m.m_geometry);
+        os.flush();
+        return os;
+    }
+
+private:
+    Geometry const& m_geometry;
+};
+
+/*!
+\brief Main WKT-streaming function
+\ingroup wkt
+\par Example:
+Small example showing how to use the wkt helper function
+\dontinclude doxygen_1.cpp
+\skip example_as_wkt_vector
+\line {
+\until }
+*/
+template <typename Geometry>
+inline wkt_manipulator<Geometry> wkt(Geometry const& geometry)
+{
+    concept::check<Geometry const>();
+
+    return wkt_manipulator<Geometry>(geometry);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_IO_WKT_WRITE_HPP
diff --git a/src/boost/geometry/iterators/base.hpp b/src/boost/geometry/iterators/base.hpp
new file mode 100644
index 0000000..1e82465
--- /dev/null
+++ b/src/boost/geometry/iterators/base.hpp
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ITERATORS_BASE_HPP
+#define BOOST_GEOMETRY_ITERATORS_BASE_HPP
+
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/mpl/if.hpp>
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace boost { namespace geometry { namespace detail { namespace iterators
+{
+
+template
+<
+    typename DerivedClass,
+    typename Iterator,
+    typename TraversalFlag = boost::bidirectional_traversal_tag
+>
+struct iterator_base
+    : public boost::iterator_adaptor
+    <
+        DerivedClass,
+        Iterator,
+        boost::use_default,
+        typename boost::mpl::if_
+        <
+            boost::is_convertible
+            <
+                typename boost::iterator_traversal<Iterator>::type,
+                boost::random_access_traversal_tag
+            >,
+            TraversalFlag,
+            boost::use_default
+        >::type
+    >
+{
+    // Define operator cast to Iterator to be able to write things like Iterator it = myit++
+    inline operator Iterator() const
+    {
+        return this->base();
+    }
+
+    /*inline bool operator==(Iterator const& other) const
+    {
+        return this->base() == other;
+    }
+    inline bool operator!=(Iterator const& other) const
+    {
+        return ! operator==(other);
+    }*/
+};
+
+}}}} // namespace boost::geometry::detail::iterators
+#endif
+
+
+#endif // BOOST_GEOMETRY_ITERATORS_BASE_HPP
diff --git a/src/boost/geometry/iterators/closing_iterator.hpp b/src/boost/geometry/iterators/closing_iterator.hpp
new file mode 100644
index 0000000..7cd8fa0
--- /dev/null
+++ b/src/boost/geometry/iterators/closing_iterator.hpp
@@ -0,0 +1,157 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ITERATORS_CLOSING_ITERATOR_HPP
+#define BOOST_GEOMETRY_ITERATORS_CLOSING_ITERATOR_HPP
+
+#include <boost/range.hpp>
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Iterator which iterates through a range, but adds first element at end of the range
+\tparam Range range on which this class is based on
+\ingroup iterators
+\note Use with "closing_iterator<Range> or "closing_iterator<Range const>
+        to get non-const / const behaviour
+\note This class is normally used from "closeable_view" if Close==true
+*/
+template <typename Range>
+struct closing_iterator
+    : public boost::iterator_facade
+    <
+        closing_iterator<Range>,
+        typename boost::range_value<Range>::type const,
+        boost::random_access_traversal_tag
+    >
+{
+    /// Constructor including the range it is based on
+    explicit inline closing_iterator(Range& range)
+        : m_range(&range)
+        , m_iterator(boost::begin(range))
+        , m_end(boost::end(range))
+        , m_size(boost::size(range))
+        , m_index(0)
+    {}
+
+    /// Constructor to indicate the end of a range
+    explicit inline closing_iterator(Range& range, bool)
+        : m_range(&range)
+        , m_iterator(boost::end(range))
+        , m_end(boost::end(range))
+        , m_size(boost::size(range))
+        , m_index(m_size + 1)
+    {}
+
+    /// Default constructor
+    explicit inline closing_iterator()
+        : m_range(NULL)
+        , m_size(0)
+        , m_index(0)
+    {}
+
+    inline closing_iterator<Range>& operator=(closing_iterator<Range> const& source)
+    {
+        m_range = source.m_range;
+        m_iterator = source.m_iterator;
+        m_end = source.m_end;
+        m_size = source.m_size;
+        m_index = source.m_index;
+        return *this;
+    }
+
+    typedef std::ptrdiff_t difference_type;
+
+private:
+    friend class boost::iterator_core_access;
+
+    inline typename boost::range_value<Range>::type const& dereference() const
+    {
+        return *m_iterator;
+    }
+
+    inline difference_type distance_to(closing_iterator<Range> const& other) const
+    {
+        return other.m_index - this->m_index;
+    }
+
+    inline bool equal(closing_iterator<Range> const& other) const
+    {
+        return this->m_range == other.m_range
+            && this->m_index == other.m_index;
+    }
+
+    inline void increment()
+    {
+        if (++m_index < m_size)
+        {
+            ++m_iterator;
+        }
+        else
+        {
+            update_iterator();
+        }
+    }
+
+    inline void decrement()
+    {
+        if (m_index-- < m_size)
+        {
+            --m_iterator;
+        }
+        else
+        {
+            update_iterator();
+        }
+    }
+
+    inline void advance(difference_type n)
+    {
+        if (m_index < m_size && m_index + n < m_size)
+        {
+            m_index += n;
+            m_iterator += n;
+        }
+        else
+        {
+            m_index += n;
+            update_iterator();
+        }
+    }
+
+    inline void update_iterator()
+    {
+        this->m_iterator = m_index <= m_size
+            ? boost::begin(*m_range) + (m_index % m_size)
+            : boost::end(*m_range)
+            ;
+    }
+
+    Range* m_range;
+    typename boost::range_iterator<Range>::type m_iterator;
+    typename boost::range_iterator<Range>::type m_end;
+    difference_type m_size;
+    difference_type m_index;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ITERATORS_CLOSING_ITERATOR_HPP
diff --git a/src/boost/geometry/iterators/ever_circling_iterator.hpp b/src/boost/geometry/iterators/ever_circling_iterator.hpp
new file mode 100644
index 0000000..566669e
--- /dev/null
+++ b/src/boost/geometry/iterators/ever_circling_iterator.hpp
@@ -0,0 +1,212 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ITERATORS_EVER_CIRCLING_ITERATOR_HPP
+#define BOOST_GEOMETRY_ITERATORS_EVER_CIRCLING_ITERATOR_HPP
+
+#include <boost/range.hpp>
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+
+#include <boost/geometry/iterators/base.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*!
+    \brief Iterator which ever circles through a range
+    \tparam Iterator iterator on which this class is based on
+    \ingroup iterators
+    \details If the iterator arrives at range.end() it restarts from the
+     beginning. So it has to be stopped in another way.
+    Don't call for(....; it++) because it will turn in an endless loop
+    \note Name inspired on David Bowie's
+    "Chant Of The Ever Circling Skeletal Family"
+*/
+template <typename Iterator>
+struct ever_circling_iterator :
+    public detail::iterators::iterator_base
+    <
+        ever_circling_iterator<Iterator>,
+        Iterator
+    >
+{
+    friend class boost::iterator_core_access;
+
+    explicit inline ever_circling_iterator(Iterator begin, Iterator end,
+            bool skip_first = false)
+      : m_begin(begin)
+      , m_end(end)
+      , m_skip_first(skip_first)
+    {
+        this->base_reference() = begin;
+    }
+
+    explicit inline ever_circling_iterator(Iterator begin, Iterator end, Iterator start,
+            bool skip_first = false)
+      : m_begin(begin)
+      , m_end(end)
+      , m_skip_first(skip_first)
+    {
+        this->base_reference() = start;
+    }
+
+    /// Navigate to a certain position, should be in [start .. end], if at end
+    /// it will circle again.
+    inline void moveto(Iterator it)
+    {
+        this->base_reference() = it;
+        check_end();
+    }
+
+private:
+
+    inline void increment(bool possibly_skip = true)
+    {
+        (this->base_reference())++;
+        check_end(possibly_skip);
+    }
+
+    inline void check_end(bool possibly_skip = true)
+    {
+        if (this->base() == this->m_end)
+        {
+            this->base_reference() = this->m_begin;
+            if (m_skip_first && possibly_skip)
+            {
+                increment(false);
+            }
+        }
+    }
+
+    Iterator m_begin;
+    Iterator m_end;
+    bool m_skip_first;
+};
+
+template <typename Range>
+struct ever_circling_range_iterator
+    : public boost::iterator_facade
+    <
+        ever_circling_range_iterator<Range>,
+        typename boost::range_value<Range>::type const,
+        boost::random_access_traversal_tag
+    >
+{
+    /// Constructor including the range it is based on
+    explicit inline ever_circling_range_iterator(Range& range)
+        : m_range(&range)
+        , m_iterator(boost::begin(range))
+        , m_size(boost::size(range))
+        , m_index(0)
+    {}
+
+    /// Default constructor
+    explicit inline ever_circling_range_iterator()
+        : m_range(NULL)
+        , m_size(0)
+        , m_index(0)
+    {}
+
+    inline ever_circling_range_iterator<Range>& operator=(ever_circling_range_iterator<Range> const& source)
+    {
+        m_range = source.m_range;
+        m_iterator = source.m_iterator;
+        m_size = source.m_size;
+        m_index = source.m_index;
+        return *this;
+    }
+
+    typedef std::ptrdiff_t difference_type;
+
+private:
+    friend class boost::iterator_core_access;
+
+    inline typename boost::range_value<Range>::type const& dereference() const
+    {
+        return *m_iterator;
+    }
+
+    inline difference_type distance_to(ever_circling_range_iterator<Range> const& other) const
+    {
+        return other.m_index - this->m_index;
+    }
+
+    inline bool equal(ever_circling_range_iterator<Range> const& other) const
+    {
+        return this->m_range == other.m_range
+            && this->m_index == other.m_index;
+    }
+
+    inline void increment()
+    {
+        ++m_index;
+        if (m_index >= 0 && m_index < m_size)
+        {
+            ++m_iterator;
+        }
+        else
+        {
+            update_iterator();
+        }
+    }
+
+    inline void decrement()
+    {
+        --m_index;
+        if (m_index >= 0 && m_index < m_size)
+        {
+            --m_iterator;
+        }
+        else
+        {
+            update_iterator();
+        }
+    }
+
+    inline void advance(difference_type n)
+    {
+        if (m_index >= 0 && m_index < m_size 
+            && m_index + n >= 0 && m_index + n < m_size)
+        {
+            m_index += n;
+            m_iterator += n;
+        }
+        else
+        {
+            m_index += n;
+            update_iterator();
+        }
+    }
+
+    inline void update_iterator()
+    {
+        while (m_index < 0)
+        {
+            m_index += m_size;
+        }
+		m_index = m_index % m_size;
+        this->m_iterator = boost::begin(*m_range) + m_index;
+    }
+
+    Range* m_range;
+    typename boost::range_iterator<Range>::type m_iterator;
+    difference_type m_size;
+    difference_type m_index;
+};
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ITERATORS_EVER_CIRCLING_ITERATOR_HPP
diff --git a/src/boost/geometry/multi/algorithms/append.hpp b/src/boost/geometry/multi/algorithms/append.hpp
new file mode 100644
index 0000000..e72be03
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/append.hpp
@@ -0,0 +1,52 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_APPEND_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_APPEND_HPP
+
+#include <boost/geometry/algorithms/append.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+namespace splitted_dispatch
+{
+
+template <typename Geometry, typename Point>
+struct append_point<multi_point_tag, Geometry, Point>
+    : detail::append::append_point<Geometry, Point>
+{};
+
+template <typename Geometry, typename Range>
+struct append_range<multi_point_tag, Geometry, Range>
+    : detail::append::append_range<Geometry, Range>
+{};
+
+}
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_APPEND_HPP
diff --git a/src/boost/geometry/multi/algorithms/area.hpp b/src/boost/geometry/multi/algorithms/area.hpp
new file mode 100644
index 0000000..6695686
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/area.hpp
@@ -0,0 +1,57 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_AREA_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_AREA_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/area.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+#include <boost/geometry/multi/algorithms/detail/multi_sum.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+template <typename MultiGeometry, typename Strategy>
+struct area<MultiGeometry, Strategy, multi_polygon_tag>
+    : detail::multi_sum
+        <
+            typename Strategy::return_type,
+            MultiGeometry,
+            Strategy,
+            area
+                <
+                    typename boost::range_value<MultiGeometry>::type,
+                    Strategy,
+                    polygon_tag
+                >
+    >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_AREA_HPP
diff --git a/src/boost/geometry/multi/algorithms/centroid.hpp b/src/boost/geometry/multi/algorithms/centroid.hpp
new file mode 100644
index 0000000..855ed22
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/centroid.hpp
@@ -0,0 +1,178 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_CENTROID_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_CENTROID_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/centroid.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace centroid
+{
+
+
+/*!
+    \brief Building block of a multi-point, to be used as Policy in the
+        more generec centroid_multi
+*/
+template
+<
+    typename Point,
+    typename Strategy
+>
+struct centroid_multi_point_state
+{
+    static inline void apply(Point const& point,
+            Strategy const& strategy, typename Strategy::state_type& state)
+    {
+        strategy.apply(point, state);
+    }
+};
+
+
+
+/*!
+    \brief Generic implementation which calls a policy to calculate the
+        centroid of the total of its single-geometries
+    \details The Policy is, in general, the single-version, with state. So
+        detail::centroid::centroid_polygon_state is used as a policy for this
+        detail::centroid::centroid_multi
+
+*/
+template
+<
+    typename Multi,
+    typename Point,
+    typename Strategy,
+    typename Policy
+>
+struct centroid_multi
+{
+    static inline void apply(Multi const& multi, Point& centroid,
+            Strategy const& strategy)
+    {
+#if ! defined(BOOST_GEOMETRY_CENTROID_NO_THROW)
+        // If there is nothing in any of the ranges, it is not possible
+        // to calculate the centroid
+        if (geometry::num_points(multi) == 0)
+        {
+            throw centroid_exception();
+        }
+#endif
+
+        typename Strategy::state_type state;
+
+        for (typename boost::range_iterator<Multi const>::type
+                it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            Policy::apply(*it, strategy, state);
+        }
+        Strategy::result(state, centroid);
+    }
+};
+
+
+
+}} // namespace detail::centroid
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename MultiLinestring,
+    typename Point,
+    typename Strategy
+>
+struct centroid<multi_linestring_tag, MultiLinestring, Point,  Strategy>
+    : detail::centroid::centroid_multi
+        <
+            MultiLinestring,
+            Point,
+            Strategy,
+            detail::centroid::centroid_range_state
+                <
+                    typename boost::range_value<MultiLinestring>::type,
+                    closed,
+                    Strategy
+                >
+        >
+{};
+
+template
+<
+    typename MultiPolygon,
+    typename Point,
+    typename Strategy
+>
+struct centroid<multi_polygon_tag, MultiPolygon, Point,  Strategy>
+    : detail::centroid::centroid_multi
+        <
+            MultiPolygon,
+            Point,
+            Strategy,
+            detail::centroid::centroid_polygon_state
+                <
+                    typename boost::range_value<MultiPolygon>::type,
+                    Strategy
+                >
+        >
+{};
+
+
+template
+<
+    typename MultiPoint,
+    typename Point,
+    typename Strategy
+>
+struct centroid<multi_point_tag, MultiPoint, Point,  Strategy>
+    : detail::centroid::centroid_multi
+        <
+            MultiPoint,
+            Point,
+            Strategy,
+            detail::centroid::centroid_multi_point_state
+                <
+                    typename boost::range_value<MultiPoint>::type,
+                    Strategy
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_CENTROID_HPP
+
diff --git a/src/boost/geometry/multi/algorithms/clear.hpp b/src/boost/geometry/multi/algorithms/clear.hpp
new file mode 100644
index 0000000..0b14b6c
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/clear.hpp
@@ -0,0 +1,43 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_CLEAR_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_CLEAR_HPP
+
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/clear.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Geometry>
+struct clear<Geometry, multi_tag>
+    : detail::clear::collection_clear<Geometry>
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_CLEAR_HPP
diff --git a/src/boost/geometry/multi/algorithms/convert.hpp b/src/boost/geometry/multi/algorithms/convert.hpp
new file mode 100644
index 0000000..4745791
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/convert.hpp
@@ -0,0 +1,128 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_CONVERT_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_CONVERT_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace conversion
+{
+
+template <typename Single, typename Multi, typename Policy>
+struct single_to_multi: private Policy
+{
+    static inline void apply(Single const& single, Multi& multi)
+    {
+        traits::resize<Multi>::apply(multi, 1);
+        Policy::apply(single, *boost::begin(multi));
+    }
+};
+
+
+
+template <typename Multi1, typename Multi2, typename Policy>
+struct multi_to_multi: private Policy
+{
+    static inline void apply(Multi1 const& multi1, Multi2& multi2)
+    {
+        traits::resize<Multi2>::apply(multi2, boost::size(multi1));
+
+        typename boost::range_iterator<Multi1 const>::type it1
+                = boost::begin(multi1);
+        typename boost::range_iterator<Multi2>::type it2
+                = boost::begin(multi2);
+
+        for (; it1 != boost::end(multi1); ++it1, ++it2)
+        {
+            Policy::apply(*it1, *it2);
+        }
+    }
+};
+
+
+}} // namespace detail::convert
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// Dispatch for multi <-> multi, specifying their single-version as policy.
+// Note that, even if the multi-types are mutually different, their single
+// version types might be the same and therefore we call boost::is_same again
+
+template <typename Multi1, typename Multi2, std::size_t DimensionCount>
+struct convert<Multi1, Multi2, multi_tag, multi_tag, DimensionCount, false>
+    : detail::conversion::multi_to_multi
+        <
+            Multi1, 
+            Multi2,
+            convert
+                <
+                    typename boost::range_value<Multi1>::type,
+                    typename boost::range_value<Multi2>::type,
+                    typename single_tag_of
+                                <
+                                    typename tag<Multi1>::type
+                                >::type,
+                    typename single_tag_of
+                                <
+                                    typename tag<Multi2>::type
+                                >::type,
+                    DimensionCount
+                >
+        >
+{};
+
+template <typename Single, typename Multi, typename SingleTag, std::size_t DimensionCount>
+struct convert<Single, Multi, SingleTag, multi_tag, DimensionCount, false>
+    : detail::conversion::single_to_multi
+        <
+            Single, 
+            Multi,
+            convert
+                <
+                    Single,
+                    typename boost::range_value<Multi>::type,
+                    typename tag<Single>::type,
+                    typename single_tag_of
+                                <
+                                    typename tag<Multi>::type
+                                >::type,
+                    DimensionCount,
+                    false
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_CONVERT_HPP
diff --git a/src/boost/geometry/multi/algorithms/correct.hpp b/src/boost/geometry/multi/algorithms/correct.hpp
new file mode 100644
index 0000000..d0c3e10
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/correct.hpp
@@ -0,0 +1,66 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_CORRECT_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_CORRECT_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/correct.hpp>
+#include <boost/geometry/multi/algorithms/detail/modify.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiPoint>
+struct correct<MultiPoint, multi_point_tag>
+    : detail::correct::correct_nop<MultiPoint>
+{};
+
+
+template <typename MultiLineString>
+struct correct<MultiLineString, multi_linestring_tag>
+    : detail::correct::correct_nop<MultiLineString>
+{};
+
+
+template <typename Geometry>
+struct correct<Geometry, multi_polygon_tag>
+    : detail::multi_modify
+        <
+            Geometry,
+            detail::correct::correct_polygon
+                <
+                    typename boost::range_value<Geometry>::type
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_CORRECT_HPP
diff --git a/src/boost/geometry/multi/algorithms/covered_by.hpp b/src/boost/geometry/multi/algorithms/covered_by.hpp
new file mode 100644
index 0000000..ba398c0
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/covered_by.hpp
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_COVERED_BY_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_COVERED_BY_HPP
+
+
+#include <boost/geometry/algorithms/covered_by.hpp>
+#include <boost/geometry/multi/core/closure.hpp>
+#include <boost/geometry/multi/core/point_order.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/algorithms/within.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Point, typename MultiPolygon>
+struct covered_by<Point, MultiPolygon, point_tag, multi_polygon_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, 
+                MultiPolygon const& multi_polygon, Strategy const& strategy)
+    {
+        return detail::within::geometry_multi_within_code
+            <
+                Point,
+                MultiPolygon,
+                Strategy,
+                detail::within::point_in_polygon
+                        <
+                            Point,
+                            typename boost::range_value<MultiPolygon>::type,
+                            order_as_direction
+                                <
+                                    geometry::point_order<MultiPolygon>::value
+                                >::value,
+                            geometry::closure<MultiPolygon>::value,
+                            Strategy
+                        >
+            >::apply(point, multi_polygon, strategy) >= 0;
+    }
+};
+
+
+} // namespace dispatch
+
+
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_COVERED_BY_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/for_each_range.hpp b/src/boost/geometry/multi/algorithms/detail/for_each_range.hpp
new file mode 100644
index 0000000..08ab14b
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/for_each_range.hpp
@@ -0,0 +1,86 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
+
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/algorithms/detail/for_each_range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace for_each
+{
+
+
+template <typename Multi, typename Actor, bool IsConst>
+struct fe_range_multi
+{
+    static inline void apply(
+                    typename add_const_if_c<IsConst, Multi>::type& multi,
+                    Actor& actor)
+    {
+        for(BOOST_AUTO_TPL(it, boost::begin(multi)); it != boost::end(multi); ++it)
+        {
+            geometry::detail::for_each_range(*it, actor);
+        }
+    }
+};
+
+
+
+}} // namespace detail::for_each
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename MultiPoint, typename Actor, bool IsConst>
+struct for_each_range<multi_point_tag, MultiPoint, Actor, IsConst>
+    : detail::for_each::fe_range_range<MultiPoint, Actor, IsConst>
+{};
+
+template <typename Geometry, typename Actor, bool IsConst>
+struct for_each_range<multi_linestring_tag, Geometry, Actor, IsConst>
+    :
+    detail::for_each::fe_range_multi<Geometry, Actor, IsConst>
+{};
+
+template <typename Geometry, typename Actor, bool IsConst>
+struct for_each_range<multi_polygon_tag, Geometry, Actor, IsConst>
+    :
+    detail::for_each::fe_range_multi<Geometry, Actor, IsConst>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_FOR_EACH_RANGE_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/modify.hpp b/src/boost/geometry/multi/algorithms/detail/modify.hpp
new file mode 100644
index 0000000..b52efd2
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/modify.hpp
@@ -0,0 +1,53 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_MODIFY_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_MODIFY_HPP
+
+
+#include <boost/range.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template <typename MultiGeometry, typename Policy>
+struct multi_modify
+{
+    static inline void apply(MultiGeometry& multi)
+    {
+        typedef typename boost::range_iterator<MultiGeometry>::type iterator_type;
+        for (iterator_type it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            Policy::apply(*it);
+        }
+    }
+};
+
+
+} // namespace detail
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_MODIFY_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp b/src/boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp
new file mode 100644
index 0000000..4ae7905
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp
@@ -0,0 +1,52 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_MODIFY_WITH_PREDICATE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_MODIFY_WITH_PREDICATE_HPP
+
+
+#include <boost/range.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename MultiGeometry, typename Predicate, typename Policy>
+struct multi_modify_with_predicate
+{
+    static inline void apply(MultiGeometry& multi, Predicate const& predicate)
+    {
+        typedef typename boost::range_iterator<MultiGeometry>::type iterator_type;
+        for (iterator_type it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            Policy::apply(*it, predicate);
+        }
+    }
+};
+
+
+} // namespace detail
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_MODIFY_WITH_PREDICATE_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/multi_sum.hpp b/src/boost/geometry/multi/algorithms/detail/multi_sum.hpp
new file mode 100644
index 0000000..a47685c
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/multi_sum.hpp
@@ -0,0 +1,58 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_SUM_HPP
+#define BOOST_GEOMETRY_MULTI_SUM_HPP
+
+#include <boost/range.hpp>
+
+
+namespace boost { namespace geometry
+{
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template
+<
+    typename ReturnType,
+    typename MultiGeometry,
+    typename Strategy,
+    typename Policy
+>
+struct multi_sum
+{
+    static inline ReturnType apply(MultiGeometry const& geometry, Strategy const& strategy)
+    {
+        ReturnType sum = ReturnType();
+        for (typename boost::range_iterator
+                <
+                    MultiGeometry const
+                >::type it = boost::begin(geometry);
+            it != boost::end(geometry);
+            ++it)
+        {
+            sum += Policy::apply(*it, strategy);
+        }
+        return sum;
+    }
+};
+
+
+} // namespace detail
+#endif
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_SUM_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp b/src/boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp
new file mode 100644
index 0000000..72be5dd
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp
@@ -0,0 +1,101 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENT_POINT_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENT_POINT_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace copy_segments
+{
+
+
+template
+<
+    typename MultiGeometry,
+    typename SegmentIdentifier,
+    typename PointOut,
+    typename Policy
+>
+struct copy_segment_point_multi
+{
+    static inline bool apply(MultiGeometry const& multi,
+                SegmentIdentifier const& seg_id, bool second,
+                PointOut& point)
+    {
+
+        BOOST_ASSERT
+            (
+                seg_id.multi_index >= 0
+                && seg_id.multi_index < int(boost::size(multi))
+            );
+
+        // Call the single-version
+        return Policy::apply(multi[seg_id.multi_index], seg_id, second, point);
+    }
+};
+
+
+}} // namespace detail::copy_segments
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename MultiGeometry,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename PointOut
+>
+struct copy_segment_point
+    <
+        multi_polygon_tag,
+        MultiGeometry,
+        Reverse,
+        SegmentIdentifier,
+        PointOut
+    >
+    : detail::copy_segments::copy_segment_point_multi
+        <
+            MultiGeometry,
+            SegmentIdentifier,
+            PointOut,
+            detail::copy_segments::copy_segment_point_polygon
+                <
+                    typename boost::range_value<MultiGeometry>::type,
+                    Reverse,
+                    SegmentIdentifier,
+                    PointOut
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENT_POINT_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp b/src/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp
new file mode 100644
index 0000000..f474b12
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp
@@ -0,0 +1,104 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
+
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
+
+#include <boost/geometry/multi/core/ring_type.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace copy_segments
+{
+
+
+template
+<
+    typename MultiGeometry,
+    typename SegmentIdentifier,
+    typename RangeOut,
+    typename Policy
+>
+struct copy_segments_multi
+{
+    static inline void apply(MultiGeometry const& multi_geometry,
+            SegmentIdentifier const& seg_id, int to_index,
+            RangeOut& current_output)
+    {
+
+        BOOST_ASSERT
+            (
+                seg_id.multi_index >= 0
+                && seg_id.multi_index < int(boost::size(multi_geometry))
+            );
+
+        // Call the single-version
+        Policy::apply(multi_geometry[seg_id.multi_index],
+                    seg_id, to_index, current_output);
+    }
+};
+
+
+}} // namespace detail::copy_segments
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename MultiPolygon,
+    bool Reverse,
+    typename SegmentIdentifier,
+    typename RangeOut
+>
+struct copy_segments
+    <
+        multi_polygon_tag,
+        MultiPolygon,
+        Reverse,
+        SegmentIdentifier,
+        RangeOut
+    >
+    : detail::copy_segments::copy_segments_multi
+        <
+            MultiPolygon,
+            SegmentIdentifier,
+            RangeOut,
+            detail::copy_segments::copy_segments_polygon
+                <
+                    typename boost::range_value<MultiPolygon>::type,
+                    Reverse,
+                    SegmentIdentifier,
+                    RangeOut
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_COPY_SEGMENTS_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/overlay/get_ring.hpp b/src/boost/geometry/multi/algorithms/detail/overlay/get_ring.hpp
new file mode 100644
index 0000000..e23acf9
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/overlay/get_ring.hpp
@@ -0,0 +1,54 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
+
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
+#include <boost/geometry/multi/core/ring_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+template<>
+struct get_ring<multi_polygon_tag>
+{
+    template<typename MultiPolygon>
+    static inline typename ring_type<MultiPolygon>::type const& apply(
+                ring_identifier const& id,
+                MultiPolygon const& multi_polygon)
+    {
+        BOOST_ASSERT
+            (
+                id.multi_index >= 0
+                && id.multi_index < int(boost::size(multi_polygon))
+            );
+        return get_ring<polygon_tag>::apply(id,
+                    multi_polygon[id.multi_index]);
+    }
+};
+
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_GET_RING_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/overlay/get_turns.hpp b/src/boost/geometry/multi/algorithms/detail/overlay/get_turns.hpp
new file mode 100644
index 0000000..1ee03cc
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/overlay/get_turns.hpp
@@ -0,0 +1,111 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP
+
+
+#include <boost/geometry/multi/core/ring_type.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
+
+#include <boost/geometry/multi/algorithms/distance.hpp>
+#include <boost/geometry/multi/views/detail/range_type.hpp>
+
+#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
+#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace get_turns
+{
+
+template
+<
+    typename Multi, typename Box,
+    bool Reverse, bool ReverseBox,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns_multi_polygon_cs
+{
+    static inline void apply(
+            int source_id1, Multi const& multi,
+            int source_id2, Box const& box,
+            Turns& turns, InterruptPolicy& interrupt_policy)
+    {
+        typedef typename boost::range_iterator
+            <
+                Multi const
+            >::type iterator_type;
+
+        int i = 0;
+        for (iterator_type it = boost::begin(multi);
+             it != boost::end(multi);
+             ++it, ++i)
+        {
+            // Call its single version
+            get_turns_polygon_cs
+                <
+                    typename boost::range_value<Multi>::type, Box,
+                    Reverse, ReverseBox,
+                    Turns, TurnPolicy, InterruptPolicy
+                >::apply(source_id1, *it, source_id2, box,
+                            turns, interrupt_policy, i);
+        }
+    }
+};
+
+}} // namespace detail::get_turns
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename MultiPolygon,
+    typename Box,
+    bool ReverseMultiPolygon, bool ReverseBox,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct get_turns
+    <
+        multi_polygon_tag, box_tag,
+        MultiPolygon, Box,
+        ReverseMultiPolygon, ReverseBox,
+        Turns,
+        TurnPolicy, InterruptPolicy
+    >
+    : detail::get_turns::get_turns_multi_polygon_cs
+        <
+            MultiPolygon, Box,
+            ReverseMultiPolygon, ReverseBox,
+            Turns,
+            TurnPolicy, InterruptPolicy
+        >
+{};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_GET_TURNS_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp b/src/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp
new file mode 100644
index 0000000..4636187
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp
@@ -0,0 +1,62 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_SELECT_RINGS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_SELECT_RINGS_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay
+{
+
+namespace dispatch
+{
+
+    template <typename Multi>
+    struct select_rings<multi_polygon_tag, Multi>
+    {
+        template <typename Geometry, typename Map>
+        static inline void apply(Multi const& multi, Geometry const& geometry,
+                    ring_identifier id, Map& map, bool midpoint)
+        {
+            typedef typename boost::range_iterator
+                <
+                    Multi const
+                >::type iterator_type;
+
+            typedef select_rings<polygon_tag, typename boost::range_value<Multi>::type> per_polygon;
+
+            id.multi_index = 0;
+            for (iterator_type it = boost::begin(multi); it != boost::end(multi); ++it)
+            {
+                id.ring_index = -1;
+                per_polygon::apply(*it, geometry, id, map, midpoint);
+                id.multi_index++;
+            }
+        }
+    };
+}
+
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_SELECT_RINGS_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp b/src/boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp
new file mode 100644
index 0000000..57d5ff9
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp
@@ -0,0 +1,56 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_SELF_TURN_POINTS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_SELF_TURN_POINTS_HPP
+
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename MultiPolygon,
+    typename Turns,
+    typename TurnPolicy,
+    typename InterruptPolicy
+>
+struct self_get_turn_points
+    <
+        multi_polygon_tag, MultiPolygon,
+        Turns,
+        TurnPolicy, InterruptPolicy
+    >
+    : detail::self_get_turn_points::get_turns
+        <
+            MultiPolygon,
+            Turns,
+            TurnPolicy,
+            InterruptPolicy
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_OVERLAY_SELF_TURN_POINTS_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/point_on_border.hpp b/src/boost/geometry/multi/algorithms/detail/point_on_border.hpp
new file mode 100644
index 0000000..ac462ed
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/point_on_border.hpp
@@ -0,0 +1,95 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_POINT_ON_BORDER_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_POINT_ON_BORDER_HPP
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/detail/point_on_border.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace point_on_border
+{
+
+
+template
+<
+    typename Point,
+    typename MultiGeometry,
+    typename Policy
+>
+struct point_on_multi
+{
+    static inline bool apply(Point& point, MultiGeometry const& multi, bool midpoint)
+    {
+        // Take a point on the first multi-geometry
+        // (i.e. the first that is not empty)
+        for (typename boost::range_iterator
+                <
+                    MultiGeometry const
+                >::type it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            if (Policy::apply(point, *it, midpoint))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+};
+
+
+
+
+}} // namespace detail::point_on_border
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template<typename Point, typename Multi>
+struct point_on_border<multi_polygon_tag, Point, Multi>
+    : detail::point_on_border::point_on_multi
+        <
+            Point,
+            Multi,
+            detail::point_on_border::point_on_polygon
+                <
+                    Point,
+                    typename boost::range_value<Multi>::type
+                >
+        >
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_POINT_ON_BORDER_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp b/src/boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp
new file mode 100644
index 0000000..28a4805
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp
@@ -0,0 +1,90 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
+
+
+#include <boost/assert.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/ring_type.hpp>
+#include <boost/geometry/algorithms/detail/sections/range_by_section.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace section
+{
+
+
+template
+<
+    typename MultiGeometry,
+    typename Section,
+    typename Policy
+>
+struct full_section_multi
+{
+    static inline typename ring_return_type<MultiGeometry const>::type apply(
+                MultiGeometry const& multi, Section const& section)
+    {
+        BOOST_ASSERT
+            (
+                section.ring_id.multi_index >= 0
+                && section.ring_id.multi_index < int(boost::size(multi))
+            );
+
+        return Policy::apply(multi[section.ring_id.multi_index], section);
+    }
+};
+
+
+}} // namespace detail::section
+#endif
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename MultiPolygon, typename Section>
+struct range_by_section<multi_polygon_tag, MultiPolygon, Section>
+    : detail::section::full_section_multi
+        <
+            MultiPolygon,
+            Section,
+            detail::section::full_section_polygon
+                <
+                    typename boost::range_value<MultiPolygon>::type,
+                    Section
+                >
+       >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
diff --git a/src/boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp b/src/boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp
new file mode 100644
index 0000000..16f70c1
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp
@@ -0,0 +1,95 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_SECTIONALIZE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_SECTIONALIZE_HPP
+
+#include <cstddef>
+#include <vector>
+
+#include <boost/concept/requires.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/detail/sections/sectionalize.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace sectionalize
+{
+
+
+template <typename MultiGeometry, typename Sections, std::size_t DimensionCount, typename Policy>
+struct sectionalize_multi
+{
+    static inline void apply(MultiGeometry const& multi, Sections& sections, ring_identifier ring_id)
+    {
+        ring_id.multi_index = 0;
+        for (typename boost::range_iterator<MultiGeometry const>::type
+                    it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it, ++ring_id.multi_index)
+        {
+            Policy::apply(*it, sections, ring_id);
+        }
+    }
+};
+
+
+}} // namespace detail::sectionalize
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+    typename MultiPolygon,
+    bool Reverse,
+    typename Sections,
+    std::size_t DimensionCount,
+    std::size_t MaxCount
+>
+struct sectionalize<multi_polygon_tag, MultiPolygon, Reverse, Sections, DimensionCount, MaxCount>
+    : detail::sectionalize::sectionalize_multi
+        <
+            MultiPolygon,
+            Sections,
+            DimensionCount,
+            detail::sectionalize::sectionalize_polygon
+                <
+                    typename boost::range_value<MultiPolygon>::type,
+                    Reverse,
+                    Sections,
+                    DimensionCount,
+                    MaxCount
+                >
+        >
+
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_SECTIONS_SECTIONALIZE_HPP
diff --git a/src/boost/geometry/multi/algorithms/distance.hpp b/src/boost/geometry/multi/algorithms/distance.hpp
new file mode 100644
index 0000000..8acb3f9
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/distance.hpp
@@ -0,0 +1,157 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP
+
+
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/geometry_id.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace distance
+{
+
+
+template<typename Geometry, typename MultiGeometry, typename Strategy>
+struct distance_single_to_multi
+    : private dispatch::distance
+      <
+          Geometry,
+          typename range_value<MultiGeometry>::type,
+          Strategy
+      >
+{
+    typedef typename strategy::distance::services::return_type<Strategy>::type return_type;
+
+    static inline return_type apply(Geometry const& geometry,
+                MultiGeometry const& multi,
+                Strategy const& strategy)
+    {
+        return_type mindist = return_type();
+        bool first = true;
+
+        for(typename range_iterator<MultiGeometry const>::type it = boost::begin(multi);
+                it != boost::end(multi);
+                ++it, first = false)
+        {
+            return_type dist = dispatch::distance
+                <
+                    Geometry,
+                    typename range_value<MultiGeometry>::type,
+                    Strategy
+                >::apply(geometry, *it, strategy);
+
+            if (first || dist < mindist)
+            {
+                mindist = dist;
+            }
+        }
+
+        return mindist;
+    }
+};
+
+template<typename Multi1, typename Multi2, typename Strategy>
+struct distance_multi_to_multi
+    : private distance_single_to_multi
+      <
+          typename range_value<Multi1>::type,
+          Multi2,
+          Strategy
+      >
+{
+    typedef typename strategy::distance::services::return_type<Strategy>::type return_type;
+
+    static inline return_type apply(Multi1 const& multi1,
+                Multi2 const& multi2, Strategy const& strategy)
+    {
+        return_type mindist = return_type();
+        bool first = true;
+
+        for(typename range_iterator<Multi1 const>::type it = boost::begin(multi1);
+                it != boost::end(multi1);
+                ++it, first = false)
+        {
+            return_type dist = distance_single_to_multi
+                <
+                    typename range_value<Multi1>::type,
+                    Multi2,
+                    Strategy
+                >::apply(*it, multi2, strategy);
+            if (first || dist < mindist)
+            {
+                mindist = dist;
+            }
+        }
+
+        return mindist;
+    }
+};
+
+
+}} // namespace detail::distance
+#endif
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename G1,
+    typename G2,
+    typename Strategy,
+    typename SingleGeometryTag
+>
+struct distance
+<
+    G1, G2, Strategy,
+    SingleGeometryTag, multi_tag, strategy_tag_distance_point_point,
+    false
+>
+    : detail::distance::distance_single_to_multi<G1, G2, Strategy>
+{};
+
+template <typename G1, typename G2, typename Strategy>
+struct distance
+<
+    G1, G2, Strategy,
+    multi_tag, multi_tag, strategy_tag_distance_point_point,
+    false
+>
+    : detail::distance::distance_multi_to_multi<G1, G2, Strategy>
+{};
+
+} // namespace dispatch
+#endif
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DISTANCE_HPP
diff --git a/src/boost/geometry/multi/algorithms/envelope.hpp b/src/boost/geometry/multi/algorithms/envelope.hpp
new file mode 100644
index 0000000..1876b5f
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/envelope.hpp
@@ -0,0 +1,117 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_ENVELOPE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_ENVELOPE_HPP
+
+#include <vector>
+
+#include <boost/range/metafunctions.hpp>
+
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/algorithms/envelope.hpp>
+
+#include <boost/geometry/multi/core/point_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+
+namespace detail { namespace envelope
+{
+
+
+template<typename MultiLinestring, typename Box>
+struct envelope_multi_linestring
+{
+    static inline void apply(MultiLinestring const& mp, Box& mbr)
+    {
+        assign_inverse(mbr);
+        for (typename boost::range_iterator<MultiLinestring const>::type
+                    it = mp.begin();
+            it != mp.end();
+            ++it)
+        {
+            envelope_range_additional(*it, mbr);
+        }
+    }
+};
+
+
+// version for multi_polygon: outer ring's of all polygons
+template<typename MultiPolygon, typename Box>
+struct envelope_multi_polygon
+{
+    static inline void apply(MultiPolygon const& mp, Box& mbr)
+    {
+        assign_inverse(mbr);
+        for (typename boost::range_const_iterator<MultiPolygon>::type
+                    it = mp.begin();
+            it != mp.end();
+            ++it)
+        {
+            envelope_range_additional(exterior_ring(*it), mbr);
+        }
+    }
+};
+
+
+}} // namespace detail::envelope
+
+#endif
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename Multi, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope<multi_point_tag, box_tag, Multi, Box, StrategyLess, StrategyGreater>
+    : detail::envelope::envelope_range<Multi, Box>
+{};
+
+template
+<
+    typename Multi, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope<multi_linestring_tag, box_tag, Multi, Box, StrategyLess, StrategyGreater>
+    : detail::envelope::envelope_multi_linestring<Multi, Box>
+{};
+
+
+template
+<
+    typename Multi, typename Box,
+    typename StrategyLess, typename StrategyGreater
+>
+struct envelope<multi_polygon_tag, box_tag, Multi, Box, StrategyLess, StrategyGreater>
+    : detail::envelope::envelope_multi_polygon<Multi, Box>
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_ENVELOPE_HPP
diff --git a/src/boost/geometry/multi/algorithms/equals.hpp b/src/boost/geometry/multi/algorithms/equals.hpp
new file mode 100644
index 0000000..a307eba
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/equals.hpp
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_EQUALS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_EQUALS_HPP
+
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/geometry_id.hpp>
+
+#include <boost/geometry/algorithms/equals.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename MultiPolygon1, typename MultiPolygon2>
+struct equals
+    <
+        multi_polygon_tag, multi_polygon_tag,
+        MultiPolygon1, MultiPolygon2,
+        2
+    >
+    : detail::equals::equals_by_collection
+        <
+            MultiPolygon1, MultiPolygon2,
+            detail::equals::area_check
+        >
+{};
+
+
+template <typename Polygon, typename MultiPolygon>
+struct equals
+    <
+        polygon_tag, multi_polygon_tag,
+        Polygon, MultiPolygon,
+        2
+    >
+    : detail::equals::equals_by_collection
+        <
+            Polygon, MultiPolygon,
+            detail::equals::area_check
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_EQUALS_HPP
+
diff --git a/src/boost/geometry/multi/algorithms/for_each.hpp b/src/boost/geometry/multi/algorithms/for_each.hpp
new file mode 100644
index 0000000..1be38e0
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/for_each.hpp
@@ -0,0 +1,129 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_FOR_EACH_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_FOR_EACH_HPP
+
+
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+
+
+#include <boost/geometry/algorithms/for_each.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace for_each
+{
+
+// Implementation of multi, for both point and segment,
+// just calling the single version.
+template
+<
+    typename MultiGeometry,
+    typename Functor,
+    bool IsConst,
+    typename Policy
+>
+struct for_each_multi
+{
+    static inline Functor apply(
+                    typename add_const_if_c<IsConst, MultiGeometry>::type& multi,
+                    Functor f)
+    {
+        for(BOOST_AUTO_TPL(it, boost::begin(multi)); it != boost::end(multi); ++it)
+        {
+            f = Policy::apply(*it, f);
+        }
+        return f;
+    }
+};
+
+
+}} // namespace detail::for_each
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    typename MultiGeometry,
+    typename Functor,
+    bool IsConst
+>
+struct for_each_point<multi_tag, MultiGeometry, Functor, IsConst>
+    : detail::for_each::for_each_multi
+        <
+            MultiGeometry,
+            Functor,
+            IsConst,
+            // Specify the dispatch of the single-version as policy
+            for_each_point
+                <
+                    typename single_tag_of
+                        <
+                            typename tag<MultiGeometry>::type
+                        >::type,
+                    typename boost::range_value<MultiGeometry>::type,
+                    Functor,
+                    IsConst
+                >
+        >
+{};
+
+
+template
+<
+    typename MultiGeometry,
+    typename Functor,
+    bool IsConst
+>
+struct for_each_segment<multi_tag, MultiGeometry, Functor, IsConst>
+    : detail::for_each::for_each_multi
+        <
+            MultiGeometry,
+            Functor,
+            IsConst,
+            // Specify the dispatch of the single-version as policy
+            for_each_segment
+                <
+                    typename single_tag_of
+                        <
+                            typename tag<MultiGeometry>::type
+                        >::type,
+                    typename boost::range_value<MultiGeometry>::type,
+                    Functor,
+                    IsConst
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_FOR_EACH_HPP
diff --git a/src/boost/geometry/multi/algorithms/intersection.hpp b/src/boost/geometry/multi/algorithms/intersection.hpp
new file mode 100644
index 0000000..31e74a7
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/intersection.hpp
@@ -0,0 +1,438 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_INTERSECTION_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_INTERSECTION_HPP
+
+
+#include <boost/geometry/multi/core/closure.hpp>
+#include <boost/geometry/multi/core/geometry_id.hpp>
+#include <boost/geometry/multi/core/is_areal.hpp>
+#include <boost/geometry/multi/core/point_order.hpp>
+#include <boost/geometry/multi/algorithms/covered_by.hpp>
+#include <boost/geometry/multi/algorithms/envelope.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/get_ring.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp>
+#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
+#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>
+
+#include <boost/geometry/algorithms/intersection.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace intersection
+{
+
+
+template
+<
+    typename MultiLinestring1, typename MultiLinestring2,
+    typename OutputIterator, typename PointOut,
+    typename Strategy
+>
+struct intersection_multi_linestring_multi_linestring_point
+{
+    static inline OutputIterator apply(MultiLinestring1 const& ml1,
+            MultiLinestring2 const& ml2, OutputIterator out,
+            Strategy const& strategy)
+    {
+        // Note, this loop is quadratic w.r.t. number of linestrings per input.
+        // Future Enhancement: first do the sections of each, then intersect.
+        for (typename boost::range_iterator
+                <
+                    MultiLinestring1 const
+                >::type it1 = boost::begin(ml1);
+            it1 != boost::end(ml1);
+            ++it1)
+        {
+            for (typename boost::range_iterator
+                    <
+                        MultiLinestring2 const
+                    >::type it2 = boost::begin(ml2);
+                it2 != boost::end(ml2);
+                ++it2)
+            {
+                out = intersection_linestring_linestring_point
+                    <
+                        typename boost::range_value<MultiLinestring1>::type,
+                        typename boost::range_value<MultiLinestring2>::type,
+                        OutputIterator, PointOut, Strategy
+                    >::apply(*it1, *it2, out, strategy);
+            }
+        }
+
+        return out;
+    }
+};
+
+
+template
+<
+    typename Linestring, typename MultiLinestring,
+    typename OutputIterator, typename PointOut,
+    typename Strategy
+>
+struct intersection_linestring_multi_linestring_point
+{
+    static inline OutputIterator apply(Linestring const& linestring,
+            MultiLinestring const& ml, OutputIterator out,
+            Strategy const& strategy)
+    {
+        for (typename boost::range_iterator
+                <
+                    MultiLinestring const
+                >::type it = boost::begin(ml);
+            it != boost::end(ml);
+            ++it)
+        {
+            out = intersection_linestring_linestring_point
+                <
+                    Linestring,
+                    typename boost::range_value<MultiLinestring>::type,
+                    OutputIterator, PointOut, Strategy
+                >::apply(linestring, *it, out, strategy);
+        }
+
+        return out;
+    }
+};
+
+
+// This loop is quite similar to the loop above, but beacuse the iterator
+// is second (above) or first (below) argument, it is not trivial to merge them.
+template
+<
+    typename MultiLinestring, typename Areal,
+    bool ReverseAreal,
+    typename OutputIterator, typename LineStringOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_of_multi_linestring_with_areal
+{
+    static inline OutputIterator apply(MultiLinestring const& ml, Areal const& areal,
+            OutputIterator out,
+            Strategy const& strategy)
+    {
+        for (typename boost::range_iterator
+                <
+                    MultiLinestring const
+                >::type it = boost::begin(ml);
+            it != boost::end(ml);
+            ++it)
+        {
+            out = intersection_of_linestring_with_areal
+                <
+                    typename boost::range_value<MultiLinestring>::type,
+                    Areal, ReverseAreal,
+                    OutputIterator, LineStringOut, OverlayType, Strategy
+                >::apply(*it, areal, out, strategy);
+        }
+
+        return out;
+
+    }
+};
+
+// This one calls the one above with reversed arguments
+template
+<
+    typename Areal, typename MultiLinestring,
+    bool ReverseAreal,
+    typename OutputIterator, typename LineStringOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_of_areal_with_multi_linestring
+{
+    static inline OutputIterator apply(Areal const& areal, MultiLinestring const& ml,
+            OutputIterator out,
+            Strategy const& strategy)
+    {
+        return intersection_of_multi_linestring_with_areal
+            <
+                MultiLinestring, Areal, ReverseAreal,
+                OutputIterator, LineStringOut,
+                OverlayType,
+                Strategy
+            >::apply(ml, areal, out, strategy);
+    }
+};
+
+
+
+template
+<
+    typename MultiLinestring, typename Box,
+    typename OutputIterator, typename LinestringOut,
+    typename Strategy
+>
+struct clip_multi_linestring
+{
+    static inline OutputIterator apply(MultiLinestring const& multi_linestring,
+            Box const& box, OutputIterator out, Strategy const& )
+    {
+        typedef typename point_type<LinestringOut>::type point_type;
+        strategy::intersection::liang_barsky<Box, point_type> lb_strategy;
+        for (typename boost::range_iterator<MultiLinestring const>::type it
+            = boost::begin(multi_linestring);
+            it != boost::end(multi_linestring); ++it)
+        {
+            out = detail::intersection::clip_range_with_box
+                <LinestringOut>(box, *it, out, lb_strategy);
+        }
+        return out;
+    }
+};
+
+
+}} // namespace detail::intersection
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+// Linear
+template
+<
+    typename MultiLinestring1, typename MultiLinestring2,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        multi_linestring_tag, multi_linestring_tag, point_tag,
+        false, false, false,
+        MultiLinestring1, MultiLinestring2,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_multi_linestring_multi_linestring_point
+            <
+                MultiLinestring1, MultiLinestring2,
+                OutputIterator, GeometryOut,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename Linestring, typename MultiLinestring,
+    typename OutputIterator, typename GeometryOut,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        linestring_tag, multi_linestring_tag, point_tag,
+        false, false, false,
+        Linestring, MultiLinestring,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_linestring_multi_linestring_point
+            <
+                Linestring, MultiLinestring,
+                OutputIterator, GeometryOut,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename MultiLinestring, typename Box,
+    bool Reverse1, bool Reverse2, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        multi_linestring_tag, box_tag, linestring_tag,
+        false, true, false,
+        MultiLinestring, Box,
+        Reverse1, Reverse2, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::clip_multi_linestring
+            <
+                MultiLinestring, Box,
+                OutputIterator, GeometryOut,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename Linestring, typename MultiPolygon,
+    bool ReverseLinestring, bool ReverseMultiPolygon, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        linestring_tag, multi_polygon_tag, linestring_tag,
+        false, true, false,
+        Linestring, MultiPolygon,
+        ReverseLinestring, ReverseMultiPolygon, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_linestring_with_areal
+            <
+                Linestring, MultiPolygon,
+                ReverseMultiPolygon,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+
+// Derives from areal/mls because runtime arguments are in that order.
+// areal/mls reverses it itself to mls/areal
+template
+<
+    typename Polygon, typename MultiLinestring,
+    bool ReversePolygon, bool ReverseMultiLinestring, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        polygon_tag, multi_linestring_tag, linestring_tag,
+        true, false, false,
+        Polygon, MultiLinestring,
+        ReversePolygon, ReverseMultiLinestring, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_areal_with_multi_linestring
+            <
+                Polygon, MultiLinestring,
+                ReversePolygon,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+
+template
+<
+    typename MultiLinestring, typename Ring,
+    bool ReverseMultiLinestring, bool ReverseRing, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        multi_linestring_tag, ring_tag, linestring_tag,
+        false, true, false,
+        MultiLinestring, Ring,
+        ReverseMultiLinestring, ReverseRing, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_multi_linestring_with_areal
+            <
+                MultiLinestring, Ring,
+                ReverseRing,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+template
+<
+    typename MultiLinestring, typename Polygon,
+    bool ReverseMultiLinestring, bool ReverseRing, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        multi_linestring_tag, polygon_tag, linestring_tag,
+        false, true, false,
+        MultiLinestring, Polygon,
+        ReverseMultiLinestring, ReverseRing, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_multi_linestring_with_areal
+            <
+                MultiLinestring, Polygon,
+                ReverseRing,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+
+
+template
+<
+    typename MultiLinestring, typename MultiPolygon,
+    bool ReverseMultiLinestring, bool ReverseMultiPolygon, bool ReverseOut,
+    typename OutputIterator, typename GeometryOut,
+    overlay_type OverlayType,
+    typename Strategy
+>
+struct intersection_insert
+    <
+        multi_linestring_tag, multi_polygon_tag, linestring_tag,
+        false, true, false,
+        MultiLinestring, MultiPolygon,
+        ReverseMultiLinestring, ReverseMultiPolygon, ReverseOut,
+        OutputIterator, GeometryOut,
+        OverlayType,
+        Strategy
+    > : detail::intersection::intersection_of_multi_linestring_with_areal
+            <
+                MultiLinestring, MultiPolygon,
+                ReverseMultiPolygon,
+                OutputIterator, GeometryOut,
+                OverlayType,
+                Strategy
+            >
+{};
+
+
+} // namespace dispatch
+#endif
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_INTERSECTION_HPP
+
diff --git a/src/boost/geometry/multi/algorithms/length.hpp b/src/boost/geometry/multi/algorithms/length.hpp
new file mode 100644
index 0000000..51ff9ef
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/length.hpp
@@ -0,0 +1,57 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_LENGTH_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_LENGTH_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/length.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/algorithms/detail/multi_sum.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiLinestring, typename Strategy>
+struct length<multi_linestring_tag, MultiLinestring, Strategy>
+    : detail::multi_sum
+        <
+            typename default_length_result<MultiLinestring>::type,
+            MultiLinestring,
+            Strategy,
+            detail::length::range_length
+                <
+                    typename boost::range_value<MultiLinestring>::type,
+                    Strategy,
+                    closed // no need to close it explicitly
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_LENGTH_HPP
diff --git a/src/boost/geometry/multi/algorithms/num_geometries.hpp b/src/boost/geometry/multi/algorithms/num_geometries.hpp
new file mode 100644
index 0000000..213339a
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/num_geometries.hpp
@@ -0,0 +1,51 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_GEOMETRIES_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_GEOMETRIES_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/num_geometries.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiGeometry>
+struct num_geometries<multi_tag, MultiGeometry>
+{
+    static inline std::size_t apply(MultiGeometry const& multi_geometry)
+    {
+        return boost::size(multi_geometry);
+    }
+};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_GEOMETRIES_HPP
diff --git a/src/boost/geometry/multi/algorithms/num_interior_rings.hpp b/src/boost/geometry/multi/algorithms/num_interior_rings.hpp
new file mode 100644
index 0000000..87b0bde
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/num_interior_rings.hpp
@@ -0,0 +1,61 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/algorithms/num_interior_rings.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename MultiPolygon>
+struct num_interior_rings<multi_polygon_tag, MultiPolygon>
+{
+    static inline std::size_t apply(MultiPolygon const& multi_polygon)
+    {
+        std::size_t n = 0;
+        for (typename boost::range_iterator<MultiPolygon const>::type
+            it = boost::begin(multi_polygon);
+            it != boost::end(multi_polygon);
+            ++it)
+        {
+            n += geometry::num_interior_rings(*it);
+        }
+        return n;
+    }
+
+};
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
diff --git a/src/boost/geometry/multi/algorithms/num_points.hpp b/src/boost/geometry/multi/algorithms/num_points.hpp
new file mode 100644
index 0000000..5ea5385
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/num_points.hpp
@@ -0,0 +1,81 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/num_points.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace num_points
+{
+
+
+template <typename MultiGeometry>
+struct multi_count
+{
+    static inline size_t apply(MultiGeometry const& geometry, bool add_for_open)
+    {
+        typedef typename boost::range_value<MultiGeometry>::type geometry_type;
+        typedef typename boost::range_iterator
+            <
+                MultiGeometry const
+            >::type iterator_type;
+
+        std::size_t n = 0;
+        for (iterator_type it = boost::begin(geometry);
+            it != boost::end(geometry);
+            ++it)
+        {
+            n += dispatch::num_points
+                <
+                    typename tag<geometry_type>::type,
+                    geometry_type
+                >::apply(*it, add_for_open);
+        }
+        return n;
+    }
+};
+
+
+}} // namespace detail::num_points
+#endif
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Geometry>
+struct num_points<multi_tag, Geometry>
+    : detail::num_points::multi_count<Geometry> {};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
diff --git a/src/boost/geometry/multi/algorithms/perimeter.hpp b/src/boost/geometry/multi/algorithms/perimeter.hpp
new file mode 100644
index 0000000..147f6fc
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/perimeter.hpp
@@ -0,0 +1,56 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_PERIMETER_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_PERIMETER_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/perimeter.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/multi/algorithms/detail/multi_sum.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+template <typename MultiPolygon, typename Strategy>
+struct perimeter<multi_polygon_tag, MultiPolygon, Strategy>
+    : detail::multi_sum
+        <
+            typename default_length_result<MultiPolygon>::type,
+            MultiPolygon,
+            Strategy,
+            perimeter
+                <
+                    polygon_tag,
+                    typename boost::range_value<MultiPolygon>::type,
+                    Strategy
+                >
+        >
+{};
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_PERIMETER_HPP
diff --git a/src/boost/geometry/multi/algorithms/reverse.hpp b/src/boost/geometry/multi/algorithms/reverse.hpp
new file mode 100644
index 0000000..f8a9442
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/reverse.hpp
@@ -0,0 +1,69 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_REVERSE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_REVERSE_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/reverse.hpp>
+#include <boost/geometry/multi/algorithms/detail/modify.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Geometry>
+struct reverse<multi_linestring_tag, Geometry>
+    : detail::multi_modify
+        <
+            Geometry,
+            detail::reverse::range_reverse
+                <
+                    typename boost::range_value<Geometry>::type
+                >
+        >
+{};
+
+
+template <typename Geometry>
+struct reverse<multi_polygon_tag, Geometry>
+    : detail::multi_modify
+        <
+            Geometry,
+            detail::reverse::polygon_reverse
+                <
+                    typename boost::range_value<Geometry>::type
+                >
+        >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_REVERSE_HPP
diff --git a/src/boost/geometry/multi/algorithms/simplify.hpp b/src/boost/geometry/multi/algorithms/simplify.hpp
new file mode 100644
index 0000000..dc3c7b5
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/simplify.hpp
@@ -0,0 +1,117 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_SIMPLIFY_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_SIMPLIFY_HPP
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+#include <boost/geometry/multi/algorithms/clear.hpp>
+#include <boost/geometry/algorithms/simplify.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace simplify
+{
+
+template<typename MultiGeometry, typename Strategy, typename Policy>
+struct simplify_multi
+{
+    static inline void apply(MultiGeometry const& multi, MultiGeometry& out,
+                    double max_distance, Strategy const& strategy)
+    {
+        traits::resize<MultiGeometry>::apply(out, boost::size(multi));
+
+        typename boost::range_iterator<MultiGeometry>::type it_out
+                = boost::begin(out);
+        for (typename boost::range_iterator<MultiGeometry const>::type it_in
+                    = boost::begin(multi);
+            it_in != boost::end(multi);
+            ++it_in, ++it_out)
+        {
+            Policy::apply(*it_in, *it_out, max_distance, strategy);
+        }
+    }
+};
+
+
+
+}} // namespace detail::simplify
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiPoint, typename Strategy>
+struct simplify<multi_point_tag, MultiPoint, Strategy>
+    : detail::simplify::simplify_copy
+        <
+            MultiPoint,
+            Strategy
+        >
+
+{};
+
+
+template <typename MultiLinestring, typename Strategy>
+struct simplify<multi_linestring_tag, MultiLinestring, Strategy>
+    : detail::simplify::simplify_multi
+        <
+            MultiLinestring,
+            Strategy,
+            detail::simplify::simplify_range
+                <
+                    typename boost::range_value<MultiLinestring>::type,
+                    Strategy,
+                    2
+                >
+        >
+
+{};
+
+
+template <typename MultiPolygon, typename Strategy>
+struct simplify<multi_polygon_tag, MultiPolygon, Strategy>
+    : detail::simplify::simplify_multi
+        <
+            MultiPolygon,
+            Strategy,
+            detail::simplify::simplify_polygon
+                <
+                    typename boost::range_value<MultiPolygon>::type,
+                    Strategy
+                >
+        >
+
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_SIMPLIFY_HPP
diff --git a/src/boost/geometry/multi/algorithms/transform.hpp b/src/boost/geometry/multi/algorithms/transform.hpp
new file mode 100644
index 0000000..0992677
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/transform.hpp
@@ -0,0 +1,102 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_TRANSFORM_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_TRANSFORM_HPP
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/algorithms/transform.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace transform
+{
+
+/*!
+    \brief Is able to transform any multi-geometry, calling the single-version as policy
+*/
+template <typename Multi1, typename Multi2, typename Policy>
+struct transform_multi
+{
+    template <typename S>
+    static inline bool apply(Multi1 const& multi1, Multi2& multi2, S const& strategy)
+    {
+        traits::resize<Multi2>::apply(multi2, boost::size(multi1));
+
+        typename boost::range_iterator<Multi1 const>::type it1
+                = boost::begin(multi1);
+        typename boost::range_iterator<Multi2>::type it2
+                = boost::begin(multi2);
+
+        for (; it1 != boost::end(multi1); ++it1, ++it2)
+        {
+            if (! Policy::apply(*it1, *it2, strategy))
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+};
+
+
+}} // namespace detail::transform
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Multi1, typename Multi2, typename Strategy>
+struct transform
+    <
+        multi_tag, multi_tag,
+        Multi1, Multi2,
+        Strategy
+    >
+    : detail::transform::transform_multi
+        <
+            Multi1,
+            Multi2,
+            transform
+                <
+                    typename single_tag_of
+                                <
+                                    typename tag<Multi1>::type
+                                >::type,
+                    typename single_tag_of
+                                <
+                                    typename tag<Multi2>::type
+                                >::type,
+                    typename boost::range_value<Multi1>::type,
+                    typename boost::range_value<Multi2>::type,
+                    Strategy
+                >
+        >
+{};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_TRANSFORM_HPP
diff --git a/src/boost/geometry/multi/algorithms/unique.hpp b/src/boost/geometry/multi/algorithms/unique.hpp
new file mode 100644
index 0000000..5067e71
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/unique.hpp
@@ -0,0 +1,102 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/unique.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace unique
+{
+
+
+template <typename MultiGeometry, typename ComparePolicy, typename Policy>
+struct multi_unique
+{
+    static inline void apply(MultiGeometry& multi, ComparePolicy const& compare)
+    {
+        for (typename boost::range_iterator<MultiGeometry>::type
+                it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            Policy::apply(*it, compare);
+        }
+    }
+};
+
+
+}} // namespace detail::unique
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+// For points, unique is not applicable and does nothing
+// (Note that it is not "spatially unique" but that it removes duplicate coordinates,
+//  like std::unique does). Spatially unique is "dissolve" which can (or will be)
+//  possible for multi-points as well, removing points at the same location.
+
+
+template <typename MultiLineString, typename ComparePolicy>
+struct unique<multi_linestring_tag, MultiLineString, ComparePolicy>
+    : detail::unique::multi_unique
+        <
+            MultiLineString,
+            ComparePolicy,
+            detail::unique::range_unique
+            <
+                typename boost::range_value<MultiLineString>::type,
+                ComparePolicy
+            >
+        >
+{};
+
+
+template <typename MultiPolygon, typename ComparePolicy>
+struct unique<multi_polygon_tag, MultiPolygon, ComparePolicy>
+    : detail::unique::multi_unique
+        <
+            MultiPolygon,
+            ComparePolicy,
+            detail::unique::polygon_unique
+            <
+                typename boost::range_value<MultiPolygon>::type,
+                ComparePolicy
+            >
+        >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
diff --git a/src/boost/geometry/multi/algorithms/within.hpp b/src/boost/geometry/multi/algorithms/within.hpp
new file mode 100644
index 0000000..a3ec751
--- /dev/null
+++ b/src/boost/geometry/multi/algorithms/within.hpp
@@ -0,0 +1,104 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_WITHIN_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_WITHIN_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/algorithms/within.hpp>
+#include <boost/geometry/multi/core/closure.hpp>
+#include <boost/geometry/multi/core/point_order.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace within
+{
+
+
+template
+<
+    typename Geometry,
+    typename MultiGeometry,
+    typename Strategy,
+    typename Policy
+>
+struct geometry_multi_within_code
+{
+    static inline int apply(Geometry const& geometry,
+            MultiGeometry const& multi,
+            Strategy const& strategy)
+    {
+        for (typename boost::range_iterator<MultiGeometry const>::type it
+                    = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            // Geometry coding on multi: 1 (within) if within one of them;
+            // 0 (touch) if on border of one of them
+            int const code = Policy::apply(geometry, *it, strategy);
+            if (code != -1)
+            {
+                return code;
+            }
+        }
+        return -1;
+    }
+};
+
+
+}} // namespace detail::within
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Point, typename MultiPolygon>
+struct within<Point, MultiPolygon, point_tag, multi_polygon_tag>
+{
+    template <typename Strategy>
+    static inline bool apply(Point const& point, 
+                MultiPolygon const& multi_polygon, Strategy const& strategy)
+    {
+        return detail::within::geometry_multi_within_code
+            <
+                Point,
+                MultiPolygon,
+                Strategy,
+                detail::within::point_in_polygon
+                        <
+                            Point,
+                            typename boost::range_value<MultiPolygon>::type,
+                            order_as_direction
+                                <
+                                    geometry::point_order<MultiPolygon>::value
+                                >::value,
+                            geometry::closure<MultiPolygon>::value,
+                            Strategy
+                        >
+            >::apply(point, multi_polygon, strategy) == 1;
+    }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_WITHIN_HPP
diff --git a/src/boost/geometry/multi/core/closure.hpp b/src/boost/geometry/multi/core/closure.hpp
new file mode 100644
index 0000000..3964db2
--- /dev/null
+++ b/src/boost/geometry/multi/core/closure.hpp
@@ -0,0 +1,58 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_CLOSURE_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_CLOSURE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/range.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Multi>
+struct closure<multi_point_tag, Multi> : public core_detail::closure::closed {};
+
+template <typename Multi>
+struct closure<multi_linestring_tag, Multi> : public core_detail::closure::closed {};
+
+// Specialization for polygon: the closure is the closure of its rings
+template <typename MultiPolygon>
+struct closure<multi_polygon_tag, MultiPolygon>
+{
+    static const closure_selector value = core_dispatch::closure
+        <
+            polygon_tag,
+            typename boost::range_value<MultiPolygon>::type
+        >::value ;
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_CLOSURE_HPP
diff --git a/src/boost/geometry/multi/core/geometry_id.hpp b/src/boost/geometry/multi/core/geometry_id.hpp
new file mode 100644
index 0000000..9d69cb2
--- /dev/null
+++ b/src/boost/geometry/multi/core/geometry_id.hpp
@@ -0,0 +1,56 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_GEOMETRY_ID_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_GEOMETRY_ID_HPP
+
+
+#include <boost/mpl/int.hpp>
+#include <boost/type_traits.hpp>
+
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/core/geometry_id.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <>
+struct geometry_id<multi_point_tag>      : boost::mpl::int_<4> {};
+
+
+template <>
+struct geometry_id<multi_linestring_tag> : boost::mpl::int_<5> {};
+
+
+template <>
+struct geometry_id<multi_polygon_tag>    : boost::mpl::int_<6> {};
+
+
+} // namespace core_dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_GEOMETRY_ID_HPP
diff --git a/src/boost/geometry/multi/core/interior_rings.hpp b/src/boost/geometry/multi/core/interior_rings.hpp
new file mode 100644
index 0000000..5a200d4
--- /dev/null
+++ b/src/boost/geometry/multi/core/interior_rings.hpp
@@ -0,0 +1,55 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_INTERIOR_RINGS_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_INTERIOR_RINGS_HPP
+
+
+#include <cstddef>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename MultiPolygon>
+struct interior_type<multi_polygon_tag, MultiPolygon>
+{
+    typedef typename core_dispatch::interior_type
+        <
+            polygon_tag,
+            typename boost::range_value<MultiPolygon>::type
+        >::type type;
+};
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_INTERIOR_RINGS_HPP
diff --git a/src/boost/geometry/multi/core/is_areal.hpp b/src/boost/geometry/multi/core/is_areal.hpp
new file mode 100644
index 0000000..ad8daeb
--- /dev/null
+++ b/src/boost/geometry/multi/core/is_areal.hpp
@@ -0,0 +1,43 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_IS_AREAL_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_IS_AREAL_HPP
+
+
+#include <boost/type_traits.hpp>
+
+
+#include <boost/geometry/core/is_areal.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <> struct is_areal<multi_polygon_tag> : boost::true_type {};
+
+} // namespace core_dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_IS_AREAL_HPP
diff --git a/src/boost/geometry/multi/core/point_order.hpp b/src/boost/geometry/multi/core/point_order.hpp
new file mode 100644
index 0000000..6b08468
--- /dev/null
+++ b/src/boost/geometry/multi/core/point_order.hpp
@@ -0,0 +1,57 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_POINT_ORDER_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_POINT_ORDER_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Multi>
+struct point_order<multi_point_tag, Multi>
+    : public detail::point_order::clockwise {};
+
+template <typename Multi>
+struct point_order<multi_linestring_tag, Multi>
+    : public detail::point_order::clockwise {};
+
+
+// Specialization for multi_polygon: the order is the order of its polygons
+template <typename MultiPolygon>
+struct point_order<multi_polygon_tag, MultiPolygon>
+{
+    static const order_selector value = core_dispatch::point_order
+        <
+            polygon_tag,
+            typename boost::range_value<MultiPolygon>::type
+        >::value ;
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_POINT_ORDER_HPP
diff --git a/src/boost/geometry/multi/core/point_type.hpp b/src/boost/geometry/multi/core/point_type.hpp
new file mode 100644
index 0000000..3c77e97
--- /dev/null
+++ b/src/boost/geometry/multi/core/point_type.hpp
@@ -0,0 +1,64 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_POINT_TYPE_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_POINT_TYPE_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename MultiPoint>
+struct point_type<multi_point_tag, MultiPoint>
+{
+    typedef typename boost::range_value<MultiPoint>::type type;
+};
+
+
+template <typename MultiLinestring>
+struct point_type<multi_linestring_tag, MultiLinestring>
+{
+    typedef typename point_type<linestring_tag,
+        typename boost::range_value<MultiLinestring>::type>::type type;
+};
+
+
+
+template <typename MultiPolygon>
+struct point_type<multi_polygon_tag, MultiPolygon>
+{
+    typedef typename point_type<polygon_tag,
+        typename boost::range_value<MultiPolygon>::type>::type type;
+};
+
+
+}
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_POINT_TYPE_HPP
diff --git a/src/boost/geometry/multi/core/ring_type.hpp b/src/boost/geometry/multi/core/ring_type.hpp
new file mode 100644
index 0000000..faafaed
--- /dev/null
+++ b/src/boost/geometry/multi/core/ring_type.hpp
@@ -0,0 +1,66 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_RING_TYPE_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_RING_TYPE_HPP
+
+
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename MultiPolygon>
+struct ring_return_type<multi_polygon_tag, MultiPolygon>
+{
+    typedef typename ring_return_type
+        <
+            polygon_tag,
+            typename mpl::if_
+                <
+                    boost::is_const<MultiPolygon>,
+                    typename boost::range_value<MultiPolygon>::type const,
+                    typename boost::range_value<MultiPolygon>::type
+                >::type
+        >::type type;
+};
+
+
+template <typename MultiPolygon>
+struct ring_type<multi_polygon_tag, MultiPolygon>
+{
+    typedef typename boost::remove_reference
+        <
+            typename ring_return_type<multi_polygon_tag, MultiPolygon>::type
+        >::type type;
+};
+
+
+} // namespace core_dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_RING_TYPE_HPP
diff --git a/src/boost/geometry/multi/core/tags.hpp b/src/boost/geometry/multi/core/tags.hpp
new file mode 100644
index 0000000..dcfca65
--- /dev/null
+++ b/src/boost/geometry/multi/core/tags.hpp
@@ -0,0 +1,71 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_TAGS_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_TAGS_HPP
+
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+/// OGC Multi point identifying tag
+struct multi_point_tag : multi_tag, pointlike_tag  {};
+
+/// OGC Multi linestring identifying tag
+struct multi_linestring_tag : multi_tag, linear_tag {};
+
+/// OGC Multi polygon identifying tag
+struct multi_polygon_tag : multi_tag, polygonal_tag {};
+
+/// OGC Geometry Collection identifying tag
+struct geometry_collection_tag : multi_tag {};
+
+
+
+
+/*!
+\brief Meta-function to get for a tag of a multi-geometry
+    the tag of the corresponding single-geometry
+*/
+template <typename Tag>
+struct single_tag_of
+{};
+
+#ifndef DOXYGEN_NO_DETAIL
+
+template <>
+struct single_tag_of<multi_point_tag>
+{
+    typedef point_tag type;
+};
+
+template <>
+struct single_tag_of<multi_linestring_tag>
+{
+    typedef linestring_tag type;
+};
+
+template <>
+struct single_tag_of<multi_polygon_tag>
+{
+    typedef polygon_tag type;
+};
+
+#endif
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_TAGS_HPP
diff --git a/src/boost/geometry/multi/core/topological_dimension.hpp b/src/boost/geometry/multi/core/topological_dimension.hpp
new file mode 100644
index 0000000..55118f1
--- /dev/null
+++ b/src/boost/geometry/multi/core/topological_dimension.hpp
@@ -0,0 +1,52 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_TOPOLOGICAL_DIMENSION_HPP
+#define BOOST_GEOMETRY_MULTI_TOPOLOGICAL_DIMENSION_HPP
+
+
+#include <boost/mpl/int.hpp>
+
+
+#include <boost/geometry/core/topological_dimension.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <>
+struct top_dim<multi_point_tag> : boost::mpl::int_<0> {};
+
+
+template <>
+struct top_dim<multi_linestring_tag> : boost::mpl::int_<1> {};
+
+
+template <>
+struct top_dim<multi_polygon_tag> : boost::mpl::int_<2> {};
+
+
+} // namespace core_dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif
diff --git a/src/boost/geometry/multi/geometries/concepts/check.hpp b/src/boost/geometry/multi/geometries/concepts/check.hpp
new file mode 100644
index 0000000..18f4ff0
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/concepts/check.hpp
@@ -0,0 +1,83 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_CHECK_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_CHECK_HPP
+
+
+
+#include <boost/type_traits/is_const.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/multi/geometries/concepts/multi_point_concept.hpp>
+#include <boost/geometry/multi/geometries/concepts/multi_linestring_concept.hpp>
+#include <boost/geometry/multi/geometries/concepts/multi_polygon_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Geometry>
+struct check<multi_point_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstMultiPoint<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<multi_point_tag, Geometry, false>
+    : detail::concept_check::check<concept::MultiPoint<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<multi_linestring_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstMultiLinestring<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<multi_linestring_tag, Geometry, false>
+    : detail::concept_check::check<concept::MultiLinestring<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<multi_polygon_tag, Geometry, true>
+    : detail::concept_check::check<concept::ConstMultiPolygon<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<multi_polygon_tag, Geometry, false>
+    : detail::concept_check::check<concept::MultiPolygon<Geometry> >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_CHECK_HPP
diff --git a/src/boost/geometry/multi/geometries/concepts/multi_linestring_concept.hpp b/src/boost/geometry/multi/geometries/concepts/multi_linestring_concept.hpp
new file mode 100644
index 0000000..b0519f0
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/concepts/multi_linestring_concept.hpp
@@ -0,0 +1,86 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_LINESTRING_CONCEPT_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_LINESTRING_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/metafunctions.hpp>
+
+
+#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief multi-linestring concept
+\ingroup concepts
+\par Formal definition:
+The multi linestring concept is defined as following:
+- there must be a specialization of traits::tag defining multi_linestring_tag as
+  type
+- it must behave like a Boost.Range
+- its range value must fulfil the Linestring concept
+
+*/
+template <typename Geometry>
+class MultiLinestring
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::range_value<Geometry>::type linestring_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Linestring<linestring_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(MultiLinestring)
+    {
+    }
+#endif
+};
+
+
+/*!
+\brief concept for multi-linestring (const version)
+\ingroup const_concepts
+*/
+template <typename Geometry>
+class ConstMultiLinestring
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::range_value<Geometry>::type linestring_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstLinestring<linestring_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstMultiLinestring)
+    {
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_LINESTRING_CONCEPT_HPP
diff --git a/src/boost/geometry/multi/geometries/concepts/multi_point_concept.hpp b/src/boost/geometry/multi/geometries/concepts/multi_point_concept.hpp
new file mode 100644
index 0000000..f5942df
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/concepts/multi_point_concept.hpp
@@ -0,0 +1,85 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_POINT_CONCEPT_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_POINT_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/metafunctions.hpp>
+
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief MultiPoint concept
+\ingroup concepts
+\par Formal definition:
+The multi point concept is defined as following:
+- there must be a specialization of traits::tag defining multi_point_tag as type
+- it must behave like a Boost.Range
+- its range value must fulfil the Point concept
+
+*/
+template <typename Geometry>
+class MultiPoint
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::range_value<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(MultiPoint)
+    {
+    }
+#endif
+};
+
+
+/*!
+\brief concept for multi-point (const version)
+\ingroup const_concepts
+*/
+template <typename Geometry>
+class ConstMultiPoint
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::range_value<Geometry>::type point_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstMultiPoint)
+    {
+    }
+#endif
+};
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_POINT_CONCEPT_HPP
diff --git a/src/boost/geometry/multi/geometries/concepts/multi_polygon_concept.hpp b/src/boost/geometry/multi/geometries/concepts/multi_polygon_concept.hpp
new file mode 100644
index 0000000..ca730d4
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/concepts/multi_polygon_concept.hpp
@@ -0,0 +1,86 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_POLYGON_CONCEPT_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_POLYGON_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/geometries/concepts/polygon_concept.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief multi-polygon concept
+\ingroup concepts
+\par Formal definition:
+The multi polygon concept is defined as following:
+- there must be a specialization of traits::tag defining multi_polygon_tag
+  as type
+- it must behave like a Boost.Range
+- its range value must fulfil the Polygon concept
+
+*/
+template <typename Geometry>
+class MultiPolygon
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::range_value<Geometry>::type polygon_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::Polygon<polygon_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(MultiPolygon)
+    {
+    }
+#endif
+};
+
+
+/*!
+\brief concept for multi-polygon (const version)
+\ingroup const_concepts
+*/
+template <typename Geometry>
+class ConstMultiPolygon
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+    typedef typename boost::range_value<Geometry>::type polygon_type;
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstPolygon<polygon_type>) );
+    BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
+
+public :
+
+    BOOST_CONCEPT_USAGE(ConstMultiPolygon)
+    {
+    }
+#endif
+};
+
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_CONCEPTS_MULTI_POLYGON_CONCEPT_HPP
diff --git a/src/boost/geometry/multi/geometries/multi_geometries.hpp b/src/boost/geometry/multi/geometries/multi_geometries.hpp
new file mode 100644
index 0000000..90cf85a
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/multi_geometries.hpp
@@ -0,0 +1,21 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_GEOMETRIES_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_GEOMETRIES_HPP
+
+#include <boost/geometry/multi/geometries/multi_point.hpp>
+#include <boost/geometry/multi/geometries/multi_linestring.hpp>
+#include <boost/geometry/multi/geometries/multi_polygon.hpp>
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_GEOMETRIES_HPP
diff --git a/src/boost/geometry/multi/geometries/multi_linestring.hpp b/src/boost/geometry/multi/geometries/multi_linestring.hpp
new file mode 100644
index 0000000..67d4da0
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/multi_linestring.hpp
@@ -0,0 +1,80 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_LINESTRING_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_LINESTRING_HPP
+
+#include <memory>
+#include <vector>
+
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+namespace model
+{
+
+/*!
+\brief multi_line, a collection of linestring
+\details Multi-linestring can be used to group lines belonging to each other,
+        e.g. a highway (with interruptions)
+\ingroup geometries
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_multi_linestring MultiLineString Concept]
+}
+*/
+template
+<
+    typename LineString,
+    template<typename, typename> class Container = std::vector,
+    template<typename> class Allocator = std::allocator
+>
+class multi_linestring : public Container<LineString, Allocator<LineString> >
+{
+    BOOST_CONCEPT_ASSERT( (concept::Linestring<LineString>) );
+};
+
+
+} // namespace model
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename LineString,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct tag< model::multi_linestring<LineString, Container, Allocator> >
+{
+    typedef multi_linestring_tag type;
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_LINESTRING_HPP
diff --git a/src/boost/geometry/multi/geometries/multi_point.hpp b/src/boost/geometry/multi/geometries/multi_point.hpp
new file mode 100644
index 0000000..002d8f8
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/multi_point.hpp
@@ -0,0 +1,94 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_POINT_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_POINT_HPP
+
+#include <memory>
+#include <vector>
+
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+
+/*!
+\brief multi_point, a collection of points
+\ingroup geometries
+\tparam Point \tparam_point
+\tparam Container \tparam_container
+\tparam Allocator \tparam_allocator
+\details Multipoint can be used to group points belonging to each other,
+        e.g. a constellation, or the result set of an intersection
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_multi_point MultiPoint Concept]
+}
+*/
+template
+<
+    typename Point,
+    template<typename, typename> class Container = std::vector,
+    template<typename> class Allocator = std::allocator
+>
+class multi_point : public Container<Point, Allocator<Point> >
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    typedef Container<Point, Allocator<Point> > base_type;
+
+public :
+    /// \constructor_default{multi_point}
+    inline multi_point()
+        : base_type()
+    {}
+
+    /// \constructor_begin_end{multi_point}
+    template <typename Iterator>
+    inline multi_point(Iterator begin, Iterator end)
+        : base_type(begin, end)
+    {}
+};
+
+} // namespace model
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename Point,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct tag< model::multi_point<Point, Container, Allocator> >
+{
+    typedef multi_point_tag type;
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_POINT_HPP
diff --git a/src/boost/geometry/multi/geometries/multi_polygon.hpp b/src/boost/geometry/multi/geometries/multi_polygon.hpp
new file mode 100644
index 0000000..af8d042
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/multi_polygon.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_POLYGON_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_POLYGON_HPP
+
+#include <memory>
+#include <vector>
+
+#include <boost/concept/requires.hpp>
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+#include <boost/geometry/geometries/concepts/polygon_concept.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace model
+{
+
+/*!
+\brief multi_polygon, a collection of polygons
+\details Multi-polygon can be used to group polygons belonging to each other,
+        e.g. Hawaii
+\ingroup geometries
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_multi_polygon MultiPolygon Concept]
+}
+*/
+template
+<
+    typename Polygon,
+    template<typename, typename> class Container = std::vector,
+    template<typename> class Allocator = std::allocator
+>
+class multi_polygon : public Container<Polygon, Allocator<Polygon> >
+{
+    BOOST_CONCEPT_ASSERT( (concept::Polygon<Polygon>) );
+};
+
+
+} // namespace model
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template
+<
+    typename Polygon,
+    template<typename, typename> class Container,
+    template<typename> class Allocator
+>
+struct tag< model::multi_polygon<Polygon, Container, Allocator> >
+{
+    typedef multi_polygon_tag type;
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_MULTI_POLYGON_HPP
diff --git a/src/boost/geometry/multi/geometries/register/multi_linestring.hpp b/src/boost/geometry/multi/geometries/register/multi_linestring.hpp
new file mode 100644
index 0000000..5ececdb
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/register/multi_linestring.hpp
@@ -0,0 +1,59 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_LINESTRING_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_LINESTRING_HPP
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+/*!
+\brief \brief_macro{multi_linestring}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING, multi_linestring} The 
+    multi_linestring may contain template parameters, which must be specified then.
+\param MultiLineString \param_macro_type{multi_linestring}
+
+\qbk{
+[heading Example]
+[register_multi_linestring]
+[register_multi_linestring_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(MultiLineString) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<> struct tag<MultiLineString> { typedef multi_linestring_tag type; }; \
+}}}
+
+
+/*!
+\brief \brief_macro{templated multi_linestring}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING_TEMPLATED, templated multi_linestring} 
+    \details_macro_templated{multi_linestring, linestring}
+\param MultiLineString \param_macro_type{multi_linestring (without template parameters)}
+
+\qbk{
+[heading Example]
+[register_multi_linestring_templated]
+[register_multi_linestring_templated_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING_TEMPLATED(MultiLineString) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<typename LineString> struct tag< MultiLineString<LineString> > { typedef multi_linestring_tag type; }; \
+}}}
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_LINESTRING_HPP
diff --git a/src/boost/geometry/multi/geometries/register/multi_point.hpp b/src/boost/geometry/multi/geometries/register/multi_point.hpp
new file mode 100644
index 0000000..813f547
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/register/multi_point.hpp
@@ -0,0 +1,59 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_POINT_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_POINT_HPP
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+/*!
+\brief \brief_macro{multi_point}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_MULTI_POINT, multi_point} The 
+    multi_point may contain template parameters, which must be specified then.
+\param MultiPoint \param_macro_type{multi_point}
+
+\qbk{
+[heading Example]
+[register_multi_point]
+[register_multi_point_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_MULTI_POINT(MultiPoint) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<> struct tag<MultiPoint> { typedef multi_point_tag type; }; \
+}}}
+
+
+/*!
+\brief \brief_macro{templated multi_point}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED, templated multi_point} 
+    \details_macro_templated{multi_point, point}
+\param MultiPoint \param_macro_type{multi_point (without template parameters)}
+
+\qbk{
+[heading Example]
+[register_multi_point_templated]
+[register_multi_point_templated_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(MultiPoint) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<typename Point> struct tag< MultiPoint<Point> > { typedef multi_point_tag type; }; \
+}}}
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_POINT_HPP
diff --git a/src/boost/geometry/multi/geometries/register/multi_polygon.hpp b/src/boost/geometry/multi/geometries/register/multi_polygon.hpp
new file mode 100644
index 0000000..801b98c
--- /dev/null
+++ b/src/boost/geometry/multi/geometries/register/multi_polygon.hpp
@@ -0,0 +1,59 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_POLYGON_HPP
+#define BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_POLYGON_HPP
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+/*!
+\brief \brief_macro{multi_polygon}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_MULTI_POLYGON, multi_polygon} The 
+    multi_polygon may contain template parameters, which must be specified then.
+\param MultiPolygon \param_macro_type{multi_polygon}
+
+\qbk{
+[heading Example]
+[register_multi_polygon]
+[register_multi_polygon_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(MultiPolygon) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<> struct tag<MultiPolygon> { typedef multi_polygon_tag type; }; \
+}}}
+
+
+/*!
+\brief \brief_macro{templated multi_polygon}
+\ingroup register
+\details \details_macro{BOOST_GEOMETRY_REGISTER_MULTI_POLYGON_TEMPLATED, templated multi_polygon} 
+    \details_macro_templated{multi_polygon, polygon}
+\param MultiPolygon \param_macro_type{multi_polygon (without template parameters)}
+
+\qbk{
+[heading Example]
+[register_multi_polygon_templated]
+[register_multi_polygon_templated_output]
+}
+*/
+#define BOOST_GEOMETRY_REGISTER_MULTI_POLYGON_TEMPLATED(MultiPolygon) \
+namespace boost { namespace geometry { namespace traits {  \
+    template<typename Polygon> struct tag< MultiPolygon<Polygon> > { typedef multi_polygon_tag type; }; \
+}}}
+
+
+#endif // BOOST_GEOMETRY_MULTI_GEOMETRIES_REGISTER_MULTI_POLYGON_HPP
diff --git a/src/boost/geometry/multi/io/dsv/write.hpp b/src/boost/geometry/multi/io/dsv/write.hpp
new file mode 100644
index 0000000..be40b5d
--- /dev/null
+++ b/src/boost/geometry/multi/io/dsv/write.hpp
@@ -0,0 +1,83 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_IO_DSV_WRITE_HPP
+#define BOOST_GEOMETRY_MULTI_IO_DSV_WRITE_HPP
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/io/dsv/write.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv
+{
+
+template <typename MultiGeometry>
+struct dsv_multi
+{
+    typedef dispatch::dsv
+                <
+                    typename single_tag_of
+                        <
+                            typename tag<MultiGeometry>::type
+                        >::type,
+                    typename boost::range_value<MultiGeometry>::type
+                > dispatch_one;
+
+    typedef typename boost::range_iterator
+        <
+            MultiGeometry const
+        >::type iterator;
+
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                MultiGeometry const& multi,
+                dsv_settings const& settings)
+    {
+        os << settings.list_open;
+
+        bool first = true;
+        for(iterator it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it, first = false)
+        {
+            os << (first ? "" : settings.list_separator);
+            dispatch_one::apply(os, *it, settings);
+        }
+        os << settings.list_close;
+    }
+};
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Geometry>
+struct dsv<multi_tag, Geometry>
+    : detail::dsv::dsv_multi<Geometry>
+{};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_IO_DSV_WRITE_HPP
diff --git a/src/boost/geometry/multi/io/wkt/detail/prefix.hpp b/src/boost/geometry/multi/io/wkt/detail/prefix.hpp
new file mode 100644
index 0000000..37b0797
--- /dev/null
+++ b/src/boost/geometry/multi/io/wkt/detail/prefix.hpp
@@ -0,0 +1,51 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_IO_WKT_DETAIL_PREFIX_HPP
+#define BOOST_GEOMETRY_MULTI_IO_WKT_DETAIL_PREFIX_HPP
+
+#include <boost/geometry/multi/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+struct prefix_null
+{
+    static inline const char* apply() { return ""; }
+};
+
+struct prefix_multipoint
+{
+    static inline const char* apply() { return "MULTIPOINT"; }
+};
+
+struct prefix_multilinestring
+{
+    static inline const char* apply() { return "MULTILINESTRING"; }
+};
+
+struct prefix_multipolygon
+{
+    static inline const char* apply() { return "MULTIPOLYGON"; }
+};
+
+}} // namespace wkt::impl
+#endif
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_IO_WKT_DETAIL_PREFIX_HPP
diff --git a/src/boost/geometry/multi/io/wkt/read.hpp b/src/boost/geometry/multi/io/wkt/read.hpp
new file mode 100644
index 0000000..218ddf9
--- /dev/null
+++ b/src/boost/geometry/multi/io/wkt/read.hpp
@@ -0,0 +1,167 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_IO_WKT_READ_MULTI_HPP
+#define BOOST_GEOMETRY_MULTI_IO_WKT_READ_MULTI_HPP
+
+#include <string>
+
+#include <boost/geometry/core/mutable_range.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+#include <boost/geometry/multi/io/wkt/detail/prefix.hpp>
+#include <boost/geometry/io/wkt/read.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace detail { namespace wkt
+{
+
+template <typename MultiGeometry, template<typename> class Parser, typename PrefixPolicy>
+struct multi_parser
+{
+    static inline void apply(std::string const& wkt, MultiGeometry& geometry)
+    {
+        traits::clear<MultiGeometry>::apply(geometry);
+
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it;
+        if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it))
+        {
+            handle_open_parenthesis(it, tokens.end(), wkt);
+
+            // Parse sub-geometries
+            while(it != tokens.end() && *it != ")")
+            {
+                traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1);
+                Parser
+                    <
+                        typename boost::range_value<MultiGeometry>::type
+                    >::apply(it, tokens.end(), wkt, geometry.back());
+                if (it != tokens.end() && *it == ",")
+                {
+                    // Skip "," after multi-element is parsed
+                    ++it;
+                }
+            }
+
+            handle_close_parenthesis(it, tokens.end(), wkt);
+        }
+        
+        check_end(it, tokens.end(), wkt);
+    }
+};
+
+template <typename P>
+struct noparenthesis_point_parser
+{
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, P& point)
+    {
+        parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt);
+    }
+};
+
+template <typename MultiGeometry, typename PrefixPolicy>
+struct multi_point_parser
+{
+    static inline void apply(std::string const& wkt, MultiGeometry& geometry)
+    {
+        traits::clear<MultiGeometry>::apply(geometry);
+
+        tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
+        tokenizer::iterator it;
+
+        if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it))
+        {
+            handle_open_parenthesis(it, tokens.end(), wkt);
+
+            // If first point definition starts with "(" then parse points as (x y)
+            // otherwise as "x y"
+            bool using_brackets = (it != tokens.end() && *it == "(");
+            
+            while(it != tokens.end() && *it != ")")
+            {
+                traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1);
+                
+                if (using_brackets)
+                {
+                    point_parser
+                        <
+                            typename boost::range_value<MultiGeometry>::type
+                        >::apply(it, tokens.end(), wkt, geometry.back());
+                }
+                else
+                {
+                    noparenthesis_point_parser
+                        <
+                            typename boost::range_value<MultiGeometry>::type
+                        >::apply(it, tokens.end(), wkt, geometry.back());
+                }
+                    
+                if (it != tokens.end() && *it == ",")
+                {
+                    // Skip "," after point is parsed
+                    ++it;
+                }
+            }
+            
+            handle_close_parenthesis(it, tokens.end(), wkt);
+        }
+        
+        check_end(it, tokens.end(), wkt);
+    }
+};
+
+}} // namespace detail::wkt
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename MultiGeometry>
+struct read_wkt<multi_point_tag, MultiGeometry>
+    : detail::wkt::multi_point_parser
+            <
+                MultiGeometry,
+                detail::wkt::prefix_multipoint
+            >
+{};
+
+template <typename MultiGeometry>
+struct read_wkt<multi_linestring_tag, MultiGeometry>
+    : detail::wkt::multi_parser
+            <
+                MultiGeometry,
+                detail::wkt::linestring_parser,
+                detail::wkt::prefix_multilinestring
+            >
+{};
+
+template <typename MultiGeometry>
+struct read_wkt<multi_polygon_tag, MultiGeometry>
+    : detail::wkt::multi_parser
+            <
+                MultiGeometry,
+                detail::wkt::polygon_parser,
+                detail::wkt::prefix_multipolygon
+            >
+{};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_IO_WKT_READ_MULTI_HPP
diff --git a/src/boost/geometry/multi/io/wkt/wkt.hpp b/src/boost/geometry/multi/io/wkt/wkt.hpp
new file mode 100644
index 0000000..55f1713
--- /dev/null
+++ b/src/boost/geometry/multi/io/wkt/wkt.hpp
@@ -0,0 +1,20 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_IO_WKT_WKT_HPP
+#define BOOST_GEOMETRY_MULTI_IO_WKT_WKT_HPP
+
+#include <boost/geometry/multi/io/wkt/read.hpp>
+#include <boost/geometry/multi/io/wkt/write.hpp>
+
+#endif // BOOST_GEOMETRY_MULTI_IO_WKT_WKT_HPP
diff --git a/src/boost/geometry/multi/io/wkt/write.hpp b/src/boost/geometry/multi/io/wkt/write.hpp
new file mode 100644
index 0000000..374da28
--- /dev/null
+++ b/src/boost/geometry/multi/io/wkt/write.hpp
@@ -0,0 +1,108 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_IO_WKT_WRITE_HPP
+#define BOOST_GEOMETRY_MULTI_IO_WKT_WRITE_HPP
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/io/wkt/detail/prefix.hpp>
+#include <boost/geometry/io/wkt/write.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace wkt
+{
+
+template <typename Multi, typename StreamPolicy, typename PrefixPolicy>
+struct wkt_multi
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Multi const& geometry)
+    {
+        os << PrefixPolicy::apply();
+        // TODO: check EMPTY here
+        os << "(";
+
+        for (typename boost::range_iterator<Multi const>::type
+                    it = boost::begin(geometry);
+            it != boost::end(geometry);
+            ++it)
+        {
+            if (it != boost::begin(geometry))
+            {
+                os << ",";
+            }
+            StreamPolicy::apply(os, *it);
+        }
+
+        os << ")";
+    }
+};
+
+}} // namespace wkt::impl
+#endif
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Multi>
+struct wkt<multi_point_tag, Multi>
+    : detail::wkt::wkt_multi
+        <
+            Multi,
+            detail::wkt::wkt_point
+                <
+                    typename boost::range_value<Multi>::type,
+                    detail::wkt::prefix_null
+                >,
+            detail::wkt::prefix_multipoint
+        >
+{};
+
+template <typename Multi>
+struct wkt<multi_linestring_tag, Multi>
+    : detail::wkt::wkt_multi
+        <
+            Multi,
+            detail::wkt::wkt_sequence
+                <
+                    typename boost::range_value<Multi>::type
+                >,
+            detail::wkt::prefix_multilinestring
+        >
+{};
+
+template <typename Multi>
+struct wkt<multi_polygon_tag, Multi>
+    : detail::wkt::wkt_multi
+        <
+            Multi,
+            detail::wkt::wkt_poly
+                <
+                    typename boost::range_value<Multi>::type,
+                    detail::wkt::prefix_null
+                >,
+            detail::wkt::prefix_multipolygon
+        >
+{};
+
+} // namespace dispatch
+#endif
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_IO_WKT_WRITE_HPP
diff --git a/src/boost/geometry/multi/multi.hpp b/src/boost/geometry/multi/multi.hpp
new file mode 100644
index 0000000..db33a9d
--- /dev/null
+++ b/src/boost/geometry/multi/multi.hpp
@@ -0,0 +1,77 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_HPP
+#define BOOST_GEOMETRY_MULTI_HPP
+
+
+#include <boost/geometry/multi/core/closure.hpp>
+#include <boost/geometry/multi/core/geometry_id.hpp>
+#include <boost/geometry/multi/core/interior_rings.hpp>
+#include <boost/geometry/multi/core/is_areal.hpp>
+#include <boost/geometry/multi/core/point_order.hpp>
+#include <boost/geometry/multi/core/point_type.hpp>
+#include <boost/geometry/multi/core/ring_type.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/multi/core/topological_dimension.hpp>
+
+#include <boost/geometry/multi/algorithms/append.hpp>
+#include <boost/geometry/multi/algorithms/area.hpp>
+#include <boost/geometry/multi/algorithms/centroid.hpp>
+#include <boost/geometry/multi/algorithms/clear.hpp>
+#include <boost/geometry/multi/algorithms/convert.hpp>
+#include <boost/geometry/multi/algorithms/correct.hpp>
+#include <boost/geometry/multi/algorithms/covered_by.hpp>
+#include <boost/geometry/multi/algorithms/distance.hpp>
+#include <boost/geometry/multi/algorithms/envelope.hpp>
+#include <boost/geometry/multi/algorithms/equals.hpp>
+#include <boost/geometry/multi/algorithms/for_each.hpp>
+#include <boost/geometry/multi/algorithms/intersection.hpp>
+#include <boost/geometry/multi/algorithms/length.hpp>
+#include <boost/geometry/multi/algorithms/num_geometries.hpp>
+#include <boost/geometry/multi/algorithms/num_interior_rings.hpp>
+#include <boost/geometry/multi/algorithms/num_points.hpp>
+#include <boost/geometry/multi/algorithms/perimeter.hpp>
+#include <boost/geometry/multi/algorithms/reverse.hpp>
+#include <boost/geometry/multi/algorithms/simplify.hpp>
+#include <boost/geometry/multi/algorithms/transform.hpp>
+#include <boost/geometry/multi/algorithms/unique.hpp>
+#include <boost/geometry/multi/algorithms/within.hpp>
+
+#include <boost/geometry/multi/algorithms/detail/for_each_range.hpp>
+#include <boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp>
+#include <boost/geometry/multi/algorithms/detail/multi_sum.hpp>
+
+#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
+#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>
+
+#include <boost/geometry/multi/algorithms/detail/overlay/copy_segment_point.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/copy_segments.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/get_ring.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/get_turns.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp>
+#include <boost/geometry/multi/algorithms/detail/overlay/self_turn_points.hpp>
+
+#include <boost/geometry/multi/geometries/concepts/check.hpp>
+#include <boost/geometry/multi/geometries/concepts/multi_point_concept.hpp>
+#include <boost/geometry/multi/geometries/concepts/multi_linestring_concept.hpp>
+#include <boost/geometry/multi/geometries/concepts/multi_polygon_concept.hpp>
+
+#include <boost/geometry/multi/views/detail/range_type.hpp>
+#include <boost/geometry/multi/strategies/cartesian/centroid_average.hpp>
+
+#include <boost/geometry/multi/io/dsv/write.hpp>
+#include <boost/geometry/multi/io/wkt/wkt.hpp>
+
+
+#endif // BOOST_GEOMETRY_MULTI_HPP
diff --git a/src/boost/geometry/multi/strategies/cartesian/centroid_average.hpp b/src/boost/geometry/multi/strategies/cartesian/centroid_average.hpp
new file mode 100644
index 0000000..f28daf2
--- /dev/null
+++ b/src/boost/geometry/multi/strategies/cartesian/centroid_average.hpp
@@ -0,0 +1,116 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_STRATEGIES_CARTESIAN_CENTROID_AVERAGE_HPP
+#define BOOST_GEOMETRY_MULTI_STRATEGIES_CARTESIAN_CENTROID_AVERAGE_HPP
+
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/strategies/centroid.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace centroid
+{
+
+
+/*!
+\brief Centroid calculation taking average of points
+\ingroup strategies
+*/
+template
+<
+    typename PointCentroid,
+    typename Point = PointCentroid
+>
+class average
+{
+private :
+
+    /*! subclass to keep state */
+    class sum
+    {
+        friend class average;
+        int count;
+        PointCentroid centroid;
+
+    public :
+        inline sum()
+            : count(0)
+        {
+            assign_zero(centroid);
+        }
+    };
+
+public :
+    typedef sum state_type;
+    typedef PointCentroid centroid_point_type;
+    typedef Point point_type;
+
+    static inline void apply(Point const& p, sum& state)
+    {
+        add_point(state.centroid, p);
+        state.count++;
+    }
+
+    static inline void result(sum const& state, PointCentroid& centroid)
+    {
+        centroid = state.centroid;
+        divide_value(centroid, state.count);
+    }
+
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+namespace services
+{
+
+template <typename Point, std::size_t DimensionCount, typename Geometry>
+struct default_strategy
+<
+    cartesian_tag,
+    pointlike_tag,
+    DimensionCount,
+    Point,
+    Geometry
+>
+{
+    typedef average
+        <
+            Point,
+            typename point_type<Geometry>::type
+        > type;
+};
+
+} // namespace services
+
+#endif
+
+
+}} // namespace strategy::centroid
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_STRATEGIES_CARTESIAN_CENTROID_AVERAGE_HPP
diff --git a/src/boost/geometry/multi/util/write_dsv.hpp b/src/boost/geometry/multi/util/write_dsv.hpp
new file mode 100644
index 0000000..2ab97df
--- /dev/null
+++ b/src/boost/geometry/multi/util/write_dsv.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_UTIL_WRITE_DSV_HPP
+#define BOOST_GEOMETRY_MULTI_UTIL_WRITE_DSV_HPP
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/io/dsv/write.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv
+{
+
+
+template <typename MultiGeometry>
+struct dsv_multi
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                MultiGeometry const& multi,
+                dsv_settings const& settings)
+    {
+        os << settings.list_open;
+
+        typedef typename boost::range_iterator
+            <
+                MultiGeometry const
+            >::type iterator;
+        for(iterator it = boost::begin(multi);
+            it != boost::end(multi);
+            ++it)
+        {
+            os << geometry::dsv(*it);
+        }
+        os << settings.list_close;
+    }
+};
+
+
+
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename Geometry>
+struct dsv<multi_tag, Geometry>
+    : detail::dsv::dsv_multi<Geometry>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_UTIL_WRITE_DSV_HPP
diff --git a/src/boost/geometry/multi/views/detail/range_type.hpp b/src/boost/geometry/multi/views/detail/range_type.hpp
new file mode 100644
index 0000000..172feb2
--- /dev/null
+++ b/src/boost/geometry/multi/views/detail/range_type.hpp
@@ -0,0 +1,62 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_VIEWS_DETAIL_RANGE_TYPE_HPP
+#define BOOST_GEOMETRY_MULTI_VIEWS_DETAIL_RANGE_TYPE_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/views/detail/range_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// multi-point acts itself as a range
+template <typename Geometry>
+struct range_type<multi_point_tag, Geometry>
+{
+    typedef Geometry type;
+};
+
+
+template <typename Geometry>
+struct range_type<multi_linestring_tag, Geometry>
+{
+    typedef typename boost::range_value<Geometry>::type type;
+};
+
+
+template <typename Geometry>
+struct range_type<multi_polygon_tag, Geometry>
+{
+    // Call its single-version
+    typedef typename geometry::detail::range_type
+        <
+            typename boost::range_value<Geometry>::type
+        >::type type;
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_VIEWS_DETAIL_RANGE_TYPE_HPP
diff --git a/src/boost/geometry/policies/compare.hpp b/src/boost/geometry/policies/compare.hpp
new file mode 100644
index 0000000..2e952d3
--- /dev/null
+++ b/src/boost/geometry/policies/compare.hpp
@@ -0,0 +1,242 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_POLICIES_COMPARE_HPP
+#define BOOST_GEOMETRY_POLICIES_COMPARE_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/strategies/compare.hpp>
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace compare
+{
+
+
+template
+<
+    int Direction,
+    typename Point,
+    typename Strategy,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct compare_loop
+{
+    typedef typename strategy::compare::detail::select_strategy
+        <
+            Strategy, Direction, Point, Dimension
+        >::type compare_type;
+
+    typedef typename geometry::coordinate_type<Point>::type coordinate_type;
+
+    static inline bool apply(Point const& left, Point const& right)
+    {
+        coordinate_type const& cleft = geometry::get<Dimension>(left);
+        coordinate_type const& cright = geometry::get<Dimension>(right);
+
+        if (geometry::math::equals(cleft, cright))
+        {
+            return compare_loop
+                <
+                    Direction, Point, Strategy,
+                    Dimension + 1, DimensionCount
+                >::apply(left, right);
+        }
+        else
+        {
+            compare_type compare;
+            return compare(cleft, cright);
+        }
+    }
+};
+
+template
+<
+    int Direction,
+    typename Point,
+    typename Strategy,
+    std::size_t DimensionCount
+>
+struct compare_loop<Direction, Point, Strategy, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Point const&, Point const&)
+    {
+        // On coming here, points are equal. Return true if
+        // direction = 0 (equal), false if -1/1 (greater/less)
+        return Direction == 0;
+    }
+};
+
+
+template <int Direction, typename Point, typename Strategy>
+struct compare_in_all_dimensions
+{
+    inline bool operator()(Point const& left, Point const& right) const
+    {
+        return detail::compare::compare_loop
+            <
+                Direction, Point, Strategy,
+                0, geometry::dimension<Point>::type::value
+            >::apply(left, right);
+    }
+};
+
+
+template <typename Point, typename Strategy, std::size_t Dimension>
+class compare_in_one_dimension
+{
+    Strategy compare;
+
+public :
+    inline bool operator()(Point const& left, Point const& right) const
+    {
+        typedef typename geometry::coordinate_type<Point>::type coordinate_type;
+
+        coordinate_type const& cleft = get<Dimension>(left);
+        coordinate_type const& cright = get<Dimension>(right);
+        return compare(cleft, cright);
+    }
+};
+
+}} // namespace detail::compare
+
+#endif
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+    int Direction,
+    typename Point,
+    typename Strategy,
+    int Dimension
+>
+struct compare_geometries
+    : detail::compare::compare_in_one_dimension
+        <
+            Point,
+            typename strategy::compare::detail::select_strategy
+                <
+                    Strategy, Direction, Point, Dimension
+                >::type,
+            Dimension
+        >
+{};
+
+
+// Specialization with -1: compare in all dimensions
+template <int Direction, typename Point, typename Strategy>
+struct compare_geometries<Direction, Point, Strategy, -1>
+    : detail::compare::compare_in_all_dimensions<Direction, Point, Strategy>
+{};
+
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+\brief Less functor, to sort points in ascending order.
+\ingroup compare
+\details This functor compares points and orders them on x,
+    then on y, then on z coordinate.
+\tparam Geometry the geometry
+\tparam Dimension the dimension to sort on, defaults to -1,
+    indicating ALL dimensions. That's to say, first on x,
+    on equal x-es then on y, etc.
+    If a dimension is specified, only that dimension is considered
+\tparam Strategy underlying coordinate comparing functor,
+    defaults to the default comparison strategies
+    related to the point coordinate system. If specified, the specified
+    strategy is used. This can e.g. be std::less<double>.
+*/
+template
+<
+    typename Point,
+    int Dimension = -1,
+    typename Strategy = strategy::compare::default_strategy
+>
+struct less
+    : dispatch::compare_geometries
+        <
+            1, // indicates ascending
+            Point,
+            Strategy,
+            Dimension
+        >
+{
+    typedef Point first_argument_type;
+    typedef Point second_argument_type;
+    typedef bool result_type;
+};
+
+
+/*!
+\brief Greater functor
+\ingroup compare
+\details Can be used to sort points in reverse order
+\see Less functor
+*/
+template
+<
+    typename Point,
+    int Dimension = -1,
+    typename Strategy = strategy::compare::default_strategy
+>
+struct greater
+    : dispatch::compare_geometries
+        <
+            -1,  // indicates descending
+            Point,
+            Strategy,
+            Dimension
+        >
+{};
+
+
+/*!
+\brief Equal To functor, to compare if points are equal
+\ingroup compare
+\tparam Geometry the geometry
+\tparam Dimension the dimension to compare on, defaults to -1,
+    indicating ALL dimensions.
+    If a dimension is specified, only that dimension is considered
+\tparam Strategy underlying coordinate comparing functor
+*/
+template
+<
+    typename Point,
+    int Dimension = -1,
+    typename Strategy = strategy::compare::default_strategy
+>
+struct equal_to
+    : dispatch::compare_geometries
+        <
+            0,
+            Point,
+            Strategy,
+            Dimension
+        >
+{};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_POLICIES_COMPARE_HPP
diff --git a/src/boost/geometry/policies/relate/de9im.hpp b/src/boost/geometry/policies/relate/de9im.hpp
new file mode 100644
index 0000000..766d80b
--- /dev/null
+++ b/src/boost/geometry/policies/relate/de9im.hpp
@@ -0,0 +1,177 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DE9IM_HPP
+#define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DE9IM_HPP
+
+
+#include <boost/geometry/strategies/intersection_result.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace policies { namespace relate
+{
+
+
+template <typename S1, typename S2>
+struct segments_de9im
+{
+    typedef de9im_segment return_type;
+    typedef S1 segment_type1;
+    typedef S2 segment_type2;
+    typedef typename select_coordinate_type<S1, S2>::type coordinate_type;
+
+    static inline return_type rays_intersect(bool on_segment,
+                    double ra, double rb,
+                    coordinate_type const& dx1, coordinate_type const& dy1,
+                    coordinate_type const& dx2, coordinate_type const& dy2,
+                    coordinate_type const& wx, coordinate_type const& wy,
+                    S1 const& s1, S2 const& s2)
+    {
+        if(on_segment)
+        {
+            // 0 <= ra <= 1 and 0 <= rb <= 1
+            // Now check if one of them is 0 or 1, these are "touch" cases
+            bool a = math::equals(ra, 0.0) || math::equals(ra, 1.0);
+            bool b = math::equals(rb, 0.0) || math::equals(rb, 1.0);
+            if (a && b)
+            {
+                // Touch boundary/boundary: i-i == -1, i-b == -1, b-b == 0
+                // Opposite: if both are equal they touch in opposite direction
+                return de9im_segment(ra,rb,
+                        -1, -1, 1,
+                        -1,  0, 0,
+                         1,  0, 2, false, math::equals(ra,rb));
+            }
+            else if (a || b)
+            {
+                // Touch boundary/interior: i-i == -1, i-b == -1 or 0, b-b == -1
+                int A = a ? 0 : -1;
+                int B = b ? 0 : -1;
+                return de9im_segment(ra,rb,
+                        -1,  B, 1,
+                         A, -1, 0,
+                         1,  0, 2);
+            }
+
+            // Intersects: i-i == 0, i-b == -1, i-e == 1
+            return de9im_segment(ra,rb,
+                     0, -1, 1,
+                    -1, -1, 0,
+                     1,  0, 2);
+        }
+
+        // Not on segment, disjoint
+        return de9im_segment(ra,rb,
+                -1, -1, 1,
+                -1, -1, 0,
+                 1,  0, 2);
+    }
+
+    static inline return_type collinear_touch(coordinate_type const& x,
+                coordinate_type const& y, bool opposite, char)
+    {
+        return de9im_segment(0,0,
+                -1, -1, 1,
+                -1,  0, 0,
+                 1,  0, 2,
+                true, opposite);
+    }
+
+    template <typename S>
+    static inline return_type collinear_interior_boundary_intersect(S const& s,
+                bool a_within_b, bool opposite)
+    {
+        return a_within_b
+            ? de9im_segment(0,0,
+                 1, -1, -1,
+                 0,  0, -1,
+                 1,  0, 2,
+                true, opposite)
+            : de9im_segment(0,0,
+                 1,  0, 1,
+                -1,  0, 0,
+                -1, -1, 2,
+                true, opposite);
+    }
+
+
+
+    static inline return_type collinear_a_in_b(S1 const& s, bool opposite)
+    {
+        return de9im_segment(0,0,
+                1, -1, -1,
+                0, -1, -1,
+                1,  0,  2,
+                true, opposite);
+    }
+    static inline return_type collinear_b_in_a(S2 const& s, bool opposite)
+    {
+        return de9im_segment(0,0,
+                 1,  0,  1,
+                -1, -1,  0,
+                -1, -1,  2,
+                true, opposite);
+    }
+
+    static inline return_type collinear_overlaps(
+                    coordinate_type const& x1, coordinate_type const& y1,
+                    coordinate_type const& x2, coordinate_type const& y2, bool opposite)
+    {
+        return de9im_segment(0,0,
+                1,  0, 1,
+                0, -1, 0,
+                1,  0, 2,
+                true, opposite);
+    }
+
+    static inline return_type segment_equal(S1 const& s, bool opposite)
+    {
+        return de9im_segment(0,0,
+                 1, -1, -1,
+                -1,  0, -1,
+                -1, -1,  2,
+                 true, opposite);
+    }
+
+    static inline return_type degenerate(S1 const& segment, bool a_degenerate)
+    {
+            return a_degenerate
+                ? de9im_segment(0,0,
+                     0, -1, -1,
+                    -1, -1, -1,
+                     1,  0,  2,
+                     false, false, false, true)
+                : de9im_segment(0,0,
+                     0, -1,  1,
+                    -1, -1,  0,
+                    -1, -1,  2,
+                     false, false, false, true);
+    }
+
+    static inline return_type collinear_disjoint()
+    {
+        return de9im_segment(0,0,
+                -1, -1, 1,
+                -1, -1, 0,
+                 1,  0, 2,
+                true);
+    }
+
+};
+
+
+}} // namespace policies::relate
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DE9IM_HPP
diff --git a/src/boost/geometry/policies/relate/direction.hpp b/src/boost/geometry/policies/relate/direction.hpp
new file mode 100644
index 0000000..cfbaf7d
--- /dev/null
+++ b/src/boost/geometry/policies/relate/direction.hpp
@@ -0,0 +1,362 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DIRECTION_HPP
+#define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DIRECTION_HPP
+
+
+#include <cstddef>
+#include <string>
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/arithmetic/determinant.hpp>
+#include <boost/geometry/strategies/side_info.hpp>
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace policies { namespace relate
+{
+
+struct direction_type
+{
+    // NOTE: "char" will be replaced by enum in future version
+
+    inline direction_type(side_info const& s, char h,
+                int ha, int hb,
+                int da = 0, int db = 0,
+                bool op = false)
+        : how(h)
+        , opposite(op)
+        , how_a(ha)
+        , how_b(hb)
+        , dir_a(da)
+        , dir_b(db)
+        , sides(s)
+    {
+        arrival[0] = ha;
+        arrival[1] = hb;
+    }
+
+    inline direction_type(char h, bool op, int ha = 0, int hb = 0)
+        : how(h)
+        , opposite(op)
+        , how_a(ha)
+        , how_b(hb)
+        , dir_a(0)
+        , dir_b(0)
+    {
+        arrival[0] = ha;
+        arrival[1] = hb;
+    }
+
+
+    // TODO: replace this
+    // NOTE: "char" will be replaced by enum in future version
+    // "How" is the intersection formed?
+    char how;
+
+    // Is it opposite (for collinear/equal cases)
+    bool opposite;
+
+    // Information on how A arrives at intersection, how B arrives at intersection
+    // 1: arrives at intersection
+    // -1: starts from intersection
+    int how_a;
+    int how_b;
+
+    // Direction: how is A positioned from B
+    // 1: points left, seen from IP
+    // -1: points right, seen from IP
+    // In case of intersection: B's TO direction
+    // In case that B's TO direction is at A: B's from direction
+    // In collinear cases: it is 0
+    int dir_a; // Direction of A-s TO from IP
+    int dir_b; // Direction of B-s TO from IP
+
+    // New information
+    side_info sides;
+    int arrival[2]; // 1=arrival, -1departure, 0=neutral; == how_a//how_b
+
+
+    // About arrival[0] (== arrival of a2 w.r.t. b) for COLLINEAR cases
+    // Arrival  1: a1--------->a2         (a arrives within b)
+    //                      b1----->b2
+
+    // Arrival  1: (a in b)
+    //
+
+
+    // Arrival -1:      a1--------->a2     (a does not arrive within b)
+    //             b1----->b2
+
+    // Arrival -1: (b in a)               a_1-------------a_2
+    //                                         b_1---b_2
+
+    // Arrival  0:                        a1------->a2  (a arrives at TO-border of b)
+    //                                        b1--->b2
+
+};
+
+
+template <typename S1, typename S2, typename CalculationType = void>
+struct segments_direction
+{
+    typedef direction_type return_type;
+    typedef S1 segment_type1;
+    typedef S2 segment_type2;
+    typedef typename select_calculation_type
+        <
+            S1, S2, CalculationType
+        >::type coordinate_type;
+
+    // Get the same type, but at least a double
+    typedef typename select_most_precise<coordinate_type, double>::type rtype;
+
+
+	template <typename R>
+    static inline return_type segments_intersect(side_info const& sides,
+					R const&,
+                    coordinate_type const& dx1, coordinate_type const& dy1,
+                    coordinate_type const& dx2, coordinate_type const& dy2,
+                    S1 const& s1, S2 const& s2)
+    {
+        bool const ra0 = sides.get<0,0>() == 0;
+        bool const ra1 = sides.get<0,1>() == 0;
+        bool const rb0 = sides.get<1,0>() == 0;
+        bool const rb1 = sides.get<1,1>() == 0;
+
+        return
+            // opposite and same starting point (FROM)
+            ra0 && rb0 ? calculate_side<1>(sides, dx1, dy1, s1, s2, 'f', -1, -1)
+
+            // opposite and point to each other (TO)
+            : ra1 && rb1 ? calculate_side<0>(sides, dx1, dy1, s1, s2, 't', 1, 1)
+
+            // not opposite, forming an angle, first a then b,
+            // directed either both left, or both right
+            // Check side of B2 from A. This is not calculated before
+            : ra1 && rb0 ? angle<1>(sides, dx1, dy1, s1, s2, 'a', 1, -1)
+
+            // not opposite, forming a angle, first b then a,
+            // directed either both left, or both right
+            : ra0 && rb1 ? angle<0>(sides, dx1, dy1, s1, s2, 'a', -1, 1)
+
+            // b starts from interior of a
+            : rb0 ? starts_from_middle(sides, dx1, dy1, s1, s2, 'B', 0, -1)
+
+            // a starts from interior of b (#39)
+            : ra0 ? starts_from_middle(sides, dx1, dy1, s1, s2, 'A', -1, 0)
+
+            // b ends at interior of a, calculate direction of A from IP
+            : rb1 ? b_ends_at_middle(sides, dx2, dy2, s1, s2)
+
+            // a ends at interior of b
+            : ra1 ? a_ends_at_middle(sides, dx1, dy1, s1, s2)
+
+            // normal intersection
+            : calculate_side<1>(sides, dx1, dy1, s1, s2, 'i', -1, -1)
+            ;
+    }
+
+    static inline return_type collinear_touch(
+                coordinate_type const& ,
+                coordinate_type const& , int arrival_a, int arrival_b)
+    {
+        // Though this is 'collinear', we handle it as To/From/Angle because it is the same.
+        // It only does NOT have a direction.
+        side_info sides;
+        //int const arrive = how == 'T' ? 1 : -1;
+        bool opposite = arrival_a == arrival_b;
+        return
+            ! opposite
+            ? return_type(sides, 'a', arrival_a, arrival_b)
+            : return_type(sides, arrival_a == 0 ? 't' : 'f', arrival_a, arrival_b, 0, 0, true);
+    }
+
+    template <typename S>
+    static inline return_type collinear_interior_boundary_intersect(S const& , bool,
+                    int arrival_a, int arrival_b, bool opposite)
+    {
+        return_type r('c', opposite);
+        r.arrival[0] = arrival_a;
+        r.arrival[1] = arrival_b;
+        return r;
+    }
+
+    static inline return_type collinear_a_in_b(S1 const& , bool opposite)
+    {
+        return_type r('c', opposite);
+        r.arrival[0] = 1;
+        r.arrival[1] = -1;
+        return r;
+    }
+    static inline return_type collinear_b_in_a(S2 const& , bool opposite)
+    {
+        return_type r('c', opposite);
+        r.arrival[0] = -1;
+        r.arrival[1] = 1;
+        return r;
+    }
+
+    static inline return_type collinear_overlaps(
+                    coordinate_type const& , coordinate_type const& ,
+                    coordinate_type const& , coordinate_type const& ,
+                    int arrival_a, int arrival_b, bool opposite)
+    {
+        return_type r('c', opposite);
+        r.arrival[0] = arrival_a;
+        r.arrival[1] = arrival_b;
+        return r;
+    }
+
+    static inline return_type segment_equal(S1 const& , bool opposite)
+    {
+        return return_type('e', opposite);
+    }
+
+    static inline return_type degenerate(S1 const& , bool)
+    {
+        return return_type('0', false);
+    }
+
+    static inline return_type disjoint()
+    {
+        return return_type('d', false);
+    }
+
+    static inline return_type collinear_disjoint()
+    {
+        return return_type('d', false);
+    }
+
+    static inline return_type error(std::string const&)
+    {
+        // Return "E" to denote error
+        // This will throw an error in get_turn_info
+        // TODO: change to enum or similar
+        return return_type('E', false);
+    }
+
+private :
+
+    static inline bool is_left
+        (
+            coordinate_type const& ux, 
+            coordinate_type const& uy,
+            coordinate_type const& vx,
+            coordinate_type const& vy
+        )
+    {
+        // This is a "side calculation" as in the strategies, but here terms are precalculated
+        // We might merge this with side, offering a pre-calculated term (in fact already done using cross-product)
+        // Waiting for implementing spherical...
+
+        rtype const zero = rtype();
+        return geometry::detail::determinant<rtype>(ux, uy, vx, vy) > zero;
+    }
+
+    template <std::size_t I>
+    static inline return_type calculate_side(side_info const& sides,
+                coordinate_type const& dx1, coordinate_type const& dy1,
+                S1 const& s1, S2 const& s2,
+                char how, int how_a, int how_b)
+    {
+        coordinate_type dpx = get<I, 0>(s2) - get<0, 0>(s1);
+        coordinate_type dpy = get<I, 1>(s2) - get<0, 1>(s1);
+
+        return is_left(dx1, dy1, dpx, dpy)
+            ? return_type(sides, how, how_a, how_b, -1, 1)
+            : return_type(sides, how, how_a, how_b, 1, -1);
+    }
+
+    template <std::size_t I>
+    static inline return_type angle(side_info const& sides,
+                coordinate_type const& dx1, coordinate_type const& dy1,
+                S1 const& s1, S2 const& s2,
+                char how, int how_a, int how_b)
+    {
+        coordinate_type dpx = get<I, 0>(s2) - get<0, 0>(s1);
+        coordinate_type dpy = get<I, 1>(s2) - get<0, 1>(s1);
+
+        return is_left(dx1, dy1, dpx, dpy)
+            ? return_type(sides, how, how_a, how_b, 1, 1)
+            : return_type(sides, how, how_a, how_b, -1, -1);
+    }
+
+
+    static inline return_type starts_from_middle(side_info const& sides,
+                coordinate_type const& dx1, coordinate_type const& dy1,
+                S1 const& s1, S2 const& s2,
+                char which,
+                int how_a, int how_b)
+    {
+        // Calculate ARROW of b segment w.r.t. s1
+        coordinate_type dpx = get<1, 0>(s2) - get<0, 0>(s1);
+        coordinate_type dpy = get<1, 1>(s2) - get<0, 1>(s1);
+
+        int dir = is_left(dx1, dy1, dpx, dpy) ? 1 : -1;
+
+        // From other perspective, then reverse
+        bool const is_a = which == 'A';
+        if (is_a)
+        {
+            dir = -dir;
+        }
+
+        return return_type(sides, 's',
+            how_a,
+            how_b,
+            is_a ? dir : -dir,
+            ! is_a ? dir : -dir);
+    }
+
+
+
+    // To be harmonized
+    static inline return_type a_ends_at_middle(side_info const& sides,
+                coordinate_type const& dx, coordinate_type const& dy,
+                S1 const& s1, S2 const& s2)
+    {
+        coordinate_type dpx = get<1, 0>(s2) - get<0, 0>(s1);
+        coordinate_type dpy = get<1, 1>(s2) - get<0, 1>(s1);
+
+        // Ending at the middle, one ARRIVES, the other one is NEUTRAL
+        // (because it both "arrives"  and "departs"  there
+        return is_left(dx, dy, dpx, dpy)
+            ? return_type(sides, 'm', 1, 0, 1, 1)
+            : return_type(sides, 'm', 1, 0, -1, -1);
+    }
+
+
+    static inline return_type b_ends_at_middle(side_info const& sides,
+                coordinate_type const& dx, coordinate_type const& dy,
+                S1 const& s1, S2 const& s2)
+    {
+        coordinate_type dpx = get<1, 0>(s1) - get<0, 0>(s2);
+        coordinate_type dpy = get<1, 1>(s1) - get<0, 1>(s2);
+
+        return is_left(dx, dy, dpx, dpy)
+            ? return_type(sides, 'm', 0, 1, 1, 1)
+            : return_type(sides, 'm', 0, 1, -1, -1);
+    }
+
+};
+
+}} // namespace policies::relate
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_DIRECTION_HPP
diff --git a/src/boost/geometry/policies/relate/intersection_points.hpp b/src/boost/geometry/policies/relate/intersection_points.hpp
new file mode 100644
index 0000000..d7d5199
--- /dev/null
+++ b/src/boost/geometry/policies/relate/intersection_points.hpp
@@ -0,0 +1,165 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
+#define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
+
+
+#include <algorithm>
+#include <string>
+
+#include <boost/concept_check.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/arithmetic/determinant.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/strategies/side_info.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace policies { namespace relate
+{
+
+
+template <typename S1, typename S2, typename ReturnType, typename CalculationType = void>
+struct segments_intersection_points
+{
+    typedef ReturnType return_type;
+    typedef S1 segment_type1;
+    typedef S2 segment_type2;
+
+    typedef typename select_calculation_type
+        <
+            S1, S2, CalculationType
+        >::type coordinate_type;
+
+	template <typename R>
+    static inline return_type segments_intersect(side_info const&,
+					R const& r,
+                    coordinate_type const& dx1, coordinate_type const& dy1,
+                    coordinate_type const& dx2, coordinate_type const& dy2,
+                    S1 const& s1, S2 const& s2)
+    {
+        typedef typename geometry::coordinate_type
+            <
+                typename return_type::point_type
+            >::type return_coordinate_type;
+
+        coordinate_type const s1x = get<0, 0>(s1);
+        coordinate_type const s1y = get<0, 1>(s1);
+
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0],
+            boost::numeric_cast<return_coordinate_type>(R(s1x) + r * R(dx1)));
+        set<1>(result.intersections[0],
+            boost::numeric_cast<return_coordinate_type>(R(s1y) + r * R(dy1)));
+
+        return result;
+    }
+
+    static inline return_type collinear_touch(coordinate_type const& x,
+                coordinate_type const& y, int, int)
+    {
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], x);
+        set<1>(result.intersections[0], y);
+        return result;
+    }
+
+    template <typename S>
+    static inline return_type collinear_inside(S const& s, int index1 = 0, int index2 = 1)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[index1], get<0, 0>(s));
+        set<1>(result.intersections[index1], get<0, 1>(s));
+        set<0>(result.intersections[index2], get<1, 0>(s));
+        set<1>(result.intersections[index2], get<1, 1>(s));
+        return result;
+    }
+
+    template <typename S>
+    static inline return_type collinear_interior_boundary_intersect(S const& s, bool a_in_b,
+                int, int, bool opposite)
+    {
+        int index1 = opposite && ! a_in_b ? 1 : 0;
+        return collinear_inside(s, index1, 1 - index1);
+    }
+
+    static inline return_type collinear_a_in_b(S1 const& s, bool)
+    {
+        return collinear_inside(s);
+    }
+    static inline return_type collinear_b_in_a(S2 const& s, bool opposite)
+    {
+        int index1 = opposite ? 1 : 0;
+        return collinear_inside(s, index1, 1 - index1);
+    }
+
+    static inline return_type collinear_overlaps(
+                coordinate_type const& x1, coordinate_type const& y1,
+                coordinate_type const& x2, coordinate_type const& y2,
+                int, int, bool)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], x1);
+        set<1>(result.intersections[0], y1);
+        set<0>(result.intersections[1], x2);
+        set<1>(result.intersections[1], y2);
+        return result;
+    }
+
+    static inline return_type segment_equal(S1 const& s, bool)
+    {
+        return_type result;
+        result.count = 2;
+        // TODO: order of IP's
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        set<0>(result.intersections[1], get<1, 0>(s));
+        set<1>(result.intersections[1], get<1, 1>(s));
+        return result;
+    }
+
+    static inline return_type disjoint()
+    {
+        return return_type();
+    }
+    static inline return_type error(std::string const&)
+    {
+        return return_type();
+    }
+
+    static inline return_type collinear_disjoint()
+    {
+        return return_type();
+    }
+
+    static inline return_type degenerate(S1 const& s, bool)
+    {
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        return result;
+    }
+};
+
+
+}} // namespace policies::relate
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
diff --git a/src/boost/geometry/policies/relate/intersection_points_determinant.hpp b/src/boost/geometry/policies/relate/intersection_points_determinant.hpp
new file mode 100644
index 0000000..bf43ef5
--- /dev/null
+++ b/src/boost/geometry/policies/relate/intersection_points_determinant.hpp
@@ -0,0 +1,176 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
+#define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
+
+
+#include <string>
+
+#include <boost/concept_check.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/strategies/side_info.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace policies { namespace relate
+{
+
+
+template <typename S1, typename S2, typename ReturnType, typename CalculationType = void>
+struct segments_intersection_points
+{
+    typedef ReturnType return_type;
+    typedef S1 segment_type1;
+    typedef S2 segment_type2;
+    typedef typename select_calculation_type
+        <
+            S1, S2, CalculationType
+        >::type coordinate_type;
+
+    // Get the same type, but at least a double
+    typedef typename select_most_precise<coordinate_type, double>::type rtype;
+
+    static inline return_type segments_intersect(side_info const&,
+                    coordinate_type const& dx1, coordinate_type const& dy1,
+                    coordinate_type const& dx2, coordinate_type const& dy2,
+                    S1 const& s1, S2 const& s2)
+    {
+        return_type result;
+        typedef typename geometry::coordinate_type
+            <
+                typename return_type::point_type
+            >::type coordinate_type;
+
+        // Get the same type, but at least a double (also used for divisions
+        typedef typename select_most_precise
+            <
+                coordinate_type, double
+            >::type promoted_type;
+
+        coordinate_type const s1x = get<0, 0>(s1);
+        coordinate_type const s1y = get<0, 1>(s1);
+
+        // Calculate other determinants - Cramers rule
+        promoted_type const wx = get<0, 0>(s1) - get<0, 0>(s2);
+        promoted_type const wy = get<0, 1>(s1) - get<0, 1>(s2);
+        promoted_type const d = (dy2 * dx1) - (dx2 * dy1);
+        promoted_type const da = (dx2 * wy) - (dy2 * wx);
+
+        // r: ratio 0-1 where intersection divides A/B
+        promoted_type const r = da / d;
+
+        result.count = 1;
+        set<0>(result.intersections[0],
+            boost::numeric_cast<coordinate_type>(s1x + r * dx1));
+        set<1>(result.intersections[0],
+            boost::numeric_cast<coordinate_type>(s1y + r * dy1));
+
+        return result;
+    }
+
+    static inline return_type collinear_touch(coordinate_type const& x,
+                coordinate_type const& y, bool, char)
+    {
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], x);
+        set<1>(result.intersections[0], y);
+        return result;
+    }
+
+    template <typename S>
+    static inline return_type collinear_inside(S const& s)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        set<0>(result.intersections[1], get<1, 0>(s));
+        set<1>(result.intersections[1], get<1, 1>(s));
+        return result;
+    }
+
+    template <typename S>
+    static inline return_type collinear_interior_boundary_intersect(S const& s, bool, bool)
+    {
+        return collinear_inside(s);
+    }
+
+    static inline return_type collinear_a_in_b(S1 const& s, bool)
+    {
+        return collinear_inside(s);
+    }
+    static inline return_type collinear_b_in_a(S2 const& s, bool)
+    {
+        return collinear_inside(s);
+    }
+
+    static inline return_type collinear_overlaps(
+                coordinate_type const& x1, coordinate_type const& y1,
+                coordinate_type const& x2, coordinate_type const& y2, bool)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], x1);
+        set<1>(result.intersections[0], y1);
+        set<0>(result.intersections[1], x2);
+        set<1>(result.intersections[1], y2);
+        return result;
+    }
+
+    static inline return_type segment_equal(S1 const& s, bool)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        set<0>(result.intersections[1], get<1, 0>(s));
+        set<1>(result.intersections[1], get<1, 1>(s));
+        return result;
+    }
+
+    static inline return_type disjoint()
+    {
+        return return_type();
+    }
+    static inline return_type error(std::string const& msg)
+    {
+        return return_type();
+    }
+
+    static inline return_type collinear_disjoint()
+    {
+        return return_type();
+    }
+    static inline return_type parallel()
+    {
+        return return_type();
+    }
+    static inline return_type degenerate(S1 const& s, bool)
+    {
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        return result;
+    }
+};
+
+
+}} // namespace policies::relate
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
diff --git a/src/boost/geometry/policies/relate/intersection_points_slope.hpp b/src/boost/geometry/policies/relate/intersection_points_slope.hpp
new file mode 100644
index 0000000..b5c9922
--- /dev/null
+++ b/src/boost/geometry/policies/relate/intersection_points_slope.hpp
@@ -0,0 +1,213 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
+#define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
+
+
+#include <string>
+
+#include <boost/concept_check.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/strategies/side_info.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace policies { namespace relate
+{
+
+
+template <typename S1, typename S2, typename ReturnType, typename CalculationType = void>
+struct segments_intersection_points
+{
+    typedef ReturnType return_type;
+    typedef S1 segment_type1;
+    typedef S2 segment_type2;
+    typedef typename select_calculation_type
+        <
+            S1, S2, CalculationType
+        >::type coordinate_type;
+
+    // Get the same type, but at least a double (also used for divisions
+    typedef typename select_most_precise
+        <
+            coordinate_type, double
+        >::type promoted_type;
+
+    template <int Dimension>
+    static inline return_type rico(
+                    coordinate_type const& dm1, coordinate_type const& dn1,
+                    coordinate_type const& dm2, coordinate_type const& dn2,
+                    S1 const& s1, S2 const& s2)
+    {
+        promoted_type const a1 = dn1 / dm1;
+        promoted_type const a2 = dn2 / dm2;
+        promoted_type const da = a1 - a2;
+
+        if (math::equals(da, 0))
+        {
+            return rico<1 - Dimension>(dn1, dm1, dn2, dm2, s1, s2);
+        }
+
+        promoted_type const b1 = get<0, Dimension>(s1) - a1 * get<0, 1 - Dimension>(s1);
+        promoted_type const b2 = get<0, Dimension>(s2) - a2 * get<0, 1 - Dimension>(s2);
+
+        promoted_type const v = (b2 - b1) / da;
+
+        return_type result;
+        result.count = 1;
+        set<1 - Dimension>(result.intersections[0],
+            boost::numeric_cast<coordinate_type>(v));
+        set<Dimension>(result.intersections[0],
+            boost::numeric_cast<coordinate_type>(a1 * v + b1));
+        return result;
+    }
+
+    static inline return_type cross(S1 const& s1, S2 const& s2)
+    {
+        // Take one of first segment, and one of second segment
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], get<0, 0>(s1));
+        set<1>(result.intersections[0], get<0, 1>(s2));
+        return result;
+    }
+
+
+    static inline return_type segments_intersect(side_info const& sides,
+                    coordinate_type const& dx1, coordinate_type const& dy1,
+                    coordinate_type const& dx2, coordinate_type const& dy2,
+                    S1 const& s1, S2 const& s2)
+    {
+        bool vertical1 = math::equals(dx1, 0);
+        bool horizontal2 = math::equals(dy2, 0);
+        if (vertical1 && horizontal2)
+        {
+            return cross(s1, s2);
+        }
+
+        bool vertical2 = math::equals(dx2, 0);
+        bool horizontal1 = math::equals(dy1, 0);
+        if (horizontal1 && vertical2)
+        {
+            return cross(s2, s1);
+        }
+        if (vertical1 || vertical2)
+        {
+            return rico<0>(dy1, dx1, dy2, dx2, s1, s2);
+        }
+        else
+        {
+            // Not crossing, take the most reasonable choice.
+            // We want to divide by the largest one.
+            //if (
+
+            return rico<1>(dx1, dy1, dx2, dy2, s1, s2);
+        }
+    }
+
+    static inline return_type collinear_touch(coordinate_type const& x,
+                coordinate_type const& y, bool, char)
+    {
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], x);
+        set<1>(result.intersections[0], y);
+        return result;
+    }
+
+    template <typename S>
+    static inline return_type collinear_inside(S const& s)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        set<0>(result.intersections[1], get<1, 0>(s));
+        set<1>(result.intersections[1], get<1, 1>(s));
+        return result;
+    }
+
+    template <typename S>
+    static inline return_type collinear_interior_boundary_intersect(S const& s, bool, bool)
+    {
+        return collinear_inside(s);
+    }
+
+    static inline return_type collinear_a_in_b(S1 const& s, bool)
+    {
+        return collinear_inside(s);
+    }
+    static inline return_type collinear_b_in_a(S2 const& s, bool)
+    {
+        return collinear_inside(s);
+    }
+
+    static inline return_type collinear_overlaps(
+                coordinate_type const& x1, coordinate_type const& y1,
+                coordinate_type const& x2, coordinate_type const& y2, bool)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], x1);
+        set<1>(result.intersections[0], y1);
+        set<0>(result.intersections[1], x2);
+        set<1>(result.intersections[1], y2);
+        return result;
+    }
+
+    static inline return_type segment_equal(S1 const& s, bool)
+    {
+        return_type result;
+        result.count = 2;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        set<0>(result.intersections[1], get<1, 0>(s));
+        set<1>(result.intersections[1], get<1, 1>(s));
+        return result;
+    }
+
+    static inline return_type disjoint()
+    {
+        return return_type();
+    }
+    static inline return_type error(std::string const& msg)
+    {
+        return return_type();
+    }
+
+    static inline return_type collinear_disjoint()
+    {
+        return return_type();
+    }
+    static inline return_type parallel()
+    {
+        return return_type();
+    }
+    static inline return_type degenerate(S1 const& s, bool)
+    {
+        return_type result;
+        result.count = 1;
+        set<0>(result.intersections[0], get<0, 0>(s));
+        set<1>(result.intersections[0], get<0, 1>(s));
+        return result;
+    }
+};
+
+
+}} // namespace policies::relate
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_INTERSECTION_POINTS_HPP
diff --git a/src/boost/geometry/policies/relate/tupled.hpp b/src/boost/geometry/policies/relate/tupled.hpp
new file mode 100644
index 0000000..f6713c4
--- /dev/null
+++ b/src/boost/geometry/policies/relate/tupled.hpp
@@ -0,0 +1,175 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP
+#define BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP
+
+
+#include <string>
+
+#include <boost/tuple/tuple.hpp>
+#include <boost/geometry/strategies/side_info.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace policies { namespace relate
+{
+
+
+// "tupled" to return intersection results together.
+// Now with two, with some meta-programming and derivations it can also be three (or more)
+template <typename Policy1, typename Policy2, typename CalculationType = void>
+struct segments_tupled
+{
+    typedef boost::tuple
+        <
+            typename Policy1::return_type,
+            typename Policy2::return_type
+        > return_type;
+
+    // Take segments of first policy, they should be equal
+    typedef typename Policy1::segment_type1 segment_type1;
+    typedef typename Policy1::segment_type2 segment_type2;
+
+    typedef typename select_calculation_type
+        <
+            segment_type1,
+            segment_type2,
+            CalculationType
+        >::type coordinate_type;
+
+    // Get the same type, but at least a double
+    typedef typename select_most_precise<coordinate_type, double>::type rtype;
+
+	template <typename R>
+    static inline return_type segments_intersect(side_info const& sides,
+				    R const& r,
+                    coordinate_type const& dx1, coordinate_type const& dy1,
+                    coordinate_type const& dx2, coordinate_type const& dy2,
+                    segment_type1 const& s1, segment_type2 const& s2)
+    {
+        return boost::make_tuple
+            (
+                Policy1::segments_intersect(sides, r,
+                    dx1, dy1, dx2, dy2, s1, s2),
+                Policy2::segments_intersect(sides, r,
+                    dx1, dy1, dx2, dy2, s1, s2)
+            );
+    }
+
+    static inline return_type collinear_touch(coordinate_type const& x,
+                coordinate_type const& y, int arrival_a, int arrival_b)
+    {
+        return boost::make_tuple
+            (
+                Policy1::collinear_touch(x, y, arrival_a, arrival_b),
+                Policy2::collinear_touch(x, y, arrival_a, arrival_b)
+            );
+    }
+
+    template <typename S>
+    static inline return_type collinear_interior_boundary_intersect(S const& segment,
+                bool a_within_b,
+                int arrival_a, int arrival_b, bool opposite)
+    {
+        return boost::make_tuple
+            (
+                Policy1::collinear_interior_boundary_intersect(segment, a_within_b, arrival_a, arrival_b, opposite),
+                Policy2::collinear_interior_boundary_intersect(segment, a_within_b, arrival_a, arrival_b, opposite)
+            );
+    }
+
+    static inline return_type collinear_a_in_b(segment_type1 const& segment,
+                bool opposite)
+    {
+        return boost::make_tuple
+            (
+                Policy1::collinear_a_in_b(segment, opposite),
+                Policy2::collinear_a_in_b(segment, opposite)
+            );
+    }
+    static inline return_type collinear_b_in_a(segment_type2 const& segment,
+                    bool opposite)
+    {
+        return boost::make_tuple
+            (
+                Policy1::collinear_b_in_a(segment, opposite),
+                Policy2::collinear_b_in_a(segment, opposite)
+            );
+    }
+
+
+    static inline return_type collinear_overlaps(
+                    coordinate_type const& x1, coordinate_type const& y1,
+                    coordinate_type const& x2, coordinate_type const& y2,
+                    int arrival_a, int arrival_b, bool opposite)
+    {
+        return boost::make_tuple
+            (
+                Policy1::collinear_overlaps(x1, y1, x2, y2, arrival_a, arrival_b, opposite),
+                Policy2::collinear_overlaps(x1, y1, x2, y2, arrival_a, arrival_b, opposite)
+            );
+    }
+
+    static inline return_type segment_equal(segment_type1 const& s,
+                bool opposite)
+    {
+        return boost::make_tuple
+            (
+                Policy1::segment_equal(s, opposite),
+                Policy2::segment_equal(s, opposite)
+            );
+    }
+
+    static inline return_type degenerate(segment_type1 const& segment,
+                bool a_degenerate)
+    {
+        return boost::make_tuple
+            (
+                Policy1::degenerate(segment, a_degenerate),
+                Policy2::degenerate(segment, a_degenerate)
+            );
+    }
+
+    static inline return_type disjoint()
+    {
+        return boost::make_tuple
+            (
+                Policy1::disjoint(),
+                Policy2::disjoint()
+            );
+    }
+
+    static inline return_type error(std::string const& msg)
+    {
+        return boost::make_tuple
+            (
+                Policy1::error(msg),
+                Policy2::error(msg)
+            );
+    }
+
+    static inline return_type collinear_disjoint()
+    {
+        return boost::make_tuple
+            (
+                Policy1::collinear_disjoint(),
+                Policy2::collinear_disjoint()
+            );
+    }
+
+};
+
+}} // namespace policies::relate
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRY_POLICIES_RELATE_TUPLED_HPP
diff --git a/src/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp b/src/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp
new file mode 100644
index 0000000..747c140
--- /dev/null
+++ b/src/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp
@@ -0,0 +1,384 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_CONVEX_GRAHAM_ANDREW_HPP
+#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_CONVEX_GRAHAM_ANDREW_HPP
+
+
+#include <cstddef>
+#include <algorithm>
+#include <vector>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/strategies/convex_hull.hpp>
+
+#include <boost/geometry/views/detail/range_type.hpp>
+
+#include <boost/geometry/policies/compare.hpp>
+
+#include <boost/geometry/algorithms/detail/for_each_range.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace convex_hull
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template
+<
+    typename InputRange,
+    typename RangeIterator,
+    typename StrategyLess,
+    typename StrategyGreater
+>
+struct get_extremes
+{
+    typedef typename point_type<InputRange>::type point_type;
+
+    point_type left, right;
+
+    bool first;
+
+    StrategyLess less;
+    StrategyGreater greater;
+
+    inline get_extremes()
+        : first(true)
+    {}
+
+    inline void apply(InputRange const& range)
+    {
+        if (boost::size(range) == 0)
+        {
+            return;
+        }
+
+        // First iterate through this range
+        // (this two-stage approach avoids many point copies,
+        //  because iterators are kept in memory. Because iterators are
+        //  not persistent (in MSVC) this approach is not applicable
+        //  for more ranges together)
+
+        RangeIterator left_it = boost::begin(range);
+        RangeIterator right_it = boost::begin(range);
+
+        for (RangeIterator it = boost::begin(range) + 1;
+            it != boost::end(range);
+            ++it)
+        {
+            if (less(*it, *left_it))
+            {
+                left_it = it;
+            }
+
+            if (greater(*it, *right_it))
+            {
+                right_it = it;
+            }
+        }
+
+        // Then compare with earlier
+        if (first)
+        {
+            // First time, assign left/right
+            left = *left_it;
+            right = *right_it;
+            first = false;
+        }
+        else
+        {
+            // Next time, check if this range was left/right from
+            // the extremes already collected
+            if (less(*left_it, left))
+            {
+                left = *left_it;
+            }
+
+            if (greater(*right_it, right))
+            {
+                right = *right_it;
+            }
+        }
+    }
+};
+
+
+template
+<
+    typename InputRange,
+    typename RangeIterator,
+    typename Container,
+    typename SideStrategy
+>
+struct assign_range
+{
+    Container lower_points, upper_points;
+
+    typedef typename point_type<InputRange>::type point_type;
+
+    point_type const& most_left;
+    point_type const& most_right;
+
+    inline assign_range(point_type const& left, point_type const& right)
+        : most_left(left)
+        , most_right(right)
+    {}
+
+    inline void apply(InputRange const& range)
+    {
+        typedef SideStrategy side;
+
+        // Put points in one of the two output sequences
+        for (RangeIterator it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            // check if it is lying most_left or most_right from the line
+
+            int dir = side::apply(most_left, most_right, *it);
+            switch(dir)
+            {
+                case 1 : // left side
+                    upper_points.push_back(*it);
+                    break;
+                case -1 : // right side
+                    lower_points.push_back(*it);
+                    break;
+
+                // 0: on line most_left-most_right,
+                //    or most_left, or most_right,
+                //    -> all never part of hull
+            }
+        }
+    }
+};
+
+template <typename Range>
+static inline void sort(Range& range)
+{
+    typedef typename boost::range_value<Range>::type point_type;
+    typedef geometry::less<point_type> comparator;
+
+    std::sort(boost::begin(range), boost::end(range), comparator());
+}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief Graham scan strategy to calculate convex hull
+\ingroup strategies
+\note Completely reworked version inspired on the sources listed below
+\see http://www.ddj.com/architect/201806315
+\see http://marknelson.us/2007/08/22/convex
+ */
+template <typename InputGeometry, typename OutputPoint>
+class graham_andrew
+{
+public :
+    typedef OutputPoint point_type;
+    typedef InputGeometry geometry_type;
+
+private:
+
+    typedef typename cs_tag<point_type>::type cs_tag;
+
+    typedef typename std::vector<point_type> container_type;
+    typedef typename std::vector<point_type>::const_iterator iterator;
+    typedef typename std::vector<point_type>::const_reverse_iterator rev_iterator;
+
+
+    class partitions
+    {
+        friend class graham_andrew;
+
+        container_type m_lower_hull;
+        container_type m_upper_hull;
+        container_type m_copied_input;
+    };
+
+
+public:
+    typedef partitions state_type;
+
+
+    inline void apply(InputGeometry const& geometry, partitions& state) const
+    {
+        // First pass.
+        // Get min/max (in most cases left / right) points
+        // This makes use of the geometry::less/greater predicates
+
+        // For the left boundary it is important that multiple points
+        // are sorted from bottom to top. Therefore the less predicate
+        // does not take the x-only template parameter (this fixes ticket #6019.
+        // For the right boundary it is not necessary (though also not harmful), 
+        // because points are sorted from bottom to top in a later stage.
+        // For symmetry and to get often more balanced lower/upper halves
+        // we keep it.
+
+        typedef typename geometry::detail::range_type<InputGeometry>::type range_type;
+
+        typedef typename boost::range_iterator
+            <
+                range_type const
+            >::type range_iterator;
+
+        detail::get_extremes
+            <
+                range_type,
+                range_iterator,
+                geometry::less<point_type>,
+                geometry::greater<point_type>
+            > extremes;
+        geometry::detail::for_each_range(geometry, extremes);
+
+        // Bounding left/right points
+        // Second pass, now that extremes are found, assign all points
+        // in either lower, either upper
+        detail::assign_range
+            <
+                range_type,
+                range_iterator,
+                container_type,
+                typename strategy::side::services::default_strategy<cs_tag>::type
+            > assigner(extremes.left, extremes.right);
+
+        geometry::detail::for_each_range(geometry, assigner);
+
+
+        // Sort both collections, first on x(, then on y)
+        detail::sort(assigner.lower_points);
+        detail::sort(assigner.upper_points);
+
+        //std::cout << boost::size(assigner.lower_points) << std::endl;
+        //std::cout << boost::size(assigner.upper_points) << std::endl;
+
+        // And decide which point should be in the final hull
+        build_half_hull<-1>(assigner.lower_points, state.m_lower_hull,
+                extremes.left, extremes.right);
+        build_half_hull<1>(assigner.upper_points, state.m_upper_hull,
+                extremes.left, extremes.right);
+    }
+
+
+    template <typename OutputIterator>
+    inline void result(partitions const& state,
+                    OutputIterator out, bool clockwise)  const
+    {
+        if (clockwise)
+        {
+            output_range<iterate_forward>(state.m_upper_hull, out, false);
+            output_range<iterate_reverse>(state.m_lower_hull, out, true);
+        }
+        else
+        {
+            output_range<iterate_forward>(state.m_lower_hull, out, false);
+            output_range<iterate_reverse>(state.m_upper_hull, out, true);
+        }
+    }
+
+
+private:
+
+    template <int Factor>
+    static inline void build_half_hull(container_type const& input,
+            container_type& output,
+            point_type const& left, point_type const& right)
+    {
+        output.push_back(left);
+        for(iterator it = input.begin(); it != input.end(); ++it)
+        {
+            add_to_hull<Factor>(*it, output);
+        }
+        add_to_hull<Factor>(right, output);
+    }
+
+
+    template <int Factor>
+    static inline void add_to_hull(point_type const& p, container_type& output)
+    {
+        typedef typename strategy::side::services::default_strategy<cs_tag>::type side;
+
+        output.push_back(p);
+        register std::size_t output_size = output.size();
+        while (output_size >= 3)
+        {
+            rev_iterator rit = output.rbegin();
+            point_type const& last = *rit++;
+            point_type const& last2 = *rit++;
+
+            if (Factor * side::apply(*rit, last, last2) <= 0)
+            {
+                // Remove last two points from stack, and add last again
+                // This is much faster then erasing the one but last.
+                output.pop_back();
+                output.pop_back();
+                output.push_back(last);
+                output_size--;
+            }
+            else
+            {
+                return;
+            }
+        }
+    }
+
+
+    template <iterate_direction Direction, typename OutputIterator>
+    static inline void output_range(container_type const& range,
+        OutputIterator out, bool skip_first)
+    {
+        typedef typename reversible_view<container_type const, Direction>::type view_type;
+        view_type view(range);
+        bool first = true;
+        for (typename boost::range_iterator<view_type const>::type it = boost::begin(view);
+            it != boost::end(view); ++it)
+        {
+            if (first && skip_first)
+            {
+                first = false;
+            }
+            else
+            {
+                *out = *it;
+                ++out;
+            }
+        }
+    }
+
+};
+
+}} // namespace strategy::convex_hull
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+template <typename InputGeometry, typename OutputPoint>
+struct strategy_convex_hull<InputGeometry, OutputPoint, cartesian_tag>
+{
+    typedef strategy::convex_hull::graham_andrew<InputGeometry, OutputPoint> type;
+};
+#endif
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_CONVEX_GRAHAM_ANDREW_HPP
diff --git a/src/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp b/src/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp
new file mode 100644
index 0000000..1398ddb
--- /dev/null
+++ b/src/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp
@@ -0,0 +1,151 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_POINT_IN_BOX_BY_SIDE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_POINT_IN_BOX_BY_SIDE_HPP
+
+#include <boost/array.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/strategies/covered_by.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+
+namespace boost { namespace geometry { namespace strategy 
+{
+    
+namespace within
+{
+
+struct decide_within
+{
+    static inline bool apply(int side, bool& result)
+    {
+        if (side != 1)
+        {
+            result = false;
+            return false;
+        }
+        return true; // continue
+    }
+};
+
+struct decide_covered_by
+{
+    static inline bool apply(int side, bool& result)
+    {
+        if (side != 1)
+        {
+            result = side >= 0;
+            return false;
+        }
+        return true; // continue
+    }
+};
+
+
+template <typename Point, typename Box, typename Decide = decide_within>
+struct point_in_box_by_side
+{
+    typedef typename strategy::side::services::default_strategy
+    <
+        typename cs_tag<Box>::type
+    >::type side_strategy_type;
+
+    static inline bool apply(Point const& point, Box const& box)
+    {
+        // Create (counterclockwise) array of points, the fifth one closes it
+        // Every point should be on the LEFT side (=1), or ON the border (=0),
+        // So >= 1 or >= 0
+        boost::array<typename point_type<Box>::type, 5> bp;
+        geometry::detail::assign_box_corners_oriented<true>(box, bp);
+        bp[4] = bp[0];
+        
+        bool result = true;
+        side_strategy_type strategy;
+        boost::ignore_unused_variable_warning(strategy);
+        
+        for (int i = 1; i < 5; i++)
+        {
+            int const side = strategy.apply(point, bp[i - 1], bp[i]);
+            if (! Decide::apply(side, result))
+            {
+                return result;
+            }
+        }
+    
+        return result;
+    }
+};
+
+
+} // namespace within
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+namespace within { namespace services
+{
+
+template <typename Point, typename Box>
+struct default_strategy
+    <
+        point_tag, box_tag, 
+        point_tag, areal_tag, 
+        spherical_tag, spherical_tag, 
+        Point, Box
+    >
+{
+    typedef within::point_in_box_by_side
+                <
+                    Point, Box, within::decide_within
+                > type;
+};
+
+
+
+}} // namespace within::services
+
+
+namespace covered_by { namespace services
+{
+
+
+template <typename Point, typename Box>
+struct default_strategy
+    <
+        point_tag, box_tag, 
+        point_tag, areal_tag, 
+        spherical_tag, spherical_tag, 
+        Point, Box
+    >
+{
+    typedef within::point_in_box_by_side
+                <
+                    Point, Box, within::decide_covered_by
+                > type;
+};
+
+
+}} // namespace covered_by::services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}}} // namespace boost::geometry::strategy
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_POINT_IN_BOX_BY_SIDE_HPP
diff --git a/src/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp b/src/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp
new file mode 100644
index 0000000..423948f
--- /dev/null
+++ b/src/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp
@@ -0,0 +1,208 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP
+#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP
+
+
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace within
+{
+
+/*!
+\brief Within detection using winding rule, but checking if enclosing ring is
+    counter clockwise and, if so, reverses the result
+\ingroup strategies
+\tparam Point \tparam_point
+\tparam Reverse True if parameter should be reversed
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+\author Barend Gehrels
+\note The implementation is inspired by terralib http://www.terralib.org (LGPL)
+\note but totally revised afterwards, especially for cases on segments
+\note Only dependant on "side", -> agnostic, suitable for spherical/latlong
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
+}
+ */
+template
+<
+    bool Reverse,
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void
+>
+class oriented_winding
+{
+    typedef typename select_calculation_type
+        <
+            Point,
+            PointOfSegment,
+            CalculationType
+        >::type calculation_type;
+
+
+    typedef typename strategy::side::services::default_strategy
+        <
+            typename cs_tag<Point>::type
+        >::type strategy_side_type;
+
+
+    /*! subclass to keep state */
+    class counter
+    {
+        int m_count;
+        bool m_touches;
+        calculation_type m_sum_area;
+
+        inline int code() const
+        {
+            return m_touches ? 0 : m_count == 0 ? -1 : 1;
+        }
+        inline int clockwise_oriented_code() const
+        {
+            return (m_sum_area > 0) ? code() : -code();
+        }
+        inline int oriented_code() const
+        {
+            return Reverse
+                ? -clockwise_oriented_code()
+                : clockwise_oriented_code();
+        }
+
+    public :
+        friend class oriented_winding;
+
+        inline counter()
+            : m_count(0)
+            , m_touches(false)
+            , m_sum_area(0)
+        {}
+
+        inline void add_to_area(calculation_type triangle)
+        {
+            m_sum_area += triangle;
+        }
+
+    };
+
+
+    template <size_t D>
+    static inline int check_touch(Point const& point,
+                PointOfSegment const& seg1, PointOfSegment const& seg2,
+                counter& state)
+    {
+        calculation_type const p = get<D>(point);
+        calculation_type const s1 = get<D>(seg1);
+        calculation_type const s2 = get<D>(seg2);
+        if ((s1 <= p && s2 >= p) || (s2 <= p && s1 >= p))
+        {
+            state.m_touches = true;
+        }
+        return 0;
+    }
+
+
+    template <size_t D>
+    static inline int check_segment(Point const& point,
+                PointOfSegment const& seg1, PointOfSegment const& seg2,
+                counter& state)
+    {
+        calculation_type const p = get<D>(point);
+        calculation_type const s1 = get<D>(seg1);
+        calculation_type const s2 = get<D>(seg2);
+
+
+        // Check if one of segment endpoints is at same level of point
+        bool eq1 = math::equals(s1, p);
+        bool eq2 = math::equals(s2, p);
+
+        if (eq1 && eq2)
+        {
+            // Both equal p -> segment is horizontal (or vertical for D=0)
+            // The only thing which has to be done is check if point is ON segment
+            return check_touch<1 - D>(point, seg1, seg2, state);
+        }
+
+        return
+              eq1 ? (s2 > p ?  1 : -1)  // Point on level s1, UP/DOWN depending on s2
+            : eq2 ? (s1 > p ? -1 :  1)  // idem
+            : s1 < p && s2 > p ?  2     // Point between s1 -> s2 --> UP
+            : s2 < p && s1 > p ? -2     // Point between s2 -> s1 --> DOWN
+            : 0;
+    }
+
+
+
+
+public :
+
+    // Typedefs and static methods to fulfill the concept
+    typedef Point point_type;
+    typedef PointOfSegment segment_point_type;
+    typedef counter state_type;
+
+    static inline bool apply(Point const& point,
+                PointOfSegment const& s1, PointOfSegment const& s2,
+                counter& state)
+    {
+        state.add_to_area(get<0>(s2) * get<1>(s1) - get<0>(s1) * get<1>(s2));
+
+        int count = check_segment<1>(point, s1, s2, state);
+        if (count != 0)
+        {
+            int side = strategy_side_type::apply(s1, s2, point);
+            if (side == 0)
+            {
+                // Point is lying on segment
+                state.m_touches = true;
+                state.m_count = 0;
+                return false;
+            }
+
+            // Side is NEG for right, POS for left.
+            // The count is -2 for down, 2 for up (or -1/1)
+            // Side positive thus means UP and LEFTSIDE or DOWN and RIGHTSIDE
+            // See accompagnying figure (TODO)
+            if (side * count > 0)
+            {
+                state.m_count += count;
+            }
+        }
+        return ! state.m_touches;
+    }
+
+    static inline int result(counter const& state)
+    {
+        return state.oriented_code();
+    }
+};
+
+
+}} // namespace strategy::within
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP
diff --git a/src/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp b/src/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp
new file mode 100644
index 0000000..6918865
--- /dev/null
+++ b/src/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp
@@ -0,0 +1,232 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
+#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
+
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/strategies/covered_by.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace within
+{
+
+/*!
+\brief Within detection using winding rule
+\ingroup strategies
+\tparam Point \tparam_point
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+\author Barend Gehrels
+\note The implementation is inspired by terralib http://www.terralib.org (LGPL)
+\note but totally revised afterwards, especially for cases on segments
+\note Only dependant on "side", -> agnostic, suitable for spherical/latlong
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
+}
+ */
+template
+<
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void
+>
+class winding
+{
+    typedef typename select_calculation_type
+        <
+            Point,
+            PointOfSegment,
+            CalculationType
+        >::type calculation_type;
+
+
+    typedef typename strategy::side::services::default_strategy
+        <
+            typename cs_tag<Point>::type
+        >::type strategy_side_type;
+
+
+    /*! subclass to keep state */
+    class counter
+    {
+        int m_count;
+        bool m_touches;
+
+        inline int code() const
+        {
+            return m_touches ? 0 : m_count == 0 ? -1 : 1;
+        }
+
+    public :
+        friend class winding;
+
+        inline counter()
+            : m_count(0)
+            , m_touches(false)
+        {}
+
+    };
+
+
+    template <size_t D>
+    static inline int check_touch(Point const& point,
+                PointOfSegment const& seg1, PointOfSegment const& seg2,
+                counter& state)
+    {
+        calculation_type const p = get<D>(point);
+        calculation_type const s1 = get<D>(seg1);
+        calculation_type const s2 = get<D>(seg2);
+        if ((s1 <= p && s2 >= p) || (s2 <= p && s1 >= p))
+        {
+            state.m_touches = true;
+        }
+        return 0;
+    }
+
+
+    template <size_t D>
+    static inline int check_segment(Point const& point,
+                PointOfSegment const& seg1, PointOfSegment const& seg2,
+                counter& state)
+    {
+        calculation_type const p = get<D>(point);
+        calculation_type const s1 = get<D>(seg1);
+        calculation_type const s2 = get<D>(seg2);
+
+        // Check if one of segment endpoints is at same level of point
+        bool eq1 = math::equals(s1, p);
+        bool eq2 = math::equals(s2, p);
+
+        if (eq1 && eq2)
+        {
+            // Both equal p -> segment is horizontal (or vertical for D=0)
+            // The only thing which has to be done is check if point is ON segment
+            return check_touch<1 - D>(point, seg1, seg2,state);
+        }
+
+        return
+              eq1 ? (s2 > p ?  1 : -1)  // Point on level s1, UP/DOWN depending on s2
+            : eq2 ? (s1 > p ? -1 :  1)  // idem
+            : s1 < p && s2 > p ?  2     // Point between s1 -> s2 --> UP
+            : s2 < p && s1 > p ? -2     // Point between s2 -> s1 --> DOWN
+            : 0;
+    }
+
+
+
+
+public :
+
+    // Typedefs and static methods to fulfill the concept
+    typedef Point point_type;
+    typedef PointOfSegment segment_point_type;
+    typedef counter state_type;
+
+    static inline bool apply(Point const& point,
+                PointOfSegment const& s1, PointOfSegment const& s2,
+                counter& state)
+    {
+        int count = check_segment<1>(point, s1, s2, state);
+        if (count != 0)
+        {
+            int side = strategy_side_type::apply(s1, s2, point);
+            if (side == 0)
+            {
+                // Point is lying on segment
+                state.m_touches = true;
+                state.m_count = 0;
+                return false;
+            }
+
+            // Side is NEG for right, POS for left.
+            // The count is -2 for down, 2 for up (or -1/1)
+            // Side positive thus means UP and LEFTSIDE or DOWN and RIGHTSIDE
+            // See accompagnying figure (TODO)
+            if (side * count > 0)
+            {
+                state.m_count += count;
+            }
+        }
+        return ! state.m_touches;
+    }
+
+    static inline int result(counter const& state)
+    {
+        return state.code();
+    }
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+
+// Register using "areal_tag" for ring, polygon, multi-polygon
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, cartesian_tag, cartesian_tag, Point, Geometry>
+{
+    typedef winding<Point, typename geometry::point_type<Geometry>::type> type;
+};
+
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, spherical_tag, spherical_tag, Point, Geometry>
+{
+    typedef winding<Point, typename geometry::point_type<Geometry>::type> type;
+};
+
+
+} // namespace services
+
+#endif
+
+
+}} // namespace strategy::within
+
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace strategy { namespace covered_by { namespace services
+{
+
+// Register using "areal_tag" for ring, polygon, multi-polygon
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, cartesian_tag, cartesian_tag, Point, Geometry>
+{
+    typedef strategy::within::winding<Point, typename geometry::point_type<Geometry>::type> type;
+};
+
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, spherical_tag, spherical_tag, Point, Geometry>
+{
+    typedef strategy::within::winding<Point, typename geometry::point_type<Geometry>::type> type;
+};
+
+
+}}} // namespace strategy::covered_by::services
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
diff --git a/src/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp b/src/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp
new file mode 100644
index 0000000..4a1a22d
--- /dev/null
+++ b/src/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp
@@ -0,0 +1,229 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 1995, 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 1995 Maarten Hilferink, Amsterdam, the Netherlands
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
+#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
+
+
+#include <cstddef>
+#include <vector>
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/strategies/distance.hpp>
+
+
+
+//#define GL_DEBUG_DOUGLAS_PEUCKER
+
+#ifdef GL_DEBUG_DOUGLAS_PEUCKER
+#include <boost/geometry/io/dsv/write.hpp>
+#endif
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace simplify
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+    /*!
+        \brief Small wrapper around a point, with an extra member "included"
+        \details
+            It has a const-reference to the original point (so no copy here)
+        \tparam the enclosed point type
+    */
+    template<typename Point>
+    struct douglas_peucker_point
+    {
+        Point const& p;
+        bool included;
+
+        inline douglas_peucker_point(Point const& ap)
+            : p(ap)
+            , included(false)
+        {}
+
+        // Necessary for proper compilation
+        inline douglas_peucker_point<Point> operator=(douglas_peucker_point<Point> const& )
+        {
+            return douglas_peucker_point<Point>(*this);
+        }
+    };
+}
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief Implements the simplify algorithm.
+\ingroup strategies
+\details The douglas_peucker strategy simplifies a linestring, ring or
+    vector of points using the well-known Douglas-Peucker algorithm.
+    For the algorithm, see for example:
+\see http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
+\see http://www2.dcs.hull.ac.uk/CISRG/projects/Royal-Inst/demos/dp.html
+\tparam Point the point type
+\tparam PointDistanceStrategy point-segment distance strategy to be used
+\note This strategy uses itself a point-segment-distance strategy which
+    can be specified
+\author Barend and Maarten, 1995/1996
+\author Barend, revised for Generic Geometry Library, 2008
+*/
+template
+<
+    typename Point,
+    typename PointDistanceStrategy
+>
+class douglas_peucker
+{
+public :
+
+	// See also ticket 5954 https://svn.boost.org/trac/boost/ticket/5954
+	// Comparable is currently not possible here because it has to be compared to the squared of max_distance, and more.
+	// For now we have to take the real distance.
+	typedef PointDistanceStrategy distance_strategy_type;
+    // typedef typename strategy::distance::services::comparable_type<PointDistanceStrategy>::type distance_strategy_type;
+
+    typedef typename strategy::distance::services::return_type<distance_strategy_type>::type return_type;
+
+private :
+    typedef detail::douglas_peucker_point<Point> dp_point_type;
+    typedef typename std::vector<dp_point_type>::iterator iterator_type;
+
+
+    static inline void consider(iterator_type begin,
+                iterator_type end,
+                return_type const& max_dist, int& n,
+                distance_strategy_type const& ps_distance_strategy)
+    {
+        std::size_t size = end - begin;
+
+        // size must be at least 3
+        // because we want to consider a candidate point in between
+        if (size <= 2)
+        {
+#ifdef GL_DEBUG_DOUGLAS_PEUCKER
+            if (begin != end)
+            {
+                std::cout << "ignore between " << dsv(begin->p)
+                    << " and " << dsv((end - 1)->p)
+                    << " size=" << size << std::endl;
+            }
+            std::cout << "return because size=" << size << std::endl;
+#endif
+            return;
+        }
+
+        iterator_type last = end - 1;
+
+#ifdef GL_DEBUG_DOUGLAS_PEUCKER
+        std::cout << "find between " << dsv(begin->p)
+            << " and " << dsv(last->p)
+            << " size=" << size << std::endl;
+#endif
+
+
+        // Find most far point, compare to the current segment
+        //geometry::segment<Point const> s(begin->p, last->p);
+        return_type md(-1.0); // any value < 0
+        iterator_type candidate;
+        for(iterator_type it = begin + 1; it != last; ++it)
+        {
+            return_type dist = ps_distance_strategy.apply(it->p, begin->p, last->p);
+
+#ifdef GL_DEBUG_DOUGLAS_PEUCKER
+            std::cout << "consider " << dsv(it->p)
+                << " at " << double(dist)
+                << ((dist > max_dist) ? " maybe" : " no") 
+                << std::endl;
+
+#endif
+            if (dist > md)
+            {
+                md = dist;
+                candidate = it;
+            }
+        }
+
+        // If a point is found, set the include flag
+        // and handle segments in between recursively
+        if (md > max_dist)
+        {
+#ifdef GL_DEBUG_DOUGLAS_PEUCKER
+            std::cout << "use " << dsv(candidate->p) << std::endl;
+#endif
+
+            candidate->included = true;
+            n++;
+
+            consider(begin, candidate + 1, max_dist, n, ps_distance_strategy);
+            consider(candidate, end, max_dist, n, ps_distance_strategy);
+        }
+    }
+
+
+public :
+
+    template <typename Range, typename OutputIterator>
+    static inline OutputIterator apply(Range const& range,
+                    OutputIterator out, double max_distance)
+    {
+        distance_strategy_type strategy;
+
+        // Copy coordinates, a vector of references to all points
+        std::vector<dp_point_type> ref_candidates(boost::begin(range),
+                        boost::end(range));
+
+        // Include first and last point of line,
+        // they are always part of the line
+        int n = 2;
+        ref_candidates.front().included = true;
+        ref_candidates.back().included = true;
+
+        // Get points, recursively, including them if they are further away
+        // than the specified distance
+        typedef typename strategy::distance::services::return_type<distance_strategy_type>::type return_type;
+
+        consider(boost::begin(ref_candidates), boost::end(ref_candidates), max_distance, n, strategy);
+
+        // Copy included elements to the output
+        for(typename std::vector<dp_point_type>::const_iterator it
+                        = boost::begin(ref_candidates);
+            it != boost::end(ref_candidates);
+            ++it)
+        {
+            if (it->included)
+            {
+                // copy-coordinates does not work because OutputIterator
+                // does not model Point (??)
+                //geometry::convert(it->p, *out);
+                *out = it->p;
+                out++;
+            }
+        }
+        return out;
+    }
+
+};
+
+}} // namespace strategy::simplify
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
diff --git a/src/boost/geometry/strategies/area.hpp b/src/boost/geometry/strategies/area.hpp
new file mode 100644
index 0000000..e192d9b
--- /dev/null
+++ b/src/boost/geometry/strategies/area.hpp
@@ -0,0 +1,50 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_AREA_HPP
+#define BOOST_GEOMETRY_STRATEGIES_AREA_HPP
+
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/strategies/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace area { namespace services
+{
+
+/*!
+    \brief Traits class binding a default area strategy to a coordinate system
+    \ingroup area
+    \tparam Tag tag of coordinate system
+    \tparam PointOfSegment point-type
+*/
+template <typename Tag, typename PointOfSegment>
+struct default_strategy
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE
+            , (types<PointOfSegment>)
+        );
+};
+
+
+}}} // namespace strategy::area::services
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_AREA_HPP
diff --git a/src/boost/geometry/strategies/cartesian/area_surveyor.hpp b/src/boost/geometry/strategies/cartesian/area_surveyor.hpp
new file mode 100644
index 0000000..74b6353
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/area_surveyor.hpp
@@ -0,0 +1,134 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_SURVEYOR_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_SURVEYOR_HPP
+
+
+#include <boost/mpl/if.hpp>
+
+#include <boost/geometry/arithmetic/determinant.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace area
+{
+
+/*!
+\brief Area calculation for cartesian points
+\ingroup strategies
+\details Calculates area using the Surveyor's formula, a well-known
+    triangulation algorithm
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)]
+}
+
+*/
+template
+<
+    typename PointOfSegment,
+    typename CalculationType = void
+>
+class surveyor
+{
+public :
+    // If user specified a calculation type, use that type,
+    //   whatever it is and whatever the point-type is.
+    // Else, use the pointtype, but at least double
+    typedef typename
+        boost::mpl::if_c
+        <
+            boost::is_void<CalculationType>::type::value,
+            typename select_most_precise
+            <
+                typename coordinate_type<PointOfSegment>::type,
+                double
+            >::type,
+            CalculationType
+        >::type return_type;
+
+
+private :
+
+    class summation
+    {
+        friend class surveyor;
+
+        return_type sum;
+    public :
+
+        inline summation() : sum(return_type())
+        {
+            // Strategy supports only 2D areas
+            assert_dimension<PointOfSegment, 2>();
+        }
+        inline return_type area() const
+        {
+            return_type result = sum;
+            return_type const two = 2;
+            result /= two;
+            return result;
+        }
+    };
+
+public :
+    typedef summation state_type;
+    typedef PointOfSegment segment_point_type;
+
+    static inline void apply(PointOfSegment const& p1,
+                PointOfSegment const& p2,
+                summation& state)
+    {
+        // SUM += x2 * y1 - x1 * y2;
+        state.sum += detail::determinant<return_type>(p2, p1);
+    }
+
+    static inline return_type result(summation const& state)
+    {
+        return state.area();
+    }
+
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+    template <typename Point>
+    struct default_strategy<cartesian_tag, Point>
+    {
+        typedef strategy::area::surveyor<Point> type;
+    };
+
+} // namespace services
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::area
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_AREA_SURVEYOR_HPP
diff --git a/src/boost/geometry/strategies/cartesian/box_in_box.hpp b/src/boost/geometry/strategies/cartesian/box_in_box.hpp
new file mode 100644
index 0000000..7680b83
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/box_in_box.hpp
@@ -0,0 +1,176 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/strategies/covered_by.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+
+namespace boost { namespace geometry { namespace strategy 
+{
+    
+   
+namespace within
+{
+
+struct box_within_range
+{
+    template <typename BoxContainedValue, typename BoxContainingValue>
+    static inline bool apply(BoxContainedValue const& bed_min
+                , BoxContainedValue const& bed_max
+                , BoxContainingValue const& bing_min
+                , BoxContainingValue const& bing_max)
+    {
+        return bed_min > bing_min && bed_max < bing_max;
+    }
+};
+
+
+struct box_covered_by_range
+{
+    template <typename BoxContainedValue, typename BoxContainingValue>
+    static inline bool apply(BoxContainedValue const& bed_min
+                , BoxContainedValue const& bed_max
+                , BoxContainingValue const& bing_min
+                , BoxContainingValue const& bing_max)
+    {
+        return bed_min >= bing_min && bed_max <= bing_max;
+    }
+};
+
+
+template
+<
+    typename SubStrategy,
+    typename Box1,
+    typename Box2,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct relate_box_box_loop
+{
+    static inline bool apply(Box1 const& b_contained, Box2 const& b_containing)
+    {
+        assert_dimension_equal<Box1, Box2>();
+
+        if (! SubStrategy::apply(
+                    get<min_corner, Dimension>(b_contained), 
+                    get<max_corner, Dimension>(b_contained), 
+                    get<min_corner, Dimension>(b_containing), 
+                    get<max_corner, Dimension>(b_containing)
+                )
+            )
+        {
+            return false;
+        }
+
+        return relate_box_box_loop
+            <
+                SubStrategy,
+                Box1, Box2,
+                Dimension + 1, DimensionCount
+            >::apply(b_contained, b_containing);
+    }
+};
+
+template
+<
+    typename SubStrategy,
+    typename Box1,
+    typename Box2,
+    std::size_t DimensionCount
+>
+struct relate_box_box_loop<SubStrategy, Box1, Box2, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Box1 const& , Box2 const& )
+    {
+        return true;
+    }
+};
+
+template
+<
+    typename Box1,
+    typename Box2,
+    typename SubStrategy = box_within_range
+>
+struct box_in_box
+{
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        return relate_box_box_loop
+            <
+                SubStrategy, 
+                Box1, Box2, 0, dimension<Box1>::type::value
+            >::apply(box1, box2);
+    }
+};
+
+
+} // namespace within
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+namespace within { namespace services
+{
+
+template <typename BoxContained, typename BoxContaining>
+struct default_strategy
+    <
+        box_tag, box_tag, 
+        box_tag, areal_tag, 
+        cartesian_tag, cartesian_tag, 
+        BoxContained, BoxContaining
+    >
+{
+    typedef within::box_in_box<BoxContained, BoxContaining> type;
+};
+
+
+}} // namespace within::services
+
+namespace covered_by { namespace services
+{
+
+template <typename BoxContained, typename BoxContaining>
+struct default_strategy
+    <
+        box_tag, box_tag, 
+        box_tag, areal_tag, 
+        cartesian_tag, cartesian_tag, 
+        BoxContained, BoxContaining
+    >
+{
+    typedef within::box_in_box
+                <
+                    BoxContained, BoxContaining,
+                    within::box_covered_by_range
+                > type;
+};
+
+}} // namespace covered_by::services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}}} // namespace boost::geometry::strategy
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BOX_IN_BOX_HPP
diff --git a/src/boost/geometry/strategies/cartesian/cart_intersect.hpp b/src/boost/geometry/strategies/cartesian/cart_intersect.hpp
new file mode 100644
index 0000000..ed0f500
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/cart_intersect.hpp
@@ -0,0 +1,738 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INTERSECTION_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INTERSECTION_HPP
+
+#include <algorithm>
+
+#include <boost/geometry/core/exception.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/geometries/concepts/segment_concept.hpp>
+
+#include <boost/geometry/arithmetic/determinant.hpp>
+#include <boost/geometry/algorithms/detail/assign_values.hpp>
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+
+// Temporary / will be Strategy as template parameter
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
+
+#include <boost/geometry/strategies/side_info.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace intersection
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <std::size_t Dimension, typename Segment, typename T>
+static inline void segment_arrange(Segment const& s, T& s_1, T& s_2, bool& swapped)
+{
+    s_1 = get<0, Dimension>(s);
+    s_2 = get<1, Dimension>(s);
+    if (s_1 > s_2)
+    {
+        std::swap(s_1, s_2);
+        swapped = true;
+    }
+}
+
+template <std::size_t Index, typename Segment>
+inline typename geometry::point_type<Segment>::type get_from_index(
+            Segment const& segment)
+{
+    typedef typename geometry::point_type<Segment>::type point_type;
+    point_type point;
+    geometry::detail::assign::assign_point_from_index
+        <
+            Segment, point_type, Index, 0, dimension<Segment>::type::value
+        >::apply(segment, point);
+    return point;
+}
+
+}
+#endif
+
+/***
+template <typename T>
+inline std::string rdebug(T const& value)
+{
+    if (math::equals(value, 0)) return "'0'";
+    if (math::equals(value, 1)) return "'1'";
+    if (value < 0) return "<0";
+    if (value > 1) return ">1";
+    return "<0..1>";
+}
+***/
+
+/*!
+    \see http://mathworld.wolfram.com/Line-LineIntersection.html
+ */
+template <typename Policy, typename CalculationType = void>
+struct relate_cartesian_segments
+{
+    typedef typename Policy::return_type return_type;
+    typedef typename Policy::segment_type1 segment_type1;
+    typedef typename Policy::segment_type2 segment_type2;
+
+    //typedef typename point_type<segment_type1>::type point_type;
+    //BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+
+    BOOST_CONCEPT_ASSERT( (concept::ConstSegment<segment_type1>) );
+    BOOST_CONCEPT_ASSERT( (concept::ConstSegment<segment_type2>) );
+
+    typedef typename select_calculation_type
+        <segment_type1, segment_type2, CalculationType>::type coordinate_type;
+
+    /// Relate segments a and b
+    static inline return_type apply(segment_type1 const& a, segment_type2 const& b)
+    {
+        coordinate_type const dx_a = get<1, 0>(a) - get<0, 0>(a); // distance in x-dir
+        coordinate_type const dx_b = get<1, 0>(b) - get<0, 0>(b);
+        coordinate_type const dy_a = get<1, 1>(a) - get<0, 1>(a); // distance in y-dir
+        coordinate_type const dy_b = get<1, 1>(b) - get<0, 1>(b);
+        return apply(a, b, dx_a, dy_a, dx_b, dy_b);
+    }
+
+
+    // Relate segments a and b using precalculated differences.
+    // This can save two or four subtractions in many cases
+    static inline return_type apply(segment_type1 const& a, segment_type2 const& b,
+            coordinate_type const& dx_a, coordinate_type const& dy_a,
+            coordinate_type const& dx_b, coordinate_type const& dy_b)
+    {
+        typedef side::side_by_triangle<coordinate_type> side;
+        side_info sides;
+
+        bool collinear_use_first = math::abs(dx_a) + math::abs(dx_b) >= math::abs(dy_a) + math::abs(dy_b);
+
+        sides.set<0>
+            (
+                side::apply(detail::get_from_index<0>(b)
+                    , detail::get_from_index<1>(b)
+                    , detail::get_from_index<0>(a)),
+                side::apply(detail::get_from_index<0>(b)
+                    , detail::get_from_index<1>(b)
+                    , detail::get_from_index<1>(a))
+            );
+        sides.set<1>
+            (
+                side::apply(detail::get_from_index<0>(a)
+                    , detail::get_from_index<1>(a)
+                    , detail::get_from_index<0>(b)),
+                side::apply(detail::get_from_index<0>(a)
+                    , detail::get_from_index<1>(a)
+                    , detail::get_from_index<1>(b))
+            );
+
+        bool collinear = sides.collinear();
+
+        robustness_verify_collinear(a, b, sides, collinear);
+        robustness_verify_meeting(a, b, sides, collinear, collinear_use_first);
+
+        if (sides.same<0>() || sides.same<1>())
+        {
+            // Both points are at same side of other segment, we can leave
+            if (robustness_verify_same_side(a, b, sides))
+            {
+                return Policy::disjoint();
+            }
+        }
+
+        // Degenerate cases: segments of single point, lying on other segment, non disjoint
+        coordinate_type const zero = 0;
+        if (math::equals(dx_a, zero) && math::equals(dy_a, zero))
+        {
+            return Policy::degenerate(a, true);
+        }
+        if (math::equals(dx_b, zero) && math::equals(dy_b, zero))
+        {
+            return Policy::degenerate(b, false);
+        }
+
+        typedef typename select_most_precise
+            <
+                coordinate_type, double
+            >::type promoted_type;
+
+        // r: ratio 0-1 where intersection divides A/B
+		// (only calculated for non-collinear segments)
+		promoted_type r;
+		if (! collinear)
+		{
+	        // Calculate determinants - Cramers rule
+			coordinate_type const wx = get<0, 0>(a) - get<0, 0>(b);
+			coordinate_type const wy = get<0, 1>(a) - get<0, 1>(b);
+			coordinate_type const d = geometry::detail::determinant<coordinate_type>(dx_a, dy_a, dx_b, dy_b);
+			coordinate_type const da = geometry::detail::determinant<coordinate_type>(dx_b, dy_b, wx, wy);
+
+	        coordinate_type const zero = coordinate_type();
+			if (math::equals(d, zero))
+			{
+				// This is still a collinear case (because of FP imprecision this can occur here)
+				// sides.debug();
+				sides.set<0>(0,0);
+				sides.set<1>(0,0);
+				collinear = true;
+			}
+			else
+			{
+				r = da / d;
+
+                if (! robustness_verify_r(a, b, r))
+                {
+                    return Policy::disjoint();
+                }
+
+                robustness_handle_meeting(a, b, sides, dx_a, dy_a, wx, wy, d, r);
+
+                if (robustness_verify_disjoint_at_one_collinear(a, b, sides))
+                {
+                    return Policy::disjoint();
+                }
+
+			}
+		}
+
+        if(collinear)
+        {
+            if (collinear_use_first)
+            {
+                return relate_collinear<0>(a, b);
+            }
+            else
+            {
+				// Y direction contains larger segments (maybe dx is zero)
+                return relate_collinear<1>(a, b);
+            }
+        }
+
+        return Policy::segments_intersect(sides, r,
+            dx_a, dy_a, dx_b, dy_b,
+            a, b);
+    }
+
+private :
+
+
+	// Ratio should lie between 0 and 1
+	// Also these three conditions might be of FP imprecision, the segments were actually (nearly) collinear
+    template <typename T>
+    static inline bool robustness_verify_r(
+                segment_type1 const& a, segment_type2 const& b,
+                T& r)
+    {
+		T const zero = 0;
+		T const one = 1;
+        if (r < zero || r > one)
+        {
+		    if (verify_disjoint<0>(a, b) || verify_disjoint<1>(a, b))
+		    {
+			    // Can still be disjoint (even if not one is left or right from another)
+                // This is e.g. in case #snake4 of buffer test.
+			    return false;
+		    }
+
+            //std::cout << "ROBUSTNESS: correction of r " << r << std::endl;
+            // sides.debug();
+
+            // ROBUSTNESS: the r value can in epsilon-cases much larger than 1, while (with perfect arithmetic)
+            // it should be one. It can be 1.14 or even 1.98049 or 2 (while still intersecting)
+
+            // If segments are crossing (we can see that with the sides)
+            // and one is inside the other, there must be an intersection point.
+            // We correct for that.
+            // This is (only) in case #ggl_list_20110820_christophe in unit tests
+
+            // If segments are touching (two sides zero), of course they should intersect
+            // This is (only) in case #buffer_rt_i in the unit tests)
+
+            // If one touches in the middle, they also should intersect (#buffer_rt_j)
+
+            // Note that even for ttmath r is occasionally > 1, e.g. 1.0000000000000000000000036191231203575
+
+            if (r > one)
+            {
+                r = one;
+            }
+            else if (r < zero)
+            {
+    		    r = zero;
+            }
+        }
+        return true;
+    }
+
+    static inline void robustness_verify_collinear(
+                segment_type1 const& a, segment_type2 const& b,
+                side_info& sides,
+                bool& collinear)
+    {
+		if ((sides.zero<0>() && ! sides.zero<1>()) || (sides.zero<1>() && ! sides.zero<0>()))
+		{
+			// If one of the segments is collinear, the other must be as well.
+			// So handle it as collinear.
+			// (In float/double epsilon margins it can easily occur that one or two of them are -1/1)
+			// sides.debug();
+            sides.set<0>(0,0);
+            sides.set<1>(0,0);
+            collinear = true;
+		}
+    }
+
+    static inline void robustness_verify_meeting(
+                segment_type1 const& a, segment_type2 const& b,
+                side_info& sides,
+                bool& collinear, bool& collinear_use_first)
+    {
+        if (sides.meeting())
+        {
+            // If two segments meet each other at their segment-points, two sides are zero,
+            // the other two are not (unless collinear but we don't mean those here).
+            // However, in near-epsilon ranges it can happen that two sides are zero
+            // but they do not meet at their segment-points.
+            // In that case they are nearly collinear and handled as such.
+            if (! point_equals
+                    (
+                        select(sides.zero_index<0>(), a),
+                        select(sides.zero_index<1>(), b)
+                    )
+                )
+            {
+                sides.set<0>(0,0);
+                sides.set<1>(0,0);
+                collinear = true;
+
+                if (collinear_use_first && analyse_equal<0>(a, b))
+                {
+                    collinear_use_first = false;
+                }
+                else if (! collinear_use_first && analyse_equal<1>(a, b))
+                {
+                    collinear_use_first = true;
+                }
+
+            }
+        }
+    }
+
+    // Verifies and if necessary correct missed touch because of robustness
+    // This is the case at multi_polygon_buffer unittest #rt_m
+    static inline bool robustness_verify_same_side(
+                segment_type1 const& a, segment_type2 const& b,
+                side_info& sides)
+    {
+        int corrected = 0;
+        if (sides.one_touching<0>())
+        {
+            if (point_equals(
+                        select(sides.zero_index<0>(), a),
+                        select(0, b)
+                    ))
+            {
+                sides.correct_to_zero<1, 0>();
+                corrected = 1;
+            }
+            if (point_equals
+                    (
+                        select(sides.zero_index<0>(), a),
+                        select(1, b)
+                    ))
+            {
+                sides.correct_to_zero<1, 1>();
+                corrected = 2;
+            }
+        }
+        else if (sides.one_touching<1>())
+        {
+            if (point_equals(
+                        select(sides.zero_index<1>(), b),
+                        select(0, a)
+                    ))
+            {
+                sides.correct_to_zero<0, 0>();
+                corrected = 3;
+            }
+            if (point_equals
+                    (
+                        select(sides.zero_index<1>(), b),
+                        select(1, a)
+                    ))
+            {
+                sides.correct_to_zero<0, 1>();
+                corrected = 4;
+            }
+        }
+
+        return corrected == 0;
+    }
+
+    static inline bool robustness_verify_disjoint_at_one_collinear(
+                segment_type1 const& a, segment_type2 const& b,
+                side_info const& sides)
+    {
+        if (sides.one_of_all_zero())
+        {
+			if (verify_disjoint<0>(a, b) || verify_disjoint<1>(a, b))
+			{
+    			return true;
+            }
+		}
+        return false;
+    }
+
+
+    // If r is one, or zero, segments should meet and their endpoints.
+    // Robustness issue: check if this is really the case.
+    // It turns out to be no problem, see buffer test #rt_s1 (and there are many cases generated)
+    // It generates an "ends in the middle" situation which is correct.
+    template <typename T, typename R>
+    static inline void robustness_handle_meeting(segment_type1 const& a, segment_type2 const& b,
+                side_info& sides,
+                T const& dx_a, T const& dy_a, T const& wx, T const& wy,
+                T const& d, R const& r)
+    {
+        return;
+
+        T const db = geometry::detail::determinant<T>(dx_a, dy_a, wx, wy);
+
+		R const zero = 0;
+		R const one = 1;
+        if (math::equals(r, zero) || math::equals(r, one))
+        {
+        	R rb = db / d;
+            if (rb <= 0 || rb >= 1 || math::equals(rb, 0) || math::equals(rb, 1))
+            {
+                if (sides.one_zero<0>() && ! sides.one_zero<1>()) // or vice versa
+                {
+#if defined(BOOST_GEOMETRY_COUNT_INTERSECTION_EQUAL)
+                    extern int g_count_intersection_equal;
+                    g_count_intersection_equal++;
+#endif
+                    sides.debug();
+                    std::cout << "E r=" << r << " r.b=" << rb << " ";
+                }
+            }
+        }
+    }
+
+	template <std::size_t Dimension>
+    static inline bool verify_disjoint(segment_type1 const& a,
+					segment_type2 const& b)
+	{
+		coordinate_type a_1, a_2, b_1, b_2;
+		bool a_swapped = false, b_swapped = false;
+		detail::segment_arrange<Dimension>(a, a_1, a_2, a_swapped);
+		detail::segment_arrange<Dimension>(b, b_1, b_2, b_swapped);
+		return math::smaller(a_2, b_1) || math::larger(a_1, b_2);
+	}
+
+    template <typename Segment>
+    static inline typename point_type<Segment>::type select(int index, Segment const& segment)
+    {
+        return index == 0 
+            ? detail::get_from_index<0>(segment)
+            : detail::get_from_index<1>(segment)
+            ;
+    }
+
+    // We cannot use geometry::equals here. Besides that this will be changed
+    // to compare segment-coordinate-values directly (not necessary to retrieve point first)
+    template <typename Point1, typename Point2>
+    static inline bool point_equals(Point1 const& point1, Point2 const& point2)
+    {
+        return math::equals(get<0>(point1), get<0>(point2))
+            && math::equals(get<1>(point1), get<1>(point2))
+            ;
+    }
+
+    // We cannot use geometry::equals here. Besides that this will be changed
+    // to compare segment-coordinate-values directly (not necessary to retrieve point first)
+    template <typename Point1, typename Point2>
+    static inline bool point_equality(Point1 const& point1, Point2 const& point2,
+                    bool& equals_0, bool& equals_1)
+    {
+        equals_0 = math::equals(get<0>(point1), get<0>(point2));
+        equals_1 = math::equals(get<1>(point1), get<1>(point2));
+        return equals_0 && equals_1;
+    }
+
+    template <std::size_t Dimension>
+    static inline bool analyse_equal(segment_type1 const& a, segment_type2 const& b)
+    {
+		coordinate_type const a_1 = geometry::get<0, Dimension>(a);
+		coordinate_type const a_2 = geometry::get<1, Dimension>(a);
+		coordinate_type const b_1 = geometry::get<0, Dimension>(b);
+		coordinate_type const b_2 = geometry::get<1, Dimension>(b);
+        return math::equals(a_1, b_1)
+            || math::equals(a_2, b_1)
+            || math::equals(a_1, b_2)
+            || math::equals(a_2, b_2)
+            ;
+    }
+
+	template <std::size_t Dimension>
+    static inline return_type relate_collinear(segment_type1 const& a,
+											   segment_type2 const& b)
+	{
+		coordinate_type a_1, a_2, b_1, b_2;
+		bool a_swapped = false, b_swapped = false;
+		detail::segment_arrange<Dimension>(a, a_1, a_2, a_swapped);
+		detail::segment_arrange<Dimension>(b, b_1, b_2, b_swapped);
+		if (math::smaller(a_2, b_1) || math::larger(a_1, b_2))
+		//if (a_2 < b_1 || a_1 > b_2)
+		{
+			return Policy::disjoint();
+		}
+        return relate_collinear(a, b, a_1, a_2, b_1, b_2, a_swapped, b_swapped);
+	}
+
+    /// Relate segments known collinear
+    static inline return_type relate_collinear(segment_type1 const& a
+            , segment_type2 const& b
+            , coordinate_type a_1, coordinate_type a_2
+            , coordinate_type b_1, coordinate_type b_2
+            , bool a_swapped, bool b_swapped)
+    {
+        // All ca. 150 lines are about collinear rays
+        // The intersections, if any, are always boundary points of the segments. No need to calculate anything.
+        // However we want to find out HOW they intersect, there are many cases.
+        // Most sources only provide the intersection (above) or that there is a collinearity (but not the points)
+        // or some spare sources give the intersection points (calculated) but not how they align.
+        // This source tries to give everything and still be efficient.
+        // It is therefore (and because of the extensive clarification comments) rather long...
+
+        // \see http://mpa.itc.it/radim/g50history/CMP/4.2.1-CERL-beta-libes/file475.txt
+        // \see http://docs.codehaus.org/display/GEOTDOC/Point+Set+Theory+and+the+DE-9IM+Matrix
+        // \see http://mathworld.wolfram.com/Line-LineIntersection.html
+
+        // Because of collinearity the case is now one-dimensional and can be checked using intervals
+        // This function is called either horizontally or vertically
+        // We get then two intervals:
+        // a_1-------------a_2 where a_1 < a_2
+        // b_1-------------b_2 where b_1 < b_2
+        // In all figures below a_1/a_2 denotes arranged intervals, a1-a2 or a2-a1 are still unarranged
+
+        // Handle "equal", in polygon neighbourhood comparisons a common case
+
+        bool const opposite = a_swapped ^ b_swapped;
+        bool const both_swapped = a_swapped && b_swapped;
+
+        // Check if segments are equal or opposite equal...
+		bool const swapped_a1_eq_b1 = math::equals(a_1, b_1);
+		bool const swapped_a2_eq_b2 = math::equals(a_2, b_2);
+
+        if (swapped_a1_eq_b1 && swapped_a2_eq_b2)
+        {
+            return Policy::segment_equal(a, opposite);
+        }
+
+		bool const swapped_a2_eq_b1 = math::equals(a_2, b_1);
+		bool const swapped_a1_eq_b2 = math::equals(a_1, b_2);
+
+		bool const a1_eq_b1 = both_swapped ? swapped_a2_eq_b2 : a_swapped ? swapped_a2_eq_b1 : b_swapped ? swapped_a1_eq_b2 : swapped_a1_eq_b1;
+		bool const a2_eq_b2 = both_swapped ? swapped_a1_eq_b1 : a_swapped ? swapped_a1_eq_b2 : b_swapped ? swapped_a2_eq_b1 : swapped_a2_eq_b2;
+
+		bool const a1_eq_b2 = both_swapped ? swapped_a2_eq_b1 : a_swapped ? swapped_a2_eq_b2 : b_swapped ? swapped_a1_eq_b1 : swapped_a1_eq_b2;
+		bool const a2_eq_b1 = both_swapped ? swapped_a1_eq_b2 : a_swapped ? swapped_a1_eq_b1 : b_swapped ? swapped_a2_eq_b2 : swapped_a2_eq_b1;
+
+
+
+
+        // The rest below will return one or two intersections.
+        // The delegated class can decide which is the intersection point, or two, build the Intersection Matrix (IM)
+        // For IM it is important to know which relates to which. So this information is given,
+        // without performance penalties to intersection calculation
+
+        bool const has_common_points = swapped_a1_eq_b1 || swapped_a1_eq_b2 || swapped_a2_eq_b1 || swapped_a2_eq_b2;
+
+
+        // "Touch" -> one intersection point -> one but not two common points
+        // -------->             A (or B)
+        //         <----------   B (or A)
+        //        a_2==b_1         (b_2==a_1 or a_2==b1)
+
+        // The check a_2/b_1 is necessary because it excludes cases like
+        // ------->
+        //     --->
+        // ... which are handled lateron
+
+        // Corresponds to 4 cases, of which the equal points are determined above
+        // #1: a1---->a2 b1--->b2   (a arrives at b's border)
+        // #2: a2<----a1 b2<---b1   (b arrives at a's border)
+        // #3: a1---->a2 b2<---b1   (both arrive at each others border)
+        // #4: a2<----a1 b1--->b2   (no arrival at all)
+        // Where the arranged forms have two forms:
+        //    a_1-----a_2/b_1-------b_2 or reverse (B left of A)
+        if ((swapped_a2_eq_b1 || swapped_a1_eq_b2) && ! swapped_a1_eq_b1 && ! swapped_a2_eq_b2)
+        {
+            if (a2_eq_b1) return Policy::collinear_touch(get<1, 0>(a), get<1, 1>(a), 0, -1);
+            if (a1_eq_b2) return Policy::collinear_touch(get<0, 0>(a), get<0, 1>(a), -1, 0);
+            if (a2_eq_b2) return Policy::collinear_touch(get<1, 0>(a), get<1, 1>(a), 0, 0);
+            if (a1_eq_b1) return Policy::collinear_touch(get<0, 0>(a), get<0, 1>(a), -1, -1);
+        }
+
+
+        // "Touch/within" -> there are common points and also an intersection of interiors:
+        // Corresponds to many cases:
+        // #1a: a1------->a2  #1b:        a1-->a2
+        //          b1--->b2         b1------->b2
+        // #2a: a2<-------a1  #2b:        a2<--a1
+        //          b1--->b2         b1------->b2
+        // #3a: a1------->a2  #3b:        a1-->a2
+        //          b2<---b1         b2<-------b1
+        // #4a: a2<-------a1  #4b:        a2<--a1
+        //          b2<---b1         b2<-------b1
+
+        // Note: next cases are similar and handled by the code
+        // #4c: a1--->a2
+        //      b1-------->b2
+        // #4d: a1-------->a2
+        //      b1-->b2
+
+        // For case 1-4: a_1 < (b_1 or b_2) < a_2, two intersections are equal to segment B
+        // For case 5-8: b_1 < (a_1 or a_2) < b_2, two intersections are equal to segment A
+        if (has_common_points)
+        {
+            // Either A is in B, or B is in A, or (in case of robustness/equals)
+            // both are true, see below
+            bool a_in_b = (b_1 < a_1 && a_1 < b_2) || (b_1 < a_2 && a_2 < b_2);
+            bool b_in_a = (a_1 < b_1 && b_1 < a_2) || (a_1 < b_2 && b_2 < a_2);
+
+            if (a_in_b && b_in_a)
+            {
+                // testcase "ggl_list_20110306_javier"
+                // In robustness it can occur that a point of A is inside B AND a point of B is inside A,
+                // still while has_common_points is true (so one point equals the other).
+                // If that is the case we select on length.
+                coordinate_type const length_a = geometry::math::abs(a_1 - a_2);
+                coordinate_type const length_b = geometry::math::abs(b_1 - b_2);
+                if (length_a > length_b)
+                {
+                    a_in_b = false;
+                }
+                else
+                {
+                    b_in_a = false;
+                }
+            }
+
+            int const arrival_a = a_in_b ? 1 : -1;
+            if (a2_eq_b2) return Policy::collinear_interior_boundary_intersect(a_in_b ? a : b, a_in_b, 0, 0, false);
+            if (a1_eq_b2) return Policy::collinear_interior_boundary_intersect(a_in_b ? a : b, a_in_b, arrival_a, 0, true);
+            if (a2_eq_b1) return Policy::collinear_interior_boundary_intersect(a_in_b ? a : b, a_in_b, 0, -arrival_a, true);
+            if (a1_eq_b1) return Policy::collinear_interior_boundary_intersect(a_in_b ? a : b, a_in_b, arrival_a, -arrival_a, false);
+        }
+
+
+
+        // "Inside", a completely within b or b completely within a
+        // 2 cases:
+        // case 1:
+        //        a_1---a_2        -> take A's points as intersection points
+        //   b_1------------b_2
+        // case 2:
+        //   a_1------------a_2
+        //       b_1---b_2         -> take B's points
+        if (a_1 > b_1 && a_2 < b_2)
+        {
+            // A within B
+            return Policy::collinear_a_in_b(a, opposite);
+        }
+        if (b_1 > a_1 && b_2 < a_2)
+        {
+            // B within A
+            return Policy::collinear_b_in_a(b, opposite);
+        }
+
+
+        /*
+
+        Now that all cases with equal,touch,inside,disjoint,
+        degenerate are handled the only thing left is an overlap
+
+        Either a1 is between b1,b2
+        or a2 is between b1,b2 (a2 arrives)
+
+        Next table gives an overview.
+        The IP's are ordered following the line A1->A2
+
+             |                                 |
+             |          a_2 in between         |       a_1 in between
+             |                                 |
+        -----+---------------------------------+--------------------------
+             |   a1--------->a2                |       a1--------->a2
+             |          b1----->b2             |   b1----->b2
+             |   (b1,a2), a arrives            |   (a1,b2), b arrives
+             |                                 |
+        -----+---------------------------------+--------------------------
+        a sw.|   a2<---------a1*               |       a2<---------a1*
+             |           b1----->b2            |   b1----->b2
+             |   (a1,b1), no arrival           |   (b2,a2), a and b arrive
+             |                                 |
+        -----+---------------------------------+--------------------------
+             |   a1--------->a2                |       a1--------->a2
+        b sw.|           b2<-----b1            |   b2<-----b1
+             |   (b2,a2), a and b arrive       |   (a1,b1), no arrival
+             |                                 |
+        -----+---------------------------------+--------------------------
+        a sw.|    a2<---------a1*              |       a2<---------a1*
+        b sw.|            b2<-----b1           |   b2<-----b1
+             |   (a1,b2), b arrives            |   (b1,a2), a arrives
+             |                                 |
+        -----+---------------------------------+--------------------------
+        * Note that a_1 < a_2, and a1 <> a_1; if a is swapped,
+          the picture might seem wrong but it (supposed to be) is right.
+        */
+
+        if (b_1 < a_2 && a_2 < b_2)
+        {
+            // Left column, from bottom to top
+            return
+                both_swapped ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<1, 0>(b), get<1, 1>(b), -1,  1, opposite)
+                : b_swapped  ? Policy::collinear_overlaps(get<1, 0>(b), get<1, 1>(b), get<1, 0>(a), get<1, 1>(a),  1,  1, opposite)
+                : a_swapped  ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<0, 0>(b), get<0, 1>(b), -1, -1, opposite)
+                :              Policy::collinear_overlaps(get<0, 0>(b), get<0, 1>(b), get<1, 0>(a), get<1, 1>(a),  1, -1, opposite)
+                ;
+        }
+        if (b_1 < a_1 && a_1 < b_2)
+        {
+            // Right column, from bottom to top
+            return
+                both_swapped ? Policy::collinear_overlaps(get<0, 0>(b), get<0, 1>(b), get<1, 0>(a), get<1, 1>(a),  1, -1, opposite)
+                : b_swapped  ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<0, 0>(b), get<0, 1>(b), -1, -1, opposite)
+                : a_swapped  ? Policy::collinear_overlaps(get<1, 0>(b), get<1, 1>(b), get<1, 0>(a), get<1, 1>(a),  1,  1, opposite)
+                :              Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<1, 0>(b), get<1, 1>(b), -1,  1, opposite)
+                ;
+        }
+        // Nothing should goes through. If any we have made an error
+		// std::cout << "Robustness issue, non-logical behaviour" << std::endl;
+        return Policy::error("Robustness issue, non-logical behaviour");
+    }
+};
+
+
+}} // namespace strategy::intersection
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_INTERSECTION_HPP
diff --git a/src/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp b/src/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp
new file mode 100644
index 0000000..8b42715
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp
@@ -0,0 +1,242 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_BASHEIN_DETMER_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_BASHEIN_DETMER_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/arithmetic/determinant.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/strategies/centroid.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+// Note: when calling the namespace "centroid", it sometimes,
+// somehow, in gcc, gives compilation problems (confusion with function centroid).
+
+namespace strategy { namespace centroid
+{
+
+
+
+/*!
+\brief Centroid calculation using algorith Bashein / Detmer
+\ingroup strategies
+\details Calculates centroid using triangulation method published by
+    Bashein / Detmer
+\tparam Point point type of centroid to calculate
+\tparam PointOfSegment point type of segments, defaults to Point
+\par Concepts for Point and PointOfSegment:
+- specialized point_traits class
+\author Adapted from  "Centroid of a Polygon" by
+    Gerard Bashein and Paul R. Detmer<em>,
+in "Graphics Gems IV", Academic Press, 1994</em>
+\par Research notes
+The algorithm gives the same results as Oracle and PostGIS but
+    differs from MySQL
+(tried 5.0.21 / 5.0.45 / 5.0.51a / 5.1.23).
+
+Without holes:
+- this:       POINT(4.06923363095238 1.65055803571429)
+- geolib:     POINT(4.07254 1.66819)
+- MySQL:      POINT(3.6636363636364  1.6272727272727)'
+- PostGIS:    POINT(4.06923363095238 1.65055803571429)
+- Oracle:           4.06923363095238 1.65055803571429
+- SQL Server: POINT(4.06923362245959 1.65055804168294)
+
+Statements:
+- \b MySQL/PostGIS: select AsText(Centroid(GeomFromText(
+    'POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6
+        ,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))')))
+- \b Oracle: select sdo_geom.sdo_centroid(sdo_geometry(2003, null, null,
+        sdo_elem_info_array(1, 1003, 1), sdo_ordinate_array(
+            2,1.3,2.4,1.7,2.8,1.8,3.4,1.2,3.7,1.6,3.4,2,4.1,3,5.3,2.6
+            ,5.4,1.2,4.9,0.8,2.9,0.7,2,1.3))
+        , mdsys.sdo_dim_array(mdsys.sdo_dim_element('x',0,10,.00000005)
+        ,mdsys.sdo_dim_element('y',0,10,.00000005)))
+        from dual
+- \b SQL Server 2008: select geometry::STGeomFromText(
+    'POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6
+        ,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))',0)
+                .STCentroid()
+                .STAsText()
+
+With holes:
+- this:       POINT(4.04663 1.6349)
+- geolib:     POINT(4.04675 1.65735)
+- MySQL:      POINT(3.6090580503834 1.607573932092)
+- PostGIS:    POINT(4.0466265060241 1.63489959839357)
+- Oracle:           4.0466265060241 1.63489959839357
+- SQL Server: POINT(4.0466264962959677 1.6348996057331333)
+
+Statements:
+- \b MySQL/PostGIS: select AsText(Centroid(GeomFromText(
+    'POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2
+        ,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)
+        ,(4 2,4.2 1.4,4.8 1.9,4.4 2.2,4 2))')));
+- \b Oracle: select sdo_geom.sdo_centroid(sdo_geometry(2003, null, null
+        , sdo_elem_info_array(1, 1003, 1, 25, 2003, 1)
+        , sdo_ordinate_array(2,1.3,2.4,1.7,2.8,1.8,3.4,1.2,3.7,1.6,3.4,
+        2,4.1,3,5.3,2.6,5.4,1.2,4.9,0.8,2.9,0.7,2,1.3,4,2, 4.2,1.4,
+        4.8,1.9, 4.4,2.2, 4,2))
+        , mdsys.sdo_dim_array(mdsys.sdo_dim_element('x',0,10,.00000005)
+        ,mdsys.sdo_dim_element('y',0,10,.00000005)))
+        from dual
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.centroid.centroid_3_with_strategy centroid (with strategy)]
+}
+
+ */
+template
+<
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void
+>
+class bashein_detmer
+{
+private :
+    // If user specified a calculation type, use that type,
+    //   whatever it is and whatever the point-type(s) are.
+    // Else, use the most appropriate coordinate type
+    //    of the two points, but at least double
+    typedef typename
+        boost::mpl::if_c
+        <
+            boost::is_void<CalculationType>::type::value,
+            typename select_most_precise
+            <
+                typename select_coordinate_type
+                    <
+                        Point,
+                        PointOfSegment
+                    >::type,
+                double
+            >::type,
+            CalculationType
+        >::type calculation_type;
+
+    /*! subclass to keep state */
+    class sums
+    {
+        friend class bashein_detmer;
+        int count;
+        calculation_type sum_a2;
+        calculation_type sum_x;
+        calculation_type sum_y;
+
+    public :
+        inline sums()
+            : count(0)
+            , sum_a2(calculation_type())
+            , sum_x(calculation_type())
+            , sum_y(calculation_type())
+        {
+            typedef calculation_type ct;
+        }
+    };
+
+public :
+    typedef sums state_type;
+
+    static inline void apply(PointOfSegment const& p1,
+            PointOfSegment const& p2, sums& state)
+    {
+        /* Algorithm:
+        For each segment:
+        begin
+            ai = x1 * y2 - x2 * y1;
+            sum_a2 += ai;
+            sum_x += ai * (x1 + x2);
+            sum_y += ai * (y1 + y2);
+        end
+        return POINT(sum_x / (3 * sum_a2), sum_y / (3 * sum_a2) )
+        */
+
+        // Get coordinates and promote them to calculation_type
+        calculation_type const x1 = boost::numeric_cast<calculation_type>(get<0>(p1));
+        calculation_type const y1 = boost::numeric_cast<calculation_type>(get<1>(p1));
+        calculation_type const x2 = boost::numeric_cast<calculation_type>(get<0>(p2));
+        calculation_type const y2 = boost::numeric_cast<calculation_type>(get<1>(p2));
+        calculation_type const ai = geometry::detail::determinant<calculation_type>(p1, p2);
+        state.count++;
+        state.sum_a2 += ai;
+        state.sum_x += ai * (x1 + x2);
+        state.sum_y += ai * (y1 + y2);
+    }
+
+    static inline bool result(sums const& state, Point& centroid)
+    {
+        calculation_type const zero = calculation_type();
+        if (state.count > 0 && ! math::equals(state.sum_a2, zero))
+        {
+            calculation_type const v3 = 3;
+            calculation_type const a3 = v3 * state.sum_a2;
+
+            typedef typename geometry::coordinate_type
+                <
+                    Point
+                >::type coordinate_type;
+
+            set<0>(centroid,
+                boost::numeric_cast<coordinate_type>(state.sum_x / a3));
+            set<1>(centroid,
+                boost::numeric_cast<coordinate_type>(state.sum_y / a3));
+            return true;
+        }
+
+        return false;
+    }
+
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+
+// Register this strategy for rings and (multi)polygons, in two dimensions
+template <typename Point, typename Geometry>
+struct default_strategy<cartesian_tag, areal_tag, 2, Point, Geometry>
+{
+    typedef bashein_detmer
+        <
+            Point,
+            typename point_type<Geometry>::type
+        > type;
+};
+
+
+} // namespace services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::centroid
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_BASHEIN_DETMER_HPP
diff --git a/src/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp b/src/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp
new file mode 100644
index 0000000..48feae5
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp
@@ -0,0 +1,144 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_WEIGHTED_LENGTH_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_WEIGHTED_LENGTH_HPP
+
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+#include <boost/geometry/strategies/centroid.hpp>
+#include <boost/geometry/strategies/default_distance_result.hpp>
+
+// Helper geometry
+#include <boost/geometry/geometries/point.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace centroid
+{
+
+namespace detail
+{
+
+template <typename Type, std::size_t DimensionCount>
+struct weighted_length_sums
+{
+    typedef typename geometry::model::point
+        <
+            Type, DimensionCount,
+            cs::cartesian
+        > work_point;
+
+    Type length;
+    work_point average_sum;
+
+    inline weighted_length_sums()
+        : length(Type())
+    {
+        geometry::assign_zero(average_sum);
+    }
+};
+}
+
+template
+<
+    typename Point,
+    typename PointOfSegment = Point
+>
+class weighted_length
+{
+private :
+    typedef typename select_most_precise
+        <
+            typename default_distance_result<Point>::type,
+            typename default_distance_result<PointOfSegment>::type
+        >::type distance_type;
+
+public :
+    typedef detail::weighted_length_sums
+        <
+            distance_type,
+            geometry::dimension<Point>::type::value
+        > state_type;
+
+    static inline void apply(PointOfSegment const& p1,
+            PointOfSegment const& p2, state_type& state)
+    {
+        distance_type const d = geometry::distance(p1, p2);
+        state.length += d;
+
+        typename state_type::work_point weighted_median;
+        geometry::assign_zero(weighted_median);
+        geometry::add_point(weighted_median, p1);
+        geometry::add_point(weighted_median, p2);
+        geometry::multiply_value(weighted_median, d/2);
+        geometry::add_point(state.average_sum, weighted_median);
+    }
+
+    static inline bool result(state_type const& state, Point& centroid)
+    {
+        distance_type const zero = distance_type();
+        if (! geometry::math::equals(state.length, zero))
+        {
+            assign_zero(centroid);
+            add_point(centroid, state.average_sum);
+            divide_value(centroid, state.length);
+            return true;
+        }
+
+        return false;
+    }
+
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+
+
+// Register this strategy for linear geometries, in all dimensions
+
+template <std::size_t N, typename Point, typename Geometry>
+struct default_strategy
+<
+    cartesian_tag,
+    linear_tag,
+    N,
+    Point,
+    Geometry
+>
+{
+    typedef weighted_length
+        <
+            Point,
+            typename point_type<Geometry>::type
+        > type;
+};
+
+
+} // namespace services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::centroid
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_WEIGHTED_LENGTH_HPP
diff --git a/src/boost/geometry/strategies/cartesian/distance_projected_point.hpp b/src/boost/geometry/strategies/cartesian/distance_projected_point.hpp
new file mode 100644
index 0000000..13d4168
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/distance_projected_point.hpp
@@ -0,0 +1,319 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/point_type.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/arithmetic/dot_product.hpp>
+
+#include <boost/geometry/strategies/tags.hpp>
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/strategies/default_distance_result.hpp>
+#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+// Helper geometry (projected point on line)
+#include <boost/geometry/geometries/point.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace distance
+{
+
+
+/*!
+\brief Strategy for distance point to segment
+\ingroup strategies
+\details Calculates distance using projected-point method, and (optionally) Pythagoras
+\author Adapted from: http://geometryalgorithms.com/Archive/algorithm_0102/algorithm_0102.htm
+\tparam Point \tparam_point
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+\tparam Strategy underlying point-point distance strategy
+\par Concepts for Strategy:
+- cartesian_distance operator(Point,Point)
+\note If the Strategy is a "comparable::pythagoras", this strategy
+    automatically is a comparable projected_point strategy (so without sqrt)
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
+}
+
+*/
+template
+<
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void,
+    typename Strategy = pythagoras<Point, PointOfSegment, CalculationType>
+>
+class projected_point
+{
+public :
+    // The three typedefs below are necessary to calculate distances
+    // from segments defined in integer coordinates.
+
+    // Integer coordinates can still result in FP distances.
+    // There is a division, which must be represented in FP.
+    // So promote.
+    typedef typename promote_floating_point
+        <
+            typename strategy::distance::services::return_type
+                <
+                    Strategy
+                >::type
+        >::type calculation_type;
+
+private :
+
+    // A projected point of points in Integer coordinates must be able to be
+    // represented in FP.
+    typedef model::point
+        <
+            calculation_type,
+            dimension<PointOfSegment>::value,
+            typename coordinate_system<PointOfSegment>::type
+        > fp_point_type;
+
+    // For convenience
+    typedef fp_point_type fp_vector_type;
+
+    // We have to use a strategy using FP coordinates (fp-type) which is
+    // not always the same as Strategy (defined as point_strategy_type)
+    // So we create a "similar" one
+    typedef typename strategy::distance::services::similar_type
+        <
+            Strategy,
+            Point,
+            fp_point_type
+        >::type fp_strategy_type;
+
+public :
+
+    inline calculation_type apply(Point const& p,
+                    PointOfSegment const& p1, PointOfSegment const& p2) const
+    {
+        assert_dimension_equal<Point, PointOfSegment>();
+
+        /* 
+            Algorithm [p1: (x1,y1), p2: (x2,y2), p: (px,py)]
+            VECTOR v(x2 - x1, y2 - y1)
+            VECTOR w(px - x1, py - y1)
+            c1 = w . v
+            c2 = v . v
+            b = c1 / c2
+            RETURN POINT(x1 + b * vx, y1 + b * vy)
+        */
+
+        // v is multiplied below with a (possibly) FP-value, so should be in FP
+        // For consistency we define w also in FP
+        fp_vector_type v, w;
+
+        geometry::convert(p2, v);
+        geometry::convert(p, w);
+        subtract_point(v, p1);
+        subtract_point(w, p1);
+
+        Strategy strategy;
+        boost::ignore_unused_variable_warning(strategy);
+
+        calculation_type const zero = calculation_type();
+        calculation_type const c1 = dot_product(w, v);
+        if (c1 <= zero)
+        {
+            return strategy.apply(p, p1);
+        }
+        calculation_type const c2 = dot_product(v, v);
+        if (c2 <= c1)
+        {
+            return strategy.apply(p, p2);
+        }
+
+        // See above, c1 > 0 AND c2 > c1 so: c2 != 0
+        calculation_type const b = c1 / c2;
+
+        fp_strategy_type fp_strategy
+            = strategy::distance::services::get_similar
+                <
+                    Strategy, Point, fp_point_type
+                >::apply(strategy);
+
+        fp_point_type projected;
+        geometry::convert(p1, projected);
+        multiply_value(v, b);
+        add_point(projected, v);
+
+        //std::cout << "distance " << dsv(p) << " .. " << dsv(projected) << std::endl;
+
+        return fp_strategy.apply(p, projected);
+    }
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct tag<projected_point<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef strategy_tag_distance_point_segment type;
+};
+
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct return_type<projected_point<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef typename projected_point<Point, PointOfSegment, CalculationType, Strategy>::calculation_type type;
+};
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct strategy_point_point<projected_point<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef Strategy type;
+};
+
+
+template
+<
+    typename Point,
+    typename PointOfSegment,
+    typename CalculationType,
+    typename Strategy,
+    typename P1,
+    typename P2
+>
+struct similar_type<projected_point<Point, PointOfSegment, CalculationType, Strategy>, P1, P2>
+{
+    typedef projected_point<P1, P2, CalculationType, Strategy> type;
+};
+
+
+template
+<
+    typename Point,
+    typename PointOfSegment,
+    typename CalculationType,
+    typename Strategy,
+    typename P1,
+    typename P2
+>
+struct get_similar<projected_point<Point, PointOfSegment, CalculationType, Strategy>, P1, P2>
+{
+    static inline typename similar_type
+        <
+            projected_point<Point, PointOfSegment, CalculationType, Strategy>, P1, P2
+        >::type apply(projected_point<Point, PointOfSegment, CalculationType, Strategy> const& )
+    {
+        return projected_point<P1, P2, CalculationType, Strategy>();
+    }
+};
+
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct comparable_type<projected_point<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    // Define a projected_point strategy with its underlying point-point-strategy
+    // being comparable
+    typedef projected_point
+        <
+            Point,
+            PointOfSegment,
+            CalculationType,
+            typename comparable_type<Strategy>::type
+        > type;
+};
+
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct get_comparable<projected_point<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef typename comparable_type
+        <
+            projected_point<Point, PointOfSegment, CalculationType, Strategy>
+        >::type comparable_type;
+public :
+    static inline comparable_type apply(projected_point<Point, PointOfSegment, CalculationType, Strategy> const& )
+    {
+        return comparable_type();
+    }
+};
+
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct result_from_distance<projected_point<Point, PointOfSegment, CalculationType, Strategy> >
+{
+private :
+    typedef typename return_type<projected_point<Point, PointOfSegment, CalculationType, Strategy> >::type return_type;
+public :
+    template <typename T>
+    static inline return_type apply(projected_point<Point, PointOfSegment, CalculationType, Strategy> const& , T const& value)
+    {
+        Strategy s;
+        return result_from_distance<Strategy>::apply(s, value);
+    }
+};
+
+
+// Get default-strategy for point-segment distance calculation
+// while still have the possibility to specify point-point distance strategy (PPS)
+// It is used in algorithms/distance.hpp where users specify PPS for distance
+// of point-to-segment or point-to-linestring.
+// Convenient for geographic coordinate systems especially.
+template <typename Point, typename PointOfSegment, typename Strategy>
+struct default_strategy<segment_tag, Point, PointOfSegment, cartesian_tag, cartesian_tag, Strategy>
+{
+    typedef strategy::distance::projected_point
+    <
+        Point,
+        PointOfSegment,
+        void,
+        typename boost::mpl::if_
+            <
+                boost::is_void<Strategy>,
+                typename default_strategy
+                    <
+                        point_tag, Point, PointOfSegment,
+                        cartesian_tag, cartesian_tag
+                    >::type,
+                Strategy
+            >::type
+    > type;
+};
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PROJECTED_POINT_HPP
diff --git a/src/boost/geometry/strategies/cartesian/distance_pythagoras.hpp b/src/boost/geometry/strategies/cartesian/distance_pythagoras.hpp
new file mode 100644
index 0000000..51d2722
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/distance_pythagoras.hpp
@@ -0,0 +1,349 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/access.hpp>
+
+#include <boost/geometry/strategies/distance.hpp>
+
+#include <boost/geometry/util/calculation_type.hpp>
+
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace distance
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Point1, typename Point2, size_t I, typename T>
+struct compute_pythagoras
+{
+    static inline T apply(Point1 const& p1, Point2 const& p2)
+    {
+        T const c1 = boost::numeric_cast<T>(get<I-1>(p2));
+        T const c2 = boost::numeric_cast<T>(get<I-1>(p1));
+        T const d = c1 - c2;
+        return d * d + compute_pythagoras<Point1, Point2, I-1, T>::apply(p1, p2);
+    }
+};
+
+template <typename Point1, typename Point2, typename T>
+struct compute_pythagoras<Point1, Point2, 0, T>
+{
+    static inline T apply(Point1 const&, Point2 const&)
+    {
+        return boost::numeric_cast<T>(0);
+    }
+};
+
+}
+#endif // DOXYGEN_NO_DETAIL
+
+
+namespace comparable
+{
+
+/*!
+\brief Strategy to calculate comparable distance between two points
+\ingroup strategies
+\tparam Point1 \tparam_first_point
+\tparam Point2 \tparam_second_point
+\tparam CalculationType \tparam_calculation
+*/
+template
+<
+    typename Point1,
+    typename Point2 = Point1,
+    typename CalculationType = void
+>
+class pythagoras
+{
+public :
+
+    typedef typename util::calculation_type::geometric::binary
+            <
+                Point1,
+                Point2,
+                CalculationType
+            >::type calculation_type;
+
+    static inline calculation_type apply(Point1 const& p1, Point2 const& p2)
+    {
+        BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point1>) );
+        BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point2>) );
+
+        // Calculate distance using Pythagoras
+        // (Leave comment above for Doxygen)
+
+        assert_dimension_equal<Point1, Point2>();
+
+        return detail::compute_pythagoras
+            <
+                Point1, Point2,
+                dimension<Point1>::value,
+                calculation_type
+            >::apply(p1, p2);
+    }
+};
+
+} // namespace comparable
+
+
+/*!
+\brief Strategy to calculate the distance between two points
+\ingroup strategies
+\tparam Point1 \tparam_first_point
+\tparam Point2 \tparam_second_point
+\tparam CalculationType \tparam_calculation
+
+\qbk{
+[heading Notes]
+[note Can be used for points with two\, three or more dimensions]
+[heading See also]
+[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
+}
+
+*/
+template
+<
+    typename Point1,
+    typename Point2 = Point1,
+    typename CalculationType = void
+>
+class pythagoras
+{
+    typedef comparable::pythagoras<Point1, Point2, CalculationType> comparable_type;
+public :
+    typedef typename util::calculation_type::geometric::binary
+            <
+                Point1,
+                Point2,
+                CalculationType,
+                double,
+                double // promote integer to double
+            >::type calculation_type;
+
+    /*!
+    \brief applies the distance calculation using pythagoras
+    \return the calculated distance (including taking the square root)
+    \param p1 first point
+    \param p2 second point
+    */
+    static inline calculation_type apply(Point1 const& p1, Point2 const& p2)
+    {
+        calculation_type const t = comparable_type::apply(p1, p2);
+        return sqrt(t);
+    }
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct tag<pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct return_type<pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef typename pythagoras<Point1, Point2, CalculationType>::calculation_type type;
+};
+
+
+template
+<
+    typename Point1,
+    typename Point2,
+    typename CalculationType,
+    typename P1,
+    typename P2
+>
+struct similar_type<pythagoras<Point1, Point2, CalculationType>, P1, P2>
+{
+    typedef pythagoras<P1, P2, CalculationType> type;
+};
+
+
+template
+<
+    typename Point1,
+    typename Point2,
+    typename CalculationType,
+    typename P1,
+    typename P2
+>
+struct get_similar<pythagoras<Point1, Point2, CalculationType>, P1, P2>
+{
+    static inline typename similar_type
+        <
+            pythagoras<Point1, Point2, CalculationType>, P1, P2
+        >::type apply(pythagoras<Point1, Point2, CalculationType> const& )
+    {
+        return pythagoras<P1, P2, CalculationType>();
+    }
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct comparable_type<pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef comparable::pythagoras<Point1, Point2, CalculationType> type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct get_comparable<pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef comparable::pythagoras<Point1, Point2, CalculationType> comparable_type;
+public :
+    static inline comparable_type apply(pythagoras<Point1, Point2, CalculationType> const& )
+    {
+        return comparable_type();
+    }
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct result_from_distance<pythagoras<Point1, Point2, CalculationType> >
+{
+private :
+    typedef typename return_type<pythagoras<Point1, Point2, CalculationType> >::type return_type;
+public :
+    template <typename T>
+    static inline return_type apply(pythagoras<Point1, Point2, CalculationType> const& , T const& value)
+    {
+        return return_type(value);
+    }
+};
+
+
+// Specializations for comparable::pythagoras
+template <typename Point1, typename Point2, typename CalculationType>
+struct tag<comparable::pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct return_type<comparable::pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef typename comparable::pythagoras<Point1, Point2, CalculationType>::calculation_type type;
+};
+
+
+
+
+template
+<
+    typename Point1,
+    typename Point2,
+    typename CalculationType,
+    typename P1,
+    typename P2
+>
+struct similar_type<comparable::pythagoras<Point1, Point2, CalculationType>, P1, P2>
+{
+    typedef comparable::pythagoras<P1, P2, CalculationType> type;
+};
+
+
+template
+<
+    typename Point1,
+    typename Point2,
+    typename CalculationType,
+    typename P1,
+    typename P2
+>
+struct get_similar<comparable::pythagoras<Point1, Point2, CalculationType>, P1, P2>
+{
+    static inline typename similar_type
+        <
+            comparable::pythagoras<Point1, Point2, CalculationType>, P1, P2
+        >::type apply(comparable::pythagoras<Point1, Point2, CalculationType> const& )
+    {
+        return comparable::pythagoras<P1, P2, CalculationType>();
+    }
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct comparable_type<comparable::pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef comparable::pythagoras<Point1, Point2, CalculationType> type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct get_comparable<comparable::pythagoras<Point1, Point2, CalculationType> >
+{
+    typedef comparable::pythagoras<Point1, Point2, CalculationType> comparable_type;
+public :
+    static inline comparable_type apply(comparable::pythagoras<Point1, Point2, CalculationType> const& )
+    {
+        return comparable_type();
+    }
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct result_from_distance<comparable::pythagoras<Point1, Point2, CalculationType> >
+{
+private :
+    typedef typename return_type<comparable::pythagoras<Point1, Point2, CalculationType> >::type return_type;
+public :
+    template <typename T>
+    static inline return_type apply(comparable::pythagoras<Point1, Point2, CalculationType> const& , T const& value)
+    {
+        return_type const v = value;
+        return v * v;
+    }
+};
+
+
+template <typename Point1, typename Point2>
+struct default_strategy<point_tag, Point1, Point2, cartesian_tag, cartesian_tag, void>
+{
+    typedef pythagoras<Point1, Point2> type;
+};
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_DISTANCE_PYTHAGORAS_HPP
diff --git a/src/boost/geometry/strategies/cartesian/point_in_box.hpp b/src/boost/geometry/strategies/cartesian/point_in_box.hpp
new file mode 100644
index 0000000..275f755
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/point_in_box.hpp
@@ -0,0 +1,172 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_BOX_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_BOX_HPP
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/strategies/covered_by.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+
+namespace boost { namespace geometry { namespace strategy 
+{
+    
+namespace within
+{
+
+
+struct within_range
+{
+    template <typename Value1, typename Value2>
+    static inline bool apply(Value1 const& value, Value2 const& min_value, Value2 const& max_value)
+    {
+        return value > min_value && value < max_value;
+    }
+};
+
+
+struct covered_by_range
+{
+    template <typename Value1, typename Value2>
+    static inline bool apply(Value1 const& value, Value2 const& min_value, Value2 const& max_value)
+    {
+        return value >= min_value && value <= max_value;
+    }
+};
+
+
+template
+<
+    typename SubStrategy,
+    typename Point,
+    typename Box,
+    std::size_t Dimension,
+    std::size_t DimensionCount
+>
+struct relate_point_box_loop
+{
+    static inline bool apply(Point const& point, Box const& box)
+    {
+        if (! SubStrategy::apply(get<Dimension>(point), 
+                    get<min_corner, Dimension>(box), 
+                    get<max_corner, Dimension>(box))
+            )
+        {
+            return false;
+        }
+        
+        return relate_point_box_loop
+            <
+                SubStrategy,
+                Point, Box,
+                Dimension + 1, DimensionCount
+            >::apply(point, box);
+    }
+};
+
+
+template
+<
+    typename SubStrategy,
+    typename Point,
+    typename Box,
+    std::size_t DimensionCount
+>
+struct relate_point_box_loop<SubStrategy, Point, Box, DimensionCount, DimensionCount>
+{
+    static inline bool apply(Point const& , Box const& )
+    {
+        return true;
+    }
+};
+
+
+template
+<
+    typename Point,
+    typename Box,
+    typename SubStrategy = within_range
+>
+struct point_in_box
+{
+    static inline bool apply(Point const& point, Box const& box) 
+    {
+        return relate_point_box_loop
+            <
+                SubStrategy,
+                Point, Box, 
+                0, dimension<Point>::type::value
+            >::apply(point, box);
+    }
+};
+
+
+} // namespace within
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+namespace within { namespace services
+{
+
+template <typename Point, typename Box>
+struct default_strategy
+    <
+        point_tag, box_tag, 
+        point_tag, areal_tag, 
+        cartesian_tag, cartesian_tag, 
+        Point, Box
+    >
+{
+    typedef within::point_in_box<Point, Box> type; 
+};
+
+
+}} // namespace within::services
+
+
+namespace covered_by { namespace services
+{
+
+
+template <typename Point, typename Box>
+struct default_strategy
+    <
+        point_tag, box_tag, 
+        point_tag, areal_tag, 
+        cartesian_tag, cartesian_tag, 
+        Point, Box
+    >
+{
+    typedef within::point_in_box
+                <
+                    Point, Box,
+                    within::covered_by_range
+                > type;
+};
+
+
+}} // namespace covered_by::services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}}} // namespace boost::geometry::strategy
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_BOX_HPP
diff --git a/src/boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp b/src/boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp
new file mode 100644
index 0000000..94da5cc
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp
@@ -0,0 +1,124 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_POLY_CROSSINGS_MULTIPLY_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_POLY_CROSSINGS_MULTIPLY_HPP
+
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace within
+{
+
+/*!
+\brief Within detection using cross counting,
+\ingroup strategies
+\tparam Point \tparam_point
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+\see http://tog.acm.org/resources/GraphicsGems/gemsiv/ptpoly_haines/ptinpoly.c
+\note Does NOT work correctly for point ON border
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
+}
+ */
+
+template
+<
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void
+>
+class crossings_multiply
+{
+    typedef typename select_calculation_type
+        <
+            Point,
+            PointOfSegment,
+            CalculationType
+        >::type calculation_type;
+
+    class flags
+    {
+        bool inside_flag;
+        bool first;
+        bool yflag0;
+
+    public :
+
+        friend class crossings_multiply;
+
+        inline flags()
+            : inside_flag(false)
+            , first(true)
+            , yflag0(false)
+        {}
+    };
+
+public :
+
+    typedef Point point_type;
+    typedef PointOfSegment segment_point_type;
+    typedef flags state_type;
+
+    static inline bool apply(Point const& point,
+            PointOfSegment const& seg1, PointOfSegment const& seg2,
+            flags& state)
+    {
+        calculation_type const tx = get<0>(point);
+        calculation_type const ty = get<1>(point);
+        calculation_type const x0 = get<0>(seg1);
+        calculation_type const y0 = get<1>(seg1);
+        calculation_type const x1 = get<0>(seg2);
+        calculation_type const y1 = get<1>(seg2);
+
+        if (state.first)
+        {
+            state.first = false;
+            state.yflag0 = y0 >= ty;
+        }
+
+
+        bool yflag1 = y1 >= ty;
+        if (state.yflag0 != yflag1)
+        {
+            if ( ((y1-ty) * (x0-x1) >= (x1-tx) * (y0-y1)) == yflag1 )
+            {
+                state.inside_flag = ! state.inside_flag;
+            }
+        }
+        state.yflag0 = yflag1;
+        return true;
+    }
+
+    static inline int result(flags const& state)
+    {
+        return state.inside_flag ? 1 : -1;
+    }
+};
+
+
+
+}} // namespace strategy::within
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_POLY_CROSSINGS_MULTIPLY_HPP
diff --git a/src/boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp b/src/boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp
new file mode 100644
index 0000000..a774d3c
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp
@@ -0,0 +1,118 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_POLY_FRANKLIN_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_POLY_FRANKLIN_HPP
+
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/util/select_calculation_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace within
+{
+
+/*!
+\brief Within detection using cross counting
+\ingroup strategies
+\tparam Point \tparam_point
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+\author adapted from Randolph Franklin algorithm
+\author Barend and Maarten, 1995
+\author Revised for templatized library, Barend Gehrels, 2007
+\return true if point is in ring, works for closed rings in both directions
+\note Does NOT work correctly for point ON border
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
+}
+ */
+
+template
+<
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void
+>
+class franklin
+{
+    typedef typename select_calculation_type
+        <
+            Point,
+            PointOfSegment,
+            CalculationType
+        >::type calculation_type;
+
+        /*! subclass to keep state */
+        class crossings
+        {
+            bool crosses;
+
+        public :
+
+            friend class franklin;
+            inline crossings()
+                : crosses(false)
+            {}
+        };
+
+public :
+
+    typedef Point point_type;
+    typedef PointOfSegment segment_point_type;
+    typedef crossings state_type;
+
+    static inline bool apply(Point const& point,
+            PointOfSegment const& seg1, PointOfSegment const& seg2,
+            crossings& state)
+    {
+        calculation_type const& px = get<0>(point);
+        calculation_type const& py = get<1>(point);
+        calculation_type const& x1 = get<0>(seg1);
+        calculation_type const& y1 = get<1>(seg1);
+        calculation_type const& x2 = get<0>(seg2);
+        calculation_type const& y2 = get<1>(seg2);
+
+        if (
+            ( (y2 <= py && py < y1) || (y1 <= py && py < y2) )
+            && (px < (x1 - x2) * (py - y2) / (y1 - y2) + x2)
+            )
+        {
+            state.crosses = ! state.crosses;
+        }
+        return true;
+    }
+
+    static inline int result(crossings const& state)
+    {
+        return state.crosses ? 1 : -1;
+    }
+};
+
+
+
+}} // namespace strategy::within
+
+
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_POINT_IN_POLY_FRANKLIN_HPP
diff --git a/src/boost/geometry/strategies/cartesian/side_by_triangle.hpp b/src/boost/geometry/strategies/cartesian/side_by_triangle.hpp
new file mode 100644
index 0000000..967090c
--- /dev/null
+++ b/src/boost/geometry/strategies/cartesian/side_by_triangle.hpp
@@ -0,0 +1,121 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_SIDE_BY_TRIANGLE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_SIDE_BY_TRIANGLE_HPP
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/arithmetic/determinant.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/strategies/side.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace side
+{
+
+/*!
+\brief Check at which side of a segment a point lies:
+    left of segment (> 0), right of segment (< 0), on segment (0)
+\ingroup strategies
+\tparam CalculationType \tparam_calculation
+ */
+template <typename CalculationType = void>
+class side_by_triangle
+{
+public :
+
+    // Template member function, because it is not always trivial
+    // or convenient to explicitly mention the typenames in the
+    // strategy-struct itself.
+
+    // Types can be all three different. Therefore it is
+    // not implemented (anymore) as "segment"
+
+    template <typename P1, typename P2, typename P>
+    static inline int apply(P1 const& p1, P2 const& p2, P const& p)
+    {
+        typedef typename boost::mpl::if_c
+            <
+                boost::is_void<CalculationType>::type::value,
+                typename select_most_precise
+                    <
+                        typename select_most_precise
+                            <
+                                typename coordinate_type<P1>::type,
+                                typename coordinate_type<P2>::type
+                            >::type,
+                        typename coordinate_type<P>::type
+                    >::type,
+                CalculationType
+            >::type coordinate_type;
+
+        coordinate_type const x = get<0>(p);
+        coordinate_type const y = get<1>(p);
+
+        coordinate_type const sx1 = get<0>(p1);
+        coordinate_type const sy1 = get<1>(p1);
+        coordinate_type const sx2 = get<0>(p2);
+        coordinate_type const sy2 = get<1>(p2);
+
+        // Promote float->double, small int->int
+        typedef typename select_most_precise
+            <
+                coordinate_type,
+                double
+            >::type promoted_type;
+
+        promoted_type const dx = sx2 - sx1;
+        promoted_type const dy = sy2 - sy1;
+        promoted_type const dpx = x - sx1;
+        promoted_type const dpy = y - sy1;
+
+        promoted_type const s 
+            = geometry::detail::determinant<promoted_type>
+                (
+                    dx, dy, 
+                    dpx, dpy
+                );
+
+        promoted_type const zero = promoted_type();
+        return math::equals(s, zero) ? 0 
+            : s > zero ? 1 
+            : -1;
+    }
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename CalculationType>
+struct default_strategy<cartesian_tag, CalculationType>
+{
+    typedef side_by_triangle<CalculationType> type;
+};
+
+}
+#endif
+
+}} // namespace strategy::side
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_SIDE_BY_TRIANGLE_HPP
diff --git a/src/boost/geometry/strategies/centroid.hpp b/src/boost/geometry/strategies/centroid.hpp
new file mode 100644
index 0000000..4963e6b
--- /dev/null
+++ b/src/boost/geometry/strategies/centroid.hpp
@@ -0,0 +1,72 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CENTROID_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CENTROID_HPP
+
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/strategies/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace centroid
+{
+
+struct not_applicable_strategy
+{
+};
+
+
+namespace services
+{
+
+/*!
+    \brief Traits class binding a centroid calculation strategy to a coordinate system
+    \ingroup centroid
+    \tparam CsTag tag of coordinate system, for specialization
+    \tparam GeometryTag tag of geometry, for specialization
+    \tparam Dimension dimension of geometry, for specialization
+    \tparam Point point-type
+    \tparam Geometry
+*/
+template
+<
+    typename CsTag,
+    typename GeometryTag,
+    std::size_t Dimension,
+    typename Point,
+    typename Geometry
+>
+struct default_strategy
+{
+    typedef not_applicable_strategy type;
+};
+
+
+} // namespace services
+
+
+}} // namespace strategy::centroid
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CENTROID_HPP
diff --git a/src/boost/geometry/strategies/compare.hpp b/src/boost/geometry/strategies/compare.hpp
new file mode 100644
index 0000000..2958319
--- /dev/null
+++ b/src/boost/geometry/strategies/compare.hpp
@@ -0,0 +1,172 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
+
+#include <cstddef>
+#include <functional>
+
+#include <boost/mpl/if.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+#include <boost/geometry/strategies/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+    \brief Traits class binding a comparing strategy to a coordinate system
+    \ingroup util
+    \tparam Tag tag of coordinate system of point-type
+    \tparam Direction direction to compare on: 1 for less (-> ascending order)
+        and -1 for greater (-> descending order)
+    \tparam Point point-type
+    \tparam CoordinateSystem coordinate sytem of point
+    \tparam Dimension: the dimension to compare on
+*/
+template
+<
+    typename Tag,
+    int Direction,
+    typename Point,
+    typename CoordinateSystem,
+    std::size_t Dimension
+>
+struct strategy_compare
+{
+    typedef strategy::not_implemented type;
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+// For compare we add defaults specializations,
+// because they defaultly redirect to std::less / greater / equal_to
+template
+<
+    typename Tag,
+    typename Point,
+    typename CoordinateSystem,
+    std::size_t Dimension
+>
+struct strategy_compare<Tag, 1, Point, CoordinateSystem, Dimension>
+{
+    typedef std::less<typename coordinate_type<Point>::type> type;
+};
+
+
+template
+<
+    typename Tag,
+    typename Point,
+    typename CoordinateSystem,
+    std::size_t Dimension
+>
+struct strategy_compare<Tag, -1, Point, CoordinateSystem, Dimension>
+{
+    typedef std::greater<typename coordinate_type<Point>::type> type;
+};
+
+
+template
+<
+    typename Tag,
+    typename Point,
+    typename CoordinateSystem,
+    std::size_t Dimension
+>
+struct strategy_compare<Tag, 0, Point, CoordinateSystem, Dimension>
+{
+    typedef std::equal_to<typename coordinate_type<Point>::type> type;
+};
+
+
+#endif
+
+
+namespace strategy { namespace compare
+{
+
+
+/*!
+    \brief Default strategy, indicates the default strategy for comparisons
+    \details The default strategy for comparisons defer in most cases
+        to std::less (for ascending) and std::greater (for descending).
+        However, if a spherical coordinate system is used, and comparison
+        is done on longitude, it will take another strategy handling circular
+*/
+struct default_strategy {};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Type>
+struct is_default : boost::false_type
+{};
+
+
+template <>
+struct is_default<default_strategy> : boost::true_type
+{};
+
+
+/*!
+    \brief Meta-function to select strategy
+    \details If "default_strategy" is specified, it will take the
+        traits-registered class for the specified coordinate system.
+        If another strategy is explicitly specified, it takes that one.
+*/
+template
+<
+    typename Strategy,
+    int Direction,
+    typename Point,
+    std::size_t Dimension
+>
+struct select_strategy
+{
+    typedef typename
+        boost::mpl::if_
+        <
+            is_default<Strategy>,
+            typename strategy_compare
+            <
+                typename cs_tag<Point>::type,
+                Direction,
+                Point,
+                typename coordinate_system<Point>::type,
+                Dimension
+            >::type,
+            Strategy
+        >::type type;
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+}} // namespace strategy::compare
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
diff --git a/src/boost/geometry/strategies/concepts/area_concept.hpp b/src/boost/geometry/strategies/concepts/area_concept.hpp
new file mode 100644
index 0000000..75821b5
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/area_concept.hpp
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_AREA_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_AREA_CONCEPT_HPP
+
+
+#include <boost/concept_check.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+    \brief Checks strategy for area
+    \ingroup area
+*/
+template <typename Strategy>
+class AreaStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    // 1) must define state_type,
+    typedef typename Strategy::state_type state_type;
+
+    // 2) must define return_type,
+    typedef typename Strategy::return_type return_type;
+
+    // 3) must define point_type, of polygon (segments)
+    typedef typename Strategy::segment_point_type spoint_type;
+
+    struct check_methods
+    {
+        static void apply()
+        {
+            Strategy const* str = 0;
+            state_type *st = 0;
+
+            // 4) must implement a method apply with the following signature
+            spoint_type const* sp = 0;
+            str->apply(*sp, *sp, *st);
+
+            // 5) must implement a static method result with the following signature
+            return_type r = str->result(*st);
+
+            boost::ignore_unused_variable_warning(r);
+            boost::ignore_unused_variable_warning(str);
+        }
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(AreaStrategy)
+    {
+        check_methods::apply();
+    }
+
+#endif
+};
+
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_AREA_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/concepts/centroid_concept.hpp b/src/boost/geometry/strategies/concepts/centroid_concept.hpp
new file mode 100644
index 0000000..f493ef6
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/centroid_concept.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
+
+
+
+#include <boost/concept_check.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+    \brief Checks strategy for centroid
+    \ingroup centroid
+*/
+template <typename Strategy>
+class CentroidStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    // 1) must define state_type,
+    typedef typename Strategy::state_type state_type;
+
+    // 2) must define point_type,
+    typedef typename Strategy::point_type point_type;
+
+    // 3) must define point_type, of polygon (segments)
+    typedef typename Strategy::segment_point_type spoint_type;
+
+    struct check_methods
+    {
+        static void apply()
+        {
+            Strategy *str = 0;
+            state_type *st = 0;
+
+            // 4) must implement a static method apply,
+            // getting two segment-points
+            spoint_type const* sp = 0;
+            str->apply(*sp, *sp, *st);
+
+            // 5) must implement a static method result
+            //  getting the centroid
+            point_type *c = 0;
+            bool r = str->result(*st, *c);
+
+            boost::ignore_unused_variable_warning(str);
+            boost::ignore_unused_variable_warning(r);
+        }
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(CentroidStrategy)
+    {
+        check_methods::apply();
+    }
+#endif
+};
+
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/concepts/convex_hull_concept.hpp b/src/boost/geometry/strategies/concepts/convex_hull_concept.hpp
new file mode 100644
index 0000000..b31f0ca
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/convex_hull_concept.hpp
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CONVEX_HULL_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CONVEX_HULL_CONCEPT_HPP
+
+
+#include <vector>
+
+#include <boost/concept_check.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+    \brief Checks strategy for convex_hull
+    \ingroup convex_hull
+*/
+template <typename Strategy>
+class ConvexHullStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    // 1) must define state_type
+    typedef typename Strategy::state_type state_type;
+
+    // 2) must define point_type
+    typedef typename Strategy::point_type point_type;
+
+    // 3) must define geometry_type
+    typedef typename Strategy::geometry_type geometry_type;
+
+    struct check_methods
+    {
+        static void apply()
+        {
+            Strategy const* str;
+
+            state_type* st;
+            geometry_type* sp;
+            std::vector<point_type> *v;
+
+            // 4) must implement a method apply, iterating over a range
+            str->apply(*sp, *st);
+
+            // 5) must implement a method result, with an output iterator
+            str->result(*st, std::back_inserter(*v), true);
+        }
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(ConvexHullStrategy)
+    {
+        check_methods::apply();
+    }
+#endif
+};
+
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_CONVEX_HULL_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/concepts/distance_concept.hpp b/src/boost/geometry/strategies/concepts/distance_concept.hpp
new file mode 100644
index 0000000..ba347d0
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/distance_concept.hpp
@@ -0,0 +1,206 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
+
+#include <vector>
+#include <iterator>
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/util/parameter_type_of.hpp>
+
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+    \brief Checks strategy for point-segment-distance
+    \ingroup distance
+*/
+template <typename Strategy>
+struct PointDistanceStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+private :
+
+    struct checker
+    {
+        template <typename ApplyMethod>
+        static void apply(ApplyMethod const&)
+        {
+            // 1: inspect and define both arguments of apply
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 0
+                >::type ptype1;
+
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 1
+                >::type ptype2;
+
+            // 2) check if apply-arguments fulfill point concept
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<ptype1>)
+                );
+
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<ptype2>)
+                );
+
+
+            // 3) must define meta-function return_type
+            typedef typename strategy::distance::services::return_type<Strategy>::type rtype;
+
+            // 4) must define meta-function "similar_type"
+            typedef typename strategy::distance::services::similar_type
+                <
+                    Strategy, ptype2, ptype1
+                >::type stype;
+
+            // 5) must define meta-function "comparable_type"
+            typedef typename strategy::distance::services::comparable_type
+                <
+                    Strategy
+                >::type ctype;
+
+            // 6) must define meta-function "tag"
+            typedef typename strategy::distance::services::tag
+                <
+                    Strategy
+                >::type tag;
+
+            // 7) must implement apply with arguments
+            Strategy* str = 0;
+            ptype1 *p1 = 0;
+            ptype2 *p2 = 0;
+            rtype r = str->apply(*p1, *p2);
+
+            // 8) must define (meta)struct "get_similar" with apply
+            stype s = strategy::distance::services::get_similar
+                <
+                    Strategy,
+                    ptype2, ptype1
+                >::apply(*str);
+
+            // 9) must define (meta)struct "get_comparable" with apply
+            ctype c = strategy::distance::services::get_comparable
+                <
+                    Strategy
+                >::apply(*str);
+
+            // 10) must define (meta)struct "result_from_distance" with apply
+            r = strategy::distance::services::result_from_distance
+                <
+                    Strategy
+                >::apply(*str, 1.0);
+
+            boost::ignore_unused_variable_warning(str);
+            boost::ignore_unused_variable_warning(s);
+            boost::ignore_unused_variable_warning(c);
+            boost::ignore_unused_variable_warning(r);
+        }
+    };
+
+
+
+public :
+    BOOST_CONCEPT_USAGE(PointDistanceStrategy)
+    {
+        checker::apply(&Strategy::apply);
+    }
+#endif
+};
+
+
+/*!
+    \brief Checks strategy for point-segment-distance
+    \ingroup strategy_concepts
+*/
+template <typename Strategy>
+struct PointSegmentDistanceStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+private :
+
+    struct checker
+    {
+        template <typename ApplyMethod>
+        static void apply(ApplyMethod const&)
+        {
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 0
+                >::type ptype;
+
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 1
+                >::type sptype;
+
+            // 2) check if apply-arguments fulfill point concept
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<ptype>)
+                );
+
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<sptype>)
+                );
+
+
+            // 3) must define meta-function return_type
+            typedef typename strategy::distance::services::return_type<Strategy>::type rtype;
+
+            // 4) must define underlying point-distance-strategy
+            typedef typename strategy::distance::services::strategy_point_point<Strategy>::type stype;
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::PointDistanceStrategy<stype>)
+                );
+
+
+            Strategy *str = 0;
+            ptype *p = 0;
+            sptype *sp1 = 0;
+            sptype *sp2 = 0;
+
+            rtype r = str->apply(*p, *sp1, *sp2);
+
+            boost::ignore_unused_variable_warning(str);
+            boost::ignore_unused_variable_warning(r);
+        }
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(PointSegmentDistanceStrategy)
+    {
+        checker::apply(&Strategy::apply);
+    }
+#endif
+};
+
+
+}}} // namespace boost::geometry::concept
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_DISTANCE_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/concepts/segment_intersect_concept.hpp b/src/boost/geometry/strategies/concepts/segment_intersect_concept.hpp
new file mode 100644
index 0000000..43bcccf
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/segment_intersect_concept.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SEGMENT_INTERSECT_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SEGMENT_INTERSECT_CONCEPT_HPP
+
+
+//NOT FINISHED!
+
+#include <boost/concept_check.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+    \brief Checks strategy for segment intersection
+    \ingroup segment_intersection
+*/
+template <typename Strategy>
+class SegmentIntersectStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    // 1) must define return_type
+    typedef typename Strategy::return_type return_type;
+
+    // 2) must define point_type (of segment points)
+    //typedef typename Strategy::point_type point_type;
+
+    // 3) must define segment_type 1 and 2 (of segment points)
+    typedef typename Strategy::segment_type1 segment_type1;
+    typedef typename Strategy::segment_type2 segment_type2;
+
+
+    struct check_methods
+    {
+        static void apply()
+        {
+            Strategy const* str;
+
+            return_type* rt;
+            //point_type const* p;
+            segment_type1 const* s1;
+            segment_type2 const* s2;
+
+            // 4) must implement a method apply
+            //    having two segments
+            *rt = str->apply(*s1, *s2);
+
+        }
+    };
+
+
+public :
+    BOOST_CONCEPT_USAGE(SegmentIntersectStrategy)
+    {
+        check_methods::apply();
+    }
+#endif
+};
+
+
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SEGMENT_INTERSECT_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/concepts/simplify_concept.hpp b/src/boost/geometry/strategies/concepts/simplify_concept.hpp
new file mode 100644
index 0000000..92e5156
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/simplify_concept.hpp
@@ -0,0 +1,109 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP
+
+#include <vector>
+#include <iterator>
+
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/strategies/concepts/distance_concept.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+    \brief Checks strategy for simplify
+    \ingroup simplify
+*/
+template <typename Strategy>
+struct SimplifyStrategy
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+private :
+
+    // 1) must define distance_strategy_type,
+    //    defining point-segment distance strategy (to be checked)
+    typedef typename Strategy::distance_strategy_type ds_type;
+
+
+    struct checker
+    {
+        template <typename ApplyMethod>
+        static void apply(ApplyMethod const&)
+        {
+            namespace ft = boost::function_types;
+            typedef typename ft::parameter_types
+                <
+                    ApplyMethod
+                >::type parameter_types;
+
+            typedef typename boost::mpl::if_
+                <
+                    ft::is_member_function_pointer<ApplyMethod>,
+                    boost::mpl::int_<1>,
+                    boost::mpl::int_<0>
+                >::type base_index;
+
+            // 1: inspect and define both arguments of apply
+            typedef typename boost::remove_const
+                <
+                    typename boost::remove_reference
+                    <
+                        typename boost::mpl::at
+                            <
+                                parameter_types,
+                                base_index
+                            >::type
+                    >::type
+                >::type point_type;
+
+
+
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::PointSegmentDistanceStrategy<ds_type>)
+                );
+
+            Strategy *str = 0;
+            std::vector<point_type> const* v1 = 0;
+            std::vector<point_type> * v2 = 0;
+
+            // 2) must implement method apply with arguments
+            //    - Range
+            //    - OutputIterator
+            //    - floating point value
+            str->apply(*v1, std::back_inserter(*v2), 1.0);
+
+            boost::ignore_unused_variable_warning(str);
+        }
+    };
+
+public :
+    BOOST_CONCEPT_USAGE(SimplifyStrategy)
+    {
+        checker::apply(&ds_type::apply);
+
+    }
+#endif
+};
+
+
+
+}}} // namespace boost::geometry::concept
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_SIMPLIFY_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/concepts/within_concept.hpp b/src/boost/geometry/strategies/concepts/within_concept.hpp
new file mode 100644
index 0000000..a9684b9
--- /dev/null
+++ b/src/boost/geometry/strategies/concepts/within_concept.hpp
@@ -0,0 +1,291 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP
+
+
+
+#include <boost/concept_check.hpp>
+#include <boost/function_types/result_type.hpp>
+
+#include <boost/geometry/util/parameter_type_of.hpp>
+
+
+namespace boost { namespace geometry { namespace concept
+{
+
+
+/*!
+\brief Checks strategy for within (point-in-polygon)
+\ingroup within
+*/
+template <typename Strategy>
+class WithinStrategyPolygonal
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    // 1) must define state_type
+    typedef typename Strategy::state_type state_type;
+
+    struct checker
+    {
+        template <typename ApplyMethod, typename ResultMethod>
+        static void apply(ApplyMethod const&, ResultMethod const& )
+        {
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 0
+                >::type point_type;
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 1
+                >::type segment_point_type;
+
+            // CHECK: apply-arguments should both fulfill point concept
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<point_type>)
+                );
+
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<segment_point_type>)
+                );
+
+            // CHECK: return types (result: int, apply: bool)
+            BOOST_MPL_ASSERT_MSG
+                (
+                    (boost::is_same
+                        <
+                            bool, typename boost::function_types::result_type<ApplyMethod>::type
+                        >::type::value),
+                    WRONG_RETURN_TYPE_OF_APPLY
+                    , (bool)
+                );
+            BOOST_MPL_ASSERT_MSG
+                (
+                    (boost::is_same
+                        <
+                            int, typename boost::function_types::result_type<ResultMethod>::type
+                        >::type::value),
+                    WRONG_RETURN_TYPE_OF_RESULT
+                    , (int)
+                );
+
+
+            // CHECK: calling method apply and result
+            Strategy const* str = 0;
+            state_type* st = 0;
+            point_type const* p = 0;
+            segment_point_type const* sp = 0;
+
+            bool b = str->apply(*p, *sp, *sp, *st);
+            int r = str->result(*st);
+
+            boost::ignore_unused_variable_warning(r);
+            boost::ignore_unused_variable_warning(b);
+            boost::ignore_unused_variable_warning(str);
+        }
+    };
+
+
+public :
+    BOOST_CONCEPT_USAGE(WithinStrategyPolygonal)
+    {
+        checker::apply(&Strategy::apply, &Strategy::result);
+    }
+#endif
+};
+
+template <typename Strategy>
+class WithinStrategyPointBox
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    struct checker
+    {
+        template <typename ApplyMethod>
+        static void apply(ApplyMethod const&)
+        {
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 0
+                >::type point_type;
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 1
+                >::type box_type;
+
+            // CHECK: apply-arguments should fulfill point/box concept
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstPoint<point_type>)
+                );
+
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstBox<box_type>)
+                );
+
+            // CHECK: return types (apply: bool)
+            BOOST_MPL_ASSERT_MSG
+                (
+                    (boost::is_same
+                        <
+                            bool, 
+                            typename boost::function_types::result_type<ApplyMethod>::type
+                        >::type::value),
+                    WRONG_RETURN_TYPE
+                    , (bool)
+                );
+
+
+            // CHECK: calling method apply
+            Strategy const* str = 0;
+            point_type const* p = 0;
+            box_type const* bx = 0;
+
+            bool b = str->apply(*p, *bx);
+
+            boost::ignore_unused_variable_warning(b);
+            boost::ignore_unused_variable_warning(str);
+        }
+    };
+
+
+public :
+    BOOST_CONCEPT_USAGE(WithinStrategyPointBox)
+    {
+        checker::apply(&Strategy::apply);
+    }
+#endif
+};
+
+template <typename Strategy>
+class WithinStrategyBoxBox
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+    struct checker
+    {
+        template <typename ApplyMethod>
+        static void apply(ApplyMethod const&)
+        {
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 0
+                >::type box_type1;
+            typedef typename parameter_type_of
+                <
+                    ApplyMethod, 1
+                >::type box_type2;
+
+            // CHECK: apply-arguments should both fulfill box concept
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstBox<box_type1>)
+                );
+
+            BOOST_CONCEPT_ASSERT
+                (
+                    (concept::ConstBox<box_type2>)
+                );
+
+            // CHECK: return types (apply: bool)
+            BOOST_MPL_ASSERT_MSG
+                (
+                    (boost::is_same
+                        <
+                            bool, 
+                            typename boost::function_types::result_type<ApplyMethod>::type
+                        >::type::value),
+                    WRONG_RETURN_TYPE
+                    , (bool)
+                );
+
+
+            // CHECK: calling method apply
+            Strategy const* str = 0;
+            box_type1 const* b1 = 0;
+            box_type2 const* b2 = 0;
+
+            bool b = str->apply(*b1, *b2);
+
+            boost::ignore_unused_variable_warning(b);
+            boost::ignore_unused_variable_warning(str);
+        }
+    };
+
+
+public :
+    BOOST_CONCEPT_USAGE(WithinStrategyBoxBox)
+    {
+        checker::apply(&Strategy::apply);
+    }
+#endif
+};
+
+// So now: boost::geometry::concept::within
+namespace within 
+{ 
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename FirstTag, typename SecondTag, typename CastedTag, typename Strategy>
+struct check_within
+{};
+
+
+template <typename AnyTag, typename Strategy>
+struct check_within<point_tag, AnyTag, areal_tag, Strategy>
+{
+    BOOST_CONCEPT_ASSERT( (WithinStrategyPolygonal<Strategy>) );
+};
+
+
+template <typename Strategy>
+struct check_within<point_tag, box_tag, areal_tag, Strategy>
+{
+    BOOST_CONCEPT_ASSERT( (WithinStrategyPointBox<Strategy>) );
+};
+
+template <typename Strategy>
+struct check_within<box_tag, box_tag, areal_tag, Strategy>
+{
+    BOOST_CONCEPT_ASSERT( (WithinStrategyBoxBox<Strategy>) );
+};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief Checks, in compile-time, the concept of any within-strategy
+\ingroup concepts
+*/
+template <typename FirstTag, typename SecondTag, typename CastedTag, typename Strategy>
+inline void check()
+{
+    dispatch::check_within<FirstTag, SecondTag, CastedTag, Strategy> c;
+    boost::ignore_unused_variable_warning(c);
+}
+
+
+}}}} // namespace boost::geometry::concept::within
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP
diff --git a/src/boost/geometry/strategies/convex_hull.hpp b/src/boost/geometry/strategies/convex_hull.hpp
new file mode 100644
index 0000000..f4edc5b
--- /dev/null
+++ b/src/boost/geometry/strategies/convex_hull.hpp
@@ -0,0 +1,47 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_CONVEX_HULL_HPP
+#define BOOST_GEOMETRY_STRATEGIES_CONVEX_HULL_HPP
+
+#include <boost/geometry/strategies/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+/*!
+    \brief Traits class binding a convex hull calculation strategy to a coordinate system
+    \ingroup convex_hull
+    \tparam Tag tag of coordinate system
+    \tparam Geometry the geometry type (hull operates internally per hull over geometry)
+    \tparam Point point-type of output points
+*/
+template
+<
+    typename Geometry1,
+    typename Point,
+    typename CsTag = typename cs_tag<Point>::type
+>
+struct strategy_convex_hull
+{
+    typedef strategy::not_implemented type;
+};
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_CONVEX_HULL_HPP
diff --git a/src/boost/geometry/strategies/covered_by.hpp b/src/boost/geometry/strategies/covered_by.hpp
new file mode 100644
index 0000000..a878b26
--- /dev/null
+++ b/src/boost/geometry/strategies/covered_by.hpp
@@ -0,0 +1,72 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_COVERED_BY_HPP
+#define BOOST_GEOMETRY_STRATEGIES_COVERED_BY_HPP
+
+#include <boost/mpl/assert.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace covered_by
+{
+
+
+namespace services
+{
+
+/*!
+\brief Traits class binding a covered_by determination strategy to a coordinate system
+\ingroup covered_by
+\tparam TagContained tag (possibly casted) of point-type
+\tparam TagContained tag (possibly casted) of (possibly) containing type
+\tparam CsTagContained tag of coordinate system of point-type
+\tparam CsTagContaining tag of coordinate system of (possibly) containing type
+\tparam Geometry geometry-type of input (often point, or box)
+\tparam GeometryContaining geometry-type of input (possibly) containing type
+*/
+template
+<
+    typename TagContained,
+    typename TagContaining,
+    typename CastedTagContained,
+    typename CastedTagContaining,
+    typename CsTagContained,
+    typename CsTagContaining,
+    typename GeometryContained,
+    typename GeometryContaining
+>
+struct default_strategy
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_TYPES
+            , (types<GeometryContained, GeometryContaining>)
+        );
+};
+
+
+} // namespace services
+
+
+}} // namespace strategy::covered_by
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_COVERED_BY_HPP
+
diff --git a/src/boost/geometry/strategies/default_area_result.hpp b/src/boost/geometry/strategies/default_area_result.hpp
new file mode 100644
index 0000000..8adfa5d
--- /dev/null
+++ b/src/boost/geometry/strategies/default_area_result.hpp
@@ -0,0 +1,51 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_AREA_RESULT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_DEFAULT_AREA_RESULT_HPP
+
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/strategies/area.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Meta-function defining return type of area function, using the default strategy
+\ingroup area
+\note The strategy defines the return-type (so this situation is different
+    from length, where distance is sqr/sqrt, but length always squared)
+ */
+
+template <typename Geometry>
+struct default_area_result
+{
+    typedef typename point_type<Geometry>::type point_type;
+    typedef typename strategy::area::services::default_strategy
+        <
+            typename cs_tag<point_type>::type,
+            point_type
+        >::type strategy_type;
+
+    typedef typename strategy_type::return_type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_AREA_RESULT_HPP
diff --git a/src/boost/geometry/strategies/default_distance_result.hpp b/src/boost/geometry/strategies/default_distance_result.hpp
new file mode 100644
index 0000000..ea5f3ff
--- /dev/null
+++ b/src/boost/geometry/strategies/default_distance_result.hpp
@@ -0,0 +1,50 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_DISTANCE_RESULT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_DEFAULT_DISTANCE_RESULT_HPP
+
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/strategies/distance.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Meta-function defining return type of distance function
+\ingroup distance
+\note The strategy defines the return-type (so this situation is different
+    from length, where distance is sqr/sqrt, but length always squared)
+ */
+template <typename Geometry1, typename Geometry2 = Geometry1>
+struct default_distance_result
+{
+    typedef typename strategy::distance::services::return_type
+        <
+            typename strategy::distance::services::default_strategy
+                <
+                    point_tag,
+                    typename point_type<Geometry1>::type,
+                    typename point_type<Geometry2>::type
+                >::type
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_DISTANCE_RESULT_HPP
diff --git a/src/boost/geometry/strategies/default_length_result.hpp b/src/boost/geometry/strategies/default_length_result.hpp
new file mode 100644
index 0000000..706941b
--- /dev/null
+++ b/src/boost/geometry/strategies/default_length_result.hpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
+
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+    \brief Meta-function defining return type of length function
+    \ingroup length
+    \note Length of a line of integer coordinates can be double.
+        So we take at least a double. If Big Number types are used,
+        we take that type.
+
+ */
+template <typename Geometry>
+struct default_length_result
+{
+    typedef typename select_most_precise
+        <
+            typename coordinate_type<Geometry>::type,
+            long double
+        >::type type;
+};
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_DEFAULT_LENGTH_RESULT_HPP
diff --git a/src/boost/geometry/strategies/distance.hpp b/src/boost/geometry/strategies/distance.hpp
new file mode 100644
index 0000000..ef9a7ee
--- /dev/null
+++ b/src/boost/geometry/strategies/distance.hpp
@@ -0,0 +1,135 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/strategies/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace distance { namespace services
+{
+
+
+template <typename Strategy> struct tag {};
+template <typename Strategy> struct return_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>)
+        );
+};
+
+
+/*!
+    \brief Metafunction delivering a similar strategy with other input point types
+*/
+template
+<
+    typename Strategy,
+    typename Point1,
+    typename Point2
+>
+struct similar_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY
+            , (types<Strategy, Point1, Point2>)
+        );
+};
+
+template
+<
+    typename Strategy,
+    typename Point1,
+    typename Point2
+>
+struct get_similar
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY
+            , (types<Strategy, Point1, Point2>)
+        );
+};
+
+template <typename Strategy> struct comparable_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>)
+        );
+};
+
+template <typename Strategy> struct get_comparable
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>)
+        );
+};
+
+template <typename Strategy> struct result_from_distance {};
+
+
+// For point-segment only:
+template <typename Strategy> struct strategy_point_point {};
+
+
+// Default strategy
+
+
+/*!
+    \brief Traits class binding a default strategy for distance
+        to one (or possibly two) coordinate system(s)
+    \ingroup distance
+    \tparam GeometryTag tag (point/segment) for which this strategy is the default
+    \tparam Point1 first point-type
+    \tparam Point2 second point-type
+    \tparam CsTag1 tag of coordinate system of first point type
+    \tparam CsTag2 tag of coordinate system of second point type
+*/
+template
+<
+    typename GeometryTag,
+    typename Point1,
+    typename Point2 = Point1,
+    typename CsTag1 = typename cs_tag<Point1>::type,
+    typename CsTag2 = typename cs_tag<Point2>::type,
+    typename UnderlyingStrategy = void
+>
+struct default_strategy
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION
+            , (types<Point1, Point2, CsTag1, CsTag2>)
+        );
+};
+
+
+}}} // namespace strategy::distance::services
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP
diff --git a/src/boost/geometry/strategies/intersection.hpp b/src/boost/geometry/strategies/intersection.hpp
new file mode 100644
index 0000000..fc628c0
--- /dev/null
+++ b/src/boost/geometry/strategies/intersection.hpp
@@ -0,0 +1,93 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
+#define BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/geometries/segment.hpp>
+
+#include <boost/geometry/policies/relate/intersection_points.hpp>
+#include <boost/geometry/policies/relate/direction.hpp>
+#include <boost/geometry/policies/relate/tupled.hpp>
+
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/strategies/intersection.hpp>
+#include <boost/geometry/strategies/intersection_result.hpp>
+
+#include <boost/geometry/strategies/cartesian/cart_intersect.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+// The intersection strategy is a "compound strategy",
+// it contains a segment-intersection-strategy
+// and a side-strategy
+/*!
+\tparam CalculationType \tparam_calculation
+*/
+template
+<
+    typename Tag,
+    typename Geometry1,
+    typename Geometry2,
+    typename IntersectionPoint,
+    typename CalculationType = void
+>
+struct strategy_intersection
+{
+private :
+    typedef typename geometry::point_type<Geometry1>::type point1_type;
+    typedef typename geometry::point_type<Geometry2>::type point2_type;
+    typedef typename model::referring_segment<point1_type const> segment1_type;
+    typedef typename model::referring_segment<point2_type const> segment2_type;
+
+    typedef segment_intersection_points
+        <
+            IntersectionPoint
+        > ip_type;
+
+public:
+    typedef strategy::intersection::relate_cartesian_segments
+            <
+                policies::relate::segments_tupled
+                    <
+                        policies::relate::segments_intersection_points
+                            <
+                                segment1_type,
+                                segment2_type,
+                                ip_type,
+                                CalculationType
+                            > ,
+                        policies::relate::segments_direction
+                            <
+                                segment1_type,
+                                segment2_type,
+                                CalculationType
+                            >,
+                        CalculationType
+                    >,
+                CalculationType
+            > segment_intersection_strategy_type;
+
+    typedef typename strategy::side::services::default_strategy
+        <
+            Tag,
+            CalculationType
+        >::type side_strategy_type;
+};
+
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
diff --git a/src/boost/geometry/strategies/intersection_result.hpp b/src/boost/geometry/strategies/intersection_result.hpp
new file mode 100644
index 0000000..15917a9
--- /dev/null
+++ b/src/boost/geometry/strategies/intersection_result.hpp
@@ -0,0 +1,174 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP
+#define BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP
+
+#if defined(HAVE_MATRIX_AS_STRING)
+#include <string>
+#endif
+
+#include <cstddef>
+
+
+namespace boost { namespace geometry
+{
+
+/*!
+    \brief Dimensionally Extended 9 Intersection Matrix
+    \details
+    \ingroup overlay
+    \see http://gis.hsr.ch/wiki/images/3/3d/9dem_springer.pdf
+*/
+struct de9im
+{
+    int ii, ib, ie,
+        bi, bb, be,
+        ei, eb, ee;
+
+    inline de9im()
+        : ii(-1), ib(-1), ie(-1)
+        , bi(-1), bb(-1), be(-1)
+        , ei(-1), eb(-1), ee(-1)
+    {
+    }
+
+    inline de9im(int ii0, int ib0, int ie0,
+        int bi0, int bb0, int be0,
+        int ei0, int eb0, int ee0)
+        : ii(ii0), ib(ib0), ie(ie0)
+        , bi(bi0), bb(bb0), be(be0)
+        , ei(ei0), eb(eb0), ee(ee0)
+    {}
+
+    inline bool equals() const
+    {
+        return ii >= 0 && ie < 0 && be < 0 && ei < 0 && eb < 0;
+    }
+
+    inline bool disjoint() const
+    {
+        return ii < 0 && ib < 0 && bi < 0 && bb < 0;
+    }
+
+    inline bool intersects() const
+    {
+        return ii >= 0 || bb >= 0 || bi >= 0 || ib >= 0;
+    }
+
+    inline bool touches() const
+    {
+        return ii < 0 && (bb >= 0 || bi >= 0 || ib >= 0);
+    }
+
+    inline bool crosses() const
+    {
+        return (ii >= 0 && ie >= 0) || (ii == 0);
+    }
+
+    inline bool overlaps() const
+    {
+        return ii >= 0 && ie >= 0 && ei >= 0;
+    }
+
+    inline bool within() const
+    {
+        return ii >= 0 && ie < 0 && be < 0;
+    }
+
+    inline bool contains() const
+    {
+        return ii >= 0 && ei < 0 && eb < 0;
+    }
+
+
+    static inline char as_char(int v)
+    {
+        return v >= 0 && v < 10 ? ('0' + char(v)) : '-';
+    }
+
+#if defined(HAVE_MATRIX_AS_STRING)
+    inline std::string matrix_as_string(std::string const& tab, std::string const& nl) const
+    {
+        std::string ret;
+        ret.reserve(9 + tab.length() * 3 + nl.length() * 3);
+        ret += tab; ret += as_char(ii); ret += as_char(ib); ret += as_char(ie); ret += nl;
+        ret += tab; ret += as_char(bi); ret += as_char(bb); ret += as_char(be); ret += nl;
+        ret += tab; ret += as_char(ei); ret += as_char(eb); ret += as_char(ee);
+        return ret;
+    }
+
+    inline std::string matrix_as_string() const
+    {
+        return matrix_as_string("", "");
+    }
+#endif
+
+};
+
+struct de9im_segment : public de9im
+{
+    bool collinear; // true if segments are aligned (for equal,overlap,touch)
+    bool opposite; // true if direction is reversed (for equal,overlap,touch)
+    bool parallel;  // true if disjoint but parallel
+    bool degenerate; // true for segment(s) of zero length
+
+    double ra, rb; // temp
+
+    inline de9im_segment()
+        : de9im()
+        , collinear(false)
+        , opposite(false)
+        , parallel(false)
+        , degenerate(false)
+    {}
+
+    inline de9im_segment(double a, double b,
+        int ii0, int ib0, int ie0,
+        int bi0, int bb0, int be0,
+        int ei0, int eb0, int ee0,
+        bool c = false, bool o = false, bool p = false, bool d = false)
+        : de9im(ii0, ib0, ie0, bi0, bb0, be0, ei0, eb0, ee0)
+        , collinear(c)
+        , opposite(o)
+        , parallel(p)
+        , degenerate(d)
+        , ra(a), rb(b)
+    {}
+
+
+#if defined(HAVE_MATRIX_AS_STRING)
+    inline std::string as_string() const
+    {
+        std::string ret = matrix_as_string();
+        ret += collinear ? "c" : "-";
+        ret += opposite ? "o" : "-";
+        return ret;
+    }
+#endif
+};
+
+
+
+template <typename Point>
+struct segment_intersection_points
+{
+    std::size_t count;
+    Point intersections[2];
+    typedef Point point_type;
+
+    segment_intersection_points()
+        : count(0)
+    {}
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_RESULT_HPP
diff --git a/src/boost/geometry/strategies/side.hpp b/src/boost/geometry/strategies/side.hpp
new file mode 100644
index 0000000..376f2fd
--- /dev/null
+++ b/src/boost/geometry/strategies/side.hpp
@@ -0,0 +1,55 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SIDE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SIDE_HPP
+
+
+#include <boost/geometry/strategies/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace side
+{
+
+namespace services
+{
+
+/*!
+\brief Traits class binding a side determination strategy to a coordinate system
+\ingroup util
+\tparam Tag tag of coordinate system of point-type
+\tparam CalculationType \tparam_calculation
+*/
+template <typename Tag, typename CalculationType = void>
+struct default_strategy
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_TYPE
+            , (types<Tag>)
+        );
+};
+
+
+} // namespace services
+
+
+}} // namespace strategy::side
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SIDE_HPP
diff --git a/src/boost/geometry/strategies/side_info.hpp b/src/boost/geometry/strategies/side_info.hpp
new file mode 100644
index 0000000..f3a9da0
--- /dev/null
+++ b/src/boost/geometry/strategies/side_info.hpp
@@ -0,0 +1,166 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SIDE_INFO_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SIDE_INFO_HPP
+
+
+#include <utility>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief Class side_info: small class wrapping for sides (-1,0,1)
+*/
+class side_info
+{
+public :
+    inline side_info(int side_a1 = 0, int side_a2 = 0,
+            int side_b1 = 0, int side_b2 = 0)
+    {
+        sides[0].first = side_a1;
+        sides[0].second = side_a2;
+        sides[1].first = side_b1;
+        sides[1].second = side_b2;
+    }
+
+    template <int Which>
+    inline void set(int first, int second)
+    {
+        sides[Which].first = first;
+        sides[Which].second = second;
+    }
+
+    template <int Which, int Index>
+    inline void correct_to_zero()
+    {
+        if (Index == 0)
+        {
+            sides[Which].first = 0;
+        }
+        else
+        {
+            sides[Which].second = 0;
+        }
+    }
+
+    template <int Which, int Index>
+    inline int get() const
+    {
+        return Index == 0 ? sides[Which].first : sides[Which].second;
+    }
+
+
+    // Returns true if both lying on the same side WRT the other
+    // (so either 1,1 or -1-1)
+    template <int Which>
+    inline bool same() const
+    {
+        return sides[Which].first * sides[Which].second == 1;
+    }
+
+    inline bool collinear() const
+    {
+        return sides[0].first == 0
+            && sides[0].second == 0
+            && sides[1].first == 0
+            && sides[1].second == 0;
+    }
+
+    inline bool crossing() const
+    {
+        return sides[0].first * sides[0].second == -1
+            && sides[1].first * sides[1].second == -1;
+    }
+
+    inline bool touching() const
+    {
+        return (sides[0].first * sides[1].first == -1
+            && sides[0].second == 0 && sides[1].second == 0)
+            || (sides[1].first * sides[0].first == -1
+            && sides[1].second == 0 && sides[0].second == 0);
+    }
+
+    template <int Which>
+    inline bool one_touching() const
+    {
+        // This is normally a situation which can't occur:
+        // If one is completely left or right, the other cannot touch
+        return one_zero<Which>()
+            && sides[1 - Which].first * sides[1 - Which].second == 1;
+    }
+
+    inline bool meeting() const
+    {
+        // Two of them (in each segment) zero, two not
+        return one_zero<0>() && one_zero<1>();
+    }
+
+    template <int Which>
+    inline bool zero() const
+    {
+        return sides[Which].first == 0 && sides[Which].second == 0;
+    }
+
+    template <int Which>
+    inline bool one_zero() const
+    {
+        return (sides[Which].first == 0 && sides[Which].second != 0)
+            || (sides[Which].first != 0 && sides[Which].second == 0);
+    }
+
+    inline bool one_of_all_zero() const
+    {
+        int const sum = std::abs(sides[0].first)
+                + std::abs(sides[0].second)
+                + std::abs(sides[1].first)
+                + std::abs(sides[1].second);
+        return sum == 3;
+    }
+
+
+    template <int Which>
+    inline int zero_index() const
+    {
+        return sides[Which].first == 0 ? 0 : 1;
+    }
+
+
+    inline void debug() const
+    {
+        std::cout << sides[0].first << " "
+            << sides[0].second << " "
+            << sides[1].first << " "
+            << sides[1].second 
+			<< std::endl;
+    }
+
+
+    inline void reverse()
+    {
+        std::swap(sides[0], sides[1]);
+    }
+
+//private :
+    std::pair<int, int> sides[2];
+
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SIDE_INFO_HPP
diff --git a/src/boost/geometry/strategies/spherical/area_huiller.hpp b/src/boost/geometry/strategies/spherical/area_huiller.hpp
new file mode 100644
index 0000000..1bef9b5
--- /dev/null
+++ b/src/boost/geometry/strategies/spherical/area_huiller.hpp
@@ -0,0 +1,202 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AREA_HUILLER_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AREA_HUILLER_HPP
+
+
+
+#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
+
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace area
+{
+
+
+
+/*!
+\brief Area calculation by spherical excess / Huiller's formula
+\ingroup strategies
+\tparam PointOfSegment point type of segments of rings/polygons
+\tparam CalculationType \tparam_calculation
+\author Barend Gehrels. Adapted from:
+- http://www.soe.ucsc.edu/~pang/160/f98/Gems/GemsIV/sph_poly.c
+- http://williams.best.vwh.net/avform.htm
+\note The version in Gems didn't account for polygons crossing the 180 meridian.
+\note This version works for convex and non-convex polygons, for 180 meridian
+crossing polygons and for polygons with holes. However, some cases (especially
+180 meridian cases) must still be checked.
+\note The version which sums angles, which is often seen, doesn't handle non-convex
+polygons correctly.
+\note The version which sums longitudes, see
+http://trs-new.jpl.nasa.gov/dspace/bitstream/2014/40409/1/07-03.pdf, is simple
+and works well in most cases but not in 180 meridian crossing cases. This probably
+could be solved.
+
+\note This version is made for spherical equatorial coordinate systems
+
+\qbk{
+
+[heading Example]
+[area_with_strategy]
+[area_with_strategy_output]
+
+
+[heading See also]
+[link geometry.reference.algorithms.area.area_2_with_strategy area (with strategy)]
+}
+
+*/
+template
+<
+    typename PointOfSegment,
+    typename CalculationType = void
+>
+class huiller
+{
+typedef typename boost::mpl::if_c
+    <
+        boost::is_void<CalculationType>::type::value,
+        typename select_most_precise
+            <
+                typename coordinate_type<PointOfSegment>::type,
+                double
+            >::type,
+        CalculationType
+    >::type calculation_type;
+
+protected :
+    struct excess_sum
+    {
+        calculation_type sum;
+
+        // Distances are calculated on unit sphere here
+        strategy::distance::haversine<PointOfSegment, PointOfSegment>
+                distance_over_unit_sphere;
+
+
+        inline excess_sum()
+            : sum(0)
+            , distance_over_unit_sphere(1)
+        {}
+        inline calculation_type area(calculation_type radius) const
+        {
+            return - sum * radius * radius;
+        }
+    };
+
+public :
+    typedef calculation_type return_type;
+    typedef PointOfSegment segment_point_type;
+    typedef excess_sum state_type;
+
+    inline huiller(calculation_type radius = 1.0)
+        : m_radius(radius)
+    {}
+
+    inline void apply(PointOfSegment const& p1,
+                PointOfSegment const& p2,
+                excess_sum& state) const
+    {
+        if (! geometry::math::equals(get<0>(p1), get<0>(p2)))
+        {
+            calculation_type const half = 0.5;
+            calculation_type const two = 2.0;
+            calculation_type const four = 4.0;
+            calculation_type const two_pi = two * geometry::math::pi<calculation_type>();
+            calculation_type const half_pi = half * geometry::math::pi<calculation_type>();
+
+            // Distance p1 p2
+            calculation_type a = state.distance_over_unit_sphere.apply(p1, p2);
+
+            // Sides on unit sphere to south pole
+            calculation_type b = half_pi - geometry::get_as_radian<1>(p2);
+            calculation_type c = half_pi - geometry::get_as_radian<1>(p1);
+
+            // Semi parameter
+            calculation_type s = half * (a + b + c);
+
+            // E: spherical excess, using l'Huiller's formula
+            // [tg(e / 4)]2   =   tg[s / 2]  tg[(s-a) / 2]  tg[(s-b) / 2]  tg[(s-c) / 2]
+            calculation_type E = four * atan(sqrt(geometry::math::abs(tan(s / two)
+                    * tan((s - a) / two)
+                    * tan((s - b) / two)
+                    * tan((s - c) / two))));
+
+            E = geometry::math::abs(E);
+
+            // In right direction: positive, add area. In left direction: negative, subtract area.
+            // Longitude comparisons are not so obvious. If one is negative, other is positive,
+            // we have to take the dateline into account.
+            // TODO: check this / enhance this, should be more robust. See also the "grow" for ll
+            // TODO: use minmax or "smaller"/"compare" strategy for this
+            calculation_type lon1 = geometry::get_as_radian<0>(p1) < 0
+                ? geometry::get_as_radian<0>(p1) + two_pi
+                : geometry::get_as_radian<0>(p1);
+
+            calculation_type lon2 = geometry::get_as_radian<0>(p2) < 0
+                ? geometry::get_as_radian<0>(p2) + two_pi
+                : geometry::get_as_radian<0>(p2);
+
+            if (lon2 < lon1)
+            {
+                E = -E;
+            }
+
+            state.sum += E;
+        }
+    }
+
+    inline return_type result(excess_sum const& state) const
+    {
+        return state.area(m_radius);
+    }
+
+private :
+    /// Radius of the sphere
+    calculation_type m_radius;
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+
+
+template <typename Point>
+struct default_strategy<spherical_equatorial_tag, Point>
+{
+    typedef strategy::area::huiller<Point> type;
+};
+
+// Note: spherical polar coordinate system requires "get_as_radian_equatorial"
+/***template <typename Point>
+struct default_strategy<spherical_polar_tag, Point>
+{
+    typedef strategy::area::huiller<Point> type;
+};***/
+
+} // namespace services
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::area
+
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_AREA_HUILLER_HPP
diff --git a/src/boost/geometry/strategies/spherical/compare_circular.hpp b/src/boost/geometry/strategies/spherical/compare_circular.hpp
new file mode 100644
index 0000000..2f890df
--- /dev/null
+++ b/src/boost/geometry/strategies/spherical/compare_circular.hpp
@@ -0,0 +1,152 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_SPHERICAL_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_SPHERICAL_HPP
+
+#include <boost/math/constants/constants.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/strategies/compare.hpp>
+#include <boost/geometry/util/math.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace compare
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Units>
+struct shift
+{
+};
+
+template <>
+struct shift<degree>
+{
+    static inline double full() { return 360.0; }
+    static inline double half() { return 180.0; }
+};
+
+template <>
+struct shift<radian>
+{
+    static inline double full() { return 2.0 * boost::math::constants::pi<double>(); }
+    static inline double half() { return boost::math::constants::pi<double>(); }
+};
+
+} // namespace detail
+#endif
+
+/*!
+\brief Compare (in one direction) strategy for spherical coordinates
+\ingroup strategies
+\tparam Point point-type
+\tparam Dimension dimension
+*/
+template <typename CoordinateType, typename Units, typename Compare>
+struct circular_comparator
+{
+    static inline CoordinateType put_in_range(CoordinateType const& c,
+            double min_border, double max_border)
+    {
+        CoordinateType value = c;
+        while (value < min_border)
+        {
+            value += detail::shift<Units>::full();
+        }
+        while (value > max_border)
+        {
+            value -= detail::shift<Units>::full();
+        }
+        return value;
+    }
+
+    inline bool operator()(CoordinateType const& c1, CoordinateType const& c2)  const
+    {
+        Compare compare;
+
+        // Check situation that one of them is e.g. std::numeric_limits.
+        static const double full = detail::shift<Units>::full();
+        double mx = 10.0 * full;
+        if (c1 < -mx || c1 > mx || c2 < -mx || c2 > mx)
+        {
+            // do normal comparison, using circular is not useful
+            return compare(c1, c2);
+        }
+
+        static const double half = full / 2.0;
+        CoordinateType v1 = put_in_range(c1, -half, half);
+        CoordinateType v2 = put_in_range(c2, -half, half);
+
+        // Two coordinates on a circle are
+        // at max <= half a circle away from each other.
+        // So if it is more, shift origin.
+        CoordinateType diff = geometry::math::abs(v1 - v2);
+        if (diff > half)
+        {
+            v1 = put_in_range(v1, 0, full);
+            v2 = put_in_range(v2, 0, full);
+        }
+
+        return compare(v1, v2);
+    }
+};
+
+}} // namespace strategy::compare
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+// Specialize for the longitude (dim 0)
+template
+<
+    typename Point,
+    template<typename> class CoordinateSystem,
+    typename Units
+>
+struct strategy_compare<spherical_polar_tag, 1, Point, CoordinateSystem<Units>, 0>
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+    typedef strategy::compare::circular_comparator
+        <
+            coordinate_type,
+            Units,
+            std::less<coordinate_type>
+        > type;
+};
+
+template
+<
+    typename Point,
+    template<typename> class CoordinateSystem,
+    typename Units
+>
+struct strategy_compare<spherical_polar_tag, -1, Point, CoordinateSystem<Units>, 0>
+{
+    typedef typename coordinate_type<Point>::type coordinate_type;
+    typedef strategy::compare::circular_comparator
+        <
+            coordinate_type,
+            Units,
+            std::greater<coordinate_type>
+        > type;
+};
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_COMPARE_SPHERICAL_HPP
diff --git a/src/boost/geometry/strategies/spherical/distance_cross_track.hpp b/src/boost/geometry/strategies/spherical/distance_cross_track.hpp
new file mode 100644
index 0000000..ba58922
--- /dev/null
+++ b/src/boost/geometry/strategies/spherical/distance_cross_track.hpp
@@ -0,0 +1,349 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_CROSS_TRACK_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_CROSS_TRACK_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+
+
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/strategies/concepts/distance_concept.hpp>
+
+#include <boost/geometry/util/promote_floating_point.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
+#  include <boost/geometry/io/dsv/write.hpp>
+#endif
+
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace distance
+{
+
+/*!
+\brief Strategy functor for distance point to segment calculation
+\ingroup strategies
+\details Class which calculates the distance of a point to a segment, using latlong points
+\see http://williams.best.vwh.net/avform.htm
+\tparam Point point type
+\tparam PointOfSegment \tparam_segment_point
+\tparam CalculationType \tparam_calculation
+\tparam Strategy underlying point-point distance strategy, defaults to haversine
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
+}
+
+*/
+template
+<
+    typename Point,
+    typename PointOfSegment = Point,
+    typename CalculationType = void,
+    typename Strategy = typename services::default_strategy<point_tag, Point>::type
+>
+class cross_track
+{
+public :
+    typedef typename promote_floating_point
+        <
+            typename select_calculation_type
+                <
+                    Point,
+                    PointOfSegment,
+                    CalculationType
+                >::type
+        >::type return_type;
+
+    inline cross_track()
+    {
+        m_strategy = Strategy();
+        m_radius = m_strategy.radius();
+    }
+
+    inline cross_track(return_type const& r)
+        : m_radius(r)
+        , m_strategy(r)
+    {}
+
+    inline cross_track(Strategy const& s)
+        : m_strategy(s)
+    {
+        m_radius = m_strategy.radius();
+    }
+
+
+    // It might be useful in the future
+    // to overload constructor with strategy info.
+    // crosstrack(...) {}
+
+
+    inline return_type apply(Point const& p,
+                PointOfSegment const& sp1, PointOfSegment const& sp2) const
+    {
+        // http://williams.best.vwh.net/avform.htm#XTE
+        return_type d1 = m_strategy.apply(sp1, p);
+
+        // Actually, calculation of d2 not necessary if we know that the projected point is on the great circle...
+        return_type d2 = m_strategy.apply(sp2, p);
+
+        return_type crs_AD = course(sp1, p);
+        return_type crs_AB = course(sp1, sp2);
+        return_type XTD = m_radius * geometry::math::abs(asin(sin(d1 / m_radius) * sin(crs_AD - crs_AB)));
+
+#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
+std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " " << crs_AD * geometry::math::r2d << std::endl;
+std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " " << crs_AB * geometry::math::r2d << std::endl;
+std::cout << "XTD: " << XTD << " d1: " <<  d1  << " d2: " <<  d2  << std::endl;
+#endif
+
+
+        // Return shortest distance, either to projected point on segment sp1-sp2, or to sp1, or to sp2
+        return return_type((std::min)((std::min)(d1, d2), XTD));
+    }
+
+    inline return_type radius() const { return m_radius; }
+
+private :
+    BOOST_CONCEPT_ASSERT
+        (
+            (geometry::concept::PointDistanceStrategy<Strategy >)
+        );
+
+
+    return_type m_radius;
+
+    // Point-point distances are calculated in radians, on the unit sphere
+    Strategy m_strategy;
+
+    /// Calculate course (bearing) between two points. Might be moved to a "course formula" ...
+    inline return_type course(Point const& p1, Point const& p2) const
+    {
+        // http://williams.best.vwh.net/avform.htm#Crs
+        return_type dlon = get_as_radian<0>(p2) - get_as_radian<0>(p1);
+        return_type cos_p2lat = cos(get_as_radian<1>(p2));
+
+        // "An alternative formula, not requiring the pre-computation of d"
+        return atan2(sin(dlon) * cos_p2lat,
+            cos(get_as_radian<1>(p1)) * sin(get_as_radian<1>(p2))
+            - sin(get_as_radian<1>(p1)) * cos_p2lat * cos(dlon));
+    }
+
+};
+
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct tag<cross_track<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef strategy_tag_distance_point_segment type;
+};
+
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct return_type<cross_track<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef typename cross_track<Point, PointOfSegment, CalculationType, Strategy>::return_type type;
+};
+
+
+template
+<
+    typename Point,
+    typename PointOfSegment,
+    typename CalculationType,
+    typename Strategy,
+    typename P,
+    typename PS
+>
+struct similar_type<cross_track<Point, PointOfSegment, CalculationType, Strategy>, P, PS>
+{
+    typedef cross_track<Point, PointOfSegment, CalculationType, Strategy> type;
+};
+
+
+template
+<
+    typename Point,
+    typename PointOfSegment,
+    typename CalculationType,
+    typename Strategy,
+    typename P,
+    typename PS
+>
+struct get_similar<cross_track<Point, PointOfSegment, CalculationType, Strategy>, P, PS>
+{
+    static inline typename similar_type
+        <
+            cross_track<Point, PointOfSegment, CalculationType, Strategy>, P, PS
+        >::type apply(cross_track<Point, PointOfSegment, CalculationType, Strategy> const& strategy)
+    {
+        return cross_track<P, PS, CalculationType, Strategy>(strategy.radius());
+    }
+};
+
+
+template <typename Point, typename PointOfSegment, typename CalculationType, typename Strategy>
+struct comparable_type<cross_track<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    // Comparable type is here just the strategy
+    typedef typename similar_type
+        <
+            cross_track
+                <
+                    Point, PointOfSegment, CalculationType, Strategy
+                >, Point, PointOfSegment
+        >::type type;
+};
+
+
+template 
+<
+    typename Point, typename PointOfSegment, 
+    typename CalculationType, 
+    typename Strategy
+>
+struct get_comparable<cross_track<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef typename comparable_type
+        <
+            cross_track<Point, PointOfSegment, CalculationType, Strategy>
+        >::type comparable_type;
+public :
+    static inline comparable_type apply(cross_track<Point, PointOfSegment, CalculationType, Strategy> const& strategy)
+    {
+        return comparable_type(strategy.radius());
+    }
+};
+
+
+template 
+<
+    typename Point, typename PointOfSegment, 
+    typename CalculationType, 
+    typename Strategy
+>
+struct result_from_distance<cross_track<Point, PointOfSegment, CalculationType, Strategy> >
+{
+private :
+    typedef typename cross_track<Point, PointOfSegment, CalculationType, Strategy>::return_type return_type;
+public :
+    template <typename T>
+    static inline return_type apply(cross_track<Point, PointOfSegment, CalculationType, Strategy> const& , T const& distance)
+    {
+        return distance;
+    }
+};
+
+
+template 
+<
+    typename Point, typename PointOfSegment, 
+    typename CalculationType, 
+    typename Strategy
+>
+struct strategy_point_point<cross_track<Point, PointOfSegment, CalculationType, Strategy> >
+{
+    typedef Strategy type;
+};
+
+
+
+/*
+
+TODO:  spherical polar coordinate system requires "get_as_radian_equatorial<>"
+
+template <typename Point, typename PointOfSegment, typename Strategy>
+struct default_strategy
+    <
+        segment_tag, Point, PointOfSegment, 
+        spherical_polar_tag, spherical_polar_tag, 
+        Strategy
+    >
+{
+    typedef cross_track
+        <
+            Point,
+            PointOfSegment,
+            void,
+            typename boost::mpl::if_
+                <
+                    boost::is_void<Strategy>,
+                    typename default_strategy
+                        <
+                            point_tag, Point, PointOfSegment,
+                            spherical_polar_tag, spherical_polar_tag
+                        >::type,
+                    Strategy
+                >::type
+        > type;
+};
+*/
+
+template <typename Point, typename PointOfSegment, typename Strategy>
+struct default_strategy
+    <
+        segment_tag, Point, PointOfSegment, 
+        spherical_equatorial_tag, spherical_equatorial_tag, 
+        Strategy
+    >
+{
+    typedef cross_track
+        <
+            Point,
+            PointOfSegment,
+            void,
+            typename boost::mpl::if_
+                <
+                    boost::is_void<Strategy>,
+                    typename default_strategy
+                        <
+                            point_tag, Point, PointOfSegment,
+                            spherical_equatorial_tag, spherical_equatorial_tag
+                        >::type,
+                    Strategy
+                >::type
+        > type;
+};
+
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_CROSS_TRACK_HPP
diff --git a/src/boost/geometry/strategies/spherical/distance_haversine.hpp b/src/boost/geometry/strategies/spherical/distance_haversine.hpp
new file mode 100644
index 0000000..59ec1c3
--- /dev/null
+++ b/src/boost/geometry/strategies/spherical/distance_haversine.hpp
@@ -0,0 +1,330 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_HAVERSINE_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_HAVERSINE_HPP
+
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+
+#include <boost/geometry/util/select_calculation_type.hpp>
+#include <boost/geometry/util/promote_floating_point.hpp>
+
+#include <boost/geometry/strategies/distance.hpp>
+
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace distance
+{
+
+
+namespace comparable
+{
+
+// Comparable haversine.
+// To compare distances, we can avoid:
+// - multiplication with radius and 2.0
+// - applying sqrt
+// - applying asin (which is strictly (monotone) increasing)
+template
+<
+    typename Point1,
+    typename Point2 = Point1,
+    typename CalculationType = void
+>
+class haversine
+{
+public :
+    typedef typename promote_floating_point
+        <
+            typename select_calculation_type
+                <
+                    Point1,
+                    Point2,
+                    CalculationType
+                >::type
+        >::type calculation_type;
+
+    inline haversine(calculation_type const& r = 1.0)
+        : m_radius(r)
+    {}
+
+
+    static inline calculation_type apply(Point1 const& p1, Point2 const& p2)
+    {
+        return calculate(get_as_radian<0>(p1), get_as_radian<1>(p1),
+                        get_as_radian<0>(p2), get_as_radian<1>(p2));
+    }
+
+    inline calculation_type radius() const
+    {
+        return m_radius;
+    }
+
+
+private :
+
+    static inline calculation_type calculate(calculation_type const& lon1,
+            calculation_type const& lat1,
+            calculation_type const& lon2,
+            calculation_type const& lat2)
+    {
+        return math::hav(lat2 - lat1)
+                + cos(lat1) * cos(lat2) * math::hav(lon2 - lon1);
+    }
+
+    calculation_type m_radius;
+};
+
+
+
+} // namespace comparable
+
+/*!
+\brief Distance calculation for spherical coordinates
+on a perfect sphere using haversine
+\ingroup strategies
+\tparam Point1 \tparam_first_point
+\tparam Point2 \tparam_second_point
+\tparam CalculationType \tparam_calculation
+\author Adapted from: http://williams.best.vwh.net/avform.htm
+\see http://en.wikipedia.org/wiki/Great-circle_distance
+\note It says: <em>The great circle distance d between two
+points with coordinates {lat1,lon1} and {lat2,lon2} is given by:
+    d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
+A mathematically equivalent formula, which is less subject
+    to rounding error for short distances is:
+    d=2*asin(sqrt((sin((lat1-lat2)/2))^2
+    + cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
+    </em>
+
+\qbk{
+[heading See also]
+[link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
+}
+
+*/
+template
+<
+    typename Point1,
+    typename Point2 = Point1,
+    typename CalculationType = void
+>
+class haversine
+{
+    typedef comparable::haversine<Point1, Point2, CalculationType> comparable_type;
+
+public :
+
+    typedef typename services::return_type<comparable_type>::type calculation_type;
+
+    /*!
+    \brief Constructor
+    \param radius radius of the sphere, defaults to 1.0 for the unit sphere
+    */
+    inline haversine(calculation_type const& radius = 1.0)
+        : m_radius(radius)
+    {}
+
+    /*!
+    \brief applies the distance calculation
+    \return the calculated distance (including multiplying with radius)
+    \param p1 first point
+    \param p2 second point
+    */
+    inline calculation_type apply(Point1 const& p1, Point2 const& p2) const
+    {
+        calculation_type const a = comparable_type::apply(p1, p2);
+        calculation_type const c = calculation_type(2.0) * asin(sqrt(a));
+        return m_radius * c;
+    }
+
+    /*!
+    \brief access to radius value
+    \return the radius
+    */
+    inline calculation_type radius() const
+    {
+        return m_radius;
+    }
+
+private :
+    calculation_type m_radius;
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct tag<haversine<Point1, Point2, CalculationType> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct return_type<haversine<Point1, Point2, CalculationType> >
+{
+    typedef typename haversine<Point1, Point2, CalculationType>::calculation_type type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType, typename P1, typename P2>
+struct similar_type<haversine<Point1, Point2, CalculationType>, P1, P2>
+{
+    typedef haversine<P1, P2, CalculationType> type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType, typename P1, typename P2>
+struct get_similar<haversine<Point1, Point2, CalculationType>, P1, P2>
+{
+private :
+    typedef haversine<Point1, Point2, CalculationType> this_type;
+public :
+    static inline typename similar_type<this_type, P1, P2>::type apply(this_type const& input)
+    {
+        return haversine<P1, P2, CalculationType>(input.radius());
+    }
+};
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct comparable_type<haversine<Point1, Point2, CalculationType> >
+{
+    typedef comparable::haversine<Point1, Point2, CalculationType> type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct get_comparable<haversine<Point1, Point2, CalculationType> >
+{
+private :
+    typedef haversine<Point1, Point2, CalculationType> this_type;
+    typedef comparable::haversine<Point1, Point2, CalculationType> comparable_type;
+public :
+    static inline comparable_type apply(this_type const& input)
+    {
+        return comparable_type(input.radius());
+    }
+};
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct result_from_distance<haversine<Point1, Point2, CalculationType> >
+{
+private :
+    typedef haversine<Point1, Point2, CalculationType> this_type;
+    typedef typename return_type<this_type>::type return_type;
+public :
+    template <typename T>
+    static inline return_type apply(this_type const& , T const& value)
+    {
+        return return_type(value);
+    }
+};
+
+
+// Specializations for comparable::haversine
+template <typename Point1, typename Point2, typename CalculationType>
+struct tag<comparable::haversine<Point1, Point2, CalculationType> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct return_type<comparable::haversine<Point1, Point2, CalculationType> >
+{
+    typedef typename comparable::haversine<Point1, Point2, CalculationType>::calculation_type type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType, typename P1, typename P2>
+struct similar_type<comparable::haversine<Point1, Point2, CalculationType>, P1, P2>
+{
+    typedef comparable::haversine<P1, P2, CalculationType> type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType, typename P1, typename P2>
+struct get_similar<comparable::haversine<Point1, Point2, CalculationType>, P1, P2>
+{
+private :
+    typedef comparable::haversine<Point1, Point2, CalculationType> this_type;
+public :
+    static inline typename similar_type<this_type, P1, P2>::type apply(this_type const& input)
+    {
+        return comparable::haversine<P1, P2, CalculationType>(input.radius());
+    }
+};
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct comparable_type<comparable::haversine<Point1, Point2, CalculationType> >
+{
+    typedef comparable::haversine<Point1, Point2, CalculationType> type;
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct get_comparable<comparable::haversine<Point1, Point2, CalculationType> >
+{
+private :
+    typedef comparable::haversine<Point1, Point2, CalculationType> this_type;
+public :
+    static inline this_type apply(this_type const& input)
+    {
+        return input;
+    }
+};
+
+
+template <typename Point1, typename Point2, typename CalculationType>
+struct result_from_distance<comparable::haversine<Point1, Point2, CalculationType> >
+{
+private :
+    typedef comparable::haversine<Point1, Point2, CalculationType> strategy_type;
+    typedef typename return_type<strategy_type>::type return_type;
+public :
+    template <typename T>
+    static inline return_type apply(strategy_type const& strategy, T const& distance)
+    {
+        return_type const s = sin((distance / strategy.radius()) / return_type(2));
+        return s * s;
+    }
+};
+
+
+// Register it as the default for point-types 
+// in a spherical equatorial coordinate system
+template <typename Point1, typename Point2>
+struct default_strategy<point_tag, Point1, Point2, spherical_equatorial_tag, spherical_equatorial_tag>
+{
+    typedef strategy::distance::haversine<Point1, Point2> type;
+};
+
+// Note: spherical polar coordinate system requires "get_as_radian_equatorial"
+
+
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISTANCE_HAVERSINE_HPP
diff --git a/src/boost/geometry/strategies/spherical/side_by_cross_track.hpp b/src/boost/geometry/strategies/spherical/side_by_cross_track.hpp
new file mode 100644
index 0000000..b7cf279
--- /dev/null
+++ b/src/boost/geometry/strategies/spherical/side_by_cross_track.hpp
@@ -0,0 +1,100 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/strategies/side.hpp>
+//#include <boost/geometry/strategies/concepts/side_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace side
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+/// Calculate course (bearing) between two points. Might be moved to a "course formula" ...
+template <typename Point>
+static inline double course(Point const& p1, Point const& p2)
+{
+    // http://williams.best.vwh.net/avform.htm#Crs
+    double dlon = get_as_radian<0>(p2) - get_as_radian<0>(p1);
+    double cos_p2lat = cos(get_as_radian<1>(p2));
+
+    // "An alternative formula, not requiring the pre-computation of d"
+    return atan2(sin(dlon) * cos_p2lat,
+        cos(get_as_radian<1>(p1)) * sin(get_as_radian<1>(p2))
+        - sin(get_as_radian<1>(p1)) * cos_p2lat * cos(dlon));
+}
+
+}
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+/*!
+\brief Check at which side of a Great Circle segment a point lies
+         left of segment (> 0), right of segment (< 0), on segment (0)
+\ingroup strategies
+\tparam CalculationType \tparam_calculation
+ */
+template <typename CalculationType = void>
+class side_by_cross_track
+{
+
+public :
+    template <typename P1, typename P2, typename P>
+    static inline int apply(P1 const& p1, P2 const& p2, P const& p)
+    {
+        typedef typename boost::mpl::if_c
+            <
+                boost::is_void<CalculationType>::type::value,
+                typename select_most_precise
+                    <
+                        typename select_most_precise
+                            <
+                                typename coordinate_type<P1>::type,
+                                typename coordinate_type<P2>::type
+                            >::type,
+                        typename coordinate_type<P>::type
+                    >::type,
+                CalculationType
+            >::type coordinate_type;
+
+        double d1 = 0.001; // m_strategy.apply(sp1, p);
+        double crs_AD = detail::course(p1, p);
+        double crs_AB = detail::course(p1, p2);
+        double XTD = asin(sin(d1) * sin(crs_AD - crs_AB));
+
+        return math::equals(XTD, 0) ? 0 : XTD < 0 ? 1 : -1;
+    }
+};
+
+}} // namespace strategy::side
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SIDE_BY_CROSS_TRACK_HPP
diff --git a/src/boost/geometry/strategies/spherical/ssf.hpp b/src/boost/geometry/strategies/spherical/ssf.hpp
new file mode 100644
index 0000000..ab7c675
--- /dev/null
+++ b/src/boost/geometry/strategies/spherical/ssf.hpp
@@ -0,0 +1,136 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SSF_HPP
+#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SSF_HPP
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/util/math.hpp>
+
+#include <boost/geometry/strategies/side.hpp>
+//#include <boost/geometry/strategies/concepts/side_concept.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace strategy { namespace side
+{
+
+
+/*!
+\brief Check at which side of a Great Circle segment a point lies
+         left of segment (> 0), right of segment (< 0), on segment (0)
+\ingroup strategies
+\tparam CalculationType \tparam_calculation
+ */
+template <typename CalculationType = void>
+class spherical_side_formula
+{
+
+public :
+    template <typename P1, typename P2, typename P>
+    static inline int apply(P1 const& p1, P2 const& p2, P const& p)
+    {
+        typedef typename boost::mpl::if_c
+            <
+                boost::is_void<CalculationType>::type::value,
+
+                // Select at least a double...
+                typename select_most_precise
+                    <
+                        typename select_most_precise
+                            <
+                                typename select_most_precise
+                                    <
+                                        typename coordinate_type<P1>::type,
+                                        typename coordinate_type<P2>::type
+                                    >::type,
+                                typename coordinate_type<P>::type
+                            >::type,
+                        double
+                    >::type,
+                CalculationType
+            >::type coordinate_type;
+
+        // Convenient shortcuts
+        typedef coordinate_type ct;
+        ct const lambda1 = get_as_radian<0>(p1);
+        ct const delta1 = get_as_radian<1>(p1);
+        ct const lambda2 = get_as_radian<0>(p2);
+        ct const delta2 = get_as_radian<1>(p2);
+        ct const lambda = get_as_radian<0>(p);
+        ct const delta = get_as_radian<1>(p);
+
+        // Create temporary points (vectors) on unit a sphere
+        ct const cos_delta1 = cos(delta1);
+        ct const c1x = cos_delta1 * cos(lambda1);
+        ct const c1y = cos_delta1 * sin(lambda1);
+        ct const c1z = sin(delta1);
+
+        ct const cos_delta2 = cos(delta2);
+        ct const c2x = cos_delta2 * cos(lambda2);
+        ct const c2y = cos_delta2 * sin(lambda2);
+        ct const c2z = sin(delta2);
+
+        // (Third point is converted directly)
+        ct const cos_delta = cos(delta);
+        
+        // Apply the "Spherical Side Formula" as presented on my blog
+        ct const dist 
+            = (c1y * c2z - c1z * c2y) * cos_delta * cos(lambda) 
+            + (c1z * c2x - c1x * c2z) * cos_delta * sin(lambda)
+            + (c1x * c2y - c1y * c2x) * sin(delta);
+        
+        ct zero = ct();
+        return dist > zero ? 1
+            : dist < zero ? -1
+            : 0;
+    }
+};
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace services
+{
+
+/*template <typename CalculationType>
+struct default_strategy<spherical_polar_tag, CalculationType>
+{
+    typedef spherical_side_formula<CalculationType> type;
+};*/
+
+template <typename CalculationType>
+struct default_strategy<spherical_equatorial_tag, CalculationType>
+{
+    typedef spherical_side_formula<CalculationType> type;
+};
+
+template <typename CalculationType>
+struct default_strategy<geographic_tag, CalculationType>
+{
+    typedef spherical_side_formula<CalculationType> type;
+};
+
+}
+#endif
+
+}} // namespace strategy::side
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_SSF_HPP
diff --git a/src/boost/geometry/strategies/strategies.hpp b/src/boost/geometry/strategies/strategies.hpp
new file mode 100644
index 0000000..3aa9ab0
--- /dev/null
+++ b/src/boost/geometry/strategies/strategies.hpp
@@ -0,0 +1,59 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_STRATEGIES_HPP
+#define BOOST_GEOMETRY_STRATEGIES_STRATEGIES_HPP
+
+
+#include <boost/geometry/strategies/tags.hpp>
+
+#include <boost/geometry/strategies/area.hpp>
+#include <boost/geometry/strategies/centroid.hpp>
+#include <boost/geometry/strategies/compare.hpp>
+#include <boost/geometry/strategies/convex_hull.hpp>
+#include <boost/geometry/strategies/distance.hpp>
+#include <boost/geometry/strategies/intersection.hpp>
+#include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/strategies/transform.hpp>
+#include <boost/geometry/strategies/within.hpp>
+
+#include <boost/geometry/strategies/cartesian/area_surveyor.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp>
+#include <boost/geometry/strategies/cartesian/centroid_weighted_length.hpp>
+#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
+#include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp>
+#include <boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp>
+#include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
+
+#include <boost/geometry/strategies/spherical/area_huiller.hpp>
+#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
+#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
+#include <boost/geometry/strategies/spherical/compare_circular.hpp>
+#include <boost/geometry/strategies/spherical/ssf.hpp>
+
+#include <boost/geometry/strategies/agnostic/hull_graham_andrew.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
+#include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp>
+
+#include <boost/geometry/strategies/strategy_transform.hpp>
+
+#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
+#include <boost/geometry/strategies/transform/map_transformer.hpp>
+#include <boost/geometry/strategies/transform/inverse_transformer.hpp>
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_STRATEGIES_HPP
diff --git a/src/boost/geometry/strategies/strategy_transform.hpp b/src/boost/geometry/strategies/strategy_transform.hpp
new file mode 100644
index 0000000..61a408c
--- /dev/null
+++ b/src/boost/geometry/strategies/strategy_transform.hpp
@@ -0,0 +1,504 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_STRATEGY_TRANSFORM_HPP
+#define BOOST_GEOMETRY_STRATEGIES_STRATEGY_TRANSFORM_HPP
+
+#include <cstddef>
+#include <cmath>
+#include <functional>
+
+#include <boost/numeric/conversion/cast.hpp>
+
+#include <boost/geometry/algorithms/convert.hpp>
+#include <boost/geometry/arithmetic/arithmetic.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/radian_access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/strategies/transform.hpp>
+
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace transform
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template
+<
+    typename Src, typename Dst,
+    std::size_t D, std::size_t N,
+    template <typename> class F
+>
+struct transform_coordinates
+{
+    template <typename T>
+    static inline void transform(Src const& source, Dst& dest, T value)
+    {
+        typedef typename select_coordinate_type<Src, Dst>::type coordinate_type;
+
+        F<coordinate_type> function;
+        set<D>(dest, boost::numeric_cast<coordinate_type>(function(get<D>(source), value)));
+        transform_coordinates<Src, Dst, D + 1, N, F>::transform(source, dest, value);
+    }
+};
+
+template
+<
+    typename Src, typename Dst,
+    std::size_t N,
+    template <typename> class F
+>
+struct transform_coordinates<Src, Dst, N, N, F>
+{
+    template <typename T>
+    static inline void transform(Src const& , Dst& , T )
+    {
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+    \brief Transformation strategy to copy one point to another using assignment operator
+    \ingroup transform
+    \tparam P point type
+ */
+template <typename P>
+struct copy_direct
+{
+    inline bool apply(P const& p1, P& p2) const
+    {
+        p2 = p1;
+        return true;
+    }
+};
+
+/*!
+    \brief Transformation strategy to do copy a point, copying per coordinate.
+    \ingroup transform
+    \tparam P1 first point type
+    \tparam P2 second point type
+ */
+template <typename P1, typename P2>
+struct copy_per_coordinate
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        // Defensive check, dimensions are equal, selected by specialization
+        assert_dimension_equal<P1, P2>();
+
+        geometry::convert(p1, p2);
+        return true;
+    }
+};
+
+
+/*!
+    \brief Transformation strategy to go from degree to radian and back
+    \ingroup transform
+    \tparam P1 first point type
+    \tparam P2 second point type
+    \tparam F additional functor to divide or multiply with d2r
+ */
+template <typename P1, typename P2, template <typename> class F>
+struct degree_radian_vv
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        // Spherical coordinates always have 2 coordinates measured in angles
+        // The optional third one is distance/height, provided in another strategy
+        // Polar coordinates having one angle, will be also in another strategy
+        assert_dimension<P1, 2>();
+        assert_dimension<P2, 2>();
+
+        detail::transform_coordinates<P1, P2, 0, 2, F>::transform(p1, p2, math::d2r);
+        return true;
+    }
+};
+
+template <typename P1, typename P2, template <typename> class F>
+struct degree_radian_vv_3
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 3>();
+        assert_dimension<P2, 3>();
+
+        detail::transform_coordinates<P1, P2, 0, 2, F>::transform(p1, p2, math::d2r);
+        // Copy height or other third dimension
+        set<2>(p2, get<2>(p1));
+        return true;
+    }
+};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+    /// Helper function for conversion, phi/theta are in radians
+    template <typename P, typename T, typename R>
+    inline void spherical_polar_to_cartesian(T phi, T theta, R r, P& p)
+    {
+        assert_dimension<P, 3>();
+
+        // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_spherical_coordinates
+        // http://www.vias.org/comp_geometry/math_coord_convert_3d.htm
+        // https://moodle.polymtl.ca/file.php/1183/Autres_Documents/Derivation_for_Spherical_Co-ordinates.pdf
+        // http://en.citizendium.org/wiki/Spherical_polar_coordinates
+        
+        // Phi = first, theta is second, r is third, see documentation on cs::spherical
+
+        // (calculations are splitted to implement ttmath)
+
+        T r_sin_theta = r;
+        T r_cos_theta = r;
+        r_sin_theta *= sin(theta);
+        r_cos_theta *= cos(theta);
+
+        set<0>(p, r_sin_theta * cos(phi));
+        set<1>(p, r_sin_theta * sin(phi));
+        set<2>(p, r_cos_theta);
+    }
+    
+    /// Helper function for conversion, lambda/delta (lon lat) are in radians
+    template <typename P, typename T, typename R>
+    inline void spherical_equatorial_to_cartesian(T lambda, T delta, R r, P& p)
+    {
+        assert_dimension<P, 3>();
+
+        // http://mathworld.wolfram.com/GreatCircle.html
+        // http://www.spenvis.oma.be/help/background/coortran/coortran.html WRONG
+        
+        T r_cos_delta = r;
+        T r_sin_delta = r;
+        r_cos_delta *= cos(delta);
+        r_sin_delta *= sin(delta);
+
+        set<0>(p, r_cos_delta * cos(lambda));
+        set<1>(p, r_cos_delta * sin(lambda));
+        set<2>(p, r_sin_delta);
+    }
+    
+
+    /// Helper function for conversion
+    template <typename P, typename T>
+    inline bool cartesian_to_spherical2(T x, T y, T z, P& p)
+    {
+        assert_dimension<P, 2>();
+
+        // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates
+
+#if defined(BOOST_GEOMETRY_TRANSFORM_CHECK_UNIT_SPHERE)
+        // TODO: MAYBE ONLY IF TO BE CHECKED?
+        T const r = /*sqrt not necessary, sqrt(1)=1*/ (x * x + y * y + z * z);
+
+        // Unit sphere, so r should be 1
+        if (geometry::math::abs(r - 1.0) > T(1e-6))
+        {
+            return false;
+        }
+        // end todo
+#endif
+
+        set_from_radian<0>(p, atan2(y, x));
+        set_from_radian<1>(p, acos(z));
+        return true;
+    }
+    
+    template <typename P, typename T>
+    inline bool cartesian_to_spherical_equatorial2(T x, T y, T z, P& p)
+    {
+        assert_dimension<P, 2>();
+
+        set_from_radian<0>(p, atan2(y, x));
+        set_from_radian<1>(p, asin(z));
+        return true;
+    }
+    
+
+    template <typename P, typename T>
+    inline bool cartesian_to_spherical3(T x, T y, T z, P& p)
+    {
+        assert_dimension<P, 3>();
+
+        // http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates
+        T const r = sqrt(x * x + y * y + z * z);
+        set<2>(p, r);
+        set_from_radian<0>(p, atan2(y, x));
+        if (r > 0.0)
+        {
+            set_from_radian<1>(p, acos(z / r));
+            return true;
+        }
+        return false;
+    }
+
+	template <typename P, typename T>
+	inline bool cartesian_to_spherical_equatorial3(T x, T y, T z, P& p)
+	{
+		assert_dimension<P, 3>();
+
+		// http://en.wikipedia.org/wiki/List_of_canonical_coordinate_transformations#From_Cartesian_coordinates
+		T const r = sqrt(x * x + y * y + z * z);
+		set<2>(p, r);
+		set_from_radian<0>(p, atan2(y, x));
+		if (r > 0.0)
+		{
+			set_from_radian<1>(p, asin(z / r));
+			return true;
+		}
+		return false;
+	}
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+    \brief Transformation strategy for 2D spherical (phi,theta) to 3D cartesian (x,y,z)
+    \details on Unit sphere
+    \ingroup transform
+    \tparam P1 first point type
+    \tparam P2 second point type
+ */
+template <typename P1, typename P2>
+struct from_spherical_polar_2_to_cartesian_3
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 2>();
+        detail::spherical_polar_to_cartesian(get_as_radian<0>(p1), get_as_radian<1>(p1), 1.0, p2);
+        return true;
+    }
+};
+
+template <typename P1, typename P2>
+struct from_spherical_equatorial_2_to_cartesian_3
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 2>();
+        detail::spherical_equatorial_to_cartesian(get_as_radian<0>(p1), get_as_radian<1>(p1), 1.0, p2);
+        return true;
+    }
+};
+
+
+/*!
+    \brief Transformation strategy for 3D spherical (phi,theta,r) to 3D cartesian (x,y,z)
+    \ingroup transform
+    \tparam P1 first point type
+    \tparam P2 second point type
+ */
+template <typename P1, typename P2>
+struct from_spherical_polar_3_to_cartesian_3
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 3>();
+        detail::spherical_polar_to_cartesian(
+                    get_as_radian<0>(p1), get_as_radian<1>(p1), get<2>(p1), p2);
+        return true;
+    }
+};
+
+template <typename P1, typename P2>
+struct from_spherical_equatorial_3_to_cartesian_3
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 3>();
+        detail::spherical_equatorial_to_cartesian(
+                    get_as_radian<0>(p1), get_as_radian<1>(p1), get<2>(p1), p2);
+        return true;
+    }
+};
+
+
+/*!
+    \brief Transformation strategy for 3D cartesian (x,y,z) to 2D spherical (phi,theta)
+    \details on Unit sphere
+    \ingroup transform
+    \tparam P1 first point type
+    \tparam P2 second point type
+    \note If x,y,z point is not lying on unit sphere, transformation will return false
+ */
+template <typename P1, typename P2>
+struct from_cartesian_3_to_spherical_polar_2
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 3>();
+        return detail::cartesian_to_spherical2(get<0>(p1), get<1>(p1), get<2>(p1), p2);
+    }
+};
+
+template <typename P1, typename P2>
+struct from_cartesian_3_to_spherical_equatorial_2
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 3>();
+        return detail::cartesian_to_spherical_equatorial2(get<0>(p1), get<1>(p1), get<2>(p1), p2);
+    }
+};
+
+
+/*!
+    \brief Transformation strategy for 3D cartesian (x,y,z) to 3D spherical (phi,theta,r)
+    \ingroup transform
+    \tparam P1 first point type
+    \tparam P2 second point type
+ */
+template <typename P1, typename P2>
+struct from_cartesian_3_to_spherical_polar_3
+{
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension<P1, 3>();
+        return detail::cartesian_to_spherical3(get<0>(p1), get<1>(p1), get<2>(p1), p2);
+    }
+};
+
+template <typename P1, typename P2>
+struct from_cartesian_3_to_spherical_equatorial_3
+{
+	inline bool apply(P1 const& p1, P2& p2) const
+	{
+		assert_dimension<P1, 3>();
+		return detail::cartesian_to_spherical_equatorial3(get<0>(p1), get<1>(p1), get<2>(p1), p2);
+	}
+};
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+namespace services
+{
+
+/// Specialization for same coordinate system family, same system, same dimension, same point type, can be copied
+template <typename CoordSysTag, typename CoordSys, std::size_t D, typename P>
+struct default_strategy<CoordSysTag, CoordSysTag, CoordSys, CoordSys, D, D, P, P>
+{
+    typedef copy_direct<P> type;
+};
+
+/// Specialization for same coordinate system family and system, same dimension, different point type, copy per coordinate
+template <typename CoordSysTag, typename CoordSys, std::size_t D, typename P1, typename P2>
+struct default_strategy<CoordSysTag, CoordSysTag, CoordSys, CoordSys, D, D, P1, P2>
+{
+    typedef copy_per_coordinate<P1, P2> type;
+};
+
+/// Specialization to transform from degree to radian for any coordinate system / point type combination
+template <typename CoordSysTag, template<typename> class CoordSys, typename P1, typename P2>
+struct default_strategy<CoordSysTag, CoordSysTag, CoordSys<degree>, CoordSys<radian>, 2, 2, P1, P2>
+{
+    typedef degree_radian_vv<P1, P2, std::multiplies> type;
+};
+
+/// Specialization to transform from radian to degree for any coordinate system / point type combination
+template <typename CoordSysTag, template<typename> class CoordSys, typename P1, typename P2>
+struct default_strategy<CoordSysTag, CoordSysTag, CoordSys<radian>, CoordSys<degree>, 2, 2, P1, P2>
+{
+    typedef degree_radian_vv<P1, P2, std::divides> type;
+};
+
+
+/// Specialization degree->radian in 3D
+template <typename CoordSysTag, template<typename> class CoordSys, typename P1, typename P2>
+struct default_strategy<CoordSysTag, CoordSysTag, CoordSys<degree>, CoordSys<radian>, 3, 3, P1, P2>
+{
+    typedef degree_radian_vv_3<P1, P2, std::multiplies> type;
+};
+
+/// Specialization radian->degree in 3D
+template <typename CoordSysTag, template<typename> class CoordSys, typename P1, typename P2>
+struct default_strategy<CoordSysTag, CoordSysTag, CoordSys<radian>, CoordSys<degree>, 3, 3, P1, P2>
+{
+    typedef degree_radian_vv_3<P1, P2, std::divides> type;
+};
+
+/// Specialization to transform from unit sphere(phi,theta) to XYZ
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<spherical_polar_tag, cartesian_tag, CoordSys1, CoordSys2, 2, 3, P1, P2>
+{
+    typedef from_spherical_polar_2_to_cartesian_3<P1, P2> type;
+};
+
+/// Specialization to transform from sphere(phi,theta,r) to XYZ
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<spherical_polar_tag, cartesian_tag, CoordSys1, CoordSys2, 3, 3, P1, P2>
+{
+    typedef from_spherical_polar_3_to_cartesian_3<P1, P2> type;
+};
+
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<spherical_equatorial_tag, cartesian_tag, CoordSys1, CoordSys2, 2, 3, P1, P2>
+{
+    typedef from_spherical_equatorial_2_to_cartesian_3<P1, P2> type;
+};
+
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<spherical_equatorial_tag, cartesian_tag, CoordSys1, CoordSys2, 3, 3, P1, P2>
+{
+    typedef from_spherical_equatorial_3_to_cartesian_3<P1, P2> type;
+};
+
+/// Specialization to transform from XYZ to unit sphere(phi,theta)
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<cartesian_tag, spherical_polar_tag, CoordSys1, CoordSys2, 3, 2, P1, P2>
+{
+    typedef from_cartesian_3_to_spherical_polar_2<P1, P2> type;
+};
+
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<cartesian_tag, spherical_equatorial_tag, CoordSys1, CoordSys2, 3, 2, P1, P2>
+{
+    typedef from_cartesian_3_to_spherical_equatorial_2<P1, P2> type;
+};
+
+/// Specialization to transform from XYZ to sphere(phi,theta,r)
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<cartesian_tag, spherical_polar_tag, CoordSys1, CoordSys2, 3, 3, P1, P2>
+{
+    typedef from_cartesian_3_to_spherical_polar_3<P1, P2> type;
+};
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<cartesian_tag, spherical_equatorial_tag, CoordSys1, CoordSys2, 3, 3, P1, P2>
+{
+	typedef from_cartesian_3_to_spherical_equatorial_3<P1, P2> type;
+};
+
+
+} // namespace services
+
+
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::transform
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_STRATEGY_TRANSFORM_HPP
diff --git a/src/boost/geometry/strategies/tags.hpp b/src/boost/geometry/strategies/tags.hpp
new file mode 100644
index 0000000..39f2f23
--- /dev/null
+++ b/src/boost/geometry/strategies/tags.hpp
@@ -0,0 +1,41 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_TAGS_HPP
+#define BOOST_GEOMETRY_STRATEGIES_TAGS_HPP
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy
+{
+    /*!
+        \brief Indicate compiler/library user that strategy is not implemented.
+        \details Strategies are defined for point types or for point type
+        combinations. If there is no implementation for that specific point type, or point type
+        combination, the calculation cannot be done. To indicate this, this not_implemented
+        class is used as a typedef stub.
+
+    */
+    struct not_implemented {};
+}
+
+
+struct strategy_tag_distance_point_point {};
+struct strategy_tag_distance_point_segment {};
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_TAGS_HPP
diff --git a/src/boost/geometry/strategies/transform.hpp b/src/boost/geometry/strategies/transform.hpp
new file mode 100644
index 0000000..3c806ac
--- /dev/null
+++ b/src/boost/geometry/strategies/transform.hpp
@@ -0,0 +1,63 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_TRANSFORM_HPP
+#define BOOST_GEOMETRY_STRATEGIES_TRANSFORM_HPP
+
+#include <cstddef>
+
+#include <boost/mpl/assert.hpp>
+
+#include <boost/geometry/strategies/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace transform { namespace services
+{
+
+/*!
+    \brief Traits class binding a transformation strategy to a coordinate system
+    \ingroup transform
+    \details Can be specialized
+    - per coordinate system family (tag)
+    - per coordinate system (or groups of them)
+    - per dimension
+    - per point type
+    \tparam CoordinateSystemTag 1,2 coordinate system tags
+    \tparam CoordinateSystem 1,2 coordinate system
+    \tparam D 1, 2 dimension
+    \tparam Point 1, 2 point type
+ */
+template
+<
+    typename CoordinateSystemTag1, typename CoordinateSystemTag2,
+    typename CoordinateSystem1, typename CoordinateSystem2,
+    std::size_t Dimension1, std::size_t Dimension2,
+    typename Point1, typename Point2
+>
+struct default_strategy
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPES
+            , (types<Point1, Point2>)
+        );
+};
+
+}}} // namespace strategy::transform::services
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_TRANSFORM_HPP
diff --git a/src/boost/geometry/strategies/transform/inverse_transformer.hpp b/src/boost/geometry/strategies/transform/inverse_transformer.hpp
new file mode 100644
index 0000000..845a71d
--- /dev/null
+++ b/src/boost/geometry/strategies/transform/inverse_transformer.hpp
@@ -0,0 +1,78 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_TRANSFORM_INVERSE_TRANSFORMER_HPP
+#define BOOST_GEOMETRY_STRATEGIES_TRANSFORM_INVERSE_TRANSFORMER_HPP
+
+// Remove the ublas checking, otherwise the inverse might fail
+// (while nothing seems to be wrong)
+#define BOOST_UBLAS_TYPE_CHECK 0
+
+#include <boost/numeric/ublas/lu.hpp>
+#include <boost/numeric/ublas/io.hpp>
+
+#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace transform
+{
+
+/*!
+\brief Transformation strategy to do an inverse ransformation in Cartesian system
+\ingroup strategies
+\tparam P1 first point type
+\tparam P2 second point type
+ */
+template <typename P1, typename P2>
+class inverse_transformer
+    : public ublas_transformer<P1, P2, dimension<P1>::type::value, dimension<P2>::type::value>
+{
+    typedef typename select_coordinate_type<P1, P2>::type T;
+
+public :
+    template <typename Transformer>
+    inline inverse_transformer(Transformer const& input)
+    {
+        typedef boost::numeric::ublas::matrix<T> matrix_type;
+
+        // create a working copy of the input
+        matrix_type copy(input.matrix());
+
+        // create a permutation matrix for the LU-factorization
+        typedef boost::numeric::ublas::permutation_matrix<> permutation_matrix;
+        permutation_matrix pm(copy.size1());
+
+        // perform LU-factorization
+        int res = boost::numeric::ublas::lu_factorize<matrix_type>(copy, pm);
+        if( res == 0 )
+        {
+            // create identity matrix
+            this->m_matrix.assign(boost::numeric::ublas::identity_matrix<T>(copy.size1()));
+
+            // backsubstitute to get the inverse
+            boost::numeric::ublas::lu_substitute(copy, pm, this->m_matrix);
+        }
+    }
+
+};
+
+
+}} // namespace strategy::transform
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_STRATEGIES_TRANSFORM_INVERSE_TRANSFORMER_HPP
diff --git a/src/boost/geometry/strategies/transform/map_transformer.hpp b/src/boost/geometry/strategies/transform/map_transformer.hpp
new file mode 100644
index 0000000..150ff1d
--- /dev/null
+++ b/src/boost/geometry/strategies/transform/map_transformer.hpp
@@ -0,0 +1,165 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_TRANSFORM_MAP_TRANSFORMER_HPP
+#define BOOST_GEOMETRY_STRATEGIES_TRANSFORM_MAP_TRANSFORMER_HPP
+
+
+#include <cstddef>
+
+#include <boost/geometry/strategies/transform/matrix_transformers.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace transform
+{
+
+/*!
+\brief Transformation strategy to do map from one to another Cartesian system
+\ingroup strategies
+\tparam P1 first point type
+\tparam P2 second point type
+\tparam Mirror if true map is mirrored upside-down (in most cases pixels
+    are from top to bottom, while map is from bottom to top)
+ */
+template
+<
+    typename P1, typename P2,
+    bool Mirror = false, bool SameScale = true,
+    std::size_t Dimension1 = dimension<P1>::type::value,
+    std::size_t Dimension2 = dimension<P2>::type::value
+>
+class map_transformer
+    : public ublas_transformer<P1, P2, Dimension1, Dimension2>
+{
+    typedef typename select_coordinate_type<P1, P2>::type T;
+    typedef boost::numeric::ublas::matrix<T> M;
+
+public :
+    template <typename B, typename D>
+    explicit inline map_transformer(B const& box, D const& width, D const& height)
+    {
+        set_transformation(
+                get<min_corner, 0>(box), get<min_corner, 1>(box),
+                get<max_corner, 0>(box), get<max_corner, 1>(box),
+                width, height);
+    }
+
+    template <typename W, typename D>
+    explicit inline map_transformer(W const& wx1, W const& wy1, W const& wx2, W const& wy2,
+                        D const& width, D const& height)
+    {
+        set_transformation(wx1, wy1, wx2, wy2, width, height);
+    }
+
+
+private :
+    template <typename W, typename P, typename S>
+    inline void set_transformation_point(W const& wx, W const& wy,
+        P const& px, P const& py,
+        S const& scalex, S const& scaley)
+    {
+
+        // Translate to a coordinate system centered on world coordinates (-wx, -wy)
+        M t1(3,3);
+        t1(0,0) = 1;   t1(0,1) = 0;   t1(0,2) = -wx;
+        t1(1,0) = 0;   t1(1,1) = 1;   t1(1,2) = -wy;
+        t1(2,0) = 0;   t1(2,1) = 0;   t1(2,2) = 1;
+
+        // Scale the map
+        M s(3,3);
+        s(0,0) = scalex;   s(0,1) = 0;   s(0,2) = 0;
+        s(1,0) = 0;    s(1,1) = scaley;  s(1,2) = 0;
+        s(2,0) = 0;    s(2,1) = 0;      s(2,2) = 1;
+
+        // Translate to a coordinate system centered on the specified pixels (+px, +py)
+        M t2(3, 3);
+        t2(0,0) = 1;   t2(0,1) = 0;   t2(0,2) = px;
+        t2(1,0) = 0;   t2(1,1) = 1;   t2(1,2) = py;
+        t2(2,0) = 0;   t2(2,1) = 0;   t2(2,2) = 1;
+
+        // Calculate combination matrix in two steps
+        this->m_matrix = boost::numeric::ublas::prod(s, t1);
+        this->m_matrix = boost::numeric::ublas::prod(t2, this->m_matrix);
+    }
+
+
+    template <typename W, typename D>
+    void set_transformation(W const& wx1, W const& wy1, W const& wx2, W const& wy2,
+                    D const& width, D const& height)
+    {
+        D px1 = 0;
+        D py1 = 0;
+        D px2 = width;
+        D py2 = height;
+
+        // Get the same type, but at least a double
+        typedef typename select_most_precise<D, double>::type type;
+
+
+        // Calculate appropriate scale, take min because whole box must fit
+        // Scale is in PIXELS/MAPUNITS (meters)
+        W wdx = wx2 - wx1;
+        W wdy = wy2 - wy1;
+        type sx = (px2 - px1) / boost::numeric_cast<type>(wdx);
+        type sy = (py2 - py1) / boost::numeric_cast<type>(wdy);
+
+        if (SameScale)
+        {
+            type scale = (std::min)(sx, sy);
+            sx = scale;
+            sy = scale;
+        }
+
+        // Calculate centerpoints
+        W wtx = wx1 + wx2;
+        W wty = wy1 + wy2;
+        W two = 2;
+        W wmx = wtx / two;
+        W wmy = wty / two;
+        type pmx = (px1 + px2) / 2.0;
+        type pmy = (py1 + py2) / 2.0;
+
+        set_transformation_point(wmx, wmy, pmx, pmy, sx, sy);
+
+        if (Mirror)
+        {
+            // Mirror in y-direction
+            M m(3,3);
+            m(0,0) = 1;   m(0,1) = 0;   m(0,2) = 0;
+            m(1,0) = 0;   m(1,1) = -1;  m(1,2) = 0;
+            m(2,0) = 0;   m(2,1) = 0;   m(2,2) = 1;
+
+            // Translate in y-direction such that it fits again
+            M y(3, 3);
+            y(0,0) = 1;   y(0,1) = 0;   y(0,2) = 0;
+            y(1,0) = 0;   y(1,1) = 1;   y(1,2) = height;
+            y(2,0) = 0;   y(2,1) = 0;   y(2,2) = 1;
+
+            // Calculate combination matrix in two steps
+            this->m_matrix = boost::numeric::ublas::prod(m, this->m_matrix);
+            this->m_matrix = boost::numeric::ublas::prod(y, this->m_matrix);
+        }
+    }
+};
+
+
+}} // namespace strategy::transform
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_TRANSFORM_MAP_TRANSFORMER_HPP
diff --git a/src/boost/geometry/strategies/transform/matrix_transformers.hpp b/src/boost/geometry/strategies/transform/matrix_transformers.hpp
new file mode 100644
index 0000000..68da240
--- /dev/null
+++ b/src/boost/geometry/strategies/transform/matrix_transformers.hpp
@@ -0,0 +1,422 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_TRANSFORM_MATRIX_TRANSFORMERS_HPP
+#define BOOST_GEOMETRY_STRATEGIES_TRANSFORM_MATRIX_TRANSFORMERS_HPP
+
+
+#include <cstddef>
+
+// Remove the ublas checking, otherwise the inverse might fail
+// (while nothing seems to be wrong)
+#define BOOST_UBLAS_TYPE_CHECK 0
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/numeric/ublas/vector.hpp>
+#include <boost/numeric/ublas/matrix.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/util/math.hpp>
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace transform
+{
+
+/*!
+\brief Affine transformation strategy in Cartesian system.
+\details The strategy serves as a generic definition of affine transformation matrix
+         and procedure of application it to given point.
+\see http://en.wikipedia.org/wiki/Affine_transformation
+     and http://www.devmaster.net/wiki/Transformation_matrices
+\ingroup strategies
+\tparam P1 first point type (source)
+\tparam P2 second point type (target)
+\tparam Dimension1 number of dimensions to transform from first point
+\tparam Dimension1 number of dimensions to transform to second point
+ */
+template
+<
+    typename P1, typename P2,
+    std::size_t Dimension1,
+    std::size_t Dimension2
+>
+class ublas_transformer
+{
+};
+
+
+template <typename P1, typename P2>
+class ublas_transformer<P1, P2, 2, 2>
+{
+protected :
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+    typedef coordinate_type ct; // Abbreviation
+    typedef boost::numeric::ublas::matrix<coordinate_type> matrix_type;
+    matrix_type m_matrix;
+
+public :
+
+    inline ublas_transformer(
+                ct const& m_0_0, ct const& m_0_1, ct const& m_0_2,
+                ct const& m_1_0, ct const& m_1_1, ct const& m_1_2,
+                ct const& m_2_0, ct const& m_2_1, ct const& m_2_2)
+        : m_matrix(3, 3)
+    {
+        m_matrix(0,0) = m_0_0;   m_matrix(0,1) = m_0_1;   m_matrix(0,2) = m_0_2;
+        m_matrix(1,0) = m_1_0;   m_matrix(1,1) = m_1_1;   m_matrix(1,2) = m_1_2;
+        m_matrix(2,0) = m_2_0;   m_matrix(2,1) = m_2_1;   m_matrix(2,2) = m_2_2;
+    }
+
+    inline ublas_transformer(matrix_type const& matrix)
+        : m_matrix(matrix)
+    {}
+
+
+    inline ublas_transformer() : m_matrix(3, 3) {}
+
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        assert_dimension_greater_equal<P1, 2>();
+        assert_dimension_greater_equal<P2, 2>();
+
+        coordinate_type const& c1 = get<0>(p1);
+        coordinate_type const& c2 = get<1>(p1);
+
+
+        coordinate_type p2x = c1 * m_matrix(0,0) + c2 * m_matrix(0,1) + m_matrix(0,2);
+        coordinate_type p2y = c1 * m_matrix(1,0) + c2 * m_matrix(1,1) + m_matrix(1,2);
+
+        typedef typename geometry::coordinate_type<P2>::type ct2;
+        set<0>(p2, boost::numeric_cast<ct2>(p2x));
+        set<1>(p2, boost::numeric_cast<ct2>(p2y));
+
+        return true;
+    }
+
+    matrix_type const& matrix() const { return m_matrix; }
+};
+
+
+// It IS possible to go from 3 to 2 coordinates
+template <typename P1, typename P2>
+class ublas_transformer<P1, P2, 3, 2> : public ublas_transformer<P1, P2, 2, 2>
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+    typedef coordinate_type ct; // Abbreviation
+
+public :
+    inline ublas_transformer(
+                ct const& m_0_0, ct const& m_0_1, ct const& m_0_2,
+                ct const& m_1_0, ct const& m_1_1, ct const& m_1_2,
+                ct const& m_2_0, ct const& m_2_1, ct const& m_2_2)
+        : ublas_transformer<P1, P2, 2, 2>(
+                    m_0_0, m_0_1, m_0_2,
+                    m_1_0, m_1_1, m_1_2,
+                    m_2_0, m_2_1, m_2_2)
+    {}
+
+    inline ublas_transformer()
+        : ublas_transformer<P1, P2, 2, 2>()
+    {}
+};
+
+
+template <typename P1, typename P2>
+class ublas_transformer<P1, P2, 3, 3>
+{
+protected :
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+    typedef coordinate_type ct; // Abbreviation
+    typedef boost::numeric::ublas::matrix<coordinate_type> matrix_type;
+    matrix_type m_matrix;
+
+    inline ublas_transformer(
+                ct const& m_0_0, ct const& m_0_1, ct const& m_0_2, ct const& m_0_3,
+                ct const& m_1_0, ct const& m_1_1, ct const& m_1_2, ct const& m_1_3,
+                ct const& m_2_0, ct const& m_2_1, ct const& m_2_2, ct const& m_2_3,
+                ct const& m_3_0, ct const& m_3_1, ct const& m_3_2, ct const& m_3_3
+                )
+        : m_matrix(4, 4)
+    {
+        m_matrix(0,0) = m_0_0; m_matrix(0,1) = m_0_1; m_matrix(0,2) = m_0_2; m_matrix(0,3) = m_0_3;
+        m_matrix(1,0) = m_1_0; m_matrix(1,1) = m_1_1; m_matrix(1,2) = m_1_2; m_matrix(1,3) = m_1_3;
+        m_matrix(2,0) = m_2_0; m_matrix(2,1) = m_2_1; m_matrix(2,2) = m_2_2; m_matrix(2,3) = m_2_3;
+        m_matrix(3,0) = m_3_0; m_matrix(3,1) = m_3_1; m_matrix(3,2) = m_3_2; m_matrix(3,3) = m_3_3;
+    }
+
+    inline ublas_transformer() : m_matrix(4, 4) {}
+
+public :
+
+    inline bool apply(P1 const& p1, P2& p2) const
+    {
+        coordinate_type const& c1 = get<0>(p1);
+        coordinate_type const& c2 = get<1>(p1);
+        coordinate_type const& c3 = get<2>(p1);
+
+        typedef typename geometry::coordinate_type<P2>::type ct2;
+
+        set<0>(p2, boost::numeric_cast<ct2>(
+            c1 * m_matrix(0,0) + c2 * m_matrix(0,1) + c3 * m_matrix(0,2) + m_matrix(0,3)));
+        set<1>(p2, boost::numeric_cast<ct2>(
+            c1 * m_matrix(1,0) + c2 * m_matrix(1,1) + c3 * m_matrix(1,2) + m_matrix(1,3)));
+        set<2>(p2, boost::numeric_cast<ct2>(
+            c1 * m_matrix(2,0) + c2 * m_matrix(2,1) + c3 * m_matrix(2,2) + m_matrix(2,3)));
+
+        return true;
+    }
+
+    matrix_type const& matrix() const { return m_matrix; }
+};
+
+
+/*!
+\brief Strategy of translate transformation in Cartesian system.
+\details Translate moves a geometry a fixed distance in 2 or 3 dimensions.
+\see http://en.wikipedia.org/wiki/Translation_%28geometry%29
+\ingroup strategies
+\tparam P1 first point type
+\tparam P2 second point type
+\tparam Dimension1 number of dimensions to transform from first point
+\tparam Dimension1 number of dimensions to transform to second point
+ */
+template
+<
+    typename P1, typename P2,
+    std::size_t Dimension1 = geometry::dimension<P1>::type::value,
+    std::size_t Dimension2 = geometry::dimension<P2>::type::value
+>
+class translate_transformer
+{
+};
+
+
+template <typename P1, typename P2>
+class translate_transformer<P1, P2, 2, 2> : public ublas_transformer<P1, P2, 2, 2>
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+public :
+    // To have translate transformers compatible for 2/3 dimensions, the
+    // constructor takes an optional third argument doing nothing.
+    inline translate_transformer(coordinate_type const& translate_x,
+                coordinate_type const& translate_y,
+                coordinate_type const& = 0)
+        : ublas_transformer<P1, P2, 2, 2>(
+                1, 0, translate_x,
+                0, 1, translate_y,
+                0, 0, 1)
+    {}
+};
+
+
+template <typename P1, typename P2>
+class translate_transformer<P1, P2, 3, 3> : public ublas_transformer<P1, P2, 3, 3>
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+public :
+    inline translate_transformer(coordinate_type const& translate_x,
+                coordinate_type const& translate_y,
+                coordinate_type const& translate_z)
+        : ublas_transformer<P1, P2, 3, 3>(
+                1, 0, 0, translate_x,
+                0, 1, 0, translate_y,
+                0, 0, 1, translate_z,
+                0, 0, 0, 1)
+    {}
+
+};
+
+
+/*!
+\brief Strategy of scale transformation in Cartesian system.
+\details Scale scales a geometry up or down in all its dimensions.
+\see http://en.wikipedia.org/wiki/Scaling_%28geometry%29
+\ingroup strategies
+\tparam P1 first point type
+\tparam P2 second point type
+\tparam Dimension1 number of dimensions to transform from first point
+\tparam Dimension1 number of dimensions to transform to second point
+*/
+template
+<
+    typename P1, typename P2 = P1,
+    std::size_t Dimension1 = geometry::dimension<P1>::type::value,
+    std::size_t Dimension2 = geometry::dimension<P2>::type::value
+>
+class scale_transformer
+{
+};
+
+
+template <typename P1, typename P2>
+class scale_transformer<P1, P2, 2, 2> : public ublas_transformer<P1, P2, 2, 2>
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+public :
+    inline scale_transformer(coordinate_type const& scale_x,
+                coordinate_type const& scale_y,
+                coordinate_type const& = 0)
+        : ublas_transformer<P1, P2, 2, 2>(
+                scale_x, 0,       0,
+                0,       scale_y, 0,
+                0,       0,       1)
+    {}
+
+
+    inline scale_transformer(coordinate_type const& scale)
+        : ublas_transformer<P1, P2, 2, 2>(
+                scale, 0,     0,
+                0,     scale, 0,
+                0,     0,     1)
+    {}
+};
+
+
+template <typename P1, typename P2>
+class scale_transformer<P1, P2, 3, 3> : public ublas_transformer<P1, P2, 3, 3>
+{
+    typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+    inline scale_transformer(coordinate_type const& scale_x,
+                coordinate_type const& scale_y,
+                coordinate_type const& scale_z)
+        : ublas_transformer<P1, P2, 3, 3>(
+                scale_x, 0,       0,       0,
+                0,       scale_y, 0,       0,
+                0,       0,       scale_z, 0,
+                0,       0,       0,       1)
+    {}
+
+
+    inline scale_transformer(coordinate_type const& scale)
+        : ublas_transformer<P1, P2, 3, 3>(
+                scale, 0,     0,     0,
+                0,     scale, 0,     0,
+                0,     0,     scale, 0,
+                0,     0,     0,     1)
+    {}
+};
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template <typename DegreeOrRadian>
+struct as_radian
+{};
+
+
+template <>
+struct as_radian<radian>
+{
+    template <typename T>
+    static inline T get(T const& value)
+    {
+        return value;
+    }
+};
+
+template <>
+struct as_radian<degree>
+{
+    template <typename T>
+    static inline T get(T const& value)
+    {
+        return value * math::d2r;
+    }
+
+};
+
+
+template
+<
+    typename P1, typename P2,
+    std::size_t Dimension1 = geometry::dimension<P1>::type::value,
+    std::size_t Dimension2 = geometry::dimension<P2>::type::value
+>
+class rad_rotate_transformer
+    : public ublas_transformer<P1, P2, Dimension1, Dimension2>
+{
+    // Angle has type of coordinate type, but at least a double
+    typedef typename select_most_precise
+        <
+            typename select_coordinate_type<P1, P2>::type,
+            double
+        >::type angle_type;
+
+public :
+    inline rad_rotate_transformer(angle_type const& angle)
+        : ublas_transformer<P1, P2, Dimension1, Dimension2>(
+                 cos(angle), sin(angle), 0,
+                -sin(angle), cos(angle), 0,
+                 0,          0,          1)
+    {}
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief Strategy of rotate transformation in Cartesian system.
+\details Rotate rotates a geometry of specified angle about a fixed point (e.g. origin).
+\see http://en.wikipedia.org/wiki/Rotation_%28mathematics%29
+\ingroup strategies
+\tparam P1 first point type
+\tparam P2 second point type
+\tparam DegreeOrRadian degree/or/radian, type of rotation angle specification
+\note A single angle is needed to specify a rotation in 2D.
+      Not yet in 3D, the 3D version requires special things to allow
+      for rotation around X, Y, Z or arbitrary axis.
+\todo The 3D version will not compile.
+ */
+template <typename P1, typename P2, typename DegreeOrRadian>
+class rotate_transformer : public detail::rad_rotate_transformer<P1, P2>
+{
+    // Angle has type of coordinate type, but at least a double
+    typedef typename select_most_precise
+        <
+            typename select_coordinate_type<P1, P2>::type,
+            double
+        >::type angle_type;
+
+public :
+    inline rotate_transformer(angle_type const& angle)
+        : detail::rad_rotate_transformer
+            <
+                P1, P2
+            >(detail::as_radian<DegreeOrRadian>::get(angle))
+    {}
+};
+
+
+}} // namespace strategy::transform
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_TRANSFORM_MATRIX_TRANSFORMERS_HPP
diff --git a/src/boost/geometry/strategies/within.hpp b/src/boost/geometry/strategies/within.hpp
new file mode 100644
index 0000000..0852a22
--- /dev/null
+++ b/src/boost/geometry/strategies/within.hpp
@@ -0,0 +1,71 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_STRATEGIES_WITHIN_HPP
+#define BOOST_GEOMETRY_STRATEGIES_WITHIN_HPP
+
+#include <boost/mpl/assert.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace strategy { namespace within
+{
+
+
+namespace services
+{
+
+/*!
+\brief Traits class binding a within determination strategy to a coordinate system
+\ingroup within
+\tparam TagContained tag (possibly casted) of point-type
+\tparam TagContained tag (possibly casted) of (possibly) containing type
+\tparam CsTagContained tag of coordinate system of point-type
+\tparam CsTagContaining tag of coordinate system of (possibly) containing type
+\tparam Geometry geometry-type of input (often point, or box)
+\tparam GeometryContaining geometry-type of input (possibly) containing type
+*/
+template
+<
+    typename TagContained,
+    typename TagContaining,
+    typename CastedTagContained,
+    typename CastedTagContaining,
+    typename CsTagContained,
+    typename CsTagContaining,
+    typename GeometryContained,
+    typename GeometryContaining
+>
+struct default_strategy
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_TYPES
+            , (types<GeometryContained, GeometryContaining>)
+        );
+};
+
+
+} // namespace services
+
+
+}} // namespace strategy::within
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_STRATEGIES_WITHIN_HPP
+
diff --git a/src/boost/geometry/util/add_const_if_c.hpp b/src/boost/geometry/util/add_const_if_c.hpp
new file mode 100644
index 0000000..9e0c012
--- /dev/null
+++ b/src/boost/geometry/util/add_const_if_c.hpp
@@ -0,0 +1,56 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP
+#define BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP
+
+
+#include <boost/mpl/if.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+    \brief Meta-function to define a const or non const type
+    \ingroup utility
+    \details If the boolean template parameter is true, the type parameter
+        will be defined as const, otherwise it will be defined as it was.
+        This meta-function is used to have one implementation for both
+        const and non const references
+    \note This traits class is completely independant from Boost.Geometry
+        and might be a separate addition to Boost
+    \note Used in a.o. for_each, interior_rings, exterior_ring
+    \par Example
+    \code
+        void foo(typename add_const_if_c<IsConst, Point>::type& point)
+    \endcode
+*/
+template <bool IsConst, typename Type>
+struct add_const_if_c
+{
+    typedef typename boost::mpl::if_c
+        <
+            IsConst,
+            Type const,
+            Type
+        >::type type;
+};
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP
diff --git a/src/boost/geometry/util/calculation_type.hpp b/src/boost/geometry/util/calculation_type.hpp
new file mode 100644
index 0000000..aef5890
--- /dev/null
+++ b/src/boost/geometry/util/calculation_type.hpp
@@ -0,0 +1,176 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2012 Mateusz Loskot, London, UK.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_CALCULATION_TYPE_HPP
+#define BOOST_GEOMETRY_UTIL_CALCULATION_TYPE_HPP
+
+#include <boost/config.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace util
+{
+
+namespace detail
+{
+
+struct default_integral
+{
+#ifdef BOOST_HAS_LONG_LONG
+    typedef boost::long_long_type type;
+#else
+    typedef int type;
+#endif    
+};
+
+/*!
+\details Selects the most appropriate:
+    - if calculation type is specified (not void), that one is used
+    - else if type is non-fundamental (user defined e.g. ttmath), that one
+    - else if type is floating point, the specified default FP is used
+    - else it is integral and the specified default integral is used
+ */
+template
+<
+    typename Type,
+    typename CalculationType,
+    typename DefaultFloatingPointCalculationType,
+    typename DefaultIntegralCalculationType
+>
+struct calculation_type
+{
+    BOOST_STATIC_ASSERT((
+        boost::is_fundamental
+            <
+                DefaultFloatingPointCalculationType
+            >::type::value
+        ));
+    BOOST_STATIC_ASSERT((
+        boost::is_fundamental
+            <
+                DefaultIntegralCalculationType
+            >::type::value
+        ));
+    
+
+    typedef typename boost::mpl::if_
+        <
+            boost::is_void<CalculationType>,
+            typename boost::mpl::if_
+                <
+                    boost::is_floating_point<Type>,
+                    typename select_most_precise
+                        <
+                            DefaultFloatingPointCalculationType,
+                            Type
+                        >::type,
+                    typename select_most_precise
+                        <
+                            DefaultIntegralCalculationType,
+                            Type
+                        >::type
+                >::type,
+            CalculationType
+        >::type type;
+};
+
+} // namespace detail
+
+
+namespace calculation_type
+{
+
+namespace geometric
+{
+
+template
+<
+    typename Geometry,
+    typename CalculationType,
+    typename DefaultFloatingPointCalculationType = double,
+    typename DefaultIntegralCalculationType = detail::default_integral::type
+>
+struct unary
+{
+    typedef typename detail::calculation_type
+        <
+            typename geometry::coordinate_type<Geometry>::type,
+            CalculationType,
+            DefaultFloatingPointCalculationType,
+            DefaultIntegralCalculationType
+        >::type type;
+};
+
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename CalculationType,
+    typename DefaultFloatingPointCalculationType = double,
+    typename DefaultIntegralCalculationType = detail::default_integral::type
+>
+struct binary
+{
+    typedef typename detail::calculation_type
+        <
+            typename select_coordinate_type<Geometry1, Geometry2>::type,
+            CalculationType,
+            DefaultFloatingPointCalculationType,
+            DefaultIntegralCalculationType
+        >::type type;
+};
+
+
+/*!
+\brief calculation type (ternary, for three geometry types)
+ */
+template
+<
+    typename Geometry1,
+    typename Geometry2,
+    typename Geometry3,
+    typename CalculationType,
+    typename DefaultFloatingPointCalculationType = double,
+    typename DefaultIntegralCalculationType = detail::default_integral::type
+>
+struct ternary
+{
+    typedef typename detail::calculation_type
+        <
+            typename select_most_precise
+                <
+                    typename coordinate_type<Geometry1>::type, 
+                    typename select_coordinate_type
+                        <
+                            Geometry2,
+                            Geometry3
+                        >::type 
+                >::type,
+            CalculationType,
+            DefaultFloatingPointCalculationType,
+            DefaultIntegralCalculationType
+        >::type type;
+};
+
+}} // namespace calculation_type::geometric
+
+} // namespace util
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_CALCULATION_TYPE_HPP
diff --git a/src/boost/geometry/util/closure_as_bool.hpp b/src/boost/geometry/util/closure_as_bool.hpp
new file mode 100644
index 0000000..57fcd52
--- /dev/null
+++ b/src/boost/geometry/util/closure_as_bool.hpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_CLOSURE_AS_BOOL_HPP
+#define BOOST_GEOMETRY_UTIL_CLOSURE_AS_BOOL_HPP
+
+#include <boost/geometry/core/closure.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+template<closure_selector Closure>
+struct closure_as_bool
+{};
+
+
+template<>
+struct closure_as_bool<closed>
+{
+    static const bool value = true;
+};
+
+
+template<>
+struct closure_as_bool<open>
+{
+    static const bool value = false;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_CLOSURE_AS_BOOL_HPP
diff --git a/src/boost/geometry/util/coordinate_cast.hpp b/src/boost/geometry/util/coordinate_cast.hpp
new file mode 100644
index 0000000..16a15cc
--- /dev/null
+++ b/src/boost/geometry/util/coordinate_cast.hpp
@@ -0,0 +1,55 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_COORDINATE_CAST_HPP
+#define BOOST_GEOMETRY_UTIL_COORDINATE_CAST_HPP
+
+#include <cstdlib>
+#include <string>
+#include <boost/lexical_cast.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+/*!
+\brief cast coordinates from a string to a coordinate type
+\detail By default it uses lexical_cast. However, lexical_cast seems not to support
+    ttmath / partial specializations. Therefore this small utility is added.
+    See also "define_pi" where the same issue is solved
+*/
+template <typename CoordinateType>
+struct coordinate_cast
+{
+    static inline CoordinateType apply(std::string const& source)
+    {
+#if defined(BOOST_GEOMETRY_NO_LEXICAL_CAST)
+        return atof(source.c_str());
+#else
+        return boost::lexical_cast<CoordinateType>(source);
+#endif
+    }
+};
+
+
+} // namespace detail
+#endif
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_UTIL_COORDINATE_CAST_HPP
diff --git a/src/boost/geometry/util/for_each_coordinate.hpp b/src/boost/geometry/util/for_each_coordinate.hpp
new file mode 100644
index 0000000..7a1f55b
--- /dev/null
+++ b/src/boost/geometry/util/for_each_coordinate.hpp
@@ -0,0 +1,94 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
+#define BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
+
+#include <boost/concept/requires.hpp>
+#include <boost/geometry/geometries/concepts/point_concept.hpp>
+#include <boost/geometry/util/add_const_if_c.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Point, int Dimension, int DimensionCount, bool IsConst>
+struct coordinates_scanner
+{
+    template <typename Op>
+    static inline Op apply(typename add_const_if_c
+        <
+            IsConst,
+            Point
+        >::type& point, Op operation)
+    {
+        operation.template apply<Point, Dimension>(point);
+        return coordinates_scanner
+            <
+                Point,
+                Dimension+1,
+                DimensionCount,
+                IsConst
+            >::apply(point, operation);
+    }
+};
+
+template <typename Point, int DimensionCount, bool IsConst>
+struct coordinates_scanner<Point, DimensionCount, DimensionCount, IsConst>
+{
+    template <typename Op>
+    static inline Op apply(typename add_const_if_c
+        <
+            IsConst,
+            Point
+        >::type& , Op operation)
+    {
+        return operation;
+    }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+template <typename Point, typename Op>
+inline void for_each_coordinate(Point& point, Op operation)
+{
+    BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
+
+    typedef typename detail::coordinates_scanner
+        <
+            Point, 0, dimension<Point>::type::value, false
+        > scanner;
+
+    scanner::apply(point, operation);
+}
+
+template <typename Point, typename Op>
+inline Op for_each_coordinate(Point const& point, Op operation)
+{
+    BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point>) );
+
+    typedef typename detail::coordinates_scanner
+        <
+            Point, 0, dimension<Point>::type::value, true
+        > scanner;
+
+    return scanner::apply(point, operation);
+}
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_UTIL_FOR_EACH_COORDINATE_HPP
diff --git a/src/boost/geometry/util/math.hpp b/src/boost/geometry/util/math.hpp
new file mode 100644
index 0000000..95cbdf2
--- /dev/null
+++ b/src/boost/geometry/util/math.hpp
@@ -0,0 +1,222 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_MATH_HPP
+#define BOOST_GEOMETRY_UTIL_MATH_HPP
+
+#include <cmath>
+#include <limits>
+
+#include <boost/math/constants/constants.hpp>
+
+#include <boost/geometry/util/select_most_precise.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace math
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template <typename Type, bool IsFloatingPoint>
+struct equals
+{
+    static inline bool apply(Type const& a, Type const& b)
+    {
+        return a == b;
+    }
+};
+
+template <typename Type>
+struct equals<Type, true>
+{
+	static inline Type get_max(Type const& a, Type const& b, Type const& c)
+	{
+		return (std::max)((std::max)(a, b), c);
+	}
+
+    static inline bool apply(Type const& a, Type const& b)
+    {
+		if (a == b)
+		{
+			return true;
+		}
+
+        // See http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17,
+        // FUTURE: replace by some boost tool or boost::test::close_at_tolerance
+        return std::abs(a - b) <= std::numeric_limits<Type>::epsilon() * get_max(std::abs(a), std::abs(b), 1.0);
+    }
+};
+
+template <typename Type, bool IsFloatingPoint>
+struct smaller
+{
+    static inline bool apply(Type const& a, Type const& b)
+    {
+        return a < b;
+    }
+};
+
+template <typename Type>
+struct smaller<Type, true>
+{
+    static inline bool apply(Type const& a, Type const& b)
+    {
+		if (equals<Type, true>::apply(a, b))
+		{
+			return false;
+		}
+		return a < b;
+    }
+};
+
+
+template <typename Type, bool IsFloatingPoint> 
+struct equals_with_epsilon : public equals<Type, IsFloatingPoint> {};
+
+
+/*!
+\brief Short construct to enable partial specialization for PI, currently not possible in Math.
+*/
+template <typename T>
+struct define_pi
+{
+    static inline T apply()
+    {
+        // Default calls Boost.Math
+        return boost::math::constants::pi<T>();
+    }
+};
+
+
+} // namespace detail
+#endif
+
+
+template <typename T>
+inline T pi() { return detail::define_pi<T>::apply(); }
+
+
+// Maybe replace this by boost equals or boost ublas numeric equals or so
+
+/*!
+    \brief returns true if both arguments are equal.
+    \ingroup utility
+    \param a first argument
+    \param b second argument
+    \return true if a == b
+    \note If both a and b are of an integral type, comparison is done by ==.
+    If one of the types is floating point, comparison is done by abs and
+    comparing with epsilon. If one of the types is non-fundamental, it might
+    be a high-precision number and comparison is done using the == operator
+    of that class.
+*/
+
+template <typename T1, typename T2>
+inline bool equals(T1 const& a, T2 const& b)
+{
+    typedef typename select_most_precise<T1, T2>::type select_type;
+    return detail::equals
+        <
+            select_type,
+            boost::is_floating_point<select_type>::type::value
+        >::apply(a, b);
+}
+
+template <typename T1, typename T2>
+inline bool equals_with_epsilon(T1 const& a, T2 const& b)
+{
+    typedef typename select_most_precise<T1, T2>::type select_type;
+    return detail::equals_with_epsilon
+        <
+            select_type, 
+            boost::is_floating_point<select_type>::type::value
+        >::apply(a, b);
+}
+
+template <typename T1, typename T2>
+inline bool smaller(T1 const& a, T2 const& b)
+{
+    typedef typename select_most_precise<T1, T2>::type select_type;
+    return detail::smaller
+        <
+            select_type,
+            boost::is_floating_point<select_type>::type::value
+        >::apply(a, b);
+}
+
+template <typename T1, typename T2>
+inline bool larger(T1 const& a, T2 const& b)
+{
+    typedef typename select_most_precise<T1, T2>::type select_type;
+    return detail::smaller
+        <
+            select_type,
+            boost::is_floating_point<select_type>::type::value
+        >::apply(b, a);
+}
+
+
+
+double const d2r = geometry::math::pi<double>() / 180.0;
+double const r2d = 1.0 / d2r;
+
+/*!
+    \brief Calculates the haversine of an angle
+    \ingroup utility
+    \note See http://en.wikipedia.org/wiki/Haversine_formula
+    haversin(alpha) = sin2(alpha/2)
+*/
+template <typename T>
+inline T hav(T const& theta)
+{
+    T const half = T(0.5);
+    T const sn = sin(half * theta);
+    return sn * sn;
+}
+
+/*!
+\brief Short utility to return the square
+\ingroup utility
+\param value Value to calculate the square from
+\return The squared value
+*/
+template <typename T>
+inline T sqr(T const& value)
+{
+    return value * value;
+}
+
+
+/*!
+\brief Short utility to workaround gcc/clang problem that abs is converting to integer
+\ingroup utility
+*/
+template<typename T>
+inline T abs(const T& t)
+{
+    using std::abs;
+    return abs(t);
+}
+
+
+} // namespace math
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_UTIL_MATH_HPP
diff --git a/src/boost/geometry/util/order_as_direction.hpp b/src/boost/geometry/util/order_as_direction.hpp
new file mode 100644
index 0000000..6895ebf
--- /dev/null
+++ b/src/boost/geometry/util/order_as_direction.hpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_ORDER_AS_DIRECTION_HPP
+#define BOOST_GEOMETRY_UTIL_ORDER_AS_DIRECTION_HPP
+
+#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+template<order_selector Order>
+struct order_as_direction
+{};
+
+
+template<>
+struct order_as_direction<clockwise>
+{
+    static const iterate_direction value = iterate_forward;
+};
+
+
+template<>
+struct order_as_direction<counterclockwise>
+{
+    static const iterate_direction value = iterate_reverse;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_ORDER_AS_DIRECTION_HPP
diff --git a/src/boost/geometry/util/parameter_type_of.hpp b/src/boost/geometry/util/parameter_type_of.hpp
new file mode 100644
index 0000000..b8872d5
--- /dev/null
+++ b/src/boost/geometry/util/parameter_type_of.hpp
@@ -0,0 +1,75 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_PARAMETER_TYPE_OF_HPP
+#define BOOST_GEOMETRY_UTIL_PARAMETER_TYPE_OF_HPP
+
+
+#include <boost/function_types/function_arity.hpp>
+#include <boost/function_types/is_member_function_pointer.hpp>
+#include <boost/function_types/parameter_types.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/plus.hpp>
+#include <boost/type_traits.hpp>
+
+
+namespace boost { namespace geometry
+{ 
+
+
+/*!
+\brief Meta-function selecting a parameter type of a (member) function, by index
+\ingroup utility
+ */
+template <typename Method, std::size_t Index>
+struct parameter_type_of
+{
+    typedef typename boost::function_types::parameter_types
+        <
+            Method
+        >::type parameter_types;
+
+    typedef typename boost::mpl::if_
+        <
+            boost::function_types::is_member_function_pointer<Method>,
+            boost::mpl::int_<1>,
+            boost::mpl::int_<0>
+        >::type base_index_type;
+        
+    typedef typename boost::mpl::if_c
+        <
+            Index == 0,
+            base_index_type,
+            typename boost::mpl::plus
+                <
+                    base_index_type,
+                    boost::mpl::int_<Index>
+                >::type
+        >::type indexed_type;
+
+    typedef typename boost::remove_reference
+        <
+            typename boost::mpl::at
+                <
+                    parameter_types,
+                    indexed_type
+                >::type
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_PARAMETER_TYPE_OF_HPP
diff --git a/src/boost/geometry/util/promote_floating_point.hpp b/src/boost/geometry/util/promote_floating_point.hpp
new file mode 100644
index 0000000..0c74cb8
--- /dev/null
+++ b/src/boost/geometry/util/promote_floating_point.hpp
@@ -0,0 +1,50 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_PROMOTE_FLOATING_POINT_HPP
+#define BOOST_GEOMETRY_UTIL_PROMOTE_FLOATING_POINT_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+    \brief Meta-function converting, if necessary, to "a floating point" type
+    \details
+        - if input type is integer, type is double
+        - else type is input type
+    \ingroup utility
+ */
+
+template <typename T, typename PromoteIntegerTo = double>
+struct promote_floating_point
+{
+    typedef typename
+        boost::mpl::if_
+        <
+            boost::is_integral<T>,
+            PromoteIntegerTo,
+            T
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_PROMOTE_FLOATING_POINT_HPP
diff --git a/src/boost/geometry/util/rational.hpp b/src/boost/geometry/util/rational.hpp
new file mode 100644
index 0000000..45bee20
--- /dev/null
+++ b/src/boost/geometry/util/rational.hpp
@@ -0,0 +1,179 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2011-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2011-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_RATIONAL_HPP
+#define BOOST_GEOMETRY_UTIL_RATIONAL_HPP
+
+#include <boost/rational.hpp>
+#include <boost/numeric/conversion/bounds.hpp>
+
+#include <boost/geometry/util/coordinate_cast.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost{ namespace geometry 
+{ 
+
+
+// Specialize for Boost.Geometry's coordinate cast 
+// (from string to coordinate type)
+namespace detail
+{
+
+template <typename T>
+struct coordinate_cast<rational<T> >
+{
+    static inline void split_parts(std::string const& source, std::string::size_type p,
+        T& before, T& after, bool& negate, std::string::size_type& len)
+    {
+        std::string before_part = source.substr(0, p);
+        std::string const after_part = source.substr(p + 1);
+
+		negate = false;
+
+		if (before_part.size() > 0 && before_part[0] == '-')
+		{
+			negate = true;
+			before_part.erase(0, 1);
+		}
+        before = atol(before_part.c_str());
+        after = atol(after_part.c_str());
+        len = after_part.length();
+    }
+
+
+    static inline rational<T> apply(std::string const& source)
+    {
+        T before, after;
+        bool negate;
+        std::string::size_type len;
+
+        // Note: decimal comma is not (yet) supported, it does (and should) not
+        // occur in a WKT, where points are comma separated.
+        std::string::size_type p = source.find(".");
+        if (p == std::string::npos)
+        {
+            p = source.find("/");
+            if (p == std::string::npos)
+            {
+                return rational<T>(atol(source.c_str()));
+            }
+            split_parts(source, p, before, after, negate, len);
+
+            return negate 
+			    ? -rational<T>(before, after)
+			    : rational<T>(before, after)
+			    ;
+
+        }
+
+        split_parts(source, p, before, after, negate, len);
+
+        T den = 1;
+        for (std::string::size_type i = 0; i < len; i++)
+        {
+            den *= 10;
+        }
+
+        return negate 
+			? -rational<T>(before) - rational<T>(after, den)
+			: rational<T>(before) + rational<T>(after, den)
+			;
+    }
+};
+
+} // namespace detail
+
+// Specialize for Boost.Geometry's select_most_precise
+template <typename T1, typename T2>
+struct select_most_precise<boost::rational<T1>, boost::rational<T2> >
+{
+    typedef typename boost::rational
+        <
+            typename select_most_precise<T1, T2>::type
+        > type;
+};
+
+template <typename T>
+struct select_most_precise<boost::rational<T>, double>
+{
+    typedef typename boost::rational<T> type;
+};
+
+
+}} // namespace boost::geometry
+
+
+// Specializes boost::rational to boost::numeric::bounds
+namespace boost { namespace numeric 
+{
+
+template<class T>
+struct bounds<rational<T> >
+{
+    static inline rational<T> lowest() 
+    { 
+        return rational<T>(bounds<T>::lowest(), 1); 
+    }
+    static inline rational<T> highest() 
+    { 
+        return rational<T>(bounds<T>::highest(), 1); 
+    }
+};
+
+}} // namespace boost::numeric
+
+
+// Support for boost::numeric_cast to int and to double (necessary for SVG-mapper)
+namespace boost { namespace numeric
+{
+
+template
+<
+    typename T,
+    typename Traits,
+    typename OverflowHandler,
+    typename Float2IntRounder,
+    typename RawConverter,
+    typename UserRangeChecker
+>
+struct converter<int, rational<T>, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker>
+{
+    static inline int convert(rational<T> const& arg)
+    {
+        return int(rational_cast<double>(arg));
+    }
+};
+
+template
+<
+    typename T,
+    typename Traits,
+    typename OverflowHandler,
+    typename Float2IntRounder,
+    typename RawConverter,
+    typename UserRangeChecker
+>
+struct converter<double, rational<T>, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker>
+{
+    static inline double convert(rational<T> const& arg)
+    {
+        return rational_cast<double>(arg);
+    }
+};
+
+
+}}
+
+
+#endif // BOOST_GEOMETRY_UTIL_RATIONAL_HPP
diff --git a/src/boost/geometry/util/readme.txt b/src/boost/geometry/util/readme.txt
new file mode 100644
index 0000000..7a1bf88
--- /dev/null
+++ b/src/boost/geometry/util/readme.txt
@@ -0,0 +1,17 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+This folder contains several headerfiles not fitting in one of the other folders,
+or meta-functions which would fit into boost as a separate trait or utility,
+such as add_const_if_c
+
diff --git a/src/boost/geometry/util/select_calculation_type.hpp b/src/boost/geometry/util/select_calculation_type.hpp
new file mode 100644
index 0000000..4946c45
--- /dev/null
+++ b/src/boost/geometry/util/select_calculation_type.hpp
@@ -0,0 +1,57 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_SELECT_CALCULATION_TYPE_HPP
+#define BOOST_GEOMETRY_UTIL_SELECT_CALCULATION_TYPE_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/util/select_coordinate_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+    \brief Meta-function selecting the "calculation" type
+    \details Based on two input geometry types, and an input calculation type,
+        (which defaults to void in the calling function), this meta-function
+        selects the most appropriate:
+        - if calculation type is specified, that one is used,
+        - if it is void, the most precise of the two points is used
+    \ingroup utility
+ */
+template <typename Geometry1, typename Geometry2, typename CalculationType>
+struct select_calculation_type
+{
+    typedef typename
+        boost::mpl::if_
+        <
+            boost::is_void<CalculationType>,
+            typename select_coordinate_type
+                <
+                    Geometry1,
+                    Geometry2
+                >::type,
+            CalculationType
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_SELECT_CALCULATION_TYPE_HPP
diff --git a/src/boost/geometry/util/select_coordinate_type.hpp b/src/boost/geometry/util/select_coordinate_type.hpp
new file mode 100644
index 0000000..8309da4
--- /dev/null
+++ b/src/boost/geometry/util/select_coordinate_type.hpp
@@ -0,0 +1,45 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_SELECT_COORDINATE_TYPE_HPP
+#define BOOST_GEOMETRY_UTIL_SELECT_COORDINATE_TYPE_HPP
+
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/util/select_most_precise.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+    \brief Meta-function selecting the most precise coordinate type
+        of two geometries
+    \ingroup utility
+ */
+template <typename T1, typename T2>
+struct select_coordinate_type
+{
+    typedef typename select_most_precise
+        <
+            typename coordinate_type<T1>::type,
+            typename coordinate_type<T2>::type
+        >::type type;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_SELECT_COORDINATE_TYPE_HPP
diff --git a/src/boost/geometry/util/select_most_precise.hpp b/src/boost/geometry/util/select_most_precise.hpp
new file mode 100644
index 0000000..d55fdbf
--- /dev/null
+++ b/src/boost/geometry/util/select_most_precise.hpp
@@ -0,0 +1,162 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_SELECT_MOST_PRECISE_HPP
+#define BOOST_GEOMETRY_UTIL_SELECT_MOST_PRECISE_HPP
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+
+namespace detail { namespace select_most_precise
+{
+
+
+// At least one of the types is non-fundamental. Take that one.
+// if both are non-fundamental, the type-to-be-selected
+// is unknown, it should be defined by explicit specialization.
+template <bool Fundamental1, bool Fundamental2, typename T1, typename T2>
+struct select_non_fundamental
+{
+    typedef T1 type;
+};
+
+template <typename T1, typename T2>
+struct select_non_fundamental<true, false, T1, T2>
+{
+    typedef T2 type;
+};
+
+template <typename T1, typename T2>
+struct select_non_fundamental<false, true, T1, T2>
+{
+    typedef T1 type;
+};
+
+
+// Selection of largest type (e.g. int of <short int,int>
+// It defaults takes the first one, if second is larger, take the second one
+template <bool SecondLarger, typename T1, typename T2>
+struct select_largest
+{
+    typedef T1 type;
+};
+
+template <typename T1, typename T2>
+struct select_largest<true, T1, T2>
+{
+    typedef T2 type;
+};
+
+
+
+// Selection of floating point and specializations:
+// both FP or both !FP does never occur...
+template <bool FP1, bool FP2, typename T1, typename T2>
+struct select_floating_point
+{
+    typedef char type;
+};
+
+
+// ... so if ONE but not both of these types is floating point, take that one
+template <typename T1, typename T2>
+struct select_floating_point<true, false, T1, T2>
+{
+    typedef T1 type;
+};
+
+
+template <typename T1, typename T2>
+struct select_floating_point<false, true, T1, T2>
+{
+    typedef T2 type;
+};
+
+
+}} // namespace detail::select_most_precise
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+    \brief Meta-function to select, of two types, the most accurate type for
+        calculations
+    \ingroup utility
+    \details select_most_precise classes, compares two types on compile time.
+    For example, if an addition must be done with a double and an integer, the
+        result must be a double.
+    If both types are integer, the result can be an integer.
+    \note It is different from the "promote" class, already in boost. That
+        class promotes e.g. a (one) float to a double. This class selects a
+        type from two types. It takes the most accurate, but does not promote
+        afterwards.
+    \note This traits class is completely independant from GGL and might be a
+        separate addition to Boost
+    \note If the input is a non-fundamental type, it might be a calculation
+        type such as a GMP-value or another high precision value. Therefore,
+        if one is non-fundamental, that one is chosen.
+    \note If both types are non-fundamental, the result is indeterminate and
+        currently the first one is chosen.
+*/
+template <typename T1, typename T2>
+struct select_most_precise
+{
+    static const bool second_larger = sizeof(T2) > sizeof(T1);
+    static const bool one_not_fundamental = !
+        (boost::is_fundamental<T1>::type::value
+          && boost::is_fundamental<T2>::type::value);
+
+    static const bool both_same =
+        boost::is_floating_point<T1>::type::value
+        == boost::is_floating_point<T2>::type::value;
+
+    typedef typename boost::mpl::if_c
+        <
+            one_not_fundamental,
+            typename detail::select_most_precise::select_non_fundamental
+            <
+                boost::is_fundamental<T1>::type::value,
+                boost::is_fundamental<T2>::type::value,
+                T1,
+                T2
+            >::type,
+            typename boost::mpl::if_c
+            <
+                both_same,
+                typename detail::select_most_precise::select_largest
+                <
+                    second_larger,
+                    T1,
+                    T2
+                >::type,
+                typename detail::select_most_precise::select_floating_point
+                <
+                    boost::is_floating_point<T1>::type::value,
+                    boost::is_floating_point<T2>::type::value,
+                    T1,
+                    T2
+                >::type
+            >::type
+        >::type type;
+};
+
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_UTIL_SELECT_MOST_PRECISE_HPP
diff --git a/src/boost/geometry/util/write_dsv.hpp b/src/boost/geometry/util/write_dsv.hpp
new file mode 100644
index 0000000..3fef63e
--- /dev/null
+++ b/src/boost/geometry/util/write_dsv.hpp
@@ -0,0 +1,396 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_UTIL_WRITE_DSV_HPP
+#define BOOST_GEOMETRY_UTIL_WRITE_DSV_HPP
+
+
+#include <cstddef>
+#include <ostream>
+#include <string>
+
+#include <boost/concept_check.hpp>
+#include <boost/range.hpp>
+#include <boost/typeof/typeof.hpp>
+
+#include <boost/geometry/core/exterior_ring.hpp>
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag_cast.hpp>
+
+#include <boost/geometry/geometries/concepts/check.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv
+{
+
+
+struct dsv_settings
+{
+    std::string coordinate_separator;
+    std::string point_open;
+    std::string point_close;
+    std::string point_separator;
+    std::string list_open;
+    std::string list_close;
+    std::string list_separator;
+
+    dsv_settings(std::string const& sep
+            , std::string const& open
+            , std::string const& close
+            , std::string const& psep
+            , std::string const& lopen
+            , std::string const& lclose
+            , std::string const& lsep
+            )
+        : coordinate_separator(sep)
+        , point_open(open)
+        , point_close(close)
+        , point_separator(psep)
+        , list_open(lopen)
+        , list_close(lclose)
+        , list_separator(lsep)
+    {}
+};
+
+/*!
+\brief Stream coordinate of a point as \ref DSV
+*/
+template <typename Point, std::size_t Dimension, std::size_t Count>
+struct stream_coordinate
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Point const& point,
+            dsv_settings const& settings)
+    {
+        os << (Dimension > 0 ? settings.coordinate_separator : "")
+            << get<Dimension>(point);
+
+        stream_coordinate
+            <
+                Point, Dimension + 1, Count
+            >::apply(os, point, settings);
+    }
+};
+
+template <typename Point, std::size_t Count>
+struct stream_coordinate<Point, Count, Count>
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>&,
+            Point const&,
+            dsv_settings const& )
+    {
+    }
+};
+
+
+/*!
+\brief Stream indexed coordinate of a box/segment as \ref DSV
+*/
+template
+<
+    typename Geometry,
+    std::size_t Index,
+    std::size_t Dimension,
+    std::size_t Count
+>
+struct stream_indexed
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Geometry const& geometry,
+            dsv_settings const& settings)
+    {
+        os << (Dimension > 0 ? settings.coordinate_separator : "")
+            << get<Index, Dimension>(geometry);
+        stream_indexed
+            <
+                Geometry, Index, Dimension + 1, Count
+            >::apply(os, geometry, settings);
+    }
+};
+
+template <typename Geometry, std::size_t Index, std::size_t Count>
+struct stream_indexed<Geometry, Index, Count, Count>
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>&, Geometry const&,
+            dsv_settings const& )
+    {
+    }
+};
+
+
+
+/*!
+\brief Stream points as \ref DSV
+*/
+template <typename Point>
+struct dsv_point
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Point const& p,
+            dsv_settings const& settings)
+    {
+        os << settings.point_open;
+        stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p, settings);
+        os << settings.point_close;
+    }
+};
+
+/*!
+\brief Stream ranges as DSV
+\note policy is used to stream prefix/postfix, enabling derived classes to override this
+*/
+template <typename Range>
+struct dsv_range
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Range const& range,
+            dsv_settings const& settings)
+    {
+        typedef typename boost::range_iterator<Range const>::type iterator_type;
+
+        bool first = true;
+
+        os << settings.list_open;
+
+        for (iterator_type it = boost::begin(range);
+            it != boost::end(range);
+            ++it)
+        {
+            os << (first ? "" : settings.point_separator)
+                << settings.point_open;
+
+            stream_coordinate
+                <
+                    point_type, 0, dimension<point_type>::type::value
+                >::apply(os, *it, settings);
+            os << settings.point_close;
+
+            first = false;
+        }
+
+        os << settings.list_close;
+    }
+
+private:
+    typedef typename boost::range_value<Range>::type point_type;
+};
+
+/*!
+\brief Stream sequence of points as DSV-part, e.g. (1 2),(3 4)
+\note Used in polygon, all multi-geometries
+*/
+
+
+template <typename Polygon>
+struct dsv_poly
+{
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+                Polygon const& poly,
+                dsv_settings const& settings)
+    {
+        typedef typename ring_type<Polygon>::type ring;
+
+        os << settings.list_open;
+
+        dsv_range<ring>::apply(os, exterior_ring(poly), settings);
+
+        typename interior_return_type<Polygon const>::type rings
+                    = interior_rings(poly);
+        for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
+        {
+            os << settings.list_separator;
+            dsv_range<ring>::apply(os, *it, settings);
+        }
+        os << settings.list_close;
+    }
+};
+
+template <typename Geometry, std::size_t Index>
+struct dsv_per_index
+{
+    typedef typename point_type<Geometry>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Geometry const& geometry,
+            dsv_settings const& settings)
+    {
+        os << settings.point_open;
+        stream_indexed
+            <
+                Geometry, Index, 0, dimension<Geometry>::type::value
+            >::apply(os, geometry, settings);
+        os << settings.point_close;
+    }
+};
+
+
+template <typename Geometry>
+struct dsv_indexed
+{
+    typedef typename point_type<Geometry>::type point_type;
+
+    template <typename Char, typename Traits>
+    static inline void apply(std::basic_ostream<Char, Traits>& os,
+            Geometry const& geometry,
+            dsv_settings const& settings)
+    {
+        os << settings.list_open;
+        dsv_per_index<Geometry, 0>::apply(os, geometry, settings);
+        os << settings.point_separator;
+        dsv_per_index<Geometry, 1>::apply(os, geometry, settings);
+        os << settings.list_close;
+    }
+};
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct dsv {};
+
+
+template <typename Point>
+struct dsv<point_tag, Point>
+    : detail::dsv::dsv_point<Point>
+{};
+
+
+template <typename Linestring>
+struct dsv<linestring_tag, Linestring>
+    : detail::dsv::dsv_range<Linestring>
+{};
+
+
+template <typename Box>
+struct dsv<box_tag, Box>
+    : detail::dsv::dsv_indexed<Box>
+{};
+
+template <typename Segment>
+struct dsv<segment_tag, Segment>
+    : detail::dsv::dsv_indexed<Segment>
+{};
+
+
+template <typename Ring>
+struct dsv<ring_tag, Ring>
+    : detail::dsv::dsv_range<Ring>
+{};
+
+
+template <typename Polygon>
+struct dsv<polygon_tag, Polygon>
+    : detail::dsv::dsv_poly<Polygon>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv
+{
+
+
+// FIXME: This class is not copyable/assignable but it is used as such --mloskot
+template <typename Geometry>
+class dsv_manipulator
+{
+public:
+
+    inline dsv_manipulator(Geometry const& g,
+            dsv_settings const& settings)
+        : m_geometry(g)
+        , m_settings(settings)
+    {}
+
+    template <typename Char, typename Traits>
+    inline friend std::basic_ostream<Char, Traits>& operator<<(
+            std::basic_ostream<Char, Traits>& os,
+            dsv_manipulator const& m)
+    {
+        dispatch::dsv
+            <
+                typename tag_cast
+                    <
+                        typename tag<Geometry>::type,
+                        multi_tag
+                    >::type,
+                Geometry
+            >::apply(os, m.m_geometry, m.m_settings);
+        os.flush();
+        return os;
+    }
+
+private:
+    Geometry const& m_geometry;
+    dsv_settings m_settings;
+};
+
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief Main DSV-streaming function
+\details DSV stands for Delimiter Separated Values. Geometries can be streamed
+    as DSV. There are defaults for all separators.
+\note Useful for examples and testing purposes
+\note With this function GeoJSON objects can be created, using the right
+    delimiters
+\ingroup utility
+*/
+template <typename Geometry>
+inline detail::dsv::dsv_manipulator<Geometry> dsv(Geometry const& geometry
+    , std::string const& coordinate_separator = ", "
+    , std::string const& point_open = "("
+    , std::string const& point_close = ")"
+    , std::string const& point_separator = ", "
+    , std::string const& list_open = "("
+    , std::string const& list_close = ")"
+    , std::string const& list_separator = ", "
+    )
+{
+    concept::check<Geometry const>();
+
+    return detail::dsv::dsv_manipulator<Geometry>(geometry,
+        detail::dsv::dsv_settings(coordinate_separator,
+            point_open, point_close, point_separator,
+            list_open, list_close, list_separator));
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_WRITE_DSV_HPP
diff --git a/src/boost/geometry/views/box_view.hpp b/src/boost/geometry/views/box_view.hpp
new file mode 100644
index 0000000..26608b0
--- /dev/null
+++ b/src/boost/geometry/views/box_view.hpp
@@ -0,0 +1,114 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/views/detail/points_view.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief Makes a box behave like a ring or a range
+\details Adapts a box to the Boost.Range concept, enabling the user to iterating
+    box corners. The box_view is registered as a Ring Concept
+\tparam Box \tparam_geometry{Box}
+\tparam Clockwise If true, walks in clockwise direction, otherwise
+    it walks in counterclockwise direction
+\ingroup views
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_ring Ring Concept]
+}
+
+\qbk{[include reference/views/box_view.qbk]}
+*/
+template <typename Box, bool Clockwise = true>
+struct box_view 
+    : public detail::points_view
+        <
+            typename geometry::point_type<Box>::type, 
+            5
+        >
+{
+    typedef typename geometry::point_type<Box>::type point_type;
+    
+    /// Constructor accepting the box to adapt
+    explicit box_view(Box const& box)
+        : detail::points_view<point_type, 5>(copy_policy(box))
+    {}
+    
+private :    
+    
+    class copy_policy
+    {
+    public :
+        inline copy_policy(Box const& box)
+            : m_box(box)
+        {}
+        
+        inline void apply(point_type* points) const
+        {
+            detail::assign_box_corners_oriented<!Clockwise>(m_box, points);
+            points[4] = points[0];
+        }
+    private :
+        Box const& m_box;
+    };
+
+};
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+// All views on boxes are handled as rings
+namespace traits
+{
+
+template<typename Box, bool Clockwise>
+struct tag<box_view<Box, Clockwise> >
+{
+    typedef ring_tag type;
+};
+
+template<typename Box>
+struct point_order<box_view<Box, false> >
+{
+    static order_selector const value = counterclockwise;
+};
+
+
+template<typename Box>
+struct point_order<box_view<Box, true> >
+{
+    static order_selector const value = clockwise;
+};
+
+}
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_BOX_VIEW_HPP
diff --git a/src/boost/geometry/views/closeable_view.hpp b/src/boost/geometry/views/closeable_view.hpp
new file mode 100644
index 0000000..376246d
--- /dev/null
+++ b/src/boost/geometry/views/closeable_view.hpp
@@ -0,0 +1,100 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/iterators/closing_iterator.hpp>
+
+#include <boost/geometry/views/identity_view.hpp>
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+
+namespace detail
+{
+
+template <typename Range>
+struct closing_view
+{
+    // Keep this explicit, important for nested views/ranges
+    explicit inline closing_view(Range& r)
+        : m_range(r)
+    {}
+
+    typedef closing_iterator<Range> iterator;
+    typedef closing_iterator<Range const> const_iterator;
+
+    inline const_iterator begin() const { return const_iterator(m_range); }
+    inline const_iterator end() const { return const_iterator(m_range, true); }
+
+    inline iterator begin() { return iterator(m_range); }
+    inline iterator end() { return iterator(m_range, true); }
+private :
+    Range& m_range;
+};
+
+}
+
+#endif // DOXYGEN_NO_DETAIL
+
+
+/*!
+\brief View on a range, either closing it or leaving it as it is
+\details The closeable_view is used internally by the library to handle all rings,
+    either closed or open, the same way. The default method is closed, all 
+    algorithms process rings as if they are closed. Therefore, if they are opened,
+    a view is created which closes them.
+    The closeable_view might be used by library users, but its main purpose is
+    internally.
+\tparam Range Original range
+\tparam Close Specifies if it the range is closed, if so, nothing will happen.
+    If it is open, it will iterate the first point after the last point.
+\ingroup views
+*/
+template <typename Range, closure_selector Close>
+struct closeable_view {};
+
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+template <typename Range>
+struct closeable_view<Range, closed>
+{
+    typedef identity_view<Range> type;
+};
+
+
+template <typename Range>
+struct closeable_view<Range, open>
+{
+    typedef detail::closing_view<Range> type;
+};
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_CLOSEABLE_VIEW_HPP
diff --git a/src/boost/geometry/views/detail/points_view.hpp b/src/boost/geometry/views/detail/points_view.hpp
new file mode 100644
index 0000000..91fbc41
--- /dev/null
+++ b/src/boost/geometry/views/detail/points_view.hpp
@@ -0,0 +1,141 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_DETAIL_POINTS_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_DETAIL_POINTS_VIEW_HPP
+
+
+#include <boost/range.hpp>
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+
+#include <boost/geometry/core/exception.hpp>
+
+namespace boost { namespace geometry
+{
+
+namespace detail
+{
+
+// Adapts pointer, on points, to a Boost.Range
+template <typename Point, int MaxSize>
+class points_view
+{
+    // Iterates over a series of points (indicated by pointer
+    // to have it lightweight). Probably there is already an
+    // equivalent of this within Boost. If so, TODO: use that one.
+    // This used to be "box_iterator" and "segment_iterator".
+    struct points_iterator
+        : public boost::iterator_facade
+            <
+                points_iterator,
+                Point const,
+                boost::random_access_traversal_tag
+            >
+    {
+        // Constructor: Begin iterator
+        inline points_iterator(Point const* p)
+            : m_points(p)
+            , m_index(0) 
+        {}
+
+        // Constructor: End iterator
+        inline points_iterator(Point const* p, bool)
+            : m_points(p)
+            , m_index(MaxSize) 
+        {}
+
+        // Constructor: default (for Range Concept checking).
+        inline points_iterator()
+            : m_points(NULL)
+            , m_index(MaxSize) 
+        {}
+        
+        typedef std::ptrdiff_t difference_type;
+
+    private:
+        friend class boost::iterator_core_access;
+
+        inline Point const& dereference() const
+        {
+            if (m_index >= 0 && m_index < MaxSize)
+            {
+                return m_points[m_index];
+            }
+            
+            // If it index larger (or smaller) return first point
+            // (assuming initialized)
+            return m_points[0];
+        }
+
+        inline bool equal(points_iterator const& other) const
+        {
+            return other.m_index == this->m_index;
+        }
+
+        inline void increment()
+        {
+            m_index++;
+        }
+
+        inline void decrement()
+        {
+            m_index--;
+        }
+
+        inline difference_type distance_to(points_iterator const& other) const
+        {
+            return other.m_index - this->m_index;
+        }
+        
+        inline void advance(difference_type n)
+        {
+            m_index += n;
+        }
+
+        Point const* m_points;
+        int m_index;
+    };
+
+public :
+
+    typedef points_iterator const_iterator;
+    typedef points_iterator iterator; // must be defined
+
+    const_iterator begin() const { return const_iterator(m_points); }
+    const_iterator end() const { return const_iterator(m_points, true); }
+
+    // It may NOT be used non-const, so commented:
+    //iterator begin() { return m_begin; }
+    //iterator end() { return m_end; }
+
+protected :
+
+    template <typename CopyPolicy>
+    explicit points_view(CopyPolicy const& copy)
+    {
+       copy.apply(m_points);
+    }
+    
+private :    
+    // Copy points here - box might define them otherwise
+    Point m_points[MaxSize];
+};
+
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_DETAIL_POINTS_VIEW_HPP
diff --git a/src/boost/geometry/views/detail/range_type.hpp b/src/boost/geometry/views/detail/range_type.hpp
new file mode 100644
index 0000000..a40670c
--- /dev/null
+++ b/src/boost/geometry/views/detail/range_type.hpp
@@ -0,0 +1,106 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
+#define BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
+
+
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/views/box_view.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template <typename GeometryTag, typename Geometry>
+struct range_type
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
+            , (types<Geometry>)
+        );
+};
+
+
+template <typename Geometry>
+struct range_type<ring_tag, Geometry>
+{
+    typedef Geometry type;
+};
+
+template <typename Geometry>
+struct range_type<linestring_tag, Geometry>
+{
+    typedef Geometry type;
+};
+
+
+template <typename Geometry>
+struct range_type<polygon_tag, Geometry>
+{
+    typedef typename ring_type<Geometry>::type type;
+};
+
+template <typename Geometry>
+struct range_type<box_tag, Geometry>
+{
+    typedef box_view<Geometry> type;
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+// Will probably be replaced by the more generic "view_as", therefore in detail
+namespace detail
+{
+
+
+/*!
+\brief Meta-function defining a type which is a boost-range.
+\details
+- For linestrings and rings, it defines the type itself.
+- For polygons it defines the ring type.
+- For multi-points, it defines the type itself
+- For multi-polygons and multi-linestrings, it defines the single-version
+    (so in the end the linestring and ring-type-of-multi-polygon)
+\ingroup iterators
+*/
+template <typename Geometry>
+struct range_type
+{
+    typedef typename dispatch::range_type
+        <
+            typename tag<Geometry>::type,
+            Geometry
+        >::type type;
+};
+
+}
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_DETAIL_RANGE_TYPE_HPP
diff --git a/src/boost/geometry/views/identity_view.hpp b/src/boost/geometry/views/identity_view.hpp
new file mode 100644
index 0000000..5ce6e8e
--- /dev/null
+++ b/src/boost/geometry/views/identity_view.hpp
@@ -0,0 +1,53 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
+
+
+#include <boost/range.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief View on a range, not modifying anything
+\tparam Range original range
+\ingroup views
+*/
+template <typename Range>
+struct identity_view
+{
+    typedef typename boost::range_iterator<Range const>::type const_iterator;
+    typedef typename boost::range_iterator<Range>::type iterator;
+
+    explicit inline identity_view(Range& r)
+        : m_range(r)
+    {}
+
+    inline const_iterator begin() const { return boost::begin(m_range); }
+    inline const_iterator end() const { return boost::end(m_range); }
+
+    inline iterator begin() { return boost::begin(m_range); }
+    inline iterator end() { return boost::end(m_range); }
+private :
+    Range& m_range;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_IDENTITY_VIEW_HPP
diff --git a/src/boost/geometry/views/reversible_view.hpp b/src/boost/geometry/views/reversible_view.hpp
new file mode 100644
index 0000000..6d6dc0d
--- /dev/null
+++ b/src/boost/geometry/views/reversible_view.hpp
@@ -0,0 +1,74 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
+
+
+#include <boost/version.hpp>
+#include <boost/range.hpp>
+#include <boost/range/adaptor/reversed.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/geometry/views/identity_view.hpp>
+
+namespace boost { namespace geometry
+{
+
+/*!
+\brief Flag for iterating a reversible_view in forward or reverse direction
+\ingroup views
+*/
+enum iterate_direction { iterate_forward, iterate_reverse };
+
+/*!
+\brief View on a range, reversing direction if necessary
+\tparam Range original range
+\tparam Direction direction of iteration
+\ingroup views
+*/
+template <typename Range, iterate_direction Direction>
+struct reversible_view {};
+
+
+
+#ifndef DOXYGEN_NO_SPECIALIZATIONS
+
+template <typename Range>
+struct reversible_view<Range, iterate_forward>
+{
+    typedef identity_view<Range> type;
+};
+
+
+template <typename Range>
+struct reversible_view<Range, iterate_reverse>
+{
+//#if BOOST_VERSION > 104500
+    typedef boost::reversed_range<Range> type;
+/*#else
+    // For older versions of Boost
+    typedef boost::range_detail::reverse_range<Range> type;
+#endif
+*/};
+
+#endif // DOXYGEN_NO_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_REVERSIBLE_VIEW_HPP
diff --git a/src/boost/geometry/views/segment_view.hpp b/src/boost/geometry/views/segment_view.hpp
new file mode 100644
index 0000000..50ff617
--- /dev/null
+++ b/src/boost/geometry/views/segment_view.hpp
@@ -0,0 +1,100 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
+#define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
+
+
+#include <boost/range.hpp>
+
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/views/detail/points_view.hpp>
+#include <boost/geometry/algorithms/assign.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+/*!
+\brief Makes a segment behave like a linestring or a range
+\details Adapts a segment to the Boost.Range concept, enabling the user to 
+    iterate the two segment points. The segment_view is registered as a LineString Concept
+\tparam Segment \tparam_geometry{Segment}
+\ingroup views
+
+\qbk{before.synopsis,
+[heading Model of]
+[link geometry.reference.concepts.concept_linestring LineString Concept]
+}
+
+\qbk{[include reference/views/segment_view.qbk]}
+
+*/
+template <typename Segment>
+struct segment_view
+    : public detail::points_view
+        <
+            typename geometry::point_type<Segment>::type, 
+            2
+        >
+{
+    typedef typename geometry::point_type<Segment>::type point_type;
+    
+    /// Constructor accepting the segment to adapt
+    explicit segment_view(Segment const& segment)
+        : detail::points_view<point_type, 2>(copy_policy(segment))
+    {}
+    
+private :    
+    
+    class copy_policy
+    {
+    public :
+        inline copy_policy(Segment const& segment)
+            : m_segment(segment)
+        {}
+        
+        inline void apply(point_type* points) const
+        {
+            geometry::detail::assign_point_from_index<0>(m_segment, points[0]);
+            geometry::detail::assign_point_from_index<1>(m_segment, points[1]);
+        }
+    private :
+        Segment const& m_segment;
+    };
+
+};
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+// All segment ranges can be handled as linestrings
+namespace traits
+{
+
+template<typename Segment>
+struct tag<segment_view<Segment> >
+{
+    typedef linestring_tag type;
+};
+
+}
+
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
diff --git a/src/boost/range/adaptor/adjacent_filtered.hpp b/src/boost/range/adaptor/adjacent_filtered.hpp
new file mode 100644
index 0000000..f717cb3
--- /dev/null
+++ b/src/boost/range/adaptor/adjacent_filtered.hpp
@@ -0,0 +1,238 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_ADJACENT_FILTER_IMPL_HPP
+#define BOOST_RANGE_ADAPTOR_ADJACENT_FILTER_IMPL_HPP
+
+#include <boost/config.hpp>
+#ifdef BOOST_MSVC
+#pragma warning( push )
+#pragma warning( disable : 4355 )
+#endif
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/next_prior.hpp>
+
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class Iter, class Pred, bool default_pass >
+        class skip_iterator
+          : public boost::iterator_adaptor<
+                    skip_iterator<Iter,Pred,default_pass>,
+                    Iter,
+                    BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::value_type,
+                    boost::forward_traversal_tag,
+                    BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::reference,
+                    BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::difference_type
+                >
+          , private Pred
+        {
+        private:
+            typedef boost::iterator_adaptor<
+                        skip_iterator<Iter,Pred,default_pass>,
+                        Iter,
+                        BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::value_type,
+                        boost::forward_traversal_tag,
+                        BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::reference,
+                        BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::difference_type
+                    > base_t;
+
+        public:
+            typedef Pred pred_t;
+            typedef Iter iter_t;
+
+            skip_iterator() : m_last() {}
+
+            skip_iterator(iter_t it, iter_t last, const Pred& pred)
+                : base_t(it)
+                , pred_t(pred)
+                , m_last(last)
+            {
+                move_to_next_valid();
+            }
+
+            template<class OtherIter>
+            skip_iterator( const skip_iterator<OtherIter, pred_t, default_pass>& other )
+            : base_t(other.base())
+            , pred_t(other)
+            , m_last(other.m_last) {}
+
+            void move_to_next_valid()
+            {
+                iter_t& it = this->base_reference();
+                pred_t& bi_pred = *this;
+                if (it != m_last)
+                {
+                    if (default_pass)
+                    {
+                        iter_t nxt = ::boost::next(it);
+                        while (nxt != m_last && !bi_pred(*it, *nxt))
+                        {
+                            ++it;
+                            ++nxt;
+                        }
+                    }
+                    else
+                    {
+                        iter_t nxt = ::boost::next(it);
+                        for(; nxt != m_last; ++it, ++nxt)
+                        {
+                            if (bi_pred(*it, *nxt))
+                            {
+                                break;
+                            }
+                        }
+                        if (nxt == m_last)
+                        {
+                            it = m_last;
+                        }
+                    }
+                }
+            }
+
+            void increment()
+            {
+                iter_t& it = this->base_reference();
+                BOOST_ASSERT( it != m_last );
+                ++it;
+                move_to_next_valid();
+            }
+
+            iter_t m_last;
+        };
+
+        template< class P, class R, bool default_pass >
+        struct adjacent_filtered_range
+            : iterator_range< skip_iterator<
+                                BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
+                                P,
+                                default_pass
+                            >
+                        >
+        {
+        private:
+            typedef skip_iterator<
+                        BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
+                        P,
+                        default_pass
+                     >
+                skip_iter;
+
+            typedef iterator_range<skip_iter>
+                base_range;
+
+            typedef BOOST_DEDUCED_TYPENAME range_iterator<R>::type raw_iterator;
+
+        public:
+            adjacent_filtered_range( const P& p, R& r )
+            : base_range(skip_iter(boost::begin(r), boost::end(r), p),
+                         skip_iter(boost::end(r), boost::end(r), p))
+            {
+            }
+        };
+
+        template< class T >
+        struct adjacent_holder : holder<T>
+        {
+            adjacent_holder( T r ) : holder<T>(r)
+            { }
+        };
+
+        template< class T >
+        struct adjacent_excl_holder : holder<T>
+        {
+            adjacent_excl_holder( T r ) : holder<T>(r)
+            { }
+        };
+
+        template< class ForwardRng, class BinPredicate >
+        inline adjacent_filtered_range<BinPredicate, ForwardRng, true>
+        operator|( ForwardRng& r,
+                   const adjacent_holder<BinPredicate>& f )
+        {
+            return adjacent_filtered_range<BinPredicate, ForwardRng, true>( f.val, r );
+        }
+
+        template< class ForwardRng, class BinPredicate >
+        inline adjacent_filtered_range<BinPredicate, const ForwardRng, true>
+        operator|( const ForwardRng& r,
+                   const adjacent_holder<BinPredicate>& f )
+        {
+            return adjacent_filtered_range<BinPredicate,
+                                           const ForwardRng, true>( f.val, r );
+        }
+
+        template< class ForwardRng, class BinPredicate >
+        inline adjacent_filtered_range<BinPredicate, ForwardRng, false>
+        operator|( ForwardRng& r,
+                   const adjacent_excl_holder<BinPredicate>& f )
+        {
+            return adjacent_filtered_range<BinPredicate, ForwardRng, false>( f.val, r );
+        }
+
+        template< class ForwardRng, class BinPredicate >
+        inline adjacent_filtered_range<BinPredicate, ForwardRng, false>
+        operator|( const ForwardRng& r,
+                   const adjacent_excl_holder<BinPredicate>& f )
+        {
+            return adjacent_filtered_range<BinPredicate,
+                                           const ForwardRng, false>( f.val, r );
+        }
+
+    } // 'range_detail'
+
+    // Bring adjacent_filter_range into the boost namespace so that users of
+    // this library may specify the return type of the '|' operator and
+    // adjacent_filter()
+    using range_detail::adjacent_filtered_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::forwarder<range_detail::adjacent_holder>
+                adjacent_filtered =
+                   range_detail::forwarder<range_detail::adjacent_holder>();
+
+            const range_detail::forwarder<range_detail::adjacent_excl_holder>
+                adjacent_filtered_excl =
+                    range_detail::forwarder<range_detail::adjacent_excl_holder>();
+        }
+
+        template<class ForwardRng, class BinPredicate>
+        inline adjacent_filtered_range<BinPredicate, ForwardRng, true>
+        adjacent_filter(ForwardRng& rng, BinPredicate filter_pred)
+        {
+            return adjacent_filtered_range<BinPredicate, ForwardRng, true>(filter_pred, rng);
+        }
+
+        template<class ForwardRng, class BinPredicate>
+        inline adjacent_filtered_range<BinPredicate, const ForwardRng, true>
+        adjacent_filter(const ForwardRng& rng, BinPredicate filter_pred)
+        {
+            return adjacent_filtered_range<BinPredicate, const ForwardRng, true>(filter_pred, rng);
+        }
+
+    } // 'adaptors'
+
+}
+
+#ifdef BOOST_MSVC
+#pragma warning( pop )
+#endif
+
+#endif
diff --git a/src/boost/range/adaptor/argument_fwd.hpp b/src/boost/range/adaptor/argument_fwd.hpp
new file mode 100644
index 0000000..fbfd40c
--- /dev/null
+++ b/src/boost/range/adaptor/argument_fwd.hpp
@@ -0,0 +1,80 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_ARGUMENT_FWD_HPP
+#define BOOST_RANGE_ADAPTOR_ARGUMENT_FWD_HPP
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable : 4512) // assignment operator could not be generated
+#endif
+
+namespace boost
+{
+    namespace range_detail
+    {  
+        template< class T >
+        struct holder
+        {
+            T val;
+            holder( T t ) : val(t)
+            { }
+        };
+
+        template< class T >
+        struct holder2
+        {
+            T val1, val2;
+            holder2( T t, T u ) : val1(t), val2(u)
+            { }
+        };
+        
+        template< template<class> class Holder >
+        struct forwarder
+        {
+            template< class T >
+            Holder<T> operator()( T t ) const
+            {
+                return Holder<T>(t);
+            }
+        };
+
+        template< template<class> class Holder >
+        struct forwarder2
+        {
+            template< class T >
+            Holder<T> operator()( T t, T u ) const
+            {
+                return Holder<T>(t,u);
+            }
+        };
+
+        template< template<class,class> class Holder >
+        struct forwarder2TU
+        {
+            template< class T, class U >
+            Holder<T, U> operator()( T t, U u ) const
+            {
+                return Holder<T, U>(t, u);
+            }
+        };
+
+
+    } 
+        
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/src/boost/range/adaptor/copied.hpp b/src/boost/range/adaptor/copied.hpp
new file mode 100644
index 0000000..f4cf2d1
--- /dev/null
+++ b/src/boost/range/adaptor/copied.hpp
@@ -0,0 +1,58 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_COPIED_HPP
+#define BOOST_RANGE_ADAPTOR_COPIED_HPP
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/adaptor/sliced.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    namespace adaptors
+    {
+        struct copied
+        {
+            copied(std::size_t t_, std::size_t u_)
+                : t(t_), u(u_) {}
+
+            std::size_t t;
+            std::size_t u;
+        };
+
+        template< class CopyableRandomAccessRng >
+        inline CopyableRandomAccessRng
+        operator|( const CopyableRandomAccessRng& r, const copied& f )
+        {
+            iterator_range<
+                BOOST_DEDUCED_TYPENAME range_iterator<const
+                                               CopyableRandomAccessRng>::type >
+            temp( adaptors::slice( r, f.t, f.u ) );
+            return CopyableRandomAccessRng( temp.begin(), temp.end() );
+        }
+
+        template<class CopyableRandomAccessRange>
+        inline CopyableRandomAccessRange
+        copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u)
+        {
+            iterator_range<
+                BOOST_DEDUCED_TYPENAME range_iterator<const
+                    CopyableRandomAccessRange>::type> temp(
+                        adaptors::slice(rng, t, u));
+
+            return CopyableRandomAccessRange( temp.begin(), temp.end() );
+        }
+    } // 'adaptors'
+
+}
+
+#endif
diff --git a/src/boost/range/adaptor/define_adaptor.hpp b/src/boost/range/adaptor/define_adaptor.hpp
new file mode 100644
index 0000000..b228df3
--- /dev/null
+++ b/src/boost/range/adaptor/define_adaptor.hpp
@@ -0,0 +1,109 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED
+#define BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED
+
+#include <boost/tuple/tuple.hpp>
+
+#define BOOST_DEFINE_RANGE_ADAPTOR( adaptor_name, range_adaptor ) \
+    struct adaptor_name##_forwarder {}; \
+    \
+    template<typename Range> range_adaptor <Range> \
+        operator|(Range& rng, adaptor_name##_forwarder) \
+    { \
+        return range_adaptor <Range>( rng ); \
+    } \
+    \
+    template<typename Range> range_adaptor <const Range> \
+        operator|(const Range& rng, adaptor_name##_forwarder) \
+    { \
+        return range_adaptor <const Range>( rng ); \
+    } \
+    \
+    static adaptor_name##_forwarder adaptor_name = adaptor_name##_forwarder(); \
+    \
+    template<typename Range> \
+    range_adaptor <Range> \
+    make_##adaptor_name(Range& rng) \
+    { \
+        return range_adaptor <Range>(rng); \
+    } \
+    \
+    template<typename Range> \
+    range_adaptor <const Range> \
+    make_##adaptor_name(const Range& rng) \
+    { \
+        return range_adaptor <const Range>(rng); \
+    }
+
+#define BOOST_DEFINE_RANGE_ADAPTOR_1( adaptor_name, range_adaptor, arg1_type ) \
+    struct adaptor_name \
+    { \
+        explicit adaptor_name (arg1_type arg1_) \
+            : arg1(arg1_) {} \
+        arg1_type arg1; \
+    }; \
+    \
+    template<typename Range> range_adaptor <Range> \
+        operator|(Range& rng, adaptor_name args) \
+    { \
+        return range_adaptor <Range>(rng, args.arg1); \
+    } \
+    \
+    template<typename Range> range_adaptor <const Range> \
+        operator|(const Range& rng, adaptor_name args) \
+    { \
+        return range_adaptor <const Range>(rng, args.arg1); \
+    } \
+    \
+    template<typename Range> \
+    range_adaptor <Range> \
+    make_##adaptor_name(Range& rng, arg1_type arg1) \
+    { \
+        return range_adaptor <Range>(rng, arg1); \
+    } \
+    \
+    template<typename Range> \
+    range_adaptor <const Range> \
+    make_##adaptor_name(const Range& rng, arg1_type arg1) \
+    { \
+        return range_adaptor <const Range>(rng, arg1); \
+    }
+
+#define BOOST_RANGE_ADAPTOR_2( adaptor_name, range_adaptor, arg1_type, arg2_type ) \
+    struct adaptor_name \
+    { \
+        explicit adaptor_name (arg1_type arg1_, arg2_type arg2_) \
+            : arg1(arg1_), arg2(arg2_) {} \
+        arg1_type arg1; \
+        arg2_type arg2; \
+    }; \
+    \
+    template<typename Range> range_adaptor <Range> \
+    operator|(Range& rng, adaptor_name args) \
+    { \
+        return range_adaptor <Range>(rng, args.arg1, args.arg2); \
+    } \
+    template<typename Range> \
+    range_adaptor <Range> \
+    make_##adaptor_name(Range& rng, arg1_type arg1, arg2_type arg2) \
+    { \
+        return range_adaptor <Range>(rng, arg1, arg2); \
+    } \
+    template<typename Range> \
+    range_adaptor <const Range> \
+    make_##adaptor_name(const Range& rng, arg1_type arg1, arg2_type arg2) \
+    { \
+        return range_adaptor <const Range>(rng, arg1, arg2); \
+    }
+
+
+#endif // include guard
diff --git a/src/boost/range/adaptor/filtered.hpp b/src/boost/range/adaptor/filtered.hpp
new file mode 100644
index 0000000..d9315bd
--- /dev/null
+++ b/src/boost/range/adaptor/filtered.hpp
@@ -0,0 +1,101 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_FILTERED_HPP
+#define BOOST_RANGE_ADAPTOR_FILTERED_HPP
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/filter_iterator.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class P, class R >
+        struct filtered_range :
+            boost::iterator_range<
+                boost::filter_iterator< P,
+                    BOOST_DEDUCED_TYPENAME range_iterator<R>::type
+                >
+            >
+        {
+        private:
+            typedef boost::iterator_range<
+                        boost::filter_iterator< P,
+                            BOOST_DEDUCED_TYPENAME range_iterator<R>::type
+                        >
+                    > base;
+        public:
+            filtered_range( P p, R& r )
+            : base( make_filter_iterator( p, boost::begin(r), boost::end(r) ),
+                    make_filter_iterator( p, boost::end(r), boost::end(r) ) )
+            { }
+        };
+
+        template< class T >
+        struct filter_holder : holder<T>
+        {
+            filter_holder( T r ) : holder<T>(r)
+            { }
+        };
+
+        template< class InputRng, class Predicate >
+        inline filtered_range<Predicate, InputRng>
+        operator|( InputRng& r,
+                   const filter_holder<Predicate>& f )
+        {
+            return filtered_range<Predicate, InputRng>( f.val, r );
+        }
+
+        template< class InputRng, class Predicate >
+        inline filtered_range<Predicate, const InputRng>
+        operator|( const InputRng& r,
+                   const filter_holder<Predicate>& f )
+        {
+            return filtered_range<Predicate, const InputRng>( f.val, r );
+        }
+
+    } // 'range_detail'
+
+    // Unusual use of 'using' is intended to bring filter_range into the boost namespace
+    // while leaving the mechanics of the '|' operator in range_detail and maintain
+    // argument dependent lookup.
+    // filter_range logically needs to be in the boost namespace to allow user of
+    // the library to define the return type for filter()
+    using range_detail::filtered_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::forwarder<range_detail::filter_holder>
+                    filtered =
+                       range_detail::forwarder<range_detail::filter_holder>();
+        }
+
+        template<class InputRange, class Predicate>
+        inline filtered_range<Predicate, InputRange>
+        filter(InputRange& rng, Predicate filter_pred)
+        {
+            return range_detail::filtered_range<Predicate, InputRange>( filter_pred, rng );
+        }
+
+        template<class InputRange, class Predicate>
+        inline filtered_range<Predicate, const InputRange>
+        filter(const InputRange& rng, Predicate filter_pred)
+        {
+            return range_detail::filtered_range<Predicate, const InputRange>( filter_pred, rng );
+        }
+    } // 'adaptors'
+
+}
+
+#endif
diff --git a/src/boost/range/adaptor/indexed.hpp b/src/boost/range/adaptor/indexed.hpp
new file mode 100644
index 0000000..5a523ce
--- /dev/null
+++ b/src/boost/range/adaptor/indexed.hpp
@@ -0,0 +1,156 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_INDEXED_IMPL_HPP
+#define BOOST_RANGE_ADAPTOR_INDEXED_IMPL_HPP
+
+#include <boost/config.hpp>
+#ifdef BOOST_MSVC
+#pragma warning( push )
+#pragma warning( disable : 4355 )
+#endif
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+
+
+
+namespace boost
+{
+    namespace adaptors
+    {
+        // This structure exists to carry the parameters from the '|' operator
+        // to the index adapter. The expression rng | indexed(1) instantiates
+        // this structure and passes it as the right-hand operand to the
+        // '|' operator.
+        struct indexed
+        {
+            explicit indexed(std::size_t x) : val(x) {}
+            std::size_t val;
+        };
+    }
+
+    namespace range_detail
+    {
+        template< class Iter >
+        class indexed_iterator
+            : public boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
+        {
+        private:
+            typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
+                  base;
+
+            typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type;
+
+            index_type m_index;
+
+        public:
+            explicit indexed_iterator( Iter i, index_type index )
+            : base(i), m_index(index)
+            {
+                BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
+            }
+
+            index_type index() const
+            {
+                return m_index;
+            }
+
+         private:
+            friend class boost::iterator_core_access;
+
+            void increment()
+            {
+                ++m_index;
+                ++(this->base_reference());
+            }
+
+
+            void decrement()
+            {
+                BOOST_ASSERT( m_index > 0 && "Indexed Iterator out of bounds" );
+                --m_index;
+                --(this->base_reference());
+            }
+
+            void advance( index_type n )
+            {
+                m_index += n;
+                BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
+                this->base_reference() += n;
+            }
+        };
+
+        template< class Rng >
+        struct indexed_range :
+            iterator_range< indexed_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type> >
+        {
+        private:
+            typedef indexed_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type>
+                iter_type;
+            typedef iterator_range<iter_type>
+                base;
+        public:
+            template< class Index >
+            indexed_range( Index i, Rng& r )
+              : base( iter_type(boost::begin(r), i), iter_type(boost::end(r),i) )
+            { }
+        };
+
+    } // 'range_detail'
+
+    // Make this available to users of this library. It will sometimes be
+    // required since it is the return type of operator '|' and
+    // index().
+    using range_detail::indexed_range;
+
+    namespace adaptors
+    {
+        template< class SinglePassRange >
+        inline indexed_range<SinglePassRange>
+        operator|( SinglePassRange& r,
+                   const indexed& f )
+        {
+            return indexed_range<SinglePassRange>( f.val, r );
+        }
+
+        template< class SinglePassRange >
+        inline indexed_range<const SinglePassRange>
+        operator|( const SinglePassRange& r,
+                   const indexed& f )
+        {
+            return indexed_range<const SinglePassRange>( f.val, r );
+        }
+
+        template<class SinglePassRange, class Index>
+        inline indexed_range<SinglePassRange>
+        index(SinglePassRange& rng, Index index_value)
+        {
+            return indexed_range<SinglePassRange>(index_value, rng);
+        }
+
+        template<class SinglePassRange, class Index>
+        inline indexed_range<const SinglePassRange>
+        index(const SinglePassRange& rng, Index index_value)
+        {
+            return indexed_range<const SinglePassRange>(index_value, rng);
+        }
+    } // 'adaptors'
+
+}
+
+#ifdef BOOST_MSVC
+#pragma warning( pop )
+#endif
+
+#endif
diff --git a/src/boost/range/adaptor/indirected.hpp b/src/boost/range/adaptor/indirected.hpp
new file mode 100644
index 0000000..d7edc18
--- /dev/null
+++ b/src/boost/range/adaptor/indirected.hpp
@@ -0,0 +1,88 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_INDIRECTED_HPP
+#define BOOST_RANGE_ADAPTOR_INDIRECTED_HPP
+
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/indirect_iterator.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class R >
+        struct indirected_range :
+            public boost::iterator_range<
+                        boost::indirect_iterator<
+                            BOOST_DEDUCED_TYPENAME range_iterator<R>::type
+                        >
+                    >
+        {
+        private:
+            typedef boost::iterator_range<
+                        boost::indirect_iterator<
+                            BOOST_DEDUCED_TYPENAME range_iterator<R>::type
+                        >
+                    >
+                base;
+
+        public:
+            explicit indirected_range( R& r )
+                : base( r )
+            { }
+        };
+
+        struct indirect_forwarder {};
+
+        template< class InputRng >
+        inline indirected_range<InputRng>
+        operator|( InputRng& r, indirect_forwarder )
+        {
+            return indirected_range<InputRng>( r );
+        }
+
+        template< class InputRng >
+        inline indirected_range<const InputRng>
+        operator|( const InputRng& r, indirect_forwarder )
+        {
+            return indirected_range<const InputRng>( r );
+        }
+
+    } // 'range_detail'
+
+    using range_detail::indirected_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::indirect_forwarder indirected =
+                                            range_detail::indirect_forwarder();
+        }
+
+        template<class InputRange>
+        inline indirected_range<InputRange>
+        indirect(InputRange& rng)
+        {
+            return indirected_range<InputRange>(rng);
+        }
+
+        template<class InputRange>
+        inline indirected_range<const InputRange>
+        indirect(const InputRange& rng)
+        {
+            return indirected_range<const InputRange>(rng);
+        }
+    } // 'adaptors'
+
+}
+
+#endif
diff --git a/src/boost/range/adaptor/map.hpp b/src/boost/range/adaptor/map.hpp
new file mode 100644
index 0000000..ff8b97e
--- /dev/null
+++ b/src/boost/range/adaptor/map.hpp
@@ -0,0 +1,187 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_MAP_HPP
+#define BOOST_RANGE_ADAPTOR_MAP_HPP
+
+#include <boost/range/adaptor/transformed.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/reference.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        struct map_keys_forwarder {};
+        struct map_values_forwarder {};
+
+        template< class Map >
+        struct select_first
+        {
+            typedef BOOST_DEDUCED_TYPENAME range_reference<const Map>::type argument_type;
+            typedef const BOOST_DEDUCED_TYPENAME range_value<const Map>::type::first_type& result_type;
+
+            result_type operator()( argument_type r ) const
+            {
+                return r.first;
+            }
+        };
+
+        template< class Map >
+        struct select_second_mutable
+        {
+            typedef BOOST_DEDUCED_TYPENAME range_reference<Map>::type argument_type;
+            typedef BOOST_DEDUCED_TYPENAME range_value<Map>::type::second_type& result_type;
+
+            result_type operator()( argument_type r ) const
+            {
+                return r.second;
+            }
+        };
+
+        template< class Map >
+        struct select_second_const
+        {
+            typedef BOOST_DEDUCED_TYPENAME range_reference<const Map>::type argument_type;
+            typedef const BOOST_DEDUCED_TYPENAME range_value<const Map>::type::second_type& result_type;
+
+            result_type operator()( argument_type r ) const
+            {
+                return r.second;
+            }
+        };
+
+        template<class StdPairRng>
+        class select_first_range
+            : public transformed_range<
+                        select_first<StdPairRng>,
+                        const StdPairRng>
+        {
+            typedef transformed_range<select_first<StdPairRng>, const StdPairRng> base;
+        public:
+            typedef select_first<StdPairRng> transform_fn_type;
+            typedef const StdPairRng source_range_type;
+
+            select_first_range(transform_fn_type fn, source_range_type& rng)
+                : base(fn, rng)
+            {
+            }
+
+            select_first_range(const base& other) : base(other) {}
+        };
+
+        template<class StdPairRng>
+        class select_second_mutable_range
+            : public transformed_range<
+                        select_second_mutable<StdPairRng>,
+                        StdPairRng>
+        {
+            typedef transformed_range<select_second_mutable<StdPairRng>, StdPairRng> base;
+        public:
+            typedef select_second_mutable<StdPairRng> transform_fn_type;
+            typedef StdPairRng source_range_type;
+
+            select_second_mutable_range(transform_fn_type fn, source_range_type& rng)
+                : base(fn, rng)
+            {
+            }
+
+            select_second_mutable_range(const base& other) : base(other) {}
+        };
+
+        template<class StdPairRng>
+        class select_second_const_range
+            : public transformed_range<
+                        select_second_const<StdPairRng>,
+                        const StdPairRng>
+        {
+            typedef transformed_range<select_second_const<StdPairRng>, const StdPairRng> base;
+        public:
+            typedef select_second_const<StdPairRng> transform_fn_type;
+            typedef const StdPairRng source_range_type;
+
+            select_second_const_range(transform_fn_type fn, source_range_type& rng)
+                : base(fn, rng)
+            {
+            }
+
+            select_second_const_range(const base& other) : base(other) {}
+        };
+
+        template< class StdPairRng >
+        inline select_first_range<StdPairRng>
+        operator|( const StdPairRng& r, map_keys_forwarder )
+        {
+            return operator|( r,
+                boost::adaptors::transformed( select_first<StdPairRng>() ) );
+        }
+
+        template< class StdPairRng >
+        inline select_second_mutable_range<StdPairRng>
+        operator|( StdPairRng& r, map_values_forwarder )
+        {
+            return operator|( r,
+                boost::adaptors::transformed( select_second_mutable<StdPairRng>() ) );
+        }
+
+        template< class StdPairRng >
+        inline select_second_const_range<StdPairRng>
+        operator|( const StdPairRng& r, map_values_forwarder )
+        {
+            return operator|( r,
+                boost::adaptors::transformed( select_second_const<StdPairRng>() ) );
+        }
+
+    } // 'range_detail'
+
+    using range_detail::select_first_range;
+    using range_detail::select_second_mutable_range;
+    using range_detail::select_second_const_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::map_keys_forwarder map_keys =
+                                            range_detail::map_keys_forwarder();
+
+            const range_detail::map_values_forwarder map_values =
+                                           range_detail::map_values_forwarder();
+        }
+
+        template<class StdPairRange>
+        inline select_first_range<StdPairRange>
+        keys(const StdPairRange& rng)
+        {
+            return select_first_range<StdPairRange>(
+                range_detail::select_first<StdPairRange>(), rng );
+        }
+
+        template<class StdPairRange>
+        inline select_second_const_range<StdPairRange>
+        values(const StdPairRange& rng)
+        {
+            return select_second_const_range<StdPairRange>(
+                range_detail::select_second_const<StdPairRange>(), rng );
+        }
+
+        template<class StdPairRange>
+        inline select_second_mutable_range<StdPairRange>
+        values(StdPairRange& rng)
+        {
+            return select_second_mutable_range<StdPairRange>(
+                range_detail::select_second_mutable<StdPairRange>(), rng );
+        }
+    } // 'adaptors'
+
+}
+
+#endif
diff --git a/src/boost/range/adaptor/replaced.hpp b/src/boost/range/adaptor/replaced.hpp
new file mode 100644
index 0000000..deeb8da
--- /dev/null
+++ b/src/boost/range/adaptor/replaced.hpp
@@ -0,0 +1,134 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2007. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_REPLACED_IMPL_HPP_INCLUDED
+#define BOOST_RANGE_ADAPTOR_REPLACED_IMPL_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class Value >
+        class replace_value
+        {
+        public:
+            typedef const Value& result_type;
+            typedef const Value& first_argument_type;
+
+            replace_value(const Value& from, const Value& to)
+                :   m_from(from), m_to(to)
+            {
+            }
+
+            const Value& operator()(const Value& x) const
+            {
+                return (x == m_from) ? m_to : x;
+            }
+
+        private:
+            Value m_from;
+            Value m_to;
+        };
+
+        template< class R >
+        class replaced_range :
+            public boost::iterator_range<
+                boost::transform_iterator<
+                    replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type >,
+                    BOOST_DEDUCED_TYPENAME range_iterator<R>::type > >
+        {
+        private:
+            typedef replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type > Fn;
+
+            typedef boost::iterator_range<
+                boost::transform_iterator<
+                    replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type >,
+                    BOOST_DEDUCED_TYPENAME range_iterator<R>::type > > base_t;
+
+        public:
+            typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
+
+            replaced_range( R& r, value_type from, value_type to )
+                : base_t( make_transform_iterator( boost::begin(r), Fn(from, to) ),
+                          make_transform_iterator( boost::end(r), Fn(from, to) ) )
+            { }
+        };
+
+        template< class T >
+        class replace_holder : public holder2<T>
+        {
+        public:
+            replace_holder( const T& from, const T& to )
+                : holder2<T>(from, to)
+            { }
+        private:
+            // not assignable
+            void operator=(const replace_holder&);
+        };
+
+        template< class InputRng >
+        inline replaced_range<InputRng>
+        operator|( InputRng& r,
+                   const replace_holder<BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
+        {
+            return replaced_range<InputRng>(r, f.val1, f.val2);
+        }
+
+        template< class InputRng >
+        inline replaced_range<const InputRng>
+        operator|( const InputRng& r,
+                   const replace_holder<BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
+        {
+            return replaced_range<const InputRng>(r, f.val1, f.val2);
+        }
+    } // 'range_detail'
+
+    using range_detail::replaced_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::forwarder2<range_detail::replace_holder>
+                replaced =
+                    range_detail::forwarder2<range_detail::replace_holder>();
+        }
+
+        template<class InputRange>
+        inline replaced_range<InputRange>
+        replace(InputRange& rng,
+                BOOST_DEDUCED_TYPENAME range_value<InputRange>::type from,
+                BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
+        {
+            return replaced_range<InputRange>(rng, from, to);
+        }
+
+        template<class InputRange>
+        inline replaced_range<const InputRange>
+        replace(const InputRange& rng,
+                BOOST_DEDUCED_TYPENAME range_value<const InputRange>::type from,
+                BOOST_DEDUCED_TYPENAME range_value<const InputRange>::type to)
+        {
+            return replaced_range<const InputRange>(rng, from ,to);
+        }
+
+    } // 'adaptors'
+} // 'boost'
+
+#endif // include guard
diff --git a/src/boost/range/adaptor/replaced_if.hpp b/src/boost/range/adaptor/replaced_if.hpp
new file mode 100644
index 0000000..b514354
--- /dev/null
+++ b/src/boost/range/adaptor/replaced_if.hpp
@@ -0,0 +1,136 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2007. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_REPLACED_IF_IMPL_HPP_INCLUDED
+#define BOOST_RANGE_ADAPTOR_REPLACED_IF_IMPL_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class Pred, class Value >
+        class replace_value_if
+        {
+        public:
+            typedef const Value& result_type;
+            typedef const Value& first_argument_type;
+
+            replace_value_if(const Pred& pred, const Value& to)
+                :   m_pred(pred), m_to(to)
+            {
+            }
+
+            const Value& operator()(const Value& x) const
+            {
+                return m_pred(x) ? m_to : x;
+            }
+
+        private:
+            Pred  m_pred;
+            Value m_to;
+        };
+
+        template< class Pred, class R >
+        class replaced_if_range :
+            public boost::iterator_range<
+                boost::transform_iterator<
+                    replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
+                    BOOST_DEDUCED_TYPENAME range_iterator<R>::type > >
+        {
+        private:
+            typedef replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type > Fn;
+
+            typedef boost::iterator_range<
+                boost::transform_iterator<
+                    replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
+                    BOOST_DEDUCED_TYPENAME range_iterator<R>::type > > base_t;
+
+        public:
+            typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
+
+            replaced_if_range( R& r, const Pred& pred, value_type to )
+                : base_t( make_transform_iterator( boost::begin(r), Fn(pred, to) ),
+                          make_transform_iterator( boost::end(r), Fn(pred, to) ) )
+            { }
+        };
+
+        template< class Pred, class T >
+        class replace_if_holder
+        {
+        public:
+            replace_if_holder( const Pred& pred, const T& to )
+                : m_pred(pred), m_to(to)
+            { }
+
+            const Pred& pred() const { return m_pred; }
+            const T& to() const { return m_to; }
+
+        private:
+            Pred m_pred;
+            T m_to;
+        };
+
+        template< class Pred, class InputRng >
+        inline replaced_if_range<Pred, InputRng>
+        operator|( InputRng& r,
+                   const replace_if_holder<Pred, BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
+        {
+            return replaced_if_range<Pred, InputRng>(r, f.pred(), f.to());
+        }
+
+        template< class Pred, class InputRng >
+        inline replaced_if_range<Pred, const InputRng>
+        operator|( const InputRng& r,
+                   const replace_if_holder<Pred, BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
+        {
+            return replaced_if_range<Pred, const InputRng>(r, f.pred(), f.to());
+        }
+    } // 'range_detail'
+
+    using range_detail::replaced_if_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::forwarder2TU<range_detail::replace_if_holder>
+                replaced_if =
+                    range_detail::forwarder2TU<range_detail::replace_if_holder>();
+        }
+        
+        template<class Pred, class InputRange>
+        inline replaced_if_range<Pred, InputRange>
+        replace_if(InputRange& rng, Pred pred,
+                   BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
+        {
+            return range_detail::replaced_if_range<Pred, InputRange>(rng, pred, to);
+        }
+
+        template<class Pred, class InputRange>
+        inline replaced_if_range<Pred, const InputRange>
+        replace_if(const InputRange& rng, Pred pred,
+                   BOOST_DEDUCED_TYPENAME range_value<const InputRange>::type to)
+        {
+            return range_detail::replaced_if_range<Pred, const InputRange>(rng, pred, to);
+        }
+    } // 'adaptors'
+    
+} // 'boost'
+
+#endif // include guard
diff --git a/src/boost/range/adaptor/reversed.hpp b/src/boost/range/adaptor/reversed.hpp
new file mode 100644
index 0000000..c85eda8
--- /dev/null
+++ b/src/boost/range/adaptor/reversed.hpp
@@ -0,0 +1,90 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_REVERSED_HPP
+#define BOOST_RANGE_ADAPTOR_REVERSED_HPP
+
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/reverse_iterator.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class R >
+        struct reversed_range : 
+            public boost::iterator_range< 
+                      boost::reverse_iterator<
+                        BOOST_DEDUCED_TYPENAME range_iterator<R>::type 
+                                              >
+                                         >
+        {
+        private:
+            typedef boost::iterator_range< 
+                      boost::reverse_iterator<
+                        BOOST_DEDUCED_TYPENAME range_iterator<R>::type 
+                                              >
+                                         >
+                base;
+            
+        public:
+            typedef boost::reverse_iterator<BOOST_DEDUCED_TYPENAME range_iterator<R>::type> iterator;
+
+            explicit reversed_range( R& r ) 
+                : base( iterator(boost::end(r)), iterator(boost::begin(r)) )
+            { }
+        };
+
+        struct reverse_forwarder {};
+        
+        template< class BidirectionalRng >
+        inline reversed_range<BidirectionalRng> 
+        operator|( BidirectionalRng& r, reverse_forwarder )
+        {
+            return reversed_range<BidirectionalRng>( r );   
+        }
+    
+        template< class BidirectionalRng >
+        inline reversed_range<const BidirectionalRng> 
+        operator|( const BidirectionalRng& r, reverse_forwarder )
+        {
+            return reversed_range<const BidirectionalRng>( r );   
+        }
+        
+    } // 'range_detail'
+    
+    using range_detail::reversed_range;
+
+    namespace adaptors
+    { 
+        namespace
+        {
+            const range_detail::reverse_forwarder reversed = 
+                                            range_detail::reverse_forwarder();
+        }
+        
+        template<class BidirectionalRange>
+        inline reversed_range<BidirectionalRange>
+        reverse(BidirectionalRange& rng)
+        {
+            return reversed_range<BidirectionalRange>(rng);
+        }
+        
+        template<class BidirectionalRange>
+        inline reversed_range<const BidirectionalRange>
+        reverse(const BidirectionalRange& rng)
+        {
+            return reversed_range<const BidirectionalRange>(rng);
+        }
+    } // 'adaptors'
+    
+} // 'boost'
+
+#endif
diff --git a/src/boost/range/adaptor/sliced.hpp b/src/boost/range/adaptor/sliced.hpp
new file mode 100644
index 0000000..14ad986
--- /dev/null
+++ b/src/boost/range/adaptor/sliced.hpp
@@ -0,0 +1,82 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_SLICED_HPP
+#define BOOST_RANGE_ADAPTOR_SLICED_HPP
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    namespace adaptors
+    {
+        struct sliced
+        {
+            sliced(std::size_t t_, std::size_t u_)
+                : t(t_), u(u_) {}
+            std::size_t t;
+            std::size_t u;
+        };
+
+        template< class RandomAccessRange >
+        class sliced_range : public boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
+        {
+            typedef boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type > base_t;
+        public:
+            template<typename Rng, typename T, typename U>
+            sliced_range(Rng& rng, T t, U u)
+                : base_t(boost::make_iterator_range(rng, t, u - boost::size(rng)))
+            {
+            }
+        };
+
+        template< class RandomAccessRange >
+        inline sliced_range<RandomAccessRange>
+        slice( RandomAccessRange& rng, std::size_t t, std::size_t u )
+        {
+            BOOST_ASSERT( t <= u && "error in slice indices" );
+            BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
+                          "second slice index out of bounds" );
+
+            return sliced_range<RandomAccessRange>(rng, t, u);
+        }
+
+        template< class RandomAccessRange >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
+        slice( const RandomAccessRange& rng, std::size_t t, std::size_t u )
+        {
+            BOOST_ASSERT( t <= u && "error in slice indices" );
+            BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
+                          "second slice index out of bounds" );
+
+            return sliced_range<const RandomAccessRange>(rng, t, u);
+        }
+
+        template< class RandomAccessRange >
+        inline sliced_range<RandomAccessRange>
+        operator|( RandomAccessRange& r, const sliced& f )
+        {
+            return sliced_range<RandomAccessRange>( r, f.t, f.u );
+        }
+
+        template< class RandomAccessRange >
+        inline sliced_range<const RandomAccessRange>
+        operator|( const RandomAccessRange& r, const sliced& f )
+        {
+            return sliced_range<const RandomAccessRange>( r, f.t, f.u );
+        }
+
+    } // namespace adaptors
+    using adaptors::sliced_range;
+} // namespace boost
+
+#endif
diff --git a/src/boost/range/adaptor/strided.hpp b/src/boost/range/adaptor/strided.hpp
new file mode 100644
index 0000000..e843f62
--- /dev/null
+++ b/src/boost/range/adaptor/strided.hpp
@@ -0,0 +1,350 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2007. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ADAPTOR_STRIDED_HPP_INCLUDED
+#define BOOST_RANGE_ADAPTOR_STRIDED_HPP_INCLUDED
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <iterator>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        // strided_iterator for wrapping a forward traversal iterator
+        template<class BaseIterator, class Category>
+        class strided_iterator
+            : public iterator_adaptor<
+                strided_iterator<BaseIterator, Category>
+              , BaseIterator
+              , use_default
+              , boost::forward_traversal_tag
+            >
+        {
+            friend class ::boost::iterator_core_access;
+
+            typedef iterator_adaptor<
+                        strided_iterator<BaseIterator, Category>
+                      , BaseIterator
+                      , use_default
+                      , boost::forward_traversal_tag
+                    > super_t;
+
+        public:
+            typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
+            typedef BaseIterator base_iterator;
+
+            strided_iterator()
+                : m_last()
+                , m_stride()
+            {
+            }
+
+            strided_iterator(base_iterator first, base_iterator it, base_iterator last, difference_type stride)
+                : super_t(it)
+                , m_last(last)
+                , m_stride(stride)
+            {
+            }
+
+            template<class OtherIterator>
+            strided_iterator(const strided_iterator<OtherIterator, Category>& other,
+                             BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, base_iterator>::type* = 0)
+                : super_t(other)
+                , m_last(other.base_end())
+                , m_stride(other.get_stride())
+            {
+            }
+
+            base_iterator base_end() const { return m_last; }
+            difference_type get_stride() const { return m_stride; }
+
+        private:
+            void increment()
+            {
+                base_iterator& it = this->base_reference();
+                for (difference_type i = 0; (it != m_last) && (i < m_stride); ++i)
+                    ++it;
+            }
+
+            base_iterator m_last;
+            difference_type m_stride;
+        };
+
+        // strided_iterator for wrapping a bidirectional iterator
+        template<class BaseIterator>
+        class strided_iterator<BaseIterator, bidirectional_traversal_tag>
+            : public iterator_adaptor<
+                strided_iterator<BaseIterator, bidirectional_traversal_tag>
+              , BaseIterator
+              , use_default
+              , bidirectional_traversal_tag
+            >
+        {
+            friend class ::boost::iterator_core_access;
+
+            typedef iterator_adaptor<
+                        strided_iterator<BaseIterator, bidirectional_traversal_tag>
+                      , BaseIterator
+                      , use_default
+                      , bidirectional_traversal_tag
+                    > super_t;
+        public:
+            typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
+            typedef BaseIterator base_iterator;
+
+            strided_iterator()
+                : m_first()
+                , m_last()
+                , m_stride()
+            {
+            }
+
+            strided_iterator(base_iterator first, base_iterator it, base_iterator last, difference_type stride)
+                : super_t(it)
+                , m_first(first)
+                , m_last(last)
+                , m_stride(stride)
+            {
+            }
+
+            template<class OtherIterator>
+            strided_iterator(const strided_iterator<OtherIterator, bidirectional_traversal_tag>& other,
+                             BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, base_iterator>::type* = 0)
+                : super_t(other.base())
+                , m_first(other.base_begin())
+                , m_last(other.base_end())
+                , m_stride(other.get_stride())
+            {
+            }
+
+            base_iterator base_begin() const { return m_first; }
+            base_iterator base_end() const { return m_last; }
+            difference_type get_stride() const { return m_stride; }
+
+        private:
+            void increment()
+            {
+                base_iterator& it = this->base_reference();
+                for (difference_type i = 0; (it != m_last) && (i < m_stride); ++i)
+                    ++it;
+            }
+
+            void decrement()
+            {
+                base_iterator& it = this->base_reference();
+                for (difference_type i = 0; (it != m_first) && (i < m_stride); ++i)
+                    --it;
+            }
+
+            base_iterator m_first;
+            base_iterator m_last;
+            difference_type m_stride;
+        };
+
+        // strided_iterator implementation for wrapping a random access iterator
+        template<class BaseIterator>
+        class strided_iterator<BaseIterator, random_access_traversal_tag>
+            : public iterator_adaptor<
+                        strided_iterator<BaseIterator, random_access_traversal_tag>
+                      , BaseIterator
+                      , use_default
+                      , random_access_traversal_tag
+                    >
+        {
+            friend class ::boost::iterator_core_access;
+
+            typedef iterator_adaptor<
+                        strided_iterator<BaseIterator, random_access_traversal_tag>
+                      , BaseIterator
+                      , use_default
+                      , random_access_traversal_tag
+                    > super_t;
+        public:
+            typedef BOOST_DEDUCED_TYPENAME super_t::difference_type difference_type;
+            typedef BaseIterator base_iterator;
+
+            strided_iterator()
+                : m_first()
+                , m_last()
+                , m_index(0)
+                , m_stride()
+            {
+            }
+
+            strided_iterator(BaseIterator first, BaseIterator it, BaseIterator last, difference_type stride)
+                : super_t(it)
+                , m_first(first)
+                , m_last(last)
+                , m_index(stride ? (it - first) / stride : 0)
+                , m_stride(stride)
+            {
+            }
+
+            template<class OtherIterator>
+            strided_iterator(const strided_iterator<OtherIterator, random_access_traversal_tag>& other,
+                             BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, BaseIterator>::type* = 0)
+                : super_t(other.base())
+                , m_first(other.base_begin())
+                , m_last(other.base_end())
+                , m_index(other.get_index())
+                , m_stride(other.get_stride())
+            {
+            }
+
+            base_iterator base_begin() const { return m_first; }
+            base_iterator base_end() const { return m_last; }
+            difference_type get_stride() const { return m_stride; }
+            difference_type get_index() const { return m_index; }
+
+        private:
+            void increment()
+            {
+                m_index += m_stride;
+                if (m_index < (m_last - m_first))
+                    this->base_reference() = m_first + m_index;
+                else
+                    this->base_reference() = m_last;
+            }
+
+            void decrement()
+            {
+                m_index -= m_stride;
+                if (m_index >= 0)
+                    this->base_reference() = m_first + m_index;
+                else
+                    this->base_reference() = m_first;
+            }
+
+            void advance(difference_type offset)
+            {
+                offset *= m_stride;
+                m_index += offset;
+                if (m_index < 0)
+                    this->base_reference() = m_first;
+                else if (m_index > (m_last - m_first))
+                    this->base_reference() = m_last;
+                else
+                    this->base_reference() = m_first + m_index;
+            }
+
+            template<class OtherIterator>
+            difference_type distance_to(const strided_iterator<OtherIterator, random_access_traversal_tag>& other,
+                                        BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, BaseIterator>::type* = 0) const
+            {
+                if (other.base() >= this->base())
+                    return (other.base() - this->base() + (m_stride - 1)) / m_stride;
+                return (other.base() - this->base() - (m_stride - 1)) / m_stride;
+            }
+
+            bool equal(const strided_iterator& other) const
+            {
+                return this->base() == other.base();
+            }
+
+        private:
+            base_iterator m_first;
+            base_iterator m_last;
+            difference_type m_index;
+            difference_type m_stride;
+        };
+
+        template<class BaseIterator, class Difference> inline
+        strided_iterator<BaseIterator, BOOST_DEDUCED_TYPENAME iterator_traversal<BaseIterator>::type>
+        make_strided_iterator(BaseIterator first, BaseIterator it,
+                              BaseIterator last, Difference stride)
+        {
+            BOOST_ASSERT( stride >= 0 );
+            typedef BOOST_DEDUCED_TYPENAME iterator_traversal<BaseIterator>::type traversal_tag;
+            return strided_iterator<BaseIterator, traversal_tag>(first, it, last, stride);
+        }
+
+        template< class Rng
+                , class Category = BOOST_DEDUCED_TYPENAME iterator_traversal<
+                                    BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type
+                                   >::type
+         >
+        class strided_range
+            : public iterator_range<
+                        range_detail::strided_iterator<
+                            BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type,
+                            Category
+                        >
+                     >
+        {
+            typedef range_detail::strided_iterator<
+                        BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type,
+                        Category
+                    > iter_type;
+            typedef iterator_range<iter_type> super_t;
+        public:
+            template<class Difference>
+            strided_range(Difference stride, Rng& rng)
+                : super_t(make_strided_iterator(boost::begin(rng), boost::begin(rng), boost::end(rng), stride),
+                          make_strided_iterator(boost::begin(rng), boost::end(rng), boost::end(rng), stride))
+            {
+                BOOST_ASSERT( stride >= 0 );
+            }
+        };
+
+        template<class Difference>
+        class strided_holder : public holder<Difference>
+        {
+        public:
+            explicit strided_holder(Difference value) : holder<Difference>(value) {}
+        };
+
+        template<class Rng, class Difference>
+        inline strided_range<Rng>
+        operator|(Rng& rng, const strided_holder<Difference>& stride)
+        {
+            return strided_range<Rng>(stride.val, rng);
+        }
+
+        template<class Rng, class Difference>
+        inline strided_range<const Rng>
+        operator|(const Rng& rng, const strided_holder<Difference>& stride)
+        {
+            return strided_range<const Rng>(stride.val, rng);
+        }
+
+    } // namespace range_detail
+
+    using range_detail::strided_range;
+
+    namespace adaptors
+    {
+
+        namespace
+        {
+            const range_detail::forwarder<range_detail::strided_holder>
+                strided = range_detail::forwarder<range_detail::strided_holder>();
+        }
+
+        template<class Range, class Difference>
+        inline strided_range<Range>
+        stride(Range& rng, Difference step)
+        {
+            return strided_range<Range>(step, rng);
+        }
+
+        template<class Range, class Difference>
+        inline strided_range<const Range>
+        stride(const Range& rng, Difference step)
+        {
+            return strided_range<const Range>(step, rng);
+        }
+
+    } // namespace 'adaptors'
+} // namespace 'boost'
+
+#endif
diff --git a/src/boost/range/adaptor/tokenized.hpp b/src/boost/range/adaptor/tokenized.hpp
new file mode 100644
index 0000000..8a7402a
--- /dev/null
+++ b/src/boost/range/adaptor/tokenized.hpp
@@ -0,0 +1,137 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_TOKENIZED_HPP
+#define BOOST_RANGE_ADAPTOR_TOKENIZED_HPP
+
+#include <boost/regex.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+
+        template< class R >
+        struct tokenized_range : 
+            public boost::iterator_range< 
+                      boost::regex_token_iterator< 
+                          BOOST_DEDUCED_TYPENAME range_iterator<R>::type 
+                                              >
+                                         >
+        {
+        private:
+            typedef           
+                boost::regex_token_iterator< 
+                          BOOST_DEDUCED_TYPENAME range_iterator<R>::type 
+                                            >
+                regex_iter;
+            
+            typedef BOOST_DEDUCED_TYPENAME regex_iter::regex_type 
+                regex_type;
+        
+            typedef boost::iterator_range<regex_iter> 
+                base;
+
+        public:
+            template< class Regex, class Submatch, class Flag >
+            tokenized_range( R& r, const Regex& re, const Submatch& sub, Flag f )
+              : base( regex_iter( boost::begin(r), boost::end(r), 
+                                  regex_type(re), sub, f ),
+                      regex_iter() )
+            { }
+        };
+
+        template< class T, class U, class V >
+        struct regex_holder
+        {
+            const T&  re;
+            const U&  sub;
+            V         f;
+
+            regex_holder( const T& rex, const U& subm, V flag ) :
+                re(rex), sub(subm), f(flag)
+            { }
+        private:
+            // Not assignable
+            void operator=(const regex_holder&);
+        };
+
+        struct regex_forwarder
+        {           
+            template< class Regex >
+            regex_holder<Regex,int,regex_constants::match_flag_type>
+            operator()( const Regex& re, 
+                        int submatch = 0,    
+                        regex_constants::match_flag_type f = 
+                            regex_constants::match_default ) const
+            {
+                return regex_holder<Regex,int,
+                           regex_constants::match_flag_type>( re, submatch, f );
+            }
+             
+            template< class Regex, class Submatch >
+            regex_holder<Regex,Submatch,regex_constants::match_flag_type> 
+            operator()( const Regex& re, 
+                        const Submatch& sub, 
+                        regex_constants::match_flag_type f = 
+                            regex_constants::match_default ) const
+            {
+                return regex_holder<Regex,Submatch,
+                           regex_constants::match_flag_type>( re, sub, f ); 
+            }
+        };
+        
+        template< class BidirectionalRng, class R, class S, class F >
+        inline tokenized_range<BidirectionalRng> 
+        operator|( BidirectionalRng& r, 
+                   const regex_holder<R,S,F>& f )
+        {
+            return tokenized_range<BidirectionalRng>( r, f.re, f.sub, f.f );   
+        }
+
+        template< class BidirectionalRng, class R, class S, class F  >
+        inline tokenized_range<const BidirectionalRng> 
+        operator|( const BidirectionalRng& r, 
+                   const regex_holder<R,S,F>& f )
+        {
+            return tokenized_range<const BidirectionalRng>( r, f.re, f.sub, f.f );
+        }
+        
+    } // 'range_detail'
+
+    using range_detail::tokenized_range;
+
+    namespace adaptors
+    { 
+        namespace
+        {
+            const range_detail::regex_forwarder tokenized = 
+                    range_detail::regex_forwarder();
+        }
+        
+        template<class BidirectionalRange, class Regex, class Submatch, class Flag>
+        inline tokenized_range<BidirectionalRange>
+        tokenize(BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
+        {
+            return tokenized_range<BidirectionalRange>(rng, reg, sub, f);
+        }
+        
+        template<class BidirectionalRange, class Regex, class Submatch, class Flag>
+        inline tokenized_range<const BidirectionalRange>
+        tokenize(const BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
+        {
+            return tokenized_range<const BidirectionalRange>(rng, reg, sub, f);
+        }
+    } // 'adaptors'
+    
+}
+
+#endif
diff --git a/src/boost/range/adaptor/transformed.hpp b/src/boost/range/adaptor/transformed.hpp
new file mode 100644
index 0000000..96d2dab
--- /dev/null
+++ b/src/boost/range/adaptor/transformed.hpp
@@ -0,0 +1,104 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_TRANSFORMED_HPP
+#define BOOST_RANGE_ADAPTOR_TRANSFORMED_HPP
+
+#include <boost/range/adaptor/argument_fwd.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/utility/result_of.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+
+        template< class F, class R >
+        struct transformed_range :
+            public boost::iterator_range<
+                      boost::transform_iterator< F,
+                          BOOST_DEDUCED_TYPENAME range_iterator<R>::type
+                                              >
+                                         >
+        {
+        private:
+            typedef boost::iterator_range<
+                      boost::transform_iterator< F,
+                        BOOST_DEDUCED_TYPENAME range_iterator<R>::type
+                                              >
+                                         >
+                base;
+
+        public:
+            typedef F transform_fn_type;
+            typedef R source_range_type;
+
+            transformed_range( F f, R& r )
+                : base( boost::make_transform_iterator( boost::begin(r), f ),
+                        boost::make_transform_iterator( boost::end(r), f ) )
+
+            { }
+        };
+
+        template< class T >
+        struct transform_holder : holder<T>
+        {
+            transform_holder( T r ) : holder<T>(r)
+            { }
+        };
+
+        template< class InputRng, class UnaryFunction >
+        inline transformed_range<UnaryFunction,InputRng>
+        operator|( InputRng& r,
+                   const transform_holder<UnaryFunction>& f )
+        {
+            return transformed_range<UnaryFunction,InputRng>( f.val, r );
+        }
+
+        template< class InputRng, class UnaryFunction >
+        inline transformed_range<UnaryFunction, const InputRng>
+        operator|( const InputRng& r,
+                   const transform_holder<UnaryFunction>& f )
+        {
+           return transformed_range<UnaryFunction, const InputRng>( f.val, r );
+        }
+
+    } // 'range_detail'
+
+    using range_detail::transformed_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::forwarder<range_detail::transform_holder>
+                    transformed =
+                      range_detail::forwarder<range_detail::transform_holder>();
+        }
+
+        template<class UnaryFunction, class InputRange>
+        inline transformed_range<UnaryFunction, InputRange>
+        transform(InputRange& rng, UnaryFunction fn)
+        {
+            return transformed_range<UnaryFunction, InputRange>(fn, rng);
+        }
+
+        template<class UnaryFunction, class InputRange>
+        inline transformed_range<UnaryFunction, const InputRange>
+        transform(const InputRange& rng, UnaryFunction fn)
+        {
+            return transformed_range<UnaryFunction, const InputRange>(fn, rng);
+        }
+    } // 'adaptors'
+
+}
+
+#endif
diff --git a/src/boost/range/adaptor/type_erased.hpp b/src/boost/range/adaptor/type_erased.hpp
new file mode 100644
index 0000000..80bc712
--- /dev/null
+++ b/src/boost/range/adaptor/type_erased.hpp
@@ -0,0 +1,184 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ADAPTOR_TYPE_ERASED_HPP_INCLUDED
+#define BOOST_RANGE_ADAPTOR_TYPE_ERASED_HPP_INCLUDED
+
+#include <boost/range/reference.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/iterator_range_core.hpp>
+#include <boost/range/any_range.hpp>
+#include <boost/cast.hpp>
+
+namespace boost
+{
+    namespace adaptors
+    {
+        template<
+            class Value = use_default
+          , class Traversal = use_default
+          , class Reference = use_default
+          , class Difference = use_default
+          , class Buffer = use_default
+        >
+        struct type_erased
+        {
+        };
+
+        template<
+            class SinglePassRange
+          , class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        typename any_range_type_generator<
+            SinglePassRange
+          , Value
+          , Traversal
+          , Reference
+          , Difference
+          , Buffer
+        >::type
+        operator|(SinglePassRange& rng,
+                  type_erased<
+                        Value
+                      , Traversal
+                      , Reference
+                      , Difference
+                      , Buffer
+                    >)
+        {
+            typedef typename any_range_type_generator<
+                SinglePassRange
+              , Value
+              , Traversal
+              , Reference
+              , Difference
+              , Buffer
+            >::type range_type;
+            return range_type(boost::begin(rng), boost::end(rng));
+        }
+
+        template<
+            class SinglePassRange
+          , class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        typename any_range_type_generator<
+            const SinglePassRange
+          , Value
+          , Traversal
+          , Reference
+          , Difference
+          , Buffer
+        >::type
+        operator|(const SinglePassRange& rng,
+                  type_erased<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , Buffer
+                    >)
+        {
+            typedef typename any_range_type_generator<
+                const SinglePassRange
+              , Value
+              , Traversal
+              , Reference
+              , Difference
+              , Buffer
+            >::type range_type;
+            return range_type(boost::begin(rng), boost::end(rng));
+        }
+
+        template<
+            class SinglePassRange
+          , class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        typename any_range_type_generator<
+            SinglePassRange
+          , Value
+          , Traversal
+          , Reference
+          , Difference
+          , Buffer
+        >::type
+        type_erase(SinglePassRange& rng
+                 , type_erased<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , Buffer
+                    > = type_erased<>()
+                )
+        {
+            typedef typename any_range_type_generator<
+                SinglePassRange
+              , Value
+              , Traversal
+              , Reference
+              , Difference
+              , Buffer
+            >::type range_type;
+
+            return range_type(boost::begin(rng), boost::end(rng));
+        }
+
+        template<
+            class SinglePassRange
+          , class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        typename any_range_type_generator<
+            const SinglePassRange
+          , Value
+          , Traversal
+          , Reference
+          , Difference
+          , Buffer
+        >::type
+        type_erase(const SinglePassRange& rng
+                 , type_erased<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , Buffer
+                    > = type_erased<>()
+                )
+        {
+            typedef typename any_range_type_generator<
+                const SinglePassRange
+              , Value
+              , Traversal
+              , Reference
+              , Difference
+              , Buffer
+            >::type range_type;
+
+            return range_type(boost::begin(rng), boost::end(rng));
+        }
+    }
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/adaptor/uniqued.hpp b/src/boost/range/adaptor/uniqued.hpp
new file mode 100644
index 0000000..40c8249
--- /dev/null
+++ b/src/boost/range/adaptor/uniqued.hpp
@@ -0,0 +1,90 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP
+#define BOOST_RANGE_ADAPTOR_UNIQUED_IMPL_HPP
+
+#include <boost/range/adaptor/adjacent_filtered.hpp>
+
+namespace boost
+{
+
+    namespace range_detail
+    {
+        struct unique_forwarder { };
+
+        struct unique_not_equal_to
+        {
+            typedef bool result_type;
+
+            template< class T >
+            bool operator()( const T& l, const T& r ) const
+            {
+                return !(l == r);
+            }
+        };
+
+        template<class ForwardRng>
+        class uniqued_range : public adjacent_filtered_range<unique_not_equal_to, ForwardRng, true>
+        {
+            typedef adjacent_filtered_range<unique_not_equal_to, ForwardRng, true> base;
+        public:
+            explicit uniqued_range(ForwardRng& rng)
+                : base(unique_not_equal_to(), rng)
+            {
+            }
+        };
+
+        template< class ForwardRng >
+        inline uniqued_range<ForwardRng>
+        operator|( ForwardRng& r,
+                   unique_forwarder )
+        {
+            return uniqued_range<ForwardRng>(r);
+        }
+
+        template< class ForwardRng >
+        inline uniqued_range<const ForwardRng>
+        operator|( const ForwardRng& r,
+                   unique_forwarder )
+        {
+            return uniqued_range<const ForwardRng>(r);
+        }
+
+    } // 'range_detail'
+
+    using range_detail::uniqued_range;
+
+    namespace adaptors
+    {
+        namespace
+        {
+            const range_detail::unique_forwarder uniqued =
+                       range_detail::unique_forwarder();
+        }
+
+        template<class ForwardRange>
+        inline uniqued_range<ForwardRange>
+        unique(ForwardRange& rng)
+        {
+            return uniqued_range<ForwardRange>(rng);
+        }
+
+        template<class ForwardRange>
+        inline uniqued_range<const ForwardRange>
+        unique(const ForwardRange& rng)
+        {
+            return uniqued_range<const ForwardRange>(rng);
+        }
+    } // 'adaptors'
+
+}
+
+#endif
diff --git a/src/boost/range/adaptors.hpp b/src/boost/range/adaptors.hpp
new file mode 100644
index 0000000..92062a9
--- /dev/null
+++ b/src/boost/range/adaptors.hpp
@@ -0,0 +1,30 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2007.
+//  Copyright Thorsten Ottosen 2006.
+//  Use, modification and distribution is subject to the Boost Software
+//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ADAPTORS_HPP
+#define BOOST_RANGE_ADAPTORS_HPP
+
+#include <boost/range/adaptor/adjacent_filtered.hpp>
+#include <boost/range/adaptor/copied.hpp>
+#include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/adaptor/indexed.hpp>
+#include <boost/range/adaptor/indirected.hpp>
+#include <boost/range/adaptor/map.hpp>
+#include <boost/range/adaptor/replaced.hpp>
+#include <boost/range/adaptor/replaced_if.hpp>
+#include <boost/range/adaptor/reversed.hpp>
+#include <boost/range/adaptor/sliced.hpp>
+#include <boost/range/adaptor/strided.hpp>
+#include <boost/range/adaptor/tokenized.hpp>
+#include <boost/range/adaptor/transformed.hpp>
+#include <boost/range/adaptor/uniqued.hpp>
+
+#endif
diff --git a/src/boost/range/algorithm.hpp b/src/boost/range/algorithm.hpp
new file mode 100644
index 0000000..b7d8dd7
--- /dev/null
+++ b/src/boost/range/algorithm.hpp
@@ -0,0 +1,104 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file algorithm.hpp
+///   Includes the range-based versions of the algorithms in the
+///   C++ standard header file <algorithm>
+//
+/////////////////////////////////////////////////////////////////////////////
+
+// Copyright 2009 Neil Groves.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// Acknowledgements:
+// This code uses combinations of ideas, techniques and code snippets
+// from: Thorsten Ottosen, Eric Niebler, Jeremy Siek,
+// and Vladimir Prus'
+//
+// The original mutating algorithms that served as the first version
+// were originally written by Vladimir Prus'
+// <ghost at cs.msu.su> code from Boost Wiki
+
+#if defined(_MSC_VER) && _MSC_VER >= 1000
+#pragma once
+#endif
+
+#ifndef BOOST_RANGE_ALGORITHM_HPP_INCLUDED_01012009
+#define BOOST_RANGE_ALGORITHM_HPP_INCLUDED_01012009
+
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/next_prior.hpp>
+#include <algorithm>
+
+// Non-mutating algorithms
+#include <boost/range/algorithm/adjacent_find.hpp>
+#include <boost/range/algorithm/count.hpp>
+#include <boost/range/algorithm/count_if.hpp>
+#include <boost/range/algorithm/equal.hpp>
+#include <boost/range/algorithm/for_each.hpp>
+#include <boost/range/algorithm/find.hpp>
+#include <boost/range/algorithm/find_end.hpp>
+#include <boost/range/algorithm/find_first_of.hpp>
+#include <boost/range/algorithm/find_if.hpp>
+#include <boost/range/algorithm/lexicographical_compare.hpp>
+#include <boost/range/algorithm/mismatch.hpp>
+#include <boost/range/algorithm/search.hpp>
+#include <boost/range/algorithm/search_n.hpp>
+
+// Mutating algorithms
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/range/algorithm/copy_backward.hpp>
+#include <boost/range/algorithm/fill.hpp>
+#include <boost/range/algorithm/fill_n.hpp>
+#include <boost/range/algorithm/generate.hpp>
+#include <boost/range/algorithm/inplace_merge.hpp>
+#include <boost/range/algorithm/merge.hpp>
+#include <boost/range/algorithm/nth_element.hpp>
+#include <boost/range/algorithm/partial_sort.hpp>
+#include <boost/range/algorithm/partial_sort_copy.hpp>
+#include <boost/range/algorithm/partition.hpp>
+#include <boost/range/algorithm/random_shuffle.hpp>
+#include <boost/range/algorithm/remove.hpp>
+#include <boost/range/algorithm/remove_copy.hpp>
+#include <boost/range/algorithm/remove_copy_if.hpp>
+#include <boost/range/algorithm/remove_if.hpp>
+#include <boost/range/algorithm/replace.hpp>
+#include <boost/range/algorithm/replace_copy.hpp>
+#include <boost/range/algorithm/replace_copy_if.hpp>
+#include <boost/range/algorithm/replace_if.hpp>
+#include <boost/range/algorithm/reverse.hpp>
+#include <boost/range/algorithm/reverse_copy.hpp>
+#include <boost/range/algorithm/rotate.hpp>
+#include <boost/range/algorithm/rotate_copy.hpp>
+#include <boost/range/algorithm/sort.hpp>
+#include <boost/range/algorithm/stable_partition.hpp>
+#include <boost/range/algorithm/stable_sort.hpp>
+#include <boost/range/algorithm/transform.hpp>
+#include <boost/range/algorithm/unique.hpp>
+#include <boost/range/algorithm/unique_copy.hpp>
+
+// Binary search
+#include <boost/range/algorithm/binary_search.hpp>
+#include <boost/range/algorithm/equal_range.hpp>
+#include <boost/range/algorithm/lower_bound.hpp>
+#include <boost/range/algorithm/upper_bound.hpp>
+
+// Set operations of sorted ranges
+#include <boost/range/algorithm/set_algorithm.hpp>
+
+// Heap operations
+#include <boost/range/algorithm/heap_algorithm.hpp>
+
+// Minimum and Maximum
+#include <boost/range/algorithm/max_element.hpp>
+#include <boost/range/algorithm/min_element.hpp>
+
+// Permutations
+#include <boost/range/algorithm/permutation.hpp>
+
+#endif // include guard
+
diff --git a/src/boost/range/algorithm/adjacent_find.hpp b/src/boost/range/algorithm/adjacent_find.hpp
new file mode 100644
index 0000000..1b88dae
--- /dev/null
+++ b/src/boost/range/algorithm/adjacent_find.hpp
@@ -0,0 +1,125 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_ADJACENT_FIND_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function adjacent_find
+///
+/// range-based version of the adjacent_find std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template< typename ForwardRange >
+inline typename range_iterator<ForwardRange>::type
+adjacent_find(ForwardRange & rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return std::adjacent_find(boost::begin(rng),boost::end(rng));
+}
+
+/// \overload
+template< typename ForwardRange >
+inline typename range_iterator<const ForwardRange>::type
+adjacent_find(const ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return std::adjacent_find(boost::begin(rng),boost::end(rng));
+}
+
+/// \overload
+template< typename ForwardRange, typename BinaryPredicate >
+inline typename range_iterator<ForwardRange>::type
+adjacent_find(ForwardRange & rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        typename range_value<ForwardRange>::type,
+        typename range_value<ForwardRange>::type>));
+    return std::adjacent_find(boost::begin(rng),boost::end(rng),pred);
+}
+
+/// \overload
+template< typename ForwardRange, typename BinaryPredicate >
+inline typename range_iterator<const ForwardRange>::type
+adjacent_find(const ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        typename range_value<const ForwardRange>::type,
+        typename range_value<const ForwardRange>::type>));
+    return std::adjacent_find(boost::begin(rng),boost::end(rng),pred);
+}
+
+//  range_return overloads
+
+/// \overload
+template< range_return_value re, typename ForwardRange >
+inline typename range_return<ForwardRange,re>::type
+adjacent_find(ForwardRange & rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return range_return<ForwardRange,re>::
+        pack(std::adjacent_find(boost::begin(rng),boost::end(rng)),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, typename ForwardRange >
+inline typename range_return<const ForwardRange,re>::type
+adjacent_find(const ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return range_return<const ForwardRange,re>::
+        pack(std::adjacent_find(boost::begin(rng),boost::end(rng)),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, typename ForwardRange, typename BinaryPredicate >
+inline typename range_return<ForwardRange,re>::type
+adjacent_find(ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        typename range_value<ForwardRange>::type,
+        typename range_value<ForwardRange>::type>));
+    return range_return<ForwardRange,re>::
+        pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, typename ForwardRange, typename BinaryPredicate >
+inline typename range_return<const ForwardRange,re>::type
+adjacent_find(const ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return range_return<const ForwardRange,re>::
+        pack(std::adjacent_find(boost::begin(rng),boost::end(rng),pred),
+             rng);
+}
+
+    } // namespace range
+    using range::adjacent_find;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/binary_search.hpp b/src/boost/range/algorithm/binary_search.hpp
new file mode 100644
index 0000000..bb64ec8
--- /dev/null
+++ b/src/boost/range/algorithm/binary_search.hpp
@@ -0,0 +1,49 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_BINARY_SEARCH_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_BINARY_SEARCH_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function binary_search
+///
+/// range-based version of the binary_search std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class ForwardRange, class Value>
+inline bool binary_search(const ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::binary_search(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template<class ForwardRange, class Value, class BinaryPredicate>
+inline bool binary_search(const ForwardRange& rng, const Value& val,
+                          BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::binary_search(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+    } // namespace range
+    using range::binary_search;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/copy.hpp b/src/boost/range/algorithm/copy.hpp
new file mode 100644
index 0000000..f15b31f
--- /dev/null
+++ b/src/boost/range/algorithm/copy.hpp
@@ -0,0 +1,41 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function copy
+///
+/// range-based version of the copy std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre OutputIterator is a model of the OutputIteratorConcept
+template< class SinglePassRange, class OutputIterator >
+inline OutputIterator copy(const SinglePassRange& rng, OutputIterator out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::copy(boost::begin(rng),boost::end(rng),out);
+}
+
+    } // namespace range
+    using range::copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/copy_backward.hpp b/src/boost/range/algorithm/copy_backward.hpp
new file mode 100644
index 0000000..c95c6f1
--- /dev/null
+++ b/src/boost/range/algorithm/copy_backward.hpp
@@ -0,0 +1,43 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_COPY_BACKWARD_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_COPY_BACKWARD_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function copy_backward
+///
+/// range-based version of the copy_backwards std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+/// \pre BidirectionalTraversalWriteableIterator is a model of the BidirectionalIteratorConcept
+/// \pre BidirectionalTraversalWriteableIterator is a model of the WriteableIteratorConcept
+template< class BidirectionalRange, class BidirectionalTraversalWriteableIterator >
+inline BidirectionalTraversalWriteableIterator
+copy_backward(const BidirectionalRange& rng,
+              BidirectionalTraversalWriteableIterator out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::copy_backward(boost::begin(rng), boost::end(rng), out);
+}
+
+    } // namespace range
+    using range::copy_backward;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/count.hpp b/src/boost/range/algorithm/count.hpp
new file mode 100644
index 0000000..8316ce0
--- /dev/null
+++ b/src/boost/range/algorithm/count.hpp
@@ -0,0 +1,50 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_COUNT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function count
+///
+/// range-based version of the count std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+template< class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange>::type
+count(SinglePassRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    return std::count(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_difference<SinglePassRange const>::type
+count(const SinglePassRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::count(boost::begin(rng), boost::end(rng), val);
+}
+
+    } // namespace range
+    using range::count;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/count_if.hpp b/src/boost/range/algorithm/count_if.hpp
new file mode 100644
index 0000000..ae17b0e
--- /dev/null
+++ b/src/boost/range/algorithm/count_if.hpp
@@ -0,0 +1,51 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_COUNT_IF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_COUNT_IF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function count_if
+///
+/// range-based version of the count_if std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
+template< class SinglePassRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME boost::range_difference<SinglePassRange>::type
+count_if(SinglePassRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    return std::count_if(boost::begin(rng), boost::end(rng), pred);
+}
+
+/// \overload
+template< class SinglePassRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME boost::range_difference<const SinglePassRange>::type
+count_if(const SinglePassRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::count_if(boost::begin(rng), boost::end(rng), pred);
+}
+
+    } // namespace range
+    using range::count_if;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/equal.hpp b/src/boost/range/algorithm/equal.hpp
new file mode 100644
index 0000000..4472bb1
--- /dev/null
+++ b/src/boost/range/algorithm/equal.hpp
@@ -0,0 +1,198 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009.
+//  Use, modification and distribution is subject to the Boost Software
+//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EQUAL_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <iterator>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        // An implementation of equality comparison that is optimized for iterator
+        // traversal categories less than RandomAccessTraversal.
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2,
+                  class IteratorCategoryTag1,
+                  class IteratorCategoryTag2 >
+        inline bool equal_impl( SinglePassTraversalReadableIterator1 first1,
+                                SinglePassTraversalReadableIterator1 last1,
+                                SinglePassTraversalReadableIterator2 first2,
+                                SinglePassTraversalReadableIterator2 last2,
+                                IteratorCategoryTag1,
+                                IteratorCategoryTag2 )
+        {
+            while (true)
+            {
+                // If we have reached the end of the left range then this is
+                // the end of the loop. They are equal if and only if we have
+                // simultaneously reached the end of the right range.
+                if (first1 == last1)
+                    return first2 == last2;
+
+                // If we have reached the end of the right range at this line
+                // it indicates that the right range is shorter than the left
+                // and hence the result is false.
+                if (first2 == last2)
+                    return false;
+
+                // continue looping if and only if the values are equal
+                if (*first1 != *first2)
+                    break;
+
+                ++first1;
+                ++first2;
+            }
+
+            // Reaching this line in the algorithm indicates that a value
+            // inequality has been detected.
+            return false;
+        }
+
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2,
+                  class IteratorCategoryTag1,
+                  class IteratorCategoryTag2,
+                  class BinaryPredicate >
+        inline bool equal_impl( SinglePassTraversalReadableIterator1 first1,
+                                SinglePassTraversalReadableIterator1 last1,
+                                SinglePassTraversalReadableIterator2 first2,
+                                SinglePassTraversalReadableIterator2 last2,
+                                BinaryPredicate                      pred,
+                                IteratorCategoryTag1,
+                                IteratorCategoryTag2 )
+        {
+            while (true)
+            {
+                // If we have reached the end of the left range then this is
+                // the end of the loop. They are equal if and only if we have
+                // simultaneously reached the end of the right range.
+                if (first1 == last1)
+                    return first2 == last2;
+
+                // If we have reached the end of the right range at this line
+                // it indicates that the right range is shorter than the left
+                // and hence the result is false.
+                if (first2 == last2)
+                    return false;
+
+                // continue looping if and only if the values are equal
+                if (!pred(*first1, *first2))
+                    break;
+
+                ++first1;
+                ++first2;
+            }
+
+            // Reaching this line in the algorithm indicates that a value
+            // inequality has been detected.
+            return false;
+        }
+
+        // An implementation of equality comparison that is optimized for
+        // random access iterators.
+        template< class RandomAccessTraversalReadableIterator1,
+                  class RandomAccessTraversalReadableIterator2 >
+        inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
+                                RandomAccessTraversalReadableIterator1 last1,
+                                RandomAccessTraversalReadableIterator2 first2,
+                                RandomAccessTraversalReadableIterator2 last2,
+                                std::random_access_iterator_tag,
+                                std::random_access_iterator_tag )
+        {
+            return ((last1 - first1) == (last2 - first2))
+                && std::equal(first1, last1, first2);
+        }
+
+        template< class RandomAccessTraversalReadableIterator1,
+                  class RandomAccessTraversalReadableIterator2,
+                  class BinaryPredicate >
+        inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
+                                RandomAccessTraversalReadableIterator1 last1,
+                                RandomAccessTraversalReadableIterator2 first2,
+                                RandomAccessTraversalReadableIterator2 last2,
+                                BinaryPredicate                        pred )
+        {
+            return ((last1 - first1) == (last2 - first2))
+                && std::equal(first1, last1, first2, pred);
+        }
+
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2 >
+        inline bool equal( SinglePassTraversalReadableIterator1 first1,
+                           SinglePassTraversalReadableIterator1 last1,
+                           SinglePassTraversalReadableIterator2 first2,
+                           SinglePassTraversalReadableIterator2 last2 )
+        {
+            BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1;
+            BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2;
+
+            return equal_impl(first1, last1, first2, last2, tag1, tag2);
+        }
+
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2,
+                  class BinaryPredicate >
+        inline bool equal( SinglePassTraversalReadableIterator1 first1,
+                           SinglePassTraversalReadableIterator1 last1,
+                           SinglePassTraversalReadableIterator2 first2,
+                           SinglePassTraversalReadableIterator2 last2,
+                           BinaryPredicate                      pred )
+        {
+            BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator1 >::iterator_category tag1;
+            BOOST_DEDUCED_TYPENAME std::iterator_traits< SinglePassTraversalReadableIterator2 >::iterator_category tag2;
+
+            return equal_impl(first1, last1, first2, last2, pred, tag1, tag2);
+        }
+
+    } // namespace range_detail
+
+    namespace range
+    {
+
+        /// \brief template function equal
+        ///
+        /// range-based version of the equal std algorithm
+        ///
+        /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+        /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+        /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+        template< class SinglePassRange1, class SinglePassRange2 >
+        inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2 )
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+            return ::boost::range_detail::equal(
+                ::boost::begin(rng1), ::boost::end(rng1),
+                ::boost::begin(rng2), ::boost::end(rng2) );
+        }
+
+        /// \overload
+        template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
+        inline bool equal( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
+                           BinaryPredicate pred )
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+            return ::boost::range_detail::equal(
+                ::boost::begin(rng1), ::boost::end(rng1),
+                ::boost::begin(rng2), ::boost::end(rng2),
+                pred);
+        }
+
+    } // namespace range
+    using ::boost::range::equal;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/equal_range.hpp b/src/boost/range/algorithm/equal_range.hpp
new file mode 100644
index 0000000..4aa4a54
--- /dev/null
+++ b/src/boost/range/algorithm/equal_range.hpp
@@ -0,0 +1,80 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EQUAL_RANGE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EQUAL_RANGE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function equal_range
+///
+/// range-based version of the equal_range std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre SortPredicate is a model of the BinaryPredicateConcept
+template<class ForwardRange, class Value>
+inline std::pair<
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type,
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
+       >
+equal_range(ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::equal_range(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template<class ForwardRange, class Value>
+inline std::pair<
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type,
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
+       >
+equal_range(const ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::equal_range(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template<class ForwardRange, class Value, class SortPredicate>
+inline std::pair<
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type,
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
+       >
+equal_range(ForwardRange& rng, const Value& val, SortPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::equal_range(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+/// \overload
+template<class ForwardRange, class Value, class SortPredicate>
+inline std::pair<
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type,
+        BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
+       >
+equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::equal_range(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+    } // namespace range
+    using range::equal_range;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/fill.hpp b/src/boost/range/algorithm/fill.hpp
new file mode 100644
index 0000000..95231a8
--- /dev/null
+++ b/src/boost/range/algorithm/fill.hpp
@@ -0,0 +1,49 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FILL_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function fill
+///
+/// range-based version of the fill std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template< class ForwardRange, class Value >
+inline ForwardRange& fill(ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    std::fill(boost::begin(rng), boost::end(rng), val);
+    return rng;
+}
+
+/// \overload
+template< class ForwardRange, class Value >
+inline const ForwardRange& fill(const ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    std::fill(boost::begin(rng), boost::end(rng), val);
+    return rng;
+}
+
+    } // namespace range
+    using range::fill;
+}
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/fill_n.hpp b/src/boost/range/algorithm/fill_n.hpp
new file mode 100644
index 0000000..02a0c2a
--- /dev/null
+++ b/src/boost/range/algorithm/fill_n.hpp
@@ -0,0 +1,53 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FILL_N_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FILL_N_HPP_INCLUDED
+
+#include <boost/assert.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function fill_n
+///
+/// range-based version of the fill_n std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre n <= std::distance(boost::begin(rng), boost::end(rng))
+template< class ForwardRange, class Size, class Value >
+inline ForwardRange& fill_n(ForwardRange& rng, Size n, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    BOOST_ASSERT( static_cast<Size>(std::distance(boost::begin(rng), boost::end(rng))) >= n );
+    std::fill_n(boost::begin(rng), n, val);
+    return rng;
+}
+
+/// \overload
+template< class ForwardRange, class Size, class Value >
+inline const ForwardRange& fill_n(const ForwardRange& rng, Size n, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    BOOST_ASSERT( static_cast<Size>(std::distance(boost::begin(rng), boost::end(rng))) >= n );
+    std::fill_n(boost::begin(rng), n, val);
+    return rng;
+}
+
+    } // namespace range
+    using range::fill_n;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/find.hpp b/src/boost/range/algorithm/find.hpp
new file mode 100644
index 0000000..72c5cf1
--- /dev/null
+++ b/src/boost/range/algorithm/find.hpp
@@ -0,0 +1,80 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FIND_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function find
+///
+/// range-based version of the find std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+template< class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange>,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type
+>::type
+find( SinglePassRange& rng, const Value& val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    return std::find(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type
+find( const SinglePassRange& rng, const Value& val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::find(boost::begin(rng), boost::end(rng), val);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange>,
+    BOOST_DEDUCED_TYPENAME range_return<SinglePassRange,re>::type
+>::type
+find( SinglePassRange& rng, const Value& val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    return range_return<SinglePassRange,re>::
+        pack(std::find(boost::begin(rng), boost::end(rng), val),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class SinglePassRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange,re>::type
+find( const SinglePassRange& rng, const Value& val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return range_return<const SinglePassRange,re>::
+        pack(std::find(boost::begin(rng), boost::end(rng), val),
+             rng);
+}
+
+    } // namespace range
+    using range::find;
+}
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/find_end.hpp b/src/boost/range/algorithm/find_end.hpp
new file mode 100644
index 0000000..757e999
--- /dev/null
+++ b/src/boost/range/algorithm/find_end.hpp
@@ -0,0 +1,152 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FIND_END_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function find_end
+///
+/// range-based version of the find_end std algorithm
+///
+/// \pre ForwardRange1 is a model of the ForwardRangeConcept
+/// \pre ForwardRange2 is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template< class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange1>,
+    BOOST_DEDUCED_TYPENAME range_iterator< ForwardRange1 >::type
+>::type
+find_end(ForwardRange1 & rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_end(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2));
+}
+
+/// \overload
+template< class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_iterator< const ForwardRange1 >::type
+find_end(const ForwardRange1 & rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_end(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2));
+}
+
+/// \overload
+template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange1>,
+    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
+>::type
+find_end(ForwardRange1 & rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_end(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2),pred);
+}
+
+/// \overload
+template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
+find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_end(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2),pred);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange1>,
+    BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
+>::type
+find_end(ForwardRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<ForwardRange1,re>::
+        pack(std::find_end(boost::begin(rng1), boost::end(rng1),
+                           boost::begin(rng2), boost::end(rng2)),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
+find_end(const ForwardRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<const ForwardRange1,re>::
+        pack(std::find_end(boost::begin(rng1), boost::end(rng1),
+                           boost::begin(rng2), boost::end(rng2)),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange1>,
+    BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
+>::type
+find_end(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<ForwardRange1,re>::
+        pack(std::find_end(boost::begin(rng1), boost::end(rng1),
+                           boost::begin(rng2), boost::end(rng2), pred),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
+find_end(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<const ForwardRange1,re>::
+        pack(std::find_end(boost::begin(rng1), boost::end(rng1),
+                           boost::begin(rng2), boost::end(rng2), pred),
+             rng1);
+}
+
+    } // namespace range
+    using range::find_end;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/find_first_of.hpp b/src/boost/range/algorithm/find_first_of.hpp
new file mode 100644
index 0000000..4cb5989
--- /dev/null
+++ b/src/boost/range/algorithm/find_first_of.hpp
@@ -0,0 +1,155 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FIND_FIRST_OF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FIND_FIRST_OF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function find_first_of
+///
+/// range-based version of the find_first_of std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre ForwardRange2 is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template< class SinglePassRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange1>,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type
+>::type
+find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_first_of(boost::begin(rng1),boost::end(rng1),
+                              boost::begin(rng2),boost::end(rng2));
+}
+
+/// \overload
+template< class SinglePassRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
+find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_first_of(boost::begin(rng1),boost::end(rng1),
+                              boost::begin(rng2),boost::end(rng2));
+}
+
+/// \overload
+template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange1>,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type
+>::type
+find_first_of(SinglePassRange1 & rng1, ForwardRange2 const & rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_first_of(boost::begin(rng1),boost::end(rng1),
+                              boost::begin(rng2),boost::end(rng2),pred);
+}
+
+/// \overload
+template< class SinglePassRange1, class ForwardRange2, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
+find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return std::find_first_of(boost::begin(rng1),boost::end(rng1),
+                              boost::begin(rng2),boost::end(rng2),pred);
+}
+
+// range return overloads
+/// \overload
+template< range_return_value re, class SinglePassRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange1>,
+    BOOST_DEDUCED_TYPENAME range_return<SinglePassRange1,re>::type
+>::type
+find_first_of(SinglePassRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<SinglePassRange1,re>::
+        pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
+                                boost::begin(rng2), boost::end(rng2)),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class SinglePassRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange1,re>::type
+find_first_of(const SinglePassRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<const SinglePassRange1,re>::
+        pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
+                                boost::begin(rng2), boost::end(rng2)),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class SinglePassRange1, class ForwardRange2,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange1>,
+    BOOST_DEDUCED_TYPENAME range_return<SinglePassRange1,re>::type
+>::type
+find_first_of(SinglePassRange1 & rng1, const ForwardRange2& rng2,
+              BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<SinglePassRange1,re>::
+        pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
+                                boost::begin(rng2), boost::end(rng2), pred),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class SinglePassRange1, class ForwardRange2,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange1,re>::type
+find_first_of(const SinglePassRange1 & rng1, const ForwardRange2& rng2,
+              BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+
+    return range_return<const SinglePassRange1,re>::
+        pack(std::find_first_of(boost::begin(rng1), boost::end(rng1),
+                                boost::begin(rng2), boost::end(rng2), pred),
+             rng1);
+}
+
+    } // namespace range
+    using range::find_first_of;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/find_if.hpp b/src/boost/range/algorithm/find_if.hpp
new file mode 100644
index 0000000..2d1926d
--- /dev/null
+++ b/src/boost/range/algorithm/find_if.hpp
@@ -0,0 +1,81 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FIND_IF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FIND_IF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function find_if
+///
+/// range-based version of the find_if std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
+template< class SinglePassRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange>,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type
+>::type
+find_if( SinglePassRange& rng, UnaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    return std::find_if(boost::begin(rng), boost::end(rng), pred);
+}
+
+/// \overload
+template< class SinglePassRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type
+find_if( const SinglePassRange& rng, UnaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::find_if(boost::begin(rng), boost::end(rng), pred);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class SinglePassRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<SinglePassRange>,
+    BOOST_DEDUCED_TYPENAME range_return<SinglePassRange,re>::type
+>::type
+find_if( SinglePassRange& rng, UnaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    return range_return<SinglePassRange,re>::
+        pack(std::find_if(boost::begin(rng), boost::end(rng), pred),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class SinglePassRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const SinglePassRange,re>::type
+find_if( const SinglePassRange& rng, UnaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return range_return<const SinglePassRange,re>::
+        pack(std::find_if(boost::begin(rng), boost::end(rng), pred),
+             rng);
+}
+
+    } // namespace range
+    using range::find_if;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/for_each.hpp b/src/boost/range/algorithm/for_each.hpp
new file mode 100644
index 0000000..4f5108d
--- /dev/null
+++ b/src/boost/range/algorithm/for_each.hpp
@@ -0,0 +1,109 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/ref.hpp>
+#include <algorithm>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
+#include <xutility>
+#endif
+
+namespace boost
+{
+    namespace range
+    {
+
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
+        namespace for_each_detail
+        {
+            template<typename Iterator, typename UnaryFunction>
+            inline UnaryFunction
+            for_each_impl(Iterator first, Iterator last, UnaryFunction fun,
+                          typename enable_if<
+                            is_reference_wrapper<UnaryFunction>,
+                            void
+                          >::type* = 0)
+            {
+                    typedef typename std::_Get_unchecked_type<Iterator>::type
+                                unchecked_iterator;
+
+                    unchecked_iterator unchecked_last = std::_Unchecked(last);
+                    for (unchecked_iterator unchecked_first = std::_Unchecked(first); first != last; ++first)
+                            fun.get()(*unchecked_first);
+
+                    return fun;
+            }
+
+            template<typename Iterator, typename UnaryFunction>
+            inline UnaryFunction
+            for_each_impl(Iterator first, Iterator last, UnaryFunction fn,
+                          typename disable_if<
+                            is_reference_wrapper<UnaryFunction>,
+                            void
+                          >::type* = 0)
+            {
+                return std::for_each<Iterator, UnaryFunction>(first, last, fn);
+            }
+        }
+#endif
+
+/// \brief template function for_each
+///
+/// range-based version of the for_each std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre UnaryFunction is a model of the UnaryFunctionConcept
+template< class SinglePassRange, class UnaryFunction >
+inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+    
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
+        return for_each_detail::for_each_impl<
+                typename range_iterator<SinglePassRange>::type,
+                UnaryFunction
+        >(boost::begin(rng), boost::end(rng), fun);
+#else
+    return std::for_each<
+        BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type,
+        UnaryFunction
+    >(boost::begin(rng),boost::end(rng),fun);
+#endif    
+}
+
+/// \overload
+template< class SinglePassRange, class UnaryFunction >
+inline UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
+        return for_each_detail::for_each_impl<
+                typename range_iterator<const SinglePassRange>::type,
+                UnaryFunction
+        >(boost::begin(rng), boost::end(rng), fun);
+#else    
+    return std::for_each<
+        BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type,
+        UnaryFunction
+    >(boost::begin(rng), boost::end(rng), fun);
+#endif    
+}
+
+    } // namespace range
+    using range::for_each;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/generate.hpp b/src/boost/range/algorithm/generate.hpp
new file mode 100644
index 0000000..324412c
--- /dev/null
+++ b/src/boost/range/algorithm/generate.hpp
@@ -0,0 +1,49 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_GENERATE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_GENERATE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+/// \brief template function generate
+///
+/// range-based version of the generate std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre Generator is a model of the UnaryFunctionConcept
+template< class ForwardRange, class Generator >
+inline ForwardRange& generate( ForwardRange& rng, Generator gen )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    std::generate(boost::begin(rng), boost::end(rng), gen);
+    return rng;
+}
+
+/// \overload
+template< class ForwardRange, class Generator >
+inline const ForwardRange& generate( const ForwardRange& rng, Generator gen )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    std::generate(boost::begin(rng), boost::end(rng), gen);
+    return rng;
+}
+
+    } // namespace range
+    using range::generate;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/heap_algorithm.hpp b/src/boost/range/algorithm/heap_algorithm.hpp
new file mode 100644
index 0000000..584920d
--- /dev/null
+++ b/src/boost/range/algorithm/heap_algorithm.hpp
@@ -0,0 +1,194 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function push_heap
+///
+/// range-based version of the push_heap std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre Compare is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& push_heap(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::push_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& push_heap(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::push_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline RandomAccessRange& push_heap(RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline const RandomAccessRange& push_heap(const RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \brief template function pop_heap
+///
+/// range-based version of the pop_heap std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre Compare is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& pop_heap(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::pop_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::pop_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline RandomAccessRange& pop_heap(RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \brief template function make_heap
+///
+/// range-based version of the make_heap std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre Compare is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& make_heap(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::make_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& make_heap(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::make_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline RandomAccessRange& make_heap(RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline const RandomAccessRange& make_heap(const RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \brief template function sort_heap
+///
+/// range-based version of the sort_heap std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre Compare is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& sort_heap(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::sort_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::sort_heap(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline RandomAccessRange& sort_heap(RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Compare>
+inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
+    return rng;
+}
+
+    } // namespace range
+    using range::push_heap;
+    using range::pop_heap;
+    using range::make_heap;
+    using range::sort_heap;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/inplace_merge.hpp b/src/boost/range/algorithm/inplace_merge.hpp
new file mode 100644
index 0000000..dfadbaa
--- /dev/null
+++ b/src/boost/range/algorithm/inplace_merge.hpp
@@ -0,0 +1,74 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_INPLACE_MERGE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_INPLACE_MERGE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function inplace_merge
+///
+/// range-based version of the inplace_merge std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class BidirectionalRange>
+inline BidirectionalRange& inplace_merge(BidirectionalRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type middle)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    std::inplace_merge(boost::begin(rng), middle, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class BidirectionalRange>
+inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng,
+    BOOST_DEDUCED_TYPENAME boost::range_iterator<const BidirectionalRange>::type middle)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    std::inplace_merge(boost::begin(rng), middle, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class BidirectionalRange, class BinaryPredicate>
+inline BidirectionalRange& inplace_merge(BidirectionalRange& rng,
+    BOOST_DEDUCED_TYPENAME boost::range_iterator<BidirectionalRange>::type middle,
+    BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred);
+    return rng;
+}
+
+/// \overload
+template<class BidirectionalRange, class BinaryPredicate>
+inline const BidirectionalRange& inplace_merge(const BidirectionalRange& rng,
+    BOOST_DEDUCED_TYPENAME boost::range_iterator<const BidirectionalRange>::type middle,
+    BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    std::inplace_merge(boost::begin(rng), middle, boost::end(rng), pred);
+    return rng;
+}
+
+    } // namespace range
+    using range::inplace_merge;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/lexicographical_compare.hpp b/src/boost/range/algorithm/lexicographical_compare.hpp
new file mode 100644
index 0000000..c6e4bc8
--- /dev/null
+++ b/src/boost/range/algorithm/lexicographical_compare.hpp
@@ -0,0 +1,58 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function lexicographic_compare
+///
+/// range-based version of the lexicographic_compare std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+template<class SinglePassRange1, class SinglePassRange2>
+inline bool lexicographical_compare(const SinglePassRange1& rng1,
+                                    const SinglePassRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::lexicographical_compare(
+        boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2));
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class BinaryPredicate>
+inline bool lexicographical_compare(const SinglePassRange1& rng1,
+                                    const SinglePassRange2& rng2,
+                                    BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::lexicographical_compare(
+        boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2), pred);
+}
+
+    } // namespace range
+    using range::lexicographical_compare;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/lower_bound.hpp b/src/boost/range/algorithm/lower_bound.hpp
new file mode 100644
index 0000000..cb5e639
--- /dev/null
+++ b/src/boost/range/algorithm/lower_bound.hpp
@@ -0,0 +1,124 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_LOWER_BOUND_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function lower_bound
+///
+/// range-based version of the lower_bound std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template< class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+>::type
+lower_bound( ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::lower_bound(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+lower_bound( const ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::lower_bound(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class ForwardRange, class Value, class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+>::type
+lower_bound( ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+/// \overload
+template< class ForwardRange, class Value, class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+lower_bound( const ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::lower_bound(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+>::type
+lower_bound( ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::
+        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+lower_bound( const ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::
+        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value, class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+>::type
+lower_bound( ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::
+        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value, class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+lower_bound( const ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::
+        pack(std::lower_bound(boost::begin(rng), boost::end(rng), val, pred),
+             rng);
+}
+
+    } // namespace range
+    using range::lower_bound;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/max_element.hpp b/src/boost/range/algorithm/max_element.hpp
new file mode 100644
index 0000000..a0c1ffd
--- /dev/null
+++ b/src/boost/range/algorithm/max_element.hpp
@@ -0,0 +1,115 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function max_element
+///
+/// range-based version of the max_element std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+max_element(ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::max_element(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+max_element(const ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::max_element(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+max_element(ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::max_element(boost::begin(rng), boost::end(rng), pred);
+}
+
+/// \overload
+template<class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+max_element(const ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::max_element(boost::begin(rng), boost::end(rng), pred);
+}
+
+// range_return overloads
+
+/// \overload
+template<range_return_value re, class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+max_element(ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::pack(
+        std::max_element(boost::begin(rng), boost::end(rng)),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+max_element(const ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::pack(
+        std::max_element(boost::begin(rng), boost::end(rng)),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+max_element(ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::pack(
+        std::max_element(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+max_element(const ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::pack(
+        std::max_element(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+    } // namespace range
+    using range::max_element;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/merge.hpp b/src/boost/range/algorithm/merge.hpp
new file mode 100644
index 0000000..c81b8c7
--- /dev/null
+++ b/src/boost/range/algorithm/merge.hpp
@@ -0,0 +1,61 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_MERGE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_MERGE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function merge
+///
+/// range-based version of the merge std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+///
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator>
+inline OutputIterator merge(const SinglePassRange1& rng1,
+                            const SinglePassRange2& rng2,
+                            OutputIterator          out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::merge(boost::begin(rng1), boost::end(rng1),
+                      boost::begin(rng2), boost::end(rng2), out);
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator, class BinaryPredicate>
+inline OutputIterator merge(const SinglePassRange1& rng1,
+                            const SinglePassRange2& rng2,
+                            OutputIterator          out,
+                            BinaryPredicate         pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::merge(boost::begin(rng1), boost::end(rng1),
+                      boost::begin(rng2), boost::end(rng2), out, pred);
+}
+
+    } // namespace range
+    using range::merge;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/min_element.hpp b/src/boost/range/algorithm/min_element.hpp
new file mode 100644
index 0000000..c966b1e
--- /dev/null
+++ b/src/boost/range/algorithm/min_element.hpp
@@ -0,0 +1,115 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function min_element
+///
+/// range-based version of the min_element std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+min_element(ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::min_element(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+min_element(const ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::min_element(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+min_element(ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::min_element(boost::begin(rng), boost::end(rng), pred);
+}
+
+/// \overload
+template<class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+min_element(const ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::min_element(boost::begin(rng), boost::end(rng), pred);
+}
+
+// range_return overloads
+
+/// \overload
+template<range_return_value re, class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+min_element(ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::pack(
+        std::min_element(boost::begin(rng), boost::end(rng)),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class ForwardRange>
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+min_element(const ForwardRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::pack(
+        std::min_element(boost::begin(rng), boost::end(rng)),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+min_element(ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::pack(
+        std::min_element(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class ForwardRange, class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+min_element(const ForwardRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::pack(
+        std::min_element(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+    } // namespace range
+    using range::min_element;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/mismatch.hpp b/src/boost/range/algorithm/mismatch.hpp
new file mode 100644
index 0000000..2819c33
--- /dev/null
+++ b/src/boost/range/algorithm/mismatch.hpp
@@ -0,0 +1,195 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_MISMATCH_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_MISMATCH_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2 >
+        inline std::pair<SinglePassTraversalReadableIterator1,
+                         SinglePassTraversalReadableIterator2>
+        mismatch_impl(SinglePassTraversalReadableIterator1 first1,
+                      SinglePassTraversalReadableIterator1 last1,
+                      SinglePassTraversalReadableIterator2 first2,
+                      SinglePassTraversalReadableIterator2 last2)
+        {
+            while (first1 != last1 && first2 != last2 && *first1 == *first2)
+            {
+                ++first1;
+                ++first2;
+            }
+            return std::pair<SinglePassTraversalReadableIterator1,
+                             SinglePassTraversalReadableIterator2>(first1, first2);
+        }
+
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2,
+                  class BinaryPredicate >
+        inline std::pair<SinglePassTraversalReadableIterator1,
+                         SinglePassTraversalReadableIterator2>
+        mismatch_impl(SinglePassTraversalReadableIterator1 first1,
+                      SinglePassTraversalReadableIterator1 last1,
+                      SinglePassTraversalReadableIterator2 first2,
+                      SinglePassTraversalReadableIterator2 last2,
+                      BinaryPredicate pred)
+        {
+            while (first1 != last1 && first2 != last2 && pred(*first1, *first2))
+            {
+                ++first1;
+                ++first2;
+            }
+            return std::pair<SinglePassTraversalReadableIterator1,
+                             SinglePassTraversalReadableIterator2>(first1, first2);
+        }
+    } // namespace range_detail
+
+    namespace range
+    {
+/// \brief template function mismatch
+///
+/// range-based version of the mismatch std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template< class SinglePassRange1, class SinglePassRange2 >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
+mismatch(SinglePassRange1& rng1, const SinglePassRange2 & rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2));
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2 >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
+mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2));
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2 >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
+mismatch(SinglePassRange1& rng1, SinglePassRange2 & rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2));
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2 >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
+mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2));
+}
+
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
+mismatch(SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2), pred);
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type >
+mismatch(const SinglePassRange1& rng1, const SinglePassRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2), pred);
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
+mismatch(SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2), pred);
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2, class BinaryPredicate >
+inline std::pair<
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type >
+mismatch(const SinglePassRange1& rng1, SinglePassRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    return ::boost::range_detail::mismatch_impl(
+        ::boost::begin(rng1), ::boost::end(rng1),
+        ::boost::begin(rng2), ::boost::end(rng2), pred);
+}
+
+    } // namespace range
+    using range::mismatch;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/nth_element.hpp b/src/boost/range/algorithm/nth_element.hpp
new file mode 100644
index 0000000..a605595
--- /dev/null
+++ b/src/boost/range/algorithm/nth_element.hpp
@@ -0,0 +1,74 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_NTH_ELEMENT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_NTH_ELEMENT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function nth_element
+///
+/// range-based version of the nth_element std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& nth_element(RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type nth)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::nth_element(boost::begin(rng), nth, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& nth_element(const RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type nth)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::nth_element(boost::begin(rng), nth, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline RandomAccessRange& nth_element(RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type nth,
+    BinaryPredicate sort_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline const RandomAccessRange& nth_element(const RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type nth,
+    BinaryPredicate sort_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::nth_element(boost::begin(rng), nth, boost::end(rng), sort_pred);
+    return rng;
+}
+
+    } // namespace range
+    using range::nth_element;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/partial_sort.hpp b/src/boost/range/algorithm/partial_sort.hpp
new file mode 100644
index 0000000..d7044cd
--- /dev/null
+++ b/src/boost/range/algorithm/partial_sort.hpp
@@ -0,0 +1,76 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function partial_sort
+///
+/// range-based version of the partial_sort std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::partial_sort(boost::begin(rng), middle, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::partial_sort(boost::begin(rng), middle, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle,
+    BinaryPredicate sort_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::partial_sort(boost::begin(rng), middle, boost::end(rng),
+                        sort_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle,
+    BinaryPredicate sort_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::partial_sort(boost::begin(rng), middle, boost::end(rng),
+                        sort_pred);
+    return rng;
+}
+
+    } // namespace range
+    using range::partial_sort;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/partial_sort_copy.hpp b/src/boost/range/algorithm/partial_sort_copy.hpp
new file mode 100644
index 0000000..9129389
--- /dev/null
+++ b/src/boost/range/algorithm/partial_sort_copy.hpp
@@ -0,0 +1,82 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/value_type.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function partial_sort_copy
+///
+/// range-based version of the partial_sort_copy std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre RandomAccessRange is a model of the Mutable_RandomAccessRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class SinglePassRange, class RandomAccessRange>
+inline BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type
+partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
+
+    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2));
+}
+
+/// \overload
+template<class SinglePassRange, class RandomAccessRange>
+inline BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type
+partial_sort_copy(const SinglePassRange& rng1, const RandomAccessRange& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
+
+    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2));
+}
+
+/// \overload
+template<class SinglePassRange, class RandomAccessRange,
+         class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type
+partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2,
+    BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
+
+    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2), pred);
+}
+
+/// \overload
+template<class SinglePassRange, class RandomAccessRange,
+         class BinaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type
+partial_sort_copy(const SinglePassRange& rng1, const RandomAccessRange& rng2,
+    BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
+
+    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2), pred);
+}
+
+    } // namespace range
+    using range::partial_sort_copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/partition.hpp b/src/boost/range/algorithm/partition.hpp
new file mode 100644
index 0000000..b814a24
--- /dev/null
+++ b/src/boost/range/algorithm/partition.hpp
@@ -0,0 +1,74 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_PARTITION__HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_PARTITION__HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function partition
+///
+/// range-based version of the partition std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template<class ForwardRange, class UnaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+partition(ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::partition(boost::begin(rng),boost::end(rng),pred);
+}
+
+/// \overload
+template<class ForwardRange, class UnaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+partition(const ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::partition(boost::begin(rng),boost::end(rng),pred);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class ForwardRange,
+          class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+partition(ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return boost::range_return<ForwardRange,re>::
+        pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange,
+          class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+partition(const ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return boost::range_return<const ForwardRange,re>::
+        pack(std::partition(boost::begin(rng), boost::end(rng), pred), rng);
+}
+
+    } // namespace range
+    using range::partition;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/permutation.hpp b/src/boost/range/algorithm/permutation.hpp
new file mode 100644
index 0000000..75388cc
--- /dev/null
+++ b/src/boost/range/algorithm/permutation.hpp
@@ -0,0 +1,108 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_PERMUTATION_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function next_permutation
+///
+/// range-based version of the next_permutation std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+/// \pre Compare is a model of the BinaryPredicateConcept
+template<class BidirectionalRange>
+inline bool next_permutation(BidirectionalRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    return std::next_permutation(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class BidirectionalRange>
+inline bool next_permutation(const BidirectionalRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::next_permutation(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class BidirectionalRange, class Compare>
+inline bool next_permutation(BidirectionalRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    return std::next_permutation(boost::begin(rng), boost::end(rng),
+                                 comp_pred);
+}
+
+/// \overload
+template<class BidirectionalRange, class Compare>
+inline bool next_permutation(const BidirectionalRange& rng,
+                             Compare                   comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::next_permutation(boost::begin(rng), boost::end(rng),
+                                 comp_pred);
+}
+
+/// \brief template function prev_permutation
+///
+/// range-based version of the prev_permutation std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+/// \pre Compare is a model of the BinaryPredicateConcept
+template<class BidirectionalRange>
+inline bool prev_permutation(BidirectionalRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    return std::prev_permutation(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class BidirectionalRange>
+inline bool prev_permutation(const BidirectionalRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::prev_permutation(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class BidirectionalRange, class Compare>
+inline bool prev_permutation(BidirectionalRange& rng, Compare comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    return std::prev_permutation(boost::begin(rng), boost::end(rng),
+                                 comp_pred);
+}
+
+/// \overload
+template<class BidirectionalRange, class Compare>
+inline bool prev_permutation(const BidirectionalRange& rng,
+                             Compare                   comp_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::prev_permutation(boost::begin(rng), boost::end(rng),
+                                 comp_pred);
+}
+
+    } // namespace range
+    using range::next_permutation;
+    using range::prev_permutation;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/random_shuffle.hpp b/src/boost/range/algorithm/random_shuffle.hpp
new file mode 100644
index 0000000..95bbd97
--- /dev/null
+++ b/src/boost/range/algorithm/random_shuffle.hpp
@@ -0,0 +1,68 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_RANDOM_SHUFFLE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function random_shuffle
+///
+/// range-based version of the random_shuffle std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre Generator is a model of the UnaryFunctionConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& random_shuffle(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::random_shuffle(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::random_shuffle(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Generator>
+inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class Generator>
+inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
+    return rng;
+}
+
+    } // namespace range
+    using range::random_shuffle;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/remove.hpp b/src/boost/range/algorithm/remove.hpp
new file mode 100644
index 0000000..699a7cd
--- /dev/null
+++ b/src/boost/range/algorithm/remove.hpp
@@ -0,0 +1,74 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REMOVE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function remove
+///
+/// range-based version of the remove std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template< class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+remove(ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::remove(boost::begin(rng),boost::end(rng),val);
+}
+
+/// \overload
+template< class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+remove(const ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::remove(boost::begin(rng),boost::end(rng),val);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+remove(ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::pack(
+        std::remove(boost::begin(rng), boost::end(rng), val),
+        rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+remove(const ForwardRange& rng, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::pack(
+        std::remove(boost::begin(rng), boost::end(rng), val),
+        rng);
+}
+
+    } // namespace range
+    using range::remove;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/remove_copy.hpp b/src/boost/range/algorithm/remove_copy.hpp
new file mode 100644
index 0000000..b65747e
--- /dev/null
+++ b/src/boost/range/algorithm/remove_copy.hpp
@@ -0,0 +1,44 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function remove_copy
+///
+/// range-based version of the remove_copy std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre OutputIterator is a model of the OutputIteratorConcept
+/// \pre Value is a model of the EqualityComparableConcept
+/// \pre Objects of type Value can be compared for equality with objects of
+/// InputIterator's value type.
+template< class SinglePassRange, class OutputIterator, class Value >
+inline OutputIterator
+remove_copy(const SinglePassRange& rng, OutputIterator out_it, const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::remove_copy(boost::begin(rng), boost::end(rng), out_it, val);
+}
+
+    } // namespace range
+    using range::remove_copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/remove_copy_if.hpp b/src/boost/range/algorithm/remove_copy_if.hpp
new file mode 100644
index 0000000..8d9c37b
--- /dev/null
+++ b/src/boost/range/algorithm/remove_copy_if.hpp
@@ -0,0 +1,38 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REMOVE_COPY_IF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    /// \brief template function remove_copy_if
+    ///
+    /// range-based version of the remove_copy_if std algorithm
+    ///
+    /// \pre SinglePassRange is a model of the SinglePassRangeConcept
+    /// \pre OutputIterator is a model of the OutputIteratorConcept
+    /// \pre Predicate is a model of the PredicateConcept
+    /// \pre InputIterator's value type is convertible to Predicate's argument type
+    /// \pre out_it is not an iterator in the range rng
+    template< class SinglePassRange, class OutputIterator, class Predicate >
+    inline OutputIterator
+    remove_copy_if(const SinglePassRange& rng, OutputIterator out_it, Predicate pred)
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+        return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
+    }
+}
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/remove_if.hpp b/src/boost/range/algorithm/remove_if.hpp
new file mode 100644
index 0000000..a965df0
--- /dev/null
+++ b/src/boost/range/algorithm/remove_if.hpp
@@ -0,0 +1,75 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REMOVE_IF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REMOVE_IF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function remove_if
+///
+/// range-based version of the remove_if std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
+template< class ForwardRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME boost::range_iterator<ForwardRange>::type
+remove_if(ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::remove_if(boost::begin(rng), boost::end(rng), pred);
+}
+
+/// \overload
+template< class ForwardRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME boost::range_iterator<const ForwardRange>::type
+remove_if(const ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::remove_if(boost::begin(rng), boost::end(rng), pred);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class ForwardRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+remove_if(ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::pack(
+        std::remove_if(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class UnaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+remove_if(const ForwardRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::pack(
+        std::remove_if(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+    } // namespace range
+    using range::remove_if;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/replace.hpp b/src/boost/range/algorithm/replace.hpp
new file mode 100644
index 0000000..44d3e4c
--- /dev/null
+++ b/src/boost/range/algorithm/replace.hpp
@@ -0,0 +1,53 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REPLACE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REPLACE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function replace
+///
+/// range-based version of the replace std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template< class ForwardRange, class Value >
+inline ForwardRange&
+replace(ForwardRange& rng, const Value& what,
+        const Value& with_what)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    std::replace(boost::begin(rng), boost::end(rng), what, with_what);
+    return rng;
+}
+
+/// \overload
+template< class ForwardRange, class Value >
+inline const ForwardRange&
+replace(const ForwardRange& rng, const Value& what,
+        const Value& with_what)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    std::replace(boost::begin(rng), boost::end(rng), what, with_what);
+    return rng;
+}
+
+    } // namespace range
+    using range::replace;
+} // namespace boost;
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/replace_copy.hpp b/src/boost/range/algorithm/replace_copy.hpp
new file mode 100644
index 0000000..0c02005
--- /dev/null
+++ b/src/boost/range/algorithm/replace_copy.hpp
@@ -0,0 +1,42 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REPLACE_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function replace_copy
+///
+/// range-based version of the replace_copy std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template< class ForwardRange, class OutputIterator, class Value >
+inline OutputIterator
+replace_copy(const ForwardRange& rng, OutputIterator out_it, const Value& what,
+        const Value& with_what)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::replace_copy(boost::begin(rng), boost::end(rng), out_it,
+        what, with_what);
+}
+
+    } // namespace range
+    using range::replace_copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/replace_copy_if.hpp b/src/boost/range/algorithm/replace_copy_if.hpp
new file mode 100644
index 0000000..d313151
--- /dev/null
+++ b/src/boost/range/algorithm/replace_copy_if.hpp
@@ -0,0 +1,46 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REPLACE_COPY_IF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function replace_copy_if
+///
+/// range-based version of the replace_copy_if std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre Predicate is a model of the PredicateConcept
+/// \pre Value is convertible to Predicate's argument type
+/// \pre Value is Assignable
+/// \pre Value is convertible to a type in OutputIterator's set of value types.
+template< class ForwardRange, class OutputIterator, class Predicate, class Value >
+inline OutputIterator
+replace_copy_if(const ForwardRange& rng, OutputIterator out_it, Predicate pred,
+        const Value& with_what)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::replace_copy_if(boost::begin(rng), boost::end(rng), out_it,
+        pred, with_what);
+}
+
+    } // namespace range
+    using range::replace_copy_if;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/replace_if.hpp b/src/boost/range/algorithm/replace_if.hpp
new file mode 100644
index 0000000..93d5a1f
--- /dev/null
+++ b/src/boost/range/algorithm/replace_if.hpp
@@ -0,0 +1,54 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REPLACE_IF_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REPLACE_IF_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function replace_if
+///
+/// range-based version of the replace_if std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
+template< class ForwardRange, class UnaryPredicate, class Value >
+inline ForwardRange&
+    replace_if(ForwardRange& rng, UnaryPredicate pred,
+               const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    std::replace_if(boost::begin(rng), boost::end(rng), pred, val);
+    return rng;
+}
+
+/// \overload
+template< class ForwardRange, class UnaryPredicate, class Value >
+inline const ForwardRange&
+    replace_if(const ForwardRange& rng, UnaryPredicate pred,
+               const Value& val)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    std::replace_if(boost::begin(rng), boost::end(rng), pred, val);
+    return rng;
+}
+
+    } // namespace range
+    using range::replace_if;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/reverse.hpp b/src/boost/range/algorithm/reverse.hpp
new file mode 100644
index 0000000..20a7eb1
--- /dev/null
+++ b/src/boost/range/algorithm/reverse.hpp
@@ -0,0 +1,50 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REVERSE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function reverse
+///
+/// range-based version of the reverse std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+template<class BidirectionalRange>
+inline BidirectionalRange& reverse(BidirectionalRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    std::reverse(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class BidirectionalRange>
+inline const BidirectionalRange& reverse(const BidirectionalRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    std::reverse(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+    } // namespace range
+    using range::reverse;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/reverse_copy.hpp b/src/boost/range/algorithm/reverse_copy.hpp
new file mode 100644
index 0000000..f1990ad
--- /dev/null
+++ b/src/boost/range/algorithm/reverse_copy.hpp
@@ -0,0 +1,40 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_REVERSE_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_REVERSE_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/iterator/iterator_concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function reverse_copy
+///
+/// range-based version of the reverse_copy std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+template<class BidirectionalRange, class OutputIterator>
+inline OutputIterator reverse_copy(const BidirectionalRange& rng, OutputIterator out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::reverse_copy(boost::begin(rng), boost::end(rng), out);
+}
+
+    } // namespace range
+    using range::reverse_copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/rotate.hpp b/src/boost/range/algorithm/rotate.hpp
new file mode 100644
index 0000000..ca4b223
--- /dev/null
+++ b/src/boost/range/algorithm/rotate.hpp
@@ -0,0 +1,51 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_ROTATE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_ROTATE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function rotate
+///
+/// range-based version of the rotate std algorithm
+///
+/// \pre Rng meets the requirements for a Forward range
+template<class ForwardRange>
+inline ForwardRange& rotate(ForwardRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type middle)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    std::rotate(boost::begin(rng), middle, boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class ForwardRange>
+inline const ForwardRange& rotate(const ForwardRange& rng,
+    BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type middle)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    std::rotate(boost::begin(rng), middle, boost::end(rng));
+    return rng;
+}
+
+    } // namespace range
+    using range::rotate;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/rotate_copy.hpp b/src/boost/range/algorithm/rotate_copy.hpp
new file mode 100644
index 0000000..0409ac5
--- /dev/null
+++ b/src/boost/range/algorithm/rotate_copy.hpp
@@ -0,0 +1,44 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_ROTATE_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+    /// \brief template function rotate
+    ///
+    /// range-based version of the rotate std algorithm
+    ///
+    /// \pre Rng meets the requirements for a Forward range
+    template<typename ForwardRange, typename OutputIterator>
+    inline OutputIterator rotate_copy(
+        const ForwardRange&                                             rng,
+        BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type middle,
+        OutputIterator                                                  target
+        )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+        return std::rotate_copy(boost::begin(rng), middle, boost::end(rng), target);
+    }
+
+    } // namespace range
+    using range::rotate_copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/search.hpp b/src/boost/range/algorithm/search.hpp
new file mode 100644
index 0000000..28cc6e6
--- /dev/null
+++ b/src/boost/range/algorithm/search.hpp
@@ -0,0 +1,134 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_SEARCH_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function search
+///
+/// range-based version of the search std algorithm
+///
+/// \pre ForwardRange1 is a model of the ForwardRangeConcept
+/// \pre ForwardRange2 is a model of the ForwardRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template< class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
+search(ForwardRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return std::search(boost::begin(rng1),boost::end(rng1),
+                       boost::begin(rng2),boost::end(rng2));
+}
+
+/// \overload
+template< class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
+search(const ForwardRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return std::search(boost::begin(rng1), boost::end(rng1),
+                       boost::begin(rng2), boost::end(rng2));
+}
+
+/// \overload
+template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange1>::type
+search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return std::search(boost::begin(rng1),boost::end(rng1),
+                       boost::begin(rng2),boost::end(rng2),pred);
+}
+
+/// \overload
+template< class ForwardRange1, class ForwardRange2, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange1>::type
+search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return std::search(boost::begin(rng1), boost::end(rng1),
+                       boost::begin(rng2), boost::end(rng2), pred);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
+search(ForwardRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return range_return<ForwardRange1,re>::
+        pack(std::search(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2)),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2 >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
+search(const ForwardRange1& rng1, const ForwardRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return range_return<const ForwardRange1,re>::
+        pack(std::search(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2)),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange1,re>::type
+search(ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return range_return<ForwardRange1,re>::
+        pack(std::search(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2),pred),
+             rng1);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange1, class ForwardRange2,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange1,re>::type
+search(const ForwardRange1& rng1, const ForwardRange2& rng2, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange2> ));
+    return range_return<const ForwardRange1,re>::
+        pack(std::search(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2),pred),
+             rng1);
+}
+
+    } // namespace range
+    using range::search;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/search_n.hpp b/src/boost/range/algorithm/search_n.hpp
new file mode 100644
index 0000000..ca2b6ef
--- /dev/null
+++ b/src/boost/range/algorithm/search_n.hpp
@@ -0,0 +1,360 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_SEARCH_N_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_SEARCH_N_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <boost/range/value_type.hpp>
+#include <iterator>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+namespace range_detail
+{
+    // Rationale: search_n is implemented rather than delegate to
+    // the standard library implementation because some standard
+    // library implementations are broken eg. MSVC.
+
+    // search_n forward iterator version
+    template<typename ForwardIterator, typename Integer, typename Value>
+    inline ForwardIterator
+    search_n_impl(ForwardIterator first, ForwardIterator last, Integer count,
+                  const Value& value, std::forward_iterator_tag)
+    {
+        first = std::find(first, last, value);
+        while (first != last)
+        {
+            typename std::iterator_traits<ForwardIterator>::difference_type n = count;
+            ForwardIterator i = first;
+            ++i;
+            while (i != last && n != 1 && *i==value)
+            {
+                ++i;
+                --n;
+            }
+            if (n == 1)
+                return first;
+            if (i == last)
+                return last;
+            first = std::find(++i, last, value);
+        }
+        return last;
+    }
+
+    // search_n random-access iterator version
+    template<typename RandomAccessIterator, typename Integer, typename Value>
+    inline RandomAccessIterator
+    search_n_impl(RandomAccessIterator first, RandomAccessIterator last,
+                  Integer count, const Value& value,
+                  std::random_access_iterator_tag)
+    {
+        typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_t;
+
+        difference_t tail_size = last - first;
+        const difference_t pattern_size = count;
+
+        if (tail_size < pattern_size)
+            return last;
+
+        const difference_t skip_offset = pattern_size - 1;
+        RandomAccessIterator look_ahead = first + skip_offset;
+        tail_size -= pattern_size;
+
+        while (1)
+        {
+            // look_ahead here is pointing to the last element of the
+            // next possible match
+            while (!(*look_ahead == value)) // skip loop...
+            {
+                if (tail_size < pattern_size)
+                    return last; // no match
+                look_ahead += pattern_size;
+                tail_size -= pattern_size;
+            }
+            difference_t remainder = skip_offset;
+            for (RandomAccessIterator back_track = look_ahead - 1;
+                    *back_track == value; --back_track)
+            {
+                if (--remainder == 0)
+                {
+                    return look_ahead - skip_offset; // matched
+                }
+            }
+            if (remainder > tail_size)
+                return last; // no match
+            look_ahead += remainder;
+            tail_size -= remainder;
+        }
+
+        return last;
+    }
+
+    // search_n for forward iterators using a binary predicate
+    // to determine a match
+    template<typename ForwardIterator, typename Integer, typename Value,
+             typename BinaryPredicate>
+    inline ForwardIterator
+    search_n_pred_impl(ForwardIterator first, ForwardIterator last,
+                       Integer count, const Value& value,
+                       BinaryPredicate pred, std::forward_iterator_tag)
+    {
+        typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_t;
+
+        while (first != last && !static_cast<bool>(pred(*first, value)))
+            ++first;
+
+        while (first != last)
+        {
+            difference_t n = count;
+            ForwardIterator i = first;
+            ++i;
+            while (i != last && n != 1 && static_cast<bool>(pred(*i, value)))
+            {
+                ++i;
+                --n;
+            }
+            if (n == 1)
+                return first;
+            if (i == last)
+                return last;
+            first = ++i;
+            while (first != last && !static_cast<bool>(pred(*first, value)))
+                ++first;
+        }
+        return last;
+    }
+
+    // search_n for random-access iterators using a binary predicate
+    // to determine a match
+    template<typename RandomAccessIterator, typename Integer,
+             typename Value, typename BinaryPredicate>
+    inline RandomAccessIterator
+    search_n_pred_impl(RandomAccessIterator first, RandomAccessIterator last,
+                       Integer count, const Value& value,
+                       BinaryPredicate pred, std::random_access_iterator_tag)
+    {
+        typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_t;
+
+        difference_t tail_size = last - first;
+        const difference_t pattern_size = count;
+
+        if (tail_size < pattern_size)
+            return last;
+
+        const difference_t skip_offset = pattern_size - 1;
+        RandomAccessIterator look_ahead = first + skip_offset;
+        tail_size -= pattern_size;
+
+        while (1)
+        {
+            // look_ahead points to the last element of the next
+            // possible match
+            while (!static_cast<bool>(pred(*look_ahead, value))) // skip loop
+            {
+                if (tail_size < pattern_size)
+                    return last; // no match
+                look_ahead += pattern_size;
+                tail_size -= pattern_size;
+            }
+            difference_t remainder = skip_offset;
+            for (RandomAccessIterator back_track = look_ahead - 1;
+                    pred(*back_track, value); --back_track)
+            {
+                if (--remainder == 0)
+                    return look_ahead -= skip_offset; // success
+            }
+            if (remainder > tail_size)
+            {
+                return last; // no match
+            }
+            look_ahead += remainder;
+            tail_size -= remainder;
+        }
+    }
+
+    template<typename ForwardIterator, typename Integer, typename Value>
+    inline ForwardIterator
+    search_n_impl(ForwardIterator first, ForwardIterator last,
+                  Integer count, const Value& value)
+    {
+        BOOST_RANGE_CONCEPT_ASSERT((ForwardIteratorConcept<ForwardIterator>));
+        BOOST_RANGE_CONCEPT_ASSERT((EqualityComparableConcept<Value>));
+        BOOST_RANGE_CONCEPT_ASSERT((EqualityComparableConcept<typename std::iterator_traits<ForwardIterator>::value_type>));
+        //BOOST_RANGE_CONCEPT_ASSERT((EqualityComparableConcept2<typename std::iterator_traits<ForwardIterator>::value_type, Value>));
+
+        typedef typename std::iterator_traits<ForwardIterator>::iterator_category cat_t;
+
+        if (count <= 0)
+            return first;
+        if (count == 1)
+            return std::find(first, last, value);
+        return range_detail::search_n_impl(first, last, count, value, cat_t());
+    }
+
+    template<typename ForwardIterator, typename Integer, typename Value,
+             typename BinaryPredicate>
+    inline ForwardIterator
+    search_n_pred_impl(ForwardIterator first, ForwardIterator last,
+                       Integer count, const Value& value,
+                       BinaryPredicate pred)
+    {
+        BOOST_RANGE_CONCEPT_ASSERT((ForwardIteratorConcept<ForwardIterator>));
+        BOOST_RANGE_CONCEPT_ASSERT((
+            BinaryPredicateConcept<
+                BinaryPredicate,
+                typename std::iterator_traits<ForwardIterator>::value_type,
+                Value>
+            ));
+
+        typedef typename std::iterator_traits<ForwardIterator>::iterator_category cat_t;
+
+        if (count <= 0)
+            return first;
+        if (count == 1)
+        {
+            while (first != last && !static_cast<bool>(pred(*first, value)))
+                ++first;
+            return first;
+        }
+        return range_detail::search_n_pred_impl(first, last, count,
+                                                value, pred, cat_t());
+    }
+} // namespace range_detail
+
+/// \brief template function search
+///
+/// range-based version of the search std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+/// \pre Integer is an integral type
+/// \pre Value is a model of the EqualityComparableConcept
+/// \pre ForwardRange's value type is a model of the EqualityComparableConcept
+/// \pre Object's of ForwardRange's value type can be compared for equality with Objects of type Value
+template< class ForwardRange, class Integer, class Value >
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+search_n(ForwardRange& rng, Integer count, const Value& value)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return range_detail::search_n_impl(boost::begin(rng),boost::end(rng), count, value);
+}
+
+/// \overload
+template< class ForwardRange, class Integer, class Value >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+search_n(const ForwardRange& rng, Integer count, const Value& value)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
+    return range_detail::search_n_impl(boost::begin(rng), boost::end(rng), count, value);
+}
+
+/// \overload
+template< class ForwardRange, class Integer, class Value,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+search_n(ForwardRange& rng, Integer count, const Value& value,
+         BinaryPredicate binary_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type, const Value&>));
+    return range_detail::search_n_pred_impl(boost::begin(rng), boost::end(rng),
+        count, value, binary_pred);
+}
+
+/// \overload
+template< class ForwardRange, class Integer, class Value,
+          class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+search_n(const ForwardRange& rng, Integer count, const Value& value,
+         BinaryPredicate binary_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        BOOST_DEDUCED_TYPENAME range_value<const ForwardRange>::type, const Value&>));
+    return range_detail::search_n_pred_impl(boost::begin(rng), boost::end(rng),
+        count, value, binary_pred);
+}
+
+// range_return overloads
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Integer,
+          class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+search_n(ForwardRange& rng, Integer count, const Value& value)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    return range_return<ForwardRange,re>::
+        pack(range_detail::search_n_impl(boost::begin(rng),boost::end(rng),
+                           count, value),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Integer,
+          class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+search_n(const ForwardRange& rng, Integer count, const Value& value)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
+    return range_return<const ForwardRange,re>::
+        pack(range_detail::search_n_impl(boost::begin(rng), boost::end(rng),
+                           count, value),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Integer,
+          class Value, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+search_n(ForwardRange& rng, Integer count, const Value& value,
+         BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type,
+        const Value&>));
+    return range_return<ForwardRange,re>::
+        pack(range_detail::search_n_pred_impl(boost::begin(rng),
+                                              boost::end(rng),
+                           count, value, pred),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Integer,
+          class Value, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+search_n(const ForwardRange& rng, Integer count, const Value& value,
+         BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+        BOOST_DEDUCED_TYPENAME range_value<const ForwardRange>::type,
+        const Value&>));
+    return range_return<const ForwardRange,re>::
+        pack(range_detail::search_n_pred_impl(boost::begin(rng),
+                                              boost::end(rng),
+                           count, value, pred),
+             rng);
+}
+
+    } // namespace range
+    using range::search_n;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/set_algorithm.hpp b/src/boost/range/algorithm/set_algorithm.hpp
new file mode 100644
index 0000000..82ef8ec
--- /dev/null
+++ b/src/boost/range/algorithm/set_algorithm.hpp
@@ -0,0 +1,198 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_SET_ALGORITHM_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function includes
+///
+/// range-based version of the includes std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class SinglePassRange1, class SinglePassRange2>
+inline bool includes(const SinglePassRange1& rng1,
+                     const SinglePassRange2& rng2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::includes(boost::begin(rng1),boost::end(rng1),
+                         boost::begin(rng2),boost::end(rng2));
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class BinaryPredicate>
+inline bool includes(const SinglePassRange1& rng1,
+                     const SinglePassRange2& rng2,
+                     BinaryPredicate         pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::includes(boost::begin(rng1), boost::end(rng1),
+                         boost::begin(rng2), boost::end(rng2), pred);
+}
+
+/// \brief template function set_union
+///
+/// range-based version of the set_union std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator>
+inline OutputIterator set_union(const SinglePassRange1& rng1,
+                                const SinglePassRange2& rng2,
+                                OutputIterator          out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_union(boost::begin(rng1), boost::end(rng1),
+                          boost::begin(rng2), boost::end(rng2), out);
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator, class BinaryPredicate>
+inline OutputIterator set_union(const SinglePassRange1& rng1,
+                                const SinglePassRange2& rng2,
+                                OutputIterator          out,
+                                BinaryPredicate         pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_union(boost::begin(rng1), boost::end(rng1),
+                          boost::begin(rng2), boost::end(rng2), out, pred);
+}
+
+/// \brief template function set_intersection
+///
+/// range-based version of the set_intersection std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator>
+inline OutputIterator set_intersection(const SinglePassRange1& rng1,
+                                       const SinglePassRange2& rng2,
+                                       OutputIterator          out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_intersection(boost::begin(rng1), boost::end(rng1),
+                                 boost::begin(rng2), boost::end(rng2), out);
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator, class BinaryPredicate>
+inline OutputIterator set_intersection(const SinglePassRange1& rng1,
+                                       const SinglePassRange2& rng2,
+                                       OutputIterator          out,
+                                       BinaryPredicate         pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_intersection(boost::begin(rng1), boost::end(rng1),
+                                 boost::begin(rng2), boost::end(rng2),
+                                 out, pred);
+}
+
+/// \brief template function set_difference
+///
+/// range-based version of the set_difference std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator>
+inline OutputIterator set_difference(const SinglePassRange1& rng1,
+                                     const SinglePassRange2& rng2,
+                                     OutputIterator out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_difference(boost::begin(rng1), boost::end(rng1),
+                               boost::begin(rng2), boost::end(rng2), out);
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator, class BinaryPredicate>
+inline OutputIterator set_difference(const SinglePassRange1& rng1,
+                                     const SinglePassRange2& rng2,
+                                     OutputIterator          out,
+                                     BinaryPredicate         pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_difference(
+        boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2), out, pred);
+}
+
+/// \brief template function set_symmetric_difference
+///
+/// range-based version of the set_symmetric_difference std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator>
+inline OutputIterator
+set_symmetric_difference(const SinglePassRange1& rng1,
+                         const SinglePassRange2& rng2,
+                         OutputIterator          out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_symmetric_difference(boost::begin(rng1), boost::end(rng1),
+                                         boost::begin(rng2), boost::end(rng2), out);
+}
+
+/// \overload
+template<class SinglePassRange1, class SinglePassRange2,
+         class OutputIterator, class BinaryPredicate>
+inline OutputIterator
+set_symmetric_difference(const SinglePassRange1& rng1,
+                         const SinglePassRange2& rng2,
+                         OutputIterator          out,
+                         BinaryPredicate         pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+    return std::set_symmetric_difference(
+        boost::begin(rng1), boost::end(rng1),
+        boost::begin(rng2), boost::end(rng2), out, pred);
+}
+
+    } // namespace range
+    using range::includes;
+    using range::set_union;
+    using range::set_intersection;
+    using range::set_difference;
+    using range::set_symmetric_difference;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/sort.hpp b/src/boost/range/algorithm/sort.hpp
new file mode 100644
index 0000000..45eecde
--- /dev/null
+++ b/src/boost/range/algorithm/sort.hpp
@@ -0,0 +1,68 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_SORT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_SORT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function sort
+///
+/// range-based version of the sort std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& sort(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::sort(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& sort(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::sort(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::sort(boost::begin(rng), boost::end(rng), pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::sort(boost::begin(rng), boost::end(rng), pred);
+    return rng;
+}
+
+    } // namespace range
+    using range::sort;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/stable_partition.hpp b/src/boost/range/algorithm/stable_partition.hpp
new file mode 100644
index 0000000..24febfc
--- /dev/null
+++ b/src/boost/range/algorithm/stable_partition.hpp
@@ -0,0 +1,73 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_STABLE_PARTITION_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_STABLE_PARTITION_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function stable_partition
+///
+/// range-based version of the stable_partition std algorithm
+///
+/// \pre BidirectionalRange is a model of the BidirectionalRangeConcept
+/// \pre UnaryPredicate is a model of the UnaryPredicateConcept
+template<class BidirectionalRange, class UnaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type
+stable_partition(BidirectionalRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    return std::stable_partition(boost::begin(rng), boost::end(rng), pred);
+}
+
+/// \overload
+template<class BidirectionalRange, class UnaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_iterator<const BidirectionalRange>::type
+stable_partition(const BidirectionalRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return std::stable_partition(boost::begin(rng),boost::end(rng),pred);
+}
+
+// range_return overloads
+template<range_return_value re, class BidirectionalRange, class UnaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_return<BidirectionalRange,re>::type
+stable_partition(BidirectionalRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<BidirectionalRange> ));
+    return range_return<BidirectionalRange,re>::pack(
+        std::stable_partition(boost::begin(rng), boost::end(rng), pred),
+        rng);
+}
+
+/// \overload
+template<range_return_value re, class BidirectionalRange, class UnaryPredicate>
+inline BOOST_DEDUCED_TYPENAME range_return<const BidirectionalRange,re>::type
+stable_partition(const BidirectionalRange& rng, UnaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalRangeConcept<const BidirectionalRange> ));
+    return range_return<const BidirectionalRange,re>::pack(
+        std::stable_partition(boost::begin(rng),boost::end(rng),pred),
+        rng);
+}
+
+    } // namespace range
+    using range::stable_partition;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/stable_sort.hpp b/src/boost/range/algorithm/stable_sort.hpp
new file mode 100644
index 0000000..d18da4d
--- /dev/null
+++ b/src/boost/range/algorithm/stable_sort.hpp
@@ -0,0 +1,68 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_STABLE_SORT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_STABLE_SORT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function stable_sort
+///
+/// range-based version of the stable_sort std algorithm
+///
+/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template<class RandomAccessRange>
+inline RandomAccessRange& stable_sort(RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::stable_sort(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange>
+inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::stable_sort(boost::begin(rng), boost::end(rng));
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate sort_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
+    std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred);
+    return rng;
+}
+
+/// \overload
+template<class RandomAccessRange, class BinaryPredicate>
+inline const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate sort_pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
+    std::stable_sort(boost::begin(rng), boost::end(rng), sort_pred);
+    return rng;
+}
+
+    } // namespace range
+    using range::stable_sort;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/swap_ranges.hpp b/src/boost/range/algorithm/swap_ranges.hpp
new file mode 100644
index 0000000..52b0162
--- /dev/null
+++ b/src/boost/range/algorithm/swap_ranges.hpp
@@ -0,0 +1,132 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_SWAP_RANGES_HPP_INCLUDED
+
+#include <boost/assert.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template<class Iterator1, class Iterator2>
+        void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
+                              Iterator2 it2, Iterator2 last2,
+                              single_pass_traversal_tag,
+                              single_pass_traversal_tag)
+        {
+            ignore_unused_variable_warning(last2);
+            for (; it1 != last1; ++it1, ++it2)
+            {
+                BOOST_ASSERT( it2 != last2 );
+                std::iter_swap(it1, it2);
+            }
+        }
+
+        template<class Iterator1, class Iterator2>
+        void swap_ranges_impl(Iterator1 it1, Iterator1 last1,
+                              Iterator2 it2, Iterator2 last2,
+                              random_access_traversal_tag,
+                              random_access_traversal_tag)
+        {
+            ignore_unused_variable_warning(last2);
+            BOOST_ASSERT( last2 - it2 >= last1 - it1 );
+            std::swap_ranges(it1, last1, it2);
+        }
+
+        template<class Iterator1, class Iterator2>
+        void swap_ranges_impl(Iterator1 first1, Iterator1 last1,
+                              Iterator2 first2, Iterator2 last2)
+        {
+            swap_ranges_impl(first1, last1, first2, last2,
+                BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator1>::type(),
+                BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator2>::type());
+        }
+    } // namespace range_detail
+
+    namespace range
+    {
+
+/// \brief template function swap_ranges
+///
+/// range-based version of the swap_ranges std algorithm
+///
+/// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+/// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+template< class SinglePassRange1, class SinglePassRange2 >
+inline SinglePassRange2&
+swap_ranges(SinglePassRange1& range1, SinglePassRange2& range2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange1>));
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange2>));
+
+    boost::range_detail::swap_ranges_impl(
+        boost::begin(range1), boost::end(range1),
+        boost::begin(range2), boost::end(range2));
+
+    return range2;
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2 >
+inline SinglePassRange2&
+swap_ranges(const SinglePassRange1& range1, SinglePassRange2& range2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange1>));
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange2>));
+
+    boost::range_detail::swap_ranges_impl(
+        boost::begin(range1), boost::end(range1),
+        boost::begin(range2), boost::end(range2));
+
+    return range2;
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2 >
+inline const SinglePassRange2&
+swap_ranges(SinglePassRange1& range1, const SinglePassRange2& range2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange1>));
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange2>));
+
+    boost::range_detail::swap_ranges_impl(
+        boost::begin(range1), boost::end(range1),
+        boost::begin(range2), boost::end(range2));
+
+    return range2;
+}
+
+/// \overload
+template< class SinglePassRange1, class SinglePassRange2 >
+inline const SinglePassRange2&
+swap_ranges(const SinglePassRange1& range1, const SinglePassRange2& range2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange1>));
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange2>));
+
+    boost::range_detail::swap_ranges_impl(
+        boost::begin(range1), boost::end(range1),
+        boost::begin(range2), boost::end(range2));
+
+    return range2;
+}
+
+    } // namespace range
+    using range::swap_ranges;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/transform.hpp b/src/boost/range/algorithm/transform.hpp
new file mode 100644
index 0000000..fb03441
--- /dev/null
+++ b/src/boost/range/algorithm/transform.hpp
@@ -0,0 +1,97 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_TRANSFORM_HPP_INCLUDED
+
+#include <boost/assert.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+        /// \brief template function transform
+        ///
+        /// range-based version of the transform std algorithm
+        ///
+        /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
+        /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
+        /// \pre OutputIterator is a model of the OutputIteratorConcept
+        /// \pre UnaryOperation is a model of the UnaryFunctionConcept
+        /// \pre BinaryOperation is a model of the BinaryFunctionConcept
+        template< class SinglePassRange1,
+                  class OutputIterator,
+                  class UnaryOperation >
+        inline OutputIterator
+        transform(const SinglePassRange1& rng,
+                  OutputIterator          out,
+                  UnaryOperation          fun)
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+            return std::transform(boost::begin(rng),boost::end(rng),out,fun);
+        }
+
+    } // namespace range
+
+    namespace range_detail
+    {
+        template< class SinglePassTraversalReadableIterator1,
+                  class SinglePassTraversalReadableIterator2,
+                  class OutputIterator,
+                  class BinaryFunction >
+        inline OutputIterator
+        transform_impl(SinglePassTraversalReadableIterator1 first1,
+                       SinglePassTraversalReadableIterator1 last1,
+                       SinglePassTraversalReadableIterator2 first2,
+                       SinglePassTraversalReadableIterator2 last2,
+                       OutputIterator                       out,
+                       BinaryFunction                       fn)
+        {
+            for (; first1 != last1; ++first1, ++first2)
+            {
+                BOOST_ASSERT( first2 != last2 );
+                *out = fn(*first1, *first2);
+                ++out;
+            }
+            return out;
+        }
+    }
+
+    namespace range
+    {
+
+        /// \overload
+        template< class SinglePassRange1,
+                  class SinglePassRange2,
+                  class OutputIterator,
+                  class BinaryOperation >
+        inline OutputIterator
+        transform(const SinglePassRange1& rng1,
+                  const SinglePassRange2& rng2,
+                  OutputIterator          out,
+                  BinaryOperation         fun)
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+            return boost::range_detail::transform_impl(
+                        boost::begin(rng1), boost::end(rng1),
+                        boost::begin(rng2), boost::end(rng2),
+                        out, fun);
+        }
+
+    } // namespace range
+    using range::transform;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/unique.hpp b/src/boost/range/algorithm/unique.hpp
new file mode 100644
index 0000000..be6eaf9
--- /dev/null
+++ b/src/boost/range/algorithm/unique.hpp
@@ -0,0 +1,107 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_UNIQUE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_UNIQUE_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function unique
+///
+/// range-based version of the unique std algorithm
+///
+/// \pre Rng meets the requirements for a Forward range
+template< range_return_value re, class ForwardRange >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+unique( ForwardRange& rng )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::
+        pack( std::unique( boost::begin(rng),
+                           boost::end(rng)), rng );
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+unique( const ForwardRange& rng )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::
+        pack( std::unique( boost::begin(rng),
+                           boost::end(rng)), rng );
+}
+/// \overload
+template< range_return_value re, class ForwardRange, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+unique( ForwardRange& rng, BinaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::
+        pack(std::unique(boost::begin(rng), boost::end(rng), pred),
+             rng);
+}
+/// \overload
+template< range_return_value re, class ForwardRange, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+unique( const ForwardRange& rng, BinaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::
+        pack(std::unique(boost::begin(rng), boost::end(rng), pred),
+             rng);
+}
+
+/// \overload
+template< class ForwardRange >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange, return_begin_found>::type
+unique( ForwardRange& rng )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return ::boost::range::unique<return_begin_found>(rng);
+}
+/// \overload
+template< class ForwardRange >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange, return_begin_found>::type
+unique( const ForwardRange& rng )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return ::boost::range::unique<return_begin_found>(rng);
+}
+/// \overload
+template< class ForwardRange, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange, return_begin_found>::type
+unique( ForwardRange& rng, BinaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return ::boost::range::unique<return_begin_found>(rng);
+}
+/// \overload
+template< class ForwardRange, class BinaryPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+unique( const ForwardRange& rng, BinaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return ::boost::range::unique<return_begin_found>(rng, pred);
+}
+
+    } // namespace range
+    using range::unique;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/unique_copy.hpp b/src/boost/range/algorithm/unique_copy.hpp
new file mode 100644
index 0000000..0682d74
--- /dev/null
+++ b/src/boost/range/algorithm/unique_copy.hpp
@@ -0,0 +1,51 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_UNIQUE_COPY_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_UNIQUE_COPY_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function unique_copy
+///
+/// range-based version of the unique_copy std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre OutputIterator is a model of the OutputIteratorConcept
+/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
+template< class SinglePassRange, class OutputIterator >
+inline OutputIterator
+unique_copy( const SinglePassRange& rng, OutputIterator out_it )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::unique_copy(boost::begin(rng), boost::end(rng), out_it);
+}
+/// \overload
+template< class SinglePassRange, class OutputIterator, class BinaryPredicate >
+inline OutputIterator
+unique_copy( const SinglePassRange& rng, OutputIterator out_it,
+             BinaryPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    return std::unique_copy(boost::begin(rng), boost::end(rng), out_it, pred);
+}
+
+    } // namespace range
+    using range::unique_copy;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm/upper_bound.hpp b/src/boost/range/algorithm/upper_bound.hpp
new file mode 100644
index 0000000..c8acbc6
--- /dev/null
+++ b/src/boost/range/algorithm/upper_bound.hpp
@@ -0,0 +1,127 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_UPPER_BOUND_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_UPPER_BOUND_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/detail/range_return.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function upper_bound
+///
+/// range-based version of the upper_bound std algorithm
+///
+/// \pre ForwardRange is a model of the ForwardRangeConcept
+template< class ForwardRange, class Value >
+inline
+BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+>::type
+upper_bound( ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::upper_bound(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class ForwardRange, class Value >
+BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+upper_bound( const ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::upper_bound(boost::begin(rng), boost::end(rng), val);
+}
+
+/// \overload
+template< class ForwardRange, class Value, class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
+>::type
+upper_bound( ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+/// \overload
+template< class ForwardRange, class Value, class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
+upper_bound( const ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return std::upper_bound(boost::begin(rng), boost::end(rng), val, pred);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+>::type
+upper_bound( ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::
+        pack(std::upper_bound(boost::begin(rng), boost::end(rng), val),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+upper_bound( const ForwardRange& rng, Value val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::
+        pack(std::upper_bound(boost::begin(rng), boost::end(rng), val),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value,
+          class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME disable_if<
+    is_const<ForwardRange>,
+    BOOST_DEDUCED_TYPENAME range_return<ForwardRange,re>::type
+>::type
+upper_bound( ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    return range_return<ForwardRange,re>::
+        pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred),
+             rng);
+}
+
+/// \overload
+template< range_return_value re, class ForwardRange, class Value,
+          class SortPredicate >
+inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange,re>::type
+upper_bound( const ForwardRange& rng, Value val, SortPredicate pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    return range_return<const ForwardRange,re>::
+        pack(std::upper_bound(boost::begin(rng), boost::end(rng), val, pred),
+             rng);
+}
+
+    } // namespace range
+    using range::upper_bound;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext.hpp b/src/boost/range/algorithm_ext.hpp
new file mode 100644
index 0000000..783d38a
--- /dev/null
+++ b/src/boost/range/algorithm_ext.hpp
@@ -0,0 +1,28 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2007. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//  Copyright Thorsten Ottosen 2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_HPP
+#define BOOST_RANGE_ALGORITHM_EXT_HPP
+
+#include <boost/range/algorithm_ext/copy_n.hpp>
+#include <boost/range/algorithm_ext/for_each.hpp>
+#include <boost/range/algorithm_ext/is_sorted.hpp>
+#include <boost/range/algorithm_ext/iota.hpp>
+#include <boost/range/algorithm_ext/overwrite.hpp>
+#include <boost/range/algorithm_ext/push_back.hpp>
+#include <boost/range/algorithm_ext/push_front.hpp>
+#include <boost/range/algorithm_ext/insert.hpp>
+#include <boost/range/algorithm_ext/erase.hpp>
+
+#endif
diff --git a/src/boost/range/algorithm_ext/copy_n.hpp b/src/boost/range/algorithm_ext/copy_n.hpp
new file mode 100644
index 0000000..f855441
--- /dev/null
+++ b/src/boost/range/algorithm_ext/copy_n.hpp
@@ -0,0 +1,53 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_COPY_N_HPP_INCLUDED
+
+#include <boost/assert.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/distance.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function copy
+///
+/// range-based version of the copy std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+/// \pre OutputIterator is a model of the OutputIteratorConcept
+/// \pre 0 <= n <= distance(rng)
+template< class SinglePassRange, class Size, class OutputIterator >
+inline OutputIterator copy_n(const SinglePassRange& rng, Size n, OutputIterator out)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+    BOOST_ASSERT( n <= static_cast<Size>(::boost::distance(rng)) );
+    BOOST_ASSERT( n >= static_cast<Size>(0) );
+
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type source = ::boost::begin(rng);
+
+    for (Size i = 0; i < n; ++i, ++out, ++source)
+        *out = *source;
+
+    return out;
+}
+
+    } // namespace range
+    using ::boost::range::copy_n;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/erase.hpp b/src/boost/range/algorithm_ext/erase.hpp
new file mode 100644
index 0000000..107d32b
--- /dev/null
+++ b/src/boost/range/algorithm_ext/erase.hpp
@@ -0,0 +1,61 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_ERASE_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/iterator_range_core.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+
+template< class Container >
+inline Container& erase( Container& on,
+      iterator_range<BOOST_DEDUCED_TYPENAME Container::iterator> to_erase )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
+    on.erase( boost::begin(to_erase), boost::end(to_erase) );
+    return on;
+}
+
+template< class Container, class T >
+inline Container& remove_erase( Container& on, const T& val )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
+    on.erase(
+        std::remove(boost::begin(on), boost::end(on), val),
+        boost::end(on));
+    return on;
+}
+
+template< class Container, class Pred >
+inline Container& remove_erase_if( Container& on, Pred pred )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
+    on.erase(
+        std::remove_if(boost::begin(on), boost::end(on), pred),
+        boost::end(on));
+    return on;
+}
+
+    } // namespace range
+    using range::erase;
+    using range::remove_erase;
+    using range::remove_erase_if;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/for_each.hpp b/src/boost/range/algorithm_ext/for_each.hpp
new file mode 100644
index 0000000..a470e2b
--- /dev/null
+++ b/src/boost/range/algorithm_ext/for_each.hpp
@@ -0,0 +1,86 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_FOR_EACH_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_FOR_EACH_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template<class InputIterator1, class InputIterator2, class Fn2>
+        inline Fn2 for_each_impl(InputIterator1 first1, InputIterator1 last1,
+                                 InputIterator2 first2, InputIterator2 last2,
+                                 Fn2 fn)
+        {
+            for (; first1 != last1 && first2 != last2; ++first1, ++first2)
+            {
+                fn(*first1, *first2);
+            }
+            return fn;
+        }
+    }
+
+    namespace range
+    {
+        template<class SinglePassRange1, class SinglePassRange2, class Fn2>
+        inline Fn2 for_each(const SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn)
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+            return ::boost::range_detail::for_each_impl(
+                ::boost::begin(rng1), ::boost::end(rng1),
+                ::boost::begin(rng2), ::boost::end(rng2), fn);
+        }
+
+        template<class SinglePassRange1, class SinglePassRange2, class Fn2>
+        inline Fn2 for_each(const SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn)
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+            return ::boost::range_detail::for_each_impl(
+                ::boost::begin(rng1), ::boost::end(rng1),
+                ::boost::begin(rng2), ::boost::end(rng2), fn);
+        }
+
+        template<class SinglePassRange1, class SinglePassRange2, class Fn2>
+        inline Fn2 for_each(SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn)
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+            return ::boost::range_detail::for_each_impl(
+                ::boost::begin(rng1), ::boost::end(rng1),
+                ::boost::begin(rng2), ::boost::end(rng2), fn);
+        }
+
+        template<class SinglePassRange1, class SinglePassRange2, class Fn2>
+        inline Fn2 for_each(SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn)
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+            return ::boost::range_detail::for_each_impl(
+                ::boost::begin(rng1), ::boost::end(rng1),
+                ::boost::begin(rng2), ::boost::end(rng2), fn);
+        }
+    } // namespace range
+    using range::for_each;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/insert.hpp b/src/boost/range/algorithm_ext/insert.hpp
new file mode 100644
index 0000000..b9adfdd
--- /dev/null
+++ b/src/boost/range/algorithm_ext/insert.hpp
@@ -0,0 +1,42 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+
+template< class Container, class Range >
+inline Container& insert( Container& on,
+                          BOOST_DEDUCED_TYPENAME Container::iterator before,
+                          const Range& from )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
+    BOOST_ASSERT( (void*)&on != (void*)&from &&
+                  "cannot copy from a container to itself" );
+    on.insert( before, boost::begin(from), boost::end(from) );
+    return on;
+}
+
+    } // namespace range
+    using range::insert;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/iota.hpp b/src/boost/range/algorithm_ext/iota.hpp
new file mode 100644
index 0000000..f7af446
--- /dev/null
+++ b/src/boost/range/algorithm_ext/iota.hpp
@@ -0,0 +1,54 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_IOTA_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_IOTA_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+
+template< class ForwardRange, class Value >
+inline ForwardRange& iota( ForwardRange& rng, Value x )
+{
+    BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
+    typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
+
+    iterator_t last_target = ::boost::end(rng);
+    for (iterator_t target = ::boost::begin(rng); target != last_target; ++target, ++x)
+        *target = x;
+
+    return rng;
+}
+
+template< class ForwardRange, class Value >
+inline const ForwardRange& iota( const ForwardRange& rng, Value x )
+{
+    BOOST_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
+    typedef BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type iterator_t;
+    
+    iterator_t last_target = ::boost::end(rng);
+    for (iterator_t target = ::boost::begin(rng); target != last_target; ++target, ++x)
+        *target = x;
+    
+    return rng;
+}
+
+    } // namespace range
+    using range::iota;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/is_sorted.hpp b/src/boost/range/algorithm_ext/is_sorted.hpp
new file mode 100644
index 0000000..3d00729
--- /dev/null
+++ b/src/boost/range/algorithm_ext/is_sorted.hpp
@@ -0,0 +1,57 @@
+//  Copyright Bryce Lelbach 2010
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_IS_SORTED_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_IS_SORTED_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/detail/is_sorted.hpp>
+#include <algorithm>
+
+namespace boost
+{
+    namespace range
+    {
+
+/// \brief template function is_sorted
+///
+/// range-based version of the is_sorted std algorithm
+///
+/// \pre SinglePassRange is a model of the SinglePassRangeConcept
+template<class SinglePassRange>
+inline bool is_sorted(const SinglePassRange& rng)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept<BOOST_DEDUCED_TYPENAME
+      range_value<const SinglePassRange>::type>));
+    return ::boost::detail::is_sorted(boost::begin(rng), boost::end(rng));
+}
+
+/// \overload
+template<class SinglePassRange, class BinaryPredicate>
+inline bool is_sorted(const SinglePassRange& rng, BinaryPredicate pred)
+{
+    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
+    BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
+      BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type,
+      BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type>));
+    return ::boost::detail::is_sorted(boost::begin(rng), boost::end(rng), pred);
+}
+
+    } // namespace range
+
+using range::is_sorted;
+
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/overwrite.hpp b/src/boost/range/algorithm_ext/overwrite.hpp
new file mode 100644
index 0000000..f84f6ea
--- /dev/null
+++ b/src/boost/range/algorithm_ext/overwrite.hpp
@@ -0,0 +1,84 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+
+template< class SinglePassRange1, class SinglePassRange2 >
+inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
+        i = boost::begin(from), e = boost::end(from);
+
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
+        out = boost::begin(to);
+
+#ifndef NDEBUG
+    BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
+        last_out = boost::end(to);
+#endif
+
+    for( ; i != e; ++out, ++i )
+    {
+#ifndef NDEBUG
+        BOOST_ASSERT( out != last_out
+            && "out of bounds in boost::overwrite()" );
+#endif
+        *out = *i;
+    }
+}
+
+template< class SinglePassRange1, class SinglePassRange2 >
+inline void overwrite( const SinglePassRange1& from, const SinglePassRange2& to )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
+        i = boost::begin(from), e = boost::end(from);
+
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type
+        out = boost::begin(to);
+
+#ifndef NDEBUG
+    BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type
+        last_out = boost::end(to);
+#endif
+
+    for( ; i != e; ++out, ++i )
+    {
+#ifndef NDEBUG
+        BOOST_ASSERT( out != last_out
+            && "out of bounds in boost::overwrite()" );
+#endif
+        *out = *i;
+    }
+}
+
+    } // namespace range
+    using range::overwrite;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/push_back.hpp b/src/boost/range/algorithm_ext/push_back.hpp
new file mode 100644
index 0000000..51a7a7b
--- /dev/null
+++ b/src/boost/range/algorithm_ext/push_back.hpp
@@ -0,0 +1,40 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_PUSH_BACK_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_PUSH_BACK_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+
+template< class Container, class Range >
+inline Container& push_back( Container& on, const Range& from )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
+    BOOST_ASSERT( (void*)&on != (void*)&from &&
+                  "cannot copy from a container to itself" );
+    on.insert( on.end(), boost::begin(from), boost::end(from) );
+    return on;
+}
+
+    } // namespace range
+    using range::push_back;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/algorithm_ext/push_front.hpp b/src/boost/range/algorithm_ext/push_front.hpp
new file mode 100644
index 0000000..470d793
--- /dev/null
+++ b/src/boost/range/algorithm_ext/push_front.hpp
@@ -0,0 +1,40 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ALGORITHM_EXT_PUSH_FRONT_HPP_INCLUDED
+#define BOOST_RANGE_ALGORITHM_EXT_PUSH_FRONT_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+
+template< class Container, class Range >
+inline Container& push_front( Container& on, const Range& from )
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
+    BOOST_ASSERT( (void*)&on != (void*)&from &&
+                  "cannot copy from a container to itself" );
+    on.insert( on.begin(), boost::begin(from), boost::end(from) );
+    return on;
+}
+
+    } // namespace range
+    using range::push_front;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/any_range.hpp b/src/boost/range/any_range.hpp
new file mode 100644
index 0000000..ba4c224
--- /dev/null
+++ b/src/boost/range/any_range.hpp
@@ -0,0 +1,205 @@
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
+#define BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/range/detail/any_iterator.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/reference.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/iterator_range_core.hpp>
+#include <boost/cast.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        // If T is use_default, return the result of Default, otherwise
+        // return T.
+        //
+        // This is an implementation artifact used to pick intelligent default
+        // values when the user specified boost::use_default as a template
+        // parameter.
+        template<
+            class T,
+            class Default
+        >
+        struct any_range_default_help
+            : mpl::eval_if<
+                is_same<T, use_default>
+              , Default
+              , mpl::identity<T>
+            >
+        {
+        };
+
+        template<
+            class WrappedRange
+          , class Value
+          , class Reference
+        >
+        struct any_range_value_type
+        {
+# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
+            typedef typename any_range_default_help<
+                    Value
+                  , mpl::eval_if<
+                        is_same<Reference, use_default>
+                      , range_value<
+                            typename remove_const<WrappedRange>
+                        ::type>
+                      , remove_reference<Reference>
+                    >
+                >::type type;
+# else
+            typedef typename any_range_default_help<
+                Value
+              , range_value<
+                    typename remove_const<WrappedRange>
+                ::type>
+            >::type type;
+# endif
+        };
+
+        template<
+            class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer = use_default
+        >
+        class any_range
+            : public iterator_range<
+                        any_iterator<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , typename any_range_default_help<
+                                Buffer
+                              , mpl::identity<any_iterator_default_buffer>
+                            >::type
+                        >
+                    >
+        {
+            typedef iterator_range<
+                        any_iterator<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , typename any_range_default_help<
+                                Buffer
+                              , mpl::identity<any_iterator_default_buffer>
+                            >::type
+                        >
+                    > base_type;
+
+            struct enabler {};
+            struct disabler {};
+        public:
+            any_range()
+            {
+            }
+
+            any_range(const any_range& other)
+                : base_type(other)
+            {
+            }
+
+            template<class WrappedRange>
+            any_range(WrappedRange& wrapped_range)
+            : base_type(boost::begin(wrapped_range),
+                        boost::end(wrapped_range))
+            {
+            }
+
+            template<class WrappedRange>
+            any_range(const WrappedRange& wrapped_range)
+            : base_type(boost::begin(wrapped_range),
+                        boost::end(wrapped_range))
+            {
+            }
+
+            template<
+                class OtherValue
+              , class OtherTraversal
+              , class OtherReference
+              , class OtherDifference
+            >
+            any_range(const any_range<
+                                OtherValue
+                              , OtherTraversal
+                              , OtherReference
+                              , OtherDifference
+                              , Buffer
+                            >& other)
+            : base_type(boost::begin(other), boost::end(other))
+            {
+            }
+
+            template<class Iterator>
+            any_range(Iterator first, Iterator last)
+                : base_type(first, last)
+            {
+            }
+        };
+
+        template<
+            class WrappedRange
+          , class Value = use_default
+          , class Traversal = use_default
+          , class Reference = use_default
+          , class Difference = use_default
+          , class Buffer = use_default
+        >
+        struct any_range_type_generator
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<WrappedRange> ));
+            typedef any_range<
+                typename any_range_value_type<
+                    WrappedRange
+                  , Value
+                  , typename any_range_default_help<
+                        Reference
+                      , range_reference<WrappedRange>
+                    >::type
+                >::type
+              , typename any_range_default_help<
+                            Traversal
+                          , iterator_traversal<
+                                typename range_iterator<WrappedRange>::type
+                            >
+                        >::type
+              , typename any_range_default_help<
+                    Reference
+                  , range_reference<WrappedRange>
+                >::type
+              , typename any_range_default_help<
+                    Difference
+                  , range_difference<WrappedRange>
+                >::type
+              , typename any_range_default_help<
+                    Buffer
+                  , mpl::identity<any_iterator_default_buffer>
+                >::type
+            > type;
+        };
+    } // namespace range_detail
+
+    using range_detail::any_range;
+    using range_detail::any_range_type_generator;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/as_array.hpp b/src/boost/range/as_array.hpp
new file mode 100644
index 0000000..0723e60
--- /dev/null
+++ b/src/boost/range/as_array.hpp
@@ -0,0 +1,45 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_AS_ARRAY_HPP
+#define BOOST_RANGE_AS_ARRAY_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/detail/str_types.hpp>
+
+namespace boost
+{
+
+    template< class R >
+    inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<R>::type > 
+    as_array( R& r )
+    {
+        return boost::make_iterator_range( r );
+    }
+
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+    template< class Range >
+    inline boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type > 
+    as_array( const Range& r )
+    {
+        return boost::make_iterator_range( r );
+    }
+    
+#endif
+    
+}
+
+#endif
+
diff --git a/src/boost/range/as_literal.hpp b/src/boost/range/as_literal.hpp
new file mode 100644
index 0000000..9ea144d
--- /dev/null
+++ b/src/boost/range/as_literal.hpp
@@ -0,0 +1,127 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_AS_LITERAL_HPP
+#define BOOST_RANGE_AS_LITERAL_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+#include <boost/range/detail/as_literal.hpp>
+#else
+
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/detail/str_types.hpp>
+
+#include <boost/detail/workaround.hpp>
+
+#include <cstring>
+#ifndef BOOST_NO_CWCHAR
+#include <cwchar>
+#endif
+
+namespace boost
+{
+    namespace range_detail
+    {
+        inline std::size_t length( const char* s )
+        {
+            return strlen( s );
+        }
+
+#ifndef BOOST_NO_CWCHAR
+        inline std::size_t length( const wchar_t* s )
+        {
+            return wcslen( s );
+        }
+#endif
+
+        //
+        // Remark: the compiler cannot choose between T* and T[sz]
+        // overloads, so we must put the T* internal to the
+        // unconstrained version.
+        //
+
+        inline bool is_char_ptr( char* )
+        {
+            return true;
+        }
+
+        inline bool is_char_ptr( const char* )
+        {
+            return true;
+        }
+
+#ifndef BOOST_NO_CWCHAR
+        inline bool is_char_ptr( wchar_t* )
+        {
+            return true;
+        }
+
+        inline bool is_char_ptr( const wchar_t* )
+        {
+            return true;
+        }
+#endif
+
+        template< class T >
+        inline long is_char_ptr( const T& /* r */ )
+        {
+            return 0L;
+        }
+
+        template< class T >
+        inline iterator_range<T*>
+        make_range( T* const r, bool )
+        {
+            return iterator_range<T*>( r, r + length(r) );
+        }
+
+        template< class T >
+        inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<T>::type>
+        make_range( T& r, long )
+        {
+            return boost::make_iterator_range( r );
+        }
+
+    }
+
+    template< class Range >
+    inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
+    as_literal( Range& r )
+    {
+        return range_detail::make_range( r, range_detail::is_char_ptr(r) );
+    }
+
+    template< class Range >
+    inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type>
+    as_literal( const Range& r )
+    {
+        return range_detail::make_range( r, range_detail::is_char_ptr(r) );
+    }
+
+    template< class Char, std::size_t sz >
+    inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
+    {
+        return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
+    }
+
+    template< class Char, std::size_t sz >
+    inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
+    {
+        return range_detail::make_range( arr, range_detail::is_char_ptr(arr) );
+    }
+}
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+#endif
diff --git a/src/boost/range/atl.hpp b/src/boost/range/atl.hpp
new file mode 100644
index 0000000..ab492d9
--- /dev/null
+++ b/src/boost/range/atl.hpp
@@ -0,0 +1,733 @@
+#ifndef BOOST_RANGE_ATL_HPP
+#define BOOST_RANGE_ATL_HPP
+
+
+
+
+// Boost.Range ATL Extension
+//
+// Copyright Shunsuke Sogame 2005-2006.
+// Distributed under the Boost Software License, Version 1.0. 
+// (See accompanying file LICENSE_1_0.txt or copy at 
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+
+
+// config
+//
+
+
+#include <atldef.h> // _ATL_VER
+
+
+#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+    #if (_ATL_VER < 0x0700)
+        #define BOOST_RANGE_ATL_NO_COLLECTIONS
+    #endif
+#endif
+
+
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+    #if (_ATL_VER < 0x0700) // dubious
+        #define BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX
+    #endif
+#endif
+
+
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
+    #if (_MSC_VER < 1310)   // from <boost/regex/mfc.hpp>, but dubious
+        #define BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING
+    #endif
+#endif
+
+
+
+
+// forward declarations
+//
+
+
+#include <basetyps.h> // IID
+
+
+namespace ATL {
+
+
+#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+
+
+    // arrays
+    //
+    template< class E, class ETraits >
+    class CAtlArray;
+
+    template< class E >
+    class CAutoPtrArray;
+
+    template< class I, const IID *piid >
+    class CInterfaceArray;
+
+
+    // lists
+    //
+    template< class E, class ETraits >
+    class CAtlList;
+
+    template< class E >
+    class CAutoPtrList;
+
+    template< class E, class Allocator >
+    class CHeapPtrList;
+
+    template< class I, const IID *piid >
+    class CInterfaceList;
+
+
+    // maps
+    //
+    template< class K, class V, class KTraits, class VTraits >
+    class CAtlMap;
+
+    template< class K, class V, class KTraits, class VTraits >
+    class CRBTree;
+
+    template< class K, class V, class KTraits, class VTraits >
+    class CRBMap;
+
+    template< class K, class V, class KTraits, class VTraits >
+    class CRBMultiMap;
+
+
+    // strings
+    //
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
+    template< class BaseType, bool t_bMFCDLL >
+    class CSimpleStringT;
+#else
+    template< class BaseType >
+    class CSimpleStringT;
+#endif
+
+    template< class BaseType, class StringTraits >
+    class CStringT;
+
+    template< class StringType, int t_nChars >
+    class CFixedStringT;
+
+    template< class BaseType, const int t_nSize >
+    class CStaticString;
+
+
+#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+
+
+    // simples
+    //
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+
+    template< class T, class TEqual >
+    class CSimpleArray;
+
+    template< class TKey, class TVal, class TEqual >
+    class CSimpleMap;
+
+#else
+
+    template< class T >
+    class CSimpleArray;
+
+    template< class T >
+    class CSimpleValArray;
+
+    template< class TKey, class TVal >
+    class CSimpleMap;
+
+#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+
+
+    // pointers
+    //
+    template< class E >
+    class CAutoPtr;
+
+    template< class T >
+    class CComPtr;
+
+    template< class T, const IID *piid >
+    class CComQIPtr;
+
+    template< class E, class Allocator >
+    class CHeapPtr;
+
+    template< class T >
+    class CAdapt;
+
+
+} // namespace ATL
+
+
+
+
+// indirect_iterator customizations
+//
+
+
+#include <boost/mpl/identity.hpp>
+#include <boost/pointee.hpp>
+
+
+namespace boost {
+
+
+    template< class E >
+    struct pointee< ATL::CAutoPtr<E> > :
+        mpl::identity<E>
+    { };
+
+    template< class T >
+    struct pointee< ATL::CComPtr<T> > :
+        mpl::identity<T>
+    { };
+
+    template< class T, const IID *piid >
+    struct pointee< ATL::CComQIPtr<T, piid> > :
+        mpl::identity<T>
+    { };
+
+    template< class E, class Allocator >
+    struct pointee< ATL::CHeapPtr<E, Allocator> > :
+        mpl::identity<E>
+    { };
+
+    template< class T >
+    struct pointee< ATL::CAdapt<T> > :
+        pointee<T>
+    { };
+
+
+} // namespace boost
+
+
+
+
+// extended customizations
+//
+
+
+#include <boost/iterator/indirect_iterator.hpp>
+#include <boost/iterator/zip_iterator.hpp>
+#include <boost/range/detail/microsoft.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <atlbase.h> // CComBSTR
+
+
+namespace boost { namespace range_detail_microsoft {
+
+
+#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+
+
+    // arrays
+    //
+
+    struct atl_array_functions :
+        array_functions
+    {
+        template< class Iterator, class X >
+        Iterator end(X& x) // redefine
+        {
+            return x.GetData() + x.GetCount(); // no 'GetSize()'
+        }
+    };
+
+
+    template< class E, class ETraits >
+    struct customization< ATL::CAtlArray<E, ETraits> > :
+        atl_array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef E val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< class E >
+    struct customization< ATL::CAutoPtrArray<E> > :
+        atl_array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            // ATL::CAutoPtr/CHeapPtr is no assignable.
+            typedef ATL::CAutoPtr<E> val_t;
+            typedef val_t *miter_t;
+            typedef val_t const *citer_t;
+
+            typedef indirect_iterator<miter_t> mutable_iterator;
+            typedef indirect_iterator<citer_t> const_iterator;
+        };
+    };
+
+
+    template< class I, const IID *piid >
+    struct customization< ATL::CInterfaceArray<I, piid> > :
+        atl_array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ATL::CComQIPtr<I, piid> val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< class E, class ETraits >
+    struct customization< ATL::CAtlList<E, ETraits> > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef E val_t;
+
+            typedef list_iterator<X, val_t> mutable_iterator;
+            typedef list_iterator<X const, val_t const> const_iterator;
+        };
+    };
+
+
+    struct indirected_list_functions
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            typedef typename Iterator::base_type base_t; // == list_iterator
+            return Iterator(base_t(x, x.GetHeadPosition()));
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            typedef typename Iterator::base_type base_t;
+            return Iterator(base_t(x, POSITION(0)));
+        }
+    };
+
+
+    template< class E >
+    struct customization< ATL::CAutoPtrList<E> > :
+        indirected_list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ATL::CAutoPtr<E> val_t;
+            typedef list_iterator<X, val_t> miter_t;
+            typedef list_iterator<X const, val_t const> citer_t;
+
+            typedef indirect_iterator<miter_t> mutable_iterator;
+            typedef indirect_iterator<citer_t> const_iterator;
+        };
+    };
+
+
+    template< class E, class Allocator >
+    struct customization< ATL::CHeapPtrList<E, Allocator> > :
+        indirected_list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ATL::CHeapPtr<E, Allocator> val_t;
+            typedef list_iterator<X, val_t> miter_t;
+            typedef list_iterator<X const, val_t const> citer_t;
+
+            typedef indirect_iterator<miter_t> mutable_iterator;
+            typedef indirect_iterator<citer_t> const_iterator;
+        };
+    };
+
+
+    template< class I, const IID *piid >
+    struct customization< ATL::CInterfaceList<I, piid> > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ATL::CComQIPtr<I, piid> val_t;
+
+            typedef list_iterator<X, val_t> mutable_iterator;
+            typedef list_iterator<X const, val_t const> const_iterator;
+        };
+    };
+
+
+    // maps
+    //
+
+    struct atl_rb_tree_tag
+    { };
+
+    template< >
+    struct customization< atl_rb_tree_tag > :
+        indirected_list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef typename X::CPair val_t;
+
+            typedef list_iterator<X, val_t *, val_t *> miter_t;
+            typedef list_iterator<X const, val_t const *, val_t const *> citer_t;
+            
+            typedef indirect_iterator<miter_t> mutable_iterator;
+            typedef indirect_iterator<citer_t> const_iterator;
+        };
+    };
+
+
+    template< class K, class V, class KTraits, class VTraits >
+    struct customization< ATL::CAtlMap<K, V, KTraits, VTraits> > :
+        customization< atl_rb_tree_tag >
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x) // redefine
+        {
+            typedef typename Iterator::base_type base_t; // == list_iterator
+            return Iterator(base_t(x, x.GetStartPosition())); // no 'GetHeadPosition'
+        }
+    };
+
+
+    // strings
+    //
+
+    struct atl_string_tag
+    { };
+
+    template< >
+    struct customization< atl_string_tag >
+    {
+        template< class X >
+        struct meta
+        {
+            typedef typename X::PXSTR mutable_iterator;
+            typedef typename X::PCXSTR const_iterator;
+        };
+
+        template< class Iterator, class X >
+        typename mutable_<Iterator, X>::type begin(X& x)
+        {
+            return x.GetBuffer(0);
+        }
+
+        template< class Iterator, class X >
+        Iterator begin(X const& x)
+        {
+            return x.GetString();
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return begin<Iterator>(x) + x.GetLength();
+        }
+    };
+
+
+    template< class BaseType, const int t_nSize >
+    struct customization< ATL::CStaticString<BaseType, t_nSize> >
+    {
+        template< class X >
+        struct meta
+        {
+            typedef BaseType const *mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+
+        template< class Iterator, class X >
+        Iterator begin(X const& x)
+        {
+            return x;
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X const& x)
+        {
+            return begin<Iterator>(x) + X::GetLength();
+        }
+    };
+
+
+#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+
+
+    template< >
+    struct customization< ATL::CComBSTR >
+    {
+        template< class X >
+        struct meta
+        {
+            typedef OLECHAR *mutable_iterator;
+            typedef OLECHAR const *const_iterator;
+        };
+
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return x.operator BSTR();
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return begin<Iterator>(x) + x.Length();
+        }
+    };
+
+
+    // simples
+    //
+
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+    template< class T, class TEqual >
+    struct customization< ATL::CSimpleArray<T, TEqual> > :
+#else
+    template< class T >
+    struct customization< ATL::CSimpleArray<T> > :
+#endif
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef T val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+#if defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+
+    template< class T >
+    struct customization< ATL::CSimpleValArray<T> > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef T val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+#endif // defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+
+
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+    template< class TKey, class TVal, class TEqual >
+    struct customization< ATL::CSimpleMap<TKey, TVal, TEqual> >
+#else
+    template< class TKey, class TVal >
+    struct customization< ATL::CSimpleMap<TKey, TVal> >
+#endif
+    {
+        template< class X >
+        struct meta
+        {
+            typedef TKey k_val_t;
+            typedef k_val_t *k_miter_t;
+            typedef k_val_t const *k_citer_t;
+
+            typedef TVal v_val_t;
+            typedef v_val_t *v_miter_t;
+            typedef v_val_t const *v_citer_t;
+
+            // Topic:
+            // 'std::pair' can't contain references
+            // because of reference to reference problem.
+
+            typedef zip_iterator< tuple<k_miter_t, v_miter_t> > mutable_iterator;
+            typedef zip_iterator< tuple<k_citer_t, v_citer_t> > const_iterator;
+        };
+
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return Iterator(boost::make_tuple(x.m_aKey, x.m_aVal));
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return Iterator(boost::make_tuple(x.m_aKey + x.GetSize(), x.m_aVal + x.GetSize()));
+        }
+    };
+
+
+} } // namespace boost::range_detail_microsoft
+
+
+
+
+// range customizations
+//
+
+
+#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+
+
+    // arrays
+    //
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CAtlArray, 2
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CAutoPtrArray, 1
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CInterfaceArray, (class)(const IID *)
+    )
+
+
+    // lists
+    //
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CAtlList, 2
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CAutoPtrList, 1
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CHeapPtrList, 2
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CInterfaceList, (class)(const IID *)
+    )
+
+
+    //maps
+    //
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CAtlMap, 4
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::atl_rb_tree_tag,
+        (ATL, BOOST_PP_NIL), CRBTree, 4
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::atl_rb_tree_tag,
+        (ATL, BOOST_PP_NIL), CRBMap, 4
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::atl_rb_tree_tag,
+        (ATL, BOOST_PP_NIL), CRBMultiMap, 4
+    )
+
+
+    // strings
+    //
+    #if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+            boost::range_detail_microsoft::atl_string_tag,
+            (ATL, BOOST_PP_NIL), CSimpleStringT, (class)(bool)
+        )
+    #else
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+            boost::range_detail_microsoft::atl_string_tag,
+            (ATL, BOOST_PP_NIL), CSimpleStringT, 1
+        )
+    #endif
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::atl_string_tag,
+        (ATL, BOOST_PP_NIL), CStringT, 2
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::atl_string_tag,
+        (ATL, BOOST_PP_NIL), CFixedStringT, (class)(int)
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CStaticString, (class)(const int)
+    )
+
+
+#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
+
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    (ATL, BOOST_PP_NIL), CComBSTR
+)
+
+
+// simples
+//
+#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CSimpleArray, 2
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CSimpleMap, 3
+    )
+
+#else
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CSimpleArray, 1
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CSimpleMap, 2
+    )
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        (ATL, BOOST_PP_NIL), CSimpleValArray, 1
+    )
+
+#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
+
+
+
+
+#endif
diff --git a/src/boost/range/begin.hpp b/src/boost/range/begin.hpp
new file mode 100644
index 0000000..c668488
--- /dev/null
+++ b/src/boost/range/begin.hpp
@@ -0,0 +1,143 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_BEGIN_HPP
+#define BOOST_RANGE_BEGIN_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+#include <boost/range/detail/begin.hpp>
+#else
+
+#include <boost/range/iterator.hpp>
+
+namespace boost
+{
+
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+namespace range_detail
+{
+#endif
+
+    //////////////////////////////////////////////////////////////////////
+    // primary template
+    //////////////////////////////////////////////////////////////////////
+
+    template< typename C >
+    inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
+    range_begin( C& c )
+    {
+        //
+        // If you get a compile-error here, it is most likely because
+        // you have not implemented range_begin() properly in
+        // the namespace of C
+        //
+        return c.begin();
+    }
+
+    //////////////////////////////////////////////////////////////////////
+    // pair
+    //////////////////////////////////////////////////////////////////////
+
+    template< typename Iterator >
+    inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
+    {
+        return p.first;
+    }
+
+    template< typename Iterator >
+    inline Iterator range_begin( std::pair<Iterator,Iterator>& p )
+    {
+        return p.first;
+    }
+
+    //////////////////////////////////////////////////////////////////////
+    // array
+    //////////////////////////////////////////////////////////////////////
+
+    //
+    // May this be discarded? Or is it needed for bad compilers?
+    //
+    template< typename T, std::size_t sz >
+    inline const T* range_begin( const T (&a)[sz] )
+    {
+        return a;
+    }
+
+    template< typename T, std::size_t sz >
+    inline T* range_begin( T (&a)[sz] )
+    {
+        return a;
+    }
+
+
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+} // namespace 'range_detail'
+#endif
+
+// Use a ADL namespace barrier to avoid ambiguity with other unqualified
+// calls. This is particularly important with C++0x encouraging
+// unqualified calls to begin/end.
+namespace range_adl_barrier
+{
+
+template< class T >
+inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
+{
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+    using namespace range_detail;
+#endif
+    return range_begin( r );
+}
+
+template< class T >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
+{
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+    using namespace range_detail;
+#endif
+    return range_begin( r );
+}
+
+    } // namespace range_adl_barrier
+} // namespace boost
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+namespace boost
+{
+    namespace range_adl_barrier
+    {
+        template< class T >
+        inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
+        const_begin( const T& r )
+        {
+            return boost::range_adl_barrier::begin( r );
+        }
+    } // namespace range_adl_barrier
+
+    using namespace range_adl_barrier;
+} // namespace boost
+
+#endif
+
diff --git a/src/boost/range/category.hpp b/src/boost/range/category.hpp
new file mode 100644
index 0000000..1574605
--- /dev/null
+++ b/src/boost/range/category.hpp
@@ -0,0 +1,29 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_CATEGORY_HPP
+#define BOOST_RANGE_CATEGORY_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace boost
+{
+    template< class T >
+    struct range_category : iterator_category< typename range_iterator<T>::type >
+    { };
+}
+
+#endif
diff --git a/src/boost/range/combine.hpp b/src/boost/range/combine.hpp
new file mode 100644
index 0000000..999bbc3
--- /dev/null
+++ b/src/boost/range/combine.hpp
@@ -0,0 +1,304 @@
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_COMBINE_HPP
+#define BOOST_RANGE_COMBINE_HPP
+
+#include <boost/iterator/zip_iterator.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/type_traits/is_void.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/mpl/plus.hpp>
+#include <boost/mpl/arithmetic.hpp>
+#include <boost/config.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        struct void_ { typedef void_ type; };
+    }
+
+    template<> struct range_iterator< ::boost::range_detail::void_ >
+    {
+       typedef ::boost::tuples::null_type type;
+    };
+
+    namespace range_detail
+    {
+        inline ::boost::tuples::null_type range_begin( ::boost::range_detail::void_& )
+        { return ::boost::tuples::null_type(); }
+
+        inline ::boost::tuples::null_type range_begin( const ::boost::range_detail::void_& )
+        { return ::boost::tuples::null_type(); }
+
+        inline ::boost::tuples::null_type range_end( ::boost::range_detail::void_& )
+        { return ::boost::tuples::null_type(); }
+
+        inline ::boost::tuples::null_type range_end( const ::boost::range_detail::void_& )
+        { return ::boost::tuples::null_type(); }
+
+        template< class T >
+        struct tuple_iter
+        {
+            typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::eval_if_c<
+                ::boost::is_same<T, ::boost::range_detail::void_ >::value,
+                ::boost::mpl::identity< ::boost::tuples::null_type >,
+                ::boost::range_iterator<T>
+            >::type type;
+        };
+
+        template< class Rng1, class Rng2 >
+        struct tuple_range
+        {
+            typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::eval_if_c<
+                ::boost::is_same<Rng1, ::boost::range_detail::void_ >::value,
+                ::boost::range_detail::void_,
+                ::boost::mpl::identity<Rng1>
+            >::type type;
+        };
+
+        template
+        <
+            class R1,
+            class R2,
+            class R3,
+            class R4,
+            class R5,
+            class R6
+        >
+        struct generate_tuple
+        {
+            typedef ::boost::tuples::tuple<
+                        BOOST_DEDUCED_TYPENAME tuple_iter<R1>::type,
+                        BOOST_DEDUCED_TYPENAME tuple_iter<R2>::type,
+                        BOOST_DEDUCED_TYPENAME tuple_iter<R3>::type,
+                        BOOST_DEDUCED_TYPENAME tuple_iter<R4>::type,
+                        BOOST_DEDUCED_TYPENAME tuple_iter<R5>::type,
+                        BOOST_DEDUCED_TYPENAME tuple_iter<R6>::type
+                    > type;
+
+            static type begin( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 )
+            {
+                return ::boost::tuples::make_tuple( ::boost::begin(r1),
+                                                    ::boost::begin(r2),
+                                                    ::boost::begin(r3),
+                                                    ::boost::begin(r4),
+                                                    ::boost::begin(r5),
+                                                    ::boost::begin(r6) );
+            }
+
+            static type end( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 )
+            {
+                return ::boost::tuples::make_tuple( ::boost::end(r1),
+                                                    ::boost::end(r2),
+                                                    ::boost::end(r3),
+                                                    ::boost::end(r4),
+                                                    ::boost::end(r5),
+                                                    ::boost::end(r6) );
+            }
+        };
+
+        template
+        <
+            class R1,
+            class R2 = void_,
+            class R3 = void_,
+            class R4 = void_,
+            class R5 = void_,
+            class R6 = void_
+        >
+        struct zip_rng
+            : iterator_range<
+                zip_iterator<
+                    BOOST_DEDUCED_TYPENAME generate_tuple<R1,R2,R3,R4,R5,R6>::type
+                >
+            >
+        {
+        private:
+            typedef generate_tuple<R1,R2,R3,R4,R5,R6>        generator_t;
+            typedef BOOST_DEDUCED_TYPENAME generator_t::type tuple_t;
+            typedef zip_iterator<tuple_t>                    zip_iter_t;
+            typedef iterator_range<zip_iter_t>               base_t;
+
+        public:
+            zip_rng( R1& r1, R2& r2, R3& r3, R4& r4, R5& r5, R6& r6 )
+            : base_t( zip_iter_t( generator_t::begin(r1,r2,r3,r4,r5,r6) ),
+                      zip_iter_t( generator_t::end(r1,r2,r3,r4,r5,r6) ) )
+            {
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r2));
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r3));
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r4));
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r5));
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r6));
+            }
+
+            template< class Zip, class Rng >
+            zip_rng( Zip& z, Rng& r )
+            : base_t( zip_iter_t( generator_t::begin( z, r ) ),
+                      zip_iter_t( generator_t::end( z, r ) ) )
+            {
+
+                // @todo: tuple::begin( should be overloaded for this situation
+            }
+
+            struct tuple_length : ::boost::tuples::length<tuple_t>
+            { };
+
+            template< unsigned N >
+            struct get
+            {
+                template< class Z, class R >
+                static BOOST_DEDUCED_TYPENAME ::boost::tuples::element<N,tuple_t>::type begin( Z& z, R& )
+                {
+                    return get<N>( z.begin().get_iterator_tuple() );
+                }
+
+                template< class Z, class R >
+                static BOOST_DEDUCED_TYPENAME ::boost::tuples::element<N,tuple_t>::type end( Z& z, R& r )
+                {
+                    return get<N>( z.end().get_iterator_tuple() );
+                }
+            };
+
+        };
+
+        template< class Rng1, class Rng2 >
+        struct zip_range
+            : iterator_range<
+                zip_iterator<
+                    ::boost::tuples::tuple<
+                        BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
+                        BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type
+                    >
+                >
+            >
+        {
+        private:
+            typedef zip_iterator<
+                        ::boost::tuples::tuple<
+                            BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
+                            BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type
+                        >
+                    > zip_iter_t;
+            typedef iterator_range<zip_iter_t> base_t;
+
+        public:
+            zip_range( Rng1& r1, Rng2& r2 )
+            : base_t( zip_iter_t( ::boost::tuples::make_tuple(::boost::begin(r1),
+                                                              ::boost::begin(r2)) ),
+                      zip_iter_t( ::boost::tuples::make_tuple(::boost::end(r1),
+                                                              ::boost::end(r2)) ) )
+            {
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r2));
+            }
+        };
+
+        template< class Rng1, class Rng2, class Rng3 >
+        struct zip_range3
+            : iterator_range<
+                zip_iterator<
+                    ::boost::tuples::tuple<
+                        BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
+                        BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type,
+                        BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng3>::type
+                    >
+                >
+            >
+        {
+        private:
+            typedef zip_iterator<
+                ::boost::tuples::tuple<
+                    BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng1>::type,
+                    BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng2>::type,
+                    BOOST_DEDUCED_TYPENAME ::boost::range_iterator<Rng3>::type
+                >
+            > zip_iter_t;
+            typedef iterator_range<zip_iter_t> base_t;
+
+        public:
+            zip_range3( Rng1& r1, Rng2& r2, Rng3& r3 )
+            : base_t( zip_iter_t( ::boost::tuples::make_tuple(::boost::begin(r1),
+                                                              ::boost::begin(r2),
+                                                              ::boost::begin(r3)) ),
+                      zip_iter_t( ::boost::tuples::make_tuple(::boost::end(r1),
+                                                              ::boost::end(r2),
+                                                              ::boost::end(r3)) )
+                    )
+            {
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r2));
+                BOOST_ASSERT(::boost::distance(r1) <= ::boost::distance(r3));
+            }
+        };
+
+
+        struct combine_tag {};
+
+        template< class Rng >
+        inline zip_rng<Rng>
+        operator&( combine_tag, Rng& r )
+        {
+            return zip_rng<Rng>(r);
+        }
+
+        template< class Rng >
+        inline iterator_range<const Rng>
+        operator&( combine_tag, const Rng& r )
+        {
+            return iterator_range<const Rng>(r);
+        }
+
+        template
+        <
+            class R1,
+            class R2,
+            class R3,
+            class R4,
+            class R5,
+            class Rng
+        >
+        inline BOOST_DEDUCED_TYPENAME zip_rng<R1,R2,R3,R4,R5>::next
+        operator&( const zip_rng<R1,R2,R3,R4,R5>& zip,
+                   Rng& r )
+        {
+            return zip_rng<R1,R2,R3,R4,R5>::next( zip, r );
+        }
+
+    } // namespace range_detail
+
+    template< class Rng1, class Rng2 >
+    inline ::boost::range_detail::zip_range<Rng1, Rng2> combine( Rng1& r1, Rng2& r2 )
+    {
+        return ::boost::range_detail::zip_range<Rng1, Rng2>(r1, r2);
+    }
+
+    template< class Rng1, class Rng2 >
+    inline ::boost::range_detail::zip_range<const Rng1, Rng2> combine( const Rng1& r1, Rng2& r2 )
+    {
+        return ::boost::range_detail::zip_range<const Rng1, Rng2>(r1, r2);
+    }
+
+    template< class Rng1, class Rng2 >
+    inline ::boost::range_detail::zip_range<Rng1, const Rng2> combine( Rng1& r1, const Rng2& r2 )
+    {
+        return ::boost::range_detail::zip_range<Rng1, const Rng2>(r1, r2);
+    }
+
+    template< class Rng1, class Rng2 >
+    inline ::boost::range_detail::zip_range<const Rng1, const Rng2> combine( const Rng1& r1, const Rng2& r2 )
+    {
+        return ::boost::range_detail::zip_range<const Rng1, const Rng2>(r1, r2);
+    }
+
+} // namespace boost
+
+#endif
diff --git a/src/boost/range/concepts.hpp b/src/boost/range/concepts.hpp
new file mode 100644
index 0000000..5965293
--- /dev/null
+++ b/src/boost/range/concepts.hpp
@@ -0,0 +1,366 @@
+// Boost.Range library concept checks
+//
+//  Copyright Neil Groves 2009. Use, modification and distribution
+//  are subject to the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//  Copyright Daniel Walker 2006. Use, modification and distribution
+//  are subject to the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_CONCEPTS_HPP
+#define BOOST_RANGE_CONCEPTS_HPP
+
+#include <boost/concept_check.hpp>
+#include <boost/iterator/iterator_concepts.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/detail/misc_concept.hpp>
+
+/*!
+ * \file
+ * \brief Concept checks for the Boost Range library.
+ *
+ * The structures in this file may be used in conjunction with the
+ * Boost Concept Check library to insure that the type of a function
+ * parameter is compatible with a range concept. If not, a meaningful
+ * compile time error is generated. Checks are provided for the range
+ * concepts related to iterator traversal categories. For example, the
+ * following line checks that the type T models the ForwardRange
+ * concept.
+ *
+ * \code
+ * BOOST_CONCEPT_ASSERT((ForwardRangeConcept<T>));
+ * \endcode
+ *
+ * A different concept check is required to ensure writeable value
+ * access. For example to check for a ForwardRange that can be written
+ * to, the following code is required.
+ *
+ * \code
+ * BOOST_CONCEPT_ASSERT((WriteableForwardRangeConcept<T>));
+ * \endcode
+ *
+ * \see http://www.boost.org/libs/range/doc/range.html for details
+ * about range concepts.
+ * \see http://www.boost.org/libs/iterator/doc/iterator_concepts.html
+ * for details about iterator concepts.
+ * \see http://www.boost.org/libs/concept_check/concept_check.htm for
+ * details about concept checks.
+ */
+
+namespace boost {
+
+    namespace range_detail {
+
+#ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+
+// List broken compiler versions here:
+    #ifdef __GNUC__
+        // GNUC 4.2 has strange issues correctly detecting compliance with the Concepts
+        // hence the least disruptive approach is to turn-off the concept checking for
+        // this version of the compiler.
+        #if __GNUC__ == 4 && __GNUC_MINOR__ == 2
+            #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
+        #endif
+    #endif
+
+    #ifdef __BORLANDC__
+        #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
+    #endif
+
+    #ifdef __PATHCC__
+        #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
+    #endif
+
+// Default to using the concept asserts unless we have defined it off
+// during the search for black listed compilers.
+    #ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+        #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 1
+    #endif
+
+#endif
+
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+    #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x )
+#else
+    #define BOOST_RANGE_CONCEPT_ASSERT( x )
+#endif
+
+        // Rationale for the inclusion of redefined iterator concept
+        // classes:
+        //
+        // The Range algorithms often do not require that the iterators are
+        // Assignable or default constructable, but the correct standard
+        // conformant iterators do require the iterators to be a model of the
+        // Assignable concept.
+        // Iterators that contains a functor that is not assignable therefore
+        // are not correct models of the standard iterator concepts,
+        // despite being adequate for most algorithms. An example of this
+        // use case is the combination of the boost::adaptors::filtered
+        // class with a boost::lambda::bind generated functor.
+        // Ultimately modeling the range concepts using composition
+        // with the Boost.Iterator concepts would render the library
+        // incompatible with many common Boost.Lambda expressions.
+        template<class Iterator>
+        struct IncrementableIteratorConcept : CopyConstructible<Iterator>
+        {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+            typedef BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator>::type traversal_category;
+
+            BOOST_RANGE_CONCEPT_ASSERT((
+                Convertible<
+                    traversal_category,
+                    incrementable_traversal_tag
+                >));
+
+            BOOST_CONCEPT_USAGE(IncrementableIteratorConcept)
+            {
+                ++i;
+                (void)i++;
+            }
+        private:
+            Iterator i;
+#endif
+        };
+
+        template<class Iterator>
+        struct SinglePassIteratorConcept
+            : IncrementableIteratorConcept<Iterator>
+            , EqualityComparable<Iterator>
+        {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+            BOOST_RANGE_CONCEPT_ASSERT((
+                Convertible<
+                    BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category,
+                    single_pass_traversal_tag
+                >));
+
+            BOOST_CONCEPT_USAGE(SinglePassIteratorConcept)
+            {
+                Iterator i2(++i);
+                boost::ignore_unused_variable_warning(i2);
+
+                // deliberately we are loose with the postfix version for the single pass
+                // iterator due to the commonly poor adherence to the specification means that
+                // many algorithms would be unusable, whereas actually without the check they
+                // work
+                (void)(i++);
+
+                BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r1(*i);
+                boost::ignore_unused_variable_warning(r1);
+
+                BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r2(*(++i));
+                boost::ignore_unused_variable_warning(r2);
+            }
+        private:
+            Iterator i;
+#endif
+        };
+
+        template<class Iterator>
+        struct ForwardIteratorConcept
+            : SinglePassIteratorConcept<Iterator>
+            , DefaultConstructible<Iterator>
+        {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+            typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::difference_type difference_type;
+
+            BOOST_MPL_ASSERT((is_integral<difference_type>));
+            BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
+
+            BOOST_RANGE_CONCEPT_ASSERT((
+                Convertible<
+                    BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category,
+                    forward_traversal_tag
+                >));
+
+            BOOST_CONCEPT_USAGE(ForwardIteratorConcept)
+            {
+                // See the above note in the SinglePassIteratorConcept about the handling of the
+                // postfix increment. Since with forward and better iterators there is no need
+                // for a proxy, we can sensibly require that the dereference result
+                // is convertible to reference.
+                Iterator i2(i++);
+                boost::ignore_unused_variable_warning(i2);
+                BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r(*(i++));
+                boost::ignore_unused_variable_warning(r);
+            }
+        private:
+            Iterator i;
+#endif
+         };
+
+         template<class Iterator>
+         struct BidirectionalIteratorConcept
+             : ForwardIteratorConcept<Iterator>
+         {
+ #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+             BOOST_RANGE_CONCEPT_ASSERT((
+                 Convertible<
+                     BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept::traversal_category,
+                     bidirectional_traversal_tag
+                 >));
+
+             BOOST_CONCEPT_USAGE(BidirectionalIteratorConcept)
+             {
+                 --i;
+                 (void)i--;
+             }
+         private:
+             Iterator i;
+ #endif
+         };
+
+         template<class Iterator>
+         struct RandomAccessIteratorConcept
+             : BidirectionalIteratorConcept<Iterator>
+         {
+ #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+             BOOST_RANGE_CONCEPT_ASSERT((
+                 Convertible<
+                     BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::traversal_category,
+                     random_access_traversal_tag
+                 >));
+
+             BOOST_CONCEPT_USAGE(RandomAccessIteratorConcept)
+             {
+                 i += n;
+                 i = i + n;
+                 i = n + i;
+                 i -= n;
+                 i = i - n;
+                 n = i - j;
+             }
+         private:
+             BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n;
+             Iterator i;
+             Iterator j;
+ #endif
+         };
+
+    } // namespace range_detail
+
+    //! Check if a type T models the SinglePassRange range concept.
+    template<class T>
+    struct SinglePassRangeConcept
+    {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+         typedef BOOST_DEDUCED_TYPENAME range_iterator<T const>::type  const_iterator;
+         typedef BOOST_DEDUCED_TYPENAME range_iterator<T>::type        iterator;
+
+         BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<iterator>));
+         BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<const_iterator>));
+
+         BOOST_CONCEPT_USAGE(SinglePassRangeConcept)
+         {
+            // This has been modified from assigning to this->i
+            // (where i was a member variable) to improve
+            // compatibility with Boost.Lambda
+            iterator i1 = boost::begin(*m_range);
+            iterator i2 = boost::end(*m_range);
+
+            ignore_unused_variable_warning(i1);
+            ignore_unused_variable_warning(i2);
+
+            const_constraints(*m_range);
+        }
+
+    private:
+        void const_constraints(const T& const_range)
+        {
+            const_iterator ci1 = boost::begin(const_range);
+            const_iterator ci2 = boost::end(const_range);
+
+            ignore_unused_variable_warning(ci1);
+            ignore_unused_variable_warning(ci2);
+        }
+
+       // Rationale:
+       // The type of m_range is T* rather than T because it allows
+       // T to be an abstract class. The other obvious alternative of
+       // T& produces a warning on some compilers.
+       T* m_range;
+#endif
+    };
+
+    //! Check if a type T models the ForwardRange range concept.
+    template<class T>
+    struct ForwardRangeConcept : SinglePassRangeConcept<T>
+    {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+        BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::iterator>));
+        BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::const_iterator>));
+#endif
+    };
+
+    template<class Range>
+    struct WriteableRangeConcept
+    {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<Range>::type iterator;
+
+        BOOST_CONCEPT_USAGE(WriteableRangeConcept)
+        {
+            *i = v;
+        }
+    private:
+        iterator i;
+        BOOST_DEDUCED_TYPENAME range_value<Range>::type v;
+#endif
+    };
+
+    //! Check if a type T models the WriteableForwardRange range concept.
+    template<class T>
+    struct WriteableForwardRangeConcept
+        : ForwardRangeConcept<T>
+        , WriteableRangeConcept<T>
+    {
+    };
+
+    //! Check if a type T models the BidirectionalRange range concept.
+    template<class T>
+    struct BidirectionalRangeConcept : ForwardRangeConcept<T>
+    {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+        BOOST_RANGE_CONCEPT_ASSERT((BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::iterator>));
+        BOOST_RANGE_CONCEPT_ASSERT((BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::const_iterator>));
+#endif
+    };
+
+    //! Check if a type T models the WriteableBidirectionalRange range concept.
+    template<class T>
+    struct WriteableBidirectionalRangeConcept
+        : BidirectionalRangeConcept<T>
+        , WriteableRangeConcept<T>
+    {
+    };
+
+    //! Check if a type T models the RandomAccessRange range concept.
+    template<class T>
+    struct RandomAccessRangeConcept : BidirectionalRangeConcept<T>
+    {
+#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
+        BOOST_RANGE_CONCEPT_ASSERT((RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::iterator>));
+        BOOST_RANGE_CONCEPT_ASSERT((RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::const_iterator>));
+#endif
+    };
+
+    //! Check if a type T models the WriteableRandomAccessRange range concept.
+    template<class T>
+    struct WriteableRandomAccessRangeConcept
+        : RandomAccessRangeConcept<T>
+        , WriteableRangeConcept<T>
+    {
+    };
+
+} // namespace boost
+
+#endif // BOOST_RANGE_CONCEPTS_HPP
diff --git a/src/boost/range/config.hpp b/src/boost/range/config.hpp
new file mode 100644
index 0000000..4e7fb24
--- /dev/null
+++ b/src/boost/range/config.hpp
@@ -0,0 +1,54 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_CONFIG_HPP
+#define BOOST_RANGE_CONFIG_HPP
+
+#include <boost/detail/workaround.hpp>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_RANGE_DEDUCED_TYPENAME
+#error "macro already defined!"
+#endif
+
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+# define BOOST_RANGE_DEDUCED_TYPENAME typename
+#else
+# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) && !defined(_MSC_EXTENSIONS)
+#  define BOOST_RANGE_DEDUCED_TYPENAME typename
+# else
+#  define BOOST_RANGE_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
+# endif
+#endif
+
+#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
+#error "macro already defined!"
+#endif
+
+#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
+#define BOOST_RANGE_NO_ARRAY_SUPPORT 1
+#endif
+
+#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
+#define BOOST_RANGE_ARRAY_REF() (boost_range_array)
+#define BOOST_RANGE_NO_STATIC_ASSERT
+#else
+#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
+#endif
+
+
+
+#endif
+
diff --git a/src/boost/range/const_iterator.hpp b/src/boost/range/const_iterator.hpp
new file mode 100644
index 0000000..875320f
--- /dev/null
+++ b/src/boost/range/const_iterator.hpp
@@ -0,0 +1,67 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_CONST_ITERATOR_HPP
+#define BOOST_RANGE_CONST_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/range/detail/const_iterator.hpp>
+#else
+
+#include <boost/range/detail/extract_optional_type.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <cstddef>
+#include <utility>
+
+namespace boost
+{
+    //////////////////////////////////////////////////////////////////////////
+    // default
+    //////////////////////////////////////////////////////////////////////////
+    
+    namespace range_detail {
+        BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( const_iterator )
+    }
+
+    template< typename C >
+    struct range_const_iterator : range_detail::extract_const_iterator<C>
+    {};
+    
+    //////////////////////////////////////////////////////////////////////////
+    // pair
+    //////////////////////////////////////////////////////////////////////////
+
+    template< typename Iterator >
+    struct range_const_iterator< std::pair<Iterator,Iterator> >
+    {
+        typedef Iterator type;
+    };
+    
+    //////////////////////////////////////////////////////////////////////////
+    // array
+    //////////////////////////////////////////////////////////////////////////
+
+    template< typename T, std::size_t sz >
+    struct range_const_iterator< T[sz] >
+    {
+        typedef const T* type;
+    };
+
+} // namespace boost
+
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#endif
diff --git a/src/boost/range/const_reverse_iterator.hpp b/src/boost/range/const_reverse_iterator.hpp
new file mode 100644
index 0000000..215bcc7
--- /dev/null
+++ b/src/boost/range/const_reverse_iterator.hpp
@@ -0,0 +1,32 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP
+#define BOOST_RANGE_CONST_REVERSE_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/reverse_iterator.hpp>
+
+namespace boost
+{
+    //
+    // This interface is deprecated, use range_reverse_iterator<const T>
+    //
+    
+    template< typename C >
+    struct range_const_reverse_iterator : range_reverse_iterator<const C>
+    { };
+    
+} // namespace boost
+
+#endif
diff --git a/src/boost/range/counting_range.hpp b/src/boost/range/counting_range.hpp
new file mode 100644
index 0000000..b8e4e3a
--- /dev/null
+++ b/src/boost/range/counting_range.hpp
@@ -0,0 +1,66 @@
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
+#define BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#if BOOST_MSVC >= 1400
+#pragma warning(push)
+#pragma warning(disable : 4244)
+#endif
+
+#include <boost/range/iterator_range_core.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/iterator/counting_iterator.hpp>
+
+namespace boost
+{
+
+    template<class Value>
+    inline iterator_range<counting_iterator<Value> >
+    counting_range(Value first, Value last)
+    {
+        typedef counting_iterator<Value> counting_iterator_t;
+        typedef iterator_range<counting_iterator_t> result_t;
+        return result_t(counting_iterator_t(first),
+                        counting_iterator_t(last));
+    }
+
+    template<class Range>
+    inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> >
+    counting_range(const Range& rng)
+    {
+        typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> counting_iterator_t;
+        typedef iterator_range<counting_iterator_t> result_t;
+        return boost::empty(rng)
+            ? result_t()
+            : result_t(
+                counting_iterator_t(*boost::begin(rng)),
+                counting_iterator_t(*boost::prior(boost::end(rng))));
+    }
+
+    template<class Range>
+    inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> >
+    counting_range(Range& rng)
+    {
+        typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> counting_iterator_t;
+        typedef iterator_range<counting_iterator_t> result_t;
+        return boost::empty(rng)
+            ? result_t()
+            : result_t(
+                counting_iterator_t(*boost::begin(rng)),
+                counting_iterator_t(*boost::prior(boost::end(rng))));
+    }
+} // namespace boost
+
+#if BOOST_MSVC >= 1400
+#pragma warning(pop)
+#endif
+
+#endif // include guard
diff --git a/src/boost/range/detail/any_iterator.hpp b/src/boost/range/detail/any_iterator.hpp
new file mode 100644
index 0000000..5705ff0
--- /dev/null
+++ b/src/boost/range/detail/any_iterator.hpp
@@ -0,0 +1,586 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_ANY_ITERATOR_HPP_INCLUDED
+
+#include <boost/cast.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/range/detail/any_iterator_buffer.hpp>
+#include <boost/range/detail/any_iterator_interface.hpp>
+#include <boost/range/detail/any_iterator_wrapper.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        // metafunction to determine if T is a const reference
+        template<class T>
+        struct is_const_reference
+        {
+            typedef typename mpl::and_<
+                typename is_reference<T>::type,
+                typename is_const<
+                    typename remove_reference<T>::type
+                >::type
+            >::type type;
+        };
+
+        // metafunction to determine if T is a mutable reference
+        template<class T>
+        struct is_mutable_reference
+        {
+            typedef typename mpl::and_<
+                typename is_reference<T>::type,
+                typename mpl::not_<
+                    typename is_const<
+                        typename remove_reference<T>::type
+                    >::type
+                >::type
+            >::type type;
+        };
+
+        // metafunction to evaluate if a source 'reference' can be
+        // converted to a target 'reference' as a value.
+        //
+        // This is true, when the target reference type is actually
+        // not a reference, and the source reference is convertible
+        // to the target type.
+        template<class SourceReference, class TargetReference>
+        struct is_convertible_to_value_as_reference
+        {
+            typedef typename mpl::and_<
+                typename mpl::not_<
+                    typename is_reference<TargetReference>::type
+                >::type
+              , typename is_convertible<
+                    SourceReference
+                  , TargetReference
+                >::type
+            >::type type;
+        };
+
+        template<
+            class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer = any_iterator_default_buffer
+        >
+        class any_iterator;
+
+        // metafunction to determine if SomeIterator is an
+        // any_iterator.
+        //
+        // This is the general implementation which evaluates to false.
+        template<class SomeIterator>
+        struct is_any_iterator
+            : mpl::bool_<false>
+        {
+        };
+
+        // specialization of is_any_iterator to return true for
+        // any_iterator classes regardless of template parameters.
+        template<
+            class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct is_any_iterator<
+            any_iterator<
+                Value
+              , Traversal
+              , Reference
+              , Difference
+              , Buffer
+            >
+        >
+            : mpl::bool_<true>
+        {
+        };
+    } // namespace range_detail
+
+    namespace detail
+    {
+        // Rationale:
+        // These are specialized since the iterator_facade versions lack
+        // the requisite typedefs to allow wrapping to determine the types
+        // if a user copy constructs from a postfix increment.
+
+        template<
+            class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        class postfix_increment_proxy<
+                    range_detail::any_iterator<
+                        Value
+                      , Traversal
+                      , Reference
+                      , Difference
+                      , Buffer
+                    >
+                >
+        {
+            typedef range_detail::any_iterator<
+                Value
+              , Traversal
+              , Reference
+              , Difference
+              , Buffer
+            > any_iterator_type;
+
+        public:
+            typedef Value value_type;
+            typedef typename std::iterator_traits<any_iterator_type>::iterator_category iterator_category;
+            typedef Difference difference_type;
+            typedef typename iterator_pointer<any_iterator_type>::type pointer;
+            typedef Reference reference;
+
+            explicit postfix_increment_proxy(any_iterator_type const& x)
+                : stored_value(*x)
+            {}
+
+            value_type&
+            operator*() const
+            {
+                return this->stored_value;
+            }
+        private:
+            mutable value_type stored_value;
+        };
+
+        template<
+            class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        class writable_postfix_increment_proxy<
+                    range_detail::any_iterator<
+                        Value
+                      , Traversal
+                      , Reference
+                      , Difference
+                      , Buffer
+                    >
+                >
+        {
+            typedef range_detail::any_iterator<
+                        Value
+                      , Traversal
+                      , Reference
+                      , Difference
+                      , Buffer
+                    > any_iterator_type;
+         public:
+            typedef Value value_type;
+            typedef typename std::iterator_traits<any_iterator_type>::iterator_category iterator_category;
+            typedef Difference difference_type;
+            typedef typename iterator_pointer<any_iterator_type>::type pointer;
+            typedef Reference reference;
+
+            explicit writable_postfix_increment_proxy(any_iterator_type const& x)
+              : stored_value(*x)
+              , stored_iterator(x)
+            {}
+
+            // Dereferencing must return a proxy so that both *r++ = o and
+            // value_type(*r++) can work.  In this case, *r is the same as
+            // *r++, and the conversion operator below is used to ensure
+            // readability.
+            writable_postfix_increment_proxy const&
+            operator*() const
+            {
+                return *this;
+            }
+
+            // Provides readability of *r++
+            operator value_type&() const
+            {
+                return stored_value;
+            }
+
+            // Provides writability of *r++
+            template <class T>
+            T const& operator=(T const& x) const
+            {
+                *this->stored_iterator = x;
+                return x;
+            }
+
+            // This overload just in case only non-const objects are writable
+            template <class T>
+            T& operator=(T& x) const
+            {
+                *this->stored_iterator = x;
+                return x;
+            }
+
+            // Provides X(r++)
+            operator any_iterator_type const&() const
+            {
+                return stored_iterator;
+            }
+
+         private:
+            mutable value_type stored_value;
+            any_iterator_type stored_iterator;
+        };
+
+
+    }
+
+    namespace range_detail
+    {
+        template<
+            class Value
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        class any_iterator
+            : public iterator_facade<
+                        any_iterator<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , Buffer
+                        >
+                    , Value
+                    , Traversal
+                    , Reference
+                    , Difference
+                >
+        {
+            template<
+                class OtherValue
+              , class OtherTraversal
+              , class OtherReference
+              , class OtherDifference
+              , class OtherBuffer
+            >
+            friend class any_iterator;
+
+            struct enabler {};
+            struct disabler {};
+
+            typedef typename any_iterator_interface_type_generator<
+                Traversal
+              , Reference
+              , Difference
+              , Buffer
+            >::type abstract_base_type;
+
+            typedef iterator_facade<
+                        any_iterator<
+                            Value
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , Buffer
+                        >
+                      , Value
+                      , Traversal
+                      , Reference
+                      , Difference
+                  > base_type;
+
+            typedef Buffer buffer_type;
+
+        public:
+            typedef typename base_type::value_type value_type;
+            typedef typename base_type::reference reference;
+            typedef typename base_type::difference_type difference_type;
+
+            // Default constructor
+            any_iterator()
+                : m_impl(0) {}
+
+            // Simple copy construction without conversion
+            any_iterator(const any_iterator& other)
+                : base_type(other)
+                , m_impl(other.m_impl
+                            ? other.m_impl->clone(m_buffer)
+                            : 0)
+            {
+            }
+
+            // Simple assignment operator without conversion
+            any_iterator& operator=(const any_iterator& other)
+            {
+                if (this != &other)
+                {
+                    if (m_impl)
+                        m_impl->~abstract_base_type();
+                    m_buffer.deallocate();
+                    m_impl = 0;
+                    if (other.m_impl)
+                        m_impl = other.m_impl->clone(m_buffer);
+                }
+                return *this;
+            }
+
+            // Implicit conversion from another any_iterator where the
+            // conversion is from a non-const reference to a const reference
+            template<
+                class OtherValue
+              , class OtherTraversal
+              , class OtherReference
+              , class OtherDifference
+            >
+            any_iterator(const any_iterator<
+                                OtherValue,
+                                OtherTraversal,
+                                OtherReference,
+                                OtherDifference,
+                                Buffer
+                            >& other,
+                         typename enable_if<
+                            typename mpl::and_<
+                                typename is_mutable_reference<OtherReference>::type,
+                                typename is_const_reference<Reference>::type
+                            >::type,
+                            enabler
+                        >::type* = 0
+                    )
+                : m_impl(other.m_impl
+                            ? other.m_impl->clone_const_ref(m_buffer)
+                         : 0
+                        )
+            {
+            }
+
+            // Implicit conversion from another any_iterator where the
+            // reference types of the source and the target are references
+            // that are either both const, or both non-const.
+            template<
+                class OtherValue
+              , class OtherTraversal
+              , class OtherReference
+              , class OtherDifference
+            >
+            any_iterator(const any_iterator<
+                                OtherValue
+                              , OtherTraversal
+                              , OtherReference
+                              , OtherDifference
+                              , Buffer
+                            >& other,
+                         typename enable_if<
+                            typename mpl::or_<
+                                typename mpl::and_<
+                                    typename is_mutable_reference<OtherReference>::type,
+                                    typename is_mutable_reference<Reference>::type
+                                >::type,
+                                typename mpl::and_<
+                                    typename is_const_reference<OtherReference>::type,
+                                    typename is_const_reference<Reference>::type
+                                >::type
+                            >::type,
+                            enabler
+                        >::type* = 0
+                        )
+                : m_impl(other.m_impl
+                            ? other.m_impl->clone(m_buffer)
+                         : 0
+                        )
+            {
+            }
+
+            // Implicit conversion to an any_iterator that uses a value for
+            // the reference type.
+            template<
+                class OtherValue
+              , class OtherTraversal
+              , class OtherReference
+              , class OtherDifference
+            >
+            any_iterator(const any_iterator<
+                                OtherValue
+                              , OtherTraversal
+                              , OtherReference
+                              , OtherDifference
+                              , Buffer
+                            >& other,
+                        typename enable_if<
+                            typename is_convertible_to_value_as_reference<
+                                        OtherReference
+                                      , Reference
+                                    >::type,
+                            enabler
+                        >::type* = 0
+                        )
+                : m_impl(other.m_impl
+                            ? other.m_impl->clone_reference_as_value(m_buffer)
+                            : 0
+                            )
+            {
+            }
+
+            any_iterator clone() const
+            {
+                any_iterator result;
+                if (m_impl)
+                    result.m_impl = m_impl->clone(result.m_buffer);
+                return result;
+            }
+
+            any_iterator<
+                Value
+              , Traversal
+              , typename abstract_base_type::const_reference
+              , Difference
+              , Buffer
+            >
+            clone_const_ref() const
+            {
+                typedef any_iterator<
+                    Value
+                  , Traversal
+                  , typename abstract_base_type::const_reference
+                  , Difference
+                  , Buffer
+                > result_type;
+
+                result_type result;
+
+                if (m_impl)
+                    result.m_impl = m_impl->clone_const_ref(result.m_buffer);
+
+                return result;
+            }
+
+            // implicit conversion and construction from type-erasure-compatible
+            // iterators
+            template<class WrappedIterator>
+            explicit any_iterator(
+                const WrappedIterator& wrapped_iterator,
+                typename disable_if<
+                    typename is_any_iterator<WrappedIterator>::type
+                  , disabler
+                >::type* = 0
+                )
+            {
+                typedef typename any_iterator_wrapper_type_generator<
+                            WrappedIterator
+                          , Traversal
+                          , Reference
+                          , Difference
+                          , Buffer
+                        >::type wrapper_type;
+
+                void* ptr = m_buffer.allocate(sizeof(wrapper_type));
+                m_impl = new(ptr) wrapper_type(wrapped_iterator);
+            }
+
+            ~any_iterator()
+            {
+                // manually run the destructor, the deallocation is automatically
+                // handled by the any_iterator_small_buffer base class.
+                if (m_impl)
+                    m_impl->~abstract_base_type();
+            }
+
+        private:
+            friend class ::boost::iterator_core_access;
+
+            Reference dereference() const
+            {
+                BOOST_ASSERT( m_impl );
+                return m_impl->dereference();
+            }
+
+            bool equal(const any_iterator& other) const
+            {
+                return (m_impl == other.m_impl)
+                    || (m_impl && other.m_impl && m_impl->equal(*other.m_impl));
+            }
+
+            void increment()
+            {
+                BOOST_ASSERT( m_impl );
+                m_impl->increment();
+            }
+
+            void decrement()
+            {
+                BOOST_ASSERT( m_impl );
+                m_impl->decrement();
+            }
+
+            Difference distance_to(const any_iterator& other) const
+            {
+                return m_impl && other.m_impl
+                    ? m_impl->distance_to(*other.m_impl)
+                    : 0;
+            }
+
+            void advance(Difference offset)
+            {
+                BOOST_ASSERT( m_impl );
+                m_impl->advance(offset);
+            }
+
+            any_iterator& swap(any_iterator& other)
+            {
+                BOOST_ASSERT( this != &other );
+                // grab a temporary copy of the other iterator
+                any_iterator tmp(other);
+
+                // deallocate the other iterator, taking care to obey the
+                // class-invariants in-case of exceptions later
+                if (other.m_impl)
+                {
+                    other.m_impl->~abstract_base_type();
+                    other.m_buffer.deallocate();
+                    other.m_impl = 0;
+                }
+
+                // If this is a non-null iterator then we need to put
+                // a clone of this iterators impementation into the other
+                // iterator.
+                // We can't just swap because of the small buffer optimization.
+                if (m_impl)
+                {
+                    other.m_impl = m_impl->clone(other.m_buffer);
+                    m_impl->~abstract_base_type();
+                    m_buffer.deallocate();
+                    m_impl = 0;
+                }
+
+                // assign to this instance a clone of the temporarily held
+                // tmp which represents the input other parameter at the
+                // start of execution of this function.
+                if (tmp.m_impl)
+                    m_impl = tmp.m_impl->clone(m_buffer);
+
+                return *this;
+            }
+
+            buffer_type m_buffer;
+            abstract_base_type* m_impl;
+        };
+
+    } // namespace range_detail
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/any_iterator_buffer.hpp b/src/boost/range/detail/any_iterator_buffer.hpp
new file mode 100644
index 0000000..2bb5d53
--- /dev/null
+++ b/src/boost/range/detail/any_iterator_buffer.hpp
@@ -0,0 +1,117 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_BUFFER_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_ANY_ITERATOR_BUFFER_HPP_INCLUDED
+
+#include <boost/array.hpp>
+#include <boost/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/noncopyable.hpp>
+
+namespace boost
+{
+    template<std::size_t StackBufferSize>
+    class any_iterator_buffer
+        : noncopyable
+    {
+        BOOST_STATIC_ASSERT(( StackBufferSize > 0 ));
+    public:
+        any_iterator_buffer()
+            : m_ptr()
+        {
+        }
+
+        ~any_iterator_buffer()
+        {
+            delete [] m_ptr;
+        }
+
+        void* allocate(std::size_t bytes)
+        {
+            BOOST_ASSERT( !m_ptr );
+            if (bytes <= StackBufferSize)
+                return m_buffer.data();
+
+            m_ptr = new char[bytes];
+            return m_ptr;
+        }
+
+        void deallocate()
+        {
+            delete [] m_ptr;
+            m_ptr = 0;
+        }
+
+    private:
+        // Rationale:
+        // Do not use inheritance from noncopyable because this causes
+        // the concepts to erroneous detect the derived any_iterator
+        // as noncopyable.
+        any_iterator_buffer(const any_iterator_buffer&);
+        void operator=(const any_iterator_buffer&);
+
+        char* m_ptr;
+        boost::array<char, StackBufferSize> m_buffer;
+    };
+
+    class any_iterator_heap_only_buffer
+        : noncopyable
+    {
+    public:
+        any_iterator_heap_only_buffer()
+            : m_ptr()
+        {
+        }
+
+        ~any_iterator_heap_only_buffer()
+        {
+            delete [] m_ptr;
+        }
+
+        void* allocate(std::size_t bytes)
+        {
+            BOOST_ASSERT( !m_ptr );
+            m_ptr = new char[bytes];
+            return m_ptr;
+        }
+
+        void deallocate()
+        {
+            delete [] m_ptr;
+            m_ptr = 0;
+        }
+
+    private:
+        char* m_ptr;
+    };
+
+    template<std::size_t StackBufferSize>
+    class any_iterator_stack_only_buffer
+    {
+        BOOST_STATIC_ASSERT(( StackBufferSize > 0 ));
+    public:
+        void* allocate(std::size_t bytes)
+        {
+            BOOST_ASSERT( bytes <= m_buffer.size() );
+            return m_buffer.data();
+        }
+
+        void deallocate()
+        {
+        }
+
+    private:
+        boost::array<char, StackBufferSize> m_buffer;
+    };
+
+    typedef any_iterator_buffer<64> any_iterator_default_buffer;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/any_iterator_interface.hpp b/src/boost/range/detail/any_iterator_interface.hpp
new file mode 100644
index 0000000..d8f4de7
--- /dev/null
+++ b/src/boost/range/detail/any_iterator_interface.hpp
@@ -0,0 +1,258 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
+
+#include <boost/range/detail/any_iterator_buffer.hpp>
+#include <boost/type_traits/add_reference.hpp>
+#include <boost/type_traits/add_const.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template<class T>
+        struct const_reference_type_generator
+        {
+            typedef typename mpl::if_<
+                typename is_reference<T>::type,
+                typename add_reference<
+                    typename add_const<
+                        typename remove_reference<T>::type
+                    >::type
+                >::type,
+                T
+            >::type type;
+        };
+
+        template<
+            class Reference
+          , class Buffer
+        >
+        struct any_incrementable_iterator_interface
+        {
+            typedef Reference reference;
+            typedef typename const_reference_type_generator<
+                Reference
+            >::type const_reference;
+            typedef typename remove_const<
+                typename remove_reference<Reference>::type
+            >::type reference_as_value_type;
+
+            typedef Buffer buffer_type;
+
+            virtual ~any_incrementable_iterator_interface() {}
+
+            virtual any_incrementable_iterator_interface*
+                        clone(buffer_type& buffer) const = 0;
+
+            virtual any_incrementable_iterator_interface<const_reference, Buffer>*
+                        clone_const_ref(buffer_type& buffer) const = 0;
+
+            virtual any_incrementable_iterator_interface<reference_as_value_type, Buffer>*
+                        clone_reference_as_value(buffer_type& buffer) const = 0;
+
+            virtual void increment() = 0;
+        };
+
+        template<
+            class Reference
+          , class Buffer
+        >
+        struct any_single_pass_iterator_interface
+            : any_incrementable_iterator_interface<Reference, Buffer>
+        {
+            typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference reference;
+            typedef typename any_incrementable_iterator_interface<Reference, Buffer>::const_reference const_reference;
+            typedef typename any_incrementable_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
+            typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
+
+            virtual any_single_pass_iterator_interface*
+                        clone(buffer_type& buffer) const = 0;
+
+            virtual any_single_pass_iterator_interface<const_reference, Buffer>*
+                        clone_const_ref(buffer_type& buffer) const = 0;
+
+            virtual any_single_pass_iterator_interface<reference_as_value_type, Buffer>*
+                        clone_reference_as_value(buffer_type& buffer) const = 0;
+
+            virtual Reference dereference() const = 0;
+
+            virtual bool equal(const any_single_pass_iterator_interface& other) const = 0;
+        };
+
+        template<
+            class Reference
+          , class Buffer
+        >
+        struct any_forward_iterator_interface
+            : any_single_pass_iterator_interface<Reference, Buffer>
+        {
+            typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference reference;
+            typedef typename any_single_pass_iterator_interface<Reference, Buffer>::const_reference const_reference;
+            typedef typename any_single_pass_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
+            typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
+
+            virtual any_forward_iterator_interface*
+                        clone(buffer_type& buffer) const = 0;
+
+            virtual any_forward_iterator_interface<const_reference, Buffer>*
+                        clone_const_ref(buffer_type& buffer) const = 0;
+
+            virtual any_forward_iterator_interface<reference_as_value_type, Buffer>*
+                        clone_reference_as_value(buffer_type& buffer) const = 0;
+        };
+
+        template<
+            class Reference
+          , class Buffer
+        >
+        struct any_bidirectional_iterator_interface
+            : any_forward_iterator_interface<Reference, Buffer>
+        {
+            typedef typename any_forward_iterator_interface<Reference, Buffer>::reference reference;
+            typedef typename any_forward_iterator_interface<Reference, Buffer>::const_reference const_reference;
+            typedef typename any_forward_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
+            typedef typename any_forward_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
+
+            virtual any_bidirectional_iterator_interface*
+                        clone(buffer_type& buffer) const = 0;
+
+            virtual any_bidirectional_iterator_interface<const_reference, Buffer>*
+                        clone_const_ref(buffer_type& buffer) const = 0;
+
+            virtual any_bidirectional_iterator_interface<reference_as_value_type, Buffer>*
+                        clone_reference_as_value(buffer_type& buffer) const = 0;
+
+            virtual void decrement() = 0;
+        };
+
+        template<
+            class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_random_access_iterator_interface
+            : any_bidirectional_iterator_interface<
+                    Reference
+                  , Buffer
+                >
+        {
+            typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference reference;
+            typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::const_reference const_reference;
+            typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
+            typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
+            typedef Difference difference_type;
+
+            virtual any_random_access_iterator_interface*
+                        clone(buffer_type& buffer) const = 0;
+
+            virtual any_random_access_iterator_interface<const_reference, Difference, Buffer>*
+                        clone_const_ref(buffer_type& buffer) const = 0;
+
+            virtual any_random_access_iterator_interface<reference_as_value_type, Difference, Buffer>*
+                        clone_reference_as_value(buffer_type& buffer) const = 0;
+
+            virtual void advance(Difference offset) = 0;
+
+            virtual Difference distance_to(const any_random_access_iterator_interface& other) const = 0;
+        };
+
+        template<
+            class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_interface_type_generator;
+
+        template<
+            class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_interface_type_generator<
+                    incrementable_traversal_tag
+                  , Reference
+                  , Difference
+                  , Buffer
+                >
+        {
+            typedef any_incrementable_iterator_interface<Reference, Buffer> type;
+        };
+
+        template<
+            class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_interface_type_generator<
+                    single_pass_traversal_tag
+                  , Reference
+                  , Difference
+                  , Buffer
+                >
+        {
+            typedef any_single_pass_iterator_interface<Reference, Buffer> type;
+        };
+
+        template<
+            class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_interface_type_generator<
+                    forward_traversal_tag
+                  , Reference
+                  , Difference
+                  , Buffer
+                >
+        {
+            typedef any_forward_iterator_interface<Reference, Buffer> type;
+        };
+
+        template<
+            class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_interface_type_generator<
+                    bidirectional_traversal_tag
+                  , Reference
+                  , Difference
+                  , Buffer
+                >
+        {
+            typedef any_bidirectional_iterator_interface<Reference, Buffer> type;
+        };
+
+        template<
+            class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_interface_type_generator<
+                    random_access_traversal_tag
+                  , Reference
+                  , Difference
+                  , Buffer
+                >
+        {
+            typedef any_random_access_iterator_interface<
+                        Reference
+                      , Difference
+                      , Buffer
+                    > type;
+        };
+
+    } // namespace range_detail
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/any_iterator_wrapper.hpp b/src/boost/range/detail/any_iterator_wrapper.hpp
new file mode 100644
index 0000000..b5313a7
--- /dev/null
+++ b/src/boost/range/detail/any_iterator_wrapper.hpp
@@ -0,0 +1,590 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
+
+#include <boost/range/config.hpp>
+#include <boost/range/detail/any_iterator_interface.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Buffer
+        >
+        class any_incrementable_iterator_wrapper
+            : public any_incrementable_iterator_interface<
+                        Reference
+                      , Buffer
+                    >
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( IncrementableIteratorConcept<WrappedIterator> ));
+        public:
+            typedef WrappedIterator wrapped_type;
+
+            BOOST_STATIC_ASSERT(( is_convertible<
+                                    typename iterator_reference<WrappedIterator>::type
+                                  , Reference
+                                  >::value ));
+
+            any_incrementable_iterator_wrapper()
+                : m_it()
+            {}
+
+            explicit any_incrementable_iterator_wrapper(wrapped_type it)
+                : m_it(it)
+            {}
+
+        // any_incrementable_iterator implementation
+            virtual any_incrementable_iterator_wrapper* clone(
+                typename any_incrementable_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                return new (buffer.allocate(sizeof(*this)))
+                                any_incrementable_iterator_wrapper(m_it);
+            }
+
+            virtual any_incrementable_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_incrementable_iterator_wrapper::const_reference
+                      , Buffer
+                    >* clone_const_ref(
+                        typename any_incrementable_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                typedef any_incrementable_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_incrementable_iterator_wrapper::const_reference
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual any_incrementable_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_incrementable_iterator_wrapper::reference_as_value_type
+                      , Buffer
+                    >* clone_reference_as_value(
+                        typename any_incrementable_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                typedef any_incrementable_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_incrementable_iterator_wrapper::reference_as_value_type
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual void increment()
+            {
+                ++m_it;
+            }
+
+         private:
+            wrapped_type m_it;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Buffer
+        >
+        class any_single_pass_iterator_wrapper
+            : public any_single_pass_iterator_interface<
+                        Reference
+                      , Buffer
+                    >
+        {
+            struct disabler {};
+            BOOST_RANGE_CONCEPT_ASSERT(( SinglePassIteratorConcept<WrappedIterator> ));
+        public:
+
+            any_single_pass_iterator_wrapper()
+                : m_it()
+            {}
+
+            explicit any_single_pass_iterator_wrapper(const WrappedIterator& it)
+                : m_it(it)
+            {}
+        // any_single_pass_iterator_interface<Reference> implementation
+            virtual any_single_pass_iterator_wrapper* clone(
+                typename any_single_pass_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                return new (buffer.allocate(sizeof(*this)))
+                            any_single_pass_iterator_wrapper(m_it);
+            }
+
+            virtual any_single_pass_iterator_wrapper<
+                WrappedIterator
+              , typename any_single_pass_iterator_wrapper::const_reference
+              , Buffer
+            >* clone_const_ref(
+                   typename any_single_pass_iterator_wrapper::buffer_type& buffer
+                   ) const
+            {
+                typedef any_single_pass_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_single_pass_iterator_wrapper::const_reference
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual any_single_pass_iterator_wrapper<
+                WrappedIterator
+              , typename any_single_pass_iterator_wrapper::reference_as_value_type
+              , Buffer
+            >* clone_reference_as_value(
+                typename any_single_pass_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                typedef any_single_pass_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_single_pass_iterator_wrapper::reference_as_value_type
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual void increment()
+            {
+                ++m_it;
+            }
+
+            virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
+            {
+                return m_it == boost::polymorphic_downcast<const any_single_pass_iterator_wrapper*>(&other)->m_it;
+            }
+
+            virtual Reference dereference() const
+            {
+                return *m_it;
+            }
+
+        private:
+            WrappedIterator m_it;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Buffer
+        >
+        class any_forward_iterator_wrapper
+            : public any_forward_iterator_interface<
+                        Reference
+                      , Buffer
+                    >
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( ForwardIteratorConcept<WrappedIterator> ));
+        public:
+            any_forward_iterator_wrapper()
+                : m_it()
+            {}
+
+            explicit any_forward_iterator_wrapper(const WrappedIterator& it)
+                : m_it(it)
+            {}
+
+            // any_forward_iterator_interface<Reference> implementation
+            virtual any_forward_iterator_wrapper* clone(
+                typename any_forward_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                return new (buffer.allocate(sizeof(*this)))
+                                any_forward_iterator_wrapper(m_it);
+            }
+
+            virtual any_forward_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_forward_iterator_wrapper::const_reference
+                      , Buffer
+                    >* clone_const_ref(
+                            typename any_forward_iterator_wrapper::buffer_type& buffer
+                        ) const
+            {
+                typedef any_forward_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_forward_iterator_wrapper::const_reference
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual any_forward_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_forward_iterator_wrapper::reference_as_value_type
+                      , Buffer
+                    >* clone_reference_as_value(
+                            typename any_forward_iterator_wrapper::buffer_type& buffer
+                    ) const
+            {
+                typedef any_forward_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_forward_iterator_wrapper::reference_as_value_type
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual void increment()
+            {
+                ++m_it;
+            }
+
+            virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
+            {
+                return m_it == boost::polymorphic_downcast<const any_forward_iterator_wrapper*>(&other)->m_it;
+            }
+
+            virtual Reference dereference() const
+            {
+                return *m_it;
+            }
+        private:
+            WrappedIterator m_it;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Buffer
+        >
+        class any_bidirectional_iterator_wrapper
+            : public any_bidirectional_iterator_interface<
+                        Reference
+                      , Buffer
+                    >
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalIteratorConcept<WrappedIterator> ));
+        public:
+            any_bidirectional_iterator_wrapper()
+                : m_it()
+            {
+            }
+
+            explicit any_bidirectional_iterator_wrapper(const WrappedIterator& it)
+                : m_it(it)
+            {
+            }
+
+            virtual any_bidirectional_iterator_wrapper* clone(
+                typename any_bidirectional_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                return new (buffer.allocate(sizeof(*this)))
+                            any_bidirectional_iterator_wrapper(*this);
+            }
+
+            virtual any_bidirectional_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_bidirectional_iterator_wrapper::const_reference
+                      , Buffer
+                    >* clone_const_ref(
+                           typename any_bidirectional_iterator_wrapper::buffer_type& buffer
+                       ) const
+            {
+                typedef any_bidirectional_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_bidirectional_iterator_wrapper::const_reference
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual any_bidirectional_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_bidirectional_iterator_wrapper::reference_as_value_type
+                      , Buffer
+                    >* clone_reference_as_value(
+                           typename any_bidirectional_iterator_wrapper::buffer_type& buffer
+                       ) const
+            {
+                typedef any_bidirectional_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_bidirectional_iterator_wrapper::reference_as_value_type
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual void increment()
+            {
+                ++m_it;
+            }
+
+            virtual void decrement()
+            {
+                --m_it;
+            }
+
+            virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
+            {
+                return m_it == boost::polymorphic_downcast<const any_bidirectional_iterator_wrapper*>(&other)->m_it;
+            }
+
+            virtual Reference dereference() const
+            {
+                return *m_it;
+            }
+
+        private:
+            WrappedIterator m_it;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        class any_random_access_iterator_wrapper
+            : public any_random_access_iterator_interface<
+                            Reference
+                          , Difference
+                          , Buffer
+                        >
+        {
+            BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessIteratorConcept<WrappedIterator> ));
+        public:
+            typedef Difference difference_type;
+
+            any_random_access_iterator_wrapper()
+                : m_it()
+            {
+            }
+
+            explicit any_random_access_iterator_wrapper(const WrappedIterator& other)
+                : m_it(other)
+            {
+            }
+
+            virtual any_random_access_iterator_wrapper* clone(
+                    typename any_random_access_iterator_wrapper::buffer_type& buffer
+                ) const
+            {
+                return new (buffer.allocate(sizeof(*this)))
+                                any_random_access_iterator_wrapper(*this);
+            }
+
+            virtual any_random_access_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_random_access_iterator_wrapper::const_reference
+                      , Difference
+                      , Buffer
+                    >* clone_const_ref(
+                           typename any_random_access_iterator_wrapper::buffer_type& buffer
+                           ) const
+            {
+                typedef any_random_access_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_random_access_iterator_wrapper::const_reference
+                          , Difference
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual any_random_access_iterator_wrapper<
+                        WrappedIterator
+                      , typename any_random_access_iterator_wrapper::reference_as_value_type
+                      , Difference
+                      , Buffer
+                    >* clone_reference_as_value(
+                           typename any_random_access_iterator_wrapper::buffer_type& buffer
+                           ) const
+            {
+                typedef any_random_access_iterator_wrapper<
+                            WrappedIterator
+                          , typename any_random_access_iterator_wrapper::reference_as_value_type
+                          , Difference
+                          , Buffer
+                        > result_type;
+
+                return new (buffer.allocate(sizeof(result_type)))
+                            result_type(m_it);
+            }
+
+            virtual void increment()
+            {
+                ++m_it;
+            }
+
+            virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
+            {
+                return m_it == boost::polymorphic_downcast<const any_random_access_iterator_wrapper*>(&other)->m_it;
+            }
+
+            virtual void decrement()
+            {
+                --m_it;
+            }
+
+            virtual void advance(Difference offset)
+            {
+                m_it += offset;
+            }
+
+            virtual Reference dereference() const
+            {
+                return *m_it;
+            }
+
+            virtual Difference distance_to(const any_random_access_iterator_interface<Reference, Difference, Buffer>& other) const
+            {
+                return boost::polymorphic_downcast<const any_random_access_iterator_wrapper*>(&other)->m_it - m_it;
+            }
+
+        private:
+            WrappedIterator m_it;
+        };
+
+        template<
+            class WrappedIterator
+          , class Traversal
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_wrapper_type_generator;
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_wrapper_type_generator<
+            WrappedIterator
+          , incrementable_traversal_tag
+          , Reference
+          , Difference
+          , Buffer
+        >
+        {
+            typedef any_incrementable_iterator_wrapper<
+                        WrappedIterator
+                      , Reference
+                      , Buffer
+                    > type;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_wrapper_type_generator<
+            WrappedIterator
+          , single_pass_traversal_tag
+          , Reference
+          , Difference
+          , Buffer
+        >
+        {
+            typedef any_single_pass_iterator_wrapper<
+                        WrappedIterator
+                      , Reference
+                      , Buffer
+                > type;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_wrapper_type_generator<
+            WrappedIterator
+          , forward_traversal_tag
+          , Reference
+          , Difference
+          , Buffer
+        >
+        {
+            typedef any_forward_iterator_wrapper<
+                WrappedIterator
+              , Reference
+              , Buffer
+            > type;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_wrapper_type_generator<
+            WrappedIterator
+          , bidirectional_traversal_tag
+          , Reference
+          , Difference
+          , Buffer
+        >
+        {
+            typedef any_bidirectional_iterator_wrapper<
+                WrappedIterator
+              , Reference
+              , Buffer
+            > type;
+        };
+
+        template<
+            class WrappedIterator
+          , class Reference
+          , class Difference
+          , class Buffer
+        >
+        struct any_iterator_wrapper_type_generator<
+            WrappedIterator
+          , random_access_traversal_tag
+          , Reference
+          , Difference
+          , Buffer
+        >
+        {
+            typedef any_random_access_iterator_wrapper<
+                WrappedIterator
+              , Reference
+              , Difference
+              , Buffer
+            > type;
+        };
+
+    } // namespace range_detail
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/as_literal.hpp b/src/boost/range/detail/as_literal.hpp
new file mode 100644
index 0000000..0bd9a15
--- /dev/null
+++ b/src/boost/range/detail/as_literal.hpp
@@ -0,0 +1,33 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
+#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/detail/detail_str.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    template< class Range >
+    inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type> 
+    as_literal( Range& r )
+    {
+        return ::boost::make_iterator_range( ::boost::range_detail::str_begin(r),
+                                             ::boost::range_detail::str_end(r) );
+    }
+
+}
+
+#endif
diff --git a/src/boost/range/detail/begin.hpp b/src/boost/range/detail/begin.hpp
new file mode 100644
index 0000000..f3da732
--- /dev/null
+++ b/src/boost/range/detail/begin.hpp
@@ -0,0 +1,94 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
+#define BOOST_RANGE_DETAIL_BEGIN_HPP
+
+#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/detail/workaround.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/detail/common.hpp>
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
+# include <boost/range/value_type.hpp>
+#endif
+
+namespace boost
+{
+
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_begin;
+
+        //////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_begin<std_container_>
+        {
+            template< typename C >
+            static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
+            {
+                return c.begin();
+            };
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_begin<std_pair_>
+        {
+            template< typename P >
+            static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
+            {
+                return p.first;
+            }
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_begin<array_>
+        {
+        #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
+            template< typename T, std::size_t sz >
+            static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return boost_range_array;
+            }
+        #else
+            template<typename T>
+            static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
+            {
+                return t;
+            }
+        #endif
+        };
+
+    } // namespace 'range_detail'
+
+    namespace range_adl_barrier
+    {
+        template< typename C >
+        inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
+        begin( C& c )
+        {
+            return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
+        }
+    }
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/detail/collection_traits.hpp b/src/boost/range/detail/collection_traits.hpp
new file mode 100644
index 0000000..c50ca3e
--- /dev/null
+++ b/src/boost/range/detail/collection_traits.hpp
@@ -0,0 +1,266 @@
+//  Boost string_algo library collection_traits.hpp header file  -------------//
+
+//  Copyright Pavol Droba 2002-2003. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+
+// (C) Copyright Thorsten Ottosen 2002-2003. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+
+// (C) Copyright Jeremy Siek 2001. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+
+//  Original idea of container traits was proposed by Jeremy Siek and
+//  Thorsten Ottosen. This implementation is lightweighted version
+//  of container_traits adapter for usage with string_algo library
+
+#ifndef BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
+#define BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
+
+#include <boost/algorithm/string/config.hpp>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/mpl/eval_if.hpp>
+
+// Implementation
+#include <boost/range/detail/collection_traits_detail.hpp>
+
+/*! \file
+    Defines collection_traits class and related free-standing functions.
+    This facility is used to unify the access to different types of collections.
+    It allows the algorithms in the library to work with STL collections, c-style
+    array, null-terminated c-strings (and more) using the same interface.
+*/
+
+namespace boost {
+    namespace algorithm {
+
+//  collection_traits template class -----------------------------------------//
+        
+        //! collection_traits class
+        /*!
+            Collection traits provide uniform access to different types of 
+            collections. This functionality allows to write generic algorithms
+            which work with several different kinds of collections.
+
+            Currently following collection types are supported:
+                - containers with STL compatible container interface ( see ContainerConcept )
+                    ( i.e. \c std::vector<>, \c std::list<>, \c std::string<> ... )
+                - c-style array 
+                   ( \c char[10], \c int[15] ... )
+                - null-terminated c-strings
+                    ( \c char*, \c wchar_T* )
+                - std::pair of iterators 
+                    ( i.e \c std::pair<vector<int>::iterator,vector<int>::iterator> )
+
+            Collection traits provide an external collection interface operations.
+            All are accessible using free-standing functions.
+
+            The following operations are supported:
+                - \c size()
+                - \c empty()
+                - \c begin()
+                - \c end()
+
+            Container traits have somewhat limited functionality on compilers not
+            supporting partial template specialization and partial template ordering.
+        */
+        template< typename T >
+        struct collection_traits
+        {
+        private:
+            typedef BOOST_STRING_TYPENAME ::boost::mpl::eval_if< 
+                    ::boost::algorithm::detail::is_pair<T>, 
+                        detail::pair_container_traits_selector<T>,
+                        BOOST_STRING_TYPENAME ::boost::mpl::eval_if< 
+                        ::boost::is_array<T>, 
+                            detail::array_container_traits_selector<T>,
+                            BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
+                            ::boost::is_pointer<T>,
+                                detail::pointer_container_traits_selector<T>,
+                                detail::default_container_traits_selector<T>
+                            >
+                        > 
+                >::type container_helper_type;
+        public:
+            //! Function type       
+            typedef container_helper_type function_type;        
+            //! Value type
+            typedef BOOST_STRING_TYPENAME 
+                container_helper_type::value_type value_type;
+            //! Size type
+            typedef BOOST_STRING_TYPENAME 
+                container_helper_type::size_type size_type;
+            //! Iterator type
+            typedef BOOST_STRING_TYPENAME 
+                container_helper_type::iterator iterator;
+            //! Const iterator type
+            typedef BOOST_STRING_TYPENAME 
+                container_helper_type::const_iterator const_iterator;
+            //! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
+            typedef BOOST_STRING_TYPENAME 
+                container_helper_type::result_iterator result_iterator;
+            //! Difference type
+            typedef BOOST_STRING_TYPENAME 
+                container_helper_type::difference_type difference_type;
+
+        }; // 'collection_traits'
+
+//  collection_traits metafunctions -----------------------------------------//
+
+        //! Container value_type trait
+        /*!
+            Extract the type of elements contained in a container
+        */
+        template< typename C >
+        struct value_type_of
+        {
+            typedef BOOST_STRING_TYPENAME collection_traits<C>::value_type type;
+        };
+        
+        //! Container difference trait
+        /*!
+            Extract the container's difference type
+        */
+        template< typename C >
+        struct difference_type_of
+        {
+            typedef BOOST_STRING_TYPENAME collection_traits<C>::difference_type type;
+        };
+
+        //! Container iterator trait
+        /*!
+            Extract the container's iterator type
+        */
+        template< typename C >
+        struct iterator_of
+        {
+            typedef BOOST_STRING_TYPENAME collection_traits<C>::iterator type;
+        };
+
+        //! Container const_iterator trait
+        /*!
+            Extract the container's const_iterator type
+        */
+        template< typename C >
+        struct const_iterator_of
+        {
+            typedef BOOST_STRING_TYPENAME collection_traits<C>::const_iterator type;
+        };
+
+
+        //! Container result_iterator
+        /*!
+            Extract the container's result_iterator type. This type maps to \c C::iterator
+            for mutable container and \c C::const_iterator for const containers.
+        */
+        template< typename C >
+        struct result_iterator_of
+        {
+            typedef BOOST_STRING_TYPENAME collection_traits<C>::result_iterator type;
+        };
+
+//  collection_traits related functions -----------------------------------------//
+
+        //! Free-standing size() function
+        /*!
+            Get the size of the container. Uses collection_traits.
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::size_type
+        size( const C& c )
+        {
+            return collection_traits<C>::function_type::size( c ); 
+        }
+
+        //! Free-standing empty() function
+        /*!
+            Check whether the container is empty. Uses container traits.
+        */
+        template< typename C >
+        inline bool empty( const C& c )
+        {
+            return collection_traits<C>::function_type::empty( c );
+        }
+
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+        //! Free-standing begin() function
+        /*!
+            Get the begin iterator of the container. Uses collection_traits.
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
+        begin( C& c )
+        {
+            return collection_traits<C>::function_type::begin( c ); 
+        }
+
+        //! Free-standing begin() function
+        /*!
+            \overload
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
+        begin( const C& c )
+        {
+            return collection_traits<C>::function_type::begin( c ); 
+        }
+
+        //! Free-standing end() function
+        /*!
+            Get the begin iterator of the container. Uses collection_traits.
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
+        end( C& c )
+        {
+            return collection_traits<C>::function_type::end( c );
+        }
+
+        //! Free-standing end() function
+        /*!
+            \overload           
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
+        end( const C& c )
+        {
+            return collection_traits<C>::function_type::end( c );
+        }
+
+#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+        //! Free-standing begin() function
+        /*!
+            \overload
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
+        begin( C& c )
+        {
+            return collection_traits<C>::function_type::begin( c );
+        }
+
+        //! Free-standing end() function
+        /*!
+            \overload
+        */
+        template< typename C >
+        inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
+        end( C& c )
+        {
+            return collection_traits<C>::function_type::end( c );
+        }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+    } // namespace algorithm
+} // namespace boost
+
+#endif // BOOST_STRING_COLLECTION_TRAITS_HPP
diff --git a/src/boost/range/detail/collection_traits_detail.hpp b/src/boost/range/detail/collection_traits_detail.hpp
new file mode 100644
index 0000000..44fbde0
--- /dev/null
+++ b/src/boost/range/detail/collection_traits_detail.hpp
@@ -0,0 +1,621 @@
+//  Boost string_algo library collection_traits.hpp header file  -----------------------//
+
+//  Copyright Pavol Droba 2002-2003. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+
+//  See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
+#define BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
+
+#include <boost/algorithm/string/config.hpp>
+#include <cstddef>
+#include <string>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/fold.hpp>
+#include <boost/detail/iterator.hpp>
+#include <boost/algorithm/string/yes_no_type.hpp>
+
+// Container traits implementation ---------------------------------------------------------
+
+namespace boost {
+    namespace algorithm {
+        namespace detail {
+
+// Default collection traits -----------------------------------------------------------------
+
+            // Default collection helper 
+            /*
+                Wraps std::container compliant containers
+            */
+            template< typename ContainerT >     
+            struct default_container_traits
+            {
+                typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type;
+                typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator;
+                typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator;
+                typedef BOOST_STRING_TYPENAME 
+                    ::boost::mpl::if_< ::boost::is_const<ContainerT>,
+                        const_iterator,
+                        iterator 
+                    >::type result_iterator;
+                typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type;
+                typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type;
+                
+                // static operations
+                template< typename C >
+                static size_type size( const C& c )
+                {
+                    return c.size();
+                }
+
+                template< typename C >
+                static bool empty( const C& c )
+                {
+                    return c.empty();
+                }
+
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+                template< typename C >
+                static iterator begin( C& c )
+                {
+                    return c.begin();
+                }
+
+                template< typename C >
+                static const_iterator begin( const C& c )
+                {
+                    return c.begin();
+                }
+
+                template< typename C >
+                static iterator end( C& c )
+                {
+                    return c.end();
+                }
+
+                template< typename C >
+                static const_iterator end( const C& c )
+                {
+                    return c.end();
+                }
+
+#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+                template< typename C >
+                static result_iterator begin( C& c )
+                {
+                    return c.begin();
+                }
+
+                template< typename C >
+                static result_iterator end( C& c )
+                {
+                    return c.end();
+                }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING    
+
+            }; 
+
+            template<typename T>
+            struct default_container_traits_selector
+            {
+                typedef default_container_traits<T> type;
+            };
+
+// Pair container traits ---------------------------------------------------------------------
+                    
+            // pair selector
+            template< typename T, typename U >
+            yes_type is_pair_impl( const std::pair<T,U>* );
+            no_type is_pair_impl( ... );
+
+            template<typename T> struct is_pair
+            {
+            private:
+                static T* t;
+            public:
+                BOOST_STATIC_CONSTANT( bool, value=
+                    sizeof(is_pair_impl(t))==sizeof(yes_type) );
+            };
+
+            // pair helper
+            template< typename PairT >
+            struct pair_container_traits
+            {
+                typedef BOOST_STRING_TYPENAME PairT::first_type element_type;
+
+                typedef BOOST_STRING_TYPENAME ::boost::detail::
+                    iterator_traits<element_type>::value_type value_type;
+                typedef std::size_t size_type;
+                typedef BOOST_STRING_TYPENAME ::boost::detail::
+                    iterator_traits<element_type>::difference_type difference_type;
+
+                typedef element_type iterator;
+                typedef element_type const_iterator;
+                typedef element_type result_iterator;
+
+                // static operations
+                template< typename P >
+                static size_type size( const P& p )
+                {
+                    difference_type diff = std::distance( p.first, p.second );
+                    if ( diff < 0 ) 
+                        return 0;
+                    else
+                        return diff;
+                }
+
+                template< typename P >
+                static bool empty( const P& p )
+                {
+                    return p.first==p.second;
+                }
+
+                template< typename P > 
+                static const_iterator begin( const P& p )
+                {
+                    return p.first;
+                }
+
+                template< typename P >
+                static const_iterator end( const P& p )
+                {
+                    return p.second;
+                }
+            }; // 'pair_container_helper'
+
+            template<typename T>
+            struct pair_container_traits_selector
+            {
+                typedef pair_container_traits<T> type;
+            };
+
+// Array container traits ---------------------------------------------------------------
+
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+            // array traits ( partial specialization )
+            template< typename T >
+            struct array_traits;
+
+            template< typename T, std::size_t sz >
+            struct array_traits<T[sz]>
+            {
+                // typedef
+                typedef T* iterator;
+                typedef const T* const_iterator;
+                typedef T value_type;
+                typedef std::size_t size_type;
+                typedef std::ptrdiff_t difference_type;
+
+                // size of the array ( static );
+                BOOST_STATIC_CONSTANT( size_type, array_size = sz );
+            };
+
+#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+            // array traits ( no partial specialization )
+            /*
+                without parial specialization we are able to
+                provide support only for a limited number of
+                types. Currently the primitive numeric types 
+                are supported
+            */
+            template< typename T, typename BaseT >
+            struct array_traits_impl
+            {
+                typedef BaseT value_type;
+                typedef BaseT* iterator;
+                typedef const BaseT* const_iterator;
+                typedef std::size_t size_type;
+                typedef std::ptrdiff_t difference_type;
+
+                // size of the array
+                BOOST_STATIC_CONSTANT( size_type, array_size = sizeof(T)/sizeof(BaseT) );
+            };
+            
+            template< typename T, typename BaseT >
+            struct array_traits_impl_selector
+            {
+                typedef array_traits_impl<T,BaseT> type;
+            };
+
+            struct array_traits_void
+            {
+                typedef void type;
+            };
+
+            template< typename T, typename BaseT >
+            struct array_traits_cv_selector
+            {
+                typedef BOOST_STRING_TYPENAME 
+                    ::boost::mpl::eval_if< 
+                        ::boost::is_convertible<T,BaseT*>,
+                        array_traits_impl_selector<T,BaseT>,
+                        ::boost::mpl::eval_if< 
+                            ::boost::is_convertible<T,const BaseT*>,
+                                array_traits_impl_selector<T, const BaseT>,
+                                ::boost::mpl::eval_if< 
+                                    ::boost::is_convertible<T, volatile BaseT*>,
+                                    array_traits_impl_selector<T, volatile BaseT>,
+                                    array_traits_impl_selector<T, const volatile BaseT>
+                                >
+                            >
+                    >::type type;
+            };
+
+            template< typename T >
+            struct array_traits_select
+            {
+                template< typename T1, typename T2 >
+                struct apply
+                {
+                    typedef BOOST_STRING_TYPENAME
+                        ::boost::mpl::eval_if< 
+                            ::boost::is_convertible<T,const volatile T2*>,
+                            array_traits_cv_selector<T,T2>,
+                            ::boost::mpl::identity<T1> >::type type;
+                };
+            };
+
+            template< typename T >
+            struct array_traits_selector 
+            {
+            private:
+                // supported array base types
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::mpl::vector10<
+                        wchar_t,
+#else // BOOST_NO_INTRINSIC_WCHAR_T
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::mpl::vector9<
+#endif // BOOST_NO_INTRINSIC_WCHAR_T
+                        char,
+                        signed char,
+                        unsigned char,
+                        signed short,
+                        unsigned short,
+                        signed int,
+                        unsigned int,
+                        signed long,
+                        unsigned long
+                >::type array_base_types;
+
+            public:
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::mpl::fold<
+                        array_base_types,
+                        ::boost::algorithm::detail::array_traits_void,
+                        ::boost::algorithm::detail::array_traits_select<T> >::type type;
+            };
+
+            template< typename T >
+            struct array_traits
+            {
+                typedef BOOST_STRING_TYPENAME
+                    array_traits_selector<T>::type traits_type;
+
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::value_type value_type;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::iterator iterator;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::const_iterator const_iterator;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::size_type size_type;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::difference_type difference_type;
+
+                BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
+            };
+
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+            
+            // array lenght resolving
+            /*
+                Lenght of string contained in a static array could
+                be different from the size of the array.
+                For string processing we need the lenght without
+                terminating 0.
+
+                Therefore, the lenght is calulated for char and wchar_t
+                using char_traits, rather then simply returning
+                the array size.
+            */
+            template< typename T >
+            struct array_length_selector
+            {
+                template< typename TraitsT >
+                struct array_length
+                {
+                    typedef BOOST_STRING_TYPENAME 
+                        TraitsT::size_type size_type;
+
+                    BOOST_STATIC_CONSTANT(
+                        size_type,
+                        array_size=TraitsT::array_size );
+
+                    template< typename A >
+                    static size_type length( const A& )
+                    {
+                        return array_size;
+                    }
+
+                    template< typename A >
+                    static bool empty( const A& )
+                    {
+                        return array_size==0;
+                    }
+                };
+            };
+
+            // specialization for char
+            template<>
+            struct array_length_selector<char>
+            {
+                template< typename TraitsT >
+                struct array_length
+                {
+                    typedef BOOST_STRING_TYPENAME 
+                        TraitsT::size_type size_type;
+
+                    template< typename A >
+                    static size_type length( const A& a )
+                    {
+                        if ( a==0 ) 
+                            return 0;
+                        else
+                            return std::char_traits<char>::length(a);
+                    }
+                    
+                    template< typename A >
+                    static bool empty( const A& a )
+                    {
+                        return a==0 || a[0]==0;
+                    }
+                };
+            };
+
+            // specialization for wchar_t
+            template<>
+            struct array_length_selector<wchar_t>
+            {
+                template< typename TraitsT >
+                struct array_length
+                {
+                    typedef BOOST_STRING_TYPENAME 
+                        TraitsT::size_type size_type;
+
+                    template< typename A >
+                    static size_type length( const A& a )
+                    {
+                        if ( a==0 ) 
+                            return 0;
+                        else
+                            return std::char_traits<wchar_t>::length(a);
+                    }
+
+                    template< typename A >
+                    static bool empty( const A& a )
+                    {
+                        return a==0 || a[0]==0;
+                    }
+                };
+            };
+
+            template< typename T >
+            struct array_container_traits
+            {
+            private:
+                // resolve array traits
+                typedef array_traits<T> traits_type;
+
+            public:
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::value_type value_type;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::iterator iterator;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::const_iterator const_iterator;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::size_type size_type;
+                typedef BOOST_STRING_TYPENAME
+                    traits_type::difference_type difference_type;
+
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::mpl::if_< ::boost::is_const<T>,
+                        const_iterator,
+                        iterator 
+                    >::type result_iterator;
+                
+            private:
+                // resolve array size
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::remove_cv<value_type>::type char_type;
+                typedef BOOST_STRING_TYPENAME
+                    array_length_selector<char_type>::
+                        BOOST_NESTED_TEMPLATE array_length<traits_type> array_length_type;
+
+            public:
+                BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
+
+                // static operations
+                template< typename A >
+                static size_type size( const A& a )
+                {
+                    return array_length_type::length(a);
+                }
+
+                template< typename A >
+                static bool empty( const A& a )
+                {
+                    return array_length_type::empty(a);
+                }
+                
+
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+                template< typename A >
+                static iterator begin( A& a )
+                {
+                    return a;
+                }
+
+                template< typename A >
+                static const_iterator begin( const A& a )
+                {
+                    return a;
+                }
+
+                template< typename A >
+                static iterator end( A& a )
+                {
+                    return a+array_length_type::length(a);
+                }
+
+                template< typename A >
+                static const_iterator end( const A& a )
+                {
+                    return a+array_length_type::length(a);
+                }
+
+#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+                template< typename A >
+                static result_iterator begin( A& a )
+                {
+                    return a;
+                }
+
+                template< typename A >
+                static result_iterator end( A& a )
+                {
+                    return a+array_length_type::length(a);
+                }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING    
+
+            }; 
+
+            template<typename T>
+            struct array_container_traits_selector
+            {
+                typedef array_container_traits<T> type;
+            };
+
+// Pointer container traits ---------------------------------------------------------------
+
+            template<typename T>
+            struct pointer_container_traits
+            {
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::remove_pointer<T>::type value_type;
+
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::remove_cv<value_type>::type char_type;
+                typedef ::std::char_traits<char_type> char_traits;
+
+                typedef value_type* iterator;
+                typedef const value_type* const_iterator;
+                typedef std::ptrdiff_t difference_type;
+                typedef std::size_t size_type;
+
+                typedef BOOST_STRING_TYPENAME
+                    ::boost::mpl::if_< ::boost::is_const<T>,
+                        const_iterator,
+                        iterator 
+                    >::type result_iterator;
+
+                // static operations
+                template< typename P >
+                static size_type size( const P& p )
+                {
+                    if ( p==0 ) 
+                        return 0;
+                    else
+                        return char_traits::length(p);
+                }
+
+                template< typename P >
+                static bool empty( const P& p )
+                {
+                    return p==0 || p[0]==0;
+                }
+
+#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+                template< typename P >
+                static iterator begin( P& p )
+                {
+                    return p;
+                }
+
+                template< typename P >
+                static const_iterator begin( const P& p )
+                {
+                    return p;
+                }
+
+                template< typename P >
+                static iterator end( P& p )
+                {
+                    if ( p==0 )
+                        return p;
+                    else
+                        return p+char_traits::length(p);
+                }
+
+                template< typename P >
+                static const_iterator end( const P& p )
+                {
+                    if ( p==0 )
+                        return p;
+                    else
+                        return p+char_traits::length(p);
+                }
+
+#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+                template< typename P >
+                static result_iterator begin( P& p )
+                {
+                    return p;
+                }
+
+                template< typename P >
+                static result_iterator end( P& p )
+                {
+                    if ( p==0 )
+                        return p;
+                    else
+                        return p+char_traits::length(p);
+                }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING    
+            }; 
+
+            template<typename T>
+            struct pointer_container_traits_selector
+            {
+                typedef pointer_container_traits<T> type;
+            };
+
+        } // namespace detail
+    } // namespace algorithm
+} // namespace boost
+
+
+#endif  // BOOST_STRING_DETAIL_COLLECTION_HPP
diff --git a/src/boost/range/detail/common.hpp b/src/boost/range/detail/common.hpp
new file mode 100644
index 0000000..f7539f5
--- /dev/null
+++ b/src/boost/range/detail/common.hpp
@@ -0,0 +1,117 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_COMMON_HPP
+#define BOOST_RANGE_DETAIL_COMMON_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/detail/sfinae.hpp>
+#include <boost/type_traits/is_void.hpp>
+#include <boost/type_traits/detail/ice_or.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/int.hpp>
+#include <cstddef>
+
+//////////////////////////////////////////////////////////////////////////////
+// missing partial specialization  workaround.
+//////////////////////////////////////////////////////////////////////////////
+
+namespace boost 
+{
+    namespace range_detail 
+    {        
+        // 1 = std containers
+        // 2 = std::pair
+        // 3 = const std::pair
+        // 4 = array
+        // 5 = const array
+        // 6 = char array
+        // 7 = wchar_t array
+        // 8 = char*
+        // 9 = const char*
+        // 10 = whar_t*
+        // 11 = const wchar_t*
+        // 12 = string
+        
+        typedef mpl::int_<1>::type    std_container_;
+        typedef mpl::int_<2>::type    std_pair_;
+        typedef mpl::int_<3>::type    const_std_pair_;
+        typedef mpl::int_<4>::type    array_;
+        typedef mpl::int_<5>::type    const_array_;
+        typedef mpl::int_<6>::type    char_array_;
+        typedef mpl::int_<7>::type    wchar_t_array_;
+        typedef mpl::int_<8>::type    char_ptr_;
+        typedef mpl::int_<9>::type    const_char_ptr_;
+        typedef mpl::int_<10>::type   wchar_t_ptr_;
+        typedef mpl::int_<11>::type   const_wchar_t_ptr_;
+        typedef mpl::int_<12>::type   string_;
+        
+        template< typename C >
+        struct range_helper
+        {
+            static C* c;
+            static C  ptr;
+
+            BOOST_STATIC_CONSTANT( bool, is_pair_                = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_char_ptr_            = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_      = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_         = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_   = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_char_array_          = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_       = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
+            BOOST_STATIC_CONSTANT( bool, is_string_              = (boost::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::value ));
+            BOOST_STATIC_CONSTANT( bool, is_array_               = boost::is_array<C>::value );
+            
+        };
+        
+        template< typename C >
+        class range
+        {
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
+                                                                  boost::range_detail::std_pair_,
+                                                                  void >::type pair_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
+                                                                    boost::range_detail::array_,
+                                                                    pair_t >::type array_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
+                                                                    boost::range_detail::string_,
+                                                                    array_t >::type string_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
+                                                                    boost::range_detail::const_char_ptr_,
+                                                                    string_t >::type const_char_ptr_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
+                                                                    boost::range_detail::char_ptr_,
+                                                                    const_char_ptr_t >::type char_ptr_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
+                                                                    boost::range_detail::const_wchar_t_ptr_,
+                                                                    char_ptr_t >::type const_wchar_ptr_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
+                                                                    boost::range_detail::wchar_t_ptr_,
+                                                                    const_wchar_ptr_t >::type wchar_ptr_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
+                                                                    boost::range_detail::wchar_t_array_,
+                                                                    wchar_ptr_t >::type wchar_array_t;
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
+                                                                    boost::range_detail::char_array_,
+                                                                    wchar_array_t >::type char_array_t;
+        public:
+            typedef BOOST_RANGE_DEDUCED_TYPENAME   boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
+                                                                    boost::range_detail::std_container_,
+                                                                    char_array_t >::type type;  
+        }; // class 'range' 
+    }
+}
+        
+#endif
+
diff --git a/src/boost/range/detail/const_iterator.hpp b/src/boost/range/detail/const_iterator.hpp
new file mode 100644
index 0000000..e5cb34a
--- /dev/null
+++ b/src/boost/range/detail/const_iterator.hpp
@@ -0,0 +1,71 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
+#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
+
+#include <boost/range/detail/common.hpp>
+#include <boost/range/detail/remove_extent.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+// missing partial specialization  workaround.
+//////////////////////////////////////////////////////////////////////////////
+
+namespace boost 
+{
+    namespace range_detail 
+    {      
+        template< typename T >
+        struct range_const_iterator_;
+
+        template<>
+        struct range_const_iterator_<std_container_>
+        {
+            template< typename C >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME C::const_iterator type;
+            };
+        };
+
+        template<>
+        struct range_const_iterator_<std_pair_>
+        {
+            template< typename P >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
+            };
+        };
+
+
+        template<>
+        struct range_const_iterator_<array_>
+        { 
+            template< typename T >
+            struct pts
+            {
+                typedef const BOOST_RANGE_DEDUCED_TYPENAME 
+                    remove_extent<T>::type* type;
+            };
+        };
+    } 
+    
+    template< typename C >
+    class range_const_iterator
+    {
+        typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
+    public:
+        typedef BOOST_DEDUCED_TYPENAME range_detail::range_const_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; 
+    };
+
+}
+
+#endif
diff --git a/src/boost/range/detail/demote_iterator_traversal_tag.hpp b/src/boost/range/detail/demote_iterator_traversal_tag.hpp
new file mode 100644
index 0000000..2127de9
--- /dev/null
+++ b/src/boost/range/detail/demote_iterator_traversal_tag.hpp
@@ -0,0 +1,91 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// Acknowledgements:
+// aschoedl supplied a fix to supply the level of interoperability I had
+// originally intended, but failed to implement.
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_DEMOTE_ITERATOR_TRAVERSAL_TAG_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_DEMOTE_ITERATOR_TRAVERSAL_TAG_HPP_INCLUDED
+
+#include <boost/iterator/iterator_categories.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+
+template<class IteratorTraversalTag1, class IteratorTraversalTag2>
+struct inner_demote_iterator_traversal_tag
+{
+};
+
+#define BOOST_DEMOTE_TRAVERSAL_TAG( Tag1, Tag2, ResultTag ) \
+template<> struct inner_demote_iterator_traversal_tag< Tag1 , Tag2 > \
+{ \
+    typedef ResultTag type; \
+};
+
+BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, no_traversal_tag,            no_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, incrementable_traversal_tag, no_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, single_pass_traversal_tag,   no_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, forward_traversal_tag,       no_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, bidirectional_traversal_tag, no_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, random_access_traversal_tag, no_traversal_tag )
+
+BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, no_traversal_tag,            no_traversal_tag            )
+BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, single_pass_traversal_tag,   incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, forward_traversal_tag,       incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, bidirectional_traversal_tag, incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( incrementable_traversal_tag, random_access_traversal_tag, incrementable_traversal_tag )
+
+BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, no_traversal_tag,            no_traversal_tag            )
+BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, single_pass_traversal_tag,   single_pass_traversal_tag   )
+BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, forward_traversal_tag,       single_pass_traversal_tag   )
+BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, bidirectional_traversal_tag, single_pass_traversal_tag   )
+BOOST_DEMOTE_TRAVERSAL_TAG( single_pass_traversal_tag, random_access_traversal_tag, single_pass_traversal_tag   )
+
+BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, no_traversal_tag,            no_traversal_tag            )
+BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, single_pass_traversal_tag,   single_pass_traversal_tag   )
+BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, forward_traversal_tag,       forward_traversal_tag       )
+BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, bidirectional_traversal_tag, forward_traversal_tag       )
+BOOST_DEMOTE_TRAVERSAL_TAG( forward_traversal_tag, random_access_traversal_tag, forward_traversal_tag       )
+
+BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, no_traversal_tag,            no_traversal_tag            )
+BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, single_pass_traversal_tag,   single_pass_traversal_tag   )
+BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, forward_traversal_tag,       forward_traversal_tag       )
+BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, bidirectional_traversal_tag, bidirectional_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( bidirectional_traversal_tag, random_access_traversal_tag, bidirectional_traversal_tag )
+
+BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, no_traversal_tag,            no_traversal_tag            )
+BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, incrementable_traversal_tag, incrementable_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, single_pass_traversal_tag,   single_pass_traversal_tag   )
+BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, forward_traversal_tag,       forward_traversal_tag       )
+BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, bidirectional_traversal_tag, bidirectional_traversal_tag )
+BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal_tag, random_access_traversal_tag )
+
+#undef BOOST_DEMOTE_TRAVERSAL_TAG
+
+template<class IteratorTraversalTag1, class IteratorTraversalTag2>
+struct demote_iterator_traversal_tag
+    : inner_demote_iterator_traversal_tag<
+        typename boost::detail::pure_traversal_tag< IteratorTraversalTag1 >::type,
+        typename boost::detail::pure_traversal_tag< IteratorTraversalTag2 >::type
+      >
+{
+};
+
+    } // namespace range_detail
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/detail_str.hpp b/src/boost/range/detail/detail_str.hpp
new file mode 100644
index 0000000..5ef7a34
--- /dev/null
+++ b/src/boost/range/detail/detail_str.hpp
@@ -0,0 +1,376 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_DETAIL_STR_HPP
+#define BOOST_RANGE_DETAIL_DETAIL_STR_HPP
+
+#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/range/iterator.hpp>
+
+namespace boost 
+{
+    
+    namespace range_detail
+    {
+        //
+        // iterator
+        //
+        
+        template<>
+        struct range_iterator_<char_array_>
+        { 
+            template< typename T >
+            struct pts
+            {
+                 typedef BOOST_RANGE_DEDUCED_TYPENAME 
+                    remove_extent<T>::type* type;
+            };
+        };
+
+        template<>
+        struct range_iterator_<char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef char* type; 
+            };         
+        };
+
+        template<>
+        struct range_iterator_<const_char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef const char* type;
+            };         
+        };
+
+        template<>
+        struct range_iterator_<wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef wchar_t* type; 
+            };         
+        };
+
+        template<>
+        struct range_iterator_<const_wchar_t_ptr_>
+        {
+             template< typename S >
+             struct pts
+             {
+                 typedef const wchar_t* type; 
+             };         
+        };
+
+
+        //
+        // const iterator
+        //
+
+        template<>
+        struct range_const_iterator_<char_array_>
+        { 
+            template< typename T >
+            struct pts
+            {
+                typedef const BOOST_RANGE_DEDUCED_TYPENAME 
+                    remove_extent<T>::type* type;
+            };
+        };
+
+        template<>
+        struct range_const_iterator_<char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef const char* type; 
+            };         
+        };
+
+        template<>
+        struct range_const_iterator_<const_char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef const char* type; 
+            };         
+        };
+
+        template<>
+        struct range_const_iterator_<wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef const wchar_t* type; 
+            };         
+        };
+
+        template<>
+        struct range_const_iterator_<const_wchar_t_ptr_>
+        {
+             template< typename S >
+             struct pts
+             {
+                 typedef const wchar_t* type; 
+             };         
+        };
+    }
+}
+
+#include <boost/range/detail/begin.hpp>
+#include <boost/range/detail/end.hpp>
+#include <boost/range/detail/size_type.hpp>
+#include <boost/range/detail/value_type.hpp>
+#include <boost/range/detail/common.hpp>
+
+namespace boost 
+{
+    
+    namespace range_detail
+    {
+        //
+        // str_begin()
+        //
+        template<>
+        struct range_begin<char_ptr_>
+        {
+            static char* fun( char* s )
+            {
+                return s;
+            }
+        };
+
+        template<>
+        struct range_begin<const_char_ptr_>
+        {
+            static const char* fun( const char* s )
+            {
+                return s;
+            }
+        };
+        
+        template<>
+        struct range_begin<wchar_t_ptr_>
+        {
+            
+            static wchar_t* fun( wchar_t* s )
+            {
+                return s;
+            }
+        };
+
+        template<>
+        struct range_begin<const_wchar_t_ptr_>
+        {
+            static const wchar_t* fun( const wchar_t* s )
+            {
+                return s;
+            }
+        };
+        
+        template< typename C >
+        inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type 
+        str_begin( C& c )
+        {
+            return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME 
+                range_detail::range<C>::type >::fun( c );
+        }
+
+        //
+        // str_end()
+        //
+
+        template<>
+        struct range_end<char_array_>
+        {
+            template< typename T, std::size_t sz >
+            static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return boost::range_detail::array_end( boost_range_array );
+            }
+        };
+        
+        template<>
+        struct range_end<wchar_t_array_>
+        {
+            template< typename T, std::size_t sz >
+            static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return boost::range_detail::array_end( boost_range_array );
+            }
+        };
+        
+        template<>
+        struct range_end<char_ptr_>
+        {
+            static char* fun( char* s )
+            {
+                return boost::range_detail::str_end( s );
+            }
+        };
+
+        template<>
+        struct range_end<const_char_ptr_>
+        {
+            static const char* fun( const char* s )
+            {
+                return boost::range_detail::str_end( s );
+            }
+        };
+
+        template<>
+        struct range_end<wchar_t_ptr_>
+        {
+            static wchar_t* fun( wchar_t* s )
+            {
+                return boost::range_detail::str_end( s );
+            }
+        };
+
+
+        template<>
+        struct range_end<const_wchar_t_ptr_>
+        {
+            static const wchar_t* fun( const wchar_t* s )
+            {
+                return boost::range_detail::str_end( s );
+            }
+        };
+
+        template< typename C >
+        inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type 
+        str_end( C& c )
+        {
+            return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME 
+                range_detail::range<C>::type >::fun( c );
+        }
+
+        //
+        // size_type
+        //
+
+        template<>
+        struct range_size_type_<char_array_>
+        { 
+            template< typename A >
+            struct pts
+            {
+                typedef std::size_t type;
+            };
+        };
+
+        template<>
+        struct range_size_type_<char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::size_t type;
+            };         
+        };
+        
+        template<>
+        struct range_size_type_<const_char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::size_t type;
+            };         
+        };
+        
+        template<>
+        struct range_size_type_<wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::size_t type;
+            };         
+        };
+        
+        template<>
+        struct range_size_type_<const_wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::size_t type;
+            };         
+        };  
+
+        //
+        // value_type
+        //
+        
+        template<>
+        struct range_value_type_<char_array_>
+        { 
+            template< typename T >
+            struct pts
+            {
+                typedef char type;
+            };
+        };
+
+        template<>
+        struct range_value_type_<char_ptr_>
+        {
+             template< typename S >
+             struct pts
+             {
+                 typedef char type; 
+             };         
+        };
+        
+        template<>
+        struct range_value_type_<const_char_ptr_>
+        {
+             template< typename S >
+             struct pts
+             {
+                 typedef const char type;
+             };         
+        };
+        
+        template<>
+        struct range_value_type_<wchar_t_ptr_>
+        {
+             template< typename S >
+             struct pts
+             {
+                 typedef wchar_t type;
+             };         
+        };
+        
+        template<>
+        struct range_value_type_<const_wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef const wchar_t type;
+            };         
+        };
+
+    } // namespace 'range_detail'
+
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/detail/difference_type.hpp b/src/boost/range/detail/difference_type.hpp
new file mode 100644
index 0000000..c641516
--- /dev/null
+++ b/src/boost/range/detail/difference_type.hpp
@@ -0,0 +1,121 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP
+#define BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP
+
+#include <boost/range/detail/common.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+// missing partial specialization  workaround.
+//////////////////////////////////////////////////////////////////////////////
+
+namespace boost 
+{
+    namespace range_detail 
+    {        
+        template< typename T >
+        struct range_difference_type_;
+
+        template<>
+        struct range_difference_type_<std_container_>
+        {
+            template< typename C >
+            struct pts
+            {
+                typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
+            };
+        };
+
+        template<>
+        struct range_difference_type_<std_pair_>
+        {
+            template< typename P >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;                
+            };
+        };
+
+        template<>
+        struct range_difference_type_<array_>
+        {
+            template< typename A >
+            struct pts
+            {
+                typedef std::ptrdiff_t type;
+            };
+        };
+
+        template<>
+        struct range_difference_type_<char_array_>
+        { 
+            template< typename A >
+            struct pts
+            {
+                typedef std::ptrdiff_t type;
+            };
+        };
+
+        template<>
+        struct range_difference_type_<char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::ptrdiff_t type;
+            };         
+        };
+        
+        template<>
+        struct range_difference_type_<const_char_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::ptrdiff_t type;
+            };         
+        };
+        
+        template<>
+        struct range_difference_type_<wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::ptrdiff_t type;
+            };         
+        };
+        
+        template<>
+        struct range_difference_type_<const_wchar_t_ptr_>
+        {
+            template< typename S >
+            struct pts
+            {
+                typedef std::ptrdiff_t type;
+            };         
+        };
+        
+    } 
+    
+    template< typename C >
+    class range_difference
+    {
+        typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
+    public:
+        typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; 
+    };
+
+}
+
+#endif
+
diff --git a/src/boost/range/detail/empty.hpp b/src/boost/range/detail/empty.hpp
new file mode 100644
index 0000000..b098705
--- /dev/null
+++ b/src/boost/range/detail/empty.hpp
@@ -0,0 +1,120 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_EMPTY_HPP
+#define BOOST_RANGE_DETAIL_EMPTY_HPP
+
+#include <boost/range/detail/common.hpp>
+
+namespace boost 
+{
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_empty;
+
+        //////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_empty<std_container_>
+        {
+            template< typename C >
+            static bool fun( C& c )
+            {
+                return c.empty();
+            };
+        };
+                    
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_empty<std_pair_>
+        {
+            template< typename P >
+            static bool fun( const P& p )
+            {
+                return p.first == p.second;
+            }
+        };
+ 
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_empty<array_>
+        {
+            template< typename T, std::size_t sz >
+            static bool fun( T BOOST_ARRAY_REF[sz] )
+            {
+                if( boost_range_array == 0 )
+                    return true;
+                return false;
+            }
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // string
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_empty<char_ptr_>
+        {
+            static bool fun( const char* s )
+            {
+                return s == 0 || s[0] == 0;
+            }
+        };
+
+        template<>
+        struct range_empty<const_char_ptr_>
+        {
+            static bool fun( const char* s )
+            {
+                return  s == 0 || s[0] == 0;
+            }
+        };
+
+        template<>
+        struct range_empty<wchar_t_ptr_>
+        {
+            static bool fun( const wchar_t* s )
+            {
+                return  s == 0 || s[0] == 0;
+            }
+        };
+        
+        template<>
+        struct range_empty<const_wchar_t_ptr_>
+        {
+            static bool fun( const wchar_t* s )
+            {
+                return  s == 0 || s[0] == 0;
+            }
+        };
+
+    } // namespace 'range_detail'
+    
+        
+    template< typename C >
+    inline bool 
+    empty( const C& c )
+    {
+        return range_detail::range_empty<  BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
+    }
+
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/detail/end.hpp b/src/boost/range/detail/end.hpp
new file mode 100644
index 0000000..8b5f35d
--- /dev/null
+++ b/src/boost/range/detail/end.hpp
@@ -0,0 +1,101 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_END_HPP
+#define BOOST_RANGE_DETAIL_END_HPP
+
+#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+# include <boost/range/detail/vc6/end.hpp>
+#else
+# include <boost/range/detail/implementation_help.hpp>
+# include <boost/range/iterator.hpp>
+# include <boost/range/detail/common.hpp>
+# if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
+#  include <boost/range/detail/remove_extent.hpp>
+# endif
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_end;
+
+        //////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_end<std_container_>
+        {
+            template< typename C >
+            static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
+            fun( C& c )
+            {
+                return c.end();
+            };
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_end<std_pair_>
+        {
+            template< typename P >
+            static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
+            fun( const P& p )
+            {
+                return p.second;
+            }
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_end<array_>
+        {
+        #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
+            template< typename T, std::size_t sz >
+            static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return boost::range_detail::array_end( boost_range_array );
+            }
+        #else
+            template<typename T>
+            static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
+            {
+                return t + remove_extent<T>::size;
+            }
+        #endif
+        };
+
+    } // namespace 'range_detail'
+
+    namespace range_adl_barrier
+    {
+        template< typename C >
+        inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
+        end( C& c )
+        {
+            return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
+        }
+    } // namespace range_adl_barrier
+
+} // namespace 'boost'
+
+# endif // VC6
+#endif
diff --git a/src/boost/range/detail/extract_optional_type.hpp b/src/boost/range/detail/extract_optional_type.hpp
new file mode 100644
index 0000000..8292e34
--- /dev/null
+++ b/src/boost/range/detail/extract_optional_type.hpp
@@ -0,0 +1,52 @@
+// Boost.Range library
+//
+//  Copyright Arno Schoedl & Neil Groves 2009.
+//  Use, modification and distribution is subject to the Boost Software
+//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_EXTRACT_OPTIONAL_TYPE_HPP_INCLUDED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_NO_PARTIAL_TEMPLATE_SPECIALIZATION
+
+#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef )                         \
+    template< typename C >                                                     \
+    struct extract_ ## a_typedef                                               \
+    {                                                                          \
+        typedef BOOST_DEDUCED_TYPENAME C::a_typedef type;                      \
+    };
+
+#else
+
+namespace boost {
+    namespace range_detail {
+        template< typename T > struct exists { typedef void type; };
+    }
+}
+
+// Defines extract_some_typedef<T> which exposes T::some_typedef as
+// extract_some_typedef<T>::type if T::some_typedef exists. Otherwise
+// extract_some_typedef<T> is empty.
+#define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef )                         \
+    template< typename C, typename Enable=void >                               \
+    struct extract_ ## a_typedef                                               \
+    {};                                                                        \
+    template< typename C >                                                     \
+    struct extract_ ## a_typedef< C                                            \
+    , BOOST_DEDUCED_TYPENAME boost::range_detail::exists< BOOST_DEDUCED_TYPENAME C::a_typedef >::type \
+    > {                                                                        \
+        typedef BOOST_DEDUCED_TYPENAME C::a_typedef type;                      \
+    };
+
+#endif
+
+#endif // include guard
diff --git a/src/boost/range/detail/implementation_help.hpp b/src/boost/range/detail/implementation_help.hpp
new file mode 100644
index 0000000..1f7d163
--- /dev/null
+++ b/src/boost/range/detail/implementation_help.hpp
@@ -0,0 +1,103 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
+#define BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
+
+#include <boost/range/config.hpp>
+#include <boost/range/detail/common.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <cstddef>
+#include <string.h>
+
+#ifndef BOOST_NO_CWCHAR
+#include <wchar.h>
+#endif
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template <typename T>
+        inline void boost_range_silence_warning( const T& ) { }
+
+        /////////////////////////////////////////////////////////////////////
+        // end() help
+        /////////////////////////////////////////////////////////////////////
+
+        inline const char* str_end( const char* s, const char* )
+        {
+            return s + strlen( s );
+        }
+
+#ifndef BOOST_NO_CWCHAR
+        inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
+        {
+            return s + wcslen( s );
+        }
+#else
+        inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
+        {
+            if( s == 0 || s[0] == 0 )
+                return s;
+            while( *++s != 0 )
+                ;
+            return s;
+        }
+#endif
+
+        template< class Char >
+        inline Char* str_end( Char* s )
+        {
+            return const_cast<Char*>( str_end( s, s ) );
+        }
+
+        template< class T, std::size_t sz >
+        inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
+        {
+            return boost_range_array + sz;
+        }
+
+        template< class T, std::size_t sz >
+        inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
+        {
+            return boost_range_array + sz;
+        }
+
+        /////////////////////////////////////////////////////////////////////
+        // size() help
+        /////////////////////////////////////////////////////////////////////
+
+        template< class Char >
+        inline std::size_t str_size( const Char* const& s )
+        {
+            return str_end( s ) - s;
+        }
+
+        template< class T, std::size_t sz >
+        inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
+        {
+            boost_range_silence_warning( boost_range_array );
+            return sz;
+        }
+
+        template< class T, std::size_t sz >
+        inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
+        {
+            boost_range_silence_warning( boost_range_array );
+            return sz;
+        }
+
+    } // namespace 'range_detail'
+
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/detail/iterator.hpp b/src/boost/range/detail/iterator.hpp
new file mode 100644
index 0000000..58346d4
--- /dev/null
+++ b/src/boost/range/detail/iterator.hpp
@@ -0,0 +1,78 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_ITERATOR_HPP
+#define BOOST_RANGE_DETAIL_ITERATOR_HPP
+
+#include <boost/range/detail/common.hpp>
+#include <boost/range/detail/remove_extent.hpp>
+
+#include <boost/static_assert.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+// missing partial specialization  workaround.
+//////////////////////////////////////////////////////////////////////////////
+
+namespace boost 
+{
+    namespace range_detail 
+    {        
+        template< typename T >
+        struct range_iterator_ {
+            template< typename C >
+            struct pts
+            {
+                typedef int type;
+            };
+        };
+
+        template<>
+        struct range_iterator_<std_container_>
+        {
+            template< typename C >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type;
+            };
+        };
+
+        template<>
+        struct range_iterator_<std_pair_>
+        {
+            template< typename P >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
+            };
+        };
+
+        template<>
+        struct range_iterator_<array_>
+        { 
+            template< typename T >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME 
+                    remove_extent<T>::type* type;
+            };
+        };
+        
+    } 
+
+    template< typename C >
+    class range_mutable_iterator
+    {
+        typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
+    public:
+        typedef typename range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; 
+    };
+}
+
+#endif
diff --git a/src/boost/range/detail/join_iterator.hpp b/src/boost/range/detail/join_iterator.hpp
new file mode 100644
index 0000000..bbdeec7
--- /dev/null
+++ b/src/boost/range/detail/join_iterator.hpp
@@ -0,0 +1,344 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// Acknowledgements:
+// aschoedl contributed an improvement to the determination
+// of the Reference type parameter.
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED
+
+#include <iterator>
+#include <boost/assert.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/empty.hpp>
+#include <boost/range/detail/demote_iterator_traversal_tag.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/next_prior.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+
+template<typename Iterator1, typename Iterator2>
+struct join_iterator_link
+{
+public:
+    join_iterator_link(Iterator1 last1, Iterator2 first2)
+        :    last1(last1)
+        ,    first2(first2)
+    {
+    }
+
+    Iterator1 last1;
+    Iterator2 first2;
+
+private:
+    join_iterator_link() /* = delete */ ;
+};
+
+class join_iterator_begin_tag {};
+class join_iterator_end_tag {};
+
+template<typename Iterator1
+       , typename Iterator2
+       , typename Reference
+>
+class join_iterator_union
+{
+public:
+    typedef Iterator1 iterator1_t;
+    typedef Iterator2 iterator2_t;
+
+    join_iterator_union() {}
+    join_iterator_union(unsigned int /*selected*/, const iterator1_t& it1, const iterator2_t& it2) : m_it1(it1), m_it2(it2) {}
+
+    iterator1_t& it1() { return m_it1; }
+    const iterator1_t& it1() const { return m_it1; }
+
+    iterator2_t& it2() { return m_it2; }
+    const iterator2_t& it2() const { return m_it2; }
+
+    Reference dereference(unsigned int selected) const
+    {
+        return selected ? *m_it2 : *m_it1;
+    }
+
+    bool equal(const join_iterator_union& other, unsigned int selected) const
+    {
+        return selected
+            ? m_it2 == other.m_it2
+            : m_it1 == other.m_it1;
+    }
+
+private:
+    iterator1_t m_it1;
+    iterator2_t m_it2;
+};
+
+template<class Iterator, class Reference>
+class join_iterator_union<Iterator, Iterator, Reference>
+{
+public:
+    typedef Iterator iterator1_t;
+    typedef Iterator iterator2_t;
+
+    join_iterator_union() {}
+
+    join_iterator_union(unsigned int selected, const iterator1_t& it1, const iterator2_t& it2)
+        : m_it(selected ? it2 : it1)
+    {
+    }
+
+    iterator1_t& it1() { return m_it; }
+    const iterator1_t& it1() const { return m_it; }
+
+    iterator2_t& it2() { return m_it; }
+    const iterator2_t& it2() const { return m_it; }
+
+    Reference dereference(unsigned int) const
+    {
+        return *m_it;
+    }
+
+    bool equal(const join_iterator_union& other, unsigned int selected) const
+    {
+        return m_it == other.m_it;
+    }
+
+private:
+    iterator1_t m_it;
+};
+
+template<typename Iterator1
+       , typename Iterator2
+       , typename ValueType = typename iterator_value<Iterator1>::type
+       // find least demanding, commonly supported reference type, in the order &, const&, and by-value:
+       , typename Reference = typename mpl::if_c<
+                !is_reference<typename iterator_reference<Iterator1>::type>::value
+             || !is_reference<typename iterator_reference<Iterator2>::type>::value,
+                        typename remove_const<
+                            typename remove_reference<
+                                typename iterator_reference<Iterator1>::type
+                            >::type
+                        >::type,
+                        typename mpl::if_c<
+                            is_const<
+                                typename remove_reference<
+                                    typename iterator_reference<Iterator1>::type
+                                >::type
+                            >::value
+                            || is_const<
+                                typename remove_reference<
+                                    typename iterator_reference<Iterator2>::type
+                                >::type
+                            >::value,
+                            typename add_const<
+                                typename iterator_reference<Iterator2>::type
+                            >::type,
+                            typename iterator_reference<Iterator1>::type
+                        >::type
+                    >::type
+       , typename Traversal = typename demote_iterator_traversal_tag<
+                                  typename iterator_traversal<Iterator1>::type
+                                , typename iterator_traversal<Iterator2>::type>::type
+>
+class join_iterator
+    : public iterator_facade<join_iterator<Iterator1,Iterator2,ValueType,Reference,Traversal>, ValueType, Traversal, Reference>
+{
+    typedef join_iterator_link<Iterator1, Iterator2> link_t;
+    typedef join_iterator_union<Iterator1, Iterator2, Reference> iterator_union;
+public:
+    typedef Iterator1 iterator1_t;
+    typedef Iterator2 iterator2_t;
+
+    join_iterator()
+        : m_section(0u)
+        , m_it(0u, iterator1_t(), iterator2_t())
+        , m_link(link_t(iterator1_t(), iterator2_t()))
+    {}
+
+    join_iterator(unsigned int section, Iterator1 current1, Iterator1 last1, Iterator2 first2, Iterator2 current2)
+        : m_section(section)
+        , m_it(section, current1, current2)
+        , m_link(link_t(last1, first2))
+        {
+        }
+
+    template<typename Range1, typename Range2>
+    join_iterator(Range1& r1, Range2& r2, join_iterator_begin_tag)
+        : m_section(boost::empty(r1) ? 1u : 0u)
+        , m_it(boost::empty(r1) ? 1u : 0u, boost::begin(r1), boost::begin(r2))
+        , m_link(link_t(boost::end(r1), boost::begin(r2)))
+    {
+    }
+
+    template<typename Range1, typename Range2>
+    join_iterator(const Range1& r1, const Range2& r2, join_iterator_begin_tag)
+        : m_section(boost::empty(r1) ? 1u : 0u)
+        , m_it(boost::empty(r1) ? 1u : 0u, boost::const_begin(r1), boost::const_begin(r2))
+        , m_link(link_t(boost::const_end(r1), boost::const_begin(r2)))
+    {
+    }
+
+    template<typename Range1, typename Range2>
+    join_iterator(Range1& r1, Range2& r2, join_iterator_end_tag)
+        : m_section(1u)
+        , m_it(1u, boost::end(r1), boost::end(r2))
+        , m_link(link_t(boost::end(r1), boost::begin(r2)))
+    {
+    }
+
+    template<typename Range1, typename Range2>
+    join_iterator(const Range1& r1, const Range2& r2, join_iterator_end_tag)
+        : m_section(1u)
+        , m_it(1u, boost::const_end(r1), boost::const_end(r2))
+        , m_link(link_t(boost::const_end(r1), boost::const_begin(r2)))
+    {
+    }
+
+private:
+    void increment()
+    {
+        if (m_section)
+            ++m_it.it2();
+        else
+        {
+            ++m_it.it1();
+            if (m_it.it1() == m_link.last1)
+            {
+                m_it.it2() = m_link.first2;
+                m_section = 1u;
+            }
+        }
+    }
+
+    void decrement()
+    {
+        if (m_section)
+        {
+            if (m_it.it2() == m_link.first2)
+            {
+                m_it.it1() = boost::prior(m_link.last1);
+                m_section = 0u;
+            }
+            else
+                --m_it.it2();
+        }
+        else
+            --m_it.it1();
+    }
+
+    typename join_iterator::reference dereference() const
+    {
+        return m_it.dereference(m_section);
+    }
+
+    bool equal(const join_iterator& other) const
+    {
+        return m_section == other.m_section
+            && m_it.equal(other.m_it, m_section);
+    }
+
+    void advance(typename join_iterator::difference_type offset)
+    {
+        if (m_section)
+            advance_from_range2(offset);
+        else
+            advance_from_range1(offset);
+    }
+
+    typename join_iterator::difference_type distance_to(const join_iterator& other) const
+    {
+        typename join_iterator::difference_type result;
+        if (m_section)
+        {
+            if (other.m_section)
+                result = other.m_it.it2() - m_it.it2();
+            else
+            {
+                result = (m_link.first2 - m_it.it2())
+                       + (other.m_it.it1() - m_link.last1);
+
+                BOOST_ASSERT( result <= 0 );
+            }
+        }
+        else
+        {
+            if (other.m_section)
+            {
+                result = (m_link.last1 - m_it.it1())
+                       + (other.m_it.it2() - m_link.first2);
+            }
+            else
+                result = other.m_it.it1() - m_it.it1();
+        }
+        return result;
+    }
+
+    void advance_from_range2(typename join_iterator::difference_type offset)
+    {
+        typedef typename join_iterator::difference_type difference_t;
+        BOOST_ASSERT( m_section == 1u );
+        if (offset < 0)
+        {
+            difference_t r2_dist = m_link.first2 - m_it.it2();
+            BOOST_ASSERT( r2_dist <= 0 );
+            if (offset >= r2_dist)
+                std::advance(m_it.it2(), offset);
+            else
+            {
+                difference_t r1_dist = offset - r2_dist;
+                BOOST_ASSERT( r1_dist <= 0 );
+                m_it.it1() = m_link.last1 + r1_dist;
+                m_section = 0u;
+            }
+        }
+        else
+            std::advance(m_it.it2(), offset);
+    }
+
+    void advance_from_range1(typename join_iterator::difference_type offset)
+    {
+        typedef typename join_iterator::difference_type difference_t;
+        BOOST_ASSERT( m_section == 0u );
+        if (offset > 0)
+        {
+            difference_t r1_dist = m_link.last1 - m_it.it1();
+            BOOST_ASSERT( r1_dist >= 0 );
+            if (offset < r1_dist)
+                std::advance(m_it.it1(), offset);
+            else
+            {
+                difference_t r2_dist = offset - r1_dist;
+                BOOST_ASSERT( r2_dist >= 0 );
+                m_it.it2() = m_link.first2 + r2_dist;
+                m_section = 1u;
+            }
+        }
+        else
+            std::advance(m_it.it1(), offset);
+    }
+
+    unsigned int m_section;
+    iterator_union m_it;
+    link_t m_link;
+
+    friend class ::boost::iterator_core_access;
+};
+
+    } // namespace range_detail
+
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/microsoft.hpp b/src/boost/range/detail/microsoft.hpp
new file mode 100644
index 0000000..7b672c9
--- /dev/null
+++ b/src/boost/range/detail/microsoft.hpp
@@ -0,0 +1,931 @@
+#ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP
+#define BOOST_RANGE_DETAIL_MICROSOFT_HPP
+
+// Boost.Range MFC/ATL Extension
+//
+// Copyright Shunsuke Sogame 2005-2006.
+// Distributed under the Boost Software License, Version 1.0. 
+// (See accompanying file LICENSE_1_0.txt or copy at 
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+
+
+// config
+//
+
+
+#include <boost/range/iterator.hpp>
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1 1
+
+
+#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
+    #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
+    #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin            range_begin
+    #define BOOST_RANGE_DETAIL_MICROSOFT_range_end              range_end
+#else
+    #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
+    #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin            range_begin
+    #define BOOST_RANGE_DETAIL_MICROSOFT_range_end              range_end
+#endif
+
+
+
+
+// yet another customization way
+//
+
+
+#include <boost/iterator/iterator_traits.hpp> // iterator_difference
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/comma_if.hpp>
+#include <boost/preprocessor/detail/is_unary.hpp>
+#include <boost/preprocessor/list/for_each.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/seq/for_each_i.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+#include <boost/range/const_iterator.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/utility/addressof.hpp>
+#include <boost/utility/enable_if.hpp> // disable_if
+
+#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
+    #include <boost/range/mutable_iterator.hpp>
+#else
+    #include <iterator> // distance
+    #include <boost/range/begin.hpp>
+    #include <boost/range/end.hpp>
+    #include <boost/range/iterator.hpp>
+#endif
+
+
+namespace boost { namespace range_detail_microsoft {
+
+
+    // customization point
+    //
+
+    template< class Tag >
+    struct customization;
+
+
+    template< class T >
+    struct customization_tag;
+
+
+    struct using_type_as_tag
+    { };
+
+
+    // Topic:
+    // In fact, it is unnecessary for VC++.
+    // VC++'s behavior seems conforming, while GCC fails without this.
+    template< class Iterator, class T >
+    struct mutable_ :
+        disable_if< is_const<T>, Iterator >
+    { };
+
+
+    // helpers
+    //
+
+    template< class Tag, class T >
+    struct customization_tag_of
+    {
+        typedef typename mpl::if_< is_same<using_type_as_tag, Tag>,
+            T,
+            Tag
+        >::type type;
+    };
+
+
+    template< class T >
+    struct customization_of
+    {
+        typedef typename remove_cv<T>::type bare_t;
+        typedef typename customization_tag<bare_t>::type tag_t;
+        typedef customization<tag_t> type;
+    };
+
+
+    template< class T >
+    struct mutable_iterator_of
+    {
+        typedef typename remove_cv<T>::type bare_t;
+        typedef typename customization_of<bare_t>::type cust_t;
+        typedef typename cust_t::template meta<bare_t>::mutable_iterator type;
+    };
+
+
+    template< class T >
+    struct const_iterator_of
+    {
+        typedef typename remove_cv<T>::type bare_t;
+        typedef typename customization_of<bare_t>::type cust_t;
+        typedef typename cust_t::template meta<bare_t>::const_iterator type;
+    };
+
+
+    template< class T >
+    struct size_type_of
+    {
+        typedef typename range_detail_microsoft::mutable_iterator_of<T>::type miter_t;
+        typedef typename iterator_difference<miter_t>::type type;
+    };
+
+
+    template< class T > inline
+    typename mutable_iterator_of<T>::type
+    begin_of(T& x)
+    {
+        typedef typename customization_of<T>::type cust_t;
+        return cust_t().template begin<typename mutable_iterator_of<T>::type>(x);
+    }
+
+
+    template< class T > inline
+    typename const_iterator_of<T>::type
+    begin_of(T const& x)
+    {
+        typedef typename customization_of<T>::type cust_t;
+        return cust_t().template begin<typename const_iterator_of<T>::type>(x);
+    }
+
+
+    template< class T > inline
+    typename mutable_iterator_of<T>::type
+    end_of(T& x)
+    {
+        typedef typename customization_of<T>::type cust_t;
+        return cust_t().template end<typename mutable_iterator_of<T>::type>(x);
+    }
+
+
+    template< class T > inline
+    typename const_iterator_of<T>::type
+    end_of(T const& x)
+    {
+        typedef typename customization_of<T>::type cust_t;
+        return cust_t().template end<typename const_iterator_of<T>::type>(x);
+    }
+
+
+#if defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
+
+    template< class T > inline
+    typename size_type_of<T>::type
+    size_of(T const& x)
+    {
+        return std::distance(boost::begin(x), boost::end(x));
+    }
+
+#endif
+
+
+    template< class Range >
+    struct compatible_mutable_iterator : 
+        BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>
+    { };
+
+
+} } // namespace boost::range_detail_microsoft
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
+    BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op, ~, NamespaceList) \
+/**/
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op(r, data, elem) \
+        namespace elem { \
+    /**/
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
+    BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op, ~, NamespaceList) \
+/**/
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op(r, data, elem) \
+        } \
+    /**/
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op(r, data, elem) \
+    :: elem \
+/**/
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(Tag, NamespaceList, Name) \
+    namespace boost { namespace range_detail_microsoft { \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+    } } \
+    \
+    namespace boost { \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+    } \
+    \
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
+/**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name) \
+        BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) :: Name \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, Fullname) \
+        template< > \
+        struct customization_tag< Fullname > : \
+            customization_tag_of< Tag, Fullname > \
+        { }; \
+    /**/
+
+
+    // metafunctions
+    //
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(Fullname) \
+        template< > \
+        struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
+            range_detail_microsoft::mutable_iterator_of< Fullname > \
+        { }; \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(Fullname) \
+        template< > \
+        struct range_const_iterator< Fullname > : \
+            range_detail_microsoft::const_iterator_of< Fullname > \
+        { }; \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(Fullname) \
+        template< > \
+        struct range_size< Fullname > : \
+            range_detail_microsoft::size_type_of< Fullname > \
+        { }; \
+    /**/
+
+
+    // functions
+    //
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(Fullname) \
+        inline \
+        boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
+        { \
+            return boost::range_detail_microsoft::begin_of(x); \
+        } \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(Fullname) \
+        inline \
+        boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
+        { \
+            return boost::range_detail_microsoft::begin_of(x); \
+        } \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(Fullname) \
+        inline \
+        boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
+        { \
+            return boost::range_detail_microsoft::end_of(x); \
+        } \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(Fullname) \
+        inline \
+        boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
+        { \
+            return boost::range_detail_microsoft::end_of(x); \
+        } \
+    /**/
+
+
+    #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
+
+        #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
+        /**/
+
+    #else
+
+        #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
+            inline \
+            boost::range_detail_microsoft::size_type_of< Fullname >::type \
+            boost_range_size(Fullname const& x) \
+            { \
+                return boost::range_detail_microsoft::size_of(x); \
+            } \
+        /**/
+
+    #endif
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(Tag, NamespaceList, Name, ParamSeqOrCount) \
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl( \
+        Tag, NamespaceList, Name, \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
+    ) \
+/**/
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
+        BOOST_PP_IIF(BOOST_PP_IS_UNARY(ParamSeqOrCount), \
+            ParamSeqOrCount BOOST_PP_TUPLE_EAT(3), \
+            BOOST_PP_REPEAT \
+        )(ParamSeqOrCount, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op, ~) \
+    /**/
+
+        #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op(z, n, _) \
+            (class) \
+        /**/
+
+
+#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl(Tag, NamespaceList, Name, ParamSeq) \
+    namespace boost { namespace range_detail_microsoft { \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag( \
+            Tag, \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+    } } \
+    \
+    namespace boost { \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+        \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+    } \
+    \
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+        BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size( \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
+            BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        ) \
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
+/**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq) \
+        BOOST_PP_SEQ_FOR_EACH_I(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op, ~, ParamSeq) \
+    /**/
+
+        #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op(r, data, i, elem) \
+            BOOST_PP_COMMA_IF(i) elem BOOST_PP_CAT(T, i) \
+        /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
+        BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) \
+        :: Name < BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(ParamSeq), T) > \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag(Tag, Params, Fullname) \
+        template< Params > \
+        struct customization_tag< Fullname > : \
+            customization_tag_of< Tag, Fullname > \
+        { }; \
+    /**/
+
+
+    // metafunctions
+    //
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator(Params, Fullname) \
+        template< Params > \
+        struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
+            range_detail_microsoft::mutable_iterator_of< Fullname > \
+        { }; \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator(Params, Fullname) \
+        template< Params > \
+        struct range_const_iterator< Fullname > : \
+            range_detail_microsoft::const_iterator_of< Fullname > \
+        { }; \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type(Params, Fullname) \
+        template< Params > \
+        struct range_size< Fullname > : \
+            range_detail_microsoft::size_type_of< Fullname > \
+        { }; \
+    /**/
+
+
+    // functions
+    //
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin(Params, Fullname) \
+        template< Params > inline \
+        typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
+        { \
+            return boost::range_detail_microsoft::begin_of(x); \
+        } \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const(Params, Fullname) \
+        template< Params > inline \
+        typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
+        { \
+            return boost::range_detail_microsoft::begin_of(x); \
+        } \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end(Params, Fullname) \
+        template< Params > inline \
+        typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
+        { \
+            return boost::range_detail_microsoft::end_of(x); \
+        } \
+    /**/
+
+
+    #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const(Params, Fullname) \
+        template< Params > inline \
+        typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
+        BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
+        { \
+            return boost::range_detail_microsoft::end_of(x); \
+        } \
+    /**/
+
+
+    #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
+
+        #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
+        /**/
+
+    #else
+
+        #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
+            template< Params > inline \
+            typename boost::range_detail_microsoft::size_type_of< Fullname >::type \
+            boost_range_size(Fullname const& x) \
+            { \
+                return boost::range_detail_microsoft::size_of(x); \
+            } \
+        /**/
+
+    #endif
+
+
+
+
+// list_iterator and helpers
+//
+
+
+#include <boost/assert.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+
+// POSITION's header is undocumented, so is NULL.
+//
+struct __POSITION; // incomplete, but used as just a pointer.
+typedef __POSITION *POSITION;
+
+
+namespace boost { namespace range_detail_microsoft {
+
+
+    template<
+        class ListT,
+        class Value,
+        class Reference,
+        class Traversal
+    >
+    struct list_iterator;
+
+
+    template<
+        class ListT,
+        class Value,
+        class Reference,
+        class Traversal
+    >
+    struct list_iterator_super
+    {
+        typedef typename mpl::if_< is_same<use_default, Reference>,
+            Value&,
+            Reference
+        >::type ref_t;
+
+        typedef typename mpl::if_< is_same<use_default, Traversal>,
+            bidirectional_traversal_tag,
+            Traversal
+        >::type trv_t;
+
+        typedef iterator_facade<
+            list_iterator<ListT, Value, Reference, Traversal>,
+            Value,
+            trv_t,
+            ref_t
+        > type;
+    };
+
+
+    template<
+        class ListT,
+        class Value,
+        class Reference = use_default,
+        class Traversal = use_default
+    >
+    struct list_iterator :
+        list_iterator_super<ListT, Value, Reference, Traversal>::type
+    {
+    private:
+        typedef list_iterator self_t;
+        typedef typename list_iterator_super<ListT, Value, Reference, Traversal>::type super_t;
+        typedef typename super_t::reference ref_t;
+
+    public:
+        explicit list_iterator()
+        { }
+
+        explicit list_iterator(ListT& lst, POSITION pos) :
+            m_plst(boost::addressof(lst)), m_pos(pos)
+        { }
+
+    template< class, class, class, class > friend struct list_iterator;
+        template< class ListT_, class Value_, class Reference_, class Traversal_>
+        list_iterator(list_iterator<ListT_, Value_, Reference_, Traversal_> const& other) :
+            m_plst(other.m_plst), m_pos(other.m_pos)
+        { }
+
+    private:
+        ListT *m_plst;
+        POSITION m_pos;
+
+    friend class iterator_core_access;
+        ref_t dereference() const
+        {
+            BOOST_ASSERT(m_pos != 0 && "out of range");
+            return m_plst->GetAt(m_pos);
+        }
+
+        // A    B    C    D    x
+        // Head           Tail NULL(0)
+        //
+        void increment()
+        {
+            BOOST_ASSERT(m_pos != 0 && "out of range");
+            m_plst->GetNext(m_pos);
+        }
+
+        void decrement()
+        {
+            if (m_pos == 0) {
+                m_pos = m_plst->GetTailPosition();
+                return;
+            }
+
+            m_plst->GetPrev(m_pos);
+        }
+
+        bool equal(self_t const& other) const
+        {
+            BOOST_ASSERT(m_plst == other.m_plst && "iterators incompatible");
+            return m_pos == other.m_pos;
+        }
+    };
+
+
+    // customization helpers
+    //
+
+    struct array_functions
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return x.GetData();
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return begin<Iterator>(x) + x.GetSize();
+        }
+    };
+
+
+    struct list_functions
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return Iterator(x, x.GetHeadPosition());
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return Iterator(x, POSITION(0));
+        }
+    };
+
+
+} } // namespace boost::range_detail_microsoft
+
+
+
+
+// test
+//
+
+
+#if defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
+
+
+#include <algorithm>
+#include <iterator>
+#include <vector>
+#include <boost/concept_check.hpp>
+#include <boost/next_prior.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/const_iterator.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/distance.hpp>
+#include <boost/range/empty.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/mutable_iterator.hpp>
+#include <boost/range/rbegin.hpp>
+#include <boost/range/rend.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+
+namespace boost { namespace range_detail_microsoft {
+
+
+    template< class Range1, class Range2 >
+    bool test_equals(Range1 const& rng1, Range2 const& rng2)
+    {
+        return
+            boost::distance(rng1) == boost::distance(rng2) &&
+            std::equal(boost::begin(rng1), boost::end(rng1), boost::begin(rng2))
+        ;
+    }
+
+
+    template< class AssocContainer, class PairT >
+    bool test_find_key_and_mapped(AssocContainer const& ac, PairT const& pa)
+    {
+        typedef typename boost::range_const_iterator<AssocContainer>::type iter_t;
+        for (iter_t it = boost::const_begin(ac), last = boost::const_end(ac); it != last; ++it) {
+            if (it->first == pa.first && it->second == pa.second)
+                return true;
+        }
+
+        return false;
+    }
+
+
+    // test functions
+    //
+
+    template< class Range >
+    bool test_emptiness(Range& )
+    {
+        bool result = true;
+
+        Range emptyRng;
+        result = result && boost::empty(emptyRng);
+
+        return result;
+    }
+
+
+    template< class Range >
+    bool test_trivial(Range& rng)
+    {
+        bool result = true;
+
+        // convertibility check
+        typedef typename range_const_iterator<Range>::type citer_t;
+        citer_t cit = boost::begin(rng);
+        (void)cit; // unused
+
+        // mutability check
+        typedef typename range_value<Range>::type val_t;
+        val_t v = *boost::begin(rng);
+        *boost::begin(rng) = v;
+        result = result && *boost::begin(rng) == v;
+
+        return result;
+    }
+
+
+    template< class Range >
+    bool test_forward(Range& rng)
+    {
+        boost::function_requires< ForwardRangeConcept<Range> >();
+
+        bool result = (test_trivial)(rng);
+
+        typedef typename range_value<Range>::type val_t;
+
+        std::vector<val_t> saved;
+        std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
+        std::rotate(boost::begin(saved), boost::next(boost::begin(saved)), boost::end(saved));
+
+        std::rotate(boost::begin(rng), boost::next(boost::begin(rng)), boost::end(rng));
+
+        return result && (test_equals)(saved, rng);
+    };
+
+
+    template< class Range >
+    bool test_bidirectional(Range& rng)
+    {
+        boost::function_requires< BidirectionalRangeConcept<Range> >();
+
+        bool result = (test_forward)(rng);
+
+        typedef typename range_value<Range>::type val_t;
+
+        std::vector<val_t> saved;
+        std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
+
+        result = result && (test_equals)(
+            boost::make_iterator_range(boost::rbegin(saved), boost::rend(saved)),
+            boost::make_iterator_range(boost::rbegin(rng), boost::rend(rng))
+        );
+
+        return result;
+    }
+
+
+    template< class Range >
+    bool test_random_access(Range& rng)
+    {
+        boost::function_requires< RandomAccessRangeConcept<Range> >();
+
+        bool result = (test_bidirectional)(rng);
+
+        typedef typename range_value<Range>::type val_t;
+
+        std::vector<val_t> saved;
+        std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
+        std::sort(boost::begin(saved), boost::end(saved));
+
+        std::random_shuffle(boost::begin(rng), boost::end(rng));
+        std::sort(boost::begin(rng), boost::end(rng));
+        result = result && (test_equals)(rng, saved);
+
+        std::random_shuffle(boost::begin(rng), boost::end(rng));
+        std::stable_sort(boost::begin(rng), boost::end(rng));
+        result = result && (test_equals)(rng, saved);
+
+        std::random_shuffle(boost::begin(rng), boost::end(rng));
+        std::partial_sort(boost::begin(rng), boost::end(rng), boost::end(rng));
+        result = result && (test_equals)(rng, saved);
+
+        return result;
+    }
+
+
+    // initializer
+    //
+
+    template< class ArrayT, class SampleRange >
+    bool test_init_array(ArrayT& arr, SampleRange const& sample)
+    {
+        typedef typename range_const_iterator<SampleRange>::type iter_t;
+        typedef typename range_value<SampleRange>::type val_t;
+
+        for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
+            val_t v = *it; // works around ATL3 CSimpleArray
+            arr.Add(v);
+        }
+
+        return (test_equals)(arr, sample);
+    }
+
+
+    template< class ListT, class SampleRange >
+    bool test_init_list(ListT& lst, SampleRange const& sample)
+    {
+        typedef typename range_const_iterator<SampleRange>::type iter_t;
+
+        for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
+            lst.AddTail(*it);
+        }
+
+        return (test_equals)(lst, sample);
+    }
+
+
+    template< class StringT, class SampleRange >
+    bool test_init_string(StringT& str, SampleRange const& sample)
+    {
+        typedef typename range_const_iterator<SampleRange>::type iter_t;
+        typedef typename range_value<SampleRange>::type val_t;
+
+        for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
+            str += *it;
+        }
+
+        return (test_equals)(str, sample);
+    }
+
+
+    template< class MapT, class SampleMap >
+    bool test_init_map(MapT& map, SampleMap const& sample)
+    {
+        typedef typename range_const_iterator<SampleMap>::type iter_t;
+
+        for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
+            map.SetAt(it->first, it->second);
+        }
+
+        return boost::distance(map) == boost::distance(sample);
+    }
+
+
+    // metafunction test
+    //
+
+    template< class Range, class Iter >
+    struct test_mutable_iter :
+        boost::is_same< typename boost::BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>::type, Iter >
+    { };
+
+
+    template< class Range, class Iter >
+    struct test_const_iter :
+        boost::is_same< typename boost::range_const_iterator<Range>::type, Iter >
+    { };
+
+
+} } // namespace boost::range_detail_microsoft
+
+
+#endif // defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
+
+
+
+#endif
diff --git a/src/boost/range/detail/misc_concept.hpp b/src/boost/range/detail/misc_concept.hpp
new file mode 100644
index 0000000..74cb919
--- /dev/null
+++ b/src/boost/range/detail/misc_concept.hpp
@@ -0,0 +1,33 @@
+// Boost.Range library concept checks
+//
+//  Copyright Neil Groves 2009. Use, modification and distribution
+//  are subject to the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+#ifndef BOOST_RANGE_DETAIL_MISC_CONCEPT_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_MISC_CONCEPT_HPP_INCLUDED
+
+#include <boost/concept_check.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template<typename T1, typename T2>
+        class SameTypeConcept
+        {
+        public:
+            BOOST_CONCEPT_USAGE(SameTypeConcept)
+            {
+                same_type(a,b);
+            }
+        private:
+            template<typename T> void same_type(T,T) {}
+            T1 a;
+            T2 b;
+        };
+    }
+}
+
+#endif // include guard
diff --git a/src/boost/range/detail/range_return.hpp b/src/boost/range/detail/range_return.hpp
new file mode 100644
index 0000000..52a6073
--- /dev/null
+++ b/src/boost/range/detail/range_return.hpp
@@ -0,0 +1,180 @@
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_DETAIL_RANGE_RETURN_HPP_INCLUDED
+#define BOOST_RANGE_DETAIL_RANGE_RETURN_HPP_INCLUDED
+
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    enum range_return_value
+    {
+        // (*) indicates the most common values
+        return_found,       // only the found resulting iterator (*)
+        return_next,        // next(found) iterator
+        return_prior,       // prior(found) iterator
+        return_begin_found, // [begin, found) range (*)
+        return_begin_next,  // [begin, next(found)) range
+        return_begin_prior, // [begin, prior(found)) range
+        return_found_end,   // [found, end) range (*)
+        return_next_end,    // [next(found), end) range
+        return_prior_end,   // [prior(found), end) range
+        return_begin_end    // [begin, end) range
+    };
+
+    template< class SinglePassRange, range_return_value >
+    struct range_return
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
+                         SinglePassRange& rng)
+        {
+            return type(found, boost::end(rng));
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_found >
+    {
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type type;
+
+        static type pack(type found, SinglePassRange&)
+        {
+            return found;
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_next >
+    {
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type type;
+
+        static type pack(type found, SinglePassRange& rng)
+        {
+            return found == boost::end(rng)
+                ? found
+                : boost::next(found);
+        }
+    };
+
+    template< class BidirectionalRange >
+    struct range_return< BidirectionalRange, return_prior >
+    {
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type type;
+
+        static type pack(type found, BidirectionalRange& rng)
+        {
+            return found == boost::begin(rng)
+                ? found
+                : boost::prior(found);
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_begin_found >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
+                         SinglePassRange& rng)
+        {
+            return type(boost::begin(rng), found);
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_begin_next >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
+                         SinglePassRange& rng)
+        {
+            return type( boost::begin(rng), 
+                         found == boost::end(rng) ? found : boost::next(found) );
+        }
+    };
+
+    template< class BidirectionalRange >
+    struct range_return< BidirectionalRange, return_begin_prior >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type found,
+                         BidirectionalRange& rng)
+        {
+            return type( boost::begin(rng),
+                         found == boost::begin(rng) ? found : boost::prior(found) );
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_found_end >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
+                         SinglePassRange& rng)
+        {
+            return type(found, boost::end(rng));
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_next_end >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
+                         SinglePassRange& rng)
+        {
+            return type( found == boost::end(rng) ? found : boost::next(found),
+                         boost::end(rng) );
+        }
+    };
+
+    template< class BidirectionalRange >
+    struct range_return< BidirectionalRange, return_prior_end >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<BidirectionalRange>::type found,
+                         BidirectionalRange& rng)
+        {
+            return type( found == boost::begin(rng) ? found : boost::prior(found),
+                         boost::end(rng) );
+        }
+    };
+
+    template< class SinglePassRange >
+    struct range_return< SinglePassRange, return_begin_end >
+    {
+        typedef boost::iterator_range<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type > type;
+
+        static type pack(BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type found,
+                         SinglePassRange& rng)
+        {
+            return type(boost::begin(rng), boost::end(rng));
+        }
+    };
+
+}
+
+#endif // include guard
diff --git a/src/boost/range/detail/remove_extent.hpp b/src/boost/range/detail/remove_extent.hpp
new file mode 100644
index 0000000..68e4597
--- /dev/null
+++ b/src/boost/range/detail/remove_extent.hpp
@@ -0,0 +1,157 @@
+// Boost.Range library
+//
+//  Copyright Jonathan Turkanis 2005. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+
+#ifndef BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
+#define BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
+
+#include <boost/config.hpp>  // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std.
+#include <cstddef>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+namespace boost 
+{
+    namespace range_detail
+    {
+        
+        template< typename Case1 = mpl::true_,
+                  typename Type1 = mpl::void_,
+                  typename Case2 = mpl::true_,
+                  typename Type2 = mpl::void_,
+                  typename Case3 = mpl::true_,
+                  typename Type3 = mpl::void_,
+                  typename Case4 = mpl::true_,
+                  typename Type4 = mpl::void_,
+                  typename Case5 = mpl::true_,
+                  typename Type5 = mpl::void_,
+                  typename Case6 = mpl::true_,
+                  typename Type6 = mpl::void_,
+                  typename Case7 = mpl::true_,
+                  typename Type7 = mpl::void_,
+                  typename Case8 = mpl::true_,
+                  typename Type8 = mpl::void_,
+                  typename Case9 = mpl::true_,
+                  typename Type9 = mpl::void_,
+                  typename Case10 = mpl::true_,
+                  typename Type10 = mpl::void_,
+                  typename Case11 = mpl::true_,
+                  typename Type11 = mpl::void_,
+                  typename Case12 = mpl::true_,
+                  typename Type12 = mpl::void_,
+                  typename Case13 = mpl::true_,
+                  typename Type13 = mpl::void_,
+                  typename Case14 = mpl::true_,
+                  typename Type14 = mpl::void_,
+                  typename Case15 = mpl::true_,
+                  typename Type15 = mpl::void_,
+                  typename Case16 = mpl::true_,
+                  typename Type16 = mpl::void_,
+                  typename Case17 = mpl::true_,
+                  typename Type17 = mpl::void_,
+                  typename Case18 = mpl::true_,
+                  typename Type18 = mpl::void_,
+                  typename Case19 = mpl::true_,
+                  typename Type19 = mpl::void_,
+                  typename Case20 = mpl::true_,
+                  typename Type20 = mpl::void_>
+        struct select {
+            typedef typename
+                    mpl::eval_if<
+                        Case1, mpl::identity<Type1>, mpl::eval_if<
+                        Case2, mpl::identity<Type2>, mpl::eval_if<
+                        Case3, mpl::identity<Type3>, mpl::eval_if<
+                        Case4, mpl::identity<Type4>, mpl::eval_if<
+                        Case5, mpl::identity<Type5>, mpl::eval_if<
+                        Case6, mpl::identity<Type6>, mpl::eval_if<
+                        Case7, mpl::identity<Type7>, mpl::eval_if<
+                        Case8, mpl::identity<Type8>, mpl::eval_if<
+                        Case9, mpl::identity<Type9>, mpl::if_<
+                        Case10, Type10, mpl::void_ > > > > > > > > >
+                    >::type result1;
+            typedef typename
+                    mpl::eval_if<
+                        Case11, mpl::identity<Type11>, mpl::eval_if<
+                        Case12, mpl::identity<Type12>, mpl::eval_if<
+                        Case13, mpl::identity<Type13>, mpl::eval_if<
+                        Case14, mpl::identity<Type14>, mpl::eval_if<
+                        Case15, mpl::identity<Type15>, mpl::eval_if<
+                        Case16, mpl::identity<Type16>, mpl::eval_if<
+                        Case17, mpl::identity<Type17>, mpl::eval_if<
+                        Case18, mpl::identity<Type18>, mpl::eval_if<
+                        Case19, mpl::identity<Type19>, mpl::if_<
+                        Case20, Type20, mpl::void_ > > > > > > > > >
+                    > result2;
+            typedef typename    
+                    mpl::eval_if<
+                        is_same<result1, mpl::void_>,
+                        result2,
+                        mpl::identity<result1>
+                    >::type type;
+        };
+
+        template<typename T>
+        struct remove_extent {
+            static T* ar;
+            BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0]));
+
+            typedef typename
+                    select<
+                        is_same<T, bool[size]>,                  bool,
+                        is_same<T, char[size]>,                  char,
+                        is_same<T, signed char[size]>,           signed char,
+                        is_same<T, unsigned char[size]>,         unsigned char,
+                    #ifndef BOOST_NO_INTRINSIC_WCHAR_T
+                        is_same<T, wchar_t[size]>,               wchar_t,
+                    #endif
+                        is_same<T, short[size]>,                 short,
+                        is_same<T, unsigned short[size]>,        unsigned short,
+                        is_same<T, int[size]>,                   int,
+                        is_same<T, unsigned int[size]>,          unsigned int,
+                        is_same<T, long[size]>,                  long,
+                        is_same<T, unsigned long[size]>,         unsigned long,
+                        is_same<T, float[size]>,                 float,
+                        is_same<T, double[size]>,                double,
+                        is_same<T, long double[size]>,           long double
+                    >::type result1;
+            typedef typename
+                    select<
+                        is_same<T, const bool[size]>,            const bool,
+                        is_same<T, const char[size]>,            const char,
+                        is_same<T, const signed char[size]>,     const signed char,
+                        is_same<T, const unsigned char[size]>,   const unsigned char,
+                    #ifndef BOOST_NO_INTRINSIC_WCHAR_T
+                        is_same<T, const wchar_t[size]>,         const wchar_t,
+                    #endif
+                        is_same<T, const short[size]>,           const short,
+                        is_same<T, const unsigned short[size]>,  const unsigned short,
+                        is_same<T, const int[size]>,             const int,
+                        is_same<T, const unsigned int[size]>,    const unsigned int,
+                        is_same<T, const long[size]>,            const long,
+                        is_same<T, const unsigned long[size]>,   const unsigned long,
+                        is_same<T, const float[size]>,           const float,
+                        is_same<T, const double[size]>,          const double,
+                        is_same<T, const long double[size]>,     const long double
+                    > result2;
+            typedef typename
+                    mpl::eval_if<
+                        is_same<result1, mpl::void_>,
+                        result2,
+                        mpl::identity<result1>
+                    >::type type;
+        };
+
+    } // namespace 'range_detail'
+
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/detail/safe_bool.hpp b/src/boost/range/detail/safe_bool.hpp
new file mode 100644
index 0000000..182e510
--- /dev/null
+++ b/src/boost/range/detail/safe_bool.hpp
@@ -0,0 +1,72 @@
+//  This header intentionally has no include guards.
+//
+//  Copyright (c) 2010 Neil Groves
+//  Distributed under the Boost Software License, Version 1.0.
+//  See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt
+//
+// This code utilises the experience gained during the evolution of
+// <boost/smart_ptr/operator_bool.hpp>
+#ifndef BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
+#define BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
+
+#include <boost/config.hpp>
+#include <boost/range/config.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+
+template<class DataMemberPtr>
+class safe_bool
+{
+public:
+    typedef safe_bool this_type;
+
+#if (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570)) || defined(__CINT_)
+    typedef bool unspecified_bool_type;
+    static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
+    {
+        return x;
+    }
+#elif defined(_MANAGED)
+    static void unspecified_bool(this_type***)
+    {
+    }
+    typedef void(*unspecified_bool_type)(this_type***);
+    static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
+    {
+        return x ? unspecified_bool : 0;
+    }
+#elif \
+    ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
+    ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
+    ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
+
+    typedef bool (this_type::*unspecified_bool_type)() const;
+
+    static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
+    {
+        return x ? &this_type::detail_safe_bool_member_fn : 0;
+    }
+private:
+    bool detail_safe_bool_member_fn() const { return false; }
+#else
+    typedef DataMemberPtr unspecified_bool_type;
+    static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr p)
+    {
+        return x ? p : 0;
+    }
+#endif
+private:
+    safe_bool();
+    safe_bool(const safe_bool&);
+    void operator=(const safe_bool&);
+    ~safe_bool();
+};
+
+    } // namespace range_detail
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/detail/sfinae.hpp b/src/boost/range/detail/sfinae.hpp
new file mode 100644
index 0000000..5b2c61e
--- /dev/null
+++ b/src/boost/range/detail/sfinae.hpp
@@ -0,0 +1,77 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_SFINAE_HPP
+#define BOOST_RANGE_DETAIL_SFINAE_HPP
+
+#include <boost/range/config.hpp>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/detail/yes_no_type.hpp>
+#include <utility>
+
+
+namespace boost 
+{
+    namespace range_detail
+    {          
+        using type_traits::yes_type;
+        using type_traits::no_type;
+
+        //////////////////////////////////////////////////////////////////////
+        // string
+        //////////////////////////////////////////////////////////////////////
+        
+        yes_type is_string_impl( const char* const );
+        yes_type is_string_impl( const wchar_t* const );
+        no_type  is_string_impl( ... );
+        
+        template< std::size_t sz >
+        yes_type is_char_array_impl( char BOOST_RANGE_ARRAY_REF()[sz] );
+        template< std::size_t sz >
+        yes_type is_char_array_impl( const char BOOST_RANGE_ARRAY_REF()[sz] );
+        no_type  is_char_array_impl( ... );
+        
+        template< std::size_t sz >
+        yes_type is_wchar_t_array_impl( wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
+        template< std::size_t sz >
+        yes_type is_wchar_t_array_impl( const wchar_t BOOST_RANGE_ARRAY_REF()[sz] );
+        no_type  is_wchar_t_array_impl( ... );
+                                     
+        yes_type is_char_ptr_impl( char* const );
+        no_type  is_char_ptr_impl( ... );
+        
+        yes_type is_const_char_ptr_impl( const char* const );
+        no_type  is_const_char_ptr_impl( ... );
+
+        yes_type is_wchar_t_ptr_impl( wchar_t* const );
+        no_type  is_wchar_t_ptr_impl( ... );
+        
+        yes_type is_const_wchar_t_ptr_impl( const wchar_t* const );
+        no_type  is_const_wchar_t_ptr_impl( ... );
+        
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+
+        template< typename Iterator >
+        yes_type is_pair_impl( const std::pair<Iterator,Iterator>* );
+        no_type  is_pair_impl( ... );
+
+        //////////////////////////////////////////////////////////////////////
+        // tags
+        //////////////////////////////////////////////////////////////////////
+
+        struct char_or_wchar_t_array_tag {};
+        
+    } // namespace 'range_detail'
+    
+} // namespace 'boost'
+
+#endif
diff --git a/src/boost/range/detail/size.hpp b/src/boost/range/detail/size.hpp
new file mode 100644
index 0000000..fe52ba0
--- /dev/null
+++ b/src/boost/range/detail/size.hpp
@@ -0,0 +1,159 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+
+#ifndef BOOST_RANGE_DETAIL_SIZE_HPP
+#define BOOST_RANGE_DETAIL_SIZE_HPP
+
+#include <boost/config.hpp> // BOOST_MSVC
+#include <boost/detail/workaround.hpp>
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+# include <boost/range/detail/vc6/size.hpp>
+#else
+# include <boost/range/detail/implementation_help.hpp>
+# include <boost/range/detail/size_type.hpp>
+# include <boost/range/detail/common.hpp>
+# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
+#  include <boost/range/detail/remove_extent.hpp>
+# endif
+# include <iterator>
+
+namespace boost 
+{
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_size_;
+
+        //////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_size_<std_container_>
+        {
+            template< typename C >
+            static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
+            {
+                return c.size();
+            };
+        };
+                    
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_size_<std_pair_>
+        {
+            template< typename P >
+            static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type 
+            fun( const P& p )
+            {
+                return std::distance( p.first, p.second );
+            }
+        };
+ 
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_size_<array_>
+        {
+        #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+            template< typename T, std::size_t sz >
+            static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return sz;
+            }
+        #else
+            template<typename T>
+            static std::size_t fun(T& t)
+            {
+                return remove_extent<T>::size;
+            }
+        #endif
+        };
+        
+        template<>
+        struct range_size_<char_array_>
+        {
+            template< typename T, std::size_t sz >
+            static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return boost::range_detail::array_size( boost_range_array );
+            }
+        };
+        
+        template<>
+        struct range_size_<wchar_t_array_>
+        {
+            template< typename T, std::size_t sz >
+            static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
+            {
+                return boost::range_detail::array_size( boost_range_array );
+            }
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // string
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_size_<char_ptr_>
+        {
+            static std::size_t fun( const char* s )
+            {
+                return boost::range_detail::str_size( s );
+            }
+        };
+
+        template<>
+        struct range_size_<const_char_ptr_>
+        {
+            static std::size_t fun( const char* s )
+            {
+                return boost::range_detail::str_size( s );
+            }
+        };
+        
+        template<>
+        struct range_size_<wchar_t_ptr_>
+        {
+            static std::size_t fun( const wchar_t* s )
+            {
+                return boost::range_detail::str_size( s );
+            }
+        };
+
+        template<>
+        struct range_size_<const_wchar_t_ptr_>
+        {
+            static std::size_t fun( const wchar_t* s )
+            {
+                return boost::range_detail::str_size( s );
+            }
+        };
+  
+    } // namespace 'range_detail'
+    
+
+    template< typename C >
+    BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type 
+    size( const C& c )
+    {
+        return range_detail::range_size_<  BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
+    }
+    
+} // namespace 'boost'
+
+# endif
+#endif
diff --git a/src/boost/range/detail/size_type.hpp b/src/boost/range/detail/size_type.hpp
new file mode 100644
index 0000000..78a60a4
--- /dev/null
+++ b/src/boost/range/detail/size_type.hpp
@@ -0,0 +1,55 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_SIZE_TYPE_HPP
+#define BOOST_RANGE_DETAIL_SIZE_TYPE_HPP
+
+#include <boost/range/detail/common.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+// missing partial specialization  workaround.
+//////////////////////////////////////////////////////////////////////////////
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_size_type_
+        {
+            template< typename C >
+            struct pts
+            {
+                typedef std::size_t type;
+            };
+        };
+
+        template<>
+        struct range_size_type_<std_container_>
+        {
+            template< typename C >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME C::size_type type;
+            };
+        };
+    }
+
+    template< typename C >
+    class range_size
+    {
+        typedef typename range_detail::range<C>::type c_type;
+    public:
+        typedef typename range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
+    };
+}
+
+#endif
+
diff --git a/src/boost/range/detail/sizer.hpp b/src/boost/range/detail/sizer.hpp
new file mode 100644
index 0000000..b4c1c91
--- /dev/null
+++ b/src/boost/range/detail/sizer.hpp
@@ -0,0 +1,35 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_SIZER_HPP
+#define BOOST_RANGE_DETAIL_SIZER_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <cstddef>
+
+namespace boost 
+{
+    //////////////////////////////////////////////////////////////////////
+    // constant array size
+    //////////////////////////////////////////////////////////////////////
+    
+    template< typename T, std::size_t sz >
+    char (& sizer( const T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz];
+    
+    template< typename T, std::size_t sz >
+    char (& sizer( T BOOST_RANGE_ARRAY_REF()[sz] ) )[sz];
+
+} // namespace 'boost'
+
+#endif
diff --git a/src/boost/range/detail/str_types.hpp b/src/boost/range/detail/str_types.hpp
new file mode 100644
index 0000000..f8cab19
--- /dev/null
+++ b/src/boost/range/detail/str_types.hpp
@@ -0,0 +1,38 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_STR_TYPES_HPP
+#define BOOST_RANGE_DETAIL_STR_TYPES_HPP
+
+#include <boost/range/size_type.hpp>
+#include <boost/range/iterator.hpp>
+
+namespace boost
+{
+    template< class T >
+    struct range_mutable_iterator<T*>
+    {
+        typedef T* type;
+    };
+
+    template< class T >
+    struct range_const_iterator<T*>
+    {
+        typedef const T* type;
+    };
+
+    template< class T >
+    struct range_size<T*>
+    {
+       typedef std::size_t type;
+    };    
+}
+
+#endif
diff --git a/src/boost/range/detail/value_type.hpp b/src/boost/range/detail/value_type.hpp
new file mode 100644
index 0000000..2784514
--- /dev/null
+++ b/src/boost/range/detail/value_type.hpp
@@ -0,0 +1,72 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
+#define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
+
+#include <boost/range/detail/common.hpp>
+#include <boost/range/detail/remove_extent.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+// missing partial specialization  workaround.
+//////////////////////////////////////////////////////////////////////////////
+
+namespace boost 
+{
+    namespace range_detail 
+    {        
+        template< typename T >
+        struct range_value_type_;
+
+        template<>
+        struct range_value_type_<std_container_>
+        {
+            template< typename C >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME C::value_type type;
+            };
+        };
+
+        template<>
+        struct range_value_type_<std_pair_>
+        {
+            template< typename P >
+            struct pts
+            {
+                typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
+            };
+        };
+
+        template<>
+        struct range_value_type_<array_>
+        { 
+            template< typename T >
+            struct pts
+            {
+                typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
+            };
+        };
+        
+    } 
+    
+    template< typename C >
+    class range_value
+    {
+        typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
+    public:
+        typedef BOOST_DEDUCED_TYPENAME range_detail::range_value_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; 
+    };
+
+}
+
+#endif
+
diff --git a/src/boost/range/detail/vc6/end.hpp b/src/boost/range/detail/vc6/end.hpp
new file mode 100644
index 0000000..4f76af5
--- /dev/null
+++ b/src/boost/range/detail/vc6/end.hpp
@@ -0,0 +1,170 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DETAIL_VC6_END_HPP
+#define BOOST_RANGE_DETAIL_VC6_END_HPP
+
+#include <boost/range/detail/implementation_help.hpp>
+#include <boost/range/detail/implementation_help.hpp>
+#include <boost/range/result_iterator.hpp>
+#include <boost/range/detail/common.hpp>
+#include <boost/range/detail/remove_extent.hpp>
+
+namespace boost 
+{
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_end;
+
+        //////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_end<std_container_>
+        {
+            template< typename C >
+            struct inner {
+                static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type 
+                fun( C& c )
+                {
+                    return c.end();
+                };
+            };
+        };
+                    
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_end<std_pair_>
+        {
+            template< typename P >
+            struct inner {
+                static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type 
+                fun( const P& p )
+                {
+                    return p.second;
+                }
+            };
+        };
+ 
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_end<array_>  
+        {
+            template< typename T >
+            struct inner {
+                static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
+                fun(T& t)
+                {
+                    return t + remove_extent<T>::size;
+                }
+            };
+        };
+
+                
+        template<>
+        struct range_end<char_array_>
+        {
+            template< typename T >
+            struct inner {
+                static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
+                fun(T& t)
+                {
+                    return t + remove_extent<T>::size;
+                }
+            };
+        };
+        
+        template<>
+        struct range_end<wchar_t_array_>
+        {
+            template< typename T >
+            struct inner {
+                static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
+                fun(T& t)
+                {
+                    return t + remove_extent<T>::size;
+                }
+            };
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // string
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_end<char_ptr_>
+        {
+            template< typename T >
+            struct inner {
+                static char* fun( char* s )
+                {
+                    return boost::range_detail::str_end( s );
+                }
+            };
+        };
+
+        template<>
+        struct range_end<const_char_ptr_>
+        {
+            template< typename T >
+            struct inner {
+                static const char* fun( const char* s )
+                {
+                    return boost::range_detail::str_end( s );
+                }
+            };
+        };
+
+        template<>
+        struct range_end<wchar_t_ptr_>
+        {
+            template< typename T >
+            struct inner {
+                static wchar_t* fun( wchar_t* s )
+                {
+                    return boost::range_detail::str_end( s );
+                }
+            };
+        };
+
+
+        template<>
+        struct range_end<const_wchar_t_ptr_>
+        {
+            template< typename T >
+            struct inner {
+                static const wchar_t* fun( const wchar_t* s )
+                {
+                    return boost::range_detail::str_end( s );
+                }
+            };
+        };
+        
+    } // namespace 'range_detail'
+    
+    template< typename C >
+    inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type 
+    end( C& c )
+    {
+        return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c );
+    }
+    
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/detail/vc6/size.hpp b/src/boost/range/detail/vc6/size.hpp
new file mode 100644
index 0000000..39f559f
--- /dev/null
+++ b/src/boost/range/detail/vc6/size.hpp
@@ -0,0 +1,166 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+
+#ifndef BOOST_RANGE_DETAIL_VC6_SIZE_HPP
+#define BOOST_RANGE_DETAIL_VC6_SIZE_HPP
+
+#include <boost/range/detail/implementation_help.hpp>
+#include <boost/range/detail/size_type.hpp>
+#include <boost/range/detail/common.hpp>
+#include <boost/range/detail/remove_extent.hpp>
+#include <iterator>
+
+namespace boost 
+{
+    namespace range_detail
+    {
+        template< typename T >
+        struct range_size_;
+
+        //////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_size_<std_container_>
+        {
+            template< typename C >
+            struct inner {
+                static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
+                {
+                    return c.size();
+                };
+            };
+        };
+                    
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+        
+        template<>
+        struct range_size_<std_pair_>
+        {
+            template< typename P >
+            struct inner {
+                static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type 
+                fun( const P& p )
+                {
+                    return std::distance( p.first, p.second );
+                }
+            };
+        };
+ 
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_size_<array_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun(T& t)
+                {
+                    return remove_extent<T>::size;
+                }
+            };
+        };
+        
+        template<>
+        struct range_size_<char_array_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun(T& t)
+                {
+                    return sizeof(T) / sizeof(T[0]);
+                }
+            };
+        };
+        
+        template<>
+        struct range_size_<wchar_t_array_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun(T& t)
+                {
+                    return sizeof(T) / sizeof(T[0]);
+                }
+            };
+        };
+
+        //////////////////////////////////////////////////////////////////////
+        // string
+        //////////////////////////////////////////////////////////////////////
+
+        template<>
+        struct range_size_<char_ptr_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun( const char* s )
+                {
+                    return boost::range_detail::str_size( s );
+                }
+            };
+        };
+
+        template<>
+        struct range_size_<const_char_ptr_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun( const char* s )
+                {
+                    return boost::range_detail::str_size( s );
+                }
+            };
+        };
+        
+        template<>
+        struct range_size_<wchar_t_ptr_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun( const wchar_t* s )
+                {
+                    return boost::range_detail::str_size( s );
+                }
+            };
+        };
+
+        template<>
+        struct range_size_<const_wchar_t_ptr_>
+        {
+            template<typename T>
+            struct inner {
+                static std::size_t fun( const wchar_t* s )
+                {
+                    return boost::range_detail::str_size( s );
+                }
+            };
+        };
+  
+    } // namespace 'range_detail'
+    
+
+    template< typename C >
+    BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type 
+    size( const C& c )
+    {
+        return range_detail::range_size_<range_detail::range<C>::type>::inner<C>::fun( c );
+    }
+    
+} // namespace 'boost'
+
+
+#endif
diff --git a/src/boost/range/difference_type.hpp b/src/boost/range/difference_type.hpp
new file mode 100644
index 0000000..164288f
--- /dev/null
+++ b/src/boost/range/difference_type.hpp
@@ -0,0 +1,29 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DIFFERENCE_TYPE_HPP
+#define BOOST_RANGE_DIFFERENCE_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace boost
+{
+    template< class T >
+    struct range_difference : iterator_difference< typename range_iterator<T>::type >
+    { };
+}
+
+#endif
diff --git a/src/boost/range/distance.hpp b/src/boost/range/distance.hpp
new file mode 100644
index 0000000..42a106d
--- /dev/null
+++ b/src/boost/range/distance.hpp
@@ -0,0 +1,34 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_DISTANCE_HPP
+#define BOOST_RANGE_DISTANCE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/difference_type.hpp>
+
+namespace boost 
+{
+
+    template< class T >
+    inline BOOST_DEDUCED_TYPENAME range_difference<T>::type 
+    distance( const T& r )
+    {
+        return std::distance( boost::begin( r ), boost::end( r ) );
+    }
+
+} // namespace 'boost'
+
+#endif
diff --git a/src/boost/range/empty.hpp b/src/boost/range/empty.hpp
new file mode 100644
index 0000000..78c4e85
--- /dev/null
+++ b/src/boost/range/empty.hpp
@@ -0,0 +1,34 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_EMPTY_HPP
+#define BOOST_RANGE_EMPTY_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+
+namespace boost 
+{ 
+
+    template< class T >
+    inline bool empty( const T& r )
+    {
+        return boost::begin( r ) == boost::end( r );
+    }
+
+} // namepace 'boost'
+
+
+#endif
diff --git a/src/boost/range/end.hpp b/src/boost/range/end.hpp
new file mode 100644
index 0000000..d5e6526
--- /dev/null
+++ b/src/boost/range/end.hpp
@@ -0,0 +1,136 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_END_HPP
+#define BOOST_RANGE_END_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+#include <boost/range/detail/end.hpp>
+#else
+
+#include <boost/range/detail/implementation_help.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/const_iterator.hpp>
+
+namespace boost
+{
+
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+namespace range_detail
+{
+#endif
+
+        //////////////////////////////////////////////////////////////////////
+        // primary template
+        //////////////////////////////////////////////////////////////////////
+        template< typename C >
+        inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
+        range_end( C& c )
+        {
+            //
+            // If you get a compile-error here, it is most likely because
+            // you have not implemented range_begin() properly in
+            // the namespace of C
+            //
+            return c.end();
+        }
+
+        //////////////////////////////////////////////////////////////////////
+        // pair
+        //////////////////////////////////////////////////////////////////////
+
+        template< typename Iterator >
+        inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
+        {
+            return p.second;
+        }
+
+        template< typename Iterator >
+        inline Iterator range_end( std::pair<Iterator,Iterator>& p )
+        {
+            return p.second;
+        }
+
+        //////////////////////////////////////////////////////////////////////
+        // array
+        //////////////////////////////////////////////////////////////////////
+
+        template< typename T, std::size_t sz >
+        inline const T* range_end( const T (&a)[sz] )
+        {
+            return range_detail::array_end<T,sz>( a );
+        }
+
+        template< typename T, std::size_t sz >
+        inline T* range_end( T (&a)[sz] )
+        {
+            return range_detail::array_end<T,sz>( a );
+        }
+
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+} // namespace 'range_detail'
+#endif
+
+namespace range_adl_barrier
+{
+
+template< class T >
+inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
+{
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+    using namespace range_detail;
+#endif
+    return range_end( r );
+}
+
+template< class T >
+inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
+{
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+    using namespace range_detail;
+#endif
+    return range_end( r );
+}
+
+    } // namespace range_adl_barrier
+} // namespace 'boost'
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+namespace boost
+{
+    namespace range_adl_barrier
+    {
+        template< class T >
+        inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
+        const_end( const T& r )
+        {
+            return boost::range_adl_barrier::end( r );
+        }
+    } // namespace range_adl_barrier
+    using namespace range_adl_barrier;
+} // namespace boost
+
+#endif
+
diff --git a/src/boost/range/functions.hpp b/src/boost/range/functions.hpp
new file mode 100644
index 0000000..b8b8608
--- /dev/null
+++ b/src/boost/range/functions.hpp
@@ -0,0 +1,27 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_FUNCTIONS_HPP
+#define BOOST_RANGE_FUNCTIONS_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/size.hpp>
+#include <boost/range/distance.hpp>
+#include <boost/range/empty.hpp>
+#include <boost/range/rbegin.hpp>
+#include <boost/range/rend.hpp>
+
+#endif
+
diff --git a/src/boost/range/has_range_iterator.hpp b/src/boost/range/has_range_iterator.hpp
new file mode 100644
index 0000000..8046eb4
--- /dev/null
+++ b/src/boost/range/has_range_iterator.hpp
@@ -0,0 +1,62 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_HAS_ITERATOR_HPP_INCLUDED
+#define BOOST_RANGE_HAS_ITERATOR_HPP_INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/has_xxx.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/utility/enable_if.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        BOOST_MPL_HAS_XXX_TRAIT_DEF(type)
+
+        template<class T, class Enabler = void>
+        struct has_range_iterator_impl
+            : boost::mpl::false_
+        {
+        };
+
+        template<class T>
+        struct has_range_iterator_impl<T, BOOST_DEDUCED_TYPENAME enable_if< has_type< range_mutable_iterator<T> > >::type>
+            : boost::mpl::true_
+        {
+        };
+
+        template<class T, class Enabler = void>
+        struct has_range_const_iterator_impl
+            : boost::mpl::false_
+        {
+        };
+
+        template<class T>
+        struct has_range_const_iterator_impl<T, BOOST_DEDUCED_TYPENAME enable_if< has_type< range_const_iterator<T> > >::type>
+            : boost::mpl::true_
+        {
+        };
+
+    } // namespace range_detail
+
+    template<class T>
+    struct has_range_iterator
+        : range_detail::has_range_iterator_impl<T>
+    {};
+
+    template<class T>
+    struct has_range_const_iterator
+        : range_detail::has_range_const_iterator_impl<T>
+    {};
+} // namespace boost
+
+#endif // include guard
+
diff --git a/src/boost/range/irange.hpp b/src/boost/range/irange.hpp
new file mode 100644
index 0000000..3b5a6cc
--- /dev/null
+++ b/src/boost/range/irange.hpp
@@ -0,0 +1,230 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_IRANGE_HPP_INCLUDED
+#define BOOST_RANGE_IRANGE_HPP_INCLUDED
+
+#include <boost/assert.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        // integer_iterator is an iterator over an integer sequence that
+        // is bounded only by the limits of the underlying integer
+        // representation.
+        //
+        // This is useful for implementing the irange(first, last)
+        // function.
+        //
+        // Note:
+        // This use of this iterator and irange is appreciably less
+        // performant than the corresponding hand-written integer
+        // loop on many compilers.
+        template<typename Integer>
+        class integer_iterator
+            : public boost::iterator_facade<
+                        integer_iterator<Integer>,
+                        Integer,
+                        boost::random_access_traversal_tag,
+                        Integer,
+                        std::ptrdiff_t
+                    >
+        {
+            typedef boost::iterator_facade<
+                        integer_iterator<Integer>,
+                        Integer,
+                        boost::random_access_traversal_tag,
+                        Integer,
+                        std::ptrdiff_t
+                    > base_t;
+        public:
+            typedef typename base_t::value_type value_type;
+            typedef typename base_t::difference_type difference_type;
+            typedef typename base_t::reference reference;
+
+            integer_iterator() : m_value() {}
+            explicit integer_iterator(value_type x) : m_value(x) {}
+
+        private:
+            void increment()
+            {
+                ++m_value;
+            }
+
+            void decrement()
+            {
+                --m_value;
+            }
+
+            void advance(difference_type offset)
+            {
+                m_value += offset;
+            }
+
+            difference_type distance_to(const integer_iterator& other) const
+            {
+                return other.m_value - m_value;
+            }
+
+            bool equal(const integer_iterator& other) const
+            {
+                return m_value == other.m_value;
+            }
+
+            reference dereference() const
+            {
+                return m_value;
+            }
+
+            friend class ::boost::iterator_core_access;
+            value_type m_value;
+        };
+
+        // integer_iterator_with_step is similar in nature to the
+        // integer_iterator but provides the ability to 'move' in
+        // a number of steps specified at construction time.
+        //
+        // The three variable implementation provides the best guarantees
+        // of loop termination upon various combinations of input.
+        //
+        // While this design is less performant than some less
+        // safe alternatives, the use of ranges and iterators to
+        // perform counting will never be optimal anyhow, hence
+        // if optimal performance is desired a handcoded loop
+        // is the solution.
+        template<typename Integer>
+        class integer_iterator_with_step
+            : public boost::iterator_facade<
+                        integer_iterator_with_step<Integer>,
+                        Integer,
+                        boost::random_access_traversal_tag,
+                        Integer,
+                        std::ptrdiff_t
+                    >
+        {
+            typedef boost::iterator_facade<
+                        integer_iterator_with_step<Integer>,
+                        Integer,
+                        boost::random_access_traversal_tag,
+                        Integer,
+                        std::ptrdiff_t
+                    > base_t;
+        public:
+            typedef typename base_t::value_type value_type;
+            typedef typename base_t::difference_type difference_type;
+            typedef typename base_t::reference reference;
+
+            integer_iterator_with_step(value_type first, difference_type step, value_type step_size)
+                : m_first(first)
+                , m_step(step)
+                , m_step_size(step_size)
+            {
+            }
+
+        private:
+            void increment()
+            {
+                ++m_step;
+            }
+
+            void decrement()
+            {
+                --m_step;
+            }
+
+            void advance(difference_type offset)
+            {
+                m_step += offset;
+            }
+
+            difference_type distance_to(const integer_iterator_with_step& other) const
+            {
+                return other.m_step - m_step;
+            }
+
+            bool equal(const integer_iterator_with_step& other) const
+            {
+                return m_step == other.m_step;
+            }
+
+            reference dereference() const
+            {
+                return m_first + (m_step * m_step_size);
+            }
+
+            friend class ::boost::iterator_core_access;
+            value_type m_first;
+            value_type m_step;
+            difference_type m_step_size;
+        };
+
+    } // namespace range_detail
+
+    template<typename Integer>
+    class integer_range
+        : public iterator_range< range_detail::integer_iterator<Integer> >
+    {
+        typedef range_detail::integer_iterator<Integer> iterator_t;
+        typedef iterator_range<iterator_t> base_t;
+    public:
+        integer_range(Integer first, Integer last)
+            : base_t(iterator_t(first), iterator_t(last))
+        {
+        }
+    };
+
+    template<typename Integer>
+    class strided_integer_range
+    : public iterator_range< range_detail::integer_iterator_with_step<Integer> >
+    {
+        typedef range_detail::integer_iterator_with_step<Integer> iterator_t;
+        typedef iterator_range<iterator_t> base_t;
+    public:
+        template<typename Iterator>
+        strided_integer_range(Iterator first, Iterator last)
+            : base_t(first, last)
+        {
+        }
+    };
+
+    template<typename Integer>
+    integer_range<Integer>
+    irange(Integer first, Integer last)
+    {
+        BOOST_ASSERT( first <= last );
+        return integer_range<Integer>(first, last);
+    }
+
+    template<typename Integer, typename StepSize>
+    strided_integer_range<Integer>
+        irange(Integer first, Integer last, StepSize step_size)
+    {
+        BOOST_ASSERT( step_size != 0 );
+        BOOST_ASSERT( (step_size > 0) ? (last >= first) : (last <= first) );
+        
+        typedef typename range_detail::integer_iterator_with_step<Integer> iterator_t;
+
+        const std::ptrdiff_t sz = static_cast<std::ptrdiff_t>(step_size >= 0 ? step_size : -step_size);
+        const Integer l = step_size >= 0 ? last : first;
+        const Integer f = step_size >= 0 ? first : last;
+        const std::ptrdiff_t num_steps = (l + ((l-f) % sz) - f) / sz;
+        BOOST_ASSERT(num_steps >= 0);
+       
+        return strided_integer_range<Integer>(
+            iterator_t(first, 0, step_size),
+            iterator_t(first, num_steps, step_size));
+    }
+
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/istream_range.hpp b/src/boost/range/istream_range.hpp
new file mode 100644
index 0000000..c3f2248
--- /dev/null
+++ b/src/boost/range/istream_range.hpp
@@ -0,0 +1,37 @@
+//  Copyright Neil Groves 2010. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ISTREAM_RANGE_HPP_INCLUDED
+#define BOOST_RANGE_ISTREAM_RANGE_HPP_INCLUDED
+
+/*!
+ * \file istream_range.hpp
+ */
+
+#include <iterator>
+#include <istream>
+#include <boost/config.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    namespace range
+    {
+        template<class Type, class Elem, class Traits> inline
+            iterator_range<std::istream_iterator<Type, Elem, Traits> >
+        istream_range(std::basic_istream<Elem, Traits>& in)
+        {
+            return iterator_range<std::istream_iterator<Type, Elem, Traits> >(
+                std::istream_iterator<Type>(in),
+                std::istream_iterator<Type>());
+        }
+    } // namespace range
+    using range::istream_range;
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/iterator.hpp b/src/boost/range/iterator.hpp
new file mode 100644
index 0000000..ec73ddc
--- /dev/null
+++ b/src/boost/range/iterator.hpp
@@ -0,0 +1,72 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_ITERATOR_HPP
+#define BOOST_RANGE_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/mutable_iterator.hpp>
+#include <boost/range/const_iterator.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/mpl/eval_if.hpp>
+
+namespace boost
+{
+
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
+
+    namespace range_detail_vc7_1
+    {
+       template< typename C, typename Sig = void(C) >
+       struct range_iterator
+       {
+           typedef BOOST_RANGE_DEDUCED_TYPENAME
+               mpl::eval_if_c< is_const<C>::value,
+                               range_const_iterator< typename remove_const<C>::type >,
+                               range_mutable_iterator<C> >::type type;
+       };
+
+       template< typename C, typename T >
+       struct range_iterator< C, void(T[]) >
+       {
+           typedef T* type;
+       };
+    }
+
+#endif
+
+    template< typename C >
+    struct range_iterator
+    {
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
+
+        typedef BOOST_RANGE_DEDUCED_TYPENAME
+               range_detail_vc7_1::range_iterator<C>::type type;
+
+#else
+
+        typedef BOOST_RANGE_DEDUCED_TYPENAME
+            mpl::eval_if_c< is_const<C>::value,
+                            range_const_iterator< typename remove_const<C>::type >,
+                            range_mutable_iterator<C> >::type type;
+
+#endif
+    };
+
+} // namespace boost
+
+//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#endif
diff --git a/src/boost/range/iterator_range.hpp b/src/boost/range/iterator_range.hpp
new file mode 100644
index 0000000..dfcd4d2
--- /dev/null
+++ b/src/boost/range/iterator_range.hpp
@@ -0,0 +1,16 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009.
+//  Use, modification and distribution is subject to the Boost Software
+//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP_INCLUDED
+#define BOOST_RANGE_ITERATOR_RANGE_HPP_INCLUDED
+
+#include "boost/range/iterator_range_core.hpp"
+#include "boost/range/iterator_range_io.hpp"
+
+#endif // include guard
diff --git a/src/boost/range/iterator_range_core.hpp b/src/boost/range/iterator_range_core.hpp
new file mode 100644
index 0000000..60c7670
--- /dev/null
+++ b/src/boost/range/iterator_range_core.hpp
@@ -0,0 +1,650 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves & Thorsten Ottosen & Pavol Droba 2003-2004.
+//  Use, modification and distribution is subject to the Boost Software
+//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED
+#define BOOST_RANGE_ITERATOR_RANGE_CORE_HPP_INCLUDED
+
+#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+    #pragma warning( push )
+    #pragma warning( disable : 4996 )
+#endif
+
+#include <boost/assert.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/type_traits/is_abstract.hpp>
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/range/functions.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/algorithm/equal.hpp>
+#include <boost/range/detail/safe_bool.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <iterator>
+#include <algorithm>
+#include <cstddef>
+
+/*! \file
+    Defines the \c iterator_class and related functions.
+    \c iterator_range is a simple wrapper of iterator pair idiom. It provides
+    a rich subset of Container interface.
+*/
+
+
+namespace boost
+{
+    namespace iterator_range_detail
+    {
+        //
+        // The functions adl_begin and adl_end are implemented in a separate
+        // class for gcc-2.9x
+        //
+        template<class IteratorT>
+        struct iterator_range_impl {
+            template< class ForwardRange >
+            static IteratorT adl_begin( ForwardRange& r )
+            {
+                return static_cast<IteratorT>( boost::begin( r ) );
+            }
+
+            template< class ForwardRange >
+            static IteratorT adl_end( ForwardRange& r )
+            {
+                return static_cast<IteratorT>( boost::end( r ) );
+            }
+        };
+
+        template< class Left, class Right >
+        inline bool less_than( const Left& l, const Right& r )
+        {
+            return std::lexicographical_compare( boost::begin(l),
+                                                 boost::end(l),
+                                                 boost::begin(r),
+                                                 boost::end(r) );
+        }
+        
+        template< class Left, class Right >
+        inline bool greater_than( const Left& l, const Right& r )
+        {
+            return less_than(r,l);
+        }
+        
+        template< class Left, class Right >
+        inline bool less_or_equal_than( const Left& l, const Right& r )
+        {
+            return !iterator_range_detail::less_than(r,l);
+        }
+        
+        template< class Left, class Right >
+        inline bool greater_or_equal_than( const Left& l, const Right& r )
+        {
+            return !iterator_range_detail::less_than(l,r);
+        }
+
+        // This version is maintained since it is used in other boost libraries
+        // such as Boost.Assign
+        template< class Left, class Right >
+        inline bool equal(const Left& l, const Right& r)
+        {
+            return boost::equal(l, r);
+        }
+
+        struct range_tag { };
+        struct const_range_tag { };
+    }
+
+//  iterator range template class -----------------------------------------//
+
+        //! iterator_range class
+        /*!
+            An \c iterator_range delimits a range in a sequence by beginning and ending iterators.
+            An iterator_range can be passed to an algorithm which requires a sequence as an input.
+            For example, the \c toupper() function may be used most frequently on strings,
+            but can also be used on iterator_ranges:
+
+            \code
+                boost::tolower( find( s, "UPPERCASE STRING" ) );
+            \endcode
+
+            Many algorithms working with sequences take a pair of iterators,
+            delimiting a working range, as an arguments. The \c iterator_range class is an
+            encapsulation of a range identified by a pair of iterators.
+            It provides a collection interface,
+            so it is possible to pass an instance to an algorithm requiring a collection as an input.
+        */
+        template<class IteratorT>
+        class iterator_range
+        {
+            typedef range_detail::safe_bool< IteratorT iterator_range<IteratorT>::* > safe_bool_t;
+        protected: // Used by sub_range
+            //! implementation class
+            typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
+        public:
+            //! this type
+            typedef iterator_range<IteratorT> type;
+            typedef BOOST_DEDUCED_TYPENAME safe_bool_t::unspecified_bool_type unspecified_bool_type;
+            //BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
+
+            //! Encapsulated value type
+            typedef BOOST_DEDUCED_TYPENAME
+                iterator_value<IteratorT>::type value_type;
+
+            //! Difference type
+            typedef BOOST_DEDUCED_TYPENAME
+                iterator_difference<IteratorT>::type difference_type;
+
+            //! Size type
+            typedef std::size_t size_type; // note: must be unsigned
+
+            //! This type
+            typedef iterator_range<IteratorT> this_type;
+
+            //! Reference type
+            //
+            // Needed because value-type is the same for
+            // const and non-const iterators
+            //
+            typedef BOOST_DEDUCED_TYPENAME
+                iterator_reference<IteratorT>::type reference;
+
+            //! const_iterator type
+            /*!
+                There is no distinction between const_iterator and iterator.
+                These typedefs are provides to fulfill container interface
+            */
+            typedef IteratorT const_iterator;
+            //! iterator type
+            typedef IteratorT iterator;
+
+        private: // for return value of operator()()
+            typedef BOOST_DEDUCED_TYPENAME
+                boost::mpl::if_< boost::is_abstract<value_type>,
+                                 reference, value_type >::type abstract_value_type;
+
+        public:
+            iterator_range() : m_Begin( iterator() ), m_End( iterator() )
+            { }
+
+            //! Constructor from a pair of iterators
+            template< class Iterator >
+            iterator_range( Iterator Begin, Iterator End ) :
+                m_Begin(Begin), m_End(End)
+            {}
+
+            //! Constructor from a Range
+            template< class Range >
+            iterator_range( const Range& r ) :
+                m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
+            {}
+
+            //! Constructor from a Range
+            template< class Range >
+            iterator_range( Range& r ) :
+                m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
+            {}
+
+            //! Constructor from a Range
+            template< class Range >
+            iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
+                m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
+            {}
+
+            //! Constructor from a Range
+            template< class Range >
+            iterator_range( Range& r, iterator_range_detail::range_tag ) :
+                m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
+            {}
+
+            #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
+            this_type& operator=( const this_type& r )
+            {
+                m_Begin  = r.begin();
+                m_End    = r.end();
+                return *this;
+            }
+            #endif
+
+            template< class Iterator >
+            iterator_range& operator=( const iterator_range<Iterator>& r )
+            {
+                m_Begin  = r.begin();
+                m_End    = r.end();
+                return *this;
+            }
+
+            template< class ForwardRange >
+            iterator_range& operator=( ForwardRange& r )
+            {
+                m_Begin  = impl::adl_begin( r );
+                m_End    = impl::adl_end( r );
+                return *this;
+            }
+
+            template< class ForwardRange >
+            iterator_range& operator=( const ForwardRange& r )
+            {
+                m_Begin  = impl::adl_begin( r );
+                m_End    = impl::adl_end( r );
+                return *this;
+            }
+
+            IteratorT begin() const
+            {
+                return m_Begin;
+            }
+
+            IteratorT end() const
+            {
+                return m_End;
+            }
+
+            difference_type size() const
+            {
+                return m_End - m_Begin;
+            }
+
+            bool empty() const
+            {
+                return m_Begin == m_End;
+            }
+
+            operator unspecified_bool_type() const
+            {
+                return safe_bool_t::to_unspecified_bool(m_Begin != m_End, &iterator_range::m_Begin);
+            }
+
+            bool operator!() const
+            {
+                return empty();
+            }
+
+            bool equal( const iterator_range& r ) const
+            {
+                return m_Begin == r.m_Begin && m_End == r.m_End;
+            }
+
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+            bool operator==( const iterator_range& r ) const
+            {
+                return boost::equal( *this, r );
+            }
+
+            bool operator!=( const iterator_range& r ) const
+            {
+                return !operator==(r);
+            }
+
+           bool operator<( const iterator_range& r ) const
+           {
+               return iterator_range_detail::less_than( *this, r );
+           }
+           
+           bool operator>( const iterator_range& r ) const
+           {
+               return iterator_range_detail::greater_than( *this, r );
+           }
+           
+           bool operator<=( const iterator_range& r ) const
+           {
+               return iterator_range_detail::less_or_equal_than( *this, r );
+           }
+           
+           bool operator>=( const iterator_range& r ) const
+           {
+               return iterator_range_detail::greater_or_equal_than( *this, r );
+           }
+
+#endif
+
+        public: // convenience
+           reference front() const
+           {
+               BOOST_ASSERT( !empty() );
+               return *m_Begin;
+           }
+
+           reference back() const
+           {
+               BOOST_ASSERT( !empty() );
+               IteratorT last( m_End );
+               return *--last;
+           }
+
+           // pop_front() - added to model the SinglePassRangePrimitiveConcept
+           void pop_front()
+           {
+               BOOST_ASSERT( !empty() );
+               ++m_Begin;
+           }
+
+           // pop_back() - added to model the BidirectionalRangePrimitiveConcept
+           void pop_back()
+           {
+               BOOST_ASSERT( !empty() );
+               --m_End;
+           }
+
+           reference operator[]( difference_type at ) const
+           {
+               BOOST_ASSERT( at >= 0 && at < size() );
+               return m_Begin[at];
+           }
+
+           //
+           // When storing transform iterators, operator[]()
+           // fails because it returns by reference. Therefore
+           // operator()() is provided for these cases.
+           //
+           abstract_value_type operator()( difference_type at ) const
+           {
+               BOOST_ASSERT( at >= 0 && at < size() );
+               return m_Begin[at];
+           }
+
+           iterator_range& advance_begin( difference_type n )
+           {
+               std::advance( m_Begin, n );
+               return *this;
+           }
+
+           iterator_range& advance_end( difference_type n )
+           {
+               std::advance( m_End, n );
+               return *this;
+           }
+
+        private:
+            // begin and end iterators
+            IteratorT m_Begin;
+            IteratorT m_End;
+
+        protected:
+            //
+            // Allow subclasses an easy way to access the
+            // base type
+            //
+            typedef iterator_range iterator_range_;
+        };
+
+//  iterator range free-standing operators ---------------------------//
+
+        /////////////////////////////////////////////////////////////////////
+        // comparison operators
+        /////////////////////////////////////////////////////////////////////
+
+        template< class IteratorT, class ForwardRange >
+        inline bool operator==( const ForwardRange& l,
+                                const iterator_range<IteratorT>& r )
+        {
+            return boost::equal( l, r );
+        }
+
+        template< class IteratorT, class ForwardRange >
+        inline bool operator!=( const ForwardRange& l,
+                                const iterator_range<IteratorT>& r )
+        {
+            return !boost::equal( l, r );
+        }
+
+        template< class IteratorT, class ForwardRange >
+        inline bool operator<( const ForwardRange& l,
+                               const iterator_range<IteratorT>& r )
+        {
+            return iterator_range_detail::less_than( l, r );
+        }
+        
+        template< class IteratorT, class ForwardRange >
+        inline bool operator<=( const ForwardRange& l,
+                                const iterator_range<IteratorT>& r )
+        {
+            return iterator_range_detail::less_or_equal_than( l, r );
+        }
+        
+        template< class IteratorT, class ForwardRange >
+        inline bool operator>( const ForwardRange& l,
+                               const iterator_range<IteratorT>& r )
+        {
+            return iterator_range_detail::greater_than( l, r );
+        }
+        
+        template< class IteratorT, class ForwardRange >
+        inline bool operator>=( const ForwardRange& l,
+                                const iterator_range<IteratorT>& r )
+        {
+            return iterator_range_detail::greater_or_equal_than( l, r );
+        }
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+#else
+        template< class Iterator1T, class Iterator2T >
+        inline bool operator==( const iterator_range<Iterator1T>& l,
+                                const iterator_range<Iterator2T>& r )
+        {
+            return boost::equal( l, r );
+        }
+
+        template< class IteratorT, class ForwardRange >
+        inline bool operator==( const iterator_range<IteratorT>& l,
+                                const ForwardRange& r )
+        {
+            return boost::equal( l, r );
+        }
+
+
+        template< class Iterator1T, class Iterator2T >
+        inline bool operator!=( const iterator_range<Iterator1T>& l,
+                                const iterator_range<Iterator2T>& r )
+        {
+            return !boost::equal( l, r );
+        }
+
+        template< class IteratorT, class ForwardRange >
+        inline bool operator!=( const iterator_range<IteratorT>& l,
+                                const ForwardRange& r )
+        {
+            return !boost::equal( l, r );
+        }
+
+
+        template< class Iterator1T, class Iterator2T >
+        inline bool operator<( const iterator_range<Iterator1T>& l,
+                               const iterator_range<Iterator2T>& r )
+        {
+            return iterator_range_detail::less_than( l, r );
+        }
+
+        template< class IteratorT, class ForwardRange >
+        inline bool operator<( const iterator_range<IteratorT>& l,
+                               const ForwardRange& r )
+        {
+            return iterator_range_detail::less_than( l, r );
+        }
+        
+        template< class Iterator1T, class Iterator2T >
+        inline bool operator<=( const iterator_range<Iterator1T>& l,
+                                const iterator_range<Iterator2T>& r )
+        {
+            return iterator_range_detail::less_or_equal_than( l, r );
+        }
+        
+        template< class IteratorT, class ForwardRange >
+        inline bool operator<=( const iterator_range<IteratorT>& l,
+                                const ForwardRange& r )
+        {
+            return iterator_range_detail::less_or_equal_than( l, r );
+        }
+        
+        template< class Iterator1T, class Iterator2T >
+        inline bool operator>( const iterator_range<Iterator1T>& l,
+                               const iterator_range<Iterator2T>& r )
+        {
+            return iterator_range_detail::greater_than( l, r );
+        }
+        
+        template< class IteratorT, class ForwardRange >
+        inline bool operator>( const iterator_range<IteratorT>& l,
+                               const ForwardRange& r )
+        {
+            return iterator_range_detail::greater_than( l, r );
+        }
+        
+        template< class Iterator1T, class Iterator2T >
+        inline bool operator>=( const iterator_range<Iterator1T>& l,
+                                const iterator_range<Iterator2T>& r )
+        {
+            return iterator_range_detail::greater_or_equal_than( l, r );
+        }
+        
+        template< class IteratorT, class ForwardRange >
+        inline bool operator>=( const iterator_range<IteratorT>& l,
+                                const ForwardRange& r )
+        {
+            return iterator_range_detail::greater_or_equal_than( l, r );
+        }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+//  iterator range utilities -----------------------------------------//
+
+        //! iterator_range construct helper
+        /*!
+            Construct an \c iterator_range from a pair of iterators
+
+            \param Begin A begin iterator
+            \param End An end iterator
+            \return iterator_range object
+        */
+        template< typename IteratorT >
+        inline iterator_range< IteratorT >
+        make_iterator_range( IteratorT Begin, IteratorT End )
+        {
+            return iterator_range<IteratorT>( Begin, End );
+        }
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+        template< typename Range >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
+        make_iterator_range( Range& r )
+        {
+            return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
+                ( boost::begin( r ), boost::end( r ) );
+        }
+
+#else
+        //! iterator_range construct helper
+        /*!
+            Construct an \c iterator_range from a \c Range containing the begin
+            and end iterators.
+        */
+        template< class ForwardRange >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
+        make_iterator_range( ForwardRange& r )
+        {
+           return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
+                ( r, iterator_range_detail::range_tag() );
+        }
+
+        template< class ForwardRange >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
+        make_iterator_range( const ForwardRange& r )
+        {
+           return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
+                ( r, iterator_range_detail::const_range_tag() );
+        }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+        namespace iterator_range_detail
+        {
+            template< class Range >
+            inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
+            make_range_impl( Range& r,
+                             BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
+                             BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
+            {
+                //
+                // Not worth the effort
+                //
+                //if( advance_begin == 0 && advance_end == 0 )
+                //    return make_iterator_range( r );
+                //
+
+                BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
+                    new_begin = boost::begin( r ),
+                    new_end   = boost::end( r );
+                std::advance( new_begin, advance_begin );
+                std::advance( new_end, advance_end );
+                return make_iterator_range( new_begin, new_end );
+            }
+        }
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+        template< class Range >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
+        make_iterator_range( Range& r,
+                    BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
+                    BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
+        {
+            //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
+            return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
+        }
+
+#else
+
+        template< class Range >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
+        make_iterator_range( Range& r,
+                    BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
+                    BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
+        {
+            //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
+            return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
+        }
+
+        template< class Range >
+        inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
+        make_iterator_range( const Range& r,
+                    BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
+                    BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
+        {
+            //BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
+            return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
+        }
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+        //! copy a range into a sequence
+        /*!
+            Construct a new sequence of the specified type from the elements
+            in the given range
+
+            \param Range An input range
+            \return New sequence
+        */
+        template< typename SeqT, typename Range >
+        inline SeqT copy_range( const Range& r )
+        {
+            return SeqT( boost::begin( r ), boost::end( r ) );
+        }
+
+} // namespace 'boost'
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+    #pragma warning( pop )
+#endif
+
+#endif
+
diff --git a/src/boost/range/iterator_range_io.hpp b/src/boost/range/iterator_range_io.hpp
new file mode 100644
index 0000000..51e3a4f
--- /dev/null
+++ b/src/boost/range/iterator_range_io.hpp
@@ -0,0 +1,93 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009.
+//  Use, modification and distribution is subject to the Boost Software
+//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED
+#define BOOST_RANGE_ITERATOR_RANGE_IO_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+    #pragma warning( push )
+    #pragma warning( disable : 4996 )
+#endif
+
+// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
+#ifndef BOOST_OLD_IOSTREAMS 
+# if defined(__STL_CONFIG_H) && \
+    !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
+    /**/
+#  define BOOST_OLD_IOSTREAMS
+# endif
+#endif // #ifndef BOOST_OLD_IOSTREAMS
+
+#ifndef _STLP_NO_IOSTREAMS
+# ifndef BOOST_OLD_IOSTREAMS
+#  include <ostream>
+# else
+#  include <ostream.h>
+# endif
+#endif // _STLP_NO_IOSTREAMS
+
+#include <boost/range/iterator_range_core.hpp>
+#include <iterator>
+#include <algorithm>
+#include <cstddef>
+
+namespace boost
+{
+
+#ifndef _STLP_NO_IOSTREAMS
+# ifndef BOOST_OLD_IOSTREAMS   
+
+        //! iterator_range output operator
+        /*!
+            Output the range to an ostream. Elements are outputed
+            in a sequence without separators.
+        */
+        template< typename IteratorT, typename Elem, typename Traits >
+        inline std::basic_ostream<Elem,Traits>& operator<<( 
+                    std::basic_ostream<Elem, Traits>& Os,
+                    const iterator_range<IteratorT>& r )
+        {
+            std::copy( r.begin(), r.end(), 
+                       std::ostream_iterator< BOOST_DEDUCED_TYPENAME 
+                                              iterator_value<IteratorT>::type, 
+                                              Elem, Traits>(Os) );
+            return Os;
+        }
+
+# else
+
+        //! iterator_range output operator
+        /*!
+            Output the range to an ostream. Elements are outputed
+            in a sequence without separators.
+        */
+        template< typename IteratorT >
+        inline std::ostream& operator<<( 
+                    std::ostream& Os,
+                    const iterator_range<IteratorT>& r )
+        {
+            std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os));
+            return Os;
+        }
+
+# endif
+#endif // _STLP_NO_IOSTREAMS
+
+} // namespace boost
+
+#undef BOOST_OLD_IOSTREAMS
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
+    #pragma warning(pop)
+#endif
+
+#endif // include guard
diff --git a/src/boost/range/join.hpp b/src/boost/range/join.hpp
new file mode 100644
index 0000000..aacc0a3
--- /dev/null
+++ b/src/boost/range/join.hpp
@@ -0,0 +1,91 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+#ifndef BOOST_RANGE_JOIN_HPP_INCLUDED
+#define BOOST_RANGE_JOIN_HPP_INCLUDED
+
+#include <boost/config.hpp>
+#include <boost/range/detail/join_iterator.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator_range.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+
+template<class SinglePassRange1, class SinglePassRange2>
+class joined_type
+{
+public:
+    typedef iterator_range<
+        range_detail::join_iterator<
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
+            BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type,
+            BOOST_DEDUCED_TYPENAME range_value<SinglePassRange1>::type
+        >
+    > type;
+};
+
+    } // namespace range_detail
+
+namespace range
+{
+
+template<class SinglePassRange1, class SinglePassRange2>
+class joined_range
+    : public range_detail::joined_type<SinglePassRange1, SinglePassRange2>::type
+{
+    typedef range_detail::join_iterator<
+        BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
+        BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type,
+        BOOST_DEDUCED_TYPENAME range_value<SinglePassRange1>::type
+        > iterator_t;
+
+    typedef BOOST_DEDUCED_TYPENAME range_detail::joined_type<
+                    SinglePassRange1, SinglePassRange2>::type base_t;
+public:
+    joined_range(SinglePassRange1& rng1, SinglePassRange2& rng2)
+        : base_t(
+            iterator_t(rng1, rng2, range_detail::join_iterator_begin_tag()),
+            iterator_t(rng1, rng2, range_detail::join_iterator_end_tag())
+        )
+    {
+    }
+};
+
+template<class SinglePassRange1, class SinglePassRange2>
+joined_range<const SinglePassRange1, const SinglePassRange2>
+join(const SinglePassRange1& r1, const SinglePassRange2& r2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    return joined_range<const SinglePassRange1, const SinglePassRange2>(r1, r2);
+}
+
+template<class SinglePassRange1, class SinglePassRange2>
+joined_range<SinglePassRange1, SinglePassRange2>
+join(SinglePassRange1& r1, SinglePassRange2& r2)
+{
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
+    BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
+
+    return joined_range<SinglePassRange1, SinglePassRange2>(r1, r2);
+}
+
+} // namespace range
+
+using ::boost::range::joined_range;
+using ::boost::range::join;
+
+} // namespace boost
+
+#endif // include guard
diff --git a/src/boost/range/metafunctions.hpp b/src/boost/range/metafunctions.hpp
new file mode 100644
index 0000000..469d9ae
--- /dev/null
+++ b/src/boost/range/metafunctions.hpp
@@ -0,0 +1,31 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_METAFUNCTIONS_HPP
+#define BOOST_RANGE_METAFUNCTIONS_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/iterator.hpp>
+#include <boost/range/has_range_iterator.hpp>
+#include <boost/range/result_iterator.hpp>
+#include <boost/range/reverse_iterator.hpp>
+#include <boost/range/const_reverse_iterator.hpp>
+#include <boost/range/reverse_result_iterator.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/category.hpp>
+#include <boost/range/reference.hpp>
+#include <boost/range/pointer.hpp>
+
+#endif
diff --git a/src/boost/range/mfc.hpp b/src/boost/range/mfc.hpp
new file mode 100644
index 0000000..058e54e
--- /dev/null
+++ b/src/boost/range/mfc.hpp
@@ -0,0 +1,984 @@
+#ifndef BOOST_RANGE_MFC_HPP
+#define BOOST_RANGE_MFC_HPP
+
+
+
+
+// Boost.Range MFC Extension
+//
+// Copyright Shunsuke Sogame 2005-2006.
+// Distributed under the Boost Software License, Version 1.0. 
+// (See accompanying file LICENSE_1_0.txt or copy at 
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+
+
+// config
+//
+
+
+#include <afx.h> // _MFC_VER
+
+
+#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
+    #if (_MFC_VER < 0x0700) // dubious
+        #define BOOST_RANGE_MFC_NO_CPAIR
+    #endif
+#endif
+
+
+#if !defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
+    #if (_MFC_VER < 0x0700) // dubious
+        #define BOOST_RANGE_MFC_HAS_LEGACY_STRING
+    #endif
+#endif
+
+
+// A const collection of old MFC doesn't return const reference.
+//
+#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
+    #if (_MFC_VER < 0x0700) // dubious
+        #define BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF
+    #endif
+#endif
+
+
+
+
+// forward declarations
+//
+
+
+template< class Type, class ArgType >
+class CArray;
+
+template< class Type, class ArgType >
+class CList;
+
+template< class Key, class ArgKey, class Mapped, class ArgMapped >
+class CMap;
+
+template< class BaseClass, class PtrType >
+class CTypedPtrArray;
+
+template< class BaseClass, class PtrType >
+class CTypedPtrList;
+
+template< class BaseClass, class KeyPtrType, class MappedPtrType >
+class CTypedPtrMap;
+
+
+
+
+// extended customizations
+//
+
+
+#include <cstddef> // ptrdiff_t
+#include <utility> // pair
+#include <boost/assert.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/range/atl.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/const_iterator.hpp>
+#include <boost/range/detail/microsoft.hpp>
+#include <boost/range/end.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/utility/addressof.hpp>
+#include <afx.h> // legacy CString
+#include <afxcoll.h> // CXXXArray, CXXXList, CMapXXXToXXX
+#include <tchar.h>
+
+
+namespace boost { namespace range_detail_microsoft {
+
+
+    // mfc_ptr_array_iterator
+    //
+    // 'void **' is not convertible to 'void const **',
+    // so we define...
+    //
+
+    template< class ArrayT, class PtrType >
+    struct mfc_ptr_array_iterator;
+
+    template< class ArrayT, class PtrType >
+    struct mfc_ptr_array_iterator_super
+    {
+        typedef iterator_adaptor<
+            mfc_ptr_array_iterator<ArrayT, PtrType>,
+            std::ptrdiff_t, // Base!
+            PtrType,        // Value
+            random_access_traversal_tag,
+            use_default,
+            std::ptrdiff_t  // Difference
+        > type;
+    };
+
+    template< class ArrayT, class PtrType >
+    struct mfc_ptr_array_iterator :
+        mfc_ptr_array_iterator_super<ArrayT, PtrType>::type
+    {
+    private:
+        typedef mfc_ptr_array_iterator self_t;
+        typedef typename mfc_ptr_array_iterator_super<ArrayT, PtrType>::type super_t;
+        typedef typename super_t::reference ref_t;
+
+    public:
+        explicit mfc_ptr_array_iterator()
+        { }
+
+        explicit mfc_ptr_array_iterator(ArrayT& arr, INT_PTR index) :
+            super_t(index), m_parr(boost::addressof(arr))
+        { }
+
+    template< class, class > friend struct mfc_ptr_array_iterator;
+        template< class ArrayT_, class PtrType_ >
+        mfc_ptr_array_iterator(mfc_ptr_array_iterator<ArrayT_, PtrType_> const& other) :
+            super_t(other.base()), m_parr(other.m_parr)
+        { }
+
+    private:
+        ArrayT *m_parr;
+
+    friend class iterator_core_access;
+        ref_t dereference() const
+        {
+            BOOST_ASSERT(0 <= this->base() && this->base() < m_parr->GetSize() && "out of range");
+            return *( m_parr->GetData() + this->base() );
+        }
+
+        bool equal(self_t const& other) const
+        {
+            BOOST_ASSERT(m_parr == other.m_parr && "iterators incompatible");
+            return this->base() == other.base();
+        }
+    };
+
+    struct mfc_ptr_array_functions
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return Iterator(x, 0);
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return Iterator(x, x.GetSize());
+        }
+    };
+
+
+    // arrays
+    //
+
+    template< >
+    struct customization< ::CByteArray > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef BYTE val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CDWordArray > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef DWORD val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CObArray > :
+        mfc_ptr_array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef mfc_ptr_array_iterator<X, CObject *> mutable_iterator;
+            typedef mfc_ptr_array_iterator<X const, CObject const *> const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CPtrArray > :
+        mfc_ptr_array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef mfc_ptr_array_iterator<X, void *> mutable_iterator;
+            typedef mfc_ptr_array_iterator<X const, void const *> const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CStringArray > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ::CString val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CUIntArray > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef UINT val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CWordArray > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef WORD val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    // lists
+    //
+
+    template< >
+    struct customization< ::CObList > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef list_iterator<X, ::CObject *> mutable_iterator;
+    #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
+            typedef list_iterator<X const, ::CObject const *> const_iterator;
+    #else
+            typedef list_iterator<X const, ::CObject const * const, ::CObject const * const> const_iterator;
+    #endif
+        };
+    };
+
+
+    template< >
+    struct customization< ::CPtrList > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef list_iterator<X, void *> mutable_iterator;
+    #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
+            typedef list_iterator<X const, void const *> const_iterator;
+    #else
+            typedef list_iterator<X const, void const * const, void const * const> const_iterator;
+    #endif
+        };
+    };
+
+
+    template< >
+    struct customization< ::CStringList > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ::CString val_t;
+
+            typedef list_iterator<X, val_t> mutable_iterator;
+    #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
+            typedef list_iterator<X const, val_t const> const_iterator;
+    #else
+            typedef list_iterator<X const, val_t const, val_t const> const_iterator;
+    #endif
+        };
+    };
+
+
+    // mfc_map_iterator
+    //
+
+    template< class MapT, class KeyT, class MappedT >
+    struct mfc_map_iterator;
+
+    template< class MapT, class KeyT, class MappedT >
+    struct mfc_map_iterator_super
+    {
+        typedef iterator_facade<
+            mfc_map_iterator<MapT, KeyT, MappedT>,
+            std::pair<KeyT, MappedT>,
+            forward_traversal_tag,
+            std::pair<KeyT, MappedT> const
+        > type;
+    };
+
+    template< class MapT, class KeyT, class MappedT >
+    struct mfc_map_iterator :
+        mfc_map_iterator_super<MapT, KeyT, MappedT>::type
+    {
+    private:
+        typedef mfc_map_iterator self_t;
+        typedef typename mfc_map_iterator_super<MapT, KeyT, MappedT>::type super_t;
+        typedef typename super_t::reference ref_t;
+
+    public:
+        explicit mfc_map_iterator()
+        { }
+
+        explicit mfc_map_iterator(MapT const& map, POSITION pos) :
+            m_pmap(boost::addressof(map)), m_posNext(pos)
+        {
+            increment();
+        }
+
+        explicit mfc_map_iterator(MapT const& map) :
+            m_pmap(&map), m_pos(0) // end iterator
+        { }
+
+    template< class, class, class > friend struct mfc_map_iterator;
+        template< class MapT_, class KeyT_, class MappedT_>
+        mfc_map_iterator(mfc_map_iterator<MapT_, KeyT_, MappedT_> const& other) :
+            m_pmap(other.m_pmap),
+            m_pos(other.m_pos), m_posNext(other.m_posNext),
+            m_key(other.m_key), m_mapped(other.m_mapped)
+        { }
+
+    private:
+        MapT const *m_pmap;
+        POSITION m_pos, m_posNext;
+        KeyT m_key; MappedT m_mapped;
+
+    friend class iterator_core_access;
+        ref_t dereference() const
+        {
+            BOOST_ASSERT(m_pos != 0 && "out of range");
+            return std::make_pair(m_key, m_mapped);
+        }
+
+        void increment()
+        {
+            BOOST_ASSERT(m_pos != 0 && "out of range");
+
+            if (m_posNext == 0) {
+                m_pos = 0;
+                return;
+            }
+
+            m_pos = m_posNext;
+            m_pmap->GetNextAssoc(m_posNext, m_key, m_mapped);
+        }
+
+        bool equal(self_t const& other) const
+        {
+            BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
+            return m_pos == other.m_pos;
+        }
+    };
+
+    struct mfc_map_functions
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return Iterator(x, x.GetStartPosition());
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return Iterator(x);
+        }
+    };
+
+
+#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
+
+
+    // mfc_cpair_map_iterator
+    //
+    // used by ::CMap and ::CMapStringToString
+    //
+
+    template< class MapT, class PairT >
+    struct mfc_cpair_map_iterator;
+
+    template< class MapT, class PairT >
+    struct mfc_pget_map_iterator_super
+    {
+        typedef iterator_facade<
+            mfc_cpair_map_iterator<MapT, PairT>,
+            PairT,
+            forward_traversal_tag
+        > type;
+    };
+
+    template< class MapT, class PairT >
+    struct mfc_cpair_map_iterator :
+        mfc_pget_map_iterator_super<MapT, PairT>::type
+    {
+    private:
+        typedef mfc_cpair_map_iterator self_t;
+        typedef typename mfc_pget_map_iterator_super<MapT, PairT>::type super_t;
+        typedef typename super_t::reference ref_t;
+
+    public:
+        explicit mfc_cpair_map_iterator()
+        { }
+
+        explicit mfc_cpair_map_iterator(MapT& map, PairT *pp) :
+            m_pmap(boost::addressof(map)), m_pp(pp)
+        { }
+
+    template< class, class > friend struct mfc_cpair_map_iterator;
+        template< class MapT_, class PairT_>
+        mfc_cpair_map_iterator(mfc_cpair_map_iterator<MapT_, PairT_> const& other) :
+            m_pmap(other.m_pmap), m_pp(other.m_pp)
+        { }
+
+    private:
+        MapT  *m_pmap;
+        PairT *m_pp;
+
+    friend class iterator_core_access;
+        ref_t dereference() const
+        {
+            BOOST_ASSERT(m_pp != 0 && "out of range");
+            return *m_pp;
+        }
+
+        void increment()
+        {
+            BOOST_ASSERT(m_pp != 0 && "out of range");
+            m_pp = m_pmap->PGetNextAssoc(m_pp);
+        }
+
+        bool equal(self_t const& other) const
+        {
+            BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
+            return m_pp == other.m_pp;
+        }
+    };
+
+    struct mfc_cpair_map_functions
+    {
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            // Workaround:
+            // Assertion fails if empty.
+            // MFC document is wrong.
+    #if !defined(NDEBUG)
+            if (x.GetCount() == 0) 
+                return Iterator(x, 0);
+    #endif
+
+            return Iterator(x, x.PGetFirstAssoc());
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return Iterator(x, 0);
+        }
+    };
+
+
+#endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)
+
+
+    // maps
+    //
+
+    template< >
+    struct customization< ::CMapPtrToWord > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef void *key_t;
+            typedef WORD mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CMapPtrToPtr > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef void *key_t;
+            typedef void *mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CMapStringToOb > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ::CString key_t;
+            typedef ::CObject *mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CMapStringToPtr > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef ::CString key_t;
+            typedef void *mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CMapStringToString > :
+    #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
+        mfc_cpair_map_functions
+    #else
+        mfc_map_functions
+    #endif
+    {
+        template< class X >
+        struct meta
+        {
+    #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
+            typedef typename X::CPair pair_t;
+
+            typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
+            typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
+    #else
+            typedef ::CString key_t;
+            typedef ::CString mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+    #endif
+        };
+    };
+
+
+    template< >
+    struct customization< ::CMapWordToOb > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef WORD key_t;
+            typedef ::CObject *mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    template< >
+    struct customization< ::CMapWordToPtr > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef WORD key_t;
+            typedef void *mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    // templates
+    //
+
+    template< class Type, class ArgType >
+    struct customization< ::CArray<Type, ArgType> > :
+        array_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef Type val_t;
+
+            typedef val_t *mutable_iterator;
+            typedef val_t const *const_iterator;
+        };
+    };
+
+
+    template< class Type, class ArgType >
+    struct customization< ::CList<Type, ArgType> > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef Type val_t;
+
+            typedef list_iterator<X, val_t> mutable_iterator;
+    #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
+            typedef list_iterator<X const, val_t const> const_iterator;
+    #else
+            typedef list_iterator<X const, val_t const, val_t const> const_iterator;
+    #endif
+        };
+    };
+
+
+    template< class Key, class ArgKey, class Mapped, class ArgMapped >
+    struct customization< ::CMap<Key, ArgKey, Mapped, ArgMapped> > :
+    #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
+        mfc_cpair_map_functions
+    #else
+        mfc_map_functions
+    #endif
+    {
+        template< class X >
+        struct meta
+        {
+    #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
+            typedef typename X::CPair pair_t;
+
+            typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
+            typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
+    #else
+            typedef Key key_t;
+            typedef Mapped mapped_t;
+
+            typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+    #endif            
+        };
+    };
+
+
+    template< class BaseClass, class PtrType >
+    struct customization< ::CTypedPtrArray<BaseClass, PtrType> >
+    {
+        template< class X >
+        struct fun
+        {
+            typedef typename remove_pointer<PtrType>::type val_t;
+
+            typedef typename mpl::if_< is_const<X>,
+                val_t const,
+                val_t
+            >::type val_t_;
+
+            typedef val_t_ * const result_type;
+
+            template< class PtrType_ >
+            result_type operator()(PtrType_ p) const
+            {
+                return static_cast<result_type>(p);
+            }
+        };
+
+        template< class X >
+        struct meta
+        {
+            typedef typename compatible_mutable_iterator<BaseClass>::type miter_t;
+            typedef typename range_const_iterator<BaseClass>::type citer_t;
+
+            typedef transform_iterator<fun<X>, miter_t> mutable_iterator;
+            typedef transform_iterator<fun<X const>, citer_t> const_iterator;
+        };
+
+        template< class Iterator, class X >
+        Iterator begin(X& x)
+        {
+            return Iterator(boost::begin<BaseClass>(x), fun<X>());
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return Iterator(boost::end<BaseClass>(x), fun<X>());
+        }
+    };
+
+
+    template< class BaseClass, class PtrType >
+    struct customization< ::CTypedPtrList<BaseClass, PtrType> > :
+        list_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef typename remove_pointer<PtrType>::type val_t;
+
+            // not l-value
+            typedef list_iterator<X, val_t * const, val_t * const> mutable_iterator;
+            typedef list_iterator<X const, val_t const * const, val_t const * const> const_iterator;
+        };
+    };
+
+
+    template< class BaseClass, class KeyPtrType, class MappedPtrType >
+    struct customization< ::CTypedPtrMap<BaseClass, KeyPtrType, MappedPtrType> > :
+        mfc_map_functions
+    {
+        template< class X >
+        struct meta
+        {
+            typedef mfc_map_iterator<X, KeyPtrType, MappedPtrType> mutable_iterator;
+            typedef mutable_iterator const_iterator;
+        };
+    };
+
+
+    // strings
+    //
+
+#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
+
+    template< >
+    struct customization< ::CString >
+    {
+        template< class X >
+        struct meta
+        {
+            // LPTSTR/LPCTSTR is not always defined in <tchar.h>.
+            typedef TCHAR *mutable_iterator;
+            typedef TCHAR const *const_iterator;
+        };
+
+        template< class Iterator, class X >
+        typename mutable_<Iterator, X>::type begin(X& x)
+        {
+            return x.GetBuffer(0);
+        }
+
+        template< class Iterator, class X >
+        Iterator begin(X const& x)
+        {
+            return x;
+        }
+
+        template< class Iterator, class X >
+        Iterator end(X& x)
+        {
+            return begin<Iterator>(x) + x.GetLength();
+        }
+    };
+
+#endif // defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
+
+
+} } // namespace boost::range_detail_microsoft
+
+
+
+
+// range customizations
+//
+
+
+// arrays
+//
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CByteArray
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CDWordArray
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CStringArray
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CUIntArray
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CWordArray
+)
+
+
+// lists
+//
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CObList
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CPtrList
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CStringList
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CObArray
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CPtrArray
+)
+
+
+// maps
+//
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapPtrToWord
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapPtrToPtr
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapStringToOb
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapStringToPtr
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapStringToString
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapWordToOb
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMapWordToPtr
+)
+
+
+// templates
+//
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CArray, 2
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CList, 2
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CMap, 4
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CTypedPtrArray, 2
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CTypedPtrList, 2
+)
+
+BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
+    boost::range_detail_microsoft::using_type_as_tag,
+    BOOST_PP_NIL, CTypedPtrMap, 3
+)
+
+
+// strings
+//
+#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
+
+    BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
+        boost::range_detail_microsoft::using_type_as_tag,
+        BOOST_PP_NIL, CString
+    )
+
+#endif
+
+
+
+
+#endif
diff --git a/src/boost/range/mutable_iterator.hpp b/src/boost/range/mutable_iterator.hpp
new file mode 100644
index 0000000..7beca66
--- /dev/null
+++ b/src/boost/range/mutable_iterator.hpp
@@ -0,0 +1,67 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_MUTABLE_ITERATOR_HPP
+#define BOOST_RANGE_MUTABLE_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/range/detail/iterator.hpp>
+#else
+
+#include <boost/range/detail/extract_optional_type.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <cstddef>
+#include <utility>
+
+namespace boost
+{
+    //////////////////////////////////////////////////////////////////////////
+    // default
+    //////////////////////////////////////////////////////////////////////////
+    
+    namespace range_detail {
+        BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( iterator )
+    }
+
+    template< typename C >
+    struct range_mutable_iterator : range_detail::extract_iterator<C>
+    {};
+    
+    //////////////////////////////////////////////////////////////////////////
+    // pair
+    //////////////////////////////////////////////////////////////////////////
+
+    template< typename Iterator >
+    struct range_mutable_iterator< std::pair<Iterator,Iterator> >
+    {
+        typedef Iterator type;
+    };
+
+    //////////////////////////////////////////////////////////////////////////
+    // array
+    //////////////////////////////////////////////////////////////////////////
+
+    template< typename T, std::size_t sz >
+    struct range_mutable_iterator< T[sz] >
+    {
+        typedef T* type;
+    };
+
+} // namespace boost
+
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+#endif
diff --git a/src/boost/range/numeric.hpp b/src/boost/range/numeric.hpp
new file mode 100644
index 0000000..bfd1049
--- /dev/null
+++ b/src/boost/range/numeric.hpp
@@ -0,0 +1,118 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file algorithm.hpp
+///   Contains range-based versions of the std algorithms
+//
+/////////////////////////////////////////////////////////////////////////////
+// Copyright 2009 Neil Groves.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+
+// Copyright 2006 Thorsten Ottosen.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// Copyright 2004 Eric Niebler.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#if defined(_MSC_VER) && _MSC_VER >= 1000
+    #pragma once
+#endif
+
+#ifndef BOOST_RANGE_NUMERIC_HPP
+#define BOOST_RANGE_NUMERIC_HPP
+
+#include <boost/config.hpp>
+#include <boost/assert.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/distance.hpp>
+#include <numeric>
+
+
+namespace boost
+{
+    template< class SinglePassRange, class Value >
+    inline Value accumulate( const SinglePassRange& rng, Value init )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+        return std::accumulate( boost::begin(rng), boost::end(rng), init );
+    }
+
+    template< class SinglePassRange, class Value, class BinaryOperation >
+    inline Value accumulate( const SinglePassRange& rng, Value init, BinaryOperation op )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+        return std::accumulate( boost::begin(rng), boost::end(rng), init, op );
+    }
+
+
+    template< class SinglePassRange1, class SinglePassRange2, class Value >
+    inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+        BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
+        return std::inner_product( boost::begin(rng1), boost::end(rng1),
+            boost::begin(rng2), init );
+    }
+
+    template< class SinglePassRange1,
+              class SinglePassRange2,
+              class Value,
+              class BinaryOperation1, class BinaryOperation2 >
+    inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
+                                Value init,
+                                BinaryOperation1 op1, BinaryOperation2 op2 )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
+        BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
+
+        return std::inner_product( boost::begin(rng1), boost::end(rng1),
+                                   boost::begin(rng2), init, op1, op2 );
+    }
+
+    template< class SinglePassRange, class OutputIterator >
+    inline OutputIterator partial_sum ( const SinglePassRange& rng,
+                                        OutputIterator result )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+        return std::partial_sum( boost::begin(rng), boost::end(rng), result );
+    }
+
+    template< class SinglePassRange, class OutputIterator, class BinaryOperation >
+    inline OutputIterator partial_sum ( const SinglePassRange& rng, OutputIterator result,
+                                        BinaryOperation op )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+        return std::partial_sum( boost::begin(rng), boost::end(rng), result, op );
+    }
+
+    template< class SinglePassRange, class OutputIterator >
+    inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
+                                                OutputIterator result )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
+        return std::adjacent_difference( boost::begin(rng), boost::end(rng),
+                                         result );
+    }
+
+    template< class SinglePassRange, class OutputIterator, class BinaryOperation >
+    inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
+                                                OutputIterator result,
+                                                BinaryOperation op )
+    {
+        BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
+        return std::adjacent_difference( boost::begin(rng), boost::end(rng),
+                                         result, op );
+    }
+
+}
+
+#endif
diff --git a/src/boost/range/pointer.hpp b/src/boost/range/pointer.hpp
new file mode 100644
index 0000000..e7431ff
--- /dev/null
+++ b/src/boost/range/pointer.hpp
@@ -0,0 +1,29 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2006. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_POINTER_TYPE_HPP
+#define BOOST_RANGE_POINTER_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace boost
+{
+    template< class T >
+    struct range_pointer : iterator_pointer< typename range_iterator<T>::type >
+    { };
+}
+
+#endif
diff --git a/src/boost/range/rbegin.hpp b/src/boost/range/rbegin.hpp
new file mode 100644
index 0000000..78e5f61
--- /dev/null
+++ b/src/boost/range/rbegin.hpp
@@ -0,0 +1,65 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_RBEGIN_HPP
+#define BOOST_RANGE_RBEGIN_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/end.hpp>
+#include <boost/range/reverse_iterator.hpp>
+
+namespace boost
+{
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+template< class C >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
+rbegin( C& c )
+{
+    return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::end( c ) );
+}
+
+#else
+
+template< class C >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
+rbegin( C& c )
+{
+    typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
+        iter_type;
+    return iter_type( boost::end( c ) );
+}
+
+template< class C >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
+rbegin( const C& c )
+{
+    typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
+        iter_type;
+    return iter_type( boost::end( c ) );
+}
+
+#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+template< class T >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
+const_rbegin( const T& r )
+{
+    return boost::rbegin( r );
+}
+
+} // namespace 'boost'
+
+#endif
+
diff --git a/src/boost/range/reference.hpp b/src/boost/range/reference.hpp
new file mode 100644
index 0000000..d308e43
--- /dev/null
+++ b/src/boost/range/reference.hpp
@@ -0,0 +1,29 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_REFERENCE_TYPE_HPP
+#define BOOST_RANGE_REFERENCE_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace boost
+{
+    template< class T >
+    struct range_reference : iterator_reference< typename range_iterator<T>::type >
+    { };
+}
+
+#endif
diff --git a/src/boost/range/rend.hpp b/src/boost/range/rend.hpp
new file mode 100644
index 0000000..fd79aa2
--- /dev/null
+++ b/src/boost/range/rend.hpp
@@ -0,0 +1,65 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_REND_HPP
+#define BOOST_RANGE_REND_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/begin.hpp>
+#include <boost/range/reverse_iterator.hpp>
+
+namespace boost
+{
+
+#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
+
+template< class C >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
+rend( C& c )
+{
+    return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::begin( c ) );
+}
+
+#else
+
+template< class C >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
+rend( C& c )
+{
+    typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
+               iter_type;
+    return iter_type( boost::begin( c ) );
+}
+
+template< class C >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
+rend( const C& c )
+{
+    typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
+        iter_type;
+    return iter_type( boost::begin( c ) );
+}
+
+#endif
+
+template< class T >
+inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
+const_rend( const T& r )
+{
+    return boost::rend( r );
+}
+
+} // namespace 'boost'
+
+#endif
+
diff --git a/src/boost/range/result_iterator.hpp b/src/boost/range/result_iterator.hpp
new file mode 100644
index 0000000..ba09c5f
--- /dev/null
+++ b/src/boost/range/result_iterator.hpp
@@ -0,0 +1,33 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_RESULT_ITERATOR_HPP
+#define BOOST_RANGE_RESULT_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/range/iterator.hpp>
+
+namespace boost
+{
+    //
+    // This interface is deprecated, use range_iterator<T>
+    //
+    
+    template< typename C >
+    struct range_result_iterator : range_iterator<C>
+    { };
+    
+} // namespace boost
+
+
+#endif
diff --git a/src/boost/range/reverse_iterator.hpp b/src/boost/range/reverse_iterator.hpp
new file mode 100644
index 0000000..f8e9221
--- /dev/null
+++ b/src/boost/range/reverse_iterator.hpp
@@ -0,0 +1,40 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_REVERSE_ITERATOR_HPP
+#define BOOST_RANGE_REVERSE_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator.hpp>
+#include <boost/iterator/reverse_iterator.hpp>
+
+
+namespace boost
+{
+    //////////////////////////////////////////////////////////////////////////
+    // default
+    //////////////////////////////////////////////////////////////////////////
+    
+    template< typename C >
+    struct range_reverse_iterator
+    {
+        typedef reverse_iterator< 
+            BOOST_DEDUCED_TYPENAME range_iterator<C>::type > type;
+    };
+    
+
+} // namespace boost
+
+
+#endif
diff --git a/src/boost/range/reverse_result_iterator.hpp b/src/boost/range/reverse_result_iterator.hpp
new file mode 100644
index 0000000..62bf135
--- /dev/null
+++ b/src/boost/range/reverse_result_iterator.hpp
@@ -0,0 +1,32 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP
+#define BOOST_RANGE_REVERSE_RESULT_ITERATOR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/range/reverse_iterator.hpp>
+
+namespace boost
+{
+    //
+    // This interface is deprecated, use range_reverse_iterator<T>
+    //
+   
+    template< typename C >
+    struct range_reverse_result_iterator : range_reverse_iterator<C>
+    { };
+    
+} // namespace boost
+
+#endif
diff --git a/src/boost/range/size.hpp b/src/boost/range/size.hpp
new file mode 100644
index 0000000..6ae74d1
--- /dev/null
+++ b/src/boost/range/size.hpp
@@ -0,0 +1,52 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_SIZE_HPP
+#define BOOST_RANGE_SIZE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/assert.hpp>
+
+namespace boost
+{
+    namespace range_detail
+    {
+        template<class SinglePassRange>
+        inline BOOST_DEDUCED_TYPENAME range_size<const SinglePassRange>::type
+        range_calculate_size(const SinglePassRange& rng)
+        {
+            BOOST_ASSERT( (boost::end(rng) - boost::begin(rng)) >= 0 &&
+                          "reachability invariant broken!" );
+            return boost::end(rng) - boost::begin(rng);
+        }
+    }
+
+    template<class SinglePassRange>
+    inline BOOST_DEDUCED_TYPENAME range_size<const SinglePassRange>::type
+    size(const SinglePassRange& rng)
+    {
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+    !BOOST_WORKAROUND(__GNUC__, < 3) \
+    /**/
+        using namespace range_detail;
+#endif
+        return range_calculate_size(rng);
+    }
+
+} // namespace 'boost'
+
+#endif
diff --git a/src/boost/range/size_type.hpp b/src/boost/range/size_type.hpp
new file mode 100644
index 0000000..c6fb54b
--- /dev/null
+++ b/src/boost/range/size_type.hpp
@@ -0,0 +1,89 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_SIZE_TYPE_HPP
+#define BOOST_RANGE_SIZE_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/difference_type.hpp>
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+#include <boost/range/detail/size_type.hpp>
+#else
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <cstddef>
+#include <utility>
+
+namespace boost
+{
+    namespace detail
+    {
+
+        //////////////////////////////////////////////////////////////////////////
+        // default
+        //////////////////////////////////////////////////////////////////////////
+
+        template<typename T>
+        class has_size_type
+        {
+            typedef char no_type;
+            struct yes_type { char dummy[2]; };
+
+            template<typename C>
+            static yes_type test(BOOST_DEDUCED_TYPENAME C::size_type x);
+
+            template<typename C, typename Arg>
+            static no_type test(Arg x);
+
+        public:
+            static const bool value = sizeof(test<T>(0)) == sizeof(yes_type);
+        };
+
+        template<typename C, typename Enabler=void>
+        struct range_size
+        {
+            typedef BOOST_DEDUCED_TYPENAME make_unsigned<
+                BOOST_DEDUCED_TYPENAME range_difference<C>::type
+            >::type type;
+        };
+
+        template<typename C>
+        struct range_size<
+            C,
+            BOOST_DEDUCED_TYPENAME enable_if<has_size_type<C>, void>::type
+        >
+        {
+            typedef BOOST_DEDUCED_TYPENAME C::size_type type;
+        };
+
+    }
+
+    template< class T >
+    struct range_size :
+        detail::range_size<T>
+    { };
+
+    template< class T >
+    struct range_size<const T >
+        : detail::range_size<T>
+    { };
+
+} // namespace boost
+
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+
+#endif
diff --git a/src/boost/range/sub_range.hpp b/src/boost/range/sub_range.hpp
new file mode 100644
index 0000000..0b00086
--- /dev/null
+++ b/src/boost/range/sub_range.hpp
@@ -0,0 +1,182 @@
+// Boost.Range library
+//
+//  Copyright Neil Groves 2009.
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_SUB_RANGE_HPP
+#define BOOST_RANGE_SUB_RANGE_HPP
+
+#include <boost/detail/workaround.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) 
+    #pragma warning( push )
+    #pragma warning( disable : 4996 )
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/range/value_type.hpp>
+#include <boost/range/size_type.hpp>
+#include <boost/range/difference_type.hpp>
+#include <boost/range/algorithm/equal.hpp>
+#include <boost/assert.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+namespace boost
+{
+    
+    template< class ForwardRange > 
+    class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type > 
+    {
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
+        typedef iterator_range< iterator_t  > base;
+
+        typedef BOOST_DEDUCED_TYPENAME base::impl impl;
+    public:
+        typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type            value_type;
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type         iterator;
+        typedef BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type   const_iterator;
+        typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type       difference_type;
+        typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type             size_type;
+        typedef BOOST_DEDUCED_TYPENAME base::reference                            reference;
+        
+    public: // for return value of front/back
+        typedef BOOST_DEDUCED_TYPENAME 
+                boost::mpl::if_< boost::is_reference<reference>,
+                                 const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&, 
+                                 reference >::type const_reference;
+
+    public:
+        sub_range() : base() 
+        { }
+        
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) ) 
+        sub_range( const sub_range& r ) 
+            : base( static_cast<const base&>( r ) )  
+        { }  
+#endif
+
+        template< class ForwardRange2 >
+        sub_range( ForwardRange2& r ) : 
+            
+#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
+            base( impl::adl_begin( r ), impl::adl_end( r ) )
+#else
+            base( r )
+#endif        
+        { }
+        
+        template< class ForwardRange2 >
+        sub_range( const ForwardRange2& r ) : 
+
+#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
+            base( impl::adl_begin( r ), impl::adl_end( r ) )
+#else
+            base( r )
+#endif                
+        { }
+
+        template< class Iter >
+        sub_range( Iter first, Iter last ) :
+            base( first, last )
+        { }
+        
+        template< class ForwardRange2 >
+        sub_range& operator=( ForwardRange2& r )
+        {
+            base::operator=( r );
+            return *this;
+        }
+
+        template< class ForwardRange2 >
+        sub_range& operator=( const ForwardRange2& r )
+        {
+            base::operator=( r );
+            return *this;
+        }   
+
+        sub_range& operator=( const sub_range& r )
+        {
+            base::operator=( static_cast<const base&>(r) );
+            return *this;            
+        }
+        
+    public:
+        
+        iterator        begin()          { return base::begin(); }
+        const_iterator  begin() const    { return base::begin(); }
+        iterator        end()            { return base::end();   }
+        const_iterator  end() const      { return base::end();   }
+        difference_type size() const     { return base::size();  }   
+
+        
+    public: // convenience
+        reference front()
+        {
+            return base::front();
+        }
+
+        const_reference front() const
+        {
+            return base::front();
+        }
+
+        reference back()
+        {
+            return base::back();
+        }
+
+        const_reference back() const
+        {
+            return base::back();
+        }
+
+        reference operator[]( difference_type sz )
+        {
+            return base::operator[](sz);
+        }
+
+        const_reference operator[]( difference_type sz ) const
+        {
+            return base::operator[](sz);
+        }
+
+    };
+
+    template< class ForwardRange, class ForwardRange2 >
+    inline bool operator==( const sub_range<ForwardRange>& l,
+                            const sub_range<ForwardRange2>& r )
+    {
+        return boost::equal( l, r );
+    }
+
+    template< class ForwardRange, class ForwardRange2 >
+    inline bool operator!=( const sub_range<ForwardRange>& l,
+                            const sub_range<ForwardRange2>& r )
+    {
+        return !boost::equal( l, r );
+    }
+
+    template< class ForwardRange, class ForwardRange2 >
+    inline bool operator<( const sub_range<ForwardRange>& l,
+                           const sub_range<ForwardRange2>& r )
+    {
+        return iterator_range_detail::less_than( l, r );
+    }
+
+
+} // namespace 'boost'
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500)) 
+    #pragma warning( pop )
+#endif
+
+#endif
+
diff --git a/src/boost/range/value_type.hpp b/src/boost/range/value_type.hpp
new file mode 100644
index 0000000..95c7580
--- /dev/null
+++ b/src/boost/range/value_type.hpp
@@ -0,0 +1,34 @@
+// Boost.Range library
+//
+//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
+//  distribution is subject to the Boost Software License, Version
+//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+
+#ifndef BOOST_RANGE_VALUE_TYPE_HPP
+#define BOOST_RANGE_VALUE_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif
+
+#include <boost/range/config.hpp>
+#include <boost/range/iterator.hpp>
+
+//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+//#include <boost/range/detail/value_type.hpp>
+//#else
+
+#include <boost/iterator/iterator_traits.hpp>
+
+namespace boost
+{
+    template< class T >
+    struct range_value : iterator_value< typename range_iterator<T>::type >
+    { };
+}
+
+#endif
diff --git a/src/common/AnimationRules.cc b/src/common/AnimationRules.cc
new file mode 100644
index 0000000..eeb864c
--- /dev/null
+++ b/src/common/AnimationRules.cc
@@ -0,0 +1,267 @@
+/*! \file FrameLoop.cc
+    \brief Implementation of the Template class FrameLoop.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Fri 29-Aug-2008
+    
+    Changes:
+    
+*/
+
+
+#include "AnimationRules.h"
+#include "BaseDriver.h"
+#include "Text.h"
+#include "PaperPoint.h"
+#include "Layer.h"
+#include <limits>
+#include "Data.h"
+
+using namespace magics;
+
+
+AnimationStep::AnimationStep(AnimationRules& rules) : rules_(rules),
+xResolution_(std::numeric_limits<double>::max()), yResolution_(std::numeric_limits<double>::max())
+{
+	
+}
+
+
+AnimationStep::~AnimationStep() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void AnimationStep::print(ostream& out)  const
+{
+	out << "AnimationStep[" << size() << " entries";
+	TagHandler::print(out); 
+	for (map<Layer*, int>::const_iterator l = begin(); l != end(); ++l) 
+		out << *(l->first) << "---> " << l->second << endl;
+	out << "]";
+}
+
+
+
+void AnimationStep::rules(vector<string>& rules)
+{ 
+	rules_.rules(rules); 
+}
+
+AnimationRules::AnimationRules() 
+{
+}
+
+AnimationRules::~AnimationRules() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void AnimationRules::print(ostream& out)  const
+{
+	for ( vector<AnimationStep*>::const_iterator step = begin(); step != end(); ++step) 
+		out << "step->" << **step << endl;
+//	out << endl;
+}
+
+void AnimationRules::rules(vector<string>& ) const
+{
+}
+
+void AsIsAnimationRules::rules(vector<string>& infos) const
+{
+	infos.push_back("<grib_info key='shortName'/>");
+	infos.push_back("<grib_info key='valid-date'/>");
+	infos.push_back("<grib_info key='level'/>");
+}
+
+
+AsIsAnimationRules::AsIsAnimationRules() : AnimationRules()
+{
+}
+
+AsIsAnimationRules::~AsIsAnimationRules() 
+{
+}
+
+void AnimationRules::add(StepLayer& )
+{
+	assert(false);
+}
+
+void AsIsAnimationRules::add(StepLayer& objects )
+{
+	int i = 0;
+	for (vector<SingleLayer*>::iterator object = objects.firstStep(); object != objects.endStep(); ++object) {
+		int x = size() -1;
+		if ( i > x )  
+			this->push_back(new AnimationStep(*this));
+		(*this)[i]->insert(make_pair(&objects, i));		
+		i++;
+	}
+}
+
+NoOverlayAnimationRules::NoOverlayAnimationRules() : AnimationRules()
+{
+}
+
+NoOverlayAnimationRules::~NoOverlayAnimationRules() 
+{
+}
+
+
+
+void NoOverlayAnimationRules::add(StepLayer& objects )
+{
+    int i = 0;
+	for (vector<SingleLayer*>::iterator object = objects.firstStep(); object != objects.endStep(); ++object) {	
+		    AnimationStep* step = new AnimationStep(*this);
+		    step->insert(make_pair(&objects, i));
+		    push_back(step);	
+
+			i++;
+	}
+
+}
+void NoOverlayAnimationRules::rules(vector<string>& infos) const
+{
+	infos.push_back("<grib_info key='shortName'/>");
+	infos.push_back("<grib_info key='valid-date'/>");
+	infos.push_back("<grib_info key='level'/>");
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void AsIsAnimationRules::print(ostream& out)  const
+{
+	out << "AsIsAnimationRules[" << this->size() << " steps";
+	AnimationRules::print(out);
+	out << "]";
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NoOverlayAnimationRules::print(ostream& out)  const
+{
+	out << "NoOverlayAnimationRules[" << this->size() << " steps";
+	AnimationRules::print(out);
+	out << "]";
+}
+
+
+DateAnimationRules::DateAnimationRules() : AnimationRules()
+{
+}
+
+DateAnimationRules::~DateAnimationRules() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void DateAnimationRules::print(ostream& out)  const
+{
+	out << "DateAnimationRules[" << this->size() << " entries";
+	out << "]";
+}
+
+void DateAnimationRules::rules(vector<string>& infos) const
+{
+	infos.push_back("<grib_info key='shortName'/>");
+	infos.push_back("<grib_info key='valid-date'/>");
+	infos.push_back("<grib_info key='level'/>");
+}
+
+
+
+
+void DateAnimationRules::add(StepLayer& objects )
+{
+    int i = 0;
+	for (vector<SingleLayer*>::iterator object = objects.firstStep(); object != objects.endStep(); ++object) {
+
+		    DateDescription& valid((*object)->timeStamp());
+
+		    map<DateDescription, AnimationStep*>::iterator stepi = steps_.find(valid);
+		    AnimationStep* step;
+		    if (stepi ==  steps_.end() ) {
+		    	step = new AnimationStep(*this);
+		    	steps_.insert(make_pair(valid, step));
+		    }
+		    else {
+		    	stepi->first.update(valid);
+		    	step = stepi->second;
+		    }
+
+		    step->insert(make_pair(&objects, i));
+			i++;
+	}
+	// We rebuild the vector...
+	clear();
+	for ( map<DateDescription, AnimationStep*>::iterator step = steps_.begin(); step != steps_.end(); ++ step) {
+		push_back(step->second);
+	}
+
+
+}
+LevelAnimationRules::LevelAnimationRules() : AnimationRules()
+{
+}
+
+LevelAnimationRules::~LevelAnimationRules()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void LevelAnimationRules::print(ostream& out)  const
+{
+	out << "DateAnimationRules[" << this->size() << " entries";
+	out << "]";
+}
+void LevelAnimationRules::rules(vector<string>& infos) const
+{
+	infos.push_back("<grib_info key='shortName'/>");
+	infos.push_back("<grib_info key='valid-date'/>");
+	infos.push_back("<grib_info key='level'/>");
+}
+
+void LevelAnimationRules::add(StepLayer& objects )
+{
+	int i = 0;
+	for (vector<SingleLayer*>::iterator object = objects.firstStep(); object != objects.endStep(); ++object) {
+
+			LevelDescription& level((*object)->dataLevel());
+
+			map<LevelDescription, AnimationStep*>::iterator stepi = steps_.find(level);
+			AnimationStep* step;
+			if (stepi ==  steps_.end() ) {
+				step = new AnimationStep(*this);
+				steps_.insert(make_pair(level, step));
+			}
+			else {
+				stepi->first.update(level);
+				step = stepi->second;
+			}
+
+			step->insert(make_pair(&objects, i));
+			i++;
+	}
+	// We rebuild the vector...
+	clear();
+	for ( map<LevelDescription, AnimationStep*>::iterator step = steps_.begin(); step != steps_.end(); ++ step) {
+		push_back(step->second);
+	}
+}
+
+
+
diff --git a/src/common/AnimationRules.h b/src/common/AnimationRules.h
new file mode 100644
index 0000000..3de0644
--- /dev/null
+++ b/src/common/AnimationRules.h
@@ -0,0 +1,165 @@
+/*! \file FrameLoop.h
+    \brief Definition of the Template class FrameLoop.
+    
+    Magics Team - ECMWF 2008
+    
+    Started: Fri 29-Aug-2008
+    
+    Changes:
+    
+*/
+
+#ifndef FrameLoop_H
+#define FrameLoop_H
+
+#include "magics.h"
+
+#include "BasicGraphicsObject.h"
+#include "BasicSceneObject.h"
+#include "TagHandler.h"
+#include "Factory.h"
+namespace magics {
+
+class AnimationRules;
+class AsIsAnimationRules;
+
+class TopAxisVisitor;
+class BottomAxisVisitor;
+class LeftAxisVisitor;
+class RightAxisVisitor;
+
+
+
+class AnimationStep : public map<Layer*, int>, public TagHandler
+{
+public:
+	AnimationStep(AnimationRules&);
+	virtual ~AnimationStep();
+
+	void rules(vector<string>&);
+	AnimationRules& rules_;
+	const map<string, string>& label(); 
+	void xResolution(double xres) { xResolution_ = std::min(xResolution_, xres); }
+	void yResolution(double yres) { yResolution_ = std::min(yResolution_, yres); }
+	double xResolution() const { return xResolution_; }
+	double yResolution() const { return yResolution_; }
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	map<string, string>    label_;
+	double       xResolution_;
+	double       yResolution_;
+		  	 
+private:
+	//! Copy constructor - No copy allowed
+	AnimationStep(const AnimationStep&);
+	//! Overloaded << operator to copy - No copy allowed
+	AnimationStep& operator=(const AnimationStep&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AnimationStep& p)
+	{ p.print(s); return s; }
+};
+
+
+
+class AnimationRules : public vector<AnimationStep*>
+{
+public:
+	AnimationRules();
+	virtual ~AnimationRules();
+	virtual void add(StepLayer&);
+	virtual void rules(vector<string>&) const;
+	
+protected:
+	     //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	string labelFormat_;
+	
+private:
+	//! Copy constructor - No copy allowed
+	AnimationRules(const AnimationRules&);
+	//! Overloaded << operator to copy - No copy allowed
+	AnimationRules& operator=(const AnimationRules&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AnimationRules& p)
+		{ p.print(s); return s; }
+};
+
+
+class AsIsAnimationRules : public AnimationRules
+{
+public:
+	AsIsAnimationRules();
+	virtual ~AsIsAnimationRules();
+	
+	void add(StepLayer&);
+	void rules(vector<string>&) const;
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+};
+
+class NoOverlayAnimationRules : public AnimationRules
+{
+public:
+	NoOverlayAnimationRules();
+	virtual ~NoOverlayAnimationRules();
+	
+	void add(StepLayer&);
+	void rules(vector<string>&) const;
+		
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+};
+
+
+class  DateAnimationRules : public AnimationRules
+{
+public:
+	DateAnimationRules();
+	virtual ~DateAnimationRules();
+	void add(StepLayer&);
+	void rules(vector<string>&) const;
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const;
+	map<DateDescription, AnimationStep* > steps_;
+};
+
+class  LevelAnimationRules : public AnimationRules
+{
+public:
+	LevelAnimationRules();
+	virtual ~LevelAnimationRules();
+	void add(StepLayer&);
+	void rules(vector<string>&) const;
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	map<LevelDescription, AnimationStep* > steps_;
+};
+template <>
+class MagTranslator<string, AnimationRules > {
+public:
+	AnimationRules* operator()(const string& val) {
+		return SimpleObjectMaker<AnimationRules >::create(val);
+	}
+
+	AnimationRules* magics(const string& param)
+	{
+		AnimationRules* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+} // namespace magics
+#endif
diff --git a/src/common/Arrow.h b/src/common/Arrow.h
new file mode 100644
index 0000000..c1e585b
--- /dev/null
+++ b/src/common/Arrow.h
@@ -0,0 +1,99 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Arrow.h
+    \brief Definition of the Template class Arrow.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mar-2005
+
+*/
+
+#ifndef Arrow_H
+#define Arrow_H
+
+#include "magics.h"
+
+#include "BasicGraphicsObject.h"
+#include "BaseDriver.h"
+#include "ArrowProperties.h"
+
+namespace magics {
+
+
+class ArrowPoint 
+{
+public:
+	ArrowPoint(double x, double y, const PaperPoint& point) :
+		 x_(x), y_(y), point_(point) {}
+	ArrowPoint(const PaperPoint& point) :
+		 x_(0), y_(0), point_(point) {}
+	double x_;
+	double y_;
+	PaperPoint point_;
+
+	void set(double speed, double direction)
+	{
+		x_ = speed * cos(RAD(270.-direction));
+		y_ = speed * sin(RAD(270.-direction));
+
+	}
+	double norm()  const {return sqrt((x_ * x_) + (y_ * y_));}
+	double angle() const {return atan2(y_,x_);}// 0 = east, clockwise
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream& out) const
+	{
+		out << "Arrow[" << point_.x() << ", " << point_.y() << ", " << x_ << ", " << y_ << "]" << "\n";
+	}
+
+private:	   
+	friend ostream& operator<<(ostream& s,const ArrowPoint& p)
+		{ p.print(s); return s; } 
+};
+
+
+class Arrow: public BasicGraphicsObject, public ArrowProperties, public vector<ArrowPoint> {
+
+public:
+	Arrow() {}
+	virtual ~Arrow() {}
+
+	virtual void redisplay(const BaseDriver& driver) const { driver.redisplay(*this); }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const {}
+
+private:
+	//! Copy constructor - No copy allowed
+	Arrow(const Arrow&);
+	//! Overloaded << operator to copy - No copy allowed
+	Arrow& operator=(const Arrow&);
+
+// -- Friends
+	friend class BaseDriver;
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Arrow& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/ArrowProperties.cc b/src/common/ArrowProperties.cc
new file mode 100644
index 0000000..f785153
--- /dev/null
+++ b/src/common/ArrowProperties.cc
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ArrowProperties.cc
+    \brief Implementation of the Template class Arrow.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 16-Mar-2005
+    
+    Changes:
+    
+*/
+
+#include "ArrowProperties.h"
+#include "OriginMarker.h"
+#include "CalmIndicator.h"
+
+using namespace magics;
+
+ArrowProperties::ArrowProperties() :
+	scale_(0),  crossBoundary_(false), 
+	thickness_(1), style_(M_SOLID), hemisphere_(NORTH), position_(M_TAIL), 
+	originMarker_("none"), originHeight_(0),headIndex_(0),headRatio_(0.3)
+{
+}
+
+void ArrowProperties::copy(const ArrowProperties& from) 
+{
+	scale_         = from.scale_;
+	crossBoundary_ = from.crossBoundary_;
+	thickness_     = from.thickness_;
+	style_         = from.style_;
+	hemisphere_    = from.hemisphere_;
+	position_      = from.position_;
+	originMarker_  = from.originMarker_;
+	originHeight_  = from.originHeight_;
+	headIndex_     = from.headIndex_;
+	headRatio_     = from.headRatio_;
+}
+
+void ArrowProperties::print(ostream& out)  const
+{
+	out << ", scale=" << scale_;
+	out << ", crossBoundary=" << crossBoundary_;
+	out << ", thickness=" << thickness_;
+	out << ", style=" << style_;
+	out << ", hemisphere=" << hemisphere_;
+	out << ", originMarker_=" << originMarker_;
+	out << ", originHeight_=" << originHeight_;
+}
+
diff --git a/src/common/ArrowProperties.h b/src/common/ArrowProperties.h
new file mode 100644
index 0000000..bc2354b
--- /dev/null
+++ b/src/common/ArrowProperties.h
@@ -0,0 +1,98 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ArrowProperties.h
+    \brief Definition of the Template class Arrow.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 16-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ArrowProperties_H
+#define ArrowProperties_H
+
+#include "magics.h"
+#include "Colour.h"
+
+namespace magics {
+
+enum FlagConvention  { SI , KNOTS  };
+class ArrowProperties 
+{
+public:
+	ArrowProperties();
+	virtual ~ArrowProperties(){}
+// Accessors :
+	double getScale() const                { return scale_; }
+	void setScale(double scale)            { scale_ = scale; }
+
+	bool getCrossBoundary() const            { return crossBoundary_; }
+	void setCrossBoundary(bool cross)        { crossBoundary_ = cross; }
+
+	int getThickness() const              { return thickness_; }
+	void setThickness(int thickness)        { thickness_ = thickness; }
+
+	LineStyle getStyle() const               { return style_; }
+	void setStyle(LineStyle style)           { style_ = style; }
+
+	ArrowPosition getArrowPosition() const   { return position_; }
+	void setArrowPosition(ArrowPosition pos) { position_ = pos; }
+
+	void copy(const ArrowProperties&);
+
+	Hemisphere getHemisphere() const          { return hemisphere_; }
+	void setHemisphere(Hemisphere hemisphere) { hemisphere_ = hemisphere; }
+
+	string getOriginMarker() const          { return originMarker_; }
+	void setOriginMarker(const string& marker) { originMarker_ = marker; }
+
+	double getOriginHeight() const          { return originHeight_; }
+	void setOriginHeight(double height)     { originHeight_ = height; }
+
+	void setHeadIndex(int head)		{ headIndex_ =  head; } 
+	int getHeadIndex() const		{ return headIndex_; } 
+
+	void setHeadRatio(double ratio)		{ headRatio_ =  ratio; } 
+	double getHeadRatio() const		{ return headRatio_; } 
+    
+	void setColour(const Colour& colour)		{ colour_ =  colour; } 
+	const Colour& getColour() const		{ return colour_; } 
+protected:
+
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+
+	 double      scale_;
+	 bool          crossBoundary_;
+	 int           thickness_;
+	 LineStyle     style_;
+	 Colour colour_;
+	 Hemisphere    hemisphere_;
+	 ArrowPosition position_;
+	 string        originMarker_;
+	 double      originHeight_;
+	 int           headIndex_;
+	 double        headRatio_;
+};
+}// end namespace
+
+#endif
diff --git a/src/common/AutoLock.h b/src/common/AutoLock.h
new file mode 100755
index 0000000..b41d64a
--- /dev/null
+++ b/src/common/AutoLock.h
@@ -0,0 +1,63 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File AutoLock.h
+// Baudouin Raoult - ECMWF May 96
+
+#ifndef AutoLock_H
+#define AutoLock_H
+
+// The class AutoLock is used to AutoLock a mutex in a multi-threaded
+// environment. AutoLocks are MagExceptions safe.
+
+class AutoLocker {
+public:
+	static void want(void*);
+	static void got(void*);
+	static void release(void*);
+	static void analyse(void*);
+};
+
+template<class T> class AutoLock : public AutoLocker {
+public:
+
+// -- Contructors
+	
+    AutoLock(T& resource) : resource_(resource) 
+							{ want(&resource); resource_.lock(); got(&resource);}
+    AutoLock(T* resource) : resource_(*resource)
+							{ want(resource); resource_.lock(); got(resource);}
+
+// -- Destructor
+
+    ~AutoLock() { release(&resource_); resource_.unlock(); }
+
+private:
+
+// No copy allowed
+
+	AutoLock(const AutoLock<T>&);
+	AutoLock<T>& operator=(const AutoLock<T>&);
+
+// -- Members
+	
+    T& resource_;
+
+};
+
+#endif
diff --git a/src/common/AutoLocker.cc b/src/common/AutoLocker.cc
new file mode 100644
index 0000000..c6be0c8
--- /dev/null
+++ b/src/common/AutoLocker.cc
@@ -0,0 +1,126 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/* #define CHECK_DEAD_LOCKS */
+
+#ifndef   AutoLock_H
+#include "AutoLock.h"
+#endif
+
+#ifndef   Mutex_H
+#include "Mutex.h"
+#endif
+
+#ifndef   MagExceptions_H
+#include "MagExceptions.h"
+#endif
+
+typedef map<void*,pthread_t,less<void*> > GotMap;
+typedef map<pthread_t,void*,less<pthread_t> > WantMap;
+static WantMap*   wantMap = 0;
+static GotMap*   gotMap = 0;
+static Mutex* mutex = 0;
+typedef set<pthread_t,less<pthread_t> > Set;
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static void lock()
+{
+#ifdef CHECK_DEAD_LOCKS
+	 mutex->lock();
+#endif
+}
+
+static void unlock()
+{
+#ifdef CHECK_DEAD_LOCKS
+	mutex->unlock();
+#endif
+}
+
+static void init(void)
+{
+	mutex   = new Mutex;
+	wantMap = new WantMap;
+	gotMap  = new GotMap;
+	pthread_atfork(lock,unlock,unlock);
+}
+
+
+void AutoLocker::want(void* resource)
+{
+#ifdef CHECK_DEAD_LOCKS
+	pthread_once(&once,init);
+	mutex->lock();
+
+	GotMap::iterator i = gotMap->find(resource);
+
+	if( i != gotMap->end())
+	{
+		if((*i).second != pthread_self())
+		{
+			(*wantMap)[pthread_self()] = resource;
+			analyse(resource);
+		}
+	}
+
+	mutex->unlock();
+#endif
+}
+
+void AutoLocker::got(void* resource)
+{
+#ifdef CHECK_DEAD_LOCKS
+	mutex->lock();
+	(*gotMap)[resource] = pthread_self();
+	wantMap->erase(pthread_self());
+	mutex->unlock();
+#endif
+}
+
+void AutoLocker::release(void* resource)
+{
+#ifdef CHECK_DEAD_LOCKS
+	mutex->lock();
+	gotMap->erase(resource);
+	mutex->unlock();
+#endif
+}
+
+static void visit(pthread_t p, Set& s,void *resource)
+{
+	if(s.find(p) != s.end())
+		Panic("Deadlock detected");
+	
+	s.insert(p);
+	
+	GotMap::iterator i = gotMap->find(resource);
+	pthread_t q = (*i).second; // The one with the resource
+
+	WantMap::iterator j = wantMap->find(q);
+	if(j != wantMap->end())
+		visit(q,s,(*j).second);
+
+	s.erase(p);
+}
+
+void AutoLocker::analyse(void *resource)
+{
+	Set set;
+	visit(pthread_self(),set,resource);
+}
diff --git a/src/common/BackgroundColour.h b/src/common/BackgroundColour.h
new file mode 100644
index 0000000..edc5de9
--- /dev/null
+++ b/src/common/BackgroundColour.h
@@ -0,0 +1,65 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BackgroundColour.h
+    \brief Definition of Colour class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started 2002
+
+*/
+#ifndef BackgroundColour_H
+#define BackgroundColour_H
+
+
+#include "Colour.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+
+namespace magics {
+
+class BackgroundColour : public Colour
+{
+public:
+	BackgroundColour() {}
+	BackgroundColour(const string& colour) : Colour(colour) {}
+	BackgroundColour* clone() const { return new BackgroundColour(*this); }
+};
+
+template<>
+class MagTranslator<string, BackgroundColour> { 
+public:
+	BackgroundColour* operator()(const string& val )
+	{
+		 if (Colour::valid(val) ) return new BackgroundColour(val);
+		 if ( val == "background_colour" ) return new BackgroundColour();
+		 throw NoFactoryException(val);
+	}
+
+	BackgroundColour* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/BaseParameter.cc b/src/common/BaseParameter.cc
new file mode 100644
index 0000000..d562a75
--- /dev/null
+++ b/src/common/BaseParameter.cc
@@ -0,0 +1,54 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseParameter.cc
+    \brief Definition of Parameter base class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+
+
+#include "BaseParameter.h"
+#include "ParameterManager.h"
+
+using namespace magics;
+
+
+
+
+BaseParameter::BaseParameter(const string& name)  : name_(lowerCase(name))
+{
+   ParameterManager::add(name_, this);
+}
+
+
+BaseParameter::~BaseParameter() 
+{
+}
+
+	
+void BaseParameter::print(ostream& out)  const
+{
+	out << name_ << "[]";
+}
+
diff --git a/src/common/BaseParameter.h b/src/common/BaseParameter.h
new file mode 100644
index 0000000..b30bb64
--- /dev/null
+++ b/src/common/BaseParameter.h
@@ -0,0 +1,245 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseParameter.h
+    \brief Definition of Parameter base class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+
+#ifndef BaseParameter_H
+#define BaseParameter_H
+
+
+#include "magics.h"
+#include "MagException.h"
+#include <PaperPoint.h>
+#include "Matrix.h"
+
+#if MAGICS_CAIRO
+ #include "cairo.h"
+ typedef cairo_t* CairoPtr;
+#endif
+
+#if MAGICS_QT
+ #include "Qt/qwidget.h"
+ #include "Qt/qgraphicsscene.h"	
+ typedef QWidget* QWidgetPtr;
+ typedef QGraphicsScene* QGraphicsScenePtr;
+#endif
+
+#ifdef LATER
+#include "grib_api.h"
+typedef grib_handle* GribHandlePtr ;
+#endif
+
+#ifndef MAGICS_Exception
+#include <MagLog.h>
+#endif
+
+namespace magics {
+
+class MistmatchType : public MagicsException
+{
+public:
+	MistmatchType(const string& name, const string& type, const string& wait) : 
+		MagicsException("Parameter " + name + ": type mismatch -> type received \"" + type + "\", expected type \"" + wait + "\" - setting ignored!") {}
+};
+
+
+
+class BaseParameter {
+
+public:
+	BaseParameter(const string& name);
+	virtual ~BaseParameter();
+	virtual void reset() = 0;
+	virtual void setLocal(const BaseParameter*) = 0;
+	virtual void resetLocal() = 0;
+	virtual BaseParameter* clone() = 0;
+	const string& name() const { return name_; }
+
+#ifdef MAGICS_EXCEPTION
+	virtual void set(const double&) { throw MistmatchType(name_, "real", type()); }
+	virtual void setLocal(const double&) { throw MistmatchType(name_, "real", type()); }
+	virtual void get(double&) const { throw MistmatchType(name_, "real", type()); }
+	
+	virtual void set(bool) { throw MistmatchType(name_, "bool", type()); }
+	virtual void setLocal(bool) { throw MistmatchType(name_, "bool", type()); }
+	virtual void get(bool&) const { throw MistmatchType(name_, "bool", type()); }
+
+	virtual void set(const magvector<double>&) { throw MistmatchType(name_, "array of reals", type()); }
+	virtual void setLocal(const magvector<double>&) { throw MistmatchType(name_, "array of reals", type()); }
+	virtual void get(magvector<double>&) const { throw MistmatchType(name_, "array of reals", type()); }
+
+	virtual void set(const int&) { throw MistmatchType(name_, "integer", type()); }
+	virtual void setLocal(const int&) { throw MistmatchType(name_, "integer", type()); }
+	virtual void get(int&) const { throw MistmatchType(name_, "integer", type()); }
+
+	virtual void set(const magvector<int>&) { throw MistmatchType(name_, "integer", type()); }
+	virtual void setLocal(const magvector<int>&) { throw MistmatchType(name_, "integer", type()); }
+	virtual void get(magvector<int>&) const { throw MistmatchType(name_, "integer", type()); }
+
+	virtual void set(const string&) { throw MistmatchType(name_, "string", type()); }
+	virtual void setLocal(const string&) { throw MistmatchType(name_, "string", type()); }
+	virtual void get(string&) const { throw MistmatchType(name_, "string", type()); }
+
+	virtual void set(const magvector<string>&) { throw MistmatchType(name_, "stringarray", type()); }
+	virtual void setLocal(const magvector<string>&) { throw MistmatchType(name_, "stringarray", type()); }
+	virtual void get(magvector<string>&) const { throw MistmatchType(name_, "stringarray", type()); }
+
+	virtual void set(LineStyle) { throw MistmatchType(name_, "LineStyle", type()); }
+	virtual void setLocal(LineStyle) { throw MistmatchType(name_, "LineStyle", type()); }
+	virtual void get(LineStyle&) const { throw MistmatchType(name_, "LineStyle", type()); }
+	
+	virtual void set(DisplayType) { throw MistmatchType(name_, "LineStyle", type()); }
+	virtual void setLocal(DisplayType) { throw MistmatchType(name_, "LineStyle", type()); }
+	virtual void get(DisplayType&) const { throw MistmatchType(name_, "LineStyle", type()); }
+
+	virtual void set(Justification) { throw MistmatchType(name_, "Justification", type()); }
+	virtual void setLocal(Justification) { throw MistmatchType(name_, "LineStyle", type()); }
+	virtual void get(Justification&) const { throw MistmatchType(name_, "Justification", type()); }
+	
+	virtual void set(ListPolicy) { throw MistmatchType(name_, "ListPolicy", type()); }
+	virtual void setLocal(ListPolicy) { throw MistmatchType(name_, "LineStyle", type()); }
+	virtual void get(ListPolicy&) const { throw MistmatchType(name_, "ListPolicy", type()); }
+	
+	virtual void set(AxisAutomaticSetting) { throw MistmatchType(name_, "AxisAutomaticSetting", type()); }
+	virtual void setLocal(AxisAutomaticSetting) { throw MistmatchType(name_, "AxisAutomaticSetting", type()); }
+	virtual void get(AxisAutomaticSetting&) const { throw MistmatchType(name_, "AxisAutomaticSetting", type()); }
+	
+	virtual void set(ArrowPosition) { throw MistmatchType(name_, "ArrowPosition", type()); }
+	virtual void setLocal(ArrowPosition) { throw MistmatchType(name_, "ArrowPosition", type()); }
+	virtual void get(ArrowPosition&) const { throw MistmatchType(name_, "ArrowPosition", type()); }
+	
+	virtual void set(const Matrix&) { throw MistmatchType(name_, "Matrix", type()); }
+	virtual void setLocal(const Matrix&) { throw MistmatchType(name_, "Matrix", type()); }
+	virtual void get(Matrix&) const { throw MistmatchType(name_, "Matrix", type()); }
+#else	
+	virtual void set(const double&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+	virtual void setLocal(const double&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+	virtual void get(double&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+
+	virtual void set(bool) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "bool", type()) << "\n";}
+	virtual void setLocal(bool) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "bool", type()) << "\n"; }
+	virtual void get(bool&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "bool", type()) << "\n"; }
+
+	virtual void set(const magvector<double>&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+	virtual void setLocal(const magvector<double>&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+	virtual void get(magvector<double>&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+
+	virtual void set(const int&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "integer", type()) << "\n"; }
+	virtual void setLocal(const int&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+	virtual void get(int&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "integer", type()) << "\n"; }
+
+	virtual void set(const magvector<int>&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "real", type()) << "\n"; }
+	virtual void setLocal(const magvector<int>&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "integer", type()) << "\n"; }
+	virtual void get(magvector<int>&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "integer", type()) << "\n"; }
+
+	virtual void set(const string&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "string", type()) << "\n"; }
+	virtual void setLocal(const string&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "string", type()) << "\n"; }
+	virtual void get(string&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "string", type()) << "\n"; }
+
+	virtual void set(const magvector<string>&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "string", type()) << "\n"; }
+	virtual void setLocal(const magvector<string>&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "string", type()) << "\n"; }
+	virtual void get(magvector<string>&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "string", type()) << "\n"; }
+
+	virtual void set(LineStyle) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "LineStyle", type()) << "\n"; }
+	virtual void setLocal(LineStyle) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "LineStyle", type()) << "\n"; }
+	virtual void get(LineStyle&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "LineStyle", type()) << "\n"; }
+
+	virtual void set(Justification) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "Justification", type()) << "\n"; }
+	virtual void setLocal(Justification) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "Justification", type()) << "\n"; }
+	virtual void get(Justification&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "Justification", type()) << "\n"; }
+	
+	virtual void set(ListPolicy) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "ListPolicy", type()) << "\n"; }
+	virtual void setLocal(ListPolicy) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "Justification", type()) << "\n"; }
+	virtual void get(ListPolicy&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "ListPolicy", type()) << "\n"; }
+	
+	virtual void set(AxisAutomaticSetting) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "AxisAutomaticSetting", type()) << "\n"; }
+	virtual void setLocal(AxisAutomaticSetting) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "AxisAutomaticSetting", type()) << "\n"; }
+	virtual void get(AxisAutomaticSetting&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "AxisAutomaticSetting", type()) << "\n"; }
+			
+
+	virtual void set(ArrowPosition) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "ArrowPosition", type()) << "\n"; }
+	virtual void setLocal(ArrowPosition) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "ArrowPosition", type()) << "\n"; }	
+	virtual void get(ArrowPosition&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "ArrowPosition", type()) << "\n"; }
+	
+	virtual void set(const Matrix&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "Matrix", type()) << "\n"; }
+	virtual void setLocal(Matrix&) { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "ArrowPosition", type()) << "\n"; }	
+	virtual void get(Matrix&) const { MagLog::dev()<< "Magics-warning:" << MistmatchType(name_, "Matrix", type()) << "\n"; }
+#endif
+	virtual string type() const = 0;
+	
+
+
+#if MAGICS_QT
+	virtual void set(const QWidgetPtr&) { throw MistmatchType(name_, "qt_widget", type()); }
+	virtual void get(QWidgetPtr&) const { throw MistmatchType(name_, "qt_widget", type()); }
+	string getType(QWidgetPtr) const { return "qt_widget"; }
+
+	virtual void set(const QGraphicsScenePtr&) { throw MistmatchType(name_, "qt_scene", type()); }
+	virtual void get(QGraphicsScenePtr&) const { throw MistmatchType(name_, "qt_scene", type()); }
+	string getType(QGraphicsScenePtr) const { return "qt_scene"; }
+#endif
+
+#if MAGICS_CAIRO
+	virtual void set(const CairoPtr&) { throw MistmatchType(name_, "cairo_context", type()); }
+	virtual void get(CairoPtr&) const { throw MistmatchType(name_, "cairo_context", type()); }
+	string getType(CairoPtr) const { return "cairo_context"; }
+#endif
+
+#ifdef LATER
+	virtual void set(const GribHandlePtr&) { throw MistmatchType(name_, "grib_handle", type()); }
+	virtual void get(GribHandlePtr&) const { throw MistmatchType(name_, "grib_handle", type()); }
+	string getType(GribHandlePtr&) const { return "grib_handle"; }
+#endif
+
+	string getType(const string&) const { return "string"; }
+	string getType(const int&) const { return "integer"; }
+	string getType(const double&) const { return "real"; }
+	string getType(const magvector<string>&) const { return "array of string"; }
+	string getType(const magvector<int>&) const { return "array of integer"; }
+	string getType(const magvector<double>&) const { return "array of real"; }
+	string getType(LineStyle) const { return "LineStyle"; }
+	string getType(AxisAutomaticSetting) const { return "AxisAutomaticSetting"; }
+	string getType(Justification) const { return "Justification"; }
+	string getType(ArrowPosition) const { return "ArrowPosition"; }
+	string getType(Matrix) const { return "2DMatrix"; }
+
+protected:
+	virtual void print(ostream&) const;
+	string name_;
+     
+private:
+	// No copy allowed
+	BaseParameter(const BaseParameter&);
+	BaseParameter& operator=(const BaseParameter&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const BaseParameter& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/BasePointsHandler.cc b/src/common/BasePointsHandler.cc
new file mode 100644
index 0000000..0bd575f
--- /dev/null
+++ b/src/common/BasePointsHandler.cc
@@ -0,0 +1,42 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BasePointsHandler.h
+    \brief Definition of the Template base class AbstractPoints.
+
+    Magics Team - ECMWF 2004
+
+    Started: Fri 16-Jan-2004
+
+    Changes:
+
+*/
+
+#include "BasePointsHandler.h"
+
+using namespace magics;
+
+MinMaxHelper::MinMaxHelper(AbstractPoints& points):
+            minX_(INT_MAX), maxX_(INT_MIN),
+            minY_(INT_MAX), maxY_(INT_MIN),
+            min_(INT_MAX), max_(INT_MIN)
+    {
+            points.for_each(*this);
+            points.setToFirst();
+
+    }
diff --git a/src/common/BasePointsHandler.h b/src/common/BasePointsHandler.h
new file mode 100644
index 0000000..e58e340
--- /dev/null
+++ b/src/common/BasePointsHandler.h
@@ -0,0 +1,175 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BasePointsHandler.h
+    \brief Definition of the Template base class AbstractPoints.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef AbstractPoints_H
+#define AbstractPoints_H
+
+#include "magics.h"
+#include "UserPoint.h"
+
+#include "VectorOfPointers.h"
+
+namespace magics {
+
+class AbstractPoints;
+
+
+class MinMaxHelper
+{
+public:
+    MinMaxHelper(AbstractPoints& points);
+    void operator()(const UserPoint& point)
+    {
+        if (point.x() < minX_ ) minX_ = point.x();
+        if (point.x() > maxX_ ) maxX_ = point.x();
+        if (point.y() < minY_ ) minY_ = point.y();
+        if (point.y() > maxY_ ) maxY_ = point.y();
+        
+        if (point.value() < min_ ) min_ = point.value();
+        if (point.value() > max_ ) max_ = point.value();
+     
+    }
+    double minX_;
+    double maxX_;
+    double minY_;
+    double maxY_;
+    double min_;
+    double max_;
+};
+
+class BasePointsHandler 
+{
+public:
+	BasePointsHandler() {}
+	virtual ~BasePointsHandler() { };
+	virtual double minX() const { return INT_MIN; }
+	virtual double minY() const { return INT_MIN; }
+	virtual double maxX() const { return INT_MAX; }
+	virtual double maxY() const { return INT_MAX; }
+	virtual double min() const  { return INT_MIN; }
+	virtual double max() const  { return INT_MIN; }
+};
+
+
+class AbstractPoints : public BasePointsHandler {
+
+public:
+	AbstractPoints() : helper_(0) {};
+	virtual ~AbstractPoints() { if (helper_) delete helper_; };
+	//! Method to go through the collection. The Class 0 needs to define 
+	// void operator()(const P&)
+	template <class O>
+	void for_each(O& object)
+	{
+		setToFirst();
+		while (more()) {
+		  object(current());
+		  advance();
+		}  
+	}
+	//! Method to set the current position to the first point.(abstract)
+	virtual void setToFirst()  {assert(false);};
+	//! Method to test the end of collection.
+	virtual bool more()  {assert(false);return false;};
+	//! Method to return the current value
+	virtual const UserPoint& current()  {assert(false);};
+	//! Method to advance
+	virtual void advance()  {assert(false);};
+
+	virtual int size()  {
+		points_ = 0;
+		for_each(*this);
+		return points_;
+	}
+
+	virtual double minX()  {
+		if ( !helper_ ) helper_ = new MinMaxHelper(*this);
+		return helper_->minX_;
+	}
+	virtual double minY()  {
+		if ( !helper_ ) helper_ = new MinMaxHelper(*this);
+		return helper_->minY_;
+	}
+	virtual double maxX()  {
+		if ( !helper_ ) helper_ = new MinMaxHelper(*this);
+		return helper_->maxX_;
+	}
+	virtual double maxY()  {
+		if ( !helper_ ) helper_ = new MinMaxHelper(*this);
+		return helper_->maxY_;
+	}
+	virtual double min()  {
+		if ( !helper_ ) helper_ = new MinMaxHelper(*this);
+		return helper_->min_;
+	}
+	virtual double max()  {
+		if ( !helper_ ) helper_ = new MinMaxHelper(*this);
+		return helper_->max_;
+	}
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { out << "AbstractPoints"; }
+	void operator()(const UserPoint&) const { points_++; }
+	mutable MinMaxHelper* helper_;
+	mutable int points_;
+
+private:
+	//! Copy constructor - No copy allowed
+	AbstractPoints(const AbstractPoints&);
+	//! Overloaded << operator to copy - No copy allowed
+	AbstractPoints& operator=(const AbstractPoints&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AbstractPoints& p)
+		{ p.print(s); return s; }
+};
+
+
+class PointsList : public vector<UserPoint*>, public AbstractPoints {
+
+public:
+	PointsList()  {}
+	~PointsList() {}
+	// Implements the AbstractPoints interface
+	virtual void setToFirst() 	{ current_ = this->begin(); }
+	virtual bool more() 	{ return current_ != this->end(); }
+	virtual UserPoint& current() { return **current_; }
+	virtual void advance() 	{ current_++; }
+	virtual int size() 	{ return vector<UserPoint*>::size(); }
+
+
+protected :
+	mutable  vector<UserPoint*>::const_iterator current_;
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/BinaryObject.cc b/src/common/BinaryObject.cc
new file mode 100644
index 0000000..b7cba5d
--- /dev/null
+++ b/src/common/BinaryObject.cc
@@ -0,0 +1,52 @@
+/*! \file BinaryObject.cc
+    \brief Implementation of the Template class BinaryObject.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Fri 8-Jan-2010
+    
+    Changes:
+    
+*/
+
+#include "BinaryObject.h"
+#include "BaseDriver.h"
+#include "SceneVisitor.h"
+#include "Layer.h"
+
+using namespace magics;
+
+BinaryObject::BinaryObject() 
+{
+}
+
+BinaryObject::~BinaryObject() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void BinaryObject::print(ostream& out)  const
+{
+	out << "BinaryObject[";
+	BinaryObjectAttributes::print(out);
+	out << "]";
+}
+
+void  BinaryObject::redisplay(const BaseDriver& driver) const
+{
+	driver.redisplay(*this);
+}
+
+void BinaryObject::visit(SceneLayer& layer)
+{
+	// First we create the layer!
+	// and push It to the parent layer! 
+	StaticLayer* bin = new StaticLayer(this);
+	bin->name(path_);
+	layer.add(bin);
+	BinaryObject* binary = new BinaryObject();
+	binary->copy(*this);
+	bin->add(binary);
+}
diff --git a/src/common/BinaryObject.h b/src/common/BinaryObject.h
new file mode 100644
index 0000000..7b831cf
--- /dev/null
+++ b/src/common/BinaryObject.h
@@ -0,0 +1,67 @@
+/*! \file BinaryObject.h
+    \brief Definition of the Template class BinaryObject.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Fri 8-Jan-2010
+    
+    Changes:
+    
+*/
+
+#ifndef BinaryObject_H
+#define BinaryObject_H
+
+#include "magics.h"
+
+#include "BasicGraphicsObject.h"
+#include "BasicSceneObject.h"
+#include "BinaryObjectAttributes.h"
+
+namespace magics {
+
+class BaseDriver;
+class SceneLayer;
+
+class BinaryObject: 
+     public BasicGraphicsObject,
+     public BasicSceneObject,
+     public BinaryObjectAttributes 
+{
+public:
+	BinaryObject();
+	virtual ~BinaryObject();
+	void redisplay(const BaseDriver&) const;
+ 
+	void visit(SceneLayer&);
+    
+	void set(const map<string, string>& map ) { BinaryObjectAttributes::set(map); }
+	void set(const XmlNode& node ) { BinaryObjectAttributes::set(node); }
+	const string& getPath() const
+			{ return path_; }
+
+
+	double getTransparency() const { return transparency_; }
+	int getMgb_x() const { return mgb_x_; }
+	int getMgb_y() const { return mgb_y_; }
+	int getMgb_width() const { return mgb_width_; }
+	int getMgb_height() const { return mgb_height_; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	BinaryObject(const BinaryObject&);
+	//! Overloaded << operator to copy - No copy allowed
+	BinaryObject& operator=(const BinaryObject&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BinaryObject& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/CartesianTransformation.cc b/src/common/CartesianTransformation.cc
new file mode 100644
index 0000000..4f14489
--- /dev/null
+++ b/src/common/CartesianTransformation.cc
@@ -0,0 +1,242 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CartesianTransformation.cc
+    \brief Implementation of the Template class CartesianTransformation.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+
+#include "CartesianTransformation.h"
+#include "Layout.h"
+#include "MetaData.h"
+#include "Polyline.h"
+#include "ParameterSettings.h"
+#include "MagJSon.h"
+
+using namespace magics;
+
+
+CartesianTransformation::CartesianTransformation() 
+{
+	dataReferenceX_ =  x_->reference();
+	dataReferenceY_ =  y_->reference();
+	referenceX_ =  x_->reference();
+	referenceY_ =  y_->reference();
+	topAxis_ = false;
+	coordinateType_=XyType;
+}
+
+CartesianTransformation::~CartesianTransformation() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void CartesianTransformation::print(ostream& out)  const
+{
+	out << "CartesianTransformation[";
+	CartesianTransformationAttributes::print(out);
+	out << "]";
+}
+
+
+static void niceAdjust(double& min, double& max)
+{
+	float inc;
+	int nb = 5;
+	float step;
+	float log, ws;
+
+	while (nb < 20) {
+		step = (max-min)/nb;
+		log = log10(step);
+		ws = pow(10., int(log));
+		inc = ceil(step/ws)*ws;
+		MagLog::dev() << "Automatic method ---> increment = " << inc << " ---> try base=" << inc/ws << endl;
+		if ( inc/ws == 1 || inc/ws == 2 || inc/ws == 5 || inc/ws == 10 ) {
+			MagLog::dev() << "Automatic method ---> increment " << inc << " OK! " << endl;
+			break;
+		}
+		nb++;
+		
+	}
+	
+	float first = floor(min/inc) *inc;
+	vector<float> values;
+    
+     
+	for (float val = first;  val <= max +inc; val += inc) {
+        	values.push_back(val);
+	}
+	
+	if ( values.empty() ) {
+		MagLog::warning() << " No input data --> return to default\n"; 
+		min = 0;
+		max = 100;
+		return;
+	}
+	min = *std::min_element(values.begin(), values.end());
+	max = *std::max_element(values.begin(), values.end());
+}
+
+void CartesianTransformation::adjustXAxis(Layout& layout) const
+{
+	MagLog::dev() << "CartesianTransformation::adjustXAxis()--->[" << dataMinX_ << ", " << dataMaxX_ << "]\n";
+	if (  dataMinX_ == x_->min() && dataMaxX_ == x_->max() ) return;
+	if ( dataReferenceX_ == "" ) niceAdjust(dataMinX_, dataMaxX_);
+	MagLog::dev() << "CartesianTransformation::adjustXAxis()--->[" << dataMinX_ << ", " << dataMaxX_ << "]\n";
+	
+	if (dataMaxX_ - dataMinX_ < 4 ) dataMaxX_ = dataMinX_ + 4;// this needs to be done with more care later!
+	// Should become a user option...
+	const_cast<CartesianTransformation*>(this)->x_->min(dataMinX_);
+	const_cast<CartesianTransformation*>(this)->x_->max(dataMaxX_);
+	
+	(*this)(layout);
+}
+
+
+void CartesianTransformation::adjustYAxis(Layout& layout) const
+{
+	MagLog::dev() << "CartesianTransformation::adjustYAxis()--->[" << dataMinY_ << ", " << dataMaxY_ << "]\n";
+	if (  dataMinY_ == y_->min() && dataMaxY_ == y_->max() ) return;
+	if ( dataReferenceY_ == "" ) niceAdjust(dataMinY_, dataMaxY_);
+	MagLog::dev() << "CartesianTransformation::adjustYAxis()--->[" << dataMinY_ << ", " << dataMaxY_ << "]\n";
+	if (dataMaxY_ - dataMinY_ < 4) dataMaxY_ = dataMinY_ + 4; // this needs to be done with more care later!
+	// Should become a user option...
+	const_cast<CartesianTransformation*>(this)->y_->min(dataMinY_);
+	const_cast<CartesianTransformation*>(this)->y_->max(dataMaxY_);
+	const_cast<CartesianTransformation*>(this)->referenceY_ = dataReferenceY_;
+	(*this)(layout);
+	
+}
+
+
+MAGICS_NO_EXPORT void CartesianTransformation::operator()(Layout& ) const
+{
+	/*
+	if (layout["drawing_area"]) layout["drawing_area"]->setCoordinates(x_->minpc(), x_->maxpc(), y_->minpc(), y_->maxpc());
+	if (layout["top_comment_box"]) layout["top_comment_box"]->setCoordinates(x_->minpc(), x_->maxpc(), -10, 10);
+	if (layout["bottom_comment_box"]) layout["bottom_comment_box"]->setCoordinates(x_->minpc(), x_->maxpc(), -10, 10);
+	if (layout["left_comment_box"]) layout["left_comment_box"]->setCoordinates(-10, 10, y_->minpc(), y_->maxpc());
+	if (layout["right_comment_box"]) layout["right_comment_box"]->setCoordinates(-10, 10, y_->minpc(), y_->maxpc());
+	if (layout["title"]) layout["title"]->setCoordinates(0, 100, 0, 100);
+	if (layout["legend"]) layout["legend"]->setCoordinates(0, 100, 0, 100);
+	*/
+}
+void CartesianTransformation::aspectRatio(double& width, double& height)
+{
+
+	double w = getAbsoluteMaxPCX() - getAbsoluteMinPCX();
+	double h = getAbsoluteMaxPCY() - getAbsoluteMinPCY();
+	return;
+		if ( w/h >= width/height) {
+			double nh = (h/w) * width;
+			if ( nh <= height) {
+				height = nh;
+			}
+			else {
+				width = (w/h) * height;			
+			}
+		}
+		else 
+			width = (w/h) * height;
+}
+
+void CartesianTransformation::visit(MetaDataVisitor& visitor,
+		double left, double top,
+		double width, double height,
+		double img_width, double img_height)
+ {
+         ostringstream java;
+         double w = getMaxPCX() - getMinPCX();
+         double h = getMaxPCY() - getMinPCY();
+         java << "{";
+         java << "\"name\" : \"cartesian\",";
+
+         java << "\"top\" : \"" << top <<  "\",";
+         java << "\"left\" : \"" << left <<  "\",";
+         java << "\"width\" : \"" << width <<  "\",";
+         java << "\"height\" : \"" << height <<  "\",";
+         java << "\"img_width\" : \"" << img_width <<  "\",";
+         java << "\"img_height\" : \"" << img_height <<  "\",";
+         java << "\"pcxmin\" : \"" << getMinPCX() <<  "\",";
+         java << "\"pcymin\" : \"" << getMinPCY() <<  "\",";
+         java << "\"pcwidth\" : \"" << w <<  "\",";
+         java << "\"pcheight\" : \"" << h <<  "\"";
+         ostringstream def;
+         CartesianTransformationAttributes::toxml(def);
+         java << ",\"subpage_map_projection\":" << def.str() << endl;
+         java << "}";
+         visitor.add("projection", java.str());
+
+ }
+
+void CartesianTransformation::boxes() const
+{
+	if ( !PCEnveloppe_->empty() )
+		return;
+
+	PCEnveloppe_->box(PaperPoint(x_->minpc(), y_->minpc()), PaperPoint(x_->maxpc(), y_->maxpc()));
+}
+
+void CartesianTransformation::getNewDefinition(const UserPoint& ll, const UserPoint& ur, string& out) const
+{
+	map<string, string> def;
+	def["subpage_map_projection"] = "cartesian";
+	x_->getNewDefinition(ll, ur, def);
+	y_->getNewDefinition(ll, ur, def);
+	::toxml(out, def);
+
+	out = "{" + out + "}";
+
+	MagJSon helper;
+
+	helper.interpret(out);
+
+
+
+}
+
+void CartesianTransformation::setDefinition(const string& json)
+{
+	if (json.empty())
+		return;
+
+
+
+	MagJSon helper;
+	helper.interpret(json);
+
+	XmlNode node = **helper.tree_.firstElement();
+
+	node.name("cartesian");
+
+
+	set(node);
+
+
+
+}
diff --git a/src/common/CartesianTransformation.h b/src/common/CartesianTransformation.h
new file mode 100644
index 0000000..a207465
--- /dev/null
+++ b/src/common/CartesianTransformation.h
@@ -0,0 +1,168 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CartesianTransformation.h
+    \brief Definition of the Template class CartesianTransformation.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef CartesianTransformation_H
+#define CartesianTransformation_H
+
+#include "magics.h"
+
+#include "Transformation.h"
+#include "CartesianTransformationAttributes.h"
+
+namespace magics { 
+class XmlNode;
+
+class CartesianTransformation: public Transformation, public CartesianTransformationAttributes {
+
+public:
+	CartesianTransformation();
+	virtual ~CartesianTransformation();
+    virtual void operator()(Layout&) const;
+    void init() {
+    	x_->set();
+    	y_->set();
+    }
+    virtual void toxml(ostream& out) const { CartesianTransformationAttributes::toxml(out); }
+    virtual void set(const map<string, string>& map) { CartesianTransformationAttributes::set(map); }
+    virtual void set(const XmlNode& node) { CartesianTransformationAttributes::set(node); }
+    virtual bool accept(const string& node) { return CartesianTransformationAttributes::accept(node); }
+	virtual double x(double x) const { return (*x_)(x); }
+	virtual double y(double y) const { return (*y_)(y); }
+	virtual double rx(double x) const { return (*x_).revert(x); }
+	virtual double ry(double y) const { return (*y_).revert(y); }
+	
+	virtual PaperPoint operator()(const UserPoint& xy) const 
+                 { return PaperPoint((*x_)(xy.x()), (*y_)(xy.y()),  xy.value()); }
+		
+   void aspectRatio(double&, double&);
+
+    virtual Transformation* clone() const {
+		CartesianTransformation* object = new CartesianTransformation();
+		object->copy(*this);
+		return object;
+	}
+	
+	virtual void adjustXAxis(Layout& layout) const;
+	virtual void adjustYAxis(Layout& layout) const;
+	
+	virtual double getMinX() const { return x_->min(); }
+	virtual double getMaxX() const { return x_->max(); }
+	virtual double getMinY() const { return y_->min(); }
+	virtual double getMaxY() const { return y_->max(); }
+
+	virtual double getMinPCX() const { return x_->minpc(); }
+	virtual double getMaxPCX() const { return x_->maxpc(); }
+	virtual double getMinPCY() const { return y_->minpc(); }
+	virtual double getMaxPCY() const { return y_->maxpc(); }
+	
+	double x(const string& val) const { return (*x_)(val); }
+	double y(const string& val) const { return (*y_)(val); }
+
+	
+	virtual void setMinX(double x)   { x_->min(x); }
+	virtual void setMaxX(double x)   { x_->max(x); }
+	virtual void setMinY(double y)   { y_->min(y); }
+	virtual void setMaxY(double y)   { y_->max(y); }
+
+    virtual const string& getReferenceX() const  { referenceX_ = x_->reference(); return referenceX_;}
+    virtual const string& getReferenceY() const  { referenceY_ = y_->reference(); return referenceY_; }
+
+	
+	virtual void setDataMinX(double minx) const { x_->dataMin(minx); }
+	virtual void setDataMaxX(double maxx) const { x_->dataMax(maxx); }
+	virtual void setDataMinY(double miny) const { y_->dataMin(miny); }
+	virtual void setDataMaxY(double maxy) const { y_->dataMax(maxy); }
+	
+	vector<double> getDataVectorMinX() const  { return  x_->mins(); }
+	vector<double> getDataVectorMaxX() const { return  x_->maxs(); }
+	vector<double> getDataVectorMinY() const  { return  y_->mins(); }
+	vector<double> getDataVectorMaxY() const { return  y_->maxs(); }
+	
+
+	Polyline& getPCBoundingBox()   const  {  boxes(); return *PCEnveloppe_; }
+
+	void boxes() const;
+
+
+    virtual void setDataMinX(double minx, const string& ref) const { 
+    	dataMinX_ = std::min(minx, dataMinX_);
+    	x_->dataMin(dataMinX_, ref); 
+    	referenceX_ = x_->reference();
+    }
+	virtual void setDataMaxX(double maxx, const string& ref) const { 
+		dataMaxX_ = std::max(maxx, dataMaxX_);
+		x_->dataMax(dataMaxX_, ref); 
+		referenceX_ = x_->reference();
+	}
+	virtual void setDataMinY(double miny, const string& ref) const { 
+		dataMinY_ = std::min(miny, dataMinY_);
+		y_->dataMin(dataMinY_, ref); 
+		referenceY_ = y_->reference();
+	}
+	virtual void setDataMaxY(double maxy, const string& ref) const { 
+		dataMaxY_ = std::max(maxy, dataMaxY_);
+		y_->dataMax(dataMaxY_, ref); 
+		referenceY_ = y_->reference();
+	}; 
+	virtual void setAutomaticX(bool automatic) { x_->automatic(automatic); }
+		virtual void setAutomaticY(bool automatic) { y_->automatic(automatic); }
+		virtual bool getAutomaticX() const { return  x_->automatic(); } 
+		virtual bool getAutomaticY() const { return y_->automatic(); }
+	
+	virtual bool in(double x, double y) const 
+         {  double minx = std::min(x_->min(), x_->max() );
+         	double maxx = std::max(x_->min(), x_->max() );
+         	double miny = std::min(y_->min(), y_->max() );
+         	double maxy = std::max(y_->min(), y_->max() );
+         	return ( minx <= x && x <=  maxx && miny <= y && y <= maxy ); }
+	
+	string xAxisType() const { return x_->type(); }
+	   string yAxisType() const { return y_->type(); }
+	void visit(MetaDataVisitor&, double, double, double, double,double, double);
+	void getNewDefinition(const UserPoint&, const UserPoint&, string&) const;
+	void setDefinition(const string&);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	CartesianTransformation(const CartesianTransformation&);
+    //! Overloaded << operator to copy - No copy allowed
+	CartesianTransformation& operator=(const CartesianTransformation&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CartesianTransformation& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Clipper.h b/src/common/Clipper.h
new file mode 100644
index 0000000..8b4be54
--- /dev/null
+++ b/src/common/Clipper.h
@@ -0,0 +1,362 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Clipper.h
+    \brief Definition of the clipping.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: 2004
+
+*/ 
+
+#ifndef Clipper_H
+#define Clipper_H
+
+#include "magics.h"
+#include "PolyCoast.h"
+#include "Transformation.h"
+
+namespace magics {
+
+template <class P> 
+class Push 
+{
+public:
+	Push(Polyline& poly) : poly_(poly) {}
+	~Push() {}
+	void operator()(P& point) { poly_.push_back(point); }
+protected:
+	Polyline& poly_;
+};
+
+
+template <class P>
+bool clockwise(Polyline& c) {
+        double area = 0 ;
+        if(c.size()) c.push_back(c[0]);
+
+        for(unsigned int j = 0; j < c.size(); j++)
+        {
+                if(j) area += ( c[j-1].x() * c[j].y() -
+                                c[j].x()   * c[j-1].y() );
+        }
+        if(c.size()) c.pop_back();
+        return area < 0;
+}
+
+template <class P>
+class Empty
+{
+public:
+   Empty() {}
+   ~Empty() {}
+   bool operator()(const Polyline* poly)
+   {
+      if ( poly->empty() ) {
+        delete poly;
+        return true;
+      }
+      return false;
+   }
+};
+
+
+template <class C>
+class Clipper
+{
+public:
+	Clipper(const Transformation& transformation) : 
+		lastX_(INT_MIN), lastY_(INT_MIN), 
+		lastIn_(false),  current_(0), 
+		transformation_(transformation),
+		missing_(true) 
+	{
+		left_ = std::min(transformation_.getMinPCX(), transformation_.getMaxPCX());
+		right_ = std::max(transformation_.getMinPCX(), transformation_.getMaxPCX());
+		top_ = std::max(transformation_.getMinPCY(), transformation_.getMaxPCY());
+		bottom_ = std::min(transformation_.getMinPCY(), transformation_.getMaxPCY());
+	}
+	~Clipper() {}
+	
+	void feed(C& out) { 
+		for(  vector<Polyline* >::iterator line = helper_.begin(); line != helper_.end(); ++line) {
+			if ( (*line)->getShading() ) {
+				(*line)->setFilled(true);
+			
+			}
+			out.push_back(*line);
+		}
+	}
+	void adjust(double left, double bottom, double right, double top) {
+		left_ = left;
+		right_ = right;
+		top_ = top;
+		bottom_ = bottom;
+	}
+
+    bool pointin_;
+    void close(PolyCoast& poly)
+    {
+    	// Fisrt we reproject! 
+    	current_ = poly.getShade();
+    	
+    	if ( current_ ) { 
+    		vector<UserPoint>& geo = poly.coastlines();
+    		pointin_ = false;
+    		for ( vector<UserPoint>::const_iterator point = geo.begin(); point != geo.end(); ++point)    		
+    			close(transformation_(*point));
+    		current_->push_back(current_->front());   	
+        	 helper_.push_back(current_);
+    	}
+
+    	current_ = poly.getContour();
+    	vector<UserPoint>& geo = poly.coastlines();     	
+    	for ( vector<UserPoint>::const_iterator point = geo.begin(); point != geo.end(); ++point)    		
+    		(*this)( transformation_(*point));   	    		
+    	  if ( !current_->empty() ) {
+    		  helper_.push_back(current_); 
+    	  }
+    	  else 
+    		  delete current_; // Was allocated for nothing!
+    }
+	
+
+    void operator()(const Polyline& poly)
+    {
+    	//if  ( poly.allMissing() ) return;
+        current_ = new Polyline();   
+    	current_->copy(poly);  	
+    	lastX_ = INT_MIN;
+    	lastY_ = INT_MIN; 
+		lastIn_ = false;
+    	value_ = poly.front().value();
+    	allmissing_ = poly.allMissing();
+        static int i = 0;
+        i++;
+
+
+    	for ( Polyline::const_iterator point = poly.begin(); point != poly.end(); ++point) {
+
+    	 	(*this)(*point);
+    	}
+    	
+    	
+    	if ( !transformation_.concatenate(helper_, current_) ) 
+            	helper_.push_back(current_);
+    }
+   
+
+	void ignoreMissing(bool missing = true) { missing_ = !missing; }
+ 
+	MAGICS_NO_EXPORT bool in(double x, double y) const
+	{
+		return ((y <= top_ && y >= bottom_) && (x >= left_ && x <= right_));
+	}
+
+#define A(x1, y1, x2, y2) (y2 -y1)/(x2-x1)
+#define B(a, x, y) (y - a * x)
+#define X(a, b, y) ((y - b)/a)
+#define Y(a, b, x) ((a * x) + b)
+
+    MAGICS_NO_EXPORT void push_intersection(double x, double y) 
+    {
+        if (lastX_ == INT_MIN) return;
+
+        double a = (lastX_ == x) ? 0 : A(lastX_, lastY_, x, y);
+        double b = B(a, x, y);
+
+        // Intersect left?
+        if  ( (x < left_ && lastX_ > left_) || (lastX_ < left_ && x > left_) )
+	{
+            current_->push_back(PaperPoint(left_, Y(a, b, left_), value_, allmissing_));
+            return;
+        }
+        // Intersect top?
+    if  ( (y < top_ && lastY_ > top_) || ( lastY_ > bottom_ && lastY_ < top_ && y > top_) )
+	{
+        double nx = (!a) ? x : X(a, b, top_);
+        
+        if ( nx > right_ ) nx = right_;
+        if ( nx < left_ ) nx = left_;
+		
+        current_->push_back(PaperPoint(nx, top_, value_, allmissing_));
+		
+                return;
+	}
+
+        // Intersect right?
+        if ( (x < right_ && lastX_ > right_) || (lastX_ < right_ && x > right_) )
+	{
+            current_->push_back(PaperPoint(right_, Y(a, b, right_), value_, allmissing_));
+            return;
+        }
+
+        // intersect bottom?
+        if ( (y < bottom_ && lastY_ > bottom_ && lastY_ < top_ ) || ( lastY_ < bottom_ && y > bottom_) )
+	{
+            if (!a ) current_->push_back(PaperPoint(x, bottom_));
+            else current_->push_back(PaperPoint(X(a, b, bottom_), bottom_, value_, allmissing_));
+            return;
+        }
+    }
+
+    MAGICS_NO_EXPORT void operator()(const PaperPoint& point)
+    {
+    	if (missing_ && point.missing () && !current_->empty()) {
+            if ( !transformation_.concatenate(helper_, current_) ) 
+            	helper_.push_back(current_);
+    		Polyline* poly = new Polyline();
+            poly->copy(*current_);            
+            current_ = poly;
+            //out_.push_back(current_);
+            return;
+    	}
+
+        if ( in(point.x(), point.y()) ) {
+            if (lastIn_ ) {
+                current_->push_back(point);
+                lastX_ = point.x();
+                lastY_ = point.y();
+				lastIn_ = true;
+                return;
+            }
+            else {
+                // We are entering the area ..
+                // find intersection -->Push intersection + point... 
+            	current_->clear();
+                lastIn_ = true;
+                push_intersection(point.x(), point.y());
+                current_->push_back(point);
+                lastX_ = point.x();
+                lastY_ = point.y();
+		
+                return; 
+            }
+            return;
+        }
+	
+        // Point is out 
+        
+        if (current_->empty()) {
+            lastX_ = point.x();
+            lastY_ = point.y();
+            lastIn_ = false; 
+	    
+            return;
+        }
+        // Why?
+//        if (current_->size() == 1 ) {
+//        	current_->clear();
+//            lastX_ = point.x();
+//            lastY_ = point.y();
+//            lastIn_ = false; 
+//	    
+//            return;
+//        }
+        
+        if (!lastIn_) { 
+             lastX_ = point.x();
+             lastY_ = point.y();
+            return;
+        }
+        else {
+            // push_back intersection
+            push_intersection(point.x(), point.y());
+            lastX_ = point.x();
+            lastY_ = point.y();
+            // create new Polyline...
+           Polyline* poly = new Polyline();
+            if ( !transformation_.concatenate(helper_, current_) ) 
+            	helper_.push_back(current_);
+            poly->copy(*current_);  
+            current_ = poly;
+            lastIn_ = false;
+        }
+        return;
+     }
+    
+    //! Only used for coastlines
+    MAGICS_NO_EXPORT void close(const PaperPoint& point)
+    {
+        if ( in(point.x(), point.y()) ) {
+           if ( !pointin_ ) {
+              push_intersection(point.x(), point.y());
+           }
+           current_->push_back(point);
+
+           pointin_ = true;
+        }
+    	
+        // first point is out!
+        else {
+          if ( pointin_) {
+             // We have to calculate the intersction
+             lastX_ = current_->back().x();
+             lastY_ = current_->back().y();
+             push_intersection(point.x(), point.y());
+          }
+          else {
+             double x =  point.x();
+             double y =  point.y();
+             lastX_ = x;
+             lastY_ = y;
+
+             x = std::min(x, right_);
+             x = std::max(x, left_);
+             y = std::min(y, top_);
+             y = std::max(y, bottom_);
+             current_->push_back(PaperPoint(x, y, value_, allmissing_));
+          }
+          pointin_ = false;
+        }
+    }
+    
+    MAGICS_NO_EXPORT void clip(const PaperPoint& point)
+    {
+        // ONly used for coastlines!
+        if ( in(point.x(), point.y()) ) {
+          current_->push_back(point);
+        }
+        else {
+          if ( !current_->empty() ) {
+              helper_.push_back(current_);
+              current_ = current_->getNew();
+          }
+        }
+    }
+
+private:
+    double left_;
+    double bottom_;
+    double right_;
+    double top_;
+    double lastX_;
+    double lastY_;
+    bool lastIn_;
+
+    Polyline* current_;
+    const Transformation& transformation_;
+    vector<Polyline* > helper_;
+    bool missing_;
+
+    double value_;
+    bool allmissing_;
+};
+
+}
+#endif
diff --git a/src/common/Colour.cc b/src/common/Colour.cc
new file mode 100644
index 0000000..5288223
--- /dev/null
+++ b/src/common/Colour.cc
@@ -0,0 +1,529 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Colour.cc
+    \brief Implementation of Colour class.
+
+    Magics Team - ECMWF 2004
+
+    Started by Sylvie Lamy-Thepaut ECMWF 2002
+
+    Changes:
+
+
+*/
+#include "Colour.h"
+#include "MagLog.h"
+#include "BaseParameter.h"
+#include "XmlNode.h"
+
+/*! \defgroup colours Colours
+
+   \section howToDefine How can colours be defined?
+   
+   There are more than one way how colour values can be defined within Magics++
+   
+   - RGB
+   - HSL
+   
+   \todo Where are the web colours defined?
+   
+   MagException of type BadRGBFormat and BadHSLFormat are thrown in case
+   values look wrong.
+*/
+
+
+using namespace magics;
+
+std::map<string, Rgb> Colour::colours_;
+
+
+
+Colour::Colour() : rgb_(1., 0., 0., 1.), automatic_(false)
+{
+	init();
+}
+
+Colour::Colour(Rgb& rgb) : rgb_(rgb),  automatic_(false)
+{ 
+	name_ = tostring(rgb_);
+}
+
+Colour::Colour(Hsl& hsl) : rgb_(hsl.rgb()), automatic_(false) 
+{ 
+	name_ = tostring(rgb_);
+}
+
+Colour::Colour(float red, float green, float blue, float alpha) : 
+	rgb_(red, green, blue, alpha), automatic_(false)
+{
+	ostringstream name;
+	name << "RGB(" << red <<  "," << green << "," << blue << "," << alpha << ")" << "\n";
+	name_ = name.str();
+}
+
+Colour::Colour(const string& name) : name_(lowerCase(name)), automatic_(false)
+{
+	if ( name == "automatic" ) automatic_ = true;
+	init();
+	try {
+		setColour(name);
+	}
+	catch (BadHslFormat& e)
+	{
+		name_ = "red";
+		rgb_ = Rgb(1., 0., 0.,1.);
+	}
+}
+
+void Colour::set(const XmlNode& xml)
+{
+	MagLog::debug() << "set Colour-->" << xml << "\n";
+	try {
+		setColour(xml.data());
+	}
+	catch (BadHslFormat& e)
+	{
+		name_ = "red";
+		rgb_ = Rgb(1., 0., 0.,1.);	        	
+	}
+}
+
+void Colour::setColour(const string& name) 
+{
+	if ( name.empty() )
+	{
+		MagLog::warning() << "No colour name given. Red used.\n";
+		name_ = "red";
+		rgb_ = Rgb(1., 0., 0.);
+		MagLog::broadcast();
+		return;
+	}
+	try {
+	// get rid of white space...
+	string::size_type first = name.find_first_not_of(" ");  
+	string::size_type last = name.find_last_not_of(" ");  
+
+	string find = name.substr(first,  last-first+1);    
+	name_ = lowerCase(find);
+
+	map<string, Rgb>::iterator colour = colours_.find(name_);
+	if (colour == colours_.end())
+	{
+		string prefix = name_.substr(0,3);
+
+		if ( magCompare(prefix, "rgb") )
+		{
+			rgb_ = Rgb(name_);
+		}
+		else if ( magCompare(prefix, "hsl") )
+		{
+			Hsl hsl(name);
+			rgb_ = hsl.rgb();
+		}
+		else if ( magCompare(name_.substr(0, 1), "#") )
+         
+		{
+            // Web format should on 7 characher or 4 
+            if ( name_.size() == 7 ) { 
+			    float red = strtol(name_.substr(1, 2).c_str(), 0, 16)/256.;
+			    float green = strtol(name_.substr(3, 2).c_str(), 0, 16)/256.;
+			    float blue = strtol(name_.substr(5, 2).c_str(), 0, 16)/256.;
+			    rgb_ = Rgb(red, green, blue, 1.);	
+            }
+            else if ( name_.size() == 4) {
+                float red = strtol(name_.substr(1, 1).c_str(), 0, 16)/256.;
+			    float green = strtol(name_.substr(2, 1).c_str(), 0, 16)/256.;
+			    float blue = strtol(name_.substr(3, 1).c_str(), 0, 16)/256.;
+			    rgb_ = Rgb(red, green, blue, 1.);
+            }
+            else {
+                MagLog::warning() << "The color [" << name_ << "] is not valid. Red used.\n";
+			    name_ = "red";
+			    rgb_ = Rgb(1., 0., 0.,1.);	
+            }
+            		
+		}
+		else
+		{
+			MagLog::warning() << "The color [" << name_ << "] is not valid. Red used.\n";
+			name_ = "red";
+			rgb_ = Rgb(1., 0., 0.,1.);	
+		}
+	}
+	else rgb_ = (*colour).second;
+	}
+	catch (...) {
+		MagLog::warning() << " Invalid colour name " << name  << ". Red used.\n";
+				name_ = "red";
+				rgb_ = Rgb(1., 0., 0.);
+				MagLog::broadcast();
+				return;
+	}
+}
+
+void Colour::setColour(float red, float green, float blue, float alpha)
+{
+	ostringstream name;
+
+	name << "RGB(" << red <<  "," << green << "," << blue<< "," << alpha << ")" << "\n";
+	name_ = name.str();
+	rgb_ = Rgb(red, green, blue, alpha);
+}
+
+void Colour::setAlpha(float alpha)
+{
+	ostringstream name;
+	
+	name << "RGB(" << red() <<  "," << green() << "," << blue()<< "," << alpha << ")" << "\n";
+	name_ = name.str();
+	rgb_ = Rgb(red(), green(), blue(), alpha);
+}
+
+void Colour::scaleLight(float scale_factor)
+{	
+	Hsl hsl=rgb_.hsl();
+	hsl.light_*=scale_factor;
+	if(hsl.light_ > 1) hsl.light_=1.;
+	Rgb rgb=hsl.rgb();
+
+	setColour(rgb.red_,rgb.green_,rgb.blue_,rgb_.alpha_);
+}
+
+
+Colour::~Colour() {}
+	
+void Colour::print(ostream& out)  const
+{
+	
+	out <<name_ << "["<<rgb_.red_<<", "<<rgb_.green_<< ", "<< rgb_.blue_ << ", " << rgb_.alpha_<<"] ";
+}
+
+Hsl Colour::hsl() const 
+{ 
+    return rgb_.hsl();
+}
+
+Hsl Rgb::hsl() const 
+{
+    Hsl hsl;
+    float min = std::min( red_, std::min(green_, blue_) );    //Min. value of RGB
+    float max = std::max( red_, std::max(green_, blue_) );    //Max. value of RGB
+    float diff = max - min;             //Delta RGB value
+
+    hsl.light_ = ( max + min ) / 2;
+    hsl.alpha_ = alpha_;
+
+    if ( diff == 0 )                     //This is a gray, no chroma...
+    {
+        hsl.hue_ = 0;                                //HSL results = From 0 to 1
+        hsl.saturation_ = 0;
+    }
+    else                                    //Chromatic data...
+    {
+        if ( hsl.light_ < 0.5 ) hsl.saturation_ = diff / ( max + min );
+        else   hsl.saturation_ = diff / ( 2 - max - min );
+
+        float red   = ( ( ( max - red_)  / 6 ) + ( diff / 2 ) ) / diff;
+        float green = ( ( ( max - green_ ) / 6 ) + ( diff / 2 ) ) / diff;
+        float blue  = ( ( ( max - blue_ ) / 6 ) + ( diff / 2 ) ) / diff;
+
+        if      ( red_ == max ) hsl.hue_ = blue - green; 
+        else if ( green_ == max ) hsl.hue_ = ( 1. / 3. ) + red - blue;
+        else if ( blue_ == max ) hsl.hue_ = ( 2. / 3. ) + green - red;
+
+        if ( hsl.hue_ < 0 )  hsl.hue_ += 1;
+        if ( hsl.hue_ > 1 )  hsl.hue_ -= 1;
+        hsl.hue_ *= 360.;
+    }
+    return hsl;
+}
+
+inline float hue2rgb(float v1, float v2, float vH )             //Function Hue_2_RGB
+{
+   if ( vH < 0 ) vH += 1;
+   if ( vH > 1 ) vH -= 1;
+   if ( ( 6 * vH ) < 1 ) return ( v1 + ( v2 - v1 ) * 6 * vH );
+   if ( ( 2 * vH ) < 1 ) return ( v2 );
+   if ( ( 3 * vH ) < 2 ) return ( v1 + ( v2 - v1 ) * ( ( 2. / 3.) - vH ) * 6 );
+   return v1;
+}
+
+Rgb Hsl::rgb() const 
+{
+    Rgb rgb;
+    rgb.alpha_ = alpha_;
+    float var1, var2;
+    if ( saturation_ == 0 ) {
+        rgb.red_ = light_;
+        rgb.green_ = light_;
+        rgb.blue_ = light_;
+    }
+    else
+    {
+        if ( light_ < 0.5 ) var2 = light_ * ( 1 + saturation_ );
+        else  var2 = ( light_ + saturation_ ) - ( saturation_ * light_ );
+
+        var1 = 2 * light_ - var2;
+
+        rgb.red_ = hue2rgb( var1, var2, (hue_/360.) + ( 1. / 3. ) );
+        rgb.green_ = hue2rgb( var1, var2, (hue_/360.) );
+        rgb.blue_ = hue2rgb( var1, var2, (hue_/360.) - ( 1. / 3.) );
+    }
+    if (rgb.red_ < 0.000001) rgb.red_= 0.;
+    if (rgb.green_ < 0.000001) rgb.green_= 0.;
+    if (rgb.blue_ < 0.000001) rgb.blue_= 0.;
+    return rgb;
+}
+
+
+bool Colour::valid(const string& name)
+{
+	init();
+	Colour colour;
+	try {
+		colour.setColour(name);
+	}
+	catch (BadHslFormat& e)
+	{
+	        return false;
+	}
+	return true;
+}
+
+
+void Colour::init() {
+	if (!colours_.empty()) return;
+	 colours_["automatic"] = Rgb(0., 0., 0.); // NEEDS FIXING 
+	 colours_["none"] = Rgb(-1., -1., -1.); 
+	 colours_["background"] = Rgb(1., 1., 1.); 
+	 colours_["foreground"] = Rgb(0., 0., 0.); 
+	 colours_["red"] = Rgb(1.0000, 0.0000, 0.0000); 
+	 colours_["green"] = Rgb(0.0000, 1.0000, 0.0000); 
+	 colours_["blue"] = Rgb(0.0000, 0.0000, 1.0000);
+	 colours_["yellow"] = Rgb(1.0000, 1.0000, 0.0000); 
+	 colours_["cyan"] = Rgb(0.0000, 1.0000, 1.0000); 
+	 colours_["magenta"] = Rgb(1.0000, 0.0000, 1.0000); 
+	 colours_["black"] = Rgb(0.0000, 0.0000, 0.0000); 
+	 colours_["avocado"] = Rgb(0.4225, 0.6500, 0.1950); 
+	 colours_["beige"] = Rgb(0.8500, 0.7178, 0.4675); 
+	 colours_["brick"] = Rgb(0.6000, 0.0844, 0.0300); 
+	 colours_["brown"] = Rgb(0.4078, 0.0643, 0.0000); 
+	 colours_["burgundy"] = Rgb(0.5000, 0.0000, 0.1727); 
+	 colours_["charcoal"] = Rgb(0.2000, 0.2000, 0.2000); 
+	 colours_["chestnut"] = Rgb(0.3200, 0.0112, 0.0000); 
+	 colours_["coral"] = Rgb(0.9000, 0.2895, 0.2250); 
+	 colours_["cream"] = Rgb(1.0000, 0.8860, 0.6700); 
+	 colours_["evergreen"] = Rgb(0.0000, 0.4500, 0.2945); 
+	 colours_["gold"] = Rgb(0.7500, 0.5751, 0.0750); 
+	 colours_["grey"] = Rgb(0.7000, 0.7000, 0.7000); 
+	 colours_["khaki"] = Rgb(0.5800, 0.4798, 0.2900); 
+	 colours_["kelly_green"] = Rgb(0.0000, 0.5500, 0.1900); 
+	 colours_["lavender"] = Rgb(0.6170, 0.4070, 0.9400); 
+	 colours_["mustard"] = Rgb(0.6000, 0.3927, 0.0000); 
+	 colours_["navy"] = Rgb(0.0000, 0.0000, 0.4000); 
+	 colours_["ochre"] = Rgb(0.6800, 0.4501, 0.0680); 
+	 colours_["olive"] = Rgb(0.3012, 0.3765, 0.0000); 
+	 colours_["peach"] = Rgb(0.9400, 0.4739, 0.3788); 
+	 colours_["pink"] = Rgb(0.9000, 0.3600, 0.4116); 
+	 colours_["rose"] = Rgb(0.8000, 0.2400, 0.4335); 
+	 colours_["rust"] = Rgb(0.7000, 0.2010, 0.0000); 
+	 colours_["sky"] = Rgb(0.4500, 0.6400, 1.0000); 
+	 colours_["tan"] = Rgb(0.4000, 0.3309, 0.2000); 
+	 colours_["tangerine"] = Rgb(0.8784, 0.4226, 0.0000); 
+	 colours_["turquoise"] = Rgb(0.1111, 0.7216, 0.6503); 
+	 colours_["violet"] = Rgb(0.4823, 0.0700, 0.7000); 
+	 colours_["reddish_purple"] = Rgb(1.0000, 0.0000, 0.8536); 
+	 colours_["purple_red"] = Rgb(1.0000, 0.0000, 0.5000); 
+	 colours_["purplish_red"] = Rgb(1.0000, 0.0000, 0.2730); 
+	 colours_["orangish_red"] = Rgb(1.0000, 0.0381, 0.0000); 
+	 colours_["red_orange"] = Rgb(1.0000, 0.1464, 0.0000); 
+	 colours_["reddish_orange"] = Rgb(1.0000, 0.3087, 0.0000); 
+	 colours_["orange"] = Rgb(1.0000, 0.5000, 0.0000); 
+	 colours_["yellowish_orange"] = Rgb(1.0000, 0.6913, 0.0000); 
+	 colours_["orange_yellow"] = Rgb(1.0000, 0.8536, 0.0000); 
+	 colours_["orangish_yellow"] = Rgb(1.0000, 0.9619, 0.0000); 
+	 colours_["greenish_yellow"] = Rgb(0.8536, 1.0000, 0.0000); 
+	 colours_["yellow_green"] = Rgb(0.5000, 1.0000, 0.0000); 
+	 colours_["yellowish_green"] = Rgb(0.1464, 1.0000, 0.0000); 
+	 colours_["bluish_green"] = Rgb(0.0000, 1.0000, 0.5000); 
+	 colours_["blue_green"] = Rgb(0.0000, 1.0000, 1.0000); 
+	 colours_["greenish_blue"] = Rgb(0.0000, 0.5000, 1.0000); 
+	 colours_["purplish_blue"] = Rgb(0.1464, 0.0000, 1.0000); 
+	 colours_["blue_purple"] = Rgb(0.5000, 0.0000, 1.0000); 
+	 colours_["bluish_purple"] = Rgb(0.8536, 0.0000, 1.0000); 
+	 colours_["purple"] = Rgb(1.0000, 0.0000, 1.0000); 
+	 colours_["white"] = Rgb(1.0000, 1.0000, 1.0000); 
+	 colours_["undefined"] = Rgb(-1., -1., -1.);
+}
+
+#include "BackgroundColour.h"
+Colour* MagTranslator<string, Colour>::operator()(const string& val )
+{
+ 	 if (Colour::valid(val) ) return new Colour(val);
+ 	 if ( val == "colour" ) return new Colour();
+ 	 if ( val == "background_colour" ) return new BackgroundColour();
+ 	 throw NoFactoryException(val);
+}
+
+Rgb::Rgb(const string& name): red_(1.), green_(1.), blue_(1.),alpha_(1.)
+{
+  istringstream in(name);
+  stringbuf token;
+  in >> ws;
+  in.get(token, '(');
+
+  if (in.eof()) throw BadRgbFormat();
+
+  if (magCompare(token.str(), "rgb"))
+  {
+	      in.ignore(name.length(), '(');
+	      in >> red_; 
+	      if (red_ <0 || red_>1) throw BadRgbFormat();
+
+	      in.ignore(name.length(), ',');
+	      if (in.eof()) throw BadRgbFormat();
+	      in >> green_;
+	      if (green_ <0 || green_>1) throw BadRgbFormat();
+	      in.ignore(name.length(), ',');
+	      if (in.eof()) throw BadRgbFormat();
+	      in >> blue_; 
+	      if (blue_ <0 || blue_>1) throw BadRgbFormat();
+  }
+  else if (magCompare(token.str(), "rgba")) {
+	      in.ignore(name.length(), '(');
+	      in >> red_; 
+	      if (red_ <0 || red_>1) throw BadRgbFormat();
+
+	      in.ignore(name.length(), ',');
+	      if (in.eof()) throw BadRgbFormat();	    
+	      in >> green_;
+	      if (green_ <0 || green_>1) throw BadRgbFormat();
+	      in.ignore(name.length(), ',');
+	      if (in.eof()) throw BadRgbFormat();	    
+	      in >> blue_; 
+	      if (blue_ <0 || blue_>1) throw BadRgbFormat();
+	      in.ignore(name.length(), ',');
+	      if (in.eof()) throw BadRgbFormat();	    
+	      in >> alpha_; 
+	      if (alpha_ <0 || alpha_>1) throw BadRgbFormat();
+    }
+    else 
+          throw BadRgbFormat();
+}
+
+
+Hsl::Hsl(const string& name)
+{
+    istringstream in(name);
+    stringbuf token;
+    in >> ws;
+    in.get(token, '(');
+
+    if (in.eof()) throw BadHslFormat();
+
+    if (magCompare(token.str(),"HSL")) {
+
+        in.ignore(name.length(), '(');
+        in >> hue_; 
+        if (hue_ <0 || hue_>360) throw BadHslFormat();
+
+        in.ignore(name.length(), ',');
+        if (in.eof()) throw BadHslFormat();	    
+        in >> saturation_;
+        if ( saturation_ <0 || saturation_>1) throw BadHslFormat();
+
+        in.ignore(name.length(), ',');
+        if (in.eof()) throw BadHslFormat();	    
+        in >> light_; 
+        if ( light_ <0 || light_>1) throw BadHslFormat();
+        alpha_=1.;
+    }
+    else if (magCompare(token.str(),"HSLA")) {
+        in.ignore(name.length(), '(');
+        in >> hue_; 
+        if (hue_ <0 || hue_>360) throw BadHslFormat();
+
+        in.ignore(name.length(), ',');
+        if (in.eof()) throw BadHslFormat();
+        in >> saturation_;
+        if ( saturation_ <0 || saturation_>1) throw BadHslFormat();
+
+        in.ignore(name.length(), ',');
+        if (in.eof()) throw BadHslFormat();
+        in >> light_; 
+        if ( light_ <0 || light_>1) throw BadHslFormat();
+
+        in.ignore(name.length(), ',');
+        if (in.eof()) throw BadHslFormat();
+        in >> alpha_; 
+        if ( alpha_ <0 || alpha_>1) throw BadHslFormat();
+    }
+    else throw BadHslFormat();
+}
+
+
+istream& operator>>(istream& s, Rgb& p)
+{
+	string token;
+	s.width(3);
+	s >> token;
+
+	if (token != "RGB") throw BadRgbFormat();
+
+	s.ignore(256, '(');
+	s >> p.red_; 
+	if (p.red_ <0 || p.red_>1) throw BadRgbFormat();
+		
+	s.ignore(256, ',');
+	s >> p.green_;
+	if (p.green_ <0 || p.green_>1) throw BadRgbFormat();
+	s.ignore(256, ',');
+
+	s >> p.blue_; 
+	if (p.blue_ <0 || p.blue_>1) throw BadRgbFormat();
+
+	return s; 
+}
+
+istream& operator>>(istream& s, Hsl& p)
+{
+	string token;
+	s.width(3);
+	s >> token;
+
+	if (token != "HSL") throw BadHslFormat();
+
+	s.ignore(256, '(');
+	s >> p.hue_; 
+	if (p.hue_ <0 || p.hue_>360) throw BadHslFormat();
+
+	s.ignore(256, ',');
+	s >> p.saturation_;
+	if (p.saturation_ <0 || p.saturation_>1) throw BadHslFormat();
+	s.ignore(256, ',');
+
+	s >> p.light_; 
+	if (p.light_ <0 || p.light_>1) throw BadHslFormat();
+	return s; 
+}
+bool Colour::none() const
+{
+	static Colour none("none");
+	return *this == none;
+}
diff --git a/src/common/Colour.h b/src/common/Colour.h
new file mode 100644
index 0000000..5fb51ec
--- /dev/null
+++ b/src/common/Colour.h
@@ -0,0 +1,207 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Colour.h
+    \brief Definition of Colour class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started by Sylvie Lamy-Thepaut ECMWF 2002
+    
+    Changes:
+    
+    Jan-2004 Stephan: Adopt this class to Magics++ 0.1 (namespace etc.) 
+    
+*/
+#ifndef Colour_H
+#define Colour_H
+
+#include <magics.h> 
+#include <sstream>
+#include "Factory.h"
+#include "MagTranslator.h"
+
+using std::istream;
+
+namespace magics {
+
+
+class Hsl;
+class XmlNode;
+
+/*! \struct Rgb
+    \brief Struct expressing colour values in RGB.
+    
+    
+
+*/
+struct BadRgbFormat
+{ 
+	BadRgbFormat() {}
+	~BadRgbFormat() {}
+};
+
+
+
+struct Rgb
+{
+    Rgb(float red =1., float green = 1., float blue = 1., float alpha=1.): 
+        red_(red), 
+        green_(green), 
+        blue_(blue),
+        alpha_(alpha)
+    {}
+    Rgb(const string&); 
+
+    bool operator==(const Rgb other) const
+    { 
+        return (red_ == other.red_ && 
+            green_ == other.green_ && 
+            blue_ == other.blue_ && alpha_ == other.alpha_);
+    }
+    float red_;
+    float green_;
+    float blue_;
+    float alpha_;
+    Hsl hsl() const;
+    friend ostream& operator<<(ostream& s,const Rgb& p)
+    {  s << "RGB(" << p.red_ << ", " << p.green_ << ", " 
+         << p.blue_ << ", " << p.alpha_ << ")"; return s; }
+    friend istream& operator>>(istream& s, Rgb& p);
+};
+
+struct BadHslFormat
+{ 
+	BadHslFormat() {}
+	~BadHslFormat() {}
+};
+
+struct Hsl {
+     Hsl(float hue =0., float saturation = 1., float light = 1., float alpha = 1.): 
+        hue_(hue), 
+        saturation_(saturation), 
+        light_(light),
+        alpha_(alpha)
+    {}
+     Hsl(const string&); 
+   
+    bool operator==(const Hsl& other) const { 
+        return (hue_ == other.hue_ && 
+            saturation_ == other.saturation_ && 
+            light_ == other.light_ &&
+            alpha_ == other.alpha_);
+    }      
+    float hue_;
+    float saturation_;
+    float light_;
+    float alpha_;    
+    
+    Rgb rgb() const;
+  
+    
+    // -- Friends
+	friend ostream& operator<<(ostream& s,const Hsl& p)
+		{  s << "HSL(" << p.hue_ << ", " 
+            << p.saturation_ << ", "  << p.light_ << ", " << p.alpha_ << ")"; 
+            return s; }
+	friend istream& operator>>(istream& s, Hsl& p);
+};
+
+/*! \class Colour 
+    \brief Class to express a colour.
+    
+    This class holds colour values in RGB (for this it uses Rgb ).
+    
+    
+
+*/
+class Colour  {
+
+public:
+// -- Contructors
+	Colour();	
+	Colour(const string&);
+	Colour(float, float, float, float = 1.);
+	Colour(Rgb&);
+	Colour(Hsl&);
+
+// -- Destructor
+	~Colour();
+    
+	void set(const map<string, string>&) {};
+	void set(const XmlNode&);
+	Colour* clone() const { return new Colour(*this); }
+	bool automatic() const { return automatic_; }
+	bool none() const;
+// -- Methods
+	float red()   const { return rgb_.red_; }
+	float blue()  const { return rgb_.blue_; }
+	float green() const { return rgb_.green_; }
+	float alpha() const { return rgb_.alpha_; }
+	string name() const { return name_; }
+
+	bool operator==(const Colour& other) const {
+	   return other.rgb_ == rgb_;
+	}
+	
+	bool operator==(const string& other) const {
+	   return lowerCase(other) == lowerCase(name_);
+	}
+	bool operator < (const Colour& other) const {
+	   return name_  < other.name_;
+	}
+    
+	Hsl hsl() const;
+	
+	void setColour(const string&);
+	void setColour(float, float, float, float = 1.);
+	void setAlpha(float);
+	void scaleLight(float);
+	static bool valid(const string& name);
+
+protected:
+	void print(ostream&) const;
+
+private:
+// -- Members
+	static std::map<string, Rgb> colours_;
+	static void init();
+	Rgb rgb_; 
+	string name_;
+	bool     automatic_;       
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const Colour& p)
+		{ p.print(s); return s; }
+};
+
+template<>
+class MagTranslator<string, Colour> { 
+public:
+    Colour* operator()(const string& val );
+    Colour* magics(const string& param)
+    {
+        string val;
+        ParameterManager::get(param, val);
+        return (*this)(val);
+    }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/ColourTable.cc b/src/common/ColourTable.cc
new file mode 100644
index 0000000..afd5046
--- /dev/null
+++ b/src/common/ColourTable.cc
@@ -0,0 +1,106 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTable.cc
+    \brief Implementation of the Template class ColourTable.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "ColourTable.h"
+#include "PaperPoint.h"
+#include "Polyline.h"
+
+using namespace magics;
+
+ColourTable::ColourTable() 
+{
+}
+
+
+ColourTable::~ColourTable() 
+{
+}
+
+void ColourTable::prepare() 
+{
+#if 0  
+	for ( int i = 1; i < 256; i++) 
+		push_back(Rgb(1./i, 1./i, 1./i)); 
+#else
+		push_back(Colour(1., 0., 0.)); 
+		push_back(Colour(0., 1., 0)); 
+		push_back(Colour(0., 0., 1.)); 
+		push_back(Colour(1., 1., 0.)); 
+		push_back(Colour(1., 0., 1.)); 
+		push_back(Colour(0., 1., 1.)); 
+#endif
+}
+/*!
+ Class information are given to the output-stream.
+*/		
+void ColourTable::print(ostream& out)  const
+{
+	out << "ColourTable[\n";
+	int i = 0;
+	for ( ColourIterator colour = begin(); colour != end(); ++colour ) {
+		out << "\t Colour " << i << ":" << *colour << "\n";
+		i++; 
+	}
+	out << "]\n";
+}
+/*
+void ColourTable::visit(LegendEntryList& list) const
+{
+	for ( ColourIterator colour = begin(); colour != end(); ++colour ) 
+		colour->visit(list);
+}
+
+void ColourTableEntry::visit(LegendEntryList& list) const
+{
+	
+	Polyline*  box = new Polyline(0, "legend");
+	FillShadingProperties* shading = new FillShadingProperties();    
+	box->setColour(colour_);
+	
+	shading->left_      = colour_;
+	shading->right_     = colour_;
+	shading->inColour_ = colour_;
+	shading->outColour_ = Colour("NONE");    
+	 
+	box->setShading(shading);
+	list.push_back(new BoxEntry(min_, max_, box));
+	
+}
+*/
+void ColourTableEntry::print(ostream& out)  const
+{
+	out << "[" << min_ << ", " << max_ << ", " << colour_ << "]";
+}
+
+
+
+
+
diff --git a/src/common/ColourTable.h b/src/common/ColourTable.h
new file mode 100644
index 0000000..8001681
--- /dev/null
+++ b/src/common/ColourTable.h
@@ -0,0 +1,99 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTable.h
+    \brief Definition of the Template class ColourTable.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTable_H
+#define ColourTable_H
+
+#include "magics.h"
+#include "Colour.h"
+
+
+namespace magics {
+	
+	
+class ColourTableEntry 
+{
+public:
+	ColourTableEntry(const Colour& colour) : 
+		min_(INT_MAX), max_(INT_MIN), colour_(colour) {}
+	~ColourTableEntry() {}
+	//void visit(LegendEntryList&) const;
+	void value(double val) { 
+		if ( min_ > val ) min_ = val; 
+		if ( val > max_ ) max_ = val;		
+	}
+	
+	const Colour& colour() const { return colour_; }
+	
+	double red()   const { return colour_.red(); }
+	double blue()  const { return colour_.blue(); }
+	double green() const { return colour_.green(); }
+	double alpha() const { return colour_.alpha(); }
+
+	bool operator==(const string& other) const {
+	   return colour_ == other;
+	}
+	
+
+protected:
+	double min_;
+	double max_; 
+	Colour colour_;
+	void print(ostream&) const; 
+	friend ostream& operator<<(ostream& s,const ColourTableEntry& p)
+		{ p.print(s); return s; }
+};
+
+class ColourTable : public magvector<ColourTableEntry> {
+
+public:
+    typedef magvector<ColourTableEntry>::const_iterator ColourIterator;
+	ColourTable();
+	virtual ~ColourTable();
+    virtual void prepare();
+    
+    //void visit(LegendEntryList&) const;
+    void push_pack(const Colour& colour) 
+   		{ push_back(ColourTableEntry(colour)); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+   
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTable& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/ColourTableDefinition.h b/src/common/ColourTableDefinition.h
new file mode 100644
index 0000000..65e3d39
--- /dev/null
+++ b/src/common/ColourTableDefinition.h
@@ -0,0 +1,93 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinition.h
+    \brief Definition of the Template class ColourTableDefinition.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTableDefinition_H
+#define ColourTableDefinition_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "ColourTable.h"
+
+namespace magics {
+
+class XmlNode;
+
+class ColourTableDefinition {
+
+
+public:
+	ColourTableDefinition() {}
+	virtual ~ColourTableDefinition() {}
+	virtual void set(ColourTable&, int) {};
+	virtual ColourTableDefinition* clone() const { return new ColourTableDefinition(); }
+	
+	virtual void set(const XmlNode&) { }
+	virtual void set(const map<string, string>&) { }
+	virtual bool accept(const string&) { return false; }
+	
+	virtual void toxml(ostream&)  const {}
+	virtual void prepare() {}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourTableDefinition(const ColourTableDefinition&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourTableDefinition& operator=(const ColourTableDefinition&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTableDefinition& p)
+		{ p.print(s); return s; }
+
+};
+
+
+template<>
+class MagTranslator<string, ColourTableDefinition> { 
+public:
+	ColourTableDefinition* operator()(const string& val ) {
+		 return SimpleObjectMaker<ColourTableDefinition>::create(val);
+	}     
+    ColourTableDefinition* magics(const string& param)
+    {
+        ColourTableDefinition* object;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/ColourTableDefinitionCompute.cc b/src/common/ColourTableDefinitionCompute.cc
new file mode 100644
index 0000000..b8b0b04
--- /dev/null
+++ b/src/common/ColourTableDefinitionCompute.cc
@@ -0,0 +1,159 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinitionCompute.cc
+    \brief Implementation of the Template class ColourTableDefinitionCompute.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "ColourTableDefinitionCompute.h"
+#include "XmlNode.h"
+
+using namespace magics;
+
+ColourTableDefinitionCompute::ColourTableDefinitionCompute() 
+{
+}
+
+
+ColourTableDefinitionCompute::~ColourTableDefinitionCompute() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ColourTableDefinitionCompute::print(ostream& out)  const
+{
+	out << "ColourTableDefinitionCompute[";
+	out << "]";
+}
+
+void ColourTableDefinitionCompute::set(const ColourTableDefinitionComputeInterface& attributes)
+{
+	minColour_ = attributes.getMin();
+	maxColour_ = attributes.getMax();
+	direction_ = attributes.getDirection();
+}
+
+void ColourTableDefinitionCompute::set(const XmlNode& node)
+{
+	direction_ = node.getAttribute("direction");
+	MagLog::warning() << "ColourTableDefinitionCompute::set(const XmlNode&): to be implemented\n";
+	
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		if ( magCompare((*elt)->name(), "min_colour") ) {
+			minColour_ = Colour((*elt)->data());
+		}
+		if ( magCompare((*elt)->name(), "max_colour") ) {
+			maxColour_ = Colour((*elt)->data());
+		}
+		
+	}
+	
+	
+}
+
+void ColourTableDefinitionCompute::set(ColourTable& table, int nb)
+{
+	prepare();
+	double step_hue;
+	double step_light;
+	double step_alpha;
+	MagLog::dev() << "ColourTableDefinitionCompute::set->min-->" << minColour_ << endl;
+	MagLog::dev() << "ColourTableDefinitionCompute::set->max-->" << maxColour_ << endl;
+	MagLog::dev() << "nb interval-->" << nb << endl;
+    Hsl hmin = minColour_.hsl();
+    Hsl hmax = maxColour_.hsl();
+/*    
+    table.push_back(Colour("none"));
+    nb--;
+    if ( nb < 2) {
+    	return;
+
+    }
+*/
+    if (nb == 2) {
+    	table.push_back(minColour_);
+    	return;
+    }
+    if (nb == 3) {
+       	table.push_back(minColour_);
+       	table.push_back(maxColour_);
+       	return;
+       }
+    
+/*
+    
+    if ( hmax.hue_ == hmin.hue_ && hmax.light_  != 1 && hmin.light_  != 1) {
+    	// Grey scale...
+    	step_light = (hmax.light_ - hmin.light_)/(nb-2);
+    	 for ( int i = 0;  i < nb; i++) {
+       		table.push_back(Colour(hmin));
+      	 	hmin.light_ += step_light;     	 	
+    	 }
+    	 return;
+    }
+  */
+    
+    if (nb == 1) {
+        // Only One Colour to allocate;
+        step_hue = hmax.hue_ - hmin.hue_;
+        step_alpha = hmax.alpha_ - hmin.alpha_;
+        if ( step_hue == 0 ) {
+          step_hue = 1;
+          hmax.hue_++;
+          // Change the value of hmax to be sure that we have at least one colour...
+        }
+    }
+    
+    else { 
+    	step_light = (hmax.light_ - hmin.light_)/(nb-2);
+    	step_alpha = (hmax.alpha_ - hmin.alpha_)/(nb-2);
+        if ( magCompare(direction_, "anti_clockwise") ) {
+           if ( hmax.hue_ < hmin.hue_ )  hmax.hue_ += 360;
+           step_hue = (hmax.hue_ - hmin.hue_)/(nb-2);
+        } 
+        else {
+            if ( hmin.hue_ < hmax.hue_ )  hmin.hue_ += 360;
+            step_hue =  (hmax.hue_ - hmin.hue_)/(nb-2);
+        }
+    }
+    
+    float step_sat =  (hmax.saturation_ - hmin.saturation_)/(nb-2);
+    // WE have nb levels : we need nb-1 colours! 
+   
+    for ( int i = 0;  i < nb-1; i++) {
+    	MagLog::dev() << "ColourTableDefinitionCompute::set->add-->" << Colour(hmin) << endl;
+       table.push_back(Colour(hmin));
+       hmin.saturation_ += step_sat;
+       hmin.hue_ += step_hue;
+       hmin.light_ += step_light;
+       hmin.alpha_ += step_alpha;
+    }
+}
+
+
diff --git a/src/common/ColourTableDefinitionCompute.h b/src/common/ColourTableDefinitionCompute.h
new file mode 100644
index 0000000..f452a77
--- /dev/null
+++ b/src/common/ColourTableDefinitionCompute.h
@@ -0,0 +1,77 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinitionCompute.h
+    \brief Definition of the Template class ColourTableDefinitionCompute.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTableDefinitionCompute_H
+#define ColourTableDefinitionCompute_H
+
+#include "magics.h"
+
+#include "ColourTableDefinition.h"
+#include "ColourTableDefinitionComputeInterface.h"
+
+namespace magics {
+
+class ColourTableDefinitionCompute: public ColourTableDefinition {
+
+public:
+	ColourTableDefinitionCompute();
+	virtual ~ColourTableDefinitionCompute();
+	void set(const ColourTableDefinitionComputeInterface&);
+	void set(const XmlNode&);
+	ColourTableDefinition* clone() const {
+		ColourTableDefinitionCompute* object = new ColourTableDefinitionCompute();
+		object->minColour_ = minColour_;
+		object->maxColour_ = maxColour_;
+		object->direction_ = direction_;
+		return object;
+	}
+	void set(ColourTable&, int);
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 Colour     minColour_;
+	 Colour     maxColour_;
+	 string  direction_;
+private:
+    //! Copy constructor - No copy allowed
+	ColourTableDefinitionCompute(const ColourTableDefinitionCompute&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourTableDefinitionCompute& operator=(const ColourTableDefinitionCompute&);
+	
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTableDefinitionCompute& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/ColourTableDefinitionComputeInterface.h b/src/common/ColourTableDefinitionComputeInterface.h
new file mode 100644
index 0000000..9ee3dba
--- /dev/null
+++ b/src/common/ColourTableDefinitionComputeInterface.h
@@ -0,0 +1,68 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinitionComputeInterface.h
+    \brief Definition of the Template class ColourTableDefinitionComputeInterface.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTableDefinitionComputeInterface_H
+#define ColourTableDefinitionComputeInterface_H
+
+#include "magics.h"
+
+#include "Colour.h"
+
+
+namespace magics {
+
+class ColourTableDefinitionComputeInterface {
+
+public:
+	ColourTableDefinitionComputeInterface() {}
+	virtual ~ColourTableDefinitionComputeInterface() {}
+	
+	virtual const Colour& getMax() const = 0;
+	virtual const Colour& getMin() const = 0;
+	virtual const string& getDirection() const = 0;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourTableDefinitionComputeInterface(const ColourTableDefinitionComputeInterface&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourTableDefinitionComputeInterface& operator=(const ColourTableDefinitionComputeInterface&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTableDefinitionComputeInterface& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/ColourTableDefinitionList.cc b/src/common/ColourTableDefinitionList.cc
new file mode 100644
index 0000000..0cc8dde
--- /dev/null
+++ b/src/common/ColourTableDefinitionList.cc
@@ -0,0 +1,101 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinitionList.cc
+    \brief Implementation of the Template class ColourTableDefinitionList.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "ColourTableDefinitionList.h"
+#include "XmlNode.h"
+
+using namespace magics;
+
+ColourTableDefinitionList::ColourTableDefinitionList() 
+{
+}
+
+
+ColourTableDefinitionList::~ColourTableDefinitionList() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ColourTableDefinitionList::print(ostream& out)  const
+{
+	out << "ColourTableDefinitionList[";
+	out << "]";
+}
+
+void ColourTableDefinitionList::set(const ColourTableDefinitionListInterface& attributes)
+{
+	colours_ = attributes.getValues();
+}
+
+void ColourTableDefinitionList::set(const XmlNode& node)
+{	
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		try {
+			Colour* colour = MagTranslator<string, Colour>()((*elt)->name());
+			colour->set(*(*elt));
+			colours_.push_back(colour->name());
+			MagLog::dev() << "add colour---" << colour->name() << "\n";
+		}
+		catch (NoFactoryException& e) {}
+	}
+}
+
+
+void  ColourTableDefinitionList::set(ColourTable& table, int nb)
+{
+	prepare();
+	if ( colours_.empty() ) {
+		MagLog::warning() << "Colour Table Definition: No colour defined\n";
+		colours_.push_back("blue");
+		colours_.push_back("green");
+		colours_.push_back("yellow");
+		colours_.push_back("orange");
+		colours_.push_back("red");
+	}
+	 
+	stringarray::const_iterator colour = colours_.begin();
+	// Nb is the number of intervals! 
+	// We need nb-1 colours!
+	for ( int i = 0; i < nb-1; i++) {
+        
+		if ( colour == colours_.end() ) {
+                MagLog::warning() << "List of colours not big enough: reuse the last colour!" << endl;
+				table.push_back(Colour(colours_.back()));
+			
+		}
+		else {
+            table.push_back(Colour(*colour));
+		    colour++;
+        }
+	}
+}
diff --git a/src/common/ColourTableDefinitionList.h b/src/common/ColourTableDefinitionList.h
new file mode 100644
index 0000000..0fe3bf8
--- /dev/null
+++ b/src/common/ColourTableDefinitionList.h
@@ -0,0 +1,74 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinitionList.h
+    \brief Definition of the Template class ColourTableDefinitionList.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTableDefinitionList_H
+#define ColourTableDefinitionList_H
+
+#include "magics.h"
+
+#include "ColourTableDefinition.h"
+#include "ColourTableDefinitionListInterface.h"
+
+
+namespace magics {
+
+class ColourTableDefinitionList: public ColourTableDefinition {
+
+public:
+	ColourTableDefinitionList();
+	virtual ~ColourTableDefinitionList();
+	void set(const ColourTableDefinitionListInterface&);
+	void set(const XmlNode&);
+	void set(ColourTable&, int);
+
+    ColourTableDefinition* clone() const {
+		ColourTableDefinitionList* object = new ColourTableDefinitionList();
+		object->colours_ = colours_;
+		return object;
+	}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 mutable stringarray colours_;
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourTableDefinitionList(const ColourTableDefinitionList&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourTableDefinitionList& operator=(const ColourTableDefinitionList&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTableDefinitionList& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/ColourTableDefinitionListInterface.h b/src/common/ColourTableDefinitionListInterface.h
new file mode 100644
index 0000000..6373152
--- /dev/null
+++ b/src/common/ColourTableDefinitionListInterface.h
@@ -0,0 +1,63 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTableDefinitionListInterface.h
+    \brief Definition of the Template class ColourTableDefinitionListInterface.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTableDefinitionListInterface_H
+#define ColourTableDefinitionListInterface_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class ColourTableDefinitionListInterface {
+
+public:
+	ColourTableDefinitionListInterface() {}
+	virtual ~ColourTableDefinitionListInterface() {}
+	virtual stringarray getValues() const = 0;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourTableDefinitionListInterface(const ColourTableDefinitionListInterface&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourTableDefinitionListInterface& operator=(const ColourTableDefinitionListInterface&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTableDefinitionListInterface& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Coordinate.cc b/src/common/Coordinate.cc
new file mode 100644
index 0000000..c4fc2d4
--- /dev/null
+++ b/src/common/Coordinate.cc
@@ -0,0 +1,55 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Coordinate.cc
+    \brief Implementation of the Template class Coordinate.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 10-Aug-2006
+    
+    Changes:
+    
+*/
+
+#include "Coordinate.h"
+
+using namespace magics;
+
+Coordinate::Coordinate() 
+{
+	if ( automatic() ) {
+		min(std::numeric_limits<double>::max());
+		max(-std::numeric_limits<double>::max());
+	}
+
+}
+
+
+Coordinate::~Coordinate() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Coordinate::print(ostream& out)  const
+{
+	out << "Coordinate[";
+	out << "]";
+}
diff --git a/src/common/Coordinate.h b/src/common/Coordinate.h
new file mode 100644
index 0000000..edb18c2
--- /dev/null
+++ b/src/common/Coordinate.h
@@ -0,0 +1,924 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Coordinate.h
+    \brief Definition of the Template class Coordinate.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 10-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef Coordinate_H
+#define Coordinate_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+#include "XRegularCoordinateAttributes.h"
+#include "YRegularCoordinateAttributes.h"
+
+#include "XLogarithmicCoordinateAttributes.h"
+#include "YLogarithmicCoordinateAttributes.h"
+
+#include "XDateCoordinateAttributes.h"
+#include "YDateCoordinateAttributes.h"
+
+#include "XHyperCoordinateAttributes.h"
+#include "YHyperCoordinateAttributes.h"
+#include "DateTime.h"
+#include "UserPoint.h"
+
+#include "XmlNode.h"
+
+#include <limits>
+namespace magics {
+
+class XmlNode;
+
+class Coordinate {
+
+public:
+	Coordinate();
+	virtual ~Coordinate();
+	
+	virtual double min() { return 0; }
+    virtual double max() { return 100; }
+    virtual double minpc() { return 0; }
+    virtual double maxpc() { return 100; }
+    virtual vector<double> maxs() { vector<double> vmax; vmax.push_back(max()); return vmax; }
+    virtual vector<double> mins() { vector<double> vmin; vmin.push_back(min()); return vmin; }
+    virtual string reference() { return ""; }
+    
+    virtual void min(double) { }
+    virtual void max(double) { }
+    
+    virtual double operator()(double c) { return c; }
+    virtual double revert(double c) { return c; }
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        
+    }
+    virtual void metadata(ostream& out) { out << "axis : {}"; }
+    virtual void set() {}
+    virtual bool accept(const string&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return false;
+    }
+    
+    virtual void toxml(ostream&) const {}
+    virtual AxisAutomaticSetting automatic() { return m_off; }
+    virtual void automatic(bool) {  }
+    virtual double operator()(const string& val) const { return tonumber(val); }
+    virtual string type() const { return "regular"; }
+    
+    
+    virtual void dataMin(double m) { 
+    	if ( automatic() == m_off || automatic()== m_max_only) return;
+//    	MagLog::dev()<< "new min-->" << m << "< " << min() << ???" << endl;  
+    	if (min() > m) min(m); 
+    }
+    virtual void dataMax(double m) { 
+    	if ( automatic()== m_off || automatic() == m_min_only) return;
+//   	MagLog::dev()<< "new max-->" << m << endl; 
+//    	MagLog::dev()<< "new max-->" << m << "> " << max() << "???" << endl;  
+    	if (  max() < m ) max(m); 
+    }
+    virtual void dataMin(double m, const string&) { if (min() > m) dataMin(m); }
+    virtual void dataMax(double m, const string&) { if (max() < m)dataMax(m); }    
+    virtual void setAutomatic(AxisAutomaticSetting) {}
+    virtual void getNewDefinition(const UserPoint&, const UserPoint&, map<string, string>&) const
+    {}
+  
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	Coordinate(const Coordinate&);
+    //! Overloaded << operator to copy - No copy allowed
+	Coordinate& operator=(const Coordinate&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Coordinate& p)
+		{ p.print(s); return s; }
+
+};
+
+class XCoordinate : public Coordinate
+{
+public:
+	XCoordinate() {}
+	virtual ~XCoordinate() {}
+	virtual XCoordinate* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new XCoordinate();
+    }
+	virtual void toxml(ostream& out) const {}
+	void set(const XmlNode& node) { }
+	void set(const map<string, string>& map) {}
+	void set() {}
+	void print(ostream& out) const {  }
+    virtual AxisAutomaticSetting automatic() { return m_off; }
+    virtual void automatic(bool val) {  }
+    bool accept(const string& tag) { }
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const XCoordinate& p)
+		{ p.print(s); return s; }
+	virtual void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+	{
+		def["x_axis_type"]= type();
+		def["x_min"]= tostring(ll.x_);
+		def["x_max"]= tostring(ur.x_);
+		def["x_automatic"]= "off";
+	}
+};
+
+class YCoordinate : public Coordinate
+{
+public:
+	YCoordinate() {}
+	virtual ~YCoordinate() {}
+	virtual void toxml(ostream& out) const {  }
+	virtual YCoordinate* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new YCoordinate();
+    }
+	virtual void automatic(bool val) {}
+	void set(const XmlNode& node) { }
+	void set(const map<string, string>& map) {}
+	void set() {}
+	void print(ostream& out) const {  }
+	bool accept(const string& tag) { return false; }
+    virtual AxisAutomaticSetting automatic() { return m_off; }
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const YCoordinate& p)
+		{ p.print(s); return s; }
+	virtual void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+		{
+			def["y_axis_type"]= type();
+			def["y_min"]= tostring(ll.y_);
+			def["y_max"]= tostring(ur.y_);
+			def["y_automatic"]= "off";
+		}
+};
+
+class RegularCoordinate 
+{
+public:
+	RegularCoordinate() {}
+	virtual ~RegularCoordinate() {}
+};
+
+class XRegularCoordinate : public RegularCoordinate, public XCoordinate, public XRegularCoordinateAttributes
+{
+public:
+	XRegularCoordinate() { 
+		set();	
+	}
+	virtual ~XRegularCoordinate() {}
+	void toxml(ostream& out) const { XRegularCoordinateAttributes::toxml(out); }
+	void set() {
+		switch ( automatic_ ) {
+			case m_both:
+				min_ = std::numeric_limits<double>::max();
+				max_ = -min_;
+				break;
+			case m_min_only:
+				min_ = std::numeric_limits<double>::max();
+				break;
+			case m_max_only:
+				max_ = -std::numeric_limits<double>::max();
+				break;
+			default:
+				break;
+		}
+	}
+	
+	virtual void set(const XmlNode& node) {
+		 XRegularCoordinateAttributes::set(node);
+        	set();
+	}
+	void set(const map<string, string>& map) {
+    	XRegularCoordinateAttributes::set(map);
+    	set();
+	}
+    virtual bool accept(const string& node) { return XRegularCoordinateAttributes::accept(node); }
+	double min() { return min_; }
+    double max() { return max_; }
+    double minpc() { return min_; }
+    double maxpc() { return max_; }
+    
+    AxisAutomaticSetting automatic() { return automatic_; }
+    virtual void setAutomatic(AxisAutomaticSetting automatic) { automatic_ = automatic; }
+    virtual void  automatic(bool automatic) { automatic_ = automatic?m_both:m_off; set(); }
+
+    void min(double m) {
+      	switch ( automatic_ ) {
+      					case m_both:
+      					case m_min_only:
+      						min_ = std::min(min_, m);
+      						break;
+      					default:
+      						break;
+      				}
+      }
+      void max(double m) {
+      	switch ( automatic_ ) {
+      		case m_both:
+      		case m_max_only:
+      			max_ = std::max(max_, m);
+      			break;
+      		default:
+      			break;
+      	}
+      }
+    
+    virtual XCoordinate* clone() const {
+    	XRegularCoordinate* x = new XRegularCoordinate();
+    	x->copy(*this);
+        return x;
+    }
+    
+    
+
+  
+    
+protected:
+	virtual void print(ostream& out) const  {
+		XRegularCoordinateAttributes::print(out);
+	}
+};
+
+class YRegularCoordinate : public RegularCoordinate,  public YCoordinate, public YRegularCoordinateAttributes
+{
+public:
+	YRegularCoordinate() {
+		set();
+	}
+	virtual ~YRegularCoordinate() {}
+
+	void toxml(ostream& out) const { YRegularCoordinateAttributes::toxml(out); }
+
+	void set() {
+		switch ( automatic_ ) {
+				case m_both:
+					min_ = std::numeric_limits<double>::max();
+					max_ = -min_;
+					break;
+				case m_min_only:
+					min_ = std::numeric_limits<double>::max();
+					break;
+				case m_max_only:
+					max_ = -std::numeric_limits<double>::max();
+					break;
+				default:
+					break;
+			}
+	}
+	double min() { return min_; }
+    double max() { return max_; }
+    double minpc() { return min_; }
+    double maxpc() { return max_; }
+    virtual void setAutomatic(AxisAutomaticSetting automatic) { automatic_ = automatic; set(); }
+    void min(double m) {
+    	switch ( automatic_ ) {
+    					case m_both:
+    					case m_min_only:
+    						min_ = std::min(m, min_);
+    						break;
+    					default:
+    						break;
+    				}
+    }
+    void max(double m) {
+    	switch ( automatic_ ) {
+    		case m_both:
+    		case m_max_only:
+    			max_ = std::max(m, max_);
+    			break;
+    		default:
+    			break;
+    	}
+    }
+
+    virtual void automatic(bool automatic) { automatic_ = automatic?m_both:m_off; set();}
+    virtual YCoordinate* clone() const {
+    	YRegularCoordinate* y = new YRegularCoordinate();
+    	y->copy(*this);
+        return y;
+    }
+    void set(const XmlNode&  node ) { 
+	YRegularCoordinateAttributes::set(node);
+	set(); }
+    void set(const map<string, string>& map) { 
+    	YRegularCoordinateAttributes::set(map);
+    	set();
+	}
+    bool accept(const string& node) { return YRegularCoordinateAttributes::accept(node); }
+
+    void setMin(double min) { min_ = min; }
+    void setMax(double max) { max_ = max; }
+    AxisAutomaticSetting automatic() { return automatic_; }
+    
+   
+protected:
+	virtual void print(ostream& out) const  {
+		YRegularCoordinateAttributes::print(out);
+	}
+};
+
+
+class LogarithmicCoordinate : public Coordinate
+{
+public:
+	LogarithmicCoordinate() {}
+	virtual ~LogarithmicCoordinate() {}
+	string type() const { return "logarithmic"; }
+
+};
+
+class XLogarithmicCoordinate : public LogarithmicCoordinate,  public XCoordinate, public XLogarithmicCoordinateAttributes
+{
+public:
+	XLogarithmicCoordinate() {}
+	virtual ~XLogarithmicCoordinate() {}
+	virtual void toxml(ostream& out) const { XLogarithmicCoordinateAttributes::toxml(out); }
+	double min() { return min_; }
+    double max() { return max_; }
+    double minpc() { return (*this)(min_); }
+    double maxpc() { return (*this)(max_); }
+    virtual void set(const XmlNode& node) {
+	    if ( !magCompare(node.name(), "x_logarithmic") ) return; 
+		XmlNode regular = node;
+		regular.name("x_regular");
+		XLogarithmicCoordinateAttributes::set(regular);
+        set();
+    }
+    void set() {
+    		switch ( automatic_ ) {
+    				case m_both:
+    					min_ = std::numeric_limits<double>::max();
+    					max_ = -min_;
+    					break;
+    				case m_min_only:
+    					min_ = std::numeric_limits<double>::max();
+    					break;
+    				case m_max_only:
+    					max_ = -std::numeric_limits<double>::max();
+    					break;
+    				default:
+    					break;
+    			}
+    	}
+    void min(double m) {
+    	switch ( automatic_ ) {
+    					case m_both:
+    					case m_min_only:
+    						min_ =std::min(m, min_);
+    						break;
+    					default:
+    						break;
+    				}
+    }
+    void max(double m) {
+    	switch ( automatic_ ) {
+    		case m_both:
+    		case m_max_only:
+    			max_ = std::max(m, max_);
+    			break;
+    		default:
+    			break;
+    	}
+    }
+
+    double operator()(double c ) { return (c) ? log10(c) :0 ; }
+    double revert(double c ) { return pow(c, 10); }
+    
+     virtual XCoordinate* clone() const {
+    	XLogarithmicCoordinate* x = new XLogarithmicCoordinate();
+    	x->copy(*this);
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return x;
+    }
+    
+    void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+    {
+		def["x_axis_type"]= "logarithmic";
+		def["x_min"]= tostring( ll.x_);
+		def["x_max"]= tostring( ur.x_);
+		def["x_automatic"]= "off";
+    }
+    AxisAutomaticSetting automatic() { return automatic_; }
+    virtual void automatic(bool automatic) { automatic_ = (automatic?m_both:m_off);}
+    virtual void setAutomatic(AxisAutomaticSetting automatic) { automatic_ = automatic; }
+protected:
+	virtual void print(ostream& out) const  {
+		out << "XLogarithmicCoordinate[";
+		XLogarithmicCoordinateAttributes::print(out);
+		out << "]";
+	}
+};
+
+
+class YLogarithmicCoordinate : public LogarithmicCoordinate,  public YCoordinate, public YLogarithmicCoordinateAttributes
+{
+public:
+	YLogarithmicCoordinate() {}
+	virtual ~YLogarithmicCoordinate() {}
+	virtual void set(const XmlNode& node) {
+		if ( !magCompare(node.name(), "y_logarithmic") ) return; 
+		XmlNode regular = node;
+		regular.name("y_regular");
+		YLogarithmicCoordinateAttributes::set(regular);
+        set();
+    }
+
+	virtual void toxml(ostream& out) const { YLogarithmicCoordinateAttributes::toxml(out); }
+	void set() {
+		switch ( automatic_ ) {
+				case m_both:
+					min_ = std::numeric_limits<double>::max();
+					max_ = -min_;
+					break;
+				case m_min_only:
+					min_ = std::numeric_limits<double>::max();
+					break;
+				case m_max_only:
+					max_ = -std::numeric_limits<double>::max();
+					break;
+				default:
+					break;
+			}
+	}
+	double min() { return min_; }
+    double max() { return max_; }
+    double minpc() { return (*this)(min_); }
+    double maxpc() { return (*this)(max_); }
+
+    void min(double m) {
+    	switch ( automatic_ ) {
+    					case m_both:
+    					case m_min_only:
+    						min_  =std::min(m, min_);;
+    						break;
+    					default:
+    						break;
+    				}
+    }
+    void max(double m) {
+    	switch ( automatic_ ) {
+    		case m_both:
+    		case m_max_only:
+    			max_ = std::max(m, max_);;
+    			break;
+    		default:
+    			break;
+    	}
+    }
+    void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+    {
+    	def["y_axis_type"]= "logarithmic";
+    	def["y_min"]= tostring(exp10(ll.y_));
+    	def["y_max"]= tostring(exp10(ur.y_));
+		def["y_automatic"]= "off";
+    }
+    AxisAutomaticSetting automatic() { return automatic_; }
+    
+    void setMin(double min) { min_ = min; }
+    void setMax(double max) { max_ = max; }
+    double operator()(double c ) {  return (c) ? log10(c) :0 ; }
+    double revert(double c ) { return exp10(c); }
+    virtual YCoordinate* clone() const {
+    	YLogarithmicCoordinate* y = new YLogarithmicCoordinate();
+    	y->copy(*this);
+        return y;
+    }
+
+    virtual void automatic(bool automatic) { automatic_ = automatic?m_both:m_off;}
+    virtual void setAutomatic(AxisAutomaticSetting automatic) { automatic_ = automatic; }
+    
+protected:
+	virtual void print(ostream& out) const  {
+		out << "YLogarithmicCoordinate[";
+		YLogarithmicCoordinateAttributes::print(out);
+		out << "]";
+	}
+};
+
+
+class DateCoordinate 
+{
+public:
+	DateCoordinate() {}
+	virtual ~DateCoordinate() {}   
+	virtual string type() const { return "date"; }
+
+};
+
+class XDateCoordinate : public DateCoordinate, public XDateCoordinateAttributes, public XCoordinate
+{
+public:
+	XDateCoordinate() { anna_ = false; }
+	virtual ~XDateCoordinate() {}
+	virtual void toxml(ostream& out) const {XDateCoordinateAttributes::toxml(out); }
+	double min() { return 0; }
+    double max() { return DateTime(date_max_) - DateTime(date_min_); }
+    	
+    double minpc() { return anna_ ? min_anna_ : 0; }
+    double maxpc() { return anna_ ? max_anna_ : max(); }
+    
+    void min(double min) { min_anna_ = min; anna_ = true; }
+    void max(double max) { max_anna_ = max; anna_ = true;}
+
+    string reference() { return  DateTime(date_min_); }
+    virtual XCoordinate* clone() const {
+    	XDateCoordinate* x = new XDateCoordinate();
+    	//x->copy(*this);
+        return x;
+    }
+    virtual string type() const { return "date"; }
+    AxisAutomaticSetting automatic() { return automatic_ ? m_both:  m_off;}
+    void set(const XmlNode& node) { XDateCoordinateAttributes::set(node);  }
+    void set(const map<string, string>& map) { XDateCoordinateAttributes::set(map); }
+    bool accept(const string& xml) { return XDateCoordinateAttributes::accept(xml); }
+    
+    void setMin(double) { }
+    void setMax(double) { }
+    
+    void automatic(bool automatic) { automatic_ = (automatic?m_both:m_off); }
+    virtual void setAutomatic(AxisAutomaticSetting automatic) { automatic_ = (automatic); }
+    
+    void setMin(const string& min) { date_min_ = min; }
+    void setMax(const string& max) { date_max_ = max;}
+    
+    void dataMin(double min, const string& date) { 
+    	switch ( automatic_ ) {
+    		case m_both:
+    		case m_min_only: {
+    			DateTime newmin(date);
+    			newmin = newmin + Second(min);
+    			date_min_ = string(newmin);
+    			break;
+    		}
+    		default:
+    			break;
+    	}
+
+    }
+    void dataMax(double max, const string& date) { 
+    	switch ( automatic_ ) {
+			case m_both:
+			case m_max_only: {
+				DateTime newmax(date);
+				newmax = newmax + Second(max);
+				date_max_ = string(newmax);
+				break;
+			}
+			default:
+				break;
+		}
+    } 
+     
+    double operator()(double c ) { return c; }
+    
+    double operator()(const string& val) const  { 
+    	DateTime date(val); 
+    	return date - DateTime(date_min_);
+    }
+
+    void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+    {
+    	DateTime min = DateTime(date_min_) + Second(ll.x_);
+    	DateTime max = DateTime(date_min_) + Second(ur.x_);
+    		def["x_axis_type"]="date";
+    		def["x_date_min"]= tostring(min);
+    		def["x_date_max"]= tostring(max);
+    		def["x_automatic"]= "off";
+    	}
+	
+	
+protected:
+	virtual void print(ostream& out) const  {
+		XDateCoordinateAttributes::print(out);
+	}
+	// patch for anna! 
+	
+	double min_anna_;
+	double max_anna_;
+	bool anna_;
+
+};
+
+
+class YDateCoordinate : public DateCoordinate, public YDateCoordinateAttributes, public YCoordinate
+{
+public:
+	YDateCoordinate() {}
+	virtual ~YDateCoordinate() {}
+	virtual void toxml(ostream& out) const { YDateCoordinateAttributes::toxml(out); }
+	double min()   { return 0; }
+    double max()   { return DateTime(date_max_) - DateTime(date_min_); }
+    double minpc()     { return 0; }
+    double maxpc()     { return DateTime(date_max_) - DateTime(date_min_);}
+    string reference() { return DateTime(date_min_); }
+    virtual string type() const { return "date"; }
+    bool accept(const string& xml) { return YDateCoordinateAttributes::accept(xml); }
+    void set(const XmlNode& node) { YDateCoordinateAttributes::set(node); }
+       void set(const map<string, string>& map) { YDateCoordinateAttributes::set(map);  }
+    virtual void setAutomatic(AxisAutomaticSetting automatic) { automatic_ = (automatic); }
+    void automatic(bool automatic) { automatic_ = (automatic?m_both:m_off); }
+
+    virtual YCoordinate* clone() const {
+    	YDateCoordinate* y = new YDateCoordinate();
+    	//y->copy(*this);
+        return y;
+    }
+    AxisAutomaticSetting automatic() { return automatic_ ? m_both:  m_off; }
+    
+    void setMin(double) { }
+    void setMax(double) { }
+    
+    void setMin(const string& min) { date_min_ = min; }
+    void setMax(const string& max) { date_max_ = max;}
+    
+    double operator()(double c ) { return c; }
+    double operator()(const string& val) const  { 
+    	DateTime date(val); 
+    	return date -  DateTime(date_min_);
+    }
+    void dataMin(double min, const string& date) { 
+        	switch ( automatic_ ) {
+        		case m_both:
+        		case m_min_only: {
+        			DateTime newmin(date);
+        			newmin = newmin + Second(min);
+        			setMin(string(newmin));
+        			break;
+        		}
+        		default:
+        			break;
+        	}
+
+        }
+        void dataMax(double max, const string& date) {
+        	switch ( automatic_ ) {
+    			case m_both:
+    			case m_max_only: {
+    				DateTime newmax(date);
+    				newmax = newmax + Second(max);
+    				setMax(string(newmax));
+    				break;
+    			}
+    			default:
+    				break;
+    		}
+        }
+        void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+        {
+        	DateTime min = DateTime(date_min_) + Second(ll.y_);
+        	DateTime max = DateTime(date_min_) + Second(ur.y_);
+        		def["y_axis_type"]="date";
+        		def["y_date_min"]= tostring(min);
+        		def["y_date_max"]= tostring(max);
+        		def["y_automatic"]= "off";
+        	}
+
+protected:
+	virtual void print(ostream& out) const  {
+		YDateCoordinateAttributes::print(out);
+	}
+};
+
+
+class YHyperCoordinate : public YHyperCoordinateAttributes, public YCoordinate
+{
+public:
+	YHyperCoordinate() {}
+	virtual ~YHyperCoordinate() {}
+	double min()   { return min_lon_; }
+    double max()   { return max_lon_; }
+    double minpc()     { return min_lon_; }
+    double maxpc()     { return max_lon_; }
+    string reference() { return ""; }
+    void toxml(ostream& out) const { YHyperCoordinateAttributes::toxml(out); }
+     bool accept(const string& xml) { return YHyperCoordinateAttributes::accept(xml); }
+    void set(const XmlNode& node) { YHyperCoordinateAttributes::set(node); }
+    void set(const map<string, string>& map) { YHyperCoordinateAttributes::set(map); }
+    virtual void setAutomatic(bool automatic) {automatic_ = automatic?m_both:m_off; }
+    void automatic(bool automatic) { automatic_ = automatic?m_both:m_off; }
+    
+    virtual YCoordinate* clone() const {
+    	YHyperCoordinate* y = new YHyperCoordinate();
+    	//y->copy(*this);
+        return y;
+    }
+    AxisAutomaticSetting automatic() { return automatic_ ; }
+    
+    void setMin(double) { }
+    void setMax(double) { }
+    
+    vector<double> mins() { vector<double> mins; mins.push_back(min_lon_); mins.push_back(min_lat_);  return mins; }
+     vector<double> maxs() {  vector<double> maxs; maxs.push_back(max_lon_); maxs.push_back(max_lat_);  return maxs; }
+     string type() const { return "geoline"; }
+     void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+     {
+    	double lon1 = ll.y();
+		double lon2 = ur.y();
+
+      	double lat1 = (max_lat_-min_lat_) ? min_lat_ + ((lon1-min_lon_)/(max_lon_-min_lon_))* (max_lat_-min_lat_) : 0;
+        double lat2 = (max_lat_-min_lat_) ? min_lat_ + ((lon2-min_lon_)/(max_lon_-min_lon_)) * (max_lat_-min_lat_) : 0;
+        def["y_automatic"]="off";
+		def["y_axis_type"]="geoline";
+		def["y_min_latitude"]= tostring(lat1);
+		def["y_max_latitude"]= tostring(lat2);
+		def["y_min_longitude"]= tostring(lon1);
+		def["y_max_longitude"]= tostring(lon2);
+     }void dataMin(double min, const string& info) {
+
+    	 //interpret the info : lonmin/latmin
+    	 Tokenizer tokenizer("/");
+    	 vector<string> tokens;
+    	 tokenizer(info, tokens);
+            	switch ( automatic_ ) {
+            		case m_both:
+            		case m_min_only: {
+            			min_lon_ = tonumber(tokens[0]);
+            			min_lat_ = tonumber(tokens[1]);
+            			break;
+            		}
+            		default:
+            			break;
+            	}
+
+            }
+            void dataMax(double max, const string& info) {
+
+            	//interpret the info : lonmin/latmin
+            	Tokenizer tokenizer("/");
+            	vector<string> tokens;
+            	tokenizer(info, tokens);
+            	switch ( automatic_ ) {
+        			case m_both:
+        			case m_max_only: {
+        				max_lon_ = tonumber(tokens[0]);
+        				max_lat_ = tonumber(tokens[1]);
+        				break;
+        			}
+        			default:
+        				break;
+        		}
+            }
+protected:
+	virtual void print(ostream& out) const  {
+		YHyperCoordinateAttributes::print(out);
+	}
+};
+
+class XHyperCoordinate : public XHyperCoordinateAttributes, public XCoordinate
+{
+public:
+	XHyperCoordinate() {}
+	virtual ~XHyperCoordinate() {}
+	double min()   { return min_lon_; }
+    double max()   { return max_lon_; }
+    double minpc()     { return min_lon_; }
+    double maxpc()     { return max_lon_; }
+    string reference() { return ""; }
+    void toxml(ostream& out) const { XHyperCoordinateAttributes::toxml(out); }
+     bool accept(const string& xml) { return XHyperCoordinateAttributes::accept(xml); }
+    void set(const XmlNode& node) { XHyperCoordinateAttributes::set(node); }
+    void set(const map<string, string>& map) { XHyperCoordinateAttributes::set(map); }
+    virtual void setAutomatic(bool automatic) { automatic_ = (automatic?m_both:m_off); }
+    void automatic(bool automatic) {  automatic_ = automatic?m_both:m_off; }
+    vector<double> mins() { vector<double> mins; mins.push_back(min_lon_); mins.push_back(min_lat_);  return mins; }
+    vector<double> maxs() {  vector<double> maxs; maxs.push_back(max_lon_); maxs.push_back(max_lat_);  return maxs; }
+    
+    virtual XCoordinate* clone() const {
+    	XHyperCoordinate* x = new XHyperCoordinate();
+
+        return x;
+    }
+    AxisAutomaticSetting automatic() { return automatic_ ? m_both:  m_off; }
+    
+    void setMin(double) { }
+    void setMax(double) { }
+    
+     string type() const { return "geoline"; }
+     void dataMin(double min, const string& info) {
+
+    	 //interpret the info : lonmin/latmin
+    	 Tokenizer tokenizer("/");
+    	 vector<string> tokens;
+    	 tokenizer(info, tokens);
+            	switch ( automatic_ ) {
+            		case m_both:
+            		case m_min_only: {
+            			min_lon_ = tonumber(tokens[0]);
+            			min_lat_ = tonumber(tokens[1]);
+            			break;
+            		}
+            		default:
+            			break;
+            	}
+
+            }
+            void dataMax(double max, const string& info) {
+
+            	//interpret the info : lonmin/latmin
+            	Tokenizer tokenizer("/");
+            	vector<string> tokens;
+            	tokenizer(info, tokens);
+            	switch ( automatic_ ) {
+        			case m_both:
+        			case m_max_only: {
+        				max_lon_ = tonumber(tokens[0]);
+        				max_lat_ = tonumber(tokens[1]);
+        				break;
+        			}
+        			default:
+        				break;
+        		}
+            }
+            void getNewDefinition(const UserPoint& ll, const UserPoint& ur, map<string, string>& def) const
+            {
+            	double lon1 = ll.x();
+            	double lon2 = ur.x();
+
+            	// we have to compute the lat and lon of the point!
+
+            	double lat1 = (max_lat_-min_lat_) ? min_lat_ + ((lon1-min_lon_)/(max_lon_-min_lon_))* (max_lat_-min_lat_) : 0;
+            	double lat2 = (max_lat_-min_lat_) ? min_lat_ + ((lon2-min_lon_)/(max_lon_-min_lon_)) * (max_lat_-min_lat_) : 0;
+            	def["x_automatic"]="off";
+                def["x_axis_type"]="geoline";
+                def["x_min_latitude"]= tostring(lat1);
+                def["x_max_latitude"]= tostring(lat2);
+                def["x_min_longitude"]= tostring(lon1);
+                def["x_max_longitude"]= tostring(lon2);
+               }
+
+protected:
+	virtual void print(ostream& out) const  {
+		XHyperCoordinateAttributes::print(out);
+	}
+};
+
+template <>
+class MagTranslator<string, XCoordinate> { 
+public:
+	XCoordinate* operator()(const string& val )
+	{
+		return SimpleObjectMaker<XCoordinate>::create(val);
+	}     
+
+	XCoordinate* magics(const string& param)
+	{
+		XCoordinate* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+template <>
+class MagTranslator<string, YCoordinate> { 
+public:
+	YCoordinate* operator()(const string& val )
+	{
+		return SimpleObjectMaker<YCoordinate>::create(val);
+	}     
+
+	YCoordinate* magics(const string& param)
+	{
+		YCoordinate* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+} // namespace magics
+#endif
diff --git a/src/common/CustomisedPoint.h b/src/common/CustomisedPoint.h
new file mode 100644
index 0000000..81ddeeb
--- /dev/null
+++ b/src/common/CustomisedPoint.h
@@ -0,0 +1,111 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CustomisedPoint.h
+    \brief Definition of the Template class CustomisedPoint.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 19-May-2005
+    
+    Changes:
+    
+*/
+
+#ifndef CustomisedPoint_H
+#define CustomisedPoint_H
+
+#include "magics.h"
+#include "VectorOfPointers.h"
+#include "DateTime.h"
+
+namespace magics {
+
+class CustomisedPoint : public map<string, double> {
+
+public:
+	CustomisedPoint(): missing_(false) {}
+	CustomisedPoint(double lon, double lat, string ident) :
+		latitude_(lat), longitude_(lon), identifier_(ident), missing_(false){}
+	virtual ~CustomisedPoint() {}
+	
+	double latitude() const { return latitude_; }
+	void latitude(double latitude) { latitude_ = latitude; }
+	
+	double longitude() const { return longitude_; }
+	void longitude(double longitude) { longitude_ = longitude; }
+	
+	const DateTime& reference() const { return reference_; }
+	void reference(DateTime ref) { reference_ = ref; }
+	
+	const DateTime& base() const { return base_; }
+	void base(DateTime base) { base_ = base; }
+	
+	const DateTime& valid() const { return valid_; }
+	void valid(DateTime valid) { valid_ = valid; }
+	
+	double referenceStep() const { return valid_- reference_; }
+	double step() const { return valid_- base_; }
+	
+	string identifier() const { return identifier_; }
+	void identifier(const string& identifier) { identifier_ = identifier; }
+
+	string type() const { return type_; }
+	void type(const string& type) { type_ = type; }
+	bool missing() const { return missing_; }
+	void missing(bool missing) { missing_  = missing; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const
+	 { 
+	 	out << "CustomisedPoint[";
+	 	out << "latitude=" << latitude_;
+	 	out << ", longitude=" << longitude_;
+	 	out << ", identifier=" << identifier_;
+	 	for ( const_iterator value = begin(); value != end(); ++ value) 
+	 		out << ", " << value->first << "=" << value->second;
+	 	out << "]";
+	 }  
+	 double  latitude_;
+	 double  longitude_;
+	 string   identifier_;
+	 string   type_;
+     DateTime base_;
+     DateTime valid_;
+     DateTime reference_;
+     bool     missing_;
+     
+private:
+    //! Copy constructor - No copy allowed
+	CustomisedPoint(const CustomisedPoint&);
+    //! Overloaded << operator to copy - No copy allowed
+	CustomisedPoint& operator=(const CustomisedPoint&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CustomisedPoint& p)
+		{ p.print(s); return s; }
+
+};
+
+
+typedef  VectorOfPointers< vector<CustomisedPoint*> > CustomisedPointsList;  
+
+} // namespace magics
+#endif
diff --git a/src/common/Data.cc b/src/common/Data.cc
new file mode 100644
index 0000000..885b082
--- /dev/null
+++ b/src/common/Data.cc
@@ -0,0 +1,132 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Data.h
+    \brief Definition of the Abstract template class Data.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+
+#include "Data.h"
+
+void Data::computeStats()
+{
+	map<string,vector<double> >::iterator itX, itY, itV;	
+	itX=stats_.find("x");
+	itY=stats_.find("y");
+	itV=stats_.find("value");
+
+	//X and Y for scatterplots
+	if(info("statsType") == "scatter" && 
+	   itX != stats_.end() && itY != stats_.end())
+	{
+		DataStats stX(itX->second);
+		DataStats stY(itY->second);	
+
+		std::map<string,DataStats*> st;
+		st["_x"]=&stX;
+		st["_y"]=&stY;
+	  	
+		for(std::map<string,DataStats*>::iterator it=st.begin(); it != st.end(); it++)
+		{
+		 	setInfo("stats::points" + it->first,tostring(it->second->num()));
+			setInfo("stats::min" + it->first, tostring(it->second->min()));	
+			setInfo("stats::max" + it->first, tostring(it->second->max()));
+			setInfo("stats::avg" + it->first, tostring(it->second->mean()));
+			if(it->second->hasStDev()) setInfo("stats::stdev" + it->first,tostring(it->second->stDev()));
+				else setInfo("stats::stdev" + it->first,"-");
+		}
+		
+		setInfo("stats::correlation",tostring(DataStats::correlation(itX->second,itY->second,stX,stY)));
+	}
+	
+	else if(info("statsType") == "vector" && 
+	        itX != stats_.end() && itY != stats_.end())
+	{		
+		DataStats stX(itX->second);
+		DataStats stY(itY->second);
+	  	
+		std::map<string,DataStats*> st;
+		st["_x"]=&stX;
+		st["_y"]=&stY;
+	  	
+		for(std::map<string,DataStats*>::iterator it=st.begin(); it != st.end(); it++)
+		{
+		 	setInfo("stats::points" + it->first,tostring(it->second->num()));
+			setInfo("stats::min" + it->first, tostring(it->second->min()));	
+			setInfo("stats::max" + it->first, tostring(it->second->max()));
+			setInfo("stats::avg" + it->first, tostring(it->second->mean()));
+			setInfo("stats::stdev" + it->first,"-");
+			setInfo("stats::skewness" + it->first,"-");		
+			setInfo("stats::kurtosis" + it->first,"-");	
+	
+			if(it->second->hasStDev())
+			{
+				setInfo("stats::stdev" + it->first,tostring(it->second->stDev()));
+				if(it->second->hasThirdMoment())
+				{
+					setInfo("stats::skewness" + it->first,tostring(it->second->skewness()));
+					setInfo("stats::kurtosis" + it->first,tostring(it->second->kurtosis()));
+				}
+			}	
+		}
+	}
+
+        //Value		
+	if(itV != stats_.end())
+	{
+		if(itV->second.size() == 0)	
+		{
+			setInfo("stats::min","");
+    			setInfo("stats::max","");
+			setInfo("stats::avg","");
+    			setInfo("stats::points","");
+			return;
+		}	
+
+		DataStats st(itV->second);
+		setInfo("stats::points",tostring(st.num()));
+		setInfo("stats::min", tostring(st.min()));
+    		setInfo("stats::max", tostring(st.max()));
+		setInfo("stats::avg", tostring(st.mean()));
+		setInfo("stats::stdev","-");
+		setInfo("stats::skewness","-");		
+		setInfo("stats::kurtosis","-");
+
+		if(st.hasStDev())
+		{
+			setInfo("stats::stdev",tostring(st.stDev()));
+			if(st.hasThirdMoment())
+			{
+				setInfo("stats::skewness",tostring(st.skewness()));
+				setInfo("stats::kurtosis",tostring(st.kurtosis()));
+			}
+		}
+	}
+
+	stats_.clear();	
+}
+
+int Data::uniqueOwnerId_ = 0;
+
diff --git a/src/common/Data.h b/src/common/Data.h
new file mode 100644
index 0000000..83599b6
--- /dev/null
+++ b/src/common/Data.h
@@ -0,0 +1,224 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Data.h
+    \brief Definition of the Abstract template class Data.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Data_H
+#define Data_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "MatrixHandler.h"
+#include "PointsHandler.h"
+#include "RasterData.h"
+#include "CustomisedPoint.h"
+#include "RasterData.h"
+#include "Transformation.h"
+#include "Layer.h"
+#include "DateTime.h"
+#include "MagicsEvent.h"
+#include "ThinningMethod.h"
+#include "DataStats.h"
+#include "BinningObject.h"
+
+namespace magics {
+
+class LegendVisitor;
+class TextVisitor;
+class MetaDataVisitor; 
+class MagnifierVisitor; 
+class LayerNode;
+class AnimationRules;
+class AnimationStep;
+
+
+
+
+
+class DataInMemory : public MagicsException
+{
+public:
+	 DataInMemory():
+		MagicsException("Data in Memory..." ) {}
+};     
+
+
+
+class Data: public MetviewIcon{
+
+public:
+	Data(): name_("no_name"), binning_(0), dimension_(1) {}
+	virtual ~Data() { if ( binning_ ) delete binning_; }
+    //! Method to access the data as a matrix Used by pcont action routine
+    virtual MatrixHandler& matrix() { throw MethodNotYetImplemented("Data::matrix"); }
+    virtual MatrixHandler& matrix(const Transformation&) { throw MethodNotYetImplemented("Data::matrix"); }
+    
+
+    void binning(BinningObject* binning) { binning_ = binning; }
+
+  
+
+
+
+    virtual void release() {}
+    
+    virtual void getReady(const Transformation&) {}
+    virtual void visit(Transformation&)          {}
+    
+    //! Methods to access the data as a file used by pplot action routine
+    virtual string path() { throw DataInMemory(); }
+    //! Methods to access the data as a RasterData used by pimage action routine.
+    virtual RasterData& raster(const Transformation&) { throw MethodNotYetImplemented("Data<P>::raster"); }
+    
+    virtual void getInfo(const std::set<string>&, multimap<string, string>&) 
+    { throw MethodNotYetImplemented("Data::getInfo"); }
+    
+    virtual bool check(const Transformation& transformation, UserPoint& point) {
+		bool c = transformation.in(point);
+    	if ( !c) 
+    		point.flagMissing();
+			return c;
+    }
+    //! Method to access the data as a list of points
+   // needMissing : if true the list will contain all the points ( If they are outside the area: They will be flagged missing)
+    virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, bool ) = 0;
+    //! Method to access the data as a list of points
+     // needMissing : if true the list will contain all the points (If they are outside the area: They will be flagged missing)
+     virtual PointsHandler& points(const Transformation&, bool) =0;
+
+    virtual void customisedPoints(const AutomaticThinningMethod&, const Transformation& transformation, const std::set<string>& need , CustomisedPointsList& out)
+           { customisedPoints(transformation, need, out, false); }
+    virtual void customisedPoints(const BasicThinningMethod&, const Transformation& transformation, const std::set<string>& need , CustomisedPointsList& out) 
+             { customisedPoints(transformation, need, out, false); }
+    virtual void visit(TextVisitor&) {}
+    virtual void visit(LegendVisitor&) {}
+    virtual void visit(AnimationRules&) {}
+    virtual void visit(AnimationStep&) {}
+    virtual void visit(MetaDataVisitor&) {} 
+    virtual void visit(Layer& layer) { 
+    	MetviewIcon::visit(layer);
+    	layer.name(name());
+    	layer.valid(from(), to());
+    }
+    virtual void visit(MetaDataCollector& collector)  {MetviewIcon::visit(collector);}  
+    virtual void visit(ValuesCollector&) {}
+    virtual void visit(DataIndexCollector& dc) {dc.setDataIndex(dataIndex_);} 
+    virtual void visit(MagnifierCollector& magnifier) {
+    	const Transformation& transformation = magnifier.transformation();
+    	PointsHandler& list = this->points(transformation, true);
+
+    	list.setToFirst();
+    	while (list.more()) {   		
+    		magnifier.push_back(transformation(list.current()));
+    		list.advance();
+    	}  
+    }
+    virtual void initInfo() {MetviewIcon::initInfo();}
+    string legend() { return legend_; }
+    
+    // Information needed fron layer management!
+    virtual string layerId()  {  return  ( layerId_.empty() ) ?  iconName_ + "/ " + iconClass_  : layerId_  ; }
+    virtual string name()  { return  ( iconName_.empty() ) ? name_ : iconName_; }
+    virtual const DateTime& from()  { return from_; }
+    virtual const DateTime& to()  { return to_; }
+    virtual const DateDescription& timeStamp() { return timeStamp_; }
+    virtual const LevelDescription& level()  { return dataLevel_; }
+ virtual string legendText(double,double) {return string();}
+ 	 int dimension() const { return dimension_; }
+ 	 void index(int i ) { index_ = i; }
+ 	 static int getUniqueOwnerId() {
+ 		uniqueOwnerId_++;
+ 		return uniqueOwnerId_;
+ 	 }
+protected:
+     int dimension_;
+     int index_;
+     static int uniqueOwnerId_; // Metview usage for overlay control
+
+ 	 DateDescription timeStamp_;
+     LevelDescription dataLevel_;
+
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+    virtual void print(ostream& out) const { out << "Data<P>"; }
+    virtual void computeStats();
+    
+     VectorOfPointers<vector<PointsHandler* > > pointsHandlers_;
+     // The objects are put in a list, they will be automaticcaly destructed 
+     VectorOfPointers<vector<MatrixHandler* > > matrixHandlers_;
+
+	string legend_;
+	
+	string name_;
+	string layerId_;
+	DateTime from_;
+	DateTime to_;
+	map<string,vector<double> > stats_;
+	vector<int> dataIndex_;
+
+
+	BinningObject* binning_;
+
+private:
+    //! Copy constructor - No copy allowed
+	Data(const Data&);
+    //! Overloaded << operator to copy - No copy allowed
+	Data& operator=(const Data&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Data& p)
+		{ p.print(s); return s; }
+};
+
+
+
+
+
+class DataLoop: public MetviewIcon
+{ 
+public:
+	DataLoop() {}
+	virtual ~DataLoop() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual void set(LayerNode&) {}
+	
+	virtual void setToFirst() {}
+	virtual Data* current() = 0;
+	virtual bool         hasMore() = 0;
+	virtual void         next() = 0;
+	virtual void add(Data*) {}
+	virtual string layerId()  {  return   iconName_ + "/ " + iconClass_   ; }
+	virtual string name()  { return  iconName_; }
+	virtual void visit(Transformation&) {}
+	void visit(Layer& layer) { MetviewIcon::visit(layer); }
+};
+} // namespace magics
+
+
+#endif
diff --git a/src/common/DataStats.cc b/src/common/DataStats.cc
new file mode 100644
index 0000000..d14dcd2
--- /dev/null
+++ b/src/common/DataStats.cc
@@ -0,0 +1,107 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DataStats.cc
+    \brief Implementation of the class DataStats.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: April 2011
+    
+    Changes:
+    
+*/
+
+#include <algorithm>
+#include <numeric> 
+#include <math.h>
+
+#include "DataStats.h"
+
+DataStats::DataStats(vector<double>& data)
+{
+	num_=0; 
+	hasStDev_=false;
+	hasThirdMoment_=false;
+	
+	compute(data);
+}
+
+void DataStats::compute(vector<double> &data)
+{
+	num_=data.size();
+
+	if(num_==0)
+	{
+		return;
+	}
+
+	min_ = *(std::min_element(data.begin(), data.end()));
+	max_ = *(std::max_element(data.begin(), data.end()));
+	
+	mean_ = std::accumulate(data.begin(), data.end(), 0.0) / data.size();
+
+	if(data.size() >= 1)
+	{					
+  		double v,m2=0.,m3=0.,m4=0.;
+			
+		for(vector<double>::const_iterator it=data.begin(); it != data.end(); it++)
+		{
+			v=(*it)-mean_;
+			m2+=v*v;
+			m3+=v*v*v;
+			m4+=v*v*v*v;
+		}
+
+		m2/=data.size();
+		m3/=data.size();
+		m4/=data.size();
+			
+		stDev_=sqrt(m2);
+		hasStDev_=true;
+
+		if(m2 != 0)
+		{
+			skewness_=m3/(stDev_*stDev_*stDev_);
+			kurtosis_=m4/(m2*m2)-3.;	
+			hasThirdMoment_=true;
+		}
+	}
+}
+
+double DataStats::correlation(vector<double> &dataX,vector<double> &dataY, DataStats &stX, DataStats &stY)
+{
+	double corr=0.;
+
+	if(stX.hasStDev() == false || stY.hasStDev() == false || 
+	   stX.stDev() <=0. || stY.stDev() <= 0. ||
+	   stX.num() != stY.num() || dataX.size() != stX.num() ||
+           dataY.size() != stY.num() || stX.num() ==0)
+	{
+		return corr;
+	}
+
+	for(unsigned int i=0; i < dataX.size() ; i++)
+	{	
+		corr+=(dataX[i]-stX.mean())*(dataY[i]-stY.mean());
+	}
+	
+	corr/=stX.num()*stX.stDev()*stY.stDev();
+
+	return corr;
+}
diff --git a/src/common/DataStats.h b/src/common/DataStats.h
new file mode 100644
index 0000000..a361607
--- /dev/null
+++ b/src/common/DataStats.h
@@ -0,0 +1,68 @@
+
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DataStats.h
+    \brief Definition of the  class  dataStats.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: April 2011
+    
+    Changes:
+    
+*/
+
+#ifndef DataStats_H
+#define DataStats_H
+
+#include <vector>
+
+using namespace std;
+
+class DataStats
+{
+public:
+	DataStats(vector<double>&);
+
+	unsigned int num() {return num_;}
+	double min() {return min_;}
+	double max() {return max_;}
+	double mean() {return mean_;}
+	double stDev() {return stDev_;}
+	double skewness() {return skewness_;}
+	double kurtosis() {return kurtosis_;}
+	bool hasStDev() {return hasStDev_;}
+	bool hasThirdMoment() {return hasThirdMoment_;}
+	static double correlation(vector<double>&,vector<double>&,DataStats&,DataStats&);
+
+private:
+	void compute(vector<double>&);
+
+	unsigned int num_;
+	double min_;
+	double max_;
+	double mean_;
+	double stDev_;
+	double skewness_;
+	double kurtosis_;
+	bool hasStDev_;
+	bool hasThirdMoment_;
+};
+
+#endif
diff --git a/src/common/Decoder.h b/src/common/Decoder.h
new file mode 100644
index 0000000..d1b2f88
--- /dev/null
+++ b/src/common/Decoder.h
@@ -0,0 +1,64 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Decoder.h
+    \brief Definition of the Abstract template class Decoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Decoder_H
+#define Decoder_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class Decoder {
+
+public:
+	Decoder() {};
+	virtual ~Decoder() {};
+    //! Method to decode : abstract
+    virtual void decode() = 0;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "Base class Decoder"; }
+
+private:
+    //! Copy constructor - No copy allowed
+	Decoder(const Decoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	Decoder& operator=(const Decoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Decoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Dimension.cc b/src/common/Dimension.cc
new file mode 100644
index 0000000..e1b17d8
--- /dev/null
+++ b/src/common/Dimension.cc
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Dimension.h
+    \brief Implementation of the Template class Dimension.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 29-Mar-2004
+    
+    Changes:
+    
+*/
+
+#include "Dimension.h"
+#include "MagLog.h"
+
+using namespace magics;
+
+template<class T>
+inline void helper(const string& in, T& out)
+{
+	std::stringstream is(in);
+	is >> out;
+}
+
+Dimension::Dimension(const string& value, double parent, double def)
+{
+	if ( magCompare(value, "undef") ) {
+		percent_ = def;
+		absolute_ = parent*def*0.01;
+		return;		
+	}
+	// Look for % ..
+	string::size_type pos = value.find("%");
+	if ( pos == 0 ) {
+		MagLog::error() << "format(" << pos << ") is not valid\n";
+		percent_ = def;
+		absolute_ = parent*def*0.01;
+		return;
+	}		
+	if (pos != string::npos) {		
+		helper(value, percent_);
+		absolute_ = parent*percent_*0.01;
+		return;
+	}
+
+	// By default it is cm...
+	helper(value, absolute_);
+	percent_ = absolute_*100/parent;
+}
diff --git a/src/common/Dimension.h b/src/common/Dimension.h
new file mode 100644
index 0000000..e4a6ef6
--- /dev/null
+++ b/src/common/Dimension.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Dimension.h
+    \brief Definition of the Template class Dimension.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 16-Jun-2005
+    
+    Changes:
+    
+*/
+
+#ifndef Dimension_H
+#define Dimension_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class Dimension {
+
+public:
+	Dimension(const string& , double, double = 100. );
+	virtual ~Dimension() {}
+	double absolute()  { return absolute_;}
+	double percent() { return percent_;}
+	string str() const { 
+		ostringstream  percent;
+		percent << percent_ << "%"; 
+		return percent.str(); 
+	}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "Dimension"; } 
+	 double  absolute_;
+	 double  percent_;
+	 int       pixel_;
+
+private:
+    //! Copy constructor - No copy allowed
+	Dimension(const Dimension&);
+    //! Overloaded << operator to copy - No copy allowed
+	Dimension& operator=(const Dimension&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Dimension& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/DriverStatic.cc b/src/common/DriverStatic.cc
new file mode 100644
index 0000000..27a64d0
--- /dev/null
+++ b/src/common/DriverStatic.cc
@@ -0,0 +1,45 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DriverStatic.cc
+    \brief Implementation of the Template class DriverStatic.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Thu Sep. 2006
+*/
+
+#include "DriverStatic.h"
+
+using namespace magics;
+
+DriverStatic::DriverStatic() 
+{
+}
+
+DriverStatic::~DriverStatic() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void DriverStatic::print(ostream& out)  const
+{
+	out << "DriverStatic[";
+	out << "]";
+}
diff --git a/src/common/DriverStatic.h b/src/common/DriverStatic.h
new file mode 100644
index 0000000..cb0abde
--- /dev/null
+++ b/src/common/DriverStatic.h
@@ -0,0 +1,62 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DriverStatic.h
+    \brief Definition of the Template class DriverStatic.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 21-Sep-2006
+    
+    Changes:
+    
+*/
+
+#ifndef DriverStatic_H
+#define DriverStatic_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class DriverStatic {
+
+public:
+	DriverStatic();
+	virtual ~DriverStatic();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	DriverStatic(const DriverStatic&);
+    //! Overloaded << operator to copy - No copy allowed
+	DriverStatic& operator=(const DriverStatic&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const DriverStatic& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Factory.cc b/src/common/Factory.cc
new file mode 100644
index 0000000..f044662
--- /dev/null
+++ b/src/common/Factory.cc
@@ -0,0 +1,89 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Factory.cc
+    \brief Definition of Parameter base class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+
+using namespace magics;
+using namespace std;   // to run on AIX
+
+template<class B>
+map<string, SimpleFactory<B>* >* SimpleFactory<B>::map_ = 0;
+
+
+
+
+
+template<class B>
+SimpleFactory<B>::SimpleFactory(const string& name): name_(lowerCase(name))
+{
+	if (!map_) map_ = new map<string, SimpleFactory<B>* >();
+	(*map_)[name_] = this; 
+}
+
+
+template<class B>
+SimpleFactory<B>::~SimpleFactory()
+{
+	if (map_) {
+		delete map_;
+		map_ = 0;
+	}
+}
+
+template<class B>
+B* SimpleFactory<B>::create(const string& name)
+{
+	SimpleFactory<B>* maker = get(name);
+	if (maker) {
+		B* object =(*maker).make();
+		return object;
+	}
+#ifdef MAGICS_EXCEPTION
+	throw NoFactoryException(name);
+#else 
+	return 0;
+#endif	
+} 
+
+
+
+	
+template<class B>
+SimpleFactory<B>* SimpleFactory<B>::get(const string& name)
+{	 
+	assert(map_);
+	typename map<string, SimpleFactory<B>*>::iterator maker = (*map_).find(lowerCase(name));
+	if (maker != (*map_).end()) return  (*maker).second;
+#ifdef MAGICS_EXCEPTION
+	throw NoFactoryException(name);
+#else 
+	return 0;
+#endif
+}
+
+	
+
diff --git a/src/common/Factory.h b/src/common/Factory.h
new file mode 100644
index 0000000..6a67cc5
--- /dev/null
+++ b/src/common/Factory.h
@@ -0,0 +1,82 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Factory.h
+    \brief Definition of Factory  class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#ifndef MPP_Factory_H
+#define MPP_Factory_H
+
+
+#include "magics.h"
+#include "MagException.h" 
+#include "MagLog.h"
+
+namespace magics {
+
+class NoFactoryException : public MagicsException
+{
+public:
+	NoFactoryException( const string& factory ):
+		MagicsException("Factory (" +  factory + ") not found") {}
+	NoFactoryException():
+		MagicsException("Factory not found") {}
+}; 
+
+
+
+template<class B> 
+class SimpleFactory {
+public:
+// -- Contructors
+	SimpleFactory(const string& name);
+	virtual ~SimpleFactory();
+// methods
+	static B*  create(const string& name);
+	virtual B* make() const  = 0;
+// -- Members
+	static map<string, SimpleFactory<B>* >* map_;
+	static SimpleFactory<B>* get(const string& name);
+	string name_;	 
+};
+
+
+
+
+template <class A, class B=A>
+class SimpleObjectMaker : public SimpleFactory<B>
+{
+public :
+	SimpleObjectMaker(const string& name) : SimpleFactory<B>(name) 
+        {}
+	B* make() const {  return new A(); }
+};
+
+
+} // namespace magics
+
+#include "Factory.cc"
+
+#endif
diff --git a/src/common/Flag.cc b/src/common/Flag.cc
new file mode 100644
index 0000000..fcc7eb0
--- /dev/null
+++ b/src/common/Flag.cc
@@ -0,0 +1,51 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Flag.cc
+    \brief Implementation of the Template class Flag.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 16-Mar-2005
+    
+    Changes:
+*/
+
+#include "Flag.h"
+
+using namespace magics;
+
+
+Flag::Flag() : length_(1), convention_(SI)
+{
+}
+
+
+Flag::~Flag() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+	
+void Flag::print(ostream& out)  const
+{
+	out << "Flag";
+}
+	
diff --git a/src/common/Flag.h b/src/common/Flag.h
new file mode 100644
index 0000000..154b087
--- /dev/null
+++ b/src/common/Flag.h
@@ -0,0 +1,78 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Flag.h
+    \brief Definition of the Template class Flag.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 16-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef Flag_H
+#define Flag_H
+
+#include "magics.h"
+
+#include "Arrow.h"
+
+namespace magics {
+
+
+
+class Flag: public Arrow {
+
+public:
+   
+	Flag();
+	~Flag();
+	
+	void redisplay(const BaseDriver& driver) const { driver.redisplay(*this); }
+	
+	double getLength() const                { return length_; }
+	void setLength(double length)           { length_ = length; }
+    
+	FlagConvention getConvention() const           { return convention_; }
+	void setConvention(FlagConvention convention)  { convention_ = convention; }
+
+//private:
+	//! Copy constructor - No copy allowed
+	Flag(const Flag&);
+	//! Overloaded << operator to copy - No copy allowed
+	Flag& operator=(const Flag&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream.
+	void print(ostream&) const; 	 
+	double         length_;
+	FlagConvention convention_;
+    
+private:
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Flag& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/FortranRootSceneNodeAttributes.h b/src/common/FortranRootSceneNodeAttributes.h
new file mode 100644
index 0000000..5cff208
--- /dev/null
+++ b/src/common/FortranRootSceneNodeAttributes.h
@@ -0,0 +1,91 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file FortranRootSceneNodeAttributes.h
+    \brief Definition of FortranRootSceneNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef FortranRootSceneNodeAttributes_H
+#define FortranRootSceneNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class FortranRootSceneNodeAttributes 
+{
+public:
+//  --  constructor
+    FortranRootSceneNodeAttributes();
+    
+//  --  destructor
+    virtual ~FortranRootSceneNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const FortranRootSceneNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double width_;
+	double height_;
+	bool frame_;
+	auto_ptr<Colour> colour_;
+	LineStyle style_;
+	int thickness_;
+	string plot_layout_;
+	string plot_start_;
+	string plot_direction_;
+	bool legend_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const FortranRootSceneNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/FortranSceneNodeAttributes.h b/src/common/FortranSceneNodeAttributes.h
new file mode 100644
index 0000000..a9ff25b
--- /dev/null
+++ b/src/common/FortranSceneNodeAttributes.h
@@ -0,0 +1,94 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file FortranSceneNodeAttributes.h
+    \brief Definition of FortranSceneNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef FortranSceneNodeAttributes_H
+#define FortranSceneNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "PageID.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class FortranSceneNodeAttributes 
+{
+public:
+//  --  constructor
+    FortranSceneNodeAttributes();
+    
+//  --  destructor
+    virtual ~FortranSceneNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const FortranSceneNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double x_;
+	double y_;
+	double width_;
+	double height_;
+	bool frame_;
+	auto_ptr<Colour> frame_colour_;
+	LineStyle frame_line_style_;
+	int frame_thickness_;
+	auto_ptr<NoPageID> page_id_;
+	string plot_layout_;
+	string plot_start_;
+	string plot_direction_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const FortranSceneNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/FortranViewNodeAttributes.h b/src/common/FortranViewNodeAttributes.h
new file mode 100644
index 0000000..8312a74
--- /dev/null
+++ b/src/common/FortranViewNodeAttributes.h
@@ -0,0 +1,109 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file FortranViewNodeAttributes.h
+    \brief Definition of FortranViewNode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef FortranViewNodeAttributes_H
+#define FortranViewNodeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "PreviewVisitor.h"
+#include "Transformation.h"
+#include "MagnifierVisitor.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class FortranViewNodeAttributes 
+{
+public:
+//  --  constructor
+    FortranViewNodeAttributes();
+    
+//  --  destructor
+    virtual ~FortranViewNodeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const FortranViewNodeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string vertical_;
+	string horizontal_;
+	double top_;
+	double bottom_;
+	double left_;
+	double bottom_internal_;
+	double left_internal_;
+	double right_;
+	double width_;
+	double height_;
+	double height_internal_;
+	double width_internal_;
+	auto_ptr<Colour> background_;
+	bool frame_;
+	auto_ptr<Colour> frame_colour_;
+	LineStyle frame_line_style_;
+	int frame_thickness_;
+	double vertical_axis_with_;
+	double horizontal_axis_height_;
+	string overlay_;
+	auto_ptr<Transformation> transformation_;
+	string json_;
+	bool title_;
+	auto_ptr<NoPreviewVisitor> preview_;
+	auto_ptr<NoMagnifierVisitor> magnify_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const FortranViewNodeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/Frame.h b/src/common/Frame.h
new file mode 100644
index 0000000..acdb73d
--- /dev/null
+++ b/src/common/Frame.h
@@ -0,0 +1,93 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Frame.h
+    \brief Definition of the Template class Frame.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 29-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Frame_H
+#define Frame_H
+
+#include "magics.h"
+#include "FrameBase.h"
+#include "FrameAttributes.h"
+
+namespace magics {
+
+class PaperPoint;
+class Polyline;
+
+
+class Frame: public FrameBase, public FrameAttributes {
+
+public:
+	Frame();
+	virtual ~Frame();	
+	virtual FrameBase* clone() const;
+	
+	void set(const map<string, string>& map) { FrameAttributes::set(map); }
+	void set(const XmlNode& xml) { FrameAttributes::set(xml); }
+	
+    virtual bool operator()() const { return true; }
+    void set(Polyline&);
+    void blank(Polyline&);
+ // Simulate the FrameAttributes interface!
+    virtual void setColour(Colour* colour)   { FrameAttributes::setColour(colour);  } 
+	virtual void setStyle(LineStyle style)   { FrameAttributes::setStyle(style); } 
+	virtual void setThickness(int thickness) { FrameAttributes::setThickness(thickness); } 
+	virtual void setBlanking(bool blanking)  { FrameAttributes::setBlanking(blanking); }
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    
+	
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Frame& p)
+		{ p.print(s); return s; }
+
+};
+class NoFrame: public FrameBase
+{
+public:
+    NoFrame() {}
+    ~NoFrame() {}
+ 
+    bool operator()() const {  return false; }
+    FrameBase* clone() const { return new NoFrame(); }
+protected:
+    virtual void print(ostream&) const; 
+};
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/common/FrameBase.cc b/src/common/FrameBase.cc
new file mode 100644
index 0000000..8838cdd
--- /dev/null
+++ b/src/common/FrameBase.cc
@@ -0,0 +1,53 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file FrameBase.cc
+    \brief Implementation of the Template class FrameBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 9-Feb-2006
+    
+    Changes:
+    
+*/
+
+
+
+#include "FrameBase.h"
+
+using namespace magics;
+
+FrameBase::FrameBase() 
+{
+}
+
+
+FrameBase::~FrameBase() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void FrameBase::print(ostream& out)  const
+{
+	out << "FrameBase[";
+	out << "]";
+}
+
diff --git a/src/common/FrameBase.h b/src/common/FrameBase.h
new file mode 100644
index 0000000..eefb5d2
--- /dev/null
+++ b/src/common/FrameBase.h
@@ -0,0 +1,116 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file FrameBase.h
+    \brief Definition of the Template class FrameBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 9-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef FrameBase_H
+#define FrameBase_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class Polyline;
+class PaperPoint;
+class Colour;
+
+class FrameBase {
+
+public:
+	FrameBase() {}
+	virtual ~FrameBase() {}
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "FrameBase::set(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "FrameBase::set(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual FrameBase* clone() const {
+        MagLog::dev() << "FrameBase::set(const map<string, string&)---> to be checked!...\n";
+        return new FrameBase();
+    } 
+     virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << "FrameBase::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+    }  
+    virtual bool operator()() const { 
+    	MagLog::dev() << " bool FrameBase::operator()() const ---> to be checked!...\n";
+    	return false; 
+    }
+    
+    virtual void set(Polyline&) {
+     	MagLog::dev() << " bool FrameBase::set(Polyline&) ---> to be checked!...\n";
+    }
+     virtual void blank(Polyline&) {
+     	MagLog::dev() << " bool FrameBase::blank(Polyline&) ---> to be checked!...\n";
+    }
+    // Simulate the FrameAttributes interface!
+    virtual void setColour(Colour*) {} 
+	virtual void setStyle(LineStyle) {} 
+	virtual void setThickness(int) {} 
+	virtual void setBlanking(bool) {}
+	
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "FrameBase\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	FrameBase(const FrameBase&);
+    //! Overloaded << operator to copy - No copy allowed
+	FrameBase& operator=(const FrameBase&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const FrameBase& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, FrameBase> { 
+public:
+	FrameBase* operator()(const string& val )
+	{
+		return SimpleObjectMaker<FrameBase>::create(val);
+	}     
+
+	FrameBase* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/FullPaperPoint.h b/src/common/FullPaperPoint.h
new file mode 100644
index 0000000..963fdbb
--- /dev/null
+++ b/src/common/FullPaperPoint.h
@@ -0,0 +1,92 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PaperPoint.h
+    \brief Definition of Point (x, y, z, v).
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#ifndef FullPaperPoint_H
+#define FullPaperPoint_H
+
+#include "magics.h"
+
+namespace magics {
+
+class FullPaperPoint  {
+
+public:
+	FullPaperPoint(double x = 0, double y = 0, double val = 0, double z = 0) :
+		x_(x), y_(y), z_(z), value_(val), colour_(val), marker_(val), size_(val) {}
+	virtual ~FullPaperPoint() {}
+	
+	void y(double y) { y_ = y; }
+	void x(double x) { x_ = x; }
+	void z(double z) { z_ = z; }
+	void value(double val) { value_ = val; }
+	void colour(double col) { colour_ = col; }
+	void marker(double marker) { marker_ = marker; }
+	void size(double size) { marker_ = size_; }
+    
+    
+	inline double y() const { return y_; }
+	inline double x() const { return x_; }
+	inline double z() const { return z_; }
+	double value() const { return value_; }
+	double colour() const { return colour_; }
+	double marker() const { return marker_; }
+	double size() const { return size_; }
+	
+	bool operator==(const FullPaperPoint& other) const
+	{
+		return (  (x_==other.x()) && (y_==other.y()) &&(z_==other.z()) 
+			&&(value_==other.value()) && (colour_==other.colour()) 
+			&&(marker_==other.marker()) && (size_==other.size()) );
+	}
+
+	double x_;
+	double y_;
+
+protected:
+	virtual void print(ostream& out) const 
+	{ 
+		out << "FullPaperPoint[";
+		out << x_ << "(x), ";
+		out << y_ << "(y), ";
+		out << z_ << "(z), ";
+		out << value_ << "(val)]";
+	}
+
+private:
+	double z_;
+	double value_;
+	double colour_;
+	double marker_;
+	double size_;
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const FullPaperPoint& p)
+		{ p.print(s); return s; }
+};
+}
+#endif
diff --git a/src/common/GeoPoint.h b/src/common/GeoPoint.h
new file mode 100644
index 0000000..519d409
--- /dev/null
+++ b/src/common/GeoPoint.h
@@ -0,0 +1,221 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File UserPoint
+// Sylvie Lamy-Thepaut ECMWF 2002
+#ifndef UserPoint_H
+#define UserPoint_H
+
+#include "magics.h"
+#include <cmath>
+#include <iomanip>
+#include <stack>
+
+namespace magics {
+
+class UserPoint {
+
+public:
+
+	UserPoint(double lon, double lat, double val = 0, 
+			bool missing = false, bool border = false) :
+        y_(lat), x_(lon), height_(0), 
+        value_(val), colour_(val), marker_(val), size_(val),
+        high_(false), low_(false), missing_(missing), border_(border) {}
+    
+    UserPoint() :
+        y_(0), x_(0), height_(0), 
+        value_(0), colour_(0), marker_(0), size_(0),
+        high_(false), low_(false), missing_(false), border_(false)  {}
+	virtual ~UserPoint() {}
+    
+	void latitude(double lat) { y_ = lat; }
+	void longitude(double lon) { x_ = lon; }
+	void height(double height) { height_ = height; }
+	void value(double val) { value_ = val; }
+	void colour(double col) { colour_ = col; }
+	void marker(double marker) { marker_ = marker; }
+	void size(double size) { size_ = size; }
+	void high(bool high) { high_ = high; }
+	void low(bool low) { low_ = low; }
+	void flagMissing() { missing_ = true; }
+	void flagBorder() { border_ = true; }
+
+	double y_;
+	double x_;
+	double latitude() const { return y_; }
+	double longitude() const { return x_; }
+	double height() const { return height_; }
+	double value() const { return value_; }
+	double colour() const { return colour_; }
+	double marker() const { return marker_; }
+	double size() const { return size_; }
+	bool high() const { return high_; }
+	bool low() const { return low_; }
+	bool missing() const { return missing_; }
+	bool border() const { return border_; }
+	bool ignore() const { return missing_ || border_; }
+    
+	inline double y() const { return y_; }
+	inline double x() const { return x_; }
+    
+	bool in(double left, double right, double bottom, double top, std::stack<UserPoint>& points) const
+	{
+		
+		UserPoint point = *this;
+		if (y_ > top)
+		{
+			return false;
+		}
+		if (y_ < bottom)
+		{
+			return false;
+		}
+        
+		while ( point.x_ < left ) 
+			point.x_ += 360;
+		while ( point.x_ > left + 360. )             
+			point.x_ -= 360.;
+
+		if ( point.x_ < left )
+		{
+			//MagLog::dev() << longitude_ << "<" << left << "\n";
+			return false;
+		}
+		if (point.x_ > right )
+		{
+			//MagLog::dev() << longitude_ << ">" << right << "\n";
+			return false;
+		}
+		
+		points.push(point);
+		while (true) {
+			point.x_ += 360;
+			if ( point.x_ >  left && point.x_ < right) {
+				points.push(point);
+			}
+			else 
+				break;
+		}
+				
+		return true;
+	}
+
+	bool wrapPB(const UserPoint& p) const
+	{ 
+		return abs(x_ - p.x_) > 180; 
+	}
+    
+	bool operator==(const UserPoint& other) const
+	{
+		return ( same(other.x_, x_) &&  
+                 same(other.y_, y_) &&  
+                 same(other.height_, height_) &&  
+                 same(other.value_, value_));
+	}
+	bool operator!=(const UserPoint& other) const
+	{
+        return ( !same(other.x_, x_) || 
+                 !same(other.y_, y_) || 
+                 !same(other.height_, height_) || 
+                 !same(other.value_, value_));
+	}
+    
+	bool  operator<(const UserPoint& other) const
+	{
+		if (other == *this) return false;
+		return (same(other.x_,x_)) ? (other.y_ < y_) : (x_ < other.x_ );
+	}
+
+	UserPoint left()const
+	{ 
+		return UserPoint(x_ - 360, y_, value_, height_); 
+	}
+
+	UserPoint right() const
+	{  
+		return UserPoint(x_  + 360, y_, value_, height_); 
+	}
+    
+	UserPoint shift(double left, double right) const
+	{ 
+		UserPoint point(*this);
+		if ( left <= x_ &&  x_ <= right) return point;
+		while (point.x_ <= left && point.x_ <= right) 
+			point.x_ += 360;
+		while (point.x_ >= right && point.x_ > left) 
+			point.x_ -= 360;
+		return point;
+	}
+
+	string writeLongitude() const
+	{
+		ostringstream lon;
+//		string ew = "#232"; // degree symbol
+		string ew = "°";
+		UserPoint nice = shift(-180, 180);
+
+		if ( nice.x_ < 0 ) ew += "W";
+		if ( nice.x_ >= 0 ) ew += "E";
+		float x = float(maground(abs(nice.x_)*100)) / 100;
+		lon << x << ew;
+		return  lon.str();    
+	} 
+
+	string writeLatitude() const
+	{
+		ostringstream lat;
+		//string ns = "#232"; // degree symbol
+		string ns = "°";
+		if ( y_ < 0 ) ns += "S";
+		if ( y_ >= 0 ) ns += "N";
+		float y = float(maground(abs(y_)*100)) / 100;
+		lat <<  y << ns;
+		return  lat.str();    
+	} 
+
+protected:
+	virtual void print(ostream& out) const 
+	{ 
+		out << "UserPoint[";
+		out << x_ << "(lon), ";
+		out << y_ << "(lat), ";
+		out << height_ << "(height), ";
+		out << value_ << "(val)]";
+		out << colour_ << "(colour)]";
+	}
+
+private:
+
+	double height_;
+	double value_;
+	double colour_;
+	double marker_;
+	double size_;
+	bool high_;
+	bool low_;
+	bool missing_;
+	bool border_;
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const UserPoint& p)
+		{ p.print(s); return s; }
+};
+
+}
+#endif
diff --git a/src/common/GeoRectangularProjection.cc b/src/common/GeoRectangularProjection.cc
new file mode 100644
index 0000000..afc5c75
--- /dev/null
+++ b/src/common/GeoRectangularProjection.cc
@@ -0,0 +1,684 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GeoRectangularProjection.cc
+    \brief Implementation of GeoRectangularProjection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Thu Jan 10 17:24:36 2008
+
+*/
+
+#include <GeoRectangularProjection.h>
+
+#include <Polyline.h>
+#include <Text.h>
+
+#include <UserPoint.h>
+#include <SceneVisitor.h>
+#include <GridPlotting.h>
+#include <LabelPlotting.h>
+#include <MatrixHandler.h>
+#include "ParameterSettings.h"
+#include "MagJSon.h"
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+*/
+GeoRectangularProjection::GeoRectangularProjection() : projection_(0)
+{
+	init();
+}
+
+/*!
+  \brief Destructor
+
+  \todo do we need here a "delete projection_;" as in MercatorProjection::~MercatorProjection() ?
+*/
+GeoRectangularProjection::~GeoRectangularProjection() 
+{
+}
+
+void GeoRectangularProjection::print(ostream& o) const
+{
+	o << "GeoRectangularProjection[";
+	GeoRectangularProjectionAttributes::print(o);
+	o << "]"; 
+} 
+
+
+
+PaperPoint GeoRectangularProjection::operator()(const UserPoint& point)  const
+{
+	if ( !projection_ ) {
+		return  PaperPoint(point.x(), point.y(), point.value(), point.missing(), point.border());
+
+	}
+
+	
+	TeCoord2D geo = TeCoord2D(point.x()*TeCDR, point.y()*TeCDR);
+	TeCoord2D xy = projection_->LL2PC(geo);
+
+	return PaperPoint(xy.x(), xy.y(), point.value(), point.missing());
+}
+
+PaperPoint GeoRectangularProjection::operator()(const PaperPoint& point)  const
+{
+	MagLog::dev() << "GeoRectangularProjection::operator()(...) needs implementing." << endl;
+	return Transformation::operator()(point);
+}
+
+void GeoRectangularProjection::revert(const PaperPoint& xy, UserPoint& point)  const
+{
+	if ( !projection_ )
+	{
+		point = UserPoint(xy.x(), xy.y());
+		return;
+	}
+	TeCoord2D texy = TeCoord2D(xy.x(), xy.y());
+	TeCoord2D geo = projection_->PC2LL(texy);  
+	point = UserPoint(geo.x()*TeCRD, geo.y()*TeCRD);	
+}
+
+
+
+void GeoRectangularProjection::revert(const vector<pair<double, double> > & input, vector<pair<double, double> > & output) const
+{
+	output.reserve(input.size());
+	const vector<pair<double, double> >::const_iterator in_end =input.end();
+	if ( !projection_ )
+	{
+		for ( vector<pair<double, double> >::const_iterator pt = input.begin();  pt != in_end; ++pt)
+		{
+			output.push_back(*pt);
+		}
+		return;
+	}
+	assert(projection_);
+
+	for ( vector<pair<double, double> >::const_iterator pt = input.begin();  pt != in_end; ++pt)
+	{
+		TeCoord2D texy = TeCoord2D(pt->first, pt->second);
+		TeCoord2D geo = projection_->PC2LL(texy);
+		output.push_back(make_pair(geo.x()*TeCRD, geo.y()*TeCRD));
+	}
+}
+
+bool GeoRectangularProjection::needShiftedCoastlines()  const
+{
+	return true;
+}
+
+void GeoRectangularProjection::boundingBox(double& xmin, double& ymin, 
+			double& xmax, double& ymax)  const
+{
+	xmin = std::min(min_longitude_, max_longitude_);
+	xmax = std::max(min_longitude_, max_longitude_);
+	ymin = std::min(min_latitude_, max_latitude_);
+	ymax = std::max(min_latitude_, max_latitude_);
+	const double tol = 1.;
+	xmin = xmin - tol;
+	xmax = xmax + tol;
+	ymin = (ymin < (-90+tol) ) ? -90. : ymin - tol;
+	ymax = (ymax > ( 90-tol) ) ?  90. : ymax + tol;
+}
+
+void GeoRectangularProjection::smallestBoundingBox(double& xmin, double& ymin,
+			double& xmax, double& ymax)  const
+{
+	xmin = std::min(min_longitude_, max_longitude_);
+	xmax = std::max(min_longitude_, max_longitude_);
+	ymin = std::min(min_latitude_, max_latitude_);
+	ymax = std::max(min_latitude_, max_latitude_);
+}
+
+bool GeoRectangularProjection::verifyDef(const string& def) const
+{
+	return ( def == "EPSG:4326" || def == "CRS:84"); 
+}
+
+
+void GeoRectangularProjection::aspectRatio(double& w, double& h) 
+{
+	init();
+	Transformation::aspectRatio(w, h);
+}
+
+
+double GeoRectangularProjection::getMinX()  const
+{
+	 return min_longitude_;
+}
+
+double GeoRectangularProjection::getMinY()  const
+{
+	return min_latitude_;
+}
+
+double GeoRectangularProjection::getMaxX()  const
+{
+	return max_longitude_;
+}
+
+double GeoRectangularProjection::getMaxY()  const
+{
+	return max_latitude_;
+}
+
+void GeoRectangularProjection::setMinX(double xx)  
+{
+	min_longitude_ = xx;
+}
+
+void GeoRectangularProjection::setMinY(double yy)  
+{
+	min_latitude_ = yy;
+}
+
+void GeoRectangularProjection::setMaxX(double xx)  
+{
+	max_longitude_ = xx;
+}
+
+void GeoRectangularProjection::setMaxY(double yy)  
+{
+	max_latitude_ = yy;
+}
+
+double GeoRectangularProjection::getMinPCX()  const
+{
+	return xpcmin_;
+}
+
+double GeoRectangularProjection::getMinPCY()  const
+{
+	return ypcmin_;
+}
+
+double GeoRectangularProjection::getMaxPCX()  const
+{
+	return xpcmax_;
+}
+
+double GeoRectangularProjection::getMaxPCY()  const
+{
+	return ypcmax_;
+}
+
+void GeoRectangularProjection::gridLongitudes(const GridPlotting& grid)  const
+{
+	const vector<double>& longitudes = grid.longitudes();
+	const double min = std::max(min_latitude_, -90.);
+	const double max = std::min(max_latitude_, 90.);
+	const double step = (max - min)/20;
+	const vector<double>::const_iterator lon_end =longitudes.end();
+	for (vector<double>::const_iterator lon = longitudes.begin(); lon != lon_end; ++lon)
+	{
+		Polyline poly;
+		poly.setAntiAliasing(false);
+	
+		for (double lat = min; lat <= max+step; lat += step)
+		{
+			( lat >  max ) ?  
+				poly.push_back((*this)(UserPoint(*lon, max))) :
+				poly.push_back((*this)(UserPoint(*lon,lat)));
+		}
+		grid.add(poly);
+	}
+}
+
+void GeoRectangularProjection::gridLatitudes(const GridPlotting& grid)  const
+{
+	const vector<double>& latitudes = grid.latitudes();
+	
+	const double step = (max_longitude_ - min_longitude_)/20;
+	const vector<double>::const_iterator lat_end = latitudes.end();
+	for(vector<double>::const_iterator lat = latitudes.begin(); lat != lat_end; ++lat)
+	{
+		if ( *lat < -90 ) continue;
+		if ( *lat > 90 ) continue;
+		Polyline poly;
+		poly.setAntiAliasing(false);
+		for (double lon = getMinX(); lon < getMaxX(); lon += step)
+		{
+			poly.push_back((*this)(UserPoint(lon,*lat)));
+		}
+		// add the last one!
+		poly.push_back((*this)(UserPoint(getMaxX(),*lat)));
+		grid.add(poly);
+	}
+}
+
+/*!
+ \brief generates text to mark longitudes at the top
+ 
+ \sa Text
+*/
+void GeoRectangularProjection::labels(const LabelPlotting& label, TopAxisVisitor&)  const
+{
+	Text *text;
+	const double cy = min_latitude_ + (max_latitude_-min_latitude_)*.2;
+	const vector<double>& longitudes = label.longitudes();
+	const vector<double>::const_iterator lon_end = longitudes.end();
+	for(vector<double>::const_iterator lon = longitudes.begin(); lon != lon_end; ++lon)
+	{	
+		if ( *lon > min_longitude_ &&  *lon < max_longitude_ )
+		{
+			UserPoint point(*lon, cy);
+			text = new Text();
+			label.add(text);
+			text->setText(writeLongitude(point));
+			text->setJustification(MCENTRE);
+			text->setVerticalAlign(MBOTTOM);
+			text->push_back((*this)(point));
+
+		}
+	}       	
+}
+
+/*!
+ \brief generates text to mark longitudes at the bottom
+
+ \sa Text
+*/
+void GeoRectangularProjection::labels(const LabelPlotting& label, BottomAxisVisitor&)  const
+{
+	Text *text;
+	const double cy = min_latitude_ + (max_latitude_-min_latitude_)*.8;
+	const vector<double>& longitudes = label.longitudes();
+	const vector<double>::const_iterator lon_end = longitudes.end();
+	for(vector<double>::const_iterator lon = longitudes.begin(); lon != lon_end; ++lon)
+	{	
+		if ( *lon > min_longitude_ &&  *lon < max_longitude_ )
+		{
+			UserPoint point(*lon, cy);
+			text = new Text();
+			label.add(text);
+			text->setText(writeLongitude(point));
+			text->setJustification(MCENTRE);
+			text->setVerticalAlign(MTOP);
+			text->push_back((*this)(point));
+
+		}
+	}
+}
+
+/*!
+ \brief generates text to mark latitudes at the left
+  
+ \sa Text
+*/
+void GeoRectangularProjection::labels(const LabelPlotting& label, LeftAxisVisitor&)  const
+{
+	Text *text;
+	const vector<double>& latitudes = label.latitudes();
+	const vector<double>::const_iterator lat_end = latitudes.end();
+	const double lon = max_longitude_ - ((max_longitude_-min_longitude_)*.1);
+	for(vector<double>::const_iterator lat = latitudes.begin(); lat != lat_end; ++lat)
+	{	
+		if ( *lat > min_latitude_ &&  *lat < max_latitude_ )
+		{
+			UserPoint point(lon, *lat);
+			text = new Text();
+			label.add(text);
+			text->setText(writeLatitude(point));
+	        text->setJustification(MRIGHT);
+			text->setVerticalAlign(MHALF);
+			text->push_back((*this)(point));
+
+		}
+	}
+}
+
+void GeoRectangularProjection::labels(const LabelPlotting&, DrawingVisitor&)  const
+{
+}
+
+/*!
+ \brief generates text to mark latitudes at the right
+ 
+ \sa Text
+*/
+void GeoRectangularProjection::labels(const LabelPlotting& label, RightAxisVisitor&)  const
+{
+	Text *text;
+	const vector<double>& latitudes = label.latitudes();
+	const vector<double>::const_iterator lat_end = latitudes.end();
+	for(vector<double>::const_iterator lat = latitudes.begin(); lat != lat_end; ++lat)
+	{	
+		if ( *lat > min_latitude_ &&  *lat < max_latitude_ )
+		{
+			const double lon = min_longitude_ + ((max_longitude_-min_longitude_)*.1);
+			UserPoint point(lon, *lat);
+			text = new Text();
+			label.add(text);
+			text->setText(writeLatitude(point));
+	        text->setJustification(MLEFT);
+			text->setVerticalAlign(MHALF); 
+			text->push_back((*this)(point));
+
+		}
+	}
+}
+double GeoRectangularProjection::patchDistance(double res) const
+{
+
+	return (res/110)*5.;
+}
+
+void GeoRectangularProjection::init()
+{
+	// make sure min < max! 
+	// reset any previous setting
+	userEnveloppe_->clear();
+	PCEnveloppe_->clear();
+
+	while (min_longitude_ > max_longitude_) {
+		max_longitude_ += 360;
+		MagLog::warning() << "lower_left_longitude > upper_right_longitude --> upper_right_longitude is change to " << max_longitude_ << endl;
+	}
+
+	if (min_latitude_ > max_latitude_) {
+		MagLog::warning() << "lower_left_latitude > upper_right_latitude --> swap" << endl;
+		std::swap(min_latitude_, max_latitude_);
+	}
+
+	if ( max_longitude_ - min_longitude_  < min_area_ ) {
+		max_longitude_ = min_longitude_ + min_area_;
+		MagLog::warning() << "The geographical area has been extented to respect the minimal dimension" << endl;
+	}
+
+	if ( max_latitude_ -  min_latitude_ < min_area_) {
+		max_latitude_ = min_latitude_ + min_area_;
+		MagLog::warning() << "The geographical area has been extented to respect the minimal dimension" << endl;
+	}
+
+	if ( max_longitude_ - min_longitude_  > 1080 )
+		max_longitude_ = min_longitude_ + 1080;
+
+	// Now 	we try to get the min longitudes in the the ranges -360/+720
+	while ( min_longitude_ < -360) {
+		min_longitude_ += 360;
+		max_longitude_ += 360;
+	}
+	while ( max_longitude_ > 720 ) {
+		min_longitude_ -= 360;
+		max_longitude_ -= 360;
+	}
+
+	if ( min_latitude_ < -90) min_latitude_ = -90.;
+	if ( max_latitude_ > 90 ) max_latitude_ = 90;
+
+
+	xpcmin_ = min_longitude_;
+	ypcmin_ = min_latitude_;
+	xpcmax_ = max_longitude_;
+	ypcmax_ = max_latitude_;	
+
+	userEnveloppe_->push_back(PaperPoint(min_longitude_, min_latitude_));
+	userEnveloppe_->push_back(PaperPoint(min_longitude_, max_latitude_));
+	userEnveloppe_->push_back(PaperPoint(max_longitude_, max_latitude_));
+	userEnveloppe_->push_back(PaperPoint(max_longitude_, min_latitude_));
+	userEnveloppe_->push_back(PaperPoint(min_longitude_, min_latitude_));
+
+	PCEnveloppe_->push_back(PaperPoint(min_longitude_, min_latitude_));
+	PCEnveloppe_->push_back(PaperPoint(min_longitude_, max_latitude_));
+	PCEnveloppe_->push_back(PaperPoint(max_longitude_, max_latitude_));
+	PCEnveloppe_->push_back(PaperPoint(max_longitude_, min_latitude_));
+	PCEnveloppe_->push_back(PaperPoint(min_longitude_, min_latitude_));
+}
+
+MercatorProjection::MercatorProjection()
+{
+}
+
+MercatorProjection::~MercatorProjection()
+{
+	delete projection_;
+}
+
+void MercatorProjection::print(ostream& o) const
+{
+	o << " mercator[";
+	GeoRectangularProjection::print(o);
+	o << "]";
+} 
+
+void MercatorProjection::init()
+{
+	if (!projection_) 
+		projection_ = new TeMercator(TeDatum(), 0);
+	// make sure min < max! 
+	if (min_longitude_ > max_longitude_)
+	{
+		MagLog::warning() << "lower_left_lon > upper_right_lon --> swap" << endl;
+		std::swap(min_longitude_, max_longitude_);
+	}
+	if (min_latitude_ > max_latitude_)
+	{
+		MagLog::warning() << "lower_left_lat > upper_right_lat --> swap" << endl;
+		std::swap(min_latitude_, max_latitude_);
+	}
+
+	const double t = 2;
+	min_latitude_ = std::max(min_latitude_, -89.);
+	max_latitude_ = std::min(max_latitude_, 89.);
+	min_longitude_ = std::max(min_longitude_, -180.);
+	max_longitude_ = std::min(max_longitude_, 720.);
+	
+	if ( max_longitude_ - min_longitude_  < t) 
+			max_longitude_ = min_longitude_ + t;
+	if ( max_latitude_ -  min_latitude_ < t) 
+			max_latitude_ = min_latitude_ + t;
+	
+	UserPoint   ll(min_longitude_, min_latitude_);
+	UserPoint   ur(max_longitude_, max_latitude_);
+
+	PaperPoint xy;	
+
+	xy = (*this)(ll);	
+	xpcmin_ = xy.x();
+	ypcmin_ = xy.y();
+
+	xy = (*this)(ur);
+	xpcmax_ = xy.x();
+	ypcmax_ = xy.y();
+	userEnveloppe_->clear();
+	PCEnveloppe_->clear();
+
+} 
+void MercatorProjection::fast_reproject(double& x, double& y) const
+{
+
+	TeCoord2D geo = TeCoord2D(x*TeCDR, y*TeCDR);
+	TeCoord2D xy = projection_->LL2PC(geo);
+
+	x = xy.x();
+	y = xy.y();
+
+}
+
+
+double round( double x)
+{
+        double prec = 100.;
+        return floor(x*prec+0.5)/prec;
+}
+
+void GeoRectangularProjection::setNewPCBox(double minx, double miny, double maxx, double maxy)
+{
+	   PaperPoint p1(minx, miny);
+	   PaperPoint p2(maxx, maxy);
+	   UserPoint   ll, ur;
+ 
+	   revert(p1, ll);
+	   revert(p2, ur);
+ 
+	   min_longitude_ =ll.x();
+	   max_longitude_ = ur.x();
+	   min_latitude_ = ll.y();
+	   max_latitude_ = ur.y();
+}
+
+
+/*!
+  \brief Set the resolution of Coastlines
+*/
+void GeoRectangularProjection::coastSetting(map<string, string>& setting, double abswidth, double absheight) const
+{
+	// work out the ratios of geographical to paper lengths
+	const double xratio = ( max_longitude_ - min_longitude_ ) / abswidth;
+	const double yratio = ( max_latitude_  - min_latitude_ )  / absheight;
+
+	// choose the smallest (smaller ratio means more detail required)
+	const double ratio = min(xratio, yratio);
+
+	std::string resol = "110m";
+	if ( ratio < 0.8 )  // highest resolution
+	{
+		resol = "10m";
+	}
+	else if ( ratio < 3.5)   // medium resolution
+	{
+		resol = "50m";
+	}
+
+	setting["resolution"] = resol;
+	setting["lakes"]      = resol + "/" + resol + "_lakes";
+	setting["land"]       = resol + "/" + resol + "_land";
+	setting["rivers"]     = resol + "/" + resol + "_rivers_lake_centerlines";
+	setting["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+	
+	//! \note Administraive borders hardcoded to 10m resolution (low res version do not contain all info)
+	setting["administrative_boundaries"] = "10m/10m_admin_1_states_provinces_shp";
+
+	MagLog::dev() << "GeoRectangularProjection::coastSetting[" << abswidth << ", " << absheight << "]->" <<  ratio << " resol: "<<resol<< endl;
+}
+
+
+MatrixHandler* GeoRectangularProjection::prepareData(const AbstractMatrix& matrix) const
+{
+	return new GeoBoxMatrixHandler(matrix, *this);
+}
+
+void GeoRectangularProjection::wraparound(const UserPoint& origin, stack<UserPoint>& out) const
+{
+	 UserPoint point = origin;
+	 if (point.y_ > max_latitude_ || point.y_ < min_latitude_ )
+	    return;
+
+
+
+	 while ( point.x_ < min_longitude_)
+	      point.x_ += 360;
+	 while ( point.x_ > min_longitude_ + 360. )
+	      point.x_ -= 360.;
+
+
+	 if ( point.x_ < min_longitude_ || point.x_ > max_longitude_) {
+
+		 return;
+	 }
+
+	 out.push(point);
+
+	 double lon = point.x_;
+	 // To the East
+	 point.x_ = lon + 360.;
+	 while (point.x_ >  min_longitude_ && point.x_ < max_longitude_) {
+		 out.push(point);
+	     point.x_ += 360;
+	 }
+	 // To the West
+	 point.x_ = lon - 360.;
+	 while (point.x_ >  min_longitude_ && point.x_ < max_longitude_) {
+	 	out.push(point);
+	 	point.x_ -= 360;
+	 }
+
+}
+
+Polyline& GeoRectangularProjection::getPCBoundingBox() const
+{
+
+	if ( PCEnveloppe_->empty() ) {
+		PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmin_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmax_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmax_, ypcmax_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmax_, ypcmin_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmin_));
+	}
+
+
+	return *PCEnveloppe_;
+}
+
+Polyline& GeoRectangularProjection::getUserBoundingBox() const
+{
+	if ( userEnveloppe_->empty() ) {
+
+		userEnveloppe_->push_back(PaperPoint(min_longitude_, min_latitude_));
+		userEnveloppe_->push_back(PaperPoint(min_longitude_, max_latitude_));
+		userEnveloppe_->push_back(PaperPoint(max_longitude_, max_latitude_));
+		userEnveloppe_->push_back(PaperPoint(max_longitude_, min_latitude_));
+		userEnveloppe_->push_back(PaperPoint(min_longitude_, min_latitude_));
+	}
+
+	return *userEnveloppe_;
+}
+
+void GeoRectangularProjection::getNewDefinition(const UserPoint& ll, const UserPoint& ur, string& out) const
+{
+	map<string, string> def;
+	def["subpage_map_projection"] = "cylindrical";
+	def["subpage_map_area_definition"] = "corners";
+	def["subpage_lower_left_longitude"] = tostring(ll.x_);
+	def["subpage_lower_left_latitude"] = tostring(ll.y_);
+	def["subpage_upper_right_longitude"] = tostring(ur.x_);
+	def["subpage_upper_right_latitude"] = tostring(ur.y_);
+	::toxml(out, def);
+	out = "{" + out + "}";
+}
+
+void GeoRectangularProjection::setDefinition(const string& json)
+{
+	if (json.empty())
+			return;
+
+
+
+		MagJSon helper;
+		helper.interpret(json);
+
+		XmlNode node = **helper.tree_.firstElement();
+
+		node.name("cylindrical");
+
+
+		set(node);
+
+
+}
+double MercatorProjection::patchDistance(double) const
+{
+	return 1000000;
+}
diff --git a/src/common/GeoRectangularProjection.h b/src/common/GeoRectangularProjection.h
new file mode 100644
index 0000000..e6cef4f
--- /dev/null
+++ b/src/common/GeoRectangularProjection.h
@@ -0,0 +1,222 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file GeoRectangularProjection.h
+    \brief Definition of GeoRectangularProjection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Fri Jan 11 11:08:24 2008
+*/
+
+#ifndef _GeoRectangularProjection_H
+#define _GeoRectangularProjection_H
+
+#include <Transformation.h>
+#include <GeoRectangularProjectionAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \class GeoRectangularProjection
+    \brief Implements a new projection
+    \ingroup projection
+
+    This projection ...
+*/
+
+class GeoRectangularProjection: public Transformation, public GeoRectangularProjectionAttributes
+{
+
+public:
+	GeoRectangularProjection();
+	~GeoRectangularProjection();
+
+	/*!
+	  \brief sets  from an XML node
+	*/
+	void set(const XmlNode& node)
+	{
+        Transformation::set(node);
+        GeoRectangularProjectionAttributes::set(node);
+        init();
+	}
+	bool verifyDef(const string&) const;
+   /*!
+	  \brief sets  from a map
+	*/
+	void set(const map<string, string>& map)
+	{
+        Transformation::set(map);
+        GeoRectangularProjectionAttributes::set(map);
+        init();
+	}
+    
+    virtual Transformation* clone() const {
+		GeoRectangularProjection* transformation = new GeoRectangularProjection();
+        transformation->copy(*this);
+		return transformation;
+	}
+    void setNewPCBox(double, double, double, double);
+    
+    void coastSetting(map<string, string>&, double, double) const;
+
+    Polyline& getPCBoundingBox() const;
+    Polyline& getUserBoundingBox() const;
+
+    double patchDistance(double) const;
+	/*!
+	\\brief 
+	*/
+	virtual PaperPoint operator()(const UserPoint&) const;
+	/*!
+	\\brief 
+	*/
+	virtual PaperPoint operator()(const PaperPoint&) const;
+	/*!
+	\\brief 
+	*/
+	virtual void revert(const PaperPoint&, UserPoint&) const;
+
+	void revert(const vector<pair<double, double> > &, vector<pair<double, double> > &) const;
+	/*!
+	\\brief Does the projection needs the coastalines to be shifted!
+	*/
+	virtual bool needShiftedCoastlines() const;
+	/*!
+	\\brief set the aspect ratio!
+	*/
+	virtual void aspectRatio(double&, double&);
+	/*!
+	\\brief set the bounding box!
+	*/
+	virtual void boundingBox(double&, double&, double&, double&) const;
+	virtual void smallestBoundingBox(double&, double&, double&, double&) const;
+	/*!
+	\\brief return the xmin in user coordinates!
+	*/
+	virtual double getMinX() const;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual double getMinY() const;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual double getMaxX() const;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual double getMaxY() const;
+	/*!
+	\\brief set the xmin in user coordinates!
+	*/
+	virtual void setMinX(double) ;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual void setMinY(double) ;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual void setMaxX(double) ;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual void setMaxY(double) ;
+	/*!
+	\\brief return the xmin in projection coordinates!
+	*/
+	virtual double getMinPCX() const;
+	/*!
+	\\brief return the ymin in projection coordinates!
+	*/
+	virtual double getMinPCY() const;
+	/*!
+	\\brief return the xmax in projection coordinates!
+	*/
+	virtual double getMaxPCX() const;
+	/*!
+	\\brief return the ymax in projection coordinates!
+	*/
+	virtual double getMaxPCY() const;
+	/*!
+	\\brief create the grid for the longitudes!!
+	*/
+	virtual void gridLongitudes(const GridPlotting&) const;
+	/*!
+	\\brief create the grid for the latitudes!!
+	*/
+	virtual void gridLatitudes(const GridPlotting&) const;
+	/*!
+	\\brief calculate the top labels
+	*/
+	virtual void labels(const LabelPlotting&, DrawingVisitor&) const;
+	virtual void labels(const LabelPlotting&, LeftAxisVisitor&) const;
+	virtual void labels(const LabelPlotting&, RightAxisVisitor&) const;
+	virtual void labels(const LabelPlotting&, TopAxisVisitor&) const;
+	virtual void labels(const LabelPlotting&, BottomAxisVisitor&) const;
+
+	MatrixHandler* prepareData(const AbstractMatrix& matrix) const;
+	void wraparound(const UserPoint&, stack<UserPoint>&) const;
+	void getNewDefinition(const UserPoint&, const UserPoint&, string&) const;
+	void setDefinition(const string&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 virtual void init(); 
+	 
+	 mutable TeProjection* projection_;
+	 double 	       xpcmin_;
+	 double                ypcmin_;
+	 double                xpcmax_;
+	 double                ypcmax_;
+
+private:
+    //! Copy constructor - No copy allowed
+	GeoRectangularProjection(const GeoRectangularProjection&);
+    //! Overloaded << operator to copy - No copy allowed
+	GeoRectangularProjection& operator=(const GeoRectangularProjection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GeoRectangularProjection& p)
+		{ p.print(s); return s; }
+
+};
+
+class MercatorProjection : public GeoRectangularProjection
+{
+public:
+	MercatorProjection();
+	~MercatorProjection();
+	void fast_reproject(double& x, double& y) const;
+	double patchDistance(double) const;
+
+protected :
+	void print(ostream&) const; 
+	void init();
+};
+    
+
+} // namespace magics
+#endif
diff --git a/src/common/GeoRectangularProjectionAttributes.h b/src/common/GeoRectangularProjectionAttributes.h
new file mode 100644
index 0000000..72705cb
--- /dev/null
+++ b/src/common/GeoRectangularProjectionAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file GeoRectangularProjectionAttributes.h
+    \brief Definition of GeoRectangularProjection Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:17 2012
+*/
+   
+
+#ifndef GeoRectangularProjectionAttributes_H
+#define GeoRectangularProjectionAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class GeoRectangularProjectionAttributes 
+{
+public:
+//  --  constructor
+    GeoRectangularProjectionAttributes();
+    
+//  --  destructor
+    virtual ~GeoRectangularProjectionAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const GeoRectangularProjectionAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double min_latitude_;
+	double min_longitude_;
+	double max_latitude_;
+	double max_longitude_;
+	double min_area_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const GeoRectangularProjectionAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/HeightTableDefinition.h b/src/common/HeightTableDefinition.h
new file mode 100644
index 0000000..6a506bd
--- /dev/null
+++ b/src/common/HeightTableDefinition.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightTableDefinition.h
+    \brief Definition of Colour class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started by Sylvie Lamy-Thepaut ECMWF 2002
+    
+    Changes:
+    
+    
+    
+*/
+#ifndef HeightTableDefinition_H
+#define HeightTableDefinition_H
+
+#include "TableDefinition.h"
+#include "TableDefinitionList.h"
+#include "TableDefinitionCompute.h"
+
+#include "Factory.h"
+#include "MagTranslator.h"
+
+
+namespace magics {
+
+
+class HeightTableDefinition : public TableDefinitionInterface<double> 
+{
+public:
+	HeightTableDefinition() {}
+	HeightTableDefinition* clone() const { return new HeightTableDefinition(); }
+	 virtual void toxml(ostream&, int)  const {}
+};
+
+class HeightTableDefinitionList : public HeightTableDefinition
+{
+public:
+	HeightTableDefinitionList()  { helper_ = new TableDefinitionList<double>(); }
+	HeightTableDefinition* clone() const { return new HeightTableDefinitionList(); }	
+};
+
+class HeightTableDefinitionCompute : public HeightTableDefinition
+{
+public:
+	HeightTableDefinitionCompute()  { helper_ = new TableDefinitionCompute<double>(); }
+	HeightTableDefinition* clone() const { return new HeightTableDefinitionCompute(); }
+
+		
+};
+
+
+template<>
+class MagTranslator<string, HeightTableDefinition> { 
+public:
+	HeightTableDefinition* operator()(const string& val)
+	{
+		return SimpleObjectMaker<HeightTableDefinition>::create(val);
+		 
+	}
+    HeightTableDefinition* magics(const string& param)
+    {
+        HeightTableDefinition* object;
+		ParameterManager::update(param, object);
+		return object;
+    }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/Image.h b/src/common/Image.h
new file mode 100644
index 0000000..74e4576
--- /dev/null
+++ b/src/common/Image.h
@@ -0,0 +1,74 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Image.h
+    \brief Definition of the Template class Image.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef Image_H
+#define Image_H
+
+#include "magics.h"
+#include "BaseDriver.h"
+#include "ImageProperties.h"
+
+namespace magics {
+
+class Image: public ImageProperties, public vector<short>  {
+
+public:
+	Image() {}
+	virtual ~Image() {}
+	
+	// Implement the BaseGraphics Interface 
+	virtual void redisplay(const BaseDriver& driver) const { driver.redisplay(*this); } 
+	
+	void set(int rows, int columns) { rows_ = rows; columns_ = columns; reserve(rows_*columns_); }
+
+	int getNumberOfRows() const {return rows_;}
+	int getNumberOfColumns() const {return columns_;}
+	
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const {}
+	int rows_;
+	int columns_;
+private:
+	//! Copy constructor - No copy allowed
+	Image(const Image&);
+	//! Overloaded << operator to copy - No copy allowed
+	Image& operator=(const Image&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Image& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/common/ImageProperties.h b/src/common/ImageProperties.h
new file mode 100644
index 0000000..1525a66
--- /dev/null
+++ b/src/common/ImageProperties.h
@@ -0,0 +1,110 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImageProperties.h
+    \brief Definition of the Template class ImageProperties.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 13-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImageProperties_H
+#define ImageProperties_H
+
+#include "magics.h"
+#include "BasicGraphicsObject.h"
+#include "ColourTable.h"
+#include "Transformation.h"
+
+
+namespace magics {
+
+class ImageProperties : public BasicGraphicsObject {
+
+public:
+	ImageProperties() : transparency_(1), originReference_(centre) {}
+	virtual ~ImageProperties() {}
+
+	enum  OriginReference { centre, bottom_left };
+
+    void copy(const ImageProperties& from) {
+    	origin_ = from.origin_;
+    	width_  = from.width_;
+    	height_ = from.height_;
+    	transparency_ = from.transparency_;
+    	table_ = from.table_;
+    }
+	
+	void setOrigin(const PaperPoint& origin)    { origin_ = origin; }
+	PaperPoint getOrigin() const                { return origin_; }
+	
+	void setWidth(double width)      { width_ = width; }
+	double getWidth() const          { return width_; }
+	
+	void setHeight(double height)    { height_ = height; }
+	double getHeight() const         { return height_; }
+	
+	void setTransparency(double transparency)    { transparency_ = transparency; }
+	double getTransparency() const         { return transparency_; }
+	
+	void setColourTable(const ColourTable& table) { table_ = table; }
+	ColourTable& getColourTable() const { return table_; }
+	
+	OriginReference getOriginReference() const { return originReference_; }
+	void setOriginReference(OriginReference ref)  { originReference_ = ref; }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const {
+	 	out << "ImageProperties[x=" << origin_.x(); 
+		out << ", y=" << origin_.y();
+		out << ", width=" << width_;
+		out << ", height=" << height_;
+		out << ", lookup_table=" << table_;
+		out << ", transparency=" << transparency_;
+		out << "]";
+	 }
+	 PaperPoint origin_;
+	 double width_;
+	 double height_;
+	 mutable ColourTable table_;
+	 double transparency_;
+
+	 OriginReference originReference_;
+
+
+private:
+    //! Copy constructor - No copy allowed
+	ImageProperties(const ImageProperties&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImageProperties& operator=(const ImageProperties&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImageProperties& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/common/ImportObject.cc b/src/common/ImportObject.cc
new file mode 100644
index 0000000..45a4d64
--- /dev/null
+++ b/src/common/ImportObject.cc
@@ -0,0 +1,69 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImportObject.h
+    \brief Implementation of the Template class ImportObject.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+#include "ImportObject.h"
+
+using namespace magics;
+
+
+ImportObject::ImportObject()
+{
+}
+
+
+ImportObject::~ImportObject() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void ImportObject::print(ostream& out)  const
+{
+	out << "ImportObject[";
+	out << "path=" << path_;
+	out << ", format=" << format_;
+	ImageProperties::print(out);
+	out << "]";
+}
+
+bool ImportObject::reproject(BasicGraphicsObjectContainer& parent) const
+{
+	const Transformation& transformation = parent.transformation();
+	ImportObject* object = new ImportObject();
+	
+	this->setObject(*object, transformation);
+	parent.push_back(object);
+	
+	object->setFormat(format_);
+	object->setPath(path_);
+	return false;
+
+}
diff --git a/src/common/ImportObject.h b/src/common/ImportObject.h
new file mode 100644
index 0000000..ce44641
--- /dev/null
+++ b/src/common/ImportObject.h
@@ -0,0 +1,79 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImportObject.h
+    \brief Definition of the Template class ImportObject.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImportObject_H
+#define ImportObject_H
+
+#include "magics.h"
+#include "ImageProperties.h"
+#include "BaseDriver.h"
+
+namespace magics {
+
+
+
+class ImportObject: public ImageProperties {
+
+public:
+	ImportObject() {}
+	virtual ~ImportObject() {}
+	
+	// Implement the BaseGraphics Interface 
+	virtual void redisplay(const BaseDriver& driver) const { driver.redisplay(*this); } 
+	
+	void setPath(const string& path) { path_ = path; }
+	string getPath() const          { return path_; }
+	
+	void setFormat(const string& format) { format_ = format; }
+	string getFormat() const          { return format_; }
+
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+	 string path_;
+	 string format_;
+
+private:
+	//! Copy constructor - No copy allowed
+	ImportObject(const ImportObject&);
+	//! Overloaded << operator to copy - No copy allowed
+	ImportObject& operator=(const ImportObject&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImportObject& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/common/IntervalMap.h b/src/common/IntervalMap.h
new file mode 100644
index 0000000..141d845
--- /dev/null
+++ b/src/common/IntervalMap.h
@@ -0,0 +1,124 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IntervalMap.h
+    \brief Definition of the Template class IntervalMap
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 22-Jun-2004
+    
+    Changes:
+    
+*/
+ 
+#ifndef IntervalMap_H
+#define IntervalMap_H
+
+#include "magics.h"
+
+namespace magics {
+
+class Interval
+{
+public:
+    Interval(double min = 0, double max = 0) : min_(min), max_(max) {}
+    Interval(const Interval& other) : min_(other.min_), max_(other.max_) {}
+    virtual ~Interval() {}
+    virtual bool between(double val) const
+    { 
+        //MagLog::debug() << min_ << "<" << val << "<" << max_ << "?" << "\n";
+    	if(same(min_,val)) return true;
+        return (min_ < val && val < max_); 
+    }
+    bool  operator<(const Interval& other) const
+    {
+        if ( other.min_ == min_ ) 
+            return other.max_ > max_;
+        else 
+            return other.min_ > min_;
+    }
+    double min_;
+    double max_;
+    virtual void print(ostream& out) const { out << "[" << min_ << ", " << max_ << "]"; } 
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Interval& p)
+		{ p.print(s); return s; }
+};
+
+
+class OutOfRangeMagException : public MagicsException
+{
+public:
+	OutOfRangeMagException():MagicsException("OutOfRangeMagException"){}
+}; 
+
+
+template <class C>
+class IntervalMap : public map<Interval, C>
+{
+	
+public:
+	IntervalMap() {}
+	~IntervalMap() {}
+	
+	bool accept(double val) const
+		{
+			for (typename map<Interval, C>::const_iterator interval = this->begin(); interval != this->end(); ++interval)
+			{
+				if (interval->first.between(val))
+					return true;
+			}
+			//MagLog::warning() << "IntervalMap - Could not find value "<< val <<" in interval!" << endl;
+			return false;
+		}
+
+	const C& find(double val, const C& def) const
+	{
+		for (typename map<Interval, C>::const_iterator interval = this->begin(); interval != this->end(); ++interval)
+		{
+			if (interval->first.between(val))
+				return interval->second;
+		}
+		//MagLog::warning() << "IntervalMap - Could not find value "<< val <<" in interval!" << endl;
+		return def;
+	}
+	 typename map<Interval, C>::iterator   get(double val)  {
+		for (typename map<Interval, C>::iterator interval = this->begin(); interval != this->end(); ++interval)
+				{
+					if (interval->first.between(val))
+						return interval;
+				}
+		throw MagicsException("not in range"); 
+	}
+	
+	 typename map<Interval, C>::const_iterator   find(double val) const {
+		for (typename map<Interval, C>::const_iterator interval = this->begin(); interval != this->end(); ++interval)
+				{
+					if (interval->first.between(val))
+						return interval;
+				}
+		throw MagicsException("not in range"); 
+	}
+
+};
+
+} // namespace magics
+#endif	
diff --git a/src/common/Label.cc b/src/common/Label.cc
new file mode 100644
index 0000000..58e6e3b
--- /dev/null
+++ b/src/common/Label.cc
@@ -0,0 +1,64 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Label.h
+    \brief Implementation of the Template class Label.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 16-Mar-2004
+    
+    Changes:
+    
+*/
+
+#include "Label.h"
+
+using namespace magics;
+
+Label::Label(const string& label) : label_(label),
+	justification_(MCENTRE), verticalAlign_(MBASE),  angle_(0.), 
+	blanking_(false), visible_(false) 
+{
+}
+
+
+
+Label::Label(double label) : label_(tostring(label)),  
+		justification_(MCENTRE), verticalAlign_(MBASE), angle_(0.), 
+		blanking_(false), visible_(false) 
+{
+
+}
+
+Label::~Label() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Label::print(ostream& out)  const
+{
+	out << "Label[";
+	out << "label = " << label_;
+	out << ",visible = " << visible_;
+	out << ",blanking = " << blanking_;
+	out << ",font = " << font_;
+	out << ",angle = " << angle_;
+	out << "]";
+}
diff --git a/src/common/Label.h b/src/common/Label.h
new file mode 100644
index 0000000..119f194
--- /dev/null
+++ b/src/common/Label.h
@@ -0,0 +1,153 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Label.h
+    \brief Definition of the Template class Label.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 16-Mar-2004
+    
+    Changes:
+    	Stephan - 18th March 2005: add vertical align
+    
+*/
+#ifndef Label_H
+#define Label_H
+
+#include "magics.h"
+#include "MagFont.h"
+
+
+namespace magics {
+
+class Label  {
+
+public:
+	Label(const string& label = "");
+	
+
+	Label(double label);
+	virtual ~Label();
+
+
+	
+	
+    
+	string getText() const { return label_; }
+	void setText(const string& text) { label_ = text; }
+    
+	void setText(double val, const string& = "") {
+		ostringstream s;
+		s << val;
+		setText(s.str());  
+	}
+
+    Label* clone() const {
+    	
+    	Label* label = new Label(label_); 
+		label->font(font_);
+		label->setVisible(visible_);
+		label->setBlanking(blanking_);
+		label->setJustification(justification_);
+		label->setVerticalAlign(verticalAlign_);
+		label->setAngle(angle_);
+		return label;
+    }
+
+
+	string getFont() const { return font_.name(); }
+	void setFont(const string& font) { font_.name(font); }
+
+	double getFontSize() const { return font_.size(); }
+	void setFontSize(double size) { font_.size(size); }
+	
+	double getHeight() const { return font_.size(); }
+	void setHeight(double size) { font_.size(size); }
+	
+	string getFontStyle() const { return font_.style(); }
+	void setFontStyle(const string& style) { font_.style(style); }
+	
+	const Colour& getFontColour() const { return font_.colour(); }
+	void setFontColour(const Colour& colour) { font_.colour(colour); }
+
+	const MagFont& font() { return font_; }
+	void font(const MagFont& font) { font_ = font; }
+	
+
+	Justification getJustification() const { return justification_; }
+	void setJustification(const Justification justification) { justification_ = justification; }
+
+	VerticalAlign getVerticalAlign() const { return verticalAlign_; }
+	void setVerticalAlign(const VerticalAlign va) { verticalAlign_ = va; }
+
+	/*!
+	  \brief Method setting the angle in which the text is written.
+	  
+	  The angle gives the gradient in which the text is written. Angles are given 
+	  in degree and an angle of 0 degree is horizontal. Angles are going 
+	  anticlockwise.
+	  
+	  \sa setAngle
+	*/
+	double getAngle() const {return angle_;}
+	/*!
+	  \brief Method getting the angle in which the text is written.
+	  
+	  The angle gives the gradient in which the text is written. Angles are given 
+	  in degree and an angle of 0 degree is horizontal. Angles are going 
+	  anticlockwise.
+	  
+	  \sa getAngle
+	*/
+	void setAngle(double angle) {angle_ = angle;}
+    
+	
+    
+	bool getBlanking() const { return blanking_; }
+	void setBlanking(bool blanking) { blanking_ = blanking; }
+    
+	bool isVisible() const { return visible_; }
+	void setVisible(bool visible) { visible_ = visible; }
+
+	static 	double convertFontSize(double height) { return height * 48; }
+	static 	double height2Point(double height) { return height * 48; }
+	static 	double point2Height(double height) { return height / 48; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	string  label_;
+	
+	MagFont       font_;
+	Justification justification_;
+	VerticalAlign verticalAlign_;
+	double   angle_;
+	bool       blanking_;
+	bool       visible_;
+
+private:
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Label& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Layout.cc b/src/common/Layout.cc
new file mode 100644
index 0000000..624e325
--- /dev/null
+++ b/src/common/Layout.cc
@@ -0,0 +1,506 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Layout.cc
+    \brief Implementation of the Template class Layout.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 30-Jan-2004
+    
+    Changes:
+    
+*/
+
+#include "Layout.h"
+#include "BaseDriver.h"
+
+#include "Polyline.h"
+#include "PaperPoint.h"
+#include "SceneVisitor.h"
+
+#include "Transformation.h"
+
+
+using namespace magics;
+
+const double axisHeight_ = 3;
+const double axisWidth_ = 3;
+const double legendHeight_ = 3;
+
+#define CLEAR(a) if (a) delete a;
+
+Layout::Layout()  :
+	owner_(0),animationRules_(0), transformation_(0),
+	width_(100), height_(100), x_(0), y_(0), display_(INLINE),
+	xmin_(0), xmax_(100), ymin_(0), ymax_(100),
+	zoomable_(false), navigable_(false), resizable_(false), resolve_(false)
+{
+}
+
+Layout::~Layout()
+{
+	if ( owner_ )
+		delete owner_;
+}
+
+void Layout::redisplay(const BaseDriver& driver) const
+{
+	if ( objects_.empty() )
+		return;
+	MagLog::debug() <<  "Layout::redisplay-->" << *this << endl;
+	driver.redisplay(*this);
+
+
+
+
+
+}
+
+bool Layout::reproject(BasicGraphicsObjectContainer& /*out*/) const
+{
+	//out.push_back(this));
+	return true;
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Layout::print(ostream& out)  const
+{
+	out << "Layout[";
+    out << name_;
+    if (parent_) 
+    	out <<", parent="<< parent_->name();
+    out << ", x="<< x_;
+    out << ", y="<< y_;
+    out << ", width="<< width_;
+    out << ", height="<< height_;
+    out << ", xmin="<< xmin_;
+    out << ", ymin="<< ymin_;
+    out << ", xmax="<< xmax_;
+    out << ", ymax="<< ymax_; 
+    out << ", size="<< objects_.size();
+	out << "]";
+	for (vector<DriverInfo>::const_iterator info = driverInfos_.begin(); info != driverInfos_.end(); ++info) 
+		out << *info << endl;
+}
+
+
+void Layout::absoluteWidth(double width) 
+{
+	width_ = 100*width / absoluteWidth();
+}
+
+void Layout::absoluteHeight(double height) 
+{
+	height_ = 100*height / absoluteHeight();
+}
+
+RootLayout::RootLayout(double width, double height) :
+	absoluteWidth_(width), absoluteHeight_(height)
+{	
+}
+
+RootLayout::~RootLayout()
+{
+}
+
+PreviewLayout::~PreviewLayout()
+{
+}
+
+PreviewLayout::PreviewLayout()
+{
+}
+
+MagnifierLayout::~MagnifierLayout()
+{
+}
+
+MagnifierLayout::MagnifierLayout()
+{
+}
+
+
+LayoutFrame::LayoutFrame(): 
+	thickness_(1), 
+	style_(M_SOLID), 
+	colour_("grey"), 
+	blanking_(false), 
+	visible_(false) 
+{
+}
+
+LayoutFrame::~LayoutFrame()
+{
+}
+
+Layout* Layout::execute(AnimationStep& /*step*/,  const Layout* /*visitor*/)
+{
+	return 0;
+}
+
+void LayoutFrame::blank(Layout& owner)
+{
+	
+	if ( ! blanking_ ) return;
+		// Create and push_back the frame!
+		
+	Polyline* frame = new Polyline();
+	frame->setLineStyle(style_);
+	frame->setThickness(thickness_);
+	frame->setColour(visible_ ? colour_ : Colour("none"));
+	frame->setFilled(true);      
+	frame->setFillColour(Colour("white"));      
+		
+	FillShadingProperties* shading = new FillShadingProperties();          
+
+	frame->setShading(shading);
+		
+	frame->push_back(PaperPoint(owner.minX(), owner.minY()));
+	frame->push_back(PaperPoint(owner.minX(), owner.maxY()));
+	frame->push_back(PaperPoint(owner.maxX(), owner.maxY()));
+	frame->push_back(PaperPoint(owner.maxX(), owner.minY()));
+	frame->push_back(PaperPoint(owner.minX(), owner.minY()));
+	
+	owner.push_back(frame);
+}
+
+void LayoutFrame::frame(Layout& owner)
+{
+	if ( ! visible_ ) return;
+	// Create and push_back the frame!
+	
+	Polyline* frame = new Polyline();
+	frame->setLineStyle(style_);
+	frame->setThickness(thickness_);
+	frame->setColour(colour_); 
+	
+	double px = (owner.maxX() - owner.minX())*0.00;
+	double py = (owner.maxY() - owner.minY())*0.00;
+	
+	
+	frame->push_back(PaperPoint(owner.minX() +px , owner.minY() + py));
+	frame->push_back(PaperPoint(owner.minX() +px , owner.maxY() - py));
+	frame->push_back(PaperPoint(owner.maxX() - px, owner.maxY() - py));
+	frame->push_back(PaperPoint(owner.maxX() - px , owner.minY() +py));
+	frame->push_back(PaperPoint(owner.minX() + px, owner.minY() +py));
+	
+	owner.push_back(frame);
+	
+}
+
+double Layout::absoluteX() const
+{
+//return parent_->absoluteX() + x_ * parent_->absoluteWidth() /100;
+    return 0;
+}
+
+double Layout::absoluteY() const
+{
+	//return parent_->absoluteY() + y_ * parent_->absoluteHeight() /100;
+	return 0;
+}
+
+double Layout::absoluteWidth() const
+{
+    assert(parent_);
+    return width_ * parent_->absoluteWidth() /100;
+}
+
+double Layout::absoluteHeight() const
+{
+	assert(parent_);
+	return height_ * parent_->absoluteHeight() /100;
+}
+
+
+void Layout::transformation(Transformation* transformation)
+{
+    	transformation_ = transformation;    
+    	xmin_ = transformation_->getMinPCX();
+    	xmax_ = transformation_->getMaxPCX();
+    	ymin_ = transformation_->getMinPCY();
+    	ymax_ = transformation_->getMaxPCY();
+}
+
+void Layout::redisplay(AnimationStep& step, const BaseDriver& driver)
+{
+	BasicGraphicsObject* plot = owner_->execute(step, *this);
+	
+	if (plot) 
+		plot->redisplay(driver);
+}
+
+
+LayoutHelper::LayoutHelper() : 
+		xmin_(INT_MAX), xmax_(-INT_MAX),  ymin_(INT_MAX), ymax_(-INT_MAX)
+{
+}
+
+LayoutHelper::~LayoutHelper()
+{
+}
+
+void LayoutHelper::add(LayoutVisitor* visitor)
+{
+	Layout* layout = visitor->mainLayout();
+	if ( xmin_ > layout->x() ) 
+		xmin_ = layout->x();
+	if ( ymin_ > layout->y() ) 
+		ymin_ = layout->y();
+	if ( xmax_ < ( layout->x() +  layout->width() ) )
+		xmax_ = layout->x()  +  layout->width();
+	if ( ymax_ < ( layout->y() + layout->height() ) ) 
+		ymax_ = layout->y() + layout->height();
+	MagLog::dev() << "New Layout-->" << *this << endl;
+}
+	
+void LayoutHelper::attachTop(LayoutVisitor* visitor)
+{
+	Layout* layout = visitor->mainLayout();
+	layout->y(ymax_);
+	layout->x(xmin_);
+	layout->width(xmax_-xmin_);
+	
+}
+
+void LayoutHelper::attachNoConstraintTop(LayoutVisitor* visitor)
+{
+	Layout* layout = visitor->mainLayout();
+	layout->y(ymax_);
+	layout->x(xmin_);
+}
+
+void LayoutHelper::attachLeft(LayoutVisitor* visitor)
+{
+	Layout* layout = visitor->mainLayout();
+	layout->x(xmin_ - layout->width());
+	layout->y(ymin_);
+	layout->height(ymax_-ymin_);
+}
+
+void LayoutHelper::attachRight(LayoutVisitor* visitor)
+{
+	Layout* layout = visitor->mainLayout();
+	layout->x(xmax_);
+	layout->y(ymin_);
+	layout->height(ymax_-ymin_);
+}
+
+void LayoutHelper::attachBottom(LayoutVisitor* visitor)
+{
+	Layout* layout = visitor->mainLayout();
+	//if ( ymin_ - layout->height() > 0 )
+		layout->y(ymin_ - layout->height());
+	//else {
+	//	layout->y(0);
+
+		//layout->height(ymin_);
+	//}
+	layout->x(xmin_);
+	layout->width(xmax_-xmin_);
+}
+
+void LayoutHelper::print(ostream& out)  const
+{
+	out << "LayoutHelper[";
+	out << "xmin_=" << xmin_;
+	out << "xmax_=" << xmax_;
+	out << "ymin_=" << ymin_;
+	out << "ymax_=" << ymax_;
+	out << "]";
+}
+
+Layout*  Layout::clone() const
+{
+	Layout* layout = newLayout();
+	
+	layout->name_ = this->name_;
+	layout->width_ = this->width_;
+	layout->height_ = this->height_;
+	layout->x_ = this->x_;	
+	layout->y_ = this->y_;	
+	
+	layout->xmin_ = this->xmin_;		
+	layout->xmax_ = this->xmax_;		
+	layout->ymin_ = this->ymin_;	
+	layout->ymax_ = this->ymax_;
+	layout->transformation_ = this->transformation_;
+	layout->parent_ = this->parent_;
+	
+	layout->id_ = this->id_;		
+	layout->zoomable_ = this->zoomable_;
+	layout->navigable_ = this->navigable_;
+	layout->zoomLevels_ = this->zoomLevels_;		
+	layout->zoomCurrentLevel_ = this->zoomCurrentLevel_;			
+	layout->widthResolution_ = this->widthResolution_;
+	layout->heightResolution_ = this->heightResolution_;
+	layout->resizable_ = this->resizable_;				
+
+	layout->frame(*this);
+	
+	return layout;
+}
+
+void RootLayout::redisplay(const BaseDriver& driver) const
+{
+	if ( resolve_) {
+		intarray frames = driver.frames();
+		unsigned int nb = frames.size();
+		unsigned int current = 0;
+		bool more = true;
+
+		while (more) {
+
+			unsigned int frame = (nb) ? frames[current]-1 : current;
+			more = buildTree(*this, frame, driver);
+
+			current++;
+			if (current == nb)
+				more = false;
+
+			
+
+		}
+		// here we can release the graphics object!
+		MagLog::debug() << "RELEASE OBJECTS!!!!!!!!!!!!" << endl;
+		const_cast<RootLayout*>(this)->clear();
+	}
+	else
+		driver.redisplay(*this);
+}
+
+void PreviewLayout::redisplay(const BaseDriver& driver) const
+{
+	driver.redisplay(*this);
+}
+
+LegendLayout::LegendLayout()
+{
+
+}
+
+LegendLayout::~LegendLayout()
+{
+
+}
+
+void LegendLayout::redisplay(const BaseDriver& driver) const
+{
+	driver.redisplay(*this);
+}
+
+void MagnifierLayout::redisplay(const BaseDriver& driver) const
+{
+	driver.redisplay(*this);
+}
+
+void StartPage::redisplay(const BaseDriver& driver) const
+{
+	MagLog::dev() << "StartPage::redisplay-->" << *this << endl;
+	
+	driver.redisplay(*this);
+}
+void EndPage::redisplay(const BaseDriver& driver) const
+{
+	MagLog::dev() << "EndPage::redisplay-->" << *this << endl;
+	
+	driver.redisplay(*this);
+}
+HistoLayout::HistoLayout()
+{
+	
+}
+
+HistoLayout::~HistoLayout()
+{
+	
+}
+
+void HistoLayout::redisplay(const BaseDriver& driver) const
+{
+
+	driver.redisplay(*this);
+}
+SceneLayout::SceneLayout()
+{
+
+}
+
+SceneLayout::~SceneLayout()
+{
+
+}
+
+void SceneLayout::redisplay(const BaseDriver& driver) const
+{
+	if ( objects_.empty() )
+		return;
+	MagLog::debug() <<  "Layout::redisplay-->" << *this << endl;
+    
+	driver.redisplay(*this);
+}
+bool Layout::buildTree(const Layout& parent, unsigned int frame, const BaseDriver& driver) const
+{
+	bool more = false;
+
+	for (vector<BasicGraphicsObject*>::const_iterator object = objects_.begin(); object!= objects_.end(); ++object){
+		if ( (*object)->buildTree(*this, frame, driver ) )
+			more = true;
+	}
+
+	// here we can release the graphics object!
+	//		cout << "Layout::buildTree-->RELEASE OBJECTS!!!!!!!!!!!!" << endl;
+	//		const_cast<Layout*>(this)->clear();
+
+
+	return more;
+}
+
+BasicLayout::BasicLayout()
+{
+}
+BasicLayout::~BasicLayout()
+{
+}
+
+
+
+bool BasicLayout::buildTree(const Layout& parent, unsigned int frame, const BaseDriver& driver) const
+{
+	bool more = false;
+
+
+	StartPage* start = new StartPage();
+	driver.redisplay(*start);
+
+	for (vector<BasicGraphicsObject*>::const_iterator object = objects_.begin(); object!= objects_.end(); ++object){
+		if ( (*object)->buildTree(*this, frame, driver ) )
+			more = true;
+	}
+
+	EndPage* end = new EndPage();
+	driver.redisplay(*end);
+	return more;
+}
+
+
+vector<DriverInfo> Layout::driverInfos_;
+
diff --git a/src/common/Layout.h b/src/common/Layout.h
new file mode 100644
index 0000000..f84b663
--- /dev/null
+++ b/src/common/Layout.h
@@ -0,0 +1,377 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Layout.h
+    \brief Definition of the Template class Layout.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 30-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Layout_H
+#define Layout_H
+
+#include "magics.h"
+#include "BasicGraphicsObject.h"
+
+#include "Colour.h"
+
+
+namespace magics {
+
+
+class PaperPoint;
+class BasicSceneObject;
+class AnimationRules;
+class AnimationStep;
+class LayoutVisitor;
+
+
+class DriverInfo {
+public:
+	DriverInfo(double x, double y, double width, double height): 
+		x_(x), y_(y), width_(width), height_(height) {}
+	~DriverInfo() {}
+	DriverInfo() {}
+
+	void print(ostream& s) const
+	{
+		s << "<driver_info";
+		s << " x = \'" << x_ << "\'";
+		s << " y = \'" << y_ <<  "\'";
+		s << " width = \'" << width_ << "\'";
+		s << " height = \'" << height_ << "\'";
+		s << "/>";
+	}
+
+	double x_;
+	double y_;
+	double width_;
+	double height_;
+	
+	friend ostream& operator<<(ostream& s,const DriverInfo& p)
+		{ p.print(s); return s; }
+};
+
+class Layout;
+class LayoutVisitor;
+
+class LayoutFrame 
+{
+public:
+	LayoutFrame();
+	~LayoutFrame();
+	void blank(Layout&);
+	void frame(Layout&);
+protected:
+	int thickness_;
+	LineStyle style_;
+	Colour colour_;
+	bool blanking_;
+	bool visible_;
+	friend class Layout;
+};
+
+
+class StartPage : public BasicGraphicsObject
+{
+public:
+	StartPage() {}
+	virtual ~StartPage() {}
+	void redisplay(const BaseDriver& driver) const;
+};
+
+
+class EndPage : public BasicGraphicsObject
+{
+public:
+	EndPage() {}
+	virtual ~EndPage() {}
+	void redisplay(const BaseDriver& driver) const;
+};
+
+
+class Layout : public BasicGraphicsObjectContainer
+{
+public:
+	Layout();
+	virtual ~Layout();
+
+	virtual Layout*  clone() const;
+	virtual Layout*  newLayout() const { return new Layout(); }
+	
+	bool reproject(BasicGraphicsObjectContainer&) const;	
+	void redisplay(const BaseDriver& driver) const;
+	void redisplay(AnimationStep&, const BaseDriver& driver); 
+
+	double x()    const { return x_ ; } // percentage of the parent
+	double y()    const { return y_ ; };  // percentage of the parent
+	double width()	 const { return width_ ; };  // percentage of the parent 
+	double height() const { return height_ ; };  // percentage of the parent 
+	
+	void x(double x ) { x_ = x; }
+	void y(double y ) { y_ = y; }
+	void absoluteWidth(double);
+	void absoluteHeight(double);
+	void width(double width ) { width_ = width; }
+	void height(double height ) { height_ = height; }
+	
+	
+	void display(DisplayType display) { display_ = display; }
+	DisplayType display() const { return display_; }
+
+/* Methods needed to calculate the percentage when unit in cm!*/
+	double absoluteX()      		const; //absolute position from the root
+	double absoluteY()      		const; //absolute position from the root
+	double absoluteWidth()  const; //absolute position from the root
+	double absoluteHeight()  const; //absolute position from the root
+	
+	bool buildTree(const Layout&, unsigned int, const BaseDriver&) const;
+
+	
+	virtual Layout* execute(AnimationStep& step,  const Layout* visitor);
+
+	
+	double minX()  const { return xmin_; }
+	double maxX()  const { return xmax_; }
+	double minY()  const { return ymin_; }
+	double maxY()  const { return ymax_; }
+	void minX(double xmin)  { xmin_ = xmin; }
+	void maxX(double xmax) {  xmax_ = xmax; }
+	void minY(double ymin)  { ymin_ = ymin; }
+	void maxY(double ymax) { ymax_ = ymax; }
+	
+	
+	void setCoordinates(double xmin, double xmax, double ymin, double ymax) {
+		xmin_ = xmin; xmax_ = xmax; ymin_ = ymin; ymax_ = ymax; 
+	}
+	
+	void pushDriverInfo(double x, double y, double width, double height) const 
+	{
+		driverInfos_.push_back(DriverInfo(x, y, width, height));
+	} 
+	
+	void getDriverInfo(double& x, double& y, double& width, double& height)
+	{
+		if ( !driverInfos_.empty() ) {
+			x = driverInfos_.front().x_;
+			y = driverInfos_.front().y_;
+			width = driverInfos_.front().width_;
+			height = driverInfos_.front().height_;
+		}
+		else {
+			parent_->getDriverInfo(x, y, width, height);
+		}
+	}
+
+	void frame(const Layout& other)
+	{
+		frame_.blanking_ = other.frame_.blanking_;
+		frame_.visible_ = other.frame_.visible_;
+		frame_.colour_ = other.frame_.colour_;
+		frame_.style_ = other.frame_.style_;
+		frame_.thickness_ = other.frame_.thickness_;
+	}
+	
+	void frame(bool blank, bool visible, const Colour& colour, LineStyle style, int thickness) {
+		frame_.blanking_ = blank;
+		frame_.visible_ = visible;
+		frame_.colour_ = colour;
+		frame_.style_ = style;
+		frame_.thickness_ = thickness;
+	}
+	
+	void zoomable(bool zoom = true) { zoomable_ = zoom; }
+	bool isZoomable() const { return zoomable_; }
+	
+	void setNavigable() { navigable_ = true; }
+	bool isNavigable() const { return navigable_; }
+
+	const string& id() const { return id_; }
+	void id(const string& id) { id_ = id; }
+    int zoomLevels() const { return zoomLevels_; }
+    void zoomLevels(int levels)  { zoomLevels_ = levels; }
+    int zoomCurrentLevel() const { return zoomCurrentLevel_; }
+    void zoomCurrentLevel(int level)  { zoomCurrentLevel_ = level; }
+ 
+    void animationRules(AnimationRules* rules) { animationRules_ = rules; }
+    AnimationRules* animationRules() const { return animationRules_; }
+    
+    const Transformation& transformation() const { 
+    	assert(transformation_); 
+    	return *transformation_; 
+    }
+    virtual bool childOfRoot() const { assert(parent_); return parent_->root(); }
+    
+    void transformation(Transformation* );
+    void transformation(Layout& layout) const
+    { layout.transformation(transformation_);  }
+  
+    void frameIt() { frame_.frame(*this); }
+    void blankIt() { frame_.blank(*this); }
+    void resolve(bool resolve) { resolve_  = resolve; }
+    bool resolve() const { return resolve_; }
+    virtual void resize(double, double) {}
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+	BasicSceneObject* owner_;
+	AnimationRules*   animationRules_; // will be deleted in the destructor!
+	Transformation*   transformation_; // Just a reference! 
+
+	//Dimension of the layout in percentage of the parent! 
+	double width_; 
+	double height_;
+	double x_;
+	double y_;
+	DisplayType display_;
+	
+	// coordiantes system used in this layout!
+	double xmin_;
+	double xmax_;
+	double ymin_; 
+	double ymax_;
+	
+	bool zoomable_;
+	bool navigable_;
+	// Zoom information : only used if mode is ZOOMABLE
+	int zoomLevels_;
+	int zoomCurrentLevel_;
+	string id_;
+	
+	bool resizable_;
+	bool resolve_;
+	
+	LayoutFrame frame_;
+		
+	static vector<DriverInfo> driverInfos_;
+	friend class LayoutVisitor;
+	friend class TopAxisVisitor;
+	friend class BottomAxisVisitor;
+	friend class LeftAxisVisitor;
+	friend class RightAxisVisitor;
+	
+private:
+	//! Copy constructor - No copy allowed
+	Layout(const Layout&);
+	//! Overloaded << operator to copy - No copy allowed
+	Layout& operator=(const Layout&);
+// 
+};
+
+
+class PreviewLayout : public Layout 
+{
+public:
+	PreviewLayout();
+	virtual ~PreviewLayout();
+	void redisplay(const BaseDriver& driver) const;
+	
+};
+class LegendLayout : public Layout
+{
+public:
+	LegendLayout();
+	virtual ~LegendLayout();
+	void redisplay(const BaseDriver& driver) const;
+
+};
+class HistoLayout : public Layout 
+{
+public:
+	HistoLayout();
+	virtual ~HistoLayout();
+	void redisplay(const BaseDriver& driver) const;
+};
+
+class SceneLayout : public Layout
+{
+public:
+	SceneLayout();
+	virtual ~SceneLayout();
+	void redisplay(const BaseDriver& driver) const;
+	
+};
+
+
+
+class MagnifierLayout : public Layout 
+{
+public:
+	MagnifierLayout();
+	virtual ~MagnifierLayout();
+	void redisplay(const BaseDriver& driver) const;
+	virtual void redisplay(const BaseDriver&, vector<PaperPoint>&,float,float) const {}
+};
+
+class RootLayout : public Layout
+{
+public:
+	RootLayout(double width, double height);
+	virtual ~RootLayout();
+	double absoluteWidth() const { return absoluteWidth_; }
+	double absoluteHeight() const { return absoluteHeight_; }
+	virtual bool childOfRoot() { return false; }
+	void redisplay(const BaseDriver& driver) const;
+
+	 virtual void resize(double width, double height) { absoluteWidth_ = width; absoluteHeight_ = height; }
+
+protected:
+	double absoluteWidth_;
+	double absoluteHeight_; 
+
+};
+class BasicLayout : public Layout
+{
+public:
+	BasicLayout();
+	virtual ~BasicLayout();
+	bool buildTree(const Layout&, unsigned int, const BaseDriver&) const;
+};
+class LayoutVisitor;
+
+
+class LayoutHelper
+{
+public:
+	LayoutHelper();
+	~LayoutHelper();
+	void add(LayoutVisitor*);
+	void attachTop(LayoutVisitor*);
+	void attachNoConstraintTop(LayoutVisitor*);
+	void attachLeft(LayoutVisitor*);
+	void attachRight(LayoutVisitor*);
+	void attachBottom(LayoutVisitor*);
+
+protected :
+	virtual void print(ostream&) const; 
+	double xmin_;
+	double xmax_;
+	double ymin_;
+	double ymax_;
+	friend ostream& operator<<(ostream& s,const LayoutHelper& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/LevelTableDefinition.h b/src/common/LevelTableDefinition.h
new file mode 100644
index 0000000..2604a46
--- /dev/null
+++ b/src/common/LevelTableDefinition.h
@@ -0,0 +1,86 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LevelTableDefinition.h
+    \brief Definition of Colour class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started by Sylvie Lamy-Thepaut ECMWF 2002
+    
+    Changes:
+    
+    
+    
+*/
+#ifndef LevelTableDefinition_H
+#define LevelTableDefinition_H
+
+#include "TableDefinition.h"
+#include "TableDefinitionList.h"
+#include "TableDefinitionCompute.h"
+
+#include "Factory.h"
+#include "MagTranslator.h"
+
+
+namespace magics {
+
+class LevelTableDefinition : public TableDefinitionInterface<double> 
+{
+public:
+	LevelTableDefinition() {}
+	LevelTableDefinition* clone() const { return new LevelTableDefinition(); }
+	 virtual void toxml(ostream&, int)  const {}
+};
+
+class LevelTableDefinitionList : public LevelTableDefinition
+{
+public:
+	LevelTableDefinitionList()  { helper_ = new TableDefinitionList<double>(); }
+	LevelTableDefinition* clone() const { return new LevelTableDefinitionList(); }	
+};
+
+class LevelTableDefinitionCompute : public LevelTableDefinition
+{
+public:
+	LevelTableDefinitionCompute()  { helper_ = new TableDefinitionCompute<double>(); }
+	LevelTableDefinition* clone() const { return new LevelTableDefinitionCompute(); }
+};
+
+
+template<>
+class MagTranslator<string, LevelTableDefinition>
+{
+public:
+	LevelTableDefinition* operator()(const string& val)
+	{
+		return SimpleObjectMaker<LevelTableDefinition>::create(val);
+		 
+	}
+	LevelTableDefinition* magics(const string& param)
+	{
+		LevelTableDefinition* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/LogoPlotting.cc b/src/common/LogoPlotting.cc
new file mode 100644
index 0000000..064e67f
--- /dev/null
+++ b/src/common/LogoPlotting.cc
@@ -0,0 +1,132 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LogoPlotting.cc
+    \brief Implementation of the Template class LogoPlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 3-Jun-2005
+    
+    Changes:
+    
+*/
+
+#include "LogoPlotting.h"
+#include "Symbol.h"
+#include "PaperPoint.h"
+#include "ImportObject.h"
+#include "BasicSceneObject.h"
+#include "Dimension.h"
+
+using namespace magics;
+
+
+
+LogoPlotting::LogoPlotting()
+{
+	x_ = 80;
+	y_ = 2.5;
+}
+
+LogoPlotting::~LogoPlotting()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LogoPlotting::print(ostream& out)  const
+{
+	out << "LogoPlotting[";
+	out << "]";
+}
+
+void LogoPlotting::operator()(BasicGraphicsObjectContainer& tree) const
+{
+	Symbol* symbol = new Symbol();
+
+
+
+	double x =  (0.3 * 6.75 * 100) / tree.absoluteWidth();
+	x = 90;
+    double y = (0.3/tree.absoluteHeight())*100; 	 // 0.2
+
+	(*symbol).setColour(Colour("BLUE"));
+	(*symbol).setSymbol("logo_ecmwf");
+	(*symbol).setHeight(0.6);   // length = height * 6.75
+	(*symbol).push_back(PaperPoint(x,y));
+
+	tree.push_back(symbol);
+}
+
+
+UserLogoPlotting::UserLogoPlotting()
+{
+}
+
+
+UserLogoPlotting::~UserLogoPlotting()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void UserLogoPlotting::print(ostream& out)  const
+{
+	out << "UserLogoPlotting[";
+	out << "]";
+}
+
+void UserLogoPlotting::operator()(BasicGraphicsObjectContainer& tree) const
+{
+    
+    ImportObject* object = new ImportObject();
+    
+	object->setPath(UserLogoPlottingAttributes::path_);
+	object->setFormat(UserLogoPlottingAttributes::format_);
+	object->setWidth(UserLogoPlottingAttributes::width_);
+	object->setHeight(UserLogoPlottingAttributes::height_);
+	
+	double x = UserLogoPlottingAttributes::x_;
+	double y = UserLogoPlottingAttributes::y_;
+	
+	
+	double height = tree.absoluteHeight();    
+	double width = tree.absoluteWidth();
+	// Diemnsion 
+	if ( UserLogoPlottingAttributes::bottom_.empty() || UserLogoPlottingAttributes::left_.empty() ) {
+		if ( magCompare(UserLogoPlottingAttributes::units_, "cm") ) {
+			
+			x = (UserLogoPlottingAttributes::x_/width)*100;
+			y = (UserLogoPlottingAttributes::y_/height)*100;
+		}
+	}
+	else {
+		Dimension bottom(bottom_ , height, 2.5);
+		Dimension left(left_ , width, 80);
+		x = left.percent();
+		y = bottom.percent();
+	}
+	object->setOrigin(PaperPoint(x, y));
+	
+	tree.push_back(object);    
+}
+
+
diff --git a/src/common/LogoPlotting.h b/src/common/LogoPlotting.h
new file mode 100644
index 0000000..5698cb9
--- /dev/null
+++ b/src/common/LogoPlotting.h
@@ -0,0 +1,162 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LogoPlotting.h
+    \brief Definition of the Template class LogoPlotting.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jun-2005
+
+*/
+
+#ifndef LogoPlotting_H
+#define LogoPlotting_H
+
+#include "magics.h"
+#include "LogoPlottingAttributes.h"
+#include "UserLogoPlottingAttributes.h"
+#include "BasicGraphicsObject.h"
+#include "MagTranslator.h"
+namespace magics {
+
+class BasicSceneObject;
+
+class NoLogoPlotting {
+
+public:
+	NoLogoPlotting() {}
+	virtual ~NoLogoPlotting() {}
+
+    virtual void set(const XmlNode&) { }
+    virtual void set(const map<string, string>&) { }
+    
+    virtual bool accept(const string&) { return false; }
+
+    virtual NoLogoPlotting* clone() const {
+        return new NoLogoPlotting();
+    }
+    virtual void toxml(ostream&, int = 0) const { }  
+    
+    virtual void operator()(BasicGraphicsObjectContainer&) const {  }
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "NoLogoPlotting\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	NoLogoPlotting(const NoLogoPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoLogoPlotting& operator=(const NoLogoPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoLogoPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+class LogoPlotting  : public NoLogoPlotting {
+
+public:
+	LogoPlotting();
+	virtual ~LogoPlotting(); 
+	virtual void set(const map<string, string>&)  {}
+	virtual void set(const XmlNode&)  {}
+	void toxml(ostream&, int)  const {}
+	virtual NoLogoPlotting* clone() const {
+		LogoPlotting* object = new LogoPlotting();
+		return object;
+	}
+	virtual void operator()(BasicGraphicsObjectContainer&) const;
+    
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+	 double  x_;
+	 double  y_;
+
+private:
+    //! Copy constructor - No copy allowed
+	LogoPlotting(const LogoPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	LogoPlotting& operator=(const LogoPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LogoPlotting& p)
+		{ p.print(s); return s; }
+};
+
+
+
+class UserLogoPlotting: public NoLogoPlotting, public UserLogoPlottingAttributes 
+{
+
+public:
+	UserLogoPlotting();
+	virtual ~UserLogoPlotting();
+	virtual void set(const map<string, string>& map)  { UserLogoPlottingAttributes::set(map); }
+	virtual void set(const XmlNode& node)  { UserLogoPlottingAttributes::set(node); }
+	bool accept(const string& node) { return UserLogoPlottingAttributes::accept(node); }
+
+	virtual NoLogoPlotting* clone() const {
+		UserLogoPlotting* object = new UserLogoPlotting();
+		object->copy(*this);
+		return object;
+	}
+	void operator()( BasicGraphicsObjectContainer&) const;
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	UserLogoPlotting(const UserLogoPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	UserLogoPlotting& operator=(const UserLogoPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const UserLogoPlotting& p)
+		{ p.print(s); return s; }
+};
+
+
+template <>
+class MagTranslator<string, NoLogoPlotting> { 
+public:
+	NoLogoPlotting* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoLogoPlotting>::create(val);
+	}
+
+	NoLogoPlotting* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/LogoPlottingAttributes.h b/src/common/LogoPlottingAttributes.h
new file mode 100644
index 0000000..2405552
--- /dev/null
+++ b/src/common/LogoPlottingAttributes.h
@@ -0,0 +1,80 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LogoPlottingAttributes.h
+    \brief Definition of LogoPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef LogoPlottingAttributes_H
+#define LogoPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LogoPlottingAttributes 
+{
+public:
+//  --  constructor
+    LogoPlottingAttributes();
+    
+//  --  destructor
+    virtual ~LogoPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LogoPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LogoPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/LogoPlottingBase.h b/src/common/LogoPlottingBase.h
new file mode 100644
index 0000000..13e3de5
--- /dev/null
+++ b/src/common/LogoPlottingBase.h
@@ -0,0 +1,46 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagLogoPlottingBase.h
+    \brief Definition of the Template class MagLogoPlottingBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 9-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef MagLogoPlottingBase_H
+#define MagLogoPlottingBase_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "BasicGraphicsObject.h"
+
+
+namespace magics {
+	
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/common/MagException.cc b/src/common/MagException.cc
new file mode 100644
index 0000000..6693d5c
--- /dev/null
+++ b/src/common/MagException.cc
@@ -0,0 +1,38 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Exception
+// Sylvie Lamy-Thepaut - ECMWF Mar 02
+
+#include <MagException.h>
+ 
+using namespace magics;
+
+
+
+
+AssertionFailed::AssertionFailed(const char* msg,int line,
+    const char* file, const char* proc)
+{
+    ostringstream s;
+
+    s << "Assertion failed: " << msg << " in " << proc << ", line " << line << " of " << file;
+
+    what_ = s.str();
+ 
+}
diff --git a/src/common/MagException.h b/src/common/MagException.h
new file mode 100644
index 0000000..6e8c82b
--- /dev/null
+++ b/src/common/MagException.h
@@ -0,0 +1,120 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef MagicsException_H
+#define MagicsException_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class MagicsException : public exception
+{
+ public:
+	MagicsException( const string& why) : what_(why) {
+        if (::getenv("MAGICS_ABORT_EXCEPTION")) {
+            ::abort();
+        }
+    } 
+
+    MagicsException() : what_("") {
+        if (::getenv("MAGICS_ABORT_EXCEPTION")) {
+            ::abort();
+        }
+    } 
+
+	virtual const char *what() const throw() {  return what_.c_str(); }
+	virtual ~MagicsException() throw() {}
+ protected:
+    virtual void print(ostream& out) const 
+    {
+        out << what_;
+    }
+    string what_;
+    // -- Friends
+	friend ostream& operator<<(ostream& s,const MagicsException& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class NoSuchFileException : public MagicsException
+{
+public:
+	 NoSuchFileException( const string& file ):
+		MagicsException("No Such File: " +  file){}
+};     
+
+class NoWritePermissionException : public MagicsException
+{
+public:
+	 NoWritePermissionException( const string& file ):
+		MagicsException("No write permission to write file: " +  file){}
+};     
+    
+class NotYetImplemented : public MagicsException
+{
+public:
+	 NotYetImplemented(const string& type, const string& method ):
+		MagicsException( type + " " + method  + " : not yet implemented... "){}
+};         
+
+class MethodNotYetImplemented : public NotYetImplemented
+{
+public:
+	 MethodNotYetImplemented(const string& method):
+		NotYetImplemented("Method",  method) {}  
+};    
+     
+class ParameterNotYetImplemented : public NotYetImplemented
+{
+public:
+	 ParameterNotYetImplemented(const string& param):
+		NotYetImplemented("Parameter", param){}
+}; 
+
+class AssertionFailed : public MagicsException {
+public:
+    AssertionFailed(const string&);
+    AssertionFailed(const char*,int,const char*,const char*);
+};
+
+
+inline void Assert(int code,const char *msg,int line,const char *file,
+    const char *proc)
+{
+    if(code != 0)
+        throw AssertionFailed(msg,line,file,proc);
+}
+
+
+class IgnoreException : public MagicsException
+{
+public:
+	 IgnoreException():
+		MagicsException("Just Ignore...") {}
+};
+
+} // end namespace magics
+
+#define ASSERT(a)  Assert(!(a),#a,__LINE__,__FILE__,__FUNCTION__)
+
+#endif
+// EXCEPTION_H_
+
diff --git a/src/common/MagExceptions.cc b/src/common/MagExceptions.cc
new file mode 100644
index 0000000..9cae9ea
--- /dev/null
+++ b/src/common/MagExceptions.cc
@@ -0,0 +1,203 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include <signal.h>
+
+#ifndef MagExceptions_H
+#include "MagExceptions.h"
+#endif
+
+#ifndef ThreadSingleton_H
+#include "ThreadSingleton.h"
+#endif
+
+static MagException*& first()
+{
+	static ThreadSingleton<MagException*> p;
+	return p.instance();
+}
+
+void xldb_throw(const char *c) // To set a break point in xldb
+{
+	if(getenv("PAUSE_MagExceptionS"))
+	{
+		cout << "debug me " << getpid() << endl;
+		pause();
+	}
+
+	if(getenv("ABORT_MagExceptionS"))
+		Panic(c);
+}
+
+MagException::MagException():
+	next_(first())
+{
+	first() = this;
+	xldb_throw("?");
+}
+
+MagException::~MagException() THROW_NOTHING()
+{
+	first() = next_;
+}
+
+void MagException::MagExceptionStack(ostream& out)
+{
+	out << "MagException stack: " << endl;
+	MagException* e =  first();
+	while(e)
+	{
+		out << e->what() << endl;
+		e = e->next_;
+	}
+	out << "End stack" << endl;
+}
+
+MagException::MagException(const string& w):
+	what_(w),
+	next_(first())
+{
+	first() = this;
+	xldb_throw(w.c_str());
+}
+
+void MagException::reason(const string& w)
+{
+	what_ = w;
+}
+
+bool MagException::throwing()
+{
+	return first() != 0;
+}
+
+TooManyRetries::TooManyRetries(const int retries) 
+{
+ cout << "Too many retries: " << retries << endl;
+}
+
+TimeOut::TimeOut(const unsigned long timeout)
+{   
+ cout << "Timeout expired: " << timeout << endl;
+}
+
+
+FailedSystemCall::FailedSystemCall(const string& w)
+{   
+ cout << "Failed system call: " << w << " " << endl;
+}
+
+FailedSystemCall::FailedSystemCall(const char* msg,int line, const char* file, const char* proc,int err)
+{
+ cout << "Failed system call: " << msg << " in " <<proc<< ", line " << line << " of " << file << endl;
+}
+
+AssertionFailed::AssertionFailed(const string& w): 
+	MagException(string("Assertion failed: ") + w)
+{   
+} 
+
+AssertionFailed::AssertionFailed(const char* msg,int line,
+	const char* file, const char* proc)
+{
+ cout << "Assertion failed: " << msg << " in " <<proc<< ", line " << line << " of " << file << endl;
+}
+
+BadParameter::BadParameter(const string& w):
+	MagException(string("Bad parameter: ") + w)
+{   
+}
+
+NotImplemented::NotImplemented(int line,const char* file,const char* proc)
+{
+ cout << "Not implemented: " <<proc<< ", line " << line << " of " << file << endl;
+}
+
+UserError::UserError(const string& r):
+	MagException(string("UserError: ") + r)
+{   
+}
+
+UserError::UserError(const string& r,const string& x):
+	MagException(string("UserError: ") + r + " : " + x)
+{   
+}
+
+Stop::Stop(const string& r):
+	MagException(string("Stop: ") + r)
+{   
+}
+
+Abort::Abort(const string& r):
+	MagException(string("Abort: ") + r)
+{   
+}
+
+OutOfRange::OutOfRange(unsigned long long index, unsigned long long max)
+{   
+}
+
+FileError::FileError(const string& msg)
+{   
+}
+
+CantOpenFile::CantOpenFile(const string& file, bool retry):
+	retry_(retry)
+{   
+}
+
+WriteError::WriteError(const string& file): 
+	FileError(string("Write error on ") + file)
+{   
+}
+
+ReadError::ReadError(const string& file): 
+	FileError(string("Read error on ") + file)
+{   
+}
+
+ShortFile::ShortFile(const string& file): 
+	ReadError(string("Short file while reading ") + file)
+{   
+}
+
+Ostore::Ostore(const string& msg):
+	MagException(string("ObjectStore: ") + msg)
+{
+}
+
+void Panic(const char *msg)
+{
+	msg = msg ? msg : "(null message)";
+
+	if(getenv("SLEEP_ON_PANIC"))
+	{
+		::kill(::getpid(),SIGSTOP);
+	}
+	else ::kill(::getpid(),SIGABRT);
+	::pause();
+}
+
+void Panic(const char* msg,int line,const char* file, const char* proc)
+{
+}
+
+OutOfMemory::OutOfMemory():
+	MagException("out of memory")
+{
+}
diff --git a/src/common/MagExceptions.h b/src/common/MagExceptions.h
new file mode 100644
index 0000000..27e14f0
--- /dev/null
+++ b/src/common/MagExceptions.h
@@ -0,0 +1,213 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef MagMagExceptions_H
+#define MagMagExceptions_H
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+#ifndef MagLog_H
+#include "MagLog.h"
+#endif
+
+void Panic(const char*);
+void Panic(const char *msg,int line,const char *file,const char *proc);
+
+// General purpose MagException
+// Other MagExceptions must be defined in the class that throw them
+
+// Misc. errors
+
+class MagException : public exception {
+
+
+public:
+	virtual const char *what() const THROW_NOTHING() {  return what_.c_str(); }
+	MagException(const string&);
+	~MagException() THROW_NOTHING();
+	virtual bool retryOnServer() const        { return false; }
+	virtual bool retryOnClient() const        { return false; }
+	virtual bool terminateApplication() const { return false; }
+
+	static bool throwing();
+	static void MagExceptionStack(ostream&);
+
+protected:
+	void reason(const string&);
+	MagException();
+private:
+	string what_;
+	//SaveStatus save_;
+	MagException* next_;
+};
+
+class SeriousBug : public MagException {
+public:
+	SeriousBug(const string& w) : MagException(string("Serious Bug:") + w) {}
+	SeriousBug(const string&,const string&);
+	SeriousBug(const string&,int);
+};
+
+class TooManyRetries : public MagException {
+public:
+	TooManyRetries(const int);
+};
+
+class TimeOut : public MagException {
+public:
+	TimeOut(const unsigned long);
+};
+
+class FailedSystemCall : public MagException {
+public:
+	FailedSystemCall(const string&);
+	FailedSystemCall(const char*,int,const char*,const char*,int);
+};
+
+class AssertionFailed : public MagException {
+public:
+	AssertionFailed(const string&);
+	AssertionFailed(const char*,int,const char*,const char*);
+};
+
+class BadParameter : public MagException {
+public:
+	BadParameter(const string& s);
+};
+
+class NotImplemented : public MagException {
+public:
+	NotImplemented(int,const char*,const char*);
+};
+
+class Stop : public MagException {
+public:
+	Stop(const string&);
+};
+
+class Abort : public MagException {
+public:
+	Abort(const string&);
+};
+
+class Cancel : public MagException {
+public:
+	Cancel(const string&);
+};
+
+class UserError : public MagException {
+public:
+	UserError(const string&);
+	UserError(const string&,const string&);
+	UserError(const string&,int);
+};
+
+class OutOfRange : public MagException {
+public:
+	OutOfRange(unsigned long long, unsigned long long);
+};
+
+// File errors
+
+class FileError : public MagException {
+protected:
+	FileError(const string&);
+	FileError()					{  }
+};
+
+class CantOpenFile : public FileError { 
+	bool retry_;
+	virtual bool retryOnServer() const { return retry_; }
+public:
+	CantOpenFile(const string&,bool retry = false);
+};
+
+class WriteError : public FileError { 
+public:
+	WriteError(const string&);
+};
+
+class ReadError : public FileError { 
+public:
+	ReadError(const string&);
+};
+
+class ShortFile : public ReadError { 
+public:
+	ShortFile(const string&);
+};
+
+// ObjectStore
+
+class Ostore : public MagException {
+public:
+	Ostore(const string&);
+};
+
+// =======================================
+
+inline void SysCall(long long code,const char *msg,int line,const char *file,
+	const char *proc)
+{
+	if(code<0)
+		throw FailedSystemCall(msg,line,file,proc,errno);
+}
+
+inline void ThrCall(int code,const char *msg,int line,const char *file,
+	const char *proc)
+{
+	if(code != 0) // Threads return errno in return code
+		throw FailedSystemCall(msg,line,file,proc,code);
+}
+
+inline void Assert(int code,const char *msg,int line,const char *file,
+	const char *proc)
+{
+	/*if(code != 0)
+		throw AssertionFailed(msg,line,file,proc);
+	*/
+}
+
+inline void Panic(int code,const char *msg,int line,const char *file, 
+	const char *proc)
+{
+	if(code != 0) 
+		Panic(msg,line,file,proc);
+}
+
+//--------------------------------------------------------------
+// For compatibility
+//--------------------------------------------------------------
+class OutOfMemory : public MagException {
+	virtual bool terminateApplication() const { return true; }
+	virtual const char *what() const THROW_NOTHING() {  return "OutOfMemory"; }
+public:
+	OutOfMemory();
+
+};
+
+#define THRCALL(a) ThrCall(a,#a,__LINE__,__FILE__,__FUNCTION__)
+#define SYSCALL(a) SysCall(a,#a,__LINE__,__FILE__,__FUNCTION__)
+#define ASSERT(a)  Assert(!(a),#a,__LINE__,__FILE__,__FUNCTION__)
+#define PANIC(a)   Panic((a),#a,__LINE__,__FILE__,__FUNCTION__)
+#define NOTIMP     throw NotImplemented(__LINE__,__FILE__,__FUNCTION__)
+
+
+#endif
diff --git a/src/common/MagFont.cc b/src/common/MagFont.cc
new file mode 100644
index 0000000..70d4318
--- /dev/null
+++ b/src/common/MagFont.cc
@@ -0,0 +1,70 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagFont.cc
+    \brief Implementation of the Template class MagFont.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Mon 14-Aug-2006
+    
+    Changes:
+    
+*/
+
+#include "MagFont.h"
+
+using namespace magics;
+
+MagFont::MagFont(const string& name, const string& style, double size) :
+	name_(name), size_(size)
+{
+	styles_.insert(style);
+}
+
+MagFont::MagFont(const string& name) :
+	name_(name), size_(0.5)
+{
+}
+
+MagFont::MagFont() : name_("sansserif"), size_(0.5)
+{
+}
+
+MagFont::~MagFont() 
+{
+	styles_.clear();
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MagFont::print(ostream& out)  const
+{
+	out << "MagFont[" << name_ << ", " << colour_ << ", ";
+	for ( set<string>::const_iterator style = styles_.begin(); style !=  styles_.end(); ++style) 
+		out << *style << ", ";
+	out << size_ << "]"; 
+}
+
+void MagFont::style(const string& style) 
+{ 
+	if ( styles_.size() == 1 && styles_.begin()->empty() )
+		styles_.clear();
+	styles_.insert(style); 
+}
diff --git a/src/common/MagFont.h b/src/common/MagFont.h
new file mode 100644
index 0000000..1204620
--- /dev/null
+++ b/src/common/MagFont.h
@@ -0,0 +1,94 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagFont.h
+    \brief Definition of the Template class MagFont.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Mon 14-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef MagFont_H
+#define MagFont_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Colour.h"
+
+namespace magics {
+
+class MagFont {
+
+public:
+	MagFont(const string&, const string&, double size);
+	MagFont(const string&);
+	MagFont();
+	~MagFont();
+
+	const string& name() const      { return name_; }
+	void name(const string& name)   { name_ = name; }
+
+	const string& style() const     { return *styles_.begin(); }
+	void style(const string& style);
+
+	const set<string>& styles() const { return styles_; }
+
+	double size() const             { return size_; }
+	void size(double size)          { size_ = size; }
+
+	const Colour& colour() const      { return colour_; }
+	void colour(const Colour& colour)   {colour_ = colour; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const; 
+
+	string name_;
+	set<string> styles_;
+	double size_;
+	Colour colour_;
+
+private: 
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MagFont& p)
+		{ p.print(s); return s; }
+};
+
+template<>
+class MagTranslator<string,magics::MagFont> { 
+public:
+	MagFont* operator()(string s)
+	{
+		return new MagFont(s);
+	}
+
+	MagFont* magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/MagLog.cc b/src/common/MagLog.cc
new file mode 100644
index 0000000..7c2ea79
--- /dev/null
+++ b/src/common/MagLog.cc
@@ -0,0 +1,280 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagLog.cc
+    \brief Implementation of the MagLog class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+    Changes:
+*/
+
+#include <MagLog.h>
+#include "MagicsObserver.h"
+
+using namespace magics;
+
+MagLog  MagLog::log_;
+bool MagLog::header_;
+
+class MagLogObserver : public ostringstream
+{
+public:
+	MagLogObserver() {}
+	~MagLogObserver() {}
+	
+	void broadcast()
+	{
+		cout << "BROADCAST---->" << str() << "<---BROADCAST----";
+		flush();
+	}
+};
+
+static MagLogObserver MYLOG;
+
+
+//extern string lowerCase(const string&);
+
+inline bool setMsg(const string& name, bool def)
+{
+	string value = getEnvVariable(name);
+	//value = lowerCase(value);
+	if (value == "no" || value == "off" || value == "false") return false;
+	if (value == "yes"|| value == "on"  || value == "true")  return true;
+
+	return def;
+}
+
+/*!
+ \todo Decide if Warnings are plotted when MAGPLUS_QUIET 
+*/
+MagLog::MagLog() :
+    reporter_(0),
+    devnull_("/dev/null"),
+    debug_(true), 
+    dev_(true),
+    info_(true),
+    userInfo_(true),
+    warning_(true),
+    error_(true),
+    fatal_(true),
+    profiling_(true),
+    warnings_(0)
+{
+    debug_ = setMsg("MAGPLUS_DEBUG", false);
+    dev_ = setMsg("MAGPLUS_DEV", false);
+    info_ = setMsg("MAGPLUS_INFO", false);
+    profiling_ = setMsg("MAGPLUS_PROFILE", false);
+    if(setMsg("MAGPLUS_QUIET",false) )
+    {
+       info_      = false;
+       dev_       = false;
+       profiling_ = false;
+       debug_    = false;
+       userInfo_ = false;
+    }
+    header_ = true;
+}
+
+MagLog::~MagLog() 
+{
+	//if ( reporter_ ) delete reporter_;
+}
+
+static void niceprint(int nb, const string& legend, const string& sep, ostream& out)
+{
+	if (!nb) return;
+	string plurial = (nb > 1) ? "s" : "";
+	out << sep << nb << legend << plurial; 
+}
+	
+void ErrorReporter::report(ostream& out)  const
+{
+	if ( !warnings_ &&  !errors_) return;
+
+	out << " - [ ";
+	niceprint(warnings_, " warning", "", out);
+	string sep = (warnings_) ? ", " : "";
+	niceprint(errors_, " error", sep, out);
+	out << " ]";
+	warnings_ = 0;
+	errors_   = 0;
+}
+
+
+void MagLog::print(ostream&)  const
+{
+}
+
+
+ostream& MagLog::warning()
+{
+	if ( log_.reporter_ ) log_.reporter_->warning();
+	// Here we broadcast some eventuel infos...
+	broadcast();
+	if (log_.warning_)
+	{
+		if ( log_.warnings_ ++ == 100 ) {
+			log_.warningstream_ << "Magics-warning: Too many warnings! Stop sending them ..." << endl;
+			return log_.devnull_;
+		}
+
+		if  ( log_.warnings_  < 100 ) {
+			if ( log_.observers_.empty() ) {
+				cout  << "Magics-warning: ";
+				return cout;
+			}
+			log_.warningstream_ << "Magics-warning: ";
+			return log_.warningstream_;
+		}
+	}
+	return log_.devnull_;
+}
+
+ostream& MagLog::error()
+{
+	if ( log_.reporter_ ) log_.reporter_->error();
+	broadcast();
+	if (log_.error_)
+	{
+		if ( log_.observers_.empty() ) {
+			cout  << "Magics-ERROR: ";
+			return cout;
+		}
+		log_.errorstream_ << "Magics-ERROR: ";
+		return log_.errorstream_;
+	}
+	return log_.devnull_;
+}
+
+
+ostream& MagLog::debug()
+{
+	if (log_.debug_)
+	{
+		string text = ( header_ )  ? "Magics-debug: " : "";
+		cout << text;
+		return cout;
+	}
+	return log_.devnull_;
+}
+
+ostream& MagLog::profile()
+{
+	if (log_.profiling_)
+	{
+		string text = ( header_ )  ? "Magics-profile: " : "";
+		cout << text;
+		return cout;
+	}
+	return log_.devnull_;
+}
+
+ostream& MagLog::dev()
+{
+	if (log_.dev_) {
+		string text = ( header_ )  ? "Magics-dev: " : "";
+		cout << text;		
+		return cout;
+	}
+	return log_.devnull_;
+}
+
+ostream& MagLog::info()
+{
+	// Here we broadcast some eventuel infos...
+	broadcast();
+	if (log_.info_)
+	{
+		if ( log_.observers_.empty() ) {
+			cout  << "Magics-warning: ";
+			return cout;
+		}
+		log_.infostream_ << "Magics-info: ";
+		return log_.infostream_;
+	}
+	return log_.devnull_;
+}
+
+ostream& MagLog::progress()
+{
+	// Here we broadcast some eventuel infos...
+	broadcast();
+
+	log_.progressstream_ << "Magics-progress: ";
+	return log_.progressstream_;
+}
+
+void MagLog::progress(const string& msg)
+{
+	for(vector<MagicsObserver*>::iterator observer = log_.observers_.begin(); observer != log_.observers_.end(); ++observer) 
+	{			
+		(*observer)->progressMessage(msg);
+	}
+}
+
+ostream& MagLog::userInfo()
+{
+	if (log_.userInfo_)
+	{
+		cout << "Magics :";
+		return cout;
+	}
+	return log_.devnull_;
+}
+
+
+void MagLog::broadcast()
+{
+	for ( vector<MagicsObserver*>::iterator observer = log_.observers_.begin(); observer != log_.observers_.end(); ++observer) {
+		if ( !log_.warningstream_.str().empty() ) {
+			(*observer)->warningMessage(log_.warningstream_.str());
+		}
+		if ( !log_.errorstream_.str().empty() ) {
+			(*observer)->errorMessage(log_.errorstream_.str());
+		}		
+		if ( !log_.infostream_.str().empty() ){
+			(*observer)->infoMessage(log_.infostream_.str());
+		}
+		if ( !log_.progressstream_.str().empty() ){
+			(*observer)->progressMessage(log_.progressstream_.str());
+		}
+	}
+	log_.warningstream_.str("");
+	log_.errorstream_.str("");
+	log_.infostream_.str("");
+	log_.progressstream_.str("");
+}
+
+ostream& MagLog::fatal()
+{
+	if (log_.fatal_)
+	{
+		cout << "Magics-fatal: ";
+		return cout;
+	}
+	return log_.devnull_;
+}
+
+void MagLog::unregisterObserver(MagicsObserver* observer)
+{
+	 vector<MagicsObserver*>::iterator o = std::find(log_.observers_.begin(), log_.observers_.end(), observer);
+	 if ( o != log_.observers_.end() )
+		 log_.observers_.erase(o);
+}
diff --git a/src/common/MagLog.h b/src/common/MagLog.h
new file mode 100644
index 0000000..58d211f
--- /dev/null
+++ b/src/common/MagLog.h
@@ -0,0 +1,162 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagLog.h
+    \brief Definition of log class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+*/
+
+#ifndef MPPMagLog_H
+#define MPPMagLog_H
+
+#include "magics.h"
+#include <fstream>
+using std::ofstream;
+
+namespace magics {
+
+
+class ErrorReporter
+{
+public:
+	ErrorReporter() : errors_(0), warnings_(0) {}
+	void error()  const { errors_++; }
+	void warning() const { warnings_++; }
+	void report(ostream&) const;
+
+protected:
+	mutable int errors_;
+	mutable int warnings_;
+};
+
+class MagicsObserver;
+
+class MagLog {
+
+public:
+	MagLog();
+	//! Destructor
+	~MagLog();
+	
+	
+
+// -- Methods
+	static ostream& warning();
+	static ostream& debug();
+	static ostream& info();
+	static ostream& userInfo();
+	static ostream& error();
+	static ostream& fatal();
+	static ostream& dev();
+	static ostream& profile();
+	static ostream& progress();
+	static void progress(const string&);
+	
+	static void broadcast();
+
+	static void devMessage(bool dev = true)
+		 { log_.dev_ = dev; }
+	
+	static void infoMessage(bool info = true)
+		 { log_.info_ = info; }
+	
+	static void userInfoMessage(bool info = true)
+		 { log_.userInfo_ = info; }
+
+	static void warningMessage(bool warning = true)
+		 { log_.warning_ = warning; }
+
+	static void debugMessage(bool debug = true)
+		 { log_.debug_ = debug; }
+
+	static void errorMessage(bool error = true)
+		 { log_.error_ = error; }
+	
+	static void profilingMessage(bool error = true)
+			 { log_.error_ = error; }
+
+	static void fatalMessage(bool fatal = true)
+		 { log_.fatal_ = fatal; }
+
+	static void header(bool header)
+		 { header_ = header; }
+
+	static void setReporter(const ErrorReporter* reporter) { log_.reporter_ = reporter; }
+	static void registerObserver(MagicsObserver* observer) { log_.observers_.push_back(observer); }
+	static void unregisterObserver(MagicsObserver* observer);
+
+protected:
+// -- Methods
+	 void print(ostream&) const;
+	 const ErrorReporter* reporter_;
+
+private:
+// No copy allowed
+	MagLog(const MagLog&);
+	MagLog& operator=(const MagLog&);
+
+// -- Members
+	static MagLog log_;
+	static bool header_;
+
+	ofstream devnull_;
+	bool debug_;
+	bool dev_;
+	bool info_;
+	bool userInfo_;	
+	bool warning_;
+	bool error_;
+	bool fatal_;
+	bool profiling_;
+
+	string stamp_;
+	
+	int warnings_;
+	
+	ostringstream infostream_;
+	ostringstream warningstream_;
+	ostringstream errorstream_;
+	ostringstream progressstream_;
+	vector<MagicsObserver*> observers_;
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const MagLog& p)
+		{ p.print(s); return s; }
+};
+/*
+class HeaderMagLog
+{
+public:
+	HeaderMagLog(bool header = true): header_(header) {}
+	~HeaderMagLog() {}	
+
+	friend  ostream& operator <<(ostream& out, const HeaderMagLog& log) 
+	{
+		MagLog::header(log.header_);
+		return out;
+	}
+	bool header_;
+};
+*/
+#define LOGDEV(a) MagLog::dev() << __FUNCTION__ << "--->" << #a << " = " << a << "\n";
+#define VALGRIND  MagLog::dev() << "valgrind----->" << __FUNCTION__ << "\n";
+}
+#endif
diff --git a/src/common/MagTranslator.h b/src/common/MagTranslator.h
new file mode 100644
index 0000000..d465010
--- /dev/null
+++ b/src/common/MagTranslator.h
@@ -0,0 +1,592 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagTranslator.h
+    \brief Definition of MagTranslator class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+
+#ifndef MPP_MagTranslator_H
+#define MPP_MagTranslator_H
+
+// Forward declarations
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Tokenizer.h"
+
+
+namespace magics {
+	
+class Matrix;
+
+template<class From,class To> 
+class MagTranslator {
+public:
+	virtual ~MagTranslator() {}
+// Default template calls cast
+	To* operator()(From from)
+	{
+		return new To(from); 
+	}
+  
+	To* magics(const string& param)
+	{
+		From from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string, double>
+{
+public:
+	double operator()(string value)
+	{
+		return atof(value.c_str());
+	}
+
+	double magics(const string& param)
+	{
+		double from;
+		ParameterManager::get(param, from);
+		return from;
+	}
+};
+
+
+template<>
+class MagTranslator<double, double> {
+public:
+	double operator()(double value)
+	{
+		return value;
+	}
+    
+	double magics(const string& param)
+	{
+		double from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+#if MAGICS_CAIRO
+template<>
+class MagTranslator<cairo_t*, cairo_t*> {
+public:
+	cairo_t* operator()(cairo_t* value)
+	{
+		return value;
+	}
+    
+	cairo_t* magics(const string& param)
+	{
+		cairo_t* from;
+		ParameterManager::get(param, from);
+		return (*this)(from); 
+	}
+};
+
+template<>
+class MagTranslator<string,  cairo_t*> {
+public:
+	cairo_t* operator()(const string&)
+	{
+		return 0;
+	}
+	string magics(const string&)
+	{
+		return "unknown";
+	}
+};
+#endif
+
+#if MAGICS_QT
+template<>
+class MagTranslator<QWidget*, QWidget*> {
+public:
+	QWidget* operator()(QWidget* value)
+	{
+		return value;
+	}
+    
+	QWidget* magics(const string& param)
+	{
+		QWidget* from;
+		ParameterManager::get(param, from);
+		return (*this)(from); 
+	}
+};
+
+template<>
+class MagTranslator<string,  QWidget*> {
+public:
+	QWidget* operator()(const string&)
+	{
+		return 0;
+	}
+	string magics(const string&)
+	{
+		return "unknown";
+	}
+};
+template<>
+class MagTranslator<QGraphicsScene*, QGraphicsScene*> {
+public:
+	QGraphicsScene* operator()(QGraphicsScene* value)
+	{
+		return value;
+	}
+    
+	QGraphicsScene* magics(const string& param)
+	{
+		QGraphicsScene* from;
+		ParameterManager::get(param, from);
+		return (*this)(from); 
+	}
+};
+
+template<>
+class MagTranslator<string,  QGraphicsScene*> {
+public:
+	QGraphicsScene* operator()(const string&)
+	{
+		return 0;
+	}
+	string magics(const string&)
+	{
+		return "unknown";
+	}
+};
+#endif
+
+
+template<>
+class MagTranslator<doublearray, doublearray> {
+public:
+	virtual ~MagTranslator() {}
+
+	doublearray operator()(doublearray value)
+	{
+		return value;
+	}
+    
+	doublearray magics(const string& param)
+	{
+		doublearray from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string, doublearray> {
+public:
+	doublearray operator()(string value)
+	{
+		doublearray array;
+		vector<string> list;
+		Tokenizer tokenizer("/");
+		tokenizer(value, list);
+		for(vector<string>::const_iterator item = list.begin(); item != list.end(); ++item) {
+			array.push_back(atof((*item).c_str()));
+		}
+		return array;
+	}
+	doublearray magics(const string& param)
+	{
+		doublearray from;
+		ParameterManager::get(param, from);
+		return from;
+	}
+};
+template<>
+class MagTranslator<string, Matrix> {
+public:
+//	Matrix operator()(string value)
+	Matrix operator()(string )
+	{
+		Matrix array;
+		return array;
+	}
+	Matrix magics(const string& param)
+	{
+		Matrix from;
+		ParameterManager::get(param, from);
+		return from;
+	}
+};
+
+template<>
+class MagTranslator<string, int> {
+public:
+	int operator()(string value)
+	{
+		return atoi(value.c_str());
+	}
+	int magics(const string& param)
+	{
+		int from;
+		ParameterManager::get(param, from);
+		return from;
+	}
+};
+
+template<>
+class MagTranslator<int, int> {
+public:
+	int operator()(int value)
+	{
+		return value;
+	}
+	int magics(const string& param)
+	{
+		int from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string, intarray> {
+public:
+	intarray operator()(string value)
+	{
+		intarray array;
+		vector<string> list;
+		Tokenizer tokenizer("/");
+		tokenizer(value, list);
+    
+		for(vector<string>::const_iterator item = list.begin(); item != list.end(); ++item) {
+			array.push_back(atoi((*item).c_str()));
+		}
+		return array;
+	}
+	intarray magics(const string& param)
+	{
+		intarray from;
+		ParameterManager::get(param, from);
+		return from;
+	}
+};
+
+
+template<>
+class MagTranslator<intarray, intarray> {
+public:
+	intarray operator()(intarray value)
+	{
+		return value;
+	}
+	intarray magics(const string& param)
+	{
+		intarray from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<const string&, const string&> {
+public:
+	const string& operator()(const string& value)
+	{
+		return value;
+	}
+	const string& magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+template<>
+class MagTranslator<string, string> {
+public:
+	string operator()(const string& value)
+	{
+		return value;
+	}
+	string magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<stringarray, stringarray> {
+public:
+	stringarray operator()(stringarray value)
+	{
+		return value;
+	}
+	stringarray magics(const string& param)
+	{
+		stringarray from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string, stringarray> {
+public:
+	stringarray operator()(string value)
+	{
+		stringarray result;
+		
+		Tokenizer tokenizer("/");
+		tokenizer(value, result);
+		return result;
+	}
+    
+	stringarray magics(const string& param)
+	{
+		stringarray from;
+		ParameterManager::get(param, from);
+		return from;
+	}
+};
+
+template<>
+class MagTranslator<bool,const string&> {
+public:
+	string operator()(bool value)
+	{
+		ostringstream out;
+		out << value << ends;
+		return out.str();
+	}
+};
+
+template<>
+class MagTranslator<const string&,bool> { 
+public:
+	bool operator()(const string& s)
+	{
+		if(s == "no" || s == "off" || s == "false") return false;
+		if(s == "yes"|| s == "on"  || s == "true")  return true;
+
+		// Catter for ints
+		return atoi(s.c_str());
+	}
+	bool magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string,bool> { 
+public:
+	bool operator()(string s)
+	{
+		 string val = lowerCase(s);
+		if(val == "no" || val == "off" || val == "false") return false;
+		if(val == "yes"|| val == "on"  || val == "true")  return true;
+
+		// Catter for ints
+		return atoi(val.c_str());
+	}
+	bool magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string,magics::Hemisphere> { 
+public:
+	magics::Hemisphere operator()(string s)
+	{
+ 		string val = lowerCase(s);
+		//enum	LineStyle { SOLID , DASH , DOT , CHAIN_DASH , CHAIN_DOT };
+		if (val  == "north") return NORTH;
+		if (val  == "south") return SOUTH;
+		
+		return NORTH;
+	}
+	magics::Hemisphere magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string,magics::ArrowPosition> { 
+public:
+	magics::ArrowPosition operator()(string s)
+	{
+		string val = lowerCase(s);
+		//enum	LineStyle { SOLID , DASH , DOT , CHAIN_DASH , CHAIN_DOT };
+		if (val  == "tail") return M_TAIL;
+		if (val  == "centre") return M_CENTRE;
+		
+		return M_TAIL;
+	}
+	magics::ArrowPosition magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string,magics::LineStyle> { 
+public:
+	magics::LineStyle operator()(string s)
+	{
+		string val = lowerCase(s);
+		if (val  == "solid") return M_SOLID;
+		if (val  == "dash") return M_DASH;
+		if (val  == "dot") return M_DOT;
+		if (val  == "chain_dash") return M_CHAIN_DASH;
+		if (val  == "chain_dot") return M_CHAIN_DOT;
+		return M_SOLID;
+	}
+	magics::LineStyle magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+
+template<>
+class MagTranslator<string,magics::Justification> { 
+public:
+	magics::Justification operator()(string s)
+	{
+		string val = lowerCase(s);
+		// enum	Justification { MLEFT , MCENTRE, MRIGHT }; };
+		if (val  == "left") return MLEFT;
+		if (val  == "centre") return MCENTRE;
+		if (val  == "right") return MRIGHT;
+		return MCENTRE;
+	}
+	magics::Justification magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string,magics::ListPolicy> { 
+public:
+	magics::ListPolicy operator()(string s)
+	{
+ 		string val = lowerCase(s);
+		// enum	ListPolicy { M_LASTONE , M_CYCLE }; };
+		if (val  == "lastone") return M_LASTONE;
+		if (val  == "cycle") return M_CYCLE;
+		MagLog::warning() << "Invalid value : " << val << "for a List Policy-->" << " changed to lastone" << endl;
+		return M_LASTONE;
+	}
+	magics::ListPolicy magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+template<>
+class MagTranslator<string,magics::AxisAutomaticSetting> { 
+public:
+	magics::AxisAutomaticSetting operator()(string s)
+	{
+ 		string val = lowerCase(s);
+		// enum	ListPolicy {  m_off, m_both, m_min_only, m_max_only }; };
+		if (val  == "off") return m_off;
+		if (val  == "no") return m_off;
+		if (val  == "false") return m_off;
+		if (val  == "on") return m_both;
+		if (val  == "yes") return m_both;
+		if (val  == "true") return m_both;
+		if (val  == "both") return m_both;
+		if (val  == "min_only") return m_min_only;
+		if (val  == "max_only") return m_max_only;
+		
+		MagLog::warning() << "Invalid value : " << val << "for an  Axis Automatic Setting-->" << " changed to off" << endl;
+		return m_off;
+	}
+	magics::AxisAutomaticSetting magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<string,magics::DisplayType> { 
+public:
+	magics::DisplayType operator()(const string& s)
+	{
+		string val = lowerCase(s);
+		// enum	Justification { MLEFT , MCENTRE, MRIGHT }; };
+		if (val  == "inline") return INLINE;
+		if (val  == "block") return BLOCK;
+		if (val  == "none") return NONE;
+		if (val  == "hidden") return HIDDEN;
+		if (val  == "absolute") return ABSOLUTE;
+		return ABSOLUTE;
+	}
+	magics::DisplayType magics(const string& param)
+	{
+		string from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+template<>
+class MagTranslator<Matrix, Matrix> {
+public:
+	Matrix operator()(Matrix value)
+	{
+		return value;
+	}
+	Matrix magics(const string& param)
+	{
+		Matrix from;
+		ParameterManager::get(param, from);
+		return (*this)(from);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/MagicsCalls.cc b/src/common/MagicsCalls.cc
new file mode 100644
index 0000000..4a78bee
--- /dev/null
+++ b/src/common/MagicsCalls.cc
@@ -0,0 +1,1618 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagicsCalls.cc
+    \brief Implementation of Fortran and C interface
+
+ To use the C interface "magics_api.h" must be included.
+
+ Changes: 13-06-2006 Added C interface (Stephan)
+
+ \sa magics_api.h
+*/
+
+#include <MagLog.h>
+#include <FortranMagics.h>
+#include <WebFormat.h>
+#include <MagicsParameter.h>
+
+extern "C" {
+#include <magics_api.h>
+}
+
+
+
+static FortranMagics* magics_ = 0;
+
+/*! \defgroup compatibility Compatibility to MAGICS 6 for deprecated parameters
+
+  The CompatibilityHelper allows the handling of deprecated parameters and set the
+  equivalent new parameter are gives info/warning messages. The class is located in 
+  file src/common/MagicsCalls.cc .
+  
+  To add a new parameter produce a new class which inherits from CompatibilityHelper.
+  The produce a static object of that class: static 'class_name' 'para_name';
+
+*/
+
+/*! \brief Ensures backwards compability with Magics 6.x
+
+  This base class checks if parameter are set which are not supported anymore 
+  in Magics++ but need to be supported for backwards compability.
+  
+*/
+class CompatibilityHelper 
+{
+public :
+	CompatibilityHelper(const string& name) {
+		compatibility_[name] = this;
+	}
+	CompatibilityHelper() {}
+	
+	void set(const string& name) {
+		compatibility_[name] = this;
+	} 
+
+	virtual ~CompatibilityHelper() {}
+	template <class P>
+	static bool check(const string& param, P value) 
+	{
+		map<string, CompatibilityHelper*>::const_iterator tool = compatibility_.find(lowerCase(param));
+		if ( tool == compatibility_.end() ) return false;
+		else return (*(tool->second))(value);
+	}
+	static void reset(const string& param)  {
+		map<string, CompatibilityHelper*>::const_iterator tool = compatibility_.find(lowerCase(param));
+		if ( tool != compatibility_.end() )
+			(*(tool->second)).reset();
+	}
+	static bool check(const string& param, const string& value) 
+	{
+		map<string, CompatibilityHelper*>::const_iterator tool = compatibility_.find(lowerCase(param));
+		if ( tool == compatibility_.end() ) return false;
+		else return (*(tool->second))(string(value));
+	}
+	virtual void reset()            		   { }
+	virtual bool operator()(int)           { return false; }
+	virtual bool operator()(const string&) { return false; }
+	virtual bool operator()(double)        { return false; }
+	virtual bool operator()(const doublearray&)        { return false; }
+	virtual bool operator()(const stringarray&)        { return false; }
+	virtual bool operator()(const intarray&)        { return false; }
+	virtual bool operator()(bool)        { return false; }
+protected:
+	static map<string, CompatibilityHelper*> compatibility_;
+};
+
+class NoMoreGribex : public CompatibilityHelper
+{
+public :
+	NoMoreGribex(const string& param) : CompatibilityHelper(param), parameter_(param) {}
+	~NoMoreGribex() {}
+	bool operator()(const string&)
+	{
+		MagLog::info() << "Compatibility issue: the parameter [" << parameter_ << "] is discontinued.\n"
+		            << "              Please use the grib_api interface  instead." <<endl;
+		return true;
+	}
+
+protected :
+	string parameter_;
+};
+
+
+class IgnoreConverter : public CompatibilityHelper
+{
+public :
+	IgnoreConverter(const string& param) : CompatibilityHelper(param), parameter_(param) {}
+	~IgnoreConverter() {}
+	bool operator()(const string&)
+	{
+		MagLog::info() << "Deprecated: Parameter " << parameter_ << " is not needed anymore --> setting is ignored" <<endl;
+		return true;
+	}
+
+protected :
+	string parameter_;
+};
+
+
+class ComingSoonConverter : public CompatibilityHelper
+{
+public :
+	ComingSoonConverter(const string& param) : CompatibilityHelper(param), parameter_(param) {}
+	~ComingSoonConverter() {}
+	bool operator()(const string&)
+	{
+		MagLog::info() << "Coming soon: Parameter " << parameter_ << " will be implemented soon" <<endl;
+		return true;
+	}
+
+protected :
+	string parameter_;
+};
+
+map<string, CompatibilityHelper*> CompatibilityHelper::compatibility_;
+
+
+/*! \brief Prints info about old parameter
+*/
+class GribSubareaExtraction: public CompatibilityHelper {
+public :
+	GribSubareaExtraction() : CompatibilityHelper("grib_subarea_extraction") {}
+	~GribSubareaExtraction() {}
+	bool operator()(const string& )
+	{
+		MagLog::info() << "Compatibility issue: Parameter grib_subarea_extraction not required anymore.\n"<<endl;
+		return true;
+	}
+};
+
+/*! \brief Prints info about old parameter
+*/
+class GribFieldPosition: public CompatibilityHelper {
+public :
+	GribFieldPosition() : CompatibilityHelper("grib_field_position") {}
+	~GribFieldPosition() {}
+	bool operator()(int)
+	{
+		assert(magics_);
+		magics_->resetGrib();
+		return false;
+	}
+};
+class SimpleTranslator: public CompatibilityHelper {
+public:
+	SimpleTranslator(const string& from, const string& to, bool both=false) : CompatibilityHelper(from), from_(from), to_(to), both_(both) {}
+	~SimpleTranslator() {}
+	void deprecated() {
+		MagLog::warning() << "Compatibility issue: Parameter " << from_ << " is deprecated : consider using " << to_ << " instead\n";
+	}
+	bool operator()(double val)
+	{
+		if ( both_ )
+			ParameterManager::set(from_, val);
+		else {
+			deprecated();
+		}
+		if ( CompatibilityHelper::check(to_, val) ) return true;
+		ParameterManager::set(to_, val);
+		return true;
+	}
+	virtual void reset()
+	{	if ( both_ )
+			ParameterManager::reset(from_);
+		else {
+			deprecated();
+
+		}
+		ParameterManager::reset(to_);
+	}
+	virtual bool operator()(int val)
+	{
+		if ( both_ )
+					ParameterManager::set(from_, val);
+				else {
+					deprecated();
+
+				}
+		ParameterManager::set(to_, val);
+				return true;
+	}
+	virtual bool operator()(const string& val)
+	{
+		if ( both_ )
+					ParameterManager::set(from_, val);
+				else {
+					deprecated();
+
+				}
+		ParameterManager::set(to_, val);
+				return true;
+	}
+
+	virtual bool operator()(const doublearray& val) {
+		if ( both_ )
+					ParameterManager::set(from_, val);
+				else {
+					deprecated();
+
+				}
+		ParameterManager::set(to_, val);
+				return true;
+	}
+	virtual bool operator()(const stringarray& val)    {
+		if ( both_ )
+					ParameterManager::set(from_, val);
+				else {
+					deprecated();
+
+				}
+		ParameterManager::set(to_, val);
+				return true;
+	}
+	virtual bool operator()(bool val)      {
+		if ( both_ )
+					ParameterManager::set(from_, val);
+				else {
+					deprecated();
+
+				}
+		ParameterManager::set(to_, val);
+				return true;
+	}
+	string from_;
+	string to_;
+	bool both_; // If both_ is true set the 2 parameters the old, and the new!
+};
+
+class ActionInterceptor: public CompatibilityHelper {
+public:
+	ActionInterceptor(const string& from, FortranMagics::Action action) : CompatibilityHelper(from), action_(action){}
+	~ActionInterceptor() {}
+
+	bool operator()(double val)
+	{
+		(magics_->*action_)();
+		return false;
+	}
+
+	virtual bool operator()(int val)
+	{
+		(magics_->*action_)();
+		return false;
+	}
+	virtual bool operator()(const string& val)
+	{
+		(magics_->*action_)();
+		return false;
+	}
+
+	virtual bool operator()(const doublearray& val) {
+		(magics_->*action_)();
+		return false;
+	}
+	virtual bool operator()(const stringarray& val)    {
+		(magics_->*action_)();
+		return false;
+	}
+	virtual bool operator()(bool val)      {
+		(magics_->*action_)();
+		return false;
+	}
+
+	FortranMagics::Action action_;
+
+};
+
+/*! \brief Converts WIND_ARROW_LEGEND into LEGEND
+
+  The convention to enable Legends for Wind in Magics++ has changed.
+*/
+class WindArrowLegend: public CompatibilityHelper {
+public :
+	WindArrowLegend() : CompatibilityHelper("wind_arrow_legend") {}
+	~WindArrowLegend() {}
+	bool operator()(const string& leg)
+	{
+		MagLog::info() << "Compatibility issue: wind_arrow_legend is deprecated.\n"
+		            << "               Please use legend instead."<<endl;
+		ParameterManager::set("legend", leg);
+		return true;
+	}
+};
+
+/*! \brief Converts WIND_ARROW_LEGEND into LEGEND
+
+  The convention to enable Legends for Wind in Magics++ has changed.
+*/
+class CoastlinesResolution: public CompatibilityHelper {
+public :
+	CoastlinesResolution() : CompatibilityHelper("map_coastline_resolution")  { }
+	~CoastlinesResolution() {}
+	bool operator()(const string& res)
+	{
+
+		if ( magCompare(res, "high") || magCompare(res, "medium") ) {
+			MagLog::warning() << "Magics is using a new dataset for coastlines naturalearth.\n"
+		            << "             You can experience longer processing time and bigger output files \n"
+					<< "             if you use medium or high on a large area.\n"
+					<< "             if so, you may want to come back to low or automatic resolution.\n";
+		}
+
+
+		return true;
+	}
+};
+
+
+/*! \brief Converts ps_file_name into output_file_root_name.
+
+  The convention to describe filenames in Magics++ has changed.
+*/
+class PsFileName: public CompatibilityHelper {
+public :
+	PsFileName() : CompatibilityHelper("ps_file_name") {}
+	~PsFileName() {}
+	bool operator()(const string& file)
+	{
+		MagLog::info() << "Compatibility issue: ps_file_name is deprecated.\n"
+		            << "               Please use output_name instead."<<endl;
+		ParameterManager::set("output_legacy_name", file);
+		ParameterManager::set("output_file_minimal_width", 0);  
+		return true;
+	}
+};
+
+/*! \brief Gives warning for using ps_device 
+*/
+class PsDevice: public CompatibilityHelper {
+public :
+	PsDevice() : CompatibilityHelper("ps_device") {}
+	~PsDevice() {}
+	bool operator()(const string& )
+	{
+		MagLog::info() << "Compatibility issue: ps_device was removed.\n"
+		            << "               Please use other PostScript driver parameter instead."<<endl;
+		return true;
+	}
+};
+
+/*! \brief Converts ps_device into output_ps_device.
+*/
+class OutputPsDevice: public CompatibilityHelper {
+public :
+	OutputPsDevice() : CompatibilityHelper("output_ps_device") {}
+	~OutputPsDevice() {}
+	bool operator()(const string& )
+	{
+		MagLog::info() << "Compatibility issue: output_ps_device is deprecated."<<endl;
+		return true;
+	}
+};
+
+/*! \brief Removes ps_help
+*/
+class PsHelp: public CompatibilityHelper {
+public :
+	PsHelp() : CompatibilityHelper("ps_help") {}
+	~PsHelp() {}
+	bool operator()(const string& )
+	{
+		MagLog::info() << "Compatibility issue: Parameter ps_help was removed.\n"<<endl;
+		return false;
+	}
+};
+
+/*! \brief Removes ps_metric
+*/
+class PsMetric: public CompatibilityHelper {
+public :
+	PsMetric() : CompatibilityHelper("ps_metric") {}
+	~PsMetric() {}
+	bool operator()(const string& )
+	{
+		MagLog::info() << "Compatibility issue: Parameter ps_metric was removed.\n"<<endl;
+		return false;
+	}
+};
+
+/*! 
+*/
+class GraphType: public CompatibilityHelper {
+public :
+	GraphType() : CompatibilityHelper("graph_type") {}
+	~GraphType() {}
+	bool operator()(const string& type)
+	{
+		if ( magCompare(type, "curve") ) {
+			ParameterManager::set("graph_shade", "off");
+		}
+		if ( magCompare(type, "bar") ) {
+			ParameterManager::set("graph_shade", "on");
+		}
+		if ( magCompare(type, "area") ) {
+			ParameterManager::set("graph_shade", "on");
+		}
+		return false;
+	}
+};
+
+class GraphValuesConverter : public CompatibilityHelper
+{
+public:
+	GraphValuesConverter(const string& from, const string & to) : 
+		CompatibilityHelper(from), from_(from), to_(to) {}
+	
+	bool operator()(const doublearray& values)
+	{
+		MagLog::info() << "Compatibility issue: Parameter " << from_ << " is deprecated.\n"
+		            << "               Please use " << to_ << " instead."<<endl;
+		ParameterManager::set(to_, values);  
+		return true;
+	}
+	bool operator()(const stringarray& values)
+	{
+		MagLog::info() << "Compatibility issue: Parameter " << from_ << " is deprecated.\n"
+		            << "               Please use " << to_ << " instead."<<endl;
+		ParameterManager::set(to_, values);  
+		return true;
+	}
+	bool operator()(const string& value)
+	{
+		MagLog::info() << "Compatibility issue: Parameter " << from_ << " is deprecated.\n"
+		            << "               Please use " << to_ << " instead."<<endl;
+		ParameterManager::set(to_, value);
+		return true;
+	}
+	bool operator()(double value)
+	{
+		MagLog::info() << "Compatibility issue: Parameter " << from_ << " is deprecated.\n"
+		            << "               Please use " << to_ << " instead."<<endl;
+		ParameterManager::set(to_, value);
+		return true;
+	}
+	void reset() {
+		ParameterManager::reset(to_);
+	}
+protected:
+	string from_;
+	string to_;
+};
+
+class ValuesConverter : public CompatibilityHelper
+{
+public:
+	ValuesConverter(const string& from, const string & to, bool done=true) :
+		CompatibilityHelper(from), from_(from), to_(to), done_(done) {}
+	
+	bool operator()(const doublearray& values)
+	{
+		
+		ParameterManager::set(to_, values);  
+		return done_;;
+	}
+	bool operator()(const stringarray& values)
+	{
+		
+		ParameterManager::set(to_, values);  
+		return done_;
+	}
+	bool operator()(const string& values)
+		{
+
+			ParameterManager::set(to_, values);
+			return done_;
+		}
+protected:
+	string from_;
+	string to_;
+	bool done_;
+};
+
+
+
+static GraphValuesConverter graph_curve_x_values("graph_curve_x_values", "x_values");
+static GraphValuesConverter graph_curve_y_values("graph_curve_y_values", "y_values");
+static GraphValuesConverter graph_curve_date_x_values("graph_curve_date_x_values", "x_date_values");
+static GraphValuesConverter graph_curve_date_y_values("graph_curve_date_y_values", "y_date_values");
+
+
+
+static GraphValuesConverter graph_curve_x_base_date("graph_curve_x_base_date", "x_base_date");
+static GraphValuesConverter graph_curve_x_date_offset("graph_curve_x_date_offset", "x_date_offset");
+static GraphValuesConverter graph_curve_y_base_date("graph_curve_y_base_date", "y_base_date");
+static GraphValuesConverter graph_curve_y_date_offset("graph_curve_y_date_offset", "y_date_offset");
+
+static GraphValuesConverter graph_curve2_x_values("graph_curve2_x_values", "x2_values");
+static GraphValuesConverter graph_curve2_y_values("graph_curve2_y_values", "y2_values");
+static GraphValuesConverter graph_curve2_date_x_values("graph_curve2_date_x_values", "x2_date_values");
+static GraphValuesConverter graph_curve2_date_y_values("graph_curve2_date_y_values", "y2_date_values");
+static  ValuesConverter symbol_input_text_list("symbol_input_text_list", "symbol_texts");
+static  ValuesConverter contour_hilo_text_blanking("contour_hilo_text_blanking", "contour_hilo_blanking");
+static GraphValuesConverter graph_bar_x_values("graph_bar_x_values", "x_values");
+static GraphValuesConverter graph_bar_y_values("graph_bar_y_values", "y_values");
+static GraphValuesConverter graph_bar_date_x_values("graph_bar_date_x_values", "x_date_values");
+static GraphValuesConverter graph_bar_date_y_values("graph_bar_date_y_values", "y_date_values");
+
+static GraphValuesConverter graph_bar_x_lower_values("graph_bar_x_lower_values", "x_lower_values");
+static GraphValuesConverter graph_bar_x_upper_values("graph_bar_x_upper_values", "x_upper_values");
+static GraphValuesConverter graph_bar_date_x_lower_values("graph_bar_date_x_lower_values", "x_lower_date_values");
+static GraphValuesConverter graph_bar_date_x_upper_values("graph_bar_date_x_upper_values", "x_upper_date_values");
+
+static GraphValuesConverter graph_bar_y_lower_values("graph_bar_y_lower_values", "y_lower_values");
+static GraphValuesConverter graph_bar_y_upper_values("graph_bar_y_upper_values", "y_upper_values");
+static GraphValuesConverter graph_bar_date_y_lower_values("graph_bar_date_y_lower_values", "y_lower_date_values");
+static GraphValuesConverter graph_bar_date_y_upper_values("graph_bar_date_y_upper_values", "y_upper_date_values");
+
+
+/*! \brief Converts device_file_name into output_file_root_name.
+
+  The convention to describe filenames in Magics++ has changed.
+*/
+class DeviceFileName: public CompatibilityHelper {
+public :
+	DeviceFileName() : CompatibilityHelper("device_file_name") {}
+	~DeviceFileName() {}
+	bool operator()(const string& file)
+	{
+		MagLog::info() << "Compatibility issue: Parameter device_file_name is deprecated.\n"
+		            << "               Please use output_name instead."<<endl;
+		ParameterManager::set("output_legacy_name", file);
+		ParameterManager::set("output_file_minimal_width", 0);  
+		return true;
+	}
+};
+
+/*! \brief Converts device_width into output_width.
+
+  The convention to describe filenames in Magics++ has changed.
+*/
+class DeviceWidth: public CompatibilityHelper {
+public :
+	DeviceWidth() : CompatibilityHelper("device_width") {}
+	~DeviceWidth() {}
+	bool operator()(const int width)
+	{
+		MagLog::info() << "Compatibility issue: Parameter device_width is deprecated.\n"
+		               << "             Please use output_width instead."<<endl;
+		ParameterManager::set("output_width", width);
+		return true;
+	}
+};
+
+/*! \brief Converts device_ into output_width.
+
+  The convention to describe filenames in Magics++ has changed.
+*/
+class DeviceQualityLevel: public CompatibilityHelper {
+public :
+	DeviceQualityLevel() : CompatibilityHelper("device_quality_level") {}
+	~DeviceQualityLevel() {}
+	bool operator()(const int quality)
+	{
+		MagLog::info() << "Compatibility issue: Parameter device_quality_level is deprecated.\n"
+		               << "             Please use output_jpg_quality instead."<<endl;
+		ParameterManager::set("output_jpg_quality", quality);
+		return true;
+	}
+};
+
+/*! \brief Converts text_quality into text_font and text_font_style.
+
+*/
+class TextQuality: public CompatibilityHelper {
+public :
+	TextQuality(const string& base = "") : CompatibilityHelper() {
+		base_ = ( base.empty() ) ? "" : base + "_";
+		set(base_ + "quality");
+	}
+	~TextQuality() {}
+	bool operator()(const string& quality)
+	{
+		MagLog::info() << "Compatibility issue: Parameter " << base_ << "quality is deprecated.\n"
+		            << "               Please use " << base_ << "font and " << base_ << "font_style instead."<<endl;
+
+		if(magCompare(quality,"low") )
+		{
+			ParameterManager::set(base_ +"font","serif");
+			ParameterManager::set(base_ +"font_style","normal");
+		}
+		else if(magCompare(quality,"medium") )
+		{
+			ParameterManager::set(base_ +"font", "sansserif");
+			ParameterManager::set(base_ +"font_style","normal");
+		}
+		else if(magCompare(quality,"high") )
+		{
+			ParameterManager::set(base_ +"font","sansserif");
+			ParameterManager::set(base_ +"font_style", "bold");
+		}
+		else
+		{
+			MagLog::warning()<<"The setting "<<quality<<" for the parameter " << base_ << "_quality is not valid! Default font is used."<<endl;
+			ParameterManager::set(base_ +"font", "sansserif");
+			ParameterManager::set(base_ + "font_style", "normal");
+		}
+
+		return true;
+	}
+protected:
+	string base_;
+};
+
+
+
+class TextHeight: public CompatibilityHelper {
+public :
+	TextHeight(const string& from, const string& to) : CompatibilityHelper(from), from_(from), to_(to) {}
+	~TextHeight() {}
+	bool operator()(double height)
+	{
+		MagLog::warning() << "Compatibility issue: Parameter " << from_ << " is deprecated.\n"
+		               << "               Please use " << to_ << " instead. " << to_ << " has been set to "<<height<<endl;
+		ParameterManager::set(to_, height);
+		return true;
+	}	
+	
+protected: 
+	string from_;
+	string to_;
+};
+class TextFontHeight: public CompatibilityHelper {
+public :
+	TextFontHeight(const string& from, const string& to) : CompatibilityHelper(from), from_(from), to_(to) {}
+	~TextFontHeight() {}
+	bool operator()(double height)
+	{
+		if (from_ != to_ ) {
+			MagLog::info() << "Compatibility issue: Parameter " << from_ << " is deprecated.\n"
+		               << "               Please use " << to_ << " instead. " << to_ << " has been set to "<<height<<endl;
+		}
+		else {
+			MagLog::info() << from_ << " is now expecting a string : consider to change your setting for psetc " << endl;
+		}
+		ParameterManager::set(to_, tostring(height));
+		return true;
+	}	
+	bool operator()(const string& height)
+		{
+			
+			ParameterManager::set(to_, height);
+			return true;
+		}	
+	
+protected: 
+	string from_;
+	string to_;
+};
+/*! \brief Converts gd_file_name into output_file_root_name.
+
+  The convention to describe GD filenames in Magics++ has changed between version 1.1 and 1.2.
+*/
+class GdFileName: public CompatibilityHelper {
+public :
+	GdFileName() : CompatibilityHelper("gd_file_name") {}
+	~GdFileName() {}
+	bool operator()(const string& file)
+	{
+		MagLog::info() << "Compatibility issue: Parameter gd_file_name is deprecated.\n"
+		            << "              Please use output_name instead."<<endl;
+		ParameterManager::set("output_legacy_name", file);
+		ParameterManager::set("output_file_minimal_width", 0); 
+		return true;
+	}
+};
+
+class SubpageMapProjectionNone: public CompatibilityHelper {
+public :
+	SubpageMapProjectionNone() : CompatibilityHelper("subpage_map_projection") {}
+	~SubpageMapProjectionNone() {}
+	bool operator()(const string& projection)
+	{
+		string fix = projection;
+		if ( magCompare(projection, "none") )
+		{
+			fix="cartesian";
+			MagLog::info() << "Compatibility issue: The value [none] for Parameter subpage_map_projection is deprecated.\n"
+			               << "               Please use [cartesian] instead."<<endl;
+		}
+		ParameterManager::set("subpage_map_projection",fix);
+		return true;
+	}
+};
+
+/*! \brief 'device' is not a valid parameter anymore 
+
+   set device to gd and gf_format
+*/
+class DeviceCompatibilityHelper: public CompatibilityHelper {
+public :
+	DeviceCompatibilityHelper() : CompatibilityHelper("device") {}
+	~DeviceCompatibilityHelper() {}
+	bool operator()(const string& device)
+	{
+		MagLog::info() << "Compatibility issue: the parameter device is deprecated.\n"
+		               << "              Please use the parameter output_format instead!"<< endl;
+
+		if( magCompare(device, "jpeg") || magCompare(device, "jpg") || magCompare(device, "png") || magCompare(device, "gif")) {
+			ParameterManager::set("output_format", device);
+			return true;
+		}
+		else
+		{
+			ParameterManager::set("output_format", device);
+			return true;
+		}
+		return false;
+	}
+};
+
+class Legend: public CompatibilityHelper {
+public :
+	Legend(const string& legend) : CompatibilityHelper(legend) {}
+	~Legend() {}
+	bool operator()(const string& legend)
+	{
+		MagTranslator<string, bool> translator;
+		if ( translator(legend) == false ) {
+			ParameterManager::set("legend", "off");
+			return false;
+		}
+		MagLog::info() << "Compatibility issue: The legend is turned on!\n";	
+		ParameterManager::set("legend", "on");
+		// Act as a Action routine!...
+		magics_->plegend();
+		return false;
+	}
+};
+
+class WindArrowIndexHead: public CompatibilityHelper {
+public :
+	WindArrowIndexHead() : CompatibilityHelper("wind_arrow_head_index") {}
+	~WindArrowIndexHead() {}
+	bool operator()(int index)
+	{
+	    MagLog::info() << "Compatibility issue: Parameter wind_arrow_index_head does not exist anymore.\n"
+	                   << "            use wind_arrow_head_shape and wind_arrow_head_ratio instead." << endl;
+	    const int head_index = (int)index/10;
+	    const int ratio = index % 10;
+	    double head_ratio;
+
+	    if (ratio == 1)       head_ratio = 0.3;
+	    else if (ratio == 2)  head_ratio = 0.6;
+	    else if (ratio == 3)  head_ratio = 1.;
+	    else if (ratio == 4)  head_ratio = 1.3;
+	    else if (ratio == 5)  head_ratio = 1.6;
+	    else if (ratio == 6)  head_ratio = 2.0;
+	    else
+	    {
+	    	MagLog::warning() << "invalid ratio " << ratio << " revert to default 1." << endl;
+	    	head_ratio = 1.;
+	    }
+
+	    MagLog::info() << "  wind_arrow_head_index set to " << head_index
+	                   << "AND wind_arrow_head_ratio set to " << head_ratio << endl;
+
+	    ParameterManager::set("wind_arrow_head_shape", head_index);
+	    ParameterManager::set("wind_arrow_head_ratio", head_ratio);
+	    return true;
+	}
+};
+
+static WindArrowLegend windarrowlegend;
+static PsFileName ps_file_name;
+static GribSubareaExtraction grib_subarea_extraction;
+static GribFieldPosition grib_field_position;
+static GdFileName gd_file_name;
+static PsDevice ps_device;
+static OutputPsDevice output_ps_device;
+static PsHelp ps_help;
+static PsMetric ps_metric;
+static DeviceCompatibilityHelper device;
+static DeviceFileName device_file_name;
+static DeviceQualityLevel device_quality_level;
+static DeviceWidth device_width;
+static TextQuality text_quality("text");
+static TextQuality legend_text_quality("legend_text");
+static TextQuality axis_tick_label_quality("axis_tick_label");
+static TextQuality axis_Title_quality("axis_title");
+static TextQuality page_id_quality("page_id_line");
+static TextQuality contour_label_quality("contour_label") ;
+static WindArrowIndexHead wind_arrow_index_head;
+
+static TextFontHeight text_reference_character_height("text_reference_character_height", "text_font_size");
+static TextFontHeight text_height("text_font_size", "text_font_size");
+static TextFontHeight legend_text_font_size("legend_text_font_size", "legend_text_font_size");
+
+
+
+static SubpageMapProjectionNone subpage_map_projection_none;
+static NoMoreGribex grib_mode("grib_mode");
+static NoMoreGribex grib_product_block("grib_product_block");
+static NoMoreGribex grib_grid_block("grib_grid_block");
+static NoMoreGribex grib_output_field("grib_output_field");
+static NoMoreGribex grib_input_type("grib_input_type");
+
+static IgnoreConverter graph_position_mode("graph_position_mode");
+static IgnoreConverter axis_date_units("axis_date_units");
+static IgnoreConverter legend_entry_maximum_width("legend_entry_maximum_width");
+
+static ComingSoonConverter graph_curve_method("graph_curve_method");
+
+static IgnoreConverter graph_curve_interpolation("graph_curve_interpolation");
+
+static GraphType graph_type;
+static Legend legend("legend");
+
+
+static SimpleTranslator legend_text_height("legend_text_height", "legend_text_font_size");
+static SimpleTranslator graph_shade_colour("graph_shade_colour", "graph_bar_colour", true);
+static SimpleTranslator graph_bar_colour("graph_bar_colour", "graph_shade_colour", true);
+static SimpleTranslator subpage_map_area_definition("subpage_map_area_definition", "subpage_map_area_definition_polar", true);
+static SimpleTranslator wind_arrow_legend("wind_arrow_legend", "legend");
+#ifdef MAGICS_ODB
+static SimpleTranslator odb_latitude("odb_latitude", "odb_latitude_variable");
+static SimpleTranslator odb_longitude("odb_longitude", "odb_longitude_variable");
+static SimpleTranslator odb_y_component("odb_y_component", "odb_y_component_variable");
+static SimpleTranslator odb_x_component("odb_x_component", "odb_x_component_variable");
+static SimpleTranslator odb_x("odb_x", "odb_x_variable");
+static SimpleTranslator odb_y("odb_y", "odb_y_variable");
+static SimpleTranslator odb_value("odb_value", "odb_value_variable");
+#endif
+
+static SimpleTranslator netcdf_value_variable("netcdf_field_variable_name", "netcdf_value_variable");
+static SimpleTranslator netcdf_latitude_variable("netcdf_latitude_variable_name", "netcdf_latitude_variable");
+static SimpleTranslator netcdf_longitude_variable("netcdf_longitude_variable_name", "netcdf_longitude_variable");
+static SimpleTranslator netcdf_x_component_variable("netcdf_x_component_variable_name", "netcdf_x_component_variable");
+static SimpleTranslator netcdf_y_component_variable("netcdf_y_component_variable_name", "netcdf_y_component_variable");
+static SimpleTranslator netcdf_x_variable("netcdf_x_variable_name", "netcdf_x_variable");
+static SimpleTranslator netcdf_y_variable("netcdf_y_variable_name", "netcdf_y_variable");
+static SimpleTranslator netcdf_x_position_variable("netcdf_x_position_variable_name", "netcdf_x_variable");
+static SimpleTranslator netcdf_y_position_variable("netcdf_y_position_variable_name", "netcdf_y_variable");
+static SimpleTranslator netcdf_x2_variable_name("netcdf_x2_variable_name", "netcdf_x_auxiliary_variable");
+static SimpleTranslator graph_x_missing_value("graph_x_missing_value", "x_missing_value");
+static SimpleTranslator graph_y_missing_value("graph_y_missing_value", "y_missing_value");
+static SimpleTranslator symbol_marker("symbol_marker", "symbol_marker_index");
+
+
+extern "C" {
+
+/* **************************************************************************
+
+***
+***  Fortran 77 interface
+***
+
+****************************************************************************/
+
+void popen_()
+{
+	if (magics_ == 0) 
+		magics_ = new FortranMagics();
+	magics_->popen();
+}
+
+void pcoast_()
+{
+	magics_->pcoast();
+}
+
+void ptaylor_()
+{
+	magics_->ptaylor();
+
+}
+void pgrib_()
+{
+	magics_->pgrib();
+}
+
+void pmapgen_()
+{
+	magics_->pmapgen();
+}
+
+void ptest_()
+{
+	magics_->ptest();
+}
+
+
+void podb_()
+{
+#ifdef MAGICS_ODB
+	magics_->podb();
+#else
+	MagLog::warning() << "ODB support is NOT enabled!\n";
+#endif
+}
+
+
+void pimport_()
+{
+	magics_->pimport();
+}
+void poverlay_()
+{
+	magics_->poverlay();
+}
+void pnetcdf_()
+{
+	magics_->pnetcdf();
+}
+
+void pcont_()
+{
+	magics_->pcont();
+}
+
+void pobs_()
+{
+	magics_->pobs();
+}
+
+void praw_()
+{
+#ifdef MAGICS_NETPBM
+	MagLog::warning() << "praw->not implemented\n";  
+#else
+	MagLog::warning() << "Netpbm NOT supported!" << endl;
+#endif    
+}
+
+void pimage_()
+{
+	magics_->pimage();
+}
+
+void pplot_()
+{
+	MagLog::warning() << "pplot has no effect ... use pimport instead" << endl;
+}
+
+void pnew_(const char* name, int length)
+{
+	std::string n(name, length);
+	mag_new(n.c_str());
+}
+
+void ptext_()
+{
+    magics_->ptext();
+}
+
+void pwind_()
+{
+     magics_->pwind();
+}
+
+
+void pline_()
+{
+	magics_->pline();
+}
+
+void psymb_()
+{
+	magics_->psymb();
+}
+
+void pclose_()
+{
+	magics_->pclose();
+
+	delete magics_;
+	magics_ = 0;
+}
+
+void pact_(const char*, const char*, const char*, int, int, int)
+{
+	MagLog::dev() << "PACT will NOT be implemented!\n";    
+}
+
+void presets_() {
+
+	ParameterManager::reset();
+}
+
+void preset_(const char* name, int length)
+{
+	std::string n(name, length);
+	CompatibilityHelper::reset(n);
+	mag_reset(n.c_str());
+}
+
+void psetc_(const char* name, const char* value, int namel, int valuel)
+{
+	try {        
+		string val = string(value, valuel);
+		string::size_type index = val.find_last_not_of(" ");    
+		val = (index == string::npos) ? "" :  val.substr(0, index+1);
+		if ( CompatibilityHelper::check(string(name, namel), val) ) return;
+		ParameterManager::set(string(name, namel), val);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void pseti_(const char* name, const int* value, int namel)
+{
+	try {
+		if ( CompatibilityHelper::check(string(name, namel), int(*value)) ) return;
+		ParameterManager::set(string(name, namel), int(*value));
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void pset1i_(const char* name, const int* data, const int* dim, int length)
+{
+	std::string n(name, length);
+	mag_set1i(n.c_str(), data, *dim);
+}
+
+void pset2i_(const char* name, const int* data, const int* dim, const int* dim2, int length)
+{
+	std::string n(name, length);
+	mag_set2i(n.c_str(), data, *dim, *dim2);	    
+}
+
+void pset3i_(const char* name, const int* data, const int* dim, const int* dim2, const int* dim3, int length)
+{
+	std::string n(name, length);
+	mag_set3i(n.c_str(), data, *dim, *dim2, *dim3);	     
+}
+
+void pset1c_(const char* name, const char* value, const int *dim, int namel, int l)
+{
+    stringarray values;
+    string work(value, (*dim)*l);
+    int first =0;
+    for ( int i = 0; i < *dim; i++) {
+    	
+        // remove the  space at the end of the string
+        string val = work.substr(first, l);
+        
+        string::size_type index = val.find_last_not_of(" ");
+        if (index == string::npos)
+        	 values.push_back("");
+        else 
+        	values.push_back(val.substr(0, index+1));        
+        first += l;
+    }
+    
+    try {
+    	string n(name, namel);
+    	if ( CompatibilityHelper::check(n, values) ) return;
+        ParameterManager::set(n, values);
+    }
+    catch (MagicsException& e)
+    {
+        MagLog::error() << e << "\n";
+    }
+}
+
+
+void penqi_(const char* name, int* value, int length)
+{
+	std::string n(name, length);
+	mag_enqi(n.c_str(), value);
+}
+
+
+void penqc_(const char* name, char* value, int length, int vlength)
+{
+	
+	std::string n(name, length);
+	
+	mag_enqc( n.c_str(), value);
+	
+	
+	
+	for (int i = strlen(value); i < vlength; i++)
+		value[i]=' ';
+	
+}
+
+void ppie_()
+{
+	MagLog::warning() << "ppie-> is deprecated and will NOT be implemented.\n";   
+}
+
+
+void pgraph_()
+{
+	magics_->pgraph();
+}
+
+void paxis_()
+{
+	 magics_->paxis();
+}
+
+void pgeo_()
+{
+	magics_->pgeo();
+}
+void pinput_()
+{
+	magics_->pinput();
+}
+
+void peps_()
+{
+	MagLog::warning() << "peps-->not yet implemented\n";   
+}
+
+
+void pboxplot_()
+{
+	magics_->pboxplot();
+}
+void pwrepjson_()
+{
+	magics_->wrepjson();
+}
+void pepscloud_()
+{
+	magics_->epscloud();
+}
+
+void pepsgraph_() {
+	magics_->epsgraph();
+}
+
+void pepswave_() {
+	magics_->epswave();
+}
+
+void pepswind_()
+{
+	magics_->epswind();
+}
+
+void pepsbar_()
+{
+	magics_->epsbar();
+}
+
+void pepsshading_()
+{
+	magics_->epsshading();
+}
+
+void pprint_()
+{
+	MagLog::warning() << "pprint-->not yet implemented\n";
+}
+
+void pinfo_(){mag_info();}
+
+
+/* **************************************************************************
+
+***
+***  C interface  ( calling Fortran 90 interface above )
+***
+
+****************************************************************************/
+void mag_open()  {popen_();}
+void mag_close() {pclose_();}
+void mag_coast() {pcoast_();}
+void mag_grib()  {pgrib_();}
+void mag_mapgen()  {pmapgen_();}
+void mag_line()  {pline_();}
+void mag_legend()  {magics_->simplelegend();}
+void mag_test()  {ptest_();}
+void mag_odb()   {podb_();}
+void mag_import(){pimport_();}
+void mag_overlay(){poverlay_();}
+void mag_netcdf(){pnetcdf_();}
+void mag_cont()  {pcont_();}
+void mag_input()  {pinput_();}
+void mag_obs()   {pobs_();}
+void mag_raw()   {praw_();}
+void mag_image() {pimage_();}
+void mag_plot()  {pplot_();}
+void mag_text()	 {ptext_();}
+void mag_wind()  {pwind_();}
+void mag_symb()  {psymb_();}
+void mag_boxplot()  {pboxplot_();}
+void mag_taylor()  {ptaylor_();}
+
+void mag_wrepjson()  { pwrepjson_(); }
+void mag_epscloud()  { pepscloud_(); }
+
+void mag_epsgraph()  	   { pepsgraph_(); }
+void mag_epswave()       { pepswave_(); }
+void mag_epswind()       { pepswind_(); }
+void mag_epsbar()        { pepsbar_(); }
+void mag_epsshading()    { pepsshading_(); }
+
+void mag_new(const char* page)
+{
+	magics_->pnew(page);
+}
+
+void mag_reset(const char* name)
+{
+	try {
+		ParameterManager::reset(name);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}	
+}
+
+void mag_setc(const char* name, const char* value)
+{
+	string n(name);
+	string v(value);
+	psetc_(n.c_str(), value, n.size(), v.size());
+}
+
+void mag_setr(const char* name, const double value)
+{
+	std::string n(name);
+
+	try {
+		if ( CompatibilityHelper::check(n, value) ) return;
+		ParameterManager::set(n, value);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void mag_seti(const char* name, const int value)
+{
+	string n(name);
+	pseti_(name, &value, n.size());
+}
+
+void mag_setp(const char* name, void* value)
+{
+	string n(name);
+#ifdef MAGICS_CAIRO
+    if ( magCompare(n, "output_cairo_drawing_context") ) {
+       ParameterManager::set("output_cairo_drawing_context", (CairoPtr)value); 
+    }
+#endif
+#ifdef MAGICS_QT
+    if ( magCompare(n, "output_qt_widget") ) {
+       ParameterManager::set("output_qt_widget", (QWidgetPtr)value); 
+    }
+    if ( magCompare(n, "output_qt_scene") ) {
+       ParameterManager::set("output_qt_scene", (QGraphicsScenePtr)value); 
+    }	
+#endif
+}
+
+void mag_act(const char* a, const char* b, const char* c)
+{
+	string aa(a);
+	string bb(b);
+	string cc(c);
+	pact_(a, b, c,aa.size(),bb.size(),cc.size());
+}
+
+void mag_set1r(const char* name, const double *data, const int dim1)
+{
+	std::string n(name);
+	floatarray values;
+	for ( int i = 0; i < dim1; i++) values.push_back(data[i]);        
+
+	try {
+		if ( CompatibilityHelper::check(n, values) ) return;
+		ParameterManager::set(n, values);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void mag_set2r(const char* name, const double *data, const int dim1, const int dim2)
+{
+	string param(name);
+	Matrix matrix;
+	for (int i = 0; i < (dim2) * (dim1); i++) {
+	  matrix.push_back(data[i]);
+	}
+
+	matrix.set(dim2, dim1);
+
+	try {
+		if ( CompatibilityHelper::check(param, matrix) ) return;
+		ParameterManager::set(param, matrix);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+	MagLog::dev() << "Parameter " << string(name) << " set to " << matrix << "\n";
+}
+
+void mag_set3r(const char*, const double *, const int, const int, const int)
+{
+	MagLog::warning() << "pset3r --> not yet implemented\n";
+}
+
+void mag_set1i(const char* name, const int *data, const int dim1)
+{
+	std::string param(name);
+	intarray values;
+	for ( int i = 0; i < dim1; i++) values.push_back(data[i]);        
+
+	try {
+		if ( CompatibilityHelper::check(param, values) ) return;
+		ParameterManager::set(param, values);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void mag_set2i(const char* name, const int *data, const int dim1, const int dim2)
+{
+	string param(name);
+	Matrix matrix;
+	for (int i = 0; i < (dim2) * (dim1); i++) matrix.push_back(data[i]);
+
+	matrix.set(dim2, dim1);
+	try {
+			if ( CompatibilityHelper::check( param, matrix) ) return;
+			ParameterManager::set(param, matrix);
+		}
+		catch (MagicsException& e)
+		{
+			MagLog::error() << e << "\n";
+		}
+	MagLog::dev() << "Parameter " << param << " set to " << matrix << "\n";
+}
+
+void mag_set3i(const char* , const int *, const int , const int , const int )
+{
+	MagLog::warning() << "pset3i --> not yet implemented\n";
+}
+
+void mag_set1c(const char* name, const char** data, const int dim)
+{
+	string param(name);
+
+//	MagLog::dev() << "entry in the new mag_set1c\n";    
+//	MagLog::dev() << "\tmag_set1c("  << dim << " entries);\n";
+	stringarray values;
+
+	for ( int i = 0; i < dim; i++)
+	{
+		string work (data[i]);
+		// remove the space at the start and end of the string
+
+		string::size_type index1 = work.find_first_not_of(" ");
+		string::size_type index2 = work.find_last_not_of(" ");
+		string val =  (index1 == string::npos || index2 == string::npos) ? "" : work.substr(index1, index2+1);
+		values.push_back(val);        
+	}
+    
+	try {
+		if ( CompatibilityHelper::check(param, values) ) return;
+		ParameterManager::set(param, values);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void mag_enqr(const char* fname, double *value)
+{
+	string name(fname);
+	vector<string> special;
+	special.push_back("subpage_x_position");
+	special.push_back("subpage_y_position");
+	special.push_back("subpage_x_length");
+	special.push_back("subpage_y_length");
+	// parameters needs magics to get reday! 
+
+	 string projection;
+	 
+	 ParameterManager::get("subpage_map_projection", projection);
+
+	for (vector<string>::iterator param = special.begin(); param != special.end(); ++param)  
+		if (magCompare(name, *param) ) {
+			double val;
+			ParameterManager::get(name,val);
+			if ( !magCompare(projection, "cartesian")  )  {
+				magics_->prepare();
+		 		name  = name + "_internal";	
+			}
+		}
+	double magics;
+	ParameterManager::get(name,magics);
+	*value=magics;
+	 MagLog::dev() << "mag_enqr->" << name << " = " << magics << endl;
+}
+
+
+void mag_enqi(const char* name, int *value)
+{
+	int magics;
+	ParameterManager::get(string(name),magics);
+	*value=magics;
+}
+
+void mag_enqc(const char* name, char* value)
+{
+	string magics;
+	ParameterManager::get(string(name),magics);
+	strcpy( value, magics.c_str() );
+}
+
+
+void mag_pie()   {ppie_();}
+void mag_graph() {pgraph_();}
+void mag_axis()  {paxis_();}
+void mag_geo()   {pgeo_();}
+void mag_eps()   {peps_();}
+void mag_print() {pprint_();}
+
+void mag_info()
+{
+	MagLog::userInfo() << "INFO:\n"
+		<< "INFO: "<<getMagicsVersionString()<<"\n"
+		<< "INFO:\n"
+		<< "INFO: Machine: "<<getEnvVariable("HOSTNAME")<<" is running "<<getEnvVariable("VENDOR")<<" "<<getEnvVariable("OSTYPE")<<" "<<getEnvVariable("MACHTYPE")<<"\n"
+		<< "INFO:\n"
+		<< "INFO: $MAGPLUS_HOME    = "<<getEnvVariable("MAGPLUS_HOME")<<"\n"
+		<< "INFO: $TMPDIR          = "<<getEnvVariable("TMPDIR")<<"\n"
+		<< "INFO: $ODB_LIBS        = "<<getEnvVariable("ODB_LIBS")<<"\n"
+		<< "INFO: $LD_LIBRARY_PATH = "<<getEnvVariable("LD_LIBRARY_PATH")<<"\n"
+		<< "INFO:\n";
+}
+
+}// end of extern "C"
+
+MagicsParameter<double> paxis_min_value("axis_min_value", 0);
+MagicsParameter<double> paxis_max_value("axis_max_value", 100);
+MagicsParameter<string> pgraph_axis_control("graph_axis_control", "off");
+MagicsParameter<string> paxis_date_max_value("axis_date_max_value", "");
+MagicsParameter<string> paxis_date_min_value("axis_date_min_value", "");
+
+class AxisConverter : public CompatibilityHelper
+{
+public:
+	AxisConverter(const string& from, const string& horiz, const string& vert) :
+		CompatibilityHelper(from), from_(from), vertical_(vert), horizontal_(horiz) {}
+	
+	bool operator()(double val)
+	{
+		ParameterManager::set(from_, val);
+
+		update(val);
+
+		return false;
+	}
+
+	template <class T>
+	void update(T val)
+	{
+		string orientation;
+		ParameterManager::get("axis_orientation", orientation);
+		
+
+		if ( magCompare(orientation, "horizontal") )
+		{
+			ParameterManager::set(horizontal_, val);
+		}
+		else
+		{
+			ParameterManager::set(vertical_, val);
+
+		}
+	}
+
+	void update(const string& val)
+	{
+			string orientation;
+			ParameterManager::get("axis_orientation", orientation);
+
+
+			if ( magCompare(orientation, "horizontal") )
+			{
+				if (magCompare(val, "position_list") ){
+					MagLog::warning() << "position_list is now using the user coordinates system and not cm" << endl;
+					MagLog::warning() << "please check your coordinates system" << endl;
+					ParameterManager::set(vertical_, "regular");
+				}
+				else
+					ParameterManager::set(horizontal_, val);
+			}
+			else
+			{
+				if (magCompare(val, "position_list") ){
+					MagLog::warning() << "position_list is now using the user coordinates system and not cm" << endl;
+					MagLog::warning() << "please check your coordinates system" << endl;
+					ParameterManager::set(vertical_, "regular");
+				}
+				else
+					ParameterManager::set(vertical_, val);
+
+			}
+		}
+
+	bool operator()(const string& value)
+	{
+		ParameterManager::set(from_, value);
+		update(value);
+		return false;
+	}
+protected:
+	string from_;
+	string horizontal_;
+	string vertical_;
+};
+
+
+static AxisConverter axis_type("axis_type", "subpage_x_axis_type", "subpage_y_axis_type");
+
+
+static AxisConverter axis_min_value("axis_min_value", "subpage_x_min", "subpage_y_min");
+static AxisConverter axis_max_value("axis_max_value", "subpage_x_max", "subpage_y_max");
+static AxisConverter axis_min_date_value("axis_date_min_value", "subpage_x_date_min", "subpage_y_date_min");
+static AxisConverter axis_max_date_value("axis_date_max_value", "subpage_x_date_max", "subpage_y_date_max");
+static AxisConverter graph_axis_control("graph_axis_control", "subpage_x_automatic", "subpage_y_automatic");
+
+void execute_magml(const char* file)
+{
+	WebInterpretor::magml(file);
+}
+
+void execute_json(const char* file)
+{
+	WebInterpretor::json(file);
+}
+
+void set_param(const char* param, const char* value)
+{
+	WebInterpretor::set(param, value);
+}
+
+static ActionInterceptor symbol_input_x_position("symbol_input_x_position", &FortranMagics::flagInputSymbol);
+static ActionInterceptor symbol_input_y_position("symbol_input_y_position", &FortranMagics::flagInputSymbol);
+static ActionInterceptor symbol_input_wind_direction("symbol_input_wind_direction", &FortranMagics::flagInputSymbol);
+static ActionInterceptor symbol_input_wind_speed("symbol_input_wind_speed", &FortranMagics::flagInputSymbol);
+
+static ActionInterceptor input_field("input_field", &FortranMagics::flagInputMatrix);
+static ActionInterceptor input_simple_field("input_simple_field", &FortranMagics::flagInputMatrix);
+static ActionInterceptor input_wind_u_component("input_wind_u_component", &FortranMagics::flagInputMatrix);
+static ActionInterceptor input_wind_v_component("input_wind_v_component", &FortranMagics::flagInputMatrix);
+static ActionInterceptor input_wind_speed("input_wind_speed", &FortranMagics::flagInputMatrix);
+static ActionInterceptor input_wind_direction("input_wind_direction", &FortranMagics::flagInputMatrix);
+
+static ActionInterceptor polyline_input_latitudes("polyline_input_latitudes", &FortranMagics::flagInputPoly);
+static ActionInterceptor polyline_input_longitudes("polyline_input_longitudes", &FortranMagics::flagInputPoly);
+static ActionInterceptor polyline_input_positions_filename("polyline_input_positions_filename", &FortranMagics::flagInputPoly);
+
+class PageIDWarning : public CompatibilityHelper
+{
+public :
+	PageIDWarning() : CompatibilityHelper("page_id_line_logo_plot"){}
+	~PageIDWarning() {}
+	bool operator()(const string& val)
+	{
+		if ( magCompare(val, "user" ) ){
+			MagLog::warning() << "The value user for page_id_line_logo_plot is now deprecated.\n"
+			                  << "               Please use pimport to add your own logo."<< endl;
+			ParameterManager::set("page_id_line_logo_plot", "off");
+		}
+		else
+			ParameterManager::set("page_id_line_logo_plot", val);
+		return true;
+	}
+};
+static PageIDWarning page_id_line_logo_plot;
+static CoastlinesResolution map_coastline_resolution;
diff --git a/src/common/MagicsFormat.cc b/src/common/MagicsFormat.cc
new file mode 100644
index 0000000..da14237
--- /dev/null
+++ b/src/common/MagicsFormat.cc
@@ -0,0 +1,304 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include "MagicsFormat.h"
+#include <ios>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <MagLog.h>
+
+using namespace std;
+using namespace magics;
+
+bool MagicsFormat::valid(ostream& out) const
+{
+	if ( magCompare(format_, "(automatic)") || magCompare(format_, "automatic" ) )
+	{
+		char bufr[256];
+		double trVal=trunc(value_);
+		if(value_ == trVal  &&  static_cast<double>(static_cast<int>(trVal)) == trVal)
+		{
+			sprintf(bufr, "%d", static_cast<int>(trVal));
+		}
+		else
+		{
+		  	sprintf(bufr, "%g", value_);
+		}	
+			
+		out << bufr; 
+		return true;
+	}
+    
+	string print =  "%g";
+	string flags;
+	string width;
+	string precision;
+	string specifier = "g";
+	string:: const_iterator c = format_.begin();
+
+	int state = 0;
+	bool valid = true;
+	int space = 0;
+
+	while (c != format_.end() && valid)
+	{
+		switch (state)
+		{
+			case 0 :
+				if (*c == '(') {
+					state = 1;
+					break;
+				}
+			case 1 : 
+				switch (*c) {
+					case 'B':
+					case 'b': state = 3; break; // Wait n/z
+					case 'S': 
+					case 's': state = 4; break; // Wait p
+					case 'E':
+					case 'e': state = 5; break; // Wait number
+					case 'G':
+					case 'g': state = 6; break; // Wait number
+					case 'I':
+					case 'i': state = 7; break; // Wait number
+					case 'F': 
+					case 'f': state = 8; break; // Wait number
+					default:
+						if ( isdigit(*c) ) {
+							state = 2; // Wait X								
+							space = atoi(&(*c));						
+						}
+						else valid = false;
+						break;
+					}
+				break;
+			 case 2 : // Format ---> nX Specifies that "n" spaces will appear in the output field.
+			 	if ( isdigit(*c) ) break;
+				switch (*c) {						
+					case 'X': 	
+					case 'x': 
+					          for ( int i = 0; i < space; i++) out << " ";
+						      state = 1;
+						      MagLog::debug() << state << endl;
+					          break;						
+					default:
+					    valid=false;
+						break;
+					}
+					break;
+			  case 3 : // Format BN Leading blank in an numerical output are removed
+			  	 switch (*c) {
+					case 'N':
+					case 'n': 
+						
+						//out.left; 
+						state = 1; 
+						break;
+					case 'Z':
+					case 'z': 
+					    
+						//out.right(); 
+						state = 1; 
+						break; 
+					default :
+						valid = false;
+						break;
+				 }
+				break;
+			   case 5 : // Format Ew.d[E.e] Plots real values in exponential form.				
+				 specifier = "e";
+				 if (isdigit(*c) ) {
+					 width = tostring( atoi(&(*c))); 
+					state = 51;
+					break;
+				 }					
+				 valid = false;
+				 break;
+				case 51 : // Format Ew.d[E.e] Waiting for a . 
+					if (isdigit(*c) ) break;
+					if (*c == '.') {
+						state = 52;
+						break;
+					}
+					if ( *c == 'E' || *c == 'e') {
+						state = 54;
+						break;
+					}
+					if ( *c == '(') {
+						state = 101;
+						break;
+					}
+					valid=false;
+					break;
+				case 52 : // // Format Ew.d[E.e] Waiting for a number d
+					if (isdigit(*c) ) {
+						out.precision(atoi(&(*c)));
+						state = 53;
+						break;
+					}
+					valid = false;
+					break;
+				case 53 : // Format Ew.d[E.e] Waiting for a E or for the end of the format!
+					if (isdigit(*c) ) break; 
+					if ( *c == 'E' || *c == 'e') {
+						state = 54;
+						break;
+					}
+					if ( *c == '(') {
+						state = 101;
+						break;
+					}
+					valid = false;
+				 	break;
+				 case 54 : // Format Ew.d[E.e] Waiting for a number e
+				 	 if (isdigit(*c) ) {
+					
+						state = 100;
+						break;
+					}
+					valid = false;
+					break;
+					
+				case 6 : // Format Gw.d[Ee]
+			    
+			  	 out << scientific;
+				 if (isdigit(*c) ) {
+				    // to d
+					state = 9;
+					break;
+				 }
+				 valid = false;
+				 break;
+			    case 7 : // Format Iw[.m]
+			    	specifier ="d";
+			     
+				 if (isdigit(*c) ) {
+					  width = tostring( atoi(&(*c))); 
+					state = 71;
+					break;
+				 }
+				 valid = false;
+				 break;
+				case 71 : // Format Iw[.m] -->Wait for a .
+					if ( *c == '.') { 
+						
+						state = 72;
+						break;
+					}
+					if ( *c == ')') {
+						// set the width.
+						char bufr[256];
+						string print = "%" + width + precision + specifier;
+						sprintf(bufr, print.c_str(), int(value_));
+						out << bufr; 
+						break;
+					}
+					valid = false;
+				 	break;
+				 case 72 : // Format Iw[.m] -->Wait for a number m [the least number of digits in the field] 
+					specifier = "i";
+					 
+					 if (isdigit(*c) ) {
+						 precision =  "." + tostring( atoi(&(*c)));
+						state = 100;
+						break;
+					 }				
+				
+				     state = 100;
+				 	valid = false;
+				 	break;
+				 case 100 : // Wait for a ) to finish the format
+				  	if (isdigit(*c) ) break;
+				  	if ( *c == ')' ) {
+				    	// set the width.
+				  		char bufr[256];
+				  			string print = "%" + width + precision + specifier;
+				  			
+				  			sprintf(bufr, print.c_str(), value_);
+				  			
+				  			out << bufr; 
+				  			
+						state = 102;
+						break;
+				 	}
+				 	valid = false;
+				 	break;
+				 case 102 :
+					 break;
+				 case 101 :
+				 	valid = false;
+				 	break;
+
+                case 8: // Format F(w.d)           
+                    specifier = "f";
+
+                    if (isdigit(*c) ) {
+					    width = tostring( atoi(&(*c))); 
+					    state = 81;
+					    break;
+				    }
+                    valid=false;
+                    break;
+			    case 81 : // Format  F(w.d) wait for a .
+			    	if (isdigit(*c) ) break;
+					if ( *c == '.' ) {     
+				       state = 82;
+				       break;
+					}
+					if ( *c == ')' ) {
+						state = 101;
+						break;
+				 	}
+					valid = false;
+					break;
+		    case 82: 
+		    	if ( isdigit(*c) )
+			{
+		    		precision =  "." + tostring( atoi(&(*c)));
+		    		state =100;
+		    		break;
+		    	}
+		    	if ( *c == ')' )
+			{ 
+				state = 101;
+				break;
+			}
+			default: 
+				break;
+		}
+		c++;
+	}
+	return valid;
+}
+
+ostream& MagicsFormat::format(ostream& out) const
+{
+	//MagLog::debug() << "MAGICS FORMAT to APPLY --->" << format_ << "=====";
+	if ( !valid(out) ) { 
+		MagLog::warning() << " Format \"" << format_ << "\" is not valid: will be reset to automatic " << endl; 
+		return out;
+	}
+	//out.width(20);
+	//out << scientific; // exposant
+	//out << showpos; // sign +
+	//out << fixed;
+	//out.width(8); 
+	//out.precision(3); // nombre apres la virgule
+	return out;
+}
diff --git a/src/common/MagicsFormat.h b/src/common/MagicsFormat.h
new file mode 100644
index 0000000..d447a34
--- /dev/null
+++ b/src/common/MagicsFormat.h
@@ -0,0 +1,47 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+#ifndef MagicsFormat_H
+#define MagicsFormat_H
+#include "magics.h"
+
+
+namespace magics {
+
+class MagicsFormat 
+{
+public:
+	MagicsFormat(const string& format,double value) : format_(format), value_(value) {}
+	virtual ~MagicsFormat() {}	
+	bool valid(ostream& out) const;
+
+    virtual ostream& format(ostream& out) const;
+	
+	
+		
+	friend  ostream& operator <<(ostream& out, const MagicsFormat& manip) 
+	{ 		
+		return manip.format(out);
+	}
+	string format_;
+	double value_;
+};
+
+
+}
+
+#endif
diff --git a/src/common/MagicsParameter.cc b/src/common/MagicsParameter.cc
new file mode 100644
index 0000000..f7f7d41
--- /dev/null
+++ b/src/common/MagicsParameter.cc
@@ -0,0 +1,35 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File MagicsParameter.cc
+// Magics Team - ECMWF 2004
+
+
+#include "MagicsParameter.h"
+
+using namespace magics;
+
+
+
+
+template <class T>	
+void MagicsParameter<T>::print(ostream& out)  const
+{
+	out << name_ << "[" << value_ << ", " << default_ << "]";
+}
+
diff --git a/src/common/MagicsParameter.h b/src/common/MagicsParameter.h
new file mode 100644
index 0000000..e535a99
--- /dev/null
+++ b/src/common/MagicsParameter.h
@@ -0,0 +1,91 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagicsParameter.h
+    \brief Definition of the MagicsParameter template class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+    Changes:
+
+*/
+#ifndef MagicsParameter_H
+#define MagicsParameter_H
+
+#include <magics.h>
+#include <BaseParameter.h>
+#include <MagLog.h>
+
+namespace magics {
+
+template <class T>
+class MagicsParameter: public BaseParameter
+{
+public:
+	MagicsParameter(const string& name, const T& def, const string& migration = "") :
+        BaseParameter(name), default_(def), global_(def), local_(def), migration_(migration) { }
+
+	~MagicsParameter() {}
+
+	void get(T& value) const { value = local_; }
+	void reset() { global_ = local_ =  default_; }
+	
+	BaseParameter* clone() { return new MagicsParameter<T>(this->name_, this->default_);  }
+	
+	string type() const  { return getType(default_); }
+
+	void set(const T& value)
+	{
+		global_ = local_ = value;		
+		MagLog::info() << " Parameter " << name_  << " set to " << global_<< "\n";
+		           
+	}
+	void setLocal(const BaseParameter* from)
+	{
+		    
+			from->get(local_); 
+			MagLog::debug() << " Parameter (local) " << name_  << " set to " << local_<< "\n";
+	}
+	void resetLocal()
+	{
+			local_ = global_; 
+			MagLog::debug() << " Parameter (local) " << name_  << "reset\n";
+	}
+
+protected:
+	void print(ostream& out) const 
+		{ out << name_ << "[" << global_ << ", " << local_ << ", " << default_ << "]"; }
+	T default_;
+	T global_;
+	T local_;
+	string migration_;
+
+private:
+// No copy allowed
+	MagicsParameter(const MagicsParameter<T>&);
+	MagicsParameter& operator=(const MagicsParameter&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const MagicsParameter<T>& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/MagicsSingleton.h b/src/common/MagicsSingleton.h
new file mode 100644
index 0000000..3f3b331
--- /dev/null
+++ b/src/common/MagicsSingleton.h
@@ -0,0 +1,253 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file MagicsSingleton.h
+
+    \brief Definition of ...
+
+    Magics Team - ECMWF 2006
+
+    Started: Wed 27-Oct-2006
+
+*/
+
+#ifndef MagicsSingleton_H
+#define MagicsSingleton_H
+
+#include "magics.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "Axis.h"
+#include "Timer.h"
+#include "XYList.h"
+#include "GraphPlotting.h"
+#include "EpsGraph.h"
+#include "UserPointsDecoder.h"
+#include "GribDecoder.h"
+#include "OutputHandler.h"
+#include "InputMatrix.h"
+
+#include "MagicsSingletonAttributes.h"
+
+namespace magics {
+
+class MagicsSingleton : public MagicsSingletonAttributes
+{
+	MagicsSingleton() : magics_(0), 
+		page_(false), 
+		geoTask_(0), 
+		xyTask_(0),
+		timer_("Magics processing", MagLog::info()), 
+		x_("x"), y_("y")
+	{
+		if (singleton_) return;
+		singleton_ = this;
+		magics_ = new MagicsManager();
+		output_.set(*magics_);
+		
+	}    
+	~MagicsSingleton() { MagLog::debug() << "Delete MagicsSingleton\n"; }
+	static MagicsSingleton* singleton_;
+
+public:
+	static PlotManager& manager() 
+	{
+		if (!singleton_) new MagicsSingleton();
+		return *(singleton_->layout_);
+	}
+
+	static void checkPage()
+	{
+		if (!singleton_) new MagicsSingleton();
+		singleton_->layout_->check(*(singleton_->magics_));
+	}
+
+	static void execute() 
+	{
+		assert(singleton_);
+		MagLog::dev() << "Execute --->" << *(singleton_->magics_->root()) << "\n";
+		singleton_->magics_->execute();
+	}
+
+	static VisualTask<UserPoint>* getGeoTask()
+	{
+		assert(singleton_);
+		return singleton_->geoTask();
+	}
+
+	static VisualTask<UserPoint>* getXYTask()
+	{
+		assert(singleton_);
+		return singleton_->xyTask();
+	}
+
+	static void close() 
+	{
+		if (!singleton_) new MagicsSingleton();
+		MagLog::dev() << "Close --->" << *(singleton_->magics_->root()) << "\n";
+		singleton_->magics_->execute();
+		singleton_->magics_->close();
+		delete singleton_;
+		singleton_ = 0;
+	}
+
+	static void createTask(Data* data) 
+	{
+		if (!singleton_) new MagicsSingleton();
+		checkPage();
+		singleton_->geoTask_ = new VisualTask<UserPoint>();
+		singleton_->layout_->add(singleton_->geoTask_);
+		singleton_->geoTask_->set(data);
+	}
+    
+	static void createTask(Data* data) 
+	{
+		if (!singleton_) new MagicsSingleton();
+		checkPage();
+		singleton_->xyTask_ = new VisualTask<UserPoint>();
+		singleton_->layout_->add(singleton_->xyTask_);
+		singleton_->xyTask_->set(data);
+	}
+	static void superpage()
+	{
+		if (!singleton_) new MagicsSingleton();
+		singleton_->layout_->superpage(*(singleton_->magics_));
+		singleton_->page_ = false;
+//		singleton_->magics_->resetRoot();
+	}
+
+	static void page()
+	{
+		if (!singleton_) new MagicsSingleton();
+		singleton_->layout_->page(*(singleton_->magics_));
+		singleton_->page_ = true;
+//		singleton_->magics_->resetRoot();
+	}
+    
+	static void subpage()
+	{
+		if (!singleton_) new MagicsSingleton();
+		singleton_->layout_->subpage(*(singleton_->magics_));
+		singleton_->page_ = true;
+//		singleton_->magics_->resetRoot();
+	}
+    
+	static void add(BaseSceneObject* object) 
+	{ 
+		singleton_->layout_->add(object); 
+	}
+
+	static void addVisualiser(Visualiser<UserPoint>* visdef) 
+	{
+		if (!singleton_) new MagicsSingleton();
+		if (!singleton_->xyTask_)
+		{ 
+			XYList* input = new XYList();        
+			MagicsSingleton::createTask(input);
+			MagLog::dev() << *input << "\n";
+			//throw MagicsException("Plotting routine called prior any Data definition--> The call is ignored");
+		}
+		singleton_->xyTask_->set(visdef);
+		singleton_->xyTask_ = 0;
+	}
+
+	static void addVisualiser(Visualiser<UserPoint>* visdef) 
+	{
+		if (!singleton_) new MagicsSingleton();
+		if (!singleton_->geoTask_)
+		{ 
+			InputMatrix* input = new InputMatrix();     
+			if (input->defined() ) {
+				MagicsSingleton::createTask(input);
+				MagLog::dev() << *input << "\n";
+			}
+			else {
+				delete input;
+				GribDecoder* grib = new GribDecoder();        
+				MagicsSingleton::createTask(grib);
+				MagLog::dev() << *grib << "\n";
+			}
+			
+			
+			//throw MagicsException("Plotting routine called prior any Data definition--> The call is ignored");
+		}
+		singleton_->geoTask_->set(visdef);
+		singleton_->geoTask_ = 0;
+	}
+	VisualTask<UserPoint>* geoTask() { return geoTask_; }
+	VisualTask<UserPoint>* xyTask() { return xyTask_; }
+	static bool xIsDate() { 
+		if (!singleton_) new MagicsSingleton(); 
+		return (singleton_->x_ == "date"); 
+	}
+	static bool yIsDate() { 
+		if (!singleton_) new MagicsSingleton(); 
+		return (singleton_->y_ == "date"); 
+	}
+	static void xIsDate(bool date) { 
+		if (!singleton_) new MagicsSingleton(); 
+		singleton_->x_ = date  ? "date" : "x"; 
+	}
+	static void yIsDate(bool date) { 
+		if (!singleton_) new MagicsSingleton(); 
+		singleton_->y_ = date  ? "date" : "y"; 
+	}
+	static void setHorizontalAxis(HorizontalAxis* axis) { 
+		if (!singleton_) new MagicsSingleton(); 
+		singleton_->haxis_ = axis; 
+	}
+	static void setVerticalAxis(VerticalAxis* axis) { 
+		if (!singleton_) new MagicsSingleton(); 
+		singleton_->vaxis_ = axis; 
+	}
+	
+	static bool isCartesianSystem() {
+		
+		return singleton_->haxis_ && singleton_->vaxis_; 
+		
+	}
+	
+	static void setCartesianSystem() {
+		checkPage();
+		if (singleton_->haxis_) {
+			add(singleton_->haxis_);
+			singleton_->haxis_ = 0;
+		}
+		if (singleton_->vaxis_) {
+			add(singleton_->vaxis_);
+			singleton_->vaxis_ = 0;
+		}
+		
+	}
+protected :
+	MagicsManager*  magics_;
+	bool 			page_;
+	bool            superpage_;
+	VisualTask<UserPoint>* geoTask_;
+	VisualTask<UserPoint>* xyTask_;
+	Timer timer_;
+	string x_;
+	string y_;
+	HorizontalAxis* haxis_;
+	VerticalAxis*   vaxis_;
+	OutputHandler   output_;
+};
+} // namespace magics
+#endif
+
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
new file mode 100644
index 0000000..374a142
--- /dev/null
+++ b/src/common/Makefile.am
@@ -0,0 +1,119 @@
+
+PROJECTION_ATTRIBUTES = GeoRectangularProjectionAttributes.cc PolarStereographicProjectionAttributes.cc TaylorProjectionAttributes.cc
+PROJECTION_SRC = GeoRectangularProjection.cc  PolarStereographicProjection.cc TaylorProjection.cc
+PROJECTION_INC = GeoRectangularProjection.h  GeoRectangularProjectionAttributes.h PolarStereographicProjection.h SatelliteProjection.h TaylorProjection.h
+
+if MAGICS_PROJ4
+PROJECTION_ATTRIBUTES += Proj4ProjectionAttributes.cc
+PROJECTION_SRC += Proj4Projection.cc 
+PROJECTION_INC += Proj4Projection.h
+endif
+
+
+noinst_LTLIBRARIES = libcommon.la
+include_H = \
+	OutputFactory.h MagLog.h \
+	BaseParameter.h Colour.h MagException.h \
+	Factory.cc Factory.h \
+	ParameterManager.h Frame.h Layout.h \
+	PaperPoint.h GeoPoint.h  Tokenizer.h Node.h MagTranslator.h \
+	ImageProperties.h LogoPlotting.h \
+	ImportObject.h ImportObject.cc ColourTable.h PageID.h \
+	Transformation.h Dimension.h \
+	XmlNode.h XmlTree.h XmlReader.h BackgroundColour.h \
+	ColourTableDefinition.h ColourTableDefinitionCompute.h ColourTableDefinitionComputeInterface.h\
+	ColourTableDefinitionList.h ColourTableDefinitionListInterface.h  \
+	TableDefinition.h TableDefinitionList.h TableDefinitionListInterface.h \
+	TableDefinitionCompute.h TableDefinitionComputeInterface.h \
+	HeightTableDefinition.h LevelTableDefinition.h IntervalMap.h PaperDimension.h \
+	Matrix.h MatrixHandler.h Data.h Decoder.h \
+	BasePointsHandler.h RasterData.h  Visualiser.h CustomisedPoint.h PointsHandler.h \
+	MetaData.h \
+	Polyline.h \
+	Text.h \
+	Symbol.h \
+	BinaryObject.h \
+	Arrow.h \
+	Flag.h Flag.cc \
+	Image.h  \
+	ArrowProperties.h \
+	MagicsParameter.cc MagicsParameter.h Clipper.h LogoPlottingBase.h \
+	TableDefinitionCompute.cc  \
+	FrameBase.cc FrameBase.h \
+	TableDefinitionList.cc \
+	Coordinate.h OutputHandler.h \
+	MagFont.h FortranRootSceneNodeAttributes.h OutputHandlerAttributes.h \
+	AnimationRules.h SymbolItem.h \
+	UserPoint.h Label.h \
+	Timer.h \
+	FortranSceneNodeAttributes.h PageIDAttributes.h LogoPlottingAttributes.h UserLogoPlottingAttributes.h FortranViewNodeAttributes.h \
+	${PROJECTION_INC} CustomisedPoint.h Static.h DriverStatic.h ProgressObject.h PolyCoast.h \
+	ProgressTask.h FullPaperPoint.h \
+	BasePointsHandler.h PointsHandler.h Decoder.h Data.h \
+	Visualiser.h MatrixHandler.h \
+	Seconds.h \
+	Matrix.h Matrix.cc \
+	Path.h\
+	MagicsSingleton.h \
+	PlotManager.h \
+	Image.h  \
+	XmlReader.h XmlTree.h XmlNode.h \
+	MagicsFormat.h \
+	CartesianTransformation.h \
+	Dimension.cc \
+	XCoordinate.h YCoordinate.h marsmachine.h linux.h aix.h \
+	Thread.h MutexCond.h Mutex.h AutoLock.h ThreadControler.h Task.h MagExceptions.h ThreadSingleton.h ThreadSingleton.cc \
+	DataStats.h SciMethods.h
+
+if MAGICS_ALLHEADERS
+include_HEADERS = magics_api.h $(include_H)
+noinst_HEADERS	= $(noinst_H)
+else
+include_HEADERS = magics_api.h
+noinst_HEADERS	= $(noinst_H) $(include_H)
+endif
+
+
+ATTRIBUTES = \
+	MetaDataAttributes.cc OutputHandlerAttributes.cc \
+	FortranSceneNodeAttributes.cc FortranViewNodeAttributes.cc \
+	FortranRootSceneNodeAttributes.cc CartesianTransformationAttributes.cc \
+	LogoPlottingAttributes.cc UserLogoPlottingAttributes.cc \
+	XDateCoordinateAttributes.cc YDateCoordinateAttributes.cc \
+	XLogarithmicCoordinateAttributes.cc YLogarithmicCoordinateAttributes.cc \
+	XRegularCoordinateAttributes.cc YRegularCoordinateAttributes.cc \
+	XHyperCoordinateAttributes.cc YHyperCoordinateAttributes.cc \
+	PageIDAttributes.cc BinaryObjectAttributes.cc
+
+nodist_libcommon_la_SOURCES = ${ATTRIBUTES} ${PROJECTION_ATTRIBUTES}
+
+libcommon_la_SOURCES = \
+	${PROJECTION_SRC} \
+	Data.cc Matrix.cc MagicsCalls.cc Static.cc DriverStatic.cc MagLog.cc Colour.cc Transformation.cc MagException.cc \
+	BaseParameter.cc ParameterManager.cc   \
+	Tokenizer.cc Timer.cc Seconds.cc Label.cc \
+	ArrowProperties.cc \
+	XmlReader.cc XmlTree.cc XmlNode.cc Dimension.cc \
+	MetaData.cc \
+	MagicsFormat.cc \
+	OutputHandler.cc  OutputFactory.cc \
+	MagFont.cc \
+	ColourTable.cc ColourTableDefinitionList.cc \
+	ColourTableDefinitionCompute.cc CartesianTransformation.cc \
+	BinaryObject.cc \
+	Coordinate.cc \
+	LogoPlotting.cc \
+	PageID.cc AnimationRules.cc Layout.cc SymbolItem.cc Symbol.cc Polyline.cc \
+	Text.cc Flag.cc   \
+	Mutex.cc MutexCond.cc Thread.cc MagExceptions.cc AutoLocker.cc \
+	ThreadControler.cc Task.cc \
+	DataStats.cc SciMethods.cc BasePointsHandler.cc PointsHandler.cc
+
+    
+libcommon_la_LDFLAGS	= -no-undefined -no-install
+			
+AM_CPPFLAGS		=  ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src -I$(top_srcdir)/src/web -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/common -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders -I$(top_srcdir)/include
+
+if MAGICS_QT
+AM_CPPFLAGS += $(QT_CPPFLAGS)
+endif
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
new file mode 100644
index 0000000..ce42a72
--- /dev/null
+++ b/src/common/Makefile.in
@@ -0,0 +1,932 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_PROJ4_TRUE@am__append_1 = Proj4ProjectionAttributes.cc
+ at MAGICS_PROJ4_TRUE@am__append_2 = Proj4Projection.cc 
+ at MAGICS_PROJ4_TRUE@am__append_3 = Proj4Projection.h
+ at MAGICS_QT_TRUE@am__append_4 = $(QT_CPPFLAGS)
+subdir = src/common
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcommon_la_LIBADD =
+am__libcommon_la_SOURCES_DIST = GeoRectangularProjection.cc \
+	PolarStereographicProjection.cc TaylorProjection.cc \
+	Proj4Projection.cc Data.cc Matrix.cc MagicsCalls.cc Static.cc \
+	DriverStatic.cc MagLog.cc Colour.cc Transformation.cc \
+	MagException.cc BaseParameter.cc ParameterManager.cc \
+	Tokenizer.cc Timer.cc Seconds.cc Label.cc ArrowProperties.cc \
+	XmlReader.cc XmlTree.cc XmlNode.cc Dimension.cc MetaData.cc \
+	MagicsFormat.cc OutputHandler.cc OutputFactory.cc MagFont.cc \
+	ColourTable.cc ColourTableDefinitionList.cc \
+	ColourTableDefinitionCompute.cc CartesianTransformation.cc \
+	BinaryObject.cc Coordinate.cc LogoPlotting.cc PageID.cc \
+	AnimationRules.cc Layout.cc SymbolItem.cc Symbol.cc \
+	Polyline.cc Text.cc Flag.cc Mutex.cc MutexCond.cc Thread.cc \
+	MagExceptions.cc AutoLocker.cc ThreadControler.cc Task.cc \
+	DataStats.cc SciMethods.cc BasePointsHandler.cc \
+	PointsHandler.cc
+ at MAGICS_PROJ4_TRUE@am__objects_1 = Proj4Projection.lo
+am__objects_2 = GeoRectangularProjection.lo \
+	PolarStereographicProjection.lo TaylorProjection.lo \
+	$(am__objects_1)
+am_libcommon_la_OBJECTS = $(am__objects_2) Data.lo Matrix.lo \
+	MagicsCalls.lo Static.lo DriverStatic.lo MagLog.lo Colour.lo \
+	Transformation.lo MagException.lo BaseParameter.lo \
+	ParameterManager.lo Tokenizer.lo Timer.lo Seconds.lo Label.lo \
+	ArrowProperties.lo XmlReader.lo XmlTree.lo XmlNode.lo \
+	Dimension.lo MetaData.lo MagicsFormat.lo OutputHandler.lo \
+	OutputFactory.lo MagFont.lo ColourTable.lo \
+	ColourTableDefinitionList.lo ColourTableDefinitionCompute.lo \
+	CartesianTransformation.lo BinaryObject.lo Coordinate.lo \
+	LogoPlotting.lo PageID.lo AnimationRules.lo Layout.lo \
+	SymbolItem.lo Symbol.lo Polyline.lo Text.lo Flag.lo Mutex.lo \
+	MutexCond.lo Thread.lo MagExceptions.lo AutoLocker.lo \
+	ThreadControler.lo Task.lo DataStats.lo SciMethods.lo \
+	BasePointsHandler.lo PointsHandler.lo
+am__objects_3 = MetaDataAttributes.lo OutputHandlerAttributes.lo \
+	FortranSceneNodeAttributes.lo FortranViewNodeAttributes.lo \
+	FortranRootSceneNodeAttributes.lo \
+	CartesianTransformationAttributes.lo LogoPlottingAttributes.lo \
+	UserLogoPlottingAttributes.lo XDateCoordinateAttributes.lo \
+	YDateCoordinateAttributes.lo \
+	XLogarithmicCoordinateAttributes.lo \
+	YLogarithmicCoordinateAttributes.lo \
+	XRegularCoordinateAttributes.lo \
+	YRegularCoordinateAttributes.lo XHyperCoordinateAttributes.lo \
+	YHyperCoordinateAttributes.lo PageIDAttributes.lo \
+	BinaryObjectAttributes.lo
+ at MAGICS_PROJ4_TRUE@am__objects_4 = Proj4ProjectionAttributes.lo
+am__objects_5 = GeoRectangularProjectionAttributes.lo \
+	PolarStereographicProjectionAttributes.lo \
+	TaylorProjectionAttributes.lo $(am__objects_4)
+nodist_libcommon_la_OBJECTS = $(am__objects_3) $(am__objects_5)
+libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) \
+	$(nodist_libcommon_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libcommon_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(libcommon_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libcommon_la_SOURCES) $(nodist_libcommon_la_SOURCES)
+DIST_SOURCES = $(am__libcommon_la_SOURCES_DIST)
+am__include_HEADERS_DIST = magics_api.h OutputFactory.h MagLog.h \
+	BaseParameter.h Colour.h MagException.h Factory.cc Factory.h \
+	ParameterManager.h Frame.h Layout.h PaperPoint.h GeoPoint.h \
+	Tokenizer.h Node.h MagTranslator.h ImageProperties.h \
+	LogoPlotting.h ImportObject.h ImportObject.cc ColourTable.h \
+	PageID.h Transformation.h Dimension.h XmlNode.h XmlTree.h \
+	XmlReader.h BackgroundColour.h ColourTableDefinition.h \
+	ColourTableDefinitionCompute.h \
+	ColourTableDefinitionComputeInterface.h \
+	ColourTableDefinitionList.h \
+	ColourTableDefinitionListInterface.h TableDefinition.h \
+	TableDefinitionList.h TableDefinitionListInterface.h \
+	TableDefinitionCompute.h TableDefinitionComputeInterface.h \
+	HeightTableDefinition.h LevelTableDefinition.h IntervalMap.h \
+	PaperDimension.h Matrix.h MatrixHandler.h Data.h Decoder.h \
+	BasePointsHandler.h RasterData.h Visualiser.h \
+	CustomisedPoint.h PointsHandler.h MetaData.h Polyline.h Text.h \
+	Symbol.h BinaryObject.h Arrow.h Flag.h Flag.cc Image.h \
+	ArrowProperties.h MagicsParameter.cc MagicsParameter.h \
+	Clipper.h LogoPlottingBase.h TableDefinitionCompute.cc \
+	FrameBase.cc FrameBase.h TableDefinitionList.cc Coordinate.h \
+	OutputHandler.h MagFont.h FortranRootSceneNodeAttributes.h \
+	OutputHandlerAttributes.h AnimationRules.h SymbolItem.h \
+	UserPoint.h Label.h Timer.h FortranSceneNodeAttributes.h \
+	PageIDAttributes.h LogoPlottingAttributes.h \
+	UserLogoPlottingAttributes.h FortranViewNodeAttributes.h \
+	GeoRectangularProjection.h \
+	GeoRectangularProjectionAttributes.h \
+	PolarStereographicProjection.h SatelliteProjection.h \
+	TaylorProjection.h Proj4Projection.h Static.h DriverStatic.h \
+	ProgressObject.h PolyCoast.h ProgressTask.h FullPaperPoint.h \
+	Seconds.h Matrix.cc Path.h MagicsSingleton.h PlotManager.h \
+	MagicsFormat.h CartesianTransformation.h Dimension.cc \
+	XCoordinate.h YCoordinate.h marsmachine.h linux.h aix.h \
+	Thread.h MutexCond.h Mutex.h AutoLock.h ThreadControler.h \
+	Task.h MagExceptions.h ThreadSingleton.h ThreadSingleton.cc \
+	DataStats.h SciMethods.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = OutputFactory.h MagLog.h BaseParameter.h \
+	Colour.h MagException.h Factory.cc Factory.h \
+	ParameterManager.h Frame.h Layout.h PaperPoint.h GeoPoint.h \
+	Tokenizer.h Node.h MagTranslator.h ImageProperties.h \
+	LogoPlotting.h ImportObject.h ImportObject.cc ColourTable.h \
+	PageID.h Transformation.h Dimension.h XmlNode.h XmlTree.h \
+	XmlReader.h BackgroundColour.h ColourTableDefinition.h \
+	ColourTableDefinitionCompute.h \
+	ColourTableDefinitionComputeInterface.h \
+	ColourTableDefinitionList.h \
+	ColourTableDefinitionListInterface.h TableDefinition.h \
+	TableDefinitionList.h TableDefinitionListInterface.h \
+	TableDefinitionCompute.h TableDefinitionComputeInterface.h \
+	HeightTableDefinition.h LevelTableDefinition.h IntervalMap.h \
+	PaperDimension.h Matrix.h MatrixHandler.h Data.h Decoder.h \
+	BasePointsHandler.h RasterData.h Visualiser.h \
+	CustomisedPoint.h PointsHandler.h MetaData.h Polyline.h Text.h \
+	Symbol.h BinaryObject.h Arrow.h Flag.h Flag.cc Image.h \
+	ArrowProperties.h MagicsParameter.cc MagicsParameter.h \
+	Clipper.h LogoPlottingBase.h TableDefinitionCompute.cc \
+	FrameBase.cc FrameBase.h TableDefinitionList.cc Coordinate.h \
+	OutputHandler.h MagFont.h FortranRootSceneNodeAttributes.h \
+	OutputHandlerAttributes.h AnimationRules.h SymbolItem.h \
+	UserPoint.h Label.h Timer.h FortranSceneNodeAttributes.h \
+	PageIDAttributes.h LogoPlottingAttributes.h \
+	UserLogoPlottingAttributes.h FortranViewNodeAttributes.h \
+	GeoRectangularProjection.h \
+	GeoRectangularProjectionAttributes.h \
+	PolarStereographicProjection.h SatelliteProjection.h \
+	TaylorProjection.h Proj4Projection.h Static.h DriverStatic.h \
+	ProgressObject.h PolyCoast.h ProgressTask.h FullPaperPoint.h \
+	Seconds.h Matrix.cc Path.h MagicsSingleton.h PlotManager.h \
+	MagicsFormat.h CartesianTransformation.h Dimension.cc \
+	XCoordinate.h YCoordinate.h marsmachine.h linux.h aix.h \
+	Thread.h MutexCond.h Mutex.h AutoLock.h ThreadControler.h \
+	Task.h MagExceptions.h ThreadSingleton.h ThreadSingleton.cc \
+	DataStats.h SciMethods.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+PROJECTION_ATTRIBUTES = GeoRectangularProjectionAttributes.cc \
+	PolarStereographicProjectionAttributes.cc \
+	TaylorProjectionAttributes.cc $(am__append_1)
+PROJECTION_SRC = GeoRectangularProjection.cc \
+	PolarStereographicProjection.cc TaylorProjection.cc \
+	$(am__append_2)
+PROJECTION_INC = GeoRectangularProjection.h \
+	GeoRectangularProjectionAttributes.h \
+	PolarStereographicProjection.h SatelliteProjection.h \
+	TaylorProjection.h $(am__append_3)
+noinst_LTLIBRARIES = libcommon.la
+include_H = \
+	OutputFactory.h MagLog.h \
+	BaseParameter.h Colour.h MagException.h \
+	Factory.cc Factory.h \
+	ParameterManager.h Frame.h Layout.h \
+	PaperPoint.h GeoPoint.h  Tokenizer.h Node.h MagTranslator.h \
+	ImageProperties.h LogoPlotting.h \
+	ImportObject.h ImportObject.cc ColourTable.h PageID.h \
+	Transformation.h Dimension.h \
+	XmlNode.h XmlTree.h XmlReader.h BackgroundColour.h \
+	ColourTableDefinition.h ColourTableDefinitionCompute.h ColourTableDefinitionComputeInterface.h\
+	ColourTableDefinitionList.h ColourTableDefinitionListInterface.h  \
+	TableDefinition.h TableDefinitionList.h TableDefinitionListInterface.h \
+	TableDefinitionCompute.h TableDefinitionComputeInterface.h \
+	HeightTableDefinition.h LevelTableDefinition.h IntervalMap.h PaperDimension.h \
+	Matrix.h MatrixHandler.h Data.h Decoder.h \
+	BasePointsHandler.h RasterData.h  Visualiser.h CustomisedPoint.h PointsHandler.h \
+	MetaData.h \
+	Polyline.h \
+	Text.h \
+	Symbol.h \
+	BinaryObject.h \
+	Arrow.h \
+	Flag.h Flag.cc \
+	Image.h  \
+	ArrowProperties.h \
+	MagicsParameter.cc MagicsParameter.h Clipper.h LogoPlottingBase.h \
+	TableDefinitionCompute.cc  \
+	FrameBase.cc FrameBase.h \
+	TableDefinitionList.cc \
+	Coordinate.h OutputHandler.h \
+	MagFont.h FortranRootSceneNodeAttributes.h OutputHandlerAttributes.h \
+	AnimationRules.h SymbolItem.h \
+	UserPoint.h Label.h \
+	Timer.h \
+	FortranSceneNodeAttributes.h PageIDAttributes.h LogoPlottingAttributes.h UserLogoPlottingAttributes.h FortranViewNodeAttributes.h \
+	${PROJECTION_INC} CustomisedPoint.h Static.h DriverStatic.h ProgressObject.h PolyCoast.h \
+	ProgressTask.h FullPaperPoint.h \
+	BasePointsHandler.h PointsHandler.h Decoder.h Data.h \
+	Visualiser.h MatrixHandler.h \
+	Seconds.h \
+	Matrix.h Matrix.cc \
+	Path.h\
+	MagicsSingleton.h \
+	PlotManager.h \
+	Image.h  \
+	XmlReader.h XmlTree.h XmlNode.h \
+	MagicsFormat.h \
+	CartesianTransformation.h \
+	Dimension.cc \
+	XCoordinate.h YCoordinate.h marsmachine.h linux.h aix.h \
+	Thread.h MutexCond.h Mutex.h AutoLock.h ThreadControler.h Task.h MagExceptions.h ThreadSingleton.h ThreadSingleton.cc \
+	DataStats.h SciMethods.h
+
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = magics_api.h
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = magics_api.h $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(noinst_H) $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = $(noinst_H)
+ATTRIBUTES = \
+	MetaDataAttributes.cc OutputHandlerAttributes.cc \
+	FortranSceneNodeAttributes.cc FortranViewNodeAttributes.cc \
+	FortranRootSceneNodeAttributes.cc CartesianTransformationAttributes.cc \
+	LogoPlottingAttributes.cc UserLogoPlottingAttributes.cc \
+	XDateCoordinateAttributes.cc YDateCoordinateAttributes.cc \
+	XLogarithmicCoordinateAttributes.cc YLogarithmicCoordinateAttributes.cc \
+	XRegularCoordinateAttributes.cc YRegularCoordinateAttributes.cc \
+	XHyperCoordinateAttributes.cc YHyperCoordinateAttributes.cc \
+	PageIDAttributes.cc BinaryObjectAttributes.cc
+
+nodist_libcommon_la_SOURCES = ${ATTRIBUTES} ${PROJECTION_ATTRIBUTES}
+libcommon_la_SOURCES = \
+	${PROJECTION_SRC} \
+	Data.cc Matrix.cc MagicsCalls.cc Static.cc DriverStatic.cc MagLog.cc Colour.cc Transformation.cc MagException.cc \
+	BaseParameter.cc ParameterManager.cc   \
+	Tokenizer.cc Timer.cc Seconds.cc Label.cc \
+	ArrowProperties.cc \
+	XmlReader.cc XmlTree.cc XmlNode.cc Dimension.cc \
+	MetaData.cc \
+	MagicsFormat.cc \
+	OutputHandler.cc  OutputFactory.cc \
+	MagFont.cc \
+	ColourTable.cc ColourTableDefinitionList.cc \
+	ColourTableDefinitionCompute.cc CartesianTransformation.cc \
+	BinaryObject.cc \
+	Coordinate.cc \
+	LogoPlotting.cc \
+	PageID.cc AnimationRules.cc Layout.cc SymbolItem.cc Symbol.cc Polyline.cc \
+	Text.cc Flag.cc   \
+	Mutex.cc MutexCond.cc Thread.cc MagExceptions.cc AutoLocker.cc \
+	ThreadControler.cc Task.cc \
+	DataStats.cc SciMethods.cc BasePointsHandler.cc PointsHandler.cc
+
+libcommon_la_LDFLAGS = -no-undefined -no-install
+AM_CPPFLAGS = ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/web -I$(top_srcdir)/src/terralib/kernel \
+	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/basic \
+	-I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers \
+	-I$(top_srcdir)/src/decoders -I$(top_srcdir)/include \
+	$(am__append_4)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/common/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/common/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libcommon_la_LINK)  $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AnimationRules.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ArrowProperties.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AutoLocker.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BaseParameter.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BasePointsHandler.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinaryObject.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinaryObjectAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CartesianTransformation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CartesianTransformationAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Colour.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ColourTable.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ColourTableDefinitionCompute.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ColourTableDefinitionList.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Coordinate.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Data.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DataStats.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Dimension.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DriverStatic.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Flag.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FortranRootSceneNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FortranSceneNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FortranViewNodeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GeoRectangularProjection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GeoRectangularProjectionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Label.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Layout.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LogoPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LogoPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagException.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagExceptions.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagFont.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagLog.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagicsCalls.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagicsFormat.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Matrix.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetaData.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetaDataAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Mutex.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MutexCond.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OutputFactory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OutputHandler.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OutputHandlerAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PageID.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PageIDAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ParameterManager.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PointsHandler.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolarStereographicProjection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolarStereographicProjectionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Polyline.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4Projection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4ProjectionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SciMethods.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Seconds.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Static.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Symbol.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Task.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TaylorProjection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TaylorProjectionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Text.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Thread.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ThreadControler.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Timer.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Tokenizer.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Transformation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/UserLogoPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XDateCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XHyperCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XLogarithmicCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XRegularCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlNode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlReader.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XmlTree.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YDateCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YHyperCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YLogarithmicCoordinateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YRegularCoordinateAttributes.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/common/Matrix.cc b/src/common/Matrix.cc
new file mode 100644
index 0000000..ce2aa4c
--- /dev/null
+++ b/src/common/Matrix.cc
@@ -0,0 +1,436 @@
+
+
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ 
+ ******************************** LICENSE ********************************/
+
+/*! \file Matrix.h
+    \brief Implementation of the Template class Matrix.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "Matrix.h"
+#include "Timer.h"
+#include "SegmentJoiner.h"
+
+using namespace magics;
+
+
+
+
+void ProjectedMatrix::build()
+{
+	vector<pair<int, int>  > coords(4);
+	for (int r = 0; r < rows_; r++)
+		for (int c = 0; c < columns_; c++)
+			push_back(missing_);
+	
+	coords[0] = std::make_pair(0,0);
+	coords[1] = std::make_pair(0,1);
+	coords[2] = std::make_pair(1,1);
+	coords[3] = std::make_pair(1,0);
+	
+	Timer  t("GridHelper::build", "GridHelper");
+	for ( int row = 0 ; row < origRows_-1; row++)
+		for ( int column = 0 ; column < origColumns_-1; column++)
+		{
+			double xmin = origColumns_;
+			double xmax = 0;
+			double ymin = rows_;
+			double ymax = 0;
+			
+			vector<double> x, y, v;
+			vector<double> xs, ys, vs;
+			vector<Point> points;
+			bool stop = true;
+			
+			for (vector<pair<int, int>  >::iterator p = coords.begin(); p != coords.end(); ++p) {
+				int r = row+ p->first;
+				int c = column+ p->second;
+				double rr = rowsArray_[index(r, c)];
+				double cc = columnsArray_[index(r, c)];
+				MagLog::debug() << rr << " ? " << miny_ -  stepy_ << " " <<  maxy_ + stepy_ << endl;
+				MagLog::debug() << cc << " ? " << minx_ -  stepx_ << " " <<  maxx_ + stepx_ << endl;
+				if ( rr >= miny_ -  stepy_ && rr <= maxy_ + stepy_)
+					stop = false;
+
+				if ( cc >= minx_ -  stepx_ && cc <= maxx_ + stepx_ )
+					stop = false;
+				
+			}
+			if ( stop )
+				// Go to next cell...
+
+				continue;
+			for (vector<pair<int, int>  >::iterator p = coords.begin(); p != coords.end(); ++p) {
+				
+				int r = row+ p->first;
+				int c = column+ p->second;
+				double  rr = rowsArray_[index(r, c)];
+				double cc = columnsArray_[index(r, c)];
+				
+				
+
+				 x.push_back( (cc - minx_ ) / stepx_ );
+				 y.push_back( (rr - miny_ ) / stepy_);
+
+				 points.push_back(Point(x.back(), y.back()));
+				 v.push_back( values_[index(r, c)]);  						
+			}
+			points.push_back(points.front());
+			xmin = *std::min_element(x.begin(), x.end());
+			xmax = *std::max_element(x.begin(), x.end());
+			ymin = *std::min_element(y.begin(), y.end());
+			ymax = *std::max_element(y.begin(), y.end());
+
+			MagLog::debug() << "x------->" << xmin << " " << xmax << endl;
+			MagLog::debug() << "y------->" << ymin << " " << ymax << endl;
+			int ii = (xmin < 0) ? 0 : xmin;
+
+			while (ii <= xmax && ii < columns_ )
+			{
+				int jj = (ymin < 0) ? 0 : ymin;
+				while ( jj <= ymax && jj < rows_ ) {
+			
+					MagLog::debug() << "ii=" << 	ii << "  jj=" << jj <<  endl;
+					// is the point inside or oiutside .. if inside use it! 
+
+				    int i = 0;
+				    bool done = false;
+					for (vector<Point>::iterator pt = points.begin(); pt != points.end(); ++pt) {
+				    	MagLog::debug() << *pt << endl;
+						if ( *pt == Point(ii, jj) ) {
+							(*this)[(jj*columns_) + ii] = v[i];
+							done = true;
+				    		break;
+				    	}
+						i++;
+				    }
+					if (  !done && SegmentJoiner::pointInPoly(Point(ii, jj),  points) )
+					 {
+						//feed the matrix...
+						vector<double> w;
+						double total = 0.;
+						for (unsigned int i = 0; i < x.size(); i++) {
+							double val = sqrt( ((ii - x[i])*(ii-x[i]))  + ( (jj-y[i])*(jj-y[i]) ) );
+
+														w.push_back(1/ (val) ? (val*val) : 1);
+														if (v[i] != missing_)
+														    total += w[i];
+						}
+						
+						double val = 0.;
+						for (unsigned int i = 0; i < w.size(); i++) {
+							if (v[i] != missing_) 
+								val += (v[i]*w[i]/total);
+							}
+
+				     (*this)[(jj*columns_) + ii] = val;
+				     MagLog::debug() << "[" << ii << ", " << jj << "]=" << val << endl;
+				     MagLog::debug() << "[" << ii <<  "]=" << columnsAxis_[ii] << endl;
+				     MagLog::debug() << "[" << jj <<  "]=" << rowsAxis_[jj] << endl;
+					}else {
+						MagLog::debug() <<  "out[" << ii <<  "]=" << columnsAxis_[ii] << endl;
+				     MagLog::debug() << "out[" << jj <<  "]=" << rowsAxis_[jj] << endl;
+					}
+
+					jj++;
+				}
+				ii++;
+			}
+		}
+}
+
+void ProjectedMatrix::getReady()
+{
+	assert(!values_.empty());
+	assert(!rowsArray_.empty());
+	assert(!columnsArray_.empty());
+	
+	// find the bounding box! 
+	//columns_ = 100;
+	//rows_ = 100;
+	
+	minx_ = *std::min_element(columnsArray_.begin(), columnsArray_.end());
+	maxx_ = *std::max_element(columnsArray_.begin(), columnsArray_.end());
+	miny_ = *std::min_element(rowsArray_.begin(), rowsArray_.end());
+	maxy_ = *std::max_element(rowsArray_.begin(), rowsArray_.end());
+	
+	stepx_ = (maxx_ - minx_)/(columns_-1);
+    stepy_ = (maxy_ - miny_)/(rows_-1);
+	double x = minx_;
+	double y = miny_;
+	// Create the Axis for Regular Matrix..
+	for ( int i = 0; i < columns_; i++) {
+		columnsAxis_.push_back(x); 
+		MagLog::debug() << "x-> " << x << endl;
+		x += stepx_;
+
+	}
+	for ( int j = 0; j < rows_; j++) {
+			rowsAxis_.push_back(y); 
+			MagLog::debug() << "y-> " << y << endl;
+			y +=  stepy_;
+	}
+	setMapsAxis();
+	
+	// Now preapre the matrix! 
+	build();
+}
+
+
+ProjectedMatrix::ProjectedMatrix(int rows, int columns): Matrix(rows, columns)
+{
+	       origColumns_ = columns;
+	       origRows_ = rows;
+
+	       rowsArray_.reserve(rows*columns);  
+	       columnsArray_.reserve(rows*columns);
+}
+RotatedMatrix::RotatedMatrix(int rows, int columns): Matrix(rows, columns)
+{
+	rowsArray_.reserve(rows*columns);
+	columnsArray_.reserve(rows*columns);
+	values_.reserve(rows*columns);
+}
+
+
+
+double Matrix::min() const {
+  	 if ( min_ < DBL_MAX) 
+  		 return min_;
+  	
+  	 for ( const_iterator val = begin(); val != end(); ++val) {
+  		 if ( *val == missing_ ) continue; 
+  		 if ( *val < min_ ) min_ = *val;
+  		 if ( *val > max_ ) max_ = *val;
+  	 }
+  	 return min_;
+ }
+
+
+double Matrix::max() const
+{
+  	 if ( max_ > -DBL_MAX) 
+  		 return max_; 
+  	 
+  	  for ( const_iterator val = begin(); val != end(); ++val) {
+  	  		 if ( *val == missing_ ) continue; 
+  	  		 if ( *val < min_ ) min_ = *val;
+  	  		 if ( *val > max_ ) max_ = *val;
+  	  }
+  	 return max_;
+}
+   
+double Matrix::interpolate(double i, double j) const    
+{  
+	   double xleft = std::min( left(), right());
+	   double xright = std::max( left(), right());
+	   double ybottom = std::min( bottom(), top());
+	   double ytop = std::max( bottom(), top());
+	   
+	   if ( columns() == 0 || j < xleft || j > xright ) 
+		   return missing_;
+	   if ( i < ybottom || i > ytop ) 
+   			return missing_;
+		int ii = rowIndex(i);
+	    	if (ii == -1) {
+	    		// interpolate between 2 rows.
+	    		double v1, v2;
+	    		int i1, i2;
+	    		boundRow(i, v1, i1, v2, i2);
+	    		
+	    		if (i1 == -1) return missing(); 
+	    		
+	    	    double a = (*this).interpolate(v1, j);
+	            double b = (*this).interpolate(v2, j);
+	          
+	            if ( same(a, missing()) || same(b, missing()) ) return missing();
+	            
+	            double da = (v2-i)/(v2-v1);
+	            double db = (i-v1)/(v2-v1);
+	            double val = (a*da) + (b*db);
+	            return val;
+	        }
+	        int jj = columnIndex(j);
+	        if (jj == -1) {
+	        	double v1, v2;
+	    		int i1, i2;
+	    		boundColumn(j, v1, i1, v2, i2);
+	    		if (i1 == -1) return missing(); 
+	    		
+	        	
+	    		double a = (*this)(ii, i1);
+	            double b = (*this)(ii, i2);
+	            
+	            if ( same(a, missing()) || same(b, missing()) ) return missing();
+	            
+	            double da = (v2-j)/(v2-v1);
+	            double db = (j-v1)/(v2-v1);
+	            double val = (a*da) + (b*db);
+	            return val;         
+	   }
+	   return (*this)(ii, jj);
+}
+
+double Matrix::nearest(double row, double col,double &rowOut, double &colOut) const    
+{  
+	double xleft = std::min( left(), right());
+	double xright = std::max( left(), right());
+	double ybottom = std::min( bottom(), top());
+	double ytop = std::max( bottom(), top());
+	 
+	
+	if ( columns() == 0 || col < xleft || col > xright ) 
+		return missing_;
+	if ( columns() == 0 ||  row < ybottom || row > ytop ) 
+  		return missing_;
+	
+	double row1, row2, col1, col2;
+	int rowIdx1, rowIdx2, colIdx1, colIdx2;
+	
+	boundRow(row, row1, rowIdx1, row2, rowIdx2);   
+	if(rowIdx1 == -1 || rowIdx2 == -1)
+		return missing_;
+	
+	boundColumn(col, col1, colIdx1, col2, colIdx2);   
+	if(colIdx1 == -1 || colIdx2 == -1)
+		return missing_;
+	  
+	int rowIdx, colIdx;
+	if(fabs(row1-row) < fabs(row2-row))
+	{
+		rowOut= row1;
+		rowIdx=rowIdx1;
+	}
+	else
+	{
+	  	rowOut= row2;
+		rowIdx=rowIdx2;
+	}
+	
+	if(fabs(col1-col) < fabs(col2-col))
+	{
+		colOut= col1;
+		colIdx=colIdx1;
+	}
+	else
+	{
+	  	colOut= col2;
+		colIdx=colIdx2;
+	}
+		
+	return (*this)(rowIdx, colIdx);
+	
+}	
+
+
+double Matrix::operator()(int row, int column) const
+  {
+         // Here for perfrormance we are trusting the user we do not catch MagException
+
+				double val = (*this)[ row * columns_ + column];
+				return val;
+
+  }
+#include "MatrixHandler.h"
+GeoBoxMatrixHandler::GeoBoxMatrixHandler(const AbstractMatrix& matrix, const Transformation& transformation):
+	  TransformMatrixHandler(matrix), transformation_(transformation), original_(0)
+{
+	map<double, int> lats;
+	map<double, int> lons;
+	double lon, lat;
+	double minlon, minlat, maxlon, maxlat;
+
+	transformation.boundingBox(minlon, minlat, maxlon, maxlat);
+
+	int rows = matrix_.rows();
+	int columns = matrix_.columns();
+	double step = matrix_.XResolution();
+	bool global =  ( matrix_.regular_column(columns-1) - matrix_.regular_column(0) ) > ( 360. - 2 *matrix_.XResolution() );
+	if (!global) {
+
+		lon = matrix_.regular_column(0) - step;
+		if ( minlon <= lon && lon <= maxlon)
+				lons[lon] = -1;
+
+		double ml = lon - 360;
+		while ( ml >= minlon && ml <= maxlon ) {  lons[ml] = -1; ml -= 360; }
+		ml = lon + 360;
+		while (  ml >= minlon && ml <= maxlon ) {  lons[ml] = -1; ml += 360; }
+
+		lon = matrix_.regular_column(columns-1) + step;
+		if ( minlon <= lon && lon <= maxlon)
+				lons[lon] = -1;
+
+		ml = lon - 360;
+		while ( ml >= minlon && ml <= maxlon ) {  lons[ml] = -1; ml -= 360; }
+		ml = lon + 360;
+		while (  ml >= minlon && ml <= maxlon ) {  lons[ml] = -1; ml += 360; }
+	}
+
+
+
+	for (int i = 0; i < columns; i++)
+	{
+		lon = matrix_.regular_column(i);
+
+		if ( minlon <= lon && lon <= maxlon)
+			lons[lon] = i;
+
+		double ml = lon - 360;
+
+		while ( ml >= minlon && ml <= maxlon ) {  lons[ml] = i; ml -= 360; }
+		ml = lon + 360;
+		while (  ml >= minlon && ml <= maxlon ) {  lons[ml] = i; ml += 360; }
+	}
+
+
+	int i = 0;
+	for (map<double, int>::const_iterator entry = lons.begin(); entry != lons.end(); ++entry)
+	{
+		columns_[i] = entry->second;
+		regular_longitudes_.push_back(entry->first);
+		columnsMap_[entry->first] = i;
+		i++;
+	}
+
+
+
+
+	for (int i = 0; i < rows; i++) {
+
+		lat = matrix_.regular_row(i);
+		if ( minlat <= lat && lat <= maxlat) lats[lat] = i;
+
+	}
+	i = 0;
+	for (map<double, int>::const_iterator entry = lats.begin(); entry != lats.end(); ++entry) {
+		rows_[i] = entry->second;
+		regular_latitudes_.push_back(entry->first);
+		rowsMap_[entry->first] = i;
+		i++;
+	}
+
+
+}
diff --git a/src/common/Matrix.h b/src/common/Matrix.h
new file mode 100644
index 0000000..17c33ed
--- /dev/null
+++ b/src/common/Matrix.h
@@ -0,0 +1,532 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Matrix.h
+    \brief Definition of the Template class Matrix.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Matrix_H
+#define Matrix_H
+
+#include <cfloat>
+#include "magics.h"
+#include "MagException.h"
+
+namespace magics {
+
+class XmlNode;
+
+class AbstractMatrix 
+{
+public :
+    virtual ~AbstractMatrix(){}
+    virtual double  operator()(int  i, int  j) const = 0;   
+    virtual int    rows() const = 0;
+    virtual int    columns() const = 0;
+    virtual double  regular_row(int) const = 0;
+    virtual double  regular_column(int) const = 0;
+    virtual double  row(int, int) const = 0;
+    virtual double  column(int, int) const = 0;
+     virtual double  real_row(double, double) const = 0;
+    virtual double  real_column(double, double) const = 0;
+    virtual int    lowerRow(double) const = 0;
+    virtual int    lowerColumn(double) const = 0;    
+    virtual double  interpolate(double  i, double  j) const = 0; 
+    virtual double  nearest(double i, double j, double &iOut, double &jOut) const = 0;  
+    virtual double  nearest(double i, double j) const =0 ;
+    virtual double  missing() const = 0;
+    virtual double  XResolution() const = 0;
+    virtual double  YResolution() const = 0;
+    virtual double  width() const = 0;
+    virtual double   height() const = 0;
+    virtual bool akimaEnable() const { return false; }
+
+  
+
+   
+   
+
+    
+     virtual const AbstractMatrix&  original() const { return *this; }
+     
+     virtual int firstRow() const = 0;
+     virtual int nextRow(int, int) const = 0;
+     
+     virtual int firstColumn() const = 0;
+     virtual int nextColumn(int, int) const = 0;
+     
+     template <class O> 
+     void for_each(int xf, int yf, const O& object)
+     {
+        
+     	 for ( int i = firstRow(); i > 0; i = nextRow(i, xf) )
+     		 for ( int j = firstColumn(); j > 0; j = nextColumn(j, yf) )
+     			 	object(row(i,j), column(i,j), (*this)(i, j));
+     }
+
+    virtual double  minX() const = 0;
+    virtual double  minY() const = 0;
+    virtual double  maxX() const = 0;
+    virtual double  maxY() const = 0;
+    virtual double  min() const = 0;
+    virtual double  max() const = 0;
+     
+    virtual double  left() const = 0;
+       virtual double  top() const = 0;
+       virtual double  right() const = 0;
+       virtual double  bottom() const = 0;
+       
+       virtual double  x(double, double) const = 0;
+       virtual double  y(double, double) const = 0;      
+       
+    virtual int rowIndex(double r) const  = 0;
+    virtual int columnIndex(double c) const = 0;
+    
+    virtual void boundRow(double r, 
+    	double& row1, int& index1, double& row2, int& index2) const = 0;
+    
+    virtual void boundColumn(double r, 
+    	double& column1, int& index1, double& column2, int& index2) const = 0;
+    
+    virtual bool accept(double, double) const { return true; }
+   
+    virtual vector<double>&  rowsAxis() const = 0;
+    
+    virtual bool  hasMissingValues() const  { return false; }
+  
+    
+    virtual vector<double>&  columnsAxis() const = 0;
+    virtual void print(ostream& out) const 
+        { out << "No Print implemented for this MatrixHandler" << "\n"; }
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AbstractMatrix& p)
+		{ p.print(s); return s; }
+};
+
+struct Plus 
+{
+    Plus(double offset, double missing) : offset_(offset), missing_(missing) {}
+    double operator()(double x) const { return ( x == missing_ ) ? missing_ : x + offset_; }
+    double offset_;
+    double missing_;
+};
+
+struct Multiply 
+{
+    Multiply(double factor, double missing) : factor_(factor), missing_(missing) {}
+    double operator()(double x) const { return ( x == missing_ ) ? missing_ : x * factor_; }
+    double factor_;
+    double missing_;
+};
+
+
+class OutOfRange : public MagicsException
+{
+public:
+    
+    OutOfRange(double r, double c) 
+    { 
+        ostringstream s;
+        s << "Out of Range: Cannot access [" << r << ", " << c << "]" << ends;
+        what_ = s.str();
+    }
+    OutOfRange(double x) 
+    { 
+        ostringstream s;
+        s << "Out of Range: Cannot access [" << x << "]" << ends;
+        what_ = s.str();
+    }
+};
+
+
+
+class Matrix: public AbstractMatrix, public magvector<double> {
+
+public:
+	Matrix(int rows, int columns): 
+		rows_(rows), 
+		columns_(columns),
+		missing_(DBL_MIN),
+		akima_(false),
+		min_(DBL_MAX), max_(DBL_MIN)
+	{  
+         set(rows, columns);
+	}
+	
+	Matrix* clone() { return new Matrix(); }
+	void set(const XmlNode&) { }
+	
+    Matrix(int rows, int columns, double val):     
+        rows_(rows), 
+        columns_(columns), missing_(DBL_MIN), akima_(false), min_(DBL_MAX), max_(DBL_MIN)
+     {       
+         
+         resize(rows_ * columns_, val); 
+         rowsAxis_.resize(rows_, val);
+         columnsAxis_.resize(columns_, val); 
+	}
+    
+    Matrix(): missing_(DBL_MIN), akima_(false), min_(DBL_MAX), max_(DBL_MIN) {}
+    
+    void set(int rows, int columns) 
+    {
+         rows_ = rows;
+         columns_ = columns;
+         reserve(rows_*columns_); 
+         rowsAxis_.reserve(rows); 
+         columnsAxis_.reserve(columns);  
+    }
+    
+     double min() const;
+     double max() const;
+     void min(double m) {min_=m;}
+     void max(double m) {max_=m;}
+    
+    virtual ~Matrix() {}
+    
+    double width() const { return regular_column(columns_ - 1) - regular_column(0); }
+    double height() const { return regular_row(rows_ - 1) - regular_row(0); }
+    
+    int rows() const { return rows_; }
+    int columns() const { return columns_; }
+     
+    double regular_row(int i) const { return rowsAxis_[i]; } 
+    double row(int i, int) const { return regular_row(i); }
+    double real_row(double r, double) const { return r; }
+    double real_column(double, double c) const { return c; }
+    
+
+    void release()
+    {
+    	rows_ = 0;
+    	columns_ = 0;
+    	rowsAxis_.clear();
+    	rowsAxis_.resize(0);
+    	columnsAxis_.clear();
+    	this->clear();
+    	columnsAxis_.resize(0);
+		this->resize(0);
+    }
+ 
+    
+    double regular_column(int j) const { return columnsAxis_[j];  }
+    double column(int, int j) const { return columnsAxis_[j];  }
+     
+    void missing(double missing) { missing_ = missing; }
+    double missing() const { return missing_; }
+    
+    void setRowsAxis(const vector<double>& axis) 
+    {
+        int ind = 0;
+        rowsAxis_.reserve(axis.size());
+        for (vector<double>::const_iterator val = axis.begin(); val != axis.end(); ++val) {
+            rowsAxis_.push_back(*val);
+            rowsMap_[*val] = ind++;
+        }
+        rows_ = axis.size();          
+    }
+    void setColumnsAxis(const vector<double>& axis) 
+    {
+        int ind = 0;
+        columnsAxis_.reserve(axis.size());
+        for ( vector<double>::const_iterator val = axis.begin(); val != axis.end(); ++val) {
+            columnsAxis_.push_back(*val);
+            columnsMap_[*val] = ind++;
+        }
+        columns_ = axis.size();
+            
+    }
+    
+    virtual void setMapsAxis() 
+    {
+        int ind = 0;
+        for (vector<double>::const_iterator val = rowsAxis_.begin(); val != rowsAxis_.end(); ++val) {
+            rowsMap_[*val] = ind++;
+        }
+        rows_ = ind;
+        
+        
+        ind = 0;
+        for (vector<double>::const_iterator val = columnsAxis_.begin(); val != columnsAxis_.end(); ++val) {
+            columnsMap_[*val] = ind++;
+        }
+        columns_ = ind;
+    }
+    
+  
+    double interpolate(double r, double c) const;
+    double nearest(double i, double j) const {double d1, d2; return nearest(i,j,d1,d2);}
+    double nearest(double i, double j,double &iOut, double &jOut) const;
+    
+   void multiply(double factor) 
+    {
+        if (factor == 1 ) return;
+        std::transform(begin(), end(), begin(), Multiply(factor, missing_));
+    }
+    
+    void plus(double offset) 
+    {
+        if (offset == 0 ) return;
+        std::transform(begin(), end(), begin(), Plus(offset, missing_));
+       
+    }
+    
+     virtual int firstRow() const { return 0; }
+     virtual int nextRow(int i, int f) const   
+     { 
+     	i += f; 
+	return ( i < rows_ ) ? i : -1;
+     }
+     
+     virtual int firstColumn() const { return 0; }
+     virtual int nextColumn(int j, int f) const   
+     { 
+     	j += f; 
+	return ( j < rows_ ) ? j : -1;
+     }
+     
+    
+    double operator()(int row, int column) const;
+
+    double YResolution() const {
+    	
+           magvector<double> diff;
+           diff.reserve(rowsAxis_.size());
+           std::adjacent_difference(rowsAxis_.begin(), rowsAxis_.end(), back_inserter(diff));
+           double resol = std::accumulate(diff.begin()+1, diff.end(), 0.)/(diff.size()-1);
+           //MagLog::dev() << "Matrix::YResolution()--->" << resol << "\n";
+           return resol;
+    }
+     double XResolution() const {
+           magvector<double> diff;
+           diff.reserve(columnsAxis_.size());
+           std::adjacent_difference(columnsAxis_.begin(), columnsAxis_.end(), back_inserter(diff));
+           double resol = std::accumulate(diff.begin()+1, diff.end(), 0.)/(diff.size()-1);
+           //MagLog::dev() << "Matrix::XResolution()--->" << resol << "\n";
+           return resol;
+    }
+   
+    vector<double>& rowsAxis() const { return rowsAxis_; }
+    vector<double>& columnsAxis() const  { return columnsAxis_; }
+    
+    
+    double  minX() const { return columnsAxis_.front(); }
+    double  minY() const { return rowsAxis_.front(); } 
+    double  maxX() const { return columnsAxis_.back(); }
+    double  maxY() const { return rowsAxis_.back(); }
+    
+    double  left() const { return columnsAxis_.front(); }
+      double bottom() const { return rowsAxis_.front(); } 
+      double  right() const { return columnsAxis_.back(); }
+      double  top() const { return rowsAxis_.back(); }
+      
+      double x(double x, double) const  { return x; }
+      double y(double, double y) const { return y; }
+    
+    virtual int rowIndex(double r) const     { return row_ind(r); } 
+    virtual int columnIndex(double c) const  { return column_ind(c); } 
+    virtual bool akimaEnable() const  { return akima_; }  
+    void akimaEnabled()  { akima_ = true; }  
+    void akimaDisabled()  { akima_ = false; } 
+    virtual void boundRow(double r, 
+    	double& row1, int& index1, double& row2, int& index2) const { 
+    	
+    	index1 = this->lowerRow(r);
+           		row1 = this->regular_row(index1);
+           		index2 = this->upperRow(r);
+           		row2 = this->regular_row(index2);
+    } 
+    
+    virtual void boundColumn(double r, 
+    	double& column1, int& index1, double& column2, int& index2) const { 
+    	
+    	index1 = this->lowerColumn(r);
+    	column1 = this->regular_column(index1);
+        index2 = this->upperColumn(r);
+        column2 = this->regular_column(index2);
+    } 
+    
+	int    lowerRow(double r) const {
+
+		int last = -1;
+		for ( map<double, int>::const_iterator i = rowsMap_.begin(); i != rowsMap_.end(); ++i) { 	
+			if ( i->first >  r  ) {				
+				return last;
+			}				
+			last = i->second;
+		}		
+		return last;	
+	}
+	int    lowerColumn(double c) const { 
+		
+		int last = -1;
+		for ( map<double, int>::const_iterator i = columnsMap_.begin(); i != columnsMap_.end(); ++i) {
+				if ( i->first > c  ) 
+					return last;
+				last = i->second;
+		}
+		return last;
+    } 
+	int    upperRow(double r) const {
+		
+		
+		for ( map<double, int>::const_iterator i = rowsMap_.begin(); i != rowsMap_.end(); ++i) { 	
+			if ( i->first >=  r  ) {				
+				return i->second;
+			}				
+		
+		}		
+		return -1;	
+	}
+	int    upperColumn(double c) const { 
+		
+		
+		for ( map<double, int>::const_iterator i = columnsMap_.begin(); i != columnsMap_.end(); ++i) {
+				if ( i->first >= c  ) 
+					return i->second;
+		}
+		return -1;
+    } 
+
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const {
+	 	out << "Matrix<P>[";
+    	out << "rowsAxis=" << rowsAxis_;
+    	out << ", columnsAxis=" << columnsAxis_;
+   	 	out << ", values=";
+    	magvector<double>::print(out);
+    	out << "]"; 
+	 }
+	 
+     map<double, int>   rowsMap_;
+     mutable magvector<double>     rowsAxis_;
+     
+     map<double, int>    columnsMap_;
+     mutable magvector<double>      columnsAxis_;
+     
+     int rows_;
+     int columns_;
+     double missing_;
+     bool akima_;
+
+    int row_ind(double row) const {
+        map<double, int>::const_iterator i = rowsMap_.lower_bound(row);
+    	if ( same(i->first, row) )
+    			return i->second;
+        if ( i == rowsMap_.end() ) {
+            map<double, int>::const_reverse_iterator i = rowsMap_.rbegin();
+            if ( same(i->first, row) )
+                return i->second;
+        }
+    	return -1;
+    }
+    int column_ind(double column) const {
+	  
+       map<double, int>::const_iterator i = columnsMap_.lower_bound(column);
+	   
+    	if ( same(i->first, column) )
+    	    	return i->second;
+        if ( i == columnsMap_.end() ) {
+            map<double, int>::const_reverse_iterator i = columnsMap_.rbegin();
+            if ( same(i->first, column) )
+                return i->second;
+        }
+    	return -1;
+    }    
+private:
+   mutable double min_;
+   mutable double max_;
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Matrix& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class ProjectedMatrix: public Matrix
+{
+public:
+	    
+		ProjectedMatrix(int rows, int columns);
+	
+		
+		void getReady(); // Prepare the matrix ... 
+		  
+		vector<double>&  values() const { return values_; }
+		vector<double>&  rowsArray() const { return rowsArray_; }
+		vector<double>&  columnsArray() const { return columnsArray_; }
+		
+		int index(int r, int c) { return (r* origColumns_) + c; }
+		  
+		  
+protected:
+	      void build();
+	      
+	      int origColumns_;
+	      int origRows_;
+		  mutable vector<double> rowsArray_;
+		  mutable vector<double> columnsArray_; 
+		  mutable vector<double> values_; 
+		  
+		  double minx_;
+		  double miny_;
+		  double maxx_;
+		  double maxy_;
+		  
+		  double stepx_;
+		  double stepy_;
+		  
+			
+};
+class RotatedMatrix: public Matrix
+{
+
+public:
+		RotatedMatrix(int, int);
+
+		vector<double>&  values() const { return values_; }
+		vector<double>&  rowsArray() const { return rowsArray_; }
+		vector<double>&  columnsArray() const { return columnsArray_; }
+
+		double operator()(int r, int c) const { return values_[r* columns_ + c]; }
+		double row(int r, int c) const { return rowsArray_[r* columns_ + c]; }
+		double column(int r, int c) const { return columnsArray_[r* columns_ + c]; }
+protected:
+
+		mutable vector<double> rowsArray_;
+		mutable vector<double> columnsArray_;
+		mutable vector<double> values_;
+
+
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/MatrixHandler.h b/src/common/MatrixHandler.h
new file mode 100644
index 0000000..d0f4dd9
--- /dev/null
+++ b/src/common/MatrixHandler.h
@@ -0,0 +1,875 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MatrixHandler.h
+    \brief Definition of the Template class MatrixHandler.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Feb-2004 
+    
+    Changes:
+    
+*/ 
+
+#ifndef MatrixHandler_H
+#define MatrixHandler_H
+ 
+#include "magics.h"
+#include "Matrix.h"
+#include "BasePointsHandler.h"
+#include "Transformation.h"
+#include "VectorOfPointers.h"
+
+#include "Timer.h"
+
+#include "Transformation.h"
+
+namespace magics {
+
+class MatrixHandler : public AbstractMatrix, public AbstractPoints
+{
+public : 
+    MatrixHandler(const AbstractMatrix& matrix) : AbstractMatrix(),
+        AbstractPoints(),
+        matrix_(matrix), min_(INT_MAX), max_(-INT_MAX)  {}
+    MatrixHandler(const MatrixHandler& matrix) :
+        AbstractMatrix(),
+        AbstractPoints(),
+        matrix_(matrix) , min_(INT_MAX), max_(-INT_MAX) {}
+    virtual ~MatrixHandler() {}
+   
+    virtual double operator()(int  i, int  j) const { return matrix_(i, j); } 
+    
+    virtual int rowIndex(double r) const     { return matrix_.rowIndex(r); } 
+    virtual int columnIndex(double c) const  { return matrix_.columnIndex(c); }  
+    virtual bool  akimaEnable() const  { return matrix_.akimaEnable(); }
+    
+    
+    virtual void boundRow(double r, 
+    	double& row1, int& index1, double& row2, int& index2) const 
+    		{ return matrix_.boundRow(r, row1, index1, row2, index2); }
+    virtual void boundColumn(double r, 
+    	double& column1, int& index1, double& column2, int& index2) const 
+    		{ return matrix_.boundColumn(r, column1, index1, column2, index2); }		
+    
+    double  left() const { return matrix_.left(); }
+         double bottom() const { return matrix_.bottom(); } 
+         double  right() const { return matrix_.right(); }
+         double  top() const { return matrix_.top(); }
+         
+         double x(double x, double y) const  { return matrix_.x(x, y); }
+         double y(double x, double y) const { return matrix_.y(x, y); }
+         
+     virtual double nearest(double  row, double  column, double &rowOut, double &columnOut) const
+     {
+    		rowOut=-1;
+		columnOut=-1;
+		return nearest(row,column);
+     }		
+     virtual double nearest(double  row, double  column) const
+     {
+            	if ( columns() == 0  || rows() == 0)
+            		return matrix_.missing();
+
+        		if ( column < left() && !same(column, left()) )
+                    return matrix_.missing();
+                if ( column > right() && !same(column, right()) )
+                    return matrix_.missing();
+                if ( row < bottom() && !same(row, bottom()) )
+                    return matrix_.missing();
+                if ( row > top() && !same(row, top()) )
+                    return matrix_.missing();
+   
+                int ri = rowIndex(row);
+                int ci = columnIndex(column);
+                if ( ri != -1 && ci != -1)
+                	return  (*this)(ri, ci);
+                double x1, x2;
+                double y1, y2;
+                int r1, r2, c1, c2;
+                vector<double> distances;
+                map<double, pair<pair<double, double>,  pair<int, int> > > helper;
+                vector<pair<pair<double, double>,  pair<int, int> > > coordinates;
+                if (ri != -1 ) {
+                	boundColumn(column, x1, c1, x2, c2);
+                	coordinates.push_back(make_pair(make_pair(row, x1), make_pair(ri, c1)));
+                	coordinates.push_back(make_pair(make_pair(row, x2), make_pair(ri, c2)));
+                }
+                else if (ci != -1 ) {
+                	boundRow(row, y1, r1, y2, r2);
+                	coordinates.push_back(make_pair(make_pair(y1, column), make_pair(r1, ci)));
+                	coordinates.push_back(make_pair(make_pair(y2, column), make_pair(r2, ci)));
+
+                }
+                else {
+                	boundColumn(column, x1, c1, x2, c2);
+                	boundRow(row, y1, r1, y2, r2);
+
+                // 4 points ...
+                // x1, y1 - x2, y1 -  x1, y2 - x2, y2
+                // find the nearest...
+                	coordinates.push_back(make_pair(make_pair(y1, x1), make_pair(r1, c1)));
+                	coordinates.push_back(make_pair(make_pair(y1, x2), make_pair(r1, c2)));
+                	coordinates.push_back(make_pair(make_pair(y2, x1), make_pair(r2, c1)));
+                	coordinates.push_back(make_pair(make_pair(y2, x2), make_pair(r2, c2)));
+                }
+
+                for (vector< pair<pair<double, double>, pair<int, int> > >::iterator coord = coordinates.begin(); coord != coordinates.end(); ++coord) {
+                	double distance = (row- coord->first.first)*(row-coord->first.first) + (column - coord->first.second)*(column - coord->first.second);
+                	//cout << distance << " [ " << coord->first.first << ", " << coord->first.second << "]" << endl;
+                	distances.push_back(distance);
+                	helper.insert(make_pair(distance, *coord));
+                }
+
+				if ( distances.empty() ) 
+                    return matrix_.missing();
+
+				double min = *std::min_element(distances.begin(), distances.end());
+
+                map<double, pair<pair<double, double>,  pair<int, int> > >::iterator near = helper.find(min);
+
+				if ( near == helper.end() ) 
+					return  matrix_.missing();
+
+				return (*this)(near->second.second.first, near->second.second.second);
+
+    }
+	
+    virtual double interpolate(double  i, double  j) const 
+    {
+    	if ( columns() == 0  || rows() == 0)
+    		return matrix_.missing();
+
+		if ( j < left() && !same(j, left()) )
+            return matrix_.missing();
+        if ( j > right() && !same(j, right()) )
+            return matrix_.missing();
+        if ( i < bottom() && !same(i, bottom()) )
+            return matrix_.missing();
+        if ( i > top() && !same(i, top()) )
+            return matrix_.missing();
+
+
+    	
+    	int ii = rowIndex(i);
+    	if (ii == -1) {
+    		// interpolate between 2 rows.
+    		double v1, v2;
+    		int i1, i2;
+    		boundRow(i, v1, i1, v2, i2);
+    		
+    		if (i1 == -1) return missing(); 
+    		
+    	    double a = (*this).interpolate(v1, j);
+            double b = (*this).interpolate(v2, j);
+          
+            if ( same(a, missing()) || same(b, missing()) ) return missing();
+            
+            double da = (v2-i)/(v2-v1);
+            double db = (i-v1)/(v2-v1);
+            double val = (a*da) + (b*db);
+            return val;
+        }
+        int jj = columnIndex(j);
+        if (jj == -1) {
+        	double v1, v2;
+    		int i1, i2;
+    		boundColumn(j, v1, i1, v2, i2);
+    		if (i1 == -1) return missing(); 
+    		
+        	
+    		double a = (*this)(ii, i1);
+            double b = (*this)(ii, i2);
+            
+            if ( same(a, missing()) || same(b, missing()) ) return missing();
+            
+            double da = (v2-j)/(v2-v1);
+            double db = (j-v1)/(v2-v1);
+            double val = (a*da) + (b*db);
+            return val;
+            
+        }
+    	
+    	return (*this)(ii, jj);
+    			
+    	
+    }  
+    
+    virtual int    rows() const { return matrix_.rows(); }
+    virtual int    columns() const { return matrix_.columns(); }
+    virtual int    lowerRow(double v) const { return matrix_.lowerRow(v); }
+    virtual int    lowerColumn(double v) const { return matrix_.lowerColumn(v); } 
+    virtual double  XResolution() const { return matrix_.XResolution(); } 
+    virtual double  YResolution() const { return matrix_.YResolution(); } 
+    virtual double  width() const { return matrix_.width(); } 
+    virtual double  height() const { return matrix_.height(); } 
+    
+    virtual const AbstractMatrix& original() const { return matrix_.original(); }
+    virtual int firstRow() const 	{ return matrix_.firstRow(); }
+    virtual int nextRow(int i, int f) const   { return matrix_.nextRow(i, f); }
+    virtual int firstColumn() const { return matrix_.firstColumn(); }
+    virtual int nextColumn(int j, int f) const  { return matrix_.nextColumn(j, f); } 
+    
+    void setMinMax() const {
+    	int nb_rows = rows();
+    	int nb_columns = columns();
+    	double missing =  matrix_.missing();    
+    	        	
+    	            for (int r = 0; r < nb_rows; r++) {
+    	                for (int c = 0; c < nb_columns; c++) {
+    	                     double val =  (*this)(r, c);
+    	                     if ( val == missing ) continue; 
+    	                     if ( val < min_ ) min_ = val;
+    	                     if ( val > max_ ) max_ = val;   	                       
+    	                }
+    	            }            
+    }
+    
+    double min() const {
+      	 if ( min_ != INT_MAX) 
+      		 return min_;
+      	
+      	setMinMax();
+      	 return min_;
+     }
+     
+       double max() const {
+      	 if ( max_ != -INT_MAX) 
+      		 return max_; 
+      	 
+      	setMinMax();
+      	 return max_;
+       }
+    
+    virtual double  minX() const { return matrix_.minX(); }
+    virtual double  maxX() const { return matrix_.maxX(); }
+    virtual double  minY() const { return matrix_.minY(); }
+    virtual double  maxY() const { return matrix_.maxY(); }
+    
+    // Implements the AbstractPoints interface
+    virtual void setToFirst()   {
+        if (points_.empty()) {
+        	int nb_rows = rows();
+        	int nb_columns = columns();
+
+            points_.reserve(nb_rows * nb_columns);
+        	
+            for (int r = 0; r < nb_rows; r++) {
+                for (int c = 0; c < nb_columns; c++) {
+                    if ( matrix_.accept(column(r, c), row(r, c)) ) 
+                        if ( !same((*this)(r, c), matrix_.missing() ) ) 
+                        	points_.push_back(new UserPoint(column(r,c), row(r,c), (*this)(r, c)));
+                }
+            }            
+        }
+        current_ = points_.begin();
+    }
+    
+    //! Method to test the end of collection.
+    virtual bool more()   {
+        return current_ != points_.end();
+    }
+   
+    virtual bool accept(double x, double y) const { return matrix_.accept(x, y); }
+  
+    virtual UserPoint& current()
+    {
+        return **current_;
+       
+    }
+    
+    virtual void advance()  {
+        current_++;
+    }
+    
+    
+    virtual vector<double>&  rowsAxis()  const { return const_cast<MatrixHandler*>(this)->matrix_.rowsAxis(); }
+    virtual vector<double>&  columnsAxis() const  { return const_cast<MatrixHandler*>(this)->matrix_.columnsAxis(); }
+    
+    virtual double  row(int i, int j) const { 
+        return matrix_.row(i, j); 
+    }
+    virtual double  column(int i, int j) const { 
+        return matrix_.column(i, j); }
+    
+    virtual double  real_row(double i, double j) const { 
+        return matrix_.real_row(i, j); 
+    }
+    virtual double  real_column(double i, double j) const { 
+        return matrix_.real_column(i, j); }
+    virtual double  regular_row(int i) const { 
+        return matrix_.regular_row(i); 
+    }
+    virtual double  regular_column(int i) const { 
+        return matrix_.regular_column(i); 
+    }
+    
+    
+    virtual double  missing() const  { return matrix_.missing(); }
+    virtual bool  hasMissingValues() const  { 
+       
+        for (int r = 0; r < rows(); r++) {
+                for (int c = 0; c < columns(); c++) {                   
+                        if ( operator()(r, c) == matrix_.missing() )
+                        	return true;
+                }
+            }
+        return false;
+    }    
+    
+    
+    
+ 
+    
+protected:    
+    const AbstractMatrix& matrix_;
+    mutable VectorOfPointers<vector<UserPoint*> > points_;
+    mutable VectorOfPointers<vector<UserPoint*> >::const_iterator current_;
+    mutable double min_;
+    mutable double max_;
+  
+};
+
+
+
+   
+
+
+
+
+
+
+
+
+
+
+class TransformMatrixHandler : public MatrixHandler
+{
+public :
+ 	TransformMatrixHandler(const AbstractMatrix& matrix) : MatrixHandler(matrix)
+      {}
+
+
+    double  operator()(int  i, int  j) const
+    {
+    	return matrix_( i + minrow_ , j + mincolumn_ );
+    }  
+    
+    double  left() const {
+    	return minx_;
+    }
+    double  right() const {
+    	return maxx_;
+    }
+    double  bottom() const {
+        	return miny_;
+    }
+    double  top() const {
+          return  maxy_;
+     } 
+    
+    void set() {
+    	for ( int i = 0; i < rows(); i++ ) {
+    		double row = matrix_.regular_row(minrow_ +i);
+    		rowsMap_.insert(make_pair(row, i));			
+    		fastRows_.push_back(row);
+    	}
+    	for ( int i = 0; i < columns(); i++ ) {
+        		double column = matrix_.regular_column(mincolumn_ + i);
+        		columnsMap_.insert(make_pair(column, i));			
+        		fastColumns_.push_back(column);
+        	} 	
+    	minx_ =  std::min(fastColumns_.front(), fastColumns_.back());
+    	maxx_ =  std::max(fastColumns_.front(), fastColumns_.back());
+    	miny_ =  std::min(fastRows_.front(), fastRows_.back());
+        maxy_ =  std::max(fastRows_.front(), fastRows_.back());
+    }
+    
+    int  rows() const { return maxrow_ - minrow_ +1; } 
+    int  columns() const { return maxcolumn_ - mincolumn_+1; } 
+    double regular_row(int index) const {       
+    	return fastRows_[index]; 
+    }
+    double regular_column(int index) const { 
+    	return fastColumns_[index]; 
+    }
+    double real_row(int index) const  { 
+    	return fastRows_[index]; 
+    }
+    double real_column(int index) const { 
+    	return fastColumns_[index]; 
+    }
+    inline double column(int, int j) const {  
+    	return fastColumns_[j]; 
+    }
+    virtual double  real_row(double row, double) const { 
+         return row; 
+     }
+     virtual double  real_column(double, double column) const { 
+         return column; 
+    }
+    inline double row(int i, int) const {  
+    	
+        return fastRows_[i]; 
+    }
+    virtual bool  hasMissingValues() const {  return matrix_.hasMissingValues(); }
+    double interpolate(double  i, double  j) const { return matrix_.interpolate(i, j);}
+    double  missing() const { return matrix_.missing(); }
+	int    lowerRow(double r) const {
+	
+		int last = -1;
+		for ( map<double, int>::const_iterator i = rowsMap_.begin(); i != rowsMap_.end(); ++i) { 	
+			if ( i->first >  r  ) {				
+				return last;
+			}				
+			last = i->second;
+		}		
+		return -1;	
+	}
+	int    lowerColumn(double c) const { 
+		
+		int last = -1;
+		for ( map<double, int>::const_iterator i = columnsMap_.begin(); i != columnsMap_.end(); ++i) {
+				if ( i->first > c  ) 
+					return last;
+				last = i->second;
+		}
+		return -1;
+    } 
+	int    upperRow(double r) const {
+		
+		
+		for ( map<double, int>::const_iterator i = rowsMap_.begin(); i != rowsMap_.end(); ++i) { 	
+			if ( i->first >  r  ) {				
+				return i->second;
+			}				
+		
+		}		
+		return -1;	
+	}
+	int    upperColumn(double c) const { 
+		
+		
+		for ( map<double, int>::const_iterator i = columnsMap_.begin(); i != columnsMap_.end(); ++i) {
+				if ( i->first > c  ) 
+					return i->second;
+		}
+		return -1;
+    } 
+
+protected :
+   int minrow_;
+   int maxrow_;
+   int mincolumn_;
+   int maxcolumn_;
+   map<double, int> rowsMap_;
+   map<double, int> columnsMap_;
+   vector<double> fastRows_;
+   vector<double> fastColumns_;
+   double minx_;
+   double maxx_;
+   double miny_;
+   double maxy_;
+   
+   bool rowrevert_;
+   bool columnrevert_;
+};
+
+
+
+
+class BoxMatrixHandler : public TransformMatrixHandler
+{
+public:
+    BoxMatrixHandler(const AbstractMatrix& matrix, const Transformation& transformation) : 
+        TransformMatrixHandler(matrix),
+	transformation_(transformation),
+	original_(0) 
+   { 
+        double minx = std::min(transformation.getMinX(), transformation.getMaxX());
+        double maxx = std::max(transformation.getMinX(), transformation.getMaxX());
+        double miny = std::min(transformation.getMinY(), transformation.getMaxY());
+        double maxy = std::max(transformation.getMinY(), transformation.getMaxY());
+
+        int rows = matrix_.rows();
+        int columns = matrix_.columns();
+
+        mincolumn_ = columns-1;
+        maxcolumn_ = 0;
+        minrow_ = rows-1;
+        maxrow_ = 0;
+
+        for ( int row = 0; row < rows;  row++) {
+        	for ( int column = 0; column < columns;  column++) {
+        		double x = matrix_.column(row, column);
+        		double y = matrix_.row(row, column);
+        		if ( minx <= x && x < maxx && miny <= y && y <= maxy) {
+        			mincolumn_ = std::min(mincolumn_, column);
+        			maxcolumn_ = std::max(maxcolumn_, column);
+        			minrow_ = std::min(minrow_, row);
+        			maxrow_ = std::max(maxrow_, row);
+        		}
+        	}
+   	}
+
+
+        if ( mincolumn_ > maxcolumn_ ) {
+        	mincolumn_ = maxcolumn_;
+        	MagLog::warning() << "No data to plot in the requested area" << endl;
+        }
+        if ( minrow_ > maxrow_ ) {
+        	minrow_ = maxrow_;
+        	MagLog::warning() << "No data to plot in the requested area" << endl;
+        }
+        //MagLog::broadcast();
+
+        mincolumn_ = std::max(mincolumn_-1, 0);
+        maxcolumn_ = std::min(maxcolumn_+1, columns-1);
+
+        columnrevert_ =   matrix_.column(0,  maxcolumn_ ) < matrix_.column(0,  mincolumn_) ;
+        
+        minrow_ = std::max(minrow_-1, 0);
+        maxrow_ = std::min(maxrow_+1, rows-1);
+
+        rowrevert_ =   matrix_.row(maxrow_, 0 ) < matrix_.row(minrow_, 0 ) ;
+        set();
+               
+    }
+    
+    virtual const AbstractMatrix& original() const { 
+    	if ( !original_) 
+		original_ = new BoxMatrixHandler(matrix_.original(), transformation_);
+	return *original_;
+    }
+    
+    
+    virtual void boundRow(double r, 
+       	double& row1, int& index1, double& row2, int& index2) const {        	
+       		index1 = lowerRow(r);
+       		row1 = regular_row(index1);
+       		index2 = upperRow(r);
+       		row2 = regular_row(index2);
+       	
+       } 
+       
+       virtual void boundColumn(double r, 
+       	double& column1, int& index1, double& column2, int& index2) const { 
+    	   index1 = lowerColumn(r);
+           column1 = regular_column(index1);
+           index2 = upperColumn(r);
+           column2 = regular_column(index2);
+       } 
+  
+    
+    virtual ~BoxMatrixHandler() { delete original_; }
+     
+    // Implements the AbstractPoints interface
+    virtual bool accept(double x, double y) const {
+        return transformation_.in(x, y);
+    }
+   
+    double  minX() const {return std::min(transformation_.getMinX(), transformation_.getMaxX());  }
+    double  maxX() const { return std::max(transformation_.getMinX(), transformation_.getMaxX()); }
+    double  minY() const { return std::min(transformation_.getMinY(), transformation_.getMaxY()); }
+    double  maxY() const { return std::max(transformation_.getMinY(), transformation_.getMaxY());}
+
+protected :
+    const Transformation& transformation_;
+    mutable BoxMatrixHandler*   original_;
+};
+
+
+class GeoBoxMatrixHandler: public TransformMatrixHandler
+{
+public:
+	GeoBoxMatrixHandler(const AbstractMatrix& matrix, const Transformation& transformation);
+    
+    virtual const AbstractMatrix& original() const { 
+    	if ( !original_) 
+		original_ = new GeoBoxMatrixHandler(matrix_.original(), transformation_);
+	return *original_;
+    }
+    
+    int columns() const { return  columnsMap_.size(); }
+    int rows() const { return rowsMap_.size(); }
+    
+    int rowIndex(double r) const {
+    	map<double, int>::const_iterator i = rowsMap_.lower_bound(r);
+    	if ( same(i->first, r) )
+    			return i->second;
+    	return -1;
+
+
+    }
+    
+    int columnIndex(double c) const {
+    	map<double, int>::const_iterator i = columnsMap_.lower_bound(c);
+    	if ( same(i->first, c) )
+    	    	return i->second;
+    	return -1;
+    }
+    
+    inline double column(int, int column) const {   	
+       	return regular_longitudes_[column];
+   }
+    inline double row(int row, int) const {
+    	return regular_latitudes_[row];
+    }
+     double  operator()(int  row, int  column) const {
+    	if ( columns_[column] == -1 )
+    			return matrix_.missing();
+        return matrix_(rows_[row], columns_[column]);
+     }
+
+	int lowerRow(double r) const
+	{   
+		map<double, int>::const_iterator i = rowsMap_.lower_bound(r);
+		if ( same(i->first, r) )
+		   return i->second;
+		if  ( i != rowsMap_.begin() ) {
+			i--;
+			return i->second;
+		}
+		return -1;
+	}  
+
+	int lowerColumn(double c) const
+	{    	
+		map<double, int>::const_iterator i = columnsMap_.lower_bound(c);
+		if ( same(i->first, c) )
+			return i->second;
+		if  ( i != columnsMap_.begin() ) {
+			i--;
+			return i->second;
+		}
+		return -1;
+	}
+
+	double regular_row(int i) const    { return regular_latitudes_[i]; }
+	double regular_column(int i) const { return regular_longitudes_[i]; }
+    
+	virtual ~GeoBoxMatrixHandler() { delete original_; }
+     
+	// Implements the AbstractPoints interface
+	virtual bool accept(double x, double y) const
+	{
+		return transformation_.in(x, y);
+	}
+   
+	double  minX() const {return std::min(transformation_.getMinX(), transformation_.getMaxX());  }
+	double  maxX() const { return std::max(transformation_.getMinX(), transformation_.getMaxX()); }
+	double  minY() const { return std::min(transformation_.getMinY(), transformation_.getMaxY()); }
+	double  maxY() const { return std::max(transformation_.getMinY(), transformation_.getMaxY());}
+
+	double  left()   const { return regular_longitudes_.front(); }
+	double  bottom() const { return regular_latitudes_.front(); } 
+	double  right()  const { return regular_longitudes_.back(); }
+	double  top()    const { return regular_latitudes_.back(); } 
+
+	virtual void boundRow(double r, double& row1, int& index1, double& row2, int& index2) const
+	{
+		index1 = lowerRow(r);
+		row1 = regular_latitudes_[index1];
+		index2 = index1+1;
+		row2 = regular_latitudes_[index2];
+	} 
+
+	virtual void boundColumn(double r, double& column1, int& index1, double& column2, int& index2) const
+	{
+		index1 = lowerColumn(r);
+		column1 = regular_longitudes_[index1];
+		index2 = index1+1;
+		column2 = regular_longitudes_[index2];
+	} 
+
+           
+protected :
+	const Transformation& transformation_;
+	mutable GeoBoxMatrixHandler*   original_;
+	mutable map<int, int>     rows_;
+	mutable map<int, int>     columns_;
+	vector<double> regular_latitudes_;
+	vector<double> regular_longitudes_;
+};
+
+
+
+
+class MonotonicIncreasingMatrixHandler : public MatrixHandler
+{
+public:
+    MonotonicIncreasingMatrixHandler(const AbstractMatrix& matrix) : 
+        MatrixHandler(matrix) {
+	// Check RowAxis...
+	int row = matrix_.rows();
+	if (matrix_.regular_row(1) - matrix_.regular_row(0) >= 0) // Increasing Axis...
+	     for (int i = 0; i < row; i++) {
+             rows_[i] = i;
+             newRowsMap_[matrix.regular_row(i)] = i;
+	     }
+	else // Decreasing axis...
+	     for (int i = 0; i < row; i++) {
+             rows_[i] = ( row - 1) - i;
+             newRowsMap_[matrix.regular_row(( row - 1) - i)] = i;
+	     }
+	// Check ColumnAxis
+	int column = matrix_.columns();
+	if (matrix_.regular_column(1) - matrix_.regular_column(0) >= 0) // Increasing Axis...
+	     for (int j = 0; j < column; j++) {
+             columns_[j] = j;
+             newColumnsMap_[matrix.regular_column(j)] = j;
+	     }
+	else // Decreasing axis...
+	     for (int j = 0; j < column; j++) {
+             columns_[j] = (column - 1) - j;
+             newColumnsMap_[matrix.regular_column((column - 1) - j)] = j;
+	     }
+	
+	}
+    virtual ~MonotonicIncreasingMatrixHandler() {}
+    
+    double  operator()(int  i, int  j) const
+    {
+        int x = const_cast<MonotonicIncreasingMatrixHandler*>(this)->rows_[i];
+        int y = const_cast<MonotonicIncreasingMatrixHandler*>(this)->columns_[j];
+        
+        return matrix_(x, y);
+    }  
+
+    int rows() const { return matrix_.rows(); }
+    virtual int columns() const { return matrix_.columns(); }
+    virtual double regular_column(int i) const { return matrix_.regular_column(const_cast<MonotonicIncreasingMatrixHandler*>(this)->columns_[i]); }
+    virtual double regular_row(int j) const { return matrix_.regular_row( const_cast<MonotonicIncreasingMatrixHandler*>(this)->rows_[j]); }
+    virtual double interpolate(double  i, double  j) const {return matrix_.interpolate(i, j);}
+    virtual double missing() const { return matrix_.missing(); }
+    void print() 
+    {
+        MagLog::debug() << "MonotonicIncreasingMatrixHandler->\n";
+        for (int j = 0; j < rows() ; j++)
+	{
+            for (int i = 0; i < columns(); i++)
+	    {
+                MagLog::dev()<< (*this)(j,i) << " ";
+            }
+            MagLog::dev()<<"\n";
+        }
+        MagLog::debug() << "<--" << endl;
+    }
+    
+    
+    int  lowerRow(double r) const
+    {    
+        map<double, int>::const_iterator bound = newRowsMap_.find(r);
+        if ( bound != newRowsMap_.end() ) return (*bound).second;
+    	
+        bound = newRowsMap_.lower_bound(r);
+        if ( bound == newRowsMap_.end() ) return -1; 
+        return (*bound).second - 1;
+   
+    }  
+    
+    int  lowerColumn(double c) const
+    {    	
+        map<double, int>::const_iterator bound = newColumnsMap_.find(c);
+        if ( bound != newColumnsMap_.end() ) return (*bound).second;
+            
+        bound = newColumnsMap_.lower_bound(c);
+        if ( bound == newColumnsMap_.end() ) return -1;
+        return (*bound).second - 1;
+    }
+    
+protected :
+    map<int, int>     rows_;
+    map<int, int>     columns_;
+    map<double, int>   newRowsMap_;
+    map<double, int>   newColumnsMap_;
+};
+ 
+
+
+class OriginalMatrixHandler : public MatrixHandler
+{
+public:
+	OriginalMatrixHandler(AbstractMatrix& matrix) : 
+		MatrixHandler(matrix.original())
+	{
+	}
+};
+
+
+class ThinningMatrixHandler : public MatrixHandler
+{
+public:
+	ThinningMatrixHandler(const AbstractMatrix& matrix, int  fr, int  fc) : 
+		MatrixHandler(matrix), frequencyRow_(fr), frequencyColumn_(fc)
+	{
+		int rows = matrix_.rows();
+		int columns = matrix_.columns();
+
+		int row = 0;
+		for (int i = 0; i < rows; i+=frequencyRow_)
+		{
+		    rowIndex_.insert(make_pair(row, i));
+		    row++;           
+		}
+		int column=0;
+		for (int i = 0; i < columns; i+=frequencyColumn_)
+		{
+			//MagLog::dev()<< "Sample --> " << column << "=" << i << endl;
+			columnIndex_.insert(make_pair(column, i));
+			//MagLog::dev()<< "Sample --> " << column << "=" << i << "[" << regular_column(column) << "]" << endl;
+
+			column++;           
+		}
+		columnIndex_.insert(make_pair(column, columns-1));
+		//MagLog::dev()<< "Sample --> " << column << "=" << columns-1 << "[" << regular_column(column) << "]"<< endl;
+	}
+
+	int rows() const { return rowIndex_.size(); }
+	int columns() const { return columnIndex_.size(); }
+	
+	double operator()(int row, int column) const {return matrix_(rowIndex(row), columnIndex(column));}
+	double column(int row, int column) const {return matrix_.column(rowIndex(row), columnIndex(column));}
+	double row(int row, int column) const {return matrix_.row(rowIndex(row), columnIndex(column));}
+	double regular_row(int row) const {return matrix_.regular_row(rowIndex(row));}
+	double regular_column(int column) const {return matrix_.regular_column(columnIndex(column));}
+	double real_row(int row, int column) const {return matrix_.real_row(rowIndex(row), columnIndex(column));}
+	double real_column(int row, int column) const {return matrix_.real_column(rowIndex(row), columnIndex(column));}
+
+protected :
+	int columnIndex(int column) const
+	{
+		map<int, int>::const_iterator index = columnIndex_.find(column);
+		assert( index != columnIndex_.end() );
+		return index->second;
+	}
+	int rowIndex(int row) const
+	{
+		map<int, int>::const_iterator index = rowIndex_.find(row);
+		assert( index != rowIndex_.end() );
+		return index->second;
+	}
+	int  frequencyRow_;
+	int  frequencyColumn_;
+	map<int, int> rowIndex_;
+	map<int, int> columnIndex_;
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/MetaData.cc b/src/common/MetaData.cc
new file mode 100644
index 0000000..0e7d104
--- /dev/null
+++ b/src/common/MetaData.cc
@@ -0,0 +1,195 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MetaData.h
+    \brief Implementation of the Template class MetaData.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 5-Jan-2006
+    
+    Changes:
+    
+*/
+
+
+
+#include "MetaData.h"
+#include "Timer.h"
+#include <sys/time.h>
+#include <sys/resource.h>
+
+using namespace magics;
+
+MetaDataVisitor::MetaDataVisitor() 
+{
+	meta_.push_back(this);
+}
+
+
+MetaDataVisitor::~MetaDataVisitor() 
+{
+	meta_.erase(std::remove(meta_.begin(),meta_.end(), this), meta_.end());
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MetaDataVisitor::print(ostream& out)  const
+{
+	out << "MetaData[";
+	out << "]";
+}
+
+
+void MetaDataVisitor::close()
+{
+	//MagLog::dev() << " MetaData::write --->  " << meta << " in file[" << path_ << "]" << endl;
+	return;
+	ofstream out(path_.c_str());
+	out << "<metadata>\n";
+	for (const_iterator entry = begin(); entry != end(); ++entry)
+		out << **entry;
+	out << "</metadata>\n";
+	out.close();
+	
+	
+}
+
+void MetaDataVisitor::collectMetaData()
+{
+	MagLog::dev() << "----MetaData::visit-----" << endl;
+	parent_->visit(*this);
+	close();
+	
+	
+	try {
+	 ofstream out(profile_.c_str());
+
+	    	double t;
+	       struct timeval tim;
+
+
+
+
+
+		out << "{\n\"magics timers\" : {" << endl;
+
+		string s = "";
+		                    
+		for (vector<ProfileInfo>::const_iterator web = Timer::begin(); web != Timer::end(); ++web) {
+			out << s;
+			out << *web;
+			s = ",\n";
+		}
+		
+
+		struct rusage p;
+		getrusage(RUSAGE_SELF, &p);
+		out << 	",\n\t\"general\": {" << endl;
+		out << "\t\t\"user\" : " <<  p.ru_utime.tv_sec << "," << endl;
+		out << "\t\t\"system\" : " <<  p.ru_stime.tv_sec << "," << endl;
+		out << "\t\t\"memory\" : " <<   p.ru_maxrss/1024 << ","   << endl;
+		out << "\t\t\"input\" : " <<   p.ru_inblock  << "," << endl;
+		out << "\t\t\"output\" : " <<   p.ru_oublock  << endl;
+		out << "\t}" << endl;
+		out << "}" << endl;
+	}
+
+	catch ( ...) {}
+
+	if ( ! javascript_.empty() ) {
+		try  {
+			ofstream out(javascript_.c_str());
+
+			out        << "{";
+		
+			string s = "";
+
+			for (map<string, string>::const_iterator web = web_.begin(); web != web_.end(); ++web) {
+				if ( web->first == "world_file" )
+					continue;
+				out << s;
+				out << "\"" << web->first << "\":" <<  web->second;
+				s = ",";
+			}
+
+			out << "}";
+			out.close();
+		}
+		catch (...) {}
+	}
+	
+	if ( ! world_file_.empty() ) {
+		try  {
+			ofstream out(world_file_.c_str());
+
+
+
+			for (map<string, string>::const_iterator web = web_.begin(); web != web_.end(); ++web) {
+				if ( web->first != "world_file" )
+					continue;
+
+				out << web->second;
+
+			}
+
+
+			out.close();
+		}
+		catch (...) {}
+	}
+	if ( ! efi_.empty() ) {
+				char c;
+				string path = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "efi/" + efi_template_;
+				try  {
+					ofstream out(efi_.c_str());
+					ifstream in(path.c_str());
+					while(in && in.get(c) )
+					    out.put(c);
+					out.close();
+					in.close();
+				}
+				catch (...) {
+					ofstream out(efi_.c_str());
+					out << " Could not opened " << path << endl;
+					out.close();
+				}
+
+	}
+
+}
+
+void MetaDataVisitor::metadata(map<string, string>& data)
+{
+    string quote = "\"";
+	data["magics_version"] = quote + MAGICS_VERSION + quote;
+    data["filename"] = javascript_;
+    parent_->visit(*this);
+    close();
+}
+
+vector<MetaDataVisitor*> MetaDataVisitor::meta_;
+
+void MetaDataVisitor::collect() 
+{
+	for ( vector<MetaDataVisitor*>::iterator meta = meta_.begin(); meta != meta_.end(); ++meta ) 
+		(*meta)->collectMetaData();
+}
+		
+
diff --git a/src/common/MetaData.h b/src/common/MetaData.h
new file mode 100644
index 0000000..fd05689
--- /dev/null
+++ b/src/common/MetaData.h
@@ -0,0 +1,143 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MetaData.h
+    \brief Definition of the Template class MetaData.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan-2006
+
+*/
+
+#ifndef MetaData_H
+#define MetaData_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+#include "MetaDataAttributes.h"
+#include "VectorOfPointers.h"
+#include "BasicSceneObject.h"
+
+namespace magics {
+	
+class MetaDataEntry 
+{
+public: 
+	MetaDataEntry(const string& data) : data_(data) {}
+	virtual ~MetaDataEntry() {}
+	
+protected:
+	string data_;
+	 virtual void print(ostream& s) const { s << data_; } 
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MetaDataEntry& p)
+		{ p.print(s); return s; }
+};
+
+typedef  VectorOfPointers<vector<MetaDataEntry*> > MetaDataEntryList;
+
+class MetaDataVisitor: public MetaDataAttributes, public MetaDataEntryList, public BasicSceneObject {
+
+public:
+	MetaDataVisitor();
+	virtual ~MetaDataVisitor();
+
+    virtual void set(const XmlNode& node) {
+        MetaDataAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+    	 MetaDataAttributes::set(map);
+    }
+    virtual MetaDataVisitor* clone() const {
+
+        MetaDataVisitor* object = new MetaDataVisitor();
+        object->copy(*this);
+        return object;
+    }
+
+    void collectMetaData();
+    
+    void add(MetaDataEntry* entry) { MetaDataEntryList::push_back(entry); }
+    void add(const string& key, const string& value) {web_.insert(make_pair(key, value)); }
+    void metadata(map<string,string>&);
+
+    virtual void close(); 
+    
+    static void collect();
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 map<string, string> web_;
+	 static vector<MetaDataVisitor*> meta_;
+private:
+    //! Copy constructor - No copy allowed
+	MetaDataVisitor(const MetaDataVisitor&);
+    //! Overloaded << operator to copy - No copy allowed
+	MetaDataVisitor& operator=(const MetaDataVisitor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MetaDataVisitor& p)
+		{ p.print(s); return s; }
+};
+
+class MetaData: public MetaDataVisitor
+{
+public:
+    MetaData() {}
+    ~MetaData() {}
+	MetaDataVisitor* clone() const {
+        return new MetaData();
+    }
+};
+
+class NoMetaData: public MetaDataVisitor
+{
+public:
+    NoMetaData() {}
+    ~NoMetaData() {}
+	MetaDataVisitor* clone() const {
+        return new NoMetaData();
+    }
+    virtual void close() {}
+    virtual void visit(BasicGraphicsObjectContainer&) {}
+};
+
+template <>
+class MagTranslator<string, MetaDataVisitor> { 
+public:
+	MetaDataVisitor* operator()(const string& val )
+	{
+		return SimpleObjectMaker<MetaDataVisitor>::create(val);
+	}
+
+	MetaDataVisitor* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Mutex.cc b/src/common/Mutex.cc
new file mode 100644
index 0000000..5034c19
--- /dev/null
+++ b/src/common/Mutex.cc
@@ -0,0 +1,102 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+#ifndef Mutex_H
+#include "Mutex.h"
+#endif
+
+#ifndef MagExceptions_H
+#include "MagExceptions.h"
+#endif
+
+#include <errno.h>
+
+
+#if 0
+static int _tc(int a, const char* m)
+{
+	
+	return a;
+}
+
+#undef THRCALL
+#define THRCALL(a) _tc(a,#a)
+#endif
+
+
+Mutex::Mutex(char tag) :
+	exists_(false),
+	tag_(tag)
+{
+
+#if defined(__GNUC__) && __GNUC__ < 3
+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP { PTHREAD_MUTEX_RECURSIVE_NP }
+#endif
+	pthread_mutexattr_t attr = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+#else
+	pthread_mutexattr_t attr;
+	THRCALL(::pthread_mutexattr_init(&attr));
+	THRCALL(::pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE));
+#endif
+
+	THRCALL(pthread_mutex_init(&mutex_,&attr));
+
+	exists_ = true;
+	THRCALL(::pthread_mutexattr_destroy(&attr));
+}
+
+Mutex::~Mutex() 
+{
+	THRCALL(pthread_mutex_destroy(&mutex_));
+}
+
+void Mutex::lock(void) 
+{
+
+	if(!this || !exists_)
+	{
+		cerr << "Mutex used before being contructed" << endl;
+		return;
+	}
+
+	THRCALL(pthread_mutex_lock(&mutex_)); 
+}
+
+void Mutex::unlock(void) 
+{
+	if(!exists_)
+	{
+		cerr << "Mutex used before being contructed" << endl;
+		return;
+	}
+	THRCALL(pthread_mutex_unlock(&mutex_));
+}
+
+//=============================================================
+
+static Mutex globalMutex;
+
+Mutex& Mutex::global()
+{
+	return globalMutex;
+}
diff --git a/src/common/Mutex.h b/src/common/Mutex.h
new file mode 100644
index 0000000..9c7f41a
--- /dev/null
+++ b/src/common/Mutex.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Mutex.h
+// Baudouin Raoult - ECMWF May 96
+
+#ifndef Mutex_H
+#define Mutex_H
+
+#ifdef machine_H
+#define marsmachine_H
+#endif
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+class Mutex {
+public:
+
+// -- Contructors
+
+	Mutex(char tag = ' ');
+
+// -- Destructor
+
+	~Mutex();
+
+// -- Methods
+
+	void lock();
+	void unlock();
+	char tag() const { return tag_; }
+
+// -- Class methods
+
+	static Mutex& global();
+
+private:
+
+// No copy allowed
+
+	Mutex(const Mutex&);
+	Mutex& operator=(const Mutex&);
+
+protected:
+
+// -- Members
+
+	pthread_mutex_t mutex_;
+	bool            exists_;
+	char            tag_;
+
+};
+
+#endif
diff --git a/src/common/MutexCond.cc b/src/common/MutexCond.cc
new file mode 100644
index 0000000..d126652
--- /dev/null
+++ b/src/common/MutexCond.cc
@@ -0,0 +1,115 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include <time.h>
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+#ifndef MagLog_H
+#include "MagLog.h"
+#endif
+
+#ifndef MagExceptions_H
+#include "MagExceptions.h"
+#endif
+
+#ifndef MutexCond_H
+#include "MutexCond.h"
+#endif
+
+
+#define PTHREAD_INIT NULL
+
+MutexCond::MutexCond(char tag):
+	tag_(tag)
+{
+
+#if 0 
+// linux
+	pthread_mutexattr_t attr = XXXXXXXXXX;
+#else
+	pthread_mutexattr_t attr;
+	pthread_condattr_t  cattr;
+	THRCALL(::pthread_mutexattr_init(&attr));
+	THRCALL(::pthread_condattr_init(&cattr));
+#endif
+
+#ifdef DCE_THREADS
+	THRCALL(pthread_mutex_init(&mutex_,attr));
+	THRCALL(pthread_cond_init(&cond_,cattr));
+#else
+	THRCALL(pthread_mutex_init(&mutex_,&attr));
+	THRCALL(pthread_cond_init(&cond_,&cattr));
+#endif
+
+
+	inited_ = true;
+	THRCALL(::pthread_mutexattr_destroy(&attr));
+	THRCALL(::pthread_condattr_destroy(&cattr));
+}
+
+MutexCond::~MutexCond()
+{
+	THRCALL(pthread_mutex_destroy(&mutex_));
+
+	pthread_cond_destroy(&cond_); // Don't use THRCALL as some thread may be waiting for that condition
+	inited_ = false;
+}
+
+void MutexCond::lock()
+{
+	ASSERT(inited_);
+	THRCALL(pthread_mutex_lock(&mutex_));
+}
+
+void MutexCond::unlock()
+{
+	ASSERT(inited_);
+	THRCALL(pthread_mutex_unlock(&mutex_));
+}
+
+void MutexCond::wait()
+{
+	ASSERT(inited_);
+//	AutoState x('.');
+	THRCALL(pthread_cond_wait(&cond_,&mutex_));
+}
+
+bool MutexCond::wait(int sec)
+{
+	ASSERT(inited_);
+//	AutoState x(':');
+	timespec timeout = { ::time(0) + sec ,0};
+	int n = pthread_cond_timedwait(&cond_,&mutex_,&timeout);
+	if(n && n != ETIMEDOUT) THRCALL(n);
+	return n == ETIMEDOUT;
+}
+
+void MutexCond::signal()
+{
+	ASSERT(inited_);
+	pthread_cond_signal(&cond_);
+}
+
+void MutexCond::broadcast()
+{
+	ASSERT(inited_);
+	pthread_cond_broadcast(&cond_);
+}
diff --git a/src/common/MutexCond.h b/src/common/MutexCond.h
new file mode 100644
index 0000000..a3f8834
--- /dev/null
+++ b/src/common/MutexCond.h
@@ -0,0 +1,85 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************//******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File MutexCond.h
+// Baudouin Raoult - ECMWF Jun 96
+
+#ifndef MutexCond_H
+#define MutexCond_H
+
+#ifndef Mutex_H
+#include "Mutex.h"
+#endif
+
+// A mutex and a condition variable
+// for Producer/Consumer architectures
+
+class MutexCond {
+public:
+
+// -- Contructors
+
+	MutexCond(char tag = ' ');
+
+// -- Destructor
+
+	~MutexCond();
+
+// -- Methods
+
+	void lock();
+	void unlock();
+	void wait();
+	void signal();
+	void broadcast();
+	bool wait(int);
+	char tag() const { return tag_; }
+
+private:
+
+// No copy allowed
+
+	MutexCond(const MutexCond&);
+	MutexCond& operator=(const MutexCond&);
+
+// -- Members
+
+	pthread_mutex_t mutex_;
+	pthread_cond_t  cond_;
+	char tag_;
+	bool inited_;
+
+};
+
+#endif
diff --git a/src/common/Node.h b/src/common/Node.h
new file mode 100644
index 0000000..7ee99bb
--- /dev/null
+++ b/src/common/Node.h
@@ -0,0 +1,111 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Node.h
+    \brief Definition of the Template class Node.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 11-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Node_H
+#define Node_H
+
+#include "magics.h"
+
+#include "BaseSceneObject.h"
+#include "BasicGraphicsObject.h"
+#include "SuperPageAttributes.h"
+#include "XmlPageAttributes.h"
+
+   
+
+namespace magics {
+
+
+class FloatingNode : public BaseSceneObject
+{
+public:
+	FloatingNode() : layout_(0) {}
+	~FloatingNode() {}
+	
+	virtual void set(const map<string, string>&) 
+		{ MagLog::warning() << "set(const map<string, string>&) not implemented for " << *this << "\n"; }
+	virtual void set(const XmlNode&) 
+		{ MagLog::warning() << "set(const XmlNode&) not implemented for " << *this << "\n"; }
+	
+	Layout& getLayout()  { return *layout_; }
+	virtual void setFromFortran() {}
+protected: 
+	Layout* layout_;
+	
+};
+
+
+class FrameNode;
+
+class RootNode : public BaseSceneObject
+{
+public: 
+    RootNode();
+    ~RootNode();
+    virtual void set(const map<string, string>&);
+    virtual void set(const XmlNode&);
+    
+    // Ensure compatibilty width the old Magics, and fortran
+    virtual void set(const SuperPageAttributes&);
+    
+    // Ensure compatibility with the New Magics.
+    virtual void set(const XmlPageAttributes&);    
+    
+    void prepareGraphics();
+    
+    double getWidth() const    { return width_; }   
+    double getHeight() const   { return height_; }
+    inline double rootWidth() const  { return width_; }
+    inline double rootHeight() const { return height_; }
+    inline double absoluteX_() const  { return 0; }
+    inline double absoluteY_() const { return 0; }
+    BaseSceneObject* newXmlNode();
+    BaseSceneObject* newFortranNode();
+    BaseSceneObject* newMetviewNode(const SuperPageAttributes&);
+    Layout& getLayout();
+    void addChild(BaseSceneObject* child);
+    virtual void clear();
+    
+      
+protected:
+	virtual void print(ostream&) const;
+    FrameNode*           frameNode_;
+    double             width_;
+    double             height_;
+    FrameBase*           frame_;
+    MetaDataVisitor*            metaData_;
+    bool                 needsNewPage_;
+    
+    friend ostream& operator<<(ostream& s,const RootNode& p)
+		{ p.print(s); return s; }
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/common/OutputFactory.cc b/src/common/OutputFactory.cc
new file mode 100644
index 0000000..9d6ac78
--- /dev/null
+++ b/src/common/OutputFactory.cc
@@ -0,0 +1,267 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OutputFactory.cc
+    \brief Implementation of the Template class OutputFactory.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Wed July 2006
+*/
+
+#include "OutputFactory.h"
+#include "DriverManager.h"
+#include "PostScriptDriver.h"
+
+#ifdef MAGICS_RASTER
+#include "GDDriver.h"
+#endif
+
+
+using namespace magics;
+
+#ifdef MAGICS_RASTER
+GDDriver* GdOutputFactory::driver_ = 0;
+#endif
+PostScriptDriver* PS_PsOutputFactory::driver_ = 0;
+
+
+OutputFactory::OutputFactory() 
+{
+}
+
+OutputFactory::~OutputFactory() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void OutputFactory::print(ostream& out)  const
+{
+	out << "OutputFactory[";
+	out << "]";
+}
+
+void OutputFactory::set(DriverManager&, const XmlNode&)
+{
+}
+
+
+
+void PS_PsOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	if(!driver_)
+	{
+		driver_ = new PostScriptDriver();		
+		magics.push_back(driver_);
+	}
+	driver_->set(node);
+	driver_->setPS(true);
+}
+
+void  PS_PsOutputFactory::reset()
+{
+	if ( driver_ ) delete driver_;
+	driver_ = 0;
+}
+
+void  PS_PdfOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	if(!driver_)
+	{
+		driver_ = new PostScriptDriver();	
+		magics.push_back(driver_);
+	}
+	driver_->set(node);	
+	driver_->setPDF(true);
+}
+
+void PS_EpsOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	// Add a new PsDriver only for this purpose!
+	PostScriptDriver* driver = new PostScriptDriver();
+	driver->set(node);
+	driver->setEPS(true);
+	
+	magics.push_back(driver);
+}
+
+
+#ifdef MAGICS_RASTER
+void GD_GifOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	if( !driver_ )
+	{
+		driver_ = new GDDriver();
+		magics.push_back(driver_);
+	}
+	driver_->set(node);
+	driver_->setGIF(true);
+}
+
+void GD_PngOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	if ( !driver_ )
+	{
+		driver_ = new GDDriver();
+		magics.push_back(driver_);
+	}
+	
+	driver_->set(node);
+	driver_->setPNG(true);
+}
+
+void GD_JpegOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	if ( !driver_ ) {
+		driver_ = new GDDriver();
+		magics.push_back(driver_);
+	}
+	driver_->set(node);
+	driver_->setJPG(true);
+}
+
+void GD_GifAnimOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	GDDriver* driver = new GDDriver();
+	driver->set(node);
+	driver->setAnimation(true);
+
+	magics.push_back(driver);
+}
+
+void GdOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	driver_ = new GDDriver();
+	driver_->set(node);
+
+	magics.push_back(driver_);
+}
+
+void GdOutputFactory::reset()
+{
+	if ( driver_ ) delete driver_;
+	driver_ = 0;
+}
+#endif
+
+#include "BinaryDriver.h"
+void BinaryOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	BinaryDriver* driver = new BinaryDriver();
+	driver->set(node);
+
+	magics.push_back(driver);
+}
+
+#include "SVGDriver.h"
+void SVG_SvgOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	SVGDriver* driver = new SVGDriver();
+	driver->set(node);
+
+	magics.push_back(driver);
+}
+
+/*
+#ifdef MAGICS_QT
+#include "QtDriver.h"
+void QT_OutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	QtDriver* driver = new QtDriver();
+	driver->set(node);
+
+	magics.push_back(driver);
+}
+#endif
+*/
+
+#ifdef MAGICS_CAIRO
+#include "CairoDriver.h"
+void CAIRO_PdfOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setPDF();
+
+	magics.push_back(driver); 
+}
+
+void CAIRO_CairoOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setCairo();
+
+	magics.push_back(driver);
+}
+
+void CAIRO_PngOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setPNG();
+
+	magics.push_back(driver);
+}
+
+void CAIRO_PsOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setPS();
+
+	magics.push_back(driver);
+}
+
+void CAIRO_EpsOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setEPS();
+
+	magics.push_back(driver);
+}
+
+void CAIRO_SvgOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setSVG();
+	
+	magics.push_back(driver);
+}
+
+void CAIRO_XOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	CairoDriver* driver = new CairoDriver();
+	driver->set(node);
+	driver->setX();
+	
+	magics.push_back(driver);
+}
+#endif
+
+#include "KMLDriver.h"
+void KML_KmlOutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	KMLDriver* driver = new KMLDriver();
+	driver->set(node);
+
+	magics.push_back(driver);
+}
diff --git a/src/common/OutputFactory.h b/src/common/OutputFactory.h
new file mode 100644
index 0000000..a8ce890
--- /dev/null
+++ b/src/common/OutputFactory.h
@@ -0,0 +1,303 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OutputFactory.h
+    \brief Definition of the Template class OutputFactory.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Wed July-2006
+*/
+
+#ifndef OutputFactory_H
+#define OutputFactory_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+namespace magics {
+
+class DriverManager;
+class MagicsManager;
+class GDDriver;
+class PostScriptDriver;
+
+class OutputFactory {
+
+public:
+	OutputFactory();
+	virtual ~OutputFactory();
+
+	virtual void set(const XmlNode&)
+	{
+		MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+	}
+	virtual void set(const map<string, string>&)
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+	}
+	virtual OutputFactory* clone() const
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new OutputFactory();
+	}
+	virtual void set(DriverManager&, const XmlNode&); 
+	virtual void set(MagicsManager&) {} 
+	virtual void reset() {};
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	OutputFactory(const OutputFactory&);
+	//! Overloaded << operator to copy - No copy allowed
+	OutputFactory& operator=(const OutputFactory&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const OutputFactory& p)
+		{ p.print(s); return s; }
+};
+
+class BinaryOutputFactory : public OutputFactory
+{
+public:
+	BinaryOutputFactory() {}
+	virtual ~BinaryOutputFactory() {}
+	
+	virtual OutputFactory* clone() const {return new BinaryOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+
+class PS_PsOutputFactory : public OutputFactory
+{
+public:
+	PS_PsOutputFactory() {}
+	virtual ~PS_PsOutputFactory() { reset(); }
+	
+	virtual OutputFactory* clone() const
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new PS_PsOutputFactory();
+	}
+	virtual void set(DriverManager&, const XmlNode&); 
+	virtual void reset();
+protected:
+	static PostScriptDriver* driver_;
+};
+
+class PS_EpsOutputFactory : public PS_PsOutputFactory
+{
+public:
+	PS_EpsOutputFactory() {}
+	virtual ~PS_EpsOutputFactory() {}	
+	virtual OutputFactory* clone() const  { return new PS_EpsOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&);
+	
+};
+
+class PS_PdfOutputFactory : public PS_PsOutputFactory
+{
+public:
+	PS_PdfOutputFactory() {}
+	virtual ~PS_PdfOutputFactory() {}	
+	virtual OutputFactory* clone() const  { return new PS_PdfOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+
+#ifdef MAGICS_RASTER
+class GdOutputFactory : public OutputFactory
+{
+public:
+	GdOutputFactory() {}
+	virtual ~GdOutputFactory() { reset(); }
+	
+	virtual OutputFactory* clone() const {return new GdOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 	
+	virtual void reset();
+protected:
+	static GDDriver* driver_;
+};
+
+class GD_GifOutputFactory : public GdOutputFactory
+{
+public:
+	GD_GifOutputFactory() {}
+	virtual ~GD_GifOutputFactory() {}
+
+	virtual OutputFactory* clone() const { return new GD_GifOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+
+class GD_PngOutputFactory : public GdOutputFactory
+{
+public:
+	GD_PngOutputFactory() {}
+	virtual ~GD_PngOutputFactory() {}
+
+	virtual OutputFactory* clone() const  { return new GD_PngOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+class GD_JpegOutputFactory : public GdOutputFactory
+{
+public:
+	GD_JpegOutputFactory() {}
+	virtual ~GD_JpegOutputFactory() { reset(); }
+	
+	virtual OutputFactory* clone() const  { return new GD_JpegOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+
+class GD_GifAnimOutputFactory : public GdOutputFactory
+{
+public:
+	GD_GifAnimOutputFactory() {}
+	virtual ~GD_GifAnimOutputFactory() { reset(); }	
+	virtual OutputFactory* clone() const { return new GD_GifAnimOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&);
+};
+#endif
+
+class SVG_SvgOutputFactory : public OutputFactory
+{
+public:
+	SVG_SvgOutputFactory() {}
+	virtual ~SVG_SvgOutputFactory() {}
+	
+	virtual OutputFactory* clone() const {return new SVG_SvgOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+
+/*
+#ifdef MAGICS_QT
+class QT_OutputFactory : public OutputFactory
+{
+public:
+	QT_OutputFactory() {}
+	virtual ~QT_OutputFactory() {}	
+
+	virtual OutputFactory* clone() const { return new QT_OutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+#endif
+*/
+
+#ifdef MAGICS_CAIRO
+class CAIRO_PngOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_PngOutputFactory() {}
+	virtual ~CAIRO_PngOutputFactory() {}
+
+	virtual OutputFactory* clone() const { return new CAIRO_PngOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+class CAIRO_CairoOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_CairoOutputFactory() {}
+	virtual ~CAIRO_CairoOutputFactory() {}	
+
+	virtual OutputFactory* clone() const { return new CAIRO_CairoOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+
+class CAIRO_PdfOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_PdfOutputFactory() {}
+	virtual ~CAIRO_PdfOutputFactory() {}
+
+	virtual OutputFactory* clone() const  { return new CAIRO_PdfOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+class CAIRO_PsOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_PsOutputFactory() {}
+	virtual ~CAIRO_PsOutputFactory() {}
+
+	virtual OutputFactory* clone() const  { return new CAIRO_PsOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+class CAIRO_EpsOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_EpsOutputFactory() {}
+	virtual ~CAIRO_EpsOutputFactory() {}	
+	virtual OutputFactory* clone() const  { return new CAIRO_EpsOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+class CAIRO_SvgOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_SvgOutputFactory() {}
+	virtual ~CAIRO_SvgOutputFactory() {}	
+	virtual OutputFactory* clone() const  { return new CAIRO_SvgOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&);
+};
+
+class CAIRO_XOutputFactory : public OutputFactory
+{
+public:
+	CAIRO_XOutputFactory() {}
+	virtual ~CAIRO_XOutputFactory() {}
+	
+	virtual OutputFactory* clone() const  { return new CAIRO_XOutputFactory(); }    
+	virtual void set(DriverManager&, const XmlNode&);
+};
+#endif
+
+class KML_KmlOutputFactory : public OutputFactory
+{
+public:
+	KML_KmlOutputFactory() {}
+	virtual ~KML_KmlOutputFactory() {}
+	
+	virtual OutputFactory* clone() const {return new KML_KmlOutputFactory();}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+
+
+template <>
+class MagTranslator<string, OutputFactory> { 
+public:
+	OutputFactory* operator()(const string& val )
+	{
+		return SimpleObjectMaker<OutputFactory>::create(val);
+	}     
+
+	OutputFactory* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/OutputHandler.cc b/src/common/OutputHandler.cc
new file mode 100644
index 0000000..42d1319
--- /dev/null
+++ b/src/common/OutputHandler.cc
@@ -0,0 +1,100 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OutputHandler.cc
+    \brief Implementation of the Template class OutputHandler.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Wed July 2006
+*/
+
+#include "OutputHandler.h"
+#include "DriverManager.h"
+#include "OutputFactory.h"
+#include "XmlNode.h"
+
+using namespace magics;
+
+void OutputHandler::set(DriverManager& magics) 
+{
+	if ( formats_.empty() ) formats_.push_back(format_);
+
+	for ( vector<string>::const_iterator format = formats_.begin(); format != formats_.end(); ++format)
+	{
+		OutputFactory* factory = MagTranslator<string, OutputFactory>()(*format);
+		XmlNode node;
+		factory->set(magics, node); 
+		factories_.push_back(factory);
+	}
+}
+
+void OutputHandler::set(const XmlNode& node, DriverManager& magics) 
+{
+	try {
+		OutputFactory* factory = MagTranslator<string, OutputFactory>()(node.name());
+	
+		factory->set(magics, node); 
+		factories_.push_back(factory);
+	}
+	catch (...)
+	{
+	}
+}
+
+
+OutputHandler::~OutputHandler()
+{
+	for ( vector<OutputFactory* >::const_iterator factory = factories_.begin(); factory != factories_.end(); ++factory)
+		(*factory)->reset(); 
+}
+
+
+/*
+ This code was copied from OutputFactory.cc to hear to work in 
+ STATIC Magics++ libraries!
+*/
+static SimpleObjectMaker<PS_PsOutputFactory,   OutputFactory> ps("ps");
+static SimpleObjectMaker<PS_EpsOutputFactory, OutputFactory> eps("eps");
+static SimpleObjectMaker<PS_PdfOutputFactory,  OutputFactory> ps_pdf("ps_pdf");
+
+#ifdef MAGICS_RASTER
+#ifdef MAGICS_CAIRO
+static SimpleObjectMaker<GD_PngOutputFactory, OutputFactory> gdpng("gd_png");
+#else
+static SimpleObjectMaker<GD_PngOutputFactory, OutputFactory> gdpng("png");
+#endif
+static SimpleObjectMaker<GD_JpegOutputFactory, OutputFactory> jpeg("jpeg");
+static SimpleObjectMaker<GD_GifOutputFactory, OutputFactory> gif("gif");
+static SimpleObjectMaker<GD_GifAnimOutputFactory, OutputFactory> gif_anim("gif_animation");
+#endif
+
+static SimpleObjectMaker<SVG_SvgOutputFactory, OutputFactory> svg("svg");
+
+static SimpleObjectMaker<BinaryOutputFactory, OutputFactory> binary("mgb");
+
+#ifdef MAGICS_CAIRO
+static SimpleObjectMaker<CAIRO_PngOutputFactory,   OutputFactory> png("png");
+static SimpleObjectMaker<CAIRO_PdfOutputFactory,    OutputFactory> pdf("pdf");
+static SimpleObjectMaker<CAIRO_XOutputFactory,       OutputFactory> x("x");
+static SimpleObjectMaker<CAIRO_CairoOutputFactory,  OutputFactory> cairo("cairo");
+static SimpleObjectMaker<CAIRO_SvgOutputFactory,    OutputFactory> csvg("cairo_svg");
+static SimpleObjectMaker<CAIRO_PsOutputFactory,      OutputFactory> cps("cairo_ps");
+static SimpleObjectMaker<CAIRO_EpsOutputFactory,    OutputFactory> ceps("cairo_eps");
+#endif
+
+static SimpleObjectMaker<KML_KmlOutputFactory, OutputFactory> kml("kml");
diff --git a/src/common/OutputHandler.h b/src/common/OutputHandler.h
new file mode 100644
index 0000000..713b81d
--- /dev/null
+++ b/src/common/OutputHandler.h
@@ -0,0 +1,112 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OutputHandler.h
+    \brief Definition of the Template class OutputHandler.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Wed 19-Jul-2006
+    
+    Changes:
+    
+*/
+
+#ifndef OutputHandler_H
+#define OutputHandler_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "OutputFactory.h"
+#include "VectorOfPointers.h"
+
+#include "OutputHandlerAttributes.h"
+
+namespace magics {
+
+class XmlNode;
+class DriverManager;
+
+
+class OutputHandler:  public OutputHandlerAttributes {
+
+public:
+	OutputHandler() {}
+	virtual ~OutputHandler();
+    
+	virtual void set(const XmlNode& node)
+	{
+		OutputHandlerAttributes::set(node);
+	}
+	virtual void set(const map<string, string>& map)
+	{
+		OutputHandlerAttributes::set(map);
+	}
+	virtual OutputHandler* clone() const
+	{
+		return new OutputHandler();
+	}
+	virtual void toxml(ostream&, int = 0) const
+	{
+		MagLog::dev() << "OutputHandler::toxml(ostream&, int = 0)---> to be checked!...\n";
+	}
+	void set(DriverManager&);
+	
+	void set(const XmlNode& node, DriverManager&);
+	
+	void clear() { factories_.clear(); }
+	
+	
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "OutputHandler[]\n"; } 
+	 VectorOfPointers<vector<OutputFactory* > > factories_;
+
+private:
+	//! Copy constructor - No copy allowed	VectorOfPointers<OutputFactory* > factories_;
+
+	OutputHandler(const OutputHandler&);
+	//! Overloaded << operator to copy - No copy allowed
+	//OutputHandler& operator=(const OutputHandler&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const OutputHandler& p)
+		{ p.print(s); return s; }
+};
+
+template <>
+class MagTranslator<string, OutputHandler> { 
+public:
+	OutputHandler* operator()(const string& val )
+	{
+		return SimpleObjectMaker<OutputHandler>::create(val);
+	}     
+
+	OutputHandler* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/OutputHandlerAttributes.h b/src/common/OutputHandlerAttributes.h
new file mode 100644
index 0000000..85dd677
--- /dev/null
+++ b/src/common/OutputHandlerAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file OutputHandlerAttributes.h
+    \brief Definition of OutputHandler Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef OutputHandlerAttributes_H
+#define OutputHandlerAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class OutputHandlerAttributes 
+{
+public:
+//  --  constructor
+    OutputHandlerAttributes();
+    
+//  --  destructor
+    virtual ~OutputHandlerAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const OutputHandlerAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string format_;
+	stringarray formats_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const OutputHandlerAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/PageID.cc b/src/common/PageID.cc
new file mode 100644
index 0000000..8cd95a3
--- /dev/null
+++ b/src/common/PageID.cc
@@ -0,0 +1,119 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PageID.h
+    \brief Implementation of the Template class PageID.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 29-Mar-2004
+    
+    Changes:
+    
+*/
+
+#include "PageID.h"
+#include "Text.h"
+#include "PaperPoint.h"
+#include "System.h"
+#include "Transformation.h"
+using namespace magics;
+
+PageID::PageID() 
+{
+}
+
+PageID::~PageID() 
+{
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void PageID::print(ostream& out)  const
+{
+	out << "PageID[";
+	out << "]";
+}
+
+
+NoPageID* PageID::clone() const
+{
+	PageID* id = new PageID();
+	
+	id->copy(*this);
+	return id;
+}
+
+/*!
+ Method generating the ID string and send it. The logo is NOT plotted here. 
+ 
+ \sa UserMagLogoPlotting MagLogoPlotting
+ 
+ \todo Do we need to add errors?
+ \todo We always plot 'getMagicsVersionString()' is this right?
+ \todo Is vertical alignement middle not better?
+*/
+void PageID::visit(BasicGraphicsObjectContainer& out)
+{
+	char* regression = getenv("MAGPLUS_REGRESSION");
+	if ( regression )
+		return;
+
+    SystemInfo info;
+    ostringstream text;
+    string sep;
+
+    if ( magics_) {
+    	text << getMagicsVersionString();
+    	sep = " - ";
+    }
+    if ( system_ ) {
+    	text << sep << info.getHostName() << " - " << info.getUserID();
+    	sep = " - ";
+    }
+    if ( date_ )  {
+    	text << sep  << info.getTime();
+    	sep = " - ";
+    }
+
+    if ( text_ && user_text_ != "" )   text << sep << user_text_;
+
+    Text* id = new Text();
+
+    MagFont font(font_);
+    font.style(font_style_);
+    font.size(PageIDAttributes::height_);
+    font.colour(*colour_);
+
+    id->addText(text.str(), font);
+    id->setJustification(MLEFT);
+    id->setVerticalAlign(MHALF);
+
+    const double y = (PageIDAttributes::height_ /out.absoluteHeight())*100; 	 
+    // Line position  0.5 cm/ 0.5cm...
+    const double x = 2.5; //  in % of the page
+
+    id->push_back(PaperPoint(x, y));
+
+    out.push_back(id);
+    (*logo_)(out);
+}
+
+
diff --git a/src/common/PageID.h b/src/common/PageID.h
new file mode 100644
index 0000000..7abaadc
--- /dev/null
+++ b/src/common/PageID.h
@@ -0,0 +1,134 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PageID.h
+    \brief Definition of the Template class PageID.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 29-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef PageID_H
+#define PageID_H
+
+#include "magics.h"
+#include "PageIDAttributes.h"
+#include "BasicSceneObject.h"
+
+
+namespace magics {
+
+
+
+class NoPageID: public BasicSceneObject {
+
+public:
+	NoPageID() {}
+	virtual ~NoPageID() {}
+
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "PageIDBase::set(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "PageIDBase::set(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) {
+    	return false;
+    }
+    virtual NoPageID* clone() const {
+        MagLog::dev() << "NoPageID::set(const map<string, string&)---> to be checked!...\n";
+        return new NoPageID();
+    }
+    virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << "NoPageID::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+    }
+    virtual bool needLegend() { return false; }
+    virtual void visit(BasicGraphicsObjectContainer& ) {}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "NoPageID\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	NoPageID(const NoPageID&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoPageID& operator=(const NoPageID&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoPageID& p)
+		{ p.print(s); return s; }
+
+};
+
+class PageID: public NoPageID, public PageIDAttributes {
+
+public:
+	PageID();
+	virtual ~PageID();
+	virtual void set(const map<string, string>& map) 
+		{ PageIDAttributes::set(map); }
+    virtual void set(const XmlNode& node) 
+		{ PageIDAttributes::set(node); }
+	 virtual bool accept(const string& node) 
+	    { return PageIDAttributes::accept(node); }
+	virtual void visit(BasicGraphicsObjectContainer& list);
+	virtual NoPageID* clone() const;
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+
+private:
+	//! Copy constructor - No copy allowed
+	PageID(const PageID&);
+	//! Overloaded << operator to copy - No copy allowed
+	PageID& operator=(const PageID&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PageID& p)
+		{ p.print(s); return s; }
+};
+
+
+template <>
+class MagTranslator<string, NoPageID>
+{
+public:
+	NoPageID* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoPageID>::create(val);
+	}
+
+	NoPageID* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/PageIDAttributes.h b/src/common/PageIDAttributes.h
new file mode 100644
index 0000000..c3de7e3
--- /dev/null
+++ b/src/common/PageIDAttributes.h
@@ -0,0 +1,93 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file PageIDAttributes.h
+    \brief Definition of PageID Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef PageIDAttributes_H
+#define PageIDAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "LogoPlotting.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class PageIDAttributes 
+{
+public:
+//  --  constructor
+    PageIDAttributes();
+    
+//  --  destructor
+    virtual ~PageIDAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const PageIDAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double height_;
+	auto_ptr<Colour> colour_;
+	bool magics_;
+	string user_text_;
+	bool system_;
+	bool date_;
+	bool errors_;
+	bool text_;
+	auto_ptr<NoLogoPlotting> logo_;
+	string font_;
+	string font_style_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const PageIDAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/PaperDimension.h b/src/common/PaperDimension.h
new file mode 100644
index 0000000..972dd00
--- /dev/null
+++ b/src/common/PaperDimension.h
@@ -0,0 +1,126 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PaperDimension.h
+    \brief Definition of the Template class PaperDimension.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 14-Jun-2005
+    
+    Changes:
+    
+*/
+
+#ifndef PaperDimension_H
+#define PaperDimension_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+namespace magics {
+
+class PaperDimension  {
+
+public:
+	PaperDimension() {}
+	virtual ~PaperDimension() {}
+    void setOrientation(string orientation) { landscape_ = magCompare(orientation, "landscape"); } 
+    
+    
+    double getWidth()  { return (landscape_) ? largeDimension_ : smallDimension_;  }
+    double getHeight() { return (landscape_) ? smallDimension_ : largeDimension_; }	
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const = 0; 
+	 
+	 
+	 bool landscape_;
+	 double smallDimension_;
+	 double largeDimension_;
+
+private:
+    //! Copy constructor - No copy allowed
+	PaperDimension(const PaperDimension&);
+    //! Overloaded << operator to copy - No copy allowed
+	PaperDimension& operator=(const PaperDimension&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PaperDimension& p)
+		{ p.print(s); return s; }
+
+};
+
+class A6 : public PaperDimension
+{
+public:
+	A6() { smallDimension_ = 10.5; largeDimension_ = 14.8; }
+	~A6() {} 
+protected: 
+	virtual void print(ostream& out ) const { out << "format=a6[10.5,29.7]"; } 
+};
+
+class A5 : public PaperDimension
+{
+public:
+	A5() { smallDimension_ = 14.8; largeDimension_ = 21.; }
+	~A5() {} 
+protected: 
+	virtual void print(ostream& out ) const { out << "format=a5[14.8,21.]"; } 
+};
+
+class A4 : public PaperDimension
+{
+public:
+	A4() { smallDimension_ = 21.; largeDimension_ = 29.7; }
+	~A4() {} 
+protected: 
+	virtual void print(ostream& out ) const { out << "format=a4[21.,29.7]"; } 
+};
+
+class A3 : public PaperDimension
+{
+public:
+	 A3() { smallDimension_ = 29.7; largeDimension_ = 42.; }
+	~A3() {} 
+protected: 
+	virtual void print(ostream& out ) const { out << "format=a3[29.7,42.]"; } 
+};
+
+template<>
+class MagTranslator<string, PaperDimension> { 
+public:
+	PaperDimension* operator()(const string& val )
+	{
+		return SimpleObjectMaker<PaperDimension>::create(val);
+	}     
+
+	PaperDimension* magics(const string& param)
+	{
+		PaperDimension* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/common/PaperPoint.h b/src/common/PaperPoint.h
new file mode 100644
index 0000000..ac21662
--- /dev/null
+++ b/src/common/PaperPoint.h
@@ -0,0 +1,120 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PaperPoint.h
+    \brief Definition of Point (x, y, z, v).
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#ifndef PaperPoint_H
+#define PaperPoint_H
+
+#include "magics.h"
+
+
+
+namespace magics {
+
+
+class PaperPoint  {
+
+public:
+	PaperPoint(double x, double y, double value = 0, bool missing = false, bool border=false, int range = 0) :
+		x_(x), y_(y), value_(value), range_(range), high_(false), low_(false),
+		missing_(missing), border_(border) {}
+	//~PaperPoint() {}
+	PaperPoint() : x_(0), y_(0), value_(0), high_(false), low_(false), 
+		missing_(false), border_(false) {}
+	
+	void y(double y) { y_ = y; }
+	void x(double x) { x_ = x; }
+	
+    bool operator <(const PaperPoint& other) const
+    {
+    	if ( same(y_, other.y_)) return ( x_ < other.x_ );
+    	return  ( y_ < other.y_ );
+
+    }
+    
+	inline double y() const     { return y_; }
+	inline double x() const     { return x_; }
+	inline double value() const { return value_; }
+	inline int range() const { return range_; }
+	
+	void flagMissing()          { missing_ = true; }
+	void flagBorder()          { border_ = true; }
+	bool missing() const        { return missing_; }
+	bool border() const        { return border_; }
+	bool ignore() const          { return missing_ || border_; }
+	
+	bool operator==(const PaperPoint& other) const
+	{
+		return (  same(x_, other.x()) && same(y_, other.y()) );
+	}
+
+	double x_;
+	double y_;
+	double value_;
+	int       range_;
+	bool in(double left, double right, double bottom, double top) const
+	{
+		if (y_ > top)
+			return false;
+		if (y_ < bottom)
+			return false;
+		if (x_ < left)
+			return false;
+		if (x_ > right)
+			return false;
+		return true;
+	}
+	void high(bool high) { high_ = high; }
+	void low(bool low)   { low_ = low; }
+	bool high() const { return high_; }
+	bool low() const { return low_; }
+	double distance(const PaperPoint& other) const;
+
+protected:
+    bool high_;
+	bool low_;
+	bool missing_;
+	bool border_;
+	
+	void print(ostream& out) const
+	{ 
+		out << "PaperPoint[";
+		out << x_ << "(x), ";
+		out << y_ << "(y)]";
+	}
+
+private:
+	
+// -- Friends
+	friend ostream& operator<<(ostream& s,const PaperPoint& p)
+		{ p.print(s); return s; }
+};
+
+
+}
+
+#endif
diff --git a/src/common/ParameterManager.cc b/src/common/ParameterManager.cc
new file mode 100644
index 0000000..2da6368
--- /dev/null
+++ b/src/common/ParameterManager.cc
@@ -0,0 +1,62 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ParameterManager.cc
+ Magics Team - ECMWF 2004
+
+*/
+
+#include "ParameterManager.h"
+#include "VectorOfPointers.h"
+
+using namespace magics;
+
+ParameterManager* ParameterManager::table_ = 0;
+
+ParameterManager::ParameterManager() 
+{
+}
+
+
+ParameterManager::~ParameterManager() 
+{
+	
+}
+
+	
+void ParameterManager::print(ostream& out)  const
+{
+	out << "ParameterManager";
+	string sep = "[";
+	for (const_iterator entry = begin(); entry != end(); ++entry) { 
+		out << sep << (*(*entry).second);
+		sep = ",";
+	}
+	out << "]";
+}
+void ParameterManager::resetAll()
+{
+	for (iterator entry = begin(); entry != end(); ++entry) { 
+		entry->second->reset();
+	}
+}
+void  ParameterManager::add(const string& name, BaseParameter* param)  
+{
+	if ( !table_ )  table_ = new ParameterManager();
+	(*table_)[name] = param;
+}
diff --git a/src/common/ParameterManager.h b/src/common/ParameterManager.h
new file mode 100644
index 0000000..a90763c
--- /dev/null
+++ b/src/common/ParameterManager.h
@@ -0,0 +1,309 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ParameterManager.h
+    \brief Handles the Magics Parameters
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+    Changes:
+
+*/
+
+#ifndef ParameterManager_H
+#define ParameterManager_H
+
+#include <magics.h>
+#include <BaseParameter.h>
+#include <MagLog.h>
+#include <Factory.h>
+#include <MagException.h>
+
+
+namespace magics {
+
+
+class UnknownParameter : public MagicsException
+{
+public :
+    UnknownParameter(const string& name) :
+        MagicsException(name + ": unknown parameter, the call is ignored.")
+   {
+	MagLog::info() << "The parameter " << name << " is unknown in Magics++.\n"
+	            << "Please check the documentation or contact\n"
+	            << "the Meteorological Visualisation Section at ECMWF.\n";
+   }
+};
+
+
+class ParameterManager : public map<string, BaseParameter*>
+{
+public:
+	ParameterManager();
+	virtual ~ParameterManager();
+
+	static void add(const string&, BaseParameter*); 
+
+	template  <class T>
+	static void set(const string& name, const T& value)
+	{
+		assert(table_);
+		BaseParameter* param = (*table_).parameter(name);
+		if (param)
+		{
+			try {
+			    param->set(value);
+			}
+			catch (MagicsException& e)
+			{
+			    MagLog::warning() << "MagException > " << e << "\n";
+			}
+		}
+		else
+			MagLog::warning() << "The parameter " << name << " was not found.\n";
+	}
+
+	static void set(const string& name, const char* value)
+	{
+		assert(table_);
+		BaseParameter* param = (*table_).parameter(name);
+		if (param)
+			try {
+			    param->set(string(value));
+			}
+			catch (MagicsException& e)
+			{
+			    MagLog::warning() << "MagException > " << e << "\n";
+			}
+		else
+			MagLog::warning() << "The parameter " << name << " was not found.\n";
+	}
+	
+	static void setLocal(const BaseParameter* from)
+	{
+		assert(table_);
+		BaseParameter* param = (*table_).parameter(from->name());
+		if (param)
+			try {
+			    param->setLocal(from);
+			}
+			catch (MagicsException& e)
+			{
+			    MagLog::warning() << "MagException > " << e << "\n";
+			}
+		else
+			MagLog::warning() << "The parameter " << from->name() << " was not found.\n";
+	}
+
+	static void resetLocal(const string& name)
+	{
+		assert(table_);
+		BaseParameter* param = (*table_).parameter(name);
+		if (param)
+		{
+			try {
+			    param->resetLocal();
+			}
+			catch (MagicsException& e)
+			{
+			    MagLog::warning() << "MagException > " << e << "\n";
+			}
+		}
+		else
+			MagLog::warning() << "The parameter " << name << " was not found.\n";
+	}
+
+
+	static void reset(const string& name)
+	{
+		assert(table_);
+		BaseParameter* param = (*table_).parameter(name);
+		if (param) param->reset();
+	}
+
+	static void release()
+	{
+		if (table_) delete table_;
+	}
+
+	static BaseParameter* getCopy(const string& name)
+	{
+	     assert(table_);
+	     BaseParameter* param = (*table_).parameter(name);
+	     return (param) ? param->clone() : 0;
+	}
+
+	template <class T>
+	static void get(const string& name, T& value)
+	{
+		assert(table_);
+		BaseParameter* param = (*table_).parameter(name);
+		if (param) param->get(value);
+	}
+
+	static double getDouble(const string& name) 
+	{
+		double value;
+		get(name, value);
+		return value;
+	}
+
+	static int getInt(const string& name) 
+	{
+		int value;
+		get(name, value);
+		return value;
+	}
+
+	static string getString(const string& name) 
+	{
+		string value;
+		get(name, value);
+		return value;
+	}
+	static stringarray getStringArray(const string& name)
+		{
+			stringarray value;
+			get(name, value);
+			return value;
+		}
+	static doublearray getDoubleArray(const string& name)
+		{
+			doublearray value;
+			get(name, value);
+			return value;
+		}
+	static intarray getIntArray(const string& name)
+		{
+			intarray value;
+			get(name, value);
+			return value;
+		}
+
+	static bool getBool(const string& name)
+	{
+
+		string s;
+		get(name, s);
+		s = lowerCase(s);
+
+		if(s == "no" || s == "off" || s == "false") return false;
+		if(s == "yes"|| s == "on"  || s == "true")  return true;
+
+		// Catter for ints
+		return atoi(s.c_str());
+
+	}
+
+	template <class T>
+	static void update(const string& name, T*& object)
+	{
+		string val, def;
+
+		if (!table_) {
+     			MagLog::error() << "Problem in setting the parameter [" << name <<  "] ---> contact Magics team" << endl;
+		}
+		assert(table_);
+
+		BaseParameter* param = (*table_).parameter(name);
+		if (!param)
+		{
+			MagLog::warning() << "parameter \"" << name << "\" not found " << endl;
+			return;
+		}
+
+	#ifdef MAGICS_EXCEPTION
+		try {
+			param->get(val);
+			object = SimpleObjectMaker<T>::create(val);
+		}
+		catch (NoFactoryException& e)
+		{
+			param->reset();
+			param->get(def);
+			MagLog::warning() << "parameter \"" << name << "\" : value [" << val << "] is not valid ---> default [" << def <<  "] used" << endl;
+
+			try {
+				object = SimpleObjectMaker<T>::create(def);
+			}
+			catch (NoFactoryException& e2) {
+				MagLog::error() << "default [" << def <<  "] not found ---> contact Magics team" << endl;
+				throw e2;
+			}
+		}
+	#else
+		param->get(val);
+		object = SimpleObjectMaker<T>::create(val);
+
+		if (!object)
+		{
+			param->reset();
+			param->get(def);
+			MagLog::warning() << "parameter \"" << name << "\" : value [" << val << "] is not valid ---> default [" << def <<  "] used" << endl;
+			object = SimpleObjectMaker<T>::create(def);	
+			if (!object)
+			{
+				MagLog::error() << "default [" << def <<  "] not found ---> contact Magics team\n"
+				             << "Serious Error --> abort" << endl;
+				throw NoFactoryException("name");
+			}
+		}
+	#endif
+	}
+
+	void resetAll();
+
+	static void reset() {
+		if (table_)
+			table_->resetAll();
+	}
+
+protected:
+	virtual void print(ostream&) const;
+	static ParameterManager* table_;
+
+	BaseParameter* parameter(const string& name) const
+	{
+		string lower = lowerCase(name);
+		size_type pos = lower.find_first_of(" ");
+
+		string tofind = ( pos != string::npos) ? lower.substr(0,  pos) : lower;
+		const_iterator param = find(tofind); 
+		if ( param != end() )
+		{
+			return (*param).second;	
+		}
+		MagLog::info() << "The parameter " << name << " is unknown in Magics++.\n"
+		            << "Please check the documentation or contact\n"
+		            << "the Meteorological Visualisation Section at ECMWF.\n";
+		return 0;
+	}
+
+private:
+	// No copy allowed
+	ParameterManager(const ParameterManager&);
+	ParameterManager& operator=(const ParameterManager&);
+
+	// -- Friends
+	friend ostream& operator<<(ostream& s,const ParameterManager& p)
+		{ assert(table_); (*p.table_).print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Path.h b/src/common/Path.h
new file mode 100644
index 0000000..06e4b3a
--- /dev/null
+++ b/src/common/Path.h
@@ -0,0 +1,91 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Path
+// Sylvie Lamy-Thepaut - ECMWF Mar 02
+
+#ifndef Path_H
+#define Path_H
+
+
+#include "magics.h"
+#include "MagTranslator.h"
+
+
+namespace magics
+{
+	
+	
+class XmlNode;
+    
+class Path {
+
+public:
+	Path() {}
+	Path(const string& path) 
+    {
+        // remove the "white" space at the end of the string"
+        int index = path.find_last_not_of(" ");
+        path_ = path.substr(0, index+1);
+    }
+     void set(const map<string, string>&) {}
+     void set(const XmlNode&) {}
+     void toxml(ostream&, int)  const {}
+     Path* clone() const { return new Path(path_); }
+// -- Destructor
+	virtual ~Path() {}
+
+// -- Convertors
+	operator const string&() const { return path_;} 
+	operator const char*() const { return path_.c_str();}
+
+
+protected:
+	 virtual void print(ostream& out) const { out << "Path = " << path_; } 
+
+private:
+    string path_;
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const Path& p)
+		{ p.print(s); return s; }
+        
+
+};
+
+
+template<>
+class MagTranslator<string, Path> {
+public:
+	Path* operator()(string value)
+	{
+		return new Path(value);
+	}
+    
+    Path* magics(const string& param)
+    {
+        string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+    }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/PlotManager.h b/src/common/PlotManager.h
new file mode 100644
index 0000000..456fbd1
--- /dev/null
+++ b/src/common/PlotManager.h
@@ -0,0 +1,99 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PlotManager.h
+    \brief Definition of the Template class PlotManager.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef PlotManager_H
+#define PlotManager_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "MagicsManager.h"
+#include "Node.h"
+
+namespace magics {
+
+class XmlNode;
+
+class PlotManager : public stack<BaseSceneObject*> {
+
+public:
+	PlotManager();
+	virtual ~PlotManager();
+    
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual PlotManager* clone() { return new PlotManager(); }
+    void toxml(ostream&, int)  const {}
+    
+    virtual void superpage(MagicsManager&);
+    virtual void page(MagicsManager&);
+    virtual void subpage(MagicsManager&);
+    virtual void check(MagicsManager&);
+    virtual void addpage(MagicsManager&);
+    void addNode(MagicsManager&, BaseSceneObject* object);
+    void add(BaseSceneObject* object);
+
+    virtual void addRoot(MagicsManager&);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     bool page_;
+
+private:
+    //! Copy constructor - No copy allowed
+	PlotManager(const PlotManager&);
+    //! Overloaded << operator to copy - No copy allowed
+	PlotManager& operator=(const PlotManager&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PlotManager& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, PlotManager> { 
+public:
+	PlotManager* operator()(const string& val )
+	{
+		return SimpleObjectMaker<PlotManager>::create(val);
+	}     
+
+	PlotManager* magics(const string& param)
+	{
+		PlotManager* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/common/PointsHandler.cc b/src/common/PointsHandler.cc
new file mode 100644
index 0000000..4780096
--- /dev/null
+++ b/src/common/PointsHandler.cc
@@ -0,0 +1,172 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PointsHandler.h
+    \brief Definition of the Template class PointsHandler.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 20-Jan-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "magics.h"
+
+#include "PointsHandler.h"
+
+#include <stack>
+
+
+using namespace magics;
+
+
+
+
+
+
+
+    //! Method to set the current position to the first point.(abstract)    
+void BoxPointsHandler::setToFirst()  {
+	this->handler_.setToFirst();
+    	if (this->handler_.more() == false) {
+    		more_ = false;
+    		return;
+    	}
+
+    	advance(); 
+    	
+    }
+    
+
+    
+    //! Method to advance
+void BoxPointsHandler::advance()   {
+	    // First we delete the previous one.
+
+
+
+    	if ( !duplicates_.empty() ) {
+    		current_ = duplicates_.top();
+
+    		duplicates_.pop();
+    		more_ = true;
+    		return;
+    	}
+    	while ( this->handler_.more() ) {
+    		current_ = this->handler_.current();
+    		this->handler_.advance();
+    		
+    		transformation_.wraparound(current_, duplicates_);
+
+    		while ( !duplicates_.empty() ) {
+    			// point are falled msiing if they are our=tside the view!
+    			current_ = duplicates_.top();
+
+    			duplicates_.pop();
+    			if ( current_.missing() && filter_ ) // we go to the next point!
+    				continue;
+    			else {
+    				more_ = true;
+    				return;
+    			}
+    		}   	
+    	}
+    	more_ = false;
+    }
+  
+
+    //! Method to set the current position to the first point.(abstract)
+void ThinningPointsHandler::setToFirst()  {
+	   this->handler_.setToFirst();
+    	if ( this->handler_.more() == false ) {
+    		more_ = false;
+    		return;
+    	}
+
+
+    	    	current_ = this->handler_.current();
+
+    	    	xfreq_=std::max(1, xfreq_);
+    	    	yfreq_=std::max(1, yfreq_);
+    	    	// we have to prepare the list
+    	    	while ( this->handler_.more() ) {
+    	    		current_ = this->handler_.current();
+    	    		double x = current_.x();
+    	    		double y = current_.y();
+
+    	    		map<double, map<double, UserPoint> >::iterator row = data_.find(y);
+    	    		if ( row == data_.end() ) {
+    	    			data_.insert(make_pair(y, map<double, UserPoint>()));
+    	    			row = data_.find(y);
+    	    		}
+    	    		row->second.insert(make_pair(x, current_));
+
+    	    		this->handler_.advance();
+    	    	}
+    	    	y_ = data_.begin();
+
+
+    	    	if ( y_ == data_.end() ) {
+    	    		more_ = false;
+    	    		return;
+    	    	}
+    	    	x_ =  y_->second.begin();
+    	    	if ( x_ == y_->second.end() ) {
+    	    		more_ = false;
+    	    		return;
+    	    	}
+    	    	current_ = x_->second;
+    	    	more_ = true;
+    }
+
+
+
+    //! Method to advance
+void ThinningPointsHandler::advance()   {
+    	// look on the y_...
+    	int j = 0;
+    	while (j++ < xfreq_ ) {
+    		x_++;
+    		if ( x_ == y_->second.end() ) {
+    			int i = 0;
+    			while (i++ < yfreq_ ) {
+    				y_++;
+    				if ( y_ == data_.end() ) {
+    					more_ = false;
+    					return;
+    				}
+    				x_ = y_->second.begin();
+    			}
+    		}
+    	}
+    	if ( y_ == data_.end() || x_ ==  y_->second.end() ) {
+    		more_ = false;
+    		return;
+    	}
+
+    	more_ = true;
+    	current_ = x_->second;
+    }
+
+
+
+
diff --git a/src/common/PointsHandler.h b/src/common/PointsHandler.h
new file mode 100644
index 0000000..aca5ca0
--- /dev/null
+++ b/src/common/PointsHandler.h
@@ -0,0 +1,202 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PointsHandler.h
+    \brief Definition of the Template class PointsHandler.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 20-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef PointsHandler_H
+#define PointsHandler_H
+
+#include "magics.h"
+
+#include "BasePointsHandler.h"
+#include "Transformation.h"
+
+namespace magics {
+
+
+class PointsHandler: public AbstractPoints {
+
+public:
+	PointsHandler(AbstractPoints& handler):handler_(handler) {}
+	virtual ~PointsHandler() {}
+    //! Method to set the current position to the first point.(abstract)
+    virtual void setToFirst() { handler_.setToFirst(); }
+    //! Method to test the end of collection.
+    virtual bool more()        { return handler_.more(); }
+    //! Method to return the current value
+    virtual const UserPoint& current()  { return handler_.current(); }
+    //! Method to advance
+    virtual void advance()   { handler_.advance(); }
+    virtual bool empty()   {  handler_.setToFirst(); return handler_.more() == false; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "PointsHandler on " << handler_; }
+     AbstractPoints& handler_;
+
+private:
+    //! Copy constructor - No copy allowed
+	PointsHandler(const PointsHandler&);
+    //! Overloaded << operator to copy - No copy allowed
+	PointsHandler& operator=(const PointsHandler&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PointsHandler& p)
+		{ p.print(s); return s; }
+
+};
+
+class BatchPointsHandler : public PointsHandler
+{
+public:
+	BatchPointsHandler(AbstractPoints& handler, int count):
+		PointsHandler(handler),  count_(count), more_(0), last_(false) {}
+	virtual ~BatchPointsHandler() {}
+    //! Method to set the current position to the first point.(abstract)
+    virtual void setToFirst()  {}
+    //! Method to test the end of collection.
+    virtual bool more()
+    {
+         if ( last_ ) {
+            last_ = false;
+            return false;
+        }
+        //MagLog::debug() << "batch " << more_ << "\n";
+        if (more_++ < count_) return this->handler_.more();  
+       
+        last_ = true;
+        return true;
+    }
+    //! Method to return the current value
+    virtual const UserPoint& current()  { return this->handler_.current(); }
+    //! Method to advance
+    virtual void advance()   { this->handler_.advance(); }
+  
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "BatchPointsHandler(" << count_ << "items) on " << this->handler_; }
+ 
+     int count_;
+     mutable int more_;
+     mutable bool last_;
+     
+private:
+    //! Copy constructor - No copy allowed
+	BatchPointsHandler(const BatchPointsHandler&);
+    //! Overloaded << operator to copy - No copy allowed
+	BatchPointsHandler& operator=(const BatchPointsHandler&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BatchPointsHandler& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+class BoxPointsHandler : public PointsHandler
+{
+public:
+	BoxPointsHandler(AbstractPoints& handler, const Transformation& transformation, bool filter) :
+		PointsHandler(handler),
+		transformation_(transformation),
+		filter_(filter) {}
+	virtual ~BoxPointsHandler() {}
+	
+    //! Method to set the current position to the first point.(abstract)    
+    virtual void setToFirst() ;
+    
+    //! Method to test the end of collection.
+    virtual bool more()
+    {
+    	return more_;
+        
+    }
+    
+    //! Method to return the current value
+    virtual UserPoint& current()  { return current_; }
+    
+    //! Method to advance
+    virtual void advance() ;
+  
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "BocPointsHandler() on " << this->handler_; }
+    
+     const Transformation& transformation_;
+     mutable std::stack<UserPoint>            duplicates_;
+
+     mutable UserPoint               current_;
+     mutable bool more_;
+     bool filter_; // Do no send the point if they are outside the transformation view!
+
+};
+
+class ThinningPointsHandler : public PointsHandler
+{
+public:
+	ThinningPointsHandler(AbstractPoints& handler, int xfreq, int yfreq):
+		PointsHandler(handler),
+		xfreq_(xfreq), yfreq_(yfreq) {
+	}
+	virtual ~ThinningPointsHandler() {}
+
+    //! Method to set the current position to the first point.(abstract)
+    virtual void setToFirst();
+
+    //! Method to test the end of collection.
+    virtual bool more()
+    {
+    	return more_;
+
+    }
+
+    //! Method to return the current value
+    virtual const UserPoint& current()  { return current_; }
+
+    //! Method to advance
+    virtual void advance() ;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "BocPointsHandler() on " << this->handler_; }
+
+	 mutable int xfreq_;
+	 mutable int yfreq_;
+	 mutable map<double, map<double, UserPoint> > data_;
+	 map<double, map<double, UserPoint> >::iterator y_;
+	 map<double, UserPoint>::iterator x_;
+     mutable UserPoint               current_;
+     mutable bool more_;
+
+};
+    
+} // namespace magics
+
+#endif
diff --git a/src/common/PolarStereographicProjection.cc b/src/common/PolarStereographicProjection.cc
new file mode 100644
index 0000000..84218c8
--- /dev/null
+++ b/src/common/PolarStereographicProjection.cc
@@ -0,0 +1,1003 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreedto in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PolarStereographicProjection.cc
+    \brief Implementation of PolarStereographicProjection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Fri Jan 11 15:01:45 2008
+
+*/
+
+#include <PolarStereographicProjection.h>
+#include <BasicSceneObject.h>
+#include <GridPlotting.h>
+#include <LabelPlotting.h>
+#include <Text.h>
+#include <MatrixHandler.h>
+#include <MetaData.h>
+#include <ParameterSettings.h>
+#include <math.h>
+#include <MagJSon.h>
+
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+*/
+PolarStereographicProjection::PolarStereographicProjection()  : projection_(0)
+{
+}
+
+/*!
+  \brief Destructor
+*/
+PolarStereographicProjection::~PolarStereographicProjection()
+{
+	delete projection_;
+}
+
+void PolarStereographicProjection::print(ostream& out) const
+{
+	out << "PolarStereographicProjection[";
+	PolarStereographicProjectionAttributes::print(out);
+	out << "]"; 
+} 
+
+double PolarStereographicProjection::unitToCm(double width, double height) const
+{
+	// Reproject 2 point and find the unit
+	const int hemis = (hemisphere_ ==  NORTH) ? 1 : -1;
+
+	UserPoint ll1(0,  hemis*50);
+	UserPoint ll2(0,  hemis*51);
+	PaperPoint xy1 = (*this)(ll1);
+	PaperPoint xy2 = (*this)(ll2);
+	
+	const double unit = abs(xy1.y() - xy2.y());
+	const double wid  = getMaxPCY() - getMinPCY();
+	if (!zero(wid))	return unit*(height/wid);
+	return unit;
+}
+
+double PolarStereographicProjection::height() const { 
+	// Reproject 2 point and find the unit
+		int hemis = (hemisphere_ ==  NORTH) ? 1 : -1;
+		bool pole;
+		double height;
+		UserPoint ll(0,  hemis*90);
+		PaperPoint xy = (*this)(ll);
+
+		pole =  ( xy.x() > xpcmin_ && xy.x() < xpcmax_  && xy.y() > ypcmin_ && xy.y() < ypcmax_ );
+		
+		if ( !pole )  { 
+			height = (ymax_-ymin_); 
+		}
+		else {
+			if (hemisphere_ ==  NORTH) {
+				height = 180-ymax_-ymin_;
+			}
+			else {
+			 height = 180+ymax_+ymin_;
+			}
+		}
+	return height;
+}
+
+PaperPoint PolarStereographicProjection::operator()(const UserPoint& point)  const
+{
+	assert(projection_);
+
+	TeCoord2D geo = TeCoord2D(point.x()*TeCDR, point.y()*TeCDR);
+	TeCoord2D xy = projection_->LL2PC(geo);
+
+	return PaperPoint(xy.x(), xy.y(), point.value(), point.missing(), point.border());
+}
+
+
+
+PaperPoint PolarStereographicProjection::operator()(const PaperPoint& point)  const
+{
+	return Transformation::operator()(point);
+}
+
+void PolarStereographicProjection::revert(const vector<pair<double, double> > & in, vector<pair<double, double> > & out) const
+{
+	assert(projection_);
+	out.reserve(in.size());
+	for ( vector<pair<double, double> >::const_iterator pt = in.begin();  pt != in.end(); ++pt) {
+		TeCoord2D texy = TeCoord2D(pt->first, pt->second);
+		TeCoord2D geo = projection_->PC2LL(texy);
+		out.push_back(make_pair(geo.x()*TeCRD, geo.y()*TeCRD));
+	}
+}
+
+void PolarStereographicProjection::revert(const PaperPoint& xy, UserPoint& point)  const
+{
+	assert(projection_);
+	TeCoord2D texy = TeCoord2D(xy.x(), xy.y());
+	TeCoord2D geo = projection_->PC2LL(texy);
+  
+	point = UserPoint(geo.x()*TeCRD, geo.y()*TeCRD);
+}
+
+
+
+bool PolarStereographicProjection::needShiftedCoastlines()  const
+{
+	return false;
+}
+
+void PolarStereographicProjection::init(double width, double height)
+{
+	if ( !projection_ ) 
+		projection_ = new TePolarStereographic(TeDatum(), vertical_longitude_*TeCDR, 0., 0., "Meters", (hemisphere_ == NORTH) ? TeNORTH_HEM : TeSOUTH_HEM);
+	
+	if ( magCompare(area_, "full") ) {
+		ymin_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
+		ymax_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
+		xmin_ = ( hemisphere_ == NORTH ) ? -45. : 45.;
+		xmax_ = ( hemisphere_ == NORTH ) ? 135. : -135.;
+	}
+	else
+		magCompare(area_, "corners" ) ?  corners() : centre(width, height);
+	double llx, urx , lly , ury;
+		
+	if ( magCompare(system_, "projection") == false )
+	{
+		TeCoord2D ll = TeCoord2D(xmin_*TeCDR, ymin_*TeCDR);
+		TeCoord2D ur = TeCoord2D(xmax_*TeCDR, ymax_*TeCDR);
+
+		TeCoord2D llxy = projection_->LL2PC(ll);
+		TeCoord2D urxy = projection_->LL2PC(ur);
+    
+		TeCoord2D ell = TeCoord2D(-20*TeCDR, 40*TeCDR);
+		TeCoord2D exy = projection_->LL2PC(ell);
+    
+		ell = projection_->PC2LL(exy);
+    
+		// Create a grid 100/100 to calculate the corners ...
+     
+		llx = ::min(urxy.x(), llxy.x());
+		urx = ::max(urxy.x(), llxy.x());
+
+		if ( (urx - llx) < 10) {
+				urx = llx+10.;
+
+		}
+
+		lly = ::min(urxy.y(), llxy.y());
+		ury = ::max(urxy.y(), llxy.y());
+		if ( ( ury - lly ) < 10) {
+			ury = lly+10.;
+
+		}
+		xmin_ = DBL_MAX;
+		ymin_ = DBL_MAX;
+		xmax_ = DBL_MIN;
+		ymax_ = DBL_MIN;
+
+		double stepx= (urx - llx)/100.;
+		double stepy= (ury - lly)/100.;
+		for (double x = llx; x <= urx; x += stepx )
+		{
+		   for (double y = lly; y <= ury; y += stepy )
+		   {
+		       TeCoord2D xy(x, y);
+		       TeCoord2D ll = projection_->PC2LL(xy);
+		       double xx = ll.x()*TeCRD;
+		       double yy = ll.y()*TeCRD;
+
+		       if (xx < xmin_) xmin_ = xx;
+		       if (xx > xmax_) xmax_ = xx;
+		       if (yy < ymin_) ymin_ = yy;
+		       if (yy > ymax_) ymax_ = yy;
+		   }
+		}
+
+		if (xmax_ - xmin_ > 358)
+		{
+			// Wrap around!
+			xmax_=180;
+			xmin_=-180; 
+		}
+	
+		xpcmin_ = llx;
+		ypcmin_ = lly;
+		xpcmax_ = urx;
+		ypcmax_ = ury; 
+	}
+	else {
+		llx = ::min(xmin_, xmax_);
+		urx = ::max(xmin_, xmax_);
+		lly = ::min(ymin_, ymax_);
+		ury = ::max(ymin_, ymax_);
+		TeCoord2D llxy(llx, lly);
+		TeCoord2D ll = projection_->PC2LL(llxy); 
+		TeCoord2D urxy(urx, ury);
+		TeCoord2D  ur = projection_->PC2LL(urxy); 
+		         
+		xmin_ =  ::min(ll.x()*TeCRD, ur.x()*TeCRD);
+		xmax_ = ::max(ll.x()*TeCRD, ur.x()*TeCRD); 
+		ymin_ =  ::min(ll.y()*TeCRD, ur.y()*TeCRD);
+		ymax_ =  ::max(ll.y()*TeCRD, ur.y()*TeCRD);
+		double stepx= (urx - llx)/100.;
+		double stepy= (ury - lly)/100.;
+		for (double x = llx; x <= urx; x += stepx )
+		{
+		   for (double y = lly; y <= ury; y += stepy )
+		   {
+        		  TeCoord2D xy(x, y);
+        		  TeCoord2D ll = projection_->PC2LL(xy);
+        		  double xx = ll.x()*TeCRD;
+        		  double yy = ll.y()*TeCRD;
+
+        		  if (xx < xmin_) xmin_ = xx;
+        		  if (xx > xmax_) xmax_ = xx;
+        		  if (yy < ymin_) ymin_ = yy;
+        		  if (yy > ymax_) ymax_ = yy;
+		   }
+		}
+
+		if (xmax_ - xmin_ > 358)
+		{
+			// Wrap around!
+			xmax_=180;
+			xmin_=-180; 
+		}
+
+		xpcmin_ = llx;
+		ypcmin_ = lly;
+		xpcmax_ = urx;
+		ypcmax_ = ury; 
+
+		PCEnveloppe_->clear();
+
+		PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmin_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmax_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmax_, ypcmax_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmax_, ypcmin_));
+		PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmin_));
+
+		boost::geometry::correct(PCEnveloppe_->polygon_);
+
+
+		MagLog::dev() << " Projection definition-->[" << ymin_ << ", " << xmin_ << ", " << xmax_ << ", " << ymax_ << "]" << endl;
+	}
+}
+
+void PolarStereographicProjection::fill(double& width, double& height)  
+{  
+	init(width, height);
+	Transformation::fill(width, height);
+}
+
+void PolarStereographicProjection::aspectRatio(double& width, double& height)  
+{  
+	init(width, height);
+	Transformation::aspectRatio(width, height);
+}
+
+void PolarStereographicProjection::smallestBoundingBox(double& xmin, double& ymin, double& xmax, double& ymax)  const
+{
+		vector<pair<double, double> > geo;
+		vector<pair<double, double> > xy;
+
+		double xpcmax =  xpcmax_;
+		double xpcmin =  xpcmin_;
+		double ypcmax =  ypcmax_;
+		double ypcmin =  ypcmin_;
+
+		const double xs = (xpcmax- xpcmin)/99.;
+		const double ys = (ypcmax- ypcmin)/99.;
+		// Walk along the boundary...
+		double x,y;
+		for (int i = 0; i < 100; i++) {
+			x = xpcmin +(i*xs);
+			for (int i = 0; i < 100; i++) {
+				y = ypcmin +(i*ys);
+				xy.push_back(make_pair(x, y));
+			}
+		}
+		revert(xy, geo);
+		xmin=DBL_MAX;
+		xmax=DBL_MIN;
+		ymin=DBL_MAX;
+		ymax=DBL_MIN;
+
+		for (vector<pair<double, double> >::iterator point = geo.begin(); point != geo.end(); ++point) {
+			if ( xmin > point->first) xmin = point->first;
+			if ( xmax < point->first) xmax = point->first;
+			if ( ymin > point->second) ymin = point->second;
+			if ( ymax < point->second) ymax = point->second;
+			//userEnveloppe_->push_back(PaperPoint(point->first, point->second));
+		}
+
+
+}
+
+void PolarStereographicProjection::boundingBox(double& xmin, double& ymin, double& xmax, double& ymax)  const
+{
+	smallestBoundingBox(xmin, ymin, xmax, ymax);
+	xmin -= 5;
+	xmax += 5;
+	ymin -= 5;
+	ymax += 5;
+	
+	MagLog::dev() << " Projection bounding box-->[" << xmin << ", " << xmax << ", " << ymin << ", " << ymax << "]" << endl;
+}
+
+double PolarStereographicProjection::getMinX()  const
+{
+	return xmin_;
+}
+
+double PolarStereographicProjection::getMinY()  const
+{
+	return ymin_;
+}
+
+double PolarStereographicProjection::getMaxX()  const
+{
+	return xmax_;
+}
+
+double PolarStereographicProjection::getMaxY()  const
+{
+	return ymax_;
+}
+
+void PolarStereographicProjection::setMinX(double x)  
+{
+	MagLog::dev() << "PolarStereographicProjection::setMinX(...) needs implementing." << endl;
+	Transformation::setMinX(x);
+}
+
+void PolarStereographicProjection::setMinY(double y)  
+{
+	MagLog::dev() << "PolarStereographicProjection::setMinY(...) needs implementing." << endl;
+	Transformation::setMinY(y);
+}
+
+void PolarStereographicProjection::setMaxX(double x)  
+{
+	MagLog::dev() << "PolarStereographicProjection::setMaxX(...) needs implementing." << endl;
+	Transformation::setMaxX(x);
+}
+
+void PolarStereographicProjection::setMaxY(double y)  
+{
+	MagLog::dev() << "PolarStereographicProjection::setMaxY(...) needs implementing." << endl;
+	Transformation::setMaxY(y);
+}
+
+double PolarStereographicProjection::getMinPCX()  const
+{
+	return xpcmin_;
+}
+
+double PolarStereographicProjection::getMinPCY()  const
+{
+	return ypcmin_;
+}
+
+double PolarStereographicProjection::getMaxPCX()  const
+{
+	return xpcmax_;
+}
+
+double PolarStereographicProjection::getMaxPCY()  const
+{
+	return ypcmax_;
+}
+
+void PolarStereographicProjection::gridLongitudes(const GridPlotting& grid)  const
+{
+	const vector<double>& longitudes = grid.longitudes();
+	const vector<double>& latitudes = grid.latitudes();
+	for (vector<double>::const_iterator lon = longitudes.begin(); lon != longitudes.end(); ++lon)
+	{
+		if (*lon < xmin_ ) continue;
+		if (*lon > xmax_ ) continue;
+		Polyline poly;
+
+		double min = ::min(latitudes.front(), latitudes.back());
+		double max = ::max(latitudes.front(), latitudes.back());
+		
+
+		for (double lat = min; lat <= max; lat += 1) {
+			poly.push_back((*this)(UserPoint(*lon,lat)));
+		}  
+		grid.add(poly);     
+	}
+}
+
+void PolarStereographicProjection::gridLatitudes(const GridPlotting& grid)  const
+{
+	const vector<double>& latitudes = grid.latitudes();
+	for (vector<double>::const_iterator lat = latitudes.begin(); lat != latitudes.end(); ++lat)
+	{
+		if (*lat < ymin_ ) continue;
+		if (*lat > ymax_ ) continue;
+	    Polyline poly;        
+
+            for (int lon = -180; lon <= 180; lon += 1) {
+                poly.push_back((*this)(UserPoint(lon,*lat)));
+                
+            }	
+	    grid.add(poly);        
+	}
+}
+
+inline double CA(TeCoord2D& p1, TeCoord2D& p2)
+{
+    return (p2.x() - p1.x()) ? (p2.y() - p1.y())/(p2.x() - p1.x()) : 0;
+}
+
+inline double CB(double a, TeCoord2D& p)
+{
+    return p.y() - a * p.x();
+}
+
+inline double CX(double a, double b, double y)
+{
+    return (a) ? (y - b)/a : 0;
+}
+
+inline double CY(double a, double b, double x)
+{
+    return (a * x) + b;
+}
+
+void PolarStereographicProjection::horizontalLabels(const LabelPlotting& label, double y, double yy, bool top) const
+{
+	double xmin, ymin, xmax, ymax;
+	boundingBox(xmin, ymin, xmax,ymax);
+
+	vector<double> done;
+    const vector<double>& longitudes = label.longitudes();
+    for (vector<double>::const_iterator lon = longitudes.begin(); lon != longitudes.end(); ++lon)
+    {
+     	// find the equation of the line using 2 points : lon/-20 -->lon/ +20
+        TeCoord2D p1 = TeCoord2D((*lon)*TeCDR, 20*TeCDR);
+        TeCoord2D p2 = TeCoord2D((*lon)*TeCDR, -20*TeCDR);
+
+        TeCoord2D p1xy = projection_->LL2PC(p1);
+        TeCoord2D p2xy = projection_->LL2PC(p2);
+
+        double a = CA(p1xy, p2xy);
+        double b = CB(a, p1xy);
+            
+        TeCoord2D xy = TeCoord2D(CX(a, b, y), y);   
+
+        PaperPoint point(CX(a, b, y), y);
+
+        if ( !in(point) ) continue;
+        bool add = true;
+        for ( vector<double>::iterator x = done.begin(); x != done.end(); ++x) {
+        	if ( same(*x, point.x_ ) ) {
+        		add = false;
+        		break;
+        	}
+        }
+
+        if ( !add ) continue;
+        done.push_back(point.x_);
+    	UserPoint geo;
+       	revert(point, geo);
+       	point.y(yy);
+
+        Text* text = new Text();
+        text->setJustification(MCENTRE);
+        text->setVerticalAlign(MBOTTOM);
+        text->setVerticalAlign(top ? MBOTTOM : MTOP);
+        label.add(text);
+        text->setText(writeLongitude(geo));
+        text->push_back(point);
+			
+
+     }
+}
+
+/*!
+ Method to draw vertical labels.
+ 
+ \sa LeftAxisVisitor RightAxisVisitor
+ 
+*/
+void PolarStereographicProjection::verticalLabels(const LabelPlotting& label, double x, double xx, bool left)  const
+{
+    const vector<double>& longitudes = label.longitudes();
+
+    vector<double> done;
+    for (vector<double>::const_iterator lon = longitudes.begin(); lon != longitudes.end(); ++lon)
+    {
+        // find the equation of the line using 2 points : lon/-20 -->lon/ +20
+        TeCoord2D p1 = TeCoord2D((*lon)*TeCDR, 20*TeCDR);
+        TeCoord2D p2 = TeCoord2D((*lon)*TeCDR, -20*TeCDR);
+
+        TeCoord2D p1xy = projection_->LL2PC(p1);
+        TeCoord2D p2xy = projection_->LL2PC(p2);
+    
+        double a = CA(p1xy, p2xy);
+        double b = CB(a, p1xy);
+        if ( !a ) continue; // parallele line!
+        
+        TeCoord2D xy = TeCoord2D(x, CY(a, b, x) );       
+
+        PaperPoint point(x, CY(a, b, x));
+        if ( !in(point) ) continue;
+        bool add = true;
+        for ( vector<double>::iterator x = done.begin(); x != done.end(); ++x) {
+            if ( same(*x, point.y_ ) ) {
+                add = false;
+                break;
+             }
+         }
+
+         if ( !add ) continue;
+         done.push_back(point.y_);
+
+         UserPoint geo;
+         revert(point, geo);
+         point.x(xx);
+
+
+        Text* text = new Text();
+        label.add(text);
+        text->setJustification(left ? MRIGHT: MLEFT);
+        text->setVerticalAlign(MHALF);    
+        text->setText(writeLongitude(geo));
+        text->push_back(point);
+	
+
+     }
+}
+
+
+void PolarStereographicProjection::labels(const LabelPlotting& label, DrawingVisitor& )  const
+{
+	Text *text;
+	const vector<double>& latitudes = label.latitudes();
+	//const vector<double>& longitudes = label.longitudes();
+	vector<double> longitudes;
+	longitudes.push_back(0);
+	unsigned int flat = (unsigned int) std::max(1, (int) maground(latitudes.size()/4));
+	unsigned int flon = (unsigned int) std::max(1, (int) maground(longitudes.size()/4));
+
+	for (unsigned int lat = 0; lat < latitudes.size(); lat += flat)
+	{  
+	    for (unsigned int lon = 0 ; lon < longitudes.size(); lon += flon)
+	    { 	   
+	   	   UserPoint point(longitudes[lon],latitudes[lat]);
+	   	   PaperPoint xy = (*this)(point);
+	   	   
+	   	   if ( !in(xy) ) continue;	   
+	   
+	   	   text = new Text();
+	   	   label.add(text); // This will set the font!
+	   	   text->setText(writeLatitude(point));
+	       text->push_back(xy);
+	       text->setBlanking(true);
+
+	    }
+	}
+}
+
+void PolarStereographicProjection::labels(const LabelPlotting& label, TopAxisVisitor&)  const
+{
+	// Find intersection of the latitude line  with the top!
+	// Y = top
+
+	const double yy = ypcmin_ + ( ( ypcmax_ - ypcmin_  )*0.1);
+	horizontalLabels(label, ypcmax_, yy, true);
+}
+
+void PolarStereographicProjection::labels(const LabelPlotting& label, BottomAxisVisitor&)  const
+{
+	// Find intersection of the latitude line  with the bottom!
+	// Y = bottom
+     
+	const double yy = ypcmax_ - ( ( ypcmax_ - ypcmin_  )*0.1);
+	horizontalLabels(label, ypcmin_, yy, false);
+}
+
+void PolarStereographicProjection::labels(const LabelPlotting& label, LeftAxisVisitor&)  const
+{
+	// Find intersection of the latitude line  with the left!
+	// X = left
+    
+	const double xx = xpcmax_ - ( ( xpcmax_ - xpcmin_  )*0.1);
+	verticalLabels(label, xpcmin_, xx, true);
+}
+
+void PolarStereographicProjection::labels(const LabelPlotting& label, RightAxisVisitor& )  const
+{
+	// Find intersection of the latitude line  with the right!
+	// X = right
+	
+	const double xx = xpcmin_ + ( ( xpcmax_ - xpcmin_  )*0.1);
+	verticalLabels(label, xpcmax_, xx, false);
+}
+
+/*!
+ This method generates meta output for web interaction through JavaScript...
+*/
+void  PolarStereographicProjection::visit(MetaDataVisitor& visitor, 
+	double left, double top, 
+	double width, double height,
+	double img_width, double img_height) 
+{
+	ostringstream java;
+
+	double w = getMaxPCX() - getMinPCX();
+	double h = getMaxPCY() - getMinPCY();
+
+	java << "{";
+	projection_->LL2PC(java);
+		
+	java << "\"top\" : " << top <<  ",";		
+	java << "\"left\" : " << left <<  ",";		
+	java << "\"width\" : " << width <<  ",";	
+	java << "\"img_width\" : " << img_width <<  ",";	
+	java << "\"height\" : " << height <<  ",";	
+	java << "\"img_height\" : " << img_height <<  ",";	
+	
+	java << "\"pcxmin\" : " << getMinPCX() <<  ",";		
+	java << "\"pcymin\" : " << getMinPCY() <<  ",";		
+	java << "\"pcwidth\" : " << w <<  ",";	
+	java << "\"pcheight\" : " << h <<  "";	
+	java << "}";	
+	visitor.add("projection", java.str());
+}
+
+void PolarStereographicProjection::corners()
+{
+	// For backwards compatibility!
+	if  ( min_longitude_ == -180 && max_longitude_ == 180 &&
+		   min_latitude_ == -90 && max_latitude_ == 90 ) {
+		min_latitude_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
+		max_latitude_ = ( hemisphere_ == NORTH ) ? -20. : 20.;
+		min_longitude_ = ( hemisphere_ == NORTH ) ? -45. : 45.;
+		max_longitude_ = ( hemisphere_ == NORTH ) ? 135. : -135.;
+	}
+
+	xmin_ = min_longitude_;
+	xmax_ = max_longitude_;
+	ymin_ = min_latitude_;
+	ymax_ = max_latitude_;
+		
+	if ( magCompare(system_, "projection") ) 
+		return; 
+	
+	
+}
+
+
+
+void PolarStereographicProjection::centre(double width, double height)
+{
+    PaperPoint centre = (*this)(UserPoint(centre_longitude_, centre_latitude_));
+      
+    double x = (width* map_scale_)/200;
+    double y = (height * map_scale_)/200;
+    
+           
+    PaperPoint llxy(centre.x() - x, centre.y() - y);
+    PaperPoint urxy(centre.x() + x, centre.y() + y);
+    
+    UserPoint ll;
+    revert(PaperPoint(centre.x() - x, centre.y() - y), ll);
+    UserPoint ur;
+    revert(PaperPoint(centre.x() + x, centre.y() + y), ur);    
+
+    xmin_ = ll.x();
+    ymin_ = ll.y();
+    xmax_ = ur.x();
+    ymax_ = ur.y();
+}
+
+
+
+
+/*!
+ Read in the documentation:	
+ For Polar Stereographic projections, the thinning factor is the distance, 
+ in both X and Y directions, corresponding to the projected INPUT_FIELD_LONGITUDE_STEP ,
+ along 60 degrees latitude, multiplied by the value of WIND_THINNING_FACTOR . 
+ After plotting at a grid point, all subsequent grid points, 
+ whose distance from the current grid point is less than the thinning factor, will be ignored. 
+ The default value is 2.0, e.g. the statement
+*/
+void PolarStereographicProjection::thin(MatrixHandler& matrix, double x, double y, vector<UserPoint>& out) const
+{
+
+	int yfactor = (int) ceil((float) x);
+    
+
+
+	int columns = matrix.columns();
+	int rows = matrix.rows();
+ 
+	for ( int row = 0; row < rows; row+=yfactor)
+	{
+		const double lat = matrix.row(row, 0);
+		int incrementx;
+		if (abs(lat) == 90) {
+			incrementx = columns;
+		}
+		else {
+			double coeff = (1-((lat/90.)*(lat/90.)));
+			assert ( coeff != 0);
+			incrementx = yfactor / coeff;
+			if (incrementx < 0 )
+				incrementx = 1;
+		}
+		for ( int column = 0; column < columns; column+=incrementx)
+		{
+			const double lon = matrix.column(row, column);
+
+			UserPoint point(lon, lat, matrix(row, column));
+			out.push_back(point); 
+		}
+	}
+}
+
+
+void PolarStereographicProjection::setNewPCBox(double minx, double miny, double maxx, double maxy)
+{
+	PaperPoint p1(minx, miny);
+	PaperPoint p2(maxx, maxy);
+	UserPoint   ll, ur;
+
+	revert(p1, ll);
+	revert(p2, ur);
+
+	min_longitude_ = ll.x();
+	max_longitude_ = ur.x();
+	min_latitude_ = ll.y();
+	max_latitude_ = ur.y(); 
+
+
+
+	corners();
+
+	xpcmin_ = minx;
+	ypcmin_ = miny;
+	xpcmax_ = maxx;
+	ypcmax_ = maxy;
+
+	PCEnveloppe_->clear();
+
+	PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmin_));
+	PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmax_));
+	PCEnveloppe_->push_back(PaperPoint(xpcmax_, ypcmax_));
+	PCEnveloppe_->push_back(PaperPoint(xpcmax_, ypcmin_));
+	PCEnveloppe_->push_back(PaperPoint(xpcmin_, ypcmin_));
+}
+
+void PolarStereographicProjection::operator()(const UserPoint& geo, vector<PaperPoint>& out) const
+{
+	PaperPoint pp = (*this)(geo);
+		if ( in(pp) ) 
+			out.push_back(pp);
+}
+
+void PolarStereographicProjection::reprojectComponents(const UserPoint& point, pair<double, double>& components) const
+{
+
+	double speed = sqrt((components.first * components.first) + (components.second * components.second));
+	double angle = atan2(components.second,components.first);
+
+
+
+
+    UserPoint pt(point.x()+0.5, point.y());
+
+    PaperPoint pp = (*this) (pt);
+	PaperPoint from = (*this)(point);
+
+
+	components.first = pp.x() - from.x();
+	components.second = pp.y() - from.y();
+
+	double rotation = atan2((pp.y() - from.y()), (pp.x() - from.x()));
+
+
+
+
+	//components.second *= f;
+	// we the angle and the spped we compute u/v...
+	components.first = speed * cos(angle+rotation);
+	components.second = speed * sin(angle+rotation);
+
+
+
+
+	speed = sqrt((components.first * components.first) + (components.second * components.second));
+	angle = DEG(atan2(components.second,components.first));
+
+
+}
+
+void PolarStereographicProjection::reprojectSpeedDirection(const PaperPoint& point, pair<double, double>& wind) const
+{
+	double a = 90 - (wind.second); 
+	const double x = 3.14/180.;
+	a *= x;
+	UserPoint geo;
+	const double speed =wind.first; 
+	wind.first = speed-1 * cos(a);
+	wind.second = speed-1 * sin(a);
+	reprojectComponents(geo, wind);
+}
+
+void PolarStereographicProjection::coastSetting(map<string, string>& setting, double abswidth, double absheight) const
+{
+	// work out the ratios of geographical to paper lengths
+	const double xratio = ( xpcmax_ - xpcmin_ ) / abswidth;
+	const double yratio = ( ypcmax_ - ypcmin_ ) / absheight;
+
+	// choose the smallest (smaller ratio means more detail required)
+	const double ratio = min (xratio, yratio);
+
+	std::string resol = "110m";
+	if ( ratio < 100000 )  // highest resolution
+	{
+		resol = "10m";
+	}
+	else if ( ratio < 300000)   // medium resolution
+	{
+		resol = "50m";
+	}
+	setting["resolution"]      = resol;
+	setting["lakes"]      = resol + "/" + resol + "_lakes";
+	setting["land"]       = resol + "/" + resol + "_land";
+	setting["rivers"]     = resol + "/" + resol + "_rivers_lake_centerlines";
+	setting["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+	
+	//! \note Administraive borders hardcoded to 10m resolution (low res version do not contain all info)
+	setting["administrative_boundaries"] = "10m/10m_admin_1_states_provinces_shp";
+
+	MagLog::dev() << "GeoRectangularProjection::coastSetting[" << abswidth << ", " << absheight << "]->" <<  ratio << " resol: "<<resol<< endl;
+}
+
+MatrixHandler* PolarStereographicProjection::prepareData(const AbstractMatrix& matrix) const
+{ return new GeoBoxMatrixHandler(matrix, *this); }
+
+void PolarStereographicProjection::wraparound(const UserPoint& point, stack<UserPoint>& duplicates) const
+{
+	if ( in(point) ) {
+		duplicates.push(point);
+	}
+
+}
+
+Polyline& PolarStereographicProjection::getPCBoundingBox() const
+{
+
+
+	if ( PCEnveloppe_->empty() ) {
+		getUserBoundingBox();
+	}
+
+	return *PCEnveloppe_;
+}
+
+Polyline& PolarStereographicProjection::getUserBoundingBox() const
+{
+
+	double minlat = -90;
+	double maxlat = 90; 
+	double minlon = -180;
+	double maxlon = 180; 
+
+	if ( userEnveloppe_->empty() ) {
+		// left
+		for ( int lat = minlat; lat <= maxlat; lat++) {
+			userEnveloppe_->push_back(PaperPoint(minlon,lat));
+
+		}
+		// top
+		for ( int lon = minlon; lon <= maxlon; lon++) {
+			userEnveloppe_->push_back(PaperPoint(lon, maxlat));
+
+		}
+		// right
+		for ( int lat = maxlat; lat >= minlat; lat--) {
+
+			userEnveloppe_->push_back(PaperPoint(maxlon, lat));
+
+		}
+		// bottom
+		for ( int lon = maxlon; lon >= minlon; lon--) {
+			userEnveloppe_->push_back(PaperPoint(lon, minlat));
+
+		}
+
+	}
+
+	return *userEnveloppe_;
+
+
+
+}
+
+#include <boost/geometry/algorithms/distance.hpp>
+double PolarStereographicProjection::patchDistance(double res) const
+{
+	/*
+	UserPoint geo1(0,60);
+	UserPoint geo2(0,61);
+
+	PaperPoint xy1 = (*this)(geo1);
+	PaperPoint xy2 = (*this)(geo2);
+
+	double x = xy1.distance(xy2);
+	*/
+	return 100000*res;
+
+}
+
+void  PolarStereographicProjection::fast_reproject(double& x, double& y) const
+{
+	TeCoord2D geo = TeCoord2D(x*TeCDR, y*TeCDR);
+	TeCoord2D xy = projection_->LL2PC(geo);
+	x = xy.x();
+	y = xy.y();
+
+}
+
+void PolarStereographicProjection::getNewDefinition(const UserPoint& ll, const UserPoint& ur, string& out) const
+{
+	map<string, string> def;
+	def["subpage_map_projection"] = "polar_stereographic";
+	def["subpage_map_area_definition"] = "corners";
+
+	def["subpage_map_hemisphere"] = (hemisphere_ == NORTH) ? "north" : "south";
+	def["subpage_map_vertical_longitude"] = tostring(vertical_longitude_);
+	def["subpage_lower_left_longitude"] = tostring(ll.x_);
+	def["subpage_lower_left_latitude"] = tostring(ll.y_);
+	def["subpage_upper_right_longitude"] = tostring(ur.x_);
+	def["subpage_upper_right_latitude"] = tostring(ur.y_);
+	::toxml(out, def);
+	out = "{" + out + "}";
+
+}
+void PolarStereographicProjection::setDefinition(const string& json)
+{
+	if (json.empty())
+				return;
+
+	MagJSon helper;
+	helper.interpret(json);
+
+	XmlNode node = **helper.tree_.firstElement();
+
+	node.name("polar_stereographic");
+
+
+	set(node);
+
+
+}
+
+
diff --git a/src/common/PolarStereographicProjection.h b/src/common/PolarStereographicProjection.h
new file mode 100644
index 0000000..80961ad
--- /dev/null
+++ b/src/common/PolarStereographicProjection.h
@@ -0,0 +1,238 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file PolarStereographicProjection.h
+    \brief Definition of PolarStereographicProjection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Fri Jan 11 15:01:45 2008
+*/
+
+#ifndef _PolarStereographicProjection_H
+#define _PolarStereographicProjection_H
+
+#include <Transformation.h>
+#include <PolarStereographicProjectionAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \class PolarStereographicProjection
+    \brief Implements a new projection
+    \ingroup projection
+
+    This projection ...
+*/
+
+class PolarStereographicProjection: public Transformation, public PolarStereographicProjectionAttributes
+{
+public:
+	PolarStereographicProjection();
+	~PolarStereographicProjection();
+
+	/*!
+	  \brief sets  from an XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		Transformation::set(node);
+		PolarStereographicProjectionAttributes::set(node);
+	}
+	/*!
+	  \brief sets  from a map
+	*/
+	void set(const map<string, string>& map)
+	{
+		Transformation::set(map);
+		PolarStereographicProjectionAttributes::set(map);
+	}
+    
+	virtual Transformation* clone() const {
+		PolarStereographicProjection* transformation = new PolarStereographicProjection();
+		transformation->copy(*this);
+		return transformation;
+	}
+	virtual void fill(double&, double&) ;
+	 void setNewPCBox(double, double, double, double);
+
+	 double patchDistance(double) const;
+	 void fast_reproject(double& x, double& y) const;
+	/*!
+	\\brief Initialise the projection
+	*/
+	virtual void init(double, double) ;
+
+	/*!
+	\\brief 
+	*/
+	virtual PaperPoint operator()(const UserPoint&) const;
+	virtual void operator()(const UserPoint&, vector<PaperPoint>& out) const;
+	virtual double unitToCm(double, double) const;
+	virtual double height() const;
+	/*!
+	\\brief 
+	*/
+	virtual PaperPoint operator()(const PaperPoint&) const;
+	void revert(const vector<pair<double, double> > &, vector<pair<double, double> > &) const;
+	/*!
+	\\brief 
+	*/
+	virtual void revert(const PaperPoint&, UserPoint&) const;
+	/*!
+	\\brief Does the projection needs the coastalines to be shifted!
+	*/
+	virtual bool needShiftedCoastlines() const;
+
+	//virtual bool concatenate(vector<Polyline* >& lines, Polyline* poly) const;
+	Polyline& getPCBoundingBox() const;
+	Polyline& getUserBoundingBox() const;
+	/*!
+	\\brief set the aspect ratio!
+	*/
+	virtual void aspectRatio(double&, double&) ;
+	/*!
+	\\brief set the bounding box!
+	*/
+	virtual void boundingBox(double&, double&, double&, double&) const;
+	virtual void smallestBoundingBox(double&, double&, double&, double&) const;
+	/*!
+	\\brief return the xmin in user coordinates!
+	*/
+	virtual double getMinX() const;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual double getMinY() const;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual double getMaxX() const;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual double getMaxY() const;
+	/*!
+	\\brief set the xmin in user coordinates!
+	*/
+	virtual void setMinX(double) ;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual void setMinY(double) ;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual void setMaxX(double) ;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual void setMaxY(double) ;
+	/*!
+	\\brief return the xmin in projection coordinates!
+	*/
+	virtual double getMinPCX() const;
+	/*!
+	\\brief return the ymin in projection coordinates!
+	*/
+	virtual double getMinPCY() const;
+	/*!
+	\\brief return the xmax in projection coordinates!
+	*/
+	virtual double getMaxPCX() const;
+	/*!
+	\\brief return the ymax in projection coordinates!
+	*/
+	virtual double getMaxPCY() const;
+	/*!
+	\\brief create the grid for the longitudes!!
+	*/
+	virtual void gridLongitudes(const GridPlotting&) const;
+	/*!
+	\\brief create the grid for the latitudes!!
+	*/
+	virtual void gridLatitudes(const GridPlotting&) const;
+	/*!
+	\\brief calculate the top labels
+	*/
+	virtual void labels(const LabelPlotting&, DrawingVisitor&) const;
+	virtual void labels(const LabelPlotting&, LeftAxisVisitor&) const;
+	virtual void labels(const LabelPlotting&, RightAxisVisitor&) const;
+	virtual void labels(const LabelPlotting&, TopAxisVisitor&) const;
+	virtual void labels(const LabelPlotting&, BottomAxisVisitor&) const;
+	
+	virtual void thin(MatrixHandler&, double x, double y, vector<UserPoint>&) const;
+	/*!
+	        \\brief prepare the javascript for thes particular instance of projection
+	*/
+	virtual void  visit(MetaDataVisitor&,double, double, double, double, double, double) ;
+	
+	// Needed for Image processing!
+	virtual TeProjection&  getProjection() 
+			{ return *projection_ ; }
+	double dimension(BasicGraphicsObjectContainer& parent) const
+        { return parent.absoluteHeight(); }
+	void getNewDefinition(const UserPoint&, const UserPoint&, string&) const;
+	void setDefinition(const string&);
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	 
+	void corners();
+	void centre(double, double);
+	void verticalLabels(const LabelPlotting&, double, double, bool)  const;
+	void horizontalLabels(const LabelPlotting&, double, double, bool)  const;
+
+	mutable TeProjection* projection_;
+	 
+	double xmin_;
+	double ymin_;
+	double xmax_;
+	double ymax_;
+
+	double xpcmin_;
+	double ypcmin_;
+	double xpcmax_;
+	double ypcmax_;
+	void reprojectComponents(const UserPoint&, pair<double, double>&) const;
+	void reprojectSpeedDirection(const PaperPoint& point, pair<double, double>&) const;
+
+	void coastSetting(map<string, string>&, double width, double height) const;
+
+	MatrixHandler* prepareData(const AbstractMatrix& matrix) const;
+	void wraparound(const UserPoint&, stack<UserPoint>&) const;
+
+
+private:
+	//! Copy constructor - No copy allowed
+	PolarStereographicProjection(const PolarStereographicProjection&);
+	//! Overloaded << operator to copy - No copy allowed
+	PolarStereographicProjection& operator=(const PolarStereographicProjection&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PolarStereographicProjection& p)
+		{ p.print(s); return s; }
+};
+    
+
+} // namespace magics
+#endif
diff --git a/src/common/PolyCoast.h b/src/common/PolyCoast.h
new file mode 100644
index 0000000..4b58ccb
--- /dev/null
+++ b/src/common/PolyCoast.h
@@ -0,0 +1,137 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file PolyCoast.h
+    \brief Definition of the Template class CoastPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+#ifndef PolyCoast_H
+#define PolyCoast_H
+
+#include "magics.h"
+
+#include "Polyline.h"
+
+namespace magics
+{
+	
+
+class PolyCoast : public Polyline
+{
+public :
+	PolyCoast(): level_(0), greenwich_(0), area_(0)
+		{ this->winding_ = -1; }
+	~PolyCoast() {}
+
+	virtual PolyCoast* clone() const
+	{
+		PolyCoast* poly = new PolyCoast();
+
+		poly->coastlines_ = coastlines_;
+		poly->setColour(this->getColour());
+		poly->setThickness(this->thickness_);
+		poly->setDashLength(this->dash_length_);
+		poly->setLineStyle(this->style_);
+		
+		poly->level(this->level_);
+		poly->setFillColour(this->getFillColour());
+		poly->setFilled(this->fill_);   
+		if (this->shading_) poly->setShading(this->shading_->clone());
+		poly->insert(poly->begin(), this->begin(), this->end());
+		poly->setMinX(this->getMinX());  // copy the bounding box
+		poly->setMinY(this->getMinY());  // copy the bounding box
+		poly->setMaxX(this->getMaxX());  // copy the bounding box
+		poly->setMaxY(this->getMaxY());  // copy the bounding box
+		return poly;
+	}
+	
+	virtual Polyline* getNew() const
+	{
+		PolyCoast* poly = new PolyCoast();
+		
+		poly->setColour(this->getColour());
+		poly->setThickness(this->thickness_);
+		poly->setDashLength(this->dash_length_);
+		poly->setLineStyle(this->style_);
+		poly->level(this->level_);
+		poly->setFillColour(this->getFillColour());
+		poly->setFilled(this->fill_);   
+		if (this->shading_) poly->setShading(this->shading_->clone()); 
+	
+		return poly;
+	}
+	
+	virtual Polyline* getShade() const
+		{
+		if ( !this->fill_ ) return 0;
+		
+			PolyCoast* poly = new PolyCoast();
+			
+			poly->setColour(Colour("none"));
+			poly->setThickness(0);
+			poly->setDashLength(this->dash_length_);
+			poly->setLineStyle(this->style_);
+			poly->level(this->level_);
+			poly->setFillColour(this->getFillColour());
+			poly->setFilled(this->fill_);   
+			if (this->shading_) poly->setShading(this->shading_->clone()); 
+		
+			return poly;
+		}
+	virtual Polyline* getContour() const
+		{
+		
+		
+			PolyCoast* poly = new PolyCoast();
+			
+			poly->setColour(this->getColour());
+			poly->setThickness(this->thickness_);
+			poly->setDashLength(this->dash_length_);
+			poly->setLineStyle(this->style_);
+			poly->level(this->level_);
+			poly->setFillColour(this->getFillColour());
+			poly->setFilled(false);   
+			poly->setShading(0); 
+		
+			return poly;
+		}
+
+	int level() const { return level_; }
+	void level(int level) { level_ = level; }
+	int greenwich() const { return greenwich_; }
+	void greenwich(int greenwich) { greenwich_ = greenwich; }
+	
+	vector<UserPoint>& coastlines() { return coastlines_; }
+	
+protected:
+	int level_;
+	int greenwich_;
+	double area_;
+	vector<UserPoint> coastlines_;
+
+	
+};
+} // end namespace
+#endif
diff --git a/src/common/Polyline.cc b/src/common/Polyline.cc
new file mode 100644
index 0000000..158d0d5
--- /dev/null
+++ b/src/common/Polyline.cc
@@ -0,0 +1,355 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Polyline.cc
+    \brief Implementation of polyline graphics class (template).
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#include "Polyline.h"
+#include "Transformation.h"
+#include "TeCoord2D.h"
+#include "TeGeometryAlgorithms.h"
+
+
+using namespace magics;
+
+
+
+Polyline::Polyline()
+{
+
+}
+
+
+Polyline::~Polyline() 
+{
+}
+
+void Polyline::reserve(double x)
+{
+	//polygon_.outer().reserve(x);
+}
+
+bool Polyline::reproject(BasicGraphicsObjectContainer& out) const
+{
+	const Transformation& transformation = out.transformation();
+	transformation(*this, out);	
+	return false;	
+}
+
+
+
+
+Polyline* Polyline::getNew() const
+{
+	Polyline* poly = new Polyline();
+
+	poly->copy(*this);
+
+	return poly;
+}
+
+
+void Polyline::print(ostream& out) const 
+{
+	out << "Polyline[";
+	out << ", nb_points = " << this->size();
+	  if ( this->size() < 25 ) {
+            out << " Outer [";
+            string sep = "";
+	    const unsigned int nb = size();
+            for (unsigned int i = 0; i < nb; i++) {
+                out << sep << get(i);
+                sep = ", ";
+            }
+            out << "]";
+        }
+        else {
+            unsigned int nb = size();
+            out << " Outer[" << get(0) << ", " << get(1) << ", " << get(2);
+            out << "...." << get(nb-3) << ", " << get(nb-2)  << ", " << get(nb-1);
+            out << "(" << nb << " elements)]";
+        }
+	out << "]";
+}
+
+
+
+Polyline* Polyline::simplify(double factor)
+{
+	BoostPoly simplified;
+	boost::geometry::simplify(polygon_, simplified, factor);
+	polygon_ = simplified;
+	return this;
+}
+
+
+
+
+void Polyline::redisplay(const BaseDriver& driver) const 
+{
+    if ( polygon_.outer().size() > 1 ) driver.redisplay(*this);
+}
+
+void Polyline::newHole()
+{
+	polygon_.inners().push_back(BoostPoly::ring_type());
+}
+
+void Polyline::push_back_hole(const PaperPoint& point)
+{
+	polygon_.inners().back().push_back(point);
+}
+
+
+Polyline::Holes::const_iterator Polyline::beginHoles() const
+{
+	return polygon_.inners().begin();
+}
+
+Polyline::Holes::const_iterator Polyline::endHoles() const
+{
+	return polygon_.inners().end();
+}
+
+void Polyline::hole(Holes::const_iterator hole, vector<double>& x, vector<double>& y) const
+{
+	x.reserve(hole->size());
+	y.reserve(hole->size());
+
+	for (deque<PaperPoint>::const_iterator h = hole->begin(); h != hole->end(); ++h) {
+		x.push_back(h->x_);
+		y.push_back(h->y_);
+	}
+}
+
+void Polyline::hole(Holes::const_iterator hole, Polyline& poly) const
+{
+	for (deque<PaperPoint>::const_iterator h = hole->begin(); h != hole->end(); ++h) {
+		poly.push_back(*h);
+	}
+}
+
+void Polyline::newHole(const Polyline& poly)
+{
+	polygon_.inners().push_back(BoostPoly::ring_type());
+	for (MagLine::const_iterator point = poly.begin(); point != poly.end(); ++point) {
+		polygon_.inners().back().push_back(*point);
+	}
+}
+
+void Polyline::reproject(const Transformation& transformation)
+{
+	for (MagLine::iterator point = polygon_.outer().begin(); point != polygon_.outer().end(); ++point) {
+		transformation.fast_reproject(point->x_, point->y_);
+	}
+// Now the holes!
+	for (Holes::iterator hole = polygon_.inners().begin(); hole != polygon_.inners().end(); ++hole)  {
+		for (MagLine::iterator h = hole->begin(); h != hole->end(); ++h) {
+			transformation.fast_reproject(h->x_, h->y_);
+		}
+	}
+}
+
+Polyline*  Polyline::clone() const
+{
+
+	Polyline* to = getNew();
+
+	for (MagLine::const_iterator point = begin(); point != end(); ++point) {
+		to->push_back(*point);
+	}
+
+// Now the holes!
+	for (Holes::const_iterator hole = polygon_.inners().begin(); hole != polygon_.inners().end(); ++hole)  {
+		to->newHole();
+		for (MagLine::const_iterator h = hole->begin(); h != hole->end(); ++h) {
+			to->push_back_hole(*h);
+		}
+
+	}
+
+	return to;
+}
+
+void Polyline::intersect(const Polyline& poly, vector<Polyline>& out) const
+{
+
+	vector<BoostPoly> clip;
+	try {
+		boost::geometry::intersection(this->polygon_, poly.polygon_, clip);
+
+		for (vector<BoostPoly>::iterator c = clip.begin(); c != clip.end(); ++c) {
+			out.push_back(Polyline());
+			out.back().copy(*this);
+			out.back().polygon_ = *c;
+		}
+	}
+	catch(...) {
+		MagLog::debug() << " pb intersect! " << endl;
+		MagLog::debug() << *this << endl;
+		MagLog::debug() << " with-> " << endl;
+		MagLog::debug() << poly << endl;
+		out.push_back(poly);
+	}
+}
+
+void Polyline::clip(const Polyline& poly, vector<Polyline>& out) const
+{
+//  convert the outer in a stringline! and then clip...
+	boost::geometry::model::linestring<PaperPoint> line;
+
+	for (deque<PaperPoint>::const_iterator p = poly.polygon_.outer().begin();
+			p != poly.polygon_.outer().end(); ++p) {
+		if ( p->x_ == begin()->x_ )
+			line.push_back(PaperPoint(p->x_+1, p->y_));
+		else
+			line.push_back(*p);
+
+	}
+
+	vector<boost::geometry::model::linestring<PaperPoint> > clip;
+	boost::geometry::intersection(line, polygon_,  clip);
+	vector<boost::geometry::model::linestring<PaperPoint> >::iterator c;
+	for (c = clip.begin(); c != clip.end(); ++c) {
+		out.push_back(Polyline());
+		out.back().copy(poly);
+		for (boost::geometry::model::linestring<PaperPoint>::iterator p = c->begin(); p != c->end(); ++p) {
+			out.back().polygon_.outer().push_back(*p);
+		}
+
+	}
+}
+
+// Is the poyline included in the "other" polyline"
+bool Polyline::in(const Polyline& other)
+{
+	return !boost::geometry::disjoint(this->polygon_, other.polygon_);
+}
+
+// Is the pointincluded in the polyline"
+bool Polyline::in(const PaperPoint& point)
+{
+	return boost::geometry::covered_by(point, this->polygon_);
+}
+
+void Polyline::push_front(Polyline& other)
+{
+	other.polygon_.outer().pop_back();
+	polygon_.outer().insert(polygon_.outer().begin(),
+			other.polygon_.outer().begin(), other.polygon_.outer().end());
+}
+
+void Polyline::push_back(Polyline& other)
+{
+	other.polygon_.outer().pop_front();
+		polygon_.outer().insert(polygon_.outer().end(),
+				other.polygon_.outer().begin(), other.polygon_.outer().end());
+}
+
+/*! \brief Routine to check (and correct) integrity of the inner holes of polygons read from shape files.
+*/
+void Polyline::correct()
+{
+	boost::geometry::correct(polygon_);
+}
+bool Polyline::sanityCheck()
+{
+    // input polygon _should_ have an outer ring larger than all its inner
+    // (hole) rings. This routine enforces this rule and ensures all the
+    // orientations are correct (i.e. outer ring clockwise, inners all
+    // anti-clockwise).
+    //
+    // output flag true if input polygon modified.
+	boost::geometry::correct(polygon_);
+    bool io_rbModified = false;
+    if (polygon_.outer().size() == 0)
+        return io_rbModified;
+
+    // we construct a "largest" polygon by iterating through the input.
+    // the largest ring we find will be assigned to its outer,
+    // the remaining rings will all be assigned to its inner holes.
+
+    BoostPoly largest = polygon_;
+    largest.inners().resize(0);
+
+    for (int i = 0; i < polygon_.inners().size(); i++)
+    {
+        // Note that anticlockwise "inner" polygons that are mistakenly in the "outer"
+        // position will return negativve areas. By taking the highest area we
+        // guard against inner polygons as outer rings and guard against any
+        // erroneous clockwise inner polygons that we might encounter.
+        if (boost::geometry::area(polygon_.inners()[i]) > boost::geometry::area(largest.outer()))
+        {
+            // we have an inner ring larger than the current outer ring.
+
+            // move the outer ring to the set of inner rings
+            largest.inners().push_back(largest.outer());
+            // assign the larger ring as a new outer ring
+            boost::geometry::assign(largest, polygon_.inners()[i]);
+
+            io_rbModified = true;
+        }
+        else
+        {
+            // simple copy of the inner ring
+            largest.inners().push_back(polygon_.inners()[i]);
+        }
+
+    }
+
+    // if any swapping has taken place, correct and assign the output polygon
+    if (io_rbModified)
+    {
+        // set the orientations using the boost method
+        boost::geometry::correct(largest);
+        polygon_ = largest;
+    }
+
+    return io_rbModified;
+
+}
+
+
+double PaperPoint::distance(const PaperPoint& other) const
+{
+	return boost::geometry::distance(*this, other);
+}
+void Polyline::box(const PaperPoint& ll, const PaperPoint& ur)
+{
+	push_back(ll);
+	push_back(ll.x(), ur.y());
+	push_back(ur);
+	push_back(ur.x(), ll.y());
+	push_back(ll);
+	boost::geometry::correct(polygon_);
+}
+bool Polyline::concatenate(Polyline&)
+{
+	return false;
+}
+void Polyline::intersection(Polyline&)
+{
+
+}
diff --git a/src/common/Polyline.h b/src/common/Polyline.h
new file mode 100644
index 0000000..c3b366c
--- /dev/null
+++ b/src/common/Polyline.h
@@ -0,0 +1,405 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Polyline.h
+    \brief Definition of polyline graphics class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+*/
+#ifndef Polyline_H
+#define Polyline_H
+
+#include "magics.h"
+
+#include "BasicGraphicsObject.h"
+#include "BaseDriver.h"
+#include "VectorOfPointers.h"
+#include "Label.h"
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/register/point.hpp>
+#include <boost/geometry/geometries/register/ring.hpp>
+#include <boost/geometry/geometries/register/linestring.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+BOOST_GEOMETRY_REGISTER_POINT_2D(magics::PaperPoint, double, boost::geometry::cs::cartesian, x_, y_)
+BOOST_GEOMETRY_REGISTER_RING(deque<magics::PaperPoint>);
+BOOST_GEOMETRY_REGISTER_LINESTRING(vector<magics::PaperPoint>);
+
+namespace magics {
+
+struct ShadingProperties
+{
+    ShadingProperties() 
+    {}
+    virtual ~ShadingProperties() {}
+    virtual ShadingProperties* clone() = 0;
+    virtual void draw(const BaseDriver& driver) const = 0;
+   
+    virtual void print(ostream& out) const
+    {
+       out << "ShadingProperties[";
+       out << "]";
+    }
+    friend ostream& operator<<(ostream& s,const ShadingProperties& p)
+		{ p.print(s); return s; }
+};
+
+struct FillShadingProperties : public ShadingProperties
+{
+    FillShadingProperties() {}
+    ~FillShadingProperties() {}
+    ShadingProperties* clone()
+    {	
+        FillShadingProperties* shading = new FillShadingProperties();
+        return shading;
+    }
+    void draw(const BaseDriver& driver) const { driver.shade(*this); }
+    void print(ostream& out) const
+    {
+       out << "FillShadingProperties[";
+       out << "]";
+   }
+};
+
+
+struct DotShadingProperties : public ShadingProperties
+{
+    DotShadingProperties() : angle_(45), size_(0.02), density_(25){}
+    ~DotShadingProperties() {}
+    void draw(const BaseDriver& driver) const { driver.shade(*this);}
+    double angle_;
+    double size_;
+    double density_;
+    ShadingProperties* clone()
+    {
+        DotShadingProperties* shading = new DotShadingProperties();
+        shading->angle_ = angle_;
+        shading->size_ = size_;
+        shading->density_ = density_;
+        return shading;
+    }
+
+    void print(ostream& out) const
+    {
+       out << "DotShadingProperties["   
+           << ", angle=" << angle_
+           << ", size=" << size_
+           << ", density=" << density_
+           << "]";
+   }
+};
+
+struct HatchShadingProperties : public ShadingProperties 
+{
+    HatchShadingProperties() : index_(0), thickness_(1), density_(18) {}
+    ~HatchShadingProperties() {}
+    void draw(const BaseDriver& driver) const {driver.shade(*this);} 
+    int index_;
+    int thickness_;
+    double density_;
+    ShadingProperties* clone() {
+        HatchShadingProperties* shading = new HatchShadingProperties();
+        
+        shading->index_ = index_;
+        shading->thickness_ = thickness_;
+        shading->density_ = density_;
+        return shading;
+    }
+    void print(ostream& out) const {
+       out << "HatchShadingProperties[";
+       out << ", thickness=" << thickness_;
+       out << ", index=" << index_;
+       out << ", density=" << density_;
+       out << "]";
+   }
+};
+
+
+class PolylineProperties : public BasicGraphicsObject 
+{
+public :
+	PolylineProperties() :  thickness_(1), dash_length_(10), style_(M_SOLID), fill_(false), shading_(0), stroke_(true), antialiasing_(true) {}
+	virtual ~PolylineProperties() { if (shading_) delete shading_; }
+	
+	virtual void copy(const PolylineProperties& other)
+	{			
+		label_       = other.label_ ;
+		colour_ = other.colour_;
+		thickness_ 	 = other.thickness_;
+		dash_length_ = other.dash_length_;	
+		style_       = other.style_;
+		fill_        = other.fill_;
+		antialiasing_ = other.antialiasing_;
+		fill_colour_ = other.fill_colour_;
+		stroke_ = other.stroke_;
+		if ( shading_ ) delete shading_;
+		shading_     = other.shading_ ? other.shading_->clone() : 0;
+	}
+	//! Method to set the thickness of a drawn line.
+	void setThickness(int t){thickness_ = t;}
+	//! Method to get the thickness of a drawn line.
+	int getThickness() const {return thickness_;}
+
+	//! Method to set the length of dashes in the line.
+	void setDashLength(int dl){dash_length_ = dl;}
+	//! Method to get the length of dashes in the line.
+	int getDashLength() const {return dash_length_;}
+
+	//! Method to set the style for the drawn line.
+	void  setLineStyle(LineStyle ls){style_ = ls;}
+	//! Method to get the style for the drawn line.
+	LineStyle getLineStyle() const {return style_;}
+	
+	//! Method to set the colour for the drawn line.
+	void  setColour(const Colour& colour){colour_ = colour;}
+	//! Method to get the colour for the drawn line.
+	const Colour& getColour() const {return colour_;}
+	
+	//! Method to set filling.
+	void  setFilled(bool fill){fill_ = fill;}
+	//! Method to get the style for the drawn line.
+	bool isFilled() const {return fill_;}
+	
+	void setFillColour(Colour col){  fill_colour_ = col;}
+	Colour getFillColour() const {return fill_colour_;}
+	
+	void setLabel(const Label& label){  label_ = label;}
+	const Label& getLabel() const {return label_;}
+	void setAntiAliasing(bool antialiasing){ antialiasing_ = antialiasing; }
+	bool getAntiAliasing() const {return antialiasing_;}
+	
+	void setStroke(bool stroke){ stroke_ = stroke; }
+	bool isStroked() const {return stroke_;}
+
+	void setShading(ShadingProperties* shading)
+	{ 
+		if ( shading_) delete shading_; 
+		shading_ = shading; 
+	}
+	
+	ShadingProperties* getShading() const { return shading_; }
+
+protected:
+	int			thickness_;
+	int			dash_length_;	
+	LineStyle		style_;
+	bool			fill_;
+	Colour			fill_colour_;
+	ShadingProperties*	shading_; 
+	Label                   label_;
+	Colour                  colour_;
+	bool                    stroke_;
+	bool                    antialiasing_;
+};
+
+
+using namespace magics;
+
+
+class Polyline:
+
+	public PolylineProperties
+{
+public:
+	typedef boost::geometry::model::polygon<PaperPoint, true, true, deque, deque > BoostPoly;
+	typedef boost::geometry::model::linestring<PaperPoint, deque > BoostLine;
+	typedef BoostPoly::inner_container_type Holes;
+	typedef deque<PaperPoint> MagLine;
+	Polyline();
+	~Polyline();
+	
+	void reproject(const Transformation&);
+	bool reproject(BasicGraphicsObjectContainer& out) const;
+	void redisplay(const BaseDriver& driver) const;
+
+	Colour cellColour_;
+	double cellValue_;
+	int index_;
+
+	const Colour& cellColour() const { return cellColour_; }
+	double cellValue() const { return cellValue_; }
+
+	int index() const { return index_; }
+	void index(int index)  { index_ = index; }
+
+	void cellColour(const Colour& colour ) { cellColour_ = colour; }
+	void cellValue(double value ) { cellValue_ = value; }
+	void cellInfo(const Colour& colour, double value) { cellColour_ = colour; cellValue_ = value; }
+
+	bool concatenate(Polyline&);
+	void intersection(Polyline&);
+	Polyline*  clone() const;
+	void push_back(const PaperPoint& point)
+	{	
+		if ( empty() ) {
+			polygon_.outer().push_back(point);
+			return;
+		}
+		PaperPoint last = back();
+		if ( point.x_ !=  last.x_ ||  point.y_ !=  last.y_)
+			polygon_.outer().push_back(point);
+	}
+	void push_back(double x, double y)
+	{
+		polygon_.outer().push_back(PaperPoint(x, y));
+	} 
+	void box(const PaperPoint&, const PaperPoint&);
+	bool empty() const {
+		return polygon_.outer().empty();
+	}
+	bool closed() const { return polygon_.outer().front() == polygon_.outer().back(); }
+	MagLine::const_iterator end() const { return polygon_.outer().end(); }
+	MagLine::const_iterator begin() const { return polygon_.outer().begin(); }
+	unsigned int size() const { return polygon_.outer().size(); }
+	const PaperPoint& get(int i) const { return polygon_.outer()[i]; }
+	const PaperPoint& front() const { return polygon_.outer().front(); }
+	const PaperPoint& back() const { return polygon_.outer().back(); }
+	void push_front(const PaperPoint& point)
+	{	
+		polygon_.outer().push_front(point);
+	} 
+	
+	void push_front(Polyline&);
+	void push_back(Polyline&);
+
+
+	// Is the poyline included in the "other" polyline"
+	bool in(const Polyline& other);
+
+	// Is the pointincluded in the polyline"
+	bool in(const PaperPoint&);
+
+	bool sanityCheck();
+	void correct();
+
+	void reserve(double);
+
+	/*!
+	  Counts checks if a given point is in the Polyline
+	  This method can be used to see if a point at x_in and y_in
+	  lies inside a CLOSED Polyline. If counts is odd the point
+	  should lie inside.
+	*/
+	bool inside(const float x_in,const float y_in) const;
+
+
+	bool allMissing() const
+	{		
+	    deque<PaperPoint>::const_iterator p = polygon_.outer().begin();
+	    while (p != polygon_.outer().end() )
+	    {
+	    	if ( !p->missing() ) 
+	    		return false;
+	    	p++;
+	    }
+	    return true;
+	}
+	    	
+	bool someMissing() const
+	{
+		deque<PaperPoint>::const_iterator p = polygon_.outer().begin();
+	    while (p != polygon_.outer().end() )
+	    {
+	    	if ( p->missing() ) 
+	    		return true;
+	    	p++;
+	    }
+	    return false;
+	}		 
+
+
+	bool within(const PaperPoint& point) const {
+		return boost::geometry::covered_by(point, polygon_);
+	}
+
+	void clip(const Polyline& poly, vector<Polyline>&) const;
+	void intersect(const Polyline& poly, vector<Polyline>&) const;
+
+	Polyline* simplify(double);
+	Polyline* getNew() const;
+
+
+	// Holes
+	void newHole(const Polyline&);
+	void newHole();
+	void push_back_hole(const PaperPoint& point);
+
+
+	void hole(Holes::const_iterator, Polyline&) const;
+	Holes::const_iterator beginHoles() const;
+	Holes::const_iterator endHoles() const;
+
+	void hole(Holes::const_iterator, vector<double>&, vector<double>&) const;
+	unsigned int numberOfHoles() const {return polygon_.inners().size();}
+	void  clearHoles()  { polygon_.inners().clear();}
+	void  clear()  { polygon_.clear();}
+	Holes& holes();
+
+protected:
+	void print(ostream&) const;
+
+
+
+public:
+
+
+
+	BoostPoly polygon_;
+
+
+private: 
+	//Polyline(const Polyline&);
+//
+// -- Friends
+	friend ostream& operator<<(ostream& s,const Polyline& p)
+		{ p.print(s); return s; }
+};
+
+
+class PolylineSet : public BasicGraphicsObjectContainer
+	{
+	public:
+	    PolylineSet() {}
+	    ~PolylineSet() { }
+
+	    void redisplay(const BaseDriver& driver) const
+	        { driver.redisplay(*this); }
+	protected:
+	    void print(ostream& out) const { out << "PolylineSet[ " << objects_.size() << " elts]\n" << endl; }
+
+	private:
+	    PolylineSet(const Polyline&);
+	    PolylineSet& operator=(const PolylineSet&);
+
+	// -- Friends
+	    friend ostream& operator<<(ostream& s,const PolylineSet& p)
+	        { p.print(s); return s; }
+	};
+
+
+
+} // namespace magics
+
+
+
+
+#endif
diff --git a/src/common/ProgressObject.h b/src/common/ProgressObject.h
new file mode 100644
index 0000000..00e340e
--- /dev/null
+++ b/src/common/ProgressObject.h
@@ -0,0 +1,64 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File ProgressObject.h
+// Magics Team - ECMWF 2004
+
+#ifndef ProgressObject_H
+#define ProgressObject_H
+
+#include "magics.h"
+
+#include "BasicGraphicsObject.h"
+
+namespace magics {
+
+class BaseDriver;
+
+class ProgressObject: public BasicGraphicsObject {
+
+public:
+	ProgressObject(const string& progress) : progress_(progress) {}
+	virtual ~ProgressObject() {}
+    
+	bool reproject(const Transformation&, BasicGraphicsObjectContainer& out) const 
+		{ 
+			out.push_back(const_cast<ProgressObject*>(this)); 
+			return true; // remove thee obect from tthe in list!
+		}
+	void redisplay(const BaseDriver& driver) const;
+    
+	string getText() const {return progress_;}
+
+protected:
+	virtual void print(ostream&) const; 
+	string progress_;
+
+private:
+// No copy allowed
+	ProgressObject(const ProgressObject&);
+	ProgressObject& operator=(const ProgressObject&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const ProgressObject& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/ProgressTask.h b/src/common/ProgressTask.h
new file mode 100644
index 0000000..1ace422
--- /dev/null
+++ b/src/common/ProgressTask.h
@@ -0,0 +1,52 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File ProgressTask.h
+// Magics Team - ECMWF 2004
+
+#ifndef ProgressTask_H
+#define ProgressTask_H
+
+#include "magics.h"
+
+#include "Task.h"
+
+namespace magics {
+
+class ProgressTask: public Task {
+
+public:
+	ProgressTask();
+	virtual ~ProgressTask();
+
+protected:
+	 virtual void print(ostream&) const; 
+
+private:
+// No copy allowed
+	ProgressTask(const ProgressTask&);
+	ProgressTask& operator=(const ProgressTask&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const ProgressTask& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Proj4Projection.cc b/src/common/Proj4Projection.cc
new file mode 100644
index 0000000..1f42433
--- /dev/null
+++ b/src/common/Proj4Projection.cc
@@ -0,0 +1,1054 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Proj4Projection.cc
+    \brief Implementation of Proj4Projection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Tue May 18 17:39:58 2010
+
+*/
+
+#include <Proj4Projection.h>
+#include <Polyline.h>
+#include <GridPlotting.h>
+#include <LabelPlotting.h>
+#include <Text.h>
+#include "MetaData.h"
+#include "MagConfig.h"
+#include <MatrixHandler.h>
+#include <ParameterSettings.h>
+#include <Layer.h>
+#include <MagJSon.h>
+
+namespace magics
+{
+
+struct Epsg
+{
+	Epsg(const string& name) : name_(name) {
+		epsgs_.insert(make_pair(lowerCase(name), this));
+		methods_["definition"] = &Epsg::definition;
+		methods_["min_longitude"] = &Epsg::minlon;
+		methods_["min_latitude"] = &Epsg::minlat;
+		methods_["max_longitude"] = &Epsg::maxlon;
+		methods_["max_latitude"] = &Epsg::maxlat;
+		methods_["method"] = &Epsg::method;
+	}
+	string name_;
+	string definition_;
+
+
+	typedef void (Epsg::*Method)(const json_spirit::Value&);
+	map<string,  Method> methods_;
+
+	void definition(const json_spirit::Value& value) {
+		definition_ =  value.get_value<string>();
+	}
+	void minlon(const json_spirit::Value& value) {
+		minlon_ =  value.get_value<double>();
+	}
+	void minlat(const json_spirit::Value& value) {
+		minlat_ =  value.get_value<double>();
+	}
+	void maxlon(const json_spirit::Value& value) {
+		maxlon_ =  value.get_value<double>();
+	}
+	void maxlat(const json_spirit::Value& value) {
+		maxlat_ =  value.get_value<double>();
+	}
+	void method(const json_spirit::Value& value) {
+		method_ =  value.get_value<string>();
+	}
+
+	double minlon_ ;
+	double minlat_;
+	double maxlon_ ;
+	double maxlat_;
+
+	string method_;
+
+	static map<string, Epsg*> epsgs_;
+
+	void  set(const json_spirit::Value&);
+
+	static Epsg* find(const string& name) {
+		map<string, Epsg*>::iterator epsg = epsgs_.find(lowerCase(name));
+		if ( epsg == epsgs_.end() )  {
+			MagLog::warning() << "Can not find information on " << name << ": use epsg instead" << endl;
+			return find("EPSG:4326");
+		}
+		return epsg->second;
+	}
+	const char* definition() { return definition_.c_str(); }
+
+
+};
+
+class EpsgConfig : public MagConfig
+{
+public:
+	EpsgConfig() {}
+	~EpsgConfig() {}
+
+	void callback(const string&, const json_spirit::Value&);
+	void init();
+	Epsg* epsg_;
+};
+}
+using namespace magics;
+
+map<string, Epsg*> Epsg::epsgs_;
+
+void EpsgConfig::init()
+{
+	//methods_["epsg"] =  &EpsgConfig::epsg;
+	MagConfigHandler(getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "/epsg.json", *this);
+}
+void Epsg::set(const json_spirit::Value& value)
+{
+	assert (value.type() == json_spirit::obj_type);
+	json_spirit::Object object =value.get_value< json_spirit::Object >();
+	for (vector<json_spirit::Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+
+		map<string,  Method >::iterator method = methods_.find(entry->name_);
+	    if ( method != methods_.end() ) {
+	    	   ( (this->*method->second)(entry->value_) );
+	    }
+
+	}
+}
+void  EpsgConfig::callback(const string& name, const json_spirit::Value& value)
+{
+
+	// here we get an Array of epsg!
+
+	assert (value.type() == json_spirit::array_type);
+	json_spirit::Array values = value.get_value<json_spirit::Array>();
+	for (unsigned int i = 0; i < values.size(); i++) {
+		json_spirit::Object object = values[i].get_value< json_spirit::Object >();
+		 for (vector<json_spirit::Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+
+		 	Epsg* epsg = new Epsg(entry->name_);
+		 	epsg->set( entry->value_);
+		 }
+	}
+
+}
+/*
+static Epsg epsg_4336("EPSG:4326",
+		"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
+		-180, -90, +180, 90,
+		-180, -90, +180, 90,
+		20, 20, true
+		);
+
+static Epsg cylindrical("cylindrical",
+				"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs",
+				-180, -90, +180, 90,
+				-180, -90, +180, 90,
+				20, 20, true
+				);
+
+static Epsg polar_north("polar_north",
+				"+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
+				-180, -20, +180, -20,// line this one is to find the limit of the projection coordinate system.
+				-45, -20, 135, -20, // this one to define the default full extend
+				2,2, false
+				);
+static Epsg epsg_32661("EPSG:32661",
+				"+proj=stere +lat_0=90 +lat_ts=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
+				-180, -20, +180, -20,// line this one is to find the limit of the projection coordinate system.
+				-45, -20, 135, -20, // this one to define the default full extend
+				2,2, false
+				);
+static Epsg geos("geos",
+				"+proj=goode",
+				-160,  0, 160, 0,// line this one is to find the limit of the projection coordinate system.
+				-180,  -90, 180, 90, // this one to define the default full extend
+				2,2, false
+				);
+*/
+/*!
+  \brief Constructor
+*/
+Proj4Projection::Proj4Projection(const string& definition) : definition_(definition)
+{
+
+	//init();
+	EpsgConfig config;
+	config.init();
+}
+Proj4Projection::Proj4Projection()
+{
+
+	//init();
+	EpsgConfig config;
+	config.init();
+}
+
+
+/*!
+  \brief Destructor
+*/
+Proj4Projection::~Proj4Projection() 
+{
+	
+}
+
+void Proj4Projection::print(ostream& out) const
+{
+    out << "Proj4Projection[";
+    Proj4ProjectionAttributes::print(out);
+    out << "]"; 
+} 
+
+Polyline& Proj4Projection::getPCBoundingBox() const
+{
+
+	return *PCEnveloppe_;
+}
+
+Polyline& Proj4Projection::getUserBoundingBox() const
+{
+
+
+		return *userEnveloppe_;
+
+
+
+}
+
+void Proj4Projection::init()  
+{
+
+	MagLog::dev() << "Proj4Projection::init()" << *this << endl;
+
+
+
+	from_ = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84");
+	projection_ = Epsg::find(definition_);
+	to_    = pj_init_plus(projection_->definition());
+	if ( !to_) {
+		MagLog::error() << pj_strerrno(pj_errno) << endl;
+		MagLog::error() << " proj4 error " << projection_->definition() << endl;
+		assert(false);
+	}
+
+	methods_["geos"] = &Proj4Projection::geos;
+	methods_["conic"] = &Proj4Projection::conic;
+	methods_["simple"] = &Proj4Projection::simple;
+	map<string,  InitMethod >::iterator method = methods_.find(projection_->method_);
+	if ( method != methods_.end() )
+		(this->*method->second)();
+	else
+		simple();
+	helpers_["full"] = &Proj4Projection::full;
+	helpers_["corners"] = &Proj4Projection::corners;
+	helpers_["centre"] = &Proj4Projection::centre;
+
+	map<string,  SettingHelper >::iterator helper = helpers_.find(lowerCase(setting_));
+
+	if ( helper != helpers_.end() )
+		(this->*helper->second)();
+	else {
+		MagLog::warning() << " Coud not fing method " << setting_ << " to set the geographical area"
+				<< "  Going back to default area" << endl;
+
+		full();
+	}
+
+
+}
+
+void Proj4Projection::full()
+{
+}
+
+void Proj4Projection::corners()
+{
+	// we have to update the PVBounding box!
+
+		min_pcx_ = min_longitude_;
+		min_pcy_ = min_latitude_;
+		max_pcx_ = max_longitude_;
+		max_pcy_ = max_latitude_;
+
+
+		fast_reproject(min_pcx_, min_pcy_);
+		fast_reproject(max_pcx_, max_pcy_);
+
+
+
+
+		Polyline box;
+		box.box(PaperPoint(min_pcx_, min_pcy_), PaperPoint(max_pcx_, max_pcy_));
+
+		vector<Polyline> newbox;
+		PCEnveloppe_->intersect(box, newbox);
+		if ( newbox.empty() ) {
+			MagLog::warning() << "Proj4 : the sub-area is not valid : use global view instead" << endl;
+		}
+		else {
+			PCEnveloppe_ = newbox.front().clone();
+		}
+}
+
+void Proj4Projection::centre()
+{
+
+}
+
+PaperPoint Proj4Projection::operator()(const UserPoint& point)  const
+{
+	if ( ! from_ ) {
+		from_ = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84");
+		projection_ = Epsg::find(definition_);
+		to_    = pj_init_plus(projection_->definition());
+	}
+	double x = point.x();
+	double y = point.y();
+
+	x *= DEG_TO_RAD;
+	y *= DEG_TO_RAD;
+
+    int error = pj_transform(from_, to_, 1, 1, &x, &y, NULL);
+    if ( error ) {
+		MagLog::debug() << pj_strerrno(error) << " for " << point << endl;
+
+		return PaperPoint(-1000000, -10000000);
+
+	}
+
+	return PaperPoint(x, y, point.value_, point.missing());
+	               
+}
+
+PaperPoint Proj4Projection::operator()(const PaperPoint& point)  const
+{
+	MagLog::dev() << "Proj4Projection::operator()(...) needs implementing." << endl;
+	return Transformation::operator()(point);
+}
+
+void Proj4Projection::setNewPCBox(double minx, double miny, double maxx, double maxy)
+{
+	   PaperPoint p1(minx, miny);
+	   PaperPoint p2(maxx, maxy);
+	   UserPoint   ll, ur;
+
+	   revert(p1, ll);
+	   revert(p2, ur);
+
+	   min_longitude_ =ll.x();
+	   max_longitude_ = ur.x();
+	   min_latitude_ = ll.y();
+	   max_latitude_ = ur.y();
+	min_pcx_ = minx;
+	max_pcx_ = maxx;
+	min_pcy_ = miny;
+	max_pcy_ = maxy;
+}
+
+void Proj4Projection::revert(const PaperPoint& xy, UserPoint& point)  const
+{
+
+
+	double x = xy.x();
+	double y = xy.y();
+		
+
+	int error = pj_transform(to_, from_, 1, 1, &x, &y, NULL );
+
+	if ( error ) {
+		MagLog::debug() << pj_strerrno(error) << endl;
+		point = UserPoint(-1000, -1000);
+		return;
+	}
+
+	x *= RAD_TO_DEG;
+	y *= RAD_TO_DEG;
+	point = UserPoint(x, y);
+}
+
+
+
+bool Proj4Projection::needShiftedCoastlines()  const
+{
+	// Will need w new parameter to know!
+	return false;
+}
+
+void Proj4Projection::aspectRatio(double& width, double& height)  
+{
+	MagLog::dev() << "Proj4Projection::aspectRatio(...) needs implementing." << endl;
+	Transformation::aspectRatio(width, height);
+}
+
+static double gridMinLon_ = DBL_MAX;
+static double gridMinLat_= DBL_MAX;
+static double gridMaxLon_= -DBL_MAX;
+static double gridMaxLat_= -DBL_MAX;
+
+void Proj4Projection::add(double lon, double lat)
+{
+	double x = lon*DEG_TO_RAD;
+	double y = DEG_TO_RAD*lat;
+	int error =  pj_transform(from_, to_, 1, 1, &x, &y, NULL );
+	userEnveloppe_->push_back(PaperPoint(lon, lat));
+	PCEnveloppe_->push_back(PaperPoint(x, y));
+	if ( x < min_pcx_ )  min_pcx_ = x;
+	if ( y < min_pcy_ )  min_pcy_ = y;
+	if ( x > max_pcx_ )  max_pcx_ = x;
+	if ( y > max_pcy_ )  max_pcy_ = y;
+	if ( lon < gridMinLon_)  gridMinLon_ = lon;
+	if ( lat < gridMinLat_ )  gridMinLat_ = lat;
+	if ( lon > gridMaxLon_)  gridMaxLon_ = lon;
+	if ( lat > gridMaxLat_ )  gridMaxLat_ = lat;
+
+
+
+}
+
+void Proj4Projection::conic()
+{
+	userEnveloppe_->clear();
+		PCEnveloppe_->clear();
+	min_pcx_ = DBL_MAX;
+		min_pcy_ = DBL_MAX;
+		max_pcx_ = -DBL_MAX;
+		max_pcy_ = -DBL_MAX;
+	/*
+	// left
+	for ( int lat = projection_->minlat_; lat <= projection_->maxlat_; lat++) {
+		add(projection_->minlon_, lat);
+	}
+	*/
+	// top
+	add( projection_->minlon_, projection_->maxlat_);
+	for ( int lon = projection_->minlon_; lon <= projection_->maxlon_; lon++) {
+		add(lon, projection_->minlat_);
+	}
+	add( projection_->maxlon_, projection_->maxlat_);
+	PCEnveloppe_->correct();
+	userEnveloppe_->correct();
+	/*
+	// right
+	for ( int lat = projection_->maxlat_; lat >= projection_->minlat_; lat--) {
+		add(projection_->maxlon_, lat);
+	}
+	// bottom
+	for ( int lon = projection_->maxlon_; lon >= projection_->minlon_; lon--) {
+			add(lon, projection_->minlat_);
+		}
+	*/
+}
+
+
+
+void Proj4Projection::simple()
+{
+	userEnveloppe_->clear();
+	PCEnveloppe_->clear();
+	min_pcx_ = DBL_MAX;
+	min_pcy_ = DBL_MAX;
+	max_pcx_ = -DBL_MAX;
+	max_pcy_ = -DBL_MAX;
+	add(projection_->minlon_, projection_->minlat_);
+	add(projection_->minlon_, projection_->maxlat_);
+	add(projection_->maxlon_, projection_->maxlat_);
+	add(projection_->maxlon_, projection_->minlat_);
+	add(projection_->minlon_, projection_->minlat_);
+}
+
+void Proj4Projection::geos()
+{
+	userEnveloppe_->clear();
+	PCEnveloppe_->clear();
+	// here we have to prepare the enveloppe!
+	min_pcx_ = DBL_MAX;
+		min_pcy_ = DBL_MAX;
+		max_pcx_ = -DBL_MAX;
+		max_pcy_ = -DBL_MAX;
+		map<double, vector<double> > helper;
+
+		for ( int lat = projection_->minlat_; lat <= projection_->maxlat_; lat++) {
+			helper.insert(make_pair(lat, vector<double>()));
+			for ( int lon =  projection_->minlon_; lon <= projection_->maxlon_; lon++) {
+				double x = lon*DEG_TO_RAD;
+				double y = DEG_TO_RAD*lat;
+				int error =  pj_transform(from_, to_, 1, 1, &x, &y, NULL );
+				if ( !error) {
+					helper[lat].push_back(lon);
+				}
+			}
+		}
+		// now we create the envelope...
+		for ( map<double, vector<double> >::iterator lat = helper.begin(); lat != helper.end(); ++lat) {
+			if ( lat->second.empty() )
+				continue;
+			add(lat->second.front(), lat->first);
+
+		}
+		// now reverse!
+		for ( map<double, vector<double> >::reverse_iterator lat = helper.rbegin(); lat != helper.rend(); ++lat) {
+			if ( lat->second.empty() )
+				continue;
+			add(lat->second.back(), lat->first);
+			userEnveloppe_->push_back(PaperPoint(lat->second.back(), lat->first));
+
+		}
+
+
+
+
+
+}
+
+
+
+void Proj4Projection::boundingBox(double& xmin, double& ymin, double& xmax, double& ymax)  const
+{
+	if ( ! from_ ) {
+			from_ = pj_init_plus("+proj=longlat +ellps=WGS84 +datum=WGS84");
+			projection_ = Epsg::find(definition_);
+			to_    = pj_init_plus(projection_->definition());
+		}
+	ymin = gridMinLat_;
+	xmin = gridMinLon_-5;
+	ymax = gridMaxLat_;
+	xmax = gridMaxLon_+5;
+
+}
+
+double Proj4Projection::getMinX()  const
+{
+	return gridMinLon_;
+}
+
+double Proj4Projection::getMinY()  const
+{
+	
+	return gridMinLat_;
+}
+
+double Proj4Projection::getMaxX()  const
+{
+	return gridMaxLon_;
+}
+
+double Proj4Projection::getMaxY()  const
+{
+	return gridMaxLat_;
+}
+
+void Proj4Projection::setMinX(double x)  
+{
+	min_longitude_ = x;
+}
+
+void Proj4Projection::setMinY(double y)  
+{
+	min_latitude_ = y;
+}
+
+void Proj4Projection::setMaxX(double x)  
+{
+	
+	max_longitude_ = x;
+}
+
+void Proj4Projection::setMaxY(double y)  
+{
+
+	max_latitude_ = y;
+}
+
+double Proj4Projection::getMinPCX()  const
+{
+	return min_pcx_;
+}
+
+double Proj4Projection::getMinPCY()  const
+{
+	return min_pcy_;
+}
+
+double Proj4Projection::getMaxPCX()  const
+{
+	return max_pcx_;
+}
+
+double Proj4Projection::getMaxPCY()  const
+{
+	return max_pcy_;
+}
+
+
+void Proj4Projection::gridLongitudes(const GridPlotting& grid)  const
+{
+
+	Polyline boundaries;
+
+	for (Polyline::MagLine::const_iterator point = PCEnveloppe_->begin(); point != PCEnveloppe_->end(); ++point )
+	{
+		boundaries.push_back(*point);
+	}
+
+	grid.add(boundaries);
+
+	//return;
+	vector<double> longitudes = grid.longitudes();
+
+
+		const double step = 0.5;
+		longitudes.push_back(180);
+		const vector<double>::const_iterator lon_end =longitudes.end();
+
+		for (vector<double>::const_iterator lon = longitudes.begin(); lon != lon_end; ++lon)
+		{
+
+			Polyline poly;
+			poly.setAntiAliasing(false);
+
+			for (double lat = gridMinLat_; (lat == gridMaxLat_ || lat < gridMaxLat_ + step); lat += step)
+			{
+				PaperPoint p(*lon, lat);
+				if ( userEnveloppe_->within(p) )
+					poly.push_back((*this)(UserPoint(*lon,lat)));
+			}
+			grid.add(poly);
+		}
+}
+
+void Proj4Projection::gridLatitudes(const GridPlotting& grid)  const
+{
+	const vector<double>& latitudes = grid.latitudes();
+
+	const double step = 0.5;
+	const vector<double>::const_iterator lat_end = latitudes.end();
+	for(vector<double>::const_iterator lat = latitudes.begin(); lat != lat_end; ++lat)
+	{
+
+		Polyline poly;
+		poly.setAntiAliasing(false);
+		for (double lon = gridMinLon_; lon <= gridMaxLon_ + step; lon += step)
+		{
+			PaperPoint p(lon, *lat);
+			if ( userEnveloppe_->within(p) )
+				poly.push_back((*this)(UserPoint(lon,*lat)));
+		}
+		grid.add(poly);
+	}
+}
+
+void Proj4Projection::labels(const LabelPlotting& label, DrawingVisitor& visitor)  const
+{
+
+	vector<double> pro4_longitudes;
+	pro4_longitudes.push_back(0);
+	pro4_longitudes.push_back(90);
+	pro4_longitudes.push_back(-90);
+	pro4_longitudes.push_back(180);
+	pro4_longitudes.push_back(-180);
+	const vector<double>& longitudes = label.longitudes();
+	const vector<double>& latitudes = label.latitudes();
+	for (vector<double>::const_iterator lat = latitudes.begin(); lat != latitudes.end(); ++lat)
+	{
+		for (vector<double>::iterator lon = pro4_longitudes.begin(); lon != pro4_longitudes.end(); ++lon)
+		{
+			vector<double>::const_iterator ilon = find(longitudes.begin(), longitudes.end(), *lon);
+			if ( ilon == longitudes.end() )
+				continue;
+
+			UserPoint point(*lon, *lat);
+			PaperPoint xy = (*this)(point);
+
+			if ( !in(xy) ) continue;
+
+			Text *text = new Text();
+			label.add(text);
+			text->setText(writeLatitude(point));
+			text->push_back(xy);
+			text->setBlanking(true);
+
+		}
+	}
+}
+
+
+void Proj4Projection::labels(const LabelPlotting& label, LeftAxisVisitor& visitor)  const
+{
+
+	if ( false ) {
+		const vector<double>& latitudes = label.latitudes();
+
+		for (unsigned int lat = 0; lat < latitudes.size(); lat++ )
+		{
+			double lon = max_longitude_ - ((max_longitude_-min_longitude_)*.1);
+			UserPoint point(lon,latitudes[lat]);
+			PaperPoint xy = (*this)(point);
+			if ( !in(xy) ) continue;
+			Text *text = new Text();
+			label.add(text);
+			text->setText(writeLatitude(point));
+			text->push_back(xy);
+			text->setJustification(MRIGHT);
+			text->setVerticalAlign(MHALF);
+			text->setBlanking(true);
+
+		}
+	}
+	else {
+		double x = max_pcx_ - ((max_pcx_-min_pcx_)*.1);
+		// we calculate the intersection of the longitudes with the left side
+		verticalLabels(label, min_pcx_, x, MRIGHT);
+
+	}
+}
+
+void Proj4Projection::labels(const LabelPlotting& label, RightAxisVisitor& visitor)  const
+{
+
+	if ( false ) {
+		const vector<double>& latitudes = label.latitudes();
+		for (unsigned int lat = 0; lat < latitudes.size(); lat++ )
+		{
+			double lon = min_longitude_ + ((max_longitude_-min_longitude_)*.1);
+			UserPoint point(lon,latitudes[lat]);
+			PaperPoint xy = (*this)(point);
+			if ( !in(xy) ) continue;
+			Text *text = new Text();
+			label.add(text);
+			text->setText(writeLatitude(point));
+			text->push_back(xy);
+			text->setJustification(MLEFT);
+			text->setVerticalAlign(MHALF);
+			text->setBlanking(true);
+
+		}
+	}
+	else {
+		// we calculate the intersection of the longitudes with the right side
+		double x = min_pcx_ + ((max_pcx_-min_pcx_)*.1);
+		verticalLabels(label, max_pcx_, x, MLEFT);
+
+	}
+}
+
+void Proj4Projection::labels(const LabelPlotting& label, BottomAxisVisitor& visitor)  const
+{
+
+	if ( false ) {
+		const vector<double>& longitudes = label.longitudes();
+		const double lat = min_latitude_ + (max_latitude_-min_latitude_)*.8;
+		for (unsigned int lon = 0; lon < longitudes.size(); lon++ )
+		{
+			UserPoint point(longitudes[lon],lat);
+			PaperPoint xy = (*this)(point);
+			if ( !in(xy) ) continue;
+			Text *text = new Text();
+			label.add(text);
+			text->setText(writeLongitude(point));
+			text->push_back(xy);
+			text->setJustification(MCENTRE);
+			text->setVerticalAlign(MTOP);
+			text->setBlanking(true);
+
+		}
+	}
+	else {
+			// we calculate the intersection of the longitudes with the right side
+		double y = min_pcy_ + ((max_pcy_-min_pcy_)*.8);
+		horizontalLabels(label, min_pcy_, y, MTOP);
+	}
+}
+
+inline double CA(PaperPoint& p1, PaperPoint& p2)
+{
+    return (p2.x() - p1.x()) ? (p2.y() - p1.y())/(p2.x() - p1.x()) : 0;
+}
+
+inline double CB(double a, PaperPoint& p)
+{
+    return p.y() - a * p.x();
+}
+
+inline double CX(double a, double b, double y)
+{
+    return (a) ? (y - b)/a : 0;
+}
+inline double CY(double a, double b, double x)
+{
+    return (a * x) + b;
+}
+inline bool between(double x, double x1, double x2)
+{
+	return ( std::min(x1, x2) <= x && x <= std::max(x1, x2) );
+}
+
+void Proj4Projection::verticalLabels(const LabelPlotting& label, double x, double pos, Justification justif)  const
+{
+
+    const vector<double>& longitudes = label.longitudes();
+    for (vector<double>::const_iterator lon = longitudes.begin(); lon != longitudes.end(); ++lon)
+    {
+        // find the equation of the line using 2 points : lon/-20 -->lon/ +20
+    	for ( double lat1 = -90, lat2 = -80; lat2 < 90; lat1+=10, lat2+=10) {
+    		UserPoint geo1(*lon, lat1);
+    		UserPoint geo2(*lon, lat2);
+    		PaperPoint xy1 = (*this)(geo1);
+    		PaperPoint xy2 = (*this)(geo2);
+    		if ( between(x, xy1.x_, xy2.x_) ) {
+    			double a = CA(xy1, xy2);
+    			double b = CB(a, xy1);
+    			PaperPoint xy(x, CY(a, b, x));
+    			if ( !in(xy) ) continue;
+    			UserPoint geo;
+    	        revert(xy, geo);
+    	        xy.x(pos);
+    			if ( !same(geo.x(),*lon ) ) continue;
+    			Text* text = new Text();
+    			label.add(text);
+    			text->setJustification(justif);
+    			text->setVerticalAlign(MHALF);
+    		    text->setText(writeLongitude(geo));
+    		    text->push_back(xy);
+
+    		}
+    	}
+    }
+
+}
+void Proj4Projection::horizontalLabels(const LabelPlotting& label, double y, double pos, VerticalAlign align)  const
+{
+
+	const vector<double>& longitudes = label.longitudes();
+	for (vector<double>::const_iterator lon = longitudes.begin(); lon != longitudes.end(); ++lon) {
+	    // find the equation of the line using 2 points : lon/-20 -->lon/ +20
+		for ( double lat1 = -90, lat2 = -80; lat2 < 90; lat1+=10, lat2+=10) {
+			UserPoint geo1(*lon, lat1);
+			UserPoint geo2(*lon, lat2);
+			PaperPoint xy1 = (*this)(geo1);
+			PaperPoint xy2 = (*this)(geo2);
+			if ( between(y, xy1.y_, xy2.y_) ) {
+				double a = CA(xy1, xy2);
+				double b = CB(a, xy1);
+				PaperPoint xy(CX(a, b, y), y);
+				if ( !in(xy) ) continue;
+	        	UserPoint geo;
+	        	revert(xy, geo);
+	        	xy.y(pos);
+	        	if ( !same(geo.x(), *lon ) ) continue;
+	        	Text* text = new Text();
+	        	label.add(text);
+	        	text->setJustification(MCENTRE);
+	        	text->setVerticalAlign(align);
+	        	text->setText(writeLongitude(geo));
+	        	text->push_back(xy);
+
+			}
+		}
+	}
+}
+
+void Proj4Projection::labels(const LabelPlotting& label, TopAxisVisitor& visitor)  const
+{
+	if ( true ) {
+		const vector<double>& longitudes = label.longitudes();
+		const double lat = min_latitude_ + (max_latitude_-min_latitude_)*.2;
+		for (unsigned int lon = 0; lon < longitudes.size(); lon++ )
+		{
+			UserPoint point(longitudes[lon],lat);
+			PaperPoint xy = (*this)(point);
+			if ( !in(xy) ) continue;
+			Text *text = new Text();
+			label.add(text);
+			text->setText(writeLongitude(point));
+			text->push_back(xy);
+			text->setJustification(MCENTRE);
+			text->setVerticalAlign(MBOTTOM);
+			text->setBlanking(true);
+
+		}
+	}
+	else {
+		// we calculate the intersection of the longitudes with the right side
+		double y = min_pcy_ + ((max_pcy_-min_pcy_)*.2);
+		horizontalLabels(label, max_pcy_, y, MBOTTOM);
+	}
+}
+
+void Proj4Projection::revert(const vector<pair<double, double> > & in, vector<pair<double, double> > & out) const
+{
+
+
+	out.reserve(in.size());
+	for ( vector<pair<double, double> >::const_iterator pt = in.begin();  pt != in.end(); ++pt) {
+		  double x = pt->first;
+		  double y = pt->second;
+		  PaperPoint p(x, y);
+
+		  if ( PCEnveloppe_->within(p) == false ) {
+				  out.push_back(make_pair(-1000, -1000));
+			  continue;
+		  }
+
+		  int error =  pj_transform(to_, from_, 1, 1, &x, &y, NULL );
+
+		  if ( error  ) {
+			  MagLog::error() << pj_strerrno(error) << " for " << pt->first << " " << pt->second << endl;
+			  out.push_back(make_pair(-1000, -1000));
+		  }
+		  else {
+			  double lon = x*RAD_TO_DEG;
+			  double lat = y*RAD_TO_DEG;
+			  out.push_back(make_pair(lon, lat));
+		  }
+
+	}
+}
+
+void Proj4Projection::coastSetting(map<string, string>& setting, double abswidth, double absheight) const
+{
+	// work out the ratios of geographical to paper lengths
+	//const double xratio = ( xpcmax_ - xpcmin_ ) / abswidth;
+	//const double yratio = ( ypcmax_ - ypcmin_ ) / absheight;
+
+	// choose the smallest (smaller ratio means more detail required)
+	const double ratio = 10;
+
+	std::string resol = "110m";
+	if ( ratio < 100000 )  // highest resolution
+	{
+		resol = "10m";
+	}
+	else if ( ratio < 300000)   // medium resolution
+	{
+		resol = "50m";
+	}
+	resol = "110m";
+	setting["resolution"]      = resol;
+	setting["lakes"]      = resol + "/" + resol + "_lakes";
+	setting["land"]       = resol + "/" + resol + "_land";
+	setting["rivers"]     = resol + "/" + resol + "_rivers_lake_centerlines";
+	setting["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+	setting["administrative_boundaries"] = resol + "/" + resol + "_admin_1_states_provinces_shp";
+
+	MagLog::dev() << "GeoRectangularProjection::coastSetting[" << abswidth << ", " << absheight << "]->" <<  ratio << " resol: "<<resol<< endl;
+}
+void Proj4Projection::visit(MetaDataVisitor& visitor, 
+	double left, double top, 
+	double width, double height,
+	double iwidth, double iheight)
+{
+
+	ostringstream java;
+	double w = getMaxPCX() - getMinPCX();
+	double h = getMaxPCY() - getMinPCY();
+	java << "{";
+	java << "\"name\" : \"proj4\",";
+    java << "\"definition\" : \"" << definition_ <<  "\",";
+    java << "\"proj4_definition\" : \"" << projection_->definition_ <<  "\",";
+	java << "\"top\" : \"" << top <<  "\",";
+	java << "\"left\" : \"" << left <<  "\",";
+	java << "\"width\" : \"" << width <<  "\",";
+	java << "\"height\" : \"" << height <<  "\",";
+	java << "\"img_width\" : \"" << iwidth <<  "\",";
+	java << "\"img_height\" : \"" << iheight <<  "\",";
+
+	java << "\"pcxmin\" : \"" << getMinPCX() <<  "\",";
+	java << "\"pcymin\" : \"" << getMinPCY() <<  "\",";
+	java << "\"pcwidth\" : \"" << w <<  "\",";
+	java << "\"pcheight\" : \"" << h <<  "\"";
+
+	java << "}";
+	visitor.add("projection", java.str());
+	ostringstream wf;
+	wf << (w/width)<< endl;
+	wf << "0\n0\n";
+	wf << -(h/height) << endl;
+	wf << getMaxPCY() - (h/height)/2<< endl;
+	wf <<  getMinPCX() +  (w/width)/ 2<< endl;
+	visitor.add("world_file", wf.str());
+}
+
+MatrixHandler* Proj4Projection::prepareData(const AbstractMatrix& matrix) const {
+	return new GeoBoxMatrixHandler(matrix, *this);
+}
+
+void Proj4Projection::fast_reproject(double& x, double& y) const
+{
+	x *= DEG_TO_RAD;
+	y *= DEG_TO_RAD;
+	pj_transform(from_, to_, 1, 1, &x, &y, NULL );
+}
+
+double Proj4Projection::patchDistance(double res) const {
+	double x1 = 0;
+	double y1 = 60;
+	double x2 = 0;
+	double y2 = 61;
+	fast_reproject(x1, y1);
+	fast_reproject(x2, y2);
+
+	double degree = ((x1-x2) * (x1-x2)) + ((y1-y2) * (y1-y2));
+	return 1000000000;
+
+}
+void  Proj4Projection::collect(MetaDataCollector& collector) const
+{
+
+	collector["Projection"] = definition_;
+	collector["Proj4  Definition"] = projection_->definition();
+}
+void Proj4Projection::getNewDefinition(const UserPoint& ll, const UserPoint& ur, string& out) const
+{
+	map<string, string> def;
+	def["subpage_map_projection"] = definition_;
+	def["subpage_map_area_definition"] = "corners";
+	def["subpage_lower_left_longitude"] = tostring(ll.x_);
+	def["subpage_lower_left_latitude"] = tostring(ll.y_);
+	def["subpage_upper_right_longitude"] = tostring(ur.x_);
+	def["subpage_upper_right_latitude"] = tostring(ur.y_);
+	::toxml(out, def);
+	out = "{" + out + "}";
+
+}
+
+
+void Proj4Projection::setDefinition(const string& json)
+{
+	if (json.empty())
+				return;
+
+
+
+			MagJSon helper;
+			helper.interpret(json);
+
+			XmlNode node = **helper.tree_.firstElement();
+
+			node.name("");
+
+
+			set(node);
+
+
+}
diff --git a/src/common/Proj4Projection.h b/src/common/Proj4Projection.h
new file mode 100644
index 0000000..24c3d50
--- /dev/null
+++ b/src/common/Proj4Projection.h
@@ -0,0 +1,305 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file Proj4Projection.h
+    \brief Definition of Proj4Projection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Tue May 18 17:39:58 2010
+*/
+
+#ifndef _Proj4Projection_H
+#define _Proj4Projection_H
+
+#include <Transformation.h>
+#include <Proj4ProjectionAttributes.h>
+#include <XmlNode.h>
+#include <XmlNode.h>
+#include <proj_api.h>
+
+namespace magics
+{
+
+class MetaDataVisistor;
+class Epsg;
+/*! \class Proj4Projection
+    \brief Implements a new projection
+    \ingroup projection
+
+    This projection ...
+*/
+
+
+class Proj4Projection: public Transformation, public Proj4ProjectionAttributes
+{
+
+public:
+	Proj4Projection();
+	Proj4Projection(const string& definition);
+	~Proj4Projection();
+
+	/*!
+	  \brief sets  from an XML node
+	*/
+	void set(const XmlNode& node)
+	{
+        Transformation::set(node);
+        Proj4ProjectionAttributes::set(node);
+        init();
+	}
+   /*!
+	  \brief sets  from a map
+	*/
+	void set(const map<string, string>& map)
+	{
+        Transformation::set(map);
+        Proj4ProjectionAttributes::set(map);
+        init();
+	}
+    
+    virtual Transformation* clone() const {
+		Proj4Projection* transformation = new Proj4Projection(definition_);
+        transformation->copy(*this);
+		return transformation;
+	}
+	
+	/*!
+	\\brief Initialise the projection
+	*/
+	virtual void init() ;
+	/*!
+	\\brief 
+	*/
+
+
+	virtual PaperPoint operator()(const UserPoint&) const;
+	/*!
+	\\brief 
+	*/
+	virtual void fast_reproject(double& x, double& y) const;
+
+	virtual PaperPoint operator()(const PaperPoint&) const;
+	/*!
+	\\brief 
+	*/
+	void  collect(MetaDataCollector&) const;
+	virtual void revert(const PaperPoint&, UserPoint&) const;
+	
+	void revert(const vector<pair<double, double> > & in, vector<pair<double, double> > & out) const;
+	
+	/*!
+	\\brief Does the projection needs the coastalines to be shifted!
+	*/
+	virtual bool needShiftedCoastlines() const;
+	/*!
+	\\brief set the aspect ratio!
+	*/
+	virtual void aspectRatio(double&, double&) ;
+	/*!
+	\\brief set the bounding box!
+	*/
+	virtual void boundingBox(double&, double&, double&, double&) const;
+	/*!
+	\\brief return the xmin in user coordinates!
+	*/
+	virtual double getMinX() const;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual double getMinY() const;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual double getMaxX() const;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual double getMaxY() const;
+	/*!
+	\\brief set the xmin in user coordinates!
+	*/
+	virtual void setMinX(double) ;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual void setMinY(double) ;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual void setMaxX(double) ;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual void setMaxY(double) ;
+	/*!
+	\\brief return the xmin in projection coordinates!
+	*/
+	virtual double getMinPCX() const;
+	/*!
+	\\brief return the ymin in projection coordinates!
+	*/
+	virtual double getMinPCY() const;
+	/*!
+	\\brief return the xmax in projection coordinates!
+	*/
+	virtual double getMaxPCX() const;
+	/*!
+	\\brief return the ymax in projection coordinates!
+	*/
+	virtual double getMaxPCY() const;
+	/*!
+	\\brief create the grid for the longitudes!!
+	*/
+	virtual void gridLongitudes(const GridPlotting&) const;
+	/*!
+	\\brief create the grid for the latitudes!!
+	*/
+	virtual void gridLatitudes(const GridPlotting&) const;
+	/*!
+	\\brief calculate the labels
+	*/
+	virtual void labels(const LabelPlotting&, DrawingVisitor&) const;
+	/*!
+	\\brief calculate the left labels
+	*/
+	virtual void labels(const LabelPlotting&, LeftAxisVisitor&) const;
+	/*!
+	\\brief calculate the right labels
+	*/
+	virtual void labels(const LabelPlotting&, RightAxisVisitor&) const;
+	/*!
+	\\brief calculate the bottom labels
+	*/
+	virtual void labels(const LabelPlotting&, BottomAxisVisitor&) const;
+	/*!
+	\\brief calculate the top labels
+	*/
+	virtual void labels(const LabelPlotting&, TopAxisVisitor&) const;
+	virtual void coastSetting(map<string, string>&, double, double) const;
+
+	void visit(MetaDataVisitor& visitor, double left, double top, double width, double height, double imgw, double imgh);
+	void setNewPCBox(double minx, double miny, double maxx, double maxy);
+	void verticalLabels(const LabelPlotting& label, double x, double pos, Justification justif)  const;
+	void horizontalLabels(const LabelPlotting& label, double y, double pos, VerticalAlign align)  const;
+	MatrixHandler* prepareData(const AbstractMatrix&) const;
+	Polyline& getPCBoundingBox() const;
+	Polyline& getUserBoundingBox() const;
+
+	typedef void (Proj4Projection::*InitMethod)();
+	map<string,  InitMethod> methods_;
+
+	void conic();
+	void geos();
+	void simple();
+	void add(double, double);
+	double patchDistance(double) const;
+
+	void getNewDefinition(const UserPoint&, const UserPoint&, string&) const;
+	void setDefinition(const string&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 typedef void (Proj4Projection::*SettingHelper)();
+	 map<string,  SettingHelper> helpers_;
+
+	 void full();
+	 void corners();
+	 void centre();
+
+	 virtual void print(ostream&) const; 
+	 mutable projPJ from_;
+	 mutable projPJ to_;
+	 double min_pcx_;
+	 double max_pcx_;
+	 double min_pcy_;
+	 double max_pcy_;
+	 mutable Epsg*   projection_;
+	 string definition_;
+
+private:
+    //! Copy constructor - No copy allowed
+	Proj4Projection(const Proj4Projection&);
+    //! Overloaded << operator to copy - No copy allowed
+	Proj4Projection& operator=(const Proj4Projection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Proj4Projection& p)
+		{ p.print(s); return s; }
+
+};
+
+class Proj4PolarNorth : public Proj4Projection
+{
+public:
+	Proj4PolarNorth() : Proj4Projection("polar_north") {}
+};
+
+class Proj4Lambert : public Proj4Projection
+{
+public:
+	Proj4Lambert() : Proj4Projection("lambert") {}
+};
+class Proj4EPSG3857 : public Proj4Projection
+{
+public:
+	Proj4EPSG3857() : Proj4Projection("EPSG:3857") {}
+};
+class Proj4Geos : public Proj4Projection
+{
+public:
+	Proj4Geos() : Proj4Projection("geos") {}
+};
+class Proj4Goode : public Proj4Projection
+{
+public:
+	Proj4Goode() : Proj4Projection("goode") {}
+};
+class Proj4Collignon : public Proj4Projection
+{
+public:
+	Proj4Collignon() : Proj4Projection("collignon") {}
+};
+
+class Proj4Mollweide : public Proj4Projection
+{
+public:
+	Proj4Mollweide() : Proj4Projection("mollweide") {}
+};
+class Proj4Bonne : public Proj4Projection
+{
+public:
+	Proj4Bonne() : Proj4Projection("bonne") {}
+};
+
+class Proj4EPSG32661 : public Proj4Projection
+{
+public:
+	Proj4EPSG32661() : Proj4Projection(" EPSG:32661") {}
+};
+class Proj4EPSG4326 : public Proj4Projection
+{
+public:
+	Proj4EPSG4326() : Proj4Projection("EPSG:4326") {}
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/RasterData.h b/src/common/RasterData.h
new file mode 100644
index 0000000..fb932b1
--- /dev/null
+++ b/src/common/RasterData.h
@@ -0,0 +1,130 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file RasterData.h
+    \brief Definition of the Template class RasterData.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 12-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef RasterData_H
+#define RasterData_H
+
+#include "magics.h"
+
+class TeProjection;
+
+
+namespace magics {
+
+class Raster : public vector<double>
+{
+public:
+	Raster() {}
+	virtual ~Raster() {}
+	double operator()(int row, int column) const
+		{ return (*this)[row * columns_ + column]; }
+	double min() const { if(this->empty()) return -1.; return *(std::min_element(begin(), end())); }
+	double max() const { if(this->empty()) return -1.; return *(std::max_element(begin(), end())); }
+        inline int   getRows()             const { return rows_; }
+	inline int   getColumns()          const { return columns_; }	
+	inline void setColumns(int columns)  { columns_ = columns; }
+	inline void setRows(int rows)        { rows_ = rows; }
+
+protected:
+	 virtual void print(ostream& out) const { 
+	 		out << "Raster[";
+	 		out << size() << " points, ";
+	 		out << min() << ", " << max() << "]"; 
+	 }
+	 int        rows_;
+	 int        columns_;
+
+	
+private:
+    //! Copy constructor - No copy allowed
+	Raster(const Raster&);
+    //! Overloaded << operator to copy - No copy allowed
+	Raster& operator=(const Raster&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Raster& p)
+		{ p.print(s); return s; }
+
+	
+};
+
+
+class RasterData  : public Raster {
+	
+
+public:
+	RasterData() {}
+	virtual ~RasterData() {}
+	
+	TeProjection& getProjection() { return *projection_; }
+	
+	inline double getXResolution()      const { return x_; }
+	inline double getYResolution()      const { return y_; }
+
+	inline const UserPoint& getLowerLeftCorner()  const { return lowerLeft_; }
+	inline const UserPoint& getUpperRightCorner() const { return upperRight_; }
+	
+	inline void setXResolution(double x ) { x_ = x; }
+	inline void setYResolution(double y ) { y_ = y; }
+	
+	inline void setUpperRightCorner(double lon, double lat) 
+		{ upperRight_ = UserPoint(lon, lat); }
+	inline void setLowerLeftCorner(double lon, double lat) 
+		{ lowerLeft_ = UserPoint(lon, lat); }
+	
+	inline void setProjection(TeProjection* projection) { projection_ = projection; }
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+	 TeProjection* projection_;
+	 double      x_;
+	 double      y_;
+	 UserPoint             lowerLeft_;
+	 UserPoint             upperRight_;
+	 	 
+private:
+    //! Copy constructor - No copy allowed
+	RasterData(const RasterData&);
+    //! Overloaded << operator to copy - No copy allowed
+	RasterData& operator=(const RasterData&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const RasterData& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/common/SatelliteProjection.h b/src/common/SatelliteProjection.h
new file mode 100644
index 0000000..b2d94de
--- /dev/null
+++ b/src/common/SatelliteProjection.h
@@ -0,0 +1,142 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SatelliteProjection.h
+    \brief Definition of the Template class SatelliteProjection.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Fri 21-Apr-2006
+    
+    Changes:
+    
+*/
+
+#ifndef SatelliteProjection_H
+#define SatelliteProjection_H
+
+#include "magics.h"
+
+#include "Transformation.h"
+#include "SatelliteProjectionAttributes.h"
+#include "TeProjection.h"
+
+namespace magics {
+
+
+/*! \class SatelliteProjection
+    \brief Implements a new projection for satellite data
+    \ingroup projection
+
+    This projection ...
+*/
+class SatelliteProjection: public Transformation, 
+	public TeSatelliteProjection,
+	public SatelliteProjectionAttributes
+{
+
+public:
+	SatelliteProjection();
+	virtual ~SatelliteProjection();
+	
+	void set(const map<string, string>& map) {
+		SatelliteProjectionAttributes::set(map); 
+		Transformation::set(map);
+	}
+    
+	void set(const XmlNode& node) {
+		SatelliteProjectionAttributes::set(node); 
+	}
+    
+	bool accept(const string& node) { return SatelliteProjectionAttributes::accept(node); }
+
+	virtual Transformation* clone() const {
+		SatelliteProjection* object = new SatelliteProjection();
+		object->copy(*this);
+		return object;
+	}
+
+
+	void operator()(const Polyline&, BasicGraphicsObject::Container&) const;
+	void operator()(const Text<UserPoint>&, Text&) const;
+	void operator()(const vector<UserPoint>&, vector<PaperPoint>&) const;
+	void operator()(const vector<PaperPoint>&, vector<PaperPoint>&) const;
+
+	virtual TeProjection&  getProjection() { return *this; }
+
+	virtual Polyline* reproject(const Polyline& from) const;
+
+	virtual bool in(double x, double y) const; 
+
+
+	// implements the Transformation 
+	virtual void operator()(Layout&) const;
+	virtual PaperPoint operator()(const UserPoint&) const;   
+	virtual PaperPoint operator()(const PaperPoint&) const;
+	virtual UserPoint revert(const PaperPoint&) const;
+
+	virtual void gridLongitudes(const GridPlotting&, Task&) const;
+	virtual void gridLatitudes(const GridPlotting&, Task&) const;
+
+	virtual void topLabels(const LabelPlotting&, Task&) const;
+	virtual void bottomLabels(const LabelPlotting&, Task&) const;
+	virtual void leftLabels(const LabelPlotting&, Task&) const;
+	virtual void rightLabels(const LabelPlotting&, Task&) const;
+
+	void horizontalLabels(const LabelPlotting&, Task&, const string& box, double x, double miny, double maxy) const;
+	void verticalLabels(const LabelPlotting&, Task&, const string& box, double y, double minx, double maxy) const;
+
+
+	virtual double getMinX() const { return minlon_; }
+	virtual double getMaxX() const { return maxlon_; }
+	virtual double getMinY() const { return minlat_; }
+	virtual double getMaxY() const { return maxlat_; }
+
+	virtual double getMinPCX() const { return llx_; }
+	virtual double getMaxPCX() const { return urx_; }
+	virtual double getMinPCY() const { return lly_; }
+	virtual double getMaxPCY() const { return ury_; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+ 
+	mutable double llx_;
+	mutable double lly_;
+	mutable double urx_;
+	mutable double ury_;
+
+	mutable double minlon_;
+	mutable double maxlon_;
+	mutable double minlat_;
+	mutable double maxlat_;
+
+private:
+    //! Copy constructor - No copy allowed
+	SatelliteProjection(const SatelliteProjection&);
+    //! Overloaded << operator to copy - No copy allowed
+	SatelliteProjection& operator=(const SatelliteProjection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SatelliteProjection& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/SciMethods.cc b/src/common/SciMethods.cc
new file mode 100644
index 0000000..59e31fb
--- /dev/null
+++ b/src/common/SciMethods.cc
@@ -0,0 +1,318 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file SciMethods.cc
+    \brief Definition of SciMethods.
+    \author Graphics Section, ECMWF
+
+    Started: September 2011
+*/
+
+#include <math.h>
+
+#include "SciMethods.h"
+
+namespace magics 
+{
+  
+const double KAPPA=0.285611; //Rd/cp
+
+/*! Computes the distance on Earth in km */
+double geoDistanceInKm(double fi1,double la1,double fi2,double la2)
+{   
+  	double rfi1=RAD(fi1);
+	double rla1=RAD(la1);
+	double rfi2=RAD(fi2);
+	double rla2=RAD(la2);
+
+   	if(rla1 != rla2)
+     	{
+       		double d=sin(rfi1)*sin(rfi2)+cos(rfi1)*cos(rfi2)*cos(fabs(rla1-rla2));
+       		return acos(d)*EarthRadiusInKm;
+     	}
+	else
+	{  
+   	      	return fabs(rfi1-rfi2)*EarthRadiusInKm;
+
+	}
+}
+
+/*! 
+  \brief computes potential temperature
+
+   This method computes the potential temperature for a given
+   temperature and pressure.
+   
+   \param t temperature in K
+   \param p pressure in Pa 
+   \return potential temperature in K
+ */
+double theta(double t, double p)
+{
+	return t*pow(100000./p,KAPPA); 
+} 
+
+/*! 
+  \brief computes temperature from potential temperature
+
+   This method computes the temperature for a given 
+   potential temperature and pressure.
+   
+   \param th potential temperature in K
+   \param p pressure in Pa   
+   \return temperature in K
+   
+*/
+double temperatureFromTheta(double th, double p)
+{	
+   	return th*pow(p/100000.,KAPPA); 
+}
+
+/*! 
+  \brief computes pressure from potential temperature
+
+   This method computes the pressure for a given 
+   potential temperature and temperature.
+   
+   \param th potential temperature in K
+   \param t temperature in K 
+   \return pressure in Pa   
+*/
+double pressureFromTheta(double th, double t)
+{	
+   	return 100000.*pow(t/th,1./KAPPA); 
+}
+
+/*! 
+  \brief computes the dew point temperature
+
+   This method computes the dew point
+   temperature for a given temperature
+   and relative humidity.
+   
+   \param t  temperature in K
+   \param rh relative humidity in %
+   \return   dew point temperature in K
+*/
+
+double tDew(double t, double rh)
+{
+	double td;
+  	double tc=t-273.16;
+  	double a=17.27;
+ 	double b=237.7;
+
+  	if (rh>=100.) td=tc; 
+  	else 
+ 	{
+  		double gamma=a*tc/(b+tc)+log(rh/100.);
+    		td=b*gamma/(a-gamma);
+   	}
+   
+  	return td+273.16;
+} 
+
+/*! 
+  \brief computes the wet bulb temperature
+ 
+  This method computes the wet bulb temperature.
+
+  \param td dew point temperature in K 
+  \param t  temperature in K  
+  \param p  pressure in Pa
+  \return   wet bulb temperature in K   
+*/   
+
+double tWet(double td,double t,double p)
+{
+  	double r=mixingRatio(td,p);  
+  	double th=theta(t,p);
+	
+	double pSec=p;
+	for(int i=0; i < 10; i++)
+	{
+	  	double x=0.02*(temperatureFromMixingRatio(r,pSec)-temperatureFromTheta(th,pSec));
+		if(abs(x) < 0.01)
+		{
+		  	break;
+		}
+		pSec=pow(2.,x);
+	}
+	
+	double tSec=temperatureFromTheta(th,pSec);
+	
+	double thSat = thetaEq(tSec,pSec);
+	return temperatureFromThetaEq(thSat, p);
+}
+
+/*! 
+  \brief computes the equivalent potential temperature from initial conditions
+  
+   \param td  dew point temperature in K
+   \param t   temperature in K
+   \param p   pressure in Pa
+   \return   equivalent potential temperature in K 
+*/
+
+double thetaEq(double td,double t,double p)
+{
+	double tLCL=temperatureLCL(td,t);	
+	double th=theta(t,p);	
+	double thEq=th * exp(2.6518986 * mixingRatio(td,p)/tLCL);	
+ 	return thEq;
+}
+
+/*! 
+  \brief computes the equivalent potential temperature on a saturation adiabat
+
+  This method computes the equivalent potential temperature for a saturation 
+  adiabat.
+  
+  \param t  temperature in K  
+  \param p  pressure in Pa
+  \return   equvalent potential temperature in K   
+*/  
+
+double thetaEq(double t,double p)
+{
+	return theta(t,p)/exp(-2.6518986*mixingRatio(t,p)/t);
+}	
+
+/*! 
+  \brief computes the temperature on saturation adiabat
+
+  This method computes the temperature on a saturation adiabat for
+  a given equvalent potential temperature and pressure.
+
+  \param thEq equivalent potential temperature   
+  \param p    pressure in Pa
+  \return     temperature in K 
+*/   
+
+double temperatureFromThetaEq(double thEq,double p)
+{
+  	double tq=253.16;
+	double d=120.;
+  	for(int i=0; i<12; i++)
+	{  
+		d/=2;
+		double x = thEq*exp(-2.6518986*mixingRatio(tq,p)/tq)-theta(tq,p);	
+		if(abs(x) <= 0.0000001)
+		{	
+			break;
+		}	
+		tq+=((x<0)?-1:1)*abs(d);			
+	}
+	
+	return tq;
+}
+ 
+/*! 
+  \brief computes the saturation vapour pressure over water from temperature
+ 
+  This method computes the saturation vapour pressure
+  over water from temperature.
+
+  \param t temperature in K 
+  \return pressure in mb   
+*/   
+
+double saturationVapourPressure(double t)
+{
+	double c1 = 23.832241-5.02808*log10(t);
+   	double c2 = 3.49149-1302.8844/t;
+	double c3 = 11.344-0.0303998*t;
+  	return (exp10(c1-1.3816E-7*exp10(c3)+8.1328E-3*exp10(c2)-2949.076/t));
+} 
+  
+/*! 
+  \brief computes the saturation  mixing ratio
+
+  This method computes the mixing ratio.
+
+  \param t  temperature in K 
+  \param p  pressure in Pa
+  \return   saturation mixing ratio in g/kg 
+*/
+
+double mixingRatio(double t, double p)
+{
+	double e=saturationVapourPressure(t); 
+  	return 622.*e/(0.01*p-e); 
+}
+
+
+double temperatureFromMixingRatio(double r, double p)
+{		
+  	double pmb=p*0.01;
+  	double c = log10(r*pmb/(622.+r));
+	
+	return exp10(0.0498646455*c + 2.4082965)-280.23475+
+	          38.9114*pow(2.,exp10(0.0915*c)-1.2035);
+}
+
+/*! 
+  \brief computes the temperature of LCL
+
+   This method computes the temperature of
+   the lifted condensation level (LCL) 
+   
+   \param td  dew point temperature in K
+   \param tf  temperature in K
+   \return   LCL temperature in Pa
+*/
+
+double temperatureLCL(double td,double t)
+{
+  double tdc=td-273.16;
+  double tLCL=tdc-(0.001296*tdc+0.1963)*(t-td);
+  
+  return tLCL+273.5;
+} 
+
+/*! 
+  \brief computes the pressure of LCL
+
+   This method computes the pressure of
+   the lifted condensation level (LCL) 
+   
+   \param td  dew point temperature in K
+   \param t  temperature in K
+   \param p   pressure in Pa
+   \return   LCL pressure in Pa
+*/
+
+double pressureLCL(double td, double t, double p)
+{
+  	double pLCL;
+  	double tLCL=temperatureLCL(td,t);
+
+	if (tLCL == t) pLCL=p;
+  	else 
+    	{ 
+    		pLCL=p*pow(tLCL/t,3.5); 
+    	}
+  
+	return pLCL;
+} 
+
+
+} //end namespace
\ No newline at end of file
diff --git a/src/common/SciMethods.h b/src/common/SciMethods.h
new file mode 100644
index 0000000..6fede11
--- /dev/null
+++ b/src/common/SciMethods.h
@@ -0,0 +1,64 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file SciMethods.h
+    \brief Definition of SciMethods.
+    \author Graphics Section, ECMWF
+
+    Started: September 2011
+*/
+
+#ifndef SciMethods_H
+#define SciMethods_H
+
+
+#include "magics.h"
+
+namespace magics
+{
+/*! Earth radius in km */
+const double EarthRadiusInKm=6378.388;   //Earth radius in km 
+
+/*! Computes the distance on Earth in km */
+double geoDistanceInKm(double,double,double,double);
+
+/*!  computes potential temperature */
+double theta(double t, double p);
+
+/*!  computes temperature form potential temperature */
+double temperatureFromTheta(double th, double p);
+
+/*!  computes pressure potential temperature */
+double pressureFromTheta(double th, double t);
+
+double tDew(double t, double rh);
+double tWet(double td,double t,double p);
+double thetaEq(double td,double t,double p);
+double thetaEq(double t,double p);
+double temperatureFromThetaEq(double thSat,double p);
+double saturationVapourPressure(double t);
+double mixingRatio(double t, double p);
+double temperatureFromMixingRatio(double r, double p);
+double temperatureLCL(double td,double t);
+double pressureLCL(double td, double t, double p);
+}
+
+#endif
\ No newline at end of file
diff --git a/src/common/Seconds.cc b/src/common/Seconds.cc
new file mode 100644
index 0000000..22ff832
--- /dev/null
+++ b/src/common/Seconds.cc
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+
+
+#include "Seconds.h"
+
+using namespace magics;
+
+Seconds::Seconds(double seconds):
+	seconds_(seconds)
+{
+    
+}
+
+Seconds::Seconds(const timeval& time):
+	seconds_(time.tv_sec + time.tv_usec / 1000000.0)
+{
+}
+
+static struct  {
+    int length_;
+    char *name_;
+} periods[] = {
+    {7 * 24 * 60 * 60, "week",},    
+    {24 * 60 * 60, "day",}, 
+    {60 * 60, "hour",}, 
+    {60, "minute",},    
+    {1, "second",}, 
+    {0,0,},
+};
+
+namespace magics {
+ostream& operator<<(ostream& s,const Seconds&  sec)
+{
+	double t = sec.seconds_;
+    long n  = long(t);
+    int flg = 0;
+
+    for(int i=0;periods[i].length_;i++)
+    {
+        long m = n / periods[i].length_;
+        if(m) {
+            if(flg) s << ' ';
+            s << m << ' ' << periods[i].name_;
+            if(m>1) s << 's';
+            n %= periods[i].length_;
+            flg++;
+        }
+    }   
+
+    if(!flg) s << t << " second";
+
+	return s;
+}
+}
+Seconds::operator string() const
+{
+	ostringstream s;
+
+	s << *this << ends;
+
+	return s.str();
+}
diff --git a/src/common/Seconds.h b/src/common/Seconds.h
new file mode 100644
index 0000000..3183601
--- /dev/null
+++ b/src/common/Seconds.h
@@ -0,0 +1,60 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Seconds.h
+// Baudouin Raoult - ECMWF Jul 96
+
+#ifndef Seconds_H
+#define Seconds_H
+ 
+
+#include "magics.h"
+
+namespace magics {
+
+class Seconds {
+public:
+
+// -- Contructors
+
+	Seconds(double);
+	Seconds(const timeval&);
+
+// -- Operators
+
+	operator string() const;
+	operator double() const { return seconds_; }
+    double seconds_;
+
+	friend ostream& operator<<(ostream&,const Seconds&);
+
+private:
+
+// No copy allowed
+
+	Seconds(const Seconds&);
+	Seconds& operator=(const Seconds&);
+
+// -- Members
+
+	
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/Static.cc b/src/common/Static.cc
new file mode 100644
index 0000000..535d9d6
--- /dev/null
+++ b/src/common/Static.cc
@@ -0,0 +1,45 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include "Static.h"
+#include "MagException.h"
+#include "DriverStatic.h"
+
+
+
+using namespace magics;
+
+Static::Static() 
+{
+    DriverStatic drivers;
+}
+
+Static::~Static() 
+{
+   
+}
+
+
+#include "PaperDimension.h"
+static SimpleObjectMaker<A4, PaperDimension> a4("a4");
+static SimpleObjectMaker<A3, PaperDimension> a3("a3");
+static SimpleObjectMaker<A5, PaperDimension> a5("a5");
+static SimpleObjectMaker<A6, PaperDimension> a6("a6");
+
+
+
diff --git a/src/common/Static.h b/src/common/Static.h
new file mode 100644
index 0000000..41ada13
--- /dev/null
+++ b/src/common/Static.h
@@ -0,0 +1,35 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef Static_H
+#define Static_H
+
+#include "magics.h"
+
+namespace magics {
+   
+class Static {
+
+public:
+	Static();
+	virtual ~Static();
+};
+
+}
+
+#endif
diff --git a/src/common/Symbol.cc b/src/common/Symbol.cc
new file mode 100644
index 0000000..a83548e
--- /dev/null
+++ b/src/common/Symbol.cc
@@ -0,0 +1,302 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Symbol.cc
+    \brief Implementation of Symbol graphics class (template).
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#include "Symbol.h"
+#include "Polyline.h"
+#include "ImportObject.h"
+#include "Text.h"
+
+using namespace magics;
+
+
+Symbol::Symbol() : marker_(0), height_(0.2),outline_(false), connectLine_(false)
+{
+}
+
+
+Symbol::~Symbol() 
+{
+}
+
+
+void Symbol::print(ostream& out)  const
+{
+	out << "Symbol<P>[";
+	BasicGraphicsObject::print(out);
+	out << ", height = " << height_;
+	out << ", marker = " << marker_;
+	out << ", nb_points = " << this->size();
+	out << "]";
+}
+
+
+SymbolProperties::SymbolProperties(Colour colour, double height, const string& marker, const string& label) : 
+        colour_(colour), 
+        height_(height),
+        marker_(marker),
+        label_(label), position_(Symbol::M_NONE),outline_(false),
+        connectLine_(false), image_(false)
+{ font_.size(height_); font_.colour(colour_); }
+
+SymbolProperties::SymbolProperties(Colour colour, double height, int marker, const string& label) : 
+        colour_(colour), 
+        height_(height),
+        marker_(Symbol::convert(marker)),
+        label_(label),position_(Symbol::M_NONE),outline_(false),
+        connectLine_(false), image_(false)
+{ font_.size(height_); font_.colour(colour_); }
+
+SymbolProperties::SymbolProperties() : 
+        colour_(Colour("none")), 
+        height_(0),
+        marker_(Symbol::convert(1)),
+        label_(""), position_(Symbol::M_NONE),outline_(false),
+        connectLine_(false), image_(false)
+{ font_.size(height_); font_.colour(colour_); }
+
+
+void SymbolProperties::setSymbol(const string& symbol, int marker)
+{
+	marker_ = !symbol.empty() ? symbol : Symbol::convert(marker);
+}
+
+Symbol* SymbolProperties::symbol(const string& type) const
+{
+	Symbol* symbol = 0;
+
+	const unsigned text_size = text_.size();
+	
+	if ( magCompare(type, "marker")  )	{
+		if ( image_  ) {
+			ImageSymbol* img =  new ImageSymbol(image_path_, image_format_);
+			img->set(image_width_, image_height_);
+			symbol = img;
+		}
+
+		else
+			if ( text_size  ) {
+				TextSymbol* text = new TextSymbol();
+				text->position(position_);
+				symbol = text;
+				text->font(font_);
+				text->text(text_);
+				text->blanking(blanking_);
+			}
+			else
+				symbol = new Symbol();
+	}
+	if ( magCompare(type, "both") ) {
+		TextSymbol* text = new TextSymbol();
+
+		text->position(position_);
+		symbol = text;
+		text->font(font_);
+		text->text(text_);
+		text->blanking(blanking_);
+	}
+
+	if ( magCompare(type, "text") )
+	{
+		if ( text_size == 0 ) {
+			SimpleTextSymbol* stext = new SimpleTextSymbol(label_); 
+			stext->position(position_);
+			symbol = stext;
+			stext->font(font_);
+			vector<string> helper;		
+			helper.push_back(label_);
+			stext->text(helper);
+		}
+		else {
+			TextSymbol* text = new TextSymbol();		
+			text->position(position_);
+			symbol = text;
+			text->font(font_);
+			text->text(text_);
+			text->blanking(blanking_);
+		}
+	}
+	if ( magCompare(type, "number") )
+	{
+		TextSymbol* text = new TextSymbol();		
+		text->position(position_);
+		symbol = text;
+		text->font(font_);
+		text->text(text_);
+		text->blanking(blanking_);
+		symbol->setColour(Colour("none"));
+		symbol->setSymbol(marker_);
+		symbol->setHeight(0.0);
+
+		return symbol;
+	}
+	
+	symbol->setColour(colour_);
+	symbol->setSymbol(marker_);
+	symbol->setHeight(height_);
+	symbol->outline(outline_, outlineColour_, outlineThickness_, outlineStyle_);
+	symbol->connectline(connectLine_, connectLineColour_, connectLineThickness_, connectLineStyle_);
+
+	return symbol;
+}
+
+
+void ComplexSymbol::print(ostream& out) const
+{
+	out << "ComplexSymbol[" << endl;
+	for (vector<GraphicsItem*>::const_iterator item = items_.begin(); item != items_.end(); ++item)
+		out << **item  << ", " << endl;
+	out << "]" << endl;
+}
+
+
+struct WithinFunction
+{
+	WithinFunction(const Polyline& box) : boundingbox_(box) {}
+	const Polyline& boundingbox_;
+	bool operator()(const PaperPoint& point) {
+		return ( boundingbox_.within(point) == false );
+	}
+};
+
+void Symbol::redisplay(const BaseDriver& driver) const
+{
+	if ( !connectLine_ ) {
+		if ( !colour_.none()  )
+			driver.redisplay(*this);
+		return;
+	}
+	// We create a Polyline!
+	Polyline line;
+	line.setColour(connectLineColour_);
+	line.setLineStyle(connectLineStyle_);
+	line.setThickness(connectLineThickness_);
+	for ( vector<PaperPoint>::const_iterator point = begin(); point != end(); ++point) {
+		line.push_back(*point);
+	}
+	//first  we remove the point that are outside!
+	// here we cast to be able to clean the symbol list!
+	Symbol symbol = *this;
+	symbol.connectline(false);
+
+	vector<PaperPoint>::iterator last = std::remove_if(symbol.begin(), symbol.end(), WithinFunction(boundingbox_));
+	symbol.erase(last, symbol.end());
+
+	driver.redisplay(symbol);
+
+	vector<Polyline> lines;
+
+	boundingbox_.clip(line, lines);
+
+	for ( vector<Polyline>::const_iterator l = lines.begin(); l != lines.end(); ++l) {
+
+		driver.redisplay(*l);
+	}
+}
+
+void Symbol::boundingbox(const Polyline& boundingbox)
+{
+	boundingbox_ = boundingbox;
+}
+
+void TextSymbol::redisplay(const BaseDriver& driver) const
+{
+	if (!connectLine()) {
+	if (position_ == M_CENTRE) {
+		// send text and symbol;
+		Symbol::redisplay(driver);
+		// Now we display the text
+		vector<PaperPoint>::const_iterator point = begin();
+		vector<string>::const_iterator info = texts_.begin();
+		while ( point != end() || info != texts_.end() ) {
+			Text text;
+			text.addText(*info, font_);
+			text.push_back(*point);
+			text.setBlanking(blanking_);
+			text.setVerticalAlign(MHALF);
+			text.setJustification(MCENTRE);
+			++point;
+			text.redisplay(driver);
+
+			++info;
+		}
+		return;
+	}
+	// We make sure here that we have the right number of texxt.
+	if ( texts_.empty()) {
+		texts_.push_back("?");
+	}
+	while ( texts_.size() < size() ) {
+		texts_.push_back( texts_.back() );
+	}
+
+	driver.redisplay(*this);
+	return;
+	}
+	// We create a Polyline!
+		Polyline line;
+		line.setColour(connectLineColour());
+		line.setLineStyle(connectLineStyle());
+		line.setThickness(connectLineThickness());
+		for ( vector<PaperPoint>::const_iterator point = begin(); point != end(); ++point) {
+			line.push_back(*point);
+		}
+
+		vector<Polyline> lines;
+
+		boundingbox_.clip(line, lines);
+
+		for ( vector<Polyline>::const_iterator l = lines.begin(); l != lines.end(); ++l) {
+
+			driver.redisplay(*l);
+		}
+		//first  we remove the point that are outside!
+		// here we cast to be able to clean the symbol list!
+		TextSymbol symbol = *this;
+		symbol.connectline(false);
+
+		vector<PaperPoint>::iterator last = std::remove_if(symbol.begin(), symbol.end(), WithinFunction(boundingbox_));
+		symbol.erase(last, symbol.end());
+
+		driver.redisplay(symbol);
+
+
+}
+
+void ImageSymbol::redisplay(const BaseDriver& driver) const
+{
+	for ( vector<PaperPoint>::const_iterator point = begin(); point != end(); ++point) {
+		ImportObject*  object = new ImportObject();
+		object->setOrigin(*point);
+		object->setPath(path_);
+		object->setFormat(format_);
+
+		object->setWidth(width_);
+		object->setHeight(height_);
+		driver.redisplay(*object);
+	}
+}
diff --git a/src/common/Symbol.h b/src/common/Symbol.h
new file mode 100644
index 0000000..86e49ac
--- /dev/null
+++ b/src/common/Symbol.h
@@ -0,0 +1,294 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Symbol.h
+    \brief Definition of Symbol graphics class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes: 
+    
+*/
+#ifndef Symbol_H
+#define Symbol_H
+
+#include "magics.h"
+
+#include "BasicGraphicsObject.h"
+#include "BaseDriver.h"
+#include "SymbolItem.h"
+#include "Polyline.h"
+
+namespace magics {
+
+
+class Symbol: public BasicGraphicsObject, public vector<PaperPoint> {
+
+public:
+	enum TextPosition { M_NONE, M_BELOW , M_ABOVE , M_LEFT , M_RIGHT, M_CENTRE};
+	Symbol();
+	virtual ~Symbol();
+
+	void redisplay(const BaseDriver& driver) const;
+
+	void setMarker(int m)
+	{ 
+		marker_ = m;
+		symbol_ = convert(m);
+	}
+	
+	static string convert(int m)
+	{
+		ostringstream symbol;
+		symbol << "magics_" << m; 
+		return symbol.str();
+	}
+
+	    void boundingbox(const Polyline& boundingbox);
+	virtual void push_back(const PaperPoint& point,const string& ="") {
+		 vector<PaperPoint>::push_back(point);
+	}
+	
+	int getMarker() const {return marker_;} 
+
+	void   setSymbol(const string& symbol) { symbol_ = symbol; }
+	const string& getSymbol() const  {return symbol_;} 
+
+	void   setColour(const Colour& colour) { colour_ = colour; }
+	const Colour& getColour() const  {return colour_;} 
+
+	void   setHeight(double h){height_ = h;}
+	double getHeight() const  {return height_;}
+	
+	void   setDistanceApart(double a){apart_ = a;}
+	double getDistanceApart() const  {return apart_;}
+
+	void   outlineColour(const Colour& a){ outlineColour_ = a;}
+
+	const Colour& outlineColour() const { return outlineColour_; }
+	bool   outline() const { return outline_;}
+
+	int outlineThickness() const { return outlineThickness_; }
+	LineStyle outlineLineStyle() const { return outlineStyle_; }
+
+	void outline(bool outline, const Colour& colour, int thickness, LineStyle style) {
+		outline_ = outline;
+		outlineColour_ = colour;
+		outlineThickness_ = thickness;
+		outlineStyle_ = style;
+	}
+	void connectline(bool connect) { connectLine_ = connect; }
+	void connectline(bool connectline, const Colour& colour, int thickness, LineStyle style) {
+		connectLine_ = connectline;
+		connectLineColour_ = colour;
+		connectLineThickness_ = thickness;
+		connectLineStyle_ = style;
+	}
+	int connectLineThickness() const { return connectLineThickness_; }
+	LineStyle connectLineStyle() const { return connectLineStyle_; }
+	const Colour& connectLineColour() const { return connectLineColour_; }
+	bool connectLine() const { return connectLine_; }
+
+//private:
+// No copy allowed
+
+
+protected:
+	virtual void print(ostream&) const; 
+	Polyline boundingbox_;
+private:
+	int	marker_;
+	double	height_;
+	string	symbol_;
+	Colour colour_;
+	double apart_;
+	Colour outlineColour_;
+	LineStyle outlineStyle_;
+	int outlineThickness_;
+	bool outline_;
+
+	bool connectLine_;
+	Colour connectLineColour_;
+	LineStyle connectLineStyle_;
+	int connectLineThickness_;
+
+
+
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const Symbol& p)
+		{ p.print(s); return s; }
+};
+
+
+class TextSymbol : public Symbol
+{
+public:
+	TextSymbol() : position_(M_BELOW) {}
+	~TextSymbol() {}
+
+	void push_back(const PaperPoint& point, const string& text) {
+		Symbol::push_back(point);
+		if ( !text.empty() ) texts_.push_back(text);
+	}
+
+	void text(const vector<string>& text) { texts_ = text; }
+	void redisplay(const BaseDriver& driver) const;
+
+	vector<string>::const_iterator textBegin() const { return texts_.begin(); }
+	vector<string>::const_iterator textEnd() const { return texts_.end(); }
+	const vector<string>& text() const {return texts_; } 	 
+
+	void font(const MagFont& font) { font_ = font; }
+	const MagFont& font() const { return font_; }
+	void blanking(bool blanking) { blanking_ = blanking; }
+	bool blanking() const { return blanking_; }
+
+	void position(TextPosition position) { position_ = position; }
+	TextPosition position() const { return position_; }
+
+protected:
+	mutable vector<string> texts_;
+	MagFont font_;
+	TextPosition position_;
+	bool blanking_;
+};
+
+
+class ImageSymbol : public Symbol
+{
+public:
+	ImageSymbol(const string& path, const string& format) : path_(path), format_(format) {}
+	~ImageSymbol() {}
+	void redisplay(const BaseDriver& driver) const;
+
+	void set(double width, double height) { width_ = width; height_ = height; }
+
+protected:
+	string path_;
+	string format_;
+	double width_;
+	double height_;
+};
+class SimpleTextSymbol : public TextSymbol
+{
+public:
+	SimpleTextSymbol(const string& text) : text_(text) {}
+	~SimpleTextSymbol() {}
+	
+	void push_back(const PaperPoint& point) {
+		TextSymbol::push_back(point, text_);
+	}
+	void push_back(const PaperPoint& point, const string&) {
+			TextSymbol::push_back(point, text_);
+		}
+protected:
+	string text_;
+};
+
+
+class ComplexSymbol : public Symbol
+{
+public:
+	ComplexSymbol(): rows_(1), columns_(1) {}
+	ComplexSymbol(int rows, int columns): rows_(rows), columns_(columns) {}
+	~ComplexSymbol() {}
+	
+	void redisplay(const BaseDriver& driver) const { MagLog::dev() << "Redisplay -->" << *this << endl; driver.redisplay(*this); }
+	void add(GraphicsItem* item) { items_.push_back(item);}
+	vector<GraphicsItem*>::const_iterator itemBegin() const { return items_.begin(); }
+	vector<GraphicsItem*>::const_iterator itemEnd() const { return items_.end(); }
+	const vector<GraphicsItem*>& items() const { return items_; }
+
+protected:
+	virtual void print(ostream&) const; 
+	VectorOfPointers<vector<GraphicsItem*> > items_;
+	int rows_;
+	int columns_;
+};
+
+struct SymbolProperties
+{
+	Colour    colour_;
+	double    height_;
+	string    marker_;
+	string    label_;
+	MagFont   font_;
+	bool      blanking_;
+	Symbol::TextPosition position_;
+	vector<string> text_;
+
+	bool outline_;
+	Colour outlineColour_;
+	LineStyle outlineStyle_;
+	int outlineThickness_;
+
+	bool connectLine_;
+	Colour connectLineColour_;
+	LineStyle connectLineStyle_;
+	int connectLineThickness_;
+
+
+	bool  image_;
+	string image_path_;
+	string image_format_;
+	int    image_width_;
+	int    image_height_;
+
+    SymbolProperties(Colour colour, double height, const string& marker, const string& label="");
+    SymbolProperties(Colour colour, double height, int marker, const string& label=""); 
+    SymbolProperties();
+
+    void setSymbol(const string& symbol, int marker);
+    void position(Symbol::TextPosition position) { position_ = position; }
+
+    virtual ~SymbolProperties() {}
+    bool  operator<(const SymbolProperties& other) const
+    {
+        if ( other.colour_ == colour_ ) 
+            if ( other.height_ == height_ )
+                return other.marker_ < marker_;
+            else return other.height_ < height_;
+        else 
+            return other.colour_ < colour_;
+    }
+    
+    void label(const string& label) { label_ = label; }
+    
+    virtual void print(ostream& out) const {
+        out << "SymbolProperty[";
+        out << colour_ << "(colour),";
+        out << height_ << "(height),";
+        out << marker_ << "(marker)";
+        out << label_ << "(label)";
+        out << "]";
+    }
+    
+    Symbol* symbol(const string&) const;
+//    
+// -- Friends
+	//! Overloaded << operator to call print().
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolProperties& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/SymbolItem.cc b/src/common/SymbolItem.cc
new file mode 100644
index 0000000..01cea66
--- /dev/null
+++ b/src/common/SymbolItem.cc
@@ -0,0 +1,90 @@
+/*! \file GraphicItem.cc
+    \brief Implementation of the Template class GraphicItem.
+    
+    Magics Team - ECMWF 2009
+    
+    Started: Tue 27-Jan-2009
+    
+    Changes:
+    
+*/
+
+
+
+#include "SymbolItem.h"
+#include "BaseDriver.h"
+
+using namespace magics;
+
+GraphicsItem::GraphicsItem() 
+{
+}
+
+
+GraphicsItem::~GraphicsItem() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GraphicsItem::print(ostream& out)  const
+{
+	out << "GraphicsItem[";
+	out << "x=" << x_<< ", ";
+	out << "y=" << y_;
+	out << "]";
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SymbolItem::print(ostream& out)  const
+{
+	out << "SymbolItem[";
+	out << "x=" << x_<< ", ";
+	out << "y=" << y_<< ", ";
+	out << "symbol=" << symbol_<< ", ";
+	out << "colour=" << colour_;	
+	out << "]";
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TextItem::print(ostream& out)  const
+{
+	out << "TextItem[";
+	out << "x=" << x_ << ", ";
+	out << "y=" << y_<< ", ";
+	out << "text=" << text_<< ", ";
+	out << "font=" << font_;	
+	out << "]";
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void FlagItem::print(ostream& out)  const
+{
+	out << "FlagItem[";
+	out << "x=" << x_<< ", ";
+	out << "y=" << y_;
+	out << "]";
+}
+
+void FlagItem::redisplay(const ComplexSymbol& symbol, const BaseDriver& driver) 
+{
+	driver.redisplay(*this, symbol);
+}
+
+void SymbolItem::redisplay(const ComplexSymbol& symbol, const BaseDriver& driver) 
+{
+	driver.redisplay(*this, symbol);
+}
+void TextItem::redisplay(const ComplexSymbol& symbol, const BaseDriver& driver) 
+{
+	driver.redisplay(*this, symbol);
+}
+
+
diff --git a/src/common/SymbolItem.h b/src/common/SymbolItem.h
new file mode 100644
index 0000000..135f0ea
--- /dev/null
+++ b/src/common/SymbolItem.h
@@ -0,0 +1,125 @@
+/*! \file SymbolItem.h
+    \brief Definition of the Template class SymbolItem.
+    
+    Magics Team - ECMWF 2009
+    
+    Started: Tue 27-Jan-2009
+    
+    Changes:
+    
+*/
+
+#ifndef SymbolItem_H
+#define SymbolItem_H
+
+#include "magics.h"
+#include "MagFont.h"
+#include "ArrowProperties.h"
+
+namespace magics {
+class BaseDriver;
+class ComplexSymbol;
+
+class GraphicsItem {
+
+public:
+	GraphicsItem();
+	virtual ~GraphicsItem();
+	void x(int x) { x_ = x; }
+	void y(int y) { y_ = y; }
+	int x() const { return x_;}
+	int y() const { return y_; }
+	virtual void redisplay(const ComplexSymbol&, const BaseDriver&) {}
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 int x_; // relative coordinate to the Symbol parent
+	 int y_;
+private:
+    //! Copy constructor - No copy allowed
+	GraphicsItem(const GraphicsItem&);
+    //! Overloaded << operator to copy - No copy allowed
+	GraphicsItem& operator=(const GraphicsItem&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GraphicsItem& p)
+		{ p.print(s); return s; }
+
+};
+
+class SymbolItem : public GraphicsItem
+{
+public:
+	SymbolItem() {}
+	~SymbolItem() {}
+	
+	void redisplay(const ComplexSymbol&, const BaseDriver&);
+	
+	double height() const { return height_; }
+	void height(double height)  { height_ = height; }
+	
+	const string& symbol() const { return symbol_; }
+	void symbol(const string& symbol)  { symbol_ = symbol; }
+
+	const Colour& colour() const { return colour_; }
+	void colour(const Colour& colour)  { colour_ = colour; }	
+
+protected:
+	virtual void print(ostream&) const; 
+	double	height_;
+	string	symbol_;
+	Colour colour_;
+	
+};
+class TextItem : public GraphicsItem
+{
+public:
+	TextItem() {}
+	~TextItem() {}
+	
+	void redisplay(const ComplexSymbol&, const BaseDriver&);
+	
+	const string& text() const { return text_; }
+	void text(const string& text)  { text_ = text; }
+	
+	MagFont font() const { return font_; }
+	void font(const MagFont& font)  { font_ = font; }
+	
+protected:
+	virtual void print(ostream&) const; 
+	string	text_;
+	MagFont font_;
+	
+};
+class FlagItem : public GraphicsItem, public ArrowProperties
+{
+	
+public:
+	FlagItem() {}
+	~FlagItem() {}
+	
+	void redisplay(const ComplexSymbol&, const BaseDriver&);
+	
+	double length() const             { return length_; }
+	void length(double length)        { length_ = length; }
+
+	void speed(double speed)          { speed_ = speed; }
+	double speed() const              { return  speed_; }
+	
+	void direction(double direction)  { direction_ = direction; }
+	double direction() const          { return  direction_; }
+	
+	void convention(FlagConvention convention)  { convention_ = convention; }
+	FlagConvention convention() const           { return convention_; }
+	
+protected:
+	virtual void print(ostream&) const; 
+	double         length_;
+	FlagConvention convention_;
+	double speed_;
+	double direction_; 
+};
+} // namespace magics
+#endif
diff --git a/src/common/TableDefinition.h b/src/common/TableDefinition.h
new file mode 100644
index 0000000..b11189e
--- /dev/null
+++ b/src/common/TableDefinition.h
@@ -0,0 +1,115 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinition.h
+    \brief Definition of the Template class TableDefinition.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef TableDefinition_H
+#define TableDefinition_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+namespace magics {
+
+class XmlNode;
+
+template <class T>
+
+class TableDefinition : public vector<T> {
+
+
+public:
+    typedef vector<double>::const_iterator TableIterator; 
+	TableDefinition() {}
+	virtual ~TableDefinition() {}
+	virtual TableDefinition* clone() const = 0;
+	virtual void set(const XmlNode&) = 0;
+	virtual void prepare() {}
+	virtual void adjust(double, double) {}
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	
+private:
+    //! Copy constructor - No copy allowed
+	TableDefinition(const TableDefinition&);
+    //! Overloaded << operator to copy - No copy allowed
+	TableDefinition& operator=(const TableDefinition&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDefinition& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+template <class T>
+class TableDefinitionInterface
+{
+public:
+	TableDefinitionInterface() : helper_(0) {}
+	virtual void set(const XmlNode& node) 
+		{  assert(helper_); helper_->set(node); } 
+	int size() 								{ assert(helper_); return helper_->size(); }
+	typename TableDefinition<T>::TableIterator begin() { assert(helper_); return helper_->begin(); }
+	typename TableDefinition<T>::TableIterator end()   { assert(helper_); return helper_->end(); }
+	void adjust(T min, T max)     { assert(helper_); helper_->adjust(min, max); }
+	bool empty()     							{ assert(helper_); return helper_->empty(); }
+	void push_back(T val)     			{ assert(helper_); helper_->push_back(val); }
+
+	
+protected:
+	TableDefinition<T>* helper_;
+
+	virtual void print(ostream& out) const { out << *helper_ ; } 
+	
+
+private:
+	//! Copy constructor - No copy allowed
+	TableDefinitionInterface(const TableDefinitionInterface&);
+	//! Overloaded << operator to copy - No copy allowed
+	TableDefinitionInterface& operator=(const TableDefinitionInterface&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDefinitionInterface& p)
+		{ p.print(s); return s; }
+		
+};
+
+
+
+
+} // namespace magics
+
+#endif
diff --git a/src/common/TableDefinitionCompute.cc b/src/common/TableDefinitionCompute.cc
new file mode 100644
index 0000000..5ca18e5
--- /dev/null
+++ b/src/common/TableDefinitionCompute.cc
@@ -0,0 +1,76 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinitionCompute.cc
+    \brief Implementation of the Template class TableDefinitionCompute.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#include "TableDefinitionCompute.h"
+#include "XmlNode.h"
+
+using namespace magics;
+
+
+template <class T>
+void TableDefinitionCompute<T>::set(const TableDefinitionComputeInterface<T>& attributes)
+{
+    count_ = attributes.getCount();
+}
+
+template <class T>
+inline void fromString(const string& str, T& out) 
+{
+	std::stringstream ss(str);
+	ss >> out;
+}
+
+template <class T>
+void TableDefinitionCompute<T>::set(const XmlNode& node )
+{
+	MagLog::warning() <<  "TableDefinitionCompute::set(const XmlNode&): to be implemented\n";
+	MagLog::dev() << "Node to be interpreted ---> " << node << endl; 
+
+	fromString(node.getAttribute("count"), count_);
+}
+
+template <class T>
+void TableDefinitionCompute<T>::adjust(T min, T max)
+{
+        double step = (max - min)/(count_+1);
+
+        T log = log10(step);
+        T istep = pow(10., int(log));	
+        T inc = ceil(step/istep)*istep;
+        T first = floor(min/inc)*inc;
+  
+       
+        for (T val = first; val <= max + inc; val += inc)
+	{
+            MagLog::dev() << "Add level --->" << val << "\n";
+            push_back(val);                
+        }
+
+        MagLog::dev() << "Numver of levels --->" << count_ << "---->" << this->size() << "\n";
+}
diff --git a/src/common/TableDefinitionCompute.h b/src/common/TableDefinitionCompute.h
new file mode 100644
index 0000000..fbbf6a5
--- /dev/null
+++ b/src/common/TableDefinitionCompute.h
@@ -0,0 +1,77 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinitionCompute.h
+    \brief Definition of the Template class TableDefinitionCompute.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef TableDefinitionCompute_H
+#define TableDefinitionCompute_H
+
+#include "magics.h"
+
+#include "TableDefinition.h"
+#include "TableDefinitionComputeInterface.h"
+
+namespace magics {
+
+template <class T>
+class TableDefinitionCompute: public TableDefinition<T> {
+
+public:
+	TableDefinitionCompute() {}
+	virtual ~TableDefinitionCompute() {}
+	void set(const TableDefinitionComputeInterface<T>&);
+	void set(const XmlNode&);
+	void adjust(T min, T max);
+
+	TableDefinition<T>* clone() const
+	{
+		TableDefinitionCompute<T>* object = new TableDefinitionCompute<T>();
+		// What to do with the values!
+		std::copy(this->begin(), this->end(), object->begin());
+		return object;
+	}
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	 int count_;
+
+private:
+	//! Copy constructor - No copy allowed
+	TableDefinitionCompute(const TableDefinitionCompute&);
+	//! Overloaded << operator to copy - No copy allowed
+	TableDefinitionCompute& operator=(const TableDefinitionCompute&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDefinitionCompute<T>& p)
+		{ p.print(s); return s; }
+};
+
+#include "TableDefinitionCompute.cc"
+
+} // namespace magics
+#endif
diff --git a/src/common/TableDefinitionComputeInterface.h b/src/common/TableDefinitionComputeInterface.h
new file mode 100644
index 0000000..a9967e0
--- /dev/null
+++ b/src/common/TableDefinitionComputeInterface.h
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinitionComputeInterface.h
+    \brief Definition of the Template class TableDefinitionComputeInterface.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef TableDefinitionComputeInterface_H
+#define TableDefinitionComputeInterface_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+template <class T>
+
+class TableDefinitionComputeInterface {
+
+public:
+	TableDefinitionComputeInterface() {}
+	virtual ~TableDefinitionComputeInterface() {}
+	virtual int getCount() const = 0;
+	virtual T getMin() const { return std::numeric_limits<T>::max(); }
+	virtual T getMax() const { return std::numeric_limits<T>::min(); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	TableDefinitionComputeInterface(const TableDefinitionComputeInterface&);
+    //! Overloaded << operator to copy - No copy allowed
+	TableDefinitionComputeInterface& operator=(const TableDefinitionComputeInterface&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDefinitionComputeInterface& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/TableDefinitionList.cc b/src/common/TableDefinitionList.cc
new file mode 100644
index 0000000..e30a5d4
--- /dev/null
+++ b/src/common/TableDefinitionList.cc
@@ -0,0 +1,65 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinitionList.cc
+    \brief Implementation of the Template class TableDefinitionList.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#include "TableDefinitionList.h"
+#include "XmlNode.h"
+
+using namespace magics;
+
+
+template <class T>
+void TableDefinitionList<T>::set(const TableDefinitionListInterface<T>& attributes)
+{
+	const vector<T>& values = attributes.getValues();
+	std::copy(values.begin(), values.end(), this->begin());
+}
+
+template <class T>
+inline void fromString(const string& str, T& out) 
+{
+	std::stringstream ss(str);
+	ss >> out;
+}
+
+template <class T>
+void TableDefinitionList<T>::set(const XmlNode& node )
+{
+	MagLog::info() <<  "TableDefinitionList::set(const XmlNode&): to be implemented\n";
+	MagLog::dev() << "Node to be interpreted ---> " << node << endl; 
+
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		if ( magCompare((*elt)->name(), "value") ) {
+			// convert the value ..
+			double val;
+			fromString((*elt)->data(), val);
+
+			this->push_back(val);
+		}
+	}
+}
diff --git a/src/common/TableDefinitionList.h b/src/common/TableDefinitionList.h
new file mode 100644
index 0000000..7df1896
--- /dev/null
+++ b/src/common/TableDefinitionList.h
@@ -0,0 +1,77 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinitionList.h
+    \brief Definition of the Template class TableDefinitionList.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef TableDefinitionList_H
+#define TableDefinitionList_H
+
+#include "magics.h"
+
+#include "TableDefinition.h"
+#include "TableDefinitionListInterface.h"
+
+
+namespace magics {
+
+template <class T>
+class TableDefinitionList: public TableDefinition<T> {
+
+public:
+	TableDefinitionList() {}
+	virtual ~TableDefinitionList() {}
+	void set(const TableDefinitionListInterface<T>&);
+	void set(const XmlNode&);
+
+	TableDefinition<T>* clone() const {
+		TableDefinitionList<T>* object = new TableDefinitionList();
+		// What to do with the values!
+		std::copy(this->begin(), this->end(), object->begin());
+		return object;
+	}
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+	//! Copy constructor - No copy allowed
+	TableDefinitionList(const TableDefinitionList<T>&);
+	//! Overloaded << operator to copy - No copy allowed
+	TableDefinitionList& operator=(const TableDefinitionList<T>&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDefinitionList<T>& p)
+		{ p.print(s); return s; }
+
+};
+
+
+} // namespace magics
+
+#include "TableDefinitionList.cc"
+#endif
diff --git a/src/common/TableDefinitionListInterface.h b/src/common/TableDefinitionListInterface.h
new file mode 100644
index 0000000..25492c9
--- /dev/null
+++ b/src/common/TableDefinitionListInterface.h
@@ -0,0 +1,65 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDefinitionListInterface.h
+    \brief Definition of the Template class TableDefinitionListInterface.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 4-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef TableDefinitionListInterface_H
+#define TableDefinitionListInterface_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+template <class T>
+class TableDefinitionListInterface {
+
+public:
+	TableDefinitionListInterface() {}
+	virtual ~TableDefinitionListInterface() {}
+	virtual vector<T> getValues() const = 0;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	TableDefinitionListInterface(const TableDefinitionListInterface&);
+    //! Overloaded << operator to copy - No copy allowed
+	TableDefinitionListInterface& operator=(const TableDefinitionListInterface&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDefinitionListInterface<T>& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/Task.cc b/src/common/Task.cc
new file mode 100644
index 0000000..d047dae
--- /dev/null
+++ b/src/common/Task.cc
@@ -0,0 +1,30 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef Task_H
+#include "Task.h"
+#endif
+
+Task::Task()
+{
+}
+
+Task::~Task()
+{
+}
+
diff --git a/src/common/Task.h b/src/common/Task.h
new file mode 100644
index 0000000..aaa446f
--- /dev/null
+++ b/src/common/Task.h
@@ -0,0 +1,57 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Task.h
+// Baudouin Raoult - ECMWF May 96
+
+#ifndef Task_H
+#define Task_H
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+class Task {
+public:
+
+// -- Contructors
+
+	Task();
+
+// -- Destructor
+
+	virtual ~Task();
+
+// -- Methods
+
+	virtual void start()  = 0;
+	virtual void stop()   = 0;
+	virtual void wait()   = 0;
+	virtual bool active() = 0;
+	virtual void kill()   = 0;
+
+private:
+
+// No copy allowed
+
+	Task(const Task&);
+	Task& operator=(const Task&);
+
+};
+
+#endif
diff --git a/src/common/TaylorProjection.cc b/src/common/TaylorProjection.cc
new file mode 100644
index 0000000..e671a3a
--- /dev/null
+++ b/src/common/TaylorProjection.cc
@@ -0,0 +1,216 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TaylorProjection.cc
+    \brief Implementation of TaylorProjection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Thu Jun 12 16:01:47 2008
+
+*/
+
+#include <TaylorProjection.h>
+#include <Polyline.h>
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+  
+  \todo what does still need implmenting? can debug message be removed?
+*/
+TaylorProjection::TaylorProjection() 
+{
+
+}
+
+/*!
+  \brief Destructor
+*/
+TaylorProjection::~TaylorProjection() 
+{
+}
+
+void TaylorProjection::print(ostream& out) const
+{
+    out << "TaylorProjection[";
+    TaylorProjectionAttributes::print(out);
+    out << "]"; 
+} 
+
+void TaylorProjection::init()  
+{
+
+	Transformation::init();
+	PCEnveloppe_->clear();
+	PCEnveloppe_->push_back(PaperPoint(min_, min_));
+	PCEnveloppe_->push_back(PaperPoint(min_, max_));
+
+	for ( float i = 0; i <= (3.14/2); i = i +0.1) {
+
+
+		PCEnveloppe_->push_back(PaperPoint(max_*cos(i), max_*sin(i)));
+
+	}
+
+	PCEnveloppe_->push_back(PaperPoint(max_, min_));
+	PCEnveloppe_->push_back(PaperPoint(min_, min_));
+}
+
+PaperPoint TaylorProjection::operator()(const UserPoint& xy)  const
+{
+	double sinus = (xy.y() < 1)  ? sin(acos(xy.y())) : 0;
+	double cosinus = (xy.y() > 1) ? 1 :   xy.y();
+	
+	return PaperPoint(xy.x()*cosinus, xy.x()*sinus,xy.value());
+}
+
+
+
+PaperPoint TaylorProjection::operator()(const PaperPoint& point)  const
+{
+
+	return Transformation::operator()(point);
+}
+
+
+
+void TaylorProjection::revert(const PaperPoint& xy, UserPoint& point)  const
+{
+	
+	double angle = atan(xy.y()/xy.x());
+	point.y(cos(angle));
+	point.x(xy.x()/cos(angle));	
+	
+}
+
+bool TaylorProjection::needShiftedCoastlines()  const
+{
+	return false;
+}
+
+void TaylorProjection::aspectRatio(double& width, double& height)  
+{
+
+	Transformation::aspectRatio(width, height);
+}
+
+void TaylorProjection::boundingBox(double& xmin, double& ymin, double& xmax, double& ymax)  const
+{
+
+	Transformation::boundingBox(xmin, ymin, xmax, ymax);
+}
+
+double TaylorProjection::getMinX()  const
+{
+	
+	return min_;
+}
+
+double TaylorProjection::getMinY()  const
+{
+	
+	return 0;
+}
+
+double TaylorProjection::getMaxX()  const
+{
+	return max_;
+}
+
+double TaylorProjection::getMaxY()  const
+{
+
+	return 1;;
+}
+
+void TaylorProjection::setMinX(double x)  
+{
+	min_ = x;
+}
+
+void TaylorProjection::setMinY(double y)  
+{
+	min_ = y;
+}
+
+void TaylorProjection::setMaxX(double x)  
+{
+	max_ = x;
+}
+
+void TaylorProjection::setMaxY(double y)  
+{
+	max_ = y;
+}
+
+double TaylorProjection::getMinPCX()  const
+{
+	return min_;
+}
+
+double TaylorProjection::getMinPCY()  const
+{
+	return min_;
+}
+
+double TaylorProjection::getMaxPCX()  const
+{
+	return max_;
+}
+
+double TaylorProjection::getMaxPCY()  const
+{
+	return max_;
+}
+
+Polyline& TaylorProjection::getPCBoundingBox() const
+{
+	if ( PCEnveloppe_->empty() ) {
+		PCEnveloppe_->push_back(PaperPoint(min_, min_));
+		PCEnveloppe_->push_back(PaperPoint(min_, max_));
+		PCEnveloppe_->push_back(PaperPoint(max_, max_));
+		PCEnveloppe_->push_back(PaperPoint(max_, min_));
+		PCEnveloppe_->push_back(PaperPoint(min_, min_));
+	}
+
+	return *PCEnveloppe_;
+
+}
+
+Polyline& TaylorProjection::getUserBoundingBox() const
+{
+	if ( userEnveloppe_->empty() ) {
+		userEnveloppe_->push_back(PaperPoint(min_, min_));
+		userEnveloppe_->push_back(PaperPoint(min_, max_));
+		userEnveloppe_->push_back(PaperPoint(max_, max_));
+		userEnveloppe_->push_back(PaperPoint(max_, min_));
+		userEnveloppe_->push_back(PaperPoint(min_, min_));
+	}
+
+	return *userEnveloppe_;
+}
+
+void TaylorProjection::setDefinition(const string& def)
+{
+	assert(def.empty());
+}
+
+
diff --git a/src/common/TaylorProjection.h b/src/common/TaylorProjection.h
new file mode 100644
index 0000000..59b4cb9
--- /dev/null
+++ b/src/common/TaylorProjection.h
@@ -0,0 +1,181 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file TaylorProjection.h
+    \brief Definition of TaylorProjection.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Thu Jun 12 16:01:47 2008
+*/
+
+#ifndef _TaylorProjection_H
+#define _TaylorProjection_H
+
+#include <Transformation.h>
+#include <TaylorProjectionAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \class TaylorProjection
+    \brief Implements a new projection
+    \ingroup projection
+
+    This projection ...
+*/
+
+class TaylorProjection: public Transformation, public TaylorProjectionAttributes
+{
+
+public:
+	TaylorProjection();
+	~TaylorProjection();
+
+	/*!
+	  \brief sets  from an XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		Transformation::set(node);
+		TaylorProjectionAttributes::set(node);
+	}
+	/*!
+	  \brief sets  from a map
+	*/
+	void set(const map<string, string>& map)
+	{
+		Transformation::set(map);
+		TaylorProjectionAttributes::set(map);
+	}
+    
+	virtual Transformation* clone() const {
+		TaylorProjection* transformation = new TaylorProjection();
+		transformation->copy(*this);
+		return transformation;
+	}
+	
+	/*!
+	\\brief Initialise the projection
+	*/
+	virtual void init() ;
+	/*!
+	\\brief 
+	*/
+	virtual PaperPoint operator()(const UserPoint&) const;
+	/*!
+	\\brief 
+	*/
+
+	virtual PaperPoint operator()(const PaperPoint&) const;
+	/*!
+	\\brief 
+	*/
+	virtual void revert(const PaperPoint&, UserPoint&) const;
+
+
+	/*!
+	\\brief Does the projection needs the coastalines to be shifted!
+	*/
+	virtual bool needShiftedCoastlines() const;
+	/*!
+	\\brief set the aspect ratio!
+	*/
+	virtual void aspectRatio(double&, double&) ;
+	/*!
+	\\brief set the bounding box!
+	*/
+	virtual void boundingBox(double&, double&, double&, double&) const;
+
+	/*!
+	\\brief return the xmin in user coordinates!
+	*/
+	virtual double getMinX() const;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual double getMinY() const;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual double getMaxX() const;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual double getMaxY() const;
+	/*!
+	\\brief set the xmin in user coordinates!
+	*/
+	virtual void setMinX(double) ;
+	/*!
+	\\brief return the ymin in user coordinates!
+	*/
+	virtual void setMinY(double) ;
+	/*!
+	\\brief return the xmax in user coordinates!
+	*/
+	virtual void setMaxX(double) ;
+	/*!
+	\\brief return the ymax in user coordinates!
+	*/
+	virtual void setMaxY(double) ;
+	/*!
+	\\brief return the xmin in projection coordinates!
+	*/
+	virtual double getMinPCX() const;
+	/*!
+	\\brief return the ymin in projection coordinates!
+	*/
+	virtual double getMinPCY() const;
+	/*!
+	\\brief return the xmax in projection coordinates!
+	*/
+	virtual double getMaxPCX() const;
+	/*!
+	\\brief return the ymax in projection coordinates!
+	*/
+	virtual double getMaxPCY() const;
+
+	virtual Polyline& getPCBoundingBox() const;
+	virtual Polyline& getUserBoundingBox() const;
+
+	virtual void setDefinition(const string&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	TaylorProjection(const TaylorProjection&);
+    //! Overloaded << operator to copy - No copy allowed
+	TaylorProjection& operator=(const TaylorProjection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TaylorProjection& p)
+		{ p.print(s); return s; }
+
+};
+    
+
+} // namespace magics
+#endif
diff --git a/src/common/Text.cc b/src/common/Text.cc
new file mode 100644
index 0000000..85da3da
--- /dev/null
+++ b/src/common/Text.cc
@@ -0,0 +1,101 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Text.cc
+    \brief Implementation of Text graphics class (template).
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+
+#include "Text.h"
+#include "TagHandler.h"
+
+
+
+using namespace magics;
+
+Text::Text() :  justification_(MCENTRE), blanking_(false), verticalAlign_(MBASE), angle_(0)
+{
+}
+
+Text::~Text() 
+{
+} 
+
+/*
+class AddHelper
+{
+public:
+	AddHelper(vector<NiceText>& text) : text_(text) {}
+	~AddHelper() {}
+	void operator()(const NiceText& text) 
+		{ text_.push_back(text); }
+protected:
+	vector<NiceText>& text_;
+};
+*/
+
+
+
+double  Text::getFontMax()
+{
+	double max= -1;
+	for (vector<NiceText>::const_iterator nice = nice_.begin(); nice != nice_.end(); ++nice) {
+		if (nice->font().size() > max ) 
+			max = nice->font().size();
+	}
+	if ( max < 0) max = getFont().size();
+//	MagLog::dev() << " Text::getFontMax()-->" << max << endl;
+	return max;
+}
+
+
+void Text::print(ostream& out)  const
+{
+	out << "Text[";
+	for (vector<NiceText>::const_iterator nice = nice_.begin(); nice != nice_.end(); ++nice) {
+	   out << *nice << endl;
+	}
+	for (Text::const_iterator point = this->begin(); point != this->end(); ++point)
+		out << ", " << *point;
+	out << "]";
+}
+
+
+void Text::redisplay(const BaseDriver& driver) const
+{
+	driver.redisplay(*this);
+}
+
+void Text::setText(const string& text) {
+	TagHandler dummy;
+
+	TagConverter converter(dummy);
+
+	converter.font(getFont());
+
+	converter.decode(text, this);
+
+
+
+}
diff --git a/src/common/Text.h b/src/common/Text.h
new file mode 100644
index 0000000..6ecb4e0
--- /dev/null
+++ b/src/common/Text.h
@@ -0,0 +1,200 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Text.h
+    \brief Definition of Text graphics class.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#ifndef Text_H
+#define Text_H
+
+#include "magics.h"
+
+#include "Label.h"
+#include "BaseDriver.h"
+#include "BasicGraphicsObject.h"
+
+namespace magics {
+	
+enum TextElevation { NORMAL, SUPERSCRIPT ,SUBSCRIPT };
+
+class NiceText
+{
+public:
+	NiceText(): elevation_(NORMAL) {}
+	~NiceText() {}
+
+	void font(const MagFont& font) { font_ = font; }
+	const MagFont& font() const { return font_; }
+
+	void elevation(const TextElevation& elevation) { elevation_ = elevation; }
+	TextElevation elevation() const { return elevation_; }
+
+	void text(const string& text) { text_ = text; }
+	const string& text() const { return text_; }
+
+protected:
+	void print(ostream& out) const 
+	{
+		out << "[" << text_ << " (" << font_ << ", " << elevation_ << "]" << endl;
+	}
+	
+	MagFont       font_;
+	TextElevation elevation_;
+	string        text_;
+
+	// -- Friends
+	friend ostream& operator<<(ostream& s,const NiceText& p)
+		{ p.print(s); return s; }
+};
+
+
+class Text: public BasicGraphicsObject, public vector<PaperPoint> {
+
+public:
+	Text();
+	
+   	Text* clone() const 
+	{    	
+    		Text* text = new Text; 
+		
+               
+		for(vector<PaperPoint>::const_iterator it=this->begin(); it != this->end(); it++)
+		{ 
+			text->push_back(*it);
+		}	
+
+		for(vector<NiceText>::const_iterator it=textBegin(); it != textEnd(); it++)
+		{
+			text->addNiceText(*it);
+		}
+
+		text->setJustification(justification_);
+		text->setBlanking(blanking_);
+		text->setAngle(angle_); 
+		text->setVerticalAlign(verticalAlign_); 
+		
+
+		return text;
+    	}
+		
+	virtual ~Text();
+	
+	void addText(const string& text, const Colour& colour, double height) {
+		nice_.push_back(NiceText());
+		nice_.back().text(text);
+		MagFont font;
+		font.colour(colour); 
+		font.size(height); 
+		nice_.back().font(font);
+	}
+	void setText(const string& text);
+	void addText(double val, const Colour& colour, double height) {
+		addText(tostring(val), colour, height);
+	}
+	
+	void addText(const string& text, const MagFont& f) {
+		nice_.push_back(NiceText());
+		nice_.back().text(text);
+		nice_.back().font(f);
+		font_ = f;
+	}
+	void setFont(const MagFont& f) {
+		    if (nice_.empty() == false)
+				nice_.back().font(f);
+		    font_ = f;
+	}
+	const MagFont& getFont() {
+		    return nice_.empty() ? font_ : nice_.back().font();
+		}
+	double getMaxFontSize();
+	vector<NiceText>::const_iterator textBegin() const {return nice_.begin();}
+	vector<NiceText>::const_iterator textEnd() const {return nice_.end();}
+
+	void addNiceText(const NiceText& text) const {nice_.push_back(text);}
+	const vector<NiceText>& getNiceText() const {return nice_;}
+	double getFontMax(); 
+	
+	bool noText() { return nice_.empty(); } 
+	void clear() {  nice_.clear(); }
+
+
+	void redisplay(const BaseDriver& driver) const;
+	
+	
+	void setJustification(Justification justification) {justification_ = justification; }
+	Justification getJustification() const { return justification_; }
+	
+	void setBlanking(bool blanking) {blanking_ = blanking; }
+	bool getBlanking() const { return blanking_; }
+
+	VerticalAlign getVerticalAlign() const { return verticalAlign_; }
+		void setVerticalAlign(const VerticalAlign va) { verticalAlign_ = va; }
+
+		/*!
+		  \brief Method setting the angle in which the text is written.
+		  
+		  The angle gives the gradient in which the text is written. Angles are given 
+		  in degree and an angle of 0 degree is horizontal. Angles are going 
+		  anticlockwise.
+		  
+		  \sa setAngle
+		*/
+		double getAngle() const {return angle_;}
+		/*!
+		  \brief Method getting the angle in which the text is written.
+		  
+		  The angle gives the gradient in which the text is written. Angles are given 
+		  in degree and an angle of 0 degree is horizontal. Angles are going 
+		  anticlockwise.
+		  
+		  \sa getAngle
+		*/
+		void setAngle(double angle) {angle_ = angle;}
+protected:
+	virtual void print(ostream&) const; 
+	
+	Justification justification_;
+	bool           blanking_;
+	VerticalAlign verticalAlign_;
+	double        angle_;
+	MagFont font_;
+
+	
+	
+	
+private:
+// No copy allowed
+	Text(const Text&);
+	Text& operator=(const Text&);
+	mutable vector<NiceText> nice_; 
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const Text& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/Thread.cc b/src/common/Thread.cc
new file mode 100644
index 0000000..1e4eb6a
--- /dev/null
+++ b/src/common/Thread.cc
@@ -0,0 +1,51 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+#ifndef AutoLock_H
+#include "AutoLock.h"
+#endif
+
+#ifndef Thread_H
+#include "Thread.h"
+#endif
+
+Thread::Thread(bool autodel):
+	stop_(false),
+	autodel_(autodel)
+{
+}
+
+Thread::~Thread()
+{
+}
+
+void Thread::stop()
+{
+	AutoLock<Mutex> lock(mutex_);
+	stop_ = true;	
+}
+
+bool Thread::stopped()
+{
+	AutoLock<Mutex> lock(mutex_);
+	return stop_;	
+}
diff --git a/src/common/Thread.h b/src/common/Thread.h
new file mode 100644
index 0000000..c3978c7
--- /dev/null
+++ b/src/common/Thread.h
@@ -0,0 +1,78 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Thread.h
+// Baudouin Raoult - ECMWF Jun 96
+
+#ifndef Thread_H
+#define Thread_H
+
+#ifndef Mutex_H
+#include "Mutex.h"
+#endif
+
+// This should be a Task
+
+class Thread {
+public:
+	friend class ThreadControler;
+
+// -- Contructors
+	
+	Thread(bool autodel = true); // 
+
+// -- Destructor
+
+	virtual ~Thread();
+
+// -- Methods
+
+	void stop();
+
+protected:
+
+// -- Members
+
+	Mutex mutex_;
+
+// -- Methods
+
+	bool  stopped();
+
+private:
+
+// No copy allowed
+
+	Thread(const Thread&);
+	Thread& operator=(const Thread&);
+
+// -- Members
+
+	bool    stop_;
+	bool    autodel_;
+#ifdef linux
+	void*   data_;
+#endif
+
+// -- Methods
+	
+	virtual void run() = 0;
+
+};
+
+#endif
diff --git a/src/common/ThreadControler.cc b/src/common/ThreadControler.cc
new file mode 100644
index 0000000..be7a2cc
--- /dev/null
+++ b/src/common/ThreadControler.cc
@@ -0,0 +1,231 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+#include <signal.h>
+#include <assert.h>
+
+#ifndef linux
+#include <sys/sched.h>
+#endif
+
+#ifndef AutoLock_H
+#include "AutoLock.h"
+#endif
+
+#ifndef MagLog_H
+#include "MagLog.h"
+#endif
+
+#ifndef MagExceptions_H
+#include "MagExceptions.h"
+#endif
+
+#ifndef ThreadControler_H
+#include "ThreadControler.h"
+#endif
+
+#ifndef Thread_H
+#include "Thread.h"
+#endif
+
+
+
+ThreadControler::ThreadControler(Thread* proc,bool detached):
+	detached_(detached),
+	thread_(0),
+	proc_(proc),
+	running_(false)
+{
+}
+
+ThreadControler::~ThreadControler()
+{
+	AutoLock<MutexCond> lock(cond_);
+
+	if(running_)
+	{
+		// The Thread will delete itself
+		// so there is no need for:
+		// delete proc_;
+	}
+	else
+	{
+		delete proc_;
+	}
+}
+
+//------------------------------------------------------
+
+void ThreadControler::execute()
+{
+	static const char *here = __FUNCTION__;
+
+	//=================
+	// Make sure the logs are created...
+
+
+	//============
+
+	Thread *proc = proc_;
+
+	{ // Signal that we are running
+
+		AutoLock<MutexCond> lock(cond_);
+		running_ = true;
+		cond_.signal();
+
+	}
+
+	//=============
+
+	// We don't want to recieve reconfigure events
+
+	sigset_t set,old_set;
+
+	sigemptyset(&set);
+
+	sigaddset(&set, SIGHUP);
+	sigaddset(&set, SIGCHLD);
+	sigaddset(&set, SIGPIPE);
+
+#ifdef IBM
+	SYSCALL(sigthreadmask(SIG_BLOCK, &set, &old_set));
+#else
+	SYSCALL(pthread_sigmask(SIG_BLOCK, &set, &old_set));
+#endif
+
+	//=============
+
+	try {
+		proc->run();
+	}
+	catch(MagException& e){
+		magics::MagLog::error() << "** " << e.what() << " Caught in " 
+			<< here <<  endl;
+		magics::MagLog::error() << "** MagException is termiates thread " 
+			<< pthread_self() << endl;
+	}
+	catch(...)
+	{
+		magics::MagLog::error() << "** UNKNOWN MagException Caught in " 
+			<< here <<  endl;
+		magics::MagLog::error() << "** MagException is termiates thread " 
+			<< pthread_self() << endl;
+	}
+
+#ifdef linux
+	//if(proc->data_)
+	//	MemoryPool::largeDeallocate(proc->data_);
+#endif
+
+	if(proc->autodel_)
+		delete proc;
+
+
+}
+
+void *ThreadControler::startThread(void *data)
+{
+	((ThreadControler*)data)->execute(); // static_cast or dynamic_cast ??
+	return 0;
+}
+
+void ThreadControler::start()
+{
+	assert(thread_ == 0);
+
+	pthread_attr_t attr;
+	pthread_attr_init(&attr);
+
+
+#ifdef linux
+
+	proc_->data_ = 0;
+
+#if 0
+	const size_t size = 2*1024*1024;
+	void *stack = MemoryPool::largeAllocate(size);
+
+	pthread_attr_setstacksize(&attr,size);
+	pthread_attr_setstackaddr(&attr,(char*)stack + size);
+
+	proc_->data_ = stack;
+#endif
+
+#endif
+
+
+	if(detached_)
+		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	else
+		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+	AutoLock<MutexCond> lock(cond_);
+
+#ifdef DCE_THREADS
+	THRCALL(pthread_create(&thread_,attr,startThread,this));
+#else
+	THRCALL(pthread_create(&thread_,&attr,startThread,this));
+#endif
+
+	pthread_attr_destroy(&attr);
+
+	while(!running_)
+		cond_.wait();
+}
+
+void ThreadControler::kill()
+{
+	pthread_cancel(thread_);
+	//pthread_kill(thread_,sig);
+}
+
+void ThreadControler::stop()
+{
+	proc_->stop();
+}
+
+void ThreadControler::wait()
+{
+	ASSERT(!detached_);
+	// if(running_) 
+	THRCALL(pthread_join(thread_,0));
+}
+
+bool ThreadControler::active()
+{
+	if(thread_ != 0)
+	{
+		// Try see if it exists
+
+		int policy; 
+		sched_param param;
+
+		int n = pthread_getschedparam(thread_, &policy, &param); 
+
+		// The thread does not exist
+		if(n != 0)
+			thread_ = 0;
+
+	}
+	return thread_ != 0;
+}
diff --git a/src/common/ThreadControler.h b/src/common/ThreadControler.h
new file mode 100644
index 0000000..44a90c2
--- /dev/null
+++ b/src/common/ThreadControler.h
@@ -0,0 +1,93 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File ThreadControler.h
+// Baudouin Raoult - ECMWF May 96
+
+#ifndef ThreadControler_H
+#define ThreadControler_H
+
+#include <pthread.h>
+
+#ifndef Task_H
+#include "Task.h"
+#endif
+
+#ifndef MutexCond_H
+#include "MutexCond.h"
+#endif
+
+// Don't subclass from ThreadControler put from Thread
+
+class Thread;
+
+class ThreadControler : public Task {
+public:
+
+// -- Contructors
+	
+	// ThreadControler takes ownership of Thread
+
+	ThreadControler(Thread*,bool detached = true);
+
+// -- Destructor
+	
+	~ThreadControler();
+
+// -- Overridden methods
+
+	// From Task
+
+	virtual void start();
+	virtual void stop();
+	virtual void kill();
+	virtual void wait();
+	virtual bool active();
+
+protected:
+
+// -- Members
+	
+	MutexCond  cond_;
+	bool       detached_;
+
+private:
+
+// No copy allowed
+
+	ThreadControler(const ThreadControler&);
+	ThreadControler& operator=(const ThreadControler&);
+
+// -- Members
+	
+	pthread_t      thread_;
+	Thread     *proc_;
+	bool           running_;
+
+// -- Methods
+	
+	void execute();
+
+// -- Class methods
+
+	static void *startThread(void *);
+
+};
+
+
+#endif
diff --git a/src/common/ThreadSingleton.cc b/src/common/ThreadSingleton.cc
new file mode 100755
index 0000000..2eec3cf
--- /dev/null
+++ b/src/common/ThreadSingleton.cc
@@ -0,0 +1,72 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+#ifndef MagExceptions_H
+#include "MagExceptions.h"
+#endif
+
+#ifndef ThreadSingleton_H
+#include "ThreadSingleton.h"
+#endif
+
+template<class T> pthread_once_t ThreadSingleton<T>::once_ = PTHREAD_ONCE_INIT;
+template<class T> pthread_key_t ThreadSingleton<T>::key_;
+
+template<class T> ThreadSingleton<T>::ThreadSingleton()
+{
+}
+
+template<class T> ThreadSingleton<T>::~ThreadSingleton()
+{
+}
+
+template<class T> 
+T& ThreadSingleton<T>::instance()
+{
+	pthread_once(&once_,init);
+
+	T* value = 0;
+
+#ifdef DCE_THREADS
+	THRCALL(pthread_getspecific(key_,(void**)&value));
+#else
+	value = (T*)pthread_getspecific(key_);
+#endif
+	if(!value)
+	{
+
+		value = new T();
+		THRCALL(pthread_setspecific(key_,value));
+	}
+	return *value;
+}
+
+template<class T> void ThreadSingleton<T>::cleanUp(void* data)
+{
+	delete (T*)data;
+	pthread_setspecific(key_,0);
+}
+
+template<class T> void ThreadSingleton<T>::init()
+{
+	pthread_key_create(&key_,cleanUp);
+}
diff --git a/src/common/ThreadSingleton.h b/src/common/ThreadSingleton.h
new file mode 100755
index 0000000..58d0cae
--- /dev/null
+++ b/src/common/ThreadSingleton.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File ThreadSingleton.h
+// Baudouin Raoult - ECMWF Jun 96
+
+#ifndef ThreadSingleton_H
+#define ThreadSingleton_H
+
+#ifndef marsmachine_H
+#include "marsmachine.h"
+#endif
+
+template<class T> class ThreadSingleton {
+public:
+
+// -- Contructors
+
+	ThreadSingleton();
+
+// -- Destructor
+
+	~ThreadSingleton();
+
+// -- Class methods
+
+	static T& instance();
+
+private:
+
+// No copy allowed
+
+	ThreadSingleton(const ThreadSingleton<T>&);
+	ThreadSingleton<T>& operator=(const ThreadSingleton<T>&);
+
+// -- Class members
+
+	static pthread_once_t once_;
+	static pthread_key_t  key_;
+
+// -- Class methods
+
+	static void init(void);
+	static void cleanUp(void*);
+
+};
+
+
+#include "ThreadSingleton.cc"
+
+#endif
diff --git a/src/common/Timer.cc b/src/common/Timer.cc
new file mode 100644
index 0000000..531bed2
--- /dev/null
+++ b/src/common/Timer.cc
@@ -0,0 +1,108 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef marsmachine_H
+#include "magics.h"
+#endif
+
+#ifndef Timer_H
+#include "Timer.h"
+#endif
+
+#ifndef Seconds_H
+#include "Seconds.h"
+#endif
+
+#include "Mutex.h"
+#include "AutoLock.h"
+#include "MagLog.h"
+
+namespace magics {
+
+timeval operator-(const timeval& a,const timeval& b)
+{
+	timeval diff;
+
+	diff.tv_sec  = a.tv_sec  - b.tv_sec;
+	diff.tv_usec = a.tv_usec - b.tv_usec;
+
+	if (diff.tv_usec < 0)
+	{
+		diff.tv_sec--;
+		diff.tv_usec += 1000000;
+	}
+	return diff;
+}
+
+}
+using namespace magics;
+
+Timer::Timer(const string& name, const string& detail):
+	name_(name),
+	details_(detail), 
+	cpu_(clock())
+{
+	gettimeofday(&start_,0);
+}
+static Mutex lockprofiles_;
+Timer::~Timer()
+{
+	const double  s   = elapsed();
+	clock_t cpu =  clock();
+	const Seconds	sec1(s);
+	const Seconds	sec2(double(cpu-cpu_)/CLOCKS_PER_SEC);
+	MagLog::profile() << name_ << ": " 
+		<< sec1 << " elapsed, " 
+		<< sec2 << " cpu" << "\n";
+	ostringstream e;
+			e << elapsed();
+			
+			ostringstream c;
+			c << double(cpu-cpu_)/CLOCKS_PER_SEC;
+			
+
+	{
+		AutoLock<Mutex> lock(lockprofiles_);
+	
+		profiles_.push_back(ProfileInfo(name_, details_, e.str(), c.str()));
+	}
+}
+
+double Timer::elapsed()
+{
+	timeval stop;
+	gettimeofday(&stop,0);  
+	timeval diff = stop - start_;
+	return (double)diff.tv_sec + ((double)diff.tv_usec / 1000000.);
+}
+
+ProfileInfo::ProfileInfo(const string& name, const string& details, const string& elapsed, const string& cpu) :
+	name_(name), details_(details), elapsed_(elapsed), cpu_(cpu)  {
+		
+	}
+
+ostream& operator<<(ostream& s,const ProfileInfo& p)
+			{ s << "\t\"" << p.name_ << "\" : {" << endl;
+			   s << "\t\t\"details\" : \"" << p.details_ << "\"," << endl;
+			   s << "\t\t\"elapsed\" : " << p.elapsed_ << "," << endl;
+			   s << "\t\t\"cpu\" : " << p.cpu_ << endl;
+			   s << "\t}";
+			   return s;
+			   }
+	
+vector<ProfileInfo> Timer::profiles_;
diff --git a/src/common/Timer.h b/src/common/Timer.h
new file mode 100644
index 0000000..ee80c6c
--- /dev/null
+++ b/src/common/Timer.h
@@ -0,0 +1,105 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Timer.h
+// Baudouin Raoult - ECMWF May 96
+
+#ifndef Timer_H
+#define Timer_H
+
+#ifndef magics_H
+#include "magics.h"
+#endif
+
+//#ifndef MagLog_H
+//#include "MagLog.h"
+//#endif
+
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+
+
+
+class ProfileInfo 
+{
+public:
+	ProfileInfo(const string& name, const string& details, const string& elapsed, const string& cpu);
+	string name_;
+	string details_;
+	string elapsed_;
+	string cpu_;
+	
+	// -- Friends
+	    //! Overloaded << operator to call print().
+		friend ostream& operator<<(ostream& s,const ProfileInfo& p);
+	
+};
+
+// This stack object prints the elapse time between the call to
+// its contructor and the call to its destructor
+namespace magics {
+class Timer {
+public:
+
+// -- Contructors
+
+	Timer(const string& name, const string& details);
+
+// -- Destructor
+
+	~Timer();
+
+// -- Methods
+
+	double elapsed();
+	static vector<ProfileInfo>::const_iterator begin() 
+			{ return profiles_.begin(); }
+		static vector<ProfileInfo>::const_iterator end() 
+			{ return profiles_.end(); }
+
+private:
+
+// No copy allowed
+
+	Timer(const Timer&);
+	Timer& operator=(const Timer&);
+
+// -- Members
+	
+	string         name_;
+	string 		  details_;
+	struct timeval start_;
+	clock_t        cpu_;
+	static vector<ProfileInfo> profiles_;
+	
+	
+	
+
+// -- Methods
+	
+	ostream& put(ostream&,double);
+
+};
+
+timeval operator-(const timeval&,const timeval&);
+
+} // namespace magics
+
+#endif
diff --git a/src/common/Tokenizer.cc b/src/common/Tokenizer.cc
new file mode 100644
index 0000000..809628b
--- /dev/null
+++ b/src/common/Tokenizer.cc
@@ -0,0 +1,70 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef   Tokenizer_H
+#include "Tokenizer.h"
+#endif
+
+#include <fstream>
+
+Tokenizer::Tokenizer(const string& separators)
+{
+	for(unsigned int i=0; i<separators.length(); i++)
+		separator_.insert(separators[i]);
+}
+
+Tokenizer::~Tokenizer()
+{
+}
+
+
+void Tokenizer::operator()(const string& raw, vector<string>& v)
+{
+	int    index  = 0;
+	int    length = raw.length();
+	string token  = "";
+
+	while(index < length)
+	{
+		char c = raw[index];
+		if(find(separator_.begin(),separator_.end(),c) != separator_.end())
+		{
+			if(token.length()>0)
+				v.push_back(token);
+			token ="";
+		}
+		else
+			token += c;
+
+		index++;
+	}
+
+	if(token.length()>0)
+		v.push_back(token);
+}
+
+void Tokenizer::operator()(std::istream& in, vector<string>& v)
+{
+	string raw;
+	char c;
+
+	while(in.get(c) && c != EOF && c != '\n')
+		raw += c;
+
+	operator()(raw,v);
+}
diff --git a/src/common/Tokenizer.h b/src/common/Tokenizer.h
new file mode 100644
index 0000000..7bd255b
--- /dev/null
+++ b/src/common/Tokenizer.h
@@ -0,0 +1,70 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Tokenizer.h
+// Manuel Fuentes - ECMWF Jan 97
+
+#ifndef Tokenizer_H
+#define Tokenizer_H
+
+// Headers
+
+#include "magics.h"
+
+
+// 
+
+class Tokenizer {
+public:
+
+// -- Contructors
+
+    Tokenizer(const string&);
+
+// -- Destructor
+
+	~Tokenizer(); // Change to virtual if base class
+
+// -- Methods
+	
+	void operator()(const string&, vector<string>&);
+	void operator()(std::istream&,vector<string>&);
+
+private:
+
+// No copy allowed
+
+	Tokenizer(const Tokenizer&);
+	Tokenizer& operator=(const Tokenizer&);
+
+// -- Members
+
+	set<char,std::less<char> > separator_;     // To make searching faster
+
+// -- Methods
+
+	void print(ostream&) const;
+
+	friend ostream& operator<<(ostream& s,const Tokenizer& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+#endif
diff --git a/src/common/Transformation.cc b/src/common/Transformation.cc
new file mode 100644
index 0000000..38ce2d0
--- /dev/null
+++ b/src/common/Transformation.cc
@@ -0,0 +1,483 @@
+/******************************** LICENSE ********************************
+
+  Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF) 
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// File Transformation.cc
+// Magics Team - ECMWF 2004
+
+#include "BasicGraphicsObject.h"
+#include "Transformation.h"
+#include "Layout.h"
+#include <iomanip>
+#include "MatrixHandler.h"
+#include "PointsHandler.h"
+#include "MetaData.h"
+#define BOOST_GEOMETRY_OVERLAY_NO_THROW
+#include "Polyline.h"
+
+
+
+using namespace magics;
+
+
+Transformation::Transformation() : 
+	coordinateType_(GeoType),
+	dataMinX_(std::numeric_limits<double>::max()),
+	dataMaxX_(-std::numeric_limits<double>::max()),
+	dataMinY_(std::numeric_limits<double>::max()),
+	dataMaxY_(-std::numeric_limits<double>::min()),
+	topAxis_(true)
+{
+	userEnveloppe_ = new Polyline();
+	PCEnveloppe_ = new Polyline();
+}
+
+Transformation::~Transformation() 
+{
+	delete userEnveloppe_;
+	delete PCEnveloppe_;
+}
+
+void Transformation::print(ostream& out)  const
+{
+	out << "Transformation";
+}
+
+void Transformation::forceNewArea(double xpcmin, double ypmin, double xpcmax, double ypcmax, double& width, double& height)
+{
+	
+}
+void Transformation::fill(double& width, double& height)
+{
+	init();
+	// with and height will only 
+	double w = getAbsoluteMaxPCX() - getAbsoluteMinPCX();
+	double h = getAbsoluteMaxPCY() - getAbsoluteMinPCY();
+	
+	double minx =  getAbsoluteMinPCX();
+	double maxx =  getAbsoluteMaxPCX();
+	
+	double miny =  getAbsoluteMinPCY();
+	double maxy =  getAbsoluteMaxPCY();
+	
+	
+		
+	
+	
+		  	double nw = (width/height) *h;		
+		  	if ( nw > w) {
+		  	// we need to extend in the x direction
+		  		double more = (nw-w)/2;
+		  		maxx = maxx + more;
+		  		minx = minx - more;			
+		  	}
+			else { 
+				double nh = (height/width)*w;				
+				double more = (nh-h)/2;							
+				maxy = maxy + more;
+				miny = miny - more;				
+			}
+		
+		
+	
+		setNewPCBox(minx, miny, maxx, maxy); 
+		
+	
+}
+
+void Transformation::aspectRatio(double& width, double& height)
+{
+	init();
+	double w = getAbsoluteMaxPCX() - getAbsoluteMinPCX();
+	double h = getAbsoluteMaxPCY() - getAbsoluteMinPCY();
+	if ( w/h >= width/height) {
+		double nh = (h/w) * width;
+		if ( nh <= height) {
+			height = nh;
+		}
+		else {
+			width = (w/h) * height;			
+		}
+	}
+	else 
+		width = (w/h) * height;
+}
+
+
+
+
+void Transformation::thin(MatrixHandler& matrix, double x, double y, vector<UserPoint>& out) const
+{
+	int xfactor = (int) ceil((float) x);
+	int yfactor = (int) ceil((float) y);
+	
+	if(xfactor < 1)
+	{
+	  	xfactor=1;
+		MagLog::warning() << "Ivalid x-thinning factor: " << x << "! Reverted back to 1" << endl;
+	}
+	if(yfactor < 1)
+	{
+	  	yfactor=1;
+		MagLog::warning() << "Ivalid y-thinning factor: " << y << "! Reverted back to 1" << endl;
+	}	
+	
+	ThinningMatrixHandler thin_matrix(matrix, xfactor , yfactor);
+	
+
+
+	int columns =thin_matrix.columns();
+	int rows = thin_matrix.rows();
+
+	
+		for ( int lat = 0; lat < rows; lat++)		
+			for ( int lon = 0; lon < columns; lon++) 
+				out.push_back(UserPoint(thin_matrix.column(lat, lon), thin_matrix.row(lat, lon), thin_matrix(lat, lon)));
+	columns = matrix.columns();
+	rows = matrix.rows();
+
+
+
+}
+
+
+
+
+ViewFilter::ViewFilter(double xmin, double xmax, double ymin, double ymax, double xres, double yres) : 
+	xmin_(xmin), xmax_(xmax), ymin_(ymin), ymax_(ymax), 
+	xres_(xres), yres_(yres) 
+{
+	xdim_ = (int) (xmax_-xmin_)/xres_;
+	ydim_ = (int) (ymax_-ymin_)/yres_;
+
+	for (int y = 0; y < ydim_; y++)
+		for ( int x = 0; x < xdim_; x++)
+			done.push_back(false);
+
+}
+
+
+bool ViewFilter::in(const PaperPoint& xy){
+	if ( xy.x() < xmin_ ) return false;
+	if ( xy.x() > xmax_ ) return false;
+	if ( xy.y() < ymin_ ) return false;
+	if ( xy.y() < ymin_ ) return false;
+	return true;
+}
+
+
+void Transformation::init()
+{
+	if ( PCEnveloppe_->empty()) {
+			PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMinPCY()));
+			PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMaxPCY()));
+			PCEnveloppe_->push_back(PaperPoint(getMaxPCX(), getMaxPCY()));
+			PCEnveloppe_->push_back(PaperPoint(getMaxPCX(), getMinPCY()));
+			PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMinPCY()));
+		}
+}
+
+
+void Transformation::setDataMinX(double minx, const string& ref) const
+{ 
+	// WE will have to take into acount the date!
+	dataMinX_ = std::min(minx, dataMinX_); 
+	dataReferenceX_ = ref;
+}
+
+void Transformation::setDataMaxX(double maxx, const string& ref) const 
+{ 
+	dataMaxX_ = std::max(maxx, dataMaxX_); 
+	dataReferenceX_ = ref;
+}
+
+void Transformation::setDataMinY(double miny, const string& ref) const
+{ 
+	dataMinY_ = std::min(miny, dataMinY_);
+	dataReferenceY_ = ref; 
+}
+
+void Transformation::setDataMaxY(double maxy, const string& ref) const 
+{ 
+	dataMaxY_ = std::max(maxy, dataMaxY_); 
+	dataReferenceY_ = ref; 
+}
+
+
+void Transformation::visit(MetaDataVisitor& visitor, 
+	double left, double top, double width, double height,  double imgwidth, double imgheight)
+{
+	ostringstream java;
+	double w = getMaxPCX() - getMinPCX();
+	double h = getMaxPCY() - getMinPCY();
+	java << "{";
+	java << "\"name\" : \"cylindrical\",";		
+
+	java << "\"top\" : \"" << top <<  "\",";		
+	java << "\"left\" : \"" << left <<  "\",";		
+
+	java << "\"img_width\" : \"" << imgwidth <<  "\",";	
+	java << "\"img_height\" : \"" << imgheight <<  "\",";	
+	java << "\"width\" : \"" << width <<  "\",";	
+	java << "\"height\" : \"" << height <<  "\",";	
+
+	java << "\"pcxmin\" : \"" << getMinPCX() <<  "\",";		
+	java << "\"pcymin\" : \"" << getMinPCY() <<  "\",";		
+	java << "\"pcwidth\" : \"" << w <<  "\",";	
+	java << "\"pcheight\" : \"" << h <<  "\"";	
+
+	java << "}";	
+	visitor.add("projection", java.str());
+	ostringstream wf;
+	wf << (w/width)<< endl;
+	wf << "0\n0\n";
+	wf << -(h/height) << endl;
+	wf << getMaxPCY() - (h/height)/2<< endl;
+	wf <<  getMinPCX() +  (w/width)/ 2<< endl;
+	visitor.add("world_file", wf.str());
+}
+
+
+#include <boost/geometry/geometries/box.hpp>
+
+
+
+void Transformation::operator()(const Polyline& from, BasicGraphicsObjectContainer& out) const
+{	
+	if (from.empty())
+		return;
+	PaperPoint ll(getMinPCX(), getMinPCY());
+	PaperPoint ur(getMaxPCX(), getMaxPCY());
+	boost::geometry::model::box<PaperPoint> box(ll, ur);
+	boost::geometry::correct(box);
+	if ( from.closed() ) {
+		deque<PaperPoint> line;
+
+		for (unsigned i = 0; i < from.size(); i++) {
+			line.push_back(from.get(i));
+
+		}
+
+		boost::geometry::correct(line);
+		vector<deque<PaperPoint> > result;
+		boost::geometry::intersection(box, line, result);
+
+		// Now we feed the graphic container!
+
+		for (vector<deque<PaperPoint> >::iterator l = result.begin(); l != result.end(); l++)
+		{
+			Polyline* poly = from.getNew();
+
+			for (deque<PaperPoint>::iterator point = l->begin(); point != l->end(); ++point)
+				poly->push_back(*point);
+
+			if ( !poly->empty() )
+				out.push_back(poly);
+		}
+	}
+	else {
+		vector<PaperPoint> line;
+
+		for (unsigned i = 0; i < from.size(); i++) {
+			line.push_back(from.get(i));
+		}
+		boost::geometry::correct(line);
+		vector<vector<PaperPoint> > result;
+		boost::geometry::intersection(box, line, result);
+
+		// Now we feed the graphic container!
+
+		for (vector<vector<PaperPoint> >::iterator l = result.begin(); l != result.end(); l++)
+		{
+			Polyline* poly = from.getNew();
+
+			for (vector<PaperPoint>::iterator point = l->begin(); point != l->end(); ++point)
+				poly->push_back(*point);
+
+			if ( !poly->empty() )
+				out.push_back(poly);
+		}
+	}
+}
+
+
+
+void Transformation::boundingBox(double& minx, double& miny, double&maxx, double& maxy) const
+{
+	// Return exactly the box ... Perhaps could return a bit more to avoid side effect.
+	minx= getMinX();
+	miny= getMinY();
+	maxx= getMaxX();
+	maxy= getMaxY();
+
+	PCEnveloppe_->push_back(PaperPoint(minx, miny));
+	PCEnveloppe_->push_back(PaperPoint(minx, maxy));
+	PCEnveloppe_->push_back(PaperPoint(maxx, maxy));
+	PCEnveloppe_->push_back(PaperPoint(minx, maxy));
+	PCEnveloppe_->push_back(PaperPoint(minx, miny));
+
+	userEnveloppe_->push_back(PaperPoint(minx, miny));
+	userEnveloppe_->push_back(PaperPoint(minx, maxy));
+	userEnveloppe_->push_back(PaperPoint(maxx, maxy));
+	userEnveloppe_->push_back(PaperPoint(minx, maxy));
+	userEnveloppe_->push_back(PaperPoint(minx, miny));
+
+}
+
+
+
+bool Transformation::in(const UserPoint& point) const
+{
+
+	PaperPoint pp = (*this)(point);
+	return in(pp);
+}
+
+
+
+bool Transformation::in(const PaperPoint& point) const
+{
+	if ( PCEnveloppe_->empty()) {
+		PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMinPCY()));
+		PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMaxPCY()));
+		PCEnveloppe_->push_back(PaperPoint(getMaxPCX(), getMaxPCY()));
+		PCEnveloppe_->push_back(PaperPoint(getMaxPCX(), getMinPCY()));
+		PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMinPCY()));
+	}
+
+	return boost::geometry::covered_by(point, PCEnveloppe_->polygon_);
+}
+
+
+bool Transformation::in(double x, double y) const
+{
+	if ( PCEnveloppe_->empty()) {
+				PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMinPCY()));
+				PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMaxPCY()));
+				PCEnveloppe_->push_back(PaperPoint(getMaxPCX(), getMaxPCY()));
+				PCEnveloppe_->push_back(PaperPoint(getMaxPCX(), getMinPCY()));
+				PCEnveloppe_->push_back(PaperPoint(getMinPCX(), getMinPCY()));
+			}
+	PaperPoint point = (*this)(UserPoint(x,y));
+	return boost::geometry::covered_by(point, PCEnveloppe_->polygon_);
+}
+
+void Transformation::thin(PointsHandler& points, vector<PaperPoint>& thin,  vector<PaperPoint>& all) const
+{	
+
+	BoxPointsHandler box(points, *this,  true);
+	box.setToFirst();
+	while (box.more()) {               		
+		PaperPoint xy = (*this)(box.current());
+		if ( view_.in(xy) ) {
+			thin.push_back(xy);
+		}
+		all.push_back(xy);
+
+		box.advance();		
+	}  
+
+}
+
+
+void Transformation::thin(MatrixHandler& points, vector<PaperPoint>& thin,  vector<PaperPoint>& all) const
+{	
+
+	BoxMatrixHandler box(points, *this);
+	int row = std::max(int(view_.yres_/abs(box.YResolution())), 1);
+	int column = std::max(int(view_.xres_/abs(box.XResolution())), 1);
+	ThinningMatrixHandler sample(box, row, column);
+
+	box.setToFirst();
+	while (box.more()) {               		
+		PaperPoint xy = (*this)(box.current());	                   
+		if ( view_.in(xy) ) 
+			all.push_back(xy);	           
+		box.advance();		
+	}  
+	sample.setToFirst();
+	while (sample.more()) {               		
+		PaperPoint xy = (*this)(sample.current());	           
+		if ( view_.in(xy) ) 
+			thin.push_back(xy);	           
+
+		sample.advance();		
+	}  
+
+
+
+
+
+
+
+}
+
+
+double Transformation::unitToCm(double width, double height) const
+{
+	
+	return height/(getAbsoluteMaxPCY() - getAbsoluteMinPCY());
+}
+
+void Transformation::operator()(const UserPoint& geo, vector<PaperPoint>& out) const
+{
+	PaperPoint pp = (*this)(geo);
+		if ( in(pp) ) 
+			out.push_back(pp);
+
+}
+void Transformation::operator()(const UserPoint& geo, Polyline& out) const
+{
+	PaperPoint pp = (*this)(geo);
+		if ( in(pp) )
+			out.push_back(pp);
+
+}
+
+
+void Transformation::reprojectComponents(const UserPoint&, pair<double, double>&) const
+{
+	
+}
+
+void Transformation::reprojectSpeedDirection(const PaperPoint& point, pair<double, double>&) const
+{
+	
+}
+
+void Transformation::revert(const vector<pair<double, double> > & in, vector<pair<double, double> > & out) const
+{
+	out.reserve(in.size());
+	for (vector<pair<double, double> >::const_iterator p = in.begin(); p != in.end(); ++p)
+		out.push_back(make_pair(this->rx(p->first), this->ry(p->second)));
+
+}
+
+string Transformation::writeLongitude(const UserPoint& point) const
+{
+		return point.asLongitude();
+}
+string Transformation::writeLatitude(const UserPoint& point) const
+{
+		return point.asLatitude();
+}
+
+void Transformation::wraparound(const UserPoint& point, stack<UserPoint>& duplicates) const
+{
+	if ( in(point) ) {
+		duplicates.push(point);
+	}
+}
+
+MatrixHandler* Transformation::prepareData(const AbstractMatrix& matrix) const {
+	return new BoxMatrixHandler(matrix, *this);
+}
+
diff --git a/src/common/Transformation.h b/src/common/Transformation.h
new file mode 100644
index 0000000..153dcfe
--- /dev/null
+++ b/src/common/Transformation.h
@@ -0,0 +1,375 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \defgroup projections Geographical projections
+
+\section supportedProjection Supported projections
+
+Currently Magics++ supports following projections:
+
+ - Cylindrical
+ - Polar-stereographic
+ - Satellite
+
+ You can select the projection by setting the parameter SUBPAGE_MAP_PROJECTION .
+
+\section addProjection How to add a new projection
+
+ - add your <i>NewProjection.xml</i> in <i>src/xml</i>
+
+ - add this file in <i>src/xml/Makefile.am</i>
+
+ - add <i>NewProjection.cc/.h</i> in <i>src/drivers/common/</i>,
+   inheriting from Transformation, NewProjectionParameters and a relevant Terralib class
+
+ - add the new files in <i>src/common/Makefile.am</i>
+ 
+ - add new projection in src/common/SubPageAttributes.cc:\n
+    static SimpleObjectMaker<NewProjection, Transformation> new_NewProjection("new_name");
+
+ - add new projection in src/common/ViewAttributes.cc:\n
+    static SimpleObjectMaker<NewProjection, Transformation> new_NewProjection("new_name");
+    
+ - Last but not least: add the new projection to the documentation!
+*/
+
+/*! \file Transformation.h
+
+ Magics Team - ECMWF 2004
+*/
+
+#ifndef Transformation_H
+#define Transformation_H
+
+#include "magics.h"
+
+#include "PaperPoint.h"
+#include "UserPoint.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "TeProjection.h"
+#include "BasicGraphicsObject.h"
+#include "SceneVisitor.h"
+
+
+
+
+namespace magics {
+
+class Layout;
+class GridPlotting;
+class LabelPlotting;
+class BasicSceneObject;
+class MetaDataCollector;
+class AbstractMatrix;
+class MatrixHandler;
+class PointsHandler;
+class XmlNode;
+
+class Polyline;
+
+class ViewFilter
+{
+public:
+	ViewFilter() {}
+	ViewFilter(double xmin, double xmax, double ymin, double ymax, double xres, double yres);
+	~ViewFilter() {}
+	bool in(const PaperPoint& xy);
+
+    vector<bool> done;
+    double xmin_;
+    double xmax_;
+    double ymin_;
+    double ymax_;
+    double xres_;
+    double yres_;
+    int xdim_;
+    int ydim_;
+};
+
+
+class Transformation
+{
+public:
+	Transformation();
+	virtual ~Transformation();
+	virtual void init();
+
+	enum CoordinateType {GeoType,XyType};
+	CoordinateType coordinateType() const {return coordinateType_;}	
+	virtual void toxml(ostream&) const {}
+	// Xml Methods ! 
+	virtual void set(const map<string, string>& ) {}
+	virtual void set(const XmlNode& ) {}
+	virtual bool accept(const string& ) { return false; }
+	void toxml(ostream&, int)  const {}
+	virtual Transformation* clone() const {
+		Transformation* object = new Transformation();
+		return object;
+	}
+	
+	virtual Polyline& getUserBoundingBox() const  { assert(false); }
+	virtual Polyline& getPCBoundingBox()   const  { assert(false); }
+	
+	bool needTopAxis() const   { return topAxis_; }
+	void needTopAxis(bool top) { topAxis_ = top; }
+
+	void operator()(const Polyline& poly,  BasicGraphicsObjectContainer& out) const;	
+
+	string writeLongitude(const UserPoint&) const;
+	string writeLatitude(const UserPoint&) const;
+
+	virtual bool wrapAround(const Polyline&) const { return false; }
+	virtual void coastSetting(map<string, string>&, double, double) const { assert(false); }
+	virtual bool verifyDef(const string&) const { return false; }   
+
+
+
+	virtual double x(double x) const { return x; }
+	virtual double y(double y) const { return y; }
+	virtual double rx(double x) const { return x; }
+	virtual double ry(double y) const { return y; }
+
+	/*
+	// is the polyline out the projection!
+	virtual bool out(const Polyline&) const;
+	// is the polyline in the projection?
+	virtual bool in(const Polyline&) const;
+	*/
+    // is the point in projected area?
+	bool in(const UserPoint&) const;
+	bool in(const PaperPoint&) const;
+
+
+	// is the point in PC in the projected area?
+	bool in(double x, double y) const;
+
+    bool inX(double x) const
+       { return ( getAbsoluteMinX() <= x && x <=  getAbsoluteMaxX()); }
+    bool inY(double y) const
+        { return ( getAbsoluteMinY() <= y && y <= getAbsoluteMaxY()); }
+
+	// Needed for Image processing!
+	virtual TeProjection&  getProjection() 
+		{ static TeDatum datum; static TeLatLong dummy(datum); return dummy; }
+	
+	
+	
+	virtual void gridLongitudes(const GridPlotting&) const {}
+	virtual void gridLatitudes(const GridPlotting&) const  {}
+
+	virtual void labels(const LabelPlotting&, DrawingVisitor&) const {}
+	virtual void labels(const LabelPlotting&, LeftAxisVisitor&) const {}
+	virtual void labels(const LabelPlotting&, RightAxisVisitor&) const {}
+	virtual void labels(const LabelPlotting&, TopAxisVisitor&) const {}
+	virtual void labels(const LabelPlotting&, BottomAxisVisitor&) const {}
+
+	
+	
+	virtual void aspectRatio(double&, double&);
+	virtual void fill(double&, double&); // fill the space , can adapt the coordiantes to return the biggest area..
+	virtual void forceNewArea(double, double, double, double, double&, double&); 
+	
+	
+// Basic reprojection method! 
+	virtual PaperPoint operator()(const UserPoint& xy) const 
+		{ return PaperPoint(xy.x(), xy.y()); }
+
+
+	virtual void fast_reproject(double& x, double& y) const
+			{ }
+
+	virtual double patchDistance(double) const { assert(false); }
+
+	virtual PaperPoint operator()(const PaperPoint& xy) const 
+		{ return xy; }
+	virtual void operator()(const UserPoint& geo, Polyline& out) const;
+	virtual void operator()(const UserPoint& xy, vector<PaperPoint>& out) const;
+
+	virtual void revert(const vector<pair<double, double> > &, vector<pair<double, double> > &) const;
+	
+	virtual void revert(const PaperPoint& xy, UserPoint& point) const 
+		{ point = UserPoint(xy.x(), xy.y()); }		
+
+
+// Does the projection needs the coastalines to be shifted!
+	virtual bool needShiftedCoastlines() const { return false; }
+
+// Set the bounding box in user coordinates 
+	virtual void boundingBox(double&, double&, double&, double&) const;
+	virtual void smallestBoundingBox(double& x1, double& y1, double& x2, double& y2) const
+	{
+		boundingBox(x1, y1, x2, y2);
+	}
+	
+
+	virtual void setDataMinX(double minx) const { dataMinX_ = std::min(minx, dataMinX_); }
+	virtual void setDataMaxX(double maxx) const { dataMaxX_ = std::max(maxx, dataMaxX_); }
+	virtual void setDataMinY(double miny) const { dataMinY_ = std::min(miny, dataMinY_); }
+	virtual void setDataMaxY(double maxy) const { dataMaxY_ = std::max(maxy, dataMaxY_); }
+	
+	virtual void setAutomaticX(bool) {}
+	virtual void setAutomaticY(bool) {}
+	virtual bool getAutomaticX() const { return false; } 
+	virtual bool getAutomaticY() const { return false; }
+	
+    virtual void setDataMinX(double minx, const string& ref) const; 
+	virtual void setDataMaxX(double maxx, const string& ref) const; 
+	virtual void setDataMinY(double miny, const string& ref) const; 
+	virtual void setDataMaxY(double maxy, const string& ref) const; 
+	
+	virtual vector<double> getDataVectorMinX() const  { return vector<double>(); }
+	virtual vector<double> getDataVectorMaxX() const  { return vector<double>(); }
+	virtual vector<double> getDataVectorMinY() const  { return vector<double>(); }
+	virtual vector<double> getDataVectorMaxY() const  { return vector<double>(); }
+	
+	
+	
+    virtual const string& getReferenceX() const  { return referenceX_; }
+	virtual const string& getReferenceY() const  { return referenceY_; }
+	void setReferenceX(const string& ref) const  { referenceX_ = ref; }
+	void setReferenceY(const string& ref) const  { referenceY_ = ref; }
+	
+	
+	
+	virtual void adjustXAxis(Layout&) const {}
+	virtual void adjustYAxis(Layout&) const {}
+
+	virtual double getWidth() { return -1; }
+	virtual double getHeight() { return -1; }
+	
+	virtual double x(const string& val) const { return tonumber(val); }
+	virtual double y(const string& val) const { return tonumber(val); }
+
+
+	virtual double getMinX() const { return -1; }
+	virtual double getMaxX() const { return -1; }
+	virtual double getMinY() const { return -1; }
+	virtual double getMaxY() const { return -1; }
+	
+	virtual void setMinX(double) {}
+	virtual void setMaxX(double) {}
+	virtual void setMinY(double) {}
+	virtual void setMaxY(double) {}
+
+	virtual double getMinPCX() const { return -1; }
+	virtual double getMaxPCX() const { return -1; }
+	virtual double getMinPCY() const { return -1; }
+	virtual double getMaxPCY() const { return -1; }
+	virtual double dimension(BasicGraphicsObjectContainer& parent) const 
+	{ return parent.absoluteWidth(); }
+	
+	double getAbsoluteMinPCX() const { return std::min(getMinPCX(), getMaxPCX()); }
+	double getAbsoluteMaxPCX() const { return std::max(getMinPCX(), getMaxPCX()); }
+	double getAbsoluteMinPCY() const  { return std::min(getMinPCY(), getMaxPCY()); }
+	double getAbsoluteMaxPCY() const  { return std::max(getMinPCY(), getMaxPCY()); }
+	
+	double getAbsoluteMinX() const { return std::min(getMinX(), getMaxX()); }
+	double getAbsoluteMaxX() const { return std::max(getMinX(), getMaxX()); }
+	double getAbsoluteMinY() const  { return std::min(getMinY(), getMaxY()); }
+	double getAbsoluteMaxY() const  { return std::max(getMinY(), getMaxY()); }
+	
+	virtual void setNewPCBox(double, double, double, double) {  }
+	virtual double unitToCm(double, double) const;
+	
+	virtual double height() const { return getMaxX() - getMinX(); }
+	
+
+	virtual void getNewDefinition(const UserPoint&, const UserPoint&, string&) const
+		{ assert(false); }
+	virtual void setDefinition(const string&)
+		{ assert(false); }
+
+   virtual void thin(MatrixHandler&, double x, double y, vector<UserPoint>&) const;
+   
+   virtual void reprojectComponents(const UserPoint& point, pair<double, double>&) const;
+   virtual void reprojectSpeedDirection(const PaperPoint& point, pair<double, double>&) const;
+ 
+   void thin(PointsHandler& points, vector<PaperPoint>& out, vector<PaperPoint>&) const;
+   void thin(MatrixHandler& points, vector<PaperPoint>& out, vector<PaperPoint>&) const;
+
+   // The view is set in Projection coordinates!
+  virtual void filterView(double xmin, double xmax, double ymin, double ymax, double x, double y)  const {
+	  	view_ = ViewFilter(xmin, xmax, ymin, ymax, x, y);
+  }
+  virtual  void  collect(MetaDataCollector&) const {}
+   virtual  void  visit(MetaDataVisitor&, double, double, double, double, double, double);
+   virtual string xAxisType() const { return "regular"; }
+   virtual string yAxisType() const { return "regular"; }
+
+   virtual MatrixHandler* prepareData(const AbstractMatrix& matrix) const;
+   virtual void wraparound(const UserPoint&, stack<UserPoint>&) const;
+
+protected:
+	virtual void print(ostream&) const;    
+    
+    CoordinateType coordinateType_;	
+    
+    mutable double areaMinX_;
+    mutable double areaMaxX_;
+    mutable double areaMinY_;
+    mutable double areaMaxY_;
+    
+    mutable double  dataMinX_;
+    mutable double  dataMaxX_;
+    mutable double  dataMinY_;
+    mutable double  dataMaxY_;
+    
+    mutable string dataReferenceX_;
+    mutable string dataReferenceY_;
+    mutable string referenceX_;
+    mutable string referenceY_;
+    
+    mutable ViewFilter view_;
+
+    bool topAxis_;
+
+    mutable Polyline* userEnveloppe_;
+    mutable Polyline* PCEnveloppe_;
+
+private:
+	// No copy allowed
+	Transformation(const Transformation&);
+	Transformation& operator=(const Transformation&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const Transformation& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, Transformation>
+{ 
+public:
+	Transformation* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<Transformation>::create(val);
+	}     
+	Transformation* magics(const string& param)
+	{
+		Transformation* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
+
diff --git a/src/common/UserLogoPlottingAttributes.h b/src/common/UserLogoPlottingAttributes.h
new file mode 100644
index 0000000..11426ef
--- /dev/null
+++ b/src/common/UserLogoPlottingAttributes.h
@@ -0,0 +1,89 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file UserLogoPlottingAttributes.h
+    \brief Definition of UserLogoPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef UserLogoPlottingAttributes_H
+#define UserLogoPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class UserLogoPlottingAttributes 
+{
+public:
+//  --  constructor
+    UserLogoPlottingAttributes();
+    
+//  --  destructor
+    virtual ~UserLogoPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const UserLogoPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string path_;
+	string format_;
+	string units_;
+	double y_;
+	double x_;
+	string bottom_;
+	string left_;
+	double width_;
+	double height_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const UserLogoPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/common/UserPoint.h b/src/common/UserPoint.h
new file mode 100644
index 0000000..a16dd82
--- /dev/null
+++ b/src/common/UserPoint.h
@@ -0,0 +1,156 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file UserPoint.h
+    \brief Definition of Point (x, y, z, v).
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Jan 2004
+    
+    Changes:
+    
+*/
+#ifndef UserPoint_H
+#define UserPoint_H
+
+#include "magics.h"
+#include <stack>
+
+namespace magics {
+
+class UserPoint  {
+
+public:
+	UserPoint(double x, double y, double value = 0, bool missing = false, bool border = false) :
+		x_(x), y_(y), value_(value), high_(false), low_(false), missing_(missing), border_(border)  {}
+	// ~UserPoint() {}
+	UserPoint() :
+		x_(0), y_(0), value_(0), high_(false), low_(false), missing_(false), border_(false) {}
+	
+	void y(double y) { y_ = y; }
+	void x(double x) { x_ = x; }
+	void value(double value) { value_ = value; }
+    
+    
+	inline double y() const     { return y_; }
+	inline double x() const     { return x_; }
+	inline double value() const { return value_; }
+	
+	void flagMissing()          { missing_ = true; }
+	bool missing() const        { return missing_; }
+	
+	void flagBorder()          { border_ = true; }
+		bool border() const        { return border_; }
+		
+	bool ignore() const { return border_ || missing_; } 
+	
+	bool operator==(const UserPoint& other) const
+	{
+		return (  same(x_, other.x()) && same(y_, other.y()) );
+	}
+	bool operator!=(const UserPoint& other) const
+	{
+		return !(*this == other);
+	}
+	double x_;
+	double y_;
+	double value_;
+	/*
+	bool in(double left, double right, double bottom, double top,std::stack<UserPoint*>& points)
+	{
+		double miny = std::min(top, bottom);
+		double maxy = std::max(top, bottom);
+		double minx = std::min(left, right);
+		double maxx = std::max(left, right);
+
+		if (y_ > maxy)
+			return false;
+		if (y_ < miny)
+			return false;
+		if (x_ < minx)
+			return false;
+		if (x_ > maxx)
+			return false;
+		UserPoint* point = this;
+		points.push(point);
+		return true;
+	}
+	*/
+	void high(bool high) { high_ = high; }
+	void low(bool low)   { low_ = low; }
+	bool high() const { return high_; }
+	bool low() const { return low_; }
+
+	UserPoint shift(double left, double right) const
+	{
+		UserPoint point(*this);
+		if ( left <= x_ &&  x_ <= right) return point;
+		while (point.x_ <= left && point.x_ <= right)
+			point.x_ += 360;
+		while (point.x_ >= right && point.x_ > left)
+			point.x_ -= 360;
+		return point;
+	}
+	string asLongitude() const
+	{
+		ostringstream lon;
+//		string ew = "#232"; // degree symbol
+		string ew = "°";
+		UserPoint nice = shift(-180, 180);
+
+		if ( nice.x_ < 0 ) ew += "W";
+		if ( nice.x_ >= 0 ) ew += "E";
+		float x = float(maground(abs(nice.x_)*100)) / 100;
+		lon << x << ew;
+		return  lon.str();
+	}
+
+	string asLatitude() const
+	{
+		ostringstream lat;
+		//string ns = "#232"; // degree symbol
+		string ns = "°";
+		if ( y_ < 0 ) ns += "S";
+		if ( y_ >= 0 ) ns += "N";
+		float y = float(maground(abs(y_)*100)) / 100;
+		lat <<  y << ns;
+		return  lat.str();
+	}
+protected:
+    bool high_;
+	bool low_;
+	bool missing_;
+	bool border_;
+	
+	void print(ostream& out) const
+	{ 
+		out << "UserPoint[";
+		out << x_ << "(x), ";
+		out << y_ << "(y),";
+		out << value_ << "(value)]";
+	}
+
+private:
+	
+// -- Friends
+	friend ostream& operator<<(ostream& s,const UserPoint& p)
+		{ p.print(s); return s; }
+};
+}
+#endif
diff --git a/src/common/Visualiser.h b/src/common/Visualiser.h
new file mode 100644
index 0000000..f2f62ec
--- /dev/null
+++ b/src/common/Visualiser.h
@@ -0,0 +1,96 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Visualiser.h
+    \brief Definition of the Template class Visualiser.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 19-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Visualiser_H
+#define Visualiser_H
+
+#include "magics.h"
+
+
+#include "VisualTask.h"
+
+
+namespace magics {
+
+template <class P> class Data;
+template <class P> class MatrixHandler;
+
+template <class P>
+class VisualComponent
+{
+public:
+	VisualComponent()  {};
+	virtual ~VisualComponent() {};
+	
+	
+	
+    
+    
+    
+    virtual void preparePlot(Data<P>&, Task&) 
+    	{ MagLog::dev() << "VisualComponent::preparePlot(Data<P>&, Task&)--->Not yet implemented\n"; }
+    virtual void preparePlot(MatrixHandler<P>&, Task&) 
+        { MagLog::dev() << "VisualComponent::preparePlot(MatrixHandler<P>&, Task&)--->Not yet implemented\n"; }
+    virtual void preparePlot(Task&) 
+    	{ MagLog::dev() << "VisualComponent::preparePlot(Task&)--->Not yet implemented\n"; }
+	
+};
+
+
+template <class P>
+class Visualiser : public BaseSceneObject, public VisualComponent<P> {
+
+public:
+	Visualiser()  {};
+	virtual ~Visualiser() {};
+	
+	 virtual void specialise(VisualTask<P>& task) { task.set(this); };
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "Base class Visualiser"; } 
+  
+     
+private:
+    //! Copy constructor - No copy allowed
+	Visualiser(const Visualiser&);
+    //! Overloaded << operator to copy - No copy allowed
+	Visualiser& operator=(const Visualiser&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Visualiser<P>& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/common/XCoordinate.h b/src/common/XCoordinate.h
new file mode 100644
index 0000000..5958ccf
--- /dev/null
+++ b/src/common/XCoordinate.h
@@ -0,0 +1,35 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XCoordinate.h
+    \brief Definition of the Template class XCoordinate.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 10-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef XCoordinate_H
+#define XCoordinate_H
+
+#include "Coordinate.h"
+
+#endif
diff --git a/src/common/XmlNode.cc b/src/common/XmlNode.cc
new file mode 100644
index 0000000..a69dea9
--- /dev/null
+++ b/src/common/XmlNode.cc
@@ -0,0 +1,119 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlNode.cc
+    \brief Implementation of the Template class XmlNode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 10-Jun-2005
+    
+    Changes:
+    
+*/
+
+#include "XmlNode.h"
+
+using namespace magics;
+
+XmlNode::XmlNode() 
+{
+}
+
+XmlNode::XmlNode(const string& name) : name_(name) 
+{
+}
+
+XmlNode::XmlNode(const string& name, const map<string, string>& def) : 
+	name_(name), attributes_(def)
+{
+}
+
+XmlNode::XmlNode(const XmlNode& from) :
+	name_(from.name_)
+{
+	copy(from);
+}
+
+void XmlNode::copy(const XmlNode& from) 
+{
+	name_ = from.name_;
+	data_ = from.data_;
+// First copy the attributes...
+	// From the node..
+	for ( map<string, string>::const_iterator attr = from.attributes_.begin(); attr != from.attributes_.end(); ++attr) {
+		attributes_.insert(make_pair(attr->first, attr->second));
+	}
+
+	// Now copy the element...
+	for (vector<XmlNode*>::const_iterator elt = from.elements_.begin(); elt != from.elements_.end(); ++elt) {
+		elements_.push_back(new XmlNode(**elt));	
+	}
+}
+
+XmlNode::XmlNode(const XmlNode& from, const map<string, string>& def) 
+{
+	copy(from);
+	for ( map<string, string>::const_iterator attr = def.begin(); attr != def.end(); ++attr) {
+		attributes_.insert(make_pair(attr->first, attr->second));
+	}
+}
+
+XmlNode::~XmlNode() 
+{
+}
+
+string  XmlNode::getAttribute(const string& attr, const string& def) const
+{
+	
+	AttributesIterator value = attributes_.find(attr);
+	return ( value != attributes_.end() ) ?  value->second : def;
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void XmlNode::print(ostream& out)  const
+{
+	static int indent = -1;
+	indent++;
+	ostringstream tabs;
+	for (int i = 0; i < indent; i++) tabs << "  ";
+	string tab = tabs.str();
+	out << tab << "<" << name_;
+		
+	for (map<string, string>::const_iterator attr = attributes_.begin(); attr != attributes_.end(); ++attr) {
+		out << " " << attr->first << "='" << attr->second <<"'";	
+	}
+	out << ">\n";
+	for (vector<string>::const_iterator data = data_.begin(); data != data_.end(); ++data) {
+		out << *data << "\n";
+	}
+	for (vector<XmlNode*>::const_iterator elt = elements_.begin(); elt != elements_.end(); ++elt) {
+		out << **elt;			
+	}
+	out << tab << "</" << name_ << ">\n";
+	indent--;
+}
+
+void  XmlNode::visit(XmlNodeVisitor& visitor) const
+{ 
+	for (vector<XmlNode*>::const_iterator elt = elements_.begin(); elt != elements_.end(); ++elt) {
+		visitor.visit(**elt);		
+	}
+}
diff --git a/src/common/XmlNode.h b/src/common/XmlNode.h
new file mode 100644
index 0000000..e599d6e
--- /dev/null
+++ b/src/common/XmlNode.h
@@ -0,0 +1,108 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlNode.h
+    \brief Definition of the Template class XmlNode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 10-Jun-2005
+    
+    Changes:
+    
+*/
+
+#ifndef XmlNode_H
+#define XmlNode_H
+
+#include "magics.h"
+#include "VectorOfPointers.h"
+
+
+namespace magics {
+	
+class XmlNode;
+	
+class XmlNodeVisitor
+{
+public:
+	XmlNodeVisitor() {}
+	virtual ~XmlNodeVisitor() {}
+	virtual void visit(const XmlNode&) = 0;
+	
+};
+
+class XmlNode {
+
+public:
+    typedef vector<XmlNode*>::const_iterator ElementIterator;
+    typedef map<string, string>::const_iterator AttributesIterator;
+    typedef vector<string>::const_iterator DataIterator;
+    
+	XmlNode();
+	XmlNode(const string&);
+	XmlNode(const string&, const map<string, string>&);
+	XmlNode(const XmlNode&, const map<string, string>&);
+	XmlNode(const XmlNode&);
+	
+	virtual ~XmlNode();
+	void push_back(XmlNode* element) { elements_.push_back(element); }
+	void setData(const string& data) { data_.push_back(data); }
+	
+	
+	bool noElement() const { return elements_.empty(); }
+	
+	ElementIterator firstElement()  const      { return elements_.begin(); }
+	ElementIterator lastElement() const        { return elements_.end(); }
+	AttributesIterator firstAttributes() const { return attributes_.begin(); }
+	AttributesIterator lastAttributes() const  { return attributes_.end(); }
+	DataIterator   firstData() const           { return data_.begin(); }
+	DataIterator   lastData() const            { return data_.end(); }
+	const string& data() const              { static string e = ""; return data_.empty() ? e : *data_.begin(); }
+	
+	string   getAttribute(const string& attr, const string& def = "") const;
+	
+	const string&   name() const                       { return name_; } 
+	void   name(const string& name)                       { name_ = name; } 
+	const map<string, string>&   attributes() const { return attributes_; }
+	void addAttribute(const string& param, const string& value) { attributes_.insert(make_pair(param, value)); }
+	
+	void  visit(XmlNodeVisitor&) const;
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 string                  name_;
+	 vector<string>          data_;
+	 VectorOfPointers<vector<XmlNode*> > elements_;
+	 map<string, string>  attributes_;
+	 void copy(const XmlNode&); 
+private:
+ 
+    //! Overloaded << operator to copy - No copy allowed
+	XmlNode& operator=(const XmlNode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const XmlNode& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/XmlReader.cc b/src/common/XmlReader.cc
new file mode 100644
index 0000000..3b9f019
--- /dev/null
+++ b/src/common/XmlReader.cc
@@ -0,0 +1,206 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlReader.cc
+    \brief Implementation of the Reader for Xml.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: 2005
+    
+    Changes:
+    
+*/ 
+
+#include "XmlReader.h"
+#include "expat.h"
+#include "MagLog.h"
+#include "MagException.h"
+using namespace magics;
+
+XmlReader::XmlReader(bool tag) : dataAsTag_(tag) 
+{
+}
+
+
+XmlReader::~XmlReader() 
+{
+}
+
+static void XMLCALL startElementHandler(void *data, const char *name, const char **atts)
+{
+	XmlReader* reader  = (XmlReader*) data; 
+	map<string, string> def;
+	while (*atts) {         
+		def.insert(std::make_pair(*atts,*(atts+1)));
+		atts+=2;
+	}	
+	reader->newElement(name, def);      
+}
+
+
+static void XMLCALL endElementHandler(void* data, const char* tag)
+{
+	XmlReader* reader  = (XmlReader*) data; 
+	reader->endElement(tag);
+}
+
+static bool empty(const string& value)
+{
+	for (string::const_iterator c = value.begin(); c != value.end(); ++c) {
+		if ( !isspace(*c) ) return false;
+	}
+	return true;
+}
+
+static void XMLCALL dataHandler (void *data, const char *value, int len)
+{
+	string stringval = string(value, len);
+	if (  empty(stringval) ) return;
+	XmlReader* reader  = (XmlReader*) data;
+	
+	if ( reader->dataAsTag() ) {
+		map<string, string> def;
+    	def["data"] = stringval;
+		reader->newElement("data", def);     
+		reader->endElement("data");
+	}
+	else 
+		reader->addData(stringval);
+}
+
+
+static int externalEntityRefHandler( XML_Parser ,//	 parser,
+		const XML_Char *  	context,
+		const XML_Char *  	base,
+		const XML_Char *  	systemID,
+		const XML_Char *  	publicID
+	)
+{
+	//MagLog::dev()<< "context--->" << context << endl;
+	//MagLog::dev()<< "base--->" << base << endl;
+	//MagLog::dev()<< "systemID--->" << systemID << endl;
+	//MagLog::dev()<< "publicID--->" << publicID << endl;
+	return 0;
+}
+
+
+
+void XmlReader::newElement(const string& name, const map<string, string>& def)
+{
+
+	// Here we create a XmlNode you put in the tree...
+	XmlNode* parent = tree_->getParent(name);
+	if ( parent ) {
+		//MagLog::dev()<< "push-->empty " << name << endl;
+		push(parent);
+	}
+	if ( empty() )
+		push(tree_->root());
+	XmlNode* node = tree_->newNode(name, def);
+	top()->push_back(node);
+	push(node); 
+}
+
+void XmlReader::endElement(const string& tag)
+{
+	tree_->endElement(tag);
+	pop();
+	//MagLog::dev()<< "pop-->" << tag << endl;
+	if ( tag == "definition" ) {
+		pop();
+		//MagLog::dev()<< "pop-->empty" << tag << endl;
+	}
+	if ( tag == "magics" ) {
+		pop();
+		//MagLog::dev()<< "pop-->empty" << tag << endl;
+	}
+}
+
+void XmlReader::addData(const string& data)
+{
+	top()->setData(data);
+}
+
+
+
+void XmlReader::interpret(const string& xml, XmlTree* tree)
+{
+	tree_ = tree;
+	char buf[BUFSIZ];
+	XML_Parser parser = XML_ParserCreate(NULL);
+	int done;
+	XML_SetUserData(parser, this);
+	XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+	XML_SetElementHandler(parser, startElementHandler, endElementHandler);
+	XML_SetCharacterDataHandler(parser, dataHandler);
+
+	FILE* in  = fopen(xml.c_str(), "r");
+
+	if (!in) {
+		MagLog::dev()<< "XmlDecoder: can not open file " << xml << endl;
+		MagLog::error() << "XmlDecoder: can not open file " << xml << endl;
+		return;
+	}
+
+	do
+	{
+		size_t len = fread(buf, 1, sizeof(buf), in);
+		done = len < sizeof(buf);
+		if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+		{
+			ostringstream s;
+			s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+			cerr <<  s.str() << "\n";
+		}
+	} while (!done);
+	XML_ParserFree(parser);
+	fclose(in);
+}
+
+int XmlReader::decode(const string& xml, XmlTree* tree)
+{
+	tree_ = tree;
+//	char buf[BUFSIZ];
+	XML_Parser parser = XML_ParserCreate(NULL);
+//	int done;
+	XML_SetUserData(parser, this);
+	XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+	XML_SetElementHandler(parser, startElementHandler, endElementHandler);
+	XML_SetCharacterDataHandler(parser, dataHandler);
+		
+	int err = 0;
+	if (XML_Parse(parser, xml.c_str(), xml.size(), true) == XML_STATUS_ERROR)
+	{
+		ostringstream s;
+		s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+		err = -1;
+	}
+	XML_ParserFree(parser);
+	return err;
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void XmlReader::print(ostream& out)  const
+{
+	out << "XmlReader[";
+	out << "]";
+}
diff --git a/src/common/XmlReader.h b/src/common/XmlReader.h
new file mode 100644
index 0000000..8a99080
--- /dev/null
+++ b/src/common/XmlReader.h
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlReader.h
+    \brief Definition of the Template class XmlReader.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jun-2005
+
+*/
+
+#ifndef XmlReader_H
+#define XmlReader_H
+
+#include "magics.h"
+#include "XmlTree.h"
+
+namespace magics {
+	
+class XmlReader : private std::stack<XmlNode*> {
+
+public:
+	XmlReader(bool tag=false);
+	virtual ~XmlReader();
+	void interpret(const string&, XmlTree*);
+	int decode(const string&, XmlTree*);
+	void newElement(const string&, const map<string, string>&);
+	void endElement(const string&);
+	void addData(const string&);
+	
+	bool dataAsTag() { return dataAsTag_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 XmlTree* tree_;
+	 bool     dataAsTag_;
+
+private:
+    //! Copy constructor - No copy allowed
+	XmlReader(const XmlReader&);
+    //! Overloaded << operator to copy - No copy allowed
+	XmlReader& operator=(const XmlReader&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const XmlReader& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/XmlTree.cc b/src/common/XmlTree.cc
new file mode 100644
index 0000000..2ec6ed0
--- /dev/null
+++ b/src/common/XmlTree.cc
@@ -0,0 +1,136 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlTree.h
+    \brief Implementation of the Template class XmlTree.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 10-Jun-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "XmlTree.h"
+#include "MagLog.h"
+
+using namespace magics;
+
+XmlTree::XmlTree() : root_("root")
+{
+}
+
+
+XmlTree::~XmlTree() 
+{
+//	for (map<string, XmlNode*>::iterator id = ids_.begin(); id != ids_.end(); ++id) {
+//		XmlNode* node = id->second;
+//		id->second =0;
+//		delete node;
+//	}
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void XmlTree::print(ostream& out)  const
+{
+	out << "XmlTree[";
+	out << root_;
+	out << "]";
+}
+
+
+XmlNode* XmlTree::getParent(const string& tag)
+{
+	if (tag == "magics_plot") return &root_;
+	if (tag == "magics") return &root_;
+	if (tag == "definition") return &definitions_;
+	return 0; // Not special tag!
+}
+
+void XmlTree::endElement(const string& tag)
+{
+	if ( tag == "definition") {
+		// we build the map of id ...
+		XmlNode::ElementIterator def = definitions_.firstElement();
+		while ((*def)->name() != "definition" ) def++;
+		for (XmlNode::ElementIterator id = (*def)->firstElement(); id != (*def)->lastElement(); ++id ) {
+				string keyword = (*id)->getAttribute("id");
+				if ( keyword == "" ) 
+					MagLog::warning() << "No if defined in group definition : " << (*id)->name() << "\n";
+				else
+					ids_.insert(make_pair(keyword, (*id)));
+				
+				
+		} 
+		
+	}
+}
+
+XmlNode* XmlTree::newNode(const string& name, const map<string, string>& def) const
+{
+	// find in the attributes, if the keywird use_id is present
+	map<string, string>::const_iterator use_id = def.find("use_id");
+	if ( use_id == def.end() ) {
+		return new XmlNode(name, def);
+	}
+	map<string, XmlNode*>::const_iterator id = ids_.find(use_id->second);
+	if ( id == ids_.end() && definitions_.noElement() == false) {
+		// We try to update the tree to see 
+		
+			XmlNode::ElementIterator elt = definitions_.firstElement();
+			
+			while ( (*elt)->name() != "definition" ) 
+				elt++;
+			for (XmlNode::ElementIterator i = (*elt)->firstElement(); i != (*elt)->lastElement(); ++i ) {
+				string keyword = (*i)->getAttribute("id");
+				if ( keyword == "" ) 
+					MagLog::warning() << "No id defined in group definition : " << (*i)->name() << "\n";
+				else
+					ids_.insert(make_pair(keyword, (*i)));			
+			}
+
+		// we try again! 
+		id = ids_.find(use_id->second); 
+		if ( id == ids_.end() ) { 
+			MagLog::warning() << "Could not find definition for " << use_id->second << "\n";
+			return new XmlNode(name, def);
+		}
+	}
+	return new XmlNode(*(id->second), def);
+}
+
+void XmlTree::definition(XmlNode* definition)
+{
+	definitions_.push_back(definition);
+	XmlNode::ElementIterator elt = definitions_.firstElement();
+				
+	while ( (*elt)->name() != "definition" ) 
+		elt++;
+	for (XmlNode::ElementIterator i = (*elt)->firstElement(); i != (*elt)->lastElement(); ++i ) {
+		string keyword = (*i)->getAttribute("id");
+		if ( keyword == "" ) 
+			MagLog::warning() << "No if defined in group definition : " << (*i)->name() << "\n";
+		else
+			ids_.insert(make_pair(keyword, (*i)));		
+	}
+}
diff --git a/src/common/XmlTree.h b/src/common/XmlTree.h
new file mode 100644
index 0000000..06ba1e0
--- /dev/null
+++ b/src/common/XmlTree.h
@@ -0,0 +1,70 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XmlTree.h
+    \brief Definition of the Template class XmlTree.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jun-2005
+
+*/
+
+#ifndef XmlTree_H
+#define XmlTree_H
+
+#include "magics.h"
+#include "XmlNode.h"
+
+
+namespace magics {
+
+class XmlTree {
+
+public:
+	XmlTree();
+	virtual ~XmlTree();
+    XmlNode* getParent(const string&);
+    void     endElement(const string&); 
+    XmlNode* newNode(const string&, const map<string, string>& def) const;
+    XmlNode::ElementIterator firstElement() const { return root_.firstElement(); }
+    XmlNode::ElementIterator lastElement() const  { return root_.lastElement(); }
+    void visit(XmlNodeVisitor& visitor) const { root_.visit(visitor); } 
+    XmlNode* root()                           { return &root_; } 
+    void definition(XmlNode* definition);    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 mutable map<string, XmlNode*> ids_;
+	 XmlNode                  root_;
+	 XmlNode                  definitions_;
+
+private:
+    //! Copy constructor - No copy allowed
+	XmlTree(const XmlTree&);
+    //! Overloaded << operator to copy - No copy allowed
+	XmlTree& operator=(const XmlTree&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const XmlTree& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/common/YCoordinate.h b/src/common/YCoordinate.h
new file mode 100644
index 0000000..363ca83
--- /dev/null
+++ b/src/common/YCoordinate.h
@@ -0,0 +1,31 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XCoordinate.h
+    \brief Definition of the Template class XCoordinate.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Aug-2006
+*/
+
+#ifndef YCoordinate_H
+#define YCoordinate_H
+
+#include "Coordinate.h"
+
+#endif
diff --git a/src/common/aix.h b/src/common/aix.h
new file mode 100644
index 0000000..d15b3e8
--- /dev/null
+++ b/src/common/aix.h
@@ -0,0 +1,121 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef MagicsAIX_H
+#define MagicsAIX_H
+
+
+#define _(A) A
+
+#include <stdio.h>
+#include <pthread.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <string.h>
+
+#include <new>
+#include <iostream>
+#include <fstream>
+#include <iomanip>
+
+#include <sstream>
+#define HAS_STRINGSTREAM
+/* #include <strstream.h> */
+
+#ifndef _THREAD_SAFE
+#define _THREAD_SAFE
+#endif
+
+// Stl
+
+#include <set>
+#include <map>
+#include <list>
+#include <vector>
+#include <stack>
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <numeric>
+#include <queue>
+
+
+using namespace std;
+
+// #define __FUNCTION__  __FILE__
+
+#define STATIC_CAST(a,b)      static_cast<a>(b)
+#define DYNAMIC_CAST(a,b)     dynamic_cast<a>(b)
+#define REINTERPRET_CAST(a,b) reinterpret_cast<a>(b)
+
+#define NPOS string::npos
+#define THROW_NOTHING throw
+
+#define HAS_BOOL
+
+
+#ifndef linux
+#define linux
+#endif
+
+//typedef int   fortint;
+//typedef float fortfloat;
+
+#ifndef __USE_LARGEFILE64
+#define off64_t     off_t
+#define stat64      stat
+#define ftruncate64 ftruncate
+#define flock64     flock
+#define lseek64     lseek
+#define open64      open
+#define fopen64     fopen
+#define fseeko64    fseek
+#define ftello64    ftell
+#define mmap64      mmap
+#define fstat64     fstat
+#endif
+
+#include <stdint.h>
+
+#define INCLUDE_TEMPLATES
+
+#if defined(__GNUC__) && __GNUC__ < 3
+/* #define OLD_STREAMBUF */
+#else
+
+
+#define HAS_STRINGSTREAM
+
+struct output_iterator {
+  typedef output_iterator_tag iterator_category;
+  typedef void                value_type;
+  typedef void                difference_type;
+  typedef void                pointer;
+  typedef void                reference;
+};
+
+// GCC 3.3 is confused about offsetof
+static double _offset;
+#define member_offset(Z,z)  size_t( reinterpret_cast<char*>(&reinterpret_cast<Z*>(&_offset)->z) - reinterpret_cast<char*>(&_offset))
+#define member_size(Z,z)    size_t( sizeof(reinterpret_cast<Z*>(&_offset)->z))
+
+#endif
+
+
+#endif
diff --git a/src/common/linux.h b/src/common/linux.h
new file mode 100644
index 0000000..edfe659
--- /dev/null
+++ b/src/common/linux.h
@@ -0,0 +1,118 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#define _(A) A
+
+#include <stdio.h>
+#include <pthread.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <string.h>
+
+#include <new>
+#include <iostream>
+#include <fstream>
+#include <iomanip>
+
+#include <bits/stream_iterator.h>
+
+#include <sstream>
+#define HAS_STRINGSTREAM
+/* #include <strstream.h> */
+
+#ifndef _THREAD_SAFE
+#define _THREAD_SAFE
+#endif
+
+// Stl
+
+#include <set>
+#include <map>
+#include <list>
+#include <vector>
+#include <stack>
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <numeric>
+#include <queue>
+
+
+using namespace std;
+
+#define __FUNCTION__  __FILE__
+
+#define STATIC_CAST(a,b)      static_cast<a>(b)
+#define DYNAMIC_CAST(a,b)     dynamic_cast<a>(b)
+#define REINTERPRET_CAST(a,b) reinterpret_cast<a>(b)
+
+#define NPOS string::npos
+#define THROW_NOTHING throw
+
+#define HAS_BOOL
+
+
+#ifndef linux
+#define linux
+#endif
+
+//typedef int   fortint;
+//typedef float fortfloat;
+
+#ifndef __USE_LARGEFILE64
+#define off64_t     off_t
+#define stat64      stat
+#define ftruncate64 ftruncate
+#define flock64     flock
+#define lseek64     lseek
+#define open64      open
+#define fopen64     fopen
+#define fseeko64    fseek
+#define ftello64    ftell
+#define mmap64      mmap
+#define fstat64     fstat
+#endif
+
+#include <stdint.h>
+
+#define INCLUDE_TEMPLATES
+
+#if defined(__GNUC__) && __GNUC__ < 3
+/* #define OLD_STREAMBUF */
+#else
+
+
+#define HAS_STRINGSTREAM
+
+struct output_iterator {
+  typedef output_iterator_tag iterator_category;
+  typedef void                value_type;
+  typedef void                difference_type;
+  typedef void                pointer;
+  typedef void                reference;
+};
+
+// GCC 3.3 is confused about offsetof
+//static double _offset;
+#define member_offset(Z,z)  size_t( reinterpret_cast<char*>(&reinterpret_cast<Z*>(&_offset)->z) - reinterpret_cast<char*>(&_offset))
+#define member_size(Z,z)    size_t( sizeof(reinterpret_cast<Z*>(&_offset)->z))
+
+
+#endif
+
diff --git a/src/common/magics_api.h b/src/common/magics_api.h
new file mode 100644
index 0000000..9fc21d4
--- /dev/null
+++ b/src/common/magics_api.h
@@ -0,0 +1,107 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file magics_api.h
+  \brief Implementation of C interface
+  This header file needs to be included by all C programs
+  using the C Magics parameter interface.
+  
+  Be careful with including stdio.h because 
+  pclose() and popen() are used there too!!!
+*/
+#ifndef _MAGICS_API_H_
+#define _MAGICS_API_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void mag_open();
+void mag_close();
+void mag_coast();
+void mag_grib();
+void mag_mapgen();
+void mag_test();
+void mag_odb();
+void mag_bufr();
+void mag_legend();
+void mag_import();
+void mag_netcdf();
+void mag_cont();
+void mag_obs();
+void mag_raw();
+void mag_image();
+void mag_plot();
+void mag_text();
+void mag_wind();
+void mag_symb();
+void mag_boxplot();
+void mag_line();
+void mag_taylor();
+void mag_input();
+
+void mag_wrepjson();
+void mag_epscloud();
+void mag_epsgraph();
+void mag_epsbar();
+void mag_epsshading();
+void mag_epswind();
+void mag_epswave();
+
+
+
+void mag_new(const char* page);
+
+void mag_setc(const char* name, const char*  value);
+void mag_setr(const char* name, const double value);
+void mag_seti(const char* name, const int value);
+void mag_setp(const char* name, void* value);
+void mag_reset(const char* name);
+
+void mag_act  (const char* name, const char*, const char*);
+void mag_set1i(const char* name, const int* data, const int dim1);
+void mag_set2i(const char* name, const int* data, const int dim1, const int dim2);
+void mag_set3i(const char* name, const int* data, const int dim1, const int dim2, const int dim3);
+void mag_set1c(const char* name, const char** value, const int dim1);
+void mag_set1r(const char* name, const double* data, const int dim1);
+void mag_set2r(const char* name, const double* data, const int dim1, const int dim2);
+void mag_set3r(const char* name, const double* data, const int dim1, const int dim2, const int dim3);
+
+void mag_enqr (const char* name, double* value);
+void mag_enqi (const char* name, int* value);
+void mag_enqc (const char* name, char* value);
+
+void mag_pie();
+void mag_graph();
+void mag_axis();
+void mag_geo();
+void mag_eps();
+void mag_print();
+void mag_info();
+
+/* Definition of the python web interface*/
+void execute_magml(const char*);
+void execute_json(const char*);
+void set_param(const char*, const char*);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/common/marsmachine.h b/src/common/marsmachine.h
new file mode 100644
index 0000000..03a1628
--- /dev/null
+++ b/src/common/marsmachine.h
@@ -0,0 +1,134 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef marsmachine_H
+#define marsmachine_H
+
+// All machine dependant stuff should go here
+
+#ifdef __xlC__
+#include "aix.h"
+#endif
+
+#ifdef __GNUG__
+#include "linux.h"
+#endif
+
+#ifdef __sgi
+#include "sgi.h"
+#endif
+
+#ifdef __hpux
+#include "hpux.h"
+#endif
+
+
+// Usefull macros
+
+#ifndef NUMBER
+#define NUMBER(x) (sizeof(x)/sizeof(x[0]))
+#endif
+
+template<class T>
+inline void zero(T& p) { ::memset(&p,0,sizeof(T)); }
+
+class Bless {
+public:	
+
+	bool          operator() (bool*  a)          { return *a; }
+	int           operator() (int*   a)          { return *a; }
+	short         operator() (short*   a)          { return *a; }
+	char          operator() (char*  a)          { return *a; }
+	long          operator() (long* a)           { return *a; }
+	long long     operator() (long long* a)      { return *a; }
+
+	unsigned long operator() (unsigned long* a) { return *a; }
+	unsigned int  operator() (unsigned int* a)  { return *a; }
+	unsigned char operator() (unsigned char* a) { return *a; }
+	unsigned short operator() (unsigned short* a) { return *a; }
+	unsigned long long operator() (unsigned long long* a)      { return *a; }
+
+	double        operator() (double* a)        { return *a; }
+
+	template<class T>
+	Bless&        operator() (T*)               { return *this; }
+};
+
+class TypeInfo;
+class Isa {
+public:
+	Isa* next_;
+	TypeInfo* type_;
+	Isa(TypeInfo* t,Isa* n) : next_(n), type_(t) {};
+	static void add(TypeInfo* t,const string&);
+	static Isa* get(const string&);  
+
+
+};
+
+
+#ifndef member_size
+#define member_size(a,b)   size_t(sizeof(((a*)0)->b))
+#endif
+
+#ifndef member_offset
+#define member_offset(a,b) size_t(&(((a*)0)->b))
+#endif
+
+class Schema {
+public:
+	virtual void start(const string&, size_t size) = 0;
+	virtual void member(const string&, size_t size, size_t offset, const string& type) = 0;
+	virtual void end(const string&) = 0;
+};
+
+template<class T>
+void _describe(ostream& s,int depth,const T& what) 
+{
+	what.describe(s,depth);
+}
+
+void _describe(ostream& s,int depth,int what);
+void _describe(ostream& s,int depth,unsigned int what);
+void _describe(ostream& s,int depth,short what);
+void _describe(ostream& s,int depth,bool what);
+void _describe(ostream& s,int depth,unsigned short what);
+void _describe(ostream& s,int depth,long what);
+void _describe(ostream& s,int depth,long long what);
+void _describe(ostream& s,int depth,unsigned long long what);
+void _describe(ostream& s,int depth,unsigned long what);
+void _describe(ostream& s,int depth,char what);
+void _describe(ostream& s,int depth,unsigned char what);
+void _describe(ostream& s,int depth,double what);
+
+void _startClass(ostream& s,int depth,const string& name);
+void _endClass(ostream& s,int depth,const string& name);
+void _startMember(ostream& s,int depth,const string& name);
+void _endMember(ostream& s,int depth,const string& name);
+
+template<class T>
+void _describe(ostream& s,int depth,const string& name,const T& what) 
+{
+	_startMember(s,depth,name);
+	_describe(s,depth,what);
+	_endMember(s,depth,name);
+}
+
+
+#endif
+
diff --git a/src/decoders/BinningObject.cc b/src/decoders/BinningObject.cc
new file mode 100644
index 0000000..72f7fe4
--- /dev/null
+++ b/src/decoders/BinningObject.cc
@@ -0,0 +1,147 @@
+/*! \file BinningObject.cc
+    \brief Implementation of the Template class BinningObject.
+    
+    Magics Team - ECMWF 2011
+    
+    Started: Thu 7-Apr-2011
+    
+    Changes:
+    
+*/
+
+
+
+#include "BinningObject.h"
+
+
+using namespace magics;
+
+
+
+BinningObject::BinningObject() 
+{
+
+	binners_x_["count"] = &BinningObject::countx;
+	binners_x_["list"] = &BinningObject::listx;
+	binners_x_["interval"] = &BinningObject::intervalx;
+
+	binners_y_["count"] = &BinningObject::county;
+	binners_y_["list"] = &BinningObject::listy;
+	binners_y_["interval"] = &BinningObject::intervaly;
+
+}
+
+
+BinningObject::~BinningObject() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void BinningObject::print(ostream& out)  const
+{
+	out << "BinningObject[";
+	BinningObjectAttributes::print(out);
+	out << "]";
+}
+
+void BinningObject::build(vector<double>& vals, IntervalMap<int>& binns)
+{
+	vector<double>::iterator from = vals.begin();
+	vector<double>::iterator to  = vals.begin();
+	++to;
+	int index = 0;
+	while ( to != vals.end() ) {
+		binns.insert(make_pair(Interval(*from, *to), index));
+		index++;
+		++to;
+		++from;
+	}
+}
+
+/*
+
+
+*/
+static double mindef = -1.0e+21;
+static double maxdef = 1.0e+21;
+
+void  BinningObject::countx(vector<double>& vals, double min, double max)
+{
+	double vmin = ( x_min_ == mindef) ? min : std::max(min, x_min_);
+	double vmax = ( x_max_ == maxdef) ? max : std::min(max, x_max_);
+
+	double step = (max-min)/x_count_;
+
+	int index = 0;
+	for (double val = vmin; val <= vmax; val+=step) {
+		vals.push_back(val);
+		index++;
+	}
+
+}
+
+void  BinningObject::county(vector<double>& vals, double min, double max)
+{
+	double vmin = ( y_min_ == mindef) ? min : std::max(min, y_min_);
+	double vmax = ( y_max_ == maxdef) ? max : std::min(max, y_max_);
+	double step = (max-min)/y_count_;
+
+	int index = 0;
+	for (double val = vmin; val <= vmax; val+=step) {
+		vals.push_back(val);
+		index++;
+	}
+}
+
+void  BinningObject::listx(vector<double>& vals, double min, double max)
+{
+	double vmin = ( y_min_ == mindef) ? min : std::max(min, y_min_);
+	double vmax = ( y_max_ == maxdef) ? max : std::min(max, y_max_);
+
+	for (vector<double>::iterator val = x_list_.begin(); val != x_list_.end(); ++val) {
+		if ( *val >=vmin && *val <=vmax )
+			vals.push_back(*val);
+	}
+
+
+}
+void  BinningObject::listy(vector<double>& vals, double min, double max)
+{
+	double vmin = ( y_min_ == mindef) ? min : std::max(min, y_min_);
+	double vmax = ( y_max_ == maxdef) ? max : std::min(max, y_max_);
+
+	for (vector<double>::iterator val = x_list_.begin(); val != x_list_.end(); ++val) {
+		if ( *val >=vmin && *val <=vmax )
+			vals.push_back(*val);
+	}
+
+}
+
+void  BinningObject::intervalx(vector<double>& vals, double min, double max)
+{
+	double vmin = ( x_min_ == mindef) ? min : std::max(min, x_min_);
+	double vmax = ( x_max_ == maxdef) ? max : std::min(max, x_max_);
+
+	for (double val = x_reference_; val <= vmax; val+= x_interval_)
+		vals.push_back(val);
+	for (double val = x_reference_ - x_interval_; val >= vmin; val -= x_interval_)
+		vals.push_back(val);
+
+	std::sort(vals.begin(), vals.end());
+
+}
+void  BinningObject::intervaly(vector<double>& vals, double min, double max)
+{
+	double vmin = ( y_min_ == mindef) ? min : std::max(min, y_min_);
+	double vmax = ( y_max_ == maxdef) ? max : std::min(max, y_max_);
+
+	for (double val = y_reference_; val <= vmax; val+= y_interval_)
+		vals.push_back(val);
+	for (double val = y_reference_ - y_interval_; val >= vmin; val -= y_interval_)
+		vals.push_back(val);
+
+	std::sort(vals.begin(), vals.end());
+}
+
diff --git a/src/decoders/BinningObject.h b/src/decoders/BinningObject.h
new file mode 100644
index 0000000..733cc3d
--- /dev/null
+++ b/src/decoders/BinningObject.h
@@ -0,0 +1,168 @@
+/*! \file BinningObject.h
+    \brief Definition of the Template class BinningObject.
+    
+    Magics Team - ECMWF 2011
+    
+    Started: Thu 7-Apr-2011
+    
+    Changes:
+    
+*/
+
+#ifndef BinningObject_H
+#define BinningObject_H
+
+#include "magics.h"
+#include "Matrix.h"
+#include "BinningObjectAttributes.h"
+#include "BasePointsHandler.h"
+#include "IntervalMap.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+namespace magics {
+
+  
+class BinningObject: public BinningObjectAttributes {
+
+public:
+	BinningObject();
+	~BinningObject();
+
+	virtual BinningObject* clone() const { return new BinningObject(); }
+
+	Matrix* operator()(PointsList& points)
+	{
+
+		Matrix* matrix = new Matrix();
+
+			double minx = points.minX();
+			double maxx = points.maxX();
+			double miny = points.minY();
+			double maxy = points.maxY();
+			double max = points.min();
+			double min = points.max();
+
+		IntervalMap<int> xbinns;
+		IntervalMap<int> ybinns;
+
+		map<string, binner>::iterator binner = binners_x_.find(x_);
+
+		if ( binner != binners_x_.end() ) {
+		   	 (this->*binner->second)(matrix->columnsAxis(), minx, maxx);
+		   	 if ( matrix->columnsAxis().empty() ) {
+		   		MagLog::warning() << " could not find any binns: return to count method" << endl;
+		   		countx(matrix->columnsAxis(), minx, maxx);
+		   	 }
+		}
+		else {
+			MagLog::warning() << " could not find the method " << x_ << " for binning: return to count method" << endl;
+			countx(matrix->columnsAxis(), minx, maxx);
+		}
+		build(matrix->columnsAxis(), xbinns);
+		binner = binners_y_.find(y_);
+
+		if ( binner != binners_y_.end() ) {
+			(this->*binner->second)(matrix->rowsAxis(), miny, maxy);
+			 if ( matrix->rowsAxis().empty() ) {
+				   		MagLog::warning() << " could not find any binns: return to count method" << endl;
+				   		county(matrix->columnsAxis(), minx, maxx);
+				   	 }
+		}
+		else {
+			MagLog::warning() << " could not find the method " << y_ << " for binning: return to count method" << endl;
+			county(matrix->rowsAxis(), miny, maxy);
+		}
+		build(matrix->rowsAxis(), ybinns);
+
+
+		matrix->setMapsAxis();
+//		double val = 0;
+		vector<double> total;
+
+		for ( int j = 0; j < matrix->columns(); j++)
+			for ( int i = 0; i <  matrix->rows(); i++) {
+				matrix->push_back(0);
+				total.push_back(0);
+			}
+
+		double columns = matrix->columns();
+		points.setToFirst();
+		while ( points.more() ) {
+			const UserPoint& point = points.current();
+			int x = xbinns.find(point.x_, -1);
+			int y = ybinns.find(point.y_, -1);
+			if ( x!= -1 && x!=-1) {
+				(*matrix)[ y * columns + x] = (*matrix)[ y * columns + x]+1;
+				total[ y * columns + x] = total[y * columns + x]+point.value();
+			}
+			points.advance();
+		}
+
+		if ( min != max ) {
+			for (unsigned int i = 0; i < matrix->size(); ++i) {
+
+				if ( (*matrix)[i] != 0 )
+					(*matrix)[i] = total[i]/(*matrix)[i];
+			}
+		}
+		return matrix;
+	}
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 void print(ostream&) const;
+	 typedef void (BinningObject::*binner)(vector<double>&, double, double);
+	 		 map<string,  binner> binners_x_;
+	 		 map<string,  binner> binners_y_;
+
+	 	void build(vector<double>& vals, IntervalMap<int>& binns);
+	 	 void countx(vector<double>&, double, double);
+	 	 void listx(vector<double>&, double, double);
+	 	 void intervalx(vector<double>&, double, double);
+
+	 	 void county(vector<double>&, double, double);
+	 	 void listy(vector<double>&, double, double);
+	 	 void intervaly(vector<double>&, double, double);
+private:
+    //! Copy constructor - No copy allowed
+	BinningObject(const BinningObject&);
+    //! Overloaded << operator to copy - No copy allowed
+	BinningObject& operator=(const BinningObject&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BinningObject& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class NoBinningObject: public BinningObject {
+
+public:
+	NoBinningObject() {}
+	~NoBinningObject() {}
+	BinningObject* clone() const { return new NoBinningObject(); }
+};
+
+
+template <>
+class MagTranslator<string, BinningObject> {
+public:
+	BinningObject* operator()(const string& val )
+	{
+		return SimpleObjectMaker<BinningObject>::create(val);
+	}
+
+	BinningObject* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+} // namespace magics
+#endif
diff --git a/src/decoders/BinningObjectAttributes.h b/src/decoders/BinningObjectAttributes.h
new file mode 100644
index 0000000..a249d0d
--- /dev/null
+++ b/src/decoders/BinningObjectAttributes.h
@@ -0,0 +1,94 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BinningObjectAttributes.h
+    \brief Definition of BinningObject Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef BinningObjectAttributes_H
+#define BinningObjectAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class BinningObjectAttributes 
+{
+public:
+//  --  constructor
+    BinningObjectAttributes();
+    
+//  --  destructor
+    virtual ~BinningObjectAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const BinningObjectAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string x_;
+	double x_min_;
+	double x_max_;
+	int x_count_;
+	floatarray x_list_;
+	double x_interval_;
+	double x_reference_;
+	string y_;
+	double y_min_;
+	double y_max_;
+	int y_count_;
+	floatarray y_list_;
+	double y_interval_;
+	double y_reference_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const BinningObjectAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/BoxPlotDecoder.cc b/src/decoders/BoxPlotDecoder.cc
new file mode 100644
index 0000000..bccb7f1
--- /dev/null
+++ b/src/decoders/BoxPlotDecoder.cc
@@ -0,0 +1,98 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotDecoder.h
+    \brief Implementation of the Template class BoxPlotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 29-Sep-2005
+    
+    Changes:
+
+*/
+
+
+
+#include "BoxPlotDecoder.h"
+
+using namespace magics;
+
+BoxPlotDecoder::BoxPlotDecoder() 
+{
+}
+
+
+BoxPlotDecoder::~BoxPlotDecoder() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void BoxPlotDecoder::print(ostream& out)  const
+{
+	out << "BoxPlotDecoder[";
+	BoxPlotDecoderAttributes::print(out);
+	out << "]";
+}
+
+void BoxPlotDecoder::customisedPoints(const std::set<string>& , CustomisedPointsList& out) 
+{
+	vector<int> sizes;
+
+	doublearray::const_iterator x = x_.begin();
+	sizes.push_back(x_.size());	
+	doublearray::const_iterator min = min_.begin();
+	sizes.push_back(min_.size());
+	doublearray::const_iterator max = max_.begin();
+	sizes.push_back(max_.size());
+	doublearray::const_iterator lower = lower_.begin();
+	sizes.push_back(lower_.size());
+	doublearray::const_iterator upper = upper_.begin();
+	sizes.push_back(upper_.size());
+	doublearray::const_iterator median = median_.begin();
+	sizes.push_back(median_.size());
+	
+
+	vector<int>::const_iterator size = std::min_element(sizes.begin(), sizes.end());
+
+	for (int i = 0; i != *size; i++)
+	{
+		CustomisedPoint* point = new CustomisedPoint();
+		point->longitude(*x);	
+	    (*point)["x"] = *x++;
+		(*point)["min"] = *min++;
+		(*point)["max"] = *max++;
+		(*point)["lower"] = *lower++;
+		(*point)["upper"] = *upper++;
+		(*point)["median"] = *median++;
+	  
+		out.push_back(point);
+	}
+}
+
+void BoxPlotDecoder::getReady(const Transformation& transformation)
+{
+	try {
+		for ( vector<string>::const_iterator x = date_x_.begin(); x != date_x_.end(); ++x )
+			x_.push_back(transformation.x(*x));
+		}
+	catch(...)
+	{}
+}
diff --git a/src/decoders/BoxPlotDecoder.h b/src/decoders/BoxPlotDecoder.h
new file mode 100644
index 0000000..53c5a9d
--- /dev/null
+++ b/src/decoders/BoxPlotDecoder.h
@@ -0,0 +1,82 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotDecoder.h
+    \brief Definition of the Template class BoxPlotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 29-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef BoxPlotDecoder_H
+#define BoxPlotDecoder_H
+
+#include "magics.h"
+
+#include "BoxPlotDecoderAttributes.h"
+#include "Data.h"
+#include "Decoder.h"
+#include "UserPoint.h"
+
+namespace magics {
+
+class BoxPlotDecoder: 
+		public BoxPlotDecoderAttributes, 
+		public Data,
+		public PointsList {
+
+public:
+	BoxPlotDecoder();
+	virtual ~BoxPlotDecoder();
+	
+	virtual void set(const map<string, string>& map) 
+		{  BoxPlotDecoderAttributes::set(map); }
+	
+	virtual void set(const XmlNode& node) 
+		{  BoxPlotDecoderAttributes::set(node); }
+
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+    {
+    	customisedPoints(n, out);
+    }
+    PointsHandler& points(const Transformation&, bool) { assert(false); }
+    void getReady(const Transformation&);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	BoxPlotDecoder(const BoxPlotDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	BoxPlotDecoder& operator=(const BoxPlotDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BoxPlotDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/ClassicMtgDecoder.cc b/src/decoders/ClassicMtgDecoder.cc
new file mode 100644
index 0000000..1fc2adc
--- /dev/null
+++ b/src/decoders/ClassicMtgDecoder.cc
@@ -0,0 +1,672 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ClassicMtgDecoder.cc
+    \brief Implementation of the Template class ClassicMtgDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#include "ClassicMtgDecoder.h"
+#include "TextVisitor.h"
+#include "MetaData.h"
+#include "CustomisedPoint.h"
+#include "DateTime.h"
+#include "spot_database.h"
+#include "Timer.h"
+
+#include "Factory.h"
+#include <locale>
+#include <limits>
+
+using namespace magics;
+
+namespace magics
+{
+
+class MtgTempe: public MetgramParameter
+{
+public:
+	MtgTempe() : MetgramParameter("temperature", "Temperature (°C)", "167.128")  
+	{
+	}
+	~MtgTempe() {}
+	const string& title() const {
+		return title_;
+	}
+	const string& xml() const {
+		return title_;
+	}	
+	virtual double operator()(double value) const { 
+		return value - 273.15;
+	}	
+	virtual spot_query_result* prepare(const ClassicMtgDecoder&, vector<CustomisedPoint*>&);
+
+protected :
+	
+   
+};
+
+class MtgMSL: public MetgramParameter
+{
+public:
+	MtgMSL() : MetgramParameter("msl", "MSL Pressure (hPa)", "151.128")  
+	{
+		
+	}
+	~MtgMSL() {}
+	const string& title() const {
+		return title_;		
+	}
+	
+	const string& xml() const {		
+		return title_;		
+	}	
+	
+	virtual double operator()(double value) const { 
+		return value/100;		
+	}	
+	
+	virtual spot_query_result* prepare(const ClassicMtgDecoder&, vector<CustomisedPoint*>&);
+
+protected :
+	
+   
+};
+
+class MtgHumidity: public MetgramParameter
+{
+public:
+	MtgHumidity() : MetgramParameter("humidity", "850 hPa Relative Humidity (%)", "157.128")  
+	{
+		
+	}
+	~MtgHumidity() {}
+	const string& title() const { return title_; }
+	const string& xml() const   { return title_; }	
+	virtual double operator()(double value) const { 
+		if (value < 0.05 ) return 0;
+		if ( value > 100 ) return 100;
+		return value; 
+	}	
+	virtual spot_query_result* prepare(const ClassicMtgDecoder&, vector<CustomisedPoint*>&);
+
+protected :
+	
+   
+};
+
+class MtgCloudCover: public MetgramParameter
+{
+public:
+	MtgCloudCover() : MetgramParameter("cloud_cover", "Cloud Amount (%)", "164.128")  
+	{
+		
+	}
+	~MtgCloudCover() {}
+	const string& title() const { return title_; }
+	const string& xml() const   { return title_; }	
+	virtual double operator()(double value) const { 
+	
+		value *= 100;
+		if (value < 0.1 ) return 0;
+		if ( value > 100 ) return 100;
+		return value; 
+	}	
+	virtual spot_query_result* prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+	{
+		spot_query* query = decoder.newQuery();
+		
+		spot_set_parameter(query,"param", "164.128"); 
+		spot_query_result* result = spot_handle_query(query);
+		interpretResult(result,out, "curve1");
+		
+		spot_delete_query(query);		
+		return result; 
+	}
+
+protected :
+	
+   
+};
+
+
+class MtgPrecipitation: public MetgramParameter
+{
+public:
+	MtgPrecipitation() : MetgramParameter("precipitation", "Precipitation (mm/3h to 144 hours then mm/6h)", "143.128")  
+	{
+		
+	}
+	~MtgPrecipitation() {}
+	const string& title() const { return title_; }
+	const string& xml() const   { return title_; }	
+	virtual double operator()(double value) const { 
+		value *= 1000;
+		if (value < 0.05 ) return 0;
+		return value; 
+	}	
+	virtual spot_query_result* prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+	{
+		spot_query* query = decoder.newQuery();
+		
+		spot_set_parameter(query,"param", "143.128"); 
+		spot_query_result* result = spot_handle_query(query);
+		interpretResult(result,out, "curve1");
+		
+		spot_delete_query(query);		
+		if (maxy_ < 3 ) maxy_ = 3;
+		else if (maxy_ < 5 ) maxy_ = 5;
+		else if (maxy_ < 10 ) maxy_ = 10;
+		else if (maxy_ < 30 ) maxy_ = 30;
+		else if (maxy_ < 50 ) maxy_ = 50;
+		else if (maxy_ < 100 ) maxy_ = 100;
+		return result; 
+	}
+
+protected :
+	
+   
+};
+
+class Mtg10mWind: public MetgramParameter
+{
+public:
+	Mtg10mWind() : MetgramParameter("10m_wind", "10m Wind (kt) ", "143.128")  
+	{
+		
+	}
+	~Mtg10mWind() {}
+	const string& title() const { return title_; }
+	const string& xml() const   { return title_; }	
+	virtual double operator()(double value) const { 
+		return value; 
+	}	
+	virtual spot_query_result* prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+	{
+		spot_query* query = decoder.newQuery();
+		
+		spot_set_parameter(query,"param", "165.128"); 
+		spot_query_result* result = spot_handle_query(query);
+		interpretResult(result,out, "curve1");
+		
+		spot_delete_query(query);		
+		query = decoder.newQuery();
+		spot_set_parameter(query,"param", "166.128"); 
+		result = spot_handle_query(query);
+	
+		interpretResult(result, out, "curve2");
+		spot_delete_query(query);
+	
+			return result; 
+	}
+
+protected :
+	
+   
+};
+
+SimpleObjectMaker<MtgTempe, MetgramParameter> mt("temperature");
+SimpleObjectMaker<MtgMSL, MetgramParameter> msl("msl");
+SimpleObjectMaker<MtgHumidity, MetgramParameter> humidity("humidity");
+SimpleObjectMaker<MtgCloudCover, MetgramParameter> cloud_cover("cloud_cover");
+SimpleObjectMaker<MtgPrecipitation, MetgramParameter> precipitation("precipitation");
+SimpleObjectMaker<Mtg10mWind, MetgramParameter> tenmwind("10m_wind");
+
+
+static string get_spot(spot_query_result* result, const char* param)
+{
+	char tmp[1024];
+	size_t len = 1024;
+	
+	spot_get_parameter(result,param,tmp, &len); 
+	
+	return string(tmp, len-1);
+}
+
+
+void MetgramParameter::interpretResult(spot_query_result* result, vector<CustomisedPoint*>& out, const string& key)
+{
+	Timer timer("access spot","");
+	size_t len = 1024;
+	char tmp[1024];
+	double missing = INT_MAX;
+	
+	string date = get_spot(result,"date");
+	string time = get_spot(result,"time");
+	map<string, int> columns;
+	map<int, int> rows;
+	
+	vector<double> xpos;
+	vector<double> ypos;
+	
+	
+	// Get the columns names;
+	for(int i = 0 ; i < spot_get_column_count(result); i++){
+    	spot_get_column_name(result, i,tmp,&len);
+    	columns[tmp] = i;
+    	len = 1024;
+	}
+	
+	double values[1024];
+	size_t nb = 1024;
+	// get the rows names
+	for(int i = 0 ; i < spot_get_row_count(result); i++){
+    	spot_get_row_name(result, i,tmp,&len);   	
+    	int x = atoi(tmp);
+    	rows[x] = i;
+    	len = 1024;    	
+	}	
+	bool rain = false;
+	
+	base_ = DateTime(date, MagTime(time));
+
+	DateTime next;
+
+	for (map<int, int>::const_iterator step = rows.begin(); step != rows.end(); ++step) {
+		
+		
+		
+		
+		next = base_ +  Second(step->first * 3600);    
+		vector<CustomisedPoint*>::iterator p;
+		for (p = out.begin(); p != out.end(); ++p) {
+			if ( (**p)["year"] != next.date().year() ) continue;
+			if ( (**p)["month"] !=  next.date().month() ) continue;
+			if ( (**p)["day"] != next.date().day() ) continue;
+			if ( (**p)["hours"] != next.time().hours()) continue;
+			if ( (**p)["minutes"] != next.time().minutes()) continue;
+			if ( (**p)["seconds"] != next.time().seconds()) continue;
+			break;
+		}
+		
+		CustomisedPoint* point;
+		
+		if (  p != out.end() ) {
+			point = *p;
+		}
+		else {
+			point = new CustomisedPoint();
+			out.push_back(point);
+			point->longitude(step->first);
+			xpos.push_back(step->first);
+	
+	
+		
+			(*point)["year"]    = next.date().year();
+			(*point)["month"]    = next.date().month();
+			(*point)["day"]    = next.date().day();
+			(*point)["hours"]   = next.time().hours();
+			(*point)["minutes"] = next.time().minutes();
+			(*point)["seconds"] = next.time().seconds();
+			//(*point)["shift"] = (*parameter_)(step->first);
+			(*point)["shift"] = 0;
+		}	
+		
+		      	
+		
+		
+		
+		spot_get_row(result, step->second,values,&nb);
+		bool ok = true;
+		for (map<string, int>::const_iterator info = columns.begin(); info != columns.end(); ++info) {
+			// dirty to recognize rain!
+			if ( values[info->second] > missing ) {
+				(*point)["as_rain"] = 1;
+				values[info->second] = 0;
+				rain = true;
+			}
+	    	if ( !isnan(values[info->second]) && values[info->second] < missing ) {
+	    		(*point)[key] = (*this)(values[info->second]);	  
+	    		ypos.push_back( (*this)(values[info->second]));	 
+	    		if (rain) (*point)["as_rain"] = 1;
+	    		MagLog::dev() << " SPOTBASE returns " << info->first << " for " <<(*this)(values[info->second]) << " at " << step->first <<  endl;
+		
+	    	}
+	    	else {
+	    		MagLog::warning() << " SPOTBASE returns nan for " << info->first << " : data ignored for step " << (*point)["shift"]<< endl;
+	    		ok = false;
+	    	}
+	    	
+	    	
+		}
+    	
+		nb=1024;
+	
+	}
+	
+	
+	if ( !xpos.empty() ) { 
+		minx_ = std::min(minx_, *std::min_element(xpos.begin(), xpos.end()));
+		maxx_ = std::max(maxx_, *std::max_element(xpos.begin(), xpos.end()));
+	
+		MagLog::debug() << "MIN=" << minx_ << "MAX=" << maxx_ << endl;
+	}
+    miny_ = std::min(miny_, *std::min_element(ypos.begin(), ypos.end()));
+	maxy_ = std::max(maxy_, *std::max_element(ypos.begin(), ypos.end()));
+	
+	MagLog::debug() << "MIN=" << miny_ << "MAX=" << maxy_ << endl;
+}
+
+
+void MetgramParameter::setTransformation(Transformation& transformation)
+{
+	transformation.setDataMinX(minx_*3600, base_);
+	transformation.setDataMaxX(maxx_*3600, base_);
+
+	double maxy =  (maxy_ == miny_ )  ? maxy_ + 1 : maxy_;
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy);
+}
+
+spot_query_result* MtgTempe::prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+{
+	spot_query* query = decoder.newQuery();
+	
+	spot_set_parameter(query,"param", "167.128"); 
+	spot_query_result* result;
+	{
+	Timer timer("Spot Handle","");
+	result = spot_handle_query(query);
+	}
+	interpretResult(result,out, "curve1");
+	spot_delete_result(result);
+	spot_delete_query(query);
+	
+	query = decoder.newQuery();
+	spot_set_parameter(query,"param", "130.128"); 
+	{
+	Timer timer("Spot Handle","");
+	result = spot_handle_query(query);
+	}
+	
+	interpretResult(result, out, "curve2");
+	spot_delete_query(query);
+	out.front()->insert(make_pair("temperature", 1));
+	return result; 
+	
+}
+
+spot_query_result* MetgramParameter::prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+{
+	spot_query* query = decoder.newQuery();
+	
+	spot_set_parameter(query,"param", code_.c_str()); 
+	spot_query_result* result;
+	{
+	Timer timer("Spot Handle","");
+	result = spot_handle_query(query);
+	}
+
+	spot_delete_query(query);
+
+	return result; 
+}
+
+spot_query_result* MtgMSL::prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+{
+	spot_query* query = decoder.newQuery();
+	
+	spot_set_parameter(query,"param", "151.128"); 
+	spot_query_result* result;
+	{
+	Timer timer("Spot Handle","");
+	result = spot_handle_query(query);
+	}
+	interpretResult(result,out, "curve1");
+
+	spot_delete_query(query);
+
+	return result;
+}
+
+spot_query_result* MtgHumidity::prepare(const ClassicMtgDecoder& decoder, vector<CustomisedPoint*>& out)
+{
+	spot_query* query = decoder.newQuery();
+	
+	spot_set_parameter(query,"param", "157.128"); 
+	spot_query_result* result;
+	{
+	Timer timer("Spot Handle","");
+	result = spot_handle_query(query);
+	}
+	interpretResult(result,out, "curve1");
+	
+	spot_delete_query(query);
+	
+	return result; 	
+}
+
+ClassicMtgDecoder::ClassicMtgDecoder() :spot_(0) 
+{
+}
+
+
+ClassicMtgDecoder::~ClassicMtgDecoder() 
+{
+	
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ClassicMtgDecoder::print(ostream& out)  const
+{
+	out << "ClassicMtgDecoder[";
+	ClassicMtgDecoderAttributes::print(out);
+	out << "]";
+}
+
+template <class T>
+inline void read(const string& str, T& i) 
+{
+	
+	std::stringstream ss(str);
+	ss >> i;
+
+}
+
+
+}
+
+void ClassicMtgDecoder::visit(TextVisitor& title)
+{
+	decode();
+	moreTitle(title);
+	if (parameter_) 
+		title.add(new TextEntry(parameter_->title()));
+	
+}
+/*
+void ClassicMtgDecoder::visit(MetaData&)
+{
+	
+	
+	
+	
+}
+*/
+
+void ClassicMtgDecoder::moreTitle(TextVisitor&) const 
+{
+}
+
+spot_query* ClassicMtgDecoder::newQuery() const
+{
+Timer time("openSpot","");
+	if (! spot_) {
+		spot_ = spot_open_database(database_.c_str());	
+	}
+	if ( !spot_ )
+	{
+		MagLog::error() << database_ << ": Not a valid Epsgram Database\n";
+		throw MagicsException(database_ +": Not a valid Epsgram Database");
+	}
+
+	spot_query*  query  =  spot_new_query(spot_);
+	spot_set_location (query, latitude_, longitude_);
+
+	spot_set_method(query,"EPSGRAM");
+ 
+	if (!date_.empty() ) {
+		MagLog::debug() << "Set the date --->" << date_ << "\n";
+		spot_set_parameter(query,"date", date_.c_str());
+	}
+   
+	if (!time_.empty() ) {
+		MagLog::debug() << "Set the date --->" << time_ << "\n";
+		spot_set_parameter(query,"time", time_.c_str());
+	}
+
+	return query;
+}
+
+
+void ClassicMtgDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& out) 
+{
+	decode();
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+		out.push_back(*point);
+}
+
+
+void ClassicMtgDecoder::decode() 
+{
+	if ( !points_.empty() ) return; 
+
+#ifdef MAGICS_EXCEPTION            
+	try {
+		parameter_ = SimpleFactory<MetgramParameter>::create(param_);        
+	}
+	catch (NoFactoryException& e)
+	{
+		// The data do not know how to verify the criter ....
+		MagLog::warning() << "Eps Data access: parameter [" << param_ << "] unknown\n";   
+		parameter_ = new MetgramParameter(param_, param_title_, param_);
+	} 
+#else
+	parameter_ = SimpleFactory<MetgramParameter>::create(param_);
+	if ( !parameter_ )
+	{
+		// The data do not know how to verify the criter ....
+		MagLog::warning() << "Eps Data access: parameter [" << param_ << "] unknown\n";
+		parameter_ = new MetgramParameter(param_, param_title_, param_);
+	}
+#endif   
+	parameter_->scaling(param_scaling_);
+	parameter_->offset(param_offset_);
+	spot_query_result *result;
+	{
+		Timer timer("prepare param","");
+	    result = parameter_->prepare(*this, points_);
+	}
+	if ( !result )
+	{
+		MagLog::error() << " No EpsData\n";
+		return;
+	}
+	Timer ("prepare meta data","");
+	double lat, lon;
+
+	spot_get_location(result, &lat, &lon);
+	
+	spot_get_index_value(result, "orog", &detz_);
+	spot_get_index_value(result, "mask", &mask_);
+
+	if ( lon > 180 ) lon -= 360.;
+
+	grid_ = UserPoint(lon, lat);
+
+	map<string, int> columns;
+	map<int, int> rows;
+	
+
+	long resol; 
+	
+	read(get_spot(result,"numberOfPointsAlongAMeridian"), resol);
+	ostringstream rs, dets;
+	
+	rs << "T" << resol-1;
+	dets << "T" << (2*resol)-1;
+	resolution_ = rs.str();
+
+	date_ = get_spot(result,"date");
+	time_ = get_spot(result,"time");
+
+	spot_delete_result(result);
+
+	spot_close_database(spot_);
+	//delete spot_;
+	spot_ = 0;
+}
+
+void ClassicMtgDecoder::moreTitle(TextVisitor& title)
+{
+	if ( !long_title_ ) return;
+	
+	DateTime base(date_, MagTime(time_));
+	ostringstream out;
+	tm convert = base;
+	locale loc("");        
+    
+	out.imbue(loc);   
+	const std::time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+	string format = "%A %e %B %Y %H UTC";
+	tfac.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length()); 
+	vector<string> lines;
+	
+	string height = "";
+	if (height_ < INT_MAX  ) {
+		ostringstream sh;
+		sh << " (" << height_ << "m) ";
+		height = sh.str();
+	}
+	else {
+		height = " ";
+	}
+	
+	lines.push_back(station_ + " " + grid_.asLatitude() + " " + grid_.asLongitude() + " " + tostring(maground(detz_)) + " m");
+	lines.push_back("ECMWF Forecast from " + out.str());
+	
+	string landsea = (mask_>= 0.5) ? "Nearest land grid point" : "Nearest sea grid point";
+	
+	lines.push_back(landsea + " (" + resolution_ + ")" );
+	
+	
+	
+	lines.push_back("");
+	
+	for ( vector<string>::const_iterator line = lines.begin(); line != lines.end(); ++line)
+	 	title.add(new TextEntry(*line));
+}
+
+void ClassicMtgDecoder::visit(Transformation& transformation)
+{
+	decode();
+	
+	assert(parameter_);
+	parameter_->setTransformation(transformation);
+
+	
+}
+
diff --git a/src/decoders/ClassicMtgDecoder.h b/src/decoders/ClassicMtgDecoder.h
new file mode 100644
index 0000000..6aa322f
--- /dev/null
+++ b/src/decoders/ClassicMtgDecoder.h
@@ -0,0 +1,161 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ClassicMtgDecoder.h
+    \brief Definition of the Template class ClassicMtgDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ClassicMtgDecoder_H
+#define ClassicMtgDecoder_H
+
+#include "magics.h"
+
+#include "ClassicMtgDecoderAttributes.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+
+#include "DateTime.h"
+#include <limits>
+
+class  spot_query;
+class spot_config;
+class spot_query_result;
+
+
+namespace magics {
+
+class XmlNode;
+class ClassicMtgDecoder;
+
+class MetgramParameter
+{
+public:
+	MetgramParameter() : scaling_(1), offset_(0) { 
+		minx_ = std::numeric_limits<double>::max();
+		maxx_ = -minx_;
+		miny_ = std::numeric_limits<double>::max();
+		maxy_ = -miny_;
+	}
+	MetgramParameter(const string& name, const string& title, const string& code) :
+		name_(name), code_(code),  title_(title), scaling_(1), offset_(0) { 
+		minx_ = std::numeric_limits<double>::max();
+		maxx_ = -minx_;
+		miny_ = std::numeric_limits<double>::max();
+		maxy_ = -miny_;
+	}
+	virtual ~MetgramParameter() {}
+	virtual double operator()(double value, const string&) const 
+		{ return (value * scaling_) + offset_ ; } 
+	virtual double operator()(double value) const 
+		{ return (value * scaling_) + offset_ ; } 
+	const string& code() const  { return code_; }
+	virtual const string& title() const { return title_; }
+	virtual spot_query_result* prepare(const ClassicMtgDecoder&, vector<CustomisedPoint*>&);
+	virtual void interpretResult(spot_query_result*, vector<CustomisedPoint*>&, const string&);
+    virtual void setTransformation(Transformation&);
+    void scaling(double scaling) { scaling_ = scaling; }
+    void offset(double offset)   { offset_ = offset; }
+    
+protected:
+	string name_;
+	string code_;
+	mutable string title_;
+	mutable string xml_;
+	double epsz_;
+	double detz_;
+	mutable double step_;
+	double correction_;
+	string detResolution_;
+	string epsResolution_;
+	double height_;
+	double scaling_;
+	double offset_;
+	double minx_; 
+	double miny_;
+	double maxx_; 
+	double maxy_;
+    DateTime base_;
+
+};
+
+class ClassicMtgDecoder: 
+			public ClassicMtgDecoderAttributes, 
+			public Decoder,
+			public Data,
+			public PointsList  {
+
+public:
+	ClassicMtgDecoder();
+	virtual ~ClassicMtgDecoder();
+	
+	virtual void set(const map<string, string>& map) 
+		{  ClassicMtgDecoderAttributes::set(map); }
+	virtual void set(const XmlNode& node) 
+		{  ClassicMtgDecoderAttributes::set(node); }
+		
+	void decode();
+	
+	spot_query* newQuery() const;
+	
+	
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	void customisedPoints(const Transformation&, const std::set<string>& n, CustomisedPointsList& out, bool)
+	{ customisedPoints(n, out); }
+	PointsHandler& points(const Transformation&, bool) { assert(false); }
+	void visit(TextVisitor&);
+	void moreTitle(TextVisitor&);
+	void visit(Transformation&);
+
+	//void visit(MetaData&);
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 MetgramParameter* parameter_;
+	 void moreTitle(TextVisitor&) const;
+	 UserPoint grid_;
+	 double   mask_;
+	 double   detz_;
+	 double   epsz_;
+	 string   resolution_;
+	 mutable spot_config* spot_;
+	 vector<CustomisedPoint*> points_;
+
+private:
+    //! Copy constructor - No copy allowed
+	ClassicMtgDecoder(const ClassicMtgDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	ClassicMtgDecoder& operator=(const ClassicMtgDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ClassicMtgDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/Date.cc b/src/decoders/Date.cc
new file mode 100644
index 0000000..ad8e368
--- /dev/null
+++ b/src/decoders/Date.cc
@@ -0,0 +1,325 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+#include "MagException.h"
+#include "DateTime.h"
+#include "Tokenizer.h"
+
+#include <time.h>
+#include <iomanip>
+
+using namespace magics;
+
+static const char* months[] = 
+{ "jan","feb","mar","apr","may","jun",
+  "jul","aug","sep","oct","nov","dec"
+};
+
+static void check(const MagDate& date,long value)
+{
+	if(value <= 999999 ) value += 19000000;
+
+	if(value != date.yyyymmdd())
+	{
+		ostringstream  os;
+		os << "Invalid date " << value << " becomes " << date << ends;
+		throw MagicsException(os.str());
+	}
+}
+
+
+MagDate::MagDate(long date) : julian_(dateToJulian(date))
+{
+	if(date) check(*this,date);
+}
+
+MagDate::MagDate(long year,long month,long day) : julian_(dateToJulian(year*10000 + month*100 +day))
+{
+	check(*this,year*10000 + month*100 +day);
+}
+
+// Warning, unchecked...
+MagDate::MagDate(long year,long dayOfYear)
+{
+	julian_ = dateToJulian(year*10000 + 101); // 1 of jan
+	julian_ += (dayOfYear - 1);
+	ASSERT(this->year() == year);
+}
+
+long MagDate::parse(const string& s)
+{
+	Tokenizer parse("-");
+	vector<string> result;
+
+	parse(s,result);
+
+	bool err   = false;
+	long value = 0;
+	int i;
+
+	switch(result.size())
+	{
+		case 1:
+			switch(s.length())
+			{
+				case 3:
+					// For climatology
+					err = true;
+					for(i = 0; i < 12; i++)
+						if(s == months[i])
+						{
+							value = 1900 * 10000 + (i+1)*100 + 1;
+							err   = false;
+							break;
+						}
+					break;
+
+				case 6:
+				case 8:
+					value   = atol(s.c_str());
+					break;
+
+				default:
+					err = true;
+					break;
+			}
+			break;
+
+		// MagDates as yyyy-ddd
+
+		case 2:
+
+			if(result[0].length() != 2 && result[0].length() != 4) err = true;
+			if(result[1].length() != 3) err = true;
+
+			{
+				long year = atol(result[0].c_str());
+				long day  = atol(result[1].c_str());
+
+				MagDate date(year,1,1);
+				date += day - 1;
+				value = date.yyyymmdd();
+			}
+
+			break;
+
+		// MagDates as yyyy-mm-dd
+
+		case 3:
+
+			if(result[0].length() != 2 && result[0].length() != 4) err = true;
+			if(result[1].length() > 3) err = true;
+			if(result[2].length() > 3) err = true;
+
+			value = atol(result[0].c_str()) * 10000 +
+					atol(result[1].c_str()) * 100 +
+					atol(result[2].c_str());
+
+			break;
+
+
+		default:
+			err = true;
+			break;
+	}
+
+	if(err) 
+		throw MagicsException(string("Invalid date ") + s);
+
+	// Come back here....
+	// temp patch for monthly means
+	if( (value%100) == 0) value++;
+
+	return value;
+}
+
+MagDate::MagDate(const string& s)
+{
+	long value = parse(s);
+	julian_    = dateToJulian(value);
+	check(*this,value);
+}
+
+MagDate::operator string() const
+{
+	ostringstream os;
+	os << *this << ends;
+	return os.str();
+}
+
+MagDate::operator tm() const
+{
+	struct tm tm_date = { 0, 0, 0, 0, 0, 0, 0, 0 };
+	tm_date.tm_mday = day();
+	tm_date.tm_mon = month() - 1;
+	tm_date.tm_year = year() - 1900;
+    
+	int mm = month();
+	int yy = year();
+	if (mm < 3)
+	{
+		mm += 12;
+		--yy;
+	}
+
+	tm_date.tm_wday  = (day() + (13 * mm - 27)/5 + yy + yy/4 - yy/100 + yy/400) % 7;
+	return tm_date;
+}
+
+// Returns a date in the format yyyymmdd from a julian number
+
+long MagDate::julianToMagDate(long jdate)
+{
+	long x,y,d,m,e;
+	long day,month,year;
+
+	x = 4 * jdate - 6884477;
+	y = (x / 146097) * 100;
+	e = x % 146097;
+	d = e / 4;
+
+	x = 4 * d + 3;
+	y = (x / 1461) + y;
+	e = x % 1461;
+	d = e / 4 + 1;
+
+	x = 5 * d - 3;
+	m = x / 153 + 1;
+	e = x % 153;
+	d = e / 5 + 1;
+
+	if( m < 11 )
+		month = m + 2;
+	else
+		month = m - 10;
+
+	day = d;
+	year = y + m / 11;
+
+	return year * 10000 + month * 100 + day;
+}
+
+long MagDate::today(void)
+{
+	time_t now;
+	time(&now);
+
+#ifdef _THREAD_SAFE
+	struct tm t;
+	gmtime_r(&now,&t);
+	long td = (1900 + t.tm_year) * 10000 + (t.tm_mon+1)* 100 + t.tm_mday;
+#else
+	struct tm *t;
+	t = gmtime(&now);
+	long td = (1900 + t->tm_year) * 10000 + (t->tm_mon+1)* 100 + t->tm_mday;
+#endif
+	return dateToJulian(td);
+}
+
+/*!
+ Returns a julian number from a yyyymmdd date
+*/
+long MagDate::dateToJulian(long ddate)
+{
+	long  m1,y1,a,b,c,d,j1;
+
+	long month,day,year;
+
+	year = ddate / 10000;
+	ddate %= 10000;
+	month  = ddate / 100;
+	ddate %= 100;
+	day = ddate;
+
+	// Negative dates are relative to today
+	if(ddate <= 0)
+		return today() + ddate;
+
+	if(year < 100)
+	{
+//		throw SeriousBug("Please, use 4 digits dates... 2000 is near");
+//      MagLog::warning() << "Please, use 4 digits dates... 2000 is near" << "\n";
+		year = year + 1900;
+	}
+
+	if(month > 2)
+	{
+		m1 = month - 3;
+		y1 = year;
+	}
+	else
+	{
+		m1 = month + 9;
+		y1 = year - 1;
+	}
+	a = 146097*(y1/100)/4;
+	d = y1 % 100;
+	b = 1461*d/4;
+	c = (153*m1+2)/5+day+1721119;
+	j1 = a+b+c;
+
+	return(j1);
+}
+
+
+void MagDate::print(ostream& s) const
+{
+	long ddate = julianToMagDate(julian_);
+	long month,day,year;
+
+	year = ddate / 10000;
+	ddate %= 10000;
+	month  = ddate / 100;
+	ddate %= 100;
+	day = ddate;
+
+	char oldfill = s.fill();
+	s << year << '-' << std::setw(2) << std::setfill('0') << month 
+		<< '-' << std::setw(2) << std::setfill('0') << day << std::setfill(oldfill);
+}
+
+long MagDate::year() const
+{
+	long ddate = julianToMagDate(julian_);
+	return ddate / 10000;
+}
+
+long MagDate::month() const
+{
+	long ddate = julianToMagDate(julian_);
+	ddate %= 10000;
+	return ddate / 100;
+}
+
+long MagDate::day() const
+{
+	long ddate = julianToMagDate(julian_);
+	return ddate % 100;
+}
+
+long MagDate::yyyymmdd() const
+{
+	return julianToMagDate(julian_);
+}
+
+string MagDate::monthName(long n)
+{
+	ASSERT(n >= 1 && n <= 12);
+	return months[n-1];
+}
diff --git a/src/decoders/DateGribLoopStepAttributes.h b/src/decoders/DateGribLoopStepAttributes.h
new file mode 100644
index 0000000..bae034b
--- /dev/null
+++ b/src/decoders/DateGribLoopStepAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file DateGribLoopStepAttributes.h
+    \brief Definition of DateGribLoopStep Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef DateGribLoopStepAttributes_H
+#define DateGribLoopStepAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "GribAddressMode.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class DateGribLoopStepAttributes 
+{
+public:
+//  --  constructor
+    DateGribLoopStepAttributes();
+    
+//  --  destructor
+    virtual ~DateGribLoopStepAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const DateGribLoopStepAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double span_;
+	auto_ptr<GribAddressMode> address_mode_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const DateGribLoopStepAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/DateTime.cc b/src/decoders/DateTime.cc
new file mode 100644
index 0000000..15e7e8c
--- /dev/null
+++ b/src/decoders/DateTime.cc
@@ -0,0 +1,185 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+#include "DateTime.h"
+
+#include "Tokenizer.h"
+
+#include "MagException.h"
+#include "MagLog.h"
+using namespace magics;
+
+DateTime::DateTime(const MagDate& d, const MagTime& t):
+	date_(d), time_(t)
+{
+}
+
+DateTime::DateTime(const string& s)
+{
+	if ( s.empty() || s == "undef" ) {
+		return;
+	}
+	Tokenizer parse(" ");
+	vector<string> result;
+
+	parse(s,result);
+	
+	if ( result.size() == 1 ) {
+		date_ = MagDate(result[0]);
+	    time_ = MagTime("00:00:00");
+		return;
+	}
+	
+	if ( result.size() == 2 ) {
+		date_ = MagDate(result[0]);
+	    time_ = MagTime(result[1]);
+		return;
+	}
+	MagLog::error() << "Check date format:" << s << "\n";
+	
+}
+
+
+DateTime::DateTime(time_t thetime)
+{
+#ifdef _THREAD_SAFE
+	struct tm t;
+	gmtime_r(&thetime,&t);
+	long td   = (1900 + t.tm_year) * 10000 + (t.tm_mon+1)* 100 + t.tm_mday;
+	long hour = t.tm_hour;
+	long min  = t.tm_min;
+	long sec  = t.tm_sec;
+#else
+	struct tm *t;
+	t = gmtime(&thetime);
+	long td   = (1900 + t->tm_year) * 10000 + (t->tm_mon+1)* 100 + t->tm_mday;
+	long hour = t->tm_hour;
+	long min  = t->tm_min;
+	long sec  = t->tm_sec;
+#endif
+
+	date_ = MagDate(td);
+	time_ = MagTime(hour,min,sec);
+}
+
+void DateTime::print(ostream& s) const
+{
+	s << date_ << ' ' << time_;
+}
+
+DateTime::operator string() const
+{
+	ostringstream os;
+	os << *this;
+	return os.str();
+}
+
+DateTime& DateTime::operator=(const DateTime& other)
+{
+	date_ = other.date_;
+	time_ = other.time_;
+	return *this;
+}
+
+Second DateTime::operator-(const DateTime& other) const
+{
+	Second date = (date_ - other.date_) * 24 * 3600;
+	Second time = time_ - other.time_;
+
+	return date + time;
+}
+
+DateTime DateTime::operator+(const Second& s) const
+{
+	MagDate d = date();
+	long t = time();
+	d += long(s) / (24 * 3600);
+	t += long(s) % (24 * 3600); 
+	if ( t < 0 ) {
+		d -= 1;
+		while (t <= (-3600 * 24) ) {
+			d -= 1;
+			t += 3600 * 24;
+		}
+	    t += 3600 * 24;
+	}
+	while (t >= 3600 * 24)
+	{
+		d += 1;
+		t -= 3600 * 24;
+	}
+	
+	return DateTime(d,Second(t));
+}
+
+DateTime DateTime::round(const Second& rnd) const
+{
+	long long seconds = double(date_.julian_) * 24.0 * 3600 + Second(time_);
+	seconds = (seconds / long(rnd)) * rnd;
+	
+	long	d = seconds / (3600 * 24);
+	Second	t = seconds % (3600 * 24);
+
+	return DateTime(MagDate(d,true),MagTime(t));
+}
+
+DateTime::operator tm() const
+{
+	struct tm tm_date = tm(date_);
+    tm_date.tm_sec = time_.seconds();
+	tm_date.tm_min = time_.minutes();
+	tm_date.tm_hour = time_.hours();
+	return tm_date;
+}
+
+DateTime::operator double() const
+{
+	return double(date_.julian_) * 24.0 * 3600 + Second(time_);
+}
+
+
+#include <locale>
+using namespace std;
+static std::locale& getLocale()
+{
+static locale loc= locale::classic();
+    try {
+        loc = locale("");
+    }
+    catch (...)
+    {
+        MagLog::info() << "Problem to setup the locale\n"
+                       << "Check your LANG variable - current value: " <<  getEnvVariable("LANG")<< endl;
+        loc= locale::classic();
+    }
+    return loc;
+}
+
+string DateTime::tostring(const string& format) const
+{
+        ostringstream out;
+        tm convert = *this;
+        out.imbue(getLocale());
+        const std::time_put<char>& tfac = use_facet<time_put<char> >(getLocale());
+
+        tfac.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length());
+
+        return out.str();
+}
+
diff --git a/src/decoders/DateTime.h b/src/decoders/DateTime.h
new file mode 100644
index 0000000..bc09075
--- /dev/null
+++ b/src/decoders/DateTime.h
@@ -0,0 +1,359 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+// Baudouin Raoult - ECMWF Sep 96
+
+#ifndef DateTime_H
+#define DateTime_H
+
+#include "magics.h"
+
+#include <time.h>
+
+
+namespace magics {
+typedef long Second;
+
+class MagDate {
+public:
+
+// -- Contructors
+
+	MagDate() : julian_(0) { }
+	MagDate(long);
+	MagDate(long,long,long);
+	MagDate(const string&);
+	MagDate(long,long);
+
+    
+
+	MagDate(const MagDate& other):
+		julian_(other.julian_) {}
+
+	MagDate& operator=(const MagDate& other)
+		{ julian_ = other.julian_; return *this; }
+
+// -- Destructor
+
+	~MagDate() {}
+
+// -- Convertors
+	
+	operator string() const;
+    operator tm() const;
+
+// -- Operators
+
+	bool operator==(const MagDate& other) const
+		{ return julian_ == other.julian_ ;}
+
+	bool operator!=(const MagDate& other) const
+		{ return julian_ != other.julian_ ;}
+
+	bool operator<(const MagDate& other)  const
+		{ return julian_ <  other.julian_ ;}
+
+	bool operator>(const MagDate& other)  const
+		{ return julian_ >  other.julian_ ;}
+
+	bool operator<=(const MagDate& other)  const
+		{ return julian_ <=  other.julian_ ;}
+
+	bool operator>=(const MagDate& other)  const
+		{ return julian_ >=  other.julian_ ;}
+
+
+	MagDate& operator++() { julian_++; return *this; }
+	MagDate& operator--() { julian_--; return *this; }
+
+	MagDate& operator+=(long d) { julian_ += d; return *this; }
+	MagDate& operator-=(long d) { julian_ -= d; return *this; }
+
+// -- Methods
+
+	long year() const;
+	long month() const;
+	long day() const;
+	long yyyymmdd() const;
+
+	long julian() const { return julian_;                  }
+	MagDate round(int n)   { return MagDate((julian_/n)*n,true); }
+	string monthName(long n);
+    
+
+// -- Class methods
+
+	static long         parse(const string&);
+
+// -- Friends
+
+	friend ostream& operator<< (ostream& s, const MagDate& date)
+		{ date.print(s); return s; }
+
+protected:
+
+	MagDate(long julian,bool) : julian_(julian) {}
+
+// -- Members
+	// None
+
+// -- Methods
+	// None
+
+// -- Overridden methods
+	// None
+
+// -- Class members
+	// None
+
+// -- Class methods
+	// None
+
+private:
+
+// -- Members
+	
+	long julian_;
+
+// -- Methods
+
+	void print(ostream&) const;
+
+// -- Class methods
+
+	static long julianToMagDate(long);
+	static long dateToJulian(long);
+	static long today();
+
+// -- Friends
+
+	friend long operator-(const MagDate& d1, const MagDate& d2)
+		{ return (d1.julian_ - d2.julian_); }
+
+//	friend long operator-(const MagDate& d1)
+//		{ NOTIMP; return 0; }
+
+	friend MagDate operator+(const MagDate& d1, const long n)
+		{ return MagDate::julianToMagDate(d1.julian_ + n); }
+
+	friend MagDate operator+(const long n, const MagDate& d1)
+		{ return d1+n; }
+
+	friend MagDate operator+(const MagDate& d1, const MagDate& d2)
+		{ return MagDate::julianToMagDate(d1.julian_ + d2.julian_); }
+
+
+	friend class DateTime;
+};
+
+
+class MagTime {
+
+public:
+
+// -- MagExceptions
+	// None
+
+// -- Contructors
+
+	MagTime(long, long, long);
+	MagTime(long seconds = 0);
+	MagTime(const string&);
+
+
+// -- Copy
+
+	MagTime(const MagTime&);
+	MagTime& operator=(const MagTime&);
+
+// -- Destructor
+
+	~MagTime();
+
+// -- Convertors
+
+	operator string() const;
+	operator Second() const { return seconds_; }
+
+// -- Operators
+
+	bool operator==(const MagTime& other) const
+		{ return seconds_ == other.seconds_; }
+
+	bool operator!=(const MagTime& other) const
+		{ return (seconds_ != other.seconds_); }
+
+	bool operator>(const MagTime& other) const
+		{ return (seconds_ > other.seconds_); }
+
+	bool operator<(const MagTime& other) const
+		{ return (seconds_ < other.seconds_); }
+
+	bool operator>=(const MagTime& other) const
+		{ return (seconds_ >= other.seconds_); }
+
+	bool operator<=(const MagTime& other) const
+		{ return (seconds_ <= other.seconds_); }
+
+	Second operator-(const MagTime& other) const
+		{ return seconds_ - other.seconds_; }
+
+//	MagTime operator+(const MagTime& other) const
+//		{ return seconds_ + other.seconds_; }
+
+	MagTime& operator+=(const Second& sec)
+		{ seconds_ += sec; return *this; }	
+
+	MagTime& operator-=(const Second& sec)
+		{ seconds_ -= sec; return *this; }	
+
+// -- Methods
+	long hours() const;
+	long minutes() const;
+	long seconds() const;
+	long hhmmss() const;
+
+
+// -- Class Methods
+
+	static MagTime now();
+
+protected:
+
+// -- Methods
+
+	void print(ostream&) const;
+
+private:
+
+// -- Members
+
+	Second seconds_;
+
+	friend ostream& operator<<(ostream& s,const MagTime& t)
+		{ t.print(s); return s; }
+
+};
+
+
+
+class XmlNode;
+
+class DateTime {
+public:
+
+// -- Contructors
+
+	DateTime(time_t = ::time(0));
+	DateTime(const MagDate&, const MagTime&);
+	DateTime(const string&);
+	string tostring(const string&) const;
+	
+	DateTime* clone() const { return new DateTime(date(), time()); }
+	void set(const XmlNode&) { }
+	void set(const map<string, string>&) { }
+	 virtual void toxml(ostream&) const {
+   		
+    }   
+
+
+// -- Destructor
+
+	virtual ~DateTime() {}
+
+// -- Operators
+
+	bool operator<(const DateTime& other) const
+		{ return (date_ == other.date_)
+			?(time_ < other.time_)
+			:(date_ < other.date_); }
+
+	bool operator==(const DateTime& other) const
+		{ return (date_ == other.date_) && (time_ == other.time_); }
+
+	bool operator!=(const DateTime& other) const
+		{ return (date_ != other.date_) || (time_ != other.time_); }
+
+	bool operator>(const DateTime& other) const
+		{ return (date_ == other.date_)
+			?(time_ > other.time_)
+			:(date_ > other.date_); }
+
+	bool operator>=(const DateTime& other) const
+		{ return !(*this < other); }
+
+	bool operator<=(const DateTime& other) const
+		{ return !(*this > other); }
+
+	DateTime& operator=(const DateTime&);
+
+	Second operator-(const DateTime&) const;
+	DateTime operator+(const Second&) const;
+
+	operator string() const;
+    operator tm() const;
+    
+    operator double() const;
+
+// -- Methods
+
+	const MagDate& date() const { return date_; }
+	const MagTime& time() const { return time_; }
+
+	DateTime round(const Second& seconds) const;
+
+
+
+protected:
+
+// -- Members
+
+	MagDate date_;
+	MagTime time_;
+
+// -- Methods
+	// None
+
+// -- Overridden methods
+	// None
+
+// -- Class members
+	// None
+
+// -- Class methods
+	// None
+
+private:
+
+// -- Members
+	// None
+
+// -- Methods
+
+	void print(ostream&) const;
+
+// -- Class methods
+
+// -- Friends
+
+	friend ostream& operator<<(ostream& s,const DateTime& p)
+		{ p.print(s); return s; }
+};
+
+}
+#endif
diff --git a/src/decoders/EfiDataDecoder.h b/src/decoders/EfiDataDecoder.h
new file mode 100644
index 0000000..754d98d
--- /dev/null
+++ b/src/decoders/EfiDataDecoder.h
@@ -0,0 +1,82 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EfiDataDecoder.h
+    \brief Definition of the Template class EfiDataDecoder.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 18-May-2006
+    
+    Changes:
+    
+*/
+
+#ifndef EfiDataDecoder_H
+#define EfiDataDecoder_H
+
+#include "magics.h"
+
+#include "EfiDataDecoderAttributes.h"
+#include "BaseSceneObject.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "PaperPoint.h"
+
+namespace magics {
+
+class XmgrBasic;
+
+class EfiDataDecoder: public EfiDataDecoderAttributes, 	
+            public Data<PaperPoint>, 
+            public PointsList<PaperPoint> {
+
+public:
+	EfiDataDecoder();
+	virtual ~EfiDataDecoder();
+	void set(const map<string, string>& map) 
+		{ EfiDataDecoderAttributes::set(map); }
+	void set(const XmlNode& node) 
+		{ EfiDataDecoderAttributes::set(node); }
+	
+	virtual void decode();
+	virtual PointsHandler<PaperPoint>& points();
+	void    visit(TitleBase& title);
+	void    visit(LegendBase& legend);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	EfiDataDecoder(const EfiDataDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	EfiDataDecoder& operator=(const EfiDataDecoder&);
+	XmgrBasic*       data_;
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EfiDataDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/EfiLegendEntry.h b/src/decoders/EfiLegendEntry.h
new file mode 100644
index 0000000..db43bc1
--- /dev/null
+++ b/src/decoders/EfiLegendEntry.h
@@ -0,0 +1,198 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file SpotDecoder.h
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+#include "LegendVisitor.h"
+#include "Polyline.h"
+
+class EfiEntry : public LegendEntry
+{
+public:
+	EfiEntry(int efi) : LegendEntry(""), efi_(efi)
+	{
+		if ( efi_ > -200 ) label_ = tostring(efi_) + "%"; 
+	}
+
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& task)
+	{
+		MagLog::dev() << "LEGEND_STYLE --->" << style_ << endl; 
+		MagLog::dev() << "LEGEND_TYPE --->" << type_ << endl;
+		MagLog::dev() << "LEGEND_COLOUR --->" << colour_ << endl;
+		double x = point.x()-0.7;
+		double y = point.y();
+
+		double factor = 1.5;
+		double half = factor/2;
+		double width = efi_* factor/100.;
+		double height = 0.5; 
+		double top = y-height;
+		double bottom = y+height;
+
+		if ( magCompare(style_, "title") )
+		{
+			Text* efi = new Text();
+			efi->addText("EFI", textColour_, textHeight_);
+			efi->push_back(PaperPoint(x, y));	
+			task.push_back(efi);
+			Text* t1 = new Text();
+			t1->addText("-100%", textColour_, textHeight_);
+			t1->push_back(PaperPoint(x-factor, y));	
+			task.push_back(t1);
+			Text* t2 = new Text();
+			t2->addText("-50%", textColour_, textHeight_);
+			t2->push_back(PaperPoint(x-half, y));	
+			task.push_back(t2);
+			Text* t3 = new Text();
+			t3->addText("50%", textColour_, textHeight_);
+			t3->push_back(PaperPoint(x+half, y));	
+			task.push_back(t3);
+			Text* t4 = new Text();
+			t4->addText("100%", textColour_, textHeight_);
+			t4->push_back(PaperPoint(x+factor, y));	
+			task.push_back(t4);
+
+			return;              
+		}
+
+		Polyline* normal  = new Polyline();
+		normal->setColour(normalColour_);
+		normal->setThickness(normalThickness_);
+		normal->push_back(PaperPoint(x, bottom));
+		normal->push_back(PaperPoint(x, top));
+
+		Polyline* lmax  = new Polyline();
+		lmax->setColour(normalColour_);
+		lmax->setThickness(1);
+		lmax->push_back(PaperPoint(x+factor, bottom));
+		lmax->push_back(PaperPoint(x+factor, top));			
+
+		Polyline* lmin  = new Polyline();
+		lmin->setColour(normalColour_);
+		lmin->setThickness(1);
+		lmin->push_back(PaperPoint(x-factor, bottom));
+		lmin->push_back(PaperPoint(x-factor, top));
+
+		Polyline* l1  = new Polyline();
+		l1->setColour(normalColour_);
+		l1->setThickness(1);
+		l1->setLineStyle(M_DOT);
+		l1->push_back(PaperPoint(x+half, bottom));
+		l1->push_back(PaperPoint(x+half, top));			
+
+		Polyline* l2  = new Polyline();
+		l2->setColour(normalColour_);
+		l2->setThickness(1); 
+		l2->setLineStyle(M_DOT);
+		l2->push_back(PaperPoint(x-half, bottom));
+		l2->push_back(PaperPoint(x-half, top));
+
+		Polyline* lt  = new Polyline();
+		lt->setColour(normalColour_);
+		lt->setThickness(1); 
+		lt->setLineStyle(M_DOT);
+		lt->push_back(PaperPoint(x-factor, top));
+		lt->push_back(PaperPoint(x+factor, top));
+
+		Polyline* lb  = new Polyline();
+		lb->setColour(normalColour_);
+		lb->setThickness(1); 
+		lb->setLineStyle(M_DOT);
+		lb->push_back(PaperPoint(x-factor, bottom));
+		lb->push_back(PaperPoint(x+factor, bottom));
+
+		task.push_back(lmin);
+		task.push_back(lmax);
+		task.push_back(l1);
+		task.push_back(l2);
+		task.push_back(lt);
+		task.push_back(lb);
+		if (efi_ > -200)
+		{
+		  if ( magCompare(type_, "both") || 
+		     ( efi_ < 0  && magCompare(type_, "negative") ) || 
+		     ( efi_ > 0  && magCompare(type_, "positive") ) )
+		  {			
+			Polyline* box  = new Polyline();
+			box->setColour(normalColour_);
+			box->setFilled(true);
+			box->setFillColour(colour_);
+
+			FillShadingProperties* shading = new FillShadingProperties();                      
+			box->setShading(shading);
+
+
+			box->push_back(PaperPoint(x, bottom));
+			box->push_back(PaperPoint(x, top));
+			box->push_back(PaperPoint(x+width, top));
+			box->push_back(PaperPoint(x+width, bottom));
+			box->push_back(PaperPoint(x, bottom));
+			task.push_back(box);
+		  }
+		}
+		task.push_back(normal);
+            
+		if ( magCompare(style_, "bottom") )
+		{
+			Polyline* line  = new Polyline();
+			line->setColour(normalColour_);
+			line->setThickness(1); 
+			line->push_back(PaperPoint(x-factor, bottom));
+			line->push_back(PaperPoint(x+factor, bottom));
+			task.push_back(line);
+		} 
+		if ( magCompare(style_, "top") )
+		{
+			Polyline* line  = new Polyline();
+			line->setColour(normalColour_);
+			line->setThickness(1); 
+			line->push_back(PaperPoint(x-factor, top));
+			line->push_back(PaperPoint(x+factor, top));
+			task.push_back(line);
+		}
+	}
+
+        double textColumnPosition() { return 0.85; }
+	void type(const string& type)  { type_ = type; }
+        void style(const string& style)  { style_ = style; }
+	void colour(const Colour& colour) { colour_ = colour; }
+	void normalColour(const Colour& colour) { normalColour_ = colour; }
+	void normalThickness(int thickness) { normalThickness_ = thickness; }
+        void textColour(const Colour& colour) { textColour_ = colour; }
+        void textHeight(double height) { textHeight_ = height; }
+
+protected:
+	int efi_;
+	Colour colour_;
+	Colour textColour_;
+	double textHeight_;
+	string type_;
+	string style_;
+	Colour normalColour_;
+	int     normalThickness_;
+};
diff --git a/src/decoders/EpsBufr.cc b/src/decoders/EpsBufr.cc
new file mode 100644
index 0000000..e8b16ab
--- /dev/null
+++ b/src/decoders/EpsBufr.cc
@@ -0,0 +1,242 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file SpotDecoder.h
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+
+#include <locale>
+#include "EpsBufr.h"
+#include "MetaData.h"
+#include "CustomisedPoint.h"
+#include "DateTime.h"
+#include "TextVisitor.h"
+#include "MvObs.h"
+
+using namespace magics;
+
+    
+void EpsBufr::visit(Transformation& transformation)
+{
+	decode();
+	transformation.setDataMinX((minstep_ - shift_) * 3600, base_);
+	transformation.setDataMaxX((maxstep_ + 6) * 3600, base_);
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy_);
+}
+		
+void EpsBufr::decode()
+{
+	if ( !points_.empty()) return;
+	
+     MagLog::dev() << "EpsBufr::decode()-->" << *this << endl;		
+     // Test
+     MvObsSet set(path_.c_str());
+     
+     MvObsSetIterator   filter(set);
+     MvLocation ll(latitude_-0.1, longitude_-0.1);
+     MvLocation ur(latitude_+0.1, longitude_+0.1);
+     filter.setArea(ll, ur);
+     
+     MvObs obs = filter();
+    
+     map<int, float > curve1; 
+     map<int, float > curve2; 
+     
+     minstep_ = std::numeric_limits<double>::max();
+     maxstep_ = -std::numeric_limits<double>::max();
+     miny_ = std::numeric_limits<double>::max();
+     maxy_ = -std::numeric_limits<double>::max();
+
+     double previous = 0;
+     while (obs)
+     {
+             //MagLog::dev()<< "obs---------------------------------------------------------------------------" << endl;		
+     		MvLocation loc = obs.location();
+//      	  int subsets = obs.msgSubsetCount();
+
+       		 float value = obs.value(param_descriptor_ );
+        	obs.value(5195); 
+        	if ( value == kFortranBufrMissingValue )
+		{
+        		obs = filter(NR_returnMsg);         	// Were going to the next message!
+        		continue;
+        	}
+        	
+    		int i = 0;
+    		 
+    		while ( ++i  )
+		{
+    			// 0424 is the bufr descriptor for Time Period Or Displacement [HOUR]
+                
+    			float step =  obs.valueByOccurrence(i, 4024);  
+    			float value =  obs.valueByOccurrence(i, param_descriptor_);
+    			if ( value == kFortranBufrMissingValue ) {
+    				obs = filter(); // We going to the next subset!
+    				break;
+    			}
+    			value = (value * param_scaling_factor_ ) + param_offset_factor_;
+    			
+    			base_ = DateTime(obs.obsTime().CharValue());
+    			MagLog::dev() << "date--->" << base_ << endl; 
+    		
+    			if ( accumulated_) {
+    				double total = value;
+    				value = value - previous;
+    				previous = total;
+    			}
+
+    			if  ( minstep_ > step ) minstep_ = step;
+    			if  ( maxstep_ < step ) maxstep_ = step;
+    			if  ( miny_ > value ) miny_ = value;
+    			if  ( maxy_ < value ) maxy_ = value;
+
+    			curve1[step] = value;
+    		}
+     	}
+     if ( param_descriptor_2_) { 
+    	 MvObsSet set(path_.c_str());
+     
+     MvObsSetIterator   filter(set);
+     MvLocation ll(latitude_-0.1, longitude_-0.1);
+     MvLocation ur(latitude_+0.1, longitude_+0.1);
+     filter.setArea(ll, ur);
+    MvObs obs2 = filter();
+     while (obs2)
+         {
+                 //MagLog::dev()<< "obs---------------------------------------------------------------------------" << endl;		
+         	MvLocation loc = obs2.location();
+    //        int subsets = obs.msgSubsetCount();
+
+            float value = obs2.value( param_descriptor_2_ );
+            
+            	if ( value == kFortranBufrMissingValue )
+    		{
+            		obs2 = filter(NR_returnMsg);         	// Were going to the next message!
+            		continue;
+            	}
+            	
+        		int i = 0;
+        		 
+        		while ( ++i  )
+    		{
+        			// 0424 is the bufr descriptor for Time Period Or Displacement [HOUR]
+        			float step =  obs2.valueByOccurrence(i, 4024); 
+        			obs2.valueByOccurrence(i, 5195);  			
+        			float value =  obs2.valueByOccurrence(i, param_descriptor_2_);
+        			if ( value == kFortranBufrMissingValue ) {
+        				obs2 = filter(); // We going to the next subset!
+        				break;
+        			}
+
+        			curve2[step] = value;
+        		}
+         	}
+     }
+    
+	for (map<int, float>::const_iterator step = curve1.begin(); step != curve1.end(); ++step) {
+		CustomisedPoint* point = new CustomisedPoint();		
+		point->longitude(step->first * 3600);		 
+		point->latitude(step->first * 3600);		 
+		DateTime date  = base_ +  Second(step->first * 3600);    
+		(*point)["step"]    = step->first * 3600;
+		(*point)["shift"] = minstep_ - shift_ *3600;
+		(*point)["year"]    = date.date().year();
+		(*point)["month"]   = date.date().month();
+		(*point)["day"]     = date.date().day();
+		(*point)["hours"]   = date.time().hours();
+		(*point)["minutes"] = date.time().minutes();
+		(*point)["seconds"] = date.time().seconds();
+		(*point)["width"]    = 1 * 3600;
+		(*point)["control"] = step->second;	
+		(*point)["curve1"] = step->second;	
+		if ( param_descriptor_2_ ) 
+			(*point)["curve2"] = curve2[step->first];	
+		points_.push_back(point);
+	}
+}
+
+void EpsBufr::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	MagLog::dev() << "EpsBufr::customisedPoints-->need to be implemented" <<endl;
+	MagLog::dev() << *this << endl;
+	decode();
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+			out.push_back(*point);	
+}
+
+PointsHandler& EpsBufr::points()
+{
+}
+
+void EpsBufr::visit(TextVisitor& title)
+{
+	decode();
+	if (  EpsBufrAttributes::information_ )
+	{
+		ostringstream out;
+		tm convert = base_;	
+		locale loc("");      
+		out.imbue(loc);   
+		const std::time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+		string format = "Forecast VT %A %e %B %Y %H UTC";
+		tfac.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length()); 
+	    		
+		ostringstream line;
+		UserPoint position(longitude_, latitude_);
+		line << station_name_ << "(" << position.asLatitude() << ", " << position.asLongitude() << ")" << endl;
+		title.add(new TextEntry(title_));
+		title.add(new TextEntry(line.str()));
+		title.add(new TextEntry(out.str()));
+	}
+	if ( short_title_ ) {
+		title.add(new TextEntry(""));
+		if ( param_title_.empty() ) 
+			param_title_ = "" + param_descriptor_; 
+		title.add(new TextEntry(param_title_));
+	}
+}
+
+void EpsBufr::visit(MetaDataVisitor&)
+{
+}
+	
+void EpsBufr::print(ostream& out) const
+{
+	out << "EpsBufr[";
+	EpsBufrAttributes::print(out);
+	out << "]";
+}
+
+EpsBufr::EpsBufr() : shift_(12)
+{
+}
+
+EpsBufr::~EpsBufr()
+{
+}
diff --git a/src/decoders/EpsBufr.h b/src/decoders/EpsBufr.h
new file mode 100644
index 0000000..fc9e70a
--- /dev/null
+++ b/src/decoders/EpsBufr.h
@@ -0,0 +1,101 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsgramDecoder.h
+    \brief Definition of the Template class EpsgramDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef EpsBufr_H
+#define EpsBufr_H
+
+#include "magics.h"
+
+
+#include "EpsBufrAttributes.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "DateTime.h"
+
+#include <limits>
+
+namespace magics {
+
+
+
+class EpsBufr:
+			public Decoder,
+			public Data,
+			public PointsList,
+			public EpsBufrAttributes {
+public:
+	EpsBufr();
+	virtual ~EpsBufr();
+	
+	virtual void set(const map<string, string>& map) 	{EpsBufrAttributes::set(map); }
+	virtual void set(const XmlNode& node) { EpsBufrAttributes::set(node); }
+	
+	virtual void visit(Transformation&);
+	void visit(const XmlNode& node);
+		
+	virtual void decode();
+  	
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	virtual PointsHandler& points();
+	virtual void visit(TextVisitor&);
+	virtual void visit(MetaDataVisitor&);
+	void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool)
+	{
+		customisedPoints(n, out);
+	}
+	
+		PointsHandler& points(const Transformation&, bool) { return  points(); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 DateTime base_;
+	 vector<CustomisedPoint*> points_; 
+     double minstep_;
+	 double maxstep_;
+	 double miny_;
+	 double maxy_;
+	 double shift_;
+	 
+	 
+private:
+    //! Copy constructor - No copy allowed
+	EpsBufr(const EpsBufr&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsBufr& operator=(const EpsBufr&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsBufr& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/EpsXmlInput.cc b/src/decoders/EpsXmlInput.cc
new file mode 100644
index 0000000..3c01f62
--- /dev/null
+++ b/src/decoders/EpsXmlInput.cc
@@ -0,0 +1,216 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file SpotDecoder.h
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+
+
+#include "EpsXmlInput.h"
+#include "MetaData.h"
+#include "CustomisedPoint.h"
+#include "DateTime.h"
+#include "TextVisitor.h"
+#include "LegendVisitor.h"
+#include "XmlReader.h"
+#include "IntervalMap.h"
+
+#include "Factory.h"
+#include <locale>
+#include <limits>
+
+using namespace magics;
+
+namespace magics
+{
+
+void EpsXmlInput::visit(Transformation& transformation)
+{
+	decode();
+	
+	transformation.setDataMinX((minstep_ - dateOffset_) * 3600, base_);
+	
+	transformation.setDataMaxX((maxstep_+dateOffset_) * 3600, base_);
+	
+	dateOffset_ = minstep_ - dateOffset_;
+	
+	transformation.setMinY(miny_);
+	transformation.setMaxY(maxy_);
+}
+		
+void EpsXmlInput::decode()
+{
+	if ( !points_.empty()) return;
+	minstep_ =  std::numeric_limits<double>::max();
+	maxstep_ =  std::numeric_limits<double>::min();
+	miny_ =  std::numeric_limits<double>::max();;
+	maxy_ =  std::numeric_limits<double>::min();;
+		
+	XmlReader parser(true);
+	XmlTree tree;	
+
+	try {
+		parser.interpret(path_, &tree);		
+		tree.visit(*this);
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::debug() << e.what() << endl;
+	}
+}
+  	
+void EpsXmlInput::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	MagLog::dev() << "EpsXmlInput::customisedPoints-->need to be implemented" <<endl;
+	MagLog::dev() << *this << endl;
+	decode();
+
+	for (vector<CustomisedPoint*>::iterator point = points_.begin(); point != points_.end(); ++point)
+	{
+		(**point)["step"] -= (dateOffset_* 3600);	
+		out.push_back(*point);
+	}
+}
+
+
+void EpsXmlInput::visit(TextVisitor& title)
+{
+	if ( !long_title_ && !short_title_) return;
+	decode();
+	if ( long_title_ )
+	{
+		ostringstream out;
+		tm convert = base_;	
+		locale loc("");      
+		out.imbue(loc);   
+		const std::time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+		string format = "Forecast %A %e %B %Y %H UTC";
+		tfac.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length()); 
+
+		ostringstream line;
+		UserPoint position(longitude_, latitude_);
+		line << station_ << "(" << position.asLatitude() << ", " << position.asLongitude() << ")" << endl;
+		title.add(new TextEntry(title_));
+		title.add(new TextEntry(line.str()));
+		title.add(new TextEntry(out.str()));
+	}
+	if ( short_title_ )
+	{
+		title.add(new TextEntry(""));
+		title.add(new TextEntry(parameter_));
+	}
+}
+
+void EpsXmlInput::visit(MetaDataVisitor&)
+{
+}	
+
+void EpsXmlInput::print(ostream& out) const
+{
+	out << "EpsXmlInput[";
+	EpsXmlInputAttributes::print(out);
+	out << "]";
+}
+
+EpsXmlInput::EpsXmlInput():dateOffset_(6)
+{
+}
+
+EpsXmlInput::~EpsXmlInput()
+{
+}
+
+#define value(s) (tonumber(node.getAttribute(s))*scaling) + offset
+
+void EpsXmlInput::visit(const XmlNode& node)
+{
+	MagLog::dev() << node.name() << endl;
+	if ( node.name() == "forecast" )
+	{
+		MagDate date(node.getAttribute("date"));
+		MagTime time(node.getAttribute("time"));
+		station_ = node.getAttribute("station");
+		title_ = node.getAttribute("title");
+		latitude_ = tonumber(node.getAttribute("latitude"));
+		longitude_ = tonumber(node.getAttribute("longitude"));
+		base_ = DateTime(date, time);
+		node.visit(*this);
+	}
+
+	static double scaling;
+	static double offset;
+
+	if ( node.name() == "param" && node.getAttribute("name") == param_ )
+	{
+		string s = node.getAttribute("scaling");
+		parameter_ = node.getAttribute("title");
+		scaling = (s.empty()) ? 1 :  tonumber(s);
+		string o = node.getAttribute("offset");
+		offset = (o.empty()) ? 0 :  tonumber(o);
+		
+		node.visit(*this);
+	}
+
+	if ( node.name() == "step" )
+	{
+		MagLog::dev() << node.getAttribute("value") << endl;
+		double step = tonumber(node.getAttribute("value"));
+		if ( step < minstep_) minstep_ = step;
+		if ( step > maxstep_) maxstep_ = step;
+		double min = value("min");
+		double max = value("max");
+		if ( min < miny_) miny_ = min;
+		if ( max > maxy_) maxy_ = max;
+		CustomisedPoint* point = new CustomisedPoint();						
+		point->longitude(step * 3600);		
+		//point->insert(make_pair("shift", dateOffset_*3600));		
+		point->insert(make_pair("shift", 0 ));
+		point->insert(make_pair("step", step* 3600));
+		point->insert(make_pair("width", 1.5 * 3600));	
+
+		point->insert(make_pair("year",  base_.date().year()));	
+		point->insert(make_pair("month",  base_.date().month()));	
+		point->insert(make_pair("day",  base_.date().day()));	
+		point->insert(make_pair("hours",  base_.time().hours()));	
+		point->insert(make_pair("minutes",  base_.time().minutes()));		    
+		point->insert(make_pair("seconds",  base_.time().seconds()));	
+		point->insert(make_pair("min", value("min")));	
+		point->insert(make_pair("max", value("max")));	
+		point->insert(make_pair("ten", value("ten")));	
+		point->insert(make_pair("twentyfive", value("twentyfive")));	
+		point->insert(make_pair("median", value("median")));	
+		point->insert(make_pair("seventyfive", value("seventyfive")));	
+		point->insert(make_pair("ninty", value("ninety")));
+		if ( !node.getAttribute("forecast").empty() )
+			point->insert(make_pair("forecast", value("forecast")));	
+		if ( !node.getAttribute("control").empty() )
+			point->insert(make_pair("control", value("control")));	
+
+		points_.push_back(point);   	
+	}
+}
+}
diff --git a/src/decoders/EpsXmlInput.h b/src/decoders/EpsXmlInput.h
new file mode 100644
index 0000000..0884c4f
--- /dev/null
+++ b/src/decoders/EpsXmlInput.h
@@ -0,0 +1,107 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsgramDecoder.h
+    \brief Definition of the Template class EpsgramDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef EpsXmlDecoder_H
+#define EpsXmlDecoder_H
+
+#include "magics.h"
+
+#include "EpsXmlInputAttributes.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "BasicSceneObject.h"
+#include "XmlReader.h"
+#include "DateTime.h"
+
+#include <limits>
+
+namespace magics {
+
+
+class EpsXmlInput:
+			public Decoder,
+			public Data,
+			public PointsList,
+			public EpsXmlInputAttributes,
+			public XmlNodeVisitor {
+public:
+	EpsXmlInput();
+	virtual ~EpsXmlInput();
+	
+	virtual void set(const map<string, string>& map) 	{EpsXmlInputAttributes::set(map); }
+	virtual void set(const XmlNode& node) { EpsXmlInputAttributes::set(node); }
+	
+	virtual void visit(Transformation&);
+	void visit(const XmlNode& node);
+		
+	virtual void decode();
+  	
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+       {
+       	customisedPoints(n, out);
+       }
+       PointsHandler& points(const Transformation& t, bool) { assert(false);}
+	
+	virtual void visit(TextVisitor&);
+	virtual void visit(MetaDataVisitor&);
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 DateTime base_;
+	 vector<CustomisedPoint*> points_;
+	 double minstep_;
+	 double maxstep_;
+	 double miny_;
+	 double maxy_;
+	 string   station_;
+	 double latitude_;
+	 double longitude_;
+	 string   title_;
+	 string   parameter_;
+	 int dateOffset_;
+
+	 
+private:
+    //! Copy constructor - No copy allowed
+	EpsXmlInput(const EpsXmlInput&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsXmlInput& operator=(const EpsXmlInput&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsXmlInput& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/EpsgramDecoder.cc b/src/decoders/EpsgramDecoder.cc
new file mode 100644
index 0000000..1dc1ded
--- /dev/null
+++ b/src/decoders/EpsgramDecoder.cc
@@ -0,0 +1,1979 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file SpotDecoder.h
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+
+
+#include "EpsgramDecoder.h"
+#include "MetaData.h"
+#include "CustomisedPoint.h"
+#include "DateTime.h"
+#include "TextVisitor.h"
+#include "LegendVisitor.h"
+#include "XmlReader.h"
+#include "IntervalMap.h"
+#include "EfiLegendEntry.h"
+
+#include "Factory.h"
+#include <locale>
+#include <limits>
+#include <cfloat>
+
+using namespace magics;
+
+namespace magics
+{
+
+EpsParameter::EpsParameter() : title_("eps10")
+{
+		specifics_["eps10"] = &EpsParameter::specific10;
+		specifics_["eps15"] = &EpsParameter::specific15;
+		minx_ = std::numeric_limits<double>::max();
+		maxx_ = -minx_;
+		miny_ = std::numeric_limits<double>::max();
+		maxy_ = std::numeric_limits<double>::min();
+}
+
+string EpsParameter::x(const string& prefix, const string& name) const
+{
+	static map<string, string> names;
+//	if ( names.empty() ) {
+//		names["0"] = "min";
+//		
+//		names["1"] = "one";
+//		names["10"] = "ten";
+//		names["25"] = "twentyfive";
+//		names["50"] = "median";
+//		names["75"] = "seventyfive";
+//		names["90"] = "ninty";
+//	    names["99"] = "nintynine";
+//
+//		names["100"] = "max";
+//
+//	}
+	return ( names.find(name) == names.end() ) ?  prefix + lowerCase(name) : prefix + names.find(name)->second;  
+}
+
+void EpsParameter::specific15(CustomisedPoint& point) const 
+{		
+	point["shift"] = shift_ * 3600;
+	point["shift"] = 0 * 3600;
+	point["width"] = 3 * 3600;
+	point["last"] = 15 * (24 * 3600);
+}
+
+void EpsParameter::specific10(CustomisedPoint& point) const 
+{		
+	point["width"] = 1.5 * 3600;
+	point["last"] = 10.25 * (24 * 3600);
+}
+
+void EpsParameter::steps(const vector<double>& steps)
+{
+	for(vector<double>::const_iterator step = steps.begin(); step != steps.end(); ++step) 
+		steps_.insert(make_pair(*step, *step));
+}
+
+
+class Eps2mTemperature: public EpsParameter
+{
+public:
+	Eps2mTemperature(const string& name, const string& title, const string& code) : EpsParameter(name, title, code)
+	{}
+	Eps2mTemperature(const string& code) : EpsParameter("min", "2m Temperature (deg C) (No reduction ( working on it...) ", code)
+	{}
+	Eps2mTemperature() : EpsParameter("min", "2m Temperature (deg C) (No reduction ( working on it...) ", "167.128")  
+	{}
+	~Eps2mTemperature() {}
+	const string& title() const
+	{
+		ostringstream title;
+		title << "2m Temperature " << " (°C) " << reduction_  <<  " from " << maground(detz_) << " m ("  << detResolution_ << ") and " << maground(epsz_) << " m (" << epsResolution_ << ")";
+		title_ = title.str();
+		return title_;
+	}
+
+	const string& xml() const
+	{
+		ostringstream xml;
+		xml << "2m Temperature (deg C) ";
+		xml_ = xml.str();
+		return xml_;
+	}
+
+	double eps(double value) const
+	{
+		reduction_ =  "reduced to the station height";
+		if ( height_ == INT_MAX && detz_)
+		{
+			//reduction_ =  "reduced to the " + detResolution_ + " orography";
+			const double correction = ( detz_ - epsz_ ) * 0.0065;
+			return value - correction;
+		} 
+		if ( height_ == INT_MAX )
+		{
+			//reduction_ =  "no reduction";
+			return value;
+		}
+
+		const double correction = (height_ - epsz_ ) * 0.0065;
+		return value - correction; 
+	}
+
+	double deterministic(double value) const
+	{
+		if ( height_ == INT_MAX )
+			return value;
+		const double correction = (height_ - detz_ ) * 0.0065;
+		return value - correction ; 
+	}
+   
+	void specific15(CustomisedPoint& point) const
+	{
+		point["shift"] = 6 * 3600;
+		point["shift"] = 0;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 *3600);
+	}
+
+	void specific10(CustomisedPoint& point) const
+	{
+		point["width"] = 1.5 * 3600;
+		point["last"] = 10.25 * (24 *3600);
+	}	
+  
+	virtual double operator()(double value, const string& data) const
+	{
+		if ( !correction_ ) return value - 273.15;
+		
+		if ( map_.empty() ) {
+			map_["forecast"] = &Eps2mTemperature::deterministic;
+			map_["control"] = &Eps2mTemperature::eps;
+			map_["median"] = &Eps2mTemperature::eps;
+			map_["twentyfive"] = &Eps2mTemperature::eps;
+			map_["min"] = &Eps2mTemperature::eps;
+			map_["max"] = &Eps2mTemperature::eps;
+			map_["seventyfive"] = &Eps2mTemperature::eps;
+			map_["ten"] = &Eps2mTemperature::eps;
+			map_["ninty"] = &Eps2mTemperature::eps;
+		}
+		map<string,  CorrectionFunction >::const_iterator correction = map_.find(data);		
+		return ( correction != map_.end() ) ?  (this->*correction->second)(value) - 273.15 : value - 273.15; 
+	}
+	
+protected :
+	typedef double (Eps2mTemperature::*CorrectionFunction)(double) const;
+	mutable string reduction_;
+	static map<string, CorrectionFunction > map_;
+};
+
+string EpsParameter::height() 
+{
+	ostringstream height;
+	if ( height_ < INT_MAX )
+		height << " " << height_ << " m";
+	else 
+		height << " " << maground(detz_) << " m (" << detResolution_ << ")";
+
+	return height.str();;
+}
+
+class EpsTemperature: public Eps2mTemperature
+{
+public:
+	EpsTemperature() {}
+	~EpsTemperature() {}
+	virtual double operator()(double) const 
+	{		
+		return shift_;
+	} 
+  
+	const string& title() const
+	{
+		ostringstream title;
+		title << "2m min/max temperature (°C) " << reduction_ << " from "  << maground(epsz_) << "m (" << epsResolution_ << ")";
+		title_ = title.str();
+		return title_;
+	}
+
+	const string& xml() const
+	{
+		ostringstream xml;
+		xml << "2m Min Temperature (deg C) ";
+		xml_ = xml.str();
+		return xml_;
+	}
+	
+	void specific15(CustomisedPoint& point) const
+	{	
+		point[( shift_ == -3 ) ? "left" : "right" ] = 1;	
+		point[( shift_ == -3 ) ? "tmin" : "tmax" ] = 1;
+		point["shift"] = shift_ * 3600;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 *3600);
+	}
+	
+	void specific10(CustomisedPoint& point) const
+	{
+		point["width"] = 1.5 * 3600;
+		point["last"] = 10.25 * (24 *3600);
+	}	
+
+	spot_query_result* prepare(const SpotDecoder& decoder, vector<CustomisedPoint*>& out)
+	{
+		spot_query* query = decoder.newQuery();
+
+		spot_set_parameter(query,"param", "122.128");
+		shift_ = -3; 
+		spot_query_result* result = spot_handle_query(query);
+		interpretResult(result,out);
+		spot_delete_query(query);
+		spot_delete_result(result);	
+
+		query = decoder.newQuery();	
+		spot_set_parameter(query,"param", "121.128");
+		shift_ = 3; 
+		result = spot_handle_query(query);
+		interpretResult(result,out);
+		spot_delete_query(query);		
+		return result; 
+	}
+
+protected :
+	typedef double (Eps2mTemperature::*CorrectionFunction)(double) const;
+	mutable double shift_;
+};
+
+
+class ClTemperature: public EpsTemperature
+{
+public:
+    ClTemperature() {}
+    ~ClTemperature() {}
+    const string& title() const {
+		title_= "";
+		return title_;
+	} 
+};
+
+
+map<string,  Eps2mTemperature::CorrectionFunction> Eps2mTemperature::map_;
+
+class EpsPrecipitation: public EpsParameter
+{
+public:
+	EpsPrecipitation(const string& code = "143.128") : 
+		EpsParameter("precip", "Total Precipitation (mm/24h)", code) { step_ = 0; }
+	~EpsPrecipitation() {}
+	virtual double operator()(double) const 
+	{
+		return 12;
+	} 
+	const string& title() const {
+		title_ = "Total Precipitation for " + type_;
+		if ( type_ == "eps10" ) title_ =  "Total Precipitation (mm/6h)";
+		if ( type_ == "eps15" ) title_ =  "Total Precipitation (mm/24h)";
+		return title_;
+	}
+	virtual double operator()(double value, const string&) const { 
+		if (value < 0 ) return 0;
+		return value*1000;
+	} 
+	 
+	void specific15(CustomisedPoint& point) const {		
+		point["shift"] = -12 * 3600;
+		point["shift"] = 0;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 * 3600);
+	}
+	void specific10(CustomisedPoint& point) const {		
+		point["shift"] = -3 * 3600;
+		point["width"] = 1.5 * 3600;
+		point["last"] = 10.25 * (24 * 3600);
+	}
+	void setTransformation(Transformation& transformation)
+	{
+	transformation.setDataMinX(minx_, base_);
+	transformation.setDataMaxX(maxx_ - 6*3600, base_);
+	if ( type_ == "eps15" ) {
+		transformation.setDataMaxX(maxx_+18*3600, base_);
+		transformation.setDataMinX(0, base_);
+	}
+	if ( type_ == "eps10" ) {
+		transformation.setDataMaxX(maxx_ + 6*3600, base_);
+		transformation.setDataMinX(0, base_);
+	}
+	
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy_);
+}
+protected : 
+	map<string, string> titles_;
+};
+
+
+class ClimEpsPrecipitation: public EpsPrecipitation
+{
+public:
+	ClimEpsPrecipitation() : 	EpsPrecipitation("143.128") { title_ = ""; }
+	const string& title() const {
+		static string none;
+		return none;
+	}
+	int x(int val) const { 
+		if ( val == 20 ) return val+256; 
+		if ( val == 44 ) return val+256; 
+		if ( val == 68 ) return val+256; 
+		if ( val == 92 ) return val+256; 
+		else return val;
+	} 
+	string x(const string& val) const { return val; } 
+	 void specific15(CustomisedPoint& point) const {		
+		point["shift"] = 0;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 * 3600);
+	}
+};
+
+
+class EpsCloudCover: public EpsParameter
+{
+public:
+	EpsCloudCover(const string& code = "164.128") : 
+		EpsParameter("cloud-cover", "Daily mean of Total Cloud Cover (okta)", code) {}
+	~EpsCloudCover() {}
+
+	const string& title() const
+	{
+		title_ = "Cloud Cover for " + type_;
+		if ( type_ == "eps10" ) title_ =  "Total Cloud Cover (okta)";
+		if ( type_ == "eps15" ) title_ =  "Daily mean of Total Cloud Cover (okta)";
+		return title_;
+	}
+
+	virtual double operator()(double value, const string&) const
+	{
+		return 8*value;
+	} 
+
+	void specific15(CustomisedPoint& point) const {		
+		point["shift"] = 6 * 3600;
+		point["shift"] = 0 * 3600;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 * 3600);
+	}
+
+	void specific10(CustomisedPoint& point) const
+	{		
+		point["width"] = 1.5 * 3600;
+		point["last"] = 10.25 * (24 * 3600);
+	}
+	
+};
+
+class ClimEpsTemperature: public Eps2mTemperature
+{
+public:
+	ClimEpsTemperature() : 	Eps2mTemperature("167.128") {}
+
+	int x(int val) const
+	{ 
+		if ( val == 20 ) return val+256; 
+		if ( val == 44 ) return val+256; 
+		if ( val == 68 ) return val+256; 
+		if ( val == 92 ) return val+256; 
+		else return val;
+	} 
+
+	const string& title() const
+	{
+		title_ = "";
+		return title_;
+	}
+
+	void specific15(CustomisedPoint& point) const
+	{
+		point["shift"] = 0;
+	}
+};
+
+
+class ClimEpsMinTemperature: public Eps2mTemperature
+{
+public:
+	ClimEpsMinTemperature() : Eps2mTemperature("122.128") {}
+
+	int x(int val) const
+	{ 
+		if ( val == 20 ) return val+256; 
+		if ( val == 44 ) return val+256; 
+		if ( val == 68 ) return val+256; 
+		if ( val == 92 ) return val+256; 
+		else return val;
+	} 
+
+	const string& title() const
+	{
+		title_ = "";
+		return title_;
+	}
+
+	void specific15(CustomisedPoint& point) const
+	{
+		point["shift"] = 0;
+	}
+	
+};
+
+
+class ClimEpsMaxTemperature: public Eps2mTemperature
+{
+public:
+	ClimEpsMaxTemperature() : Eps2mTemperature("121.128") {}
+
+	int x(int val) const
+	{ 
+		if ( val == 20 ) return val+256; 
+		if ( val == 44 ) return val+256; 
+		if ( val == 68 ) return val+256; 
+		if ( val == 92 ) return val+256; 
+		else return val;
+	}
+	 
+	const string& title() const
+	{
+		title_ = "";
+		return title_;
+	}
+
+	void specific15(CustomisedPoint& point) const
+	{
+		point["shift"] = 0;
+	}
+};
+
+class ClimEpsCloudCover: public EpsCloudCover
+{
+public:
+	ClimEpsCloudCover() : 	EpsCloudCover("164.128") {}
+	int x(int val) const { 
+		if ( val == 20 ) return val+256; 
+		if ( val == 44 ) return val+256; 
+		if ( val == 68 ) return val+256; 
+		if ( val == 92 ) return val+256; 
+		else return val;
+	}
+	 
+	const string& title() const
+	{
+		title_ = "";
+		return title_;
+	}
+
+	void specific15(CustomisedPoint& point) const
+	{
+		point["shift"] = 0;
+	}
+};
+
+
+class EfiTemperature: public Eps2mTemperature
+{
+public:
+	EfiTemperature(const string& name, const string& title, const string& code) : 
+		Eps2mTemperature(name, title, code) {}
+	~EfiTemperature() {}
+	const string& title() const
+	{
+		title_ = "Efi 2m temperature";
+		return title_;
+	}
+
+	string x(const string& prefix, const string& val) const
+	{ 
+		 return (prefix == "clim_") ? prefix + val :prefix +  tostring( 2*tonumber(val)); 
+	}
+
+	void setTransformation(Transformation& transformation)
+	{
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+	}
+
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos)
+	{ 
+		xpos.push_back(x); 
+	}
+    
+};
+
+
+class EfiMaxTemperature: public EfiTemperature
+{
+public:
+	EfiMaxTemperature() : EfiTemperature("efi-2mt-max", "clim", "121.128") {}
+	~EfiMaxTemperature() {}
+	const string& title() const {
+		title_ = "CDF for 24h max 2m temperature (°C)";
+        return title_;
+	}
+};
+
+class EfiMinTemperature: public EfiTemperature
+{
+public:
+	EfiMinTemperature() : EfiTemperature("efi-2mt-min", "clim", "122.128") {}
+	~EfiMinTemperature() {}
+	const string& title() const {
+		title_ = "CDF for 24h min 2m temperature (°C)";
+        return title_;
+	}
+};
+
+class EfiMeanTemperature: public EfiTemperature
+{
+public:
+	EfiMeanTemperature() : EfiTemperature("efi-2mt-mean", "clim", "167.128") {}
+	~EfiMeanTemperature() {}
+	const string& title() const {
+		title_ = "CDF for 24h mean 2m temperature (°C)";
+        return title_;
+	}
+};
+
+class ClimTemperature: public Eps2mTemperature
+{
+public:
+	ClimTemperature(const string& name, const string& title, const string& code) : 
+		Eps2mTemperature(name, title, code) {}
+	~ClimTemperature() {}
+	const string& title() const {
+		title_ = "2m temperature";
+        return title_;
+	}
+	void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+		transformation.setDataMinY(miny_);
+		transformation.setDataMaxY(maxy_);
+	}
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) 
+	{ xpos.push_back(x); }
+	
+};
+
+class ClimMaxTemperature: public ClimTemperature
+{
+public:
+	ClimMaxTemperature() : ClimTemperature("clim-2mt-max", "clim", "121.128") {}
+	~ClimMaxTemperature() {}
+	const string& title() const {
+		title_ = "2m temperature max";
+        return title_;
+	}
+};
+
+class ClimMinTemperature: public ClimTemperature
+{
+public:
+	ClimMinTemperature() : ClimTemperature("clim-2mt-min", "clim", "122.128") {}
+	~ClimMinTemperature() {}
+	const string& title() const {
+		title_ = "2m temperature min";
+        return title_;
+	}
+};
+class ClimMeanTemperature: public ClimTemperature
+{
+public:
+	ClimMeanTemperature() : ClimTemperature("clim-2mt-mean", "clim", "167.128") {}
+	~ClimMeanTemperature() {}
+	const string& title() const {
+		title_ = "2m temperature mean";
+        return title_;
+	}
+};
+
+class EfiWindGust: public EpsParameter
+{
+public:
+	EfiWindGust() : EpsParameter("efi-wind-gust", "Wind Gust", "123.128") {}
+	~EfiWindGust() {}
+	const string& title() const {
+		title_ = "CDF for 24h maximum wind gust (m/s)";
+        return title_;
+	}
+	virtual double operator()(double value, const string&) const { 
+		return value; 
+	} 
+	virtual double operator()(double val) const { return val; } 
+
+	string x(const string& prefix, const string& val) const { 
+			 return (prefix == "clim_") ? prefix + val :prefix +  tostring( 2*tonumber(val)); 
+		}
+	void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+		
+	}
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) { xpos.push_back(x); }
+};
+
+class EfiWind: public EpsParameter
+{
+public:
+	EfiWind() : EpsParameter("efi-wind", "Wind", "165.128") {}
+	~EfiWind() {}
+	const string& title() const {
+		title_ = "CDF for 24h maximum wind gust (m/s)";
+        return title_;
+	}
+	virtual double operator()(double value, const string&) const { 
+		return value; 
+	} 
+	virtual double operator()(double val) const { return val; } 
+	string x(const string& val) const 
+		{ return tostring( 2*tonumber(val)); } 
+	void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+		
+	}
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) { xpos.push_back(x); }
+};
+
+class ClimWindGust: public EpsParameter
+{
+public:
+	ClimWindGust() : EpsParameter("clim-wind-gust", "Wind Gust", "123.128") {}
+	~ClimWindGust() {}
+	const string& title() const {
+		title_ = "Clim Wind Gust";
+        return title_;
+	}
+	virtual double operator()(double val) const { return val; } 
+	virtual double operator()(double value, const string&) const { 
+			return value; 
+		} 
+	
+	void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+		
+	}
+	
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) { xpos.push_back(x); }
+};
+class ClimWind: public EpsParameter
+{
+public:
+	ClimWind() : EpsParameter("clim-wind-gust", "Wind Gust", "165.128") {}
+	~ClimWind() {}
+	const string& title() const {
+		title_ = "Clim Wind";
+        return title_;
+	}
+	virtual double operator()(double val) const { return val; } 
+	virtual double operator()(double value, const string&) const { 
+			return value; 
+		} 
+	
+	void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+		
+	}
+	
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) { xpos.push_back(x); }
+};
+class EfiPrecipitation: public EpsParameter
+{
+public:
+	EfiPrecipitation() : EpsParameter("efi-precip", "Precipitation", "143.128") {}
+	~EfiPrecipitation() {}
+	const string& title() const {
+		title_ = "CDF for 24h precipitation (mm)";
+        return title_;
+	}
+	virtual double operator()(double value, const string&) const { 
+		if (value < 0 ) return 0;
+		return value*1000;
+	 } 
+	 string x(const string& prefix, const string& val) const { 
+		 return (prefix == "clim_") ? prefix + val :prefix +  tostring( 2*tonumber(val)); 
+	} 
+	 void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_);
+	    transformation.setDataMaxX(maxx_);
+		
+	}
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) { xpos.push_back(x); }
+	
+
+};
+class PlumeGeopotential: public EpsParameter
+{
+public:
+	PlumeGeopotential() : EpsParameter("z500", "z500", "129.128") {}
+	~PlumeGeopotential() {}
+	const string& title() const {
+		double range =  maxy_ - miny_; 
+		
+		title_ = "Geopotential 500hPa - Probability for 2.5 dam intervals      Range : " + tostring(maground(range)) + " dam";
+        return title_;
+	}
+	virtual double operator()(double value, const string&) const { 
+		
+		return value/100;
+	 } 
+	double plumesInterval() { return 2.5; }
+};
+
+
+class PlumeTemperature: public EpsParameter
+{
+public:
+		PlumeTemperature() : EpsParameter("t850", "t850", "130.128") {}
+		~PlumeTemperature() {}
+		const string& title() const {
+			double range =  maxy_ - miny_; 
+			title_ = "Temperature 850hPa - Probability for 1°C intervals      Range :  " + tostring(maground(range))  + " °C";
+	        return title_;
+		}
+		virtual double operator()(double value, const string&) const { 
+			
+			return value-273.15;
+		 } 
+		double plumesInterval() { return 1.; }
+	};
+	
+	class PlumePrecip: public EpsParameter
+	{
+	public:
+	
+		PlumePrecip() : EpsParameter("rr", "rr", "143.128") {}
+			~PlumePrecip() {}
+			const string& title() const {
+				title_ = "Ensemble members of Total Precipitation - Accum rate mm/12h";
+		        return title_;
+			}
+			virtual double operator()(double value, const string&) const { 
+				if (value < 0 ) return 0;
+				return value*1000;
+			 } 
+			
+		};
+class ClimPrecipitation: public EpsParameter
+{
+public:
+	ClimPrecipitation() : EpsParameter("clim-precip", "Precipitation", "143.128") {}
+	~ClimPrecipitation() {}
+	const string& title() const {
+		title_ = "Clim Precipitation";
+        return title_;
+	}
+	virtual double operator()(double value, const string&) const { 
+		if (value < 0 ) return 0;
+		return value*1000;
+	 } 
+	 void setTransformation(Transformation& transformation)
+    {
+	    transformation.setDataMinX(minx_); 
+	    transformation.setDataMaxX(maxx_);
+		
+	}
+	virtual void stepvalues(double, vector<double>&) {}  
+	virtual void xvalues(double x, vector<double>& xpos) { xpos.push_back(x); }
+};
+
+class EpsWindFF: public EpsParameter
+{
+public:
+	EpsWindFF(const string& code = "165.128") : EpsParameter("10m-wind", "Daily mean of 10m Wind Speed (m/s)", code ) {}
+	~EpsWindFF() {}
+	const string& title() const {
+		title_ = "10m Wind Speed (m/s) for " + type_;
+		if ( type_ == "eps10" ) title_ =  "10m Wind Speed (m/s)";
+		if ( type_ == "eps15" ) title_ =  "Daily mean of 10m Wind Speed (m/s)";
+        return title_;
+	}
+	 void specific15(CustomisedPoint& point) const {		
+		point["shift"] = 6 * 3600;
+		point["shift"] = 0 * 3600;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 * 3600);
+	}
+    void specific10(CustomisedPoint& point) const {		
+		point["width"] = 1.5 * 3600;
+		point["last"] = 10.25 * (24 * 3600);
+	}
+};
+
+class ClimEpsWindFF: public EpsWindFF
+{
+public:
+	ClimEpsWindFF() : 	EpsWindFF("165.128") {}
+	int x(int val) const { 
+		if ( val == 20 ) return val+256; 
+		if ( val == 44 ) return val+256; 
+		if ( val == 68 ) return val+256; 
+		if ( val == 92 ) return val+256; 
+		else return val;
+	}
+	const string& title() const {
+		title_ = "";
+		return title_;
+	}
+	void specific15(CustomisedPoint& point) const {		
+		point["shift"] = 0;
+		
+	}
+};
+
+class EpsWindDD: public EpsParameter
+{
+public:
+	EpsWindDD() : EpsParameter("10m-wind-dd", "Daily mean of 10m Wind", "249.140") {}
+	~EpsWindDD() {}
+	
+	const string& title() const {
+		title_ = "10m Wind Speed (m/s) for " + type_;
+		if ( type_ == "eps10" ) title_ =  "10m Wind Speed (m/s)";
+		if ( type_ == "eps15" ) title_ =  "Daily distribution of 10m Wind Direction";
+        return title_;
+	}
+	
+	void specific15(CustomisedPoint& point) const {		
+		point["shift"] = 6 * 3600;
+		point["shift"] = 0 * 3600;
+		point["width"] = 3 * 3600;
+		point["last"] = 15 * (24 * 3600);
+	}
+   
+};
+}
+SimpleObjectMaker<EfiMaxTemperature, EpsParameter> efi_2mt_max("efi-2mt-max");
+SimpleObjectMaker<EfiMinTemperature, EpsParameter> efi_2mt_min("efi-2mt-min");
+SimpleObjectMaker<EfiMeanTemperature, EpsParameter> efi_2mt_mean("efi-2mt-mean");
+SimpleObjectMaker<ClimMaxTemperature, EpsParameter> clim_2mt_max("clim-2mt-max");
+SimpleObjectMaker<ClimMinTemperature, EpsParameter> clim_2mt_min("clim-2mt-min");
+SimpleObjectMaker<ClimMeanTemperature, EpsParameter> clim_2mt_mean("clim-2mt-mean");
+
+SimpleObjectMaker<EfiWindGust, EpsParameter> efi_wind_gust("efi-wind-gust");
+SimpleObjectMaker<EfiWind, EpsParameter> efi_wind("efi-wind");
+SimpleObjectMaker<ClimWindGust, EpsParameter> clim_wind_gust("clim-wind-gust");
+SimpleObjectMaker<ClimWind, EpsParameter> clim_wind("clim-wind");
+
+SimpleObjectMaker<EfiPrecipitation, EpsParameter> efi_precip("efi-precip");
+SimpleObjectMaker<ClimPrecipitation, EpsParameter> clim_eps_precip("clim-precip");
+
+SimpleObjectMaker<Eps2mTemperature, EpsParameter> mt("2mt");
+SimpleObjectMaker<ClimEpsMaxTemperature, EpsParameter> tempe_clim_max("clim-eps-2mt-max");
+SimpleObjectMaker<ClimEpsMinTemperature, EpsParameter> tempe_clim_min("clim-eps-2mt-min");
+SimpleObjectMaker<ClimEpsTemperature, EpsParameter> tempe_clim("clim-eps-2mt");
+
+SimpleObjectMaker<PlumeGeopotential, EpsParameter> z500("z500");
+SimpleObjectMaker<PlumeTemperature, EpsParameter> t850("t850");
+SimpleObjectMaker<PlumePrecip, EpsParameter> rr("rr");
+
+
+SimpleObjectMaker<EpsTemperature, EpsParameter> temperature("temperature");
+SimpleObjectMaker<ClTemperature, EpsParameter> cltemperature("clim-temperature");
+SimpleObjectMaker<EpsWindFF, EpsParameter> wind("10m-wind");
+SimpleObjectMaker<ClimEpsWindFF, EpsParameter> clim_wind_ff("clim-10m-wind");
+SimpleObjectMaker<EpsWindDD, EpsParameter> windDD("10m-wind-dd");
+
+SimpleObjectMaker<EpsCloudCover, EpsParameter> cloud("cloud-cover");
+SimpleObjectMaker<ClimEpsCloudCover, EpsParameter> clim_cloud("clim-eps-cloud-cover");
+
+SimpleObjectMaker<EpsPrecipitation, EpsParameter> precip("precip");
+SimpleObjectMaker<ClimEpsPrecipitation, EpsParameter> clim_precip("clim-eps-precip");
+
+
+spot_query_result* EpsParameter::prepare(const SpotDecoder& decoder, vector<CustomisedPoint*>& out)
+{
+		spot_query* query = decoder.newQuery();
+		
+	
+		
+		spot_set_parameter(query,"param", code_.c_str()); 
+		spot_query_result* result = spot_handle_query(query);
+		interpretResult(result,out);
+		spot_delete_query(query);		
+	    return result; 
+	
+}
+
+template <class T>
+inline void read(const string& str, T& i) 
+{
+	
+	std::stringstream ss(str);
+	ss >> i;
+
+}
+static string get_spot(spot_query_result* result, const char* param)
+{
+	char tmp[1024];
+	size_t len = 1024;
+	
+	spot_get_parameter(result,param,tmp, &len); 
+	
+	return string(tmp, len-1);
+}
+
+
+string convert(const string& name)
+{
+	static map<string, string> names;
+	if ( names.empty() ) {
+		names["0"] = "min";
+		
+		names["1"] = "one";
+		names["10"] = "ten";
+		names["25"] = "twentyfive";
+		names["50"] = "median";
+		names["75"] = "seventyfive";
+		names["90"] = "ninty";
+	    names["99"] = "nintynine";
+
+		names["100"] = "max";
+
+	}	
+	
+	
+	return ( names.find(name) == names.end() ) ?  lowerCase(name) : names.find(name)->second;  
+	
+}
+
+struct SortHelper
+{
+	bool operator()(CustomisedPoint* first, CustomisedPoint* second) {
+		return first->longitude() < second->longitude();
+	}
+};
+
+
+void EpsParameter::interpretResult(spot_query_result* result, vector<CustomisedPoint*>& out)
+{
+	size_t len = 1024;
+	char tmp[1024];
+	
+	vector<double> xpos;
+	vector<double> ypos;
+	
+	if ( result == 0 ) {
+		MagLog::warning() << "No Information for parameter " << name_ << endl;
+		minx_ = 0;
+		maxx_ = 60;
+		miny_ = 0;
+		maxy_ = 1;
+		DateTime base;	
+		base_ = string(base);
+		return;
+	}
+		
+		
+	
+	string date = get_spot(result,"date");
+	string time = get_spot(result,"time");
+	map<string, int> columns;
+	map<int, int> rows;
+	
+	
+	// Get the columns names;
+	for(int i = 0 ; i < spot_get_column_count(result); i++){
+    	spot_get_column_name(result, i,tmp,&len);
+    	columns[tmp] = i;
+    	len = 1024;
+	}
+	
+	double values[1024];
+	size_t nb = 1024;
+	// get the rows names
+	for(int i = 0 ; i < spot_get_row_count(result); i++){
+    	spot_get_row_name(result, i,tmp,&len);   	
+    	int x = atoi(tmp);
+    	rows[x] = i;
+    	len = 1024;    	
+	}	
+
+	DateTime base(date, MagTime(time));
+	DateTime next;
+	
+	base_ = string(base);
+	
+	
+	len = 1024;
+	
+	for(int i = 0 ; i < spot_get_column_count(result); i++){
+    	spot_get_column_name(result, i,tmp,&len);        
+    	columns[tmp] = i;
+    	len = 1024;
+	}
+	
+	
+	for(int i = 0 ; i < spot_get_row_count(result); i++){
+    	spot_get_row_name(result, i,tmp,&len);
+    	
+    	int x = atoi(tmp);
+    	rows[x] = i;
+    	len = 1024;    	
+	}	
+	
+	long resol;
+
+
+	read(get_spot(result,"numberOfPointsAlongAMeridian"), resol);
+	
+    spot_get_index_value(result, "epsz", &epsz_);
+    spot_get_index_value(result, "detz", &detz_);    
+   
+    ostringstream rs, dets;	
+    rs << "T" << resol-1;
+    dets << "T" << (2*resol)-1;
+    detResolution_ = dets.str() ;
+    epsResolution_ = rs.str();
+	 
+	MagLog::debug() << "Code ---> " << code_ << endl;
+	MagLog::debug() << "Resolution ---> " << resol << endl;
+	MagLog::debug() << "Det height ---> " << detz_ << endl;
+	MagLog::debug() << "Eps height ---> " << epsz_ << endl;
+	MagLog::debug() << "Det resoltion ---> " << detResolution_ << endl;
+	MagLog::debug() << "Eps resoltion ---> " << epsResolution_ << endl;
+  
+	
+	for (map<int, int>::const_iterator step = rows.begin(); step != rows.end(); ++step) { 
+
+		CustomisedPoint* point = new CustomisedPoint();		
+		point->latitude(0);
+		point->longitude((x(step->first) ) * 3600);				
+		(*point)["resolution"] = resol;
+		 
+		Second s = x(step->first) * 3600;
+		DateTime valid = base + s;
+		point->base(base);
+		point->valid(valid);      
+		spot_get_row(result, step->second,values,&nb);
+		
+        bool ok = true;
+	
+		for (map<string, int>::const_iterator info = columns.begin(); info != columns.end(); ++info) {
+		    	
+			if ( !steps_.empty() && steps_.find(step->first) == steps_.end()) {
+				ok = false;
+				continue;
+			}
+           
+            MagLog::debug()  << step->first << " -> " << info->first << " = " << values[info->second] << "->" << (*this)(values[info->second], info->first) << endl;
+	    	(*point)["step"]    = x(step->first) * 3600;
+	    	stepvalues(x(step->first) * 3600, xpos);
+	 
+			map<string, EpsParameter::SpecificFunction>::const_iterator function = specifics_.find(type_);
+			(*point)["width"] = 1*3600;
+			if ( type_ == "eps10" ) 
+				specific10(*point);
+			if ( type_ == "eps15" ) 
+				specific15(*point);
+
+		if ( !isnan(values[info->second]) ) {
+		  (*point)[x(prefix_, info->first)] = (*this)(values[info->second], info->first);
+		  //MagLog::debug() <<  x(info->first) << "----->" << (*this)(values[info->second], info->first) << endl;
+
+		   ypos.push_back((*this)(values[info->second], info->first));
+
+		  xvalues((*this)(values[info->second], info->first), xpos);
+
+	    	  if ( info->first == "forecast"  && step->first > 240 )
+	    	   (*point)["forecast"] = DBL_MIN;
+	    	}
+	    	else {
+	    		MagLog::warning() << " SPOTBASE returns nan for " << info->first << " : data ignored for step " << (*point)["shift"]<< endl;
+	    		ok = false;
+	    	}
+		}
+    	if ( ok ) {
+            out.push_back(point);
+    	}
+		nb=1024;
+	}
+	
+	vector<double> maxs;
+	vector<double> allvalues;
+
+    for (vector<CustomisedPoint*>::iterator point = out.begin(); point != out.end(); ++point) {
+    	maxs.push_back((**point)["max"]);
+    	allvalues.push_back((**point)["seventyfive"]);
+    	allvalues.push_back((**point)["ninty"]);
+    	if ( (*point)->find("forecast") != (*point)->end() ) {
+    		allvalues.push_back((**point)["forecast"]);
+    		maxs.push_back((**point)["forecast"]);
+    	}
+    	if ( (*point)->find("control") != (*point)->end() ) {
+    		allvalues.push_back((**point)["control"]);  
+    		maxs.push_back((**point)["control"]);
+    	}
+    }
+
+    if ( threshold_ < 30) {
+    	double limit = *std::max_element(allvalues.begin(), allvalues.end());
+    	std::sort(maxs.begin(), maxs.end());
+
+    	double mm = maxs.back();
+    	double p1 = 1;
+    	double p2;
+    	int i = maxs.size() -1 ;
+    	int n = maxs.size();
+    	for ( vector<double>::reverse_iterator val = maxs.rbegin(); val != maxs.rend(); ++val) {
+    		p2 = (*val)/maxs.back();
+    	
+    		if ( p2 < (1 - i/n)*percentile_ && (p1-p2) > threshold_/n && *val >= limit ) {
+    			mm = *val;
+    		}
+   			p1 = p2;
+			i--;
+  	  	}
+    
+    	miny_ = std::min(miny_, *std::min_element(ypos.begin(), ypos.end()));
+        maxy_ = std::max(mm, 1.);
+    }
+    else {
+    	 miny_ = std::min(miny_, *std::min_element(ypos.begin(), ypos.end()));
+    	 maxy_ = std::max(maxy_,*std::max_element(ypos.begin(), ypos.end()));
+    }
+    
+	
+	std::sort(out.begin(), out.end(), SortHelper());
+	minx_ = std::min(minx_, *std::min_element(xpos.begin(), xpos.end()));
+	maxx_ = std::max(maxx_, *std::max_element(xpos.begin(), xpos.end()));
+	
+
+    
+	
+	if ( miny_  == maxy_ ) {
+		if ( miny_ == 9999. ) {
+			miny_ = 0;
+			maxy_ = 20;
+		}
+		else 
+			maxy_ = miny_ + 1;
+	}
+}
+
+
+SpotDecoder::SpotDecoder() :parameter_(0), prefix_(""),  spot_(0), shift_(0)
+{
+}
+
+
+
+
+SpotDecoder::~SpotDecoder() 
+{
+	if (parameter_) delete parameter_;
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SpotDecoder::print(ostream& out)  const
+{
+	out << "SpotDecoder[";
+	out << "]";
+}
+
+
+
+
+
+PointsHandler& SpotDecoder::points()
+{
+	decode();
+	
+	pointsHandlers_.push_back(new PointsHandler(*this));
+	return *(pointsHandlers_.back());
+}
+
+void SpotDecoder::visit(TextVisitor& title)
+{
+	decode();
+	moreTitle(title);
+	
+	if ( parameter_ && !magCompare(parameter_->title(), "ignore")  )
+				title.add(new TextEntry(parameter_->title()));
+}
+
+static string build_date(const string& date, const string& time)
+{
+	ostringstream out;
+	if ( date.empty() ) {
+		out << "Unknown date";
+	}
+	else {
+		DateTime base(date, MagTime(time));
+		tm convert = base;	
+    	locale loc("");
+    	out.imbue(loc);   
+    	const std::time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+    	string format = "%A %e %B %Y %H UTC";
+    	tfac.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length());    	
+	}
+	return out.str();
+}
+
+
+void EpsgramDecoder::visit(MetaDataVisitor& metadata)
+{
+	decode();
+	ostringstream meta;
+	meta << "<epsgram>\n";
+	//toxml(meta, "input", 1);
+	meta << "\t<output\n";
+	meta << "\t\tparameter =\'" << parameter_->xml() << "\'\n";
+	meta << "\t\tdate =\'" << SpotDecoder::date_ << "\'\n";
+	meta << "\t\ttime =\'" << SpotDecoder::time_ << "\'\n";
+	
+	string date = build_date(SpotDecoder::date_, SpotDecoder::time_);
+
+	meta << "\t\tnice_date =\'" <<  date << "\'\n";
+	string landsea = (mask_>= 0.5) ? "no" : "yes";
+	meta << "\t\tsea_point =\'" <<  landsea << "\'\n";
+
+	string height = "";
+	if (SpotDecoder::height_ < INT_MAX  ) {
+		ostringstream sh;
+		sh << SpotDecoder::height_ << "m";
+		height = sh.str();
+		meta << "\t\theight =\'" <<  height << "\'\n";
+	}
+
+	UserPoint position(SpotDecoder::longitude_, SpotDecoder::latitude_);
+	meta << "\t\tstation =\'" <<  SpotDecoder::station_ << "\'\n";
+	meta << "\t\tlatitude =\'" <<  grid_.y() << "\'\n";
+	meta << "\t\tlongitude =\'" <<  grid_.x() << "\'\n";
+	meta << "\t\tresolution =\'" <<  resolution_ << "\'/>\n";
+	
+	meta << "</epsgram>\n";
+
+	metadata.add(new MetaDataEntry(meta.str()));
+}
+
+
+EpsgramDecoder::EpsgramDecoder()
+{
+}
+
+EpsgramDecoder::~EpsgramDecoder() 
+{
+}
+
+void EpsgramDecoder::moreTitle(TextVisitor& title) const 
+{
+	if (long_title_ == false ) return;
+	
+	static map<string, string> titles;
+	if ( titles.empty() ) {
+		titles["eps10"] = "Deterministic Forecast and EPS Distribution ";
+		titles["eps15"] = "Extended Range Forecast based on EPS Distribution ";
+		titles["epsrose"] = "Deterministic Forecast and EPS Distribution ";
+		titles["epsplume"] = "ECMWF ensemble forecast ";
+	}
+	string date = build_date(SpotDecoder::date_, SpotDecoder::time_);
+	 
+    ostringstream lt;
+    for (stringarray::const_iterator t = title_.begin(); t != title_.end(); ++t)
+    	lt  << *t;
+   
+    string long_title = SpotDecoder::station_;    
+ 	title.add(new TextEntry(title_text_));
+	
+	string landsea = (mask_>= 0.5) ? " (EPS land point)" : " (EPS sea point)";
+	
+	
+	string height = long_title_height_ ? parameter_->height() : " ";
+
+	string epsz = "";
+	ostringstream sd;
+	//sd  <<  maground(epsz_) << " m";
+    sd  <<  "undef" << " m";
+	epsz = sd.str();
+	
+	MagLog::dev() << "title-->" << long_title << "(" << long_title.size() << ")\n";
+
+    string station = long_title;
+    if ( long_title_point_ ) {
+    	station = station + string(" ")  + grid_.asLatitude() + " " + grid_.asLongitude() + landsea + height;
+    }
+    
+ 	title.add(new TextEntry(station));
+	
+	map<string, string>::const_iterator t = titles.find(SpotDecoder::type_);
+	if ( t != titles.end() )
+ 		title.add(new TextEntry(t->second + date));
+	else 
+		title.add(new TextEntry(SpotDecoder::type_ + "title to implement " + date));
+ 	title.add(new TextEntry());
+}
+
+
+void SpotDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& out) 
+{
+	try {
+		decode();
+	}
+	catch ( ... ) {
+		return; // no data..
+	}
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+    {
+    		out.push_back(*point);
+    }
+}
+
+
+void SpotDecoder::decode(bool check) 
+{
+    
+	if ( check == false && !points_.empty() ) return;
+	int date;
+	
+	if (!date_.empty()) {
+		read(date_, date);	 
+		if ( date <= 0) {
+			MagDate d(0);
+	 		d += date;
+	 		date_ = tostring(d.yyyymmdd());	
+		}
+	}
+	   
+#ifdef MAGICS_EXCEPTION            
+    try { 
+		parameter_ = SimpleFactory<EpsParameter>::create(param_);       
+    }
+    catch (NoFactoryException& e) {
+    	parameter_ = new EpsParameter(param_, param_title_, param_);
+    }
+#else
+	parameter_ = SimpleFactory<EpsParameter>::create(param_);
+	if ( !parameter_ )
+	{
+		// The data do not know how to verify the criter ....
+		MagLog::warning() << "Eps Data access: parameter [" << param_ << "] unknown\n";
+		return;
+	}
+#endif   
+     parameter_->scaling(scaling_);
+     parameter_->offset(offset_);
+     parameter_->shift(shift_);
+	 parameter_->type(type_);
+	 parameter_->steps(steps_);
+	 parameter_->correction(SpotDecoder::correction_);
+	 parameter_->stationHeight(height_);
+	 parameter_->percentile_ = percentile_;
+	 parameter_->threshold_ = threshold_;
+	 parameter_->prefix_ = prefix_;
+    
+	spot_query_result *result = parameter_->prepare(*this, points_);
+	
+	if ( !result ) {
+		MagLog::error() << " No EpsData\n";
+		date_ = "";
+		time_ = "";
+		return;
+	}
+	
+    double lat, lon;
+ 	
+    spot_get_location(result, &lat, &lon);
+
+    spot_get_index_value(result, "mask", &mask_);
+    
+    if ( type_ == "epsrose" ) {
+    	// The mask is strange Seems to be 1 for sea and 0 fr land! 
+    	//MagLog::dev()<< "MASK--> " << mask_ << endl;
+    	if ( mask_ == 0 ) mask_ = 1;
+    	else mask_ = 0;
+    }
+    if ( lon > 180 ) 
+    	lon -= 360.;
+
+	grid_ = UserPoint(lon, lat);
+
+	long resol; 
+	
+	read(get_spot(result,"numberOfPointsAlongAMeridian"), resol);
+	spot_get_index_value(result, "bathymetry", &bathymetry_);
+
+	ostringstream rs, dets;
+	
+    rs << "T" << resol-1;
+    dets << "T" << (2*resol)-1;
+    //dets << "resolution to be checked!";
+    resolution_ = dets.str();
+   
+	date_ = get_spot(result,"date");
+	time_ = get_spot(result,"time");
+		
+	MagLog::debug() << "Date /time ---> [" << date_ << ", " << time_ << "]\n";
+
+  
+
+    spot_delete_result(result);
+    
+    
+    //spot_close_database(spot_);
+    
+//    delete spot_; 
+//    delete spot_;
+    spot_ = 0;
+
+     
+}
+
+
+
+MatrixHandler& EpsgramDecoder::matrix()
+{
+	decode();
+	vector<double> values;
+	vector<double> steps;
+	// Find the min and the max ..
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+	{
+		 MagLog::dev() << **point << endl;
+		 MagLog::dev() << **point << endl;
+		 for ( int s = 0; s != 50; s++) {		    
+				string key = tostring(s);
+			    map<string, double>::const_iterator member = (*point)->find(key);
+				if ( member != (*point)->end() ) 
+					values.push_back(member->second );
+		 }
+
+		 steps.push_back((**point)["step"]);
+	}
+
+
+	double from = maground(*min_element(values.begin(), values.end())) - 1;
+	double to = maground(*max_element(values.begin(), values.end())) + 1 ;
+	MagLog::dev() << "min->" << *min_element(values.begin(), values.end()) << " = " << from << endl;
+	MagLog::dev() << "max->" << *max_element(values.begin(), values.end()) << " = " << to << endl;
+
+	IntervalMap<int> array;
+	const double step = parameter_->plumesInterval();
+	for ( double a = from; a <= to; a = a + step ) {
+			array.insert(make_pair(Interval(a, a+step), 0));
+	}
+
+
+
+	matrix_.set(array.size(), points_.size());
+	for (IntervalMap<int>::iterator interval = array.begin(); interval!= array.end(); ++interval) {
+		const double row = (interval->first.max_ - interval->first.min_)/2 +interval->first.min_ ;
+		matrix_.rowsAxis().push_back(row);
+	}
+	for (vector<double>::iterator s = steps.begin(); s != steps.end(); ++s) {				
+		matrix_.columnsAxis().push_back(*s);
+	}
+
+	matrix_.setMapsAxis();
+	int column = 0;
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+	{
+
+		for (IntervalMap<int>::iterator interval = array.begin(); interval!= array.end(); ++interval)
+		{
+			interval->second = 0;
+		}
+
+		for ( int s = 0; s != 50; s++)
+		{
+			string key = tostring(s);
+
+			map<string, double>::const_iterator step = (*point)->find(key);
+			if (step != (*point)->end() ) {
+
+			  IntervalMap<int>::iterator interval = array.get(step->second);
+			  interval->second++;
+			}
+		}
+		int row = 0;
+
+		for (IntervalMap<int>::iterator interval = array.begin(); interval!= array.end(); ++interval)
+		{
+
+			matrix_[column+row*steps.size()] = interval->second*2; // in percentage!
+			row++;
+		}
+	    column++;
+	}
+
+	/*matrix_.set(steps_.size(), heights_.size());
+
+
+	for ( vector<double>::const_iterator height =heights_.begin(); height != heights_.end(); ++height) {
+				matrix_.rowsAxis().push_back(*height);
+	}	
+	MagLog::dev()<< " step-->" <<endl;
+	for ( vector<double>::const_iterator step = steps_.begin(); step != steps_.end(); ++step) {
+				matrix_.columnsAxis().push_back(*step);
+				MagLog::dev()<< *step << " ";
+			}
+			MagLog::dev()<< endl << "<--- step" <<endl;
+			matrix_.setMapsAxis();
+			int i = 0;
+			for ( int height = 0; height < heights_.size(); height++) {
+
+			    MagLog::dev()<< endl <<  heights_[height] << " " << steps_.size() << endl;
+				for ( int step = 0; step < steps_.size(); step++) {
+					matrix_.push_back(values_[(step*heights_.size()) + height]);
+					MagLog::dev()<< matrix_.back() << " ";
+				}
+			}
+				MagLog::debug() << matrix_ << endl;
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+	{
+			 MagLog::dev() << **point << endl;
+
+	}
+	*/
+	matrixHandlers_.push_back(new  MatrixHandler(matrix_));
+	return *(matrixHandlers_.back());
+}
+
+spot_query* SpotDecoder::newQuery() const
+{
+	return newQuery(database_);
+}
+
+spot_query* SpotDecoder::newQuery(const string& database) const
+{
+	MagLog::dev() << "Accessing Database ->" << database << endl;
+
+	if (! spot_) {
+			
+			spot_ = spot_open_database(database.c_str());
+	}
+	if ( !spot_ )
+	{
+		MagLog::error() << database << ": Not a valid Epsgram Database\n";
+		throw MagicsException(database +": Not a valid Epsgram Database");
+	}
+
+	spot_query*  query  =  spot_new_query(spot_);
+	spot_set_location (query, latitude_, longitude_);
+	MagLog::dev()<< "lat---> " << latitude_ << "lon-->" << longitude_ << endl;
+	spot_set_method(query,"EPSGRAM");
+
+    //MagLog::dev()<< "resol---> " << resol << endl;
+    //MagLog::dev() << "bathymetry---> " << bathymetry_ << endl;
+    
+ 
+     if (!date_.empty() ) {
+     	MagLog::dev() << "Set the date --->" << date_ << "\n";
+     	spot_set_parameter(query,"date", date_.c_str());
+     }
+   
+     if (!time_.empty() ) {
+     	MagLog::dev() << "Set the date --->" << time_ << "\n";
+     	spot_set_parameter(query,"time", time_.c_str());
+     }
+     
+	return query;
+}
+
+void EpsgramDecoder::set()
+{
+	 SpotDecoder::database_ = EpsgramDecoderAttributes::database_;
+	 SpotDecoder::station_ = EpsgramDecoderAttributes::station_;
+	 SpotDecoder::param_ = EpsgramDecoderAttributes::param_;
+	 SpotDecoder::latitude_ = EpsgramDecoderAttributes::latitude_;
+	 SpotDecoder::longitude_ = EpsgramDecoderAttributes::longitude_;
+	 SpotDecoder::type_ = EpsgramDecoderAttributes::type_;
+	 SpotDecoder::date_ = EpsgramDecoderAttributes::date_; 
+	 SpotDecoder::time_ = EpsgramDecoderAttributes::time_;
+	 SpotDecoder::height_ = EpsgramDecoderAttributes::height_;
+	 SpotDecoder::correction_ = EpsgramDecoderAttributes::correction_;
+	 SpotDecoder::param_title_ = EpsgramDecoderAttributes::param_title_;
+	 SpotDecoder::percentile_ = EpsgramDecoderAttributes::percentile_;
+	 SpotDecoder::threshold_ = EpsgramDecoderAttributes::threshold_;
+
+	 scaling_ = param_scaling_factor_;
+	 offset_ = param_offset_factor_;
+	 shift_ = param_hour_shift_;
+}
+
+EfigramDecoder::EfigramDecoder() : first_(true)
+{
+}
+
+EfigramDecoder::~EfigramDecoder()
+{
+}
+
+void EfigramDecoder::decode()
+{
+	vector<double> values;
+	if ( !first_ ) return;
+	first_ = false;
+
+	map<string, string> codes;
+	
+	codes["efi-precip"] = "143.128";
+	codes["efi-2mt-max"] = "121.128";
+	codes["efi-2mt-mean"] = "167.128";
+	codes["efi-2mt-min"] = "122.128";
+	codes["efi-wind-gust"] = "123.128";
+	codes["efi-wind"] = "165.128";
+    
+	int prefix = 1; 
+	string lastdate = "";
+	string lasttime = "";
+	int laststep = 0;
+
+	SpotDecoder::param_ = EfigramDecoderAttributes::param_;
+	SpotDecoder::latitude_ = EfigramDecoderAttributes::latitude_;
+	SpotDecoder::longitude_ = EfigramDecoderAttributes::longitude_;       		 
+	SpotDecoder::correction_ = false; // EfigramDecoderAttributes::correction_;
+	legends_.push_back("Climate t+ [24-48h]");
+	vector<int>::iterator step = EfigramDecoderAttributes::steps_.begin();
+
+	for (vector<string>::iterator date = dates_.begin(); date != dates_.end(); ++date )
+	{
+		SpotDecoder::steps_.clear();
+		SpotDecoder::steps_.push_back(*step);
+		int legend_step = *step +12;
+		SpotDecoder::database_ = EfigramDecoderAttributes::database_ + "/" + *date + "/epsdb";
+		SpotDecoder::prefix_ = tostring(prefix) + "_"; 
+
+		try {
+
+			date_ = "";
+			time_ = "";
+			step_ = *step;
+			SpotDecoder::decode(true);
+			values.push_back(parameter_->minx_);
+			values.push_back(parameter_->maxx_);
+
+			lastdate = date_;
+			lasttime = time_;
+			laststep = *step;
+
+			if ( EfigramDecoderAttributes::legend_ ==  false) 
+    				continue;
+			// Now the legend...	
+
+			if ( legend_database_.empty() )
+			{
+    				legends_.push_back("Climate t+ [24-48h]");
+    				return;
+			}
+
+			size_t len = 1024;
+			char tmp[1024];
+
+    			map<string, int> columns;
+    			map<int, int> rows;
+    			// build name of database!
+    			string database = legend_database_ + "/" + *date + "/epsdb";;
+    			MagLog::dev() << "Accessing Database for legend-->" << database << endl;
+    			spot_query* query = newQuery(database);		
+			spot_set_parameter(query,"param", codes[SpotDecoder::param_].c_str()); 
+			spot_query_result* result = spot_handle_query(query);	
+
+			// Get the columns names;
+			for(int i = 0 ; i < spot_get_column_count(result); i++)
+			{
+    				spot_get_column_name(result, i,tmp,&len);
+    				columns[tmp] = i;
+    				len = 1024;
+			}
+
+			double values[1024];
+			size_t nb = 1024;
+			// get the rows names
+			for(int i = 0 ; i < spot_get_row_count(result); i++)
+			{
+				spot_get_row_name(result, i,tmp,&len);   	
+				int x = atoi(tmp);
+				rows[x] = i;
+				len = 1024;    	
+			}	
+
+			string date = get_spot(result,"date");
+			string time = get_spot(result,"time");
+
+			DateTime base(date, MagTime(time));
+
+			ostringstream out;
+			tm convert = base;	
+			locale loc("");      
+			out.imbue(loc);   
+			const std::time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+			string format = "%e %b-%Hh";
+			tfac.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length()); 
+
+			ostringstream legend;
+
+			for (map<int, int>::const_iterator s = rows.begin(); s != rows.end(); ++s)
+			{	
+ 				spot_get_row(result, s->second,values,&nb);	
+				for (map<string, int>::const_iterator info = columns.begin(); info != columns.end(); ++info)
+				{
+					MagLog::dev() << "legend_step--> " << legend_step
+					           << "\nefi read --->" <<  s->first << " = " << values[info->second] << endl;
+					if ( s->first == legend_step )
+					{						
+						legend << "Eps t+ [" << legend_step - 24 << "-" << legend_step;			
+						legend << "h] ";		
+						efi_.push_back(int(maground(double(values[info->second]*100))));
+						MagLog::dev() << "efi--->" <<  values[info->second] << " " << efi_.back() << endl;
+					}
+				}
+			}
+			legends_.push_back(legend.str());
+
+			MagLog::dev() << "legend ---" <<  legends_.back() << endl;
+			spot_delete_result(result);
+			spot_delete_query(query);
+
+			//spot_close_database(spot_);
+			//	delete spot_;
+			spot_ = 0;
+			spot_ = 0;
+
+			prefix++;
+		}
+		catch (...) {
+			date_ = lastdate;
+			time_ = lasttime;
+			step_ = laststep;
+		}
+		++step;
+	}
+    
+
+       //Now the Clim! 
+	{
+		SpotDecoder::steps_.clear();
+		SpotDecoder::steps_.push_back(clim_step_);
+
+		SpotDecoder::database_ = EfigramDecoderAttributes::clim_database_ + "/" + clim_date_ + "/epsdb";
+		SpotDecoder::prefix_ = "clim_"; 
+    
+		try {
+			date_ = "";
+			time_ = "";
+			SpotDecoder::decode(true);
+			values.push_back(parameter_->minx_);
+    					values.push_back(parameter_->maxx_);
+		}
+		catch (...) {
+			MagLog::info() <<" No Clim" << endl;
+		}
+    	
+		date_ = lastdate;
+		time_ = lasttime;
+
+		if (values.empty() )
+		{
+		    minx_ = 0;
+		    maxx_ = 100;
+		}
+		else
+		{
+		    minx_ = *min_element(values.begin(), values.end());
+		    maxx_ = *max_element(values.begin(), values.end());
+		}
+        }
+}
+
+void EfigramDecoder::set()
+{
+	
+}
+
+#include "Polyline.h"
+#include "PaperPoint.h"
+
+
+
+void EfigramDecoder::visit(LegendVisitor& legend)
+{ 
+    legend.columns_ = 5;
+    for ( vector<string>::iterator entry = legends_.begin(); entry != legends_.end(); ++entry) {
+        LegendEntry *step = new LegendEntry(*entry);
+        legend.add(step);
+    }
+    for ( vector<string>::iterator entry = legends_.begin(); entry != legends_.end(); ++entry) {
+        
+        legend.add(new EmptyEntry());
+        legend.add(new EmptyEntry());
+    }    
+    EfiEntry* efi = new EfiEntry(-9999);
+    efi->style("title");
+    efi->textColour(*legend.colour_);
+    efi->textHeight(legend.getFont_size()); 
+	legend.add(efi);
+	
+	if ( legend_colours_.empty() ) {
+		legend_colours_.push_back("blue");
+	}
+    vector<string>::const_iterator colour = legend_colours_.begin();
+    for ( unsigned int i = 0; i < efi_.size(); i++) {
+        EfiEntry* efi = new EfiEntry(efi_[i]);
+        if ( i == 0 ) {
+            efi->style("top");
+        }
+        if ( i == efi_.size()-1 ) {
+            efi->style("bottom");
+        }
+	    efi->textColour(*legend.colour_);
+	    efi->textHeight(legend.getFont_size()); 
+	    efi->colour(Colour(*colour));
+	    efi->type(legend_type_);
+	    efi->normalColour(*legend_normal_colour_);
+	    efi->normalThickness(legend_normal_thickness_);
+	    legend.add(efi);
+	    vector<string>::const_iterator next = colour;
+	    ++next;
+	    if ( next != legend_colours_.end() ) 
+	    	++colour;
+	}
+}
+
+void EfigramDecoder::visit(TextVisitor& title)
+{
+	if ( !long_title_ && !title_) return;
+	try {
+		decode();
+	}
+	catch ( ... ) {
+		return;
+	}
+
+	if ( long_title_ )
+	{
+		DateTime base(date_, MagTime(time_));
+		DateTime from = base + Second((step_-12)*3600);
+		DateTime to = base + Second((step_+12)*3600);
+		MagLog::debug() << "HELOOOO-->Date/time ---> [" << date_ << ", " << time_ << ", " << step_ << "]\n";
+		ostringstream out;
+        
+		tm cfrom = from;	
+		tm cto = to;
+		locale loc("");      
+		out.imbue(loc);   
+		out << "valid for 24 hours from ";
+		const std::time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+		string format = "%A %e %B %Y %H UTC";
+		tfac.put(out, out, ' ', &cfrom, format.c_str(), format.c_str()+format.length()); 
+		out << " to ";
+		tfac.put(out, out, ' ', &cto, format.c_str(), format.c_str()+format.length()); 
+
+		ostringstream line;
+		UserPoint position(SpotDecoder::longitude_, SpotDecoder::latitude_);
+
+		line << "Forecast and M-Climate cumulative distribution functions with EFI values at " << position.asLatitude() << "/" << position.asLongitude() << endl;
+
+		title.add(new TextEntry(line.str()));
+		title.add(new TextEntry(out.str()));
+		title.add(new TextEntry(""));
+	}
+	if (parameter_) 
+		title.add(new TextEntry(parameter_->title()));
+}
+
+
+void EfigramDecoder::visit(MetaDataVisitor&)
+{
+}
+
+
+void SpotDecoder::visit(Transformation& transformation)
+{
+	try {
+		decode();
+	}
+	catch (...)
+	{
+		return;
+	}
+	assert(parameter_);
+	parameter_->setTransformation(transformation);
+}
+
+
+void EpsParameter::setTransformation(Transformation& transformation)
+{
+	transformation.setDataMinX(minx_, base_);
+	transformation.setDataMaxX(maxx_ + 12*3600, base_);
+	
+	if ( type_ == "eps15" ) {
+		transformation.setDataMaxX(maxx_ + 18*3600, base_);
+		transformation.setDataMinX(0, base_);
+	}
+	if ( type_ == "epswave" ) {
+		transformation.setDataMaxX(maxx_ + 6*3600, base_);
+		transformation.setDataMinX(0, base_);
+	}
+	if ( type_ == "epsrose" ) {
+		transformation.setDataMaxX(maxx_ + 18*3600, base_);
+		transformation.setDataMinX(0, base_);
+	}
+	if ( type_ == "eps10" ) {
+		transformation.setDataMaxX(maxx_ + 6*3600, base_);
+		transformation.setDataMinX(0, base_);
+	}
+	
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy_); 
+}
+    
+
+void EfigramDecoder::visit(Transformation& transformation)
+{	
+	decode();
+	transformation.setDataMinX(minx_);
+	transformation.setDataMaxX(maxx_);
+}
diff --git a/src/decoders/EpsgramDecoder.h b/src/decoders/EpsgramDecoder.h
new file mode 100644
index 0000000..f74b06c
--- /dev/null
+++ b/src/decoders/EpsgramDecoder.h
@@ -0,0 +1,261 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsgramDecoder.h
+    \brief Definition of the Template class EpsgramDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef EpsgramDecoder_H
+#define EpsgramDecoder_H
+
+#include "magics.h"
+
+#include "EpsgramDecoderAttributes.h"
+#include "EfigramDecoderAttributes.h"
+#include "EpsXmlInputAttributes.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "spot_database.h"
+#include "BasicSceneObject.h"
+#include "XmlReader.h"
+#include "DateTime.h"
+
+#include <limits>
+
+namespace magics {
+
+class XmlNode;
+class SpotDecoder;
+
+class EpsParameter
+{
+public:
+	EpsParameter();
+		
+	EpsParameter(const string& name, const string& title, const string& code) :
+		name_(name), code_(code),  title_(title), offset_(0), scaling_(1) {
+		minx_ = std::numeric_limits<double>::max();
+		maxx_ = -minx_;
+		miny_ = std::numeric_limits<double>::max();
+		maxy_ = -miny_;
+		if (title_.empty() ) title_ = code_;
+	}
+	virtual ~EpsParameter() {}
+	string height(); // return the height of the station... 
+	void   steps(const vector<double>& steps);
+	virtual double operator()(double value, const string&) const { return (value * scaling_) + offset_; } 
+	virtual double operator()(double) const { return -6; } 
+	const string& code() const  { return code_; }
+	virtual const string& title() const { return title_; }
+	virtual const string& xml() const { return xml_; }
+	void epsHeight(double epsz) { epsz_ = epsz; }
+	void deterministicHeight(double detz) { detz_ = detz; }
+	void stationHeight(double height) { height_ = height; }
+	void correction(bool correction) { correction_ = correction; }
+	void deterministicResolution(const string& resolution) { detResolution_ = resolution; }
+	void epsResolution(const string& resolution) { epsResolution_ = resolution; }
+    virtual spot_query_result* prepare(const SpotDecoder& decoder, vector<CustomisedPoint*>& out);
+    virtual void interpretResult(spot_query_result*, vector<CustomisedPoint*>&);
+    virtual void specific10(CustomisedPoint&) const;
+	virtual void specific15(CustomisedPoint&) const;
+	virtual int x(int val) const { return val; }
+	virtual string x(const string& prefix, const string& val) const;
+	virtual void setTransformation(Transformation&);
+	void scaling(double scaling) { scaling_ = scaling; }
+	void offset(double offset)   { offset_ = offset; }
+	void shift(double shift)   { shift_ = shift; }
+	virtual void stepvalues(double step, vector<double>& xpos) { xpos.push_back( step); }  
+	virtual void xvalues(double, vector<double>&) {}
+	virtual double  plumesInterval() { assert(false); } 
+	 
+void type(const string& type) { type_ = type; }
+protected:
+	string name_;
+	string code_;
+	mutable string title_;
+	mutable string xml_;
+	mutable double epsz_;
+	mutable double detz_;
+	mutable double step_;
+	double shift_;
+	double correction_;
+	mutable string detResolution_;
+	mutable string epsResolution_;
+	double height_;
+	string type_;
+	map<double, double> steps_;
+	typedef void (EpsParameter::*SpecificFunction)(CustomisedPoint&) const;
+	 map<string, EpsParameter::SpecificFunction> specifics_;
+	string base_;
+	 double minx_;
+	 double miny_;
+	 double maxx_;
+	 double maxy_;
+	 double offset_;
+	 double scaling_;
+	 double percentile_;
+	 double threshold_;
+	 string      prefix_;
+	 
+	 friend class SpotDecoder; 
+	 friend class EfigramDecoder; 
+};
+
+
+class SpotDecoder:
+			public Decoder,
+			public Data,
+			public PointsList  {
+public:
+	SpotDecoder();
+	virtual ~SpotDecoder();
+	
+	virtual void set(const map<string, string>&) 	{}
+	virtual void set(const XmlNode&) {}
+	
+	virtual void visit(Transformation&);
+	virtual void decode() { decode(false); }	
+	virtual void decode(bool);
+    spot_query* newQuery() const;
+	spot_query* newQuery(const string&) const;
+	
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	virtual PointsHandler& points();
+
+	void customisedPoints(const Transformation&, const std::set<string>& n, CustomisedPointsList& out, bool)
+	{ customisedPoints(n, out); }
+	PointsHandler& points(const Transformation&, bool) { return points(); }
+	virtual void visit(TextVisitor&);
+	//virtual void visit(MetaData&);
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 EpsParameter* parameter_;
+
+	 UserPoint grid_;
+	 double   mask_;
+	 double   detz_;
+	 double   epsz_;
+	 double   bathymetry_;
+	 string      prefix_;
+
+	 string   resolution_;
+	 mutable spot_config* spot_;
+	 vector<CustomisedPoint*> points_;
+	 virtual void moreTitle(TextVisitor&) const {}	
+	 
+	 
+	 string database_;
+	 string station_;
+	 string param_;
+	 string param_title_;
+	 double latitude_;
+	 double longitude_;
+	 string type_;
+	 string date_;
+	 string time_;
+	 double height_;
+	 bool correction_;
+	 vector<double> steps_;
+	 double scaling_;
+	 double offset_;
+	 double shift_;
+	 double percentile_;
+	 double threshold_;
+
+
+	 virtual void set() {}
+	 
+	 
+private:
+    //! Copy constructor - No copy allowed
+	SpotDecoder(const SpotDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	SpotDecoder& operator=(const SpotDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SpotDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsgramDecoder: public SpotDecoder, public EpsgramDecoderAttributes
+{
+public:
+	EpsgramDecoder();
+	virtual ~EpsgramDecoder();
+	
+	virtual void set(const XmlNode& node) 
+		{  EpsgramDecoderAttributes::set(node); set(); }
+	virtual void set(const map<string, string>& map) 
+		{  EpsgramDecoderAttributes::set(map); set(); }
+	virtual MatrixHandler& matrix();
+	
+
+protected:
+	Matrix matrix_;
+
+	
+    void moreTitle(TextVisitor&) const;	
+	
+	void visit(MetaDataVisitor&);
+	void set();
+
+	
+};
+
+class EfigramDecoder: public SpotDecoder, public EfigramDecoderAttributes
+{
+public:
+	EfigramDecoder();
+	virtual ~EfigramDecoder();
+
+	virtual void set(const map<string, string>& map) 
+		{  EfigramDecoderAttributes::set(map); set(); }
+	virtual void set(const XmlNode& node) 
+		{  EfigramDecoderAttributes::set(node); set(); }	
+	void set();
+	void visit(TextVisitor&);
+	void visit(MetaDataVisitor&);
+    virtual void visit(LegendVisitor&);
+    void visit(Transformation&);
+	virtual void decode();
+protected: 
+	vector<int> efi_;
+	vector<string> legends_;
+    bool first_;
+    int step_;
+    double minx_;
+   	 double maxx_;
+
+	
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/GeoPointsDecoder.cc b/src/decoders/GeoPointsDecoder.cc
new file mode 100644
index 0000000..b3768cf
--- /dev/null
+++ b/src/decoders/GeoPointsDecoder.cc
@@ -0,0 +1,319 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GeoPointsDecoder.cc
+    \brief Implementation of the Template class GeoPointsDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 12-Dec-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "GeoPointsDecoder.h"
+#include "SciMethods.h"
+
+using namespace magics;
+
+GeoPointsDecoder::GeoPointsDecoder()
+{
+}
+
+
+GeoPointsDecoder::~GeoPointsDecoder()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GeoPointsDecoder::print(ostream& out)  const
+{
+	out << "GeoPointsDecoder[";
+	out << "]";
+}
+
+void GeoPointsDecoder::add(const Transformation& transformation, UserPoint& geo)
+{
+    std::stack<UserPoint>   duplicates;
+	transformation.wraparound(geo, duplicates);
+	while (duplicates.empty() == false) {
+	    push_back(new UserPoint(duplicates.top()));
+	    duplicates.pop();
+	    stats_["value"].push_back(geo.value());
+	 }   	
+}
+
+void GeoPointsDecoder::add(const Transformation& transformation, CustomisedPoint& point)
+{
+	UserPoint geo(point.longitude(), point.latitude());
+	std::stack<UserPoint>   duplicates;
+	transformation.wraparound(geo, duplicates);
+
+	while (duplicates.empty() == false) {
+		UserPoint p = duplicates.top();
+		push_back(new UserPoint(p));
+		CustomisedPoint*  cp = new CustomisedPoint(p.x(), p.y(), point.identifier());
+		for ( CustomisedPoint::iterator key = point.begin(); key != point.end(); ++key)
+			cp->insert(make_pair(key->first, key->second));
+		customisedPoints_.push_back(cp);
+		duplicates.pop();
+		
+		//Compute speed for stats and histogram
+		map<string,double>::const_iterator itX=point.find("x_component");
+		map<string,double>::const_iterator itY=point.find("y_component");
+		if(itX != point.end() && itY != point.end())
+		{	
+			double speed=sqrt((itX->second)*(itX->second)+(itY->second)*(itY->second));
+			back()->value(speed);
+		  	stats_["value"].push_back(speed);
+		}	
+	}
+
+}
+
+void GeoPointsDecoder::yxdtlv2(const string& line, const Transformation& transformation)
+{
+	std::istringstream in(line);
+	double lat, lon, date, time, level, value;
+	in >> lat >> lon >> level >> date >> time >>  value;
+	UserPoint geo(lon, lat, value);
+	add(transformation, geo);
+}
+
+void GeoPointsDecoder::xyv2(const string& line, const Transformation& transformation)
+{
+	std::istringstream in(line);
+	double lat, lon, value;
+	in >> lon >> lat >> value;
+	UserPoint geo(lon, lat, value);
+	add(transformation, geo);
+	
+}
+void GeoPointsDecoder::lluv(const string& line, const Transformation& transformation)
+{
+	std::istringstream in(line);
+	double lat, lon, height, date, time, u, v;
+	in >> lat >> lon >> height >> date >> time >> u >> v;
+	CustomisedPoint geo(lon, lat, "lluv");
+	geo["x_component"] = u;
+	geo["y_component"] = v;
+	add(transformation, geo);
+
+}
+void GeoPointsDecoder::yxdtlv1(const string& line)
+{
+	std::istringstream in(line);
+	double lat, lon, date, time, level, value;
+	in >> lat >> lon >> level >> date >> time >>  value;
+
+	push_back(new UserPoint(lon, lat, value));
+}
+
+void GeoPointsDecoder::xyv1(const string& line)
+{
+	std::istringstream in(line);
+	double lat, lon, value;
+	in >> lon >> lat >> value;
+	push_back(new UserPoint(lon, lat, value));
+	
+}
+void GeoPointsDecoder::decode(const Transformation& transformation)
+{
+	if ( formats_.empty() ) {
+		formats_["XYV"] = &GeoPointsDecoder::xyv2;
+		formats_["LLV"] = &GeoPointsDecoder::xyv2;
+		formats_["XY_VECTOR"] = &GeoPointsDecoder::lluv;
+	}
+	
+	GeoPointsDecoder::Decode method = &GeoPointsDecoder::yxdtlv2;
+	
+	if ( !empty() ) return;
+	char line[1024];
+	try {
+		
+		ifstream in(path_.c_str());
+		while( in.getline( line, sizeof(line) ) ) {
+		      if( strncmp( line, "#DATA", 5 ) == 0 ) 
+		    	  break;
+		      if( strncmp( line, "#FORMAT ", 8 ) == 0 ) {
+		    	  const char* fp = line+7;
+		    	  while( fp && *fp == ' ' )
+		    		  	++fp;
+		    	  string format(fp);
+		    	  map<string, GeoPointsDecoder::Decode>::iterator m = formats_.find(format);
+		    	  method = ( m != formats_.end() ) ? m->second : &GeoPointsDecoder::yxdtlv2;
+		      }
+		    }
+
+		  while( in.getline( line, sizeof(line) ) ) {
+		      if( (*line != '#') && (strlen( line ) > 4) ) {
+		    	  (this->*method)(line, transformation);
+		      }
+		    }
+
+		//computeStats();
+
+		in.close();
+	}
+	catch (...)
+	{
+		MagLog::error() << "Geopoints file : can not open " << path_ << endl;
+	}
+	 
+	 
+}
+
+void GeoPointsDecoder::customisedPoints(const Transformation& transformation, const std::set<string>&, CustomisedPointsList& list)
+{
+
+	customisedPoints_.clear();
+
+	decode(transformation);
+
+	for ( vector<CustomisedPoint*>::iterator point = customisedPoints_.begin(); point != customisedPoints_.end(); ++point)
+		list.push_back(*point);
+
+
+
+}
+void GeoPointsDecoder::decode()
+{
+	if ( simple_formats_.empty() ) {
+		simple_formats_["XYV"] = &GeoPointsDecoder::xyv1;
+		simple_formats_["LLV"] = &GeoPointsDecoder::xyv1;
+	}
+	
+	GeoPointsDecoder::SimpleDecode method = &GeoPointsDecoder::yxdtlv1;
+	
+	if ( !empty() ) return;
+	char line[1024];
+	try {
+		
+		ifstream in(path_.c_str());
+		while( in.getline( line, sizeof(line) ) ) {
+		      if( strncmp( line, "#DATA", 5 ) == 0 ) 
+		    	  break;
+		      if( strncmp( line, "#FORMAT ", 8 ) == 0 ) {
+		    	  const char* fp = line+7;
+		    	  while( fp && *fp == ' ' )
+		    		  	++fp;
+		    	  string format(fp);
+		    	  map<string, GeoPointsDecoder::SimpleDecode>::iterator m = simple_formats_.find(format);
+		    	  method = ( m != simple_formats_.end() ) ? m->second : &GeoPointsDecoder::yxdtlv1;
+		      }
+		    }
+
+		  while( in.getline( line, sizeof(line) ) ) {
+		      if( (*line != '#') && (strlen( line ) > 4) ) {
+		    	  (this->*method)(line);
+		      }
+		    }
+
+		//computeStats();
+
+		in.close();
+	}
+	catch (...)
+	{
+		MagLog::error() << "Geopoints file : can not open " << path_ << endl;
+	}
+	 
+	 
+}
+
+void GeoPointsDecoder::initInfo()
+{
+	setInfo("_datatype","GEOPOINTS");
+	setInfo("path",path_);
+	setInfo("MV_Format","GEOPOINTS");
+	//setInfo("value",getValue());
+	//setInfo("x",getX());
+	//setInfo("y",getY());
+}
+
+void GeoPointsDecoder::visit(MetaDataCollector& mdc)
+{	
+	for(map<string, string>::iterator key = mdc.begin(); key != mdc.end(); ++key )
+	{	    
+		if(information_.find(key->first) == information_.end() &&
+		  mdc.attribute(key->first).group() == MetaDataAttribute::StatsGroup)
+		{
+			  computeStats();
+			  break;
+		}
+	}
+	
+	MetviewIcon::visit(mdc);
+}  
+
+void GeoPointsDecoder::visit(ValuesCollector& points)
+{
+	points.setCollected(true);
+  	 
+	if(points.size() <=0 || size() == 0)
+	  	return;
+	
+	//if(value_.empty())
+	//	points.setHasValue(false);
+		
+	for (ValuesCollector::iterator point =  points.begin(); point != points.end(); ++point)
+	{
+	  	double lat=(*point).y();
+	  	double lon=(*point).x();
+		
+		vector<int> idxV;		
+		for(int i=0; i < size(); i++)
+		{
+			if(fabs(at(i)->y()-lat) < points.searchRadiusY() &&
+			   fabs(at(i)->x()-lon) <  points.searchRadiusX())
+			{
+			  	idxV.push_back(i);
+			}
+		}
+		
+		if(idxV.size() ==0)
+			continue;  
+		
+		double dist=10000000.;
+		int minIdx=-1;
+		
+		//MagLog::debug() << "odb collect idxV : " << lat << " " << lon << " " << idxV.size() << endl;
+ 		
+		for(int i=0; i < idxV.size(); i++)
+		{  			
+		  	int idx=idxV[i];
+			double d=magics::geoDistanceInKm(at(idx)->y(),at(idx)->x(),lat,lon);
+			
+			if(d < dist)
+			{
+			  	minIdx=idx;
+				dist=d;
+			}			
+		}	
+		if(minIdx>=0)  
+			(*point).push_back(new ValuesCollectorData(at(minIdx)->x(),
+							       at(minIdx)->y(),
+							       at(minIdx)->value(),
+							       dist));					     			
+	}	  
+}
diff --git a/src/decoders/GeoPointsDecoder.h b/src/decoders/GeoPointsDecoder.h
new file mode 100644
index 0000000..2dcd8d1
--- /dev/null
+++ b/src/decoders/GeoPointsDecoder.h
@@ -0,0 +1,112 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GeoPointsDecoder.h
+    \brief Definition of the Template class GeoPointsDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 12-Dec-2005
+    
+    Changes:
+    
+*/
+
+#ifndef GeoPointsDecoder_H
+#define GeoPointsDecoder_H
+
+#include "magics.h"
+
+#include "GeoPointsDecoderAttributes.h"
+#include "Data.h"
+#include "Decoder.h"
+#include "UserPoint.h"
+
+namespace magics {
+	
+class XmlNode;
+
+class GeoPointsDecoder: public GeoPointsDecoderAttributes,
+		public Data, public Decoder, public PointsList {
+
+public:
+	GeoPointsDecoder();
+	virtual ~GeoPointsDecoder();
+	   //! Method to access the data as a list of points : Used by psymb.
+   
+     virtual void decode(const Transformation&);
+     virtual void decode();
+     void set(const map<string, string>& map ) { GeoPointsDecoderAttributes::set(map); }
+	 void set(const XmlNode& node ) { GeoPointsDecoderAttributes::set(node); }
+
+  
+    
+	 PointsHandler& points()  {
+	     	decode();
+	     	pointsHandlers_.push_back(new PointsHandler(*this));
+	     	return *(pointsHandlers_.back());
+	     } 
+    PointsHandler& points(const Transformation& transformation)  {
+    	decode(transformation);
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    } 
+    
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& );
+
+    void add(const Transformation&, UserPoint&); 
+    void add(const Transformation&, CustomisedPoint&);
+    void yxdtlv2(const string&, const Transformation&);
+    void xyv2(const string&, const Transformation&);
+    void yxdtlv1(const string&);
+    void xyv1(const string&s);
+
+    void polar(const string&, const Transformation&);
+    void lluv(const string&, const Transformation&); 
+    void initInfo();
+    void visit(MetaDataCollector&);
+    void visit(ValuesCollector&);
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+       {
+       	customisedPoints(t, n, out);
+       }
+       PointsHandler& points(const Transformation& t, bool) { return points(t); }
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 typedef void (GeoPointsDecoder::*SimpleDecode)(const string&);
+	 typedef void (GeoPointsDecoder::*Decode)(const string&, const Transformation&);
+	 std::map<string, Decode> formats_;
+	 std::map<string, SimpleDecode> simple_formats_;
+	 vector<CustomisedPoint*> customisedPoints_;
+private:
+    //! Copy constructor - No copy allowed
+	GeoPointsDecoder(const GeoPointsDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	GeoPointsDecoder& operator=(const GeoPointsDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GeoPointsDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/GeoPointsDecoderAttributes.h b/src/decoders/GeoPointsDecoderAttributes.h
new file mode 100644
index 0000000..40f2952
--- /dev/null
+++ b/src/decoders/GeoPointsDecoderAttributes.h
@@ -0,0 +1,81 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file GeoPointsDecoderAttributes.h
+    \brief Definition of GeoPointsDecoder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef GeoPointsDecoderAttributes_H
+#define GeoPointsDecoderAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class GeoPointsDecoderAttributes 
+{
+public:
+//  --  constructor
+    GeoPointsDecoderAttributes();
+    
+//  --  destructor
+    virtual ~GeoPointsDecoderAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const GeoPointsDecoderAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string path_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const GeoPointsDecoderAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/GribAddressMode.h b/src/decoders/GribAddressMode.h
new file mode 100644
index 0000000..9b44bef
--- /dev/null
+++ b/src/decoders/GribAddressMode.h
@@ -0,0 +1,166 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribAddressMode.h
+    \brief Definition of the Template class GribAddressMode.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Mon 13-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef GribAddressMode_H
+#define GribAddressMode_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+#include "grib_api.h"
+
+
+namespace magics {
+
+class XmlNode;
+
+class GribAddressMode {
+
+public:
+	GribAddressMode() {}
+	virtual ~GribAddressMode() {}
+    
+    virtual void set(const XmlNode&) {
+		
+    }
+    virtual void set(const map<string, string>&) {
+    }
+    
+     virtual bool accept(const string&) { return false; }
+    
+    virtual GribAddressMode* clone() const {
+        MagLog::dev() << "GribAddressMode::set(const map<string, string&)---> to be checked!...\n";
+        return new GribAddressMode();
+    }
+    virtual void toxml(ostream&, int = 0) const {
+        MagLog::dev() << "GribAddressMode::toxml(ostream&, int = 0)---> to be checked!...\n";
+    }
+    virtual grib_handle* operator()(grib_context*, FILE*, int) const {
+        MagLog::dev() << "GribAddressMode::toxml(ostream&, int = 0)---> to be checked!...\n";
+        return 0;
+    }
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "GribAddressMode\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	GribAddressMode(const GribAddressMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	GribAddressMode& operator=(const GribAddressMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribAddressMode& p)
+		{ p.print(s); return s; }
+
+};
+
+class GribAddressRecordMode : public GribAddressMode
+{
+public :
+	GribAddressRecordMode() {}
+	~GribAddressRecordMode() {}
+
+	virtual GribAddressMode* clone() const {
+		GribAddressMode* mode = new GribAddressRecordMode();
+		return mode;
+	}
+
+	virtual grib_handle* operator()(grib_context* context, FILE* file, int position) const
+	{
+		grib_handle* handle = 0;
+
+
+		int error;
+		for (int i = 0; i < position-1; i++)
+		{
+			//MagLog::debug() << "call to grib_handle_new_from_file for position " << i << "\n";
+			handle = grib_handle_new_from_file(context, file, &error) ; 
+			grib_handle_delete(handle);
+		}
+		handle = grib_handle_new_from_file(context, file, &error) ; 
+		//grib_handle_delete(handle);
+
+		return handle;
+	}
+    
+protected :
+	void print(ostream& out) const { out << "GribAddressRecordMode\n"; }
+};
+
+class GribAddressByteMode : public GribAddressMode
+{
+public:
+	GribAddressByteMode() {}
+	~GribAddressByteMode() {}
+	virtual GribAddressMode* clone() const {
+		GribAddressMode* mode = new GribAddressByteMode();
+		return mode;
+	}
+	
+	virtual grib_handle* operator()(grib_context* context, FILE* file, int position) const
+	{
+		fseek(file, position, SEEK_SET);
+        grib_handle* handle = 0;
+
+		int error;
+		handle = grib_handle_new_from_file(context, file, &error) ;
+         return handle;
+           
+    }
+    
+protected :
+    void print(ostream& out) const { out << "GribAddressRecordMode\n"; } 
+    
+};
+
+
+
+template <>
+class MagTranslator<string, GribAddressMode> { 
+public:
+	GribAddressMode* operator()(const string& val )
+	{
+		return SimpleObjectMaker<GribAddressMode>::create(val);
+	}     
+
+	GribAddressMode* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/GribDecoder.cc b/src/decoders/GribDecoder.cc
new file mode 100644
index 0000000..acceee2
--- /dev/null
+++ b/src/decoders/GribDecoder.cc
@@ -0,0 +1,2030 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribDecoder.cc
+    \brief Implementation of the Template class GribDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 16-Mar-2004
+    
+    Changes:
+    
+*/
+ 
+#include "GribDecoder.h"
+#include "Factory.h"
+#include <limits>
+#include "TitleTemplate.h"
+#include "LocalTable.h"
+#include "DateTime.h"
+#include "GribTables.h"
+#include "GribInterpretor.h"
+#include "XmlReader.h"
+#include "TextVisitor.h"
+#include "Timer.h"
+#include "VisualAction.h"
+#include "AnimationRules.h"
+#include "Transformation.h"
+
+
+using namespace magics;
+grib_context* GribDecoder::context_ = 0;
+int  GribDecoder::count_ = 0;
+
+GribDecoder::GribDecoder() :  matrix_(0),  xComponent_(0), yComponent_(0),
+		colourComponent_(0), handle_(0), interpretor_(0)
+{
+	count_++;
+	title_ = "grib_" + tostring(count_);
+	version();
+}
+
+void GribDecoder::version()
+{
+	static bool done = false;
+	if ( done ) return;
+	done = true;
+	MagLog::info() << "GribAPI Version :" << grib_get_api_version() << endl;
+}
+
+GribDecoder::~GribDecoder() 
+{
+	if ( matrix_) delete matrix_;
+	if ( xComponent_ ) delete xComponent_;
+	if ( yComponent_ ) delete yComponent_;
+	if ( handle_ ) grib_handle_delete (handle_);
+	for (PointsList::iterator point = points_.begin(); point != points_.end(); ++point) {
+		delete *point;
+		*point = 0;
+	}
+	if ( interpretor_ ) delete interpretor_;
+
+	//context is a reference to a global context and should not be deleted
+}
+
+void GribDecoder::set(const GribLoop& loop, int index)
+{
+	// Copy the information about scaling...
+	scaling_         = loop.scaling_;
+	derived_scaling_ = loop.derived_scaling_;
+	scaling_offset_  = loop.scaling_offset_;
+	scaling_factor_  = loop.scaling_factor_;
+	index_           = loop.uniqueId_;
+	wind_mode_       = auto_ptr<WindMode>(loop.wind_mode_->clone());
+	internalIndex_ = index;
+
+}
+
+long GribDecoder::getLong(const string& key, bool warnIfKeyAbsent) const
+{
+	assert (context_);
+	long val;
+	int err = grib_get_long(handle_, key.c_str(), &val);
+	if ( err )
+	{
+		if (warnIfKeyAbsent)
+		{
+			MagLog::warning() << "Grib API: can not find key [" << key << "]\n"
+			               << grib_get_error_message(err) <<"\n";
+		}
+		return 0;
+	}
+	return val;
+}
+
+string GribDecoder::getstring(const string& key, bool warnIfKeyAbsent) const
+{
+	assert (context_); 
+	char val[1024];
+	size_t length = 1024;
+	int err = grib_get_string(handle_, key.c_str(), val, &length);
+	if ( err )
+	{
+		if (warnIfKeyAbsent)
+		{
+				MagLog::warning() << "Grib API: can not find key [" << key << "]\n"
+				               << grib_get_error_message(err) <<"\n";
+			}
+			return "";
+		}
+		return string(val);
+}
+
+string GribDecoder::getString(const string& key, bool warnIfKeyAbsent) const
+{
+
+	if ( Data::dimension_ == 1 )
+		return getstring(key, warnIfKeyAbsent);
+
+	string value;
+	grib_handle* handle = handle_;
+	// otherwise we build a name...
+
+	GribDecoder* grib = const_cast<GribDecoder*>(this);
+	grib->openFirstComponent();
+	string name1 = getstring(key, warnIfKeyAbsent);
+	grib->openSecondComponent();
+	string name2 = getstring(key, warnIfKeyAbsent);
+	grib->handle_ = handle;
+	value = (name1==name2) ? name1 : name1 + "/" + name2;
+
+	if ( Data::dimension_ == 3 ) {
+		grib->openThirdComponent();
+		string name3 = getstring(key, warnIfKeyAbsent);
+		grib->handle_ = handle;
+		if ( value != name3 )
+			value = value + "/" + name3;
+	}
+	return value;
+}
+
+
+double GribDecoder::getDouble(const string& key, bool warnIfKeyAbsent) const
+{
+	assert (context_); 
+	double val;
+	int err = grib_get_double(handle_, key.c_str(), &val);
+	if ( err )
+	{
+		if (warnIfKeyAbsent)
+		{
+			MagLog::warning() << "Grib API: can not find key [" << key << "]\n"
+			               << grib_get_error_message(err) <<"\n";
+		}
+		return 0;
+	}
+	return val;
+}
+
+
+void   GribDecoder::setDouble(const string& key, double val) const
+{
+	assert (context_);
+	int err = grib_set_double(handle_, key.c_str(), val);
+	if ( err )
+	{
+		MagLog::warning() << "Grib API: can not find key [" << key << "]\n"
+		               << grib_get_error_message(err) <<"\n";
+	}
+}
+
+
+void GribDecoder::read(Matrix **matrix)
+{
+
+	if ( handle_ <=0 ) {
+		*matrix = 0;
+		return;
+	}
+	long repres;
+	grib_get_long(handle_,"dataRepresentationType",&repres);
+	const string representation = getString("typeOfGrid");
+
+	try {
+		if ( !interpretor_ ) {
+			interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+		}
+		interpretor_->interpretAsMatrix(*this, matrix);
+		interpretor_->scaling(*this, matrix);
+	}
+	catch (NoFactoryException&)
+	{
+		MagLog::error() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+		throw MagicsException("Grib Decoder: Representation [] not yet supported.");
+	}
+}
+
+
+void GribDecoder::read(Matrix **matrix, const Transformation&  transformation)
+{
+	if ( handle_ <=0 ) {
+		*matrix = 0;
+		return;
+	}
+	long repres;    
+	grib_get_long(handle_,"dataRepresentationType",&repres);
+	const string representation = getString("typeOfGrid");
+
+	try {
+		if ( !interpretor_ ) {
+					interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+				}
+		interpretor_->interpretAsMatrix(*this, matrix, transformation);
+		interpretor_->scaling(*this, matrix);
+	}
+	catch (NoFactoryException&)
+	{
+		MagLog::error() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+		throw MagicsException("Grib Decoder: Representation [] not yet supported.");
+	}
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GribDecoder::print(ostream& out)  const
+{
+	out << "GribDecoder[";
+	GribDecoderAttributes::print(out);
+	out << "] ";
+}
+
+void GribDecoder::release()
+{
+	if ( matrix_ ) {
+		delete matrix_;
+		matrix_ = 0;
+	}
+	if ( xComponent_ ) {
+		delete xComponent_;
+		xComponent_ = 0;
+	}
+	if ( yComponent_ ) {
+		delete yComponent_;
+		yComponent_ = 0;
+	}
+	if ( colourComponent_ ) {
+			delete colourComponent_;
+			colourComponent_ = 0;
+		}
+
+	for (PointsList::iterator point = points_.begin(); point != points_.end(); ++point) {
+				delete *point;
+				*point = 0;
+		}
+	points_.clear();
+}
+
+void GribDecoder::decode2D() 
+{
+
+	if (xComponent_) return;
+	Matrix     *w1 = 0;
+	Matrix     *w2 = 0;
+	colourComponent_ = 0;
+	const string representation = getString("typeOfGrid");
+	try {
+
+		if ( !interpretor_ ) {
+					interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+		}
+		interpretor_->keepOriginal(true);
+
+	}
+	catch (NoFactoryException&)
+	{
+		MagLog::warning() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+
+	}
+	readColourComponent();
+	openFirstComponent();
+	read(&w1);
+	openSecondComponent();
+	read(&w2);
+    Data::dimension_ = ( colourComponent_ ) ? 3 : 2;
+
+
+
+	wind_mode_->x(&xComponent_, &yComponent_, w1, w2);
+	interpretor_->keepOriginal(false);
+}
+
+
+void GribDecoder::customisedPoints(const AutomaticThinningMethod& thinning, const Transformation& transformation, const std::set<string>& request, CustomisedPointsList& points)
+{
+	if ( !context_ ) return;
+	int factor = thinning.points();
+	
+	openFirstComponent();
+	long repres;    
+	grib_get_long(handle_,"dataRepresentationType",&repres);
+	const string representation = getString("typeOfGrid");
+	try {
+		if ( !interpretor_ ) {
+					interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+				}
+		// Try to find the XResolution ...
+		// Compute the thinning factor...
+		double yres = interpretor_->XResolution(*this);
+		double height = transformation.height();
+		factor = maground((height/factor) / yres);
+		if (factor < 1) factor = 1;
+		
+		thinning.units(yres*factor);
+
+		if ( factor == 1)
+		{
+			CustomisedPointsList xvalues, yvalues, cvalues;
+			string xc = "x_component";
+			string yc = "y_component";
+			string cc = "colour_component";
+			interpretor_->raw(*this, transformation, xc, xvalues);
+			readColourComponent();
+			if ( colourComponent_ )
+				interpretor_->raw(*this, transformation, cc, cvalues);
+
+			openSecondComponent();
+			interpretor_->raw(*this, transformation, yc, yvalues);
+
+			CustomisedPointsList::iterator x = xvalues.begin();
+			CustomisedPointsList::iterator y = yvalues.begin();
+			CustomisedPointsList::iterator c = cvalues.begin();
+			while ( x != xvalues.end() && y!= yvalues.end() )
+			{
+				CustomisedPoint* point = new CustomisedPoint((*x)->longitude(), (*x)->latitude(), "");
+				pair<double, double> val = (*wind_mode_)( (**x)[xc], (**y)[yc]);
+				point->insert(make_pair(xc, val.first));
+				point->insert(make_pair(yc, val.second));
+				if ( c != cvalues.end() ) {
+					point->insert(make_pair(cc, (**c)[cc]));
+					c++;
+				}
+				
+				points.push_back(point);
+				x++;
+				y++;
+			}
+		}
+		else {
+			if ( thinning.rawOnly() == false ) {
+				BasicThinningMethod basic;
+				basic.factor(factor);
+				thinning.units(yres*factor);
+				customisedPoints(basic, transformation, request, points);
+			}
+		}
+	}
+	catch (NoFactoryException&)
+	{
+		MagLog::error() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+		throw MagicsException("Grib Decoder: Representation [] not yet supported.");
+	}
+}
+
+
+void newPoint(const Transformation& transformation, double lat, double lon, double uc, double vc, double cc, vector<CustomisedPoint*>& points)
+{
+
+
+
+
+	  std::stack<UserPoint>   duplicates;
+  	  UserPoint geo(lon, lat);
+
+
+  	 transformation.wraparound(geo, duplicates);
+		 while (duplicates.empty() == false) {
+			UserPoint pt = duplicates.top();
+
+			CustomisedPoint *point = new CustomisedPoint(pt.x(), pt.y(), "");
+
+			point->insert(make_pair("x_component", uc));
+            point->insert(make_pair("y_component", vc));
+		    points.push_back(point);
+		    if ( cc != -9999 ) {
+				point->insert(make_pair("colour_component", cc));
+
+			}
+
+			duplicates.pop();
+		 }
+}
+
+void GribDecoder::customisedPoints(const BasicThinningMethod& thinning, const Transformation& transformation, const std::set<string>&, CustomisedPointsList& points)
+{
+	if ( !context_ ) return;
+
+	decode2D();
+	MatrixHandler* inx = new MatrixHandler(*xComponent_);
+	MatrixHandler* iny = new MatrixHandler(*yComponent_);
+	MatrixHandler* inc = 0;
+	if ( colourComponent_ )
+		inc = new MatrixHandler(*colourComponent_);
+	vector<UserPoint> thinx;
+	vector<UserPoint> thiny;
+	vector<UserPoint> thinc;
+		
+	int factor = thinning.factor();
+	
+	double xres = inx->XResolution();
+	
+
+	thinning.units(xres*factor);
+	
+	transformation.thin(*inx, factor, factor, thinx);
+	transformation.thin(*iny, factor, factor, thiny);
+	if ( inc )
+		transformation.thin(*inc, factor, factor, thinc);
+
+	vector<UserPoint>::const_iterator x = thinx.begin();
+	vector<UserPoint>::const_iterator y = thiny.begin();
+	vector<UserPoint>::const_iterator c = thinc.begin();
+	if (thinx.empty()) return;
+	while (x->value() == inx->missing() ||   y->value() == iny->missing()) {
+		++x;
+		++y;
+		if ( c != thinc.end() ) ++c;
+		if (x == thinx.end() || y == thiny.end())
+			return;
+	}
+	double lat = x->y();
+	double lon = x->x();
+	double uc= x->value();
+	double vc = y->value();
+	double cc =  c != thinc.end() ? c->value() : -9999;
+	interpretor_->interpret2D(lat, lon, uc, vc);
+	newPoint(transformation, lat, lon, uc, vc, cc, points);
+
+	
+	double lastx = lon;
+
+	x++;
+	y++;
+	while ( x != thinx.end() && y != thiny.end() )
+	{
+		double lat = x->y();
+		double lon = x->x();
+		if ( x->value() != inx->missing() &&  y->value() != iny->missing() )
+		{
+
+			double uc= x->value();
+			double vc = y->value();
+			double cc =  c != thinc.end() ? c->value() : -9999;
+			interpretor_->interpret2D(lat, lon, uc, vc);
+
+			newPoint(transformation, lat, lon, uc, vc, cc, points);
+
+
+		}
+		lastx = lon;
+		x++;
+		y++;
+		if ( !thinc.empty() && c != thinc.end() ) ++c;
+	} 
+
+}
+
+void GribDecoder::decode2D(const Transformation&) 
+{	
+	Data::dimension_ = 2;
+	if (xComponent_) return;
+	Matrix     *w1 = 0;
+	Matrix     *w2 = 0;
+
+
+
+	const string representation = getString("typeOfGrid");
+
+	try {
+		if ( !interpretor_ ) {
+					interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+				}
+		readColourComponent();
+
+			openFirstComponent();
+			read(&w1);
+			openSecondComponent();
+			read(&w2);
+
+	}
+	catch (NoFactoryException&)
+	{
+		MagLog::warning() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+
+	}
+
+	wind_mode_->x(&xComponent_, &yComponent_, w1, w2);
+}
+
+
+void GribDecoder::openFirstComponent() 
+{
+	grib_field_position_ =  position_1_;
+	open();
+}
+
+
+void GribDecoder::openSecondComponent() 
+{
+	grib_field_position_ =  position_2_;
+	open();
+}
+void GribDecoder::openThirdComponent()
+{
+	grib_field_position_ =  colour_position_;
+	open(false);
+}
+void GribDecoder::readColourComponent()
+{
+	grib_field_position_ =  colour_position_;
+	try {
+		open(false);
+		read(&colourComponent_);
+	}
+
+	catch (...) {
+		colourComponent_ = 0;
+	}
+
+
+
+}
+
+void  GribDecoder::open(bool sendmsg)
+{
+	FILE* file = fopen(file_name_.c_str(),"r");
+	handle_ = 0;
+	if (!file)
+	{
+		MagLog::error() << "file can not be opened [" << file_name_ << "]" <<endl;
+		//throw GribFileMagException(file_name_, grib_field_position_);
+		//throw exception();
+		return;
+	}
+	if (!context_) 
+		context_ =  grib_context_get_default();
+
+	handle_ = (*address_mode_)(context_, file, grib_field_position_);
+
+	if (handle_<=0 )
+	{
+		if (sendmsg)
+			MagLog::error() << "can not access position [" << grib_field_position_<<" in " << file_name_ << "]" <<endl;
+	//	throw GribFileMagException(file_name_, grib_field_position_);
+	}
+}
+
+
+bool GribDecoder::id(const string& id) const 
+{
+	return magCompare(id_, id);
+}
+
+
+void GribDecoder::decodePoints()
+{
+	if ( !points_.empty() ) return;
+	unsigned long flags=0;
+	int error;
+
+	if ( Data::dimension_ == 1 ) {
+		double scaling;
+		double offset;
+		open();
+		const string representation = getString("typeOfGrid");
+		double missing = getDouble("missingValue");
+		try {
+			if ( !interpretor_ ) {
+						interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+					}
+			interpretor_->scaling(*this, scaling, offset);
+		}
+		catch (NoFactoryException&)
+		{
+			MagLog::warning() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+			scaling =1 ; offset =0;
+		}
+
+		grib_iterator* iter = grib_iterator_new(handle_, flags, &error);
+
+
+
+		if (!iter)
+		{
+			MagLog::error() << "Grib Iterator not yet supported on this kind of grib\n";
+			throw MagicsException("Grib Iterator not yet supported.");
+		}
+
+		double lat;
+		double lon;
+		double val;
+		while (grib_iterator_next(iter,&lat,&lon,&val))
+		{
+			if ( val != missing)
+				points_.push_back(new UserPoint(lon, lat, (val*scaling) + offset));
+		}
+		return;
+	}
+
+	openFirstComponent();
+	const string representation = getString("typeOfGrid");
+	double missing = getDouble("missingValue");
+
+	grib_iterator* iter1 = grib_iterator_new(handle_, flags, &error);
+	openSecondComponent();
+	grib_iterator* iter2 = grib_iterator_new(handle_, flags, &error);
+	if (!iter1 || !iter2)
+	{
+		MagLog::error() << "Grib Iterator not yet supported on this kind of grib\n";
+		throw MagicsException("Grib Iterator not yet supported.");
+	}
+
+	double lat1, lat2;
+	double lon1, lon2;
+	double val1, val2, norm;
+	while ( grib_iterator_next(iter1,&lat1,&lon1,&val1) && grib_iterator_next(iter2,&lat2,&lon2,&val2) )
+	{
+		if ( lat1 == lat2 && lon1 == lon2 )
+			if ( val1 != missing && val2 != missing) {
+				norm=wind_mode_->norm(val1,val2);
+				points_.push_back(new UserPoint(lon1, lat1, norm));
+			}
+	}	
+}
+
+
+grib_context* GribDecoder::gribContext() 
+{
+	if (!context_)
+		context_ = grib_context_get_default();
+	return context_;
+}
+
+
+GribLoop::~GribLoop()
+{
+    for (vector<GribDecoder*>::const_iterator g = gribs_.begin(); g != gribs_.end(); ++g)
+    {
+        delete *g;
+    }
+}
+
+
+Data* GribLoop::current()
+{
+	return currentgrib_;
+}
+
+
+map<string, string> GribLoop::ids_;
+int GribLoop::index_ = 0;
+void GribLoop::next() {}
+
+
+GribLoop::GribLoop():  currentgrib_(0), file_(0)
+{
+	currentDim_ = dimension_.begin();
+	currentPos_ = dim_.begin();
+	gribs_.clear();
+	uniqueId_ = Data::getUniqueOwnerId();
+	counter_ = 0;
+}
+
+
+void GribLoop::setToFirst() 
+{
+	currentDim_ = dimension_.begin();
+	currentPos_ = dim_.begin();
+
+}
+
+
+bool  GribLoop::hasMore()
+{
+
+	if (file_ == 0 ) {
+		file_ = fopen(path_.c_str(),"r");
+		if (!file_) {
+			MagLog::error() << "file can not be opened [" << path_ <<  "]" <<endl;
+			throw GribFileMagException(path_, 0);
+		}	
+	}
+	
+    grib_context* context = GribDecoder::gribContext();
+    
+    // Now we have to find the right Entry!!! 
+    
+
+   if ( currentDim_ == dimension_.end() )
+	   return false;
+    
+   
+    if ( *currentDim_ == 1 ) {
+    	if (  dim_.empty() ) {
+    		 // case 1 dimension= 1 and loop on all the fields! 
+    		int error;
+    		grib_handle* handle = grib_handle_new_from_file(context, file_, &error) ; 
+    		if (handle <=0)
+    			return false;
+    		currentgrib_ = new GribEntryDecoder(handle);
+
+    		currentgrib_->set(*this, counter_++);
+
+            gribs_.push_back(currentgrib_);
+    	}
+    	else {
+    		if ( currentPos_ == dim_.end() )
+    			return false;
+    		 // Case 3 Dimension = 1 but we only used  a subset of fields
+
+    		grib_handle* handle =  (*address_mode_)(context, file_, *currentPos_);
+    		currentPos_++;
+    		if (handle <=0)  
+    			return false;
+    		currentgrib_ = new GribEntryDecoder(handle);
+    		currentgrib_->set(*this, counter_++);
+            gribs_.push_back(currentgrib_);
+    	}
+    }
+    
+   
+    if ( *currentDim_  == 2)
+    {
+    	if ( dim_.empty()  )
+    	{
+    		// case 2 Dimension = 2 and loop on all the field!
+    		int error;
+    		grib_handle* handle1 = grib_handle_new_from_file(context, file_, &error) ;
+    		if (handle1 <=0)  return false;
+    		grib_handle* handle2 = grib_handle_new_from_file(context, file_, &error) ;
+    		if (handle2 <=0)  return false;
+    		currentgrib_ = new GribEntryDecoder(handle1, handle2);
+    		currentgrib_->set(*this, counter_++);
+    		gribs_.push_back(currentgrib_);
+    	}
+    	else {
+    		// Case 4 Dimesnion = 2 and we only used a subset of fields!
+    		vector<int>::iterator dim1 =  currentPos_;
+    		if ( currentPos_ ==  dim_.end() )
+    			return false;
+    		currentPos_++;
+    		vector<int>::iterator dim2 =  currentPos_;
+    		if ( currentPos_ ==  dim_.end() )
+    			return false;
+    		currentPos_++;
+
+
+    		grib_handle* handle1 =  (*address_mode_)(context, file_, *dim1);
+    		grib_handle* handle2 =  (*address_mode_)(context, file_, *dim2);
+    		if ( handle1 <=0 )
+    			return false;
+    		if ( handle2 <=0 )
+    			return false;
+    		currentgrib_ = new GribEntryDecoder(handle1, handle2);
+    		currentgrib_->set(*this, counter_++);
+
+    		gribs_.push_back(currentgrib_);
+
+    	}
+    }
+
+	if ( *currentDim_  == 3)
+		{
+			if ( dim_.empty()  )
+			{
+				// case 2 Dimension = 2 and loop on all the field!
+	    			int error;
+	       			grib_handle* handle1 = grib_handle_new_from_file(context, file_, &error) ;
+	       			if (handle1 <=0)  return false;
+	       			grib_handle* handle2 = grib_handle_new_from_file(context, file_, &error) ;
+	        		if (handle2 <=0)  return false;
+	        		grib_handle* handle3 = grib_handle_new_from_file(context, file_, &error) ;
+	        		if (handle3 <=0)  return false;
+	        		currentgrib_ = new GribEntryDecoder(handle1, handle2, handle3);
+	        		currentgrib_->set(*this, counter_++);
+	        		gribs_.push_back(currentgrib_);
+			}
+			else {
+	        		// Case 4 Dimesnion = 2 and we only used a subset of fields!
+					vector<int>::iterator dim1 =  currentPos_;
+					if ( currentPos_ ==  dim_.end() )
+						return false;
+					currentPos_++;
+					vector<int>::iterator dim2 =  currentPos_;
+					if ( currentPos_ ==  dim_.end() )
+						return false;
+					currentPos_++;
+					vector<int>::iterator dim3 =  currentPos_;
+										if ( currentPos_ ==  dim_.end() )
+											return false;
+										currentPos_++;
+
+	        		grib_handle* handle1 =  (*address_mode_)(context, file_, *dim1);
+	        		grib_handle* handle2 =  (*address_mode_)(context, file_, *dim2);
+	        		grib_handle* handle3 =  (*address_mode_)(context, file_, *dim3);
+
+	        		if ( handle1 <=0 )
+	        			return false;
+	        		if ( handle2 <=0 )
+	        		       return false;
+	        		if ( handle3 <=0 )
+	        			        		       return false;
+	        		currentgrib_ = new GribEntryDecoder(handle1, handle2, handle3);
+	        		currentgrib_->set(*this, counter_++);
+
+	        		gribs_.push_back(currentgrib_);
+
+			}
+		}
+	currentDim_++;
+	currentgrib_->setPath(path_);
+	if ( iconName_.empty() )
+	{
+    		map<string, string>::iterator id = ids_.find(path_);
+    		if ( id == ids_.end() )
+		{
+    		    	iconName_ = "Grib" + tostring(index_);
+    		    	index_++;
+    		    	ids_.insert(make_pair(path_, iconName_));  		
+    		 }
+    		 else 
+    		    	iconName_ = id->second;
+	}
+	currentgrib_->icon(*this);
+	return true;
+}
+
+void GribLoop::print(ostream&) const {}
+
+
+
+class GribTag: public XmlNodeVisitor
+{
+public:
+	GribTag(GribDecoder& grib, TagHandler& title) : grib_(grib), title_(title) {
+	}
+	
+	~GribTag() {}
+	string baseDate(const XmlNode& node)
+	{
+		string format= node.getAttribute("format");
+		if ( format.empty() )  
+			format =  "%A %d %B %Y at %H UTC";
+		const long day  = grib_.getLong("date");  
+		const long hour = grib_.getLong("hour");  
+		const long mn   = grib_.getLong("minute"); 
+		MagDate part1 = MagDate(day);
+		MagTime part2 = MagTime(hour, mn, 0);
+		DateTime full(part1, part2);
+	    
+		return full.tostring(format);
+		
+	}
+
+	string startDate(const XmlNode& node)
+	{
+			string format= node.getAttribute("format");
+			if ( format.empty() )  
+				format =  "%A %d %B %Y at %H UTC";
+			const long day  = grib_.getLong("date");  
+			const long hour = grib_.getLong("hour");  
+			const long mn   = grib_.getLong("minute");
+			const long step = grib_.getLong("startStep");  // default is in hours. Set 'stepUnits' to change.
+
+			MagDate part1 = MagDate(day);
+			MagTime part2 = MagTime(hour, mn, 0);
+			DateTime full(part1, part2);	
+			full = full + (step*3600);
+			    
+			return full.tostring(format);
+	}
+
+	string validDate(const XmlNode& node)
+	{
+			string format= node.getAttribute("format");
+			if ( format.empty() )  
+				format =  "%A %d %B %Y at %H UTC";
+			const long day =  grib_.getLong("date");  
+			const long hour = grib_.getLong("hour");  
+			const long mn =  grib_.getLong("minute");
+			const long step =  grib_.getLong("stepRange");  // default is in hours. Set 'stepUnits' to change.
+			
+
+						
+			MagDate part1 = MagDate(day);
+			MagTime part2 = MagTime(hour, mn, 0);
+			DateTime full(part1, part2);	
+			full = full + (step*3600);
+
+			return full.tostring(format);
+			
+	}
+
+	string endDate(const XmlNode& node)
+	{
+		string format=  node.getAttribute("format");
+		if ( format.empty() )  
+			format =  "%A %d %B %Y at %H UTC";
+		const long day =  grib_.getLong("date");  
+		const long hour = grib_.getLong("hour");  
+		const long mn =  grib_.getLong("minute");
+		const long step =  grib_.getLong("endStep");  // default is in hours. Set 'stepUnits' to change.
+
+		MagDate part1 = MagDate(day);
+		MagTime part2 = MagTime(hour, mn, 0);
+		DateTime full(part1, part2);	
+		full = full + ( step*3600 );
+		    
+		return full.tostring(format);
+		
+	}
+
+	void visit(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "grib_info") )
+		{
+			string grib = node.getAttribute("id");
+					if ( !grib_.id(grib)) return;
+			string def = node.getAttribute("key");
+			if (def.empty()) {
+				 def = node.getAttribute("definition");
+				 // for backward compatibility with the first version! 
+			}
+			if ( def== "valid-date") {
+							title_.update("grib"+grib, def, validDate(node));
+							return;
+						}
+			
+			if ( def == "base-date") {
+				title_.update("grib"+grib, def, baseDate(node));
+				return;
+			}
+			if ( def == "MV_Format" ) {
+				title_.update("grib"+grib, def, "grib");
+				return;
+			}
+			if ( def == "MV_Index"  || def == "MV_Frame" ||  def == "MV_Value" ) {
+				// this is handled by Metview, so we just ignore it here
+				return;
+			}
+			if ( def == "start-date" ) {
+				title_.update("grib"+grib, def, startDate(node));
+				return;
+			}
+			if ( def == "end-date" ) {
+				title_.update("grib"+grib, def, endDate(node));
+				return;
+			}	
+			string val; 
+			string readAsLong = node.getAttribute("readAsLong");
+			if(readAsLong != "yes")
+			{
+				val =  grib_.getString(def);
+				string format = node.getAttribute("format"); 
+				if ( !format.empty() ) {
+					char tmp[256];
+					sprintf(tmp, format.c_str(), val.c_str());
+					val = tmp;
+					
+				}
+			}
+			else
+			{
+				long longVal = grib_.getLong(def);
+				std::stringstream sst ;
+				sst << longVal;
+				val=sst.str(); 
+			}
+	
+			if ( val.empty() ) 
+				val =  node.getAttribute("default");
+			title_.update("grib"+grib, def, val);
+		}		
+		
+		if ( magCompare(node.name(), "magics_title") )
+		{
+			string grib = node.getAttribute("id");
+			if ( !grib_.id(grib)) return;
+
+			vector<string> lines;
+			TitleTemplate::title(lines, grib_);
+			for (unsigned int i = 0; i < lines.size(); i++)
+			{
+				string id = grib_.title() + "_" + tostring(i);
+				title_.update("grib"+grib, id, lines[i]);		
+				string entry = "<grib_info definition=\'" + id + "\'/>";
+				title_.addToTags("<magics_title/>", entry);
+			}
+			//title_.addLines(lines.size());
+		}
+		node.visit(*this);	
+	}
+	
+	void decode(const string& line)
+	{
+		XmlReader parser;
+		XmlTree tree;
+	
+		ostringstream xml;
+		xml << "<?xml version='1.0' ?> \n";		
+		xml << "<xml> \n";
+		xml << line;
+		xml << "\n</xml>";
+
+		try {
+			parser.decode(xml.str(), &tree);		
+			tree.visit(*this);
+		}
+		catch (MagicsException& e) {
+			MagLog::debug() << e.what() << endl;
+		}	
+     } 
+     string str() const { return out.str(); }
+protected :
+	GribDecoder& grib_;
+	TagHandler& title_;
+	ostringstream out;
+};
+
+void GribDecoder::visit(AnimationRules& )
+{
+}
+
+void GribDecoder::visit(ValuesCollector& points)
+{
+	open();	
+	const Transformation& transformation = points.transformation();
+		
+	points.setCollected(true);
+
+	int nb = points.size();
+	double inlats[nb];
+	double inlons[nb];
+	double outlats[nb];
+	double outlons[nb];
+	double values[nb];
+	double x[nb];
+	double y[nb];
+	double distances[nb];
+	int indexes[nb];
+	double scaling, offset;
+	string oriUnits, derivedUnits;
+	string representation = getString("typeOfGrid");
+		
+	//Scaling works only for scalar data!!!
+	
+	try 
+	{
+		if ( !interpretor_ ) {
+					interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+				}
+		interpretor_->scaling(*this, scaling, offset,oriUnits,derivedUnits);
+	}      
+	catch (NoFactoryException&)
+	{
+		MagLog::warning() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+		scaling =1 ; offset =0;
+	}
+ 	
+	for (int i =0; i < nb; i++)
+	{
+		 
+	  	 inlats[i] = points[i].y();
+		 inlons[i] = std::fmod(points[i].x(),360.);
+		 if(inlons[i] < 0.) inlons[i]+=360.;
+		 i++;
+	}
+ 
+	double missing = getDouble("missingValue");
+		
+	if ( Data::dimension_ == 1 ) {
+	  	bool scaled=(scaling==1 && offset == 0)?false:true;
+		points.setScaled(scaled);
+		points.setUnits(oriUnits);
+		points.setScaledUnits(derivedUnits);
+	  
+		open();
+		grib_nearest_find_multiple(handle_, 0, inlats, inlons, nb, outlats, outlons, values, distances, indexes);
+		for (int i =0; i < nb; i++) 
+		{
+			points[i].push_back(new ValuesCollectorData(outlons[i],outlats[i],values[i],distances[i]));
+			if(scaled)
+				points[i].back()->setScaledValue(scaling*values[i] + offset);
+			if(values[i] == missing)
+			  	points[i].back()->setMissing(true);
+		}
+	}
+	else if ( Data::dimension_ == 2  ) {
+		bool scaled=(scaling==1 && offset == 0)?false:true;		
+		oriUnits=getString("units",false);
+		if(oriUnits.find("/") == string::npos)
+		{
+		  	oriUnits=oriUnits + "/" + oriUnits;
+		}	
+		points.setUnits(oriUnits);
+		points.setScaledUnits("/");
+				  			
+		
+		openFirstComponent();
+		grib_nearest_find_multiple(handle_, 0, inlats, inlons, nb, outlats, outlons, x, distances, indexes);
+		openSecondComponent();
+		grib_nearest_find_multiple(handle_, 0, inlats, inlons, nb, outlats, outlons, y, distances, indexes);
+		for (int i =0; i < nb; i++) 
+		{
+			points[i].push_back(wind_mode_->values(outlons[i],outlats[i],x[i],y[i], distances[i]));
+			if(x[i] == missing || y[i] == missing)
+				points[i].back()->setMissing(true);	  
+		}
+	}
+		else   {
+			bool scaled=(scaling==1 && offset == 0)?false:true;
+					oriUnits=getString("units",false);
+					if(oriUnits.find("/") == string::npos)
+					{
+					  	oriUnits=oriUnits + "/" + oriUnits;
+					}
+					points.setUnits(oriUnits);
+					points.setScaledUnits("/");
+
+
+					openFirstComponent();
+					grib_nearest_find_multiple(handle_, 0, inlats, inlons, nb, outlats, outlons, x, distances, indexes);
+					openSecondComponent();
+					grib_nearest_find_multiple(handle_, 0, inlats, inlons, nb, outlats, outlons, y, distances, indexes);
+					for (int i =0; i < nb; i++)
+					{
+						points[i].push_back(wind_mode_->values(outlons[i],outlats[i],x[i],y[i], distances[i]));
+						if(x[i] == missing || y[i] == missing)
+							points[i].back()->setMissing(true);
+					}
+		}
+
+}
+
+void GribDecoder::visit(MagnifierCollector& magnifier)
+{
+	const Transformation& transformation = magnifier.transformation(); 
+	PointsHandler& points = this->points(transformation);
+	points.setToFirst();
+
+	while  ( points.more() )
+	{
+		magnifier.push_back(transformation(points.current()));
+		points.advance();
+	}
+}
+const DateDescription& GribDecoder::timeStamp()
+{
+	vector<string> need;
+	need.push_back("<grib_info key='valid-date' format='%Y-%m-%d %H:%M:00'/>");
+	need.push_back("<grib_info key='level'/>");
+	need.push_back("<grib_info key='typeOfLevel'/>");
+
+	TagHandler helper;
+	GribTag tag1(*this, helper);
+	for ( vector<string>::const_iterator t = need.begin(); t != need.end(); ++t )
+			tag1.decode(*t);
+
+
+	timeStamp_ = DateDescription(helper.get("grib", "valid-date"), index_, internalIndex_);
+	dataLevel_ = LevelDescription::level(helper.get("grib", "typeOfLevel"), tonumber(helper.get("grib", "level")), index_, internalIndex_);
+
+
+	return timeStamp_;
+
+}
+
+const LevelDescription& GribDecoder::level()
+{
+	timeStamp();
+	return dataLevel_;
+}
+
+void GribDecoder::visit(MetaDataCollector& step)
+{
+	// Here we gather information for the label!
+	const Transformation& transformation = step.transformation();
+	
+	open(); // just to be sure the file is opened!
+
+	initInfo();
+
+	 //Collect infos
+	if(step.empty())
+	{
+		MetviewIcon::visit(step);
+	   	return;
+	}
+	   
+	try {	  
+		bool members=false;
+		vector<string> need;
+		if(name_.empty())
+		{
+			members=true;
+		  	need.push_back("<grib_info key='shortName'/>");
+			need.push_back("<grib_info key='level'/>");
+			need.push_back("<grib_info key='start-date' format='%Y-%m-%d %H:%M:00'/>");
+			need.push_back("<grib_info key='end-date' format='%Y-%m-%d %H:%M:00'/>");
+		}
+		
+		for(map<string, string>::iterator key = step.begin(); key != step.end(); ++key )
+		{	    
+			//If key is not found in information we use gribapi
+		  	if(information_.find(key->first) == information_.end())
+			{  
+				//Compute stats
+				if (step.attribute(key->first).group() == MetaDataAttribute::StatsGroup)
+				{
+					stats_.clear();
+					
+
+					PointsHandler& points = this->points(transformation, false);
+
+					points.setToFirst();
+	
+					while( points.more() )
+					{
+						stats_["value"].push_back(points.current().value());						
+						points.advance();
+					}
+					
+					computeStats();
+					
+
+				}
+				//We use gribapi
+				else if(step.attribute(key->first).source() == MetaDataAttribute::AnySource ||
+				   step.attribute(key->first).source() == MetaDataAttribute::GribApiSource)
+				{  					  
+					if(step.attribute(key->first).type() != MetaDataAttribute::NumberType)   
+					{
+						need.push_back("<grib_info key='"+key->first+ "'/>");
+		   			}
+					else
+					{
+						need.push_back("<grib_info key='"+key->first+ "' readAsLong='yes'/>");
+					}
+
+				}
+				else if(key->first == "scaling_formula" ||key->first == "scaled_units" )
+				{
+					double scaling, offset;
+					string oriUnits, derivedUnits;
+					string representation = getString("typeOfGrid");
+					try 
+					{
+						auto_ptr<GribInterpretor> interpretor_(SimpleObjectMaker<GribInterpretor>::create(representation));
+						interpretor_->scaling(*this, scaling, offset,oriUnits,derivedUnits);
+						if(scaling==1 && offset == 0)
+						{
+							information_["scaling_formula"]="";
+							information_["scaled_units"]="";
+						}
+						else
+						{  
+							string offsetSign=(offset >=0)?"+":"-";
+							information_["scaling_formula"]="(value * " + tostring(scaling) + ") " + offsetSign + " " + tostring(fabs(offset));
+							information_["scaled_units"]= derivedUnits;
+						}
+					}	
+					catch (NoFactoryException&)
+					{
+						MagLog::warning() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n"<<endl;;
+						information_[key->first]="N/A";
+					}
+					
+				}       	
+				
+			}	
+			//If key is found in information_ we copy it
+			else
+			{
+				  	key->second=information_[key->first];
+			}	
+		}
+		
+		
+		if(!need.empty())	
+		{
+			TagHandler helper;
+			GribTag tag1(*this, helper);
+			for ( vector<string>::const_iterator t = need.begin(); t != need.end(); ++t ) 
+			{
+	   			tag1.decode(*t);
+			}	
+				
+	   		if(members)
+			{  
+	   			name_ = helper.get("grib", "shortName") +  " " +  helper.get("grib", "level");
+
+	   			from_ = DateTime(helper.get("grib", "start-date"));
+	   			to_ =  DateTime(helper.get("grib", "end-date"));
+			}
+			
+			for(map<string, string>::iterator key = step.begin(); key != step.end(); ++key )
+			{	    
+				if(information_.find(key->first) == information_.end())
+				{  
+					if(step.attribute(key->first).source() == MetaDataAttribute::AnySource ||
+				   	   step.attribute(key->first).source() == MetaDataAttribute::GribApiSource)
+					{  					  
+					 	key->second = helper.get("grib", key->first);
+						setInfo(key->first,key->second);
+					}	
+				} 
+
+			}	  
+			
+	   	}
+	}
+
+	catch (...) {}
+
+}
+
+void GribDecoder::decode(const Transformation& transformation) 
+{
+	if (matrix_) return;
+	
+	open();
+	read(&matrix_, transformation);
+	if (!matrix_) return;
+	
+	// here we build information for the layers!
+	TagHandler helper; 
+	vector<string> need;
+	need.push_back("<grib_info id=\'" + id_ +"\' key='shortName'/>");
+	need.push_back("<grib_info id=\'" + id_ +"\' key='level'/>");
+	need.push_back("<grib_info id=\'" + id_ +"\'  key='start-date' format='%Y-%m-%d %H:%M:00'/>");
+	need.push_back("<grib_info id=\'" + id_ +"\' key='end-date' format='%Y-%m-%d %H:%M:00'/>");
+	GribTag tag1(*this, helper);
+
+	for ( vector<string>::const_iterator t = need.begin(); t != need.end(); ++t )
+	{
+		tag1.decode(*t);
+	}
+
+	name_ = helper.get("grib"+id_, "shortName") +  "-" +  helper.get("grib"+id_, "level");
+	name_ = iconName_;
+	layerId_ = name_ + file_name_;
+	from_ = DateTime(helper.get("grib"+id_, "start-date"));
+	to_ =  DateTime(helper.get("grib"+id_, "end-date"));	
+}
+
+void GribDecoder::decode() 
+{
+	if (matrix_) return;
+	
+	open();
+	
+	read(&matrix_);
+	if (!matrix_) return;
+	
+	// here we build information for the layers!
+	TagHandler helper; 
+	vector<string> need;
+	need.push_back("<grib_info id=\'" + id_ +"\' key='shortName'/>");
+	need.push_back("<grib_info id=\'" + id_ +"\' key='level'/>");
+	need.push_back("<grib_info id=\'" + id_ +"\'  key='start-date' format='%Y-%m-%d %H:%M:00'/>");
+	need.push_back("<grib_info id=\'" + id_ +"\' key='end-date' format='%Y-%m-%d %H:%M:00'/>");
+	GribTag tag1(*this, helper);
+
+	for ( vector<string>::const_iterator t = need.begin(); t != need.end(); ++t )
+	{
+		tag1.decode(*t);
+	}
+
+	name_ = helper.get("grib"+id_, "shortName") +  "-" +  helper.get("grib"+id_, "level");
+	name_ = iconName_;
+	layerId_ = name_ + file_name_;
+	from_ = DateTime(helper.get("grib"+id_, "start-date"));
+	to_ =  DateTime(helper.get("grib"+id_, "end-date"));	
+}
+
+
+
+void GribDecoder::visit(TextVisitor& title) 
+{
+	try {
+		open();	
+	}
+	catch ( ... )
+	{
+		return;
+	}
+	
+	vector<string> titles;
+
+	title.titles(titles);
+	GribTag tag(*this, title);
+	
+	for ( vector<string>::const_iterator t = titles.begin(); t != titles.end(); ++t ) {
+		tag.decode(*t);
+	}
+}
+
+
+
+void GribDecoder::decodeRaster(const Transformation& transformation) 
+{
+	open();
+	
+	string representation = getString("typeOfGrid");
+	
+	try {
+		if ( !interpretor_ ) {
+					interpretor_ = SimpleObjectMaker<GribInterpretor>::create(representation);
+				}
+		interpretor_->interpretAsRaster(*this, raster_, transformation);
+	}
+    
+    catch (NoFactoryException&)
+    {
+    	MagLog::error() << "Grib Decoder: Representation [" << representation << "] not yet supported.\n";
+    	throw MagicsException("Grib Decoder: Representation [] not yet supported.");
+    }
+}
+
+
+void GribDecoder::initInfo()
+{
+	if(information_.find("_datatype") == information_.end())
+	{
+	  	setInfo("_datatype","GRIB");
+		setInfo("path", file_name_);
+		setInfo("MV_Format","GRIB");
+	}
+}
+
+
+
+namespace magics {
+
+class GribInfo
+{
+public:
+	GribInfo() {}
+	virtual ~GribInfo() {}
+	virtual void operator()(ostream&, const GribDecoder&) = 0;
+};
+
+class GribParameter : public GribInfo
+{
+public: 
+	GribParameter() {}
+	~GribParameter() {}
+	void operator()(ostream& out, const GribDecoder& grib)
+	{
+		string val = grib.getString("name");
+ 		out << val;
+	}
+};
+
+class GribParamCriter : public MatchCriteria
+{
+public:
+	GribParamCriter() {}
+	~GribParamCriter() {}
+	bool verify(const GribDecoder& grib, const string&, const string& val)
+	{
+		long param = grib.getLong("paramId");
+		return (tostring(param) == val);
+	}
+};
+
+class GribLocalCriter : public MatchCriteria
+{
+public:
+	GribLocalCriter() {}
+	~GribLocalCriter() {}
+	bool verify(const GribDecoder& grib, const string& param, const string& val)
+	{
+		string key = param;
+		string criter = grib.getString(key, false); // 'false' to avoid warnings if key is absent
+		MagLog::debug() << "I am verifing " << param << " for a GribDecoder : " << criter << " ==  " << val << "???" << "\n";
+		return (criter == val);
+	}
+};
+
+class GribObsDiagCriter : public MatchCriteria
+{
+public:
+	GribObsDiagCriter() {}
+	~GribObsDiagCriter() {}
+	bool verify(const GribDecoder& grib, const string&, const string& )
+	{
+		string param = grib.getString("observationDiagnostic", false); // do not warn if the key is absent
+		return (param != "");
+	}
+};
+
+
+class GribLocalDefHandler : public TitleFieldHandler
+{
+public:
+	GribLocalDefHandler() {}
+	~GribLocalDefHandler() {}
+
+	void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+	{
+
+		ostringstream out;
+		string local = grib.getString("localDefinitionNumber");       
+		out << "local definition =" << local << " ";        
+		title.back() += out.str();
+	}
+};
+
+class GribObsDiagHandler : public TitleFieldHandler
+{
+public:
+	GribObsDiagHandler() {}
+	~GribObsDiagHandler() {}
+
+	void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+	{
+
+        ostringstream out;
+		string local = grib.getString("observationDiagnostic");       
+        out << "diagnostic =" << local << " ";   
+        title.back() += out.str();
+	}
+};
+
+class GribObstatHandler : public TitleFieldHandler
+{
+public:
+	GribObstatHandler() {}
+	~GribObstatHandler() {}
+
+	void operator()(TitleField&, vector<string>& /*title*/, const GribDecoder& grib)
+	{
+
+		/*string type = grib.getString("codeType"); 
+		string platform = grib.getString("platform"); 
+      		string instrument = grib.getString("instrument");
+		string selection = grib.getString("dataSelection");
+		string diag = grib.getString("observationDiagnostic");
+		string channel = grib.getString("scaledValueOfFirstFixedSurface");
+		string min = grib.getString("min");
+		string max = grib.getString("max");
+		string mean = grib.getString("average");
+		string units= grib.getString("units");
+		string exp= grib.getString("experimentVersionNumber");
+		string date= grib.getString("mars.date");
+		string time= grib.getString("mars.time");
+ 
+       		out << "Statistics for " << type << " from " << platform << "/" << instrument << "<br/>" << 
+       			diag << " [" << units << "] (" << selection << ")" <<  "<br/>" << 
+       			"Date = " << date << "  Time = " << time << "<br/>" <<
+       			"Exp = " << exp << " Channel = " << channel << "<br/>" <<
+       			"Min: "  << min << "    Max: " << max << " Mean: " << "mean";         
+	
+	*/
+	}
+};
+
+class GribLocalHandler : public TitleFieldHandler
+{
+public:
+	GribLocalHandler(const string& local) : local_(local) {}
+	~GribLocalHandler() {}
+
+	void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+	{
+
+		ostringstream out;
+		string code = grib.getString(local_);
+		out << local_ << "=" << code  << " ";
+		title.back()+= out.str();
+	}
+protected :
+	string local_;
+};
+
+class GribStreamHandler : public GribLocalHandler 
+{
+public:
+	GribStreamHandler() : GribLocalHandler("marsStream") {}
+	~GribStreamHandler() {}
+};
+
+class GribClassHandler : public GribLocalHandler 
+{
+public:
+	GribClassHandler() : GribLocalHandler("marsClass") {}
+	~GribClassHandler() {}
+};
+
+class GribTypeHandler : public GribLocalHandler 
+{
+public:
+	GribTypeHandler() : GribLocalHandler("marsType") {}
+	~GribTypeHandler() {}
+};
+
+
+class GribParamHandler : public TitleFieldHandler
+{
+public:
+	GribParamHandler() {}
+	~GribParamHandler() {}
+	virtual void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+	{
+
+		string param = grib.getString("name");
+ 		title.back()+=param;
+	}
+};
+
+
+class GribKeyHandler : public TitleFieldHandler
+{
+public:
+	GribKeyHandler() {}
+	~GribKeyHandler() {}
+	void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+	{
+		
+
+		char x[256];
+		
+		string key = field.attribute("key", ""); 	
+		string value  = grib.getString(key);       
+		string format = field.attribute("format", "%s");
+		sprintf(x, format.c_str(), value.c_str());
+
+	    title.back() += string(x);
+
+	}
+};
+
+
+
+class GribBaseDateHandler : public TitleFieldHandler
+{
+public:
+	GribBaseDateHandler() {}
+	~GribBaseDateHandler() {}
+	void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+	{
+
+		ostringstream out;
+
+		long date = grib.getLong("date");    
+		long hour = grib.getLong("hour");  
+		long mn =  grib.getLong("minute"); 
+		MagDate part1 = MagDate(date);
+		MagTime part2 = MagTime(hour, mn, 0);
+		DateTime full(part1, part2);
+	
+		string format = field.attribute("format", "%A %d %B %Y at %H UTC");
+	
+		title.back() += full.tostring(format);
+	}	
+};
+
+class GribValidDateHandler : public TitleFieldHandler
+{
+public:
+    GribValidDateHandler() {}
+    ~GribValidDateHandler() {}
+    void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+    {
+	    ostringstream out;
+        long date = grib.getLong("date");    
+        long hour = grib.getLong("hour");  
+        long mn   = grib.getLong("minute"); 
+        long step = grib.getLong("step") * 3600; // needs steps in second!   // default is in hours. Set 'stepUnits' to change.
+       
+        MagDate part1 = MagDate(date);
+        MagTime part2 = MagTime(hour, mn, 0);
+        DateTime full(part1, part2);
+        full = full + step;
+
+        
+	    string format = field.attribute("format", "%A %d %B %Y %H UTC");
+	        
+	    title.back() += full.tostring(format);
+       
+
+    }
+};
+
+class GribStepHandler : public TitleFieldHandler
+{
+public:
+    GribStepHandler() {}
+    ~GribStepHandler() {}
+    void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+    {
+
+        ostringstream out;
+        long istep = grib.getLong("startStep");
+
+
+        ostringstream step;
+        step << istep;
+        string format = field.attribute("format", "t+%s");
+        out << SimpleStringFormat(step.str(), format);
+        title.back() += out.str();
+	}
+};
+
+
+class GribLevelHandler : public TitleFieldHandler
+{
+public:
+    GribLevelHandler() { 
+    	if (map_.empty()) {
+    		map_["Surface"] = &GribLevelHandler::surface;
+    		map_["Unknown"] = &GribLevelHandler::surface;
+    		map_["isobaricInhPa"] = &GribLevelHandler::isobaricInhPa;
+    		map_["hybrid"] = &GribLevelHandler::hybrid;
+    	}
+    }
+    
+    ~GribLevelHandler() {}
+    typedef string (GribLevelHandler::*Builder)(const string& def, const GribDecoder& grib) const;
+    
+    void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+    {
+    	ostringstream out;
+
+        string level = grib.getString("typeOfLevel");
+        
+        map<string,  GribLevelHandler::Builder>::iterator help = map_.find(level);
+        if ( help != map_.end() ) out << (this->*help->second)(level, grib) << " ";
+        else out << level << " ";    
+        
+        title.back() +=  out.str();
+        
+    }
+    
+protected: 
+	static map<string, GribLevelHandler::Builder> map_;
+	
+	string surface(const string&, const GribDecoder& ) const
+	{
+		return "";
+	}	
+	string unknown(const string& level, const GribDecoder& ) const
+	{
+		ostringstream out;
+		out << "Unknown type of level[" << level << "]";
+		return out.str();
+	}	
+	string isobaricInhPa(const string& , const GribDecoder& grib) const
+	{
+		ostringstream out;
+		long level = grib.getLong("level");
+		out  << level  <<  " " << "hPa";
+		return out.str();
+	}	
+	string hybrid(const string& , const GribDecoder& grib) const
+	{
+		ostringstream out;
+		long level = grib.getLong("level");
+		out  << "Model level " << level;
+		return out.str();
+	}
+};
+map<string, GribLevelHandler::Builder> GribLevelHandler::map_;
+
+
+class GribTimeHandler : public TitleFieldHandler
+{
+public:
+    GribTimeHandler() {}
+    ~GribTimeHandler() {}
+    void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+    {
+//        if (!grib.getText()) return;
+//        ostringstream out;
+//        grib_int_t idate;
+//        grib_get(grib.id(),(grib_string_t*)"time","I",&idate);      
+//     
+//        out << "Time:" << idate;
+//        title.add(out.str());
+
+          title.back() +=  "Time? ";
+    }
+};
+
+class GribCentreHandler : public TitleFieldHandler
+{
+public:
+	GribCentreHandler() {}
+	~GribCentreHandler() {}
+	void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+	{
+		string format = field.attribute("format", "%s");
+		string style = field.attribute("style", "short");
+		long centre = grib.getLong("centre");	
+		GeneralDef def = CentreTable::definition(centre);
+		char x[256];
+		string value = (style == "short") ?  def.shortTitle() : def.longTitle();
+		sprintf(x, format.c_str(), value.c_str());
+
+		title.back() += string(x);
+	}
+};
+
+class GribProductHandler : public TitleFieldHandler
+{
+public:
+    GribProductHandler() {}
+    ~GribProductHandler() {}
+    void operator()(TitleField&, vector<string>& title, const GribDecoder& grib)
+    {
+
+       long type = grib.getLong("type");
+
+       GeneralDef def = TypeTable::definition(type);
+       title.back() += def.longTitle();
+    }
+};
+
+
+class GribPlotTypeHandler : public TitleFieldHandler
+{
+public:
+    GribPlotTypeHandler() {}
+    ~GribPlotTypeHandler() {}
+    void operator()(TitleField&, vector<string>&,const GribDecoder&)
+    {
+         //MagLog::warning() << "Plot Type: not implemented--> wait for the specification." << "\n";
+    }
+};
+
+
+class NewLineHandler : public TitleFieldHandler
+{
+public:
+    NewLineHandler() {}
+    ~NewLineHandler() {}
+    void operator()(TitleField&, vector<string>& title,const GribDecoder&)
+    {
+        title.push_back("");
+    }
+};
+
+
+class SatelliteHandler : public TitleFieldHandler
+{
+public:
+    SatelliteHandler()  {}
+    ~SatelliteHandler() {}
+    void operator()(TitleField&, vector<string>& title,const GribDecoder& grib)
+    {
+       ostringstream out;
+       long ident =  grib.getLong("ident");
+
+       out << "Sat:" << ident << " ";
+       title.back() += out.str();
+    }
+};
+
+class ChannelHandler : public TitleFieldHandler
+{
+public:
+    ChannelHandler()  {}
+    ~ChannelHandler() {}
+    void operator()(TitleField&, vector<string>& title,const GribDecoder& grib)
+    {       
+    	ostringstream out;
+        long band = grib.getLong("obstype");
+        out << "Band:" << band << " ";
+        title.back() += out.str();
+    }
+};
+
+
+class GribExpverHandler : public TitleFieldHandler
+{
+public:
+    GribExpverHandler() {}
+    ~GribExpverHandler() {}
+    void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+    {
+
+       if ( !grib.getExpver() ) return; 
+       ostringstream out;    
+       string expver = grib.getString("mars.experimentVersionNumber");
+       string format = field.attribute("format", "Expver=%s");          
+       out << SimpleStringFormat(expver, format);
+       title.back() += out.str();
+   }
+};
+
+
+class GribEpsNumberInfoHandler : public TitleFieldHandler
+{
+public:
+    GribEpsNumberInfoHandler() {}
+    ~GribEpsNumberInfoHandler() {}
+    void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+    {
+	    
+//       if (!grib.getText()) return;
+//        ostringstream out;
+//       grib_int_t local;
+//       grib_get(grib.id(),(grib_string_t*)"localDefinition","I","localDefinitionNumber",&local);
+//       if (local != 1) return;
+//
+//       char number[1024];
+//       grib_get(grib.id(),(grib_string_t*)"localDefinition","s","total",number);
+//       string format = field.attribute("format", "(%s members)");     
+//      
+//      out << SimpleStringFormat(number, format);
+//        title.add(out.str());
+
+    	 title.back() +=  "epsnumber?";
+
+    }
+};
+
+
+class GribUnitHandler : public TitleFieldHandler
+{
+public:
+    GribUnitHandler() {}
+    ~GribUnitHandler() {}
+    void operator()(TitleField& field, vector<string>& title, const GribDecoder& grib)
+    {
+/*
+		if (!grib.getText()) return;
+        if ( !grib.getUnits() ) return; 
+        ostringstream out;      
+     
+        double id   = grib.getDouble("paramId");
+        long centre  = grib.getLong("centre");
+        				
+        long param = (long) id;
+        long table   = (id - param )*100;
+
+          
+        const ParamDef& parameter = LocalTable::localInfo(param, table, centre);
+           
+        string format = field.attribute("format", "Units:%s");           
+        string unit = (grib.getScaling()) ? parameter.derivedUnit() :  parameter.originalUnit();
+        out << SimpleStringFormat(unit, format);
+      
+        
+        title.back() += out.str();
+   */
+    }
+};
+
+}// end namespace magics
+
+
+
+static SimpleObjectMaker<GribParamCriter, MatchCriteria > gribparamcriter("parameter");
+static SimpleObjectMaker<GribParamHandler, TitleFieldHandler > gribparamhandler("parameter");
+static SimpleObjectMaker<GribBaseDateHandler, TitleFieldHandler > gribbasedatehandler("base_date");
+static SimpleObjectMaker<GribValidDateHandler, TitleFieldHandler > gribvaliddatehandler("valid_date");
+static SimpleObjectMaker<GribStepHandler, TitleFieldHandler > gribstephandler("step");
+static SimpleObjectMaker<GribEpsNumberInfoHandler, TitleFieldHandler > gribepsnumberhandler("eps_number_info");
+
+static SimpleObjectMaker<GribTimeHandler, TitleFieldHandler > gribTimehandler("time");
+static SimpleObjectMaker<GribLevelHandler, TitleFieldHandler > gribLevelhandler("level");
+static SimpleObjectMaker<NewLineHandler, TitleFieldHandler > newlinehandler("newline");
+static SimpleObjectMaker<GribKeyHandler, TitleFieldHandler > gribkeyhandler("gribapi");
+
+static SimpleObjectMaker<GribStreamHandler, TitleFieldHandler > gribstreamhandler("stream");
+static SimpleObjectMaker<GribClassHandler, TitleFieldHandler > gribclasshandler("class");
+static SimpleObjectMaker<GribTypeHandler, TitleFieldHandler > gribtypehandler("type");
+static SimpleObjectMaker<GribLocalDefHandler, TitleFieldHandler > griblocaldefhandler("localdef");
+static SimpleObjectMaker<GribCentreHandler, TitleFieldHandler > gribcentrehandler("centre");
+static SimpleObjectMaker<GribProductHandler, TitleFieldHandler > gribproducthandler("product");
+static SimpleObjectMaker<GribUnitHandler, TitleFieldHandler > gribunithandler("units");
+static SimpleObjectMaker<GribExpverHandler, TitleFieldHandler > gribexpverhandler("expver");
+static SimpleObjectMaker<GribPlotTypeHandler, TitleFieldHandler > gribplottypehandler("plot_type");
+static SimpleObjectMaker<SatelliteHandler, TitleFieldHandler > satellitehandler("satellite");
+static SimpleObjectMaker<ChannelHandler, TitleFieldHandler > channelhandler("channel");
+static SimpleObjectMaker<GribBaseDateHandler, TitleFieldHandler > datehandler("date");
+
+
+static SimpleObjectMaker<GribObsDiagCriter, MatchCriteria > gribobsdiagriter("observationDiagnostic");
+static SimpleObjectMaker<GribObsDiagHandler, TitleFieldHandler > gribobsdiaghandler("observationDiagnostic");
+static SimpleObjectMaker<GribObstatHandler, TitleFieldHandler > gribobstathandler("obstat");
+
+
+static SimpleObjectMaker<GribLocalCriter, MatchCriteria > gribstreamcriter("stream");
+static SimpleObjectMaker<GribLocalCriter, MatchCriteria > gribtypecriter("type");
+static SimpleObjectMaker<GribLocalCriter, MatchCriteria > gribclasscriter("class");
+static SimpleObjectMaker<GribLocalCriter, MatchCriteria > typeOfgeneratingProcess("typeOfGeneratingProcess");
+static SimpleObjectMaker<GribLocalCriter, MatchCriteria > timeRangeIndicator("timeRangeIndicator");
+
+#include "GribRegularInterpretor.h"
+static SimpleObjectMaker<GribRegularInterpretor, GribInterpretor> regular_ll("regular_ll");
+static SimpleObjectMaker<GribReducedLatLonInterpretor, GribInterpretor> reduced_ll("reduced_ll");
+static SimpleObjectMaker<GribRegularGaussianInterpretor, GribInterpretor> regular_gg("regular_gg");
+static SimpleObjectMaker<GribReducedGaussianInterpretor, GribInterpretor> reduced_gg("reduced_gg");
+static SimpleObjectMaker<GribRotatedInterpretor, GribInterpretor> rotated_ll("rotated_ll");
+static SimpleObjectMaker<GribLambertAzimutalInterpretor, GribInterpretor> lambert_azimuthal_equal_area("lambert_azimuthal_equal_area");
+static SimpleObjectMaker<GribLambertAzimutalInterpretor, GribInterpretor> lambert("lambert");
+
+
+#include "GribSatelliteInterpretor.h"
+static SimpleObjectMaker<GribSatelliteInterpretor, GribInterpretor> satellite("space_view");
+
diff --git a/src/decoders/GribDecoder.h b/src/decoders/GribDecoder.h
new file mode 100644
index 0000000..0a66609
--- /dev/null
+++ b/src/decoders/GribDecoder.h
@@ -0,0 +1,352 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribDecoder.h
+    \brief Definition of the Template class GribDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 16-Mar-2004
+    
+    Changes:
+
+*/
+
+#ifndef GribDecoder_H
+#define GribDecoder_H
+
+#include "magics.h"
+#include "MagException.h"
+
+
+#include "Decoder.h"
+#include "Data.h"
+#include "GribDecoderAttributes.h"
+#include "UserPoint.h"
+
+
+#include "GribLoopAttributes.h"
+
+#include "grib_api.h"
+
+#include "GribInterpretor.h"
+
+
+namespace magics {
+class GribDecoder;
+struct MatchCriteria
+{
+    MatchCriteria() {}
+    virtual ~MatchCriteria() {}
+    virtual bool verify(const GribDecoder&, const string&, const string&) { return false; }
+};
+
+class GribMagException : public MagicsException
+{
+public:
+	 GribMagException( const string& why ):
+		MagicsException("Grib API error message: " +  why){}
+}; 
+class GribFileMagException : public MagicsException
+{
+public:
+	GribFileMagException(const string& file, int index)
+	{ 
+		ostringstream s;
+		s << "Grib decoding failed: field " << index << " in " << file << endl;
+		what_ = s.str();
+	}
+}; 
+
+class GribLoop;
+
+class GribDecoder: 
+    public Decoder, 
+    public Data,
+    public GribDecoderAttributes
+{
+public:
+	GribDecoder();
+	virtual ~GribDecoder();    
+
+	// implements BaseSceneObject interface
+	virtual void set(const map<string, string>& params) { GribDecoderAttributes::set(params); }
+	virtual void set(const XmlNode& node) { GribDecoderAttributes::set(node); }
+	void set(const GribLoop&, int);
+	// implements Decoder interface
+	void decode();
+	void decode2D();
+	void decode(const Transformation&);
+		void decode2D(const Transformation&);
+	void decodeRaster(const Transformation&);
+	void decodePoints();
+	void release();
+	
+	// Data Interface : info for the layer managment! 
+	 string layerId()  { decode(); return layerId_; }
+	 string name() { decode(); return name_; }
+	 const DateTime& from() { decode(); return from_; }
+	 const DateTime& to()  { decode(); return to_; }
+	
+	string title() {
+		return title_;
+	}
+
+	bool getExpver() const { return expver_; }
+	void version();
+	
+	
+	// implements Decoder
+		void visit(AnimationRules&);
+		void visit(MetaDataCollector&);
+		void visit(MagnifierCollector&);
+		void visit(ValuesCollector&);
+		
+		 const DateDescription& timeStamp();
+		 const LevelDescription& level() ;
+
+	// implements Decoder
+	void visit(TextVisitor&);
+    
+	PointsHandler& points()
+	{
+		decodePoints();
+		pointsHandlers_.push_back(new PointsHandler(points_));
+		return *(pointsHandlers_.back()); 
+	} 
+	PointsHandler& points(const Transformation& transformation)
+		{
+			decodePoints();
+			pointsHandlers_.push_back(new BoxPointsHandler(points_, transformation, true));
+			return *(pointsHandlers_.back()); 
+		} 
+	PointsHandler& points(const Transformation& transformation, bool all) {
+		decodePoints();
+		pointsHandlers_.push_back(new BoxPointsHandler(points_, transformation, !all));
+		return *(pointsHandlers_.back());
+	}
+
+	MatrixHandler& matrix()
+	{
+		if ( !context_) 
+			throw MagicsException("No data to display ");
+		decode();
+		matrixHandlers_.push_back(new MatrixHandler(*matrix_));
+		return *(matrixHandlers_.back()); 
+	}
+	MatrixHandler& matrix(const Transformation& transformation)
+		{
+		if ( !context_) 
+			throw MagicsException("No data to display ");
+			decode(transformation);
+			matrixHandlers_.push_back(new MatrixHandler(*matrix_));
+			return *(matrixHandlers_.back()); 
+		}
+	
+	void setPath(const string& path) { file_name_ = path; }
+	
+	RasterData&  raster(const Transformation& transformation)
+	{
+		decodeRaster(transformation);
+		return raster_; 
+	} 
+	void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	{
+
+	}
+
+	void customisedPoints(const AutomaticThinningMethod&, const Transformation&, const std::set<string>&, CustomisedPointsList&);
+	void customisedPoints(const BasicThinningMethod&, const Transformation&, const std::set<string>&, CustomisedPointsList& );
+
+
+	virtual void open(bool sendMsg = true);
+	virtual void openFirstComponent();
+	virtual void openSecondComponent();
+	virtual void openThirdComponent();
+	virtual void readColourComponent();
+
+	grib_handle*  id() const { if (!handle_) const_cast<GribDecoder*>(this)->decode(); return handle_; }
+	long      getLong(const string&,   bool warnIfKeyAbsent = true) const;
+	string    getString(const string&, bool warnIfKeyAbsent = true) const;
+	double    getDouble(const string&, bool warnIfKeyAbsent = true) const;
+    void      setDouble(const string&, double) const;
+
+    string    getstring(const string&, bool warnIfKeyAbsent = true) const;
+
+	void      read(Matrix **matrix);
+	void      read(Matrix **matrix, const Transformation&);
+	bool      id(const string&) const;
+
+
+	static grib_context* gribContext();
+	static void releaseContext() {  
+		if (context_)  
+			grib_context_delete(context_); 
+		context_ = 0;
+	}
+	grib_handle*  handle() const { return handle_; }
+        void initInfo();
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     
+	mutable Matrix*     matrix_;
+	mutable Matrix*     xComponent_;
+	mutable Matrix*     yComponent_;     
+	mutable Matrix*     colourComponent_;
+	mutable RasterData raster_;
+	mutable PointsList points_;
+
+	int internalIndex_;
+	GribInterpretor* interpretor_;
+
+
+
+	
+ 
+	static 	grib_context* context_;
+	grib_handle*  handle_;
+	
+	string title_;
+	static int count_;
+	friend class GribInterpretor;
+private:
+	//! Copy constructor - No copy allowed
+	GribDecoder(const GribDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	GribDecoder& operator=(const GribDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribDecoder& p)
+		{ p.print(s); return s; }
+};
+
+
+class GribEntryDecoder: public GribDecoder
+{
+public:
+	GribEntryDecoder(grib_handle* handle) {
+		handle_ = handle;
+		handle1_ = 0;
+		handle2_ = 0;
+		handle3_ = 0;
+		Data::dimension_ = 1;
+
+	}
+	GribEntryDecoder(grib_handle* handle1, grib_handle* handle2) { 
+		handle_ = handle1;
+		handle1_ = handle1; 
+		handle2_ = handle2;
+		handle3_ = 0;
+
+		Data::dimension_ = 2;
+	}
+	GribEntryDecoder(grib_handle* handle1, grib_handle* handle2, grib_handle* handle3) {
+		handle_ = handle1;
+		handle1_ = handle1;
+		handle2_ = handle2;
+		handle3_ = handle3;
+		Data::dimension_ = 3;
+	}
+	~GribEntryDecoder() {}
+
+	void open(bool sendMsg = true) { assert(handle_); }
+	
+	void openFirstComponent() { 
+		assert(handle1_);
+		handle_ = handle1_;
+	}
+	
+	void openSecondComponent() { 
+		assert(handle2_);
+		handle_ = handle2_;
+	}
+	void openThirdComponent() {
+			assert(handle3_);
+			handle_ = handle3_;
+		}
+	void readColourComponent() {
+		if ( handle3_ ) {
+			handle_ = handle3_;
+			read(&colourComponent_);
+		}
+		else
+			colourComponent_ = 0;
+	}
+	
+protected:
+	grib_handle*  handle1_;
+	grib_handle*  handle2_;
+	grib_handle*  handle3_;
+};
+
+class GribLoop : public GribLoopAttributes, public DataLoop
+{
+public:
+	GribLoop();
+	virtual ~GribLoop();
+	
+	
+	
+	void set(const map<string, string>& map) { GribLoopAttributes::set(map); }
+	void set(const XmlNode& node) { GribLoopAttributes::set(node); }
+	
+	
+	Data* current();
+	bool         hasMore();
+	void         next();
+	void setToFirst();
+	
+	
+	
+
+protected:
+	virtual void print(ostream&) const; 
+	vector<GribDecoder*> gribs_;
+    GribDecoder* currentgrib_;
+	friend class GribDecoder;
+	vector<int>::iterator currentDim_;
+	vector<int>::iterator currentPos_;
+
+	
+	FILE* file_;
+	static map<string, string>  ids_;
+	static int  index_;
+	int uniqueId_;
+	int counter_;
+	
+private:
+	//! Copy constructor - No copy allowed
+	GribLoop(const GribLoop&);
+	//! Overloaded << operator to copy - No copy allowed
+	GribLoop& operator=(const GribLoop&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribLoop& p)
+		{ p.print(s); return s; }
+	
+};
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/GribDecoderAttributes.h b/src/decoders/GribDecoderAttributes.h
new file mode 100644
index 0000000..97bd20a
--- /dev/null
+++ b/src/decoders/GribDecoderAttributes.h
@@ -0,0 +1,97 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file GribDecoderAttributes.h
+    \brief Definition of GribDecoder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef GribDecoderAttributes_H
+#define GribDecoderAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "WindMode.h"
+#include "GribAddressMode.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class GribDecoderAttributes 
+{
+public:
+//  --  constructor
+    GribDecoderAttributes();
+    
+//  --  destructor
+    virtual ~GribDecoderAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const GribDecoderAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string file_name_;
+	string id_;
+	bool scaling_;
+	bool derived_scaling_;
+	double scaling_factor_;
+	double scaling_offset_;
+	bool expver_;
+	bool units_;
+	auto_ptr<GribAddressMode> address_mode_;
+	auto_ptr<WindMode> wind_mode_;
+	int grib_field_position_;
+	int position_1_;
+	int position_2_;
+	int colour_position_;
+	double missing_value_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const GribDecoderAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/GribInterpretor.h b/src/decoders/GribInterpretor.h
new file mode 100644
index 0000000..f67dad1
--- /dev/null
+++ b/src/decoders/GribInterpretor.h
@@ -0,0 +1,104 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribInterpretor.h
+    \brief Definition of the Template class GribInterpretor.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 18-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef GribInterpretor_H
+#define GribInterpretor_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "UserPoint.h"
+
+
+namespace magics {
+
+class GribDecoder;
+class Matrix;
+class Transformation;
+
+
+class RasterData;
+
+
+class GribInterpretor  {
+
+public:
+	GribInterpretor() {}
+	virtual ~GribInterpretor() {}
+	virtual double XResolution(const GribDecoder&) const { return 0; }
+	virtual void raw(const GribDecoder&, const Transformation&, const string&, CustomisedPointsList&) const;
+	virtual void interpretAsMatrix(const GribDecoder&, Matrix**) const {}
+	virtual void interpretAsMatrix(const GribDecoder& grib, Matrix** matrix, const Transformation&) const
+		{ interpretAsMatrix(grib, matrix); }
+
+
+    virtual void interpret2D(double&, double&, double&, double&) const {}
+    virtual void keepOriginal(bool) {}
+    virtual void interpretAsRaster(const GribDecoder&, RasterData&, const Transformation&) const {}
+    virtual void scaling(const GribDecoder&, Matrix**) const;
+    virtual void scaling(const GribDecoder& grib, double& scaling, double& offset) const;
+    virtual void scaling(const GribDecoder& grib, double& scaling, double& offset, string& originalUnits, string& derivedUnits) const;
+    void longitudesSanityCheck(double&, double&) const;
+
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out <<  "GribInterpretor" << endl; }
+
+private:
+    //! Copy constructor - No copy allowed
+	GribInterpretor(const GribInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	GribInterpretor& operator=(const GribInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, GribInterpretor> { 
+public:
+	MAGICS_NO_EXPORT GribInterpretor* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<GribInterpretor>::create(val);
+	}     
+	MAGICS_NO_EXPORT GribInterpretor* magics(const string& param)
+	{
+		GribInterpretor* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/GribLoopAttributes.h b/src/decoders/GribLoopAttributes.h
new file mode 100644
index 0000000..12ba557
--- /dev/null
+++ b/src/decoders/GribLoopAttributes.h
@@ -0,0 +1,96 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file GribLoopAttributes.h
+    \brief Definition of GribLoop Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef GribLoopAttributes_H
+#define GribLoopAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "WindMode.h"
+#include "GribAddressMode.h"
+#include "GribLoopStep.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class GribLoopAttributes 
+{
+public:
+//  --  constructor
+    GribLoopAttributes();
+    
+//  --  destructor
+    virtual ~GribLoopAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const GribLoopAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<GribAddressMode> address_mode_;
+	intarray dimension_;
+	intarray dim_1_;
+	intarray dim_2_;
+	intarray dim_colour_;
+	intarray dim_;
+	string path_;
+	auto_ptr<GribLoopStep> step_;
+	bool scaling_;
+	bool derived_scaling_;
+	double scaling_factor_;
+	double scaling_offset_;
+	auto_ptr<WindMode> wind_mode_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const GribLoopAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/GribLoopStep.cc b/src/decoders/GribLoopStep.cc
new file mode 100644
index 0000000..46c033f
--- /dev/null
+++ b/src/decoders/GribLoopStep.cc
@@ -0,0 +1,82 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+#include "GribLoopStep.h"
+#include "GribDecoder.h"
+#include "DateTime.h"
+#include "ViewNode.h"
+#include <locale>
+
+
+
+void GribLoopStep::print(ostream&) const
+{
+	
+}
+/*
+void DateGribLoopStep::operator()(GribDecoder&, LayerNode&)
+{
+	grib.open();
+	long date = grib.getLong("date");    
+    long hour = grib.getLong("hour");  
+    long mn   = grib.getLong("minute"); 
+    long step = grib.getLong("step"); 
+       
+    Date part1 = Date(date);
+    Time part2 = Time(hour, mn, 0);
+    DateTime base(part1, part2);
+    base = base + (step *3600);
+    
+    
+    DateTime valid(part1, part2);
+    valid = valid + (step *3600);
+    valid = valid + ( long(span_) * 3600);    
+    ostringstream from, to;
+
+    tm convert = base;
+    locale loc("");
+      
+    from.imbue(loc);
+    to.imbue(loc);
+    
+    const time_put<char>& tfac = use_facet<time_put<char> >(loc); 
+    string format = "%Y-%m-%dT%H:%M:00Z";
+    tfac.put(from, from, ' ', &convert, format.c_str(), format.c_str()+format.length());    
+    
+    convert = valid;
+    
+    tfac.put(to, to, ' ', &convert, format.c_str(), format.c_str()+format.length());
+    layer.setName(from.str());
+	layer.timestamp(from.str());
+	layer.timespan(to.str());
+}
+
+
+void ParamGribLoopStep::operator()(GribDecoder&, LayerNode& layer)
+{
+	layer.timestamp("unknown");
+	layer.timespan("unnkwon");
+	
+}
+
+*/
+
+
+	
+
diff --git a/src/decoders/GribLoopStep.h b/src/decoders/GribLoopStep.h
new file mode 100644
index 0000000..c3525fe
--- /dev/null
+++ b/src/decoders/GribLoopStep.h
@@ -0,0 +1,114 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file GribLoopStep.h
+    \brief Definition of the Template class GribLoopStep
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 16-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef GribLoop_H
+#define GribLoop_H
+
+#include "magics.h"
+#include "MagException.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "DateGribLoopStepAttributes.h"
+namespace magics {
+
+class GribDecoder;
+class XmlNode;
+class LayerNode;
+
+class GribLoopStep
+{
+public:
+	GribLoopStep() {}
+	virtual ~GribLoopStep() {}
+	virtual void set(const map<string, string>& ) {}
+	virtual void set(const XmlNode& ) {}
+	virtual bool accept(const string& ) { return false;}
+	//virtual void operator()(GribDecoder&) {}
+	virtual GribLoopStep* clone() { return new GribLoopStep(); }
+	virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << " const ---> to be checked!...\n";
+    }
+
+protected :
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	GribLoopStep(const GribLoopStep&);
+	//! Overloaded << operator to copy - No copy allowed
+	GribLoopStep& operator=(const GribLoopStep&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribLoopStep& p)
+		{ p.print(s); return s; }
+};
+
+
+class DateGribLoopStep : public GribLoopStep, public DateGribLoopStepAttributes
+{
+public:
+	DateGribLoopStep() {}
+	~DateGribLoopStep() {}
+	void set(const XmlNode& node) { DateGribLoopStepAttributes::set(node); }
+	bool accept(const string& node) { return DateGribLoopStepAttributes::accept(node);; }
+	GribLoopStep* clone() { return new DateGribLoopStep(); }
+	//virtual void operator()(GribDecoder&, LayerNode&);
+};
+
+class ParamGribLoopStep : public GribLoopStep
+{
+public:
+	ParamGribLoopStep() {}
+	~ParamGribLoopStep() {}
+	//virtual void operator()(GribDecoder&, LayerNode&);
+	GribLoopStep* clone() { return new ParamGribLoopStep(); }
+};
+
+
+template <>
+class MagTranslator<string, GribLoopStep> { 
+public:
+	GribLoopStep* operator()(const string& val)
+	{
+		return SimpleObjectMaker<GribLoopStep>::create(val);
+	}
+
+	GribLoopStep* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namepace magics
+#endif
diff --git a/src/decoders/GribRegularInterpretor.cc b/src/decoders/GribRegularInterpretor.cc
new file mode 100644
index 0000000..6d53aba
--- /dev/null
+++ b/src/decoders/GribRegularInterpretor.cc
@@ -0,0 +1,1403 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribRegularInterpretor.cc
+    \brief Implementation of the Template class GribRegularInterpretor.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon 18-Apr-2005
+
+    Changes:
+*/
+
+#include <limits>
+
+#include "CustomisedPoint.h"
+#include "TeProjection.h"
+#include "GribRegularInterpretor.h"
+#include "GribDecoder.h"
+#include "Matrix.h"
+#include "LocalTable.h"
+#include "RasterData.h"
+#include "Timer.h"
+
+
+using namespace magics;
+
+GribRegularInterpretor::GribRegularInterpretor() 
+{
+}
+
+GribRegularInterpretor::~GribRegularInterpretor() 
+{
+}
+
+void GribInterpretor::longitudesSanityCheck(double& west, double& east) const
+{
+	 // make sure that the west longitudes is always inferior to teh East longitudes and always 
+	// betwwen -180 and 360...
+	
+	while ( east <= west) {		
+		// We add 360 to the east ...
+		east += 360;
+	}
+	
+	// We reposition if needed 
+	
+	while ( east > 360 ) {
+		west -= 360.;
+		east -= 360.;
+	}
+}
+void GribInterpretor::scaling(const GribDecoder& grib, double& scaling, double& offset) const
+{
+	string originalUnits,derivedUnits;
+	this->scaling(grib,scaling,offset,originalUnits,derivedUnits);
+}	
+  
+  
+void GribInterpretor::scaling(const GribDecoder& grib, double& scaling, double& offset,
+			      string& originalUnits, string& derivedUnits) const
+{
+	scaling = 1;
+	offset  = 0;
+
+	// First check that they are not derived fields! 
+
+	if (grib.scaling_ || grib.derived_scaling_)
+	{
+		long derived = grib.getLong("generatingProcessIdentifier");
+
+		if ( (derived != 254 && grib.scaling_) || (derived == 254 && grib.derived_scaling_) )
+		{
+			// The key 'paramId' embodies a number of features such as centre, parameter,
+			// level, etc. This means that we should not need to worry about table
+			// numbers, etc as we did with GRIBEX. However, it's not entirely clear
+			// what we can do with non-ECMWF data, as we don't seem to have tables
+			// giving scaling factors & offsets for such data. The code, as originally
+			// written here takes a table-based approach, but this will probably
+			// become redundant. What we really need is something more based on paramIds.
+			// In the meantime, we will take the paramIds as if they are from ECMWF data.
+			// In practice, this means pretending that all data is from
+			// centre=98,table=128.
+
+			long table   = 128; // hard-coded in case of GRIB 2
+			long centre  = 98;  // hard-coded in case of GRIB 2
+
+			//long edition = grib.getLong("edition");
+			//
+			//if (edition == 1)
+			//{
+			//	table  = grib.getLong("table2Version");
+			//	centre = grib.getLong("centre");
+			//}
+			//else
+			//{
+			//	// GRIB 2 does not use the table-based approach, so we just hope that this will
+			//	// work with most data if we use the standard ECMWF tables...
+			//}
+
+
+			long id = grib.getLong("paramId");
+
+			try {
+				const ParamDef& paramdef = LocalTable::localInfo(id, table, centre);
+				scaling = paramdef.scaling();
+				offset = paramdef.offset();
+				originalUnits =paramdef.originalUnit();
+				derivedUnits =paramdef.derivedUnit();
+			}
+			catch (...) {
+				MagLog::warning() << " Can not find information for the parameter [" << id << "." << table << "]\n";
+			}
+            		}
+	}
+	else {
+		scaling = grib.scaling_factor_;
+		offset  = grib.scaling_offset_;
+	}
+	// Add a sanity check : the factor can not be 0..
+	if (scaling == 0)
+		scaling = 1;
+}
+
+
+void GribInterpretor::scaling(const GribDecoder& grib, Matrix** matrix) const
+{
+	double factor, offset;
+
+	scaling(grib, factor, offset);
+
+	(*matrix)->multiply(factor);
+	(*matrix)->plus(offset);
+}
+
+
+void GribInterpretor::raw(const GribDecoder& grib, const Transformation& transformation, const string& key, CustomisedPointsList& points) const
+{
+	double factor, offset;
+	scaling(grib, factor, offset);
+	int err;
+
+    grib_iterator* iter = grib_iterator_new(grib.handle(), 0,&err);                                     
+    double missing = grib.getDouble("missingValue");
+
+
+    double lat, lon, value;
+        /* Loop on all the lat/lon/values. */
+    while(grib_iterator_next(iter,&lat,&lon,&value)) {   
+  
+      
+      if (value != missing ) {
+    	  std::stack<UserPoint>   duplicates;
+    	  UserPoint geo(lon, lat);
+    	  value = (value*factor)+offset;
+    	  
+    	 transformation.wraparound(geo, duplicates);
+		 while (duplicates.empty() == false) {
+			UserPoint pt = duplicates.top();
+			CustomisedPoint *point = new CustomisedPoint(pt.x(), pt.y(), "");
+			point->insert(make_pair(key, value));
+			points.push_back(point);
+			duplicates.pop();
+		 }
+    	
+      }
+       
+    }
+
+        /* At the end the iterator is deleted to free memory. */
+    grib_iterator_delete(iter);               
+
+	
+}
+/*!
+ Class information are given to the output-stream.
+*/		
+void GribRegularInterpretor::print(ostream& out)  const
+{
+	out << "GribRegularInterpretor[";
+	out << "]";
+}
+
+void GribRegularInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix, const Transformation& ) const
+{
+	interpretAsMatrix(grib, matrix);
+}
+
+void GribRegularInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix) const 
+{
+  Timer timer("gribapi", " read grib");
+  MagLog::dev() << "GribRegularInterpretor::interpretAsMatrix" << "\n";
+  long nblon = grib.getLong("numberOfPointsAlongAParallel");
+  long nblat = grib.getLong("numberOfPointsAlongAMeridian");
+  
+  if ( *matrix == 0 ) *matrix = new Matrix(nblat, nblon);
+  
+  
+  size_t nb;
+  grib_get_size(grib.id(), "values", &nb);
+
+  MagLog::dev() << "numberOfFieldValues[" << nb << "]" << "\n";
+  double missing = INT_MAX;
+  grib.setDouble("missingValue", missing);    
+  (*matrix)->missing(missing);
+  (*matrix)->akimaEnabled();
+
+  double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+  double west = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+  double south = grib.getDouble("latitudeOfLastGridPointInDegrees");; 
+  double east = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+  longitudesSanityCheck(west, east);
+
+
+
+  MagLog::dev() << "NewAPI---> area[" << west << ", " << north << ", " << east << ", " << south << "]" << "\n";
+  double loni = longitudeIncrement(grib);
+  
+  double lon = (east-west)/(nblon-1);
+  
+  MagLog::dev() << "increment -->" << loni << " (from->" << west << " to-->" << west + (nblon-1) *loni << ")" <<  endl;
+  MagLog::dev() << "calcul -->" << lon << " (from->" << west << " to-->" << west + (nblon-1) *lon << ")" <<  endl;
+
+  latitudes(grib, (*matrix)->rowsAxis());
+ 
+  double x = west;
+  for (int i = 0; i < nblon; i++)
+  {
+	(*matrix)->columnsAxis().push_back(x);
+	x  = west + (i+1)*lon;
+  }
+	
+  (*matrix)->setMapsAxis();
+
+
+  long jPointsAreConsecutive = grib.getLong("jPointsAreConsecutive");
+
+  try
+  { 
+	(*matrix)->resize(nb);
+  	size_t aux = size_t(nb);
+
+    // if jPointsAreConsecutive=1 then the values represent columns of data instead
+    // of rows, so we have to 'reshape' the array so that it is reorganised into rows.
+
+    if (jPointsAreConsecutive)
+    {
+        vector<double> *d = new vector<double>(nb);  // temporary array
+        double *d1 = &d->front();                    // temporary array pointer
+        double *d2 = &(*matrix)->front();            // final array
+    
+  	    grib_get_double_array(grib.id(), "values", d1, &aux); 
+
+        for (int i = 0; i < nblon; i++)
+        {
+            for (int j = 0; j < nblat; j++)
+            {
+                d2[j*nblon + i] = d1[i*nblat + j];
+            }
+        }
+
+        delete d;
+    }
+    else  // otherwise, just copy the array of values as they are
+    {
+        grib_get_double_array(grib.id(),"values", &(*matrix)->front(),&aux); 
+    }
+
+  	(*matrix)->missing(missing);
+
+
+  } 
+  catch (...) 
+  {
+	throw MagicsException("GribRegularInterpretor - Not enough memory");
+  }
+}
+
+
+void  GribRegularInterpretor::latitudes(const GribDecoder& grib, vector<double>& latitudes) const
+{
+		double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");	
+
+		long nblat = grib.getLong("numberOfPointsAlongAMeridian");
+		int scanning = grib.getLong("jScansPositively") ? 1 : -1;
+		double lat =  scanning * grib.getDouble("jDirectionIncrementInDegrees");
+	
+		double y = north;
+		for (int i = 0; i < nblat; i++)
+		{
+				latitudes.push_back(y);
+				 y  += lat;
+		}
+}
+
+
+void GribRegularGaussianInterpretor::latitudes(const GribDecoder& grib, vector<double>& latitudes) const 
+{
+	long res     = grib.getLong("numberOfParallelsBetweenAPoleAndTheEquator");
+	double array[2 *res];
+	grib_get_gaussian_latitudes(res, array);
+	 double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+	 
+	  double south = grib.getDouble("latitudeOfLastGridPointInDegrees");; 
+	
+	for ( int i = 0; i < 2*res; i++ )
+	{
+		if ( array[i] <= north && array[i] >= south)
+			latitudes.push_back(array[i]);
+	}
+	
+}
+
+
+double GribRegularInterpretor::longitudeIncrement(const GribDecoder& grib) const 
+{
+	int scanning = grib.getLong("iScansNegatively") ? -1 : 1;
+	return scanning * grib.getDouble("iDirectionIncrementInDegrees");	
+	
+}
+
+
+
+
+void GribRegularInterpretor::interpretAsRaster(const GribDecoder& grib, RasterData& raster,const Transformation& transformation) const
+{
+	MagLog::dev() << "GribRegularInterpretor::interpretAsRaster" << "\n";
+	
+	BoxMatrixHandler box(const_cast<GribDecoder* >(&grib)->matrix(), transformation);
+	
+	int nblon = box.columns();
+	int nblat = box.rows();
+	double east = box.column(0,nblon-1);
+	double west = box.column(0, 0);
+	double south = box.row(0, 0);
+	double north = box.row(nblat-1, 0);
+	
+	raster.setUpperRightCorner(east, north);
+	raster.setLowerLeftCorner(west, south);
+
+	double lon = (east-west)/(nblon-1);
+	double lat = (north-south)/(nblat-1);
+	
+	raster.setXResolution(lon);
+	raster.setYResolution(lat);
+	
+	raster.setColumns(nblon);
+	raster.setRows(nblat);
+//	
+	raster.setProjection(new TeLatLong(TeDatum()));
+
+	raster.reserve(nblon*nblat);
+	
+		for ( int j = nblat-1; j >= 0; j--)
+			for ( int i = 0; i < nblon; i++)
+				raster.push_back(box(j, i));
+}
+
+
+void GribReducedGaussianInterpretor::interpretAsRaster(const GribDecoder& grib, RasterData& raster,const Transformation& transformation) const
+{
+	MagLog::dev() << "GribRegularInterpretor::interpretAsRaster" << "\n";
+	Timer timer("grib api", "read grib" );
+	BoxMatrixHandler box(const_cast<GribDecoder* >(&grib)->matrix(), transformation);
+	
+	int nblon = box.columns();
+	int nblat = box.rows();
+	double east = box.column(0,nblon-1);
+	double west = box.column(0, 0);
+	double south = box.row(0, 0);
+	double north = box.row(nblat-1, 0);
+	
+	raster.setUpperRightCorner(east, north);
+	raster.setLowerLeftCorner(west, south);
+
+	double lon = (east-west)/(nblon-1);
+	double lat = (north-south)/(nblat-1);
+	
+	raster.setXResolution(lon);
+	raster.setYResolution(lat);
+	
+	raster.setColumns(nblon);
+	raster.setRows(nblat);
+//	
+	raster.setProjection(new TeLatLong(TeDatum()));
+
+	
+	raster.reserve(nblon*nblat);
+	
+		for ( int j = nblat-1; j >= 0; j--)
+			for ( int i = 0; i < nblon; i++)
+				raster.push_back(box(j, i));
+}
+
+
+void GribReducedGaussianInterpretor::print(ostream& out)  const
+{
+	out << "GribRegularInterpretor[";
+	out << "]";
+}
+
+#ifdef later
+class GribMatrix : public Matrix
+{
+public:
+	    GribMatrix(const GribDecoder& grib) : grib_(grib) {
+	    	
+	    }
+	    
+	    void prepare(double north = 90., double south = -90., double west = -180, double east = 180) 
+	    {
+	        Timer timer("gribapi", "subarea extraction");
+	    	int error;
+	    	box_ = grib_box_new(grib_.id(),&error);
+	    	// deal with the error! 
+	    	grib_points* points = grib_box_get_points(box_,north,west,south,east,&error);
+
+	    	double value[points->n];
+	    	grib_points_get_values(grib_.id(),points,value);
+	    	
+	    	map<double, vector<double> > positions;
+	    	map<double, vector<double> > values;
+	    	
+	    	for (unsigned int i=0;i<points->n;i++) {
+	    		map<double, vector<double> >::iterator pos = positions.find(points->latitudes[i]);
+	    		map<double, vector<double> >::iterator val = values.find(points->latitudes[i]);
+	    		if ( pos == positions.end() ) {
+	    			positions.insert(make_pair(points->latitudes[i], vector<double>()) );
+	    			values.insert(make_pair(points->latitudes[i], vector<double>()) );
+	    			pos = positions.find(points->latitudes[i]);
+	    			val = values.find(points->latitudes[i]);
+	    		}
+	    		pos->second.push_back(points->longitudes[i]);
+	    		val->second.push_back(value[i]);	    		   
+	    	}
+	    	unsigned int max = 0;
+	    	double lat = 0;
+	    
+	    	
+	    	for (map<double, vector<double> >::iterator pos = positions.begin(); pos != positions.end(); ++pos) {
+	    		if ( pos->second.size() > max ) {
+	    			max = pos->second.size();
+	    			lat = pos->first;
+	    		}
+	    		this->rowsAxis().push_back(pos->first);
+	    	}
+	    		vector<double>& longitudes = positions[lat];
+	    		
+
+	    		int nblon = longitudes.size();
+	    		double width = longitudes.back() -  longitudes.front();
+	    		double step = (width)/(nblon-1); 
+
+	    		for (map<double, vector<double> >::iterator pos = positions.begin(); pos != positions.end(); ++pos) {
+	    			
+	    			map<double, vector<double> >::iterator val = values.find(pos->first);
+	    			vector<double>& p =val->second;
+	    			double lon = longitudes.front();
+	    			unsigned int p1 = 0;
+	    			unsigned int p2 = 1;
+	    			double lon1 = lon;
+	    			double lon2 = lon1 + (width/(p.size()-1));
+
+	    			for ( unsigned int x = 0; x < longitudes.size(); x++ ) {
+	    				if ( lon >= lon2 ) {
+	    					p1++;
+	    					p2++;
+	    					lon1 = lon2;
+	    					lon2 += (width)/(p.size()-1);
+	    				}
+	    				double d1 = (lon2 - lon)/(lon2-lon1);
+	    				double d2 = 1-d1;
+	    				double val;
+	    				
+	    				assert ( p1 < p.size() );
+	    				if (p2 == p.size()) {
+	    					this->push_back(p[p1]);
+	    				}
+	    				else {
+	    					if (p[p1] == missing_ ||  p[p2] == missing_)
+	    						val = missing_;
+	    					else
+	    						val = (p[p1] * d1) + (p[p2] * d2);
+	    					this->push_back(val);
+	    				}
+	    				lon += step;
+	    			}
+	    		}
+	    		
+	    		for ( vector<double>::iterator lon = longitudes.begin(); lon != longitudes.end(); ++lon) 
+	    				this->columnsAxis().push_back(*lon);
+	    		
+	    		setMapsAxis();
+	    }
+		  
+protected:
+	const GribDecoder& grib_;
+	grib_box*                   box_;
+};
+#endif
+
+
+void GribReducedGaussianInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix, const Transformation& transformation) const
+{ 
+	interpretAsMatrix(grib, matrix);
+	//GribMatrix* helper = new GribMatrix(grib);
+	//*matrix = helper;
+	//double minlon, minlat, maxlon, maxlat;
+    	      
+	 //transformation.boundingBox(minlon, minlat, maxlon, maxlat);
+	 
+	// helper->prepare(maxlat, minlon, minlat, maxlon);
+}
+
+double GribReducedLatLonInterpretor::XResolution(const GribDecoder& grib) const
+{
+	long res     = grib.getLong("Nj");
+	
+
+	double west  = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+	double east  = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+	
+	longitudesSanityCheck(west, east);
+	
+	return (east-west)/(2*res);
+}
+double GribReducedGaussianInterpretor::XResolution(const GribDecoder& grib) const
+{
+	long res     = grib.getLong("numberOfParallelsBetweenAPoleAndTheEquator");
+	double west  = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+	
+	double east  = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+		
+	longitudesSanityCheck(west, east);
+	return (east-west)/(4*res);
+}
+
+void GribReducedGaussianInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix) const
+{
+	MagLog::dev() << "GribRegularInterpretor::interpretAsMatrix" << "\n";
+	MagLog::dev() << "GribRegularInterpretor::interpretAsMatrix" << "\n";
+ 
+	Timer timer("gribapi", " read grib");
+	*matrix = new Matrix();
+	size_t nb;
+	grib_get_size(grib.id(), "values", &nb);
+
+	MagLog::dev() << "numberOfFieldValues[" << nb << "]" << "\n";
+	double missing = std::numeric_limits<double>::max();
+	grib.setDouble("missingValue", missing);
+	(*matrix)->missing(missing);
+
+	(*matrix)->akimaEnabled();
+
+	double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+	double west  = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+	double south = grib.getDouble("latitudeOfLastGridPointInDegrees");; 
+	double east  = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+	double plp   = grib.getDouble("PLPresent");
+	long res     = grib.getLong("numberOfParallelsBetweenAPoleAndTheEquator");
+	longitudesSanityCheck(west, east);
+	MagLog::dev() << "NewAPI---> area[" << west << ", " << north << ", " << east << ", " << south << "]" << "\n";
+	MagLog::dev() << "PLPresent---> " << plp << "\n";
+	MagLog::dev() << "Res---> " << res << "\n";
+
+	double pl[2*res];
+
+	size_t aux = 2*res;
+	grib_get_double_array(grib.id(),"pl",pl,&aux);
+	
+    // We have to determine if the field is global! 
+	if (north-south > 175.) {
+        east = west + 360.;
+	}
+
+	// compute the number of points we'll be adding to the matrix so that we can
+	// allocate them in one go, rather than allowing the STL to re-allocate
+	// when we reach the capacity
+	(*matrix)->reserve(aux * 4 * res);
+
+	double *data = new double[nb];
+
+	size_t aux2 = size_t(nb);
+	int nblon = 4*res;
+	double width = east-west;
+	double step = (width)/(nblon);
+
+	grib_get_double_array(grib.id(),"values",data,&aux2);
+	int d = 0;
+	for ( size_t i = 0; i < aux; i++)
+	{
+		vector<double> p;
+		for ( int ii = 0; ii < pl[i]; ii++)
+		{
+			p.push_back(data[d]);
+			d++;
+		}
+		
+		double lon = west;
+		unsigned int p1 = 0;
+		unsigned int p2 = 1;
+		double lon1 = west;
+		double lon2 = lon1 + (width/(p.size()));
+
+		for ( int x = 0; x < 4*res; x++ )
+		{
+
+			if ( lon >= lon2 )
+			{
+				p1++;
+				p2++;
+				lon1 = lon2;
+				lon2 += (width)/(p.size());
+			}
+			double d1 = (lon2 - lon)/(lon2-lon1);
+			double d2 = 1-d1;
+			double val;
+			
+			assert ( p1 < p.size() );
+			if (p2 == p.size()) {
+				(*matrix)->push_back(p[p1]);
+			}
+			else {
+				if (p[p1] == missing ||  p[p2] == missing)
+					val = missing;
+				else
+					val = (p[p1] * d1) + (p[p2] * d2);
+				(*matrix)->push_back(val);
+			}
+			lon += step;
+		}
+
+	}
+
+	delete [] data;
+
+	for (int x = 0; x < nblon; x++)
+	{
+		(*matrix)->columnsAxis().push_back(west+(x*step));
+	}
+		
+	double array[2 *res];
+	long par = grib.getLong("numberOfParallelsBetweenAPoleAndTheEquator");
+	grib_get_gaussian_latitudes(par, array);
+
+	for ( int i = 0; i < 2*res; i++ )
+	{
+		(*matrix)->rowsAxis().push_back(array[i]);
+	}
+	(*matrix)->setMapsAxis();
+}
+
+void GribReducedLatLonInterpretor::print(ostream& out)  const
+{
+	out << "GribReducedLatLonInterpretor[";
+	out << "]";
+}
+
+void GribReducedLatLonInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix) const
+{
+	
+ 
+	Timer timer("gribapi", " read grib");
+    *matrix = new Matrix();
+	size_t nb;
+	grib_get_size(grib.id(), "values", &nb);
+
+	MagLog::dev() << "numberOfFieldValues[" << nb << "]" << "\n";
+	double missing = std::numeric_limits<double>::max();
+	grib.setDouble("missingValue", missing);
+	(*matrix)->missing(missing);
+	(*matrix)->akimaEnabled();
+
+	double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+	double west  = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+	double south = grib.getDouble("latitudeOfLastGridPointInDegrees");; 
+	double east  = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+	longitudesSanityCheck(west, east);
+	size_t res     = grib.getLong("Nj");
+
+	MagLog::dev() << "NewAPI---> area[" << west << ", " << north << ", " << east << ", " << south << "]" << "\n";
+	MagLog::dev() << "Res---> " << res << "\n";
+
+	double pl[res];
+	
+	long nblat = grib.getLong("numberOfPointsAlongAMeridian");
+	int scanning = grib.getLong("jScansPositively") ? 1 : -1;
+	double lat =  scanning * grib.getDouble("jDirectionIncrementInDegrees");
+
+	grib_get_double_array(grib.id(),"pl",pl,&res);
+
+	double *data = new double[nb];
+
+	size_t aux2 = size_t(nb);
+	int nblon = 2*res;
+	float width = east-west;
+	float step = (width)/(nblon-1); 
+	// We have to determine if the field is global! 
+        bool global = east-west > 360 - 5*step;
+        if (global) {
+                MagLog::dev() << "YES THE FIELD IS GLOBAL" << endl;
+                east = west + 360;
+        }
+
+	
+	grib_get_double_array(grib.id(),"values",data,&aux2);
+	int d = 0;
+	for ( size_t i = 0; i < res; i++)
+	{
+		float lon = west;
+	
+		float lon1 = west;
+		if ( pl[i] == 0 ) {
+			// add missing data 
+			for ( int x = 0; x < nblon; x++ ) 
+				(*matrix)->push_back(missing);
+		}
+		else
+		{
+			unsigned int p1 = 0;
+			unsigned int p2 = 1;
+			vector<double> p;
+
+			for ( int ii = 0; ii < pl[i]; ii++)
+			{
+				p.push_back(data[d]);
+				d++;
+			}
+		
+			float lon2 = lon1 + (width/(p.size()-1));
+
+			for ( int x = 0; x < nblon; x++ )
+			{
+				float d1 = (lon2 - lon)/(lon2-lon1);
+				float d2 = 1-d1;
+				double val; 
+				if (p[p1] == missing ||  p[p2] == missing)
+					val = missing;
+				else
+					val = (p[p1] * d1) + (p[p2] * d2);
+				(*matrix)->push_back(val);
+				lon += step;
+				if ( lon >= lon2 )
+				{
+					p1++;
+					if ( p1==p.size() )
+					{
+						p1 = 0;
+					}
+					p2++;
+					if ( p2 == p.size() )
+					{
+						p2 = 0;
+					}
+					lon1 = lon2;
+					lon2 += (width)/(p.size()-1);
+				}
+			}
+		}
+	}
+    
+	delete [] data;
+
+	float lon = (width) / (nblon-1);
+//	float lat = (north - south) / (2 *res);
+	for (int x = 0; x < nblon; x++)
+	{
+		(*matrix)->columnsAxis().push_back(west+(x*lon));
+	}
+
+	double y = north;
+	for (long i = 0; i < nblat; i++)
+	{
+		(*matrix)->rowsAxis().push_back(y);
+		y  += lat;
+	}
+
+	(*matrix)->setMapsAxis();
+}
+
+
+/*
+ * Imported from Metview MvGrid...
+ */ 
+
+
+void GribRotatedInterpretor::print(ostream& out) const
+{
+	out << "GribRotatedInterpretor[]";
+}
+
+
+UserPoint GribLambertAzimutalInterpretor::unrotate(double lat, double lon) const
+{
+	  
+	  return UserPoint(lon, lat);
+}
+
+pair<double, double> GribRotatedInterpretor::unrotate( double lat_y, double lon_x) const
+{
+	const double cToRadians         = M_PI/180.0;    
+	double ZRADI  = 1./cToRadians; 
+	double ZSYCEN = sin(cToRadians*(southPoleLat_+90.));  
+	double ZCYCEN = cos(cToRadians*(southPoleLat_+90.));            
+	double ZSXROT = sin(cToRadians*lon_x);                                       
+	double ZCXROT = cos(cToRadians*lon_x);                                   
+	double ZSYROT = sin(cToRadians*lat_y);                                    
+	double ZCYROT = cos(cToRadians*lat_y);                                  
+	double ZSYREG = ZCYCEN*ZSYROT + ZSYCEN*ZCYROT*ZCXROT;             
+	ZSYREG = MAX( MIN(ZSYREG, +1.0), -1.0 );                                            
+	double PYREG = asin(ZSYREG)*ZRADI;                                   
+	double ZCYREG = cos(PYREG*cToRadians);                         
+	double ZCXMXC = (ZCYCEN*ZCYROT*ZCXROT - ZSYCEN*ZSYROT)/ZCYREG;                           
+	ZCXMXC = MAX( MIN(ZCXMXC, +1.0), -1.0 );                                                
+	double ZSXMXC = ZCYROT*ZSXROT/ZCYREG;                                       
+	double ZXMXC  = acos(ZCXMXC)*ZRADI;                                            
+	if( ZSXMXC < 0.0)                                                                             
+		ZXMXC = -ZXMXC;                                                          
+	double PXREG = ZXMXC + southPoleLon_;                        
+	return make_pair( PYREG, PXREG );                                     
+}               
+
+pair<double, double> GribRotatedInterpretor::rotate( double lat_y, double lon_x) const
+{
+  const double cToRadians         = M_PI/180.0;
+  double ZRADI  = 1./cToRadians;
+  double ZSYCEN = sin(cToRadians*(southPoleLat_+90.));
+  double ZCYCEN = cos(cToRadians*(southPoleLat_+90.));
+
+  double ZXMXC  = cToRadians*(lon_x - southPoleLon_);
+  double ZSXMXC = sin(ZXMXC);
+  double ZCXMXC = cos(ZXMXC);
+  double ZSYREG = sin(cToRadians*lat_y);
+  double ZCYREG = cos(cToRadians*lat_y);
+  double ZSYROT = ZCYCEN*ZSYREG - ZSYCEN*ZCYREG*ZCXMXC;
+  ZSYROT = MAX( MIN(ZSYROT, +1.0), -1.0 );
+
+  double PYROT  = asin(ZSYROT)*ZRADI;
+
+  double ZCYROT = cos(PYROT*cToRadians);
+  double ZCXROT = (ZCYCEN*ZCYREG*ZCXMXC + ZSYCEN*ZSYREG)/ZCYROT;
+  ZCXROT = MAX( MIN(ZCXROT, +1.0), -1.0 );
+  double ZSXROT = ZCYREG*ZSXMXC/ZCYROT;
+
+  double PXROT = acos(ZCXROT)*ZRADI;
+
+  if( ZSXROT < 0.0)
+    PXROT = -PXROT;
+
+  return make_pair( PYROT, PXROT );
+}
+
+
+void GribLambertAzimutalInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix) const
+{
+	  long im = grib.getLong("numberOfPointsAlongXAxis");
+	  long jm = grib.getLong("numberOfPointsAlongYAxis");
+	  
+	  *matrix = new Matrix(im, jm);
+	  
+	
+	  
+	  size_t nb;
+	  grib_get_size(grib.id(), "values", &nb);
+
+	  
+
+	  MagLog::dev() << "numberOfFieldValues[" << nb << "]" << "\n";
+	  double missing = -std::numeric_limits<double>::max();
+	  missing = grib.getDouble("missingValue");    
+	  
+
+	  double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+	  double west = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+	  
+	  MagLog::dev() << "NewAPI---> area[" << west << ", " << north << "]" << "\n";
+	  
+	  
+
+	 
+	 
+	 
+	  
+      		try
+		{
+			Timer time("Grib", "lambert");
+				
+               
+			
+					
+			MagLog::debug() << "Version" << 	grib_get_api_version()<< endl;
+    
+            vector<double> latm;
+            vector<double> lonm;
+            vector<double> data;
+            latm.reserve(nb);
+            lonm.reserve(nb);
+            data.reserve(nb);
+            
+			size_t aux = size_t(nb);
+	        
+            grib_get_double_array(grib.id(),"latitudes",&(latm.front()),&aux); 
+     
+            double minlat = *min_element(latm.begin(), latm.end());
+	         double maxlat =*max_element(latm.begin(), latm.end());;
+            grib_get_double_array(grib.id(),"longitudes",&(lonm.front()),&aux); 
+     
+            double minlon = *min_element(lonm.begin(), lonm.end());
+	         double maxlon =*max_element(lonm.begin(), lonm.end());;
+            
+             // This test needs to be improved ...
+            
+             if (minlon > 50.) minlon -=360;
+             if (maxlon > 50.) maxlon -=360;
+             
+			
+            grib_get_double_array(grib.id(),"values", &(data.front()),&aux); 
+            double min = *min_element(data.begin(), data.end());
+	         double max =*max_element(data.begin(), data.end());;
+    
+     for ( int i = 0; i < nb; i++) {
+     if (lonm[i] > 50.) lonm[i] = lonm[i] -360;
+       
+        
+        if ( minlat > latm[i] ) minlat=latm[i];
+        if ( maxlat < latm[i] ) maxlat=latm[i];         
+        if ( minlon > lonm[i] ) minlon=lonm[i];
+        if ( maxlon < lonm[i] ) maxlon=lonm[i];
+    }
+	  
+     
+      
+        MagLog::debug() << "lat [" << minlat << ", " << maxlat << "]" <<endl;
+		MagLog::debug()	<< "lon [" << minlon << ", " << maxlon << "]" <<endl;
+				
+ 
+	  
+
+
+					vector<double>& lon = (*matrix)->columnsAxis();
+					vector<double>& lat = (*matrix)->rowsAxis();
+
+					// for the lon we take the fisrt line :
+					double inci = (maxlon - minlon)/((im) -1);
+					double incj = (maxlat - minlat)/((jm) -1);
+					for (int i = 0; i < im; i++)
+						lon.push_back(minlon + (i*inci));
+					// for the lon we take the fisrt column :
+					for (int i = 0; i < jm; i++)
+						lat.push_back(minlat + (i*incj));
+
+					typedef map<double, map<double, pair<int, int> > > Helper;
+
+					//typedef map<double, double> Helper;
+					Helper helper;
+					int row = 0;
+					for (vector<double>::iterator y = lat.begin(); y != lat.end(); ++y) {
+
+						helper.insert(make_pair(*y, map<double, pair<int, int>  >()));
+
+						Helper::iterator h = helper.find(*y);
+
+						int column = 0;
+						for (vector<double>::iterator x = lon.begin(); x != lon.end(); ++x) {
+							h->second.insert(make_pair(*x, make_pair(row, column)));
+
+							(*matrix)->push_back(missing);
+							column++;
+
+						}
+						row++;
+					}
+
+
+
+					int r = 0;
+					int c = 0;
+
+					double lat11, lat12, lat21, lat22;
+					double lon11, lon12, lon21, lon22;
+					double val11, val12, val21, val22;
+
+					for (int r = 0; r < jm -1; r++) {
+						for (int c = 0;  c < im -1; c++) {
+
+							lat11 = latm[c + (im*r)];
+
+							lat12 = latm[(c+1) + (im*r)];
+							minlat = std::min(lat11, lat12);
+							maxlat = std::max(lat11, lat12);
+							lat21 = latm[c + (im* (r+1))];
+							minlat = std::min(minlat, lat21);
+							maxlat = std::max(maxlat, lat21);
+							lat22 = latm[(c+1) + (im* (r+1))];
+							minlat = std::min(minlat, lat22);
+							maxlat = std::max(maxlat, lat22);
+
+							lon11 = lonm[c + (im*r)];
+							lon12 = lonm[(c+1) + (im*r)];
+							if ( lon12 < lon11 )
+								lon12 +=360.;
+							minlon = std::min(lon11, lon12);
+							maxlon = std::max(lon11, lon12);
+							lon21 = lonm[c + (im* (r+1))];
+							minlon = std::min(minlon, lon21);
+							maxlon = std::max(maxlon, lon21);
+							lon22 = lonm[(c+1) + (im* (r+1))];
+							if ( lon22 < lon21 )
+									lon22 +=360.;
+							minlon = std::min(minlon, lon22);
+							maxlon = std::max(maxlon, lon22);
+
+							val11 = data[c + (im*r)];
+							val12 = data[(c+1) + (im*r)];
+							val21 = data[c + (im* (r+1))];
+							val22 = data[(c+1) + (im* (r+1))];
+
+
+
+							// find the points from the helper!
+							Helper::iterator low,up;
+							low = helper.lower_bound(minlat);
+							up = helper.lower_bound(maxlat);
+							if ( low == helper.end() || up == helper.end() )
+								break;
+							for (Helper::iterator it = low; it != up; ++it) {
+								if (it == helper.end()) break;
+								map<double, pair<int, int> >&  lons = it->second;
+								map<double, pair<int, int> >::iterator llow = lons.lower_bound(minlon);
+								map<double, pair<int, int> >::iterator lup = lons.lower_bound(maxlon);
+								if ( llow == lons.end() || lup == lons.end() )
+									break;;
+								for (map<double, pair<int, int> >::iterator lit = llow; lit != lup; ++lit) {
+
+									double lat = it->first;
+									double lon = lit->first;
+									pair<int, int> index = lit->second;
+
+									// we interpolate at the point using the 4 points found!
+									double val = missing;
+									if ( val11 != missing && val12 != missing && val21 != missing && val22 != missing) {
+										double val1 =  	((lon12 - lon )/(lon12-lon11))*val11 + ((lon - lon11)/(lon12-lon11))*val12;
+
+										double val2 =  	((lon22 - lon )/(lon22-lon21))*val21 + ((lon - lon21)/(lon22-lon21))*val22;
+										if ( isnan(val1) ) {
+											if ( isnan(val2) ) {
+												val = missing;
+											}
+											else
+												val = ((lat - lat11)/(lat22-lat11))*val2;
+										}
+										else {
+											if ( isnan(val2) ) {
+												val =  	((lat22 - lat )/(lat22-lat11))*val1;
+											}
+											else {
+												val =  	((lat22 - lat )/(lat22-lat11))*val1 + ((lat - lat11)/(lat22-lat11))*val2;
+											}
+										}
+
+										if (isnan(val) || isinf(val) || isinf(-val) ) {
+											val = missing;
+										}
+									}
+									if (isnan(val) ) val = missing;
+									if ( (**matrix)[index.second +( index.first*im)] == missing ) {
+										(**matrix)[index.second +( index.first*im)] = val;
+                                        
+                                    }
+
+								}
+
+
+							}
+
+
+					}
+
+
+					 (*matrix)->setMapsAxis();
+                     (*matrix)->missing(missing);
+					}
+
+					
+
+					
+	        
+			MagLog::dev() << **matrix << "\n";
+			
+		}
+	    
+		catch (MagicsException& e)
+		{
+			MagLog::error() << e << "\n";
+		}
+        
+}
+
+
+
+void GribLambertAzimutalInterpretor::print(ostream& out) const
+{
+	out << "GribLambertAzimutalInterpretor[]";
+}
+
+void GribRotatedInterpretor::interpretAsMatrix(const GribDecoder& grib, Matrix** matrix) const
+{
+
+	southPoleLat_  = grib.getDouble("latitudeOfSouthernPoleInDegrees");
+	southPoleLon_  = grib.getDouble("longitudeOfSouthernPoleInDegrees");
+	angle_  = grib.getDouble("angleOfRotationInDegrees") * 180.0/M_PI;
+	uvRelativeToGrid_  = grib.getLong("uvRelativeToGrid");
+	if ( original_ ) {
+		long nblon = grib.getLong("numberOfPointsAlongAParallel");
+		long nblat = grib.getLong("numberOfPointsAlongAMeridian");
+
+		*matrix = new RotatedMatrix(nblat, nblon);
+		size_t nb;
+		grib_get_size(grib.id(), "values", &nb);
+
+		MagLog::dev() << "numberOfFieldValues[" << nb << "]" << "\n";
+		double missing = -std::numeric_limits<double>::max();
+		grib.setDouble("missingValue", missing);
+
+		(*matrix)->missing(missing);
+
+		double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+		double west = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+		double south = grib.getDouble("latitudeOfLastGridPointInDegrees");;
+		double east = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+		longitudesSanityCheck(west, east);
+
+
+		double lon = (east-west)/(nblon-1);
+		double lat =   (south-north)/(nblat-1);
+
+		vector<double>& rows = static_cast<RotatedMatrix*>(*matrix)->rowsArray();
+		vector<double>& columns = static_cast<RotatedMatrix*>(*matrix)->columnsArray();
+		vector<double>& values = static_cast<RotatedMatrix*>(*matrix)->values();
+		MagLog::dev() << "calcul -->" << lon << " (from->" << west << " to-->" << west + (nblon-1) *lon << ")" <<  endl;
+
+		double y = north;
+		for (int i = 0; i < nblat; i++)
+		{
+			double x = west;
+			for (int  j = 0; j < nblon; j++)
+			{
+				if ( i == 0 )
+					(*matrix)->columnsAxis().push_back(x);
+				pair<double, double> point = unrotate(y, x);
+				columns.push_back(point.second);
+				rows.push_back(point.first);
+				x  = west + (j+1)*lon;
+
+			}
+
+			y  = north + (i+1)*lat;
+
+		}
+
+
+
+
+
+
+		try {
+			(*matrix)->resize(nb);
+			size_t aux = size_t(nb);
+			grib_get_double_array(grib.id(),"values", &values.front(),&aux);
+		}
+		catch (...)
+		{
+			throw MagicsException("Not enough memory");
+		}
+
+
+		return;
+	}
+
+
+	long nblon = grib.getLong("numberOfPointsAlongAParallel");
+	long nblat = grib.getLong("numberOfPointsAlongAMeridian");
+	*matrix = new Matrix(nblat, nblon);
+
+	Matrix* helper = new Matrix(nblat, nblon); // settup as the equivalent regular matrix! 
+
+	size_t nb;
+	grib_get_size(grib.id(), "values", &nb);
+
+	MagLog::dev() << "numberOfFieldValues[" << nb << "]" << "\n";
+	double missing = -std::numeric_limits<double>::max();
+	grib.setDouble("missingValue", missing);    
+	helper->missing(missing);
+	(*matrix)->missing(missing);
+
+	double north = grib.getDouble("latitudeOfFirstGridPointInDegrees");
+	double west = grib.getDouble("longitudeOfFirstGridPointInDegrees");
+	double south = grib.getDouble("latitudeOfLastGridPointInDegrees");; 
+	double east = grib.getDouble("longitudeOfLastGridPointInDegrees");;
+	longitudesSanityCheck(west, east);
+
+	MagLog::dev() << "NewAPI---> area[" << west << ", " << north << ", " << east << ", " << south << "]" << "\n";
+
+	double lon = (east-west)/(nblon-1);
+	double lat =   (south-north)/(nblat-1);
+
+	MagLog::dev() << "calcul -->" << lon << " (from->" << west << " to-->" << west + (nblon-1) *lon << ")" <<  endl;
+    
+	double y = north;
+    	for (int i = 0; i < nblat; i++)
+    	{
+    	    
+    		helper->rowsAxis().push_back(y);
+    		y  = north + (i+1)*lat;
+    		
+    	}
+    	
+   
+   
+
+   
+	double x = west;
+  	for (int i = 0; i < nblon; i++)
+  	{
+  	    
+  		helper->columnsAxis().push_back(x);
+  		x  = west + (i+1)*lon;
+  		
+  	}
+  
+	helper->setMapsAxis();
+
+
+	try { 
+		helper->resize(nb);
+		size_t aux = size_t(nb);
+		grib_get_double_array(grib.id(),"values", &helper->front(),&aux); 
+	} 
+	catch (...) 
+	{
+		throw MagicsException("Not enough memory");
+	}
+   
+  
+	
+
+
+	lon = west; 
+	lat = north; 
+	double steplon = (east-west)/(nblon-1);
+	double steplat = (south-north)/(nblat-1);
+
+	// Fisrt try to find the bounding box 
+	vector<double>  rows;
+	rows.reserve(nb);
+	vector<double>  columns;
+	columns.reserve(nb);
+	vector<double>  values;
+	values.reserve(nb);
+
+	for ( int j = 0; j < nblat; j++ )
+	{
+		lon = west;
+		
+		for ( int i = 0; i < nblon; i++ )
+		{
+			pair<double, double> point = unrotate(lat,lon);
+			
+			
+			
+
+			rows.push_back(point.first);   
+			columns.push_back(point.second);
+			
+			lon += steplon;
+		}
+		lat += steplat;
+	}
+
+	double minx = *std::min_element(columns.begin(), columns.end());
+	double maxx = *std::max_element(columns.begin(), columns.end());
+	double miny = *std::min_element(rows.begin(), rows.end());
+	double maxy = *std::max_element(rows.begin(), rows.end());
+	
+	
+	
+
+	double stepx = (maxx - minx)/(nblon-1);
+	double stepy = (maxy - miny)/(nblat-1);
+	x = minx;
+	y = miny;
+	// Create the Axis for Regular Matrix..
+	for ( int i = 0; i < nblon; i++)
+	{
+		(*matrix)->columnsAxis().push_back(x); 
+		x += stepx;
+	}
+	for ( int j = 0; j < nblat; j++)
+	{
+		(*matrix)->rowsAxis().push_back(y); 
+		y +=  stepy;
+	}
+
+	miny = std::min(north, south);
+	maxy = std::max(north, south);
+	minx = std::min(west, east);
+	maxx = std::max(west, east);
+	
+	(*matrix)->setMapsAxis();
+	for ( int j = 0; j < nblat; j++)
+	{
+		for ( int i = 0; i < nblon; i++)
+		{
+			
+		    pair<double, double> point = rotate( (*matrix)->row(j, i), (*matrix)->column(j, i) );
+		    if ( point.first >  miny && point.first < maxy && point.second > minx && point.second < maxx )		    {	
+		    	(*matrix)->push_back(helper->interpolate(point.first, point.second));
+		    	
+		    }
+		    else {
+		    	(*matrix)->push_back(missing);
+		    	
+		    }
+		}
+	}
+}
+
+
+void GribRotatedInterpretor::interpret2D(double& lat, double& lon, double& uc, double& vc) const
+{
+	if ( !uvRelativeToGrid_ )
+		return;
+	double speed = sqrt((uc * uc) + (vc * vc));
+	double angle = atan2(vc,uc);
+
+	pair<double, double> pt = rotate(lat, lon);
+	pair<double, double> pv = unrotate(pt.first, pt.second + 1);
+
+	double rangle = atan2(pv.first - lat ,pv.second - lon) + angle;
+	//components.second *= f;
+	// we the angle and the spped we compute u/v...
+	uc = speed * cos(rangle);
+	vc = speed * sin(rangle);
+
+
+}
+
+void GribRotatedInterpretor::raw(const GribDecoder& grib, const Transformation& transformation, const string& key, CustomisedPointsList& points) const
+{
+	double factor, offset;
+	scaling(grib, factor, offset);
+	int err;
+	southPoleLat_  = grib.getDouble("latitudeOfSouthernPoleInDegrees");
+	southPoleLon_  = grib.getDouble("longitudeOfSouthernPoleInDegrees");
+	angle_  = grib.getDouble("angleOfRotationInDegrees") * 180.0/M_PI;;
+    grib_iterator* iter = grib_iterator_new(grib.handle(), 0,&err);
+    double missing = grib.getDouble("missingValue");
+
+
+    double lat, lon, value;
+        /* Loop on all the lat/lon/values. */
+    while(grib_iterator_next(iter,&lat,&lon,&value)) {
+
+      pair<double, double> coords = unrotate(lat, lon);
+      lat = coords.first;
+      lon = coords.second;
+      if (value != missing ) {
+    	  std::stack<UserPoint>   duplicates;
+    	  UserPoint geo(lon, lat);
+    	  value = (value*factor)+offset;
+
+    	 transformation.wraparound(geo, duplicates);
+		 while (duplicates.empty() == false) {
+			UserPoint pt = duplicates.top();
+			CustomisedPoint *point = new CustomisedPoint(pt.x(), pt.y(), "");
+			point->insert(make_pair(key, value));
+			points.push_back(point);
+			duplicates.pop();
+		 }
+
+      }
+
+    }
+
+        /* At the end the iterator is deleted to free memory. */
+    grib_iterator_delete(iter);
+
+
+}
diff --git a/src/decoders/GribRegularInterpretor.h b/src/decoders/GribRegularInterpretor.h
new file mode 100644
index 0000000..c4d58f9
--- /dev/null
+++ b/src/decoders/GribRegularInterpretor.h
@@ -0,0 +1,185 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribRegularInterpretor.h
+    \brief Definition of the Template class GribRegularInterpretor.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 18-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef GribRegularInterpretor_H
+#define GribRegularInterpretor_H
+
+#include "magics.h"
+
+#include "GribInterpretor.h"
+
+namespace magics {
+
+class GribRegularInterpretor: public GribInterpretor {
+
+public:
+	GribRegularInterpretor();
+	virtual ~GribRegularInterpretor();
+	
+	void interpretAsMatrix(const GribDecoder&, Matrix**) const; 
+	virtual double XResolution(const GribDecoder& grib) const { return  longitudeIncrement(grib); }
+	
+	void interpretAsMatrix(const GribDecoder&, Matrix**, const Transformation&) const; 
+	virtual void interpretAsRaster(const GribDecoder&, RasterData&, const Transformation&) const;
+    virtual void latitudes(const GribDecoder&, vector<double>&) const;
+    virtual double longitudeIncrement(const GribDecoder&) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	GribRegularInterpretor(const GribRegularInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	GribRegularInterpretor& operator=(const GribRegularInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribRegularInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+class GribReducedGaussianInterpretor: public GribInterpretor {
+
+public:
+	GribReducedGaussianInterpretor() {}
+	virtual ~GribReducedGaussianInterpretor() {}
+	
+	virtual double XResolution(const GribDecoder& grib) const;
+	void interpretAsMatrix(const GribDecoder&, Matrix**) const; 
+	void interpretAsMatrix(const GribDecoder&, Matrix**, const Transformation&) const; 
+	void interpretAsRaster(const GribDecoder&, RasterData&, const Transformation&) const;
+	
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	GribReducedGaussianInterpretor(const GribRegularInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	GribReducedGaussianInterpretor& operator=(const GribRegularInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribReducedGaussianInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+class GribReducedLatLonInterpretor: public GribInterpretor {
+
+public:
+	GribReducedLatLonInterpretor() {}
+	virtual ~GribReducedLatLonInterpretor() {}
+	
+	void interpretAsMatrix(const GribDecoder&, Matrix**) const; 
+	virtual double XResolution(const GribDecoder& grib) const;
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	GribReducedLatLonInterpretor(const GribRegularInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	GribReducedLatLonInterpretor& operator=(const GribRegularInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribReducedLatLonInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+class GribRotatedInterpretor: public GribRegularInterpretor {
+
+public:
+	GribRotatedInterpretor(): original_(false) {}
+	virtual ~GribRotatedInterpretor() {}
+	
+	pair<double, double> unrotate(double lat, double lon) const;
+	pair<double, double> rotate(double lat, double lon) const;
+	void raw(const GribDecoder&, const Transformation&, const string&, CustomisedPointsList&) const;
+	void keepOriginal(bool original) { original_ = original; }
+	void interpretAsMatrix(const GribDecoder&, Matrix**) const; 
+	void interpret2D(double&, double&, double&, double&) const;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 mutable double southPoleLat_;
+	 mutable double southPoleLon_;
+	 mutable double angle_;
+	 mutable bool uvRelativeToGrid_;
+
+	 bool original_;
+};
+
+class GribLambertAzimutalInterpretor: public GribRegularInterpretor {
+
+public:
+	GribLambertAzimutalInterpretor() {}
+	virtual ~GribLambertAzimutalInterpretor() {}
+	
+	UserPoint unrotate(double lat, double lon) const;
+	void interpretAsMatrix(const GribDecoder&, Matrix**) const; 
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 mutable double standardParallel_;
+	 mutable double centralLongitude_;
+
+   
+};
+
+
+
+
+class GribRegularGaussianInterpretor: public GribRegularInterpretor 
+{
+
+public:
+	GribRegularGaussianInterpretor() {}
+	virtual ~GribRegularGaussianInterpretor() {}
+	
+	void latitudes(const GribDecoder&, vector<double>&) const;
+
+protected:
+     
+
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/GribSatelliteInterpretor.cc b/src/decoders/GribSatelliteInterpretor.cc
new file mode 100644
index 0000000..b8cb590
--- /dev/null
+++ b/src/decoders/GribSatelliteInterpretor.cc
@@ -0,0 +1,132 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribSatelliteInterpretor.cc
+    \brief Implementation of the Template class GribSatelliteInterpretor.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon 18-Apr-2005
+
+    Changes:
+*/
+
+
+#include "CustomisedPoint.h"
+#include "GribSatelliteInterpretor.h"
+#include "GribDecoder.h"
+#include "RasterData.h"
+#include "TeProjection.h"
+
+using namespace magics;
+
+GribSatelliteInterpretor::GribSatelliteInterpretor() 
+{
+}
+
+
+GribSatelliteInterpretor::~GribSatelliteInterpretor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GribSatelliteInterpretor::print(ostream& out)  const
+{
+     out << "GribSatelliteInterpretor[";
+     out << "]";
+}
+
+
+void GribSatelliteInterpretor::interpretAsRaster(const GribDecoder& grib, RasterData& raster,const Transformation&) const
+{
+     MagLog::dev() << "GribSatelliteInterpretor::interpretAsRaster" << "\n";
+/*
+     \param datum:    planimetric datum
+     \param offx:     x offset
+     \param offy:     y offset
+     \param Pri:      Sensor angle resolution along y axis in radians
+     \param Prj:      Sensor angle resolution along x axis in radians
+     \param Pis:      Y-coordinate of sub-satellite point 
+     \param Pjs:      X-coordinate of sub-satellite point
+     \param Pla0:     Latitude of sub-satellite point in radians
+     \param Plo0:     Longitude of sub-satellite point in radians
+     \param Prs:      Radius of satellite orbit in meters
+     \param Pscn:     Scanning mode: 0-WE/NS, 1-SN/EW
+     \param Pyaw:     Grid orientation, i.e., angle in radians between
+			 the increasing y axis and the meridian of the
+			 sub-satellite point along the direction of
+			 increasing latitude.
+*/
+     double altitude = grib.getDouble("NrInRadiusOfEarth") * 0.000001;
+     long   nx   = grib.getLong("numberOfPointsAlongXAxis");
+     long   ny   = grib.getLong("numberOfPointsAlongYAxis");
+     double offx = grib.getDouble("xCoordinateOfOriginOfSectorImage");
+     double offy = grib.getDouble("yCoordinateOfOriginOfSectorImage");
+     double prj  = 2*asin(1/altitude)/grib.getDouble("dx");
+     double pri  = 2*asin(1/altitude)/grib.getDouble("dy");
+     double pjs  = grib.getDouble("XpInGridLengths");
+     double pis  = grib.getDouble("YpInGridLengths");
+     double lao  = grib.getDouble("latitudeOfSubSatellitePointInDegrees") *TeCDR;
+     double lono = grib.getDouble("longitudeOfSubSatellitePointInDegrees")*TeCDR;
+     double prs  = altitude * TeEARTHRADIUS;
+     double scn  = 0; // scanning mode later! 
+     double yaw  = grib.getDouble("orientationOfTheGrid");
+
+     yaw = RAD(yaw/1000);
+     if (yaw < 0.) yaw += PI;
+     else          yaw -= PI; 
+
+     TeSatelliteProjection* projection = new TeSatelliteProjection(TeDatum(), offx, offy, pri, prj, pis, pjs, lao, lono, prs, scn, yaw);
+
+     double resx = (double)( atan( tan(pri) * (altitude-1.) ) * TeEARTHRADIUS );
+     double resy = (double)( atan( tan(prj) * (altitude-1.) ) * TeEARTHRADIUS );
+
+     double west  = offx * resx;
+     double east  = (offx + nx - 1) * resx;
+     double north = -(offy * resy);
+     double south = -(offy + ny - 1) * resy;
+
+     raster.setXResolution(resx);
+     raster.setYResolution(resy);
+     raster.setColumns(nx);
+     raster.setRows(ny);
+     raster.setUpperRightCorner(east, north);
+     raster.setLowerLeftCorner(west, south);
+     raster.setProjection(projection);
+
+     size_t nb=0;
+     grib_get_size(grib.id(), "values", &nb);
+     raster.reserve(nb);
+
+     // If value is temperature in degrees K then add 145 to pixel value
+     double offset = (grib.getLong("functionCode") == 1) ? 145. : 0.;
+     
+    grib_get_double_array(grib.id(),"values",&raster.front(),&nb);
+    
+     if (offset) { 
+    	 for (unsigned int i = 0; i < nb; i++) {
+    		 	raster[i] +=offset;
+    	       
+    	 }
+     }
+     
+
+}
+
+static SimpleObjectMaker<GribSatelliteInterpretor, GribInterpretor> gribsatellite("90");
diff --git a/src/decoders/GribSatelliteInterpretor.h b/src/decoders/GribSatelliteInterpretor.h
new file mode 100644
index 0000000..ee42aa6
--- /dev/null
+++ b/src/decoders/GribSatelliteInterpretor.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribSatelliteInterpretor.h
+    \brief Definition of the Template class GribSatelliteInterpretor.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 18-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef GribSatelliteInterpretor_H
+#define GribSatelliteInterpretor_H
+
+#include "magics.h"
+
+#include "GribInterpretor.h"
+
+namespace magics {
+
+class GribSatelliteInterpretor: public GribInterpretor {
+
+public:
+	GribSatelliteInterpretor();
+	virtual ~GribSatelliteInterpretor();
+	
+	virtual void interpretAsRaster(const GribDecoder&, RasterData&, const Transformation&) const;
+    virtual void interpretAsVectors(const GribDecoder&, Matrix&, Matrix&) const 
+    	{ throw  NotYetImplemented("Satellite representation", " Vectors"); }
+    virtual void interpretAsMatrix(const GribDecoder&, Matrix&) const 
+    	{ throw  NotYetImplemented("Satellite representation", " Matrix "); }
+
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	GribSatelliteInterpretor(const GribSatelliteInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	GribSatelliteInterpretor& operator=(const GribSatelliteInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GribSatelliteInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/ImportAction.h b/src/decoders/ImportAction.h
new file mode 100644
index 0000000..e501395
--- /dev/null
+++ b/src/decoders/ImportAction.h
@@ -0,0 +1,127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImportAction.h
+    \brief Definition of the Template class ImportAction.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImportAction_H
+#define ImportAction_H
+
+#include "magics.h"
+
+#include "ImportActionAttributes.h"
+#include "Data.h"
+#include "TextVisitor.h"
+namespace magics {
+
+
+class ImportAction: public ImportActionAttributes, public Data {
+
+public:
+	ImportAction() {}
+	virtual ~ImportAction() {} 
+	void set(const map<string, string>& map) { ImportActionAttributes::set(map); }
+	
+	
+	string path() { return path_; }
+	
+	void visit(MetaDataCollector& collector) {
+		MetviewIcon::visit(collector);
+
+		MetaDataCollector::iterator format = collector.find("MV_Format");
+		if ( format != collector.end() ) {
+			format->second = service_;
+		}
+
+		MetaDataCollector::iterator name = collector.find("shortName");
+		if ( name != collector.end() ) {
+			name->second = short_name_;
+		}
+	 }
+
+	 void visit(TextVisitor& text)
+	 {
+		MetaDataCollector collector;
+		collector["service_name"]="";
+		collector["service_title"]="";
+		collector["title"]="";
+		collector["date"]="";
+		collector["time"]="";
+
+		MetviewIcon::visit(collector);
+
+		if(collector["service_name"] == "WMS")
+		{
+			string s="WMS: " + collector["title"] + " " + collector["date"] + " " + collector["time"];
+
+			text.addAutomaticTitle(s);
+		}	
+		else if(!url_.empty() && !service_.empty() )
+		{
+			text.addAutomaticTitle(service_ + " :" + url_);
+		} 
+	 }
+	   virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, bool ) {}
+	    //! Method to access the data as a list of points
+	     // needMissing : if true the list will contain all the points (If they are outside the area: They will be flagged missing)
+	     virtual PointsHandler& points(const Transformation&, bool) { assert(false); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "ImportAction["; ImportActionAttributes::print(out); out << "]"; }
+
+private:
+    //! Copy constructor - No copy allowed
+	ImportAction(const ImportAction&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImportAction& operator=(const ImportAction&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImportAction& p)
+		{ p.print(s); return s; }
+};
+
+
+class ImportLoop : public DataLoop, public vector<Data * >
+{
+public :
+	ImportLoop() {}
+	virtual ~ImportLoop() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual void set(LayerNode&) {}
+	
+	virtual void setToFirst() { current_ = this->begin(); }
+	virtual Data* current() { return *current_; }
+	virtual bool         hasMore() { return current_!= this->end(); }
+	virtual void         next() { ++current_; }
+	void add(Data* data) { push_back(data); }
+protected:
+	vector<Data * >::iterator current_;
+};
+} // namespace magics
+
+#endif
diff --git a/src/decoders/ImportActionAttributes.h b/src/decoders/ImportActionAttributes.h
new file mode 100644
index 0000000..0b354d5
--- /dev/null
+++ b/src/decoders/ImportActionAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ImportActionAttributes.h
+    \brief Definition of ImportAction Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef ImportActionAttributes_H
+#define ImportActionAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ImportActionAttributes 
+{
+public:
+//  --  constructor
+    ImportActionAttributes();
+    
+//  --  destructor
+    virtual ~ImportActionAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ImportActionAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string path_;
+	string valid_time_;
+	string service_;
+	string url_;
+	string short_name_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ImportActionAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/InputData.cc b/src/decoders/InputData.cc
new file mode 100644
index 0000000..0669702
--- /dev/null
+++ b/src/decoders/InputData.cc
@@ -0,0 +1,426 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file InputData.cc
+    \brief Implementation of the Template class InputData.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 6-May-2004
+    
+    Changes:
+    
+*/
+
+#include "InputData.h"
+#include "SciMethods.h"
+
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+
+void InputData::print(ostream& out)  const
+{
+	out << "InputData[";
+    InputDataAttributes::print(out);
+	out << "]";
+}
+
+
+void  InputData::dateSetting(vector<string>& dates, vector<double>& values, DateTime& base)
+{
+	if ( dates.empty() )
+		return;
+	base = DateTime(dates.front());
+	for (vector<string>:: iterator date = dates.begin(); date != dates.end(); ++ date ) {
+		DateTime d(*date);
+		values.push_back(d-base);
+	}
+}
+
+
+void  InputData::numberSetting(vector<double>& from, vector<double>& values)
+{
+	std::copy(from.begin(), from.end(), back_inserter(values));
+}
+
+
+void  InputData::prepare()
+{
+    if ( !x_values_.empty() ) return;
+
+    if ( magCompare(x_type_, "date" ) ) {
+    	dateSetting(date_x_, x_values_, baseDateX_);
+    	dateSetting(date_x2_, x2_values_, baseDateX_);
+    }
+    else {
+    	numberSetting(x_,  x_values_);
+    	numberSetting(x2_,  x2_values_);
+    	numberSetting(longitudes_,  x_values_);
+    }
+    if ( magCompare(y_type_, "date" ) ) {
+      	dateSetting(date_y_, y_values_, baseDateY_);
+      	dateSetting(date_y2_, y2_values_, baseDateY_);
+     }
+     else {
+      	numberSetting(y_,  y_values_);
+      	numberSetting(y2_,  y2_values_);
+      	numberSetting(latitudes_,  y_values_);
+     }
+    
+    vector<double>::iterator x = x_values_.begin();
+	vector<double>::iterator y = y_values_.begin();
+	vector<double>::iterator v = values_.begin();
+	vector<double>::reverse_iterator x2 = x2_values_.rbegin();
+	vector<double>::reverse_iterator y2 = y2_values_.rbegin();
+
+    while ( x != x_values_.end() && y != y_values_.end() ) {
+    	double val = 0;
+    	if ( v != values_.end() ) {
+    		val = *v;
+    		++v;
+    	}
+    	push_back(new UserPoint(*x, *y, val));
+    	++x;
+    	++y;
+
+    }
+    while ( x2 != x2_values_.rend() && y2 != y2_values_.rend() ) {
+        	double val = 0;
+        	if ( v != values_.end() ) {
+        		val = *v;
+        		++v;
+        	}
+        	push_back(new UserPoint(*x2, *y2, val));
+        	++x2;
+        	++y2;
+        }
+}
+ 
+void InputData::customisedPoints(const Transformation& transformation, const std::set<string>& needs, CustomisedPointsList& out, bool)
+{
+	customisedPoints(transformation, needs, out);
+}
+void InputData::customisedPoints(const Transformation& transformation, const std::set<string>& needs, CustomisedPointsList& out)
+{
+	prepare();
+	vector<double>::const_iterator x = x_values_.begin();
+	vector<double>::const_iterator y = y_values_.begin();
+	vector<double>::const_iterator xc = x_component_.begin();
+	vector<double>::const_iterator yc = y_component_.begin();
+	vector<double>::const_iterator v = values_.begin();
+	while (  x != x_values_.end() && y != y_values_.end()  ) {
+		double valx = *x;
+		double valy = *y;
+		if ( magCompare(x_type_, "date" ) ) {
+			DateTime ref(transformation.getReferenceX());
+			double shift = ref - baseDateX_;
+			valx -= shift;
+		}
+		if ( magCompare(y_type_, "date" ) ) {
+			DateTime ref(transformation.getReferenceY());
+			double shift = ref - baseDateY_;
+			valy -= shift;
+		}
+
+		CustomisedPoint* point = new CustomisedPoint();
+
+
+		point->longitude(*x);
+		point->latitude(*y);
+		out.push_back(point);
+
+
+
+		if ( same(*x, x_missing_) )
+			point->missing(true);
+		(*point)["x"] = valx;
+		x++;
+
+		if ( same(*y, y_missing_) )
+			point->missing(true);
+		(*point)["y"] = valy;
+		y++;
+
+		double speed = 0;
+		double angle = 0;
+		if ( xc != x_component_.end() && yc != y_component_.end() ) {
+			speed = sqrt( (*xc * *xc)  +  (*yc * *yc) );
+			angle = ( atan2(*xc, *yc)*(180/M_PI) );
+			if ( angle == 0 ) angle =0.1;
+			(*point)["x_component"] = *(xc++);
+			(*point)["y_component"] = *(yc++);
+			(*point)["intensity"] = speed;
+			(*point)["direction"] = angle;
+		}
+		if ( v != values_.end() ) {
+			(*point)["colour_component"] = *(v++);
+		}
+		else
+			(*point)["colour_component"] = speed;
+	}
+	if ( needs.find("area")  == needs.end() )
+		return;
+	vector<double>::reverse_iterator x2 = x2_values_.rbegin();
+	vector<double>::reverse_iterator y2 = y2_values_.rbegin();
+	while (  x2 != x2_values_.rend() && y2 != y2_values_.rend()  ) {
+		CustomisedPoint* point = new CustomisedPoint();
+		if ( same(*x2, x_missing_) )
+			point->missing(true);
+		(*point)["x"] = *(x2++);
+
+		if ( same(*y2, y_missing_) )
+			point->missing(true);
+		(*point)["y"] = *(y2++);
+		out.push_back(point);
+	}
+}
+
+void InputData::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	prepare();
+	vector<double>::const_iterator x = x_values_.begin();
+	vector<double>::const_iterator y = y_values_.begin();
+	vector<double>::const_iterator xc = x_component_.begin();
+	vector<double>::const_iterator yc = y_component_.begin();
+	vector<double>::const_iterator v = values_.begin();
+	while (  x != x_values_.end() || y != y_values_.end()  ) {
+		    	CustomisedPoint* point = new CustomisedPoint();
+
+
+		    		point->longitude(*x);
+		    		point->latitude(*y);
+		    		out.push_back(point);
+
+		    	if ( x != x_.end() ) (*point)["x"] = *(x++);
+		    	if ( y != y_.end() ) (*point)["y"] = *(y++);
+		        double speed = 0;
+		    	if ( xc != x_component_.end() && yc != y_component_.end() ) {
+		    		speed = sqrt( (*xc * *xc)  +  (*yc * *yc) );
+		    		(*point)["x_component"] = *(xc++);
+		    		(*point)["y_component"] = *(yc++);
+		    	}
+		    	if ( v != values_.end() ) {
+		    		(*point)["colour_component"] = *(v++);
+		    	}
+		    	else
+		    		(*point)["colour_component"] = speed;
+
+
+
+		    }
+}
+
+MatrixHandler& InputData::matrix()
+{
+	if  ( !matrix_ ) {
+		prepare();
+		matrix_ = (*binning_)(*this);
+	}
+
+	matrixHandlers_.push_back(new MatrixHandler(*matrix_));
+	return *(matrixHandlers_.back());
+}
+
+
+void InputData::getReady(const Transformation& transformation)
+{
+	try {
+		for ( vector<string>::const_iterator x = date_x_.begin(); x != date_x_.end(); ++x )
+			x_.push_back(transformation.x(*x));
+		}
+	catch (...) {}
+	try {
+		for ( vector<string>::const_iterator y = date_y_.begin(); y != date_y_.end(); ++y )
+			y_.push_back(transformation.y(*y));
+	}
+	catch (...) {}
+	
+}
+
+void InputData::visit(Transformation& transformation)
+{
+	// get the data ...
+	try {
+		prepare();
+		if ( transformation.getAutomaticX() ) {
+			double min = INT_MAX;
+			double max = -INT_MAX;
+			for (vector<double>::iterator x = x_values_.begin(); x != x_values_.end(); ++x) {
+				if ( same(*x, x_missing_) ) continue;
+				if ( min > *x ) min = *x;
+				if ( max < *x ) max = *x;
+			}
+			for (vector<double>::iterator x = x2_values_.begin(); x != x2_values_.end(); ++x) {
+				if ( same(*x, x_missing_) ) continue;
+				if ( min > *x ) min = *x;
+				if ( max < *x ) max = *x;
+			}
+			if ( magCompare(x_type_, "date" ) ) {
+
+				transformation.setDataMinX(min, baseDateX_);
+				transformation.setDataMaxX(max, baseDateX_);
+			}
+			else {
+				transformation.setMinX(min);
+				transformation.setMaxX(max);
+			}
+		}
+		if ( transformation.getAutomaticY() ) {
+			double min = INT_MAX;
+			double max = -INT_MAX;
+			for (vector<double>::iterator y = y_values_.begin(); y != y_values_.end(); ++y) {
+				if ( same(*y, y_missing_) ) continue;
+				if ( min > *y ) min = *y;
+				if ( max < *y ) max = *y;
+			}
+			for (vector<double>::iterator y = y2_values_.begin(); y != y2_values_.end(); ++y) {
+				if ( same(*y, y_missing_) ) continue;
+				if ( min > *y ) min = *y;
+				if ( max < *y ) max = *y;
+			}
+			if ( magCompare(y_type_, "date" ) ) {
+				transformation.setDataMinY(min, baseDateY_);
+				transformation.setDataMaxY(max, baseDateY_);
+			}
+			else {
+				transformation.setMinY(min);
+				transformation.setMaxY(max);
+			}
+		}
+
+	}
+	catch ( ... ) {}
+}
+
+
+PointsHandler& InputData::points(const Transformation& transformation, bool all)  {
+	 prepare();
+
+	 if ( magCompare(x_type_, "date" ) || magCompare(y_type_, "date" )) {
+// create a new points list!
+		PointsList*  points = new PointsList();
+		for (PointsList::iterator pt = begin(); pt != end(); ++pt) {
+			UserPoint* point = *pt;
+			if ( magCompare(x_type_, "date" ) ) {
+				DateTime ref(transformation.getReferenceX());
+				double shift = ref - baseDateX_;
+				point->x_ -= shift;
+			}
+			if ( magCompare(y_type_, "date" ) ) {
+				DateTime ref(transformation.getReferenceY());
+				double shift = ref - baseDateY_;
+				point->y_ -= shift;
+			}
+			if ( !transformation.in(*point) ) {
+				point->flagMissing();
+				if ( all )
+					points->push_back(point);
+				else
+					delete point;
+			}
+			else {
+				points->push_back(point);
+			}
+		}
+		PointsHandler* handler;
+		if (all)
+			handler = new PointsHandler(*points);
+		else
+			handler = new BoxPointsHandler(*points, transformation, false);
+		pointsHandlers_.push_back(handler);
+	}
+	else {
+		if ( all)
+			pointsHandlers_.push_back(new PointsHandler(*this));
+		else
+			pointsHandlers_.push_back(new BoxPointsHandler(*this, transformation, false));
+	}
+
+	return *(pointsHandlers_.back());
+  }
+
+
+void InputData::visit(ValuesCollector& points)
+{
+	const Transformation& transformation = points.transformation();
+	
+	points.setCollected(true);
+  	 
+	if(points.size() <=0 || size() == 0)
+	  	return;
+	
+	if(values_.empty())
+		points.setHasValue(false);
+		
+	for (ValuesCollector::iterator point =  points.begin(); point != points.end(); ++point)
+	{
+	  	double y=(*point).y(); //lat
+	  	double x=(*point).x(); //lon
+		
+		vector<int> idxV;		
+		for(int i=0; i < size(); i++)
+		{
+			if(fabs(at(i)->y()-y) < points.searchRadiusY() &&
+			   fabs(at(i)->x()-x) <  points.searchRadiusX())
+			{
+			  	idxV.push_back(i);
+			}
+		}
+		
+		if(idxV.size() ==0)
+			continue;  
+		
+		double dist=10000000.;
+		int minIdx=-1;
+		
+		//MagLog::debug() << "odb collect idxV : " << lat << " " << lon << " " << idxV.size() << endl;
+ 		
+		for(int i=0; i < idxV.size(); i++)
+		{  			
+		  	int idx=idxV[i];
+			double d;
+			if(transformation.coordinateType() == Transformation::GeoType )
+			{  
+				d=magics::geoDistanceInKm(at(idx)->y(),at(idx)->x(),y,x);
+			}
+			else
+			{
+			  	d=(at(idx)->x()-x)*(at(idx)->x()-x) +
+			        	 (at(idx)->y()-y)*(at(idx)->y()-y);
+			}
+			  					
+			if(d < dist)
+			{
+			  	minIdx=idx;
+				dist=d;
+			}			
+		}	
+		if(minIdx>=0)  
+			(*point).push_back(new ValuesCollectorData(at(minIdx)->x(),
+							       at(minIdx)->y(),
+							       at(minIdx)->value(),
+							       dist));					     			
+	}	  
+}
+
+
+
diff --git a/src/decoders/InputData.h b/src/decoders/InputData.h
new file mode 100644
index 0000000..51daecc
--- /dev/null
+++ b/src/decoders/InputData.h
@@ -0,0 +1,100 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file InputData.h
+    \brief Definition of the Template class InputData.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 6-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef InputData_H
+#define InputData_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "Data.h"
+#include "InputDataAttributes.h"
+#include "UserPoint.h"
+#include "Matrix.h"
+
+namespace magics {
+
+
+class InputData: public Data,
+              public InputDataAttributes, 
+              public PointsList
+{
+public:
+	
+	InputData(): matrix_(0){}
+	virtual ~InputData() {}
+    
+    void prepare();
+   
+    void set(const map<string, string>& map ) { InputDataAttributes::set(map); }
+	void set(const XmlNode& node ) { InputDataAttributes::set(node); }
+	void visit(Transformation& transformation);
+
+
+    
+    MatrixHandler& matrix();
+    virtual PointsHandler& points(const Transformation&, bool);
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, bool);
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+   void getReady(const Transformation&);
+   void visit(ValuesCollector&);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void  dateSetting(vector<string>&, vector<double>& , DateTime&);
+	 void  numberSetting(vector<double>& , vector<double>&);
+	
+     vector<double> x_values_;
+     vector<double> y_values_;
+     vector<double> x2_values_;
+     vector<double> y2_values_;
+
+     DateTime baseDateX_;
+     DateTime baseDateY_;
+
+     Matrix *matrix_;
+
+private:
+    //! Copy constructor - No copy allowed
+	InputData(const InputData&);
+    //! Overloaded << operator to copy - No copy allowed
+	InputData& operator=(const InputData&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const InputData& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/InputMatrix.cc b/src/decoders/InputMatrix.cc
new file mode 100644
index 0000000..197d3ce
--- /dev/null
+++ b/src/decoders/InputMatrix.cc
@@ -0,0 +1,246 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file InputMatrix.h
+    \brief Implementation of the Template class InputMatrix.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 16-Sep-2005
+    
+    Changes:
+    
+*/
+
+#include "InputMatrix.h"
+#include "Transformation.h"
+#include "Timer.h"
+
+using namespace magics;
+
+InputMatrix::InputMatrix():  matrix_(0), u_(0), v_(0), speed_(0), direction_(0)
+{
+	Timer timer("InputMatrix", "Loading data");
+	filter(field_);
+	filter(u_component_);
+	filter(v_component_);
+	filter(wind_speed_);
+	filter(wind_direction_);
+	
+}
+
+
+InputMatrix::~InputMatrix()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void InputMatrix::print(ostream& out)  const
+{
+	out << "InputMatrix[";
+	out << field_;
+	out << "]";
+}
+
+MatrixHandler& InputMatrix::matrix()
+{
+	Timer timer("InputMatrix", "Getting data");
+	if (simple_field_) 
+		matrix_ = (*organization_).geoInterpret(&field_, *this);
+	this->matrixHandlers_.push_back(new MatrixHandler(*matrix_));
+	return *(this->matrixHandlers_.back()); 
+}
+
+
+void InputMatrix::filter(Matrix& data)
+{
+	for ( unsigned int i = 0; i < data.size(); i++ )
+		if ( data[i] <= suppress_below_ || data[i] >= suppress_above_ ) 
+			data[i] = data.missing();
+}
+
+
+void InputMatrix::getReady(const Transformation& transformation)
+{
+	(*organization_).getReady(transformation);
+
+	if(transformation.coordinateType() == Transformation::GeoType ) {
+		if ( !field_.empty())
+			matrix_ = (*organization_).geoInterpret(&field_, *this);
+		if ( !u_component_.empty())
+			u_ = (*organization_).geoInterpret(&u_component_, *this);
+		if ( !v_component_.empty())
+			v_ = (*organization_).geoInterpret(&v_component_, *this);
+		if ( !wind_speed_.empty())
+			speed_ = (*organization_).geoInterpret(&wind_speed_, *this);
+		if ( !wind_direction_.empty())
+			direction_ = (*organization_).geoInterpret(&wind_direction_, *this);
+	}
+
+	else {
+		if ( !field_.empty())
+			matrix_ = (*organization_).xyInterpret(&field_, *this);
+		if ( !u_component_.empty())
+			u_ = (*organization_).xyInterpret(&u_component_, *this);
+		if ( !v_component_.empty())
+			v_ = (*organization_).xyInterpret(&v_component_, *this);
+		if ( !wind_speed_.empty())
+			speed_ = (*organization_).xyInterpret(&wind_speed_, *this);
+		if ( !wind_direction_.empty())
+			direction_ = (*organization_).xyInterpret(&wind_direction_, *this);
+	}
+}
+
+
+
+void  InputMatrix::release()
+{
+	 if ( matrix_ )
+		 matrix_->release();
+
+	 if ( u_ )
+		 u_->release();
+
+	 if ( v_ )
+		 v_->release();
+
+	 if ( speed_ )
+	 	speed_->release();
+
+	 if ( direction_ )
+		direction_->release();
+}
+
+pair<double, double> InputMatrix::sd2uv(double s, double d)
+{
+	double a = 90 - (d);
+	double pi = 3.14/180.;
+	a *= pi;
+    return make_pair(s * -1 * cos(a), s*-1* sin(a));
+}
+
+
+MatrixHandler& InputMatrix::xComponent()
+{
+	if ( !u_ )
+		prepareComponents();
+
+	this->matrixHandlers_.push_back(new MatrixHandler(*u_));
+	return *(this->matrixHandlers_.back());
+}
+
+
+void InputMatrix::prepareComponents()
+{
+		Matrix u, v;
+		// We calculate the u_component_ using the speed and direction...
+		vector<double>::const_iterator speed = speed_->begin();
+		vector<double>::const_iterator angle = direction_->begin();
+
+		while ( speed != speed_->end() && angle != direction_->end() )
+		{
+			if ( *speed == speed_->missing() || *angle == direction_->missing() ) {
+					 u.push_back(direction_->missing());
+					 v.push_back(direction_->missing());
+			}
+			else if ( *speed == 0 && *angle == 0   ) {
+					u.push_back(direction_->missing());
+					v.push_back(direction_->missing());
+			}
+			else {
+				pair<double, double> uv = sd2uv(*speed, *angle);
+				u.push_back(uv.first);
+				v.push_back(uv.second);
+			}
+			speed++;
+			angle++;
+		}
+		u_ = speed_;
+		v_ = direction_;
+		u_->clear();
+		v_->clear();
+		std::copy(u.begin(), u.end(), back_inserter(*u_));
+		std::copy(v.begin(), v.end(), back_inserter(*v_));
+}
+
+
+MatrixHandler& InputMatrix::yComponent()
+{
+	if ( !v_ )
+		prepareComponents();
+	Data::matrixHandlers_.push_back(new MatrixHandler(*v_));
+	return *(this->matrixHandlers_.back()); 
+}
+
+PointsHandler& InputMatrix::points(const Transformation& transformation)
+{
+		this->pointsHandlers_.push_back(new BoxPointsHandler(this->matrix(), transformation, true));
+		return *(this->pointsHandlers_.back());
+}
+
+
+void InputMatrix::customisedPoints(const BasicThinningMethod& thinning, const Transformation& transformation, const std::set<string>&, CustomisedPointsList& points)
+{
+	vector<UserPoint> thinx;
+	vector<UserPoint> thiny;
+
+	int factor = thinning.factor();
+	MatrixHandler* inx = transformation.prepareData(xComponent());
+	MatrixHandler* iny = transformation.prepareData(yComponent());
+	transformation.thin(*inx, factor, factor, thinx);
+	transformation.thin(*iny, factor, factor, thiny);
+
+	vector<UserPoint>::const_iterator x = thinx.begin();
+	vector<UserPoint>::const_iterator y = thiny.begin();
+
+	if (thinx.empty()) return;
+	while (x->value() == inx->missing() || y->value() == iny->missing())
+	{
+		++x;
+		++y;
+		if (x == thinx.end() || y == thiny.end()) 
+			return;
+	}
+	CustomisedPoint *point = new CustomisedPoint(x->x(), x->y(), "");
+	point->insert(make_pair("x_component", x->value()));
+	point->insert(make_pair("y_component", y->value()));
+	points.push_back(point);
+
+//	double lastx = x->x();
+//	double lasty = x->x();
+	x++;
+	y++;
+	while ( x != thinx.end() && y != thiny.end() )
+	{
+		if ( x->value() != inx->missing() &&  y->value() != iny->missing() )
+		{
+			CustomisedPoint *point = new CustomisedPoint(x->x(), x->y(), "");
+			point->insert(make_pair("x_component", x->value()));
+			point->insert(make_pair("y_component", y->value()));
+			points.push_back(point);
+
+		}
+//		lastx = x->x();
+		x++;
+		y++;
+	} 
+	delete inx;
+	delete iny;
+}
diff --git a/src/decoders/InputMatrix.h b/src/decoders/InputMatrix.h
new file mode 100644
index 0000000..dbdf122
--- /dev/null
+++ b/src/decoders/InputMatrix.h
@@ -0,0 +1,103 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file InputMatrix.h
+    \brief Definition of the Template class InputMatrix.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 16-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef InputMatrix_H
+#define InputMatrix_H
+
+#include "magics.h"
+
+#include "InputMatrixAttributes.h"
+#include "Data.h"
+
+namespace magics {
+
+
+class InputMatrix: public Data, public InputMatrixAttributes {
+
+public:
+	InputMatrix();
+	virtual ~InputMatrix();
+	
+	virtual void set(const map<string, string>& map) { InputMatrixAttributes::set(map); }
+	virtual void set(const XmlNode& node) { InputMatrixAttributes::set(node); }
+
+    void getReady(const Transformation& transformation);
+
+	virtual MatrixHandler& matrix();
+	virtual MatrixHandler& xComponent();
+	virtual MatrixHandler& yComponent();
+	void prepareComponents();
+	pair<double, double> sd2uv(double s, double d);
+	virtual PointsHandler& points(const Transformation&);
+	
+	void customisedPoints(const BasicThinningMethod&, const Transformation&, const std::set<string>&, CustomisedPointsList& );
+	void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	{}
+	PointsHandler& points(const Transformation& t, bool) { return points(t); }
+	
+	bool defined()
+	{
+	   return !field_.empty() || 
+	           (
+	             (!u_component_.empty() && !u_component_.empty() )    ||
+	             (!wind_speed_.empty()  && !wind_direction_.empty() ) || 
+	             simple_field_
+	           );
+	}
+	void filter(Matrix&);
+	void release();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     Matrix* matrix_;
+     Matrix* u_;
+     Matrix* v_;
+     Matrix* speed_;
+     Matrix* direction_;
+     
+     friend class InputMatrixRegularInterpretor;
+
+private:
+    //! Copy constructor - No copy allowed
+	InputMatrix(const InputMatrix&);
+    //! Overloaded << operator to copy - No copy allowed
+	InputMatrix& operator=(const InputMatrix&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const InputMatrix& p)
+		{ p.print(s); return s; }
+
+};
+} // namespace magics
+
+
+
+#endif
diff --git a/src/decoders/InputMatrixInterpretor.cc b/src/decoders/InputMatrixInterpretor.cc
new file mode 100644
index 0000000..7640228
--- /dev/null
+++ b/src/decoders/InputMatrixInterpretor.cc
@@ -0,0 +1,279 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file InputMatrixInterpretor.h
+    \brief Implementation of the Template class InputMatrixInterpretor.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 16-Sep-2005
+    
+    Changes:
+    
+*/
+
+#include "InputMatrixInterpretor.h"
+#include "InputMatrix.h"
+#include <limits>
+
+using namespace magics;
+
+InputMatrixInterpretor::InputMatrixInterpretor() 
+{
+	mappers_["upper_left"] = &InputMatrixInterpretor::upperLeft;
+	mappers_["lower_left"] = &InputMatrixInterpretor::lowerLeft;
+	mappers_["upper_right"] = &InputMatrixInterpretor::upperRight;
+	mappers_["lower_right"] = &InputMatrixInterpretor::lowerRight;     
+	mappers_["upper_left_transposed"] = &InputMatrixInterpretor::upperLeftTransposed;
+	mappers_["lower_left_transposed"] = &InputMatrixInterpretor::lowerLeftTransposed;
+	mappers_["upper_right_transposed"] = &InputMatrixInterpretor::upperRightTransposed;
+	mappers_["lower_right_transposed"] = &InputMatrixInterpretor::lowerRightTransposed;
+}
+
+InputMatrixInterpretor::~InputMatrixInterpretor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void InputMatrixInterpretor::print(ostream& out)  const
+{
+	out << "InputMatrixInterpretor[";
+	out << "]";
+}
+
+
+InputMatrixRegularInterpretor::InputMatrixRegularInterpretor() 
+{    
+}
+
+InputMatrixRegularInterpretor::~InputMatrixRegularInterpretor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void InputMatrixRegularInterpretor::print(ostream& out)  const
+{
+	out << "InputMatrixRegularInterpretor[";
+	out << "]";
+}
+
+Matrix* InputMatrixRegularInterpretor::geoInterpret(Matrix* in, const InputMatrix& info)
+{
+	std::map<string, Mapper>::iterator mapper = mappers_.find(lowerCase(info.mapping_));
+
+	if ( mapper == mappers_.end() )
+		MagLog::warning() << "unknow input matrix mapping " << info.mapping_ << endl;
+	else 
+		(this->*mapper->second)();
+
+	if ( in->columnsAxis().empty() == false )
+		// The initialisation has already been done return;
+		return in;
+
+	int nblon =  in->columns();
+	double lon = longitude_;
+	
+	for (int i = 0; i < nblon; i++) {		
+		in->columnsAxis().push_back(lon);
+		lon += longitude_step_;		
+	}
+
+	int nblat =  in->rows();
+	double lat = latitude_;
+	
+	for (int i = 0; i < nblat; i++) {		
+		in->rowsAxis().push_back(lat);
+		lat += latitude_step_;
+	}
+	in->setMapsAxis();
+	in->missing(std::numeric_limits<double>::max());
+	MagLog::dev()<< in << endl;
+    return in;
+	}
+
+Matrix* InputMatrixRegularInterpretor::xyInterpret(Matrix* in, const InputMatrix& info)
+{
+	in->missing(std::numeric_limits<double>::max());
+	if ( !in->rowsAxis().empty() )
+		// WE have already initialised the matrix ..
+		return in;
+	if ( x_coords_.size() == in->columns() && y_coords_.size() == in->rows()) {
+		in->setRowsAxis(y_coords_);
+		in->setColumnsAxis(x_coords_);
+
+		return in;
+		// the user has defined the vector of coordinates
+		// We use them
+	}
+	// if y a date or an normal axis..
+
+	if ( !y_first_date_.empty() ) {
+		y_first_ = 0;
+		DateTime from(y_first_date_);
+		DateTime to(y_last_date_);
+		y_last_ = to-from;
+	}
+	if ( !x_first_date_.empty() ) {
+			x_first_ = 0;
+			DateTime from(x_first_date_);
+			DateTime to(x_last_date_);
+			x_last_ = to-from;
+	}
+	double y = y_first_;
+	double step = (y_last_ - y_first_)/(in->rows()-1);
+	for (int i = 0; i < in->rows(); i++) {
+			
+			in->rowsAxis().push_back(y);
+			y += step;
+	}
+
+	double x = x_first_;
+	step = (x_last_ - x_first_)/(in->columns()-1);
+	for (int i = 0; i < in->columns(); i++) {
+			
+			in->columnsAxis().push_back(x);
+			x += step;
+	}
+	in->missing(std::numeric_limits<double>::max());
+	in->setMapsAxis();
+    return in;
+}
+
+
+InputMatrixIrregularInterpretor::InputMatrixIrregularInterpretor() 
+{    
+}
+
+InputMatrixIrregularInterpretor::~InputMatrixIrregularInterpretor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void InputMatrixIrregularInterpretor::print(ostream& out)  const
+{
+	out << "InputMatrixIrregularInterpretor[";
+	out << "]";
+}
+
+Matrix* InputMatrixIrregularInterpretor::geoInterpret(Matrix* in, const InputMatrix& info)
+{
+
+    ProjectedMatrix* matrix = new ProjectedMatrix(in->rows(), in->columns());
+    vector<double>& values = matrix->values();
+    vector<double>& rows = matrix->rowsArray();
+    vector<double>& columns = matrix->columnsArray();
+ 
+	for (vector<double>::iterator val = in->begin(); val != in->end(); ++val) {
+            values.push_back(*val);  
+	}
+           
+            
+	for (vector<double>::iterator y = latitudes_.begin(); y != latitudes_.end(); ++y) {
+			//MagLog::dev() << *y << endl;
+			rows.push_back(*y);
+	}
+
+	for (vector<double>::iterator x = longitudes_.begin(); x != longitudes_.end(); ++x) {
+			//MagLog::dev() << *x << endl;
+			columns.push_back(*x);					
+	}
+    
+	matrix->missing(std::numeric_limits<double>::max());
+	matrix->getReady();
+    return matrix;
+}
+
+Matrix* InputMatrixIrregularInterpretor::xyInterpret(Matrix* in, const InputMatrix& info)
+{
+	
+    // here we have to create a projected matrix! 
+    
+    ProjectedMatrix* matrix = new ProjectedMatrix(in->rows(), in->columns());
+   
+
+	vector<double>& values = matrix->values();
+	vector<double>& rows = matrix->rowsArray();
+	vector<double>& columns = matrix->columnsArray();
+	
+    for (int row = 0; row < in->rows(); row++)
+          for (int column = 0; column < in->columns(); column++)
+            values.push_back((*in)(row, column));
+
+	for (vector<double>::iterator y = y_.begin(); y != y_.end(); ++y) {
+		//MagLog::dev() << *y << endl;
+		rows.push_back(*y);
+	}
+
+	for (vector<double>::iterator x = x_.begin(); x != x_.end(); ++x) {
+			//MagLog::dev() << *x << endl;
+			columns.push_back(*x);					
+	}
+	matrix->missing(std::numeric_limits<double>::max());
+	matrix->getReady();
+    
+    return matrix;
+}
+
+
+void InputMatrixInterpretor::upperLeft()
+{
+}
+
+void InputMatrixInterpretor::lowerLeft()
+{
+}
+
+void InputMatrixInterpretor::upperRight()
+{
+}
+
+void InputMatrixInterpretor::lowerRight()   
+{
+}
+
+  
+void InputMatrixInterpretor::upperLeftTransposed()
+{
+}
+
+void InputMatrixInterpretor::lowerLeftTransposed()
+{
+}
+
+void InputMatrixInterpretor::upperRightTransposed()
+{
+}
+
+void InputMatrixInterpretor::lowerRightTransposed()
+{
+}
+
+void InputMatrixRegularInterpretor::getReady(const Transformation& transformation)
+{
+    if ( transformation.xAxisType() != "date" )
+        x_first_date_.clear();
+    if ( transformation.yAxisType() != "date" )
+        y_first_date_.clear();
+}
+
diff --git a/src/decoders/InputMatrixInterpretor.h b/src/decoders/InputMatrixInterpretor.h
new file mode 100644
index 0000000..b1b3210
--- /dev/null
+++ b/src/decoders/InputMatrixInterpretor.h
@@ -0,0 +1,175 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file InputMatrixInterpretor.h
+    \brief Definition of the Template class InputMatrixInterpretor.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 16-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef InputMatrixInterpretor_H
+#define InputMatrixInterpretor_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "InputMatrixRegularInterpretorAttributes.h"
+#include "InputMatrixIrregularInterpretorAttributes.h"
+
+
+namespace magics {
+
+class XmlNode;
+class UserPoint;
+class UserPoint;
+class Transformation;
+
+
+class InputMatrix;
+
+class InputMatrixInterpretor {
+
+public:
+	InputMatrixInterpretor();
+	virtual ~InputMatrixInterpretor();
+	
+	virtual InputMatrixInterpretor* clone() { return new InputMatrixInterpretor(); }
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual void toxml(ostream&)  const {}
+	virtual bool accept(const string&) { return false; }
+	virtual Matrix* xyInterpret(Matrix*, const InputMatrix&) { return 0; }
+	virtual Matrix* geoInterpret(Matrix*, const InputMatrix&) { return 0; }
+	virtual void getReady(const Transformation&) { }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	typedef void (InputMatrixInterpretor::*Mapper)(); 
+	std::map<string, Mapper> mappers_;
+	void upperLeft();
+	void lowerLeft();
+	void upperRight();
+	void lowerRight();     
+	void upperLeftTransposed();
+	void lowerLeftTransposed();
+	void upperRightTransposed();
+	void lowerRightTransposed();
+
+private:
+	//! Copy constructor - No copy allowed
+	InputMatrixInterpretor(const InputMatrixInterpretor&);
+	//! Overloaded << operator to copy - No copy allowed
+	InputMatrixInterpretor& operator=(const InputMatrixInterpretor&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const InputMatrixInterpretor& p)
+		{ p.print(s); return s; }
+};
+
+
+class InputMatrixRegularInterpretor: public InputMatrixRegularInterpretorAttributes, public InputMatrixInterpretor
+{
+public:
+	InputMatrixRegularInterpretor();
+	virtual ~InputMatrixRegularInterpretor();
+
+	virtual void set(const map<string, string>& map) { InputMatrixRegularInterpretorAttributes::set(map); }
+	virtual void set(const XmlNode& node) { InputMatrixRegularInterpretorAttributes::set(node); }
+    
+	virtual Matrix* xyInterpret(Matrix*, const InputMatrix&);
+	virtual Matrix* geoInterpret(Matrix*, const InputMatrix&);
+    virtual void getReady(const Transformation&);
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	InputMatrixRegularInterpretor(const InputMatrixRegularInterpretor&);
+	//! Overloaded << operator to copy - No copy allowed
+	InputMatrixRegularInterpretor& operator=(const InputMatrixRegularInterpretor&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const InputMatrixRegularInterpretor& p)
+		{ p.print(s); return s; }
+};
+
+class InputMatrixGaussianInterpretor : public InputMatrixRegularInterpretor
+{
+public:
+	InputMatrixGaussianInterpretor() {}
+	virtual ~InputMatrixGaussianInterpretor() {}
+
+};
+
+class InputMatrixIrregularInterpretor: public InputMatrixIrregularInterpretorAttributes, public InputMatrixInterpretor {
+
+public:
+	InputMatrixIrregularInterpretor();
+	virtual ~InputMatrixIrregularInterpretor();
+	
+	virtual void set(const map<string, string>& map) { InputMatrixIrregularInterpretorAttributes::set(map); }
+	virtual void set(const XmlNode& node) { InputMatrixIrregularInterpretorAttributes::set(node); }
+    
+	virtual Matrix* geoInterpret(Matrix*, const InputMatrix&);
+	virtual Matrix* xyInterpret(Matrix*, const InputMatrix&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const;
+
+private:
+	//! Copy constructor - No copy allowed
+	InputMatrixIrregularInterpretor(const InputMatrixIrregularInterpretor&);
+	//! Overloaded << operator to copy - No copy allowed
+	InputMatrixIrregularInterpretor& operator=(const InputMatrixIrregularInterpretor&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const InputMatrixIrregularInterpretor& p)
+		{ p.print(s); return s; }
+};
+
+
+template<>
+class MagTranslator<string, InputMatrixInterpretor> { 
+public:
+	InputMatrixInterpretor* operator()(const string& val )
+	{
+		return SimpleObjectMaker<InputMatrixInterpretor>::create(val);
+	}     
+
+	InputMatrixInterpretor* magics(const string& param)
+	{
+		InputMatrixInterpretor* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/LandgramDecoder.cc b/src/decoders/LandgramDecoder.cc
new file mode 100644
index 0000000..163b806
--- /dev/null
+++ b/src/decoders/LandgramDecoder.cc
@@ -0,0 +1,190 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LandgramDecoder.h
+    \brief Implementation of the Template class LandgramDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 25-Mar-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "LandgramDecoder.h"
+#include "Factory.h"
+#include <limits>
+#include <TextVisitor.h>
+using namespace magics;
+
+LandgramDecoder::LandgramDecoder(): first_(0) 
+{
+	/*
+	ifstream f("/home/graphics/cgs/public/map.txt");
+	assert(f);
+	int rows, columns;
+	double lon, lat, inclon, inclat;
+	f >> rows >> columns;
+	f >> lat >> lon >> inclat >> inclon;
+	matrix_.set(rows, columns);
+	double missing = -std::numeric_limits<magfloat>::max();
+     
+	matrix_.missing(missing);
+	
+	char c;
+    while (! f.eof() )
+    {
+      f.get(c);      
+   
+      if (isdigit(c) )   
+      	matrix_.push_back(atoi(&c));
+      if (c == '.') 
+      	matrix_.push_back(missing);
+         
+    }
+    f.close();
+    
+    
+  
+	
+	
+    for (int i = 0; i < columns; i++) {
+           matrix_.columnsAxis().push_back(lon);
+           lon+=inclon;
+    }
+    
+    for (int i = 0; i < rows; i++) {
+    	matrix_.rowsAxis().push_back(lat);
+    	lat+=inclat;
+    }
+
+   
+    matrix_.setMapsAxis();
+
+    
+   */
+}
+
+
+void LandgramDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& points)
+{
+	decode();
+	for (unsigned int step = 0; step < steps_.size(); step++)
+	{
+		CustomisedPoint* point = new CustomisedPoint(0,0,"box");
+		point->longitude(steps_[step]);		
+		point->insert(make_pair("step", steps_[step]));	
+		for (unsigned int height = 0; height < heights_.size(); height++)
+		{
+			ostringstream key;
+			key << "box" <<  heights_[height];
+			point->insert(make_pair(key.str(), values_[(step*heights_.size()) + height]));	
+		}
+		points.push_back(point);
+	} 
+}
+
+void LandgramDecoder::decode()
+{
+	
+	if ( !steps_.empty() ) return;
+	
+	XmlReader parser(true);
+	XmlTree tree;	
+
+		try {
+				parser.interpret(path_, &tree);		
+				tree.visit(*this);
+		}
+		catch (MagicsException& e) {
+					MagLog::debug() << e.what() << endl;
+		}
+		
+		
+		matrix_.set(steps_.size(), heights_.size());
+		
+		for ( vector<double>::const_iterator height =heights_.begin(); height != heights_.end(); ++height) {
+			matrix_.rowsAxis().push_back(*height);
+		}	
+		MagLog::dev()<< " step-->" <<endl;
+		for ( vector<double>::const_iterator step = steps_.begin(); step != steps_.end(); ++step) {
+			matrix_.columnsAxis().push_back(*step);
+			MagLog::dev()<< *step << " ";
+		}
+		MagLog::dev()<< endl << "<--- step" <<endl;
+		matrix_.setMapsAxis();
+//		int i = 0;
+		for (unsigned int height = 0; height < heights_.size(); height++)
+		{
+			MagLog::dev()<< endl <<  heights_[height] << " " << steps_.size() << endl;
+			for (unsigned int step = 0; step < steps_.size(); step++)
+			{
+				matrix_.push_back(values_[(step*heights_.size()) + height]);
+				MagLog::dev()<< matrix_.back() << " ";
+			}
+		}
+	MagLog::debug() << matrix_ << endl;
+}
+
+LandgramDecoder::~LandgramDecoder() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LandgramDecoder::print(ostream& out)  const
+{
+	out << "LandgramDecoder[";
+	out << "]";
+}
+
+void LandgramDecoder::visit(const XmlNode& node)
+{
+	
+	MagLog::dev() << node.name() << endl;
+	if ( node.name() == "forecast" ) {
+			node.visit(*this);
+	}
+	else if ( node.name() == "step" ) {
+		    first_ ++;
+			MagLog::dev()<< "step --> " << tonumber(node.getAttribute("value")) << endl;
+			steps_.push_back(tonumber(node.getAttribute("value")));
+			node.visit(*this);
+			MagLog::dev()<< "step --> " <<  steps_.size();
+		}
+	else {		
+			double height =  tonumber(node.getAttribute("height")) ;
+			double value = tonumber(node.getAttribute("value")) ;
+			if (first_ == 1) 
+				heights_.push_back(height);
+			
+			values_.push_back((value*scaling_)+offset_);
+			MagLog::dev()<< "height --> " << tonumber(node.getAttribute("height")) <<  " = value " << tonumber(node.getAttribute("value")) << endl;
+			node.visit(*this);
+	}
+}
+
+void LandgramDecoder::visit(TextVisitor& node)
+{
+	TextEntry* text = new TextEntry(title_);
+	node.add(text);
+}
diff --git a/src/decoders/LandgramDecoder.h b/src/decoders/LandgramDecoder.h
new file mode 100644
index 0000000..6b9d60d
--- /dev/null
+++ b/src/decoders/LandgramDecoder.h
@@ -0,0 +1,95 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LandgramDecoder.h
+    \brief Definition of the Template class LandgramDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 25-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef LandgramDecoder_H
+#define LandgramDecoder_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "Data.h"
+#include "Decoder.h"
+#include "LandgramDecoderAttributes.h"
+#include "XmlReader.h"
+
+namespace magics {
+
+class LandgramDecoder: public LandgramDecoderAttributes, 
+	public Decoder, 
+	public Data,
+	public XmlNodeVisitor {
+
+public:
+	LandgramDecoder();
+	virtual ~LandgramDecoder();
+	// implements Decoder interface
+	void decode();
+
+	virtual void set(const map<string, string>& map) { LandgramDecoderAttributes::set(map); }
+	virtual void set(const XmlNode& node) { LandgramDecoderAttributes::set(node); }
+	void visit(const XmlNode& node);
+	void visit(TextVisitor& node);
+	
+    
+	PointsHandler& points() { throw MethodNotYetImplemented("LandgramDecoder::points()"); }
+	virtual MatrixHandler& matrix()
+	{
+		decode();
+		matrixHandlers_.push_back(new  MatrixHandler(matrix_));
+		return *(matrixHandlers_.back());
+	}
+	void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	 void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	    {
+	    	customisedPoints(n, out);
+	    }
+	    PointsHandler& points(const Transformation& t, bool) { return points(); }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	Matrix matrix_;
+	vector<double> values_;
+	vector<double> steps_;
+	vector<double> heights_;
+	int first_;
+private:
+	//! Copy constructor - No copy allowed
+	LandgramDecoder(const LandgramDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	LandgramDecoder& operator=(const LandgramDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LandgramDecoder& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/LocalTable.cc b/src/decoders/LocalTable.cc
new file mode 100644
index 0000000..0154f63
--- /dev/null
+++ b/src/decoders/LocalTable.cc
@@ -0,0 +1,107 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LocalTable.h
+    \brief Implementation of the Template class LocalTable.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+#include "LocalTable.h"
+#include "MagException.h"
+#include "expat.h"
+//#include "MagLog.h"
+
+using namespace magics;
+template <> 
+map<string, DefinitionTable<ParamDef>* >* DefinitionTable<ParamDef>::tables_ = 0;
+
+const DefinitionTable<ParamDef>& LocalTable::localTable(long table, long)
+{
+    ostringstream sfile;
+	sfile << "table_" << table << ".xml";
+    return definitionTable(sfile.str(), "param");
+}
+
+const ParamDef& LocalTable::localInfo(long code, long table, long centre)
+{
+    const DefinitionTable<ParamDef>& local = localTable(table, centre); 
+    return local.definition(code);    
+}
+
+LocalTable::~LocalTable() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LocalTable::print(ostream& out)  const
+{
+	out << "LocalTable[";
+	out << "]";
+}
+
+ParamDef::ParamDef(const map<string, string>& def)
+{
+    map<string, string>::const_iterator info;
+    
+    info = def.find("code");
+    if ( info == def.end() ) code_ = -1;
+    else code_ =  atoi(info->second.c_str());
+    
+    info = def.find("long_title");
+    if ( info == def.end() ) longTitle_ = "Unknown parameter";
+    else longTitle_ =  info->second;
+    
+    info = def.find("short_title");
+    if ( info == def.end() ) shortTitle_ = -1;
+    else shortTitle_ =  info->second;
+    
+    info = def.find("original_unit");
+    if ( info == def.end() ) originalUnit_ = "Unknown unit";
+    else originalUnit_ =  info->second;
+    
+    info = def.find("derived_unit");
+    if ( info == def.end() ) derivedUnit_ = "Unknown unit";
+    else derivedUnit_ =  info->second;
+    
+    info = def.find("scaling");
+    if ( info == def.end() ) scaling_ = 1;
+    else scaling_ =   atof(info->second.c_str());
+    
+    info = def.find("offset");
+    if ( info == def.end() ) offset_ = 1;
+    else offset_ =   atof(info->second.c_str());
+}
+
+void ParamDef::print(ostream& out) const
+{
+    out << "ParamDef[";
+    out << "code=" << code_;
+    out << ", long title=" <<  longTitle_;
+    out << ", short title=" <<  shortTitle_;
+    out << ", original units=" <<  originalUnit_;
+    out << ", derived units=" <<  derivedUnit_;
+    out << ", scaling factor=" <<  scaling_;
+    out << ", offset=" <<  offset_;
+    out << "]";
+}
diff --git a/src/decoders/LocalTable.h b/src/decoders/LocalTable.h
new file mode 100644
index 0000000..2d8abb7
--- /dev/null
+++ b/src/decoders/LocalTable.h
@@ -0,0 +1,108 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LocalTable.h
+    \brief Definition of the Template class LocalTable.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef LocalTable_H
+#define LocalTable_H
+
+#include "magics.h"
+
+#include "DefinitionTable.h"
+
+
+namespace magics {
+
+
+class ParamDef 
+{
+public :
+    ParamDef(const map<string, string>& def);
+    ParamDef(): code_(-1), 
+        longTitle_("unknown parameter"), 
+        shortTitle_("unknown parameter"),
+        originalUnit_("unknown units"),
+        derivedUnit_("unknown units"),
+        scaling_(1),
+        offset_(0) {}
+    virtual ~ParamDef() {}
+    int code()                  { return code_; }
+    string longTitle() const    { return longTitle_; }
+    string shortTitle() const   { return shortTitle_; }
+    string originalUnit() const { return originalUnit_; }
+    string derivedUnit() const  { return derivedUnit_; }
+    double scaling() const       { return scaling_; }
+    double offset() const        { return offset_; }
+    
+protected:
+  //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+    
+    int    code_;
+    string longTitle_;
+    string shortTitle_;
+    string originalUnit_;
+    string derivedUnit_;
+    double  scaling_;
+    double  offset_;   
+    
+    // -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ParamDef& p)
+		{ p.print(s); return s; }
+};
+
+
+class LocalTable : public DefinitionTable<ParamDef>
+{
+public:
+	LocalTable(const string&);
+	virtual ~LocalTable();
+    static const DefinitionTable<ParamDef>& localTable(long table, long center = -1);
+    static const ParamDef& localInfo(long code, long table, long center = -1);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     void setDefinition() { definition_ = "param"; }
+   
+ 
+private:
+    //! Copy constructor - No copy allowed
+	LocalTable(const LocalTable&);
+    //! Overloaded << operator to copy - No copy allowed
+	LocalTable& operator=(const LocalTable&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LocalTable& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/Makefile.am b/src/decoders/Makefile.am
new file mode 100644
index 0000000..bcc1628
--- /dev/null
+++ b/src/decoders/Makefile.am
@@ -0,0 +1,113 @@
+noinst_LTLIBRARIES	= libdecoders.la
+
+if MAGICS_NETCDF
+NETCDF_noi_H 		= Netcdf.h NetcdfDecoder.h NetcdfInterpretor.h \
+		NetcdfMatrixInterpretor.h \
+		NetcdfGeoMatrixInterpretor.h NetcdfGeopointsInterpretor.h \
+		NetcdfVectorInterpretor.h NetcdfOrcaInterpretor.h\
+		NetcdfConvention.h NetcdfMarsConvention.h \
+		NetcdfDecoderAttributes.h  NetcdfInterpretorAttributes.h NetcdfGeopointsInterpretorAttributes.h NetcdfMatrixInterpretorAttributes.h \
+		NetcdfGeoPolarMatrixInterpretorAttributes.h NetcdfGeoMatrixInterpretorAttributes.h NetcdfGeoVectorInterpretorAttributes.h NetcdfVectorInterpretorAttributes.h
+
+NETCDF_la_S 		= Netcdf.cc NetcdfDecoder.cc NetcdfInterpretor.cc \
+		NetcdfMatrixInterpretor.cc NetcdfVectorInterpretor.cc \
+		NetcdfGeoMatrixInterpretor.cc NetcdfGeopointsInterpretor.cc \
+		NetcdfOrcaInterpretor.cc \
+		NetcdfConvention.cc NetcdfMarsConvention.cc
+ATTRIBUTES_NETCDF	= 	NetcdfDecoderAttributes.cc NetcdfInterpretorAttributes.cc \
+		NetcdfGeopointsInterpretorAttributes.cc NetcdfXYpointsInterpretorAttributes.cc \
+		NetcdfGeoMatrixInterpretorAttributes.cc NetcdfOrcaInterpretorAttributes.cc NetcdfMatrixInterpretorAttributes.cc\
+		NetcdfGeoPolarMatrixInterpretorAttributes.cc \
+ 		NetcdfVectorInterpretorAttributes.cc NetcdfGeoVectorInterpretorAttributes.cc 
+endif
+
+if MAGICS_GRIB
+GRIB_noi_H =		GribDecoder.h GribDecoderAttributes.h GribLoopAttributes.h DateGribLoopStepAttributes.h GeoPointsDecoderAttributes.h \
+			GribInterpretor.h GribRegularInterpretor.h GribSatelliteInterpretor.h GribAddressMode.h
+GRIB_la_S =		GribDecoder.cc GribRegularInterpretor.cc GribSatelliteInterpretor.cc GribLoopStep.cc
+ATTRIBUTES_GRIB	= 	GribDecoderAttributes.cc DateGribLoopStepAttributes.cc GribLoopAttributes.cc	
+endif
+
+
+if MAGICS_BUFR
+BUFR_noi_H =		ObsDecoder.h EpsBufr.h
+BUFR_la_S =		ObsDecoder.cc EpsBufr.cc
+ATTRIBUTES_BUFR	= 	ObsDecoderAttributes.cc EpsBufrAttributes.cc
+endif
+
+if MAGICS_SPOT
+SPOT_noi_H =		EpsgramDecoder.h  ClassicMtgDecoder.h 
+SPOT_la_S =		EpsgramDecoder.cc ClassicMtgDecoder.cc  
+ATTRIBUTES_SPOT	= 	EpsgramDecoderAttributes.cc EfigramDecoderAttributes.cc ClassicMtgDecoderAttributes.cc 
+endif
+
+
+ATTRIBUTES =	${ATTRIBUTES_GRIB} ${ATTRIBUTES_BUFR} ${ATTRIBUTES_SPOT} ${ATTRIBUTES_NETCDF} ShapeDecoderAttributes.cc MapGenDecoderAttributes.cc  \
+		TitleTemplateAttributes.cc \
+		EpsXmlInputAttributes.cc \
+		InputDataAttributes.cc TableDecoderAttributes.cc InputMatrixAttributes.cc SymbolInputAttributes.cc \
+		InputMatrixRegularInterpretorAttributes.cc InputMatrixIrregularInterpretorAttributes.cc XYListAttributes.cc \
+		SimplePolylineInputAttributes.cc \
+		BoxPlotDecoderAttributes.cc  \
+		GeoPointsDecoderAttributes.cc ImportActionAttributes.cc LandgramDecoderAttributes.cc \
+		ObsStatDecoderAttributes.cc BinningObjectAttributes.cc 
+
+include_H =	DateTime.h ObsStatDecoder.h ObsStatDecoderAttributes.h $(GRIB_noi_H) $(SPOT_noi_H) $(NETPBM_noi_H) $(BUFR_noi_H) $(NETCDF_noi_H) \
+		EpsXmlInput.h MatrixTestDecoder.h \
+		XYList.h XYList.cc \
+		TitleTemplate.h \
+		TitleField.h TitleStringField.h TitleMetaField.h \
+		LocalTable.h \
+		ImportAction.h \
+		SymbolInput.h  \
+		InputMatrix.h InputMatrix.cc \
+		InputData.h InputData.cc \
+		TableDecoder.h TableDecoder.cc \
+		InputMatrixInterpretor.h \
+		BoxPlotDecoder.h \
+		EfiDataDecoder.h EfiLegendEntry.h \
+		LandgramDecoder.h \
+		WindMode.h \
+		MapGenDecoder.cc MapGenDecoder.h ShapeDecoder.h shapefil.h \
+		SimplePolylineInput.h GribLoopStep.h \
+		GeoPointsDecoder.h ObsDecoderAttributes.h ImportActionAttributes.h ThinningMethod.h BinningObject.h BinningObjectAttributes.h
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= $(noinst_H)
+else
+include_HEADERS = 
+noinst_HEADERS	= $(noinst_H) $(include_H)
+endif
+
+nodist_libdecoders_la_SOURCES = ${ATTRIBUTES}
+
+libdecoders_la_SOURCES	=  $(GRIB_la_S) $(SPOT_la_S) $(BUFR_la_S) $(NETCDF_la_S) \
+		DateTime.cc  \
+		LocalTable.cc Date.cc Time.cc \
+		EpsXmlInput.cc \
+		TitleTemplate.cc  \
+		TitleField.cc TitleStringField.cc TitleMetaField.cc  \
+		ShapeDecoder.cc \
+		WindMode.cc \
+		MatrixTestDecoder.cc \
+		InputMatrixInterpretor.cc  \
+		SimplePolylineInput.cc \
+		BoxPlotDecoder.cc \
+		ThinningMethod.cc \
+		GeoPointsDecoder.cc LandgramDecoder.cc \
+		ObsStatDecoder.cc \
+		shpopen.c dbfopen.c \
+		BinningObject.cc  XYList.cc MapGenDecoder.cc  InputMatrix.cc \
+		InputData.cc TableDecoder.cc
+
+
+libdecoders_la_LDFLAGS	= -no-undefined
+AM_CXXFLAGS		= $(MAGICS_VISIBILITY) -DINTEGER_IS_INT -Dfortfloat=float -Dfortint=int -Dboolean=bool # for MVObs !!!
+AM_CPPFLAGS		=  $(GRIBAPI_CXXFLAGS) $(SPOT_INCLUDE)  -I$(top_srcdir)/src/libTable -I$(top_srcdir)/src/MvObs -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/include
+#AM_CPPFLAGS		=  $(GRIBAPI_CXXFLAGS) -I/usr/local/lib/metaps/lib/spot_database/new/include -I$(top_srcdir)/src/MvObs -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src -I$(top_srcdir)/src/common -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/include
+
+if MAGICS_QT
+AM_CPPFLAGS += -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+endif
+
diff --git a/src/decoders/Makefile.in b/src/decoders/Makefile.in
new file mode 100644
index 0000000..f3991a2
--- /dev/null
+++ b/src/decoders/Makefile.in
@@ -0,0 +1,961 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+#AM_CPPFLAGS		=  $(GRIBAPI_CXXFLAGS) -I/usr/local/lib/metaps/lib/spot_database/new/include -I$(top_srcdir)/src/MvObs -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src -I$(top_srcdir)/src/common -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers -I$(top_srcdir)/include
+ at MAGICS_QT_TRUE@am__append_1 = -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+subdir = src/decoders
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libdecoders_la_LIBADD =
+am__libdecoders_la_SOURCES_DIST = GribDecoder.cc \
+	GribRegularInterpretor.cc GribSatelliteInterpretor.cc \
+	GribLoopStep.cc EpsgramDecoder.cc ClassicMtgDecoder.cc \
+	ObsDecoder.cc EpsBufr.cc Netcdf.cc NetcdfDecoder.cc \
+	NetcdfInterpretor.cc NetcdfMatrixInterpretor.cc \
+	NetcdfVectorInterpretor.cc NetcdfGeoMatrixInterpretor.cc \
+	NetcdfGeopointsInterpretor.cc NetcdfOrcaInterpretor.cc \
+	NetcdfConvention.cc NetcdfMarsConvention.cc DateTime.cc \
+	LocalTable.cc Date.cc Time.cc EpsXmlInput.cc TitleTemplate.cc \
+	TitleField.cc TitleStringField.cc TitleMetaField.cc \
+	ShapeDecoder.cc WindMode.cc MatrixTestDecoder.cc \
+	InputMatrixInterpretor.cc SimplePolylineInput.cc \
+	BoxPlotDecoder.cc ThinningMethod.cc GeoPointsDecoder.cc \
+	LandgramDecoder.cc ObsStatDecoder.cc shpopen.c dbfopen.c \
+	BinningObject.cc XYList.cc MapGenDecoder.cc InputMatrix.cc \
+	InputData.cc TableDecoder.cc
+ at MAGICS_GRIB_TRUE@am__objects_1 = GribDecoder.lo \
+ at MAGICS_GRIB_TRUE@	GribRegularInterpretor.lo \
+ at MAGICS_GRIB_TRUE@	GribSatelliteInterpretor.lo GribLoopStep.lo
+ at MAGICS_SPOT_TRUE@am__objects_2 = EpsgramDecoder.lo \
+ at MAGICS_SPOT_TRUE@	ClassicMtgDecoder.lo
+ at MAGICS_BUFR_TRUE@am__objects_3 = ObsDecoder.lo EpsBufr.lo
+ at MAGICS_NETCDF_TRUE@am__objects_4 = Netcdf.lo NetcdfDecoder.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfInterpretor.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfMatrixInterpretor.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfVectorInterpretor.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoMatrixInterpretor.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeopointsInterpretor.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfOrcaInterpretor.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfConvention.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfMarsConvention.lo
+am_libdecoders_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
+	$(am__objects_3) $(am__objects_4) DateTime.lo LocalTable.lo \
+	Date.lo Time.lo EpsXmlInput.lo TitleTemplate.lo TitleField.lo \
+	TitleStringField.lo TitleMetaField.lo ShapeDecoder.lo \
+	WindMode.lo MatrixTestDecoder.lo InputMatrixInterpretor.lo \
+	SimplePolylineInput.lo BoxPlotDecoder.lo ThinningMethod.lo \
+	GeoPointsDecoder.lo LandgramDecoder.lo ObsStatDecoder.lo \
+	shpopen.lo dbfopen.lo BinningObject.lo XYList.lo \
+	MapGenDecoder.lo InputMatrix.lo InputData.lo TableDecoder.lo
+ at MAGICS_GRIB_TRUE@am__objects_5 = GribDecoderAttributes.lo \
+ at MAGICS_GRIB_TRUE@	DateGribLoopStepAttributes.lo \
+ at MAGICS_GRIB_TRUE@	GribLoopAttributes.lo
+ at MAGICS_BUFR_TRUE@am__objects_6 = ObsDecoderAttributes.lo \
+ at MAGICS_BUFR_TRUE@	EpsBufrAttributes.lo
+ at MAGICS_SPOT_TRUE@am__objects_7 = EpsgramDecoderAttributes.lo \
+ at MAGICS_SPOT_TRUE@	EfigramDecoderAttributes.lo \
+ at MAGICS_SPOT_TRUE@	ClassicMtgDecoderAttributes.lo
+ at MAGICS_NETCDF_TRUE@am__objects_8 = NetcdfDecoderAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeopointsInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfXYpointsInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoMatrixInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfOrcaInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfMatrixInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoPolarMatrixInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfVectorInterpretorAttributes.lo \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoVectorInterpretorAttributes.lo
+am__objects_9 = $(am__objects_5) $(am__objects_6) $(am__objects_7) \
+	$(am__objects_8) ShapeDecoderAttributes.lo \
+	MapGenDecoderAttributes.lo TitleTemplateAttributes.lo \
+	EpsXmlInputAttributes.lo InputDataAttributes.lo \
+	TableDecoderAttributes.lo InputMatrixAttributes.lo \
+	SymbolInputAttributes.lo \
+	InputMatrixRegularInterpretorAttributes.lo \
+	InputMatrixIrregularInterpretorAttributes.lo \
+	XYListAttributes.lo SimplePolylineInputAttributes.lo \
+	BoxPlotDecoderAttributes.lo GeoPointsDecoderAttributes.lo \
+	ImportActionAttributes.lo LandgramDecoderAttributes.lo \
+	ObsStatDecoderAttributes.lo BinningObjectAttributes.lo
+nodist_libdecoders_la_OBJECTS = $(am__objects_9)
+libdecoders_la_OBJECTS = $(am_libdecoders_la_OBJECTS) \
+	$(nodist_libdecoders_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libdecoders_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libdecoders_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libdecoders_la_SOURCES) $(nodist_libdecoders_la_SOURCES)
+DIST_SOURCES = $(am__libdecoders_la_SOURCES_DIST)
+am__include_HEADERS_DIST = DateTime.h ObsStatDecoder.h \
+	ObsStatDecoderAttributes.h GribDecoder.h \
+	GribDecoderAttributes.h GribLoopAttributes.h \
+	DateGribLoopStepAttributes.h GeoPointsDecoderAttributes.h \
+	GribInterpretor.h GribRegularInterpretor.h \
+	GribSatelliteInterpretor.h GribAddressMode.h EpsgramDecoder.h \
+	ClassicMtgDecoder.h ObsDecoder.h EpsBufr.h Netcdf.h \
+	NetcdfDecoder.h NetcdfInterpretor.h NetcdfMatrixInterpretor.h \
+	NetcdfGeoMatrixInterpretor.h NetcdfGeopointsInterpretor.h \
+	NetcdfVectorInterpretor.h NetcdfOrcaInterpretor.h \
+	NetcdfConvention.h NetcdfMarsConvention.h \
+	NetcdfDecoderAttributes.h NetcdfInterpretorAttributes.h \
+	NetcdfGeopointsInterpretorAttributes.h \
+	NetcdfMatrixInterpretorAttributes.h \
+	NetcdfGeoPolarMatrixInterpretorAttributes.h \
+	NetcdfGeoMatrixInterpretorAttributes.h \
+	NetcdfGeoVectorInterpretorAttributes.h \
+	NetcdfVectorInterpretorAttributes.h EpsXmlInput.h \
+	MatrixTestDecoder.h XYList.h XYList.cc TitleTemplate.h \
+	TitleField.h TitleStringField.h TitleMetaField.h LocalTable.h \
+	ImportAction.h SymbolInput.h InputMatrix.h InputMatrix.cc \
+	InputData.h InputData.cc TableDecoder.h TableDecoder.cc \
+	InputMatrixInterpretor.h BoxPlotDecoder.h EfiDataDecoder.h \
+	EfiLegendEntry.h LandgramDecoder.h WindMode.h MapGenDecoder.cc \
+	MapGenDecoder.h ShapeDecoder.h shapefil.h \
+	SimplePolylineInput.h GribLoopStep.h GeoPointsDecoder.h \
+	ObsDecoderAttributes.h ImportActionAttributes.h \
+	ThinningMethod.h BinningObject.h BinningObjectAttributes.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = DateTime.h ObsStatDecoder.h \
+	ObsStatDecoderAttributes.h GribDecoder.h \
+	GribDecoderAttributes.h GribLoopAttributes.h \
+	DateGribLoopStepAttributes.h GeoPointsDecoderAttributes.h \
+	GribInterpretor.h GribRegularInterpretor.h \
+	GribSatelliteInterpretor.h GribAddressMode.h EpsgramDecoder.h \
+	ClassicMtgDecoder.h ObsDecoder.h EpsBufr.h Netcdf.h \
+	NetcdfDecoder.h NetcdfInterpretor.h NetcdfMatrixInterpretor.h \
+	NetcdfGeoMatrixInterpretor.h NetcdfGeopointsInterpretor.h \
+	NetcdfVectorInterpretor.h NetcdfOrcaInterpretor.h \
+	NetcdfConvention.h NetcdfMarsConvention.h \
+	NetcdfDecoderAttributes.h NetcdfInterpretorAttributes.h \
+	NetcdfGeopointsInterpretorAttributes.h \
+	NetcdfMatrixInterpretorAttributes.h \
+	NetcdfGeoPolarMatrixInterpretorAttributes.h \
+	NetcdfGeoMatrixInterpretorAttributes.h \
+	NetcdfGeoVectorInterpretorAttributes.h \
+	NetcdfVectorInterpretorAttributes.h EpsXmlInput.h \
+	MatrixTestDecoder.h XYList.h XYList.cc TitleTemplate.h \
+	TitleField.h TitleStringField.h TitleMetaField.h LocalTable.h \
+	ImportAction.h SymbolInput.h InputMatrix.h InputMatrix.cc \
+	InputData.h InputData.cc TableDecoder.h TableDecoder.cc \
+	InputMatrixInterpretor.h BoxPlotDecoder.h EfiDataDecoder.h \
+	EfiLegendEntry.h LandgramDecoder.h WindMode.h MapGenDecoder.cc \
+	MapGenDecoder.h ShapeDecoder.h shapefil.h \
+	SimplePolylineInput.h GribLoopStep.h GeoPointsDecoder.h \
+	ObsDecoderAttributes.h ImportActionAttributes.h \
+	ThinningMethod.h BinningObject.h BinningObjectAttributes.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libdecoders.la
+ at MAGICS_NETCDF_TRUE@NETCDF_noi_H = Netcdf.h NetcdfDecoder.h NetcdfInterpretor.h \
+ at MAGICS_NETCDF_TRUE@		NetcdfMatrixInterpretor.h \
+ at MAGICS_NETCDF_TRUE@		NetcdfGeoMatrixInterpretor.h NetcdfGeopointsInterpretor.h \
+ at MAGICS_NETCDF_TRUE@		NetcdfVectorInterpretor.h NetcdfOrcaInterpretor.h\
+ at MAGICS_NETCDF_TRUE@		NetcdfConvention.h NetcdfMarsConvention.h \
+ at MAGICS_NETCDF_TRUE@		NetcdfDecoderAttributes.h  NetcdfInterpretorAttributes.h NetcdfGeopointsInterpretorAttributes.h NetcdfMatrixInterpretorAttributes.h \
+ at MAGICS_NETCDF_TRUE@		NetcdfGeoPolarMatrixInterpretorAttributes.h NetcdfGeoMatrixInterpretorAttributes.h NetcdfGeoVectorInterpretorAttributes.h NetcdfVectorInterpretorAttributes.h
+
+ at MAGICS_NETCDF_TRUE@NETCDF_la_S = Netcdf.cc NetcdfDecoder.cc NetcdfInterpretor.cc \
+ at MAGICS_NETCDF_TRUE@		NetcdfMatrixInterpretor.cc NetcdfVectorInterpretor.cc \
+ at MAGICS_NETCDF_TRUE@		NetcdfGeoMatrixInterpretor.cc NetcdfGeopointsInterpretor.cc \
+ at MAGICS_NETCDF_TRUE@		NetcdfOrcaInterpretor.cc \
+ at MAGICS_NETCDF_TRUE@		NetcdfConvention.cc NetcdfMarsConvention.cc
+
+ at MAGICS_NETCDF_TRUE@ATTRIBUTES_NETCDF = NetcdfDecoderAttributes.cc NetcdfInterpretorAttributes.cc \
+ at MAGICS_NETCDF_TRUE@		NetcdfGeopointsInterpretorAttributes.cc NetcdfXYpointsInterpretorAttributes.cc \
+ at MAGICS_NETCDF_TRUE@		NetcdfGeoMatrixInterpretorAttributes.cc NetcdfOrcaInterpretorAttributes.cc NetcdfMatrixInterpretorAttributes.cc\
+ at MAGICS_NETCDF_TRUE@		NetcdfGeoPolarMatrixInterpretorAttributes.cc \
+ at MAGICS_NETCDF_TRUE@ 		NetcdfVectorInterpretorAttributes.cc NetcdfGeoVectorInterpretorAttributes.cc 
+
+ at MAGICS_GRIB_TRUE@GRIB_noi_H = GribDecoder.h GribDecoderAttributes.h GribLoopAttributes.h DateGribLoopStepAttributes.h GeoPointsDecoderAttributes.h \
+ at MAGICS_GRIB_TRUE@			GribInterpretor.h GribRegularInterpretor.h GribSatelliteInterpretor.h GribAddressMode.h
+
+ at MAGICS_GRIB_TRUE@GRIB_la_S = GribDecoder.cc GribRegularInterpretor.cc GribSatelliteInterpretor.cc GribLoopStep.cc
+ at MAGICS_GRIB_TRUE@ATTRIBUTES_GRIB = GribDecoderAttributes.cc DateGribLoopStepAttributes.cc GribLoopAttributes.cc	
+ at MAGICS_BUFR_TRUE@BUFR_noi_H = ObsDecoder.h EpsBufr.h
+ at MAGICS_BUFR_TRUE@BUFR_la_S = ObsDecoder.cc EpsBufr.cc
+ at MAGICS_BUFR_TRUE@ATTRIBUTES_BUFR = ObsDecoderAttributes.cc EpsBufrAttributes.cc
+ at MAGICS_SPOT_TRUE@SPOT_noi_H = EpsgramDecoder.h  ClassicMtgDecoder.h 
+ at MAGICS_SPOT_TRUE@SPOT_la_S = EpsgramDecoder.cc ClassicMtgDecoder.cc  
+ at MAGICS_SPOT_TRUE@ATTRIBUTES_SPOT = EpsgramDecoderAttributes.cc EfigramDecoderAttributes.cc ClassicMtgDecoderAttributes.cc 
+ATTRIBUTES = ${ATTRIBUTES_GRIB} ${ATTRIBUTES_BUFR} ${ATTRIBUTES_SPOT} ${ATTRIBUTES_NETCDF} ShapeDecoderAttributes.cc MapGenDecoderAttributes.cc  \
+		TitleTemplateAttributes.cc \
+		EpsXmlInputAttributes.cc \
+		InputDataAttributes.cc TableDecoderAttributes.cc InputMatrixAttributes.cc SymbolInputAttributes.cc \
+		InputMatrixRegularInterpretorAttributes.cc InputMatrixIrregularInterpretorAttributes.cc XYListAttributes.cc \
+		SimplePolylineInputAttributes.cc \
+		BoxPlotDecoderAttributes.cc  \
+		GeoPointsDecoderAttributes.cc ImportActionAttributes.cc LandgramDecoderAttributes.cc \
+		ObsStatDecoderAttributes.cc BinningObjectAttributes.cc 
+
+include_H = DateTime.h ObsStatDecoder.h ObsStatDecoderAttributes.h $(GRIB_noi_H) $(SPOT_noi_H) $(NETPBM_noi_H) $(BUFR_noi_H) $(NETCDF_noi_H) \
+		EpsXmlInput.h MatrixTestDecoder.h \
+		XYList.h XYList.cc \
+		TitleTemplate.h \
+		TitleField.h TitleStringField.h TitleMetaField.h \
+		LocalTable.h \
+		ImportAction.h \
+		SymbolInput.h  \
+		InputMatrix.h InputMatrix.cc \
+		InputData.h InputData.cc \
+		TableDecoder.h TableDecoder.cc \
+		InputMatrixInterpretor.h \
+		BoxPlotDecoder.h \
+		EfiDataDecoder.h EfiLegendEntry.h \
+		LandgramDecoder.h \
+		WindMode.h \
+		MapGenDecoder.cc MapGenDecoder.h ShapeDecoder.h shapefil.h \
+		SimplePolylineInput.h GribLoopStep.h \
+		GeoPointsDecoder.h ObsDecoderAttributes.h ImportActionAttributes.h ThinningMethod.h BinningObject.h BinningObjectAttributes.h
+
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(noinst_H) $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = $(noinst_H)
+nodist_libdecoders_la_SOURCES = ${ATTRIBUTES}
+libdecoders_la_SOURCES = $(GRIB_la_S) $(SPOT_la_S) $(BUFR_la_S) $(NETCDF_la_S) \
+		DateTime.cc  \
+		LocalTable.cc Date.cc Time.cc \
+		EpsXmlInput.cc \
+		TitleTemplate.cc  \
+		TitleField.cc TitleStringField.cc TitleMetaField.cc  \
+		ShapeDecoder.cc \
+		WindMode.cc \
+		MatrixTestDecoder.cc \
+		InputMatrixInterpretor.cc  \
+		SimplePolylineInput.cc \
+		BoxPlotDecoder.cc \
+		ThinningMethod.cc \
+		GeoPointsDecoder.cc LandgramDecoder.cc \
+		ObsStatDecoder.cc \
+		shpopen.c dbfopen.c \
+		BinningObject.cc  XYList.cc MapGenDecoder.cc  InputMatrix.cc \
+		InputData.cc TableDecoder.cc
+
+libdecoders_la_LDFLAGS = -no-undefined
+AM_CXXFLAGS = $(MAGICS_VISIBILITY) -DINTEGER_IS_INT -Dfortfloat=float -Dfortint=int -Dboolean=bool # for MVObs !!!
+AM_CPPFLAGS = $(GRIBAPI_CXXFLAGS) $(SPOT_INCLUDE) \
+	-I$(top_srcdir)/src/libTable -I$(top_srcdir)/src/MvObs \
+	-I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common \
+	-I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/drivers \
+	-I$(top_srcdir)/include $(am__append_1)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/decoders/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/decoders/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libdecoders.la: $(libdecoders_la_OBJECTS) $(libdecoders_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libdecoders_la_LINK)  $(libdecoders_la_OBJECTS) $(libdecoders_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinningObject.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinningObjectAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ClassicMtgDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ClassicMtgDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Date.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DateGribLoopStepAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DateTime.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EfigramDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsBufr.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsBufrAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsXmlInput.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsXmlInputAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsgramDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsgramDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GeoPointsDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GeoPointsDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribLoopAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribLoopStep.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribRegularInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribSatelliteInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImportActionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputData.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputDataAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputMatrix.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputMatrixAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputMatrixInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputMatrixIrregularInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputMatrixRegularInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LandgramDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LandgramDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LocalTable.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MapGenDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MapGenDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MatrixTestDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Netcdf.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfConvention.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoMatrixInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoMatrixInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoPolarMatrixInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoVectorInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeopointsInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeopointsInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfMarsConvention.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfMatrixInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfMatrixInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfOrcaInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfOrcaInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfVectorInterpretor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfVectorInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfXYpointsInterpretorAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsStatDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsStatDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ShapeDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ShapeDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SimplePolylineInput.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SimplePolylineInputAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolInputAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TableDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TableDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ThinningMethod.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Time.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TitleField.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TitleMetaField.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TitleStringField.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TitleTemplate.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TitleTemplateAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XYList.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XYListAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/dbfopen.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shpopen.Plo at am__quote@
+
+.c.o:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/decoders/MapGenDecoder.cc b/src/decoders/MapGenDecoder.cc
new file mode 100644
index 0000000..4a98e7f
--- /dev/null
+++ b/src/decoders/MapGenDecoder.cc
@@ -0,0 +1,118 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MapGenDecoder.cc
+    \brief Implementation of the Template class MapGenDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 12-Dec-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "MapGenDecoder.h"
+#include "CustomisedPoint.h"
+
+using namespace magics;
+
+
+MapGenDecoder::MapGenDecoder()
+{
+}
+
+
+MapGenDecoder::~MapGenDecoder()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void MapGenDecoder::print(ostream& out)  const
+{
+	out << "MapGenDecoder[";
+	out << "]";
+}
+
+
+void MapGenDecoder::decode()
+{
+	if ( !this->empty() ) return;
+	try {
+		char line[1024];
+		ifstream in(path_.c_str());
+		float lat, lon;
+		int i = 0;
+		while ( in.good() )
+		{
+			in.getline(line, 1024);
+            
+            string test(line);
+            
+			if ( test.empty() ) 
+                continue;
+			if ( strncmp(line,"# -b", 4) == 0 ) 
+			   if ( record_ < 0 ) {
+				   if ( this->empty() ) push_back(new PointsList());
+				   this->back()->push_back(new UserPoint(0,0,0, true));
+			   }
+			   else
+				   push_back(new PointsList());
+			else {
+				sscanf(line, "%f %f", &lon, &lat);
+				this->back()->push_back(new UserPoint(lon, lat, i++));
+			}						
+		}
+	
+		in.close();
+	}
+	catch (...)
+	{
+		MagLog::error() << "MapGen file : can not open " << path_ << endl;
+	}
+	MagLog::dev() << "Map gen file--->" << this->size() << endl; 
+}
+
+
+void MapGenDecoder::customisedPoints(const std::set<string>&, magics::CustomisedPointsList& out)
+{
+	PointsHandler& list = points();
+	
+	list.setToFirst();
+	int i = 0;
+     while (list.more()) {        
+    	  UserPoint point = list.current();
+          CustomisedPoint* cpoint = new CustomisedPoint();
+		    	(*cpoint)["x"] = point.x();
+		    	(*cpoint)["y"] = point.y();
+		    	(*cpoint)["value"] = i++;
+		    	(*cpoint)["x_lower"] = 0;
+		    	(*cpoint)["y_lower"] = 0;
+		    	(*cpoint)["x_upper"] = point.x();
+		    	(*cpoint)["y_upper"] = point.y();
+		    	out.push_back(cpoint);
+          list.advance();
+      
+    }  	
+		
+}
diff --git a/src/decoders/MapGenDecoder.h b/src/decoders/MapGenDecoder.h
new file mode 100644
index 0000000..9ee5154
--- /dev/null
+++ b/src/decoders/MapGenDecoder.h
@@ -0,0 +1,95 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MapGenDecoder.h
+    \brief Definition of the Template class MapGenDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 12-Dec-2005
+    
+    Changes:
+    
+*/
+
+#ifndef MapGenDecoder_H
+#define MapGenDecoder_H
+
+#include "magics.h"
+
+#include "MapGenDecoderAttributes.h"
+#include "Data.h"
+#include "Decoder.h"
+#include "UserPoint.h"
+
+namespace magics {
+	
+class XmlNode;
+
+
+class MapGenDecoder: public MapGenDecoderAttributes, 
+		public Data, public Decoder, public vector<PointsList* >
+{
+
+public:
+	MapGenDecoder();
+	virtual ~MapGenDecoder();
+	//! Method to access the data as a list of points : Used by psymb.
+
+	virtual void decode();
+	void set(const map<string, string>& map ) { MapGenDecoderAttributes::set(map); }
+	void set(const XmlNode& node ) { MapGenDecoderAttributes::set(node); }
+
+	PointsHandler& points()
+	{ 
+		decode();
+		if (record_ > int(this->size()) ) record_= 1;
+		if (record_ == -1 ) record_ = 1;
+		this->pointsHandlers_.push_back(new PointsHandler(*(*this)[record_-1]));
+		return *(this->pointsHandlers_.back());
+	} 
+	PointsHandler& points(const Transformation& )
+	{
+	        return points();
+	}
+
+	void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	 void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	    {
+	    	customisedPoints( n, out);
+	    }
+	    PointsHandler& points(const Transformation& t, bool) { return points(t); }
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	MapGenDecoder(const MapGenDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	MapGenDecoder& operator=(const MapGenDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MapGenDecoder& p)
+		{ p.print(s); return s; }
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/MatrixTestDecoder.cc b/src/decoders/MatrixTestDecoder.cc
new file mode 100644
index 0000000..44f3065
--- /dev/null
+++ b/src/decoders/MatrixTestDecoder.cc
@@ -0,0 +1,102 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MatrixTestDecoder.h
+    \brief Implementation of the Template class MatrixTestDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 25-Mar-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "MatrixTestDecoder.h"
+#include "Factory.h"
+#include <limits>
+
+using namespace magics;
+
+MatrixTestDecoder::MatrixTestDecoder()
+{
+	
+	ifstream f("/home/graphics/cgs/public/map.txt");
+	assert(f);
+	int rows, columns;
+	double lon, lat, inclon, inclat;
+	f >> rows >> columns;
+	f >> lat >> lon >> inclat >> inclon;
+	matrix_.set(rows, columns);
+	double missing = -std::numeric_limits<double>::max();
+     
+	matrix_.missing(missing);
+	
+	char c;
+    while (! f.eof() )
+    {
+      f.get(c);      
+   
+      if (isdigit(c) )   
+      	matrix_.push_back(atoi(&c));
+      if (c == '.') 
+      	matrix_.push_back(missing);
+         
+    }
+    f.close();
+    
+    
+  
+	
+	
+    for (int i = 0; i < columns; i++) {
+           matrix_.columnsAxis().push_back(lon);
+           lon+=inclon;
+    }
+    
+    for (int i = 0; i < rows; i++) {
+    	matrix_.rowsAxis().push_back(lat);
+    	lat+=inclat;
+    }
+
+   
+    matrix_.setMapsAxis();
+
+    
+   
+}
+
+
+
+MatrixTestDecoder::~MatrixTestDecoder() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MatrixTestDecoder::print(ostream& out)  const
+{
+	out << "MatrixTestDecoder[";
+	
+	out << "]";
+}
+
+
diff --git a/src/decoders/MatrixTestDecoder.h b/src/decoders/MatrixTestDecoder.h
new file mode 100644
index 0000000..5727dbe
--- /dev/null
+++ b/src/decoders/MatrixTestDecoder.h
@@ -0,0 +1,85 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MatrixTestDecoder.h
+    \brief Definition of the Template class MatrixTestDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 25-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MatrixTestDecoder_H
+#define MatrixTestDecoder_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "Data.h"
+#include "Decoder.h"
+
+
+namespace magics {
+
+class MatrixTestDecoder: public Decoder, public Data {
+
+public:
+	MatrixTestDecoder();
+	virtual ~MatrixTestDecoder();
+	// implements Decoder interface
+	void decode() {}
+
+	virtual void set(const map<string, string>& ) {}
+	
+	 void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	    {
+	    	assert(false);
+	    }
+	    PointsHandler& points(const Transformation& t, bool) { assert(false); }
+	
+    
+	PointsHandler& points() { throw MethodNotYetImplemented("MatrixTestDecoder::points()"); }
+	virtual MatrixHandler& matrix()
+	{
+		decode();
+		matrixHandlers_.push_back(new  MatrixHandler(matrix_));
+		return *(matrixHandlers_.back());
+	}
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	Matrix matrix_;
+
+private:
+	//! Copy constructor - No copy allowed
+	MatrixTestDecoder(const MatrixTestDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	MatrixTestDecoder& operator=(const MatrixTestDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MatrixTestDecoder& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/Netcdf.cc b/src/decoders/Netcdf.cc
new file mode 100644
index 0000000..ef19eee
--- /dev/null
+++ b/src/decoders/Netcdf.cc
@@ -0,0 +1,302 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+//! \file Netcdf.cc
+/*!
+ Sylvie Lamy-Thepaut - ECMWF Apr 02
+ 
+ Changes:
+ 
+   Apr 06: update for GCC 4.0 (Stephan) 
+*/
+#include <Netcdf.h>
+#include <MagException.h>
+#include <MagLog.h>
+ 
+
+using namespace magics;
+
+
+static bool isVariable(NcVar* var)
+{
+    if (var->num_dims() != 1) return true;
+    
+    string name0(var->name());
+    string name1(var->get_dim(0)->name());
+    if ( name0 == name1) return false;
+    return true; 
+}
+
+template <class From, class To>
+Convertor<From,To>::Convertor(NetVariable& var) : variable_(var)
+{
+	To scale(1);
+	To offset(0);
+	scale_factor_ = variable_.getAttribute("scale_factor", scale);
+	add_offset_ = variable_.getAttribute("add_offset", offset);
+}
+
+/*
+template <class T>
+void Accessor<T>::access(vector<T>& data, vector<long> start, vector<long> edges, NetVariable& var) 
+{
+        typename map<NcType, Accessor<T>*>::const_iterator accessor = accessors_->find(var.id_->type());
+        if ( accessor == accessors_->end() ) throw new MagicsException("No accessor available");
+        
+        (*(*accessor).second)(data, start, edges, var);
+}
+*/
+
+//template <class T>
+//void Accessor<T>::access(vector<T>& data, NetDimension& dim) 
+//{
+//       typename map<NcType, Accessor<T>*>::const_iterator accessor = accessors_->find(var.id_->type());
+//       if ( accessor == accessors_->end() ) throw new MagicsException("No accessor available");
+
+//        (*(*accessor).second)(data, dim);
+//}
+
+template <class F, class T>   
+void TypedAccessor<F,T>::operator() (vector<T>& to, vector<long>& start, vector<long>& edges, NetVariable& var) const
+{
+	F* from = new F[to.size()];
+	var.id_->set_cur(&start[0]);
+	var.id_->get(from, &edges[0]);
+	// Convert the data....       
+	std::transform(from, from + to.size(), to.begin(), Convertor<F, T>(var));
+	delete[] from;
+	
+	
+}
+
+template <class F, class T> 
+void TypedAccessor<F,T>::get (vector<F>& from, vector<long>& start, vector<long>& edges, NetVariable& var)const
+{
+	var.id_->set_cur(&start[0]);
+	var.id_->get(from, &edges[0]);
+} 
+
+Netcdf::Netcdf(const string& path) : file_(path.c_str())
+{
+	if (file_.is_valid() == false) throw NoSuchNetcdfFile(path);
+	for ( int v = 0; v < file_.num_vars(); v++)
+	{ 
+		NcVar* var = file_.get_var(v); 
+		//MagLog::debug() << "Netcdf [" << path << "] " << ": add Variable --->" << var->name() << "\n"; 
+		variables_.insert(std::make_pair(var->name(), NetVariable(var->name(), var, file_)));
+		// Check that the variable is not a dimension! if not, add it to the dataset.
+	    //MagLog::debug() << "Netcdf [" << path << "] " << ": add Variable --->" << var->name() << "\n"; 
+
+		if (isVariable(var)) dataset_.insert(std::make_pair(var->name(), NetVariable(var->name(), var, file_)));
+	}
+	MagLog::debug() << "Initialisation of  Netcdf [" << path << "] OK! " << "\n";  
+	for ( int v = 0; v < file_.num_atts(); v++)
+		{
+			NcAtt* attr = file_.get_att(v);
+			//MagLog::debug() << "Netcdf [" << path << "] " << ": add Variable --->" << var->name() << "\n";
+			attributes_.insert(std::make_pair(attr->name(), NetAttribute(attr->name(), attr)));
+
+
+
+		}
+}
+
+
+Netcdf::~Netcdf() 
+{	
+}
+
+void Netcdf::print(ostream& out)  const
+{
+	out << "print Netcdf: " << "\n";
+	out << "Variables: " << "\n";
+	for (map<string, NetVariable>::const_iterator var = variables_.begin(); var != variables_.end(); ++var)
+	{
+		out << (*var).second;
+	}
+	out << "Dataset: " << "\n";
+	for (map<string, NetVariable>::const_iterator var = dataset_.begin(); var != dataset_.end(); ++var)
+	{
+		out << (*var).second;
+	}
+}
+
+
+struct Index
+{
+	static map<NcType, Index*>* tools_;
+	Index(NcType type)
+	{
+		if ( tools_ == 0) tools_ = new  map<NcType, Index*>();
+		tools_->insert(std::make_pair(type, this));
+	}
+	virtual int operator()(const string&,  NcValues*, long)
+	{
+		throw MagicsException("Index not implemented.."); 
+	}
+	static int get(const NcType& type, const string& val,  NcValues* values, long nb)
+	{
+		map<NcType, Index*>::const_iterator tool = tools_->find(type);
+		if ( tool == tools_->end() ) throw new MagicsException("No Index available");
+        
+		return (*(*tool).second)(val, values, nb);
+	}
+};
+
+struct FloatIndex: public Index
+{
+	FloatIndex() : Index(ncFloat) {}
+    
+	virtual int operator()(const string& val,  NcValues* values, long nb )
+	{
+		float value = atof(val.c_str());
+                if ( nb == 1 && values->as_float(0) == value) return 0;
+		for (int i = 0; i < nb - 1; i++) {
+			if (values->as_float(i) == value) return i;
+			if (values->as_float(i+1) == value) return i+1;
+			if (values->as_float(i) < value && value  < values->as_float(i+1) ) return i;  
+			if (values->as_float(i+1) < value && value  < values->as_float(i) ) return i+1;     
+		}
+		throw MagicsException("No such value : " + val);
+	}
+};
+struct DoubleIndex: public Index
+{
+	DoubleIndex() : Index(ncDouble) {}
+    
+	virtual int operator()(const string& val,  NcValues* values, long nb )
+	{
+		double value = tonumber(val);
+        if ( nb == 1 && values->as_double(0) == value) return 0;
+		for (int i = 0; i < nb - 1; i++) {
+			if (values->as_double(i) == value) return i;
+			if (values->as_double(i+1) == value) return i+1;
+			if (values->as_double(i) < value && value  < values->as_double(i+1) ) return i;  
+			if (values->as_double(i+1) < value && value  < values->as_double(i) ) return i+1;     
+		}
+		throw MagicsException("No such value : " + val);
+	}
+};
+
+
+struct IntIndex: public Index
+{
+	IntIndex() : Index(ncInt) {}
+    
+	virtual int operator()(const string& val,  NcValues* values, long nb )
+	{
+		int value = atoi(val.c_str());
+        	 if ( nb == 1 && values->as_int(0) == value) return 0;
+
+		for (int i = 0; i < nb - 1; i++)
+		{
+			if (values->as_int(i) == value) return i;
+			if (values->as_int(i+1) == value) return i+1;
+			if ( values->as_int(i) < value && value < values->as_int(i+1) ) return i;   
+			if ( values->as_int(i+1) < value && value < values->as_int(i) ) return i+1;     
+		}
+		throw MagicsException("No such value : " + val);
+	}
+};
+
+struct StringIndex: public Index
+{
+	StringIndex() : Index(ncInt) {}
+    
+	virtual int operator()(const string& val,  NcValues* values, long nb )
+	{
+		for (int i = 0; i < nb; i++)
+		{
+			string read(values->as_string(i));
+			if ( read == val) return i;
+		}
+		throw MagicsException("No such value : " + val);
+	}
+};
+
+map<NcType, Index*>*  Index::tools_ = 0;
+
+static FloatIndex float_index;
+static IntIndex int_index;
+static DoubleIndex double_index;
+
+int  NetDimension::index(const string& val)
+{
+	return Index::get(variable_->type(), val, variable_->values(), variable_->num_vals());
+}
+
+
+void NetDimension::first(const string& val)
+{
+	if ( variable_ ) first_ = index(val);
+}
+
+
+void NetDimension::last(const string& val)
+{
+	if (!variable_ ) return;
+	int last = index(val);     
+	if ( last < first_ )
+	{
+		MagLog::warning() << "last position (" + val + ") < first position: exchange " << "\n";
+		int tmp = first_;
+		first_ = last;
+		last = tmp;
+	} 
+	dim_ = last - first_ + 1;   
+}
+
+
+NetVariable::NetVariable(const string& name, NcVar* id, const NcFile& file): name_(name), id_(id) 
+	{
+		for (int d = 0; d < id_->num_dims(); d++)
+		{
+			NcDim* dim = id_->get_dim(d);
+			NcVar* var = 0;
+			string dim_name = dim->name();
+		    for (int v = 0; v < file.num_vars(); v++) {
+		    	 string var_name = file.get_var(v)->name();
+		         if (var_name == dim_name) var = file.get_var(dim->name());
+		         
+		    }
+			dimensions_[dim->name()]= NetDimension(dim, var, d); 
+		}
+		for (int a = 0; a < id_->num_atts(); a++)
+		{
+			NcAtt* att = id_->get_att(a);
+			attributes_[att->name()] = NetAttribute(att->name(), att); 
+		}
+	}
+
+namespace magics {
+	template<> map<NcType, Accessor<double>*>*  Accessor<double>::accessors_ = 0;
+	template<> map<NcType, Accessor<float>*>*  Accessor<float>::accessors_ = 0;
+} // end namespace
+
+
+static TypedAccessor<short, float>  short_float_accessor(ncShort);
+static TypedAccessor<int, float>  int_float_accessor(ncInt);
+static TypedAccessor<float, float>  float_float_accessor(ncFloat);
+static TypedAccessor<double, float> double_float_accessor(ncDouble);
+
+static TypedAccessor<ncbyte, double>  byte_double_accessor(ncByte);
+static TypedAccessor<short, double>  short_double_accessor(ncShort);
+static TypedAccessor<int, double>  int_double_accessor(ncInt);
+static TypedAccessor<float, double>  float_double_accessor(ncFloat);
+static TypedAccessor<double, double> double_double_accessor(ncDouble);
+
diff --git a/src/decoders/Netcdf.h b/src/decoders/Netcdf.h
new file mode 100644
index 0000000..fdd215a
--- /dev/null
+++ b/src/decoders/Netcdf.h
@@ -0,0 +1,396 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Netcdf.h
+    \brief Definition of the Netcdf access tools.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Netcdf_H
+#define Netcdf_H
+
+#include "magics.h"
+#include "netcdfcpp.h"
+
+#include "MagException.h"
+#include "MagLog.h"
+
+namespace magics {
+
+class NoSuchNetcdfVariable : public MagicsException
+{
+public:
+	 NoSuchNetcdfVariable( const string& var ):
+		MagicsException("Netcdf MagException:  Can not find variable ---> " + var) 
+		{	MagLog::warning() << what_ << "\n"; }
+}; 
+class NoSuchNetcdfDimension : public MagicsException
+{
+public:
+	 NoSuchNetcdfDimension( const string& dim ):
+		MagicsException("Netcdf MagException :  Can not find dimension ---> " + dim) 
+		{	MagLog::warning() << what_ << "\n"; }
+}; 
+
+class NoSuchNetcdfFile : public MagicsException
+{
+public:
+	 NoSuchNetcdfFile( const string& file ):
+		MagicsException("Netcdf MagException: The file " + file + " does not exist or is not a valid netcdf file")
+		{	MagLog::error() << what_ << "\n"; }
+}; 
+
+struct NetDimension 
+{
+    string name_;
+    long   size_; 
+    long   first_;
+    long   dim_;
+    long   index_;
+    NcDim* id_;
+    NcVar* variable_;
+ 
+    NetDimension() {}
+    NetDimension(NcDim* id, NcVar* variable, long index) : 
+        name_(id->name()), size_(id->size()), 
+        first_(0), dim_(size_), index_(index), 
+        id_(id), variable_(variable)
+        {}
+        
+    void first(const string&);
+    void last(const string&);
+    int  index(const string&);
+    
+    void print(ostream& s) const
+    {
+        s << name_ << "(" << size_ << ", " << index_ << ", " << first_ << ", " << dim_ << ")";
+    }
+    friend ostream& operator<<(ostream& s,const NetDimension& p)
+		{ p.print(s); return s; }
+};   
+
+
+struct NetAttribute 
+{
+	string name_;
+	NcAtt* id_;
+	NetAttribute(const string name, NcAtt* id) : name_(name), id_(id) {} 
+	NetAttribute() {}
+	void get(double& val)      { val =  id_->as_double(0); }
+	void get(float& val)       { val =  id_->as_float(0); }
+	void get(const char*& val) { val =  id_->as_string(0); }
+
+};
+
+class NetVariable;
+
+template <class From, class To>
+struct Convertor
+{
+	Convertor(NetVariable& );
+	To operator()(From from)
+	{      
+		return from * scale_factor_ + add_offset_;
+	}  
+
+	NetVariable& variable_;
+	To    scale_factor_;
+	To    add_offset_;
+};
+
+
+template <class T>
+class Accessor
+{
+public:
+    Accessor(NcType type) {
+        if ( !accessors_) accessors_ = new map<NcType, Accessor<T>*>;
+        accessors_->insert(std::make_pair(type, this));
+    }
+    virtual ~Accessor() {    }
+       
+    virtual void operator() (vector<T>&,  vector<long>& , vector<long>&, NetVariable&) const {}
+    
+    static map<NcType, Accessor<T>*>* accessors_;
+    static void release() {
+ 		if ( accessors_ ) 
+ 			for ( typename map<NcType, Accessor<T>*>::iterator a = accessors_.begin(); a != accessors_.end(); ++a) {
+ 				Accessor<T>* accessor = a->second;
+ 				 a->second = 0;
+ 				 delete accessor;
+    		}
+	}
+    
+
+    static void access(vector<T>& data, vector<long> start, vector<long> edges, NetVariable& var); 
+    static void access(vector<T>& data, NetDimension& dim){}
+};
+
+template <class F, class T>
+class TypedAccessor : public Accessor<T>
+{
+public:
+	TypedAccessor(NcType type) : Accessor<T>(type) {}
+
+	void operator() (vector<T>& to, vector<long>& start, vector<long>& edges, NetVariable& var) const;
+	void get (vector<F>& from, vector<long>& start, vector<long>& edges, NetVariable& var) const;
+};
+
+
+
+struct NetVariable 
+{
+	string name_;
+	NcVar* id_;
+	map<string, NetDimension> dimensions_;
+	map<string, NetAttribute> attributes_;
+    
+	NetVariable(const string& name, NcVar* id, const NcFile& file);
+
+	void getStartingPoint(vector<long>& dims)
+	{
+		dims.resize(dimensions_.size());
+		for (map<string, NetDimension>::const_iterator dim = dimensions_.begin(); dim != dimensions_.end(); ++dim) 
+		{
+			dims[(*dim).second.index_] = (*dim).second.first_;
+		}
+	}
+    
+	void getDimensions(vector<long>& dims)
+	{
+		dims.resize(dimensions_.size());
+		for (map<string, NetDimension>::const_iterator dim = dimensions_.begin(); dim != dimensions_.end(); ++dim) 
+		{
+			dims[(*dim).second.index_] = (*dim).second.dim_;
+		}
+	}
+    
+ 
+    void setFirstPoint(const string& name, const string& first)
+    {
+        map<string, NetDimension>::iterator dim = dimensions_.find(name);   
+        if ( dim == dimensions_.end() ) return;
+        (*dim).second.first(first);
+    }
+   
+    void setLastPoint(const string& name, const string& last)
+    {
+        map<string, NetDimension>::iterator d = dimensions_.find(name);   
+        if ( d == dimensions_.end() ) return;
+        (*d).second.last(last);
+    }
+    
+    long getSize(const vector<long>& dims)
+    {
+       long size = 1;
+       for (unsigned int i = 0; i < dims.size(); i++)
+           size = (dims[i] ) * size;
+       return size;    
+    }
+    void print(ostream& s) const
+    {
+        s << name_ << "[";
+        string sep = "";
+        for (map<string, NetDimension>::const_iterator dim = dimensions_.begin(); dim != dimensions_.end(); ++dim) 
+        {
+            s << sep << (*dim).second;
+            sep = ", ";
+        }
+        
+        s << "]" << "\n";
+        
+    }
+    
+    template <class T> 
+    T  getAttribute(const string& name, T def) 
+    {
+        T val;
+        map<string, NetAttribute>::iterator attr = attributes_.find(name);
+        if ( attr == attributes_.end() ) return def;
+        (*attr).second.get(val);
+        return val;
+   
+    } 
+    
+    template <class T>
+    void get(vector<T>& vals, map<string, string> first, map<string, string> last)  
+    {
+        for (map<string, string>::const_iterator f = first.begin(); f != first.end(); ++f) {
+            setFirstPoint((*f).first, (*f).second);
+        }
+        for (map<string, string>::const_iterator f = last.begin(); f != last.end(); ++f) {
+            setLastPoint((*f).first, (*f).second);
+        }
+        get(vals);
+    }
+    
+    template <class T>
+    void get(vector<T>& vals)
+    {
+        vector<long> start;
+        getStartingPoint(start);
+        vector<long> end;
+        getDimensions(end);
+        
+        vals.resize(getSize(end));
+        Accessor<T>::access(vals, start, end, *this);
+    
+        
+    }
+    
+    friend ostream& operator<<(ostream& s,const NetVariable& p)
+		{ p.print(s); return s; }
+     
+};
+
+   
+class Netcdf { 
+public:
+
+    Netcdf(const string&);
+
+    virtual ~Netcdf();
+	
+    typedef map<string, NetVariable> VariableMap;
+    
+
+    template <class T>
+    void get(const string& name, vector<T>& vals, 
+                                map<string, string> first, 
+                                map<string, string> last)
+    {
+    
+        map<string, NetVariable>::iterator var = variables_.find(name);
+        if ( var == variables_.end() ) throw NoSuchNetcdfVariable(name);
+        (*var).second.get(vals, first, last);
+    }
+    
+    template <class T>
+    void get(const string& name, vector<T>& vals)
+    {
+    
+        map<string, NetVariable>::iterator var = variables_.find(name);
+        if ( var == variables_.end() ) throw NoSuchNetcdfVariable(name);
+        (*var).second.get(vals);
+    }
+    
+    int getDimension(const string& name)
+    {
+        NcDim* dim = file_.get_dim(name.c_str());
+        return dim->size();
+    }
+
+    template <class T>
+    T getVariableAttribute(const string& name, const string& attr, T def)
+    {
+        map<string, NetVariable>::iterator var = variables_.find(name);
+        if ( var == variables_.end() ) throw NoSuchNetcdfVariable(name);
+        return (*var).second.getAttribute(attr, def);
+    }      
+    template <class T>
+    T getAttribute(const string& name, T def)
+    {
+    	  T val;
+    	  map<string, NetAttribute>::iterator attr = attributes_.find(name);
+    	  if ( attr == attributes_.end() ) return def;
+    	        (*attr).second.get(val);
+    	        return val;
+
+     }
+     NetVariable getVariable(const string& name)
+     {
+		map<string, NetVariable>::iterator var = variables_.find(name);
+         	if ( var == variables_.end() ) throw NoSuchNetcdfVariable(name);
+	 	return (*var).second;
+     }
+     
+     map<string, NetAttribute> getAttributes()
+     {
+		return attributes_;
+     }
+	 
+      		 
+	 
+	 
+protected:
+	virtual void print(ostream&) const; 
+	map<string, NetVariable> variables_;
+	map<string, NetVariable> dataset_;
+	map<string, NetAttribute> attributes_;
+     
+private:
+	NcFile    file_;
+
+	friend ostream& operator<<(ostream& s,const Netcdf& p)
+		{ p.print(s); return s; }
+};
+
+
+template <class From, class To> 
+class DataAccessor
+{
+public:
+    DataAccessor(Netcdf& netcdf) : netcdf_(netcdf) {}
+    void operator()(const string& name, vector<To>& to)
+    {
+        vector<From> from;
+        netcdf_.get(name, from, start_, end_);
+        int i = 0;
+        for (typename vector<From>::const_iterator val = from.begin(); val != from.end(); ++val) {
+            To add = To(*val);
+         
+            to.push_back(To(*val));
+        }
+    }
+    
+   void setDimension(const string& name, long from, long dim) {
+        start_.insert(std::make_pair(name, from));
+        end_.insert(std::make_pair(name, dim));
+   }
+   
+   void setDimension(const string& name, long val) {
+        start_.insert(std::make_pair(name, val));
+        end_.insert(std::make_pair(name, 1));
+   }
+    
+   map<string, long> start_;
+   map<string, long> end_;
+   Netcdf& netcdf_;
+};
+
+template <class T> 
+void Accessor<T>::access(vector<T>& data, vector<long> start, vector<long> edges, NetVariable& var) 
+{
+	typename map<NcType, Accessor<T>*>::const_iterator accessor = accessors_->find(var.id_->type());
+	if ( accessor == accessors_->end() ) throw new MagicsException("No accessor available");
+
+	(*(*accessor).second)(data, start, edges, var);
+}
+
+} // Namespace Magics
+
+
+
+
+#endif
diff --git a/src/decoders/NetcdfConvention.cc b/src/decoders/NetcdfConvention.cc
new file mode 100644
index 0000000..a213713
--- /dev/null
+++ b/src/decoders/NetcdfConvention.cc
@@ -0,0 +1,51 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfConvention.cc
+    \brief Implementation of the Template class NetcdfConvention.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "NetcdfConvention.h"
+
+using namespace magics;
+
+NetcdfConvention::NetcdfConvention() 
+{
+}
+
+
+NetcdfConvention::~NetcdfConvention() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfConvention::print(ostream& out)  const
+{
+	out << "NetcdfConvention[";
+	out << "]";
+}
+
diff --git a/src/decoders/NetcdfConvention.h b/src/decoders/NetcdfConvention.h
new file mode 100644
index 0000000..48d9637
--- /dev/null
+++ b/src/decoders/NetcdfConvention.h
@@ -0,0 +1,85 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfConvention.h
+    \brief Definition of the Template class NetcdfConvention.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfConvention_H
+#define NetcdfConvention_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+namespace magics {
+
+class XmlNode; 
+
+class NetcdfConvention  {
+
+public:
+	NetcdfConvention();
+	virtual ~NetcdfConvention();
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual bool accept(const string&) { return false; }
+    virtual NetcdfConvention* clone() { return new NetcdfConvention(); }
+    void toxml(ostream&, int)  const {}
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfConvention(const NetcdfConvention&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfConvention& operator=(const NetcdfConvention&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfConvention& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, NetcdfConvention> { 
+public:
+	NetcdfConvention* operator()(const string& val ) {
+		 return SimpleObjectMaker<NetcdfConvention>::create(val);
+	}     
+    NetcdfConvention* magics(const string& param)
+    {
+        NetcdfConvention* object;
+		ParameterManager::update(param, object);
+		return object;
+    }
+};
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfDecoder.cc b/src/decoders/NetcdfDecoder.cc
new file mode 100644
index 0000000..3d282ad
--- /dev/null
+++ b/src/decoders/NetcdfDecoder.cc
@@ -0,0 +1,149 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfDecoder.h
+    \brief Implementation of the Template class NetcdfDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "NetcdfDecoder.h"
+#include "Factory.h"
+#include "Transformation.h"
+#include "MagnifierVisitor.h"
+
+using namespace magics;
+
+
+NetcdfDecoder::NetcdfDecoder(): data_(0)
+{
+	setInfo("MV_Format","NetCDF");
+}
+
+
+NetcdfDecoder::~NetcdfDecoder()
+{
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void NetcdfDecoder::print(ostream& out)  const
+{
+	out << "NetcdfDecoder[";
+	NetcdfDecoderAttributes::print(out);
+	out << "]";
+}
+
+void NetcdfDecoder::visit(MagnifierVisitor& magnify)
+{
+	try {
+	vector<PaperPoint> thin;
+	vector<PaperPoint> all;
+	const Transformation& transformation = magnify.transformation();
+	
+	
+	transformation.thin(matrix(), thin, all);
+	
+	for (vector<PaperPoint>::iterator point = thin.begin(); point != thin.end(); ++point) {
+		 magnify.add(*point);
+	}
+	for (vector<PaperPoint>::iterator point = all.begin(); point != all.end(); ++point) {
+			 magnify.addMore(*point);
+	}
+	}
+	catch (...) {}
+	
+		 
+	
+	 
+}
+
+void NetcdfDecoder::visit(MetaDataCollector& mdc)
+{
+	bool interpretorCalled=false;
+	for(map<string, string>::iterator key = mdc.begin(); key != mdc.end(); ++key )
+	{	    
+		if(information_.find(key->first) == information_.end() && !interpretorCalled)
+		{
+			 MetaDataCollector mdcInt;
+			 (*interpretor_).visit(mdcInt);
+			 for(map<string, string>::iterator keyInt = mdcInt.begin(); keyInt != mdcInt.end(); ++keyInt )
+			 {	
+				setInfo(keyInt->first,keyInt->second);
+			 }
+			 interpretorCalled=true;
+		}
+	}
+	
+	for(map<string, string>::iterator key = mdc.begin(); key != mdc.end(); ++key )
+	{	
+		if(information_.find(key->first) == information_.end() &&
+		   mdc.attribute(key->first).group() == MetaDataAttribute::StatsGroup)
+		{
+			  (*interpretor_).statsData(stats_);
+			  computeStats();
+			  break;
+		}
+	}
+	
+	MetviewIcon::visit(mdc);  	
+}
+
+void NetcdfDecoder::visit(ValuesCollector& values)
+{
+	(*interpretor_).visit(values,points_);
+}
+
+
+void NetcdfDecoder::visit(TextVisitor& text)
+{
+	(*interpretor_).visit(text);
+
+}
+
+PointsHandler&  NetcdfDecoder::points(const Transformation& transformation, bool all)
+{
+	  PointsList points;
+	  (*interpretor_).interpretAsPoints(points, transformation);
+
+	  for ( PointsList::iterator point = points.begin(); point != points.end(); ++point ) {
+		  	  stack<UserPoint> pts;
+		  	  transformation.wraparound(**point, pts);
+		  	  while ( pts.empty() == false ) {
+		  		UserPoint pt = pts.top();
+		  		pts.pop();
+		  		if ( pt.missing() == false || ( pt.missing() && all) )
+		  			points_.push_back(new UserPoint(pt));
+		  	}
+
+	  }
+
+	  this->pointsHandlers_.push_back(new PointsHandler(points_));
+	  return *(this->pointsHandlers_.back());
+
+}
diff --git a/src/decoders/NetcdfDecoder.h b/src/decoders/NetcdfDecoder.h
new file mode 100644
index 0000000..7b1bd15
--- /dev/null
+++ b/src/decoders/NetcdfDecoder.h
@@ -0,0 +1,186 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfDecoder.h
+    \brief Definition of the Template class NetcdfDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfDecoder_H
+#define NetcdfDecoder_H
+
+#include "magics.h"
+#include "AnimationRules.h"
+
+#include "Decoder.h"
+#include "NetcdfDecoderAttributes.h"
+#include "UserPoint.h"
+#include "Data.h"
+#include "PointsHandler.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+
+
+namespace magics {
+
+class Transformation;
+
+
+class NetcdfDecoder: public Decoder,
+                     public Data,
+                     public NetcdfDecoderAttributes
+{
+
+public:
+	NetcdfDecoder();
+	virtual ~NetcdfDecoder();
+    
+    void decode() {}
+    // implements BaseSceneObject interface
+    virtual void set(const map<string, string>& params) { NetcdfDecoderAttributes::set(params); }
+    virtual void set(const XmlNode& node) { NetcdfDecoderAttributes::set(node); }
+    virtual void visit(MagnifierVisitor&); 
+    
+    virtual PointsHandler& points(const Transformation&, bool);
+
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+       {
+       	customisedPoints(t, n, out);
+       }
+
+    void getReady(const Transformation& transformation)
+    {
+    	(*interpretor_).getReady(transformation);
+    }
+
+    void visit(Transformation& transformation) {
+    	 (*interpretor_).visit(transformation);    
+    }
+    
+    MatrixHandler& matrix() {
+        MagLog::dev() << "NetcdfDecoder::matrix! " << "\n";
+        (*interpretor_).interpretAsMatrix(&data_); 
+        this->matrixHandlers_.push_back(new MatrixHandler(*data_));
+        return *(this->matrixHandlers_.back());
+    } 
+    
+    void customisedPoints(const std::set<string>& request, CustomisedPointsList& out) {
+    	(*interpretor_).customisedPoints(request, out); 
+    }
+    void customisedPoints(const Transformation& transformation, const std::set<string>& request, CustomisedPointsList& out) {
+       	(*interpretor_).customisedPoints(transformation, request, out); 
+       }
+    
+    void visit(AnimationStep& step) {
+    	   try {
+    		   MatrixHandler& data = matrix() ;
+    		   // Information about contains...
+    		   	MagLog::dev() << "Netcdf::visit(AnimationRules&) --> " << endl;
+    		   	
+    		
+    		   	step.xResolution(abs(data.XResolution()));
+    		   	step.yResolution(abs(data.YResolution()));
+    	         }
+    	   catch (...)
+    	   {
+    		   
+    	   }
+    	   
+    	        
+    	         
+    	
+    }
+    void visit(MetaDataCollector&);
+    void visit(ValuesCollector&);
+    void visit(TextVisitor&);
+    
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 
+	 PointsList points_;
+	 Matrix*     data_;
+
+private:
+	//! Copy constructor - No copy allowed
+	NetcdfDecoder(const NetcdfDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	NetcdfDecoder& operator=(const NetcdfDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfDecoder& p)
+		{ p.print(s); return s; }
+};
+
+
+class NetcdfLoop : public DataLoop
+{
+public:
+	NetcdfLoop(NetcdfDecoder* netcdf): netcdf_(netcdf) {}
+	virtual ~NetcdfLoop() {}
+	void set(const map<string, string>& map) { } // NetcdfLoopAttributes::set(map); }
+	void set(const XmlNode& node) { } // NetcdfLoopAttributes::set(node); }
+	
+    void set(NetcdfDecoder* netcdf) { netcdf_ = netcdf; }
+	
+	Data* current() {
+		NetcdfDecoder* current = netcdf_;
+		netcdf_ = 0;
+		return current;
+	}
+	bool         hasMore() {
+		return (netcdf_ != 0);
+	}
+	void         next() { netcdf_ = 0; }
+	
+
+   void visit(Transformation& transformation) { if ( netcdf_ ) netcdf_->visit(transformation); }
+	
+
+protected:
+	virtual void print(ostream&) const {}
+	NetcdfDecoder* netcdf_;
+	
+	
+	
+	
+private:
+	//! Copy constructor - No copy allowed
+	NetcdfLoop(const NetcdfLoop&);
+	//! Overloaded << operator to copy - No copy allowed
+	NetcdfLoop& operator=(const NetcdfLoop&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfLoop& p)
+		{ p.print(s); return s; }
+	
+};
+
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfDecoderAttributes.h b/src/decoders/NetcdfDecoderAttributes.h
new file mode 100644
index 0000000..b10a6d4
--- /dev/null
+++ b/src/decoders/NetcdfDecoderAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfDecoderAttributes.h
+    \brief Definition of NetcdfDecoder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfDecoderAttributes_H
+#define NetcdfDecoderAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "NetcdfInterpretor.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfDecoderAttributes 
+{
+public:
+//  --  constructor
+    NetcdfDecoderAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfDecoderAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfDecoderAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<NetcdfInterpretor> interpretor_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfDecoderAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfGeoMatrixInterpretor.cc b/src/decoders/NetcdfGeoMatrixInterpretor.cc
new file mode 100644
index 0000000..ed292eb
--- /dev/null
+++ b/src/decoders/NetcdfGeoMatrixInterpretor.cc
@@ -0,0 +1,211 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfGeoMatrixInterpretor.cc
+    \brief Implementation of the Template class NetcdfGeoMatrixInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "NetcdfGeoMatrixInterpretor.h"
+#include "Factory.h"
+#include "Netcdf.h"
+#include <limits>
+#include "Layer.h"
+
+using namespace magics;
+
+NetcdfGeoMatrixInterpretor::NetcdfGeoMatrixInterpretor() 
+{}
+
+
+NetcdfGeoMatrixInterpretor::~NetcdfGeoMatrixInterpretor() 
+{}
+
+
+
+void NetcdfGeoMatrixInterpretor::interpretAsMatrix(Matrix** data)
+{
+	if ( *data ) return;
+	
+	matrix_ = new Matrix();
+	matrix_->akimaEnabled();
+	*data = matrix_;
+
+   
+	Netcdf netcdf(path_);
+	double missing_value = missing(netcdf);
+
+	// get the data ...
+	try
+	{
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+
+		netcdf.get(longitude_, matrix_->columnsAxis(), first, last);
+		netcdf.get(latitude_, matrix_->rowsAxis(), first, last);
+		
+
+
+		matrix_->missing(missing_value);
+
+		if  ( magCompare(primary_index_, "latitude") ) {
+			// WE reserve the matrix_ since we are used to lat/lon matrix_!
+			vector<double> data;
+			netcdf.get(field_, data, first, last);
+			int columns =  matrix_->columnsAxis().size();
+			int rows =  matrix_->rowsAxis().size();
+ 
+		    for (int lon = 0; lon < columns; lon++)
+			     for (int lat = 0; lat < rows; lat++) {
+			    	matrix_->push_back(data[lon + lat*rows]);
+			     }
+		}
+		else 	{
+			vector<double> data;	
+			netcdf.get(field_, data, first, last);
+			int i = 0;
+			for (vector<double>::iterator d = data.begin(); d != data.end(); ++d ) {
+				if ( !isnan(*d) ) {
+					matrix_->push_back(*d);
+				}
+				else 
+					matrix_->push_back(missing_value);
+			   i++;
+			}
+		}
+
+
+		matrix_->multiply(scaling_);
+		matrix_->plus(offset_);
+        
+
+        
+	        matrix_->setMapsAxis();
+        
+
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+/*
+ Class information are given to the output-stream.
+*/		
+void NetcdfGeoMatrixInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfGeoMatrixInterpretor[";
+	NetcdfInterpretor::print(out);
+	NetcdfGeoMatrixInterpretorAttributes::print(out);
+	out << "]";
+}
+
+void NetcdfGeoMatrixInterpretor::interpretAsPoints(PointsList& list)
+{
+	Netcdf netcdf(path_);
+	
+	// get the data ...
+	try
+	{
+		vector<double> latitudes;
+		vector<double> longitudes;
+		vector<double> values;
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+		double missing_value = missing(netcdf);
+		
+		netcdf.get(field_, values, first, last);
+		netcdf.get(longitude_, longitudes, first, last);
+		netcdf.get(latitude_, latitudes, first, last);
+		unsigned int val = 0;
+		
+		for (unsigned int  lat  =0 ; lat < latitudes.size(); lat+=latitude_sample_) {
+			for ( unsigned int lon = 0; lon < longitudes.size(); lon+=longitude_sample_) {
+				val = (lat* longitudes.size() + lon);
+				if (val >= values.size() ) return;
+				if ( values[val] < suppress_below_ ) continue;
+				if ( values[val] > suppress_above_ ) continue;
+				if ( same(values[val], missing_value ) ) continue;
+				list.push_back(new UserPoint(longitudes[lon],latitudes[lat],values[val]));
+			}
+		}
+ 		MagLog::dev()<< "everything ok" << endl;
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void NetcdfGeoMatrixInterpretor::statsData(map<string,vector<double> >& stats)
+{
+	if(matrix_)
+	{
+	  	for(unsigned int i=0; i < matrix_->size(); i++)
+		{  
+			if(matrix_->at(i) != matrix_->missing())
+			{
+			  	stats["value"].push_back(matrix_->at(i));
+			}
+		}
+	}	
+}
+
+void NetcdfGeoMatrixInterpretor::visit(MetaDataCollector& mdc)
+{
+	mdc["_datatype"]="NetCDF_geomatrix";
+	mdc["path"]=path_;
+	mdc["latitude"]=latitude_;
+	mdc["longitude"]=longitude_;
+	mdc["value"]=field_;	
+	mdc["statsType"]="scalar";
+	
+	Netcdf nc(path_);
+	
+	string attrKey;
+	string attrVal;		
+
+	//Value attributes
+	getAttributes(nc,field_,attrKey,attrVal);		
+	if(!attrKey.empty())
+	{
+		mdc["valueAttrKey"]=attrKey;
+		mdc["valueAttrValue"]=attrVal;
+	}
+}
+
+void NetcdfGeoMatrixInterpretor::visit(ValuesCollector& vcp,PointsList&)
+{	
+	vcp.setCollected(true);
+	
+  	assert(matrix_); 
+  	const Transformation& transformation = vcp.transformation();
+  	MatrixHandler* box =  transformation.prepareData(*matrix_);
+	for (ValuesCollector::iterator point =  vcp.begin(); point != vcp.end(); ++point) {
+		point->push_back(new ValuesCollectorData(point->x(),point->y(),box->nearest(point->y(), point->x()),-1.));
+	}
+}
+
+
diff --git a/src/decoders/NetcdfGeoMatrixInterpretor.h b/src/decoders/NetcdfGeoMatrixInterpretor.h
new file mode 100644
index 0000000..8fe90d6
--- /dev/null
+++ b/src/decoders/NetcdfGeoMatrixInterpretor.h
@@ -0,0 +1,97 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfGeoMatrixInterpretor.h
+    \brief Definition of the Template class NetcdfGeoMatrixInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfGeoMatrixInterpretor_H
+#define NetcdfGeoMatrixInterpretor_H
+
+#include "magics.h"
+
+#include "NetcdfGeoMatrixInterpretorAttributes.h"
+#include "NetcdfInterpretor.h"
+#include "Matrix.h"
+#include "XmlNode.h"
+
+
+namespace magics {
+
+class NetcdfGeoMatrixInterpretor: public NetcdfGeoMatrixInterpretorAttributes, public NetcdfInterpretor {
+
+public:
+	NetcdfGeoMatrixInterpretor();
+	virtual ~NetcdfGeoMatrixInterpretor();
+    
+    void set(const map<string, string>& params) { 
+        MagLog::debug() << "NetcdfGeoMatrixInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfGeoMatrixInterpretorAttributes::set(params);
+    }
+    void set(const XmlNode& node) { 
+        MagLog::debug() << "NetcdfGeoMatrixInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(node); 
+        XmlNode netcdf = node;
+        netcdf.name("netcdf");
+        NetcdfInterpretorAttributes::set(netcdf); 
+        NetcdfGeoMatrixInterpretorAttributes::set(node);
+    }
+	virtual NetcdfInterpretor* clone() const {
+    	NetcdfGeoMatrixInterpretor* object = new NetcdfGeoMatrixInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+    void clone(const NetcdfGeoMatrixInterpretor& other) {
+    	NetcdfInterpretorAttributes::copy(other); 
+    	NetcdfGeoMatrixInterpretorAttributes::copy(other); 
+    }
+    virtual void interpretAsMatrix(Matrix**);
+    void interpretAsPoints(PointsList&);
+
+    virtual void statsData(map<string,vector<double> >&);
+    virtual void visit(MetaDataCollector&);
+    virtual void visit(ValuesCollector&,PointsList&); 
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 Matrix* matrix_;
+    
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfGeoMatrixInterpretor(const NetcdfGeoMatrixInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfGeoMatrixInterpretor& operator=(const NetcdfGeoMatrixInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfGeoMatrixInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfGeoMatrixInterpretorAttributes.h b/src/decoders/NetcdfGeoMatrixInterpretorAttributes.h
new file mode 100644
index 0000000..91afa17
--- /dev/null
+++ b/src/decoders/NetcdfGeoMatrixInterpretorAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfGeoMatrixInterpretorAttributes.h
+    \brief Definition of NetcdfGeoMatrixInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfGeoMatrixInterpretorAttributes_H
+#define NetcdfGeoMatrixInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfGeoMatrixInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfGeoMatrixInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfGeoMatrixInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfGeoMatrixInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string latitude_;
+	string longitude_;
+	int longitude_sample_;
+	int latitude_sample_;
+	string primary_index_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfGeoMatrixInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfGeoPolarMatrixInterpretorAttributes.h b/src/decoders/NetcdfGeoPolarMatrixInterpretorAttributes.h
new file mode 100644
index 0000000..2e54eee
--- /dev/null
+++ b/src/decoders/NetcdfGeoPolarMatrixInterpretorAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfGeoPolarMatrixInterpretorAttributes.h
+    \brief Definition of NetcdfGeoPolarMatrixInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfGeoPolarMatrixInterpretorAttributes_H
+#define NetcdfGeoPolarMatrixInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfGeoPolarMatrixInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfGeoPolarMatrixInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfGeoPolarMatrixInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfGeoPolarMatrixInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string speed_;
+	string direction_;
+	string latitude_;
+	string longitude_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfGeoPolarMatrixInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfGeoVectorInterpretorAttributes.h b/src/decoders/NetcdfGeoVectorInterpretorAttributes.h
new file mode 100644
index 0000000..56f0232
--- /dev/null
+++ b/src/decoders/NetcdfGeoVectorInterpretorAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfGeoVectorInterpretorAttributes.h
+    \brief Definition of NetcdfGeoVectorInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfGeoVectorInterpretorAttributes_H
+#define NetcdfGeoVectorInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfGeoVectorInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfGeoVectorInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfGeoVectorInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfGeoVectorInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string x_component_;
+	string y_component_;
+	string latitude_;
+	string longitude_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfGeoVectorInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfGeopointsInterpretor.cc b/src/decoders/NetcdfGeopointsInterpretor.cc
new file mode 100644
index 0000000..708e201
--- /dev/null
+++ b/src/decoders/NetcdfGeopointsInterpretor.cc
@@ -0,0 +1,556 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfGeopointsInterpretor.cc
+    \brief Implementation of the Template class NetcdfGeopointsInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "NetcdfGeopointsInterpretor.h"
+#include "Factory.h"
+#include "Netcdf.h"
+#include <limits>
+#include "Layer.h"
+#include "SciMethods.h"
+
+using namespace magics;
+
+NetcdfGeopointsInterpretor::NetcdfGeopointsInterpretor() 
+{}
+
+
+NetcdfGeopointsInterpretor::~NetcdfGeopointsInterpretor() 
+{}
+
+
+
+static void setDim(Netcdf& netcdf, const string& name, vector<double>& values, map<string, string>& first, map<string, string>& last)
+{
+    try {
+       netcdf.get(name, values, first, last); 
+    }
+    catch (...) {
+        int dim = netcdf.getDimension(name);
+        for (int i =0; i < dim; ++i) 
+            values.push_back(i);
+    }
+}
+
+
+void NetcdfGeopointsInterpretor::interpretAsPoints(PointsList& list, const Transformation& projection) {
+    Netcdf netcdf(path_);
+	
+	// get the data ...
+	try
+	{
+		vector<double> latitudes;
+		vector<double> longitudes;
+		vector<double> values;
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+		
+		netcdf.get(field_, values, first, last);
+		setDim(netcdf, longitude_, longitudes, first, last);
+		setDim(netcdf, latitude_, latitudes, first, last);
+		
+		vector<double>::iterator lat = latitudes.begin();
+		vector<double>::iterator lon = longitudes.begin();
+		vector<double>::const_iterator val = values.begin();
+		
+		//If the lat-lon units is specified as "radians" convert lat-lon 
+		//to degrees. By default the units are sipposed to be "degrees"
+		const char *units = 0;
+		if ( magCompare(netcdf.getVariableAttribute(latitude_,"units",units), "radians") )
+		{			
+			while ( lat!= latitudes.end()) {
+			  *lat=DEG(*lat);
+			  lat++;
+			}
+		}
+		
+		if ( magCompare(netcdf.getVariableAttribute(longitude_,"units",units), "radians") )
+		{			
+			while ( lon!= longitudes.end()) {
+			  *lon=DEG(*lon);
+			  lon++;
+			}  			
+		}		
+
+		lat = latitudes.begin();		
+		lon = longitudes.begin();
+		while ( lat != latitudes.end() && lon != longitudes.end() && val != values.end() ) {
+            UserPoint* geo = new UserPoint(*lon,*lat,*val);
+			list.push_back(geo);
+			lon++;
+			lat++;
+			val++;
+		}
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+void NetcdfGeopointsInterpretor::interpretAsPoints(PointsList& list)
+{
+	Netcdf netcdf(path_);
+	
+	// get the data ...
+	try
+	{
+		vector<double> latitudes;
+		vector<double> longitudes;
+		vector<double> values;
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+		
+		netcdf.get(field_, values, first, last);
+		setDim(netcdf, longitude_, longitudes, first, last);
+		setDim(netcdf, latitude_, latitudes, first, last);
+		
+		vector<double>::iterator lat = latitudes.begin();
+		vector<double>::iterator lon = longitudes.begin();
+		vector<double>::const_iterator val = values.begin();
+		
+		//If the lat-lon units is specified as "radians" convert lat-lon 
+		//to degrees. By default the units are sipposed to be "degrees"
+		const char *units = 0;
+		if ( magCompare(netcdf.getVariableAttribute(latitude_,"units",units), "radians") )
+		{
+			while ( lat!= latitudes.end()) {
+			  *lat=DEG(*lat);
+			  lat++;
+			}
+		}
+		
+		if ( magCompare(netcdf.getVariableAttribute(longitude_,"units",units), "radians") )
+		{			
+			while ( lon!= longitudes.end()) {
+			  *lon=DEG(*lon);
+			  lon++;
+			} 
+		}
+
+		lat = latitudes.begin();		
+		lon = longitudes.begin();
+		while ( lat != latitudes.end() && lon != longitudes.end() && val != values.end() ) {
+			list.push_back(new UserPoint(*lon,*lat,*val));
+			lon++;
+			lat++;
+			val++;
+		}
+	}    
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+void NetcdfGeopointsInterpretor::visit(MetaDataCollector& mdc)
+{
+  	mdc["_datatype"]="NetCDF_geopoints";
+	mdc["path"]=path_;
+	mdc["latitude"]=latitude_;
+	mdc["longitude"]=longitude_;
+	mdc["value"]=field_;	
+	mdc["statsType"]="scalar";		
+		
+	string attrKey;
+	string attrVal;		
+
+	Netcdf nc(path_);
+	//Value attributes
+	getAttributes(nc,field_,attrKey,attrVal);		
+	if(!attrKey.empty())
+	{
+		mdc["valueAttrKey"]=attrKey;
+		mdc["valueAttrValue"]=attrVal;
+	}
+}
+
+void NetcdfGeopointsInterpretor::visit(ValuesCollector& vcp,PointsList& points)
+{
+	if(field_.empty())
+	{
+	  	vcp.setHasValue(false);
+	}
+  
+  	vcp.setCollected(true);
+	
+	/*if(!matrix_ && stats_.find("value") == stats_.end())
+	{
+		points.setCollected(true);	
+	}
+	else
+	{  	
+		points.setCollected(true);
+	}*/
+	
+	
+	if(points.size() <=0)
+	   return;
+
+	for (ValuesCollector::iterator it =  vcp.begin(); it != vcp.end(); ++it)
+	{
+	  	double y=(*it).y();
+	  	double x=(*it).x();
+				
+		vector<int> idxV;				  
+		for(int i=0; i < static_cast<int>(points.size()); i++)
+		{		  
+		  	if(fabs(points.at(i)->x()-x) < vcp.searchRadiusX() &&
+			   fabs(points.at(i)->y()-y) < vcp.searchRadiusY())
+			{
+			  	idxV.push_back(i);
+			}
+		}
+		
+		if(idxV.size() ==0)
+			continue;  
+		
+		double dist=10000000.;
+		int minIdx=-1;
+		
+		for(int i=0; i < idxV.size(); i++)
+		{  			
+		  	int idx=idxV[i];
+			double d=magics::geoDistanceInKm(points.at(idx)->y(),points.at(idx)->x(),y,x);
+		
+			if(d < dist)
+			{
+			  	minIdx=idx;
+				dist=d;
+			}
+		}
+			
+		if(minIdx>=0)
+			(*it).push_back(new ValuesCollectorData(points.at(minIdx)->x(),
+							       points.at(minIdx)->y(),
+							       points.at(minIdx)->value(),
+							       dist));					     				
+	}
+}
+
+/*
+ Class information are given to the output-stream.
+*/		
+void NetcdfGeopointsInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfGeopointsInterpretor[";
+	NetcdfInterpretor::print(out);
+	out << "]";
+}
+
+NetcdfXYpointsInterpretor::NetcdfXYpointsInterpretor()
+{}
+
+
+NetcdfXYpointsInterpretor::~NetcdfXYpointsInterpretor()
+{}
+
+
+
+
+
+void NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list, const Transformation& projection) {
+    Netcdf netcdf(path_);
+
+	// get the data ...
+	try
+	{
+		vector<double> xs;
+		vector<double> ys;
+		vector<double> values;
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+
+		if (field_.empty() == false ) {
+					netcdf.get(field_, values, first, last);
+				}
+		setDim(netcdf, x_, xs, first, last);
+		setDim(netcdf, y_, ys, first, last);
+
+		vector<double>::iterator x = xs.begin();
+		vector<double>::iterator y = ys.begin();
+		vector<double>::const_iterator val = values.begin();
+
+		while ( x != xs.end() && y != ys.end()) {
+			double value = 0;
+			 if ( val != values.end() ) {
+				 value = *val;
+				 val++;
+			 }
+            UserPoint*  xy = new UserPoint(*x,*y,value);
+            if ( projection.in(*xy) )
+			    list.push_back(xy);
+			x++;
+			y++;
+		}
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+void NetcdfXYpointsInterpretor::interpretAsPoints(PointsList& list)
+{
+	Netcdf netcdf(path_);
+
+	// get the data ...
+	try
+	{
+		vector<double> ys;
+		vector<double> xs;
+		vector<double> values;
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+		if (field_.empty() == false ) {
+			netcdf.get(field_, values, first, last);
+		}
+		setDim(netcdf, x_, xs, first, last);
+		setDim(netcdf, y_, ys, first, last);
+
+		vector<double>::iterator y = ys.begin();
+		vector<double>::iterator x = xs.begin();
+		vector<double>::const_iterator val = values.begin();
+
+
+
+
+		while ( x != xs.end() && y != ys.end()  ) {
+			double value = 0;
+			if ( val != values.end() ) {
+			 	value = *val;
+			 	val++;
+			}
+			list.push_back(new UserPoint(*x,*y,value));
+			x++;
+			y++;
+
+		}
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+/*
+ Class information are given to the output-stream.
+*/
+void NetcdfXYpointsInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfGeopointsInterpretor[";
+	NetcdfInterpretor::print(out);
+	out << "]";
+}
+
+void NetcdfXYpointsInterpretor::visit(Transformation& transformation)
+{
+	// get the data ...
+
+
+	try {
+		PointsList points;
+		interpretAsPoints(points);
+
+		transformation.setMinX(points.minX());
+		transformation.setMaxX(points.maxX());
+		transformation.setMinY(points.minY());
+		transformation.setMaxY(points.maxY());
+	}
+	catch ( ... ) {}
+}
+
+void NetcdfXYpointsInterpretor::customisedPoints(const Transformation& transformation, const std::set<string>&, CustomisedPointsList& out)
+{
+	PointsList points;
+	interpretAsPoints(points);
+
+	for (PointsList::iterator point = points.begin(); point != points.end(); ++point)  {
+		CustomisedPoint* pt = new CustomisedPoint();
+		out.push_back(pt);
+		pt->insert(make_pair("x", (*point)->x()));
+		pt->insert(make_pair("y", (*point)->y()));
+	}
+
+}
+
+void NetcdfXYpointsInterpretor::visit(MetaDataCollector& mdc)
+{
+	bool isVprof=false;
+  
+  	Netcdf nc(path_);
+  	map<string, NetAttribute> attrs = nc.getAttributes();
+
+	//Find out if its vertical profile data
+	map<string, NetAttribute>::iterator attrIt=attrs.find("_VIEW");
+	if( attrIt !=  attrs.end())
+	{  
+	  	const char* val;	  
+	  	attrIt->second.get(val);
+	  	string str;
+	  	if(val) str=string(val);
+	  
+	 	if(str == "MVERTPROFVIEW")
+	  		isVprof=true;
+	}
+    
+  	if(!isVprof)
+	{  
+  		mdc["_datatype"]="NetCDF_xypoints";
+		mdc["path"]=path_;
+		mdc["x"]=x_;
+		mdc["y"]=y_;
+		mdc["value"]=field_;	
+		mdc["statsType"]="scalar";		
+		
+		string attrKey;
+		string attrVal;		
+
+		//Value attributes
+		getAttributes(nc,field_,attrKey,attrVal);		
+		if(!attrKey.empty())
+		{
+		  	mdc["valueAttrKey"]=attrKey;
+			mdc["valueAttrValue"]=attrVal;
+		}
+	}
+	else
+	{
+		mdc["_datatype"]="NetCDF_vprof";
+		mdc["description"]="Vertical profile";
+		mdc["path"]=path_;
+		mdc["x"]=x_;
+		mdc["y"]=y_;
+		
+		// Get the point's co-ordinates
+		try
+		{
+			vector<double> lat,lon;
+			nc.get("latitude", lat);
+			nc.get("longitude", lon);
+			
+			if(lat.size() == 1 && lon.size() == 1)
+			{
+				mdc["latitude"]=tostring(lat[0]);
+				mdc["longitude"]=tostring(lon[0]);
+			}
+		}
+		catch ( ... ) {}
+		
+		mdc["statsType"]="scalar";
+		
+		string attrKey;
+		string attrVal;		
+
+		//X attributes
+		getAttributes(nc,x_,attrKey,attrVal);		
+		if(!attrKey.empty())
+		{
+		  	mdc["xAttrKey"]=attrKey;
+			mdc["xAttrValue"]=attrVal;
+		}
+		
+		attrKey.clear();
+		attrVal.clear();
+		
+		//Y attributes
+		getAttributes(nc,y_,attrKey,attrVal);		
+		if(!attrKey.empty())
+		{
+		  	mdc["yAttrKey"]=attrKey;
+			mdc["yAttrValue"]=attrVal;
+		}
+		
+		
+		
+	}
+}
+
+void NetcdfXYpointsInterpretor::visit(ValuesCollector& vcp,PointsList& points)
+{
+	if(field_.empty())
+	{
+	  	vcp.setHasValue(false);
+	}
+  
+  	vcp.setCollected(true);
+	
+	/*if(!matrix_ && stats_.find("value") == stats_.end())
+	{
+		points.setCollected(true);	
+	}
+	else
+	{  	
+		points.setCollected(true);
+	}*/
+	
+	
+	if(points.size() <=0)
+	   return;
+
+	for (ValuesCollector::iterator it =  vcp.begin(); it != vcp.end(); ++it)
+	{
+	  	double y=(*it).y();
+	  	double x=(*it).x();
+				
+		vector<int> idxV;				  
+		for(int i=0; i < static_cast<int>(points.size()); i++)
+		{		  
+		  	if(fabs(points.at(i)->x()-x) < vcp.searchRadiusX() &&
+			   fabs(points.at(i)->y()-y) < vcp.searchRadiusY())
+			{
+			  	idxV.push_back(i);
+			}
+		}
+		
+		if(idxV.size() ==0)
+			continue;  
+		
+		double dist=10000000.;
+		int minIdx=-1;
+		
+		for(int i=0; i < idxV.size(); i++)
+		{  			
+		  	int idx=idxV[i];
+			double d=(points.at(idx)->x()-x)*(points.at(idx)->x()-x) +
+			        	 (points.at(idx)->y()-y)*(points.at(idx)->y()-y);
+			
+			if(d < dist)
+			{
+			  	minIdx=idx;
+				dist=d;
+			}
+		}
+			
+		if(minIdx>=0)
+			(*it).push_back(new ValuesCollectorData(points.at(minIdx)->x(),
+							       points.at(minIdx)->y(),
+							       points.at(minIdx)->value(),
+							       dist));
+					     				
+	}
+}
+
diff --git a/src/decoders/NetcdfGeopointsInterpretor.h b/src/decoders/NetcdfGeopointsInterpretor.h
new file mode 100644
index 0000000..34798e6
--- /dev/null
+++ b/src/decoders/NetcdfGeopointsInterpretor.h
@@ -0,0 +1,148 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfGeopointsInterpretor.h
+    \brief Definition of the Template class NetcdfGeopointsInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfGeopointsInterpretor_H
+#define NetcdfGeopointsInterpretor_H
+
+#include "magics.h"
+
+#include "NetcdfGeopointsInterpretorAttributes.h"
+#include "NetcdfXYpointsInterpretorAttributes.h"
+#include "NetcdfInterpretor.h"
+#include "Matrix.h"
+#include "XmlNode.h"
+namespace magics {
+
+class NetcdfGeopointsInterpretor: public NetcdfInterpretor, public NetcdfGeopointsInterpretorAttributes {
+
+public:
+	NetcdfGeopointsInterpretor();
+	virtual ~NetcdfGeopointsInterpretor();
+    
+    void set(const map<string, string>& params) { 
+        MagLog::debug() << "NetcdfGeopointsInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfGeopointsInterpretorAttributes::set(params);
+    }
+    void set(const XmlNode& node) { 
+        MagLog::debug() << "NetcdfGeopointsInterpretor::set(params)" << "\n";
+        XmlNode netcdf = node;
+        NetcdfGeopointsInterpretorAttributes::set(node);
+        netcdf.name("netcdf");
+        NetcdfInterpretorAttributes::set(netcdf); 
+
+    }
+	virtual NetcdfInterpretor* clone() const {
+    	NetcdfGeopointsInterpretor* object = new NetcdfGeopointsInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+    void clone(const NetcdfGeopointsInterpretor& other) {
+    	NetcdfInterpretorAttributes::copy(other); 
+    	NetcdfGeopointsInterpretorAttributes::copy(other); 
+    }
+    virtual void interpretAsPoints(PointsList&);
+    virtual void interpretAsPoints(PointsList&, const Transformation&);
+    virtual void interpretAsMatrix(Matrix**) { throw MagicsException("Not Yet"); }
+    virtual void visit(MetaDataCollector&);
+    virtual void visit(ValuesCollector&,PointsList&);
+    
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+    
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfGeopointsInterpretor(const NetcdfGeopointsInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfGeopointsInterpretor& operator=(const NetcdfGeopointsInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfGeopointsInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+class NetcdfXYpointsInterpretor: public NetcdfInterpretor, public NetcdfXYpointsInterpretorAttributes {
+
+public:
+	NetcdfXYpointsInterpretor();
+	virtual ~NetcdfXYpointsInterpretor();
+
+    void set(const map<string, string>& params) {
+        MagLog::debug() << "NetcdfGeopointsInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params);
+        NetcdfXYpointsInterpretorAttributes::set(params);
+    }
+    void set(const XmlNode& node) {
+        MagLog::debug() << "NetcdfGeopointsInterpretor::set(params)" << "\n";
+        XmlNode netcdf = node;
+        NetcdfXYpointsInterpretorAttributes::set(node);
+        netcdf.name("netcdf");
+        NetcdfInterpretorAttributes::set(netcdf);
+
+    }
+	virtual NetcdfInterpretor* clone() const {
+    	NetcdfXYpointsInterpretor* object = new NetcdfXYpointsInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+    void clone(const NetcdfXYpointsInterpretor& other) {
+    	NetcdfInterpretorAttributes::copy(other);
+    	NetcdfXYpointsInterpretorAttributes::copy(other);
+    }
+    virtual void interpretAsPoints(PointsList&);
+    virtual void interpretAsPoints(PointsList&, const Transformation&);
+    virtual void interpretAsMatrix(Matrix**) { throw MagicsException("Not Yet"); }
+    virtual void visit(Transformation&);
+    virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+    virtual void visit(MetaDataCollector&);
+    virtual void visit(ValuesCollector&,PointsList&);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfXYpointsInterpretor(const NetcdfXYpointsInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfXYpointsInterpretor& operator=(const NetcdfXYpointsInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfXYpointsInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfGeopointsInterpretorAttributes.h b/src/decoders/NetcdfGeopointsInterpretorAttributes.h
new file mode 100644
index 0000000..27b9011
--- /dev/null
+++ b/src/decoders/NetcdfGeopointsInterpretorAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfGeopointsInterpretorAttributes.h
+    \brief Definition of NetcdfGeopointsInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfGeopointsInterpretorAttributes_H
+#define NetcdfGeopointsInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfGeopointsInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfGeopointsInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfGeopointsInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfGeopointsInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string latitude_;
+	string longitude_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfGeopointsInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfInterpretor.cc b/src/decoders/NetcdfInterpretor.cc
new file mode 100644
index 0000000..f0f671d
--- /dev/null
+++ b/src/decoders/NetcdfInterpretor.cc
@@ -0,0 +1,121 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfInterpretor.cc
+    \brief Implementation of the Template class NetcdfInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "NetcdfInterpretor.h"
+#include "Netcdf.h"
+#include <limits>
+
+using namespace magics;
+
+NetcdfInterpretor::NetcdfInterpretor() 
+{
+}
+
+void NetcdfInterpretor::setDimensions(const stringarray& value, map<string, string>& first, map<string, string>& last)
+{
+    first.clear();
+    last.clear();
+ 
+    Tokenizer tokenizer("/ ");
+    vector<string> tokens;
+    for (stringarray::const_iterator val = value.begin(); val != value.end(); ++val) {
+        tokens.clear();
+        tokenizer(*val, tokens);
+        
+        switch (tokens.size()) 
+        {
+            case 2 : // param/from/from
+                first[tokens[0]] = tokens[1];
+                last[tokens[0]] =  tokens[1];
+                break;
+            case 3 : // param/from/to
+                first[tokens[0]] =  tokens[1];
+                last[tokens[0]] = tokens[2];
+                break;
+            case 1  : // param = all    
+    			break;
+            default : 
+                throw MagicsException( "Syntax not Valid!:" + *val);
+        }
+          
+    }
+    MagLog::debug() << "NetcdfInterpretor::setDimensions---> OK!" << "\n";
+}
+NetcdfInterpretor::~NetcdfInterpretor() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfInterpretor[";
+    NetcdfInterpretorAttributes::print(out);
+	out << "]";
+}
+/*
+ * return the missing value
+ */
+double NetcdfInterpretor::missing(Netcdf& netcdf) const
+{
+	double missing = netcdf.getAttribute(missing_attribute_, std::numeric_limits<double>::max());
+	return missing;
+}
+
+void NetcdfInterpretor::getAttributes(Netcdf& nc,const string& varName,string& keys,string& values)
+{
+	try
+	{	
+		NetVariable var=nc.getVariable(varName);
+		bool first=true;
+		for(map<string, NetAttribute>::iterator it=var.attributes_.begin(); it != var.attributes_.end(); it++)
+		{
+			const char* val;
+			string str;
+			it->second.get(val);
+			if(val) str=string(val);
+		
+			if(!first)
+			{	
+			  	keys+="/";
+				values+="/";
+			}
+			first=false;
+		
+				keys+=it->first;
+				values+=val;		
+			}
+	}
+	catch ( ... ) {}
+}
+
+
diff --git a/src/decoders/NetcdfInterpretor.h b/src/decoders/NetcdfInterpretor.h
new file mode 100644
index 0000000..e5d6f75
--- /dev/null
+++ b/src/decoders/NetcdfInterpretor.h
@@ -0,0 +1,118 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfInterpretor.h
+    \brief Definition of the Template class NetcdfInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfInterpretor_H
+#define NetcdfInterpretor_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "UserPoint.h"
+#include "UserPoint.h"
+#include "MatrixHandler.h"
+#include "NetcdfInterpretorAttributes.h"
+#include "CustomisedPoint.h"
+
+namespace magics {
+
+class RasterData;
+
+class Netcdf;
+class NetcdfInterpretor: public NetcdfInterpretorAttributes {
+
+public:
+	NetcdfInterpretor();
+	virtual ~NetcdfInterpretor();
+	virtual void visit(Transformation&) {}
+	virtual void getReady(const Transformation&) {}
+    virtual void interpretAsMatrix(Matrix**)
+    	{ MagLog::dev() << "Method  NetcdfInterpretor::interpretAsMatrix() --> Not yet implemented.\n"; }
+    virtual void interpretAsVectors(Matrix**, Matrix**) 
+    	{ MagLog::dev() << "Method  NetcdfInterpretor::interpretAsVectors() --> Not yet implemented.\n"; }
+    virtual void interpretAsRaster(RasterData&)
+    	{ MagLog::dev() << "Method  NetcdfInterpretor::interpretAsRaster() --> Not yet implemented.\n"; }
+    virtual void interpretAsPoints(PointsList&)
+    	{ MagLog::dev() << "Method  NetcdfInterpretor::interpretAsPoints() --> Not yet implemented.\n"; }
+    virtual void customisedPoints(const std::set<string>&, CustomisedPointsList&)  
+        	{ MagLog::dev() << "Method  NetcdfInterpretor::customisedPoints() --> Not yet implemented.\n"; }
+    virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&)  
+            	{ MagLog::dev() << "Method  NetcdfInterpretor::customisedPoints() --> Not yet implemented.\n"; }
+
+    virtual void interpretAsPoints(PointsList& points, const Transformation&)
+    	{ interpretAsPoints(points);}
+    virtual void set(const map<string, string>& params) { NetcdfInterpretorAttributes::set(params); }
+    virtual void set(const XmlNode& node) { NetcdfInterpretorAttributes::set(node); }
+     virtual bool accept(const string& node) { return NetcdfInterpretorAttributes::accept(node); }
+    virtual NetcdfInterpretor* clone() const {
+    	NetcdfInterpretor* object = new NetcdfInterpretor();
+    	object->copy(*this);
+    	return object;
+    }
+    
+    virtual void statsData(map<string,vector<double> >&) {}
+    virtual void visit(MetaDataCollector&) {}
+    virtual void visit(ValuesCollector&,PointsList&) {};
+    virtual void visit(TextVisitor&) {}    
+    double missing(Netcdf&) const;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     void setDimensions(const stringarray&, map<string, string>& first, map<string, string>& last);
+     void getAttributes(Netcdf&,const string&,string&,string&);
+	
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfInterpretor(const NetcdfInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfInterpretor& operator=(const NetcdfInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfInterpretor& p)
+		{ p.print(s); return s; }
+};
+template<>
+class MagTranslator<string, NetcdfInterpretor> { 
+public:
+	NetcdfInterpretor* operator()(const string& val ) {
+		 return SimpleObjectMaker<NetcdfInterpretor>::create(val);
+	}
+
+	NetcdfInterpretor* magics(const string& param)
+	{
+		NetcdfInterpretor* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfInterpretorAttributes.h b/src/decoders/NetcdfInterpretorAttributes.h
new file mode 100644
index 0000000..11946c9
--- /dev/null
+++ b/src/decoders/NetcdfInterpretorAttributes.h
@@ -0,0 +1,89 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfInterpretorAttributes.h
+    \brief Definition of NetcdfInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfInterpretorAttributes_H
+#define NetcdfInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string path_;
+	stringarray dimension_;
+	string field_;
+	double scaling_;
+	double offset_;
+	string missing_attribute_;
+	string reference_;
+	double suppress_below_;
+	double suppress_above_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfMarsConvention.cc b/src/decoders/NetcdfMarsConvention.cc
new file mode 100644
index 0000000..fac8a74
--- /dev/null
+++ b/src/decoders/NetcdfMarsConvention.cc
@@ -0,0 +1,55 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfMarsConvention.cc
+    \brief Implementation of the Template class NetcdfMarsConvention.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "NetcdfMarsConvention.h"
+#include "Factory.h"
+
+using namespace magics;
+
+NetcdfMarsConvention::NetcdfMarsConvention() 
+{
+}
+
+
+NetcdfMarsConvention::~NetcdfMarsConvention() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfMarsConvention::print(ostream& out)  const
+{
+	out << "NetcdfMarsConvention[";
+	out << "]";
+}
+
+static SimpleObjectMaker<NetcdfMarsConvention, NetcdfConvention>  netcdf_mars_convention("mars");
diff --git a/src/decoders/NetcdfMarsConvention.h b/src/decoders/NetcdfMarsConvention.h
new file mode 100644
index 0000000..4ef87c2
--- /dev/null
+++ b/src/decoders/NetcdfMarsConvention.h
@@ -0,0 +1,63 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfMarsConvention.h
+    \brief Definition of the Template class NetcdfMarsConvention.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfMarsConvention_H
+#define NetcdfMarsConvention_H
+
+#include "magics.h"
+
+#include "NetcdfConvention.h"
+
+namespace magics {
+
+class NetcdfMarsConvention: public NetcdfConvention {
+
+public:
+	NetcdfMarsConvention();
+	virtual ~NetcdfMarsConvention();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfMarsConvention(const NetcdfMarsConvention&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfMarsConvention& operator=(const NetcdfMarsConvention&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfMarsConvention& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfMatrixInterpretor.cc b/src/decoders/NetcdfMatrixInterpretor.cc
new file mode 100644
index 0000000..0149eb8
--- /dev/null
+++ b/src/decoders/NetcdfMatrixInterpretor.cc
@@ -0,0 +1,400 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfMatrixInterpretor.h
+    \brief Implementation of the Template class NetcdfMatrixInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include <limits>
+
+#include "NetcdfMatrixInterpretor.h"
+#include "Factory.h"
+#include "Netcdf.h"
+#include "Coordinate.h"
+#include "Layer.h"
+#include "TextVisitor.h"
+#include "Tokenizer.h"
+using namespace magics;
+
+NetcdfMatrixInterpretor::NetcdfMatrixInterpretor() : baseDateX_(""), baseDateY_("")
+{
+}
+
+
+NetcdfMatrixInterpretor::~NetcdfMatrixInterpretor() 
+{
+}
+
+
+void NetcdfMatrixInterpretor::interpretAsMatrix(Matrix** matrix)
+{
+	
+	MagLog::debug() << "NetcdfMatrixInterpretor::interpret()--->" << *this << "\n";
+	if ( *matrix ) return;
+	
+	matrix_ = new Matrix();
+	
+	*matrix = matrix_;
+	if ( !matrix_->empty() ) return;
+    
+	matrix_->missing(std::numeric_limits<double>::max());
+
+	Netcdf netcdf(path_);
+	string title = netcdf.getAttribute("title", "NO TITLE");
+
+
+    x();
+    y();
+	// get the data ...
+	try {
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+		MagLog::debug() << "matrix_" << matrix_->size() << "\n";
+        
+		netcdf.get(field_, *matrix_, first, last);
+		
+		MagLog::debug() << "matrix_[" << matrix_->size() << ", " << scaling_ << ", " << offset_ << "]" << "\n";
+
+		matrix_->multiply(scaling_);
+		matrix_->plus(offset_);
+        
+       
+        
+		MagLog::debug() << "matrix_[" << matrix_->size() << ", " << scaling_ << ", " << offset_ << "\n";
+        
+		
+		vector<double> col;
+	  
+		string missing = netcdf.getVariableAttribute(field_, missing_attribute_, "");
+		if ( !missing.empty() ) {
+			std::stringstream ss(missing);		
+			double m;
+			ss >> m;
+            matrix_->missing(m);
+		}
+		
+		
+		matrix_->setColumnsAxis(columns_);
+		matrix_->setRowsAxis(rows_);
+		
+    
+		MagLog::dev() << *matrix_ << "\n";
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}    
+}
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfMatrixInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfMatrixInterpretor[";
+	NetcdfInterpretor::print(out);
+	NetcdfMatrixInterpretorAttributes::print(out);
+	out << "]";
+}
+
+
+
+bool NetcdfMatrixInterpretor::reference_date(Netcdf& netcdf, const string& var, const string& refdate, string& basedate, vector<double>& coords)
+{
+	static map<string, double> factors;
+	if ( factors.empty() ) {
+		factors["hours"] = 3600;
+		factors["days"] = 24*3600;
+	}
+	string date = netcdf.getVariableAttribute(var, "reference_date", "");
+	if ( date.empty() ) return false;
+	string units = netcdf.getVariableAttribute(var, "units", "");
+	basedate = date;
+	double diff = ( refdate.empty() ) ? 0 : DateTime(date) - DateTime(refdate) ;
+	map<string, double>::const_iterator factor = factors.find(units);
+	if ( factor != factors.end() )
+		std::transform(coords.begin(), coords.end(),  coords.begin(), Multiply(factor->second, std::numeric_limits<double>::max()));
+	std::transform(coords.begin(), coords.end(),  coords.begin(), Plus(diff, std::numeric_limits<double>::max()));
+}
+
+bool NetcdfMatrixInterpretor::cf_date(Netcdf& netcdf, const string& var, const string& refdate, string& basedate, vector<double>& coords)
+{
+	//Step 1 : try to find a attribute long_name = time
+	//Step 2 : Parse the attribute  units : days since date
+	static map<string, double> factors;
+	if ( factors.empty() ) {
+		factors["hours"] = 3600;
+		factors["days"] = 24*3600;
+	}
+	string date = netcdf.getVariableAttribute(var, "long_name", "");
+	if ( date.empty() ) return false;
+	if ( date != "time" ) return false;
+
+	string units = netcdf.getVariableAttribute(var, "units", "");
+	if ( units.empty() ) return false;
+
+	// Now we parse the string !
+	vector<string> tokens;
+	Tokenizer tokenizer(" ");
+	tokenizer(units, tokens);
+
+
+
+	basedate = tokens[2];
+	double diff = ( refdate.empty() ) ? 0 : DateTime(basedate) - DateTime(refdate) ;
+	map<string, double>::const_iterator factor = factors.find(tokens[0]);
+	if ( factor != factors.end() )
+		std::transform(coords.begin(), coords.end(),  coords.begin(), Multiply(factor->second, std::numeric_limits<double>::max()));
+	std::transform(coords.begin(), coords.end(),  coords.begin(), Plus(diff, std::numeric_limits<double>::max()));
+}
+	
+void NetcdfMatrixInterpretor::x()
+{
+	if ( !columns_.empty() )
+			return;
+
+    Netcdf netcdf(path_);
+    map<string, string> first, last;
+    setDimensions(dimension_, first, last);
+
+    try {
+        netcdf.get(x_, columns_, first, last);
+        baseDateX_ = "";
+        if ( !reference_date(netcdf, x_, refDateX_, baseDateX_, columns_) )
+        	cf_date(netcdf, x_, refDateX_, baseDateX_, columns_);
+	} 
+    catch (...) {
+        int x = netcdf.getDimension(x_);
+        for (int i = 0; i < x; i++) 
+            columns_.push_back(i);
+    }
+
+    if ( aux_x_.empty() )
+    	return;
+    try {
+    	vector<double> aux;
+
+    	netcdf.get(aux_x_,aux, first, last);
+    	if ( !aux.empty() ) {
+    		ostringstream geominx, geomaxx;
+    		geominx << columns_.front() << "/" << aux.front() << endl;
+    		geomaxx << columns_.back() << "/" << aux.back() << endl;
+    		geoMinX_ = geominx.str();
+    		geoMaxX_ = geomaxx.str();
+    	}
+    }
+    catch (...) {
+    }
+
+}
+
+void NetcdfMatrixInterpretor::y()
+{
+
+	if ( !rows_.empty() )
+		return;
+
+    Netcdf netcdf(path_);
+    map<string, string> first, last;
+    setDimensions(dimension_, first, last);
+    try {
+    	 netcdf.get(y_, rows_, first, last);
+    	 baseDateY_ = "";
+    	 if ( !reference_date(netcdf, y_, refDateY_, baseDateY_, rows_) )
+    	      cf_date(netcdf, y_, refDateY_, baseDateY_, rows_);
+	} 
+    catch (...) {
+        int y = netcdf.getDimension(y_);
+        for (int i = 0; i < y; i++) 
+            rows_.push_back(i);
+    } 
+
+    if ( aux_y_.empty() )
+    	return;
+    try {
+    	vector<double> aux;
+    	netcdf.get(aux_y_,aux, first, last);
+    	if ( !aux.empty() ) {
+    		ostringstream geominx, geomaxx;
+    		geominx << rows_.front() << "/" << aux.front() << endl;
+    		geomaxx << rows_.back() << "/" << aux.back() << endl;
+    		geoMinY_ = geominx.str();
+    		geoMaxY_ = geomaxx.str();
+    	}
+    }
+    catch (...) {
+    }
+}
+void NetcdfMatrixInterpretor::getReady(const Transformation& transformation)
+{
+	// adjust the data to the transformation..
+
+	refDateX_ = ( !transformation.getAutomaticX() ) ? "" : transformation.getReferenceX();
+	columns_.clear();
+	x();
+	refDateY_ = ( !transformation.getAutomaticY() ) ? "" : transformation.getReferenceY();
+	rows_.clear();
+	y();
+
+}
+
+void NetcdfMatrixInterpretor::visit(Transformation& transformation)
+{
+	// get the data ...
+		// by default, respect the internal organisation of the data..
+		try {
+
+			refDateX_ = ( transformation.getAutomaticX() ) ? "" : transformation.getReferenceX();
+			x();
+			refDateY_ = ( transformation.getAutomaticY() ) ? "" : transformation.getReferenceY();
+			y();
+
+			if ( transformation.getAutomaticX() ) {
+				if ( !this->baseDateX_.empty() ) {
+					transformation.setDataMinX(columns_.front(), this->baseDateX_);
+					transformation.setDataMaxX(columns_.back(), this->baseDateX_);
+				}
+				else if ( !this->geoMinX_.empty() ) {
+					transformation.setDataMinX(columns_.front(), this->geoMinX_);
+					transformation.setDataMaxX(columns_.back(), this->geoMaxX_);
+				}
+				else
+				{
+					transformation.setMinX(columns_.front());
+					transformation.setMaxX(columns_.back());
+				}
+			}
+			if ( transformation.getAutomaticY() ) {
+				if ( !this->baseDateY_.empty() ) {
+					transformation.setDataMinY(rows_.front(), this->baseDateY_);
+					transformation.setDataMaxY(rows_.back(), this->baseDateY_);
+				}
+				else if ( !this->geoMinY_.empty() ) {
+					transformation.setDataMinY(rows_.front(), this->geoMinY_);
+					transformation.setDataMaxY(rows_.back(), this->geoMaxY_);
+				}
+				else {
+					transformation.setMinY(rows_.front());
+					transformation.setMaxY(rows_.back());
+				}
+			}
+
+		}
+		catch ( ... ) {}
+		
+
+}
+
+void NetcdfMatrixInterpretor::statsData(map<string,vector<double> >& stats)
+{
+	if(matrix_)
+	{
+	  	for(unsigned int i=0; i < matrix_->size(); i++)
+		{  
+			if(matrix_->at(i) != matrix_->missing())
+			{
+			  	stats["value"].push_back(matrix_->at(i));
+			}
+		}
+	}	
+}
+
+void NetcdfMatrixInterpretor::visit(MetaDataCollector& mdc)
+{
+	mdc["_datatype"]="NetCDF_matrix";
+	mdc["path"]=path_;
+	mdc["x"]=x_;
+	mdc["y"]=y_;
+	mdc["value"]=field_;	
+	mdc["statsType"]="scalar";
+	
+	Netcdf nc(path_);
+	
+	string attrKey;
+	string attrVal;		
+
+	//Value attributes
+	getAttributes(nc,field_,attrKey,attrVal);		
+	if(!attrKey.empty())
+	{
+		mdc["valueAttrKey"]=attrKey;
+		mdc["valueAttrValue"]=attrVal;
+	}
+}
+
+void NetcdfMatrixInterpretor::visit(ValuesCollector& vcp,PointsList&)
+{
+	vcp.setCollected(true);
+	
+	assert(matrix_); 
+		
+	const Transformation& transformation = vcp.transformation();
+  	MatrixHandler* box =  transformation.prepareData(*matrix_);
+	for (ValuesCollector::iterator point =  vcp.begin(); point != vcp.end(); ++point) {
+		point->push_back(new ValuesCollectorData(point->x(),point->y(),box->nearest(point->y(), point->x()),-1.));
+	}
+
+	//for (ValuesCollector::iterator point =  points.begin(); point != points.end(); ++point) {
+	//	point->push_back(new ValuesCollectorData(point->x(), point->y(),matrix_->nearest(point->y(), point->x()),-1.));
+	//}
+}
+
+void NetcdfMatrixInterpretor::visit(TextVisitor& title)
+{
+	vector<string> titles;
+
+	title.titles(titles);
+
+
+	for ( vector<string>::const_iterator t = titles.begin(); t != titles.end(); ++t ) {
+		MagLog::debug() << "NetcdfMatrixInterpretor::visit" << *t << endl;
+
+	}
+	Netcdf netcdf(path_);
+	title.addAutomaticTitle(netcdf.getAttribute("title", "NO TITLE"));
+}
+
+
+void NetcdfMatrixInterpretor::interpretAsPoints(PointsList& points, const Transformation& transformation)
+{
+	refDateX_ = transformation.getReferenceX();
+	refDateY_ = transformation.getReferenceY();
+
+	Matrix* data = 0;
+
+	interpretAsMatrix(&data);
+
+	vector<double>::iterator d = data->begin();
+	for (vector<double>::iterator row = rows_.begin(); row != rows_.end(); ++row)
+		for (vector<double>::iterator column = columns_.begin(); column != columns_.end(); ++column) {
+			UserPoint* point = new UserPoint(*column, *row, *d);
+			++d;
+			points.push_back(point);
+		}
+
+
+}
diff --git a/src/decoders/NetcdfMatrixInterpretor.h b/src/decoders/NetcdfMatrixInterpretor.h
new file mode 100644
index 0000000..cebdc56
--- /dev/null
+++ b/src/decoders/NetcdfMatrixInterpretor.h
@@ -0,0 +1,127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfMatrixInterpretor.h
+    \brief Definition of the Template class NetcdfMatrixInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfMatrixInterpretor_H
+#define NetcdfMatrixInterpretor_H
+
+#include "magics.h"
+
+#include "NetcdfMatrixInterpretorAttributes.h"
+#include "NetcdfInterpretor.h"
+#include "Matrix.h"
+#include "PaperPoint.h"
+#include "XmlNode.h"
+
+namespace magics {
+
+class NetcdfMatrixInterpretor: public NetcdfMatrixInterpretorAttributes, public NetcdfInterpretor {
+
+public:
+	NetcdfMatrixInterpretor();
+	virtual ~NetcdfMatrixInterpretor();
+    
+    void set(const map<string, string>& params)
+    { 
+        MagLog::debug() << "NetcdfMatrixInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfMatrixInterpretorAttributes::set(params);
+    }
+    
+    void set(const XmlNode& node)
+    { 
+        MagLog::debug() << "NetcdfMatrixInterpretor::set(params)" << "\n";
+        XmlNode netcdf = node;
+         netcdf.name("netcdf");
+         NetcdfInterpretorAttributes::set(netcdf); 
+        NetcdfMatrixInterpretorAttributes::set(node);
+    }
+    
+    bool accept(const string& node)
+    { 
+        if ( NetcdfInterpretorAttributes::accept(node) ) 
+        	return true; 
+        return NetcdfMatrixInterpretorAttributes::accept(node);
+    }
+
+    virtual NetcdfInterpretor* clone() const
+    {
+    	NetcdfMatrixInterpretor* object = new NetcdfMatrixInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+
+    void clone(const NetcdfMatrixInterpretor& )
+//    void clone(const NetcdfMatrixInterpretor& other)
+    {
+    	NetcdfInterpretorAttributes::copy(*this); 
+    	NetcdfMatrixInterpretorAttributes::copy(*this); 
+    }
+    virtual void interpretAsMatrix(Matrix**);
+    virtual void interpretAsPoints(PointsList& points, const Transformation&);
+    virtual void visit(Transformation&);
+    virtual void getReady(const Transformation&);
+    virtual void visit(MetaDataCollector&);
+    virtual void visit(ValuesCollector&,PointsList&);
+    virtual void visit(TextVisitor&); 
+    virtual void statsData(map<string,vector<double> >&);
+	virtual void x();
+	virtual void y(); 
+	bool cf_date(Netcdf& netcdf, const string&, const string&, string&, vector<double>&);
+	//return true, if the the data is date CF-compliant and the date axis has been set
+	bool reference_date(Netcdf& netcdf, const string&, const string&, string&, vector<double>&);
+	//return true, if the the data is Metview-date compliant and the date axis has been set
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 Matrix* matrix_;
+	 vector<double> columns_;
+	 vector<double> rows_;
+
+	 string baseDateX_;
+	 string baseDateY_;
+	 string geoMinX_;
+	 string geoMaxX_;
+	 string geoMinY_;
+	 string geoMaxY_;
+	 string refDateX_;
+	 string refDateY_;
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfMatrixInterpretor(const NetcdfMatrixInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfMatrixInterpretor& operator=(const NetcdfMatrixInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfMatrixInterpretor& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfMatrixInterpretorAttributes.h b/src/decoders/NetcdfMatrixInterpretorAttributes.h
new file mode 100644
index 0000000..1738d1e
--- /dev/null
+++ b/src/decoders/NetcdfMatrixInterpretorAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfMatrixInterpretorAttributes.h
+    \brief Definition of NetcdfMatrixInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfMatrixInterpretorAttributes_H
+#define NetcdfMatrixInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfMatrixInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfMatrixInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfMatrixInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfMatrixInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string y_;
+	string x_;
+	string aux_x_;
+	string aux_y_;
+	string primary_index_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfMatrixInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/NetcdfOrcaInterpretor.cc b/src/decoders/NetcdfOrcaInterpretor.cc
new file mode 100644
index 0000000..4876f3a
--- /dev/null
+++ b/src/decoders/NetcdfOrcaInterpretor.cc
@@ -0,0 +1,326 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfOrcaInterpretor.h
+    \brief Implementation of the Template class NetcdfOrcaInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "NetcdfOrcaInterpretor.h"
+#include "Factory.h"
+#include "Netcdf.h"
+#include <limits>
+
+using namespace magics;
+
+NetcdfOrcaInterpretor::NetcdfOrcaInterpretor() 
+{}
+
+
+NetcdfOrcaInterpretor::~NetcdfOrcaInterpretor() 
+{}
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+
+void NetcdfOrcaInterpretor::interpretAsMatrix(Matrix** data)
+{
+	
+	if ( *data ) return;
+	
+
+	
+	    
+		
+	  
+		Netcdf netcdf(path_);
+		
+		
+		int jm = netcdf.getDimension("y");
+		int im = netcdf.getDimension("x");
+		
+		Matrix* matrix = new Matrix(jm, im);
+		
+		*data = matrix;
+		double m = std::numeric_limits<double>::max();
+		matrix->missing(std::numeric_limits<double>::max());
+		string missing = netcdf.getVariableAttribute(field_, missing_attribute_, "");
+		if ( !missing.empty() ) {
+			std::stringstream ss(missing);
+			ss >> m;
+		}
+		typedef boost::geometry::model::d2::point_xy<double> point_type;
+		typedef boost::geometry::model::polygon<point_type> polygon_type;
+
+		vector<pair<point_type, pair<int, int> > > points;
+
+		matrix->missing(m);
+		// get the data ...
+		try
+		{
+			Timer time("orca", "decode");
+					map<string, string> first, last;
+					setDimensions(dimension_, first, last);
+
+
+
+					MagLog::debug() << "data[" << matrix->size() << ":" << *std::min_element(matrix->begin(), matrix->end()) << ", " << offset_ << "\n";
+
+
+					vector<double> latm;
+					vector<double> lonm;
+					vector<double> data;
+
+					netcdf.get(longitude_, lonm, first, last);
+					netcdf.get(latitude_,  latm, first, last);
+					netcdf.get(field_, data, first, last);
+
+					double minlat = *std::min_element(latm.begin(), latm.end());
+					double maxlat = *std::max_element(latm.begin(), latm.end());
+
+					double minlon = *std::min_element(lonm.begin(), lonm.end());
+					double maxlon = *std::max_element(lonm.begin(), lonm.end());
+
+
+
+					vector<double>& lon = matrix->columnsAxis();
+					vector<double>& lat = matrix->rowsAxis();
+
+					// for the lon we take the fisrt line :
+					double inci = (maxlon - minlon)/((im) -1);
+					double incj = (maxlat - minlat)/((jm) -1);
+					for (int i = 0; i < im; i++)
+						lon.push_back(minlon + (i*inci));
+					// for the lon we take the fisrt column :
+					for (int i = 0; i < jm; i++)
+						lat.push_back(minlat + (i*incj));
+
+					typedef map<double, map<double, pair<int, int> > > Helper;
+
+					//typedef map<double, double> Helper;
+					Helper helper;
+					int row = 0;
+					for (vector<double>::iterator y = lat.begin(); y != lat.end(); ++y) {
+
+						helper.insert(make_pair(*y, map<double, pair<int, int>  >()));
+
+						Helper::iterator h = helper.find(*y);
+
+						int column = 0;
+						for (vector<double>::iterator x = lon.begin(); x != lon.end(); ++x) {
+							h->second.insert(make_pair(*x, make_pair(row, column)));
+
+							matrix->push_back(m);
+							column++;
+
+						}
+						row++;
+					}
+
+
+					int r = 0;
+					int c = 0;
+
+					double lat11, lat12, lat21, lat22;
+					double lon11, lon12, lon21, lon22;
+					double val11, val12, val21, val22;
+
+					for (int r = 0; r < jm -1; r++) {
+						for (int c = 0;  c < im -1; c++) {
+
+							lat11 = latm[c + (im*r)];
+
+							lat12 = latm[(c+1) + (im*r)];
+							minlat = std::min(lat11, lat12);
+							maxlat = std::max(lat11, lat12);
+							lat21 = latm[c + (im* (r+1))];
+							minlat = std::min(minlat, lat21);
+							maxlat = std::max(maxlat, lat21);
+							lat22 = latm[(c+1) + (im* (r+1))];
+							minlat = std::min(minlat, lat22);
+							maxlat = std::max(maxlat, lat22);
+
+							lon11 = lonm[c + (im*r)];
+							lon12 = lonm[(c+1) + (im*r)];
+							if ( lon12 < lon11 )
+								lon12 +=360.;
+							minlon = std::min(lon11, lon12);
+							maxlon = std::max(lon11, lon12);
+							lon21 = lonm[c + (im* (r+1))];
+							minlon = std::min(minlon, lon21);
+							maxlon = std::max(maxlon, lon21);
+							lon22 = lonm[(c+1) + (im* (r+1))];
+							if ( lon22 < lon21 )
+									lon22 +=360.;
+							minlon = std::min(minlon, lon22);
+							maxlon = std::max(maxlon, lon22);
+
+							val11 = data[c + (im*r)];
+							val12 = data[(c+1) + (im*r)];
+							val21 = data[c + (im* (r+1))];
+							val22 = data[(c+1) + (im* (r+1))];
+
+
+
+							// find the points from the helper!
+							Helper::iterator low,up;
+							low = helper.lower_bound(minlat);
+							up = helper.lower_bound(maxlat);
+							if ( low == helper.end() || up == helper.end() )
+								break;
+							for (Helper::iterator it = low; it != up; ++it) {
+								if (it == helper.end()) break;
+								map<double, pair<int, int> >&  lons = it->second;
+								map<double, pair<int, int> >::iterator llow = lons.lower_bound(minlon);
+								map<double, pair<int, int> >::iterator lup = lons.lower_bound(maxlon);
+								if ( llow == lons.end() || lup == lons.end() )
+									break;;
+								for (map<double, pair<int, int> >::iterator lit = llow; lit != lup; ++lit) {
+
+									double lat = it->first;
+									double lon = lit->first;
+									pair<int, int> index = lit->second;
+
+									// we interpolate at the point using the 4 points found!
+									double val = m;
+									if ( val11 != m && val12 != m && val21 != m && val22 != m) {
+										double val1 =  	((lon12 - lon )/(lon12-lon11))*val11 + ((lon - lon11)/(lon12-lon11))*val12;
+
+										double val2 =  	((lon22 - lon )/(lon22-lon21))*val21 + ((lon - lon21)/(lon22-lon21))*val22;
+										if ( isnan(val1) ) {
+											if ( isnan(val2) ) {
+												val = m;
+											}
+											else
+												val = ((lat - lat11)/(lat22-lat11))*val2;
+										}
+										else {
+											if ( isnan(val2) ) {
+												val =  	((lat22 - lat )/(lat22-lat11))*val1;
+											}
+											else {
+												val =  	((lat22 - lat )/(lat22-lat11))*val1 + ((lat - lat11)/(lat22-lat11))*val2;
+											}
+										}
+
+										if (isnan(val) || isinf(val) || isinf(-val) ) {
+											val = m;
+										}
+									}
+									if (isnan(val) ) val = m;
+									if ( (*matrix)[index.second +( index.first*im)] == m )
+										(*matrix)[index.second +( index.first*im)] = val;
+
+								}
+
+
+							}
+
+
+					}
+
+
+					 matrix->setMapsAxis();
+					}
+
+					
+
+					
+	        
+			MagLog::dev() << *matrix << "\n";
+			
+		}
+	    
+		catch (MagicsException& e)
+		{
+			MagLog::error() << e << "\n";
+		}
+}
+
+
+void NetcdfOrcaInterpretor::interpretAsPoints(PointsList& points)
+{
+	
+    Matrix latitudes;
+    Matrix longitudes;
+	Matrix matrix;
+	
+	matrix.missing(std::numeric_limits<double>::max());
+	// later!
+
+	// get the data ...
+	try
+	{
+		MagLog::dev() << " Netcdf File Path --->" << path_ << "\n";
+		Netcdf netcdf(path_);
+		map<string, string> first, last;
+		setDimensions(dimension_, first, last);
+		vector<double> latm;
+		vector<double> lonm;
+		vector<double> data;
+
+		netcdf.get(longitude_, lonm, first, last);
+		netcdf.get(latitude_,  latm, first, last);
+		netcdf.get(field_, data, first, last);
+		
+
+	 
+
+        
+
+        vector<double>::iterator lat = latm.begin();
+        vector<double>::iterator lon = lonm.begin();
+        vector<double>::iterator val = data.begin();
+        
+		while (lat != latm.end() ) {
+		  	points.push_back(new UserPoint(*lon, *lat, *val));
+			++lat;
+			++lon;
+			++val;
+
+		  }
+	}
+   
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+
+}
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfOrcaInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfOrcaInterpretor[";
+	NetcdfInterpretor::print(out);
+	NetcdfOrcaInterpretorAttributes::print(out);
+	out << "]";
+}
+
+static SimpleObjectMaker<NetcdfOrcaInterpretor, NetcdfInterpretor> netcdf_geovalues_interpretor("orca");
+
diff --git a/src/decoders/NetcdfOrcaInterpretor.h b/src/decoders/NetcdfOrcaInterpretor.h
new file mode 100644
index 0000000..c894658
--- /dev/null
+++ b/src/decoders/NetcdfOrcaInterpretor.h
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfOrcaInterpretor.h
+    \brief Definition of the Template class NetcdfOrcaInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfOrcaInterpretor_H
+#define NetcdfOrcaInterpretor_H
+
+#include "magics.h"
+
+#include "NetcdfOrcaInterpretorAttributes.h"
+#include "NetcdfInterpretor.h"
+#include "Matrix.h"
+#include "MagException.h"
+#include "VectorOfPointers.h"
+
+namespace magics {
+
+class NetcdfOrcaInterpretor: 
+        public NetcdfOrcaInterpretorAttributes,
+		public NetcdfInterpretor {
+
+public:
+	NetcdfOrcaInterpretor();
+	virtual ~NetcdfOrcaInterpretor();
+    
+    void set(const map<string, string>& params) { 
+        MagLog::debug() << "NetcdfOrcaInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfOrcaInterpretorAttributes::set(params);
+    }
+
+    virtual void interpretAsPoints(PointsList&);
+    virtual void interpretAsMatrix(Matrix**);
+   
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+   
+     
+private:
+    //! Copy constructor - No copy allowed
+	NetcdfOrcaInterpretor(const NetcdfOrcaInterpretor&);
+    //! Overloaded << operator to copy - No copy allowed
+	NetcdfOrcaInterpretor& operator=(const NetcdfOrcaInterpretor&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NetcdfOrcaInterpretor& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfVectorInterpretor.cc b/src/decoders/NetcdfVectorInterpretor.cc
new file mode 100644
index 0000000..8840f7b
--- /dev/null
+++ b/src/decoders/NetcdfVectorInterpretor.cc
@@ -0,0 +1,240 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfVectorInterpretor.h
+    \brief Implementation of the Template class NetcdfVectorInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include <limits>
+
+#include "NetcdfVectorInterpretor.h"
+#include "Factory.h"
+#include "Netcdf.h"
+#include "Coordinate.h"
+#include "Coordinate.h"
+
+
+using namespace magics;
+
+NetcdfVectorInterpretor::NetcdfVectorInterpretor() 
+{
+}
+
+
+NetcdfVectorInterpretor::~NetcdfVectorInterpretor() 
+{
+}
+
+
+void NetcdfVectorInterpretor::customisedPoints(const std::set<string>&, CustomisedPointsList&)
+{
+	MagLog::dev() << "NetcdfVectorInterpretor::customisedPoints()--> to be implemented!" << endl;
+}
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfVectorInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfVectorInterpretor[";
+	NetcdfInterpretor::print(out);
+	NetcdfVectorInterpretorAttributes::print(out);
+	out << "]";
+}
+
+
+NetcdfGeoVectorInterpretor::NetcdfGeoVectorInterpretor() 
+{
+}
+
+
+NetcdfGeoVectorInterpretor::~NetcdfGeoVectorInterpretor() 
+{
+}
+
+
+void NetcdfGeoVectorInterpretor::customisedPoints(const Transformation& transformation, const std::set<string>&, CustomisedPointsList& list)
+{
+	Netcdf netcdf(path_);
+	try {
+			vector<double> latitudes;
+			vector<double> longitudes;
+			vector<double> x_component;
+			vector<double> y_component;
+			map<string, string> first, last;
+			setDimensions(dimension_, first, last);
+			
+			netcdf.get(x_component_, x_component, first, last);
+			netcdf.get(y_component_, y_component, first, last);
+			netcdf.get(longitude_, longitudes, first, last);
+			netcdf.get(latitude_, latitudes, first, last);
+			
+			vector<double>::iterator lat = latitudes.begin();
+			vector<double>::iterator lon = longitudes.begin();
+			vector<double>::const_iterator x = x_component.begin();
+			vector<double>::const_iterator y = y_component.begin();
+			
+			//If the lat-lon units is specified as "radians" convert lat-lon 
+			//to degrees. By default the units are sipposed to be "degrees"
+			const char *units = 0;
+			if ( magCompare(netcdf.getVariableAttribute(latitude_,"units",units), "radians") )
+			{			
+				while ( lat!= latitudes.end()) {
+				  *lat=DEG(*lat);
+				  lat++;
+				}  			
+			}
+			
+			if ( magCompare(netcdf.getVariableAttribute(longitude_,"units",units), "radians") )
+			{			
+				while ( lon!= longitudes.end()) {
+				  *lon=DEG(*lon);
+				  lon++;
+				}  			
+			}		
+
+			lat = latitudes.begin();		
+			lon = longitudes.begin();
+			while ( lat != latitudes.end() && lon != longitudes.end() &&
+						x != x_component.end() && y != y_component.end() ) {
+				       //if ( transformation.in( *lon, *lat) ) {
+				    	   CustomisedPoint* point = new CustomisedPoint();		
+				    	   point->longitude(*lon);
+				    	   point->latitude(*lat);
+				    	   (*point)["x_component"] = *x;
+				    	   (*point)["y_component"] = *y;
+				    	   list.push_back(point);
+				       //}
+						lon++;
+						lat++;
+						x++;
+						y++;
+			}
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfGeoVectorInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfGeoVectorInterpretor[";
+	NetcdfInterpretor::print(out);
+	NetcdfGeoVectorInterpretorAttributes::print(out);
+	out << "]";
+}
+
+NetcdfGeoPolarMatrixInterpretor::NetcdfGeoPolarMatrixInterpretor() 
+{
+}
+
+
+NetcdfGeoPolarMatrixInterpretor::~NetcdfGeoPolarMatrixInterpretor() 
+{
+}
+
+
+void NetcdfGeoPolarMatrixInterpretor::customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& list)
+{
+	Netcdf netcdf(path_);
+	try {
+			vector<double> latitudes;
+			vector<double> longitudes;
+			vector<double> speed;
+			vector<double> direction;
+			map<string, string> first, last;
+			setDimensions(dimension_, first, last);
+			
+			netcdf.get(speed_, speed, first, last);
+			netcdf.get(direction_, direction, first, last);
+			netcdf.get(longitude_, longitudes, first, last);
+			netcdf.get(latitude_, latitudes, first, last);
+			
+			vector<double>::iterator lat = latitudes.begin();
+			vector<double>::iterator lon = longitudes.begin();
+			vector<double>::const_iterator x = speed.begin();
+			vector<double>::const_iterator y = direction.begin();
+			
+			//If the lat-lon units is specified as "radians" convert lat-lon 
+			//to degrees. By default the units are sipposed to be "degrees"
+			const char *units = 0;
+			if ( magCompare(netcdf.getVariableAttribute(latitude_,"units",units), "radians") )
+			{			
+				while ( lat!= latitudes.end()) {
+				  *lat=DEG(*lat);
+				  lat++;
+				}  			
+			}
+			
+			if ( magCompare(netcdf.getVariableAttribute(longitude_,"units",units), "radians") )
+			{			
+				while ( lon!= longitudes.end()) {
+				  *lon=DEG(*lon);
+				  lon++;
+				}  			
+			}		
+			/*
+			lat = latitudes.begin();		
+			lon = longitudes.begin();
+			while ( lat != latitudes.end() && lon != longitudes.end() &&
+						x != x_component.end() && y != y_component.end() ) {
+						CustomisedPoint* point = new CustomisedPoint();		
+						point->longitude(*lon);
+						point->latitude(*lat);
+						(*point)["x_component"] = *x;
+						(*point)["y_component"] = *y;
+						list.push_back(point);		
+						lon++;
+						lat++;
+						x++;
+						y++;
+			}
+			*/
+	}
+	catch (MagicsException& e)
+	{
+		MagLog::error() << e << "\n";
+	}
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NetcdfGeoPolarMatrixInterpretor::print(ostream& out)  const
+{
+	out << "NetcdfGeoPolarMatrixInterpretor[";
+	NetcdfInterpretor::print(out);
+	NetcdfGeoPolarMatrixInterpretorAttributes::print(out);
+	out << "]";
+}
diff --git a/src/decoders/NetcdfVectorInterpretor.h b/src/decoders/NetcdfVectorInterpretor.h
new file mode 100644
index 0000000..855b842
--- /dev/null
+++ b/src/decoders/NetcdfVectorInterpretor.h
@@ -0,0 +1,205 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NetcdfVectorInterpretor.h
+    \brief Definition of the Template class NetcdfVectorInterpretor.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 17-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef NetcdfVectorInterpretor_H
+#define NetcdfVectorInterpretor_H
+
+#include "magics.h"
+
+#include "NetcdfVectorInterpretorAttributes.h"
+#include "NetcdfGeoVectorInterpretorAttributes.h"
+#include "NetcdfGeoPolarMatrixInterpretorAttributes.h"
+#include "NetcdfInterpretor.h"
+#include "PaperPoint.h"
+#include "UserPoint.h"
+#include "CustomisedPoint.h"
+#include "XmlNode.h"
+namespace magics {
+
+
+class NetcdfVectorInterpretor: public NetcdfVectorInterpretorAttributes, public NetcdfInterpretor {
+
+public:
+	NetcdfVectorInterpretor();
+	virtual ~NetcdfVectorInterpretor();
+    
+    void set(const map<string, string>& params)
+    { 
+        MagLog::debug() << "NetcdfVectorInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfVectorInterpretorAttributes::set(params);
+    }
+    
+    void set(const XmlNode& node)
+    { 
+        MagLog::debug() << "NetcdfVectorInterpretor::set(params)" << "\n";
+        XmlNode netcdf(node);
+        netcdf.name("netcdf");
+        NetcdfInterpretorAttributes::set(netcdf); 
+        
+        NetcdfVectorInterpretorAttributes::set(node);
+    }
+    
+    bool accept(const string& node)
+    { 
+        if ( NetcdfInterpretorAttributes::accept(node) ) 
+        	return true; 
+        return NetcdfVectorInterpretorAttributes::accept(node);
+    }
+
+    virtual NetcdfInterpretor* clone() const
+    {
+    	NetcdfVectorInterpretor* object = new NetcdfVectorInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+
+    void clone(const NetcdfVectorInterpretor& )
+//    void clone(const NetcdfVectorInterpretor& other)
+    {
+    	NetcdfInterpretorAttributes::copy(*this); 
+    	NetcdfVectorInterpretorAttributes::copy(*this); 
+    }
+    virtual void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+};
+
+class NetcdfGeoVectorInterpretor: public NetcdfGeoVectorInterpretorAttributes, public NetcdfInterpretor {
+
+public:
+	NetcdfGeoVectorInterpretor();
+	virtual ~NetcdfGeoVectorInterpretor();
+    
+    void set(const map<string, string>& params)
+    { 
+        MagLog::debug() << "NetcdfGeoVectorInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfGeoVectorInterpretorAttributes::set(params);
+    }
+    
+    void set(const XmlNode& node)
+    { 
+        MagLog::debug() << "NetcdfGeoVectorInterpretor::set(params)" << "\n";
+        XmlNode netcdf(node);
+        netcdf.name("netcdf");
+        NetcdfInterpretorAttributes::set(netcdf); 
+        NetcdfGeoVectorInterpretorAttributes::set(node);
+    }
+    
+    bool accept(const string& node)
+    { 
+        if ( NetcdfInterpretorAttributes::accept(node) ) 
+        	return true; 
+        return NetcdfGeoVectorInterpretorAttributes::accept(node);
+    }
+
+    virtual NetcdfInterpretor* clone() const
+    {
+    	NetcdfGeoVectorInterpretor* object = new NetcdfGeoVectorInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+
+    void clone(const NetcdfGeoVectorInterpretor& )
+//    void clone(const NetcdfGeoVectorInterpretor& other)
+    {
+    	NetcdfInterpretorAttributes::copy(*this); 
+    	NetcdfGeoVectorInterpretorAttributes::copy(*this); 
+    }
+    virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+  
+
+// 
+};
+
+
+
+class NetcdfGeoPolarMatrixInterpretor: public NetcdfGeoPolarMatrixInterpretorAttributes, public NetcdfInterpretor {
+
+public:
+	NetcdfGeoPolarMatrixInterpretor();
+	virtual ~NetcdfGeoPolarMatrixInterpretor();
+    
+    void set(const map<string, string>& params)
+    { 
+        MagLog::debug() << "NetcdfGeoPolarMatrixInterpretor::set(params)" << "\n";
+        NetcdfInterpretorAttributes::set(params); 
+        NetcdfGeoPolarMatrixInterpretorAttributes::set(params);
+    }
+    
+    void set(const XmlNode& node)
+    { 
+        MagLog::debug() << "NetcdfGeoPolarMatrixInterpretor::set(params)" << "\n";
+        XmlNode netcdf(node);
+        netcdf.name("netcdf");
+        NetcdfInterpretorAttributes::set(netcdf); 
+        NetcdfGeoPolarMatrixInterpretorAttributes::set(node);
+    }
+    
+    bool accept(const string& node)
+    { 
+        if ( NetcdfInterpretorAttributes::accept(node) ) 
+        	return true; 
+        return NetcdfGeoPolarMatrixInterpretorAttributes::accept(node);
+    }
+
+    virtual NetcdfInterpretor* clone() const
+    {
+    	NetcdfGeoPolarMatrixInterpretor* object = new NetcdfGeoPolarMatrixInterpretor();
+    	object->clone(*this);
+    	return object;
+    }
+
+    void clone(const NetcdfGeoPolarMatrixInterpretor& )
+//    void clone(const NetcdfGeoPolarMatrixInterpretor& other)
+    {
+    	NetcdfInterpretorAttributes::copy(*this); 
+    	NetcdfGeoPolarMatrixInterpretorAttributes::copy(*this); 
+    }
+    virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+  
+
+// 
+};
+
+
+
+} // namespace magics
+#endif
diff --git a/src/decoders/NetcdfVectorInterpretorAttributes.h b/src/decoders/NetcdfVectorInterpretorAttributes.h
new file mode 100644
index 0000000..f5140f9
--- /dev/null
+++ b/src/decoders/NetcdfVectorInterpretorAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NetcdfVectorInterpretorAttributes.h
+    \brief Definition of NetcdfVectorInterpretor Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef NetcdfVectorInterpretorAttributes_H
+#define NetcdfVectorInterpretorAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NetcdfVectorInterpretorAttributes 
+{
+public:
+//  --  constructor
+    NetcdfVectorInterpretorAttributes();
+    
+//  --  destructor
+    virtual ~NetcdfVectorInterpretorAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NetcdfVectorInterpretorAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string x_component_;
+	string y_component_;
+	string y_;
+	string x_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NetcdfVectorInterpretorAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/ObsDecoder.cc b/src/decoders/ObsDecoder.cc
new file mode 100644
index 0000000..4ccb16a
--- /dev/null
+++ b/src/decoders/ObsDecoder.cc
@@ -0,0 +1,752 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsDecoder.cc
+    \brief Implementation of the Template class ObsDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 23-Mar-2005
+    
+    Changes:
+    
+*/
+
+#include "ObsDecoder.h"
+#include "MvObs.h"
+#include "TextVisitor.h"
+#include "CustomisedPoint.h"
+#include "expat.h"
+#include "Factory.h"
+
+using namespace magics;
+
+map<int, bool> multilevels_;
+
+class  BufrSubType : public map<string, string> 
+{
+public:
+	BufrSubType() {}
+	~BufrSubType() {}
+protected :
+	void print(ostream& out) const {
+		for (const_iterator subtype = begin(); subtype != end(); ++subtype) 
+			out << "subtype[" << subtype->first << "=" << subtype->second << "]";
+	} 
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BufrSubType& p)
+		{ p.print(s); return s; }
+};
+
+
+class BufrFamily : public map<string, BufrSubType> 
+{
+public:
+	BufrFamily(const string&);
+	~BufrFamily() {};
+	
+	void currentType(const map<string, string>& def) { type_ = def.find("value")->second; }
+
+	void currentSubtype(const map<string, string>& def)
+	{
+		map<string, string>::const_iterator value = def.find("value");
+		if ( value == def.end() )
+		{
+			MagLog::warning() << "BufrFamily> No code defined for subtype!\n";
+			subtype_ = "???";
+		}
+		else 
+		  subtype_ = def.find("value")->second;
+
+		map<string, string>::const_iterator tmpl = def.find("template");
+		template_ = ( tmpl != def.end() ) ? tmpl->second : "";
+		subtypeToBeSet_ = true; 
+	}
+
+	void addSubtype(const string& value)
+	{
+		if (template_ == "") template_ = value;
+		(*this)[type_].insert(make_pair(subtype_, template_)); 
+		subtypeToBeSet_ = false;
+	}
+
+	bool subtype() { return subtypeToBeSet_; }
+
+	void subtypeToReset() { subtypeToBeSet_ = false; }
+	
+	string getType(const string& type, const string& subtype) const
+	{
+		const_iterator t = find(type);
+		if ( t != end() )
+		{
+			BufrSubType::const_iterator s = t->second.find(subtype);
+			if (s != t->second.end() ) return s->second;
+		}
+		return "";
+	}
+
+protected :
+	void print(ostream& out) const
+	{
+		for (const_iterator type = begin(); type != end(); ++type) 
+			out << type->first << "=[" << type->second << "]";
+	} 
+
+	string type_;
+	string subtype_;
+	string template_;
+	bool   subtypeToBeSet_;
+	string centre_;
+
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BufrFamily& p)
+		{ p.print(s); return s; }
+};
+
+
+class BufrFamilyTable : public map<string, BufrFamily*>
+{
+public :
+	BufrFamilyTable() {}
+	~BufrFamilyTable() {}
+	static const BufrFamily& get(const string& centre)
+	{
+		const_iterator table = table_.find(centre);
+		if ( table != table_.end() ) return *(table->second);
+		BufrFamily*  idents = new BufrFamily(centre);
+		table_[centre] = idents;
+		return *idents; 
+	}
+
+	static BufrFamilyTable table_;
+};
+
+
+static void XMLCALL
+startElement(void *userData, const char *name, const char **atts)
+{
+	BufrIdentifiers* ident  = (BufrIdentifiers*) userData; 
+      
+        while (*atts) {
+            if (string(*atts) == "descriptor") {
+            	ident->insert(make_pair(name,*(atts+1)));
+            }
+            atts+=2;
+        }
+}
+
+static void XMLCALL
+endElement(void *, const char *)
+{
+}
+
+
+static void XMLCALL
+startFamilyElement(void *userData, const char *name, const char **atts)
+{
+	BufrFamily* ident  = (BufrFamily*) userData; 
+	string token(name);
+	ident->subtypeToReset();
+	map<string, string> def;
+	if (token != "type" && token != "subtype") return;
+	while (*atts) {         
+	    def.insert(make_pair(*atts,*(atts+1)));
+	    atts+=2;
+	}
+	if ( token == "type") { ident->currentType(def); }
+	if ( token == "subtype") { ident->currentSubtype(def); }
+}
+
+static void XMLCALL
+endFamilyElement(void *, const char *)
+{
+}
+
+static void XMLCALL character (void *userData,
+                            const char *s,
+                            int len)
+{
+	//int *depthPtr = (int*)userData;
+	BufrFamily* object  = (BufrFamily*) userData;
+	if (  std::string(s, len) == "\n" ) return;
+	if (object->subtype()) {
+		object->addSubtype(string(s, len));
+	}
+}
+
+
+BufrIdentifiers::BufrIdentifiers(int centre) : centre_(centre) 
+{
+	ostringstream file, deffile;
+	file << getEnvVariable("MAGPLUS_HOME") <<  MAGPLUS_PATH_TO_SHARE_ << "bufr_" << centre << ".xml";
+	deffile << getEnvVariable("MAGPLUS_HOME") <<  MAGPLUS_PATH_TO_SHARE_ << "bufr_98.xml";
+	char buf[BUFSIZ];
+	XML_Parser parser = XML_ParserCreate(NULL);
+	int done;
+	XML_SetUserData(parser, this);
+	XML_SetElementHandler(parser, startElement, endElement);
+
+	FILE* in  = fopen(file.str().c_str(), "r");
+	if (!in) {
+		// Open the default template for 98! 
+		//and send a big warning! 
+	    in  = fopen(deffile.str().c_str(), "r");
+	    MagLog::warning() << "No definition file for [" << centre << "]: We use ECMWF definitions " <<  endl;
+	}
+
+	do
+	{
+		size_t len = fread(buf, 1, sizeof(buf), in);
+		done = len < sizeof(buf);
+		if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+		{
+			ostringstream s;
+			s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+			cerr <<  s.str() << "\n";
+		}
+	} while (!done);
+	XML_ParserFree(parser);
+	fclose(in);
+}
+
+
+
+
+int BufrIdentifiers::ident(const string& token) const
+{
+	const_iterator ident = find(token);
+	if ( ident != end() ) return atoi(ident->second.c_str());
+	if (centre_ == 98) return -1;
+	else return BufrIdentTable::get(98).ident(token);
+}
+
+
+BufrIdentTable BufrIdentTable::table_;
+BufrFamilyTable BufrFamilyTable::table_;
+
+BufrFamily::BufrFamily(const string& centre) : centre_(centre)
+{
+	ostringstream file;
+	file << getEnvVariable("MAGPLUS_HOME") <<  MAGPLUS_PATH_TO_SHARE_ << "bufr_" << centre << ".xml";
+	char buf[BUFSIZ];
+	XML_Parser parser = XML_ParserCreate(NULL);
+	int done;
+	XML_SetUserData(parser, this);
+	XML_SetElementHandler(parser, startFamilyElement, endFamilyElement);
+	XML_SetCharacterDataHandler(parser, character);
+
+	FILE* in  = fopen(file.str().c_str(), "r");
+	if (!in) return;
+
+	do
+	{
+		size_t len = fread(buf, 1, sizeof(buf), in);
+		done = len < sizeof(buf);
+		if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+		{
+			ostringstream s;
+			s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+			cerr <<  s.str() << "\n";
+		}
+	} while (!done);
+	XML_ParserFree(parser);
+	fclose(in);
+}
+
+const BufrIdentifiers& BufrIdentTable::get(int centre)
+{
+	const_iterator table = table_.find(centre);
+	if ( table != table_.end() ) return *(table->second);
+	BufrIdentifiers*  idents = new BufrIdentifiers(centre);
+	table_[centre] = idents;
+	return *idents; 
+}
+
+
+class BufrAccessor 
+{
+public:
+	BufrAccessor() {};
+	BufrAccessor(const string& descriptor) : descriptor_(descriptor) {}
+	virtual ~BufrAccessor() {};
+	virtual void operator()(const ObsDecoder&, MvObs&, string&) const {}
+	virtual void operator()(const ObsDecoder&, MvObs& obs, double& val) const
+	{
+		const BufrIdentifiers& table =  BufrIdentTable::get(obs.originatingCentre());
+		val = obs.value(table.ident(descriptor_));
+		MagLog::dev()<< "BufrAccessor-Descriptor--->" << descriptor_ << " Value--->" << val << endl;
+	}
+	virtual void print() {}
+	const string& keyword() { return descriptor_; }
+protected:
+	string descriptor_;
+};
+
+class BufrMultiValueAccessor : public BufrAccessor 
+{
+public:
+	BufrMultiValueAccessor(const string& descriptor, int index) : BufrAccessor(descriptor), index_(index) {}
+	virtual ~BufrMultiValueAccessor() {};
+	virtual void operator()(const ObsDecoder&, MvObs& obs, double& val) const {
+		const BufrIdentifiers& table =  BufrIdentTable::get(obs.originatingCentre());
+		val = obs.valueByOccurrence(index_, table.ident(descriptor_));
+		MagLog::dev()<< "BufrMultiValueAccessor-Descriptor--->" << descriptor_ << " INDEX--->" << index_ << " Value--->" << val << endl;
+	}
+	virtual void print() {}
+protected:
+	int index_;
+};
+
+class BufrLowCloudAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrLowCloudAccessor() : BufrMultiValueAccessor("low_cloud", 1) {}
+	virtual ~BufrLowCloudAccessor() {}
+};
+
+class BufrMediumCloudAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrMediumCloudAccessor() : BufrMultiValueAccessor("medium_cloud", 2) {}
+	virtual ~BufrMediumCloudAccessor() {}
+};
+
+class BufrHighCloudAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrHighCloudAccessor() : BufrMultiValueAccessor("high_cloud", 3) {}
+	virtual ~BufrHighCloudAccessor() {}
+};
+
+class BufrLowCloudNebulosityAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrLowCloudNebulosityAccessor() : BufrMultiValueAccessor("low_cloud_nebulosity", 1) {}
+	virtual ~BufrLowCloudNebulosityAccessor() {}
+};
+
+class BufrMediumCloudNebulosityAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrMediumCloudNebulosityAccessor() : BufrMultiValueAccessor("medium_cloud_nebulosity", 2) {}
+	virtual ~BufrMediumCloudNebulosityAccessor() {}
+};
+
+class BufrHighCloudNebulosityAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrHighCloudNebulosityAccessor() : BufrMultiValueAccessor("high_cloud_nebulosity", 3) {}
+	virtual ~BufrHighCloudNebulosityAccessor() {}
+};
+class BufrLowCloudHeightAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrLowCloudHeightAccessor() : BufrMultiValueAccessor("low_cloud_height", 1) {}
+	virtual ~BufrLowCloudHeightAccessor() {}
+};
+
+class BufrMediumCloudHeightAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrMediumCloudHeightAccessor() : BufrMultiValueAccessor("medium_cloud_height", 2) {}
+	virtual ~BufrMediumCloudHeightAccessor() {}
+};
+
+class BufrHighCloudHeightAccessor : public BufrMultiValueAccessor 
+{
+public:
+	BufrHighCloudHeightAccessor() : BufrMultiValueAccessor("high_cloud_height", 3) {}
+	virtual ~BufrHighCloudHeightAccessor() {}
+};
+
+
+class BufrTypeAccessor : public BufrAccessor 
+{
+public:
+	BufrTypeAccessor() { descriptor_ = "type"; };
+	virtual ~BufrTypeAccessor() {};
+	void operator()(const ObsDecoder&, MvObs& obs, string& val) const
+	{
+		val = obs.messageType();
+
+		pair<string, string> type = make_pair(tostring(obs.messageType()),  tostring(obs.messageSubtype()));
+		map<pair<string, string>, string>::iterator value = types_.find(type);
+		if ( value ==  types_.end() )
+		{
+		   string centre = tostring(obs.originatingCentre());
+		   const BufrFamily& family =  BufrFamilyTable::get(centre);
+
+		   val = family.getType(type.first, type.second);		
+		   if (val == "")
+		   {
+
+		      MagLog::warning() << "BufrTypeAccessor> No template type for [" << centre << ", " << type.first << ", " << type.second << "][centre, type, subtype]" << endl;
+		      val = "position";
+		   }
+		   types_[type] = val;
+		}
+		else {
+		   val = value->second;
+		}
+	}
+	static map<pair<string, string>, string> types_;
+};
+
+map<pair<string, string>, string> BufrTypeAccessor::types_; 
+
+class BufrThicknessAccessor : public BufrAccessor
+{
+public:
+	BufrThicknessAccessor() { descriptor_ = "thickness"; keyword_ = "geopotential"; }
+
+	virtual ~BufrThicknessAccessor() {}
+	void operator()(const ObsDecoder& decoder, MvObs& obs, double& val) const {
+		const BufrIdentifiers& table =  BufrIdentTable::get(obs.originatingCentre());	
+		int type  = obs.messageType();
+		
+		map<int, bool>::const_iterator multilevel = multilevels_.find(type);
+		if ( multilevel == multilevels_.end() ) {
+			MagLog::warning() << "BufrThicknessAccessor> Unknown observation type [" << val << "]\n";
+			val =  kBufrMissingValue;
+		}
+		if ( type == 0 || type == 1) {
+			// surface data 
+			val = 0;			
+		}
+		else {
+			//MagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel();
+			// upper-air data 
+			if  ( type == 5 || type == 4 ) 
+				val = 0;			
+			else // Multi-level data {
+				val = abs(obs.valueByPressureLevel(decoder.level_, table.ident(keyword_)) - obs.valueByPressureLevel(decoder.level2_, table.ident(keyword_))) ;	
+			//MagLog::dev()<< " : get --->" << val << endl;
+		}
+	}
+protected:
+	string keyword_;
+};
+
+
+class BufrMultiLevelAccessor : public BufrAccessor
+{
+public:
+	BufrMultiLevelAccessor(const string& descriptor, const string& surface, const string& altitude) :
+		surface_(surface), altitude_(altitude) { descriptor_ = descriptor; }
+	BufrMultiLevelAccessor(const string& descriptor) :
+			surface_(descriptor), altitude_(descriptor) { descriptor_ = descriptor; }
+	virtual ~BufrMultiLevelAccessor() {}
+	void operator()(const ObsDecoder& decoder, MvObs& obs, double& val) const {
+		const BufrIdentifiers& table =  BufrIdentTable::get(obs.originatingCentre());	
+		int type  = obs.messageType();
+		
+		map<int, bool>::const_iterator multilevel = multilevels_.find(type);
+		if ( multilevel == multilevels_.end() ) {
+			MagLog::warning() << "BufrMultiLevelAccessor> Unknown observation type [" << val << "]\n";
+			val =  kBufrMissingValue;
+		}
+		if ( type == 0 || type == 1) {
+			// surface data 
+			val = obs.value(table.ident(surface_));			
+		}
+		else {
+			//MagLog::dev()<< " look for --->" << table.ident(altitude_) << " at " << decoder.getLevel();
+			// upper-air data 
+			if  ( type == 5 || type == 4 ) 
+				val = obs.value(table.ident(altitude_));			
+			else // Multi-level data
+				val = obs.valueByPressureLevel(decoder.level_, table.ident(altitude_));	
+			//MagLog::dev()<< " : get --->" << val << endl;
+		}
+	}
+protected:
+	string surface_;
+	string altitude_;
+};
+
+class BufrGeopotentialAccessor : public BufrMultiLevelAccessor 
+{
+public:
+	BufrGeopotentialAccessor() : BufrMultiLevelAccessor("geopotential") {}
+	virtual ~BufrGeopotentialAccessor() {}
+};
+
+class BufrTemperatureAccessor : public BufrMultiLevelAccessor 
+{
+public:
+	BufrTemperatureAccessor() : BufrMultiLevelAccessor("temperature", "temperature_2meters",  "temperature") {}
+	virtual ~BufrTemperatureAccessor() {}
+};
+class BufrDewPointAccessor : public BufrMultiLevelAccessor 
+{
+public:
+	BufrDewPointAccessor() : BufrMultiLevelAccessor("dewpoint", "dewpoint_2meters",  "dewpoint") {}
+	virtual ~BufrDewPointAccessor() {}
+};
+
+class BufrWindSpeedAccessor : public BufrMultiLevelAccessor 
+{
+public:
+	BufrWindSpeedAccessor() : BufrMultiLevelAccessor("wind_speed", "wind_speed_10meters",  "wind_speed") {}
+	virtual ~BufrWindSpeedAccessor() {}
+};
+
+class BufrWindDirectionAccessor : public BufrMultiLevelAccessor 
+{
+public:
+	BufrWindDirectionAccessor() : BufrMultiLevelAccessor("wind_direction", "wind_direction_10meters",  "wind_direction") {}
+	virtual ~BufrWindDirectionAccessor() {}
+};
+
+SimpleObjectMaker<BufrTypeAccessor, BufrAccessor> type_accessor("type");
+SimpleObjectMaker<BufrTemperatureAccessor, BufrAccessor> temperature_accessor("temperature");
+SimpleObjectMaker<BufrDewPointAccessor, BufrAccessor> dewpoint_accessor("dewpoint");
+SimpleObjectMaker<BufrGeopotentialAccessor, BufrAccessor> geopotential_accessor("geopotential");
+SimpleObjectMaker<BufrThicknessAccessor, BufrAccessor> thickness_accessor("thickness");
+
+SimpleObjectMaker<BufrWindSpeedAccessor, BufrAccessor> wind_speed_accessor("wind_speed");
+SimpleObjectMaker<BufrWindDirectionAccessor, BufrAccessor> wind_direction_accessor("wind_direction");
+
+SimpleObjectMaker<BufrLowCloudAccessor, BufrAccessor> low_cloud_accessor("low_cloud");
+SimpleObjectMaker<BufrMediumCloudAccessor, BufrAccessor> medium_cloud_accessor("medium_cloud");
+SimpleObjectMaker<BufrHighCloudAccessor, BufrAccessor> high_cloud_accessor("high_cloud");
+
+SimpleObjectMaker<BufrLowCloudHeightAccessor, BufrAccessor> low_cloud_nebulosity_accessor("low_cloud_height");
+SimpleObjectMaker<BufrMediumCloudHeightAccessor, BufrAccessor> medium_cloud_nebulosity_accessor("medium_cloud_height");
+SimpleObjectMaker<BufrHighCloudHeightAccessor, BufrAccessor> high_cloud_nebulosity_accessor("high_cloud_height");
+
+SimpleObjectMaker<BufrLowCloudNebulosityAccessor, BufrAccessor> low_cloud_height_accessor("low_cloud_nebulosity");
+SimpleObjectMaker<BufrMediumCloudNebulosityAccessor, BufrAccessor> medium_cloud_height_accessor("medium_cloud_nebulosity");
+SimpleObjectMaker<BufrHighCloudNebulosityAccessor, BufrAccessor> high_cloud_heightaccessor("high_cloud_nebulosity");
+
+
+
+/*!
+ 
+\class ObsDecoder
+
+*/
+ObsDecoder::ObsDecoder()
+{
+	if ( multilevels_.empty() )
+	{
+		multilevels_[0] = false;
+		multilevels_[1] = false;
+		multilevels_[2] = true;
+		multilevels_[3] = true;
+		multilevels_[4] = false;
+		multilevels_[5] = false;
+	}
+}
+
+ObsDecoder::~ObsDecoder() 
+{
+}
+
+void ObsDecoder::decode() 
+{
+	// Read observation file
+	MvObsSet obsSet(file_name_.c_str());
+
+	// Test 
+        MvObsSetIterator obsIterator(obsSet);
+	MvObs obs = obsIterator();
+
+	ostringstream title;
+	title << "Observation: " << obs.obsTime() << " [ type = " << obs.messageType() << " , subtype = " << obs.messageSubtype() << "]";
+	title_ = title.str();
+        
+	while (obs)
+	{
+		MvLocation location = obs.location();
+#ifdef OBS_DEBUG_
+		MagLog::debug() << obsIterator.msgNumber() << " " << location << " " << obs.obsTime() << " " << obs.WmoIdentNumber()
+		     << "\n\ttype=" << obs.messageType() << ", subtype=" << obs.messageSubtype()
+		     << "\n\tlat=" << obs.value(5001) << ", lon=" << obs.value(6001)
+		     << "\n\ttempe=" << obs.value(12004)  << endl;
+#endif
+		push_back(new UserPoint(location.x(), location.y(), obs.value(12004)));
+		obs = obsIterator();
+	}
+}
+
+
+bool ObsDecoder::findInTypes(const string& val) 
+{
+	if ( types_.empty() )   // No restriction specified by the user --> we accept all the types.
+		return true;
+	
+	for (stringarray::const_iterator type = types_.begin(); type != types_.end(); ++type) {
+		return magCompare(*type, val); 	
+	}
+	return false;
+}
+
+
+bool ObsDecoder::checkLevel(double level) 
+{
+    if ( level == kBufrMissingValue ) return true; // Surface data ....
+	level = level/100; // levels are expressed in Pascal...
+    return (level_ - tolerance_ < level && level < level_ + tolerance_ );
+}
+
+
+void ObsDecoder::getInfo(const std::set<string>& tokens, multimap<string, string>& values)
+{
+	MvObsSet obsSet(file_name_.c_str());
+
+	for (std::set<string>::const_iterator token = tokens.begin(); token != tokens.end(); ++token)
+	{
+		std::set<string> noduplicate;
+		string value;
+		try {
+			BufrAccessor* accessor = SimpleObjectMaker<BufrAccessor>::create(*token);
+			MvObsSetIterator   obsIterator(obsSet);
+			MvObs obs;
+			accessor->print();
+			obs = obsIterator();        
+			while (obs)
+			{
+				(*accessor)(*this, obs, value);
+				if ( value != "") noduplicate.insert(value);
+				obs = obsIterator();
+			}
+		}
+		catch ( NoFactoryException) {}
+
+		for (std::set<string>::const_iterator no = noduplicate.begin(); no != noduplicate.end(); ++no)
+		{
+
+			MagLog::debug() << " ObsDecoderToken: "<< *token << " -> " << *no << "\n";
+
+			// here we add it to the list, only if it is the obs_types_list!
+			if ( findInTypes(*no) ) values.insert(make_pair(*token, *no));
+		}
+	}
+}
+
+/*!
+   For Each points ... create an CustomisedPoints using the tokens..
+   then add it to the list! 
+*/
+void ObsDecoder::customisedPoints(const Transformation& transformation, const std::set<string>& tokens, CustomisedPointsList& values)
+{
+	MvObsSet obsSet(file_name_.c_str());
+
+	// Test 
+	MvObsSetIterator obsIterator(obsSet);
+	MvObs obs = obsIterator();
+
+	ostringstream title;
+	title << "Observation: " << obs.obsTime() << " [ type = " << obs.messageType() << " , subtype = " << obs.messageSubtype() << "]";
+	title_ = title.str();
+
+	MagLog::debug() << " ObsTitle: "<< title_ << "\n";
+
+	VectorOfPointers<vector<BufrAccessor*> > accessors;
+	for (std::set<string>::const_iterator token = tokens.begin(); token != tokens.end(); ++token)
+	{
+#ifdef MAGICS_EXCEPTION
+		try {
+    			BufrAccessor* accessor = SimpleObjectMaker<BufrAccessor>::create(*token);
+    			accessors.push_back(accessor);
+		}
+		catch (NoFactoryException&) {
+    			MagLog::dev() << " No Specialised accessor for " << *token << ": take the default\n";
+    			BufrAccessor* accessor = new BufrAccessor(*token);
+    			accessors.push_back(accessor);
+		}
+#else 
+		BufrAccessor* accessor = SimpleObjectMaker<BufrAccessor>::create(*token);
+		if (accessor)
+		{
+			accessors.push_back(accessor);
+		}
+		else
+		{
+			MagLog::dev() << " No Specialised accessor for " << *token << ": take the default\n";
+    			BufrAccessor* accessor = new BufrAccessor(*token);
+    			accessors.push_back(accessor);
+		}
+#endif
+	}
+
+	// Create the type accessor!
+	BufrAccessor* type_accessor = SimpleObjectMaker<BufrAccessor>::create("type");
+	string type;
+	BufrAccessor* level_accessor = new BufrAccessor("pressure");
+	double level;
+    
+	while (obs)
+	{
+		(*type_accessor)(*this, obs, type);
+		
+		if ( findInTypes(type) )
+		{
+			(*level_accessor)(*this, obs, level);
+			if (multilevels_[obs.messageType()] == false || checkLevel(level) )
+			{				
+			   MvLocation loc = obs.location();
+			   double value;		
+			   UserPoint geo(loc.x(), loc.y());
+			   PaperPoint point = transformation(geo);
+			   if ( transformation.in(point) ) {
+				   CustomisedPoint* point = new CustomisedPoint(loc.x(), loc.y(),  obs.findSomeIdent());		
+				   point->type(type);
+				
+				   for (VectorOfPointers<vector<BufrAccessor*> >::const_iterator accessor = accessors.begin(); accessor != accessors.end(); ++accessor)
+				   {
+					   (**accessor)(*this, obs, value);	    
+					   if (value != kBufrMissingValue)  (*point)[(*accessor)->keyword()] = value;
+				   }
+				   if ( !(*point).empty())
+				   {
+					   TMetTime date = obs.msgTime();
+					   (*point)["time"] = date.GetHour()*100 + date.GetMin();
+					   	values.push_back(point);
+				   }
+				   else 
+					   delete point;
+			   }
+			}
+		}
+		obs = obsIterator();
+	}
+} 
+
+PointsHandler& ObsDecoder::points()
+{
+	decode();
+
+	pointsHandlers_.push_back(new PointsHandler(*this));
+	return *(pointsHandlers_.back());
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ObsDecoder::print(ostream& out)  const
+{
+	out << "ObsDecoder[";
+	out << "]";
+}
+
+void ObsDecoder::visit(TitleNode& /*title*/)
+{
+	//title.add(new TitleEntry(title_));
+}
diff --git a/src/decoders/ObsDecoder.h b/src/decoders/ObsDecoder.h
new file mode 100644
index 0000000..9466190
--- /dev/null
+++ b/src/decoders/ObsDecoder.h
@@ -0,0 +1,115 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsDecoder.h
+    \brief Definition of the Template class ObsDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 23-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ObsDecoder_H
+#define ObsDecoder_H
+
+#include "magics.h"
+
+#include "ObsDecoderAttributes.h"
+#include "Decoder.h"
+#include "Data.h"
+
+namespace magics {
+
+class BufrIdentifiers : public map<string, string>
+{
+public:
+	BufrIdentifiers(int centre);
+	~BufrIdentifiers() {}
+	void set(const map<string, string>&);
+	int ident(const string&) const; 	// Return -1 if ident does not exist.
+protected:
+	int centre_;
+};
+
+class BufrIdentTable : public map<int, BufrIdentifiers*>
+{
+public:
+	BufrIdentTable() {}
+	static const BufrIdentifiers& get(int centre);
+
+protected: 	
+	static  BufrIdentTable table_;
+};
+
+
+
+class TitleNode;
+
+/*! \brief Reader for obs data in BUFR
+  
+*/
+class ObsDecoder: 
+	public ObsDecoderAttributes, 
+	public Decoder, 
+	public Data,
+	public PointsList
+{
+public:
+	ObsDecoder();
+	virtual ~ObsDecoder();
+	virtual void set(const map<string, string>& map) 
+		{  ObsDecoderAttributes::set(map); }
+
+	virtual void decode();
+
+	bool defined() { return file_name_.empty() == false; }
+	void getInfo(const std::set<string>&, multimap<string, string>&);	
+	void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+	void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool)
+	{
+		customisedPoints(t, n, out);
+	}
+	virtual PointsHandler& points();
+	PointsHandler& points(const Transformation&, bool) { return  points(); }
+	void visit(TitleNode&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	string   title_;
+
+	bool findInTypes(const string&); 
+	bool checkLevel(double);
+
+private:
+	//! Copy constructor - No copy allowed
+	ObsDecoder(const ObsDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	ObsDecoder& operator=(const ObsDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsDecoder& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/ObsDecoderAttributes.h b/src/decoders/ObsDecoderAttributes.h
new file mode 100644
index 0000000..18dcc1f
--- /dev/null
+++ b/src/decoders/ObsDecoderAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ObsDecoderAttributes.h
+    \brief Definition of ObsDecoder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef ObsDecoderAttributes_H
+#define ObsDecoderAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ObsDecoderAttributes 
+{
+public:
+//  --  constructor
+    ObsDecoderAttributes();
+    
+//  --  destructor
+    virtual ~ObsDecoderAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ObsDecoderAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string file_name_;
+	int level_;
+	int level2_;
+	int tolerance_;
+	stringarray types_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ObsDecoderAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/ObsStatDecoder.cc b/src/decoders/ObsStatDecoder.cc
new file mode 100644
index 0000000..116f41e
--- /dev/null
+++ b/src/decoders/ObsStatDecoder.cc
@@ -0,0 +1,291 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsStatDecoder.cc
+    \brief Implementation of the Template class ObsStatDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 17-Oct-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "ObsStatDecoder.h"
+#include "CustomisedPoint.h"
+#include "Tokenizer.h"
+
+using namespace magics;
+
+
+ObsStatDecoder::ObsStatDecoder() 
+{
+}
+
+
+ObsStatDecoder::~ObsStatDecoder() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ObsStatDecoder::print(ostream& out)  const
+{
+	out << "ObsStatDecoder[";
+	out << "]";
+}
+
+bool equal(const string& in, const string& key) 
+{
+	if (in.length() < key.length() ) return false;
+	string read = in.substr(0, key.length());
+	return ( read == key);
+}
+
+void parsedef(const string& in, string& param, vector<string>& values)
+{
+	
+	Tokenizer tokenizer("= ");
+	vector<string> tokens;
+	tokenizer(in, tokens);
+	
+	vector<string>::const_iterator token = tokens.begin();
+	param = *token; 
+	++token;
+	
+	while ( token != tokens.end() ) {
+		values.push_back(*token);
+		++token;
+	}
+	
+	
+}
+void parse(const string& in, map<string, int>& values)
+{
+	Tokenizer tokenizer("# ");
+	vector<string> tokens;
+	
+	tokenizer(in, tokens);
+	int i = 0;
+	for (vector<string>::const_iterator token = tokens.begin(); token != tokens.end(); ++token) {
+		
+		values[*token] = i++;
+	}
+	
+}
+void parse(const string& in, vector<double>& values)
+{
+	Tokenizer tokenizer(" ");
+
+	vector<string> tokens;
+	
+	tokenizer(in, tokens);
+	
+	for (vector<string>::const_iterator token = tokens.begin(); token != tokens.end(); ++token) {
+		
+		values.push_back(atof((*token).c_str()));
+	}
+		
+}
+
+
+StatItem::StatItem(const string& name, ifstream& in) : name_(name)
+{
+	char buf[1024];
+	while ( in.good() ) {
+		in.getline(buf, 1024);
+		if (string(buf).empty()) continue;
+		if (equal(buf, "END STATITEM")) break;
+		if (equal(buf, "#Pressure")) {
+			
+			parse(buf, columns_);
+			continue;
+		}
+		if (equal(buf, "#")) {
+			vector<string> defs;
+			string name;
+			parsedef(buf, name, defs);
+			definitions_[name] = defs;
+	
+			continue;
+		}
+		else {
+			vector<double> values;
+			parse(buf, values);
+			rows_.push_back(values);
+		}
+		
+	}
+		
+}
+
+
+
+StatDef::StatDef(const string& name, ifstream& in) :name_(name)
+{
+	
+	char buf[1024];
+	while ( in.good() ) {
+		in.getline(buf, 1024);
+		if (string(buf).empty()) continue;
+		string name, ref;
+		vector<string> defs;
+		if (equal(buf, "END STATDEF")) continue;
+		if (equal(buf, "BEGIN STATITEM")) {
+			istringstream line(buf);
+			string d1, d2;
+			line >> d1 >> d2 >> ref;					
+			data_.push_back(StatItem(ref, in));
+		}
+		if (equal(buf, "####################")) {
+			break;
+		}
+		else {
+			parsedef(buf, name, defs);
+			definitions_[name] = defs;
+		}
+			
+	}
+	
+}
+
+
+void ObsStatDecoder::decode()
+{
+	ifstream in(path_.c_str());
+	char buf[1024];
+	
+	string statdef = "BEGIN STATDEF";
+	// First get version!
+	string name;
+	in.getline(buf, 1024);
+	version_ = buf;
+	MagLog::dev()<< "version-->" << version_ << endl;
+	// look for BEGIN STATDEF 
+	while (in.good()) {
+	    in.getline(buf, 1024);
+	   
+		if ( equal(buf, "BEGIN STATDEF") ){
+			istringstream line(buf);
+			string d1, d2;
+			line >> d1 >> d2 >> name ;					
+			MagLog::dev()<< buf << " ---> " << name << endl;
+			data_.insert(make_pair(name, StatDef(name, in)));			
+		}
+	}
+	in.close();
+	
+	for (map<string, StatDef>::const_iterator def = data_.begin(); def != data_.end(); ++def) {
+		MagLog::dev()<< def->first << "------->" << def->second <<  endl;
+	}
+	
+	
+}
+
+void StatItem::print(ostream& out) const
+{
+	out << "BEGIN STATITEM " << name_ << "\n";
+	for (map<string, vector<string> >::const_iterator def = definitions_.begin(); def != definitions_.end(); ++def) {
+		out << def->first << " = ";
+		for (vector<string>::const_iterator val = def->second.begin(); val != def->second.end(); ++val) 
+			out << *val << " ";
+		out << "\n";
+	} 
+	for (map<string, int >::const_iterator column = columns_.begin(); column != columns_.end(); ++column) {
+		out << column->first << " ";
+	} 
+	out << "\n";
+	for (vector<vector<double> >::const_iterator row = rows_.begin(); row != rows_.end(); ++row) {
+		for (vector<double>::const_iterator val = row->begin(); val != row->end(); ++val)
+			out << *val << " ";			
+		out << "\n";
+	} 
+} 
+
+void StatDef::print (ostream& out) const
+{
+	out << "BEGIN STATDEF" << name_ << "\n";
+	for (map<string, vector<string> >::const_iterator def = definitions_.begin(); def != definitions_.end(); ++def) {
+		out << def->first << " = ";
+		for (vector<string>::const_iterator val = def->second.begin(); val != def->second.end(); ++val) 
+			out << *val << " ";
+		out << "\n";
+	} 
+		
+	
+	out << "END BEGIN " << name_ << "\n";
+	
+	for (vector<StatItem>::const_iterator item = data_.begin(); item != data_.end(); ++item) 
+		out << *item;
+	out << "##########################################\n";
+}
+	
+void ObsStatDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& list)
+{
+	decode();
+	
+	map<string, StatDef>::const_iterator def = data_.find("1");
+	if ( def == data_.end() ) return;
+	
+	const StatDef& stat = def->second;
+	int i = 0;
+	for (vector<StatItem>::const_iterator item = stat.data_.begin(); item != stat.data_.end(); ++item) {
+		i++;
+		int y = 1;		
+		for ( vector<vector<double> >::const_iterator row =  (*item).rows_.begin(); row !=  (*item).rows_.end(); ++row) {
+			vector<double>::const_iterator val = (*row).begin();
+			CustomisedPoint* point = new CustomisedPoint();
+			(*point)["total"] = (*item).columns_.size();
+			list.push_back(point);
+			
+			for (map<string, int>::const_iterator column = (*item).columns_.begin(); column !=  (*item).columns_.end(); ++column) {
+				ostringstream t;
+				t <<  (column->first) << "_" << i;
+				string name = t.str();
+				
+				
+				MagLog::dev()<< name << "--->" << *val << "[" << y << "]" << endl;
+				(*point)[name]= *val;
+				(*point)["y"]= y;
+				++val;
+			}
+			y++;
+		}
+		
+		
+	}
+	
+}
+
+
+PointsHandler&  ObsStatDecoder::points()
+{
+	decode();	
+	pointsHandlers_.push_back(new PointsHandler(*this));
+	return *(pointsHandlers_.back());
+}
+
+/*void ObsStatDecoder::visit(TitleBase&)
+{
+}
+*/
+
diff --git a/src/decoders/ObsStatDecoder.h b/src/decoders/ObsStatDecoder.h
new file mode 100644
index 0000000..9e5af91
--- /dev/null
+++ b/src/decoders/ObsStatDecoder.h
@@ -0,0 +1,117 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsStatDecoder.h
+    \brief Definition of the Template class ObsStatDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 17-Oct-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ObsStatDecoder_H
+#define ObsStatDecoder_H
+
+#include "magics.h"
+
+#include "ObsStatDecoderAttributes.h"
+//#include "BaseSceneObject.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "PaperPoint.h"
+
+
+namespace magics {
+	
+class StatItem 
+{
+public:
+	StatItem(const string&, ifstream&);
+	virtual ~StatItem() {}
+	map<string, int>    columns_;
+	vector<vector<double> > rows_; 
+	map<string, vector<string> > definitions_;
+	string name_;
+	virtual void print(ostream&) const; 
+	friend ostream& operator<<(ostream& s,const StatItem& p)
+		{ p.print(s); return s; }
+	              
+};
+	
+class StatDef 
+{
+public:
+	StatDef(const string&, ifstream&);
+	virtual ~StatDef() {}
+	map<string, vector<string> > definitions_;
+	vector<StatItem>  data_;
+	string name_;
+	virtual void print(ostream&) const; 
+	friend ostream& operator<<(ostream& s,const StatDef& p)
+		{ p.print(s); return s; }
+};
+
+class ObsStatDecoder: public ObsStatDecoderAttributes, 
+			public Data,
+			public PointsList {
+
+public:
+	ObsStatDecoder();
+	virtual ~ObsStatDecoder();
+	
+	void set(const map<string, string>& map) { ObsStatDecoderAttributes::set(map); }
+	void set(const XmlNode& node) { ObsStatDecoderAttributes::set(node); }
+	
+	virtual void decode();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 
+	
+	
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	virtual PointsHandler& points();
+    void customisedPoints(const Transformation&, const std::set<string>& needs, CustomisedPointsList& out, bool)
+       { customisedPoints(needs, out); }	
+    PointsHandler& points(const Transformation&, bool) 
+       {  return points(); } 
+    
+
+	
+	string version_;
+	map<string, StatDef> data_;
+
+private:
+    //! Copy constructor - No copy allowed
+	ObsStatDecoder(const ObsStatDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	ObsStatDecoder& operator=(const ObsStatDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsStatDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/ObsStatDecoderAttributes.h b/src/decoders/ObsStatDecoderAttributes.h
new file mode 100644
index 0000000..55cad96
--- /dev/null
+++ b/src/decoders/ObsStatDecoderAttributes.h
@@ -0,0 +1,81 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ObsStatDecoderAttributes.h
+    \brief Definition of ObsStatDecoder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef ObsStatDecoderAttributes_H
+#define ObsStatDecoderAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ObsStatDecoderAttributes 
+{
+public:
+//  --  constructor
+    ObsStatDecoderAttributes();
+    
+//  --  destructor
+    virtual ~ObsStatDecoderAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ObsStatDecoderAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string path_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ObsStatDecoderAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/decoders/ShapeDecoder.cc b/src/decoders/ShapeDecoder.cc
new file mode 100644
index 0000000..20eb207
--- /dev/null
+++ b/src/decoders/ShapeDecoder.cc
@@ -0,0 +1,467 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ShapeDecoder.cc
+    \brief Implementation of the Template class ShapeDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 12-Dec-2005
+    
+    Changes:
+    
+*/
+
+
+#include "ShapeDecoder.h"
+#include "CustomisedPoint.h"
+#include "shapefil.h"
+#include "Polyline.h"
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/algorithms/make.hpp>
+
+// #define BOOST_VERSION 104700
+
+ShapeDecoder::ShapeDecoder() :holes_(false)
+{
+}
+
+ShapeDecoder::~ShapeDecoder() 
+{
+	MagLog::debug() << "clean ShapeDecoder->" << size() << endl;
+	for ( iterator line = begin(); line != end(); ++line) {
+		for ( PointsList::iterator point = (*line)->begin(); point != (*line)->end(); ++point) {
+			delete *point;
+			*point = 0;
+		}
+		delete *line;
+		*line = 0;
+	}
+
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/
+void ShapeDecoder::print(ostream& out)  const
+{
+	out << "ShapeDecoder[";
+	out << "]";
+}
+
+void ShapeDecoder::decode(const Transformation& transformation)
+{
+	vector<string> all;
+	string no;
+	decode(transformation, no, all);
+}
+
+/*! \brief Method to read llocation and names of state capitals
+  
+  \todo When we can handle Unicode we should change "nameascii" back to "name"
+  
+*/
+void ShapeDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	try {
+		SHPHandle hSHP;
+		DBFHandle hDBF;
+		char szTitle[12];
+
+		int     nWidth, nDecimals;
+		int     nShapeType, nEntities, i;
+		double  adfMinBound[4], adfMaxBound[4];
+		string shp = path_ + ".shp";
+		string dbf = path_ + ".dbf";
+		hSHP = SHPOpen( shp.c_str(), "rb" ); 
+		hDBF = DBFOpen( dbf.c_str(), "rb" );
+		if ( !hSHP || !hDBF ) {
+	   		    MagLog::error() << "Can not open Shapefile " << path_ << endl;
+	   		    return;
+	   	}
+
+		SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
+
+		map<string, int> attributes;
+		
+		for( i = 0; i < DBFGetFieldCount(hDBF); i++ ) {
+		            DBFGetFieldInfo( hDBF, i, szTitle, &nWidth, &nDecimals );
+		            attributes.insert(make_pair(lowerCase(szTitle), i));
+		}
+		
+		map<string, int>::iterator index  = attributes.find("nameascii");
+		map<string, int>::iterator indexc = attributes.find("featurecla");
+
+		vector<string> needs;
+		needs.push_back("Admin-0 capital");
+
+		for( i = 0; i < nEntities; i++ )
+		{
+			SHPObject *psShape;
+			string capital  =  DBFReadStringAttribute(hDBF, i, indexc->second);
+			bool add =false;
+
+			for (vector<string>::const_iterator need = needs.begin(); need != needs.end(); ++need)
+			{
+				if (*need == capital ) {
+					add = true;
+					break;
+				}
+			}
+
+			if ( !add )
+				continue;
+
+
+			psShape = SHPReadObject( hSHP, i );
+			string name = ( index != attributes.end() ) ? DBFReadStringAttribute(hDBF, i, index->second) : "?";
+
+			if (psShape->nVertices == 1)
+			{
+			    	CustomisedPoint* point = new CustomisedPoint();
+			    	point->latitude(psShape->padfY[0]);
+			    	point->longitude(psShape->padfX[0]);
+			    	point->identifier(name);
+			    	out.push_back(point);
+			}
+			SHPDestroyObject( psShape );
+		    }
+		    SHPClose( hSHP ); 
+            DBFClose ( hDBF ); 
+	}
+	catch (...)
+	{
+		MagLog::error() << "Can not open Shapefile " << path_ << endl;
+	}
+	MagLog::dev() << "Shape file--->" << this->size() << endl; 
+}
+
+/*
+
+  \sa Boundaries::operator()
+*/
+void ShapeDecoder::decode(const Transformation& transformation, const string& filter, const vector<string>& values)
+{
+	if ( !this->empty() ) return;
+	try {
+		SHPHandle  hSHP;
+		DBFHandle  hDBF;
+		char    szTitle[12];
+		double  minx, miny, maxx, maxy;
+		transformation.smallestBoundingBox(minx, miny, maxx, maxy);
+
+		Polyline& box = transformation.getUserBoundingBox();
+
+		int     nWidth, nDecimals;
+		int     nShapeType, nEntities, i, iPart;
+		double  adfMinBound[4], adfMaxBound[4];
+
+		string shp = path_ + ".shp";
+		string dbf = path_ + ".dbf";
+		hSHP = SHPOpen( shp.c_str(), "rb" ); 
+		hDBF = DBFOpen( dbf.c_str(), "rb" );
+
+		if ( !hSHP || !hDBF ) {
+			MagLog::error() << "Can not open Shapefile " << shp << endl;
+			return;
+		}
+
+		SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
+		map<string, int> attributes;
+		
+		for( i = 0; i < DBFGetFieldCount(hDBF); i++ )
+		{
+		            DBFGetFieldInfo( hDBF, i, szTitle, &nWidth, &nDecimals );
+		            attributes.insert(make_pair(lowerCase(szTitle), i));
+		}
+		map<string, int>::iterator index =  filter.empty() ? attributes.end() : attributes.find(filter);
+
+		if ( index == attributes.end() && !filter.empty() ) {
+			MagLog::info() << "ShapeDecoder: can not find attribute " << filter << " -> Data will not be filtered!" << endl;
+		}
+		SHPObject *psShape = 0;
+		for( i = 0; i < nEntities; i++ )
+		{
+			int       j;
+			if ( psShape ) {
+								SHPDestroyObject(psShape);
+							}
+
+			psShape = SHPReadObject( hSHP, i );
+		
+			bool add = true;
+			if ( index != attributes.end() )
+			{
+				string s = DBFReadStringAttribute(hDBF, i, index->second);
+				add = false;
+
+				for (vector<string>::const_iterator val = values.begin(); val != values.end(); ++val) {
+					string ss = s.substr(0, val->length());
+					if ( magCompare(*val, ss) ) {
+						add = true;
+						MagLog::debug() << "Found " << ss << endl;
+						break;
+					}
+				}
+			}
+
+			if (  add)  {
+				bool in = true;
+				bool left = true;
+				bool right = true;
+
+				if ( psShape->dfYMax <= miny ) continue;
+				if ( psShape->dfYMin >= maxy ) continue;
+				if ( psShape->dfXMax <= minx ) in = false;
+				if ( psShape->dfXMin >= maxx ) in = false;
+
+				if ( psShape->dfXMax-360 < minx ) left = false;
+				if ( psShape->dfXMin+360 > maxx ) right = false;
+
+				if ( !in && !right && !left ) continue;
+
+
+				PointsList *inlist, *leftlist, *rightlist;
+				if (in) {
+					push_back(new PointsList());
+					inlist = back();
+				}
+				if (left) {
+					push_back(new PointsList());
+					leftlist = back();
+				}
+				if (right) {
+					push_back(new PointsList());
+					rightlist = back();
+				}
+
+//				bool hole = false;
+				for( j = 0, iPart = 1; j < psShape->nVertices; j++ )
+				{
+					if( iPart < psShape->nParts && psShape->panPartStart[iPart] == j )
+					{
+						if ( holes_ == false ) break;
+						iPart++;
+						if (in) {
+        						push_back(new PointsList());
+							inlist = back();
+						}
+						if (left) {
+							push_back(new PointsList());
+							leftlist = back();
+						}
+						if (right) {
+							push_back(new PointsList());
+							rightlist = back();
+						}
+					}
+					if (in) {
+							inlist->push_back(new UserPoint(psShape->padfX[j], psShape->padfY[j], i));
+
+					}
+					if (left) {
+						leftlist->push_back(new UserPoint(psShape->padfX[j]-360., psShape->padfY[j], i));
+					}
+					if (right) {
+						rightlist->push_back(new UserPoint(psShape->padfX[j]+360., psShape->padfY[j], i));
+					}
+				}
+			}
+
+		}
+		SHPDestroyObject(psShape);
+
+		SHPClose( hSHP );
+        DBFClose ( hDBF ); 
+	}
+	catch (...)
+	{
+		MagLog::error() << "Can not open Shapefile " << path_ << endl;
+	}
+	MagLog::dev() << "Shape file--->" << this->size() << endl; 
+}
+
+
+
+
+
+void ShapeDecoder::decode(vector<Polyline>& data, const Transformation& transformation)
+{
+	Timer timer("Read Shape file ", "read shape file" + path_);
+
+
+		Polyline& geobox = transformation.getUserBoundingBox();
+		Polyline& box = transformation.getPCBoundingBox();
+		try {
+			SHPHandle  hSHP;
+			int	nShapeType, nEntities, i, iPart;
+			bool hole=false;
+			double 	adfMinBound[4], adfMaxBound[4];
+			string shp = path_ + ".shp";
+			string dbf = path_ + ".dbf";
+			hSHP = SHPOpen( shp.c_str(), "rb" );
+			if ( !hSHP  ) {
+			    	MagLog::error() << "Can not open Shapefile " << path_ << endl;
+			    	return;
+			}
+			data.clear();
+			SHPGetInfo( hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound );
+
+			//vector<polygon_2d> polys;
+			SHPObject	*psShape = 0;
+			int nb  = 0;
+			for( i = 0; i < nEntities; i++ )
+			{
+				int		j;
+
+
+				SHPDestroyObject(psShape);
+
+
+				psShape = SHPReadObject( hSHP, i );
+
+				bool in = true;
+				bool left = false;
+				bool right = false;
+
+				if ( psShape->dfYMax <= transformation.getMinY() ) continue;
+				if ( psShape->dfYMin >= transformation.getMaxY() ) continue;
+				if ( psShape->dfXMax <= transformation.getMinX() ) in = false;
+				if ( psShape->dfXMin >=  transformation.getMaxX()) in = false;
+				if ( psShape->dfXMax-360 > transformation.getMinX() &&  !same(psShape->dfXMax-360, transformation.getMinX())) {
+					        left = true;
+				}
+				if ( psShape->dfXMin+360 < transformation.getMaxX() && !same(psShape->dfXMin+360, transformation.getMaxX() ) ) {
+						right = true;
+				}
+
+				if ( !in && !right && !left ) continue;
+				VectorOfPointers<vector<Polyline *> > polys;
+				Polyline* poly = 0;
+                Polyline* polyleft = 0;
+                Polyline* polyright = 0; 
+                if ( in) {
+                    poly  = new Polyline();
+                    polys.push_back(poly);
+                }
+				if ( left ) {
+                    polyleft  = new Polyline();
+                    polys.push_back(polyleft);
+                }
+                if ( right ) {
+                    polyright  = new Polyline();
+                    polys.push_back(polyright);
+                }
+                
+				left = false;
+				right=false;
+				double last;
+				for( j = 0, iPart = 1, hole = false; j < psShape->nVertices ; j++ )
+				{
+					if( iPart < psShape->nParts && psShape->panPartStart[iPart] == j )
+					{
+						iPart++;
+						hole=true;
+						// We create a new hole!
+
+						if (poly)
+							poly->newHole();
+						if (polyleft)
+							polyleft->newHole();
+						if (polyright)
+							polyright->newHole();
+
+					}
+
+					else {
+						double x = psShape->padfX[j];
+
+						last = psShape->padfX[j];
+
+
+						double y = psShape->padfY[j];
+
+						if ( iPart==1 ) {
+							if ( poly ) {
+								poly->push_back(PaperPoint(x, y));
+							}
+
+							if ( polyleft ) {
+								x -= 360;
+								polyleft->push_back(PaperPoint(x, y));
+							}
+							if ( polyright ) {
+								polyright->push_back(PaperPoint(psShape->padfX[j]+360,  psShape->padfY[j]));
+							}
+
+						}
+						else {
+							if ( in ) {
+								poly->push_back_hole(PaperPoint(x, y));
+							}
+
+							if ( polyleft ) {
+								x -= 360;
+								polyleft->push_back_hole(PaperPoint(x, y));
+
+							}
+							if ( polyright ) {
+								polyright->push_back_hole(PaperPoint(psShape->padfX[j]+360, psShape->padfY[j]));
+							}
+						 }
+					}
+
+
+
+				}
+				
+
+	// first we clip
+					for (vector<Polyline*>::iterator poly = polys.begin(); poly != polys.end(); ++poly ) {
+						(*poly)->sanityCheck();
+					//polyleft.sanityCheck();
+						vector<Polyline> clipped;
+						geobox.intersect(**poly, clipped);
+
+
+	                //geobox.intersect(polyleft, clipped);
+	                // then we reproject!
+						for (vector<Polyline>::iterator clip = clipped.begin(); clip != clipped.end(); ++clip ) {
+							clip->reproject(transformation);
+							clip->sanityCheck();
+							box.intersect(*clip, data);
+						}
+
+	                }
+
+
+
+
+			}
+			SHPDestroyObject(psShape);
+			SHPClose( hSHP );
+		}
+		catch (std::exception e)
+		{
+			MagLog::error() << "Can not open Shapefile " << path_ << endl;
+		}
+}
+
+
diff --git a/src/decoders/ShapeDecoder.h b/src/decoders/ShapeDecoder.h
new file mode 100644
index 0000000..08d1ee5
--- /dev/null
+++ b/src/decoders/ShapeDecoder.h
@@ -0,0 +1,104 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ShapeDecoder.h
+    \brief Definition of the Template class ShapeDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 12-Dec-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ShapeDecoder_H
+#define ShapeDecoder_H
+
+#include "magics.h"
+
+#include "ShapeDecoderAttributes.h"
+#include "Data.h"
+#include "Decoder.h"
+#include "UserPoint.h"
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+typedef boost::geometry::model::d2::point_xy<double>                   point_2d;
+typedef boost::geometry::model::polygon< boost::geometry::model::d2::point_xy<double> > polygon_2d;
+typedef boost::geometry::model::box<     boost::geometry::model::d2::point_xy<double> >     box_2d;
+
+namespace magics {
+	
+class XmlNode;
+
+class ShapeDecoder: public ShapeDecoderAttributes, 
+		public Data, public Decoder, public vector<PointsList* >
+{
+public:
+	ShapeDecoder();
+	virtual ~ShapeDecoder();
+	//! Method to access the data as a list of points : Used by psymb.
+
+	virtual void decode(const Transformation&);
+
+	virtual void decode(vector<Polyline>&, const Transformation&);
+	virtual void decode(const Transformation&, const string&, const vector<string>&);
+	void set(const map<string, string>& map ) { ShapeDecoderAttributes::set(map); }
+	void set(const XmlNode& node ) { ShapeDecoderAttributes::set(node); }
+	void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	void decode() {assert(false);}
+	void needHoles(bool holes) { holes_ = holes; }
+	void setPath(const string& path) { path_ = path; }
+	PointsHandler& points()
+	{
+		assert(false);
+	}
+
+	PointsHandler& points(const Transformation&, bool )
+	{
+		assert(false);
+	}
+	void customisedPoints(const Transformation&, const std::set<string>& n, CustomisedPointsList& out, bool)
+	{
+		customisedPoints(n, out);
+	}
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	bool holes_; // Do we need to deal with the holes during decoding!.
+
+    //! Method to ensure all inner rings lie within outer ring of polygon
+    void sanityCheckPolygon(polygon_2d& io_rPolygon, bool& io_rbModified);
+
+private:
+	//! Copy constructor - No copy allowed
+	ShapeDecoder(const ShapeDecoder&);
+	//! Overloaded << operator to copy - No copy allowed
+	ShapeDecoder& operator=(const ShapeDecoder&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ShapeDecoder& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/SimplePolylineInput.cc b/src/decoders/SimplePolylineInput.cc
new file mode 100644
index 0000000..debf738
--- /dev/null
+++ b/src/decoders/SimplePolylineInput.cc
@@ -0,0 +1,119 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SimplePolylineInput.cc
+    \brief Implementation of the Template class SimplePolylineInput.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Mon 19-Mar-2007
+    
+    Changes:
+    
+*/
+
+
+
+#include "SimplePolylineInput.h"
+
+using namespace magics;
+
+SimplePolylineInput::SimplePolylineInput() 
+{
+}
+
+
+SimplePolylineInput::~SimplePolylineInput() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SimplePolylineInput::print(ostream& out)  const
+{
+	out << "SimplePolylineInput[";
+	out << "]";
+}
+
+void SimplePolylineInput::decode()
+{
+	if ( latitudes_.empty() && longitudes_.empty() && values_.empty() ) {
+		ifstream position(position_filename_.c_str());
+		double lat, lon;
+		if(position)
+		{	
+			while (!position.eof()) {
+				position >> lon >> lat;
+                if (!position.eof())
+                {
+				    latitudes_.push_back(lat);
+				    longitudes_.push_back(lon);
+                }			
+			}	
+		}
+
+		ifstream values(values_filename_.c_str());
+		double value;
+		if(values)
+		{	
+			while (!values.eof()) {
+				values >> value;
+                if (!values.eof())
+                {
+				    values_.push_back(value);
+                }
+			}	
+		}
+	}
+		
+    floatarray::const_iterator lat = latitudes_.begin();
+    floatarray::const_iterator lon = longitudes_.begin();
+    floatarray::const_iterator val = values_.begin();
+    
+    int num_polylines = 0;
+
+    if (!values_.empty())
+    {
+        while ( lat != latitudes_.end() && lon != longitudes_.end() ) 
+        {
+            if ( same(*lat, breakvalue_) || same(*lon, breakvalue_) ) {
+                push_back(new UserPoint(0,0,0,true));
+                num_polylines++;
+                val++;
+
+                // in the case where we don't have enough values,
+                // we will repeat the last one
+
+                if (val == values_.end()) {
+                    val--;
+                }
+            }
+            else 
+                push_back(new UserPoint(*lon, *lat,*val));
+            lon++;
+            lat++;
+
+        }
+    }
+    
+    // check for inconsistencies in numbers of points / values
+    
+    
+
+}
diff --git a/src/decoders/SimplePolylineInput.h b/src/decoders/SimplePolylineInput.h
new file mode 100644
index 0000000..e1f51d2
--- /dev/null
+++ b/src/decoders/SimplePolylineInput.h
@@ -0,0 +1,84 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SimplePolylineInput.h
+    \brief Definition of the Template class SimplePolylineInput.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Mon 19-Mar-2007
+    
+    Changes:
+    
+*/
+
+#ifndef SimplePolylineInput_H
+#define SimplePolylineInput_H
+
+#include "magics.h"
+
+#include "SimplePolylineInputAttributes.h"
+#include "Data.h"
+#include "UserPoint.h"
+
+namespace magics {
+
+class SimplePolylineInput: 
+        public SimplePolylineInputAttributes, 
+        public Data,
+        public PointsList {
+
+public:
+	SimplePolylineInput();
+	virtual ~SimplePolylineInput();
+    virtual void decode();
+    void set(const map<string, string>& map ) { SimplePolylineInputAttributes::set(map); }
+	void set(const XmlNode& node ) { SimplePolylineInputAttributes::set(node); }
+
+  
+    PointsHandler& points()  {
+    	decode();
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    } 
+
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+    {
+    }
+    PointsHandler& points(const Transformation&, bool) { return points();  }
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	SimplePolylineInput(const SimplePolylineInput&);
+    //! Overloaded << operator to copy - No copy allowed
+	SimplePolylineInput& operator=(const SimplePolylineInput&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SimplePolylineInput& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/SymbolInput.h b/src/decoders/SymbolInput.h
new file mode 100644
index 0000000..0d9dbc3
--- /dev/null
+++ b/src/decoders/SymbolInput.h
@@ -0,0 +1,184 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolInput.h
+    \brief Definition of the Template class SymbolInput.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 19-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef SymbolInput_H
+#define SymbolInput_H
+
+#include "magics.h"
+#include <stack>
+
+
+#include "Data.h"
+#include "SymbolInputAttributes.h"
+
+
+namespace magics {
+
+
+class SymbolInput: 
+	public Data,
+	public SymbolInputAttributes {
+
+public:
+	SymbolInput() {}
+	virtual ~SymbolInput() {}
+	
+	 // Implements the set method ... 
+    void set(const map<string, string>& map ) { SymbolInputAttributes::set(map); }
+   
+
+    virtual void decodePoints() { 
+    	if ( value_.empty() )
+		  	for (doublearray::iterator x = x_.begin(); x != x_.end(); x++)
+    			value_.push_back(0);
+    	
+    	doublearray::iterator x = x_.begin();
+    	doublearray::iterator y = y_.begin();
+    	doublearray::iterator v = value_.begin();
+    	
+    	while ( x != x_.end() && y != y_.end() && v != value_.end() ) {
+    		points_.push_back(new UserPoint(*x, *y, *v));
+    		x++;
+    		y++;
+    		v++;
+    	} 	
+    }
+    
+    virtual void decodePoints(const Transformation& projection) { 
+        	if ( value_.empty() )
+    		  	for (doublearray::iterator x = x_.begin(); x != x_.end(); x++)
+        			value_.push_back(0);
+        	
+        	doublearray::iterator x = x_.begin();
+        	doublearray::iterator y = y_.begin();
+        	doublearray::iterator v = value_.begin();
+        	
+        	while ( x != x_.end() && y != y_.end() && v != value_.end() ) {
+        		UserPoint point(*x, *y, *v);
+        		std::stack<UserPoint> points;
+        		projection.wraparound(point, points);
+        		while ( !points.empty() ) {
+        			points_.push_back(new UserPoint(points.top()));
+        			points.pop();
+        		}
+        		x++;
+        		y++;
+        		v++;
+        	} 	
+        }
+  
+    
+    PointsHandler& points() {
+    	decodePoints(); 
+    	
+    	this->pointsHandlers_.push_back(new PointsHandler(points_));
+    	return  (*this->pointsHandlers_.back());
+    }   
+    
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& out)
+    {  
+        if ( x_.empty() ) return;
+        if ( y_.empty() ) return;
+        if ( speed_.empty() ) return;
+        if ( direction_.empty() ) return;  
+        doublearray::iterator x = x_.begin();
+    	doublearray::iterator y = y_.begin();
+        doublearray::iterator speed = speed_.begin();
+        doublearray::iterator direction = direction_.begin();
+        doublearray::iterator v = value_.empty() ? speed_.begin() : value_.begin();
+        doublearray::iterator vend = value_.empty() ? speed_.end() : value_.end();
+        while ( x != x_.end() && y != y_.end()  && speed != speed_.end() 
+                && direction != direction_.end() && v != vend ) {
+            CustomisedPoint* point = new CustomisedPoint(*x, *y, "");
+            double pi = 3.14/180.; 
+            double a = 90 - (*direction);
+            a *= pi;
+            double xc = *speed * -1 * cos(a);
+            double yc = *speed*-1* sin(a);
+            point->insert(make_pair("x_component", xc));
+            point->insert(make_pair("y_component", yc));
+            point->insert(make_pair("colour_component", *v));
+            ++x;
+            ++y;
+            ++speed;
+            ++direction;
+            ++v; 
+            out.push_back(point);
+            
+        }    
+        cout << "MINX" << *min_element(x_.begin(), x_.end()) << endl;
+        cout << "MaxX" << *max_element(x_.begin(), x_.end()) << endl;
+        cout << "MINY" << *min_element(y_.begin(), y_.end()) << endl;
+        cout << "MaxY" << *max_element(y_.begin(), y_.end()) << endl;
+        
+    }
+    
+    
+      
+              
+    PointsHandler& points(const Transformation& transformation) {
+    	decodePoints(transformation); 
+    	
+    	this->pointsHandlers_.push_back(new PointsHandler(points_));
+    	return  (*this->pointsHandlers_.back());
+    } 
+
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+    {
+    	customisedPoints(t, n, out);
+    }
+    PointsHandler& points(const Transformation& t, bool) { return points(t); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const 
+	 	{ 
+	 		out << "SymbolInput[";
+	 		SymbolInputAttributes::print(out);
+	 		out << "]";
+	 	}
+	 PointsList points_;
+	
+private:
+    //! Copy constructor - No copy allowed
+	SymbolInput(const SymbolInput&);
+    //! Overloaded << operator to copy - No copy allowed
+	SymbolInput& operator=(const SymbolInput&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolInput& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/decoders/TableDecoder.cc b/src/decoders/TableDecoder.cc
new file mode 100644
index 0000000..a44e856
--- /dev/null
+++ b/src/decoders/TableDecoder.cc
@@ -0,0 +1,722 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDecoder.cc
+    \brief Implementation of the Template class TableDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 6-May-2004
+    
+    Changes:
+    
+*/
+
+#include "TableDecoder.h"
+#include "TableReader.h"
+#include "Tokenizer.h"
+#include "TextVisitor.h"
+#include "SciMethods.h"
+
+using namespace::magics;
+
+
+TableDecoder::TableDecoder() : matrix_(0)
+{
+	MetviewIcon::setInfo("_datatype","TABLE");
+	MetviewIcon::setInfo("_description","Table Data");
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/
+void TableDecoder::print(ostream& out)  const
+{
+	out << "TableDecoder[";
+    TableDecoderAttributes::print(out);
+	out << "]";
+}
+
+
+void  TableDecoder::dateSetting(vector<string>& dates, vector<double>& values, DateTime& base)
+{
+	if ( dates.empty() )
+		return;
+	base = DateTime(dates.front());
+	for (vector<string>:: iterator date = dates.begin(); date != dates.end(); ++ date ) {
+		DateTime d(*date);
+		values.push_back(d-base);
+	}
+}
+
+
+void  TableDecoder::numberSetting(vector<double>& from, vector<double>& values)
+{
+	std::copy(from.begin(), from.end(), back_inserter(values));
+}
+
+
+
+namespace magics {
+
+void TableDecoder::nameGeoMode(TableReader& reader)
+{
+	x_name_ = this->lon_;
+	y_name_ = this->lat_;
+	reader.setFieldContainer(-1, y_name_, this->y_values_, -999);
+	reader.setFieldContainer(-1, x_name_, this->x_values_, -999);
+
+
+	if ( !this->values_.empty() && this->values_ != "-1") {
+		v_name_ = this->values_;
+		reader.setFieldContainer(-1, v_name_, this->v_values_, -999);
+	}
+	if ( !this->x_component_.empty() && this->x_component_ != "-1") {
+		xc_name_ = this->x_component_;
+		reader.setFieldContainer(-1, xc_name_, this->xc_values_, -999);
+	}
+	if ( !this->y_component_.empty()  && this->y_component_ != "-1") {
+		yc_name_ = this->y_component_;
+		reader.setFieldContainer(-1, yc_name_, this->yc_values_, -999);
+	}
+}
+
+
+void TableDecoder::indexGeoMode(TableReader& reader)
+{
+	int x_index_ = indexToNumber(this->lon_) -1;
+	int y_index_ = indexToNumber(this->lat_) -1;
+	int val_index= indexToNumber(this->values_);
+	int xc_index= indexToNumber(this->x_component_);
+	int yc_index= indexToNumber(this->y_component_);
+
+	reader.setFieldContainer(x_index_, x_name_, this->x_values_, -999);
+	reader.setFieldContainer(y_index_, y_name_, this->y_values_, -999);
+
+
+	if ( val_index != -1 ) {
+		reader.setFieldContainer(val_index -1, v_name_, this->v_values_, -999);
+	}
+	if ( xc_index != -1 ) {
+		reader.setFieldContainer(xc_index -1, xc_name_, this->xc_values_, -999);
+	}
+	if ( yc_index != -1 ) {
+		reader.setFieldContainer(yc_index -1, yc_name_, this->yc_values_, -999);
+	}
+}
+
+
+void  TableDecoder::prepareGeo()
+{
+	  TableReader reader;
+
+	  bool ok;
+	  string error;
+	  reader.setPath(this->path_);
+	  reader.setHeaderRow(this->header_row_);
+	  if ( !this->delimiter_.empty() )
+		  reader.setDelimiter(this->delimiter_[0]);
+	  reader.setConsecutiveDelimitersAsOne(this->combine_delimiters_);
+	  reader.setDataRowOffset(this->data_row_offset_);
+	  reader.setUserMetaDataRows(this->meta_data_rows_);
+
+	  vector<string> names = reader.fieldNames();
+
+
+  if ( !this->x_values_.empty() ) return;
+
+  // first set the containers!!
+  if ( magCompare(this->name_mode_, "name" ) )
+	  nameGeoMode(reader);
+  else
+	  indexGeoMode(reader);
+
+
+  // Then read and interpret!
+   ok = reader.read(error);
+   if ( !ok ) {
+  	 MagLog::error() << error << endl;
+  	 return;
+   }
+  
+  vector<double>::iterator x = this->x_values_.begin();
+	vector<double>::iterator y = this->y_values_.begin();
+	vector<double>::iterator v = this->v_values_.begin();
+
+  while ( x != this->x_values_.end() && x != this->x_values_.end() ) {
+  	double val = 0;
+  	if ( v != v_values_.end() ) {
+  		val = *v;
+  		++v;
+  	}
+  	push_back(new UserPoint(*x, *y, val));
+  	++x;
+  	++y;
+  }
+
+  	//Meta-data
+	map<string,string> meta=reader.userMetaData();	
+	
+	map<string,string>::const_iterator metaIt;
+  	if( (metaIt=meta.find("Metview::type")) != meta.end() &&
+      	     metaIt->second == "FLEXTRA")
+  	{
+		setInfo("_datatype","TABLE_flextra");
+		setInfo("_description","FLEXTRA Trajectories");
+	}
+	
+	for(map<string,string>::const_iterator it=meta.begin(); it != meta.end(); it++)
+  	{
+    		setInfo(it->first,it->second);
+  	}	
+}
+
+
+void TableDecoder::nameXYMode(TableReader& reader)
+{
+	 x_name_ = this->x_;
+	 y_name_ = this->y_;
+	 if ( magCompare(this->x_type_, "date" ) ) {
+		 reader.setFieldContainer(-1, x_name_, this->x_date_values_, "none");
+	 }
+	 else {
+		 reader.setFieldContainer(-1, x_name_, this->x_values_, -999);
+	 }
+	 if ( magCompare(this->y_type_, "date" ) ) {
+		 reader.setFieldContainer(-1, y_name_, this->y_date_values_, "none");
+	  }
+	  else {
+		reader.setFieldContainer(-1, y_name_, this->y_values_, -999);
+	  }
+
+	 if ( !this->values_.empty() && this->values_ != "-1" ) {
+		 v_name_ = this->values_;
+		 reader.setFieldContainer(-1, v_name_, this->v_values_, -999);
+	 }
+	 if ( !this->x_component_.empty() && this->x_component_ != "-1" ) {
+		 xc_name_ = this->x_component_;
+		 reader.setFieldContainer(-1, xc_name_, this->xc_values_, -999);
+	 }
+	 if ( !this->y_component_.empty() && this->y_component_ != "-1") {
+		 yc_name_ = this->y_component_;
+		 reader.setFieldContainer(-1, yc_name_, this->yc_values_, -999);
+	 }
+}
+
+
+void TableDecoder::indexXYMode(TableReader& reader)
+{
+	int x_index = indexToNumber(this->x_) -1;
+	int y_index = indexToNumber(this->y_) -1;
+	int val_index= indexToNumber(this->values_);
+	int xc_index= indexToNumber(this->x_component_);
+	int yc_index= indexToNumber(this->y_component_);
+
+	if ( magCompare(this->x_type_, "date" ) ) {
+
+	    		reader.setFieldContainer(x_index, x_name_, this->x_date_values_, "none");
+	     }
+	     else {
+	    	 reader.setFieldContainer(x_index, x_name_, this->x_values_, -999);
+	     }
+	     if ( magCompare(this->y_type_, "date" ) ) {
+	    	 reader.setFieldContainer(y_index, y_name_, this->y_date_values_, "none");
+	      }
+	      else {
+	    	reader.setFieldContainer(y_index, y_name_, this->y_values_, -999);
+	      }
+
+	     if ( val_index != -1 ) {
+	    	 reader.setFieldContainer(val_index-1, v_name_, this->v_values_, -999);
+	     }
+	     if ( xc_index != -1 ) {
+	    	 reader.setFieldContainer(xc_index-1, xc_name_, this->xc_values_, -999);
+	     }
+	     if ( yc_index != -1 ) {
+	    	 reader.setFieldContainer(yc_index-1, yc_name_, this->yc_values_, -999);
+	     }
+}
+
+
+void  TableDecoder::prepareXY()
+{
+	  TableReader reader;
+
+	  bool ok;
+	  string error;
+	  reader.setPath(this->path_);
+	  reader.setHeaderRow(this->header_row_);
+	  if ( !this->delimiter_.empty() )
+		  reader.setDelimiter(this->delimiter_[0]);
+	  reader.setConsecutiveDelimitersAsOne(this->combine_delimiters_);
+	  reader.setDataRowOffset(this->data_row_offset_);
+	  reader.setUserMetaDataRows(this->meta_data_rows_);
+
+	  vector<string> names = reader.fieldNames();
+
+
+    if ( !this->x_values_.empty() ) return;
+
+    // first set the containers!!
+    // first set the containers!!
+    if ( magCompare(this->name_mode_, "name" ) )
+    	  nameXYMode(reader);
+      else
+    	  indexXYMode(reader);
+    // Then read and interpret!
+     ok = reader.read(error);
+     if ( !ok) {
+    	 MagLog::error() << error << endl;
+    	 return;
+     }
+
+     // Now we interpret
+    if ( magCompare(this->x_type_, "date" ) ) {
+    	this->dateSetting(this->x_date_values_, this->x_values_, baseDateX_);
+    }
+
+    if ( magCompare(this->y_type_, "date" ) ) {
+      	this->dateSetting(this->y_date_values_, this->y_values_, baseDateY_);
+
+     }
+
+    vector<double>::iterator x = this->x_values_.begin();
+	vector<double>::iterator y = this->y_values_.begin();
+	vector<double>::iterator v = this->v_values_.begin();
+
+    while ( x != this->x_values_.end() && x != this->x_values_.end() ) {
+    	double val = 0;
+    	if ( v != v_values_.end() ) {
+    		val = *v;
+    		++v;
+    	}
+    	push_back(new UserPoint(*x, *y, val));
+    	if ( same(*x, x_missing_) ||  same(*y, y_missing_) )
+    		back()->flagMissing();
+    	++x;
+    	++y;
+    }
+
+	//Meta-data
+	map<string,string> meta=reader.userMetaData();	
+	
+	map<string,string>::const_iterator metaIt;
+  	if( (metaIt=meta.find("Metview::type")) != meta.end() &&
+      	     metaIt->second == "FLEXTRA")
+  	{
+		setInfo("_datatype","TABLE_flextra");
+		setInfo("_description","FLEXTRA Trajectories");
+	}
+	
+	for(map<string,string>::const_iterator it=meta.begin(); it != meta.end(); it++)
+  	{
+    		setInfo(it->first,it->second);
+  	}	
+}
+
+
+void TableDecoder::customisedPoints(const Transformation& transformation, const std::set<string>&, CustomisedPointsList& out)
+{
+	if ( transformation.coordinateType() == Transformation::GeoType )
+		prepareGeo();
+	else
+		prepareXY();
+
+	vector<double>::const_iterator x = x_values_.begin();
+	vector<double>::const_iterator y = y_values_.begin();
+	vector<double>::const_iterator xc = this->xc_values_.begin();
+	vector<double>::const_iterator yc = this->yc_values_.begin();
+	vector<double>::const_iterator v = this->v_values_.begin();
+	while (  x != x_values_.end() && y != y_values_.end()  ) {
+				double valx = *x;
+				double valy = *y;
+				if ( magCompare(this->x_type_, "date" ) ) {
+					DateTime ref(transformation.getReferenceX());
+					double shift = ref - this->baseDateX_;
+					valx -= shift;
+				}
+				if ( magCompare(this->y_type_, "date" ) ) {
+					DateTime ref(transformation.getReferenceY());
+					double shift = ref - this->baseDateY_;
+					valy -= shift;
+				}
+		    	CustomisedPoint* point = new CustomisedPoint();
+		    	bool todelete = true;
+		    	if ( transformation.in(valx, valy) ) {
+		    		point->longitude(valx);
+		    		point->latitude(valx);
+		    		out.push_back(point);
+		    		todelete = false;
+		    	}
+
+
+		    	(*point)["x"] = valx;
+		    	++x;
+		    	(*point)["y"] = valy;
+		    	++y;
+
+
+		        double speed = 0;
+		    	if ( xc != this->xc_values_.end() && yc != this->yc_values_.end() ) {
+		    		speed = sqrt( (*xc * *xc)  +  (*yc * *yc) );
+		    		(*point)["x_component"] = *(xc++);
+		    		(*point)["y_component"] = *(yc++);
+		    	}
+		    	if ( v != this->v_values_.end() ) {
+		    		(*point)["colour_component"] = *(v++);
+		    	}
+		    	else
+		    		(*point)["colour_component"] = speed;
+
+		        if ( todelete ) delete point;
+		    	
+		    }
+
+}
+  	
+  	
+MatrixHandler& TableDecoder::matrix()
+{
+
+
+
+	if  ( !matrix_ ) {
+		prepareXY();
+		matrix_ = (*table_binning_)(*this);
+	}
+	cout << *matrix_ << endl;
+	this->matrixHandlers_.push_back(new MatrixHandler(*matrix_));
+	return *(this->matrixHandlers_.back());
+}
+
+
+void TableDecoder::getReady(const Transformation& transformation)
+{
+	/*
+	try {
+		for ( vector<string>::const_iterator x = date_x_.begin(); x != date_x_.end(); ++x )
+			x_.push_back(transformation.x(*x));
+		}
+
+	catch (...) {}
+	try {
+		for ( vector<string>::const_iterator y = date_y_.begin(); y != date_y_.end(); ++y )
+			y_.push_back(transformation.y(*y));
+	}
+	catch (...) {}
+	*/
+}
+
+void TableDecoder::visit(Transformation& transformation)
+{
+	// get the data ...
+	try {
+		if ( transformation.coordinateType() == Transformation::GeoType )
+			prepareGeo();
+		else
+			prepareXY();
+
+		if ( transformation.getAutomaticX() ) {
+
+			if ( magCompare(this->x_type_, "date" ) ) {
+				double min = ( this->x_values_.empty() ) ? 0 : *std::min_element(this->x_values_.begin(), this->x_values_.end());
+				double max = ( this->x_values_.empty() ) ? 24*3600 : *std::max_element(this->x_values_.begin(), this->x_values_.end());
+				transformation.setDataMinX(min, this->baseDateX_);
+				transformation.setDataMaxX(max, this->baseDateX_);
+			}
+			else {
+				double min = ( this->x_values_.empty() ) ? 0 : *std::min_element(this->x_values_.begin(), this->x_values_.end());
+				double max = ( this->x_values_.empty() ) ? 100 : *std::max_element(this->x_values_.begin(), this->x_values_.end());
+				transformation.setMinX(min);
+				transformation.setMaxX(max);
+			}
+		}
+		if ( transformation.getAutomaticY() ) {
+			if ( magCompare(this->y_type_, "date" ) ) {
+				double min = ( this->y_values_.empty() ) ? 0 : *std::min_element(this->y_values_.begin(), this->y_values_.end());
+				double max = ( this->y_values_.empty() ) ? 24*3600 : *std::max_element(this->y_values_.begin(), this->y_values_.end());
+
+				transformation.setDataMinY(min, this->baseDateY_);
+				transformation.setDataMaxY(max, this->baseDateY_);
+			}
+			else {
+				double min = ( this->y_values_.empty() ) ? 0 : *std::min_element(this->y_values_.begin(), this->y_values_.end());
+				double max = ( this->y_values_.empty() ) ? 100 : *std::max_element(this->y_values_.begin(), this->y_values_.end());
+
+				transformation.setMinY(min);
+				transformation.setMaxY(max);
+			}
+		}
+	}
+	catch ( ... ) {}
+}
+
+
+void TableDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	prepareXY();
+	vector<double>::const_iterator x = x_values_.begin();
+	vector<double>::const_iterator y = y_values_.begin();
+	vector<double>::const_iterator xc = this->xc_values_.begin();
+	vector<double>::const_iterator yc = this->yc_values_.begin();
+	vector<double>::const_iterator v = this->v_values_.begin();
+	while (  x != x_values_.end() || y != y_values_.end()  ) {
+		    	CustomisedPoint* point = new CustomisedPoint();
+
+		    		point->longitude(*x);
+		    		point->latitude(*y);
+		    		out.push_back(point);
+
+		    	if ( x != x_values_.end() ) (*point)["x"] = *(x++);
+		    	if ( y != y_values_.end() ) (*point)["y"] = *(y++);
+		        double speed = 0;
+		    	if ( xc != this->xc_values_.end() && yc != this->yc_values_.end() ) {
+		    		speed = sqrt( (*xc * *xc)  +  (*yc * *yc) );
+		    		(*point)["x_component"] = *(xc++);
+		    		(*point)["y_component"] = *(yc++);
+		    	}
+		    	if ( v != this->v_values_.end() ) {
+		    		(*point)["colour_component"] = *(v++);
+		    	}
+		    	else
+		    		(*point)["colour_component"] = speed;
+	}
+}
+
+
+void TableDecoder:: visit(TextVisitor& title)
+{
+	//if ( !title_.empty() )
+	//	title.add(new TextEntry(title_));
+
+	if(MetviewIcon::info("_datatype") == "TABLE_flextra")  
+	{	
+	  	string s="FLEXTRA: ";		
+
+		string date=MetviewIcon::info("startDate");
+		string time=MetviewIcon::info("startTime");
+		string lat=MetviewIcon::info("startLat");
+		string lon=MetviewIcon::info("startLon");
+		string lev=MetviewIcon::info("startZ");
+				
+		s+=MetviewIcon::info("direction") + " " + MetviewIcon::info("type");
+		
+		if(!date.empty())
+		{
+			s+= " " + date;
+			if(!time.empty())
+			{
+				s+= " " + time;
+			}	
+		}	
+			
+		if(!lev.empty())
+		{
+			s+= " " + lev +  "m";
+		}
+		
+		if(!lat.empty() && !lon.empty())
+		{
+			s+= " " + MetviewIcon::info("startComment") + " (" + lon + ", " + lat + ")";
+		}
+
+
+		title.addAutomaticTitle(s);
+	}
+}
+
+
+string TableDecoder::legendText(double valMin,double valMax)
+{
+	if(MetviewIcon::info("_datatype") == "TABLE_flextra")  
+	{
+		ostringstream sst;
+	    	sst << valMin; 
+		string valStr=sst.str();
+		
+		string id,date,time,lev;		
+		id=MetviewIcon::info("id_TR");
+		date=MetviewIcon::info("startDate_TR");
+		time=MetviewIcon::info("startTime_TR");
+		lev=MetviewIcon::info("startZ_TR");
+
+		if(id.empty() || time.empty() || date.empty() || lev.empty())
+		{
+		  	return string();
+		}
+		
+		Tokenizer tk("/");
+		vector<string> idVec,dateVec,timeVec,levVec;
+		tk(id,idVec);
+		tk(date,dateVec);
+		tk(time,timeVec);
+		tk(lev,levVec);		
+		
+		if(idVec.size() != timeVec.size() || timeVec.size() != dateVec.size() || 
+		     dateVec.size() != levVec.size() )
+		{
+		  	return string();
+		}
+		
+		for(unsigned int i=0; i < idVec.size(); i++)
+		{
+		  	if(idVec[i] == valStr)
+			{
+				return dateVec[i].substr(dateVec[i].size()-2,2) + "/" + timeVec[i].substr(0,2) + 
+				" " + levVec[i] + " m";
+			}
+		}
+	}
+	return string();
+}
+
+
+PointsHandler& TableDecoder::points(const Transformation& transformation, bool all)
+{
+
+	// fisrt we adjust point!
+	// we create another poin list with adjisted points!
+	PointsList* list = new PointsList();
+
+	for (vector<UserPoint*>::iterator point = begin(); point != end(); ++point) {
+		UserPoint *pt = new UserPoint(**point);
+		stack<UserPoint> duplicates;
+		check(transformation, pt, duplicates);
+		while ( !duplicates.empty() ) {
+			list->push_back(new UserPoint(duplicates.top()));
+			duplicates.pop();
+		}
+	}
+
+	// then we filter them  we filter the points
+	if ( all )
+		this->pointsHandlers_.push_back(new PointsHandler(*list));
+	else
+		this->pointsHandlers_.push_back(new BoxPointsHandler(*list, transformation, true));
+
+	return *(this->pointsHandlers_.back());
+}
+
+
+bool TableDecoder::check(const Transformation& transformation, UserPoint* point,stack<UserPoint>& duplicates )
+{
+	// We need to adjust the point if we have a date axis!
+	if ( magCompare(x_type_, "date" ) ) {
+		DateTime ref(transformation.getReferenceX());
+		double shift = ref - baseDateX_;
+		point->x_ -= shift;
+	}
+	if ( magCompare(y_type_, "date" ) ) {
+		DateTime ref(transformation.getReferenceY());
+		double shift = ref - baseDateY_;
+		point->y_ -= shift;
+	}
+
+	transformation.wraparound(*point, duplicates);
+	if ( duplicates.empty()  ) {
+		// we falg the point and add to the list!
+		point->flagMissing();
+		duplicates.push(*point);
+		return false;// point has been adjusted and is not in the transformation view
+	}
+	return true; // point and eventual duplicates! has been adjusted and is in the transformation view!
+}
+
+
+void TableDecoder::customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool)
+{
+	customisedPoints(t, n, out);
+}
+
+
+void TableDecoder::visit(ValuesCollector& points)
+{
+	const Transformation& transformation = points.transformation();
+	
+	points.setCollected(true);
+  	 
+	if(points.size() <=0 || size() == 0)
+	  	return;
+	
+	if(values_.empty())
+		points.setHasValue(false);
+		
+	for (ValuesCollector::iterator point =  points.begin(); point != points.end(); ++point)
+	{
+	  	double y=(*point).y(); //lat
+	  	double x=(*point).x(); //lon
+		
+		vector<int> idxV;		
+		for(int i=0; i < size(); i++)
+		{
+			if(fabs(at(i)->y()-y) < points.searchRadiusY() &&
+			   fabs(at(i)->x()-x) <  points.searchRadiusX())
+			{
+			  	idxV.push_back(i);
+			}
+		}
+		
+		if(idxV.size() ==0)
+			continue;  
+		
+		double dist=10000000.;
+		int minIdx=-1;
+		
+		//MagLog::debug() << "odb collect idxV : " << lat << " " << lon << " " << idxV.size() << endl;
+ 		
+		for(int i=0; i < idxV.size(); i++)
+		{  			
+		  	int idx=idxV[i];
+			double d;
+			if(transformation.coordinateType() == Transformation::GeoType )
+			{  
+				d=magics::geoDistanceInKm(at(idx)->y(),at(idx)->x(),y,x);
+			}
+			else
+			{
+			  	d=(at(idx)->x()-x)*(at(idx)->x()-x) +
+			        	 (at(idx)->y()-y)*(at(idx)->y()-y);
+			}
+			  					
+			if(d < dist)
+			{
+			  	minIdx=idx;
+				dist=d;
+			}			
+		}	
+		if(minIdx>=0)  
+			(*point).push_back(new ValuesCollectorData(at(minIdx)->x(),
+							       at(minIdx)->y(),
+							       at(minIdx)->value(),
+							       dist));					     			
+	}	  
+}
+
+double TableDecoder::indexToNumber(const string& str)
+{
+	if ( str.empty() )
+		return -1;
+	
+	double r;
+	std::stringstream ss(str);
+	ss >> r;
+	return r;
+}
+
+} //end namespace
diff --git a/src/decoders/TableDecoder.h b/src/decoders/TableDecoder.h
new file mode 100644
index 0000000..d940acf
--- /dev/null
+++ b/src/decoders/TableDecoder.h
@@ -0,0 +1,123 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TableDecoder.h
+    \brief Definition of the Template class TableDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 6-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef TableDecoder_H
+#define TableDecoder_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "Data.h"
+#include "TableDecoderAttributes.h"
+#include "UserPoint.h"
+#include "Matrix.h"
+#include "TableReader.h"
+
+namespace magics {
+
+class TableDecoder: public Data,
+              public TableDecoderAttributes,
+              public PointsList
+{
+public:
+	
+	TableDecoder();
+	virtual ~TableDecoder() {}
+    
+    void prepareXY();
+    void prepareGeo();
+   
+    void set(const map<string, string>& map ) { TableDecoderAttributes::set(map); }
+	void set(const XmlNode& node ) { TableDecoderAttributes::set(node); }
+	void visit(Transformation& transformation);
+	void visit(TextVisitor& title);
+
+	PointsHandler& points(const Transformation& transformation, bool);
+	
+    PointsHandler& points()  {
+    	this->pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(this->pointsHandlers_.back());
+    } 
+    
+    MatrixHandler& matrix();
+    bool check(const Transformation&, UserPoint*, stack<UserPoint>&);
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+    void getReady(const Transformation&);
+    string legendText(double,double);
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, bool);
+    void visit(ValuesCollector&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void  dateSetting(vector<string>&, vector<double>& , DateTime&);
+	 void  numberSetting(vector<double>& , vector<double>&);
+	 void  indexGeoMode(TableReader&);
+	 void  nameGeoMode(TableReader&);
+	 void  indexXYMode(TableReader&);
+	 void  nameXYMode(TableReader&);
+	 double indexToNumber(const string&);
+	
+     vector<double> x_values_;
+     vector<double> y_values_;
+     vector<double> xc_values_;
+     vector<double> yc_values_;
+     vector<double> v_values_;
+     vector<string> x_date_values_;
+     vector<string> y_date_values_;
+
+     string x_name_;
+     string y_name_;
+     string xc_name_;
+     string yc_name_;
+     string v_name_;
+
+     DateTime baseDateX_;
+     DateTime baseDateY_;
+
+     Matrix *matrix_;
+     Transformation::CoordinateType coordinate_;
+
+private:
+    //! Copy constructor - No copy allowed
+	TableDecoder(const TableDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	TableDecoder& operator=(const TableDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TableDecoder& p)
+		{ p.print(s); return s; }
+
+};
+} // namespace magics
+
+
+#endif
diff --git a/src/decoders/ThinningMethod.cc b/src/decoders/ThinningMethod.cc
new file mode 100644
index 0000000..d0623f9
--- /dev/null
+++ b/src/decoders/ThinningMethod.cc
@@ -0,0 +1,147 @@
+/*! \file ThinningMethod.h
+    \brief Implementation of the Template class ThinningMethod.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Thu 28-Oct-2010
+    
+    Changes:
+    
+*/
+
+
+
+#include "ThinningMethod.h"
+#include "Data.h"
+
+using namespace magics;
+
+ThinningMethod::ThinningMethod() 
+{
+}
+
+
+ThinningMethod::~ThinningMethod() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ThinningMethod::print(ostream& out)  const
+{
+	out << "ThinningMethod[";
+	out << "]";
+}
+
+AutomaticThinningMethod::AutomaticThinningMethod() 
+{
+}
+
+
+void ThinningMethod::operator()(Data&, const Transformation&, const std::set<string>&, CustomisedPointsList&)
+{
+}
+
+
+void BasicThinningMethod::operator()(Data&data,
+		const Transformation& transformation,
+		const std::set<string>& request, CustomisedPointsList& points)
+{
+	try {
+		data.customisedPoints(*this, transformation, request, points);
+	}
+
+	catch ( ...) {
+		data.customisedPoints(transformation, request, points,false);
+	}
+}
+
+
+void AutomaticThinningMethod::operator()(Data& data,
+		const Transformation& transformation, const std::set<string>& request, CustomisedPointsList& points)
+{
+
+	try {
+				data.customisedPoints(*this, transformation, request, points);
+			}
+
+			catch ( ...) {
+				data.customisedPoints(transformation, request, points, false);
+			}
+}
+
+AutomaticThinningMethod::~AutomaticThinningMethod() 
+{
+}
+
+void AutomaticThinningMethod::set(const ThinningMethodUI& ui) 
+{
+	nbPoints_ = ui.nbPoints_;
+	rawOnly_ = ui.rawOnly_; // If true, do not thin .. only show raw data if resolution allows it! 
+}
+
+
+BasicThinningMethod::BasicThinningMethod() 
+{
+}
+
+
+BasicThinningMethod::~BasicThinningMethod() 
+{
+}
+
+void BasicThinningMethod::set(const ThinningMethodUI& ui) 
+{
+	factor_ = ui.factor_;
+}
+
+static SimpleObjectMaker<AutomaticThinningMethod, ThinningMethod> automatic("automatic");
+static SimpleObjectMaker<BasicThinningMethod, BasicThinningMethod> basic("basic");
+static SimpleObjectMaker<BasicThinningMethod, BasicThinningMethod> data("data");
+
+/*
+const Transformation& transformation = parent.transformation();
+try {
+	MatrixHandler<P>& inx = data.xComponent();
+	MatrixHandler<P>& iny = data.yComponent();
+
+	vector thinx;
+	vector thiny;
+	
+ int xfactor = this->thinning_factor_;
+	if ( magCompare(this->thinning_method_, "automatic" ) ) {
+		// We need to recalcalate the thinning ...			
+		double width = parent.transformation().getMaxX() - parent.transformation().getMinX();
+		this->thinning_factor_ = (width/this->thinning_factor_) / inx .XResolution();
+		xfactor = (int) ceil((float)  this->thinning_factor_);
+		 
+		MagLog::dev() << " Thinning factor->" << this->thinning_factor_ << endl;
+		
+	}
+	this->thinning_factor_ = xfactor;
+	(*this->type_).prepare(parent, xfactor*inx .XResolution());
+
+	transformation.thin(inx, this->thinning_factor_, this->thinning_factor_, thinx);
+	transformation.thin(iny, this->thinning_factor_, this->thinning_factor_, thiny);
+
+	typename vector<P>::const_iterator x = thinx.begin();
+	typename vector<P>::const_iterator y = thiny.begin();
+
+	while ( x != thinx.end() && y != thiny.end() )
+	{
+		
+		if ( x->value() != inx.missing() &&  y->value() != iny.missing() ) {
+		    pair<double, double> component = make_pair( x->value(), y->value());
+		    transformation.reprojectComponents(*x, component);
+			(*this->type_)(*x, transformation(*x), component.first,  component.second, 0);
+		}
+		// Here we could check that the lat/lon of the x and y coordinates are the same...
+		x++;
+		y++;
+	} 
+}
+catch ( MagException& e) 
+{
+*/
+
diff --git a/src/decoders/ThinningMethod.h b/src/decoders/ThinningMethod.h
new file mode 100644
index 0000000..0c4cd95
--- /dev/null
+++ b/src/decoders/ThinningMethod.h
@@ -0,0 +1,115 @@
+/*! \file ThinningMethod.h
+    \brief Definition of the Template class ThinningMethod.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Thu 28-Oct-2010
+    
+    Changes:
+    
+*/
+
+#ifndef ThinningMethod_H
+#define ThinningMethod_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+#include "CustomisedPoint.h"
+#include "Transformation.h"
+
+
+namespace magics {
+
+class Data;
+class UserPoint;
+class UserPoint;
+
+struct ThinningMethodUI {
+	int nbPoints_; // For automatic Method
+	int factor_;
+	bool rawOnly_;
+};
+
+class ThinningMethod {
+
+public:
+	ThinningMethod();
+	virtual ~ThinningMethod();
+    
+	void set2D() { twoD_ = false; }
+	
+	virtual void set(const ThinningMethodUI&) {}
+	virtual void operator()(Data&, const Transformation&, const std::set<string>&, CustomisedPointsList&);
+
+	double units() const { return units_; }
+	void units(double units) const { units_ = units; }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 bool twoD_;
+	 mutable double units_;
+private:
+    //! Copy constructor - No copy allowed
+	ThinningMethod(const ThinningMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	ThinningMethod& operator=(const ThinningMethod&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ThinningMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+class AutomaticThinningMethod: public ThinningMethod
+{
+public:
+	AutomaticThinningMethod();
+	virtual ~AutomaticThinningMethod();
+	
+	virtual void set(const ThinningMethodUI&);
+	virtual void operator()(Data&, const Transformation&, const std::set<string>&, CustomisedPointsList&);
+
+	int points() const { return nbPoints_; }
+	void points(int points) { nbPoints_ = points; }
+	bool rawOnly() const { return rawOnly_; }
+protected: 
+	int nbPoints_;
+	bool rawOnly_;
+};
+
+class BasicThinningMethod: public ThinningMethod
+{
+public:
+	BasicThinningMethod();
+	virtual ~BasicThinningMethod();
+	
+	virtual void set(const ThinningMethodUI&);
+	virtual void operator()(Data&, const Transformation&, const std::set<string>&, CustomisedPointsList&);
+
+    int factor() const { return factor_; }
+    void factor(int factor) { factor_ = factor; }
+protected: 
+	int factor_;
+};
+
+template <>
+class MagTranslator<string, ThinningMethod> { 
+public:
+	ThinningMethod* operator()(const string& val )
+	{
+		return SimpleObjectMaker<ThinningMethod>::create(val);
+	}     
+
+	ThinningMethod* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/Time.cc b/src/decoders/Time.cc
new file mode 100644
index 0000000..accf3e0
--- /dev/null
+++ b/src/decoders/Time.cc
@@ -0,0 +1,203 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include "DateTime.h"
+#include "MagException.h"
+#include "MagTranslator.h"
+#include <time.h>
+#include "Tokenizer.h"
+
+
+using namespace magics;
+
+inline void printMagTime(ostream& s, long n)
+{
+	if(n<10) s << '0';
+	s << n;
+}
+
+magics::MagTime::MagTime(long seconds):
+	seconds_(seconds)
+{
+	if(seconds >= 86400 || seconds < 0)
+	{
+		string msg = "MagTime in seconds cannot exceed 86400 ";
+//		MagTranslator<long,string> t;
+//		msg += t(seconds);
+		throw MagicsException(msg);
+	}
+}
+
+magics::MagTime::MagTime(const string& s)
+{
+	Tokenizer parse(":");
+	vector<string> result;
+
+	parse(s,result);
+
+	long hh = 0, mm = 0 , ss = 0;
+	bool err = false;
+	long t = atol(s.c_str());
+	//MagLog::debug() << "time-->[" << s << "]=" << s.length() << "\n";
+	switch(result.size())
+	{
+		case 1:
+			// hh or hhmm or hhmmss
+			switch(s.length())
+			{
+				
+				case 2: hh = t; break;
+				case 4: hh = t/100; mm = t % 100; break;
+				case 6: hh = t/10000; mm = (t%10000)/100; ss = (t%10000)%100; break;
+				default: err = true; break;
+			}
+			break;
+
+		case 2:
+			// hh:mm
+			err =  result[0].length() != 2 
+				|| result[1].length() != 2;
+
+			hh = atol(result[0].c_str());
+			mm = atol(result[1].c_str());
+
+			break;
+			
+		case 3:
+			// hh:mm:ss
+			//MagLog::dev()<< result[0].length() << ":" << result[1].length() << ":" << result[2].length() << endl;
+			err =  result[0].length() != 2 
+			    || result[1].length() != 2 
+				|| result[2].length() != 2;
+
+			hh = atol(result[0].c_str());
+			mm = atol(result[1].c_str());
+			ss = atol(result[2].c_str());
+			err = false;
+
+			break;
+
+		default: 
+			err = true;
+			break;
+	}
+
+	if(err) {
+		throw MagicsException(string("Invalid time ") + s);
+	}
+	
+	if(hh >= 24 || mm >= 60 || ss >= 60
+	   || hh < 0 || mm < 0 || ss < 0)
+	{
+        string msg = "Wrong input for time: ";
+//        MagTranslator<long,string> t;
+//        msg += t(hh); msg += " hours ";
+//        msg += t(mm); msg += " minutes ";
+//        msg += t(ss); msg += " seconds";
+        throw MagicsException(msg);
+	}
+
+	seconds_ = hh*3600+mm*60+ss;
+}
+
+magics::MagTime::operator string() const
+{
+	ostringstream os;
+	os << *this << ends;
+	return os.str();
+}
+
+magics::MagTime::MagTime(const MagTime& other):
+	seconds_(other.seconds_)
+{
+}
+
+magics::MagTime& magics::MagTime::operator=(const MagTime& other)
+{
+	seconds_ = other.seconds_;
+	return *this;
+}
+
+magics::MagTime::MagTime(long hh, long mm, long ss):
+	seconds_(hh*3600+mm*60+ss)
+{
+	if(hh >= 24 || mm >= 60 || ss >= 60
+	   || hh < 0 || mm < 0 || ss < 0)
+	{
+        string msg = "Wrong input for time: ";
+//        MagTranslator<long,string> t;
+//        msg += t(hh); msg += " hours ";
+//        msg += t(mm); msg += " minutes ";
+//        msg += t(ss); msg += " seconds";
+        throw MagicsException(msg);
+	}
+}
+
+magics::MagTime::~MagTime()
+{
+}
+
+long magics::MagTime::hours() const
+{
+	long l = seconds_;
+	return l / 3600;
+}
+
+long magics::MagTime::minutes() const
+{
+	long l = seconds_;
+	return (l % 3600) / 60;
+}
+
+long magics::MagTime::seconds() const
+{
+	long l = seconds_;
+	return l % 60;
+}
+
+long magics::MagTime::hhmmss() const
+{
+	return hours() * 10000 + minutes() * 100 + seconds();
+}
+
+void magics::MagTime::print(ostream& s) const
+{
+	printMagTime(s,hours());
+	s << ':';
+	printMagTime(s,minutes());
+	s << ':';
+	printMagTime(s,seconds());
+}
+
+magics::MagTime magics::MagTime::now()
+{
+	time_t now;
+	time(&now);
+	struct tm *pt;
+
+#ifdef _THREAD_SAFE
+	struct tm t;
+	gmtime_r(&now,&t);
+	pt = &t;
+#else
+	struct tm *t;
+	t = gmtime(&now);
+	pt = t;
+#endif
+	return MagTime(pt->tm_hour,pt->tm_min,pt->tm_sec);
+}
diff --git a/src/decoders/TitleField.cc b/src/decoders/TitleField.cc
new file mode 100644
index 0000000..0ddd8bc
--- /dev/null
+++ b/src/decoders/TitleField.cc
@@ -0,0 +1,50 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleField.cc
+    \brief Implementation of the Template class TitleField.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#include "TitleField.h"
+
+using namespace magics;
+
+TitleField::TitleField() 
+{
+}
+
+
+TitleField::~TitleField() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TitleField::print(ostream& out)  const
+{
+	out << "TitleField[";
+	out << "]";
+}
diff --git a/src/decoders/TitleField.h b/src/decoders/TitleField.h
new file mode 100644
index 0000000..d0308d6
--- /dev/null
+++ b/src/decoders/TitleField.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleField.h
+    \brief Definition of the Template class TitleField.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef TitleField_H
+#define TitleField_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class TitleField : public map<string, string> {
+
+public:
+	TitleField();
+	virtual ~TitleField();
+    
+    string attribute(const string& param, const string& def = "") 
+    {
+        map<string, string>::const_iterator attribute = find(param);
+        if ( attribute == end() ) return def;
+        return attribute->second;
+    }
+    virtual string name() { return ""; }
+    virtual void operator()(vector<string>&) const =0;
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	TitleField(const TitleField&);
+    //! Overloaded << operator to copy - No copy allowed
+	TitleField& operator=(const TitleField&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TitleField& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/TitleMetaField.cc b/src/decoders/TitleMetaField.cc
new file mode 100644
index 0000000..ac647ed
--- /dev/null
+++ b/src/decoders/TitleMetaField.cc
@@ -0,0 +1,73 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleMetaField.cc
+    \brief Implementation of the Template class TitleMetaField.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "TitleMetaField.h"
+
+using namespace magics;
+
+TitleMetaField::TitleMetaField(const string& token) : token_(token) 
+{
+}
+
+
+TitleMetaField::~TitleMetaField() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TitleMetaField::print(ostream& out)  const
+{
+    if ( token_ == "newline") {
+        //out << ends;
+        return;
+    }
+	out << "TitleMetaField[";
+    out << "token=" << token_;
+    for (const_iterator attribute = begin(); attribute != end(); ++attribute) 
+        out << ", " <<  attribute->first << "=" << attribute->second;
+	out << "]";
+}
+
+void TitleMetaField::operator()(vector<string>& title ) const
+{
+	
+	 ostringstream out;
+		out << "TitleMetaField[";
+	    out << "token=" << token_;
+	    for (const_iterator attribute = begin(); attribute != end(); ++attribute) 
+	        out << ", " <<  attribute->first << "=" << attribute->second;
+		out << "]";
+	    
+	    title.back() += out.str();
+}
+
diff --git a/src/decoders/TitleMetaField.h b/src/decoders/TitleMetaField.h
new file mode 100644
index 0000000..478ee35
--- /dev/null
+++ b/src/decoders/TitleMetaField.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleMetaField.h
+    \brief Definition of the Template class TitleMetaField.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef TitleMetaField_H
+#define TitleMetaField_H
+
+#include "magics.h"
+
+#include "TitleField.h"
+
+namespace magics {
+
+class TitleMetaField: public TitleField {
+
+public:
+	TitleMetaField(const string&);
+	virtual ~TitleMetaField();
+    
+    virtual string name() { return token_; }
+    
+   
+    virtual void operator()(vector<string>&) const;
+    
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     string token_;
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	TitleMetaField(const TitleMetaField&);
+    //! Overloaded << operator to copy - No copy allowed
+	TitleMetaField& operator=(const TitleMetaField&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TitleMetaField& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/TitleStringField.cc b/src/decoders/TitleStringField.cc
new file mode 100644
index 0000000..38d2f42
--- /dev/null
+++ b/src/decoders/TitleStringField.cc
@@ -0,0 +1,55 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleStringField.cc
+    \brief Implementation of the Template class TitleStringField.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#include "TitleStringField.h"
+
+using namespace magics;
+
+TitleStringField::TitleStringField(const string& text) : text_(text) 
+{
+}
+
+
+TitleStringField::~TitleStringField() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TitleStringField::print(ostream& out)  const
+{
+	out << text_; 
+}
+
+
+void TitleStringField::operator()(vector<string>& lines) const
+{
+	lines.back() += text_;
+}
\ No newline at end of file
diff --git a/src/decoders/TitleStringField.h b/src/decoders/TitleStringField.h
new file mode 100644
index 0000000..e4584d3
--- /dev/null
+++ b/src/decoders/TitleStringField.h
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleStringField.h
+    \brief Definition of the Template class TitleStringField.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef TitleStringField_H
+#define TitleStringField_H
+
+#include "magics.h"
+
+#include "TitleField.h"
+
+namespace magics {
+
+class TitleStringField: public TitleField {
+
+public:
+	TitleStringField(const string& text);
+	virtual ~TitleStringField();
+    virtual string name() { return "text"; }
+    
+    virtual void operator()(vector<string>&) const;
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+     string text_;
+
+private:
+    //! Copy constructor - No copy allowed
+	TitleStringField(const TitleStringField&);
+    //! Overloaded << operator to copy - No copy allowed
+	TitleStringField& operator=(const TitleStringField&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TitleStringField& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/TitleTemplate.cc b/src/decoders/TitleTemplate.cc
new file mode 100644
index 0000000..2fdd83e
--- /dev/null
+++ b/src/decoders/TitleTemplate.cc
@@ -0,0 +1,179 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleTemplate.cc
+    \brief Implementation of the Template class TitleTemplate.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+#include "TitleTemplate.h"
+#include "Factory.h"
+#include "MagException.h"
+#include "expat.h"
+#include "TitleMetaField.h"
+#include "TitleStringField.h"
+#include "GribDecoder.h"
+using namespace magics;
+
+static void XMLCALL
+startElement(void *userData, const char *name, const char **atts)
+{
+	TitleTemplate* object  = (TitleTemplate*) userData; 
+	if (string(name) == "title" )
+	{
+		TitleTemplate* title = new TitleTemplate();
+		while (*atts) {
+            title->criteria()[*(atts)] = *(atts+1);           
+            atts += 2;
+		}
+		object->top()->push_back(title);
+		object->push(title);
+	}
+	else
+	{
+		TitleMetaField* meta = new TitleMetaField(name);
+		while (*atts)
+        {
+            (*meta)[*(atts)] = *(atts+1);           
+            atts += 2;
+		}
+		object->top()->add(meta);
+	}
+}
+
+static void XMLCALL
+endElement(void *userData, const char *name)
+{
+	if (string(name) == "title" )
+	{
+		TitleTemplate* object  = (TitleTemplate*) userData;
+		object->pop();
+	}
+}
+
+
+
+static void XMLCALL character (void *userData,
+                            const char *s,
+                            int len)
+{
+	//int *depthPtr = (int*)userData;
+	TitleTemplate* object  = (TitleTemplate*) userData;
+	if (  std::string(s, len) == "\n" ) return;
+	object->top()->add(new TitleStringField(string(s, len)));
+}
+
+static void XMLCALL startData(void *)
+{
+	MagLog::dev() << "start data" << "\n";
+	
+}
+
+static void XMLCALL endData(void *)
+{
+}
+
+TitleTemplate* TitleTemplate::singleton_ = 0;
+
+TitleTemplate::TitleTemplate() 
+{
+	if ( !singleton_ ) decode();
+}
+
+void TitleTemplate::decode()
+{
+	singleton_ = this;
+	string filename = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + file_;
+	char buf[BUFSIZ];
+
+	push(this);
+	XML_Parser parser = XML_ParserCreate(NULL);
+	int done;
+	XML_SetUserData(parser, this);
+	XML_SetElementHandler(parser, startElement, endElement);
+	XML_SetCdataSectionHandler(parser,startData, endData);
+	XML_SetCharacterDataHandler(parser, character);
+
+	FILE* in  = fopen(filename.c_str(), "r");
+     
+	if (!in) throw NoSuchFileException(filename);
+	
+	do
+	{
+		size_t len = fread(buf, 1, sizeof(buf), in);
+		done = len < sizeof(buf);
+		if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+		{
+			ostringstream s;
+			s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+			MagLog::error() << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << "\n";
+            throw MagicsException(s.str());
+		}
+	} while (!done);
+	XML_ParserFree(parser);
+	fclose(in);
+}
+
+TitleTemplate::~TitleTemplate() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TitleTemplate::print(ostream& out)  const
+{
+	out << "TitleTemplate[";
+	for (map<string, string>::const_iterator criter = criteria_.begin(); criter != criteria_.end(); ++criter)
+	{
+		out << criter->first << " = " << criter->second << "," << "\n";
+	}
+	for (vector<TitleField*>::const_iterator field = template_.begin(); field != template_.end(); ++field) 
+		out << *(*field);   
+	for (const_iterator child = begin(); child != end(); ++child)
+		out << *(*child);   
+	out << "]";
+}
+
+bool TitleTemplate::verify(const GribDecoder& data) const
+{
+	for (map<string, string>::const_iterator criter = criteria_.begin(); criter != criteria_.end(); ++criter)
+	{
+//#ifdef MAGICS_EXCEPTION
+		try{
+			MagLog::debug() << "Try  to create the MatchCriteria for " << criter->first << "\n";
+			auto_ptr<MatchCriteria >  object(SimpleObjectMaker<MatchCriteria >::create(criter->first));
+			MagLog::debug() << "Found the MatchCriteria for " << criter->first << "\n";
+			if (!(*object).verify(data, criter->first, criter->second)) return false;
+		}
+		catch (NoFactoryException& e)
+		{ // The data do not know how to verify the criter ....
+			MagLog::warning() << "Can Not Create the MatchCriteria for " << criter->first << "\n";
+			return false;
+		}
+//#else
+
+//#endif
+	}
+	return true;
+}
+
diff --git a/src/decoders/TitleTemplate.h b/src/decoders/TitleTemplate.h
new file mode 100644
index 0000000..b869124
--- /dev/null
+++ b/src/decoders/TitleTemplate.h
@@ -0,0 +1,190 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleTemplate.h
+    \brief Definition of the Template class TitleTemplate.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef TitleTemplate_H
+#define TitleTemplate_H
+
+#include <magics.h>
+#include <TitleTemplateAttributes.h>
+#include <TitleField.h>
+#include <Data.h>
+#include <Factory.h>
+#include <VectorOfPointers.h>
+
+#include <stack>
+
+namespace magics {
+class GribDecoder;
+
+
+class SimpleStringFormat
+{
+public:
+	SimpleStringFormat(const string& value, const string& format) : format_(format), value_(value) {}
+protected:
+	string format_;
+	string value_;
+	
+	void operator()(ostream& out) const
+	{
+	  string dup = format_;
+	  string::size_type pos = dup.find ("%s",0);
+
+	  if (pos != string::npos)
+	  {
+	    dup.replace(pos,2,value_);
+	  }
+	  out << dup;
+	}
+
+	friend ostream& operator<<(ostream& out,const SimpleStringFormat& format)
+	{
+	      format(out);
+	      return out;
+	}
+};
+
+
+class TitleFieldHandler 
+{
+public :
+    TitleFieldHandler() {}
+    virtual ~TitleFieldHandler() {};
+    virtual void operator()(TitleField& field, vector<string>& lines, const GribDecoder&) { assert (false); }
+
+};
+
+
+class TitleTemplate : public VectorOfPointers<vector<TitleTemplate*> >, 
+	public TitleTemplateAttributes, 
+	public std::stack<TitleTemplate*>
+{
+
+public:
+	TitleTemplate(map<string, string> criteria) : criteria_(criteria) {}
+	TitleTemplate();
+	virtual ~TitleTemplate();
+
+	void add(TitleField* field) { template_.push_back(field); }
+
+	template <class D>
+	static void title(vector<string>& out,  const D& data)
+	{
+		if ( !singleton_) new TitleTemplate();
+		(*singleton_)(out, data);
+	}
+
+	static void release() 
+	{
+		if (singleton_) {
+		     delete singleton_;
+		     singleton_ = 0;
+		}
+	}
+
+	template <class D>
+	void operator()(vector<string>& out, const D& data) const
+	{
+		if ( !verify(data) ) return;
+		vector<string> lines;
+		lines.push_back("");
+		for (const_iterator child = begin(); child != end(); ++child)
+		{
+			if ((*child)->verify(data))
+			{
+				(*(*child))(lines, data);
+				for (vector<string>::iterator line = lines.begin(); line != lines.end(); ++line)
+					if ( !line->empty() ) out.push_back(*line);
+				return; 
+			}
+		}
+
+		for (vector<TitleField*>::const_iterator entry = template_.begin(); entry != template_.end(); ++entry)
+		{
+#ifdef MAGICS_EXCEPTION
+			try
+			{
+				auto_ptr<TitleFieldHandler > object(SimpleObjectMaker<TitleFieldHandler >::create((*entry)->name()));
+				(*object)(*(*entry), lines, data);
+			}
+			catch (NoFactoryException& e)
+			{
+				// The data do not know how to verify the criter ....
+				MagLog::debug() << "Can Not Create the TitleFieldHandler for " << (*entry)->name() << "\n";
+				(*(*entry))(lines);
+			}
+#else
+			TitleFieldHandler* object = SimpleObjectMaker<TitleFieldHandler >::create((*entry)->name());
+			if (object)
+			{
+				(*object)(*(*entry), lines, data);
+			}
+			else
+			{
+				// The data do not know how to verify the criter ....
+				MagLog::debug() << "Can Not Create the TitleFieldHandler for " << (*entry)->name() << "\n";
+				(*(*entry))(lines);
+			}
+#endif
+		}
+		
+		for (vector<string>::iterator line = lines.begin(); line != lines.end(); ++line)
+			if ( !line->empty()) out.push_back(*line);
+	}
+
+/*!
+ \todo code needed if MAGICS_EXCEPTION are disabled!
+*/
+
+	bool verify(const GribDecoder& data) const;
+
+	map<string, string>& criteria() { return criteria_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	map<string, string> criteria_;
+	VectorOfPointers<vector<TitleField*> > template_;
+	static TitleTemplate* singleton_;
+	void decode();
+
+private:
+	//! Copy constructor - No copy allowed
+	TitleTemplate(const TitleTemplate&);
+	//! Overloaded << operator to copy - No copy allowed
+	TitleTemplate& operator=(const TitleTemplate&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TitleTemplate& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/WindMode.cc b/src/decoders/WindMode.cc
new file mode 100644
index 0000000..054346c
--- /dev/null
+++ b/src/decoders/WindMode.cc
@@ -0,0 +1,119 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file WindMode.cc
+    \brief Implementation of the Template class WindMode.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Wed 9-Aug-2006
+    
+    Changes:
+    
+*/
+
+
+
+#include "WindMode.h"
+
+using namespace magics;
+
+WindMode::WindMode() 
+{
+}
+
+
+WindMode::~WindMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void WindMode::print(ostream& out)  const
+{
+	out << "WindMode[";
+	out << "]";
+}
+
+void UVWindMode::x(Matrix** out1, Matrix** out2, Matrix* in1, Matrix* in2)
+{
+	*out1 = in1;
+	*out2 = in2;
+}
+
+
+void SDWindMode::x(Matrix** out1, Matrix** out2, Matrix* in1, Matrix* in2)
+{
+	*out1 = in1;
+	*out2 = in2;
+        double x = 3.14/180.;
+	vector<double>::const_iterator speed = in1->begin();
+	vector<double>::const_iterator angle = in2->begin();
+	vector<double> speeds;
+	vector<double> directions;
+//	MagLog::dev()<< "missing1-->" << in1->missing() << endl;
+//	MagLog::dev()<< "missing2-->" << in2->missing() << endl;
+	while ( speed != in1->end() && angle != in2->end() ) {
+       if ( *speed == in1->missing() || *angle == in2->missing() ) 
+       {
+    	   speeds.push_back(in2->missing());
+    	   directions.push_back(in2->missing());
+       }
+       else {
+       	double a = 90 - (*angle); 
+	a *= x;
+       	speeds.push_back(*speed * -1 * cos(a));
+    	directions.push_back(*speed*-1* sin(a));
+       }
+       speed++;
+       angle++;
+	}	
+	
+	(*out1)->clear();
+	(*out2)->clear();
+	
+        vector<double>::iterator d = directions.begin();
+        vector<double>::iterator send = speeds.end();
+	for (vector<double>::iterator s = speeds.begin(); s != send; ++s) {
+			(*out1)->push_back(*s);
+			(*out2)->push_back(*d);
+			++d;
+	}
+}
+
+
+pair<double, double> SDWindMode::operator()(double s, double d)
+{
+	double a = 90 - (d);    
+	double x = 3.14/180.;
+	a *= x;
+    return make_pair(s * -1 * cos(a), s*-1* sin(a)) ;
+  
+}
+
+
+void VDWindMode::x(Matrix**, Matrix* in1, Matrix* in2)
+{
+}
+
+void VDWindMode::y(Matrix**, Matrix* in1, Matrix* in2)
+{
+}
+
+
diff --git a/src/decoders/WindMode.h b/src/decoders/WindMode.h
new file mode 100644
index 0000000..0b269a7
--- /dev/null
+++ b/src/decoders/WindMode.h
@@ -0,0 +1,157 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file WindMode.h
+    \brief Definition of the Template class WindMode.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Wed 9-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef WindMode_H
+#define WindMode_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "Layer.h"
+
+
+namespace magics {
+
+class WindMode {
+
+public:
+	WindMode();
+	virtual ~WindMode();
+
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+
+    virtual bool accept(const string&) { return false; }
+    virtual WindMode* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new WindMode();
+    }
+    
+    virtual void toxml(ostream&) {}
+
+    virtual void x(Matrix**,  Matrix**, Matrix*, Matrix*) {}
+    virtual pair<double, double> operator()(double x, double y) { return make_pair(x, y); }
+
+    virtual ValuesCollectorData* values(double lon, double lat, double x, double y, double dist)
+    { return new ValuesCollectorData(lon, lat, x, dist); }
+    
+    virtual double norm(double x, double y) const {return x;}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	WindMode(const WindMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	WindMode& operator=(const WindMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const WindMode& p)
+		{ p.print(s); return s; }
+
+};
+
+class UVWindMode : public WindMode 
+{
+public:
+	UVWindMode() {}
+	virtual ~UVWindMode() {}
+	WindMode* clone() const { return new UVWindMode(); }
+	virtual void x(Matrix** out,  Matrix**, Matrix* in1, Matrix* in2);
+	virtual pair<double, double> operator()(double x, double y) { return make_pair(x, y); }
+	ValuesCollectorData* values(double lon, double lat, double x, double y, double dist)
+	{ return new ValuesCollectorUVData(lon, lat, x, y, dist); }
+	double norm(double x, double y) const {return sqrt(x*x+y*y);}
+private:
+    //! Copy constructor - No copy allowed
+	UVWindMode(const WindMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	UVWindMode& operator=(const WindMode&);
+};
+
+    
+class SDWindMode : public WindMode 
+{
+public:
+	SDWindMode() {}
+	virtual ~SDWindMode() {}
+	WindMode* clone() const { return new SDWindMode(); }
+	virtual void x(Matrix** out, Matrix**, Matrix* in1, Matrix* in2);
+	virtual pair<double, double> operator()(double x, double y);
+	ValuesCollectorData* values(double lon, double lat, double x, double y, double dist)
+		{ return new ValuesCollectorSDData(lon, lat, x, y, dist); }
+	double norm(double x, double y) const {return x;}
+private:
+    //! Copy constructor - No copy allowed
+	SDWindMode(const WindMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	SDWindMode& operator=(const SDWindMode&);
+};
+
+class VDWindMode : public WindMode 
+{
+public:
+	VDWindMode() {}
+	virtual ~VDWindMode() {}
+	WindMode* clone() const { return new VDWindMode(); }
+	virtual void x(Matrix** out, Matrix* in1, Matrix* in2);
+	    virtual void y(Matrix** out, Matrix* in1, Matrix* in2);
+private:
+    //! Copy constructor - No copy allowed
+	VDWindMode(const WindMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	VDWindMode& operator=(const SDWindMode&);
+};
+
+template <>
+class MagTranslator<string, WindMode> { 
+public:
+	WindMode* operator()(const string& val )
+	{
+		return SimpleObjectMaker<WindMode>::create(val);
+	}
+
+	WindMode* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/XYList.cc b/src/decoders/XYList.cc
new file mode 100644
index 0000000..fdebb85
--- /dev/null
+++ b/src/decoders/XYList.cc
@@ -0,0 +1,300 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XYList.cc
+    \brief Implementation of the Template class XYList.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 6-May-2004
+    
+    Changes:
+    
+*/
+
+#include "XYList.h"
+
+
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+
+void XYList::print(ostream& out)  const
+{
+	out << "XYList[";
+    XYListAttributes::print(out);
+	out << "]";
+}
+
+void  XYList::prepare()
+{
+    if ( !this->empty() ) return;
+    vector<double>::const_iterator i = x_.begin();
+    vector<double>::const_iterator j = y_.begin();
+    
+    while ( i != x_.end() && j != y_.end() ) {
+    	this->push_back(new UserPoint(*i, *j, *j));
+    	i++;
+    	j++;
+    }
+/*
+    vector<double>::const_reverse_iterator i2 = x2_.rbegin();
+    vector<double>::const_reverse_iterator j2 = y2_.rbegin();
+    
+    vector<double>::const_reverse_iterator ei2 = x2_.rend();
+    vector<double>::const_reverse_iterator ej2 = y2_.rend();
+    while ( i2 != ei2 && j2 != ej2 ) {
+    	this->push_back(new UserPoint(*i2, *j2, *j2));
+    	i2++;
+    	j2++;
+    }
+*/
+}
+
+
+
+void XYList::customisedPoints(const std::set<string>& needs, CustomisedPointsList& out)
+{
+	vector<double>::const_iterator x = x_.begin();
+	vector<double>::const_iterator y = y_.begin();
+	vector<double>::const_reverse_iterator x2 = x2_.rbegin();
+	vector<double>::const_reverse_iterator y2 = y2_.rbegin();
+	vector<double>::const_iterator x_upper = x_upper_.begin();
+	vector<double>::const_iterator y_upper = y_upper_.begin();
+	vector<double>::const_iterator x_lower = x_lower_.begin();
+	vector<double>::const_iterator y_lower = y_lower_.begin();
+	
+	bool bar = (needs.find("bar") != needs.end());
+	bool area = (needs.find("area") != needs.end());
+	while (  x != x_.end() ) {
+		    	CustomisedPoint* point = new CustomisedPoint();
+
+		    	if ( x != x_.end() ) {
+		    		if ( same(*x, x_missing_) )
+		    			point->missing(true);
+		    		(*point)["x"] = *(x++);
+		    	}
+		    	if ( y != y_.end() ) {
+		    		if ( same(*y, y_missing_) )
+		    			point->missing(true);
+		    		(*point)["y"] = *(y++);
+		    	}
+
+		    	if (bar) {
+		    		if ( x_lower != x_lower_.end() ) {
+		    			if ( same(*x_lower, x_missing_) )
+							point->missing(true);
+						(*point)["x_lower"] = *(x_lower++);
+					}
+					if ( y_lower != y_lower_.end() ) {
+						if ( same(*y_lower, y_missing_) )
+						   point->missing(true);
+						(*point)["y_lower"] = *(y_lower++);
+					}
+					if ( x_upper != x_upper_.end() ) {
+						if ( same(*x_upper, x_missing_) )
+							point->missing(true);
+						(*point)["x_upper"] = *(x_upper++);
+					}
+					if ( y_upper != y_upper_.end() ) {
+						if ( same(*y_upper, y_missing_) )
+							   point->missing(true);
+						(*point)["y_upper"] = *(y_upper++);
+					}
+		    	}
+		    	out.push_back(point);
+		    }
+
+	// now we add the lower values in case one!
+	if ( needs.find("area")  == needs.end() )
+		return;
+
+	while (  x2 != x2_.rend() || y2 != y2_.rend()  ) {
+		CustomisedPoint* point = new CustomisedPoint();
+			    		if ( same(*x2, x_missing_) )
+			    			point->missing(true);
+			    		(*point)["x"] = *(x2++);
+
+			    		if ( same(*y2, y_missing_) )
+			    			point->missing(true);
+			    		(*point)["y"] = *(y2++);
+
+
+			    	if (bar) {
+			    		if ( x_lower != x_lower_.end() ) {
+			    			if ( same(*x_lower, x_missing_) )
+								point->missing(true);
+							(*point)["x_lower"] = *(x_lower++);
+						}
+						if ( y_lower != y_lower_.end() ) {
+							if ( same(*y_lower, y_missing_) )
+							   point->missing(true);
+							(*point)["y_lower"] = *(y_lower++);
+						}
+						if ( x_upper != x_upper_.end() ) {
+							if ( same(*x_upper, x_missing_) )
+								point->missing(true);
+							(*point)["x_upper"] = *(x_upper++);
+						}
+						if ( y_upper != y_upper_.end() ) {
+							if ( same(*y_upper, y_missing_) )
+								   point->missing(true);
+							(*point)["y_upper"] = *(y_upper++);
+						}
+			    	}
+			    	out.push_back(point);
+	}
+}
+
+
+void XYList::customisedPoints(const Transformation&, const std::set<string>& s, CustomisedPointsList& out)
+{
+  customisedPoints(s, out);
+}
+
+double offset(const string& val)
+{
+	static map<string, double> offsets;
+	if ( offsets.empty() ) {
+		offsets["hours"] = 3600;
+		offsets["hour"] = 3600;
+		offsets["days"] = 3600*24;
+		offsets["day"] = 3600*24;
+		offsets["minute"] = 60;
+		offsets["minutes"] = 60;
+		offsets["second"] = 1;
+	}
+	map<string, double>::iterator off = offsets.find(lowerCase(val));
+	return ( off !=  offsets.end() ) ?  off->second : 1;
+}
+
+void XYList::getReady(const Transformation& transformation)
+{
+	try {
+		if ( transformation.xAxisType() == "date" ) {
+		// Fisrt create the x_date if base date and offset are used!
+		if ( x_date_.empty() && !x_base_.empty() ) {
+			DateTime base(x_base_);
+			double off = offset(x_offset_);
+			for ( vector<double>::const_iterator x = x_.begin(); x != x_.end(); ++x ) {
+				DateTime date(base + Second((*x)*off));
+				x_date_.push_back(date);
+			}
+		}
+		if ( !x_date_.empty() ) 
+			x_.clear();
+		for ( vector<string>::const_iterator x = x_date_.begin(); x != x_date_.end(); ++x )
+			x_.push_back(transformation.x(*x));
+		}
+	}
+	catch (...) {}
+	try {
+		// Fisrt create the x_date if base date and offset are used!
+		if ( transformation.yAxisType() == "date" ) {
+		if ( y_date_.empty() && !y_base_.empty() ) {
+			DateTime base(y_base_);
+			double off = offset(y_offset_);
+			for ( vector<double>::const_iterator y = y_.begin(); y != y_.end(); ++y ) {
+				DateTime date(base + Second((*y)*off));
+				y_date_.push_back(date);
+			}
+		}
+		if ( !y_date_.empty() ) 
+			y_.clear();
+		for ( vector<string>::const_iterator y = y_date_.begin(); y != y_date_.end(); ++y )
+			y_.push_back(transformation.y(*y));
+		}
+	}
+	catch (...) {}
+	
+	try {
+		for ( vector<string>::const_iterator x = x2_date_.begin(); x != x2_date_.end(); ++x )
+			x2_.push_back(transformation.x(*x));
+		}
+	catch (...) {}
+	try {
+		for ( vector<string>::const_iterator y = y2_date_.begin(); y != y2_date_.end(); ++y )
+			y2_.push_back(transformation.y(*y));
+	}
+	catch (...) {}
+
+	try {
+		for ( vector<string>::const_iterator x = x_upper_date_.begin(); x !=x_upper_date_.end(); ++x )
+			x_upper_.push_back(transformation.x(*x));
+		}
+	catch (...) {}
+	try {
+		for ( vector<string>::const_iterator y = y_upper_date_.begin(); y != y_upper_date_.end(); ++y )
+			y_upper_.push_back(transformation.y(*y));
+	}
+	catch (...) {}
+
+	try {
+		for ( vector<string>::const_iterator x = x_lower_date_.begin(); x != x_lower_date_.end(); ++x )
+			x_lower_.push_back(transformation.x(*x));
+		}
+	catch (...) {}
+	try {
+		for ( vector<string>::const_iterator y = y_lower_date_.begin(); y != y_lower_date_.end(); ++y )
+			y_lower_.push_back(transformation.y(*y));
+	}
+	catch (...) {}
+}
+
+
+
+void XYList::visit(Transformation& transformation)
+{
+	// get the data ...
+	try {
+		this->prepare();
+
+				if ( transformation.getAutomaticX() ) {
+					transformation.setMinX(*std::min_element(this->x_.begin(), this->x_.end()));
+					transformation.setMaxX(*std::max_element(this->x_.begin(), this->x_.end()));
+				}
+				if ( transformation.getAutomaticY() ) {
+					transformation.setMinY(*std::min_element(this->y_.begin(), this->y_.end()));
+					transformation.setMaxY(*std::max_element(this->y_.begin(), this->y_.end()));
+				}
+			}
+			catch ( ... )
+			{
+			}
+}
+
+
+void XYList::points(const Transformation&, vector<UserPoint>& data)
+{
+	// here the data are already ready!
+	data.reserve(x_.size());
+	vector<double>::const_iterator x = x_.begin();
+	vector<double>::const_iterator y = y_.begin();
+	while (  x != x_.end() && y != y_.end() ) {
+		UserPoint point(*x, *y);
+		if (*x == this->x_missing_ || *y == this->y_missing_ )
+			point.flagMissing();
+		data.push_back(point);
+	    ++x;
+	    ++y;
+	}
+
+}
diff --git a/src/decoders/XYList.h b/src/decoders/XYList.h
new file mode 100644
index 0000000..733048a
--- /dev/null
+++ b/src/decoders/XYList.h
@@ -0,0 +1,99 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file XYList.h
+    \brief Definition of the Template class XYList.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 6-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef XYList_H
+#define XYList_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "Data.h"
+#include "XYListAttributes.h"
+#include "UserPoint.h"
+
+
+namespace magics {
+
+
+class XYList: public Data,
+              public XYListAttributes, 
+              public PointsList
+{
+public:
+	XYList() {}
+	virtual ~XYList() {}
+
+	void prepare();
+	void set(const map<string, string>& map ) { XYListAttributes::set(map); }
+	void set(const XmlNode& node ) { XYListAttributes::set(node); }
+	void visit(Transformation& transformation);
+
+
+	PointsHandler& points(const Transformation&)  {
+	    	prepare();
+	    	this->pointsHandlers_.push_back(new PointsHandler(*this));
+	    	return *(this->pointsHandlers_.back());
+	    } 
+	
+	PointsHandler& points(){
+		prepare();
+		this->pointsHandlers_.push_back(new PointsHandler(*this));
+		return *(this->pointsHandlers_.back());
+	}
+
+	virtual void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	virtual void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& );
+	void getReady(const Transformation&);
+	virtual void points(const Transformation&, vector<UserPoint>&);
+
+	void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	{
+		customisedPoints(t, n, out);
+	}
+	PointsHandler& points(const Transformation& t, bool) { return points(t); }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	XYList(const XYList&);
+    //! Overloaded << operator to copy - No copy allowed
+	XYList& operator=(const XYList&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const XYList& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/decoders/dbfopen.c b/src/decoders/dbfopen.c
new file mode 100644
index 0000000..43b25ac
--- /dev/null
+++ b/src/decoders/dbfopen.c
@@ -0,0 +1,1495 @@
+/******************************************************************************
+ * $Id: dbfopen.c,v 1.48 2003/03/10 14:51:27 warmerda Exp $
+ *
+ * Project:  Shapelib
+ * Purpose:  Implementation of .dbf access API documented in dbf_api.html.
+ * Author:   Frank Warmerdam, warmerdam at pobox.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * This software is available under the following "MIT Style" license,
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
+ * option is discussed in more detail in shapelib.html.
+ *
+ * --
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: dbfopen.c,v $
+ * Revision 1.48  2003/03/10 14:51:27  warmerda
+ * DBFWrite* calls now return FALSE if they have to truncate
+ *
+ * Revision 1.47  2002/11/20 03:32:22  warmerda
+ * Ensure field name in DBFGetFieldIndex() is properly terminated.
+ *
+ * Revision 1.46  2002/10/09 13:10:21  warmerda
+ * Added check that width is positive.
+ *
+ * Revision 1.45  2002/09/29 00:00:08  warmerda
+ * added FTLogical and logical attribute read/write calls
+ *
+ * Revision 1.44  2002/05/07 13:46:11  warmerda
+ * Added DBFWriteAttributeDirectly().
+ *
+ * Revision 1.43  2002/02/13 19:39:21  warmerda
+ * Fix casting issues in DBFCloneEmpty().
+ *
+ * Revision 1.42  2002/01/15 14:36:07  warmerda
+ * updated email address
+ *
+ * Revision 1.41  2002/01/15 14:31:49  warmerda
+ * compute rather than copying nHeaderLength in DBFCloneEmpty()
+ *
+ * Revision 1.40  2002/01/09 04:32:35  warmerda
+ * fixed to read correct amount of header
+ *
+ * Revision 1.39  2001/12/11 22:41:03  warmerda
+ * improve io related error checking when reading header
+ *
+ * Revision 1.38  2001/11/28 16:07:31  warmerda
+ * Cleanup to avoid compiler warnings as suggested by Richard Hash.
+ *
+ * Revision 1.37  2001/07/04 05:18:09  warmerda
+ * do last fix properly
+ *
+ * Revision 1.36  2001/07/04 05:16:09  warmerda
+ * fixed fieldname comparison in DBFGetFieldIndex
+ *
+ * Revision 1.35  2001/06/22 02:10:06  warmerda
+ * fixed NULL shape support with help from Jim Matthews
+ *
+ * Revision 1.33  2001/05/31 19:20:13  warmerda
+ * added DBFGetFieldIndex()
+ *
+ * Revision 1.32  2001/05/31 18:15:40  warmerda
+ * Added support for NULL fields in DBF files
+ *
+ * Revision 1.31  2001/05/23 13:36:52  warmerda
+ * added use of SHPAPI_CALL
+ *
+ * Revision 1.30  2000/12/05 14:43:38  warmerda
+ * DBReadAttribute() white space trimming bug fix
+ *
+ * Revision 1.29  2000/10/05 14:36:44  warmerda
+ * fix bug with writing very wide numeric fields
+ *
+ * Revision 1.28  2000/09/25 14:18:07  warmerda
+ * Added some casts of strlen() return result to fix warnings on some
+ * systems, as submitted by Daniel.
+ *
+ * Revision 1.27  2000/09/25 14:15:51  warmerda
+ * added DBFGetNativeFieldType()
+ *
+ * Revision 1.26  2000/07/07 13:39:45  warmerda
+ * removed unused variables, and added system include files
+ *
+ * Revision 1.25  2000/05/29 18:19:13  warmerda
+ * avoid use of uchar, and adding casting fix
+ *
+ * Revision 1.24  2000/05/23 13:38:27  warmerda
+ * Added error checks on return results of fread() and fseek().
+ *
+ * Revision 1.23  2000/05/23 13:25:49  warmerda
+ * Avoid crashing if field or record are out of range in dbfread*attribute().
+ *
+ * Revision 1.22  1999/12/15 13:47:24  warmerda
+ * Added stdlib.h to ensure that atof() is prototyped.
+ *
+ * Revision 1.21  1999/12/13 17:25:46  warmerda
+ * Added support for upper case .DBF extention.
+ *
+ * Revision 1.20  1999/11/30 16:32:11  warmerda
+ * Use atof() instead of sscanf().
+ *
+ * Revision 1.19  1999/11/05 14:12:04  warmerda
+ * updated license terms
+ *
+ * Revision 1.18  1999/07/27 00:53:28  warmerda
+ * ensure that whole old field value clear on write of string
+ *
+ * Revision 1.1  1999/07/05 18:58:07  warmerda
+ * New
+ *
+ * Revision 1.17  1999/06/11 19:14:12  warmerda
+ * Fixed some memory leaks.
+ *
+ * Revision 1.16  1999/06/11 19:04:11  warmerda
+ * Remoted some unused variables.
+ *
+ * Revision 1.15  1999/05/11 03:19:28  warmerda
+ * added new Tuple api, and improved extension handling - add from candrsn
+ *
+ * Revision 1.14  1999/05/04 15:01:48  warmerda
+ * Added 'F' support.
+ *
+ * Revision 1.13  1999/03/23 17:38:59  warmerda
+ * DBFAddField() now actually does return the new field number, or -1 if
+ * it fails.
+ *
+ * Revision 1.12  1999/03/06 02:54:46  warmerda
+ * Added logic to convert shapefile name to dbf filename in DBFOpen()
+ * for convenience.
+ *
+ * Revision 1.11  1998/12/31 15:30:34  warmerda
+ * Improved the interchangability of numeric and string attributes.  Add
+ * white space trimming option for attributes.
+ *
+ * Revision 1.10  1998/12/03 16:36:44  warmerda
+ * Use r+b instead of rb+ for binary access.
+ *
+ * Revision 1.9  1998/12/03 15:34:23  warmerda
+ * Updated copyright message.
+ *
+ * Revision 1.8  1997/12/04 15:40:15  warmerda
+ * Added newline character after field definitions.
+ *
+ * Revision 1.7  1997/03/06 14:02:10  warmerda
+ * Ensure bUpdated is initialized.
+ *
+ * Revision 1.6  1996/02/12 04:54:41  warmerda
+ * Ensure that DBFWriteAttribute() returns TRUE if it succeeds.
+ *
+ * Revision 1.5  1995/10/21  03:15:12  warmerda
+ * Changed to use binary file access, and ensure that the
+ * field name field is zero filled, and limited to 10 chars.
+ *
+ * Revision 1.4  1995/08/24  18:10:42  warmerda
+ * Added use of SfRealloc() to avoid pre-ANSI realloc() functions such
+ * as on the Sun.
+ *
+ * Revision 1.3  1995/08/04  03:15:16  warmerda
+ * Fixed up header.
+ *
+ * Revision 1.2  1995/08/04  03:14:43  warmerda
+ * Added header.
+ */
+
+static char rcsid[] = 
+  "$Id: dbfopen.c,v 1.48 2003/03/10 14:51:27 warmerda Exp $";
+
+#include "shapefil.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+
+#ifndef FALSE
+#  define FALSE		0
+#  define TRUE		1
+#endif
+
+static int	nStringFieldLen = 0;
+static char * pszStringField = NULL;
+
+/************************************************************************/
+/*                             SfRealloc()                              */
+/*                                                                      */
+/*      A realloc cover function that will access a NULL pointer as     */
+/*      a valid input.                                                  */
+/************************************************************************/
+
+static void * SfRealloc( void * pMem, int nNewSize )
+
+{
+    if( pMem == NULL )
+        return( (void *) malloc(nNewSize) );
+    else
+        return( (void *) realloc(pMem,nNewSize) );
+}
+
+/************************************************************************/
+/*                           DBFWriteHeader()                           */
+/*                                                                      */
+/*      This is called to write out the file header, and field          */
+/*      descriptions before writing any actual data records.  This      */
+/*      also computes all the DBFDataSet field offset/size/decimals     */
+/*      and so forth values.                                            */
+/************************************************************************/
+
+static void DBFWriteHeader(DBFHandle psDBF)
+
+{
+    unsigned char	abyHeader[XBASE_FLDHDR_SZ];
+    int		i;
+
+    if( !psDBF->bNoHeader )
+        return;
+
+    psDBF->bNoHeader = FALSE;
+
+/* -------------------------------------------------------------------- */
+/*	Initialize the file header information.				*/
+/* -------------------------------------------------------------------- */
+    for( i = 0; i < XBASE_FLDHDR_SZ; i++ )
+        abyHeader[i] = 0;
+
+    abyHeader[0] = 0x03;		/* memo field? - just copying 	*/
+
+    /* date updated on close, record count preset at zero */
+
+    abyHeader[8] = psDBF->nHeaderLength % 256;
+    abyHeader[9] = psDBF->nHeaderLength / 256;
+    
+    abyHeader[10] = psDBF->nRecordLength % 256;
+    abyHeader[11] = psDBF->nRecordLength / 256;
+
+/* -------------------------------------------------------------------- */
+/*      Write the initial 32 byte file header, and all the field        */
+/*      descriptions.                                     		*/
+/* -------------------------------------------------------------------- */
+    fseek( psDBF->fp, 0, 0 );
+    fwrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp );
+    fwrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp );
+
+/* -------------------------------------------------------------------- */
+/*      Write out the newline character if there is room for it.        */
+/* -------------------------------------------------------------------- */
+    if( psDBF->nHeaderLength > 32*psDBF->nFields + 32 )
+    {
+        char	cNewline;
+
+        cNewline = 0x0d;
+        fwrite( &cNewline, 1, 1, psDBF->fp );
+    }
+}
+
+/************************************************************************/
+/*                           DBFFlushRecord()                           */
+/*                                                                      */
+/*      Write out the current record if there is one.                   */
+/************************************************************************/
+
+static void DBFFlushRecord( DBFHandle psDBF )
+
+{
+    int		nRecordOffset;
+
+    if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
+    {
+	psDBF->bCurrentRecordModified = FALSE;
+
+	nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord 
+	                                             + psDBF->nHeaderLength;
+
+	fseek( psDBF->fp, nRecordOffset, 0 );
+	fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+    }
+}
+
+/************************************************************************/
+/*                              DBFOpen()                               */
+/*                                                                      */
+/*      Open a .dbf file.                                               */
+/************************************************************************/
+   
+DBFHandle SHPAPI_CALL
+DBFOpen( const char * pszFilename, const char * pszAccess )
+
+{
+    DBFHandle		psDBF;
+    unsigned char		*pabyBuf;
+    int			nFields, nHeadLen, nRecLen, iField, i;
+    char		*pszBasename, *pszFullname;
+
+/* -------------------------------------------------------------------- */
+/*      We only allow the access strings "rb" and "r+".                  */
+/* -------------------------------------------------------------------- */
+    if( strcmp(pszAccess,"r") != 0 && strcmp(pszAccess,"r+") != 0 
+        && strcmp(pszAccess,"rb") != 0 && strcmp(pszAccess,"rb+") != 0
+        && strcmp(pszAccess,"r+b") != 0 )
+        return( NULL );
+
+    if( strcmp(pszAccess,"r") == 0 )
+        pszAccess = "rb";
+ 
+    if( strcmp(pszAccess,"r+") == 0 )
+        pszAccess = "rb+";
+
+/* -------------------------------------------------------------------- */
+/*	Compute the base (layer) name.  If there is any extension	*/
+/*	on the passed in filename we will strip it off.			*/
+/* -------------------------------------------------------------------- */
+    pszBasename = (char *) malloc(strlen(pszFilename)+5);
+    strcpy( pszBasename, pszFilename );
+    for( i = strlen(pszBasename)-1; 
+	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+	       && pszBasename[i] != '\\';
+	 i-- ) {}
+
+    if( pszBasename[i] == '.' )
+        pszBasename[i] = '\0';
+
+    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+    sprintf( pszFullname, "%s.dbf", pszBasename );
+        
+    psDBF = (DBFHandle) calloc( 1, sizeof(DBFInfo) );
+    psDBF->fp = fopen( pszFullname, pszAccess );
+
+    if( psDBF->fp == NULL )
+    {
+        sprintf( pszFullname, "%s.DBF", pszBasename );
+        psDBF->fp = fopen(pszFullname, pszAccess );
+    }
+    
+    free( pszBasename );
+    free( pszFullname );
+    
+    if( psDBF->fp == NULL )
+    {
+        free( psDBF );
+        return( NULL );
+    }
+
+    psDBF->bNoHeader = FALSE;
+    psDBF->nCurrentRecord = -1;
+    psDBF->bCurrentRecordModified = FALSE;
+
+/* -------------------------------------------------------------------- */
+/*  Read Table Header info                                              */
+/* -------------------------------------------------------------------- */
+    pabyBuf = (unsigned char *) malloc(500);
+    if( fread( pabyBuf, 32, 1, psDBF->fp ) != 1 )
+    {
+        fclose( psDBF->fp );
+        free( pabyBuf );
+        free( psDBF );
+        return NULL;
+    }
+
+    psDBF->nRecords = 
+     pabyBuf[4] + pabyBuf[5]*256 + pabyBuf[6]*256*256 + pabyBuf[7]*256*256*256;
+
+    psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9]*256;
+    psDBF->nRecordLength = nRecLen = pabyBuf[10] + pabyBuf[11]*256;
+    
+    psDBF->nFields = nFields = (nHeadLen - 32) / 32;
+
+    psDBF->pszCurrentRecord = (char *) malloc(nRecLen);
+
+/* -------------------------------------------------------------------- */
+/*  Read in Field Definitions                                           */
+/* -------------------------------------------------------------------- */
+    
+    pabyBuf = (unsigned char *) SfRealloc(pabyBuf,nHeadLen);
+    psDBF->pszHeader = (char *) pabyBuf;
+
+    fseek( psDBF->fp, 32, 0 );
+    if( fread( pabyBuf, nHeadLen-32, 1, psDBF->fp ) != 1 )
+    {
+        fclose( psDBF->fp );
+        free( pabyBuf );
+        free( psDBF );
+        return NULL;
+    }
+
+    psDBF->panFieldOffset = (int *) malloc(sizeof(int) * nFields);
+    psDBF->panFieldSize = (int *) malloc(sizeof(int) * nFields);
+    psDBF->panFieldDecimals = (int *) malloc(sizeof(int) * nFields);
+    psDBF->pachFieldType = (char *) malloc(sizeof(char) * nFields);
+
+    for( iField = 0; iField < nFields; iField++ )
+    {
+	unsigned char		*pabyFInfo;
+
+	pabyFInfo = pabyBuf+iField*32;
+
+	if( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' )
+	{
+	    psDBF->panFieldSize[iField] = pabyFInfo[16];
+	    psDBF->panFieldDecimals[iField] = pabyFInfo[17];
+	}
+	else
+	{
+	    psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17]*256;
+	    psDBF->panFieldDecimals[iField] = 0;
+	}
+
+	psDBF->pachFieldType[iField] = (char) pabyFInfo[11];
+	if( iField == 0 )
+	    psDBF->panFieldOffset[iField] = 1;
+	else
+	    psDBF->panFieldOffset[iField] = 
+	      psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1];
+    }
+
+    return( psDBF );
+}
+
+/************************************************************************/
+/*                              DBFClose()                              */
+/************************************************************************/
+
+void SHPAPI_CALL
+DBFClose(DBFHandle psDBF)
+{
+/* -------------------------------------------------------------------- */
+/*      Write out header if not already written.                        */
+/* -------------------------------------------------------------------- */
+    if( psDBF->bNoHeader )
+        DBFWriteHeader( psDBF );
+
+    DBFFlushRecord( psDBF );
+
+/* -------------------------------------------------------------------- */
+/*      Update last access date, and number of records if we have	*/
+/*	write access.                					*/
+/* -------------------------------------------------------------------- */
+    if( psDBF->bUpdated )
+    {
+	unsigned char		abyFileHeader[32];
+
+	fseek( psDBF->fp, 0, 0 );
+	fread( abyFileHeader, 32, 1, psDBF->fp );
+
+	abyFileHeader[1] = 95;			/* YY */
+	abyFileHeader[2] = 7;			/* MM */
+	abyFileHeader[3] = 26;			/* DD */
+
+	abyFileHeader[4] = psDBF->nRecords % 256;
+	abyFileHeader[5] = (psDBF->nRecords/256) % 256;
+	abyFileHeader[6] = (psDBF->nRecords/(256*256)) % 256;
+	abyFileHeader[7] = (psDBF->nRecords/(256*256*256)) % 256;
+
+	fseek( psDBF->fp, 0, 0 );
+	fwrite( abyFileHeader, 32, 1, psDBF->fp );
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Close, and free resources.                                      */
+/* -------------------------------------------------------------------- */
+    fclose( psDBF->fp );
+
+    if( psDBF->panFieldOffset != NULL )
+    {
+        free( psDBF->panFieldOffset );
+        free( psDBF->panFieldSize );
+        free( psDBF->panFieldDecimals );
+        free( psDBF->pachFieldType );
+    }
+
+    free( psDBF->pszHeader );
+    free( psDBF->pszCurrentRecord );
+
+    free( psDBF );
+
+    if( pszStringField != NULL )
+    {
+        free( pszStringField );
+        pszStringField = NULL;
+        nStringFieldLen = 0;
+    }
+}
+
+/************************************************************************/
+/*                             DBFCreate()                              */
+/*                                                                      */
+/*      Create a new .dbf file.                                         */
+/************************************************************************/
+
+DBFHandle SHPAPI_CALL
+DBFCreate( const char * pszFilename )
+
+{
+    DBFHandle	psDBF;
+    FILE	*fp;
+    char	*pszFullname, *pszBasename;
+    int		i;
+
+/* -------------------------------------------------------------------- */
+/*	Compute the base (layer) name.  If there is any extension	*/
+/*	on the passed in filename we will strip it off.			*/
+/* -------------------------------------------------------------------- */
+    pszBasename = (char *) malloc(strlen(pszFilename)+5);
+    strcpy( pszBasename, pszFilename );
+    for( i = strlen(pszBasename)-1; 
+	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+	       && pszBasename[i] != '\\';
+	 i-- ) {}
+
+    if( pszBasename[i] == '.' )
+        pszBasename[i] = '\0';
+
+    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+    sprintf( pszFullname, "%s.dbf", pszBasename );
+    free( pszBasename );
+
+/* -------------------------------------------------------------------- */
+/*      Create the file.                                                */
+/* -------------------------------------------------------------------- */
+    fp = fopen( pszFullname, "wb" );
+    if( fp == NULL )
+        return( NULL );
+
+    fputc( 0, fp );
+    fclose( fp );
+
+    fp = fopen( pszFullname, "rb+" );
+    if( fp == NULL )
+        return( NULL );
+
+    free( pszFullname );
+
+/* -------------------------------------------------------------------- */
+/*	Create the info structure.					*/
+/* -------------------------------------------------------------------- */
+    psDBF = (DBFHandle) malloc(sizeof(DBFInfo));
+
+    psDBF->fp = fp;
+    psDBF->nRecords = 0;
+    psDBF->nFields = 0;
+    psDBF->nRecordLength = 1;
+    psDBF->nHeaderLength = 33;
+    
+    psDBF->panFieldOffset = NULL;
+    psDBF->panFieldSize = NULL;
+    psDBF->panFieldDecimals = NULL;
+    psDBF->pachFieldType = NULL;
+    psDBF->pszHeader = NULL;
+
+    psDBF->nCurrentRecord = -1;
+    psDBF->bCurrentRecordModified = FALSE;
+    psDBF->pszCurrentRecord = NULL;
+
+    psDBF->bNoHeader = TRUE;
+
+    return( psDBF );
+}
+
+/************************************************************************/
+/*                            DBFAddField()                             */
+/*                                                                      */
+/*      Add a field to a newly created .dbf file before any records     */
+/*      are written.                                                    */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFAddField(DBFHandle psDBF, const char * pszFieldName, 
+            DBFFieldType eType, int nWidth, int nDecimals )
+
+{
+    char	*pszFInfo;
+    int		i;
+
+/* -------------------------------------------------------------------- */
+/*      Do some checking to ensure we can add records to this file.     */
+/* -------------------------------------------------------------------- */
+    if( psDBF->nRecords > 0 )
+        return( -1 );
+
+    if( !psDBF->bNoHeader )
+        return( -1 );
+
+    if( eType != FTDouble && nDecimals != 0 )
+        return( -1 );
+
+    if( nWidth < 1 )
+        return -1;
+
+/* -------------------------------------------------------------------- */
+/*      SfRealloc all the arrays larger to hold the additional field      */
+/*      information.                                                    */
+/* -------------------------------------------------------------------- */
+    psDBF->nFields++;
+
+    psDBF->panFieldOffset = (int *) 
+      SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
+
+    psDBF->panFieldSize = (int *) 
+      SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
+
+    psDBF->panFieldDecimals = (int *) 
+      SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
+
+    psDBF->pachFieldType = (char *) 
+      SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields );
+
+/* -------------------------------------------------------------------- */
+/*      Assign the new field information fields.                        */
+/* -------------------------------------------------------------------- */
+    psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength;
+    psDBF->nRecordLength += nWidth;
+    psDBF->panFieldSize[psDBF->nFields-1] = nWidth;
+    psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals;
+
+    if( eType == FTLogical )
+        psDBF->pachFieldType[psDBF->nFields-1] = 'L';
+    else if( eType == FTString )
+        psDBF->pachFieldType[psDBF->nFields-1] = 'C';
+    else
+        psDBF->pachFieldType[psDBF->nFields-1] = 'N';
+
+/* -------------------------------------------------------------------- */
+/*      Extend the required header information.                         */
+/* -------------------------------------------------------------------- */
+    psDBF->nHeaderLength += 32;
+    psDBF->bUpdated = FALSE;
+
+    psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,psDBF->nFields*32);
+
+    pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields-1);
+
+    for( i = 0; i < 32; i++ )
+        pszFInfo[i] = '\0';
+
+    if( (int) strlen(pszFieldName) < 10 )
+        strncpy( pszFInfo, pszFieldName, strlen(pszFieldName));
+    else
+        strncpy( pszFInfo, pszFieldName, 10);
+
+    pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1];
+
+    if( eType == FTString )
+    {
+        pszFInfo[16] = nWidth % 256;
+        pszFInfo[17] = nWidth / 256;
+    }
+    else
+    {
+        pszFInfo[16] = nWidth;
+        pszFInfo[17] = nDecimals;
+    }
+    
+/* -------------------------------------------------------------------- */
+/*      Make the current record buffer appropriately larger.            */
+/* -------------------------------------------------------------------- */
+    psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
+					       psDBF->nRecordLength);
+
+    return( psDBF->nFields-1 );
+}
+
+/************************************************************************/
+/*                          DBFReadAttribute()                          */
+/*                                                                      */
+/*      Read one of the attribute fields of a record.                   */
+/************************************************************************/
+
+static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
+                              char chReqType )
+
+{
+    int	       	nRecordOffset;
+    unsigned char	*pabyRec;
+    void	*pReturnField = NULL;
+
+    static double dDoubleField;
+
+/* -------------------------------------------------------------------- */
+/*      Verify selection.                                               */
+/* -------------------------------------------------------------------- */
+    if( hEntity < 0 || hEntity >= psDBF->nRecords )
+        return( NULL );
+
+    if( iField < 0 || iField >= psDBF->nFields )
+        return( NULL );
+
+/* -------------------------------------------------------------------- */
+/*	Have we read the record?					*/
+/* -------------------------------------------------------------------- */
+    if( psDBF->nCurrentRecord != hEntity )
+    {
+	DBFFlushRecord( psDBF );
+
+	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+	if( fseek( psDBF->fp, nRecordOffset, 0 ) != 0 )
+        {
+            fprintf( stderr, "fseek(%d) failed on DBF file.\n",
+                     nRecordOffset );
+            return NULL;
+        }
+
+	if( fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 
+                   1, psDBF->fp ) != 1 )
+        {
+            fprintf( stderr, "fread(%d) failed on DBF file.\n",
+                     psDBF->nRecordLength );
+            return NULL;
+        }
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+/* -------------------------------------------------------------------- */
+/*	Ensure our field buffer is large enough to hold this buffer.	*/
+/* -------------------------------------------------------------------- */
+    if( psDBF->panFieldSize[iField]+1 > nStringFieldLen )
+    {
+	nStringFieldLen = psDBF->panFieldSize[iField]*2 + 10;
+	pszStringField = (char *) SfRealloc(pszStringField,nStringFieldLen);
+    }
+
+/* -------------------------------------------------------------------- */
+/*	Extract the requested field.					*/
+/* -------------------------------------------------------------------- */
+    strncpy( pszStringField, 
+	     ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
+	     psDBF->panFieldSize[iField] );
+    pszStringField[psDBF->panFieldSize[iField]] = '\0';
+
+    pReturnField = pszStringField;
+
+/* -------------------------------------------------------------------- */
+/*      Decode the field.                                               */
+/* -------------------------------------------------------------------- */
+    if( chReqType == 'N' )
+    {
+        dDoubleField = atof(pszStringField);
+
+	pReturnField = &dDoubleField;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Should we trim white space off the string attribute value?      */
+/* -------------------------------------------------------------------- */
+#ifdef TRIM_DBF_WHITESPACE
+    else
+    {
+        char	*pchSrc, *pchDst;
+
+        pchDst = pchSrc = pszStringField;
+        while( *pchSrc == ' ' )
+            pchSrc++;
+
+        while( *pchSrc != '\0' )
+            *(pchDst++) = *(pchSrc++);
+        *pchDst = '\0';
+
+        while( pchDst != pszStringField && *(--pchDst) == ' ' )
+            *pchDst = '\0';
+    }
+#endif
+    
+    return( pReturnField );
+}
+
+/************************************************************************/
+/*                        DBFReadIntAttribute()                         */
+/*                                                                      */
+/*      Read an integer attribute.                                      */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+    double	*pdValue;
+
+    pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
+
+    if( pdValue == NULL )
+        return 0;
+    else
+        return( (int) *pdValue );
+}
+
+/************************************************************************/
+/*                        DBFReadDoubleAttribute()                      */
+/*                                                                      */
+/*      Read a double attribute.                                        */
+/************************************************************************/
+
+double SHPAPI_CALL
+DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+    double	*pdValue;
+
+    pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
+
+    if( pdValue == NULL )
+        return 0.0;
+    else
+        return( *pdValue );
+}
+
+/************************************************************************/
+/*                        DBFReadStringAttribute()                      */
+/*                                                                      */
+/*      Read a string attribute.                                        */
+/************************************************************************/
+
+const char SHPAPI_CALL1(*)
+DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+    return( (const char *) DBFReadAttribute( psDBF, iRecord, iField, 'C' ) );
+}
+
+/************************************************************************/
+/*                        DBFReadLogicalAttribute()                     */
+/*                                                                      */
+/*      Read a logical attribute.                                       */
+/************************************************************************/
+
+const char SHPAPI_CALL1(*)
+DBFReadLogicalAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+    return( (const char *) DBFReadAttribute( psDBF, iRecord, iField, 'L' ) );
+}
+
+/************************************************************************/
+/*                         DBFIsAttributeNULL()                         */
+/*                                                                      */
+/*      Return TRUE if value for field is NULL.                         */
+/*                                                                      */
+/*      Contributed by Jim Matthews.                                    */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField )
+
+{
+    const char	*pszValue;
+
+    pszValue = DBFReadStringAttribute( psDBF, iRecord, iField );
+
+    switch(psDBF->pachFieldType[iField])
+    {
+      case 'N':
+      case 'F':
+        /* NULL numeric fields have value "****************" */
+        return pszValue[0] == '*';
+
+      case 'D':
+        /* NULL date fields have value "00000000" */
+        return strncmp(pszValue,"00000000",8) == 0;
+
+      case 'L':
+        /* NULL boolean fields have value "?" */ 
+        return pszValue[0] == '?';
+
+      default:
+        /* empty string fields are considered NULL */
+        return strlen(pszValue) == 0;
+    }
+}
+
+/************************************************************************/
+/*                          DBFGetFieldCount()                          */
+/*                                                                      */
+/*      Return the number of fields in this table.                      */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFGetFieldCount( DBFHandle psDBF )
+
+{
+    return( psDBF->nFields );
+}
+
+/************************************************************************/
+/*                         DBFGetRecordCount()                          */
+/*                                                                      */
+/*      Return the number of records in this table.                     */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFGetRecordCount( DBFHandle psDBF )
+
+{
+    return( psDBF->nRecords );
+}
+
+/************************************************************************/
+/*                          DBFGetFieldInfo()                           */
+/*                                                                      */
+/*      Return any requested information about the field.               */
+/************************************************************************/
+
+DBFFieldType SHPAPI_CALL
+DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName,
+                 int * pnWidth, int * pnDecimals )
+
+{
+    if( iField < 0 || iField >= psDBF->nFields )
+        return( FTInvalid );
+
+    if( pnWidth != NULL )
+        *pnWidth = psDBF->panFieldSize[iField];
+
+    if( pnDecimals != NULL )
+        *pnDecimals = psDBF->panFieldDecimals[iField];
+
+    if( pszFieldName != NULL )
+    {
+	int	i;
+
+	strncpy( pszFieldName, (char *) psDBF->pszHeader+iField*32, 11 );
+	pszFieldName[11] = '\0';
+	for( i = 10; i > 0 && pszFieldName[i] == ' '; i-- )
+	    pszFieldName[i] = '\0';
+    }
+
+    if ( psDBF->pachFieldType[iField] == 'L' )
+	return( FTLogical);
+
+    else if( psDBF->pachFieldType[iField] == 'N' 
+             || psDBF->pachFieldType[iField] == 'F'
+             || psDBF->pachFieldType[iField] == 'D' )
+    {
+	if( psDBF->panFieldDecimals[iField] > 0 )
+	    return( FTDouble );
+	else
+	    return( FTInteger );
+    }
+    else
+    {
+	return( FTString );
+    }
+}
+
+/************************************************************************/
+/*                         DBFWriteAttribute()                          */
+/*									*/
+/*	Write an attribute record to the file.				*/
+/************************************************************************/
+
+static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField,
+			     void * pValue )
+
+{
+    int	       	nRecordOffset, i, j, nRetResult = TRUE;
+    unsigned char	*pabyRec;
+    char	szSField[400], szFormat[20];
+
+/* -------------------------------------------------------------------- */
+/*	Is this a valid record?						*/
+/* -------------------------------------------------------------------- */
+    if( hEntity < 0 || hEntity > psDBF->nRecords )
+        return( FALSE );
+
+    if( psDBF->bNoHeader )
+        DBFWriteHeader(psDBF);
+
+/* -------------------------------------------------------------------- */
+/*      Is this a brand new record?                                     */
+/* -------------------------------------------------------------------- */
+    if( hEntity == psDBF->nRecords )
+    {
+	DBFFlushRecord( psDBF );
+
+	psDBF->nRecords++;
+	for( i = 0; i < psDBF->nRecordLength; i++ )
+	    psDBF->pszCurrentRecord[i] = ' ';
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Is this an existing record, but different than the last one     */
+/*      we accessed?                                                    */
+/* -------------------------------------------------------------------- */
+    if( psDBF->nCurrentRecord != hEntity )
+    {
+	DBFFlushRecord( psDBF );
+
+	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+	fseek( psDBF->fp, nRecordOffset, 0 );
+	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+    psDBF->bCurrentRecordModified = TRUE;
+    psDBF->bUpdated = TRUE;
+
+/* -------------------------------------------------------------------- */
+/*      Translate NULL value to valid DBF file representation.          */
+/*                                                                      */
+/*      Contributed by Jim Matthews.                                    */
+/* -------------------------------------------------------------------- */
+    if( pValue == NULL )
+    {
+        switch(psDBF->pachFieldType[iField])
+        {
+          case 'N':
+          case 'F':
+	    /* NULL numeric fields have value "****************" */
+            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '*', 
+                    psDBF->panFieldSize[iField] );
+            break;
+
+          case 'D':
+	    /* NULL date fields have value "00000000" */
+            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '0', 
+                    psDBF->panFieldSize[iField] );
+            break;
+
+          case 'L':
+	    /* NULL boolean fields have value "?" */ 
+            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '?', 
+                    psDBF->panFieldSize[iField] );
+            break;
+
+          default:
+            /* empty string fields are considered NULL */
+            memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '\0', 
+                    psDBF->panFieldSize[iField] );
+            break;
+        }
+        return TRUE;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Assign all the record fields.                                   */
+/* -------------------------------------------------------------------- */
+    switch( psDBF->pachFieldType[iField] )
+    {
+      case 'D':
+      case 'N':
+      case 'F':
+	if( psDBF->panFieldDecimals[iField] == 0 )
+	{
+            int		nWidth = psDBF->panFieldSize[iField];
+
+            if( sizeof(szSField)-2 < nWidth )
+                nWidth = sizeof(szSField)-2;
+
+	    sprintf( szFormat, "%%%dd", nWidth );
+	    sprintf(szSField, szFormat, (int) *((double *) pValue) );
+	    if( (int)strlen(szSField) > psDBF->panFieldSize[iField] )
+            {
+	        szSField[psDBF->panFieldSize[iField]] = '\0';
+                nRetResult = FALSE;
+            }
+
+	    strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+		    szSField, strlen(szSField) );
+	}
+	else
+	{
+            int		nWidth = psDBF->panFieldSize[iField];
+
+            if( sizeof(szSField)-2 < nWidth )
+                nWidth = sizeof(szSField)-2;
+
+	    sprintf( szFormat, "%%%d.%df", 
+                     nWidth, psDBF->panFieldDecimals[iField] );
+	    sprintf(szSField, szFormat, *((double *) pValue) );
+	    if( (int) strlen(szSField) > psDBF->panFieldSize[iField] )
+            {
+	        szSField[psDBF->panFieldSize[iField]] = '\0';
+                nRetResult = FALSE;
+            }
+	    strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+		    szSField, strlen(szSField) );
+	}
+	break;
+
+      case 'L':
+        if (psDBF->panFieldSize[iField] >= 1  && 
+            (*(char*)pValue == 'F' || *(char*)pValue == 'T'))
+            *(pabyRec+psDBF->panFieldOffset[iField]) = *(char*)pValue;
+        break;
+
+      default:
+	if( (int) strlen((char *) pValue) > psDBF->panFieldSize[iField] )
+        {
+	    j = psDBF->panFieldSize[iField];
+            nRetResult = FALSE;
+        }
+	else
+        {
+            memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
+                    psDBF->panFieldSize[iField] );
+	    j = strlen((char *) pValue);
+        }
+
+	strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+		(char *) pValue, j );
+	break;
+    }
+
+    return( nRetResult );
+}
+
+/************************************************************************/
+/*                     DBFWriteAttributeDirectly()                      */
+/*                                                                      */
+/*      Write an attribute record to the file, but without any          */
+/*      reformatting based on type.  The provided buffer is written     */
+/*      as is to the field position in the record.                      */
+/************************************************************************/
+
+int DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField,
+                              void * pValue )
+
+{
+    int	       	nRecordOffset, i, j;
+    unsigned char	*pabyRec;
+
+/* -------------------------------------------------------------------- */
+/*	Is this a valid record?						*/
+/* -------------------------------------------------------------------- */
+    if( hEntity < 0 || hEntity > psDBF->nRecords )
+        return( FALSE );
+
+    if( psDBF->bNoHeader )
+        DBFWriteHeader(psDBF);
+
+/* -------------------------------------------------------------------- */
+/*      Is this a brand new record?                                     */
+/* -------------------------------------------------------------------- */
+    if( hEntity == psDBF->nRecords )
+    {
+	DBFFlushRecord( psDBF );
+
+	psDBF->nRecords++;
+	for( i = 0; i < psDBF->nRecordLength; i++ )
+	    psDBF->pszCurrentRecord[i] = ' ';
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Is this an existing record, but different than the last one     */
+/*      we accessed?                                                    */
+/* -------------------------------------------------------------------- */
+    if( psDBF->nCurrentRecord != hEntity )
+    {
+	DBFFlushRecord( psDBF );
+
+	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+	fseek( psDBF->fp, nRecordOffset, 0 );
+	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+/* -------------------------------------------------------------------- */
+/*      Assign all the record fields.                                   */
+/* -------------------------------------------------------------------- */
+    if( (int)strlen((char *) pValue) > psDBF->panFieldSize[iField] )
+        j = psDBF->panFieldSize[iField];
+    else
+    {
+        memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
+                psDBF->panFieldSize[iField] );
+        j = strlen((char *) pValue);
+    }
+
+    strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
+            (char *) pValue, j );
+
+    psDBF->bCurrentRecordModified = TRUE;
+    psDBF->bUpdated = TRUE;
+
+    return( TRUE );
+}
+
+/************************************************************************/
+/*                      DBFWriteDoubleAttribute()                       */
+/*                                                                      */
+/*      Write a double attribute.                                       */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField,
+                         double dValue )
+
+{
+    return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
+}
+
+/************************************************************************/
+/*                      DBFWriteIntegerAttribute()                      */
+/*                                                                      */
+/*      Write a integer attribute.                                      */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField,
+                          int nValue )
+
+{
+    double	dValue = nValue;
+
+    return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
+}
+
+/************************************************************************/
+/*                      DBFWriteStringAttribute()                       */
+/*                                                                      */
+/*      Write a string attribute.                                       */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField,
+                         const char * pszValue )
+
+{
+    return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) pszValue ) );
+}
+
+/************************************************************************/
+/*                      DBFWriteNULLAttribute()                         */
+/*                                                                      */
+/*      Write a string attribute.                                       */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFWriteNULLAttribute( DBFHandle psDBF, int iRecord, int iField )
+
+{
+    return( DBFWriteAttribute( psDBF, iRecord, iField, NULL ) );
+}
+
+/************************************************************************/
+/*                      DBFWriteLogicalAttribute()                      */
+/*                                                                      */
+/*      Write a logical attribute.                                      */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFWriteLogicalAttribute( DBFHandle psDBF, int iRecord, int iField,
+		       const char lValue)
+
+{
+    return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) (&lValue) ) );
+}
+
+/************************************************************************/
+/*                         DBFWriteTuple()                              */
+/*									*/
+/*	Write an attribute record to the file.				*/
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple )
+
+{
+    int	       	nRecordOffset, i;
+    unsigned char	*pabyRec;
+
+/* -------------------------------------------------------------------- */
+/*	Is this a valid record?						*/
+/* -------------------------------------------------------------------- */
+    if( hEntity < 0 || hEntity > psDBF->nRecords )
+        return( FALSE );
+
+    if( psDBF->bNoHeader )
+        DBFWriteHeader(psDBF);
+
+/* -------------------------------------------------------------------- */
+/*      Is this a brand new record?                                     */
+/* -------------------------------------------------------------------- */
+    if( hEntity == psDBF->nRecords )
+    {
+	DBFFlushRecord( psDBF );
+
+	psDBF->nRecords++;
+	for( i = 0; i < psDBF->nRecordLength; i++ )
+	    psDBF->pszCurrentRecord[i] = ' ';
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Is this an existing record, but different than the last one     */
+/*      we accessed?                                                    */
+/* -------------------------------------------------------------------- */
+    if( psDBF->nCurrentRecord != hEntity )
+    {
+	DBFFlushRecord( psDBF );
+
+	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+	fseek( psDBF->fp, nRecordOffset, 0 );
+	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+    memcpy ( pabyRec, pRawTuple,  psDBF->nRecordLength );
+
+    psDBF->bCurrentRecordModified = TRUE;
+    psDBF->bUpdated = TRUE;
+
+    return( TRUE );
+}
+
+/************************************************************************/
+/*                          DBFReadTuple()                              */
+/*                                                                      */
+/*      Read one of the attribute fields of a record.                   */
+/************************************************************************/
+
+const char SHPAPI_CALL1(*)
+DBFReadTuple(DBFHandle psDBF, int hEntity )
+
+{
+    int	       	nRecordOffset;
+    unsigned char	*pabyRec;
+    static char	*pReturnTuple = NULL;
+
+    static int	nTupleLen = 0;
+
+/* -------------------------------------------------------------------- */
+/*	Have we read the record?					*/
+/* -------------------------------------------------------------------- */
+    if( hEntity < 0 || hEntity >= psDBF->nRecords )
+        return( NULL );
+
+    if( psDBF->nCurrentRecord != hEntity )
+    {
+	DBFFlushRecord( psDBF );
+
+	nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength;
+
+	fseek( psDBF->fp, nRecordOffset, 0 );
+	fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+	psDBF->nCurrentRecord = hEntity;
+    }
+
+    pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
+
+    if ( nTupleLen < psDBF->nRecordLength) {
+      nTupleLen = psDBF->nRecordLength;
+      pReturnTuple = (char *) SfRealloc(pReturnTuple, psDBF->nRecordLength);
+    }
+    
+    memcpy ( pReturnTuple, pabyRec, psDBF->nRecordLength );
+        
+    return( pReturnTuple );
+}
+
+/************************************************************************/
+/*                          DBFCloneEmpty()                              */
+/*                                                                      */
+/*      Read one of the attribute fields of a record.                   */
+/************************************************************************/
+
+DBFHandle SHPAPI_CALL
+DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ) 
+{
+    DBFHandle	newDBF;
+
+   newDBF = DBFCreate ( pszFilename );
+   if ( newDBF == NULL ) return ( NULL ); 
+   
+   newDBF->pszHeader = (char *) malloc ( 32 * psDBF->nFields );
+   memcpy ( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields );
+   
+   newDBF->nFields = psDBF->nFields;
+   newDBF->nRecordLength = psDBF->nRecordLength;
+   newDBF->nHeaderLength = 32 * (psDBF->nFields+1);
+    
+   newDBF->panFieldOffset = (int *) malloc ( sizeof(int) * psDBF->nFields ); 
+   memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
+   newDBF->panFieldSize = (int *) malloc ( sizeof(int) * psDBF->nFields );
+   memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
+   newDBF->panFieldDecimals = (int *) malloc ( sizeof(int) * psDBF->nFields );
+   memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
+   newDBF->pachFieldType = (char *) malloc ( sizeof(int) * psDBF->nFields );
+   memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(int) * psDBF->nFields );
+
+   newDBF->bNoHeader = TRUE;
+   newDBF->bUpdated = TRUE;
+   
+   DBFWriteHeader ( newDBF );
+   DBFClose ( newDBF );
+   
+   newDBF = DBFOpen ( pszFilename, "rb+" );
+
+   return ( newDBF );
+}
+
+/************************************************************************/
+/*                       DBFGetNativeFieldType()                        */
+/*                                                                      */
+/*      Return the DBase field type for the specified field.            */
+/*                                                                      */
+/*      Value can be one of: 'C' (String), 'D' (Date), 'F' (Float),     */
+/*                           'N' (Numeric, with or without decimal),    */
+/*                           'L' (Logical),                             */
+/*                           'M' (Memo: 10 digits .DBT block ptr)       */
+/************************************************************************/
+
+char SHPAPI_CALL
+DBFGetNativeFieldType( DBFHandle psDBF, int iField )
+
+{
+    if( iField >=0 && iField < psDBF->nFields )
+        return psDBF->pachFieldType[iField];
+
+    return  ' ';
+}
+
+/************************************************************************/
+/*                            str_to_upper()                            */
+/************************************************************************/
+
+static void str_to_upper (char *string)
+{
+    int len;
+    short i = -1;
+
+    len = strlen (string);
+
+    while (++i < len)
+        if (isalpha(string[i]) && islower(string[i]))
+            string[i] = toupper ((int)string[i]);
+}
+
+/************************************************************************/
+/*                          DBFGetFieldIndex()                          */
+/*                                                                      */
+/*      Get the index number for a field in a .dbf file.                */
+/*                                                                      */
+/*      Contributed by Jim Matthews.                                    */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
+
+{
+    char          name[12], name1[12], name2[12];
+    int           i;
+
+    strncpy(name1, pszFieldName,11);
+    name1[11] = '\0';
+    str_to_upper(name1);
+
+    for( i = 0; i < DBFGetFieldCount(psDBF); i++ )
+    {
+        DBFGetFieldInfo( psDBF, i, name, NULL, NULL );
+        strncpy(name2,name,11);
+        str_to_upper(name2);
+
+        if(!strncmp(name1,name2,10))
+            return(i);
+    }
+    return(-1);
+}
diff --git a/src/decoders/shapefil.h b/src/decoders/shapefil.h
new file mode 100644
index 0000000..80af789
--- /dev/null
+++ b/src/decoders/shapefil.h
@@ -0,0 +1,484 @@
+#ifndef _SHAPEFILE_H_INCLUDED
+#define _SHAPEFILE_H_INCLUDED
+
+/******************************************************************************
+ * $Id: shapefil.h,v 1.26 2002/09/29 00:00:08 warmerda Exp $
+ *
+ * Project:  Shapelib
+ * Purpose:  Primary include file for Shapelib.
+ * Author:   Frank Warmerdam, warmerdam at pobox.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, Frank Warmerdam
+ *
+ * This software is available under the following "MIT Style" license,
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
+ * option is discussed in more detail in shapelib.html.
+ *
+ * --
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $MagLog: shapefil.h,v $
+ * Revision 1.26  2002/09/29 00:00:08  warmerda
+ * added FTMagLogical and logical attribute read/write calls
+ *
+ * Revision 1.25  2002/05/07 13:46:30  warmerda
+ * added DBFWriteAttributeDirectly().
+ *
+ * Revision 1.24  2002/04/10 16:59:54  warmerda
+ * added SHPRewindObject
+ *
+ * Revision 1.23  2002/01/15 14:36:07  warmerda
+ * updated email address
+ *
+ * Revision 1.22  2002/01/15 14:32:00  warmerda
+ * try to improve SHPAPI_CALL docs
+ *
+ * Revision 1.21  2001/11/01 16:29:55  warmerda
+ * move pabyRec into SHPInfo for thread safety
+ *
+ * Revision 1.20  2001/07/20 13:06:02  warmerda
+ * fixed SHPAPI attribute for SHPTreeFindLikelyShapes
+ *
+ * Revision 1.19  2001/05/31 19:20:13  warmerda
+ * added DBFGetFieldIndex()
+ *
+ * Revision 1.18  2001/05/31 18:15:40  warmerda
+ * Added support for NULL fields in DBF files
+ *
+ * Revision 1.17  2001/05/23 13:36:52  warmerda
+ * added use of SHPAPI_CALL
+ *
+ * Revision 1.16  2000/09/25 14:15:59  warmerda
+ * added DBFGetNativeFieldType()
+ *
+ * Revision 1.15  2000/02/16 16:03:51  warmerda
+ * added null shape support
+ *
+ * Revision 1.14  1999/11/05 14:12:05  warmerda
+ * updated license terms
+ *
+ * Revision 1.13  1999/06/02 18:24:21  warmerda
+ * added trimming code
+ *
+ * Revision 1.12  1999/06/02 17:56:12  warmerda
+ * added quad'' subnode support for trees
+ *
+ * Revision 1.11  1999/05/18 19:11:11  warmerda
+ * Added example searching capability
+ *
+ * Revision 1.10  1999/05/18 17:49:38  warmerda
+ * added initial quadtree support
+ *
+ * Revision 1.9  1999/05/11 03:19:28  warmerda
+ * added new Tuple api, and improved extension handling - add from candrsn
+ *
+ * Revision 1.8  1999/03/23 17:22:27  warmerda
+ * Added extern "C" protection for C++ users of shapefil.h.
+ *
+ * Revision 1.7  1998/12/31 15:31:07  warmerda
+ * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options.
+ *
+ * Revision 1.6  1998/12/03 15:48:15  warmerda
+ * Added SHPCalculateExtents().
+ *
+ * Revision 1.5  1998/11/09 20:57:16  warmerda
+ * Altered SHPGetInfo() call.
+ *
+ * Revision 1.4  1998/11/09 20:19:33  warmerda
+ * Added 3D support, and use of SHPObject.
+ *
+ * Revision 1.3  1995/08/23 02:24:05  warmerda
+ * Added support for reading bounds.
+ *
+ * Revision 1.2  1995/08/04  03:17:39  warmerda
+ * Added header.
+ *
+ */
+
+#include <stdio.h>
+
+#ifdef USE_DBMALLOC
+#include <dbmalloc.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************/
+/*                        Configuration options.                        */
+/************************************************************************/
+
+/* -------------------------------------------------------------------- */
+/*      Should the DBFReadStringAttribute() strip leading and           */
+/*      trailing white space?                                           */
+/* -------------------------------------------------------------------- */
+#define TRIM_DBF_WHITESPACE
+
+/* -------------------------------------------------------------------- */
+/*      Should we write measure values to the Multipatch object?        */
+/*      Reportedly ArcView crashes if we do write it, so for now it     */
+/*      is disabled.                                                    */
+/* -------------------------------------------------------------------- */
+#define DISABLE_MULTIPATCH_MEASURE
+
+/* -------------------------------------------------------------------- */
+/*      SHPAPI_CALL                                                     */
+/*                                                                      */
+/*      The following two macros are present to allow forcing           */
+/*      various calling conventions on the Shapelib API.                */
+/*                                                                      */
+/*      To force __stdcall conventions (needed to call Shapelib         */
+/*      from Visual Basic and/or Dephi I believe) the makefile could    */
+/*      be modified to define:                                          */
+/*                                                                      */
+/*        /DSHPAPI_CALL=__stdcall                                       */
+/*                                                                      */
+/*      If it is desired to force export of the Shapelib API without    */
+/*      using the shapelib.def file, use the following definition.      */
+/*                                                                      */
+/*        /DSHAPELIB_DLLEXPORT                                          */
+/*                                                                      */
+/*      To get both at once it will be necessary to hack this           */
+/*      include file to define:                                         */
+/*                                                                      */
+/*        #define SHPAPI_CALL __declspec(dllexport) __stdcall           */
+/*        #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall        */
+/*                                                                      */
+/*      The complexity of the situtation is partly caused by the        */
+/*      peculiar requirement of Visual C++ that __stdcall appear        */
+/*      after any "*"'s in the return value of a function while the     */
+/*      __declspec(dllexport) must appear before them.                  */
+/* -------------------------------------------------------------------- */
+
+#ifdef SHAPELIB_DLLEXPORT
+#  define SHPAPI_CALL __declspec(dllexport)
+#  define SHPAPI_CALL1(x)  __declspec(dllexport) x
+#endif
+
+#ifndef SHPAPI_CALL
+#  define SHPAPI_CALL
+#endif
+
+#ifndef SHPAPI_CALL1
+#  define SHPAPI_CALL1(x)      x SHPAPI_CALL
+#endif
+    
+/************************************************************************/
+/*                             SHP Support.                             */
+/************************************************************************/
+typedef	struct
+{
+    FILE        *fpSHP;
+    FILE	*fpSHX;
+
+    int		nShapeType;				/* SHPT_* */
+    
+    int		nFileSize;				/* SHP file */
+
+    int         nRecords;
+    int		nMaxRecords;
+    int		*panRecOffset;
+    int		*panRecSize;
+
+    double	adBoundsMin[4];
+    double	adBoundsMax[4];
+
+    int		bUpdated;
+
+    unsigned char *pabyRec;
+    int         nBufSize;
+} SHPInfo;
+
+typedef SHPInfo * SHPHandle;
+
+/* -------------------------------------------------------------------- */
+/*      Shape types (nSHPType)                                          */
+/* -------------------------------------------------------------------- */
+#define SHPT_NULL	0
+#define SHPT_POINT	1
+#define SHPT_ARC	3
+#define SHPT_POLYGON	5
+#define SHPT_MULTIPOINT	8
+#define SHPT_POINTZ	11
+#define SHPT_ARCZ	13
+#define SHPT_POLYGONZ	15
+#define SHPT_MULTIPOINTZ 18
+#define SHPT_POINTM	21
+#define SHPT_ARCM	23
+#define SHPT_POLYGONM	25
+#define SHPT_MULTIPOINTM 28
+#define SHPT_MULTIPATCH 31
+
+
+/* -------------------------------------------------------------------- */
+/*      Part types - everything but SHPT_MULTIPATCH just uses           */
+/*      SHPP_RING.                                                      */
+/* -------------------------------------------------------------------- */
+
+#define SHPP_TRISTRIP	0
+#define SHPP_TRIFAN	1
+#define SHPP_OUTERRING	2
+#define SHPP_INNERRING	3
+#define SHPP_FIRSTRING	4
+#define SHPP_RING	5
+
+/* -------------------------------------------------------------------- */
+/*      SHPObject - represents on shape (without attributes) read       */
+/*      from the .shp file.                                             */
+/* -------------------------------------------------------------------- */
+typedef struct
+{
+    int		nSHPType;
+
+    int		nShapeId; /* -1 is unknown/unassigned */
+
+    int		nParts;
+    int		*panPartStart;
+    int		*panPartType;
+    
+    int		nVertices;
+    double	*padfX;
+    double	*padfY;
+    double	*padfZ;
+    double	*padfM;
+
+    double	dfXMin;
+    double	dfYMin;
+    double	dfZMin;
+    double	dfMMin;
+
+    double	dfXMax;
+    double	dfYMax;
+    double	dfZMax;
+    double	dfMMax;
+} SHPObject;
+
+/* -------------------------------------------------------------------- */
+/*      SHP API Prototypes                                              */
+/* -------------------------------------------------------------------- */
+SHPHandle SHPAPI_CALL
+      SHPOpen( const char * pszShapeFile, const char * pszAccess );
+SHPHandle SHPAPI_CALL
+      SHPCreate( const char * pszShapeFile, int nShapeType );
+void SHPAPI_CALL
+      SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
+                  double * padfMinBound, double * padfMaxBound );
+
+SHPObject SHPAPI_CALL1(*)
+      SHPReadObject( SHPHandle hSHP, int iShape );
+int SHPAPI_CALL
+      SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
+
+void SHPAPI_CALL
+      SHPDestroyObject( SHPObject * psObject );
+void SHPAPI_CALL
+      SHPComputeExtents( SHPObject * psObject );
+SHPObject SHPAPI_CALL1(*)
+      SHPCreateObject( int nSHPType, int nShapeId,
+                       int nParts, int * panPartStart, int * panPartType,
+                       int nVertices, double * padfX, double * padfY,
+                       double * padfZ, double * padfM );
+SHPObject SHPAPI_CALL1(*)
+      SHPCreateSimpleObject( int nSHPType, int nVertices,
+                             double * padfX, double * padfY, double * padfZ );
+
+int SHPAPI_CALL
+      SHPRewindObject( SHPHandle hSHP, SHPObject * psObject );
+
+void SHPAPI_CALL
+      SHPClose( SHPHandle hSHP );
+
+const char SHPAPI_CALL1(*)
+      SHPTypeName( int nSHPType );
+const char SHPAPI_CALL1(*)
+      SHPPartTypeName( int nPartType );
+
+/* -------------------------------------------------------------------- */
+/*      Shape quadtree indexing API.                                    */
+/* -------------------------------------------------------------------- */
+
+/* this can be two or four for binary or quad tree */
+#define MAX_SUBNODE	4
+
+typedef struct shape_tree_node
+{
+    /* region covered by this node */
+    double	adfBoundsMin[4];
+    double	adfBoundsMax[4];
+
+    /* list of shapes stored at this node.  The papsShapeObj pointers
+       or the whole list can be NULL */
+    int		nShapeCount;
+    int		*panShapeIds;
+    SHPObject   **papsShapeObj;
+
+    int		nSubNodes;
+    struct shape_tree_node *apsSubNode[MAX_SUBNODE];
+    
+} SHPTreeNode;
+
+typedef struct
+{
+    SHPHandle   hSHP;
+    
+    int		nMaxDepth;
+    int		nDimension;
+    
+    SHPTreeNode	*psRoot;
+} SHPTree;
+
+SHPTree SHPAPI_CALL1(*)
+      SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
+                     double *padfBoundsMin, double *padfBoundsMax );
+void    SHPAPI_CALL
+      SHPDestroyTree( SHPTree * hTree );
+
+int	SHPAPI_CALL
+      SHPWriteTree( SHPTree *hTree, const char * pszFilename );
+SHPTree SHPAPI_CALL
+      SHPReadTree( const char * pszFilename );
+
+int	SHPAPI_CALL
+      SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject );
+int	SHPAPI_CALL
+      SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
+int	SHPAPI_CALL
+      SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
+
+void 	SHPAPI_CALL
+      SHPTreeTrimExtraNodes( SHPTree * hTree );
+
+int    SHPAPI_CALL1(*)
+      SHPTreeFindLikelyShapes( SHPTree * hTree,
+                               double * padfBoundsMin,
+                               double * padfBoundsMax,
+                               int * );
+int     SHPAPI_CALL
+      SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
+
+/************************************************************************/
+/*                             DBF Support.                             */
+/************************************************************************/
+typedef	struct
+{
+    FILE	*fp;
+
+    int         nRecords;
+
+    int		nRecordLength;
+    int		nHeaderLength;
+    int		nFields;
+    int		*panFieldOffset;
+    int		*panFieldSize;
+    int		*panFieldDecimals;
+    char	*pachFieldType;
+
+    char	*pszHeader;
+
+    int		nCurrentRecord;
+    int		bCurrentRecordModified;
+    char	*pszCurrentRecord;
+    
+    int		bNoHeader;
+    int		bUpdated;
+} DBFInfo;
+
+typedef DBFInfo * DBFHandle;
+
+typedef enum {
+  FTString,
+  FTInteger,
+  FTDouble,
+  FTLogical,
+  FTInvalid
+} DBFFieldType;
+
+#define XBASE_FLDHDR_SZ       32
+
+DBFHandle SHPAPI_CALL
+      DBFOpen( const char * pszDBFFile, const char * pszAccess );
+DBFHandle SHPAPI_CALL
+      DBFCreate( const char * pszDBFFile );
+
+int	SHPAPI_CALL
+      DBFGetFieldCount( DBFHandle psDBF );
+int	SHPAPI_CALL
+      DBFGetRecordCount( DBFHandle psDBF );
+int	SHPAPI_CALL
+      DBFAddField( DBFHandle hDBF, const char * pszFieldName,
+                   DBFFieldType eType, int nWidth, int nDecimals );
+
+DBFFieldType SHPAPI_CALL
+      DBFGetFieldInfo( DBFHandle psDBF, int iField, 
+                       char * pszFieldName, int * pnWidth, int * pnDecimals );
+
+int SHPAPI_CALL
+      DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName);
+
+int 	SHPAPI_CALL
+      DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
+double 	SHPAPI_CALL
+      DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
+const char SHPAPI_CALL1(*)
+      DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
+const char SHPAPI_CALL1(*)
+      DBFReadMagLogicalAttribute( DBFHandle hDBF, int iShape, int iField );
+int     SHPAPI_CALL
+      DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
+
+int SHPAPI_CALL
+      DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField, 
+                                int nFieldValue );
+int SHPAPI_CALL
+      DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
+                               double dFieldValue );
+int SHPAPI_CALL
+      DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
+                               const char * pszFieldValue );
+int SHPAPI_CALL
+     DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
+
+int SHPAPI_CALL
+     DBFWriteMagLogicalAttribute( DBFHandle hDBF, int iShape, int iField,
+			       const char lFieldValue);
+int SHPAPI_CALL
+     DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField,
+                               void * pValue );
+const char SHPAPI_CALL1(*)
+      DBFReadTuple(DBFHandle psDBF, int hEntity );
+int SHPAPI_CALL
+      DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
+
+DBFHandle SHPAPI_CALL
+      DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
+ 
+void	SHPAPI_CALL
+      DBFClose( DBFHandle hDBF );
+char    SHPAPI_CALL
+      DBFGetNativeFieldType( DBFHandle hDBF, int iField );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ndef _SHAPEFILE_H_INCLUDED */
diff --git a/src/decoders/shpopen.c b/src/decoders/shpopen.c
new file mode 100644
index 0000000..e57ccee
--- /dev/null
+++ b/src/decoders/shpopen.c
@@ -0,0 +1,1866 @@
+/******************************************************************************
+ * $Id: shpopen.c,v 1.39 2002/08/26 06:46:56 warmerda Exp $
+ *
+ * Project:  Shapelib
+ * Purpose:  Implementation of core Shapefile read/write functions.
+ * Author:   Frank Warmerdam, warmerdam at pobox.com
+ *
+ ******************************************************************************
+ * Copyright (c) 1999, 2001, Frank Warmerdam
+ *
+ * This software is available under the following "MIT Style" license,
+ * or at the option of the licensee under the LGPL (see LICENSE.LGPL).  This
+ * option is discussed in more detail in shapelib.html.
+ *
+ * --
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ ******************************************************************************
+ *
+ * $Log: shpopen.c,v $
+ * Revision 1.39  2002/08/26 06:46:56  warmerda
+ * avoid c++ comments
+ *
+ * Revision 1.38  2002/05/07 16:43:39  warmerda
+ * Removed debugging printf.
+ *
+ * Revision 1.37  2002/04/10 17:35:22  warmerda
+ * fixed bug in ring reversal code
+ *
+ * Revision 1.36  2002/04/10 16:59:54  warmerda
+ * added SHPRewindObject
+ *
+ * Revision 1.35  2001/12/07 15:10:44  warmerda
+ * fix if .shx fails to open
+ *
+ * Revision 1.34  2001/11/01 16:29:55  warmerda
+ * move pabyRec into SHPInfo for thread safety
+ *
+ * Revision 1.33  2001/07/03 12:18:15  warmerda
+ * Improved cleanup if SHX not found, provied by Riccardo Cohen.
+ *
+ * Revision 1.32  2001/06/22 01:58:07  warmerda
+ * be more careful about establishing initial bounds in face of NULL shapes
+ *
+ * Revision 1.31  2001/05/31 19:35:29  warmerda
+ * added support for writing null shapes
+ *
+ * Revision 1.30  2001/05/28 12:46:29  warmerda
+ * Add some checking on reasonableness of record count when opening.
+ *
+ * Revision 1.29  2001/05/23 13:36:52  warmerda
+ * added use of SHPAPI_CALL
+ *
+ * Revision 1.28  2001/02/06 22:25:06  warmerda
+ * fixed memory leaks when SHPOpen() fails
+ *
+ * Revision 1.27  2000/07/18 15:21:33  warmerda
+ * added better enforcement of -1 for append in SHPWriteObject
+ *
+ * Revision 1.26  2000/02/16 16:03:51  warmerda
+ * added null shape support
+ *
+ * Revision 1.25  1999/12/15 13:47:07  warmerda
+ * Fixed record size settings in .shp file (was 4 words too long)
+ * Added stdlib.h.
+ *
+ * Revision 1.24  1999/11/05 14:12:04  warmerda
+ * updated license terms
+ *
+ * Revision 1.23  1999/07/27 00:53:46  warmerda
+ * added support for rewriting shapes
+ *
+ * Revision 1.22  1999/06/11 19:19:11  warmerda
+ * Cleanup pabyRec static buffer on SHPClose().
+ *
+ * Revision 1.21  1999/06/02 14:57:56  kshih
+ * Remove unused variables
+ *
+ * Revision 1.20  1999/04/19 21:04:17  warmerda
+ * Fixed syntax error.
+ *
+ * Revision 1.19  1999/04/19 21:01:57  warmerda
+ * Force access string to binary in SHPOpen().
+ *
+ * Revision 1.18  1999/04/01 18:48:07  warmerda
+ * Try upper case extensions if lower case doesn't work.
+ *
+ * Revision 1.17  1998/12/31 15:29:39  warmerda
+ * Disable writing measure values to multipatch objects if
+ * DISABLE_MULTIPATCH_MEASURE is defined.
+ *
+ * Revision 1.16  1998/12/16 05:14:33  warmerda
+ * Added support to write MULTIPATCH.  Fixed reading Z coordinate of
+ * MULTIPATCH. Fixed record size written for all feature types.
+ *
+ * Revision 1.15  1998/12/03 16:35:29  warmerda
+ * r+b is proper binary access string, not rb+.
+ *
+ * Revision 1.14  1998/12/03 15:47:56  warmerda
+ * Fixed setting of nVertices in SHPCreateObject().
+ *
+ * Revision 1.13  1998/12/03 15:33:54  warmerda
+ * Made SHPCalculateExtents() separately callable.
+ *
+ * Revision 1.12  1998/11/11 20:01:50  warmerda
+ * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
+ *
+ * Revision 1.11  1998/11/09 20:56:44  warmerda
+ * Fixed up handling of file wide bounds.
+ *
+ * Revision 1.10  1998/11/09 20:18:51  warmerda
+ * Converted to support 3D shapefiles, and use of SHPObject.
+ *
+ * Revision 1.9  1998/02/24 15:09:05  warmerda
+ * Fixed memory leak.
+ *
+ * Revision 1.8  1997/12/04 15:40:29  warmerda
+ * Fixed byte swapping of record number, and record length fields in the
+ * .shp file.
+ *
+ * Revision 1.7  1995/10/21 03:15:58  warmerda
+ * Added support for binary file access, the magic cookie 9997
+ * and tried to improve the int32 selection logic for 16bit systems.
+ *
+ * Revision 1.6  1995/09/04  04:19:41  warmerda
+ * Added fix for file bounds.
+ *
+ * Revision 1.5  1995/08/25  15:16:44  warmerda
+ * Fixed a couple of problems with big endian systems ... one with bounds
+ * and the other with multipart polygons.
+ *
+ * Revision 1.4  1995/08/24  18:10:17  warmerda
+ * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc()
+ * functions (such as on the Sun).
+ *
+ * Revision 1.3  1995/08/23  02:23:15  warmerda
+ * Added support for reading bounds, and fixed up problems in setting the
+ * file wide bounds.
+ *
+ * Revision 1.2  1995/08/04  03:16:57  warmerda
+ * Added header.
+ *
+ */
+
+static char rcsid[] = 
+  "$Id: shpopen.c,v 1.39 2002/08/26 06:46:56 warmerda Exp $";
+
+#include "shapefil.h"
+
+#include <math.h>
+#include <limits.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef unsigned char uchar;
+
+#if UINT_MAX == 65535
+typedef long	      int32;
+#else
+typedef int	      int32;
+#endif
+
+#ifndef FALSE
+#  define FALSE		0
+#  define TRUE		1
+#endif
+
+#define ByteCopy( a, b, c )	memcpy( b, a, c )
+#ifndef MAX
+#  define MIN(a,b)      ((a<b) ? a : b)
+#  define MAX(a,b)      ((a>b) ? a : b)
+#endif
+
+static int 	bBigEndian;
+
+
+/************************************************************************/
+/*                              SwapWord()                              */
+/*                                                                      */
+/*      Swap a 2, 4 or 8 byte word.                                     */
+/************************************************************************/
+
+static void	SwapWord( int length, void * wordP )
+
+{
+    int		i;
+    uchar	temp;
+
+    for( i=0; i < length/2; i++ )
+    {
+	temp = ((uchar *) wordP)[i];
+	((uchar *)wordP)[i] = ((uchar *) wordP)[length-i-1];
+	((uchar *) wordP)[length-i-1] = temp;
+    }
+}
+
+/************************************************************************/
+/*                             SfRealloc()                              */
+/*                                                                      */
+/*      A realloc cover function that will access a NULL pointer as     */
+/*      a valid input.                                                  */
+/************************************************************************/
+
+static void * SfRealloc( void * pMem, int nNewSize )
+
+{
+    if( pMem == NULL )
+        return( (void *) malloc(nNewSize) );
+    else
+        return( (void *) realloc(pMem,nNewSize) );
+}
+
+/************************************************************************/
+/*                          SHPWriteHeader()                            */
+/*                                                                      */
+/*      Write out a header for the .shp and .shx files as well as the	*/
+/*	contents of the index (.shx) file.				*/
+/************************************************************************/
+
+static void SHPWriteHeader( SHPHandle psSHP )
+
+{
+    uchar     	abyHeader[100];
+    int		i;
+    int32	i32;
+    double	dValue;
+    int32	*panSHX;
+
+/* -------------------------------------------------------------------- */
+/*      Prepare header block for .shp file.                             */
+/* -------------------------------------------------------------------- */
+    for( i = 0; i < 100; i++ )
+      abyHeader[i] = 0;
+
+    abyHeader[2] = 0x27;				/* magic cookie */
+    abyHeader[3] = 0x0a;
+
+    i32 = psSHP->nFileSize/2;				/* file size */
+    ByteCopy( &i32, abyHeader+24, 4 );
+    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+    
+    i32 = 1000;						/* version */
+    ByteCopy( &i32, abyHeader+28, 4 );
+    if( bBigEndian ) SwapWord( 4, abyHeader+28 );
+    
+    i32 = psSHP->nShapeType;				/* shape type */
+    ByteCopy( &i32, abyHeader+32, 4 );
+    if( bBigEndian ) SwapWord( 4, abyHeader+32 );
+
+    dValue = psSHP->adBoundsMin[0];			/* set bounds */
+    ByteCopy( &dValue, abyHeader+36, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+36 );
+
+    dValue = psSHP->adBoundsMin[1];
+    ByteCopy( &dValue, abyHeader+44, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+44 );
+
+    dValue = psSHP->adBoundsMax[0];
+    ByteCopy( &dValue, abyHeader+52, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+52 );
+
+    dValue = psSHP->adBoundsMax[1];
+    ByteCopy( &dValue, abyHeader+60, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+60 );
+
+    dValue = psSHP->adBoundsMin[2];			/* z */
+    ByteCopy( &dValue, abyHeader+68, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+68 );
+
+    dValue = psSHP->adBoundsMax[2];
+    ByteCopy( &dValue, abyHeader+76, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+76 );
+
+    dValue = psSHP->adBoundsMin[3];			/* m */
+    ByteCopy( &dValue, abyHeader+84, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+84 );
+
+    dValue = psSHP->adBoundsMax[3];
+    ByteCopy( &dValue, abyHeader+92, 8 );
+    if( bBigEndian ) SwapWord( 8, abyHeader+92 );
+
+/* -------------------------------------------------------------------- */
+/*      Write .shp file header.                                         */
+/* -------------------------------------------------------------------- */
+    fseek( psSHP->fpSHP, 0, 0 );
+    fwrite( abyHeader, 100, 1, psSHP->fpSHP );
+
+/* -------------------------------------------------------------------- */
+/*      Prepare, and write .shx file header.                            */
+/* -------------------------------------------------------------------- */
+    i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100)/2;   /* file size */
+    ByteCopy( &i32, abyHeader+24, 4 );
+    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+    
+    fseek( psSHP->fpSHX, 0, 0 );
+    fwrite( abyHeader, 100, 1, psSHP->fpSHX );
+
+/* -------------------------------------------------------------------- */
+/*      Write out the .shx contents.                                    */
+/* -------------------------------------------------------------------- */
+    panSHX = (int32 *) malloc(sizeof(int32) * 2 * psSHP->nRecords);
+
+    for( i = 0; i < psSHP->nRecords; i++ )
+    {
+	panSHX[i*2  ] = psSHP->panRecOffset[i]/2;
+	panSHX[i*2+1] = psSHP->panRecSize[i]/2;
+	if( !bBigEndian ) SwapWord( 4, panSHX+i*2 );
+	if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 );
+    }
+
+    fwrite( panSHX, sizeof(int32) * 2, psSHP->nRecords, psSHP->fpSHX );
+
+    free( panSHX );
+}
+
+/************************************************************************/
+/*                              SHPOpen()                               */
+/*                                                                      */
+/*      Open the .shp and .shx files based on the basename of the       */
+/*      files or either file name.                                      */
+/************************************************************************/
+   
+SHPHandle SHPAPI_CALL
+SHPOpen( const char * pszLayer, const char * pszAccess )
+
+{
+    char		*pszFullname, *pszBasename;
+    SHPHandle		psSHP;
+    
+    uchar		*pabyBuf;
+    int			i;
+    double		dValue;
+
+/* -------------------------------------------------------------------- */
+/*      Ensure the access string is one of the legal ones.  We          */
+/*      ensure the result string indicates binary to avoid common       */
+/*      problems on Windows.                                            */
+/* -------------------------------------------------------------------- */
+    if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0
+        || strcmp(pszAccess,"r+") == 0 )
+        pszAccess = "r+b";
+    else
+        pszAccess = "rb";
+    
+/* -------------------------------------------------------------------- */
+/*	Establish the byte order on this machine.			*/
+/* -------------------------------------------------------------------- */
+    i = 1;
+    if( *((uchar *) &i) == 1 )
+        bBigEndian = FALSE;
+    else
+        bBigEndian = TRUE;
+
+/* -------------------------------------------------------------------- */
+/*	Initialize the info structure.					*/
+/* -------------------------------------------------------------------- */
+    psSHP = (SHPHandle) calloc(sizeof(SHPInfo),1);
+
+    psSHP->bUpdated = FALSE;
+
+/* -------------------------------------------------------------------- */
+/*	Compute the base (layer) name.  If there is any extension	*/
+/*	on the passed in filename we will strip it off.			*/
+/* -------------------------------------------------------------------- */
+    pszBasename = (char *) malloc(strlen(pszLayer)+5);
+    strcpy( pszBasename, pszLayer );
+    for( i = strlen(pszBasename)-1; 
+	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+	       && pszBasename[i] != '\\';
+	 i-- ) {}
+
+    if( pszBasename[i] == '.' )
+        pszBasename[i] = '\0';
+
+/* -------------------------------------------------------------------- */
+/*	Open the .shp and .shx files.  Note that files pulled from	*/
+/*	a PC to Unix with upper case filenames won't work!		*/
+/* -------------------------------------------------------------------- */
+    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+    sprintf( pszFullname, "%s.shp", pszBasename );
+    psSHP->fpSHP = fopen(pszFullname, pszAccess );
+    if( psSHP->fpSHP == NULL )
+    {
+        sprintf( pszFullname, "%s.SHP", pszBasename );
+        psSHP->fpSHP = fopen(pszFullname, pszAccess );
+    }
+    
+    if( psSHP->fpSHP == NULL )
+    {
+        free( psSHP );
+        free( pszBasename );
+        free( pszFullname );
+        return( NULL );
+    }
+
+    sprintf( pszFullname, "%s.shx", pszBasename );
+    psSHP->fpSHX = fopen(pszFullname, pszAccess );
+    if( psSHP->fpSHX == NULL )
+    {
+        sprintf( pszFullname, "%s.SHX", pszBasename );
+        psSHP->fpSHX = fopen(pszFullname, pszAccess );
+    }
+    
+    if( psSHP->fpSHX == NULL )
+    {
+        fclose( psSHP->fpSHP );
+        free( psSHP );
+        free( pszBasename );
+        free( pszFullname );
+        return( NULL );
+    }
+
+    free( pszFullname );
+    free( pszBasename );
+
+/* -------------------------------------------------------------------- */
+/*  Read the file size from the SHP file.				*/
+/* -------------------------------------------------------------------- */
+    pabyBuf = (uchar *) malloc(100);
+    fread( pabyBuf, 100, 1, psSHP->fpSHP );
+
+    psSHP->nFileSize = (pabyBuf[24] * 256 * 256 * 256
+			+ pabyBuf[25] * 256 * 256
+			+ pabyBuf[26] * 256
+			+ pabyBuf[27]) * 2;
+
+/* -------------------------------------------------------------------- */
+/*  Read SHX file Header info                                           */
+/* -------------------------------------------------------------------- */
+    fread( pabyBuf, 100, 1, psSHP->fpSHX );
+
+    if( pabyBuf[0] != 0 
+        || pabyBuf[1] != 0 
+        || pabyBuf[2] != 0x27 
+        || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) )
+    {
+	fclose( psSHP->fpSHP );
+	fclose( psSHP->fpSHX );
+	free( psSHP );
+
+	return( NULL );
+    }
+
+    psSHP->nRecords = pabyBuf[27] + pabyBuf[26] * 256
+      + pabyBuf[25] * 256 * 256 + pabyBuf[24] * 256 * 256 * 256;
+    psSHP->nRecords = (psSHP->nRecords*2 - 100) / 8;
+
+    psSHP->nShapeType = pabyBuf[32];
+
+    if( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 )
+    {
+        /* this header appears to be corrupt.  Give up. */
+	fclose( psSHP->fpSHP );
+	fclose( psSHP->fpSHX );
+	free( psSHP );
+
+	return( NULL );
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Read the bounds.                                                */
+/* -------------------------------------------------------------------- */
+    if( bBigEndian ) SwapWord( 8, pabyBuf+36 );
+    memcpy( &dValue, pabyBuf+36, 8 );
+    psSHP->adBoundsMin[0] = dValue;
+
+    if( bBigEndian ) SwapWord( 8, pabyBuf+44 );
+    memcpy( &dValue, pabyBuf+44, 8 );
+    psSHP->adBoundsMin[1] = dValue;
+
+    if( bBigEndian ) SwapWord( 8, pabyBuf+52 );
+    memcpy( &dValue, pabyBuf+52, 8 );
+    psSHP->adBoundsMax[0] = dValue;
+
+    if( bBigEndian ) SwapWord( 8, pabyBuf+60 );
+    memcpy( &dValue, pabyBuf+60, 8 );
+    psSHP->adBoundsMax[1] = dValue;
+
+    if( bBigEndian ) SwapWord( 8, pabyBuf+68 );		/* z */
+    memcpy( &dValue, pabyBuf+68, 8 );
+    psSHP->adBoundsMin[2] = dValue;
+    
+    if( bBigEndian ) SwapWord( 8, pabyBuf+76 );
+    memcpy( &dValue, pabyBuf+76, 8 );
+    psSHP->adBoundsMax[2] = dValue;
+    
+    if( bBigEndian ) SwapWord( 8, pabyBuf+84 );		/* z */
+    memcpy( &dValue, pabyBuf+84, 8 );
+    psSHP->adBoundsMin[3] = dValue;
+
+    if( bBigEndian ) SwapWord( 8, pabyBuf+92 );
+    memcpy( &dValue, pabyBuf+92, 8 );
+    psSHP->adBoundsMax[3] = dValue;
+
+    free( pabyBuf );
+
+/* -------------------------------------------------------------------- */
+/*	Read the .shx file to get the offsets to each record in 	*/
+/*	the .shp file.							*/
+/* -------------------------------------------------------------------- */
+    psSHP->nMaxRecords = psSHP->nRecords;
+
+    psSHP->panRecOffset =
+        (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) );
+    psSHP->panRecSize =
+        (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) );
+
+    pabyBuf = (uchar *) malloc(8 * MAX(1,psSHP->nRecords) );
+    fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX );
+
+    for( i = 0; i < psSHP->nRecords; i++ )
+    {
+	int32		nOffset, nLength;
+
+	memcpy( &nOffset, pabyBuf + i * 8, 4 );
+	if( !bBigEndian ) SwapWord( 4, &nOffset );
+
+	memcpy( &nLength, pabyBuf + i * 8 + 4, 4 );
+	if( !bBigEndian ) SwapWord( 4, &nLength );
+
+	psSHP->panRecOffset[i] = nOffset*2;
+	psSHP->panRecSize[i] = nLength*2;
+    }
+    free( pabyBuf );
+
+    return( psSHP );
+}
+
+/************************************************************************/
+/*                              SHPClose()                              */
+/*								       	*/
+/*	Close the .shp and .shx files.					*/
+/************************************************************************/
+
+void SHPAPI_CALL
+SHPClose(SHPHandle psSHP )
+
+{
+/* -------------------------------------------------------------------- */
+/*	Update the header if we have modified anything.			*/
+/* -------------------------------------------------------------------- */
+    if( psSHP->bUpdated )
+    {
+	SHPWriteHeader( psSHP );
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Free all resources, and close files.                            */
+/* -------------------------------------------------------------------- */
+    free( psSHP->panRecOffset );
+    free( psSHP->panRecSize );
+
+    fclose( psSHP->fpSHX );
+    fclose( psSHP->fpSHP );
+
+    if( psSHP->pabyRec != NULL )
+    {
+        free( psSHP->pabyRec );
+    }
+    
+    free( psSHP );
+}
+
+/************************************************************************/
+/*                             SHPGetInfo()                             */
+/*                                                                      */
+/*      Fetch general information about the shape file.                 */
+/************************************************************************/
+
+void SHPAPI_CALL
+SHPGetInfo(SHPHandle psSHP, int * pnEntities, int * pnShapeType,
+           double * padfMinBound, double * padfMaxBound )
+
+{
+    int		i;
+    
+    if( pnEntities != NULL )
+        *pnEntities = psSHP->nRecords;
+
+    if( pnShapeType != NULL )
+        *pnShapeType = psSHP->nShapeType;
+
+    for( i = 0; i < 4; i++ )
+    {
+        if( padfMinBound != NULL )
+            padfMinBound[i] = psSHP->adBoundsMin[i];
+        if( padfMaxBound != NULL )
+            padfMaxBound[i] = psSHP->adBoundsMax[i];
+    }
+}
+
+/************************************************************************/
+/*                             SHPCreate()                              */
+/*                                                                      */
+/*      Create a new shape file and return a handle to the open         */
+/*      shape file with read/write access.                              */
+/************************************************************************/
+
+SHPHandle SHPAPI_CALL
+SHPCreate( const char * pszLayer, int nShapeType )
+
+{
+    char	*pszBasename, *pszFullname;
+    int		i;
+    FILE	*fpSHP, *fpSHX;
+    uchar     	abyHeader[100];
+    int32	i32;
+    double	dValue;
+    
+/* -------------------------------------------------------------------- */
+/*      Establish the byte order on this system.                        */
+/* -------------------------------------------------------------------- */
+    i = 1;
+    if( *((uchar *) &i) == 1 )
+        bBigEndian = FALSE;
+    else
+        bBigEndian = TRUE;
+
+/* -------------------------------------------------------------------- */
+/*	Compute the base (layer) name.  If there is any extension	*/
+/*	on the passed in filename we will strip it off.			*/
+/* -------------------------------------------------------------------- */
+    pszBasename = (char *) malloc(strlen(pszLayer)+5);
+    strcpy( pszBasename, pszLayer );
+    for( i = strlen(pszBasename)-1; 
+	 i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
+	       && pszBasename[i] != '\\';
+	 i-- ) {}
+
+    if( pszBasename[i] == '.' )
+        pszBasename[i] = '\0';
+
+/* -------------------------------------------------------------------- */
+/*      Open the two files so we can write their headers.               */
+/* -------------------------------------------------------------------- */
+    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
+    sprintf( pszFullname, "%s.shp", pszBasename );
+    fpSHP = fopen(pszFullname, "wb" );
+    if( fpSHP == NULL )
+        return( NULL );
+
+    sprintf( pszFullname, "%s.shx", pszBasename );
+    fpSHX = fopen(pszFullname, "wb" );
+    if( fpSHX == NULL )
+        return( NULL );
+
+    free( pszFullname );
+    free( pszBasename );
+
+/* -------------------------------------------------------------------- */
+/*      Prepare header block for .shp file.                             */
+/* -------------------------------------------------------------------- */
+    for( i = 0; i < 100; i++ )
+      abyHeader[i] = 0;
+
+    abyHeader[2] = 0x27;				/* magic cookie */
+    abyHeader[3] = 0x0a;
+
+    i32 = 50;						/* file size */
+    ByteCopy( &i32, abyHeader+24, 4 );
+    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+    
+    i32 = 1000;						/* version */
+    ByteCopy( &i32, abyHeader+28, 4 );
+    if( bBigEndian ) SwapWord( 4, abyHeader+28 );
+    
+    i32 = nShapeType;					/* shape type */
+    ByteCopy( &i32, abyHeader+32, 4 );
+    if( bBigEndian ) SwapWord( 4, abyHeader+32 );
+
+    dValue = 0.0;					/* set bounds */
+    ByteCopy( &dValue, abyHeader+36, 8 );
+    ByteCopy( &dValue, abyHeader+44, 8 );
+    ByteCopy( &dValue, abyHeader+52, 8 );
+    ByteCopy( &dValue, abyHeader+60, 8 );
+
+/* -------------------------------------------------------------------- */
+/*      Write .shp file header.                                         */
+/* -------------------------------------------------------------------- */
+    fwrite( abyHeader, 100, 1, fpSHP );
+
+/* -------------------------------------------------------------------- */
+/*      Prepare, and write .shx file header.                            */
+/* -------------------------------------------------------------------- */
+    i32 = 50;						/* file size */
+    ByteCopy( &i32, abyHeader+24, 4 );
+    if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
+    
+    fwrite( abyHeader, 100, 1, fpSHX );
+
+/* -------------------------------------------------------------------- */
+/*      Close the files, and then open them as regular existing files.  */
+/* -------------------------------------------------------------------- */
+    fclose( fpSHP );
+    fclose( fpSHX );
+
+    return( SHPOpen( pszLayer, "r+b" ) );
+}
+
+/************************************************************************/
+/*                           _SHPSetBounds()                            */
+/*                                                                      */
+/*      Compute a bounds rectangle for a shape, and set it into the     */
+/*      indicated location in the record.                               */
+/************************************************************************/
+
+static void	_SHPSetBounds( uchar * pabyRec, SHPObject * psShape )
+
+{
+    ByteCopy( &(psShape->dfXMin), pabyRec +  0, 8 );
+    ByteCopy( &(psShape->dfYMin), pabyRec +  8, 8 );
+    ByteCopy( &(psShape->dfXMax), pabyRec + 16, 8 );
+    ByteCopy( &(psShape->dfYMax), pabyRec + 24, 8 );
+
+    if( bBigEndian )
+    {
+        SwapWord( 8, pabyRec + 0 );
+        SwapWord( 8, pabyRec + 8 );
+        SwapWord( 8, pabyRec + 16 );
+        SwapWord( 8, pabyRec + 24 );
+    }
+}
+
+/************************************************************************/
+/*                         SHPComputeExtents()                          */
+/*                                                                      */
+/*      Recompute the extents of a shape.  Automatically done by        */
+/*      SHPCreateObject().                                              */
+/************************************************************************/
+
+void SHPAPI_CALL
+SHPComputeExtents( SHPObject * psObject )
+
+{
+    int		i;
+    
+/* -------------------------------------------------------------------- */
+/*      Build extents for this object.                                  */
+/* -------------------------------------------------------------------- */
+    if( psObject->nVertices > 0 )
+    {
+        psObject->dfXMin = psObject->dfXMax = psObject->padfX[0];
+        psObject->dfYMin = psObject->dfYMax = psObject->padfY[0];
+        psObject->dfZMin = psObject->dfZMax = psObject->padfZ[0];
+        psObject->dfMMin = psObject->dfMMax = psObject->padfM[0];
+    }
+    
+    for( i = 0; i < psObject->nVertices; i++ )
+    {
+        psObject->dfXMin = MIN(psObject->dfXMin, psObject->padfX[i]);
+        psObject->dfYMin = MIN(psObject->dfYMin, psObject->padfY[i]);
+        psObject->dfZMin = MIN(psObject->dfZMin, psObject->padfZ[i]);
+        psObject->dfMMin = MIN(psObject->dfMMin, psObject->padfM[i]);
+
+        psObject->dfXMax = MAX(psObject->dfXMax, psObject->padfX[i]);
+        psObject->dfYMax = MAX(psObject->dfYMax, psObject->padfY[i]);
+        psObject->dfZMax = MAX(psObject->dfZMax, psObject->padfZ[i]);
+        psObject->dfMMax = MAX(psObject->dfMMax, psObject->padfM[i]);
+    }
+}
+
+/************************************************************************/
+/*                          SHPCreateObject()                           */
+/*                                                                      */
+/*      Create a shape object.  It should be freed with                 */
+/*      SHPDestroyObject().                                             */
+/************************************************************************/
+
+SHPObject SHPAPI_CALL1(*)
+SHPCreateObject( int nSHPType, int nShapeId, int nParts,
+                 int * panPartStart, int * panPartType,
+                 int nVertices, double * padfX, double * padfY,
+                 double * padfZ, double * padfM )
+
+{
+    SHPObject	*psObject;
+    int		i, bHasM, bHasZ;
+
+    psObject = (SHPObject *) calloc(1,sizeof(SHPObject));
+    psObject->nSHPType = nSHPType;
+    psObject->nShapeId = nShapeId;
+
+/* -------------------------------------------------------------------- */
+/*	Establish whether this shape type has M, and Z values.		*/
+/* -------------------------------------------------------------------- */
+    if( nSHPType == SHPT_ARCM
+        || nSHPType == SHPT_POINTM
+        || nSHPType == SHPT_POLYGONM
+        || nSHPType == SHPT_MULTIPOINTM )
+    {
+        bHasM = TRUE;
+        bHasZ = FALSE;
+    }
+    else if( nSHPType == SHPT_ARCZ
+             || nSHPType == SHPT_POINTZ
+             || nSHPType == SHPT_POLYGONZ
+             || nSHPType == SHPT_MULTIPOINTZ
+             || nSHPType == SHPT_MULTIPATCH )
+    {
+        bHasM = TRUE;
+        bHasZ = TRUE;
+    }
+    else
+    {
+        bHasM = FALSE;
+        bHasZ = FALSE;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Capture parts.  Note that part type is optional, and            */
+/*      defaults to ring.                                               */
+/* -------------------------------------------------------------------- */
+    if( nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON
+        || nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM
+        || nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ
+        || nSHPType == SHPT_MULTIPATCH )
+    {
+        psObject->nParts = MAX(1,nParts);
+
+        psObject->panPartStart = (int *)
+            malloc(sizeof(int) * psObject->nParts);
+        psObject->panPartType = (int *)
+            malloc(sizeof(int) * psObject->nParts);
+
+        psObject->panPartStart[0] = 0;
+        psObject->panPartType[0] = SHPP_RING;
+        
+        for( i = 0; i < nParts; i++ )
+        {
+            psObject->panPartStart[i] = panPartStart[i];
+            if( panPartType != NULL )
+                psObject->panPartType[i] = panPartType[i];
+            else
+                psObject->panPartType[i] = SHPP_RING;
+        }
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Capture vertices.  Note that Z and M are optional, but X and    */
+/*      Y are not.                                                      */
+/* -------------------------------------------------------------------- */
+    if( nVertices > 0 )
+    {
+        psObject->padfX = (double *) calloc(sizeof(double),nVertices);
+        psObject->padfY = (double *) calloc(sizeof(double),nVertices);
+        psObject->padfZ = (double *) calloc(sizeof(double),nVertices);
+        psObject->padfM = (double *) calloc(sizeof(double),nVertices);
+
+        assert( padfX != NULL );
+        assert( padfY != NULL );
+    
+        for( i = 0; i < nVertices; i++ )
+        {
+            psObject->padfX[i] = padfX[i];
+            psObject->padfY[i] = padfY[i];
+            if( padfZ != NULL && bHasZ )
+                psObject->padfZ[i] = padfZ[i];
+            if( padfM != NULL && bHasM )
+                psObject->padfM[i] = padfM[i];
+        }
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Compute the extents.                                            */
+/* -------------------------------------------------------------------- */
+    psObject->nVertices = nVertices;
+    SHPComputeExtents( psObject );
+
+    return( psObject );
+}
+
+/************************************************************************/
+/*                       SHPCreateSimpleObject()                        */
+/*                                                                      */
+/*      Create a simple (common) shape object.  Destroy with            */
+/*      SHPDestroyObject().                                             */
+/************************************************************************/
+
+SHPObject SHPAPI_CALL1(*)
+SHPCreateSimpleObject( int nSHPType, int nVertices,
+                       double * padfX, double * padfY,
+                       double * padfZ )
+
+{
+    return( SHPCreateObject( nSHPType, -1, 0, NULL, NULL,
+                             nVertices, padfX, padfY, padfZ, NULL ) );
+}
+                                  
+/************************************************************************/
+/*                           SHPWriteObject()                           */
+/*                                                                      */
+/*      Write out the vertices of a new structure.  Note that it is     */
+/*      only possible to write vertices at the end of the file.         */
+/************************************************************************/
+
+int SHPAPI_CALL
+SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject )
+		      
+{
+    int	       	nRecordOffset, i, nRecordSize;
+    uchar	*pabyRec;
+    int32	i32;
+
+    psSHP->bUpdated = TRUE;
+
+/* -------------------------------------------------------------------- */
+/*      Ensure that shape object matches the type of the file it is     */
+/*      being written to.                                               */
+/* -------------------------------------------------------------------- */
+    assert( psObject->nSHPType == psSHP->nShapeType 
+            || psObject->nSHPType == SHPT_NULL );
+
+/* -------------------------------------------------------------------- */
+/*      Ensure that -1 is used for appends.  Either blow an             */
+/*      assertion, or if they are disabled, set the shapeid to -1       */
+/*      for appends.                                                    */
+/* -------------------------------------------------------------------- */
+    assert( nShapeId == -1 
+            || (nShapeId >= 0 && nShapeId < psSHP->nRecords) );
+
+    if( nShapeId != -1 && nShapeId >= psSHP->nRecords )
+        nShapeId = -1;
+
+/* -------------------------------------------------------------------- */
+/*      Add the new entity to the in memory index.                      */
+/* -------------------------------------------------------------------- */
+    if( nShapeId == -1 && psSHP->nRecords+1 > psSHP->nMaxRecords )
+    {
+	psSHP->nMaxRecords =(int) ( psSHP->nMaxRecords * 1.3 + 100);
+
+	psSHP->panRecOffset = (int *) 
+            SfRealloc(psSHP->panRecOffset,sizeof(int) * psSHP->nMaxRecords );
+	psSHP->panRecSize = (int *) 
+            SfRealloc(psSHP->panRecSize,sizeof(int) * psSHP->nMaxRecords );
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Initialize record.                                              */
+/* -------------------------------------------------------------------- */
+    pabyRec = (uchar *) malloc(psObject->nVertices * 4 * sizeof(double) 
+			       + psObject->nParts * 8 + 128);
+    
+/* -------------------------------------------------------------------- */
+/*  Extract vertices for a Polygon or Arc.				*/
+/* -------------------------------------------------------------------- */
+    if( psObject->nSHPType == SHPT_POLYGON
+        || psObject->nSHPType == SHPT_POLYGONZ
+        || psObject->nSHPType == SHPT_POLYGONM
+        || psObject->nSHPType == SHPT_ARC 
+        || psObject->nSHPType == SHPT_ARCZ
+        || psObject->nSHPType == SHPT_ARCM
+        || psObject->nSHPType == SHPT_MULTIPATCH )
+    {
+	int32		nPoints, nParts;
+	int    		i;
+
+	nPoints = psObject->nVertices;
+	nParts = psObject->nParts;
+
+	_SHPSetBounds( pabyRec + 12, psObject );
+
+	if( bBigEndian ) SwapWord( 4, &nPoints );
+	if( bBigEndian ) SwapWord( 4, &nParts );
+
+	ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
+	ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
+
+        nRecordSize = 52;
+
+        /*
+         * Write part start positions.
+         */
+	ByteCopy( psObject->panPartStart, pabyRec + 44 + 8,
+                  4 * psObject->nParts );
+	for( i = 0; i < psObject->nParts; i++ )
+	{
+	    if( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i );
+            nRecordSize += 4;
+	}
+
+        /*
+         * Write multipatch part types if needed.
+         */
+        if( psObject->nSHPType == SHPT_MULTIPATCH )
+        {
+            memcpy( pabyRec + nRecordSize, psObject->panPartType,
+                    4*psObject->nParts );
+            for( i = 0; i < psObject->nParts; i++ )
+            {
+                if( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize );
+                nRecordSize += 4;
+            }
+        }
+
+        /*
+         * Write the (x,y) vertex values.
+         */
+	for( i = 0; i < psObject->nVertices; i++ )
+	{
+	    ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 );
+	    ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 );
+
+	    if( bBigEndian )
+                SwapWord( 8, pabyRec + nRecordSize );
+            
+	    if( bBigEndian )
+                SwapWord( 8, pabyRec + nRecordSize + 8 );
+
+            nRecordSize += 2 * 8;
+	}
+
+        /*
+         * Write the Z coordinates (if any).
+         */
+        if( psObject->nSHPType == SHPT_POLYGONZ
+            || psObject->nSHPType == SHPT_ARCZ
+            || psObject->nSHPType == SHPT_MULTIPATCH )
+        {
+            ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+            
+            ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+
+            for( i = 0; i < psObject->nVertices; i++ )
+            {
+                ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
+                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+                nRecordSize += 8;
+            }
+        }
+
+        /*
+         * Write the M values, if any.
+         */
+        if( psObject->nSHPType == SHPT_POLYGONM
+            || psObject->nSHPType == SHPT_ARCM
+#ifndef DISABLE_MULTIPATCH_MEASURE            
+            || psObject->nSHPType == SHPT_MULTIPATCH
+#endif            
+            || psObject->nSHPType == SHPT_POLYGONZ
+            || psObject->nSHPType == SHPT_ARCZ )
+        {
+            ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+            
+            ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+
+            for( i = 0; i < psObject->nVertices; i++ )
+            {
+                ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
+                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+                nRecordSize += 8;
+            }
+        }
+    }
+
+/* -------------------------------------------------------------------- */
+/*  Extract vertices for a MultiPoint.					*/
+/* -------------------------------------------------------------------- */
+    else if( psObject->nSHPType == SHPT_MULTIPOINT
+             || psObject->nSHPType == SHPT_MULTIPOINTZ
+             || psObject->nSHPType == SHPT_MULTIPOINTM )
+    {
+	int32		nPoints;
+	int    		i;
+
+	nPoints = psObject->nVertices;
+
+        _SHPSetBounds( pabyRec + 12, psObject );
+
+	if( bBigEndian ) SwapWord( 4, &nPoints );
+	ByteCopy( &nPoints, pabyRec + 44, 4 );
+	
+	for( i = 0; i < psObject->nVertices; i++ )
+	{
+	    ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 );
+	    ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 );
+
+	    if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 );
+	    if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 );
+	}
+
+	nRecordSize = 48 + 16 * psObject->nVertices;
+
+        if( psObject->nSHPType == SHPT_MULTIPOINTZ )
+        {
+            ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+
+            ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+            
+            for( i = 0; i < psObject->nVertices; i++ )
+            {
+                ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
+                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+                nRecordSize += 8;
+            }
+        }
+
+        if( psObject->nSHPType == SHPT_MULTIPOINTZ
+            || psObject->nSHPType == SHPT_MULTIPOINTM )
+        {
+            ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+
+            ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+            
+            for( i = 0; i < psObject->nVertices; i++ )
+            {
+                ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
+                if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+                nRecordSize += 8;
+            }
+        }
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Write point.							*/
+/* -------------------------------------------------------------------- */
+    else if( psObject->nSHPType == SHPT_POINT
+             || psObject->nSHPType == SHPT_POINTZ
+             || psObject->nSHPType == SHPT_POINTM )
+    {
+	ByteCopy( psObject->padfX, pabyRec + 12, 8 );
+	ByteCopy( psObject->padfY, pabyRec + 20, 8 );
+
+	if( bBigEndian ) SwapWord( 8, pabyRec + 12 );
+	if( bBigEndian ) SwapWord( 8, pabyRec + 20 );
+
+        nRecordSize = 28;
+        
+        if( psObject->nSHPType == SHPT_POINTZ )
+        {
+            ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+        }
+        
+        if( psObject->nSHPType == SHPT_POINTZ
+            || psObject->nSHPType == SHPT_POINTM )
+        {
+            ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 );
+            if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
+            nRecordSize += 8;
+        }
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Not much to do for null geometries.                             */
+/* -------------------------------------------------------------------- */
+    else if( psObject->nSHPType == SHPT_NULL )
+    {
+        nRecordSize = 12;
+    }
+
+    else
+    {
+        /* unknown type */
+        assert( FALSE );
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Establish where we are going to put this record. If we are      */
+/*      rewriting and existing record, and it will fit, then put it     */
+/*      back where the original came from.  Otherwise write at the end. */
+/* -------------------------------------------------------------------- */
+    if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 )
+    {
+        if( nShapeId == -1 )
+            nShapeId = psSHP->nRecords++;
+
+        psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize;
+        psSHP->panRecSize[nShapeId] = nRecordSize-8;
+        psSHP->nFileSize += nRecordSize;
+    }
+    else
+    {
+        nRecordOffset = psSHP->panRecOffset[nShapeId];
+    }
+    
+/* -------------------------------------------------------------------- */
+/*      Set the shape type, record number, and record size.             */
+/* -------------------------------------------------------------------- */
+    i32 = nShapeId+1;					/* record # */
+    if( !bBigEndian ) SwapWord( 4, &i32 );
+    ByteCopy( &i32, pabyRec, 4 );
+
+    i32 = (nRecordSize-8)/2;				/* record size */
+    if( !bBigEndian ) SwapWord( 4, &i32 );
+    ByteCopy( &i32, pabyRec + 4, 4 );
+
+    i32 = psObject->nSHPType;				/* shape type */
+    if( bBigEndian ) SwapWord( 4, &i32 );
+    ByteCopy( &i32, pabyRec + 8, 4 );
+
+/* -------------------------------------------------------------------- */
+/*      Write out record.                                               */
+/* -------------------------------------------------------------------- */
+    if( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0
+        || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
+    {
+        printf( "Error in fseek() or fwrite().\n" );
+        free( pabyRec );
+        return -1;
+    }
+    
+    free( pabyRec );
+
+/* -------------------------------------------------------------------- */
+/*	Expand file wide bounds based on this shape.			*/
+/* -------------------------------------------------------------------- */
+    if( psSHP->adBoundsMin[0] == 0.0
+        && psSHP->adBoundsMax[0] == 0.0
+        && psSHP->adBoundsMin[1] == 0.0
+        && psSHP->adBoundsMax[1] == 0.0 
+        && psObject->nSHPType != SHPT_NULL )
+    {
+        psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
+        psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
+        psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0];
+        psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0];
+    }
+
+    for( i = 0; i < psObject->nVertices; i++ )
+    {
+	psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0],psObject->padfX[i]);
+	psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1],psObject->padfY[i]);
+	psSHP->adBoundsMin[2] = MIN(psSHP->adBoundsMin[2],psObject->padfZ[i]);
+	psSHP->adBoundsMin[3] = MIN(psSHP->adBoundsMin[3],psObject->padfM[i]);
+	psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0],psObject->padfX[i]);
+	psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1],psObject->padfY[i]);
+	psSHP->adBoundsMax[2] = MAX(psSHP->adBoundsMax[2],psObject->padfZ[i]);
+	psSHP->adBoundsMax[3] = MAX(psSHP->adBoundsMax[3],psObject->padfM[i]);
+    }
+
+    return( nShapeId  );
+}
+
+/************************************************************************/
+/*                          SHPReadObject()                             */
+/*                                                                      */
+/*      Read the vertices, parts, and other non-attribute information	*/
+/*	for one shape.							*/
+/************************************************************************/
+
+SHPObject SHPAPI_CALL1(*)
+SHPReadObject( SHPHandle psSHP, int hEntity )
+
+{
+    SHPObject		*psShape;
+
+/* -------------------------------------------------------------------- */
+/*      Validate the record/entity number.                              */
+/* -------------------------------------------------------------------- */
+    if( hEntity < 0 || hEntity >= psSHP->nRecords )
+        return( NULL );
+
+/* -------------------------------------------------------------------- */
+/*      Ensure our record buffer is large enough.                       */
+/* -------------------------------------------------------------------- */
+    if( psSHP->panRecSize[hEntity]+8 > psSHP->nBufSize )
+    {
+	psSHP->nBufSize = psSHP->panRecSize[hEntity]+8;
+	psSHP->pabyRec = (uchar *) SfRealloc(psSHP->pabyRec,psSHP->nBufSize);
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Read the record.                                                */
+/* -------------------------------------------------------------------- */
+    fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 );
+    fread( psSHP->pabyRec, psSHP->panRecSize[hEntity]+8, 1, psSHP->fpSHP );
+
+/* -------------------------------------------------------------------- */
+/*	Allocate and minimally initialize the object.			*/
+/* -------------------------------------------------------------------- */
+    psShape = (SHPObject *) calloc(1,sizeof(SHPObject));
+    psShape->nShapeId = hEntity;
+
+    memcpy( &psShape->nSHPType, psSHP->pabyRec + 8, 4 );
+    if( bBigEndian ) SwapWord( 4, &(psShape->nSHPType) );
+
+/* ==================================================================== */
+/*  Extract vertices for a Polygon or Arc.				*/
+/* ==================================================================== */
+    if( psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC
+        || psShape->nSHPType == SHPT_POLYGONZ
+        || psShape->nSHPType == SHPT_POLYGONM
+        || psShape->nSHPType == SHPT_ARCZ
+        || psShape->nSHPType == SHPT_ARCM
+        || psShape->nSHPType == SHPT_MULTIPATCH )
+    {
+	int32		nPoints, nParts;
+	int    		i, nOffset;
+
+/* -------------------------------------------------------------------- */
+/*	Get the X/Y bounds.						*/
+/* -------------------------------------------------------------------- */
+        memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 +  4, 8 );
+        memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
+        memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
+        memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
+
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
+
+/* -------------------------------------------------------------------- */
+/*      Extract part/point count, and build vertex and part arrays      */
+/*      to proper size.                                                 */
+/* -------------------------------------------------------------------- */
+	memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
+	memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
+
+	if( bBigEndian ) SwapWord( 4, &nPoints );
+	if( bBigEndian ) SwapWord( 4, &nParts );
+
+	psShape->nVertices = nPoints;
+        psShape->padfX = (double *) calloc(nPoints,sizeof(double));
+        psShape->padfY = (double *) calloc(nPoints,sizeof(double));
+        psShape->padfZ = (double *) calloc(nPoints,sizeof(double));
+        psShape->padfM = (double *) calloc(nPoints,sizeof(double));
+
+	psShape->nParts = nParts;
+        psShape->panPartStart = (int *) calloc(nParts,sizeof(int));
+        psShape->panPartType = (int *) calloc(nParts,sizeof(int));
+
+        for( i = 0; i < nParts; i++ )
+            psShape->panPartType[i] = SHPP_RING;
+
+/* -------------------------------------------------------------------- */
+/*      Copy out the part array from the record.                        */
+/* -------------------------------------------------------------------- */
+	memcpy( psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
+	for( i = 0; i < nParts; i++ )
+	{
+	    if( bBigEndian ) SwapWord( 4, psShape->panPartStart+i );
+	}
+
+	nOffset = 44 + 8 + 4*nParts;
+
+/* -------------------------------------------------------------------- */
+/*      If this is a multipatch, we will also have parts types.         */
+/* -------------------------------------------------------------------- */
+        if( psShape->nSHPType == SHPT_MULTIPATCH )
+        {
+            memcpy( psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
+            for( i = 0; i < nParts; i++ )
+            {
+                if( bBigEndian ) SwapWord( 4, psShape->panPartType+i );
+            }
+
+            nOffset += 4*nParts;
+        }
+        
+/* -------------------------------------------------------------------- */
+/*      Copy out the vertices from the record.                          */
+/* -------------------------------------------------------------------- */
+	for( i = 0; i < nPoints; i++ )
+	{
+	    memcpy(psShape->padfX + i,
+		   psSHP->pabyRec + nOffset + i * 16,
+		   8 );
+
+	    memcpy(psShape->padfY + i,
+		   psSHP->pabyRec + nOffset + i * 16 + 8,
+		   8 );
+
+	    if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
+	    if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
+	}
+
+        nOffset += 16*nPoints;
+        
+/* -------------------------------------------------------------------- */
+/*      If we have a Z coordinate, collect that now.                    */
+/* -------------------------------------------------------------------- */
+        if( psShape->nSHPType == SHPT_POLYGONZ
+            || psShape->nSHPType == SHPT_ARCZ
+            || psShape->nSHPType == SHPT_MULTIPATCH )
+        {
+            memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
+            memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
+            
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
+            
+            for( i = 0; i < nPoints; i++ )
+            {
+                memcpy( psShape->padfZ + i,
+                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
+                if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
+            }
+
+            nOffset += 16 + 8*nPoints;
+        }
+
+/* -------------------------------------------------------------------- */
+/*      If we have a M measure value, then read it now.  We assume      */
+/*      that the measure can be present for any shape if the size is    */
+/*      big enough, but really it will only occur for the Z shapes      */
+/*      (options), and the M shapes.                                    */
+/* -------------------------------------------------------------------- */
+        if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints )
+        {
+            memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
+            memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
+            
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
+            
+            for( i = 0; i < nPoints; i++ )
+            {
+                memcpy( psShape->padfM + i,
+                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
+                if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
+            }
+        }
+        
+    }
+
+/* ==================================================================== */
+/*  Extract vertices for a MultiPoint.					*/
+/* ==================================================================== */
+    else if( psShape->nSHPType == SHPT_MULTIPOINT
+             || psShape->nSHPType == SHPT_MULTIPOINTM
+             || psShape->nSHPType == SHPT_MULTIPOINTZ )
+    {
+	int32		nPoints;
+	int    		i, nOffset;
+
+	memcpy( &nPoints, psSHP->pabyRec + 44, 4 );
+	if( bBigEndian ) SwapWord( 4, &nPoints );
+
+	psShape->nVertices = nPoints;
+        psShape->padfX = (double *) calloc(nPoints,sizeof(double));
+        psShape->padfY = (double *) calloc(nPoints,sizeof(double));
+        psShape->padfZ = (double *) calloc(nPoints,sizeof(double));
+        psShape->padfM = (double *) calloc(nPoints,sizeof(double));
+
+	for( i = 0; i < nPoints; i++ )
+	{
+	    memcpy(psShape->padfX+i, psSHP->pabyRec + 48 + 16 * i, 8 );
+	    memcpy(psShape->padfY+i, psSHP->pabyRec + 48 + 16 * i + 8, 8 );
+
+	    if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
+	    if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
+	}
+
+        nOffset = 48 + 16*nPoints;
+        
+/* -------------------------------------------------------------------- */
+/*	Get the X/Y bounds.						*/
+/* -------------------------------------------------------------------- */
+        memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 +  4, 8 );
+        memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
+        memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
+        memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
+
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
+	if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
+
+/* -------------------------------------------------------------------- */
+/*      If we have a Z coordinate, collect that now.                    */
+/* -------------------------------------------------------------------- */
+        if( psShape->nSHPType == SHPT_MULTIPOINTZ )
+        {
+            memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
+            memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
+            
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
+            
+            for( i = 0; i < nPoints; i++ )
+            {
+                memcpy( psShape->padfZ + i,
+                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
+                if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
+            }
+
+            nOffset += 16 + 8*nPoints;
+        }
+
+/* -------------------------------------------------------------------- */
+/*      If we have a M measure value, then read it now.  We assume      */
+/*      that the measure can be present for any shape if the size is    */
+/*      big enough, but really it will only occur for the Z shapes      */
+/*      (options), and the M shapes.                                    */
+/* -------------------------------------------------------------------- */
+        if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints )
+        {
+            memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
+            memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
+            
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
+            if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
+            
+            for( i = 0; i < nPoints; i++ )
+            {
+                memcpy( psShape->padfM + i,
+                        psSHP->pabyRec + nOffset + 16 + i*8, 8 );
+                if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
+            }
+        }
+    }
+
+/* ==================================================================== */
+/*      Extract vertices for a point.                                   */
+/* ==================================================================== */
+    else if( psShape->nSHPType == SHPT_POINT
+             || psShape->nSHPType == SHPT_POINTM
+             || psShape->nSHPType == SHPT_POINTZ )
+    {
+        int	nOffset;
+        
+	psShape->nVertices = 1;
+        psShape->padfX = (double *) calloc(1,sizeof(double));
+        psShape->padfY = (double *) calloc(1,sizeof(double));
+        psShape->padfZ = (double *) calloc(1,sizeof(double));
+        psShape->padfM = (double *) calloc(1,sizeof(double));
+
+	memcpy( psShape->padfX, psSHP->pabyRec + 12, 8 );
+	memcpy( psShape->padfY, psSHP->pabyRec + 20, 8 );
+
+	if( bBigEndian ) SwapWord( 8, psShape->padfX );
+	if( bBigEndian ) SwapWord( 8, psShape->padfY );
+
+        nOffset = 20 + 8;
+        
+/* -------------------------------------------------------------------- */
+/*      If we have a Z coordinate, collect that now.                    */
+/* -------------------------------------------------------------------- */
+        if( psShape->nSHPType == SHPT_POINTZ )
+        {
+            memcpy( psShape->padfZ, psSHP->pabyRec + nOffset, 8 );
+        
+            if( bBigEndian ) SwapWord( 8, psShape->padfZ );
+            
+            nOffset += 8;
+        }
+
+/* -------------------------------------------------------------------- */
+/*      If we have a M measure value, then read it now.  We assume      */
+/*      that the measure can be present for any shape if the size is    */
+/*      big enough, but really it will only occur for the Z shapes      */
+/*      (options), and the M shapes.                                    */
+/* -------------------------------------------------------------------- */
+        if( psSHP->panRecSize[hEntity]+8 >= nOffset + 8 )
+        {
+            memcpy( psShape->padfM, psSHP->pabyRec + nOffset, 8 );
+        
+            if( bBigEndian ) SwapWord( 8, psShape->padfM );
+        }
+
+/* -------------------------------------------------------------------- */
+/*      Since no extents are supplied in the record, we will apply      */
+/*      them from the single vertex.                                    */
+/* -------------------------------------------------------------------- */
+        psShape->dfXMin = psShape->dfXMax = psShape->padfX[0];
+        psShape->dfYMin = psShape->dfYMax = psShape->padfY[0];
+        psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0];
+        psShape->dfMMin = psShape->dfMMax = psShape->padfM[0];
+    }
+
+    return( psShape );
+}
+
+/************************************************************************/
+/*                            SHPTypeName()                             */
+/************************************************************************/
+
+const char SHPAPI_CALL1(*)
+SHPTypeName( int nSHPType )
+
+{
+    switch( nSHPType )
+    {
+      case SHPT_NULL:
+        return "NullShape";
+
+      case SHPT_POINT:
+        return "Point";
+
+      case SHPT_ARC:
+        return "Arc";
+
+      case SHPT_POLYGON:
+        return "Polygon";
+
+      case SHPT_MULTIPOINT:
+        return "MultiPoint";
+        
+      case SHPT_POINTZ:
+        return "PointZ";
+
+      case SHPT_ARCZ:
+        return "ArcZ";
+
+      case SHPT_POLYGONZ:
+        return "PolygonZ";
+
+      case SHPT_MULTIPOINTZ:
+        return "MultiPointZ";
+        
+      case SHPT_POINTM:
+        return "PointM";
+
+      case SHPT_ARCM:
+        return "ArcM";
+
+      case SHPT_POLYGONM:
+        return "PolygonM";
+
+      case SHPT_MULTIPOINTM:
+        return "MultiPointM";
+
+      case SHPT_MULTIPATCH:
+        return "MultiPatch";
+
+      default:
+        return "UnknownShapeType";
+    }
+}
+
+/************************************************************************/
+/*                          SHPPartTypeName()                           */
+/************************************************************************/
+
+const char SHPAPI_CALL1(*)
+SHPPartTypeName( int nPartType )
+
+{
+    switch( nPartType )
+    {
+      case SHPP_TRISTRIP:
+        return "TriangleStrip";
+        
+      case SHPP_TRIFAN:
+        return "TriangleFan";
+
+      case SHPP_OUTERRING:
+        return "OuterRing";
+
+      case SHPP_INNERRING:
+        return "InnerRing";
+
+      case SHPP_FIRSTRING:
+        return "FirstRing";
+
+      case SHPP_RING:
+        return "Ring";
+
+      default:
+        return "UnknownPartType";
+    }
+}
+
+/************************************************************************/
+/*                          SHPDestroyObject()                          */
+/************************************************************************/
+
+void SHPAPI_CALL
+SHPDestroyObject( SHPObject * psShape )
+
+{
+    if( psShape == NULL )
+        return;
+    
+    if( psShape->padfX != NULL )
+        free( psShape->padfX );
+    if( psShape->padfY != NULL )
+        free( psShape->padfY );
+    if( psShape->padfZ != NULL )
+        free( psShape->padfZ );
+    if( psShape->padfM != NULL )
+        free( psShape->padfM );
+
+    if( psShape->panPartStart != NULL )
+        free( psShape->panPartStart );
+    if( psShape->panPartType != NULL )
+        free( psShape->panPartType );
+
+    free( psShape );
+}
+
+/************************************************************************/
+/*                          SHPRewindObject()                           */
+/*                                                                      */
+/*      Reset the winding of polygon objects to adhere to the           */
+/*      specification.                                                  */
+/************************************************************************/
+
+int SHPAPI_CALL
+SHPRewindObject( SHPHandle hSHP, SHPObject * psObject )
+
+{
+    int  iOpRing, bAltered = 0;
+
+/* -------------------------------------------------------------------- */
+/*      Do nothing if this is not a polygon object.                     */
+/* -------------------------------------------------------------------- */
+    if( psObject->nSHPType != SHPT_POLYGON
+        && psObject->nSHPType != SHPT_POLYGONZ
+        && psObject->nSHPType != SHPT_POLYGONM )
+        return 0;
+
+/* -------------------------------------------------------------------- */
+/*      Process each of the rings.                                      */
+/* -------------------------------------------------------------------- */
+    for( iOpRing = 0; iOpRing < psObject->nParts; iOpRing++ )
+    {
+        int      bInner, iVert, nVertCount, nVertStart, iCheckRing;
+        double   dfSum, dfTestX, dfTestY;
+
+/* -------------------------------------------------------------------- */
+/*      Determine if this ring is an inner ring or an outer ring        */
+/*      relative to all the other rings.  For now we assume the         */
+/*      first ring is outer and all others are inner, but eventually    */
+/*      we need to fix this to handle multiple island polygons and      */
+/*      unordered sets of rings.                                        */
+/* -------------------------------------------------------------------- */
+        dfTestX = psObject->padfX[psObject->panPartStart[iOpRing]];
+        dfTestY = psObject->padfY[psObject->panPartStart[iOpRing]];
+
+        bInner = FALSE;
+        for( iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++ )
+        {
+            int iEdge;
+
+            if( iCheckRing == iOpRing )
+                continue;
+            
+            nVertStart = psObject->panPartStart[iCheckRing];
+
+            if( iCheckRing == psObject->nParts-1 )
+                nVertCount = psObject->nVertices 
+                    - psObject->panPartStart[iCheckRing];
+            else
+                nVertCount = psObject->panPartStart[iCheckRing+1] 
+                    - psObject->panPartStart[iCheckRing];
+
+            for( iEdge = 0; iEdge < nVertCount; iEdge++ )
+            {
+                int iNext;
+
+                if( iEdge < nVertCount-1 )
+                    iNext = iEdge+1;
+                else
+                    iNext = 0;
+
+                if( (psObject->padfY[iEdge+nVertStart] < dfTestY 
+                     && psObject->padfY[iNext+nVertStart] >= dfTestY)
+                    || (psObject->padfY[iNext+nVertStart] < dfTestY 
+                        && psObject->padfY[iEdge+nVertStart] >= dfTestY) )
+                {
+                    if( psObject->padfX[iEdge+nVertStart] 
+                        + (dfTestY - psObject->padfY[iEdge+nVertStart])
+                           / (psObject->padfY[iNext+nVertStart]
+                              - psObject->padfY[iEdge+nVertStart])
+                           * (psObject->padfX[iNext+nVertStart]
+                              - psObject->padfX[iEdge+nVertStart]) < dfTestX )
+                        bInner = !bInner;
+                }
+            }
+        }
+
+/* -------------------------------------------------------------------- */
+/*      Determine the current order of this ring so we will know if     */
+/*      it has to be reversed.                                          */
+/* -------------------------------------------------------------------- */
+        nVertStart = psObject->panPartStart[iOpRing];
+
+        if( iOpRing == psObject->nParts-1 )
+            nVertCount = psObject->nVertices - psObject->panPartStart[iOpRing];
+        else
+            nVertCount = psObject->panPartStart[iOpRing+1] 
+                - psObject->panPartStart[iOpRing];
+
+        dfSum = 0.0;
+        for( iVert = nVertStart; iVert < nVertStart+nVertCount-1; iVert++ )
+        {
+            dfSum += psObject->padfX[iVert] * psObject->padfY[iVert+1]
+                - psObject->padfY[iVert] * psObject->padfX[iVert+1];
+        }
+
+        dfSum += psObject->padfX[iVert] * psObject->padfY[nVertStart]
+               - psObject->padfY[iVert] * psObject->padfX[nVertStart];
+
+/* -------------------------------------------------------------------- */
+/*      Reverse if necessary.                                           */
+/* -------------------------------------------------------------------- */
+        if( (dfSum < 0.0 && bInner) || (dfSum > 0.0 && !bInner) )
+        {
+            int   i;
+
+            bAltered++;
+            for( i = 0; i < nVertCount/2; i++ )
+            {
+                double dfSaved;
+
+                /* Swap X */
+                dfSaved = psObject->padfX[nVertStart+i];
+                psObject->padfX[nVertStart+i] = 
+                    psObject->padfX[nVertStart+nVertCount-i-1];
+                psObject->padfX[nVertStart+nVertCount-i-1] = dfSaved;
+
+                /* Swap Y */
+                dfSaved = psObject->padfY[nVertStart+i];
+                psObject->padfY[nVertStart+i] = 
+                    psObject->padfY[nVertStart+nVertCount-i-1];
+                psObject->padfY[nVertStart+nVertCount-i-1] = dfSaved;
+
+                /* Swap Z */
+                if( psObject->padfZ )
+                {
+                    dfSaved = psObject->padfZ[nVertStart+i];
+                    psObject->padfZ[nVertStart+i] = 
+                        psObject->padfZ[nVertStart+nVertCount-i-1];
+                    psObject->padfZ[nVertStart+nVertCount-i-1] = dfSaved;
+                }
+
+                /* Swap M */
+                if( psObject->padfM )
+                {
+                    dfSaved = psObject->padfM[nVertStart+i];
+                    psObject->padfM[nVertStart+i] = 
+                        psObject->padfM[nVertStart+nVertCount-i-1];
+                    psObject->padfM[nVertStart+nVertCount-i-1] = dfSaved;
+                }
+            }
+        }
+    }
+
+    return bAltered;
+}
diff --git a/src/drivers/BaseDriver.cc b/src/drivers/BaseDriver.cc
new file mode 100644
index 0000000..2cf2b54
--- /dev/null
+++ b/src/drivers/BaseDriver.cc
@@ -0,0 +1,685 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseDriver.cc
+    \brief Implementation of driver base class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+*/
+
+#include <BaseDriver.h>
+
+#include <Layout.h>
+#include <Layer.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <BinaryObject.h>
+#include <Colour.h>
+#include <Arrow.h>
+#include <Flag.h>
+#include <ImportObject.h>
+#include <Image.h>
+#include <Symbol.h>
+#include <PaperPoint.h>
+#include "AnimationRules.h"
+
+#include <BaseDriverSymbols.h>
+#include <BaseDriverWind.h>
+#include <BaseDriverImages.h>
+#include <BaseDriverBinaryReader.cc>
+
+#include <System.h>
+
+using namespace magics;
+
+int BaseDriver::numFiles_ = 0;
+
+
+
+//! Constructor for all drivers
+/*!
+  Main job is to initialise most variables and read font information
+*/
+BaseDriver::BaseDriver():currentPage_(-1),fileName_(""),currentLayer_(""),
+        currentLineType_(M_SOLID),currentLineWidth_(-1), currentLineStyle_(1),currentColour_(Colour("white")),
+	coordRatioX_(1),coordRatioY_(1),
+//	lastAreaHeightPercentage_(0.),lastAreaWidthPercentage_(0.),
+	newPage_(true),//newLayout_(true), // external_(false),
+	disabled_(false),alphaEnabled_(false),
+	indexHatch_(0),currentShading_(M_SH_NONE),cmScale_(1.),
+	xDeviceLength_(MagTranslator<double, double>().magics("SUPER_PAGE_X_LENGTH")),
+	yDeviceLength_(MagTranslator<double, double>().magics("SUPER_PAGE_Y_LENGTH")),obs_distance_(-1.)
+//	polylineAntialiasing_(false),
+{
+        //width in pixels  = cm * 2.54 * dpi
+        //height in pixels = cm * 2.54 * dpi
+/*        const string size = getSize();
+        const MFloat cmdpi = 2.54 * 72.;
+        if(!magCompare(size,"a4"))
+        {
+            string::size_type posX = size.find_first_of("x");
+            if(posX != string::npos)
+            {
+                const string first = size.substr(0,posX);
+                string::size_type posCM = size.find_first_of("c",posX+1);
+                if(posCM != string::npos) // assume CM
+                {
+                   MFloat xcm=0.;
+                   MFloat ycm=0.;
+                   istringstream is(first);
+                   is>>xcm;
+                   xDeviceLength_ = static_cast<int>(xcm * cmdpi);
+                   const string second = size.substr(posX+1,posCM);
+                   istringstream iy(second);
+                   iy>>ycm;
+                   yDeviceLength_ = static_cast<int>(ycm * cmdpi);
+                }
+                else   // assume pixels
+                {
+                   xDeviceLength_ = atoi(first.c_str());
+                   const string second = size.substr(posX+1);
+                   yDeviceLength_ = atoi(second.c_str());
+                }
+            }
+            else
+            {
+                if     (magCompare(size,"a4")) {xDeviceLength_= 21.  * cmdpi; yDeviceLength_= 29.7 * cmdpi;}
+                else if(magCompare(size,"a3")) {xDeviceLength_= 29.7 * cmdpi; yDeviceLength_= 42.  * cmdpi;}
+            }
+        }
+*/
+}
+
+BaseDriver::~BaseDriver()
+{
+  FontMap_.clear();
+}
+
+
+/*! \brief Method set solid fill shading properties
+
+ \sa renderSimplePolygon
+*/
+void BaseDriver::shade(const FillShadingProperties& properties)  const
+{
+	currentShading_ = M_SH_SOLID;
+	currentShadingProperties_ = &properties;
+}
+
+/*! \brief Method set hatch fill shading properties
+
+ \sa renderSimplePolygon
+*/
+void BaseDriver::shade(const HatchShadingProperties& properties) const
+{
+	currentShading_ = M_SH_HATCH;
+	currentShadingProperties_ = &properties;
+}
+
+/*! \brief Method set dot fill shading properties
+
+ \sa renderSimplePolygon
+*/
+void BaseDriver::shade(const DotShadingProperties& properties)   const
+{
+	currentShading_ = M_SH_DOT;
+	currentShadingProperties_ = &properties;
+}
+
+/*!
+ \brief Method to print list of all generated files in the driver
+*/
+void BaseDriver::printOutputName(const std::string & str) const
+{
+	if(filelist_)
+	{
+		const SystemInfo info;
+		fstream fs;
+		if(numFiles_ == 0)
+		{
+			fs.open(filelist_name_.c_str(),fstream::out);
+			fs << "# "<< getMagicsVersionString()<< " "<<info.getHostName() <<" " << info.getTime()<< "\n";
+		}
+		else
+			fs.open(filelist_name_.c_str(),fstream::out | fstream::app);
+
+		fs << info.getTime()<< " "<<str<< "\n";
+		fs.close();
+		numFiles_++;
+	}
+}
+
+
+//! Method to read font information
+/*!
+ A hash table is produce to map font names to file names of TTF files.
+
+  \todo make this a singleton!?
+*/
+void BaseDriver::readFonts() const
+{
+	const string s = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "Fonts.dat";
+	ifstream psfile(s.c_str());
+
+	if(psfile)
+	{
+		int	id;
+		char	temp[128];
+		char	magics_name[64];
+		char	ps_name[128];
+		char	ps_filename[128];
+		char	ttf_filename[128];
+		char	css_name[128];
+
+		// read header (4 lines) and ignore
+		psfile.getline(temp,128);psfile.getline(temp,128);
+		psfile.getline(temp,128);psfile.getline(temp,128);
+
+		while (!psfile.eof())
+		{
+			magFont font;
+			psfile >> id >> magics_name >> ps_name >> ps_filename >> ttf_filename >> css_name;
+			font.id = id;
+			font.magics_name = magics_name;
+			font.ps_name = ps_name;
+			font.ps_filename = ps_filename;
+			font.ttf_filename = ttf_filename;
+			font.css_name = css_name;
+			FontMap_[string(magics_name)]= font;
+		}
+		psfile.close();
+	}
+	else MagLog::fatal() << "BaseDriver::readFonts() --> Cannot open Font file " << s << " ! No text can be plotted.\n";
+}
+
+/*! \brief formulating a filename
+
+  This method is used to add the page number for multipage output,
+  such in PostScriptDriver (if EPS or splitted), GDDriver (if not animated)
+  and SVGDriver.
+
+  It preserves the file name extension, and it needs it !!!
+*/
+string BaseDriver::getFileName(const string &extension, const unsigned int no) const
+{
+	string ext = "."+extension;
+	bool full     = false;
+	bool legacy   = false;
+
+	string filename = name_;
+	if(filename.empty())
+	{
+	  filename = fullname_;
+	  if(!filename.empty()) full = true;
+	}
+	if(filename.empty())
+	{
+	  filename = legacyname_;
+	  if(!filename.empty()) legacy = true;
+	}
+	if(filename.empty())
+	{
+	  filename = extension;
+	}
+
+	// name stays the same as given
+	if( no==0 && (full || (legacy && extension=="ps")) ) return filename;
+	if( no==0 )  { filename += ext; return filename;}
+//	if( external_ )   { filename += "_legend"+ext; return filename;}
+
+
+	// if nothing is set
+	if(filename=="") filename = "magics";
+
+	if(full)
+	{
+		string::size_type pos = filename.find_last_of(".");
+		if(pos != string::npos)
+		{
+			const string f = filename.substr(0,pos);
+			const string t = filename.substr(pos);
+			ext = t;
+			filename = f;
+		}
+	}
+
+	const int numberWidth = numberingwidth_;
+
+	if( (no > 1) || firstnumber_ || legacy )
+	{
+		char *ostr;
+		if(numberWidth==4)      {ostr=new char[5]; sprintf(ostr,"%04u",no);}
+		else if(numberWidth==3) {ostr=new char[4]; sprintf(ostr,"%03u",no);}
+		else if(numberWidth==2) {ostr=new char[3]; sprintf(ostr,"%02u",no);}
+		else                    {ostr=new char[2]; sprintf(ostr,"%u",no);}
+		filename += separator_+ostr+ext;
+		delete [] ostr;
+	}
+	else // if first page no number
+	{
+		filename += ext;
+	}
+
+	return filename;
+}
+
+
+/*!
+  \brief processing layouts
+  This methods processes the Layout objects. It needs to be checked if a Layout is a new page or not.
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const Layout& layout) const 
+{
+	project(layout);
+	staLayouts_.push(&layout);
+	layout.visit(*this);  // visit this layout!
+	unproject();
+}
+
+
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const RootLayout& root) const
+{
+	root.visit(*this);  // visit this ROOT layout!
+}
+
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const LegendLayout& legend) const
+{
+	redisplay((const Layout&) legend);
+}
+
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const SceneLayout& scene) const
+{
+	redisplay((const Layout&) scene);
+}
+
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const StartPage& ) const
+{
+   startPage();
+}
+
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const EndPage& ) const
+{
+   endPage();
+   vecPoints_.clear();
+}
+
+
+void BaseDriver::redisplay(const PolylineSet& line) const
+{
+      line.visit(*this);
+}
+
+/*!
+  \brief Decision how to stroke/fill simple polygon
+  
+  Overwritten in SVGDriver::redisplay(const Polyline& line) const
+*/
+void BaseDriver::redisplay(const Polyline& line) const
+{
+	if(line.isFilled())   renderSimplePolygon(line);
+	if(line.isStroked())  printLine(line);
+}
+
+void BaseDriver::redisplay(const Arrow& arrow) const
+{
+	renderWindArrow(arrow);
+}
+
+void BaseDriver::redisplay(const Flag& flag) const
+{
+	renderWindFlag(flag);
+}
+
+void BaseDriver::redisplay(const ImportObject& object) const
+{
+	renderImage(object);
+}
+
+void BaseDriver::redisplay(const Image& object) const
+{
+	renderCellArray(object);
+}
+
+void BaseDriver::redisplay(const Text& text) const
+{
+	renderText(text);
+}
+
+void BaseDriver::redisplay(const Symbol& symbol) const
+{
+	renderSymbols(symbol);
+}
+
+void BaseDriver::redisplay(const TextSymbol& symbol) const 
+{
+	renderTextSymbols(symbol);
+}
+
+void BaseDriver::redisplay(const ComplexSymbol& symbol) const 
+{
+	renderComplexSymbols(symbol);
+}
+
+void BaseDriver::redisplay(const TextItem& text, const ComplexSymbol& symbol) const
+{
+	renderTextItem(text, symbol);
+}
+
+void BaseDriver::redisplay(const SymbolItem& text, const ComplexSymbol& symbol) const
+{
+	renderSymbolItem(text, symbol);
+}
+
+void BaseDriver::redisplay(const FlagItem& text, const ComplexSymbol& symbol) const
+{
+	renderFlagItem(text, symbol);
+}
+
+
+
+/*
+ \brief Least Square fit of a line.
+
+ Returns the angle (in relation to horizon == 0 ).
+
+ \sa printLine
+*/
+double BaseDriver::LSF(MFloat *x,MFloat *y, int i0) const
+{
+	double angle = 0.;
+	double x_sum = 0.;
+	double y_sum = 0.;
+	const unsigned int n = 15;
+
+	for(unsigned int r=0;r<n;r++)
+	{
+		x_sum += projectX(x[i0+r]);
+		y_sum += projectY(y[i0+r]);
+	}
+
+	const double x_over_n = x_sum / n;
+	const double y_over_n = y_sum / n;
+	double sxx = 0;
+	double sxy = 0;
+
+	for(unsigned int r=0;r<n;r++)
+	{
+		const double xi = projectX(x[i0+r]) - x_over_n;
+		const double yi = projectY(y[i0+r]) - y_over_n;
+		sxx  += (xi*xi);
+		sxy  += (xi*yi);
+	}
+	if(sxx != 0) angle = atan2( (sxy/sxx) ,1.);
+	else MagLog::debug() << "BaseDriver: Devision through zero prevented in calculation of Label angle!" << endl;
+
+	return angle;
+}
+
+/*!
+  \brief Method plotting Polylines with Labels.
+
+  \sa renderPolyline renderText
+
+  \todo location memory for labels.
+*/
+void BaseDriver::printLine(const Polyline &line) const
+{
+    const unsigned long n = line.size();
+    if(n < 1) return;
+
+    MFloat *x      = new MFloat[n];
+    MFloat *y      = new MFloat[n];
+
+    for(unsigned long s=0;s<n;s++)
+    {
+        x[s] = line.get(s).x();
+        y[s] = line.get(s).y();
+    }
+
+    // render line - driver specific part
+    if(line.getThickness()>0  && !(line.getColour()==Colour("NONE")) )
+    {
+	setNewColour(line.getColour());
+	currentLineStyle_ = setLineParameters(line.getLineStyle(),line.getThickness());
+
+//	if(line.getAntiAliasing()) polylineAntialiasing_=true;
+	renderPolyline(n, x, y);
+//	polylineAntialiasing_=false;
+    
+	Polyline::Holes::const_iterator h  = line.beginHoles();
+	Polyline::Holes::const_iterator he = line.endHoles();
+
+	for (; h != he; ++h)
+	{
+		vector<double> xx;
+		vector<double> yy;
+		line.hole(h,xx,yy);
+		const unsigned long nn = xx.size();
+		MFloat *nx      = new MFloat[nn];
+		MFloat *ny      = new MFloat[nn];
+		for(unsigned int is=0;is<nn;is++)
+		{
+		  nx[is] = xx[is];
+		  ny[is] = yy[is];
+		}
+		renderPolyline(nn, nx, ny);
+		delete [] nx;
+		delete [] ny;
+	}
+    }
+
+    const unsigned int minimum_points_for_labelling = 32;  // must be at least -15 : see function LSF above
+
+    if (line.getLabel().isVisible() && line.getLabel().getText() != "" && (n > minimum_points_for_labelling))
+    {
+	assert(staLayouts_.empty() == false);
+
+	MFloat *labelx = new MFloat[n];  // in theory, we shouldn't need this many entries...
+	MFloat *labely = new MFloat[n];  // in theory, we shouldn't need this many entries...
+
+	// Store the minimum x,y corner, pretending that we're going to plot a label there.
+	// We won't actually plot a label there though - it's just to make sure that
+	// we don't plot one too close to that point.
+	int num_labels = 1;
+	labelx [0] = staLayouts_.top()->minX();
+	labely [0] = staLayouts_.top()->minY();
+
+	// Calculate how far apart the labels should be.
+	// Our algorithm is to take the average of the width and height and divide by 2.
+	// This should give us approximately 3 labels over the width of the page.
+	const MFloat  coords_range_x = fabs(staLayouts_.top()->maxX()-staLayouts_.top()->minX());
+	const MFloat  coords_range_y = fabs(staLayouts_.top()->maxY()-staLayouts_.top()->minY());
+	const MFloat  min_distance_between_labels = (coords_range_x + coords_range_y) / 4.;
+	const MFloat  min_square_distance_between_labels = (min_distance_between_labels * min_distance_between_labels);
+
+	unsigned int i = 15;
+	while(i < n-minimum_points_for_labelling)
+	{
+	  const double angle = LSF(x,y,i);
+	  const double angle2 = LSF(x,y,i+1);
+	  if(fabs(angle-angle2)< 0.01)
+	  {
+	    const MFloat THIS_X = x[i];
+	    const MFloat THIS_Y = y[i];
+	    const MFloat PREV_X = labelx[num_labels - 1];
+	    const MFloat PREV_Y = labely[num_labels - 1];
+
+	    const double distance_squared = ((THIS_X - PREV_X) * (THIS_X - PREV_X)) + ((THIS_Y - PREV_Y) * (THIS_Y - PREV_Y));
+
+	    if (distance_squared > min_square_distance_between_labels)
+	    {
+                // line fitting
+                MFloat pro_x = x[i+2];
+                MFloat pro_y = y[i+2];  // lines not needed
+                // end of line fitting
+		
+                Text text;
+		PaperPoint pp(pro_x,pro_y);		
+		text.push_back(pp);
+
+		const Label label= line.getLabel();
+
+		text.addText(label.getText(),label.getFontColour(),label.getFontSize()); 
+		text.setBlanking(label.getBlanking());
+		text.setJustification(label.getJustification());
+		text.setVerticalAlign(MHALF);
+		text.setAngle(-setAngleY(angle));	
+
+		renderText(text);
+
+		labelx [num_labels] = x[i];
+		labely [num_labels] = y[i];
+		num_labels++;
+	     }
+	  }//angles are not the same
+	  i++;i++;
+        }
+        delete [] labelx;
+        delete [] labely;
+    }// endif enough points for a label
+
+    delete [] x;
+    delete [] y;
+
+    currentColour_ = Colour("none");
+}
+
+void BaseDriver::renderPolyline(vector<PaperPoint> &vP) const
+{
+	const unsigned int size = vP.size();
+	MFloat *x = new MFloat[size];
+	MFloat *y = new MFloat[size];
+	for(unsigned int i=0;i<size;i++)
+	{
+		x[i] = vP[i].x();
+		y[i] = vP[i].y();
+	}
+	renderPolyline(size,x,y);
+
+	delete [] x;
+	delete [] y;
+}
+
+void BaseDriver::renderPolyline2(vector<PaperPoint> &vP) const
+{
+	const unsigned int size = vP.size();
+	MFloat *x = new MFloat[size];
+	MFloat *y = new MFloat[size];
+	for(int unsigned i=0;i<size;i++)
+	{
+		x[i] = projectX(vP[i].x());
+		y[i] = projectY(vP[i].y());
+	}
+	renderPolyline2(size,x,y);
+
+	delete [] x;
+	delete [] y;
+}
+
+void BaseDriver::renderSimplePolygon(vector<PaperPoint> &vP) const
+{
+	const unsigned int size = vP.size();
+	MFloat *x = new MFloat[size];
+	MFloat *y = new MFloat[size];
+	for(unsigned int i=0;i<size;i++)
+	{
+		x[i] = vP[i].x();
+		y[i] = vP[i].y();
+	}
+	renderSimplePolygon(size,x,y);
+
+	delete [] x;
+	delete [] y;
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void BaseDriver::print(ostream& out) const
+{
+	out << "BaseDriver";
+}
+
+string BaseDriver::getTmpName() const
+{
+	string stmp;
+//	if(getTempdir()!="local") stmp=getTempdir();
+//	string stmp = (tmpdir) ? tmpdir : tmp;
+	stmp+= "magics_temp_ps_XXXXXX";
+	char* mtmp = new char [stmp.length()+1];
+	stmp.copy(mtmp,string::npos);
+	mtmp[stmp.length()] = '\0';
+#ifndef MAGICS_WINDOWS_CYGWIN
+	const int m = mkstemp(mtmp);
+	stmp = ( m ) ? mtmp : " ";
+#endif
+	delete [] mtmp;
+
+	return stmp;
+}
+
+bool BaseDriver::renderCellArray(const Image& ) const
+{
+//	MagLog::dev() << "BaseDriver::renderCellArray" << endl;
+	return true;
+}
+
+bool BaseDriver::renderPixmap(MFloat, MFloat, MFloat, MFloat, int, int, unsigned char*, int, bool) const
+{
+//	MagLog::dev() << "BaseDriver::renderPixmap" << endl;
+	return true;
+}
+
+
+/*!
+  Overwritten in KMLDriver
+  
+  \sa Layer
+*/
+MAGICS_NO_EXPORT void BaseDriver::redisplay(const Layer& layer) const 
+{
+  MagLog::dev() << "BaseDriver::redisplay( layer) > " << layer.name()<< endl;
+}
+
+void BaseDriver::redisplay(const SceneLayer& layer) const
+{
+	for (vector<Layer*>::iterator l = layer.beginLayer(); l != layer.endLayer(); ++l)
+	{
+		(*l)->redisplay(*this);
+	}
+}
+
+void BaseDriver::redisplay(const StaticLayer& layer) const
+{
+	currentLayer_ = layer.name();
+	layer.visit(*this);
+}
+
+void BaseDriver::redisplay(const NoDataLayer& layer) const
+{
+	currentLayer_ = layer.name();
+	layer.visit(*this);
+}
+
+void BaseDriver::redisplay(const StepLayer& layer) const
+{
+  MagLog::dev() << "BaseDriver::redisplay( StepLayer&)" << layer.name()<< endl;
+}
diff --git a/src/drivers/BaseDriver.h b/src/drivers/BaseDriver.h
new file mode 100644
index 0000000..0647c44
--- /dev/null
+++ b/src/drivers/BaseDriver.h
@@ -0,0 +1,503 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \defgroup drivers Output drivers
+
+   \section generalDriver Overview
+
+   Magics++ supports various vector and raster output formats. It
+   produces a generic descriptions of the output plot which
+   than gets converted by a chosen driver to the requested format(s).
+
+   \sa DriverManager::DriverManager(), OutputHandler(), OutputFactory()
+
+   \section usingDrivers Using drivers
+
+   In MagML the \<drivers\> Tag is used to define all drivers being used. Each output
+   format
+
+   Example test/MagML/drivers.magml test/C/drivers.c
+
+   \section addDriver How to add a new output format / driver
+
+   It is assumed you try to add a driver called <i>NewDriver</i>.
+
+   - go into the <i>tools</i> directory and run <i>perl newdriver New</i>
+   - edit your <i>NewDriver.xml</i> and copy it to <i>src/xml</i>
+   - add this file in <i>src/xml/Makefile.am</i>
+   - edit <i>NewDriver.cc/.h</i> and copy them to <i>src/drivers/</i>
+   - add the new files in <i>src/drivers/Makefile.am</i>
+   - look at <i>NewDriver.todo</i> and add factories in:
+		-# <i>src/common/OutputHandler.cc</i>
+		-# <i>src/common/OutputFactory.cc/.h</i>
+
+
+\example drivers.c Example how mulitiples drivers can be used in C.
+\example drivers.magml Example how drivers can be used in MagML.
+*/
+
+/*! \file BaseDriver.h
+    \brief Definition of driver base class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+
+*/
+#ifndef MPP_BaseDriver_H
+#define MPP_BaseDriver_H
+
+#include <magics.h>
+#include <MagTranslator.h>
+#include <Colour.h>
+#include <BaseDriverAttributes.h>
+#include "MagicsObserver.h"
+
+namespace magics{
+
+class Layer;
+class SceneLayer;
+class StaticLayer;
+class NoDataLayer;
+class StepLayer;
+
+class Layout;
+class SceneLayout;
+class LegendLayout;
+class StartPage;
+class EndPage;
+class RootLayout;
+class BinaryObject;
+class Polyline;
+class PolylineSet;
+class Text;
+class Symbol;
+class TextSymbol;
+
+class ComplexSymbol;
+class TextItem;
+class FlagItem;
+class SymbolItem;
+
+class Image;
+class Arrow;
+class Flag;
+class ImportObject;
+class PaperPoint;
+
+struct ShadingProperties;
+struct FillShadingProperties;
+struct DotShadingProperties;
+struct HatchShadingProperties;
+
+class SelectionMode;
+class MtInputEvent;
+class PreviewLayout;
+class HistoLayout;
+class MagnifierLayout;
+
+/*!
+ Codes for Brinary reading and writing
+*/
+#define BINARY_VERSION 2               // last updated with version 2.15.0
+
+typedef double MFloat;
+
+
+/*!
+ \brief helper compare function for string maps
+
+ The function follows the descriptionn of Josuttis's STL book at page 213.
+*/
+class RuntimeStringCompare
+{
+	static bool nocase_compare(char c1, char c2) {return toupper(c1)<toupper(c2);}
+public:
+	RuntimeStringCompare(){}
+	bool operator() (const string& s1, const string& s2) const 
+	{
+		return lexicographical_compare(s1.begin(),s1.end(),s2.begin(),s2.end(),nocase_compare);
+	}
+};
+
+/*!
+ \brief Method to extract points of Polylines
+ 
+ First all possible commas are replaced by spaces and than all points are read through a stream 
+*/
+inline void parsePoints(vector<PaperPoint> &vPP, string &points)
+{
+	string::size_type pos = points.find_first_of(",");
+
+	while(pos != string::npos)
+	{
+		points.replace(pos,1," ",1);
+		pos = points.find_first_of(",",pos);
+	}
+
+	istringstream totalString(points);
+	MFloat x,y;
+
+	while(!totalString.eof())
+	{
+		totalString >> x >> y;
+		PaperPoint pp;
+		pp.x(x);
+		pp.y(y);
+		vPP.push_back(pp);
+	}
+}
+
+/*!
+ \brief struct describing an XML element
+
+ Helper construct for symbol plotting.
+*/
+struct xmlElement
+{
+	string name;
+	std::map<string, string> attributes;
+	xmlElement() : name("") {}
+};
+
+/*!
+ \brief struct describing an SVG element
+
+ Helper construct for symbol plotting.
+*/
+struct svgSymbol
+{
+	string id;
+	vector<xmlElement> elements;
+	svgSymbol() : id("") {}
+};
+
+typedef vector<svgSymbol> vSymbols;
+
+/*!
+ \brief struct describing a entry in the font table
+
+ All fonts read in by readFonts() are stored in this way.
+
+ \sa readFonts()
+*/
+struct magFont
+{
+	int	id;
+	string	magics_name;
+	string	ps_name;
+	string	ps_filename;
+	string	ttf_filename;
+	string	css_name;
+};
+
+
+/*! \class BaseDriver
+    \brief Base class for all drivers of Magics++.
+    \ingroup drivers
+
+    This abstract class provides an interface for Magics
+    to call various device drivers.
+
+    Every new driver has to inherit this class and has
+    to provide own implementation of abstract members.
+*/
+class BaseDriver : public BaseDriverAttributes, public MagicsObserver
+{
+public:
+	BaseDriver();
+	virtual ~BaseDriver();
+
+	virtual void set(const XmlNode& node)
+	{
+		BaseDriverAttributes::set(node);
+	}
+	void setWidth(double width) { width_ = width; }
+
+	virtual void set(const std::map<string, string>& map)
+	{
+		BaseDriverAttributes::set(map);
+	}
+
+	virtual void open() {}
+	virtual void close() {}
+	void printOutputName(const std::string & str) const; 
+
+	virtual void project(const Layout& ) const {}
+	virtual void unproject() const {}
+
+	virtual void newLayer() const { debugOutput("BaseDriver::newLayer");}
+	virtual void closeLayer() const { debugOutput("BaseDriver::closeLayer");}
+	virtual void newLayer(Layer&) const {debugOutput("BaseDriver::newLayer()");}
+	virtual void closeLayer(Layer&) const {debugOutput("BaseDriver::closeLayer()");}
+	virtual void newLayer(StaticLayer&) const {debugOutput("BaseDriver::newStaticLayer");}
+	virtual void closeLayer(StaticLayer&) const {debugOutput("BaseDriver::closeStaticLayer");}
+	virtual void newLayer(StepLayer&) const {debugOutput("BaseDriver::newStepLayer");}
+	virtual void closeLayer(StepLayer&) const {debugOutput("BaseDriver::closeStepLayer");}
+
+	intarray frames() const  { return frame_list_; }
+
+	MAGICS_NO_EXPORT void redisplay(const Layout&) const;
+	MAGICS_NO_EXPORT void redisplay(const RootLayout&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const LegendLayout&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const SceneLayout&) const;
+	MAGICS_NO_EXPORT void redisplay(const StartPage&) const;
+	MAGICS_NO_EXPORT void redisplay(const EndPage&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const Layer&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const SceneLayer&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const StaticLayer&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const NoDataLayer&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const StepLayer&) const;
+	
+	virtual MAGICS_NO_EXPORT void redisplay(const Polyline&) const;
+	virtual MAGICS_NO_EXPORT void redisplay(const PolylineSet&) const;
+
+#ifdef MAGICS_QT
+	virtual MAGICS_NO_EXPORT void redisplay(const PreviewLayout&) const {};
+	virtual MAGICS_NO_EXPORT void redisplay(const HistoLayout&) const {};
+	virtual MAGICS_NO_EXPORT void redisplay(const MagnifierLayout&) const {};
+#endif
+	typedef void (BaseDriver::*ModeFunction)(const SelectionMode&);
+	typedef void (BaseDriver::*ControlFunction)(bool);
+	typedef void (BaseDriver::*InputEventFunction)(MtInputEvent*);
+
+	virtual void redisplay(const BinaryObject&) const;
+	void setDimensionsFromBinary(string mbg_tmpl,MFloat &ratio,int &width) const;
+
+	//! Method to redisplay a Text.
+	MAGICS_NO_EXPORT void redisplay(const Text&) const;
+	//! Method to redisplay a Symbol.
+	MAGICS_NO_EXPORT void redisplay(const Symbol&) const;
+	//! Method to redisplay a TextSymbol.
+	MAGICS_NO_EXPORT void redisplay(const TextSymbol&) const;
+	//! Method to redisplay a ComlpexSymbol.
+	void redisplay(const ComplexSymbol&) const;
+	void redisplay(const TextItem&, const ComplexSymbol&) const;
+	void redisplay(const FlagItem&, const ComplexSymbol&) const;
+	void redisplay(const SymbolItem&, const ComplexSymbol&) const;
+	
+	//! Method to redisplay an Arrow.
+	virtual MAGICS_NO_EXPORT void redisplay(const Arrow&) const;
+	//! Method to redisplay an Flag.
+	virtual MAGICS_NO_EXPORT void redisplay(const Flag&) const;
+	//! Method to redisplay a external file.
+	void redisplay(const ImportObject&) const;
+	//! Method to redisplay a external file.
+	MAGICS_NO_EXPORT void redisplay(const Image&) const;
+
+	void shade(const FillShadingProperties&) const;
+	void shade(const DotShadingProperties&) const;
+	void shade(const HatchShadingProperties&) const;
+
+	bool disable() const { return disabled_; }
+	void disable(bool disabled) { disabled_ = disabled; }
+
+
+	/*!
+	 SUPER_PAGE_X_LENGTH Default: 29.7
+	*/
+	MAGICS_NO_EXPORT void setXDeviceLength(MFloat xdevicelength)
+		{ xDeviceLength_ =  xdevicelength; }
+	MAGICS_NO_EXPORT MFloat getXDeviceLength() const
+		{ return xDeviceLength_; }
+
+	/*!
+	 SUPER_PAGE_Y_LENGTH Default: 21.0
+	*/
+	MAGICS_NO_EXPORT void setYDeviceLength(MFloat ydevicelength)
+		{ yDeviceLength_ =  ydevicelength; }
+	MAGICS_NO_EXPORT MFloat getYDeviceLength() const
+		{ return yDeviceLength_; }
+
+
+protected:
+	MFloat convertCM(const MFloat cm) const {return cm*cmScale_;}
+	void setCMscale(const MFloat scale) const {cmScale_ = scale;}
+
+	/*!
+	  \brief set Y values positive or negative
+
+	  Some drivers hava a Y axis which is positive towards the bottom of the plot
+	  and these need to set this method negative.
+	*/
+	virtual MAGICS_NO_EXPORT MFloat setY(const MFloat y) const {return y;}
+
+	/*!
+	  \brief set Y values positive or negative dependent how symbols are interpreted
+
+	*/
+	virtual MAGICS_NO_EXPORT MFloat setSymbolY(const MFloat y) const {return y;}
+
+	/*!
+	  \brief set Y values positive or negative dependent how angles are interpreted
+
+	  Some drivers hava a angle orientation different to PS
+	  and these need to set this method negative.
+	*/
+        virtual MAGICS_NO_EXPORT MFloat setAngleY(const MFloat y) const {return y;}
+        virtual MAGICS_NO_EXPORT MFloat setFlagY(const MFloat y) const {return y;}
+
+	string getFileName(const string &extension, const unsigned int no = 0) const;
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const;
+        virtual void startPage() const{};
+        virtual void endPage() const{};
+	virtual void setNewColour(const Colour &) const {};
+	virtual void printLine(const Polyline &line) const;
+
+	virtual void renderText(const Text &) const {}
+	virtual void debugOutput(const string &s) const 
+	{
+		if(debug_) MagLog::debug() <<" DRIVERS: "<<s<< "\n";
+	}
+
+	virtual MFloat projectX(const MFloat x) const {return coordRatioX_*x;}
+	virtual MFloat projectY(const MFloat y) const {return coordRatioY_*y;}
+		
+	string getTmpName() const;
+
+	double LSF(MFloat *x,MFloat *y, int i0) const;
+
+	mutable int	currentPage_;
+	mutable string	fileName_;
+	mutable string	currentLayer_;  // from Layer (open & close)
+
+	mutable LineStyle currentLineType_;
+	mutable MFloat	currentLineWidth_;
+	mutable int	currentLineStyle_;
+	mutable Colour	currentColour_;
+
+	mutable MFloat	coordRatioX_;
+	mutable MFloat	coordRatioY_;
+	mutable MFloat	dimensionX_;
+        mutable MFloat	dimensionY_;
+        mutable MFloat	offsetX_;
+        mutable MFloat	offsetY_;
+
+	mutable std::stack<MFloat>  dimensionStack_;
+	mutable std::stack<MFloat>  scalesX_;
+	mutable std::stack<MFloat>  scalesY_;
+
+//	mutable MFloat	lastAreaHeightPercentage_;
+//	mutable MFloat	lastAreaWidthPercentage_;
+	mutable bool	newPage_;
+//	mutable bool	firstPage_;
+//	mutable	bool	newLayout_;
+//	mutable	bool    external_;
+//	mutable bool    polylineAntialiasing_;
+
+	bool    disabled_;
+	bool    alphaEnabled_;
+	mutable vSymbols  sym_;
+
+	virtual MAGICS_NO_EXPORT void setNewLineWidth(const MFloat w) const {currentLineWidth_ = w;}
+	MAGICS_NO_EXPORT MFloat getNewLineWidth() const {return currentLineWidth_;}
+
+	//! Load svg symbols from file
+	void loadSymbols() const;
+
+	virtual MAGICS_NO_EXPORT void renderTextSymbols(const TextSymbol& symbol) const;
+	
+	virtual void renderComplexSymbols(const ComplexSymbol& symbol) const;
+	virtual void renderTextItem(const TextItem&, const ComplexSymbol&) const;
+	virtual void renderFlagItem(const FlagItem&, const ComplexSymbol& symbol) const;
+	virtual void renderSymbolItem(const SymbolItem&, const ComplexSymbol& symbol) const;
+	virtual void renderSymbols(const Symbol& symbol) const;
+	virtual void renderPolyline(const int, MFloat *, MFloat *) const {};
+	virtual void renderPolyline2(const int, MFloat *, MFloat *) const {}
+	void renderPolyline(vector<PaperPoint> &vP) const;
+	void renderPolyline2(vector<PaperPoint> &vP) const;
+
+	virtual MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const = 0;
+	virtual MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const = 0;
+	virtual void circle(const MFloat, const MFloat, const MFloat, const int) const {}
+	virtual MAGICS_NO_EXPORT int setLineParameters(const LineStyle st, const MFloat w) const {currentLineType_=st; setNewLineWidth(w);return 0;}
+
+	// Filling calculating methods
+	// PolylineSets rendering methods
+	//MAGICS_NO_EXPORT void renderPolylineSets(const PolylineSet<PaperPoint>&) const;
+	mutable unsigned int indexHatch_;
+	mutable Shading   currentShading_;
+	mutable const ShadingProperties *currentShadingProperties_;
+
+        // wind calculating methods (overridden in Binary)
+        virtual MAGICS_NO_EXPORT void renderWindArrow(const Arrow &arrow) const;
+        virtual MAGICS_NO_EXPORT void renderWindFlag(const Flag &flag) const;
+
+	// images + bitmap methods
+	virtual void renderImage(const ImportObject& object) const;
+	MAGICS_NO_EXPORT void renderImage(const Image& obj) const {renderCellArray(obj);}
+        virtual MAGICS_NO_EXPORT bool convertToPixmap(const string &fname, const GraphicsFormat format, const int reso,
+	             const MFloat wx0, const MFloat wy0,const MFloat wx1,const MFloat wy1) const;
+	virtual MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool hasAlpha=false) const;
+	virtual MAGICS_NO_EXPORT bool renderCellArray(const Image& ) const;
+
+	mutable std::map<string, magFont, RuntimeStringCompare> FontMap_;
+	typedef std::map<string, magFont, RuntimeStringCompare>::const_iterator fontMapIter;
+
+	void terminate() const {exit(1);}
+
+	void readFonts() const;
+	void relieveFonts() const {FontMap_.clear();}
+
+private:
+	mutable MFloat cmScale_;
+	MFloat xDeviceLength_;
+	MFloat yDeviceLength_;
+	static int numFiles_;
+	mutable double obs_distance_;
+	mutable stack<const Layout *>  staLayouts_;
+	mutable vector<const PaperPoint *>  vecPoints_;
+	bool checkDistanceMoreThan(const PaperPoint *pp, double distance) const;
+	void renderSimplePolygon(vector<PaperPoint> &vP) const;
+	void snowflake(const MFloat, const MFloat, const MFloat) const;
+	void drizzle(const MFloat, const MFloat, const MFloat) const;
+	void triangle(const MFloat, const MFloat, const MFloat, const int, const int) const;
+	void lightning(const MFloat x, const MFloat y, const MFloat size) const;
+
+	//! Copy constructor - No copy allowed
+	BaseDriver(const BaseDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	BaseDriver& operator=(const BaseDriver&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BaseDriver& p) { p.print(s); return s; }
+};
+
+/*!
+ \brief translates a string to a driver
+*/
+template<>
+class MagTranslator<string, BaseDriver>
+{
+public:
+	MAGICS_NO_EXPORT BaseDriver* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<BaseDriver>::create(val);
+	}
+	MAGICS_NO_EXPORT BaseDriver* magics(const string& param)
+	{
+		BaseDriver* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/BaseDriverBinaryReader.cc b/src/drivers/BaseDriverBinaryReader.cc
new file mode 100644
index 0000000..f11cf0e
--- /dev/null
+++ b/src/drivers/BaseDriverBinaryReader.cc
@@ -0,0 +1,513 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2009 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseDriverBinaryReader.cc
+    \brief Implementation of methods to read the binary input
+    
+    Magics Team - ECMWF 2010
+    
+    Started: June 2010
+    
+    Changes:
+
+*/
+#include "Timer.h"
+
+using namespace magics;
+
+/*!
+ \brief Method to read and execute binary file
+ 
+ This method is implemented for performance in Metview 4 and WREP
+ 
+*/
+void BaseDriver::setDimensionsFromBinary(string mbg_tmpl,MFloat &ratio,int &width) const
+{
+  ifstream in(mbg_tmpl.c_str());
+  if(in.is_open()) 
+  {
+	char mag [6];
+	in.read((char *)(&mag), 6);
+	if(strncmp( "MAGICS", mag,6) !=0 )
+	{
+		MagLog::error() << "Magics number of TEMPLATE binary file " <<mbg_tmpl<<" is wrong!\n"
+			<< "   Please check endiness and/or if you gave the right filename."<< endl;
+		return;
+	}
+
+	int checksum;
+	in.read((char *)(&checksum), sizeof(int));
+	if(checksum!=10)
+	{
+		MagLog::error() << "Checksum of TEMPLATE binary file " <<mbg_tmpl<<" is wrong!\n"
+		       << "   Please check endiness of your file."<< endl;
+		return;
+	}
+
+	int version;
+	in.read((char *)(&version), sizeof(int));
+	if(version!=BINARY_VERSION) MagLog::error() << " MGB VERSION MISMATCH " <<version<<" != "<<BINARY_VERSION << endl;
+	int lengthHeader;
+	in.read((char *)(&lengthHeader), sizeof(int));
+
+	MFloat lx;
+	MFloat ly;
+	in.read((char *)(&lx), sizeof(MFloat));
+	in.read((char *)(&ly), sizeof(MFloat));
+	in.close();
+
+	ratio = ly / lx;
+	width = maground(lx);
+  }
+  else
+  {
+  	MagLog::error() << "TEMPLATE binary file " <<mbg_tmpl<<" could NOT be opened!"<< endl;
+  }
+}
+
+
+/*!
+ \brief Method to read and execute binary file
+ 
+ This method is implemented for performance in Metview 4 and WREP
+ 
+*/
+void BaseDriver::redisplay(const BinaryObject& binary) const 
+{
+  Timer timer("binary", " read");
+  const string mbg_tmpl = binary.getPath();
+  ifstream in(mbg_tmpl.c_str());
+  if(in.is_open()) 
+  {
+    const float alpha = binary.getTransparency();
+    char mag [6];
+    in.read((char *)(&mag), 6);
+    if(strncmp( "MAGICS", mag,6) !=0 )
+    {
+	  MagLog::error() << "Magics number of binary file " <<mbg_tmpl.c_str()<<" is wrong!\n"
+			<< "   Please check endiness and if you gave the right filename."<< endl;
+	  return;
+    }
+
+    int checksum;
+  in.read((char *)(&checksum), sizeof(int));
+  if(checksum!=10)
+  {
+    MagLog::error() << "Checksum of binary file " <<mbg_tmpl.c_str()<<" is wrong!\n"
+                    << "   Please check endiness of your file."<< endl;
+    return;
+  }
+
+  string old_currentLayer_ = currentLayer_;
+  currentLayer_ = mbg_tmpl;
+
+  Layer lay;
+  lay.name(mbg_tmpl);
+  newLayer(lay);
+
+  int version;
+  in.read((char *)(&version), sizeof(int));
+
+  int lengthHeader;
+  in.read((char *)(&lengthHeader), sizeof(int));
+  
+  
+  MFloat lx;
+  MFloat ly;
+  in.read((char *)(&lx), sizeof(MFloat));
+  in.read((char *)(&ly), sizeof(MFloat));
+  
+//  if(lx!=0 || ly != 0) MagLog::warning()<<"Reading Binary: dimension mismatch!!!"<<endl;
+  Layout la;
+   la.x(binary.getMgb_x());
+   la.y(binary.getMgb_y());
+   la.width(binary.getMgb_width());
+   la.height(binary.getMgb_height());
+   la.minX(0);
+   la.minY(0);
+   la.maxX(100);
+   la.maxY(100);
+  project(la);
+
+  char c;
+  while( in.get(c) )
+  {
+	int n;
+	switch(c) {
+	case 'T':
+		MFloat x;
+		MFloat y;
+		MFloat s;
+		int len, noNT;
+		int size;
+		{ 
+			in.read((char *)(&size), sizeof(int));
+			MFloat r,g,b;
+			in.read((char *)(&r), sizeof(MFloat));
+			in.read((char *)(&g), sizeof(MFloat));
+			in.read((char *)(&b), sizeof(MFloat));
+
+			MFloat angle;
+			in.read((char *)(&angle), sizeof(MFloat));
+			bool bl;
+			in.read((char *)(&bl), sizeof(bool));
+			enum Justification horizontal;
+			enum VerticalAlign vertical;
+			in.read((char *)(&horizontal), sizeof(enum Justification));
+			in.read((char *)(&vertical), sizeof(enum VerticalAlign));
+
+			in.read((char *)(&noNT), sizeof(int));
+
+			Text text;
+			text.setBlanking(bl);
+			text.setJustification(horizontal);
+			text.setVerticalAlign(vertical);
+			text.setAngle(angle);
+
+			for(int ntc=0;ntc<noNT;ntc++)
+			{
+			  in.read((char *)(&r), sizeof(MFloat));
+			  in.read((char *)(&g), sizeof(MFloat));
+			  in.read((char *)(&b), sizeof(MFloat));
+			  in.read((char *)(&s), sizeof(MFloat));
+			  in.read((char *)(&len), sizeof(int));
+			  char *tex = new char[len+1];
+			  in.read(tex, sizeof(char)*len);
+			  tex[len]='\0';
+			  string str(tex);
+			  text.addText(str,Colour(r,g,b,alpha),s);
+			  delete [] tex;
+			}
+
+			for(int n=0;n<size;n++)
+			{
+				in.read((char *)(&x), sizeof(MFloat));
+				in.read((char *)(&y), sizeof(MFloat));
+				PaperPoint pp(x,y);
+				text.push_back(pp);
+			}
+			renderText(text);
+		}
+        	break;
+
+	case 'A':
+        	in.read((char *)(&n), sizeof(int));
+        	{
+			Arrow arrow;
+			double sc;
+			in.read((char *)(&sc), sizeof(double));
+			arrow.setScale(sc);
+			int index;
+			in.read((char *)(&index), sizeof(int));
+			arrow.setHeadIndex(index);
+			LineStyle ls;
+			in.read((char *)(&ls), sizeof(LineStyle));
+			arrow.setStyle(ls);
+			ArrowPosition ap;
+			in.read((char *)(&ap), sizeof(ArrowPosition));
+			arrow.setArrowPosition(ap);
+			int hi;
+			in.read((char *)(&hi), sizeof(int));
+			arrow.setHeadIndex(hi);
+			double hr;
+			in.read((char *)(&hr), sizeof(double));
+			arrow.setHeadRatio(hr);
+			MFloat r,g,b;
+			in.read((char *)(&r), sizeof(MFloat));
+			in.read((char *)(&g), sizeof(MFloat));
+			in.read((char *)(&b), sizeof(MFloat));
+			setNewColour(Colour(r,g,b,alpha));
+			arrow.setColour(Colour(r,g,b,alpha));
+
+			for(int pts=0;pts<n;pts++)
+			{
+			  double x,y;
+			  in.read((char *)(&x), sizeof(double));
+			  in.read((char *)(&y), sizeof(double));
+			  PaperPoint p;
+			  in.read((char *)(&p), sizeof(PaperPoint));
+			  ArrowPoint ap(x, y, p);
+			  arrow.push_back(ap);
+			} 
+			renderWindArrow(arrow);
+		}
+		break;
+	case 'F':
+        	in.read((char *)(&n), sizeof(int));
+        	{
+			Flag flag;
+			double ll;
+			in.read((char *)(&ll), sizeof(double));
+			flag.setLength(ll);
+			LineStyle ls;
+			in.read((char *)(&ls), sizeof(LineStyle));
+			flag.setStyle(ls);
+			FlagConvention fc;
+			in.read((char *)(&fc), sizeof(FlagConvention));
+			flag.setConvention(fc);
+			Hemisphere he;
+			in.read((char *)(&he), sizeof(Hemisphere));
+			flag.setHemisphere(he);
+			double hr;
+			in.read((char *)(&hr), sizeof(double));
+			flag.setThickness(hr);
+			double hi;
+			in.read((char *)(&hi), sizeof(double));
+			flag.setOriginHeight(hi);
+
+			MFloat r,g,b;
+			in.read((char *)(&r), sizeof(MFloat));
+			in.read((char *)(&g), sizeof(MFloat));
+			in.read((char *)(&b), sizeof(MFloat));
+			setNewColour(Colour(r,g,b,alpha));
+			flag.setColour(Colour(r,g,b,alpha));
+
+			int len;
+			in.read((char *)(&len), sizeof(int));
+			char *tex = new char[len+1];
+			in.read(tex, sizeof(char)*len);
+			tex[len]='\0';
+			string str(tex);
+			flag.setOriginMarker(str);
+
+			for(int pts=0;pts<n;pts++)
+			{
+			  double x,y;
+			  in.read((char *)(&x), sizeof(double));
+			  in.read((char *)(&y), sizeof(double));
+			  PaperPoint p;
+			  in.read((char *)(&p), sizeof(PaperPoint));
+			  ArrowPoint ap(x, y, p);
+			  flag.push_back(ap);
+			} 
+			renderWindFlag(flag);
+		}
+		break;
+	case 'H':
+		in.read((char *)(&n), sizeof(int));
+		{
+			MFloat *x = new MFloat[n];
+			MFloat *y = new MFloat[n];
+			in.read((char *)(x), sizeof(MFloat)*n);
+			in.read((char *)(y), sizeof(MFloat)*n);
+			renderPolyline( n, x, y);
+			delete [] x;
+			delete [] y;
+		}
+		break;
+
+	case 'I':
+		{
+			MFloat x0=0.;
+			MFloat x1=0.;
+			MFloat y0=0.;
+			MFloat y1 = 0.;
+			int he=0;
+			int wi=0;
+			int si=0;
+			double red=0.;double green=0.;double blue=0.;double alpha=0.;
+
+			in.read((char *)(&wi), sizeof(int));
+			in.read((char *)(&he), sizeof(int));
+			in.read((char *)(&x0), sizeof(MFloat));
+			in.read((char *)(&y0), sizeof(MFloat));
+			in.read((char *)(&x1), sizeof(MFloat));
+			in.read((char *)(&y1), sizeof(MFloat));
+			const int d=wi*he;
+
+			in.read((char *)(&si), sizeof(int));
+			ColourTable table;
+
+//cout << "Image>  pixel: "<<wi<<"x"<<he<<"="<<d<<" orig: "<<x0<<"/"<<y0<<"    dim: "<<x1<<"/"<<y1<<"     noColours: "<<si<< endl;
+
+			for(int v=0;v<si;v++)
+			{
+			  in.read((char *)(&red  ), sizeof(double));
+			  in.read((char *)(&green), sizeof(double));
+			  in.read((char *)(&blue ), sizeof(double));
+			  in.read((char *)(&alpha), sizeof(double));
+			  table.push_back(ColourTableEntry(Colour(red,green,blue,alpha)));
+			}
+
+			short cc[d];
+			in.read((char *)(cc), sizeof(short)*d);
+
+			Image object;
+			PaperPoint pp(x0,y0,0.);
+			object.setOrigin(pp);
+			object.setWidth(x1);
+			object.setHeight(y1);
+			object.set(he,wi);
+			for(int i=0;i<d;i++) object.push_back(cc[i]);
+			object.setColourTable(table);
+			renderCellArray(object);
+		}
+		break;
+
+	case 'B':
+		in.read((char *)(&n), sizeof(int));
+		{
+			MFloat *x = new MFloat[n];
+			MFloat *y = new MFloat[n];
+			in.read((char *)(x), sizeof(MFloat)*n);
+			in.read((char *)(y), sizeof(MFloat)*n);
+			renderPolyline2( n, x, y);
+			delete [] x;
+			delete [] y;
+		}
+		break;
+
+	case 'R':
+		MFloat cx,cy,cr;
+		int cs;
+		in.read((char *)(&cx), sizeof(MFloat));
+		in.read((char *)(&cy), sizeof(MFloat));
+		in.read((char *)(&cr), sizeof(MFloat));
+		in.read((char *)(&cs), sizeof(int));
+		circle( cx, cy, cr, cs);
+		break;
+
+	case 'X':
+		in.read((char *)(&n), sizeof(int));
+		{
+			MFloat *x = new MFloat[n];
+			MFloat *y = new MFloat[n];
+			in.read((char *)(x), sizeof(MFloat)*n);
+			in.read((char *)(y), sizeof(MFloat)*n);
+			Polyline line;
+			for(int i=0;i<n;i++)
+			{
+				line.push_back(PaperPoint(x[i],y[i]));
+			}
+			unsigned int nh = 0;
+			in.read((char *)(&nh), sizeof(unsigned int));
+			if(nh!=0)
+			{
+			 for (unsigned int h=0; h < nh; ++h)
+			 {
+			  unsigned int nhx = 0;
+			  in.read((char *)(&nhx), sizeof(unsigned int));
+			  MFloat *xx = new MFloat[nhx];
+			  MFloat *yy = new MFloat[nhx];
+			  in.read((char *)(xx), sizeof(MFloat)*nhx);
+			  in.read((char *)(yy), sizeof(MFloat)*nhx);
+			  line.newHole();
+			  for (unsigned int u=0; u < nhx; ++u)
+			  {
+			    line.push_back_hole( PaperPoint(xx[u],yy[u]) );
+			  }
+			 }
+			}
+			line.setFillColour(Colour("green"));
+			FillShadingProperties* shading = new FillShadingProperties();    
+			line.setShading(shading);
+			MFloat r,g,b,a;
+			in.read((char *)(&r), sizeof(MFloat));
+			in.read((char *)(&g), sizeof(MFloat));
+			in.read((char *)(&b), sizeof(MFloat));
+			in.read((char *)(&a), sizeof(MFloat));
+			line.setFillColour(Colour(r,g,b,a*alpha));
+			renderSimplePolygon(line);
+			delete [] x;
+			delete [] y;
+		}
+	break;
+	case 'S':
+		in.read((char *)(&n), sizeof(int));
+        	{
+			MFloat *x = new MFloat[n];
+			MFloat *y = new MFloat[n];
+			in.read((char *)(x), sizeof(MFloat)*n);
+			in.read((char *)(y), sizeof(MFloat)*n);
+			renderSimplePolygon( n, x, y);
+			delete [] x;
+			delete [] y;
+		}
+		break;
+
+	case 'W':
+		MFloat width;
+		in.read((char *)(&width), sizeof(MFloat));
+		setNewLineWidth(width);
+		break;
+
+	case 'L':
+		MFloat w;
+		LineStyle linestyle;
+		in.read((char *)(&linestyle), sizeof(LineStyle));
+		in.read((char *)(&w), sizeof(MFloat));
+		setLineParameters(linestyle, w);
+		break;
+
+	case 'C':
+		MFloat r,g,b,a;
+		in.read((char *)(&r), sizeof(MFloat));
+		in.read((char *)(&g), sizeof(MFloat));
+		in.read((char *)(&b), sizeof(MFloat));
+		in.read((char *)(&a), sizeof(MFloat));
+        	setNewColour(Colour(r,g,b,a*alpha));
+        	break;
+
+	case 'N':
+        	startPage();
+        	break;
+
+	case 'E':
+        	endPage();
+        	break;
+
+	case 'P':
+		{
+			Layout l;
+			double x,y,w,h,minx,miny,maxx,maxy;
+			in.read((char *)(&x), sizeof(double));
+			in.read((char *)(&y), sizeof(double));
+			in.read((char *)(&w), sizeof(double));
+			in.read((char *)(&h), sizeof(double));
+			in.read((char *)(&minx), sizeof(double));
+			in.read((char *)(&miny), sizeof(double));
+			in.read((char *)(&maxx), sizeof(double));
+			in.read((char *)(&maxy), sizeof(double));
+			l.x(x);
+			l.y(y);
+			l.width(w);
+			l.height(h);
+			l.minX(minx);
+			l.minY(miny);
+			l.maxX(maxx);
+			l.maxY(maxy);
+			project(l);
+		}
+        	break;
+	case 'U':
+        	unproject();
+        	break;
+	}
+   }
+   unproject();
+   in.close();
+   closeLayer(lay);
+   currentLayer_ = old_currentLayer_;
+  }
+  else
+  {
+  	MagLog::error() << "TEMPLATE binary file " <<mbg_tmpl<<" could NOT be opened!"<< endl;
+  }
+}
diff --git a/src/drivers/BaseDriverImages.h b/src/drivers/BaseDriverImages.h
new file mode 100644
index 0000000..5ea12ce
--- /dev/null
+++ b/src/drivers/BaseDriverImages.h
@@ -0,0 +1,480 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2009 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseDriverImages.h
+    \brief Implementation of methods to display images of driver base class.
+
+    Magics Team - ECMWF 2005
+
+    Started: March 2005
+
+    Changes:
+
+*/
+
+#ifdef MAGICS_RASTER
+#include <gd.h>
+#endif
+
+using namespace magics;
+
+
+static inline int getRealLine(ifstream& I, char* cline)
+{
+	int k = 0;
+	char ch;
+	while ( I.get(ch) )
+	{
+		cline[k] = ch;
+		if ( ch == '\n' || ch == '\0' || I.eof() )
+			break;
+		k++;
+	}
+	cline[k] = '\0';
+	return k;
+}
+
+static inline int getGoodLine(ifstream& I, char* cline,const int& n)
+{
+	int k = 0;
+	char ch;
+	while(I.get(ch))
+	{
+		cline[k] = ch;
+		if ( ch == '\n' || ch == '\0' || I.eof() || k == n ) break;
+		k++;
+	}
+	cline[k] = '\0';
+	return k;
+}
+
+static inline int check_ps(const string& file, int& boxx, int& boxy, int& orientation)
+{
+	ifstream I(file.c_str());
+	if (!I) return 1;
+
+	string::size_type x,y;
+	char *cline;
+	cline = new char[2048];
+	int k = getGoodLine(I,cline,2048);
+	string s(cline,k);
+
+	// level 3 only "%!PS-Adobe-3.0";
+	x = s.find("%!PS");
+	if(x == string::npos) return 1;  //no PostScript
+
+	// Looks like a PostScript file
+	int r = 0;
+	boxx = boxy = 0;
+	orientation = 0; // Portrait
+	int boundingbox_found = 1;
+	int orientation_found = 1;
+	MFloat xx = 0.0,yy = 0.0;
+
+	while(!I.eof()) // look for  %%BoundingBox: %%Orientation:
+	{
+		k = getGoodLine(I, cline,2048);
+		int i = ( k > 15 ) ? 15 : k;
+		if ( i < 15 )  // dont bother
+			continue;
+		string f(cline,i);
+
+		if ( boundingbox_found )
+		{
+			x = f.find("%%BoundingBox:");
+			if ( x != string::npos  )
+			{
+				string str(cline,k);
+				y = str.find("atend");
+				if ( y != string::npos )
+					continue;
+				else
+				{
+					str.erase(0,x+15);
+					istringstream ist(str.c_str());
+
+					MFloat dum1, dum2;
+					ist >>dum1 >> dum2 >> xx >> yy;
+					xx = xx - dum1;
+					yy = yy - dum2;
+					boundingbox_found = 0;
+				}
+			}
+		}
+		if ( orientation_found )
+		{
+			x = f.find("%%Orientation:");
+			if ( x != string::npos )
+			{
+				string str(cline,k);
+				y = str.find("atend");
+				if ( y != string::npos )
+					continue;
+				else
+				{
+					y = str.find("Landscape");
+					orientation = ( y != string::npos  ) ? 1 : 0;
+					orientation_found = 0;
+				}
+			}
+		}
+		if ( (orientation_found + boundingbox_found) == 0 ) break;
+	}
+
+	boxx = (int) xx;  boxy = (int) yy;
+	if ( boxx == 0 || boxy == 0 ) // No boundingbox
+	{
+		boxx = 595;
+		boxy = 841;
+	}
+
+	I.close();
+	delete [] cline;
+	return r;
+}
+
+static inline int check_ppmHeader(ifstream& I, int& col, int& row)
+{
+	int colours;
+	char *cline = new char[2048];
+
+	int k = getRealLine(I, cline);
+	string s = cline;
+	int r = 0;
+	int x = s.find("P6");
+
+	if(x<0) r = 1;// not PPM P6 format
+
+	if(!r)
+	{
+		cline[0] = '#';
+		while ( cline[0] == '#')  // skip comments
+			k = getRealLine(I,cline);
+		istringstream ist1(cline);
+		ist1 >> col >> row;
+		k = getRealLine(I,cline);
+		istringstream ist2(cline);
+		ist2 >> colours;
+
+		if ( col == 0 || row == 0 || colours == 0 ) r =  1;
+	}
+
+	delete [] cline;
+	return r;
+}
+
+
+/*!
+  \brief Image render method for ALL drivers.
+
+  This method should be used by all Magics++ drivers to render image objects.
+*/
+MAGICS_NO_EXPORT void BaseDriver::renderImage(const ImportObject& obj) const
+{
+	std::string f = obj.getFormat();
+	GraphicsFormat format = PNG;
+	if(magCompare(f,"ps")) format = PS;
+	else if(magCompare(f,"eps")) format = EPS;
+	else if(magCompare(f,"gif")) format = GIF;
+	else if(magCompare(f,"jpeg") || magCompare(f,"jpg")) format = JPG;
+	else if(magCompare(f,"png")) format = PNG;
+	else if(magCompare(f,"svg")) format = SVG;
+
+	MFloat width=0;
+	MFloat height=0;
+
+	if(obj.getWidth()==-1 && ( magCompare(f,"gif") || magCompare(f,"png") || magCompare(f,"jpeg")|| magCompare(f,"jpg") ) )
+	{
+#ifndef MAGICS_RASTER
+		MagLog::error() << "BaseDriverImages: Dimension is -1 and default size can not be determined (GD library required)!" << endl;
+		return;
+#else
+		FILE *in = fopen(obj.getPath().c_str(), "rb");
+		gdImagePtr image = 0;
+		if(magCompare(f,"png")) image = gdImageCreateFromPng(in);
+		else if(magCompare(f,"jpeg") || magCompare(f,"jpg")) image = gdImageCreateFromJpeg(in);
+		else if(magCompare(f,"gif"))
+		{
+#ifdef MAGICS_GIF
+			image = gdImageCreateFromGif(in);
+#else
+			MagLog::error() << "GIF import is not supported in this version! You need a GIF enabled GD library." << endl;
+			return;
+#endif
+		}
+		fclose(in);
+		width  = gdImageSX(image);
+		height = gdImageSY(image);
+		gdImageDestroy(image);
+#endif
+	}
+	else
+	{
+		width  = obj.getWidth();
+		height = obj.getHeight();
+	}
+	const MFloat ow = (obj.getWidth()<0)  ? convertCM(1./coordRatioX_) : width;
+	const MFloat oh = (obj.getHeight()<0) ? convertCM(1./coordRatioY_) : height;
+
+	const ImageProperties::OriginReference ori = obj.getOriginReference();
+	if(ori == ImageProperties::centre)
+		convertToPixmap(obj.getPath(),format, 300,
+			projectX(obj.getOrigin().x()-(ow*.5)),
+			projectY(obj.getOrigin().y()-(oh*.5)),
+			projectX(obj.getOrigin().x()+(ow*.5)),
+			projectY(obj.getOrigin().y()+(oh*.5)) );
+	else
+		convertToPixmap(obj.getPath(),format, 300,
+			projectX(obj.getOrigin().x()),
+			projectY(obj.getOrigin().y()),
+			projectX(obj.getOrigin().x()+ow),
+			projectY(obj.getOrigin().y()+oh) );
+}//end BaseDriver::renderImage()
+
+
+/*!
+  \brief converting object to pixmap
+
+  This method should be used by all Magics++ drivers
+
+*/
+MAGICS_NO_EXPORT bool BaseDriver::convertToPixmap(const string &fname, const GraphicsFormat format, const int reso,
+		     const MFloat wx0, const MFloat wy0,const MFloat wx1,const MFloat wy1) const
+{
+	debugOutput("Start Image conversion");
+
+	int Landscape = 0;
+	MFloat bx1=100.;
+	MFloat by1=100.;
+	unsigned char *image = 0;
+	int col=0,row=0;
+	int status = 0;
+	string s2(" ");
+	string pixmapFormat("rgb");
+
+	if(format==PS || format==EPS) //File is PostScript
+	{
+//		FILE* fd3;
+//		char buf[1024];
+		string cmd;
+		int x1 = 0;
+		int y1 = 0;
+
+		if(check_ps(fname,x1,y1,Landscape) )
+		{
+			MagLog::error() << "BaseDriverImages: Open of source PostScript file failed!" << endl;
+			return false;
+       		}
+
+		s2 = getTmpName()+".ppm";
+		if(s2==" ")
+		{
+			MagLog::error() << "BaseDriverImages: Open of temp file failed!" << endl;
+			return false;
+		}
+
+	//	if(format==PS)  // does not work with EPS
+		{
+		  const MFloat Xres = MFloat(reso);
+		  bx1 = MFloat(x1)/72.*Xres + 0.5;
+		  x1  = (int) bx1;
+		  by1 = MFloat(y1)/72.*Xres + 0.5;
+		  y1  = (int) by1;
+
+		  char boxx[5];
+		  char boxy[5];
+		  char boxz[5];
+		  sprintf(boxx,"%d",x1);
+		  sprintf(boxy,"%d",y1);
+		  sprintf(boxz,"%d",reso);
+
+		  cmd = "( gs -q -dNOPAUSE -dSAFER -sDEVICE=ppmraw -sOutputFile=" + s2 +
+			" -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dCOLORSCREEN -dBATCH -g" +
+			boxx + "x" + boxy + " -r" + boxz + " " + fname + " < /dev/null )";
+		}
+
+		status = system(cmd.c_str());
+
+		if(status)
+		{
+			MagLog::error() << "BaseDriverImages: Command exit Not zero" << endl;
+			return false;
+		}
+		ifstream I(s2.c_str());
+		if(!I)
+		{
+			MagLog::error() << "BaseDriverImages: Incorrect PostScript Format!" << endl;
+			return false;
+		}
+		if(check_ppmHeader(I,col,row) )
+		{
+			return 1;
+		}
+
+		image = new unsigned char [row*col*3];
+		I.read((char*)image,row*col*3);
+		I.close();
+		remove(s2.c_str());
+	}
+#ifdef MAGICS_RASTER
+	else if(format==GIF || format==PNG || format==JPG)
+	{
+		// convert png to ppm(raw) like image
+		FILE* fd3 = fopen(fname.c_str(),"rb");
+		if(!fd3)
+		{
+			MagLog::error() << "BaseDriverImages: Open failed for raster source > "<< fname << endl;
+			return false;
+		}
+		gdImagePtr imp = 0;
+		if(format==JPG)      imp = gdImageCreateFromJpeg(fd3);
+		else if(format==PNG) imp = gdImageCreateFromPng(fd3);
+		else if(format==GIF)
+		{
+#ifdef MAGICS_GIF
+			imp = gdImageCreateFromGif(fd3);
+#else
+			MagLog::error() << "GIF pixmap import is not supported in this version! You need a GIF enabled GD library." << endl;
+			return false;
+#endif
+		}
+		fclose(fd3);
+		if(!imp)
+		{
+			MagLog::error() << "BaseDriverImages: Incorrect raster file format (can not be handled by GD) !" << endl;
+			return false;
+		}
+
+		col = gdImageSX(imp);
+		row = gdImageSY(imp);
+		bx1 = (MFloat) col;
+		by1 = (MFloat) row;
+		Landscape = 0;
+
+		if(format == PNG && // imp->transparent == 1 &&
+                   alphaEnabled_ == true)
+		{
+			pixmapFormat="rgba";
+
+			image = new unsigned char [col*row*4];
+			unsigned char *p = image;
+			int i,j;
+			for (i = 0; i<row; i++)
+			for (j = 0; j<col; j++)
+			{
+				int c = gdImageGetPixel(imp,j,i);
+				int r = gdImageRed(imp,c);
+				int g = gdImageGreen(imp,c);
+				int b = gdImageBlue(imp,c);
+				int a = gdImageAlpha(imp,c);
+				*(p++) = (unsigned char) r;
+				*(p++) = (unsigned char) g;
+				*(p++) = (unsigned char) b;
+				*(p++) = (unsigned char) 255-2*a;
+			}
+		}
+		else
+		{
+			image = new unsigned char [col*row*3];
+			unsigned char *p = image;
+			int i,j;
+			for (i = 0; i<row; i++)
+			for (j = 0; j<col; j++)
+			{
+				int c = gdImageGetPixel(imp,j,i);
+				int r = gdImageRed(imp,c);
+				int g = gdImageGreen(imp,c);
+				int b = gdImageBlue(imp,c);
+				*(p++) = (unsigned char) r;
+				*(p++) = (unsigned char) g;
+				*(p++) = (unsigned char) b;
+			}
+		}
+
+		gdImageDestroy(imp);
+	}
+#endif
+	else 
+	{
+		MagLog::warning() << "BaseDriverImages: graphics formats ("<<format<<") is NOT supported!" << endl;
+		return 1;//No PPM
+	}
+
+	MFloat x0 = wx0; //Left
+	MFloat x1 = wx1; //Right
+	MFloat y0 = wy0;
+	MFloat y1 = wy1;
+
+	// const MFloat aspect = bx1/by1;
+	//if ( Landscape == 1 )		y1 = y0 + abs(x1-x0)*aspect;
+	//else if ( Landscape == 0 )	x1 = x0 + abs(y1-y0)*aspect;
+
+	bool alpha = (pixmapFormat == "rgba");
+	status = renderPixmap(x0,y0,x1,y1,col,row,image,Landscape,alpha);
+
+	if(!status) MagLog::warning() <<"BaseDriver::convertToPixmap() -> no Pixmap could be drawn! Zero size of at least one dimension."<<endl;
+	delete [] image;
+
+	return status;
+}
+
+/*
+bool BaseDriver::renderPixmap(MFloat ,MFloat,MFloat,MFloat ,int w,int h,unsigned char* IOUT,int, bool hasAlpha) const
+{
+#ifndef MAGICS_RASTER
+	MagLog::warning() << "Image import is not implemented for the used driver!!!" << endl;
+	return false;
+#else
+	gdImagePtr im = gdImageCreateTrueColor(w,h);
+	unsigned char *p = IOUT;
+	gdImageColorAllocateAlpha(im, 255, 255, 255, 127);
+	int a = 0;
+
+	for(int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; j++)
+		{
+			const int r = (int) *(p++);
+			const int g = (int) *(p++);
+			const int b = (int) *(p++);
+			if(hasAlpha) a = (int) *(p++);
+			const int col = gdImageColorResolveAlpha(im,r,g,b,a);
+			gdImageSetPixel(im, w, h, col);
+		}
+	}
+	gdImageDestroy(im);
+	gdImageAlphaBlending(im, 1);
+	gdImageSaveAlpha(im, 1); // save transparency
+
+	stringstream out;
+	out << output_resource_list_.size();
+	string filename = "magics_resource_"+out.str()+".png";
+
+	output_resource_list_.push_back(filename);
+
+
+	FILE *outFile = fopen(filename.c_str(),"wb");
+	gdImagePng(im,outFile);
+	fclose(outFile);
+
+	return true;
+#endif
+}
+*/
diff --git a/src/drivers/BaseDriverSymbols.h b/src/drivers/BaseDriverSymbols.h
new file mode 100644
index 0000000..fe91657
--- /dev/null
+++ b/src/drivers/BaseDriverSymbols.h
@@ -0,0 +1,541 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+  Licensed under the Apache License, Version 2.0 (the "License"); 
+  you may not use this file except in compliance with the License. 
+  You may obtain a copy of the License at 
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing, software 
+  distributed under the License is distributed on an "AS IS" BASIS, 
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+  See the License for the specific language governing permissions and 
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseDriverSymbols.h
+    \brief Implementation of Symbol methods of driver base class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2005
+
+*/
+
+using namespace magics;
+
+#include <Symbol.h>
+#include <expat.h>
+
+
+/////////////////////////////////////////////////////
+//
+//  READING XML
+//
+/////////////////////////////////////////////////////
+
+/*!
+ callback for expat
+*/
+static void XMLCALL startElement(void *userData, const char *name, const char **atts)
+{
+	vSymbols *s = (vSymbols*) userData;
+	
+	if(string(name)=="g") {svgSymbol sym;sym.id=*(atts+1); s->push_back(sym);return;}
+	if(s->empty()) return;
+
+	svgSymbol& sym = s->back();
+	xmlElement ele;
+	ele.name = name;
+	while (*atts)
+	{
+		ele.attributes[*(atts)] = *(atts+1);
+            	atts+=2;
+	}
+	sym.elements.push_back(ele);
+}
+
+/*!
+ callback for expat
+*/
+static void XMLCALL endElement(void *, const char *){}
+
+
+MAGICS_NO_EXPORT bool BaseDriver::checkDistanceMoreThan(const PaperPoint *pp, double distance) const
+{
+  for( vector<const PaperPoint *>::const_iterator iter = vecPoints_.begin(); iter != vecPoints_.end(); ++iter )
+  {
+    const double d = sqrt((pp->x()-(*iter)->x())*(pp->x()-(*iter)->x()) + (pp->y()-(*iter)->y())*(pp->y()-(*iter)->y()));
+    if(d < distance)
+        return false;
+  }
+  return true;
+}
+
+MAGICS_NO_EXPORT void BaseDriver::loadSymbols() const
+{	
+	if(sym_.empty())
+	{
+		string filename = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "symbols.svg";
+		XML_Parser parser = XML_ParserCreate(NULL);
+		XML_SetUserData(parser, &sym_);
+		XML_SetElementHandler(parser, startElement, endElement);
+
+		FILE* in  = fopen(filename.c_str(), "r");
+		if(!in)
+		{
+			MagLog::error() << "BaseDriver::loadSymbols() -> Symbol file " << filename
+			             << "could NOT been found! NO symbols will be plotted!" << endl;
+			return;
+		}
+	
+		int done = 0;
+		char buf[BUFSIZ];
+		do
+		{
+			size_t len = fread(buf, 1, sizeof(buf), in);
+			done = len < sizeof(buf);
+			if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+			{
+				MagLog::error() << "BaseDriver::loadSymbols()-> XML ERROR: "
+				             << XML_ErrorString(XML_GetErrorCode(parser))
+				             << " at line  " << XML_GetCurrentLineNumber(parser) << endl;
+			}
+		} while (!done);
+		XML_ParserFree(parser);
+		fclose(in);
+
+	}// endif of reading symbols.svg
+}
+
+MAGICS_NO_EXPORT void BaseDriver::renderTextSymbols(const TextSymbol& symbol) const
+{
+	const int nPos  = symbol.size();
+	const int nText = symbol.text().size();
+
+	assert(nText >= nPos);
+	if(nText < nPos) MagLog::debug() << " BaseDriverSymbols > Not enough texts ("<<nText<<") for "<<nPos<<" symbols!";
+
+	//Loop for all positions
+	for(int i=0;i< nPos ;i++)
+	{
+		Text text;
+		text.setJustification(MCENTRE);
+		text.setVerticalAlign(MHALF);
+		text.setBlanking(symbol.blanking());
+
+		MFloat shiftX = 0.;
+		MFloat shiftY = 0;
+
+		// default is M_NONE
+		if( symbol.position() == Symbol::M_NONE )
+		{
+//			cout<<"M_NONE"<<endl;
+		}
+		else if( symbol.position() == Symbol::M_RIGHT )
+		{
+			shiftX = convertCM(symbol.getHeight()*.5)/coordRatioX_;
+			text.setJustification(MLEFT);
+		}
+		else if( symbol.position() == Symbol::M_LEFT )
+		{
+			shiftX = convertCM(symbol.getHeight()*.5)/coordRatioX_;
+			text.setJustification(MRIGHT);
+		}
+		else if( symbol.position() == Symbol::M_BELOW )
+		{
+			shiftY = -convertCM(symbol.getHeight()*.6)/coordRatioY_;
+			text.setVerticalAlign(MTOP);
+		}
+		else if( symbol.position() == Symbol::M_ABOVE )
+		{
+			shiftY = convertCM(symbol.getHeight()*1.0)/coordRatioY_;
+			text.setVerticalAlign(MBOTTOM);
+		}
+
+// MagLog::dev()<<"x: " << symbol[i].x()<<"  y: "<<symbol[i].y()<<"+"<< shiftY<< endl;
+		text.push_back(PaperPoint(symbol[i].x()+shiftX, symbol[i].y()+setFlagY(shiftY) ));
+		text.setAngle(0.);
+		text.addText(symbol.text().at(i), symbol.font()); //75 dpi
+		renderText(text);
+	}
+	renderSymbols(symbol);
+}
+
+
+MAGICS_NO_EXPORT void BaseDriver::renderComplexSymbols(const ComplexSymbol& symbol) const
+{
+	obs_distance_ = convertCM(symbol.getDistanceApart()) / coordRatioX_;
+
+	if((obs_distance_>0.) && !checkDistanceMoreThan(&symbol[0],obs_distance_))
+	{
+		return;
+	}
+
+	vecPoints_.push_back(&symbol[0]);
+	for (vector<GraphicsItem*>::const_iterator item = symbol.itemBegin(); item != symbol.itemEnd(); ++item)
+		(*item)->redisplay(symbol, *this);
+}
+
+MAGICS_NO_EXPORT void BaseDriver::renderTextItem(const TextItem& textItem, const ComplexSymbol& owner) const
+{
+	Text text;
+	const MFloat scaling = convertCM(owner.getHeight()*1.5);
+	const MFloat pX = 1. / coordRatioX_;
+	const MFloat pY = 1. / coordRatioY_;
+
+	const MFloat posX = owner[0].x() + (           textItem.x()  * scaling *pX);
+	const MFloat posY = owner[0].y() + (setSymbolY(textItem.y()) * scaling *pY);
+	text.push_back(PaperPoint(posX, posY));
+	text.setJustification(MCENTRE);
+//
+//! \todo We need to decide if we need to align text in WMO symbols
+//
+//	if(owner[0].x() > 0) text.setJustification(MRIGHT);
+//	else if(owner[0].x() < 0) text.setJustification(MLEFT);
+
+	text.setVerticalAlign(MHALF);
+	text.setAngle(0.);
+	text.addText(textItem.text(), textItem.font());
+	renderText(text);
+}
+
+MAGICS_NO_EXPORT void BaseDriver::renderFlagItem(const FlagItem& flagItem, const ComplexSymbol& owner) const
+{
+	Flag flag;
+	flag.setLength(flagItem.length());
+	flag.setOriginMarker(flagItem.getOriginMarker());
+	flag.setOriginHeight(owner.getHeight());           // NOT flagItem.getOriginHeight() !!!
+	flag.setColour(flagItem.getColour());
+
+	flag.setHemisphere(flagItem.getHemisphere());
+
+	const MFloat scaling = convertCM(owner.getHeight());
+	const MFloat pX = 1. / coordRatioX_;
+	const MFloat pY = 1. / coordRatioY_;
+
+	const MFloat posX = owner[0].x() + (           flagItem.x()  * scaling *pX);
+	const MFloat posY = owner[0].y() + (setSymbolY(flagItem.y()) * scaling *pY);
+	ArrowPoint a(PaperPoint(posX, posY));
+	a.set(flagItem.speed(),flagItem.direction());
+	flag.push_back(a);
+
+	renderWindFlag(flag);
+}
+
+MAGICS_NO_EXPORT void BaseDriver::renderSymbolItem(const SymbolItem& symbol, const ComplexSymbol& owner) const
+{
+	setNewColour(symbol.colour());
+	setLineParameters(M_SOLID, 1.); // reset line
+	loadSymbols();
+	if(sym_.empty()) {MagLog::error() << "BaseDriver::renderSymbols("<<symbol.symbol()<<")-> NO symbols available!"<<endl; return;}
+
+	const int noSymbols = sym_.size();
+	svgSymbol sym;
+	int ii=0;
+	for(;ii<noSymbols;ii++)
+	{
+		sym = sym_[ii];
+		if(sym.id==symbol.symbol()) break;
+	}
+	if(ii==noSymbols) sym = sym_[0];
+
+	const unsigned int si = sym.elements.size();
+	const MFloat pX = 1. / coordRatioX_;
+	const MFloat pY = 1. / coordRatioY_;
+	
+	MFloat scaling = convertCM(owner.getHeight()*1.5);  // convertCM scales them up!
+
+	const MFloat posX = owner[0].x() + (           symbol.x()  * scaling * pX);
+	const MFloat posY = owner[0].y() + (setSymbolY(symbol.y()) * scaling * pY);
+
+	for(unsigned int i=0;i<si;i++)  // for all elements in the symbol description
+	{
+		if(sym.elements[i].name == "circle")
+		{
+			const MFloat r  = atof(sym.elements[i].attributes["r"].c_str())  * scaling;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			const int s = atoi(sym.elements[i].attributes["fill"].c_str());
+			circle(posX+cx,posY+cy,r,s);
+		}
+		else if(sym.elements[i].name == "snowflake")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str())   * scaling * pX;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			snowflake(posX+cx,posY+cy,r);
+		}
+		else if(sym.elements[i].name == "drizzle")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str())   * scaling * pX;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			drizzle(posX+cx,posY+cy,r);
+		}
+		else if(sym.elements[i].name == "triangle")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling * pX;
+			const int s = atoi(sym.elements[i].attributes["fill"].c_str());
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			const int li = atoi(sym.elements[i].attributes["line"].c_str());
+			triangle(posX+cx,posY+cy,r,s,li);
+		}
+		else if(sym.elements[i].name == "lightning")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling * pX;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			lightning(posX+cx,posY+cy,r);
+		}
+		if(sym.elements[i].name == "polyline")
+		{
+			vector<PaperPoint> vPP;
+			parsePoints(vPP, sym.elements[i].attributes["points"]);
+			const int size = vPP.size();
+
+			if(size > 0)
+			{
+			  const MFloat sX = posX;
+			  const MFloat sY = posY;
+			  for(int s=0;s<size;s++)
+			  {
+				vPP[s].x( (vPP[s].x() * scaling * pX) + sX);
+				vPP[s].y( setSymbolY(setY((vPP[s].y()) * scaling * pY)) + sY);
+			  }
+			}			
+				
+		        if(!magCompare("none",sym.elements[i].attributes["fill"]) )
+				renderSimplePolygon(vPP);
+			else
+			  renderPolyline(vPP);
+		}
+	}// endfor 
+}
+
+
+/*!
+  \brief Symbol render method for ALL drivers.
+  
+  This method should be used by all Magics++ drivers to render symbols.
+  
+*/
+MAGICS_NO_EXPORT void BaseDriver::renderSymbols(const Symbol& symbol) const
+{
+	debugOutput("Start Symbols");
+	loadSymbols();
+
+	// if still empty
+	if(sym_.empty()) {MagLog::error() << "BaseDriver::renderSymbols("<<symbol.getSymbol()<<")-> NO symbols available!"<<endl; return;}
+
+	const int noSymbols = sym_.size();
+	svgSymbol sym;
+	int ii=0;
+	for(;ii<noSymbols;ii++)
+	{
+		sym = sym_[ii];
+		if(sym.id==symbol.getSymbol()) break;
+	}
+	if(ii==noSymbols) sym = sym_[0];
+
+	const unsigned int si = sym.elements.size();
+	setNewColour(symbol.getColour());
+	setLineParameters(M_SOLID, 1.); // reset line
+
+	const MFloat pX = 1. / coordRatioX_;
+	const MFloat pY = 1. / coordRatioY_;
+	const MFloat scaling = convertCM(symbol.getHeight()*.5);
+
+	for(unsigned int i=0;i<si;i++)  // for all elements in the symbol description
+	{
+		const long n = symbol.size();
+
+		if(sym.elements[i].name == "circle")
+		{
+			const MFloat r  = atof(sym.elements[i].attributes["r"].c_str())  * scaling;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = setY(atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY);
+			const int s = atoi(sym.elements[i].attributes["fill"].c_str());
+			for(long l=0;l<n;l++)
+			{
+				circle(symbol[l].x()+cx,symbol[l].y()+cy,r,s);
+				if(s==8 && symbol.outline())
+				{
+					setNewColour(symbol.outlineColour());
+					setLineParameters(symbol.outlineLineStyle(),symbol.outlineThickness());
+					circle(symbol[l].x()+cx,symbol[l].y()+cy,r,0);
+					//We need to go back to the original values
+					setNewColour(symbol.getColour());
+					setLineParameters(M_SOLID, 1.);
+				}
+			}	
+		}
+		else if(sym.elements[i].name == "snowflake")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling * pX;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			for(long l=0;l<n;l++) snowflake(symbol[l].x()+cx,symbol[l].y()+cy,r);
+		}
+		else if(sym.elements[i].name == "drizzle")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling * pX;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			for(long l=0;l<n;l++) drizzle(symbol[l].x()+cx,symbol[l].y()+cy,r);
+		}
+		else if(sym.elements[i].name == "triangle")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling * pX;
+			const int s = atoi(sym.elements[i].attributes["fill"].c_str());
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			const int li = atoi(sym.elements[i].attributes["line"].c_str());
+
+			for(long l=0;l<n;l++)
+			{
+				triangle(symbol[l].x()+cx,symbol[l].y()+cy,r,s,li);
+				if(s == 1 && symbol.outline())
+				{
+					setNewColour(symbol.outlineColour());
+					setLineParameters(symbol.outlineLineStyle(),symbol.outlineThickness());
+					triangle(symbol[l].x()+cx,symbol[l].y()+cy,r,0,li);
+					//We need to go back to the original values
+					setNewColour(symbol.getColour());
+					setLineParameters(M_SOLID, 1.);
+				}	
+			}
+		}	
+		else if(sym.elements[i].name == "lightning")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling * pX;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling * pX;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling * pY;
+			for(long l=0;l<n;l++) lightning(symbol[l].x()+cx,symbol[l].y()+cy,r);
+		}
+		if(sym.elements[i].name == "polyline")
+		{
+			for(long l=0;l<n;l++)
+			{
+				vector<PaperPoint> vPP;
+				parsePoints(vPP, sym.elements[i].attributes["points"]);
+				const int size = vPP.size();
+
+				if(size > 0)
+				{
+					const MFloat sX = symbol[l].x();
+					const MFloat sY = symbol[l].y();
+					for(int s=0;s<size;s++)
+					{
+						vPP[s].x( (vPP[s].x() * scaling * pX) + sX);
+						vPP[s].y( setSymbolY(setY((vPP[s].y()) * scaling * pY)) + sY);
+					}
+				
+					if(!magCompare("none",sym.elements[i].attributes["fill"]) )
+						renderSimplePolygon(vPP);
+					else
+						renderPolyline(vPP);
+					if(!magCompare("none",sym.elements[i].attributes["fill"]) && symbol.outline())
+					{
+						setNewColour(symbol.outlineColour());
+						setLineParameters(symbol.outlineLineStyle(),symbol.outlineThickness());
+						renderPolyline(vPP);
+						//We need to go back to the original values
+						setNewColour(symbol.getColour());
+						setLineParameters(M_SOLID, 1.);
+					}
+				}
+			}
+		}
+	}// endfor 
+}//end BaseDriver::renderSymbols()
+
+/*!
+  Plotting a snowflake
+*/
+MAGICS_NO_EXPORT void BaseDriver::snowflake(const MFloat x, const MFloat y, const MFloat size) const
+{
+	const MFloat s5 = size;
+	const MFloat s3 = size * 0.78;
+
+	vector<PaperPoint> line;
+	  line.push_back(PaperPoint(x-s5,y));
+	  line.push_back(PaperPoint(x+s5,y));
+	renderPolyline2(line);
+	line.clear();
+	  line.push_back(PaperPoint(x-s3,y+s3));
+	  line.push_back(PaperPoint(x+s3,y-s3));
+	renderPolyline2(line);
+	line.clear();
+	  line.push_back(PaperPoint(x-s3,y-s3));
+	  line.push_back(PaperPoint(x+s3,y+s3));
+	renderPolyline2(line);
+}
+
+/*!
+  Plotting drizzle
+*/
+MAGICS_NO_EXPORT void BaseDriver::drizzle(const MFloat x, const MFloat y, const MFloat size) const
+{
+	const MFloat s2 = size*.5;
+
+	circle(x,y,s2 * coordRatioX_,8);
+
+	vector<PaperPoint> line;
+	  line.push_back(PaperPoint(x+(s2*0.8),y));
+	  line.push_back(PaperPoint(x,y-size));
+	renderPolyline2(line);
+}
+
+/*!
+  Plotting lightning symbol
+*/
+MAGICS_NO_EXPORT void BaseDriver::lightning(const MFloat x, const MFloat y, const MFloat size) const
+{
+	vector<PaperPoint> line;
+	  line.push_back(PaperPoint(x-(size*.9),y-(size*.9)));
+	  line.push_back(PaperPoint(x-(size*.9),y+(size*.9)));
+	renderPolyline(line);
+	line.clear();
+	  line.push_back(PaperPoint(x-(size*.9),y+(size*.9)));
+	  line.push_back(PaperPoint(x+(size*.9),y+(size*.9)));
+	  line.push_back(PaperPoint(x+(size*.1),y));
+	  line.push_back(PaperPoint(x+(size*.9),y-(size*.9)));
+	renderPolyline(line);
+	line.clear();
+	  line.push_back(PaperPoint(x+(size*.8), y-(size*.4) ));
+	  line.push_back(PaperPoint(x+(size*.9), y-(size*.9) ));
+	  line.push_back(PaperPoint(x+(size*.45), y-(size*.8)));
+	renderPolyline(line);
+}
+
+/*!
+  Plotting a triangle
+*/
+MAGICS_NO_EXPORT void BaseDriver::triangle(const MFloat x, const MFloat y, const MFloat size, const int fill, const int l) const
+{
+	const MFloat s = 0.5 * size;
+
+	vector<PaperPoint> line;
+	  line.push_back(PaperPoint( x+s, y-s) );
+	  line.push_back(PaperPoint( x-s, y-s) );
+	  line.push_back(PaperPoint(   x, y+s) );
+	  line.push_back(PaperPoint( x+s, y-s) );
+	if(fill < 1)
+	{
+		renderPolyline(line);
+		if(l>0)
+		{
+			line.clear();
+			line.push_back(PaperPoint( x+s*.6, y-(s*.5)) );
+			line.push_back(PaperPoint( x-s*.6, y-(s*.5)) );
+			renderPolyline(line);
+		}
+	}
+	else renderSimplePolygon(line);
+}
diff --git a/src/drivers/BaseDriverWind.h b/src/drivers/BaseDriverWind.h
new file mode 100644
index 0000000..93fa2f8
--- /dev/null
+++ b/src/drivers/BaseDriverWind.h
@@ -0,0 +1,266 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2009 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BaseDriverWind.h
+    \brief Implementation of wind field methods of driver base class.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: March 2005
+    
+    Changes:
+      
+*/
+
+
+namespace magics{
+
+class rotate
+{
+public:
+	rotate():angle_(0){}
+	rotate(MFloat a, MFloat ratio=1.):angle_(a),ratio_(ratio){}
+	void operator()(PaperPoint &p)
+	{
+		MFloat x =  p.x()         * cos(angle_) + (p.y() / ratio_) * -sin(angle_);
+		MFloat y = (p.x()*ratio_) * sin(angle_) +  p.y()           *  cos(angle_);
+		p.x(x);
+		p.y(y);
+	}
+private:
+	MFloat angle_;
+	MFloat ratio_;
+};
+
+class translate
+{
+public:
+	translate():point_(){}
+	translate(PaperPoint point):point_(point){}
+	void operator()(PaperPoint &p)
+	{
+		MFloat x = p.x() + point_.x();
+		MFloat y = p.y() + point_.y();
+		p.x(x);
+		p.y(y);
+	}
+private:
+	PaperPoint point_;
+};
+
+} // end namespace
+
+using namespace magics;
+
+/*!
+  \brief Wind arrow render method for ALL drivers.
+  
+  This method should be used by all Magics++ drivers to render wind fields.
+*/
+MAGICS_NO_EXPORT void BaseDriver::renderWindArrow(const Arrow &arrow) const
+{
+	const MFloat base = 0.7;
+	const MFloat sca = (fabs(arrow.getScale()) < 0.001) ? 1. : arrow.getScale();
+	const MFloat scaling = convertCM(1.) / (sca * ((coordRatioX_+coordRatioX_)*.5 ));
+
+	const unsigned int arrPoNo = arrow.size();
+	if(arrPoNo<1) return;
+
+	const MFloat thickness = (arrow.getThickness()==1) ? 1 : 2.*arrow.getThickness();
+	const LineStyle style = arrow.getStyle();
+	const ArrowPosition pos = arrow.getArrowPosition();
+
+	setNewColour(arrow.getColour());
+	Arrow::const_iterator arr = arrow.begin();
+	int index  = arrow.getHeadIndex();
+	const MFloat ratio = (coordRatioY_==0) ? 1. : coordRatioX_/coordRatioY_;
+
+	for(unsigned int pts=0;pts<arrPoNo;pts++)
+	{
+	  const double angle = setAngleY(arr->angle());
+	  double norm  = arr->norm()*scaling;
+
+	  // The next line was making very small wind artificially bigger!
+	  // if(fabs(norm) < 0.01) norm = scaling;
+
+	  const double norm2 = norm * base;
+
+	  vector<PaperPoint> line;
+	  (pos==M_TAIL) ? line.push_back(PaperPoint(0.,0.)) : line.push_back(PaperPoint( -0.5*norm,0.));
+	  double xx       = (pos==M_TAIL) ? norm  :       0.5  * norm;
+	  if(index==2) xx = (pos==M_TAIL) ? norm2 : (base-0.5) * norm;
+
+	  line.push_back(PaperPoint(xx,0));
+	  for_each(line.begin(),line.end(),rotate(angle,ratio) );
+	  for_each(line.begin(),line.end(),translate(arr->point_) );
+
+	  xx = (pos==M_TAIL) ? norm : 0.5*(norm); // reset length
+
+	// Arrow base
+	  const int old_currentColourIndex = currentLineStyle_;
+	  currentLineStyle_ = setLineParameters(style,thickness);
+	  renderPolyline2(line);
+	  currentLineStyle_ = old_currentColourIndex;
+
+	// Arrow head
+	  const MFloat bx = (1.0-base) * norm; // a third of the length of arrow
+	  const MFloat by = (1.0-base) * ratio * norm * arrow.getHeadRatio(); // 10% of the length
+
+	  if( index>3 || index<0)
+	  {
+	  	MagLog::warning() << "Wind: Wind arrow head index "<<index<<"out of range (0-3)! Use 2 as default" << endl;
+		index = 0;
+	  }
+
+	  if(index == 0)
+	  {
+		line.clear();
+		line.push_back(PaperPoint(xx,0. ));
+		line.push_back(PaperPoint(xx-bx,-by));
+		for_each(line.begin(),line.end(),rotate(angle,ratio) );
+		for_each(line.begin(),line.end(),translate(arr->point_) );
+		renderPolyline2(line);
+
+		line.clear();
+		line.push_back(PaperPoint(xx,0. ));
+		line.push_back(PaperPoint(xx-bx,by));
+		for_each(line.begin(),line.end(),rotate(angle,ratio) );
+		for_each(line.begin(),line.end(),translate(arr->point_) );
+		renderPolyline2(line);
+	  }
+	  else
+	  {
+		line.clear();
+		line.push_back(PaperPoint(xx,0.));
+		line.push_back(PaperPoint(xx-bx,-by));
+		line.push_back(PaperPoint(xx-bx, by));
+		line.push_back(PaperPoint(xx,0. ));
+		for_each(line.begin(),line.end(),rotate(angle,ratio) );
+		for_each(line.begin(),line.end(),translate(arr->point_) );
+
+		if(index == 1 ) renderSimplePolygon(line);
+		else renderPolyline(line);
+	  }
+	  ++arr;
+	}
+}//end BaseDriver::renderWindArrow()
+
+
+
+MAGICS_NO_EXPORT void BaseDriver::renderWindFlag(const Flag &flag) const
+{
+	const MFloat thickness = (flag.getThickness()==1) ? 1 : 2.*flag.getThickness();
+	const LineStyle style = flag.getStyle();
+	const MFloat length = convertCM(flag.getLength() / coordRatioX_ );
+	const string marker = flag.getOriginMarker();
+	const MFloat markerHeight = convertCM(flag.getOriginHeight() *.5 / coordRatioX_);
+	setNewColour(flag.getColour());
+	const unsigned int flaPoNo = flag.size();
+	Flag::const_iterator fla = flag.begin();
+
+	Symbol origin;
+
+	for(unsigned int pts=0;pts<flaPoNo;pts++)
+	{
+		vector<PaperPoint> line;
+		const MFloat angle = setAngleY(fla->angle());
+		line.push_back(PaperPoint(-markerHeight,0.) );
+		line.push_back(PaperPoint(-length,0.) );
+		const MFloat ratio = (coordRatioY_==0) ? 1. : coordRatioX_/coordRatioY_;
+		for_each(line.begin(),line.end(),rotate(angle,ratio) );
+		for_each(line.begin(),line.end(),translate(fla->point_) );
+		MFloat len = fla->norm();
+
+		MFloat lev1 = 1.25;  // 2.5
+		MFloat lev2 = 3.75;  // 5.
+		MFloat lev3 = 23.;  // 25.
+		MFloat slev1 = 2.5;
+		MFloat slev2 = 5.;
+		MFloat slev3 = 25.;
+		
+		if(flag.getConvention()==KNOTS)
+		{
+			len *= 1.94384466;
+			lev1 = 3.;
+			lev2 = 7.;
+			lev3 = 47.;
+			slev1 = 5.;
+			slev2 = 10.;
+			slev3 = 50.;
+		}
+
+		if(markerHeight>0.) origin.push_back(PaperPoint(fla->point_) );
+
+		const int old_currentColourIndex = currentLineStyle_;
+		currentLineStyle_ = setLineParameters(style,thickness);
+		renderPolyline2(line);
+
+		currentLineStyle_ = old_currentColourIndex;
+		MFloat barbFraction = 0.;
+		int i = 0;
+		const MFloat lengthY = setY(length * ratio);
+		const MFloat barbHeight = setFlagY((flag.getHemisphere()==NORTH) ? (0.4*lengthY) : (-0.4*lengthY));
+		bool fl=false;
+
+		if(len<lev2) i++;
+		while(len>(lev1))
+		{
+			if(len > lev3)       {barbFraction=1.0; len-= slev3;fl=true;}
+			else if(len >= lev2) {barbFraction=1.0; len-= slev2;fl=false;}
+			else                 {barbFraction=0.6; len-= slev1;fl=false;}
+
+			const MFloat dx   = sin(RAD(30.)) * barbFraction * 0.2 * length; // angle of flags
+			const MFloat step = i * (0.1*length);
+
+			if(!fl)
+			{
+				line.clear();
+				line.push_back(PaperPoint( -(length-step),0.) );
+				line.push_back(PaperPoint( -(length-step+dx),barbHeight*barbFraction) );
+
+				for_each(line.begin(),line.end(),rotate(angle,ratio) );
+				for_each(line.begin(),line.end(),translate(fla->point_) );
+				renderPolyline2(line);
+			}
+			else
+			{
+				line.clear();
+				line.push_back(PaperPoint( -(length-step)   ,0.) );
+				line.push_back(PaperPoint( -(length-step),barbHeight*barbFraction) );
+				line.push_back(PaperPoint( -(length-step-(0.1*length)),0.) );
+				for_each(line.begin(),line.end(),rotate(angle,ratio) );
+				for_each(line.begin(),line.end(),translate(fla->point_) );
+				renderSimplePolygon(line);
+				fl=false;
+				i++;
+			}
+			i++;
+		}// end while
+		++fla;
+	}// end for
+
+	if(markerHeight>0. && !magCompare(marker,"none"))
+	{
+		origin.setSymbol(marker);
+		origin.setHeight(flag.getOriginHeight());
+		origin.setColour(flag.getColour());
+		renderSymbols(origin);
+	}
+}
diff --git a/src/drivers/BinaryDriver.cc b/src/drivers/BinaryDriver.cc
new file mode 100644
index 0000000..ce38e02
--- /dev/null
+++ b/src/drivers/BinaryDriver.cc
@@ -0,0 +1,701 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BinaryDriver.cc
+    \brief Implementation of BinaryDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Jan  4 20:28:15 2010
+
+*/
+
+#include <BinaryDriver.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+
+
+using namespace magics;
+
+
+/*!
+  \brief Constructor
+*/
+BinaryDriver::BinaryDriver()
+{
+	MagLog::debug() << "BinaryDriver::BinaryDriver needs implementing." <<endl;
+}
+
+/*!
+  \brief Destructor
+*/
+BinaryDriver::~BinaryDriver() 
+{
+}
+
+/*!
+  \brief Opening the driver
+*/
+void BinaryDriver::open()
+{
+        dimensionX_ = maground(width_);
+	const MFloat ratio = getYDeviceLength() / getXDeviceLength();
+        dimensionY_ = maground(ratio*dimensionX_);
+
+        setCMscale(dimensionX_/getXDeviceLength());
+
+	out_.open(getFileName("mgb").c_str(),ios::out|ios::binary);
+	if( !out_ ) {
+		MagLog::error() << "BinaryDriver: Error opening output stream." << endl;
+	}
+	else
+	{
+		const int version  = BINARY_VERSION;
+		const int checksum = 10;
+		const int headersize = 2*sizeof(MFloat);
+		const char mag[7] = "MAGICS";
+		out_.write((char *)(&mag), 6);
+		out_.write((char *)(&checksum),    sizeof(int));
+		out_.write((char *)(&version),     sizeof(int));
+		out_.write((char *)(&headersize),  sizeof(int));
+		out_.write((char *)(&dimensionX_), sizeof(MFloat));
+		out_.write((char *)(&dimensionY_), sizeof(MFloat));
+		out_.flush();
+	}
+	dimensionYglobal_ = dimensionY_;
+}
+
+/*!
+  \brief Closing the driver
+*/
+void BinaryDriver::close()
+{
+	endPage();
+	currentPage_ = 0;
+}
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+*/
+MAGICS_NO_EXPORT void BinaryDriver::startPage() const
+{
+	if(currentPage_ > 0) endPage();
+	
+	currentPage_++;
+}
+
+/*!
+  \brief ending a page
+ 
+  This method has to take care that for formats with multiple output 
+  files are closed.
+*/
+MAGICS_NO_EXPORT void BinaryDriver::endPage() const
+{
+	out_.close();
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void BinaryDriver::project(const magics::Layout& layout) const
+{
+	char c = 'P';
+	out_.write(&c, 1);
+//	const MFloat oldHeight = dimensionY_;
+
+	const double x = layout.x();
+	const double y = layout.y();
+	const double w = layout.width();
+	const double h = layout.height();
+	const double minX = layout.minX();
+	const double minY = layout.minY();
+	const double maxX = layout.maxX();
+	const double maxY = layout.maxY();
+
+	out_.write((char *)(&x), sizeof(double));
+	out_.write((char *)(&y), sizeof(double));
+	out_.write((char *)(&w), sizeof(double));
+	out_.write((char *)(&h), sizeof(double));
+	out_.write((char *)(&minX), sizeof(double));
+	out_.write((char *)(&minY), sizeof(double));
+	out_.write((char *)(&maxX), sizeof(double));
+	out_.write((char *)(&maxY), sizeof(double));
+
+	// for  J A V A S C R I P T
+	// push current state
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	const MFloat oldHeight = dimensionY_;
+	offsetsX_.push(offsetX_);
+	offsetsY_.push(offsetY_);
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+
+	offsetX_    += layout.x()     * 0.01 * dimensionX_;
+	offsetY_    -= layout.y()     * 0.01 * dimensionY_;
+	dimensionX_ =  layout.width() * 0.01 * dimensionX_;
+	dimensionY_ =  layout.height()* 0.01 * dimensionY_;
+
+	const MFloat sumX = layout.maxX() - layout.minX();
+	const MFloat sumY = layout.maxY() - layout.minY();
+
+	if( sumX!=0 && sumY!=0 )
+	{
+        	coordRatioX_ = dimensionX_/sumX;
+        	coordRatioY_ = -dimensionY_/sumY;
+	}
+
+	offsetX_ = projectX( -layout.minX());
+	offsetY_ = projectY( -layout.minY());
+
+	if(layout.isNavigable())
+	{
+		const double offsetX = offsetX_ + projectX( layout.minX());
+		const double offsetY = offsetY_ + projectY( layout.maxY());
+		layout.pushDriverInfo(offsetX, oldHeight+offsetY, dimensionX_, dimensionY_);
+	}
+}
+
+/*!
+  \brief reproject out of the last Layout
+
+  This method will update the offset and scale to the state they were before the
+  last Layout was received.
+
+*/
+MAGICS_NO_EXPORT void BinaryDriver::unproject() const
+{
+	char c = 'U';
+	out_.write(&c, 1);
+
+	dimensionY_ = dimensionStack_.top();dimensionStack_.pop();
+	dimensionX_ = dimensionStack_.top();dimensionStack_.pop();
+	offsetX_ = offsetsX_.top();offsetsX_.pop();
+	offsetY_ = offsetsY_.top();offsetsY_.pop();
+	coordRatioX_  = scalesX_.top(); scalesX_.pop();
+	coordRatioY_  = scalesY_.top(); scalesY_.pop();
+}
+
+
+/*!
+  \brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the 
+  current box is finished.
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void BinaryDriver::setNewColour(const Colour &colour) const
+{
+	const MFloat r=colour.red();
+	const MFloat g=colour.green();
+	const MFloat b=colour.blue();
+	const MFloat a=colour.alpha();
+        char c = 'C';
+        out_.write(&c, 1);
+	out_.write((char *)(&r), sizeof(MFloat));
+	out_.write((char *)(&g), sizeof(MFloat));
+	out_.write((char *)(&b), sizeof(MFloat));
+	out_.write((char *)(&a), sizeof(MFloat));
+}
+
+/*!
+  \brief sets a new line width
+
+  This line width stays the default width until the painting in the 
+  current box is finished.
+
+  \sa setLineParameters()
+*/
+MAGICS_NO_EXPORT void BinaryDriver::setNewLineWidth(const MFloat width) const
+{
+        char c = 'W';
+        out_.write(&c, 1);
+	out_.write((char *)(&width), sizeof(MFloat));
+}
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the 
+  current box is finished.
+
+  \sa LineStyle
+
+  \param linestyle Object describing the line style
+  \param w width of the line
+
+*/
+MAGICS_NO_EXPORT int BinaryDriver::setLineParameters(const LineStyle linestyle, const MFloat w) const
+{
+        char c = 'L';
+        out_.write(&c, 1);
+        out_.write((char *)(&linestyle), sizeof(LineStyle));
+	out_.write((char *)(&w), sizeof(MFloat));
+	return 0;
+}
+
+#include <Arrow.h>
+#include <Flag.h>
+
+void BinaryDriver::renderWindArrow(const Arrow &arrow) const
+{
+  /*
+    arrow.getScale()
+    arrow.getThickness()
+    const LineStyle style = arrow.getStyle();
+    const ArrowPosition pos = arrow.getArrowPosition();
+  */
+	char c = 'A';
+	out_.write(&c, 1);
+        const int no = arrow.size();
+	out_.write((char *)(&no), sizeof(int));
+        const double sc  = arrow.getScale();
+	out_.write((char *)(&sc), sizeof(double));
+        const int index  = arrow.getHeadIndex();
+	out_.write((char *)(&index), sizeof(int));
+	const LineStyle ls = arrow.getStyle();
+	out_.write((char *)(&ls), sizeof(LineStyle));
+	ArrowPosition ap = arrow.getArrowPosition();
+	out_.write((char *)(&ap), sizeof(ArrowPosition));
+	const int hi = arrow.getHeadIndex();
+	out_.write((char *)(&hi), sizeof(int));
+	const double hr = arrow.getHeadRatio();
+	out_.write((char *)(&hr), sizeof(double));
+
+	Colour colour = arrow.getColour();
+	const MFloat r=colour.red();
+	const MFloat g=colour.green();
+	const MFloat b=colour.blue();
+	out_.write((char *)(&r), sizeof(MFloat));
+	out_.write((char *)(&g), sizeof(MFloat));
+	out_.write((char *)(&b), sizeof(MFloat));
+
+        Arrow::const_iterator arr = arrow.begin();
+
+        for(int pts=0;pts<no;pts++)
+        {
+          const double x = arr->x_;
+	  out_.write((char *)(&x), sizeof(double));
+          const double y = arr->y_;
+	  out_.write((char *)(&y), sizeof(double));
+          const PaperPoint p = arr->point_;
+	  out_.write((char *)(&p), sizeof(PaperPoint));
+	  ++arr;
+        }
+}
+
+void BinaryDriver::renderWindFlag(const Flag &flag) const
+{
+/*
+	flag.getThickness()
+	LineStyle style = flag.getStyle()
+	flag.getLength()
+	flag.getColour()
+	flag.size()
+	string marker = flag.getOriginMarker()
+	flag.getOriginHeight()
+	flag.getConvention()==KNOTS
+	flag.getHemisphere()==NORTH
+*/
+	char c = 'F';
+	out_.write(&c, 1);
+        const int no = flag.size();
+	out_.write((char *)(&no), sizeof(int));
+        const double sc  = flag.getLength();
+	out_.write((char *)(&sc), sizeof(double));
+	const LineStyle ls = flag.getStyle();
+	out_.write((char *)(&ls), sizeof(LineStyle));
+	FlagConvention fc = flag.getConvention();
+	out_.write((char *)(&fc), sizeof(FlagConvention));
+	Hemisphere he = flag.getHemisphere();
+	out_.write((char *)(&he), sizeof(Hemisphere));
+	const double hr = flag.getThickness();
+	out_.write((char *)(&hr), sizeof(double));
+	const double hi = flag.getOriginHeight();
+	out_.write((char *)(&hi), sizeof(double));
+
+	Colour colour = flag.getColour();
+	const MFloat r=colour.red();
+	const MFloat g=colour.green();
+	const MFloat b=colour.blue();
+	out_.write((char *)(&r), sizeof(MFloat));
+	out_.write((char *)(&g), sizeof(MFloat));
+	out_.write((char *)(&b), sizeof(MFloat));
+	
+	const string t=flag.getOriginMarker();
+        const int len = t.length();
+        out_.write((char *)(&len),sizeof(int));
+
+        char pp[len];
+        strcpy(pp, t.c_str());
+        out_.write(pp,sizeof(char)*len);
+
+        Flag::const_iterator fla = flag.begin();
+
+        for(int pts=0;pts<no;pts++)
+        {
+          const double x = fla->x_;
+	  out_.write((char *)(&x), sizeof(double));
+          const double y = fla->y_;
+	  out_.write((char *)(&y), sizeof(double));
+          const PaperPoint p = fla->point_;
+	  out_.write((char *)(&p), sizeof(PaperPoint));
+	  ++fla;
+        }
+}
+
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void BinaryDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+	char c = 'H';
+	out_.write(&c, 1);
+	out_.write((char *)(&n), sizeof(int));
+	out_.write((char *)(x),  sizeof(MFloat)*n);
+	out_.write((char *)(y),  sizeof(MFloat)*n);
+}
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void BinaryDriver::renderPolyline2(const int n, MFloat* x, MFloat* y) const
+{
+	char c = 'B';
+	out_.write(&c, 1);
+	out_.write((char *)(&n), sizeof(int));
+	out_.write((char *)(x),  sizeof(MFloat)*n);
+	out_.write((char *)(y),  sizeof(MFloat)*n);
+}
+
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param line Polyline to be shaded
+*/
+MAGICS_NO_EXPORT void BinaryDriver::renderSimplePolygon(const Polyline& line) const
+{
+	line.getShading()->draw(*this);
+	setNewColour(line.getFillColour());
+	const unsigned int n = line.size();
+	if(n<3) return;
+
+	MFloat *x = new MFloat[n];
+	MFloat *y = new MFloat[n];
+	for(unsigned int i=0;i<n;i++)
+	{
+		const PaperPoint& pp = line.get(i);
+		x[i] = pp.x();
+		y[i] = pp.y();
+	}
+	char c = 'X';
+	out_.write(&c, 1);
+	out_.write((char *)(&n), sizeof(int));
+	out_.write((char *)(x),  sizeof(MFloat)*n);
+	out_.write((char *)(y),  sizeof(MFloat)*n);
+	delete [] x;
+	delete [] y;
+//cout <<"BWRITER>>> "<< n<< endl;
+	Polyline::Holes::const_iterator h = line.beginHoles();
+	Polyline::Holes::const_iterator he = line.endHoles();
+	const unsigned int nh = line.numberOfHoles();
+	out_.write((char *)(&nh), sizeof(int));
+//cout <<"BWRITER>>> "<< nh<< endl;
+	if(nh!=0)
+	{
+	  for (; h != he; ++h)
+	  {
+		vector<double> x;
+		vector<double> y;
+		line.hole(h,x,y);
+		const unsigned int nx = x.size();
+		out_.write((char *)(&nx), sizeof(int));
+
+		MFloat *xx = new MFloat[nx];
+		MFloat *yy = new MFloat[nx];
+		std::copy(x.begin(), x.end(), xx);
+		std::copy(y.begin(), y.end(), yy);
+		out_.write((char *)(xx),  sizeof(MFloat)*nx);
+		out_.write((char *)(yy),  sizeof(MFloat)*nx);
+		delete [] xx;
+		delete [] yy;
+	  }
+	}
+	Colour colour = line.getFillColour();
+	const MFloat r=colour.red();
+	const MFloat g=colour.green();
+	const MFloat b=colour.blue();
+	const MFloat a=colour.alpha();
+	out_.write((char *)(&r), sizeof(MFloat));
+	out_.write((char *)(&g), sizeof(MFloat));
+	out_.write((char *)(&b), sizeof(MFloat));
+	out_.write((char *)(&a), sizeof(MFloat));
+}
+
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void BinaryDriver::renderSimplePolygon(const int n, MFloat* x, MFloat* y) const
+{
+	char c = 'S';
+	out_.write(&c, 1);
+	out_.write((char *)(&n), sizeof(int));
+	out_.write((char *)(x),  sizeof(MFloat)*n);
+	out_.write((char *)(y),  sizeof(MFloat)*n);
+}
+
+/*!
+  \brief renders text strings
+
+  This method renders given text strings.
+
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void BinaryDriver::renderText(const Text& text) const
+{
+        if(text.empty()) return;
+        const vector<NiceText>& niceT = text.getNiceText();
+        if(niceT.empty()) return;
+        vector<NiceText>::const_iterator niceText = text.textBegin();
+
+        char c = 'T';
+        out_.write(&c, 1);
+	
+	const int s = text.size();
+	out_.write((char *)(&s),sizeof(int));
+
+	MagFont magfont = (*niceText).font();
+	Colour colour = magfont.colour();
+	const MFloat r=colour.red();
+	const MFloat g=colour.green();
+	const MFloat b=colour.blue();
+	out_.write((char *)(&r), sizeof(MFloat));
+	out_.write((char *)(&g), sizeof(MFloat));
+	out_.write((char *)(&b), sizeof(MFloat));
+
+	const MFloat an = text.getAngle();
+	out_.write((char *)(&an),sizeof(MFloat));
+
+        bool bl = text.getBlanking();
+        out_.write((char *)(&bl),sizeof(bool));
+
+        const enum Justification horizontal = text.getJustification();
+        const enum VerticalAlign vertical   = text.getVerticalAlign();
+        out_.write((char *)(&horizontal),sizeof(enum Justification));
+        out_.write((char *)(&vertical),  sizeof(enum VerticalAlign));
+
+	const int noNT = niceT.size();
+	out_.write((char *)(&noNT),sizeof(int));
+
+	for(int ntc=0;ntc<noNT;ntc++)
+	{
+	  MagFont magfont = niceT[ntc].font();
+	  Colour colour = magfont.colour();
+	  const MFloat r=colour.red();
+	  const MFloat g=colour.green();
+	  const MFloat b=colour.blue();
+	  out_.write((char *)(&r), sizeof(MFloat));
+	  out_.write((char *)(&g), sizeof(MFloat));
+	  out_.write((char *)(&b), sizeof(MFloat));
+
+	    const MFloat sf = magfont.size();
+	    out_.write((char *)(&sf),sizeof(MFloat));
+
+            const string t=niceT[ntc].text();
+            const int len = t.length();
+            out_.write((char *)(&len),sizeof(int));
+
+            char pp[len];
+            strcpy(pp, t.c_str());
+            out_.write(pp,sizeof(char)*len);
+        }
+
+        for(int g=0;g<s;g++)
+        {
+	    const MFloat x = text[g].x();
+	    const MFloat y = text[g].y();
+	    out_.write((char *)(&x),sizeof(MFloat));
+	    out_.write((char *)(&y),sizeof(MFloat));
+        }
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void BinaryDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s) const
+{
+	char c = 'R';
+	out_.write(&c, 1);
+	out_.write((char *)(&x), sizeof(MFloat));
+	out_.write((char *)(&y), sizeof(MFloat));
+	out_.write((char *)(&r), sizeof(MFloat));
+	out_.write((char *)(&s), sizeof(int));
+}
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \sa renderCellArray()
+
+  \param x0 x of lower corner
+  \param y0 y of lower corner
+  \param x1 x of higher corner
+  \param y1 y of higher corner
+  \param w width of pixmap
+  \param h height of pixmap
+  \param pixmap contents
+  \param landscape says if contents is landscape
+
+*/
+MAGICS_NO_EXPORT bool BinaryDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                                            int w,int h,unsigned char* pixmap,int landscape, bool) const
+{
+	MagLog::debug() << "BinaryDriver::renderPixmap needs implementing." <<endl;
+	return true;
+}
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are 
+  mainly used for satellite data.
+
+  \sa renderPixmap()
+
+  \param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool BinaryDriver::renderCellArray(const Image& image) const
+{
+	char cc = 'I';
+	out_.write(&cc, 1);
+
+//	ColourTable &lt = image.getColourTable();
+	const int width  = image.getNumberOfColumns();
+	out_.write((char *)(&width), sizeof(int));
+	const int height = image.getNumberOfRows();
+	out_.write((char *)(&height), sizeof(int));
+	const MFloat x0 = image.getOrigin().x();
+	out_.write((char *)(&x0), sizeof(MFloat));
+	const MFloat y0 = image.getOrigin().y();
+	out_.write((char *)(&y0), sizeof(MFloat));
+	const MFloat x1 = image.getWidth();
+	out_.write((char *)(&x1), sizeof(MFloat));
+	const MFloat y1 = image.getHeight();
+	out_.write((char *)(&y1), sizeof(MFloat));
+
+	ColourTable &lt = image.getColourTable();
+	int si = 0;
+	for ( magvector<ColourTableEntry>::const_iterator colour = lt.begin(); colour != lt.end(); ++colour ) {
+		si++; 
+	}
+	const int sii = si;
+
+// cout << "Image>  pixel: "<<width<<"x"<<height<<"="<<width*height<<" orig: "<<x0<<"/"<<y0<<"    dim: "<<x1<<"/"<<y1<<"     noColours: "<<sii<< endl;
+
+	out_.write((char *)(&sii), sizeof(int));
+	for(int v=0;v<sii;v++)
+	{
+	  const double r=lt[v].red();
+	  const double g=lt[v].green();
+	  const double b=lt[v].blue();
+	  const double a=lt[v].alpha();
+	  out_.write((char *)(&r), sizeof(double));
+	  out_.write((char *)(&g), sizeof(double));
+	  out_.write((char *)(&b), sizeof(double));
+	  out_.write((char *)(&a), sizeof(double));
+	}
+
+	short *c = new short[width*height];
+	for (long i=0;i<width*height;i++)
+		  c[i] = image[i];
+	out_.write((char *)(c), sizeof(short)*width*height);
+	delete [] c;
+	return true;
+}
+
+
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void BinaryDriver::print(ostream& out)  const
+{
+	out << "BinaryDriver[";
+	out << "]";
+}
+
+static SimpleObjectMaker<BinaryDriver, BaseDriver> Binary_driver("Binary");
+
diff --git a/src/drivers/BinaryDriver.h b/src/drivers/BinaryDriver.h
new file mode 100644
index 0000000..841271a
--- /dev/null
+++ b/src/drivers/BinaryDriver.h
@@ -0,0 +1,130 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file BinaryDriver.h
+    \brief Definition of BinaryDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Sun Oct  4 20:28:15 2009
+*/
+
+#ifndef _MPP_BinaryDriver_H
+#define _MPP_BinaryDriver_H
+
+#include <BaseDriver.h>
+#include <BinaryDriverAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \class BinaryDriver
+    \brief This driver produces output for Binary
+    \ingroup drivers
+
+    This driver ...
+*/
+class BinaryDriver: public BaseDriver, public BinaryDriverAttributes
+{
+
+public:
+	BinaryDriver();
+	~BinaryDriver();
+	void open();
+	void close();
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "mgb") )
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("binary");
+			BinaryDriverAttributes::set(basic);
+		}
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<std::string, std::string>& map)
+	{
+		BaseDriver::set(map);
+		BinaryDriverAttributes::set(map);
+	}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void unproject() const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const MFloat) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const MFloat w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+
+	// BinaryDriver specific member functions BEGIN
+        MAGICS_NO_EXPORT void renderWindArrow(const Arrow &arrow) const;
+        MAGICS_NO_EXPORT void renderWindFlag(const Flag &flag) const;
+	
+	MAGICS_NO_EXPORT MFloat setAngleY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setSymbolY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setFlagY(const MFloat y) const {return y;}
+	MAGICS_NO_EXPORT MFloat setY(const MFloat y) const {return y;}
+
+	mutable ofstream out_;
+
+	// BinaryDriver specific member functions END
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const {MagLog::debug() << s << endl;}
+
+	//! Copy constructor - No copy allowed
+	BinaryDriver(const BinaryDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	BinaryDriver& operator=(const BinaryDriver&);
+
+	mutable stack<MFloat> offsetsX_;
+	mutable stack<MFloat> offsetsY_;
+	mutable int dimensionYglobal_;
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BinaryDriver& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/CairoDriver.cc b/src/drivers/CairoDriver.cc
new file mode 100644
index 0000000..d7ed565
--- /dev/null
+++ b/src/drivers/CairoDriver.cc
@@ -0,0 +1,1471 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+/*
+
+ I currently have a function that accepts a cairo context (with a path already set)
+ and strokes the path with a pre-set width and color. The context can have any arbitrary
+ transformation already applied to it. So given this situation, how would I ensure
+ that I get a uniform line width from the stroke even when they may have applied a
+ deforming scale to the context? Any ideas would be appreciated!
+
+Something like:
+
+  cairo_save (cr);
+  cairo_identity_matrix (cr);
+  cairo_set_line_width (cr, width);
+  cairo_stroke (cr);
+  cairo_restore (cr);
+
+*/
+
+/*! \file CairoDriver.cc
+    \brief Implementation of CairoDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Oct 15 20:49:32 2007
+
+   \todo Fix 'convert' dependency
+   \todo Check how much drivers are dependent on writing temp files in local directory (thread safety)
+*/
+#include <cairo.h>
+
+#include <CairoDriver.h>
+//#include <CairoDriverRaster.cc>
+
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+#include <Symbol.h>
+#include <ImportObject.h>
+#include <System.h>
+#include <Timer.h>
+
+#include <pango/pangocairo.h>
+#include <iconv.h>             // Only for AIX?
+
+#if CAIRO_HAS_PDF_SURFACE
+#include <cairo-pdf.h>
+#endif
+
+#if CAIRO_HAS_PS_SURFACE
+#include <cairo-ps.h>
+#endif
+
+#if CAIRO_HAS_SVG_SURFACE
+#include <cairo-svg.h>
+#endif
+
+#if CAIRO_HAS_XLIB_SURFACE
+#include <cairo-xlib.h>
+Display *dpy;
+#endif
+
+#define FONT_SCALE 25*.7  //! \todo clean-up!!!
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+*/
+CairoDriver::CairoDriver() : filename_(""), offsetX_(0), offsetY_(0), backend_("PDF")
+{
+        cr_ = 0;
+}
+
+/*!
+  \brief Destructor
+*/
+CairoDriver::~CairoDriver()
+{
+}
+
+/*!
+  \brief Opening the driver
+*/
+void CairoDriver::open()
+{
+	MagLog::dev() << "Cairo version used is: "<<cairo_version_string()<< " backend: "<<backend_ <<endl;
+
+	MFloat ratio = getYDeviceLength() / getXDeviceLength();
+	int width = maground(width_);
+
+	string mbg_tmpl = mgb_template_;
+	if(!mbg_tmpl.empty())
+	{
+		setDimensionsFromBinary(mbg_tmpl,ratio,	width);
+//cout <<"CAIRO> BINARY TEMPLATE: SET WIDTH TO "<<width<< " and ratio to "<<ratio<<endl;
+	}
+
+	setCMscale(MFloat(width)/getXDeviceLength());
+	dimensionXglobal_ = width;
+	MagLog::dev() << "width -->" << width << endl;
+	MagLog::dev() << "ratio -->" << ratio*width << endl;
+	MagLog::dev() << "ratio -->" << maground(ratio*width) << endl;
+	MagLog::dev() << "ratio -->" << static_cast<int>(ratio*width) << endl;
+	dimensionYglobal_ = maground(ratio*width);
+
+	coordRatioY_ = -1;
+
+	if(context_)
+	{
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
+		cr_ = (cairo_t*)context_;
+		surface_ = cairo_get_group_target(cr_);
+		dimensionXglobal_ = cairo_image_surface_get_width (surface_);
+                dimensionYglobal_ = cairo_image_surface_get_height(surface_);
+#else
+		MagLog::error() << "CairoDriver: For contexts you need at least Cairo 1.2!" <<endl;
+#endif
+	}
+	else
+		setupNewSurface();
+
+	cairo_status_t res = cairo_surface_status(surface_);
+	if (res != CAIRO_STATUS_SUCCESS)
+	{
+		MagLog::warning() << "Cairo> " << cairo_status_to_string(res) << endl;
+		return;
+	}
+
+	if(magCompare(antialias_,"off"))
+	{
+	  cairo_set_antialias(cr_, CAIRO_ANTIALIAS_NONE);
+	  cairo_font_options_t *cf = cairo_font_options_create();
+	  cairo_font_options_set_antialias(cf, CAIRO_ANTIALIAS_NONE);
+	}
+}
+
+
+void CairoDriver::setupNewSurface() const
+{
+	if(magCompare(backend_,"png"))
+	{
+	    surface_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dimensionXglobal_, dimensionYglobal_);
+	}
+	else if(magCompare(backend_,"pdf"))
+	{
+#if CAIRO_HAS_PDF_SURFACE
+	    filename_ = getFileName("pdf");
+//            dimensionXglobal_ = static_cast<int>(getXDeviceLength()*72/2.54);
+ //           dimensionYglobal_ = static_cast<int>(getYDeviceLength()*72/2.54);
+
+	    surface_ = cairo_pdf_surface_create(filename_.c_str(), dimensionXglobal_, dimensionYglobal_);
+#else
+	    MagLog::error() << "CairoDriver: PDF output NOT supported! Enable PDF support in your Cairo installation." <<endl;
+#endif
+	}
+	else if(magCompare(backend_,"ps"))
+	{
+#if CAIRO_HAS_PS_SURFACE
+	    filename_ = getFileName("ps"); 
+
+	    const int dimensionXglobal = static_cast<int>(getXDeviceLength()*72/2.54);
+	    const int dimensionYglobal = static_cast<int>(getYDeviceLength()*72/2.54);
+
+//	    if(dimensionXglobal>dimensionYglobal)   // landscape
+//	    {
+//               surface_ = cairo_ps_surface_create(filename_.c_str(), dimensionYglobal,dimensionXglobal);
+//            }
+//            else
+//            {
+                surface_ = cairo_ps_surface_create(filename_.c_str(), dimensionXglobal,dimensionYglobal);
+//            }
+#else
+	    MagLog::error() << "CairoDriver: PS output NOT supported! Enable PS support in your Cairo installation." <<endl;
+#endif
+	}
+	else if(magCompare(backend_,"eps"))
+	{
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)
+	    filename_ = getFileName("eps");
+	    surface_ = cairo_ps_surface_create(filename_.c_str(), dimensionXglobal_, dimensionYglobal_);
+	    cairo_ps_surface_set_eps (surface_,true);
+#else
+	    MagLog::error() << "CairoDriver: EPS output NOT supported! You need at least version Cairo 1.5.2.\n"
+	                 << "PostScript is generated instead." <<endl;
+	    filename_ = getFileName("ps");
+	    surface_ = cairo_ps_surface_create(filename_.c_str(), dimensionXglobal_, dimensionYglobal_);
+#endif
+	}
+	else if(magCompare(backend_,"svg"))
+	{
+#if CAIRO_HAS_SVG_SURFACE
+	    filename_ = getFileName("svg",currentPage_+1);
+
+	    surface_ = cairo_svg_surface_create (filename_.c_str(), dimensionXglobal_, dimensionYglobal_);
+//	    cairo_svg_surface_restrict_to_version (surface_, CAIRO_SVG_VERSION_1_2);
+#else
+	    MagLog::error() << "CairoDriver: SVG output NOT supported! Enable SVG support in your Cairo installation." <<endl;
+#endif
+	}
+	else if(magCompare(backend_,"x"))
+	{
+#if CAIRO_HAS_XLIB_SURFACE
+		Window rootwin;
+		Window win;
+
+		if(!(dpy=XOpenDisplay(NULL)))
+		{
+			MagLog::fatal() << "CairoDriver: Could not open display for Xlib!"<<endl;
+			terminate();
+		}
+
+		int scr=DefaultScreen(dpy);
+		rootwin=RootWindow(dpy, scr);
+
+		win=XCreateSimpleWindow(dpy, rootwin, 1, 1, dimensionXglobal_, dimensionYglobal_, 0,
+				BlackPixel(dpy, scr), BlackPixel(dpy, scr));
+
+		XStoreName(dpy, win, "Magics++");
+		XSelectInput(dpy, win, ExposureMask|ButtonPressMask);
+		XMapWindow(dpy, win);
+
+		surface_ = cairo_xlib_surface_create(dpy, win, DefaultVisual(dpy, 0), dimensionXglobal_, dimensionYglobal_);
+#else
+		MagLog::error() << "CairoDriver: Xlib output NOT supported! Enable Xlib support in your Cairo installation." <<endl;
+#endif
+	}
+	else
+	{
+		MagLog::error() << "CairoDriver: The backend "<< backend_ <<" is NOT supported!" <<endl;
+	}
+
+	cairo_status_t status = cairo_surface_status(surface_);
+	if (status)
+	{
+		MagLog::error()	<< "CairoDriver: the surface ("<<backend_<<") could not be generated!\n"
+				<< " -> "<<cairo_status_to_string(status)<<endl;
+	}
+
+	if ( !cr_) cr_ = cairo_create (surface_);
+
+	// set PS META information
+	if(magCompare(backend_,"ps") )
+	{
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
+	  const SystemInfo info;
+	  const string s1 = "%%Title: " + title_;
+	  cairo_ps_surface_dsc_comment (surface_, s1.c_str());
+	  const string s2 = "%%Creator2: " + getMagicsVersionString();
+	  cairo_ps_surface_dsc_comment (surface_, s2.c_str());
+	  const string s3 = "%%For: " + info.getUserID() + "@" + info.getHostName() + " " + info.getUserName();
+	  cairo_ps_surface_dsc_comment (surface_, s3.c_str());
+
+/*	    if(dimensionXglobal_>dimensionYglobal_)   // landscape
+	    {
+                dimensionYglobal_ = static_cast<int>(getXDeviceLength()*72/2.54);
+                dimensionXglobal_ = static_cast<int>(getYDeviceLength()*72/2.54);
+                cairo_translate (cr_, 0, dimensionYglobal_);
+                cairo_matrix_t matrix;
+                cairo_matrix_init (&matrix, 0, -1, 1, 0, 0,  0);
+		cairo_transform (cr_, &matrix);
+		cairo_ps_surface_dsc_comment (surface_, "%%PageOrientation: Landscape");
+	    }
+            else
+            {
+*/
+                dimensionXglobal_ = static_cast<int>(getXDeviceLength()*72/2.54);
+                dimensionYglobal_ = static_cast<int>(getYDeviceLength()*72/2.54);
+          	cairo_ps_surface_dsc_comment (surface_, "%%PageOrientation: Landscape");
+//            }
+
+	  if(magCompare(MAGICS_SITE,"ecmwf"))
+	    cairo_ps_surface_dsc_comment (surface_, "%%Copyright: Copyright (C) ECMWF");
+#endif
+	}
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
+	cairo_surface_set_fallback_resolution (surface_, resolution_, resolution_);
+#endif
+	if(magCompare(transparent_,"off") || !magCompare(backend_,"png"))
+	{
+		cairo_set_source_rgb (cr_, 1.0, 1.0, 1.0); /* white */
+	}
+	else
+	{
+		cairo_set_source_rgba (cr_, 1.0, 1.0, 1.0,0.0); /* white transparent */
+	}
+	cairo_paint (cr_);
+	cairo_set_line_join(cr_,CAIRO_LINE_JOIN_BEVEL);
+
+	dimensionX_ = static_cast<MFloat>(dimensionXglobal_);
+	if(!context_)
+	   dimensionY_ = static_cast<MFloat>(dimensionYglobal_);
+	else
+	{
+	   const MFloat ratio = getYDeviceLength() / getXDeviceLength();
+	   dimensionY_ =  static_cast<int>(ratio*dimensionXglobal_);
+	}
+	currentPage_ = 0;
+
+	if(magCompare(antialias_,"off"))
+		cairo_set_antialias(cr_, CAIRO_ANTIALIAS_NONE);
+	else
+		cairo_set_antialias(cr_, CAIRO_ANTIALIAS_SUBPIXEL);
+}
+
+/*!
+  \brief Closing the driver
+*/
+void CairoDriver::close()
+{
+	currentPage_ = 0;
+
+	if(magCompare(backend_,"pdf") && !filename_.empty()) printOutputName("CAIRO pdf "+filename_);
+	if(magCompare(backend_,"ps") && !filename_.empty()) printOutputName("CAIRO ps "+filename_);
+
+	if ( context_ == 0 ) {
+		cairo_surface_destroy (surface_);
+		cairo_destroy (cr_);
+	}
+#if CAIRO_HAS_XLIB_SURFACE
+	if(magCompare(backend_,"x"))
+	{
+		XEvent event;
+		while(1)
+		{
+			XNextEvent(dpy, &event);
+			if(event.type==Expose && event.xexpose.count<1)
+			{}
+			else if(event.type==ButtonPress) break;
+		}
+		XCloseDisplay(dpy);
+	}
+#endif
+}
+
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+*/
+MAGICS_NO_EXPORT void CairoDriver::startPage() const
+{
+	if(currentPage_ > 0)
+	{
+		if (magCompare(backend_,"png") )
+		{
+			cairo_destroy (cr_);
+			cairo_surface_destroy (surface_);
+
+			surface_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dimensionXglobal_, dimensionYglobal_);
+			cr_ = cairo_create(surface_);
+			if(magCompare(transparent_,"off"))
+			{
+				cairo_set_source_rgb (cr_, 1.0, 1.0, 1.0); /* white */
+			}
+			else
+			{
+				cairo_set_source_rgba (cr_, 1.0, 1.0, 1.0, 0.0); /* white transparent */
+			}
+			cairo_paint (cr_);
+		}
+#if CAIRO_HAS_SVG_SURFACE
+		else if (magCompare(backend_,"svg") )
+		{
+			cairo_destroy (cr_);
+			cairo_surface_destroy (surface_);
+
+			filename_ = getFileName("svg",currentPage_+1);
+			surface_ = cairo_svg_surface_create(filename_.c_str(), dimensionXglobal_, dimensionYglobal_);
+			cr_ = cairo_create (surface_);
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
+			cairo_svg_surface_restrict_to_version (surface_, CAIRO_SVG_VERSION_1_1);
+#endif
+		}
+#endif
+		else if(magCompare(backend_,"eps"))
+		{
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)
+			cairo_destroy (cr_);
+			cairo_surface_destroy (surface_);
+
+			filename_ = getFileName("eps",currentPage_+1);
+			surface_ = cairo_ps_surface_create(filename_.c_str(), dimensionXglobal_, dimensionYglobal_);
+			cairo_ps_surface_set_eps (surface_,true);
+			cr_ = cairo_create (surface_);
+#endif
+		}
+	}
+
+	if( currentPage_ == 0 || (!magCompare(backend_,"pdf") && !magCompare(backend_,"ps")) )
+	{
+		cairo_translate(cr_,0,static_cast<MFloat>(dimensionYglobal_));
+	}
+//	cairo_scale(cr_,1,-1);
+
+	currentPage_++;
+	newPage_ = true;
+}
+
+
+/*!
+  \brief ending a new page
+
+  This method has to take care that for formats with multiple output
+  files are closed.
+*/
+MAGICS_NO_EXPORT void CairoDriver::endPage() const
+{
+	cairo_show_page(cr_);
+
+	if(magCompare(backend_,"eps"))
+	{
+		if(!filename_.empty()) printOutputName("CAIRO eps "+filename_);
+	}
+	else if(magCompare(backend_,"svg"))
+	{
+		if(!filename_.empty()) printOutputName("CAIRO svg "+filename_);
+	}
+	else if (magCompare(backend_,"png") )
+	{
+		Timer timer("cairo", "write png");
+//		write_png(surface_, "test256.png");
+		filename_ = getFileName("png" ,currentPage_);
+		cairo_surface_write_to_png(surface_, filename_.c_str());
+		if(!filename_.empty()) printOutputName("CAIRO png "+filename_);
+
+	//	filename_ = getFileName("jpg" ,currentPage_);
+	//	write_jpeg(surface_, "test.jpg", JCS_RGB, JCS_RGB, 3, false, true);
+	//	filename_ = getFileName("tiff" ,currentPage_);
+	//	write_tiff(surface_, "test.tiff");
+	}
+}
+
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void CairoDriver::project(const Layout& layout) const
+{
+	cairo_save (cr_);
+
+	// push current state
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	const MFloat oldHeight = dimensionY_;
+	offsetsX_.push(offsetX_);
+	offsetsY_.push(offsetY_);
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+
+	offsetX_    += layout.x()     * 0.01 * dimensionX_;
+	offsetY_    -= layout.y()     * 0.01 * dimensionY_;
+	dimensionX_ =  layout.width() * 0.01 * dimensionX_;
+	dimensionY_ =  layout.height()* 0.01 * dimensionY_;
+
+	const MFloat sumX = layout.maxX() - layout.minX();
+	const MFloat sumY = layout.maxY() - layout.minY();
+
+	if( sumX!=0 && sumY!=0 )
+	{
+		coordRatioX_ = dimensionX_/sumX;
+		coordRatioY_ = -dimensionY_/sumY;
+	}
+
+	offsetX_ = projectX( -layout.minX());
+	offsetY_ = projectY( -layout.minY() );
+
+/*
+	if(box->getClip())
+	{
+//		cairo_set_source_rgb(cr_, 1,0,0);
+		cairo_rectangle (cr_, projectX(Xmin),projectY(Ymin),projectX(Xmax)-projectX(Xmin),projectY(Ymax)-projectY(Ymin) );
+		cairo_clip(cr_);
+//		cairo_stroke(cr_);
+	}
+	if(box->centered())
+	{
+		Xoff += Xlength*0.5;
+		Yoff += Ylength*0.5;
+		obsBox_=true;
+	}
+	else obsBox_=false;
+*/
+	// write meta info
+	if(layout.isNavigable() && (magCompare(backend_,"png") || magCompare(backend_,"svg")) )
+	{
+		const double offsetX = projectX(layout.minX());
+		const double offsetY = projectY(layout.maxY());
+                layout.pushDriverInfo(offsetX, oldHeight+offsetY, dimensionX_, dimensionY_);
+	}
+}
+
+/*!
+  \brief reproject out of the last Layout
+
+  This method will update the offset and scale to the state they were before the
+  last Layout was received.
+
+  \sa UnLayout
+*/
+MAGICS_NO_EXPORT void CairoDriver::unproject() const
+{
+	dimensionY_ = dimensionStack_.top();dimensionStack_.pop();
+	dimensionX_ = dimensionStack_.top();dimensionStack_.pop();
+	offsetX_ = offsetsX_.top();offsetsX_.pop();
+	offsetY_ = offsetsY_.top();offsetsY_.pop();
+	coordRatioX_  = scalesX_.top(); scalesX_.pop();
+	coordRatioY_  = scalesY_.top(); scalesY_.pop();
+
+//	cairo_reset_clip(cr_);
+	cairo_restore(cr_);
+}
+
+
+/*!
+  \brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the
+  current box is finished.
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void CairoDriver::setNewColour(const Colour &colour) const
+{
+	currentColour_ = colour;
+}
+
+/*!
+  \brief sets a new line width
+
+  This line width stays the default width until the painting in the
+  current box is finished.
+
+  \sa setLineParameters()
+  \todo Find a better way than multiple by 0.6
+*/
+MAGICS_NO_EXPORT void CairoDriver::setNewLineWidth(const MFloat width) const
+{
+//        currentLineWidth_ = (width > 0.01 ? width : 0.01) * .6;
+        currentLineWidth_ = width * .5;
+}
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the
+  current box is finished.
+
+  \sa LineStyle
+
+  \param linestyle Object describing the line style
+  \param width width of the line
+*/
+MAGICS_NO_EXPORT int CairoDriver::setLineParameters(const LineStyle linestyle, const MFloat width) const
+{
+	setNewLineWidth(width);
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
+	if(cairo_get_dash_count(cr_)==0 && linestyle==M_SOLID) return 0;
+#endif
+	switch(linestyle)
+	{
+		case M_DASH: // 6 on - 2 off
+			{
+			 cairo_set_line_cap (cr_, CAIRO_LINE_CAP_SQUARE);
+			 const double dash_line[] = { 4. };
+			 cairo_set_dash(cr_,dash_line,1,0.);
+			}
+			break;
+		case M_DOT: // 1 on - 2 off
+                        {
+			 setNewLineWidth(2*width);
+			 const double dotted_line[] = { 0., 6. };
+			 cairo_set_line_cap (cr_, CAIRO_LINE_CAP_ROUND);
+			 cairo_set_dash(cr_,dotted_line,2,0.);
+			}
+			break;
+		case M_CHAIN_DASH: // 4 on - 2 off -  1 on - 2 off
+			{
+			 const double chain_dash_line[] = { 4., 4., 0., 6. };
+			 cairo_set_line_cap (cr_, CAIRO_LINE_CAP_SQUARE);
+			 cairo_set_dash(cr_,chain_dash_line,4,0.);
+			}
+			break;
+		case M_CHAIN_DOT: // 4 on - 2 off -  1 on - 2 off - 1 on - 2 off
+			{
+			 const double chain_dot_line[] = { 4., 4., 0., 6., 0., 6. };
+			 cairo_set_line_cap (cr_, CAIRO_LINE_CAP_SQUARE);
+			 cairo_set_dash(cr_,chain_dot_line,6,0.);
+			}
+			break;
+		default:  // SOLID
+			{
+			 cairo_set_line_cap (cr_, CAIRO_LINE_CAP_SQUARE);
+			 const double solid_line[] = { 4., 0. };
+			 cairo_set_dash(cr_,solid_line,0,0.);
+			}
+			break;
+	}
+	return 0;
+}
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+	if(n<2 || (currentColour_==Colour("none")) ) return;
+	cairo_save(cr_);
+
+	MFloat xx = projectX(x[0]);
+	MFloat yy = projectY(y[0]);
+	cairo_move_to (cr_, xx, yy);
+
+	for(int l = 1; l<n; l++)
+	{
+		xx = projectX(x[l]);
+		yy = projectY(y[l]);
+		cairo_line_to (cr_, xx, yy);
+	}
+
+	cairo_identity_matrix (cr_);
+        cairo_set_line_width (cr_, currentLineWidth_);
+	cairo_set_source_rgba(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+        cairo_stroke (cr_);
+	cairo_restore(cr_);
+}
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderPolyline2(const int n, MFloat* x, MFloat* y) const
+{
+	if(n!=2 || (currentColour_==Colour("none")) ) return;
+
+	cairo_save(cr_);
+	cairo_move_to (cr_, x[0], y[0]);
+	cairo_line_to (cr_, x[1], y[1]);
+	cairo_identity_matrix (cr_);
+	cairo_set_line_width (cr_, currentLineWidth_);
+
+	cairo_set_source_rgba(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+        cairo_stroke (cr_);
+	cairo_restore(cr_);
+}
+
+
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param line polyline to be filled
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderSimplePolygon(const Polyline& line) const
+{
+	setNewColour(line.getFillColour());
+	const unsigned int n = line.size();
+	if(n<3 || (currentColour_==Colour("none")) ) return;
+	cairo_save(cr_);
+	line.getShading()->draw(*this);
+
+//	if(currentColour_.alpha()<0.999)
+		cairo_set_source_rgba(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue(), currentColour_.alpha());
+//	else
+//		cairo_set_source_rgb(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue());
+
+	MFloat xx = projectX(line.get(0).x());
+	MFloat yy = projectY(line.get(0).y());
+	cairo_move_to (cr_, xx, yy);
+
+	for(unsigned int l = 1; l<n; l++)
+	{
+		const PaperPoint& pp = line.get(l);
+		xx = projectX(pp.x());
+		yy = projectY(pp.y());
+		cairo_line_to (cr_, xx, yy);
+	}
+
+	cairo_set_fill_rule (cr_, CAIRO_FILL_RULE_EVEN_ODD);
+
+	Polyline::Holes::const_iterator h = line.beginHoles();
+	Polyline::Holes::const_iterator he = line.endHoles();
+
+	for (; h != he; ++h)
+	{
+		cairo_new_sub_path(cr_);
+		vector<double> x;
+		vector<double> y;
+		line.hole(h,x,y);
+		if ( x.empty() ) 
+			continue;
+		cairo_move_to (cr_, projectX(x[0]),setY(projectY(y[0])));
+		vector<double>::const_iterator yt = y.begin();
+		vector<double>::const_iterator it = x.begin();
+		++it;
+		++yt;
+		for(; it != x.end(); )
+		{
+		  cairo_line_to (cr_, projectX(*it),setY(projectY(*yt)));
+		  ++it;
+		  ++yt;
+		}
+	}
+
+//	cairo_close_path (cr_);
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
+	if (currentShading_==M_SH_DOT)
+	{
+		const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+		const int density = (int)sqrt(pro->density_);
+		if(density<=0) return;
+		const int s = (int)(pro->size_*convertCM(1.)*5.);
+		const MFloat square_size = convertCM(1.)/density;
+
+		cairo_surface_t *pat_surface;
+		cairo_pattern_t *pattern;
+		cairo_t *cr2;
+
+		pat_surface = cairo_surface_create_similar(cairo_get_group_target(cr_),CAIRO_CONTENT_COLOR_ALPHA, square_size, square_size);
+		cr2 = cairo_create (pat_surface);
+
+		cairo_set_source_rgba(cr2,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+		const MFloat off = (square_size)*.5;
+		cairo_rectangle (cr2, off, off, s, s);
+		cairo_fill (cr2);
+
+		pattern = cairo_pattern_create_for_surface (cairo_get_target (cr2));
+
+		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+		cairo_set_source (cr_, pattern);
+		cairo_fill (cr_);
+
+		cairo_pattern_destroy(pattern);
+		cairo_surface_destroy (pat_surface);
+		cairo_destroy (cr2);
+	}
+	else if (currentShading_==M_SH_HATCH)
+	{
+		const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+		indexHatch_ = pro->index_;
+		if(indexHatch_<1 || indexHatch_>6)
+		{
+			MagLog::warning() << "CairoDriver::renderSimplePolygon > Hatch index " <<indexHatch_<<" is wrong. No hatch sahding possible!" << endl;
+			return;
+		}
+		const int density = (int)(1./pro->density_*150);
+
+		cairo_surface_t *pat_surface;
+		cairo_pattern_t *pattern;
+		cairo_t *cr2;
+
+		pat_surface = cairo_surface_create_similar(cairo_get_group_target(cr_),CAIRO_CONTENT_COLOR_ALPHA, density, density);
+		cr2 = cairo_create (pat_surface);
+		cairo_surface_destroy (pat_surface);
+
+		cairo_set_source_rgba(cr2,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+		if(indexHatch_==1 || indexHatch_==3) // horizontal
+		{
+			cairo_move_to(cr2,       0, density*.5+.5);
+			cairo_line_to(cr2, density+.5, density*.5+.5);
+		}
+		if(indexHatch_==2 || indexHatch_==3) // vertical
+		{
+			cairo_move_to(cr2, density+.5*.5, 0);
+			cairo_line_to(cr2, density+.5*.5, density+.5);
+		}
+		if(indexHatch_==4 || indexHatch_==6) 
+		{
+			cairo_move_to(cr2,       0, 0);
+			cairo_line_to(cr2, density+.5, density+.5);
+		}
+		if(indexHatch_==5 || indexHatch_==6)
+		{
+			cairo_move_to(cr2, density+.5, 0);
+			cairo_line_to(cr2,       0, density+.5);
+		}
+                cairo_identity_matrix (cr_);
+		cairo_set_line_width (cr_,pro->thickness_*.5);
+		cairo_stroke(cr2);
+
+		pattern = cairo_pattern_create_for_surface (cairo_get_target (cr2));
+		cairo_destroy (cr2);
+
+		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+		cairo_set_source (cr_, pattern);
+		cairo_fill (cr_);
+
+		cairo_pattern_destroy(pattern);
+	}
+	else
+#else
+                if (currentShading_==M_SH_HATCH || currentShading_==M_SH_DOT)
+                    MagLog::error() << "CairoDriver: For hatch and dot shading you need at least Cairo 1.2!\n"
+                                 << "             Solid shading used instead."<<endl;
+#endif
+	{
+	    if(cairo_get_antialias(cr_) != CAIRO_ANTIALIAS_NONE && currentColour_.alpha() > 0.9999 )
+	    {
+	        cairo_fill_preserve(cr_);
+	        cairo_set_line_width(cr_, 1.);
+	        cairo_stroke(cr_);
+	    }
+	    else
+	    {
+	        cairo_fill(cr_);
+	    }
+	}
+	cairo_restore(cr_);
+	currentShading_=M_SH_SOLID;
+}
+
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderSimplePolygon(const int n, MFloat* x, MFloat* y) const
+{
+	if(n<3 || (currentColour_==Colour("none")) ) return;
+	cairo_save(cr_);
+
+	cairo_set_source_rgba(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue(), currentColour_.alpha());
+
+	MFloat xx = projectX(x[0]);
+	MFloat yy = projectY(y[0]);
+	cairo_move_to (cr_, xx, yy);
+
+	for(int l = 1; l<n; l++)
+	{
+		xx = projectX(x[l]);
+		yy = projectY(y[l]);
+		cairo_line_to (cr_, xx, yy);
+	}
+
+	cairo_close_path (cr_);
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
+	if (currentShading_==M_SH_DOT)
+	{
+		const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+		const int density = (int)sqrt(pro->density_);
+		if(density<=0) return;
+		const int s = (int)(pro->size_*convertCM(1.)*5.);
+		const MFloat square_size = convertCM(1.)/density;
+
+		cairo_surface_t *pat_surface;
+		cairo_pattern_t *pattern;
+		cairo_t *cr2;
+
+		pat_surface = cairo_surface_create_similar(cairo_get_group_target(cr_),CAIRO_CONTENT_COLOR_ALPHA, square_size, square_size);
+		cr2 = cairo_create (pat_surface);
+
+		cairo_set_source_rgba(cr2,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+		const MFloat off = (square_size)*.5;
+		cairo_rectangle (cr2, off, off, s, s);
+		cairo_fill (cr2);
+
+		pattern = cairo_pattern_create_for_surface (cairo_get_target (cr2));
+
+		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+		cairo_set_source (cr_, pattern);
+		cairo_fill (cr_);
+
+		cairo_pattern_destroy(pattern);
+		cairo_surface_destroy (pat_surface);
+		cairo_destroy (cr2);
+	}
+	else if (currentShading_==M_SH_HATCH)
+	{
+		const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+		indexHatch_ = pro->index_;
+		if(indexHatch_<1 || indexHatch_>6)
+		{
+			MagLog::warning() << "CairoDriver::renderSimplePolygon > Hatch index " <<indexHatch_<<" is wrong. No hatch sahding possible!" << endl;
+			return;
+		}
+		const int density = (int)(1./pro->density_*150);
+
+		cairo_surface_t *pat_surface;
+		cairo_pattern_t *pattern;
+		cairo_t *cr2;
+
+		pat_surface = cairo_surface_create_similar(cairo_get_group_target(cr_),CAIRO_CONTENT_COLOR_ALPHA, density, density);
+		cr2 = cairo_create (pat_surface);
+		cairo_surface_destroy (pat_surface);
+
+		cairo_set_source_rgba(cr2,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+		if(indexHatch_==1 || indexHatch_==3) // horizontal
+		{
+			cairo_move_to(cr2,       0, density*.5+.5);
+			cairo_line_to(cr2, density+.5, density*.5+.5);
+		}
+		if(indexHatch_==2 || indexHatch_==3) // vertical
+		{
+			cairo_move_to(cr2, density+.5*.5, 0);
+			cairo_line_to(cr2, density+.5*.5, density+.5);
+		}
+		if(indexHatch_==4 || indexHatch_==6) 
+		{
+			cairo_move_to(cr2,       0, 0);
+			cairo_line_to(cr2, density+.5, density+.5);
+		}
+		if(indexHatch_==5 || indexHatch_==6)
+		{
+			cairo_move_to(cr2, density+.5, 0);
+			cairo_line_to(cr2,       0, density+.5);
+		}
+                cairo_identity_matrix (cr_);
+		cairo_set_line_width (cr_,pro->thickness_*.5);
+		cairo_stroke(cr2);
+
+		pattern = cairo_pattern_create_for_surface (cairo_get_target (cr2));
+		cairo_destroy (cr2);
+
+		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+		cairo_set_source (cr_, pattern);
+		cairo_fill (cr_);
+
+		cairo_pattern_destroy(pattern);
+	}
+	else
+#else
+                if (currentShading_==M_SH_HATCH || currentShading_==M_SH_DOT)
+                    MagLog::error() << "CairoDriver: For hatch and dot shading you need at least Cairo 1.2!\n"
+                                 << "             Solid shading used instead."<<endl;
+#endif
+	{
+	    if(cairo_get_antialias(cr_) != CAIRO_ANTIALIAS_NONE && currentColour_.alpha() > 0.9999 )
+	    {
+	        cairo_fill_preserve(cr_);
+	        cairo_set_line_width(cr_, 1.);
+	        cairo_stroke(cr_);
+	    }
+	    else
+	    {
+	        cairo_fill(cr_);
+	    }
+	}
+	cairo_restore(cr_);
+	currentShading_=M_SH_SOLID;
+}
+
+/*!
+  \brief renders text strings
+
+  Cairo expects a string as a char array, where each character is expressed as
+  16 bit Unicode. Expat however delivers Multi-Byte encoding!
+  
+  \sa http://www.pygtk.org/docs/pygtk/pango-markup-language.html
+
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderText(const Text& text) const
+{
+	if(text.empty()) return;
+	const vector<NiceText>& niceT = text.getNiceText();
+	if(niceT.empty()) return;
+
+//	cairo_save(cr_);
+
+	enum Justification horizontal = text.getJustification();
+	const enum VerticalAlign vertical = text.getVerticalAlign();
+
+	vector<NiceText>::const_iterator niceText = text.textBegin();
+	vector<NiceText>::const_iterator niceTextEnd = text.textEnd();
+
+	MFloat textXoffset = 0.;
+	ostringstream alltext;
+
+	for(;niceText<niceTextEnd;niceText++)
+	{
+		MagFont magfont = (*niceText).font();
+		const std::set<string>& styles = magfont.styles();
+
+		setNewColour(magfont.colour());
+		const int r = (int)(currentColour_.red()*255.);
+		const int g = (int)(currentColour_.green()*255.);
+		const int b = (int)(currentColour_.blue()*255.);
+//		const int a = (int)(currentColour_.alpha()*255.);
+		if(r<0 || g<0 || b<0)
+		{
+			MagLog::debug() << "CAIRO: Text "<< (*niceText).text() <<" is RGB -1!"<< endl;
+		}
+		else
+		{
+		  ostringstream col;
+  		  col <<hex <<"#";
+		  if(r>15)	col <<r;
+		  else		col <<"0"<< r;
+		  if(g>15)	col <<g;
+		  else		col <<"0"<< g;
+		  if(b>15)	col <<b;
+		  else		col <<"0"<< b;
+
+		  gchar *t = g_markup_escape_text((*niceText).text().c_str(),-1);
+
+		  alltext << "<span color=\""<<col.str()<<"\" font_family=\""<<magfont.name()<<"\" size=\""<<int(magfont.size()*FONT_SCALE*1024)<<"\"";
+		  if(styles.find("bold")    != styles.end())  alltext << " weight=\"bold\"";
+		  if(styles.find("italic")  != styles.end())  alltext << " style=\"italic\"";
+		  if(text.getBlanking()) alltext << " background=\"#FFFFFF\"";
+		  if(styles.find("underlined") != styles.end()) alltext << " underline=\"single\"";
+		  if((*niceText).elevation()==SUPERSCRIPT)    alltext << "><sup";
+		  else if((*niceText).elevation()==SUBSCRIPT) alltext << "><sub";
+		  alltext << ">"<<t;
+		  g_free(t);
+
+		  if((*niceText).elevation()==SUPERSCRIPT)    alltext << "</sup>";
+		  else if((*niceText).elevation()==SUBSCRIPT) alltext << "</sub>";
+		  alltext <<"</span>";
+		}
+	}
+
+	const string alltextstring = alltext.str();
+
+	const char *glyphs = alltextstring.c_str();
+	const size_t len   = alltextstring.length();
+
+	GError* pError = 0;
+	PangoAttrList *pAttrList;
+	char * pText = 0;
+
+	pango_parse_markup(glyphs, len, 0, &pAttrList, &pText, NULL, &pError);
+	if(pError)
+	{
+	  MagLog::warning() << "CAIRO-PANGO: " <<pError->message<<"\n  for text: "<<glyphs<< endl;
+	  return;
+	}
+
+	PangoLayout *layout = pango_cairo_create_layout(cr_);
+	pango_layout_set_text (layout, pText, -1);
+	pango_layout_set_attributes(layout, pAttrList);
+
+//	PangoFontDescription *desc = pango_font_description_from_string(font_string.str().c_str());
+//	pango_layout_set_font_description (layout, desc);
+//	pango_font_description_free(desc);
+
+	//  T E X T co-ordinates
+	//  --> start always bottom left
+	//
+	unsigned int noTexts = text.size();
+	for(unsigned int nT=0;nT<noTexts;nT++)  // for all string COORDINATES
+	{
+	  cairo_save(cr_);
+	  const double xxx = projectX(text[nT].x());
+	  const double yyy = projectY(text[nT].y());
+
+	  int w, h;
+	  pango_layout_get_size (layout, &w, &h);
+	  double width  = w / PANGO_SCALE;
+	  double height = h / PANGO_SCALE;
+
+	  MFloat x = 0;
+	  if(horizontal == MCENTRE)     x = width*.5;
+	  else if(horizontal == MRIGHT) x = width;
+
+	  MFloat y = 0.;
+	  if (vertical==MBASE)        { y = height*.85;}
+	  else if (vertical==MHALF)   { y = height*.5; }
+	  else if (vertical==MBOTTOM) { y = height;    }
+
+	  cairo_move_to (cr_, xxx, yyy);
+	  const double angle = text.getAngle();
+	  if(fabs(angle) > epsilon)
+          {
+	      cairo_rotate (cr_, angle );
+	  }
+	  pango_cairo_update_layout (cr_, layout);
+	  cairo_rel_move_to(cr_, -x, -y);
+	  pango_cairo_show_layout (cr_, layout);
+	  cairo_restore(cr_);
+	}
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \todo check if this is right and correct colour in other drivers for case fill = 9!!!
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void CairoDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s) const
+{
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
+	const MFloat xx = projectX(x);
+	const MFloat yy = projectY(y);
+
+	cairo_save(cr_);
+	cairo_new_sub_path(cr_);
+
+//	cairo_identity_matrix (cr_);
+	cairo_set_line_width (cr_, currentLineWidth_);
+	cairo_set_source_rgba(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+
+	int fill = s;
+
+	if(s > 8) fill = 8;
+	if(s > 0)
+	{
+		cairo_arc (cr_, xx, yy, r, -M_PI * .5, M_PI * ((0.25 * fill)-.5) );
+		cairo_fill(cr_);
+	}
+
+	if(fill == 9)
+	{
+		cairo_set_source_rgb(cr_,1,1,1);
+		cairo_move_to (cr_, xx, yy+r-1);
+		cairo_line_to (cr_, xx, yy-r+1);
+	        cairo_stroke(cr_);
+		cairo_set_source_rgba(cr_,currentColour_.red(),currentColour_.green(),currentColour_.blue(),currentColour_.alpha());
+	}
+
+	cairo_arc (cr_, xx, yy, r, 0., M_PI * 2.);
+        cairo_stroke(cr_);
+	cairo_restore(cr_);
+#else
+        MagLog::warning() << "CairoDriver::circle requires at least cairo version 1.2!" << endl;
+#endif
+}
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \note Normally implemented in BaseDriver
+  \sa renderCellArray()
+
+  \param x0 x of lower corner
+  \param y0 y of lower corner
+  \param x1 x of higher corner
+  \param y1 y of higher corner
+  \param w width of pixmap
+  \param h height of pixmap
+  \param pixmap contents
+  \param alpha transparency
+*/
+MAGICS_NO_EXPORT bool CairoDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                  int w,int h,unsigned char* pixmap,int,bool alpha) const
+{
+	MagLog::debug()  << "CD:renderPixmap> "<<w<<"x"<<h << endl;
+	unsigned char *p = pixmap;
+	const MFloat dx =  (x1 - x0)/w;
+	const MFloat dy = -(y1 - y0)/h;   // Minus needed for Y axis correction
+
+	const MFloat X0 = x0;
+	const MFloat Y0 = y0;
+	MFloat a=0;
+
+	cairo_save(cr_);
+	cairo_antialias_t t = cairo_get_antialias(cr_);
+	cairo_set_antialias(cr_, CAIRO_ANTIALIAS_NONE);
+	
+	for(int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; x0+=dx,j++)
+		{
+			const MFloat r = *(p++);
+			const MFloat g = *(p++);
+			const MFloat b = *(p++);
+			if(alpha) a = *(p++);
+
+			if( (r*g*b) > 0)
+			{
+				if (!alpha) cairo_set_source_rgb(cr_,r,g,b);
+				else        cairo_set_source_rgba(cr_,r,g,b,a);
+
+				const MFloat x0 = X0+(j*dx);
+				const MFloat y0 = Y0+(i*dy);
+				cairo_rectangle (cr_, x0,y0,dx,-dy);
+				cairo_stroke_preserve(cr_);
+				cairo_fill (cr_);
+			}
+		}
+		x0 = X0;
+		y0 += dy;
+	}
+	cairo_restore(cr_);
+	cairo_set_antialias(cr_, t);
+	return true;
+}
+
+/*!
+  \brief Image render method for ALL drivers.
+
+  This method should be used by all Magics++ drivers to render image objects.
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderImage(const ImportObject& obj) const
+{
+	std::string file = obj.getPath();
+
+	if(!magCompare(obj.getFormat(),"png"))
+	{
+		std::string cmd = "convert "+file+"[1] ___magics_cairo_temp.png";
+		MagLog::info() <<"CairoDriver::renderImage calling convert ... with: " <<cmd << endl;
+		int status = system(cmd.c_str());
+		if(status)
+		{
+			MagLog::error() << "\nCairoDriver: Command exit not zero - NO PNG produced!\n"
+			             << " COMMAND: "<<cmd<<"\n"<< endl;
+			return;
+		}
+		file="___magics_cairo_temp.png";
+	}
+
+	cairo_surface_t *image = cairo_image_surface_create_from_png(file.c_str());
+
+	if(image)
+	{
+		cairo_save(cr_);
+		int w = cairo_image_surface_get_width(image);
+		int h = cairo_image_surface_get_height(image);
+
+		const MFloat oow = (obj.getWidth()<0)  ? 30./coordRatioX_ : obj.getWidth();
+		const MFloat ooh = (obj.getHeight()<0) ? 30./coordRatioY_ : obj.getHeight();
+		const MFloat x = projectX(obj.getOrigin().x());
+		const MFloat y = projectY(obj.getOrigin().y());
+		const MFloat oh = fabs(projectY(obj.getOrigin().y()+ooh) - y);
+		const MFloat ow = fabs(projectX(obj.getOrigin().x()+oow) - x);
+
+		const ImageProperties::OriginReference ori = obj.getOriginReference();
+		if(ori == ImageProperties::centre)
+			cairo_translate (cr_, x-(ow*.5), y-(oh*.5));
+		else
+			cairo_translate (cr_, x, y-oh);
+//		cairo_set_source_rgba (cr_, 1, 0.2, 0.2, 0.6);
+//		cairo_set_line_width (cr_, 6.0);
+//		cairo_arc (cr_, 0, 0, 10.0, 0, 2*M_PI);
+//		cairo_fill (cr_);
+		cairo_scale (cr_, ow/w, oh/h);
+		cairo_set_source_surface(cr_, image, 0, 0);
+		cairo_paint(cr_);
+
+		cairo_surface_destroy (image);
+		cairo_restore(cr_);
+		if(magCompare(file,"___magics_cairo_temp.png")) remove("___magics_cairo_temp.png");
+	}
+	else MagLog::warning() << "CairoDriver-> Could NOT read the image file "<< file << " !" << endl;
+}
+
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are
+  mainly used for satellite data.
+
+  \sa renderPixmap()
+
+  \param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool CairoDriver::renderCellArray(const Image& image) const
+{
+	MagLog::debug() << "CD:renderCellArray> "<<image.getWidth()<<"x"<<image.getHeight() << endl;
+	ColourTable &lt  = image.getColourTable();
+	const int width  = image.getNumberOfColumns();
+	const int height = image.getNumberOfRows();
+	const double tr  = image.getTransparency();
+	const MFloat x0  = projectX(image.getOrigin().x());
+	const MFloat y0  = projectY(image.getOrigin().y());
+
+	cairo_save(cr_);
+	cairo_antialias_t t = cairo_get_antialias(cr_);
+	cairo_set_antialias(cr_, CAIRO_ANTIALIAS_NONE);
+
+	const long dim=width*height;
+	unsigned char *chImage = new unsigned char[dim*4];
+	int jj = 0;
+//	const Colour none("none");
+	for(int j=0;j<dim; j++)
+	{
+		const short c = image[j];
+
+		const float cr = lt[c].red();
+		const float cg = lt[c].green();
+		const float cb = lt[c].blue();
+		
+		if(cr*cg*cb <0)
+		{
+			chImage[jj]=0; jj++;
+			chImage[jj]=0; jj++;
+			chImage[jj]=0; jj++;
+			chImage[jj]=0; jj++;
+		}
+		else
+		{
+			const double al = tr;//lt[c].alpha();
+			chImage[jj]=char(int(255.*cb *al )); jj++;
+			chImage[jj]=char(int(255.*cg *al )); jj++;
+			chImage[jj]=char(int(255.*cr *al )); jj++;
+			chImage[jj]=char(int(255.*al)); jj++;
+		}
+	}
+
+	cairo_surface_t* surImage = cairo_image_surface_create_for_data(
+		chImage,
+		CAIRO_FORMAT_ARGB32,
+		width,
+		height,
+		width * 4
+	);
+
+	cairo_translate (cr_, x0, y0);
+	const double scX = (image.getWidth() *coordRatioX_) /width;
+	const double scY = (image.getHeight()*coordRatioY_) /height;
+	cairo_scale (cr_, scX, -scY);
+
+	cairo_set_source_surface(cr_, surImage, 0, 0);
+	cairo_paint(cr_);
+
+	cairo_surface_destroy (surImage);
+
+	cairo_restore(cr_);
+	cairo_set_antialias(cr_, t);
+	return true;
+}
+
+
+/*!
+  \brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \note This can increase file and log file sizes if you run Magics++ in debug mode!
+
+  \param s string to be printed
+*/
+MAGICS_NO_EXPORT void CairoDriver::debugOutput(const string &s) const
+{
+	MagLog::debug() << s << endl;
+}
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void CairoDriver::print(ostream& out)  const
+{
+	out << "CairoDriver[";
+	out << "]";
+}
+
+//! Method to plot symbols
+/*!
+ Needs special treatment of MagLogo.
+*/
+MAGICS_NO_EXPORT void CairoDriver::renderSymbols(const Symbol& symbol) const
+{
+	debugOutput("Start CairoDriver Symbols");
+/*
+	if(symbol.getSymbol()=="logo_ecmwf")
+	{
+		const string logofile = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "ecmwf_logo.png";
+		cairo_surface_t *image = cairo_image_surface_create_from_png(logofile.c_str());
+
+		if(image)
+		{
+			cairo_save(cr_);
+			int w = cairo_image_surface_get_width(image);
+			int h = cairo_image_surface_get_height(image);
+
+			cairo_translate (cr_, projectX(symbol[0].x()), projectY(symbol[0].y()));
+			const MFloat scaling = convertCM(symbol.getHeight()*.5) / coordRatioY_;
+//			cairo_scale (cr_, 0.3, 0.3);
+			cairo_set_source_surface(cr_, image, w*scaling, h*scaling);
+			cairo_paint(cr_);
+
+			cairo_surface_destroy (image);
+			cairo_restore(cr_);
+		}
+		else MagLog::warning() << "CairoDriver-> Could NOT read the logo file "<< logofile << " !" << endl;
+	}
+//	else if(symbol.getSymbol().compare(0,7,"magics_")==0 )
+	else
+*/	{
+		BaseDriver::renderSymbols(symbol);
+	}
+}
+
+MAGICS_NO_EXPORT bool CairoDriver::convertToPixmap(const string &fname, const GraphicsFormat format, const int reso,
+		     const MFloat wx0, const MFloat wy0,const MFloat wx1,const MFloat wy1) const
+{
+	if(format==PNG)
+	{
+		cairo_save(cr_);
+		cairo_surface_t *image = cairo_image_surface_create_from_png (fname.c_str());
+		int w = cairo_image_surface_get_width (image);
+		int h = cairo_image_surface_get_height (image);
+
+		cairo_translate (cr_, wx0, wy0);
+		cairo_scale  (cr_, (wx1-wx0)/w, -(wy1-wy0)/h);
+//		cairo_translate (cr_, -0.5*w, -0.5*h);
+
+		cairo_set_source_surface (cr_, image, 0, 0);
+		cairo_paint (cr_);
+
+		cairo_surface_destroy (image);
+		cairo_restore(cr_);
+		return true;
+	}
+	else
+		return BaseDriver::convertToPixmap(fname, format, reso, wx0, wy0, wx1, wy1);
+}
+
+static SimpleObjectMaker<CairoDriver, BaseDriver> Cairo_driver("Cairo");
diff --git a/src/drivers/CairoDriver.h b/src/drivers/CairoDriver.h
new file mode 100644
index 0000000..17ae2ce
--- /dev/null
+++ b/src/drivers/CairoDriver.h
@@ -0,0 +1,159 @@
+/******************************** LICENSE ********************************
+
+
+  Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file CairoDriver.h
+    \brief Definition of CairoDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Oct 15 20:49:32 2007
+*/
+
+#ifndef _CairoDriver_H
+#define _CairoDriver_H
+
+#include <BaseDriver.h>
+#include <CairoDriverAttributes.h>
+#include <XmlNode.h>
+
+#ifdef _AIX
+#undef HAVE_STDLIB_H
+#endif
+#include <cairo.h>
+
+namespace magics
+{
+
+/*! \class CairoDriver
+    \brief This driver produces output for Cairo
+    \ingroup drivers
+
+    This driver ...
+*/
+class CairoDriver: public BaseDriver, public CairoDriverAttributes
+{
+
+public:
+	CairoDriver();
+	~CairoDriver();
+	void open();
+	void close();
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "png") ||
+		     magCompare(node.name(), "pdf") ||
+		     magCompare(node.name(), "cairo_ps") ||
+		     magCompare(node.name(), "cairo_svg") ||
+		     magCompare(node.name(), "x") ||
+		     magCompare(node.name(), "cairo_eps") )
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("cairo");
+			CairoDriverAttributes::set(basic);
+		}
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<string, string>& map)
+	{
+		BaseDriver::set(map);
+		CairoDriverAttributes::set(map);
+	}
+
+	void setPNG() const {backend_ = "PNG";}
+	void setPDF() const {backend_ = "PDF";}
+	void setPS () const {backend_ = "PS";}
+	void setEPS() const {backend_ = "EPS";}
+	void setSVG() const {backend_ = "SVG";}
+	void setX()   const {backend_ = "X";}
+	void setCairo() const {backend_ = "cairo";}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+        MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void unproject() const;
+	MAGICS_NO_EXPORT void setupNewSurface() const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const MFloat) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT void setColour(cairo_t* ct, const Colour &col) const;
+	MAGICS_NO_EXPORT int  setLineParameters(const LineStyle style, const MFloat w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+	MAGICS_NO_EXPORT void renderImage(const ImportObject& obj) const;
+	MAGICS_NO_EXPORT void renderSymbols(const Symbol& symbol) const;
+	MAGICS_NO_EXPORT bool convertToPixmap(const string &fname, const GraphicsFormat format, const int reso,
+			     const MFloat wx0, const MFloat wy0,const MFloat wx1,const MFloat wy1) const;
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	mutable string	filename_;
+
+	mutable cairo_t*	cr_;
+	mutable cairo_t*	tmp_cr_;
+	mutable cairo_surface_t* surface_;
+	mutable cairo_surface_t* tmp_surface_;
+
+	MAGICS_NO_EXPORT MFloat projectX(const MFloat x) const {return offsetX_+(x*coordRatioX_);}
+	MAGICS_NO_EXPORT MFloat projectY(const MFloat y) const {return offsetY_+(y*coordRatioY_);}
+	MAGICS_NO_EXPORT MFloat setAngleY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setSymbolY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setFlagY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setY(const MFloat y) const {return y;}
+
+	mutable MFloat offsetX_;
+	mutable MFloat offsetY_;
+	mutable stack<MFloat> offsetsX_;
+	mutable stack<MFloat> offsetsY_;
+
+	mutable string backend_;
+	mutable int dimensionXglobal_;
+	mutable int dimensionYglobal_;
+
+	//! Copy constructor - No copy allowed
+	CairoDriver(const CairoDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	CairoDriver& operator=(const CairoDriver&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CairoDriver& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/DriverManager.cc b/src/drivers/DriverManager.cc
new file mode 100644
index 0000000..8b4093e
--- /dev/null
+++ b/src/drivers/DriverManager.cc
@@ -0,0 +1,123 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/* \file DriverManager.cc
+   \brief Implementation of Drivermanager class.
+   \author Meteorological Visualisation Section, ECMWF
+
+   Started: Jan 2004
+
+*/
+
+#include <DriverManager.h>
+#include "BasicGraphicsObject.h"
+
+using namespace magics;
+
+DriverManager::DriverManager() 
+{
+}
+
+DriverManager::~DriverManager() 
+{
+}
+
+void DriverManager::print(ostream& out)  const
+{
+	out << "DriverManager";
+}
+
+void DriverManager::dispatch(BasicGraphicsObject* object) const
+{
+
+	if ( !object ) return;
+	for (const_iterator driver = begin(); driver != end(); ++driver)
+		if ( !(*(*driver)).disable() ) (*object).redisplay(*(*driver));
+}
+
+void DriverManager::dispatch(BaseDriver::ModeFunction mode, const SelectionMode& properties) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver)
+		if ( !(*(*driver)).disable() ) ((*driver)->*mode)(properties);
+}
+
+void DriverManager::dispatch(BaseDriver::ControlFunction mode, bool control) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver)
+		if ( !(*(*driver)).disable() ) ((*driver)->*mode)(control);
+}
+
+void DriverManager::dispatch(void (BaseDriver::*mode)()) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver)
+		if ( !(*(*driver)).disable() ) ((*driver)->*mode)();
+}
+
+void DriverManager::dispatch(void (MagicsEvent::*notify)(MagicsObserver&), MagicsEvent& event) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver)
+		if ( !(*(*driver)).disable() ) (event.*notify)(*(*driver));
+}
+
+void DriverManager::dispatch(BaseDriver::InputEventFunction mode, MtInputEvent* event) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver)
+		if ( !(*(*driver)).disable() ) ((*driver)->*mode)(event);
+}
+
+void DriverManager::openDrivers() const 
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver) 
+		if ( !(*(*driver)).disable() ) (*(*driver)).open();
+}
+
+void DriverManager::closeDrivers() const 
+{
+	const_iterator driver = begin();
+	for (; driver != end(); ++driver) 
+		if ( !(*(*driver)).disable() ) (*(*driver)).close();
+}
+
+/*
+void DriverManager::clearDrivers() const 
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver) 
+		if ( !(*(*driver)).disable() ) (*(*driver)).clear(); 
+}
+*/
+
+void DriverManager::setDriversWidth(double width) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver) 
+		if ( !(*(*driver)).disable() ) (*(*driver)).setXDeviceLength(width); 
+}
+
+void DriverManager::setOutputWidth(double width) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver) 
+		if ( !(*(*driver)).disable() ){
+			//double width = (*(*driver)).getWidth(); 
+			(*(*driver)).setWidth(width); 
+		}
+}
+
+void DriverManager::setDriversHeight(double height) const
+{
+	for (const_iterator driver = begin(); driver != end(); ++driver) 
+		if ( !(*(*driver)).disable() ) (*(*driver)).setYDeviceLength(height); 
+}
diff --git a/src/drivers/DriverManager.h b/src/drivers/DriverManager.h
new file mode 100644
index 0000000..ab38243
--- /dev/null
+++ b/src/drivers/DriverManager.h
@@ -0,0 +1,75 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/* \file DriverManager.h
+   \brief Definition of driver manager class.
+   \author Meteorological Visualisation Section, ECMWF
+
+   Started: Jan 2004
+   
+*/
+#ifndef DriverManager_H
+#define DriverManager_H
+
+#include <magics.h>
+#include <BaseDriver.h>
+#include <MagicsEvent.h>
+
+namespace magics {
+
+class BasicGraphicsObject;
+
+/* \class DriverManager
+   \brief Class to manage the various drivers.
+   
+*/
+class DriverManager : public vector<BaseDriver*>
+{
+public:
+	DriverManager();
+	virtual ~DriverManager();
+	void refresh();
+
+	void openDrivers() const;
+	void closeDrivers() const;
+	void clearDrivers() const;
+
+	void setDriversWidth(double) const;
+	void setDriversHeight(double) const;
+	void setOutputWidth(double) const;
+	void dispatch(BasicGraphicsObject*) const;
+	void dispatch(BaseDriver::ModeFunction, const SelectionMode&) const;
+	void dispatch(BaseDriver::ControlFunction, bool) const;
+	void dispatch(BaseDriver::InputEventFunction, MtInputEvent*) const;
+	void dispatch(void (MagicsEvent::*)(MagicsObserver&), MagicsEvent&) const;
+	void dispatch(void (BaseDriver::*)()) const;
+
+protected:
+	virtual void print(ostream&) const;
+
+private:
+// No copy allowed
+	DriverManager(const DriverManager&);
+	DriverManager& operator=(const DriverManager&);
+
+// -- Friends
+	friend ostream& operator<<(ostream& s,const DriverManager& p)
+		{ p.print(s); return s; }
+};
+} // namespace magics
+#endif
diff --git a/src/drivers/GDDriver.cc b/src/drivers/GDDriver.cc
new file mode 100644
index 0000000..298d942
--- /dev/null
+++ b/src/drivers/GDDriver.cc
@@ -0,0 +1,971 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GDDriver.cc
+    \brief Implementation of GDDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Oct 29 16:05:47 2007
+
+    Try 'gdlib-config --version --features' and to check your GD installation!
+
+    +----+2  Clipping area
+    |    |
+   1+----+
+
+   void gdImageSetClip(gdImagePtr im, int  x1,  int  y1,  int  x2,  int  y2)
+   void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)
+
+   void gdImageSetThickness(gdImagePtr im, int thickness)
+
+   Special characters:  & &#x197; (hex) Å (dec)
+
+   void gdImageAlphaBlending(gdImagePtr im, int blending)
+   void gdImageSaveAlpha(gdImagePtr im, int saveFlag)
+        saveFlag: 1:on 0:off  (PNG only) AS EARLY AS POSSIBLE!
+*/
+
+#include <GDDriver.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+#include <Symbol.h>
+
+#include <gdfontl.h>
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+*/
+GDDriver::GDDriver() : filename_("magics_output.gif"),currentFont_(""),
+                      currentFontSize_(0),currentPageCount_(0),
+                      lastPage_(-1),scaleFactor_(1),
+                      animated_(false),jpg_(false),gif_(false),png_(false),
+                      clipping_(true),offsetX_(0),offsetY_(0)
+{
+  readFonts();
+}
+
+/*!
+  \brief Destructor
+*/
+GDDriver::~GDDriver() 
+{
+  relieveFonts();
+}
+
+/*!
+  \brief Opening the driver
+
+ The last page needs closing and GIF animation
+ needs writing into its output file.
+
+ \sa close()
+*/
+void GDDriver::open()
+{
+	currentPage_ = -1;
+	//needed for multithread apps!
+#ifndef MAGICS_GIF	
+	if(gdFontCacheSetup()!=0)  MagLog::error() << "GDDriver::readFonts() --> Cannot initialize font cache!\n";
+#endif
+//	setCMscale(30.);// cm -> pixel
+
+	string mbg_tmpl = mgb_template_;
+	MFloat ratio = getYDeviceLength() / getXDeviceLength();
+	int width   = width_;
+	if(!mbg_tmpl.empty())
+	{
+		setDimensionsFromBinary(mbg_tmpl,ratio,	width);
+	}
+	setCMscale(MFloat(width)/getXDeviceLength());
+	scaleFactor_      = .8;
+	dimensionXglobal_ = width;
+	dimensionYglobal_ = static_cast<int>(ratio*width);
+}
+
+/*!
+  \brief Closing the driver
+
+ The last page needs closing and GIF animation
+ needs writing into its output file. The animation
+ is started in startPage().
+
+ \sa endPage open()
+*/
+void GDDriver::close()
+{
+	if(animated_)
+	{
+#ifndef MAGICS_GIF
+#ifndef MAGICS_GIF_ANIMATED
+		MagLog::warning() << "GIF and Animated GIF are not supported in this version (Too old version of GD library!)";
+		animated_ = false;
+		png_ = true;
+#else
+		gdImageGifAnimEnd(outFile_);
+		fclose(outFile_);
+		outFile_ = 0;
+#endif
+#endif
+	}
+	if( jpg_ ) MagLog::info() << "JEPG is not a good format for scientific plots. Please consider using GIF or PNG.\n";
+
+	currentPage_ = 0;
+	currentPageCount_ = 0;
+
+	const unsigned int isize = Images_.size();
+	for(unsigned int i=0;i<isize;i++)
+	{
+		gdImageDestroy(Images_[i]);
+	}
+}
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+
+ A new page in GD means a normally a new file.
+ An MagException are GIF animation.
+
+ In this method the binary output file is opened.
+ This includes the formation of the file name.
+ 
+ \sa endPage
+*/
+MAGICS_NO_EXPORT void GDDriver::startPage() const
+{
+	if(currentPage_==-1)
+	{
+		dimensionX_ = static_cast<float>(dimensionXglobal_-1);
+		dimensionY_ = static_cast<float>(dimensionYglobal_-1);
+		offsetY_ = dimensionY_;
+		coordRatioY_ = -1;
+	}
+
+	currentPageCount_++;
+	currentPage_++;
+	newPage_ = true;
+	
+	int cPage = currentPage_;
+
+	if(!animated_)
+	{
+		Images_.clear();
+		currentPage_ = 0;
+	}
+
+	// No TrueColor otherwise transparent background does not work
+	currentImage_ = gdImageCreateTrueColor(dimensionXglobal_,dimensionYglobal_);
+	if(png_)
+	{	
+		gdImageAlphaBlending(currentImage_, 0);
+		gdImageSaveAlpha(currentImage_, 1); // save transparency
+	}
+
+	Images_.push_back(currentImage_);
+
+#ifdef MAGICS_GIF_ANIMATED
+	if(animated_ && cPage==0)
+	{
+		string fileName = getFileName("gif",0);
+		outFile_ = fopen(fileName.c_str(),"wb");
+		printOutputName(fileName);
+
+		gdImageGifAnimBegin(currentImage_,outFile_,1/*global colormap*/,0/*infinite loop*/);
+	}
+#endif
+
+	int white = gdImageColorAllocate(currentImage_, 255, 255, 255);
+	if(white == -1) MagLog::error() << "GDDriver: Could NOT allocate background colour!\n";
+
+	gdImageFilledRectangle(currentImage_,0,0,dimensionXglobal_,dimensionYglobal_,white);
+	if(png_ && transparent_)
+	{
+		gdImageColorTransparent(currentImage_, white);
+		white = gdImageColorAllocateAlpha(currentImage_, 255, 255, 255,127);
+		gdImageFilledRectangle(currentImage_,0,0,dimensionXglobal_,dimensionYglobal_,white);
+	}
+	setNewColour(Colour(0,0,0)); // set colour to black as default
+}
+
+/*!
+  \brief ending a page
+ 
+  This method has to take care that for formats with multiple output 
+  files are closed.
+
+ A page in GD means normally a output file.
+ An MagException are GIF animation for which are
+ closed in close().
+
+ In this method the binary output file is opened.
+ This includes the formation of the file name.
+ 
+ \sa startPage() close()
+*/
+MAGICS_NO_EXPORT void GDDriver::endPage() const
+{
+#ifdef MAGICS_GIF
+#ifdef MAGICS_GIF_ANIMATED
+	if(animated_)
+	{
+		if(currentPage_==0) gdImageGifAnimAdd(currentImage_,outFile_,1,0,0,delay_,1,NULL);
+		else                gdImageGifAnimAdd(currentImage_,outFile_,1,0,0,delay_,1,Images_[currentPage_-1]);
+	}
+	else
+#endif
+#endif
+	{
+		string fileName; 
+		// write image to file in PNG or JPEG - close and destoy
+		if( gif_ )
+		{
+#ifndef MAGICS_GIF
+			MagLog::warning() << "GIF and Animated GIF are not supported in this version (Too old version of GD library!). You get a PNG instead.";
+			gif_ = false;
+			png_ = true;
+#else
+			fileName = getFileName("gif",currentPageCount_);
+			outFile_ = fopen(fileName.c_str(),"wb");
+			if(outFile_)
+			{
+				gdImageGif(currentImage_,outFile_);
+				fclose(outFile_);
+				printOutputName(fileName);
+			}
+			else
+				MagLog::error() << "GIF: cannot open file "<< fileName <<"!"<< endl;
+#endif
+		}
+
+		if( png_ )
+		{
+			fileName = getFileName("png",currentPageCount_);
+			outFile_ = fopen(fileName.c_str(),"wb");
+			if(outFile_)
+			{
+				gdImagePng(currentImage_,outFile_);
+				fclose(outFile_);
+				printOutputName(fileName);
+			}
+			else
+				MagLog::error() << "PNG: cannot open file "<< fileName <<"!"<< endl;
+		}
+
+		if( jpg_ )
+		{
+			fileName = getFileName("jpg",currentPageCount_);
+			outFile_ = fopen(fileName.c_str(),"wb");
+			if(outFile_)
+			{
+				gdImageJpeg(currentImage_,outFile_, quality_); // quality = -1 is default
+				fclose(outFile_);
+				printOutputName(fileName);
+			}
+			else
+				MagLog::error() << "JPEG: cannot open file "<< fileName <<"!"<< endl;
+		}
+		outFile_ = 0;
+	}
+
+	newPage_ = false;
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void GDDriver::project(const magics::Layout& layout) const
+{
+	if(newPage_) newPage_=false;
+
+	// push current state
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	offsetsX_.push(offsetX_);
+	offsetsY_.push(offsetY_);
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+
+	offsetX_    += layout.x()     * 0.01 * dimensionX_;
+	offsetY_    -= layout.y()     * 0.01 * dimensionY_;
+	dimensionX_ =  layout.width() * 0.01 * dimensionX_;
+	dimensionY_ =  layout.height()* 0.01 * dimensionY_;
+
+	const float sumX = layout.maxX() - layout.minX();
+	const float sumY = layout.maxY() - layout.minY();
+
+	if( sumX!=0 && sumY!=0 )
+	{
+		coordRatioX_ = dimensionX_/sumX;
+		coordRatioY_ = -dimensionY_/sumY;
+	}
+
+	offsetX_ = projectX( -layout.minX());
+	offsetY_ = projectY( -layout.minY());
+}
+
+/*!
+  \brief reproject out of the last Layout
+
+  This method will update the offset and scale to the state they were before the
+  last Layout was received.
+
+  \sa UnLayout
+*/
+MAGICS_NO_EXPORT void GDDriver::unproject() const
+{
+	dimensionY_ = dimensionStack_.top();dimensionStack_.pop();
+	dimensionX_ = dimensionStack_.top();dimensionStack_.pop();
+	offsetX_ = offsetsX_.top();offsetsX_.pop();
+	offsetY_ = offsetsY_.top();offsetsY_.pop();
+	coordRatioX_  = scalesX_.top(); scalesX_.pop();
+	coordRatioY_  = scalesY_.top(); scalesY_.pop();
+}
+
+
+/*!
+  \brief sets a new colour
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void GDDriver::setNewColour(const Colour &colour) const
+{
+	if(currentColour_ == colour) return;
+
+	currentColour_ = colour;
+
+	const int r = static_cast<int>(colour.red()*255.); 
+	const int g = static_cast<int>(colour.green()*255.);
+	const int b = static_cast<int>(colour.blue()*255.);
+	const int a = 127-static_cast<int>(colour.alpha()*127.);
+
+	currentColourIndex_ = gdImageColorResolveAlpha(currentImage_,r,g,b,a);
+	gdImageSetAntiAliased(currentImage_,currentColourIndex_);
+	currentLineStyleIndex_ = gdAntiAliased;
+}
+
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  \sa LineStyle
+
+  \param linestyle Object describing the line style
+  \param w width of the line
+
+*/
+MAGICS_NO_EXPORT int GDDriver::setLineParameters(const LineStyle linestyle, const MFloat w) const
+{
+//	int width = 1;
+//	if      (w > 3.) width=static_cast<int>(w*.25);
+//	else 
+	int width=w*.25;
+	if(width<1) width=1;
+
+	if(width==1 && linestyle==M_SOLID) return gdAntiAliased;
+
+	const int col = gdAntiAliased;
+	gdImageSetThickness(currentImage_,width);
+
+	int *style;
+	int stylelength;
+	int k=0;
+
+	switch(linestyle)
+	{
+		case M_SOLID:
+			stylelength = 2*width;
+			style = new int[stylelength];
+			for(;k<2*width;k++) style[k] = col;
+			break;
+		case M_DASH: // 6 on - 2 off
+			stylelength = 20*width;
+			style = new int[stylelength];
+			for(;k<10*width;k++) style[k] = gdTransparent;
+			for(;k<20*width;k++) style[k] = col;
+			break;
+		case M_DOT: // 1 on - 2 off
+			stylelength = 8*width;
+			style = new int[stylelength];
+			for(;k<3*width;k++) style[k] = col;
+			for(;k<8*width;k++) style[k] = gdTransparent;
+			break;
+		case M_CHAIN_DASH: // 4 on - 2 off -  1 on - 2 off
+			stylelength = 9*width;
+			style = new int[stylelength];
+			for(;k<4*width;k++) style[k] = col;
+			for(;k<6*width;k++) style[k] = gdTransparent;
+			for(;k<7*width;k++) style[k] = col;
+			for(;k<9*width;k++) style[k] = gdTransparent;
+			break;
+		case M_CHAIN_DOT: // 4 on - 2 off -  1 on - 2 off - 1 on - 2 off
+			stylelength = 12*width;
+			style = new int[stylelength];
+			for(;k<4*width;k++)  style[k] = col;
+			for(;k<6*width;k++)  style[k] = gdTransparent;
+			for(;k<7*width;k++)  style[k] = col;
+			for(;k<9*width;k++)  style[k] = gdTransparent;
+			for(;k<10*width;k++) style[k] = col;
+			for(;k<12*width;k++) style[k] = gdTransparent;
+			break;
+		default:  // SOLID
+			stylelength = 2*width;
+			style = new int[stylelength];
+			for(;k<2*width;k++) style[k] = col;
+			break;
+	}
+	gdImageSetStyle(currentImage_,style,stylelength);
+	currentLineStyleIndex_ = gdStyled;
+	if(style) delete [] style;
+
+	return gdStyledBrushed;
+}
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void GDDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+	if(n<2) return;
+
+	MFloat old_x = projectX(x[0]);
+	MFloat old_y = projectY(y[0]);
+
+	for(int l = 1; l<n; l++)
+	{
+		const MFloat xx = projectX(x[l]);
+		const MFloat yy = projectY(y[l]);
+
+		gdImageLine(currentImage_,(int)old_x,(int)old_y,(int)xx,(int)yy,currentLineStyleIndex_);
+
+		old_x = xx;
+		old_y = yy;
+	}
+	// clean up
+	setNewColour(Colour(0,0,0)); // set colour to black as default
+}
+
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void GDDriver::renderPolyline2(const int n, MFloat* x, MFloat* y) const
+{
+	if(n != 2) return;
+
+	MFloat *xx = x;
+	MFloat *yy = y;
+
+	const float ix0 = (float)*xx;
+	xx++;
+	const float iy0 = (float)*yy;
+	yy++;
+	const float dx0 = (float)*xx;
+	const float dy0 = (float)*yy;
+	gdImageLine(currentImage_,ix0,iy0,dx0,dy0,currentLineStyleIndex_);
+}
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param nn number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void GDDriver::renderSimplePolygon(const int nn, MFloat* x, MFloat* y) const
+{
+	int n = nn;
+	if ( (x[n-1] == x[0]) && (y[n-1] == y[0]) )  n--;
+
+	MFloat *xx = x;
+	MFloat *yy = y;
+
+	gdPoint *xyP = new gdPoint[n];
+	gdPoint *xy = xyP;
+
+	for(int i = 0; i<n;xy++,i++)
+	{
+		xy->x = projectX(*(xx++));
+		xy->y = projectY(*(yy++));
+	}
+
+	currentLineStyle_ = currentLineStyleIndex_;
+	gdImageFilledPolygon(currentImage_,xyP,n,currentLineStyleIndex_);
+	delete [] xyP;
+}
+
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param line polyline to be filled
+*/
+MAGICS_NO_EXPORT void GDDriver::renderSimplePolygon(const Polyline& line) const
+{
+	const unsigned int n = line.size();
+	if(n<3 || (currentColour_==Colour("none")) ) return;
+	line.getShading()->draw(*this);
+	setNewColour(line.getFillColour());
+
+	gdPoint *xy = new gdPoint[n];
+	for(unsigned int l = 0; l<n; l++)
+	{
+		const PaperPoint& pp = line.get(l);
+		xy[l].x = projectX(pp.x());
+		xy[l].y = projectY(pp.y());
+	}
+	currentLineStyle_ = currentLineStyleIndex_;
+	gdImageFilledPolygon(currentImage_,xy,n,currentLineStyleIndex_);
+	delete [] xy;
+}
+
+
+
+/*!
+  \brief renders text strings
+
+  This method renders given text strings.
+
+ GD offers two ways of plotting text: using own line fonts or using TTF fonts.
+ 
+ By default line fonts are used if MAGICS_TTF is not set (see configure & config.h).
+ 
+ \note Be careful: TTF text ploting seems to fail in multithread context (AIX Jan2006) 
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void GDDriver::renderText(const Text& text) const
+{
+#ifdef MAGICS_TTF
+	if(text.empty()) return;
+	const string MAGPLUS_HOME=getEnvVariable("MAGPLUS_HOME");
+
+	const vector<NiceText>& niceT = text.getNiceText();
+	if(niceT.empty() && (text.empty()) ) return;
+
+	const float PNGASCENT = 0.12;
+	const float PGNDESENT = 0.2;
+
+	float H = 0.;
+	float W = 0.;
+
+	const float LastAngle_ = -text.getAngle();
+	const float cs = cos(LastAngle_);
+	const float ss = sin(LastAngle_);
+
+	const enum Justification horizontal = text.getJustification();
+	const enum VerticalAlign vertical   = text.getVerticalAlign();
+
+	MFloat HA = 0.1; // MLEFT default
+	if (horizontal==MCENTRE)     HA = -0.5;
+	else if (horizontal==MRIGHT) HA = -1.;
+
+	MFloat VA = 0.;
+	if (vertical==MBASE) VA = + PGNDESENT;
+	else if (vertical==MTOP)    VA = 1. + PNGASCENT + PGNDESENT;
+	else if (vertical==MHALF)   VA = 0.5 + PGNDESENT;
+	else if (vertical==MBOTTOM) VA = -0.1;
+
+	string textString;
+
+	vector<NiceText>::const_iterator niceText = text.textBegin();
+	vector<NiceText>::const_iterator niceTextEnd = text.textEnd();
+
+	int text_length = 0;
+
+	for(;niceText<niceTextEnd;niceText++)
+	{
+		const MagFont magfont	= (*niceText).font();
+		const std::set<string>& styles = magfont.styles();
+		string style = "";
+		if(styles.find("bold") != styles.end()) style = "bold";
+		if(styles.find("italic") != styles.end()) style += "italic";
+		if(style == "") style = "normal";
+		const string lowFont = lowerCase(magfont.name()+"_"+style);
+		fontMapIter iter = FontMap_.find(lowFont);
+
+		string ttf = MAGPLUS_HOME + "/" + MAGICS_TTF_PATH;
+		if(iter!=FontMap_.end())
+			ttf += iter->second.ttf_filename;
+		else
+		{
+			ttf += FontMap_["sansserif_normal"].ttf_filename; // if not found get default
+			MagLog::warning() << "GDDriver: Font "<< lowFont << " is not registered! Default font is used."<< endl;
+		}
+
+		// test if font files exists
+		FILE* fontfile = fopen(ttf.c_str(),"r");
+		if(!fontfile)
+		{
+			const string new_font = lowerCase( "sansserif_"+style);
+			MagLog::warning() << "GDDriver (pretty): TTF font file "<< ttf <<" could not be found! Font "<< new_font<< " is used instead!"<< endl;
+			fontMapIter iter = FontMap_.find(new_font);
+
+			ttf = MAGPLUS_HOME + "/" + MAGICS_TTF_PATH;
+			if(iter!=FontMap_.end())
+				ttf += iter->second.ttf_filename;
+		}
+		else fclose(fontfile);
+
+		const float fontSize = scaleFactor_ * convertCM(magfont.size());
+
+		int bbx[8];
+		char *err = gdImageStringFT(NULL,&bbx[0],0,(char *)ttf.c_str(),fontSize,0.,10,10,(char*)(*niceText).text().c_str());
+		if(err) MagLog::error() << "GDDriver::renderText() -> Could not determine text bounding box for >"<<(*niceText).text()<<"< !\n";
+
+		text_length += (bbx[2] - bbx[0]);
+	 }
+
+	 text_length *= HA;
+	 offsetsX_.push(offsetX_);
+	 offsetX_ = offsetX_+text_length;
+
+	 int offset = 0;
+	 niceText = text.textBegin();
+	 for(;niceText<niceTextEnd;niceText++)
+	 {
+		textString = (*niceText).text();
+//		const int length =textString.length()+1;
+
+		const MagFont magfont = (*niceText).font();
+		const std::set<string>& styles = magfont.styles();
+		string style = "";
+		if(styles.find("bold") != styles.end()) style = "bold";
+		if(styles.find("italic") != styles.end()) style += "italic";
+		if(style == "") style = "normal";
+		const string lowFont = lowerCase(magfont.name()+"_"+style);
+		fontMapIter iter = FontMap_.find(lowFont);
+		const float fontSize = scaleFactor_ * convertCM(magfont.size());
+
+		string ttf = MAGPLUS_HOME + "/" + MAGICS_TTF_PATH;
+		if(iter!=FontMap_.end())
+			ttf += iter->second.ttf_filename;
+		else
+		{
+			ttf += FontMap_["sansserif_normal"].ttf_filename; // if not found get default
+			MagLog::warning() << "GDDriver: Font "<< lowFont << " is not registered! Default font is used."<< endl;
+		}
+	
+		// test if font files exists
+		if(currentFont_!=ttf)
+		{
+		  FILE* fontfile = fopen(ttf.c_str(),"r");
+		  if(!fontfile)
+		  {
+			const string new_font = lowerCase( "sansserif_"+style);
+			MagLog::warning() << "GDDriver (pretty): TTF font file "<< ttf <<" could not be found! Font "<< new_font<< " is used instead!"<< endl;
+			fontMapIter iter = FontMap_.find(new_font);
+
+			ttf = MAGPLUS_HOME + "/" + MAGICS_TTF_PATH;
+			if(iter!=FontMap_.end())
+				ttf += iter->second.ttf_filename;
+		  }
+		  else
+		  {
+	  		fclose(fontfile);
+			currentFont_=ttf;
+		  }
+		}
+
+		// get bbx to size text
+		int bbx[8];
+		char *err = gdImageStringFT(NULL,&bbx[0],0,(char *)ttf.c_str(),fontSize,0.,10,10,(char*)(*niceText).text().c_str());
+	
+		if (err)
+		{
+			MagLog::error() << "GDDriver: gdImageStringFT (prettyText) -> "<< err <<" in "<<ttf<< endl;
+			return;
+		}
+		else
+		{
+			//W = text_length;
+			W = (bbx[2] - bbx[0]);
+			H = (bbx[1] - bbx[7]);
+		}
+
+		const float E1x = 0;
+		const float E1y = H*VA;
+		const float E1xcsE1yss =  E1x*cs + E1y*ss + offset;
+		const float E1xssE1ycs = -E1x*ss + E1y*cs;
+		offset += W;
+
+//		const unsigned int tsize = (*niceText).text().size();
+		setNewColour(magfont.colour());
+
+	  unsigned int noTexts = text.size();
+	  for(unsigned int nT=0;nT<noTexts;nT++)  // for all sting COORDINATES
+	  {
+		const int x0 = static_cast<int>( E1xcsE1yss + projectX(text[nT].x()));//lower left
+		const int y0 = static_cast<int>( E1xssE1ycs + projectY(text[nT].y()));
+
+		if(text.getBlanking())
+		{
+			err = gdImageStringFT(NULL,&bbx[0],0,(char *)ttf.c_str(),fontSize,LastAngle_,x0,y0,(char *)(*niceText).text().c_str());
+			if(!err)
+			{
+				const int white = gdImageColorAllocate(currentImage_, 255, 255, 255);
+				gdPoint points[4];
+				points[0].x = bbx[0];  points[0].y = bbx[1];
+				points[1].x = bbx[2];  points[1].y = bbx[3];
+				points[2].x = bbx[4];  points[2].y = bbx[5];
+				points[3].x = bbx[6];  points[3].y = bbx[7];
+				gdImageFilledPolygon(currentImage_, points, 4, white);
+			}
+			else MagLog::error() << "GDDriver: gdImageStringFT -> "<< err <<" -> NO blanking!!!"<< endl;
+		}
+		err = gdImageStringFT(currentImage_,&bbx[0],currentColourIndex_,(char *)ttf.c_str(),fontSize,LastAngle_,x0,y0,(char *)(*niceText).text().c_str());
+		if (err)
+		{
+			MagLog::error() << "GDDriver: gdImageStringFT -> "<< err << endl;
+			gdImageString(currentImage_,gdFontGetLarge(),x0,y0,(unsigned char*)(*niceText).text().c_str(),currentColourIndex_);
+		}
+		delete [] err;
+	  }
+	}// endfor all text segments
+	offsetX_ = offsetsX_.top();offsetsX_.pop();
+#else
+	MagLog::warning() << "GDDriver: No TTF fonts support in Magics++!" << endl;
+	return;
+#endif
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void GDDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s) const
+{
+	const int rx = static_cast<int>(r*2.);
+	const int ry = static_cast<int>(r*2.);
+	const int cx = static_cast<int>(projectX(x));
+	const int cy = static_cast<int>(projectY(y));
+
+	if(s < 8)
+	{
+		gdImageArc(currentImage_,cx,cy,rx,ry,0,360,currentLineStyleIndex_);
+		if(s > 0)
+			gdImageFilledArc(currentImage_,cx,cy,rx,ry,270,270+(s*45),currentLineStyleIndex_, gdArc);
+	}
+	else gdImageFilledArc(currentImage_,cx,cy,rx,ry,0,360,currentLineStyleIndex_, gdArc);
+
+	if(s == 9)
+	{
+		const int col = gdImageColorResolveAlpha(currentImage_,255,255,255,0);
+		gdImageLine(this->currentImage_,cx,static_cast<int>(cy+r-1),cx,static_cast<int>(cy-r+1),col);
+	}
+}
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \sa renderCellArray()
+
+  \param x0 x of lower corner
+  \param y0 y of lower corner
+  \param x1 x of higher corner
+  \param y1 y of higher corner
+  \param w width of pixmap
+  \param h height of pixmap
+  \param pixmap contents
+  \param alpha says if array is transparent
+
+*/
+MAGICS_NO_EXPORT bool GDDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                                            int w,int h,unsigned char* pixmap,int, bool alpha) const
+{
+	unsigned char *p = pixmap;	
+	const float dx =  (x1 - x0)/w;
+	const float dy =  (y1 - y0)/h;
+
+	const float X0 = x0;
+	const float Y0 = y0;
+
+	for(int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; x0+=dx,j++)
+		{
+			int col = 0;
+			const int r = static_cast<int>( *(p++));
+			const int g = static_cast<int>( *(p++));
+			const int b = static_cast<int>( *(p++));
+			if(alpha)
+			{
+				const int a = *(p++);
+				col = gdImageColorResolveAlpha(this->currentImage_,r,g,b,a);
+			}
+			else
+				col = gdImageColorResolveAlpha(this->currentImage_,r,g,b,0);
+
+			const int x0 = static_cast<int>( X0+(j*dx) );
+			const int y0 = static_cast<int>( Y0+(i*dy) );
+			const int x1 = static_cast<int>( x0+dx);
+			const int y1 = static_cast<int>( y0+dy);
+
+			gdImageFilledRectangle(this->currentImage_,x0,y0,x1,y1,col);
+		}
+		x0 = X0;
+		y0 += dy;
+	}
+	return true;
+}
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are 
+  mainly used for satellite data.
+
+  \sa renderPixmap()
+
+  \param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool GDDriver::renderCellArray(const Image& image) const
+{
+	ColourTable &lt = image.getColourTable(); 
+	const int width  = image.getNumberOfColumns();
+	const int height = image.getNumberOfRows();
+	const float x0 = projectX(image.getOrigin().x());
+	const float y0 = projectY(image.getOrigin().y());
+	const float x1 = projectX(image.getOrigin().x()+image.getWidth());
+	const float y1 = projectY(image.getOrigin().y()+image.getHeight());
+	const float dx = (x1-x0)/width;
+	const float dy = -(y1-y0)/height;
+
+	for (int i=height-1;i>=0;i--)
+	{
+		for(int j=0;j<width; j++)
+		{
+		  const int in = width*i+j;	 
+		  const short c = image[in];
+ 
+ 		  if(!(lt[c]=="undefined"))
+		  {
+			const int r = static_cast<int>(lt[c].red()*255.);
+			const int g = static_cast<int>(lt[c].green()*255.);
+			const int b = static_cast<int>(lt[c].blue()*255.);
+			const int a = 127-static_cast<int>(lt[c].blue()*127.);
+
+			int kk = gdImageColorResolveAlpha(this->currentImage_,r,g,b,a);
+			const int wx = static_cast<int>( x0+(j*dx) );
+			const int wy = static_cast<int>( y0+(i*dy) );
+			gdImageFilledRectangle(this->currentImage_,wx,wy,static_cast<int>(wx+dx),static_cast<int>(wy+dy),kk);
+		  }// point has colour
+		}
+	}
+	return true;
+}
+
+
+/*!
+  \brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \note This can increase file and log file sizes if you run Magics++ in debug mode!
+
+  \param s string to be printed
+*/
+MAGICS_NO_EXPORT void GDDriver::debugOutput(const string &s) const
+{
+	MagLog::debug() << s << endl;
+}
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void GDDriver::print(ostream& out)  const
+{
+	out << "GDDriver[";
+	out << "]";
+}
+
+//! Method to plot logo
+/*!
+ MagLogo needs special treatment - much better quality when imported as GIF!
+ \sa convertToPixmap1()
+*/
+MAGICS_NO_EXPORT void GDDriver::renderMagLogo(MFloat x, MFloat y) const
+{
+	GraphicsFormat format = PNG;
+	const string logofile = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "ecmwf_logo.png";
+	convertToPixmap(logofile, format, 300, x-40, y+10, x+50, y-5);
+}
+
+//! Method to plot symbols
+/*!
+ Needs special treatment of MagLogo. Much better quality when imported as GIF!
+*/
+MAGICS_NO_EXPORT void GDDriver::renderSymbols(const Symbol& symbol) const
+{
+	debugOutput("Start GDDriver Symbols");
+	
+	if(symbol.getSymbol()=="logo_ecmwf")
+		renderMagLogo(projectX(symbol[0].x()),projectY(symbol[0].y()));
+	else 
+		BaseDriver::renderSymbols(symbol);
+}
+
+static SimpleObjectMaker<GDDriver, BaseDriver> GD_driver("GD");
diff --git a/src/drivers/GDDriver.h b/src/drivers/GDDriver.h
new file mode 100644
index 0000000..d393ba7
--- /dev/null
+++ b/src/drivers/GDDriver.h
@@ -0,0 +1,161 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file GDDriver.h
+    \brief Definition of GDDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Oct 29 16:05:47 2007
+*/
+
+#ifndef MPP_GDDriver_H
+#define MPP_GDDriver_H
+
+#include <BaseDriver.h>
+#include <GDDriverAttributes.h>
+#include <XmlNode.h>
+
+#include <gd.h>
+
+namespace magics
+{
+
+/*! \class GDDriver
+    \brief This driver produces output in various raster image formats.
+    \ingroup drivers
+
+    The raster image format driver produces output in various raster image formats
+    thanks to GD ( http://www.libgd.org ).
+*/
+class GDDriver: public BaseDriver, public GDDriverAttributes
+{
+public:
+	GDDriver();
+	~GDDriver();
+	void open();
+	void close();
+
+	void setJPG(bool b = true) const {jpg_ = b;}
+	void setGIF(bool b = true) const {gif_ = b;}
+	void setPNG(bool b = true) const {png_ = b;}
+	void setAnimation(bool b = true) const {animated_ = b; if(b) gif_ = true;}
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "gif") ||
+		     magCompare(node.name(), "gif_animation") ||
+		     magCompare(node.name(), "gd_png") ||
+		     magCompare(node.name(), "png") ||
+		     magCompare(node.name(), "jpeg") )
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("gd");
+			GDDriverAttributes::set(basic);
+		}
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<string, string>& map)
+	{
+		BaseDriver::set(map);
+		GDDriverAttributes::set(map);
+	}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void unproject() const;
+
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const MFloat w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int, bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+
+	MAGICS_NO_EXPORT MFloat setY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setAngleY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT void renderMagLogo(MFloat x, MFloat y) const;
+	MAGICS_NO_EXPORT void renderSymbols(const Symbol& symbol) const;
+	MAGICS_NO_EXPORT MFloat projectX(const MFloat x) const {return offsetX_+(x*coordRatioX_);}
+	MAGICS_NO_EXPORT MFloat projectY(const MFloat y) const {return offsetY_+(y*coordRatioY_);}
+
+	mutable ofstream	xmlFile_;
+	mutable FILE*		outFile_;
+	mutable string	filename_;
+	mutable string	currentFont_;
+	mutable int		currentFontSize_;
+	mutable int		currentColourIndex_;
+	mutable int		currentLineStyleIndex_;
+	mutable int		currentPageCount_;
+	mutable int		lastPage_;    //!< for layers 
+	mutable MFloat		scaleFactor_; //!< needed because GD uses different sizes as CM
+	mutable Layout*		currentLayout_;
+
+	mutable vector<gdImagePtr> Images_;
+	mutable gdImagePtr	currentImage_;
+	mutable gdImagePtr	Brush_;
+	mutable bool		animated_;
+	mutable bool		jpg_;
+	mutable bool		gif_;
+	mutable bool		png_;
+	mutable bool		clipping_;
+
+	mutable int dimensionXglobal_;
+	mutable int dimensionYglobal_;
+	mutable MFloat offsetX_;
+	mutable MFloat offsetY_;
+	mutable stack<MFloat> offsetsX_;
+	mutable stack<MFloat> offsetsY_;
+	mutable stack<MFloat> boxoffsetsX_;
+	mutable stack<MFloat> boxoffsetsY_;
+
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	//! Copy constructor - No copy allowed
+	GDDriver(const GDDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	GDDriver& operator=(const GDDriver&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GDDriver& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/KMLDriver.cc b/src/drivers/KMLDriver.cc
new file mode 100755
index 0000000..0486df2
--- /dev/null
+++ b/src/drivers/KMLDriver.cc
@@ -0,0 +1,1444 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ 	http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file KMLDriver.cc
+    \brief Implementation of KMLDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Thu Oct 18 18:41:52 2007
+
+*/
+
+#include <KMLDriver.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+#include <Symbol.h>
+#include <Layer.h>
+#include <Arrow.h>
+#include <Flag.h>
+
+
+//! For generating KMZ files
+extern "C"{
+#include <sys/stat.h>
+#include "minizip/zip.h"
+#define MAXFILENAME 256
+#define WRITEBUFFERSIZE 16384
+#include <cstdio>    // BUFSIZ
+#include <fcntl.h>   // open
+#include <unistd.h>
+}
+
+
+#ifdef MAGICS_RASTER
+#include <gd.h>
+#endif
+
+#ifdef MAGICS_CAIRO
+#include <cairo.h>
+#include <CairoDriver.h>
+#endif
+
+// #include <boost/filesystem.hpp>
+
+using namespace magics;
+
+bool copy_file(string from, string to)
+{
+    char buf[BUFSIZ];
+    size_t size;
+
+    int source = open(from.c_str(), O_RDONLY, 0);
+    int dest   = open(  to.c_str(), O_WRONLY | O_CREAT, 0644);
+
+    if(source >= 0 && dest >= 0)
+    {
+      while ((size = read(source, buf, BUFSIZ)) > 0)
+        write(dest, buf, size);
+      close(source);
+      close(dest);
+    }
+    else
+    {
+      MagLog::error() << "KMZ copy file> file "<< from << " could NOT be copied to "<< to << endl;
+      close(source);
+      close(dest);
+      return false;
+    }
+
+    return true;
+}
+
+/*!
+  \brief Constructor
+*/
+KMLDriver::KMLDriver() : currentTimeBegin_(""),currentTimeEnd_(""),kml_placemark_(false),
+                         polyline_begin_(true),polygon_begin_(true),MultiGeometrySet_(false),layer_(false),
+			 render_(true),ecmwf_logo_(false)
+{
+}
+
+/*!
+  \brief Destructor
+*/
+KMLDriver::~KMLDriver()
+{
+}
+
+/*!
+  \brief Opening the driver
+*/
+void KMLDriver::open()
+{
+	kmz_ = kmz_;
+	currentPage_ = 0;
+
+	fileName_ = getFileName("kml");
+	if(kmz_) fileName_ = "doc.kml";
+
+	pFile_.open(fileName_.c_str());
+	if(!pFile_)
+	{
+		MagLog::fatal() << "KMLDriver::open() --> Cannot open KML output file: " << fileName_ << "!\n";
+		terminate();
+	}
+	pFile_	<< "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
+		<< "<kml xmlns=\"http://www.opengis.net/kml/2.2\" \n"
+		<< "     xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"
+		<< "<Document>\n"<< " <name>"<<title_<<"</name>\n"
+		<< " <open>1</open>\n";
+	if(!author_.empty()) pFile_ << " <atom:author><atom:name>"<<author_<<"</atom:name></atom:author>\n";
+	if(!link_.empty())   pFile_ << " <atom:link href=\""<<link_<<"\" />\n";
+	pFile_	<< " <description>\n"
+		<< " <![CDATA["<<description_<<"]]>\n"
+		<< " </description>\n"
+		<< " <LookAt>\n"
+		<< "\t<longitude>"<<longitude_<<"</longitude>\n"
+		<< "\t<latitude>"<<latitude_<<"</latitude>\n"
+		<< "\t<range>"<<range_*1000.<<"</range>\n"
+		<< "\t<tilt>"<<tilt_<<"</tilt>\n"
+		<< "\t<heading>0</heading>\n"    // always 0 = north!
+		<< "\t<altitudeMode>absolute</altitudeMode>\n"    // possibly "relativeToGround"
+		<< " </LookAt>\n"
+		<< " <Style id=\"check-hide-children\">\n"
+		<< "  <ListStyle>\n"
+		<< "   <listItemType>checkHideChildren</listItemType>\n"
+		<< "  </ListStyle>\n"
+		<< " </Style>\n";
+	kml_placemark_=false;
+}
+
+/*!
+  \brief Closing the driver
+
+  While closing the driver all files generated (stored in kml_output_resource_list_ )
+  are put into one KMZ zip like file. We use minizip (see minizip subdirectory to
+  do so) since gnuzip is NOT sufficient!
+*/
+void KMLDriver::close()
+{
+    if (kml_placemark_) closePlacemark();
+
+    // Wind icon file
+    const string iconfile="magics_kml_icons.png";
+    const string path=getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + iconfile;
+//    boost::filesystem::path from(path);
+//    boost::filesystem::path to(iconfile);
+//    boost::filesystem::copy_file(from, to);
+    bool is_copied = copy_file(path,iconfile);
+    if(is_copied) kml_output_resource_list_.push_back(iconfile);
+
+	if(ecmwf_logo_)
+	{
+	   const string logofilename = "kml_logo.png";
+	   const string logofile = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + logofilename;
+           is_copied = copy_file(logofile,logofilename);
+           if(is_copied) kml_output_resource_list_.push_back(logofilename);
+	   
+		pFile_	<< "<ScreenOverlay id=\"logo\">\n"
+			<< "<name>MagLogo</name>\n"
+			<< "<Icon>\n"
+			<< " <href>"<<logofilename<<"</href>\n"
+			<< "</Icon>\n"
+			<< "<overlayXY x=\"0\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>\n"
+			<< "<screenXY x=\"0\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>\n"
+			<< "<size x=\"-1\" y=\"0.1\" xunits=\"fraction\" yunits=\"fraction\"/>\n"
+			<< "</ScreenOverlay>\n";
+	}
+	pFile_ << "</Document>\n</kml>\n";
+	pFile_.close();
+	kml_output_resource_list_.push_back(fileName_);
+
+	if(kmz_ && !kml_output_resource_list_.empty())
+	{
+	   fileName_ = getFileName("kmz");
+
+	   zipFile zf;
+	   int err=0;
+
+	   zf = zipOpen(fileName_.c_str(),0);
+           if (zf == 0)
+           {
+               printf("ERROR opening zip file %s\n",fileName_.c_str());
+           }
+           else
+	   {
+		int size_buf = WRITEBUFFERSIZE;
+		void* buf = (void*)malloc(size_buf);
+		if (buf==0)
+		{
+			MagLog::error() <<"Error allocating memory for KMZ generation!"<<endl;
+			return;
+		}
+		stringarray::iterator it    = kml_output_resource_list_.begin();
+		stringarray::iterator itend = kml_output_resource_list_.end();
+		for(; it != itend; it++)
+		{
+			if(debug_) MagLog::dev()<< "KMLDriver.close() > Start adding file " <<  *it << " to KMZ file.\n";
+			FILE * fin;
+			int size_read;
+
+			const char *filename = (*it).c_str();
+
+			err = zipOpenNewFileInZip(zf,filename, 0, 0, 0, 0, 0, 0, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
+
+			if(err != ZIP_OK)
+				MagLog::error() << "Could NOT open KMZ file "<< filename << endl;
+			else
+			{
+			  fin = fopen(filename,"rb");
+			  if(fin==0)
+			  {
+			     MagLog::fatal() << "Open file "<<filename<<" to be added to KMZ FAILED!"<< endl;
+			     return;
+			  }
+			  else
+			  {
+			    do{
+				err=ZIP_OK;
+				size_read = (int)fread(buf,1,size_buf,fin);
+				if (size_read < size_buf)
+				  if (feof(fin)==0)
+				  {
+					MagLog::error() << "Could NOT add "<<(*it) << endl;
+					err = ZIP_ERRNO;
+				  }
+
+				if (size_read>0)
+				{
+				  err = zipWriteInFileInZip(zf,buf,size_read);
+				  if (err<0)
+				  {
+					MagLog::error() << "Could NOT write KMZ file "<< fileName_<< endl;
+				  }
+				}
+			     } while ((err==ZIP_OK) && (size_read>0));
+			  }
+			  if (fin)
+				fclose(fin);
+			}
+
+			err = zipCloseFileInZip(zf);
+			if (err!=ZIP_OK)
+				MagLog::error() << "Could NOT close KMZ file "<< fileName_<< endl;
+//			delete [] filename;
+		}
+		free(buf);
+
+		err = zipClose(zf,0);
+		if (err != ZIP_OK)
+			MagLog::error() << "Could NOT close KMZ file "<< fileName_<< endl;
+		else if (!debug_)
+		{
+			stringarray::iterator it = kml_output_resource_list_.begin();
+			stringarray::iterator itend = kml_output_resource_list_.end();
+			for(; it != itend; it++)
+			{
+				remove((*it).c_str());
+			}
+			printOutputName("KML kmz "+fileName_);
+		}
+	   }// Zipping ---> K M Z
+	}
+	else if(!kmz_)
+	{
+		stringarray::iterator it = kml_output_resource_list_.begin();
+		stringarray::iterator itend = kml_output_resource_list_.end();
+		for(; it != itend; it++)
+		{
+			printOutputName("KML misc "+(*it));
+		}
+	}
+}
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+
+  \note There is NO page concept in KML!
+*/
+MAGICS_NO_EXPORT void KMLDriver::startPage() const
+{
+	currentPage_++;
+
+	debugOutput("Start Page");
+
+	polyline_begin_ = true;
+	polygon_begin_  = true;
+	currentLayer_   = "none";
+}
+
+/*!
+  \brief ending a page
+
+  This method has to take care that for formats with multiple output
+  files are closed.
+
+  \note There is NO page concept in KML!
+*/
+MAGICS_NO_EXPORT void KMLDriver::endPage() const
+{
+	if (kml_placemark_) closePlacemark();
+
+	layer_=false;
+	debugOutput("Close page");
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void KMLDriver::project(const magics::Layout& layout) const
+{
+//MagLog::dev() << " KMLDriver::project("<<layout.id()<<")"<< endl;
+}
+
+MAGICS_NO_EXPORT void KMLDriver::redisplay(const magics::LegendLayout& layout) const
+{
+#ifdef MAGICS_CAIRO
+    //redisplay((const Layout&) legend);
+    const string filename = "legend.png";
+    cairo_surface_t* surface_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, layout.width(), layout.height());
+    cairo_t* cr_ = cairo_create(surface_);
+//    if(magCompare(transparent_,"off"))
+    {
+       cairo_set_source_rgb (cr_, 1.0, 1.0, 1.0); /* white */
+    }
+//    else
+//    {
+//       cairo_set_source_rgba (cr_, 1.0, 1.0, 1.0, 0.0); /* transparent */
+//    }
+    cairo_paint (cr_);
+    
+//    CairoDriver cD;
+//    cD.redisplay((const Layout&) layout);
+
+    cairo_surface_write_to_png(surface_, filename.c_str());
+    kml_output_resource_list_.push_back(filename);
+    pFile_  << "<ScreenOverlay id=\"legend\">\n"
+            << "<name>Legend</name>\n"
+            << "<Icon>\n"
+            << " <href>"<<filename<<"</href>\n"
+            << "</Icon>\n"
+            << "<overlayXY x=\"0\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>\n"
+            << "<screenXY x=\"0\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>\n"
+            << "<size x=\"-1\" y=\"0.1\" xunits=\"fraction\" yunits=\"fraction\"/>\n"
+            << "</ScreenOverlay>\n";
+#else
+    MagLog::warning() << " KMLDriver> legend could NOT be generated - Cairo support needs to be enabled!"<< endl;
+#endif
+}
+
+/*!
+  \brief setup a new layer
+
+  This method will setup a new layer. Layers enable overlays of entities
+  of information.
+
+  \sa Layer
+*/
+MAGICS_NO_EXPORT void KMLDriver::redisplay(const StaticLayer& layer) const
+{
+//cout <<"KML staticlayer > "<<layer.name() <<" - "<<layer.kmlTimeBegin()<<endl;
+  if(!magCompare("coastlines",layer.name()) ||coastlines_ )
+  {
+//	if(!magCompare(currentLayer_,layer.name()))
+//	{
+		currentLayer_     = (layer.name().empty()) ? "StaticLayer" : layer.name();
+		currentTimeBegin_ = layer.kmlTimeBegin();
+		currentTimeEnd_   = layer.kmlTimeEnd();
+//cout << "layer "<<layer.name()<<" "<<layer.kmlTimeBegin()<< endl;
+		newLayer();
+		layer.visit(*this);
+		closeLayer();
+//	}
+//	else
+//		layer.visit(*this);
+  }
+}
+
+MAGICS_NO_EXPORT void KMLDriver::redisplay(const StepLayer& layer) const
+{
+//  cout <<"KML StepLayer> "<<layer.name() <<" - "<<layer.kmlTimeBegin()<<endl;
+  if(!magCompare("coastlines",layer.name()) || coastlines_ )
+  {
+//	if(!magCompare(currentLayer_,layer.name()))
+//	{
+		currentLayer_     = (layer.name().empty()) ? "Step" : layer.name();
+		currentTimeBegin_ = layer.kmlTimeBegin();
+		currentTimeEnd_   = layer.kmlTimeEnd();
+//cout << "layer "<<layer.name()<<" "<<layer.kmlTimeBegin()<< endl;
+		newLayer();
+		layer.visit(*this);
+		closeLayer();
+//	}
+//	else
+//		layer.visit(*this);
+  }
+}
+
+/*!
+   \brief gets ignored in KML
+   
+   \sa BaseDriver::redisplay(const NoDataLayer&)
+ */
+MAGICS_NO_EXPORT void KMLDriver::redisplay(const NoDataLayer& layer) const
+{
+//   cout << "KML::NoDataLayer> "<<layer.name()<< endl;
+}
+
+/*!
+  \brief open new layer
+
+*/
+MAGICS_NO_EXPORT void KMLDriver::newLayer() const
+{
+//cout << "KML::newLayer()> "<<currentLayer_<< endl;
+	if (kml_placemark_) closePlacemark();
+
+	debugOutput("Start Layer - "+currentLayer_);
+
+	pFile_ << "<Folder>\n<name>"<<currentLayer_<<"</name>\n<open>0</open>\n"
+	       << " <styleUrl>#check-hide-children</styleUrl>\n";
+
+	polyline_begin_=true;
+	polygon_begin_=true;
+	layer_=true;
+	render_=true;
+}
+
+
+/*!
+  \brief close the current layer
+
+  This method will close an existing layer. This includes resets of existing boxes.
+
+*/
+MAGICS_NO_EXPORT void KMLDriver::closeLayer() const
+{
+//  cout << "KML::closeLayer()> "<<currentLayer_<< endl;
+	if (kml_placemark_) closePlacemark();
+
+	layer_=false;
+	render_=false;
+	pFile_	<< "</Folder>\n";
+	debugOutput("Close Layer - "+currentLayer_);
+}
+
+
+MAGICS_NO_EXPORT void KMLDriver::closePlacemark() const
+{
+	if(MultiGeometrySet_)
+	{
+		pFile_ << "</MultiGeometry>\n";
+		MultiGeometrySet_=false;
+	}
+	pFile_ << "</Placemark>\n";
+	kml_placemark_=false;
+//	currentLayer_ = "non";
+
+	if(!polygon_begin_) polygon_begin_=true;
+}
+
+/*!
+  \brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the
+  current box is finished.
+
+  Expression is aabbggrr, where aa=alpha (00 to ff); bb=blue (00 to ff);
+  gg=green (00 to ff); rr=red (00 to ff)
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void KMLDriver::setNewColour(const Colour &colour) const
+{
+	currentColour_ = colour;
+}
+
+/*!
+  \brief sets a new line width
+
+  This line width stays the default width until the painting in the
+  current box is finished.
+
+  \sa setLineParameters()
+*/
+MAGICS_NO_EXPORT void KMLDriver::setNewLineWidth(const MFloat width) const
+{
+	currentLineWidth_ = (width<1) ? 1. : width;
+}
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the
+  current box is finished.
+
+  \sa LineStyle
+
+  param linestyle Object describing the line style
+  param w width of the line
+
+*/
+MAGICS_NO_EXPORT int KMLDriver::setLineParameters(const LineStyle , const MFloat w) const
+{
+	setNewLineWidth(w);
+
+//	MagLog::debug() << "KMLDriver::setLineParameters needs implementing." <<endl;
+	return 0;
+}
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void KMLDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+  if(render_ && n > 1 )
+  {
+  	if(!kml_placemark_ || polyline_begin_)
+	{
+		if (kml_placemark_) closePlacemark();
+		pFile_ << "<Placemark>\n";
+		if(layer_)
+		{
+			pFile_ << "<name>"<<currentLayer_<<"</name>\n";
+			if(!currentTimeBegin_.empty())
+			{
+//			   if(magCompare(currentTimeBegin_,currentTimeEnd_))
+//			   {
+//				pFile_	<< "<TimeStamp>\n"
+//					<< " <when>"<<currentTimeBegin_<<"</when>\n"
+// 					<< "</TimeStamp>\n"
+//					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+//			   }
+//			   else
+			   {
+				pFile_	<< "<TimeSpan>\n"
+					<< " <begin>"<<currentTimeBegin_<<"</begin>\n"
+					<< " <end>"<<currentTimeEnd_<<"</end>\n"
+ 					<< "</TimeSpan>\n";
+					//<< "<styleUrl>#hiker-icon</styleUrl>\n";
+			   }
+			}
+			pFile_	<< "<description><![CDATA["<<currentLayer_<<"]]></description>\n";
+		}
+		pFile_ << "<visibility>1</visibility>\n<open>0</open>\n";
+
+		kml_placemark_=true;
+
+		const int r = (int)currentColour_.red()*255;
+		const int g = (int)currentColour_.green()*255;
+		const int b = (int)currentColour_.blue()*255;
+		const int a = (int)(transparency_ * 2.55);
+
+		pFile_	<< "<!-- r:"<<r<<" g:"<<g<<" b:"<<b <<" -->"<< endl;
+
+		pFile_	<< "<Style>\n<LineStyle>\n"
+			<< "\t<color>" <<hex;
+			if(a>15)	pFile_ <<a;
+			else		pFile_ <<"0"<< a;
+			if(b>15)	pFile_ <<b;
+			else		pFile_ <<"0"<< b;
+			if(g>15)	pFile_ <<g;
+			else		pFile_ <<"0"<< g;
+			if(r>15)	pFile_ <<r;
+			else		pFile_ <<"0"<< r;
+		pFile_	<< "</color>\n" << dec
+			<< "\t<width>"<<currentLineWidth_<<"</width>\n"<<"</LineStyle>\n"
+			<< "</Style>\n"
+			<< "<MultiGeometry>\n";
+		MultiGeometrySet_=true;
+		polyline_begin_=false;
+	}
+
+	pFile_	<< "<LineString>\n"
+		<< " <extrude>0</extrude>\n"
+	//	<< " <altitudeMode>relativeToGround</altitudeMode>\n"
+		<< " <altitudeMode>clampToGround</altitudeMode>\n"
+		<< " <tessellate>0</tessellate>\n"
+		<< " <coordinates>\n";
+
+	for(int is=0;is<n;is++)
+	{
+		pFile_ <<"\t"<< x[is]<<","<<y[is]<<","<<height_*1000<<"\n";
+	}
+	pFile_ << " </coordinates>\n</LineString>\n";
+  }
+}
+
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void KMLDriver::renderPolyline2(const int , MFloat* , MFloat* ) const
+{
+}
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param xx array of x values
+  \param yy array of y values
+*/
+MAGICS_NO_EXPORT void KMLDriver::renderSimplePolygon(const int n, MFloat* xx, MFloat* yy) const
+{
+	if (!render_) return;
+	if (kml_placemark_) closePlacemark();
+
+	const int r = (int)(currentColour_.red()*255.);
+	const int g = (int)(currentColour_.green()*255.);
+	const int b = (int)(currentColour_.blue()*255.);
+	if (r*g*b < 0) return;
+//pFile_	<< "<!-- r:"<<r<<" g:"<<g<<" b:"<<b <<" -->"<< endl;
+	pFile_	<< "<Placemark>\n";
+//	if(layer_)
+//	{
+//		pFile_ << "<name>"<<currentLayer_<<"</name>\n"
+//		       << "<description><![CDATA["<<currentLayer_<<"]]></description>\n";
+//	}
+//	    << "<altitudeMode>clampToGround</altitudeMode>\n"
+	if(layer_)
+	{
+		pFile_ << "<name>"<<currentLayer_<<"</name>\n";
+		if(!currentTimeBegin_.empty())
+		{
+//			   if(magCompare(currentTimeBegin_,currentTimeEnd_))
+//			   {
+//				pFile_	<< "<TimeStamp>\n"
+//					<< " <when>"<<currentTimeBegin_<<"</when>\n"
+// 					<< "</TimeStamp>\n"
+//					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+//			   }
+//			   else
+		   {
+			pFile_	<< "<TimeSpan>\n"
+				<< " <begin>"<<currentTimeBegin_<<"</begin>\n"
+				<< " <end>"<<currentTimeEnd_<<"</end>\n"
+				<< "</TimeSpan>\n";
+		   }
+		}
+		pFile_	<< "<description><![CDATA["<<currentLayer_<<"]]></description>\n";
+	}
+
+	pFile_<< "<visibility>1</visibility>\n<open>0</open>\n";
+
+//	kml_placemark_=true;
+
+	const int a = (int)(transparency_ * 2.55);
+
+	pFile_	<< "<Style>\n<PolyStyle>\n"
+		<< "\t<color>" <<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a;
+		if(b>15)	pFile_ <<b;
+		else		pFile_ <<"0"<< b;
+		if(g>15)	pFile_ <<g;
+		else		pFile_ <<"0"<< g;
+		if(r>15)	pFile_ <<r;
+		else		pFile_ <<"0"<< r;
+	pFile_	<< "</color>\n" << dec
+		<< "\t<fill>1</fill>\n</PolyStyle>\n"
+		<< "<LineStyle>\n"
+		<< "\t<width>"<<2<<"</width>\n"
+		<< "\t<color>" <<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a;
+		if(b>15)	pFile_ <<b;
+		else		pFile_ <<"0"<< b;
+		if(g>15)	pFile_ <<g;
+		else		pFile_ <<"0"<< g;
+		if(r>15)	pFile_ <<r;
+		else		pFile_ <<"0"<< r;
+	pFile_	<< "</color>\n" << dec
+		<< "</LineStyle>\n"
+		<< "</Style>\n"
+		<< "<MultiGeometry>\n";
+	MultiGeometrySet_=true;
+//		polygon_begin_=false;
+
+	pFile_ << "<Polygon>\n"
+	       << " <extrude>1</extrude>\n"
+	//       << " <altitudeMode>relativeToGround</altitudeMode>\n"
+	       << " <altitudeMode>clampToGround</altitudeMode>\n"
+	       << " <tessellate>0</tessellate>\n"
+	       << "  <outerBoundaryIs>\n"
+	       << "   <LinearRing>\n"
+	       << "    <coordinates>\n";
+
+	for(int it=0;it<n;it++)
+	{
+		pFile_ <<"\t"<< xx[it] <<","<< yy[it] <<","<<height_*1000<<"\n";
+	}
+
+	pFile_ << "    </coordinates>\n"
+	       << "   </LinearRing>\n"
+	       << "  </outerBoundaryIs>\n";
+
+	pFile_ << "</Polygon>\n";
+	pFile_ << "</MultiGeometry>\n</Placemark>";
+}
+
+void KMLDriver::renderSimplePolygon(const Polyline& line) const
+{
+	const unsigned int n = line.size();
+	if(n<3) return;
+	Colour tmpcol = currentColour_;
+	setNewColour(line.getFillColour());
+
+	MFloat *x = new MFloat[n];
+	MFloat *y = new MFloat[n];
+	for(unsigned int i=0;i<n;i++)
+	{
+		const PaperPoint& pp = line.get(i);
+		x[i] = pp.x();
+		y[i] = pp.y();
+	}
+	renderSimplePolygon(line.size(),x,y);
+	delete [] x;
+	delete [] y;
+	setNewColour(tmpcol);
+}
+
+/*!
+  \brief renders text strings
+
+  This method renders given text strings.
+
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void KMLDriver::renderText(const Text& text) const
+{
+	if(text.empty()) return;
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void KMLDriver::circle(const MFloat , const MFloat , const MFloat , const int ) const
+{
+}
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \sa renderCellArray()
+
+  param x0 x of lower corner
+  param y0 y of lower corner
+  param x1 x of higher corner
+  param y1 y of higher corner
+  param w width of pixmap
+  param h height of pixmap
+  param pixmap contents
+
+*/
+MAGICS_NO_EXPORT bool KMLDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                                            int w,int h,unsigned char* pixmap,int, bool) const
+{
+  debugOutput("Start renderPixmap");
+  if(render_)
+  {
+	if (kml_placemark_) closePlacemark();
+#ifndef MAGICS_CAIRO
+#ifndef MAGICS_RASTER
+	MagLog::warning() << "Image import is not implemented for the used driver!!!" << endl; return false;
+#else
+MagLog::dev()<< "KML driver Image import uses GD -> for better results use Cairo backend."<< endl;
+	stringstream out;
+	out << 15 * kml_output_resource_list_.size();
+	const string filename = "KML_overlay_"+out.str()+"png";
+
+	pFile_	<< "<GroundOverlay>\n";
+	if(layer_)
+	{
+		if(!currentTimeBegin_.empty())
+		{
+//			   if(magCompare(currentTimeBegin_,currentTimeEnd_))
+//			   {
+//				pFile_	<< "<TimeStamp>\n"
+//					<< " <when>"<<currentTimeBegin_<<"</when>\n"
+// 					<< "</TimeStamp>\n"
+//					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+//			   }
+//			   else
+			   {
+				pFile_	<< "<TimeSpan>\n"
+					<< " <begin>"<<currentTimeBegin_<<"</begin>\n"
+					<< " <end>"<<currentTimeEnd_<<"</end>\n"
+ 					<< "</TimeSpan>\n"
+					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+			   }
+		}
+		pFile_	<< "<name><![CDATA[Layer: "<<currentLayer_<<"]]></name>\n";
+	}
+
+	const int a = (int)(transparency_ * 2.55);
+	pFile_ << "<styleUrl>#hiker-icon</styleUrl>\n"
+		<< "<color>"<<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a << dec;
+	pFile_ << "ffffff</color>\n"
+		<< "<visibility>1</visibility>\n"
+		<< "<color>"<<hex;
+			if(a>15)	pFile_ <<a;
+			else		pFile_ <<"0"<< a << dec;
+	pFile_ << "FFFFFF</color>\n"
+		<< "<Icon>\n"
+		<< "<href>"<<filename<<"</href>\n"
+//		<< "<refreshMode>onInterval</refreshMode>\n"
+//		<< "<refreshInterval>86400</refreshInterval>\n"
+//		<< "<viewBoundScale>0.75</viewBoundScale>\n"
+		<< "</Icon>\n"
+		<< "<LatLonBox>\n"
+		<< "   <north>"<<y0<<"</north>\n"
+		<< "   <south>"<<y1<<"</south>\n"
+		<< "   <east>"<<x1<<"</east>\n"
+		<< "   <west>"<<x0<<"</west>\n"
+		<< "   <rotation>0</rotation>\n"
+		<< "</LatLonBox>\n";
+
+
+	gdImagePtr im = gdImageCreateTrueColor(w,h);
+	unsigned char *p = pixmap;
+	gdImageColorAllocateAlpha(im, 255, 255, 255, 127);
+
+	for(int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; j++)
+		{
+			const int r = (int) *(p++);
+			const int g = (int) *(p++);
+			const int b = (int) *(p++);
+			if(r*g*b >= 0.)
+			{
+			  const int col = gdImageColorResolveAlpha(im,r,g,b,0);
+			  gdImageSetPixel(im, w, h, col);
+			}
+		}
+	}
+	gdImageDestroy(im);
+	gdImageAlphaBlending(im, 1);
+	gdImageSaveAlpha(im, 1); // save transparency
+
+	FILE *outFile = fopen(filename.c_str(),"wb");
+	gdImagePng(im,outFile);
+	fclose(outFile);
+	kml_output_resource_list_.push_back(filename);
+
+	pFile_	<< "</GroundOverlay>\n";
+#endif
+#else
+	stringstream out;
+	out << 15 * kml_output_resource_list_.size();
+	string filename = "KML_overlay_"+out.str()+"png";
+
+	pFile_	<< "<GroundOverlay>\n";
+	if(layer_)
+	{
+		if(!currentTimeBegin_.empty())
+		{
+//			   if(magCompare(currentTimeBegin_,currentTimeEnd_))
+//			   {
+//				pFile_	<< "<TimeStamp>\n"
+//					<< " <when>"<<currentTimeBegin_<<"</when>\n"
+// 					<< "</TimeStamp>\n"
+//					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+//			   }
+//			   else
+			   {
+				pFile_	<< "<TimeSpan>\n"
+					<< " <begin>"<<currentTimeBegin_<<"</begin>\n"
+					<< " <end>"<<currentTimeEnd_<<"</end>\n"
+ 					<< "</TimeSpan>\n"
+					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+			   }
+		}
+		pFile_	<< "<name><![CDATA[Time: "<<currentLayer_<<"]]></name>\n";
+	}
+
+	const int a = (int)(transparency_ * 2.55);
+	pFile_	<< "<styleUrl>#hiker-icon</styleUrl>\n"
+		<< "<color>"<<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a << dec;
+	pFile_ << "ffffff</color>\n"
+		<< "<visibility>1</visibility>\n"
+		<< "<color>"<<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a << dec;
+	pFile_ << "FFFFFF</color>\n"
+		<< "<Icon>\n"
+		<< "<href>"<<filename<<"</href>\n"
+//		<< "<refreshMode>onInterval</refreshMode>\n"
+//		<< "<refreshInterval>86400</refreshInterval>\n"
+//		<< "<viewBoundScale>0.75</viewBoundScale>\n"
+		<< "</Icon>\n"
+		<< "<LatLonBox>\n"
+		<< "   <north>"<<y0<<"</north>\n"
+		<< "   <south>"<<y1<<"</south>\n"
+		<< "   <east>"<<x1<<"</east>\n"
+		<< "   <west>"<<x0<<"</west>\n"
+		<< "   <rotation>0</rotation>\n"
+		<< "</LatLonBox>\n";
+
+	cairo_surface_t* surface_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,w,h);
+	cairo_t* cr_ = cairo_create(surface_);
+
+// \todo specify layer transparency
+
+	// set background to transparent
+//	cairo_save (cr_);
+	cairo_set_source_rgba (cr_, 1.0, 1.0, 1.0, 0.0);
+//	cairo_set_operator (cr_, CAIRO_OPERATOR_SOURCE);
+	cairo_paint (cr_);
+//	cairo_restore (cr_);
+
+	unsigned char *p = pixmap;
+	const MFloat dx =  (x1 - x0)/w;
+	const MFloat dy = -(y1 - y0)/h;   // Minus needed for Y axis correction
+
+	const MFloat X0 = x0;
+	const MFloat Y0 = y0;
+
+	for(int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; x0+=dx,j++)
+		{
+			const MFloat r = *(p++);
+			const MFloat g = *(p++);
+			const MFloat b = *(p++);
+
+			if( (r*g*b) >= 0.)
+			{
+				cairo_set_source_rgba(cr_,r,g,b,0.5);
+
+				const MFloat x0 = X0+(j*dx)+.5;
+				const MFloat y0 = Y0+(i*dy)+.5;
+				cairo_rectangle (cr_, x0,y0,dx,-dy);
+				cairo_stroke_preserve(cr_);
+				cairo_fill (cr_);
+			}
+		}
+		x0 = X0;
+		y0 += dy;
+	}
+	cairo_surface_write_to_png (surface_, filename.c_str());
+	cairo_destroy (cr_);
+	cairo_surface_destroy (surface_);
+	kml_output_resource_list_.push_back(filename);
+	pFile_	<< "</GroundOverlay>\n";
+#endif
+   }
+	debugOutput("End renderPixmap");
+	return true;
+}
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are
+  mainly used for satellite data.
+
+  sa renderPixmap()
+
+  param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool KMLDriver::renderCellArray(const Image& image) const
+{
+   debugOutput("Start renderCellArray");
+   if(render_)
+   {
+	if (kml_placemark_) closePlacemark();
+#ifndef MAGICS_CAIRO
+#ifndef MAGICS_RASTER
+	MagLog::warning() << "Image import is not implemented for the used driver!!!" << endl; return false;
+#else
+MagLog::dev()<< "KML driver uses GD -> for better results use Cairo backend."<< endl;
+	stringstream out;
+	out << currentPage_;
+	const string layer_name = (!currentLayer_.empty()) ? currentLayer_ : "default_page";
+	const string filename = "KML_cell_overlay_"+layer_name+"_"+out.str()+".png";
+
+	pFile_	<< "<GroundOverlay>\n";
+	if(layer_)
+	{
+		if(!currentTimeBegin_.empty())
+		{
+//			   if(magCompare(currentTimeBegin_,currentTimeEnd_))
+//			   {
+//				pFile_	<< "<TimeStamp>\n"
+//					<< " <when>"<<currentTimeBegin_<<"</when>\n"
+// 					<< "</TimeStamp>\n"
+//					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+//			   }
+//			   else
+			   {
+				pFile_	<< "<TimeSpan>\n"
+					<< " <begin>"<<currentTimeBegin_<<"</begin>\n"
+					<< " <end>"<<currentTimeEnd_<<"</end>\n"
+ 					<< "</TimeSpan>\n"
+					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+			   }
+		}
+		pFile_	<< "<name><![CDATA[Layer: "<<currentLayer_<<"]]></name>\n";
+	}
+
+	const int a = (int)(transparency_ * 2.55);
+	pFile_	<< "<color>"<<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a << dec;
+	pFile_ << "ffffff</color>\n"
+		<< "<visibility>1</visibility>\n"
+		<< "<Icon>\n"
+		<< "<href>"<<filename<<"</href>\n"
+//		<< "<refreshMode>onInterval</refreshMode>\n"
+//		<< "<refreshInterval>86400</refreshInterval>\n"
+//		<< "<viewBoundScale>0.75</viewBoundScale>\n"
+		<< "</Icon>\n"
+		<< "<LatLonBox>\n"
+		<< "   <north>"<<image.getOrigin().y()<<"</north>\n"
+		<< "   <south>"<<image.getOrigin().y()-image.getHeight()<<"</south>\n"
+		<< "   <east>"<<image.getOrigin().x()+image.getWidth()<<"</east>\n"
+		<< "   <west>"<<image.getOrigin().x()<<"</west>\n"
+		<< "   <rotation>0</rotation>\n"
+		<< "</LatLonBox>\n";
+
+	ColourTable &lt = image.getColourTable();
+	const int width = image.getNumberOfColumns();
+	const int height = image.getNumberOfRows();
+
+	gdImagePtr im = gdImageCreateTrueColor(width,height);
+	gdImageColorAllocateAlpha(im, 255, 255, 255, 127);
+
+	for (int i=height-1;i>=0;i--)
+	{
+		for(int j=0;j<width; j++)
+		{
+		  const int in = width*i+j;
+		  const short c = image[in];
+
+ 		  if(!(lt[c]=="undefined"))
+		  {
+			const int r = static_cast<int>(lt[c].red()*255.);
+			const int g = static_cast<int>(lt[c].green()*255.);
+			const int b = static_cast<int>(lt[c].blue()*255.);
+			const int a = static_cast<int>(lt[c].alpha()*127.);
+
+			if(r*g*b >= 0.)
+			{
+			  const int col = gdImageColorResolveAlpha(im,r,g,b,a);
+			  gdImageSetPixel(im, j, i, col);
+			}
+		  }// point has colour
+		}
+	}
+
+	gdImageAlphaBlending(im, 1);
+	gdImageSaveAlpha(im, 1); // save transparency
+
+	FILE *outFile = fopen(filename.c_str(),"wb");
+	gdImagePng(im,outFile);
+	fclose(outFile);
+	gdImageDestroy(im);
+	kml_output_resource_list_.push_back(filename);
+
+	pFile_	<< "</GroundOverlay>\n";
+#endif
+#else
+	stringstream out;
+	out << currentPage_;
+	const string layer_name = (!currentLayer_.empty()) ? currentLayer_ : "default_page";
+	string filename = "KML_cell_overlay_"+layer_name+"_"+out.str()+".png";
+	string::size_type loc=0;
+
+	while(loc != string::npos)
+	{
+	  loc=filename.find( ":", 0);
+          if( loc != string::npos ) filename.replace(loc, 1, "-");
+        }
+
+	pFile_	<< "<GroundOverlay>\n";
+	if(layer_)
+	{
+		if(!currentTimeBegin_.empty())
+		{
+//			   if(magCompare(currentTimeBegin_,currentTimeEnd_))
+//			   {
+//				pFile_	<< "<TimeStamp>\n"
+//					<< " <when>"<<currentTimeBegin_<<"</when>\n"
+// 					<< "</TimeStamp>\n"
+//					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+//			   }
+//			   else
+			   {
+				pFile_	<< "<TimeSpan>\n"
+					<< " <begin>"<<currentTimeBegin_<<"</begin>\n"
+					<< " <end>"<<currentTimeEnd_<<"</end>\n"
+ 					<< "</TimeSpan>\n"
+					<< "<styleUrl>#hiker-icon</styleUrl>\n";
+			   }
+		}
+		pFile_	<< "<name><![CDATA[Layer: "<<currentLayer_<<"]]></name>\n";
+	}
+
+	const int a = (int)(transparency_ * 2.55);
+	pFile_	<< "<color>"<<hex;
+		if(a>15)	pFile_ <<a;
+		else		pFile_ <<"0"<< a << dec;
+	pFile_ << "ffffff</color>\n"
+		<< "<visibility>1</visibility>\n"
+		<< "<Icon>\n"
+		<< "<href>"<<filename<<"</href>\n"
+//		<< "<refreshMode>onInterval</refreshMode>\n"
+//		<< "<refreshInterval>86400</refreshInterval>\n"
+//		<< "<viewBoundScale>0.75</viewBoundScale>\n"
+		<< "</Icon>\n"
+		<< "<LatLonBox>\n"
+		<< "   <north>"<<image.getOrigin().y()<<"</north>\n"
+		<< "   <south>"<<image.getOrigin().y()-image.getHeight()<<"</south>\n"
+		<< "   <east>"<<image.getOrigin().x()+image.getWidth()<<"</east>\n"
+		<< "   <west>"<<image.getOrigin().x()<<"</west>\n"
+		<< "   <rotation>0</rotation>\n"
+		<< "</LatLonBox>\n";
+
+	ColourTable &lt = image.getColourTable();
+	const int w = image.getNumberOfColumns();
+	const int h = image.getNumberOfRows();
+
+	cairo_surface_t* surface_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,w,h);
+	cairo_t* cr_ = cairo_create(surface_);
+
+// \todo specify layer transparency
+
+	// set background to transparent
+//	cairo_save (cr_);
+	cairo_set_source_rgba (cr_, 1.0, 1.0, 1.0, 0.0);
+//	cairo_set_operator (cr_, CAIRO_OPERATOR_SOURCE);
+	cairo_paint (cr_);
+//	cairo_restore (cr_);
+
+	const MFloat dx = 1.;
+	const MFloat dy = 1.;
+
+	for (int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; j++)
+		{
+		  const int in = w*i+j;
+		  const short c = image[in];
+
+ 		  if(!(lt[c]=="undefined"))
+		  {
+			MFloat r = lt[c].red();
+			MFloat g = lt[c].green();
+			MFloat b = lt[c].blue();
+			MFloat a = lt[c].alpha();
+
+			if( (r*g*b>1.) || (r*g*b<0.) )
+			{
+				r = 1.;
+				g = 1.;
+				b = 1.;
+				a = 0.;
+//				MagLog::info()<< "PostScriptDriver-> Cellshading colour not defined in table! Colour index: "<<c<<endl;
+//    PostScript will always 'overpaint' anything below missing data!!!!
+//
+			}
+			cairo_set_source_rgba(cr_,r,g,b,a);
+
+			const MFloat x0 = (j*dx);
+			const MFloat y0 = (i*dy);
+			cairo_rectangle (cr_, x0,y0,dx,-dy);
+			cairo_stroke_preserve(cr_);
+			cairo_fill (cr_);
+//			gdImageSetPixel(im, j, i, col);
+		  }// point has colour
+		}
+	}
+
+	cairo_surface_write_to_png (surface_, filename.c_str());
+
+	cairo_destroy (cr_);
+	cairo_surface_destroy (surface_);
+
+	kml_output_resource_list_.push_back(filename);
+	pFile_	<< "</GroundOverlay>\n";
+#endif
+   }
+   debugOutput("End renderCellArray");
+   return true;
+}
+
+
+//! Method to plot symbols
+/*!
+ Needs special treatment of MagLogo. The logo is added on close().
+
+ \sa close
+*/
+MAGICS_NO_EXPORT void KMLDriver::renderSymbols(const Symbol& symbol) const
+{
+	if(symbol.getSymbol()=="logo_ecmwf")
+		ecmwf_logo_=true;
+//	else
+//		BaseDriver::renderSymbols(symbol);
+}
+
+
+MAGICS_NO_EXPORT void KMLDriver::renderWindArrow(const Arrow &arrow) const
+{
+	const unsigned int arrPoNo = arrow.size();
+	if(arrPoNo<1) return;
+
+//	const ArrowPosition pos = arrow.getArrowPosition();
+
+    setNewColour(arrow.getColour());
+    const int r = (int)(currentColour_.red()*255.);
+    const int g = (int)(currentColour_.green()*255.);
+    const int b = (int)(currentColour_.blue()*255.);
+    const int a = (int)(transparency_ * 2.55);
+
+    Arrow::const_iterator arr = arrow.begin();
+	for(unsigned int pts=0;pts<arrPoNo;pts++)
+	{
+        pFile_  << "<Placemark>\n"
+                << "<Style>\n"
+                << "<IconStyle>\n"
+                << "<color>" <<hex;
+        if(a>15)    pFile_ <<a;
+        else        pFile_ <<"0"<< a;
+        if(b>15)    pFile_ <<b;
+        else        pFile_ <<"0"<< b;
+        if(g>15)    pFile_ <<g;
+        else        pFile_ <<"0"<< g;
+        if(r>15)    pFile_ <<r;
+        else        pFile_ <<"0"<< r;
+        pFile_  << "</color>\n" << dec
+                << "<heading>"<<90.+(arr->angle()*-57.29578)<<"</heading>\n"
+                << "<scale>"<<arr->norm()*0.2<<"</scale>\n"
+                << "<Icon>\n"
+                << "<href>magics_kml_icons.png</href>\n"
+                << "<x>0</x>\n"
+                << "<y>576</y>\n"
+                << "<w>64</w>\n"
+                << "<h>64</h>\n"
+                << "</Icon>\n"
+                << "</IconStyle>\n"
+                << "</Style>\n"
+                << "<Point>\n"
+                << "<coordinates>"<<arr->point_.x()<<","<<arr->point_.y()<<",0</coordinates>\n"
+                << "</Point>\n"
+                << "</Placemark>" << endl;
+	  ++arr;
+	}
+}
+
+
+MAGICS_NO_EXPORT void KMLDriver::renderWindFlag(const Flag &flag) const
+{
+/*
+ *	const MFloat thickness = (flag.getThickness()==1) ? 1 : 2.*flag.getThickness();
+	const LineStyle style = flag.getStyle();
+	const MFloat length = convertCM(flag.getLength() / coordRatioX_ );
+	const string marker = flag.getOriginMarker();
+	const MFloat markerHeight = convertCM(flag.getOriginHeight() *.5 / coordRatioX_);
+*/
+	setNewColour(flag.getColour());
+//	const unsigned int flaPoNo = flag.size();
+//	Flag::const_iterator fla = flag.begin();
+
+/*	Symbol origin;
+	if(markerHeight>0.)
+	{
+		origin.setSymbol(marker);
+		origin.setHeight(flag.getOriginHeight());
+		origin.setColour(flag.getColour());
+	}
+*/
+/*	for(unsigned int pts=0;pts<flaPoNo;pts++)
+	{
+		vector<PaperPoint> line;
+		const MFloat angle = setAngleY(fla->angle());
+		line.push_back(PaperPoint(-markerHeight,0.) );
+		line.push_back(PaperPoint(-length,0.) );
+		const MFloat ratio = (coordRatioY_==0) ? 1. : coordRatioX_/coordRatioY_;
+		for_each(line.begin(),line.end(),rotate(angle,ratio) );
+		for_each(line.begin(),line.end(),translate(fla->point_) );
+		MFloat len = fla->norm();
+
+		MFloat lev1 = 1.25;  // 2.5
+		MFloat lev2 = 3.75;  // 5.
+		MFloat lev3 = 23.;  // 25.
+		MFloat slev1 = 2.5;
+		MFloat slev2 = 5.;
+		MFloat slev3 = 25.;
+		
+		if(flag.getConvention()==KNOTS)
+		{
+			len *= 1.94384466;
+			lev1 = 3.;
+			lev2 = 7.;
+			lev3 = 47.;
+			slev1 = 5.;
+			slev2 = 10.;
+			slev3 = 50.;
+		}
+
+		if(markerHeight>0.) origin.push_back(PaperPoint(fla->point_) );
+
+		const int old_currentColourIndex = currentLineStyle_;
+		currentLineStyle_ = setLineParameters(style,thickness);
+		renderPolyline2(line);
+		currentLineStyle_ = old_currentColourIndex;
+		
+		MFloat tmp = 0.;
+		int i = 0;
+		const MFloat lengthY = setY(length * ratio);
+		const MFloat multi =  setFlagY((flag.getHemisphere()==NORTH) ? (0.2*lengthY) : (-0.2*lengthY));
+		bool fl=false;
+
+		if(len<lev2) i++;
+		while(len>(lev1))
+		{
+			if(len > lev3)      {tmp=1.0; len-= slev3;fl=true;}
+			else if(len >= lev2) {tmp=1.0; len-= slev2;fl=false;}
+			else                 {tmp=0.5; len-= slev1;fl=false;}
+
+			const MFloat dx   = sin(RAD(30.)) * tmp * 0.2 * length; // angle of flags
+			const MFloat step = i * (0.1*length);
+
+			if(!fl)
+			{
+				line.clear();
+				line.push_back(PaperPoint( -(length-step),0.) );
+				line.push_back(PaperPoint( -(length-step+dx),multi*tmp) );
+
+				for_each(line.begin(),line.end(),rotate(angle,ratio) );
+				for_each(line.begin(),line.end(),translate(fla->point_) );
+				renderPolyline2(line);
+			}
+			else
+			{
+				line.clear();
+				line.push_back(PaperPoint( -(length-step)   ,0.) );
+				line.push_back(PaperPoint( -(length-step),multi*tmp) );
+				line.push_back(PaperPoint( -(length-step-(0.1*length)),0.) );
+				for_each(line.begin(),line.end(),rotate(angle,ratio) );
+				for_each(line.begin(),line.end(),translate(fla->point_) );
+				renderSimplePolygon(line);
+				fl=false;
+				i++;
+			}
+			i++;
+		}// end while
+		++fla;
+	}// end for
+	//if(markerHeight>0.) renderSymbols(origin);
+*/}
+
+
+/*!
+  \brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \note This can increase file and log file sizes if you run Magics++ in debug mode!
+
+  \param s string to be printed
+*/
+MAGICS_NO_EXPORT void KMLDriver::debugOutput(const string &s) const
+{
+	if(debug_) pFile_ << "<!-- "<<s<<" -->\n";
+}
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void KMLDriver::print(ostream& out)  const
+{
+	out << "KMLDriver[";
+	out << "]";
+}
+
+static SimpleObjectMaker<KMLDriver, BaseDriver> KML_driver("KML");
diff --git a/src/drivers/KMLDriver.h b/src/drivers/KMLDriver.h
new file mode 100755
index 0000000..22a0012
--- /dev/null
+++ b/src/drivers/KMLDriver.h
@@ -0,0 +1,140 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file KMLDriver.h
+    \brief Definition of KMLDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Thu Oct 18 18:41:52 2007
+*/
+
+#ifndef _KMLDriver_H
+#define _KMLDriver_H
+
+#include <BaseDriver.h>
+#include <KMLDriverAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \class KMLDriver
+    \brief This driver produces output for KML
+    \ingroup drivers
+
+    The driver produces Keyhole XML (KML) output for usage with 
+    Google Earth (http://earth.google.com/) and Google Maps (http://maps.google.com/).
+*/
+class KMLDriver: public BaseDriver, public KMLDriverAttributes
+{
+
+public:
+	KMLDriver();
+	~KMLDriver();
+	void open();
+	void close();
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		if ( magCompare(node.name(),"kml"))
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("kml");
+			KMLDriverAttributes::set(basic);
+		}
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<string, string>& map)
+	{
+		BaseDriver::set(map);
+		KMLDriverAttributes::set(map);
+	}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void redisplay(const StaticLayer&) const;
+	MAGICS_NO_EXPORT void redisplay(const NoDataLayer&) const;
+	MAGICS_NO_EXPORT void redisplay(const StepLayer&) const;
+	MAGICS_NO_EXPORT void newLayer() const;
+	MAGICS_NO_EXPORT void closeLayer() const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const MFloat) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const MFloat w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int, bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+	MAGICS_NO_EXPORT void renderSymbols(const Symbol& symbol) const;
+	MAGICS_NO_EXPORT void renderWindArrow(const Arrow &arrow) const;
+	MAGICS_NO_EXPORT void renderWindFlag(const Flag &flag) const;
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	MAGICS_NO_EXPORT void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	/* K M L specific */
+    MAGICS_NO_EXPORT void redisplay(const LegendLayout& legend) const;
+	MAGICS_NO_EXPORT void closePlacemark() const;
+	mutable ofstream	pFile_;    //!< Output stream to file.
+	mutable Layout*		layout_;
+	mutable string		currentLayerPath_;
+	mutable string		currentTimeBegin_;
+	mutable string		currentTimeEnd_;
+	mutable bool		doKmz_;
+	mutable bool		kml_placemark_;
+	mutable bool		polyline_begin_;
+	mutable bool		polygon_begin_;
+	mutable bool		MultiGeometrySet_;
+	mutable bool		layer_;
+	mutable bool		render_;
+	mutable bool		ecmwf_logo_;
+
+	mutable stringarray kml_output_resource_list_;
+
+	//! Copy constructor - No copy allowed
+	KMLDriver(const KMLDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	KMLDriver& operator=(const KMLDriver&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const KMLDriver& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/Makefile.am b/src/drivers/Makefile.am
new file mode 100644
index 0000000..e2ef32a
--- /dev/null
+++ b/src/drivers/Makefile.am
@@ -0,0 +1,107 @@
+if MAGICS_QT
+include ../../m4/autotroll.mk
+endif
+
+noinst_LTLIBRARIES	= libdrivers.la
+
+MINIZIP_la_S		= minizip/ioapi.c minizip/zip.c
+MINIZIP_inc_H		= minizip/ioapi.h minizip/zip.h minizip/crypt.h
+
+
+if MAGICS_QT
+QT_inc_H	= QtDriver.h \
+		  MgQ/MgQ.h \
+                  MgQ/MgQLayoutItem.h MgQ/MgQStepItem.h \
+		  MgQ/MgQLayerItem.h MgQ/MgQPlotScene.h \
+	          MgQ/MgQSymbol.h MgQ/MgQPixmapItem.h MgQ/MgQPathItem.h \
+		  MgQ/MgQTextItem.h MgQ/MgQDriverObject.h \
+		  MgQ/MgQPolylineSetItem.h MgQ/MgQScene.h MgQ/MgQSceneItem.h \
+		  MgQ/MgQSceneCacheItem.h MgQ/MgQStepMetaData.h \
+		  MgQ/MgQPattern.h MgQ/MgQHistoItem.h MgQ/MgQRootItem.h
+QT_la_S		= QtDriver.cc \
+		  MgQ/MgQLayoutItem.cc MgQ/MgQStepItem.cc \
+		  MgQ/MgQLayerItem.cc MgQ/MgQPlotScene.cc \
+		  MgQ/MgQSymbol.cc MgQ/MgQPixmapItem.cc MgQ/MgQPathItem.cc \
+		  MgQ/MgQTextItem.cc \
+		  MgQ/MgQPolylineSetItem.cc MgQ/MgQScene.cc MgQ/MgQSceneItem.cc \
+		  MgQ/MgQSceneCacheItem.cc MgQ/MgQStepMetaData.cc \
+                  MgQ/MgQPattern.cc MgQ/MgQHistoItem.cc
+QT_la_SA	= QtDriverAttributes.cc
+QT_la_HA	= QtDriverAttributes.h
+QT_la_built     = MgQ/MgQPlotScene.moc.cpp
+endif
+
+if MAGICS_CAIRO
+CAIRO_inc_H	= CairoDriver.h
+# CairoDriverRaster.cc
+CAIRO_la_S	= CairoDriver.cc 
+CAIRO_la_SA	= CairoDriverAttributes.cc
+CAIRO_la_HA	= CairoDriverAttributes.h
+endif
+
+#if MAGICS_MING
+#MING_inc_H	= MingDriver.h
+#MING_la_S	= MingDriver.cc
+#MING_la_SA	= MingDriverAttributes.cc
+#MING_la_HA	= MingDriverAttributes.h
+#endif
+
+KML_inc_H	= KMLDriver.h
+KML_la_S	= KMLDriver.cc
+KML_la_SA	= KMLDriverAttributes.cc
+KML_la_HA	= KMLDriverAttributes.h
+
+SVG_inc_H	= SVGDriver.h
+SVG_la_S	= SVGDriver.cc
+SVG_la_SA	= SVGDriverAttributes.cc
+SVG_la_HA	= SVGDriverAttributes.h
+
+if MAGICS_RASTER
+RASTER_inc_H	= GDDriver.h 
+RASTER_la_S	= GDDriver.cc
+RASTER_la_SA	= GDDriverAttributes.cc
+RASTER_la_HA	= GDDriverAttributes.h
+endif
+
+include_H  = BaseDriver.h BinaryDriver.h PostScriptDriver.h $(MINIZIP_inc_H) $(SVG_inc_H) $(RASTER_inc_H) $(QT_inc_H) $(CAIRO_inc_H) $(KML_inc_H) DriverManager.h
+nodist_include_H  = BaseDriverAttributes.h BinaryDriverAttributes.h PostScriptDriverAttributes.h $(SVG_la_HA) $(RASTER_la_HA) $(QT_la_HA) $(CAIRO_la_HA) $(KML_la_HA)
+noinst_H	= System.h BaseDriverImages.h BaseDriverWind.h BaseDriverSymbols.h BaseDriverBinaryReader.cc
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+nodist_include_HEADERS = $(nodist_include_H)
+noinst_HEADERS	= $(noinst_H)
+else
+include_HEADERS = 
+nodist_noinst_HEADERS  = $(nodist_include_H)
+noinst_HEADERS	= $(noinst_H) $(include_H)
+endif
+
+nodist_libdrivers_la_SOURCES	= BaseDriverAttributes.cc BinaryDriverAttributes.cc PostScriptDriverAttributes.cc $(MING_la_SA) $(SVG_la_SA) $(RASTER_la_SA) $(CAIRO_la_SA) $(KML_la_SA)
+libdrivers_la_SOURCES	= BaseDriver.cc DriverManager.cc BinaryDriver.cc PostScriptDriver.cc $(MINIZIP_la_S) $(MING_la_S) $(SVG_la_S) $(RASTER_la_S) $(CAIRO_la_S) $(KML_la_S)
+
+libdrivers_la_LDFLAGS	= -no-undefined -no-install
+
+lib_LTLIBRARIES =
+
+#
+# -DNO_ADDFILEINEXISTINGZIP is needed for minizip to waor to generate KMZ
+#
+AM_CPPFLAGS	= -DNO_ADDFILEINEXISTINGZIP -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/visualisers 
+
+
+if MAGICS_QT
+LIBRARY_CURRENT			= @LIBRARY_CURRENT@
+LIBRARY_REVISION		= @LIBRARY_REVISION@
+LIBRARY_AGE			= @LIBRARY_AGE@
+lib_LTLIBRARIES			+= libMagPlusQt.la
+nodist_libMagPlusQt_la_SOURCES  = $(QT_la_SA) $(QT_la_built)
+libMagPlusQt_la_LDFLAGS		= $(QT_LIBS) -version-info $(MAGICS_LIBRARY_CURRENT):$(MAGICS_LIBRARY_REVISION):$(MAGICS_LIBRARY_AGE)
+libMagPlusQt_la_SOURCES		= $(QT_la_S)
+AM_CPPFLAGS 			+= -I$(METVIEW_HOME)/src/libUtil -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+endif
+
+BUILT_SOURCES	= $(QT_la_built)
+CLEANFILES = $(QT_la_built)
+
+AM_CXXFLAGS	= $(MAGICS_VISIBILITY) # -Weffc++
diff --git a/src/drivers/Makefile.in b/src/drivers/Makefile.in
new file mode 100644
index 0000000..1bc80c0
--- /dev/null
+++ b/src/drivers/Makefile.in
@@ -0,0 +1,1185 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+# Makerules.
+# This file is part of AutoTroll.
+# Copyright (C) 2006, 2007, 2009, 2010  Benoit Sigoure.
+#
+# AutoTroll is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+#
+# In addition, as a special exception, the copyright holders of AutoTroll
+# give you unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the macros of
+# AutoTroll.  You need not follow the terms of the GNU General Public License
+# when using or distributing such scripts, even though portions of the text of
+# AutoTroll appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes AutoTroll.
+#
+# This special exception to the GPL applies to versions of AutoTroll
+# released by the copyright holders of AutoTroll.  Note that people who make
+# modified versions of AutoTroll are not obligated to grant this special
+# exception for their modified versions; it is their choice whether to do so.
+# The GNU General Public License gives permission to release a modified version
+# without this exception; this exception also makes it possible to release a
+# modified version which carries forward this exception.
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/../../m4/autotroll.mk $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ at MAGICS_QT_TRUE@am__append_1 = libMagPlusQt.la
+ at MAGICS_QT_TRUE@am__append_2 = -I$(METVIEW_HOME)/src/libUtil -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+subdir = src/drivers
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" \
+	"$(DESTDIR)$(includedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
+libMagPlusQt_la_LIBADD =
+am__libMagPlusQt_la_SOURCES_DIST = QtDriver.cc MgQ/MgQLayoutItem.cc \
+	MgQ/MgQStepItem.cc MgQ/MgQLayerItem.cc MgQ/MgQPlotScene.cc \
+	MgQ/MgQSymbol.cc MgQ/MgQPixmapItem.cc MgQ/MgQPathItem.cc \
+	MgQ/MgQTextItem.cc MgQ/MgQPolylineSetItem.cc MgQ/MgQScene.cc \
+	MgQ/MgQSceneItem.cc MgQ/MgQSceneCacheItem.cc \
+	MgQ/MgQStepMetaData.cc MgQ/MgQPattern.cc MgQ/MgQHistoItem.cc
+ at MAGICS_QT_TRUE@am__objects_1 = QtDriver.lo MgQLayoutItem.lo \
+ at MAGICS_QT_TRUE@	MgQStepItem.lo MgQLayerItem.lo MgQPlotScene.lo \
+ at MAGICS_QT_TRUE@	MgQSymbol.lo MgQPixmapItem.lo MgQPathItem.lo \
+ at MAGICS_QT_TRUE@	MgQTextItem.lo MgQPolylineSetItem.lo \
+ at MAGICS_QT_TRUE@	MgQScene.lo MgQSceneItem.lo \
+ at MAGICS_QT_TRUE@	MgQSceneCacheItem.lo MgQStepMetaData.lo \
+ at MAGICS_QT_TRUE@	MgQPattern.lo MgQHistoItem.lo
+ at MAGICS_QT_TRUE@am_libMagPlusQt_la_OBJECTS = $(am__objects_1)
+ at MAGICS_QT_TRUE@am__objects_2 = QtDriverAttributes.lo
+ at MAGICS_QT_TRUE@am__objects_3 = MgQPlotScene.moc.lo
+ at MAGICS_QT_TRUE@nodist_libMagPlusQt_la_OBJECTS = $(am__objects_2) \
+ at MAGICS_QT_TRUE@	$(am__objects_3)
+libMagPlusQt_la_OBJECTS = $(am_libMagPlusQt_la_OBJECTS) \
+	$(nodist_libMagPlusQt_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libMagPlusQt_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libMagPlusQt_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+ at MAGICS_QT_TRUE@am_libMagPlusQt_la_rpath = -rpath $(libdir)
+libdrivers_la_LIBADD =
+am__libdrivers_la_SOURCES_DIST = BaseDriver.cc DriverManager.cc \
+	BinaryDriver.cc PostScriptDriver.cc minizip/ioapi.c \
+	minizip/zip.c SVGDriver.cc GDDriver.cc CairoDriver.cc \
+	KMLDriver.cc
+am__objects_4 = ioapi.lo zip.lo
+am__objects_5 = SVGDriver.lo
+ at MAGICS_RASTER_TRUE@am__objects_6 = GDDriver.lo
+ at MAGICS_CAIRO_TRUE@am__objects_7 = CairoDriver.lo
+am__objects_8 = KMLDriver.lo
+am_libdrivers_la_OBJECTS = BaseDriver.lo DriverManager.lo \
+	BinaryDriver.lo PostScriptDriver.lo $(am__objects_4) \
+	$(am__objects_5) $(am__objects_6) $(am__objects_7) \
+	$(am__objects_8)
+am__objects_9 = SVGDriverAttributes.lo
+ at MAGICS_RASTER_TRUE@am__objects_10 = GDDriverAttributes.lo
+ at MAGICS_CAIRO_TRUE@am__objects_11 = CairoDriverAttributes.lo
+am__objects_12 = KMLDriverAttributes.lo
+nodist_libdrivers_la_OBJECTS = BaseDriverAttributes.lo \
+	BinaryDriverAttributes.lo PostScriptDriverAttributes.lo \
+	$(am__objects_9) $(am__objects_10) $(am__objects_11) \
+	$(am__objects_12)
+libdrivers_la_OBJECTS = $(am_libdrivers_la_OBJECTS) \
+	$(nodist_libdrivers_la_OBJECTS)
+libdrivers_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libdrivers_la_LDFLAGS) $(LDFLAGS) \
+	-o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libMagPlusQt_la_SOURCES) $(nodist_libMagPlusQt_la_SOURCES) \
+	$(libdrivers_la_SOURCES) $(nodist_libdrivers_la_SOURCES)
+DIST_SOURCES = $(am__libMagPlusQt_la_SOURCES_DIST) \
+	$(am__libdrivers_la_SOURCES_DIST)
+am__include_HEADERS_DIST = BaseDriver.h BinaryDriver.h \
+	PostScriptDriver.h minizip/ioapi.h minizip/zip.h \
+	minizip/crypt.h SVGDriver.h GDDriver.h QtDriver.h MgQ/MgQ.h \
+	MgQ/MgQLayoutItem.h MgQ/MgQStepItem.h MgQ/MgQLayerItem.h \
+	MgQ/MgQPlotScene.h MgQ/MgQSymbol.h MgQ/MgQPixmapItem.h \
+	MgQ/MgQPathItem.h MgQ/MgQTextItem.h MgQ/MgQDriverObject.h \
+	MgQ/MgQPolylineSetItem.h MgQ/MgQScene.h MgQ/MgQSceneItem.h \
+	MgQ/MgQSceneCacheItem.h MgQ/MgQStepMetaData.h MgQ/MgQPattern.h \
+	MgQ/MgQHistoItem.h MgQ/MgQRootItem.h CairoDriver.h KMLDriver.h \
+	DriverManager.h
+am__noinst_HEADERS_DIST = System.h BaseDriverImages.h BaseDriverWind.h \
+	BaseDriverSymbols.h BaseDriverBinaryReader.cc BaseDriver.h \
+	BinaryDriver.h PostScriptDriver.h minizip/ioapi.h \
+	minizip/zip.h minizip/crypt.h SVGDriver.h GDDriver.h \
+	QtDriver.h MgQ/MgQ.h MgQ/MgQLayoutItem.h MgQ/MgQStepItem.h \
+	MgQ/MgQLayerItem.h MgQ/MgQPlotScene.h MgQ/MgQSymbol.h \
+	MgQ/MgQPixmapItem.h MgQ/MgQPathItem.h MgQ/MgQTextItem.h \
+	MgQ/MgQDriverObject.h MgQ/MgQPolylineSetItem.h MgQ/MgQScene.h \
+	MgQ/MgQSceneItem.h MgQ/MgQSceneCacheItem.h \
+	MgQ/MgQStepMetaData.h MgQ/MgQPattern.h MgQ/MgQHistoItem.h \
+	MgQ/MgQRootItem.h CairoDriver.h KMLDriver.h DriverManager.h
+HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) \
+	$(nodist_noinst_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+# See autotroll.m4 :)
+ at MAGICS_QT_TRUE@SUFFIXES = .moc.cpp .moc.cc .moc.cxx .moc.C .h .hh .hpp \
+ at MAGICS_QT_TRUE@			.ui .ui.h .ui.hh .ui.hpp \
+ at MAGICS_QT_TRUE@			.qrc .qrc.cpp .qrc.cc .qrc.cxx .qrc.C
+
+ at MAGICS_QT_TRUE@DISTCLEANFILES = $(BUILT_SOURCES)
+noinst_LTLIBRARIES = libdrivers.la
+MINIZIP_la_S = minizip/ioapi.c minizip/zip.c
+MINIZIP_inc_H = minizip/ioapi.h minizip/zip.h minizip/crypt.h
+ at MAGICS_QT_TRUE@QT_inc_H = QtDriver.h \
+ at MAGICS_QT_TRUE@		  MgQ/MgQ.h \
+ at MAGICS_QT_TRUE@                  MgQ/MgQLayoutItem.h MgQ/MgQStepItem.h \
+ at MAGICS_QT_TRUE@		  MgQ/MgQLayerItem.h MgQ/MgQPlotScene.h \
+ at MAGICS_QT_TRUE@	          MgQ/MgQSymbol.h MgQ/MgQPixmapItem.h MgQ/MgQPathItem.h \
+ at MAGICS_QT_TRUE@		  MgQ/MgQTextItem.h MgQ/MgQDriverObject.h \
+ at MAGICS_QT_TRUE@		  MgQ/MgQPolylineSetItem.h MgQ/MgQScene.h MgQ/MgQSceneItem.h \
+ at MAGICS_QT_TRUE@		  MgQ/MgQSceneCacheItem.h MgQ/MgQStepMetaData.h \
+ at MAGICS_QT_TRUE@		  MgQ/MgQPattern.h MgQ/MgQHistoItem.h MgQ/MgQRootItem.h
+
+ at MAGICS_QT_TRUE@QT_la_S = QtDriver.cc \
+ at MAGICS_QT_TRUE@		  MgQ/MgQLayoutItem.cc MgQ/MgQStepItem.cc \
+ at MAGICS_QT_TRUE@		  MgQ/MgQLayerItem.cc MgQ/MgQPlotScene.cc \
+ at MAGICS_QT_TRUE@		  MgQ/MgQSymbol.cc MgQ/MgQPixmapItem.cc MgQ/MgQPathItem.cc \
+ at MAGICS_QT_TRUE@		  MgQ/MgQTextItem.cc \
+ at MAGICS_QT_TRUE@		  MgQ/MgQPolylineSetItem.cc MgQ/MgQScene.cc MgQ/MgQSceneItem.cc \
+ at MAGICS_QT_TRUE@		  MgQ/MgQSceneCacheItem.cc MgQ/MgQStepMetaData.cc \
+ at MAGICS_QT_TRUE@                  MgQ/MgQPattern.cc MgQ/MgQHistoItem.cc
+
+ at MAGICS_QT_TRUE@QT_la_SA = QtDriverAttributes.cc
+ at MAGICS_QT_TRUE@QT_la_HA = QtDriverAttributes.h
+ at MAGICS_QT_TRUE@QT_la_built = MgQ/MgQPlotScene.moc.cpp
+ at MAGICS_CAIRO_TRUE@CAIRO_inc_H = CairoDriver.h
+# CairoDriverRaster.cc
+ at MAGICS_CAIRO_TRUE@CAIRO_la_S = CairoDriver.cc 
+ at MAGICS_CAIRO_TRUE@CAIRO_la_SA = CairoDriverAttributes.cc
+ at MAGICS_CAIRO_TRUE@CAIRO_la_HA = CairoDriverAttributes.h
+
+#if MAGICS_MING
+#MING_inc_H	= MingDriver.h
+#MING_la_S	= MingDriver.cc
+#MING_la_SA	= MingDriverAttributes.cc
+#MING_la_HA	= MingDriverAttributes.h
+#endif
+KML_inc_H = KMLDriver.h
+KML_la_S = KMLDriver.cc
+KML_la_SA = KMLDriverAttributes.cc
+KML_la_HA = KMLDriverAttributes.h
+SVG_inc_H = SVGDriver.h
+SVG_la_S = SVGDriver.cc
+SVG_la_SA = SVGDriverAttributes.cc
+SVG_la_HA = SVGDriverAttributes.h
+ at MAGICS_RASTER_TRUE@RASTER_inc_H = GDDriver.h 
+ at MAGICS_RASTER_TRUE@RASTER_la_S = GDDriver.cc
+ at MAGICS_RASTER_TRUE@RASTER_la_SA = GDDriverAttributes.cc
+ at MAGICS_RASTER_TRUE@RASTER_la_HA = GDDriverAttributes.h
+include_H = BaseDriver.h BinaryDriver.h PostScriptDriver.h $(MINIZIP_inc_H) $(SVG_inc_H) $(RASTER_inc_H) $(QT_inc_H) $(CAIRO_inc_H) $(KML_inc_H) DriverManager.h
+nodist_include_H = BaseDriverAttributes.h BinaryDriverAttributes.h PostScriptDriverAttributes.h $(SVG_la_HA) $(RASTER_la_HA) $(QT_la_HA) $(CAIRO_la_HA) $(KML_la_HA)
+noinst_H = System.h BaseDriverImages.h BaseDriverWind.h BaseDriverSymbols.h BaseDriverBinaryReader.cc
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@nodist_include_HEADERS = $(nodist_include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(noinst_H) $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = $(noinst_H)
+ at MAGICS_ALLHEADERS_FALSE@nodist_noinst_HEADERS = $(nodist_include_H)
+nodist_libdrivers_la_SOURCES = BaseDriverAttributes.cc BinaryDriverAttributes.cc PostScriptDriverAttributes.cc $(MING_la_SA) $(SVG_la_SA) $(RASTER_la_SA) $(CAIRO_la_SA) $(KML_la_SA)
+libdrivers_la_SOURCES = BaseDriver.cc DriverManager.cc BinaryDriver.cc PostScriptDriver.cc $(MINIZIP_la_S) $(MING_la_S) $(SVG_la_S) $(RASTER_la_S) $(CAIRO_la_S) $(KML_la_S)
+libdrivers_la_LDFLAGS = -no-undefined -no-install
+lib_LTLIBRARIES = $(am__append_1)
+
+#
+# -DNO_ADDFILEINEXISTINGZIP is needed for minizip to waor to generate KMZ
+#
+AM_CPPFLAGS = -DNO_ADDFILEINEXISTINGZIP -I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/basic \
+	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers \
+	-I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/visualisers \
+	$(am__append_2)
+ at MAGICS_QT_TRUE@LIBRARY_CURRENT = @LIBRARY_CURRENT@
+ at MAGICS_QT_TRUE@LIBRARY_REVISION = @LIBRARY_REVISION@
+ at MAGICS_QT_TRUE@LIBRARY_AGE = @LIBRARY_AGE@
+ at MAGICS_QT_TRUE@nodist_libMagPlusQt_la_SOURCES = $(QT_la_SA) $(QT_la_built)
+ at MAGICS_QT_TRUE@libMagPlusQt_la_LDFLAGS = $(QT_LIBS) -version-info $(MAGICS_LIBRARY_CURRENT):$(MAGICS_LIBRARY_REVISION):$(MAGICS_LIBRARY_AGE)
+ at MAGICS_QT_TRUE@libMagPlusQt_la_SOURCES = $(QT_la_S)
+BUILT_SOURCES = $(QT_la_built)
+CLEANFILES = $(QT_la_built)
+AM_CXXFLAGS = $(MAGICS_VISIBILITY) # -Weffc++
+all: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .moc.cpp .moc.cc .moc.cxx .moc.C .h .hh .hpp .ui .ui.h .ui.hh .ui.hpp .qrc .qrc.cpp .qrc.cc .qrc.cxx .qrc.C .c .cc .cpp .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../../m4/autotroll.mk $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/drivers/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/drivers/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+	}
+
+uninstall-libLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+	done
+
+clean-libLTLIBRARIES:
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libMagPlusQt.la: $(libMagPlusQt_la_OBJECTS) $(libMagPlusQt_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libMagPlusQt_la_LINK) $(am_libMagPlusQt_la_rpath) $(libMagPlusQt_la_OBJECTS) $(libMagPlusQt_la_LIBADD) $(LIBS)
+libdrivers.la: $(libdrivers_la_OBJECTS) $(libdrivers_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libdrivers_la_LINK)  $(libdrivers_la_OBJECTS) $(libdrivers_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BaseDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BaseDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinaryDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinaryDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CairoDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CairoDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DriverManager.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GDDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GDDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/KMLDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/KMLDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQHistoItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQLayerItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQLayoutItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQPathItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQPattern.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQPixmapItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQPlotScene.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQPlotScene.moc.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQPolylineSetItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQScene.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQSceneCacheItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQSceneItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQStepItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQStepMetaData.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQSymbol.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MgQTextItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PostScriptDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PostScriptDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/QtDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/QtDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SVGDriver.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SVGDriverAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ioapi.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/zip.Plo at am__quote@
+
+.c.o:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+ioapi.lo: minizip/ioapi.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ioapi.lo -MD -MP -MF $(DEPDIR)/ioapi.Tpo -c -o ioapi.lo `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/ioapi.Tpo $(DEPDIR)/ioapi.Plo
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='minizip/ioapi.c' object='ioapi.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ioapi.lo `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c
+
+zip.lo: minizip/zip.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zip.lo -MD -MP -MF $(DEPDIR)/zip.Tpo -c -o zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/zip.Tpo $(DEPDIR)/zip.Plo
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='minizip/zip.c' object='zip.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+MgQLayoutItem.lo: MgQ/MgQLayoutItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQLayoutItem.lo -MD -MP -MF $(DEPDIR)/MgQLayoutItem.Tpo -c -o MgQLayoutItem.lo `test -f 'MgQ/MgQLayoutItem.cc' || echo '$(srcdir)/'`MgQ/MgQLayoutItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQLayoutItem.Tpo $(DEPDIR)/MgQLayoutItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQLayoutItem.cc' object='MgQLayoutItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQLayoutItem.lo `test -f 'MgQ/MgQLayoutItem.cc' || echo '$(srcdir)/'`MgQ/MgQLayoutItem.cc
+
+MgQStepItem.lo: MgQ/MgQStepItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQStepItem.lo -MD -MP -MF $(DEPDIR)/MgQStepItem.Tpo -c -o MgQStepItem.lo `test -f 'MgQ/MgQStepItem.cc' || echo '$(srcdir)/'`MgQ/MgQStepItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQStepItem.Tpo $(DEPDIR)/MgQStepItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQStepItem.cc' object='MgQStepItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQStepItem.lo `test -f 'MgQ/MgQStepItem.cc' || echo '$(srcdir)/'`MgQ/MgQStepItem.cc
+
+MgQLayerItem.lo: MgQ/MgQLayerItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQLayerItem.lo -MD -MP -MF $(DEPDIR)/MgQLayerItem.Tpo -c -o MgQLayerItem.lo `test -f 'MgQ/MgQLayerItem.cc' || echo '$(srcdir)/'`MgQ/MgQLayerItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQLayerItem.Tpo $(DEPDIR)/MgQLayerItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQLayerItem.cc' object='MgQLayerItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQLayerItem.lo `test -f 'MgQ/MgQLayerItem.cc' || echo '$(srcdir)/'`MgQ/MgQLayerItem.cc
+
+MgQPlotScene.lo: MgQ/MgQPlotScene.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQPlotScene.lo -MD -MP -MF $(DEPDIR)/MgQPlotScene.Tpo -c -o MgQPlotScene.lo `test -f 'MgQ/MgQPlotScene.cc' || echo '$(srcdir)/'`MgQ/MgQPlotScene.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQPlotScene.Tpo $(DEPDIR)/MgQPlotScene.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQPlotScene.cc' object='MgQPlotScene.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQPlotScene.lo `test -f 'MgQ/MgQPlotScene.cc' || echo '$(srcdir)/'`MgQ/MgQPlotScene.cc
+
+MgQSymbol.lo: MgQ/MgQSymbol.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQSymbol.lo -MD -MP -MF $(DEPDIR)/MgQSymbol.Tpo -c -o MgQSymbol.lo `test -f 'MgQ/MgQSymbol.cc' || echo '$(srcdir)/'`MgQ/MgQSymbol.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQSymbol.Tpo $(DEPDIR)/MgQSymbol.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQSymbol.cc' object='MgQSymbol.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQSymbol.lo `test -f 'MgQ/MgQSymbol.cc' || echo '$(srcdir)/'`MgQ/MgQSymbol.cc
+
+MgQPixmapItem.lo: MgQ/MgQPixmapItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQPixmapItem.lo -MD -MP -MF $(DEPDIR)/MgQPixmapItem.Tpo -c -o MgQPixmapItem.lo `test -f 'MgQ/MgQPixmapItem.cc' || echo '$(srcdir)/'`MgQ/MgQPixmapItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQPixmapItem.Tpo $(DEPDIR)/MgQPixmapItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQPixmapItem.cc' object='MgQPixmapItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQPixmapItem.lo `test -f 'MgQ/MgQPixmapItem.cc' || echo '$(srcdir)/'`MgQ/MgQPixmapItem.cc
+
+MgQPathItem.lo: MgQ/MgQPathItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQPathItem.lo -MD -MP -MF $(DEPDIR)/MgQPathItem.Tpo -c -o MgQPathItem.lo `test -f 'MgQ/MgQPathItem.cc' || echo '$(srcdir)/'`MgQ/MgQPathItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQPathItem.Tpo $(DEPDIR)/MgQPathItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQPathItem.cc' object='MgQPathItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQPathItem.lo `test -f 'MgQ/MgQPathItem.cc' || echo '$(srcdir)/'`MgQ/MgQPathItem.cc
+
+MgQTextItem.lo: MgQ/MgQTextItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQTextItem.lo -MD -MP -MF $(DEPDIR)/MgQTextItem.Tpo -c -o MgQTextItem.lo `test -f 'MgQ/MgQTextItem.cc' || echo '$(srcdir)/'`MgQ/MgQTextItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQTextItem.Tpo $(DEPDIR)/MgQTextItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQTextItem.cc' object='MgQTextItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQTextItem.lo `test -f 'MgQ/MgQTextItem.cc' || echo '$(srcdir)/'`MgQ/MgQTextItem.cc
+
+MgQPolylineSetItem.lo: MgQ/MgQPolylineSetItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQPolylineSetItem.lo -MD -MP -MF $(DEPDIR)/MgQPolylineSetItem.Tpo -c -o MgQPolylineSetItem.lo `test -f 'MgQ/MgQPolylineSetItem.cc' || echo '$(srcdir)/'`MgQ/MgQPolylineSetItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQPolylineSetItem.Tpo $(DEPDIR)/MgQPolylineSetItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQPolylineSetItem.cc' object='MgQPolylineSetItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQPolylineSetItem.lo `test -f 'MgQ/MgQPolylineSetItem.cc' || echo '$(srcdir)/'`MgQ/MgQPolylineSetItem.cc
+
+MgQScene.lo: MgQ/MgQScene.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQScene.lo -MD -MP -MF $(DEPDIR)/MgQScene.Tpo -c -o MgQScene.lo `test -f 'MgQ/MgQScene.cc' || echo '$(srcdir)/'`MgQ/MgQScene.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQScene.Tpo $(DEPDIR)/MgQScene.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQScene.cc' object='MgQScene.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQScene.lo `test -f 'MgQ/MgQScene.cc' || echo '$(srcdir)/'`MgQ/MgQScene.cc
+
+MgQSceneItem.lo: MgQ/MgQSceneItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQSceneItem.lo -MD -MP -MF $(DEPDIR)/MgQSceneItem.Tpo -c -o MgQSceneItem.lo `test -f 'MgQ/MgQSceneItem.cc' || echo '$(srcdir)/'`MgQ/MgQSceneItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQSceneItem.Tpo $(DEPDIR)/MgQSceneItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQSceneItem.cc' object='MgQSceneItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQSceneItem.lo `test -f 'MgQ/MgQSceneItem.cc' || echo '$(srcdir)/'`MgQ/MgQSceneItem.cc
+
+MgQSceneCacheItem.lo: MgQ/MgQSceneCacheItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQSceneCacheItem.lo -MD -MP -MF $(DEPDIR)/MgQSceneCacheItem.Tpo -c -o MgQSceneCacheItem.lo `test -f 'MgQ/MgQSceneCacheItem.cc' || echo '$(srcdir)/'`MgQ/MgQSceneCacheItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQSceneCacheItem.Tpo $(DEPDIR)/MgQSceneCacheItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQSceneCacheItem.cc' object='MgQSceneCacheItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQSceneCacheItem.lo `test -f 'MgQ/MgQSceneCacheItem.cc' || echo '$(srcdir)/'`MgQ/MgQSceneCacheItem.cc
+
+MgQStepMetaData.lo: MgQ/MgQStepMetaData.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQStepMetaData.lo -MD -MP -MF $(DEPDIR)/MgQStepMetaData.Tpo -c -o MgQStepMetaData.lo `test -f 'MgQ/MgQStepMetaData.cc' || echo '$(srcdir)/'`MgQ/MgQStepMetaData.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQStepMetaData.Tpo $(DEPDIR)/MgQStepMetaData.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQStepMetaData.cc' object='MgQStepMetaData.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQStepMetaData.lo `test -f 'MgQ/MgQStepMetaData.cc' || echo '$(srcdir)/'`MgQ/MgQStepMetaData.cc
+
+MgQPattern.lo: MgQ/MgQPattern.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQPattern.lo -MD -MP -MF $(DEPDIR)/MgQPattern.Tpo -c -o MgQPattern.lo `test -f 'MgQ/MgQPattern.cc' || echo '$(srcdir)/'`MgQ/MgQPattern.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQPattern.Tpo $(DEPDIR)/MgQPattern.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQPattern.cc' object='MgQPattern.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQPattern.lo `test -f 'MgQ/MgQPattern.cc' || echo '$(srcdir)/'`MgQ/MgQPattern.cc
+
+MgQHistoItem.lo: MgQ/MgQHistoItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQHistoItem.lo -MD -MP -MF $(DEPDIR)/MgQHistoItem.Tpo -c -o MgQHistoItem.lo `test -f 'MgQ/MgQHistoItem.cc' || echo '$(srcdir)/'`MgQ/MgQHistoItem.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQHistoItem.Tpo $(DEPDIR)/MgQHistoItem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQHistoItem.cc' object='MgQHistoItem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQHistoItem.lo `test -f 'MgQ/MgQHistoItem.cc' || echo '$(srcdir)/'`MgQ/MgQHistoItem.cc
+
+MgQPlotScene.moc.lo: MgQ/MgQPlotScene.moc.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT MgQPlotScene.moc.lo -MD -MP -MF $(DEPDIR)/MgQPlotScene.moc.Tpo -c -o MgQPlotScene.moc.lo `test -f 'MgQ/MgQPlotScene.moc.cpp' || echo '$(srcdir)/'`MgQ/MgQPlotScene.moc.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/MgQPlotScene.moc.Tpo $(DEPDIR)/MgQPlotScene.moc.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='MgQ/MgQPlotScene.moc.cpp' object='MgQPlotScene.moc.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o MgQPlotScene.moc.lo `test -f 'MgQ/MgQPlotScene.moc.cpp' || echo '$(srcdir)/'`MgQ/MgQPlotScene.moc.cpp
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+install-nodist_includeHEADERS: $(nodist_include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-nodist_includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+	clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS install-nodist_includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
+	uninstall-nodist_includeHEADERS
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
+	ctags distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am \
+	install-includeHEADERS install-info install-info-am \
+	install-libLTLIBRARIES install-man \
+	install-nodist_includeHEADERS install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS \
+	uninstall-libLTLIBRARIES uninstall-nodist_includeHEADERS
+
+
+ at MAGICS_QT_TRUE@ # ------------- #
+ at MAGICS_QT_TRUE@ # DOCUMENTATION #
+ at MAGICS_QT_TRUE@ # ------------- #
+
+# --- #
+# MOC #
+# --- #
+
+ at MAGICS_QT_TRUE@.hpp.moc.cpp:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.hh.moc.cpp:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.h.moc.cpp:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+ at MAGICS_QT_TRUE@.hpp.moc.cc:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.hh.moc.cc:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.h.moc.cc:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+ at MAGICS_QT_TRUE@.hpp.moc.cxx:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.hh.moc.cxx:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.h.moc.cxx:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+ at MAGICS_QT_TRUE@.hpp.moc.C:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.hh.moc.C:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+ at MAGICS_QT_TRUE@.h.moc.C:
+ at MAGICS_QT_TRUE@	$(MOC) $(QT_CPPFLAGS) $(EXTRA_CPPFLAGS) $< -o $@
+
+# --- #
+# UIC #
+# --- #
+
+ at MAGICS_QT_TRUE@.ui.ui.hpp:
+ at MAGICS_QT_TRUE@	$(UIC) $< -o $@
+
+ at MAGICS_QT_TRUE@.ui.ui.hh:
+ at MAGICS_QT_TRUE@	$(UIC) $< -o $@
+
+ at MAGICS_QT_TRUE@.ui.ui.h:
+ at MAGICS_QT_TRUE@	$(UIC) $< -o $@
+
+# --- #
+# RCC #
+# --- #
+
+ at MAGICS_QT_TRUE@.qrc.qrc.cpp:
+ at MAGICS_QT_TRUE@	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+ at MAGICS_QT_TRUE@.qrc.qrc.cc:
+ at MAGICS_QT_TRUE@	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+ at MAGICS_QT_TRUE@.qrc.qrc.cxx:
+ at MAGICS_QT_TRUE@	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+ at MAGICS_QT_TRUE@.qrc.qrc.C:
+ at MAGICS_QT_TRUE@	$(RCC) -name `echo "$<" | sed 's/\.qrc$$//'` $< -o $@
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/drivers/MgQ/MgQ.h b/src/drivers/MgQ/MgQ.h
new file mode 100644
index 0000000..6aea7b7
--- /dev/null
+++ b/src/drivers/MgQ/MgQ.h
@@ -0,0 +1,63 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQ.h
+    \brief Definition of MgQ.
+    \author Graphics Section, ECMWF
+
+    Started: September 2011
+*/
+
+#ifndef _MgQ_H
+#define _MgQ_H
+
+#include <magics.h>
+
+#include <QGraphicsItem>
+
+//namespace magics 
+//{
+
+namespace MgQ
+{
+	enum ItemDataKey {ItemIsZoomableKey,ItemIsVisibleKey,ItemStepIdKey};
+
+	const int HistoItemType=QGraphicsItem::UserType + 1;
+	const int LayerItemType=QGraphicsItem::UserType + 2;
+	const int LayoutItemType=QGraphicsItem::UserType + 3;
+	const int MagnifierLayoutItemType=QGraphicsItem::UserType + 4;
+	const int PathItemType=QGraphicsItem::UserType + 5;
+	const int PixmapItemType=QGraphicsItem::UserType + 6;
+	const int PolylineSetItemType=QGraphicsItem::UserType + 7;
+	const int PreviewLayoutItemType=QGraphicsItem::UserType + 8;
+	const int RootItemType=QGraphicsItem::UserType + 9;
+	const int SceneCacheItemType=QGraphicsItem::UserType + 10;
+	const int SceneLayerItemType=QGraphicsItem::UserType + 11;
+	const int SceneItemType=QGraphicsItem::UserType + 12;
+	const int StepItemType=QGraphicsItem::UserType + 13;
+	const int SymbolSetItemType=QGraphicsItem::UserType + 14;
+	const int TextItemType=QGraphicsItem::UserType + 15;
+}
+
+//}
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQDriverObject.h b/src/drivers/MgQ/MgQDriverObject.h
new file mode 100644
index 0000000..2a9f3ee
--- /dev/null
+++ b/src/drivers/MgQ/MgQDriverObject.h
@@ -0,0 +1,45 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQDriverObject.h
+    \brief Definition of MgQDriverObject 
+    \author Graphics Section, ECMWF
+
+    Started: April 2010
+*/
+
+#ifndef MgQDriverObjectH
+#define MgQDriverObject_H
+
+#include "QtDriver.h"
+
+class MgQDriverObject
+{
+public:
+	MgQDriverObject(const QtDriver& driver) : driver_(driver) {};
+
+	const QtDriver&  driver() {return driver_;} 
+
+protected:
+	const QtDriver& driver_;
+};
+
+#endif
diff --git a/src/drivers/MgQ/MgQHistoItem.cc b/src/drivers/MgQ/MgQHistoItem.cc
new file mode 100644
index 0000000..30452f9
--- /dev/null
+++ b/src/drivers/MgQ/MgQHistoItem.cc
@@ -0,0 +1,41 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQHistoItem.cc
+    \brief Definition of MgQHistoItem
+    \author Graphics Section, ECMWF
+
+    Started: February 2011
+*/
+
+#include "MgQHistoItem.h"
+
+//using namespace magics;
+
+MgQHistoItem::MgQHistoItem() : cached_(false)
+{
+	setData(MgQ::ItemIsVisibleKey,false);	
+}
+
+MgQHistoItem::~MgQHistoItem()
+{	
+
+}
diff --git a/src/drivers/MgQ/MgQHistoItem.h b/src/drivers/MgQ/MgQHistoItem.h
new file mode 100644
index 0000000..1cdbc3c
--- /dev/null
+++ b/src/drivers/MgQ/MgQHistoItem.h
@@ -0,0 +1,63 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQHistoItem.h
+    \brief Definition of MgQHistoItem.
+    \author Graphics Section, ECMWF
+
+    Started: February 2011
+*/
+
+#ifndef _MgQHistoItem_H
+#define _MgQHistoItem_H
+
+#include <magics.h>
+
+#include "MgQ.h"
+
+class MgQHistoItem : public QGraphicsItem 
+{
+public:
+	enum {Type = MgQ::HistoItemType}; 
+
+	MgQHistoItem();
+	~MgQHistoItem();
+	QPixmap pixmap() {return pixmap_;}
+	void setPixmap(QPixmap p,QSize s) {pixmap_=p;requestedPixmapSize_=s;} 
+	QSize requestedPixmapSize() {return requestedPixmapSize_;} 
+	bool cached() {return cached_;};
+	void setCached(bool b) {cached_=b;}	
+	QHash<QString,QString> pixmapId() {return pixmapId_;}
+	void setPixmapId(QHash<QString,QString> id) {pixmapId_=id;}
+	
+	int type() const {return Type;}
+	QRectF boundingRect() const {return QRectF();}
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *) {};
+
+protected:
+	QPixmap pixmap_;
+	QSize requestedPixmapSize_;
+	bool cached_;
+	QHash<QString,QString> pixmapId_;
+};
+
+#endif
diff --git a/src/drivers/MgQ/MgQLayerItem.cc b/src/drivers/MgQ/MgQLayerItem.cc
new file mode 100644
index 0000000..87ca6f5
--- /dev/null
+++ b/src/drivers/MgQ/MgQLayerItem.cc
@@ -0,0 +1,612 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQLayerItem.cc
+    \brief Implementation of the MgQLayerItem class.
+    \author Graphics Section, ECMWF
+
+    Started: February 2010
+*/
+
+#include <QDebug>
+#include <QImage>
+#include <QPainter>
+
+#include "MgQLayerItem.h"
+
+#include "MgQHistoItem.h"
+#include "MgQLayoutItem.h"
+#include "MgQRootItem.h"
+#include "MgQScene.h"
+#include "MgQStepItem.h"
+
+using namespace magics;
+
+QImage* MgQLayerItem::alphaDevice_=0;
+QPainter* MgQLayerItem::alphaPainter_=0;
+
+
+MgQLayoutItem* MgQSceneLayerItem::findProjectorItem(QPointF scenePos)
+{
+	foreach(MgQLayoutItem* item, projectorItems_)
+	{			
+	  	if(item->contains(item->mapFromScene(scenePos)))
+		{			  
+			return item;
+		}
+	}
+	return 0;	
+}
+
+
+MgQLayerItem::MgQLayerItem(Layer &layer,MgQLayoutItem *layout,int stepNum) : 
+	  layer_(layer), layout_(layout)
+{
+	rootItem_=new MgQRootItem;
+	rootItem_->setParentItem(this);
+	rootItemOwner_=MainScene;
+	
+	magnifierLayout_=0;
+	magnifierDataEnabled_=false;
+
+	alphaScene_=0;
+	
+	previewScene_=0;
+	previewDevice_=0;
+	previewPainter_=0;
+	
+	histoScene_=0;
+	histoPainter_=0;
+	histoDevice_=0;
+	
+	//rootItem_->setTransform(layout->sceneTransform());
+
+	for(int i=0; i < stepNum; i++)
+	{
+		steps_ << 0;
+	}
+
+	for(int i=0; i < stepNum; i++)
+	{
+		histoItems_ << 0;
+	}
+	if(stepNum == 0)
+	{
+		histoItems_ << 0;
+	}
+}
+
+MgQLayerItem::~MgQLayerItem()
+{ 
+  	if(alphaScene_)
+	  	delete alphaScene_;
+	if(previewScene_)
+	  	delete previewScene_;
+	if(histoScene_)
+	  	delete histoScene_;
+	
+	if(alphaPainter_)
+	{	delete alphaPainter_;
+		alphaPainter_=0;
+	}
+	if(previewPainter_)
+		delete previewPainter_;
+	if(histoPainter_)
+		delete histoPainter_;
+	
+	if(alphaDevice_)
+	{
+	  	delete alphaDevice_;
+		alphaDevice_=0;
+	}
+	if(previewDevice_)
+		delete previewDevice_;
+	if(histoDevice_)
+		delete histoDevice_;	
+}
+
+MgQMagnifierLayoutItem * MgQLayerItem::magnifierLayoutItem()
+{
+	if(!magnifierLayout_)//Init magnifier layout item
+	{
+		MgQLayoutItem *topLayout=topLayoutItem();
+		if(!topLayout)
+			return 0;
+
+		//it is outside the root item
+		magnifierLayout_= new MgQMagnifierLayoutItem(topLayout);
+		magnifierLayout_->setParentItem(this);
+		magnifierLayout_->setParentItemInMainScene(this);
+		magnifierLayout_->setData(MgQ::ItemIsVisibleKey,false);
+	}
+	
+	return magnifierLayout_;
+}
+
+
+bool MgQLayerItem::layerVisibility() const
+{
+	return layer_.visibility();
+}
+
+void MgQLayerItem::setLayerVisibility(bool visible)
+{	
+	layer_.visibility(visible);
+	//setVisible(b);
+	setData(MgQ::ItemIsVisibleKey,visible);
+}
+
+float MgQLayerItem::layerAlpha() const
+{
+	int tr=layer_.transparency();
+	return (100-tr)/100.;
+}
+
+void MgQLayerItem::setLayerAlpha(float alpha) 
+{
+//	const float oriAlpha=layerAlpha();
+	layer_.transparency((1.-alpha)*100.);
+//	if(fabs(alpha-oriAlpha) > 0.05)
+//		update();
+}
+
+void MgQLayerItem::setStackLevel(int i)
+{
+	float z=1.1+0.01*static_cast<float>(i);
+	layer_.zindex(i);
+	setZValue(z); 
+}
+
+int MgQLayerItem::stackLevel()
+{
+	return layer_.zindex();
+
+	//int i=static_cast<int>((zValue()-1.1) *100.);
+	//return i;
+}
+
+void MgQLayerItem::saveLayerState(MgQLayerState* st)
+{
+	st->name_=QString::fromStdString(layer_.name());
+	st->id_=QString::fromStdString(layer_.id());
+	st->alpha_=layerAlpha();
+	st->visible_=layerVisibility();
+	st->stackLevel_=stackLevel();
+}
+
+void MgQLayerItem::updateLayer(const MgQLayerItem *item)
+{
+	if(item->name().toStdString() != layer_.name())
+		return;
+
+	setLayerVisibility(item->layerVisibility());
+	setLayerAlpha(item->layerAlpha());
+}
+
+void MgQLayerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                QWidget *widget)
+{
+	//Non-trasparent 
+	if(layerAlpha() >= 0.99)
+	{
+		addContentsToScene(MainScene);
+	}
+	//Transparent
+	else
+	{
+		addContentsToScene(AlphaScene);
+
+		bool clipping=(painter->clipRegion().isEmpty())?false:true;
+		QRect clipRect=painter->clipRegion().boundingRect();
+
+		float sx=painter->transform().m11();
+		float sy=painter->transform().m22();
+
+		QRectF sourceRect,targetRect;
+		QRect alphaRect, magRect;
+
+		alphaDevice_->fill(qRgba(0,0,0,0));
+
+		//Magnifier
+		if(clipping)
+		{
+			sourceRect=clipRect;
+			magRect=QRect(sourceRect.x()*sx,sourceRect.y()*sy,
+				      sourceRect.width()*sx,sourceRect.height()*sy);	
+		}
+		//Non magnifier!!
+		else
+		{
+			//The rect in local coordinates
+			sourceRect=layout_->boundingRect();	
+		}
+		
+		
+		//Physical target rect on the alpha device
+		alphaRect=QRect(0.,0.,sourceRect.width()*sx,sourceRect.height()*sy);
+				
+		//qDebug() <<  "LAYER-MAGNIFY" << scale() << sx << sy << layout_->boundingRect()  << alphaRect <<  clipRect;
+				
+		//Check if the alpha device needs to be resized
+		checkAlphaDeviceSize(alphaRect);
+			
+  		//Set antialising for alpha painter
+		alphaPainter_->setRenderHint(QPainter::Antialiasing,painter->renderHints() & QPainter::Antialiasing);
+			
+		//Render the layer into the alpha device: from sourceRect to alphaRect!			
+		alphaScene_->renderContents(alphaPainter_,option,alphaRect,sourceRect);
+				
+		//Save the painter transform
+		QTransform trOri=painter->transform();
+			
+		//Set the scaling to 1 for the painter
+		QTransform tr=trOri;
+		tr.setMatrix(1.,tr.m12(),tr.m13(),tr.m12(),1.,tr.m23(),tr.m31(),tr.m32(),tr.m33());
+		painter->setTransform(tr);
+			
+		//Paint alphaRect form the alphaDevice
+		painter->setOpacity(layerAlpha());
+		
+		//Magnifier
+		if(clipping)
+		{
+			painter->drawImage(magRect,alphaDevice_->copy(alphaRect));
+		}
+		//Non magnifier!!
+		else
+		{
+			painter->drawImage(alphaRect,alphaDevice_->copy(alphaRect));  
+		}
+		
+		//Reset the painter tranfor to the original value
+		painter->setTransform(trOri);						
+	}
+}
+
+void MgQLayerItem::checkAlphaDeviceSize(QRect rect)
+{
+  	if(!alphaDevice_)
+		return;
+	
+	int w=(alphaDevice_->width() < rect.width())?rect.width():alphaDevice_->width();
+	int h=(alphaDevice_->height() < rect.height())?rect.height():alphaDevice_->height();
+	
+	if(alphaDevice_->width() < w || alphaDevice_->height() < h)
+	{
+		delete alphaPainter_;
+		delete alphaDevice_;
+
+		alphaDevice_=new QImage(w+2,h+2,QImage::Format_ARGB32);
+		alphaPainter_=new QPainter(alphaDevice_);			  
+	}
+}	
+
+void MgQLayerItem::addContentsToScene(RootItemOwner newOwner)
+{
+  	if(rootItemOwner_ == newOwner)
+	  	return;
+  
+	if(rootItemOwner_ == MainScene)
+	{   
+  		scene()->removeItem(rootItem_);
+
+	}
+	else if(rootItemOwner_ == AlphaScene)
+	{   
+  		if(!alphaScene_)
+			return;
+
+		alphaScene_->removePlotRootItemFromScene();
+	}
+	else if(rootItemOwner_ == PreviewScene)
+	{   
+		if(!previewScene_)
+			return;
+
+		previewScene_->removePlotRootItemFromScene();
+	}
+	
+	
+	if(newOwner == MainScene)
+	{
+		rootItem_->setTransform(QTransform());
+		rootItem_->setParentItem(this);	
+	}  	  
+	else if(newOwner == AlphaScene)
+	{	
+		//rootItem_->setTransform(layout_->sceneTransform());
+		if(!alphaScene_)
+		{
+			alphaScene_=new MgQScene(rootItem_);
+		}	
+
+		if(!alphaDevice_)
+		{
+			alphaDevice_=new QImage(1100,785,QImage::Format_ARGB32);
+			alphaPainter_=new QPainter(alphaDevice_);
+		}
+	
+		alphaScene_->addPlotRootItemToScene();
+	}
+	else if(newOwner == PreviewScene)
+	{	
+		rootItem_->setTransform(layout_->sceneTransform());
+
+		if(!previewScene_)
+		{
+			previewScene_=new MgQScene(rootItem_);
+			previewDevice_=new QImage(200,200,QImage::Format_ARGB32);
+			previewPainter_=new QPainter(previewDevice_);
+ 		}
+
+		previewScene_->addPlotRootItemToScene();
+	}
+	
+	rootItemOwner_=newOwner;	
+}
+
+void MgQLayerItem::setStepVisible(int step,bool visible)
+{
+	if(steps_.count() ==0 || 
+	  step < 0 || step >= steps_.count())
+		return;
+
+	if(steps_[step])
+	{		
+		steps_[step]->setData(MgQ::ItemIsVisibleKey,visible);
+		//steps_[step]->setVisible(visible);	
+	}
+}
+
+void  MgQLayerItem::clearStep(int step)
+{		
+	if(steps_.count() ==0 || 
+	   step < 0 || step >= steps_.count())
+		return;
+
+	if(steps_[step])
+	{
+		delete steps_[step];
+		steps_[step]=0;
+	}
+}
+
+bool MgQLayerItem::stepCached(int step)
+{		
+	if(steps_.count() ==0 || 
+	   step < 0 || step >= steps_.count())
+		return false;
+
+	if(steps_[step])
+		return steps_[step]->cached();
+	else
+		return false;
+}
+
+MgQLayoutItem* MgQLayerItem::topLayoutItem()
+{
+	foreach(MgQStepItem* step,steps_)
+	{
+		if(step != 0)
+		{
+			foreach(QGraphicsItem *item, step->childItems())
+			{
+				if(item->type() == MgQ::LayoutItemType)
+				{			
+					MgQLayoutItem *layout=static_cast<MgQLayoutItem*>(item);
+					return layout;
+				}
+			}
+		}
+	}
+	return 0;		
+}	
+
+void MgQLayerItem::renderPreview()
+{
+	RootItemOwner prevOwner=rootItemOwner_;
+	addContentsToScene(PreviewScene);
+	
+	//QRectF layoutRect=layout_->boundingRect();
+	//QRectF targetRect((layout_->mapToScene( layoutRect).boundingRect()));
+	//QRectF painterRect=painter->transform().mapRect(layout_->boundingRect());
+				
+	QRectF sourceRect=QRectF((layout_->mapToScene(layout_->boundingRect()).boundingRect()));
+
+	const float w=sourceRect.width();
+	const float h=sourceRect.height();
+//	float r=w/h;
+
+	const float preW=previewDevice_->width();
+	const float preH=previewDevice_->height();
+
+	QRectF targetRect;
+	if(h*preW/w > preH)
+	{
+		targetRect=QRectF(0.,0.,w*preH/h,preH);
+	}
+	else
+	{
+		targetRect=QRectF(0.,0.,preW,h*preW/w);
+	}
+		
+	previewDevice_->fill(qRgba(255,255,255,255));
+	previewScene_->renderContents(previewPainter_,targetRect,sourceRect);
+
+	QRect targetRectInt(targetRect.x(),targetRect.y(),targetRect.width(),targetRect.height());
+	if(h*100/w > 50)
+	{
+		previewImg_=previewDevice_->copy(targetRectInt).scaledToHeight(50,Qt::SmoothTransformation).mirrored(false,true);
+	}
+	else
+	{
+		previewImg_=previewDevice_->copy(targetRectInt).scaledToWidth(100,Qt::SmoothTransformation).mirrored(false,true);
+	}
+
+
+	//previewImg_.save("/var/tmp/cgr/layer.png");
+
+
+	//QRect targetRectInt(targetRect.x(),targetRect.y(),targetRect.width(),targetRect.height());
+
+	/*painter->setOpacity(layerAlpha());
+	painter->drawImage(layout_->boundingRect(),
+			   previewDevice_->copy(targetRectInt));*/
+
+	addContentsToScene(prevOwner);
+}	
+
+
+
+MgQHistoItem* MgQLayerItem::histoItem(int step)
+{
+	if(!histoScene_)
+	{
+		histoScene_=new QGraphicsScene;
+		histoDevice_=new QImage(300,200,QImage::Format_ARGB32);
+		histoPainter_=new QPainter(histoDevice_);
+ 	}
+
+	if(stepNum() == 0)
+	{
+		if(!histoItems_[0])
+		{
+			histoItems_[0]=new MgQHistoItem;
+			histoItems_[0]->setVisible(false);
+			histoScene_->addItem(histoItems_[0]);			
+		}
+		return histoItems_[0];
+	}
+	else
+	{
+		if(step < 0 || step >= steps_.count() || !steps_[step] )
+			return 0;
+			
+		if(!histoItems_[step])
+		{
+			histoItems_[step]=new MgQHistoItem;	
+			histoItems_[step]->setVisible(false);	
+			histoScene_->addItem(histoItems_[step]);
+		}
+		return histoItems_[step];
+	}
+}
+
+MgQHistoItem* MgQLayerItem::resetHistoItem(int step)
+{
+	MgQHistoItem* item=histoItem(step);
+		
+	if(item)
+	{
+		histoScene_->removeItem(item);	
+		delete item;
+	
+		if(stepNum() == 0)		
+		{
+		 	 histoItems_[0]=0;
+			 
+		}
+		else if(step >= 0 && step < steps_.count() && steps_[step])
+		{
+		  	histoItems_[step]=0;
+		}
+		else
+		{  
+		  	return 0;
+
+		}
+	}	
+	
+	return histoItem(step);	
+}  
+
+void MgQLayerItem::addHistoItem(MgQHistoItem *item)
+{		
+	/*if(steps_.count() ==0 || step < 0 || 
+           step >= steps_.count() || !steps_[step] )
+		return;*/
+
+	/*item->scene()->removeItem(item);
+	
+	if(!histoScene_)
+	{
+		histoScene_=new QGraphicsScene;
+		histoDevice_=new QImage(200,200,QImage::Format_ARGB32);
+		histoPainter_=new QPainter(histoDevice_);
+ 	}
+	
+	histoScene_->addItem(item);*/
+}
+
+QPixmap MgQLayerItem::histoPixmap(int step,QSize size)
+{
+	MgQHistoItem *item=histoItem(step);
+
+	if(!item)
+		return QPixmap();
+
+	/*if(item->pixmap().isNull() && item->cached())
+	{
+		return QPixmap();
+	}*/
+
+	if(item->cached() && item->requestedPixmapSize() == size)
+	{
+		return item->pixmap();
+	}
+	else
+	{
+		/*foreach(QGraphicsItem *item,histoScene_->items())
+		{
+			qDebug() << item << item->childItems().count() <<  item->boundingRect() << item->sceneBoundingRect();
+		}
+
+		qDebug() << histoScene_->sceneRect() << item->boundingRect() << item->sceneBoundingRect() ;*/
+
+		if(histoDevice_->size().width() < size.width() ||
+		   histoDevice_->size().height() < size.height())
+		{
+			
+			delete histoDevice_;
+			histoDevice_ = new QImage(size,QImage::Format_ARGB32);
+		}
+
+		item->setVisible(true);			
+		histoDevice_->fill(qRgba(255,255,255,255));
+		histoScene_->render(histoPainter_,QRectF(0,0,size.width(),size.height()));
+		item->setVisible(false);
+
+		/*float ratio=1;
+		QRectF scr=histoScene_->sceneRect();
+		if(scr.height() > 0)
+			ratio=scr.width()/scr.height();
+	
+		QImage img=histoDevice_->copy(0,0,size.width(),size.width()/ratio+1).mirrored(false,true);*/
+		QImage img=histoDevice_->copy(0,0,size.width(),size.height()).mirrored(false,true);
+		
+		item->setPixmap(QPixmap::fromImage(img),size);
+		item->setCached(true);
+		
+		return item->pixmap();		
+	}
+
+	return QPixmap(); 
+}
diff --git a/src/drivers/MgQ/MgQLayerItem.h b/src/drivers/MgQ/MgQLayerItem.h
new file mode 100644
index 0000000..aa76b32
--- /dev/null
+++ b/src/drivers/MgQ/MgQLayerItem.h
@@ -0,0 +1,172 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQLayerItem.h
+    \brief Definition of MgQLayerItem.
+    \author Graphics Section, ECMWF
+
+    Started: February 2010
+*/
+
+#ifndef _MgQLayerItem_H
+#define _MgQLayerItem_H
+
+#include <Layer.h>
+#include "MgQ.h"
+
+using magics::Layer;
+using magics::SceneLayer;
+	
+class QImage;
+class QPainter;
+
+class MgQHistoItem;
+class MgQLayoutItem;
+class MgQMagnifierLayoutItem;
+class MgQRootItem;
+class MgQScene;
+class MgQStepItem;
+
+class MgQLayerState
+{
+public:
+	QString name_;
+	QString id_;
+	int     stackLevel_;
+	float   alpha_;
+	bool    visible_;
+};
+
+class MgQSceneLayerItem : public QGraphicsItem
+{
+public:
+	enum {Type = MgQ::SceneLayerItemType}; 
+	
+	MgQSceneLayerItem(const SceneLayer &sc) : sceneLayer_(sc) {};
+	~MgQSceneLayerItem() {};
+
+	const SceneLayer& sceneLayer() {return sceneLayer_;};
+	void addProjectorItem(MgQLayoutItem *n) {projectorItems_ << n;}
+	QList<MgQLayoutItem*> projectorItems() {return projectorItems_;}
+	MgQLayoutItem* findProjectorItem(QPointF);
+	
+	int type() const {return Type;}
+	QRectF boundingRect() const {return QRectF();}
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *) {};
+
+protected:
+	const SceneLayer& sceneLayer_;
+	QList<MgQLayoutItem*> projectorItems_;
+};
+
+
+
+class MgQLayerItem : public QGraphicsItem
+{
+public:	
+	enum {Type = MgQ::LayerItemType};
+	enum InfoImageType {HistoImage};
+
+	MgQLayerItem(Layer &,MgQLayoutItem *,int);
+	~MgQLayerItem();
+
+	QString name() const {return QString::fromStdString(layer_.name());}
+	Layer& layer() {return layer_;};
+	void  setLayerAlpha(float);
+	void  setLayerVisibility(bool);	
+	float layerAlpha() const; 
+	bool  layerVisibility() const;
+	void  updateLayer(const MgQLayerItem*);
+	MgQRootItem* rootItem() {return rootItem_;}
+	
+	void setStep(int step,MgQStepItem* item) {steps_[step]=item;} 
+	void setStepVisible(int,bool);
+	bool stepCached(int);
+	void clearStep(int);
+	int stepNum() {return steps_.count();}
+	bool magnifierDataEnabled() {return magnifierDataEnabled_;}
+	void setMagnifierDataEnabled(bool b) {magnifierDataEnabled_=b;}
+
+	MgQLayoutItem* parentLayoutItem() {return layout_;}
+
+	MgQMagnifierLayoutItem *magnifierLayoutItem();
+
+	int type() const {return Type;}
+	QRectF boundingRect() const {return QRectF();}
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+
+	void setStackLevel(int);
+	int stackLevel();
+
+	void saveLayerState(MgQLayerState*);
+	MgQLayoutItem* topLayoutItem();
+
+	void renderPreview();
+
+	const QImage& preview() const {return previewImg_;}
+
+
+	MgQHistoItem* histoItem(int);
+	MgQHistoItem* resetHistoItem(int);
+	void addHistoItem(MgQHistoItem *);
+	QPixmap histoPixmap(int,QSize);
+
+
+protected:
+	enum RootItemOwner {MainScene,AlphaScene,PreviewScene};
+	
+	void checkAlphaDeviceSize(QRect);
+  	void addContentsToScene(RootItemOwner);
+
+	Layer& layer_;
+
+	MgQRootItem* rootItem_;
+	RootItemOwner rootItemOwner_;
+
+	MgQLayoutItem* layout_;
+
+	MgQScene *alphaScene_;
+	static QImage *alphaDevice_;
+	static QPainter* alphaPainter_;
+
+	MgQScene *previewScene_;
+	QImage *previewDevice_;
+	QPainter* previewPainter_;
+	QImage previewImg_;
+
+	QGraphicsScene *histoScene_;
+	QImage *histoDevice_;
+	QPainter* histoPainter_;
+
+	QList<MgQStepItem*> steps_;
+	QList<MgQHistoItem*> histoItems_;
+
+
+	MgQMagnifierLayoutItem *magnifierLayout_;
+
+	bool magnifierDataEnabled_;
+};
+
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQLayoutItem.cc b/src/drivers/MgQ/MgQLayoutItem.cc
new file mode 100644
index 0000000..ac31645
--- /dev/null
+++ b/src/drivers/MgQ/MgQLayoutItem.cc
@@ -0,0 +1,176 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQLayoutItem.cc
+    \brief Definition of MgQLayoutItem
+    \author Graphics Section, ECMWF
+
+    Started: February 2010
+*/
+
+#include <QDebug>
+
+#include "MgQLayoutItem.h"
+
+#include "Transformation.h"
+
+using namespace magics;
+
+
+MgQLayoutItem::MgQLayoutItem(const Layout &l) : layout_(l)
+{
+}
+
+MgQLayoutItem::MgQLayoutItem(const MgQLayoutItem& ori) :
+	layout_(ori.layout_),
+	coordRatioX_(ori.coordRatioX_),
+	coordRatioY_(ori.coordRatioY_),
+	dimensionX_(ori.dimensionX_),
+	dimensionY_(ori.dimensionY_),
+	projectedMinX_(ori.projectedMinX_),
+	projectedMinY_(ori.projectedMinY_)
+	{}
+
+QRectF MgQLayoutItem::boundingRect() const
+{
+	return QRectF(projectedMinX_,projectedMinY_,
+			projectedMaxX_-projectedMinX_,
+			projectedMaxY_-projectedMinY_);
+}
+
+void MgQLayoutItem::mapFromSceneToProjectionCoords(QPointF& scenePoint,QPointF& projPoint) 
+{
+	QPointF ppLocal=mapFromScene(scenePoint);
+	projPoint=QPointF(ppLocal.x()/coordRatioX_,ppLocal.y()/coordRatioY_);
+}
+
+
+void MgQLayoutItem::mapFromSceneToGeoCoords(const QPointF& scenePoint,QPointF& geoPoint) 
+{
+	const Transformation& transformation = layout_.transformation();
+
+	QPointF ppLocal=mapFromScene(scenePoint);
+	PaperPoint ppLayout(ppLocal.x()/coordRatioX_,ppLocal.y()/coordRatioY_);
+
+	UserPoint gp;
+	
+	transformation.revert(ppLayout, gp);
+
+	geoPoint.setX(gp.x());
+	geoPoint.setY(gp.y());
+}
+string   MgQLayoutItem::mapFromSceneToTransformationDefinition(QPointF& ll,QPointF& ur)
+{
+	const Transformation& transformation = layout_.transformation();
+
+	QPointF lll = mapFromScene(ll);
+	PaperPoint llp(lll.x()/coordRatioX_,lll.y()/coordRatioY_);
+	UserPoint llu;
+	transformation.revert(llp, llu);
+
+	QPointF url = mapFromScene(ur);
+	PaperPoint urp(url.x()/coordRatioX_,url.y()/coordRatioY_);
+	UserPoint uru;
+	transformation.revert(urp, uru);
+
+	string def;
+	transformation.getNewDefinition(llu, uru, def);
+	return def;
+}
+void MgQLayoutItem::mapFromSceneToGeoCoords(QRectF& rect,QList<QPointF>& corners) 
+{	
+	const Transformation& transformation = layout_.transformation();
+
+	QPointF pp=mapFromScene(rect.bottomLeft());
+	PaperPoint pp_ll(pp.x()/coordRatioX_,pp.y()/coordRatioY_);
+
+	pp=mapFromScene(rect.topRight());
+	PaperPoint pp_ur(pp.x()/coordRatioX_,pp.y()/coordRatioY_);
+
+	UserPoint ll, ur;
+	
+	transformation.revert(pp_ll, ll);
+	transformation.revert(pp_ur, ur);
+
+	corners <<  QPointF(ll.x(),ll.y());
+	corners <<  QPointF(ur.x(),ur.y());
+}
+
+void MgQLayoutItem::mapFromGeoToSceneCoords(const QPointF& geoPoint,QPointF& scenePoint) 
+{
+	const Transformation& transformation = layout_.transformation();
+
+	UserPoint gp(geoPoint.x(),geoPoint.y());
+	PaperPoint ppLayout = transformation(gp);
+
+	QPointF ppLocal(ppLayout.x()*coordRatioX_,ppLayout.y()*coordRatioY_);
+
+	scenePoint = mapToScene(ppLocal);
+}
+
+bool MgQLayoutItem::containsSceneCoords(QPointF& sPoint)
+{
+	QPointF lPoint=mapFromScene(sPoint);
+	
+	return containsPoint(lPoint);
+}
+
+
+bool MgQLayoutItem::containsGeoCoords(QPointF& geoPoint)
+{
+	const Transformation& transformation = layout_.transformation();
+
+	UserPoint gp(geoPoint.x(),geoPoint.y());
+	PaperPoint ppLayout = transformation(gp);
+
+	QPointF ppLocal(ppLayout.x()*coordRatioX_,ppLayout.y()*coordRatioY_);
+
+	//contains() gave false for points on the border of the bounding rect!!
+	return containsPoint(ppLocal);
+}
+
+bool MgQLayoutItem::containsPoint(QPointF &p,qreal tolerance)
+{
+	return boundingRect().adjusted(-tolerance,-tolerance,tolerance,tolerance).contains(p);
+}
+
+void MgQLayoutItem::addToMainScene()
+{
+	setParentItem(parentItemInMainScene_);
+}
+
+
+MgQMagnifierLayoutItem::MgQMagnifierLayoutItem(MgQLayoutItem* item) : MgQLayoutItem(*item)
+{
+}
+
+QRectF MgQMagnifierLayoutItem::boundingRect() const
+{
+	return QRectF();
+}
+
+void MgQMagnifierLayoutItem::clearPlotContents()
+{	
+	foreach(QGraphicsItem *item,childItems())
+	{
+		delete item;
+	}
+}
diff --git a/src/drivers/MgQ/MgQLayoutItem.h b/src/drivers/MgQ/MgQLayoutItem.h
new file mode 100644
index 0000000..02f2394
--- /dev/null
+++ b/src/drivers/MgQ/MgQLayoutItem.h
@@ -0,0 +1,160 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQLayoutItem.h
+    \brief Definition of MgQLayoutItem.
+    \author Graphics Section, ECMWF
+
+    Started: February 2010
+*/
+
+#ifndef _MgQLayoutItem_H
+#define _MgQLayoutItem_H
+
+#include <magics.h>
+#include <Layout.h>
+#include <PaperPoint.h>
+
+#include "MgQ.h"
+
+//namespace magics 
+//{
+
+class MgQLayoutItem : public QGraphicsItem
+{
+public:
+	enum {Type = MgQ::LayoutItemType}; 
+	
+	//OpenGLLayoutItem();
+	MgQLayoutItem(const Layout &);
+	MgQLayoutItem(const MgQLayoutItem &);
+
+	virtual int type() const {return Type;}
+	virtual QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *) {};
+	
+	const Layout& layout() {return layout_;};
+	AnimationRules* animationRules() {return layout_.animationRules();};
+	//void animationRules(AnimationRules *anr) {animationRules_=anr;};
+
+	void  coordRatioX(double f) {coordRatioX_=f;};	 
+	void  coordRatioY(double f) {coordRatioY_=f;};
+	double coordRatioX() {return coordRatioX_;};	 
+	double coordRatioY() {return coordRatioY_;};
+
+	void  dimensionX(double f) {dimensionX_=f;};	 
+	void  dimensionY(double f) {dimensionY_=f;};
+	double dimensionX() {return dimensionX_;};	 
+	double dimensionY() {return dimensionY_;};
+
+	double projectedMinX() {return projectedMinX_;}
+	void  projectedMinX(double f) {projectedMinX_=f;}
+	double projectedMinY() {return projectedMinY_;}
+	void  projectedMinY(double f) {projectedMinY_=f;}
+
+	double projectedMaxX() {return projectedMaxX_;}
+	void  projectedMaxX(double f) {projectedMaxX_=f;}
+	double projectedMaxY() {return projectedMaxY_;}
+	void  projectedMaxY(double f) {projectedMaxY_=f;}
+
+	void  mapFromSceneToProjectionCoords(QPointF&,QPointF&) ;
+	string  mapFromSceneToTransformationDefinition(QPointF&,QPointF&) ;
+	void  mapFromSceneToGeoCoords(const QPointF&,QPointF&); 
+	void  mapFromSceneToGeoCoords(QRectF&,QList<QPointF>&); 
+	void  mapFromGeoToSceneCoords(const QPointF&,QPointF&);
+
+	bool containsSceneCoords(QPointF&);
+	bool containsGeoCoords(QPointF&);
+	bool containsPoint(QPointF&, qreal tolerance=0.0001);
+
+	QGraphicsItem* parentItemInMainScene() {return parentItemInMainScene_;}
+	void setParentItemInMainScene(QGraphicsItem* p) {parentItemInMainScene_=p;}
+
+	void addToMainScene();
+	
+
+protected:
+	const Layout& layout_;	
+
+	double coordRatioX_;
+	double coordRatioY_;
+	
+	double dimensionX_;	
+	double dimensionY_;
+
+	double projectedMinX_;
+	double projectedMinY_;
+	double projectedMaxX_;
+	double projectedMaxY_;
+
+	QGraphicsItem *parentItemInMainScene_;
+	//AnimationRules *animationRules_;			
+};
+
+
+class MgQPreviewLayoutItem : public MgQLayoutItem
+{
+public:
+	enum {Type = MgQ::PreviewLayoutItemType}; 
+
+	MgQPreviewLayoutItem(const Layout &l) : MgQLayoutItem(l)  {};
+	int type() const {return Type;}
+};
+
+class MgQMagnifierLayoutItem : public MgQLayoutItem
+{
+public:
+	enum {Type = MgQ::MagnifierLayoutItemType}; 
+	
+	MgQMagnifierLayoutItem(MgQLayoutItem*);
+	MgQMagnifierLayoutItem(const Layout &l) : MgQLayoutItem(l) {}; 
+	const MagnifierLayout& layout() {return (MagnifierLayout&) layout_;};
+	void clearPlotContents();
+
+	const QVector<QPointF>& area() const {return area_;}
+	double resolutionX() {return resolutionY_;}
+	double resolutionY() {return resolutionY_;}
+	AnimationStep* step() {return step_;}
+	double zoomFactor() {return zoomFactor_;}
+
+	void setArea(const QVector<QPointF> area) {area_=area;}
+	void setResolutionX(double r) {resolutionX_=r;}
+	void setResolutionY(double r) {resolutionY_=r;}
+	void setStep(AnimationStep *step) {step_=step;}
+	void setZoomFactor(double zoomFactor) {zoomFactor_=zoomFactor;}
+
+	QRectF boundingRect() const;
+	int type() const {return Type;}	
+
+protected:
+	QVector<QPointF> area_;
+	double resolutionX_;
+	double resolutionY_;
+	AnimationStep *step_;	
+	double zoomFactor_;
+};
+
+
+//}
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQPathItem.cc b/src/drivers/MgQ/MgQPathItem.cc
new file mode 100644
index 0000000..26d8e2d
--- /dev/null
+++ b/src/drivers/MgQ/MgQPathItem.cc
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPathItem.cc
+    \brief Definition of MgQPathItem
+    \author Graphics Section, ECMWF
+
+    Started: March 2010
+*/
+
+#include "MgQPathItem.h"
+
+#include <QDebug>
+#include <QPainter>
+
+//static int count=0;
+
+
+MgQPathItem::MgQPathItem(const QPainterPath& path,QGraphicsItem* parent) : 
+	QGraphicsPathItem(path,parent)
+{
+
+}
+
+MgQPathItem::~MgQPathItem()
+{	
+
+}
+
+QRectF MgQPathItem::boundingRect() const
+{
+	//qDebug() << "PIXMAP" << QGraphicsPathItem::boundingRect();
+	//qDebug() << "PIXMAP" << targetRect_;
+
+	//return QGraphicsPathItem::boundingRect();
+	float w=boundingRectSize_;
+	return QRectF(-w/2.,-w/2.,w/2.,w/2.);
+}
+
+void MgQPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                QWidget *widget)
+{
+	/*if(parentItem()->data(3).toRectF() != QRectF())
+	{		
+		QPolygonF p= mapFromScene(parentItem()->data(3).toRectF()); 
+		if(p.boundingRect().intersects(boundingRect()) == false)
+		{
+			return;
+		}
+	}*/
+
+	QGraphicsPathItem::paint(painter,option,widget);
+
+	//count++;
+
+	//qDebug() << "count" << count;	
+
+	//QGraphicsPathItem::paint(painter,option,widget);
+	//painter->drawPath(QRectF(0,0,targetRect_.width(),targetRect_.height()),
+	//		    path(),
+	//		    QRectF(0,0,pixmap().width(),pixmap().height()));
+}
diff --git a/src/drivers/MgQ/MgQPathItem.h b/src/drivers/MgQ/MgQPathItem.h
new file mode 100644
index 0000000..999d811
--- /dev/null
+++ b/src/drivers/MgQ/MgQPathItem.h
@@ -0,0 +1,54 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPathItem.h
+    \brief Definition of MgQPathItem.
+    \author Graphics Section, ECMWF
+
+    Started: March 2010
+*/
+
+#ifndef _MgQPathItem_H
+#define _MgQPathItem_H
+
+#include <QGraphicsPathItem>
+
+#include "MgQ.h"
+
+class MgQPathItem : public QGraphicsPathItem
+{
+public:
+	enum {Type = MgQ::PathItemType}; 
+	
+	MgQPathItem(const QPainterPath& ,QGraphicsItem* parent = 0);
+	~MgQPathItem();
+	
+	void setBoundingRectSize(float s) {boundingRectSize_=s;}
+	QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+	int type() const {return Type;}
+
+protected:
+	float boundingRectSize_;
+};	
+
+#endif
diff --git a/src/drivers/MgQ/MgQPattern.cc b/src/drivers/MgQ/MgQPattern.cc
new file mode 100644
index 0000000..0f3c593
--- /dev/null
+++ b/src/drivers/MgQ/MgQPattern.cc
@@ -0,0 +1,189 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPattern.h
+    \brief Definition of MgQPattern
+    \author Graphics Section, ECMWF
+
+    Started: Feb 2011
+*/
+
+#include "MgQPattern.h"
+
+#include <QDebug>
+#include <QPainter>
+
+//====================================
+//
+//  Properties
+//
+//====================================
+
+MgQPatternProperties::MgQPatternProperties(Type type) : type_(type), bg_(QColor(255,255,255,0))
+{
+
+}
+
+bool MgQPatternProperties::operator==(const MgQPatternProperties& p) const
+{
+	if(p.type_ != type_) 
+		return false;
+
+	if(type_==DotShading)
+	{
+		return p.size_ == size_ && p.itemSize_ == itemSize_ &&
+		       p.bg_ == bg_ && p.colour_ == colour_;
+
+	}
+	else if(type_==HatchShading)
+	{
+		return p.size_ == size_ && p.id_ == id_ && p.lineWidth_ == lineWidth_ &&
+		       p.bg_ == bg_ && p.colour_ == colour_;
+
+	}
+}
+
+//====================================
+//
+//  Pattern
+//
+//====================================
+
+MgQPattern::MgQPattern(const MgQPatternProperties &prop) : QPixmap(prop.size_), prop_(prop)
+{
+	if(prop.type_ == MgQPatternProperties::DotShading)
+	{
+		fill(prop.bg_);
+
+		if(prop_.itemSize_.width() < 1)
+			return;
+
+		QPainter p(this);	
+
+		if(prop_.itemSize_.width()== 1)
+		{
+			p.setPen(prop_.colour_);
+			p.drawPoint(width()/2,height()/2);
+			
+		}
+		else if(prop_.itemSize_.width() < 4)
+		{
+			p.fillRect(QRectF((width()-prop_.itemSize_.width())/2.,(height()-prop_.itemSize_.height())/2.,
+			   prop_.itemSize_.width(),prop_.itemSize_.height()),
+			   prop_.colour_);
+		}
+		else
+		{
+			p.setRenderHint(QPainter::Antialiasing,true);
+			p.setPen(prop_.colour_);
+			p.setBrush(prop_.colour_);
+			p.drawEllipse(QRectF((width()-prop_.itemSize_.width())/2.,(height()-prop_.itemSize_.height())/2.,
+			   prop_.itemSize_.width(),prop_.itemSize_.height()));
+		}
+
+	}
+	else if(prop.type_ ==  MgQPatternProperties::HatchShading)
+	{
+		fill(prop.bg_);
+			
+		QPainter p(this);
+
+		QPen pen(prop_.colour_);
+		pen.setWidthF(prop_.lineWidth_);
+		p.setPen(pen);
+
+		int index = prop_.id_.toInt();
+
+		int w=width();
+		int h=height();
+
+		if(index==1 || index==3) // horizontal
+		{			
+			p.drawLine(QPointF(0,h*0.5),QPointF(w-1,h*0.5));					
+		}		
+		if(index==2 || index==3) // vertical
+		{			
+			p.drawLine(QPointF(w*0.5,0),QPointF(w*0.5,h-1));					
+		}
+		if(index==4 || index==6) 
+		{		
+			p.drawLine(QPointF(0,0),QPointF(w-1,h-1));
+		}
+		if(index==5 || index==6) 
+		{		
+			p.drawLine(QPointF(0,h-1),QPointF(w-1,0));
+		}
+	}
+}
+
+//====================================
+//
+//  Manager
+//
+//====================================
+
+MgQPatternManager::~MgQPatternManager()
+{	
+	foreach(MgQPattern *item, patterns_)
+	{		
+		delete item;
+	}
+}
+
+MgQPattern* MgQPatternManager::getPattern(MgQPatternProperties& p)
+{	
+	foreach(MgQPattern *item, patterns_) 
+	{
+		if( item->properties() == p)
+		{
+			return item;
+		}
+	}
+	
+	return 0;		
+}
+
+MgQPattern* MgQPatternManager::addPattern(MgQPatternProperties& p)
+{
+	MgQPattern *pix = getPattern(p);
+
+	if(pix) 
+	{
+		return pix;
+	}
+	
+	pix=new MgQPattern(p);
+	patterns_ <<  pix;
+	return pix;	
+}
+
+void MgQPatternManager::deletePattern(MgQPatternProperties& p)	
+{	
+	foreach(MgQPattern *item, patterns_)
+	{
+		if( item->properties() == p)
+		{
+			delete item;
+			return;
+		}	
+	}
+}	
+
diff --git a/src/drivers/MgQ/MgQPattern.h b/src/drivers/MgQ/MgQPattern.h
new file mode 100644
index 0000000..7fdc28a
--- /dev/null
+++ b/src/drivers/MgQ/MgQPattern.h
@@ -0,0 +1,83 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPattern.h
+    \brief Definition of MgQPattern.
+    \author Graphics Section, ECMWF
+
+    Started: Feb 2011
+*/
+
+#ifndef _MgQPattern_H
+#define _MgQPattern_H
+
+#include <QList>
+#include <QPixmap>
+#include <QString>
+
+
+class MgQPatternProperties
+{
+public:
+	enum Type {DotShading,HatchShading,Symbol};
+
+	MgQPatternProperties(Type);
+	bool operator==(const MgQPatternProperties&) const;
+
+	Type type_;
+	QString id_;
+	QSize size_;
+	QSize itemSize_;
+	float lineWidth_;
+	QColor colour_;
+	QColor bg_;	
+};
+
+class MgQPattern : public QPixmap
+{
+public:
+	MgQPattern(const MgQPatternProperties&);
+	//bool equal(MgQPatternProperties);
+	const QPixmap& pixmap() {return *this;}
+	const MgQPatternProperties& properties() {return prop_;}
+
+protected:
+	MgQPatternProperties prop_;
+};
+
+class MgQPatternManager
+{
+public:
+	MgQPatternManager() {};
+	~MgQPatternManager();
+ 
+	MgQPattern* addPattern(MgQPatternProperties&);
+	MgQPattern* getPattern(MgQPatternProperties&);	
+	void deletePattern(MgQPatternProperties&);		
+
+	//int    symbolNum() {return symbols_.count();};	
+
+protected:
+	QList<MgQPattern*> patterns_;
+};	
+
+
+#endif 
diff --git a/src/drivers/MgQ/MgQPixmapItem.cc b/src/drivers/MgQ/MgQPixmapItem.cc
new file mode 100644
index 0000000..e3149f7
--- /dev/null
+++ b/src/drivers/MgQ/MgQPixmapItem.cc
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPixmapItem.cc
+    \brief Definition of MgQPixmapItem
+    \author Graphics Section, ECMWF
+
+    Started: February 2010
+*/
+
+#include "MgQPixmapItem.h"
+
+#include <QDebug>
+#include <QPainter>
+
+MgQPixmapItem::MgQPixmapItem(const QPixmap& pixmap,QGraphicsItem* parent) : 
+	QGraphicsPixmapItem(pixmap,parent)
+{
+
+}
+
+MgQPixmapItem::~MgQPixmapItem()
+{	
+
+}
+
+QRectF MgQPixmapItem::boundingRect() const
+{
+	//qDebug() << "PIXMAP" << QGraphicsPixmapItem::boundingRect();
+	//qDebug() << "PIXMAP" << targetRect_;
+
+	//return QGraphicsPixmapItem::boundingRect();
+	return QRectF(0,0,targetRect_.width(),targetRect_.height());
+}
+
+void MgQPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                QWidget *widget)
+{
+	if(!clipRect_.isEmpty())
+		painter->setClipRect(clipRect_);
+
+	painter->setBackgroundMode(Qt::TransparentMode);
+
+	//QGraphicsPixmapItem::paint(painter,option,widget);
+	painter->drawPixmap(QRectF(0,0,targetRect_.width(),targetRect_.height()),
+			    pixmap(),
+			    QRectF(0,0,pixmap().width(),pixmap().height()));
+}
+
+void MgQPixmapItem::setClipRect(QRectF rect)
+{
+	clipRect_=rect;
+}
diff --git a/src/drivers/MgQ/MgQPixmapItem.h b/src/drivers/MgQ/MgQPixmapItem.h
new file mode 100644
index 0000000..14d62f9
--- /dev/null
+++ b/src/drivers/MgQ/MgQPixmapItem.h
@@ -0,0 +1,57 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPixmapItem.h
+    \brief Definition of MgQPixmapItem.
+    \author Graphics Section, ECMWF
+
+    Started: Feb 2010
+*/
+
+#ifndef _MgQPixmapItem_H
+#define _MgQPixmapItem_H
+
+#include <QGraphicsPixmapItem>
+
+#include "MgQ.h"
+
+class MgQPixmapItem : public QGraphicsPixmapItem
+{
+public:
+	enum {Type = MgQ::PixmapItemType}; 
+	
+	MgQPixmapItem(const QPixmap& pixmap,QGraphicsItem* parent = 0);
+	~MgQPixmapItem();
+	
+	void setTargetRect(QRectF r) {targetRect_=r;}
+	QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+	void setClipRect(QRectF);
+	int type() const {return Type;}
+
+protected:
+	QRectF targetRect_;
+	QRectF clipRect_;
+
+};	
+
+#endif 
diff --git a/src/drivers/MgQ/MgQPlotScene.cc b/src/drivers/MgQ/MgQPlotScene.cc
new file mode 100644
index 0000000..0f87615
--- /dev/null
+++ b/src/drivers/MgQ/MgQPlotScene.cc
@@ -0,0 +1,550 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPlotScene.cc
+    \brief Definition of MgQPlotScene
+    \author Graphics Section, ECMWF
+
+    Started: March 2010
+*/
+
+
+#include "MgQPlotScene.h"
+
+#include <QDebug>
+#include <QGraphicsItem>
+#include <QGraphicsRectItem>
+#include <QImage>
+#include <QPixmap>
+#include <QPainter>
+#include <QProgressDialog>
+#include <QStyleOptionGraphicsItem>
+
+#include "MgQDriverObject.h"
+#include "MgQHistoItem.h"
+#include "MgQLayerItem.h"
+#include "MgQLayoutItem.h"
+#include "MgQRootItem.h"
+#include "MgQSceneCacheItem.h"
+#include "MgQSceneItem.h"
+#include "MgQStepMetaData.h"
+
+
+MgQPlotScene::MgQPlotScene(QObject *parent) : 
+	MgQScene(parent),
+	ignoreSceneItemChange_(false)
+{
+	
+	dpiResolution_=75;
+	
+	driverObject_=0;
+
+	currentSceneItemIndex_=-1;
+	sceneLayerItem_=0;
+	previewLayoutItem_=0;
+
+	//cacheDevice_=new QPixmap(900,700);
+	
+	//Cache
+	
+	cacheDevice_=new QPixmap(2000,1500);
+
+	cacheItem_=new MgQSceneCacheItem(cacheDevice_);
+	addItem(cacheItem_);
+	
+	cachePainter_=new QPainter(cacheDevice_);
+	cacheDevice_->fill(qRgba(255,255,255,255));
+
+	antialias_=false;
+	cachePainter_->setRenderHint(QPainter::Antialiasing,antialias_);
+
+	highlightItem_=0;
+	highlightedSceneItem_=0;
+
+	highlightItemForBrief_=0;
+
+	stepNum_=0;
+	
+	connect(this,SIGNAL(sceneRectChanged(const QRectF&)),
+		this,SLOT(slotSceneRectChanged(const QRectF&)));
+}
+ 
+MgQPlotScene::~MgQPlotScene()
+{
+	if(sceneLayerItem_)
+  		delete sceneLayerItem_;
+	
+  	if(driverObject_)
+		delete driverObject_;
+
+	foreach(QList<MgQLayerState*> sc,previousSceneState_)
+	{
+		foreach(MgQLayerState* st, sc)
+		{
+		  	delete st;
+		}
+		sc.clear();
+	}		
+}
+
+void MgQPlotScene::clearBeforeNewRequest()
+{
+	prevSceneItemCurrentStep_.clear();
+	
+	//Animation
+	foreach(MgQSceneItem* item,sceneItems_)
+	{  
+		prevSceneItemCurrentStep_ << item->currentStep();	
+	}
+	
+	//we do not delete annotations
+	plotRootItem_->clearContents();
+
+	sceneItems_.clear();
+	layerItems_.clear();
+
+	if(sceneLayerItem_)
+	{
+		delete sceneLayerItem_;
+	}
+
+	sceneLayerItem_=0;
+	previewLayoutItem_=0;
+	stepNum_=0;
+	highlightedSceneItem_=0;
+}
+
+void MgQPlotScene::saveStateBeforeNewRequest()
+{
+  	foreach(QList<MgQLayerState*> sc,previousSceneState_)
+	{
+		foreach(MgQLayerState* st, sc)
+		{
+		  	delete st;
+		}
+		sc.clear();
+	}	
+	previousSceneState_.clear();
+
+	for(int i=0; i < sceneItems_.count(); i++)
+	{  
+		QList<MgQLayerState*> vec;
+		
+		foreach(MgQLayerItem *layer,sceneItems_[i]->layerItems())  
+		{	
+			MgQLayerState *st=new MgQLayerState;
+			layer->saveLayerState(st);
+			vec << st;
+		}	
+		previousSceneState_ << vec;
+		
+	}
+}
+//Temporary solution until layers handled properly in Metview 4
+void MgQPlotScene::restoreLayerState()
+{	
+  	/*qDebug() << "restoreLayerState";
+  	foreach(QList<MgQLayerState*> sc,previousSceneState_)
+	{
+		qDebug() << "restoreLayerState";
+		
+		foreach(MgQLayerState* st, sc)
+		{
+		  qDebug() << "  " << st->name_ << st->id_ << st->stackLevel_ << st->alpha_ << st->visible_;	
+		}
+	}*/
+	
+	if(sceneItems_.count() != previousSceneState_.count())
+		return;  
+	
+	
+	for(int i=0; i < sceneItems_.count(); i++)
+	{  
+		bool sameNum=(sceneItems_[i]->layerItems().count() == previousSceneState_[i].count())?true:false;
+	  
+		int sameNameCnt=0;
+		
+	  	QSet<QString> usedNames;
+		MgQLayerState stAct;
+		for(int indexAct=0; indexAct < sceneItems_[i]->layerItems().count(); indexAct++)  
+		{	
+			MgQLayerItem *layer=sceneItems_[i]->layerItems().at(indexAct);			
+			layer->saveLayerState(&stAct);	  
+		  	for(int indexPrev=0; indexPrev < previousSceneState_[i].count(); indexPrev++)
+			{  
+				MgQLayerState *stPrev=previousSceneState_[i].at(indexPrev);
+			  	if(stPrev->name_ == stAct.name_ && !usedNames.contains(stAct.name_))
+				{
+				  	layer->setLayerVisibility(stPrev->visible_);						
+					layer->setLayerAlpha(stPrev->alpha_);		
+					sameNameCnt++;
+					usedNames << stAct.name_;
+					break;
+				}
+				
+			}
+			
+		}
+		
+		//If we have the same number of layers as before and the new and old names 
+		//are the same (so the layers can be matched) we set the stack level!!!
+		if(sameNum && sameNameCnt == sceneItems_[i]->layerItems().count())
+		{
+			for(int indexAct=0; indexAct < sceneItems_[i]->layerItems().count(); indexAct++)  
+			{	
+				MgQLayerItem *layer=sceneItems_[i]->layerItems().at(indexAct);			
+				layer->saveLayerState(&stAct);	  
+		  		for(int indexPrev=0; indexPrev < previousSceneState_[i].count(); indexPrev++)
+				{  
+					MgQLayerState *stPrev=previousSceneState_[i].at(indexPrev);
+			  		if(stPrev->name_ == stAct.name_)
+					{
+						layer->setStackLevel(stPrev->stackLevel_);		
+					}
+				}
+			}
+		}	
+		 
+				
+	}		  				
+}	
+ 
+void MgQPlotScene::addSceneItem(MgQSceneItem *item)
+{
+  	//item->setParentItem(plotRootItem_);
+	sceneItems_ << item;
+	
+	if(prevSceneItemCurrentStep_.count() >= sceneItems_.count())
+	{
+	  	int i=sceneItems_.count()-1;
+		sceneItems_[i]->setPrevCurrentStep(prevSceneItemCurrentStep_[i]);
+	}	
+		
+	//connect(item,SIGNAL(changed()),
+	//	this,SLOT(slotSceneItemChanged()));
+}
+
+void MgQPlotScene::setCurrentSceneItem(MgQSceneItem *item)
+{
+    	currentSceneItemIndex_=sceneItems_.indexOf(item);
+}  
+
+
+MgQSceneItem* MgQPlotScene::currentSceneItem()
+{
+	if(currentSceneItemIndex_ >=0 && currentSceneItemIndex_ < sceneItems_.count())  
+	{
+	  	return sceneItems_[currentSceneItemIndex_];
+	}
+	return 0;
+}	
+
+MgQLayoutItem* MgQPlotScene::firstProjectorItem()
+{
+	foreach(MgQSceneItem* item,sceneItems_)
+	{  
+		MgQLayoutItem* res=item->firstProjectorItem();
+		if(res)
+		  	return res;
+	}
+	
+	return 0;
+}
+
+MgQLayoutItem* MgQPlotScene::findProjectorItem(QPointF scenePos)
+{
+	foreach(MgQSceneItem* item,sceneItems_)
+	{  
+		MgQLayoutItem* res=item->findProjectorItem(scenePos);
+		if(res)
+		  	return res;
+	}
+	
+	return 0;
+}
+
+MgQSceneItem* MgQPlotScene::findSceneItem(QPointF scenePos)
+{
+	foreach(MgQSceneItem* item,sceneItems_)
+	{  
+		if(item->sceneBoundingRect().contains(scenePos))
+	  		return item;
+	}
+	return 0;  
+} 
+
+
+bool MgQPlotScene::identifyPos(QPointF scenePos, MgQSceneItem** sceneItem,MgQLayoutItem** projectorItem)
+{
+	MgQSceneItem *scn=*sceneItem;
+  	MgQLayoutItem *prn=0;
+  			
+	//Find zoomable layout, i.e. subpage!!!
+	if(scn)
+	{
+		prn=scn->findProjectorItem(scenePos);		
+		if(prn == 0)
+		{
+			scn=findSceneItem(scenePos);
+			if(scn)	
+			{
+			  	prn=scn->findProjectorItem(scenePos);
+			}
+		}
+	}
+	else
+	{  
+		scn=findSceneItem(scenePos);
+		if(scn)	
+		{
+			  prn=scn->findProjectorItem(scenePos);
+		}
+	}
+	
+	
+	*sceneItem=scn;
+	*projectorItem=prn;
+	
+	
+	return (scn && prn);
+}	
+	
+void MgQPlotScene::updateCache()
+{
+	if ( !plotRootItem_ )
+		return;
+	
+	if(cacheDevice_->width() < sceneRect().width() || 
+	   cacheDevice_->height() < sceneRect().height())
+	{
+		delete cachePainter_;
+		delete cacheDevice_;
+
+		cacheDevice_=new QPixmap(sceneRect().width()+100,sceneRect().height()+100);
+
+		cachePainter_=new QPainter(cacheDevice_);	
+		cachePainter_->setRenderHint(QPainter::Antialiasing,antialias_);
+		
+		cacheItem_->setPixmap(cacheDevice_);
+				
+		MagLog::debug() << "MgQPlotScene::updateCache() ---> Pixmap size changed to: "  <<
+		          cacheDevice_->width() << "x" << cacheDevice_->height() << endl;
+			  
+	}
+	
+	cacheItem_->setClipRect(sceneRect());
+	
+	QPainter *painter=cachePainter_;
+	QStyleOptionGraphicsItem options;
+
+	QRectF sourceRect = sceneRect();
+        QRectF targetRect(0, 0, painter->device()->width(), painter->device()->height());
+
+	cacheDevice_->fill(qRgba(255,255,255,255));
+
+	painter->save();
+
+	QTransform painterTransform;
+    	painterTransform *= QTransform()
+                        .translate(targetRect.left(), targetRect.top())
+                        //.scale(xratio, yratio)
+                        .translate(-sourceRect.left(), -sourceRect.top());
+    	painter->setWorldTransform(painterTransform, true);
+
+	plotRootItem_->setVisible(false);
+
+	renderItemRecursively(plotRootItem_,painter,&options);
+
+	plotRootItem_->setVisible(false);
+
+	/*foreach(QGraphicsItem *item, items(Qt::AscendingOrder))
+	{
+		if(item->zValue() < 1.2 && item->isVisible())
+		{
+			painter->save();
+          		painter->setTransform(item->sceneTransform(), true);
+          		item->paint(painter, &options, 0);
+          		painter->restore();			
+		}
+	}*/
+
+	painter->restore();
+
+	QPen pen(Qt::black);
+	pen.setWidth(2);
+	painter->setPen(pen);
+	painter->drawRect(targetRect);
+	
+	//cacheDevice_->save("/var/tmp/cgr/test.png");
+
+	//rootItem_->setFlag(QGraphicsItem::ItemHasNoContents,true);
+	plotRootItem_->setVisible(false); 
+
+	//cacheItem_->setPixmap(*cacheDevice_);
+	
+	//setBackgroundBrush(QPixmap::fromImage(*cacheDevice_));
+}
+
+void MgQPlotScene::renderForMagnifier(QPainter *painter, const QRectF &targetRect, const QRectF &sourceRect)
+{
+	QStyleOptionGraphicsItem option;
+	painter->setRenderHint(QPainter::Antialiasing,antialias_);
+	renderContents(painter,&option,targetRect,sourceRect,true);
+}
+
+void MgQPlotScene::drawBackground ( QPainter * painter, const QRectF & rect ) 
+{	
+	/*qDebug() << "bg" << rect << sceneRect();
+
+	QRectF targetRect(0, 0, sceneRect().width(), sceneRect().height());
+	//painter->drawPixmap(sceneRect(),*cacheDevice_,targetRect);
+
+	painter->drawPixmap(rect,*cacheDevice_,rect);*/
+}
+
+void MgQPlotScene::updateAfterNewRequest()
+{	
+  	ignoreSceneItemChange_=true;
+	
+	foreach(MgQSceneItem* item,sceneItems_)
+	{  
+		item->selectCurrentStepForAnimation();
+		item->renderLayerPreview();
+	}
+		
+	ignoreSceneItemChange_=false;	
+}
+
+
+void MgQPlotScene::sceneItemChanged()
+{
+	if(!ignoreSceneItemChange_)
+	{
+	  	updateCache();
+		update();
+	}	
+}
+
+void MgQPlotScene::setEnableAntialias(bool status)
+{
+	if(antialias_!=status)
+	{
+		antialias_=status;
+		cachePainter_->setRenderHint(QPainter::Antialiasing,antialias_);
+
+		updateCache();
+		update();
+	}
+}
+
+void MgQPlotScene::highlightSceneItem(MgQSceneItem* item, bool status)
+{
+	if(!highlightItem_)
+	{
+	  	highlightItem_=new QGraphicsRectItem;
+		highlightItem_->setBrush(QColor(0,0,255,10));
+		QPen pen(QColor(0,0,0,100));
+		pen.setWidth(2);
+		highlightItem_->setPen(pen);
+		
+		highlightItem_->setVisible(false);
+		//highlightItem_->setScale(plotRootItem_->scale());
+		addItem(highlightItem_);		
+	}
+		
+	if(status && item)
+	{
+		 highlightItem_->setRect(item->sceneBoundingRect());
+		 highlightItem_->setVisible(true);
+		 highlightedSceneItem_=item;
+	}
+	else
+	{
+		 highlightItem_->setVisible(false);
+	}
+}	
+
+
+void MgQPlotScene::highlightSceneItemForBrief(MgQSceneItem* item,bool status)
+{
+  	if(!highlightItemForBrief_)
+	{
+	  	highlightItemForBrief_=new QGraphicsRectItem;
+		highlightItemForBrief_->setBrush(QColor(255,0,0,10));
+		QPen pen(QColor(0,0,0,100));
+		pen.setWidth(2);
+		highlightItemForBrief_->setPen(pen);
+		
+		highlightItemForBrief_->setVisible(false);
+		//highlightItem_->setScale(plotRootItem_->scale());
+		addItem(highlightItemForBrief_);		
+	}
+		
+	if(status && item)
+	{
+		 highlightItemForBrief_->setRect(item->sceneBoundingRect());
+		 highlightItemForBrief_->setVisible(true);
+		 //highlightedSceneItem_=item;
+	}
+	else
+	{
+		 highlightItemForBrief_->setVisible(false);
+	}  
+}
+
+void MgQPlotScene::setPlotScale(float scaling, PlotScaleMode mode)
+{
+	if(mode == RelativeToCurrentSize)
+	{  	
+		float currentScaling=plotRootItem_->scale();
+		float newScaling=scaling*currentScaling;
+				
+		plotRootItem_->setScale(newScaling);
+		annotationRootItem_->setScale(newScaling);
+		QRectF r=sceneRect();
+		r.setWidth(r.width()*scaling);
+		r.setHeight(r.height()*scaling);
+		setSceneRect(r);
+	}
+	else if(mode == RelativeToOriSize)
+	{
+		plotRootItem_->setScale(scaling);
+		annotationRootItem_->setScale(scaling);
+		QRectF r=oriSceneRect_;
+		r.setWidth(r.width()*scaling);
+		r.setHeight(r.height()*scaling);
+		setSceneRect(r);
+	}	
+}			
+
+float MgQPlotScene::plotScale()
+{
+ 	return plotRootItem_->scale();	
+}	
+			
+void MgQPlotScene::slotSceneRectChanged(const QRectF& rect)
+{
+	if(highlightItem_ &&  highlightedSceneItem_ && highlightItem_->isVisible())
+	{
+		 highlightItem_->setRect(highlightedSceneItem_->sceneBoundingRect());
+		 //highlightItem_->setScale(plotRootItem_->scale()); 
+	}
+}	
\ No newline at end of file
diff --git a/src/drivers/MgQ/MgQPlotScene.h b/src/drivers/MgQ/MgQPlotScene.h
new file mode 100644
index 0000000..fb6e793
--- /dev/null
+++ b/src/drivers/MgQ/MgQPlotScene.h
@@ -0,0 +1,144 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPlotScene.h
+    \brief Definition of MgQPlotScene.
+    \author Graphics Section, ECMWF
+
+    Started: March 2010
+*/
+
+#ifndef MgPlotScene_H
+#define MgQPlotScene_H
+
+#include <QGraphicsScene>
+#include <QMap>
+
+#include "QtDriver.h"
+#include "MgQScene.h"
+
+// for AIX compiler which fails when we have two definition of a macro
+// (gcc also complains, but does not fail)
+// in any case, we do not use the macro, so removing it should be safe
+#undef ABS
+
+class QGraphicsRectItem;
+class QProgressDialog;
+
+class MgQDriverObject;
+class MgQLayerItem;
+class MgQLayerState;
+class MgQLayoutItem;
+class MgQPreviewLayoutItem;
+class MgQRootItem;
+class MgQSceneCacheItem;
+class MgQSceneItem;
+class MgQSceneLayerItem;
+class MgQStepMetaData;
+
+using magics::Layer;
+using magics::SceneLayer;
+
+class MgQPlotScene : public MgQScene
+{
+
+  Q_OBJECT
+  
+public:
+	MgQPlotScene(QObject *parent=0);
+	~MgQPlotScene();
+	
+	enum PlotScaleMode {RelativeToCurrentSize,RelativeToOriSize};
+	
+	void clearBeforeNewRequest();
+	void saveStateBeforeNewRequest();
+	void restoreLayerState();
+	
+	void addSceneItem(MgQSceneItem*);
+	MgQSceneItem* currentSceneItem();
+	void setCurrentSceneItem(MgQSceneItem*);	
+	QList<MgQSceneItem*> sceneItems() {return sceneItems_;}
+	MgQSceneItem* findSceneItem(QPointF);
+
+	QRectF oriSceneRect() {return oriSceneRect_;}
+	void setOriSceneRect(QRectF r) {oriSceneRect_=r;}
+
+	MgQLayoutItem* firstProjectorItem();
+	MgQLayoutItem* findProjectorItem(QPointF);
+	MgQLayoutItem* projectorItem(QPointF p) {return findProjectorItem(p);}
+	bool identifyPos(QPointF,MgQSceneItem**,MgQLayoutItem**);
+
+	void setEnableAntialias(bool);
+	void updateAfterNewRequest();	
+	void renderForMagnifier(QPainter *, const QRectF &, const QRectF &);
+    
+        void sceneItemChanged();
+	void highlightSceneItem(MgQSceneItem*, bool );	
+	void highlightSceneItemForBrief(MgQSceneItem*, bool );	
+	void setPlotScale(float, PlotScaleMode);
+	float plotScale();
+	
+	void setDpiResolution(int r) {dpiResolution_=r;}
+	int dpiResolution() {return dpiResolution_;}
+
+public slots:	
+	void slotSceneRectChanged(const QRectF&);
+
+protected:	
+	void updateCache();
+	void drawBackground ( QPainter * painter, const QRectF & rect ); 
+	
+	bool ignoreSceneItemChange_;
+	
+	QList<int> prevSceneItemCurrentStep_;
+	int stepNum_;
+
+	QRectF magnifierSceneRect_;
+	float  magnifierFactor_;
+
+	MgQPreviewLayoutItem* previewLayoutItem_;
+	QList<MgQSceneItem*> sceneItems_;
+	int currentSceneItemIndex_;
+	
+	QGraphicsRectItem* highlightItem_;
+	MgQSceneItem* highlightedSceneItem_;
+	
+	QGraphicsRectItem* highlightItemForBrief_;
+		
+	MgQSceneLayerItem *sceneLayerItem_;
+	QList<MgQLayerItem*> layerItems_;
+	QList<QList<MgQLayerState*> > previousSceneState_;
+	
+	MgQDriverObject *driverObject_;
+
+	QPixmap *cacheDevice_;
+	QPainter* cachePainter_;
+	MgQSceneCacheItem*  cacheItem_;
+
+	bool antialias_;
+	QRectF oriSceneRect_;
+	
+	int dpiResolution_;
+};
+
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQPolylineSetItem.cc b/src/drivers/MgQ/MgQPolylineSetItem.cc
new file mode 100644
index 0000000..158d87a
--- /dev/null
+++ b/src/drivers/MgQ/MgQPolylineSetItem.cc
@@ -0,0 +1,216 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPolylineSetItem.cc
+    \brief Definition of MgQPolylineSetItem
+    \author Graphics Section, ECMWF
+
+    Started: April 2010
+*/
+
+#include "MgQPolylineSetItem.h"
+
+#include <QDebug>
+#include <QPainter>
+
+//static int count=0;
+
+
+MgQPolylineSetItem::MgQPolylineSetItem(QRectF &boundingRect,QGraphicsItem* parent) : 
+	QGraphicsItem(parent)
+{
+	boundingRect_=boundingRect;
+}
+
+MgQPolylineSetItem::~MgQPolylineSetItem()
+{	
+	for(int i=0; i < polylines_.count(); i++)
+	{
+		if( polylines_[i]->points_)
+			delete [] polylines_[i]->points_;
+		if( polylines_[i]->path_)
+			delete [] polylines_[i]->path_;
+	}	
+}
+
+QRectF MgQPolylineSetItem::boundingRect() const
+{
+	//qDebug() << "PIXMAP" << QGraphicsPolylineSetItem::boundingRect();
+	//qDebug() << "PIXMAP" << targetRect_;
+
+	//return QGraphicsPolylineSetItem::boundingRect();
+	//float w=boundingRectSize_;
+	//return QRectF(-w/2.,-w/2.,w/2.,w/2.);
+	return boundingRect_;
+}
+
+void MgQPolylineSetItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                QWidget *widget)
+{
+	/*if(parentItem()->data(3).toRectF() != QRectF())
+	{		
+		QPolygonF p= mapFromScene(parentItem()->data(3).toRectF()); 
+		if(p.boundingRect().intersects(boundingRect()) == false)
+		{
+			return;
+		}
+	}*/
+
+	int brushIndex,penIndex;
+	int prevBrushIndex=-1,prevPenIndex=-1;
+
+	//qDebug() <<  "POLYLINESET" << polylines_.count() << painter->clipRegion() << painter->transform().mapRect(boundingRect_);
+
+	bool antialias=painter->renderHints() & QPainter::Antialiasing;
+	
+	for(int i=0; i < polylines_.count(); i++)
+	{
+		penIndex=polylines_[i]->penIndex_;
+		if(penIndex != prevPenIndex)
+		{
+			painter->setPen(penList_[penIndex]);
+			prevPenIndex=penIndex;
+		}
+
+		brushIndex=polylines_[i]->brushIndex_;
+		if(brushIndex != prevBrushIndex)
+		{
+			painter->setBrush(brushList_[brushIndex]);
+			prevBrushIndex=brushIndex;
+		}
+	
+		
+		if(brushList_[brushIndex] != Qt::NoBrush &&
+		   penList_[penIndex] == Qt::NoPen)
+		{
+			painter->setRenderHint(QPainter::Antialiasing,false);  
+		}
+	
+		if(polylines_[i]->num_==0 && polylines_[i]->path_ != 0)
+		{
+		  	painter->drawPath(*(polylines_[i]->path_));
+		}			
+		else
+		{
+			if(polylines_[i]->num_==2)
+			{
+				painter->drawLine(polylines_[i]->points_[0],polylines_[i]->points_[1]);
+			}		
+			else if(polylines_[i]->isPolygon_)
+			{
+				painter->drawPolygon(polylines_[i]->points_,polylines_[i]->num_);
+			}
+			else
+			{
+				painter->drawPolyline(polylines_[i]->points_,polylines_[i]->num_);
+			}
+		
+		}
+		
+		painter->setRenderHint(QPainter::Antialiasing,antialias);  
+		
+	}
+
+	//count++;
+
+	//qDebug() << "count" << count;	
+
+	//QGraphicsPolylineSetItem::paint(painter,option,widget);
+	//painter->drawPolylineSet(QRectF(0,0,targetRect_.width(),targetRect_.height()),
+	//		    path(),
+	//		    QRectF(0,0,pixmap().width(),pixmap().height()));
+}
+
+
+void MgQPolylineSetItem::addPolyline(QVector<QPointF> points,QBrush brush,QPen pen,bool isPolygon)
+{
+	if(points.count() <= 0)
+		return;
+
+	MgQPolyline *line=new MgQPolyline;
+	polylines_.push_back(line);
+
+	line->points_ = new QPointF[points.count()];
+	for(int i=0; i < points.count(); i++)
+	{		
+		line->points_[i]=points[i];
+	}
+	
+	line->num_=points.count();
+	line->isPolygon_=isPolygon;
+
+	int penIndex, brushIndex;
+
+	if((brushIndex=brushList_.indexOf(brush)) == -1)
+	{
+		brushList_.push_back(brush);
+		line->brushIndex_=brushList_.count()-1;
+	}
+	else
+	{
+		line->brushIndex_=brushIndex;
+	}
+
+	if((penIndex=penList_.indexOf(pen)) == -1)
+	{
+		penList_.push_back(pen);
+		line->penIndex_=penList_.count()-1;
+	}
+	else
+	{
+		line->penIndex_=penIndex;
+	}
+}
+
+void MgQPolylineSetItem::addPath(QPainterPath &path,QBrush brush,QPen pen)
+{
+	if(path.isEmpty())
+		return;
+
+	MgQPolyline *line=new MgQPolyline;
+	polylines_.push_back(line);
+
+	line->path_ = new QPainterPath(path);	
+	line->num_=0;
+	line->isPolygon_=true;
+
+	int penIndex, brushIndex;
+
+	if((brushIndex=brushList_.indexOf(brush)) == -1)
+	{
+		brushList_.push_back(brush);
+		line->brushIndex_=brushList_.count()-1;
+	}
+	else
+	{
+		line->brushIndex_=brushIndex;
+	}
+
+	if((penIndex=penList_.indexOf(pen)) == -1)
+	{
+		penList_.push_back(pen);
+		line->penIndex_=penList_.count()-1;
+	}
+	else
+	{
+		line->penIndex_=penIndex;
+	}
+}
diff --git a/src/drivers/MgQ/MgQPolylineSetItem.h b/src/drivers/MgQ/MgQPolylineSetItem.h
new file mode 100644
index 0000000..68518c3
--- /dev/null
+++ b/src/drivers/MgQ/MgQPolylineSetItem.h
@@ -0,0 +1,72 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQPolylineSetItem.h
+    \brief Definition of MgQPolylineSetItem.
+    \author Graphics Section, ECMWF
+
+    Started: April 2010
+*/
+
+#ifndef _MgQPolylineSetItem_H
+#define _MgQPolylineSetItem_H
+
+#include <QGraphicsItem>
+
+#include "MgQ.h"
+
+class MgQPolyline
+{
+public:
+	MgQPolyline() : points_(0), path_(0), num_(0) {};
+	QPointF* points_;
+	QPainterPath* path_; //polygons with holes stored as QPainterPath
+	int num_;
+	int brushIndex_;
+	int penIndex_;
+	bool isPolygon_;
+}; 
+
+class MgQPolylineSetItem : public QGraphicsItem
+{
+public:
+	enum {Type = MgQ::PolylineSetItemType}; 
+	
+	MgQPolylineSetItem(QRectF &,QGraphicsItem* parent = 0);
+	~MgQPolylineSetItem();
+	
+	QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+	int type() const {return Type;}
+
+	void addPolyline(QVector<QPointF>,QBrush,QPen,bool);
+	void addPath(QPainterPath&,QBrush,QPen);
+
+protected:
+	QList<MgQPolyline*> polylines_;
+	QList<QBrush> brushList_;
+	QList<QPen> penList_;
+
+	QRectF boundingRect_;
+};
+
+#endif 
diff --git a/src/drivers/MgQ/MgQRootItem.h b/src/drivers/MgQ/MgQRootItem.h
new file mode 100644
index 0000000..3cdd114
--- /dev/null
+++ b/src/drivers/MgQ/MgQRootItem.h
@@ -0,0 +1,58 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQRootItem.h
+    \brief Definition of MgQRootItem.
+    \author Graphics Section, ECMWF
+
+    Started: June 2011
+*/
+
+#ifndef _MgQRootItem_H
+#define _MgQRootItem_H
+
+#include <magics.h>
+#include "MgQ.h"
+
+class MgQRootItem : public QGraphicsItem
+{
+public:
+   	MgQRootItem(QGraphicsItem* parent=0) : QGraphicsItem(parent) {};
+	virtual ~MgQRootItem() {};
+	
+	int type() const {return Type;}
+	QRectF boundingRect() const {return QRectF();}
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *) {};
+		
+	void clearContents()
+	{
+		foreach(QGraphicsItem* item,childItems())
+		{
+	  		scene()->removeItem(item);
+			delete item;
+		}
+	}
+};
+
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQScene.cc b/src/drivers/MgQ/MgQScene.cc
new file mode 100644
index 0000000..a5cdab3
--- /dev/null
+++ b/src/drivers/MgQ/MgQScene.cc
@@ -0,0 +1,164 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQScene.cc
+    \brief Definition of MgQScene
+    \author Graphics Section, ECMWF
+
+    Started: June 2010
+*/
+
+
+#include "MgQScene.h"
+
+#include <QDebug>
+#include <QGraphicsItem>
+#include <QPainter>
+#include <QStyleOptionGraphicsItem>
+
+#include "MgQRootItem.h"
+
+MgQScene::MgQScene(QObject *parent) : QGraphicsScene(parent)
+{
+	plotRootItem_= new MgQRootItem;
+	addItem(plotRootItem_);
+	plotRootItem_->setEnabled(false);
+	plotRootItem_->setVisible(false); 
+	
+	annotationRootItem_=new MgQRootItem;	
+	addItem(annotationRootItem_);
+	annotationRootItem_->setZValue(1.); // it should be above the plotRootItem	
+}
+
+
+MgQScene::MgQScene(MgQRootItem *plotRootItem, QObject *parent) : QGraphicsScene(parent), plotRootItem_(plotRootItem)
+{
+	addItem(plotRootItem_);
+	//plotRootItem->setEnabled(false);
+	//plotRootItem->setVisible(false); 
+	
+	annotationRootItem_=new MgQRootItem;	
+	addItem(annotationRootItem_);	
+}
+
+
+MgQScene::~MgQScene()
+{	  
+}
+
+
+void MgQScene::addPlotRootItemToScene()
+{
+	if(plotRootItem_->scene() == 0)
+	{
+	  	addItem(plotRootItem_);
+	}
+}
+
+void MgQScene::removePlotRootItemFromScene()
+{
+	if(plotRootItem_->scene() == this)
+	{  	  
+		removeItem(plotRootItem_);
+	}
+}
+
+void MgQScene::renderContents(QPainter *painter, const QStyleOptionGraphicsItem* option,
+			     const QRectF &targetRect, const QRectF &sourceRect,bool renderAllItems)
+{
+	if(plotRootItem_->scene() != this)
+	{
+	  	return;
+	}	
+  
+  	//Save painter state
+	painter->save();
+  
+	//Find the ideal x / y scaling ratio to fit \a source into \a target.
+    	qreal xratio = targetRect.width() / sourceRect.width();
+    	qreal yratio = targetRect.height() / sourceRect.height();
+ 
+	//Keep aspect ratio
+	xratio = yratio = qMin(xratio, yratio);
+
+	//qDebug() << "CLIPPING " << sourceRect << targetRect;
+    	
+	//Set clipping
+	painter->setClipRect(targetRect);
+
+	//Tranform the painter
+	QTransform painterTransform;
+	painterTransform *= QTransform()
+                        .translate(targetRect.left(), targetRect.top())
+                        .scale(xratio, yratio)
+                        .translate(-sourceRect.left(), -sourceRect.top());
+    	painter->setWorldTransform(painterTransform, true);
+
+	//qDebug() << "CLIP TRANSFORMED" << painter->transform().mapRect(sourceRect) << painter->transform().mapRect(targetRect);
+	
+	renderItemRecursively(plotRootItem_,painter,option);
+	
+	if(renderAllItems)
+	{
+		renderItemRecursively(annotationRootItem_,painter,option);
+	}
+
+	painter->restore();
+}
+
+void MgQScene::renderContents(QPainter *painter,
+			      const QRectF &targetRect, const QRectF &sourceRect)
+{
+	QStyleOptionGraphicsItem option;
+	renderContents(painter,&option,targetRect,sourceRect);
+}
+
+void MgQScene::renderItemRecursively(QGraphicsItem* item,QPainter *painter,const QStyleOptionGraphicsItem *option)
+{
+	//
+	if(checkItemIsVisible(item) == true &&
+	   item->type() != MgQ::PreviewLayoutItemType)
+	{
+		painter->save();
+		painter->setTransform(item->sceneTransform(), true);
+		item->paint(painter, option, 0);
+          	painter->restore();
+
+		foreach(QGraphicsItem *childItem,item->childItems())
+		{
+			renderItemRecursively(childItem,painter,option);
+		}
+	}
+}
+
+
+bool MgQScene::checkItemIsVisible(QGraphicsItem *item)
+{
+	if(item->data(MgQ::ItemIsVisibleKey).isNull()) 
+	{
+		return true;
+	}
+	else	 
+	{
+	    	return item->data(MgQ::ItemIsVisibleKey).toBool();
+	}
+}
+
diff --git a/src/drivers/MgQ/MgQScene.h b/src/drivers/MgQ/MgQScene.h
new file mode 100644
index 0000000..23782fa
--- /dev/null
+++ b/src/drivers/MgQ/MgQScene.h
@@ -0,0 +1,63 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQScene.h
+    \brief Definition of MgQScene.
+    \author Graphics Section, ECMWF
+
+    Started: June 2010
+*/
+
+#ifndef MgQScene_H
+#define MgQScene_H
+
+#include <QGraphicsScene>
+
+class MgQRootItem;
+
+class MgQScene : public QGraphicsScene
+{
+
+public:
+	MgQScene(QObject *parent=0);
+	MgQScene(MgQRootItem *, QObject *parent=0); 
+	~MgQScene();
+
+	void renderContents(QPainter *, const QRectF &, const QRectF &);
+	void renderContents(QPainter *, const QStyleOptionGraphicsItem *,const QRectF &, const QRectF &,bool renderAllItems=false);
+	
+	MgQRootItem* plotRootItem() {return plotRootItem_;}	
+	MgQRootItem* annotationRootItem() {return annotationRootItem_;}
+	
+	void addPlotRootItemToScene();
+	void removePlotRootItemFromScene();
+
+protected:
+	void renderItemRecursively(QGraphicsItem*,QPainter *,const QStyleOptionGraphicsItem *);
+	bool checkItemIsVisible(QGraphicsItem *);
+	bool checkItemType(QGraphicsItem *,int);
+
+	MgQRootItem* plotRootItem_;
+	MgQRootItem* annotationRootItem_;
+};
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQSceneCacheItem.cc b/src/drivers/MgQ/MgQSceneCacheItem.cc
new file mode 100644
index 0000000..8b184b8
--- /dev/null
+++ b/src/drivers/MgQ/MgQSceneCacheItem.cc
@@ -0,0 +1,68 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQSceneCacheItem.cc
+    \brief Definition of MgQSceneCacheItem
+    \author Graphics Section, ECMWF
+
+    Started: September 2010
+*/
+
+#include "MgQSceneCacheItem.h"
+
+#include <QDebug>
+#include <QPainter>
+#include <QPixmap>
+#include <QStyleOptionGraphicsItem>
+
+MgQSceneCacheItem::MgQSceneCacheItem(QPixmap* pixmap,QGraphicsItem* parent) : 
+	QGraphicsItem(parent), pixmap_(pixmap)
+{
+	setFlag(QGraphicsItem::ItemUsesExtendedStyleOption,true);
+}
+
+MgQSceneCacheItem::~MgQSceneCacheItem()
+{	
+
+}
+
+QRectF MgQSceneCacheItem::boundingRect() const
+{
+	return clipRect_;
+}
+
+void MgQSceneCacheItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                QWidget *widget)
+{
+	QRectF rect=option->exposedRect;
+	
+	/*if(!painter->clipRegion().isEmpty());
+	{	  		
+		clipRect=painter->clipRegion().boundingRect();
+	}
+	else
+	{
+	  	clipRect=painter->clipPath().boundingRect();
+	}*/
+	
+	painter->drawPixmap(rect,*pixmap_,rect);	
+}
+
diff --git a/src/drivers/MgQ/MgQSceneCacheItem.h b/src/drivers/MgQ/MgQSceneCacheItem.h
new file mode 100644
index 0000000..75dcdae
--- /dev/null
+++ b/src/drivers/MgQ/MgQSceneCacheItem.h
@@ -0,0 +1,58 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQSceneCacheItem.h
+    \brief Definition of MgQSceneCacheItem.
+    \author Graphics Section, ECMWF
+
+    Started: September 2011
+*/
+
+#ifndef _MgQSceneCacheItem_H
+#define _MgQSceneCacheItem_H
+
+#include <QGraphicsItem>
+
+#include "MgQ.h"
+
+class MgQSceneCacheItem : public QGraphicsItem
+{
+public:
+	enum {Type = MgQ::SceneCacheItemType}; 
+	
+	MgQSceneCacheItem(QPixmap*,QGraphicsItem* parent = 0);
+	~MgQSceneCacheItem();
+	
+	QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+	void setPixmap(QPixmap* p) {pixmap_=p;}
+	void setClipRect(QRectF r) {clipRect_=r;}
+	int type() const {return Type;}
+
+protected:
+	QRectF clipRect_;
+	QPixmap* pixmap_;
+
+};	
+
+
+#endif 
diff --git a/src/drivers/MgQ/MgQSceneItem.cc b/src/drivers/MgQ/MgQSceneItem.cc
new file mode 100644
index 0000000..6963ad4
--- /dev/null
+++ b/src/drivers/MgQ/MgQSceneItem.cc
@@ -0,0 +1,943 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQSceneItem.cc
+    \brief Definition of MgQSceneItem
+    \author Graphics Section, ECMWF
+
+    Started: June 2011
+*/
+
+#include "MgQSceneItem.h"
+
+#include <QDebug>
+#include <QGraphicsItem>
+#include <QImage>
+#include <QPixmap>
+#include <QPainter>
+#include <QProgressDialog>
+#include <QStyleOptionGraphicsItem>
+
+#include "MgQDriverObject.h"
+#include "MgQHistoItem.h"
+#include "MgQLayerItem.h"
+#include "MgQLayoutItem.h"
+#include "MgQStepMetaData.h"
+
+#include "MgQPlotScene.h"
+
+MgQSceneItem::MgQSceneItem(const Layout& layout) : MgQLayoutItem(layout)							
+{
+	prevCurrentStep_=0;
+	driverObject_=0;
+
+	sceneLayerItem_=0;
+	previewLayoutItem_=0;
+	
+	antialias_=false;
+	
+	stepNum_=0;
+}
+ 
+MgQSceneItem::~MgQSceneItem()
+{
+	if(driverObject_)
+		delete driverObject_;
+
+	foreach(MgQLayerState *st,previousLayerState_)
+	{
+		delete st;
+	}	
+}
+
+void MgQSceneItem::clearBeforeNewRequest()
+{
+/*	if(rootItem_)
+	{
+		removeItem(rootItem_);
+		delete rootItem_;
+		rootItem_=0;
+	}
+*/
+	//Animation
+	prevCurrentStep_=currentStep_;
+
+
+	layerItems_.clear();
+	sceneLayerItem_=0;
+	previewLayoutItem_=0;
+	stepNum_=0;
+}
+
+void MgQSceneItem::saveStateBeforeNewRequest()
+{
+	foreach(MgQLayerState *st,previousLayerState_)
+	{
+		delete st;
+	}	
+	previousLayerState_.clear();
+
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		MgQLayerState *st=new MgQLayerState;
+		item->saveLayerState(st);
+		previousLayerState_.push_back(st);		
+	}
+}
+
+MgQLayoutItem* MgQSceneItem::findProjectorItem(QPointF scenePos)
+{
+	foreach(MgQLayoutItem* item, projectorItems_)
+	{			
+	  	//qDebug() << "projector" << item->name() << scenePos << item->mapFromScene(scenePos);
+	  	if(item->contains(item->mapFromScene(scenePos)))
+		{			  
+			return item;
+		}
+	}
+	return 0;	
+}
+
+MgQLayoutItem* MgQSceneItem::firstProjectorItem()
+{		
+	if(projectorItems_.count() > 0)
+	{
+		 return projectorItems_.at(0);	
+
+	}
+	
+	return 0;
+}
+
+
+MgQLayoutItem* MgQSceneItem::findPreviewLayout()
+{
+	return 0;
+
+	/*foreach(QGraphicsItem *item, items())
+	{
+		if(item->data(MgQ::ItemType).toInt() == MgQ::PreviewLayoutItem)
+		{
+			
+			MgQLayoutItem *layout=static_cast<MgQLayoutItem*>(item);
+			return layout;
+		}
+	}
+
+	return 0;*/		
+}
+
+MgQLayoutItem* MgQSceneItem::findMagnifierLayout()
+{
+/*	foreach(QGraphicsItem *item, items())
+	{
+		if(checkItemType(item,MgQ::MagnifierLayoutItem))
+		{			
+			MgQLayoutItem *layout=static_cast<MgQLayoutItem*>(item);
+			return layout;
+		}
+	}
+*/
+	return 0;		
+}
+
+
+//-------------------------------------
+// Animation
+//-------------------------------------
+
+void MgQSceneItem::updateAnimation()
+{
+  	MgQPlotScene *sc=static_cast<MgQPlotScene*>(scene());
+ 
+	sc->sceneItemChanged();
+	
+	//Regenarete the cache
+	//updateCache();
+	
+	//Repaint everything
+	//update();
+}
+
+void MgQSceneItem::selectCurrentStepForAnimation()
+{
+	setCurrentStep(prevCurrentStep_);
+}
+
+int MgQSceneItem::currentStep()
+{
+	return currentStep_;
+}
+
+int MgQSceneItem::stepNum()
+{
+	return stepNum_;
+}
+
+void MgQSceneItem::setCurrentStep(int step,bool update)
+{
+	currentStep_=step;
+
+	if(currentStep_< 0 || currentStep_ >= stepNum_)
+		return;
+
+	for(int i=0; i < stepNum_; i++)
+	{
+		if(i!= currentStep_)
+		{
+			setStepVisible(i,false);
+		}
+		else
+		{
+			setStepVisible(i,true);	
+			//updateCache(); //Why we need to call it here????
+		}
+	}
+	
+	if(update)
+        	updateAnimation();
+}
+
+void MgQSceneItem::setStepVisible(int step,bool visible)
+{
+	if(visible == true && stepCached(step) ==false)
+	{
+		//Notify scene item about the new step
+		//sceneLayer_.reset();
+		sceneLayerItem_->sceneLayer().getReady(step);
+		foreach(MgQLayerItem *item,layerItems_)
+		{
+			if(item->stepNum() > 0 && item->stepCached(step) == false)
+			{
+				//driverObject_->driver().executeStep(step,item);
+				driverObject_->driver().executeStep(step,item,sceneLayerItem_->sceneLayer());
+				//item->setStepVisible(step,visible);
+			}
+		}
+		
+	}
+
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		if(item->stepNum() > 0)
+		{
+			item->setStepVisible(step,visible);
+		}
+	}
+}
+
+bool MgQSceneItem::stepCached(int step)
+{
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		if(item->stepNum() > 0 && item->stepCached(step) == false)
+		{
+			return false;
+		}
+		
+	}
+
+	return true;
+}
+
+void MgQSceneItem::stepMetaData(MgQStepMetaData* metaData)
+{
+	if(!sceneLayerItem_)
+		return;
+
+	const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer(); 
+	
+	MetaDataCollector stepData;
+	MetaDataAttribute attr;
+	attr.setSource(MetaDataAttribute::AnySource); //to enable any metadata query method
+
+	for(int step=0; step < stepNum_; step++)
+	{	
+		metaData->addStep("");
+
+		for(vector<Layer*>::iterator it = snl.beginLayer(step); it != snl.endLayer(step); ++it) 
+		{
+			//Layer& l=*it;
+
+			foreach(QString str,metaData->keys())
+			{
+				stepData[str.toStdString()]="";
+				stepData.setAttribute(str.toStdString(),attr);
+			}
+
+			(*it)->collect(stepData);
+			
+			for(map<string,string>::iterator itK=stepData.begin(); itK!= stepData.end(); itK++)
+			{
+				QString keyStr=QString::fromStdString(itK->first);
+				QString valueStr=QString::fromStdString(itK->second);
+				if(valueStr != "")
+				{
+					valueStr+="\n";
+
+					/*if(keyStr == "MV_Format")
+					{
+						valueStr="GRIB";
+						valueStr+="\n";
+					}*/
+
+					metaData->appendToStepData(keyStr,step,valueStr);
+				}
+			}
+		}
+	}
+
+	/*
+
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		if(item->stepNum() > 0)
+		{
+			int step=0;
+			Layer& l=item->layer();
+			StepLayer *layer=static_cast<StepLayer*>(&l);
+			for(vector<SingleLayer*>::iterator it=layer->firstStep(); it != layer->endStep(); it++)
+			{
+				foreach(QString str,metaData->keys())
+				{
+					stepData[str.toStdString()]="";
+				}				
+				
+				(*it)->metadata(stepData);
+				
+				if(firstLayer || metaData->stepNum() <= step)
+				{
+					metaData->addStep("");
+				}
+
+				for(map<string,string>::iterator itK=stepData.begin(); itK!= stepData.end(); itK++)
+				{
+					QString keyStr=QString::fromStdString(itK->first);
+					QString valueStr=QString::fromStdString(itK->second);
+					valueStr+="\n";
+
+
+					if(keyStr == "MV_Format")
+					{
+						valueStr="GRIB";
+						valueStr+="\n";
+					}
+
+
+					metaData->appendToStepData(keyStr,step,valueStr);
+				}
+
+				step++;
+			}
+			
+			firstLayer=false;
+		
+		}
+	}	*/
+}
+
+
+//-------------------------------------
+// Layers
+//-------------------------------------
+
+void MgQSceneItem::updateLayers()
+{
+	MgQPlotScene *sc=static_cast<MgQPlotScene*>(scene());
+ 	
+	sc->sceneItemChanged();
+
+	//Regenarete the cache
+//	updateCache();
+	
+	//Repaint everything
+//	update();
+}
+ 
+void MgQSceneItem::addLayerItem(MgQLayerItem* item) 
+{
+	layerItems_.push_back(item);
+	//item->setStackLevel(layerItems_.count()-1);
+	assert(item->layer().zindex() >= 0);
+	item->setStackLevel(item->layer().zindex());
+}
+
+
+MgQLayerItem* MgQSceneItem::layerItem(const Layer& layer)
+{
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		if(&item->layer() == &layer)
+		{
+			return item;
+		}
+	}
+	
+	return 0;
+}
+
+void MgQSceneItem::restoreLayerState()
+{
+	if(previousLayerState_.count() == 0)
+		return;
+
+	return;
+	
+	QList<MgQLayerItem*> newItems;
+	QMap<int,MgQLayerItem*> stStackLevelToItem;	
+	QSet<MgQLayerState*> stToItem;
+	
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		bool found=false;
+		foreach(MgQLayerState *st,previousLayerState_)
+		{
+			if(stToItem.contains(st) ==  false &&
+			   st->id_ == QString::fromStdString(item->layer().id()))
+			{
+				stToItem.insert(st);
+				stStackLevelToItem[st->stackLevel_]=item;
+				item->setLayerAlpha(st->alpha_);
+				item->setLayerVisibility(st->visible_);
+				found=true;
+				break;
+			}
+		}
+		if(!found)
+		{
+			newItems.push_back(item);
+		}
+	}	
+
+	//Set stack level for the "old" items
+	int currenStackLevel=0;
+	foreach(int level,stStackLevelToItem.keys())
+	{
+		//qDebug() << "restore" << QString::fromStdString(stStackLevelToItem[level]->layer().id()) << level << currenStackLevel;
+		stStackLevelToItem[level]->setStackLevel(currenStackLevel);
+		currenStackLevel++;
+	}
+	
+	//Set stack level for the "new" items 
+	foreach(MgQLayerItem *item,newItems)
+	{
+		item->setStackLevel(currenStackLevel);
+		currenStackLevel++;
+	}
+}
+
+void MgQSceneItem::collectLayerData(QList<QPointF> &pos,QMap<int,QList<ValuesCollector> > &val,
+				    double searchRadiusX, double searchRadiusY)
+{
+	for(int step=0; step < stepNum_; step++)
+	{	
+		collectLayerData(pos,val[step],step,searchRadiusX,searchRadiusY);
+	}
+}
+
+void MgQSceneItem::collectLayerDataForCurrentStep(QList<QPointF> &pos,QList<ValuesCollector> &val,
+						  double searchRadiusX, double searchRadiusY)
+{
+	collectLayerData(pos,val,currentStep_,searchRadiusX,searchRadiusY);
+}
+
+void MgQSceneItem::collectLayerData(QList<QPointF> &pos,QList<ValuesCollector> &val,int step,
+				    double searchRadiusX,  double searchRadiusY)
+{
+	if(!sceneLayerItem_)
+		return;
+
+	const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer(); 	
+	QString str; 
+
+	QList<Layer*> layerLst;
+		
+	foreach(MgQLayerItem* item,layerItems_)	 
+	{	  
+		if(item->stepNum() == 0)
+		{
+			layerLst << item->layer().get();
+		}
+	}	
+	
+	for(vector<Layer*>::iterator it = snl.beginLayer(step); it != snl.endLayer(step); ++it) 
+	{		
+		if(layerLst.indexOf(*it) == -1)
+		{  
+			layerLst << *it;
+		}	
+	}  
+	  
+	foreach(Layer *layer,layerLst)  
+	{  
+	  	if(!layer)
+		  	continue;
+		
+		if(layer->visibility() == true)
+		{
+			ValuesCollector layerData(layer->name());
+			layerData.setSearchRadius(searchRadiusX,searchRadiusY);
+			
+			foreach(QPointF pp,pos)
+			{		
+				layerData.push_back(ValuesCollectorPoint(pp.x(),pp.y()));
+			}		
+	
+			layer->collect(layerData);
+	
+			val << layerData;
+		}	
+	}
+
+}
+
+void MgQSceneItem::collectLayerDataForCurrentStep(MgQLayerItem *item,ValuesCollector& data)
+{
+	return collectLayerData(item,data,currentStep_);
+}
+
+void MgQSceneItem::collectLayerData(MgQLayerItem *item,ValuesCollector& data,int step)
+{	
+	if(!item || !sceneLayerItem_ || 
+	   !layerItems_.contains(item))
+		return;
+
+	if(item->stepNum() == 0)
+	{
+		item->layer().collect(data);
+	}
+	else
+	{	
+		const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer();
+		Layer *stepLayer=snl.findLayer(&item->layer(),step);
+		if(stepLayer)
+		{
+		  	 stepLayer->collect(data);
+		}	
+	}
+}
+
+
+void MgQSceneItem::layerMetaDataForCurrentStep(MgQLayerItem *item,MetaDataCollector& data)
+{
+	return layerMetaData(item,data,currentStep_);
+}
+
+void MgQSceneItem::layerMetaData(MgQLayerItem *item,MetaDataCollector& data,int step)
+{	
+	if(!item || !sceneLayerItem_ || 
+	   !layerItems_.contains(item))
+		return;
+
+	if(item->stepNum() == 0)
+	{
+		item->layer().collect(data);
+	}
+	else
+	{	
+		const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer();
+		Layer *stepLayer=snl.findLayer(&item->layer(),step);
+		if(stepLayer)
+		{
+		  	 stepLayer->collect(data);
+		}	
+	}
+}
+
+void MgQSceneItem::layerDataIndexForCurrentStep(MgQLayerItem *item,DataIndexCollector& data)
+{
+	return layerDataIndex(item,data,currentStep_);
+}
+
+void MgQSceneItem::layerDataIndex(MgQLayerItem *item,DataIndexCollector& data,int step)
+{	
+	if(!item || !sceneLayerItem_ || 
+	   !layerItems_.contains(item))
+		return;
+
+	if(item->stepNum() == 0)
+	{
+		item->layer().collect(data);
+	}
+	else
+	{	
+		const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer();
+		Layer *stepLayer=snl.findLayer(&item->layer(),step);
+		if(stepLayer)
+		{
+		  	 stepLayer->collect(data);
+		}	
+	}
+}
+
+
+QPixmap MgQSceneItem::layerInfoImageForCurrentStep(MgQLayerItem *item,QHash<QString,QString> imageId)
+{
+	return layerInfoImage(item,currentStep_,imageId);
+}
+
+QPixmap MgQSceneItem::layerInfoImage(MgQLayerItem *item,int step,QHash<QString,QString> imageId)
+{
+	if(!item || !sceneLayerItem_ || 
+	   !layerItems_.contains(item))
+		return QPixmap();
+		
+	MgQHistoItem *histoItem=item->histoItem(step);
+	if(!histoItem)	
+		return QPixmap();
+		
+	if(!histoItem->cached() || histoItem->pixmapId() != imageId)
+	{
+		if(histoItem->cached())
+		{  
+			histoItem=item->resetHistoItem(step);
+		}
+		
+		histoItem->setPixmapId(imageId);
+		
+		Layer *stepLayer;
+
+		if(item->stepNum() == 0)
+		{
+			stepLayer=&item->layer();
+		}
+		else
+		{			
+			const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer(); 	
+			stepLayer=snl.findLayer(&item->layer(),step);
+		}
+
+		if(!stepLayer)
+			return QPixmap();
+			
+		QString visdefName=imageId.value("visdefName");
+		QString visdefClass=imageId.value("visdefClass");
+		driverObject_->driver().executeHisto(stepLayer,histoItem,visdefName,visdefClass);
+	}	
+
+	return item->histoPixmap(step,QSize(300,200));
+}
+
+void MgQSceneItem::layerIconsForCurrentStep(MgQLayerItem *item,MgQIconList& icons)
+{
+	return layerIcons(item,icons,currentStep_);
+}
+
+void MgQSceneItem::layerIcons(MgQLayerItem *item,MgQIconList& icons,int step)
+{	
+	if(!item || !sceneLayerItem_ || 
+	   !layerItems_.contains(item))
+		return;
+
+		
+	for(vector<MetviewIcon>::const_iterator it=item->layer().iconsBegin(); it != item->layer().iconsEnd(); it++)
+	{
+		icons << MgQIcon(QString::fromStdString((*it).iconName()),
+				 QString::fromStdString((*it).iconClass()),
+				 QString::fromStdString((*it).iconId()));
+	}
+		
+	/*if(item->stepNum() == 0)
+	{
+		for(vector<pair<string, string>  >::const_iterator it=item->layer().iconsBegin(); it != item->layer().iconsEnd(); it++)
+		{
+			icons << QPair<QString,QString>(QString::fromStdString(it->first),QString::fromStdString(it->second));
+		}	
+	}
+	else
+	{	
+		const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer();
+		Layer *stepLayer=snl.findLayer(&item->layer(),step);
+		if(stepLayer)
+		{
+		  	for(vector<pair<string, string>  >::const_iterator it=stepLayer->iconsBegin(); it != stepLayer->iconsEnd(); it++)
+			{
+				icons << QPair<QString,QString>(QString::fromStdString(it->first),QString::fromStdString(it->second));	
+			}
+		}	
+	}*/
+}
+
+void MgQSceneItem::renderLayerPreview()
+{
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		item->renderPreview();
+	}
+	
+	/*preview_=QImage();
+	
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		QImage img=item->preview();
+		preview_
+	}*/
+	
+}
+
+//----------------------------------------
+// Magnifier
+//---------------------------------------
+
+MgQMagnifierLayoutItem* MgQSceneItem::updateMagnifier(float zoomFactor)
+{
+	//magnifierZoom_=zoom;
+#if 0	
+	MgQLayerItem *magLayerItem=0;	
+
+	foreach(MgQLayerItem *item,layerItems_)
+	{
+		if(item->stepNum() > 0) //&& item->stepCached(currentStep_) == false)
+		{
+			magLayerItem=item;
+			break;
+			//driverObject_->driver().executeMagnifier(currentStep_,item);
+				//item->setStepVisible(step,visible);
+		}
+	}
+
+	if(!magLayerItem) 
+		return 0;
+
+	const magics::SceneLayer& snl=sceneLayerItem_->sceneLayer(); 	
+	QString str;
+	
+	Layer *magLayer=snl.findLayer(&magLayerItem->layer(),currentStep_);
+
+	MgQMagnifierLayoutItem *magLayoutItem=magLayerItem->magnifierLayoutItem();
+
+	if(!magLayoutItem)
+	{
+		return 0;
+	}		
+
+	magLayoutItem->clearPlotContents(); 
+
+	/*if(zoomFactor  != item->zoomFactor())
+	{
+		item->clearPlotContents();
+	}
+	else
+	{ 
+		return;
+	}*/	
+
+	magLayoutItem->setZoomFactor(zoomFactor);
+
+	/*QVector<QPointF> pp;
+
+	pp.push_back(QPointF(item->layout().minX(),item->layout().minY()));
+	pp.push_back(QPointF(item->layout().maxX(),item->layout().minY()));
+	pp.push_back(QPointF(item->layout().maxX(),item->layout().maxY()));
+	pp.push_back(QPointF(item->layout().minX(),item->layout().maxY()));
+
+	item->setArea(pp);*/
+
+	float textWidth = 70.+20;
+	float textHeight = 40.;
+		
+	magLayoutItem->setResolutionX(textWidth/zoomFactor);
+	magLayoutItem->setResolutionY(textHeight/zoomFactor);
+
+	driverObject_->driver().executeMagnifier(magLayer,magLayoutItem);
+
+	return magLayoutItem;
+
+
+	/*if(!animation_)
+		return;
+
+	item->setStep(animation_->currentStepObject());
+		
+	//MagLog::dev() << "GridValArea>  dx: " << fabsf(ldx) << " dy: " << fabsf(ldy) << endl;  
+	for(int i=0; i <  pp.count() ; i++)
+	{
+		MagLog::dev() << " " << pp[i].x() << " " << pp[i].y() << endl;
+	}	
+
+	animation_->driver().redisplayMagnifier(item);*/
+	
+#endif	
+}
+
+void MgQSceneItem::clearMagnifier()
+{
+	/*MgQLayoutItem *litem=findMagnifierLayout();
+	if(!litem) return;
+
+	MgQMagnifierLayoutItem *item=static_cast<MgQMagnifierLayoutItem*>(litem);
+
+	item->clearPlotContents();*/
+}
+
+/*void MgQSceneItem::drawItems(QPainter *painter, int numItems,
+                             QGraphicsItem *items[],
+                             const QStyleOptionGraphicsItem options[],
+                             QWidget *widget)
+ {
+     for (int i = 0; i < numItems; ++i) {
+          // Draw the item
+          painter->save();
+          painter->setMatrix(items[i]->sceneMatrix(), true);
+          items[i]->paint(painter, &options[i], widget);
+          painter->restore();
+      }
+ }
+*/
+
+void MgQSceneItem::updateCache()
+{	
+#if 0  
+  
+  	if ( !rootItem_ )
+		return;
+	
+	
+	
+	QPainter *painter=cachePainter_;
+	QStyleOptionGraphicsItem options;
+
+	QRectF sourceRect = sceneRect();
+        QRectF targetRect(0, 0, painter->device()->width(), painter->device()->height());
+
+	cacheDevice_->fill(qRgba(255,255,255,255));
+
+	painter->save();
+
+	QTransform painterTransform;
+    	painterTransform *= QTransform()
+                        .translate(targetRect.left(), targetRect.top())
+                        //.scale(xratio, yratio)
+                        .translate(-sourceRect.left(), -sourceRect.top());
+    	painter->setWorldTransform(painterTransform, true);
+
+	rootItem_->setVisible(false);
+
+	renderItemRecursively(rootItem_,painter,&options);
+
+	rootItem_->setVisible(false);
+
+	/*foreach(QGraphicsItem *item, items(Qt::AscendingOrder))
+	{
+		if(item->zValue() < 1.2 && item->isVisible())
+		{
+			painter->save();
+          		painter->setTransform(item->sceneTransform(), true);
+          		item->paint(painter, &options, 0);
+          		painter->restore();			
+		}
+	}*/
+
+	painter->restore();
+
+	//cacheDevice_->save("/var/tmp/cgr/test.png");
+
+	//rootItem_->setFlag(QGraphicsItem::ItemHasNoContents,true);
+	rootItem_->setVisible(false); 
+
+
+	//setBackgroundBrush(QPixmap::fromImage(*cacheDevice_));
+#endif
+
+}
+
+void MgQSceneItem::drawBackground ( QPainter * painter, const QRectF & rect ) 
+{	
+	/*qDebug() << "bg" << rect << sceneRect();
+
+	QRectF targetRect(0, 0, sceneRect().width(), sceneRect().height());
+	//painter->drawPixmap(sceneRect(),*cacheDevice_,targetRect);
+
+	painter->drawPixmap(rect,*cacheDevice_,rect);*/
+}
+
+void MgQSceneItem::renderForMagnifier(QPainter *painter, const QRectF &targetRect, const QRectF &sourceRect)
+{
+	/*QStyleOptionGraphicsItem option;
+	painter->setRenderHint(QPainter::Antialiasing,antialias_);
+	renderContents(painter,&option,targetRect,sourceRect,true);*/
+}
+
+void MgQSceneItem::renderForPrinter(QPainter *painter)
+{
+	/*QStyleOptionGraphicsItem option;
+	
+	QRectF sourceRect = sceneRect();
+        QRectF targetRect(0, 0, painter->device()->width(), painter->device()->height());
+
+	painter->setRenderHint(QPainter::Antialiasing,antialias_);
+	renderContents(painter,&option,targetRect,sourceRect);*/
+}
+
+void MgQSceneItem::renderForVideo(QPainter *painter,QProgressDialog *progress,QString path,QStringList &files)
+{	
+	/*QPixmap *pix=static_cast<QPixmap*>(painter->device());
+	QStyleOptionGraphicsItem option;
+	
+	QRectF sourceRect = sceneRect();
+        QRectF targetRect(0, 0, painter->device()->width(), painter->device()->height());
+		
+	int oriCurrentStep=currentStep_;
+
+	for(int i=0; i < stepNum_ && i < files.count() ; i++)
+	{		
+		progress->setValue(i);
+
+		pix->fill();
+		
+		bool oriCached=stepCached(i);
+
+		setStepVisible(i,true);	
+		for(int j=0; j < stepNum_; j++)
+		{
+			if(j != i)
+				setStepVisible(j,false);
+		}
+
+		renderContents(painter,&option,targetRect,sourceRect);
+		
+		pix->save(path + files[i]);
+		
+		if(oriCached == false)
+		{
+			foreach(MgQLayerItem *item,layerItems_)
+			{
+				item->clearStep(i);
+			}
+		}
+	}
+	
+	currentStep_=-1;
+	setCurrentStep(oriCurrentStep);*/
+}
+
+void MgQSceneItem::setEnableAntialias(bool status)
+{
+	/*if(antialias_!=status)
+	{
+		antialias_=status;
+		cachePainter_->setRenderHint(QPainter::Antialiasing,antialias_);
+
+		updateAnimation();
+	}*/
+}
+
+
diff --git a/src/drivers/MgQ/MgQSceneItem.h b/src/drivers/MgQ/MgQSceneItem.h
new file mode 100644
index 0000000..c64cda4
--- /dev/null
+++ b/src/drivers/MgQ/MgQSceneItem.h
@@ -0,0 +1,174 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQSceneLayout.h
+    \brief Definition of MgQSceneLayout.
+    \author Graphics Section, ECMWF
+
+    Started: June 2011
+*/
+
+#ifndef MgQSceneItem_H
+#define MgQSceneItem_H
+
+#include "MgQ.h"
+#include "MgQLayoutItem.h"
+
+#include <QMap>
+#include "Layer.h"
+#include "QtDriver.h"
+#include "MgQScene.h"
+
+class QProgressDialog;
+
+class MgQDriverObject;
+class MgQLayerItem;
+class MgQLayerState;
+class MgQPreviewLayoutItem;
+class MgQSceneLayerItem;
+class MgQStepMetaData;                        
+
+using magics::SceneLayer;
+
+class MgQIcon
+{
+public:
+    
+        MgQIcon(QString name, QString cs, QString id) : 
+  		name_(name), class_(cs), id_(id) {}
+  		
+	QString name_;
+	QString class_;
+	QString id_;
+};	
+
+typedef QList<MgQIcon> MgQIconList;
+
+
+class MgQSceneItem : public MgQLayoutItem
+{
+  
+public:
+	enum {Type = MgQ::SceneItemType}; 
+	
+	MgQSceneItem(const Layout &);							
+	~MgQSceneItem();
+
+	int type() const {return Type;}	
+	
+	void clearBeforeNewRequest();
+	void saveStateBeforeNewRequest();
+	void restoreLayerState();
+
+	MgQLayoutItem* findPreviewLayout();
+	MgQLayoutItem* findMagnifierLayout();
+
+	//MgQAnimation* animation();
+	//void addAnimation(MgQLayoutItem*,MgQAnimation*);
+	void selectCurrentStepForAnimation();
+	
+	void setStepNum(int n) {stepNum_=n;} 
+	int stepNum();
+	int currentStep();
+	bool stepCached(int);
+	void setCurrentStep(int,bool update=true);
+	void setPrevCurrentStep(int i) {prevCurrentStep_=i;};
+	void setStepVisible(int,bool);
+	QStringList stepLabel(int) {return QStringList();}
+	void stepMetaData(MgQStepMetaData*);
+
+	MgQMagnifierLayoutItem* updateMagnifier(float);
+	void clearMagnifier();
+
+	void setSceneLayerItem(MgQSceneLayerItem *item) {sceneLayerItem_=item;}
+	MgQSceneLayerItem* sceneLayerItem() {return sceneLayerItem_;}
+	
+	const QList<MgQLayerItem*>& layerItems() {return layerItems_;}
+	void addLayerItem(MgQLayerItem*);
+	MgQLayerItem* layerItem(const Layer&);
+
+	//void collectLayerData(QList<QPointF> &,QMap<int,QList<QStringList> > &,bool addLayerName=true);
+	//void collectLayerDataForCurrentStep(QList<QPointF> &,QList<QStringList> &,bool addLayerName=true);
+	//void collectLayerData(QList<QPointF> &,QList<QStringList> &,int,bool addLayerName=true);
+
+	void collectLayerData(QList<QPointF> &,QMap<int,QList<ValuesCollector> > &,double,double);
+	void collectLayerDataForCurrentStep(QList<QPointF> &,QList<ValuesCollector> &,double,double);
+	void collectLayerData(QList<QPointF> &,QList<ValuesCollector> &,int,double,double);
+	void collectLayerDataForCurrentStep(MgQLayerItem *,ValuesCollector& data);
+	void collectLayerData(MgQLayerItem *,ValuesCollector& ,int );
+
+	void layerMetaDataForCurrentStep(MgQLayerItem *,MetaDataCollector&);
+	void layerMetaData(MgQLayerItem *,MetaDataCollector&,int);
+	void layerDataIndexForCurrentStep(MgQLayerItem *,DataIndexCollector&);
+	void layerDataIndex(MgQLayerItem *,DataIndexCollector&,int);
+	QPixmap layerInfoImageForCurrentStep(MgQLayerItem *,QHash<QString,QString>);
+	QPixmap layerInfoImage(MgQLayerItem *,int,QHash<QString,QString>);
+	void layerIconsForCurrentStep(MgQLayerItem *,MgQIconList&);
+	void layerIcons(MgQLayerItem *,MgQIconList&,int);
+	void  renderLayerPreview();
+   
+	void addPreviewLayoutItem(MgQPreviewLayoutItem* item) {previewLayoutItem_=item;}
+	MgQPreviewLayoutItem* previewLayoutItem() {return previewLayoutItem_;}
+
+	//QList<MgQLayerState*> previousLayerState() {return previousLayerState_;}
+
+	void setDriverObject(MgQDriverObject* drv) {driverObject_=drv;}
+
+	void renderForMagnifier(QPainter *, const QRectF &, const QRectF &);
+	void renderForPrinter(QPainter *);
+	void renderForVideo(QPainter *,QProgressDialog *,QString,QStringList &);
+
+	void updateAnimation();
+	void updateLayers();
+	void setEnableAntialias(bool);
+	
+	void addProjectorItem(MgQLayoutItem *n) {projectorItems_ << n;}
+	QList<MgQLayoutItem*> projectorItems() {return projectorItems_;}
+	MgQLayoutItem* findProjectorItem(QPointF);
+	MgQLayoutItem* firstProjectorItem();
+
+protected:
+	void scanLayers();
+	void updateCache();
+	void drawBackground( QPainter * painter, const QRectF & rect ); 
+
+	int prevCurrentStep_;
+	int currentStep_;
+	int stepNum_;
+
+	//QRectF magnifierSceneRect_;
+	//float  magnifierFactor_;
+
+	MgQSceneLayerItem *sceneLayerItem_;
+	
+	MgQPreviewLayoutItem* previewLayoutItem_;
+
+	QList<MgQLayerItem*> layerItems_;
+	QList<MgQLayerState*> previousLayerState_;
+	QList<MgQLayoutItem*> projectorItems_;
+
+	MgQDriverObject *driverObject_;
+	
+	bool antialias_;
+};
+
+
+#endif
\ No newline at end of file
diff --git a/src/drivers/MgQ/MgQStepItem.cc b/src/drivers/MgQ/MgQStepItem.cc
new file mode 100644
index 0000000..a339fbe
--- /dev/null
+++ b/src/drivers/MgQ/MgQStepItem.cc
@@ -0,0 +1,43 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQStepItem.cc
+    \brief Definition of MgQStepItem
+    \author Graphics Section, ECMWF
+
+    Started: February 2010
+*/
+
+#include "MgQStepItem.h"
+
+//using namespace magics;
+
+MgQStepItem::MgQStepItem(MgQLayoutItem *parentLayoutItem) : 
+	parentLayoutItem_(parentLayoutItem)
+{
+	id_=-1;
+	cached_=false;	
+}
+
+MgQStepItem::~MgQStepItem()
+{	
+
+}
diff --git a/src/drivers/MgQ/MgQStepItem.h b/src/drivers/MgQ/MgQStepItem.h
new file mode 100644
index 0000000..d19a4f5
--- /dev/null
+++ b/src/drivers/MgQ/MgQStepItem.h
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQStepItem.h
+    \brief Definition of MgQStepItem.
+    \author Graphics Section, ECMWF
+
+    Started: May 2008
+*/
+
+#ifndef _MgQStepItem_H
+#define _MgQStepItem_H
+
+#include <magics.h>
+
+#include "MgQ.h"
+
+class MgQLayoutItem;
+
+class MgQStepItem : public QGraphicsItem
+{
+public:
+	enum {Type = MgQ::StepItemType}; 
+		
+	MgQStepItem(MgQLayoutItem*);
+	~MgQStepItem();
+	
+	int     id() {return id_;}
+	void    id(int i) {id_=i;}
+	bool    cached() {return cached_;}
+	void    setCached(bool b) {cached_=b;}
+	MgQLayoutItem* parentLayoutItem() {return parentLayoutItem_;}
+	
+	int type() const {return Type;}
+	QRectF boundingRect() const {return QRectF();}
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *) {};
+
+protected:
+	int         	id_;
+	bool        	cached_;			
+	MgQLayoutItem   *parentLayoutItem_;
+};
+
+
+//}
+
+
+#endif
diff --git a/src/drivers/MgQ/MgQStepMetaData.cc b/src/drivers/MgQ/MgQStepMetaData.cc
new file mode 100644
index 0000000..7c6ef3e
--- /dev/null
+++ b/src/drivers/MgQ/MgQStepMetaData.cc
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQStepMetaData.cc
+    \brief Definition of MgQStepMetaData.
+    \author Graphics Section, ECMWF
+
+    Started: June 2011
+*/
+
+#include "MgQStepMetaData.h"
+
+#include <QDebug>
+
+
+MgQStepMetaData::MgQStepMetaData(QStringList keys) : keys_(keys)
+{
+	for(int i=0; i < keys_.count(); i++)
+	{
+		stepData_[i]=QStringList();
+	}
+}
+
+void MgQStepMetaData::clear()
+{
+	keys_.clear();
+	stepData_.clear();
+}
+
+int MgQStepMetaData::stepNum()
+{
+	if(keys_.count() > 0)
+		return stepData_[0].count();
+	else
+		return 0;
+}
+
+QStringList MgQStepMetaData::stepData(int index)
+{
+	return stepData_[index];
+}
+
+void MgQStepMetaData::addStep(QString value)
+{
+	foreach(int index,stepData_.keys())
+	{
+		stepData_[index].append(value);
+	}
+}
+
+void MgQStepMetaData::appendToStepData(QString key, int step, QString value)
+{	
+	int index=keys_.indexOf(key,0);
+	while(index != -1)
+	{
+		QStringList& lst=stepData_[index];
+		//qDebug() << key << index << step << lst;
+		lst[step].append(value);
+
+		index=keys_.indexOf(key,index+1);
+	}
+} 
\ No newline at end of file
diff --git a/src/drivers/MgQ/MgQStepMetaData.h b/src/drivers/MgQ/MgQStepMetaData.h
new file mode 100644
index 0000000..dd1cd48
--- /dev/null
+++ b/src/drivers/MgQ/MgQStepMetaData.h
@@ -0,0 +1,52 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQStepMetaData.h
+    \brief Definition of MgQStepMetaData.
+    \author Graphics Section, ECMWF
+
+    Started: June 2011
+*/
+
+#ifndef MgQStepMetaData_H
+#define MgQStepMetaData_H
+
+#include <QMap>
+#include <QStringList>
+
+class MgQStepMetaData
+{
+public:
+	MgQStepMetaData(QStringList);
+
+	void clear();
+	QStringList keys() {return keys_;}
+	int stepNum();
+	QStringList stepData(int);
+	void addStep(QString);
+	void appendToStepData(QString,int,QString);
+
+protected:
+	QStringList keys_;
+	QMap<int,QStringList> stepData_;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/drivers/MgQ/MgQSymbol.cc b/src/drivers/MgQ/MgQSymbol.cc
new file mode 100644
index 0000000..28abcb5
--- /dev/null
+++ b/src/drivers/MgQ/MgQSymbol.cc
@@ -0,0 +1,239 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQSymbol.h
+    \brief Definition of MgQSymbol
+    \author Graphics Section, ECMWF
+
+    Started: Feb 2010
+*/
+
+#include "MgQSymbol.h"
+
+#include <QDebug>
+#include <QPainter>
+
+//====================================
+//
+//  Item
+//
+//====================================
+
+bool MgQSymbolItem::equal(const QString& id,const float size)
+{
+	return id == id_ && size == size_;
+}
+
+bool MgQSymbolItem::hasFilledPart()
+{
+	for(int i=0; i < paths_.count(); i++)
+	{		
+		if(paths_[i].isFilled())
+		{
+		  	return true;
+		}
+	}
+	
+	return false;
+}
+
+//====================================
+//
+//  Item set
+//
+//====================================
+
+void MgQSymbolSetItem::setColor(QColor color)
+{
+	pen_=QPen(color);
+
+	for(int i=0; i < symbol_->paths().count(); i++)
+	{					
+		if(symbol_->paths().at(i).isFilled())
+		{
+			if(symbol_->paths().at(i).isDefaultFill())
+			{
+				brushes_ << QBrush(Qt::white);
+			}
+			else
+			{			
+				brushes_ << QBrush(color);
+			}
+		}
+		else
+		{
+			brushes_ << QBrush();
+		}
+	}
+}
+
+void MgQSymbolSetItem::setOutlineColor(QColor color)
+{
+	pen_=QPen(color);
+	outline_=true;
+} 
+ 
+ void MgQSymbolSetItem::setConnectLinePen(QPen pen)
+{
+	connectLinePen_=pen;
+} 
+ 
+ 
+QRectF MgQSymbolSetItem::boundingRect() const
+{
+	//qDebug() << "PIXMAP" << QGraphicsPolylineSetItem::boundingRect();
+	//qDebug() << "PIXMAP" << targetRect_;
+
+	//return QGraphicsPolylineSetItem::boundingRect();
+	//float w=boundingRectSize_;
+	//return QRectF(-w/2.,-w/2.,w/2.,w/2.);
+	return boundingRect_;
+}
+
+void MgQSymbolSetItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *,QWidget*)
+{
+	//qDebug() << "Symbol" << painter->clipRegion() << painter->clipPath() <<  painter->transform(); 
+
+	float sx=painter->transform().m11();
+	float sy=painter->transform().m22();
+
+	bool clipping=(painter->clipRegion().isEmpty())?false:true;
+	QRect clipRect=painter->clipRegion().boundingRect();
+
+	if(keepSizeWhenScaling_)	
+	{
+		QTransform tr=painter->transform();
+		tr.scale(1/sx,1/sy);
+		painter->setTransform(tr);
+	}	
+
+	qDebug() << "Total"  << xp_.count()*symbol_->paths().count();
+
+	//Draw lines conncting symbols
+	if(connectLine_ && xp_.count() > 1 )
+	{
+	  	painter->setPen(connectLinePen_);	
+		
+		for(int j=1; j < xp_.count(); j++)
+		{			  			  							
+			painter->drawLine(xp_[j-1],yp_[j-1],xp_[j],yp_[j]);
+		}
+	}	
+	
+	int n=0;
+	double dx,dy;
+	double prevX=0., prevY=0.;
+	
+	painter->setPen(pen_);
+	for(int j=0; j < xp_.count(); j++)
+	{			  	  
+	  	if(!clipping || 
+	      	    clipRect.contains(xp_[j],yp_[j]))
+		{		  
+	  		dx=xp_[j]-prevX;
+			dy=yp_[j]-prevY;
+				
+			if(!keepSizeWhenScaling_)	
+				painter->translate(dx,dy);
+			else
+				painter->translate(dx*sx,dy*sy);
+				
+			for(int i=0; i < symbol_->paths().count(); i++)
+			{		
+				if(!symbol_->paths().at(i).renderOnlyForOutline()  || outline_ )
+				{
+					painter->setBrush(brushes_[i]);			
+					painter->drawPath(symbol_->paths().at(i));
+				}	
+			}
+			
+			prevX=xp_[j];
+			prevY=yp_[j];
+
+			n++;
+		}
+	}	
+
+	qDebug() << "Current"  << n;
+}
+
+void MgQSymbolSetItem::addPoint(double x, double y)
+{
+	xp_.push_back(x);
+	yp_.push_back(y);
+}
+
+//====================================
+//
+//  Manager
+//
+//====================================
+
+MgQSymbolManager::~MgQSymbolManager()
+{	
+	foreach(MgQSymbolItem *item, symbols_)
+	{		
+		delete item;
+	}
+}
+
+MgQSymbolItem* MgQSymbolManager::getSymbol(const QString& id,const float size)
+{	
+	foreach(MgQSymbolItem *item, symbols_) 
+	{
+		if( item->equal(id,size) == true)
+		{
+			return item;
+		}
+	}
+	
+	return 0;		
+}
+
+
+MgQSymbolItem* MgQSymbolManager::addSymbol(const QString& id,const float size)
+{
+	MgQSymbolItem *sym = getSymbol(id,size);
+	
+	if(sym) 
+	{
+		return sym;
+	}
+	else
+	{	
+		sym=new MgQSymbolItem(id,size);
+		symbols_.push_back(sym);
+	}
+	
+	return sym;
+}
+
+void MgQSymbolManager::deleteSymbol(const QString& id,const float size)	
+{	
+	foreach(MgQSymbolItem *item, symbols_)
+	{
+		if( item->equal(id,size) == true)
+		{
+			delete item;
+			return;
+		}	
+	}
+}	
\ No newline at end of file
diff --git a/src/drivers/MgQ/MgQSymbol.h b/src/drivers/MgQ/MgQSymbol.h
new file mode 100644
index 0000000..50218a8
--- /dev/null
+++ b/src/drivers/MgQ/MgQSymbol.h
@@ -0,0 +1,131 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQSymbol.h
+    \brief Definition of MgQSymbol.
+    \author Graphics Section, ECMWF
+
+    Started: Feb 2010
+*/
+
+#ifndef _MgQSymbol_H
+#define _MgQSymbol_H
+
+#include <QBrush>
+#include <QGraphicsItem>
+#include <QList>
+#include <QPainterPath>
+#include <QPen>
+#include <QString>
+
+#include "MgQ.h"
+
+class MgQPainterPath : public QPainterPath
+{
+public:
+	MgQPainterPath(bool filled,bool defaultFill=false) :
+		filled_(filled),defaultFill_(defaultFill), renderOnlyForOutline_(false) {};
+	bool isFilled() const {return filled_;}
+	bool isDefaultFill() const {return defaultFill_;}
+	void setRenderOnlyForOutline(bool b) {renderOnlyForOutline_=b;}
+	bool renderOnlyForOutline() const {return renderOnlyForOutline_;}
+
+  protected:
+	bool filled_;
+	bool defaultFill_;
+	bool renderOnlyForOutline_;
+};
+
+class MgQSymbolItem
+{
+public:
+	MgQSymbolItem(QString id,float s) : id_(id), size_(s) {};
+
+	const QString&  id() const   {return id_;}
+	float size()  {return size_;};
+	bool equal(const QString&,const float);
+	const QList<MgQPainterPath>& paths() const {return paths_;}
+	void addPath(MgQPainterPath &p) {paths_.push_back(p);}
+	bool hasFilledPart();
+
+protected:
+	QString id_;
+	float size_;
+	QList<MgQPainterPath> paths_;	
+};
+
+class MgQSymbolManager : public QList<MgQSymbolItem*>
+{
+public:
+	MgQSymbolManager() {};
+	~MgQSymbolManager();
+ 
+	MgQSymbolItem* addSymbol(const QString&,const float);
+	MgQSymbolItem* getSymbol(const QString&,const float);	
+	void deleteSymbol(const QString&,const float);		
+
+	int    symbolNum() {return symbols_.count();};	
+
+protected:
+	QList<MgQSymbolItem*> symbols_;
+};	
+	
+class MgQSymbolSetItem : public QGraphicsItem
+{
+public:
+	enum {Type = MgQ::SymbolSetItemType}; 
+	
+	MgQSymbolSetItem(MgQSymbolItem* symbol,QRectF &boundingRect,
+				QGraphicsItem* parent = 0) : 
+				QGraphicsItem(parent), symbol_(symbol),
+				boundingRect_(boundingRect), keepSizeWhenScaling_(false),
+				outline_(false), connectLine_(false) {};
+
+	QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+	int type() const {return Type;}
+
+	void setColor(QColor);
+	void setOutlineColor(QColor);
+	void addPoint(double,double);
+	void setKeepSizeWhenScaling(bool b) {keepSizeWhenScaling_=b;}
+	bool connectLine() {return connectLine_;}
+	void setConnectLine(bool b) {connectLine_=b;}
+	void setConnectLinePen(QPen);
+
+protected:
+	QList<double> xp_;
+	QList<double> yp_;
+	MgQSymbolItem* symbol_;
+	QPen pen_;
+	QList<QBrush> brushes_;
+	QRectF boundingRect_;	
+	bool keepSizeWhenScaling_;
+	bool outline_;
+	bool connectLine_;
+	QPen connectLinePen_;
+};
+
+
+
+
+#endif 
diff --git a/src/drivers/MgQ/MgQTextItem.cc b/src/drivers/MgQ/MgQTextItem.cc
new file mode 100644
index 0000000..b748570
--- /dev/null
+++ b/src/drivers/MgQ/MgQTextItem.cc
@@ -0,0 +1,61 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQTextItem.cc
+    \brief Definition of MgQTextItem
+    \author Graphics Section, ECMWF
+
+    Started: March2010
+*/
+
+#include "MgQTextItem.h"
+
+#include <QDebug>
+#include <QPainter>
+
+
+MgQTextItem::MgQTextItem(const QString &text,QGraphicsItem* parent) : 
+	QGraphicsSimpleTextItem(text,parent),  textBlanking_(false)
+{
+
+}
+
+MgQTextItem::~MgQTextItem()
+{	
+
+}
+
+QRectF MgQTextItem::boundingRect() const
+{
+	return QGraphicsSimpleTextItem::boundingRect();
+}
+
+void MgQTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                QWidget *widget)
+{
+	if(textBlanking_)
+	{
+		painter->fillRect(boundingRect(),Qt::white);			
+	}
+
+	QGraphicsSimpleTextItem::paint(painter,option,widget);
+
+}
diff --git a/src/drivers/MgQ/MgQTextItem.h b/src/drivers/MgQ/MgQTextItem.h
new file mode 100644
index 0000000..50effc4
--- /dev/null
+++ b/src/drivers/MgQ/MgQTextItem.h
@@ -0,0 +1,56 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file MgQTextItem.h
+    \brief Definition of MgQTextItem.
+    \author Graphics Section, ECMWF
+
+    Started: March 2010
+*/
+
+#ifndef _MgQTextItem_H
+#define _MgQTextItem_H
+
+#include <QGraphicsSimpleTextItem>
+
+#include "MgQ.h"
+
+class MgQTextItem : public QGraphicsSimpleTextItem
+{
+public:
+	enum {Type = MgQ::TextItemType}; 
+	
+	MgQTextItem(const QString& ,QGraphicsItem* parent = 0);
+	~MgQTextItem();
+	
+	void setBoundingRectSize(float s) {boundingRectSize_=s;}
+	QRectF boundingRect() const;
+	void paint(QPainter *, const QStyleOptionGraphicsItem *,
+                QWidget *widget=0);
+	int type() const {return Type;}
+	void setTextBlanking(bool b) {textBlanking_=b;}
+
+protected:
+	float boundingRectSize_;
+	bool  textBlanking_;
+};
+
+#endif 
diff --git a/src/drivers/PostScriptDriver.cc b/src/drivers/PostScriptDriver.cc
new file mode 100644
index 0000000..009619b
--- /dev/null
+++ b/src/drivers/PostScriptDriver.cc
@@ -0,0 +1,1625 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ 	http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PostScriptDriver.cc
+    \brief Implementation of PostScriptDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: March 2004
+
+*/
+
+#include <PostScriptDriver.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+#include <System.h>
+#include <Symbol.h>
+#include <iomanip>
+
+/*! \brief function to convert between PS ISO encoding and Unicode
+
+See <a href="http://www.w3.org/TR/REC-html40/sgml/entities.html">entities.html</a> for
+a description of the characters.
+\sa TextNode.cc
+\note C O P I E D   F R O M  TEXTNODE.CC
+*/
+string specialPS(const string& sp)
+{
+	static map<string, string> specialsPS;
+	if ( specialsPS.empty() )
+	{
+		specialsPS["©"] = "251"; //copyright
+		specialsPS["°"] = "260"; //degres
+		specialsPS["956"] = "265"; //mu
+		specialsPS["¼"] = "274"; //vulgar fraction one quarter
+		specialsPS["½"] = "275"; //vulgar fraction one half
+		specialsPS["¾"] = "276"; //vulgar fraction three quarters
+		specialsPS["¿"] = "277"; //inverted question mark
+		specialsPS["À"] = "300"; //latin capital letter A with grave
+		specialsPS["Á"] = "301"; //latin capital letter A with acute
+
+		specialsPS["Ã"] = "303"; //latin capital letter A with tilde
+		specialsPS["Ä"] = "304"; //latin capital letter A with diaeresis
+		specialsPS["Å"] = "305"; //latin capital letter A with ring above
+		specialsPS["Æ"] = "306"; //latin capital letter AE
+		specialsPS["Ç"] = "307"; //latin capital letter C with cedilla
+
+		specialsPS["È"] = "310"; //latin capital letter E with grave
+		specialsPS["É"] = "311"; //latin capital letter E with acute
+		specialsPS["Ê"] = "312"; //latin capital letter E with circumflex
+		specialsPS["Ë"] = "313"; //latin capital letter E with  diaeresis
+
+		specialsPS["Ì"] = "314"; //latin capital letter I with grave
+		specialsPS["Í"] = "315"; //latin capital letter I with acute
+		specialsPS["Î"] = "316"; //latin capital letter I with circumflex
+		specialsPS["Ï"] = "317"; //latin capital letter I with  diaeresis
+
+		specialsPS["Ñ"] = "321"; //latin capital letter N with tilde
+
+		specialsPS["Ò"] = "322"; //latin capital letter O with grave
+		specialsPS["Ó"] = "323"; //latin capital letter O with acute
+		specialsPS["Ô"] = "325"; //latin capital letter O with  diaeresis
+		specialsPS["Õ"] = "330"; //latin capital letter O slash
+
+		specialsPS["Ù"] = "331"; //latin capital letter U with grave
+		specialsPS["Ú"] = "332"; //latin capital letter U with acute
+		specialsPS["Û"] = "333"; //latin capital letter U with circumflex
+		specialsPS["Ü"] = "334"; //latin capital letter U with  diaeresis
+
+		specialsPS["Ý"] = "335"; //latin capital letter Y with acute
+
+		specialsPS["Þ"] = "336"; //latin capital letter THORN
+		specialsPS["ß"] = "337"; //latin small letter sharp s = ess-zed
+
+		specialsPS["à"] = "340"; //latin small letter a with grave
+		specialsPS["á"] = "341"; //latin small letter a with cute
+		specialsPS["â"] = "342"; //latin small letter a with circumflex
+		specialsPS["ã"] = "343"; //latin small letter a with tilde
+		specialsPS["ä"] = "344"; //latin small letter a with  diaeresis
+		specialsPS["å"] = "345"; //latin small letter a with ring above
+		specialsPS["æ"] = "346"; //latin small letter ae
+		specialsPS["ç"] = "347"; //latin small letter c with cedilla
+
+		specialsPS["è"] = "350"; //latin small letter e with grave
+		specialsPS["é"] = "351"; //latin small letter e with cute
+		specialsPS["ê"] = "352"; //latin small letter e with circumflex
+		specialsPS["ë"] = "353"; //latin small letter e with ring above
+
+		specialsPS["ì"] = "354"; //latin small letter i with grave
+		specialsPS["í"] = "355"; //latin small letter i with cute
+		specialsPS["î"] = "356"; //latin small letter i with circumflex
+		specialsPS["ï"] = "357"; //latin small letter i with diaeresis
+
+		specialsPS["ñ"] = "361"; //latin small letter n with tilde
+
+		specialsPS["ò"] = "362"; //latin small letter o with grave
+		specialsPS["ó"] = "363"; //latin small letter o with cute
+		specialsPS["ö"] = "364"; //latin small letter o with diaeresis
+		specialsPS["õ"] = "365"; //latin small letter o with tilde
+
+		specialsPS["ø"] = "370"; //latin small letter o slash
+
+		specialsPS["ù"] = "371"; //latin small letter u with grave
+		specialsPS["ú"] = "372"; //latin small letter u with cute
+		specialsPS["û"] = "373"; //latin small letter u with circumflex
+		specialsPS["ü"] = "374"; //latin small letter u with diaeresis
+
+		specialsPS["ý"] = "375"; //latin small letter y with acute
+
+		specialsPS["þ"] = "376"; //latin small letter THORN
+		specialsPS["ÿ"] = "377"; //latin small letter y with diaeresis
+	}
+
+	const map<string, string>::iterator f = specialsPS.find(sp);
+	return( f == specialsPS.end() ) ? "" : "\\"+f->second;
+}
+
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+
+The PostScript driver produces one or more (if split is activated) text files
+in PostScript format.
+
+*/
+PostScriptDriver::PostScriptDriver() : ps_(true),pdf_(false),eps_(false),old_(true),
+				maxPathSize_(200),deviceColourModel_(1)
+{
+  readFonts();
+}
+
+/*!
+  \brief Destructor
+*/
+PostScriptDriver::~PostScriptDriver()
+{
+  relieveFonts();
+}
+
+/*!
+  \brief Opening the driver
+*/
+void PostScriptDriver::open()
+{
+	currentPage_ = 0;
+	setCMscale(resolution_/2.54);// cm -> pixel
+	if(!isSplit()) openFile();
+}
+
+/*!
+  \brief Closing the driver
+*/
+void PostScriptDriver::close()
+{
+	if(!isSplit()) closeFile();
+
+	currentPage_ = 0; // reset values for new pages ...
+	coordRatioX_ = 1.;
+	coordRatioY_ = 1.;
+}
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up. Strongly
+  depends on what output was selected (split or eps)
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::startPage() const
+{
+	dimensionX_ = convertCM(getXDeviceLength()); // 72   = points / inch
+	dimensionY_ = convertCM(getYDeviceLength()); // 2.54 = cm / inch
+
+	MFloat resolution=resolution_;
+	MFloat ratio=1.;
+	int    width=0;
+	string mbg_tmpl = mgb_template_;
+
+	if(!mbg_tmpl.empty())
+	{
+		setDimensionsFromBinary(mbg_tmpl,ratio,width);
+		setCMscale(35.);
+		resolution=80.; // dpi for web
+		dimensionX_ = width;
+		dimensionY_ = maground(dimensionX_*ratio);
+	}
+
+	newPage_ = true;
+//	if(currentPage_ > 0) endPage();
+	if(isSplit()) openFile();
+	currentPage_++;
+	fstream *ps = getStream();
+
+	if(!isSplit()) *ps << "%%Page: " << currentPage_ << " " << currentPage_ << "\n";
+	else *ps << "%%Page: 1 1\n";
+
+	// Here the whole page gets scaled to the resolution!
+	*ps << "gs " << 72./resolution << " dup s ";
+if(old_)
+{
+	if( ( isEPS() && (dimensionX_ < dimensionY_) ) ||
+	    (!isEPS() && (dimensionX_ > dimensionY_) ) )
+		*ps << static_cast<int>(dimensionY_) << " 0 t 90 ro ";
+}
+	*ps << "1 lw [] 0 sd ";
+
+	setDeviceColourModel(colour_model_);
+
+	*ps << "2 setlinejoin 0 1 SUP 0 10 SF 0 SHA 0 SVA\n"; // MITER is now always on
+	*ps << "0 0 0 0 Y n 0 0 m "<< dimensionX_<<" 0 rl 0 "<< dimensionY_ <<" rl "<< -dimensionX_<<" 0 rl cp fill\n";// force white background
+	currentColour_ = Colour("none");
+	if(scale_<1.0)
+	{
+	  *ps << dimensionX_*.5<< " " << dimensionY_*.5 << " t\n";
+	  *ps << scale_<< " " << scale_ << " s\n";
+	  *ps << -dimensionX_*.5<< " " << -dimensionY_*.5 << " t\n";
+	}
+}
+
+/*!
+  \brief ending a page
+
+  This method has to take care that for formats with multiple output
+  files are closed.
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::endPage() const
+{
+	fstream *ps = getStream();
+	*ps << "S\n";
+	debugOutput("End of page");
+	if(isSplit()) closeFile();
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::project(const magics::Layout& layout) const
+{
+	currentWrittenColour_=Colour("NONE");
+	debugOutput("Begin layout "+layout.name());
+
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+
+	MFloat offsetX_ = (layout.x()     * 0.01 * dimensionX_);
+	MFloat offsetY_ = (layout.y()     * 0.01 * dimensionY_);
+	dimensionX_  =     layout.width() * 0.01 * dimensionX_;
+	dimensionY_  =     layout.height()* 0.01 * dimensionY_;
+
+	const MFloat sumX = layout.maxX() - layout.minX();
+	const MFloat sumY = layout.maxY() - layout.minY();
+
+	if( sumX!=0 && sumY!=0 )
+	{
+		coordRatioX_ = (dimensionX_/sumX);
+		coordRatioY_ = (dimensionY_/sumY);
+	}
+
+	const MFloat X_ = offsetX_+projectX( -layout.minX());
+	const MFloat Y_ = offsetY_+projectY( -layout.minY());
+
+	fstream *ps = getStream();
+	*ps	<< "gs";
+//	if(fabs(X_) > 0.0001 && fabs(Y_) > 0.0001 )
+		*ps<<" "<< X_ <<" "<< Y_ <<" t";
+	*ps	<<"\n";
+
+}
+
+/*!
+  \brief reproject out of the last Layout
+
+  This method will update the offset and scale to the state they were before the
+  last Layout was received.
+
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::unproject() const
+{
+	currentWrittenColour_=Colour("NONE");
+	dimensionY_ = dimensionStack_.top();dimensionStack_.pop();
+	dimensionX_ = dimensionStack_.top();dimensionStack_.pop();
+	coordRatioX_  = scalesX_.top();scalesX_.pop();
+	coordRatioY_  = scalesY_.top();scalesY_.pop();
+	
+	fstream *ps = getStream();
+	*ps << "gr\n";
+	setLineParameters(M_SOLID, 1);
+	debugOutput("End layout");
+}
+
+
+/*!
+  \brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the
+  current box is finished.
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::setNewColour(const Colour &colour) const
+{
+	if(currentColour_ == colour) return;
+	currentColour_ = colour;
+}
+
+MAGICS_NO_EXPORT void PostScriptDriver::writeColour() const
+{
+	if(currentWrittenColour_==currentColour_) return;
+	currentWrittenColour_=currentColour_;
+	MFloat c,m,y,k,gray;
+	const MFloat r = currentColour_.red();
+	const MFloat g = currentColour_.green();
+	const MFloat b = currentColour_.blue();
+
+	fstream *ps = getStream();
+	streamsize ss = ps->precision(2);
+	switch(getDeviceColourModel())
+	{
+		case 0:    // rgb
+			*ps << r << " " << g << " " << b << " C\n";
+			break;
+		case 1:    // CMYK
+			c = 1. - r;
+			m = 1. - g;
+			y = 1. - b;
+			k = (c < m) ? c : m;
+			k = (y < k) ? y : k;
+			if( k == 1. )
+				*ps << "0 0 0 1 Y\n";
+			else
+			{
+				c = (c - k) / (1.-k);
+				m = (m - k) / (1.-k);
+				y = (y - k) / (1.-k);
+				*ps << c << " " << m << " " << y << " " << k << " Y\n";
+			}
+			break;
+		case 2 :     // monochrome - RGB
+			if ( (r ==1.) && (g == 1.) && ( b ==1. ))
+				*ps << "1 1 1 C\n";
+			else
+				*ps << "0 0 0 C\n";
+			break;
+		case 3:     // RGB gray
+			gray = 0.3*r + 0.59*g + 0.11*b;
+			*ps << gray << " " << gray << " " << gray << " C\n";
+			break;
+		case 4 :    // monochrome - CMYK
+			if ( (r ==1.) && (g == 1.) && ( b ==1. ))
+				*ps << "0 0 0 0 Y\n";
+			else
+				*ps << "0 0 0 1 Y\n";
+			break;
+		case 5:    // CMYK gray
+			gray = 0.3*r + 0.59*g + 0.11*b;
+			*ps << "0 0 0 " << gray << " Y\n";
+			break;
+		default:   // RGB
+			*ps << r << " " << g << " " << b << " C\n";
+			break;
+	}// end switch
+	ps->precision(ss);
+}
+
+/*!
+  \brief sets a new line width
+
+  This line width stays the default width until the painting in the
+  current box is finished. 
+
+  \sa setLineParameters()
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::setNewLineWidth(const MFloat width) const
+{
+	if(currentLineWidth_ == width) return;
+	currentLineWidth_ = width;
+
+	fstream *ps = getStream();
+	*ps << currentLineWidth_<< " lw\n";
+}
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the
+  current box is finished.
+
+  \sa LineStyle
+
+  \param linestyle Object describing the line style
+  \param w width of the line
+
+*/
+MAGICS_NO_EXPORT int PostScriptDriver::setLineParameters(const LineStyle linestyle, const MFloat w) const
+{
+	setNewLineWidth(w);
+	if(currentLineType_ == linestyle) return 0;
+	currentLineType_ = linestyle;
+
+	fstream *ps = getStream();
+
+	const int width = (int)(currentLineWidth_+.5);
+	const int sw = (currentLineWidth_ > 2.) ? 1 : 0;
+
+	switch(currentLineType_)
+	{
+		case M_SOLID:
+			*ps << "[] 0 sd\n";
+			break;
+		case M_DASH:
+			*ps << "["  <<
+				(( sw ) ?  4*width : 16 ) << " " <<
+				(( sw ) ?  1*width :  8 ) << "] 8 sd\n";
+			break;
+		case M_DOT:
+			*ps << "[" <<
+				(( sw ) ? width : 4 ) << " " <<
+				(( sw ) ? width : 8 ) << "] 4 sd\n";
+			break;
+		case M_CHAIN_DASH:
+			*ps << "[" <<
+				( (sw) ? width*4 : 16 ) << " " <<
+				( (sw) ? width*1 :  8 ) << " " <<
+				( (sw) ? width*1 :  4 ) << " " <<
+				( (sw) ? width*1 :  8 ) << " "
+				<< "] 0 sd\n";
+			break;
+		case M_CHAIN_DOT:
+			*ps << "[" <<
+				( (sw) ? width*4 : 12 ) << " " <<
+				( (sw) ? width*1 :  8 ) << " " <<
+				( (sw) ? width*1 :  4 ) << " " <<
+				( (sw) ? width*1 :  8 ) << " " <<
+				( (sw) ? width*1 :  4 ) << " " <<
+				( (sw) ? width*1 :  8 ) << " "
+				<< "] 0 sd\n";
+			break;
+		default:
+			*ps << "[] 0 sd\n";
+			break;
+	}// end switch
+	return 0;
+}
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+	if(n < 2 || (currentColour_==Colour("NONE"))) return;
+	writeColour();
+
+	MFloat *xx = x;
+	MFloat *yy = y;
+
+	std::fstream *ps = getStream();
+
+	if(n == 2)
+	{
+		const MFloat ix0 = projectX(*xx);
+		xx++;
+		const MFloat iy0 = projectY(*yy);
+		yy++;
+		const MFloat dx0 = projectX(*xx)-ix0;
+		const MFloat dy0 = projectY(*yy)-iy0;
+		if( zero(dx0)&&zero(dy0) ) return;
+		*ps << dx0 << " " << dy0 << " " << ix0 << " " << iy0 <<" B\n";
+	}
+	else
+	{
+		int nn = n;
+		MFloat *dx,*dy;
+		streamsize ss = ps->precision(2);
+
+		while(nn>1)
+		{
+			unsigned int p = ( nn > int(maxPathSize_)) ? maxPathSize_ : nn;
+			dx = new MFloat[p+1];
+			dy = new MFloat[p+1];
+
+			MFloat kx = projectX(*xx);
+			xx++;
+			MFloat ky = projectY(*yy);
+			yy++;
+
+			*(dx++) = kx;
+			*(dy++) = ky;
+
+			unsigned int i;
+			for(i=1; i<p; i++)
+			{
+				const MFloat cx = projectX(*xx);xx++;
+				*(dx++) = cx - kx;
+				kx = cx;
+				const MFloat cy = projectY(*yy);yy++;
+				*(dy++) = cy - ky;
+				ky = cy;
+			}
+
+			int counter = 0; // to avoid to long lines
+			for(i=p-1; i>0; i--)
+			{
+				const MFloat ddx = *(--dx);
+				const MFloat ddy = *(--dy);
+
+				if( !(zero(ddx) && zero(ddy)) )
+				{
+					*ps << ddx << " " << ddy<< " ";
+					counter++;
+				}
+				else
+					p--;
+
+				if(counter>15) {*ps << "\n";counter=0;}
+			}
+			--dx;--dy;
+
+			if(p>1) *ps << p-1 << " " << *dx << " " << *dy << " p\n";
+
+			nn = nn - maxPathSize_;
+			if(++nn>1)
+			{
+				// Compensate for additional point (last becomes first)
+				--xx;--yy;
+			}
+			delete [] dx;
+			delete [] dy;
+		}// end while
+		ps->precision(ss);
+	}
+}
+
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::renderPolyline2(const int n, MFloat* x, MFloat* y) const
+{
+	if(n != 2 || (currentColour_==Colour("NONE"))) return;
+	writeColour();
+
+	MFloat *xx = x;
+	MFloat *yy = y;
+
+	const MFloat ix0 = *xx;
+	xx++;
+	const MFloat iy0 = *yy;
+	yy++;
+	const MFloat dx0 = *xx-ix0;
+	const MFloat dy0 = *yy-iy0;
+
+	if( zero(dx0) && zero(dy0) ) return;
+
+	std::fstream *ps = getStream();
+	*ps << dx0 << " " << dy0 << " " << ix0 << " " << iy0 <<" B\n";
+}
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param line polyline to be filled
+*/
+void PostScriptDriver::renderSimplePolygon(const Polyline& line) const
+{ 
+	unsigned int n = line.size();
+	setNewColour(line.getFillColour());
+	line.getShading()->draw(*this);
+
+	if( n<3 || (currentColour_==Colour("NONE")) ) return;
+	writeColour();
+
+	std::fstream *ps = getStream();
+	*ps << "gs\n";
+
+	if (currentShading_==M_SH_DOT)
+	{
+		const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+		const int density = (int)sqrt(pro->density_);
+		if(density<=0) return;
+		const MFloat square_size = convertCM(1.)/density;
+
+		int s = (int)pro->size_*convertCM(1.);
+		if (s<2) s = 2;
+
+		const MFloat r = currentColour_.red();
+		const MFloat g = currentColour_.green();
+		const MFloat b = currentColour_.blue();
+
+		MFloat c = 1. - r;
+		MFloat m = 1. - g;
+		MFloat z = 1. - b;
+		MFloat k = (c < m) ? c : m;
+		      k = (z < k) ? z : k;
+
+		*ps
+		    << "/Pat {\n gs 0 0 " << square_size << " " << square_size << " rectclip gr gs ";
+		    if( k == 1. )
+		      *ps << "0 0 0 1";
+		    else
+		    {
+		     c = (c - k) / (1.-k);
+		     m = (m - k) / (1.-k);
+		     z = (z - k) / (1.-k);
+		     *ps << c << " " << m << " " << z << " " << k;
+		    }
+		*ps << " setcmykcolor 1 1 m 0 "<<s<<" rl "<<s<<" 0 rl 0 -"<<s<<" rl cp fill gr "
+		    << "} bind def\n"
+		    << "<< /PatternType 1 /PaintType 1 /TilingType 1\n"
+		    << "/BBox [0 0 "<<square_size<<" "<<square_size<<"] /XStep "<<square_size<<" /YStep "<<square_size<<"\n"
+		    << "/PaintProc { Pat }\n"
+		    << ">>\n"
+		    << "matrix makepattern setpattern\n";
+	}
+	else if (currentShading_==M_SH_HATCH)
+	{
+		const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+		indexHatch_ = pro->index_;
+		if(indexHatch_<1 || indexHatch_>6)
+		{
+			MagLog::warning() << "PostScriptDriver::renderSimplePolygon > Hatch index " <<indexHatch_<<" is wrong. No hatch sahding possible!" << endl;
+			return;
+		}
+		const int s = (int)(pro->density_);
+
+		const MFloat r = currentColour_.red();
+		const MFloat g = currentColour_.green();
+		const MFloat b = currentColour_.blue();
+
+		MFloat c = 1. - r;
+		MFloat m = 1. - g;
+		MFloat z = 1. - b;
+		MFloat k = (c < m) ? c : m;
+		      k = (z < k) ? z : k;
+
+		*ps
+		    << "/Pat {\n gs 0 0 " << s << " " << s << " rectclip gr gs ";
+		    if( k == 1. )
+		      *ps << "0 0 0 1";
+		    else
+		    {
+		     c = (c - k) / (1.-k);
+		     m = (m - k) / (1.-k);
+		     z = (z - k) / (1.-k);
+		     *ps << c << " " << m << " " << z << " " << k;
+		    }
+
+		*ps << " setcmykcolor";
+
+		if(indexHatch_==1 || indexHatch_==3) // horizontal
+		{
+			*ps  << " 0 "<<s*.5<<" m "<<s<<" 0 rl st";
+		}
+		if(indexHatch_==2 || indexHatch_==3)
+		{
+			*ps  << " "<<s*.5<<" 0 m 0 "<<s<<" rl st";
+		}
+		if(indexHatch_==4 || indexHatch_==6)
+		{
+			*ps  << " 0 0 m "<<s<<" "<<s<<" rl st";
+		}
+		if(indexHatch_==5 || indexHatch_==6)
+		{
+			*ps  << " 0 "<<s<<" m "<<s<<" -"<<s<<" rl st";
+		}
+
+		*ps << " gr } bind def\n"
+		    << "<< /PatternType 1 /PaintType 1 /TilingType 1\n"
+		    << "/BBox [0 0 "<<s<<" "<<s<<"] /XStep "<<s<<" /YStep "<<s<<"\n"
+		    << "/PaintProc { Pat }\n"
+		    << ">>\n"
+		    << "matrix makepattern setpattern\n";
+	}// end hatch
+
+	*ps << "n ";
+
+	Polyline::Holes::const_iterator h = line.beginHoles();
+	Polyline::Holes::const_iterator he = line.endHoles();
+
+	for (; h != he; ++h)
+	{
+		vector<double> x;
+		vector<double> y;
+		line.hole(h,x,y);
+		MFloat old_x = projectX(x[0]);
+		MFloat old_y = projectY(y[0]);
+		unsigned int nt = x.size();
+
+//		if ( (line[n-1].x() == line[0].x()) && (line[n-1].y() == line[0].y()) ) {x_end--;nt--;}
+
+		int pcounter=0;
+		for(int i = nt-1; i > -1; --i)
+		{
+		  const MFloat xx = projectX(x[i]);
+		  const MFloat yy = projectY(y[i]);
+		  const MFloat diffX = old_x-xx;
+		  const MFloat diffY = old_y-yy;
+
+		  if( !(zero(diffX) && zero(diffY)) )
+		  {
+		    *ps << diffX <<" "<< diffY<<" ";
+		    old_x = xx;
+		    old_y = yy;
+		    pcounter++;
+		    if(pcounter%10==0) *ps << "\n";
+		  }
+		}
+		*ps << pcounter << " " << projectX(x[0]) << " " << projectY(y[0]) << " F P\n";
+	}
+
+	if ( (line.get(n-1).x() == line.get(0).x()) && (line.get(n-1).y() == line.get(0).y()) ) n--;
+
+	MFloat old_x = projectX(line.get(0).x());
+	MFloat old_y = projectY(line.get(0).y());
+
+	const MFloat mx = old_x;
+	const MFloat my = old_y;
+	int pcounter=0;
+	for(int i = n-1; i > -1; --i)
+	{
+		const PaperPoint& pp = line.get(i);
+		const MFloat xx = projectX(pp.x());
+		const MFloat yy = projectY(pp.y());
+		const MFloat diffX = old_x-xx;
+		const MFloat diffY = old_y-yy;
+
+/*		if(zero(diffX) && (pp.x()==line[i+1].x()))
+		{
+		  int j = i+1;
+		  while(pp.x()==line[j].x())
+		  {
+		    j++;
+		  }
+		  i=j;
+		  *ps << "0 " << old_y-projectY(line[i].y()) << " ";
+		   old_y = projectY(line[i].y());
+		   if(pcounter%10==0) *ps << "\n";
+		   pcounter++;
+		}
+		else */ 
+if( !(zero(diffX) && zero(diffY)) )
+		{
+		   *ps <<  diffX << " " << diffY << " ";
+		   old_x = xx;
+		   old_y = yy;
+		   if(pcounter%10==0) *ps << "\n";
+		   pcounter++;
+		}
+	}
+	*ps << pcounter << " " << mx << " " << my << " F P\n";
+
+	*ps << "E gr\n";
+}
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::renderSimplePolygon(const int n, MFloat* x, MFloat* y) const
+{
+	if(n<3 || (currentColour_==Colour("NONE"))) return;
+
+//MagLog::dev()<< "PS_SIMPLE " << n<<" points   col: "<< currentColour_<< endl;
+
+	int nn = n;
+	if ( (x[nn-1] == x[0]) && (y[nn-1] == y[0]) ) nn--;
+
+	const int N = nn+1;
+	MFloat *rx = new MFloat[N];
+	MFloat *ry = new MFloat[N];
+	MFloat *dx = rx; dx++;
+	MFloat *dy = ry; dy++;
+	MFloat *xx = x, *yy = y;
+	MFloat fx = projectX(*(xx++));
+	MFloat fy = projectY(*(yy++));
+
+	int i;
+	for( i = 1; i<nn; i++)
+	{
+		const MFloat pxx = projectX(*xx);
+		const MFloat pyy = projectY(*yy);
+		*(dx++) = pxx - fx; fx = pxx; xx++;
+		*(dy++) = pyy - fy; fy = pyy; yy++;
+	}
+
+	std::fstream *ps = getStream();
+	
+
+	if (currentShading_==M_SH_DOT)
+	{
+		const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+		const int density = (int)sqrt(pro->density_);
+		if(density<=0)
+		{
+			if(density<0) MagLog::warning() << "PostScriptDriver::renderSimplePolygon > Dot density " <<density<<" is negative! No shading applied" << endl;
+			return;
+		}
+		const MFloat square_size = convertCM(1.)/density;
+
+		int s = (int)pro->size_*convertCM(1.) *.2;
+		if (s<2) s = 2;
+
+		const MFloat r = currentColour_.red();
+		const MFloat g = currentColour_.green();
+		const MFloat b = currentColour_.blue();
+
+		MFloat c = 1. - r;
+		MFloat m = 1. - g;
+		MFloat z = 1. - b;
+		MFloat k = (c < m) ? c : m;
+		      k = (z < k) ? z : k;
+
+		*ps << "gs  %%\n";
+
+		*ps
+		    << "/Pat {\n gs 0 0 " << square_size << " " << square_size << " rectclip gr gs ";
+		    if( k == 1. )
+		      *ps << "0 0 0 1";
+		    else
+		    {
+		     c = (c - k) / (1.-k);
+		     m = (m - k) / (1.-k);
+		     z = (z - k) / (1.-k);
+		     *ps << c << " " << m << " " << z << " " << k;
+		    }
+		*ps << " setcmykcolor 1 1 m 0 "<<s<<" rl "<<s<<" 0 rl 0 -"<<s<<" rl cp fill gr "
+		    << "} bind def\n"
+		    << "<< /PatternType 1 /PaintType 1 /TilingType 1\n"
+		    << "/BBox [0 0 "<<square_size<<" "<<square_size<<"] /XStep "<<square_size<<" /YStep "<<square_size<<"\n"
+		    << "/PaintProc { Pat }\n"
+		    << ">>\n"
+		    << "matrix makepattern setpattern\n";
+
+	}
+	else if (currentShading_==M_SH_HATCH)
+	{
+		const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+		indexHatch_ = pro->index_;
+		if(indexHatch_<1 || indexHatch_>6)
+		{
+			MagLog::warning() << "PostScriptDriver::renderSimplePolygon > Hatch index " <<indexHatch_<<" is wrong. No hatch shading possible!" << endl;
+			return;
+		}
+		const int s = (int)(pro->density_);
+
+		const MFloat r = currentColour_.red();
+		const MFloat g = currentColour_.green();
+		const MFloat b = currentColour_.blue();
+
+		MFloat c = 1. - r;
+		MFloat m = 1. - g;
+		MFloat z = 1. - b;
+		MFloat k = (c < m) ? c : m;
+		      k = (z < k) ? z : k;
+
+		*ps << "gs\n"
+		    << "/Pat {\n gs 0 0 " << s << " " << s << " rectclip gr gs ";
+		    if( k == 1. )
+		      *ps << "0 0 0 1";
+		    else
+		    {
+		     c = (c - k) / (1.-k);
+		     m = (m - k) / (1.-k);
+		     z = (z - k) / (1.-k);
+		     *ps << c << " " << m << " " << z << " " << k;
+		    }
+
+		*ps << " setcmykcolor";
+
+		if(indexHatch_==1 || indexHatch_==3) // horizontal
+		{
+			*ps  << " 0 "<<s*.5<<" m "<<s<<" 0 rl st";
+		}
+		if(indexHatch_==2 || indexHatch_==3)
+		{
+			*ps  << " "<<s*.5<<" 0 m 0 "<<s<<" rl st";
+		}
+		if(indexHatch_==4 || indexHatch_==6)
+		{
+			*ps  << " 0 0 m "<<s<<" "<<s<<" rl st";
+		}
+		if(indexHatch_==5 || indexHatch_==6)
+		{
+			*ps  << " 0 "<<s<<" m "<<s<<" -"<<s<<" rl st";
+		}
+
+		*ps << " gr } bind def\n"
+		    << "<< /PatternType 1 /PaintType 1 /TilingType 1\n"
+		    << "/BBox [0 0 "<<s<<" "<<s<<"] /XStep "<<s<<" /YStep "<<s<<"\n"
+		    << "/PaintProc { Pat }\n"
+		    << ">>\n"
+		    << "matrix makepattern setpattern\n";
+	}// end hatch
+	else
+	{
+	  *ps << "gs\n";
+	}
+
+	*dx = projectX(x[0]) - projectX(x[nn-1]);
+	*dy = projectY(y[0]) - projectY(y[nn-1]);
+	rx[0] = projectX(x[0]);
+	ry[0] = projectY(y[0]);
+
+	for ( i=nn; i>0; i--)
+	{
+		*ps << (*dx--) << " " << *(dy--)<< " ";
+	}
+	*ps <<nn << " " << rx[0] << " " << ry[0] << " e gr\n";
+
+	delete [] rx;
+	delete [] ry;
+//	currentShading_=M_SH_SOLID;
+}
+
+/*!
+  \brief renders text strings
+
+  This method renders given text strings.
+
+  \note As of version 2.0 there are two forms of describing text in Text.
+  \todo Underlining of text
+
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::renderText(const Text& text) const
+{
+	if(text.empty()) return;
+	const vector<NiceText>& niceT = text.getNiceText();
+	if(niceT.empty()) return;
+	currentWrittenColour_=Colour("NONE");   // reset colours
+
+	fstream *ps = getStream();
+	streamsize ss = ps->precision(2);
+
+	*ps << text.getJustification() << " SHA " << text.getVerticalAlign() << " SVA ";
+
+	vector<NiceText>::const_iterator niceText = text.textBegin();
+	vector<NiceText>::const_iterator niceTextEnd = text.textEnd();
+
+	int u=0;
+	ostringstream all_text;
+	for(;niceText<niceTextEnd;)
+	{
+		all_text << (*niceText).text();
+		niceText++;
+		u++;
+	}
+
+	niceText = text.textBegin();
+	MFloat old_offset = 0;
+	int count = 0;
+
+	for(;niceText<niceTextEnd;)
+	{
+		const MagFont magfont = (*niceText).font();
+		MFloat height = convertCM(magfont.size());
+		if(height < epsilon) {
+			++niceText;
+			continue;
+		}
+
+		const std::set<string>& styles = magfont.styles();
+		string style = "";
+		if(styles.find("bold") != styles.end()) style = "bold";
+		if(styles.find("italic") != styles.end()) style += "italic";
+		if(style == "") style = "normal";
+		const string lowFont = lowerCase(magfont.name()+"_"+style);
+		fontMapIter iter = FontMap_.find(lowFont);
+
+		const bool underlined = (styles.find("underlined") != styles.end()) ? true : false;
+
+		int font;
+		if(iter!=FontMap_.end())
+			font = iter->second.id;
+		else
+		{
+			font = 0; // if not found get default
+			MagLog::info() << "PostScriptDriver: Font "<< lowFont << " is not registered!\n   Default font used for "<<(*niceText).text()<<"."<< endl;
+		}
+
+		setNewColour(magfont.colour());
+		writeColour();
+
+		MFloat offset = 0;
+		if((*niceText).elevation()==NORMAL)           {offset= -old_offset; old_offset=0;}
+		else if((*niceText).elevation()==SUPERSCRIPT) {offset= height*.5 - old_offset; old_offset=offset; height *= .8; }
+		else if((*niceText).elevation()==SUBSCRIPT)   {offset=-height*.2 - old_offset; old_offset=offset; height *= .8; }
+
+		*ps << font << " " << static_cast<int>(height) << " SF ";
+
+		// plot strings
+		string textCommand = (text.getBlanking()) ? "TB" : "T";
+		if(underlined) textCommand = "TU";
+
+		const int len = (*niceText).text().length()+1;
+		char pp[len];
+		strcpy(pp, (*niceText).text().c_str());
+		string spp= (*niceText).text();
+		char *p = pp;
+		ostringstream tmp;
+		int counter=0;
+
+		while(*p)
+		{
+		  if ( *p == '(')    {tmp << "\\(";}
+		  else if ( *p == ')')    {tmp << "\\)";}
+		  else if ( *p == '\\')   {tmp << "\\\\";}
+		  else if ( *p & 0x80)    {tmp << specialPS(spp.substr(counter,2));}   // temp fix for multibyte char (degree sign)
+		  else                    {tmp << *p;}
+		  p++;
+		  counter++;
+		}
+
+	  const string showCommand = (underlined) ? "ushow" : "show";
+	  unsigned int noTexts = text.size();
+	  for(unsigned int nT=0;nT<noTexts;nT++)  // for all string CO-ORDINATES
+	  {
+		if(niceText == text.textBegin())
+		{
+			const MFloat x0 = projectX(text[nT].x());
+			const MFloat y0 = projectY(text[nT].y()) + offset;
+
+			if(u>1)
+			{
+				*ps <<"gs "<< x0 << " " << y0 << " t ("<< all_text.str() << ") stringwidth pop HA mul VA Height mul moveto "
+				    << "("<<tmp.str()<< ") "<<showCommand<<"\n";
+			}
+			else
+			{
+
+/*
+	MagLog::dev()<< "  PS TEXT >>> " << (*niceText).text()<<" " <<text.getAngle()<< "  ver:";
+	if (text.getVerticalAlign()==MBASE)      MagLog::dev()<< "MBASE";
+	else if (text.getVerticalAlign()==MTOP)  MagLog::dev()<< "MTOP";
+	else if (text.getVerticalAlign()==MHALF) MagLog::dev()<< "MHALF";
+	else if (text.getVerticalAlign()==MBOTTOM) MagLog::dev()<< "MBOTTOM";
+	else MagLog::dev()<< "???";
+	cout<<"  x: "<< text[nT].x()<< "   y: "<< text[nT].y()<< endl;
+*/
+				const MFloat an = 360.-(text.getAngle()*57.29577951);
+				if(an==0 || an==360)
+					*ps <<"gs "<< x0 << " " << y0 << " t ("<<tmp.str()<< ") 0 0 "<<textCommand<<"\n";
+				else
+					*ps <<"gs "<< x0 << " " << y0 << " t "<<an<< " ro ("<<tmp.str()<< ") 0 0 "<<textCommand<<"\n";
+			}
+		}
+		else
+		{
+		*ps << " 0 "<<offset<<" rmoveto\n";
+			*ps << "("<<tmp.str()<< ") "<<showCommand<<"\n";
+		}
+		count++;
+		if (niceText+1 == text.textEnd()) *ps <<"gr\n";
+	   }
+	   niceText++;
+	} // endfor all nicetexts
+	ps->precision(ss);
+	currentColour_ = Colour("none");
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s) const
+{
+	writeColour();
+	std::fstream *ps = getStream();
+	const MFloat cx = projectX(x);
+	const MFloat cy = projectY(y);
+
+	if(s < 8)
+	{
+		*ps << "n " << cx << " " << cy << " " << r << " 0 360 arc st\n";
+		if(s > 0)
+			*ps <<"n "<<cx<<" "<<cy<<" m "<<cx<<" "<<cy<<" "<<r<<" 90 "<<90-(s*45)<<" arn\n";
+	}
+	else *ps << "n " << cx << " " << cy << " " << r << " 0 360 ar\n";
+	if(s == 9)
+	{
+		*ps << "1 1 1 C n "<<cx<<" "<<cy+r-1<<" m 0 "<<-r-r+2<<" rl st\n";
+		const Colour col = currentColour_;
+		currentColour_ = Colour("white");
+		writeColour();
+		setNewColour(col);
+	}
+}
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \sa renderCellArray()
+
+  \param x0 x of lower corner
+  \param y0 y of lower corner
+  \param x1 x of higher corner
+  \param y1 y of higher corner
+  \param width width of pixmap
+  \param height height of pixmap
+  \param pixmap contents
+  \param landscape says if contents is landscape
+  \param alpha transparency of array
+*/
+MAGICS_NO_EXPORT bool PostScriptDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                                            int width,int height,unsigned char* pixmap,int landscape, bool alpha) const
+{
+	if(landscape) //swop w/h
+	{
+		 const int x = width;
+		 width = height;
+		 height = x;
+	}
+	if(height==0 || width==0)  return false;
+
+	unsigned char *p = pixmap;
+	std::fstream *ps = getStream();
+	const int col_model = getDeviceColourModel();
+	const MFloat dx = x1 - x0 + 1;
+	const MFloat dy = y1 - y0 + 1;
+
+	*ps << "gs /pic " << width*(( col_model == 1 ) ? 4 : 3) << " string def " << x0 << " " << y0
+	    << " t " << dx << " " << dy << " s " << width
+	    << " " << height << " 8\n"
+	    << "[" << width << " 0 0 " << height << " 0 0] "
+	    << "{currentfile pic readhexstring pop}"
+	    << " false " << (( col_model == 1 ) ? 4 : 3) <<" colorimage\n";
+
+	char *t = new char[9];
+	int nl = 0;
+	for(int j=height-1;j>=0;j--)
+	{
+	  for(int i=width-1;i>=0;i--)
+	  {
+		// Get image left-right and bottom-up
+		const int n = ( landscape ) ? (height*i+j)*3 : (j*width + width-1-i )*3;
+		unsigned char *p2 = p+n;
+		unsigned char r = *(p2++);
+		unsigned char g = *(p2++);
+		unsigned char b = *(p2++);
+		if(alpha) p2++;                 // ignore alpha values ... :-(
+		short kr,kg,kb,kc,km,ky,kk;
+		MFloat cc,cm,cy,ck;
+
+		switch ( col_model )
+		{
+			 case 0:
+				 sprintf(t,"%02hx%02hx%02hx",r,g,b);
+				 break;
+			 case 1:
+				 cc = 1. - (r*0.00392156); cm = 1. - (g*0.00392156); cy = 1. - (b*0.00392156);
+				 ck = ( cc < cm ) ?  cc : cm;
+				 if ( cy < ck ) ck = cy;
+				 if( ck == 1. )
+				 { kc = 0; km= 0; ky = 0; kk = 255;}
+				 else
+				 {
+					 kc = int( ((cc - ck) / (1.-ck)) * 255.);
+					 km = int( ((cm - ck) / (1.-ck)) * 255.);
+					 ky = int( ((cy - ck) / (1.-ck)) * 255.);
+					 kk = int( ck * 255.);
+				 }
+				 sprintf(t,"%02hx%02hx%02hx%02hx",kc,km,ky,kk);
+				 break;
+			 case 2:
+				 if ( (r ==255) && (g == 255) && ( b ==255 ))
+				  { kr = 255; kg = 255; kb = 255;}
+				 else
+				  { kr = 0; kg = 0; kb = 0;}
+				 sprintf(t,"%02hx%02hx%02hx",kr,kg,kb);
+				 break;
+			 case 3:
+				 kr = int(0.3*r + 0.59*g + 0.11*b);
+				 sprintf(t,"%02hx%02hx%02hx",kr,kr,kr);
+				 break;
+			 default:
+				 sprintf(t,"%02hx%02hx%02hx",r,g,b);
+				 break;
+		}
+		*ps << t;
+		if ( (++nl)%12 == 0) *ps << "\n";
+	   }
+	 }
+	 *ps << "gr" <<endl;
+	 currentColour_ = Colour("none");
+	 delete [] t;
+	 return true;
+}
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are
+  mainly used for satellite data.
+
+  \sa renderPixmap()
+
+  \param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool PostScriptDriver::renderCellArray(const Image& image) const
+{
+   ColourTable &lt  = image.getColourTable();
+   const int width  = image.getNumberOfColumns();
+   const int height = image.getNumberOfRows();
+
+//MagLog::dev()<<" PostScriptDriver::renderCellArray "<< width << endl;
+
+   if(width > 0 && height > 0)
+   {
+	const int col_model = getDeviceColourModel();
+	
+	const MFloat x0 = projectX(image.getOrigin().x());
+	const MFloat y0 = projectY(image.getOrigin().y()-image.getHeight());
+	const MFloat x1 = projectX(image.getOrigin().x()+image.getWidth());
+	const MFloat y1 = projectY(image.getOrigin().y());
+	const MFloat dx = x1 - x0 + 1;
+	const MFloat dy = y1 - y0 + 1;
+//	bool mask = false;
+
+	fstream *ps = getStream();
+	*ps << "gs /pic " << width*(( col_model == 1 ) ? 4 : 3) << " string def " << x0 << " " << y0
+	    << " t " << dx << " " << dy << " s " << width
+	    << " " << height << " 8\n"
+	    << "[" << width << " 0 0 " << height << " 0 0] "
+	    << "{currentfile pic readhexstring pop}"
+	    << " false " << (( col_model == 1 ) ? 4 : 3) <<" colorimage\n";
+
+	char *t = new char[9];
+	int nl = 0;
+	for (int i=height-1;i>=0;i--)
+	{
+		for (int j=0;j<width;j++)
+		{
+			short kr,kg,kb,kc,km,ky,kk;
+			MFloat cc,cm,cy,ck;
+			const int in = width*i+j;
+			const short c = image[in];
+
+			MFloat r = lt[c].red();
+			MFloat g = lt[c].green();
+			MFloat b = lt[c].blue();
+
+			if( (r*g*b>1) || (r*g*b<0) )
+			{
+				r = 1.;
+				g = 1.;
+				b = 1.;
+//				MagLog::info()<< "PostScriptDriver-> Cellshading colour not defined in table! Colour index: "<<c<<endl;
+//    PostScript will always 'overpaint' anything below missing data!!!!
+//
+			}
+
+			switch ( col_model )
+			{
+			 case 0:
+				 kr = short(r*255.);
+				 kg = short(g*255.);
+				 kb = short(b*255.);
+				 sprintf(t,"%02hx%02hx%02hx",kr,kg,kb);
+				 break;
+			 case 1:
+				 cc = 1.0 - r; cm = 1.0 - g; cy = 1. - b;
+				 ck = ( cc < cm ) ?  cc : cm;
+				 if ( cy < ck ) ck = cy;
+				 if( ck == 1. )
+				  { kc = 0; km = 0; ky = 0; kk = 255;}
+				 else
+				 {
+					 kc = short(((cc - ck) / (1.-ck)) * 255.);
+					 km = short(((cm - ck) / (1.-ck)) * 255.);
+					 ky = short(((cy - ck) / (1.-ck)) * 255.);
+					 kk = short(ck* 255.);
+				 }
+				 sprintf(t,"%02hx%02hx%02hx%02hx",kc,km,ky,kk);
+				 break;
+			 case 2:
+				 if ( (r ==1.) && (g == 1.) && ( b ==1. ))
+				  { kr = 255; kg = 255; kb = 255;}
+				 else
+				  { kr = 0; kg = 0; kb = 0;}
+				 sprintf(t,"%02hx%02hx%02hx",kr,kg,kb);
+				 break;
+			 case 3:
+				 ck = 0.3*r + 0.59*g + 0.11*b;
+				 kr = short(ck*255.);
+				 sprintf(t,"%02hx%02hx%02hx",kr,kr,kr);
+				 break;
+			}
+			*ps << t;
+			if ( (++nl)%12 == 0) *ps << "\n";
+		}
+	}
+	*ps << "gr" <<endl;
+	delete [] t;
+   }
+   else
+   {
+	MagLog::warning() << "PostScriptDriver: failed to plot CellArray with wrong dimensions! Width: "<<width<<" Height: "<<height <<endl;
+   }
+   return true;
+}
+
+
+/*!
+  \brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \note This can increase file and log file sizes if you run Magics++ in debug mode!
+
+  \param s string to be printed
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::debugOutput(const string &s) const
+{
+	if(debug_) PSOut_ << "%% "<<s<<"\n";
+}
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void PostScriptDriver::print(ostream& out)  const
+{
+	out << "PostScriptDriver[";
+	out << "]";
+}
+
+//! Method to plot symbols
+/*!
+
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::renderSymbols(const Symbol& symbol) const
+{
+	setNewColour(symbol.getColour());
+	writeColour();
+	currentShading_=M_SH_SOLID;
+	BaseDriver::renderSymbols(symbol);
+}
+
+
+
+
+
+
+/*!
+	\note The file header can only be written after the Fonts have been read
+
+	\sa open() startPage()
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::openFile() const
+{
+	if(!isSplit()) fileName_ = getFileName("ps");
+	else
+	{
+		if(!isEPS()) fileName_ = getFileName("ps" ,currentPage_+1);
+		else         fileName_ = getFileName("eps",currentPage_+1);
+
+		//
+		// CODE for Cihan because of MetPy expected 'ps' as output file name
+		//
+		//  if you read this after 01/01/2013 -> PLEASE REMOVE
+		//
+/*		if(magCompare(fileName_,"ps.ps"))
+		{
+		  const string s = getEnvVariable("MAGPLUS_PS_SPECIAL_NAME");
+		  if (!s.empty()) fileName_ = s;
+		}
+*/
+	}
+	if(isPDF())
+	{
+		const string::size_type pos = fileName_.rfind(".pdf");
+		if(pos != string::npos) fileName_.replace(pos,4,".ps");
+	}
+
+	if(PSOut_.is_open()) PSOut_.close();
+	PSOut_.clear();
+	PSOut_.open(fileName_.c_str(),std::ios::out);
+	if(!PSOut_){
+		MagLog::fatal() << "PostScriptDriver::close() --> Cannot write PostScript file! " << fileName_ << "\n";
+		terminate();
+	}
+
+	PSOut_.setf(ios_base::fixed);
+	PSOut_.unsetf(ios::showpoint);
+	PSOut_.precision(2);
+	writePSFileHeader();
+}
+
+/*!
+	\brief Method to close the PostScript output file.
+
+	\sa close() endPage()
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::closeFile() const
+{
+	// write end of file
+	writePSFileEnd();
+
+	// close + remove files
+	PSOut_.close();
+
+	const string fps = fileName_;
+
+	if(isPDF())
+	{
+		const string::size_type pos = fileName_.rfind(".ps");
+		if(pos != string::npos) fileName_.replace(pos,3,".pdf");
+		printOutputName("PS pdf "+fileName_);
+
+		// the -q option means no output - warnings may not show up!!! (fonts)
+		string cmd = "( gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=";
+		cmd.append(fileName_);
+		cmd.append(" -c .setpdfwrite -f ");
+		cmd.append(fps);
+		cmd.append(" )");
+
+		int status = system(cmd.c_str());
+		if(status)
+		{
+			MagLog::error() << "\nPostScriptDriver: Command exit not zero - NO PDF produced!\n"
+			             << " COMMAND: "<<cmd<<"\n"<< endl;
+			setPS(true);
+		}
+	}
+	if(!isPS() && !isEPS() ) remove(fps.c_str());
+	else 
+	{
+		if(isPS()) printOutputName("PS ps "+fps);
+		else printOutputName("PS eps "+fps);
+	}
+}
+
+
+/*!
+   \brief Method writing the PostScript file header.
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::writePSFileHeader() const
+{
+	fstream *ps = getStream();
+	const SystemInfo info;
+
+	*ps << "%!PS-Adobe-3.0";
+	if(isEPS()) *ps << " EPSF-3.0";
+	*ps << "\n%%Title: "<< title_
+	    << "\n%%Creator: "<< getMagicsVersionString() <<"\n%%CreationDate: " << info.getTime()
+	    << "\n%%For: " << info.getUserID() << "@" << info.getHostName() << " " << info.getUserName()<<"\n";
+
+	MFloat dimensionX = getXDeviceLength() * 72. / 2.54; // 72   = points / inch
+	MFloat dimensionY = getYDeviceLength() * 72. / 2.54; // 2.54 = cm / inch
+
+	string orientation = (getXDeviceLength() < getYDeviceLength()) ? "Portrait" : "Landscape";
+
+	MFloat ratio=1.;
+	int    width=0;
+	string mbg_tmpl = mgb_template_;
+
+	if(!mbg_tmpl.empty())
+	{
+		setDimensionsFromBinary(mbg_tmpl,ratio,width);
+		dimensionX = width;
+		dimensionY = maground(width*ratio);
+		orientation = (dimensionX < dimensionY) ? "Portrait" : "Landscape";
+	}
+
+	if(isEPS())
+	{
+		*ps << "%%Pages: 1\n%%Orientation: "<<orientation<<"\n"
+		    << "%%BoundingBox: 0 0 " << static_cast<int>(dimensionX) << " " << static_cast<int>(dimensionY)+1 << "\n";
+	}
+	else
+	{
+		if(old_)
+		{
+			if(isPDF() && !isPS())
+			{
+				*ps << "%%Orientation: "<<orientation<<"\n%%LanguageLevel: 2\n%%Pages: 1\n";
+			}
+			else
+			{
+				MFloat big, small;
+				if(dimensionX>dimensionY) { big = dimensionX;small = dimensionY;}
+				else { big = dimensionY;small = dimensionX;}
+
+				*ps << "%%Orientation: "<<orientation<<"\n%%LanguageLevel: 2\n%%Pages: (atend)\n"
+				    << "%%BoundingBox: 0 0 " << static_cast<int>(small)+1 << " " << static_cast<int>(big)+1<< "\n";
+			}
+		}
+		else
+		{
+			*ps << "%%Pages: (atend)\n"
+			    << "%%BoundingBox: 0 0 " << static_cast<int>(dimensionX)+1 << " " << static_cast<int>(dimensionY)+1<< "\n";
+		}
+	}
+
+	*ps << "%%EndComments\n%%BeginProlog\n";
+	if(!isEPS()) *ps << "/S { gr showpage } def\n";
+	else *ps << "/S {gr} def\n"; // define "showpage" empty for EPS files
+
+	copyMacro(ps,"PostScriptMacro1.ps");
+
+	fontMapIter mapit;
+
+	for(mapit = FontMap_.begin();mapit != FontMap_.end(); mapit++)
+		*ps << "Font " << (*mapit).second.id << " eq { /"<< (*mapit).second.ps_name<< " } if\n";
+
+	copyMacro(ps,"PostScriptMacro2.ps");
+	*ps << endl;
+}
+
+/*!
+   \brief Method copying macro code in the PostScript file header.
+*/
+MAGICS_NO_EXPORT void PostScriptDriver::copyMacro(fstream *ps, const string &file) const
+{
+	const string s = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + file;
+	ifstream psfile(s.c_str());
+
+	if(!psfile){
+		MagLog::fatal() << "PostScriptDriver::copyMacro() --> Cannot open PostScript Macro file! " << s <<
+		 " Is MAGPLUS_HOME set correctly?\n";
+		return;
+	}
+	char ch;
+	while (psfile.get(ch)){ps->put(ch);}
+	psfile.close();
+}
+
+
+MAGICS_NO_EXPORT void PostScriptDriver::writePSFileEnd() const
+{
+	if(!isEPS())
+	{
+		fstream *ps = getStream();
+		const int realpagenumber = (isSplit()) ? 1 : currentPage_;
+
+		*ps << "%%Trailer\n";
+		*ps << "%%Pages: " << realpagenumber << "\n";
+		*ps << "%%EOF\n";
+		ps->close();
+	}
+}
+
+MAGICS_NO_EXPORT void PostScriptDriver::setDeviceColourModel(const string &m) const
+{
+	if(m.empty()) deviceColourModel_ = 1; // use default
+	else if(magCompare(m,"RGB"))             deviceColourModel_ = 0;
+	else if(magCompare(m,"CMYK"))            deviceColourModel_ = 1;
+	else if(magCompare(m,"MONOCHROME"))      deviceColourModel_ = 2;
+	else if(magCompare(m,"GRAY"))            deviceColourModel_ = 3;
+	else if(magCompare(m,"CMYK_MONOCHROME")) deviceColourModel_ = 4;
+	else if(magCompare(m,"CMYK_GRAY"))       deviceColourModel_ = 5;
+	else
+	{
+		MagLog::warning() << "PostScriptDriver::setDeviceColourModel() -> "<< m
+		               << " is unknown model! CMYK model is used." << endl;
+		deviceColourModel_ = 1;
+	}
+}
+
+static SimpleObjectMaker<PostScriptDriver, BaseDriver> PostScript_driver("PostScript");
diff --git a/src/drivers/PostScriptDriver.h b/src/drivers/PostScriptDriver.h
new file mode 100644
index 0000000..a54fc94
--- /dev/null
+++ b/src/drivers/PostScriptDriver.h
@@ -0,0 +1,153 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ 	http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file PostScriptDriver.h
+    \brief Definition of PostScriptDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: March 2004
+*/
+
+#ifndef MPP_PostScriptDriver_H
+#define MPP_PostScriptDriver_H
+
+#include <BaseDriver.h>
+#include <PostScriptDriverAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+/*! \class PostScriptDriver
+    \brief This driver produces output in PostScript, EPS and PDF.
+    \ingroup drivers
+
+    This driver produces output in one or multiple PostScript file(s) (*.ps), multiple
+    EPS (*.eps) and/or one PDF (*.pdf).
+
+    \todo DRIVERS: PDF is still raster and needs to be vector!
+    \note PDF is currently produced throgh <b>ghostscript</b>. This means it uses raster instead of
+    vector information to describe the graphics.
+*/
+class PostScriptDriver: public BaseDriver, public PostScriptDriverAttributes
+{
+
+public:
+	PostScriptDriver();
+	~PostScriptDriver();
+	void open();
+	void close();
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "ps") ||
+		     magCompare(node.name(), "eps") ||
+		     magCompare(node.name(), "pdf") )
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("ps");
+			PostScriptDriverAttributes::set(basic);
+		}
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<string, string>& map)
+	{
+		BaseDriver::set(map);
+		PostScriptDriverAttributes::set(map);
+	}
+
+	void setEPS(bool b) const	{eps_=b;}
+	void setPDF(bool b) const	{pdf_=b;}
+	void setPS(bool b) const	{ps_=b;}
+	bool isEPS() const	{return eps_;}
+	bool isPDF() const	{return pdf_;}
+	bool isPS() const	{return ps_;}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void unproject() const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const MFloat) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT void writeColour() const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const MFloat w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& line) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+	MAGICS_NO_EXPORT void renderSymbols(const Symbol& ) const;
+
+	// P O S T S C I P T specific member functions BEGIN
+
+	MAGICS_NO_EXPORT void writePSFileHeader() const;
+	MAGICS_NO_EXPORT void writePSFileEnd() const;
+	MAGICS_NO_EXPORT void copyMacro(fstream *m, const string &file) const;
+	MAGICS_NO_EXPORT void setDeviceColourModel(const string &m) const;
+	MAGICS_NO_EXPORT fstream* getStream() const {return &PSOut_;}
+	MAGICS_NO_EXPORT int getDeviceColourModel() const {return deviceColourModel_;}
+
+	//! Should the output be splited?
+	MAGICS_NO_EXPORT bool isSplit() const {return ((isEPS()||split_) && !isPDF());}
+	MAGICS_NO_EXPORT void openFile() const;
+	MAGICS_NO_EXPORT void closeFile() const;
+
+	mutable fstream   PSOut_;
+	mutable bool      ps_;
+	mutable bool      pdf_;
+	mutable bool      eps_;
+	mutable bool      old_;
+	mutable	unsigned int maxPathSize_;
+	mutable	unsigned int deviceColourModel_;
+	mutable Colour currentWrittenColour_;
+
+	// P O S T S C I P T specific member functions END
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	//! Copy constructor - No copy allowed
+	PostScriptDriver(const PostScriptDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	PostScriptDriver& operator=(const PostScriptDriver&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PostScriptDriver& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/QtDriver.cc b/src/drivers/QtDriver.cc
new file mode 100644
index 0000000..e2b91e9
--- /dev/null
+++ b/src/drivers/QtDriver.cc
@@ -0,0 +1,2331 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file QtDriver.cc
+    \brief Implementation of QtDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Jan  4 20:28:15 2010
+
+*/
+
+#include <QtDriver.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+#include <ImportObject.h>
+#include <Layer.h>
+#include <AnimationRules.h>
+#include <Flag.h>
+#include <Symbol.h> 
+#include "HistoVisitor.h"
+
+#include <QApplication>
+#include <QDebug>
+#include <QDesktopWidget>
+#include <QGraphicsItem>
+#include <QPainter>
+#include <QX11Info>
+
+#include "MgQPlotScene.h"
+
+#include "MgQDriverObject.h"
+#include "MgQHistoItem.h"
+#include "MgQLayerItem.h"
+#include "MgQLayoutItem.h"
+#include "MgQPattern.h"
+#include "MgQPolylineSetItem.h"
+#include "MgQRootItem.h"
+#include "MgQSceneItem.h"
+#include "MgQStepItem.h"
+#include "MgQSymbol.h"
+#include "MgQPathItem.h"
+#include "MgQPixmapItem.h"
+#include "MgQTextItem.h"
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+*/
+QtDriver::QtDriver() 
+{
+	//scene_ = 0;
+	initialized_=false;
+	symbolManager_=0;
+	patternManager_=0;
+	magnifierIsBeingRedisplayed_=false;
+	magnifierZoomFactor_=1.;
+
+	currentPolylineSetItem_=0;
+
+	penStyle_[M_DASH]=Qt::DashLine;
+	penStyle_[M_DOT]=Qt::DotLine;
+	penStyle_[M_CHAIN_DASH]=Qt::DashDotLine;
+	penStyle_[M_CHAIN_DOT]=Qt::DashDotDotLine;
+	penStyle_[M_SOLID]=Qt::SolidLine;
+
+	//lineWidthFactor_=0.67;
+	//lineWidthFactor_=0.6;
+	lineWidthFactor_=0.55;
+	fontSizeFactor_=1.1;
+}
+
+/*!
+  \brief Destructor
+*/
+QtDriver::~QtDriver() 
+{
+}
+
+/*!
+  \brief Opening the driver
+*/
+void QtDriver::open()
+{
+	MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+										
+	scene->clearBeforeNewRequest();			
+	
+	currentItem_=scene->plotRootItem();
+		
+	//Delete layout item stack
+	while(!layoutItemStack_.empty())
+	{
+		layoutItemStack_.pop();
+	}
+
+	//Initialise layout item stack
+	layoutItemStack_.push(0);
+
+	//Delete layer item stack
+	while(!layerItemStack_.empty())
+	{
+		layerItemStack_.pop();
+	}
+
+		//Initialise layer item stack
+	layerItemStack_.push(0);
+
+	//Clear the display
+	//glClear(GL_COLOR_BUFFER_BIT);
+
+	currentPolylineSetItem_=0;
+		
+	//We find out the screen dpy from Qt. It can be diffrenet to the value
+	//given by 'xdpyinfo' returned by scene->dpiResolution(). So we compute
+	//their ratio to correctly set font size for rendering!
+	int qtDpiResolution=QX11Info::appDpiY(0);
+	if(qtDpiResolution < 50 || qtDpiResolution > 150)
+	{
+	  	dpiResolutionRatio_=1.;		
+	}
+	else
+	{  
+		dpiResolutionRatio_=static_cast<float>(qtDpiResolution)/static_cast<float>(scene->dpiResolution());
+	}
+	
+	setCMscale(static_cast<float>(scene->dpiResolution())/2.54); // cm -> pixel
+	
+	dimensionX_ = floorf(convertCM(getXDeviceLength()));
+	dimensionY_ = floorf(convertCM(getYDeviceLength()));
+	
+	scene->setSceneRect(0,0,dimensionX_,dimensionY_);
+	scene->setOriSceneRect(scene->sceneRect());
+	scene->plotRootItem()->setScale(1); 
+	
+	//currentItem_=0;
+	//currentPolylineSetItem_=0;
+
+	//currentItem_=scene->plotRootItem();
+
+	//Initialise layout item stack
+	//layoutItemStack_.push(0);
+
+	//Scaling factors have to be stored for 
+	//symbol plotting and for rotations in an unscaled co-ordinate system
+	coordRatioX_=1.;
+	coordRatioY_=1;
+
+	//The driver will regard pngs as transparent images
+	alphaEnabled_=true;
+
+	//Set initialization flag
+	//initialized_=true;
+
+}
+
+/*!
+  \brief Closing the driver
+*/
+void QtDriver::close()
+{	
+	MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+	
+	//scene->drawIt();
+
+	//endPage();
+	currentPage_ = 0;
+	
+	MagLog::debug() << "QtDriver::close -->item num:"  <<  scene->items().count() << endl;
+}
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+*/
+MAGICS_NO_EXPORT void QtDriver::startPage() const
+{
+	if(currentPage_ > 0) endPage();
+
+	MagLog::debug() << "QtDriver::startPage needs implementing." <<endl;
+	
+	currentPage_++;
+	newPage_ = true;
+}
+
+/*!
+  \brief ending a page
+ 
+  This method has to take care that for formats with multiple output 
+  files are closed.
+*/
+MAGICS_NO_EXPORT void QtDriver::endPage() const
+{
+	MagLog::debug() << "QtDriver::endPage needs implementing." <<endl;
+}
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+
+MAGICS_NO_EXPORT void QtDriver::project(const magics::Layout& layout) const
+{
+	MagLog::progress("project");
+	
+	//Create a new Layout Item
+	string name=layout.name();
+	MgQLayoutItem *item = new MgQLayoutItem(layout);
+
+	QGraphicsItem *parentItem=currentItem_;	
+	item->setParentItem(parentItem);
+	item->setParentItemInMainScene(parentItem);
+	
+	project(item);	
+}	  
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new PreviewLayout given.
+
+  \sa Layout
+*/
+
+MAGICS_NO_EXPORT void QtDriver::project(const magics::PreviewLayout& layout) const
+{
+	MagLog::progress("project");
+  
+  	//Create a new PreviewLayoutItem
+	string name=layout.name();
+	MgQPreviewLayoutItem *item = new MgQPreviewLayoutItem(layout);
+	item->hide();
+	
+	MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+	if(scene->currentSceneItem())
+	{
+	  	scene->currentSceneItem()->addPreviewLayoutItem(item);
+	}	
+
+	QGraphicsItem *parentItem=currentItem_;	
+	item->setParentItem(parentItem);
+	item->setParentItemInMainScene(parentItem);
+	
+	project(item);
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new MagnifierLayout given.
+
+  \sa Layout
+*/
+
+MAGICS_NO_EXPORT void QtDriver::project(const magics::MagnifierLayout& layout) const
+{
+	//Create a new MagnifierLayoutItem
+	string name=layout.name();
+	MgQMagnifierLayoutItem *item = new MgQMagnifierLayoutItem(layout);
+	//item->hide();
+
+	QGraphicsItem *parentItem=currentItem_;	
+	item->setParentItem(parentItem);
+	item->setParentItemInMainScene(parentItem);
+	
+	project(item);
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new MagnifierLayout given.
+
+  \sa Layout
+*/
+
+MAGICS_NO_EXPORT void QtDriver::project(const magics::HistoLayout& layout) const
+{
+	//Create a new HistrogramItem
+	string name=layout.name();
+	MgQLayoutItem *item = new MgQLayoutItem(layout);
+	//item->hide();
+
+	QGraphicsItem *parentItem=currentItem_;	
+	item->setParentItem(parentItem);
+	item->setParentItemInMainScene(parentItem);
+	
+	project(item);
+}
+
+
+MAGICS_NO_EXPORT void QtDriver::project(const magics::SceneLayout& layout) const
+{
+	//QCoreApplication::processEvents();
+	
+	string name=layout.name();
+	MgQLayoutItem *item;
+
+	//QString::fromStdString(name).contains("page", Qt::CaseInsensitive))
+
+	if(currentItem_->scene() == scene_ &&
+	   QString::fromStdString(name).contains("page", Qt::CaseInsensitive))
+	{  
+		MgQSceneItem *sceneItem=new MgQSceneItem(layout);		
+			
+		MgQDriverObject *drv= new MgQDriverObject(*this);	
+		sceneItem->setDriverObject(drv);
+
+		MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+		scene->addSceneItem(sceneItem);
+		scene->setCurrentSceneItem(sceneItem);
+		
+		item=sceneItem;
+	}
+	else
+	{  
+		item = new MgQLayoutItem(layout);
+	}
+	
+	QGraphicsItem *parentItem=currentItem_;	
+	item->setParentItem(parentItem);
+	item->setParentItemInMainScene(parentItem);
+	project(item);
+}
+
+
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void QtDriver::project(MgQLayoutItem *item) const
+{
+	const Layout& layout = item->layout();
+	
+	if(layout.isZoomable() && magnifierIsBeingRedisplayed_==false)
+	{
+		item->setData(MgQ::ItemIsZoomableKey,true);
+
+		MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+		scene->currentSceneItem()->addProjectorItem(item);
+	}
+
+
+	MagLog::debug() << "---> (Qt) PROJECT " << layout.name() <<  endl;
+
+	//Get layout geometry
+	const MFloat width    = layout.width()  * 0.01 * dimensionX_;
+	const MFloat height   = layout.height() * 0.01 * dimensionY_;
+	const MFloat x        = layout.x() * 0.01 * dimensionX_;
+	const MFloat y        = layout.y() * 0.01 * dimensionY_;
+	
+	//Get layout coordinate range
+	const MFloat minX = layout.minX();
+	const MFloat maxX = layout.maxX();
+	const MFloat minY = layout.minY();
+	const MFloat maxY = layout.maxY();
+	const MFloat rangeX = maxX - minX;
+	const MFloat rangeY = maxY - minY;
+
+	//Set dimensions
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);	
+	dimensionX_ = width;
+	dimensionY_ = height;
+	item->dimensionX(dimensionX_);
+	item->dimensionY(dimensionY_);
+
+	//--------------------------------------------	
+	// Define the coordinate system translation
+	// (in parent coordinates!) 
+	//--------------------------------------------
+
+	QTransform tr;
+
+	//Here we have to compensate the translation by project(-XMin) etc. in the 
+	//parent layout item!
+	MgQLayoutItem *parentLayoutItem=layoutItemStack_.top();
+	if(parentLayoutItem && parentLayoutItem->scene() == scene_)
+	{
+		tr.translate(parentLayoutItem->projectedMinX(),
+		             parentLayoutItem->projectedMinY());
+		
+		MagLog::dev() << "Translate redo: " << parentLayoutItem->projectedMinX()  << " " 
+				<< parentLayoutItem->projectedMinY() << endl;	
+	}
+
+
+	//Translate the origo
+	tr.translate(x,y);
+	MagLog::dev() << "Translate: " << x << " " << y << endl;	 
+
+	//Set the scaling factor
+	//projectX and, projectY depend on coordRatio[X,Y]_ !!!      	
+	const MFloat xx = width/rangeX;
+	const MFloat yy = height/rangeY;
+
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+	coordRatioX_ = xx;
+	coordRatioY_ = yy;
+	
+	item->coordRatioX(coordRatioX_);
+	item->coordRatioY(coordRatioY_);
+
+	//Translate the origo
+	tr.translate(projectX(-minX),projectY(-minY));
+
+	//Save the projected minX, minY
+	item->projectedMinX(projectX(minX));
+	item->projectedMinY(projectY(minY));
+	item->projectedMaxX(projectX(maxX));
+	item->projectedMaxY(projectY(maxY));
+
+	MagLog::dev() << "Translate: " << projectX(-minX) << " " << projectY(-minY) << endl;	 
+
+	//Set thr transformation for the layout item
+	item->setTransform(tr);
+
+#if 0
+	if(layout.name() == "drawing" || layout.name() == "left" || layout.name() == "top")
+	{
+		QGraphicsRectItem *r=new QGraphicsRectItem(projectX(minX),projectY(minY),projectX(rangeX),projectY(rangeY));
+		MagLog::debug() << projectX(minX) << "  " << projectY(minY) << " " << projectX(rangeX) << " " << projectY(rangeY) << endl;
+
+		if(layout.name() != "drawing")
+			r->setBrush(Qt::cyan);
+		else
+			r->setBrush(Qt::red);	
+		//r->setTransform(tr);
+		//scene_->addItem(r);
+		//group->addToGroup(r);
+		r->setParentItem(layoutItem);
+	}
+#endif
+
+	//Update item history
+	currentItem_=item;
+	layoutItemStack_.push(item);
+}
+
+/*!
+  \brief reproject out of the last Layout
+
+  This method will update the offset and scale to the state they were before the
+  last Layout was received.
+
+*/
+MAGICS_NO_EXPORT void QtDriver::unproject() const
+{
+	MgQLayoutItem *qln=layoutItemStack_.top();
+
+	if(qln)
+		MagLog::debug() << "---> (Qt) UNPROJECT " <<  qln->layout().name() << endl;
+	else
+		MagLog::debug() << "---> (Qt) UNPROJECT 0x000000" << endl;
+
+
+	//If layout item is zero returns
+	if(!qln) return;
+
+	//Set current item to the layouts parent
+	if(qln->parentItem() != 0)
+		currentItem_=static_cast<QGraphicsItem*>(qln->parentItem());
+	else
+		currentItem_=0;
+
+	//Pop layout from the stack
+	layoutItemStack_.pop();
+
+	//Verify dimension stack
+ 	if(dimensionStack_.empty())
+	{
+		MagLog::error() << "--->UNPROJECT (" <<
+			      ") Dimension stack error!" << endl;
+		assert(dimensionStack_.empty() == false);
+	}
+
+	coordRatioX_= scalesX_.top();
+	coordRatioY_= scalesY_.top();
+	scalesX_.pop();
+	scalesY_.pop();
+
+	//Verify dimension stack
+	dimensionY_ = dimensionStack_.top();
+	dimensionStack_.pop();
+	dimensionX_ = dimensionStack_.top();
+	dimensionStack_.pop();
+}
+
+/*!
+  \brief setup a new layer
+
+  This method will setup a new layer. Layers enable overlays of entities
+  of information.
+
+  \sa PhysicalLayer
+*/
+MAGICS_NO_EXPORT void QtDriver::newLayer(Layer& layer) const
+{
+	MagLog::debug() << "(Qt) NEW Layer ---> " <<  layer.id() << endl;
+}
+
+
+/*!
+  \brief setup a new layer
+
+  This method will setup a new layer. Layers enable overlays of entities
+  of information.
+
+  \sa PhysicalLayer
+*/
+MAGICS_NO_EXPORT void QtDriver::newLayer(StaticLayer& layer) const
+{
+	MagLog::debug() << "QtDriver::newLayer (StaticLayer) ---> " <<  layer.id() << endl;
+
+	QString name(layer.name().c_str());
+	MgQLayoutItem *parentLayout=layoutItemStack_.top();
+	MgQLayerItem* qln =  new MgQLayerItem(layer, parentLayout,0);
+
+	newLayer(qln);	
+}
+
+/*!
+  \brief setup a new layer
+
+  This method will setup a new layer. Layers enable overlays of entities
+  of information.
+
+  \sa PhysicalLayer
+*/
+MAGICS_NO_EXPORT void QtDriver::newLayer(StepLayer& layer) const
+{
+	MagLog::debug() << "(Qt) NEW StepLayer ---> " <<  layer.id() << endl;
+
+	QString name(layer.name().c_str());
+	MgQLayoutItem *parentLayout=layoutItemStack_.top();
+	MgQLayerItem* qln =  new MgQLayerItem(layer, parentLayout,layer.parent()->numberOfSteps());	
+
+	newLayer(qln);
+}
+
+MAGICS_NO_EXPORT void QtDriver::newLayer(MgQLayerItem* qln) const
+{
+	MagLog::debug() << "QtDriver::newLayer (MgQLayerItem) ---> " <<  qln->layer().id() << endl;
+
+	MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+	
+	qln->setParentItem(currentItem_);
+
+	scene->currentSceneItem()->addLayerItem(qln);
+		
+	layerItemStack_.push(qln);
+	currentItem_=qln->rootItem();
+}
+
+
+
+/*!
+  \brief close the current layer
+
+  This method will close an existing layer. This includes resets of existing boxes. 
+
+  \sa UnPhysicalLayer PhysicalLayer
+*/
+MAGICS_NO_EXPORT void QtDriver::closeLayer(Layer& layer) const
+{
+	MagLog::debug() << "---> (Qt) CLOSE LAYER" <<  layer.name() << endl;	
+}
+
+
+MAGICS_NO_EXPORT void QtDriver::closeLayer(StaticLayer& layer) const
+{
+	MagLog::debug() << "---> (Qt) CLOSE LAYER" <<  layer.name() << endl;
+	MgQLayerItem *qln=layerItemStack_.top();
+	closeLayer(qln);	
+}
+
+MAGICS_NO_EXPORT void QtDriver::closeLayer(StepLayer& layer) const
+{
+	MagLog::debug() << "---> (Qt) CLOSE LAYER" <<  layer.name() << endl;
+	MgQLayerItem *qln=layerItemStack_.top();
+	closeLayer(qln);	
+}
+
+
+/*!
+  \brief close the current layer
+
+  This method will close an existing layer. This includes resets of existing boxes. 
+
+  \sa UnPhysicalLayer PhysicalLayer
+*/
+MAGICS_NO_EXPORT void QtDriver::closeLayer(MgQLayerItem *qln) const
+{	
+	
+
+	//Get current layer item
+	//MgQLayerItem *qln=layerItemStack_.top();
+
+	if(qln)
+		MagLog::debug() << "---> (Qt) CLOSE LAYER" <<  qln->layer().name() << endl;
+	else
+		MagLog::debug() << "---> (Qt) CLOSE LAYER 0x000000" << endl;
+
+	//If layer item is zero returns
+	if(!qln) return;
+
+	//Get current layer item
+	//assert(qln->layer().id() == layer.id()); 
+
+	//Pop layer item from the stack
+	layerItemStack_.pop();
+
+	//Set current item to the layer parent
+	if(qln->parentItem() != 0)
+		currentItem_=static_cast<QGraphicsItem*>(qln->parentItem());
+	else
+		currentItem_=0;
+}
+
+
+/*!
+  \brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the 
+  current box is finished.
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void QtDriver::setNewColour(const Colour &colour) const
+{
+	if(currentColour_ == colour) return;
+	currentColour_ = colour;
+	//MagLog::debug() << "QtDriver::setNewColour needs checking." <<endl;
+}
+
+/*!
+  \brief sets a new line width
+
+  This line width stays the default width until the painting in the 
+  current box is finished.
+
+  \sa setLineParameters()
+*/
+MAGICS_NO_EXPORT void QtDriver::setNewLineWidth(const MFloat width) const
+{
+	currentLineWidth_ = width*lineWidthFactor_;
+	//MagLog::debug() << "QtDriver::setNewColour needs checking." <<endl;
+}
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the 
+  current box is finished.
+
+  \sa LineStyle
+
+  \param linestyle Object describing the line style
+  \param w width of the line
+
+*/
+MAGICS_NO_EXPORT int QtDriver::setLineParameters(const LineStyle linestyle, const MFloat w) const
+{
+	setNewLineWidth(w);
+
+	currentLineStyle_=linestyle;
+
+	if(penStyle_.contains(linestyle))
+	{
+		currentPenStyle_=penStyle_[linestyle];
+	}
+	else 
+	{
+		currentPenStyle_=Qt::SolidLine;
+	}		
+
+	return 0;
+}
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void QtDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+	if(currentColour_ == Colour("none"))
+		return;
+
+	QVector<QPointF> pp;
+	for(int i = 0; i<n; i++)
+	{
+		pp << QPointF(projectX(x[i]),projectY(y[i]));
+	}
+		
+			
+	if(currentPolylineSetItem_ != 0)
+	{
+		QBrush brush(Qt::NoBrush);	
+		QPen pen(QPen(getQtColour(currentColour_)));
+		
+		pen.setStyle(currentPenStyle_);
+		pen.setWidthF(currentLineWidth_);
+		pen.setCosmetic(true);
+
+		currentPolylineSetItem_->addPolyline(pp,brush,pen,false);
+	}
+	else
+	{
+		QPainterPath path;
+		path.addPolygon(pp);
+		QGraphicsPathItem *item=new QGraphicsPathItem(path);
+		item->setParentItem(currentItem_);
+		QPen pen(QPen(getQtColour(currentColour_)));
+		pen.setStyle(currentPenStyle_);
+		pen.setWidthF(currentLineWidth_);
+		pen.setCosmetic(true);
+
+		item->setPen(pen);
+	}
+}
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void QtDriver::renderPolyline2(const int n, MFloat* x, MFloat* y) const
+{
+	if(currentColour_ == Colour("none"))
+		return;
+
+	if(n != 2) return;
+
+	if(currentPolylineSetItem_ != 0)
+	{
+		QVector<QPointF> pp;
+		for(int i = 0; i<n; i++)
+		{
+			pp << QPointF(x[i],y[i]);
+		}
+	
+		QBrush brush(Qt::NoBrush);	
+		QPen pen(QPen(getQtColour(currentColour_)));
+		pen.setWidthF(currentLineWidth_);
+		pen.setStyle(currentPenStyle_);
+		pen.setCosmetic(true);
+
+		currentPolylineSetItem_->addPolyline(pp,brush,pen,false);
+	}
+	else
+	{
+		QLineF pp(x[0],y[0],x[1],y[1]);
+	
+		QGraphicsLineItem *item=new QGraphicsLineItem(pp);
+		item->setParentItem(currentItem_);
+		QPen pen(QPen(getQtColour(currentColour_)));
+		
+		pen.setWidthF(currentLineWidth_);
+		pen.setStyle(currentPenStyle_);
+		pen.setCosmetic(true);
+		item->setPen(pen);
+	}
+}
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void QtDriver::renderSimplePolygon(const int n, MFloat* x, MFloat* y) const
+{
+	if(currentColour_ == Colour("none"))
+		return;
+
+	QBrush brush(Qt::SolidPattern);
+	QPen pen;
+
+	if (currentShading_==M_SH_DOT)
+	{
+		const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+		const int density = (int)sqrt(pro->density_);
+		if(density<=0) return;
+		const MFloat square_size = convertCM(1.)/density;
+		int dotSize = static_cast<int>(pro->size_*convertCM(1.));	
+		if (dotSize<2) dotSize = 1;
+
+		int s=static_cast<int>(ceil(square_size));
+
+		bool doSolidShading=false;
+		if(s < 2)
+		{	
+			doSolidShading=true;
+		}
+		else if(s-2 < dotSize)
+		{
+			dotSize=s-2;
+			if(dotSize < 1)
+			{
+				doSolidShading=true;
+			}			
+		}
+		
+		if(doSolidShading)
+		{
+			brush.setColor(getQtColour(currentColour_));
+			
+			pen.setColor(getQtColour(currentColour_));	
+		}
+		else
+		{						
+			if(!patternManager_)
+			{
+				patternManager_ =  new MgQPatternManager;
+			}
+	
+			MgQPatternProperties dot(MgQPatternProperties::DotShading);
+			dot.size_=QSize(s,s);
+			dot.itemSize_=QSize(dotSize,dotSize);
+			dot.colour_=getQtColour(currentColour_);
+
+			MgQPattern *pix=patternManager_->addPattern(dot);
+			
+			brush.setTexture(pix->pixmap());
+			pen=QPen(Qt::NoPen);
+			//pen.setColor(QColor(255,255,255,0));
+		}
+	}
+	else if (currentShading_==M_SH_HATCH)
+	{
+		const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+		indexHatch_ = pro->index_;
+		if(indexHatch_<1 || indexHatch_>6)
+		{
+			MagLog::warning() << "QtDriver::renderSimplePolygon > Hatch index " <<indexHatch_<<" is wrong. No hatch sahding possible!" << endl;
+			return;
+		}
+		float square_size = convertCM(1.)/pro->density_;
+		int s;
+		
+		//If the square is too small we go for solid shading
+		if(square_size < 1.5)
+		{
+			brush.setColor(getQtColour(currentColour_));
+	
+			pen.setColor(getQtColour(currentColour_));	
+		}
+		else
+		{
+			s=static_cast<int>(ceil(square_size));
+
+			if(!patternManager_)
+			{
+				patternManager_ =  new MgQPatternManager;
+			}
+	
+			MgQPatternProperties hatch(MgQPatternProperties::HatchShading);
+			hatch.id_=QString::number(indexHatch_);
+			hatch.size_=QSize(s,s);
+			hatch.lineWidth_=pro->thickness_;
+			hatch.colour_=getQtColour(currentColour_);
+
+			MgQPattern *pix=patternManager_->addPattern(hatch);
+
+			brush.setTexture(pix->pixmap());
+			pen.setColor(QColor(255,255,255,0));
+		}
+	}
+	else
+	{
+		brush.setColor(getQtColour(currentColour_));
+	
+		pen.setColor(getQtColour(currentColour_));
+	}
+
+	if(currentPolylineSetItem_ != 0)
+	{
+		QVector<QPointF> pp;
+		for(int i = 0; i<n; i++)
+		{
+			pp << QPointF(projectX(x[i]),projectY(y[i]));
+		}
+		currentPolylineSetItem_->addPolyline(pp,brush,pen,true);	
+	}
+	else
+	{
+		QVector<QPointF> pp;
+		for(int i = 0; i<n; i++)
+		{
+			pp << QPointF(projectX(x[i]),projectY(y[i]));
+		}
+		
+		QGraphicsPolygonItem *item=new QGraphicsPolygonItem(pp);
+		item->setParentItem(currentItem_);
+
+		item->setPen(pen);
+		item->setBrush(brush);
+
+	}
+}
+
+void QtDriver::renderSimplePolygon(const Polyline& line) const
+{
+	//MagLog::progress("poly");
+  
+  	//closeGroup();
+	//debugOutput("renderSimplePolygon");
+	setNewColour(line.getFillColour());
+	const unsigned int n = line.size();
+	if(n<3 || (currentColour_==Colour("none")) ) return;
+
+	line.getShading()->draw(*this);
+	
+	QBrush brush(Qt::SolidPattern);
+	QPen pen;
+	if (currentShading_==M_SH_DOT)
+	{
+		const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+		const int density = (int)sqrt(pro->density_);
+		if(density<=0) return;
+		const MFloat square_size = convertCM(1.)/density;
+		int dotSize = static_cast<int>(pro->size_*convertCM(1.));	
+		if (dotSize<2) dotSize = 1;
+
+		int s=static_cast<int>(ceil(square_size));
+
+		bool doSolidShading=false;
+		if(s < 2)
+		{	
+			doSolidShading=true;
+		}
+		else if(s-2 < dotSize)
+		{
+			dotSize=s-2;
+			if(dotSize < 1)
+			{
+				doSolidShading=true;
+			}			
+		}
+		
+		if(doSolidShading)
+		{
+			brush.setColor(getQtColour(currentColour_));
+	
+			pen.setColor(getQtColour(currentColour_));	
+		}
+		else
+		{						
+			if(!patternManager_)
+			{
+				patternManager_ =  new MgQPatternManager;
+			}
+	
+			MgQPatternProperties dot(MgQPatternProperties::DotShading);
+			dot.size_=QSize(s,s);
+			dot.itemSize_=QSize(dotSize,dotSize);
+			dot.colour_=getQtColour(currentColour_);
+
+			MgQPattern *pix=patternManager_->addPattern(dot);
+			
+			brush.setTexture(pix->pixmap());
+			pen=QPen(Qt::NoPen);
+			//pen.setColor(QColor(255,255,255,0));
+		}
+	}
+	else if (currentShading_==M_SH_HATCH)
+	{
+		const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+		indexHatch_ = pro->index_;
+		if(indexHatch_<1 || indexHatch_>6)
+		{
+			MagLog::warning() << "QtDriver::renderSimplePolygon > Hatch index " <<indexHatch_<<" is wrong. No hatch sahding possible!" << endl;
+			return;
+		}
+		float square_size = convertCM(1.)/pro->density_;
+		int s;
+		
+		//If the square is too small we go for solid shading
+		if(square_size < 1.5)
+		{
+			brush.setColor(getQtColour(currentColour_));
+	
+			pen.setColor(getQtColour(currentColour_));	
+		}
+		else
+		{
+			s=static_cast<int>(ceil(square_size));
+
+			if(!patternManager_)
+			{
+				patternManager_ =  new MgQPatternManager;
+			}
+	
+			MgQPatternProperties hatch(MgQPatternProperties::HatchShading);
+			hatch.id_=QString::number(indexHatch_);
+			hatch.size_=QSize(s,s);
+			hatch.lineWidth_=pro->thickness_;
+			hatch.colour_=getQtColour(currentColour_);
+
+			MgQPattern *pix=patternManager_->addPattern(hatch);
+
+			brush.setTexture(pix->pixmap());
+			pen=QPen(Qt::NoPen);
+			//pen.setColor(QColor(255,255,255,0));
+		}
+	}
+	else
+	{		
+		brush.setColor(getQtColour(currentColour_));
+		
+		if(line.isStroked())
+		{
+			pen.setColor(getQtColour(currentColour_));
+		}
+		else
+		{  
+			pen=QPen(Qt::NoPen); 		
+		}
+	}
+
+	QPainterPath path;
+	QVector<QPointF> pp;
+	for(unsigned int i = 0; i<n; i++)
+	{
+		pp << QPointF(projectX(line.get(i).x()),projectY(line.get(i).y()));
+	}
+		
+
+	if(line.beginHoles() != line.endHoles())
+	{  	
+		path.addPolygon(pp);
+		path.closeSubpath();
+			
+		for(Polyline::Holes::const_iterator h = line.beginHoles(); h != line.endHoles(); h++)
+		{
+			vector<double> x;
+			vector<double> y;
+			line.hole(h,x,y);
+		
+			QVector<QPointF> ppHole;
+			for(unsigned int i = 0; i< x.size(); i++)
+			{
+				ppHole << QPointF(projectX(x[i]),projectY(y[i]));
+			}
+				
+			path.addPolygon(ppHole);
+			path.closeSubpath();
+		}						
+	}
+
+
+
+	if(currentPolylineSetItem_ != 0)
+	{
+		if(path.isEmpty())
+			currentPolylineSetItem_->addPolyline(pp,brush,pen,true);	
+		else
+		  	currentPolylineSetItem_->addPath(path,brush,pen);
+	}	
+	else
+	{
+		if(path.isEmpty())
+		{
+			QGraphicsPolygonItem *item=new QGraphicsPolygonItem(pp);
+			item->setParentItem(currentItem_);
+			item->setPen(pen);
+			item->setBrush(brush);
+		}
+		else
+		{  
+			QGraphicsPathItem *item=new QGraphicsPathItem(path);
+			item->setParentItem(currentItem_);
+			item->setPen(pen);
+			item->setBrush(brush);
+		}	
+	}
+}
+
+/*!
+  \brief renders text strings
+
+  This method renders given text strings.
+
+  \note As of version 2.0 there are two forms of describing text in Text.
+
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void QtDriver::renderText(const Text& text) const
+{
+	if(text.empty()) return;
+
+	//Check if nicetext available
+	const vector<NiceText>& niceT = text.getNiceText();
+	if(niceT.empty()) return;
+	
+	const enum Justification horizontal = text.getJustification();
+	const enum VerticalAlign vertical   = text.getVerticalAlign();
+
+	string textString;						
+	MFloat pheight;
+
+	//Check if all the text items has the same font, size, colour  and style
+	MagFont magfontFirst=(text.textBegin())->font();
+	bool sameFontForItems=true;
+	for(vector<NiceText>::const_iterator niceText=text.textBegin(); niceText != text.textEnd(); niceText++)
+	{
+		const MagFont magfont = niceText->font();
+		if(magfont.size() != magfontFirst.size() ||
+	           magfont.name() != magfontFirst.name() ||
+		   !(magfont.colour() == magfontFirst.colour()) )
+		{
+			sameFontForItems=false;
+			break;
+		}
+	}      
+
+	//If all the text items has the same font ....
+	if(sameFontForItems)
+	{
+                const MagFont magfont=magfontFirst;
+		const std::set<string>& styles = magfont.styles();
+
+		pheight = 72.*magfont.size()/2.54; //height in points
+		pheight/=dpiResolutionRatio_; 		
+		pheight*=fontSizeFactor_;
+			
+                QFont font(QString::fromStdString(magfont.name()), pheight);
+		font.setPointSizeF(pheight);
+		
+		if (styles.find("underlined") != styles.end()) font.setUnderline(true);
+                if(styles.find("bold") != styles.end())        font.setBold(true);
+                if(styles.find("italic") != styles.end())      font.setItalic(true);
+
+		QString allText;
+		for(vector<NiceText>::const_iterator niceText=text.textBegin(); niceText != text.textEnd(); niceText++)
+		{	
+			QString str;
+			textToUnicode((*niceText).text(),str);
+			allText+=str;
+		}
+
+		QFontMetrics fm(font);
+                int width  = fm.width(allText);
+                int height = fm.height();
+
+		MFloat x = 0;
+                if(horizontal == MCENTRE)     x = width*.5;
+                else if(horizontal == MRIGHT) x = width;
+
+		MFloat y = 0.;
+                if (vertical==MBASE)        { y = height;}
+                else if (vertical==MTOP)    { y = 0.;}
+                else if (vertical==MHALF)   { y = height*.5;}
+                else if (vertical==MBOTTOM) { y = height;}
+
+	  	unsigned int noTexts = text.size();
+	 	for(unsigned int nT=0;nT<noTexts;nT++)  // for all string CO-ORDINATES
+	  	{		
+			const MFloat x0 = projectX(text[nT].x());
+			const MFloat y0 = projectY(text[nT].y());
+			const MFloat an = text.getAngle()*57.29577951;
+ 
+			//for debugging: Uncomment this to render red a circle to the text position!
+			/*
+			{
+				QGraphicsEllipseItem *item=new QGraphicsEllipseItem(-2,-2,4,4);
+				item->setBrush(Qt::red);
+				item->setParentItem(currentItem_);
+				item->setPos(x0,y0);
+			}*/
+
+			//Create the item
+			MgQTextItem *item= new MgQTextItem(allText);
+			item->setParentItem(currentItem_);
+			item->setFont(font);
+			//item->setPen(QPen());
+			item->setTextBlanking(text.getBlanking());
+			item->setBrush(getQtColour(magfont.colour()));
+
+			if(magnifierIsBeingRedisplayed_==true)
+			{
+				item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+			}
+	
+                        //item->setPos(x0,y0);
+			QTransform tr;
+			tr.scale(1.,-1.);
+			tr.translate(-x,-y);
+			item->setTransform(tr);
+
+			if(an !=0 &&  an != 360)
+			{
+				item->translate(x,y);
+				item->rotate(an);
+				item->translate(-x,-y);	
+			}
+
+			item->setPos(x0,y0);
+		}
+	}
+	
+	//If the text item fonts differ ...
+	else
+	{
+		//Loop for the indidual text items
+		for(vector<NiceText>::const_iterator niceText=text.textBegin(); niceText != text.textEnd(); niceText++)                               
+		{					
+			const MagFont magfont = niceText->font();
+	
+			const std::set<string>& styles = magfont.styles();
+	
+			pheight = 72.*magfont.size()/2.54; //height in points
+			pheight/=dpiResolutionRatio_; 		
+			pheight*=fontSizeFactor_;
+		
+			QFont font(QString::fromStdString(magfont.name()), pheight);
+			font.setPointSizeF(pheight);
+			if (styles.find("underlined") != styles.end()) font.setUnderline(true);
+			if(styles.find("bold") != styles.end())        font.setBold(true);
+			if(styles.find("italic") != styles.end())      font.setItalic(true);
+	
+			QString str;
+			textToUnicode((*niceText).text(),str);
+			//QString str = QString::fromStdString((*niceText).text());
+	
+			QFontMetrics fm(font);
+			int width  = fm.width(str);
+			int height = fm.height();
+	
+			MFloat x = 0;
+			if(horizontal == MCENTRE)     x = width*.5;
+			else if(horizontal == MRIGHT) x = width;
+	
+			MFloat y = 0.;
+			if (vertical==MBASE)        { y = height;}
+			else if (vertical==MTOP)    { y = 0.;}
+			else if (vertical==MHALF)   { y = height*.5;}
+			else if (vertical==MBOTTOM) { y = height;}
+	
+			unsigned int noTexts = text.size();
+			for(unsigned int nT=0;nT<noTexts;nT++)  // for all string CO-ORDINATES
+			{		
+				const MFloat x0 = projectX(text[nT].x());
+				const MFloat y0 = projectY(text[nT].y());
+				const MFloat an = text.getAngle()*57.29577951;
+	
+				//Create the item
+				MgQTextItem *item= new MgQTextItem(str);
+				item->setParentItem(currentItem_);
+				item->setFont(font);
+				//item->setPen(QPen());
+				item->setTextBlanking(text.getBlanking());
+				item->setBrush(getQtColour(magfont.colour()));
+			
+				if(magnifierIsBeingRedisplayed_==true)
+				{
+					item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+				}
+		
+				item->setPos(x0,y0);
+				QTransform tr;
+				tr.scale(1.,-1.);
+				tr.translate(-x,-y);
+				item->setTransform(tr);
+	
+				if(an !=0 &&  an != 360)	
+					item->rotate(an);
+			}
+		}
+	}
+
+}
+
+ // \brief Convert std::string to unicode QString  	
+ void QtDriver::textToUnicode(const string &str,QString &ustr) const
+ {         
+	ustr=QString::fromUtf8(str.c_str());
+
+	//Replace HTML 4 entities &#...;  to unicode char
+	QRegExp rx("&#(\\d+);");
+	
+	QStringList lstHtml;
+	QList<QChar> lstUni;
+
+	int pos=0;
+	while ((pos = rx.indexIn(ustr, pos)) != -1)
+ 	{
+     		if(!rx.cap(1).isEmpty())
+		{
+			lstHtml <<  rx.cap(0);
+			lstUni << QChar(rx.cap(1).toInt());
+		}
+		pos += rx.matchedLength();
+	}
+
+	for(int i =0; i < lstHtml.count(); i++)
+	{
+		ustr.replace(lstHtml[i],lstUni[i]);
+	}
+
+	//qDebug() << "textToUnicode" << str.c_str()  << ustr;
+
+	return;
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+
+MAGICS_NO_EXPORT void QtDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s) const
+{
+}
+
+MAGICS_NO_EXPORT void QtDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s,MgQSymbolItem *qSym) const
+{
+	int fill = s;
+	//if(s==9) fill=8
+	
+	//Fill white	
+	/*if(fill != 8 && fill != 0)
+	{
+		MgQPainterPath whiteCircle(true,true);
+		whiteCircle.addEllipse(QPointF(x,y),r,r);	
+		qSym->addPath(whiteCircle);
+	}*/
+
+	//Fill wedges	
+	if(fill > 0 && fill < 8)
+	{
+		MgQPainterPath path(true);
+		path.moveTo(QPointF(x,y));
+		path.arcTo(x-r,y-r,2.*r,2.*r, 45.*(fill-2.), -45.*fill);
+		qSym->addPath(path);
+	}
+
+	//Full filled circle
+	else if(fill==8)
+	{
+		MgQPainterPath path(true);
+		path.addEllipse(QPointF(x,y),r,r);	
+		qSym->addPath(path);
+	}
+
+	//Full filled circle whit a white vertical bar in the middle 
+	else if(fill == 9)
+	{
+		MgQPainterPath path(true);
+		//path.arcTo(x-r,y-r,2.*r,2.*r, 70, -140);
+		path.arcMoveTo(x-r,y-r,2.*r,2.*r,110);
+		path.arcTo(x-r,y-r,2.*r,2.*r, 110, 140);
+		path.closeSubpath();
+		qSym->addPath(path);
+		
+		MgQPainterPath path2(true);
+		//path2.arcTo(x-r,y-r,2.*r,2.*r, 250, 140);
+		path2.arcMoveTo(x-r,y-r,2.*r,2.*r,290);
+		path2.arcTo(x-r,y-r,2.*r,2.*r, 290, 140);
+		path2.closeSubpath();
+		qSym->addPath(path2);
+	}
+
+	//Outline
+	//Full filled circle
+	if(fill == 8)
+	{
+		MgQPainterPath pathCircle(false);
+		pathCircle.addEllipse(QPointF(x,y),r,r);	
+		pathCircle.setRenderOnlyForOutline(true);
+		qSym->addPath(pathCircle);
+	}
+	else
+	{
+	  	MgQPainterPath pathCircle(false);
+		pathCircle.addEllipse(QPointF(x,y),r,r);	
+		qSym->addPath(pathCircle);
+	}	
+}
+
+
+/*!
+  \brief Image render method for ALL drivers.
+
+  This method should be used by all Magics++ drivers to render image objects.
+*/
+
+MAGICS_NO_EXPORT void QtDriver::renderImage(const ImportObject& obj) const
+{
+	std::string f = obj.getFormat();
+	GraphicsFormat format = PNG;
+	if(magCompare(f,"ps")) return; //format = PS;
+	else if(magCompare(f,"eps")) return; // format = EPS;
+	else if(magCompare(f,"gif")) format = GIF;
+	else if(magCompare(f,"jpeg") || magCompare(f,"jpg")) format = JPG;
+	else if(magCompare(f,"png")) format = PNG;
+	else if(magCompare(f,"svg")) return; //format = SVG;
+	else return;
+	
+	MFloat width=0;
+	MFloat height=0;
+
+	if(obj.getWidth()==-1 && ( magCompare(f,"gif") || magCompare(f,"png") || magCompare(f,"jpeg")|| magCompare(f,"jpg") ) )
+	{
+		return;
+	}
+	else
+	{
+		width  = obj.getWidth();
+		height = obj.getHeight();
+	}
+
+	QImage img(obj.getPath().c_str());
+	if(img.isNull())
+	{
+		return;
+	}
+
+	MgQPixmapItem *item=new MgQPixmapItem(QPixmap::fromImage(img.mirrored(false,true)));
+	
+	MFloat x0=projectX(obj.getOrigin().x());
+	MFloat y0=projectY(obj.getOrigin().y());
+	MFloat x1=projectX(obj.getOrigin().x()+width);
+	MFloat y1=projectY(obj.getOrigin().y()+height);
+
+	item->setParentItem(currentItem_);
+	item->setTargetRect(QRectF(x0,y0,x1-x0,y1-y0));		
+	item->setPos(x0,y0);
+
+	//Set clipping
+	MgQLayoutItem *layoutParent=layoutItemStack_.top();
+
+	QRectF bb=layoutParent->boundingRect();
+	bb.translate(-QPointF(x0,y0));
+	item->setClipRect(bb);
+
+}
+
+
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \sa renderCellArray()
+
+  \param x0 x of lower corner
+  \param y0 y of lower corner
+  \param x1 x of higher corner
+  \param y1 y of higher corner
+  \param w width of pixmap
+  \param h height of pixmap
+  \param pixmap contents
+  \param landscape says if contents is landscape
+  \param hasAlpha has the array transparency?
+
+*/
+MAGICS_NO_EXPORT bool QtDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                                            int w,int h,unsigned char* pixmap,int landscape, bool hasAlpha) const
+{
+	MagLog::debug() << "renderPixmap: " << x0 << " " << y0 << " " << x1 << " " << y1 << endl; 
+
+
+	QImage img=QImage(w,h,QImage::Format_ARGB32);
+
+	//uchar *data = new uchar[w*h*4];
+	int srcPos;
+	int pixel;
+
+	if(hasAlpha)
+	{
+		for(int j=0; j< h; j++)
+		{
+			for(int i=0; i < w; i++)
+			{			
+				srcPos=((h-j-1)*w+i)*4;
+				//pixel=qRgba(pixmap[srcPos+1],pixmap[srcPos+2],pixmap[srcPos+3],pixmap[srcPos]);		
+				pixel=qRgba(pixmap[srcPos],pixmap[srcPos+1],pixmap[srcPos+2],pixmap[srcPos+3]);	
+				img.setPixel(i,j,pixel);
+			}
+		}
+	}
+	else
+	{
+		for(int j=0; j< h; j++)
+		{
+			for(int i=0; i < w; i++)
+			{			
+				srcPos=((h-j-1)*w+i)*3;
+				pixel=qRgba(pixmap[srcPos],pixmap[srcPos+1],pixmap[srcPos+2],0xff);			
+				img.setPixel(i,j,pixel);
+			}
+		}
+
+		/*int srcPos=(h-1)*w*3;
+		int targetPos=0;
+		for(int j=0; j< h; j++)
+		{
+			for(int i=0; i < w; i++)
+			{	
+				data[targetPos]=pixmap[srcPos+2];
+				data[targetPos+1]=pixmap[srcPos+1];
+				data[targetPos+2]=pixmap[srcPos];
+				data[targetPos+3]=0xff;
+
+				srcPos+=3;
+				targetPos+=4;
+			}
+			srcPos-=w*3;
+		}
+		img=QImage(data,w,h,QImage::Format_ARGB32);*/	
+	}
+
+
+	MgQPixmapItem *item=new MgQPixmapItem(QPixmap::fromImage(img));
+	
+	item->setParentItem(currentItem_);
+	item->setTargetRect(QRectF(x0,y0,x1-x0,y1-y0));		
+	item->setPos(x0,y0);	
+
+	//MgQLayoutItem layoutParent=layoutItemStack_.top();
+	//QRectF r=layoutparent->sceneBoundingRect();
+
+
+	//delete data;
+
+	return true;
+}
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are 
+  mainly used for satellite data.
+
+  \sa renderPixmap()
+
+  \param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool QtDriver::renderCellArray(const Image& image) const
+{
+	ColourTable &lt = image.getColourTable(); 
+	const int width  = image.getNumberOfColumns();
+	const int height = image.getNumberOfRows();
+	const MFloat x0 = projectX(image.getOrigin().x());
+	const MFloat y0 = projectY(image.getOrigin().y());
+	const MFloat x1 = projectX(image.getOrigin().x()+image.getWidth());
+	const MFloat y1 = projectY(image.getOrigin().y()+image.getHeight());
+	
+	//Converts colour table into qRGb
+	QList<QRgb> cols;
+	for(unsigned int i=0 ; i < lt.size(); i++)
+	{
+		Colour c(lt[i].red(),lt[i].green(),lt[i].blue());
+		cols << getQtColour(c).rgb();
+	}
+	
+	//Create an image
+	QImage img(width,height,QImage::Format_ARGB32);
+	img.fill(0x00ffffff);
+
+	for (int i=0; i < height;i++)
+	{
+		for(int j=0;j< width; j++)
+		{
+		  const int in = width*i+j;	 
+		  const short c = image[in];
+
+		  if(!(lt[c]=="none"))
+		  {			
+			img.setPixel(j,height-i-1,cols[c]);	
+					  
+		  }
+		}
+	}
+	//		
+	MgQPixmapItem *item=new MgQPixmapItem(QPixmap::fromImage(img));
+	item->setParentItem(currentItem_);
+	item->setTargetRect(QRectF(x0,y0-(y1-y0),x1-x0,y1-y0));		
+	item->setPos(x0,y0-(y1-y0));	
+
+	return true;
+}
+
+
+void QtDriver::generateSymbolPath(MgQSymbolItem *qSym,svgSymbol sym) const
+{
+	//setCoordRatio(1.,1.);
+
+	//Symbol size in pixels!!!
+	MFloat symbolSize=qSym->size();
+
+	const unsigned int si = sym.elements.size();
+
+	//setNewLineWidth(1.);
+	//const MFloat pX = 1. / coordRatioX_;
+	//const MFloat pY = 1. / coordRatioY_;
+
+	const MFloat scaling=symbolSize * 0.5; ///convertCM(1.);
+	
+	for(unsigned int i=0;i<si;i++)  // for all elements in the symbol description
+	{
+		if(sym.elements[i].name == "circle")
+		{
+			const MFloat r  = atof(sym.elements[i].attributes["r"].c_str())  * scaling;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling;
+			const int s = atoi(sym.elements[i].attributes["fill"].c_str());
+			circle(cx,cy,r,s,qSym);
+		}
+		else if(sym.elements[i].name == "snowflake")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling;
+			snowflake(cx,cy,r,qSym);
+		}
+		else if(sym.elements[i].name == "drizzle")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling;
+			drizzle(cx,cy,r,qSym);
+		}
+		else if(sym.elements[i].name == "triangle")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling;
+			const int s = atoi(sym.elements[i].attributes["fill"].c_str());
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling;
+			const int li = atoi(sym.elements[i].attributes["line"].c_str());
+			triangle(cx,cy,r,s,li,qSym);
+		}
+		else if(sym.elements[i].name == "lightning")
+		{
+			const MFloat r = atof(sym.elements[i].attributes["r"].c_str()) * scaling;
+			const MFloat cx = atof(sym.elements[i].attributes["cx"].c_str()) * scaling;
+			const MFloat cy = atof(sym.elements[i].attributes["cy"].c_str()) * scaling;
+			lightning(cx,cy,r,qSym);
+		}
+
+		else if(sym.elements[i].name == "polyline")
+		{			
+			vector<PaperPoint> vPP;
+			parsePoints(vPP, sym.elements[i].attributes["points"]);
+						
+			for(unsigned int s=0;s<vPP.size();s++)
+			{
+				vPP[s].x( vPP[s].x() * scaling);
+				vPP[s].y( vPP[s].y() * scaling);
+			 }	
+			
+			QVector<QPointF> pp;
+			for(unsigned int j = 0; j< vPP.size(); j++)
+			{
+				//pp << QPointF(projectX(vPP[j].x()),projectY(vPP[j].y()));
+				pp << QPointF(vPP[j].x(),vPP[j].y());
+			}
+
+			bool fill=false;
+			if(!magCompare("none",sym.elements[i].attributes["fill"]) )
+			{
+				fill=true;
+			}
+
+			MgQPainterPath path(fill);
+			path.addPolygon(pp);
+
+			qSym->addPath(path);
+		}
+	}// endfor 
+
+	//qSym->setPath(path);
+
+	//resetCoordRatio();
+}
+
+
+MAGICS_NO_EXPORT void QtDriver::renderSymbols(const Symbol& symbol) const
+{	
+	//setLineParameters(M_SOLID, 1.); // reset line
+
+	// if still empty
+	loadSymbols();
+	
+	if(sym_.size() == 0 ) 
+	{
+		MagLog::error() << "QtDriver::renderSymbols() --> NO symbols available!" << endl;
+		return;
+	}
+
+	MagLog::dev() << "Number of symbols: " << symbol.size() << endl;
+
+	const int noSymbols = sym_.size();
+	svgSymbol sym;
+
+	int ii=0;
+	for(;ii<noSymbols;ii++)
+	{
+		sym = sym_[ii];
+		if(sym.id==symbol.getSymbol()) break;
+	}
+
+	if(ii==noSymbols) sym = sym_[0];
+
+	//Find out symbol size in pixels!!!!!!!
+	MFloat symbolSize = convertCM(symbol.getHeight());
+
+	//Create symbolmanager if needed
+	if(!symbolManager_)
+	{
+		symbolManager_ =  new MgQSymbolManager;
+	}
+
+	//If needed compile a display list for the symbol
+	//The size of this symbol is "1 cm"
+	MgQSymbolItem *actSymbol;
+	QString id(QString::fromStdString(sym.id));
+	if((actSymbol=symbolManager_->getSymbol(id,symbolSize)) == 0 )
+	{
+		actSymbol=symbolManager_->addSymbol(id,symbolSize);
+		generateSymbolPath(actSymbol,sym);
+	}
+
+	//Set colour
+	setNewColour(symbol.getColour());	
+	
+	MgQLayoutItem *layout=layoutItemStack_.top();
+	QRectF brect=layout->boundingRect();
+
+	MgQSymbolSetItem *item=new MgQSymbolSetItem(actSymbol,brect);
+	item->setParentItem(currentItem_);
+	item->setColor(getQtColour(currentColour_));
+				       
+	if(actSymbol->hasFilledPart() && symbol.outline())
+	{
+		const Colour&  outCol=symbol.outlineColour();		
+	  	item->setOutlineColor(getQtColour(outCol));		
+	}				
+	  
+	if(symbol.connectLine())
+	{
+	  	item->setConnectLine(true);
+		const Colour&  lineCol=symbol.connectLineColour();
+		QPen pen(getQtColour(lineCol));
+					
+		magics::LineStyle lineStyle=symbol.connectLineStyle();
+		if(penStyle_.contains(lineStyle))
+		{
+			pen.setStyle(penStyle_[lineStyle]);
+		}
+		else 
+		{
+			pen.setStyle(Qt::SolidLine);
+		}		
+
+		pen.setWidthF(symbol.connectLineThickness()*lineWidthFactor_);
+		pen.setCosmetic(true);		        
+		item->setConnectLinePen(pen);
+	}	
+	  
+	  
+	if(magnifierIsBeingRedisplayed_ == true)
+	{
+		//item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+		item->setKeepSizeWhenScaling(true);
+
+	}
+
+	for(unsigned int i=0;i<symbol.size();i++)
+	{
+		item->addPoint(projectX(symbol[i].x()),projectY(symbol[i].y()));	
+	}
+
+
+	/*for(unsigned int i=0;i<symbol.size();i++)
+//	for(unsigned int i=0;i<1000;i++)
+	{ 
+		for(int j=0; j < actSymbol->paths().count(); j++)
+		{
+			MgQPathItem *item=new MgQPathItem(actSymbol->paths().at(j));
+			item->setParentItem(currentItem_);
+			item->setPen(QColor::fromRgbF(currentColour_.red(),
+				        currentColour_.green(),
+				        currentColour_.blue()));
+			
+			if(actSymbol->paths().at(j).isFilled())
+			{
+				if(actSymbol->paths().at(j).isDefaultFill())
+				{
+					item->setBrush(Qt::white);
+				}
+				else
+				{			
+					item->setBrush(QColor::fromRgbF(currentColour_.red(),
+				        	currentColour_.green(),
+				        	currentColour_.blue()));
+				}
+			}
+
+			item->setPos(projectX(symbol[i].x()),projectY(symbol[i].y()));	
+		
+			item->setBoundingRectSize(symbolSize);
+
+			if(magnifierIsBeingRedisplayed_ == true)
+			{
+				item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
+			}
+		}
+	}*/
+}
+
+/*!
+  Plotting a snowflake
+*/
+
+MAGICS_NO_EXPORT void QtDriver::snowflake(const MFloat x, const MFloat y, const MFloat size,MgQSymbolItem *qSym) const
+{
+	const MFloat s5 = size;
+	const MFloat s3 = size * 0.78;
+
+	MgQPainterPath path(false);
+	QVector<QPointF> line;
+
+	line << QPointF(x-s5,y);
+	line << QPointF(x+s5,y);
+	path.addPolygon(line);
+
+	line.clear();
+	line << QPointF(x-s3,y+s3);
+	line << QPointF(x+s3,y-s3);
+	path.addPolygon(line);
+
+	line.clear();
+	line << QPointF(x-s3,y-s3);
+	line << QPointF(x+s3,y+s3);
+	path.addPolygon(line);
+
+	qSym->addPath(path);
+
+}
+
+/*!
+  Plotting drizzle
+*/
+MAGICS_NO_EXPORT void  QtDriver::drizzle(const MFloat x, const MFloat y, const MFloat size,MgQSymbolItem *qSym) const
+{
+	const MFloat s2 = size*.5;
+
+	circle(x,y,s2,8,qSym);
+
+	MgQPainterPath path(false);
+	QVector<QPointF> line;
+	line << QPointF(x+(s2*0.8),y);
+	line << QPointF(x,y-size);
+	path.addPolygon(line);
+
+	qSym->addPath(path);
+}
+
+/*!
+  Plotting lightning symbol
+*/
+MAGICS_NO_EXPORT void QtDriver::lightning(const MFloat x, const MFloat y, const MFloat size,MgQSymbolItem *qSym) const
+{
+	MgQPainterPath path(false);
+	QVector<QPointF> pp;
+
+	pp << QPointF(x-(size*.9),y-(size*.9));
+	pp << QPointF(x-(size*.9),y+(size*.9));
+	path.addPolygon(pp);
+
+	pp.clear();
+	pp << QPointF(x-(size*.9),y+(size*.9));
+	pp << QPointF(x+(size*.9),y+(size*.9));
+	pp << QPointF(x+(size*.1),y);
+	pp << QPointF(x+(size*.9),y-(size*.9));
+	path.addPolygon(pp);
+	
+	pp.clear();
+	pp << QPointF(x+(size*.8), y-(size*.4));
+	pp << QPointF(x+(size*.9), y-(size*.9));
+	pp << QPointF(x+(size*.45), y-(size*.8));
+	path.addPolygon(pp);
+
+	qSym->addPath(path);
+}
+
+/*!
+  Plotting a triangle
+*/
+MAGICS_NO_EXPORT void 
+QtDriver::triangle(const MFloat x, const MFloat y, const MFloat size, const int fill, const int l,MgQSymbolItem *qSym) const
+{
+	const MFloat s = 0.5 * size;
+
+	bool fillIt=(fill>=1)?true:false;
+
+	MgQPainterPath path(fillIt);
+	QVector<QPointF> pp;
+
+	pp << QPointF(x+s, y-s);
+	pp << QPointF( x-s, y-s);
+	pp << QPointF( x, y+s);
+	pp << QPointF( x+s, y-s);
+	path.addPolygon(pp);
+
+	qSym->addPath(path);
+
+	if(fill < 1 && l >0)
+	{
+		pp.clear();
+		MgQPainterPath lp(false);
+		pp << QPointF(x+s*.6, y-(s*.5));
+		pp << QPointF(x-s*.6, y-(s*.5));
+		lp.addPolygon(pp);
+		qSym->addPath(lp);
+	}
+}
+
+MAGICS_NO_EXPORT void QtDriver::executeStep(int step) const
+{	
+	/*MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+
+	const SceneLayer &sl=scene->sceneLayerItem()->layer();
+	for(vector<Layer*>::const_iterator itL = sl.beginLayer();itL != sl.endLayer(0); ++itL) 
+	{		
+		executeStep(step,scene->layerItem(**itL);		
+	}*/
+}
+
+void QtDriver::executeStep(int step,MgQLayerItem *layerItem) const
+{	
+	QGraphicsItem *prevItem=currentItem_;
+
+	MgQLayoutItem *parentLayout=layerItem->parentLayoutItem();
+	layoutItemStack_.push(parentLayout);
+
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	dimensionX_=parentLayout->dimensionX();
+	dimensionY_=parentLayout->dimensionY();
+
+	MgQStepItem *item=new MgQStepItem(0);
+	item->setParentItem(layerItem->rootItem());
+	item->setCached(true);
+	layerItem->setStep(step,item);
+	
+	currentItem_=item;	
+
+	MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+	
+	//Notify scene item about the new step
+	//scene->sceneLayerItem()->sceneLayer().reset();
+
+	scene->currentSceneItem()->sceneLayerItem()->sceneLayer().execute(&layerItem->layer(),step,*this);
+
+	//layerItem->layer().execute(step,*this);
+"",
+	currentItem_=prevItem;
+	layoutItemStack_.pop();
+
+	dimensionY_  = dimensionStack_.top();
+	dimensionStack_.pop();	
+	dimensionX_  = dimensionStack_.top();
+	dimensionStack_.pop();
+}
+
+void QtDriver::executeStep(int step,MgQLayerItem *layerItem,const SceneLayer& sceneLayer) const
+{		
+	QGraphicsItem *prevItem=currentItem_;
+
+	MgQLayoutItem *parentLayout=layerItem->parentLayoutItem();
+	layoutItemStack_.push(parentLayout);
+
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	dimensionX_=parentLayout->dimensionX();
+	dimensionY_=parentLayout->dimensionY();
+
+	MgQStepItem *item=new MgQStepItem(0);
+	item->setParentItem(layerItem->rootItem());
+	item->setCached(true);
+	layerItem->setStep(step,item);
+	
+	currentItem_=item;	
+	
+	sceneLayer.execute(&layerItem->layer(),step,*this);
+
+	currentItem_=prevItem;
+	layoutItemStack_.pop();
+
+	dimensionY_  = dimensionStack_.top();
+	dimensionStack_.pop();	
+	dimensionX_  = dimensionStack_.top();
+	dimensionStack_.pop();
+}
+
+
+MAGICS_NO_EXPORT void QtDriver::executeMagnifier(Layer *layer,MgQMagnifierLayoutItem* layoutItem) const
+{
+	QGraphicsItem *prevItem=currentItem_;
+	layoutItemStack_.push(layoutItem);
+
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	dimensionX_=layoutItem->dimensionX();
+	dimensionY_=layoutItem->dimensionY();
+
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+	coordRatioX_ = layoutItem->coordRatioX();
+	coordRatioY_ = layoutItem->coordRatioY();
+	
+	magnifierZoomFactor_=layoutItem->zoomFactor();
+	magnifierIsBeingRedisplayed_=true;
+
+	//QGraphicsItem *rootItem=new QGraphicsItem("MagnifierRoot");
+	//item->setRootItem(rootItem);
+	//rootItem->setParentItem(item);
+
+	currentItem_=layoutItem;
+
+	layer->magnify(*this,layoutItem->resolutionX(),layoutItem->resolutionY());
+
+	//item->layout().redisplay(*this,
+	//	      pp,item->resolutionX(),item->resolutionY());
+
+	magnifierZoomFactor_=1.;
+	magnifierIsBeingRedisplayed_=false;
+
+	currentItem_=prevItem;
+	layoutItemStack_.pop();
+
+	dimensionY_  = dimensionStack_.top();
+	dimensionStack_.pop();	
+	dimensionX_  = dimensionStack_.top();
+	dimensionStack_.pop();
+
+	coordRatioX_ = scalesX_.top();
+	coordRatioY_ = scalesY_.top();
+	scalesX_.pop();
+	scalesY_.pop();
+}
+
+MAGICS_NO_EXPORT void QtDriver::executeHisto(Layer *layer,MgQHistoItem* layoutItem,QString visdefName,QString visdefClass) const
+{
+	QGraphicsItem *prevItem=currentItem_;
+	//layoutItemStack_.push(layoutItem);
+
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	//dimensionX_=layoutItem->dimensionX();
+	//dimensionY_=layoutItem->dimensionY();
+	dimensionX_=150;
+	dimensionY_=100;
+
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+	//coordRatioX_ = layoutItem->coordRatioX();
+	//coordRatioY_ = layoutItem->coordRatioY();
+	coordRatioX_ = 1;
+	coordRatioY_ = 1;
+	
+	//magnifierIsBeingRedisplayed_=true;
+
+	currentItem_=layoutItem;
+
+	layer->histogram(*this,visdefName.toStdString(),visdefClass.toStdString());
+
+	//magnifierIsBeingRedisplayed_=false;
+
+	currentItem_=prevItem;
+	//layoutItemStack_.pop();
+
+	dimensionY_  = dimensionStack_.top();
+	dimensionStack_.pop();	
+	dimensionX_  = dimensionStack_.top();
+	dimensionStack_.pop();
+
+	coordRatioX_ = scalesX_.top();
+	coordRatioY_ = scalesY_.top();
+	scalesX_.pop();
+	scalesY_.pop();
+}
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const Layer& layer) const 
+{
+//	newLayer(layer);
+//	layer.visit(*this);
+//	closeLayer(layer);
+}
+
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const PreviewLayout& layout) const 
+{
+	project(layout);
+	layout.visit(*this);
+	unproject();
+}
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const MagnifierLayout& layout) const 
+{
+	project(layout);
+	layout.visit(*this);
+	unproject();
+}
+  
+MAGICS_NO_EXPORT void QtDriver::redisplay(const HistoLayout& layout) const
+{
+	project(layout);
+	layout.visit(*this);
+	unproject();
+}
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const SceneLayout& layout) const
+{
+	project(layout);
+	layout.visit(*this);
+	unproject();
+}  
+  
+MAGICS_NO_EXPORT void QtDriver::redisplay(const SceneLayer& layer) const
+{
+	MagLog::dev() << "QtDriver::redisplay(const SceneLayer& layer)" << endl;
+
+	MgQPlotScene *scene = static_cast<MgQPlotScene*>(scene_);
+	MgQSceneLayerItem *ln=new MgQSceneLayerItem(layer);
+	MgQSceneItem *item=scene->currentSceneItem();
+		
+	if(item)
+	{
+	  	item->setSceneLayerItem(ln);
+		item->setStepNum(layer.numberOfSteps());
+	}
+	
+	//currentItem_=item;
+	
+	for(vector<Layer*>::iterator itL = layer.beginLayer(); itL != layer.endLayer(); ++itL) 
+	{
+		(*itL)->newLayer(*this);
+		(*itL)->execute(*this);
+		(*itL)->closeLayer(*this);
+	}
+
+	scene->restoreLayerState();
+	
+	//currentSceneLayoutItem_=0;
+	
+/*AnimationStep* step = layer.rules()->at(0);
+
+	for (list<Layer*>::const_iterator itL = layer.begin(); itL != layer.end(); ++itL) 
+	{
+	       map<Layer*, int>::iterator itS = step->find(*itL);
+		if ( itS == step->end() ) 		
+		{
+			(*itL)->execute(*this);
+		}
+	       	else
+		{ 
+	    		(*itL)->execute(itS->second,*this);
+		}
+	}*/
+
+
+	/*for (int i = 0; i < layer.numberOfSteps(); i++) {
+		layer.execute(i, *this);
+	}*/
+	
+}
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const StaticLayer& layer) const
+{
+	MagLog::dev() << "QtDriver::redisplay(const StaticLayer& layer)" << endl;
+	layer.visit(*this);
+}
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const StepLayer&) const
+{
+	MagLog::dev() << "QtDriver::redisplay(const StepLayer& layer)" << endl;
+}
+
+MAGICS_NO_EXPORT void QtDriver::redisplay(const PolylineSet& line) const
+{	
+	//BaseDriver::redisplay(line);
+	//return;
+
+	MagLog::progress("polyline");
+	
+	MgQLayoutItem *layout=layoutItemStack_.top();
+	QRectF brect=layout->boundingRect();
+
+	MgQPolylineSetItem *item=new MgQPolylineSetItem(brect);
+	item->setParentItem(currentItem_);	
+
+	currentPolylineSetItem_=item;
+
+	line.visit(*this);
+
+	currentPolylineSetItem_=0;
+}
+
+void QtDriver::redisplay(const Arrow& arrow) const
+{
+	MgQLayoutItem *layout=layoutItemStack_.top();
+	QRectF brect=layout->boundingRect();
+
+	MgQPolylineSetItem *item=new MgQPolylineSetItem(brect);
+	item->setParentItem(currentItem_);	
+
+	currentPolylineSetItem_=item;
+
+	BaseDriver::renderWindArrow(arrow);
+
+	currentPolylineSetItem_=0;
+}
+
+void QtDriver::redisplay(const Flag& flag) const
+{
+	MgQLayoutItem *layout=layoutItemStack_.top();
+	QRectF brect=layout->boundingRect();
+
+	MgQPolylineSetItem *item=new MgQPolylineSetItem(brect);
+	item->setParentItem(currentItem_);	
+
+	currentPolylineSetItem_=item;
+
+	BaseDriver::renderWindFlag(flag);
+
+	currentPolylineSetItem_=0;
+}
+/*!
+  \brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \note This can increase file and log file sizes if you run Magics++ in debug mode!
+
+  \param s string to be printed
+*/
+MAGICS_NO_EXPORT void QtDriver::debugOutput(const std::string &s) const
+{
+	MagLog::debug() << s << endl;
+}
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void QtDriver::print(ostream& out)  const
+{
+	out << "QtDriver[";
+	out << "]";
+}
+
+QColor QtDriver::getQtColour(const Colour &col) const
+{
+	qreal r=col.red();
+	qreal g=col.green();
+	qreal b=col.blue();
+	
+	if(r < 0.) r=0.;
+	else if(r > 1.) r=1.;
+	
+	if(g < 0.) g=0.;
+	else if(g > 1.) g=1.;
+	
+	if(b < 0.) b=0.;
+	else if(b > 1.) b=1.;
+	
+	return QColor::fromRgbF(r,g,b);
+}	
+		
+static SimpleObjectMaker<QtDriver, BaseDriver> Qt_driver("Qt");
diff --git a/src/drivers/QtDriver.h b/src/drivers/QtDriver.h
new file mode 100644
index 0000000..f1d4759
--- /dev/null
+++ b/src/drivers/QtDriver.h
@@ -0,0 +1,209 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file QtDriver.h
+    \brief Definition of QtDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Mon Jan  4 20:28:15 2010
+*/
+
+#ifndef _MPP_QtDriver_H
+#define _MPP_QtDriver_H
+
+#include <BaseDriver.h>
+#include <QtDriverAttributes.h>
+#include <XmlNode.h>
+
+#include <QMap>
+
+//#include <Qt/qqwidget.h>
+
+class QGraphicsItem;
+class QPainterPath;
+
+class MgQHistoItem;
+class MgQLayerItem;
+class MgQLayoutItem;
+class MgQMagnifierLayoutItem;
+class MgQPatternManager;
+class MgQPlotScene;
+class MgQPolylineSetItem;
+class MgQSceneItem;
+class MgQStepItem;
+class MgQSymbolItem;
+class MgQSymbolManager;
+
+class QPainterPath;
+
+namespace magics
+{
+
+/*! \class QtDriver
+    \brief This driver produces output for Qt
+    \ingroup drivers
+
+    This driver ...
+*/
+class QtDriver: public BaseDriver, public QtDriverAttributes
+{
+friend class MgQAnimationStep;
+friend class MgQPlotScene;
+
+public:
+	QtDriver();
+	~QtDriver();
+	void open();
+	void close();
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		if ( magCompare(node.name(), "binary") )
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("qt");
+			QtDriverAttributes::set(basic);
+		}
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<std::string, std::string>& map)
+	{
+		BaseDriver::set(map);
+		QtDriverAttributes::set(map);
+	}
+	
+	MAGICS_NO_EXPORT void executeStep(int step) const;
+	MAGICS_NO_EXPORT void executeStep(int step,MgQLayerItem *layerItem) const;	
+	MAGICS_NO_EXPORT void executeStep(int step,MgQLayerItem *layerItem,const SceneLayer& sceneLayer) const;
+	MAGICS_NO_EXPORT void executeMagnifier(Layer *,MgQMagnifierLayoutItem*) const;
+	MAGICS_NO_EXPORT void executeHisto(Layer *,MgQHistoItem*,QString,QString) const;
+	void setUpdateMode(bool mode) { updateMode_ = mode; }
+	bool getUpdateMode() const    { return updateMode_; }
+private:
+
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout&) const;
+	MAGICS_NO_EXPORT void project(const PreviewLayout&) const;
+	MAGICS_NO_EXPORT void project(const MagnifierLayout&) const;
+	MAGICS_NO_EXPORT void project(const HistoLayout&) const;
+	MAGICS_NO_EXPORT void project(const SceneLayout&) const;
+	MAGICS_NO_EXPORT void unproject() const;
+	MAGICS_NO_EXPORT void newLayer(Layer&) const;
+	MAGICS_NO_EXPORT void newLayer(StaticLayer&) const;
+	MAGICS_NO_EXPORT void newLayer(StepLayer&) const;
+	MAGICS_NO_EXPORT void closeLayer(Layer&) const;
+	MAGICS_NO_EXPORT void closeLayer(StaticLayer&) const;
+	MAGICS_NO_EXPORT void closeLayer(StepLayer&) const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const MFloat) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const MFloat w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline&) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+	MAGICS_NO_EXPORT void renderImage(const ImportObject&) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+	MAGICS_NO_EXPORT void renderSymbols(const Symbol&) const;
+
+	//! Methods to redisplay an object (virtual).
+	MAGICS_NO_EXPORT void redisplay(const Layer&) const;
+	MAGICS_NO_EXPORT void redisplay(const PreviewLayout&) const;
+	MAGICS_NO_EXPORT void redisplay(const MagnifierLayout&) const;
+	MAGICS_NO_EXPORT void redisplay(const HistoLayout&) const;
+	MAGICS_NO_EXPORT void redisplay(const SceneLayout&) const;
+	MAGICS_NO_EXPORT void redisplay(const SceneLayer&) const;
+	MAGICS_NO_EXPORT void redisplay(const StaticLayer&) const;
+	MAGICS_NO_EXPORT void redisplay(const StepLayer&) const;
+	MAGICS_NO_EXPORT void redisplay(const PolylineSet&) const;
+	MAGICS_NO_EXPORT void redisplay(const Arrow&) const;
+	MAGICS_NO_EXPORT void redisplay(const Flag&) const;
+
+
+	// QtDriver specific member functions BEGIN
+	MAGICS_NO_EXPORT void project(MgQLayoutItem*) const;
+	MAGICS_NO_EXPORT void newLayer(MgQLayerItem*) const;
+	MAGICS_NO_EXPORT void closeLayer(MgQLayerItem*) const;	
+	MAGICS_NO_EXPORT void generateSymbolPath(MgQSymbolItem *,svgSymbol) const;
+	MAGICS_NO_EXPORT void textToUnicode(const string&,QString &) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int,MgQSymbolItem*) const;
+	MAGICS_NO_EXPORT void snowflake(const MFloat, const MFloat, const MFloat,MgQSymbolItem*) const;
+	MAGICS_NO_EXPORT void drizzle(const MFloat, const MFloat, const MFloat,MgQSymbolItem*) const;
+	MAGICS_NO_EXPORT void triangle(const MFloat, const MFloat, const MFloat, const int, const int,MgQSymbolItem*) const;
+	MAGICS_NO_EXPORT void lightning(const MFloat x, const MFloat y, const MFloat size,MgQSymbolItem*) const;
+
+//void executeStep(const MgQAnimationStep&,MgQStepItem*) const;
+	//mutable QGraphicsScene* scene_;
+	// QtDriver specific member functions END
+
+	QColor getQtColour(const Colour &) const;
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	//! Copy constructor - No copy allowed
+	QtDriver(const QtDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	QtDriver& operator=(const QtDriver&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const QtDriver& p)
+		{ p.print(s); return s; }
+
+	mutable int stepToRender_;
+	mutable std::stack<MgQLayoutItem*>  layoutItemStack_;
+	mutable std::stack<MgQLayerItem*>   layerItemStack_;
+	mutable MgQSceneItem* currentSceneItem_;
+	mutable QGraphicsItem* currentItem_;
+	mutable bool initialized_;
+	mutable bool magnifierIsBeingRedisplayed_;
+	mutable MFloat magnifierZoomFactor_;
+	mutable MgQSymbolManager* symbolManager_;
+	mutable MgQPatternManager* patternManager_;
+	mutable MgQPolylineSetItem *currentPolylineSetItem_;
+	
+	mutable QMap<LineStyle,Qt::PenStyle> penStyle_;
+	mutable Qt::PenStyle currentPenStyle_;
+
+	bool updateMode_;
+
+	MFloat lineWidthFactor_;
+	MFloat fontSizeFactor_;
+	MFloat dpiResolutionRatio_;
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/SVGDriver.cc b/src/drivers/SVGDriver.cc
new file mode 100644
index 0000000..e832abe
--- /dev/null
+++ b/src/drivers/SVGDriver.cc
@@ -0,0 +1,1491 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SVGDriver.cc
+    \brief Implementation of SVGDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Fri Oct 26 20:58:21 2007
+
+*/
+
+#include <SVGDriver.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+#include <Symbol.h>
+#include <ImportObject.h>
+#include <System.h>
+#include <Layer.h>
+
+//! For generating SVGZ files
+extern "C"{
+/*
+#include <stdio.h>
+#include <string.h>
+#include <zlib.h>
+#define SET_BINARY_MODE(file)
+#define CHUNK 16384
+*/
+#include <sys/stat.h>
+#include "minizip/zip.h"
+#define MAXFILENAME 256
+#define WRITEBUFFERSIZE 16384
+}
+
+#ifdef MAGICS_RASTER
+#include <gd.h>
+#endif
+
+
+int svg_pattern_count=0;
+
+using namespace magics;
+
+/*!
+  \brief Constructor
+*/
+SVGDriver::SVGDriver() : groupString_(""), group_counter_(0), inkscape_(true)//,interactive_(false), interactiveCounter_(0)
+{
+  readFonts();
+}
+
+/*!
+  \brief Destructor
+*/
+SVGDriver::~SVGDriver() 
+{
+  relieveFonts();
+}
+
+/*!
+  \brief Opening the driver
+*/
+void SVGDriver::open()
+{
+}
+
+/*!
+  \brief Closing the driver
+*/
+void SVGDriver::close()
+{
+}
+
+/*!
+  \brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+*/
+MAGICS_NO_EXPORT void SVGDriver::startPage() const
+{
+	debugOutput("Page - START");
+//	bool fixSize = fixSize_;
+	MFloat ratio = getRatio();
+	int   wid   = width_;
+
+	string mbg_tmpl = mgb_template_;
+	if(!mbg_tmpl.empty())
+	{
+		setDimensionsFromBinary(mbg_tmpl,ratio,wid);
+//		fixSize=true;
+	}
+
+	dimensionX_ = wid;
+	dimensionY_ = dimensionX_*ratio;
+	const int height = static_cast<int>(dimensionY_);
+	const int width  = static_cast<int>(dimensionX_);
+
+	setCMscale(30.);
+
+	currentPage_++;
+
+	string filename = getFileName("svg",currentPage_+1);
+	tmp_pFile_ = filename;
+
+	pFile_.open(filename.c_str(),std::ios::out);
+
+	if(!pFile_)
+	{
+		MagLog::fatal() << "SVGDriver::startPage() --> Cannot open SVG output file: " << filename << "\n";
+		terminate();
+	}
+
+	svg_output_resource_list_.push_back(filename);
+
+	const bool xml_header=true;
+	if(xml_header)
+	{
+	  pFile_
+	  << "<?xml version=\"1.0\" ?>\n";
+//	  << "<!DOCTYPE svg PUBLIC \'-//W3C//DTD SVG 1.0//EN\' \'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\'>\n";
+	}
+
+	pFile_
+	<< "<svg version=\"1.1\" encoding=\"iso-8859-1\" baseProfile=\"full\"\n"
+	<< "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
+	<< "xmlns:cc=\"http://creativecommons.org/ns#\"\n"
+	<< "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
+	<< "xmlns=\"http://www.w3.org/2000/svg\"\n"
+	<< "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
+	<< "xmlns:ev=\"http://www.w3.org/2001/xml-events\"\n";
+
+	if(inkscape_)
+	  pFile_ << "xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n"
+	         << "xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n"
+	         << "inkscape:version=\"0.46\"\n"
+	         << "inkscape:output_extension=\"org.inkscape.output.svg.inkscape\"\n";
+	
+//	if(fixSize) pFile_<< "width=\""<<width<<"px\" height=\""<<height<<"px\" ";          ?????????????????????????????????????????????????????
+
+	pFile_ << "viewBox=\"0 0 "<<width+1<<" "<<height+1<<"\" xml:space=\"preserve\"";   
+//	 preserveAspectRatio=\"xMidYMid meet\"\n"
+//	 << " shape-rendering=\"optimizeSpeed\" text-rendering=\"optimizeSpeed\""
+	if(scripting_) pFile_<< " onload=\"OnLoadEvent(evt)\"";
+	pFile_<< ">\n<title>"<<title_<<"</title>\n";
+
+	if(!desc_.empty()) pFile_<< "<desc>"<<desc_<<"</desc>\n";
+	const SystemInfo info;
+	pFile_<< "<metadata id=\"MAGICSmetadata\">\n<rdf:RDF><cc:Work rdf:about=\"\">\n"
+	      << "\t<dc:format>image/svg+xml</dc:format>\n"
+	      << "\t<dc:title>"<<title_<<"</dc:title>\n"
+	      << "\t<dc:creator><cc:Agent><dc:title>"<<info.getUserID()<<" on "<<info.getHostName()<<"</dc:title></cc:Agent></dc:creator>\n"
+	      << "\t<dc:date>"<<info.getTime()<<"</dc:date>\n"
+	      << "\t<dc:language>en-GB</dc:language>\n"
+	      << "\t<dc:description>Meteorological plot generated by "<<getMagicsVersionString()<<"</dc:description>\n"
+	      << "\t<dc:publisher><cc:Agent>\n"
+	      << "\t <dc:title>"<<getMagicsVersionString()<<"</dc:title>\n"
+	      << "\t</cc:Agent></dc:publisher>\n"
+	      << "\t<dc:coverage>Plot of meteorological data</dc:coverage>\n";
+	if(!meta_.empty()) pFile_<< "<!-- \n"<<meta_<<"\n-->\n";
+	pFile_<<"</cc:Work></rdf:RDF>\n</metadata>\n";
+
+	if(scripting_)
+	{
+		pFile_ << "<defs>\n"
+		       << " <clipPath id=\"clip_lupe\" shape-rendering=\"optimizeSpeed\">\n"
+		       << "  <circle cx=\"0\" cy=\"0\" r=\"75\"/>\n"
+		       << " </clipPath>\n"
+		       << "</defs>\n";
+	}
+	pFile_<< "<g id=\"page\" transform=\"translate(0,"<<dimensionY_<<")\" vector-effect=\"non-scaling-stroke\">\n";
+}
+
+
+
+/*!
+  \brief ending a page
+ 
+  This method has to take care that for formats with multiple output 
+  files are closed.
+*/
+MAGICS_NO_EXPORT void SVGDriver::endPage() const
+{
+	group_counter_=0;
+	debugOutput("Page - END");
+	closeGroup();
+	pFile_	<< "</g><!--ePage-->\n";   // needed for y-axis translation in beginning!
+
+	if(scripting_)
+	{
+		pFile_ << "<g id=\"menu\" visibility=\"visible\" fill=\"blue\" stroke=\"none\" font-size=\"10\" transform=\"translate("<<static_cast<int>(dimensionX_)-100<<" 5)\""
+		          << " fill-opacity=\"0.8\" stroke-opacity=\"0.8\" onmouseover=\"evt.target.setAttributeNS(null,'stroke-opacity','1.');evt.target.setAttributeNS(null,'fill-opacity','1.')\"";
+		if(inkscape_)
+		         pFile_ << " inkscape:groupmode=\"layer\" inkscape:label=\"Menu\"";
+		pFile_ << ">\n";
+
+		// lupe button
+		pFile_ << "<g id=\"lupe_button\" stroke=\"blue\" fill=\"rgb(230,230,255)\" transform=\"translate(-20 1)\" onclick=\"switchLupe(evt)\">\n"
+			<< " <circle cx=\"0\" cy=\"11\" r=\"10\"/>\n"
+			<< " <circle cx=\"-2\" cy=\"9\" r=\"4\"/>\n"
+			<< " <rect x=\"2\" y=\"12\" transform=\"rotate(45 2 12)\" width=\"4\" height=\"2\"/>\n"
+			<< "</g>\n";
+
+		// Layer Menu
+		if(!layers_.empty())
+		{
+		  pFile_	<< "<g id=\"layers_menu\" visibility=\"visible\" onclick=\"toggleLayers(evt)\">\n"
+				<< " <rect x=\"0\" y=\"0\" rx=\"5\" ry=\"5\" fill=\"rgb(210,210,210)\" width=\"100\" height=\"23\"/>\n"
+				<< " <text x=\"10\" y=\"17\" font-size=\"11\">Layers</text>\n</g>"
+				<< "<g id=\"layers\" visibility=\"hidden\">";
+		  int offset = 30;
+		  for(vector<string>::iterator iter=layers_.begin(); iter != layers_.end();++iter)
+		  {
+		  pFile_ << "<g id=\"button_"<<*iter<<"\" transform=\"translate(0 "<<offset<<")\" onclick=\"toggle"<<*iter<<"(evt)\">\n"
+		         << " <rect x=\"0\" y=\"0\" rx=\"5\" ry=\"5\" fill=\"rgb(210,210,210)\" width=\"100\" height=\"23\"/>\n"
+		         << " <text x=\"20\" y=\"17\" font-size=\"11\">"<<*iter<<"</text>\n"
+			 << " <rect id=\""<<*iter<<"_box\" x=\"5\" y=\"8\" width=\"10\" height=\"10\" rx=\"3\" ry=\"3\" stroke=\"green\" fill=\"green\"/>\n"
+		         << "</g>\n";
+		         offset += 30;
+		  }
+		  pFile_ << "</g>\n";
+		}
+		
+		pFile_ << "</g>\n";  // end of Menu
+
+		pFile_ << "<g id=\"lupe\" visibility=\"hidden\" transform=\"translate(55,55)\">\n"
+		       << " <circle cx=\"0\" cy=\"0\" r=\"75\" fill=\"white\" stroke=\"none\"/>\n"
+		       << " <g clip-path=\"url(#clip_lupe)\">\n"
+		       << "  <use id=\"page_mirror\" xlink:href=\"#page\" transform=\"scale(2) translate(-55,55)\"/>\n"
+		       << " </g>\n"
+		       << " <circle cx=\"0\" cy=\"0\" r=\"75\" fill=\"none\" stroke=\"black\" stroke-width=\"5\" onmousedown=\"moveLupe()\"/>\n"
+		       << "</g>\n";
+
+		// /////////////////////////////////////////////////////////////////////////
+		// Scripting - JAVASCRIPT
+		//     var x=document.getElementsByClassName(field1);
+		pFile_ << "<script type=\"text/ecmascript\"><![CDATA[\n"
+			<< "var slider=null,thumb=null,page=null,sliderActive=false;\nvar doc=null;\n"
+
+			<< "function OnLoadEvent(evt)\n"
+			<< "{\n"
+			<< "doc = evt.target.ownerDocument;\n"
+			<< "doc.addEventListener(\"click\", moveLupe, false);\n"
+			<< "}\n"
+			<< "function switchLupe(evt){\n"
+			<< "\tl=doc.getElementById(\"lupe\")\n"
+			<< "\tvar at=l.getAttributeNS(null,\"visibility\");\n"
+			<< "\tif(at==\"visible\") {l.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
+			<< "\telse {l.setAttributeNS(null,\"visibility\",\"visible\");}\n"
+			<< "}\n"
+			<< "function moveLupe(evt){\n"
+			<< "\tl=doc.getElementById(\"lupe\")\n"
+			<< "\tc=doc.getElementById(\"page_mirror\")\n"
+			<< "\tx=evt.clientX-55\n"
+			<< "\ty=evt.clientY-55\n"
+			<< "\tl.setAttribute(\"transform\",\"translate(\"+x+\" \"+y+\")\")\n"
+			<< "\tc.setAttribute(\"transform\",\"scale(2) translate(\"+(-x)+\" \"+(-y)+\")\")\n"
+			<< "}\n";
+
+			if(!layers_.empty())
+			{
+			   pFile_	<< "function toggleLayers(evt){\n"
+					<< "\tvar sb=doc.getElementById(\"layers\");\n"
+					<< "\tvar at=sb.getAttributeNS(null,\"visibility\");\n"
+					<< "\tif(at==\"visible\") {sb.setAttributeNS(null,\"visibility\",\"hidden\");cl.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
+					<< "\telse {sb.setAttributeNS(null,\"visibility\",\"visible\");cl.setAttributeNS(null,\"visibility\",\"visible\");}\n"
+					<< "}\n";
+			   for(vector<string>::iterator iter=layers_.begin(); iter != layers_.end();++iter)
+			   {
+				pFile_	<< "function toggle"<<*iter<<"(evt){\n"
+					<< "\tvar cl=doc.getElementById(\""<<*iter<<"\");\n"
+					<< "\tvar sb=doc.getElementById(\""<<*iter<<"_box\");\n"
+					<< "\tvar at=sb.getAttributeNS(null,\"fill\");\n"
+					<< "\tif(at==\"green\") {sb.setAttributeNS(null,\"fill\",\"lightgreen\");cl.setAttributeNS(null,\"visibility\",\"hidden\");}\n"
+					<< "\telse {sb.setAttributeNS(null,\"fill\",\"green\");cl.setAttributeNS(null,\"visibility\",\"visible\");}\n"
+					<< "}\n";
+			   }
+			}
+			pFile_	<< "]]></script>\n";
+	}
+
+	pFile_ << "</svg>\n";
+	pFile_.close();
+
+	layers_.clear();
+/*
+	stringarray::iterator it    = svg_output_resource_list_.begin();
+	stringarray::iterator itend = svg_output_resource_list_.end();
+	for(; it != itend; it++)
+	{
+		printOutputName("SVG misc "+(*it));
+	}
+*/
+}
+
+/*!
+  \brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \sa Layout
+*/
+MAGICS_NO_EXPORT void SVGDriver::project(const magics::Layout& layout) const
+{
+	debugOutput("Layout - "+layout.name()+" START");
+	closeGroup();
+
+	dimensionStack_.push(dimensionX_);
+	dimensionStack_.push(dimensionY_);
+	const MFloat oldHeight = dimensionY_;
+	scalesX_.push(coordRatioX_);
+	scalesY_.push(coordRatioY_);
+
+	const MFloat Xoff	= layout.x()      * 0.01 * dimensionX_;
+	const MFloat Yoff	= layout.y()      * 0.01 * dimensionY_;
+	dimensionX_		= layout.width()  * 0.01 * dimensionX_;
+	dimensionY_		= layout.height() * 0.01 * dimensionY_;
+
+	const MFloat sumX = layout.maxX() - layout.minX();
+	const MFloat sumY = layout.maxY() - layout.minY();
+
+	if( sumX!=0 && sumY!=0 )
+	{
+		coordRatioX_ =  dimensionX_/sumX;
+		coordRatioY_ =  dimensionY_/sumY;
+	}
+
+	const MFloat x_set = Xoff+projectX(-layout.minX());
+	const MFloat y_set = Yoff+projectY(-layout.minY());
+
+	group_counter_++;
+
+	pFile_ << "<g";
+	if(!layout.name().empty()) pFile_ << " id=\""<<layout.name()<<"\"";
+	if( !zero(x_set) || !zero(y_set) ) pFile_ << " transform=\"translate("<<x_set <<","<<setY(y_set)<<")\"";
+
+	//if(showCoordinates_ && area=="drawing_area") pFile_ << " onmouseover=\"setLonScale("<<coordRatioX_<<");showCoords(evt)\"";
+	//if(box->getClip()) pFile_ << " clip-path=\"url(#clip_"<<area<<")\"";
+	pFile_ << ">\n";
+
+	if(layout.isNavigable())
+	{
+		const double offsetX = projectX( -layout.minX()) + projectX(layout.minX());
+		const double offsetY = projectY(  layout.minY()) + projectY(layout.minY());
+                layout.pushDriverInfo(offsetX, oldHeight+offsetY, dimensionX_, dimensionY_);
+	}
+}
+
+MAGICS_NO_EXPORT void SVGDriver::unproject() const
+{
+	closeGroup();
+	dimensionY_ = dimensionStack_.top();dimensionStack_.pop();
+	dimensionX_ = dimensionStack_.top();dimensionStack_.pop();
+	coordRatioX_  = scalesX_.top();scalesX_.pop();
+	coordRatioY_  = scalesY_.top();scalesY_.pop();
+
+	pFile_ << "</g>\n";
+	group_counter_--;
+	debugOutput("Layout - END");
+}
+
+
+
+/*!
+  \brief setup a new layer
+
+  This method will setup a new layer. Layers enable overlays of entities
+  of information.
+
+  \sa Layer
+*/
+MAGICS_NO_EXPORT void SVGDriver::redisplay(const StaticLayer& layer) const
+{
+	const string layName = layer.name();
+	currentLayer_ = (layName.empty()) ? "StaticLayer" : layName;
+//	currentTimeBegin_ = layer.kmlTimeBegin();
+//	currentTimeEnd_   = layer.kmlTimeEnd();
+
+	newLayer();
+	layer.visit(*this);
+	closeLayer();
+}
+
+
+MAGICS_NO_EXPORT void SVGDriver::redisplay(const StepLayer& layer) const
+{
+	const string layName = layer.name();
+	currentLayer_ = (layName.empty()) ? "Step" : layName;
+
+	newLayer();
+	layer.visit(*this);
+	closeLayer();
+}
+
+
+/*!
+   \sa BaseDriver::redisplay(const NoDataLayer&)
+ */
+MAGICS_NO_EXPORT void SVGDriver::redisplay(const NoDataLayer& layer) const
+{
+	const string layName = layer.name();
+	currentLayer_ = (layName.empty()) ? "Coast" : layName;
+
+	newLayer();
+	layer.visit(*this);
+	closeLayer();
+}
+
+
+/*!
+  \brief setup a new layer
+
+  This method will setup a new layer. Layers enable overlays of entities
+  of information.
+*/
+MAGICS_NO_EXPORT void SVGDriver::newLayer() const
+{
+//cout << "SVGDriver::newLayer> " <<currentLayer_<< endl;
+	closeGroup();
+	debugOutput("Layer - "+currentLayer_+" START");
+
+	pFile_ << "<g";
+	if(!currentLayer_.empty())
+	{
+	  if(inkscape_) pFile_ << " inkscape:groupmode=\"layer\" inkscape:label=\""<<currentLayer_<<"\"";
+	  pFile_ << " id=\""<<currentLayer_<<"\"><title>"<<currentLayer_<<"</title>\n";  // mark layers for SVG Edit
+	}
+	else pFile_ << ">\n";
+
+	layers_.push_back(currentLayer_);
+}
+
+
+
+/*!
+  \brief close the current layer
+
+  This method will close an existing layer.
+*/
+MAGICS_NO_EXPORT void SVGDriver::closeLayer() const
+{
+//  cout << "SVGDriver::closeLayer> " <<currentLayer_<< endl;
+	closeGroup();
+	pFile_ << "</g>\n";
+	debugOutput("Layer - "+currentLayer_+" END");
+}
+
+
+//MAGICS_NO_EXPORT void SVGDriver::renderInteractiveBegin(const InteractiveBegin& interactive) const
+//{
+/*
+	InteractiveBegin::iterator iter = interactive.begin();
+
+	for( ; iter != interactive.end(); iter++ )
+	{
+		MagLog::dev()<< "string: " << iter->first << endl;
+	}
+*/
+/*	closeGroup();
+
+	if( !magCompare(currentBox_,"non") ) unprojectBox();
+	debugOutput("renderInteractiveBegin");
+	pFile_ << "<g onmouseover=\"scaleup(evt);\" onmouseout=\"scaledown(evt);\" id=\"int"<<interactiveCounter_<<"\" fill=\"none\" transform=\"scale(1,1)\" >\n";
+	interactiveCounter_++;
+	interactive_=true;
+}
+
+MAGICS_NO_EXPORT void SVGDriver::renderInteractiveEnd(const InteractiveEnd&) const
+{
+	debugOutput("renderInteractiveEnd");
+	if( !magCompare(currentBox_,"non") ) unprojectBox();
+	pFile_ << "</g>"<<endl;
+	interactive_=false;
+}
+*/
+
+MAGICS_NO_EXPORT void SVGDriver::openGroup(string g) const
+{
+	if(!magCompare(g,groupString_))
+	{
+		closeGroup();
+		pFile_	<< "<g "<<g<<">" <<endl;
+		groupString_ = g;
+	}
+}
+
+MAGICS_NO_EXPORT void SVGDriver::closeGroup() const
+{
+	if(!groupString_.empty())
+	{
+		pFile_	<< "</g>"<<endl;
+		groupString_="";
+	}
+}
+
+
+/*!
+  \brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the 
+  current box is finished.
+
+  \sa Colour
+*/
+MAGICS_NO_EXPORT void SVGDriver::setNewColour(const Colour &colour) const
+{
+	if(currentColour_ == colour) return;
+	currentColour_ = colour;
+}
+
+/*!
+  \brief sets a new line width
+
+  This line width stays the default width until the painting in the 
+  current box is finished.
+
+  \sa setLineParameters()
+*/
+MAGICS_NO_EXPORT void SVGDriver::setNewLineWidth(const MFloat width) const
+{
+	currentLineWidth_ = width*0.5;
+}
+
+/*!
+  \brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the 
+  current box is finished.
+
+  \sa LineStyle
+
+  \param linestyle Object describing the line style
+  \param w width of the line
+
+*/
+MAGICS_NO_EXPORT int SVGDriver::setLineParameters(const LineStyle linestyle, const MFloat w) const
+{
+	const MFloat widi = w*0.5;
+//	const MFloat widi = (wid > 1) ? wid : 1;
+	currentLineType_ = linestyle;
+
+	ostringstream stream;
+	stream  << "stroke-width=\""<<widi<<"px\" ";
+	if(currentColour_.alpha() < 1.) stream	<< "stroke-opacity=\""<<currentColour_.alpha()<<"\" ";
+	stream	<< "stroke=\"rgb("
+		<< static_cast<int>(currentColour_.red()  *255) << ","
+		<< static_cast<int>(currentColour_.green()*255) << ","
+		<< static_cast<int>(currentColour_.blue() *255) << ")\""
+		<< " fill=\"none\"";
+
+	if(currentLineType_==M_DASH)            stream  << " stroke-dasharray=\""<<2*widi<<","<<2*widi<<"\"";
+	else if(currentLineType_==M_DOT)        stream  << " stroke-dasharray=\""<<1*widi<<","<<2*widi<<"\"";
+	else if(currentLineType_==M_CHAIN_DASH) stream  << " stroke-dasharray=\""<<4*widi<<","<<2*widi<<","<<2*widi<<","<<2*widi<<"\"";
+	else if(currentLineType_==M_CHAIN_DOT)  stream  << " stroke-dasharray=\""<<4*widi<<","<<2*widi<<","<<2*widi<<","<<2*widi<<","<<2*widi<<"\"";
+
+	openGroup(stream.str());
+	return 0;
+}
+
+
+
+/*!
+  \brief renders polylines
+
+  This method renders a polyline given as two MFloat arrays. The two
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void SVGDriver::renderPolyline(const int n, MFloat *x, MFloat *y) const
+{
+  if(n>1 || (currentColour_==Colour("none")) )
+  {
+	MFloat old_x = projectX(x[0]);
+	MFloat old_y = setY(projectY(y[0]));
+	pFile_ << "<path d=\"M"<<old_x<< " " << old_y;
+
+	for(int is=1;is<n;is++)
+	{
+		const MFloat x2 = projectX(x[is]);
+		const MFloat y2 = setY(projectY(y[is]));
+		const MFloat diffX = x2-old_x;
+		const MFloat diffY = y2-old_y;
+		
+		if( x2==old_x && x2==projectX(x[is+1]))
+		{
+//			cout <<"X "<<x2 << endl;
+		}
+		else if( y2==old_y && y2==setY(projectY(y[is+1]))  )
+		{
+//			cout <<"Y "<<y2 << endl;
+		}
+		else
+		{
+			pFile_ <<"l"<< diffX <<" "<< diffY;
+			old_x = x2;
+			old_y = y2;
+		}
+	}
+	pFile_	<< "\"/>\n";
+  }
+}
+
+
+/*!
+  \brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void SVGDriver::renderPolyline2(const int n, MFloat* x, MFloat* y) const
+{
+	if(n != 2 || (currentColour_==Colour("none")) ) return;
+	pFile_ << "<path d=\"M"<<x[0]<< " " <<setY(y[0])<<"L"<< x[1] <<" "<< setY(y[1]) << "\"/>\n";
+}
+
+/*!
+  \brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \sa setLineParameters()
+  \param n number of points
+  \param x array of x values
+  \param y array of y values
+*/
+MAGICS_NO_EXPORT void SVGDriver::renderSimplePolygon(const int n, MFloat* x, MFloat* y) const
+{
+	if(currentColour_.alpha() < 0.01 || n<2 || (currentColour_==Colour("none")) ) return;
+	const int r = static_cast<int>(currentColour_.red()  *255);
+	const int g = static_cast<int>(currentColour_.green()*255);
+	const int b = static_cast<int>(currentColour_.blue() *255);
+	if(r*g*b<0.) return;
+
+	debugOutput("renderSimplePolygon[]");
+
+	ostringstream gStream;
+	if(currentColour_.alpha() < 1.) gStream << "fill-opacity=\""<<currentColour_.alpha()<<"\" stroke-opacity=\"0.01\" ";
+	gStream << "stroke=\"none\" fill-rule=\"evenodd\"";
+	openGroup(gStream.str());
+	//if(currentColour_.red()*currentColour_.green()*currentColour_.blue()<0) return;
+
+	int count = 1;
+	MFloat old_x = projectX(x[0]);
+	MFloat old_y = setY(projectY(y[0]));
+
+	double sumV = 0;
+	double sumH = 0;
+	ostringstream stream;
+	stream  <<" d=\"M"<<old_x<< " " << old_y;
+
+	for(int is=1;is<n;is++)
+	{
+		const MFloat xx = projectX(x[is]);
+		const MFloat yy = setY(projectY(y[is])) ;
+		const MFloat diffX = xx-old_x;
+		const MFloat diffY = yy-old_y;
+
+		if( fabs(diffX)>0.001 || fabs(diffY)>0.001 )
+		{
+		  if     (fabs(diffX)<0.001)  // vertical
+		  {
+			if(fabs(sumH) > 0.001) {stream <<"h"<< sumH; sumH = 0.;} // empty horizontal
+			sumV += diffY;
+		  }
+		  else if(fabs(diffY)<0.001)
+		  {
+			if(fabs(sumV) > 0.001) {stream <<"v"<< sumV; sumV = 0.;}
+			sumH += diffX;
+		  }
+		  else
+		  {
+			if(     fabs(sumV) > 0.001) {stream <<"v"<< sumV; sumV = 0.;}
+			else if(fabs(sumH) > 0.001) {stream <<"h"<< sumH; sumH = 0.;}
+			stream <<"l"<< diffX <<" "<< diffY;
+		  }
+		  old_x = xx;
+		  old_y = yy;
+		  count++;
+		}
+	}
+	if     (fabs(sumV) > 0.001) {stream <<"v"<< sumV;}
+	else if(fabs(sumH) > 0.001) {stream <<"h"<< sumH;}
+
+//	if(!interactive_) stream  << "pointer-events=\"none\" ";
+
+	if(count > 3)
+	{
+		if(currentShading_==M_SH_DOT)
+		{
+			const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+			const int density = (int)sqrt(pro->density_);
+			if(density<=0) return;
+			const MFloat square_size = 1./density;
+			const MFloat s = pro->size_;
+
+			pFile_  << "<pattern id=\"D_"<<svg_pattern_count<<"\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\""<<square_size<<"cm\" height=\""<<square_size<<"cm\">\n"
+			        << "   <rect x=\"0cm\" y=\"0cm\" width=\""<<s<<"cm\" height=\""<<s<<"cm\" stroke=\"none\" fill=\"rgb("
+				<< r << ","
+				<< g << ","
+				<< b << ")\" ";
+			if(currentColour_.alpha() < 1.) pFile_	<< "fill-opacity=\""<<currentColour_.alpha()<<"\" ";
+			pFile_  << "/>\n"
+			        << "</pattern>\n"
+			        << "<path fill=\"url(#D_"<<svg_pattern_count<<")\" stroke=\"none\" "
+				<< stream.str() <<"\"/>\n";
+			svg_pattern_count++;
+		}
+		else if(currentShading_==M_SH_HATCH)
+		{
+			const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+			indexHatch_ = pro->index_;
+			const int density = (int)(1./pro->density_*150);
+
+			pFile_  << "<pattern id=\"H_"<<svg_pattern_count
+				<<"\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\""<<density<<"\" height=\""<<density<<"\">\n"
+				<< " <g stroke=\"rgb("
+				<< r << ","
+				<< g << ","
+				<< b << ")\">\n";
+
+			if(indexHatch_==1 || indexHatch_==3) // horizontal
+			{
+				pFile_ << "  <polyline points=\"0,"<<density*.5<<" "<<density<<","<<density*.5<<"\"\n/>";
+			}
+			if(indexHatch_==2 || indexHatch_==3)
+			{
+				pFile_ << "  <polyline points=\""<<density*.5<<",0 "<<density*.5<<","<<density<<"\"\n/>";
+			}
+			if(indexHatch_==4 || indexHatch_==6)
+			{
+				pFile_ << "  <polyline points=\"0,0 "<<density<<","<<density<<"\"\n/>";
+			}
+			if(indexHatch_==5 || indexHatch_==6)
+			{
+				pFile_ << "  <polyline points=\""<<density<<","<<density<<" 0,0\"\n/>";
+			}
+			pFile_ 	<< " </g>\n</pattern>\n"
+				<< "<path fill=\"url(#H_"<<svg_pattern_count<<")\" stroke=\"none\" "
+				<< stream.str() <<"\"/>\n";
+			svg_pattern_count++;
+		}
+		else
+		{
+			pFile_	<<"<path fill=\"rgb("
+				<< r << ","
+				<< g << ","
+				<< b << ")\" ";
+//				<< "stroke=\"rgb("               // mde ECMWF logo blurry
+//				<< static_cast<int>(currentColour_.red()  *255) << ","
+//				<< static_cast<int>(currentColour_.green()*255) << ","
+//				<< static_cast<int>(currentColour_.blue() *255) << ")\" "
+			pFile_	<< stream.str() <<"\"/>\n";
+		}
+	}
+}
+
+void SVGDriver::renderSimplePolygon(const Polyline& line) const
+{
+	const unsigned int n = line.size();
+	if(n<3) return;
+	line.getShading()->draw(*this);
+	setNewColour(line.getFillColour());
+	if(currentColour_.alpha() < 0.01) return;
+	debugOutput("renderSimplePolygon<Polyline>");
+	const int r = static_cast<int>(currentColour_.red()  *255);
+	const int g = static_cast<int>(currentColour_.green()*255);
+	const int b = static_cast<int>(currentColour_.blue() *255);
+	if(r*g*b<0.) return;
+
+	// Build group tag 
+	ostringstream gStream;
+	gStream << "fill-rule=\"evenodd\"";
+	if(currentColour_.alpha() < 1.) gStream << " fill-opacity=\""<<currentColour_.alpha()<<"\" stroke-opacity=\"0.01\"";
+
+	if(line.isStroked() && !(currentColour_==Colour("NONE")))
+	{
+		gStream	<< " stroke=\"rgb("
+			<< r << ","
+			<< g << ","
+			<< b << ")\"";
+	}
+	else
+	{
+		gStream << " stroke=\"none\"";
+	}
+	openGroup(gStream.str());
+
+	MFloat old_x = projectX(line.get(0).x());
+	MFloat old_y = setY(projectY(line.get(0).y()));
+	
+	double sumV = 0.;
+	double sumH = 0.;
+	ostringstream stream;
+	stream  <<"d=\"M"<<old_x<< " " << old_y;
+
+	for(unsigned int i=1;i<n;i++)
+	{
+		const PaperPoint& pp = line.get(i);
+		const MFloat xx = projectX(pp.x());
+		const MFloat yy = setY(projectY(pp.y())) ;
+		const MFloat diffX = xx-old_x;
+		const MFloat diffY = yy-old_y;
+		
+		if( fabs(diffX)>0.001 || fabs(diffY)>0.001 )
+		{
+		  if     (fabs(diffX)<0.001)  // vertical
+		  {
+			if(fabs(sumH) > 0.001) {stream <<"h"<< sumH; sumH = 0.;} // empty horizontal
+			sumV += diffY;
+		  }
+		  else if(fabs(diffY)<0.001)
+		  {
+			if(fabs(sumV) > 0.001) {stream <<"v"<< sumV; sumV = 0.;}
+			sumH += diffX;
+		  }
+		  else
+		  {
+			if(     fabs(sumV) > 0.001) {stream <<"v"<< sumV; sumV = 0.;}
+			else if(fabs(sumH) > 0.001) {stream <<"h"<< sumH; sumH = 0.;}
+			stream <<"l"<< diffX <<" "<< diffY;
+		  }
+		  old_x = xx;
+		  old_y = yy;
+		}
+	}
+	if     (fabs(sumV) > 0.001) {stream <<"v"<< sumV;}
+	else if(fabs(sumH) > 0.001) {stream <<"h"<< sumH;}
+
+	Polyline::Holes::const_iterator h = line.beginHoles();
+	Polyline::Holes::const_iterator he = line.endHoles();
+
+	for (; h != he; ++h)
+	{
+		vector<double> x;
+		vector<double> y;
+		line.hole(h,x,y);
+		if ( x.empty() ) 
+			continue;
+		stream <<"z\nM"<<  projectX(x[0])<< " "<<setY(projectY(y[0]));
+		vector<double>::const_iterator yt = y.begin();
+		vector<double>::const_iterator it = x.begin();
+		++it;
+		++yt;
+		for(; it != x.end(); )
+		{
+		  stream <<"L"<< projectX(*it) <<" "<< setY(projectY(*yt));
+		  ++it;
+		  ++yt;
+		}
+	}
+
+	ostringstream strFill;
+
+	if(currentShading_==M_SH_DOT)
+	{
+			const DotShadingProperties *pro = (DotShadingProperties*)currentShadingProperties_;
+			const int density = (int)sqrt(pro->density_);
+			if(density<=0) return;
+			const MFloat square_size = 1./density;
+			const MFloat s = pro->size_;
+
+			pFile_  << "<pattern id=\"D_"<<svg_pattern_count<<"\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\""<<square_size<<"cm\" height=\""<<square_size<<"cm\">\n"
+			        << "   <rect x=\"0cm\" y=\"0cm\" width=\""<<s<<"cm\" height=\""<<s<<"cm\" stroke=\"none\" fill=\"rgb("
+				<< r << ","
+				<< g << ","
+				<< b << ")\" ";
+			if(currentColour_.alpha() < 1.) pFile_	<< "fill-opacity=\""<<currentColour_.alpha()<<"\" ";
+			pFile_  << "/>\n"
+			        << "</pattern>\n";
+			strFill << "url(#D_" << svg_pattern_count <<")";
+			svg_pattern_count++;
+	}
+	else if(currentShading_==M_SH_HATCH)
+	{
+			const HatchShadingProperties *pro = (HatchShadingProperties*)currentShadingProperties_;
+			indexHatch_ = pro->index_;
+			const int density = (int)(1./pro->density_*150);
+
+			pFile_  << "<pattern id=\"H_"<<svg_pattern_count
+				<<"\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\""<<density<<"\" height=\""<<density<<"\">\n"
+				<< " <g stroke=\"rgb("
+				<< r << ","
+				<< g << ","
+				<< b << ")\">\n";
+
+			if(indexHatch_==1 || indexHatch_==3) // horizontal
+			{
+				pFile_ << "  <polyline points=\"0,"<<density*.5<<" "<<density<<","<<density*.5<<"\"\n/>";
+			}
+			if(indexHatch_==2 || indexHatch_==3)
+			{
+				pFile_ << "  <polyline points=\""<<density*.5<<",0 "<<density*.5<<","<<density<<"\"\n/>";
+			}
+			if(indexHatch_==4 || indexHatch_==6)
+			{
+				pFile_ << "  <polyline points=\"0,0 "<<density<<","<<density<<"\"\n/>";
+			}
+			if(indexHatch_==5 || indexHatch_==6)
+			{
+				pFile_ << "  <polyline points=\""<<density<<","<<density<<" 0,0\"\n/>";
+			}
+			pFile_ 	<< " </g>\n</pattern>\n";
+			strFill << "url(#H_" <<svg_pattern_count<<")";
+			svg_pattern_count++;
+	}
+	else
+	{
+		strFill << "rgb(" << r << "," << g << "," << b << ")";
+	}
+	pFile_	<< "<path fill=\""<<strFill.str()<<"\" " << stream.str() <<"\"/>\n";
+}
+
+
+/*!
+  \brief renders text strings
+
+  This method renders given text strings.
+
+  \note As of version 2.0 there are two forms of describing text in Text.
+
+   The'dy' parameter is used to shift text vertically because the 'basline-shift'
+   parameter does not work in Firefox 1.5 + 2.0.
+
+  \sa Text
+  \param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void SVGDriver::renderText(const Text& text) const
+{
+  if(text.empty()) return;
+
+  MFloat text_scale = 0.6;  // for Firefox 2
+
+  const vector<NiceText>& niceT = text.getNiceText();
+  if(niceT.empty()) return;
+
+  Justification horizontalAlign	= text.getJustification();
+  string justification = "middle";
+  if     ( horizontalAlign==MLEFT  ) justification = "start";
+  else if( horizontalAlign==MRIGHT ) justification = "end";
+
+  VerticalAlign verticalAlign = text.getVerticalAlign();
+  double vertical = 0.;
+
+  unsigned int noTexts = text.size();
+  vector<NiceText>::const_iterator niceTextEnd = text.textEnd();
+
+  for(unsigned int tex=0;tex<noTexts;tex++)  // for all sting COORDINATES
+  {
+	vector<NiceText>::const_iterator niceText = text.textBegin();
+
+	for(;niceText<niceTextEnd;niceText++)
+	{
+//cout <<"SVG> "<< (*niceText).text()<< endl;
+		const MagFont magfont = (*niceText).font();
+		setNewColour(magfont.colour());
+		const MFloat dheight = magfont.size()*text_scale;
+		const std::set<string>& styles = magfont.styles();
+		string style = "";
+		if(styles.find("bold") != styles.end()) style = "bold";
+		if(styles.find("italic") != styles.end()) style += "italic";
+		if(style == "") style = "normal";
+		const string font   = magfont.name()+"_"+style;
+
+		if (verticalAlign==MBASE )       vertical = dheight * .15;
+		else if (verticalAlign==MTOP)    vertical = dheight;
+		else if (verticalAlign==MHALF)   vertical = dheight * .5;
+// default	else if (verticalAlign==MBOTTOM) vertical = 0.;
+//		vertical = -vertical/dheight *100;
+
+		fontMapIter iter = FontMap_.find(font);
+		string ttf;
+		if(iter!=FontMap_.end())
+			ttf = iter->second.css_name;
+		else
+		{
+			ttf = FontMap_["sansserif_normal"].css_name; // if not found get default
+			MagLog::warning() << "SVGDriver: Font "<< font << " is not registered! Default font is used."<< endl;
+		}
+
+		const double xxx = projectX(text[tex].x());
+		const double yyy = setY(projectY(text[tex].y()));
+
+		if(niceText==text.textBegin())
+		{
+		   if(tex==0)
+		   {
+			ostringstream stream;
+			stream << "text-anchor=\""<<justification<< "\" font-size=\""<<dheight<<"cm\" font-family=\""<< ttf << "\" ";
+			if(styles.find("bold") != styles.end())   stream <<"font-weight=\"bold\" ";
+			if(styles.find("italic") != styles.end()) stream <<"font-style=\"italic\" ";
+			if(text.getAngle()!=0)
+				stream << "transform=\"rotate("<<text.getAngle()*57.29577951<<","<<xxx<<","<<yyy<<")\" ";
+			stream << "fill=\"rgb("<<static_cast<int>(currentColour_.red()*255)<<","<<static_cast<int>(currentColour_.green()*255)<<","
+			       << static_cast<int>(currentColour_.blue()*255)<<")\"";
+			openGroup(stream.str());
+		   }
+
+		   pFile_ << "<text x=\""<<xxx<<"\" y=\""<<yyy<<"\"";
+//		   if(text.getBlanking())
+//			   pFile_ << " background-color=\"white\"";
+		   if(zero(vertical))
+		     pFile_ << ">"<<(*niceText).text();
+		   else 
+		     pFile_ << "><tspan dy=\""<<vertical<<"cm\">"<<(*niceText).text()<<"</tspan>";
+		}
+		else
+		{
+		  pFile_ <<"<tspan "
+		      <<"font-size=\""<<dheight<<"cm\" font-family=\""<< ttf << "\" ";
+		  if(styles.find("bold") != styles.end())   pFile_ <<"font-weight=\"bold\" ";
+		  if(styles.find("italic") != styles.end()) pFile_ <<"font-style=\"italic\" ";
+		  pFile_ <<"fill=\"rgb("<<static_cast<int>(currentColour_.red()*255)<<","<<static_cast<int>(currentColour_.green()*255)<<","
+		      << static_cast<int>(currentColour_.blue()*255)<<")\""
+		      <<">"<<(*niceText).text()<<"</tspan>";
+		}
+	}// end for all strings
+	pFile_ <<"</text>\n";
+   }// end for all co-ordinates
+//   pFile_ <<"</g>\n";
+}
+
+/*!
+  \brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \param x X Position
+  \param y Y Position
+  \param r Radius of circle
+  \param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void SVGDriver::circle(const MFloat x, const MFloat y, const MFloat r, const int s) const
+{
+	const int cx =      static_cast<int>(projectX(x));
+	const int cy = setY(static_cast<int>(projectY(y)));
+
+	ostringstream stream;
+
+	if(s < 8 && s >= 0)
+	{
+		stream  << "stroke=\"rgb("
+			<< static_cast<int>(currentColour_.red()  *255) << ","
+			<< static_cast<int>(currentColour_.green()*255) << ","
+			<< static_cast<int>(currentColour_.blue() *255) << ")\""
+			<< " fill=\"none\"";
+		openGroup(stream.str());
+
+		if(s==0)
+		{
+		 pFile_	<< "<circle cx=\""<<cx<<"\" cy=\""<<cy<<"\" r=\""<<r<<"\"/>\n";
+		}
+		else
+		{
+		 const short  i   = (s<4) ? 1 : 0;
+		 const double rad = s*0.7853981634*r;
+		 pFile_	<< "<path d=\"M"<<cx<<" "<<cy-r<<" A"<<r<<","<<r<<" 0 "<<i<<" 1 "
+			<< cx+cos(rad)<<" "<<cy+sin(rad)<<"\" "
+			<< "fill=\"rgb("
+			<< static_cast<int>(currentColour_.red()  *255) << ","
+			<< static_cast<int>(currentColour_.green()*255) << ","
+			<< static_cast<int>(currentColour_.blue() *255) << ")\""
+			<<"/>\n"
+			<< "<circle cx=\""<<cx<<"\" cy=\""<<cy<<"\" r=\""<<r<<"\"""/>\n";
+		}
+	}
+	else if(s==8)
+	{
+		stream  << "stroke=\"rgb("
+			<< static_cast<int>(currentColour_.red()  *255) << ","
+			<< static_cast<int>(currentColour_.green()*255) << ","
+			<< static_cast<int>(currentColour_.blue() *255) << ")\""
+			<< " fill=\"rgb("
+			<< static_cast<int>(currentColour_.red()  *255) << ","
+			<< static_cast<int>(currentColour_.green()*255) << ","
+			<< static_cast<int>(currentColour_.blue() *255) << ")\"";
+		openGroup(stream.str());
+
+		pFile_	<< "<circle cx=\""<<cx<<"\" cy=\""<<cy<<"\" r=\""<<r<<"\"/>\n";
+	}
+	if(s==9)
+	{
+		stream  << "stroke=\"rgb("
+			<< static_cast<int>(currentColour_.red()  *255) << ","
+			<< static_cast<int>(currentColour_.green()*255) << ","
+			<< static_cast<int>(currentColour_.blue() *255) << ")\""
+			<< " fill=\"rgb("
+			<< static_cast<int>(currentColour_.red()  *255) << ","
+			<< static_cast<int>(currentColour_.green()*255) << ","
+			<< static_cast<int>(currentColour_.blue() *255) << ")\"";
+		openGroup(stream.str());
+		pFile_	<< "<circle cx=\""<<cx<<"\" cy=\""<<cy<<"\" r=\""<<r<<"\"/>\n"
+			<< "<polyline points=\"0,"<<r*.9<<" 0,"<<-r*.9<<"\" width=\"2\" stroke=\"white\" fill=\"white\"/>"<<endl;
+	}
+
+}
+
+/*!
+  \brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \sa renderCellArray()
+
+  \param x0 x of lower corner
+  \param y0 y of lower corner
+  \param x1 x of higher corner
+  \param y1 y of higher corner
+  \param w width of pixmap
+  \param h height of pixmap
+  \param pixmap contents
+
+*/
+MAGICS_NO_EXPORT bool SVGDriver::renderPixmap(MFloat x0,MFloat y0,MFloat x1,MFloat y1,
+                                            int w,int h,unsigned char* pixmap,int,bool ) const
+{
+//cout <<"SVGDriver::renderPixmap"<< endl;
+	unsigned char *p = pixmap;
+	const MFloat dx =  (x1 - x0)/w;
+	const MFloat dy = -(y1 - y0)/h;   // Minus needed for Y axis correction
+
+	const MFloat X0 = x0;
+	const MFloat Y0 = y0;
+
+	debugOutput("Pixmap - START");
+	pFile_	<< "<g pointer-events=\"none\" >\n";
+
+	for(int i=h-1;i>=0;i--)
+	{
+		for(int j=0;j<w; x0+=dx,j++)
+		{
+			const int r = (int) *(p++);
+			const int g = (int) *(p++);
+			const int b = (int) *(p++);
+			if(r*g*b>0.)
+			{
+			  const int x0 = static_cast<int>( X0+(j*dx) );
+			  const int y0 = static_cast<int>( Y0+(i*dy) );
+			  pFile_ << " <rect x=\""<<x0<<"\" y=\""<<setY(y0)<<"\" width=\""<<dx<<"\" height=\""<<dy<<"\""
+			         << " fill=\"rgb("<< r << ","<< g << "," << b << ")\" "<< "stroke=\"none\" />\n";
+			}
+		}
+		x0 = X0;
+		y0 += dy;
+	}
+	pFile_	<< "</g>\n";
+	debugOutput("Pixmap - END");
+	return true;
+}
+
+/*!
+  \brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are 
+  mainly used for satellite data.
+
+  \sa renderPixmap()
+
+  \param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool SVGDriver::renderCellArray(const Image& image) const
+{
+//cout <<"SVGDriver::renderCellArray"<< endl;
+	ColourTable &lt  = image.getColourTable(); 
+	const int width  = image.getNumberOfColumns();
+	const int height = image.getNumberOfRows();
+	const MFloat x0 = projectX(image.getOrigin().x());
+	const MFloat y0 = projectY(image.getOrigin().y());
+
+	debugOutput("Cell array - START");
+#ifdef MAGICS_RASTER
+if(!external_)
+#endif
+{
+	const MFloat x1 = projectX(image.getOrigin().x()+image.getWidth());
+	const MFloat y1 = projectY(image.getOrigin().y()+image.getHeight());
+	const MFloat dx = (x1-x0)/width;
+	const MFloat dy = (y1-y0)/height;
+
+	pFile_	<< "<g pointer-events=\"none\" stroke=\"none\" transform=\"translate("<<x0<<","<<-y0<<") scale("<<dx<<","<<dy<<")\">\n";
+	for (int i=height-1;i>=0;i--)
+	{
+		for(int j=0;j<width; j++)
+		{
+		  const int in = width*i+j;
+		  const short c = image[in];
+ 
+ 		  if(!(lt[c]=="undefined") && (lt[c].red()*lt[c].green()*lt[c].blue()) >= 0. )
+		  {
+			const int r = static_cast<int>(lt[c].red()*255.);
+			const int g = static_cast<int>(lt[c].green()*255.);
+			const int b = static_cast<int>(lt[c].blue()*255.);
+//			const MFloat wx = x0+(j* dx);
+//			const MFloat wy = y0+(i*-dy);
+			pFile_ << "<rect x=\""<<j<<"\" y=\""<<i<<"\" width=\"1\" height=\"1\" fill=\"#"<<hex;
+
+            if( r == g && g == b ) // to safe 3 digits
+            {
+                if(r==0)        pFile_ <<"000";
+                else if(r==255) pFile_ <<"fff";
+                else            pFile_ <<r<<r<<r;
+            }
+            else if ( ((r==0) || (r==255)) &&
+                      ((g==0) || (g==255)) &&
+                      ((b==0) || (b==255)) )
+            {
+                if(r==255) pFile_ <<"f";
+                else       pFile_ <<"0";
+                if(g==255) pFile_ <<"f";
+                else       pFile_ <<"0";
+                if(b==255) pFile_ <<"f";
+                else       pFile_ <<"0";
+            }
+            else
+            {
+                if(r>15)   pFile_ <<r;
+                else       pFile_ <<"0"<< r;
+                if(g>15)   pFile_ <<g;
+                else       pFile_ <<"0"<< g;
+                if(b>15)   pFile_ <<b;
+                else       pFile_ <<"0"<< b;
+            }
+			pFile_ << dec << "\"/>\n";
+		  }// point has colour
+		}
+	}
+	pFile_	<< "</g>\n";
+}
+#ifdef MAGICS_RASTER
+else
+{
+	pFile_	<< "<g pointer-events=\"none\" stroke=\"none\">\n";
+
+	stringstream out;
+	out << "page"<<currentPage_<<"_"<<currentLayer_;
+
+	string filename = tmp_pFile_+"_include_"+out.str()+".png";
+
+//	pFile_	<< "<image x=\""<<x0<<"\" y=\""<<setY(y0)<<"\" "
+//		<< " width=\""<<projectX(image.getWidth())<<"\" height=\""<<projectY(image.getHeight())<<"\" "/
+//		<< "xlink:href=\""<<filename<<"\" />\n";
+
+	ColourTable &lt  = image.getColourTable(); 
+	const int width  = image.getNumberOfColumns();
+	const int height = image.getNumberOfRows();
+
+	gdImagePtr im = gdImageCreateTrueColor(width,height);
+	gdImageColorResolveAlpha(im, 255, 255, 255, 0);
+
+	for (int i=height-1;i>=0;i--)
+	{
+		for(int j=0;j<width; j++)
+		{
+		  const int in = width*i+j;	 
+		  const short c = image[in];
+		  int col = 0;
+// 		  if(!(lt[c]=="undefined"))
+		  {
+			const int r = static_cast<int>(lt[c].red()*255.);
+			const int g = static_cast<int>(lt[c].green()*255.);
+			const int b = static_cast<int>(lt[c].blue()*255.);
+
+			col = gdImageColorResolveAlpha(im,r,g,b,50);
+		  }// point has colour
+//		  else{
+//		  	col = gdImageColorResolveAlpha(im,255,0,0,50);
+//		  }
+		  gdImageSetPixel(im, j, i, col);
+		}
+	}
+
+	gdImageAlphaBlending(im, 1);
+	gdImageSaveAlpha(im, 1); // save transparency
+
+	svg_output_resource_list_.push_back(filename);
+
+	FILE *outFile = fopen(filename.c_str(),"wb");
+	gdImagePng(im,outFile);
+	fclose(outFile);
+	gdImageDestroy(im);
+
+        if(!external_)
+        {
+            pFile_	<< "<image x=\""<<x0<<"\" y=\""<<setY(y0)<<"\" "
+                    << " width=\""<<projectX(image.getWidth())<<"\" height=\""<<projectY(image.getHeight())
+                    //		<< "\" xlink:href=\"data:image/png;base64,";
+                    << "\" xlink:href=\"data:;base64,";
+
+            // use uuencode to convet to base?
+            string cmd = "( uuencode --base64 ";
+            cmd.append(filename);
+            cmd.append(" too > temp.b64 )");
+
+            int status = system(cmd.c_str());
+            if(status)
+            {
+                MagLog::error() << "\nSVGDriver: Command exit not zero - NO Base64 produced!\n"
+                        << " COMMAND: "<<cmd<<"\n"<< endl;
+                return false;
+            }
+
+            char str[256];
+            int i=0;
+            fstream fout("temp.b64",ios::in);
+            while(!fout.eof())
+            {
+                fout.getline(str,256);
+                if(i>0 && strncmp(str,"=",1))
+                    pFile_ <<str<< "\n";
+                i++;
+            }
+            fout.close();
+            pFile_<<"\" />\n";
+            remove("temp.b64");
+            remove(filename.c_str());
+        }
+        else  // if external files
+        {
+            FILE *fin = fopen(filename.c_str(),"rb");
+            if(fin==0)
+            {
+                MagLog::fatal() << "Open file "<<filename<<" to be added to SVG FAILED!"<< endl;
+                return 1;
+            }
+            else
+            {
+                pFile_	<< "<image x=\""<<x0<<"\" y=\""<<setY(y0)<<"\" "
+                        << " width=\""<<projectX(image.getWidth())<<"\" height=\""<<projectY(image.getHeight())
+                        << "\" xlink:href=\""<<filename<<"\" />\n";
+            }
+            if (fin)
+                fclose(fin);
+        }
+	pFile_	<< "</g>\n";
+}
+#endif
+	debugOutput("Cell array - END");
+	return true;
+}
+
+/*!
+  \brief Image render method for ALL drivers.
+
+  This method should be used by all Magics++ drivers to render image objects.
+*/
+MAGICS_NO_EXPORT void SVGDriver::renderImage(const ImportObject& obj) const
+{
+//cout<< "SVGDriver::renderImage: "<<obj.getFormat()<<" "<<obj.getPath()<<" "<< obj.getOrigin().x()<<" "<<obj.getOrigin().y()<< endl;
+	closeGroup();
+	std::string file = obj.getPath();
+
+	string format = obj.getFormat();
+	if(magCompare(format,"ps") || magCompare(format,"pdf"))
+	{
+		std::string cmd = "convert "+file+"[1] ___magics_svg_temp.png";
+		MagLog::info() <<"SVGDriver::renderImage calling convert ... with: " <<cmd << endl;
+		int status = system(cmd.c_str());
+		if(status)
+		{
+			MagLog::error() << "\nSVGDriver: Command exit not zero - NO PNG produced!\n"
+			             << " COMMAND: "<<cmd<<"\n"<< endl;
+			return;
+		}
+		file="___magics_svg_temp.png";
+	}
+
+	const MFloat w = (obj.getWidth()<0)  ? 30./coordRatioX_ : obj.getWidth();
+	const MFloat h = (obj.getHeight()<0) ? 30./coordRatioY_ : obj.getHeight();
+
+	if(!magCompare(format,"svg"))
+	{
+		const MFloat x = projectX(obj.getOrigin().x());
+		const MFloat y = projectY(obj.getOrigin().y());
+		const MFloat oh = projectY(obj.getOrigin().y()+h) - y;
+		const MFloat ow = projectX(obj.getOrigin().x()+w) - x;
+
+		const ImageProperties::OriginReference ori = obj.getOriginReference();
+		if(ori == ImageProperties::centre)
+			pFile_ << "<image x=\""<<x-(ow*.5)<<"\" y=\""<<setY(y)-(oh*.5);
+		else
+			pFile_ << "<image x=\""<<x<<"\" y=\""<<setY(y)-oh;
+		pFile_  <<"\" width=\""  << ow
+		        <<"\" height=\"" << oh
+		        <<"\" xlink:href=\""<<file<<"\" />\n";
+	}
+	else
+	{
+		ifstream svgfile(file.c_str());
+		if(!svgfile){
+			MagLog::error() << "SVGDriver::renderImage() --> Cannot open SVG file! " << file <<"!\n";
+			return;
+		}
+		char ch;
+		while (svgfile.get(ch)){pFile_.put(ch);}
+		svgfile.close();
+		svg_output_resource_list_.push_back(file);
+	}
+}
+
+/*!
+  \brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \note This can increase file and log file sizes if you run Magics++ in debug mode!
+
+  \param s string to be printed
+*/
+MAGICS_NO_EXPORT void SVGDriver::debugOutput(const string &s) const
+{
+	if(debug_) pFile_ << "<!-- "<<s<<" -->\n";
+}
+
+/*!
+  \brief class information are given to the output-stream
+*/
+void SVGDriver::print(ostream& out)  const
+{
+	out << "SVGDriver[";
+	out << "]";
+}
+
+//! Method to plot symbols
+/*!
+ Needs special treatment of MagLogo. Much better quality when imported as GIF!
+*/
+MAGICS_NO_EXPORT void SVGDriver::renderSymbols(const Symbol& symbol) const
+{
+	debugOutput("Symbols - START");
+	closeGroup();
+
+	const string location = logoLocation_;
+
+	if(symbol.getSymbol()=="logo_ecmwf" && !magCompare(location,"INLINE") )
+	{
+          if(inkscape_) pFile_ << "<g inkscape:groupmode=\"layer\" inkscape:label=\"ECMWF_logo\">\n"
+                               << " <title>ECMWF_logo</title>\n";
+
+	  const MFloat x = projectX(symbol[0].x());
+	  const MFloat y = projectY(symbol[0].y());
+
+	  string logofile;
+	  if(magCompare(location,"WWW")) logofile = "http://www.ecmwf.int/publications/manuals/magics/magplus/resources/ecmwf_logo.png";
+	  else if(magCompare(location,"LOCAL")) logofile = "ecmwf_logo.png";
+	  else logofile = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "ecmwf_logo.png";
+	  svg_output_resource_list_.push_back(logofile);
+	  pFile_ << "<a xlink:href=\"http://www.ecmwf.int\">"
+	         << "<image x=\""<<x-(y*1.35)<<"\" y=\""<<setY(y+(y*.5))<<"\" width=\""<<y*5.4<<"\" height=\""<<y<<"\" xlink:href=\""<<logofile<<"\" />"
+	         << "</a>\n";
+	  if(inkscape_) pFile_ << "</g>\n";
+	}
+	else 
+		BaseDriver::renderSymbols(symbol);
+
+	debugOutput("Symbols - END");
+}
+
+static SimpleObjectMaker<SVGDriver, BaseDriver> SVG_driver("SVG");
diff --git a/src/drivers/SVGDriver.h b/src/drivers/SVGDriver.h
new file mode 100644
index 0000000..bc5a021
--- /dev/null
+++ b/src/drivers/SVGDriver.h
@@ -0,0 +1,145 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \file SVGDriver.h
+    \brief Definition of SVGDriver.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Fri Oct 26 20:58:21 2007
+*/
+
+#ifndef _SVGDriver_H
+#define _SVGDriver_H
+
+#include <BaseDriver.h>
+#include <SVGDriverAttributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \class SVGDriver
+    \brief This driver produces output for SVG
+    \ingroup drivers
+
+    This driver provides output in the SVG format:
+    
+    \sa http://www.w3.org/Graphics/SVG/
+*/
+class SVGDriver: public BaseDriver, public SVGDriverAttributes
+{
+
+public:
+	SVGDriver();
+	~SVGDriver();
+	void open();
+	void close();
+
+	/*!
+	  \brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+		XmlNode basic = node;
+		basic.name("driver");
+		BaseDriver::set(basic);
+		basic.name("svg");
+		SVGDriverAttributes::set(basic);
+	}
+
+	/*!
+	  \brief sets a new map
+	*/
+	void set(const map<string, string>& map)
+	{
+		BaseDriver::set(map);
+		SVGDriverAttributes::set(map);
+	}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void unproject() const;
+	MAGICS_NO_EXPORT void redisplay(const StaticLayer& layer) const;
+	MAGICS_NO_EXPORT void redisplay(const StepLayer& layer) const;
+	MAGICS_NO_EXPORT void redisplay(const NoDataLayer& layer) const;
+	MAGICS_NO_EXPORT void newLayer() const;
+	MAGICS_NO_EXPORT void closeLayer() const;
+//	MAGICS_NO_EXPORT void renderInteractiveBegin(const InteractiveBegin&) const;
+//	MAGICS_NO_EXPORT void renderInteractiveEnd(const InteractiveEnd&) const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const MFloat) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const MFloat w) const;
+//	MAGICS_NO_EXPORT void printLine(const Polyline &line) const;
+
+//	MAGICS_NO_EXPORT void redisplay(const Polyline& line) const;
+	MAGICS_NO_EXPORT void renderPolyline(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, MFloat *x, MFloat *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, MFloat *, MFloat *) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const Polyline& lines) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT bool renderPixmap(MFloat,MFloat,MFloat,MFloat,int,int,unsigned char*,int,bool) const;
+	MAGICS_NO_EXPORT void renderSymbols(const Symbol& symbol) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+	MAGICS_NO_EXPORT void renderImage(const ImportObject& obj) const;
+	MAGICS_NO_EXPORT void circle(const MFloat x, const MFloat y, const MFloat r, const int) const;
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	MAGICS_NO_EXPORT void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	MAGICS_NO_EXPORT MFloat setY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setSymbolY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT MFloat setAngleY(const MFloat y) const {return y;}
+	MAGICS_NO_EXPORT MFloat setFlagY(const MFloat y) const {return -y;}
+	MAGICS_NO_EXPORT double getRatio() const {return getYDeviceLength() / getXDeviceLength();}
+
+	MAGICS_NO_EXPORT void openGroup(string g) const;
+	MAGICS_NO_EXPORT void closeGroup() const;
+	MAGICS_NO_EXPORT bool isGroup() const {return groupString_.empty();}
+
+	mutable ofstream	pFile_;        //!< Output stream to file.
+	mutable string		tmp_pFile_;    //!< Tmp to hold output stream to file.
+	mutable string		groupString_;
+	mutable int		group_counter_;
+//	mutable bool		showCoordinates_;
+	mutable bool		inkscape_;
+//	mutable bool		interactive_;
+//	mutable unsigned short	interactiveCounter_;
+
+	mutable std::vector<string> layers_;
+	mutable stringarray svg_output_resource_list_;
+
+	//! Copy constructor - No copy allowed
+	SVGDriver(const SVGDriver&);
+	//! Overloaded << operator to copy - No copy allowed
+	SVGDriver& operator=(const SVGDriver&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SVGDriver& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/System.h b/src/drivers/System.h
new file mode 100644
index 0000000..5ce0543
--- /dev/null
+++ b/src/drivers/System.h
@@ -0,0 +1,90 @@
+/******************************** LICENSE ********************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************/
+
+/*! \file System.h
+    \brief In this file wrappers are defined for system calls
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Jan 2004
+    
+*/
+#ifndef SystemInfo_H
+#define SystemInfo_H
+
+#include <magics.h>
+#include <cstdlib>
+#include <pwd.h>
+#include <unistd.h>
+
+namespace magics {
+
+/*! \class SystemInfo
+    \brief This class gives information about the system.
+    
+     This class is very much platform dependent!!!.
+     
+     \todo move this file in a more central directory?
+*/
+class SystemInfo{
+
+public:
+	SystemInfo(){};
+	~SystemInfo(){}; // not virtual - so do not inherit!
+	
+	MAGICS_NO_EXPORT string getHostName() const
+	{
+		char host[256];
+		if(gethostname(host, sizeof(host)) == -1)
+			strcpy(host, "unknown-host");
+		string tmp(host);
+		return tmp;
+	};//end getHostName()
+	
+	MAGICS_NO_EXPORT string getTime() const
+	{
+		time_t when;
+		time(&when);
+		string tmp(ctime(&when));
+		tmp.erase(25);  // need to cut \n\0
+		tmp.erase(24);
+		return tmp;
+	};
+	
+	MAGICS_NO_EXPORT string getUserID() const
+	{
+		struct passwd* who = getpwuid(getuid());
+		string tmp(who->pw_name);
+		return tmp;
+	};
+
+	MAGICS_NO_EXPORT string getUserName() const
+	{
+		struct passwd* who = getpwuid(getuid());
+		string tmp(who->pw_gecos);
+		return tmp;
+	};		
+private:
+// No copy allowed
+	SystemInfo(const SystemInfo&);
+	SystemInfo& operator=(const SystemInfo&);
+};
+
+} // namespace magics
+#endif
diff --git a/src/drivers/minizip/crypt.h b/src/drivers/minizip/crypt.h
new file mode 100644
index 0000000..622f4bc
--- /dev/null
+++ b/src/drivers/minizip/crypt.h
@@ -0,0 +1,132 @@
+/* crypt.h -- base code for crypt/uncrypt ZIPfile
+
+
+   Version 1.01e, February 12th, 2005
+
+   Copyright (C) 1998-2005 Gilles Vollant
+
+   This code is a modified version of crypting code in Infozip distribution
+
+   The encryption/decryption parts of this source code (as opposed to the
+   non-echoing password parts) were originally written in Europe.  The
+   whole source package can be freely distributed, including from the USA.
+   (Prior to January 2000, re-export from the US was a violation of US law.)
+
+   This encryption code is a direct transcription of the algorithm from
+   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
+   file (appnote.txt) is distributed with the PKZIP program (even in the
+   version without encryption capabilities).
+
+   If you don't need crypting in your application, just define symbols
+   NOCRYPT and NOUNCRYPT.
+
+   This code support the "Traditional PKWARE Encryption".
+
+   The new AES encryption added on Zip format by Winzip (see the page
+   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
+   Encryption is not supported.
+*/
+
+#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
+
+/***********************************************************************
+ * Return the next byte in the pseudo-random sequence
+ */
+static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
+{
+    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an
+                     * unpredictable manner on 16-bit systems; not a problem
+                     * with any known compiler so far, though */
+
+    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
+    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
+}
+
+/***********************************************************************
+ * Update the encryption keys with the next byte of plain text
+ */
+static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
+{
+    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
+    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
+    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
+    {
+      register int keyshift = (int)((*(pkeys+1)) >> 24);
+      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
+    }
+    return c;
+}
+
+
+/***********************************************************************
+ * Initialize the encryption keys and the random header according to
+ * the given password.
+ */
+static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
+{
+    *(pkeys+0) = 305419896L;
+    *(pkeys+1) = 591751049L;
+    *(pkeys+2) = 878082192L;
+    while (*passwd != '\0') {
+        update_keys(pkeys,pcrc_32_tab,(int)*passwd);
+        passwd++;
+    }
+}
+
+#define zdecode(pkeys,pcrc_32_tab,c) \
+    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
+
+#define zencode(pkeys,pcrc_32_tab,c,t) \
+    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
+
+#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
+
+#define RAND_HEAD_LEN  12
+   /* "last resort" source for second part of crypt seed pattern */
+#  ifndef ZCR_SEED2
+#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */
+#  endif
+
+static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
+    const char *passwd;         /* password string */
+    unsigned char *buf;         /* where to write header */
+    int bufSize;
+    unsigned long* pkeys;
+    const unsigned long* pcrc_32_tab;
+    unsigned long crcForCrypting;
+{
+    int n;                       /* index in random header */
+    int t;                       /* temporary */
+    int c;                       /* random byte */
+    unsigned char header[RAND_HEAD_LEN-2]; /* random header */
+    static unsigned calls = 0;   /* ensure different random header each time */
+
+    if (bufSize<RAND_HEAD_LEN)
+      return 0;
+
+    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
+     * output of rand() to get less predictability, since rand() is
+     * often poorly implemented.
+     */
+    if (++calls == 1)
+    {
+        srand((unsigned)(time(NULL) ^ ZCR_SEED2));
+    }
+    init_keys(passwd, pkeys, pcrc_32_tab);
+    for (n = 0; n < RAND_HEAD_LEN-2; n++)
+    {
+        c = (rand() >> 7) & 0xff;
+        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
+    }
+    /* Encrypt random header (last two bytes is high word of crc) */
+    init_keys(passwd, pkeys, pcrc_32_tab);
+    for (n = 0; n < RAND_HEAD_LEN-2; n++)
+    {
+        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
+    }
+    buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
+    buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
+    return n;
+}
+
+#endif
diff --git a/src/drivers/minizip/ioapi.c b/src/drivers/minizip/ioapi.c
new file mode 100644
index 0000000..f1bee23
--- /dev/null
+++ b/src/drivers/minizip/ioapi.c
@@ -0,0 +1,177 @@
+/* ioapi.c -- IO base function header for compress/uncompress .zip
+   files using zlib + zip or unzip API
+
+   Version 1.01e, February 12th, 2005
+
+   Copyright (C) 1998-2005 Gilles Vollant
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "zlib.h"
+#include "ioapi.h"
+
+
+
+/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
+
+#ifndef SEEK_CUR
+#define SEEK_CUR    1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END    2
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET    0
+#endif
+
+voidpf ZCALLBACK fopen_file_func OF((
+   voidpf opaque,
+   const char* filename,
+   int mode));
+
+uLong ZCALLBACK fread_file_func OF((
+   voidpf opaque,
+   voidpf stream,
+   void* buf,
+   uLong size));
+
+uLong ZCALLBACK fwrite_file_func OF((
+   voidpf opaque,
+   voidpf stream,
+   const void* buf,
+   uLong size));
+
+long ZCALLBACK ftell_file_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+long ZCALLBACK fseek_file_func OF((
+   voidpf opaque,
+   voidpf stream,
+   uLong offset,
+   int origin));
+
+int ZCALLBACK fclose_file_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+int ZCALLBACK ferror_file_func OF((
+   voidpf opaque,
+   voidpf stream));
+
+
+voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
+   voidpf opaque;
+   const char* filename;
+   int mode;
+{
+    FILE* file = NULL;
+    const char* mode_fopen = NULL;
+    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+        mode_fopen = "rb";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+        mode_fopen = "r+b";
+    else
+    if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+        mode_fopen = "wb";
+
+    if ((filename!=NULL) && (mode_fopen != NULL))
+        file = fopen(filename, mode_fopen);
+    return file;
+}
+
+
+uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
+   voidpf opaque;
+   voidpf stream;
+   void* buf;
+   uLong size;
+{
+    uLong ret;
+    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+
+uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
+   voidpf opaque;
+   voidpf stream;
+   const void* buf;
+   uLong size;
+{
+    uLong ret;
+    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
+    return ret;
+}
+
+long ZCALLBACK ftell_file_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    long ret;
+    ret = ftell((FILE *)stream);
+    return ret;
+}
+
+long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
+   voidpf opaque;
+   voidpf stream;
+   uLong offset;
+   int origin;
+{
+    int fseek_origin=0;
+    long ret;
+    switch (origin)
+    {
+    case ZLIB_FILEFUNC_SEEK_CUR :
+        fseek_origin = SEEK_CUR;
+        break;
+    case ZLIB_FILEFUNC_SEEK_END :
+        fseek_origin = SEEK_END;
+        break;
+    case ZLIB_FILEFUNC_SEEK_SET :
+        fseek_origin = SEEK_SET;
+        break;
+    default: return -1;
+    }
+    ret = 0;
+    fseek((FILE *)stream, offset, fseek_origin);
+    return ret;
+}
+
+int ZCALLBACK fclose_file_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    int ret;
+    ret = fclose((FILE *)stream);
+    return ret;
+}
+
+int ZCALLBACK ferror_file_func (opaque, stream)
+   voidpf opaque;
+   voidpf stream;
+{
+    int ret;
+    ret = ferror((FILE *)stream);
+    return ret;
+}
+
+void fill_fopen_filefunc (pzlib_filefunc_def)
+  zlib_filefunc_def* pzlib_filefunc_def;
+{
+    pzlib_filefunc_def->zopen_file = fopen_file_func;
+    pzlib_filefunc_def->zread_file = fread_file_func;
+    pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+    pzlib_filefunc_def->ztell_file = ftell_file_func;
+    pzlib_filefunc_def->zseek_file = fseek_file_func;
+    pzlib_filefunc_def->zclose_file = fclose_file_func;
+    pzlib_filefunc_def->zerror_file = ferror_file_func;
+    pzlib_filefunc_def->opaque = NULL;
+}
diff --git a/src/drivers/minizip/ioapi.h b/src/drivers/minizip/ioapi.h
new file mode 100644
index 0000000..7d457ba
--- /dev/null
+++ b/src/drivers/minizip/ioapi.h
@@ -0,0 +1,75 @@
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+   files using zlib + zip or unzip API
+
+   Version 1.01e, February 12th, 2005
+
+   Copyright (C) 1998-2005 Gilles Vollant
+*/
+
+#ifndef _ZLIBIOAPI_H
+#define _ZLIBIOAPI_H
+
+
+#define ZLIB_FILEFUNC_SEEK_CUR (1)
+#define ZLIB_FILEFUNC_SEEK_END (2)
+#define ZLIB_FILEFUNC_SEEK_SET (0)
+
+#define ZLIB_FILEFUNC_MODE_READ      (1)
+#define ZLIB_FILEFUNC_MODE_WRITE     (2)
+#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
+
+#define ZLIB_FILEFUNC_MODE_EXISTING (4)
+#define ZLIB_FILEFUNC_MODE_CREATE   (8)
+
+
+#ifndef ZCALLBACK
+
+#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
+#define ZCALLBACK CALLBACK
+#else
+#define ZCALLBACK
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
+typedef uLong  (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong  (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef long   (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
+typedef long   (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
+typedef int    (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
+typedef int    (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
+
+typedef struct zlib_filefunc_def_s
+{
+    open_file_func      zopen_file;
+    read_file_func      zread_file;
+    write_file_func     zwrite_file;
+    tell_file_func      ztell_file;
+    seek_file_func      zseek_file;
+    close_file_func     zclose_file;
+    testerror_file_func zerror_file;
+    voidpf              opaque;
+} zlib_filefunc_def;
+
+
+
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+
+#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
+#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
+#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
+#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
+#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
+#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/drivers/minizip/zip.c b/src/drivers/minizip/zip.c
new file mode 100644
index 0000000..8b75d7c
--- /dev/null
+++ b/src/drivers/minizip/zip.c
@@ -0,0 +1,1219 @@
+/* zip.c -- IO on .zip files using zlib
+   Version 1.01e, February 12th, 2005
+
+   27 Dec 2004 Rolf Kalbermatter
+   Modification to zipOpen2 to support globalComment retrieval.
+
+   Copyright (C) 1998-2005 Gilles Vollant
+
+   Read zip.h for more info
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "zlib.h"
+#include "zip.h"
+
+#ifdef STDC
+#  include <stddef.h>
+#  include <string.h>
+#  include <stdlib.h>
+#endif
+#ifdef NO_ERRNO_H
+    extern int errno;
+#else
+#   include <errno.h>
+#endif
+
+
+#ifndef local
+#  define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+#ifndef VERSIONMADEBY
+# define VERSIONMADEBY   (0x0) /* platform depedent */
+#endif
+
+#ifndef Z_BUFSIZE
+#define Z_BUFSIZE (16384)
+#endif
+
+#ifndef Z_MAXFILENAMEINZIP
+#define Z_MAXFILENAMEINZIP (256)
+#endif
+
+#ifndef ALLOC
+# define ALLOC(size) (malloc(size))
+#endif
+#ifndef TRYFREE
+# define TRYFREE(p) {if (p) free(p);}
+#endif
+
+/*
+#define SIZECENTRALDIRITEM (0x2e)
+#define SIZEZIPLOCALHEADER (0x1e)
+*/
+
+/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
+
+#ifndef SEEK_CUR
+#define SEEK_CUR    1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END    2
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET    0
+#endif
+
+#ifndef DEF_MEM_LEVEL
+#if MAX_MEM_LEVEL >= 8
+#  define DEF_MEM_LEVEL 8
+#else
+#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
+#endif
+#endif
+const char zip_copyright[] =
+   " zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
+
+
+#define SIZEDATA_INDATABLOCK (4096-(4*4))
+
+#define LOCALHEADERMAGIC    (0x04034b50)
+#define CENTRALHEADERMAGIC  (0x02014b50)
+#define ENDHEADERMAGIC      (0x06054b50)
+
+#define FLAG_LOCALHEADER_OFFSET (0x06)
+#define CRC_LOCALHEADER_OFFSET  (0x0e)
+
+#define SIZECENTRALHEADER (0x2e) /* 46 */
+
+typedef struct linkedlist_datablock_internal_s
+{
+  struct linkedlist_datablock_internal_s* next_datablock;
+  uLong  avail_in_this_block;
+  uLong  filled_in_this_block;
+  uLong  unused; /* for future use and alignement */
+  unsigned char data[SIZEDATA_INDATABLOCK];
+} linkedlist_datablock_internal;
+
+typedef struct linkedlist_data_s
+{
+    linkedlist_datablock_internal* first_block;
+    linkedlist_datablock_internal* last_block;
+} linkedlist_data;
+
+
+typedef struct
+{
+    z_stream stream;            /* zLib stream structure for inflate */
+    int  stream_initialised;    /* 1 is stream is initialised */
+    uInt pos_in_buffered_data;  /* last written byte in buffered_data */
+
+    uLong pos_local_header;     /* offset of the local header of the file
+                                     currenty writing */
+    char* central_header;       /* central header data for the current file */
+    uLong size_centralheader;   /* size of the central header for cur file */
+    uLong flag;                 /* flag of the file currently writing */
+
+    int  method;                /* compression method of file currenty wr.*/
+    int  raw;                   /* 1 for directly writing raw data */
+    Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/
+    uLong dosDate;
+    uLong crc32;
+    int  encrypt;
+#ifndef NOCRYPT
+    unsigned long keys[3];     /* keys defining the pseudo-random sequence */
+    const unsigned long* pcrc_32_tab;
+    int crypt_header_size;
+#endif
+} curfile_info;
+
+typedef struct
+{
+    zlib_filefunc_def z_filefunc;
+    voidpf filestream;        /* io structore of the zipfile */
+    linkedlist_data central_dir;/* datablock with central dir in construction*/
+    int  in_opened_file_inzip;  /* 1 if a file in the zip is currently writ.*/
+    curfile_info ci;            /* info on the file curretly writing */
+
+    uLong begin_pos;            /* position of the beginning of the zipfile */
+    uLong add_position_when_writting_offset;
+    uLong number_entry;
+#ifndef NO_ADDFILEINEXISTINGZIP
+    char *globalcomment;
+#endif
+} zip_internal;
+
+
+
+#ifndef NOCRYPT
+#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
+#include "crypt.h"
+#endif
+
+local linkedlist_datablock_internal* allocate_new_datablock()
+{
+    linkedlist_datablock_internal* ldi;
+    ldi = (linkedlist_datablock_internal*)
+                 ALLOC(sizeof(linkedlist_datablock_internal));
+    if (ldi!=NULL)
+    {
+        ldi->next_datablock = NULL ;
+        ldi->filled_in_this_block = 0 ;
+        ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ;
+    }
+    return ldi;
+}
+
+local void free_datablock(ldi)
+    linkedlist_datablock_internal* ldi;
+{
+    while (ldi!=NULL)
+    {
+        linkedlist_datablock_internal* ldinext = ldi->next_datablock;
+        TRYFREE(ldi);
+        ldi = ldinext;
+    }
+}
+
+local void init_linkedlist(ll)
+    linkedlist_data* ll;
+{
+    ll->first_block = ll->last_block = NULL;
+}
+
+local void free_linkedlist(ll)
+    linkedlist_data* ll;
+{
+    free_datablock(ll->first_block);
+    ll->first_block = ll->last_block = NULL;
+}
+
+
+local int add_data_in_datablock(ll,buf,len)
+    linkedlist_data* ll;
+    const void* buf;
+    uLong len;
+{
+    linkedlist_datablock_internal* ldi;
+    const unsigned char* from_copy;
+
+    if (ll==NULL)
+        return ZIP_INTERNALERROR;
+
+    if (ll->last_block == NULL)
+    {
+        ll->first_block = ll->last_block = allocate_new_datablock();
+        if (ll->first_block == NULL)
+            return ZIP_INTERNALERROR;
+    }
+
+    ldi = ll->last_block;
+    from_copy = (unsigned char*)buf;
+
+    while (len>0)
+    {
+        uInt copy_this;
+        uInt i;
+        unsigned char* to_copy;
+
+        if (ldi->avail_in_this_block==0)
+        {
+            ldi->next_datablock = allocate_new_datablock();
+            if (ldi->next_datablock == NULL)
+                return ZIP_INTERNALERROR;
+            ldi = ldi->next_datablock ;
+            ll->last_block = ldi;
+        }
+
+        if (ldi->avail_in_this_block < len)
+            copy_this = (uInt)ldi->avail_in_this_block;
+        else
+            copy_this = (uInt)len;
+
+        to_copy = &(ldi->data[ldi->filled_in_this_block]);
+
+        for (i=0;i<copy_this;i++)
+            *(to_copy+i)=*(from_copy+i);
+
+        ldi->filled_in_this_block += copy_this;
+        ldi->avail_in_this_block -= copy_this;
+        from_copy += copy_this ;
+        len -= copy_this;
+    }
+    return ZIP_OK;
+}
+
+
+
+/****************************************************************************/
+
+/* #ifndef NO_ADDFILEINEXISTINGZIP */
+/* ===========================================================================
+   Inputs a long in LSB order to the given file
+   nbByte == 1, 2 or 4 (byte, short or long)
+*/
+
+local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def,
+                                voidpf filestream, uLong x, int nbByte));
+local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    uLong x;
+    int nbByte;
+{
+    unsigned char buf[4];
+    int n;
+    for (n = 0; n < nbByte; n++)
+    {
+        buf[n] = (unsigned char)(x & 0xff);
+        x >>= 8;
+    }
+    if (x != 0)
+      {     /* data overflow - hack for ZIP64 (X Roche) */
+      for (n = 0; n < nbByte; n++)
+        {
+          buf[n] = 0xff;
+        }
+      }
+
+    if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
+        return ZIP_ERRNO;
+    else
+        return ZIP_OK;
+}
+
+local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte));
+local void ziplocal_putValue_inmemory (dest, x, nbByte)
+    void* dest;
+    uLong x;
+    int nbByte;
+{
+    unsigned char* buf=(unsigned char*)dest;
+    int n;
+    for (n = 0; n < nbByte; n++) {
+        buf[n] = (unsigned char)(x & 0xff);
+        x >>= 8;
+    }
+
+    if (x != 0)
+    {     /* data overflow - hack for ZIP64 */
+       for (n = 0; n < nbByte; n++)
+       {
+          buf[n] = 0xff;
+       }
+    }
+}
+
+/****************************************************************************/
+
+
+local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
+    const tm_zip* ptm;
+    uLong dosDate;
+{
+    uLong year = (uLong)ptm->tm_year;
+    if (year>1980)
+        year-=1980;
+    else if (year>80)
+        year-=80;
+    return
+      (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
+        ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
+}
+
+
+/****************************************************************************/
+
+local int ziplocal_getByte OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream,
+    int *pi));
+
+local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    int *pi;
+{
+    unsigned char c;
+    int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
+    if (err==1)
+    {
+        *pi = (int)c;
+        return ZIP_OK;
+    }
+    else
+    {
+        if (ZERROR(*pzlib_filefunc_def,filestream))
+            return ZIP_ERRNO;
+        else
+            return ZIP_EOF;
+    }
+}
+
+
+/* ===========================================================================
+   Reads a long in LSB order from the given gz_stream. Sets
+*/
+local int ziplocal_getShort OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    uLong *pX;
+{
+    uLong x ;
+    int i;
+    int err;
+
+    err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==ZIP_OK)
+        err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<8;
+
+    if (err==ZIP_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+local int ziplocal_getLong OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream,
+    uLong *pX));
+
+local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+    uLong *pX;
+{
+    uLong x ;
+    int i;
+    int err;
+
+    err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x = (uLong)i;
+
+    if (err==ZIP_OK)
+        err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<8;
+
+    if (err==ZIP_OK)
+        err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<16;
+
+    if (err==ZIP_OK)
+        err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
+    x += ((uLong)i)<<24;
+
+    if (err==ZIP_OK)
+        *pX = x;
+    else
+        *pX = 0;
+    return err;
+}
+
+#ifndef BUFREADCOMMENT
+#define BUFREADCOMMENT (0x400)
+#endif
+/*
+  Locate the Central directory of a zipfile (at the end, just before
+    the global comment)
+*/
+local uLong ziplocal_SearchCentralDir OF((
+    const zlib_filefunc_def* pzlib_filefunc_def,
+    voidpf filestream));
+
+local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
+    const zlib_filefunc_def* pzlib_filefunc_def;
+    voidpf filestream;
+{
+    unsigned char* buf;
+    uLong uSizeFile;
+    uLong uBackRead;
+    uLong uMaxBack=0xffff; /* maximum size of global comment */
+    uLong uPosFound=0;
+
+    if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+        return 0;
+
+
+    uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
+
+    if (uMaxBack>uSizeFile)
+        uMaxBack = uSizeFile;
+
+    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+    if (buf==NULL)
+        return 0;
+
+    uBackRead = 4;
+    while (uBackRead<uMaxBack)
+    {
+        uLong uReadSize,uReadPos ;
+        int i;
+        if (uBackRead+BUFREADCOMMENT>uMaxBack)
+            uBackRead = uMaxBack;
+        else
+            uBackRead+=BUFREADCOMMENT;
+        uReadPos = uSizeFile-uBackRead ;
+
+        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+                     (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
+        if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            break;
+
+        if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+            break;
+
+        for (i=(int)uReadSize-3; (i--)>0;)
+            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
+            {
+                uPosFound = uReadPos+i;
+                break;
+            }
+
+        if (uPosFound!=0)
+            break;
+    }
+    TRYFREE(buf);
+    return uPosFound;
+}
+/*#endif*/ /* !NO_ADDFILEINEXISTINGZIP*/
+
+/************************************************************/
+extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def)
+    const char *pathname;
+    int append;
+    zipcharpc* globalcomment;
+    zlib_filefunc_def* pzlib_filefunc_def;
+{
+    zip_internal ziinit;
+    zip_internal* zi;
+    int err=ZIP_OK;
+
+
+    if (pzlib_filefunc_def==NULL)
+        fill_fopen_filefunc(&ziinit.z_filefunc);
+    else
+        ziinit.z_filefunc = *pzlib_filefunc_def;
+
+    ziinit.filestream = (*(ziinit.z_filefunc.zopen_file))
+                 (ziinit.z_filefunc.opaque,
+                  pathname,
+                  (append == APPEND_STATUS_CREATE) ?
+                  (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) :
+                    (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING));
+
+    if (ziinit.filestream == NULL)
+        return NULL;
+    ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream);
+    ziinit.in_opened_file_inzip = 0;
+    ziinit.ci.stream_initialised = 0;
+    ziinit.number_entry = 0;
+    ziinit.add_position_when_writting_offset = 0;
+    init_linkedlist(&(ziinit.central_dir));
+
+
+    zi = (zip_internal*)ALLOC(sizeof(zip_internal));
+    if (zi==NULL)
+    {
+        ZCLOSE(ziinit.z_filefunc,ziinit.filestream);
+        return NULL;
+    }
+
+    /* now we add file in a zipfile */
+#    ifndef NO_ADDFILEINEXISTINGZIP
+    ziinit.globalcomment = NULL;
+    if (append == APPEND_STATUS_ADDINZIP)
+    {
+        uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+
+        uLong size_central_dir;     /* size of the central directory  */
+        uLong offset_central_dir;   /* offset of start of central directory */
+        uLong central_pos,uL;
+
+        uLong number_disk;          /* number of the current dist, used for
+                                    spaning ZIP, unsupported, always 0*/
+        uLong number_disk_with_CD;  /* number the the disk with central dir, used
+                                    for spaning ZIP, unsupported, always 0*/
+        uLong number_entry;
+        uLong number_entry_CD;      /* total number of entries in
+                                    the central dir
+                                    (same than number_entry on nospan) */
+        uLong size_comment;
+
+        central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream);
+        if (central_pos==0)
+            err=ZIP_ERRNO;
+
+        if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
+                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            err=ZIP_ERRNO;
+
+        /* the signature, already checked */
+        if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        /* number of this disk */
+        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        /* number of the disk with the start of the central directory */
+        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        /* total number of entries in the central dir on this disk */
+        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        /* total number of entries in the central dir */
+        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        if ((number_entry_CD!=number_entry) ||
+            (number_disk_with_CD!=0) ||
+            (number_disk!=0))
+            err=ZIP_BADZIPFILE;
+
+        /* size of the central directory */
+        if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        /* offset of start of central directory with respect to the
+            starting disk number */
+        if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        /* zipfile global comment length */
+        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK)
+            err=ZIP_ERRNO;
+
+        if ((central_pos<offset_central_dir+size_central_dir) &&
+            (err==ZIP_OK))
+            err=ZIP_BADZIPFILE;
+
+        if (err!=ZIP_OK)
+        {
+            ZCLOSE(ziinit.z_filefunc, ziinit.filestream);
+            return NULL;
+        }
+
+        if (size_comment>0)
+        {
+            ziinit.globalcomment = ALLOC(size_comment+1);
+            if (ziinit.globalcomment)
+            {
+               size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment);
+               ziinit.globalcomment[size_comment]=0;
+            }
+        }
+
+        byte_before_the_zipfile = central_pos -
+                                (offset_central_dir+size_central_dir);
+        ziinit.add_position_when_writting_offset = byte_before_the_zipfile;
+
+        {
+            uLong size_central_dir_to_read = size_central_dir;
+            size_t buf_size = SIZEDATA_INDATABLOCK;
+            void* buf_read = (void*)ALLOC(buf_size);
+            if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
+                  offset_central_dir + byte_before_the_zipfile,
+                  ZLIB_FILEFUNC_SEEK_SET) != 0)
+                  err=ZIP_ERRNO;
+
+            while ((size_central_dir_to_read>0) && (err==ZIP_OK))
+            {
+                uLong read_this = SIZEDATA_INDATABLOCK;
+                if (read_this > size_central_dir_to_read)
+                    read_this = size_central_dir_to_read;
+                if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this)
+                    err=ZIP_ERRNO;
+
+                if (err==ZIP_OK)
+                    err = add_data_in_datablock(&ziinit.central_dir,buf_read,
+                                                (uLong)read_this);
+                size_central_dir_to_read-=read_this;
+            }
+            TRYFREE(buf_read);
+        }
+        ziinit.begin_pos = byte_before_the_zipfile;
+        ziinit.number_entry = number_entry_CD;
+
+        if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
+                  offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            err=ZIP_ERRNO;
+    }
+
+    if (globalcomment)
+    {
+      *globalcomment = ziinit.globalcomment;
+    }
+#    endif /* !NO_ADDFILEINEXISTINGZIP*/
+
+    if (err != ZIP_OK)
+    {
+#    ifndef NO_ADDFILEINEXISTINGZIP
+        TRYFREE(ziinit.globalcomment);
+#    endif /* !NO_ADDFILEINEXISTINGZIP*/
+        TRYFREE(zi);
+        return NULL;
+    }
+    else
+    {
+        *zi = ziinit;
+        return (zipFile)zi;
+    }
+}
+
+extern zipFile ZEXPORT zipOpen (pathname, append)
+    const char *pathname;
+    int append;
+{
+    return zipOpen2(pathname,append,NULL,NULL);
+}
+
+extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
+                                         extrafield_local, size_extrafield_local,
+                                         extrafield_global, size_extrafield_global,
+                                         comment, method, level, raw,
+                                         windowBits, memLevel, strategy,
+                                         password, crcForCrypting)
+    zipFile file;
+    const char* filename;
+    const zip_fileinfo* zipfi;
+    const void* extrafield_local;
+    uInt size_extrafield_local;
+    const void* extrafield_global;
+    uInt size_extrafield_global;
+    const char* comment;
+    int method;
+    int level;
+    int raw;
+    int windowBits;
+    int memLevel;
+    int strategy;
+    const char* password;
+    uLong crcForCrypting;
+{
+    zip_internal* zi;
+    uInt size_filename;
+    uInt size_comment;
+    uInt i;
+    int err = ZIP_OK;
+
+#    ifdef NOCRYPT
+    if (password != NULL)
+        return ZIP_PARAMERROR;
+#    endif
+
+    if (file == NULL)
+        return ZIP_PARAMERROR;
+    if ((method!=0) && (method!=Z_DEFLATED))
+        return ZIP_PARAMERROR;
+
+    zi = (zip_internal*)file;
+
+    if (zi->in_opened_file_inzip == 1)
+    {
+        err = zipCloseFileInZip (file);
+        if (err != ZIP_OK)
+            return err;
+    }
+
+
+    if (filename==NULL)
+        filename="-";
+
+    if (comment==NULL)
+        size_comment = 0;
+    else
+        size_comment = (uInt)strlen(comment);
+
+    size_filename = (uInt)strlen(filename);
+
+    if (zipfi == NULL)
+        zi->ci.dosDate = 0;
+    else
+    {
+        if (zipfi->dosDate != 0)
+            zi->ci.dosDate = zipfi->dosDate;
+        else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate);
+    }
+
+    zi->ci.flag = 0;
+    if ((level==8) || (level==9))
+      zi->ci.flag |= 2;
+    if ((level==2))
+      zi->ci.flag |= 4;
+    if ((level==1))
+      zi->ci.flag |= 6;
+    if (password != NULL)
+      zi->ci.flag |= 1;
+
+    zi->ci.crc32 = 0;
+    zi->ci.method = method;
+    zi->ci.encrypt = 0;
+    zi->ci.stream_initialised = 0;
+    zi->ci.pos_in_buffered_data = 0;
+    zi->ci.raw = raw;
+    zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ;
+    zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +
+                                      size_extrafield_global + size_comment;
+    zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);
+
+    ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);
+    /* version info */
+    ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4);
+    ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/
+    ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/
+    ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/
+    ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/
+
+    if (zipfi==NULL)
+        ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);
+    else
+        ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);
+
+    if (zipfi==NULL)
+        ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
+    else
+        ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);
+
+    ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4);
+
+    for (i=0;i<size_filename;i++)
+        *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
+
+    for (i=0;i<size_extrafield_global;i++)
+        *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =
+              *(((const char*)extrafield_global)+i);
+
+    for (i=0;i<size_comment;i++)
+        *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+
+              size_extrafield_global+i) = *(comment+i);
+    if (zi->ci.central_header == NULL)
+        return ZIP_INTERNALERROR;
+
+    /* write the local header */
+    err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4);
+
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2);
+
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);
+
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
+
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */
+
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2);
+
+    if (err==ZIP_OK)
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2);
+
+    if ((err==ZIP_OK) && (size_filename>0))
+        if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename)
+                err = ZIP_ERRNO;
+
+    if ((err==ZIP_OK) && (size_extrafield_local>0))
+        if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local)
+                                                                           !=size_extrafield_local)
+                err = ZIP_ERRNO;
+
+    zi->ci.stream.avail_in = (uInt)0;
+    zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
+    zi->ci.stream.next_out = zi->ci.buffered_data;
+    zi->ci.stream.total_in = 0;
+    zi->ci.stream.total_out = 0;
+
+    if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
+    {
+        zi->ci.stream.zalloc = (alloc_func)0;
+        zi->ci.stream.zfree = (free_func)0;
+        zi->ci.stream.opaque = (voidpf)0;
+
+        if (windowBits>0)
+            windowBits = -windowBits;
+
+        err = deflateInit2(&zi->ci.stream, level,
+               Z_DEFLATED, windowBits, memLevel, strategy);
+
+        if (err==Z_OK)
+            zi->ci.stream_initialised = 1;
+    }
+#    ifndef NOCRYPT
+    zi->ci.crypt_header_size = 0;
+    if ((err==Z_OK) && (password != NULL))
+    {
+        unsigned char bufHead[RAND_HEAD_LEN];
+        unsigned int sizeHead;
+        zi->ci.encrypt = 1;
+        zi->ci.pcrc_32_tab = get_crc_table();
+        /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
+
+        sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting);
+        zi->ci.crypt_header_size = sizeHead;
+
+        if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead)
+                err = ZIP_ERRNO;
+    }
+#    endif
+
+    if (err==Z_OK)
+        zi->in_opened_file_inzip = 1;
+    return err;
+}
+
+extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
+                                        extrafield_local, size_extrafield_local,
+                                        extrafield_global, size_extrafield_global,
+                                        comment, method, level, raw)
+    zipFile file;
+    const char* filename;
+    const zip_fileinfo* zipfi;
+    const void* extrafield_local;
+    uInt size_extrafield_local;
+    const void* extrafield_global;
+    uInt size_extrafield_global;
+    const char* comment;
+    int method;
+    int level;
+    int raw;
+{
+    return zipOpenNewFileInZip3 (file, filename, zipfi,
+                                 extrafield_local, size_extrafield_local,
+                                 extrafield_global, size_extrafield_global,
+                                 comment, method, level, raw,
+                                 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
+                                 NULL, 0);
+}
+
+extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
+                                        extrafield_local, size_extrafield_local,
+                                        extrafield_global, size_extrafield_global,
+                                        comment, method, level)
+    zipFile file;
+    const char* filename;
+    const zip_fileinfo* zipfi;
+    const void* extrafield_local;
+    uInt size_extrafield_local;
+    const void* extrafield_global;
+    uInt size_extrafield_global;
+    const char* comment;
+    int method;
+    int level;
+{
+    return zipOpenNewFileInZip2 (file, filename, zipfi,
+                                 extrafield_local, size_extrafield_local,
+                                 extrafield_global, size_extrafield_global,
+                                 comment, method, level, 0);
+}
+
+local int zipFlushWriteBuffer(zi)
+  zip_internal* zi;
+{
+    int err=ZIP_OK;
+
+    if (zi->ci.encrypt != 0)
+    {
+#ifndef NOCRYPT
+        uInt i;
+        int t;
+        for (i=0;i<zi->ci.pos_in_buffered_data;i++)
+            zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab,
+                                       zi->ci.buffered_data[i],t);
+#endif
+    }
+    if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data)
+                                                                    !=zi->ci.pos_in_buffered_data)
+      err = ZIP_ERRNO;
+    zi->ci.pos_in_buffered_data = 0;
+    return err;
+}
+
+extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
+    zipFile file;
+    const void* buf;
+    unsigned len;
+{
+    zip_internal* zi;
+    int err=ZIP_OK;
+
+    if (file == NULL)
+        return ZIP_PARAMERROR;
+    zi = (zip_internal*)file;
+
+    if (zi->in_opened_file_inzip == 0)
+        return ZIP_PARAMERROR;
+
+    zi->ci.stream.next_in = (void*)buf;
+    zi->ci.stream.avail_in = len;
+    zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
+
+    while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
+    {
+        if (zi->ci.stream.avail_out == 0)
+        {
+            if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
+                err = ZIP_ERRNO;
+            zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
+            zi->ci.stream.next_out = zi->ci.buffered_data;
+        }
+
+
+        if(err != ZIP_OK)
+            break;
+
+        if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
+        {
+            uLong uTotalOutBefore = zi->ci.stream.total_out;
+            err=deflate(&zi->ci.stream,  Z_NO_FLUSH);
+            zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
+
+        }
+        else
+        {
+            uInt copy_this,i;
+            if (zi->ci.stream.avail_in < zi->ci.stream.avail_out)
+                copy_this = zi->ci.stream.avail_in;
+            else
+                copy_this = zi->ci.stream.avail_out;
+            for (i=0;i<copy_this;i++)
+                *(((char*)zi->ci.stream.next_out)+i) =
+                    *(((const char*)zi->ci.stream.next_in)+i);
+            {
+                zi->ci.stream.avail_in -= copy_this;
+                zi->ci.stream.avail_out-= copy_this;
+                zi->ci.stream.next_in+= copy_this;
+                zi->ci.stream.next_out+= copy_this;
+                zi->ci.stream.total_in+= copy_this;
+                zi->ci.stream.total_out+= copy_this;
+                zi->ci.pos_in_buffered_data += copy_this;
+            }
+        }
+    }
+
+    return err;
+}
+
+extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
+    zipFile file;
+    uLong uncompressed_size;
+    uLong crc32;
+{
+    zip_internal* zi;
+    uLong compressed_size;
+    int err=ZIP_OK;
+
+    if (file == NULL)
+        return ZIP_PARAMERROR;
+    zi = (zip_internal*)file;
+
+    if (zi->in_opened_file_inzip == 0)
+        return ZIP_PARAMERROR;
+    zi->ci.stream.avail_in = 0;
+
+    if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
+        while (err==ZIP_OK)
+    {
+        uLong uTotalOutBefore;
+        if (zi->ci.stream.avail_out == 0)
+        {
+            if (zipFlushWriteBuffer(zi) == ZIP_ERRNO)
+                err = ZIP_ERRNO;
+            zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
+            zi->ci.stream.next_out = zi->ci.buffered_data;
+        }
+        uTotalOutBefore = zi->ci.stream.total_out;
+        err=deflate(&zi->ci.stream,  Z_FINISH);
+        zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
+    }
+
+    if (err==Z_STREAM_END)
+        err=ZIP_OK; /* this is normal */
+
+    if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK))
+        if (zipFlushWriteBuffer(zi)==ZIP_ERRNO)
+            err = ZIP_ERRNO;
+
+    if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
+    {
+        err=deflateEnd(&zi->ci.stream);
+        zi->ci.stream_initialised = 0;
+    }
+
+    if (!zi->ci.raw)
+    {
+        crc32 = (uLong)zi->ci.crc32;
+        uncompressed_size = (uLong)zi->ci.stream.total_in;
+    }
+    compressed_size = (uLong)zi->ci.stream.total_out;
+#    ifndef NOCRYPT
+    compressed_size += zi->ci.crypt_header_size;
+#    endif
+
+    ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/
+    ziplocal_putValue_inmemory(zi->ci.central_header+20,
+                                compressed_size,4); /*compr size*/
+    if (zi->ci.stream.data_type == Z_ASCII)
+        ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);
+    ziplocal_putValue_inmemory(zi->ci.central_header+24,
+                                uncompressed_size,4); /*uncompr size*/
+
+    if (err==ZIP_OK)
+        err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header,
+                                       (uLong)zi->ci.size_centralheader);
+    free(zi->ci.central_header);
+
+    if (err==ZIP_OK)
+    {
+        long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
+        if (ZSEEK(zi->z_filefunc,zi->filestream,
+                  zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            err = ZIP_ERRNO;
+
+        if (err==ZIP_OK)
+            err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
+
+        if (err==ZIP_OK) /* compressed size, unknown */
+            err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);
+
+        if (err==ZIP_OK) /* uncompressed size, unknown */
+            err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4);
+
+        if (ZSEEK(zi->z_filefunc,zi->filestream,
+                  cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0)
+            err = ZIP_ERRNO;
+    }
+
+    zi->number_entry ++;
+    zi->in_opened_file_inzip = 0;
+
+    return err;
+}
+
+extern int ZEXPORT zipCloseFileInZip (file)
+    zipFile file;
+{
+    return zipCloseFileInZipRaw (file,0,0);
+}
+
+extern int ZEXPORT zipClose (file, global_comment)
+    zipFile file;
+    const char* global_comment;
+{
+    zip_internal* zi;
+    int err = 0;
+    uLong size_centraldir = 0;
+    uLong centraldir_pos_inzip;
+    uInt size_global_comment;
+    if (file == NULL)
+        return ZIP_PARAMERROR;
+    zi = (zip_internal*)file;
+
+    if (zi->in_opened_file_inzip == 1)
+    {
+        err = zipCloseFileInZip (file);
+    }
+
+#ifndef NO_ADDFILEINEXISTINGZIP
+    if (global_comment==NULL)
+        global_comment = zi->globalcomment;
+#endif
+    if (global_comment==NULL)
+        size_global_comment = 0;
+    else
+        size_global_comment = (uInt)strlen(global_comment);
+
+    centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
+    if (err==ZIP_OK)
+    {
+        linkedlist_datablock_internal* ldi = zi->central_dir.first_block ;
+        while (ldi!=NULL)
+        {
+            if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
+                if (ZWRITE(zi->z_filefunc,zi->filestream,
+                           ldi->data,ldi->filled_in_this_block)
+                              !=ldi->filled_in_this_block )
+                    err = ZIP_ERRNO;
+
+            size_centraldir += ldi->filled_in_this_block;
+            ldi = ldi->next_datablock;
+        }
+    }
+    free_datablock(zi->central_dir.first_block);
+
+    if (err==ZIP_OK) /* Magic End */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);
+
+    if (err==ZIP_OK) /* number of this disk */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
+
+    if (err==ZIP_OK) /* number of the disk with the start of the central directory */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);
+
+    if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
+
+    if (err==ZIP_OK) /* total number of entries in the central dir */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
+
+    if (err==ZIP_OK) /* size of the central directory */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);
+
+    if (err==ZIP_OK) /* offset of start of central directory with respect to the
+                            starting disk number */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,
+                                (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);
+
+    if (err==ZIP_OK) /* zipfile comment length */
+        err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2);
+
+    if ((err==ZIP_OK) && (size_global_comment>0))
+        if (ZWRITE(zi->z_filefunc,zi->filestream,
+                   global_comment,size_global_comment) != size_global_comment)
+                err = ZIP_ERRNO;
+
+    if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0)
+        if (err == ZIP_OK)
+            err = ZIP_ERRNO;
+
+#ifndef NO_ADDFILEINEXISTINGZIP
+    TRYFREE(zi->globalcomment);
+#endif
+    TRYFREE(zi);
+
+    return err;
+}
diff --git a/src/drivers/minizip/zip.h b/src/drivers/minizip/zip.h
new file mode 100644
index 0000000..acacce8
--- /dev/null
+++ b/src/drivers/minizip/zip.h
@@ -0,0 +1,235 @@
+/* zip.h -- IO for compress .zip files using zlib
+   Version 1.01e, February 12th, 2005
+
+   Copyright (C) 1998-2005 Gilles Vollant
+
+   This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
+     WinZip, InfoZip tools and compatible.
+   Multi volume ZipFile (span) are not supported.
+   Encryption compatible with pkzip 2.04g only supported
+   Old compressions used by old PKZip 1.x are not supported
+
+  For uncompress .zip file, look at unzip.h
+
+
+   I WAIT FEEDBACK at mail info at winimage.com
+   Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
+
+   Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+
+*/
+
+/* for more info about .ZIP format, see
+      http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
+      http://www.info-zip.org/pub/infozip/doc/
+   PkWare has also a specification at :
+      ftp://ftp.pkware.com/probdesc.zip
+*/
+
+#ifndef _zip_H
+#define _zip_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _ZLIB_H
+#include "zlib.h"
+#endif
+
+#ifndef _ZLIBIOAPI_H
+#include "ioapi.h"
+#endif
+
+#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
+/* like the STRICT of WIN32, we define a pointer that cannot be converted
+    from (void*) without cast */
+typedef struct TagzipFile__ { int unused; } zipFile__;
+typedef zipFile__ *zipFile;
+#else
+typedef voidp zipFile;
+#endif
+
+#define ZIP_OK                          (0)
+#define ZIP_EOF                         (0)
+#define ZIP_ERRNO                       (Z_ERRNO)
+#define ZIP_PARAMERROR                  (-102)
+#define ZIP_BADZIPFILE                  (-103)
+#define ZIP_INTERNALERROR               (-104)
+
+#ifndef DEF_MEM_LEVEL
+#  if MAX_MEM_LEVEL >= 8
+#    define DEF_MEM_LEVEL 8
+#  else
+#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL
+#  endif
+#endif
+/* default memLevel */
+
+/* tm_zip contain date/time info */
+typedef struct tm_zip_s
+{
+    uInt tm_sec;            /* seconds after the minute - [0,59] */
+    uInt tm_min;            /* minutes after the hour - [0,59] */
+    uInt tm_hour;           /* hours since midnight - [0,23] */
+    uInt tm_mday;           /* day of the month - [1,31] */
+    uInt tm_mon;            /* months since January - [0,11] */
+    uInt tm_year;           /* years - [1980..2044] */
+} tm_zip;
+
+typedef struct
+{
+    tm_zip      tmz_date;       /* date in understandable format           */
+    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */
+/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */
+
+    uLong       internal_fa;    /* internal file attributes        2 bytes */
+    uLong       external_fa;    /* external file attributes        4 bytes */
+} zip_fileinfo;
+
+typedef const char* zipcharpc;
+
+
+#define APPEND_STATUS_CREATE        (0)
+#define APPEND_STATUS_CREATEAFTER   (1)
+#define APPEND_STATUS_ADDINZIP      (2)
+
+extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
+/*
+  Create a zipfile.
+     pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
+       an Unix computer "zlib/zlib113.zip".
+     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
+       will be created at the end of the file.
+         (useful if the file contain a self extractor code)
+     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
+       add files in existing zip (be sure you don't add file that doesn't exist)
+     If the zipfile cannot be opened, the return value is NULL.
+     Else, the return value is a zipFile Handle, usable with other function
+       of this zip package.
+*/
+
+/* Note : there is no delete function into a zipfile.
+   If you want delete file into a zipfile, you must open a zipfile, and create another
+   Of couse, you can use RAW reading and writing to copy the file you did not want delte
+*/
+
+extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
+                                   int append,
+                                   zipcharpc* globalcomment,
+                                   zlib_filefunc_def* pzlib_filefunc_def));
+
+extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
+                       const char* filename,
+                       const zip_fileinfo* zipfi,
+                       const void* extrafield_local,
+                       uInt size_extrafield_local,
+                       const void* extrafield_global,
+                       uInt size_extrafield_global,
+                       const char* comment,
+                       int method,
+                       int level));
+/*
+  Open a file in the ZIP for writing.
+  filename : the filename in zip (if NULL, '-' without quote will be used
+  *zipfi contain supplemental information
+  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
+    contains the extrafield data the the local header
+  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
+    contains the extrafield data the the local header
+  if comment != NULL, comment contain the comment string
+  method contain the compression method (0 for store, Z_DEFLATED for deflate)
+  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
+*/
+
+
+extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
+                                            const char* filename,
+                                            const zip_fileinfo* zipfi,
+                                            const void* extrafield_local,
+                                            uInt size_extrafield_local,
+                                            const void* extrafield_global,
+                                            uInt size_extrafield_global,
+                                            const char* comment,
+                                            int method,
+                                            int level,
+                                            int raw));
+
+/*
+  Same than zipOpenNewFileInZip, except if raw=1, we write raw file
+ */
+
+extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
+                                            const char* filename,
+                                            const zip_fileinfo* zipfi,
+                                            const void* extrafield_local,
+                                            uInt size_extrafield_local,
+                                            const void* extrafield_global,
+                                            uInt size_extrafield_global,
+                                            const char* comment,
+                                            int method,
+                                            int level,
+                                            int raw,
+                                            int windowBits,
+                                            int memLevel,
+                                            int strategy,
+                                            const char* password,
+                                            uLong crcForCtypting));
+
+/*
+  Same than zipOpenNewFileInZip2, except
+    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
+    password : crypting password (NULL for no crypting)
+    crcForCtypting : crc of file to compress (needed for crypting)
+ */
+
+
+extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
+                       const void* buf,
+                       unsigned len));
+/*
+  Write data in the zipfile
+*/
+
+extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
+/*
+  Close the current file in the zipfile
+*/
+
+extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
+                                            uLong uncompressed_size,
+                                            uLong crc32));
+/*
+  Close the current file in the zipfile, for fiel opened with
+    parameter raw=1 in zipOpenNewFileInZip2
+  uncompressed_size and crc32 are value for the uncompressed size
+*/
+
+extern int ZEXPORT zipClose OF((zipFile file,
+                const char* global_comment));
+/*
+  Close the zipfile
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _zip_H */
diff --git a/src/libMagWrapper/MagPlus.cc b/src/libMagWrapper/MagPlus.cc
new file mode 100644
index 0000000..240920b
--- /dev/null
+++ b/src/libMagWrapper/MagPlus.cc
@@ -0,0 +1,1601 @@
+#include "MagPlus.h"
+#include <iostream>
+
+#include <MvRootSceneNodeWrapper.h>
+#include <FortranSceneNodeWrapper.h>
+#include <FortranViewNodeWrapper.h>
+#include <CoastlinesWrapper.h>
+#include <AxisWrapper.h>
+#include <VisualAction.h>
+#include "MetaDataWrapper.h"
+
+#if MAGICS_GRIB
+#include <GribDecoderWrapper.h>
+#include <GribLoopWrapper.h>
+#endif
+
+#include <GeoPointsDecoderWrapper.h>
+#include <NetcdfDecoderWrapper.h>
+#include <BinningObjectWrapper.h>
+
+#if MAGICS_ODB
+#include <OdaGeoDecoderWrapper.h>
+#include <OdaXYDecoderWrapper.h>
+#endif
+
+#if MAGICS_BUFR
+#include <ObsDecoderWrapper.h>
+#include <ObsPlottingWrapper.h>
+#endif
+
+#include <ImportPlotWrapper.h>
+#include <ImportActionWrapper.h>
+#include <InputDataWrapper.h>
+#include <TableDecoderWrapper.h>
+
+#include <ContourWrapper.h>
+
+#include <TextVisitor.h>
+#include <TextVisitorWrapper.h>
+#include <LegendVisitorWrapper.h>
+
+#include <MultiVisdef.h>
+#include <SymbolPlottingWrapper.h>
+#include <GraphPlottingWrapper.h>
+#include <WindWrapper.h>
+
+#include <UserPoint.h>
+#include "MagicsEvent.h"
+
+
+#include <PostScriptDriverWrapper.h>
+
+#ifdef MAGICS_CAIRO
+#include <CairoDriverWrapper.h>
+#endif
+
+#include <SVGDriverWrapper.h>
+#include <KMLDriverWrapper.h>
+
+#if MAGICS_QT
+#include <QtDriver.h>
+#endif
+
+
+template <class T>
+void replace(magics::MagRequest& request, const string& name, T from, T to)
+{
+	if (request.countValues(name.c_str()) == 0 ) {
+		request(name) = to;
+		return;
+	}
+	T val = request(name);
+	if (val == from) 
+		request(name) = to;
+	
+}
+
+void replace_string(magics::MagRequest& request, const string& name, const string& from, const string& to)
+{
+	if (request.countValues(name) == 0 ) {
+		request(name) = to;
+		return;
+	}
+	string val =  request(name);
+	if (val == from) 
+		request(name) = to;
+	
+}
+
+template <class T>
+void replace(magics::MagRequest& request, const string& name, T from, const string& newname, T to)
+{
+	if (request.countValues(name) == 0 ) {
+		request(newname.c_str()) = to;
+		return;
+	}
+	T val = request(name);
+	if (val == from) 
+		request(newname) = to;
+	else 
+		request(newname) = val;
+}
+
+string get(magics::MagRequest& request, const string& param, const string& val)
+{
+	
+	string v = request(param);
+	
+	return ( !v.empty() ) ? v : val; 
+} 
+
+using namespace std;
+using namespace magics;
+
+
+
+
+map<string,  MagPlus::ObjectCreator > MagPlus::sceneCreators_;
+map<string,  MagPlus::ObjectCreator > MagPlus::driverCreators_;
+map<string,  MagPlus::ObjectCreator > MagPlus::sceneUpdators_;
+
+
+
+
+MagPlus::MagPlus() : root_(0), superpage_(-1), geographical_(true), mode_(interactif), currentMulti_(0)
+{
+#if MAGICS_QT
+	qtDriver_ = 0;
+#endif
+	if ( sceneUpdators_.empty()) {
+		sceneUpdators_["PAGE"] = &MagPlus::page_update;
+	}
+ 	if ( sceneCreators_.empty()) { 		
+ 		sceneCreators_["PAGE"] = &MagPlus::page;
+ 		sceneCreators_["NEWPAGE"] = &MagPlus::newpage;
+ 		sceneCreators_["MCOAST"] = &MagPlus::coastlines;
+ 		sceneCreators_["PCOAST"] = &MagPlus::oldcoastlines;
+
+
+ 		sceneCreators_["PAXIS"] = &MagPlus::axis;
+ 		sceneCreators_["CARTESIANVIEW"] = &MagPlus::cartesian;
+ 		sceneCreators_["PGRIB"] = &MagPlus::gribloop;
+        sceneCreators_["GRIBLOOP"] = &MagPlus::gribloop;
+        sceneCreators_["GEOPOINTS"] = &MagPlus::geopoints;
+ 		sceneCreators_["NETCDF_GEOPOINTS"] = &MagPlus::geonetcdf;
+        sceneCreators_["NETCDF_GEOVECTORS"] = &MagPlus::geonetcdf;
+        sceneCreators_["NETCDF_GEOMATRIX"] = &MagPlus::geonetcdf;
+        sceneCreators_["NETCDF_GEO_POINTS"] = &MagPlus::geonetcdf;
+        sceneCreators_["NETCDF_GEO_VECTORS"] = &MagPlus::geonetcdf;
+        sceneCreators_["NETCDF_GEO_MATRIX"] = &MagPlus::geonetcdf;
+        sceneCreators_["NETCDF_POINTS"] = &MagPlus::xynetcdf;
+        sceneCreators_["NETCDF_VECTORS"] = &MagPlus::xynetcdf;
+        sceneCreators_["NETCDF_MATRIX"] = &MagPlus::xynetcdf;
+        sceneCreators_["NETCDF_XY_POINTS"] = &MagPlus::xynetcdf;
+        sceneCreators_["NETCDF_XY_VECTORS"] = &MagPlus::xynetcdf;
+        sceneCreators_["NETCDF_XY_MATRIX"] = &MagPlus::xynetcdf;
+        sceneCreators_["BUFR"] = &MagPlus::bufr;
+        sceneCreators_["INPUT_XY_POINTS"] = &MagPlus::input;
+        sceneCreators_["INPUT_GEO_POINTS"] = &MagPlus::input;
+        sceneCreators_["INPUT_XY_VECTORS"] = &MagPlus::input;
+        sceneCreators_["INPUT_GEO_VECTORS"] = &MagPlus::input;
+        sceneCreators_["INPUT_XY_BINNING"] = &MagPlus::input;
+        sceneCreators_["INPUT_GEO_BINNING"] = &MagPlus::input;
+
+        sceneCreators_["TABLE_XY_POINTS"] = &MagPlus::table;
+        sceneCreators_["TABLE_GEO_POINTS"] = &MagPlus::table;
+        sceneCreators_["TABLE_XY_VECTORS"] = &MagPlus::table;
+        sceneCreators_["TABLE_GEO_VECTORS"] = &MagPlus::table;
+        sceneCreators_["TABLE_XY_BINNING"] = &MagPlus::table;
+        sceneCreators_["TABLE_GEO_BINNING"] = &MagPlus::table;
+
+#if MAGICS_ODB	
+	sceneCreators_["ODB_GEO_POINTS"] = &MagPlus::geoodb;
+	sceneCreators_["ODB_GEO_VECTORS"] = &MagPlus::geoodb;
+	sceneCreators_["ODB_XY_POINTS"] = &MagPlus::xyodb;
+	sceneCreators_["ODB_XY_VECTORS"] = &MagPlus::xyodb;
+	sceneCreators_["ODB_XY_BINNING"] = &MagPlus::xyodb;
+#endif
+	    sceneCreators_["VISDEFS"] = &MagPlus::visdef;
+	    sceneCreators_["MULTI"] = &MagPlus::multi;
+ 		sceneCreators_["PCONT"] = &MagPlus::contour;
+ 		sceneCreators_["MCONT"] = &MagPlus::contour;
+ 		sceneCreators_["POBS"] = &MagPlus::obs;
+ 		sceneCreators_["PSYMB"] = &MagPlus::symbol;
+ 		sceneCreators_["MSYMB"] = &MagPlus::symbol;
+        sceneCreators_["PSYMBPLUS"] = &MagPlus::symbol;
+        sceneCreators_["PWIND"] = &MagPlus::wind;
+        sceneCreators_["MWIND"] = &MagPlus::wind;
+        sceneCreators_["MGRAPH"] = &MagPlus::graph;
+ 		sceneCreators_["SUPERPAGE"] = &MagPlus::superpage;
+        sceneCreators_["PTEXT"] = &MagPlus::ptext;
+        sceneCreators_["MTEXT"] = &MagPlus::text;
+        sceneCreators_["MLEGEND"] = &MagPlus::legend;
+        sceneCreators_["DEVICE"] = &MagPlus::device;
+        sceneCreators_["PIMPORT"] = &MagPlus::import; 
+        sceneCreators_["PRASTER"] = &MagPlus::raster;
+        sceneCreators_["PRASTERLOOP"] = &MagPlus::rasterloop;
+        sceneCreators_["BINNING_OBJECT"] = &MagPlus::binning;
+ 	}
+    
+    if ( driverCreators_.empty())
+    {
+#if MAGICS_QT
+	driverCreators_["QTOUTPUT"] = &MagPlus::qtdriver;
+#endif
+ 	driverCreators_["PSOUTPUT"] = &MagPlus::psdriver;
+        driverCreators_["PNGOUTPUT"] = &MagPlus::pngdriver;
+        driverCreators_["KMLOUTPUT"] = &MagPlus::kmldriver;
+        driverCreators_["PDFOUTPUT"] = &MagPlus::pdfdriver;
+        driverCreators_["SVGOUTPUT"] = &MagPlus::svgdriver;
+        driverCreators_["EPSOUTPUT"] = &MagPlus::epsdriver;
+    }
+}
+
+bool MagPlus::superpage(magics::MagRequest& in)
+{
+	MagLog::dev()<< "superpage--->" << endl;
+	if ( root_) {
+		root_->newpage();
+
+		return false;
+	}
+	int superpage = in("SUPERPAGE_INDEX");
+	in("LAYOUT") = "positional";
+
+	if ( superpage == superpage_) return false;
+	superpage_ = superpage;
+	in("LAYOUT") = "positional";
+    
+    replace_string(in, "SUPER_PAGE_FRAME_COLOUR", "BLUE", "grey");
+  
+    in.print();
+    MvRootSceneNodeWrapper helper;
+	helper.set(in);
+		
+	root_ = helper.object();
+    
+	MagLog::dev()<< "<----superpage" << endl;
+	return false;
+}
+
+bool MagPlus::newpage(magics::MagRequest& in)
+{
+	cout << "NEW PAGE " << endl;
+
+	root_->newpage();
+
+	return false;
+}
+
+
+bool MagPlus::psdriver(magics::MagRequest& in)
+{
+	PostScriptDriverWrapper helper;
+	helper.set(in); 
+	  
+	drivers_.push_back(helper.object());  
+	mode_ = paper;
+	return false;
+}
+
+bool MagPlus::epsdriver(magics::MagRequest& in)
+{
+	PostScriptDriverWrapper helper;
+	helper.set(in); 
+	helper.me()->setEPS(true);
+	drivers_.push_back(helper.object());  
+	mode_ = paper;
+	return false;
+}
+
+bool MagPlus::pngdriver(magics::MagRequest&  in)
+{
+#ifdef MAGICS_CAIRO
+	CairoDriverWrapper helper;
+	helper.set(in); 
+	helper.me()->setPNG();
+	drivers_.push_back(helper.object());   
+	mode_ = paper;
+#endif
+	return false;
+}
+
+bool MagPlus::pdfdriver(magics::MagRequest& in)
+{
+#ifdef MAGICS_CAIRO
+	   CairoDriverWrapper helper;
+	   helper.set(in); 
+	   helper.me()->setPDF();
+       drivers_.push_back(helper.object());  
+       mode_ = paper;
+       
+#endif
+       return false;
+}
+
+#if MAGICS_QT
+void MagPlus::setQtScene(QGraphicsScene *scene)
+{
+	ParameterManager::set("output_qt_scene", scene);;
+}
+
+bool MagPlus::qtdriver(magics::MagRequest& /*in*/)
+{
+	if ( !qtDriver_)
+	{
+		//ParameterManager::set("ouptup_qt_scene", widget);
+		qtDriver_ = new magics::QtDriver();
+
+	}
+#ifndef MAG_NEXT
+	drivers_.push_back(qtDriver_);   
+#else
+	if ( mvMode_ == creation )
+		drivers_.push_back(qtDriver_);
+	qtDriver_->setUpdateMode(mvMode_ != creation);
+#endif
+	return false;
+}
+
+#endif
+
+bool MagPlus::svgdriver(magics::MagRequest& in)
+{
+	SVGDriverWrapper helper;
+	helper.set(in); 
+
+	drivers_.push_back(helper.object());   
+	mode_ = paper;
+	return false;
+}
+
+bool MagPlus::kmldriver(magics::MagRequest& in)
+{
+	KMLDriverWrapper helper;
+	in("KML_DESCRIPTION") = "Metview/Magics++";
+	helper.set(in); 
+	mode_ = paper;
+	drivers_.push_back(helper.object());   
+
+	return false;
+}
+
+bool MagPlus::page_update(magics::MagRequest& in)
+{
+	cout << "YOUPY! INEED TO UPDATE the PAGE!!!" << endl;
+	// get the Metview ID;
+	// reset the page!!!
+	int id = in("METVIEW_ID");
+	FortranViewNodeWrapper* page = pages_[id];
+	page->set(in);
+	FortranViewNodeAttributes* node= page->object();
+	page->object()->getReady();
+	MagLog::progress() << "new geometry" << *node << endl;
+	MagLog::broadcast();
+
+
+	return false;
+}
+
+bool MagPlus::page(magics::MagRequest& in)
+{
+	MagLog::dev()<< "page and subpage--->" << endl;
+	sceneCreators_["MLEGEND"] = &MagPlus::legend;
+
+
+	while ( !empty() ) pop();
+
+	replace_string(in, "PAGE_FRAME_COLOUR", "BLUE", "grey");
+	geographical_ = true;
+	in.print();
+	FortranSceneNodeWrapper scenehelper;
+	scenehelper.set(in);
+
+	setIconInfo(in, *scenehelper.object());
+	root_->insert(scenehelper.object());
+
+	push(scenehelper.object());
+	replace(in, "SUBPAGE_Y_LENGTH", 17.85, -1.); // reset to the default!
+	in("SUBPAGE_MAP_PREVIEW") = "on";
+
+	page_ = 0;
+
+	string def = get(in, "SUBPAGE_MAP_AREA_DEFINITION", "FULL");
+	if ( def == "FULL") {
+		in("SUBPAGE_MAP_AREA_DEFINITION") = in.countValues("SUBPAGE_LOWER_LEFT_LONGITUDE") ? "CORNERS" : "FULL";
+	}
+
+	if ( (string) in("SUBPAGE_MAP_PROJECTION") != "NEXT" ) {
+		FortranViewNodeWrapper* viewhelper = new FortranViewNodeWrapper();
+		viewhelper->set(in);
+		FortranViewNode* view = viewhelper->object();
+
+		string id =  in("METVIEW_ID");
+		int i =  in("METVIEW_ID");
+		pages_[i] = viewhelper;
+		if ( !id.empty() )
+		{
+			view->setInteractiveInfo(id.c_str(), 
+			in("ZOOM_NUMBER_OF_LEVELS"), in("ZOOM_CURRENT_LEVEL"));
+		}
+		top()->insert(view);
+
+		push(view);
+
+		string info = (string) in("SUBPAGE_METADATA_INFO");
+		if ( info == "ON" ) {
+			MetaDataVisitor *meta = new MetaDataVisitor();
+			string path = (string) in("SUBPAGE_METADATA_JAVASCRIPT_PATH");
+			meta->javascript_ = (path);
+			view->push_back(meta);
+		}
+	}
+	else {
+		page_ = new FortranViewNodeWrapper();
+		in("SUBPAGE_MAP_PROJECTION") = "cartesian";
+		page_->set(in);
+		int id = in("METVIEW_ID");
+		pages_[id] = page_;
+	}
+	
+	MagLog::dev()<< "<----page and subpage" << endl;
+	return false; // do not exit
+}
+
+bool MagPlus::cartesian(magics::MagRequest& in) {
+
+	in("SUBPAGE_MAP_PROJECTION") = "cartesian";
+	string xtype = lowerCase(in("X_AXIS_TYPE"));
+	string ytype = lowerCase(in("Y_AXIS_TYPE"));
+
+	replace_string(in, "X_AXIS_TYPE", "", "regular");
+	replace_string(in, "Y_AXIS_TYPE", "", "regular");
+	replace_string(in, "X_AXIS_TYPE", "longitude", "regular");
+	replace_string(in, "X_AXIS_TYPE", "LONGITUDE", "regular");
+	replace_string(in, "X_AXIS_TYPE", "latitude", "regular");
+	replace_string(in, "X_AXIS_TYPE", "LATITUDE", "regular");
+	replace_string(in, "Y_AXIS_TYPE", "", "regular");
+	replace_string(in, "Y_AXIS_TYPE", "longitude", "regular");
+	replace_string(in, "Y_AXIS_TYPE", "latitude", "regular");
+	replace_string(in, "Y_AXIS_TYPE", "LONGITUDE", "regular");
+	replace_string(in, "Y_AXIS_TYPE", "LATITUDE", "regular");
+
+			if ( !page_ ) page_ = new FortranViewNodeWrapper();
+			page_->set(in);
+			FortranViewNode* view = page_->object();
+
+			string id =  in("METVIEW_ID");
+			if (  !id.empty()  )
+			{
+				string id =  in("METVIEW_ID");
+				view->setInteractiveInfo(id.c_str(), 
+				in("ZOOM_NUMBER_OF_LEVELS"), in("ZOOM_CURRENT_LEVEL"));
+			}
+			top()->insert(view);
+			push(view);	
+			cout << "cartesian-->! " << endl;
+			in.print();
+			cout << "<--cartesian! " << endl;
+			magics::MagRequest& haxis = in.getSubRequest("HORIZONTAL_AXIS");
+
+			if ( haxis ) {
+
+				// use the user defined one
+				    HorizontalAxis*	 axis = new HorizontalAxis();
+				    haxis.print();
+				    replace_string(haxis, "_NAME", "", "Horizontal Axis");
+					replace_string(haxis, "_CLASS", "", "MAXIS");
+
+					setIconInfo(haxis, *axis);
+					AxisWrapper helper(axis);
+					string type = haxis("AXIS_TYPE");
+					if ( type != "POSITION_LIST" ) {
+						haxis("AXIS_TYPE") = xtype;
+						if ( xtype == "latitude" || xtype == "longitude") {
+							haxis("AXIS_TYPE") = "regular";
+							haxis("AXIS_TICK_LABEL_TYPE") = xtype;
+						}
+					}
+
+					haxis.print();
+					helper.set(haxis);
+
+					axis->orientation_ = "HORIZONTAL";
+					axis->position_ = ("bottom");
+					top()->push_back(axis);
+			}
+			else {
+				HorizontalAxis* haxis = new HorizontalAxis();
+				haxis->icon("Horizontal Axis", "MAXIS");
+				haxis->label_type_ = xtype;
+
+				haxis->method_ = auto_ptr<AxisMethod>(MagTranslator<string, AxisMethod>()(in("X_AXIS_TYPE")));
+				top()->push_back(haxis);
+			}
+			magics::MagRequest& vaxis = in.getSubRequest("VERTICAL_AXIS");
+
+
+			if (  vaxis ) {
+
+				// use the user defined one
+				vaxis.print();
+				VerticalAxis*	 axis = new VerticalAxis();
+				replace_string(vaxis, "_NAME", "", "Vertical Axis");
+				replace_string(vaxis, "_CLASS", "", "MAXIS");
+
+
+				setIconInfo(vaxis, *axis);
+				AxisWrapper helper(axis);
+				string type = vaxis("AXIS_TYPE");
+				if ( type != "POSITION_LIST" ) {
+					vaxis("AXIS_TYPE") = ytype;
+					if ( ytype == "latitude" || ytype == "longitude") {
+						vaxis("AXIS_TYPE") = "regular";
+						vaxis("AXIS_TICK_LABEL_TYPE") = ytype;
+					}
+				}
+
+				helper.set(vaxis);
+				axis->orientation_ = "VERTICAL";
+				top()->push_back(axis);
+			}
+			else {
+				VerticalAxis* vaxis = new VerticalAxis();
+				vaxis->icon("Vertical Axis", "MAXIS");
+				vaxis->label_type_ = ytype;
+				vaxis->method_ = auto_ptr<AxisMethod>(MagTranslator<string, AxisMethod>()(in("Y_AXIS_TYPE")));
+				top()->push_back(vaxis);
+
+			}
+
+            geographical_ = false;
+			return false; // do not exit
+}
+bool MagPlus::oldcoastlines(magics::MagRequest& in)
+{
+	replace_string(in, "MAP_COASTLINE_RESOLUTION", "MEDIUM", "automatic");
+	coastlines(in);
+}
+bool MagPlus::coastlines(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add coastlines" << endl;
+	
+
+	replace_string(in, "_NAME", "", "Coastlines");
+	replace_string(in, "_CLASS", "", "MCOAST");
+	CoastlinesWrapper helper;
+	
+	helper.set(in);
+	
+	top()->push_back(helper.object());
+	setIconInfo(in,*helper.object());
+	MagLog::dev()<< top() << endl;
+	MagLog::dev()<< *helper.object() << endl;
+	
+	return false; // do not exit
+}
+
+bool MagPlus::axis(magics::MagRequest& in)
+{
+	return false; // do not exit
+	MagLog::dev()<< "add axis" << endl;
+	 string orientation =  in("AXIS_ORIENTATION");
+	 Axis* axis = 0;
+	 if ( magCompare(orientation, "vertical") ) 
+		 axis = new VerticalAxis();
+	 else 
+		 axis = new HorizontalAxis();
+	 
+	AxisWrapper helper(axis);				
+	helper.set(in);
+	
+	top()->push_back(axis);
+	MagLog::dev() << *axis << "\n";
+
+	return false; // do not exit
+}
+
+bool MagPlus::import(magics::MagRequest& /*in*/)
+{
+	MagLog::dev()<< "ignore for now!!!" << endl;
+	return false; // do not exit
+}
+
+bool MagPlus::raster(magics::MagRequest& in)
+{
+	MagLog::dev()<< "import a raster object" << endl;
+	
+	in.print();
+
+	in("IMPORT_FILE_NAME") =  in("IMPORT_FILE_PATH");
+	in("IMPORT_FORMAT") =  in("IMPORT_FILE_TYPE");
+	
+	ImportActionWrapper object;
+	ImportPlotWrapper visdef;
+	
+	object.set(in);
+	visdef.set(in);
+	setIconInfo(in, *object.object());
+	setIconInfo(in, *visdef.object());
+	
+	
+		VisualAction* action = new VisualAction();
+		top()->push_back(action);
+		push(action);		
+		top()->data(object.object());
+		top()->visdef(visdef.object());
+		pop();
+
+	return false; // do not exit
+}
+
+bool MagPlus::binning(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add binning" << endl;
+	in.print();
+
+	BinningObjectWrapper binning;
+	binning.set(in);
+	top()->binning(binning.object());
+	return true;
+}
+
+bool MagPlus::grib(magics::MagRequest& in)
+{
+#ifdef MAGICS_GRIB
+	MagLog::dev()<< "add grib" << endl;
+	in.print();
+	
+	VisualAction* action = new VisualAction();
+	top()->push_back(action);
+	push(action);	
+  
+	GribDecoderWrapper grib;
+	grib.set(in);
+	setIconInfo(in, *grib.object());
+	top()->data(grib.object());
+#else
+	MagLog::dev()<< "can NOT add grib (disabled in Magics!)" << endl;
+#endif
+	return false; // do not exit
+}
+
+bool MagPlus::table(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add table" << endl;
+
+	in.print();
+	// First set the table_filename...	
+	magics::MagRequest&  data = in.getSubRequest("TABLE_DATA");
+	if(data)
+	{	
+	  	if(data.getVerb() == "TABLE")
+		{
+	  		string x = data("PATH");
+			in("TABLE_FILENAME") = x;
+		}	
+			
+		else if( data.getVerb() == "TABLE_READER" ) 
+		{
+			magics::MagRequest&  d = data.getSubRequest("DATA");
+			if (d) 
+			{
+				in("TABLE_FILENAME") = d("PATH");
+			}
+			else 
+			{
+				in("TABLE_FILENAME") = data("TABLE_FILENAME");
+
+			}
+		}	
+	}
+
+	if ( geographical_ ) {
+		VisualAction* action = new VisualAction();
+		top()->push_back(action);
+		push(action);
+		// Create Data
+		TableDecoderWrapper xy;
+		in.print();
+		magics::MagRequest&  bin = in.getSubRequest("TABLE_BINNING");
+		if (bin) {
+
+			in("TABLE_BINNING") = "on";
+			xy.set(in);
+			bin("TABLE_BINNING") = "on";
+			xy.set(bin);
+		}
+		else {
+			in("TABLE_BINNING") = "off";
+			xy.set(in);
+			bin("TABLE_BINNING") = "off";
+			xy.set(bin);
+		}
+		xy.set(data);
+		setIconInfo(in, *xy.object());
+		top()->data(xy.object());
+
+	}
+	else {
+		VisualAction* action = new VisualAction();
+		top()->push_back(action);
+		push(action);
+		// Create Data
+		TableDecoderWrapper xy;
+		magics::MagRequest&  bin = in.getSubRequest("TABLE_BINNING");
+		if (bin) {
+			in("TABLE_BINNING") = "on";
+			xy.set(in);
+			data("TABLE_BINNING") = "on";
+			xy.set(data);
+			bin("TABLE_BINNING") = "on";
+			xy.set(bin);
+		}
+		else {
+			in("TABLE_BINNING") = "off";
+			xy.set(in);
+			data("TABLE_BINNING") = "off";
+			xy.set(data);
+			bin("TABLE_BINNING") = "off";
+			xy.set(bin);
+		}
+
+
+		setIconInfo(in, *xy.object());
+		top()->data(xy.object());
+	}
+
+
+	return false; // do not exit
+}
+
+bool MagPlus::input(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add input" << endl;
+	in.print();
+	if ( geographical_ ) {
+		VisualAction* action = new VisualAction();
+		top()->push_back(action);
+		push(action);
+		// Create Data
+		InputDataWrapper xy;
+		magics::MagRequest&  bin = in.getSubRequest("INPUT_BINNING");
+		if (bin) {
+			in("INPUT_BINNING") = "on";
+			xy.set(in);
+			bin("INPUT_BINNING") = "on";
+			xy.set(bin);
+		}
+		else {
+			in("INPUT_BINNING") = "off";
+						xy.set(in);
+						bin("INPUT_BINNING") = "off";
+						xy.set(bin);
+		}
+		setIconInfo(in, *xy.object());
+		top()->data(xy.object());
+
+	}
+	else {
+		VisualAction* action = new VisualAction();
+		top()->push_back(action);
+		push(action);
+		// Create Data
+		InputDataWrapper xy;
+		magics::MagRequest&  bin = in.getSubRequest("INPUT_BINNING");
+		if (bin) {
+			in("INPUT_BINNING") = "on";
+			xy.set(in);
+			bin("INPUT_BINNING") = "on";
+			xy.set(bin);
+		}
+		else {
+			in("INPUT_BINNING") = "off";
+			xy.set(in);
+			bin("INPUT_BINNING") = "off";
+			xy.set(bin);
+		}
+		setIconInfo(in, *xy.object());
+		top()->data(xy.object());
+	}
+
+
+	return false; // do not exit
+}
+
+void MagPlus::setIconInfo(magics::MagRequest& mv, MetviewIcon& object) 
+{
+	string iconname =  get(mv, "_NAME", "");
+	string iconclass =  get(mv, "_CLASS", "");
+	if(iconclass.empty())
+		 iconclass =  get(mv, "_VERB", ""); 
+	string iconid =  get(mv, "_ID", "");
+	object.icon(iconname, iconclass, iconid);
+}
+
+bool MagPlus::gribloop(magics::MagRequest& in)
+{
+#ifdef MAGICS_GRIB
+	MagLog::dev()<< "add gribloop" << endl;
+	in.print();
+	string loop("loop");
+	string mode =  get(in, "GRIB_VISIT_MODE", loop);
+	
+	if ( !magCompare(mode, loop) ) 
+		// we assume it is not an animation...
+		return grib(in);
+	
+	string file =  get(in, "GRIB_INPUT_FILE_NAME", "");
+	
+
+	in("GRIB_LOOP_PATH") = file.c_str();
+	VisualAnimation* action = new VisualAnimation();
+	top()->push_back(action);
+	push(action);	
+  
+	GribLoopWrapper grib;
+	grib.set(in);
+	setIconInfo(in, *grib.object());
+	
+	action->loop(grib.object());
+#else
+	MagLog::dev()<< "can NOT add gribloop (disabled in Magics!)" << endl;
+#endif
+	return false; // do not exit
+}
+
+bool MagPlus::rasterloop(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add rasterloop" << endl;
+	in.print();
+	
+	VisualAnimation* geoloop = new VisualAnimation();
+	top()->push_back(geoloop);
+	push(geoloop);
+	
+		ImportPlotWrapper visdef;
+
+		visdef.set(in);
+		
+		setIconInfo(in, *visdef.object());
+
+	ImportLoop* loop = new ImportLoop();
+	setIconInfo(in, *loop);
+	geoloop->loop(loop);
+	geoloop->visdef(visdef.object());
+	
+	in.countValues("RASTERS");
+	
+	magics::MagRequest& rasters = in.getSubRequest("RASTERS");
+	rasters.print();
+
+	//At this point we do not know the exact type, 
+	//later we refine it
+	loop->setInfo("_datatype","RASTERLOOP");
+
+	bool first =true;
+
+	while ( rasters ) {
+		string name =  rasters("LAYERS");
+		string format  =   rasters("IMPORT_FILE_TYPE");
+		string path = rasters("IMPORT_FILE_PATH");
+		string type =  rasters("IMPORT_FILE_TYPE");
+		string time =  rasters("TIME"); //Should not work for WMS
+
+		rasters("IMPORT_FILE_NAME") = path;
+		rasters("IMPORT_FORMAT") =  rasters("IMPORT_FILE_TYPE");
+		rasters("IMPORT_VALID_TIME") =  rasters("TIME");
+		
+		ImportActionWrapper object;
+		object.set(rasters);
+
+		visdef.set(rasters);
+		object.object()->icon(name, format);
+
+		//WMS related part
+
+		string service_name =  rasters("SERVICE");
+	
+		if(service_name == "WMS")
+		{
+			string service_title =  rasters("SERVICE_TITLE");
+			string url =  rasters("URL");
+			string title =  rasters("TITLE");
+			string description =  rasters("DESCRIPTION");
+			string legend =  rasters("LEGEND");
+			string logo =  rasters("LOGO");
+			string dimName = rasters("DIM_NAME");		
+			string dimValue = rasters("DIM_VALUE");
+			
+			if(first)
+			{
+				loop->setInfo("_datatype","RASTERLOOP_WMS");
+				loop->setInfo("service_name",service_name);
+				loop->setInfo("service_title",service_title);
+				loop->setInfo("url",url);
+				loop->setInfo("name",name);
+				loop->setInfo("title",title);
+				loop->setInfo("description",description);
+				loop->setInfo("legend",legend);
+				loop->setInfo("logo",logo);
+				loop->setInfo("dimName",dimName);
+				loop->setInfo("dimValue",dimValue);
+			}
+
+			object.object()->setInfo("_datatype","RASTERLOOP_WMS");
+			object.object()->setInfo("service_name",service_name);
+			object.object()->setInfo("service_title",service_title);
+			object.object()->setInfo("url",url);
+			object.object()->setInfo("name",name);
+			object.object()->setInfo("title",title);
+			object.object()->setInfo("description",description);
+			object.object()->setInfo("legend",legend);
+			object.object()->setInfo("logo",logo);
+			object.object()->setInfo("dimName",dimName);
+			object.object()->setInfo("dimValue",dimValue);
+
+			//Temporal dimensions
+			vector<string> dimNameLst,dimValueLst;
+		
+    			std::stringstream ssN(dimName);
+   			std::string item;
+
+    			while(std::getline(ssN, item,'/'))
+			{
+        			dimNameLst.push_back(item);
+   			}
+    		
+			std::stringstream ssV(dimValue);
+    			while(std::getline(ssV, item,'/'))
+			{
+        			dimValueLst.push_back(item);
+   			}
+
+			if(dimNameLst.size() == dimValueLst.size())
+			{
+				for(unsigned int i=0; i < dimNameLst.size(); i++)
+				{
+					object.object()->setInfo(dimNameLst[i],dimValueLst[i]);
+
+					if(dimNameLst[i] == "TIME" && dimValueLst[i].size() >=9)
+					{
+						string dataDate=dimValueLst[i].substr(0,8);
+						string dataTime=dimValueLst[i].substr(8);
+
+						object.object()->setInfo("date",dataDate);
+						object.object()->setInfo("dataDate",dataDate);
+						object.object()->setInfo("time.dataDate",dataDate);
+						object.object()->setInfo("validityDate",dataDate);
+						object.object()->setInfo("time.validityDate",dataDate);
+
+						object.object()->setInfo("time",dataTime);
+						object.object()->setInfo("dataTime",dataTime);
+						object.object()->setInfo("time.dataTime",dataTime);
+						object.object()->setInfo("validityTime",dataTime);
+						object.object()->setInfo("time.validityTime",dataTime);
+
+					}
+					else if(dimNameLst[i] == "DIM_RUN" && dimValueLst[i].size() >=9)
+					{
+						string dataDate=dimValueLst[i].substr(0,8);
+						string dataTime=dimValueLst[i].substr(8);
+
+						object.object()->setInfo("date",dataDate);
+						object.object()->setInfo("dataDate",dataDate);
+						object.object()->setInfo("time.dataDate",dataDate);
+
+						object.object()->setInfo("time",dataTime);
+						object.object()->setInfo("dataTime",dataTime);
+						object.object()->setInfo("time.dataTime",dataTime);
+												
+					}
+					else if(dimNameLst[i] == "DIM_FORECAST")
+					{
+						object.object()->setInfo("step",dimValueLst[i]);
+						object.object()->setInfo("stepRange",dimValueLst[i]);
+						object.object()->setInfo("time.stepRange",dimValueLst[i]);
+					}
+					else if(dimNameLst[i] == "ELEVATION")
+					{
+						object.object()->setInfo("level",dimValueLst[i]);
+						object.object()->setInfo("vertical.level",dimValueLst[i]);
+					}
+		
+				}
+
+			}
+
+		}
+
+		/*ImportActionWrapper object;
+		object.set(rasters);
+
+		visdef.set(rasters);
+		object.object()->icon(name, format);*/
+		
+			//object.object()->setInfo("date",title);
+
+		loop->add(object.object());
+		
+		rasters.advance();
+
+		first=false;
+	}
+	pop();
+	return false; // do not exit
+}
+
+
+#if MAGICS_ODB	
+bool MagPlus::geoodb(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add geo odb" << endl;
+	in.print();
+	string path(in("ODB_FILENAME"));
+	if (path == "OFF") {
+		magics::MagRequest& odb = in.getSubRequest("ODB_DATA");
+		path = string(odb("PATH"));
+	}
+	in("ODB_FILENAME") = path.c_str();
+    
+	static map<string, string> types;
+    	if ( types.empty() ) 
+	{
+        	types["ODB_GEO_POINTS"] = "geopoint";
+        	types["ODB_GEO_VECTORS"] = "geovector";
+    	}
+        
+	in("ODB_TYPE") = types[in.getVerb()].c_str();
+	VisualAction* action = new VisualAction();
+	top()->push_back(action);
+	push(action);	
+  
+	OdaGeoDecoderWrapper geoodb;
+	geoodb.set(in);
+	setIconInfo(in, *geoodb.object());
+	top()->data(geoodb.object());
+
+	//Meta-data
+	geoodb.object()->initInfo();		
+
+	return false; // do not exit
+}
+
+bool MagPlus::xyodb(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add xy odb" << endl;
+	in.print();
+	string path(in("ODB_FILENAME"));
+	if (path == "OFF") {
+		magics::MagRequest& odb = in.getSubRequest("ODB_DATA");
+		path = string(odb("PATH"));
+	}
+	in("ODB_FILENAME") = path.c_str();
+    
+	static map<string, string> types;
+    	if ( types.empty() ) {
+        	types["ODB_XY_POINTS"] = "xypoint";
+        	types["ODB_XY_VECTORS"] = "xyvector";
+		types["ODB_XY_BINNING"] = "xybinning";
+   	 }
+        
+	in("ODB_TYPE") = types[in.getVerb()].c_str();
+	VisualAction* action = new VisualAction();
+	top()->push_back(action);
+	push(action);	
+  	
+	OdaXYDecoderWrapper xyodb;
+	
+	magics::MagRequest&  bin = in.getSubRequest("ODB_BINNING");
+	if(bin)
+	{
+		in("ODB_BINNING") = "on";
+		bin("ODB_BINNING") = "on";
+	}
+	else
+	{
+	  	in("ODB_BINNING") = "off";
+		bin("ODB_BINNING") = "off";
+	} 	
+	xyodb.set(in);	
+	xyodb.set(bin);	
+	  
+	setIconInfo(in, *xyodb.object());
+	top()->data(xyodb.object());
+	geographical_ = false;
+
+	//Meta-data
+	xyodb.object()->initInfo();
+
+	return false; // do not exit
+}
+#endif
+
+bool MagPlus::geonetcdf(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add geo netcdf" << endl;
+	in.print();
+	string path = get(in, "NETCDF_FILENAME", "OFF");
+	if (path == "OFF") {
+		magics::MagRequest& netcdf = in.getSubRequest("NETCDF_DATA");
+		path = string(netcdf("PATH"));
+	}
+	in("NETCDF_FILENAME") = path.c_str();
+    static map<string, string> types;
+    if ( types.empty() ) {
+        types["NETCDF_GEOPOINTS"] = "geopoint";
+        types["NETCDF_GEOVECTORS"] = "geovector";
+        types["NETCDF_GEOMATRIX"] = "geomatrix";
+        types["NETCDF_GEO_POINTS"] = "geopoint";
+        types["NETCDF_GEO_VECTORS"] = "geovector";
+        types["NETCDF_GEO_MATRIX"] = "geomatrix";
+        types["ARRAY"] = "geomatrix";
+        types["MATRIX"] = "complex_matrix";
+    }
+
+    string type = get(in, "NETCDF_POSITION_TYPE", in.getVerb());
+   	in("NETCDF_TYPE") = types[type].c_str();
+
+	VisualAnimation* action = new VisualAnimation();
+	top()->push_back(action);
+	push(action);	
+  
+	NetcdfDecoderWrapper geonet;
+	geonet.set(in);
+	
+	NetcdfLoop* loop = new NetcdfLoop(geonet.object());
+	setIconInfo(in, *geonet.object());
+	setIconInfo(in, *loop);
+	action->loop(loop);
+	
+	return false; // do not exit
+}
+
+
+bool MagPlus::xynetcdf(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add xy netcdf" << endl;
+	in.print();
+	string path = get(in, "NETCDF_FILENAME", "OFF");
+	if (path == "OFF") {
+		magics::MagRequest& netcdf = in.getSubRequest("NETCDF_DATA");
+		path = string(netcdf("PATH"));
+	}
+	in("NETCDF_FILENAME") = path.c_str();
+    static map<string, string> types;
+    if ( types.empty() ) {
+        types["NETCDF_POINTS"] = "xypoint";
+        types["NETCDF_VECTORS"] = "vector";
+        types["NETCDF_MATRIX"] = "matrix";
+        types["NETCDF_XY_POINTS"] = "xypoint";
+        types["NETCDF_XY_VECTORS"] = "vector";
+        types["NETCDF_XY_MATRIX"] = "matrix";
+        types["ARRAY"] = "matrix";
+        types["MATRIX"] = "complex_matrix";
+    }
+    string type = get(in, "NETCDF_POSITION_TYPE", in.getVerb());
+
+	in("NETCDF_TYPE") = types[type].c_str();
+	VisualAnimation* action = new VisualAnimation();
+	top()->push_back(action);
+	push(action);	
+  
+	NetcdfDecoderWrapper xynet;
+	xynet.set(in);
+	
+	NetcdfLoop* loop = new NetcdfLoop(xynet.object());
+	setIconInfo(in, *xynet.object());
+	geographical_ = false;
+	setIconInfo(in, *loop);
+	action->loop(loop);
+	
+	return false; // do not exit
+}
+
+
+bool MagPlus::geopoints(magics::MagRequest& in)
+{
+	// Extract the path ..
+	magics::MagRequest& record = in.getSubRequest("RECORD");
+	
+	string path =  record("PATH");
+	in("GEO_INPUT_FILE_NAME") = path;
+	in.print();
+	VisualAction* action = new VisualAction();
+	top()->push_back(action);
+	push(action);	
+  
+	GeoPointsDecoderWrapper geopoints;
+	geopoints.set(in);
+	setIconInfo(in, *geopoints.object());
+	top()->data(geopoints.object());
+
+	//Meta-data
+	geopoints.object()->initInfo();	
+	
+	return false; // do not exit
+}
+bool MagPlus::bufr(magics::MagRequest& in)
+{
+#ifdef MAGICS_BUFR
+	/*
+	// Extract the path ..
+	magics::MagRequest record = in("RECORD");
+	
+	in("GEO_INPUT_FILE_NAME") = record("PATH");
+	*/
+	in.print();
+	VisualAction* action = new VisualAction();
+	top()->push_back(action);
+	push(action);	
+  
+	ObsDecoderWrapper obs;
+	obs.set(in);
+	top()->data(obs.object());
+	setIconInfo(in, *obs.object());
+#endif
+	return false; // do not exit
+}
+bool MagPlus::symbol(magics::MagRequest& in)
+{
+	if ( in.countValues("SYMBOL_INPUT_MARKER_LIST") ) {
+		in("SYMBOL_MARKER") = in("SYMBOL_INPUT_MARKER_LIST");
+	}
+    string verb = in.getVerb();
+    if ( verb == "PSYMBPLUS" ) {
+        in("SYMBOL_TABLE_MODE") = "advanced"; 
+        in("SYMBOL_TYPE") = "marker"; 
+    } 
+    
+    FortranAutomaticLegendVisitor* node = new FortranAutomaticLegendVisitor();	
+    		LegendMethod* method = new ContinuousLegendMethod();
+    		node->method_ = auto_ptr<LegendMethod>(method);
+    		node->getReady();
+    		//top()->legend(node);
+	if ( geographical_ ) {		
+		SymbolPlottingWrapper symbol;
+		symbol.set(in);
+		setIconInfo(in, *symbol.object());
+		MagLog::dev()<< "add symbol" << *symbol.object() << endl;
+		top()->visdef(symbol.object());
+		pop();
+	}
+	else {
+		SymbolPlottingWrapper symbol;
+		symbol.set(in);
+		setIconInfo(in, *symbol.object());
+		MagLog::dev()<< "add symbol" << *symbol.object() << endl;
+		top()->visdef(symbol.object());
+		pop();
+
+	}
+
+	return false; // do not exit
+}
+
+bool  MagPlus::graph(magics::MagRequest& in)
+{
+	GraphPlottingWrapper graph ;
+	graph.set(in);
+	MagLog::dev()<< "add graph" << *graph.object() << endl;
+	top()->visdef(graph.object());
+	pop();
+	return false; // do not exit
+}
+
+bool MagPlus::obs(magics::MagRequest& in)
+{
+#ifdef MAGICS_BUFR
+	ObsPlottingWrapper visdef;
+	// here we have to set up manullay the parameters because the obs object is more complex!
+	// This is not the right solution just a workaround before we find a clean solution...
+	
+	for (int i = 0; i <    in.countParameters(); i++) {
+		string param = in.getParameter(i);
+	    string val =  in(param.c_str());
+	
+	   ParameterManager::set(param, val);
+}
+
+
+	visdef.set(in);
+	MagLog::dev()<< "add obs" << *visdef.object() << endl;
+	top()->visdef(visdef.object());
+	pop();	
+	
+	
+#endif
+	return false; // do not exit
+}
+
+bool MagPlus::wind(magics::MagRequest& in)
+{
+	
+
+	WindWrapper wind;
+	wind.set(in);
+	setIconInfo(in, *wind.object());
+	MagLog::dev()<< "add wind" << *wind.object() << endl;
+	if (currentMulti_) {
+		currentMulti_->push_back(wind.object());
+	}
+	else {
+		top()->visdef(wind.object());
+		pop();
+	}
+
+	return false; // do not exit
+}
+
+bool MagPlus::visdef(magics::MagRequest& in)
+{
+	MagLog::dev()<< "found visdef" << endl;
+	
+	MagRequest& visdefs = in.getSubRequest("ACTIONS");
+	
+	visdefs.print();
+	bool dopop = false;
+	while (visdefs) {
+		
+		string verb = visdefs.getVerb();
+		{
+	   	    map<string,  ObjectCreator >::iterator creator = sceneHandler_->find(verb);
+	   	    if ( creator != sceneHandler_->end() ) {
+	   	    	  magics::MagRequest& visdef = visdefs.justOneRequest();
+	   	    	 // we keep the action
+	   	    	  BasicSceneObject* action = top();
+	   	    	  (this->*creator->second)(visdef);
+	   	    	  // we pout it back!
+	   	    	  push(action);
+	   	    	  dopop = true;
+	   	    }
+		}
+		visdefs.advance();
+	}
+	if ( dopop ) pop();
+	MagLog::dev()<< "<---end visdef" << endl;
+	return false;
+}
+
+bool MagPlus::multi(magics::MagRequest& in)
+{
+	MultiVisdef* multi = new MultiVisdef();
+
+	top()->visdef(multi);
+	MagRequest& visdef1 = in.getSubRequest("1D_VISDEF");
+	MagRequest& visdef2 = in.getSubRequest("2D_VISDEF");
+	pop();
+	visdef1.print();
+	visdef2.print();
+	while (visdef1) {
+		currentMulti_ = multi->oneDimension();
+		string verb = visdef1.getVerb();
+		{
+	   	    map<string,  ObjectCreator >::iterator creator = sceneHandler_->find(verb);
+	   	    if ( creator != sceneHandler_->end() ) {
+	   	    	  magics::MagRequest& visdef = visdef1.justOneRequest();
+	   	    	  (this->*creator->second)(visdef);
+	   	    }
+		}
+		visdef1.advance();
+	}
+
+
+	visdef2.print();
+	while (visdef2) {
+		currentMulti_ = multi->twoDimension();
+		string verb = visdef2.getVerb();
+		{
+			map<string,  ObjectCreator >::iterator creator = sceneHandler_->find(verb);
+			if ( creator != sceneHandler_->end() ) {
+				  magics::MagRequest& visdef = visdef2.justOneRequest();
+				  (this->*creator->second)(visdef);
+			}
+		}
+		visdef2.advance();
+	}
+	currentMulti_=0;;
+	MagLog::dev()<< "<---end visdef" << endl;
+	return false;
+}
+
+
+
+bool MagPlus::contour(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add contour" << endl;
+	
+	//replace(in, "CONTOUR_LABEL_HEIGHT", 0.3, 0.2);
+	string legend  = get(in, "CONTOUR_LEGEND", "ON");
+	
+	ContourWrapper contour;
+	contour.set(in);
+	setIconInfo(in, *contour.object());
+	if (currentMulti_)
+		currentMulti_->push_back(contour.object());
+	else {
+		top()->visdef(contour.object());
+		pop();
+	}
+
+	return false; // do not exit
+}
+
+bool MagPlus::ptext(magics::MagRequest& in)   
+{
+	MagLog::dev()<< "add Text" << endl;
+	in.print();
+	sceneCreators_["MLEGEND"] = &MagPlus::ignore;
+
+	replace(in, "TEXT_REFERENCE_CHARACTER_HEIGHT", 2.0 , "TEXT_FONT_SIZE", 0.3);
+	replace_string(in, "TEXT_COLOUR", "BLUE", "navy"); 
+	in("TEXT_HTML") = "on";
+	text(in);
+	legend(in);
+
+	return false; // do not exit
+}
+
+bool MagPlus::text(magics::MagRequest& in)   
+{
+	
+	MagLog::dev()<< "add Text-->" << endl;
+	in.print();
+	MagLog::dev()<< "<--add Text" << endl;
+	string mode = get(in, "TEXT_MODE", "automatic");
+	
+	
+	in("TEXT_HTML") = "on";
+
+	TextVisitor* node;
+	if (magCompare(mode, "positional") )
+		node = new FortranPositionalTextVisitor();
+	else 
+		node = new FortranAutomaticTextVisitor();	
+	
+	TextVisitorWrapper helper(node);
+	helper.set(in);	
+	top()->text(node);
+
+
+	return false; // do not exit
+}
+
+
+bool MagPlus::legend(magics::MagRequest& in)
+{
+	
+	MagLog::dev()<< "add legend-->" << endl;
+	in.print();
+	MagLog::dev()<< "<--add legend" << endl;
+	string mode = get(in, "LEGEND_BOX_MODE", "automatic");
+
+	LegendVisitor* legend;
+	if ( magCompare(mode, "positional") ) {
+		legend = new FortranPositionalLegendVisitor();
+	
+	}
+	else 
+		legend = new FortranAutomaticLegendVisitor();
+	LegendVisitorWrapper helper(legend);
+	helper.set(in);	
+	top()->legend(legend);
+	return false; // do not exit
+}
+
+bool MagPlus::ignore(magics::MagRequest&)
+{
+	return false; // do not exit
+}
+
+bool MagPlus::device(magics::MagRequest& in)
+{
+	MagLog::dev()<< "add device" << endl;
+	in.print();
+	XmlNode* driver = 0;
+	if ( !in.countValues("FORMAT") ) return false;
+    string fmt =  in("FORMAT");
+    
+   
+    string format(fmt);
+    
+    if ( format == "POSTSCRIPT") {
+    	
+    	map<string, string> attributes;
+    	attributes["output_fullname"] =  string(in("FILE"));
+    
+    	driver = new XmlNode("ps", attributes);
+    }
+	
+	output_.set(*driver, drivers_);
+    if ( driver) delete(driver);
+	return false; // do not exit
+}
+
+/*
+ 
+void MagPlus::serve( magics::MagRequest& in, magics::MagRequest& out)
+{
+   magin = magics::MagRequest(in);
+   magout = magics::MagRequest(in);
+   //execute(in, out);
+}
+
+*/
+void MagPlus::execute( magics::MagRequest& in)
+{
+	cout << "MagPlus::execute-->" << endl;
+	in.print();
+	cout << "<---MagPlus::execute" << endl;
+	try {
+	// Start from a fersh tree! 
+#ifndef MAG_NEXT
+		if (root_)
+		{
+			delete root_;
+			root_ = 0;
+			superpage_ = -1;
+			drivers_.clear();
+			mode_ = interactif;
+		}
+		sceneHandler_ =  &sceneCreators_;
+#else
+		mvMode_ = (root_) ?  update : creation;
+		sceneHandler_ = (root_) ? &sceneUpdators_ : &sceneCreators_;
+
+#endif
+
+   while ( in ) {
+   		string verb = in.getVerb();
+   	    MagLog::dev()<< "create-->" << verb <<endl;
+        {
+   	    map<string,  ObjectCreator >::iterator creator = sceneHandler_->find(verb);
+   	    if ( creator != sceneHandler_->end() ) {
+   	    	  magics::MagRequest& request = in.justOneRequest();
+   	    	  if ( (this->*creator->second)(request) ) return;
+   	    }
+        }
+        { 
+        map<string,  ObjectCreator >::iterator creator = driverCreators_.find(verb);
+   	    if ( creator != driverCreators_.end() ) {
+   	    	  magics::MagRequest& request = in.justOneRequest();
+   	    	  if ( (this->*creator->second)(request) ) return;
+   	    }
+   	    }
+   		in.advance();
+   }
+        if ( !root_ ) {
+        	MagLog::warning() << "Sorry, nothing to to display!" << endl;
+        	return;
+        }
+		assert(root_);
+
+			root_->getReady();
+			drivers_.setDriversWidth(root_->absoluteWidth());
+			drivers_.setDriversHeight(root_->absoluteHeight());
+			root_->mode(mode_);
+		
+			root_->execute();
+
+		drivers_.openDrivers();
+		drivers_.dispatch(root_->root());
+		drivers_.closeDrivers();
+		MetaDataVisitor::collect();
+   }
+   catch (MagicsException& e)
+   {
+   	/*! \todo Why is this MagMagException empty???  */
+	   MagLog::error() << "Something went really wrong!" << e << endl;
+
+   } 
+}
+
+
+
+void MagPlus::notify(MagicsEvent& event)
+{
+	MagLog::dev()<< "NOTIFY---" << event << endl;
+	 for (vector<MagicsObserver*>::iterator observer = observers_.begin(); observer != observers_.end(); ++observer) 
+			event.notify(**observer);
+}
+
+void MagPlus::unregisterObserver(MagicsObserver* observer)
+{
+
+    observers_.erase(std::remove_if(observers_.begin(), observers_.end(), 
+    	bind2nd(std::equal_to<MagicsObserver*>(), observer)), observers_.end());
+    	  
+}
+
+
+//_____________________________________________________________________
+
+#ifdef STANDALONE
+int main( int argc, char** argv )
+{
+    MvApplication theApp( argc, argv );
+    MagPlusService magplus;
+    theApp.run();
+}
+#endif
diff --git a/src/libMagWrapper/MagPlus.h b/src/libMagWrapper/MagPlus.h
new file mode 100644
index 0000000..c504159
--- /dev/null
+++ b/src/libMagWrapper/MagPlus.h
@@ -0,0 +1,136 @@
+#ifndef MagPlus_H
+#define MagPlus_H
+
+#include <magics.h>
+#include "DriverManager.h"
+
+// undefine the macro ABS because it is defined in mars.h and will be redefined
+// by Terralib (only an big issue on AIX)
+
+#undef ABS
+
+#include "OutputHandler.h"
+#include "RootSceneNode.h"
+#include "MagicsEvent.h"
+#include "MagRequest.h"
+
+
+
+
+#if MAGICS_QT
+class QGraphicsScene;
+#endif
+
+namespace magics {
+
+#if MAGICS_QT
+class QtDriver;
+#endif
+
+class FortranViewNodeWrapper;
+class MultiVisdef;
+
+class MagPlus : public stack<BasicSceneObject*>
+{
+public:
+	MagPlus();
+	~MagPlus() {}
+
+	void execute(MagRequest&);
+
+	void registerObserver(MagicsObserver* observer) { observers_.push_back(observer); }
+	void unregisterObserver(MagicsObserver* observer);
+	//! Notify drivers about an event (GUI -> Qt)
+	void notifyDrivers(MagicsEvent& event) { drivers_.dispatch(&MagicsEvent::notify, event); }
+
+	//! Notify the magicsobservers about an event in the QtDriverObserver (Qt -> GUI)
+	void notify(MagicsEvent&);
+
+#if MAGICS_QT
+	//! Set the QGraphicsScene for the Qt driver
+	void setQtScene(QGraphicsScene*);
+#endif
+
+
+protected:
+	vector<MagicsObserver*> observers_;
+	vector<BasicSceneObject*> foreground_;
+	
+	typedef bool (MagPlus::*ObjectCreator)(magics::MagRequest&);
+ 
+	static map<string,  ObjectCreator > driverCreators_;
+	static map<string,  ObjectCreator > sceneCreators_;
+	static map<string,  ObjectCreator > sceneUpdators_;
+	map<string,  ObjectCreator >* sceneHandler_;
+	map<int,  FortranViewNodeWrapper* > pages_;
+
+	void setIconInfo(magics::MagRequest&, MetviewIcon&);
+
+	bool page(magics::MagRequest&);
+	bool newpage(magics::MagRequest&);
+	bool page_update(magics::MagRequest&);
+	bool superpage(magics::MagRequest&);
+	bool cartesian(magics::MagRequest&);
+	bool coastlines(magics::MagRequest&);
+	bool oldcoastlines(magics::MagRequest&);
+	bool axis(magics::MagRequest&);
+	bool grib(magics::MagRequest&);
+	bool gribloop(magics::MagRequest&);
+	bool rasterloop(magics::MagRequest&);
+	bool bufr(magics::MagRequest&);
+	bool visdef(magics::MagRequest&);
+	
+#if MAGICS_ODB	
+	bool geoodb(magics::MagRequest&);
+	bool xyodb(magics::MagRequest&);
+#endif
+	bool geonetcdf(magics::MagRequest&);
+	bool xynetcdf(magics::MagRequest&);
+	bool geopoints(magics::MagRequest&);
+	bool raster(magics::MagRequest&);
+	bool input(magics::MagRequest&);
+	bool table(magics::MagRequest&);
+	bool binning(magics::MagRequest&);
+
+	bool contour(magics::MagRequest&);
+	bool symbol(magics::MagRequest&);
+	bool wind(magics::MagRequest&);
+	bool import(magics::MagRequest&);
+	bool obs(magics::MagRequest&);
+	bool graph(magics::MagRequest&);
+	bool multi(magics::MagRequest&);
+	
+	bool ptext(magics::MagRequest&);
+	bool text(magics::MagRequest&);
+	bool legend(magics::MagRequest&);
+	bool ignore(magics::MagRequest&);
+	bool device(magics::MagRequest&);
+
+	bool qtdriver(magics::MagRequest&);
+	bool pdfdriver(magics::MagRequest&);
+	bool pngdriver(magics::MagRequest&);
+	bool svgdriver(magics::MagRequest&);
+	bool kmldriver(magics::MagRequest&);  
+	bool psdriver(magics::MagRequest&);
+	bool epsdriver(magics::MagRequest&);
+    
+	RootSceneNode* root_;
+	DriverManager  drivers_;
+	OutputHandler  output_;
+	int  superpage_;
+	bool geographical_;
+	MagicsMode mode_;
+	enum MetviewMode {creation, update };
+	MetviewMode mvMode_;
+	FortranViewNodeWrapper* page_;
+	vector<Visdef*>* currentMulti_;
+
+#if MAGICS_QT
+	//! Keep the instance of the QtDrver!
+	QtDriver* qtDriver_;
+#endif
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/libMagWrapper/MagRequest.h b/src/libMagWrapper/MagRequest.h
new file mode 100644
index 0000000..428078b
--- /dev/null
+++ b/src/libMagWrapper/MagRequest.h
@@ -0,0 +1,79 @@
+/*! \file MagRequest.h
+    \brief Definition of the Template class MagRequest.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Tue 24-Aug-2010
+    
+    Changes:
+    
+*/
+
+#ifndef XMagRequest_H
+#define XMagRequest_H
+
+#include "magics.h"
+
+namespace magics {
+
+class MagParam {
+public:
+	MagParam() {}
+	~MagParam() {}
+ 
+	virtual operator double() const { return dvalue_; }
+	virtual operator string() const { return svalue_;}
+	virtual operator int() const { return ivalue_; }
+	
+	virtual MagParam& operator=(int i) { ivalue_ = i; cout << "set int" << ivalue_ << endl; return *this;}
+	virtual MagParam& operator=(string s) { svalue_ = s; cout << "set string" << svalue_ << endl; return *this;}
+	virtual MagParam& operator=(double d) { dvalue_ = d; cout << "set double" << dvalue_ << endl; return *this; }
+
+protected:
+	string svalue_;
+    int ivalue_;
+    double dvalue_;
+};
+
+
+class MagRequest {
+
+public:
+	MagRequest() {}
+	virtual ~MagRequest() {}
+
+	
+	virtual string getVerb() const = 0;
+	virtual MagParam& operator()(const string& name) const =0;
+	virtual MagParam& operator()(const string& name, int i) const =0;
+	virtual int countValues(const string& name) const =0;
+
+	virtual MagRequest& getSubRequest(const string&) =0;
+    virtual operator bool () const =0;
+    virtual void advance () =0;
+	virtual int countParameters() =0;
+	virtual int countValues(const string&) =0;
+	virtual string getParameter(int) =0;
+	virtual void print() =0;
+	virtual MagRequest& justOneRequest() =0;
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+	 
+
+private:
+    //! Copy constructor - No copy allowed
+	//MagRequest(const MagRequest&);
+    //! Overloaded << operator to copy - No copy allowed
+	//MagRequest& operator=(const MagRequest&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MagRequest& p)
+		{ p.print(s); return s; }
+
+};
+
+} // end namespace
+#endif
diff --git a/src/libMagWrapper/Makefile.am b/src/libMagWrapper/Makefile.am
new file mode 100644
index 0000000..f41ab88
--- /dev/null
+++ b/src/libMagWrapper/Makefile.am
@@ -0,0 +1,132 @@
+AUTOMAKE_OPTIONS	= foreign
+
+include_HEADERS = MagPlus.h MagRequest.h 
+MY_SOURCES	= MagPlus.cc
+MY_SOURCES_NODIST	= MvRootSceneNodeWrapper.cc \
+	FortranSceneNodeWrapper.cc \
+	PageIDWrapper.cc NoPageIDWrapper.cc\
+	LogoPlottingWrapper.cc \
+	LegendVisitorWrapper.cc\
+	ContinuousLegendMethodWrapper.cc\
+	HistogramLegendMethodWrapper.cc\
+	LegendMethodWrapper.cc\
+	NoLogoPlottingWrapper.cc UserLogoPlottingWrapper.cc \
+	FortranViewNodeWrapper.cc \
+	TransformationWrapper.cc GeoRectangularProjectionWrapper.cc \
+        MercatorProjectionWrapper.cc \
+        PolarStereographicProjectionWrapper.cc \
+        ImportActionWrapper.cc \
+        ImportPlotWrapper.cc \
+        TableDecoderWrapper.cc\
+        InputDataWrapper.cc\
+        NetcdfDecoderWrapper.cc\
+        SymbolPlottingWrapper.cc\
+        WindWrapper.cc\
+        ContourWrapper.cc\
+        NoIsoPlotWrapper.cc IsoPlotWrapper.cc \
+        ContourMethodWrapper.cc\
+        Akima474MethodWrapper.cc Akima760MethodWrapper.cc\
+        HiLoBaseWrapper.cc\
+        NoIsoShadingWrapper.cc IsoShadingWrapper.cc\
+        PolyShadingTechniqueWrapper.cc ShadingTechniqueWrapper.cc \
+        MarkerShadingTechniqueWrapper.cc GridShadingWrapper.cc PolyShadingMethodWrapper.cc\
+        AutomaticContourMethodWrapper.cc HighHiLoWrapper.cc LowHiLoWrapper.cc \
+        CellShadingWrapper.cc ValuePlotWrapper.cc \
+        HatchPolyShadingMethodWrapper.cc DotPolyShadingMethodWrapper.cc \
+        SampleContourMethodWrapper.cc ValuePlotMethodWrapper.cc\
+        ValuePlotBaseWrapper.cc NoHiLoWrapper.cc\
+        MarkerValuePlotMethodWrapper.cc BothValuePlotMethodWrapper.cc \
+	CartesianTransformationWrapper.cc  HiLoWrapper.cc\
+	NoValuePlotWrapper.cc \
+	NoHiLoMarkerWrapper.cc HiLoMarkerWrapper.cc \
+	HiLoBothWrapper.cc HiLoNumberWrapper.cc HiLoTextWrapper.cc HiLoTechniqueWrapper.cc \
+	YCoordinateWrapper.cc YRegularCoordinateWrapper.cc HiLoMarkerBaseWrapper.cc\
+	YDateCoordinateWrapper.cc YLogarithmicCoordinateWrapper.cc \
+	XHyperCoordinateWrapper.cc YHyperCoordinateWrapper.cc \
+	XCoordinateWrapper.cc XRegularCoordinateWrapper.cc XDateCoordinateWrapper.cc XLogarithmicCoordinateWrapper.cc \
+	CoastlinesWrapper.cc \
+	CoastPlottingWrapper.cc NoCoastPlottingWrapper.cc \
+	BoundariesWrapper.cc NoBoundariesWrapper.cc \
+	GridPlottingWrapper.cc NoGridPlottingWrapper.cc \
+	LabelPlottingWrapper.cc NoLabelPlottingWrapper.cc \
+	GeoPointsDecoderWrapper.cc \
+	WindModeWrapper.cc SDWindModeWrapper.cc VDWindModeWrapper.cc UVWindModeWrapper.cc \
+	ColourTechniqueWrapper.cc \
+	CountSelectionTypeWrapper.cc IntervalSelectionTypeWrapper.cc LevelListSelectionTypeWrapper.cc\
+	LevelSelectionWrapper.cc CalculateColourTechniqueWrapper.cc ListColourTechniqueWrapper.cc \
+	IsoLabelWrapper.cc NoIsoLabelWrapper.cc \
+	TextVisitorWrapper.cc  \
+	SymbolModeWrapper.cc SymbolTableModeWrapper.cc SymbolAdvancedTableModeWrapper.cc SymbolIndividualModeWrapper.cc \
+	BaseDriverWrapper.cc\
+	NoOutLayerTechniqueWrapper.cc SimpleOutLayerTechniqueWrapper.cc HeightTechniqueWrapper.cc\
+	CalculateHeightTechniqueWrapper.cc ListHeightTechniqueWrapper.cc \
+	IsoHighlightWrapper.cc NoIsoHighlightWrapper.cc \
+        PreviewVisitorWrapper.cc NoPreviewVisitorWrapper.cc\
+        MagnifierVisitorWrapper.cc NoMagnifierVisitorWrapper.cc \
+        AxisWrapper.cc \
+	OriginMarkerWrapper.cc NoOriginMarkerWrapper.cc DotOriginMarkerWrapper.cc CircleOriginMarkerWrapper.cc  \
+	CalmIndicatorWrapper.cc NoCalmIndicatorWrapper.cc \
+	PostScriptDriverWrapper.cc BaseDriverWrapper.cc KMLDriverWrapper.cc SVGDriverWrapper.cc \
+	WindPlottingWrapper.cc FlagPlottingWrapper.cc ArrowPlottingWrapper.cc \
+	CitiesWrapper.cc NoCitiesWrapper.cc  NoBinningObjectWrapper.cc BinningObjectWrapper.cc GraphPlottingWrapper.cc \
+	CurveWrapper.cc CurveAreaWrapper.cc GraphWrapper.cc GraphArrowWrapper.cc GraphFlagWrapper.cc\
+	GraphShadeWrapper.cc NoGraphShadeWrapper.cc \
+	GraphShadeStyleWrapper.cc DotGraphShadeStyleWrapper.cc HatchGraphShadeStyleWrapper.cc\
+	BarWrapper.cc   MetaDataWrapper.cc  AxisMethodWrapper.cc PositionListAxisMethodWrapper.cc \
+	DateAxisMethodWrapper.cc LogarithmicAxisMethodWrapper.cc HyperAxisMethodWrapper.cc
+	
+if MAGICS_PROJ4
+MY_SOURCES_NODIST += Proj4ProjectionWrapper.cc \
+  				Proj4PolarNorthWrapper.cc \
+  				Proj4GeosWrapper.cc \
+  				Proj4GoodeWrapper.cc \
+  				Proj4LambertWrapper.cc \
+  				Proj4BonneWrapper.cc \
+  				Proj4CollignonWrapper.cc \
+  				Proj4MollweideWrapper.cc \
+  				Proj4EPSG4326Wrapper.cc \
+  				Proj4EPSG32661Wrapper.cc \
+                Proj4EPSG3857Wrapper.cc
+endif
+
+if MAGICS_CAIRO
+MY_SOURCES_NODIST += CairoDriverWrapper.cc 
+endif
+
+if MAGICS_ODB
+MY_SOURCES_NODIST += OdaGeoDecoderWrapper.cc OdaXYDecoderWrapper.cc
+endif
+
+if MAGICS_GRIB
+MY_SOURCES_NODIST += 	GribDecoderWrapper.cc GribAddressModeWrapper.cc GribAddressByteModeWrapper.cc GribAddressRecordModeWrapper.cc \
+			GribLoopWrapper.cc GribLoopStepWrapper.cc \
+			ParamGribLoopStepWrapper.cc DateGribLoopStepWrapper.cc
+endif
+
+if MAGICS_BUFR
+MY_SOURCES_NODIST += ObsDecoderWrapper.cc ObsPlottingWrapper.cc
+endif
+
+if MAGICS_NETCDF
+MY_SOURCES_NODIST += NetcdfInterpretorWrapper.cc NetcdfGeopointsInterpretorWrapper.cc NetcdfXYpointsInterpretorWrapper.cc NetcdfGeoPolarMatrixInterpretorWrapper.cc \
+	NetcdfMatrixInterpretorWrapper.cc NetcdfOrcaInterpretorWrapper.cc NetcdfGeoMatrixInterpretorWrapper.cc\
+	NetcdfVectorInterpretorWrapper.cc NetcdfGeoVectorInterpretorWrapper.cc
+endif
+
+later= TaylorProjectionWrapper.cc TaylorGridWrapper.cc PostScriptDriverWrapper.cc GDDriverWrapper.cc 
+
+#lib_LTLIBRARIES	= libMagWrapper.la
+lib_LIBRARIES		= libMagWrapper.a
+libMagWrapper_a_SOURCES	= $(MY_SOURCES)
+nodist_libMagWrapper_a_SOURCES = $(MY_SOURCES_NODIST)
+
+AM_CPPFLAGS		= -DUSE_NEW_IO ${GRIBAPI_CXXFLAGS} -DMETVIEW -DH_INCLUDES_CC -DGLX_PROBLEMS -DMAGINT_IS_INT -DREAL_IS_DOUBLE $(PLATFORM_DEFINES_MARS) \
+			 -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/libTable -I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/visualisers -I$(top_srcdir)/src/terralib/kernel \
+			 -I$(top_srcdir)/src -I$(METVIEW_HOME)/src/libMetview -I$(METVIEW_HOME)/src/libMars -I$(METVIEW_HOME)/src/libUtil
+if MAGICS_ODB
+AM_CPPFLAGS += -I$(top_srcdir)/src/oda
+endif
+
+if MAGICS_QT
+AM_CPPFLAGS += -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+endif
diff --git a/src/libMagWrapper/Makefile.in b/src/libMagWrapper/Makefile.in
new file mode 100644
index 0000000..3ff72a9
--- /dev/null
+++ b/src/libMagWrapper/Makefile.in
@@ -0,0 +1,1080 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_PROJ4_TRUE@am__append_1 = Proj4ProjectionWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4PolarNorthWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4GeosWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4GoodeWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4LambertWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4BonneWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4CollignonWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4MollweideWrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4EPSG4326Wrapper.cc \
+ at MAGICS_PROJ4_TRUE@  				Proj4EPSG32661Wrapper.cc \
+ at MAGICS_PROJ4_TRUE@                Proj4EPSG3857Wrapper.cc
+
+ at MAGICS_CAIRO_TRUE@am__append_2 = CairoDriverWrapper.cc 
+ at MAGICS_ODB_TRUE@am__append_3 = OdaGeoDecoderWrapper.cc OdaXYDecoderWrapper.cc
+ at MAGICS_GRIB_TRUE@am__append_4 = GribDecoderWrapper.cc GribAddressModeWrapper.cc GribAddressByteModeWrapper.cc GribAddressRecordModeWrapper.cc \
+ at MAGICS_GRIB_TRUE@			GribLoopWrapper.cc GribLoopStepWrapper.cc \
+ at MAGICS_GRIB_TRUE@			ParamGribLoopStepWrapper.cc DateGribLoopStepWrapper.cc
+
+ at MAGICS_BUFR_TRUE@am__append_5 = ObsDecoderWrapper.cc ObsPlottingWrapper.cc
+ at MAGICS_NETCDF_TRUE@am__append_6 = NetcdfInterpretorWrapper.cc NetcdfGeopointsInterpretorWrapper.cc NetcdfXYpointsInterpretorWrapper.cc NetcdfGeoPolarMatrixInterpretorWrapper.cc \
+ at MAGICS_NETCDF_TRUE@	NetcdfMatrixInterpretorWrapper.cc NetcdfOrcaInterpretorWrapper.cc NetcdfGeoMatrixInterpretorWrapper.cc\
+ at MAGICS_NETCDF_TRUE@	NetcdfVectorInterpretorWrapper.cc NetcdfGeoVectorInterpretorWrapper.cc
+
+ at MAGICS_ODB_TRUE@am__append_7 = -I$(top_srcdir)/src/oda
+ at MAGICS_QT_TRUE@am__append_8 = -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+subdir = src/libMagWrapper
+DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
+LIBRARIES = $(lib_LIBRARIES)
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_$(V))
+am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
+am__v_AR_0 = @echo "  AR    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+libMagWrapper_a_AR = $(AR) $(ARFLAGS)
+libMagWrapper_a_LIBADD =
+am__objects_1 = MagPlus.$(OBJEXT)
+am_libMagWrapper_a_OBJECTS = $(am__objects_1)
+ at MAGICS_PROJ4_TRUE@am__objects_2 = Proj4ProjectionWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4PolarNorthWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4GeosWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4GoodeWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4LambertWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4BonneWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4CollignonWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4MollweideWrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4EPSG4326Wrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4EPSG32661Wrapper.$(OBJEXT) \
+ at MAGICS_PROJ4_TRUE@	Proj4EPSG3857Wrapper.$(OBJEXT)
+ at MAGICS_CAIRO_TRUE@am__objects_3 = CairoDriverWrapper.$(OBJEXT)
+ at MAGICS_ODB_TRUE@am__objects_4 = OdaGeoDecoderWrapper.$(OBJEXT) \
+ at MAGICS_ODB_TRUE@	OdaXYDecoderWrapper.$(OBJEXT)
+ at MAGICS_GRIB_TRUE@am__objects_5 = GribDecoderWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	GribAddressModeWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	GribAddressByteModeWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	GribAddressRecordModeWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	GribLoopWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	GribLoopStepWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	ParamGribLoopStepWrapper.$(OBJEXT) \
+ at MAGICS_GRIB_TRUE@	DateGribLoopStepWrapper.$(OBJEXT)
+ at MAGICS_BUFR_TRUE@am__objects_6 = ObsDecoderWrapper.$(OBJEXT) \
+ at MAGICS_BUFR_TRUE@	ObsPlottingWrapper.$(OBJEXT)
+ at MAGICS_NETCDF_TRUE@am__objects_7 =  \
+ at MAGICS_NETCDF_TRUE@	NetcdfInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeopointsInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfXYpointsInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoPolarMatrixInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfMatrixInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfOrcaInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoMatrixInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfVectorInterpretorWrapper.$(OBJEXT) \
+ at MAGICS_NETCDF_TRUE@	NetcdfGeoVectorInterpretorWrapper.$(OBJEXT)
+am__objects_8 = MvRootSceneNodeWrapper.$(OBJEXT) \
+	FortranSceneNodeWrapper.$(OBJEXT) PageIDWrapper.$(OBJEXT) \
+	NoPageIDWrapper.$(OBJEXT) LogoPlottingWrapper.$(OBJEXT) \
+	LegendVisitorWrapper.$(OBJEXT) \
+	ContinuousLegendMethodWrapper.$(OBJEXT) \
+	HistogramLegendMethodWrapper.$(OBJEXT) \
+	LegendMethodWrapper.$(OBJEXT) NoLogoPlottingWrapper.$(OBJEXT) \
+	UserLogoPlottingWrapper.$(OBJEXT) \
+	FortranViewNodeWrapper.$(OBJEXT) \
+	TransformationWrapper.$(OBJEXT) \
+	GeoRectangularProjectionWrapper.$(OBJEXT) \
+	MercatorProjectionWrapper.$(OBJEXT) \
+	PolarStereographicProjectionWrapper.$(OBJEXT) \
+	ImportActionWrapper.$(OBJEXT) ImportPlotWrapper.$(OBJEXT) \
+	TableDecoderWrapper.$(OBJEXT) InputDataWrapper.$(OBJEXT) \
+	NetcdfDecoderWrapper.$(OBJEXT) SymbolPlottingWrapper.$(OBJEXT) \
+	WindWrapper.$(OBJEXT) ContourWrapper.$(OBJEXT) \
+	NoIsoPlotWrapper.$(OBJEXT) IsoPlotWrapper.$(OBJEXT) \
+	ContourMethodWrapper.$(OBJEXT) Akima474MethodWrapper.$(OBJEXT) \
+	Akima760MethodWrapper.$(OBJEXT) HiLoBaseWrapper.$(OBJEXT) \
+	NoIsoShadingWrapper.$(OBJEXT) IsoShadingWrapper.$(OBJEXT) \
+	PolyShadingTechniqueWrapper.$(OBJEXT) \
+	ShadingTechniqueWrapper.$(OBJEXT) \
+	MarkerShadingTechniqueWrapper.$(OBJEXT) \
+	GridShadingWrapper.$(OBJEXT) \
+	PolyShadingMethodWrapper.$(OBJEXT) \
+	AutomaticContourMethodWrapper.$(OBJEXT) \
+	HighHiLoWrapper.$(OBJEXT) LowHiLoWrapper.$(OBJEXT) \
+	CellShadingWrapper.$(OBJEXT) ValuePlotWrapper.$(OBJEXT) \
+	HatchPolyShadingMethodWrapper.$(OBJEXT) \
+	DotPolyShadingMethodWrapper.$(OBJEXT) \
+	SampleContourMethodWrapper.$(OBJEXT) \
+	ValuePlotMethodWrapper.$(OBJEXT) \
+	ValuePlotBaseWrapper.$(OBJEXT) NoHiLoWrapper.$(OBJEXT) \
+	MarkerValuePlotMethodWrapper.$(OBJEXT) \
+	BothValuePlotMethodWrapper.$(OBJEXT) \
+	CartesianTransformationWrapper.$(OBJEXT) HiLoWrapper.$(OBJEXT) \
+	NoValuePlotWrapper.$(OBJEXT) NoHiLoMarkerWrapper.$(OBJEXT) \
+	HiLoMarkerWrapper.$(OBJEXT) HiLoBothWrapper.$(OBJEXT) \
+	HiLoNumberWrapper.$(OBJEXT) HiLoTextWrapper.$(OBJEXT) \
+	HiLoTechniqueWrapper.$(OBJEXT) YCoordinateWrapper.$(OBJEXT) \
+	YRegularCoordinateWrapper.$(OBJEXT) \
+	HiLoMarkerBaseWrapper.$(OBJEXT) \
+	YDateCoordinateWrapper.$(OBJEXT) \
+	YLogarithmicCoordinateWrapper.$(OBJEXT) \
+	XHyperCoordinateWrapper.$(OBJEXT) \
+	YHyperCoordinateWrapper.$(OBJEXT) XCoordinateWrapper.$(OBJEXT) \
+	XRegularCoordinateWrapper.$(OBJEXT) \
+	XDateCoordinateWrapper.$(OBJEXT) \
+	XLogarithmicCoordinateWrapper.$(OBJEXT) \
+	CoastlinesWrapper.$(OBJEXT) CoastPlottingWrapper.$(OBJEXT) \
+	NoCoastPlottingWrapper.$(OBJEXT) BoundariesWrapper.$(OBJEXT) \
+	NoBoundariesWrapper.$(OBJEXT) GridPlottingWrapper.$(OBJEXT) \
+	NoGridPlottingWrapper.$(OBJEXT) LabelPlottingWrapper.$(OBJEXT) \
+	NoLabelPlottingWrapper.$(OBJEXT) \
+	GeoPointsDecoderWrapper.$(OBJEXT) WindModeWrapper.$(OBJEXT) \
+	SDWindModeWrapper.$(OBJEXT) VDWindModeWrapper.$(OBJEXT) \
+	UVWindModeWrapper.$(OBJEXT) ColourTechniqueWrapper.$(OBJEXT) \
+	CountSelectionTypeWrapper.$(OBJEXT) \
+	IntervalSelectionTypeWrapper.$(OBJEXT) \
+	LevelListSelectionTypeWrapper.$(OBJEXT) \
+	LevelSelectionWrapper.$(OBJEXT) \
+	CalculateColourTechniqueWrapper.$(OBJEXT) \
+	ListColourTechniqueWrapper.$(OBJEXT) IsoLabelWrapper.$(OBJEXT) \
+	NoIsoLabelWrapper.$(OBJEXT) TextVisitorWrapper.$(OBJEXT) \
+	SymbolModeWrapper.$(OBJEXT) SymbolTableModeWrapper.$(OBJEXT) \
+	SymbolAdvancedTableModeWrapper.$(OBJEXT) \
+	SymbolIndividualModeWrapper.$(OBJEXT) \
+	BaseDriverWrapper.$(OBJEXT) \
+	NoOutLayerTechniqueWrapper.$(OBJEXT) \
+	SimpleOutLayerTechniqueWrapper.$(OBJEXT) \
+	HeightTechniqueWrapper.$(OBJEXT) \
+	CalculateHeightTechniqueWrapper.$(OBJEXT) \
+	ListHeightTechniqueWrapper.$(OBJEXT) \
+	IsoHighlightWrapper.$(OBJEXT) NoIsoHighlightWrapper.$(OBJEXT) \
+	PreviewVisitorWrapper.$(OBJEXT) \
+	NoPreviewVisitorWrapper.$(OBJEXT) \
+	MagnifierVisitorWrapper.$(OBJEXT) \
+	NoMagnifierVisitorWrapper.$(OBJEXT) AxisWrapper.$(OBJEXT) \
+	OriginMarkerWrapper.$(OBJEXT) NoOriginMarkerWrapper.$(OBJEXT) \
+	DotOriginMarkerWrapper.$(OBJEXT) \
+	CircleOriginMarkerWrapper.$(OBJEXT) \
+	CalmIndicatorWrapper.$(OBJEXT) \
+	NoCalmIndicatorWrapper.$(OBJEXT) \
+	PostScriptDriverWrapper.$(OBJEXT) BaseDriverWrapper.$(OBJEXT) \
+	KMLDriverWrapper.$(OBJEXT) SVGDriverWrapper.$(OBJEXT) \
+	WindPlottingWrapper.$(OBJEXT) FlagPlottingWrapper.$(OBJEXT) \
+	ArrowPlottingWrapper.$(OBJEXT) CitiesWrapper.$(OBJEXT) \
+	NoCitiesWrapper.$(OBJEXT) NoBinningObjectWrapper.$(OBJEXT) \
+	BinningObjectWrapper.$(OBJEXT) GraphPlottingWrapper.$(OBJEXT) \
+	CurveWrapper.$(OBJEXT) CurveAreaWrapper.$(OBJEXT) \
+	GraphWrapper.$(OBJEXT) GraphArrowWrapper.$(OBJEXT) \
+	GraphFlagWrapper.$(OBJEXT) GraphShadeWrapper.$(OBJEXT) \
+	NoGraphShadeWrapper.$(OBJEXT) GraphShadeStyleWrapper.$(OBJEXT) \
+	DotGraphShadeStyleWrapper.$(OBJEXT) \
+	HatchGraphShadeStyleWrapper.$(OBJEXT) BarWrapper.$(OBJEXT) \
+	MetaDataWrapper.$(OBJEXT) AxisMethodWrapper.$(OBJEXT) \
+	PositionListAxisMethodWrapper.$(OBJEXT) \
+	DateAxisMethodWrapper.$(OBJEXT) \
+	LogarithmicAxisMethodWrapper.$(OBJEXT) \
+	HyperAxisMethodWrapper.$(OBJEXT) $(am__objects_2) \
+	$(am__objects_3) $(am__objects_4) $(am__objects_5) \
+	$(am__objects_6) $(am__objects_7)
+nodist_libMagWrapper_a_OBJECTS = $(am__objects_8)
+libMagWrapper_a_OBJECTS = $(am_libMagWrapper_a_OBJECTS) \
+	$(nodist_libMagWrapper_a_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libMagWrapper_a_SOURCES) $(nodist_libMagWrapper_a_SOURCES)
+DIST_SOURCES = $(libMagWrapper_a_SOURCES)
+HEADERS = $(include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+include_HEADERS = MagPlus.h MagRequest.h 
+MY_SOURCES = MagPlus.cc
+MY_SOURCES_NODIST = MvRootSceneNodeWrapper.cc \
+	FortranSceneNodeWrapper.cc PageIDWrapper.cc NoPageIDWrapper.cc \
+	LogoPlottingWrapper.cc LegendVisitorWrapper.cc \
+	ContinuousLegendMethodWrapper.cc \
+	HistogramLegendMethodWrapper.cc LegendMethodWrapper.cc \
+	NoLogoPlottingWrapper.cc UserLogoPlottingWrapper.cc \
+	FortranViewNodeWrapper.cc TransformationWrapper.cc \
+	GeoRectangularProjectionWrapper.cc \
+	MercatorProjectionWrapper.cc \
+	PolarStereographicProjectionWrapper.cc ImportActionWrapper.cc \
+	ImportPlotWrapper.cc TableDecoderWrapper.cc \
+	InputDataWrapper.cc NetcdfDecoderWrapper.cc \
+	SymbolPlottingWrapper.cc WindWrapper.cc ContourWrapper.cc \
+	NoIsoPlotWrapper.cc IsoPlotWrapper.cc ContourMethodWrapper.cc \
+	Akima474MethodWrapper.cc Akima760MethodWrapper.cc \
+	HiLoBaseWrapper.cc NoIsoShadingWrapper.cc IsoShadingWrapper.cc \
+	PolyShadingTechniqueWrapper.cc ShadingTechniqueWrapper.cc \
+	MarkerShadingTechniqueWrapper.cc GridShadingWrapper.cc \
+	PolyShadingMethodWrapper.cc AutomaticContourMethodWrapper.cc \
+	HighHiLoWrapper.cc LowHiLoWrapper.cc CellShadingWrapper.cc \
+	ValuePlotWrapper.cc HatchPolyShadingMethodWrapper.cc \
+	DotPolyShadingMethodWrapper.cc SampleContourMethodWrapper.cc \
+	ValuePlotMethodWrapper.cc ValuePlotBaseWrapper.cc \
+	NoHiLoWrapper.cc MarkerValuePlotMethodWrapper.cc \
+	BothValuePlotMethodWrapper.cc \
+	CartesianTransformationWrapper.cc HiLoWrapper.cc \
+	NoValuePlotWrapper.cc NoHiLoMarkerWrapper.cc \
+	HiLoMarkerWrapper.cc HiLoBothWrapper.cc HiLoNumberWrapper.cc \
+	HiLoTextWrapper.cc HiLoTechniqueWrapper.cc \
+	YCoordinateWrapper.cc YRegularCoordinateWrapper.cc \
+	HiLoMarkerBaseWrapper.cc YDateCoordinateWrapper.cc \
+	YLogarithmicCoordinateWrapper.cc XHyperCoordinateWrapper.cc \
+	YHyperCoordinateWrapper.cc XCoordinateWrapper.cc \
+	XRegularCoordinateWrapper.cc XDateCoordinateWrapper.cc \
+	XLogarithmicCoordinateWrapper.cc CoastlinesWrapper.cc \
+	CoastPlottingWrapper.cc NoCoastPlottingWrapper.cc \
+	BoundariesWrapper.cc NoBoundariesWrapper.cc \
+	GridPlottingWrapper.cc NoGridPlottingWrapper.cc \
+	LabelPlottingWrapper.cc NoLabelPlottingWrapper.cc \
+	GeoPointsDecoderWrapper.cc WindModeWrapper.cc \
+	SDWindModeWrapper.cc VDWindModeWrapper.cc UVWindModeWrapper.cc \
+	ColourTechniqueWrapper.cc CountSelectionTypeWrapper.cc \
+	IntervalSelectionTypeWrapper.cc \
+	LevelListSelectionTypeWrapper.cc LevelSelectionWrapper.cc \
+	CalculateColourTechniqueWrapper.cc \
+	ListColourTechniqueWrapper.cc IsoLabelWrapper.cc \
+	NoIsoLabelWrapper.cc TextVisitorWrapper.cc \
+	SymbolModeWrapper.cc SymbolTableModeWrapper.cc \
+	SymbolAdvancedTableModeWrapper.cc \
+	SymbolIndividualModeWrapper.cc BaseDriverWrapper.cc \
+	NoOutLayerTechniqueWrapper.cc \
+	SimpleOutLayerTechniqueWrapper.cc HeightTechniqueWrapper.cc \
+	CalculateHeightTechniqueWrapper.cc \
+	ListHeightTechniqueWrapper.cc IsoHighlightWrapper.cc \
+	NoIsoHighlightWrapper.cc PreviewVisitorWrapper.cc \
+	NoPreviewVisitorWrapper.cc MagnifierVisitorWrapper.cc \
+	NoMagnifierVisitorWrapper.cc AxisWrapper.cc \
+	OriginMarkerWrapper.cc NoOriginMarkerWrapper.cc \
+	DotOriginMarkerWrapper.cc CircleOriginMarkerWrapper.cc \
+	CalmIndicatorWrapper.cc NoCalmIndicatorWrapper.cc \
+	PostScriptDriverWrapper.cc BaseDriverWrapper.cc \
+	KMLDriverWrapper.cc SVGDriverWrapper.cc WindPlottingWrapper.cc \
+	FlagPlottingWrapper.cc ArrowPlottingWrapper.cc \
+	CitiesWrapper.cc NoCitiesWrapper.cc NoBinningObjectWrapper.cc \
+	BinningObjectWrapper.cc GraphPlottingWrapper.cc \
+	CurveWrapper.cc CurveAreaWrapper.cc GraphWrapper.cc \
+	GraphArrowWrapper.cc GraphFlagWrapper.cc GraphShadeWrapper.cc \
+	NoGraphShadeWrapper.cc GraphShadeStyleWrapper.cc \
+	DotGraphShadeStyleWrapper.cc HatchGraphShadeStyleWrapper.cc \
+	BarWrapper.cc MetaDataWrapper.cc AxisMethodWrapper.cc \
+	PositionListAxisMethodWrapper.cc DateAxisMethodWrapper.cc \
+	LogarithmicAxisMethodWrapper.cc HyperAxisMethodWrapper.cc \
+	$(am__append_1) $(am__append_2) $(am__append_3) \
+	$(am__append_4) $(am__append_5) $(am__append_6)
+later = TaylorProjectionWrapper.cc TaylorGridWrapper.cc PostScriptDriverWrapper.cc GDDriverWrapper.cc 
+
+#lib_LTLIBRARIES	= libMagWrapper.la
+lib_LIBRARIES = libMagWrapper.a
+libMagWrapper_a_SOURCES = $(MY_SOURCES)
+nodist_libMagWrapper_a_SOURCES = $(MY_SOURCES_NODIST)
+AM_CPPFLAGS = -DUSE_NEW_IO ${GRIBAPI_CXXFLAGS} -DMETVIEW \
+	-DH_INCLUDES_CC -DGLX_PROBLEMS -DMAGINT_IS_INT \
+	-DREAL_IS_DOUBLE $(PLATFORM_DEFINES_MARS) \
+	-I$(top_srcdir)/src/basic -I$(top_srcdir)/src/libTable \
+	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers \
+	-I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/visualisers \
+	-I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src \
+	-I$(METVIEW_HOME)/src/libMetview -I$(METVIEW_HOME)/src/libMars \
+	-I$(METVIEW_HOME)/src/libUtil $(am__append_7) $(am__append_8)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/libMagWrapper/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign src/libMagWrapper/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLIBRARIES: $(lib_LIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(libdir)'"; \
+	  $(INSTALL_DATA) $$list2 "$(DESTDIR)$(libdir)" || exit $$?; }
+	@$(POST_INSTALL)
+	@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
+	for p in $$list; do \
+	  if test -f $$p; then \
+	    $(am__strip_dir) \
+	    echo " ( cd '$(DESTDIR)$(libdir)' && $(RANLIB) $$f )"; \
+	    ( cd "$(DESTDIR)$(libdir)" && $(RANLIB) $$f ) || exit $$?; \
+	  else :; fi; \
+	done
+
+uninstall-libLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(libdir)' && rm -f "$$files" )"; \
+	cd "$(DESTDIR)$(libdir)" && rm -f $$files
+
+clean-libLIBRARIES:
+	-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+libMagWrapper.a: $(libMagWrapper_a_OBJECTS) $(libMagWrapper_a_DEPENDENCIES) 
+	$(AM_V_at)-rm -f libMagWrapper.a
+	$(AM_V_AR)$(libMagWrapper_a_AR) libMagWrapper.a $(libMagWrapper_a_OBJECTS) $(libMagWrapper_a_LIBADD)
+	$(AM_V_at)$(RANLIB) libMagWrapper.a
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima474MethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima760MethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ArrowPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AutomaticContourMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AxisMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AxisWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BarWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BaseDriverWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BinningObjectWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BothValuePlotMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoundariesWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CairoDriverWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CalculateColourTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CalculateHeightTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CalmIndicatorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CartesianTransformationWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CellShadingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CircleOriginMarkerWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CitiesWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CoastPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CoastlinesWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ColourTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ContinuousLegendMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ContourMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ContourWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CountSelectionTypeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CurveAreaWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CurveWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DateAxisMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DateGribLoopStepWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DotGraphShadeStyleWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DotOriginMarkerWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DotPolyShadingMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FlagPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FortranSceneNodeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FortranViewNodeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GeoPointsDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GeoRectangularProjectionWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphArrowWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphFlagWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphShadeStyleWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphShadeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribAddressByteModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribAddressModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribAddressRecordModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribLoopStepWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GribLoopWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GridPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GridShadingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HatchGraphShadeStyleWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HatchPolyShadingMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HeightTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoBaseWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoBothWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoMarkerBaseWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoMarkerWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoNumberWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoTextWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HighHiLoWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HistogramLegendMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HyperAxisMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImportActionWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImportPlotWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/InputDataWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IntervalSelectionTypeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoHighlightWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoLabelWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoPlotWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoShadingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/KMLDriverWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LabelPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LegendMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LegendVisitorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LevelListSelectionTypeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LevelSelectionWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ListColourTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ListHeightTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LogarithmicAxisMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LogoPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LowHiLoWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagPlus.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagnifierVisitorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MarkerShadingTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MarkerValuePlotMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MercatorProjectionWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetaDataWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MvRootSceneNodeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoMatrixInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoPolarMatrixInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeoVectorInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfGeopointsInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfMatrixInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfOrcaInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfVectorInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NetcdfXYpointsInterpretorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoBinningObjectWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoBoundariesWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoCalmIndicatorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoCitiesWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoCoastPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoGraphShadeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoGridPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoHiLoMarkerWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoHiLoWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoIsoHighlightWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoIsoLabelWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoIsoPlotWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoIsoShadingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoLabelPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoLogoPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoMagnifierVisitorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoOriginMarkerWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoOutLayerTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoPageIDWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoPreviewVisitorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoValuePlotWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OdaGeoDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OdaXYDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OriginMarkerWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PageIDWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ParamGribLoopStepWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolarStereographicProjectionWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolyShadingMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolyShadingTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PositionListAxisMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PostScriptDriverWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PreviewVisitorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4BonneWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4CollignonWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4EPSG32661Wrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4EPSG3857Wrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4EPSG4326Wrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4GeosWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4GoodeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4LambertWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4MollweideWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4PolarNorthWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Proj4ProjectionWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SDWindModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SVGDriverWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SampleContourMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ShadingTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SimpleOutLayerTechniqueWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolAdvancedTableModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolIndividualModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolTableModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TableDecoderWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TextVisitorWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TransformationWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/UVWindModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/UserLogoPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/VDWindModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ValuePlotBaseWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ValuePlotMethodWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ValuePlotWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindModeWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindPlottingWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XDateCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XHyperCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XLogarithmicCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/XRegularCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YDateCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YHyperCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YLogarithmicCoordinateWrapper.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/YRegularCoordinateWrapper.Po at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLIBRARIES clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS uninstall-libLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libLIBRARIES clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-libLIBRARIES install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS \
+	uninstall-libLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/libTable/Makefile.am b/src/libTable/Makefile.am
new file mode 100755
index 0000000..72a98c1
--- /dev/null
+++ b/src/libTable/Makefile.am
@@ -0,0 +1,17 @@
+noinst_LTLIBRARIES	= libTable.la
+
+include_H	= TableReader.h
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	=
+else
+include_HEADERS =
+noinst_HEADERS	= $(include_H)
+endif
+
+libTable_la_SOURCES	= TableReader.cc
+
+libTable_la_LDFLAGS	= -no-undefined -no-install
+AM_CPPFLAGS		= -I$(top_srcdir)/src/libTable
+EXTRA_DIST		=
diff --git a/src/libTable/Makefile.in b/src/libTable/Makefile.in
new file mode 100644
index 0000000..fb616dd
--- /dev/null
+++ b/src/libTable/Makefile.in
@@ -0,0 +1,629 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/libTable
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libTable_la_LIBADD =
+am_libTable_la_OBJECTS = TableReader.lo
+libTable_la_OBJECTS = $(am_libTable_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libTable_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(libTable_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libTable_la_SOURCES)
+DIST_SOURCES = $(libTable_la_SOURCES)
+am__include_HEADERS_DIST = TableReader.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = TableReader.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libTable.la
+include_H = TableReader.h
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = 
+libTable_la_SOURCES = TableReader.cc
+libTable_la_LDFLAGS = -no-undefined -no-install
+AM_CPPFLAGS = -I$(top_srcdir)/src/libTable
+EXTRA_DIST = 
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libTable/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/libTable/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libTable.la: $(libTable_la_OBJECTS) $(libTable_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libTable_la_LINK)  $(libTable_la_OBJECTS) $(libTable_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TableReader.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/libTable/TableReader.cc b/src/libTable/TableReader.cc
new file mode 100644
index 0000000..a3c5fd7
--- /dev/null
+++ b/src/libTable/TableReader.cc
@@ -0,0 +1,702 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2011 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+
+#include "TableReader.h"
+
+
+
+void TableReader::resizeDecoders(unsigned int numNeeded)
+{
+    // do we need to resize our list of decoders?
+
+    if ( numNeeded > decoderSets_.size())
+    {
+        decoderSets_.resize (numNeeded);
+        names_.resize       (numNeeded, NULL);
+        types_.resize       (numNeeded, TABFIELD_NUMBER);
+        namesAll_.resize    (numNeeded, "");
+    }
+}
+
+
+void TableReader::setFieldContainer(int index, string &name, vector<double>& container, double outputMissingIndicator)
+{
+    if (index == -1)  // is the user wanting to find a field with the given name?
+    {
+        int foundIndex = indexOfField(name);  // try to find it
+        
+        if (foundIndex == -1)  // not found?
+        {
+            setError ("Cannot find field with name " + name + " -  will not be stored.");
+            return;
+        }
+
+        else
+        {
+            index = foundIndex;  // we found it - so use this index
+        }
+    }
+
+
+
+    // do we need to resize our list of decoders to accommodate this one?
+
+    resizeDecoders (index+1);  // e.g. if index==2, then we need 3 decoders (0-indexed)
+
+
+    // add the decoder to the appropriate place in our list
+
+    TableDoubleVectorElementDecoder *decoder = new TableDoubleVectorElementDecoder (container, outputMissingIndicator);
+    TableElementDecoder *genericDecoder  = dynamic_cast<TableElementDecoder*> (decoder);
+    decoderSets_[index].push_back(genericDecoder); //.push_back(genericDecoder);
+    names_[index] = &name;
+}
+
+
+void TableReader::setFieldContainer (int index, string &name, vector<string>& container, string outputMissingIndicator)
+{
+	 if (index == -1)  // is the user wanting to find a field with the given name?
+	    {
+	        int foundIndex = indexOfField(name);  // try to find it
+
+	        if (foundIndex == -1)  // not found?
+	        {
+	            setError ("Cannot find field with name " + name + " -  will not be stored.");
+	            return;
+	        }
+
+	        else
+	        {
+	            index = foundIndex;  // we found it - so use this index
+	        }
+	    }
+
+    // do we need to resize our list of decoders to accommodate this one?
+
+    resizeDecoders (index+1);  // e.g. if index==2, then we need 3 decoders (0-indexed)
+
+
+    // add the decoder to the appropriate place in our list
+
+    TableStringVectorElementDecoder *decoder = new TableStringVectorElementDecoder (container, outputMissingIndicator);
+    TableElementDecoder *genericDecoder  = dynamic_cast<TableElementDecoder*> (decoder);
+    decoderSets_[index].push_back(genericDecoder); //.push_back(genericDecoder);
+    names_[index] = &name;
+}
+
+
+
+
+
+// ---------------------------------------------------------------------------
+// TableReader::splitLine
+// takes a text line and finds all the delimited strings within it.
+//  NOTE: this function is destructive to the input string!
+// ---------------------------------------------------------------------------
+
+void TableReader::splitLine (char *line, vector<char *>& tokens)
+{
+    char *current = line;
+    char *token   = current;
+
+    while (*current != '\0')
+    {
+        if (*current == delimiter_)   // reached the end of a token?
+        {
+            *current = '\0';          // yes - terminate the token string
+            tokens.push_back(token);  // store a pointer to it
+            token = current + 1;      // start the next token
+        }
+        
+        current++;  // advance to the next character
+    }
+    
+    tokens.push_back(token);  // store a pointer to the last token
+}
+
+
+// ---------------------------------------------------------------------------
+// TableReader::splitLineConsecutiveDelimiters
+// Takes a text line and finds all the delimited strings within it.
+// Version which allows consecutive delimiters to be considered as one.
+//  NOTE: this function is destructive to the input string!
+// ---------------------------------------------------------------------------
+
+void TableReader::splitLineConsecutiveDelimiters (char *line, vector<char *>& tokens)
+{
+    char *current = line;
+    char *token   = current;
+
+    if (*current == '\0')  // return nothing if it is a blank line
+        return;
+
+
+    while (*current != '\0')
+    {
+        if (*current == delimiter_)   // reached the end of a token?
+        {
+            *current = '\0';          // yes - terminate the token string
+
+            current++;                // quick look at the next character
+            while (*current != '\0' && *current == delimiter_)  // skip all consecutive delimiters
+                current++;
+            current--;                // step back one character
+
+            if (token[0] != '\0')     // when treating consecutive delimiters as one, we do not have missing values
+                tokens.push_back(token);  // store a pointer to it
+            token = current + 1;      // start the next token
+        }
+        
+        current++;  // advance to the next character
+    }
+    
+    if (token[0] != '\0')           // safeguard against stray delimiters at the end of the line
+        tokens.push_back(token);  // store a pointer to the last token
+}
+
+
+
+
+
+void TableReader::ensureHaveMetaData()
+{
+    if (!gotMetaData_)  // caller should have retrieved the meta-data already
+    {
+        string msg;
+
+        if (!getMetaData(msg))
+        {
+            setError(msg);
+        }
+    }
+}
+
+vector<TableReader::eTableReaderFieldType>& TableReader::fieldTypes()
+{
+    ensureHaveMetaData();
+
+    return types_;
+}
+
+
+vector<string>& TableReader::fieldNames()
+{
+    ensureHaveMetaData();
+
+    return namesAll_;
+}
+
+
+map<string, string>& TableReader::userMetaData()
+{
+    ensureHaveMetaData();
+
+    return userMetaData_;
+}
+
+
+int TableReader::numRecords()
+{
+    ensureHaveMetaData();
+
+    return numRecords_;
+}
+
+
+
+int TableReader::indexOfField   (string &name)
+{
+    ensureHaveMetaData();
+
+
+    // find which field has the name we're looking for
+    
+    for (vector<string *>::size_type i = 0 ; i < names_.size(); i++)
+    {
+        if (namesAll_[i] == name)
+            return i;   // found it - return its index
+    }
+
+
+    // if we got this far, then we did not find it
+    
+    return -1;
+}
+
+
+
+
+
+
+// ---------------------------------------------------------------------------
+// TableReader::guessFieldType
+// takes an element and tries to decide which data type it is, e.g. number
+// ---------------------------------------------------------------------------
+
+TableReader::eTableReaderFieldType TableReader::guessFieldType(char *str)
+{
+    if (str)
+    {
+        char *pch = str;
+
+        while(*pch)
+        {
+            int ch = *pch;  // any character not part of a proper number format means this is a string
+
+            if (!isdigit(ch) && (ch != 'e') && (ch != 'E') && (ch != '.') && (ch != '+') && (ch != '-'))
+                return TableReader::TABFIELD_STRING;
+            
+            pch++;
+        }
+    }
+    
+    return TableReader::TABFIELD_NUMBER;
+}
+
+
+
+
+
+int TableReader::nextLineTokens(char *line, size_t sizeOfLine, vector<char *>& tokens)
+{
+    // skip blank lines
+
+/*    bool gotLine = true;
+    line[0] = '\0';
+
+    while (line[0] == '\0' && gotLine)
+    {
+        gotLine = f_.getline(line, sizeOfLine);
+        numBadLines_++;
+    }
+*/
+
+    // read the next line into our buffer
+
+//    if (gotLine)
+    if (f_.getline(line, sizeOfLine))
+    {
+        // parse the line into tokens
+
+        streamsize numread = f_.gcount ();
+
+        if ((numread >= 2) && (line[numread-1] == '\0') &&  (line[numread-2] == '\r'))    // remove extraneous newline characters from Windows
+            line[numread-2] = '\0';
+
+        if (consecutiveDelimitersAsOne_)
+            splitLineConsecutiveDelimiters (line, tokens);
+        else
+            splitLine (line, tokens);
+
+        return true;
+    }
+
+    else
+    {
+        return 0;
+    }
+}
+
+
+
+// ---------------------------------------------------------------------------
+// TableReader::readUserMetaData
+// reads all the lines of user meta-data and stores them in userMetaData_.
+// Meta-data must be of the form
+// PARAM1=VALUE1 PARAM2=VALUE2
+// ---------------------------------------------------------------------------
+
+bool TableReader::readUserMetaData (char *line, size_t sizeOfLine, string &errorMessage)
+{
+    int currentRow      = 1;
+    char oldDelimiter   = delimiter_;                  // store because we will over-ride it
+    bool oldConsecutive = consecutiveDelimitersAsOne_; // store because we will over-ride it
+
+    // we parse each line in two steps:
+    //   1) split into a vector of PARAMx=VALUEX strings
+    //   2) split each of these into 2 strings and add them to the meta-data map
+
+    setConsecutiveDelimitersAsOne(true); // allows the user more flexibility
+
+    for (vector<int>::size_type r = 0 ; r < userMetaDataRows_.size(); r++)  // for each line of meta-data...
+    {
+        skipLines (userMetaDataRows_[r] - currentRow, line, sizeOfLine);  // get to the right line
+        setDelimiter(' ');
+
+
+        vector<char *> tokens;
+
+        if (nextLineTokens(line, sizeOfLine, tokens) > 0)
+        {
+            // now have one token per PARAM=VALUE - split each one into a pair
+
+            setDelimiter('=');
+
+            for (vector<string *>::size_type j = 0 ; j < tokens.size(); j++)
+            {
+                vector<char *> tokens2;
+
+                splitLineConsecutiveDelimiters (tokens[j], tokens2);
+
+                if (tokens2.size() != 2)  // should only be 2 tokens: PARAM and VALUE
+                {
+                    char msg [2000];
+                    sprintf (msg, "Error parsing parameter %d: '%s'", j+1, tokens[j]);
+                    errorMessage = msg;
+                    return false;
+                }
+                else
+                {
+                    userMetaData_[tokens2[0]] = tokens2[1];
+                }
+            }
+        }
+
+
+        currentRow = userMetaDataRows_[r] + 1;  // store which line we're at
+    }
+
+
+
+    setDelimiter(oldDelimiter);                     // restore
+    setConsecutiveDelimitersAsOne(oldConsecutive);  // restore
+    
+    return true;
+}
+
+
+// ---------------------------------------------------------------------------
+// TableReader::skipLines
+// reads and ignore the specified number of rows. Requires a buffer to read
+// into.
+// ---------------------------------------------------------------------------
+
+void TableReader::skipLines (int linesToSkip, char *line, size_t sizeOfLine)
+{
+    for (int i = 0; i < linesToSkip; i++)
+    {
+        f_.getline(line, sizeOfLine);
+    }
+}
+
+
+// ---------------------------------------------------------------------------
+// TableReader::getMetaData
+// reads the first few lines of the file and determines the number and type
+// of columns. Also, optionally, reads any lines of user meta-data from the
+// file.
+// ---------------------------------------------------------------------------
+
+bool TableReader::getMetaData(string &errorMessage)
+{
+
+    if (gotMetaData_)  // we should only need to get the meta-data once
+        return true;
+
+
+    // check for previous errors which we should report
+    
+    if (errorCode_)
+    {
+        errorMessage = errorMsg_;
+        clearError();
+        return false;
+    }
+
+
+
+    const int MAX_CHARS_IN_LINE = 1024*10;
+    char line[MAX_CHARS_IN_LINE];
+
+
+    // basic sanity checks
+
+    if (path().empty())
+    {
+        errorMessage = "TableReader: Path is empty - will not read.";
+        return false;
+    }
+
+
+    // try to open the file for reading
+
+    f_.open(path().c_str());
+
+    if (f_.fail())
+    {
+        errorMessage = "TableReader: Could not open table file: " + path();
+        return false;
+    }
+
+
+    // count the number of lines
+
+    int numLines = 0;
+
+    while (f_.getline(line, sizeof(line)))    //-- first count the lines
+        numLines++;
+
+    numRecords_ = numLines - headerRow() - dataRowOffset() + 1;  // how many actual records are there?
+
+
+
+    // rewind the file pointer before we start again
+
+    f_.clear();
+    f_.seekg(0, ios::beg);
+
+
+    // read the user meta-data if it exists
+
+    if (!userMetaDataRows_.empty())
+    {
+        if (!readUserMetaData (line, sizeof(line), errorMessage))
+        {
+            return false;
+        }
+
+
+
+        // rewind the file pointer before we start again
+
+        f_.clear();
+        f_.seekg(0, ios::beg);
+    }
+
+
+
+
+    // get to either the header row (if there is one) or the start of the data
+
+    if (headerRow() > 0)                              // there is a header row
+        skipLines (headerRow()-1, line, sizeof(line));
+    else if (dataRowOffset() > 1)                     // no header - get to start of data
+        skipLines (dataRowOffset()-1, line, sizeof(line));
+
+
+    dataStart_ = f_.tellg();  // make a note of where the data starts (may be changed if we have a header line)
+
+
+    int numLinesToCheck = 1 + (headerRow()>0 ? 1 : 0); // how many lines to read?
+    
+    if (numLinesToCheck > numLines)
+        numLinesToCheck = numLines;
+
+
+    for (int i = 0; i < numLinesToCheck; i++)
+    {
+        // read the line into a buffer and split it into tokens
+        
+        vector<char *> tokens;
+
+        if (nextLineTokens(line, sizeof(line), tokens) > 0)
+        {
+            if (i == 0 )
+            {
+                resizeDecoders (tokens.size());  // ensure our array of decoders is big enough to handle all the fields
+            }
+
+            if ((i == 0) && headerRow()>0)   // parse a header row?
+            {
+                for (vector<string *>::size_type j = 0 ; j < tokens.size(); j++)
+                {
+                    namesAll_[j] = tokens[j];
+                }
+
+                skipLines (dataRowOffset()-1, line, sizeof(line));  // go to start of data
+                dataStart_ = f_.tellg();  // make a note of where the data starts
+            }
+
+            else  // this is a data row
+            {
+                if (types_.size() != tokens.size())
+                {
+                    errorMessage = "Not the same number of elements in the first 2 lines of table. Check file format parameters.";
+                    f_.close();  // close the input file
+                    return false;
+                }
+
+
+                // determine which data type each token is
+
+                for (vector<eTableReaderFieldType>::size_type j = 0 ; j < tokens.size(); j++)
+                {
+                    types_[j] = guessFieldType(tokens[j]);
+                }
+            }
+        }
+    }
+
+
+
+    gotMetaData_ = true;
+    
+    return true;
+}
+
+
+
+
+bool TableReader::read(string &errorMessage)
+{
+    const int MAX_CHARS_IN_LINE = 1024*10;
+    char line[MAX_CHARS_IN_LINE];
+
+
+    // check for previous errors which we should report
+    
+    if (errorCode_)
+    {
+        errorMessage = errorMsg_;
+        clearError();
+        return false;
+    }
+
+
+
+    // basic sanity checks
+
+    if (path().empty())
+    {
+        errorMessage = "TableReader: Path is empty - will not read.";
+        return false;
+    }
+
+    if (decoderSets_.size() == 0)
+    {
+        errorMessage = "TableReader: No decoders installed - will not read.";
+        return false;
+    }
+
+
+    if (!getMetaData(errorMessage))  // ensure we have the meta-data. This will also open the file (f_)
+        return false;
+
+
+
+
+    // set the header names?
+
+    for (vector<string *>::size_type j = 0 ; j < namesAll_.size(); j++)
+    {
+        if (names_[j] != NULL)
+        {
+            *(names_[j]) = namesAll_[j];
+        }
+    }
+
+
+
+
+    // initialise our containers to hold the correct number of elements
+
+//    for (i = 0 ; i < decoders_.size(); i++)
+    for (vector<TableElementDecoders>::iterator decoderSet = decoderSets_.begin(); decoderSet != decoderSets_.end(); ++decoderSet)
+    {
+        for (TableElementDecoders::iterator decoder = (*decoderSet).begin(); decoder != (*decoderSet).end(); ++decoder)
+        {
+            if (*decoder != NULL)
+            {
+                (*decoder)->initialise(numRecords_);
+            }
+        }
+    }
+
+
+
+    // rewind the file pointer before we start again
+
+    f_.clear();
+    f_.seekg(dataStart_, ios::beg);  // set to start of the data (determined by getMetaData())
+
+
+
+    vector<char *> tokens;
+
+    for (int i = 0; i < numRecords_; i++)
+    {
+        // read the line into a buffer and split it into tokens
+
+        tokens.clear();
+
+        if (nextLineTokens(line, sizeof(line), tokens) > 0)
+        {
+            if (tokens.size() != decoderSets_.size())  // only do something if we have the right number of tokens
+            {
+                if (tokens.size() == 0) // blank line?
+                {
+                    char *empty = "";
+
+                    // if we are only reading one column, then it could be a missing value
+                    if (decoderSets_.size() == 1)
+                    {
+                        tokens.push_back(empty);
+                    }
+
+                    // otherwise ignore it  (is this too generous of us??)
+                    else
+                    {
+                        continue;
+                    }
+                }
+                else  // otherwise, the disparity in numbers indicates a problem
+                {
+                    char msg[128];
+                    sprintf (msg, "TableReader: record %d has %u elements, but the first record has %u. Failed to read.", i+1, (unsigned int)tokens.size(), (unsigned int)decoderSets_.size());
+                    errorMessage = msg;
+                    f_.close();  // close the input file
+                    return false;
+                }
+            }
+
+
+            // decode the data with their various decoders - one set of decoders for each field
+
+            vector<char *>::iterator s = tokens.begin();
+
+            for (vector<TableElementDecoders>::iterator decoderSet = decoderSets_.begin(); decoderSet != decoderSets_.end(); ++decoderSet)
+            {
+                for (TableElementDecoders::iterator decoder = (*decoderSet).begin(); decoder != (*decoderSet).end(); ++decoder)
+                {
+                    if (*decoder != NULL)
+                    {
+                        //string str(*s);
+                        (*decoder)->addValue(*s);
+                    }
+                }
+                s++;
+            }
+        }
+    }
+
+    f_.close();  // close the input file
+
+    return true;
+}
diff --git a/src/libTable/TableReader.h b/src/libTable/TableReader.h
new file mode 100644
index 0000000..3717f21
--- /dev/null
+++ b/src/libTable/TableReader.h
@@ -0,0 +1,210 @@
+/***************************** LICENSE START ***********************************
+
+ Copyright 2012 ECMWF and INPE. This software is distributed under the terms
+ of the Apache License version 2.0. In applying this license, ECMWF does not
+ waive the privileges and immunities granted to it by virtue of its status as
+ an Intergovernmental Organization or submit itself to any jurisdiction.
+
+ ***************************** LICENSE END *************************************/
+
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2011 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+#ifndef TableReader_H
+#define TableReader_H
+
+#include <vector>
+#include <fstream>
+#include <cstdlib>
+#include <string>
+#include <map>
+
+using namespace std;
+
+
+/*! -----------------------------------------------------------------
+    \class TableFormatAttributes
+    Base lass to handle the different ways of specifying how a table
+    file is formatted.
+   ----------------------------------------------------------------- */
+
+class TableFormatAttributes
+{
+public:
+
+    TableFormatAttributes () : delimiter_(','), headerRow_(1), consecutiveDelimitersAsOne_(false), dataRowOffset_(0) {}
+
+    void setPath          (string &path)     { path_          = path;      }
+    void setPath          (const char *path) { path_          = string(path); }
+    void setDelimiter     (char delimiter)   { delimiter_     = delimiter; }
+    void setHeaderRow     (int  headerRow)   { headerRow_     = headerRow; }
+    void setDataRowOffset (int  offset)      { dataRowOffset_ = offset; }
+    void setConsecutiveDelimitersAsOne (bool consecutive) { consecutiveDelimitersAsOne_ = consecutive; }
+    void setUserMetaDataRows (vector<int> &rows){ userMetaDataRows_ = rows; }
+
+    string path ()                     { return path_;      }
+    int    headerRow()                 { return headerRow_; }
+    int    dataRowOffset()             { return dataRowOffset_; }
+    vector<int> userMetaDataRows()     { return userMetaDataRows_; }
+
+
+protected       :
+    string path_;
+    char delimiter_;
+    int  headerRow_;
+    bool consecutiveDelimitersAsOne_;
+    int  dataRowOffset_;
+    vector<int> userMetaDataRows_;
+};
+
+
+
+
+/*! -----------------------------------------------------------------
+    \class TableElementDecoder
+    Base class to handle the decoding of a single element in a table
+    (e.g. CSV). Derived classes should handle the decoding of
+    particular data types (e.g. double, string).
+   ----------------------------------------------------------------- */
+
+class TableElementDecoder
+{
+public:
+    TableElementDecoder() : currentIndex_(0) {};
+    virtual ~TableElementDecoder(){}
+
+    virtual void initialise    (int numValues) = 0;
+    virtual void addValue      (char  *value)  = 0;
+    //virtual void decodeElement (char *element) = 0;
+
+protected:
+    int currentIndex_;
+};
+
+
+/*! -----------------------------------------------------------------
+    \class TableDoubleVectorElementDecoder
+    Derived class to handle the decoding of numeric data from a 
+    table file. The data will be put into a vector of doubles.
+   ----------------------------------------------------------------- */
+
+class TableDoubleVectorElementDecoder : public TableElementDecoder
+{
+public:
+    TableDoubleVectorElementDecoder(vector<double>& target, double outMiss) : target_(target), outputMissingIndicator_(outMiss)  {};
+
+    void initialise (int numValues) { target_.reserve(numValues); }
+    void addValue   (char *value)   { target_.push_back((value[0] != '\0') ? atof(value) : outputMissingIndicator_); }
+
+private:
+    vector<double>& target_;
+    double outputMissingIndicator_;
+};
+
+
+
+/*! -----------------------------------------------------------------
+    \class TableStringVectorElementDecoder
+    Derived class to handle the decoding of string data from a 
+    table file. The data will be put into a vector of strings.
+   ----------------------------------------------------------------- */
+
+class TableStringVectorElementDecoder : public TableElementDecoder
+{
+public:
+    TableStringVectorElementDecoder(vector<string>& target, string outMiss) : target_(target), outputMissingIndicator_(outMiss) {};
+
+    void initialise (int numValues) { target_.reserve(numValues); }
+    void addValue   (char *value)   { target_.push_back((value[0] != '\0') ? value : outputMissingIndicator_); }
+
+private:
+    vector<string>& target_;
+    string outputMissingIndicator_;
+};
+
+
+typedef vector<TableElementDecoder *> TableElementDecoders;  // for shorthand
+
+
+
+/*! -----------------------------------------------------------------
+    \class TableReader
+    Handles the reading of a table file, such as CSV.
+    To use it, set its path and any other formatting attributes
+    as available in the TableFormatAttributes class, and then
+    for each field (column) you wish to store, supply a container
+    such as a vector of numbers. Only those fields for which you
+    supply a container will be read. Fields can be specified by
+    index (0-based) or by name.
+
+   ----------------------------------------------------------------- */
+
+class TableReader : public TableFormatAttributes
+{
+public:
+
+    enum eTableReaderFieldType {TABFIELD_NUMBER, TABFIELD_STRING};
+
+    TableReader ()              {gotMetaData_ = false; errorCode_ = 0;}
+    TableReader (string &path)  {setPath(path);}
+
+    void setFieldContainer (int index, string &name, vector<double>& container, double outputMissingIndicator);
+    void setFieldContainer (int index, string &name, vector<string>& container, string outputMissingIndicator);
+
+    // setFieldContainer (string &name, vector<double>);
+    // setFieldContainer (string &name, vector<string>);
+
+    bool getMetaData(string &errorMessage);
+    bool read (string &errorMessage);  // read and parse the file; the supplied cointainers will be filled
+
+    vector<eTableReaderFieldType>& fieldTypes();
+    vector<string>&                fieldNames();
+    map<string, string>&           userMetaData();
+    int                            numRecords();
+
+private:
+
+    void resizeDecoders (unsigned int numNeeded);
+    int  nextLineTokens (char *line, size_t sizeOfLine, vector<char *>& tokens);  // reads the next line and splits into tokens
+    void splitLine      (char *line, vector<char *>& tokens);                     // splits a line into tokens based on the current settings
+    void splitLineConsecutiveDelimiters (char *line, vector<char *>& tokens);     // splits a line into tokens based on the current settings
+    bool readUserMetaData(char *line, size_t sizeOfLine, string &errorMessage);   // reads user meta-data into a map
+    int  indexOfField   (string &name);                                           // returns the index of the field with a given name (or -1)
+    void setError       (string msg)  {errorCode_ = 1; errorMsg_ = msg;};         // set an error message to be used later
+    void clearError     ()            {errorCode_ = 0;};                          // clear error message and code to be used later
+    void ensureHaveMetaData();                                                    // loads the meta-data if not already there
+    void skipLines      (int linesToSkip, char *line, size_t sizeOfLine);         // skips a user-defined number of rows
+    TableReader::eTableReaderFieldType guessFieldType(char *str);                 // tries to determine whether the field is, for example, string or number
+
+    vector<TableElementDecoders>  decoderSets_; // each column can have multiple decoders attached to it
+    vector<string *>              names_;
+    vector<string>                namesAll_;
+    vector<eTableReaderFieldType> types_;
+    bool                          gotMetaData_;
+    ifstream                      f_;
+    streampos                     dataStart_;
+    int                           numRecords_;
+    map<string, string>           userMetaData_;
+    int                           errorCode_;  // some functions will set these to be used later
+    string                        errorMsg_;   // some functions will set these to be used later
+
+};
+
+#endif
diff --git a/src/magics.h b/src/magics.h
new file mode 100644
index 0000000..58db795
--- /dev/null
+++ b/src/magics.h
@@ -0,0 +1,310 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file magics.h
+
+  \brief This file contains all global definition for the MagPlus library.
+  \author Meteorological Visualisation Section, ECMWF
+  \license Apache License 2.0
+
+  Started: January 2004
+
+  Changes:
+  
+*/
+#ifndef magicsplusplus_H
+#define magicsplusplus_H
+
+//#define BOOST_VERSION 104700
+
+#include <magics_config.h>
+#if defined(MAGICS_AIX_XLC)
+ #include <unistd.h>           // for AIX
+#endif
+#include <climits>
+
+// do the export restriction only if NOT for Metview
+#ifndef MAGICS_METVIEW
+
+#ifdef WIN32
+  #define MAGICS_IMPORT __declspec(dllimport)
+  #define MAGICS_EXPORT __declspec(dllexport)
+  #define MAGICS_DLLLOCAL
+  #define MAGICS_DLLPUBLIC
+#endif
+
+#if (__GNUC__ - 0 > 3) || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 > 2)
+  #define MAGICS_GCC 4
+  #define MAGICS_NO_EXPORT __attribute__ ((visibility("hidden")))
+  #define MAGICS_EXPORT    __attribute__ ((visibility("default")))
+  #define MAGICS_IMPORT    __attribute__ ((visibility("default")))
+  #define MAGICS_DLLLOCAL  __attribute__ ((visibility("hidden")))
+  #define MAGICS_DLLPUBLIC __attribute__ ((visibility("default")))
+#else
+  #define MAGICS_GCC 3
+  #define MAGICS_NO_EXPORT
+  #define MAGICS_IMPORT
+  #define MAGICS_EXPORT
+  #define MAGICS_DLLLOCAL
+  #define MAGICS_DLLPUBLIC
+#endif
+
+#else
+  #define MAGICS_GCC 3
+  #define MAGICS_NO_EXPORT
+  #define MAGICS_IMPORT
+  #define MAGICS_EXPORT
+  #define MAGICS_DLLLOCAL
+  #define MAGICS_DLLPUBLIC
+#endif
+
+#ifdef __GNUC__
+#define MAGICS_DEPRECATED __attribute__((deprecated))
+#else
+#define MAGICS_DEPRECATED
+#endif
+
+#include <iostream>
+#include <cstring>
+#include <string>
+#include <sstream>
+#include <fstream>
+
+using std::string;
+using std::ostream;
+using std::endl;
+using std::ends;
+using std::cout;
+using std::cerr;
+using std::ostringstream;
+using std::ofstream;
+using std::ifstream;
+
+#include <list>
+#include <vector>
+#include <stack>
+#include <memory>
+#include <map>
+#include <set>
+#include <iterator>
+#include <numeric>
+//#include <cfloat>
+#include <algorithm>
+
+using std::allocator;
+using std::vector;
+using std::pair;
+using std::list;
+using std::map;
+using std::set;
+using std::auto_ptr;
+
+#include <exception>
+using std::exception;
+
+#include <cassert>
+#include <cmath>
+
+#if defined(MAGICS_AIX_XLC) || defined(MAGICS_WINDOWS_CYGWIN) || defined(MAGICS_MAC_GCC)
+inline double exp10(const double r) { return exp(r*2.302585093);} // exp(r*ln(10))
+#endif
+
+/*! \namespace magics
+
+ The <I>magics</I> namespace encapsulates all elements of Magics++.
+ The namespace prevents confusions with other libraries or 
+ older versions of Magics.
+ 
+ You can use this namespace by simple prefix all Magics elements
+ by <I>magics::</I> or by typing <I>using namespace magics;</I>
+ before any calls in your program.
+
+*/
+namespace magics {
+
+
+//const double double_MIN = DBL_MIN;
+
+
+template <class P>
+class magvector : public std::vector<P>
+{
+public:
+    magvector() {}
+    magvector(const std::vector<P>& list) :  std::vector<P>(list) {}
+    virtual ~magvector() {} 
+    virtual MAGICS_NO_EXPORT void print(ostream& out) const
+    { 
+        if ( this->size() < 10 ) {
+            out << "Vector[";
+            string sep = "";
+	    const unsigned int si = this->size();
+            for (unsigned int i = 0; i < si; i++) {
+                out << sep << (*this)[i];
+                sep = ", ";
+            }
+            out << "]";
+        }
+        else {
+            unsigned int nb = this->size();
+            out << "Vector[" << (*this)[0] << ", " << (*this)[1] << ", " << (*this)[2];
+            out << "...." << (*this)[nb-3] << ", " << (*this)[nb-2]  << ", " << (*this)[nb-1];
+            out << "(" << nb << " elements)]";
+        }
+    }
+// -- Friends
+	friend MAGICS_NO_EXPORT ostream& operator<<(ostream& s,const magvector<P>& p)
+		{ p.print(s); return s; }
+};
+
+
+typedef magvector<string>	stringarray;
+typedef magvector<int>		intarray;
+typedef magvector<double>	doublearray;
+typedef magvector<double>	floatarray;
+
+enum LineStyle { M_SOLID , M_DASH , M_DOT , M_CHAIN_DASH , M_CHAIN_DOT };
+enum Hemisphere { NORTH , SOUTH };
+enum Justification { MLEFT, MCENTRE, MRIGHT };
+enum VerticalAlign { MNORMAL, MTOP, MCAP, MHALF, MBASE, MBOTTOM };
+//enum VerticalAlign { MBASE, MTOP, MHALF, MBOTTOM };   // if change you need to change also share/magics/PostScriptMacros2.dat
+enum Shading { M_SH_NONE, M_SH_SOLID, M_SH_HATCH, M_SH_DOT };
+enum ArrowPosition { M_TAIL, M_CENTRE };
+enum DisplayType { ABSOLUTE, INLINE, BLOCK, NONE, HIDDEN };
+enum ListPolicy { M_LASTONE, M_CYCLE };
+enum GraphicsFormat {PS, EPS, PDF, SVG, KML, PNG, X, CPS, CSVG, GIF, AGIF, JPG, QT};
+enum AxisAutomaticSetting {m_off, m_both, m_min_only, m_max_only};
+
+/*
+inline MAGICS_NO_EXPORT string getOutputString()
+{
+	const string outputs = MAGICS_OUTPUTS;
+	return outputs;
+}
+*/
+const double epsilon = 1.25e-10;
+
+template<class T>
+inline MAGICS_NO_EXPORT T abs(const T a) { return (a < 0) ? -a : a; }
+
+#ifndef PI
+const double PI = atan(1.)*4.;
+#endif
+
+inline MAGICS_NO_EXPORT double RAD(const double r) { return r*PI/180.;}
+inline MAGICS_NO_EXPORT double DEG(const double d) { return d*180./PI;}
+inline MAGICS_NO_EXPORT bool zero(const double v) { return abs(v) < epsilon; }
+inline MAGICS_NO_EXPORT bool same(const double a, const double b) { return zero(a-b); }
+
+//! Global function to read env variables
+inline MAGICS_NO_EXPORT string getEnvVariable(const string var)
+{
+	const char* va = var.c_str();
+	const char* ww = getenv(va);
+	if(ww) return string(ww);
+	if(!strcmp(va,"MAGPLUS_HOME")) return string(MAGICS_INSTALL_PATH);
+	return "";
+}
+
+//! Global function to return the Magics++ version for ID line
+/*! comes from magics_config.h !!! */
+inline string getMagicsVersionString()
+{
+	const string magics  = MAGICS_NAME;
+	string version = MAGICS_VERSION;
+	if(sizeof(long)==8) version=MAGICS_VERSION+string(" (64 bit)");
+	return magics+string(" ")+version;
+}
+
+// inline MAGICS_NO_EXPORT int upper_case(const int c) { return toupper(c);}
+inline MAGICS_NO_EXPORT char lower_case(const char c) { return tolower(c);}
+
+//! Make an lowercase copy of s:
+inline MAGICS_NO_EXPORT string lowerCase(const string& s)
+{
+	std::string out;
+	std::string::const_iterator se = s.end();
+	for ( string::const_iterator l = s.begin(); l != se; ++l)
+	{
+		char ii = tolower(*l);
+		out.push_back(ii);
+	}
+	return out;
+}
+
+/*!
+  \brief compares two strings
+*/
+inline MAGICS_NO_EXPORT bool magCompare(const string &s1, const string &s2)
+{
+	if(s1.size() != s2.size()) return false;
+#ifndef MAGICS_WINDOWS_CYGWIN
+	return !( strcasecmp(s1.c_str(),s2.c_str()) );
+#endif
+}
+
+/*!
+  \brief returns the biggest integer inside a double
+*/
+inline double maground(double x)
+{
+	return floor(x + 0.5);
+}
+
+inline double tonumber(const string& str) 
+{
+	double r;
+	std::stringstream ss(str);
+	ss >> r;
+	return r;
+}
+
+template <class T>
+inline string tostring(const T& in) 
+{
+	std::ostringstream out;
+	out << in;
+	return out.str();
+}
+
+
+/*!
+  \brief checks if file readable or not
+*/
+/*
+inline MAGICS_NO_EXPORT bool fileReadable(const string &strFile)
+{
+    FILE *fp = fopen (strFile.c_str(), "r");
+    if (fp != NULL)
+    {
+        fclose (fp);
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+*/
+
+#define MAGPLUS_PATH_TO_SHARE_ "/share/magics/"
+#define MAGPLUS_LINK_  "http://www.ecmwf.int/publications/manuals/magics"
+#define MAGPLUS_PATH_TO_PS_FONTS_ POSTSCRIPT_FONT_PATH;
+}
+#endif
diff --git a/src/magics.pc.in b/src/magics.pc.in
new file mode 100644
index 0000000..2911dc9
--- /dev/null
+++ b/src/magics.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Magics
+Description: Multi-platform meteorological graphics library
+Version: @VERSION@
+
+# @PKGCONFIG_REQUIRES@: @MAGICS_REQUIRES@
+Libs: -L${libdir} -lMagPlus
+Libs.private: @MAGICS_3RDPARTY_LIBS@
+Cflags: -I${includedir}/magics @MAGICS_3RDPARTY_INCLUDE@
diff --git a/src/magics_config.h b/src/magics_config.h
new file mode 100644
index 0000000..bdd4103
--- /dev/null
+++ b/src/magics_config.h
@@ -0,0 +1,218 @@
+/* src/magics_config.h.  Generated from magics_config.h.in by configure.  */
+/* src/magics_config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* define if the Boost library is available */
+#define HAVE_BOOST /**/
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `expat' library (-lexpat). */
+#define HAVE_LIBEXPAT 1
+
+/* Define to 1 if you have the `gd' library (-lgd). */
+#define HAVE_LIBGD 1
+
+/* Define to 1 if you have the `grib_api' library (-lgrib_api). */
+#define HAVE_LIBGRIB_API 1
+
+/* Define to 1 if you have the `proj' library (-lproj). */
+#define HAVE_LIBPROJ 1
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD 1
+
+/* Define to 1 if you have the `spot_database' library (-lspot_database). */
+#define HAVE_LIBSPOT_DATABASE 1
+
+/* Define to 1 if you have the `z' library (-lz). */
+#define HAVE_LIBZ 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#define LT_OBJDIR ".libs/"
+
+/* Turn on 32 bit addressing */
+/* #undef MAGICS_32BIT */
+
+/* Install all header files. */
+/* #undef MAGICS_ALLHEADERS */
+
+/* Turn off the BUFR support */
+#define MAGICS_BUFR 1
+
+/* Turn on the Cairo output support */
+#define MAGICS_CAIRO 1
+
+/* Period of Copyright. */
+#define MAGICS_COPYRIGHT_PERIOD "2007-2012"
+
+/* Turn on the use of Exceptions (not recommended used by Static library!) */
+#define MAGICS_EXCEPTION 1
+
+/* Defines GIF output is supported. */
+#define MAGICS_GIF 1
+
+/* Defines animated GIF output is supported. */
+#define MAGICS_GIF_ANIMATED 1
+
+/* Turn off the GRIB 1/2 support */
+#define MAGICS_GRIB 1
+
+/* Install path. */
+#define MAGICS_INSTALL_PATH "/usr/local/apps/Magics/2.18.7"
+
+/* Turn on the JSON support */
+#define MAGICS_JSON 1
+
+/* LIB_AGE of Magics. */
+/* #undef MAGICS_LIBRARY_AGE */
+
+/* LIB_CURRENT of Magics. */
+/* #undef MAGICS_LIBRARY_CURRENT */
+
+/* LIB_REVISION of Magics. */
+/* #undef MAGICS_LIBRARY_REVISION */
+
+/* Indicate if Mac is used. */
+/* #undef MAGICS_MAC */
+
+/* Turn on metgram script support */
+#define MAGICS_METGRAM 1
+
+/* Installation used by metview */
+/* #undef MAGICS_METVIEW */
+
+/* Name of this package. */
+#define MAGICS_NAME "Magics"
+
+/* Turn off the netCDF support */
+#define MAGICS_NETCDF 1
+
+/* Turn off the ODB support */
+#define MAGICS_ODB 1
+
+/* Gives the list of output formats */
+#define MAGICS_OUTPUTS "PS_EPS_PDF_SVG_KML_GIF_AGIF_PNG_CPS_CSVG_X"
+
+/* Turn on/off Proj4 support. */
+#define MAGICS_PROJ4 1
+
+/* Enable Python interface (based on swik). */
+#define MAGICS_PYTHON 1
+
+/* Turn on Qt related modules. */
+/* #undef MAGICS_QT */
+
+/* Turn on raster file format support (GIF&PNG) */
+#define MAGICS_RASTER 1
+
+/* Release date of this version. */
+#define MAGICS_RELEASE_DATE "05-December-2012"
+
+/* Name of installation site. */
+#define MAGICS_SITE "ecmwf"
+
+/* Turn off the SPOT support */
+#define MAGICS_SPOT 1
+
+/* Turn on/off thread support. */
+#define MAGICS_THREADS 1
+
+/* Turn on TIFF file format support */
+/* #undef MAGICS_TIFF */
+
+/* Turn on the TTF support */
+#define MAGICS_TTF 1
+
+/* Path to TTF font files. */
+#define MAGICS_TTF_PATH "share/magics/ttf/"
+
+/* Version of Magics. */
+#define MAGICS_VERSION "2.18.7"
+
+/* Sets visibility flags. */
+/* #undef MAGICS_VISIBILITY */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "MagPlus"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "MagPlus 2"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "magplus"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "2"
+
+/* Paths to PS fonts. */
+#define POSTSCRIPT_FONT_PATH "/usr/share/ghostscript/fonts/"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+
+
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
diff --git a/src/magics_config.h.in b/src/magics_config.h.in
new file mode 100644
index 0000000..1bfea4a
--- /dev/null
+++ b/src/magics_config.h.in
@@ -0,0 +1,217 @@
+/* src/magics_config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* define if the Boost library is available */
+#undef HAVE_BOOST
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `expat' library (-lexpat). */
+#undef HAVE_LIBEXPAT
+
+/* Define to 1 if you have the `gd' library (-lgd). */
+#undef HAVE_LIBGD
+
+/* Define to 1 if you have the `grib_api' library (-lgrib_api). */
+#undef HAVE_LIBGRIB_API
+
+/* Define to 1 if you have the `proj' library (-lproj). */
+#undef HAVE_LIBPROJ
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#undef HAVE_LIBPTHREAD
+
+/* Define to 1 if you have the `spot_database' library (-lspot_database). */
+#undef HAVE_LIBSPOT_DATABASE
+
+/* Define to 1 if you have the `z' library (-lz). */
+#undef HAVE_LIBZ
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
+/* Turn on 32 bit addressing */
+#undef MAGICS_32BIT
+
+/* Install all header files. */
+#undef MAGICS_ALLHEADERS
+
+/* Turn off the BUFR support */
+#undef MAGICS_BUFR
+
+/* Turn on the Cairo output support */
+#undef MAGICS_CAIRO
+
+/* Period of Copyright. */
+#undef MAGICS_COPYRIGHT_PERIOD
+
+/* Turn on the use of Exceptions (not recommended used by Static library!) */
+#undef MAGICS_EXCEPTION
+
+/* Defines GIF output is supported. */
+#undef MAGICS_GIF
+
+/* Defines animated GIF output is supported. */
+#undef MAGICS_GIF_ANIMATED
+
+/* Turn off the GRIB 1/2 support */
+#undef MAGICS_GRIB
+
+/* Install path. */
+#undef MAGICS_INSTALL_PATH
+
+/* Turn on the JSON support */
+#undef MAGICS_JSON
+
+/* LIB_AGE of Magics. */
+#undef MAGICS_LIBRARY_AGE
+
+/* LIB_CURRENT of Magics. */
+#undef MAGICS_LIBRARY_CURRENT
+
+/* LIB_REVISION of Magics. */
+#undef MAGICS_LIBRARY_REVISION
+
+/* Indicate if Mac is used. */
+#undef MAGICS_MAC
+
+/* Turn on metgram script support */
+#undef MAGICS_METGRAM
+
+/* Installation used by metview */
+#undef MAGICS_METVIEW
+
+/* Name of this package. */
+#undef MAGICS_NAME
+
+/* Turn off the netCDF support */
+#undef MAGICS_NETCDF
+
+/* Turn off the ODB support */
+#undef MAGICS_ODB
+
+/* Gives the list of output formats */
+#undef MAGICS_OUTPUTS
+
+/* Turn on/off Proj4 support. */
+#undef MAGICS_PROJ4
+
+/* Enable Python interface (based on swik). */
+#undef MAGICS_PYTHON
+
+/* Turn on Qt related modules. */
+#undef MAGICS_QT
+
+/* Turn on raster file format support (GIF&PNG) */
+#undef MAGICS_RASTER
+
+/* Release date of this version. */
+#undef MAGICS_RELEASE_DATE
+
+/* Name of installation site. */
+#undef MAGICS_SITE
+
+/* Turn off the SPOT support */
+#undef MAGICS_SPOT
+
+/* Turn on/off thread support. */
+#undef MAGICS_THREADS
+
+/* Turn on TIFF file format support */
+#undef MAGICS_TIFF
+
+/* Turn on the TTF support */
+#undef MAGICS_TTF
+
+/* Path to TTF font files. */
+#undef MAGICS_TTF_PATH
+
+/* Version of Magics. */
+#undef MAGICS_VERSION
+
+/* Sets visibility flags. */
+#undef MAGICS_VISIBILITY
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Paths to PS fonts. */
+#undef POSTSCRIPT_FONT_PATH
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
diff --git a/src/magics_ecmwf_log.h b/src/magics_ecmwf_log.h
new file mode 100644
index 0000000..d614de3
--- /dev/null
+++ b/src/magics_ecmwf_log.h
@@ -0,0 +1,79 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef magicsplusplus_ecmwf_H
+#define magicsplusplus_ecmwf_H
+
+#include "magics.h"
+#include <fstream>
+#include <unistd.h>
+
+namespace magics {
+  
+/*!
+  \brief Writes logging information for ECMWF users
+
+  \note Designed to work at ECMWF only! Some MetVis Section members are excluded 
+  from the list.
+  \warning The log file can grow very quickly and needs constantly checking.
+*/
+inline MAGICS_NO_EXPORT void writeMagLog(const std::string &interface)
+{
+  if(magCompare(MAGICS_SITE,"ecmwf"))
+  {
+//   string logpath = getEnvVariable("MAG_LOGGING_FILE");
+//   if(logpath.empty()) logpath = "/vol/netlog/magics/usage_log";
+//   FILE* filePtr_ = fopen(logpath.c_str(),"a");
+   FILE* filePtr_ = fopen("/vol/netlog/magics/usage_log","a");
+
+   if(filePtr_)
+   {
+	string id = getEnvVariable("USER"); //user-id
+
+	if(! (id=="cgm" || id=="cgs" || id=="cgi" || id=="cgk" || id=="cgr" ) )
+	{
+		char            host[64];
+		char            mytime[24];
+		time_t          when;
+
+		time(&when);
+		strncpy(mytime,ctime(&when),24); 
+		string smytime(mytime,24);      // date time
+
+		string arch = getEnvVariable("ARCH");
+		if(arch.empty()) arch = "NoArch";
+		
+		if(gethostname(host, sizeof(host)) == -1) strcpy(host, "NoHost");
+
+		string inter;
+		if(magCompare(interface,"magml")) inter = "x"; 
+		else if(magCompare(interface,"fortran")) inter = "*"; 
+		else inter = "?";
+
+		string logline = inter + id + "/" +  smytime + "/"+ getMagicsVersionString() + "D/" + host + "/" + arch;
+		fprintf(filePtr_,"%s\n",logline.c_str());
+
+		fflush(filePtr_);
+		fclose(filePtr_);
+	}//endif NOT cgm or cgs
+   }
+  }
+}
+
+}
+#endif
diff --git a/src/oda/Makefile.am b/src/oda/Makefile.am
new file mode 100644
index 0000000..5fecdf1
--- /dev/null
+++ b/src/oda/Makefile.am
@@ -0,0 +1,24 @@
+AUTOMAKE_OPTIONS= foreign
+
+noinst_LTLIBRARIES = liboda.la
+
+include_H	= OdaDecoder.h
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= 
+else
+include_HEADERS = 
+noinst_HEADERS	= $(include_H)
+endif
+
+ATTRIBUTES		= OdaGeoDecoderAttributes.cc OdaXYDecoderAttributes.cc
+#lib_LIBRARIES		= libMagPlusODA.a
+
+nodist_liboda_la_SOURCES	= ${ATTRIBUTES}
+liboda_la_SOURCES 	= ODACalls.cc OdaDecoder.cc
+#libMagPlusODA_a_CPPFLAGS	= -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/visualisers -I$(ODB_PATH)/include
+liboda_la_CPPFLAGS	= -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src -I$(top_srcdir)/src/visualisers
+#liboda_la_LIBADD	= $(ODB_PATH)/lib/libEc.a $(ODB_PATH)/lib/libOda.a
+liboda_la_LDFLAGS	= -no-undefined -no-install
+
diff --git a/src/oda/Makefile.in b/src/oda/Makefile.in
new file mode 100644
index 0000000..2aa8045
--- /dev/null
+++ b/src/oda/Makefile.in
@@ -0,0 +1,673 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/oda
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+liboda_la_LIBADD =
+am_liboda_la_OBJECTS = liboda_la-ODACalls.lo liboda_la-OdaDecoder.lo
+am__objects_1 = liboda_la-OdaGeoDecoderAttributes.lo \
+	liboda_la-OdaXYDecoderAttributes.lo
+nodist_liboda_la_OBJECTS = $(am__objects_1)
+liboda_la_OBJECTS = $(am_liboda_la_OBJECTS) \
+	$(nodist_liboda_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+liboda_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(liboda_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(liboda_la_SOURCES) $(nodist_liboda_la_SOURCES)
+DIST_SOURCES = $(liboda_la_SOURCES)
+am__include_HEADERS_DIST = OdaDecoder.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = OdaDecoder.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+noinst_LTLIBRARIES = liboda.la
+include_H = OdaDecoder.h
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = 
+ATTRIBUTES = OdaGeoDecoderAttributes.cc OdaXYDecoderAttributes.cc
+#lib_LIBRARIES		= libMagPlusODA.a
+nodist_liboda_la_SOURCES = ${ATTRIBUTES}
+liboda_la_SOURCES = ODACalls.cc OdaDecoder.cc
+#libMagPlusODA_a_CPPFLAGS	= -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/visualisers -I$(ODB_PATH)/include
+liboda_la_CPPFLAGS = -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src -I$(top_srcdir)/src/visualisers
+#liboda_la_LIBADD	= $(ODB_PATH)/lib/libEc.a $(ODB_PATH)/lib/libOda.a
+liboda_la_LDFLAGS = -no-undefined -no-install
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/oda/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign src/oda/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+liboda.la: $(liboda_la_OBJECTS) $(liboda_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(liboda_la_LINK)  $(liboda_la_OBJECTS) $(liboda_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liboda_la-ODACalls.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liboda_la-OdaDecoder.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liboda_la-OdaGeoDecoderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liboda_la-OdaXYDecoderAttributes.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+liboda_la-ODACalls.lo: ODACalls.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liboda_la-ODACalls.lo -MD -MP -MF $(DEPDIR)/liboda_la-ODACalls.Tpo -c -o liboda_la-ODACalls.lo `test -f 'ODACalls.cc' || echo '$(srcdir)/'`ODACalls.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/liboda_la-ODACalls.Tpo $(DEPDIR)/liboda_la-ODACalls.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='ODACalls.cc' object='liboda_la-ODACalls.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liboda_la-ODACalls.lo `test -f 'ODACalls.cc' || echo '$(srcdir)/'`ODACalls.cc
+
+liboda_la-OdaDecoder.lo: OdaDecoder.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liboda_la-OdaDecoder.lo -MD -MP -MF $(DEPDIR)/liboda_la-OdaDecoder.Tpo -c -o liboda_la-OdaDecoder.lo `test -f 'OdaDecoder.cc' || echo '$(srcdir)/'`OdaDecoder.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/liboda_la-OdaDecoder.Tpo $(DEPDIR)/liboda_la-OdaDecoder.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='OdaDecoder.cc' object='liboda_la-OdaDecoder.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liboda_la-OdaDecoder.lo `test -f 'OdaDecoder.cc' || echo '$(srcdir)/'`OdaDecoder.cc
+
+liboda_la-OdaGeoDecoderAttributes.lo: OdaGeoDecoderAttributes.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liboda_la-OdaGeoDecoderAttributes.lo -MD -MP -MF $(DEPDIR)/liboda_la-OdaGeoDecoderAttributes.Tpo -c -o liboda_la-OdaGeoDecoderAttributes.lo `test -f 'OdaGeoDecoderAttributes.cc' || echo '$(srcdir)/'`OdaGeoDecoderAttributes.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/liboda_la-OdaGeoDecoderAttributes.Tpo $(DEPDIR)/liboda_la-OdaGeoDecoderAttributes.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='OdaGeoDecoderAttributes.cc' object='liboda_la-OdaGeoDecoderAttributes.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liboda_la-OdaGeoDecoderAttributes.lo `test -f 'OdaGeoDecoderAttributes.cc' || echo '$(srcdir)/'`OdaGeoDecoderAttributes.cc
+
+liboda_la-OdaXYDecoderAttributes.lo: OdaXYDecoderAttributes.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT liboda_la-OdaXYDecoderAttributes.lo -MD -MP -MF $(DEPDIR)/liboda_la-OdaXYDecoderAttributes.Tpo -c -o liboda_la-OdaXYDecoderAttributes.lo `test -f 'OdaXYDecoderAttributes.cc' || echo '$(srcdir)/'`OdaXYDecoderAttributes.cc
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/liboda_la-OdaXYDecoderAttributes.Tpo $(DEPDIR)/liboda_la-OdaXYDecoderAttributes.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='OdaXYDecoderAttributes.cc' object='liboda_la-OdaXYDecoderAttributes.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liboda_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o liboda_la-OdaXYDecoderAttributes.lo `test -f 'OdaXYDecoderAttributes.cc' || echo '$(srcdir)/'`OdaXYDecoderAttributes.cc
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/oda/ODACalls.cc b/src/oda/ODACalls.cc
new file mode 100644
index 0000000..d702b2f
--- /dev/null
+++ b/src/oda/ODACalls.cc
@@ -0,0 +1,39 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+#include "MagLog.h"
+#include "FortranMagics.h"
+#include "XmlMagics.h"
+#include "OdaDecoder.h"
+/*
+ These functions are overwritting empty functions in main library 
+*/
+
+extern "C" {
+
+#include <magics_api.h>
+
+Data* calloda(const XmlNode& node)
+{
+	OdaGeoDecoder* oda = new OdaGeoDecoder();
+	oda->set(node);
+	return oda;
+}
+
+}
diff --git a/src/oda/OdaDecoder.cc b/src/oda/OdaDecoder.cc
new file mode 100644
index 0000000..316ca39
--- /dev/null
+++ b/src/oda/OdaDecoder.cc
@@ -0,0 +1,1194 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OdaDecoder.cc
+    \brief Implementation of the Template class OdaDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+#include <vector>
+#include <map>
+#include <set>
+
+#include "oda.h"
+extern "C" {
+#include "odbcapi.h"
+}
+
+
+#include "../common/Timer.h"
+#include "OdaDecoder.h"
+
+#include "SciMethods.h"
+#include "TextVisitor.h"
+
+static int getOdbColumnIndex(odb::Reader::iterator &,const string&);
+
+int getOdbColumnIndex(odb::Reader::iterator &firstRowIt,const string& colName)
+{
+	int index=0;
+  	for(odb::MetaData::iterator it=firstRowIt->columns().begin(); it != firstRowIt->columns().end(); ++it)
+	{			
+		string s=(*it)->name();
+		if(s == colName)
+			return index; 
+		
+		index++;
+	}
+	MagLog::warning() << "Cannot find column for "<< colName << endl;
+  	return -1;
+
+}
+
+OdaGeoDecoder::OdaGeoDecoder() 
+{
+}
+
+
+OdaGeoDecoder::~OdaGeoDecoder() 
+{
+	
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void OdaGeoDecoder::print(ostream& out)  const
+{
+	out << "OdaGeoDecoder[";
+        OdaGeoDecoderAttributes::print(out);
+        out << "]";
+}
+
+double degrees(double val) 
+{
+	return val;
+}
+
+double radians(double val) 
+{
+	return val*180/3.14;
+}
+
+typedef double (*Converter)(double);
+
+map<string, Converter> converters_;
+
+
+void OdaGeoDecoder::decode(const Transformation& transformation)
+{    
+	if ( !empty() ) 
+		return; 
+	
+	//Vectors. It is used for building histogram data for speed!!
+	if(info("_datatype") == "ODB_geovectors")
+	{		
+		CustomisedPointsList points;
+		std::set<string> noset;
+		customisedPoints(transformation,noset,points);
+		for(CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) 
+		{
+			push_back(new UserPoint((**point)["lon"], (**point)["lat"], (**point)["colour_component"]));
+		}
+	}	
+	else
+	{
+
+	try
+	{
+		odb_start();
+		odb::Reader oda(path_);	
+		odb::Reader::iterator it = oda.begin();
+	
+		int latIndex,lonIndex,valueIndex=-1;		
+		
+		if((latIndex=getOdbColumnIndex(it,latitude_)) == -1)
+			throw exception();		
+		if((lonIndex=getOdbColumnIndex(it,longitude_)) == -1)
+			throw exception();
+		
+		if(value_.empty())
+			MagLog::info() <<  "No value is specified!" << endl;
+		else if((valueIndex = getOdbColumnIndex(it,value_)) == -1)
+			throw exception();
+			  		
+		MagLog::info() <<  "Indices: " << latIndex << " " << lonIndex << " " << valueIndex << endl;
+	
+		int dataCnt=0;
+		dataIndex_.clear();
+		
+		unsigned int row=0;
+		
+		for(; it != oda.end(); ++it) 
+		{			
+			double lat = (*it)[latIndex];
+			double lon = (*it)[lonIndex];
+			position(lat, lon);
+	
+			if ( transformation.in(lon, lat)  ) 
+			{
+				if(valueIndex != -1)
+				{
+				  	stats_["value"].push_back((*it)[valueIndex]);
+				  	stats_["x"].push_back(lon);
+				  	stats_["y"].push_back(lat);
+					push_back(new UserPoint(lon, lat, (*it)[valueIndex]));
+				}
+				else
+				{
+				  	push_back(new UserPoint(lon, lat));
+				}	
+				
+				dataIndex_.push_back(dataCnt);
+				dataCnt++;
+				
+				row++;
+				if (nb_rows_ != -1 && row >= nb_rows_)
+				{
+					break;
+				}
+			}
+		}
+
+		MagLog::info() <<  "Number of rows: " << row << endl;
+
+		computeStats();
+	}
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}
+	
+	
+	}
+}
+
+void OdaGeoDecoder::visit(Transformation& transformation) {MagLog::info() <<  "No value is specified!" << endl;
+
+	return;	
+
+	decode();
+	if ( empty() ) return;
+	double minx = front()->x_;
+	double maxx = front()->x_;
+	double miny = front()->y_;
+	double maxy = front()->y_;
+
+	for (iterator point = begin(); point != end(); ++point) {
+		if ( minx > (*point)->x_ ) minx = (*point)->x_;
+		if ( miny > (*point)->y_ ) miny = (*point)->y_;
+		if ( maxx < (*point)->x_ ) maxx = (*point)->x_;
+		if ( maxy < (*point)->y_ ) maxy = (*point)->y_;
+	}
+
+	transformation.setDataMinX(minx);
+	transformation.setDataMinY(miny);
+	transformation.setDataMaxX(maxx);
+	transformation.setDataMaxY(maxy);
+}
+void OdaGeoDecoder::decode()
+{    
+	if ( !empty() ) 
+		return;  
+
+	try
+	{	
+	      odb_start();
+	      odb::Reader oda(path_);
+
+	      odb::Reader::iterator it = oda.begin();
+
+	      int latIndex,lonIndex,valueIndex=-1;		
+		      
+	      if((latIndex=getOdbColumnIndex(it,latitude_)) == -1)
+		      throw exception();		      
+	      if((lonIndex=getOdbColumnIndex(it,longitude_)) == -1)
+		      throw exception();
+		      		      	    
+	      if(value_.empty())
+		      MagLog::info() <<  "No value is specified!" << endl;
+	      else if((valueIndex = getOdbColumnIndex(it,value_)) == -1)
+		       throw exception();	
+	      			      
+	      MagLog::info() <<  "Indices: " << latIndex << " " << lonIndex << " " << valueIndex << endl;
+
+	      unsigned int row=0;
+	      
+	      int dataCnt=0;
+	      dataIndex_.clear();
+		      
+	      for (; it != oda.end(); ++it) 
+	      {			
+		      double lat = (*it)[latIndex];
+		      double lon = (*it)[lonIndex];
+		      position(lat, lon);
+		      
+		      if(valueIndex != -1)
+		      {
+			      stats_["value"].push_back((*it)[valueIndex]);
+			      stats_["x"].push_back(lon);
+			      stats_["y"].push_back(lat);
+			      push_back(new UserPoint(lon, lat, (*it)[valueIndex]));
+		      }
+		      else
+		      {
+			      push_back(new UserPoint(lon, lat));
+		      }
+		      
+		      dataIndex_.push_back(dataCnt);
+		      dataCnt++;
+		      
+		      row++;
+		      if (nb_rows_ != -1 && row >= nb_rows_)
+		      {
+				      break;
+		      }		
+	      }
+
+	      computeStats();
+
+	      MagLog::info() <<  "Number of rows: " << row << endl;	
+	}
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}
+}
+
+void OdaGeoDecoder:: visit(TextVisitor& title)
+{
+	if ( !title_.empty() )
+		title.addAutomaticTitle(title_);
+
+
+	title.addAutomaticTitle("OdbDatabase: " + path_);
+	if(stats_.find("value") == stats_.end())
+	{
+		ostringstream text;
+		if ( !info("stats::min").empty() && !info("stats::max").empty() ) {
+			text  << "Min: " << info("stats::min") << " Max: " << info("stats::max") << " (" <<  size() << " points)";
+		}
+		else
+			text << size() << " points";
+		title.addAutomaticTitle(text.str());
+	}
+	else if (info("stats::points").empty())
+	{
+		title.addAutomaticTitle(" No points found ");
+	}
+	else
+	{
+		if(info("stats::min").empty() &&  stats_["value"].size() >0)
+		{	
+		  	double min = *(std::min_element(stats_["value"].begin(), stats_["value"].end()));
+			setInfo("stats::min",tostring(min));
+		}
+		if(info("stats::max").empty() &&  stats_["value"].size() >0)
+		{	
+		  	double max = *(std::max_element(stats_["value"].begin(), stats_["value"].end()));
+			setInfo("stats::max",tostring(max));
+		}
+		title.addAutomaticTitle( "Min: " + info("stats::min") + "  Max: " + info("stats::max") + "    ( " + info("stats::points") + " points) ");
+	}
+	
+
+}
+
+static 
+double speed(double x, double y)
+{
+	return sqrt(x*x+ y*y);
+}
+
+void OdaGeoDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& list)
+{
+     	if(!customisedPoints_.empty())
+	{
+	  	for (vector<CustomisedPoint*>::const_iterator point =customisedPoints_.begin(); point != customisedPoints_.end(); ++point) 
+		{			  		  
+			CustomisedPoint*  cp = new CustomisedPoint((*point)->longitude(), (*point)->latitude(), (*point)->identifier());
+			for(CustomisedPoint::iterator key = (*point)->begin(); key != (*point)->end(); ++key)
+				cp->insert(make_pair(key->first, key->second));	
+			
+			list.push_back(cp);	
+		}
+		return;		
+	}	
+     	
+     	try
+	{	
+	    odb_start();
+	    odb::Reader oda(path_);
+
+	    odb::Reader::iterator it = oda.begin();
+	    
+	    int latIndex,lonIndex,valueIndex=-1,xIndex,yIndex;		
+		      
+	    if((latIndex=getOdbColumnIndex(it,latitude_)) == -1)
+		     throw exception();		      
+	    if((lonIndex=getOdbColumnIndex(it,longitude_)) == -1)
+		     throw exception();		      
+	    if(value_.empty())
+		      MagLog::info() <<  "No value is specified!" << endl;   
+	    else if((valueIndex=getOdbColumnIndex(it,value_)) == -1)
+		     throw exception();  
+	     
+	    if((xIndex=getOdbColumnIndex(it,x_)) == -1)
+		     throw exception();
+	    if((yIndex=getOdbColumnIndex(it,y_)) == -1)
+		     throw exception();
+	      
+	    MagLog::info() <<  "Indices: " << latIndex << " " << lonIndex << " " << valueIndex << endl;
+	    
+	    unsigned int row=0;
+		    
+	    for (; it != oda.end(); ++it, row++) 
+	    {			
+		    if(nb_rows_ != -1 && row >= nb_rows_)
+		    {
+			    break;
+		    }
+
+		    double lat = (*it)[latIndex];
+		    double lon = (*it)[lonIndex];
+		    position(lat, lon);
+					    
+		    CustomisedPoint* point = new CustomisedPoint();		
+		    point->longitude(lon);
+		    point->latitude(lat);
+		    (*point)["x_component"] = (*it)[xIndex];
+		    (*point)["y_component"] = (*it)[yIndex];
+		    double val =  (valueIndex != -1) ? (*it)[valueIndex] : speed((*it)[xIndex],  (*it)[yIndex]);
+		    (*point)["colour_component"] = val;
+		    list.push_back(point);	
+		    stats_["value"].push_back(val);		
+		    //stats_["x"].push_back((*it)[xIndex]);
+		    //stats_["y"].push_back((*it)[yIndex]);
+		    
+		    CustomisedPoint*  cp = new CustomisedPoint(point->longitude(), point->latitude(), point->identifier());
+		    for(CustomisedPoint::iterator key = point->begin(); key != point->end(); ++key)
+			    cp->insert(make_pair(key->first, key->second));					
+		    customisedPoints_.push_back(cp);
+		    
+	    }	
+
+	    computeStats();
+
+	    MagLog::info() <<  "Number of rows: " << row << endl;
+
+	}
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}
+	
+}
+
+void OdaGeoDecoder::position(double& lat, double& lon)
+{
+	if ( converters_.empty() ) {
+		converters_["degrees"] = °rees;
+		converters_["radians"] = &radians;
+	}
+
+
+	map<string, Converter>::iterator converter = converters_.find(lowerCase(unit_));
+
+	if (converter == converters_.end() ) {
+		MagLog::warning() << "odb_coordinates_unit:" << unit_ << " is not valid -->Change back to default:degrees" << endl;
+		converter = converters_.find("degrees");
+	}
+	lat = (*converter->second)(lat);
+	lon = (*converter->second)(lon);
+
+}
+
+void OdaGeoDecoder::customisedPoints(const Transformation& transformation, const std::set<string>&, CustomisedPointsList& list)
+{
+	if(!customisedPoints_.empty())
+	{
+	  	for (vector<CustomisedPoint*>::const_iterator point =customisedPoints_.begin(); point != customisedPoints_.end(); ++point) 
+		{			  		  
+			CustomisedPoint*  cp = new CustomisedPoint((*point)->longitude(), (*point)->latitude(), (*point)->identifier());
+			for(CustomisedPoint::const_iterator key = (*point)->begin(); key != (*point)->end(); ++key)
+				cp->insert(make_pair(key->first, key->second));	
+			
+			list.push_back(cp);	
+		}
+		return;		
+	}	
+	
+ 	try
+	{
+		odb_start();
+		odb::Reader oda(path_);
+
+		odb::Reader::iterator it = oda.begin();
+  
+		int latIndex,lonIndex,valueIndex=-1,xIndex,yIndex;		
+			      
+	    	if((latIndex=getOdbColumnIndex(it,latitude_)) == -1)
+		     throw exception();		      
+	    	if((lonIndex=getOdbColumnIndex(it,longitude_)) == -1)
+		     throw exception();
+		      
+	    	if(value_.empty())
+	    		MagLog::info() <<  "No value is specified!" << endl;	      
+	    	else if((valueIndex=getOdbColumnIndex(it,value_)) == -1)
+		     throw exception();  
+	     
+	    	if((xIndex=getOdbColumnIndex(it,x_)) == -1)
+		     throw exception();
+	    	if((yIndex=getOdbColumnIndex(it,y_)) == -1)
+		     throw exception();
+		
+		MagLog::info() <<  "Indices: " << latIndex << " " << lonIndex << " " << valueIndex << endl;
+
+		unsigned int row=0;
+			
+		for (; it != oda.end(); ++it) 
+		{	
+			double lat = (*it)[latIndex];
+			double lon = (*it)[lonIndex];
+			position(lat, lon);
+			if ( transformation.in(lon, lat)  ) 
+			{							  
+				CustomisedPoint* point = new CustomisedPoint();	
+				point->longitude(lon);
+				point->latitude(lat);
+				double val =  (valueIndex != -1) ? (*it)[valueIndex] : speed((*it)[xIndex],  (*it)[yIndex]);
+				(*point)["x_component"] = (*it)[xIndex];
+				(*point)["y_component"] = (*it)[yIndex];
+				(*point)["colour_component"] =val;
+				list.push_back(point);	
+				stats_["value"].push_back(val);			
+				//stats_["x"].push_back((*it)[xIndex]);
+				//stats_["y"].push_back((*it)[yIndex]);
+		
+				CustomisedPoint*  cp = new CustomisedPoint(point->longitude(), point->latitude(), point->identifier());
+		    		for(CustomisedPoint::iterator key = point->begin(); key != point->end(); ++key)
+			    		cp->insert(make_pair(key->first, key->second));					
+		    		customisedPoints_.push_back(cp);
+		    
+		    		row++;
+				if(nb_rows_ != -1 && row >= nb_rows_)
+				{
+					break;
+				}
+			}
+		}
+
+		computeStats();
+
+		MagLog::info() <<  "Number of rows: " << row << endl;	
+	}
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}	
+}
+
+void OdaGeoDecoder::initInfo()
+{
+	setInfo("MV_Format","ODB");
+	
+	if(x_.empty())
+	{
+  		setInfo("_datatype","ODB_geopoints");
+		setInfo("statsType","scalar");
+		if(!value_.empty())
+			setInfo("value",value_);
+	}
+	else
+	{	  
+		setInfo("_datatype","ODB_geovectors");
+		setInfo("statsType","scalar");
+		if(value_.empty())
+			setInfo("value","computed speed");
+		else
+		  	setInfo("value",value_);
+		setInfo("x",x_);
+		setInfo("y",y_);		
+	}
+	
+	setInfo("path",path_);
+	setInfo("lat",latitude_);
+	setInfo("lon",longitude_);
+}
+
+
+void OdaGeoDecoder::visit(ValuesCollector& points)
+{
+	points.setCollected(true);
+
+	if(points.size() <=0)
+		return;	  
+	
+	
+	if(info("_datatype") == "ODB_geopoints")
+	{  
+		if(size() == 0)
+	  		return;
+	
+		if(value_.empty())
+			points.setHasValue(false);
+	}
+	else
+	{
+	  	if(customisedPoints_.size()==0)
+			return;
+	}	
+	
+	for (ValuesCollector::iterator point =  points.begin(); point != points.end(); ++point)
+	{
+	  	vector<int> idxV;
+		double lat=(*point).y();
+	  	double lon=(*point).x();
+			
+		if((*point).mode() == ValuesCollectorPoint::IndexMode) 
+		{
+		  	if((*point).index() >=0 &&  (*point).index() < size())
+			{
+				idxV.push_back((*point).index());
+			}
+			else
+			{
+			  	continue;
+			}	
+		}	
+	  	else
+		{  	 
+			if(info("_datatype") == "ODB_geopoints")
+			{		  	  
+				for(int i=0; i < size(); i++)
+				{
+					if(fabs(at(i)->y()-lat) < points.searchRadiusY() &&
+			   		   fabs(at(i)->x()-lon) <  points.searchRadiusX())
+					{
+			  			idxV.push_back(i);
+					}
+				}
+			}
+			else
+			{		  	  
+				for(int i=0; i < customisedPoints_.size(); i++)
+				{
+					if(fabs(customisedPoints_.at(i)->latitude()-lat) < points.searchRadiusY() &&
+			   		   fabs(customisedPoints_.at(i)->longitude()-lon) <  points.searchRadiusX())
+					{
+			  			idxV.push_back(i);
+					}
+				}
+			}
+		}
+					
+		if(idxV.size() ==0)
+			continue;  
+		
+		double dist=10000000.;
+		int minIdx=-1;
+		
+		//MagLog::debug() << "odb collect idxV : " << lat << " " << lon << " " << idxV.size() << endl;
+ 		
+		if(info("_datatype") == "ODB_geopoints")
+		{
+			for(int i=0; i < idxV.size(); i++)
+			{  			
+		  		int idx=idxV[i];
+				double d=magics::geoDistanceInKm(at(idx)->y(),at(idx)->x(),lat,lon);
+				
+				if(d < dist)
+				{
+			  		minIdx=idx;
+					dist=d;
+				}			
+			}
+			
+			if(minIdx>=0)  
+			(*point).push_back(new ValuesCollectorData(at(minIdx)->x(),
+							       at(minIdx)->y(),
+							       at(minIdx)->value(),
+							       dist,minIdx));		
+			
+		}
+		else
+		{
+			for(int i=0; i < idxV.size(); i++)
+			{  			
+		  		int idx=idxV[i];
+				double d=magics::geoDistanceInKm(customisedPoints_.at(idx)->latitude(),
+								 customisedPoints_.at(idx)->longitude(),
+								 lat,lon);				
+				if(d < dist)
+				{
+			  		minIdx=idx;
+					dist=d;
+				}			
+			}
+		
+			if(minIdx>=0) 
+			{
+				map<string,double>::iterator uIt=customisedPoints_.at(minIdx)->find("x_component");
+				map<string,double>::iterator vIt=customisedPoints_.at(minIdx)->find("y_component");
+				if(uIt !=customisedPoints_.at(minIdx)->end() && 
+				   vIt !=customisedPoints_.at(minIdx)->end())
+				{  
+					(*point).push_back(new ValuesCollectorUVData(
+							       customisedPoints_.at(minIdx)->longitude(),
+							       customisedPoints_.at(minIdx)->latitude(),
+							       uIt->second,vIt->second,dist,minIdx));
+				}
+			}
+		}					  					     			
+	}	  
+}
+
+
+
+void OdaGeoDecoder::visit(MetaDataCollector& mdc)
+{	
+	for(map<string, string>::iterator key = mdc.begin(); key != mdc.end(); ++key )
+	{	    
+	  	if(information_.find(key->first) == information_.end() &&
+		  mdc.attribute(key->first).group() == MetaDataAttribute::StatsGroup)
+		{
+			  computeStats();
+			  break;
+		}
+	}
+	
+	if(information_.find("stats::points") == information_.end())
+	{
+		setInfo("stats::points",tostring(size()));
+	}
+		
+	MetviewIcon::visit(mdc);
+}  
+
+    
+OdaXYDecoder::OdaXYDecoder() : matrix_(0)
+{
+}
+
+
+OdaXYDecoder::~OdaXYDecoder() 
+{
+	
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void OdaXYDecoder::print(ostream& out)  const
+{
+	out << "OdaXYDecoder[";
+    OdaXYDecoderAttributes::print(out);
+    out << "]";
+}
+
+void OdaXYDecoder::customisedPoints(const Transformation& transformation, const std::set<string>&, CustomisedPointsList& list)
+{  
+	try
+	{
+  
+		odb_start();
+		odb::Reader oda(path_);
+
+		odb::Reader::iterator it = oda.begin();
+
+		int xIndex=-1,yIndex=-1,valueIndex=-1,xcIndex=-1,ycIndex=-1;		
+			      
+		if((xIndex=getOdbColumnIndex(it,x_)) == -1)
+			  throw exception();
+		if((yIndex=getOdbColumnIndex(it,y_)) == -1)
+			  throw exception();	    
+		if(!value_.empty() && (valueIndex=getOdbColumnIndex(it,value_)) == -1)
+			    throw exception();  
+		if(!x_component_.empty() && (xcIndex=getOdbColumnIndex(it,x_component_)) == -1)
+			    throw exception();    
+		if(!y_component_.empty() && (ycIndex=getOdbColumnIndex(it,y_component_)) == -1)
+			    throw exception();      
+		
+		MagLog::info() <<  "Indices: " << xIndex << " " << yIndex << " " << valueIndex << " " << xcIndex << " " <<  xcIndex << endl;
+
+		int dataCnt=0;
+		dataIndex_.clear();
+			
+		unsigned int row=0;
+			
+		for (; it != oda.end(); ++it) 
+		{
+			CustomisedPoint* point = new CustomisedPoint();		
+			double x = (*it)[xIndex];
+			double y = (*it)[yIndex];
+			if ( transformation.in(x,y)  ) 
+			{							  
+				point->longitude(x);
+				point->latitude(y);
+				(*point)["x"] = x;
+				(*point)["y"] = y;
+				
+				if(xcIndex != -1 && ycIndex != -1)
+				{		  	
+					(*point)["x_component"] = (*it)[xcIndex];
+					(*point)["y_component"] = (*it)[ycIndex];
+					double val =  (valueIndex != -1) ? (*it)[valueIndex] : speed((*it)[xcIndex],  (*it)[ycIndex]);
+					(*point)["colour_component"] =val;				
+					stats_["value"].push_back(val);			
+				}
+				else if(valueIndex != -1)
+				{
+					double val =  (*it)[valueIndex];
+					(*point)["colour_component"] = val;
+					stats_["value"].push_back(val);	
+				}
+				
+				list.push_back(point);			
+				stats_["x"].push_back((*it)[xIndex]);
+				stats_["y"].push_back((*it)[yIndex]);
+		
+				dataIndex_.push_back(dataCnt);
+				dataCnt++;
+				
+				row++;
+				if(nb_rows_ != -1 && row >= nb_rows_)
+				{
+					break;
+				}
+			}
+		}
+
+		computeStats();
+
+		MagLog::info() <<  "Number of rows: " << row << endl;	
+	}	
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}		
+}
+
+void OdaXYDecoder::customisedPoints(const std::set<string>&, CustomisedPointsList& list)
+{     	
+	try
+	{
+		  odb_start();
+		  odb::Reader oda(path_);
+
+		  odb::Reader::iterator it = oda.begin();
+
+		  int xIndex=-1,yIndex=-1,valueIndex=-1,xcIndex=-1,ycIndex=-1;		
+				
+		  if((xIndex=getOdbColumnIndex(it,x_)) == -1)
+			    throw exception();
+		  if((yIndex=getOdbColumnIndex(it,y_)) == -1)
+			    throw exception();	    
+		  if(!value_.empty() && (valueIndex=getOdbColumnIndex(it,value_)) == -1)
+			    throw exception();  
+		  if(!x_component_.empty() && (xcIndex=getOdbColumnIndex(it,x_component_)) == -1)
+			    throw exception();    
+		  if(!y_component_.empty() && (ycIndex=getOdbColumnIndex(it,y_component_)) == -1)
+			    throw exception(); 
+		    
+		  MagLog::info() <<  "Indices: " << xIndex << " " << yIndex << " " << valueIndex << " " << xcIndex << " " <<  xcIndex << endl;
+
+		  int dataCnt=0;
+		  dataIndex_.clear();
+		  
+		  unsigned int row=0;
+			  
+		  for (; it != oda.end(); ++it) 
+		  {
+			  CustomisedPoint* point = new CustomisedPoint();		
+			  double x = (*it)[xIndex];
+			  double y = (*it)[yIndex];
+								    
+			  point->longitude(x);
+			  point->latitude(y);
+			  (*point)["x"] = x;
+			  (*point)["y"] = y;
+				  
+			  if(xcIndex != -1 && ycIndex != -1)
+			  {		  	
+				  (*point)["x_component"] = (*it)[xcIndex];
+				  (*point)["y_component"] = (*it)[ycIndex];
+				  double val =  (valueIndex != -1) ? (*it)[valueIndex] : speed((*it)[xcIndex],  (*it)[ycIndex]);
+				  (*point)["colour_component"] =val;				
+				  stats_["value"].push_back(val);			
+			  }
+			  else if(valueIndex != -1)
+			  {
+				  double val =  (*it)[valueIndex];
+				  (*point)["colour_component"] = val;
+				  stats_["value"].push_back(val);	
+			  }
+				  
+			  list.push_back(point);			
+			  stats_["x"].push_back((*it)[xIndex]);
+			  stats_["y"].push_back((*it)[yIndex]);
+		  
+			  dataIndex_.push_back(dataCnt);
+			  dataCnt++;
+		  
+			  row++;
+			  if(nb_rows_ != -1 && row >= nb_rows_)
+			  {
+					  break;
+			  }
+		  }
+
+		  computeStats();
+
+		  MagLog::info() <<  "Number of rows: " << row << endl;	
+	}	
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}		
+}
+
+void OdaXYDecoder:: visit(TextVisitor& title)
+{
+	if ( !title_.empty() )
+		title.add(new TextEntry(title_));
+	title.addAutomaticTitle("OdbDatabase: " + path_);
+	
+	string numStr=info("stats::points");
+	if(numStr.empty() && stats_["x"].size() >0)
+	{
+	  	numStr=tostring(stats_["x"].size());
+	}	
+	  	
+	
+	if(numStr.empty())
+	{
+		title.addAutomaticTitle(" No points found " );
+	}
+	else
+	{
+		title.addAutomaticTitle("points: " + numStr);
+	}	
+}
+
+void OdaXYDecoder::decode(const Transformation& transformation)
+{
+        if ( !empty() ) 
+		return;  
+
+	try
+	{
+	  
+	      odb_start();
+	      odb::Reader oda(path_);
+
+	      odb::Reader::iterator it = oda.begin();
+
+	      int xIndex=-1,yIndex=-1,valueIndex=-1;		
+			    
+	      if((xIndex=getOdbColumnIndex(it,x_)) == -1)
+			throw exception();
+	      if((yIndex=getOdbColumnIndex(it,y_)) == -1)
+			throw exception();	    
+	      if(!value_.empty() && (valueIndex=getOdbColumnIndex(it,value_)) == -1)
+			throw exception();  
+		      
+	      MagLog::info() <<  "Indices: " << xIndex << " " << yIndex << " " << valueIndex << endl;
+
+	      int dataCnt=0;
+	      dataIndex_.clear();
+	      
+	      unsigned int row=0;
+
+	      for (; it != oda.end(); ++it) 
+	      {			
+		      double x = (*it)[xIndex];
+		      double y = (*it)[yIndex];		
+
+		      if ( transformation.in(x, y)  ) 
+		      {
+			      double val =0;
+			      if (valueIndex!=-1) {
+				      val = (*it)[valueIndex];
+				      stats_["value"].push_back(val);
+			      }
+			      push_back(new UserPoint(x, y, val));
+
+			      stats_["x"].push_back(x);
+			      stats_["y"].push_back(y);
+
+			      dataIndex_.push_back(dataCnt);
+			      dataCnt++;
+			      
+			      row++;
+			      if (nb_rows_ != -1 && row >= nb_rows_)
+			      {
+				      break;
+			      }
+		      }
+	      }
+      
+	      computeStats();
+
+	      MagLog::info() <<  "Number of rows: " << row << endl;	
+	}	
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}	
+
+}
+
+void OdaXYDecoder::decode()
+{
+        if ( !empty() ) 
+		return;  
+
+	try
+	{
+	      odb_start();
+	      odb::Reader oda(path_);
+
+	      odb::Reader::iterator it = oda.begin();
+
+	      int xIndex=-1,yIndex=-1,valueIndex=-1;		
+			    
+	      if((xIndex=getOdbColumnIndex(it,x_)) == -1)
+			throw exception();
+	      if((yIndex=getOdbColumnIndex(it,y_)) == -1)
+			throw exception();	    
+	      if(!value_.empty() && (valueIndex=getOdbColumnIndex(it,value_)) == -1)
+			throw exception();  
+	
+	      MagLog::info() <<  "Indices: " << xIndex << " " << yIndex << " " << valueIndex << endl;
+
+	      int dataCnt=0;
+	      dataIndex_.clear();
+	      
+	      unsigned int row=0;
+
+	      for (; it != oda.end(); ++it) 
+	      {			
+		      double x = (*it)[xIndex];
+		      double y = (*it)[yIndex];
+				      
+		      double val =0;
+		      if (valueIndex!=-1) {
+			      val = (*it)[valueIndex];
+			      stats_["value"].push_back(val);
+		      }
+
+		      stats_["x"].push_back(x);
+		      stats_["y"].push_back(y);
+		      push_back(new UserPoint(x, y, val));
+
+		      dataIndex_.push_back(dataCnt);
+		      dataCnt++;
+		      
+		      row++;
+		      if (nb_rows_ != -1 && row >= nb_rows_)
+		      {
+			      break;
+		      }
+		      
+	      }
+      
+	      //computeStats();
+
+	      MagLog::info() <<  "Number of rows: " << row << endl;
+	} 	
+	catch(exception e)
+	{
+		MagLog::error() << "Failed to read ODB data: " << e.what();
+		return;
+	}	    
+
+}
+void OdaXYDecoder::visit(Transformation& transformation) {
+	decode();
+	if ( empty() ) return;
+	double minx = front()->x_;
+	double maxx = front()->x_;
+	double miny = front()->y_;
+	double maxy = front()->y_;
+
+	for (iterator point = begin(); point != end(); ++point) {
+		if ( minx > (*point)->x_ ) minx = (*point)->x_;
+		if ( miny > (*point)->y_ ) miny = (*point)->y_;
+		if ( maxx < (*point)->x_ ) maxx = (*point)->x_;
+		if ( maxy < (*point)->y_ ) maxy = (*point)->y_;
+	}
+
+	transformation.setDataMinX(minx);
+		transformation.setDataMinY(miny);
+		transformation.setDataMaxX(maxx);
+		transformation.setDataMaxY(maxy);
+
+}
+
+MatrixHandler& OdaXYDecoder::matrix()
+{
+	if  ( !matrix_ ) {
+		decode();
+		matrix_ = (*odb_binning_)(*this);
+		setInfo("hasMatrix","true");
+	}
+
+	matrixHandlers_.push_back(new MatrixHandler(*matrix_));
+	return *(matrixHandlers_.back());
+}
+
+
+void OdaXYDecoder::initInfo()
+{
+	setInfo("_datatype","ODB_xy");
+	setInfo("statsType","scatter");
+	setInfo("path",path_);
+	setInfo("value",value_);
+	setInfo("x",x_);
+	setInfo("y",y_);
+}
+
+void OdaXYDecoder::visit(ValuesCollector& points)
+{
+	if(value_.empty())
+	{
+	  	points.setHasValue(false);
+	}
+  
+  	if(!matrix_ && stats_.find("value") == stats_.end())
+	{
+		points.setCollected(true);	
+	}
+	else
+	{  	
+		points.setCollected(true);
+	}
+	
+	
+	if( points.size() <=0)
+	   return;
+
+	for (ValuesCollector::iterator point =  points.begin(); point != points.end(); ++point)
+	{
+	  	double y=(*point).y();
+	  	double x=(*point).x();
+					
+		if(!matrix_)
+		{
+		  	vector<int> idxV;
+		  	if((*point).mode() == ValuesCollectorPoint::IndexMode) 
+			{
+		  		if((*point).index() >=0 &&  (*point).index() < size())
+				{
+					idxV.push_back((*point).index());
+				}
+				else
+				{
+			  		continue;
+				}	
+			}	
+		  	else
+			{  		  		
+				for(int i=0; i < size(); i++)
+				{
+					if(fabs(at(i)->x()-x) < points.searchRadiusX()&&
+			  	   	   fabs(at(i)->y()-y) < points.searchRadiusY())
+					{
+			  			idxV.push_back(i);
+					}
+				}
+			}	
+		
+			if(idxV.size() ==0)
+				continue;  
+		
+			double dist=10000000.;
+			int minIdx=-1;
+		
+			//MagLog::debug() << "odb collect idxV : " << lat << " " << lon << " " << idxV.size() << endl;
+ 		
+			for(int i=0; i < idxV.size(); i++)
+			{  			
+		  		int idx=idxV[i];
+				double d=(at(idx)->x()-x)*(at(idx)->x()-x) +
+			        	 (at(idx)->y()-y)*(at(idx)->y()-y);
+			
+				if(d < dist)
+				{
+			  		minIdx=idx;
+					dist=d;
+				}
+			}
+			
+			if(minIdx>=0)
+				(*point).push_back(new ValuesCollectorData(at(minIdx)->x(),
+							       at(minIdx)->y(),
+							       at(minIdx)->value(),
+							       dist,minIdx));
+					     		
+		}			
+		else
+		{
+			double val,xp,yp;
+			val=matrix_->nearest(y,x,yp,xp);
+			if(!same(val,matrix_->missing()))
+			{  
+				(*point).push_back(new ValuesCollectorData(xp,yp,val,-1.));
+			}	
+		}	
+	}
+}
+
+void OdaXYDecoder::visit(MetaDataCollector& mdc)
+{	
+	for(map<string, string>::iterator key = mdc.begin(); key != mdc.end(); ++key )
+	{	    
+		if(information_.find(key->first) == information_.end() &&
+		  mdc.attribute(key->first).group() == MetaDataAttribute::StatsGroup)
+		{
+			  computeStats();
+			  break;
+		}
+	}
+	
+	MetviewIcon::visit(mdc);
+}  
+
+void OdaXYDecoder::customisedPoints(const Transformation& transformation, const std::set<string>& needs, CustomisedPointsList& points, bool)
+{
+	customisedPoints(transformation, needs, points);
+}
+
+void OdaGeoDecoder::customisedPoints(const Transformation& transformation, const std::set<string>& needs, CustomisedPointsList& points, bool)
+{
+	customisedPoints(transformation, needs, points);
+}
+
diff --git a/src/oda/OdaDecoder.h b/src/oda/OdaDecoder.h
new file mode 100644
index 0000000..322a847
--- /dev/null
+++ b/src/oda/OdaDecoder.h
@@ -0,0 +1,178 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OdaDecoder.h
+    \brief Definition of the Template class OdaDecoder.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 16-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef OdaDecoder_H
+#define OdaDecoder_H
+
+#include "magics.h"
+
+#include "OdaGeoDecoderAttributes.h"
+#include "OdaXYDecoderAttributes.h"
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "UserPoint.h"
+#include "BinningObject.h"
+
+namespace magics {
+
+
+class OdaMagException : public MagicsException
+{
+public:
+	 OdaMagException( const string& why ):
+		MagicsException("Oda MagException :  " + why ) {}
+};  
+
+class OdaGeoDecoder: public OdaGeoDecoderAttributes, 
+                  public Decoder, 
+                  public Data,
+                  public PointsList
+{
+
+public:
+	OdaGeoDecoder();
+	virtual ~OdaGeoDecoder();
+    
+    //! Decoder interface
+    virtual void decode(const Transformation&);
+    virtual void decode();
+    virtual void set(const map<string, string>& map ) { OdaGeoDecoderAttributes::set(map); }
+    virtual void set(const XmlNode& node ) { OdaGeoDecoderAttributes::set(node); }
+    
+   PointsHandler& points(const Transformation& transformation) {
+    	decode(transformation);
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    } 
+   PointsHandler& points(const Transformation& transformation, bool) {
+    	decode(transformation);
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    }
+   PointsHandler& points() {
+    	decode();
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    }
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, bool);
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& ); 
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+    // implements Automatic title
+    void visit(TextVisitor&);
+    void visit(Transformation&);
+    void visit(ValuesCollector&);
+    void visit(MetaDataCollector&);
+    void initInfo();	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void position(double& lat, double& lon);
+	 
+	 CustomisedPointsList customisedPoints_;
+
+private:
+    //! Copy constructor - No copy allowed
+	OdaGeoDecoder(const OdaGeoDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	OdaGeoDecoder& operator=(const OdaGeoDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const OdaGeoDecoder& p)
+		{ p.print(s); return s; }
+
+};
+class OdaXYDecoder: public OdaXYDecoderAttributes, 
+                  public Decoder, 
+                  public Data,
+                  public PointsList
+{
+public:
+	OdaXYDecoder();
+	virtual ~OdaXYDecoder();
+    
+    //! Decoder interface
+    virtual void decode(const Transformation&);
+    virtual void decode();
+    virtual void set(const map<string, string>& map ) { OdaXYDecoderAttributes::set(map); }
+    virtual void set(const XmlNode& node ) { OdaXYDecoderAttributes::set(node); }
+    void visit(Transformation&);
+    MatrixHandler& matrix();
+
+    
+   PointsHandler& points(const Transformation& transformation) {
+    	decode(transformation);
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    } 
+    PointsHandler& points() {
+    	decode();
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    } 
+    PointsHandler& points(const Transformation& transformation, bool) {
+    	decode(transformation);
+    	pointsHandlers_.push_back(new PointsHandler(*this));
+    	return *(pointsHandlers_.back());
+    }
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&, bool);
+    void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& ); 
+    void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+    // implements Automatic title
+    void visit(TextVisitor&);
+    void visit(ValuesCollector&);
+    void visit(MetaDataCollector&);
+    void initInfo();	
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 Matrix *matrix_;
+
+
+private:
+    //! Copy constructor - No copy allowed
+	OdaXYDecoder(const OdaXYDecoder&);
+    //! Overloaded << operator to copy - No copy allowed
+	OdaXYDecoder& operator=(const OdaXYDecoder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const OdaXYDecoder& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/terralib/Makefile.am b/src/terralib/Makefile.am
new file mode 100644
index 0000000..0dbf0ab
--- /dev/null
+++ b/src/terralib/Makefile.am
@@ -0,0 +1,138 @@
+noinst_LTLIBRARIES	= libterralib.la
+
+include_H		= kernel/checkvec.h kernel/dynpq.h kernel/graph.h kernel/showseq.h \
+			kernel/Gra_algo.h \
+			kernel/TeAbstractFactory.h kernel/TeAbstractTheme.h \
+			kernel/TeAffineGT.h kernel/TeAffineGTFactory.h \
+			kernel/TeAgnostic.h kernel/TeAsciiFile.h \
+			kernel/TeAssertions.h kernel/TeAttribute.h \
+			kernel/TeBaseSTInstance.h kernel/TeBaseSTInstanceSet.h \
+			kernel/TeBox.h kernel/TeBufferRegion.h \
+			kernel/TeComposite.h kernel/TeCoord2D.h \
+			kernel/TeCounted.h \
+			kernel/TeDBConnection.h kernel/TeDBConnectionsPool.h \
+			kernel/TeDataTypes.h kernel/TeDatabase.h \
+			kernel/TeDatabaseFactory.h kernel/TeDatabaseFactoryParams.h \
+			kernel/TeDatum.h kernel/TeDecoder.h \
+			kernel/TeDecoderASCIIGrid.h kernel/TeDecoderDatabase.h \
+			kernel/TeDecoderFile.h kernel/TeDecoderMemory.h \
+			kernel/TeDecoderMemoryMap.h kernel/TeDecoderSPR.h \
+			kernel/TeDecoderSmartMem.h kernel/TeDecoderVirtualMemory.h \
+			kernel/TeDefines.h \
+			kernel/TeErrorLog.h kernel/TeErrorMessage.h \
+			kernel/TeException.h kernel/TeExternalTheme.h \
+			kernel/TeFactory.h kernel/TeFragmentation.h \
+			kernel/TeGTFactory.h kernel/TeGTParams.h \
+			kernel/TeGeometricTransformation.h kernel/TeGeometry.h \
+			kernel/TeGeometryAlgorithms.h kernel/TeGroupingAlgorithms.h \
+			kernel/TeImportRaster.h kernel/TeInitRasterDecoders.h \
+			kernel/TeIntersector.h \
+			kernel/TeKdTree.h \
+			kernel/TeLayer.h kernel/TeLegendEntry.h \
+			kernel/TeMappedMemory.h kernel/TeMatrix.h \
+			kernel/TeMeasure.h kernel/TeMetaModelCache.h \
+			kernel/TeMultiContainer.h kernel/TeMultiGeometry.h \
+			kernel/TeMutex.h \
+			kernel/TeNeighbours.h kernel/TeNetwork.h \
+			kernel/TeOverlay.h kernel/TeOverlayUtils.h \
+			kernel/TePieBar.h kernel/TePrecision.h \
+			kernel/TeProgress.h kernel/TeProgressBase.h \
+			kernel/TeProject.h kernel/TeProjection.h \
+			kernel/TeProjectiveGT.h kernel/TeProjectiveGTFactory.h \
+			kernel/TePrototype.h kernel/TeProxMatrixConstructionStrategy.h \
+			kernel/TeProxMatrixImplementation.h \
+			kernel/TeProxMatrixSlicingStrategy.h \
+			kernel/TeProxMatrixWeightsStrategy.h \
+			kernel/TeQuerier.h kernel/TeQuerierDB.h \
+			kernel/TeQuerierDBStr1.h kernel/TeQuerierDBStr2.h \
+			kernel/TeQuerierDBStr3.h kernel/TeQuerierImpl.h \
+			kernel/TeQuerierParams.h \
+			kernel/TeRTree.h kernel/TeRaster.h \
+			kernel/TeRasterMemManager.h kernel/TeRasterParams.h \
+			kernel/TeRasterRemap.h kernel/TeRasterTransform.h \
+			kernel/TeRepresentation.h \
+			kernel/TeSTEFunctionsDB.h kernel/TeSTElementSet.h \
+			kernel/TeSTEvent.h kernel/TeSTInstance.h \
+			kernel/TeSharedPtr.h kernel/TeSingleton.h \
+			kernel/TeSlice.h kernel/TeSpatialOperations.h \
+			kernel/TeStatistics.h kernel/TeStdFile.h \
+			kernel/TeTable.h kernel/TeTemporalSeries.h \
+			kernel/TeTheme.h kernel/TeThread.h \
+			kernel/TeThreadDatatypes.h kernel/TeThreadFunctor.h \
+			kernel/TeThreadParameters.h kernel/TeThreadSignal.h \
+			kernel/TeTime.h kernel/TeTimeInterval.h \
+			kernel/TeTin.h \
+			kernel/TeUtils.h \
+			kernel/TeVectorRemap.h kernel/TeView.h \
+			kernel/TeViewNode.h kernel/TeVisual.h \
+			kernel/yyTemporal.h \
+			utils/TeDatabaseUtils.h
+
+
+libterralib_la_SOURCES	= \
+			kernel/TeAbstractTheme.cpp \
+			kernel/TeAffineGT.cpp kernel/TeAffineGTFactory.cpp \
+			kernel/TeAgnostic.cpp kernel/TeAsciiFile.cpp \
+			kernel/TeBox.cpp kernel/TeBufferRegion.cpp \
+			kernel/TeCentroid.cpp \
+			kernel/TeDBConnection.cpp kernel/TeDBConnectionsPool.cpp \
+			kernel/TeDatabase.cpp kernel/TeDatabaseFactoryParams.cpp \
+			kernel/TeDatum.cpp kernel/TeDecoderASCIIGrid.cpp \
+			kernel/TeDecoderDatabase.cpp kernel/TeDecoderFile.cpp \
+			kernel/TeDecoderMemory.cpp kernel/TeDecoderMemoryMap.cpp \
+			kernel/TeDecoderSPR.cpp kernel/TeDecoderSmartMem.cpp \
+			kernel/TeDecoderVirtualMemory.cpp \
+			kernel/TeErrorLog.cpp kernel/TeErrorMessage.cpp \
+			kernel/TeException.cpp kernel/TeExternalTheme.cpp \
+			kernel/TeFragmentation.cpp \
+			kernel/TeGTFactory.cpp kernel/TeGTParams.cpp \
+			kernel/TeGeometricTransformation.cpp kernel/TeGeometry.cpp \
+			kernel/TeGeometryAlgorithms.cpp kernel/TeGroupingAlgorithms.cpp \
+			kernel/TeImportRaster.cpp kernel/TeInitRasterDecoders.cpp \
+			kernel/TeIntersector.cpp \
+			kernel/TeLayer.cpp kernel/TeLegendEntry.cpp \
+			kernel/TeMappedMemory.cpp kernel/TeMatrix.cpp \
+			kernel/TeMetaModelCache.cpp kernel/TeMultiGeometry.cpp \
+			kernel/TeMutex.cpp \
+			kernel/TeNeighbours.cpp kernel/TeNetwork.cpp \
+			kernel/TeOverlay.cpp kernel/TeOverlayUtils.cpp \
+			kernel/TeProgress.cpp kernel/TeProject.cpp \
+			kernel/TeProjection.cpp kernel/TeProjectiveGT.cpp \
+			kernel/TeProjectiveGTFactory.cpp \
+			kernel/TeProxMatrixConstructionStrategy.cpp \
+			kernel/TeProxMatrixImplementation.cpp \
+			kernel/TeProxMatrixStrategies.cpp \
+			kernel/TeQuerier.cpp kernel/TeQuerierDB.cpp \
+			kernel/TeQuerierDBStr1.cpp kernel/TeQuerierDBStr2.cpp \
+			kernel/TeQuerierDBStr3.cpp kernel/TeQuerierImpl.cpp \
+			kernel/TeQuerierParams.cpp \
+			kernel/TeRaster.cpp kernel/TeRasterMemManager.cpp \
+			kernel/TeRasterParams.cpp kernel/TeRasterRemap.cpp \
+			kernel/TeRasterTransform.cpp kernel/TeRepresentation.cpp \
+			kernel/TeSTElementSet.cpp kernel/TeSTEvent.cpp \
+			kernel/TeSTInstance.cpp kernel/TeSpatialOperations.cpp \
+			kernel/TeStdFile.cpp \
+			kernel/TeTable.cpp kernel/TeTemporalSeries.cpp \
+			kernel/TeTheme.cpp kernel/TeThread.cpp \
+			kernel/TeThreadFunctor.cpp kernel/TeThreadSignal.cpp \
+			kernel/TeTime.cpp kernel/TeTimeInterval.cpp \
+			kernel/TeTin.cpp \
+			kernel/TeUtils.cpp \
+			kernel/TeVectorRemap.cpp kernel/TeViewNode.cpp \
+			kernel/TeVisual.cpp \
+			kernel/lexTemporal.cpp kernel/yyTemporal.cpp
+
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= 
+else
+include_HEADERS = 
+noinst_HEADERS	= $(include_H)
+endif
+
+libterralib_la_CXXFLAGS	= -DNO_HUGE -DXTFUNCPROTO -DLITTLEENDIAN -DS4LINUX -DS4MDX -DS4NO_STRNICMP -DXK_MISCELLANY -DNO_TEJPEG -DNO_TETIFF
+libterralib_la_LDFLAGS	= -no-undefined -no-install
+#AM_CPPFLAGS		= -I$(top_srcdir)/src/terralib -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/terralib/jpeg -I$(top_srcdir)/src/terralib/functions -I$(top_srcdir)/src/terralib/utils
+AM_CPPFLAGS		= -I$(top_srcdir)/src/terralib -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/terralib/utils
+#EXTRA_DIST		= jpeg/ijl.h jpeg/jpeg.h
diff --git a/src/terralib/Makefile.in b/src/terralib/Makefile.in
new file mode 100644
index 0000000..3c2edac
--- /dev/null
+++ b/src/terralib/Makefile.in
@@ -0,0 +1,1704 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/terralib
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libterralib_la_LIBADD =
+am_libterralib_la_OBJECTS = libterralib_la-TeAbstractTheme.lo \
+	libterralib_la-TeAffineGT.lo \
+	libterralib_la-TeAffineGTFactory.lo \
+	libterralib_la-TeAgnostic.lo libterralib_la-TeAsciiFile.lo \
+	libterralib_la-TeBox.lo libterralib_la-TeBufferRegion.lo \
+	libterralib_la-TeCentroid.lo libterralib_la-TeDBConnection.lo \
+	libterralib_la-TeDBConnectionsPool.lo \
+	libterralib_la-TeDatabase.lo \
+	libterralib_la-TeDatabaseFactoryParams.lo \
+	libterralib_la-TeDatum.lo libterralib_la-TeDecoderASCIIGrid.lo \
+	libterralib_la-TeDecoderDatabase.lo \
+	libterralib_la-TeDecoderFile.lo \
+	libterralib_la-TeDecoderMemory.lo \
+	libterralib_la-TeDecoderMemoryMap.lo \
+	libterralib_la-TeDecoderSPR.lo \
+	libterralib_la-TeDecoderSmartMem.lo \
+	libterralib_la-TeDecoderVirtualMemory.lo \
+	libterralib_la-TeErrorLog.lo libterralib_la-TeErrorMessage.lo \
+	libterralib_la-TeException.lo \
+	libterralib_la-TeExternalTheme.lo \
+	libterralib_la-TeFragmentation.lo \
+	libterralib_la-TeGTFactory.lo libterralib_la-TeGTParams.lo \
+	libterralib_la-TeGeometricTransformation.lo \
+	libterralib_la-TeGeometry.lo \
+	libterralib_la-TeGeometryAlgorithms.lo \
+	libterralib_la-TeGroupingAlgorithms.lo \
+	libterralib_la-TeImportRaster.lo \
+	libterralib_la-TeInitRasterDecoders.lo \
+	libterralib_la-TeIntersector.lo libterralib_la-TeLayer.lo \
+	libterralib_la-TeLegendEntry.lo \
+	libterralib_la-TeMappedMemory.lo libterralib_la-TeMatrix.lo \
+	libterralib_la-TeMetaModelCache.lo \
+	libterralib_la-TeMultiGeometry.lo libterralib_la-TeMutex.lo \
+	libterralib_la-TeNeighbours.lo libterralib_la-TeNetwork.lo \
+	libterralib_la-TeOverlay.lo libterralib_la-TeOverlayUtils.lo \
+	libterralib_la-TeProgress.lo libterralib_la-TeProject.lo \
+	libterralib_la-TeProjection.lo \
+	libterralib_la-TeProjectiveGT.lo \
+	libterralib_la-TeProjectiveGTFactory.lo \
+	libterralib_la-TeProxMatrixConstructionStrategy.lo \
+	libterralib_la-TeProxMatrixImplementation.lo \
+	libterralib_la-TeProxMatrixStrategies.lo \
+	libterralib_la-TeQuerier.lo libterralib_la-TeQuerierDB.lo \
+	libterralib_la-TeQuerierDBStr1.lo \
+	libterralib_la-TeQuerierDBStr2.lo \
+	libterralib_la-TeQuerierDBStr3.lo \
+	libterralib_la-TeQuerierImpl.lo \
+	libterralib_la-TeQuerierParams.lo libterralib_la-TeRaster.lo \
+	libterralib_la-TeRasterMemManager.lo \
+	libterralib_la-TeRasterParams.lo \
+	libterralib_la-TeRasterRemap.lo \
+	libterralib_la-TeRasterTransform.lo \
+	libterralib_la-TeRepresentation.lo \
+	libterralib_la-TeSTElementSet.lo libterralib_la-TeSTEvent.lo \
+	libterralib_la-TeSTInstance.lo \
+	libterralib_la-TeSpatialOperations.lo \
+	libterralib_la-TeStdFile.lo libterralib_la-TeTable.lo \
+	libterralib_la-TeTemporalSeries.lo libterralib_la-TeTheme.lo \
+	libterralib_la-TeThread.lo libterralib_la-TeThreadFunctor.lo \
+	libterralib_la-TeThreadSignal.lo libterralib_la-TeTime.lo \
+	libterralib_la-TeTimeInterval.lo libterralib_la-TeTin.lo \
+	libterralib_la-TeUtils.lo libterralib_la-TeVectorRemap.lo \
+	libterralib_la-TeViewNode.lo libterralib_la-TeVisual.lo \
+	libterralib_la-lexTemporal.lo libterralib_la-yyTemporal.lo
+libterralib_la_OBJECTS = $(am_libterralib_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libterralib_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(libterralib_la_CXXFLAGS) $(CXXFLAGS) \
+	$(libterralib_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libterralib_la_SOURCES)
+DIST_SOURCES = $(libterralib_la_SOURCES)
+am__include_HEADERS_DIST = kernel/checkvec.h kernel/dynpq.h \
+	kernel/graph.h kernel/showseq.h kernel/Gra_algo.h \
+	kernel/TeAbstractFactory.h kernel/TeAbstractTheme.h \
+	kernel/TeAffineGT.h kernel/TeAffineGTFactory.h \
+	kernel/TeAgnostic.h kernel/TeAsciiFile.h kernel/TeAssertions.h \
+	kernel/TeAttribute.h kernel/TeBaseSTInstance.h \
+	kernel/TeBaseSTInstanceSet.h kernel/TeBox.h \
+	kernel/TeBufferRegion.h kernel/TeComposite.h \
+	kernel/TeCoord2D.h kernel/TeCounted.h kernel/TeDBConnection.h \
+	kernel/TeDBConnectionsPool.h kernel/TeDataTypes.h \
+	kernel/TeDatabase.h kernel/TeDatabaseFactory.h \
+	kernel/TeDatabaseFactoryParams.h kernel/TeDatum.h \
+	kernel/TeDecoder.h kernel/TeDecoderASCIIGrid.h \
+	kernel/TeDecoderDatabase.h kernel/TeDecoderFile.h \
+	kernel/TeDecoderMemory.h kernel/TeDecoderMemoryMap.h \
+	kernel/TeDecoderSPR.h kernel/TeDecoderSmartMem.h \
+	kernel/TeDecoderVirtualMemory.h kernel/TeDefines.h \
+	kernel/TeErrorLog.h kernel/TeErrorMessage.h \
+	kernel/TeException.h kernel/TeExternalTheme.h \
+	kernel/TeFactory.h kernel/TeFragmentation.h \
+	kernel/TeGTFactory.h kernel/TeGTParams.h \
+	kernel/TeGeometricTransformation.h kernel/TeGeometry.h \
+	kernel/TeGeometryAlgorithms.h kernel/TeGroupingAlgorithms.h \
+	kernel/TeImportRaster.h kernel/TeInitRasterDecoders.h \
+	kernel/TeIntersector.h kernel/TeKdTree.h kernel/TeLayer.h \
+	kernel/TeLegendEntry.h kernel/TeMappedMemory.h \
+	kernel/TeMatrix.h kernel/TeMeasure.h kernel/TeMetaModelCache.h \
+	kernel/TeMultiContainer.h kernel/TeMultiGeometry.h \
+	kernel/TeMutex.h kernel/TeNeighbours.h kernel/TeNetwork.h \
+	kernel/TeOverlay.h kernel/TeOverlayUtils.h kernel/TePieBar.h \
+	kernel/TePrecision.h kernel/TeProgress.h \
+	kernel/TeProgressBase.h kernel/TeProject.h \
+	kernel/TeProjection.h kernel/TeProjectiveGT.h \
+	kernel/TeProjectiveGTFactory.h kernel/TePrototype.h \
+	kernel/TeProxMatrixConstructionStrategy.h \
+	kernel/TeProxMatrixImplementation.h \
+	kernel/TeProxMatrixSlicingStrategy.h \
+	kernel/TeProxMatrixWeightsStrategy.h kernel/TeQuerier.h \
+	kernel/TeQuerierDB.h kernel/TeQuerierDBStr1.h \
+	kernel/TeQuerierDBStr2.h kernel/TeQuerierDBStr3.h \
+	kernel/TeQuerierImpl.h kernel/TeQuerierParams.h \
+	kernel/TeRTree.h kernel/TeRaster.h kernel/TeRasterMemManager.h \
+	kernel/TeRasterParams.h kernel/TeRasterRemap.h \
+	kernel/TeRasterTransform.h kernel/TeRepresentation.h \
+	kernel/TeSTEFunctionsDB.h kernel/TeSTElementSet.h \
+	kernel/TeSTEvent.h kernel/TeSTInstance.h kernel/TeSharedPtr.h \
+	kernel/TeSingleton.h kernel/TeSlice.h \
+	kernel/TeSpatialOperations.h kernel/TeStatistics.h \
+	kernel/TeStdFile.h kernel/TeTable.h kernel/TeTemporalSeries.h \
+	kernel/TeTheme.h kernel/TeThread.h kernel/TeThreadDatatypes.h \
+	kernel/TeThreadFunctor.h kernel/TeThreadParameters.h \
+	kernel/TeThreadSignal.h kernel/TeTime.h \
+	kernel/TeTimeInterval.h kernel/TeTin.h kernel/TeUtils.h \
+	kernel/TeVectorRemap.h kernel/TeView.h kernel/TeViewNode.h \
+	kernel/TeVisual.h kernel/yyTemporal.h utils/TeDatabaseUtils.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = kernel/checkvec.h kernel/dynpq.h \
+	kernel/graph.h kernel/showseq.h kernel/Gra_algo.h \
+	kernel/TeAbstractFactory.h kernel/TeAbstractTheme.h \
+	kernel/TeAffineGT.h kernel/TeAffineGTFactory.h \
+	kernel/TeAgnostic.h kernel/TeAsciiFile.h kernel/TeAssertions.h \
+	kernel/TeAttribute.h kernel/TeBaseSTInstance.h \
+	kernel/TeBaseSTInstanceSet.h kernel/TeBox.h \
+	kernel/TeBufferRegion.h kernel/TeComposite.h \
+	kernel/TeCoord2D.h kernel/TeCounted.h kernel/TeDBConnection.h \
+	kernel/TeDBConnectionsPool.h kernel/TeDataTypes.h \
+	kernel/TeDatabase.h kernel/TeDatabaseFactory.h \
+	kernel/TeDatabaseFactoryParams.h kernel/TeDatum.h \
+	kernel/TeDecoder.h kernel/TeDecoderASCIIGrid.h \
+	kernel/TeDecoderDatabase.h kernel/TeDecoderFile.h \
+	kernel/TeDecoderMemory.h kernel/TeDecoderMemoryMap.h \
+	kernel/TeDecoderSPR.h kernel/TeDecoderSmartMem.h \
+	kernel/TeDecoderVirtualMemory.h kernel/TeDefines.h \
+	kernel/TeErrorLog.h kernel/TeErrorMessage.h \
+	kernel/TeException.h kernel/TeExternalTheme.h \
+	kernel/TeFactory.h kernel/TeFragmentation.h \
+	kernel/TeGTFactory.h kernel/TeGTParams.h \
+	kernel/TeGeometricTransformation.h kernel/TeGeometry.h \
+	kernel/TeGeometryAlgorithms.h kernel/TeGroupingAlgorithms.h \
+	kernel/TeImportRaster.h kernel/TeInitRasterDecoders.h \
+	kernel/TeIntersector.h kernel/TeKdTree.h kernel/TeLayer.h \
+	kernel/TeLegendEntry.h kernel/TeMappedMemory.h \
+	kernel/TeMatrix.h kernel/TeMeasure.h kernel/TeMetaModelCache.h \
+	kernel/TeMultiContainer.h kernel/TeMultiGeometry.h \
+	kernel/TeMutex.h kernel/TeNeighbours.h kernel/TeNetwork.h \
+	kernel/TeOverlay.h kernel/TeOverlayUtils.h kernel/TePieBar.h \
+	kernel/TePrecision.h kernel/TeProgress.h \
+	kernel/TeProgressBase.h kernel/TeProject.h \
+	kernel/TeProjection.h kernel/TeProjectiveGT.h \
+	kernel/TeProjectiveGTFactory.h kernel/TePrototype.h \
+	kernel/TeProxMatrixConstructionStrategy.h \
+	kernel/TeProxMatrixImplementation.h \
+	kernel/TeProxMatrixSlicingStrategy.h \
+	kernel/TeProxMatrixWeightsStrategy.h kernel/TeQuerier.h \
+	kernel/TeQuerierDB.h kernel/TeQuerierDBStr1.h \
+	kernel/TeQuerierDBStr2.h kernel/TeQuerierDBStr3.h \
+	kernel/TeQuerierImpl.h kernel/TeQuerierParams.h \
+	kernel/TeRTree.h kernel/TeRaster.h kernel/TeRasterMemManager.h \
+	kernel/TeRasterParams.h kernel/TeRasterRemap.h \
+	kernel/TeRasterTransform.h kernel/TeRepresentation.h \
+	kernel/TeSTEFunctionsDB.h kernel/TeSTElementSet.h \
+	kernel/TeSTEvent.h kernel/TeSTInstance.h kernel/TeSharedPtr.h \
+	kernel/TeSingleton.h kernel/TeSlice.h \
+	kernel/TeSpatialOperations.h kernel/TeStatistics.h \
+	kernel/TeStdFile.h kernel/TeTable.h kernel/TeTemporalSeries.h \
+	kernel/TeTheme.h kernel/TeThread.h kernel/TeThreadDatatypes.h \
+	kernel/TeThreadFunctor.h kernel/TeThreadParameters.h \
+	kernel/TeThreadSignal.h kernel/TeTime.h \
+	kernel/TeTimeInterval.h kernel/TeTin.h kernel/TeUtils.h \
+	kernel/TeVectorRemap.h kernel/TeView.h kernel/TeViewNode.h \
+	kernel/TeVisual.h kernel/yyTemporal.h utils/TeDatabaseUtils.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libterralib.la
+include_H = kernel/checkvec.h kernel/dynpq.h kernel/graph.h kernel/showseq.h \
+			kernel/Gra_algo.h \
+			kernel/TeAbstractFactory.h kernel/TeAbstractTheme.h \
+			kernel/TeAffineGT.h kernel/TeAffineGTFactory.h \
+			kernel/TeAgnostic.h kernel/TeAsciiFile.h \
+			kernel/TeAssertions.h kernel/TeAttribute.h \
+			kernel/TeBaseSTInstance.h kernel/TeBaseSTInstanceSet.h \
+			kernel/TeBox.h kernel/TeBufferRegion.h \
+			kernel/TeComposite.h kernel/TeCoord2D.h \
+			kernel/TeCounted.h \
+			kernel/TeDBConnection.h kernel/TeDBConnectionsPool.h \
+			kernel/TeDataTypes.h kernel/TeDatabase.h \
+			kernel/TeDatabaseFactory.h kernel/TeDatabaseFactoryParams.h \
+			kernel/TeDatum.h kernel/TeDecoder.h \
+			kernel/TeDecoderASCIIGrid.h kernel/TeDecoderDatabase.h \
+			kernel/TeDecoderFile.h kernel/TeDecoderMemory.h \
+			kernel/TeDecoderMemoryMap.h kernel/TeDecoderSPR.h \
+			kernel/TeDecoderSmartMem.h kernel/TeDecoderVirtualMemory.h \
+			kernel/TeDefines.h \
+			kernel/TeErrorLog.h kernel/TeErrorMessage.h \
+			kernel/TeException.h kernel/TeExternalTheme.h \
+			kernel/TeFactory.h kernel/TeFragmentation.h \
+			kernel/TeGTFactory.h kernel/TeGTParams.h \
+			kernel/TeGeometricTransformation.h kernel/TeGeometry.h \
+			kernel/TeGeometryAlgorithms.h kernel/TeGroupingAlgorithms.h \
+			kernel/TeImportRaster.h kernel/TeInitRasterDecoders.h \
+			kernel/TeIntersector.h \
+			kernel/TeKdTree.h \
+			kernel/TeLayer.h kernel/TeLegendEntry.h \
+			kernel/TeMappedMemory.h kernel/TeMatrix.h \
+			kernel/TeMeasure.h kernel/TeMetaModelCache.h \
+			kernel/TeMultiContainer.h kernel/TeMultiGeometry.h \
+			kernel/TeMutex.h \
+			kernel/TeNeighbours.h kernel/TeNetwork.h \
+			kernel/TeOverlay.h kernel/TeOverlayUtils.h \
+			kernel/TePieBar.h kernel/TePrecision.h \
+			kernel/TeProgress.h kernel/TeProgressBase.h \
+			kernel/TeProject.h kernel/TeProjection.h \
+			kernel/TeProjectiveGT.h kernel/TeProjectiveGTFactory.h \
+			kernel/TePrototype.h kernel/TeProxMatrixConstructionStrategy.h \
+			kernel/TeProxMatrixImplementation.h \
+			kernel/TeProxMatrixSlicingStrategy.h \
+			kernel/TeProxMatrixWeightsStrategy.h \
+			kernel/TeQuerier.h kernel/TeQuerierDB.h \
+			kernel/TeQuerierDBStr1.h kernel/TeQuerierDBStr2.h \
+			kernel/TeQuerierDBStr3.h kernel/TeQuerierImpl.h \
+			kernel/TeQuerierParams.h \
+			kernel/TeRTree.h kernel/TeRaster.h \
+			kernel/TeRasterMemManager.h kernel/TeRasterParams.h \
+			kernel/TeRasterRemap.h kernel/TeRasterTransform.h \
+			kernel/TeRepresentation.h \
+			kernel/TeSTEFunctionsDB.h kernel/TeSTElementSet.h \
+			kernel/TeSTEvent.h kernel/TeSTInstance.h \
+			kernel/TeSharedPtr.h kernel/TeSingleton.h \
+			kernel/TeSlice.h kernel/TeSpatialOperations.h \
+			kernel/TeStatistics.h kernel/TeStdFile.h \
+			kernel/TeTable.h kernel/TeTemporalSeries.h \
+			kernel/TeTheme.h kernel/TeThread.h \
+			kernel/TeThreadDatatypes.h kernel/TeThreadFunctor.h \
+			kernel/TeThreadParameters.h kernel/TeThreadSignal.h \
+			kernel/TeTime.h kernel/TeTimeInterval.h \
+			kernel/TeTin.h \
+			kernel/TeUtils.h \
+			kernel/TeVectorRemap.h kernel/TeView.h \
+			kernel/TeViewNode.h kernel/TeVisual.h \
+			kernel/yyTemporal.h \
+			utils/TeDatabaseUtils.h
+
+libterralib_la_SOURCES = \
+			kernel/TeAbstractTheme.cpp \
+			kernel/TeAffineGT.cpp kernel/TeAffineGTFactory.cpp \
+			kernel/TeAgnostic.cpp kernel/TeAsciiFile.cpp \
+			kernel/TeBox.cpp kernel/TeBufferRegion.cpp \
+			kernel/TeCentroid.cpp \
+			kernel/TeDBConnection.cpp kernel/TeDBConnectionsPool.cpp \
+			kernel/TeDatabase.cpp kernel/TeDatabaseFactoryParams.cpp \
+			kernel/TeDatum.cpp kernel/TeDecoderASCIIGrid.cpp \
+			kernel/TeDecoderDatabase.cpp kernel/TeDecoderFile.cpp \
+			kernel/TeDecoderMemory.cpp kernel/TeDecoderMemoryMap.cpp \
+			kernel/TeDecoderSPR.cpp kernel/TeDecoderSmartMem.cpp \
+			kernel/TeDecoderVirtualMemory.cpp \
+			kernel/TeErrorLog.cpp kernel/TeErrorMessage.cpp \
+			kernel/TeException.cpp kernel/TeExternalTheme.cpp \
+			kernel/TeFragmentation.cpp \
+			kernel/TeGTFactory.cpp kernel/TeGTParams.cpp \
+			kernel/TeGeometricTransformation.cpp kernel/TeGeometry.cpp \
+			kernel/TeGeometryAlgorithms.cpp kernel/TeGroupingAlgorithms.cpp \
+			kernel/TeImportRaster.cpp kernel/TeInitRasterDecoders.cpp \
+			kernel/TeIntersector.cpp \
+			kernel/TeLayer.cpp kernel/TeLegendEntry.cpp \
+			kernel/TeMappedMemory.cpp kernel/TeMatrix.cpp \
+			kernel/TeMetaModelCache.cpp kernel/TeMultiGeometry.cpp \
+			kernel/TeMutex.cpp \
+			kernel/TeNeighbours.cpp kernel/TeNetwork.cpp \
+			kernel/TeOverlay.cpp kernel/TeOverlayUtils.cpp \
+			kernel/TeProgress.cpp kernel/TeProject.cpp \
+			kernel/TeProjection.cpp kernel/TeProjectiveGT.cpp \
+			kernel/TeProjectiveGTFactory.cpp \
+			kernel/TeProxMatrixConstructionStrategy.cpp \
+			kernel/TeProxMatrixImplementation.cpp \
+			kernel/TeProxMatrixStrategies.cpp \
+			kernel/TeQuerier.cpp kernel/TeQuerierDB.cpp \
+			kernel/TeQuerierDBStr1.cpp kernel/TeQuerierDBStr2.cpp \
+			kernel/TeQuerierDBStr3.cpp kernel/TeQuerierImpl.cpp \
+			kernel/TeQuerierParams.cpp \
+			kernel/TeRaster.cpp kernel/TeRasterMemManager.cpp \
+			kernel/TeRasterParams.cpp kernel/TeRasterRemap.cpp \
+			kernel/TeRasterTransform.cpp kernel/TeRepresentation.cpp \
+			kernel/TeSTElementSet.cpp kernel/TeSTEvent.cpp \
+			kernel/TeSTInstance.cpp kernel/TeSpatialOperations.cpp \
+			kernel/TeStdFile.cpp \
+			kernel/TeTable.cpp kernel/TeTemporalSeries.cpp \
+			kernel/TeTheme.cpp kernel/TeThread.cpp \
+			kernel/TeThreadFunctor.cpp kernel/TeThreadSignal.cpp \
+			kernel/TeTime.cpp kernel/TeTimeInterval.cpp \
+			kernel/TeTin.cpp \
+			kernel/TeUtils.cpp \
+			kernel/TeVectorRemap.cpp kernel/TeViewNode.cpp \
+			kernel/TeVisual.cpp \
+			kernel/lexTemporal.cpp kernel/yyTemporal.cpp
+
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = 
+libterralib_la_CXXFLAGS = -DNO_HUGE -DXTFUNCPROTO -DLITTLEENDIAN -DS4LINUX -DS4MDX -DS4NO_STRNICMP -DXK_MISCELLANY -DNO_TEJPEG -DNO_TETIFF
+libterralib_la_LDFLAGS = -no-undefined -no-install
+#AM_CPPFLAGS		= -I$(top_srcdir)/src/terralib -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/terralib/jpeg -I$(top_srcdir)/src/terralib/functions -I$(top_srcdir)/src/terralib/utils
+AM_CPPFLAGS = -I$(top_srcdir)/src/terralib -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/terralib/utils
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/terralib/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/terralib/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libterralib.la: $(libterralib_la_OBJECTS) $(libterralib_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libterralib_la_LINK)  $(libterralib_la_OBJECTS) $(libterralib_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeAbstractTheme.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeAffineGT.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeAffineGTFactory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeAgnostic.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeAsciiFile.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeBox.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeBufferRegion.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeCentroid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDBConnection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDBConnectionsPool.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDatabase.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDatabaseFactoryParams.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDatum.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderASCIIGrid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderDatabase.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderFile.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderMemory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderMemoryMap.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderSPR.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderSmartMem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeDecoderVirtualMemory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeErrorLog.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeErrorMessage.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeException.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeExternalTheme.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeFragmentation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeGTFactory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeGTParams.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeGeometricTransformation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeGeometry.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeGeometryAlgorithms.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeGroupingAlgorithms.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeImportRaster.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeInitRasterDecoders.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeIntersector.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeLayer.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeLegendEntry.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeMappedMemory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeMatrix.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeMetaModelCache.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeMultiGeometry.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeMutex.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeNeighbours.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeNetwork.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeOverlay.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeOverlayUtils.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProgress.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProject.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProjection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProjectiveGT.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProjectiveGTFactory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProxMatrixConstructionStrategy.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProxMatrixImplementation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeProxMatrixStrategies.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerier.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerierDB.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerierDBStr1.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerierDBStr2.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerierDBStr3.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerierImpl.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeQuerierParams.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeRaster.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeRasterMemManager.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeRasterParams.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeRasterRemap.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeRasterTransform.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeRepresentation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeSTElementSet.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeSTEvent.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeSTInstance.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeSpatialOperations.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeStdFile.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeTable.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeTemporalSeries.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeTheme.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeThread.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeThreadFunctor.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeThreadSignal.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeTime.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeTimeInterval.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeTin.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeUtils.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeVectorRemap.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeViewNode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-TeVisual.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-lexTemporal.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libterralib_la-yyTemporal.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+libterralib_la-TeAbstractTheme.lo: kernel/TeAbstractTheme.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeAbstractTheme.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeAbstractTheme.Tpo -c -o libterralib_la-TeAbstractTheme.lo `test -f 'kernel/TeAbstractTheme.cpp' || echo '$(srcdir)/'`kernel/TeAbstractTheme.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeAbstractTheme.Tpo $(DEPDIR)/libterralib_la-TeAbstractTheme.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeAbstractTheme.cpp' object='libterralib_la-TeAbstractTheme.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeAbstractTheme.lo `test -f 'kernel/TeAbstractTheme.cpp' || echo '$(srcdir)/'`kernel/TeAbstractTheme.cpp
+
+libterralib_la-TeAffineGT.lo: kernel/TeAffineGT.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeAffineGT.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeAffineGT.Tpo -c -o libterralib_la-TeAffineGT.lo `test -f 'kernel/TeAffineGT.cpp' || echo '$(srcdir)/'`kernel/TeAffineGT.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeAffineGT.Tpo $(DEPDIR)/libterralib_la-TeAffineGT.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeAffineGT.cpp' object='libterralib_la-TeAffineGT.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeAffineGT.lo `test -f 'kernel/TeAffineGT.cpp' || echo '$(srcdir)/'`kernel/TeAffineGT.cpp
+
+libterralib_la-TeAffineGTFactory.lo: kernel/TeAffineGTFactory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeAffineGTFactory.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeAffineGTFactory.Tpo -c -o libterralib_la-TeAffineGTFactory.lo `test -f 'kernel/TeAffineGTFactory.cpp' || echo '$(srcdir)/'`kernel/TeAffineGTFactory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeAffineGTFactory.Tpo $(DEPDIR)/libterralib_la-TeAffineGTFactory.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeAffineGTFactory.cpp' object='libterralib_la-TeAffineGTFactory.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeAffineGTFactory.lo `test -f 'kernel/TeAffineGTFactory.cpp' || echo '$(srcdir)/'`kernel/TeAffineGTFactory.cpp
+
+libterralib_la-TeAgnostic.lo: kernel/TeAgnostic.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeAgnostic.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeAgnostic.Tpo -c -o libterralib_la-TeAgnostic.lo `test -f 'kernel/TeAgnostic.cpp' || echo '$(srcdir)/'`kernel/TeAgnostic.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeAgnostic.Tpo $(DEPDIR)/libterralib_la-TeAgnostic.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeAgnostic.cpp' object='libterralib_la-TeAgnostic.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeAgnostic.lo `test -f 'kernel/TeAgnostic.cpp' || echo '$(srcdir)/'`kernel/TeAgnostic.cpp
+
+libterralib_la-TeAsciiFile.lo: kernel/TeAsciiFile.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeAsciiFile.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeAsciiFile.Tpo -c -o libterralib_la-TeAsciiFile.lo `test -f 'kernel/TeAsciiFile.cpp' || echo '$(srcdir)/'`kernel/TeAsciiFile.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeAsciiFile.Tpo $(DEPDIR)/libterralib_la-TeAsciiFile.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeAsciiFile.cpp' object='libterralib_la-TeAsciiFile.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeAsciiFile.lo `test -f 'kernel/TeAsciiFile.cpp' || echo '$(srcdir)/'`kernel/TeAsciiFile.cpp
+
+libterralib_la-TeBox.lo: kernel/TeBox.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeBox.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeBox.Tpo -c -o libterralib_la-TeBox.lo `test -f 'kernel/TeBox.cpp' || echo '$(srcdir)/'`kernel/TeBox.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeBox.Tpo $(DEPDIR)/libterralib_la-TeBox.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeBox.cpp' object='libterralib_la-TeBox.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeBox.lo `test -f 'kernel/TeBox.cpp' || echo '$(srcdir)/'`kernel/TeBox.cpp
+
+libterralib_la-TeBufferRegion.lo: kernel/TeBufferRegion.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeBufferRegion.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeBufferRegion.Tpo -c -o libterralib_la-TeBufferRegion.lo `test -f 'kernel/TeBufferRegion.cpp' || echo '$(srcdir)/'`kernel/TeBufferRegion.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeBufferRegion.Tpo $(DEPDIR)/libterralib_la-TeBufferRegion.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeBufferRegion.cpp' object='libterralib_la-TeBufferRegion.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeBufferRegion.lo `test -f 'kernel/TeBufferRegion.cpp' || echo '$(srcdir)/'`kernel/TeBufferRegion.cpp
+
+libterralib_la-TeCentroid.lo: kernel/TeCentroid.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeCentroid.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeCentroid.Tpo -c -o libterralib_la-TeCentroid.lo `test -f 'kernel/TeCentroid.cpp' || echo '$(srcdir)/'`kernel/TeCentroid.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeCentroid.Tpo $(DEPDIR)/libterralib_la-TeCentroid.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeCentroid.cpp' object='libterralib_la-TeCentroid.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeCentroid.lo `test -f 'kernel/TeCentroid.cpp' || echo '$(srcdir)/'`kernel/TeCentroid.cpp
+
+libterralib_la-TeDBConnection.lo: kernel/TeDBConnection.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDBConnection.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDBConnection.Tpo -c -o libterralib_la-TeDBConnection.lo `test -f 'kernel/TeDBConnection.cpp' || echo '$(srcdir)/'`kernel/TeDBConnection.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDBConnection.Tpo $(DEPDIR)/libterralib_la-TeDBConnection.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDBConnection.cpp' object='libterralib_la-TeDBConnection.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDBConnection.lo `test -f 'kernel/TeDBConnection.cpp' || echo '$(srcdir)/'`kernel/TeDBConnection.cpp
+
+libterralib_la-TeDBConnectionsPool.lo: kernel/TeDBConnectionsPool.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDBConnectionsPool.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDBConnectionsPool.Tpo -c -o libterralib_la-TeDBConnectionsPool.lo `test -f 'kernel/TeDBConnectionsPool.cpp' || echo '$(srcdir)/'`kernel/TeDBConnectionsPool.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDBConnectionsPool.Tpo $(DEPDIR)/libterralib_la-TeDBConnectionsPool.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDBConnectionsPool.cpp' object='libterralib_la-TeDBConnectionsPool.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDBConnectionsPool.lo `test -f 'kernel/TeDBConnectionsPool.cpp' || echo '$(srcdir)/'`kernel/TeDBConnectionsPool.cpp
+
+libterralib_la-TeDatabase.lo: kernel/TeDatabase.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDatabase.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDatabase.Tpo -c -o libterralib_la-TeDatabase.lo `test -f 'kernel/TeDatabase.cpp' || echo '$(srcdir)/'`kernel/TeDatabase.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDatabase.Tpo $(DEPDIR)/libterralib_la-TeDatabase.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDatabase.cpp' object='libterralib_la-TeDatabase.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDatabase.lo `test -f 'kernel/TeDatabase.cpp' || echo '$(srcdir)/'`kernel/TeDatabase.cpp
+
+libterralib_la-TeDatabaseFactoryParams.lo: kernel/TeDatabaseFactoryParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDatabaseFactoryParams.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDatabaseFactoryParams.Tpo -c -o libterralib_la-TeDatabaseFactoryParams.lo `test -f 'kernel/TeDatabaseFactoryParams.cpp' || echo '$(srcdir)/'`kernel/TeDatabaseFactoryParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDatabaseFactoryParams.Tpo $(DEPDIR)/libterralib_la-TeDatabaseFactoryParams.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDatabaseFactoryParams.cpp' object='libterralib_la-TeDatabaseFactoryParams.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDatabaseFactoryParams.lo `test -f 'kernel/TeDatabaseFactoryParams.cpp' || echo '$(srcdir)/'`kernel/TeDatabaseFactoryParams.cpp
+
+libterralib_la-TeDatum.lo: kernel/TeDatum.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDatum.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDatum.Tpo -c -o libterralib_la-TeDatum.lo `test -f 'kernel/TeDatum.cpp' || echo '$(srcdir)/'`kernel/TeDatum.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDatum.Tpo $(DEPDIR)/libterralib_la-TeDatum.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDatum.cpp' object='libterralib_la-TeDatum.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDatum.lo `test -f 'kernel/TeDatum.cpp' || echo '$(srcdir)/'`kernel/TeDatum.cpp
+
+libterralib_la-TeDecoderASCIIGrid.lo: kernel/TeDecoderASCIIGrid.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderASCIIGrid.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderASCIIGrid.Tpo -c -o libterralib_la-TeDecoderASCIIGrid.lo `test -f 'kernel/TeDecoderASCIIGrid.cpp' || echo '$(srcdir)/'`kernel/TeDecoderASCIIGrid.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderASCIIGrid.Tpo $(DEPDIR)/libterralib_la-TeDecoderASCIIGrid.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderASCIIGrid.cpp' object='libterralib_la-TeDecoderASCIIGrid.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderASCIIGrid.lo `test -f 'kernel/TeDecoderASCIIGrid.cpp' || echo '$(srcdir)/'`kernel/TeDecoderASCIIGrid.cpp
+
+libterralib_la-TeDecoderDatabase.lo: kernel/TeDecoderDatabase.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderDatabase.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderDatabase.Tpo -c -o libterralib_la-TeDecoderDatabase.lo `test -f 'kernel/TeDecoderDatabase.cpp' || echo '$(srcdir)/'`kernel/TeDecoderDatabase.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderDatabase.Tpo $(DEPDIR)/libterralib_la-TeDecoderDatabase.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderDatabase.cpp' object='libterralib_la-TeDecoderDatabase.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderDatabase.lo `test -f 'kernel/TeDecoderDatabase.cpp' || echo '$(srcdir)/'`kernel/TeDecoderDatabase.cpp
+
+libterralib_la-TeDecoderFile.lo: kernel/TeDecoderFile.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderFile.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderFile.Tpo -c -o libterralib_la-TeDecoderFile.lo `test -f 'kernel/TeDecoderFile.cpp' || echo '$(srcdir)/'`kernel/TeDecoderFile.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderFile.Tpo $(DEPDIR)/libterralib_la-TeDecoderFile.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderFile.cpp' object='libterralib_la-TeDecoderFile.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderFile.lo `test -f 'kernel/TeDecoderFile.cpp' || echo '$(srcdir)/'`kernel/TeDecoderFile.cpp
+
+libterralib_la-TeDecoderMemory.lo: kernel/TeDecoderMemory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderMemory.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderMemory.Tpo -c -o libterralib_la-TeDecoderMemory.lo `test -f 'kernel/TeDecoderMemory.cpp' || echo '$(srcdir)/'`kernel/TeDecoderMemory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderMemory.Tpo $(DEPDIR)/libterralib_la-TeDecoderMemory.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderMemory.cpp' object='libterralib_la-TeDecoderMemory.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderMemory.lo `test -f 'kernel/TeDecoderMemory.cpp' || echo '$(srcdir)/'`kernel/TeDecoderMemory.cpp
+
+libterralib_la-TeDecoderMemoryMap.lo: kernel/TeDecoderMemoryMap.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderMemoryMap.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderMemoryMap.Tpo -c -o libterralib_la-TeDecoderMemoryMap.lo `test -f 'kernel/TeDecoderMemoryMap.cpp' || echo '$(srcdir)/'`kernel/TeDecoderMemoryMap.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderMemoryMap.Tpo $(DEPDIR)/libterralib_la-TeDecoderMemoryMap.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderMemoryMap.cpp' object='libterralib_la-TeDecoderMemoryMap.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderMemoryMap.lo `test -f 'kernel/TeDecoderMemoryMap.cpp' || echo '$(srcdir)/'`kernel/TeDecoderMemoryMap.cpp
+
+libterralib_la-TeDecoderSPR.lo: kernel/TeDecoderSPR.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderSPR.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderSPR.Tpo -c -o libterralib_la-TeDecoderSPR.lo `test -f 'kernel/TeDecoderSPR.cpp' || echo '$(srcdir)/'`kernel/TeDecoderSPR.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderSPR.Tpo $(DEPDIR)/libterralib_la-TeDecoderSPR.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderSPR.cpp' object='libterralib_la-TeDecoderSPR.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderSPR.lo `test -f 'kernel/TeDecoderSPR.cpp' || echo '$(srcdir)/'`kernel/TeDecoderSPR.cpp
+
+libterralib_la-TeDecoderSmartMem.lo: kernel/TeDecoderSmartMem.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderSmartMem.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderSmartMem.Tpo -c -o libterralib_la-TeDecoderSmartMem.lo `test -f 'kernel/TeDecoderSmartMem.cpp' || echo '$(srcdir)/'`kernel/TeDecoderSmartMem.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderSmartMem.Tpo $(DEPDIR)/libterralib_la-TeDecoderSmartMem.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderSmartMem.cpp' object='libterralib_la-TeDecoderSmartMem.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderSmartMem.lo `test -f 'kernel/TeDecoderSmartMem.cpp' || echo '$(srcdir)/'`kernel/TeDecoderSmartMem.cpp
+
+libterralib_la-TeDecoderVirtualMemory.lo: kernel/TeDecoderVirtualMemory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeDecoderVirtualMemory.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeDecoderVirtualMemory.Tpo -c -o libterralib_la-TeDecoderVirtualMemory.lo `test -f 'kernel/TeDecoderVirtualMemory.cpp' || echo '$(srcdir)/'`kernel/TeDecoderVirtualMemory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeDecoderVirtualMemory.Tpo $(DEPDIR)/libterralib_la-TeDecoderVirtualMemory.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeDecoderVirtualMemory.cpp' object='libterralib_la-TeDecoderVirtualMemory.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeDecoderVirtualMemory.lo `test -f 'kernel/TeDecoderVirtualMemory.cpp' || echo '$(srcdir)/'`kernel/TeDecoderVirtualMemory.cpp
+
+libterralib_la-TeErrorLog.lo: kernel/TeErrorLog.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeErrorLog.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeErrorLog.Tpo -c -o libterralib_la-TeErrorLog.lo `test -f 'kernel/TeErrorLog.cpp' || echo '$(srcdir)/'`kernel/TeErrorLog.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeErrorLog.Tpo $(DEPDIR)/libterralib_la-TeErrorLog.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeErrorLog.cpp' object='libterralib_la-TeErrorLog.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeErrorLog.lo `test -f 'kernel/TeErrorLog.cpp' || echo '$(srcdir)/'`kernel/TeErrorLog.cpp
+
+libterralib_la-TeErrorMessage.lo: kernel/TeErrorMessage.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeErrorMessage.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeErrorMessage.Tpo -c -o libterralib_la-TeErrorMessage.lo `test -f 'kernel/TeErrorMessage.cpp' || echo '$(srcdir)/'`kernel/TeErrorMessage.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeErrorMessage.Tpo $(DEPDIR)/libterralib_la-TeErrorMessage.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeErrorMessage.cpp' object='libterralib_la-TeErrorMessage.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeErrorMessage.lo `test -f 'kernel/TeErrorMessage.cpp' || echo '$(srcdir)/'`kernel/TeErrorMessage.cpp
+
+libterralib_la-TeException.lo: kernel/TeException.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeException.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeException.Tpo -c -o libterralib_la-TeException.lo `test -f 'kernel/TeException.cpp' || echo '$(srcdir)/'`kernel/TeException.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeException.Tpo $(DEPDIR)/libterralib_la-TeException.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeException.cpp' object='libterralib_la-TeException.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeException.lo `test -f 'kernel/TeException.cpp' || echo '$(srcdir)/'`kernel/TeException.cpp
+
+libterralib_la-TeExternalTheme.lo: kernel/TeExternalTheme.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeExternalTheme.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeExternalTheme.Tpo -c -o libterralib_la-TeExternalTheme.lo `test -f 'kernel/TeExternalTheme.cpp' || echo '$(srcdir)/'`kernel/TeExternalTheme.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeExternalTheme.Tpo $(DEPDIR)/libterralib_la-TeExternalTheme.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeExternalTheme.cpp' object='libterralib_la-TeExternalTheme.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeExternalTheme.lo `test -f 'kernel/TeExternalTheme.cpp' || echo '$(srcdir)/'`kernel/TeExternalTheme.cpp
+
+libterralib_la-TeFragmentation.lo: kernel/TeFragmentation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeFragmentation.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeFragmentation.Tpo -c -o libterralib_la-TeFragmentation.lo `test -f 'kernel/TeFragmentation.cpp' || echo '$(srcdir)/'`kernel/TeFragmentation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeFragmentation.Tpo $(DEPDIR)/libterralib_la-TeFragmentation.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeFragmentation.cpp' object='libterralib_la-TeFragmentation.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeFragmentation.lo `test -f 'kernel/TeFragmentation.cpp' || echo '$(srcdir)/'`kernel/TeFragmentation.cpp
+
+libterralib_la-TeGTFactory.lo: kernel/TeGTFactory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeGTFactory.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeGTFactory.Tpo -c -o libterralib_la-TeGTFactory.lo `test -f 'kernel/TeGTFactory.cpp' || echo '$(srcdir)/'`kernel/TeGTFactory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeGTFactory.Tpo $(DEPDIR)/libterralib_la-TeGTFactory.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeGTFactory.cpp' object='libterralib_la-TeGTFactory.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeGTFactory.lo `test -f 'kernel/TeGTFactory.cpp' || echo '$(srcdir)/'`kernel/TeGTFactory.cpp
+
+libterralib_la-TeGTParams.lo: kernel/TeGTParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeGTParams.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeGTParams.Tpo -c -o libterralib_la-TeGTParams.lo `test -f 'kernel/TeGTParams.cpp' || echo '$(srcdir)/'`kernel/TeGTParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeGTParams.Tpo $(DEPDIR)/libterralib_la-TeGTParams.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeGTParams.cpp' object='libterralib_la-TeGTParams.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeGTParams.lo `test -f 'kernel/TeGTParams.cpp' || echo '$(srcdir)/'`kernel/TeGTParams.cpp
+
+libterralib_la-TeGeometricTransformation.lo: kernel/TeGeometricTransformation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeGeometricTransformation.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeGeometricTransformation.Tpo -c -o libterralib_la-TeGeometricTransformation.lo `test -f 'kernel/TeGeometricTransformation.cpp' || echo '$(srcdir)/'`kernel/TeGeometricTransformation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeGeometricTransformation.Tpo $(DEPDIR)/libterralib_la-TeGeometricTransformation.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeGeometricTransformation.cpp' object='libterralib_la-TeGeometricTransformation.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeGeometricTransformation.lo `test -f 'kernel/TeGeometricTransformation.cpp' || echo '$(srcdir)/'`kernel/TeGeometricTransformation.cpp
+
+libterralib_la-TeGeometry.lo: kernel/TeGeometry.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeGeometry.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeGeometry.Tpo -c -o libterralib_la-TeGeometry.lo `test -f 'kernel/TeGeometry.cpp' || echo '$(srcdir)/'`kernel/TeGeometry.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeGeometry.Tpo $(DEPDIR)/libterralib_la-TeGeometry.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeGeometry.cpp' object='libterralib_la-TeGeometry.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeGeometry.lo `test -f 'kernel/TeGeometry.cpp' || echo '$(srcdir)/'`kernel/TeGeometry.cpp
+
+libterralib_la-TeGeometryAlgorithms.lo: kernel/TeGeometryAlgorithms.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeGeometryAlgorithms.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeGeometryAlgorithms.Tpo -c -o libterralib_la-TeGeometryAlgorithms.lo `test -f 'kernel/TeGeometryAlgorithms.cpp' || echo '$(srcdir)/'`kernel/TeGeometryAlgorithms.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeGeometryAlgorithms.Tpo $(DEPDIR)/libterralib_la-TeGeometryAlgorithms.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeGeometryAlgorithms.cpp' object='libterralib_la-TeGeometryAlgorithms.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeGeometryAlgorithms.lo `test -f 'kernel/TeGeometryAlgorithms.cpp' || echo '$(srcdir)/'`kernel/TeGeometryAlgorithms.cpp
+
+libterralib_la-TeGroupingAlgorithms.lo: kernel/TeGroupingAlgorithms.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeGroupingAlgorithms.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeGroupingAlgorithms.Tpo -c -o libterralib_la-TeGroupingAlgorithms.lo `test -f 'kernel/TeGroupingAlgorithms.cpp' || echo '$(srcdir)/'`kernel/TeGroupingAlgorithms.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeGroupingAlgorithms.Tpo $(DEPDIR)/libterralib_la-TeGroupingAlgorithms.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeGroupingAlgorithms.cpp' object='libterralib_la-TeGroupingAlgorithms.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeGroupingAlgorithms.lo `test -f 'kernel/TeGroupingAlgorithms.cpp' || echo '$(srcdir)/'`kernel/TeGroupingAlgorithms.cpp
+
+libterralib_la-TeImportRaster.lo: kernel/TeImportRaster.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeImportRaster.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeImportRaster.Tpo -c -o libterralib_la-TeImportRaster.lo `test -f 'kernel/TeImportRaster.cpp' || echo '$(srcdir)/'`kernel/TeImportRaster.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeImportRaster.Tpo $(DEPDIR)/libterralib_la-TeImportRaster.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeImportRaster.cpp' object='libterralib_la-TeImportRaster.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeImportRaster.lo `test -f 'kernel/TeImportRaster.cpp' || echo '$(srcdir)/'`kernel/TeImportRaster.cpp
+
+libterralib_la-TeInitRasterDecoders.lo: kernel/TeInitRasterDecoders.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeInitRasterDecoders.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeInitRasterDecoders.Tpo -c -o libterralib_la-TeInitRasterDecoders.lo `test -f 'kernel/TeInitRasterDecoders.cpp' || echo '$(srcdir)/'`kernel/TeInitRasterDecoders.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeInitRasterDecoders.Tpo $(DEPDIR)/libterralib_la-TeInitRasterDecoders.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeInitRasterDecoders.cpp' object='libterralib_la-TeInitRasterDecoders.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeInitRasterDecoders.lo `test -f 'kernel/TeInitRasterDecoders.cpp' || echo '$(srcdir)/'`kernel/TeInitRasterDecoders.cpp
+
+libterralib_la-TeIntersector.lo: kernel/TeIntersector.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeIntersector.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeIntersector.Tpo -c -o libterralib_la-TeIntersector.lo `test -f 'kernel/TeIntersector.cpp' || echo '$(srcdir)/'`kernel/TeIntersector.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeIntersector.Tpo $(DEPDIR)/libterralib_la-TeIntersector.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeIntersector.cpp' object='libterralib_la-TeIntersector.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeIntersector.lo `test -f 'kernel/TeIntersector.cpp' || echo '$(srcdir)/'`kernel/TeIntersector.cpp
+
+libterralib_la-TeLayer.lo: kernel/TeLayer.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeLayer.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeLayer.Tpo -c -o libterralib_la-TeLayer.lo `test -f 'kernel/TeLayer.cpp' || echo '$(srcdir)/'`kernel/TeLayer.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeLayer.Tpo $(DEPDIR)/libterralib_la-TeLayer.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeLayer.cpp' object='libterralib_la-TeLayer.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeLayer.lo `test -f 'kernel/TeLayer.cpp' || echo '$(srcdir)/'`kernel/TeLayer.cpp
+
+libterralib_la-TeLegendEntry.lo: kernel/TeLegendEntry.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeLegendEntry.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeLegendEntry.Tpo -c -o libterralib_la-TeLegendEntry.lo `test -f 'kernel/TeLegendEntry.cpp' || echo '$(srcdir)/'`kernel/TeLegendEntry.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeLegendEntry.Tpo $(DEPDIR)/libterralib_la-TeLegendEntry.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeLegendEntry.cpp' object='libterralib_la-TeLegendEntry.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeLegendEntry.lo `test -f 'kernel/TeLegendEntry.cpp' || echo '$(srcdir)/'`kernel/TeLegendEntry.cpp
+
+libterralib_la-TeMappedMemory.lo: kernel/TeMappedMemory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeMappedMemory.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeMappedMemory.Tpo -c -o libterralib_la-TeMappedMemory.lo `test -f 'kernel/TeMappedMemory.cpp' || echo '$(srcdir)/'`kernel/TeMappedMemory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeMappedMemory.Tpo $(DEPDIR)/libterralib_la-TeMappedMemory.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeMappedMemory.cpp' object='libterralib_la-TeMappedMemory.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeMappedMemory.lo `test -f 'kernel/TeMappedMemory.cpp' || echo '$(srcdir)/'`kernel/TeMappedMemory.cpp
+
+libterralib_la-TeMatrix.lo: kernel/TeMatrix.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeMatrix.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeMatrix.Tpo -c -o libterralib_la-TeMatrix.lo `test -f 'kernel/TeMatrix.cpp' || echo '$(srcdir)/'`kernel/TeMatrix.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeMatrix.Tpo $(DEPDIR)/libterralib_la-TeMatrix.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeMatrix.cpp' object='libterralib_la-TeMatrix.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeMatrix.lo `test -f 'kernel/TeMatrix.cpp' || echo '$(srcdir)/'`kernel/TeMatrix.cpp
+
+libterralib_la-TeMetaModelCache.lo: kernel/TeMetaModelCache.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeMetaModelCache.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeMetaModelCache.Tpo -c -o libterralib_la-TeMetaModelCache.lo `test -f 'kernel/TeMetaModelCache.cpp' || echo '$(srcdir)/'`kernel/TeMetaModelCache.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeMetaModelCache.Tpo $(DEPDIR)/libterralib_la-TeMetaModelCache.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeMetaModelCache.cpp' object='libterralib_la-TeMetaModelCache.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeMetaModelCache.lo `test -f 'kernel/TeMetaModelCache.cpp' || echo '$(srcdir)/'`kernel/TeMetaModelCache.cpp
+
+libterralib_la-TeMultiGeometry.lo: kernel/TeMultiGeometry.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeMultiGeometry.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeMultiGeometry.Tpo -c -o libterralib_la-TeMultiGeometry.lo `test -f 'kernel/TeMultiGeometry.cpp' || echo '$(srcdir)/'`kernel/TeMultiGeometry.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeMultiGeometry.Tpo $(DEPDIR)/libterralib_la-TeMultiGeometry.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeMultiGeometry.cpp' object='libterralib_la-TeMultiGeometry.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeMultiGeometry.lo `test -f 'kernel/TeMultiGeometry.cpp' || echo '$(srcdir)/'`kernel/TeMultiGeometry.cpp
+
+libterralib_la-TeMutex.lo: kernel/TeMutex.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeMutex.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeMutex.Tpo -c -o libterralib_la-TeMutex.lo `test -f 'kernel/TeMutex.cpp' || echo '$(srcdir)/'`kernel/TeMutex.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeMutex.Tpo $(DEPDIR)/libterralib_la-TeMutex.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeMutex.cpp' object='libterralib_la-TeMutex.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeMutex.lo `test -f 'kernel/TeMutex.cpp' || echo '$(srcdir)/'`kernel/TeMutex.cpp
+
+libterralib_la-TeNeighbours.lo: kernel/TeNeighbours.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeNeighbours.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeNeighbours.Tpo -c -o libterralib_la-TeNeighbours.lo `test -f 'kernel/TeNeighbours.cpp' || echo '$(srcdir)/'`kernel/TeNeighbours.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeNeighbours.Tpo $(DEPDIR)/libterralib_la-TeNeighbours.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeNeighbours.cpp' object='libterralib_la-TeNeighbours.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeNeighbours.lo `test -f 'kernel/TeNeighbours.cpp' || echo '$(srcdir)/'`kernel/TeNeighbours.cpp
+
+libterralib_la-TeNetwork.lo: kernel/TeNetwork.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeNetwork.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeNetwork.Tpo -c -o libterralib_la-TeNetwork.lo `test -f 'kernel/TeNetwork.cpp' || echo '$(srcdir)/'`kernel/TeNetwork.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeNetwork.Tpo $(DEPDIR)/libterralib_la-TeNetwork.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeNetwork.cpp' object='libterralib_la-TeNetwork.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeNetwork.lo `test -f 'kernel/TeNetwork.cpp' || echo '$(srcdir)/'`kernel/TeNetwork.cpp
+
+libterralib_la-TeOverlay.lo: kernel/TeOverlay.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeOverlay.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeOverlay.Tpo -c -o libterralib_la-TeOverlay.lo `test -f 'kernel/TeOverlay.cpp' || echo '$(srcdir)/'`kernel/TeOverlay.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeOverlay.Tpo $(DEPDIR)/libterralib_la-TeOverlay.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeOverlay.cpp' object='libterralib_la-TeOverlay.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeOverlay.lo `test -f 'kernel/TeOverlay.cpp' || echo '$(srcdir)/'`kernel/TeOverlay.cpp
+
+libterralib_la-TeOverlayUtils.lo: kernel/TeOverlayUtils.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeOverlayUtils.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeOverlayUtils.Tpo -c -o libterralib_la-TeOverlayUtils.lo `test -f 'kernel/TeOverlayUtils.cpp' || echo '$(srcdir)/'`kernel/TeOverlayUtils.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeOverlayUtils.Tpo $(DEPDIR)/libterralib_la-TeOverlayUtils.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeOverlayUtils.cpp' object='libterralib_la-TeOverlayUtils.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeOverlayUtils.lo `test -f 'kernel/TeOverlayUtils.cpp' || echo '$(srcdir)/'`kernel/TeOverlayUtils.cpp
+
+libterralib_la-TeProgress.lo: kernel/TeProgress.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProgress.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProgress.Tpo -c -o libterralib_la-TeProgress.lo `test -f 'kernel/TeProgress.cpp' || echo '$(srcdir)/'`kernel/TeProgress.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProgress.Tpo $(DEPDIR)/libterralib_la-TeProgress.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProgress.cpp' object='libterralib_la-TeProgress.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProgress.lo `test -f 'kernel/TeProgress.cpp' || echo '$(srcdir)/'`kernel/TeProgress.cpp
+
+libterralib_la-TeProject.lo: kernel/TeProject.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProject.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProject.Tpo -c -o libterralib_la-TeProject.lo `test -f 'kernel/TeProject.cpp' || echo '$(srcdir)/'`kernel/TeProject.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProject.Tpo $(DEPDIR)/libterralib_la-TeProject.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProject.cpp' object='libterralib_la-TeProject.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProject.lo `test -f 'kernel/TeProject.cpp' || echo '$(srcdir)/'`kernel/TeProject.cpp
+
+libterralib_la-TeProjection.lo: kernel/TeProjection.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProjection.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProjection.Tpo -c -o libterralib_la-TeProjection.lo `test -f 'kernel/TeProjection.cpp' || echo '$(srcdir)/'`kernel/TeProjection.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProjection.Tpo $(DEPDIR)/libterralib_la-TeProjection.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProjection.cpp' object='libterralib_la-TeProjection.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProjection.lo `test -f 'kernel/TeProjection.cpp' || echo '$(srcdir)/'`kernel/TeProjection.cpp
+
+libterralib_la-TeProjectiveGT.lo: kernel/TeProjectiveGT.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProjectiveGT.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProjectiveGT.Tpo -c -o libterralib_la-TeProjectiveGT.lo `test -f 'kernel/TeProjectiveGT.cpp' || echo '$(srcdir)/'`kernel/TeProjectiveGT.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProjectiveGT.Tpo $(DEPDIR)/libterralib_la-TeProjectiveGT.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProjectiveGT.cpp' object='libterralib_la-TeProjectiveGT.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProjectiveGT.lo `test -f 'kernel/TeProjectiveGT.cpp' || echo '$(srcdir)/'`kernel/TeProjectiveGT.cpp
+
+libterralib_la-TeProjectiveGTFactory.lo: kernel/TeProjectiveGTFactory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProjectiveGTFactory.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProjectiveGTFactory.Tpo -c -o libterralib_la-TeProjectiveGTFactory.lo `test -f 'kernel/TeProjectiveGTFactory.cpp' || echo '$(srcdir)/'`kernel/TeProjectiveGTFactory.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProjectiveGTFactory.Tpo $(DEPDIR)/libterralib_la-TeProjectiveGTFactory.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProjectiveGTFactory.cpp' object='libterralib_la-TeProjectiveGTFactory.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProjectiveGTFactory.lo `test -f 'kernel/TeProjectiveGTFactory.cpp' || echo '$(srcdir)/'`kernel/TeProjectiveGTFactory.cpp
+
+libterralib_la-TeProxMatrixConstructionStrategy.lo: kernel/TeProxMatrixConstructionStrategy.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProxMatrixConstructionStrategy.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProxMatrixConstructionStrategy.Tpo -c -o libterralib_la-TeProxMatrixConstructionStrategy.lo `test -f 'kernel/TeProxMatrixConstructionStrategy.cpp' || echo '$(srcdir)/'`ke [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProxMatrixConstructionStrategy.Tpo $(DEPDIR)/libterralib_la-TeProxMatrixConstructionStrategy.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProxMatrixConstructionStrategy.cpp' object='libterralib_la-TeProxMatrixConstructionStrategy.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProxMatrixConstructionStrategy.lo `test -f 'kernel/TeProxMatrixConstructionStrategy.cpp' || echo '$(srcdir)/'`kernel/TeProxMatrixConstructionStrategy.cpp
+
+libterralib_la-TeProxMatrixImplementation.lo: kernel/TeProxMatrixImplementation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProxMatrixImplementation.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProxMatrixImplementation.Tpo -c -o libterralib_la-TeProxMatrixImplementation.lo `test -f 'kernel/TeProxMatrixImplementation.cpp' || echo '$(srcdir)/'`kernel/TeProxMatrixImpleme [...]
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProxMatrixImplementation.Tpo $(DEPDIR)/libterralib_la-TeProxMatrixImplementation.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProxMatrixImplementation.cpp' object='libterralib_la-TeProxMatrixImplementation.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProxMatrixImplementation.lo `test -f 'kernel/TeProxMatrixImplementation.cpp' || echo '$(srcdir)/'`kernel/TeProxMatrixImplementation.cpp
+
+libterralib_la-TeProxMatrixStrategies.lo: kernel/TeProxMatrixStrategies.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeProxMatrixStrategies.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeProxMatrixStrategies.Tpo -c -o libterralib_la-TeProxMatrixStrategies.lo `test -f 'kernel/TeProxMatrixStrategies.cpp' || echo '$(srcdir)/'`kernel/TeProxMatrixStrategies.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeProxMatrixStrategies.Tpo $(DEPDIR)/libterralib_la-TeProxMatrixStrategies.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeProxMatrixStrategies.cpp' object='libterralib_la-TeProxMatrixStrategies.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeProxMatrixStrategies.lo `test -f 'kernel/TeProxMatrixStrategies.cpp' || echo '$(srcdir)/'`kernel/TeProxMatrixStrategies.cpp
+
+libterralib_la-TeQuerier.lo: kernel/TeQuerier.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerier.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerier.Tpo -c -o libterralib_la-TeQuerier.lo `test -f 'kernel/TeQuerier.cpp' || echo '$(srcdir)/'`kernel/TeQuerier.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerier.Tpo $(DEPDIR)/libterralib_la-TeQuerier.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerier.cpp' object='libterralib_la-TeQuerier.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerier.lo `test -f 'kernel/TeQuerier.cpp' || echo '$(srcdir)/'`kernel/TeQuerier.cpp
+
+libterralib_la-TeQuerierDB.lo: kernel/TeQuerierDB.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerierDB.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerierDB.Tpo -c -o libterralib_la-TeQuerierDB.lo `test -f 'kernel/TeQuerierDB.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDB.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerierDB.Tpo $(DEPDIR)/libterralib_la-TeQuerierDB.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerierDB.cpp' object='libterralib_la-TeQuerierDB.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerierDB.lo `test -f 'kernel/TeQuerierDB.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDB.cpp
+
+libterralib_la-TeQuerierDBStr1.lo: kernel/TeQuerierDBStr1.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerierDBStr1.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerierDBStr1.Tpo -c -o libterralib_la-TeQuerierDBStr1.lo `test -f 'kernel/TeQuerierDBStr1.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDBStr1.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerierDBStr1.Tpo $(DEPDIR)/libterralib_la-TeQuerierDBStr1.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerierDBStr1.cpp' object='libterralib_la-TeQuerierDBStr1.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerierDBStr1.lo `test -f 'kernel/TeQuerierDBStr1.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDBStr1.cpp
+
+libterralib_la-TeQuerierDBStr2.lo: kernel/TeQuerierDBStr2.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerierDBStr2.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerierDBStr2.Tpo -c -o libterralib_la-TeQuerierDBStr2.lo `test -f 'kernel/TeQuerierDBStr2.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDBStr2.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerierDBStr2.Tpo $(DEPDIR)/libterralib_la-TeQuerierDBStr2.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerierDBStr2.cpp' object='libterralib_la-TeQuerierDBStr2.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerierDBStr2.lo `test -f 'kernel/TeQuerierDBStr2.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDBStr2.cpp
+
+libterralib_la-TeQuerierDBStr3.lo: kernel/TeQuerierDBStr3.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerierDBStr3.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerierDBStr3.Tpo -c -o libterralib_la-TeQuerierDBStr3.lo `test -f 'kernel/TeQuerierDBStr3.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDBStr3.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerierDBStr3.Tpo $(DEPDIR)/libterralib_la-TeQuerierDBStr3.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerierDBStr3.cpp' object='libterralib_la-TeQuerierDBStr3.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerierDBStr3.lo `test -f 'kernel/TeQuerierDBStr3.cpp' || echo '$(srcdir)/'`kernel/TeQuerierDBStr3.cpp
+
+libterralib_la-TeQuerierImpl.lo: kernel/TeQuerierImpl.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerierImpl.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerierImpl.Tpo -c -o libterralib_la-TeQuerierImpl.lo `test -f 'kernel/TeQuerierImpl.cpp' || echo '$(srcdir)/'`kernel/TeQuerierImpl.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerierImpl.Tpo $(DEPDIR)/libterralib_la-TeQuerierImpl.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerierImpl.cpp' object='libterralib_la-TeQuerierImpl.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerierImpl.lo `test -f 'kernel/TeQuerierImpl.cpp' || echo '$(srcdir)/'`kernel/TeQuerierImpl.cpp
+
+libterralib_la-TeQuerierParams.lo: kernel/TeQuerierParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeQuerierParams.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeQuerierParams.Tpo -c -o libterralib_la-TeQuerierParams.lo `test -f 'kernel/TeQuerierParams.cpp' || echo '$(srcdir)/'`kernel/TeQuerierParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeQuerierParams.Tpo $(DEPDIR)/libterralib_la-TeQuerierParams.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeQuerierParams.cpp' object='libterralib_la-TeQuerierParams.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeQuerierParams.lo `test -f 'kernel/TeQuerierParams.cpp' || echo '$(srcdir)/'`kernel/TeQuerierParams.cpp
+
+libterralib_la-TeRaster.lo: kernel/TeRaster.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeRaster.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeRaster.Tpo -c -o libterralib_la-TeRaster.lo `test -f 'kernel/TeRaster.cpp' || echo '$(srcdir)/'`kernel/TeRaster.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeRaster.Tpo $(DEPDIR)/libterralib_la-TeRaster.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeRaster.cpp' object='libterralib_la-TeRaster.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeRaster.lo `test -f 'kernel/TeRaster.cpp' || echo '$(srcdir)/'`kernel/TeRaster.cpp
+
+libterralib_la-TeRasterMemManager.lo: kernel/TeRasterMemManager.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeRasterMemManager.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeRasterMemManager.Tpo -c -o libterralib_la-TeRasterMemManager.lo `test -f 'kernel/TeRasterMemManager.cpp' || echo '$(srcdir)/'`kernel/TeRasterMemManager.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeRasterMemManager.Tpo $(DEPDIR)/libterralib_la-TeRasterMemManager.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeRasterMemManager.cpp' object='libterralib_la-TeRasterMemManager.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeRasterMemManager.lo `test -f 'kernel/TeRasterMemManager.cpp' || echo '$(srcdir)/'`kernel/TeRasterMemManager.cpp
+
+libterralib_la-TeRasterParams.lo: kernel/TeRasterParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeRasterParams.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeRasterParams.Tpo -c -o libterralib_la-TeRasterParams.lo `test -f 'kernel/TeRasterParams.cpp' || echo '$(srcdir)/'`kernel/TeRasterParams.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeRasterParams.Tpo $(DEPDIR)/libterralib_la-TeRasterParams.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeRasterParams.cpp' object='libterralib_la-TeRasterParams.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeRasterParams.lo `test -f 'kernel/TeRasterParams.cpp' || echo '$(srcdir)/'`kernel/TeRasterParams.cpp
+
+libterralib_la-TeRasterRemap.lo: kernel/TeRasterRemap.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeRasterRemap.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeRasterRemap.Tpo -c -o libterralib_la-TeRasterRemap.lo `test -f 'kernel/TeRasterRemap.cpp' || echo '$(srcdir)/'`kernel/TeRasterRemap.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeRasterRemap.Tpo $(DEPDIR)/libterralib_la-TeRasterRemap.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeRasterRemap.cpp' object='libterralib_la-TeRasterRemap.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeRasterRemap.lo `test -f 'kernel/TeRasterRemap.cpp' || echo '$(srcdir)/'`kernel/TeRasterRemap.cpp
+
+libterralib_la-TeRasterTransform.lo: kernel/TeRasterTransform.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeRasterTransform.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeRasterTransform.Tpo -c -o libterralib_la-TeRasterTransform.lo `test -f 'kernel/TeRasterTransform.cpp' || echo '$(srcdir)/'`kernel/TeRasterTransform.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeRasterTransform.Tpo $(DEPDIR)/libterralib_la-TeRasterTransform.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeRasterTransform.cpp' object='libterralib_la-TeRasterTransform.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeRasterTransform.lo `test -f 'kernel/TeRasterTransform.cpp' || echo '$(srcdir)/'`kernel/TeRasterTransform.cpp
+
+libterralib_la-TeRepresentation.lo: kernel/TeRepresentation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeRepresentation.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeRepresentation.Tpo -c -o libterralib_la-TeRepresentation.lo `test -f 'kernel/TeRepresentation.cpp' || echo '$(srcdir)/'`kernel/TeRepresentation.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeRepresentation.Tpo $(DEPDIR)/libterralib_la-TeRepresentation.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeRepresentation.cpp' object='libterralib_la-TeRepresentation.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeRepresentation.lo `test -f 'kernel/TeRepresentation.cpp' || echo '$(srcdir)/'`kernel/TeRepresentation.cpp
+
+libterralib_la-TeSTElementSet.lo: kernel/TeSTElementSet.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeSTElementSet.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeSTElementSet.Tpo -c -o libterralib_la-TeSTElementSet.lo `test -f 'kernel/TeSTElementSet.cpp' || echo '$(srcdir)/'`kernel/TeSTElementSet.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeSTElementSet.Tpo $(DEPDIR)/libterralib_la-TeSTElementSet.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeSTElementSet.cpp' object='libterralib_la-TeSTElementSet.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeSTElementSet.lo `test -f 'kernel/TeSTElementSet.cpp' || echo '$(srcdir)/'`kernel/TeSTElementSet.cpp
+
+libterralib_la-TeSTEvent.lo: kernel/TeSTEvent.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeSTEvent.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeSTEvent.Tpo -c -o libterralib_la-TeSTEvent.lo `test -f 'kernel/TeSTEvent.cpp' || echo '$(srcdir)/'`kernel/TeSTEvent.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeSTEvent.Tpo $(DEPDIR)/libterralib_la-TeSTEvent.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeSTEvent.cpp' object='libterralib_la-TeSTEvent.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeSTEvent.lo `test -f 'kernel/TeSTEvent.cpp' || echo '$(srcdir)/'`kernel/TeSTEvent.cpp
+
+libterralib_la-TeSTInstance.lo: kernel/TeSTInstance.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeSTInstance.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeSTInstance.Tpo -c -o libterralib_la-TeSTInstance.lo `test -f 'kernel/TeSTInstance.cpp' || echo '$(srcdir)/'`kernel/TeSTInstance.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeSTInstance.Tpo $(DEPDIR)/libterralib_la-TeSTInstance.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeSTInstance.cpp' object='libterralib_la-TeSTInstance.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeSTInstance.lo `test -f 'kernel/TeSTInstance.cpp' || echo '$(srcdir)/'`kernel/TeSTInstance.cpp
+
+libterralib_la-TeSpatialOperations.lo: kernel/TeSpatialOperations.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeSpatialOperations.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeSpatialOperations.Tpo -c -o libterralib_la-TeSpatialOperations.lo `test -f 'kernel/TeSpatialOperations.cpp' || echo '$(srcdir)/'`kernel/TeSpatialOperations.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeSpatialOperations.Tpo $(DEPDIR)/libterralib_la-TeSpatialOperations.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeSpatialOperations.cpp' object='libterralib_la-TeSpatialOperations.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeSpatialOperations.lo `test -f 'kernel/TeSpatialOperations.cpp' || echo '$(srcdir)/'`kernel/TeSpatialOperations.cpp
+
+libterralib_la-TeStdFile.lo: kernel/TeStdFile.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeStdFile.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeStdFile.Tpo -c -o libterralib_la-TeStdFile.lo `test -f 'kernel/TeStdFile.cpp' || echo '$(srcdir)/'`kernel/TeStdFile.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeStdFile.Tpo $(DEPDIR)/libterralib_la-TeStdFile.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeStdFile.cpp' object='libterralib_la-TeStdFile.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeStdFile.lo `test -f 'kernel/TeStdFile.cpp' || echo '$(srcdir)/'`kernel/TeStdFile.cpp
+
+libterralib_la-TeTable.lo: kernel/TeTable.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeTable.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeTable.Tpo -c -o libterralib_la-TeTable.lo `test -f 'kernel/TeTable.cpp' || echo '$(srcdir)/'`kernel/TeTable.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeTable.Tpo $(DEPDIR)/libterralib_la-TeTable.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeTable.cpp' object='libterralib_la-TeTable.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeTable.lo `test -f 'kernel/TeTable.cpp' || echo '$(srcdir)/'`kernel/TeTable.cpp
+
+libterralib_la-TeTemporalSeries.lo: kernel/TeTemporalSeries.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeTemporalSeries.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeTemporalSeries.Tpo -c -o libterralib_la-TeTemporalSeries.lo `test -f 'kernel/TeTemporalSeries.cpp' || echo '$(srcdir)/'`kernel/TeTemporalSeries.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeTemporalSeries.Tpo $(DEPDIR)/libterralib_la-TeTemporalSeries.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeTemporalSeries.cpp' object='libterralib_la-TeTemporalSeries.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeTemporalSeries.lo `test -f 'kernel/TeTemporalSeries.cpp' || echo '$(srcdir)/'`kernel/TeTemporalSeries.cpp
+
+libterralib_la-TeTheme.lo: kernel/TeTheme.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeTheme.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeTheme.Tpo -c -o libterralib_la-TeTheme.lo `test -f 'kernel/TeTheme.cpp' || echo '$(srcdir)/'`kernel/TeTheme.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeTheme.Tpo $(DEPDIR)/libterralib_la-TeTheme.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeTheme.cpp' object='libterralib_la-TeTheme.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeTheme.lo `test -f 'kernel/TeTheme.cpp' || echo '$(srcdir)/'`kernel/TeTheme.cpp
+
+libterralib_la-TeThread.lo: kernel/TeThread.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeThread.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeThread.Tpo -c -o libterralib_la-TeThread.lo `test -f 'kernel/TeThread.cpp' || echo '$(srcdir)/'`kernel/TeThread.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeThread.Tpo $(DEPDIR)/libterralib_la-TeThread.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeThread.cpp' object='libterralib_la-TeThread.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeThread.lo `test -f 'kernel/TeThread.cpp' || echo '$(srcdir)/'`kernel/TeThread.cpp
+
+libterralib_la-TeThreadFunctor.lo: kernel/TeThreadFunctor.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeThreadFunctor.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeThreadFunctor.Tpo -c -o libterralib_la-TeThreadFunctor.lo `test -f 'kernel/TeThreadFunctor.cpp' || echo '$(srcdir)/'`kernel/TeThreadFunctor.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeThreadFunctor.Tpo $(DEPDIR)/libterralib_la-TeThreadFunctor.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeThreadFunctor.cpp' object='libterralib_la-TeThreadFunctor.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeThreadFunctor.lo `test -f 'kernel/TeThreadFunctor.cpp' || echo '$(srcdir)/'`kernel/TeThreadFunctor.cpp
+
+libterralib_la-TeThreadSignal.lo: kernel/TeThreadSignal.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeThreadSignal.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeThreadSignal.Tpo -c -o libterralib_la-TeThreadSignal.lo `test -f 'kernel/TeThreadSignal.cpp' || echo '$(srcdir)/'`kernel/TeThreadSignal.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeThreadSignal.Tpo $(DEPDIR)/libterralib_la-TeThreadSignal.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeThreadSignal.cpp' object='libterralib_la-TeThreadSignal.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeThreadSignal.lo `test -f 'kernel/TeThreadSignal.cpp' || echo '$(srcdir)/'`kernel/TeThreadSignal.cpp
+
+libterralib_la-TeTime.lo: kernel/TeTime.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeTime.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeTime.Tpo -c -o libterralib_la-TeTime.lo `test -f 'kernel/TeTime.cpp' || echo '$(srcdir)/'`kernel/TeTime.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeTime.Tpo $(DEPDIR)/libterralib_la-TeTime.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeTime.cpp' object='libterralib_la-TeTime.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeTime.lo `test -f 'kernel/TeTime.cpp' || echo '$(srcdir)/'`kernel/TeTime.cpp
+
+libterralib_la-TeTimeInterval.lo: kernel/TeTimeInterval.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeTimeInterval.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeTimeInterval.Tpo -c -o libterralib_la-TeTimeInterval.lo `test -f 'kernel/TeTimeInterval.cpp' || echo '$(srcdir)/'`kernel/TeTimeInterval.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeTimeInterval.Tpo $(DEPDIR)/libterralib_la-TeTimeInterval.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeTimeInterval.cpp' object='libterralib_la-TeTimeInterval.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeTimeInterval.lo `test -f 'kernel/TeTimeInterval.cpp' || echo '$(srcdir)/'`kernel/TeTimeInterval.cpp
+
+libterralib_la-TeTin.lo: kernel/TeTin.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeTin.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeTin.Tpo -c -o libterralib_la-TeTin.lo `test -f 'kernel/TeTin.cpp' || echo '$(srcdir)/'`kernel/TeTin.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeTin.Tpo $(DEPDIR)/libterralib_la-TeTin.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeTin.cpp' object='libterralib_la-TeTin.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeTin.lo `test -f 'kernel/TeTin.cpp' || echo '$(srcdir)/'`kernel/TeTin.cpp
+
+libterralib_la-TeUtils.lo: kernel/TeUtils.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeUtils.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeUtils.Tpo -c -o libterralib_la-TeUtils.lo `test -f 'kernel/TeUtils.cpp' || echo '$(srcdir)/'`kernel/TeUtils.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeUtils.Tpo $(DEPDIR)/libterralib_la-TeUtils.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeUtils.cpp' object='libterralib_la-TeUtils.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeUtils.lo `test -f 'kernel/TeUtils.cpp' || echo '$(srcdir)/'`kernel/TeUtils.cpp
+
+libterralib_la-TeVectorRemap.lo: kernel/TeVectorRemap.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeVectorRemap.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeVectorRemap.Tpo -c -o libterralib_la-TeVectorRemap.lo `test -f 'kernel/TeVectorRemap.cpp' || echo '$(srcdir)/'`kernel/TeVectorRemap.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeVectorRemap.Tpo $(DEPDIR)/libterralib_la-TeVectorRemap.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeVectorRemap.cpp' object='libterralib_la-TeVectorRemap.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeVectorRemap.lo `test -f 'kernel/TeVectorRemap.cpp' || echo '$(srcdir)/'`kernel/TeVectorRemap.cpp
+
+libterralib_la-TeViewNode.lo: kernel/TeViewNode.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeViewNode.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeViewNode.Tpo -c -o libterralib_la-TeViewNode.lo `test -f 'kernel/TeViewNode.cpp' || echo '$(srcdir)/'`kernel/TeViewNode.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeViewNode.Tpo $(DEPDIR)/libterralib_la-TeViewNode.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeViewNode.cpp' object='libterralib_la-TeViewNode.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeViewNode.lo `test -f 'kernel/TeViewNode.cpp' || echo '$(srcdir)/'`kernel/TeViewNode.cpp
+
+libterralib_la-TeVisual.lo: kernel/TeVisual.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-TeVisual.lo -MD -MP -MF $(DEPDIR)/libterralib_la-TeVisual.Tpo -c -o libterralib_la-TeVisual.lo `test -f 'kernel/TeVisual.cpp' || echo '$(srcdir)/'`kernel/TeVisual.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-TeVisual.Tpo $(DEPDIR)/libterralib_la-TeVisual.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/TeVisual.cpp' object='libterralib_la-TeVisual.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-TeVisual.lo `test -f 'kernel/TeVisual.cpp' || echo '$(srcdir)/'`kernel/TeVisual.cpp
+
+libterralib_la-lexTemporal.lo: kernel/lexTemporal.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-lexTemporal.lo -MD -MP -MF $(DEPDIR)/libterralib_la-lexTemporal.Tpo -c -o libterralib_la-lexTemporal.lo `test -f 'kernel/lexTemporal.cpp' || echo '$(srcdir)/'`kernel/lexTemporal.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-lexTemporal.Tpo $(DEPDIR)/libterralib_la-lexTemporal.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/lexTemporal.cpp' object='libterralib_la-lexTemporal.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-lexTemporal.lo `test -f 'kernel/lexTemporal.cpp' || echo '$(srcdir)/'`kernel/lexTemporal.cpp
+
+libterralib_la-yyTemporal.lo: kernel/yyTemporal.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -MT libterralib_la-yyTemporal.lo -MD -MP -MF $(DEPDIR)/libterralib_la-yyTemporal.Tpo -c -o libterralib_la-yyTemporal.lo `test -f 'kernel/yyTemporal.cpp' || echo '$(srcdir)/'`kernel/yyTemporal.cpp
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libterralib_la-yyTemporal.Tpo $(DEPDIR)/libterralib_la-yyTemporal.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='kernel/yyTemporal.cpp' object='libterralib_la-yyTemporal.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libterralib_la_CXXFLAGS) $(CXXFLAGS) -c -o libterralib_la-yyTemporal.lo `test -f 'kernel/yyTemporal.cpp' || echo '$(srcdir)/'`kernel/yyTemporal.cpp
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+#EXTRA_DIST		= jpeg/ijl.h jpeg/jpeg.h
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/terralib/kernel/Gra_algo.h b/src/terralib/kernel/Gra_algo.h
new file mode 100644
index 0000000..2372395
--- /dev/null
+++ b/src/terralib/kernel/Gra_algo.h
@@ -0,0 +1,195 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+//  include/gra_algo.h
+#ifndef GRAPH_ALGORITHMS_H
+#define GRAPH_ALGORITHMS_H 
+#include <dynpq.h>
+#include <graph.h>
+#include <limits>
+#include <iostream>
+
+namespace br_stl {
+
+template<class GraphType, class EdgeType>
+void Dijkstra(
+       GraphType& Gr,
+       std::vector<EdgeType>& Dist,
+       std::vector<int>& Pred,
+       int Start) {
+    /* The algorithm proceeds in such a way that the distances are
+       estimated and the estimates gradually improved. The distance to
+       the starting point is known (0). For all other vertices, the
+       worst possible estimate is entered.*/
+
+    Dist = std::vector<EdgeType>(Gr.size(),
+          TeMAXFLOAT); // as good as infinity
+    Dist[Start] = (EdgeType)0;
+
+    /* The predecessor vector too is initialized with `impossible'
+       values. Subsequently, a dynamic priority queue is defined and
+       initialized with the distance vector: */
+
+	Pred = std::vector<int>(Gr.size(), -1);
+    dynamic_priority_queue<EdgeType> Q(Dist);
+
+    // In the next step, all vertices are extracted  one by one from
+    //  the priority queue, and precisely in the order of the estimated
+    // distance towards the starting vertex. Obviously, the starting
+    //vertex is dealt with first. No vertex is looked at twice. 
+
+    int u;
+    while(!Q.empty()) {
+       u = Q.topIndex();   // extract vertex with minimum
+       Q.pop();
+
+       // Now, the distance estimates for all neighboring vertices of
+       //  u are updated. If the previous estimate of the distance
+        //  between the current neighbor of u and the starting vertex
+       //   (Dist[Neighbor]) is worse than the distance between vertex u
+        //  and the starting vertex (Dist[u]) plus the distance between
+       //   u and the neighboring vertex (dist), the estimate is
+        //  improved: this process is called relaxation. In this case,
+        //  the path from the starting vertex to the neighbor cannot be
+        //  longer than (Dist[u] + dist). In this case, u would have to
+        //  be regarded as predecessor of the neighbor. 
+          
+        // improve estimates for all neighbors of u
+        typename GraphType::Successor::const_iterator
+                   I = Gr[u].second.begin();
+
+        while(I != Gr[u].second.end()) {
+            int Neighbor = (*I).first;
+            EdgeType dist = (*I).second;
+
+            // relaxation
+            if(Dist[Neighbor] > Dist[u] + dist) {
+               // improve estimate
+               Q.changeKeyAt(Neighbor, Dist[u] + dist);
+               // u is predecessor of the neighbor
+               Pred[Neighbor] = u;
+            }
+            ++I;
+        }
+    }
+	return;
+}
+
+template<class GraphType>
+bool topoSort(
+       GraphType& G,
+       std::vector<int>& Result) {
+    assert(G.isDirected());           // let's play this safe!
+    int ResCounter = 0;
+    Result = std::vector<int>(G.size(), -1);
+
+    /* The vector Result takes the indices of the correspondingly
+       distributed vertices. The counter ResCounter is the position in
+       Result where the next entry belongs. */
+
+    vector<int> PredecessorCount(G.size(), 0);
+    int VerticesWithoutSuccessor = 0;
+
+    /* For each vertex, the vector PredecessorCount counts how many
+       predecessors it has. There are vertices without successors,
+       whose number is kept in VerticesWithoutSuccessor. Furthermore,
+       the algorithm remains stable if the precondition that a graph
+       must not have cycles is violated. The variable
+       VerticesWithoutSuccessor is used to recognize this situation
+       (see below). */
+
+    /* 
+	for(size_t iv = 0; iv < G.size(); ++iv) {
+        if(G[iv].second.size() > 0) {    // is predecessor
+           typename GraphType::Successor::const_iterator I =
+                G[iv].second.begin();
+           while(I != G[iv].second.end())
+               // update number of predecessors
+               ++PredecessorCount[(*I++).first];
+        }
+        else  { // Vertex is no predecessor, that is, without successor
+             // an excessively high number of predecessors is used 
+             // for later recognition
+             PredecessorCount[iv] =   G.size(); // too many!
+             ++VerticesWithoutSuccessor;
+        }
+    }
+	*/
+
+    /* The dynamic priority queue is initialized with the vector of
+       numbers of predecessors. At the beginning of the queue we find
+       those vertices that have no predecessors and therefore are to
+       be processed next. Only the vertices which are predecessors
+       themselves, that is that have successors are processed. The
+       subsequent loop is terminated when the queue only contains
+       successor vertices which themselves are not predecessors. Their
+       number of predecessors can never be 0 because further above
+       they were initialized with too high a value.*/
+       
+    /* 
+	dynamic_priority_queue<int> Q(PredecessorCount);
+
+    // process all predecessors
+    while(Q.topKey() == 0) {
+        // determine vertex with predecessor number 0
+       int oV = Q.topIndex();
+       Q.pop();
+
+       Result[ResCounter++] = oV;
+
+       // In order to ensure that this vertex without predecessors oV
+        //  is no longer considered in the next cycle, the number of
+       //   predecessors of all its successors is decreased by 1. 
+          
+       typename GraphType::Successor::const_iterator
+             I = G[oV].second.begin();
+       while(I != G[oV].second.end()) {
+          // decrease number of predecessors with 
+          // changeKeyAt()}. Do not change directly!
+          int V = (*I).first;
+          Q.changeKeyAt(V, PredecessorCount[V] -1);
+          ++I;
+       }
+    }
+
+    // Now, all vertices without successors are entered. As a
+    //   countercheck, the variable VerticesWithoutSuccessor is
+    //   decreased. If the queue contains too many vertices, an error
+    //   message is displayed.  
+       
+    while(!Q.empty()) {
+         Result[ResCounter++] = Q.topIndex();
+         Q.pop();
+         --VerticesWithoutSuccessor;
+    }
+
+    if(VerticesWithoutSuccessor < 0)
+       std::cerr << "Error: graph contains a cycle!\n";
+    return VerticesWithoutSuccessor == 0;
+	*/
+	return false;
+}
+
+} // namespace br_stl
+#endif
+
diff --git a/src/terralib/kernel/TeAbstractFactory.h b/src/terralib/kernel/TeAbstractFactory.h
new file mode 100644
index 0000000..ead298a
--- /dev/null
+++ b/src/terralib/kernel/TeAbstractFactory.h
@@ -0,0 +1,145 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAbstractFactory.h
+	\brief Implements a template for the Abstract Factory pattern
+*/
+#ifndef  __TERRALIB_INTERNAL_NEW_FACTORY_H
+#define  __TERRALIB_INTERNAL_NEW_FACTORY_H
+
+#include "TeDefines.h"
+#include <map>
+#include <string>
+
+using std::map;
+using std::string;
+
+//!  Implements a template for the Abstract Factory pattern.
+/*
+    This file implements a templated version of the Abstract Factory Pattern 
+	See: "Design Patterns - Elements of Reusable Object-Oriented Software", by Gamma et. al
+	page 87.
+  \author Gilberto Camara, L�bia Vinhas
+*/
+template <typename PRODUCT,						// The product to be made
+		  typename PARAMS,						// The parameter necessary to make the product
+		  typename PRODUCTIDTYPE=std::string>	// The type used to identify the product
+class TeAbstractFactory
+{
+public:
+
+	//! To link each product to its factory
+	typedef map<PRODUCTIDTYPE, TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>* > TeFactoryMap; 
+
+	//! Returns the single instance of the factory registration
+	static TeFactoryMap& instance()
+	{ 
+		static TeFactoryMap Fmap_;
+		return Fmap_;
+	}
+
+protected:
+
+	//!  Builds a new product from a set of parameters (should be implemented by descendants)
+    virtual PRODUCT* build(PARAMS* /*arg*/)
+	{ 
+		return PRODUCT::DefaultObject(); 
+	}
+
+ 	//!  Builds a new product without parameters (should be implemented by descendants)
+   virtual PRODUCT* build()
+	{ 
+		return PRODUCT::DefaultObject(); 
+	}
+
+public:
+	//! Factory Constructor
+	/*
+		\param prodId the identification of the product that the factory produces
+	*/
+	TeAbstractFactory(PRODUCTIDTYPE prodId);
+
+	//! Destructor
+	virtual ~TeAbstractFactory() {}
+
+	//! Virtual constructor: make the product from some arguments
+	/*
+		\param arg a pointer to an structure that contains the arguments
+		necessary to build the product. The type of product has to be extracted
+		from the arguments
+	*/
+	static PRODUCT* make(PARAMS* arg);
+
+	//! Virtual constructor: explictly identifies which product should be made
+	static PRODUCT* make(PRODUCTIDTYPE prodId);
+
+private:
+	PRODUCTIDTYPE  productIdentification_;
+};
+
+// Factor Constructor
+template <typename PRODUCT, typename PARAMS, typename PRODUCTIDTYPE>
+TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::TeAbstractFactory(PRODUCTIDTYPE prodId):
+	productIdentification_(prodId)
+{
+	TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::instance()[prodId] = this;
+}
+
+//! Builds an object, based on the input parameters
+template <typename PRODUCT, typename PARAMS, typename PRODUCTIDTYPE> 
+PRODUCT*
+TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::make(PRODUCTIDTYPE producId)
+{
+	// try to find the name on the factory dictionary
+	typename TeFactoryMap::iterator i = TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::instance().find(producId);
+
+	// Not found ?  return the Default Object   
+	if (i == TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::instance().end())
+		return PRODUCT::DefaultObject();
+
+	// Create an object, based on the input parameters
+	return (*i).second->build();
+}
+
+//! Builds an object, based on the input parameters
+template <typename PRODUCT, typename PARAMS, typename PRODUCTIDTYPE> 
+PRODUCT*
+TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::make(PARAMS* arg)
+{
+	// If there are no arguments or factory identification return the default object
+	if (!arg)
+		return PRODUCT::DefaultObject();
+
+	PRODUCTIDTYPE productId = arg->getProductId(); 
+
+	// try to find the name on the factory dictionary
+	typename TeFactoryMap::iterator i = TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::instance().find(productId);
+
+	// Not found ?  return the Default Object   
+	if (i == TeAbstractFactory<PRODUCT,PARAMS,PRODUCTIDTYPE>::instance().end())
+		return PRODUCT::DefaultObject();
+
+	// Create an object, based on the input parameters
+		return (*i).second->build(arg);
+}
+#endif
+
diff --git a/src/terralib/kernel/TeAbstractTheme.cpp b/src/terralib/kernel/TeAbstractTheme.cpp
new file mode 100644
index 0000000..147767c
--- /dev/null
+++ b/src/terralib/kernel/TeAbstractTheme.cpp
@@ -0,0 +1,1255 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeAbstractTheme.h"
+#include "TeVisual.h"
+#include "TeRasterTransform.h"
+
+extern int  yyparse(string& sqlOut);
+extern int  initParse(const string& strIn, TeDatabase* db);
+
+TeAbstractTheme::TeAbstractTheme(const string& name, TeViewNode* parent, const int& view, const int& id, const TeViewNodeType& nodeType)
+		: TeViewNode(name, parent, view, id, nodeType),
+		generateAttributeRest_(""),
+		generateTemporalRest_(""),
+		hasSpatialRes_(false),
+		geomRest_(0),
+		minScale_(0.0),
+		maxScale_(0.0),
+		visibleRep_(0),
+		enableVisibility_(1),
+		rasterVisual_(0),
+		themeBox_(TeBox())
+{
+	grouping_.groupMode_ = TeNoGrouping;
+
+	//default legends
+	TeVisual* visp = new TeVisual(TePOLYGONS);
+	TeVisual* visl = new TeVisual(TeLINES);
+	TeVisual* vispt = new TeVisual(TePOINTS);
+	TeVisual* vist = new TeVisual(TeTEXT);
+
+	TeColor	color;
+	color.init(100, 220, 220);
+	visp->color(color);
+	visl->color(color);
+	vispt->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	visl->contourColor(color);
+	vispt->contourColor(color);
+
+	outOfCollectionLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	outOfCollectionLegend_.setVisual(visl->copy(), TeLINES);		
+	outOfCollectionLegend_.setVisual(vispt->copy(), TePOINTS);		
+	outOfCollectionLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	color.init(220, 100, 220);
+	visp->color(color);
+	visl->color(color);
+	vispt->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	visl->contourColor(color);
+	vispt->contourColor(color);
+
+	withoutDataConnectionLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	withoutDataConnectionLegend_.setVisual(visl->copy(), TeLINES);		
+	withoutDataConnectionLegend_.setVisual(vispt->copy(), TePOINTS);		
+	withoutDataConnectionLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	color.init(220, 0, 0);
+	visp->color(color);
+	color.init(0, 220, 220);
+	visl->color(color);
+	color.init(220, 90, 180);
+	vispt->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	visl->contourColor(color);
+	vispt->contourColor(color);
+	color.init(0, 0, 0);
+	vist->color(color);
+
+	defaultLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	defaultLegend_.setVisual(visl->copy(), TeLINES);		
+	defaultLegend_.setVisual(vispt->copy(), TePOINTS);		
+	defaultLegend_.setVisual(vist->copy(), TeTEXT);		
+	
+	color.init(80, 240, 100);
+	visp->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	pointingLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	pointingLegend_.setVisual(visl->copy(), TeLINES);		
+	pointingLegend_.setVisual(vispt->copy(), TePOINTS);		
+	pointingLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	color.init(210, 210, 0);
+	visp->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);		
+	queryLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	queryLegend_.setVisual(visl->copy(), TeLINES);		
+	queryLegend_.setVisual(vispt->copy(), TePOINTS);		
+	queryLegend_.setVisual(vist->copy(), TeTEXT);	
+							
+	color.init(255, 255, 0);
+	visp->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);		
+	queryAndPointingLegend_.setVisual(visp->copy(), TePOLYGONS);	
+	queryAndPointingLegend_.setVisual(visl->copy(), TeLINES);		
+	queryAndPointingLegend_.setVisual(vispt->copy(), TePOINTS);		
+	queryAndPointingLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	delete visp;
+	delete visl;
+	delete vispt;
+	delete vist;
+}
+
+TeAbstractTheme::TeAbstractTheme(const TeViewNodeParams& params) : 
+		TeViewNode(params),
+		generateAttributeRest_(""),
+		generateTemporalRest_(""),
+		hasSpatialRes_(false),
+		geomRest_(0),
+		minScale_(0.0),
+		maxScale_(0.0),
+		visibleRep_(0),
+		enableVisibility_(1),
+		rasterVisual_(0),
+		themeBox_(TeBox())
+{
+	grouping_.groupMode_ = TeNoGrouping;
+	//default legends
+	TeVisual* visp = new TeVisual(TePOLYGONS);
+	TeVisual* visl = new TeVisual(TeLINES);
+	TeVisual* vispt = new TeVisual(TePOINTS);
+	TeVisual* vist = new TeVisual(TeTEXT);
+	TeColor	color;
+	color.init(100, 220, 220);
+	visp->color(color);
+	visl->color(color);
+	vispt->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	visl->contourColor(color);
+	vispt->contourColor(color);
+
+	outOfCollectionLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	outOfCollectionLegend_.setVisual(visl->copy(), TeLINES);		
+	outOfCollectionLegend_.setVisual(vispt->copy(), TePOINTS);		
+	outOfCollectionLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	color.init(220, 100, 220);
+	visp->color(color);
+	visl->color(color);
+	vispt->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	visl->contourColor(color);
+	vispt->contourColor(color);
+
+	withoutDataConnectionLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	withoutDataConnectionLegend_.setVisual(visl->copy(), TeLINES);		
+	withoutDataConnectionLegend_.setVisual(vispt->copy(), TePOINTS);		
+	withoutDataConnectionLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	color.init(220, 0, 0);
+	visp->color(color);
+	color.init(0, 220, 220);
+	visl->color(color);
+	color.init(220, 90, 180);
+	vispt->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	visl->contourColor(color);
+	vispt->contourColor(color);
+	color.init(0, 0, 0);
+	vist->color(color);
+
+	defaultLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	defaultLegend_.setVisual(visl->copy(), TeLINES);		
+	defaultLegend_.setVisual(vispt->copy(), TePOINTS);		
+	defaultLegend_.setVisual(vist->copy(), TeTEXT);		
+	
+	color.init(80, 240, 100);
+	visp->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);
+	pointingLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	pointingLegend_.setVisual(visl->copy(), TeLINES);		
+	pointingLegend_.setVisual(vispt->copy(), TePOINTS);		
+	pointingLegend_.setVisual(vist->copy(), TeTEXT);	
+
+	color.init(210, 210, 0);
+	visp->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);		
+	queryLegend_.setVisual(visp->copy(), TePOLYGONS);		
+	queryLegend_.setVisual(visl->copy(), TeLINES);		
+	queryLegend_.setVisual(vispt->copy(), TePOINTS);		
+	queryLegend_.setVisual(vist->copy(), TeTEXT);	
+							
+	color.init(255, 255, 0);
+	visp->color(color);
+	color.init(100, 100, 100);
+	visp->contourColor(color);		
+	queryAndPointingLegend_.setVisual(visp->copy(), TePOLYGONS);	
+	queryAndPointingLegend_.setVisual(visl->copy(), TeLINES);		
+	queryAndPointingLegend_.setVisual(vispt->copy(), TePOINTS);		
+	queryAndPointingLegend_.setVisual(vist->copy(), TeTEXT);
+
+	delete visp;
+	delete visl;
+	delete vispt;
+	delete vist;
+}
+
+//! Copy constructor
+TeAbstractTheme::TeAbstractTheme (const TeAbstractTheme& other) : 
+	TeViewNode(other.viewNodeParams_) 
+{
+	generateAttributeRest_ = other.generateAttributeRest_;
+	generateTemporalRest_ = other.generateTemporalRest_;
+	generateSpatialRest_ = other.generateSpatialRest_; 
+	spatialRelation_ = other.spatialRelation_;
+	hasSpatialRes_ =  other.hasSpatialRes_;
+	boxRest_ = other.boxRest_;
+	geomRest_ = other.geomRest_; 
+	geomRepRest_ = other.geomRepRest_;	
+	minScale_ = other.minScale_;
+	maxScale_ = other.maxScale_;
+	visibleRep_ = other.visibleRep_;
+	enableVisibility_ = other.enableVisibility_;
+
+	grouping_ = other.grouping_;
+
+	cleanLegend();
+	legend_.resize(other.legend_.size());
+	copy(other.legend_.begin(),other.legend_.end(),legend_.begin());
+	outOfCollectionLegend_ = other.outOfCollectionLegend_;
+	withoutDataConnectionLegend_ = other.withoutDataConnectionLegend_;	
+	defaultLegend_ = other.defaultLegend_;
+	pointingLegend_ = other.pointingLegend_;
+	queryLegend_ = other.queryLegend_;
+	queryAndPointingLegend_ = other.queryAndPointingLegend_; 
+	
+	objectSet_ = other.objectSet_;
+	numLayerObjects_ = other.numLayerObjects_;
+	itemStatusMap_ = other.itemStatusMap_;
+	objStatusMap_ = other.objStatusMap_;
+	rasterVisual_ = 0;
+	if(other.rasterVisual_)
+	{
+		rasterVisual_ = new TeRasterTransform();
+		(*rasterVisual_) = (*other.rasterVisual_);
+	}
+	themeBox_ = other.themeBox_;
+}
+
+//! Destructor
+TeAbstractTheme::~TeAbstractTheme () 
+{ 
+	if (rasterVisual_)
+		delete rasterVisual_;
+	generateAttributeRest_.clear();
+	generateTemporalRest_.clear();
+	generateSpatialRest_.clear();
+	cleanLegend();
+	outOfCollectionLegend_.clear();
+	withoutDataConnectionLegend_.clear();
+	defaultLegend_.clear(); 
+	pointingLegend_.clear(); 
+	queryLegend_.clear(); 
+	queryAndPointingLegend_.clear();
+}
+
+TeAbstractTheme& 
+TeAbstractTheme::operator= (const TeAbstractTheme& other)
+{
+	if ( this != &other )
+	{
+		viewNodeParams_ = other.viewNodeParams_;
+		
+		generateAttributeRest_ = other.generateAttributeRest_;
+		generateTemporalRest_ = other.generateTemporalRest_;
+		generateSpatialRest_ = other.generateSpatialRest_; 
+		spatialRelation_ = other.spatialRelation_;
+		hasSpatialRes_ =  other.hasSpatialRes_;
+		boxRest_ = other.boxRest_;
+		geomRest_ = other.geomRest_; 
+		geomRepRest_ = other.geomRepRest_;	
+		minScale_ = other.minScale_;
+		maxScale_ = other.maxScale_;
+		visibleRep_ = other.visibleRep_;
+		enableVisibility_ = other.enableVisibility_;
+
+		grouping_ = other.grouping_;
+
+		cleanLegend();
+		legend_.resize(other.legend_.size());
+		copy(other.legend_.begin(),other.legend_.end(),legend_.begin());
+		outOfCollectionLegend_ = other.outOfCollectionLegend_;
+		withoutDataConnectionLegend_ = other.withoutDataConnectionLegend_;	
+		defaultLegend_ = other.defaultLegend_;
+		pointingLegend_ = other.pointingLegend_;
+		queryLegend_ = other.queryLegend_;
+		queryAndPointingLegend_ = other.queryAndPointingLegend_; 
+		
+		objectSet_ = other.objectSet_;
+		numLayerObjects_ = other.numLayerObjects_;
+		itemStatusMap_ = other.itemStatusMap_;
+		objStatusMap_ = other.objStatusMap_;
+	
+		if(rasterVisual_)
+			delete rasterVisual_;
+		rasterVisual_ = 0;
+		if(other.rasterVisual_)
+		{
+			rasterVisual_ = new TeRasterTransform();
+			(*rasterVisual_) = (*other.rasterVisual_);
+		}
+		themeBox_ = other.themeBox_;
+	}
+	return *this;
+}
+
+int TeAbstractTheme::visibleGeoRep()
+{
+	return (visibleRep_ & ~0x40000000 & ~0x80000000 & ~0x20000000);
+}
+
+void TeAbstractTheme::removeRasterVisual()
+{ 
+	if (rasterVisual_)
+	{
+		delete rasterVisual_;
+		rasterVisual_ = 0;
+	}
+}
+
+void TeAbstractTheme::cleanLegend()
+{
+   while (legend_.size())     
+   {
+       legend_[0].clear();
+       legend_.erase(legend_.begin());
+   }
+   legend_.clear(); 
+}
+
+void 
+TeAbstractTheme::setSpatialRest(TeBox& box, TeGeomRep rep, TeSpatialRelation relation)
+{
+	hasSpatialRes_ = true;
+	boxRest_ = box;
+	spatialRelation_ = relation;
+	geomRepRest_ = rep;
+	geomRest_ = 0;
+}
+
+void 
+TeAbstractTheme::setSpatialRest(TeGeometry* geom, TeGeomRep rep, TeSpatialRelation relation)
+{
+	hasSpatialRes_ = true;
+	geomRest_ = geom;
+	spatialRelation_ = relation;
+	geomRepRest_ = rep;
+	boxRest_ = TeBox();
+}
+
+void TeAbstractTheme::legend (TeLegendEntry& leg)
+{
+	if(leg.group() == -6)	// queried and pointed objects visual
+		queryAndPointingLegend_ = leg;
+	else if(leg.group() == -5)	// queried objects visual
+		queryLegend_ = leg;
+	else if (leg.group() == -4)
+		pointingLegend_ = leg;
+	else if (leg.group() == -3)
+		defaultLegend_ = leg;
+	else if (leg.group() == -2)
+		withoutDataConnectionLegend_ = leg;
+	else if (leg.group() == -1)
+		outOfCollectionLegend_ = leg;
+	else if (leg.group() > -1)
+		legend_.push_back (leg);
+}
+
+void 
+TeAbstractTheme::resetGrouping ()
+{
+	if((grouping_.groupMode_ == TeRasterSlicing) && rasterVisual_)
+			this->removeRasterVisual();
+
+	grouping_.groupMode_ = TeNoGrouping;
+	legend_.clear();
+	return;
+}
+
+bool 
+TeAbstractTheme::buildGrouping(const TeGrouping& g, vector<TeSlice>& slices)
+{
+	grouping_ = g;
+	legend_.clear(); 
+	
+	for(unsigned int j=0; j<slices.size(); j++)
+	{
+		TeLegendEntry legend(slices[j]);
+		legend.group(j);
+		legend.theme(id());
+		legend_.push_back(legend);
+	}	
+	return true;
+}
+
+bool
+TeAbstractTheme::setGroupingVisual(int n, TeVisual* visual, TeGeomRep rep)
+{
+	if(	(n > grouping_.groupNumSlices_)	||
+		((int)legend_.size() < n)				|| 
+		(legend_.empty()) )
+		return false;
+	legend_[(n-1)].setVisual (visual->copy(), rep); 
+	return true;
+}
+
+bool
+TeAbstractTheme::setGroupingVisual(int n, TeGeomRepVisualMap& vismap)
+{
+	if(	(n > grouping_.groupNumSlices_)	||
+		((int)legend_.size() < n)		|| 
+		(legend_.empty()) )
+		return false;
+
+	TeGeomRepVisualMap::iterator it = vismap.begin();
+	while (it != vismap.end())
+	{
+		legend_[(n-1)].setVisual(it->second->copy(),it->first);
+		++it;
+	}
+	return true;
+}
+
+TeSliceVector 
+TeAbstractTheme::getSlices()
+{
+	TeSliceVector sliceVec;
+	for(unsigned int x=0; x<legend_.size(); ++x)
+	{
+		TeSlice slice = legend_[x].slice();
+		sliceVec.push_back (slice);
+	}
+	return sliceVec;
+}
+
+
+
+void TeAbstractTheme::createRasterVisual(TeRaster* rst)
+{
+	if (rasterVisual_)
+		delete rasterVisual_;
+
+	if (!rst)
+		return;
+
+	rasterVisual_ = new TeRasterTransform();
+										
+	if (rst->params().photometric_[0] == TeRasterParams::TePallete)  // raster palette -> uses its palette
+	{
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Pallete2ThreeBand);
+		rasterVisual_->setLutSize(rst->params().lutr_.size());
+		return;
+	}
+
+	if (visibleRep_ & 0x40000000  &&		// sliced raster -> generate the
+		grouping_.groupMode_ == TeRasterSlicing)	// appropriate palette
+	{
+		int band = atoi(grouping_.groupAttribute_.name_.c_str());
+		rasterVisual_->setSrcBand(band);
+		if (rst->params().dataType_[band] != TeUNSIGNEDCHAR)
+			rasterVisual_->generateLUT(legend_, 1024, defaultLegend_.visual(TePOLYGONS)->color());
+		else
+			rasterVisual_->generateLUT(legend_, 256, defaultLegend_.visual(TePOLYGONS)->color());
+		rasterVisual_->setTransfFunction(&TeRasterTransform::LUT2ThreeBand);
+		return;
+	}
+
+	if (rst->params().dataType_[0] != TeUNSIGNEDCHAR)	// non unsigned char -> generate linear transformation
+		rasterVisual_->setLinearTransfParameters(rst->params().vmin_[0],rst->params().vmax_[0], 0, 255);
+
+	if (rst->params().nBands() == 1)				
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Mono2ThreeBand);
+	else if (rst->params().nBands() == 3)
+		rasterVisual_->setTransfFunction(&TeRasterTransform::ThreeBand2RGB);
+	else
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Band2Band);
+}
+
+void TeAbstractTheme::setParent (TeViewNode* )
+{
+	viewNodeParams_.myParent_ = 0; 
+	viewNodeParams_.myParentId_ = 0;
+}
+
+void TeAbstractTheme::setStatus(vector<string>& oidVec, vector<string>& itemVec, int status)
+{
+	vector<string>::iterator it;
+
+	if(status == 0)
+	{
+		for(it=oidVec.begin(); it!=oidVec.end();++it)
+		{
+			string s = *it;
+			if(objStatusMap_.find(s) != objStatusMap_.end())
+				objStatusMap_.erase(s);
+		}
+		for(it=itemVec.begin(); it!=itemVec.end();++it)
+		{
+			string s = *it;
+			if(itemStatusMap_.find(s) != itemStatusMap_.end())
+				itemStatusMap_.erase(s);
+		}
+	}
+	else
+	{
+		for(it=oidVec.begin(); it!=oidVec.end();++it)
+		{
+			string s = *it;
+			objStatusMap_[s] = status;
+		}
+		for(it=itemVec.begin(); it!=itemVec.end();++it)
+		{
+			string s = *it;
+			itemStatusMap_[s] = status;
+		}
+	}
+}
+
+void TeAbstractTheme::setStatusForObjectToggled(string oid)
+{
+	string uid;
+
+	int& oidStatus = objStatusMap_[oid];
+	if (oidStatus == TeDEFAULT)
+		oidStatus = TePOINTED;
+	else if (oidStatus == TePOINTED)
+		oidStatus = TeDEFAULT;
+	else if (oidStatus == TeQUERIED)
+		oidStatus = TePOINTED_QUERIED;
+	else if (oidStatus == TePOINTED_QUERIED)
+		oidStatus = TeQUERIED;
+
+	set<string> oidSet;
+	oidSet.insert(oid);
+	vector<string> uidVec = getItemVector(oidSet);
+	for (unsigned int i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		int& uidStatus = itemStatusMap_[uidVec[i]];
+		if (uidStatus == TeDEFAULT)
+		{
+			if (oidStatus == TePOINTED || oidStatus == TePOINTED_QUERIED)
+				uidStatus = TePOINTED;
+		}
+		else if (uidStatus == TePOINTED)
+		{
+			if (oidStatus == TeDEFAULT || oidStatus == TeQUERIED)
+				itemStatusMap_.erase(uid);
+		}
+		else if (uidStatus == TeQUERIED)
+		{
+			if (oidStatus == TePOINTED || oidStatus == TePOINTED_QUERIED)
+				uidStatus = TePOINTED_QUERIED;
+		}
+		else if (uidStatus == TePOINTED_QUERIED)
+		{
+			if (oidStatus == TeDEFAULT || oidStatus == TeQUERIED)
+				uidStatus = TeQUERIED;
+		}
+	}
+	
+	// Save the status id of the object
+	if (oidStatus == TeDEFAULT)
+		objStatusMap_.erase(oid);
+}
+
+void TeAbstractTheme::setStatusForItemsToggled(set<string>& oidSet, vector<string>& uidVec)
+{
+	unsigned int i;
+	int oidStatus;
+	string oid, uid;
+	set<string>::iterator it;
+
+	// Set the new status of the uids
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TeDEFAULT)
+			itemStatusMap_[uid] = TePOINTED;
+		else if (itemStatusMap_[uid] == TePOINTED)
+			itemStatusMap_.erase(uid);
+		else if (itemStatusMap_[uid] == TeQUERIED)
+			itemStatusMap_[uid] = TePOINTED_QUERIED;
+		else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			itemStatusMap_[uid] = TeQUERIED;
+	}
+
+
+	// Set the new status of the oids
+	for (it = oidSet.begin(); it != oidSet.end(); ++it)
+	{
+		oid = *it;
+		oidStatus = 0;
+		set<string> objSet;
+		objSet.insert(oid);
+		vector<string> uidVec = getItemVector(objSet);
+		for (i = 0; i < uidVec.size(); ++i)
+		{
+			uid = uidVec[i];
+			if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			{
+				oidStatus = TePOINTED_QUERIED;
+				break;
+			}
+			oidStatus = MAX(oidStatus, itemStatusMap_[uid]);
+			if (itemStatusMap_[uid] == TeDEFAULT)
+				itemStatusMap_.erase(uid);
+		}	
+		
+		if (oidStatus == 0)
+			objStatusMap_.erase(oid);
+		else
+			objStatusMap_[oid] = oidStatus;
+	}
+}
+
+void TeAbstractTheme::setStatusForNewItemsQueried(set<string>& oidSet, vector<string>& uidVec)
+{
+	unsigned int i;
+	string oid, uid;
+	vector<string> prevOidQVec;		// previous oids queried
+	vector<string> notInOidSetVec;	// oid is not in oidSet
+	vector<string> defaultVec;		// vector with oids or uids to be set as default
+	map<string, int>::iterator mapIt;
+	set<string>::iterator setIt;
+
+	// Get the previous oids queried
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TeQUERIED || objStatusMap_[oid] == TePOINTED_QUERIED)
+			prevOidQVec.push_back(mapIt->first);
+	}
+
+	// Check if the previous oids queried are in the oidSet; in positive case, remove
+	// them from the oidSet; in negative case, put them in the vector notInOidSetVec
+	for (i = 0; i < prevOidQVec.size(); ++i)
+	{
+		oid = prevOidQVec[i];
+		if (oidSet.find(oid) != oidSet.end())			
+			oidSet.erase(oid);				// object is in the input oidSet
+		else
+			notInOidSetVec.push_back(oid);	// object is not in the input oidSet
+	}
+
+	// For the objects in oidSet, set the queried status for them
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+			objStatusMap_[oid] = TeQUERIED;
+		else if (objStatusMap_[oid] == TePOINTED)
+			objStatusMap_[oid] = TePOINTED_QUERIED;
+	}
+
+	// For the objects not in oidSet, insert it in oidSet, and remove their queried status
+	for (i = 0; i < notInOidSetVec.size(); ++i)
+	{
+		oid = notInOidSetVec[i];
+		if (objStatusMap_[oid] == TeQUERIED)
+			defaultVec.push_back(oid);
+		else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+			objStatusMap_[oid] = TePOINTED;
+		
+		oidSet.insert(oid);
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Remove the queried status for the uids that were previously queried
+	defaultVec.clear();
+	for (mapIt = itemStatusMap_.begin(); mapIt != itemStatusMap_.end(); ++mapIt)
+	{
+		uid = mapIt->first;
+		if (itemStatusMap_[uid] == TeQUERIED)
+			defaultVec.push_back(uid);
+		else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			itemStatusMap_[uid] = TePOINTED;			
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+
+	// Set the queried status for the input uidVec
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TeDEFAULT)
+			itemStatusMap_[uid] = TeQUERIED;
+		else if (itemStatusMap_[uid] == TePOINTED)
+			itemStatusMap_[uid] = TePOINTED_QUERIED;
+	}
+}
+
+void TeAbstractTheme::setStatusForNewObjectsPointed(set<string>& oidSet)
+{
+	unsigned int i;
+	string oid, uid;
+	set<string> prevOidPointedSet;		// previous oids pointed
+	set<string> objInInputOidSet;		// set containing objects in oidSet
+	set<string> objNotInInputOidSet;	// set containing objects not in oidSet
+	vector<string> defaultVec;		    // vector with oids or uids to be set as default
+	vector<string> uidVec;				// vector of uids
+	map<string, int>::iterator mapIt;
+	set<string>::iterator setIt;
+
+	// Get the previous oids pointed
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TePOINTED || objStatusMap_[oid] == TePOINTED_QUERIED)
+			prevOidPointedSet.insert(mapIt->first);
+	}
+
+	// If the set of objects is empty, remove the pointed status of the previous oids and uids
+	if (oidSet.empty())
+	{
+		for (setIt = prevOidPointedSet.begin(); setIt != prevOidPointedSet.end(); ++setIt)
+		{
+			oid = *setIt;
+			if (objStatusMap_[oid] == TePOINTED)
+				defaultVec.push_back(oid);
+			else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+				objStatusMap_[oid] = TeQUERIED;
+
+			oidSet.insert(oid);
+		}
+
+		for (i = 0; i < defaultVec.size(); ++i)
+			objStatusMap_.erase(defaultVec[i]);
+
+		defaultVec.clear();
+//		uidVec = getUidVec(prevOidPointedVec.begin(), prevOidPointedVec.end(), this); 
+		uidVec = getItemVector(prevOidPointedSet); 
+		for (i = 0; i < uidVec.size(); ++i)
+		{
+			uid = uidVec[i];
+			if (itemStatusMap_[uid] == TePOINTED)
+				defaultVec.push_back(uid);
+			else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+				itemStatusMap_[uid] = TeQUERIED;
+		}
+
+		for (i = 0; i < defaultVec.size(); ++i)
+			itemStatusMap_.erase(defaultVec[i]);
+
+		return;
+	}
+
+	// Check if the previous oids pointed are in the oidSet; in positive case, put
+	// them in objInOidSetVec; in negative case, put them in the objNotInOidSetVec
+	for (setIt = prevOidPointedSet.begin(); setIt != prevOidPointedSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (oidSet.find(oid) != oidSet.end())
+			objInInputOidSet.insert(oid);		// object is in the input oidSet
+		else
+			objNotInInputOidSet.insert(oid);	// object is not in the input oidSet
+	}
+
+	// For the objects in oidSet, set the pointed status for them
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+			objStatusMap_[oid] = TePOINTED;
+		else if (objStatusMap_[oid] == TeQUERIED)
+			objStatusMap_[oid] = TePOINTED_QUERIED;
+	}
+
+	// For the objects not in oidSet, remove their pointed status
+	defaultVec.clear();
+	for (setIt = objNotInInputOidSet.begin(); setIt != objNotInInputOidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TePOINTED)
+			defaultVec.push_back(oid);
+		else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+			objStatusMap_[oid] = TeQUERIED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// For the objects in oidSet, set the pointed status for their uids
+	uidVec = getItemVector(oidSet);
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TeDEFAULT)
+			itemStatusMap_[uid] = TePOINTED;
+		else if (itemStatusMap_[uid] == TeQUERIED)
+			itemStatusMap_[uid] = TePOINTED_QUERIED;
+	}
+
+	// For the objects not in oidSet, remove the pointed status for their uids
+	defaultVec.clear();
+	uidVec = getItemVector(objNotInInputOidSet);
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TePOINTED)
+			defaultVec.push_back(uid);
+		else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			itemStatusMap_[uid] = TeQUERIED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+
+	// Insert in the oidSet the objects that are not in the input oidSet
+	for (setIt = objNotInInputOidSet.begin(); setIt != objNotInInputOidSet.end(); ++setIt)
+		oidSet.insert(*setIt);
+
+	// Remove from the oidSet the objects that were in the input oidSet
+	for (setIt = objInInputOidSet.begin(); setIt != objInInputOidSet.end(); ++setIt)
+		oidSet.erase(*setIt);
+}
+
+void TeAbstractTheme::setStatusForNewItemsPointed(vector<string>& itemVec)
+{
+	unsigned int i;
+	string oid, item;
+	map<string, int>::iterator mapIt;
+	vector<string> defaultVec;
+
+	//-----------------------------------------------------------------------
+	// Set the pointing status for the input items
+	//-----------------------------------------------------------------------
+
+	// Remove the pointing status for all the items
+	for (mapIt = itemStatusMap_.begin(); mapIt != itemStatusMap_.end(); ++mapIt)
+	{
+		item = mapIt->first;
+		if (itemStatusMap_[item] == TePOINTED)
+			defaultVec.push_back(item);
+		else if (objStatusMap_[item] == TePOINTED_QUERIED)
+			itemStatusMap_[item] = TeQUERIED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+
+	for (i = 0; i < itemVec.size(); ++i)
+	{
+		item = itemVec[i];
+		if (itemStatusMap_[item] == TeDEFAULT)
+			itemStatusMap_[item] = TePOINTED;
+		else if (itemStatusMap_[item] == TeQUERIED)
+			itemStatusMap_[item] = TePOINTED_QUERIED;	
+	}
+
+	//-----------------------------------------------------------------------
+	// Set the pointing status for the objects associated to the input items
+	//-----------------------------------------------------------------------
+	
+	// Remove the pointing status for all the objects
+	defaultVec.clear();
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TePOINTED)
+			defaultVec.push_back(oid);
+		else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+			objStatusMap_[oid] = TeQUERIED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Set the pointing status for the objects associated to the input items
+	set<string> oidSet = getObjects(itemVec);
+	set<string>::iterator setIt;
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+			objStatusMap_[oid] = TePOINTED;
+		else if (objStatusMap_[oid] == TeQUERIED)
+			objStatusMap_[oid] = TePOINTED_QUERIED;	
+	}
+}
+
+
+
+void TeAbstractTheme::setStatusForObjectsAddedByPointing(set<string>& oidSet)
+{
+	if (oidSet.empty())
+		return;
+
+	unsigned int i;
+	string oid, uid;
+	vector<string> prevOidPointedVec;	// previous oids pointed
+	vector<string> uidVec;				// vector of uids
+	map<string, int>::iterator mapIt;
+	set<string>::iterator setIt;
+
+	// Get the previous oids pointed
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TePOINTED || objStatusMap_[oid] == TePOINTED_QUERIED)
+			prevOidPointedVec.push_back(mapIt->first);
+	}
+
+	// If there is any object in the oidSet that is already in the previous oids pointed,
+	// remove it from the oidSet
+	for (i = 0; i < prevOidPointedVec.size(); ++i)
+	{
+		oid = prevOidPointedVec[i];
+		if (oidSet.find(prevOidPointedVec[i]) != oidSet.end())
+			oidSet.erase(oid);
+	}
+
+	// Set the pointed status for the objects added by pointing
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+			objStatusMap_[oid] = TePOINTED;
+		if (objStatusMap_[oid] == TeQUERIED)
+			objStatusMap_[oid] = TePOINTED_QUERIED;
+	}
+
+	// Set the pointed status for the uids of the objects added by pointing
+	uidVec = getItemVector(oidSet);
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TeDEFAULT)
+			itemStatusMap_[uid] = TePOINTED;
+		else if (itemStatusMap_[uid] == TeQUERIED)
+			itemStatusMap_[uid] = TePOINTED_QUERIED;
+	}
+}
+
+void TeAbstractTheme::setStatusForItemsAddedByPointing(vector<string>& itemVec)
+{
+	unsigned int i;
+	string oid, item;
+
+	//-----------------------------------------------------------------------
+	// Set the pointing status for the input items
+	//-----------------------------------------------------------------------
+	for (i = 0; i < itemVec.size(); ++i)
+	{
+		item = itemVec[i];
+		if (itemStatusMap_[item] == TeDEFAULT)
+			itemStatusMap_[item] = TePOINTED;
+		else if (objStatusMap_[item] == TeQUERIED)
+			itemStatusMap_[item] = TePOINTED_QUERIED;
+
+	}
+
+	//-----------------------------------------------------------------------
+	// Set the pointing status for the objects associated to the input items
+	//-----------------------------------------------------------------------
+	set<string> oidSet = getObjects(itemVec);
+	set<string>::iterator setIt;
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+			objStatusMap_[oid] = TePOINTED;
+		else if (objStatusMap_[oid] == TeQUERIED)
+			objStatusMap_[oid] = TePOINTED_QUERIED;	
+	}
+}
+
+
+void TeAbstractTheme::setStatusForItemsAddedByQuerying(set<string>& oidSet, vector<string>& uidVec)
+{
+	unsigned int i;
+	string oid, uid;
+	set<string>::iterator setIt;
+
+	// Set the status for the oids in oidSet as "queried"
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+			objStatusMap_[oid] = TeQUERIED;
+		else if (objStatusMap_[oid] == TePOINTED)
+			objStatusMap_[oid] = TePOINTED_QUERIED;
+	}
+
+	// Set the new status for the uidVec
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TeDEFAULT)
+			itemStatusMap_[uid] = TeQUERIED;
+		else if (itemStatusMap_[uid] == TePOINTED)
+			itemStatusMap_[uid] = TePOINTED_QUERIED;
+	}
+}
+
+
+void TeAbstractTheme::setStatusForItemsFilteredByQuerying(set<string>& oidSet, vector<string>& uidVec)
+{
+	unsigned int i;
+	string oid, uid;
+	vector<string> prevOidQVec;		// previous oids queried
+	vector<string> notInOidSetVec;	// oid is not in oidSet
+	vector<string> defaultVec;		// vector with oids or uids to be set as default
+	map<string, int>::iterator mapIt;
+	set<string>::iterator setIt;
+
+	// Get the previous oids queried
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TeQUERIED || objStatusMap_[oid] == TePOINTED_QUERIED)
+			prevOidQVec.push_back(mapIt->first);
+	}
+
+	// Check if the previous oids queried are in the oidSet; in positive case, remove
+	// them from the oidSet; in negative case, put them in the vector notInOidSetVec
+	for (i = 0; i < prevOidQVec.size(); ++i)
+	{
+		oid = prevOidQVec[i];
+		if (oidSet.find(oid) != oidSet.end())			
+			oidSet.erase(oid);				// object is in the input oidSet
+		else
+			notInOidSetVec.push_back(oid);	// object is not in the input oidSet
+	}
+
+	// For the objects not in oidSet, insert it in oidSet, and remove their queried status
+	for (i = 0; i < notInOidSetVec.size(); ++i)
+	{
+		oid = notInOidSetVec[i];
+		if (objStatusMap_[oid] == TeQUERIED)
+			defaultVec.push_back(oid);
+		else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+			objStatusMap_[oid] = TePOINTED;
+		
+		oidSet.insert(oid);
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Remove the queried status for the uids that were previously queried
+	defaultVec.clear();
+	for (mapIt = itemStatusMap_.begin(); mapIt != itemStatusMap_.end(); ++mapIt)
+	{
+		uid = mapIt->first;
+		if (itemStatusMap_[uid] == TeQUERIED)
+			defaultVec.push_back(uid);
+		else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			itemStatusMap_[uid] = TePOINTED;			
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+
+	// Set the queried status for the input uidVec
+	for (i = 0; i < uidVec.size(); ++i)
+	{
+		uid = uidVec[i];
+		if (itemStatusMap_[uid] == TeDEFAULT)
+			itemStatusMap_[uid] = TeQUERIED;
+		else if (itemStatusMap_[uid] == TePOINTED)
+			itemStatusMap_[uid] = TePOINTED_QUERIED;
+	}
+}
+
+void TeAbstractTheme::removePointingColor()
+{
+	unsigned int i;
+	string oid, uid;
+	vector<string> defaultVec;
+	map<string, int>::iterator mapIt;
+
+	// Remove the pointed status for the objects
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TePOINTED)
+			defaultVec.push_back(oid);
+		else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+			objStatusMap_[oid] = TeQUERIED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Remove the pointed status for the uids
+	defaultVec.clear();
+	for (mapIt = itemStatusMap_.begin(); mapIt != itemStatusMap_.end(); ++mapIt)
+	{
+		uid = mapIt->first;
+		if (itemStatusMap_[uid] == TePOINTED)
+			defaultVec.push_back(uid);
+		else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			itemStatusMap_[uid] = TeQUERIED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+}
+
+
+void TeAbstractTheme::removeQueryColor()
+{
+	unsigned int i;
+	string oid, uid;
+	vector<string> defaultVec;
+	map<string, int>::iterator mapIt;
+
+	// Remove the pointed status for the objects
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TeQUERIED)
+			defaultVec.push_back(oid);
+		else if (objStatusMap_[oid] == TePOINTED_QUERIED)
+			objStatusMap_[oid] = TePOINTED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Remove the pointed status for the uids
+	defaultVec.clear();
+	for (mapIt = itemStatusMap_.begin(); mapIt != itemStatusMap_.end(); ++mapIt)
+	{
+		uid = mapIt->first;
+		if (itemStatusMap_[uid] == TeQUERIED)
+			defaultVec.push_back(uid);
+		else if (itemStatusMap_[uid] == TePOINTED_QUERIED)
+			itemStatusMap_[uid] = TePOINTED;
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+}
+
+
+void TeAbstractTheme::invertObjectStatus()
+{
+	unsigned int i;
+	string oid, uid;
+	set<string> objInvToPointedStatusSet;	// objects to be inverted to the pointed status
+	set<string> objInvToDefaultStatusSet;	// objects to be inverted to the default status
+	vector<string> defaultVec;
+	map<string, int>::iterator mapIt;
+	set<string>::const_iterator setIt;
+
+	// Get all the theme objects
+	const set<string>& oidSet = getObjects();
+
+	// Get the objects that are pointed, queried, or pointed and queried
+	// and put their status to the default status, and get the objects
+	// that are in the default status and put them in the pointed status
+	for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+	{
+		oid = *setIt;
+		if (objStatusMap_[oid] == TeDEFAULT)
+		{
+			objStatusMap_[oid] = TePOINTED;
+			objInvToPointedStatusSet.insert(oid);
+		}
+		else if (objStatusMap_[oid] == TePOINTED || objStatusMap_[oid] == TeQUERIED ||
+			     objStatusMap_[oid] == TePOINTED_QUERIED)
+		{
+			defaultVec.push_back(oid);
+			objInvToDefaultStatusSet.insert(oid);
+		}
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Set the status for the uids according the status of their objects
+	vector<string> uidVec = getItemVector(objInvToPointedStatusSet);
+	for (i = 0; i < uidVec.size(); ++i)
+		itemStatusMap_[uidVec[i]] = TePOINTED;
+
+	uidVec = getItemVector(objInvToDefaultStatusSet);
+	for (i = 0; i < uidVec.size(); ++i)
+		itemStatusMap_.erase(uidVec[i]);
+}
+
+
+void TeAbstractTheme::setObjectsToDefaultStatus()
+{
+	unsigned int i;
+	string oid, uid;
+	vector<string> defaultVec;
+	map<string, int>::iterator mapIt;
+
+	// Set the default status for objects that are pointed, queried, or pointed and queried
+	for (mapIt = objStatusMap_.begin(); mapIt != objStatusMap_.end(); ++mapIt)
+	{
+		oid = mapIt->first;
+		if (objStatusMap_[oid] == TePOINTED || objStatusMap_[oid] == TeQUERIED ||
+			objStatusMap_[oid] == TePOINTED_QUERIED)
+			defaultVec.push_back(oid);
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		objStatusMap_.erase(defaultVec[i]);
+
+	// Set the default status for uids that are pointed, queried, or pointed and queried
+	defaultVec.clear();
+	for (mapIt = itemStatusMap_.begin(); mapIt != itemStatusMap_.end(); ++mapIt)
+	{
+		uid = mapIt->first;
+		if (itemStatusMap_[uid] == TePOINTED || itemStatusMap_[uid] == TeQUERIED ||
+			itemStatusMap_[uid] == TePOINTED_QUERIED)
+			defaultVec.push_back(uid);
+	}
+
+	for (i = 0; i < defaultVec.size(); ++i)
+		itemStatusMap_.erase(defaultVec[i]);
+}
+
+
+
+
+
diff --git a/src/terralib/kernel/TeAbstractTheme.h b/src/terralib/kernel/TeAbstractTheme.h
new file mode 100644
index 0000000..ffb8308
--- /dev/null
+++ b/src/terralib/kernel/TeAbstractTheme.h
@@ -0,0 +1,673 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAbstractTheme.h
+	\brief This file contains definitions about an abstract theme in TerraLib. 
+*/
+#ifndef  __TERRALIB_INTERNAL_ABSTRACT_THEME_H
+#define  __TERRALIB_INTERNAL_ABSTRACT_THEME_H
+
+#include "TeDefines.h"
+#include "TeLegendEntry.h"
+#include "TeGeometry.h"
+#include "TeViewNode.h"
+#include "TeAttribute.h"
+
+class TeRasterTransform;
+class TeRaster;
+class TeDatabase;
+struct TeRepresentation;
+
+#include <string>
+#include <set>
+
+//! A grouping structure
+/*!
+	The TeGrouping is a structure that describes how the objects of a theme should
+	be grouped, or separated in groups.
+*/
+struct TL_DLL TeGrouping
+{
+	//! Returns the attribute used to group the objects of the theme
+	TeAttributeRep	groupAttribute_;
+	
+	//! Returns the attribute used to normalize a grouping 
+	string	groupNormAttribute_;
+	
+	//! Returns the grouping mode 
+	TeGroupingMode	groupMode_;			
+	
+	//! Returns the number of groups
+	int	groupNumSlices_;	
+	
+	//! Returns the numeric precision used to group objects
+	int	groupPrecision_;
+
+	//! Returns the deviation parameter used to group objects
+	double	groupStdDev_;
+
+	//! Aggregate function
+	string	groupFunction_; 
+
+	//! Show missing data
+	bool	groupNullAttr_; 
+
+	//! Minimum value used to calculate a equal step grouping
+	double groupMinVal_;
+
+	//! Maximum value used to calculate a equal step grouping 
+	double groupMaxVal_;
+
+	//! Chronon used for grouping
+	TeChronon groupChronon_;
+
+	//! Constructor
+	TeGrouping(TeAttributeRep att=TeAttributeRep(), const string& normAttr="", 
+				TeGroupingMode gMode=TeNoGrouping, int numSlice=0, int gPrecision=6,  
+				double	gStDev=1.0, const string& func="", TeChronon gChronon = TeNOCHRONON): 
+			groupAttribute_(att),
+			groupNormAttribute_(normAttr),
+			groupMode_(gMode),
+			groupNumSlices_(numSlice),
+			groupPrecision_(gPrecision),
+			groupStdDev_(gStDev),
+			groupFunction_(func),
+			groupNullAttr_(false),
+			groupMinVal_(TeMAXFLOAT),
+			groupMaxVal_(TeMINFLOAT),
+			groupChronon_(gChronon)
+			{}
+
+	//! Copy constructor
+	TeGrouping(const TeGrouping& other)
+	{	
+		groupAttribute_		= other.groupAttribute_;
+		groupNormAttribute_	= other.groupNormAttribute_;
+		groupMode_			= other.groupMode_;
+		groupNumSlices_		= other.groupNumSlices_;
+		groupPrecision_		= other.groupPrecision_;
+		groupStdDev_		= other.groupStdDev_;
+		groupFunction_		= other.groupFunction_;
+		groupNullAttr_		= other.groupNullAttr_;
+		groupMinVal_		= other.groupMinVal_;
+		groupMaxVal_		= other.groupMaxVal_;
+		groupChronon_			= other.groupChronon_;
+	}
+			
+	//! Destructor
+	~TeGrouping() {}
+	
+	//! Copy constructor
+	TeGrouping& operator= (const TeGrouping& other)
+	{	
+		if ( this != &other )
+		{		
+			groupAttribute_		= other.groupAttribute_;
+			groupNormAttribute_	= other.groupNormAttribute_;
+			groupMode_			= other.groupMode_;
+			groupNumSlices_		= other.groupNumSlices_;
+			groupPrecision_		= other.groupPrecision_;
+			groupStdDev_		= other.groupStdDev_;
+			groupFunction_		= other.groupFunction_;
+			groupNullAttr_		= other.groupNullAttr_;
+			groupNullAttr_		= other.groupNullAttr_;
+			groupMinVal_		= other.groupMinVal_;
+			groupMaxVal_		= other.groupMaxVal_;
+			groupChronon_		= other.groupChronon_;
+		}
+		return *this;
+	}
+};
+
+using namespace std;
+
+
+//! An abstract theme class
+class TL_DLL TeAbstractTheme: public TeViewNode
+{
+
+	friend class TeDatabase;
+	
+public:
+	//! Constructor
+    TeAbstractTheme(const string& name, TeViewNode* parent, const int& view, const int& id, const TeViewNodeType& nodeType);
+
+	//! Constructor
+	TeAbstractTheme(const TeViewNodeParams& params);
+
+	//! Copy constructor
+	TeAbstractTheme(const TeAbstractTheme& other);
+
+	//! Destructor
+	virtual ~TeAbstractTheme();
+
+	//! Assignment operator
+	TeAbstractTheme& operator= (const TeAbstractTheme& other); 
+
+	/** @name Scale
+		Methods related to the range of scales where this theme should be visible
+	*/
+	//@{	
+
+	//! Returns a pointer to a projection that is the spatial reference for the objects of this theme
+	/*! Concrete classes should reimplement this method.*/
+	virtual TeProjection* getThemeProjection() = 0;
+
+	//! Returns the minimum scale in which the theme is visible
+	virtual double minScale() { return minScale_; }
+
+	//! Sets the minimum scale in which the theme is visible
+	virtual void minScale(double s) { minScale_ = s; }
+
+	//! Returns the maximum scale in which the theme is visible
+	virtual double maxScale() { return maxScale_; }
+
+	//! Sets the maximum scale in which the theme is visible
+	virtual void maxScale(double s) { maxScale_ = s; }
+	//@}
+
+	/** @name Restrictions
+		Methods related to the restrictions over the theme used to generate this theme
+	*/
+	//@{
+	//! Verifies if this theme has any kind of restrictions
+	virtual bool hasRestriction() { return (!(generateAttributeRest_.empty() || 
+									  generateTemporalRest_.empty()) && hasSpatialRes_); }
+
+	//! Returns the attribute restriction (where clause) used to generate the theme  
+	virtual string attributeRest() { return generateAttributeRest_; }
+
+	//! Sets the attribute restriction (where clause) used to generate the theme
+	virtual void attributeRest(const string& s) { generateAttributeRest_ = s; }
+
+	//! Returns if there is an attribute restriction  
+	virtual bool hasAttrRest () { return (!generateAttributeRest_.empty());}
+
+	//! Returns the temporal restriction used to generate the theme
+	virtual string temporalRest() { return generateTemporalRest_; }
+
+	//! Sets the temporal restriction used to generate the theme
+	virtual void temporalRest(const string& t) { generateTemporalRest_ = t; };
+
+	//! Returns TRUE if there is a temporal restriction defined in the theme 
+	virtual bool hasTemporalRest() { return (!generateTemporalRest_.empty());}
+
+	//! Returns the spatial restriction used to generate the theme
+	virtual string spatialRest() { return generateSpatialRest_; }
+
+	//! Sets the spatial restriction used to generate the theme
+	virtual void spatialRest(const string& s) { generateSpatialRest_ = s; };
+	
+	//! Returns the spatial relation (e.g WITHIN, COVERED BY, etc.) associate to the spatial restriction
+	virtual TeSpatialRelation	spatialRelation() { return spatialRelation_;}
+
+	//! Sets the spatial relation (e.g WITHIN, COVERED BY, etc.) associate to the spatial restriction
+	virtual void spatialRelation(TeSpatialRelation s) {spatialRelation_=s;}
+	
+	//! Returns TRUE if this theme has a spatial restriction  
+	virtual bool hasSpatialRest() { return hasSpatialRes_;}
+
+	//! Sets the flag that indicates that there is a spatial restriction 
+	virtual void hasSpatialRest(bool a) {hasSpatialRes_ = a;}
+	
+	//! Returns the box associated with the spatial restriction
+	virtual TeBox boxRestriction() { return boxRest_;}
+
+	//! Sets the box associated with the spatial restriction
+	virtual void boxRestriction(TeBox& b) {boxRest_ = b;}
+
+	//! Returns a pointer to the geometry associated with the spatial restriction
+	virtual TeGeometry* geomRestriction() { return geomRest_;}
+
+	//! Sets a pointer to the geometry associated with the spatial restriction
+	virtual void geomRestriction(TeGeometry* g) {geomRest_ = g;}
+
+	//! Returns the geometry representation of the theme which will be considered in the spatial restriction  
+	virtual TeGeomRep geomRepRestriction() { return geomRepRest_; }
+
+	//! Sets the geometry representation of the theme which will be considered in the spatial restriction  
+	virtual void geomRepRestriction (TeGeomRep& rep) { geomRepRest_ = rep; }
+
+	//! Sets the spatial restriction to be a spatial relation with a box
+	virtual void setSpatialRest(TeBox& box, TeGeomRep rep, TeSpatialRelation relation = TeWITHIN); 
+
+	//! Sets the spatial restriction to be a spatial relation with a geometry
+	virtual void setSpatialRest(TeGeometry* geom, TeGeomRep rep, TeSpatialRelation relation = TeWITHIN); 
+	//@}
+	
+	
+	/** @name Visibility/Status
+		Methods related to the visibility/status of the theme and its components: graphs,
+		geometrical representations of the objects, grouping.
+	*/
+	//@{
+	//! Sets the components or representations of the theme that are visible
+	/*!
+		The param rep is a combination of any type of geometrical representation (TeGeomRep) plus:
+		- 0x20000000: representing the visibility of the legend
+		- 0x40000000: representing the visibility of the groupings
+		- 0x80000000: representing the visibility of the pie/chart graphs
+	*/
+	virtual void visibleRep(int rep) { visibleRep_ = rep; }
+
+	//! Returns the components or representations of the theme that are visible 
+	/*!
+		The result is a combination of any type of geometrical representation (TeGeomRep) plus:
+		- 0x20000000: representing the visibility of the legend
+		- 0x40000000: representing the visibility of the groupings
+		- 0x80000000: representing the visibility of the pie/chart graphs
+	*/
+	virtual int visibleRep() { return visibleRep_; }
+
+	//! Returns the geometrical representations of the theme that are visible
+	virtual int visibleGeoRep();
+
+	//! Returns a status of a theme
+	/*! 
+		- Returns 0 if the theme is not visible and not active
+		- Returns 1 if the theme is visible and not active
+		- Returns 2 if theme is and active and not visible
+		- Returns 3 if theme is and visible and active
+	 */
+	virtual int visibility()
+	{	return enableVisibility_; }
+
+	//! Sets whether the theme should be visible and/or active
+	/*! 
+		- Returns 0 if the theme is not visible and not active
+		- Returns 1 if the theme is visible and not active
+		- Returns 2 if theme is and active and not visible
+		- Returns 3 if theme is and visible and active
+	 */
+	virtual void visibility(int v)
+	{	enableVisibility_ = v; }
+	//@}
+	
+	/** @name Grouping
+		Methods related to grouping of objects of the theme. Each group is
+		represented by a specific presentation visual called legend. An slice
+		represents the range of values of an attribute that characterizes a group.
+	*/
+	//@{
+	//! Returns a grouping associated the theme 
+	virtual TeGrouping& grouping() { return grouping_; }
+	
+	//! Sets a grouping associated to the theme
+	virtual void grouping(const TeGrouping& g) 
+	{ grouping_ = g; }
+
+	//! Returns the vector of legends of the theme
+	virtual TeLegendEntryVector& legend() { return legend_; }
+
+	//! Sets the visual associated to a geometric representation in the n-th group of the theme 
+	virtual bool setGroupingVisual(int n, TeVisual* visual, TeGeomRep rep);
+
+	//! Sets the visual of the n-th group of the theme
+	virtual bool setGroupingVisual(int n, TeGeomRepVisualMap& vismap);
+
+	//! Clear the existing grouping of objects of this theme
+	virtual void resetGrouping ();
+
+	//! Clear the vector of legends
+	virtual void cleanLegend(); 
+
+	//! Save grouping parameters in memory passing an arbitrary set of slices
+	virtual bool buildGrouping(const TeGrouping& g, vector<TeSlice>& slices);
+
+	//! Returns the slices associated to the grouping of the theme
+	virtual TeSliceVector getSlices();
+	//@}
+
+	/** @name Legends
+		Legends are also used to define presentation characteristics of the objets
+		of the theme that aren't grouped, according to some specific characteristics
+		(such as being pointed, being queried, among others).
+	*/
+	//@{	
+	//! Sets a default legend of the objects of the theme
+	virtual void defaultLegend (TeLegendEntry& leg) 
+	{ defaultLegend_ = leg; }
+
+	//! Returns the default legend of the objects of the theme
+	virtual TeLegendEntry& defaultLegend () 
+	{ return defaultLegend_; }
+
+	//! Sets the visual of the default legend for a specific geometrical representation
+	virtual void setVisualDefault (TeVisual* visual, TeGeomRep rep)
+	{ defaultLegend_.setVisual(visual, rep); }
+
+	//! Sets a legend for objects of the layer that weren't selected in this theme
+	/*! Useful when is necessary to see the theme in the context of the layer */
+	virtual void outOfCollectionLegend (TeLegendEntry &leg) 
+	{ outOfCollectionLegend_ = leg;}
+
+	//! Returns the legend of the layer objects that are not selected in this layer.
+	virtual TeLegendEntry& outOfCollectionLegend () 
+	{ return outOfCollectionLegend_; } 
+	
+	//! Sets the visual of the non-selected objects legend for a specific geometrical representation
+	virtual void setVisualOutOfCollection (TeVisual* visual, TeGeomRep rep)
+	{ outOfCollectionLegend_.setVisual(visual, rep); }
+
+	//! Sets a legend for objects that have geometries but not descriptive attributes
+	/*! Useful when in intermediary situations such as editing */
+	virtual void withoutDataConnectionLegend (TeLegendEntry &leg) 
+	{ withoutDataConnectionLegend_ = leg; }
+
+	//! Returns the legend of objects that have geometries but not descriptive attributes
+	virtual TeLegendEntry& withoutDataConnectionLegend () 
+	{ return withoutDataConnectionLegend_; }
+
+	//! Sets the visual of the without-attributes objects legend for a specific geometrical representation
+	virtual void setVisualWithoutDataConnection (TeVisual* visual, TeGeomRep rep)
+	{ withoutDataConnectionLegend_.setVisual(visual, rep); }
+	
+	//! Sets a legend for the theme objects selected by pointing
+	virtual void pointingLegend (TeLegendEntry &leg) 
+	{ pointingLegend_ = leg; }
+
+	//! Returns the legend of the theme objects selected by pointing
+	virtual TeLegendEntry& pointingLegend () 
+	{ return pointingLegend_; }
+
+	//! Sets the visual of the pointed objects legend for a specific geometrical representation
+	virtual void setVisualPointing (TeVisual* visual, TeGeomRep rep)
+	{ pointingLegend_.setVisual(visual, rep); }
+
+	//! Sets a legend for the theme objects selected by a query
+	virtual void queryLegend (TeLegendEntry &leg) 
+	{ queryLegend_ = leg; }
+
+	//! Returns the legend of the theme objects selected by a query
+	virtual TeLegendEntry& queryLegend () 
+	{ return queryLegend_; }
+	
+	//! Sets the visual of the queried objects legend for a specific geometrical representation
+	virtual void setVisualQuery (TeVisual* visual, TeGeomRep rep)
+	{ queryLegend_.setVisual(visual, rep); }
+
+	//! Sets a legend for the theme objects selected by query and pointing
+	virtual void queryAndPointingLegend (TeLegendEntry &leg) 
+	{ queryAndPointingLegend_ = leg; }
+
+	//! Returns the legend of the theme objects selected by query and pointing
+	virtual TeLegendEntry& queryAndPointingLegend () 
+	{ return queryAndPointingLegend_; }
+
+    //! Returns the map of legend ids associated to each object
+	virtual map<string, int>& getObjLegendMap() 
+	{ return objLegendMap_; }
+
+	//! Returns the map of legend ids associated to each object
+	virtual map<string, int>& getObjOwnLegendMap() 
+	{ return objOwnLegendMap_; }
+
+	//! Sets the visual of the queried and pointed objects legend for a specific geometrical representation
+	virtual void setVisualQueryAndPointing (TeVisual* visual, TeGeomRep rep)
+	{ queryAndPointingLegend_.setVisual(visual, rep); }
+
+	//! Sets a legend for the theme objects
+	virtual void legend(TeLegendEntry& leg); 
+
+	/** @name Raster Visual
+	*  Methods to deal with the visual presentation of the raster representations
+	*/
+	//@{ 
+	//! Returns the visual presentation of raster geometry
+	virtual TeRasterTransform* rasterVisual() 
+	{ return rasterVisual_; }
+
+	//! Sets the visual presentation of raster geometry
+	virtual void rasterVisual(TeRasterTransform* r) 
+	{ rasterVisual_ = r; } 
+
+	//! Removes the visual presentation of the raster
+	virtual void removeRasterVisual();
+
+	//! Creates an appropriate visual presentation to the raster of the theme
+	virtual void createRasterVisual(TeRaster* rst=0);
+	//@}
+	//@}
+
+	/** @name Box
+	    Methods related to the bounding box of a theme
+	*/
+	//@{ 
+	//! Returns the theme box 
+	virtual TeBox& getThemeBox()
+	{	return themeBox_; }
+
+	//! Sets the theme box 
+	virtual void setThemeBox(const TeBox& box)
+	{	themeBox_ = box; }
+
+	//! Returns the theme box 
+	virtual TeBox& box()
+	{	return themeBox_; }
+	//@}
+
+	//! Sets the parent node. The abstract theme does not have parent node.
+	virtual void setParent (TeViewNode* );
+	
+	//! Returns TRUE if a theme has lower priority than another
+	virtual bool operator< (const TeAbstractTheme& r) const
+	{	return viewNodeParams_.priority_ < r.viewNodeParams_.priority_; }
+
+	//! Clear the set containing the objects of the theme
+	virtual void clearObjectSet()
+	{ objectSet_.clear(); }
+
+	//! Return the number of objects of the layer
+	virtual int getNumLayerObjects()
+	{ return numLayerObjects_; }
+
+	//! Return the map containing the status of the objects
+	virtual map<string, int>& getObjStatusMap()
+	{ return objStatusMap_; }
+
+	//! Set the status of the objects to the default state
+	virtual void clearObjStatus()
+	{ objStatusMap_.clear(); }
+
+	//! Set the status of the items to the default state
+	virtual void clearItemStatus()
+	{ itemStatusMap_.clear(); }
+
+	//! Return the map containing the status of the items
+	virtual map<string, int>& getItemStatusMap()
+	{ return itemStatusMap_; }
+
+	//! the status
+	virtual void setStatus(vector<string>& oidVec, vector<string>& itemVec, int status);
+
+	//! the status for the items that were toggled
+	virtual void setStatusForItemsToggled(set<string>& oidSet, vector<string>& itemVec);
+
+	//! Set the status for the objects that were toggled
+	virtual void setStatusForObjectToggled(string oid);
+
+	//! Set the status for the new set of objects that were pointed
+	virtual void setStatusForNewObjectsPointed(set<string>& oidSet);
+
+	//! Set the status for the additional set of objects that were pointed
+	virtual void setStatusForObjectsAddedByPointing(set<string>& oidSet);
+
+	//! Set the status for the new set of items that were pointed
+	virtual void setStatusForNewItemsPointed(vector<string>& itemVec);
+
+	//! Set the status for the additional set of items that were pointed
+	virtual void setStatusForItemsAddedByPointing(vector<string>& itemVec);
+
+	//! Set the status for the new set of items that were queried
+	virtual void setStatusForNewItemsQueried(set<string>& oidSet, vector<string>& uidVec);
+
+	//! Set the status for the additional set of items that were queried
+	virtual void setStatusForItemsAddedByQuerying(set<string>& oidSet, vector<string>& uidVec);
+
+	//! Set the status for the set of items that were filtered by a query operation
+	virtual void setStatusForItemsFilteredByQuerying(set<string>& oidSet, vector<string>& uidVec);
+
+	//! Remove the pointing color
+	virtual void removePointingColor();
+
+	//! Remove the query color
+	virtual void removeQueryColor();
+
+	//! Invert the pointing status of the objects
+	virtual void invertObjectStatus();
+
+	//! Set the objects to the default status
+	virtual void setObjectsToDefaultStatus();
+
+	//! Save the theme parameters
+	virtual bool save() = 0;
+
+	//! Save the grouping parameters in memory when there is no chronon
+	virtual bool buildGrouping(const TeGrouping& g, TeSelectedObjects selectedObjects = TeAll,
+		               vector<double>* dValuesVec = 0) = 0;
+
+	//! Save the grouping parameters in memory when there is chronon
+	virtual bool buildGrouping(const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec) = 0;
+	
+	
+	//! Build the grouping and associate each object to its group  
+	virtual bool saveGrouping(TeSelectedObjects selectedObjects = TeAll) = 0;
+
+	//! Delete grouping
+	virtual bool deleteGrouping() = 0; 
+
+	//! Set the legend id for each object of the theme 
+	virtual void setLegendsForObjects() = 0;
+
+	//! Set the own legend id for each object of the theme 
+	virtual void setOwnLegendsForObjects() = 0;
+
+	/** @name Locate geometries
+	    Returns the geometry(ies) of the theme given coordinate
+	*/
+	//@{ 	
+	virtual bool locatePolygon		(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0) = 0;
+	virtual bool locatePolygonSet   (TeCoord2D &pt, double tol, TePolygonSet &polygons) = 0;
+	virtual bool locateLine		(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0) = 0;
+	virtual bool locatePoint	(TeCoord2D &pt, TePoint &point, const double& tol = 0.0) = 0;
+	virtual bool locateCell		(TeCoord2D &pt, TeCell &c, const double& tol = 0.0) = 0;
+	//@}
+
+	//! Get the set of objects corresponding to the object selection criteria
+	virtual set<string> getObjects(TeSelectedObjects selectedObjects = TeAll) = 0;
+
+	//! Get the set of objects corresponding to the list of items
+	virtual set<string> getObjects(const vector<string>& itemVec) = 0;
+
+	//! Get the set of items corresponding to the object selection criteria
+	virtual vector<string> getItemVector(TeSelectedObjects selectedObjects) = 0;
+
+	//! Get the set of items corresponding to the set of objects
+	virtual vector<string> getItemVector(const set<string>& oidSet) = 0;
+
+	//! Get the number of objects acessible by this theme
+	virtual unsigned int getNumberOfObjects()=0; 
+
+	//! Save (insert or update) the theme metadata in the database
+	virtual bool saveMetadata(TeDatabase* ) = 0;
+	
+protected:
+	string		generateAttributeRest_;
+	string		generateTemporalRest_;
+	string		generateSpatialRest_; //future use
+
+	TeSpatialRelation	spatialRelation_;
+	bool				hasSpatialRes_;
+	TeBox				boxRest_;		//box which defines the spatial restriction 
+	TeGeometry*			geomRest_;		//geometry which defines the spatial restriction 
+	TeGeomRep			geomRepRest_;	//geometry representation of the theme which will be 
+										//considered in the spatial restriction  
+	// Display scale
+	double	minScale_;
+	double	maxScale_;
+
+	//representation visible in the theme
+	int visibleRep_;
+
+	//Theme status
+	int	enableVisibility_;
+
+	// ----------------- grouping information -----------------
+	TeGrouping		grouping_;
+
+	// ----------------- legend information -----------------
+	TeLegendEntryVector	legend_;
+
+	// Background Legend
+	TeLegendEntry		outOfCollectionLegend_;			//group(-1) 
+	TeLegendEntry		withoutDataConnectionLegend_;	//group(-2) 
+	TeLegendEntry		defaultLegend_;					//group(-3) 
+	TeLegendEntry		pointingLegend_;				//group(-4) 
+	TeLegendEntry		queryLegend_;					//group(-5) 
+	TeLegendEntry		queryAndPointingLegend_;		//group(-6)
+
+	map<string, int>	objLegendMap_;					// object legend
+	map<string, int>	objOwnLegendMap_;				// object own legend
+		
+	//! visual of raster
+	TeRasterTransform*	rasterVisual_;
+	
+	TeBox	themeBox_;
+
+	//! A set containing the theme objects
+	set<string> objectSet_;
+
+	//! Number of objects of the layer
+	int numLayerObjects_;
+
+	//! Status of the item (concatenation of the unique names of each theme table)
+	map<string, int> itemStatusMap_;
+
+	//! Status of the object
+	map<string, int> objStatusMap_;
+
+	//! Load the theme metadata from database
+	virtual bool loadMetadata(TeDatabase* ) = 0;
+
+	//! Erase the theme metadata in the database
+	virtual bool eraseMetadata(TeDatabase* ) = 0;
+};
+
+//! A vector of pointers to theme
+typedef vector<TeAbstractTheme*>	TeThemeVector;
+
+//! A map from theme identifiers to pointers to theme
+typedef map<int, TeAbstractTheme*>	TeThemeMap;
+
+/*! \example creaTeAbstractTheme.cpp
+	Shows how to create themes in TerraLib.
+ */
+
+/*! \example themeGrouping.cpp
+	Shows how to do a grouping on the objects of a TerraLib theme.
+ */
+
+/*! \example rasterSlicing.cpp
+	Shows how to  create a legend over a raster data, stored in a layer TerraLib.
+ */
+#endif
+
diff --git a/src/terralib/kernel/TeAffineGT.cpp b/src/terralib/kernel/TeAffineGT.cpp
new file mode 100644
index 0000000..7fcac17
--- /dev/null
+++ b/src/terralib/kernel/TeAffineGT.cpp
@@ -0,0 +1,211 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeAffineGT.h"
+
+#include "TeAgnostic.h"
+
+
+TeAffineGT::TeAffineGT()
+{
+}
+
+
+TeAffineGT::~TeAffineGT()
+{
+}
+
+
+void TeAffineGT::directMap( const TeGTParams& params, const TeCoord2D& pt1, 
+  TeCoord2D& pt2 ) const
+{
+  TEAGN_DEBUG_CONDITION( ( params.direct_parameters_.Ncol() == 3 ),
+    "Invalid number of columns" )
+  TEAGN_DEBUG_CONDITION( ( params.direct_parameters_.Nrow() == 3 ),
+    "Invalid number of rows" )
+  
+  double x = pt1.x();
+  double y = pt1.y();
+
+  pt2.x( params.direct_parameters_(0,0) * x + 
+         params.direct_parameters_(0,1) * y + 
+         params.direct_parameters_(0,2) );
+  pt2.y( params.direct_parameters_(1,0) * x + 
+         params.direct_parameters_(1,1) * y + 
+         params.direct_parameters_(1,2) );  
+}
+
+
+void TeAffineGT::inverseMap( const TeGTParams& params, const TeCoord2D& pt2, 
+  TeCoord2D& pt1 ) const
+{
+  TEAGN_DEBUG_CONDITION( ( params.inverse_parameters_.Ncol() == 3 ),
+    "Invalid number of columns" )
+  TEAGN_DEBUG_CONDITION( ( params.inverse_parameters_.Nrow() == 3 ),
+    "Invalid number of rows" )
+
+  double u = pt2.x();
+  double v = pt2.y();
+  
+  pt1.x( params.inverse_parameters_(0,0) * u +
+         params.inverse_parameters_(0,1) * v + 
+         params.inverse_parameters_(0,2) );
+  pt1.y( params.inverse_parameters_(1,0) * u + 
+         params.inverse_parameters_(1,1) * v + 
+         params.inverse_parameters_(1,2) );  
+}
+
+
+unsigned int TeAffineGT::getMinRequiredTiePoints() const
+{
+  return 3;
+}
+
+
+bool TeAffineGT::computeParameters( TeGTParams& params )
+{
+    /*
+            u = a1.x + a2.y + a3
+            v = b1.x + b2.y + b3
+
+            A . X + L = 0
+            N = At . A
+            U = At . L
+            X = - (N ^ -1) . U
+
+            A = |x1 y1 1  0  0  0|     Xt = |a1 a2 a3 b1 b2 b3|
+                |0  0  0  x1 y1 1|
+                |x2 y2 1  0  0  0|
+                |0  0  0  x2 y2 1|     Lt = |u1 v1 u2 v2 ... un vn|
+                |.  .  .  .  .  .|
+                |xn yn 1  0  0  0|
+                |0  0  0  xn yn 1|
+
+    */
+
+  const unsigned int tiepoints_size = params.tiepoints_.size();
+  TEAGN_DEBUG_CONDITION( ( tiepoints_size > 2 ),
+    "Invalid tie-points size" )
+
+  TeMatrix A;
+  if( ! A.Init( 2*tiepoints_size, 6 ) ) {
+    return false;
+  }
+    
+  TeMatrix L;
+  if( ! L.Init( 2*tiepoints_size, 1 ) ) {
+    return false;
+  }
+
+  TeMatrix At;
+  TeMatrix N;
+  TeMatrix U;
+  TeMatrix X;
+  TeMatrix N_inv;
+
+  std::vector< TeCoordPair >::const_iterator iterator;
+
+  TeCoord2D x_y;
+  TeCoord2D u_v;
+  double x = 0;
+  double y = 0;
+  
+  /* L calcule */
+
+  iterator = params.tiepoints_.begin() ;
+  for ( unsigned int L_block_offset = 0 ; ( L_block_offset < tiepoints_size ); 
+    ++L_block_offset ) {
+    
+    u_v = iterator->pt2;
+    
+    L( L_block_offset*2     , 0) = u_v.x();
+    L( L_block_offset*2 + 1 , 0) = u_v.y();
+    
+    ++iterator ;
+  }
+  
+  /* A calcule */
+
+  iterator = params.tiepoints_.begin();
+  for ( unsigned int A_block_offset = 0 ; (A_block_offset < tiepoints_size) ; 
+        ++A_block_offset) {
+        
+    x_y = iterator->pt1;    
+    x = x_y.x();
+    y = x_y.y();
+    
+    A( A_block_offset*2  , 0 ) = x ;
+    A( A_block_offset*2  , 1 ) = y ;
+    A( A_block_offset*2  , 2 ) = 1 ;
+    A( A_block_offset*2  , 3 ) = 0 ;
+    A( A_block_offset*2  , 4 ) = 0 ;
+    A( A_block_offset*2  , 5 ) = 0 ;
+    A( A_block_offset*2+1, 0 ) = 0 ;
+    A( A_block_offset*2+1, 1 ) = 0 ;
+    A( A_block_offset*2+1, 2 ) = 0 ;
+    A( A_block_offset*2+1, 3 ) = x ;
+    A( A_block_offset*2+1, 4 ) = y ;
+    A( A_block_offset*2+1, 5 ) = 1 ; 
+    
+    ++iterator;
+  }
+
+  /* At calcule */
+  A.Transpose( At );
+
+  /* N calcule */
+  N = At * A;
+
+  /* U calcule */
+  U = At * L;
+
+  /* N_inv calcule */
+  if ( N.Inverse( N_inv ) ) {
+    /* X calcule */
+
+    X = N_inv * U;
+    
+    if( ! params.direct_parameters_.Init( 3, 3 ) ) {
+      return false;
+    }    
+
+    params.direct_parameters_(0,0) = X(0,0);
+    params.direct_parameters_(0,1) = X(1,0);
+    params.direct_parameters_(0,2) = X(2,0);
+    params.direct_parameters_(1,0) = X(3,0);
+    params.direct_parameters_(1,1) = X(4,0);
+    params.direct_parameters_(1,2) = X(5,0);
+    params.direct_parameters_(2,0) = 0;
+    params.direct_parameters_(2,1) = 0;
+    params.direct_parameters_(2,2) = 1;
+
+    if( params.direct_parameters_.Inverse( params.inverse_parameters_ ) ) {
+      return true;
+    } else {
+      return false;
+    }
+  } else {
+    return false;   
+  }
+}
+
diff --git a/src/terralib/kernel/TeAffineGT.h b/src/terralib/kernel/TeAffineGT.h
new file mode 100644
index 0000000..a86dcea
--- /dev/null
+++ b/src/terralib/kernel/TeAffineGT.h
@@ -0,0 +1,94 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAffineGT.h
+   \brief Affine geometric trasformation.
+*/
+
+
+#ifndef TEAFFINEGT_H
+  #define TEAFFINEGT_H
+  
+  #include "TeDefines.h"
+  #include <TeGeometricTransformation.h>
+
+  /**
+   * @brief This is the class to deal affine geometric trasformation.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  class TL_DLL TeAffineGT : public TeGeometricTransformation {
+    public :
+
+      /**
+       * @brief Default Constructor.
+       */
+      TeAffineGT();
+    
+      /**
+       * @brief Default Destructor
+       */
+      ~TeAffineGT();
+      
+      /**
+       * @brief Returns the minimum number of required tie-points for the current
+       * transformation.
+       *
+       * @return The minimum number of required tie-points for the current
+       * transformation.
+       */       
+      unsigned int getMinRequiredTiePoints() const;      
+      
+    protected :
+    
+      /**
+       * @brief Direct mapping ( from pt1 space into pt2 space ).
+       *
+       * @param params Transformation parameters.
+       * @param pt1 pt1 coordinate.
+       * @param pt2 pt2 coordinate.
+       */      
+      void directMap( const TeGTParams& params, const TeCoord2D& pt1, 
+        TeCoord2D& pt2 ) const;
+      
+      /**
+       * @brief Inverse mapping ( from pt2 space into pt1 space ).
+       *
+       * @param params Transformation parameters.
+       * @param pt2 pt2 coordinate.
+       * @param pt1 pt1 coordinate.
+       */      
+      void inverseMap( const TeGTParams& params, const TeCoord2D& pt2, 
+        TeCoord2D& pt1 ) const;      
+      
+      /**
+       * @brief Calculate the transformation parameters following the
+       * new supplied tie-points.
+       *
+       * @param params Transformation parameters.
+       * @return true if OK, false on errors.
+       */       
+      bool computeParameters( TeGTParams& params );
+  };
+  
+#endif
+
diff --git a/src/terralib/kernel/TeAffineGTFactory.cpp b/src/terralib/kernel/TeAffineGTFactory.cpp
new file mode 100644
index 0000000..49e8fd9
--- /dev/null
+++ b/src/terralib/kernel/TeAffineGTFactory.cpp
@@ -0,0 +1,48 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeAffineGTFactory.h"
+#include <TeAffineGT.h>
+#include <TeException.h>
+
+TeAffineGTFactory::TeAffineGTFactory()
+: TeGTFactory( std::string( "affine" ) )
+{
+};      
+
+TeAffineGTFactory::~TeAffineGTFactory()
+{
+};
+
+
+TeGeometricTransformation* TeAffineGTFactory::build ( 
+  const TeGTParams& )
+{
+  TeGeometricTransformation* instance_ptr = new TeAffineGT();
+  
+  if( ! instance_ptr ) {
+    throw TeException( FACTORY_PRODUCT_INSTATIATION_ERROR );
+  }
+  
+  return instance_ptr;
+}
diff --git a/src/terralib/kernel/TeAffineGTFactory.h b/src/terralib/kernel/TeAffineGTFactory.h
new file mode 100644
index 0000000..9b0547b
--- /dev/null
+++ b/src/terralib/kernel/TeAffineGTFactory.h
@@ -0,0 +1,71 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAffineGTFactory.h
+    \brief This file contains the affine geometric trasformation factory
+*/
+
+#ifndef TEAFFINEGTFACTORY_H
+  #define TEAFFINEGTFACTORY_H
+  
+  #include "TeDefines.h"
+  #include <TeGTFactory.h>
+
+  /**
+   * @brief This is the affine geometric trasformation factory.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  class TL_DLL TeAffineGTFactory : public TeGTFactory
+  {
+    public :
+      
+      /**
+       * @brief Default constructor
+       */
+      TeAffineGTFactory();      
+      
+      /**
+       * @brief Default Destructor
+       */
+      ~TeAffineGTFactory();
+      
+    protected :  
+    
+      /**
+       * @brief Implementation for the abstract TeFactory::build.
+       *
+       * @param arg A const reference to the used parameters.
+       * @return A pointer to the new generated instance.
+       */
+      TeGeometricTransformation* build( const TeGTParams& arg );
+      
+  };
+
+  namespace
+  {  
+    /** @brief A concrete factory instance for registering into the factory dictionary */
+    static TeAffineGTFactory TeAffineGTFactory_instance;
+  };
+  
+#endif
+
diff --git a/src/terralib/kernel/TeAgnostic.cpp b/src/terralib/kernel/TeAgnostic.cpp
new file mode 100644
index 0000000..76bcb8e
--- /dev/null
+++ b/src/terralib/kernel/TeAgnostic.cpp
@@ -0,0 +1,14 @@
+#include "TeAgnostic.h"
+
+namespace TeAgnostic{
+
+  bool debugModeCheck()
+  {
+    #ifdef TEAGN_DEBUG_MODE
+      return true;
+    #else
+      return false;
+    #endif
+  }
+
+};
diff --git a/src/terralib/kernel/TeAgnostic.h b/src/terralib/kernel/TeAgnostic.h
new file mode 100644
index 0000000..7b171a8
--- /dev/null
+++ b/src/terralib/kernel/TeAgnostic.h
@@ -0,0 +1,395 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+/**
+ * @file TeAgnostic.h
+ * @brief This file contains a set of macros, routines and classes to deal with
+ * system checking and logging facility.
+ * They should NOT be used by anyone because the support and interfaces 
+ * can be changed in future. THIS IS FOR INTERNAL USE ONLY.
+ * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+ *
+ * @note The following macros will be used:
+ * 
+ * @param TEAGN_DEBUG_MODE If defined, debug code macros will be compiled and
+ * used or if not defined the compiler debug flag will be used.
+ * @param TEAGN_ENABLE_STDOUT_LOG If defined, messages also will be logged
+ * to STDOUT ( otherwise only TeErrorLog will log messages )
+ * or if not defined the compiler debug flag will be used.
+ */
+
+#ifndef TEAGNOSTIC_H
+  #define TEAGNOSTIC_H
+
+  #include <sstream>
+  #include <string>
+  #include <iostream>
+  
+  #include <TeException.h>
+  #include <TeErrorLog.h>   
+
+  /**
+   * @brief TeAgnostic debug mode selection based on NDEBUG define.
+   */
+  #ifndef TEAGN_DEBUG_MODE
+    #ifndef NDEBUG
+      /** @brief Debug mode selection flag. */
+      #define TEAGN_DEBUG_MODE
+      
+      /** @brief STDOUT logging selection flag. */
+      #define TEAGN_ENABLE_STDOUT_LOG
+    #endif
+  #endif   
+
+  /**
+   * @brief Logs a message to stdout
+   *
+   * @param message Message to be logged.
+   */
+  #ifdef TEAGN_ENABLE_STDOUT_LOG
+    #define TEAGN_LOGMSG_STDOUT( message ) \
+      std::cout << std::endl << "Message : " \
+        << __FILE__ \
+        << ":" << __LINE__ \
+        << " - " << TeAgnostic::to_string( message ) \
+        << std::endl;
+  #else
+    #define TEAGN_LOGMSG_STDOUT( message ) {};
+  #endif
+
+    /**
+    * @brief Logs a error message to stderr
+    *
+    * @param message Message to be logged.
+    */
+  #ifdef TEAGN_ENABLE_STDOUT_LOG
+    #define TEAGN_LOGERR_STDOUT( message ) \
+      std::cerr << std::endl << "Error : " \
+        << __FILE__ \
+        << ":" << __LINE__ \
+        << " - " << TeAgnostic::to_string( message ) \
+        << std::endl;
+  #else
+    #define TEAGN_LOGERR_STDOUT( message ) {};
+  #endif
+
+    /**
+    * @brief Logs a warning message to stdout
+    *
+    * @param message Message to be logged.
+    */
+  #ifdef TEAGN_ENABLE_STDOUT_LOG
+    #define TEAGN_LOGWARN_STDOUT( message ) \
+      std::cout << std::endl << "Warning : " \
+        << __FILE__ \
+        << ":" << __LINE__ \
+        << " - " << TeAgnostic::to_string( message ) \
+        << std::endl;
+  #else
+    #define TEAGN_LOGWARN_STDOUT( message ) {};
+  #endif
+        
+
+  /**
+   * @brief Logs a message.
+   *
+   * @param message Message to be logged.
+   */
+  #define TEAGN_LOGMSG( message ) \
+  { \
+    TeErrorLog::instance().insert( LOG_MESSAGE, \
+      TeAgnostic::to_string( message ) ); \
+    TEAGN_LOGMSG_STDOUT( message ); \
+  };
+
+  /**
+   * @brief Logs a message.
+   *
+   * @param message Message to be logged.
+   */
+  #define TEAGN_LOGERR( message ) \
+  { \
+    TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE, \
+      TeAgnostic::to_string( message ) ); \
+    TEAGN_LOGERR_STDOUT( message ); \
+  };
+      
+  /**
+   * @brief Logs a warning message.
+   *
+   * @param message Message to be logged.
+   */
+  #define TEAGN_LOGWARN( message ) \
+  { \
+    TeErrorLog::instance().insert( LOG_MESSAGE, \
+     TeAgnostic::to_string( message ) ); \
+    TEAGN_LOGWARN_STDOUT( message ); \
+  };
+      
+  /**
+   * @brief Logs a message to stderr and throws.
+   *
+   * @param message Message to be logged.
+   */
+  #define TEAGN_LOG_AND_THROW( message ) \
+  { \
+    TEAGN_LOGERR_STDOUT( message ); \
+    throw TeException( UNKNOWN_ERROR_TYPE, \
+      TeAgnostic::to_string( message ), false ); \
+  };
+      
+  /**
+   * @brief Checks if value is true and throws an exception if not.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_TRUE_OR_THROW( value , message ) \
+    if( value == 0 ) { \
+      TEAGN_LOGERR_STDOUT( TeAgnostic::to_string( message ) + \
+        " - " + TeAgnostic::to_string( #value ) ); \
+      throw TeException( UNKNOWN_ERROR_TYPE, \
+        TeAgnostic::to_string( message ), false ); \
+    };      
+
+  /**
+   * @brief Variable watching.
+   *
+   * @param variable Variable to be logged.
+   */
+  #define TEAGN_WATCH( variable ) \
+    { \
+      TEAGN_LOGMSG( "WATCH - " + TeAgnostic::to_string( #variable ) + \
+        "=" + TeAgnostic::to_string( variable ) ); \
+    };
+
+  /**
+   * @brief Checks if value is true and logs an warning message if not.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_TRUE_OR_LOG( value , message ) \
+    if( value == 0 ) { \
+      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
+        " - " + TeAgnostic::to_string( #value ) ); \
+    };
+
+  /**
+   * @brief Checks if value is true. For false values a warning message will be logged 
+   * and a return of context with false value will be done.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_TRUE_OR_RETURN( value , message ) \
+    if( value == 0 ) { \
+      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
+        " - " + TeAgnostic::to_string( #value ) ); \
+      return false; \
+    };
+    
+  /**
+   * @brief Checks if value is false. For true values a warning message 
+   * will be logged 
+   * and a return of context with false value will be done.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_FALSE_OR_RETURN( value , message ) \
+    if( value != 0 ) { \
+      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
+        " - " + TeAgnostic::to_string( #value ) ); \
+      return false; \
+    };    
+
+  /**
+   * @brief Logs a warning message will and return false.
+   *
+   * @param message Message to be logged.
+   */
+  #define TEAGN_LOG_AND_RETURN( message ) \
+    { \
+      TEAGN_LOGWARN( message ); \
+      return false; \
+    };
+
+  /**
+   * @brief Checks if value is false and logs an warning message if not.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_FALSE_OR_LOG( value , message ) \
+    if( value != 0 ) { \
+      TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \
+        " - " + TeAgnostic::to_string( #value ) ); \
+    };
+
+  /**
+   * @brief Checks if two values are equal and throws an exception if not.
+   *
+   * @param value1 Value to be checked.
+   * @param value2 Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_CHECK_EQUAL( value1 , value2 , message ) \
+    TEAGN_TRUE_OR_THROW( ( ((double)value1) == ((double)value2) ), \
+    std::string( "Values must be equal [" ) + \
+    TeAgnostic::to_string( value1 ) + "!=" + \
+    TeAgnostic::to_string( value2 ) + "] - " + \
+    TeAgnostic::to_string( message ) );
+
+  /**
+   * @brief Checks if two values are diferent and throws an exception if not.
+   *
+   * @param value1 Value to be checked.
+   * @param value2 Value to be checked.
+   * @param message Message to be logged.
+   */
+  #define TEAGN_CHECK_NOTEQUAL( value1 , value2 , message ) \
+    TEAGN_TRUE_OR_THROW( ( ((double)value1) != ((double)value2) ), \
+    std::string( "Values can't be equal [" ) + \
+    TeAgnostic::to_string( #value1 ) + std::string( "==" ) + \
+    TeAgnostic::to_string( #value2 ) + std::string( "==" ) + \
+    TeAgnostic::to_string( value1 ) + std::string( "]" ) );
+
+  /**
+   * @brief  Checks if two values are equal ( within an EPS ) and
+   *  throws an exception if not.
+   *
+   * @param value1 Value to be checked.
+   * @param value2 Value to be checked.
+   * @param eps EPS ( threshold )
+   * @param message Message to be logged.
+   */
+  #define TEAGN_CHECK_EPS( value1 , value2 , eps , message ) \
+    { \
+      TEAGN_TRUE_OR_THROW( ( eps >= 0), "Invalid eps" ); \
+      double TEAGN_CHECK_EPS_double_diff = 0; \
+      double TEAGN_CHECK_EPS_double_value1 = (double)value1; \
+      double TEAGN_CHECK_EPS_double_value2 = (double)value2; \
+      double TEAGN_CHECK_EPS_double_eps = (double)eps; \
+      if( TEAGN_CHECK_EPS_double_value1 < TEAGN_CHECK_EPS_double_value2 ) { \
+        TEAGN_CHECK_EPS_double_diff = ( TEAGN_CHECK_EPS_double_value2 - \
+          TEAGN_CHECK_EPS_double_value1 ); \
+      } else { \
+        TEAGN_CHECK_EPS_double_diff = ( TEAGN_CHECK_EPS_double_value1 - \
+          TEAGN_CHECK_EPS_double_value2 ); \
+      }; \
+      TEAGN_TRUE_OR_THROW( \
+        ( TEAGN_CHECK_EPS_double_diff <= TEAGN_CHECK_EPS_double_eps ), \
+        std::string( "Values are not equal: " ) + \
+        TeAgnostic::to_string( #value1 ) + \
+        std::string( "=[") + \
+        TeAgnostic::to_string( TEAGN_CHECK_EPS_double_value1 ) + \
+        std::string( "] " ) + \
+        TeAgnostic::to_string( #value2 ) + \
+        std::string( "=[") + \
+        TeAgnostic::to_string( TEAGN_CHECK_EPS_double_value2 ) + \
+        std::string( "] eps=[") + \
+        TeAgnostic::to_string( TEAGN_CHECK_EPS_double_eps ) + \
+        std::string( "] diff=[") + \
+        TeAgnostic::to_string( TEAGN_CHECK_EPS_double_diff ) + \
+        std::string( "] - " ) + \
+        TeAgnostic::to_string( message ) \
+        ); \
+    };
+
+  /**
+   * @brief Throws an exception for not implemented source.
+   */
+  #define TEAGN_NOT_IMPLEMENTED \
+    TEAGN_LOG_AND_THROW( "Not Implemented." );
+
+  /**
+   *  @brief Checks if Debug mode is enabled and throws an exception if not.
+   */
+  #define TEAGN_DEBUG_MODE_CHECK \
+    TEAGN_TRUE_OR_THROW( TeAgnostic::debugModeCheck() , \
+    "Code not compiled with debug" );
+    
+  /**
+   * @brief Checks if value is true and throws an exception if not.
+   *
+   * @note This macro will be disabled for non debug mode.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #ifdef TEAGN_DEBUG_MODE
+    #define TEAGN_DEBUG_CONDITION( value , message ) \
+      TEAGN_TRUE_OR_THROW( value , message );
+  #else
+    #define TEAGN_DEBUG_CONDITION( value , message ) {};
+  #endif
+  
+  /**
+   * @brief Checks if value is true. For false values a warning message will be logged 
+   * and a return of context with false value will be done.
+   *
+   * @note This macro will be disabled for non debug mode.
+   *
+   * @param value Value to be checked.
+   * @param message Message to be logged.
+   */
+  #ifdef TEAGN_DEBUG_MODE
+    #define TEAGN_DEBUG_RETURN( value , message ) \
+      TEAGN_TRUE_OR_RETURN( value , message );
+  #else
+    #define TEAGN_DEBUG_RETURN( value , message ) {};
+  #endif  
+
+  /**
+   * @brief This namespace contains a set of routines and classes to deal with
+   *  system checking and logging facility.
+   * @ingroup Utils
+   */
+  namespace TeAgnostic{
+
+    /**
+     * @brief Data conversion to string.
+     *
+     * @param data Data to be converted.
+     * @return The converted string.
+     */
+     template< class T >
+     std::string to_string( const T& data )
+     {
+        std::stringstream temp_ss;
+        temp_ss.setf(std::ios_base::fixed);
+        temp_ss << data;
+        return temp_ss.str();
+     }
+
+    /**
+     * @brief Checks if the code was compiled with debug mode.
+     *
+     * @return true if debug mode was used at compilation time. false if not.
+     */
+     TL_DLL bool debugModeCheck();
+
+  };
+
+#endif
diff --git a/src/terralib/kernel/TeAsciiFile.cpp b/src/terralib/kernel/TeAsciiFile.cpp
new file mode 100644
index 0000000..0ad63f3
--- /dev/null
+++ b/src/terralib/kernel/TeAsciiFile.cpp
@@ -0,0 +1,363 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeAsciiFile.h"
+#include "TeErrorLog.h"
+#include "TeException.h"
+#include "TeAssertions.h"
+#include "TeDefines.h"
+
+#include <cstdlib> //FAMI
+
+TeAsciiFile::TeAsciiFile ( const string& name, const char* mode ): 	
+	TeStdFile ( name, mode  ) 
+{
+}  
+
+TeAsciiFile::~TeAsciiFile() 
+{ 	
+}  
+
+void
+TeAsciiFile::findNewLine ()
+{
+	if ( feof ( file_ ) != 0 )
+		return;
+	char ch = '0';
+
+	while ( ch != '\n' )
+	{
+		fscanf ( file_, "%c", &ch );
+		if ( feof ( file_ ) != 0 )
+			return;
+	}
+}
+
+char 
+TeAsciiFile::readQuotedChar()
+{
+	require ( feof ( file_ ) == 0 );
+
+	char ch = ',', ch2;
+
+	while ( ch != '"' )
+	{
+		fscanf ( file_, "%c", &ch );
+	}
+	fscanf ( file_, "%c", &ch );
+	fscanf ( file_, "%c", &ch2 );
+
+	ensure ( ch2 == '"' ); // just to make sure
+return ch;
+}
+
+char 
+TeAsciiFile::readChar()
+{
+	char ch=' ';
+	require ( feof ( file_ ) == 0 );
+	while ( ch == ' ' )
+	{
+		fscanf ( file_, "%c", &ch );
+	}
+	return ch;
+}
+
+
+string
+TeAsciiFile::readString ()
+{
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	char input [TeNAME_LENGTH];
+	input[0]=0;
+	fscanf ( file_, "%s", input );
+
+return input;
+}
+
+void
+TeAsciiFile::writeString (const string& s)
+{
+	fprintf ( file_, "%s", s.c_str() );
+}
+
+string
+TeAsciiFile::readLine ()
+{
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	char input [TeNAME_LENGTH];
+	fgets ( input, TeNAME_LENGTH, file_ );
+
+return input;
+}
+
+string 
+TeAsciiFile::readQuotedString()
+{
+	require ( feof ( file_ ) == 0 );
+
+	char ch = ' ';
+
+	string quote;
+
+	while ( ch != '"' )
+	{
+		fscanf ( file_, "%c", &ch );
+	}
+
+	while ( true )
+	{
+		fscanf ( file_, "%c", &ch );
+		if ( ch == '\n' || ch == '\r') 
+		{
+			ungetc ( ch, file_ );
+			break;
+		}
+		if ( ch == '"'  ) break;
+
+		quote = quote + ch;
+	}
+return quote;
+}
+
+void
+TeAsciiFile::readStringList ( vector<string>& strlist )
+{
+	require ( file_ != 0 );
+
+	this->readStringListCSV ( strlist, ' ');
+}
+
+void
+TeAsciiFile::readStringListCSV ( vector<string>& strlist, const char sep)
+{
+
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	char ch, lastChr = 0;
+	while (fscanf ( file_, "%c", &ch ) !=  EOF )
+	{
+		if ( ch == '\n' || ch == '\r') 
+		{ 
+			if(lastChr==sep)
+				strlist.push_back ( "" );
+
+			ungetc ( ch, file_ );
+			return;
+		}
+		ungetc ( ch, file_ );
+		// there are still more values to be read
+		string name = readStringCSV (sep);
+		if ( name.size() !=  0 || sep != ' ')
+			strlist.push_back ( name );
+		
+		lastChr = ch;
+	}
+}
+
+void
+TeAsciiFile::readNStringCSV ( vector<string>& strlist, unsigned int n, const char sep)
+{
+
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	strlist.clear();
+	char ch, lastChr = 0;
+	while (fscanf ( file_, "%c", &ch ) !=  EOF )
+	{
+		if ( ch == '\n' || ch == '\r') 
+		{ 
+			if(lastChr==sep)
+				strlist.push_back ( "" );
+
+			ungetc ( ch, file_ );
+			return;
+		}
+		ungetc ( ch, file_ );
+		// there are still more values to be read
+		string name = readStringCSV (sep);
+		if ( name.size() !=  0 || sep != ' ')
+			strlist.push_back ( name );
+		if (strlist.size() == n)
+			break;
+		
+		lastChr = ch;
+	}
+}
+
+string
+TeAsciiFile::readStringCSV( const char del, bool skip, const char skip_char )
+{
+	require ( file_ != 0 );
+
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	char ch = '0';
+	string line;
+	bool inQuotes = false;
+
+	int ret;
+	while ( (ret=fscanf ( file_, "%c", &ch )) != EOF)
+	{
+		if ( ch == '\n' || ch == '\r') 
+		{
+			ungetc ( ch, file_ );
+			break;
+		}
+		if ( ch == del  && !inQuotes ) break;
+		if (skip)
+			if (ch == skip_char) 
+			{
+				if (skip_char == '"')
+					inQuotes = !inQuotes;
+				continue;
+			}
+		line = line + ch;
+	}
+	return line;
+}
+
+string
+TeAsciiFile::readStringCSVNoSpace( const char del )
+{
+	char blank = ' ';
+	string line = readStringCSV ( del, true, blank );
+return line;
+}
+
+string
+TeAsciiFile::readStringCSVNoQuote( const char del )
+{
+	char quote = '"';
+	string line = readStringCSV ( del, true, quote );
+return line;
+}
+
+int
+TeAsciiFile::readInt ()
+{
+	require ( file_ != 0 );
+
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+	
+	int value;
+	fscanf ( file_, "%d", &value );
+
+return value;
+}
+
+int
+TeAsciiFile::readIntCSV ( const char del )
+{
+	char blank  = ' ';
+	string line = readStringCSV ( del, true, blank );
+
+return atoi(line.c_str());
+}
+
+double
+TeAsciiFile::readFloatCSV ( const char del )
+{
+	char blank = ' ';
+	string line = readStringCSV ( del, true, blank );
+
+return atof(line.c_str());
+}
+
+
+double
+TeAsciiFile::readFloat ()
+{
+	require ( file_ != 0 );
+
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+	
+	double value;
+	fscanf ( file_, "%lf", &value );
+
+return value;
+}
+
+TeCoord2D
+TeAsciiFile::readCoord2D ()
+{
+	require ( file_ != 0 );
+
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	double x, y;
+	fscanf ( file_, "%lf %lf", &x, &y);
+
+return TeCoord2D( x,  y );
+}
+
+TeBox
+TeAsciiFile::readBox() 
+{
+	require ( file_ != 0 );
+
+	if ( feof ( file_ ) != 0 )
+	{
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+	}
+	double x1, y1, x2, y2;
+
+
+	fscanf ( file_, "%lf %lf %lf %lf", &x1, &y1, &x2, &y2 );
+
+return TeBox ( x1, y1, x2, y2 );
+
+}
+
+string
+TeAsciiFile::readAll()
+{
+	require ( file_ != 0 );
+	if ( feof ( file_ ) != 0 )
+		throw TeException ( END_OF_FILE_REACHED, name(), true );
+
+	char ch = '0';
+	string text="";
+	int ret;
+	while ((ret=fscanf ( file_, "%c", &ch )) != EOF)
+	{
+		if (ch != '\n') 
+			text = text + ch;
+	}
+	return text;
+}
+
diff --git a/src/terralib/kernel/TeAsciiFile.h b/src/terralib/kernel/TeAsciiFile.h
new file mode 100644
index 0000000..e65e92f
--- /dev/null
+++ b/src/terralib/kernel/TeAsciiFile.h
@@ -0,0 +1,132 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAsciiFile.h
+    \brief This file contains structures and definitions to deal ASCII files
+*/
+#ifndef  __TERRALIB_INTERNAL_ASCIIFILE_H
+#define  __TERRALIB_INTERNAL_ASCIIFILE_H
+
+#include "TeDefines.h"
+#include "TeStdFile.h"
+#include "TeCoord2D.h"
+#include "TeBox.h"
+
+#include <stdio.h>
+
+#include <vector> 
+#include <string>
+using namespace std;
+
+//!  A class for handling reading/writing for ASCII files
+/*!  Simple wrapper around a stdio file. Clientes are all the 
+	 functions that imports from ASCII files. 
+
+ \sa
+  TeStdFile, TeSPRFile
+*/
+class TL_DLL TeAsciiFile: public TeStdFile {
+
+public:
+
+	//! Contructors
+	TeAsciiFile(const string& name, const char* mode = "r");
+	
+	//! Destructor
+	virtual ~TeAsciiFile();
+
+	//! Writes a carriage return character
+	void writeNewLine ()
+	{ fprintf ( file_, "\n" ); } 
+	
+	//! Goes to a new line 
+	void findNewLine () ; 
+
+	//! Reads a string
+	string readString(); 
+
+	//! Reads a full line up to carriage return
+	string readLine(); 
+
+	//! Writes a generic string to the file
+	void writeString (const string& s);
+
+	//! Reads a string whithin quotes
+	string readQuotedString(); 
+
+	//! Reads a comma-separated string ( with a skip character )
+	string readStringCSV( const char sep = ',', bool skip = false, 
+						  const char skip_char = ' ');
+
+	//! Reads a character whithin quotes
+	char readQuotedChar();
+
+	//! Reads a character
+	char readChar();
+
+	//! Reads a comma-separated string(ignore spaces)
+	string readStringCSVNoSpace( const char del = ',');
+
+	//! Reads a comma-separated string (ignore quote )
+	string readStringCSVNoQuote ( const char del = ',' );
+
+	//! Reads an integer
+	int readInt();
+
+	//! Reads a comma-separated int
+	int readIntCSV( const char del = ',');
+
+	//! Reads a float
+	double readFloat();
+
+	//! Reads a comma-separated float
+	double readFloatCSV( const char del = ',');
+
+	//! Reads a 2D coordinate ( x, y )
+	TeCoord2D readCoord2D();
+
+	//! Reads a line and put in a stringlist
+	void readStringList ( vector<string>& );
+
+	//! Reads a comma-separated line string and put in a string list
+	void readStringListCSV ( vector<string>&, const char sep = ',');
+
+	//! Reads the first n strings from a comma separated line string and put in a string list
+	void readNStringCSV ( vector<string>&, unsigned int n, const char sep = ',');
+
+	//! Reads a bounding box
+	TeBox readBox();
+
+	//! Reads the entire content of the file, skipping new line characters only
+	string readAll();
+
+private:
+	
+// No copy allowed
+
+	TeAsciiFile(const TeAsciiFile&);
+	TeAsciiFile& operator=(const TeAsciiFile&);
+
+};
+#endif
+
+
diff --git a/src/terralib/kernel/TeAssertions.h b/src/terralib/kernel/TeAssertions.h
new file mode 100644
index 0000000..6fbc95a
--- /dev/null
+++ b/src/terralib/kernel/TeAssertions.h
@@ -0,0 +1,35 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAssertions.h
+    \brief This file contains definitions for require and ensure macros
+*/
+
+#ifndef TeAssertions_H
+#define TeAssertions_H
+#include <assert.h>
+
+#define require(statement)    assert(statement)
+#define ensure(statement)     assert(statement)
+
+#endif
+
diff --git a/src/terralib/kernel/TeAttribute.h b/src/terralib/kernel/TeAttribute.h
new file mode 100644
index 0000000..15b28cf
--- /dev/null
+++ b/src/terralib/kernel/TeAttribute.h
@@ -0,0 +1,174 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeAttribute.h
+    \brief This file contains structures and definitions about attributes of geographical objects
+*/
+#ifndef  __TERRALIB_INTERNAL_ATTRIBUTE_H
+#define  __TERRALIB_INTERNAL_ATTRIBUTE_H
+
+#include "TeDefines.h"
+#include "TeDataTypes.h"
+#include "TeTime.h"
+
+/*! \enum TeMeasurementScale 
+	\brief Sscale of measurement according to Stevens (1949) 
+           modified by Chrisman (1998) to include CYCLIC and PROBABILITY
+           we also include FUZZY (possibility scale) 
+*/
+enum TeMeasurementScale 
+{ ORDINAL, NOMINAL, RATIO, INTERVAL, CYCLIC, PROBABILITY, FUZZY };
+
+/*! \struct TeAttributeRep
+	\brief Attribute physical representation
+*/
+struct TL_DLL TeAttributeRep
+{
+	string			name_;		//!< attribute name	
+	TeAttrDataType  type_;		//!< attribute type
+	int				numChar_;   //!< width of an attribute
+	int				decimals_;	//!< number of decimal digits
+	bool			isPrimaryKey_;	//!< flag to indicate that the attribute is part of primary key
+	bool			isAutoNumber_; 	//!< flag to indicate that the attribute is auto number
+	bool            null_;			//!< flag to indicate that attribute can be a null value (true) or not (false)
+	string			defaultValue_;	//!< default value (without "'")
+
+	//! Empty constructor
+	TeAttributeRep():
+		name_(""),
+		type_(TeSTRING),
+		numChar_(0),
+		decimals_(0),
+		isPrimaryKey_(false),
+		isAutoNumber_(false),
+		null_(true),
+		defaultValue_("")
+		{}
+
+	//! Constructor
+	TeAttributeRep(const string& name):
+		name_(name),
+		type_(TeSTRING),
+		numChar_(0),
+		decimals_(0),
+		isPrimaryKey_(false),
+		isAutoNumber_(false),
+		null_(true),
+		defaultValue_("")
+		{}
+
+	//! Operator =
+	TeAttributeRep& operator= ( const TeAttributeRep& at )
+	{
+		if ( this != &at )
+		{	
+			name_ = at.name_;
+			type_ = at.type_;
+			numChar_ = at.numChar_;
+			decimals_ = at.decimals_;
+			isPrimaryKey_ = at.isPrimaryKey_;
+			isAutoNumber_ = at.isAutoNumber_;
+			null_ = at.null_;
+			defaultValue_ = at.defaultValue_;
+		}
+		return *this;
+	}
+
+	//! Operator ==
+	bool operator== ( const TeAttributeRep& at )
+	{
+		return (name_==at.name_ && type_ == at.type_
+			&& numChar_ == at.numChar_ && decimals_ == at.decimals_ &&
+            isPrimaryKey_ == at.isPrimaryKey_ && 
+			isAutoNumber_ == at.isAutoNumber_ && 
+			null_ == at.null_ && defaultValue_ == at.defaultValue_);
+	}
+
+	//! Operator <
+	bool	operator< (const TeAttributeRep& at) const 
+	{return (name_ < at.name_);}	
+};
+
+/*! \struct TeAttribute
+	\brief Attribute description
+*/
+struct TL_DLL TeAttribute
+{
+	TeAttributeRep	rep_;		//!< representation of attribute	
+	string	semantic_;			//!< reference in a Ontology database (e.g., entry in WordNet )	
+	string	unit_;				//!< measurement unit ( e.g., m ) if applicable
+	TeMeasurementScale  scale_;	//!< scale of measurement
+
+	// for RATIO data sets
+	string				minValue_;	//!< minimum value of the attribute
+	string				maxValue_;	//!< maximum value of the attrbute	
+
+	// for NOMINAL or ORDINAL data sets
+	vector<string>		validValueList_; //!< list of valid values
+
+	// for INTERVAL data sets (??)
+	string				origin_;	//!< origin of the intervals	
+	string				interval_;	//!< mesurement interval
+
+	string				dateTimeFormat_;	//!< format for date and time values
+	string				indicatorAM_;		//!< AM indicator for a 12 hour clock
+	string				indicatorPM_;		//!< PM indicator for a 12 hour clock
+	string				dateSeparator_;		//!< date separator
+	string				timeSeparator_;		//!< time separator
+	TeChronon			dateChronon_;		//!< date chronon
+
+	//! Empty constructor
+	TeAttribute():
+		rep_			(TeAttributeRep()),
+		dateTimeFormat_	("DsMsYYYYsHHsmmsSS"), 
+		indicatorAM_	("AM"),
+		indicatorPM_	("PM"),
+		dateSeparator_	("/"),
+		timeSeparator_	(":"), 
+		dateChronon_    (TeSECOND)
+		{}
+};
+
+/*! \struct TeProperty
+	\brief A property of an object
+ */
+struct TL_DLL TeProperty
+{
+	TeAttribute		attr_;		//!< attribute description
+    string			value_;		//!< its value stored as an string
+};
+
+//! A vector of TeProperties
+typedef vector<TeProperty> TePropertyVector;
+
+//! A vector of attributes representation
+typedef vector<TeAttributeRep>  TeAttributeRepList;
+
+//! A vector of attributes 
+typedef vector<TeAttribute>		TeAttributeList;
+
+//! A Map of the attribute names to the statistical types 
+typedef vector< pair<TeAttributeRep, TeStatisticType> > TeGroupingAttr;
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeBaseSTInstance.h b/src/terralib/kernel/TeBaseSTInstance.h
new file mode 100644
index 0000000..abb17e6
--- /dev/null
+++ b/src/terralib/kernel/TeBaseSTInstance.h
@@ -0,0 +1,552 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeBaseSTInstance.h
+	\brief This file contains a base class called TeBaseSTInstance that represents 
+	an instance in time of a geographical object or element.  
+*/
+
+#ifndef  __TERRALIB_INTERNAL_BASESTINSTANCE_H
+#define  __TERRALIB_INTERNAL_BASESTINSTANCE_H
+
+#include "TeCoord2D.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeAttribute.h"
+#include "TeSharedPtr.h"
+
+#include <string>
+#include <map> 
+#include <vector>
+
+using namespace std;
+
+class TeTheme;
+
+/*! \class TeBaseSTInstance
+	\brief A base class that represents an instance in a time of a spatial object.
+
+	A spatio-temporal instance (STInstance) is composite of an attribute set and geometries 
+	of a spatial element or object that are valid in a specific time. This class implements
+	a base generic spatio-temporal instance that can be specialized according to the
+	types that represent its geometries and its valid time.
+	
+*/
+template<typename GeometryType, typename TimeType>
+class TeBaseSTInstance
+{
+	
+protected:
+	//! object identification
+	string					object_id_;		
+	//! unique identification in each attribute table
+	vector<string>			unique_id_;	
+	//! set of properties or attributes values
+	vector<string>			properties_;	
+	//! geometries
+	GeometryType			geometries_;	
+	//! valid time 
+	TimeType				time_;		
+	//! the slice or group that contains this instance  
+	int						slice_;		
+	//! a shared pointer to the descriptions of all attributes
+	TeSharedPtr<TeAttributeList> 	attrList_;			
+		
+public:		
+
+	//! Empty constructor
+	TeBaseSTInstance() : object_id_(""), slice_(-1), attrList_(0)
+	{ }
+
+	//! Constructor
+	TeBaseSTInstance (const string& object_id, const vector<string>& prop, TeAttributeList* attList = 0, const int& s = -1) : 
+		object_id_(object_id), 
+		properties_(prop),
+		slice_(s),
+		attrList_(TeSharedPtr<TeAttributeList>(attList))
+		{ } 
+
+	//! Constructor
+	TeBaseSTInstance (const string& object_id, const GeometryType& geometries, const TimeType& time, 
+		const int& s = -1) : 
+		object_id_(object_id), 
+		geometries_(geometries),
+		time_(time),
+		slice_(s),
+		attrList_(0)
+		{ } 
+
+	//! Constructor
+	TeBaseSTInstance (const string& object_id, const vector<string>& prop, TeAttributeList* attList,
+		const GeometryType& geometries,	const int& slice, const TimeType& time ) :
+		object_id_(object_id), 
+		properties_(prop),
+		geometries_(geometries),
+		time_(time),
+		slice_(slice),
+		attrList_(TeSharedPtr<TeAttributeList>(attList))
+		{ } 
+			
+	//! Destructor
+	virtual ~TeBaseSTInstance() 
+	{ } 
+
+	//! Equal operator 
+	virtual bool operator== (const TeBaseSTInstance<GeometryType, TimeType>& other);
+
+	//! Returns the object identification
+	virtual string getObjectId () 
+	{	return object_id_;	}
+	
+	//! Sets the object identification
+	virtual void setObjectId (const string& id) 
+	{	object_id_ = id;	}
+
+	//! Deprecated: Returns the object identification 
+	virtual string objectId () 
+	{	return getObjectId();	}
+	
+	//! Deprecated: Sets the object identification 
+	virtual void objectId (const string& id) 
+	{	setObjectId(id);	}
+
+	//! Returns the unique identification in all attribute tables
+	virtual vector<string>& getUniqueId() 
+	{	return unique_id_;	}
+
+	//! Returns the unique identification of the i-th attribute table
+	virtual string getUniqueId(const int& i); 
+	
+	//! Sets the unique identification in all attribute tables
+	virtual void setUniqueId (const vector<string>& id) 
+	{	unique_id_ = id;	}
+
+	//! Adds an unique identification
+	virtual void addUniqueId (const string& id) 
+	{	unique_id_.push_back(id);	}
+
+	//! Deprecated: Returns the instance identification in all attribute tables
+	virtual vector<string>& uniqueId () 
+	{	return getUniqueId();	}
+
+	//! Deprecated: Returns the instance identification in the index-th attribute table
+	virtual string uniqueId (int index) 
+	{	return getUniqueId(index);	}
+	
+	//! Deprecated: Sets the instance identifications in all attribute tables
+	virtual void uniqueId (const vector<string>& ids) 
+	{	setUniqueId(ids);	}
+
+	//! Returns the valid time 
+	virtual TimeType getTime() 
+	{	return time_;	}
+	
+	//! Sets the valid time 
+	virtual void setTime (const TimeType& t) 
+	{	time_ = t;	}
+
+	//! Sets the property value vector 
+	virtual void setProperties(const vector<string>& p) 
+	{	properties_ = p;	}
+
+	//! Deprecated: Sets the property vector to the ST instance 
+	virtual void setProperties(TePropertyVector& p); 
+
+	//! Sets the value (as a string) of the i-th property 
+	virtual bool setPropertyValue (const int& i, const string& val); 
+
+	//! Sets the value (as a string) of a property named 'name'
+	virtual bool setPropertyValue (const string& name, const string& val); 
+
+	//! Adds a new property value
+	virtual void addPropertyValue (const string& val)
+	{	properties_.push_back (val); }
+
+	//! Removes the i-th property value
+	virtual bool removePropertyValue (const int& i); 
+
+	//! Adds a new property or set its value   
+	/*!
+		Verifies if there is this property in the attribute list.
+		If not, adds it in the ST instance and in the attribute list. 
+		Otherwise, set the property value
+	*/
+	virtual bool addProperty(TeProperty& prop); 
+
+	//! Adds a new attribute in the attribute list 
+	virtual bool addProperty(TeAttribute& rep); 
+	
+	//! Returns the property value vector 
+	virtual vector<string>& getProperties()
+	{	return properties_;	}
+
+	//! Gets the property vector 
+	virtual void getPropertyVector(TePropertyVector& propVec); 
+
+	//! Deprecated: Returns the property vector from the ST instance
+	TePropertyVector getPropertyVector(); 
+	
+	//! Gets the i-th property
+	virtual bool getProperty (TeProperty& prop, unsigned int i = 0);	
+	
+	//! Gets the property named "name"
+	virtual bool getProperty (TeProperty& prop, string name); 
+	
+	//! Gets the value (as a string) of the i-th property
+	virtual bool getPropertyValue (string& val, const int& i = 0); 
+
+	//! Gets the the value (as a string) of a property named "name"
+	virtual bool getPropertyValue (const string& name, string& val); 
+	
+	//! Returns the value (as a double) of the i-th property
+	virtual double operator[](int i); 
+
+	//! Deprecated: Sets the property vector to the ST instance
+	virtual void properties(TePropertyVector& p)
+	{	setProperties(p); }
+
+	//! Returns the geometries
+	virtual GeometryType& getGeometries() 
+	{	return geometries_;}
+
+	//! Sets the geometries  
+	virtual void setGeometry(const GeometryType& g)
+	{	geometries_ = g; }
+
+	//! Deprecated: Returns the geometries
+	virtual GeometryType& geometries() 
+	{	return getGeometries();}
+
+	//! Sets the group or slice that contains this instance 
+	virtual void setSlice (int s) 
+	{	slice_ = s; }
+
+	//! Returns the group or slice that contains this instance
+	virtual int getSlice()
+	{	return slice_; }
+
+	//! Deprecated: Sets the group or slice that contains this instance 
+	virtual void slice (int s) 
+	{	setSlice(s); }
+
+	//! Deprecated: Returns the group or slice that contains this instance
+	virtual int slice()
+	{	return getSlice(); }
+
+	//! Gets a pointer to attribute desciptions
+	const TeAttributeList*	getAttrList()
+	{	return attrList_.nakedPointer(); }
+
+	//! Creates a new internal copy of the attribute description
+	void setAttrList(const TeAttributeList& attList); 
+
+	//! Sets a shared pointer to attribute descriptions
+	void setAttrList(TeSharedPtr<TeAttributeList>& attrList);
+
+	//! Clears the instance, its attributes. It must be implemented by specialized classes to clear its geometries.
+	virtual void clear();
+
+	//! Returns a centroid associated to the geometries of the instance
+	virtual TeCoord2D getCentroid();
+
+	//! Returns an area the geometries of the instance
+	virtual double getArea();
+
+	//! Verifies if the time associated with this instance is valid. It must be implemented by specialized classes.
+	virtual bool isTimeValid()
+	{	return false; } 
+	
+	//! Deprecated: Returns the theme pointer that contains this instance. 
+	virtual TeTheme* theme() 
+	{ return 0; }
+
+	//! Deprecated: Sets the theme that contains this instance.
+	virtual void theme(TeTheme*)  
+	{  }
+};
+
+template<typename GeometryType, typename TimeType> bool
+TeBaseSTInstance<GeometryType, TimeType>::operator== (const TeBaseSTInstance<GeometryType, TimeType>& other)
+{
+	return ( (object_id_ == other.object_id_) && 
+			 (time_ == other.time_) &&
+			 (slice_ == other.slice_));
+}
+
+template<typename GeometryType, typename TimeType> string 
+TeBaseSTInstance<GeometryType, TimeType>::getUniqueId(const int& i) 
+{	
+	if(i<(int)unique_id_.size())
+		return unique_id_[i];	
+	return "";
+}
+
+template<typename GeometryType, typename TimeType> void 
+TeBaseSTInstance<GeometryType, TimeType>::setAttrList(const TeAttributeList& attList)
+{
+	attrList_.reset(new TeAttributeList()); 
+	*attrList_ = attList;
+}
+
+template<typename GeometryType, typename TimeType> void 
+TeBaseSTInstance<GeometryType, TimeType>::setAttrList(TeSharedPtr<TeAttributeList>& attList)
+{
+	attrList_ = attList;
+}
+
+template<typename GeometryType, typename TimeType> void 
+TeBaseSTInstance<GeometryType, TimeType>::setProperties(TePropertyVector& p)
+{
+	properties_.clear();
+	TePropertyVector::iterator it = p.begin();
+	while(it!=p.end())
+	{
+		addPropertyValue(it->value_); 
+		++it;
+	}
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::setPropertyValue (const int& i, const string& val)
+{	
+	if(i<0 || i>=(int)properties_.size())
+		return false;
+	properties_[i] = val;
+	return true;
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::setPropertyValue (const string& name, const string& val)
+{	
+	if(!attrList_.isActive())
+		return false;
+
+	string newName = TeConvertToUpperCase(name); 
+	size_t pos = name.find(".", 0, 1);
+	if (pos != string::npos)
+		newName = TeConvertToUpperCase((name.substr(pos+1)));
+
+	for(unsigned int i=0; i<attrList_->size(); ++i)
+	{
+		string s = TeConvertToUpperCase((attrList_->operator[](i)).rep_.name_);
+		if( (s == TeConvertToUpperCase(name)) || (s == newName))
+		{
+			if(i>=properties_.size())
+				return false;
+			properties_[i] = val;
+			return true;
+		}
+	}
+	return false; 
+}
+
+template<typename GeometryType, typename TimeType> void  
+TeBaseSTInstance<GeometryType, TimeType>::getPropertyVector(TePropertyVector& propVec)
+{
+	if(!attrList_.isActive())
+		return;
+    if(properties_.size()!=attrList_->size())
+		return;
+	propVec.clear();
+	for(unsigned int i=0; i<properties_.size(); ++i)
+	{
+		TeProperty p;
+		p.value_ = properties_[i];
+		p.attr_ = attrList_->operator[](i);
+		propVec.push_back(p);
+	}
+}
+
+template<typename GeometryType, typename TimeType> TePropertyVector  
+TeBaseSTInstance<GeometryType, TimeType>::getPropertyVector()
+{
+	TePropertyVector vec; 
+	this->getPropertyVector(vec);
+	return vec;
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::getProperty (TeProperty& prop, unsigned int i)
+{
+	if(!attrList_.isActive())
+		return false;
+
+	if(i>=properties_.size() || i>=attrList_->size())
+		return false;
+	prop.value_ = properties_[i];
+	prop.attr_ = (*attrList_)[i];
+	return true;
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::getProperty (TeProperty& prop, string name)
+{
+	if(!attrList_.isActive())
+		return false;
+	 if(properties_.size()!=attrList_->size())
+		return false;
+
+	string newName = TeConvertToUpperCase(name); 
+	size_t pos = name.find(".", 0, 1);
+	if (pos != string::npos)
+		newName = TeConvertToUpperCase(name.substr(pos+1));
+
+	for(unsigned int i=0; i<attrList_->size(); ++i)
+	{
+		string s = TeConvertToUpperCase((attrList_->operator[](i)).rep_.name_); 
+		if((s == TeConvertToUpperCase(name)) || (s == newName))
+		{
+			prop.value_ = properties_[i];
+			prop.attr_ = attrList_->operator[](i);
+			return true;
+		}
+	}
+	return false; 
+}
+	
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::getPropertyValue (string& val, const int& i)
+{
+	if(i<0 || i>= (int)properties_.size())
+		return false;
+	val = properties_[i];
+	return true;
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::getPropertyValue (const string& name, string& val)
+{	
+	if(!attrList_.isActive())
+		return false;
+
+	if(properties_.size()!=attrList_->size())
+		return false;
+
+	string newName = TeConvertToUpperCase(name); 
+	size_t pos = name.find(".", 0, 1);
+	if (pos != string::npos)
+		newName = TeConvertToUpperCase(name.substr(pos+1));
+
+	for(unsigned int i=0; i<attrList_->size(); ++i)
+	{
+		string s = TeConvertToUpperCase((attrList_->operator[](i)).rep_.name_); 
+		if((s == TeConvertToUpperCase(name)) || (s == newName))
+		{
+			val = properties_[i];
+			return true;
+		}
+	}
+	return false; 
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::addProperty(TeProperty& prop)
+{
+	if(!attrList_.isActive())
+		return false;
+
+	string newName = TeConvertToUpperCase(prop.attr_.rep_.name_); 
+	size_t pos = (prop.attr_.rep_.name_).find(".", 0, 1);
+	if (pos != string::npos)
+		newName = TeConvertToUpperCase(prop.attr_.rep_.name_.substr(pos+1));
+
+	for(unsigned int i=0; i<attrList_->size(); ++i)
+	{
+		string s = TeConvertToUpperCase((attrList_->operator[](i)).rep_.name_); 
+		if((s == TeConvertToUpperCase(prop.attr_.rep_.name_)) || (s == newName))
+		{
+			//the property already exists
+			if(i>=properties_.size())
+				properties_.push_back (prop.value_);
+			else
+				properties_[i] = prop.value_;
+			return true;
+		}
+	}
+
+	// Adds a new property
+	attrList_->push_back(prop.attr_);
+	properties_.push_back (prop.value_);
+	return true; 
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::addProperty(TeAttribute& attr)
+{
+	if(!attrList_.isActive())
+		return false;
+	attrList_->push_back(attr);
+	return true; 
+}
+
+template<typename GeometryType, typename TimeType> bool 
+TeBaseSTInstance<GeometryType, TimeType>::removePropertyValue(const int& i)
+{
+	int index = 0;
+	vector<string>::iterator it = properties_.begin();
+	while(it!=properties_.end())
+	{
+		if(index==i)
+		{
+			properties_.erase(it);
+			return true;
+		}
+		++it;
+		++index;
+	}
+	return false;
+}
+
+template<typename GeometryType, typename TimeType> double 
+TeBaseSTInstance<GeometryType, TimeType>::operator[](int i)
+{	
+	double val = TeMAXFLOAT; 
+	if(i<0 || i>=(int)properties_.size() || properties_[i].empty())
+		return val;
+	val = atof(properties_[i].c_str()); 
+	return val;  
+}
+	
+template<typename GeometryType, typename TimeType> void
+TeBaseSTInstance<GeometryType, TimeType>::clear()
+{
+	object_id_ = ""; 
+	slice_ = -1; 
+    properties_.clear(); 
+	unique_id_.clear();
+	attrList_.reset(0);
+}
+
+
+template<typename GeometryType, typename TimeType> TeCoord2D
+TeBaseSTInstance<GeometryType, TimeType>::getCentroid()
+{
+	return TeFindCentroid(this->getGeometries());
+}
+
+template<typename GeometryType, typename TimeType> double
+TeBaseSTInstance<GeometryType, TimeType>::getArea()
+{
+	return TeGeometryArea(this->getGeometries());
+}
+
+			
+#endif 
diff --git a/src/terralib/kernel/TeBaseSTInstanceSet.h b/src/terralib/kernel/TeBaseSTInstanceSet.h
new file mode 100644
index 0000000..5437df9
--- /dev/null
+++ b/src/terralib/kernel/TeBaseSTInstanceSet.h
@@ -0,0 +1,1212 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeBaseSTInstanceSet.h
+	\brief This file contains structures to deal with a set of spatio-temporal 
+	instances. These instances can belong to a specific layer or theme.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_STINSTANCESET_H
+#define  __TERRALIB_INTERNAL_STINSTANCESET_H
+
+#include "TeBaseSTInstance.h"
+#include "TeRTree.h"
+#include "TeTheme.h"
+#include "TeLayer.h"
+#include "TeQuerierParams.h"
+#include "TeQuerier.h"
+#include "TeSharedPtr.h"
+
+/*! \class TeBaseSTInstanceSet
+	\brief A abstract class that represents a set of spatial temporal instances.
+
+	This abstract class implements a generic spatio-temporal instance set. It must 
+	be specialized according to the instance type (its geometry type, its time type
+	and its own type). 
+
+	\sa TeBaseSTInstance TeTheme TeLayer
+	
+*/
+template< typename GeometryType, typename TimeType, typename InstanceType >
+class TeBaseSTInstanceSet  
+{
+
+protected:
+
+	//! Set of spatio temporal instances
+	vector<InstanceType>	instances_;		
+
+	//! Minimal time associated to spatial temporal instances
+	TimeType				minTime_;
+	//! Maximal time associated to spatial temporal instances
+	TimeType				maxTime_;
+
+	//! Description of all attributes 
+	TeSharedPtr<TeAttributeList>	attrList_;
+
+	//! A pointer to a theme
+	TeTheme*				theme_;
+	//! A pointer to a layer
+	TeLayer*				layer_;	
+	//! A bounding box that contains all geometries of the spatial temporal instances
+	TeBox					box_;
+	
+	//! A map from object identity to its associated instances in the set 
+	map<string, vector<int> >		objectIdToInstances_;
+	//! A map from time to its associated instances in the set
+	map<TimeType, vector<int> >		timeToInstances_;
+	//! A map from slice to its associated instances in the set
+	map<int, vector<int> >			sliceToInstances_;
+	//! A struture to index the geometries: RTree
+	TeSAM::TeRTree<int>*			rTree_;		
+
+	//! Builds the set using a given querier and a specific slice
+	virtual bool buildImpl(TeQuerier* querier, const int& slide = -1) = 0;
+
+public:
+
+	//! An iterator that traverse each instance in the set
+	typedef typename vector<InstanceType>::iterator iterator;
+	
+	//! Constructor. It does not initialize the rTree. 
+	TeBaseSTInstanceSet(); 
+
+	//! Constructor. It initializes the rTree based on theme box.
+	TeBaseSTInstanceSet(TeTheme* theme, const TeAttributeList& attrList = TeAttributeList()); 
+
+	//! Constructor. It initializes the rTree based on layer box.
+	TeBaseSTInstanceSet(TeLayer* layer, const TeAttributeList& attrList = TeAttributeList());  
+
+	//! Constructor. It initializes the rTree based on the given box. 
+	TeBaseSTInstanceSet(const TeBox& box, const TeAttributeList& attrList = TeAttributeList());
+
+	//! Copy constructor
+	TeBaseSTInstanceSet (const TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>& other); 
+
+	//! Destructor
+	virtual ~TeBaseSTInstanceSet();  
+	
+	//! Assignment operator
+	virtual TeBaseSTInstanceSet& operator= (const TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>& other);
+
+	//! Gets minimal time
+	virtual TimeType getMinTime()
+	{ return minTime_; }
+
+	//! Sets minimal time
+	virtual void setMinTime(TimeType& t)
+	{ minTime_ = t; } 
+
+	//! Gets maximal time
+	virtual TimeType getMaxTime()
+	{ return maxTime_; }
+
+	//! Sets maximal time
+	virtual void setMaxTime(TimeType& t)
+	{ maxTime_ = t; } 
+
+	//! Gets the attribute list, that is, the description of all attributes
+	virtual TeAttributeList& getAttributeList()
+	{	return (*attrList_);  }
+
+	//! Sets the attribute list, that is, the description of all attributes
+	virtual void setAttributeList(TeAttributeList& attrs); 
+
+	//! Returns the index of an attribute named "attrName"
+	virtual int getAttributeIndex(const string& attrName);
+
+	//! Gets theme pointer
+	virtual TeTheme* getTheme()
+	{	return theme_;  }
+
+	//! Sets theme pointer
+	virtual void setTheme(TeTheme* t)
+	{	theme_ = t; }
+
+	//! Deprecated: Returns a theme pointer
+	TeTheme* theme()
+	{	return getTheme(); }
+
+	//! Gets layer pointer 
+	virtual TeLayer* getLayer()
+	{	return layer_;  }
+
+	//! Sets layer pointer
+	virtual void setLayer(TeLayer* l)
+	{	layer_ = l; }
+	
+	//! Gets a reference to the instance set 
+	virtual vector<InstanceType>& getSTInstances()
+	{	return instances_; }
+
+	//! Gets a pointer to the index-th ST instance
+	virtual InstanceType* getSTInstance(const unsigned int& index);
+
+	//! Gets a pointer to a ST instance of an object in a specific slice  
+	virtual InstanceType* getSTInstance(const string& objectId, const int& slice = -1);
+
+	//! Gets a pointer to a ST instance of an object in a specific time and slice
+	virtual InstanceType* getSTInstance(const string& objectId, TimeType& time, const int& slice = -1);
+
+	//! Gets pointers to all ST instances of a specific object in a specific slice
+	virtual void getSTInstances(vector<InstanceType*>& set, const string& objectId, const int& slice = -1);
+
+	//! Gets pointers to all ST instances of a specific object in a specific time and slice
+	virtual void getSTInstances(vector<InstanceType*>& set, const string& objectId, TimeType& time, const int& slice = -1);
+	
+	///! Gets pointers to all ST instances of a specific time
+	virtual void getSTInstances(vector<InstanceType*>& set, TimeType& time, const int& slice = -1);
+
+	//! Gets pointers to all ST instances of a specific slice
+	virtual void getSTInstances(vector<InstanceType*>& set, const int& slice);
+
+	//! Inserts a new ST instance in the set 
+	virtual bool insertSTInstance (InstanceType& object);
+		
+	//! Returns the number of instances 
+	virtual int numSTInstance(); 
+	
+	//! Returns the number of instances of an object or element
+	virtual int numSTInstance(const string& objectId); 
+
+	//! Returns the number of instances in a specific slice
+	virtual int numSTInstance(const int& slice);
+
+	//! Returns the number of instances in a specific time
+	virtual int numSTInstance(TimeType& time);
+
+	//! Returns the number of elements or objects in the set
+	virtual int numElements()
+	{	return objectIdToInstances_.size(); }
+
+	//! Sets a geometry of an object in a specific slice
+	virtual bool setGeometry(const string& object_id, GeometryType& geom, const int& slice = -1);
+
+	//! Sets a geometry of an object in a specific time and slice
+	virtual bool setGeometry(const string& object_id, GeometryType& geom, TimeType& time,  const int& slice = -1);
+
+	//! Gets the geometry of an object in a specific slice 
+	virtual bool getGeometry(const string& object_id, GeometryType& geom, const int& slice = -1);
+
+	//! Gets the geometry of an object in a specific time and slice
+	virtual bool getGeometry(const string& object_id, GeometryType& geom, TimeType& time, const int& slice = -1);
+
+	//! Gets a vector of attributes or properties of a object that is valid in a slice 
+	virtual bool getPropertyVector (const string& object_id, TePropertyVector& propVec, const int& slice = -1);
+
+	//! Gets a vector of attributes or properties of a object that is valid in a time and slice
+	virtual bool getPropertyVector (const string& object_id, TePropertyVector& propVec, TimeType& time, const int& slice = -1);
+
+	//! Sets a vector of attribute values of a object that is valid in a slice 
+	virtual bool setProperties (const string& object_id, const vector<string>& values, const int& slice = -1);
+
+	//! Sets a vector of attribute values of a object that is valid in a time and slice
+	virtual bool setProperties (const string& object_id, const vector<string>& values, TimeType& time, const int& slice = -1);
+	
+	//! Gets a vector of attribute values of a object that is valid in a slice 
+	virtual bool getProperties (const string& object_id, vector<string>& values, const int& slice = -1);
+
+	//! Gets a vector of attribute values of a object that is valid in a time and slice
+	virtual bool getProperties (const string& object_id, vector<string>& values, TimeType& time, const int& slice = -1);
+
+	//! Sets the value of the attribute named "attr_name" of an object that is valid in a slice 
+	virtual bool setAttributeValue (const string& object_id, const string& attr_name,  const string& val, const int& slice = -1);
+
+	//! Sets the value of the attribute named "attr_name" of an object that is valid in a time and slice
+	virtual bool setAttributeValue (const string& object_id, const string& attr_name,  const string& val, TimeType& time, const int& slice = -1);
+
+	//! Sets the value of the i-th attribute of an object that is valid in a slice 
+	virtual bool setAttributeValue (const string& object_id, const int& i, const string& val, const int& slice = -1); 
+
+	//! Sets the value of the i-th attribute of an object that is valid in a time and slice
+	virtual bool setAttributeValue (const string& object_id, const int& i, const string& val, TimeType& time, const int& slice = -1); 
+	
+	//! Get the value of the attribute named "attr_name" of an object that is valid in a slice 
+	virtual bool getAttributeValue (const string& object_id, const string& attr_name,  string& val, const int& slice = -1);
+
+	//! Get the value of the attribute named "attr_name" of an object that is valid in a time and slice
+	virtual bool getAttributeValue (const string& object_id, const string& attr_name,  string& val, TimeType& time, const int& slice = -1);
+
+	//! Gets the value of the i-th attribute of an object that is valid in a slice 
+	virtual bool getAttributeValue (const string& object_id, const int& i, string& val, const int& slice = -1); 
+
+	//! Gets the value of the i-th attribute of an object that is valid in a time and slice
+	virtual bool getAttributeValue (const string& object_id, const int& i, string& val, TimeType& time, const int& slice = -1); 
+
+	//! Adds a new attribute in the attribute list and adds it in all instances in the set using a default value
+	virtual bool addProperty(TeAttributeRep& attr, const string& defaultValue);
+
+	//! Adds a new attribute only in the attribute list
+	virtual bool addProperty(TeAttribute& attr);
+
+	/*!
+		\brief Adds the property or sets its value in the object in a valid slice.
+
+		If there is already the property in the attribute list, sets the value of the instances of an object  
+		valid in a specific slice. If there is no this property in the attribute list, adds it in the attribute
+		list and in all instances in the set. After that, sets the value of the instances of an object  
+		valid in a specific slice.
+	*/
+	virtual bool addProperty(const string& object_id, TeProperty& prop, const int& slice=-1);
+
+	/*!
+		\brief Adds the property or sets its value in the object in a valid time and slice.
+
+		If there is already the property in the attribute list, sets the value of the instances of an object  
+		valid in a specific time and slice. If there is no this property in the attribute list, adds it in the attribute
+		list and in all instances in the set. After that, sets the value of the instances of an object  
+		valid in a specific time and slice.
+	*/
+	virtual bool addProperty(const string& object_id, TeProperty& prop, TimeType& time, const int& slice = -1);
+
+	//! Removes an attribute of the attribute list and removes it of all instances in the set 
+	virtual void removeProperty(TeAttributeRep& attr);
+
+	//! Calculates the bounding box of all instances of all objects included in the set
+	virtual TeBox& getBox();
+
+	//! Sets the bounding box of all instances of all objects included in the set
+	virtual void setBox(TeBox& b)
+	{	box_ = b; }
+
+	//! Clears the set 
+	virtual void clear();  
+		
+	//! Returns an iterator to the first element of the set
+	virtual iterator begin()
+	{	return instances_.begin(); }
+	
+	//! Returns an iterator to the one past last element of the set
+	virtual iterator end()
+	{	return instances_.end(); }
+
+	//! Searchs the instances which bounding boxes intersect a specific bounding box, using the R Tree.
+	virtual bool search(const TeBox& b, vector<InstanceType* >& result);
+
+	//! Fills the ST instance set from a layer or theme, using the given filled parameters
+	virtual bool build(bool loadGeometries=false, bool loadAllAttributes=true, vector<string> attrNames=vector<string>(), int slide=-1); 
+
+	//! Fills the ST instance set from a layer or theme, using the given filled parameters
+	virtual bool build(TeGroupingAttr& groupAttr, bool loadGeometries=false, int slide=-1); 
+
+	
+	/*! \class propertyIterator
+		\brief This class implements an iterator concept over the instance set.
+		
+		A structure that allows the traversal ST element set
+		in a similar way as the STL iterators. This iterator passes over each 
+		ST instance of the ST element set and returns a specific numerical property.
+	*/
+	class propertyIterator
+	{
+		public:
+			//! Constructor
+			propertyIterator (TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>* setIt,
+				typename std::vector<InstanceType>::iterator it,  
+				const string& attrName):
+				attrName_(attrName), attrIndex_(-1), it_(it), setIt_(setIt)
+				{
+					attrIndex_ = setIt_->getAttributeIndex(attrName);
+				}
+
+			//! Constructor
+			propertyIterator (TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>* setIt,
+				typename std::vector<InstanceType>::iterator it,
+				const int& attrIndex):
+				attrName_ (""), attrIndex_(attrIndex), it_(it), setIt_(setIt)
+				{ }
+
+			//! Constructor
+			propertyIterator (typename vector<InstanceType>::iterator it,
+				const int& attrIndex):
+				attrName_ (""), attrIndex_(attrIndex), it_(it)
+				{}
+		
+			//! Moves to the next attribute in the set
+			propertyIterator& operator++()
+			{	
+				++it_;
+				return (*this);
+			}
+
+			//! Returns the current attribute as double
+			double operator*()
+			{	return (*it_)[attrIndex_]; 	}
+			
+			//! Sets a new value to the attrIndex_-th attribute of the element pointed by the iterator
+			void setValue(const double& val)
+			{	it_->setPropertyValue(attrIndex_, Te2String(val)); }
+
+			//! Returns a pointer to the instance set 
+			TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>* elemSet()
+			{	return setIt_; 	}
+
+			//! Equal operator
+			bool operator==(const propertyIterator& rhs) const
+			{	return (this->attrIndex_ == rhs.attrIndex_ && this->it_== rhs.it_); }
+
+			//! Unequal operator
+			bool operator!=(const propertyIterator& rhs) const
+			{	return (this->attrIndex_ != rhs.attrIndex_ || this->it_!= rhs.it_);	}
+
+			//! Deprecated: Returns the numerical property of the current instance.
+			bool getProperty(TeProperty& prop)
+			{	return (*it_).getProperty(prop, attrIndex_); }
+				
+		protected:
+			string										attrName_;	//<! the numerical property name
+			int											attrIndex_;	//<! the numerical property index
+			typename vector<InstanceType>::iterator		it_; 
+			TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>* setIt_; 
+
+	};
+
+	//! Returns a property iterator to the attribute named "attName" of the first instance in the set.
+	propertyIterator begin(const string& attName)
+	{
+		return propertyIterator(this, instances_.begin(), attName); 
+	}
+
+	//! Returns a property iterator to the attIndex-th attribute of the first instance in the set.
+	propertyIterator begin(const int& attIndex)
+	{
+		return propertyIterator(this, instances_.begin(), attIndex); 
+	}
+
+	//! Returns a property iterator to the attribute named "attName" of the one past last element of the set
+	propertyIterator end(const string& attName)
+	{
+		return propertyIterator(this, instances_.end(), attName); 
+	}
+
+	//! Returns a property iterator to the attIndex-th attribute of the one past last element of the set
+	propertyIterator end(const int& attIndex)
+	{
+		return propertyIterator(this, instances_.end(), attIndex); 
+	}
+};
+
+template<typename GeometryType, typename TimeType, typename InstanceType>
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::TeBaseSTInstanceSet() :
+	  theme_(0),  layer_(0), rTree_(0)
+{ 
+	TeAttributeList* att = new TeAttributeList();
+	attrList_ = TeSharedPtr<TeAttributeList>(att);
+}
+
+
+template<typename GeometryType, typename TimeType, typename InstanceType>
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::TeBaseSTInstanceSet(TeTheme* theme, const TeAttributeList& attrList) 
+{
+	layer_ = 0;
+	theme_ = 0;
+	rTree_ = 0;
+	TeAttributeList* att = new TeAttributeList(attrList);
+	attrList_ = TeSharedPtr<TeAttributeList>(att);
+	if(!theme)
+		return;
+	theme_ = theme;
+	rTree_ = new TeSAM::TeRTree<int>(theme_->box());
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType>
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::TeBaseSTInstanceSet(TeLayer* layer, const TeAttributeList& attrList) 
+{
+	layer_ = 0;
+	theme_ = 0;
+	rTree_ = 0;
+	TeAttributeList* att = new TeAttributeList(attrList);
+	attrList_ = TeSharedPtr<TeAttributeList>(att);
+	if(!layer)
+		return;
+	layer_ = layer;
+	rTree_ = new TeSAM::TeRTree<int>(layer_->box());
+}
+
+
+template<typename GeometryType, typename TimeType, typename InstanceType>
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::TeBaseSTInstanceSet(const TeBox& box, const TeAttributeList& attrList)
+{
+	layer_ = 0;
+	theme_ = 0;
+	rTree_ = 0;
+	box_ = box;
+	TeAttributeList* att = new TeAttributeList(attrList);
+	attrList_ = TeSharedPtr< TeAttributeList >(att);
+	if(!box_.isValid())
+		return;
+	rTree_ = new TeSAM::TeRTree<int>(box);
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType>
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::TeBaseSTInstanceSet(const TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>& other) 
+{
+	instances_ = other.instances_;		
+	minTime_ = other.minTime_;
+	maxTime_ = other.maxTime_;
+	attrList_ = other.attrList_;
+	theme_ = other.theme_;	
+	layer_ = other.layer_;	
+	box_ = other.box_;
+	objectIdToInstances_ = other.objectIdToInstances_;
+	timeToInstances_ = other.timeToInstances_;
+	sliceToInstances_ = other.sliceToInstances_;
+	rTree_ = 0;
+		
+	if(other.rTree_)
+	{
+		//Operador de copia nao implementado!
+		//rTree_ = new TeSAM::TeRTree<int>(other.rTree_->getBox());
+		//*rTree_ = *other.rTree_; 
+	}
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType>
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::~TeBaseSTInstanceSet() 
+{
+	if(rTree_)
+		delete rTree_;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>& 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::operator= (const TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>& other)
+{
+	if ( this != &other )
+	{
+		instances_ = other.instances_;		
+		minTime_ = other.minTime_;
+		maxTime_ = other.maxTime_;
+		attrList_ = other.attrList_;
+		theme_ = other.theme_;	
+		layer_ = other.layer_;	
+		box_ = other.box_;
+		objectIdToInstances_ = other.objectIdToInstances_;
+		timeToInstances_ = other.timeToInstances_;
+		sliceToInstances_ = other.sliceToInstances_;
+		if(rTree_)
+			delete rTree_;
+		rTree_ = 0;
+		
+		if(other.rTree_)
+		{
+			//Operador de copia nao implementado!
+			//rTree_ = new TeSAM::TeRTree<int>(other.rTree_->getBox());
+			//*rTree_ = *other.rTree_; 
+		}
+	}
+	return *this;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> void 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setAttributeList(TeAttributeList& attrs)
+{	
+	if(!attrList_.isActive())
+		return;
+	
+	attrList_->clear();
+	TeAttributeList::iterator it = attrs.begin();
+	while(it!=attrs.end())
+	{
+		attrList_->push_back(*it);
+		++it;
+	}
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> int
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getAttributeIndex(const string& attrName) 
+{
+	string newName = TeConvertToUpperCase(attrName); 
+	size_t pos = newName.find(".", 0, 1);
+	if (pos != string::npos)
+		newName = TeConvertToUpperCase(attrName.substr(pos+1));
+	
+	for(unsigned int i=0; i<attrList_->size(); ++i)
+	{
+		string s = TeConvertToUpperCase((*attrList_)[i].rep_.name_); 
+		if((s == TeConvertToUpperCase(attrName)) || (s == newName))
+			return i;
+	}
+	return -1;
+}
+
+
+
+template<typename GeometryType, typename TimeType, typename InstanceType> InstanceType* 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstance(const unsigned int& index)
+{
+	if(index<instances_.size())
+		return &(instances_[index]);
+
+	return 0;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> InstanceType* 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstance(const string& objectId, const int& slice)
+{
+	map<string, vector<int> >::iterator itObj = objectIdToInstances_.find(objectId);
+	if(itObj==objectIdToInstances_.end())
+		return 0;
+
+	if(slice<0)
+	{
+		//The slice is not considered
+		vector<int>::iterator it = itObj->second.begin();
+		if(it==itObj->second.end())
+			return 0;
+		return getSTInstance(*it);
+	}
+
+	map<int, vector<int> >::iterator itSlice = sliceToInstances_.find(slice);
+	if(itSlice==sliceToInstances_.end())
+		return 0;
+
+	vector<int>::iterator it = itObj->second.begin();
+	while(it != itObj->second.end())
+	{
+		vector<int>::iterator it2;
+		it2 = find(itSlice->second.begin(), itSlice->second.end(), *it);
+		if(it2!=itSlice->second.end())
+			return getSTInstance(*it2);
+		++it;
+	}
+	return 0;		
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> InstanceType* 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstance(const string& objectId, TimeType& time, const int& slice)
+{
+	map<string, vector<int> >::iterator itObj = objectIdToInstances_.find(objectId);
+	if(itObj==objectIdToInstances_.end())
+		return 0;
+
+	typename map<TimeType, vector<int> >::iterator itTime = timeToInstances_.find(time);
+	if(itTime==timeToInstances_.end())
+		return 0;
+	
+	if(slice<0)
+	{
+		//The slice is not considered
+		vector<int>::iterator it = itObj->second.begin();
+		while(it != itObj->second.end())
+		{
+			vector<int>::iterator it2;
+			it2 = find(itTime->second.begin(), itTime->second.end(), *it);
+			if(it2!=itTime->second.end())
+				return getSTInstance(*it2);
+			++it;
+		}
+		return 0;
+	}
+	
+	map<int, vector<int> >::iterator itSlice = sliceToInstances_.find(slice);
+	if(itSlice==sliceToInstances_.end())
+		return 0;
+
+	vector<int>::iterator it = itObj->second.begin();
+	while(it != itObj->second.end())
+	{
+		vector<int>::iterator it2, it3;
+		it2 = find(itTime->second.begin(), itTime->second.end(), *it);
+		it3 = find(itSlice->second.begin(), itSlice->second.end(), *it);
+		if((it2!=itTime->second.end()) && (it3!=itSlice->second.end()))
+			return getSTInstance(*it2);
+		++it;
+	}
+	return 0;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> void
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstances(vector<InstanceType* >& set, const string& objectId, const int& slice)
+{
+	set.clear();
+	map<string, vector<int> >::iterator itObj = objectIdToInstances_.find(objectId);
+	if(itObj==objectIdToInstances_.end())
+		return;
+
+	vector<int>::iterator it = itObj->second.begin();
+	while(it != itObj->second.end())
+	{
+		InstanceType* inst = getSTInstance(*it);
+		if((slice<0) || (inst->getSlice()==slice))
+			set.push_back(inst);
+		++it;
+	}
+	return;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> void
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstances(vector<InstanceType* >& set, const string& objectId, TimeType& time, const int& slice)
+{
+	set.clear();
+	map<string, vector<int> >::iterator itObj = objectIdToInstances_.find(objectId);
+	if(itObj==objectIdToInstances_.end())
+		return;
+
+	vector<int>::iterator it = itObj->second.begin();
+	while(it != itObj->second.end())
+	{
+		InstanceType* inst = getSTInstance(*it);
+		if(((slice<0) || (inst->getSlice()==slice)) && (inst->getTime()== time))
+			set.push_back(inst);
+		++it;
+	}
+	return;
+}
+	
+template<typename GeometryType, typename TimeType, typename InstanceType> void
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstances(vector<InstanceType* >& set, TimeType& time, const int& slice)
+{
+	set.clear();
+	typename map<TimeType, vector<int> >::iterator itTime = timeToInstances_.find(time);
+	if(itTime==timeToInstances_.end())
+		return;
+
+	vector<int>::iterator it = itTime->second.begin();
+	while(it != itTime->second.end())
+	{
+		InstanceType* inst = getSTInstance(*it);
+		if((slice<0) || (inst->getSlice()==slice))
+			set.push_back(inst);
+		++it;
+	}
+	return;
+
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> void
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getSTInstances(vector<InstanceType* >& set, const int& slice)
+{
+	set.clear();
+	map<int, vector<int> >::iterator itSlice = sliceToInstances_.find(slice);
+	if(itSlice==sliceToInstances_.end())
+		return;
+
+	vector<int>::iterator it = itSlice->second.begin();
+	while(it != itSlice->second.end())
+	{
+		set.push_back(getSTInstance(*it));
+		++it;
+	}
+	return;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::insertSTInstance (InstanceType& inst)
+{
+	inst.setAttrList(attrList_);
+	instances_.push_back(inst);
+	int index = (instances_.size()-1);
+	vector<int> aux;
+	aux.push_back(index);
+	
+	//object identity information
+	map<string, vector<int> >::iterator itObj = objectIdToInstances_.find(inst.getObjectId());
+	if(itObj!=objectIdToInstances_.end())
+		itObj->second.push_back(index);
+	else
+		objectIdToInstances_[inst.getObjectId()] = aux;
+
+	//time information
+	if(inst.isTimeValid())
+	{
+		typename map<TimeType, vector<int> >::iterator itTime = timeToInstances_.find(inst.getTime());
+		if(itTime!=timeToInstances_.end())
+			itTime->second.push_back(index);
+		else
+			timeToInstances_[inst.getTime()] = aux;
+	}
+
+	//slice information
+	if(inst.getSlice()>=0)
+	{
+		map<int, vector<int> >::iterator itSlice = sliceToInstances_.find(inst.getSlice());
+		if(itSlice!=sliceToInstances_.end())
+			itSlice->second.push_back(index);
+		else
+			sliceToInstances_[inst.getSlice()] = aux;
+	}
+	
+	//insert in the RTree
+	TeBox b = inst.getGeometries().box();
+	if(b.isValid())
+	{
+		if(rTree_)
+			rTree_->insert(b, index);
+		updateBox(box_, b);
+	}
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> int 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::numSTInstance()
+{
+	return instances_.size();
+}
+		
+template<typename GeometryType, typename TimeType, typename InstanceType> int 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::numSTInstance(const string& objectId)
+{
+	map<string, vector<int> >::iterator it = objectIdToInstances_.find(objectId);
+	if(it==objectIdToInstances_.end())
+		return 0;
+	return it->second.size();
+
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> int 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::numSTInstance(const int& slice)
+{
+	map<int, vector<int> >::iterator it = sliceToInstances_.find(slice);
+	if(it==sliceToInstances_.end())
+		return 0;
+	return it->second.size();
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> int 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::numSTInstance(TimeType& time)
+{
+	typename map<TimeType, vector<int> >::iterator it = timeToInstances_.find(time);
+	if(it==timeToInstances_.end())
+		return 0;
+	return it->second.size();
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setGeometry(const string& object_id, GeometryType& geom, const int& slice)
+{
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	aux->setGeometry(geom);
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setGeometry(const string& object_id, GeometryType& geom, TimeType& time, const int& slice)
+{
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	aux->setGeometry(geom);
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getGeometry(const string& object_id, GeometryType& geom, const int& slice)
+{
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	geom = aux->getGeometries(); 
+	return true;
+
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getGeometry(const string& object_id, GeometryType& geom, TimeType& time, const int& slice)
+{
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	geom = aux->getGeometries(); 
+	return true;
+}
+
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getPropertyVector (const string& object_id, TePropertyVector& propVec, const int& slice)
+{
+	propVec.clear();
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	
+	for(unsigned int i=0; i<aux->getProperties().size(); ++i)
+	{
+		TeProperty prop;
+		prop.value_ = aux->getProperties()[i];
+		if(i<attrList_->size())
+			prop.attr_ = (*attrList_)[i];
+		propVec.push_back(prop);
+	}
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getPropertyVector (const string& object_id, 
+	TePropertyVector& propVec, TimeType& time, const int& slice)
+{
+	propVec.clear();
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	
+	for(unsigned int i=0; i<aux->getProperties().size(); ++i)
+	{
+		TeProperty prop;
+		prop.value_ = aux->getProperties()[i];
+		if(i<attrList_->size())
+			prop.attr_ = (*attrList_)[i];
+		propVec.push_back(prop);
+	}
+	return true;
+
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setProperties (const string& object_id, const vector<string>& values, const int& slice)
+{
+	//the number of attributes in each instance must be equal to the number of attibutes
+	//in the attribute list. 
+	if(values.size() != attrList_->size())
+		return false;
+
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	aux->setProperties(values);
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setProperties (const string& object_id, const vector<string>& values, TimeType& time, const int& slice)
+{
+	//the number of attributes in each instance must be equal to the number of attibutes
+	//in the attribute list. 
+	if(values.size() != attrList_->size())
+		return false;
+
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	aux->setProperties(values);
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getProperties (const string& object_id, vector<string>& values, const int& slice)
+{
+	values.clear();
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	values = aux->getProperties();
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getProperties (const string& object_id, vector<string>& values, TimeType& time, const int& slice)
+{
+	values.clear();
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	values = aux->getProperties();
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setAttributeValue (const string& object_id, const string& attr_name,  const string& val, const int& slice)
+{
+	int index = this->getAttributeIndex(attr_name);
+	return this->setAttributeValue(object_id, index, val, slice);
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setAttributeValue (const string& object_id, const string& attr_name, const string& val, TimeType& time, const int& slice)
+{
+	int index = this->getAttributeIndex(attr_name);
+	return this->setAttributeValue(object_id, index, val, time, slice);
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setAttributeValue (const string& object_id, const int& i, const string& val, const int& slice)
+{
+	if(i<0 || i>=(int)attrList_->size()) //if there is not this attribute, return false 
+		return false;
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	aux->setPropertyValue(i, val); 
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::setAttributeValue (const string& object_id, const int& i, const string& val, TimeType& time, const int& slice)
+{
+	if(i<0 || i>=(int)attrList_->size()) //if there is not this attribute, return false 
+		return false;
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	aux->setPropertyValue(i, val); 
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getAttributeValue (const string& object_id, const string& attr_name,  string& val, const int& slice)
+{
+	int index = this->getAttributeIndex(attr_name);
+	return this->getAttributeValue(object_id, index, val, slice);
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getAttributeValue (const string& object_id, const string& attr_name,  string& val, TimeType& time, const int& slice)
+{
+	int index = this->getAttributeIndex(attr_name);
+	return this->getAttributeValue(object_id, index, val, time, slice);
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getAttributeValue (const string& object_id, const int& i, string& val, const int& slice)
+{
+	if(i<0 || i>=(int)attrList_->size())
+		return false;
+	InstanceType* aux = this->getSTInstance(object_id, slice);
+	if(!aux)
+		return false;
+	val = aux->getProperties()[i];
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getAttributeValue (const string& object_id, const int& i, string& val, TimeType& time, const int& slice)
+{
+	if(i<0 || i>=(int)attrList_->size())
+		return false;
+	InstanceType* aux = this->getSTInstance(object_id, time, slice);
+	if(!aux)
+		return false;
+	val = aux->getProperties()[i];
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::addProperty(TeAttributeRep& attr, const string& defaultValue)
+{
+	//verify if there is this attribute
+	if(getAttributeIndex(attr.name_)>=0) 
+		return true;
+
+	TeAttribute at;
+	at.rep_ = attr;
+	attrList_->push_back(at);
+	typename vector<InstanceType>::iterator it = instances_.begin();	
+	
+	//the number of attributes in each instance must be equal to the number of attibutes
+	//in the attribute list.
+	if((attrList_->size()-1) != it->getProperties().size())
+		return false;
+	while(it!=instances_.end())
+	{	
+		it->addPropertyValue(defaultValue);
+		++it;
+	}
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::addProperty(TeAttribute& attr)
+{
+	//verify if there is this attribute
+	if(getAttributeIndex(attr.rep_.name_)<0) 
+		attrList_->push_back(attr);
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::addProperty(const string& object_id, TeProperty& prop, const int& slice)
+{
+	int index = this->getAttributeIndex(prop.attr_.rep_.name_); 
+	if(index<0)
+	{
+		//adds this new attribute in the attr list and in all instances
+		attrList_->push_back(prop.attr_);
+		typename vector<InstanceType>::iterator it =	instances_.begin();		
+		while(it!=instances_.end())
+		{
+			if( (object_id == it->getObjectId()) && ((slice<0) || (slice==it->getSlice())))  
+				it->addPropertyValue(prop.value_);
+			else
+				it->addPropertyValue(string(""));
+			++it;
+		}
+		return true;
+	}
+	
+	//Sets this attribute value
+	typename vector<InstanceType>::iterator it =	instances_.begin();		
+	while(it!=instances_.end())
+	{
+		if( (object_id == it->getObjectId()) && ((slice<0) || (slice==it->getSlice())))  
+			it->setPropertyValue(index, prop.value_);
+		++it;
+	}
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::addProperty(const string& object_id, TeProperty& prop, TimeType& time, const int& slice)
+{
+	int index = this->getAttributeIndex(prop.attr_.rep_.name_); 
+	if(index<0)
+	{
+		//adds this new attribute in the attr list and in all instances
+		attrList_->push_back(prop.attr_);
+		typename vector<InstanceType>::iterator it =	instances_.begin();		
+		while(it!=instances_.end())
+		{
+			if( (object_id == it->getObjectId()) && 
+				(time == it->getTime()) && 
+				((slice<0) || (slice==it->getSlice())))  
+				it->addPropertyValue(prop.value_);
+			else
+				it->addPropertyValue(string(""));
+			++it;
+		}
+		return true;
+	}
+	
+	//Sets this attribute value
+	typename vector<InstanceType>::iterator it =	instances_.begin();		
+	while(it!=instances_.end())
+	{
+		if( (object_id == it->getObjectId()) && 
+			(time == it->getTime()) && 
+			((slice<0) || (slice==it->getSlice())))  
+			it->setPropertyValue(index, prop.value_);
+		++it;
+	}
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> void
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::removeProperty(TeAttributeRep& attr)
+{
+	//Remove of the attribute list
+	string newName = TeConvertToUpperCase(attr.name_); 
+	size_t pos = attr.name_.find(".", 0, 1);
+	if (pos != string::npos)
+		newName = TeConvertToUpperCase(attr.name_.substr(pos+1));
+	
+	unsigned int index = 0;
+	TeAttributeList::iterator it = attrList_->begin();
+	while(it!=attrList_->end())
+	{
+		string s = TeConvertToUpperCase(it->rep_.name_); 
+		if((s == TeConvertToUpperCase(attr.name_)) || (s == newName))
+		{
+			attrList_->erase(it);
+			break;
+		}
+		++it;
+		++index;
+	}
+
+	//Remove of all instances
+	typename vector<InstanceType>::iterator it2 = instances_.begin();		
+	while(it2!=instances_.end())
+	{
+		it2->removePropertyValue(index);
+		++it;
+	}
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> TeBox& 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::getBox()
+{
+	if(box_.isValid())
+		return box_;
+
+	if (instances_.size() <= 0)
+		return box_;
+
+	typename TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::iterator it = this->begin();
+	
+	while (it != this->end())
+	{
+		updateBox(box_,it->getGeometries().box());
+		++it;
+	}
+	return box_;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> void 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::clear()
+{
+	instances_.clear();
+	attrList_->clear();
+	objectIdToInstances_.clear();
+	timeToInstances_.clear();
+	sliceToInstances_.clear();
+	if(rTree_)
+		rTree_->clear(); 
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::search(const TeBox& b, vector<InstanceType* >& result)
+{
+	if(!rTree_ )
+		return false;
+
+	vector<int> intResult;
+	rTree_->search(b, intResult);
+	for(unsigned int i=0; i<intResult.size(); ++i)
+		result.push_back(getSTInstance(intResult[i])); 
+	return true;
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::build(bool loadGeometries, bool loadAllAttributes, vector<string> attrNames, int slide)
+{
+	TeQuerierParams param;
+	if(theme_)
+		param.setParams(theme_);
+	else if(layer_)
+		param.setParams(layer_);
+	else
+		return false;
+
+	param.setFillParams(loadGeometries, loadAllAttributes, attrNames);
+	TeQuerier querier(param);
+	return(buildImpl(&querier, slide));
+}
+
+template<typename GeometryType, typename TimeType, typename InstanceType> bool 
+TeBaseSTInstanceSet<GeometryType, TimeType, InstanceType>::build(TeGroupingAttr& groupAttr, bool loadGeometries, int slide)
+{
+	TeQuerierParams param;
+	if(theme_)
+		param.setParams(theme_);
+	else if(layer_)
+		param.setParams(layer_);
+	else
+		return false;
+
+	param.setFillParams(loadGeometries, groupAttr);
+	TeQuerier querier(param);
+	return(buildImpl(&querier, slide));
+}
+
+
+#endif
+
diff --git a/src/terralib/kernel/TeBox.cpp b/src/terralib/kernel/TeBox.cpp
new file mode 100644
index 0000000..c583b0d
--- /dev/null
+++ b/src/terralib/kernel/TeBox.cpp
@@ -0,0 +1,213 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeBox.h"
+#include "TeGeometry.h"
+
+void zoomIn ( TeBox& box, double t )
+{
+		TeCoord2D c = box.center ();
+		double w    = box.width ()*t/2.;
+		double h    = box.height ()*t/2.;
+		box.x1_ = c.x() - w;
+		box.x2_ = c.x() + w;
+		box.y1_ = c.y() - h;
+		box.y2_ = c.y() + h;
+}
+
+
+void zoomOut ( TeBox& box, double t )
+{
+		TeCoord2D c = box.center ();
+		double w = box.width ()/t/2.;
+		double h = box.height ()/t/2.;
+		box.x1_ = c.x() - w;
+		box.x2_ = c.x() + w;
+		box.y1_ = c.y() - h;
+		box.y2_ = c.y() + h;
+}
+
+// --- UPDATE BOX
+
+void
+updateBox ( TeBox& box, const TeCoord2D& pt )
+{
+	if ( pt.x() <= box.x1_ )
+		box.x1_  = pt.x();
+	
+	if ( pt.x() >= box.x2_ )
+		 box.x2_ =  pt.x();
+
+	if ( pt.y() <= box.y1_ )
+		box.y1_ =  pt.y();
+
+	if ( pt.y() >= box.y2_ )
+		box.y2_ =  pt.y();
+}
+
+void
+updateBox ( TeBox& box, const TeBox& other )
+{
+		if ( other.x1_ <= box.x1_ ) 
+			box.x1_ = other.x1_;
+		if ( other.x2_ >= box.x2_ )
+			box.x2_ = other.x2_;
+		if ( other.y1_ <= box.y1_ )
+			box.y1_ = other.y1_;
+		if ( other.y2_ >= box.y2_ )
+			box.y2_ = other.y2_;
+}
+
+void
+updateBox ( TeBox& box, const TeGeometry& geo )
+{
+		updateBox ( box, geo.box() );
+}
+
+TeBox 
+makeBox(double x1, double y1, double x2, double y2, const double& tol)
+{
+	double xlo, xhi;
+
+	if(x1 > x2)
+	{
+		xhi = x1;
+		xlo = x2;
+	}
+	else
+	{
+		xhi = x2;
+		xlo = x1;
+	}
+
+	double ylo, yhi;	
+	if(y1 > y2)
+	{
+		yhi = y1;
+		ylo = y2;
+	}
+	else
+	{
+		yhi = y2;
+		ylo = y1;
+	}
+
+	return TeBox(xlo - tol, ylo - tol, xhi + tol, yhi + tol);
+}
+
+
+TeBox 
+adjustToCut(TeBox& box, double bWidth, double bHeight)
+{
+	double auxD;
+	int auxI;
+
+	int magicX; 
+	auxD = box.x1()/bWidth;
+	auxI = (int)(box.x1()/bWidth);
+	if (box.x1() < 0 && (auxD - auxI) != 0)
+		magicX = (int) (box.x1()/bWidth - 1);
+	else
+		magicX = auxI;
+
+	int magicY;
+	auxD = box.y1()/bHeight;
+	auxI = (int)(box.y1()/bHeight);
+	if (box.y1() < 0 && (auxD - auxI) != 0)
+		magicY  = (int)(box.y1()/bHeight - 1);
+	else
+		magicY  = auxI;
+		
+	double xi = magicX*bWidth;
+	double yi = magicY*bHeight;
+
+	int magicX2;
+	auxD = box.x2()/bWidth;
+	auxI = (int)(box.x2()/bWidth);
+	if ((box.x2() < 0) || (auxD - auxI) == 0)
+		magicX2 = (int) (box.x2()/bWidth);
+	else
+		magicX2 = (int) (box.x2()/bWidth + 1);
+
+
+	int magicY2;
+	auxD = box.y2()/bHeight;
+	auxI = (int)(box.y2()/bHeight);
+	if ((box.y2() < 0) || (auxD - auxI) == 0)
+		magicY2 = (int) (box.y2()/bHeight);
+	else
+		magicY2 = (int) (box.y2()/bHeight + 1);
+
+
+	double xf = (magicX2)*bWidth;
+	double yf = (magicY2)*bHeight;
+
+	return TeBox(xi,yi,xf,yf);
+}
+
+TePolygon polygonFromBox( TeBox& bb )
+{
+	TePolygon poly;
+	TeLine2D line;
+	
+	TeCoord2D ll (bb.x1_, bb.y1_);
+	TeCoord2D ul (bb.x1_, bb.y2_);
+	TeCoord2D ur (bb.x2_, bb.y2_);
+	TeCoord2D lr (bb.x2_, bb.y1_);
+
+	line.add(ll);
+	line.add(ul);
+	line.add(ur);
+	line.add(lr);
+	line.add(ll);
+
+	TeLinearRing ring(line);
+	poly.add(ring);
+	return poly;
+}
+
+int adjustBox( TeBox& bb )
+{
+	int precision = 4;
+	double factor =  pow(10., precision);
+	double tol = 1 / factor;
+	while (( TeCompareDouble( bb.x1_, bb.x2_, precision ) == true ) || 
+		   ( TeCompareDouble( bb.y1_, bb.y2_, precision ) == true ) )
+	{
+		precision--;
+		tol = 1 / pow(10., precision);
+		if ( TeCompareDouble( bb.x1_, bb.x2_, precision ) == true )
+		{
+			bb.x1_ -= tol;
+			bb.x2_ += tol;
+		}
+		if ( TeCompareDouble( bb.y1_, bb.y2_, precision ) == true )
+		{
+			bb.y1_ -= tol;
+			bb.y2_ += tol;
+		}
+		if (precision == 0)
+			break;		
+	}
+	return precision;
+}
diff --git a/src/terralib/kernel/TeBox.h b/src/terralib/kernel/TeBox.h
new file mode 100644
index 0000000..62b782b
--- /dev/null
+++ b/src/terralib/kernel/TeBox.h
@@ -0,0 +1,218 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeBox.h
+    \brief This file contains structures and definitions to deal with a box
+*/
+#ifndef  __TERRALIB_INTERNAL_BOX_H
+#define  __TERRALIB_INTERNAL_BOX_H
+
+#include "TeDefines.h"
+#include "TeCoord2D.h"
+#include "TeDefines.h"
+#include "float.h"
+
+class TeGeometry;
+class TePolygon;
+
+//! Provides support for dealing with a rectangular a box. Used by all geometrical representations
+/*!
+ \sa
+	TeCoord2D
+ */
+struct TL_DLL TeBox {
+
+	enum TeBoxCorner { TeLOWERLEFT=0, TeUPPERLEFT=1, TeLOWERRIGHT=2, TeUPPERRIGHT=3 };
+
+//! Default constructor 
+/*!
+	\param x1 X value of the lower left box coordinate 
+	\param y1 Y value of the lower left box coordinate 
+	\param x2 X value of the upper right box coordinate 
+	\param y2 Y value of the upper right box coordinate 
+*/
+	TeBox ( const double& x1 = TeMAXFLOAT, const double y1 = TeMAXFLOAT,
+		  const double& x2 = -TeMAXFLOAT, const double y2 = -TeMAXFLOAT ):
+		  x1_ ( x1 ), y1_ ( y1 ), x2_ ( x2 ), y2_ ( y2 ) {}
+
+//! Constructor from corners as TeCoord2D objects
+/*!
+	\param p1 lower left box coordinate
+	\param p2 upper right box coordinate
+*/
+	TeBox( const TeCoord2D& p1, const TeCoord2D& p2 ):
+		x1_ ( p1.x() ), y1_ ( p1.y() ),
+		x2_ ( p2.x() ), y2_ ( p2.y() )
+		{}
+
+//! Copy constructor
+	TeBox ( const TeBox& rhs )
+	{
+		x1_ = rhs.x1_;
+		x2_ = rhs.x2_;
+		y1_ = rhs.y1_;
+		y2_ = rhs.y2_;
+	}
+
+//! Operator =
+	TeBox& operator=(const TeBox& rhs)
+	{
+		if ( this == &rhs )
+			return *this;
+		else
+		{
+		x1_ = rhs.x1_;
+		x2_ = rhs.x2_;
+		y1_ = rhs.y1_;
+		y2_ = rhs.y2_;
+		}
+		return *this;
+	}
+
+//!	Returns TRUE if current TeBox is equal to box; otherwise returns FALSE 
+	bool operator== (const TeBox& box) const 
+	{return (  ( fabs (y1_ - box.y1_) < TePrecision::instance().precision() ) 
+			&& ( fabs (x1_ - box.x1_) < TePrecision::instance().precision() ) 
+			&& ( fabs (y2_ - box.y2_) < TePrecision::instance().precision() ) 
+			&& ( fabs (x2_ - box.x2_) < TePrecision::instance().precision() ) 
+			); }
+      
+//! Returns FALSE if current TeBox is equal to box; otherwise returns TRUE 
+  bool operator!= (const TeBox& box) const
+  {
+    return ( ! operator==( box ) );
+  }      
+
+//! Returns the coordinate corresponding to the geometric center of the  box
+	TeCoord2D center() const
+	{	
+		TeCoord2D p ( (  ( x1_ + x2_ ) / 2.), ( ( y1_ + y2_ ) / 2.) );
+		return p;
+	}	
+
+//!	Returns TRUE if current box is valid; otherwise returns FALSE 
+	bool isValid() const
+	{
+		if (x1_ == TeMAXFLOAT || y1_ == TeMAXFLOAT || 
+		    x2_ == -TeMAXFLOAT || y2_ == -TeMAXFLOAT  ||
+			x1_ > x2_ || y1_ > y2_)
+			return false;
+		if( TeISNAN(x1_) || TeISNAN(y1_) || TeISNAN(x2_) || TeISNAN(y2_))
+			return false;
+		return true;
+	}
+
+//! Returns the x component of the lower left corner
+	const double& x1 () const 
+	{ return x1_;}
+
+//! Returns the y component of the lower left corner
+	const double& y1 () const 
+	{ return y1_;}
+
+//! Returns the x component of the upper right corner
+	const double& x2 () const 
+	{ return x2_;}
+
+//! Returns the y component of the upper right corner
+	const double& y2 () const 
+	{ return y2_;}
+
+//! Returns the box width 
+	double width () const 
+	{ return x2_ - x1_; }
+	
+//! Returns the box height 
+	double height () const 
+	{ return y2_ - y1_; }
+	
+//! Returns the lower left coordinate of the box 
+	TeCoord2D lowerLeft() const 
+	{ return TeCoord2D ( x1_, y1_ );}
+
+//! Returns the upper right coordinate of the box 
+	TeCoord2D upperRight() const
+	{ return TeCoord2D (x2_,y2_);}
+
+//! Destructor
+	~TeBox() {}  
+	
+	double x1_, //!< x coordinate of the lower left corner
+		   y1_,	//!< y coordinate of the lower left corner
+		   x2_,	//!< x coordinate of the upper right corner
+		   y2_;	//!< y coordinate of the upper right corner	
+
+};
+
+// ALGORITHMS THAT USE A BOX
+
+/*! \fn void updateBox void updateBox ( TeBox& box, const TeCoord2D& pt ) 
+   \brief update a box to include a coordinate
+ */
+TL_DLL void updateBox ( TeBox& box, const TeCoord2D& pt );  
+
+/*! \fn void updateBox void updateBox ( TeBox& box, const TeBox& other ) 
+   \brief update a box to include another box
+ */
+TL_DLL void updateBox ( TeBox& box, const TeBox& other );
+
+/*! \fn void updateBox ( TeBox& box, const TeGeometry& geo ) 
+   \brief update a box to include a geometry
+ */
+TL_DLL void updateBox ( TeBox& box, const TeGeometry& geo );
+
+
+// ZOOMING FUNCTIONS 
+
+/*! \fn void zoomIn void zoomIn ( TeBox& box, double t = .8) 
+   \brief increases the box by a factor t
+ */
+TL_DLL void zoomIn ( TeBox& box, double t = .8); 
+
+/*! \fn  void zoomOut void zoomOut ( TeBox& box, double t = .8) 
+   \brief decreases box by a factor of t
+ */
+TL_DLL void zoomOut ( TeBox& box, double t = .8);
+ 
+/*! \fn  TeBox makeBox(double x1, double y1, double x2, double y2, const double& tol = 0.0) 
+   \brief builds a box 
+ */
+TL_DLL TeBox makeBox(double x1, double y1, double x2, double y2, const double& tol = 0.0);
+
+/*! \fn  TeBox adjustToCut(TeBox& box, double bWidth, double bHeight) 
+   \brief finds the correspondent smallest box that allows a box to be cut in blocks of a given size 
+ */
+TL_DLL TeBox adjustToCut(TeBox& box, double bWidth, double bHeight);
+
+/*! \fn TePolygon polygonFromBox(TeBox& bb) 
+   \brief builds a TePolygon geometry from a box
+ */
+TL_DLL TePolygon polygonFromBox( TeBox& bb );
+
+/*! \fn  TeBox adjust()
+\brief Expands the box when has not width or height. Returns the precision level needed.
+*/
+TL_DLL int adjustBox( TeBox& bb );
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeBufferRegion.cpp b/src/terralib/kernel/TeBufferRegion.cpp
new file mode 100644
index 0000000..a20456a
--- /dev/null
+++ b/src/terralib/kernel/TeBufferRegion.cpp
@@ -0,0 +1,1073 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+/*
+   TODO: 1. tentar otimizar as rotinas auxilixares (elementares) de forma que o sentido do segmento nao seja importante
+            e que possamos garantir a orientacao da linha que iremos tracar ao redor de um segmento de reta (acabar dom didswap!)
+*/
+
+#include "TeBufferRegion.h"
+#include "TeOverlay.h"
+#include "TeGeometry.h" 
+#include "TeGeometryAlgorithms.h"
+
+#include <map>
+#include <algorithm>
+#include <cmath>
+
+using namespace std;
+
+namespace TeBUFFERREGION
+{
+
+//---------------- Auxiliary Constants ----------------//
+const double bufferPI       = 3.14159265358979323846;
+const double doubleBufferPI = 6.28318530717958647692;
+const double halfBufferPI   = 1.57079632679489661923;
+
+//---------------- Auxiliary Functions ----------------//
+
+/** Rotina auxiliar que define o angulo inicial utilizado para tracar o buffer ao redor de um segmento de reta (rotina de uso interno - nao deve ser utilizada diretamente).
+		\param first	primeiro ponto que define o segmento de reta: a rotina pode inverter seu conteudo com o parametro "last"
+		\param last		segundo ponto que define o segmento de reta: a rotina pode inverter seu conteudo com o parametro "first"
+		\param ang		angulo que define uma linha perpendicular ao segmento passando pela coordenada first
+		\param didswap	indica se as coordenadas first e last foram trocadas (se foi realizado o swap delas)
+		\note As coordenadas first e last devem ser necessariamente diferentes.
+  */
+inline void TeFindInitialAng(TeCoord2D& first, TeCoord2D& last, double& ang, bool& didswap)
+{
+	double xLength  = 0.0;
+	double val_ang  = 0.0;
+	
+	if(first.x_ > last.x_)
+	{
+	    swap(first, last);
+		didswap = true;
+	}
+	else if(first.x_ == last.x_)
+	{
+		if(first.y_ < last.y_)
+		{
+			swap(first, last);
+			didswap = true;
+		}
+	}
+
+// cumprimeto do segmento ao longo do eixo "x"
+	xLength = last.x_ - first.x_;
+
+// cumprimento do segmento 
+	double segmentLength = TeDistance(first, last);
+
+// inclinacao do segmento
+	val_ang = xLength / segmentLength;
+
+	if(val_ang > 1.0)	// erros de arredondamento podem definir um valor um "pouco" maior que 1, e nesse caso arredondamos para 1.
+	{
+		val_ang = 1.0;
+	}
+	else if(val_ang < -1.0)	// erros de arredondamento podem definir um valor um "pouco" menor que -1, e nesse caso arredondamos para 1.
+	{
+		val_ang = -1.0;
+	}
+	else if(fabs(val_ang) <= 0.000000000000001)	// erros de arredondamento podem definir um valor um "pouco" maior que zero, e nesse caso arredondamos para 0.
+	{
+		ang = 0.0;
+	}
+	else
+	{
+		if(first.y_ == last.y_)		// se o segmento for horizontal, o angulo inicial sera: (pi / 2)
+			ang = halfBufferPI;
+		else
+			if(first.y() > last.y())
+				ang = asin(val_ang);
+			else
+				ang = acos(val_ang) + halfBufferPI;
+	}
+
+	return;
+}
+
+/** Rotina auxiliar que traca um buffer elementar ao redor de um segmento, arredondando apenas um dos cantos do segmento: a linha do buffer tera orientacao horaria.
+		\param first	       primeiro ponto que define o segmento de reta.
+		\param last		       segundo ponto que define o segmento de reta.
+		\param bufferDistance  distancia utilizada para tracar o buffer.
+		\param numPoints       numero de pontos utilizado na definicao da semi-circunferencia ao redor dos vertices.
+		\param bufferLevels	   numero de niveis do buffer.
+		\param bufferPols	   linhas no sentido horario que definem a linha de buffer de cada nivel.
+  */
+inline void TeElementarBuffer(TeCoord2D first, TeCoord2D last, const double& bufferDistance,
+                              const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygon>& bufferPols)
+{
+	bufferPols.clear();
+
+	double ang = 0.0;		// angulo que define uma linha perpendicular ao primeiro vertice do segmento
+	bool didswap = false;	// indica se a rotina TeFindInitialAng fez o swap das coordenadas first e last
+
+	TeFindInitialAng(first, last, ang, didswap);
+
+	ang += bufferPI;	// como vamos tracar as linhas no sentido horario, vamos comecar 180 graus depois e entao vamos decrementando
+
+	double deltaAng = bufferPI / (numPoints - 1);	// angulo de cada setor que compoem o buffer
+	double c = 0.0; // variavel que contera o resultado do cosseno de um angulo
+	double s = 0.0;	// variavel que contera o resultado do seno de um angulo
+	double x = 0.0;	// variavel que contera a coordenada x transladada
+	double y = 0.0; // variavel que contera a coordenada y transladada
+
+// incializa a linha que delimitara cada nivel de buffer
+	vector<TeLine2D> bufferLines;
+
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TeLine2D newLine;
+		bufferLines.push_back(newLine);
+	}
+
+// verifica se o segmento foi ou nao invertido: isso eh importante para podermos manter a orientacao da linha de buffer
+// que estamos criando
+	if(didswap)
+	{
+// para cada extremo, calcula uma semi-circunferencia
+		for(unsigned int i = 1; i < numPoints; ++i)
+		{
+			c = cos(ang);
+			s = sin(ang);
+
+// repete o procedimento para cada nivel do buffer
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+			{
+				x = first.x() + bufferDistance * (j + 1) * c ;
+				y = first.y() + bufferDistance * (j + 1) * s ;
+				bufferLines[j].add(TeCoord2D(x, y));
+			}
+	
+			ang -= deltaAng;
+		}
+
+// coloca o ultimo ponto do primeiro arco
+		c = cos(ang);
+		s = sin(ang);		
+
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{
+// coloca o ultimo ponto do primeiro arco
+			x = first.x() + bufferDistance * (j + 1) * c; 
+			y = first.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+
+// coloca o primeiro ponto do segundo arco
+			x = last.x() + bufferDistance * (j + 1) * c ; 
+			y = last.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+		}
+
+// coloca o ultimo ponto do segundo arco
+		ang -= bufferPI;
+
+		c = cos(ang);
+		s = sin(ang);
+
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{		
+			x = last.x() + bufferDistance * (j + 1) * c; 
+			y = last.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+
+// fecha a linha: que jah se encontra no sentido horario
+			bufferLines[j].add(bufferLines[j][0]);
+
+// cria o poligono correspondente e coloca no vetor de saida
+			TePolygon pol;
+			pol.add(TeLinearRing(bufferLines[j]));
+			bufferPols.push_back(pol);
+		}
+	}
+	else
+	{
+// coloca o primeiro ponto do primeiro arco
+		c = cos(ang);
+		s = sin(ang);
+
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{		
+			x = first.x() + bufferDistance * (j + 1) * c; 
+			y = first.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+		}
+
+// coloca o ultimo ponto do primeiro arco
+		ang -= bufferPI;
+
+		c = cos(ang);
+		s = sin(ang);
+		
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{		
+// coloca o ultimo ponto do primeiro arco
+			x = first.x() + bufferDistance * (j + 1) * c; 
+			y = first.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+
+// coloca o primeiro ponto do segundo arco
+			x = last.x() + bufferDistance * (j + 1) * c ; 
+			y = last.y() + bufferDistance * (j + 1) * s ;
+			bufferLines[j].add(TeCoord2D(x, y));
+		}
+
+// coloca os pontos do ultimo arco
+		for(unsigned int i = 1; i < numPoints; ++i)
+		{
+			ang -= deltaAng;
+
+			c = cos(ang);
+			s = sin(ang);
+
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+			{		
+				x = last.x() + bufferDistance * (j + 1) * c ; 
+				y = last.y() + bufferDistance * (j + 1) * s ;
+				bufferLines[j].add(TeCoord2D(x, y));
+			}
+		}
+
+// fecha cada linha, que jah deve estar no sentido horario
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{
+			bufferLines[j].add(bufferLines[j][0]);
+
+// cria o poligono correspondente e coloca no vetor de saida
+			TePolygon pol;
+			pol.add(TeLinearRing(bufferLines[j]));
+			bufferPols.push_back(pol);
+		}
+	}
+
+	return;
+}
+
+/** Rotina auxiliar que traca um buffer elementar ao redor de um segmento, arredondando os dois cantos do segmento: a linha do buffer tera orientacao horaria.
+		\param first	       primeiro ponto que define o segmento de reta.
+		\param last		       segundo ponto que define o segmento de reta.
+		\param bufferDistance  distancia utilizada para tracar o buffer.
+		\param numPoints       numero de pontos utilizado na definicao da semi-circunferencia ao redor dos vertices.
+		\param bufferLevels	   numero de niveis do buffer.
+		\param bufferPols	   linhas no sentido horario que definem a linha de buffer de cada nivel.
+  */
+inline void TeFullElementarBuffer(TeCoord2D first, TeCoord2D last, const double& bufferDistance,
+							      const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygon>& bufferPols)
+{
+	bufferPols.clear();
+
+	double ang = 0.0;		// angulo que define uma linha perpendicular ao primeiro vertice do segmento
+	bool didswap = false;	// indica se a rotina TeFindInitialAng fez o swap das coordenadas first e last
+
+	TeFindInitialAng(first, last, ang, didswap);
+
+	ang += bufferPI;	// como vamos tracar as linhas no sentido horario, vamos comecar 180 graus depois e entao vamos decrementando
+
+	double deltaAng = bufferPI / (numPoints - 1);	// angulo de cada setor que compoem o buffer
+	double c = 0.0; // variavel que contera o resultado do cosseno de um angulo
+	double s = 0.0;	// variavel que contera o resultado do seno de um angulo
+	double x = 0.0;	// variavel que contera a coordenada x transladada
+	double y = 0.0; // variavel que contera a coordenada y transladada
+
+// incializa a linha que delimitara cada nivel de buffer
+	vector<TeLine2D> bufferLines;
+
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TeLine2D newLine;
+		bufferLines.push_back(newLine);
+	}
+
+// para cada extremo, calcula uma semi-circunferencia
+	for(unsigned int i = 1; i < numPoints; ++i)
+	{
+		c = cos(ang);
+		s = sin(ang);
+
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{		
+			x = first.x() + bufferDistance * (j + 1) * c; 
+			y = first.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+		}
+
+		ang -= deltaAng;
+	}
+
+	c = cos(ang);
+	s = sin(ang);
+
+	for(unsigned int j = 0; j < bufferLevels; ++j)
+	{	
+// coloca o ultimo ponto da primeira semi-circunferencia
+		x = first.x() + bufferDistance * (j + 1) * c; 
+		y = first.y() + bufferDistance * (j + 1) * s;
+		bufferLines[j].add(TeCoord2D(x, y));
+
+// coloca o primeiro ponto da segunda semi-circunferencia
+		x = last.x() + bufferDistance * (j + 1) * c; 
+		y = last.y() + bufferDistance * (j + 1) * s;
+		bufferLines[j].add(TeCoord2D(x, y));
+	}
+
+// coloca os demais pontos da segunda semi-circunferencia
+	for(unsigned int i = 1; i < numPoints; ++i)
+	{
+		ang -= deltaAng;
+
+		c = cos(ang);
+		s = sin(ang);
+
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+		{		
+			x = last.x() + bufferDistance * (j + 1) * c; 
+			y = last.y() + bufferDistance * (j + 1) * s;
+			bufferLines[j].add(TeCoord2D(x, y));
+		}
+	}
+
+// fecha cada linha, que jah deve estar no sentido horario
+	for(unsigned int j = 0; j < bufferLevels; ++j)
+	{
+		bufferLines[j].add(bufferLines[j][0]);
+
+// cria o poligono correspondente e coloca no vetor de saida
+		TePolygon pol;
+		pol.add(TeLinearRing(bufferLines[j]));
+		bufferPols.push_back(pol);
+	}
+
+	return;
+}
+
+/** Rotina auxiliar que traca um buffer ao redor de uma linha, tracando varios niveis independentemente um do outro: para cada nivel de buffer, o anel externo do poligono estara no sentido horario e os buracos estarao no sentido anti-horario.
+		\param line	           linha para a qual os buffers serao tracados.
+		\param bufferDistance  distancia utilizada para tracar o buffer.
+		\param numPoints       numero de pontos utilizados para construcao dos semi-circulos de cada segmento.
+		\param bufferLevels    numero de niveis do buffer.
+		\param polVec          vetor de saida com os poligonos de buffer de cada nivel: nao aninhados, isto e, possivelmente estao sobrepostos, sendo o ratamento dado em outras rotinas de mais alto nivel (que utilizam esta como suporte).
+  */
+inline bool TeLineBuffer(const TeLine2D& line, const double& bufferDistance, const unsigned int& numPoints,
+						 const unsigned int& bufferLevels, vector<TePolygon>& polVec)
+{
+	polVec.clear();
+
+	unsigned int nStep = line.size();
+
+	if(nStep < 2)
+		return false;
+
+// vetor auxiliar que contera em cada posicao um polygonset
+// com todos os poligonos elementares de um determinado nivel de buffer
+	vector<TePolygonSet> psAux;
+
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TePolygonSet pset;
+		psAux.push_back(pset);
+	}
+
+// para linhas fechadas poderemos tracar somente buffer elementares com metade dos arcos
+// enquanto que para linhas abertas, o buffer do primeiro segmento sera feito com um buffer elementar completo (os dois semi-circulos serao tracados).
+// a seguir, computaremos os buffers elementares de cada nivel.
+	if(line.isRing())
+	{
+		for(unsigned int i = 1; i < nStep; ++i)
+		{
+// gera os poliginos elementares a partir dos segmentos definidos por cada par de vertice
+			vector<TePolygon> pols;
+			TeElementarBuffer(line[i - 1], line[i], bufferDistance, numPoints, bufferLevels, pols);
+
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+				psAux[j].add(pols[j]);
+		}
+	}
+	else
+	{
+// para linhas abertas, o primeiro segmento tem um tratamento diferenciado enquanto os demais nao terao
+		vector<TePolygon> pols;
+		TeFullElementarBuffer(line[0], line[1], bufferDistance, numPoints, bufferLevels, pols);
+
+		for(unsigned int j = 0; j < bufferLevels; ++j)
+			psAux[j].add(pols[j]);
+
+		for(unsigned int i = 2; i < nStep; ++i)
+		{
+// gera os poliginos elementares a partir dos segmentos definidos por cada par de vertice
+			TeElementarBuffer(line[i - 1], line[i], bufferDistance, numPoints, bufferLevels, pols);
+
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+				psAux[j].add(pols[j]);
+		}
+	}
+
+// agora, com os buffers elementares de cada nivel jah computados, vamos fazer
+// a uniao dos buffers elementares de cada nivel individualmente
+	for(unsigned int j = 0; j < bufferLevels; ++j)
+	{
+		TePolygonSet polSetOut;
+
+// caso a uniao falhe, interrompe a execucao sinalizando o problema!
+		if(TeOVERLAY::TePairUnion(psAux[j], polSetOut) == false)
+			return false;
+
+// teoricamente o buffer de cada nivel sera formado por um unico poligono com ou sem buracos.
+		if(polSetOut.size() != 1)
+			return false;
+
+		polVec.push_back(polSetOut[0]);
+	}
+
+	return true;
+}
+
+/** Rotina auxiliar que traca um buffer interno (negativo) no interior de um poligono, tracando varios niveis independentemente um do outro: para cada nivel de buffer, o anel externo do poligono estara no sentido horario e os buracos estarao no sentido anti-horario.
+		\param pol	           poligono para a qual os buffers serao tracados.
+		\param bufferDistance  distancia utilizada para tracar o buffer.
+		\param numPoints       numero de pontos utilizados para construcao dos semi-circulos de cada segmento.
+		\param bufferLevels    numero de niveis do buffer.
+		\param polsVec         vetor de saida com os poligonos de buffer de cada nivel: jah aninhados, isto e, os poligonos do nivel "n" jah consideram os do nivel "n-1".
+  */
+inline bool TeInsideBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polsVec)
+{
+	polsVec.clear();	
+
+	unsigned int nRings = pol.size();
+
+	//vetor de polygonset, onde cada poligonset est� associado a um nivel
+	//cada nivel contem os buffers internos do pai
+	vector<TePolygonSet> internalBuffers;
+	
+	//vetor de polygonset, onde cada poligonset est� associado a um nivel
+	//cada nivel contem os buffers externos dos buracos
+	vector<TePolygonSet> externalBuffers;
+
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TePolygonSet pset;
+		polsVec.push_back(pset);
+		TePolygonSet pset2;
+		internalBuffers.push_back(pset2);
+		TePolygonSet pset3;
+		externalBuffers.push_back(pset3);
+	}
+
+	// para cada anel vamos tracar o buffer e armazenar somente a parte de interesse: 
+	// no caso de aneis externos vamos
+	// ficar com o buffer interno e no caso de buracos vamos ficar com os buffer externos
+	for(unsigned int i = 0; i < nRings; ++i)
+	{
+		vector<TePolygon> buffVec;
+		
+		if(TeLineBuffer(pol[i], bufferDistance, numPoints, bufferLevels, buffVec) == false)
+			return false;
+
+		if(i == 0)
+		{
+// para o anel externo ficamos com os aneis internos do buffer
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+			{
+				unsigned int rsize = buffVec[j].size();
+				for(unsigned int k = 1; k < rsize; ++k)
+				{
+					TePolygon paux; paux.add(buffVec[j][k]); //comeca em 1 ate k
+					internalBuffers[j].add(paux);
+				}
+			}
+		}
+		else
+		{
+// para um anel interno ficamos com os aneis externos do buffer
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+			{
+				TePolygon paux; paux.add(buffVec[j][0]); 
+				externalBuffers[j].add(paux);
+			}
+		}
+	}
+	//para cada nivel, calcular o buraco do resultado que ser�
+	//a diferenca entre os buffers internos e 
+	//a uniao dos buffers externos 
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TePolygonSet holes;
+
+		if(externalBuffers[i].size()>0)
+		{
+			TePolygonSet externalBuffersUnion;
+			//uniao dos buffers externos
+			if(TeOVERLAY::TePairUnion(externalBuffers[i], externalBuffersUnion) == false)
+				return false;
+
+			// o buffer interno ao pai pode nao existir se a distancia for muito grande  
+			if(internalBuffers[i].size()>0)
+			{
+				//diferenca
+				if(TeOVERLAY::TeDifference(internalBuffers[i], externalBuffersUnion, holes) == false)
+					return false;
+			}
+
+			//se o resultado da diferenca der vazio, significa que os buffers internos entao
+			//contidos nos buffer externos
+			//assim temos que adicionar como buracos, os buracos originais
+			if(holes.size()==0)
+			{
+				TePolygon h;
+				for(unsigned j=1; j<pol.size(); ++j) // buracos originais 
+				{
+					h.add(pol[j]); 
+					holes.add(h);
+				}
+			}
+		}
+		else
+		{
+			//o unico buraco e o internal buffer do pai
+			holes = internalBuffers[i];
+		}
+		
+		//montar o buffer final
+		TePolygon result;
+		result.add(pol[0]); // pai do original
+		for(unsigned j=0; j<holes.size(); ++j) // buracos calculados
+            result.add(holes[j][0]);
+		
+		polsVec[i].add(result);
+	}
+
+	return true;
+}
+
+/** Rotina auxiliar que traca um buffer externo (positivo) ao redor de um poligono, tracando varios niveis independentemente um do outro: para cada nivel de buffer, o anel externo do poligono estara no sentido horario e os buracos estarao no sentido anti-horario.
+		\param pol	           poligono para a qual os buffers serao tracados.
+		\param bufferDistance  distancia utilizada para tracar o buffer.
+		\param numPoints       numero de pontos utilizados para construcao dos semi-circulos de cada segmento.
+		\param bufferLevels    numero de niveis do buffer.
+		\param polsVec         vetor de saida com os poligonos de buffer de cada nivel: jah aninhados, isto e, os poligonos do nivel "n" jah consideram os do nivel "n-1".
+  */
+inline bool TeOutsideBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polsVec)
+{
+	polsVec.clear();	
+
+	unsigned int nRings = pol.size();
+
+// jah coloca um objeto polygonset correspondente a cada nivel
+	vector<TePolygonSet> outPutPolsVec;
+
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TePolygonSet pset;
+		outPutPolsVec.push_back(pset);
+		TePolygonSet pset2;
+		polsVec.push_back(pset2);
+	}
+
+// para cada anel vamos tracar o buffer e armazenar somente a parte de interesse: no caso de aneis externos vamos
+// ficar com o buffer externo e no caso de buracos vamos ficar com os buffer internos
+	for(unsigned int i = 0; i < nRings; ++i)
+	{
+		vector<TePolygon> buffVec;
+		
+		if(TeLineBuffer(pol[i], bufferDistance, numPoints, bufferLevels, buffVec) == false)
+			return false;
+
+		if(i == 0)
+		{
+// para o anel externo ficamos com o anel externo do buffer
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+			{
+				TePolygon paux; paux.add(buffVec[j][0]);
+				outPutPolsVec[j].add(paux);
+			}
+		}
+		else
+		{
+// para um anel interno ficamos com os aneis internos do buffer
+			for(unsigned int j = 0; j < bufferLevels; ++j)
+			{
+				unsigned int rsize = buffVec[j].size();
+
+				for(unsigned int k = 1; k < rsize; ++k)
+				{
+					TePolygon paux; paux.add(buffVec[j][k]);
+					outPutPolsVec[j].add(paux);
+				}
+			}
+		}
+	}
+
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+// no caso de buffers positivos (para fora) pelo menos o buffer do anel externo devera aparecer em cada nivel
+		if(outPutPolsVec[i].size() == 0)
+			return false;
+
+		TePolygonSet psetOut = outPutPolsVec[i];
+
+// LOGICA PARA O ANEL EXTERNO
+		if(i == 0)
+		{
+// o primeiro buffer pegara como buraco o anel externo original
+			psetOut[0].add(pol[0]);	
+			polsVec[i].add(psetOut[0]);
+		}
+		else
+		{
+			TeLine2D laux;
+			laux.copyElements(outPutPolsVec[i - 1][0][0]);
+			psetOut[0].add(TeLinearRing(laux));
+			polsVec[i].add(psetOut[0]);
+		}
+
+// se nao temos buracos no corrente, entao nao precisamos nos preocupar com diferencas e etc...
+		if(psetOut.size() == 1)
+			continue;
+
+		
+// LOGICA PARA OS ANEIS INTERNOS
+		if(i == 0)
+		{			
+// vamos montar um polygonset com os buracos do poligono original
+			TePolygonSet psetOriginalInnerRings;
+
+			for(unsigned int j = 1; j < nRings; ++j)
+			{
+				TePolygon paux; paux.add(pol[j]);
+				psetOriginalInnerRings.add(paux);
+			}
+
+// agora vamos montar um polygonset com os buracos (que jah estao como poligonos) do primeiro nivel
+			TePolygonSet currentPset;
+
+			for(unsigned int j = 1; j < psetOut.size(); ++j)
+			{
+				currentPset.add(psetOut[j]);
+			}
+
+// agora fazemos a diferena dos originais com o do primeiro nivel
+			TePolygonSet resultPset;
+
+			if(TeOVERLAY::TeDifference(psetOriginalInnerRings, currentPset, resultPset) == false)
+				return false;
+
+			for(unsigned int j = 0; j < resultPset.size(); ++j)
+			{
+				polsVec[i].add(resultPset[j]);
+			}
+		}
+		else
+		{
+// vamos montar um polygonset com os buracos do "n-1" e um com o corrente ("n")
+			TePolygonSet previousPset;
+
+			for(unsigned int j = 1; j < outPutPolsVec[i - 1].size(); ++j)
+			{
+				previousPset.add(outPutPolsVec[i - 1][j]);
+			}
+
+			TePolygonSet currentPset;
+
+			for(unsigned int j = 1; j < psetOut.size(); ++j)
+			{
+				currentPset.add(psetOut[j]);
+			}
+
+// agora fazemos a diferena do nivel anterior com o do nivel corrente
+			TePolygonSet resultPset;
+
+			if(TeOVERLAY::TeDifference(previousPset, currentPset, resultPset) == false)
+				return false;
+
+			for(unsigned int j = 0; j < resultPset.size(); ++j)
+			{
+				polsVec[i].add(resultPset[j]);
+			}
+		}
+	}
+
+	return true;
+}
+
+inline bool TeInOutBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polsVec)
+{
+	polsVec.clear();	
+
+	unsigned int nRings = pol.size();
+
+	//vetor de polygonset, onde cada polygonset est� associado a um nivel
+	//cada nivel contem os buffers internos e externos  
+	// de cada anel do poligono
+	vector<TePolygonSet> polVecBuffers;
+	
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		TePolygonSet pset;
+		polsVec.push_back(pset);
+		TePolygonSet pset2;
+		polVecBuffers.push_back(pset2);
+	}
+
+	// para cada anel vamos tracar o buffer e armazenar o poligono gerado (com aneis externo e internos)
+	for(unsigned int i = 0; i < nRings; ++i)
+	{
+		vector<TePolygon> buffVec;
+		
+		if(TeLineBuffer(pol[i], bufferDistance, numPoints, bufferLevels, buffVec) == false)
+			return false;
+
+		//adicona o buffer gerado em cada polygonset
+		for(unsigned int j=0; j<buffVec.size(); ++j)
+			polVecBuffers[j].add(buffVec[j]);
+
+	}
+
+
+    //para cada nivel, fazer a uniao de todos os buffers gerados
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		//uniao dos buffers 
+		if(TeOVERLAY::TePairUnion(polVecBuffers[i], polsVec[i]) == false)
+			return false;
+	}
+
+	return true;
+}
+
+}	// end namespace TeBUFFERREGION
+
+//---------------- Buffer Algorithm ----------------//
+
+bool TeBUFFERREGION::TeBufferRegion(const TeCoord2D& coord, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygon>& bufferPols)
+{
+// limpa o vetor de poligonos de saida
+	bufferPols.clear();
+
+// cria um vetor de linhas que contera a linha de buffer a cada nivel
+	vector<TeLine2D> contourLines;
+
+// cria a linha de cada nivel e jah acrescenta a coordenada inicial do canto esquerdo
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+// linha de buffer do i-th nivel
+		TeLine2D newLine;
+		newLine.add(TeCoord2D((coord.x() - (bufferDistance * (i + 1))), (coord.y())));
+
+		contourLines.push_back(newLine);
+	}
+
+	double initialAng = bufferPI;							// angulo inicial
+	const double deltaAng = doubleBufferPI / numPoints;		// angulo de cada setor que compoem o buffer
+
+	double x = 0.0;	// variavel que contera a coordenada x transladada
+	double y = 0.0;	// variavel que contera a coordenada y transladada
+	double c = 0.0;	// variavel que contera o resultado do cosseno de um angulo
+	double s = 0.0;	// variavel que contera o resultado do seno de um angulo
+
+
+// calcula as coordenadas que formarao a linha de buffer de cada nivel
+	for(unsigned int i = 1; i < numPoints; ++i)
+	{
+		initialAng -= deltaAng;
+		
+		c = cos(initialAng);
+		s = sin(initialAng);
+
+// gera o ponto equivalente para cada nivel de buffer
+		for(unsigned int k = 0; k < bufferLevels; ++k)
+		{		
+			x = coord.x_ + bufferDistance * (k + 1) * c; 
+			y = coord.y_ + bufferDistance * (k + 1) * s;
+
+			contourLines[k].add(TeCoord2D(x, y));
+		}
+	}
+
+// fecha cada uma das linhas de buffer,
+// repetindo o primeiro ponto e cria os poligonos de buffer de cada nivel formado pela respectiva
+// linha de buffer
+	for(unsigned int i = 0; i < bufferLevels; ++i)
+	{
+		contourLines[i].add(contourLines[i][0]);		
+
+		TePolygon pol;
+		pol.add(TeLinearRing(contourLines[i]));
+		bufferPols.push_back(pol);
+	}
+
+// coloca o anel externo do nivel "n-1" como anel interno do nivel "n"
+	for(unsigned int i = 1; i < bufferLevels; ++i)
+	{
+// clona a linha externa do nivel "n-1"
+		TeLine2D laux;
+		laux.copyElements(bufferPols[i - 1][0]);
+
+// deixa no sentido anti-horario a linha que servira de buraco para o buffer do nivel "n"
+		reverse(laux.begin(), laux.end());
+
+// e, finalmente, coloca a linha do nivel "n-1" como buraco do nivel "n"
+		bufferPols[i].add(TeLinearRing(laux));
+	}
+
+	return true;
+}
+
+bool TeBUFFERREGION::TeBufferRegion(const TeCoord2D& coord, const double& bufferDistance, const unsigned int& numPoints, TePolygon& pol)
+{
+	pol.clear();
+
+// define um vetor temporario para chamar a rotina acima, que realmente implementa o buffer de um ponto
+	vector<TePolygon> bufferPols;
+
+// solicita o buffer de um unico nivel ao redor do ponto
+	TeBufferRegion(coord, bufferDistance, numPoints, 1, bufferPols);
+
+	if(bufferPols.empty())
+		return false;
+
+	pol = bufferPols[0];
+
+	return true;
+}
+
+bool TeBUFFERREGION::TeBufferRegion(const TeLine2D& line, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polVec)
+{
+	polVec.clear();
+
+	for(unsigned int level=0; level<bufferLevels; ++level)
+	{
+		TePolygonSet aux;
+		polVec.push_back(aux);
+	}
+
+// para tracar o semi-circulo ao redor do canto do segmento precisamos de pelo menos tres pontos
+	unsigned int cornerPts = numPoints;
+
+	if(numPoints < 3)
+		cornerPts = 3;
+
+// traca os buffers de cada nivel ao redor da linha: cada posicao do vetor "outPutPolVec" contera o poligono de cada nivel
+	vector<TePolygon> outPutPolVec;
+
+	if(TeLineBuffer(line, bufferDistance, cornerPts, bufferLevels, outPutPolVec) == false)
+		return false;
+
+// se o numero de poligonos da saida for diferente do numero de niveis desejado, algum erro ocorreu
+	if(outPutPolVec.size() != bufferLevels)
+		return false;
+
+// para cada nivel de buffer precisamos acomodar os aneis do nivel anterior:
+// no caso do buffer de linhas, o buffer do nivel "n" eh exatamente a diferenca do resultado que temos ate aqui menos o resultado
+// do buffer do nivel "n-1"
+	polVec[0].add(outPutPolVec[0]);
+
+	for(unsigned int i = 1; i < bufferLevels; ++i)
+	{
+		TePolygonSet currentPSet;  currentPSet.add(outPutPolVec[i]);
+		TePolygonSet previousPSet; previousPSet.add(outPutPolVec[i - 1]);
+
+		TePolygonSet polSetOut;
+
+		if(TeOVERLAY::TeDifference(currentPSet, previousPSet, polSetOut) == false)
+			return false;
+
+// esperamos que o resultado da diferenca seja sempre um poligono (com zero ou mais buracos)
+		//if(polSetOut.size() != 1)
+		//	return false;
+		//polVec.push_back(polSetOut[0]);
+
+		for(unsigned int j=0; j<polSetOut.size(); ++j)
+			polVec[i].add(polSetOut[j]);
+	}
+
+	return true;	
+}
+
+bool TeBUFFERREGION::TeBufferRegion(const TeLine2D& line, const double& bufferDistance, const unsigned int& numPoints, TePolygonSet& ps)
+{
+	ps.clear();
+
+	vector<TePolygonSet> polVec;
+
+	if(TeBufferRegion(line, bufferDistance, numPoints, 1, polVec) == false)
+		return false;
+
+	ps.copyElements(polVec[0]);
+	
+	return true;
+}
+
+bool TeBUFFERREGION::TeBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, const TeBufferType& buffType, vector<TePolygonSet>& polsVec)
+{
+	if(buffType == TeINSIDEBUFFER)
+	{
+		return TeInsideBufferRegion(pol, bufferDistance, numPoints, bufferLevels, polsVec);
+	}
+	else if(buffType == TeOUTSIDEBUFFER)
+	{
+		return TeOutsideBufferRegion(pol, bufferDistance, numPoints, bufferLevels, polsVec);
+	}
+	else
+	{
+		return TeInOutBufferRegion(pol, bufferDistance, numPoints, bufferLevels, polsVec);
+	}	
+}
+
+bool TeBUFFERREGION::TeBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, TePolygonSet& ps)
+{
+	ps.clear();
+
+	vector<TePolygonSet> pols;
+	
+	if(!TeBufferRegion(pol, bufferDistance, numPoints, 1, TeOUTSIDEBUFFER, pols))
+		return false;
+
+	ps = pols[0];
+
+	return true;
+}
+
+bool TeBUFFERREGION::TeBufferRegion(const TePolygonSet& polSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, const TeBufferType& bufferType, vector<TePolygonSet>& polyVecOut)
+{
+	polyVecOut.clear();
+	
+	for(unsigned int j=0; j<polSetIn.size(); ++j)
+	{
+		vector<TePolygonSet> auxPolVec;
+		if(!TeBUFFERREGION::TeBufferRegion(polSetIn[j], bufferDistance, numPoints, bufferLevels, bufferType, auxPolVec))
+			return false;
+
+		if(j==0)
+		{
+			for(unsigned int i=0; i<auxPolVec.size(); ++i)
+				polyVecOut.push_back(auxPolVec[i]);
+		}
+		else
+		{
+			for(unsigned int i=0; i<auxPolVec.size(); ++i)
+			{
+				TePolygonSet polUnion;
+				if(!TeOVERLAY::TeUnion(polyVecOut[i], auxPolVec[i], polUnion))
+					return false;
+				polyVecOut[i]=polUnion;
+			}
+		}
+	}
+	return true;
+}
+
+
+bool TeBUFFERREGION::TeBufferRegion(const TeLineSet& lineSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polyVecOut)
+{
+	polyVecOut.clear();
+
+    for(unsigned int j=0; j<lineSetIn.size(); ++j)
+	{
+		vector<TePolygonSet> currentPolVec;
+		if(!TeBUFFERREGION::TeBufferRegion(lineSetIn[j], bufferDistance, numPoints, bufferLevels, currentPolVec))
+			return false;
+
+		if(j==0)
+		{
+			for(unsigned int i=0; i<currentPolVec.size(); ++i)
+				polyVecOut.push_back(currentPolVec[i]);
+		}
+		else
+		{
+			for(unsigned int i=0; i<currentPolVec.size(); ++i)
+			{
+				TePolygonSet polUnion;
+				if(!TeOVERLAY::TeUnion(polyVecOut[i], currentPolVec[i], polUnion))
+					return false;
+				polyVecOut[i]=polUnion;
+			}
+		}
+	}
+	return true;
+}
+
+
+bool TeBUFFERREGION::TeBufferRegion(const TePointSet& pointSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polyVecOut)
+{
+	polyVecOut.clear();
+	
+	for(unsigned int j=0; j<pointSetIn.size(); ++j)
+	{
+		vector<TePolygon> currentPolVec;
+		if(!TeBUFFERREGION::TeBufferRegion(pointSetIn[j].location(), bufferDistance, numPoints, bufferLevels, currentPolVec))
+			return false;
+
+		if(j==0)
+		{
+			for(unsigned int i=0; i<currentPolVec.size(); ++i)
+			{
+				TePolygonSet currentPolSet; currentPolSet.add(currentPolVec[i]);
+				polyVecOut.push_back(currentPolSet);
+			}
+		}
+		else
+		{
+			for(unsigned int i=0; i<currentPolVec.size(); ++i)
+			{
+				TePolygonSet polUnion, currentPolSet;
+				currentPolSet.add(currentPolVec[i]);
+				if(!TeOVERLAY::TeUnion(polyVecOut[i], currentPolSet, polUnion))
+					return false;
+				polyVecOut[i]=polUnion;
+			}
+		}
+	}
+	return true;
+}
+
+	
+bool  TeBUFFERREGION::TeBufferRegion(const TeCellSet& cellSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, const TeBufferType& bufferType, vector<TePolygonSet>& polyVecOut)
+{
+	polyVecOut.clear();
+	
+	for(unsigned int j=0; j<cellSetIn.size(); ++j)
+	{
+		vector<TePolygonSet> auxPolVec;
+		if(!TeBUFFERREGION::TeBufferRegion(TeMakePolygon(cellSetIn[j].box()), bufferDistance, numPoints, bufferLevels, bufferType, auxPolVec))
+			return false;
+
+		if(j==0)
+		{
+			for(unsigned int i=0; i<auxPolVec.size(); ++i)
+				polyVecOut.push_back(auxPolVec[i]);
+		}
+		else
+		{
+			for(unsigned int i=0; i<auxPolVec.size(); ++i)
+			{
+				TePolygonSet polUnion;
+				if(!TeOVERLAY::TeUnion(polyVecOut[i], auxPolVec[i], polUnion))
+					return false;
+				polyVecOut[i]=polUnion;
+			}
+		}
+	}
+	return true;
+}
+
diff --git a/src/terralib/kernel/TeBufferRegion.h b/src/terralib/kernel/TeBufferRegion.h
new file mode 100644
index 0000000..855bf74
--- /dev/null
+++ b/src/terralib/kernel/TeBufferRegion.h
@@ -0,0 +1,156 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file   TeBufferRegion.h
+	\brief  This file contains structures and definitions for buffer region (map distance) operation on objects.
+	\author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ */
+
+#ifndef  __TERRALIB_INTERNAL_BUFFER_H
+#define  __TERRALIB_INTERNAL_BUFFER_H
+
+#include "TeCoord2D.h"
+
+class TeLine2D;
+class TePolygon;
+class TePolygonSet;
+class TeLineSet;
+class TePointSet;
+class TeCellSet;
+
+/*! \brief Contains structures and definitions needed to execute Buffer Region operation
+*/
+namespace TeBUFFERREGION
+{	
+	//!	Buffer type.
+	/*!
+		- TeINSIDEBUFFER			used to make only inside buffer lines
+		- TeOUTSIDEBUFFER			used to make only outside buffer lines
+		- TeINSIDEOUTSIDEBUFFER		used to make inside and outside buffer lines
+	*/ 
+	enum TeBufferType { TeINSIDEBUFFER, TeOUTSIDEBUFFER, TeINSIDEOUTSIDEBUFFER };
+
+	/** \brief Calculates a buffer region around a point (DEPRECATED: use TeBufferRegion with buffer levels instead).
+		\param coord			the location of the point
+		\param bufferDistance	the desired distance in the same unit as coord
+		\param numPoints		the number of points that should be used to describe the buffer zone (a circle in this case)
+		\param pol				to return the buffer zone: a circle polygon in clockwise order
+		\return Returns true if operation succeed otherwise returns false.
+	*/
+	TL_DLL bool TeBufferRegion(const TeCoord2D& coord, const double& bufferDistance, const unsigned int& numPoints, TePolygon& pol);
+
+	/** \brief Calculates a buffer region around a point.
+		\param coord			the location of the point
+		\param bufferDistance	the desired distance in the same unit as coord
+		\param numPoints		the number of points that should be used to describe the buffer zone (a circle in this case)
+		\param bufferLevels		the number of buffer intervals
+		\param bufferPols		to return the buffer intervals: a circle polygon in clockwise order with holes in counterclockwise order
+		\return Returns true if operation succeed otherwise returns false.
+	*/
+	TL_DLL bool TeBufferRegion(const TeCoord2D& coord, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygon>& bufferPols);
+
+	/** \brief Calculates a buffer region around a line (DEPRECATED: use TeBufferRegion with buffer levels instead).
+		\param line				the line 
+		\param bufferDistance	the desired distance in the same unit as line coordinates
+		\param numPoints		the number of points that should be used to describe the curved corners of the buffer zone
+		\param ps				to return the buffer zone: a set of polygons
+		\return Returns true if operation succeed otherwise returns false.
+	*/	
+	TL_DLL bool TeBufferRegion(const TeLine2D& line, const double& bufferDistance, const unsigned int& numPoints, TePolygonSet& ps);
+	
+	/** \brief Calculates a buffer region around a line.
+		\param line				the line 
+		\param bufferDistance	the desired distance in the same unit as line coordinates
+		\param numPoints		the number of points that should be used to describe the curved corners of the buffer zone
+		\param bufferLevels		the number of buffer intervals
+		\param polVec			to return the buffer zone: a vector of polygons
+		\return Returns true if operation succeed otherwise returns false.
+	*/	
+	TL_DLL bool TeBufferRegion(const TeLine2D& line, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polVec);
+
+	
+	/** \brief Calculates a buffer region around a polygon (DEPRECATED: use TeBufferRegion with buffer levels instead).
+		\param pol				the polygon 
+		\param bufferDistance	the desired distance in the same unit as polygon rings coordinates
+		\param numPoints		the number of points that should be used to describe the curved corners of the buffer zone
+		\param ps				to return the buffer zone: a set of polygons
+		\return Returns true if operation succeed otherwise returns false.
+	*/	
+	TL_DLL bool TeBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, TePolygonSet& ps);
+
+	/** \brief Calculates a buffer region around a polygon (DEPRECATED: use TeBufferRegion with buffer levels instead).
+		\param pol				the polygon 
+		\param bufferDistance	the desired distance in the same unit as polygon rings coordinates
+		\param numPoints		the number of points that should be used to describe the curved corners of the buffer zone
+		\param bufferLevels		the number of buffer intervals
+		\param buffType		    the buffer type: inside/outside/inside+outside
+		\param polsVec			to return the buffer zone: a vector of polygon set
+		\return Returns true if operation succeed otherwise returns false.
+	*/	
+	TL_DLL bool TeBufferRegion(const TePolygon& pol, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, const TeBufferType& buffType, vector<TePolygonSet>& polsVec);
+
+	/** \brief Calculates a buffer region around an object polygon set.
+		\param polSetIn				the object polygon set
+		\param bufferDistance		the desired distance in the same unit as polygon rings coordinates
+		\param numPoints			the number of points that should be used to describe the curved corners of the buffer zone
+		\param bufferLevels			the number of buffer intervals
+		\param bufferType			the buffer type: inside/outside/inside+outside
+		\param polyVecOut			to return the buffers of the object, each level in a position of the vector
+		\return Returns true if operation succeed otherwise returns false.
+	*/	
+	TL_DLL bool TeBufferRegion(const TePolygonSet& polSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, const TeBufferType& bufferType, vector<TePolygonSet>& polyVecOut);
+
+	/** \brief Calculates a buffer region around an object line set.
+		\param lineSetIn			the object line set
+		\param bufferDistance		the desired distance in the same unit as lines coordinates
+		\param numPoints			the number of points that should be used to describe the curved corners of the buffer zone
+		\param bufferLevels			the number of buffer intervals
+		\param polyVecOut			to return the buffers of the object, each level in a position of the vector
+		\return Returns true if operation succeed otherwise returns false.
+	*/	
+	TL_DLL bool TeBufferRegion(const TeLineSet& lineSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polyVecOut);
+
+	/** \brief Calculates a buffer region around an object point set.
+		\param pointSetIn			the object point set
+		\param bufferDistance		the desired distance in the same unit as points coordinates
+		\param numPoints			the number of points that should be used to describe the curved corners of the buffer zone
+		\param bufferLevels			the number of buffer intervals
+		\param polyVecOut			to return the buffers of the object, each level in a position of the vector
+		\return Returns true if operation succeed otherwise returns false.
+	*/			
+	TL_DLL bool TeBufferRegion(const TePointSet& pointSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, vector<TePolygonSet>& polyVecOut);
+	
+	/** \brief Calculates a buffer region around an object cell set.
+		\param cellSetIn			the object cell set
+		\param bufferDistance		the desired distance in the same unit as cells coordinates
+		\param numPoints			the number of points that should be used to describe the curved corners of the buffer zone
+		\param bufferLevels			the number of buffer intervals
+		\param bufferType			the buffer type: inside/outside/inside+outside
+		\param polyVecOut			to return the buffers of the object, each level in a position of the vector
+		\return Returns true if operation succeed otherwise returns false.
+	*/			
+	TL_DLL bool TeBufferRegion(const TeCellSet& cellSetIn, const double& bufferDistance, const unsigned int& numPoints, const unsigned int& bufferLevels, const TeBufferType& bufferType, vector<TePolygonSet>& polyVecOut);
+
+}	// end namespace TeBUFFER
+
+#endif //__TERRALIB_INTERNAL_BUFFER_H
+
diff --git a/src/terralib/kernel/TeCentroid.cpp b/src/terralib/kernel/TeCentroid.cpp
new file mode 100644
index 0000000..e9c304d
--- /dev/null
+++ b/src/terralib/kernel/TeCentroid.cpp
@@ -0,0 +1,416 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include <vector>
+#include <functional>
+#include <algorithm>
+
+#include "TeAssertions.h"
+#include "TeException.h"
+#include "TeGeometryAlgorithms.h"
+
+using namespace std;
+
+
+// Prototypes for internal routines - NOT seen from the outside
+
+TeCoord2D TeFindBaricenter (const TeLinearRing& ring ); // general method ( solves most cases)
+TeCoord2D TeFindCentroidConcavePolygon (const TePolygon& poly ); // brute-force approach (use if above fails)
+
+TeCoord2D
+TeFindCentroid(TeMultiGeometry& mGeom )
+{
+	TeBox bb;
+	TeCoord2D ct;
+	if(mGeom.hasPolygons())
+	{
+		ct = TeFindCentroid(mGeom.getPolygons());
+		updateBox(bb,ct);
+	}
+	if(mGeom.hasCells())
+	{
+		ct = TeFindCentroid(mGeom.getCells());
+		updateBox(bb,ct);
+	}
+	if(mGeom.hasLines())
+	{
+		ct = TeFindCentroid(mGeom.getLines());
+		updateBox(bb,ct);
+	}
+	else if(mGeom.hasPoints())
+	{
+		ct = TeFindCentroid(mGeom.getPoints());
+		updateBox(bb,ct);
+	}
+	return bb.center();
+}
+
+TeCoord2D
+TeFindCentroid(const TePolygon& poly )
+{
+	// This is a two-step algorithm
+
+	// First, try a simple geometric solution
+	// that works for convex polygons and some concave ones
+
+	TeCoord2D pt = TeFindBaricenter( poly[0] );
+
+	if ( TeWithin ( TePoint(pt), poly) )
+		return pt;
+	
+	// No, try a more general approach
+
+	pt = TeFindCentroidConcavePolygon( poly );
+
+return pt;
+}
+
+TeCoord2D
+TeFindCentroid (const TeLine2D& line )
+{
+	int midpoint = (line.size()/2) - 1 ;
+	TeCoord2D middle;
+	
+	TeGetMiddlePoint(line[midpoint], line[midpoint+1], middle);
+	return middle;
+}
+
+TeCoord2D 
+TeFindCentroid(const TeCell& c) 
+{
+	return c.box().center();
+}
+
+TeCoord2D 
+TeFindCentroid(const TePoint& p) 
+{
+	return p.location();
+}
+
+TeCoord2D 
+TeFindCentroid(const TeText& t) 
+{
+	return t.location();
+}
+
+TeCoord2D 
+TeFindCentroid(const TePolygonSet& s)
+{
+	TeCoord2D p;
+	if (s.empty())
+		return p;
+	double sx = 0.0;
+	double sy = 0.0;
+	unsigned int n = 0;
+
+	TeBox bb = s.box();
+	TePolygonSet::iterator it1 = s.begin(); 
+	while (it1 != s.end())
+	{
+		TeCoord2D p1 = TeFindCentroid (*it1);
+		sx += p1.x();
+		sy += p1.y();
+		++n;
+		++it1;
+	}
+	double ssx = sx/n;
+	double ssy = sy/n;
+	p.setXY(ssx,ssy);
+	return p;
+}
+
+
+TeCoord2D 
+TeFindCentroid(const TeLineSet& s)
+{
+	TeCoord2D p;
+	if (s.empty())
+		return p;
+	double sx = 0.0;
+	double sy = 0.0;
+	unsigned int n = 0;
+	TeLineSet::iterator it1 = s.begin(); 
+	while (it1 != s.end())
+	{
+		TeCoord2D p1 = TeFindCentroid (*it1);
+		sx += p1.x();
+		sy += p1.y();
+		++n;
+		it1++;
+	}
+	sx = sx/n;
+	sy = sy/n;
+	p.setXY(sx,sy);
+	return p;
+}
+
+
+TeCoord2D 
+TeFindCentroid(const TeCellSet& s)
+{
+	TeCoord2D p;
+	if (s.empty())
+		return p;
+	double sx = 0.0;
+	double sy = 0.0;
+	unsigned int n = 0;
+	TeCellSet::iterator it1 = s.begin(); 
+	while (it1 != s.end())
+	{
+		TeCoord2D p1 = TeFindCentroid (*it1);
+		sx += p1.x();
+		sy += p1.y();
+		++n;
+		it1++;
+	}
+	sx = sx/n;
+	sy = sy/n;
+	p.setXY(sx,sy);
+	return p;
+}
+
+TeCoord2D 
+TeFindCentroid(TePointSet& points)
+{
+	TeCoord2D p;
+	if (points.empty())
+		return p;
+	if (points.size() == 1)
+		p = (points[0]).location();
+	else
+		p = points.box().center();
+	return p;
+}
+
+TeCoord2D 
+TeFindCentroid(TeTextSet& texts)
+{
+	return texts.box().center();
+}
+/*
+ * ANSI C++ code from the article
+ * "Centroid of a Polygon"
+ * by Gerard Bashein and Paul R. Detmer,
+ * in "Graphics Gems IV", Academic Press, 1994
+ */
+
+/*********************************************************************
+Centroid: Calculates the centroid (xCentroid, yCentroid) 
+of a polygon, given its vertices (x[0], y[0]) ... (x[n-1], y[n-1]). It
+is assumed that the contour is closed, i.e., that the vertex following
+(x[n-1], y[n-1]) is (x[0], y[0]).  
+
+**********************************************************************/
+
+TeCoord2D
+TeFindBaricenter ( const TeLinearRing& ring )
+{
+
+    double ai, atmp = 0, xtmp = 0, ytmp = 0;
+         
+    int n = ring.size() - 1; // our polygons wrap around
+	int i, j;
+
+    if (n < 3) return TeCoord2D (0., 0.);
+
+	for ( i = n-1, j = 0; j < n; i = j, j++)
+ 	{
+ 	  	ai = ring[i].x() * ring[j].y() - ring[j].x() * ring[i].y();
+	  	atmp += ai;
+	  	xtmp += (ring[j].x() + ring[i].x()) * ai;
+	  	ytmp += (ring[j].y() + ring[i].y()) * ai;
+	}
+
+    if (atmp != 0)
+	{
+		return TeCoord2D ( (xtmp / (3. * atmp)), ( ytmp / (3. * atmp)));
+	}
+	return TeCoord2D ( 0., 0. );
+}
+
+
+
+//
+//	TeFindCentroidConcavePolygon 
+//
+//  This algorithm is based on the idea of a plane-sweep
+//
+//  1. Divide the box into horizontal slices
+//
+//  2. Sweep the plane, starting from the bottom
+//
+//  3. For each y-slice, find the horizontal intersections in the 
+//     forward direction (if it exists)
+//
+//  4. Sort these intersections
+//
+//  5. Order the intersections 
+//
+//  6. For all possible "intersections", select a mid-point and
+//     test if this point is inside the polygon
+//
+//  7. If a centroid has not been found, cut the box into
+//     "smaller" slices and repeat steps 2-6
+
+
+
+// Defines a function object for sorting coordinates in ascending x-order
+ 
+struct x_order : public binary_function<TeCoord2D, TeCoord2D, bool>
+{
+        bool operator()(TeCoord2D& pt1, TeCoord2D& pt2) { return pt1.x() < pt2.x(); }
+};
+
+// Defines a distance measure between two Coordinate pairs (used for sorting)
+
+struct x_dist : public binary_function<TeCoordPair, TeCoordPair, bool>
+{
+		bool operator()(TeCoordPair c1, TeCoordPair c2)
+		{
+			return ( ( c1.pt2.x() - c1.pt1.x() ) > ( c2.pt2.x() - c2.pt1.x() ) ); 
+		}
+};
+
+
+typedef vector<double> doubleVect;
+
+TeCoord2D
+TeFindCentroidConcavePolygon ( const TePolygon& poly )
+{
+
+	TeLinearRing coords = poly[0];
+
+	TeBox box = coords.box();
+
+	int NSLICES = 10;
+
+	int NMAXSLICES = 400;
+
+	double yinit = box.lowerLeft().y();
+		
+	while ( true )
+	{
+		int nparts = NSLICES + 2; // divide the box into slices
+
+		double increm = ( box.upperRight().y() - box.lowerLeft().y() ) / nparts; // y-increment
+
+		double yslice = yinit; // start at the bottom
+
+		TeCoordPairVect intersecList;  //vector of horizontal intersections
+
+		doubleVect crossList; //vector of x-crossings
+
+		for ( int i = 0; i < NSLICES; i++ )
+		{
+			yslice += increm; //next slice
+
+			for (unsigned int x = 0; x < ( coords.size() - 1 ); x++ )
+				TeCoord2D cd= coords[x];
+
+			for  (unsigned int j = 0;  j < ( coords.size() - 1 ); j++ ) 		
+			{
+
+				TeCoord2D vtx0 = coords[j];
+				TeCoord2D vtx1 = coords[j+1];
+
+				bool yflag0 = ( vtx0.y() >= yslice );
+				bool yflag1 = ( vtx1.y() >= yslice ) ;
+				/* check if endpoints straddle (are on opposite sides) of X axis
+				* (i.e. the Y's differ); if so, +X ray could intersect this edge.
+				*/
+
+				if ( yflag0 != yflag1 )
+				{
+					// line crosses ring horizontally 
+
+					double slope =  ( vtx1.x() - vtx0.x() ) / ( vtx1.y() - vtx0.y());
+					double xcross = ( yslice -   vtx0.y() )* slope + vtx0.x();
+			
+					crossList.push_back ( xcross );	
+				}
+
+			}
+
+			// Sort the x-intersections
+
+			sort ( crossList.begin(), crossList.end() );
+
+			doubleVect::iterator it = crossList.begin();
+			
+			// Create a list of intersection points
+
+			while ( it != crossList.end() )
+			{
+				TeCoordPair cp;
+
+				cp.pt1 = TeCoord2D ( (*it), yslice );
+				++it;
+				if ( it == crossList.end() ) break;
+
+				cp.pt2 = TeCoord2D ( (*it), yslice );
+				++it;
+
+				intersecList.push_back ( cp );
+			}
+					
+		} // for all slices
+
+		// Now sort all the intersections
+
+		sort ( intersecList.begin(), intersecList.end(), x_dist() );
+
+		// Go through the intersection list
+		// Find the mid-point
+
+		TeCoordPairVect::iterator it = intersecList.begin();
+		
+		while ( it != intersecList.end() )
+		{
+			double xmid = (*it).pt1.x() + ( (*it).pt2.x() - (*it).pt1.x() ) / 2;
+
+			TeCoord2D pt ( xmid, (*it).pt2.y() );
+
+
+			if ( TeWithin (TePoint(pt), poly) ) // have we found it ???
+				return pt;
+
+			++it;  // try the next largest x-intersection
+		}
+
+		NSLICES *= 2;  // double the number of slices
+
+		// iterate until a maximum number of slices
+		// if not able to find a centroid, log an error, but don't stop
+		if ( NSLICES > NMAXSLICES ) 
+		{
+			string userText = "Polygon number " + poly.geomId ();
+
+			TeErrorLog::instance().insert ( CENTROID_NOT_FOUND, userText );
+
+			return TeCoord2D ( TeMAXFLOAT, TeMAXFLOAT );
+		}
+	}
+
+}
+
+
diff --git a/src/terralib/kernel/TeComposite.h b/src/terralib/kernel/TeComposite.h
new file mode 100644
index 0000000..03d5b6e
--- /dev/null
+++ b/src/terralib/kernel/TeComposite.h
@@ -0,0 +1,184 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeComposite.h
+    \brief This file contains definition of composite structures in TerraLib
+*/
+
+#ifndef  __TERRALIB_INTERNAL_COMPOSITE_H
+#define  __TERRALIB_INTERNAL_COMPOSITE_H
+
+#include "TeCounted.h"
+
+#include <vector>
+#include <algorithm>
+using namespace std;
+
+//!  Defines a templated class for handling an object built of one single atomic element
+template <class T>
+class TeSingle
+{
+public:
+	//! Constructor
+	TeSingle<T>() {}
+
+	//! Destructor
+	virtual ~TeSingle<T>() {}
+
+	//! Copy constructor
+	TeSingle<T> ( T& elem ): elem_ ( elem  ) {}
+
+	//! Adds the single element
+	void add ( T& elem )
+	{	elem_ = elem; }
+
+	//! Returns a referency to the single element
+	T&	location ()
+	{	return elem_; }
+
+	//! Returns a constant reference to the single element
+	const T& location() const
+	{
+		return elem_;
+	}
+
+	//! Returns a referency to the single element
+	T&	elem ()
+	{	return elem_; }
+
+protected:
+	T	elem_;	//!< the single element
+
+};
+
+//! Defines a template for handling a composite object
+/*! 
+	Provides a vector for storing components and ensures 
+	proper destruction of them, by means of a handle/body idiom. 
+	Provide a handle to an implementation and thus allow efficient 
+	copying of derived objects
+
+	\note This is a specialised example of the "Composite"
+	design pattern, with support for the "Bridge" pattern
+	(also known as the handle/body idiom).
+*/
+template <class T>
+class TeComposite: public TeCounted
+{
+public:
+	
+	using TeCounted::attach;
+	using TeCounted::detach;
+
+	//! An iterator to the composite elements 
+	typedef typename vector<T>::iterator iterator;
+	typedef typename vector<T>::const_iterator const_iterator;
+
+	//! Adds a new component
+	void add ( const T& elem )
+	{ components_.push_back ( elem ); }
+
+	//! Removes the i-th component
+	bool erase ( unsigned int i )
+	{ 	
+		if ( components_.size() < i )
+			return false;
+		return ! ( components_.erase ( components_.begin() + i ) == components_.end() );
+	}
+
+	//! Removes a specific element 
+	/*!
+		\param elem the element to be removed
+	*/
+	bool erase ( T& elem )
+	{ 
+		typename vector<T>::iterator location = find(components_.begin(),components_.end(), elem);
+		if ( location != components_.end())
+		{
+			components_.erase(location);
+			return true;
+		}
+		else
+			return false; 
+	}
+
+	//! Removes an element pointed by an iterator
+	iterator erase(iterator it)
+	{
+		return components_.erase(it);
+	}
+
+	//! Removes all elements
+	void clear ()
+	{	components_.clear (); }
+
+	//! Returns the size of the composite
+	size_t size() const
+	{ return components_.size(); }
+
+	//! Returns the i-th element
+	T& operator [] ( int i )
+	{ return components_[ i ]; }
+
+	//! Returns TRUE if the composite is empty
+	bool empty() const
+	{ return components_.empty(); }
+
+	//! Reserves space for n elements (reserve is available for vectors)  
+	void reserve(int nelem)
+	{ components_.reserve(nelem); }
+
+	//! Returns an iterator to the composite first element
+	iterator begin(void)
+	{
+		return components_.begin();
+	}
+
+	//! Returns a iterator to the composite last plus one element
+    iterator end(void)
+	{
+		return components_.end();
+	}
+
+	//! A reverse iterator to the composite elements 
+	typedef typename vector<T>::reverse_iterator reverse_iterator;
+
+	//! The iterator to the first position in the TeComposite in reverse order
+	reverse_iterator rbegin(void) 
+	{
+		return components_.rbegin();
+	}
+
+	//! The iterator to the last plus one position in the TeComposite in reverse order
+    reverse_iterator rend(void) 
+	{
+		return components_.rend();
+	}
+
+
+protected:
+	vector<T>	components_; //!< a vector of components
+};
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeCoord2D.h b/src/terralib/kernel/TeCoord2D.h
new file mode 100644
index 0000000..94624f7
--- /dev/null
+++ b/src/terralib/kernel/TeCoord2D.h
@@ -0,0 +1,160 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeCoord2D.h
+    \brief This file contains the definition of a classes to handle 2D coordinates
+*/
+#ifndef  __TERRALIB_INTERNAL_COORD2D_H
+#define  __TERRALIB_INTERNAL_COORD2D_H
+
+#include <math.h>
+#include "TeDefines.h"
+#include "TePrecision.h"
+
+#include <vector>
+
+using namespace std;
+
+//! A class for handling 2D coordinates
+class TL_DLL TeCoord2D
+{
+public:
+
+	double	x_;		//!< x coordinate
+	double	y_;		//!< y coordinate
+
+	//! Default contructor
+	TeCoord2D ( const double& x = 0., const double& y = 0. ):
+		x_ ( x ), y_ ( y ) {}
+
+	//! Copy constructor
+	TeCoord2D (const TeCoord2D& cd) 			
+		{x_ = cd.x_; y_ = cd.y_;}
+
+	//! Operator =
+	TeCoord2D& operator= ( const TeCoord2D& cd )
+	{
+		if ( this != &cd )
+		{	
+			x_ = cd.x_; y_ = cd.y_;
+		}
+		return *this;
+	}
+		
+	//!	Empty destructor.
+	~TeCoord2D () { }
+
+	//!	Returns the X componente of the coordinate
+	const double&	x () const 				
+	{	return x_;	}
+
+	//!	Sets the X componente of the coordinate
+	void x ( const double& valX )
+	{	x_ = valX; }
+
+	//!	Returns the Y componente of the coordinate
+	const double& 	y () 		const		
+	{	return y_;	}
+
+	//!	Sets the Y componente of the coordinate
+	void y(const double& valY)
+	{	y_ = valY; }
+
+	//!	Sets the X and Y componentes of the coordinate
+	void setXY(const double& xVal, const double& yVal )
+	{	x_= xVal; y_= yVal; }
+
+	//!	Adds two coordinates
+	void 	operator+=(const TeCoord2D& cd)	{x_ += cd.x_; y_ += cd.y_;}
+
+	//!	Returns TRUE if current coordinate is smaller than or equal	to TeCoord2D cd; returns FALSE otherwise 
+	bool  operator<= (const TeCoord2D& cd) const 
+		{return (( y_ - cd.y_ <= TePrecision::instance().precision() ) && 
+		         ( x_ - cd.x_ <= TePrecision::instance().precision() ) );}	
+
+	//!	Returns TRUE if current coordinate is equal	to TeCoord2D cd; returns FALSE otherwise 
+	bool operator== (const TeCoord2D& cd) const 
+	{return (  ( fabs (y_ - cd.y_) < TePrecision::instance().precision() ) 
+			&& ( fabs (x_ - cd.x_) < TePrecision::instance().precision() ) ); }
+
+	//!	Returns TRUE if current coordinate is not equal to TeCoord2D cd; returns FALSE otherwise 
+	bool	operator!= (const TeCoord2D& cd) const 
+		{return ( ( fabs (y_ - cd.y_) >= TePrecision::instance().precision() ) 
+		       || ( fabs (x_ - cd.x_) >= TePrecision::instance().precision() ) );}	
+
+	//!	Returns TRUE if current coordinate is smaller than TeCoord2D cd; returns FALSE otherwise 
+	bool	operator< (const TeCoord2D& cd) const 
+		{return ( y_ - cd.y_ < TePrecision::instance().precision() 
+		       && x_ - cd.x_ < TePrecision::instance().precision() );}	
+
+	//!	Returns TRUE if current coordinate greater than maximum allowed; returns FALSE otherwise 
+	bool	tooBig ()
+		{return ( y_ > TeMAXFLOAT/10.|| x_ > TeMAXFLOAT/10.);}	
+
+	//!	Rescales the coordinate by a value in X (xscale) and in Y (yscale)
+	void	scale ( const double xscale, const double yscale )
+	{ x_ = x_* xscale; y_ = y_ * yscale; }
+
+
+	//!	Returns the middle coordinate in horizontal direction between current coordinate and rhs
+	TeCoord2D halfWayHoriz ( TeCoord2D& rhs )
+	{
+		TeCoord2D mid (( rhs.x() + x() ) / 2., y() );
+		return mid;
+	}
+
+	//!	Returns the middle coordinate in vertical direction between current coordinate and rhs
+	TeCoord2D halfWayVert  ( TeCoord2D& rhs )
+	{
+		TeCoord2D mid ( x(), ( y() + rhs.y() ) / 2. );
+		return mid;
+	}
+
+	//! A false interface to set an obejct identifier
+	void objectId(const string& /* id */ ) 
+	{	return;  }
+};
+
+//! An structure that contains a pair of coordinates
+struct TL_DLL TeCoordPair
+{
+	TeCoord2D pt1;	//!< First coordinate value.
+	TeCoord2D pt2;	//!< Second coordinate value.
+
+	//! Default contructor: [(0.0),(0.0)]
+	TeCoordPair():
+		pt1(TeCoord2D(0.0,0.0)),
+		pt2(TeCoord2D(0.0,0.0))
+	{}
+
+	//! Constructor with parameters
+	TeCoordPair(const TeCoord2D& p1, const TeCoord2D& p2):
+		pt1(p1),
+		pt2(p2)
+		{}
+};
+
+//! A vector of pairs of coordinates
+typedef vector<TeCoordPair> TeCoordPairVect;
+
+#endif
+
diff --git a/src/terralib/kernel/TeCounted.h b/src/terralib/kernel/TeCounted.h
new file mode 100644
index 0000000..cbc501d
--- /dev/null
+++ b/src/terralib/kernel/TeCounted.h
@@ -0,0 +1,77 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeCounted.h
+    \brief This file contains classes to support the counted object idiom
+*/
+
+//! Supports the counted object idiom
+/*! 
+	A counted class keeps track of how many abstract instances are pointing
+	to the same implementation.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_COUNTED_H
+#define  __TERRALIB_INTERNAL_COUNTED_H
+
+#include "TeDefines.h"
+
+class TL_DLL TeCounted {
+public:
+
+// -- Contructors
+
+	//! Constructor: sets zero references when the object is  built
+	TeCounted(): refCount_ ( 0 ){}
+	
+// -- Methods
+
+	//! Increases the number of references to this object
+	void attach ()
+		{ refCount_++; }
+
+	//! Decreases the number of references to this object. Destroy it if there are no more references to it
+	void detach ()
+		{ if ( --refCount_ == 0 )
+			delete this; }
+
+	//! Returns the number of references to this object
+	int refCount()
+	{ return refCount_; }
+
+	//! Destructor
+	virtual ~TeCounted(){}
+
+private:
+
+	//! No copy allowed
+	TeCounted(const TeCounted&);
+
+	//! No copy allowed
+	TeCounted& operator=(const TeCounted&){return *this;}
+
+// -- Members
+	int refCount_; 	//!< the number of references to this class
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeDBConnection.cpp b/src/terralib/kernel/TeDBConnection.cpp
new file mode 100644
index 0000000..94c03e5
--- /dev/null
+++ b/src/terralib/kernel/TeDBConnection.cpp
@@ -0,0 +1,619 @@
+
+#include <sstream>
+#include "TeDBConnection.h"
+#include "TeDatabase.h"
+#include "TeDatabaseFactory.h"
+#include "TeDBConnectionsPool.h"
+
+
+TeDBConnection::TeDBConnection(const bool& isShared) :
+	id_(-1), driverInUse_(false), isShared_(isShared), db_(0), dbmsName_(""),
+	host_(""), databaseName_(""), user_(""), password_(""), portNumber_(-1)
+{ }
+
+TeDBConnection::TeDBConnection(const std::string& hostName, const std::string& databaseName, 
+		const std::string& userName, const std::string& dbmsName, const int& port, 
+		const std::string& userPasswd, const int& conId, TeDatabase* db, const bool& isShared) :
+	id_(conId), driverInUse_(false), isShared_(isShared), db_(db), dbmsName_(dbmsName),
+	host_(hostName), databaseName_(databaseName), user_(userName), password_(userPasswd),
+	portNumber_(port) 
+{
+}
+
+TeDBConnection::TeDBConnection(const int& conId, TeDatabase* db, const bool& isShared) :
+	id_(conId), driverInUse_(false), isShared_(isShared), db_(db), dbmsName_(""),
+	host_(""), databaseName_(""), user_(""), password_(""), portNumber_(-1) 
+{
+	if(db)
+	{
+		string dbKey = db->getDatabaseDescription();
+		fillDBConnectionInfo(dbKey);
+	}
+}
+
+TeDBConnection::TeDBConnection(const std::string& dbKey, const bool& isShared) :
+	id_(-1), driverInUse_(false), isShared_(isShared), db_(0), dbmsName_(""),
+	host_(""), databaseName_(""), user_(""), password_(""), portNumber_(-1)
+{
+	fillDBConnectionInfo(dbKey);
+} 
+
+TeDBConnection::TeDBConnection(const TeDBConnection& other)
+{
+	id_ = other.id_;
+    driverInUse_ = other.driverInUse_;
+	isShared_ = other.isShared_;
+	dbmsName_ = other.dbmsName_;
+	host_ = other.host_;
+	databaseName_ = other.databaseName_;
+	user_ = other.user_;
+	password_ = other.password_;
+	portNumber_ = other.portNumber_;
+	db_=0;
+	if(other.db_)
+	{
+		db_ = TeDatabaseFactory::make(other.asDatabaseFactoryParams());
+		*db_ = *other.db_;
+	}
+}
+
+TeDBConnection&
+TeDBConnection::operator=(const TeDBConnection& other)
+{
+	if(this != &other)
+	{
+		id_ = other.id_;
+        driverInUse_ = other.driverInUse_;
+		isShared_ = other.isShared_;
+		dbmsName_ = other.dbmsName_;
+		host_ = other.host_;
+		databaseName_ = other.databaseName_;
+		user_ = other.user_;
+		password_ = other.password_;
+		portNumber_ = other.portNumber_;
+		if(db_)
+		{
+			db_->close();
+			delete db_;
+			db_=0;
+		}
+		if(other.db_)
+		{
+			db_ = TeDatabaseFactory::make(other.asDatabaseFactoryParams());
+			*db_ = *other.db_;
+		}
+	}
+	return *this;
+}
+
+
+TeDBConnection::~TeDBConnection()
+{	
+	if (db_)
+	{
+		db_->close();
+		delete db_;
+	}
+	db_ = 0;
+}
+
+bool 
+TeDBConnection::operator==(const TeDBConnection& other)
+{
+	return ((id_==other.id_) && 
+			(dbmsName_ == other.dbmsName_) && 
+			(host_==other.host_) &&	(portNumber_==other.portNumber_) &&
+			(databaseName_==other.databaseName_) &&
+			(user_ == other.user_) && (password_== other.password_));
+}
+
+void 
+TeDBConnection::clear()
+{
+	id_ = -1;
+	driverInUse_ = false; 
+	isShared_ = true; 
+	if(db_)
+	{
+		db_->close();
+		delete db_;
+	}
+	db_ = 0;
+	dbmsName_ = ""; 
+	host_ = "";
+	portNumber_ = -1;
+	databaseName_= ""; 
+	user_= ""; 
+	password_= ""; 
+}
+
+void 
+TeDBConnection::setId(const int& id)
+{
+	id_ = id;
+}
+	
+int	
+TeDBConnection::getId()
+{
+	return id_;
+}
+
+bool TeDBConnection::isInUse()
+{
+	return driverInUse_;
+}
+
+void TeDBConnection::setInUse(const bool& inUse)
+{
+	driverInUse_ = inUse;
+}
+
+bool TeDBConnection::isShared()
+{
+	return isShared_;
+}
+
+void TeDBConnection::setShared(const bool& isShared)
+{
+	isShared_ = isShared;
+}
+
+TeDatabase* TeDBConnection::getDatabase()
+{
+	return db_;
+}
+
+void TeDBConnection::setDatabase(TeDatabase* db)
+{
+	db_ = db;
+}
+
+std::string TeDBConnection::getDbmsName() 
+{ 
+	return dbmsName_; 
+}
+
+void TeDBConnection::setDbmsName(const std::string& dbmsName)
+{
+	dbmsName_ = dbmsName;
+}
+
+std::string TeDBConnection::getHost() 
+{ 
+	return host_; 
+}
+
+void TeDBConnection::setHost(const std::string& host) 
+{
+	host_ = host;
+}
+
+std::string TeDBConnection::getDatabaseName() 
+{ 
+	return databaseName_; 
+}
+
+void TeDBConnection::setDatabaseName(const std::string& databaseName) 
+{
+	databaseName_ = databaseName;
+}
+
+std::string TeDBConnection::getUser()
+{ 
+	return user_; 
+}
+
+void TeDBConnection::setUser(const std::string&  user) 
+{
+	user_ = user;
+}
+
+std::string TeDBConnection::getPassword() 
+{ 
+	return password_; 
+}
+
+void TeDBConnection::setPassword(const std::string& password)
+{
+	password_ = password;
+}
+
+int TeDBConnection::getPortNumber()
+{
+	return portNumber_;
+}
+
+void TeDBConnection::setPortNumber(const int& port)
+{
+	portNumber_ = port;
+}
+
+std::string TeDBConnection::getDbKey()
+{
+	std::string  dbKey = ""; 
+	
+	dbKey += dbmsName_;
+	dbKey += ";"; 
+	dbKey += host_;
+	dbKey += ";"; 
+	dbKey += Te2String(portNumber_);
+	dbKey += ";"; 
+	dbKey += databaseName_;
+	dbKey += ";"; 
+	dbKey += user_;
+	dbKey += ";"; 
+	dbKey += password_;
+	return dbKey;
+}
+
+void TeDBConnection::fillDBConnectionInfo(const std::string& dbKey)
+{
+    int NUM_PARAMS = 6;
+
+	if (dbKey.empty())
+		return;
+
+    // Checking for valid key.
+    size_t start = 0;
+    vector<int> indexs;
+    while (true)
+    {
+        start = dbKey.find_first_of(";", start);
+        if (start == string::npos)
+            break;
+
+        indexs.push_back(start);
+        start++;
+    }
+
+    if ((int)indexs.size() != (NUM_PARAMS - 1))
+        return;
+
+    string dbms_name = "";
+    if (indexs[0] > 0)
+        dbms_name = dbKey.substr(0, indexs[0]);
+
+    string host = "";
+    if ((indexs[1] - indexs[0]) > 1)
+        host = dbKey.substr(indexs[0] + 1, (indexs[1] - indexs[0]) - 1);
+
+    int port_number = -1;
+    if ((indexs[2] - indexs[1]) > 1)
+    {
+        string v;
+        v = dbKey.substr(indexs[1] + 1, (indexs[2] - indexs[1]) - 1);
+        port_number = atoi((char*)v.c_str());
+    }
+
+    string database_name = "";
+    if ((indexs[3] - indexs[2]) > 1)
+        database_name = dbKey.substr(indexs[2] + 1, (indexs[3] - indexs[2]) - 1);
+
+    string user = "";
+    if ((indexs[4] - indexs[3]) > 1)
+        user = dbKey.substr(indexs[3] + 1, (indexs[4] - indexs[3]) - 1);
+
+    string password = "";
+    if ((dbKey.size() - indexs[4]) > 1)
+        password = dbKey.substr(indexs[4] + 1, (dbKey.size() - indexs[4]) - 1);
+
+    this->setDbmsName(dbms_name);
+    this->setHost(host);
+    this->setPortNumber(port_number);
+    this->setDatabaseName(database_name);
+    this->setUser(user);
+    this->setPassword(password);
+
+	return;
+}
+
+void TeDBConnection::lock()
+{
+	driverInUse_ = true;
+}
+
+bool TeDBConnection::connect()
+{
+	if (!db_)
+    {
+		if ( !createDatabaseConnection() )
+        {
+            return false;
+        }
+    }
+	
+	if(db_->isConnected())
+		db_->close();
+	
+	return db_->connect(host_, user_, password_, databaseName_, portNumber_);  
+}
+
+bool TeDBConnection::createDatabaseModel() 
+{
+	if (!db_)
+		return false;
+	if (!db_->newDatabase(databaseName_, user_, password_, host_))
+		return false;
+	return true;
+}
+
+TeDatabaseFactoryParams 
+TeDBConnection::asDatabaseFactoryParams() const
+{
+	TeDatabaseFactoryParams params;
+	params.host_ = host_;
+	params.port_ = portNumber_;
+	params.password_ = password_;
+	params.user_ = user_;
+	params.database_ = databaseName_;
+	params.dbms_name_ = dbmsName_;
+
+	return params;
+}
+
+bool TeDBConnection::load(TeDatabase* sourceDB, const int& dbId, TeDBConnection& dbCon)
+{
+	dbCon.clear();
+
+	if(!sourceDB)
+		return false;
+
+	std::string strSQL = "SELECT * FROM te_database_connection WHERE connection_id = " + Te2String(dbId);
+    
+	TeDatabasePortal* dbPortal = sourceDB->getPortal();
+
+    if(!dbPortal)
+		return false;
+
+    if(!dbPortal->query(strSQL) || !dbPortal->fetchRow())
+    {
+        dbPortal->freeResult();
+        delete dbPortal;
+		return false;
+	}
+
+	dbCon.setId(dbPortal->getInt("connection_id"));
+	dbCon.setDbmsName(dbPortal->getData("dbms_name"));
+	dbCon.setHost(dbPortal->getData("host_name"));
+	dbCon.setDatabaseName(dbPortal->getData("database_name"));
+	dbCon.setUser(dbPortal->getData("user_name"));
+	dbCon.setPassword(dbPortal->getData("user_password"));
+	dbCon.setPortNumber(dbPortal->getInt("port_number"));	
+
+	dbPortal->freeResult();
+    delete dbPortal;
+	return true;
+}
+
+bool TeDBConnection::load(TeDatabase* sourceDB)
+{
+	if(!sourceDB)
+		return false;
+
+	std::string strSQL="SELECT * FROM te_database_connection";
+    
+	TeDatabasePortal* dbPortal = sourceDB->getPortal();
+
+    if(!dbPortal)
+		return false;
+
+    if(!dbPortal->query(strSQL))
+    {
+        dbPortal->freeResult();
+        delete dbPortal;
+		return false;
+	}
+
+	while(dbPortal->fetchRow())
+	{
+		TeDBConnection dbConn;
+		dbConn.setId(dbPortal->getInt("connection_id"));
+		dbConn.setDbmsName(dbPortal->getData("dbms_name"));
+		dbConn.setHost(dbPortal->getData("host_name"));
+		dbConn.setDatabaseName(dbPortal->getData("database_name"));
+		dbConn.setUser(dbPortal->getData("user_name"));
+		dbConn.setPassword(dbPortal->getData("user_password"));
+		dbConn.setPortNumber(dbPortal->getInt("port_number"));
+		dbConn.setDatabase(0);
+
+		TeDBConnectionsPool::instance().insertDBConnection(dbConn);
+	}
+
+	dbPortal->freeResult();
+    delete dbPortal;
+	return true;
+}
+
+bool TeDBConnection::save(TeDatabase* sourceDB, TeDBConnection& dbConn)
+{
+	std::string searchSQL  = "SELECT * FROM te_database_connection WHERE connection_id = ";
+	            searchSQL += Te2String(dbConn.getId());
+
+	TeDatabasePortal* portal = sourceDB->getPortal();
+
+	if(!portal)
+		return false;
+
+	if(!portal->query(searchSQL))
+	{
+		portal->freeResult();
+		delete portal;
+		return false;
+	}
+
+	bool isInsert = !portal->fetchRow();
+	portal->freeResult();
+	delete portal;
+
+	std::string strSQL = "";
+
+	if(isInsert)
+	{
+		// insert
+		strSQL  = "INSERT INTO te_database_connection(dbms_name, host_name, database_name, user_name, user_password, port_number) ";
+	    strSQL += "VALUES ('" + dbConn.getDbmsName();
+        strSQL += "', '" + dbConn.getHost();
+        strSQL += "', '" + dbConn.getDatabaseName();
+        strSQL += "', '" + dbConn.getUser(); 
+        strSQL += "', '" + dbConn.getPassword();
+        strSQL += "', " + Te2String(dbConn.getPortNumber());
+        strSQL += ")";
+	}
+	else
+	{
+		// update		
+		strSQL  = "UPDATE te_database_connection SET dbms_name='" + dbConn.getDbmsName();
+		strSQL += "', host_name='" + dbConn.getHost();
+		strSQL += "', database_name='" + dbConn.getDatabaseName();
+		strSQL += "', user_name='" + dbConn.getUser();
+		strSQL += "', user_password='" + dbConn.getPassword();
+		strSQL += "', port_number=" + Te2String(dbConn.getPortNumber());
+		strSQL += " WHERE connection_id = " + Te2String(dbConn.getId());
+	}
+
+	if(!sourceDB->execute(strSQL))
+        return false;
+
+	if(isInsert)
+		return updateId(sourceDB, dbConn);
+
+    return true;
+}
+
+bool TeDBConnection::remove(TeDatabase* sourceDB, TeDBConnection& dbConn)
+{
+	std::string deleteSQL  = " DELETE FROM te_database_connection WHERE connection_id = ";
+		        deleteSQL += Te2String(dbConn.getId());
+	
+	if(!sourceDB->execute(deleteSQL))
+        return false;
+
+	TeDBConnectionsPool::instance().removeDBConnection(dbConn);
+	
+	return true;
+}
+
+int TeDBConnection::createDBConnectionTable(TeDatabase* sourceDB)
+{
+	if(!sourceDB)
+		return 0;
+
+	if(sourceDB->tableExist("te_database_connection"))
+		return -1;
+
+	TeAttributeList attList;
+
+	TeAttribute att1;
+	att1.rep_.name_ = "connection_id";
+	att1.rep_.isAutoNumber_ = true;
+	att1.rep_.isPrimaryKey_ = true;
+	att1.rep_.null_ = false;
+	att1.rep_.type_ = TeINT;
+	att1.rep_.numChar_ = 0;
+	attList.push_back(att1);
+
+	TeAttribute att2;
+	att2.rep_.name_ = "dbms_name";
+	att2.rep_.isAutoNumber_ = false;
+	att2.rep_.isPrimaryKey_ = false;
+	att2.rep_.null_ = true;
+	att2.rep_.type_ = TeSTRING;
+	att2.rep_.numChar_ = 255;
+	attList.push_back(att2);
+
+	TeAttribute att3;
+	att3.rep_.name_ = "host_name";
+	att3.rep_.isAutoNumber_ = false;
+	att3.rep_.isPrimaryKey_ = false;
+	att3.rep_.null_ = true;
+	att3.rep_.type_ = TeSTRING;
+	att3.rep_.numChar_ = 255;
+	attList.push_back(att3);
+
+	TeAttribute att4;
+	att4.rep_.name_ = "database_name";
+	att4.rep_.isAutoNumber_ = false;
+	att4.rep_.isPrimaryKey_ = false;
+	att4.rep_.null_ = true;
+	att4.rep_.type_ = TeSTRING;
+	att4.rep_.numChar_ = 255;
+	attList.push_back(att4);
+
+	TeAttribute att5;
+	att5.rep_.name_ = "user_name";
+	att5.rep_.isAutoNumber_ = false;
+	att5.rep_.isPrimaryKey_ = false;
+	att5.rep_.null_ = true;
+	att5.rep_.type_ = TeSTRING;
+	att5.rep_.numChar_ = 255;
+	attList.push_back(att5);
+
+	TeAttribute att6;
+	att6.rep_.name_ = "user_password";
+	att6.rep_.isAutoNumber_ = false;
+	att6.rep_.isPrimaryKey_ = false;
+	att6.rep_.null_ = true;
+	att6.rep_.type_ = TeSTRING;
+	att6.rep_.numChar_ = 255;
+	attList.push_back(att6);
+
+	TeAttribute att7;
+	att7.rep_.name_ = "port_number";
+	att7.rep_.isAutoNumber_ = false;
+	att7.rep_.isPrimaryKey_ = false;
+	att7.rep_.null_ = true;
+	att7.rep_.type_ = TeINT;
+	att7.rep_.numChar_ = 0;
+	attList.push_back(att7);
+
+	if(!sourceDB->createTable("te_database_connection", attList))
+		return 0;
+
+	return 1;
+}
+
+bool TeDBConnection::createDatabaseConnection() 
+{
+	if(db_)
+	{
+		db_->close();
+		delete db_;
+		db_=0;
+	}
+	db_ = TeDatabaseFactory::make(this->asDatabaseFactoryParams());
+	if(!db_)
+		return false;
+	return true;
+}
+
+bool TeDBConnection::updateId(TeDatabase* sourceDB, TeDBConnection& dbConn)
+{
+	std::string searchSQL  = "SELECT * FROM te_database_connection WHERE ";
+	            searchSQL += "dbms_name = '" + dbConn.getDbmsName();
+		        searchSQL += "' AND host_name = '" + dbConn.getHost();
+		        searchSQL += "' AND database_name = '" + dbConn.getDatabaseName();
+		        searchSQL += "' AND user_name = '" + dbConn.getUser();
+		        searchSQL += "' AND user_password = '" + dbConn.getPassword();
+		        searchSQL += "' AND port_number = " + Te2String(dbConn.getPortNumber());
+
+	TeDatabasePortal* portal = sourceDB->getPortal();
+
+	if(!portal)
+		return false;
+
+	bool status = false;
+
+	if(portal->query(searchSQL) && portal->fetchRow())
+	{
+        dbConn.setId(portal->getInt("connection_id"));
+
+		status = true;
+	}
+
+	portal->freeResult();
+	delete portal;
+	return status;
+}
+
+
diff --git a/src/terralib/kernel/TeDBConnection.h b/src/terralib/kernel/TeDBConnection.h
new file mode 100644
index 0000000..9204e43
--- /dev/null
+++ b/src/terralib/kernel/TeDBConnection.h
@@ -0,0 +1,207 @@
+
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDBConnection.h
+    \brief This file contains the class TeDBConnection that defines a database
+	connection. 
+*/
+
+#ifndef __TERRALIB_INTERNAL_DBCONNECTION_H 
+#define __TERRALIB_INTERNAL_DBCONNECTION_H
+
+#include "TeDatabaseFactoryParams.h"
+#include <string>
+
+class TeDatabase;
+
+///!  A class to represent a database connection.
+/*!  
+	 This class defines a database connection.
+
+	 \sa
+	 TeDatabase
+*/
+class TL_DLL TeDBConnection
+{
+
+protected:
+	
+	//! A number to identify a database connection
+	int id_;
+	
+	//! Flag to indicate if this connection is in use or not
+	bool driverInUse_;
+
+	//! Flag to indicate if this connection can be shared by more than one user
+	bool isShared_;
+	
+	//! A Database pointer
+	TeDatabase* db_;
+
+	//! The name of the DMBS 
+	std::string dbmsName_;
+
+	//! The host name
+	std::string host_;
+
+	//! The database name
+	std::string databaseName_;
+	
+	//! The user name
+	std::string user_;
+
+	//! The user passwor
+	std::string password_;
+
+	//! The user password
+	int portNumber_;
+
+public:
+
+	//! Empty constructor
+	TeDBConnection(const bool& isShared=true);
+
+	//! Constructor
+	TeDBConnection(const std::string& hostName, const std::string& databaseName, 
+		const std::string& userName, const std::string& dbmsName, const int& portNumber = -1,
+		const std::string& userPasswd = "", const int& conId = -1, TeDatabase* db = 0, const bool& isShared=true);
+
+	//! Constructor
+	TeDBConnection(const int& conId, TeDatabase* db = 0, const bool& isShared=true);
+
+	//! Constructor
+	TeDBConnection(const std::string& dbKey, const bool& isShared=true);
+
+	//! Copy constructor
+	TeDBConnection(const TeDBConnection& other);
+
+	//! Operator =
+	TeDBConnection& operator=(const TeDBConnection& other);
+
+	//! Destructor
+	virtual ~TeDBConnection();
+
+	//! Equal operator
+	bool operator==(const TeDBConnection& other);
+
+	//! Clear 
+	void clear();
+
+	//! Set the connection identity
+	virtual void setId(const int& id);
+	//! Get the connection identity
+	virtual int	getId();
+
+	//! Verify if this connection is in use
+	virtual bool isInUse();
+	//! Set if this connection is in use or not
+	virtual void setInUse(const bool& inUse);
+
+	//! Verify if this connection is shared
+	virtual bool isShared();
+	//! Set if this connection is shared or not
+	virtual void setShared(const bool& isShared);
+
+	//! Get the database pointer
+	virtual TeDatabase* getDatabase();
+	//! Set the database pointer
+	virtual void setDatabase(TeDatabase* db);
+
+	//! Returns the name of the DBMS
+	virtual std::string getDbmsName(); 
+	//! Sets the name of the DBMS
+	virtual void setDbmsName(const std::string& dbmsName);
+
+	//! Returns the host name 
+	virtual std::string getHost();
+	virtual void setHost(const std::string& host);
+
+	//! Returns the database name.
+	virtual std::string getDatabaseName();
+	//! Sets the database name.
+	virtual void setDatabaseName(const std::string& databaseName);
+
+	//! Returns user name
+	virtual std::string getUser();
+	//! Sets the user name
+	virtual void setUser(const std::string&  user);
+
+	//! Returns the user password
+	virtual std::string getPassword();
+	//! Sets the user password	
+	virtual void setPassword(const std::string& password);
+
+	//! Returns the port number
+	virtual int getPortNumber();
+	//! Sets the port number
+	virtual void setPortNumber(const int& port);
+
+	//! Returns the database key (with user password)
+	virtual std::string getDbKey();
+	
+	//! Fills the connection parameters (dbms name, database name, host, port number, user and password) based on the database key given
+	virtual void fillDBConnectionInfo(const std::string& dbKey);
+
+	//! Lock this connection setting it as in use
+	virtual void lock();
+
+	//! Opens a database connection based on the connection parameters
+	virtual bool connect();
+	
+	//! Creates a new database and the terralib data model 
+	virtual bool createDatabaseModel();
+
+	//! Return the connection parameters
+	virtual TeDatabaseFactoryParams asDatabaseFactoryParams() const;
+
+	//! Loads a specific database connection from a database
+	static bool load(TeDatabase* sourceDB, const int& dbId, TeDBConnection& dbConn);
+
+	//! Loads all database connections from database and put them in the database connection pool.
+	static bool load(TeDatabase* sourceDB);
+
+	//! Save a database connection in the database 
+	static bool save(TeDatabase* sourceDB, TeDBConnection& dbConn);
+
+	//! Remove a database connection in the database 
+	static bool remove(TeDatabase* sourceDB, TeDBConnection& dbConn);
+
+	/** \brief Creates the table where we store a list of connections to other databases.
+		\param sourceDB A connection to a TerraLib database that stores information about others databases that can be used for example by remote themes. (Input)
+        \return Returns 1 if the table was created, -1 if it already exists and 0 on error.
+     */
+    static int createDBConnectionTable(TeDatabase* sourceDB);
+
+	//! Updates the database connection identity from database
+	static bool updateId(TeDatabase* sourceDB, TeDBConnection& dbConn);
+
+private:
+	//! Creates a new opened database connection based on the connection parameters
+	virtual bool createDatabaseConnection();
+
+};
+
+
+#endif 
+
+
diff --git a/src/terralib/kernel/TeDBConnectionsPool.cpp b/src/terralib/kernel/TeDBConnectionsPool.cpp
new file mode 100644
index 0000000..377c078
--- /dev/null
+++ b/src/terralib/kernel/TeDBConnectionsPool.cpp
@@ -0,0 +1,403 @@
+
+#include "TeDBConnectionsPool.h"
+#include "TeDBConnection.h"
+
+#include <vector>
+#include <map>
+
+
+TeDBConnectionsPool::TeDBConnectionsPool()  
+{ }
+
+TeDBConnectionsPool::~TeDBConnectionsPool() 
+{
+	clearAllDBConnections();
+}
+
+TeDatabase* 
+TeDBConnectionsPool::getDatabase(const std::string& hostName, const std::string& databaseName, 
+	const std::string& userName, const std::string& dbmsName, const int& portNumber, const std::string& userPasswd) 
+{
+	TeDatabase* db = 0;
+	TeDBConnection* dr = 0;
+
+	TeDBConnection conn(hostName, databaseName, userName, dbmsName, portNumber, userPasswd);
+	std::string dbKey = conn.getDbKey();
+	
+	//Look for a valid connection
+	dr = findDBConnection(dbKey);
+	if(dr)
+	{
+		dr->setInUse(true);
+		return dr->getDatabase();
+	}
+
+	//Creates a new connection and put it in the pool
+	dr = createDBConnection(conn);
+	if(dr)
+	{
+		dr->setInUse(true);
+		return dr->getDatabase();
+	}
+
+	return db;
+}
+
+TeDatabase* 
+TeDBConnectionsPool::getDatabase(const int& dbDriverIndx) 
+{
+	TeDatabase* db = 0;
+	TeDBConnection* dr = 0;
+	
+	//Look for a valid connection
+	dr = findDBConnection(dbDriverIndx);
+	if(dr)
+	{
+		dr->setInUse(true);
+		return dr->getDatabase();
+	}
+	return db;
+}
+
+TeDatabase* 
+TeDBConnectionsPool::getDatabase(const std::string& dbDescriptorKey) 
+{
+	TeDatabase* db = 0;
+	TeDBConnection* dr = 0;
+	
+	//Look for a valid connection
+	dr = findDBConnection(dbDescriptorKey);
+	if(dr)
+	{
+		dr->setInUse(true);
+		return dr->getDatabase();
+	}
+
+	//Creates a new connection and put it in the pool
+	TeDBConnection dbCon;
+	dbCon.fillDBConnectionInfo(dbDescriptorKey);
+	dr = createDBConnection(dbCon);
+	if(dr)
+	{
+		dr->setInUse(true);
+		return dr->getDatabase();
+	}
+	return db;
+}
+bool TeDBConnectionsPool::releaseDatabase(TeDatabase* db) 
+{
+	if (!db)
+		return false;
+
+	std::string dbKey = db->getDatabaseDescription();	
+
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.find(dbKey);
+	if(itKey == dbIndxs_.end())
+		return false;
+
+	//Look for this database in the database connection vector
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator itAux = dbs_.find(itKey->second);
+	if(itAux==dbs_.end())
+		return false;
+
+	TeDBConnectionsVector::iterator it;
+	for (it = itAux->second.begin(); it != itAux->second.end(); ++it)
+	{			
+		TeDatabase* aux_db = it->getDatabase();
+		if (aux_db == db)
+		{
+			it->setInUse(false);
+			return true;
+		}
+	}
+	return false;
+}
+
+void TeDBConnectionsPool::releaseAllDatabases() 
+{	
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.begin();
+	while(it!=dbs_.end())
+	{
+		TeDBConnectionsVector::iterator itCon = it->second.begin();
+		while(itCon!=it->second.end())
+		{
+			itCon->setInUse(false);
+			++itCon;
+		}
+		++it;
+	}
+	return;
+}
+
+bool TeDBConnectionsPool::insertDBConnection(TeDBConnection& dr)
+{
+	int indx=0;
+	//creates the database key based on the connection parameters
+	std::string dbKey = dr.getDbKey();
+	
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.find(dbKey);
+	if(itKey == dbIndxs_.end())
+	{
+		//creates a new entity in the both maps
+		indx = dr.getId();
+		if(indx<0)
+		{
+			//look for a valid database connection id
+			indx = createsValidConId();  
+			dr.setId(indx);
+		}
+				
+		TeDBConnectionsVector vec;
+		vec.push_back(dr);
+		dbs_.insert(std::pair<int, TeDBConnectionsVector>(indx, vec));
+		dbIndxs_.insert(std::pair<std::string, int>(dbKey, indx));
+		return true;
+	}
+
+	indx = itKey->second;
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.find(indx);
+	if(it == dbs_.end())
+		return false;
+	
+	//This implementation supports only one connection by database descriptor
+	//because of the maps in the TeDatabase (layerMap, ThemeMap, etc...)
+	clearDBConnectionVector(it->second); 
+	it->second.push_back(dr);
+	return true;
+}
+
+bool TeDBConnectionsPool::removeDBConnection(TeDBConnection& dr)
+{
+	//creates the database key based on the connection parameters
+	std::string dbKey = dr.getDbKey();
+	
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.find(dbKey);
+	if(itKey==dbIndxs_.end())
+		return false;
+
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.find(itKey->second);
+	if(it==dbs_.end())
+		return false;
+
+	TeDBConnectionsVector::iterator itVec = it->second.begin();
+	while(itVec!=it->second.end())
+	{
+		if((*itVec) == dr)
+		{
+			it->second.erase(itVec);
+			continue;
+		}
+		++itVec;
+	}
+
+	if(it->second.size()>0)
+		return true;
+
+	dbs_.erase(it);
+	dbIndxs_.erase(itKey);
+	return true;
+}
+
+int 
+TeDBConnectionsPool::getDBConnectionIndx(TeDBConnection& dbCon) 
+{
+	string dbKey = dbCon.getDbKey();
+	int status = this->getDBConnectionIndx(dbKey);
+	return status;
+}
+
+int 
+TeDBConnectionsPool::getDBConnectionIndx(const std::string& dbDescriptorKey) 
+{
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.find(dbDescriptorKey);
+	if (itKey != dbIndxs_.end())
+		return itKey->second;
+	return -1;
+}
+
+std::string
+TeDBConnectionsPool::getDBConnectionKey(const int& dbConnectionIndx) 
+{
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.begin();
+	while(itKey!=dbIndxs_.end())
+	{
+		if(itKey->second == dbConnectionIndx)
+			return itKey->first;
+		++itKey;
+	}
+	return "";
+}
+
+void TeDBConnectionsPool::clearAllDBConnections()  
+{
+	//clean the the drivers pool
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.begin();
+	while(it!=dbs_.end())
+	{
+		clearDBConnectionVector(it->second);
+		++it;
+	}
+
+	dbs_.clear();
+	dbIndxs_.clear();
+}
+
+void TeDBConnectionsPool::closeDBConnection(TeDatabase* db) 
+{
+	if(!db)
+		return;
+	releaseDatabase(db);
+	db->close();		
+}
+
+void TeDBConnectionsPool::closeDBConnection(std::string& dbDescriptorKey) 
+{
+	TeDBConnection* dr = findDBConnection(dbDescriptorKey);
+	if (!dr)
+		return; 
+	
+	dr->setInUse(false);
+	TeDatabase* db = dr->getDatabase();
+	if (db)
+		db->close();		
+}
+
+//protected
+
+bool TeDBConnectionsPool::isDBConnectionInPool(TeDatabase* db) 
+{
+	if(!db)
+		return false;
+
+	std::string dbKey = db->getDatabaseDescription();	
+
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.find(dbKey);
+	if(itKey == dbIndxs_.end())
+		return false;
+
+	//Look for this database in the database connection vector
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator itAux = dbs_.find(itKey->second);
+	if(itAux==dbs_.end())
+		return false;
+
+	TeDBConnectionsVector::iterator it;
+	for (it = itAux->second.begin(); it != itAux->second.end(); ++it)
+	{			
+		TeDatabase* aux_db = it->getDatabase();
+		if (aux_db == db)
+			return true;
+	}
+	return false;
+}
+
+TeDBConnection* 
+TeDBConnectionsPool::findDBConnection(const int& dbDriverIndx)  
+{
+	TeDBConnection* dr = 0;		
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.find(dbDriverIndx);
+	if(it==dbs_.end())
+		return dr; // There are no database connection to this index 
+	
+	//Find one databases connection
+	TeDBConnectionsVector::iterator it2;
+	for (it2 = it->second.begin(); it2 != it->second.end(); ++it2)
+	{			
+		//Verify if this connection is in use. If it is, continue to look for another connection.
+		if (it2->isInUse() && !it2->isShared())
+			continue;
+		
+		TeDatabase* db = it2->getDatabase();
+		if((!db) || (!db->isConnected()))
+		{
+			it2->connect();	 //Open this db connection based on its descriptor
+			db = it2->getDatabase();
+		}
+		
+		if (db->isConnected())
+			return &(*it2);
+	}
+	return dr;
+}
+
+TeDBConnection* 
+TeDBConnectionsPool::findDBConnection(const std::string& dbkey) 
+{
+	TeDBConnection* db = 0;		
+	std::map< std::string, int, std::less<std::string> >::iterator itKey = dbIndxs_.find(dbkey);
+	if (itKey != dbIndxs_.end())
+		return findDBConnection(itKey->second);
+	return db;
+}
+
+void TeDBConnectionsPool::clearDBConnectionVector(TeDBConnectionsVector& connections) 
+{
+	//the clear method calls the destructor of all TeDBConnection 
+	connections.clear();
+}
+
+TeDBConnection* 
+TeDBConnectionsPool::createDBConnection(const std::string& hostName, const std::string& databaseName, 
+		const std::string& userName, const std::string& dbmsName, const int& portNumber, const std::string& userPasswd)
+{
+	TeDBConnection dbCon(hostName, databaseName, userName, dbmsName, portNumber, userPasswd);
+	return createDBConnection(dbCon);
+}
+
+TeDBConnection* 
+TeDBConnectionsPool::createDBConnection(TeDBConnection& dbCon)
+{
+	TeDBConnection* con = 0;
+	if(dbCon.getId()<0)
+	{
+		int indx = createsValidConId();
+		dbCon.setId(indx);
+	}
+	
+	if(!dbCon.connect()) //create a new opened database connection 
+		return con;
+	
+	//Insert this new connection in the maps
+	if(!insertDBConnection(dbCon))
+		return con;
+
+	std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.find(dbCon.getId());
+	if(it==dbs_.end())
+		return con;
+    
+	TeDBConnectionsVector::iterator itVec = it->second.begin();
+	if(itVec == it->second.end())
+		return con;
+	return &(*itVec);
+}
+
+int
+TeDBConnectionsPool::createsValidConId()
+{
+	int indx = dbIndxs_.size();
+	bool isNotValid = true;
+	//verify if this number already exists
+	while(isNotValid)
+	{
+		std::map<int, TeDBConnectionsVector, std::less<int> >::iterator it = dbs_.find(indx);
+		if(it==dbs_.end())
+			isNotValid = false;
+		else
+			++indx;
+	}
+	return indx;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/terralib/kernel/TeDBConnectionsPool.h b/src/terralib/kernel/TeDBConnectionsPool.h
new file mode 100644
index 0000000..fbe4db5
--- /dev/null
+++ b/src/terralib/kernel/TeDBConnectionsPool.h
@@ -0,0 +1,210 @@
+
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDBConnectionsPool.h
+	\brief This file contains the class TeDBConnectionsPool that defines 
+	a pool of database connections. 
+*/
+
+#ifndef __TERRALIB_INTERNAL_DBCONNECTIONPOOL_H 
+#define __TERRALIB_INTERNAL_DBCONNECTIONPOOL_H
+
+#include "TeSingleton.h"
+#include "TeDBConnection.h"
+#include "TeDatabase.h"
+
+#include <vector>
+#include <map>
+#include <string>
+
+//! A database connections vector.
+typedef std::vector<TeDBConnection> TeDBConnectionsVector;
+
+
+///!  A class that implements a manager for a database connections pool.
+/*!  
+	 \sa
+	 TeDatabase, TeDBConnection
+*/
+class TL_DLL TeDBConnectionsPool : public TeSingleton<TeDBConnectionsPool> 
+{
+public:
+
+	//! Constructor.
+	TeDBConnectionsPool(); 
+	
+	//! Destructor.
+	virtual ~TeDBConnectionsPool(); 
+
+	//! Returns an available connection in the pool for the given connection parameters.
+	/*!
+		Searches one available connection in the pool. If there is, returns this 
+		pointer otherwise creates a new connection based on the given descriptor, 
+		connects it, sets it "in use" and inserts it in the pool, then returns the new connection.	
+		\param desc The database descriptor.
+		\return If success returns a connection otherwise returns NULL.
+	*/
+    TeDatabase* getDatabase(const std::string& hostName, const std::string& databaseName, 
+		const std::string& userName, const std::string& dbmsName, const int& portNumber = 0,
+		const std::string& userPasswd = ""); 
+
+	//! Returns one available connection in the pool for a given connection index.
+	/*!
+		Searches one available connection in the pool based on the given index. 
+		\param desc The database descriptor.
+		\return If success returns a connection otherwise returns NULL.
+	*/
+	TeDatabase* getDatabase(const int& dbConnectionIndx); 
+
+	//! Returns one available connection in the pool for a given database connection key.
+	/*!
+		Searches one available connection in the pool. If there is, returns this 
+		pointer otherwise creates a new connection based on the given descriptor key, 
+		connects it, sets it "in use" and inserts it in the pool, then returns the new connection.
+		\param database descriptor key.
+		\return If success returns a connection otherwise returns NULL.
+	*/
+	TeDatabase* getDatabase(const std::string& dbKey); 
+		
+	//! Releases the given database connection.
+	/*!
+		Checks if the database connection is in the pool, then set 
+		the connection as "available".
+		\param db A pointer to a database connection.
+	*/
+	bool releaseDatabase(TeDatabase* db); 
+
+	//! Releases all connection in the pool.
+	/*!
+		Sets all connections in the pool as "available".
+	*/
+	void releaseAllDatabases(); 
+	
+	//! Inserts a database connection in the pool.
+	/*!
+		Inserts a database connection in the pool. If the database connection identity
+		is equal to -1, this method creates a new identity.
+		\param db	the database connection.
+	*/
+	bool insertDBConnection(TeDBConnection& dr);
+
+	//! Removes the database connection of the pool.
+	/*!
+		Removes a database connection of the pool. 
+		\param db	the database connection.
+	*/
+	bool removeDBConnection(TeDBConnection& dr);
+
+	//! Returns the connection index for the given connection parameters.
+	/*!
+		If success returns the found connection index otherwise returns -1.	
+		\param desc The connection descriptor.
+		\return If success returns a connection index otherwise returns -1.
+	*/
+	int getDBConnectionIndx(TeDBConnection& dbCon); 
+	
+	//! Returns the connection index for a given connection key.
+	/*!
+		If success returns the found connection index otherwise returns -1.	
+		\param dbKey The database key.
+		\return If success returns a connection index otherwise returns -1.
+	*/
+	int getDBConnectionIndx(const std::string& dbKey); 
+
+	//! Returns the connection key for a given connection index.
+	/*!
+		If success returns the found connection key otherwise returns an empty string.	
+		\param dbConnectionIndx The connection index.
+		\return If success returns a connection key returns an empty string.
+	*/
+	std::string getDBConnectionKey(const int& dbConnectionIndx); 
+		
+	//! Closes all connections and clears the pool.
+	/*!
+		Closes each database connection in the vectors and clear the maps.
+	*/
+	void clearAllDBConnections(); 
+	
+	//! Sets the database connection as not available and close it. 
+	/*!
+		Checks if the database connection is in the pool, 
+		then set it as not available and close it. 
+		\param db A pointer to a database connection.
+	*/
+	void closeDBConnection(TeDatabase* db); 
+	void closeDBConnection(std::string& dbDescriptorKey); 
+
+	//! Returns how many connections exist in the pool
+	unsigned int size() { return dbIndxs_.size(); }
+
+	//! Returns a reference to the connection container
+	std::map<int, TeDBConnectionsVector>& getDBConnections() { return dbs_; }
+
+
+protected:
+
+	//! Checks if the database connection is in the pool.
+	/*!
+		\param db A pointer to a database connection.
+		\return Returns true if the database connection is in the pool 
+		otherwise returns false.
+	*/
+	bool isDBConnectionInPool(TeDatabase* db);  
+
+	//! Searches the first available database connection in the pool for the given index.
+	/*!
+		\param dbConnectionIndx The connection index.
+		\return Returns a valid pointer if there is a valid connected in the pool otherwise return NULL.   
+	*/
+	TeDBConnection* findDBConnection(const int& dbConnectionIndx); 
+
+	//! Searches the first available database connection in the pool for the given database key.
+	/*!
+		\param dbkey The database connection key.
+		\return Returns a valid pointer if there is a valid connected in the pool otherwise return NULL.   
+	*/
+	TeDBConnection* findDBConnection(const std::string& dbkey); 
+
+	//! Closes all connections in the given vector and clears it.
+	void clearDBConnectionVector(TeDBConnectionsVector& connectionsVector); 
+
+	//! Creates a new database connection based on the given connection parameters, puts it in the pool and returns it
+	TeDBConnection* createDBConnection(const std::string& hostName, const std::string& databaseName, 
+		const std::string& userName, const std::string& dbmsName, const int& portNumber = 0,
+		const std::string& userPasswd = "");
+
+	//! Creates a new database connection based on the given connection parameters, puts it in the pool and returns it
+	TeDBConnection* createDBConnection(TeDBConnection& dbCon);
+
+private:
+
+	//! Hash table that maps a database key with a database connections vector.
+	std::map<int, TeDBConnectionsVector, std::less<int> >	dbs_;
+	std::map< std::string, int, std::less<std::string> >	dbIndxs_;
+
+	//! Creates a new valid connection database identity 
+	int createsValidConId();
+};
+
+#endif 
+
diff --git a/src/terralib/kernel/TeDataTypes.h b/src/terralib/kernel/TeDataTypes.h
new file mode 100644
index 0000000..2347318
--- /dev/null
+++ b/src/terralib/kernel/TeDataTypes.h
@@ -0,0 +1,182 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDataTypes.h
+    \brief This file contains enumerators and data types used by TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_DATATYPE_H
+#define  __TERRALIB_INTERNAL_DATATYPE_H
+
+#ifdef WIN32 
+#pragma warning ( disable: 4786 ) 
+#endif
+
+#include <vector>
+#include <string>
+#include <map> 
+
+using namespace std;
+
+//! SPRINGs data model entities
+enum TeSpringModels
+{   TeSPRCadastral=0, TeSPRNetwork=1, TeSPRThematic=2, TeSPRMNT=3 };
+
+
+//!  Types for Attributes (stored in object-relational databases)
+enum TeAttrDataType 
+{TeSTRING, TeREAL, TeINT, TeDATETIME, TeBLOB, TeOBJECT, TeCHARACTER, TeUNKNOWN, TeUNSIGNEDINT,
+ TePOINTTYPE, TeLINE2DTYPE, TePOLYGONTYPE, TeCELLTYPE, TeTEXTTYPE, TeNODETYPE,
+ TePOINTSETTYPE, TeLINESETTYPE, TePOLYGONSETTYPE, TeCELLSETTYPE, TeTEXTSETTYPE, TeNODESETTYPE,
+ TeRASTERTYPE};
+
+
+//! Geometrical representations 
+/*! Uses a binary ennumeration since the same layer 
+    may contain more than one geometrical representation
+*/
+enum TeGeomRep 
+{	TePOLYGONS = 1, TeLINES = 2, TePOINTS = 4, TeSAMPLES = 8, TeCONTOURS = 16,
+	TeARCS = 32, TeNODES = 64  , TeTEXT = 128, TeCELLS = 256 , TeRASTER = 512,
+	TeRASTERFILE = 1024, TeGEOMETRYNONE = 2048, TeSHAPEFILE = 4096, TeCOVERAGE = 8192};
+
+//! Chart types
+enum TeChartType
+{   TeBarChart, TePieChart };
+
+//! Objects that will be grouped or used in a chart
+enum TeSelectedObjects
+{	TeAll, TeSelectedByPointing, TeNotSelectedByPointing, TeSelectedByQuery, TeNotSelectedByQuery,
+	TeSelectedByPointingAndQuery, TeSelectedByPointingOrQuery, TeGrouped, TeNotGrouped };
+
+//! Modes of object selection
+enum TeObjectSelectionMode
+{   TeDefaultSelection, TePointingSelection, TeQuerySelection, TePointingAndQuerySelection };
+
+//! Modes of grouping objects
+enum TeGroupingMode
+{ TeEqualSteps = 0, TeQuantil = 1, TeStdDeviation = 2, TeUniqueValue = 3,
+  TeRasterSlicing = 4, TeNoGrouping = 100 };
+
+//! Direction of use in a ramp color
+enum TeColorDirection
+{	TeColorAscSatEnd, TeColorDescSatEnd, TeColorAscSatBegin, TeColorDescSatBegin };
+
+//! Types of attribute tables in a layer
+enum TeAttrTableType
+{	TeAllAttrTypes, TeAttrStatic, TeAttrMedia, TeAttrExternal, TeAttrEvent, TeFixedGeomDynAttr, 
+	TeDynGeomDynAttr, TeGeomAttrLinkTime, TeGeocodingData };
+
+//! Types of integrity relations among tables in a database
+enum TeDBRelationType
+{	TeNoRelation, TeRINoCascadeDeletion, TeRICascadeDeletion };
+
+//! Data types
+enum TeDataType 
+{	TeBIT, TeUNSIGNEDCHAR, TeCHAR, TeUNSIGNEDSHORT, TeSHORT, TeINTEGER, TeUNSIGNEDLONG, TeLONG, TeFLOAT, TeDOUBLE };
+
+
+//!	Statistics
+/*!
+	 - TeSUM				sum of the values
+	 - TeMAXVALUE			maximum value
+	 - TeMINVALUE			minimal value
+	 - TeCOUNT				total number of the values
+	 - TeVALIDCOUNT			valid number of the values
+	 - TeSTANDARDDEVIATION	standard deviation 
+	 - TeKERNEL				kernel
+	 - TeMEAN				mean
+	 - TeVARIANCE			variance
+	 - TeSKEWNESS			third moment about the Mean 			
+	 - TeKURTOSIS			forth moment about the Mean
+	 - TeAMPLITUDE			maximum value minus minimal value
+	 - TeMEDIAN				median value
+	 - TeVARCOEFF			coefficient of variation 
+	 - TeMODE				value more frequent 
+*/ 
+enum TeStatisticType
+{	TeNOSTATISTIC, TeSUM, TeMAXVALUE, TeMINVALUE, TeCOUNT, TeVALIDCOUNT, TeSTANDARDDEVIATION, TeKERNEL,  
+	TeMEAN, TeVARIANCE, TeSKEWNESS, TeKURTOSIS, TeAMPLITUDE, TeMEDIAN, TeVARCOEFF, TeMODE};
+
+//! A map of an statistic to its value
+typedef map<TeStatisticType, double> TeStatisticValMap;
+
+//! A map of an statistic to its string value
+typedef map<TeStatisticType, string> TeStatisticStringValMap;
+
+//! A map of an object id to its statistics
+typedef map<string, TeStatisticValMap> TeObjStatisticsMap;
+
+//! A map of an statistic to the column name where its value is stored
+typedef map<TeStatisticType, string> TeStatisticsMap;
+
+//! Intersection Algorithms.
+enum TeIntersectorAlgorithm { TeBentleyOttman, TeRedBlue, TeTrivial };
+
+//! Topological relations
+enum TeSpatialRelation	
+{	TeDISJOINT = 1, TeTOUCHES = 2, TeCROSSES = 4, TeWITHIN = 8, 
+	TeOVERLAPS = 16, TeCONTAINS = 32, TeINTERSECTS = 64, TeEQUALS = 128, TeCOVERS = 256,
+	TeCOVEREDBY = 512, TeUNDEFINEDREL = 1024};
+
+//! Temporal predicates
+enum TeTemporalRelation { TeTIMEUNDEFINED, TeTIMEEQUAL, TeTIMEBEFORE, TeTIMEAFTER, TeTIMEMEETS, TeTIMEDURING, TeTIMEOVERLAPS, TeTIMEENDS, TeTIMESTARTS };
+
+//! Logical predicates
+enum TeLogicalOperator { TeAND = 1, TeOR = 2 };
+
+//! Time chronons
+enum TeChronon {	TeNOCHRONON, TeSECOND, TeMINUTE, TeHOUR, TeDAY, TeMONTH, TeYEAR,
+					TeDAYOFWEEK, TeDAYOFMONTH, TeDAYOFYEAR, TeMONTHOFYEAR, TeSEASON, TeWEEKOFYEAR, 
+					TeHOUROFDAY, TeMINUTEOFHOUR, TeSECONDOFMINUTE };
+
+//! Polygon style types
+enum TePolyBasicType { TePolyTypeTransparent=0, TePolyTypeFill=1, TePolyTypeHorizontal=2,
+					 TePolyTypeVertical=3, TePolyTypeFDiagonal=4, TePolyTypeBDiagonal=5,
+					 TePolyTypeCross=6, TePolyTypeDiagonalCross=7 };
+//! Line style types
+enum TeLnBasicType { TeLnTypeContinuous=0, TeLnTypeDashed=1, TeLnTypeDotted=2,  
+					 TeLnTypeDashDot=3, TeLnTypeDashDotDot=4, TeLnTypeNone=5,
+					 TeLnTypeCustom=6 };
+//! Point style types
+enum TePtBasicType { TePtTypePlus=0, TePtTypeStar=1, TePtTypeCircle=2, TePtTypeX=3,  
+					 TePtTypeBox=4, TePtTypeDiamond=5, TePtTypeHollowCircle=6, 
+					 TePtTypeHollowBox=7, TePtTypeHollowDiamond=8 };
+
+//! Type of segment intersection
+enum TeSegmentIntersectionType { TeProperIntersection, TeImproperIntersection };
+
+//! Types of implementations of a generalized proximity matrix 
+enum TeGPMImplementation { TeGraphBreymann };
+
+//! Construction strategies to the generalized proximity matrix 
+enum TeGPMConstructionStrategy { TeAdjacencyStrategy, TeDistanceStrategy, TeNearestNeighboursStrategy,
+								 TeClosedNetworkStrategy, TeOpenNetworkStrategy, TeOpenNetworkStrategy2 };
+
+//! Slicing strategies to the generalized proximity matrix 
+enum TeGPMSlicingStrategy { TeNoSlicingStrategy, TeZonesSlicingStrategy };
+	
+//! Weight strategies to the generalized proximity matrix 
+enum TeGPMWeightsStrategy { TeNoWeightsStrategy, TeInverseDistanceStrategy, 
+							TeSquaredInverseDistStrategy, TeConnectionStrenghtStrategy};
+
+
+#endif
diff --git a/src/terralib/kernel/TeDatabase.cpp b/src/terralib/kernel/TeDatabase.cpp
new file mode 100644
index 0000000..c27806a
--- /dev/null
+++ b/src/terralib/kernel/TeDatabase.cpp
@@ -0,0 +1,9711 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDatabase.h"
+#include "TeDecoderDatabase.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeSpatialOperations.h"
+#include "TeImportRaster.h"
+#include "TeLayer.h"
+#include "TeAbstractTheme.h"
+#include "TeExternalTheme.h"
+#include "TeDatabaseFactoryParams.h"
+#include <TeRasterTransform.h>
+#include <TeTimeInterval.h>
+
+#include <sys/stat.h>
+#include <stdio.h>
+#include <sstream>
+
+typedef map<int,TeNode> TeNodeMap;
+
+static const int scales [] =
+{	150000,
+	80000,
+	40000,
+	20000,
+	10000,
+	3000,
+	1500,
+	800,
+	400,
+	200,
+	100,
+	30,
+	15,
+	8,
+	4,
+	2,
+	1
+};
+
+//-*********************
+
+TeDatabase::TeDatabase() :
+	isConnected_ (false),
+	host_(""),
+	user_(""),
+	password_(""),
+	database_(""),
+	portNumber_(-1),
+	errorNumber_(0),
+	errorMessage_(""),
+	transactionCounter_(0)
+{
+	metaModel_.reset(new TeMetaModelCache);
+}
+
+TeDatabase& TeDatabase::operator=(const TeDatabase& other)
+{
+	if(this != &other)
+		metaModel_ = other.metaModel_;	
+
+	return *this;
+}
+
+TeDatabase::~TeDatabase()
+{
+}
+
+string
+TeDatabase::getDatabaseDescription()
+{
+    std::stringstream desc;
+    const char sep = ';';
+
+    desc << dbmsName_;
+    desc << sep << host_;
+    desc << sep << portNumber_;
+    desc << sep << database_;
+    desc << sep << user_;
+    desc << sep << password_;
+
+    return desc.str();
+} 
+
+void TeDatabase::alterTableInfoInMemory(const string& updatedTableName, string oldTableName)
+{
+	//update table in memory
+	TeTable updatedTable(updatedTableName);
+	loadTableInfo(updatedTable);
+	if(oldTableName.empty())
+		oldTableName = updatedTableName;
+
+	TeLayerMap::iterator itLayer = metaModel_->layerMap().begin();
+	while(itLayer!=metaModel_->layerMap().end())
+	{
+		TeAttrTableVector::iterator itAttr = itLayer->second->attrTables().begin();
+		while(itAttr!=itLayer->second->attrTables().end())
+		{
+			if(TeConvertToUpperCase(itAttr->name())==TeConvertToUpperCase(oldTableName))
+			{
+				(*itAttr)=updatedTable;
+				break;
+			}
+			++itAttr;
+		}
+		++itLayer;
+	}
+	TeThemeMap::iterator itTheme = metaModel_->themeMap().begin();
+	while(itTheme!=metaModel_->themeMap().end())
+	{
+		if(itTheme->second->getProductId() != TeTHEME)
+		{
+			++itTheme; 
+			continue;
+		}
+
+		TeTheme* theme = static_cast<TeTheme*>(itTheme->second);
+				
+		TeAttrTableVector::iterator itAttr = theme->attrTables().begin();
+		while(itAttr!=theme->attrTables().end())
+		{
+			if(TeConvertToUpperCase(itAttr->name())==TeConvertToUpperCase(oldTableName))
+			{
+				(*itAttr)=updatedTable;
+				theme->loadAliasVector();
+				theme->loadAttrLists();
+				theme->loadTablesJoin(); 
+				break;
+			}
+			++itAttr;
+		}
+		++itTheme;
+	}
+	return;
+}
+
+bool TeDatabase::validTable (TeTable& table)
+{
+	int cont=0;
+	bool change = false;
+	bool changeTable = false;
+	bool uniqueName, linkName; 
+	
+	TeAttributeList::iterator it = table.attributeList().begin();
+	TeAttributeList::iterator it2;  
+	while(it != table.attributeList().end())
+	{
+		uniqueName = false;
+		linkName = false;
+
+		if((*it).rep_.name_==table.uniqueName())
+			uniqueName=true;
+		
+		if((*it).rep_.name_==table.linkName())
+			linkName=true;
+
+		string errorMess;
+		string temp = TeCheckName((*it).rep_.name_, change, errorMess);
+		
+		if(change)
+		{
+			it2 = table.attributeList().begin();
+			while(it2!=table.attributeList().end())
+			{
+				if(temp==(*it2).rep_.name_)
+				{
+					temp += Te2String(cont);
+					it2 = table.attributeList().begin();
+					++cont;
+				}
+				else
+					++it2;
+			}
+
+			changeTable = true;
+		}
+
+		if(change && uniqueName)
+			table.setUniqueName(temp);
+		if(change && linkName)
+			table.setLinkName (temp);
+
+		(*it).rep_.name_ = temp;
+		++it;
+		++cont;
+	}
+	
+	return changeTable;
+}
+
+string TeDatabase::getTableName(int tableId)
+{
+	string tableName;
+
+	TeDatabasePortal* pt = getPortal();
+	string q = "SELECT attr_table FROM te_layer_table";
+	q += " WHERE table_id = " + Te2String(tableId);
+	if (pt->query(q) == true && pt->fetchRow())
+		tableName = pt->getData("attr_table");
+	delete pt;
+	return tableName;
+}
+
+bool
+TeDatabase::deleteTable (const string& table)
+{
+//	int f =	table.find ("te_collection", std::string::npos);
+	int f =	table.find ("te_collection");
+
+	if( table=="te_theme" ||
+		table=="te_layer" ||
+		table=="te_representation" ||
+		table=="te_tables_relation" ||
+		table=="te_layer_table" ||
+		table=="te_raster_metadata" ||
+		table=="te_projection" ||
+		table=="te_view" ||
+		table=="te_legend" ||
+		table=="te_visual" ||
+		table=="te_database" ||
+		f == 0)
+	{
+		errorMessage_ = "N�o � poss�vel deletar tabelas do modelo!";
+		return false;
+	}
+
+	string del = "DROP TABLE " + table;
+	if(tableExist(table))
+	{
+		if(!execute(del))
+			return false;
+	}
+
+	return true;
+}
+
+
+bool 
+TeDatabase::deleteColumn (const string& table, const string& colName)
+{
+	if(!tableExist(table))
+		return false;
+	TeAttribute attr;
+	if (!columnExist(table,colName,attr))
+		return true;
+	string drop = "ALTER  TABLE "+ table +" DROP COLUMN "+ colName;
+	if(execute(drop) == false)
+		return false;
+
+	string tableId;
+	TeDatabasePortal* portal = getPortal();
+	string sql = "SELECT table_id FROM te_layer_table WHERE attr_table = '" + table + "'";
+	if(portal->query(sql) && portal->fetchRow())
+		tableId = portal->getData(0);
+
+	delete portal;
+	if(tableId.empty() == false)
+	{
+		// delete relation
+		sql = "DELETE FROM te_tables_relation WHERE (related_table_id = " + tableId;
+		sql += " AND related_attr = '" + colName + "')";
+		sql += " OR (external_table_name = '" + table + "'";
+		sql += " AND external_attr = '" + colName + "')";
+		if(execute(sql) == false)
+			return false;
+
+		// delete grouping
+		TeDatabasePortal* portal = getPortal();
+		sql = "SELECT theme_id FROM te_grouping WHERE grouping_attr = '" + table + "." + colName + "'";
+		if(portal->query(sql) && portal->fetchRow())
+		{
+			string themeId = portal->getData(0);
+
+			sql = "DELETE FROM te_legend WHERE theme_id = " + themeId + " AND group_id >= 0";
+			if(execute(sql) == false)
+			{
+				delete portal;
+				return false;
+			}
+		}
+		delete portal;
+
+		sql = "DELETE FROM te_grouping";
+		sql += " WHERE grouping_attr = '" + table + "." + colName + "'";
+		if(execute(sql) == false)
+			return false;
+	}
+	alterTableInfoInMemory(table);
+	return true;
+}
+
+bool 
+TeDatabase::defineIntegrity(void)
+{
+	if (existRelation("te_layer","fk_layer_proj_id") == TeNoRelation )
+		if (!createRelation("fk_layer_proj_id", "te_layer", "projection_id", "te_projection", "projection_id", false))
+			return false;
+        
+	if (existRelation("te_representation","fk_rep_layer_id") == TeNoRelation )
+		if (!createRelation("fk_rep_layer_id", "te_representation", "layer_id", "te_layer", "layer_id", true))
+			return false;
+
+	if (existRelation("te_view","fk_view_proj_id") == TeNoRelation )
+		if (!createRelation("fk_view_proj_id", "te_view", "projection_id", "te_projection", "projection_id", false))
+			return false;
+
+	if (existRelation("te_view", "fk_view_current_theme") == TeNoRelation )
+		if (!createRelation("fk_view_current_theme", "te_view", "current_theme", "te_theme", "theme_id", false))
+			return false;
+	
+	if (existRelation("te_theme","fk_theme_layer_id") == TeNoRelation )
+		if (!createRelation("fk_theme_layer_id", "te_theme", "layer_id", "te_layer", "layer_id", true))
+			return false;
+
+	if (existRelation("te_theme","fk_theme_view_id") == TeNoRelation )
+		if (!createRelation("fk_theme_view_id", "te_theme", "view_id", "te_view", "view_id", true))
+			return false;
+
+	if (existRelation("te_theme_table","fk_thmtable_theme_id") == TeNoRelation )
+		if (!createRelation("fk_thmtable_theme_id", "te_theme_table", "theme_id", "te_theme", "theme_id", true))
+			return false;
+
+	if (existRelation("te_theme_table","fk_thmtable_lytable_id") == TeNoRelation )
+		if (!createRelation("fk_thmtable_lytable_id", "te_theme_table", "table_id", "te_layer_table", "table_id", false))
+			return false;
+
+	if (existRelation("te_theme_table","fk_thmtable_relation_id") == TeNoRelation )
+		if (!createRelation("fk_thmtable_relation_id", "te_theme_table", "relation_id", "te_tables_relation", "relation_id", false))
+			return false;
+
+	if (existRelation("te_grouping","fk_group_theme_id") == TeNoRelation )
+		if (!createRelation("fk_group_theme_id", "te_grouping", "theme_id", "te_theme", "theme_id", true))
+			return false;
+
+	if (existRelation("te_legend","fk_legend_theme_id") == TeNoRelation )
+		if (!createRelation("fk_legend_theme_id", "te_legend", "theme_id", "te_theme", "theme_id", true))
+			return false;
+
+	if (existRelation("te_visual","fk_visual_legend_id") == TeNoRelation )
+		if (!createRelation("fk_visual_legend_id", "te_visual", "legend_id", "te_legend", "legend_id", true))
+			return false;
+        
+	if (existRelation("te_layer_table","fk_laytable_layer_id") == TeNoRelation )
+		if (!createRelation ("fk_laytable_layer_id", "te_layer_table", "layer_id", "te_layer", "layer_id", true))
+			return false;
+        
+	if (existRelation("te_tables_relation","fk_tabrelation_laytable_id") == TeNoRelation )
+		if (!createRelation("fk_tabrelation_laytable_id", "te_tables_relation", "related_table_id", "te_layer_table", "table_id", true))
+			return false;
+
+	if (existRelation("te_visual_raster","fk_visrast_theme_id") == TeNoRelation )
+		if (!createRelation("fk_visrast_theme_id", "te_visual_raster", "theme_id", "te_theme", "theme_id", true))
+			return false;
+
+	if (existRelation("te_project_view","fk_projectview_project_id") == TeNoRelation )
+		if (!createRelation("fk_projectview_project_id", "te_project_view", "project_id", "te_project", "project_id", true))
+			return false;
+
+	if (existRelation("te_project_view","fk_projectview_view_id") == TeNoRelation )
+		if (!createRelation("fk_projectview_view_id", "te_project_view", "view_id", "te_view", "view_id", true))
+			return false;
+
+	return true;
+}
+
+bool 
+TeDatabase::createConceptualModel(bool withIntegrity, bool newDatabase, bool /* createIndex */)
+{
+	bool status = true;
+	bool createMainTables = false;
+	
+	if (!this->tableExist("te_projection"))
+	{
+		status = this->createProjectionTable();
+		if (!status)
+			return false;	
+		createMainTables = true;
+	}
+
+	if (!this->tableExist("te_layer"))
+	{
+		status = this->createLayerTable();
+		if (!status)
+			return false;
+		createMainTables = true;
+	}
+
+	if (!this->tableExist("te_layer_table"))
+	{
+		status = this->createLayerTableTable();
+		if (!status)
+			return false;
+		createMainTables = true;
+	}
+
+	if (!this->tableExist("te_tables_relation"))
+	{
+		status = this->createTablesRelationTable();
+		if (!status)
+			return false;
+		createMainTables = true;
+	}
+	
+	if (!this->tableExist("te_representation"))
+	{
+		status = this->createRepresentationTable();
+		if (!status)
+			return false;
+		createMainTables = true;
+	}
+
+	if (!this->tableExist("te_theme"))
+	{
+		status = this->createThemeTable();
+		if (!status)
+			return false;
+		createMainTables = true;
+	}
+
+	if (!this->tableExist("te_view"))
+	{
+		status = this->createViewTable();
+		if (!status)
+			return false;
+		createMainTables = true;
+	}
+
+	if (!this->tableExist("te_grouping"))
+	{
+		status = this->createGroupingTable();
+		if (!status)
+			return false;
+	}
+
+	if (!this->tableExist("te_theme_table"))
+	{
+		status = this->createThemeTablesTable();
+		if (!status)
+			return false;
+	}
+
+	if (!this->tableExist("te_legend"))
+	{
+		status = this->createLegendTable();
+		if (!status)
+			return false;	
+	}
+
+	if (!this->tableExist("te_visual"))
+	{
+		status = this->createVisualTable();
+		if (!status)
+			return false;	
+	}
+
+	if (!this->tableExist("te_visual_raster"))
+	{
+		status = this->createVisualRasterTable();
+		if (!status)
+			return false;	
+	}
+
+	if (!this->tableExist("te_database"))
+	{
+		status = this->createDatabaseTable();
+		if (!status)
+			return false;
+	}
+
+	if (!this->tableExist("te_project"))
+	{
+		status = this->createProjectTable();
+		if (!status)
+			return false;
+	}
+
+	if (!this->tableExist("te_project_view"))
+	{
+		status = this->createProjectViewTable();
+		if (!status)
+			return false;
+	}
+	if (newDatabase || createMainTables)
+	{
+		string ins = "INSERT INTO te_database (db_version) VALUES ('" + TeDBVERSION + "')";
+		if (!execute(ins))
+			return false;
+	}
+
+	if (withIntegrity)
+		status = defineIntegrity();
+
+	return status;
+}
+
+bool
+TeDatabase::createIndex(const string& tableName, const string& indexName, const string& columnsName)
+{
+	string sql = "CREATE INDEX " + indexName + " ON " + tableName + "(" + columnsName + ")";	
+	return execute (sql);
+}
+
+bool 
+TeDatabase::createDatabaseTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attDBVersion;
+	attDBVersion.rep_.name_ = "db_version";
+	attDBVersion.rep_.type_ = TeSTRING;
+	attDBVersion.rep_.numChar_ = 50;
+	attDBVersion.rep_.isPrimaryKey_ = true;
+	attDBVersion.rep_.null_ = false;
+	attList.push_back(attDBVersion);}
+
+	{TeAttribute attDBCreation;
+	attDBCreation.rep_.name_ = "db_creation";
+	attDBCreation.rep_.type_ = TeDATETIME;
+	attList.push_back(attDBCreation);}
+
+	return createTable("te_database", attList);
+}
+
+bool 
+TeDatabase::createProjectTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attProjectId;
+	attProjectId.rep_.name_ = "project_id";
+	attProjectId.rep_.type_ = TeUNSIGNEDINT;
+	attProjectId.rep_.isAutoNumber_ = true;
+	attProjectId.rep_.isPrimaryKey_ = true;
+	attProjectId.rep_.null_ = false;
+	attList.push_back(attProjectId);}
+
+	{TeAttribute attName;
+	attName.rep_.name_ = "name";
+	attName.rep_.type_ = TeSTRING;
+	attName.rep_.numChar_ = 50;
+	attName.rep_.null_ = false;
+	attList.push_back(attName);}
+
+	{TeAttribute attDescription;
+	attDescription.rep_.name_ = "description";
+	attDescription.rep_.type_ = TeSTRING;
+	attDescription.rep_.numChar_ = 255;
+	attDescription.rep_.null_ = true;
+	attList.push_back(attDescription);}
+
+	{TeAttribute attCurrentView;
+	attCurrentView.rep_.name_ = "current_view";
+	attCurrentView.rep_.type_ = TeINT;
+	attList.push_back(attCurrentView);}
+
+	return createTable("te_project", attList);
+}
+
+bool 
+TeDatabase::createProjectViewTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attProjectId;
+	attProjectId.rep_.name_ = "project_id";
+	attProjectId.rep_.type_ = TeUNSIGNEDINT;
+	attProjectId.rep_.isPrimaryKey_ = true;
+	attProjectId.rep_.null_ = false;
+	attList.push_back(attProjectId);}
+
+	{TeAttribute attViewId;
+	attViewId.rep_.name_ = "view_id";
+	attViewId.rep_.type_ = TeUNSIGNEDINT;
+	attViewId.rep_.isPrimaryKey_ = true;
+	attViewId.rep_.null_ = false;
+	attList.push_back(attViewId);}
+
+	return createTable("te_project_view", attList);
+}
+
+bool 
+TeDatabase::createProjectionTable ()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attProjectId;
+	attProjectId.rep_.name_ = "projection_id";
+	attProjectId.rep_.type_ = TeUNSIGNEDINT;
+	attProjectId.rep_.isPrimaryKey_ = true;
+	attProjectId.rep_.isAutoNumber_ = true;
+	attProjectId.rep_.null_ = false;
+	attList.push_back(attProjectId);}
+
+	{TeAttribute attName;
+	attName.rep_.name_ = "name";
+	attName.rep_.type_ = TeSTRING;
+	attName.rep_.numChar_ = 50;
+	attName.rep_.null_ = false;
+	attList.push_back(attName);}
+
+	{TeAttribute attLong0;
+	attLong0.rep_.name_ = "long0";
+	attLong0.rep_.type_ = TeREAL;
+	attLong0.rep_.decimals_ = 15;
+	attLong0.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLong0);}
+
+	{TeAttribute attLat0;
+	attLat0.rep_.name_ = "lat0";
+	attLat0.rep_.type_ = TeREAL;
+	attLat0.rep_.decimals_ = 15;
+	attLat0.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLat0);}
+
+	{TeAttribute attOffX;
+	attOffX.rep_.name_ = "offx";
+	attOffX.rep_.type_ = TeREAL;
+	attOffX.rep_.decimals_ = 15;
+	attOffX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attOffX);}
+
+	{TeAttribute attOffY;
+	attOffY.rep_.name_ = "offy";
+	attOffY.rep_.type_ = TeREAL;
+	attOffY.rep_.decimals_ = 15;
+	attOffY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attOffY);}
+
+	{TeAttribute attSlat1;
+	attSlat1.rep_.name_ = "stlat1";
+	attSlat1.rep_.type_ = TeREAL;
+	attSlat1.rep_.decimals_ = 15;
+	attSlat1.rep_.defaultValue_ = "0.0";
+	attList.push_back(attSlat1);}
+
+	{TeAttribute attSlat2;
+	attSlat2.rep_.name_ = "stlat2";
+	attSlat2.rep_.type_ = TeREAL;
+	attSlat2.rep_.decimals_ = 15;
+	attSlat2.rep_.defaultValue_ = "0.0";
+	attList.push_back(attSlat2);}
+
+	{TeAttribute attUnit;
+	attUnit.rep_.name_ = "unit";
+	attUnit.rep_.type_ = TeSTRING;
+	attUnit.rep_.numChar_ = 50;
+	attUnit.rep_.null_ = false;
+	attList.push_back(attUnit);}
+
+	{TeAttribute attScale;
+	attScale.rep_.name_ = "scale";
+	attScale.rep_.type_ = TeREAL;
+	attScale.rep_.decimals_ = 15;
+	attScale.rep_.defaultValue_ = "0.0";
+	attList.push_back(attScale);}
+
+	{TeAttribute attHemis;
+	attHemis.rep_.name_ = "hemis";
+	attHemis.rep_.type_ = TeINT;
+	attHemis.rep_.null_ = false;
+	attList.push_back(attHemis);}
+
+	{TeAttribute attDatum;
+	attDatum.rep_.name_ = "datum";
+	attDatum.rep_.type_ = TeSTRING;
+	attDatum.rep_.numChar_ = 50;
+	attDatum.rep_.null_ = false;
+	attList.push_back(attDatum);}
+
+	{TeAttribute attRadius;
+	attRadius.rep_.name_ = "radius";
+	attRadius.rep_.type_ = TeREAL;
+	attRadius.rep_.decimals_ = 15;
+	attRadius.rep_.defaultValue_ = "0.0";
+	attList.push_back(attRadius);}
+
+	{TeAttribute attFlattening;
+	attFlattening.rep_.name_ = "flattening";
+	attFlattening.rep_.type_ = TeREAL;
+	attFlattening.rep_.decimals_ = 15;
+	attFlattening.rep_.defaultValue_ = "0.0";
+	attList.push_back(attFlattening);}
+
+	{TeAttribute attDX;
+	attDX.rep_.name_ = "dx";
+	attDX.rep_.type_ = TeREAL;
+	attDX.rep_.decimals_ = 15;
+	attDX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attDX);}
+
+	{TeAttribute attDY;
+	attDY.rep_.name_ = "dy";
+	attDY.rep_.type_ = TeREAL;
+	attDY.rep_.decimals_ = 15;
+	attDY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attDY);}
+
+	{TeAttribute attDZ;
+	attDZ.rep_.name_ = "dz";
+	attDZ.rep_.type_ = TeREAL;
+	attDZ.rep_.decimals_ = 15;
+	attDZ.rep_.defaultValue_ = "0.0";
+	attList.push_back(attDZ);}
+
+	return createTable("te_projection", attList);
+}
+
+bool TeDatabase::createLayerTable ()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attLayerId;
+	attLayerId.rep_.name_ = "layer_id";
+	attLayerId.rep_.type_ = TeUNSIGNEDINT;
+	attLayerId.rep_.isPrimaryKey_ = true;
+	attLayerId.rep_.isAutoNumber_ = true;
+	attLayerId.rep_.null_ = false;
+	attList.push_back(attLayerId);}
+
+	{TeAttribute attProjectionId;
+	attProjectionId.rep_.name_ = "projection_id";
+	attProjectionId.rep_.type_ = TeUNSIGNEDINT;
+	attProjectionId.rep_.null_ = false;
+	attList.push_back(attProjectionId);}
+
+	{TeAttribute attName;
+	attName.rep_.name_ = "name";
+	attName.rep_.type_ = TeSTRING;
+	attName.rep_.numChar_ = 255;
+	attName.rep_.null_ = false;
+	attList.push_back(attName);}
+
+	{TeAttribute attLowerX;
+	attLowerX.rep_.name_ = "lower_x";
+	attLowerX.rep_.type_ = TeREAL;
+	attLowerX.rep_.decimals_ = 15;
+	attLowerX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerX);}
+
+	{TeAttribute attLowerY;
+	attLowerY.rep_.name_ = "lower_y";
+	attLowerY.rep_.type_ = TeREAL;
+	attLowerY.rep_.decimals_ = 15;
+	attLowerY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerY);}
+
+	{TeAttribute attUpperX;
+	attUpperX.rep_.name_ = "upper_x";
+	attUpperX.rep_.type_ = TeREAL;
+	attUpperX.rep_.decimals_ = 15;
+	attUpperX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperX);}
+
+	{TeAttribute attUpperY;
+	attUpperY.rep_.name_ = "upper_y";
+	attUpperY.rep_.type_ = TeREAL;
+	attUpperY.rep_.decimals_ = 15;
+	attUpperY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperY);}
+
+	{TeAttribute attInitialTime;
+	attInitialTime.rep_.name_ = "initial_time";
+	attInitialTime.rep_.type_ = TeDATETIME;
+	attList.push_back(attInitialTime);}
+
+	{TeAttribute attFinalTime;
+	attFinalTime.rep_.name_ = "final_time";
+	attFinalTime.rep_.type_ = TeDATETIME;
+	attList.push_back(attFinalTime);}
+
+	if(!createTable("te_layer", attList))
+		return false;
+
+	string idxName = "te_idx_layer_proj";
+
+	if(!createIndex("te_layer", idxName, "projection_id"))
+		return false;
+
+	idxName = "te_idx_layer_name";
+
+	return createIndex("te_layer", idxName, "name");
+}
+
+bool TeDatabase::createLayerTableTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attTableId;
+	attTableId.rep_.name_ = "table_id";
+	attTableId.rep_.type_ = TeUNSIGNEDINT;
+	attTableId.rep_.isPrimaryKey_ = true;
+	attTableId.rep_.isAutoNumber_ = true;
+	attTableId.rep_.null_ = false;
+	attList.push_back(attTableId);}
+
+	{TeAttribute attLayerId;
+	attLayerId.rep_.name_ = "layer_id";
+	attLayerId.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attLayerId);}
+
+	{TeAttribute attTable;
+	attTable.rep_.name_ = "attr_table";
+	attTable.rep_.type_ = TeSTRING;
+	attTable.rep_.numChar_ = 255;
+	attTable.rep_.null_ = false;
+	attList.push_back(attTable);}
+
+	{TeAttribute attUniqueID;
+	attUniqueID.rep_.name_ = "unique_id";
+	attUniqueID.rep_.type_ = TeSTRING;
+	attUniqueID.rep_.numChar_ = 255;
+	attList.push_back(attUniqueID);}
+
+	{TeAttribute attLink;
+	attLink.rep_.name_ = "attr_link";
+	attLink.rep_.type_ = TeSTRING;
+	attLink.rep_.numChar_ = 255;
+	attList.push_back(attLink);}
+
+	{TeAttribute attAttrInitialTime;
+	attAttrInitialTime.rep_.name_ = "attr_initial_time";
+	attAttrInitialTime.rep_.type_ = TeSTRING;
+	attAttrInitialTime.rep_.numChar_ = 255;
+	attList.push_back(attAttrInitialTime);}
+
+	{TeAttribute attAttrFinalTime;
+	attAttrFinalTime.rep_.name_ = "attr_final_time";
+	attAttrFinalTime.rep_.type_ = TeSTRING;
+	attAttrFinalTime.rep_.numChar_ = 255;
+	attList.push_back(attAttrFinalTime);}
+
+	{TeAttribute attTimeUnit;
+	attTimeUnit.rep_.name_ = "attr_time_unit";
+	attTimeUnit.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attTimeUnit);}
+
+	{TeAttribute attTableType;
+	attTableType.rep_.name_ = "attr_table_type";
+	attTableType.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attTableType);}
+
+	{TeAttribute attUserName;
+	attUserName.rep_.name_ = "user_name";
+	attUserName.rep_.type_ = TeSTRING;
+	attUserName.rep_.numChar_ = 255;
+	attList.push_back(attUserName);}
+
+	{TeAttribute attInitialTime;
+	attInitialTime.rep_.name_ = "initial_time";
+	attInitialTime.rep_.type_ = TeDATETIME;
+	attList.push_back(attInitialTime);}
+
+	{TeAttribute attFinalTime;
+	attFinalTime.rep_.name_ = "final_time";
+	attFinalTime.rep_.type_ = TeDATETIME;
+	attList.push_back(attFinalTime);}
+
+	if(!createTable("te_layer_table", attList))
+		return false;
+
+	string idxName = "te_idx_layertable_layer";
+
+	if(!createIndex("te_layer_table", idxName, "layer_id"))
+		return false;
+
+	idxName = "te_idx_layertable_att";
+
+	return createIndex("te_layer_table", idxName, "attr_table");
+}
+
+bool 
+TeDatabase::updateTableInfo(int layerId, TeTable &table, const string user)
+{
+	if (table.id() <= 0 )  // table information doesn�t exist in database yet
+		return this->insertTableInfo(layerId,table,user);
+	string sql;
+	sql = "UPDATE te_layer_table SET ";
+	sql += "unique_id='" + table.uniqueName() + "', ";
+	sql += "attr_link='" + table.linkName() + "', ";
+	sql += "attr_initial_time='" + table.attInitialTime() + "', ";
+	sql += "attr_final_time='" + table.attFinalTime() + "', ";
+	sql += "attr_time_unit=" + Te2String(table.attTimeUnit()) + ", ";
+	sql += "attr_table_type="+ Te2String(table.tableType()) + ", ";
+	sql += "user_name='" + user + "' WHERE ";
+	sql += "layer_id=" + Te2String(layerId) + " AND ";
+	sql += "attr_table_name='" + table.name() + "'";
+	return execute (sql);
+}
+
+bool 
+TeDatabase::loadTableInfo(TeTable& table)
+{
+	if (table.name().empty())
+		return false;
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+	{
+		this->errorMessage_ = "N�o foi poss�vel abrir portal para o banco";
+		return false;
+	}
+	
+	//theme tables
+	string sel = " SELECT table_id, layer_id, attr_table, unique_id, ";
+	sel += " attr_link, attr_initial_time, attr_final_time, attr_time_unit, ";
+	sel += " attr_table_type, user_name, initial_time, final_time ";
+	sel += " FROM te_layer_table ";
+	sel += " WHERE  attr_table = '" + table.name() + "'";
+		
+	if ((!portal->query(sel)) || (!portal->fetchRow()))
+	{	
+		delete portal;
+		return false;
+	}
+	
+	if(!portal->getAttrTable(table))
+	{
+		delete portal;
+		return false;
+	}
+
+	TeAttributeList attrList;
+	getAttributeList(table.name(), attrList);
+	table.setAttributeList(attrList);
+	
+	if (table.tableType() == TeAttrExternal) //information about external table 
+	{
+		portal->freeResult();
+
+		sel = " SELECT te_layer_table.attr_table, te_tables_relation.related_table_id, ";
+		sel += " te_tables_relation.related_attr, te_tables_relation.external_attr  ";
+		sel += " FROM te_layer_table INNER JOIN te_tables_relation";
+		sel += " ON te_layer_table.table_id = te_tables_relation.related_table_id ";
+		sel += " WHERE  te_tables_relation.external_table_name = '" + table.name() + "'";
+
+		if (!portal->query(sel))
+		{	
+			delete portal;
+			return false;
+		}
+
+		if (!portal->fetchRow())
+		{
+			delete portal;
+			return true;
+		}
+		
+		int relatedTableId = portal->getInt(1); //related_table_id
+		string relatedTable = portal->getData(0); //static table name 
+		string relatedAttr = portal->getData(2); // static column name - related_attr
+        		
+		table.setTableType(TeAttrExternal, relatedTableId, relatedAttr);
+		table.relatedTableName(relatedTable);
+		table.setLinkName(portal->getData(3));  //external column name - external_attr
+	}
+	
+	delete portal;
+	return true;
+}
+
+
+bool TeDatabase::createLUTTable(const string& name)
+{
+	if(name.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attIndexId;
+	attIndexId.rep_.name_ = "index_id";
+	attIndexId.rep_.type_ = TeUNSIGNEDINT;
+	attIndexId.rep_.isPrimaryKey_ = true;
+	attIndexId.rep_.null_ = false;
+	attList.push_back(attIndexId);}
+
+	{TeAttribute attRVal;
+	attRVal.rep_.name_ = "r_val";
+	attRVal.rep_.type_ = TeUNSIGNEDINT;
+	attRVal.rep_.null_ = false;
+	attList.push_back(attRVal);}
+
+	{TeAttribute attGVal;
+	attGVal.rep_.name_ = "g_val";
+	attGVal.rep_.type_ = TeUNSIGNEDINT;
+	attGVal.rep_.null_ = false;
+	attList.push_back(attGVal);}
+
+	{TeAttribute attBVal;
+	attBVal.rep_.name_ = "b_val";
+	attBVal.rep_.type_ = TeUNSIGNEDINT;
+	attBVal.rep_.null_ = false;
+	attList.push_back(attBVal);}
+
+	return createTable(name, attList);
+}
+
+bool TeDatabase::createTablesRelationTable()
+{
+	TeAttributeList attList;
+	
+	{TeAttribute attRelationId;
+	attRelationId.rep_.name_ = "relation_id";
+	attRelationId.rep_.type_ = TeUNSIGNEDINT;
+	attRelationId.rep_.isAutoNumber_ = true;
+	attRelationId.rep_.isPrimaryKey_ = true;
+	attRelationId.rep_.null_ = false;
+	attList.push_back(attRelationId);}
+
+	{TeAttribute attRelatedTableId;
+	attRelatedTableId.rep_.name_ = "related_table_id";
+	attRelatedTableId.rep_.type_ = TeINT;
+	attRelatedTableId.rep_.null_ = false;
+	attList.push_back(attRelatedTableId);}
+
+	{TeAttribute attRelatedAttr;
+	attRelatedAttr.rep_.name_ = "related_attr";
+	attRelatedAttr.rep_.type_ = TeSTRING;
+	attRelatedAttr.rep_.numChar_ = 255;
+	attRelatedAttr.rep_.null_ = false;
+	attList.push_back(attRelatedAttr);}
+
+	{TeAttribute attExternalTableName;
+	attExternalTableName.rep_.name_ = "external_table_name";
+	attExternalTableName.rep_.type_ = TeSTRING;
+	attExternalTableName.rep_.numChar_ = 255;
+	attExternalTableName.rep_.null_ = false;
+	attList.push_back(attExternalTableName);}
+
+	{TeAttribute attExternalAttr;
+	attExternalAttr.rep_.name_ = "external_attr";
+	attExternalAttr.rep_.type_ = TeSTRING;
+	attExternalAttr.rep_.numChar_ = 255;
+	attExternalAttr.rep_.null_ = false;
+	attList.push_back(attExternalAttr);}
+
+	return createTable("te_tables_relation", attList);
+}
+
+bool TeDatabase::createRepresentationTable ()
+{
+	TeAttributeList attList;
+	
+	{TeAttribute attRepresId;
+	attRepresId.rep_.name_ = "repres_id";
+	attRepresId.rep_.type_ = TeUNSIGNEDINT;
+	attRepresId.rep_.isAutoNumber_ = true;
+	attRepresId.rep_.isPrimaryKey_ = true;
+	attRepresId.rep_.null_ = false;
+	attList.push_back(attRepresId);}
+
+	{TeAttribute attLayerId;
+	attLayerId.rep_.name_ = "layer_id";
+	attLayerId.rep_.type_ = TeUNSIGNEDINT;
+	attLayerId.rep_.null_ = false;
+	attList.push_back(attLayerId);}
+
+	{TeAttribute attGeomType;
+	attGeomType.rep_.name_ = "geom_type";
+	attGeomType.rep_.type_ = TeINT;
+	attGeomType.rep_.null_ = false;
+	attList.push_back(attGeomType);}
+
+	{TeAttribute attGeomTable;
+	attGeomTable.rep_.name_ = "geom_table";
+	attGeomTable.rep_.type_ = TeSTRING;
+	attGeomTable.rep_.numChar_ = 255;
+	attGeomTable.rep_.null_ = false;
+	attList.push_back(attGeomTable);}
+
+	{TeAttribute attDescription;
+	attDescription.rep_.name_ = "description";
+	attDescription.rep_.type_ = TeSTRING;
+	attDescription.rep_.numChar_ = 255;
+	attList.push_back(attDescription);}
+
+	{TeAttribute attLowerX;
+	attLowerX.rep_.name_ = "lower_x";
+	attLowerX.rep_.type_ = TeREAL;
+	attLowerX.rep_.decimals_ = 15;
+	attLowerX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerX);}
+
+	{TeAttribute attLowerY;
+	attLowerY.rep_.name_ = "lower_y";
+	attLowerY.rep_.type_ = TeREAL;
+	attLowerY.rep_.decimals_ = 15;
+	attLowerY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerY);}
+
+	{TeAttribute attUpperX;
+	attUpperX.rep_.name_ = "upper_x";
+	attUpperX.rep_.type_ = TeREAL;
+	attUpperX.rep_.decimals_ = 15;
+	attUpperX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperX);}
+
+	{TeAttribute attUpperY;
+	attUpperY.rep_.name_ = "upper_y";
+	attUpperY.rep_.type_ = TeREAL;
+	attUpperY.rep_.decimals_ = 15;
+	attUpperY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperY);}
+
+	{TeAttribute attResX;
+	attResX.rep_.name_ = "res_x";
+	attResX.rep_.type_ = TeREAL;
+	attResX.rep_.decimals_ = 15;
+	attResX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attResX);}
+
+	{TeAttribute attResY;
+	attResY.rep_.name_ = "res_y";
+	attResY.rep_.type_ = TeREAL;
+	attResY.rep_.decimals_ = 15;
+	attResY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attResY);}
+
+	{TeAttribute attNumCols;
+	attNumCols.rep_.name_ = "num_cols";
+	attNumCols.rep_.type_ = TeINT;
+	attList.push_back(attNumCols);}
+
+	{TeAttribute attNumRows;
+	attNumRows.rep_.name_ = "num_rows";
+	attNumRows.rep_.type_ = TeINT;
+	attList.push_back(attNumRows);}
+
+	{TeAttribute attInitialTime;
+	attInitialTime.rep_.name_ = "initial_time";
+	attInitialTime.rep_.type_ = TeDATETIME;
+	attList.push_back(attInitialTime);}
+
+	{TeAttribute attFinalTime;
+	attFinalTime.rep_.name_ = "final_time";
+	attFinalTime.rep_.type_ = TeDATETIME;
+	attList.push_back(attFinalTime);}
+
+	if(!createTable("te_representation", attList))
+		return false;
+
+	string idxName = "te_idx_representation";
+
+	return createIndex("te_representation", idxName, "layer_id");
+}
+
+bool TeDatabase::createRasterMetadataTable(const string& tableName)
+{
+	if(tableName.empty())
+		return false;
+
+	TeAttributeList attList;
+	
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attBandId;
+	attBandId.rep_.name_ = "band_id";
+	attBandId.rep_.type_ = TeUNSIGNEDINT;
+	attBandId.rep_.isPrimaryKey_ = true;
+	attBandId.rep_.null_ = false;
+	attList.push_back(attBandId);}
+
+	{TeAttribute attMinValue;
+	attMinValue.rep_.name_ = "min_value";
+	attMinValue.rep_.type_ = TeREAL;
+	attMinValue.rep_.decimals_ = 15;
+	attMinValue.rep_.defaultValue_ = "0.0";
+	attList.push_back(attMinValue);}
+
+	{TeAttribute attMaxValue;
+	attMaxValue.rep_.name_ = "max_value";
+	attMaxValue.rep_.type_ = TeREAL;
+	attMaxValue.rep_.decimals_ = 15;
+	attMaxValue.rep_.defaultValue_ = "0.0";
+	attList.push_back(attMaxValue);}
+
+	{TeAttribute attNumBits;
+	attNumBits.rep_.name_ = "num_bits";
+	attNumBits.rep_.type_ = TeINT;
+	attList.push_back(attNumBits);}
+
+	{TeAttribute attDatatype;
+	attDatatype.rep_.name_ = "data_type";
+	attDatatype.rep_.type_ = TeINT;
+	attList.push_back(attDatatype);}
+
+	{TeAttribute attPhotoType;
+	attPhotoType.rep_.name_ = "photometric_type";
+	attPhotoType.rep_.type_ = TeINT;
+	attList.push_back(attPhotoType);}
+
+	{TeAttribute attCompressType;
+	attCompressType.rep_.name_ = "compression_type";
+	attCompressType.rep_.type_ = TeINT;
+	attList.push_back(attCompressType);}
+
+	{TeAttribute attDummy;
+	attDummy.rep_.name_ = "dummy";
+	attDummy.rep_.type_ = TeREAL;
+	attDummy.rep_.decimals_ = 15;
+	attList.push_back(attDummy);}
+
+	return createTable(tableName, attList);
+}
+
+bool TeDatabase::createRasterTable(const string& tableName)
+{
+	if(tableName.empty())
+		return false;
+
+	TeAttributeList attList;
+	
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "block_id";
+	attGeomId.rep_.type_ = TeSTRING;
+	attGeomId.rep_.numChar_ = 50;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attSpatialData;
+	attSpatialData.rep_.name_ = "spatial_data";
+	attSpatialData.rep_.type_ = TeRASTERTYPE;
+	attList.push_back(attSpatialData);}
+
+	if(!createTable(tableName, attList))
+		return false;
+
+	string idxName = "te_idx_" + tableName + "_b";
+
+	return createIndex(tableName, idxName, "band_id");
+}
+
+bool TeDatabase::createRasterGeometry(const string& tableName)
+{
+	if(tableName.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attRasterTable;
+	attRasterTable.rep_.name_ = "raster_table";
+	attRasterTable.rep_.type_ = TeSTRING;
+	attRasterTable.rep_.numChar_ = 255;
+	attRasterTable.rep_.null_ = false;
+	attList.push_back(attRasterTable);}
+
+	{TeAttribute attLutTable;
+	attLutTable.rep_.name_ = "lut_table";
+	attLutTable.rep_.type_ = TeSTRING;
+	attLutTable.rep_.numChar_ = 255;
+	attList.push_back(attLutTable);}
+
+	{TeAttribute attResX;
+	attResX.rep_.name_ = "res_x";
+	attResX.rep_.type_ = TeREAL;
+	attResX.rep_.decimals_ = 15;
+	attResX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attResX);}
+
+	{TeAttribute attResY;
+	attResY.rep_.name_ = "res_y";
+	attResY.rep_.type_ = TeREAL;
+	attResY.rep_.decimals_ = 15;
+	attResY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attResY);}
+
+	{TeAttribute attNumBands;
+	attNumBands.rep_.name_ = "num_bands";
+	attNumBands.rep_.type_ = TeINT;
+	attList.push_back(attNumBands);}
+
+	{TeAttribute attNumCols;
+	attNumCols.rep_.name_ = "num_cols";
+	attNumCols.rep_.type_ = TeINT;
+	attList.push_back(attNumCols);}
+
+	{TeAttribute attNumRows;
+	attNumRows.rep_.name_ = "num_rows";
+	attNumRows.rep_.type_ = TeINT;
+	attList.push_back(attNumRows);}
+
+	{TeAttribute attBlockHeight;
+	attBlockHeight.rep_.name_ = "block_height";
+	attBlockHeight.rep_.type_ = TeINT;
+	attList.push_back(attBlockHeight);}
+
+	{TeAttribute attBlockWidth;
+	attBlockWidth.rep_.name_ = "block_width";
+	attBlockWidth.rep_.type_ = TeINT;
+	attList.push_back(attBlockWidth);}
+
+	{TeAttribute attLowerX;
+	attLowerX.rep_.name_ = "lower_x";
+	attLowerX.rep_.type_ = TeREAL;
+	attLowerX.rep_.decimals_ = 15;
+	attLowerX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerX);}
+
+	{TeAttribute attLowerY;
+	attLowerY.rep_.name_ = "lower_y";
+	attLowerY.rep_.type_ = TeREAL;
+	attLowerY.rep_.decimals_ = 15;
+	attLowerY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerY);}
+
+	{TeAttribute attUpperX;
+	attUpperX.rep_.name_ = "upper_x";
+	attUpperX.rep_.type_ = TeREAL;
+	attUpperX.rep_.decimals_ = 15;
+	attUpperX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperX);}
+
+	{TeAttribute attUpperY;
+	attUpperY.rep_.name_ = "upper_y";
+	attUpperY.rep_.type_ = TeREAL;
+	attUpperY.rep_.decimals_ = 15;
+	attUpperY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperY);}
+
+	{TeAttribute attTilingType;
+	attTilingType.rep_.name_ = "tiling_type";
+	attTilingType.rep_.type_ = TeINT;
+	attList.push_back(attTilingType);}
+
+	if(!createTable(tableName, attList))
+		return  false;
+
+	string idxName = "te_idx_" + tableName;
+
+	return createIndex(tableName,  idxName, "object_id");
+}
+
+bool TeDatabase::createViewTable ()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attViewId;
+	attViewId.rep_.name_ = "view_id";
+	attViewId.rep_.type_ = TeUNSIGNEDINT;
+	attViewId.rep_.isPrimaryKey_ = true;
+	attViewId.rep_.isAutoNumber_ = true;
+	attViewId.rep_.null_ = false;
+	attList.push_back(attViewId);}
+
+	{TeAttribute attProjectionId;
+	attProjectionId.rep_.name_ = "projection_id";
+	attProjectionId.rep_.type_ = TeUNSIGNEDINT;
+	attProjectionId.rep_.null_ = false;
+	attList.push_back(attProjectionId);}
+
+	{TeAttribute attName;
+	attName.rep_.name_ = "name";
+	attName.rep_.type_ = TeSTRING;
+	attName.rep_.numChar_ = 255;
+	attName.rep_.null_ = false;
+	attList.push_back(attName);}
+
+	{TeAttribute attUserName;
+	attUserName.rep_.name_ = "user_name";
+	attUserName.rep_.type_ = TeSTRING;
+	attUserName.rep_.numChar_ = 255;
+	attList.push_back(attUserName);}
+
+	{TeAttribute attVisibility;
+	attVisibility.rep_.name_ = "visibility";
+	attVisibility.rep_.type_ = TeINT;
+	attList.push_back(attVisibility);}
+
+	{TeAttribute attLowerX;
+	attLowerX.rep_.name_ = "lower_x";
+	attLowerX.rep_.type_ = TeREAL;
+	attLowerX.rep_.decimals_ = 15;
+	attList.push_back(attLowerX);}
+
+	{TeAttribute attLowerY;
+	attLowerY.rep_.name_ = "lower_y";
+	attLowerY.rep_.type_ = TeREAL;
+	attLowerY.rep_.decimals_ = 15;
+	attList.push_back(attLowerY);}
+
+	{TeAttribute attUpperX;
+	attUpperX.rep_.name_ = "upper_x";
+	attUpperX.rep_.type_ = TeREAL;
+	attUpperX.rep_.decimals_ = 15;
+	attList.push_back(attUpperX);}
+
+	{TeAttribute attUpperY;
+	attUpperY.rep_.name_ = "upper_y";
+	attUpperY.rep_.type_ = TeREAL;
+	attUpperY.rep_.decimals_ = 15;
+	attList.push_back(attUpperY);}
+
+	{TeAttribute attCurrentTheme;
+	attCurrentTheme.rep_.name_ = "current_theme";
+	attCurrentTheme.rep_.type_ = TeINT;
+	attList.push_back(attCurrentTheme);}
+
+	if(!createTable("te_view", attList))
+		return false;
+
+	string idxName = "te_idx_view_projid";
+
+	if(!createIndex("te_view", idxName, "projection_id"))
+		return false;
+
+	idxName = "te_idx_view_name";
+
+	if(!createIndex("te_view", idxName, "name"))
+		return false;
+
+	idxName = "te_idx_view_user_name";
+
+	return createIndex("te_view", idxName, "user_name");
+}
+
+bool TeDatabase::createThemeTable ()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attThemeId;
+	attThemeId.rep_.name_ = "theme_id";
+	attThemeId.rep_.type_ = TeUNSIGNEDINT;
+	attThemeId.rep_.isPrimaryKey_ = true;
+	attThemeId.rep_.isAutoNumber_ = true;
+	attThemeId.rep_.null_ = false;
+	attList.push_back(attThemeId);}
+
+	{TeAttribute attLayerId;
+	attLayerId.rep_.name_ = "layer_id";
+	attLayerId.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attLayerId);}
+
+	{TeAttribute attViewId;
+	attViewId.rep_.name_ = "view_id";
+	attViewId.rep_.type_ = TeUNSIGNEDINT;
+	attViewId.rep_.null_ = false;
+	attList.push_back(attViewId);}
+
+	{TeAttribute attName;
+	attName.rep_.name_ = "name";
+	attName.rep_.type_ = TeSTRING;
+	attName.rep_.numChar_ = 255;
+	attName.rep_.null_ = false;
+	attList.push_back(attName);}
+
+	{TeAttribute attParentId;
+	attParentId.rep_.name_ = "parent_id";
+	attParentId.rep_.type_ = TeUNSIGNEDINT;
+	attParentId.rep_.null_ = false;
+	attList.push_back(attParentId);}
+
+	{TeAttribute attPriority;
+	attPriority.rep_.name_ = "priority";
+	attPriority.rep_.type_ = TeUNSIGNEDINT;
+	attPriority.rep_.null_ = false;
+	attList.push_back(attPriority);}
+
+	{TeAttribute attNodeType;
+	attNodeType.rep_.name_ = "node_type";
+	attNodeType.rep_.type_ = TeUNSIGNEDINT;
+	attNodeType.rep_.null_ = false;
+	attList.push_back(attNodeType);}
+
+	{TeAttribute attMinScale;
+	attMinScale.rep_.name_ = "min_scale";
+	attMinScale.rep_.type_ = TeREAL;
+	attMinScale.rep_.decimals_ = 15;
+	attList.push_back(attMinScale);}
+
+	{TeAttribute attMaxScale;
+	attMaxScale.rep_.name_ = "max_scale";
+	attMaxScale.rep_.type_ = TeREAL;
+	attMaxScale.rep_.decimals_ = 15;
+	attList.push_back(attMaxScale);}
+
+	{TeAttribute attGenAttWhere;
+	attGenAttWhere.rep_.name_ = "generate_attribute_where";
+	attGenAttWhere.rep_.type_ = TeSTRING;
+	attGenAttWhere.rep_.numChar_ = 255;
+	attList.push_back(attGenAttWhere);}
+
+	{TeAttribute attGenSpatWhere;
+	attGenSpatWhere.rep_.name_ = "generate_spatial_where";
+	attGenSpatWhere.rep_.type_ = TeSTRING;
+	attGenSpatWhere.rep_.numChar_ = 255;
+	attList.push_back(attGenSpatWhere);}
+
+	{TeAttribute attGenTempWhere;
+	attGenTempWhere.rep_.name_ = "generate_temporal_where";
+	attGenTempWhere.rep_.type_ = TeSTRING;
+	attGenTempWhere.rep_.numChar_ = 255;
+	attList.push_back(attGenTempWhere);}
+
+	{TeAttribute attCollectionT;
+	attCollectionT.rep_.name_ = "collection_table";
+	attCollectionT.rep_.type_ = TeSTRING;
+	attCollectionT.rep_.numChar_ = 255;
+	attList.push_back(attCollectionT);}
+
+	{TeAttribute attVisiRep;
+	attVisiRep.rep_.name_ = "visible_rep";
+	attVisiRep.rep_.type_ = TeINT;
+	attList.push_back(attVisiRep);}
+
+	{TeAttribute attEnableVis;
+	attEnableVis.rep_.name_ = "enable_visibility";
+	attEnableVis.rep_.type_ = TeINT;
+	attList.push_back(attEnableVis);}
+
+	{TeAttribute attLowerX;
+	attLowerX.rep_.name_ = "lower_x";
+	attLowerX.rep_.type_ = TeREAL;
+	attLowerX.rep_.decimals_ = 15;
+	attLowerX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerX);}
+
+	{TeAttribute attLowerY;
+	attLowerY.rep_.name_ = "lower_y";
+	attLowerY.rep_.type_ = TeREAL;
+	attLowerY.rep_.decimals_ = 15;
+	attLowerY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attLowerY);}
+
+	{TeAttribute attUpperX;
+	attUpperX.rep_.name_ = "upper_x";
+	attUpperX.rep_.type_ = TeREAL;
+	attUpperX.rep_.decimals_ = 15;
+	attUpperX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperX);}
+
+	{TeAttribute attUpperY;
+	attUpperY.rep_.name_ = "upper_y";
+	attUpperY.rep_.type_ = TeREAL;
+	attUpperY.rep_.decimals_ = 15;
+	attUpperY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attUpperY);}
+
+	if(!createTable("te_theme", attList))
+		return false;	
+
+	string idxName = "te_idx_theme_view_id";
+
+	if(!createIndex("te_theme", idxName, "view_id"))
+		return false;
+
+	idxName = "te_idx_theme_name";
+
+	if(!createIndex("te_theme", idxName, "name"))
+		return false;
+
+	idxName = "te_idx_theme_layer_id";
+
+	return createIndex("te_theme", idxName, "layer_id");
+}
+
+bool TeDatabase::createGroupingTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attThemeId;
+	attThemeId.rep_.name_ = "theme_id";
+	attThemeId.rep_.type_ = TeUNSIGNEDINT;
+	attThemeId.rep_.isPrimaryKey_ = true;
+	attThemeId.rep_.null_ = false;
+	attList.push_back(attThemeId);}
+
+	{TeAttribute attGNumber;
+	attGNumber.rep_.name_ = "grouping_number";
+	attGNumber.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attGNumber);}
+
+	{TeAttribute attGAttr;
+	attGAttr.rep_.name_ = "grouping_attr";
+	attGAttr.rep_.type_ = TeSTRING;
+	attGAttr.rep_.numChar_ = 255;
+	attList.push_back(attGAttr);}
+
+	{TeAttribute attGAttrType;
+	attGAttrType.rep_.name_ = "grouping_attr_type";
+	attGAttrType.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attGAttrType);}
+
+	{TeAttribute attGMode;
+	attGMode.rep_.name_ = "grouping_mode";
+	attGMode.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attGMode);}
+
+	{TeAttribute attGNormAttr;
+	attGNormAttr.rep_.name_ = "grouping_norm_attr";
+	attGNormAttr.rep_.type_ = TeSTRING;
+	attGNormAttr.rep_.numChar_ = 255;
+	attList.push_back(attGNormAttr);}
+
+	{TeAttribute attGStdDev;
+	attGStdDev.rep_.name_ = "grouping_std_dev";
+	attGStdDev.rep_.type_ = TeREAL;
+	attGStdDev.rep_.decimals_ = 15;
+	attGStdDev.rep_.defaultValue_ = "0.0";
+	attList.push_back(attGStdDev);}
+
+	{TeAttribute attGPrec;
+	attGPrec.rep_.name_ = "grouping_precision";
+	attGPrec.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attGPrec);}
+
+	{TeAttribute attGFunc;
+	attGFunc.rep_.name_ = "grouping_function";
+	attGFunc.rep_.type_ = TeSTRING;
+	attGFunc.rep_.numChar_ = 20;
+	attList.push_back(attGFunc);}
+
+	{TeAttribute attGChronon;
+	attGChronon.rep_.name_ = "grouping_chronon";
+	attGChronon.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attGChronon);}
+
+	return createTable("te_grouping", attList);
+}
+
+bool TeDatabase::createThemeTablesTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attThemeTableId;
+	attThemeTableId.rep_.name_ = "theme_table_id";
+	attThemeTableId.rep_.type_ = TeUNSIGNEDINT;
+	attThemeTableId.rep_.isPrimaryKey_ = true;
+	attThemeTableId.rep_.isAutoNumber_ = true;
+	attThemeTableId.rep_.null_ = false;
+	attList.push_back(attThemeTableId);}
+
+	{TeAttribute attThemeId;
+	attThemeId.rep_.name_ = "theme_id";
+	attThemeId.rep_.type_ = TeUNSIGNEDINT;
+	attThemeId.rep_.null_ = false;
+	attList.push_back(attThemeId);}
+
+	{TeAttribute attTableId;
+	attTableId.rep_.name_ = "table_id";
+	attTableId.rep_.type_ = TeUNSIGNEDINT;
+	attTableId.rep_.null_ = false;
+	attList.push_back(attTableId);}
+
+	{TeAttribute attRelationId;
+	attRelationId.rep_.name_ = "relation_id";
+	attRelationId.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attRelationId);}
+
+	{TeAttribute attTableOrderId;
+	attTableOrderId.rep_.name_ = "table_order";
+	attTableOrderId.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attTableOrderId);}
+
+	if(!createTable("te_theme_table", attList))
+		return false;
+
+	string idxName = "te_idx_theme_table_id";
+
+	if(!createIndex("te_theme_table", idxName, "table_id"))
+		return false;
+
+	idxName = "te_idx_theme_relat_id";
+
+	if(!createIndex("te_theme_table", idxName, "relation_id"))
+		return false;
+
+	idxName = "te_idx_themetable_theme";
+
+	return createIndex("te_theme_table", idxName, "theme_id");
+}
+
+bool TeDatabase::createLegendTable ()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attLegendId;
+	attLegendId.rep_.name_ = "legend_id";
+	attLegendId.rep_.type_ = TeUNSIGNEDINT;
+	attLegendId.rep_.isPrimaryKey_ = true;
+	attLegendId.rep_.isAutoNumber_ = true;
+	attLegendId.rep_.null_ = false;
+	attList.push_back(attLegendId);	}
+
+	{TeAttribute attThemeId;
+	attThemeId.rep_.name_ = "theme_id";
+	attThemeId.rep_.type_ = TeUNSIGNEDINT;
+	attThemeId.rep_.null_ = false;
+	attList.push_back(attThemeId);}
+
+	{TeAttribute attGId;
+	attGId.rep_.name_ = "group_id";
+	attGId.rep_.type_ = TeINT;
+	attList.push_back(attGId);}
+
+	{TeAttribute attNObjs;
+	attNObjs.rep_.name_ = "num_objs";
+	attNObjs.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attNObjs);}
+
+	{TeAttribute attLValue;
+	attLValue.rep_.name_ = "lower_value";
+	attLValue.rep_.type_ = TeSTRING;
+	attLValue.rep_.numChar_ = 255;
+	attList.push_back(attLValue);}
+
+	{TeAttribute attUValue;
+	attUValue.rep_.name_ = "upper_value";
+	attUValue.rep_.type_ = TeSTRING;
+	attUValue.rep_.numChar_ = 255;
+	attList.push_back(attUValue);}
+
+	{TeAttribute attLabel;
+	attLabel.rep_.name_ = "label";
+	attLabel.rep_.type_ = TeSTRING;
+	attLabel.rep_.numChar_ = 255;
+	attList.push_back(attLabel);}
+	
+	if(!createTable("te_legend", attList))
+		return false;
+
+	string idxName = "te_idx_legend_theme";
+
+	return createIndex("te_legend", idxName, "theme_id");
+}
+
+bool TeDatabase::createVisualTable()
+{
+	TeAttributeList attList;
+
+	{TeAttribute attLegendId;
+	attLegendId.rep_.name_ = "legend_id";
+	attLegendId.rep_.type_ = TeUNSIGNEDINT;
+	attLegendId.rep_.isPrimaryKey_ = true;
+	attLegendId.rep_.null_ = false;
+	attList.push_back(attLegendId);}
+
+	{TeAttribute attGeomType;
+	attGeomType.rep_.name_ = "geom_type";
+	attGeomType.rep_.type_ = TeUNSIGNEDINT;
+	attGeomType.rep_.isPrimaryKey_ = true;
+	attGeomType.rep_.null_ = false;
+	attList.push_back(attGeomType);}
+
+	{TeAttribute attSymbId;
+	attSymbId.rep_.name_ = "symb_id";
+	attSymbId.rep_.type_ = TeINT;
+	attList.push_back(attSymbId);}
+
+	{TeAttribute attRed;
+	attRed.rep_.name_ = "red";
+	attRed.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attRed);}
+
+	{TeAttribute attGreen;
+	attGreen.rep_.name_ = "green";
+	attGreen.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attGreen);}
+
+	{TeAttribute attBlue;
+	attBlue.rep_.name_ = "blue";
+	attBlue.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attBlue);}
+
+	{TeAttribute attTransp;
+	attTransp.rep_.name_ = "transparency";
+	attTransp.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attTransp);}
+
+	{TeAttribute attWidth;
+	attWidth.rep_.name_ = "width";
+	attWidth.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attWidth);}
+
+	{TeAttribute attContourSymbId;
+	attContourSymbId.rep_.name_ = "contour_symb_id";
+	attContourSymbId.rep_.type_ = TeINT;
+	attList.push_back(attContourSymbId);}
+
+	{TeAttribute attContourRed;
+	attContourRed.rep_.name_ = "contour_red";
+	attContourRed.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attContourRed);}
+
+	{TeAttribute attContourGreen;
+	attContourGreen.rep_.name_ = "contour_green";
+	attContourGreen.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attContourGreen);}
+
+	{TeAttribute attContourBlue;
+	attContourBlue.rep_.name_ = "contour_blue";
+	attContourBlue.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attContourBlue);}
+
+	{TeAttribute attContourTransp;
+	attContourTransp.rep_.name_ = "contour_transp";
+	attContourTransp.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attContourTransp);}
+
+	{TeAttribute attContourWidth;
+	attContourWidth.rep_.name_ = "contour_width";
+	attContourWidth.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attContourWidth);}
+
+	{TeAttribute attSizeValue;
+	attSizeValue.rep_.name_ = "size_value";
+	attSizeValue.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attSizeValue);}
+
+	{TeAttribute attPtAngle;
+	attPtAngle.rep_.name_ = "pt_angle";
+	attPtAngle.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attPtAngle);}
+
+	{TeAttribute attFamily;
+	attFamily.rep_.name_ = "family";
+	attFamily.rep_.type_ = TeSTRING;
+	attFamily.rep_.numChar_ = 255;
+	attList.push_back(attFamily);}
+
+	{TeAttribute attBold;
+	attBold.rep_.name_ = "bold";
+	attBold.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attBold);}
+
+	{TeAttribute attItalic;
+	attItalic.rep_.name_ = "italic";
+	attItalic.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attItalic);}
+
+	{TeAttribute attAlignVert;
+	attAlignVert.rep_.name_ = "alignment_vert";
+	attAlignVert.rep_.type_ = TeREAL;
+	attAlignVert.rep_.decimals_ = 15;
+	attList.push_back(attAlignVert);}
+
+	{TeAttribute attAlignHoriz;
+	attAlignHoriz.rep_.name_ = "alignment_horiz";
+	attAlignHoriz.rep_.type_ = TeREAL;
+	attAlignHoriz.rep_.decimals_ = 15;
+	attList.push_back(attAlignHoriz);}
+
+	{TeAttribute attTabSize;
+	attTabSize.rep_.name_ = "tab_size";
+	attTabSize.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attTabSize);}
+
+	{TeAttribute attLineSpace;
+	attLineSpace.rep_.name_ = "line_space";
+	attLineSpace.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attLineSpace);}
+
+	{TeAttribute attFixedSize;
+	attFixedSize.rep_.name_ = "fixed_size";
+	attFixedSize.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attFixedSize);}
+
+	return createTable("te_visual", attList);
+}
+
+
+bool TeDatabase::createVisualRasterTable()
+{	
+	TeAttributeList attList;
+
+	{TeAttribute attThemeId;
+	attThemeId.rep_.name_ = "theme_id";
+	attThemeId.rep_.type_ = TeUNSIGNEDINT;
+	attThemeId.rep_.isPrimaryKey_ = true;
+	attThemeId.rep_.null_ = false;
+	attList.push_back(attThemeId);}
+
+	{TeAttribute attBandIn;
+	attBandIn.rep_.name_ = "band_in";
+	attBandIn.rep_.type_ = TeUNSIGNEDINT;
+	attBandIn.rep_.isPrimaryKey_ = true;
+	attBandIn.rep_.null_ = false;
+	attList.push_back(attBandIn);}
+
+	{TeAttribute attBandOut;
+	attBandOut.rep_.name_ = "band_out";
+	attBandOut.rep_.type_ = TeUNSIGNEDINT;
+	attList.push_back(attBandOut);}
+
+	{TeAttribute attTransfType;
+	attTransfType.rep_.name_ = "transf_type";
+	attTransfType.rep_.type_ = TeINT;
+	attList.push_back(attTransfType);}
+
+	{TeAttribute attParam1;
+	attParam1.rep_.name_ = "param1";
+	attParam1.rep_.type_ = TeREAL;
+	attParam1.rep_.decimals_ = 15;
+	attList.push_back(attParam1);}
+
+	{TeAttribute attParam2;
+	attParam2.rep_.name_ = "param2";
+	attParam2.rep_.type_ = TeREAL;
+	attParam2.rep_.decimals_ = 15;
+	attList.push_back(attParam2);}
+
+	{TeAttribute attLutTable;
+	attLutTable.rep_.name_ = "lut_table";
+	attLutTable.rep_.type_ = TeSTRING;
+	attLutTable.rep_.numChar_ = 255;
+	attList.push_back(attLutTable);}
+
+	return createTable("te_visual_raster", attList);
+}
+
+bool TeDatabase::insertVisual (TeLegendEntry *legend)
+{
+	TeGeomRepVisualMap::iterator it = legend->getVisualMap().begin();
+	while ( it != legend->getVisualMap().end())
+	{ 
+		string style("0"), contourStyle("0"), sizeValue("0"), width("0");
+
+		if(it->first == TePOLYGONS || it->first == TeCELLS)
+		{
+			contourStyle = Te2String(it->second->contourStyle());
+			style = Te2String(it->second->style());
+		}
+		else if(it->first == TeLINES)
+		{
+			width = Te2String(it->second->width());
+			style = Te2String(it->second->style());
+		}
+		else if(it->first == TePOINTS)
+		{
+			sizeValue = Te2String(it->second->size());
+			style = Te2String(it->second->style());
+		}
+		else if(it->first == TeTEXT)
+		{
+			sizeValue = Te2String(it->second->size());
+		}
+		
+		string insert = "INSERT INTO te_visual(legend_id, geom_type, ";
+		insert += " symb_id, "; 
+		insert += "red, green, blue, transparency, width, ";
+		insert += " contour_symb_id, "; 
+		insert += "contour_red, contour_green,";
+		insert += "contour_blue, contour_transp, contour_width, size_value,";
+		insert += "pt_angle, family, bold, italic, ";
+		insert += "alignment_vert, alignment_horiz, tab_size, line_space, fixed_size) ";
+		insert += " VALUES (";	
+		insert += Te2String(legend->id()) + ", ";
+		insert += Te2String(it->first)+ ", ";
+		insert += style + ", ";
+		insert += Te2String(it->second->color().red_) + ", ";
+		insert += Te2String(it->second->color().green_) + ", ";
+		insert += Te2String(it->second->color().blue_) + ", ";
+		insert += Te2String(it->second->transparency()) + ", ";
+		insert += width +",";
+		insert += contourStyle + ", ";
+		insert += Te2String(it->second->contourColor().red_) + ", ";
+		insert += Te2String(it->second->contourColor().green_) + ", ";
+		insert += Te2String(it->second->contourColor().blue_) + ", ";
+		insert += Te2String(it->second->contourTransparency()) + ", ";	
+		insert += Te2String(it->second->contourWidth()) + ", ";
+
+		insert += sizeValue +",";
+		insert += Te2String(it->second->ptAngle()) +", ";
+
+		insert += "'" + it->second->family() + "', ";
+		if (it->second->bold())
+			insert += "1, ";
+		else
+			insert += "0, ";
+		if (it->second->italic())
+			insert += "1, ";
+		else
+			insert += "0, ";
+		insert += Te2String(it->second->alignmentVert()) + ",";
+		insert += Te2String(it->second->alignmentHoriz()) + ",";
+		insert += Te2String(it->second->tabSize()) + ",";
+		insert += Te2String(it->second->lineSpace()) +",";
+		if (it->second->fixedSize())
+			insert += "1 ";
+		else
+			insert += "0";			
+		insert += ")";	
+
+		if (!execute(insert))
+			return false;
+		++it;
+	}
+	return true;
+}
+
+bool TeDatabase::createCollectionTable(const string& tableName)
+{
+	if(tableName.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attCObjId;
+	attCObjId.rep_.name_ = "c_object_id";
+	attCObjId.rep_.type_ = TeSTRING;
+	attCObjId.rep_.numChar_ = 255;
+	attCObjId.rep_.isPrimaryKey_ = true;
+	attCObjId.rep_.null_ = false;
+	attList.push_back(attCObjId);}
+
+	{TeAttribute attCLegendId;
+	attCLegendId.rep_.name_ = "c_legend_id";
+	attCLegendId.rep_.type_ = TeINT;
+	attList.push_back(attCLegendId);}
+
+	{TeAttribute attLabelX;
+	attLabelX.rep_.name_ = "label_x";
+	attLabelX.rep_.type_ = TeREAL;
+	attLabelX.rep_.decimals_ = 15;
+	attList.push_back(attLabelX);}
+
+	{TeAttribute attLabelY;
+	attLabelY.rep_.name_ = "label_y";
+	attLabelY.rep_.type_ = TeREAL;
+	attLabelY.rep_.decimals_ = 15;
+	attList.push_back(attLabelY);}
+
+	{TeAttribute attCLegendOwn;
+	attCLegendOwn.rep_.name_ = "c_legend_own";
+	attCLegendOwn.rep_.type_ = TeINT;
+	attList.push_back(attCLegendOwn);}
+
+	{TeAttribute attCObjStatus;
+	attCObjStatus.rep_.name_ = "c_object_status";
+	attCObjStatus.rep_.type_ = TeINT;
+	attList.push_back(attCObjStatus);}
+
+	if(!createTable(tableName, attList))
+		return false;
+
+	string collectionId;
+	unsigned int pos = tableName.rfind("_");
+	if ( (pos != std::string::npos ) && (pos+1<tableName.size()) )
+       collectionId = tableName.substr(pos+1); 
+
+	string idxName = "te_idx_c" + collectionId  + "_clegid";
+
+	if(!createIndex(tableName, idxName, "c_legend_id"))
+		return false;
+
+	idxName = "te_idx_c" + collectionId + "_clegown";
+
+	return createIndex(tableName, idxName, "c_legend_own");
+}
+
+bool TeDatabase::createCellGeometry (const string& table)
+{
+	if(table.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attSpatial;
+	attSpatial.rep_.name_ = "spatial_data";
+	attSpatial.rep_.type_ = TeCELLTYPE;
+	attList.push_back(attSpatial);}
+
+	if(!createTable(table, attList))
+		return false;
+
+	string idxName = "te_idx_"  + table + "obj";
+
+	if(!createIndex(table, idxName, "object_id"))
+		return false;
+
+	idxName = "te_idx_" + table + "_lc";
+
+	return createIndex(table, idxName, "row_number, col_number");
+}
+
+bool TeDatabase::createTextGeometry(const string& table)
+{
+	if(table.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attX;
+	attX.rep_.name_ = "x";
+	attX.rep_.type_ = TeREAL;
+	attX.rep_.decimals_ = 15;
+	attX.rep_.defaultValue_ = "0.0";
+	attList.push_back(attX);}
+
+	{TeAttribute attY;
+	attY.rep_.name_ = "y";
+	attY.rep_.type_ = TeREAL;
+	attY.rep_.decimals_ = 15;
+	attY.rep_.defaultValue_ = "0.0";
+	attList.push_back(attY);}
+
+	{TeAttribute attTextValue;
+	attTextValue.rep_.name_ = "text_value";
+	attTextValue.rep_.type_ = TeSTRING;
+	attTextValue.rep_.numChar_ = 255;
+	attList.push_back(attTextValue);}
+
+	{TeAttribute attAngle;
+	attAngle.rep_.name_ = "angle";
+	attAngle.rep_.type_ = TeREAL;
+	attAngle.rep_.decimals_ = 15;
+	attAngle.rep_.defaultValue_ = "0.0";
+	attList.push_back(attAngle);}
+
+	{TeAttribute attHeight;
+	attHeight.rep_.name_ = "height";
+	attHeight.rep_.type_ = TeREAL;
+	attHeight.rep_.decimals_ = 15;
+	attHeight.rep_.defaultValue_ = "0.0";
+	attList.push_back(attHeight);}
+
+	{TeAttribute attAlignVert;
+	attAlignVert.rep_.name_ = "alignment_vert";
+	attAlignVert.rep_.type_ = TeREAL;
+	attAlignVert.rep_.decimals_ = 15;
+	attList.push_back(attAlignVert);}
+
+	{TeAttribute attAlignHoriz;
+	attAlignHoriz.rep_.name_ = "alignment_horiz";
+	attAlignHoriz.rep_.type_ = TeREAL;
+	attAlignHoriz.rep_.decimals_ = 15;
+	attList.push_back(attAlignHoriz);}
+
+	if(!createTable(table, attList))
+		return false;
+
+	string idxName = "te_idx_"  + table + "_obj";
+
+	if(!createIndex(table, idxName, "object_id"))
+		return false;
+
+	idxName = "te_idx_"  + table + "_pos";
+
+	return createIndex(table, idxName, "x, y");
+}
+
+bool TeDatabase::createNodeGeometry(const string& table)
+{
+	if(table.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attSpatial;
+	attSpatial.rep_.name_ = "spatial_data";
+	attSpatial.rep_.type_ = TeNODETYPE;
+	attList.push_back(attSpatial);}
+
+	if(!createTable(table, attList))
+		return false;
+
+	string idxName = "te_idx_"  + table + "_obj";
+
+	return createIndex(table, idxName, "object_id");
+}
+
+bool TeDatabase::createPointGeometry(const string& table)
+{
+	if(table.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attSpatial;
+	attSpatial.rep_.name_ = "spatial_data";
+	attSpatial.rep_.type_ = TePOINTTYPE;
+	attList.push_back(attSpatial);}
+
+	if(!createTable(table, attList))
+		return false;
+
+	string idxName = "te_idx_"  + table + "_obj";
+
+	return createIndex(table, idxName, "object_id");
+}
+
+bool TeDatabase::createArcGeometry(const string& table)
+{
+	if(table.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attFromNode;
+	attFromNode.rep_.name_ = "from_node";
+	attFromNode.rep_.type_ = TeINT;
+	attFromNode.rep_.null_ = false;
+	attList.push_back(attFromNode);}
+
+	{TeAttribute attToNode;
+	attToNode.rep_.name_ = "to_node";
+	attToNode.rep_.type_ = TeINT;
+	attToNode.rep_.null_ = false;
+	attList.push_back(attToNode);}
+
+	if(!createTable(table, attList))
+		return false;
+
+	string idxName = "te_idx_"  + table + "_obj";
+
+	if(!createIndex(table, idxName, "object_id"))
+		return false;
+
+	idxName = "te_idx_"  + table + "_from";
+
+	if(!createIndex(table, idxName, "from_node"))
+		return false;
+
+	idxName = "te_idx_"  + table + "_to";
+
+	return createIndex(table, idxName, "to_node");
+}
+
+
+bool
+TeDatabase::insertTable	(TeTable &table)
+{
+	string tableName = table.name();
+	int size = table.size();
+	TeAttributeList att = table.attributeList();
+	TeAttributeList::iterator it = att.begin();
+	TeAttributeList::iterator itEnd = att.end();
+	TeTableRow row;
+	
+	int blobIndex=-1;
+	if (!beginTransaction())
+		return false;
+
+	int i;
+	unsigned int j;
+	for ( i = 0; i < size; i++ )	
+	{
+		row = table[i];
+		it = att.begin();
+		string attrs;
+		string values;
+		j = 1;
+		int jj = 0;
+		while ( it != itEnd )
+		{
+			if (row[jj].empty() || (*it).rep_.isAutoNumber_)
+			{
+				++it;
+				j++;
+				jj++;
+				continue;
+			}
+			
+			if (!values.empty())
+			{
+				attrs += ", ";
+				values += ", ";
+			}			
+			attrs += (*it).rep_.name_;			
+			switch ((*it).rep_.type_)
+			{
+			case TeSTRING:
+				values += "'"+ escapeSequence( row[jj] ) +"'";
+				break;
+			case TeREAL:
+				{
+				std::string strValue = row[jj];
+				replace(strValue.begin(), strValue.end(), ',', '.');
+				values += strValue;
+				}
+				break;
+			case TeINT:
+				values += row[jj];
+				break;
+			case TeDATETIME:
+				{
+					const string temp_dt = string(row[jj].c_str());
+					TeTime t(temp_dt, (*it).dateChronon_, (*it).dateTimeFormat_, (*it).dateSeparator_, (*it).timeSeparator_, (*it).indicatorPM_);
+					values += this->getSQLTime(t);
+				}
+				break;
+			case TeCHARACTER:
+				values += "'" + escapeSequence(row[jj]) + "'";
+				break;
+			case TeBLOB:
+				blobIndex = jj;
+			default:
+				values += "'"+ escapeSequence(row[jj]) +"'";
+				break;
+			}
+			++it;
+			j++;
+			jj++;
+		}
+
+		if (values.empty()) 
+			continue;
+
+		string q = "INSERT INTO "+tableName + " ("+ attrs+") " + " VALUES ("+values+") ";
+		if (!execute(q)) 
+			continue;
+
+		//If there were blob type 
+		if(blobIndex>=0)
+		{
+			TeAttribute uniqueAttr;
+			table.attrUnique(uniqueAttr);
+			string uniqueValue;
+			int indexUniquePos = table.attrUniquePosition();
+			if(uniqueAttr.rep_.isAutoNumber_)
+			{
+				//we have to get the last autonumber inserted
+				string sql = " SELECT MAX("+ uniqueAttr.rep_.name_ +") FROM ";
+				sql += tableName;
+				TeDatabasePortal* portal = getPortal();
+				if(!portal)
+				{
+					rollbackTransaction();
+					return false;
+				}
+				if(!portal->query(sql) || !portal->fetchRow())
+				{
+					delete portal;
+					rollbackTransaction();
+					return false;
+				}
+				uniqueValue = portal->getData(0);
+				delete portal;
+			}
+			else
+				//we can use the unique value
+				uniqueValue = row[indexUniquePos];
+			
+			if(!insertBlob(tableName, att[blobIndex].rep_.name_, uniqueAttr.rep_, uniqueValue, 
+				(unsigned char*) row[blobIndex].c_str(), row[blobIndex].size()))
+			{
+				rollbackTransaction();
+				return false;
+			} 
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::alterTable(const string& tableName, TeAttributeRep& rep, const string& oldColName)
+{
+	if(!tableExist(tableName))
+		return false;
+
+	string tab;
+
+	if(oldColName.empty())
+	{
+		tab = " ALTER TABLE " + tableName + " MODIFY ";
+		tab += rep.name_ +"  ";
+	}
+	else
+	{
+		tab = " ALTER TABLE " + tableName + " CHANGE ";
+		tab += oldColName +" "+ rep.name_ +"  ";
+	}
+
+	switch (rep.type_)
+	{
+		case TeSTRING:
+			tab += "VARCHAR(" + Te2String(rep.numChar_) + ") ";
+			break;
+			
+		case TeREAL:
+			tab += "DOUBLE(24, 15)";	
+			break;
+			
+		case TeINT:
+			tab += "INT";
+			break;
+
+		case TeDATETIME:
+			tab += "DATETIME";
+			break;
+
+		case TeCHARACTER:
+			tab += "CHAR";
+			break;
+
+		case TeBLOB:
+			tab += "LONGBLOB";
+			break; 
+		
+		default:
+			tab += "VARCHAR(" + Te2String(rep.numChar_) + ") ";
+			break;
+	}
+
+	tab += " NULL ";
+
+	if(!execute(tab))
+	{
+		if(errorMessage_.empty())
+			errorMessage_ = "Error alter table " + tableName + " !";
+		return false;
+	}
+
+	string tableId;
+	TeDatabasePortal* portal = getPortal();
+	string sql = "SELECT table_id FROM te_layer_table WHERE attr_table = '" + tableName + "'";
+	if(portal->query(sql) && portal->fetchRow())
+		tableId = portal->getData(0);
+
+	delete portal;
+
+	if(tableId.empty() == false)
+	{
+		if(oldColName.empty() == false) // column name changed
+		{
+			 // update relation
+			sql = "UPDATE te_tables_relation SET related_attr = '" + rep.name_ + "'";
+			sql += " WHERE related_table_id = " + tableId;
+			sql += " AND related_attr = '" + oldColName + "'";
+			if(execute(sql) == false)
+				return false;
+
+			sql = "UPDATE te_tables_relation SET external_attr = '" + rep.name_ + "'";
+			sql += " WHERE external_table_name = '" + tableName + "'";
+			sql += " AND external_attr = '" + oldColName + "'";
+			if(execute(sql) == false)
+				return false;
+
+			 // update grouping
+			sql = "UPDATE te_grouping SET grouping_attr = '" + tableName + "." + rep.name_ + "'";
+			sql += " WHERE grouping_attr = '" + tableName + "." + oldColName + "'";
+			if(execute(sql) == false)
+				return false;
+		}
+		else // column type changed
+		{
+			// delete relation
+			sql = "DELETE FROM te_tables_relation WHERE (related_table_id = " + tableId;
+			sql += " AND related_attr = '" + rep.name_ + "')";
+			sql += " OR (external_table_name = '" + tableName + "'";
+			sql += " AND external_attr = '" + rep.name_ + "')";
+			if(execute(sql) == false)
+				return false;
+
+			// delete grouping
+			TeDatabasePortal* portal = getPortal();
+			sql = "SELECT theme_id FROM te_grouping WHERE grouping_attr = '" + tableName + "." + oldColName + "'";
+			if(portal->query(sql) && portal->fetchRow())
+			{
+				string themeId = portal->getData(0);
+
+				sql = "DELETE FROM te_legend WHERE theme_id = " + themeId + " AND group_id >= 0";
+				if(execute(sql) == false)
+				{
+					delete portal;
+					return false;
+				}
+			}
+			delete portal;
+
+			sql = "DELETE FROM te_grouping";
+			sql += " WHERE grouping_attr = '" + tableName + "." + oldColName + "'";
+			if(execute(sql) == false)
+				return false;
+		}
+	}
+
+	alterTableInfoInMemory(tableName);
+	return true;
+}
+
+bool 
+TeDatabase::alterTable(const string& oldTableName, const string& newTablename)
+{
+	string sql = " ALTER TABLE "+ oldTableName +" RENAME "+ newTablename;
+	if(!execute(sql))
+		return false;
+
+	//update te_layer_table
+	sql = " UPDATE te_layer_table ";
+	sql += " SET attr_table = '"+ newTablename +"'";
+	sql += " WHERE attr_table = '"+ oldTableName +"'";
+	execute(sql);
+
+	//update te_tables_relation
+	sql = " UPDATE te_tables_relation ";
+	sql += " SET external_table_name = '"+ newTablename +"'";
+	sql += " WHERE external_table_name = '"+ oldTableName +"'";
+	execute(sql);
+	
+	alterTableInfoInMemory(newTablename, oldTableName);
+	return true;
+}
+
+bool 
+TeDatabase::insertBlob (const string& tableName, const string& columnBlob, TeAttributeRep& columnId, const string& valueId, unsigned char* data, int size)
+{
+	string whereClause = columnId.name_ +" = ";
+	switch (columnId.type_ )
+	{
+		case TeSTRING:
+			whereClause += "'"+ valueId + "'";
+			break;
+		default:
+			whereClause += valueId;
+			break;
+	}
+	return (insertBlob (tableName, columnBlob, whereClause, data, size));
+}
+
+bool 
+TeDatabase::insertBlob (const string& tableName, const string& columnBlob, TeAttributeRep& columnId, const string& valueId, const string& fileName)
+{
+	string whereClause = columnId.name_ +" = ";
+	switch (columnId.type_ )
+	{
+		case TeSTRING:
+			whereClause += "'"+ valueId + "'";
+			break;
+		default:
+			whereClause += valueId;
+			break;
+	}
+	return (insertBlob(tableName, columnBlob, whereClause, fileName));
+}
+
+bool 
+TeDatabase::insertBlob (const string& tableName, const string& columnBlob, const string& whereClause, const string& fileName)
+{
+	unsigned char	*cdata = 0;
+	int		size;
+	FILE	*fp = 0;
+	
+	struct	stat buf;
+	int		result;
+	
+	result = stat(fileName.c_str(), &buf);
+	
+	if( result != 0 )
+		return false;
+	
+	size = buf.st_size;
+
+	cdata = new unsigned char[size];
+	fp = fopen(fileName.c_str(), "rb");
+	fread(cdata, sizeof(unsigned char), size, fp); 
+
+	bool status = insertBlob (tableName, columnBlob, whereClause, cdata, size);
+
+	if(fp)
+		fclose(fp);
+
+	if (cdata)
+		delete []cdata;
+
+	return status;
+}
+
+bool 
+TeDatabase::getAttrTables(TeAttrTableVector& atts, TeAttrTableType attType)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+	{
+		this->errorMessage_ = "N�o foi poss�vel abrir portal para o banco";
+		return false;
+	}
+	
+	// Get layer tables	
+	string get =  " SELECT * FROM te_layer_table"; 
+	if (attType != TeAllAttrTypes)
+		get += " WHERE attr_table_type = " + Te2String(attType);
+	if (!portal->query(get))
+	{	
+		delete portal;
+		return false;
+	}
+
+	while (portal->fetchRow())
+	{
+		TeTable attTable;
+		if(!portal->getAttrTable(attTable))
+		{
+			delete portal;
+			return false;
+		}
+		
+		TeAttributeList attrList;
+		getAttributeList(attTable.name(), attrList);
+		atts.push_back(attTable);
+	}
+	delete portal;
+	return (atts.size() > 0);
+}
+
+bool
+TeDatabase::updateTable	(TeTable &table)
+{
+	TeAttributeList& att = table.attributeList();
+	unsigned int i;
+	string uniqueVal;
+	bool isUniqueValString = false;
+	
+	if (!beginTransaction())
+		return false;
+
+	string uniqueName = table.uniqueName(); // primary key explicitly defined or 
+	if (table.uniqueName().empty())			// check in the attribute list
+	{								
+		for (i=0; i<att.size(); ++i)
+			if (att[i].rep_.isPrimaryKey_)
+			{
+				uniqueName = att[i].rep_.name_;
+				table.setUniqueName(uniqueName);
+				break;
+			}
+	}
+
+	int blobIndex = -1;
+	TeAttributeList::iterator it;
+	TeTableRow row;
+	unsigned int j;
+	for (i = 0; i < table.size(); i++  )
+	{
+		row = table[i];
+		it = att.begin();
+		string q;
+		j = 1;
+		int jj = 0;
+		while ( it != att.end() )
+		{
+			if (uniqueName != (*it).rep_.name_)
+			{
+				if ((*it).rep_.isAutoNumber_)
+				{
+					++it;
+					j++;
+					jj++;
+					continue;
+				}			
+
+				if ((*it).rep_.type_ != TeBLOB)
+				{
+					if (q.empty()==false)
+						q+= ",";
+					q += (*it).rep_.name_ + "=";
+				}
+				
+  				switch ((*it).rep_.type_)
+  				{
+  					case TeSTRING:						
+						q += "'"+escapeSequence(row[jj])+"'";
+  					break;
+  					case TeREAL:
+					{
+						std::string value = row[jj];
+						replace(value.begin(), value.end(), ',', '.');
+						q += value;
+					}
+  					break;
+  					case TeINT:
+						q += row[jj];
+  					break;
+					case TeDATETIME:
+					{
+						const string temp_dt = string(row[jj].c_str());
+						TeTime t(temp_dt, (*it).dateChronon_, (*it).dateTimeFormat_, (*it).dateSeparator_, (*it).timeSeparator_, (*it).indicatorPM_);
+						q += this->getSQLTime(t);
+					}
+  					break;
+					case TeCHARACTER:
+						q += "'" + escapeSequence(row[jj]) + "'";
+  					break;
+					case TeBLOB:
+						blobIndex = jj;
+  					break;
+  					default:
+						q += "'"+escapeSequence(row[jj])+"'";
+  					break;
+  				}
+				
+			}
+			else
+			{
+				uniqueVal = row[jj];
+				isUniqueValString = ((*it).rep_.type_ == TeSTRING);
+			}
+			++it;
+			j++;
+			jj++;
+		}
+		if (q.empty())
+			continue;
+		
+		if (!uniqueName.empty() && !uniqueVal.empty())  
+		{
+			if(isUniqueValString)
+				q += " WHERE " + uniqueName + " = '" + uniqueVal +"'";
+			else
+				q += " WHERE " + uniqueName + " = " + uniqueVal;
+		}
+		string sql = "UPDATE "+ table.name() + " SET " + q;
+		if (!execute(sql))
+		{
+			rollbackTransaction();
+			return false;
+		}
+
+		//verify if there was blob type
+		if(blobIndex>=0)
+		{
+			TeAttribute uniqueAttr;
+			table.attrUnique(uniqueAttr);
+			if(!insertBlob (table.name(), att[blobIndex].rep_.name_, uniqueAttr.rep_, uniqueVal, 
+				(unsigned char*)row[blobIndex].c_str(), row[blobIndex].size()))
+			{
+				rollbackTransaction();
+				return false;
+			}
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+
+bool 
+TeDatabase::loadTable(const string& tableName, TeTable &table)
+{
+	bool isreg = false;
+	table.name(tableName);
+	if (loadTableInfo(table)) // this is not a registered table...
+		isreg = true;
+
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string q ="SELECT * FROM " + tableName;
+	if (!portal->query(q))
+	{	
+		delete portal;
+		return false;
+	}
+	if (!isreg)
+		table.setAttributeList(portal->getAttributeList());
+	while (portal->fetchRow())
+	{
+		TeTableRow row;
+		for (int j = 0; j < portal->numFields(); j++)
+		{
+           TeAttribute& attr = table.attributeList()[j];
+           if (attr.rep_.type_ == TeBLOB)
+           {
+               unsigned char* data = NULL;
+               long size = 0;
+               portal->getBlob (attr.rep_.name_, data, size);
+               string blobValue;
+               if (data != NULL)
+               {                                      
+				   blobValue.assign((char*)data, size);
+				   delete [] data;
+                   data = NULL;
+               }
+               row.push_back(blobValue);
+           }
+           else
+               row.push_back (portal->getData (j)); 
+		}
+		table.add(row);
+	}
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::selectTable (const string& tableName, const string& criteria, TeTable &table)
+{
+	bool isreg = false;
+	table.name(tableName);
+	if (loadTableInfo(table)) // this is not a registered table...
+		isreg = true;
+
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string q ="SELECT * FROM " + tableName;
+	if (!criteria.empty())
+		q += " WHERE " + criteria;
+
+	if (!portal->query(q))
+	{	
+		delete portal;
+		return false;
+	}
+	if (!isreg)
+		table.setAttributeList(portal->getAttributeList());
+	while (portal->fetchRow())
+	{
+		TeTableRow row;
+		for(int i = 0; i < portal->numFields(); i++)
+			row.push_back(portal->getData(i));
+		table.add(row);
+	}
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::updateView (TeView *view)
+{
+	TeProjection* proj = view->projection();
+	if (proj)
+	{
+		if (proj->id() <= 0)
+			this->insertProjection(view->projection());
+		else
+			this->updateProjection(view->projection());
+	}
+	else
+	{
+		errorMessage_ = "N�o � poss�vel atualizar vista sem proje��o!";
+		return false;
+	}
+
+	string sql = "UPDATE te_view SET projection_id=" + Te2String(proj->id());
+	sql+= ", name='" + view->name() + "'";
+	sql+= ", user_name='" + view->user() + "'";
+	sql+= ", visibility= " + Te2String((int)view->isVisible());
+	sql+= ", lower_x = " + Te2String(view->getCurrentBox().lowerLeft().x(),15);
+	sql+= ", lower_y = " + Te2String(view->getCurrentBox().lowerLeft().y(),15);
+	sql+= ", upper_x = " + Te2String(view->getCurrentBox().upperRight().x(),15);
+	sql+= ", upper_y = " + Te2String(view->getCurrentBox().upperRight().y(),15);
+	if(view->getCurrentTheme() > 0)
+		sql+= ", current_theme = " + Te2String(view->getCurrentTheme());
+	else
+		sql+= ", current_theme = null";
+	sql +=" WHERE view_id = " + Te2String(view->id());
+
+	if (!this->execute (sql))
+		return false;
+
+	TeViewTree* tree = view->root();
+	if (tree) 
+		return	updateViewTree(tree);
+	return true;
+
+}
+
+
+bool 
+TeDatabase::loadViewSet (const string& user, const bool& loadAttrList, const string& visualType)
+{
+	//clear view map
+	TeViewMap::iterator it = metaModel_->viewMap().begin();
+	while (it != metaModel_->viewMap().end())
+	{
+		if(it->second)
+			delete it->second;
+		++it;
+	}
+	metaModel_->viewMap().clear();
+
+	//clear theme map
+	TeThemeMap::iterator itTheme = metaModel_->themeMap().begin();
+	while (itTheme != metaModel_->themeMap().end())
+	{
+		if(itTheme->second)
+			delete itTheme->second;
+		++itTheme;
+	}
+
+	//clear invalid theme map
+	itTheme = metaModel_->invalidThemeMap().begin();
+	while (itTheme != metaModel_->invalidThemeMap().end())
+	{
+		if(itTheme->second)
+			delete itTheme->second;
+		++itTheme;
+	}
+	metaModel_->invalidThemeMap().clear();
+	metaModel_->themeMap().clear();
+	metaModel_->legendMap().clear();
+	
+	//load view, projection, themes and grouping
+	string sql = " SELECT ";
+	sql += " te_view.*, "; //0-9  (10 columns)
+	sql += " te_projection.*, "; //10 - 26 (17 columns)
+	sql += " te_theme.*, "; // 27 - 45 (19 columns)
+	sql += " te_grouping.*, "; //46 - 55 (10 columns)
+	sql += " te_legend.*,  "; // 56 - 62    (7 columns)
+	sql += " te_visual.*, "; //  63 - 86 (24 columns)
+	sql += " te_visual_raster.* "; //  87 (7 columns)
+
+	sql += " FROM ((((((te_view INNER JOIN te_projection ";
+	sql += " ON te_view.projection_id = te_projection.projection_id) ";
+	sql += " LEFT JOIN te_theme ON te_view.view_id = te_theme.view_id ) ";
+	sql += " LEFT JOIN te_grouping ON te_theme.theme_id = te_grouping.theme_id) ";
+	sql += " LEFT JOIN te_legend ON te_theme.theme_id = te_legend.theme_id) ";
+	sql += " LEFT JOIN te_visual ON te_visual.legend_id = te_legend.legend_id) ";
+	sql += " LEFT JOIN te_visual_raster ON te_theme.theme_id = te_visual_raster.theme_id) ";
+			
+	sql += " WHERE ";
+	if (!user.empty())
+		sql += " te_view.user_name = '" + user + "'";
+	else
+		sql += " te_view.user_name = '" + this->user() + "'";
+	sql += " ORDER BY te_view.view_id, te_theme.priority, te_theme.theme_id, te_legend.legend_id, ";
+	sql += " te_legend.group_id, te_visual.geom_type, te_visual_raster.band_in  "; 
+
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+	
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+	
+	int lastViewId = -1;
+	TeView *view = 0;
+	bool hasNewRow = portal->fetchRow(); //idicates that this portal was fetched 
+	while(hasNewRow)
+	{
+		//load view and its projection 
+		if(lastViewId!=atoi(portal->getData(0)))
+		{
+			//store the last view
+			if(view)
+			{
+				metaModel_->viewMap()[view->id()] = view;
+				view = 0;
+			}
+			TeProjection* proj = 0;
+			if(!portal->getProjection(&proj, 10)) //load projection
+			{
+				delete portal;
+				return false;
+			}
+			view = new TeView();
+			if(!portal->getView(*view, 0)) //load view
+			{
+				delete portal;
+				delete view;
+				return false;
+			}
+			if (proj != 0)
+				view->projection(proj);
+			lastViewId = view->id();
+		}  
+		
+		//make the rigth object
+		string aux = portal->getData(27);
+		if (aux.empty())
+		{
+			hasNewRow = portal->fetchRow();
+			continue;
+		}
+		TeViewNodeType viewNodeType = (TeViewNodeType)portal->getInt(33);
+		TeViewNode* viewNode = TeViewNodeFactory::make(viewNodeType);
+
+		if(!viewNode)
+		{
+			int currentThemeId = portal->getInt(27);
+
+			while((hasNewRow = portal->fetchRow()) && (portal->getInt(27) == currentThemeId))
+				;
+
+			continue;
+		}
+
+		if(viewNodeType == TeTREE)
+		{
+			viewNode = loadViewTree(view, portal->getInt(27), loadAttrList, visualType); 
+			view->add(viewNode);
+
+			hasNewRow = portal->fetchRow();
+			continue;
+		}
+		else 
+		{
+			if(!portal->getTheme(static_cast<TeAbstractTheme&>(*viewNode), 27))
+			{
+				delete viewNode;
+				delete portal;
+				return false;
+			}
+
+			if(viewNodeType == TeTHEME)
+			{
+				//load layer
+				int id = static_cast<TeTheme*>(viewNode)->layerId();
+				TeLayerMap::iterator it = metaModel_->layerMap().find(id);
+				if (it == metaModel_->layerMap().end())
+					loadLayerSet(loadAttrList);
+				
+				static_cast<TeTheme*>(viewNode)->layer(metaModel_->layerMap()[id]);
+			}
+		}
+		
+		TeAbstractTheme* theme = static_cast<TeAbstractTheme*>(viewNode);
+
+		//load grouping 
+		TeGrouping group;
+		if(portal->getGrouping(group, 46))
+			theme->grouping(group);
+
+		//load all legends of this theme
+		//and its visual
+		bool hasLegsToThisTheme = true;
+		while(hasLegsToThisTheme)
+		{
+			//legend
+			TeLegendEntry legend;
+			if(!portal->getLegend(legend, 56))
+			{
+				delete theme;
+				delete view;
+				delete portal;
+				return false;
+			}
+
+			//visual
+			TeRasterVisual* rasterVisual = new TeRasterVisual();
+			bool hasVisualToThisLeg = true;
+			bool hasRasterVisual = false;
+			while(hasVisualToThisLeg)
+			{
+				TeVisual* visual = TeVisualFactory::make(visualType);
+				TeGeomRep geomRep;
+				if(portal->getVisual(visual, geomRep, 63))
+					legend.setVisual(visual, geomRep);
+									
+				if(portal->getRasterVisual(*rasterVisual, 87))
+					hasRasterVisual=true;
+				
+				hasNewRow = portal->fetchRow();
+				if(!hasNewRow || portal->getInt(58)!= legend.group() || portal->getInt(56)!= legend.id())
+					hasVisualToThisLeg = false;
+			}
+
+			//Set raster visual to this theme
+			if(hasRasterVisual)
+				theme->rasterVisual(rasterVisual);
+			else
+				delete rasterVisual;
+
+			//Set legend to this theme
+			theme->legend(legend); 
+															
+			//fill legend buffer
+			if(legend.group() == -6)	
+				metaModel_->legendMap()[legend.id()] = &theme->queryAndPointingLegend();
+			else if(legend.group() == -5)	
+				metaModel_->legendMap()[legend.id()] = &theme->queryLegend(); 
+			else if (legend.group() == -4)
+				metaModel_->legendMap()[legend.id()] = &theme->pointingLegend(); 
+			else if (legend.group() == -3)
+				metaModel_->legendMap()[legend.id()] = &theme->defaultLegend(); 
+			else if (legend.group() == -2)
+				metaModel_->legendMap()[legend.id()] = &theme->withoutDataConnectionLegend(); 
+			else if (legend.group() == -1)
+				metaModel_->legendMap()[legend.id()] = &theme->outOfCollectionLegend(); 
+			else if (legend.group() == -10) //own legend
+			{
+				TeLegendEntry* legendTemp = new TeLegendEntry(legend);
+				metaModel_->legendMap()[legend.id()] = legendTemp;
+			}				
+			
+			if(!hasNewRow || portal->getInt(27)!= theme->id())
+				hasLegsToThisTheme = false;
+		}
+			
+		for (unsigned int i = 0; i < theme->legend().size(); ++i)
+			metaModel_->legendMap()[theme->legend()[i].id()] = &theme->legend()[i];
+
+		if(viewNode->type()==(int)TeTHEME)
+		{
+			//load theme table
+			if(!loadThemeTable(static_cast<TeTheme*>(theme), loadAttrList))
+			{
+				delete portal;
+				return false;
+			}
+		}
+		
+		//load specific theme parameters
+		if(!theme->loadMetadata(this))
+		{
+			metaModel_->invalidThemeMap()[viewNode->id()] = theme;
+			continue;
+		}
+
+		metaModel_->themeMap()[viewNode->id()] = theme;
+		view->add(viewNode);
+	}
+
+	//store the last view
+	if(view)
+	{
+		metaModel_->viewMap()[view->id()] = view;
+		view = 0;
+	}
+
+	delete portal;
+	return true;
+	
+}
+
+TeViewTree* 
+TeDatabase::loadViewTree(TeView* view, int id, const bool& loadAttrList, const string& visualType)
+{
+	if( view == 0) 
+		return 0;
+	
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return 0;
+
+	string q;
+	TeViewTree *node = 0;
+
+	if (id != 0)
+	{
+		q = "SELECT * FROM te_theme";
+		q += " WHERE view_id = " + Te2String (view->id());
+		q += " AND theme_id = " + Te2String(id);
+
+		if (!portal->query(q) || !portal->fetchRow())
+		{
+			delete portal;
+			return 0;
+		}
+		TeViewNodeType type = (TeViewNodeType)portal->getInt("node_type");
+		if(type != TeTREE)
+		{
+			portal->freeResult();
+			delete portal;
+			return NULL;
+		}
+		node = portal->getViewTree();
+		portal->freeResult();
+	}
+
+	q ="SELECT * FROM te_theme";
+	q += " WHERE view_id = " + Te2String (view->id());
+	q += " AND parent_id = " + Te2String(id);
+	q += " ORDER BY priority ASC";
+
+	if (!portal->query(q))
+	{
+		delete portal;
+		return node;
+	}
+
+	while (portal->fetchRow())
+	{
+		TeViewNodeType childType = (TeViewNodeType)portal->getInt("node_type");
+		TeViewNode *childNode;
+		if (childType == TeTHEME)
+		{
+			childNode = new TeTheme();
+			childNode->id(portal->getInt(0));
+			this->loadTheme((TeTheme*)childNode, loadAttrList, visualType);
+		} 
+		else
+		{
+			childNode = loadViewTree(view, portal->getInt("theme_id"), loadAttrList, visualType);
+		}
+
+		if(id == 0)
+		{
+			view->add(childNode);
+		} 
+		else
+		{
+//			view->addTheme(childNode);
+			node->add(childNode);
+		}
+	}
+	delete portal;
+	return node;
+}
+
+bool 
+TeDatabase::loadView (TeView* view, const bool& loadAttrList, const string& visualType)
+{
+	string rest;
+	if (view->id() > 0)
+		rest = " te_view.view_id=" + Te2String(view->id());
+	else if (!view->name().empty())
+	{
+		rest = " te_view.name='" + view->name() + "'";
+		
+		if(!view->user().empty())
+			rest += " AND te_view.user_name='" + view->user() + "'"; 
+	}
+	else
+		return false;
+	
+	//load view, projection, themes and grouping
+	string sql = " SELECT ";
+	sql += " te_view.*, "; //0-9  (10 columns)
+	sql += " te_projection.*, "; //10 - 26 (17 columns)
+	sql += " te_theme.*, "; // 27 - 45 (19 columns)
+	sql += " te_grouping.*, "; //46 - 55 (10 columns)
+	sql += " te_legend.*,  "; // 56 - 62    (7 columns)
+	sql += " te_visual.*, "; //  63 - 86 (24 columns)
+	sql += " te_visual_raster.* "; //  87 (7 columns)
+
+	sql += " FROM ((((((te_view INNER JOIN te_projection ";
+	sql += " ON te_view.projection_id = te_projection.projection_id) ";
+	sql += " LEFT JOIN te_theme ON te_view.view_id = te_theme.view_id ) ";
+	sql += " LEFT JOIN te_grouping ON te_theme.theme_id = te_grouping.theme_id) ";
+	sql += " LEFT JOIN te_legend ON te_theme.theme_id = te_legend.theme_id) ";
+	sql += " LEFT JOIN te_visual ON te_visual.legend_id = te_legend.legend_id) ";
+	sql += " LEFT JOIN te_visual_raster ON te_theme.theme_id = te_visual_raster.theme_id) ";
+			
+	sql += " WHERE "+ rest;
+	sql += " ORDER BY te_view.view_id, te_theme.priority, te_theme.theme_id, te_legend.legend_id, ";
+	sql += " te_legend.group_id, te_visual.geom_type, te_visual_raster.band_in  "; 
+
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+	
+	if (!portal->query(sql) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	//load projection
+	TeProjection* proj = 0;
+	if(!portal->getProjection(&proj, 10)) 
+	{
+		delete portal;
+		return false;
+	}
+	//load view		
+	if(!portal->getView(*view, 0)) 
+	{
+		delete portal;
+		return false;
+	}
+	if (proj != 0)
+		view->projection(proj);
+	
+	bool hasNewRow = true;
+
+	while(hasNewRow)
+	{
+		string aux = portal->getData(27);
+		if (aux.empty())
+		{
+			hasNewRow = portal->fetchRow();
+			continue;
+		}
+		TeViewNodeType viewNodeType = (TeViewNodeType)portal->getInt(33);
+		//make the rigth object
+		TeViewNode* viewNode = TeViewNodeFactory::make(viewNodeType);
+
+		if(!viewNode)
+		{
+			int currentThemeId = portal->getInt(27);
+
+			while((hasNewRow = portal->fetchRow()) && (portal->getInt(27) == currentThemeId))
+				;
+
+			continue;
+		}
+
+		if(viewNodeType == TeTREE)
+		{
+			viewNode = loadViewTree(view, portal->getInt(27), loadAttrList, visualType); 
+			view->add(viewNode);
+			hasNewRow = portal->fetchRow();
+			continue;
+		}
+		else 
+		{
+			if(!portal->getTheme(static_cast<TeAbstractTheme&>(*viewNode), 27))
+			{
+				delete viewNode;
+				delete portal;
+				return false;
+			}
+
+			if(viewNodeType == TeTHEME)
+			{
+				//load layer
+				int id = static_cast<TeTheme*>(viewNode)->layerId();
+				TeLayerMap::iterator it = metaModel_->layerMap().find(id);
+				if (it == metaModel_->layerMap().end())
+					loadLayerSet(loadAttrList);
+				
+				static_cast<TeTheme*>(viewNode)->layer(metaModel_->layerMap()[id]);
+			}
+		}
+		
+		TeAbstractTheme* abstractTheme = static_cast<TeAbstractTheme*>(viewNode);
+
+		//load grouping 
+		TeGrouping group;
+		if(portal->getGrouping(group, 46))
+			abstractTheme->grouping(group);
+
+		//load all legends of this theme
+		//and its visual
+		bool hasLegsToThisTheme = true;
+		while(hasLegsToThisTheme)
+		{
+			//legend
+			TeLegendEntry legend;
+			if(!portal->getLegend(legend, 56))
+			{
+				delete viewNode;
+				delete portal;
+				return false;
+			}
+
+			//visual
+			TeRasterVisual* rasterVisual = new TeRasterVisual();
+			bool hasVisualToThisLeg = true;
+			bool hasRasterVisual = false;
+			while(hasVisualToThisLeg)
+			{
+				TeVisual* visual = TeVisualFactory::make(visualType);
+				TeGeomRep geomRep;
+				if(portal->getVisual(visual, geomRep, 63))
+					legend.setVisual(visual, geomRep);
+									
+				if(portal->getRasterVisual(*rasterVisual, 87))
+					hasRasterVisual=true;
+				
+				hasNewRow = portal->fetchRow();
+				if(!hasNewRow || portal->getInt(58)!= legend.group() || portal->getInt(56)!= legend.id())
+					hasVisualToThisLeg = false;
+			}
+
+			//Set raster visual to this theme
+			if(hasRasterVisual)
+				abstractTheme->rasterVisual(rasterVisual);
+			else
+				delete rasterVisual;
+
+			//Set legend to this theme
+			abstractTheme->legend(legend); 
+															
+			//fill legend buffer
+			if(legend.group() == -6)	
+				metaModel_->legendMap()[legend.id()] = & abstractTheme->queryAndPointingLegend();
+			else if(legend.group() == -5)	
+				metaModel_->legendMap()[legend.id()] = & abstractTheme->queryLegend(); 
+			else if (legend.group() == -4)
+				metaModel_->legendMap()[legend.id()] = & abstractTheme->pointingLegend(); 
+			else if (legend.group() == -3)
+				metaModel_->legendMap()[legend.id()] = & abstractTheme->defaultLegend(); 
+			else if (legend.group() == -2)
+				metaModel_->legendMap()[legend.id()] = & abstractTheme->withoutDataConnectionLegend(); 
+			else if (legend.group() == -1)
+				metaModel_->legendMap()[legend.id()] = & abstractTheme->outOfCollectionLegend(); 
+			else if (legend.group() == -10) //own legend
+			{
+				TeLegendEntry* legendTemp = new TeLegendEntry(legend);
+				metaModel_->legendMap()[legend.id()] = legendTemp;
+			}	
+			
+			if(!hasNewRow || portal->getInt(27)!= abstractTheme->id())
+				hasLegsToThisTheme = false;
+		}				
+			
+		for (unsigned int i = 0; i < abstractTheme->legend().size(); ++i)
+			metaModel_->legendMap()[abstractTheme->legend()[i].id()] = & abstractTheme->legend()[i];
+		
+		if(viewNode->type()==(int)TeTHEME)
+		{
+			//load theme table
+			if(!loadThemeTable(static_cast<TeTheme*>(abstractTheme), loadAttrList))
+			{
+				delete portal;
+				return false;
+			}
+		}
+		
+		//load specific theme parameters
+		if(!abstractTheme->loadMetadata(this))
+		{
+			metaModel_->invalidThemeMap()[viewNode->id()] = abstractTheme;
+			continue;
+		}
+		
+		metaModel_->themeMap()[viewNode->id()] = abstractTheme;
+		view->add(viewNode);
+	}
+
+	metaModel_->viewMap()[view->id()] = view;
+	delete portal;
+	return true;
+}
+
+
+void
+TeDatabase::clear()
+{
+	metaModel_->clear();
+}
+
+bool 
+TeDatabase::deleteView (int viewId)
+{
+	TeDatabasePortal* portal = this->getPortal();
+
+	// view projection should be deleted manually
+	string sql =  "SELECT projection_id FROM te_view WHERE view_id=" + Te2String(viewId);
+	portal->freeResult();
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return false;
+	}
+	if (!portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	string projId = portal->getData("projection_id");
+	portal->freeResult();
+	
+	// delete themes belonging to this view 
+	sql = "SELECT theme_id FROM te_theme WHERE view_id=" + Te2String(viewId);
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return false;
+	}
+	while (portal->fetchRow())
+	{
+		int id = atoi(portal->getData(0));
+		if(deleteTheme(id) == false)
+		{	
+			delete portal;
+			return false;
+		}
+	}
+
+	//delete the entries in the project relation
+	if (existRelation("te_project_view","fk_projectview_view_id") != TeRICascadeDeletion)
+	{
+		sql = "DELETE FROM te_project_view WHERE view_id =" + Te2String(viewId);
+		if (!this->execute (sql))
+			return false;
+	}
+
+	// delete view
+	sql = "DELETE FROM te_view WHERE view_id = " + Te2String(viewId);
+	if (!this->execute (sql))
+	{
+		delete portal;
+		return false;
+	}
+
+	sql = "DELETE FROM te_projection WHERE  projection_id = " + projId;
+	if (!this->execute (sql))
+	{
+		delete portal;
+		return false;
+	}
+
+	// Delete the view and its themes
+	TeView* view = metaModel_->viewMap()[viewId];
+	metaModel_->viewMap().erase(viewId);
+	delete view;
+	delete portal;
+	return true;
+}
+
+bool
+TeDatabase::updateViewTree (TeViewTree *tree)
+{
+	if(tree ->type() == 1) //tree->id() > 0) //only for TeTREE
+	{
+		string sql;
+		sql = "UPDATE te_theme SET ";
+		sql += "name='" + tree->name()+"'";
+		sql += ", parent_id=" + Te2String (tree->parentId());
+		sql += ", node_type=" + Te2String (tree->type());
+		sql += " ,priority=" + Te2String (tree->priority());
+		sql += " WHERE theme_id = " + Te2String(tree->id());
+
+		if(!this->execute (sql)) return false;
+	}
+
+	for (unsigned int th=0; th<tree->size(); th++)
+	{
+		TeViewNode* node = tree->retrieve(th);
+		if (node->type() == TeTREE)
+		{
+			TeViewTree* tree = (TeViewTree*)node;
+			if(!updateViewTree(tree)) return false;
+		}
+		else
+		{
+			TeTheme *theme = (TeTheme*)node;
+			if(!updateTheme(theme)) return false;
+		}
+	}
+	return true;
+}
+
+bool 
+TeDatabase::viewExist(string viewName)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	viewName = TeConvertToUpperCase(viewName);
+
+	string sql = "SELECT name FROM te_view";
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+	while (portal->fetchRow())
+	{
+		string name = portal->getData(0);
+		name = TeConvertToUpperCase(name);
+		if (viewName == name)
+		{
+			delete portal;
+			return true;
+		}
+	}
+	delete portal;
+	return false;
+}
+
+
+bool
+TeDatabase::updateTheme (TeAbstractTheme *theme)
+{
+	string sql;
+
+	if (theme->id() <= 0 )  // theme doesn�t exist in the database yet
+	{
+		return this->insertTheme(theme);
+	}
+	
+	// update theme metadata
+	sql = "UPDATE te_theme SET ";
+	
+	if(theme->type()==TeTHEME)
+	{
+		sql += " layer_id=" + Te2String (static_cast<TeTheme*>(theme)->layerId());
+		sql += ", ";
+	}
+	
+	sql += "  view_id=" + Te2String (theme->view());
+	sql += ", name='" + escapeSequence(theme->name())+"'";
+	sql += ", parent_id=" + Te2String (theme->parentId());
+	sql += ", priority=" + Te2String (theme->priority());
+	sql += ", node_type=" + Te2String (theme->type());
+	sql += ", min_scale=" + Te2String (theme->minScale(),15);
+	sql += ", max_scale=" + Te2String (theme->maxScale(),15);
+	sql += ", generate_attribute_where='" + escapeSequence(theme->attributeRest())+"'";
+	sql += ", generate_spatial_where='" + escapeSequence(theme->spatialRest())+"'";
+	sql += ", generate_temporal_where='" + escapeSequence(theme->temporalRest())+"'";
+
+	if(theme->type()==TeTHEME || theme->type()==TeEXTERNALTHEME )
+		sql += ", collection_table='" + static_cast<TeTheme*>(theme)->collectionTable() + "'";
+
+	sql += ", visible_rep= " + Te2String(theme->visibleRep ());
+	sql += ", enable_visibility= " + Te2String(theme->visibility()); 
+	sql += ", lower_x = " + Te2String(theme->box().x1(), 15); 
+	sql += ", lower_y = " + Te2String(theme->box().y1(), 15); 
+	sql += ", upper_x = " + Te2String(theme->box().x2(), 15); 
+	sql += ", upper_y = " + Te2String(theme->box().y2(), 15); 
+	sql += " WHERE theme_id=" + Te2String (theme->id(), 15);
+
+	if (!this->execute (sql))
+		return false;
+         
+	//delete grouping 
+	sql = "DELETE FROM te_grouping WHERE theme_id= "+ Te2String(theme->id());
+	this->execute (sql);
+		
+	if(theme->grouping().groupMode_ != TeNoGrouping)
+	{
+		if(!insertGrouping(theme->id(), theme->grouping()))
+			return false;
+	}
+	
+	// update each of its legends
+	bool status = true;
+	
+	if(theme->legend().size() == 0)
+	{
+		if(!deleteLegend(theme->id()))
+			return false;
+	}
+	else
+	{
+		status = updateLegend(theme->legend());
+		if (!status)
+			return status;
+	}
+
+	status = updateLegend(&(theme->withoutDataConnectionLegend()));
+	if (!status)
+		return status;
+
+	status = updateLegend(&(theme->outOfCollectionLegend()));
+	if (!status)
+		return status;
+
+	status = updateLegend(&(theme->defaultLegend()));
+	if (!status)
+		return status;
+
+	status = updateLegend(&(theme->pointingLegend()));
+	if (!status)
+		return status;
+
+	status = updateLegend(&(theme->queryLegend()));
+	if (!status)
+		return status;
+
+	status = updateLegend(&(theme->queryAndPointingLegend()));
+	if (!status)
+		return status;
+	
+	//insert metadata theme
+	if(!theme->saveMetadata(this))
+		return false;
+
+	// theme tables
+	if(theme->type()==TeTHEME && !updateThemeTable(static_cast<TeTheme*>(theme)))
+		return false;
+
+	return true;
+}
+
+bool
+TeDatabase::loadTheme (TeAbstractTheme* theme, const bool& loadAttrList, const string& visualType)
+{
+	if (theme == 0)
+		return false;
+
+	string rest;
+	if (theme->id() > 0)
+		rest = " te_theme.theme_id = "+  Te2String(theme->id());
+	else if (!theme->name().empty())
+		rest = " te_theme.name = '"+  theme->name() + "'";
+	else
+	{
+		this->errorMessage_ = "Theme procurado n�o possui nem id nem nome";
+		return false;
+	}
+	rest += " AND te_view.user_name = \'" + this->user() +"\'";
+	
+	//load view, projection, themes and grouping
+	string sql = " SELECT ";
+	sql += " te_theme.*, "; // 0 - 18 (19 columns)   
+	sql += " te_grouping.*, "; //19 - 28 (10 columns)
+	sql += " te_legend.*,  "; // 29 - 35    (7 columns)
+	sql += " te_visual.*, "; //  36 - 59 (24 columns)
+	sql += " te_visual_raster.* "; //  60 (7 columns)
+	sql += " FROM (((((te_view INNER JOIN te_theme ON te_view.view_id = te_theme.view_id) ";
+	sql += " LEFT JOIN te_grouping ON te_theme.theme_id = te_grouping.theme_id ) ";
+	sql += " LEFT JOIN te_legend ON te_theme.theme_id = te_legend.theme_id ) ";
+	sql += " LEFT JOIN te_visual ON te_legend.legend_id = te_visual.legend_id ) ";
+	sql += " LEFT JOIN te_visual_raster ON te_theme.theme_id = te_visual_raster.theme_id) ";
+	sql += " WHERE "+ rest;
+	sql += " ORDER BY te_theme.theme_id, te_legend.legend_id, te_legend.group_id, te_visual.geom_type, te_visual_raster.band_in  "; 
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	
+	TeViewNodeType viewNodeType = (TeViewNodeType)portal->getInt(6);
+	if(viewNodeType == TeTREE)
+	{		
+		TeViewNodeParams params;
+		portal->getViewNodeParams(params, 0);
+		theme->viewNodeParams(params);
+		delete portal;
+		return true;
+	}
+			
+	if(!portal->getTheme(*theme, 0))
+	{
+		delete portal;
+		return false;
+	}
+	
+	if(viewNodeType==(int)TeTHEME)
+	{
+		//load layer
+		int id = static_cast<TeTheme*>(theme)->layerId();
+		TeLayerMap::iterator it = metaModel_->layerMap().find(id);
+		if (it == metaModel_->layerMap().end())
+			loadLayerSet(loadAttrList);
+		
+		static_cast<TeTheme*>(theme)->layer(metaModel_->layerMap()[id]);
+	}
+		
+	//load grouping 
+	TeGrouping group;
+	if(portal->getGrouping(group, 19))
+		theme->grouping(group);
+
+	//load all legends of this theme
+	//and its visual
+	bool hasLegsToThisTheme = true;
+	bool hasNewRow = true;
+	while(hasLegsToThisTheme)
+	{
+		//legend
+		TeLegendEntry legend;
+		if(!portal->getLegend(legend, 29))
+		{
+			delete portal;
+			return false;
+		}
+
+		//visual
+		TeRasterVisual* rasterVisual = new TeRasterVisual();
+		bool hasVisualToThisLeg = true;
+		bool hasRasterVisual = false;
+		while(hasVisualToThisLeg)
+		{
+			TeVisual* visual = TeVisualFactory::make(visualType);
+			TeGeomRep geomRep;
+			if(portal->getVisual(visual, geomRep, 36))
+				legend.setVisual(visual, geomRep);
+								
+			if(portal->getRasterVisual(*rasterVisual, 60))
+				hasRasterVisual=true;
+			
+			hasNewRow = portal->fetchRow();
+			if(!hasNewRow || portal->getInt(31)!= legend.group() || portal->getInt(29)!= legend.id() )  //if legend_id and group_id
+				hasVisualToThisLeg = false;
+		}
+
+		//Set raster visual to this theme
+		if(hasRasterVisual)
+			theme->rasterVisual(rasterVisual);
+		else
+			delete rasterVisual;
+
+		//Set legend to this theme
+		theme->legend(legend); 
+														
+		//fill legend buffer
+		if(legend.group() == -6)	
+			metaModel_->legendMap()[legend.id()] = &theme->queryAndPointingLegend();
+		else if(legend.group() == -5)	
+			metaModel_->legendMap()[legend.id()] = &theme->queryLegend(); 
+		else if (legend.group() == -4)
+			metaModel_->legendMap()[legend.id()] = &theme->pointingLegend(); 
+		else if (legend.group() == -3)
+			metaModel_->legendMap()[legend.id()] = &theme->defaultLegend(); 
+		else if (legend.group() == -2)
+			metaModel_->legendMap()[legend.id()] = &theme->withoutDataConnectionLegend(); 
+		else if (legend.group() == -1)
+			metaModel_->legendMap()[legend.id()] = &theme->outOfCollectionLegend(); 
+		else if (legend.group() == -10) //own legend
+		{
+			TeLegendEntry* legendTemp = new TeLegendEntry(legend);
+			metaModel_->legendMap()[legend.id()] = legendTemp;
+		}	
+		
+		if(!hasNewRow || portal->getInt(0)!= theme->id())
+			hasLegsToThisTheme = false;
+	}
+
+	delete portal;
+			
+	for (unsigned int i = 0; i < theme->legend().size(); ++i)
+		metaModel_->legendMap()[theme->legend()[i].id()] = &theme->legend()[i];
+
+	//load theme table
+	if(theme->type()==(int)TeTHEME)
+	{
+		if(!loadThemeTable(static_cast<TeTheme*>(theme), loadAttrList))
+			return false;
+	}
+
+	//load specific theme parameters
+	if(!theme->loadMetadata(this))
+	{
+		metaModel_->invalidThemeMap()[theme->id()] = theme;
+		delete portal;
+		return false;
+	}
+			
+	metaModel_->themeMap()[theme->id()] = theme;
+	return true;
+}
+
+
+bool
+TeDatabase::loadThemeTable (TeTheme* theme, const bool& loadAttrList)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+	{
+		this->errorMessage_ = "N�o foi poss�vel abrir portal para o banco";
+		return false;
+	}
+	
+	//theme tables
+	string sel = "SELECT te_theme_table.*, ";  //0 - 4 (5 columnns)
+	sel += " te_tables_relation.*, ";          //5 - 9  (5 columns)
+	sel += " te_layer_table.* ";			   //10	
+	sel += " FROM (te_theme_table LEFT JOIN te_tables_relation";
+	sel += " ON te_theme_table.relation_id = te_tables_relation.relation_id)";
+	sel += " LEFT JOIN te_layer_table ON te_theme_table.table_id = te_layer_table.table_id";
+	sel += " WHERE  te_theme_table.theme_id = " + Te2String(theme->id());
+	sel += " ORDER BY table_order";
+	
+	if (!portal->query (sel))
+	{	
+		delete portal;
+		return false;
+	}
+
+	while(portal->fetchRow ())
+	{
+		string tableName = portal->getData(12);
+		if(tableName.empty())
+			continue;
+
+		TeTable table(tableName);
+
+		TeLayerMap::iterator itLayer = metaModel_->layerMap().find(theme->layerId());
+		if(itLayer!=metaModel_->layerMap().end() && (!itLayer->second->getAttrTablesByName(tableName, table)))
+		{
+			TeAttributeList attrList;
+			if(loadAttrList)
+				getAttributeList(tableName, attrList);
+			table.setAttributeList(attrList);
+			if(!portal->getAttrTable(table, 10))
+			{
+				delete portal;
+				return false;
+			}
+		}
+
+		table.setId(portal->getInt(2)); //"te_theme_table.table_id"
+		table.setOrder(portal->getInt(4)); //"table_order"
+		TeAttrTableType tableType = table.tableType(); //portal->getInt("attr_table_type");
+		if (tableType == TeAttrExternal)
+		{
+			int relatedTableId = portal->getInt(6); //"related_table_id"
+			table.relatedTableName(getTableName(relatedTableId));
+			int relationId = portal->getInt(3); //"te_theme_table.relation_id"
+			metaModel_->relationMSet().insert(relationId);
+
+			string relatedAttr = portal->getData(7); //"related_attr"
+			table.setTableType(TeAttrExternal, relatedTableId, relatedAttr);
+
+			table.setLinkName(portal->getData(9)); //"external_attr"
+		}
+		else
+			table.setTableType((TeAttrTableType)tableType);
+
+		theme->addThemeTable(table);
+	}
+
+	delete portal;
+	return true;
+}
+
+
+bool
+TeDatabase::insertThemeTable(TeTheme *theme, TeTable& inputTable)
+{
+	int themeId = theme->id();
+	int	tableOrder = 0;
+	int	relationId;
+	bool status;
+	string qString;
+
+	// Get the order of the last theme table
+	qString = "SELECT MAX(table_order) FROM te_theme_table";
+	qString += " WHERE theme_id = " + Te2String(themeId);
+
+	TeDatabasePortal* portal = getPortal();
+	if (portal->query(qString) == false || portal->fetchRow() == false)
+		return false;
+
+	string data = portal->getData(0);
+	if (data.empty())
+		tableOrder = 0;
+	else
+	{
+		tableOrder = atoi(portal->getData(0));
+		++tableOrder;
+	}
+	inputTable.setOrder(tableOrder);
+	delete portal;
+
+	if (inputTable.tableType() == TeAttrExternal)
+	{
+		status = insertRelationInfo(inputTable.relatedTableId(),inputTable.relatedAttribute(),
+									inputTable.name(),inputTable.linkName(),relationId);
+		if (status == false)
+			return false;
+		metaModel_->relationMSet().insert(relationId);
+
+		status = insertThemeTable(themeId, inputTable.id(), relationId, tableOrder);
+	}
+	else
+	{
+		// Insert the table in the te_theme_table
+		status = insertThemeTable(themeId, inputTable.id(), 0, tableOrder);
+	}
+	return status;
+}
+
+bool
+TeDatabase::removeThemeTable(TeTheme *theme, int tableOrder)
+{
+	if (tableOrder < 0)
+		return false;
+
+	int relationId = -1;
+	string qString;
+
+	TeAttrTableVector attrTableVector; 
+	theme->getAttTables(attrTableVector);
+
+	// If the table is external, find the relation id
+	qString = "SELECT relation_id FROM te_theme_table";
+	qString += " WHERE theme_id = " + Te2String(theme->id());
+	qString += " AND relation_id IS NOT NULL";
+	qString += " AND table_order = " + Te2String(tableOrder);
+
+	TeDatabasePortal* portal = getPortal();
+	if (portal->query(qString) && portal->fetchRow())
+		relationId = portal->getInt("relation_id");
+	else
+	{
+		delete portal;
+		return false;
+	}
+	delete portal;
+
+	// Remove the table from the te_theme_table
+	qString = "DELETE FROM te_theme_table WHERE theme_id = " + Te2String(theme->id());
+	qString += " AND table_order = " + Te2String(tableOrder);
+	if (execute(qString) == false)
+		return false;
+
+	// Remove the relation from the te_tables_relation
+	// table if only this theme is using it
+	if (relationId > 0)
+	{
+		if (metaModel_->relationMSet().count(relationId) == 1)
+		{
+			qString = "DELETE FROM te_tables_relation WHERE relation_id = " + Te2String(relationId);
+			if (execute(qString) == false)
+				return false;
+			metaModel_->relationMSet().erase(relationId);
+		}
+		else
+			metaModel_->relationMSet().erase(metaModel_->relationMSet().find(relationId));
+	}
+	return true;
+}
+
+
+bool 
+TeDatabase::updateThemeTable(TeTheme *theme)
+{
+	//Initially remove from te_theme_table all the records of this theme
+	string q = "SELECT * FROM te_theme_table WHERE theme_id = " + Te2String(theme->id());
+	TeDatabasePortal *portal = getPortal();
+
+	if (portal->query(q) == false)
+	{
+		delete portal;
+		return false;
+	}
+
+	while (portal->fetchRow())
+	{
+		int relationId;
+		int themeTableId = portal->getInt("theme_table_id");
+
+		string data = portal->getData("relation_id");
+		if (data.empty())
+			relationId = -1;
+		else
+			relationId = atoi(data.c_str());
+
+		// Remove the relation from the te_tables_relation
+		// table if only this theme is using it
+		bool b = false;
+		if (relationId > 0)
+		{
+			if (metaModel_->relationMSet().count(relationId) == 1)
+				b = true;
+			else
+				metaModel_->relationMSet().erase(metaModel_->relationMSet().find(relationId));
+		}
+
+		// Remove the table from the te_theme_table
+		q = "DELETE FROM te_theme_table WHERE theme_id = " + Te2String(theme->id());
+		q += " AND theme_table_id = " + Te2String(themeTableId);
+		if (execute(q) == false)
+		{
+			delete portal;
+			return false;
+		}
+		if(b)
+		{
+			q = "DELETE FROM te_tables_relation WHERE relation_id = " + Te2String(relationId);
+			if (execute(q) == false)
+			{
+				delete portal;
+				return false;
+			}
+			metaModel_->relationMSet().erase(relationId);
+		}
+	}
+	delete portal;
+
+	// Update te_theme_table and te_tables_relation(if there are any external tables)
+	// with the information provided from the new vector of theme tables
+	TeAttrTableVector tablesVector; 
+	theme->getAttTables(tablesVector);
+	for (unsigned i = 0; i < tablesVector.size(); ++i)
+		insertThemeTable(theme, tablesVector[i]);
+
+	return true;
+}
+
+
+bool 
+TeDatabase::insertGrouping (int themeId, const TeGrouping& grouping)
+{
+	if((themeId < 1) || (grouping.groupMode_ == TeNoGrouping) )
+		return false;
+
+	string ins = " INSERT INTO te_grouping (theme_id, grouping_number, ";
+	ins += " grouping_attr, grouping_attr_type, grouping_mode, "; 
+	ins += " grouping_norm_attr, grouping_std_dev, grouping_precision, "; 
+	ins += " grouping_function, grouping_chronon)"; 
+	ins += " VALUES ( ";
+	ins += Te2String(themeId);
+	ins += ", "+ Te2String(grouping.groupNumSlices_);
+
+	string attname = grouping.groupAttribute_.name_;
+	if(attname.empty() || (attname=="NONE") )
+		attname = "";
+	
+	string norname = grouping.groupNormAttribute_;
+	if(norname.empty() || (norname=="NONE"))
+		norname = "";
+
+	map<int, map<string, string> >::iterator it = metaModel_->mapThemeAlias().find(themeId);
+	if(it != metaModel_->mapThemeAlias().end())
+	{
+		map<string, string>::iterator tit = it->second.find(attname);
+		if(tit != it->second.end())
+		{
+			string alias = tit->second;
+			attname += "(" + alias + ")";
+		}
+		if(norname.empty() == false)
+		{
+			map<string, string>::iterator tit = it->second.find(norname);
+			if(tit != it->second.end())
+			{
+				string nalias = tit->second;
+				norname += "(" + nalias + ")";
+			}
+		}
+	}
+
+	ins += ", '"+ attname +"'";
+	ins += ", "+ Te2String(grouping.groupAttribute_.type_);
+	ins += ", "+ Te2String(grouping.groupMode_);
+	ins += ", '"+ norname +"'";
+	ins += ", "+ Te2String(grouping.groupStdDev_); 
+	ins += ", "+ Te2String(grouping.groupPrecision_);
+	ins += ", '"+ grouping.groupFunction_ +"'";
+	ins += ", "+ Te2String(grouping.groupChronon_);
+	ins += ")";
+
+	return (execute(ins));
+}
+
+bool 
+TeDatabase::updateGrouping (int themeId, const TeGrouping& grouping)
+{
+	if((themeId < 1) || (grouping.groupMode_ == TeNoGrouping))
+		return false;
+
+	string up = " UPDATE te_grouping SET ";
+	up += "  grouping_number = "+ Te2String(grouping.groupNumSlices_);
+
+	string attname = grouping.groupAttribute_.name_;
+	if(attname.empty() || (attname=="NONE"))
+		attname = "";
+
+	string norname = grouping.groupNormAttribute_;
+	if(norname.empty()|| (norname=="NONE"))
+		norname = "";
+
+	map<int, map<string, string> >::iterator it = metaModel_->mapThemeAlias().find(themeId);
+	if(it != metaModel_->mapThemeAlias().end())
+	{
+		map<string, string>::iterator tit = it->second.find(attname);
+		if(tit != it->second.end())
+		{
+			string alias = tit->second;
+			attname += "(" + alias + ")";
+		}
+		if(norname.empty() == false)
+		{
+			map<string, string>::iterator tit = it->second.find(norname);
+			if(tit != it->second.end())
+			{
+				string nalias = tit->second;
+				norname += "(" + nalias + ")";
+			}
+		}
+	}
+
+	up += ", grouping_attr = '"+ attname +"'";
+	up += ", grouping_attr_type = "+ Te2String(grouping.groupAttribute_.type_);
+	up += ", grouping_mode = "+ Te2String(grouping.groupMode_);
+	up += ", grouping_norm_attr = '"+ norname +"'";
+	up += ", grouping_std_dev = "+ Te2String(grouping.groupStdDev_); 
+	up += ", grouping_precision = "+ Te2String(grouping.groupPrecision_);
+	up += ", grouping_function = '"+ grouping.groupFunction_ +"'";
+	up += ", grouping_chronon = "+ Te2String(grouping.groupChronon_);
+	up += " WHERE theme_id = "+ Te2String(themeId);
+
+	return (execute(up));
+}
+
+bool 
+TeDatabase::generateLabelPositions(TeTheme *theme, const std::string& objectId)
+{
+	string	piebar, geomTable, upd;
+	string	collTable = theme->collectionTable();
+	
+	if((collTable.empty()) || (!tableExist(collTable)))
+		return false;
+
+	if (theme->layer()->hasGeometry(TeCELLS) )
+	{
+		geomTable = theme->layer()->tableName(TeCELLS);
+
+		piebar = "SELECT label_x, label_y, lower_x, lower_y, upper_x, upper_y";
+		piebar += " FROM " + collTable + " LEFT JOIN " + geomTable;
+		piebar += " ON " + collTable + ".c_object_id = " + geomTable + ".object_id";
+		if (!objectId.empty())
+			upd += " WHERE " +  collTable + ".c_object_id = '" + objectId + "'";
+
+		upd = " UPDATE (" + piebar + ") SET";
+		upd += " label_x = lower_x + (upper_x-lower_x)/2,";
+		upd += " label_y = lower_y + (upper_y-lower_y)/2";
+		
+
+		if(!execute(upd))
+			return false;
+	}
+
+	if( theme->layer()->hasGeometry(TePOLYGONS))
+	{
+		geomTable = theme->layer()->tableName(TePOLYGONS);
+
+		piebar = "SELECT label_x, label_y, lower_x, lower_y, upper_x, upper_y";
+		piebar += " FROM " + collTable + " LEFT JOIN " + geomTable;
+		piebar += " ON " + collTable + ".c_object_id = " + geomTable + ".object_id";
+		piebar += " WHERE label_x is null OR label_y is null";
+		if (!objectId.empty())
+			upd += " AND " +  collTable + ".c_object_id = '" + objectId + "'";
+		piebar += " ORDER BY c_object_id ASC, ext_max ASC";
+		
+		upd = " UPDATE (" + piebar + ") SET";
+		upd += " label_x = lower_x + (upper_x-lower_x)/2,";
+		upd += " label_y = lower_y + (upper_y-lower_y)/2";
+
+		if(!execute(upd))
+			return false;
+	}
+	
+	if (theme->layer()->hasGeometry(TePOINTS))
+	{
+		geomTable = theme->layer()->tableName(TePOINTS);
+
+		piebar = "SELECT label_x, label_y, x, y";
+		piebar += " FROM " + collTable + " LEFT JOIN " + geomTable;
+		piebar += " ON " + collTable + ".c_object_id = " + geomTable + ".object_id";
+		piebar += " WHERE label_x is null OR label_y is null";
+		if (!objectId.empty())
+			upd += " AND " +  collTable + ".c_object_id = '" + objectId + "'";
+
+		upd = " UPDATE (" + piebar + ") SET";
+		upd += " label_x = x,";
+		upd += " label_y = y";
+
+		if(!execute(upd))
+			return false;
+	}
+	
+	if(theme->layer()->hasGeometry(TeLINES))
+	{
+		geomTable = theme->layer()->tableName(TeLINES);
+
+		piebar = "SELECT label_x, label_y, lower_x, lower_y, upper_x, upper_y";
+		piebar += " FROM " + collTable + " LEFT JOIN " + geomTable;
+		piebar += " ON " + collTable + ".c_object_id = " + geomTable + ".object_id";
+		piebar += " WHERE label_x is null OR label_y is null";
+		if (!objectId.empty())
+			upd += " AND " +  collTable + ".c_object_id = '" + objectId + "'";
+		piebar += " ORDER BY c_object_id ASC, ext_max ASC";
+		
+		upd = " UPDATE (" + piebar + ") SET";
+		upd += " label_x = lower_x + (upper_x-lower_x)/2,";
+		upd += " label_y = lower_y + (upper_y-lower_y)/2";
+
+		if(!execute(upd))
+			return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::themeExist(string themeName)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	themeName = TeConvertToUpperCase(themeName);
+
+	string sql = "SELECT name FROM te_theme";
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+	while (portal->fetchRow())
+	{
+		string name = portal->getData(0);
+		name = TeConvertToUpperCase(name);
+		if (themeName == name)
+		{
+			delete portal;
+			return true;
+		}
+	}
+	delete portal;
+	return false;
+}
+
+string TeDatabase::getNewThemeName(const string& n)
+{
+	bool changed;
+	string invalidChar;
+	string name = TeCheckName(n, changed, invalidChar);
+	string newName = name;
+
+	string q = "SELECT name FROM te_theme WHERE name = '" + newName + "'";
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(portal && portal->query(q) && portal->fetchRow())
+	{
+		// there is already a theme with this theme 
+		q = "SELECT name FROM te_theme WHERE name LIKE '" + name + "_%' ORDER BY name DESC";
+		portal->freeResult();
+		if(portal && portal->query(q))
+		{
+			newName.clear();
+			while(portal->fetchRow())
+			{
+				string s = portal->getData(0);
+				size_t i, f = s.rfind("_");
+				f++;
+				newName = s.substr(0, f);
+				string ss = s.substr(f);
+				for(i=0; i < ss.size(); ++i)
+				{
+					if(ss[i] < 0x30 || ss[i] > 0x39)
+						break;
+				}
+				if(i < ss.size())
+					continue;
+
+				int n = atoi(ss.c_str()) + 1;
+				s = Te2String(n);
+				newName += s;
+				break;
+			}
+			if(newName.empty())
+				newName = name + "_1";
+		}
+	}
+	delete portal;
+	return newName;
+}
+
+string TeDatabase::getNewTableName(const string& n)
+{
+	bool changed;
+	string invalidChar;
+	string name = TeCheckName(n, changed, invalidChar);
+	string newName = name;
+	int	i=1;
+	while (this->tableExist(newName))
+	{
+		newName = name + Te2String(i);
+		++i;
+	}
+	return newName;
+}
+
+string TeDatabase::getConcatFieldsExpression(const vector<string>& fNamesVec)
+{
+	string concatExp;
+	for (unsigned int i = 0; i < fNamesVec.size(); ++i)
+	{
+		if (i != 0)
+			concatExp += " & ";
+		concatExp += fNamesVec[i];
+	}
+	return concatExp;
+}
+
+
+bool
+TeDatabase::deleteTheme(int themeId)
+{
+	TeAbstractTheme* tema;
+	bool themeWasFound = false;
+	TeThemeMap::iterator it;
+
+	it = invalidThemeMap().find(themeId);
+	if (it != invalidThemeMap().end())
+	{
+		themeWasFound = true;
+		tema = it->second;
+		invalidThemeMap().erase(themeId);
+	}
+
+	if (themeWasFound == false)
+	{
+		it = themeMap().find(themeId);
+		if(it != themeMap().end())
+		{
+			themeWasFound = true;
+			tema = it->second;
+			themeMap().erase(themeId);
+		}
+	}
+
+	if (themeWasFound == false)
+		return false;
+	
+	if(!tema->eraseMetadata(this))
+		return false;
+	
+	string sql;
+	// delete the collection table associated to this theme
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	sql = "SELECT collection_table FROM te_theme WHERE theme_id = " + Te2String(themeId);
+	if (!portal->query(sql) ||!portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	string colTab = portal->getData("collection_table");
+	//delete collection table
+	if (this->tableExist(colTab))	
+	{
+		sql = "DROP TABLE " + colTab;
+		if (!this->execute(sql) )
+		{	
+			delete portal;
+			return false;
+		}
+	}
+	//delete auxiliar collection table
+	if (this->tableExist(colTab +"_aux"))	
+	{
+		sql = "DROP TABLE " +colTab +"_aux";
+		if (!this->execute(sql) )
+		{	
+			delete portal;
+			return false;
+		}
+	}
+	portal->freeResult();
+
+	//delete the visual associated to this theme
+	if (existRelation("te_visual","fk_visual_legend_id") != TeRICascadeDeletion)
+	{
+		sql = "SELECT legend_id FROM te_legend WHERE theme_id = " + Te2String(themeId);
+		if (!portal->query(sql))
+		{	
+			delete portal;
+			return false;
+		}
+		string wherec;
+		int c = 0;
+		while (portal->fetchRow())
+		{
+			if (c)
+				wherec += ",";
+			c++;
+			wherec += portal->getData(0);
+		}
+		portal->freeResult();
+        if (!wherec.empty()) 
+        {
+			sql = "DELETE FROM te_visual WHERE legend_id IN (" + wherec + ")";
+			if (!this->execute(sql))
+			{	
+				delete portal;
+				return false;
+			}
+	   }
+	}
+
+	//delete all visuals of raster associated to this theme
+	if (existRelation("te_visual_raster","fk_visrast_theme_id") != TeRICascadeDeletion)
+	{
+		sql = "DELETE FROM te_visual_raster WHERE theme_id =" + Te2String(themeId);
+		if (!this->execute (sql))
+		{	
+			delete portal;
+			return false;
+		}
+	}
+	
+	//delete all legends associated to this theme
+	if (existRelation("te_legend","fk_legend_theme_id") != TeRICascadeDeletion)
+	{
+		sql = "DELETE FROM te_legend WHERE theme_id =" + Te2String(themeId);
+		if (!this->execute (sql))
+		{	
+			delete portal;
+			return false;
+		}
+	}
+	
+	//select the view of this theme
+	sql = "SELECT view_id FROM te_theme WHERE theme_id = " + Te2String(themeId);
+	portal->freeResult();
+	if(!portal->query(sql) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	//delete theme of the view tree
+	int viewId = portal->getInt("view_id");
+	delete portal;
+
+	//delete the tables associated to this theme
+	if (existRelation("te_theme_table","fk_thmtable_theme_id") != TeRICascadeDeletion)
+	{
+		sql = "DELETE FROM te_theme_table WHERE theme_id =" + Te2String(themeId);
+		if (!this->execute (sql))
+			return false;
+	}
+		
+	//delete the grouping
+	if (existRelation("te_grouping","fk_group_theme_id")  != TeRICascadeDeletion)
+	{
+		sql = "DELETE FROM te_grouping WHERE theme_id =" + Te2String(themeId);
+		if (!this->execute (sql))
+			return false;
+	}
+
+	// delete raster visual
+	if (existRelation("te_visual_raster","fk_visrast_theme_id") == TeNoRelation )
+	{
+		sql = "DELETE FROM te_visual_raster WHERE theme_id =" + Te2String(themeId);
+		if (!this->execute (sql))
+			return false;
+	}
+
+	sql = " UPDATE te_view SET current_theme = NULL WHERE current_theme = "+ Te2String(themeId);
+	this->execute(sql);
+	
+	// delete the theme
+	sql = " DELETE FROM te_theme WHERE theme_id = " + Te2String(themeId);
+	if (!this->execute (sql))
+		return false;
+
+	//delete in the maps
+	TeView* view = viewMap()[viewId];
+	if (view) //this view exists
+		view->remove(themeId); 
+
+    unsigned int i;
+	TeLegendEntryVector& legendVector = tema->legend();
+	for (i = 0; i < legendVector.size(); ++i)
+		legendMap().erase(legendVector[i].id());
+	
+	delete tema;
+	return true;
+}
+
+bool
+TeDatabase::deleteThemeGroup(int themeId)
+{
+	string sql;
+	// delete the theme
+	sql = "DELETE FROM te_theme WHERE theme_id = " + Te2String(themeId);
+	if (!this->execute (sql))
+		return false;
+	return true;
+}
+
+bool
+TeDatabase::deleteLegend(int themeId)
+{
+	// If there is a collection table update legend of the objects in it
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+	string sel = "SELECT collection_table FROM te_theme WHERE theme_id = " + Te2String(themeId);
+	string TC;
+	if (portal->query(sel) && portal->fetchRow())
+		TC = portal->getData(0);
+	delete portal;
+
+	if (!TC.empty() && this->tableExist(TC))
+	{
+		string up = "UPDATE " + TC + " SET c_legend_id = 0";
+		if (!execute(up))
+			return false;
+	}
+
+	// Delete visual of the legends
+	string del = "DELETE FROM te_visual WHERE legend_id IN ";
+	del += "(SELECT legend_id FROM te_legend WHERE theme_id = " + Te2String(themeId);
+	del += " AND group_id > -1)";
+	if (!execute(del))
+		return false;
+
+	del = "DELETE FROM te_legend WHERE theme_id = " + Te2String(themeId);
+	del += " AND group_id > -1";
+	if (!execute(del))
+		return false;
+
+	// Delete from memory the legends of the theme
+	unsigned int i;
+	TeAbstractTheme *theme = metaModel_->themeMap()[themeId];
+	TeLegendEntryVector& legendVector = theme->legend();
+	for (i = 0; i < legendVector.size(); ++i)
+		metaModel_->legendMap().erase(legendVector[i].id());
+	legendVector.clear();
+
+	//delete grouping
+	del = "DELETE FROM te_grouping WHERE theme_id =" + Te2String(themeId);
+	if (!execute (del))
+		return false;
+		
+	return true;
+}
+
+bool
+TeDatabase::updateLayer(TeLayer *layer)
+{
+	if (!layer)
+		return false;
+
+	if (layer->projection())
+		updateProjection(layer->projection());
+
+	string sql;
+	sql = "UPDATE te_layer SET ";
+	sql += "name = '" + layer->name() + "' ";
+	if (layer->box().isValid())
+	{
+		sql += ", lower_x = " + Te2String(layer->box().x1(),15) + " ";
+		sql += ", lower_y = " + Te2String(layer->box().y1(),15) + " ";
+		sql += ", upper_x = " + Te2String(layer->box().x2(),15) + " ";
+		sql += ", upper_y = " + Te2String(layer->box().y2(),15) + " ";
+	}else
+	{
+		sql += ", lower_x = " + Te2String(layer->box().x1()) + " ";
+		sql += ", lower_y = " + Te2String(layer->box().y1()) + " ";
+		sql += ", upper_x = " + Te2String(layer->box().x2()) + " ";
+		sql += ", upper_y = " + Te2String(layer->box().y2()) + " ";
+	}
+	sql +=  " WHERE layer_id = " + Te2String(layer->id());
+
+	return (this->execute (sql));
+}
+
+bool
+TeDatabase::loadLayerSet(const bool& loadAttrList)
+{
+	//clear layer map
+	TeLayerMap::iterator it = metaModel_->layerMap().begin();
+	while (it != metaModel_->layerMap().end())
+	{
+		if(it->second)
+			delete it->second;
+		++it;
+	}
+	metaModel_->layerMap().clear();
+	
+	string sql = " SELECT te_layer.*, "; // 0 - 8 (9 columns)
+	sql += " te_projection.*, "; // 9 - 25  (17 columns)
+	sql += " te_representation.*, "; // 26 - 40 (15 columns)
+	sql += " te_layer_table.* "; // 41 - 52 (12 columns)
+	
+	sql += " FROM (((te_layer INNER JOIN te_projection ";
+	sql += " ON te_layer.projection_id = te_projection.projection_id) ";
+	sql += " LEFT JOIN te_representation ON ";
+	sql += " te_layer.layer_id = te_representation.layer_id) ";
+	sql += " LEFT JOIN te_layer_table ON ";
+	sql += " te_layer.layer_id = te_layer_table.layer_id) ";
+
+	sql += " ORDER BY te_layer.layer_id, te_representation.geom_type, te_layer_table.table_id ";
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+	
+	int lastLayerId = -1;
+	TeLayer *layer = 0;
+	bool hasNewRow = portal->fetchRow(); //idicates that this portal was fetched 
+	while(hasNewRow)
+	{
+		//load view and its projection 
+		if(lastLayerId!=atoi(portal->getData(0)))
+		{
+			TeProjection* proj = 0;
+			if(!portal->getProjection(&proj, 9)) //load projection
+			{
+				delete portal;
+				return false;
+			}
+			layer = new TeLayer();
+			if(!portal->getLayer(*layer, 0)) //load layer
+			{
+				delete portal;
+				delete layer;
+				return false;
+			}
+			if (proj != 0)
+				layer->setProjection(proj);
+			lastLayerId = layer->id();
+		}
+
+		//load its representation and its tables
+		bool hasRepsTablesToThisLayer = true;
+		vector<int> loadedTableId;
+		while(hasRepsTablesToThisLayer)
+		{
+			//load representation
+			string repId = portal->getData(26);
+			if(!repId.empty() && !layer->hasGeometry(TeGeomRep(portal->getInt(28))))
+			{
+				TeRepresentation* rep = new TeRepresentation();
+				if(!portal->getRepresentation(*rep, 26))
+				{
+					delete rep;
+					delete layer;
+					delete portal;
+				}
+				layer->addVectRepres(rep);
+			}
+			
+			//load tables
+			if( find(loadedTableId.begin(), loadedTableId.end(), portal->getInt(41)) == loadedTableId.end())
+			{
+				TeTable attrTable;
+				if(portal->getAttrTable(attrTable, 41))
+				{
+					TeAttributeList attrList;
+					if(loadAttrList)
+						getAttributeList(attrTable.name(), attrList);
+					attrTable.setAttributeList(attrList);
+					layer->addAttributeTable(attrTable);
+					loadedTableId.push_back(attrTable.id());
+				}
+			}
+			hasNewRow = portal->fetchRow();
+			if(!hasNewRow || portal->getInt(0)!= layer->id())
+				hasRepsTablesToThisLayer = false;
+		}
+
+		layer->setDatabase(this);
+		metaModel_->layerMap()[layer->id()] = layer;
+	}
+
+	delete portal;
+	return true;
+
+}
+
+string
+TeDatabase::getRasterTable(int layerId, const string& objectId)
+{
+	if (layerId <=0 )
+		return "";
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return "";
+
+	string get;
+	// get the raster representation
+	get = "SELECT geom_table FROM te_representation WHERE layer_id = "+Te2String(layerId);
+	get += " AND geom_type= " + Te2String((int)TeRASTER) + " OR geom_type= " + Te2String((int)TeRASTERFILE);
+	
+	// error executing query or no there is no raster representation 
+	if (!portal->query(get) || !portal->fetchRow())
+	{
+		delete portal;
+		return "";
+	}
+
+	string tableName = portal->getData(0);
+	portal->freeResult();
+	if (tableName.empty())
+	{
+		delete portal;
+		return "";
+	}
+
+	// check if a specific object is being looked for
+	get = "SELECT raster_table FROM " + tableName + " WHERE object_id='" + objectId + "'";
+	if (!portal->query(get) || !portal->fetchRow())
+	{
+		delete portal;
+		return "";
+	}
+	tableName = portal->getData(0);
+	delete portal;
+	return tableName;
+}
+
+
+TeRaster*
+TeDatabase::loadLayerRaster(int layerId, const string& objectId, const char& mode)
+{
+	if (layerId <=0 )
+		return 0;
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return 0;
+
+	TeRaster* raster = 0;
+	string get;
+
+	// get the raster representation
+	get = "SELECT geom_table, geom_type FROM te_representation WHERE layer_id = "+Te2String(layerId);
+	get += " AND (geom_type= " + Te2String((int)TeRASTER) + " OR geom_type= " + Te2String((int)TeRASTERFILE) + ")";
+	
+	// error executing query or no there is no raster representation 
+	if (!portal->query(get) || !portal->fetchRow())
+	{
+		delete portal;
+		return 0;
+	}
+	string tableName = portal->getData(0);
+	TeGeomRep rep = static_cast<TeGeomRep>(portal->getInt(1));
+	portal->freeResult();
+	if (tableName.empty())
+	{
+		delete portal;
+		return 0;
+	}
+
+	//--- this check is made for compatibility reasons with older terralib databases
+	TeAttributeRep	attrRep;
+	attrRep.name_ = "tiling_type";
+	attrRep.type_ = TeINT;
+		
+	TeAttribute att;
+	if(!columnExist(tableName, attrRep.name_,att))
+	{
+		addColumn (tableName, attrRep);
+		string sql = "UPDATE " + tableName + " SET tiling_type = " + Te2String(static_cast<int>(TeRasterParams::TeExpansible));
+		this->execute(sql);
+	}
+
+	// ---
+
+	// check if a specific object is being looked for
+	get = "SELECT * FROM " + tableName;
+	if (!objectId.empty())
+		get += " WHERE object_id='" + objectId + "'"; 
+	if (!portal->query(get) || !portal->fetchRow())
+	{
+		delete portal;
+		return 0;
+	}
+		
+	string oid = portal->getData("object_id");
+	int geomId = portal->getInt("geom_id"); // get raster representation id
+
+	// get raster parameters from te_raster_table table
+	TeRasterParams params;
+	params.fileName_ = portal->getData("raster_table");
+	params.lutName_ = portal->getData("lut_table");
+	params.nBands(portal->getInt("num_bands"));
+	params.boundingBoxResolution(portal->getDouble("lower_x"),portal->getDouble("lower_y"),
+								 portal->getDouble("upper_x"),portal->getDouble("upper_y"),
+							     portal->getDouble("res_x"),portal->getDouble("res_y"));
+	params.blockHeight_ = portal->getInt("block_height");
+	params.blockWidth_ = portal->getInt("block_width");
+	params.tiling_type_ = static_cast<TeRasterParams::TeRasterTilingType>(portal->getInt("tiling_type"));
+
+	portal->freeResult();
+
+	// get extra information from te_raster_metadata table
+	string metadatatable = tableName + "_metadata"; 
+	unsigned int nb = params.nBands();
+	unsigned int i;
+	for (i=0; i<nb; i++)
+	{
+		get = "SELECT * FROM " + metadatatable + " WHERE geom_id=" + Te2String(geomId);
+		get += " AND band_id=" + Te2String(i);
+		if (portal->query(get) && portal->fetchRow()) 
+		{
+			params.vmax_[i] = portal->getDouble("max_value");
+			params.vmin_[i] = portal->getDouble("min_value");
+			params.nbitsperPixel_[i] = portal->getInt("num_bits");
+			params.dataType_[i] =  static_cast<TeDataType>(portal->getInt("data_type"));
+			params.compression_[i] = static_cast<TeRasterParams::TeRasterCompressionMode>(portal->getInt("compression_type"));
+			params.photometric_[i] = static_cast<TeRasterParams::TeRasterPhotometricInterpretation>(portal->getInt("photometric_type"));
+		}
+		portal->freeResult();
+	}
+
+	// if raster is pallete get the associated LUT
+	if (params.photometric_[0] == TeRasterParams::TePallete && 	rep != TeRASTERFILE)
+		this->loadRasterLUT(&params);
+
+	// raster has the same projection as its layer
+	get = " SELECT te_projection.* FROM ";
+	get += " te_projection INNER JOIN te_layer ON ";
+	get += " te_projection.projection_id = te_layer.projection_id ";
+	get += " WHERE layer_id = " + Te2String(layerId);
+	
+	TeProjection* proj=0;
+	if (portal->query(get) && portal->fetchRow())
+		portal->getProjection(&proj);
+
+	portal->freeResult();
+	params.projection(proj);
+	if (proj)
+		delete proj;
+
+	bool hasDummy = false;
+	get = "SELECT band_id, dummy FROM " + metadatatable + " WHERE geom_id=" + Te2String(geomId);
+	get += " AND NOT (dummy IS NULL)";
+	if (portal->query(get))
+	{
+		while (portal->fetchRow())
+		{
+			int b = portal->getInt(0);
+			double d = portal->getDouble("dummy");
+			params.setDummy(d,b);
+			hasDummy = true;
+		}
+	}
+	params.useDummy_ = hasDummy;
+	params.mode_ = mode;
+	params.objectId_ = oid;
+	params.layerId_ = layerId;
+	delete portal;
+
+	if ( rep == TeRASTER)
+	{
+		params.nTilesInMemory_ = 0;
+		params.database_ = this;
+		TeDecoderDatabase* dec = new TeDecoderDatabase(params);
+		dec->init();
+		raster = new TeRaster();
+		raster->setDecoder(dec);
+		raster->objectId(oid);
+		return raster;
+	}
+	try
+	{
+		raster = new TeRaster(params);
+	}
+	catch(...)
+	{
+		if (params.fileName_.empty() == false)
+		{
+			errorMessage_ = "File doesn't exist: ";
+			errorMessage_ += params.fileName_;
+		}
+		else
+		{
+			errorMessage_ = "Raster file is not accessible.";
+		}
+		return 0;
+	} 
+	raster->init();
+	return raster;
+}
+
+bool 
+TeDatabase::loadRasterLUT(TeRasterParams* par)
+{
+	if (par->lutName_.empty())		
+		return false;
+	
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string get = "SELECT COUNT(index_id) FROM " + par->lutName_;
+	if (!portal->query(get) || !portal->fetchRow())	 // if there is no table, or table is empty
+	{
+		delete portal;
+		return false;
+	}
+	int nentries = atoi(portal->getData(0));
+	if (nentries <= 0)
+	{
+		delete portal;
+		return false;
+	}
+	portal->freeResult();
+
+	par->lutr_.clear();
+	par->lutg_.clear();
+	par->lutb_.clear();
+
+	par->lutr_.resize(nentries);
+	par->lutg_.resize(nentries);
+	par->lutb_.resize(nentries);
+
+	par->lutr_.assign(nentries,0);
+	par->lutg_.assign(nentries,0);
+	par->lutb_.assign(nentries,0);
+
+	get = "SELECT * FROM " + par->lutName_ + " ORDER BY index_id ASC ";
+	if (!portal->query(get) || !portal->fetchRow())	 // if there is no table, or table is empty
+	{
+		delete portal;
+		return false;
+	}
+
+	do
+	{
+		int index = atoi(portal->getData(0));
+		par->lutr_[index] = atoi(portal->getData(1));
+		par->lutg_[index] = atoi(portal->getData(2));
+		par->lutb_[index] = atoi(portal->getData(3));
+	}while (portal->fetchRow());
+
+	delete portal;
+	return true;
+}
+
+bool
+TeDatabase::createSpatialIndex(const string& table, const string& columns, TeSpatialIndexType /*type*/, short /*level*/, short /*tile*/)
+{
+	string idxName = "sp_idx_" + table;
+	return createIndex(table, idxName, columns);
+}
+
+string TeDatabase::getSpatialIdxColumn(TeGeomRep rep)
+{
+	string columns = "";
+	switch(rep)
+	{
+		case TePOINTS:
+		case TeNODES:	columns = "x, y";
+						break;
+		case TeLINES:
+		case TePOLYGONS:
+		case TeCELLS:
+						columns = "lower_x, lower_y, upper_x, upper_y";
+						break;
+		case TeRASTER:
+						columns = " lower_x, lower_y, upper_x, upper_y, resolution_factor, subband ";
+						break;
+		default:		columns = "";
+	}
+	
+    return columns;
+}
+
+bool
+TeDatabase::loadLayer(TeLayer* layer, const bool& loadAttrList)
+{
+	if (layer == 0)
+		return false;
+
+	string rest;
+	if (layer->id() > 0)
+		rest = " te_layer.layer_id = "+  Te2String(layer->id());
+	else if (!layer->name().empty())
+		rest = " te_layer.name = '"+  layer->name() + "'";
+	else
+	{
+		this->errorMessage_ = "Layer procurado n�o possui nem id nem nome";
+		return false;
+	}
+	
+	string sql = " SELECT te_layer.*, "; // 0 - 8 (9 columns)
+	sql += " te_projection.*, "; // 9 - 25  (17 columns)
+	sql += " te_representation.*, "; // 26 - 40 (15 columns)
+	sql += " te_layer_table.* "; // 41 - 52 (12 columns)
+	
+	sql += " FROM (((te_layer INNER JOIN te_projection ";
+	sql += " ON te_layer.projection_id = te_projection.projection_id) ";
+	sql += " LEFT JOIN te_representation ON ";
+	sql += " te_layer.layer_id = te_representation.layer_id) ";
+	sql += " LEFT JOIN te_layer_table ON ";
+	sql += " te_layer.layer_id = te_layer_table.layer_id) ";
+
+	sql += " WHERE "+ rest;
+
+	sql += " ORDER BY te_representation.geom_type, te_layer_table.table_id ";
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	if(!portal->query(sql) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	bool hasNewRow = true;
+	TeProjection* proj = 0;
+	if(!portal->getProjection(&proj, 9)) //load projection
+	{
+		delete portal;
+		return false;
+	}
+	
+	if(!portal->getLayer(*layer, 0)) //load layer
+	{
+		delete portal;
+		delete layer;
+		return false;
+	}
+	if (proj != 0)
+		layer->setProjection(proj);
+		
+	//load its representation and its tables
+	bool hasRepsTablesToThisLayer = true;
+	vector<int> loadedTableId;
+	while(hasRepsTablesToThisLayer)
+	{
+		string repId = portal->getData(26);
+		if(!repId.empty() && !layer->hasGeometry(TeGeomRep(portal->getInt(28))))
+		{
+			//load the geometry representation
+			TeRepresentation* rep = new TeRepresentation();
+			if(!portal->getRepresentation(*rep, 26))
+			{
+				delete rep;
+				delete layer;
+				delete portal;
+			}
+			layer->addVectRepres(rep);
+		}
+		
+		//load tables
+		if(find(loadedTableId.begin(), loadedTableId.end(), portal->getInt(41)) == loadedTableId.end())
+		{
+			TeTable attrTable;
+			if(portal->getAttrTable(attrTable, 41))
+			{
+				TeAttributeList attrList;
+				if(loadAttrList)
+					getAttributeList(attrTable.name(), attrList);
+				attrTable.setAttributeList(attrList);
+				layer->addAttributeTable(attrTable);
+				loadedTableId.push_back(attrTable.id());
+			}
+		}
+		
+		hasNewRow = portal->fetchRow();
+		if(!hasNewRow || portal->getInt(0)!= layer->id())
+			hasRepsTablesToThisLayer = false;
+	}
+	layer->setDatabase(this);
+	metaModel_->layerMap()[layer->id()] = layer;
+	
+	delete portal;
+	return true;
+}
+
+bool
+TeDatabase::loadLayerTable(TeLayer* layer, const bool& loadAttrList)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+	{
+		this->errorMessage_ = "N�o foi poss�vel abrir portal para o banco";
+		return false;
+	}
+	
+	// Get layer tables	
+	string get =  " SELECT * FROM te_layer_table"; 
+	get += " WHERE layer_id = " + Te2String(layer->id());
+	get += " ORDER BY attr_table_type, table_id";
+
+	if (!portal->query (get))
+	{	
+		delete portal;
+		return false;
+	}
+
+	while (portal->fetchRow())
+	{
+		TeTable attTable;
+		if(!portal->getAttrTable (attTable))
+		{
+			delete portal;
+			return false;
+		}
+		TeAttributeList attrList;
+		if(loadAttrList)
+			getAttributeList(attTable.name(), attrList);
+		attTable.setAttributeList(attrList);
+		layer->addAttributeTable(attTable);
+	}
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::layerExist(int layerId)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string sql = "SELECT layer_id FROM te_layer WHERE layer_id = " + Te2String(layerId);
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+	if (!portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::layerExist(string layerName)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	layerName = TeConvertToUpperCase(layerName);
+
+	string sql = "SELECT name FROM te_layer";
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+	while (portal->fetchRow())
+	{
+		string name = portal->getData(0);
+		name = TeConvertToUpperCase(name);
+		if (layerName == name)
+		{
+			delete portal;
+			return true;
+		}
+	}
+	delete portal;
+	return false;
+}
+
+string TeDatabase::getNewLayerName(const string& n)
+{
+	bool changed;
+	string invalidChar;
+	string name = TeCheckName(n, changed, invalidChar);
+	string newName = name;
+	
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return "";
+	
+	bool flag = true;
+	int count = 0;
+	while(flag)
+	{
+		portal->freeResult();
+		string q = "SELECT name FROM te_layer WHERE name = '" + newName + "'";
+		if(portal->query(q) && portal->fetchRow())
+		{
+			// there is already this theme name 
+			newName = newName+"_"+Te2String(count);
+			++count;
+			flag = true;
+         }
+		else
+			flag = false; //found the new name
+	}
+	delete portal;
+	return newName;
+}
+
+bool
+TeDatabase::deleteLayer(int layerId)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+	
+	string sql = "SELECT projection_id FROM te_layer WHERE layer_id = ";
+	sql += Te2String(layerId);
+
+	if (!portal->query(sql))
+	{	
+		delete portal;
+		return false;
+	}
+
+	if (!portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	string projId = portal->getData("projection_id");
+	portal->freeResult();
+
+	// Get all representations that are associated to this layer
+	sql = "SELECT * FROM te_representation WHERE layer_id = "+ Te2String(layerId);
+	if (!portal->query (sql))
+	{
+		delete portal;
+		return false;
+	}
+
+	while (portal->fetchRow())
+	{	
+		// Save the name of the geometry table
+		string geomTable = portal->getData("geom_table");
+
+		// Delete lut table
+		TeGeomRep rep = TeGeomRep(portal->getInt("geom_type"));
+		if (rep == TeRASTER || rep == TeRASTERFILE)
+		{
+			TeDatabasePortal* portal2 = this->getPortal();
+			sql = "SELECT lut_table, raster_table FROM " + geomTable;
+			string tabName;
+			if (!portal2->query (sql))
+			{
+				delete portal2;
+				continue;
+			}
+
+			while (portal2->fetchRow())
+			{
+				// remove lut table
+				tabName = portal2->getData(0);
+				if (!tabName.empty() && this->tableExist(tabName))
+				{
+					sql = "DROP TABLE " + tabName;
+					this->execute(sql);
+				}
+				// remove raster table
+				tabName = portal2->getData(1);
+				if (!tabName.empty() && this->tableExist(tabName))
+				{
+					sql = "DROP TABLE " + tabName;
+					this->execute(sql);
+				}
+			}
+			delete portal2;
+			// remove raster metadata table
+			tabName = geomTable + "_metadata";
+			if (!tabName.empty() && this->tableExist(tabName))
+			{
+				sql = "DROP TABLE " + tabName;
+				this->execute(sql);
+			}
+		}
+		if (this->tableExist(geomTable))
+		{
+			sql = "DROP TABLE " + geomTable;
+			if (!this->execute(sql) )
+			{
+				delete portal;
+				return false;
+			}
+		}
+	}
+	portal->freeResult();
+
+	if (existRelation("te_representation","fk_rep_layer_id") != TeRICascadeDeletion)
+	{
+		// Delete entries into representations table
+		sql = "DELETE FROM te_representation WHERE layer_id = " +Te2String(layerId);
+		if (!this->execute(sql) )
+		{
+			delete portal;
+			return false;
+		}
+	}
+
+	// delete layer themes
+	sql = "SELECT theme_id FROM te_theme WHERE layer_id=" + Te2String(layerId);
+	if (!portal->query (sql))
+	{
+		delete portal;
+		return false;
+	}
+	
+	int themeId;
+	while (portal->fetchRow())
+	{	
+		themeId = portal->getInt("theme_id");
+		this->deleteTheme(themeId);
+	}
+
+	//Delete attributes tables
+	if(!deleteLayerTable(layerId))
+		return false;
+	
+	sql = "DELETE FROM te_layer WHERE layer_id=" + Te2String(layerId);
+	if (!this->execute(sql))
+	{
+		delete portal;
+		return false;
+	}
+
+	// delete layer projection
+	sql = "DELETE FROM te_projection WHERE projection_id = "+ projId;
+	if (!this->execute(sql))
+	{	
+		delete portal;
+		return false;
+	}
+
+	// remove all the items� themes associated to the layer to be removed
+	TeThemeMap::iterator it;
+	for (it = metaModel_->themeMap().begin(); it != metaModel_->themeMap().end();)
+	{
+		if(it->second->getProductId() != TeTHEME)
+		{
+			++it;
+			continue;
+		}
+		TeTheme *theme = static_cast<TeTheme*> (it->second);
+		++it;
+		if (theme && theme->layer() && (theme->layer()->id() == layerId))
+		{
+			metaModel_->themeMap().erase(theme->id());
+			delete theme;
+		}
+	}
+	// delete layer and its entry in the layer map
+	TeLayer* layer = metaModel_->layerMap()[layerId];
+	metaModel_->layerMap().erase(layerId);
+	delete layer;
+
+	delete portal;
+	return true;
+}
+
+
+bool
+TeDatabase::deleteLayerTable (int layerId, TeAttrTableType ttype)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	//tables of the type 1 can be relationed with other layer ??? Conferir
+	string query = "SELECT attr_table, table_id FROM te_layer_table WHERE layer_id = " + Te2String(layerId);
+	query += " AND attr_table_type = " + Te2String(static_cast<int>(ttype));
+	if(!portal->query(query))
+	{
+		delete portal;
+		return false;
+	}
+		
+	vector<int> tableIds;
+	string attrTable;
+	string tableId;
+	string drop;
+	while (portal->fetchRow())
+	{
+		attrTable = portal->getData(0);
+		tableId = portal->getData(1);
+		drop = "DROP TABLE " + attrTable;
+		if(tableExist(attrTable))
+		{
+			if(!execute(drop))
+			{
+				delete portal;
+				return false;
+			}
+		}
+		tableIds.push_back(atoi(tableId.c_str()));
+
+		string del  = "DELETE FROM te_address_locator WHERE table_id = "+ tableId;
+		execute(del);
+	}
+
+	delete portal;
+	string del;
+	if (existRelation("te_tables_relation","fk_tabrelation_laytable_id") != TeRICascadeDeletion)
+	{
+		for (unsigned int i=0; i<tableIds.size();i++)
+		{
+			del = "DELETE FROM te_tables_relation WHERE relation_id = " + Te2String(tableIds[i]);
+			if (!execute (del))
+				return false;
+		}
+	}
+	del = "DELETE FROM te_layer_table WHERE layer_id = " + Te2String(layerId);
+	if (!execute (del))
+		return false;
+	return true;
+}
+
+bool 
+TeDatabase::updateRepresentation (int layerId, TeRepresentation& rep)
+{
+	if (layerId <= 0)
+		return false;
+
+	string sql;
+	sql  = "UPDATE te_representation SET ";
+	sql += " lower_x= " + Te2String(rep.box_.x1(),15);
+	sql += ", lower_y= " + Te2String(rep.box_.y1(),15);
+	sql += ", upper_x= " + Te2String(rep.box_.x2(),15);
+	sql += ", upper_y= " + Te2String(rep.box_.y2(),15);
+	sql += ", description= '" + rep.description_ + "'";
+	sql += ", res_x= " + Te2String(rep.resX_,15);
+	sql += ", res_y= " + Te2String(rep.resY_,15);
+	sql += ", num_cols=" + Te2String(rep.nCols_);
+	sql += ", num_rows=" + Te2String(rep.nLins_);
+
+	if (rep.geomRep_ != TeTEXT)
+		sql += ", geom_table='" + rep.tableName_ + "'";
+
+	sql += " WHERE layer_id=" + Te2String(layerId);
+	sql += " AND geom_type= " + Te2String(rep.geomRep_);
+
+	if (rep.geomRep_ == TeTEXT)
+		sql += " AND geom_table='" + rep.tableName_ + "'";
+
+	return this->execute(sql);
+}
+
+bool 
+TeDatabase::insertRasterGeometry(const string& tableName, TeRasterParams& par, const string& objectId)
+{
+	if (tableName.empty())
+		return false;
+	
+	string objId; 
+	if (objectId.empty())
+		objId = "O1";
+	else
+		objId = objectId;
+
+	//------ this check is made for compatibility reasons with old versions of TerraLib databases
+	TeAttributeRep	attrRep;
+	attrRep.name_ = "tiling_type";
+	attrRep.type_ = TeINT;
+		
+	TeAttribute att;
+	if(!columnExist(tableName, attrRep.name_,att))
+	{
+		addColumn (tableName, attrRep);
+		string sql = "UPDATE " + tableName + " SET tiling_type = " + Te2String(static_cast<int>(TeRasterParams::TeExpansible));
+		this->execute(sql);
+	}
+	//------
+
+	// finds the name of the raster geometry table
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	TeBox box = par.boundingBox();
+
+	string ins = "INSERT INTO " + tableName + " (object_id, raster_table, lut_table, ";
+	ins += "res_x, res_y, num_bands, num_cols, num_rows, block_height, block_width, ";
+	ins += "lower_x, lower_y, upper_x, upper_y, tiling_type) ";
+	ins += " VALUES ('" + objId + "', '" + par.fileName_+ "', '" +  par.lutName_ + "', ";
+	ins += Te2String(par.resx_) + ", " + Te2String(par.resy_) + ", ";
+	ins += Te2String(par.nBands()) + ", " + Te2String(par.ncols_) + ", " + Te2String(par.nlines_) + ", ";
+	ins += Te2String(par.blockHeight_) + ", " + Te2String(par.blockWidth_) + ", ";
+	ins += Te2String(box.x1_,15) +", " + Te2String(box.y1_,15) + ", ";
+	ins += Te2String(box.x2_,15) +", " + Te2String(box.y2_,15) + ", ";
+	ins	+= Te2String(par.tiling_type_) + ")";
+	if (!this->execute(ins))
+	{
+		delete portal;
+		return false;
+	}
+
+	// save the pallete associated to the raster
+	// if it doesn�t exist yet
+	if (par.photometric_[0] == TeRasterParams::TePallete && !par.lutName_.empty()) 
+	{
+		 if (!this->tableExist(par.lutName_))
+		 {
+			 if (this->createLUTTable(par.lutName_))
+			{
+				for (unsigned int i=0; i<par.lutb_.size(); i++)
+				{
+					string sql = "INSERT INTO " + par.lutName_ + " VALUES(";
+					sql += Te2String(i) + ", ";
+					sql += Te2String(par.lutr_[i]) + ", ";
+					sql += Te2String(par.lutg_[i]) + ", ";
+					sql += Te2String(par.lutb_[i]) + ")";
+					this->execute(sql);
+				}
+			 }
+		 }
+	}
+	
+	ins = "SELECT geom_id FROM " + tableName + " WHERE object_id='" + objId + "'";
+	ins += " AND raster_table='" + par.fileName_+ "'";
+	if(!portal->query(ins) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	int geomId = atoi(portal->getData(0));
+	delete portal;
+	string 	metadataTableName = tableName+"_metadata";
+	insertRasterMetadata(metadataTableName, geomId,par);
+	 return true;
+}
+
+bool 
+TeDatabase::updateRasterRepresentation(int layerId, TeRasterParams& par, const string& objectId)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	string sql = "SELECT repres_id, lower_x, lower_y, upper_x, upper_y, geom_table ";
+	sql += " FROM te_representation WHERE layer_id= " + Te2String(layerId);
+	sql += " AND geom_type= " + Te2String(TeRASTER);
+
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	TeBox box (portal->getDouble(1),portal->getDouble(2),
+		       portal->getDouble(3),portal->getDouble(4));
+	int represId = atoi(portal->getData(0));
+	string rasterrep = portal->getData(5);
+	portal->freeResult();
+
+	updateBox(box,par.boundingBox());
+	sql = "UPDATE te_representation SET lower_x = " + Te2String(box.x1_,15);
+	sql += ", lower_y = " + Te2String(box.y1_,15) + ", upper_x = " + Te2String(box.x2_,15);
+	sql += ", upper_y = " + Te2String(box.y2_,15) + "  WHERE repres_id=" + Te2String(represId);
+
+	if(!execute(sql))
+	{
+		delete portal;
+		return false;
+	}	 
+
+	string objId; 
+	if (objectId.empty())
+		objId = "O1";
+	else
+		objId = objectId;
+
+	box = par.boundingBox();
+
+	sql = "UPDATE " + rasterrep + " SET lut_table ='" + par.lutName_ + "'";
+	sql += ", res_x= " + Te2String(par.resx_) + ", res_y=" + Te2String(par.resy_);
+	sql += ", num_bands=" + Te2String(par.nBands()) + ", num_cols=" + Te2String(par.ncols_);
+	sql += ", num_rows=" + Te2String(par.nlines_) + ", block_height=" +  Te2String(par.blockHeight_);
+	sql += ", block_width= " + Te2String(par.blockWidth_) + ", lower_x = " + Te2String(box.x1_,15);
+	sql += ", lower_y = " + Te2String(box.y1_,15) +  ", upper_x = " + Te2String(box.x2_,15);
+	sql += ", upper_y = " + Te2String(box.y2_,15);
+	sql += "  WHERE object_id='" + objId + "' AND raster_table='" + par.fileName_ + "'";
+	if (!this->execute(sql))
+	{
+		delete portal;
+		return false;
+	}
+	
+	sql = "SELECT geom_id FROM " + rasterrep + " WHERE object_id='" + objId + "'";
+	sql+= " AND raster_table='" + par.fileName_+ "'";
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	// save the pallete associated to the raster
+	// if it doesn�t exist yet
+	if (par.photometric_[0] == TeRasterParams::TePallete && !par.lutName_.empty()) 
+	{
+
+		 if (!this->tableExist(par.lutName_))
+		 {
+			 if (this->createLUTTable(par.lutName_))
+			{
+				for (unsigned int i=0; i<par.lutb_.size(); i++)
+				{
+					string sql = "INSERT INTO " + par.lutName_ + " VALUES(";
+					sql += Te2String(i) + ", ";
+					sql += Te2String(par.lutr_[i]) + ", ";
+					sql += Te2String(par.lutg_[i]) + ", ";
+					sql += Te2String(par.lutb_[i]) + ")";
+					if (!this->execute(sql) )	
+					{
+						delete portal;
+						return false;						
+					}
+				}
+			 }
+		 }
+	}
+
+	int geomId = atoi(portal->getData(0));
+	delete portal;
+	string metadatatabel = rasterrep + "_metadata";
+	return updateRasterMetadata(metadatatabel,geomId,par);
+}
+
+bool 
+TeDatabase::insertRasterMetadata (const string& tableName, int geomId, TeRasterParams& par)
+{
+	if (geomId <= 0)
+		return false;
+	
+	string ins;
+	unsigned int i;
+
+	unsigned int nb = par.nBands();
+	ins = "INSERT INTO " + tableName + " (geom_id, band_id, min_value, max_value, ";
+	ins += " num_bits, data_type, photometric_type, compression_type ) VALUES (";
+	string vals;
+	for (i=0; i<nb; i++)
+	{
+		vals = Te2String(geomId) + ", " + Te2String(i) + ", ";
+		vals += Te2String(par.vmin_[i]) + ", " +  Te2String(par.vmax_[i]) + ", ";
+		vals += Te2String(par.nbitsperPixel_[i]) + ", " +  Te2String(par.dataType_[i]) + ", " ;
+		vals += Te2String(par.photometric_[i]) + ", " +  Te2String(par.compression_[i]) + " )" ;
+		string sql = ins + vals;
+		if (!this->execute(sql))
+			return false;
+	}
+
+	// update dummy value
+	if (par.useDummy_)
+	{
+		ins = "UPDATE " + tableName + " SET dummy = ";
+		for (i=0; i<nb; i++)
+		{
+			vals = Te2String(par.dummy_[i]) + " WHERE geom_id = " +  Te2String(geomId);
+			vals += " AND band_id=" + Te2String(i);
+			string sql = ins + vals;
+			if (!this->execute(sql))
+				return false;
+		}
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updateRasterMetadata (const string& tableName, int geomId, TeRasterParams& par)
+{
+	if (geomId <= 0)
+		return false;
+
+	string sql = "DELETE FROM " + tableName + " WHERE geom_id = " + Te2String(geomId);
+	if (!this->execute (sql))
+		return false;
+	return insertRasterMetadata(tableName,geomId,par);
+}
+
+bool 
+TeDatabase::updateLegend (TeLegendEntry *legend)
+{
+	if (!legend)
+		return false;
+
+	string sql;
+	if (legend->id() > 0 )
+	{
+		sql = "UPDATE te_legend SET ";
+		sql += " theme_id=" + Te2String (legend->theme());
+		sql += ",group_id=" + Te2String (legend->group());
+		sql += ",num_objs=" + Te2String (legend->count());
+		sql += ",lower_value='" + escapeSequence(legend->from())+"'";
+		sql += ",upper_value='" + escapeSequence(legend->to())+"'";
+		sql += ",label='" + escapeSequence(legend->label())+"'";
+		sql += " WHERE legend_id=" + Te2String (legend->id());
+
+		if (execute(sql) == false)
+			return false;
+	}
+	else
+	{
+		if (!insertLegend(legend))
+			return false;
+	}
+	metaModel_->legendMap()[legend->id()] = legend;
+
+	return updateVisual(legend);
+}
+
+bool 
+TeDatabase::updateLegend (vector<TeLegendEntry>& legVec)
+{
+	unsigned int i;
+	for (i = 0; i < legVec.size(); ++i)
+	{
+		if(!updateLegend(&legVec[i]))
+			return false;
+	}
+	return true;
+}
+
+bool
+TeDatabase::updateVisual(TeLegendEntry *legend)
+{
+	if (!legend)
+		return false;
+
+	TeGeomRepVisualMap& mapVis = legend->getVisualMap();
+	TeGeomRepVisualMap::iterator it =  mapVis.begin();
+	while ( it != mapVis.end())
+	{ 
+			
+		TeGeomRep rep = it->first;
+		TeVisual* vis = it->second;
+
+		TeColor cor = vis->color();				// filling color
+		TeColor contourCor = vis->contourColor();// contour color
+
+		string update = "UPDATE te_visual SET ";
+		update += "red = "+ Te2String(cor.red_) + ", ";
+		update += "green =" + Te2String(cor.green_) + ", ";
+		update += "blue =" + Te2String(cor.blue_) + ", ";
+		update += "transparency =" + Te2String(vis->transparency()) + ", ";
+		update += "contour_red=" + Te2String(contourCor.red_) + ", ";
+		update += "contour_green=" + Te2String(contourCor.green_) + ", ";
+		update += "contour_blue=" + Te2String(contourCor.blue_) + ", "; 
+		update += "contour_transp=" + Te2String(vis->contourTransparency()) + ", ";
+		update += "contour_width=" + Te2String(vis->contourWidth()) + ", ";
+
+		if(rep == TePOLYGONS)
+		{
+			update += "width=" + Te2String(vis->contourWidth()) + ", ";
+			update += "contour_symb_id=" + Te2String(vis->contourStyle()) + ", ";
+			update += "symb_id=" + Te2String(vis->style()) + ", ";
+		}
+		else if(rep == TeLINES)
+		{
+			update += "width=" + Te2String(vis->width()) + ", ";
+			update += "symb_id=" + Te2String(vis->style()) + ", ";
+		}
+		else if(rep == TePOINTS)
+		{
+			update += "size_value=" + Te2String(vis->size()) + ", ";
+			update += "symb_id=" + Te2String(vis->style ()) + ", ";
+		}
+		else if(rep == TeTEXT)
+		{
+			update += "size_value=" + Te2String(vis->size()) + ", ";
+			update += "pt_angle=" + Te2String(vis->ptAngle()) + ", ";
+		}
+
+		update += "family='" + vis->family() + "', ";
+		if (vis->bold())
+			update += "bold=1, ";
+		else
+			update += "bold=0, ";
+
+		if (vis->italic())
+			update += "italic=1, ";
+		else
+			update += "italic=0, ";
+
+		update += "fixed_size=" + Te2String(vis->fixedSize())+ ", ";
+		update += "alignment_vert=" + Te2String(vis->alignmentVert())+ ", ";
+		update += "alignment_horiz=" + Te2String(vis->alignmentHoriz())+ ", ";
+		update += "tab_size=" + Te2String(vis->tabSize())+ ", ";
+		update += "line_space=" + Te2String(vis->lineSpace());
+
+		update += " WHERE legend_id= " + Te2String(legend->id()) ;
+		update += " AND geom_type= " + Te2String(rep);
+
+		if (!execute(update))
+			return false;
+		++it;
+	}
+	return true;
+}
+
+bool
+TeDatabase::updateVisual(vector<TeLegendEntry>& legVec)
+{
+	unsigned int i;
+
+	// Update the te_visual table
+	TeTable visualTable;
+	selectTable("te_visual", "1=0", visualTable);
+	TeAttributeList& visualAttrList = visualTable.attributeList();
+	TeAttribute& visualAttr0 = visualAttrList[0];		// legend_id
+	visualAttr0.rep_.isPrimaryKey_ = true;
+	visualAttr0.rep_.isAutoNumber_ = false;
+	TeAttribute& visualAttr1 = visualAttrList[1];		// geom_type
+	visualAttr1.rep_.isPrimaryKey_ = true;
+	visualAttr1.rep_.isAutoNumber_ = false;
+
+	TeGeomRepVisualMap::iterator it;
+	for (i = 0; i < legVec.size(); ++i)
+	{
+		TeLegendEntry& leg = legVec[i];
+		for (it = leg.getVisualMap().begin(); it != leg.getVisualMap().end(); ++it)
+		{
+			string style, contourStyle, sizeValue, width;
+			int geomRep = it->first;
+			int legId = leg.id();
+			TeVisual* visual = it->second;
+			TeTableRow row;
+
+			if(geomRep == TePOLYGONS || geomRep == TeCELLS)
+			{
+				sizeValue = Te2String(0);
+				contourStyle = Te2String(visual->contourStyle());
+				width =  Te2String(0);
+				style = Te2String(it->second->style());
+			}
+			else if(geomRep == TeLINES)
+			{
+				sizeValue = Te2String(0);
+				contourStyle = Te2String(0);
+				width = Te2String(visual->width());
+				style = Te2String(visual->style());
+			}
+			else if(geomRep == TePOINTS)
+			{
+				sizeValue = Te2String(visual->size());
+				contourStyle = Te2String(0);
+				width = Te2String(0);
+				style = Te2String(visual->style());
+			}
+			else if(geomRep == TeTEXT)
+			{
+				sizeValue = Te2String(visual->size());
+				contourStyle = Te2String(0);
+				width = Te2String(0);
+				style = Te2String(0);
+			}
+		
+			row.push_back(Te2String(legId));						// legend_id
+			row.push_back(Te2String(geomRep));						// geom_type
+			row.push_back(style);									// symb_id
+			row.push_back(Te2String(visual->color().red_));			// red
+			row.push_back(Te2String(visual->color().green_));		// green
+			row.push_back(Te2String(visual->color().blue_));			// blue
+			row.push_back(Te2String(visual->transparency()));		// transparency
+			row.push_back(width);									// width
+			row.push_back(contourStyle);							// contour_symb_id
+			row.push_back(Te2String(visual->contourColor().red_));	// contour_red
+			row.push_back(Te2String(visual->contourColor().green_));	// contour_green
+			row.push_back(Te2String(visual->contourColor().blue_));	// contour_blue
+			row.push_back(Te2String(visual->contourTransparency()));	// contour_transp
+			row.push_back(Te2String(visual->contourWidth()));		// contour_width
+			row.push_back(sizeValue);								// size_value
+			row.push_back(Te2String(visual->ptAngle()));				// pt_angle
+			row.push_back(visual->family());							// family
+			if (visual->bold())										// bold
+				row.push_back("1");
+			else
+				row.push_back("0");
+			if (visual->italic())									// italic
+				row.push_back("1");
+			else
+				row.push_back("0");
+
+			row.push_back(Te2String(visual->alignmentVert()));		// alignment_vert
+			row.push_back(Te2String(visual->alignmentHoriz()));		// alignment_horiz
+			row.push_back(Te2String(visual->tabSize()));				// tab_size
+			row.push_back(Te2String(visual->lineSpace()));			// line_space
+
+			if (visual->fixedSize())									// fixed_size
+				row.push_back("1");
+			else
+				row.push_back("0");
+
+			visualTable.add(row);
+		}
+	}
+	return insertTable(visualTable);
+}
+
+bool 
+TeDatabase::loadLegend (TeAbstractTheme *theme, const string& visualType)
+{
+	if (!theme)
+		return false;
+	
+	theme->cleanLegend();
+
+	string rest;
+	if (theme->id() > 0)
+		rest = " te_theme.theme_id = "+  Te2String(theme->id());
+	else if (!theme->name().empty())
+		rest = " te_theme.name = '"+  theme->name() + "'";
+	else
+		return false;
+	
+	//load legend and visual
+	string sql = " SELECT ";
+	sql += " te_legend.*,  "; // 0 - 6  (7 columns)
+	sql += " te_visual.*  "; //  7		(24 columns)
+	sql += " FROM ((te_theme LEFT JOIN te_legend ON te_theme.theme_id = te_legend.theme_id ) ";
+	sql += " LEFT JOIN te_visual ON te_legend.legend_id = te_visual.legend_id ) ";
+	sql += " WHERE "+ rest;
+	sql += " ORDER BY te_legend.legend_id, te_legend.group_id, te_visual.geom_type  "; 
+
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+	
+	if (!portal->query(sql) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	//load all legends of this theme
+	//and its visual
+	bool hasLegsToThisTheme = true;
+	bool hasNewRow = true;
+	while(hasLegsToThisTheme)
+	{
+		//legend
+		TeLegendEntry legend;
+		if(!portal->getLegend(legend, 0))
+		{
+			delete portal;
+			return false;
+		}
+
+		//visual
+		bool hasVisualToThisLeg = true;
+		while(hasVisualToThisLeg)
+		{
+			TeVisual* visual = TeVisualFactory::make(visualType);
+			TeGeomRep geomRep;
+			if(portal->getVisual(visual, geomRep, 7))
+				legend.setVisual(visual, geomRep);
+								
+			hasNewRow = portal->fetchRow();
+			if(!hasNewRow || portal->getInt(2)!= legend.group() || portal->getInt(0)!= legend.id())
+				hasVisualToThisLeg = false;
+		}
+
+		//Set legend to this theme
+		theme->legend(legend); 
+														
+		//fill legend buffer
+		if(legend.group() == -6)	
+			metaModel_->legendMap()[legend.id()] = &theme->queryAndPointingLegend();
+		else if(legend.group() == -5)	
+			metaModel_->legendMap()[legend.id()] = &theme->queryLegend(); 
+		else if (legend.group() == -4)
+			metaModel_->legendMap()[legend.id()] = &theme->pointingLegend(); 
+		else if (legend.group() == -3)
+			metaModel_->legendMap()[legend.id()] = &theme->defaultLegend(); 
+		else if (legend.group() == -2)
+			metaModel_->legendMap()[legend.id()] = &theme->withoutDataConnectionLegend(); 
+		else if (legend.group() == -1)
+			metaModel_->legendMap()[legend.id()] = &theme->outOfCollectionLegend(); 
+		else if (legend.group() == -10) //own legend
+		{
+			TeLegendEntry* legendTemp = new TeLegendEntry(legend);
+			metaModel_->legendMap()[legend.id()] = legendTemp;
+		}
+		
+		if(!hasNewRow || portal->getInt(0)!= theme->id())
+			hasLegsToThisTheme = false;
+	}
+			
+	for (unsigned int i = 0; i < theme->legend().size(); ++i)
+		metaModel_->legendMap()[theme->legend()[i].id()] = &theme->legend()[i];
+
+	delete portal;
+	return true;
+}
+
+
+bool 
+TeDatabase::updateProjection (TeProjection *proj)
+{
+	if (proj->id() <= 0)
+		return false;
+	string sql;
+	sql = "UPDATE te_projection SET ";
+	sql += "name='" + proj->name() + "',";
+	sql += " long0=" + Te2String(proj->params().lon0*TeCRD,15)+ ",";
+	sql += " lat0=" + Te2String(proj->params().lat0*TeCRD,15) + ",";
+	sql += " offx=" +Te2String(proj->params().offx,15) + ",";
+	sql += " offy=" +Te2String(proj->params().offy,15) + ",";
+	sql += " stlat1="+ Te2String(proj->params().stlat1*TeCRD,15) + ",";
+	sql += " stlat2=" +Te2String(proj->params().stlat2*TeCRD,15) + ",";
+	sql += " unit='" + proj->params().units + "',";
+	sql += " scale=" + Te2String(proj->params().scale) + ",";
+	sql += " hemis=" + Te2String(proj->params().hemisphere) + ",";
+	sql += " datum='" + proj->datum().name() + "',";
+	sql += " radius=" + Te2String(proj->datum().radius(),15) + ",";
+	sql += " flattening=" + Te2String(proj->datum().flattening(),15) + ",";
+	sql += " dx=" + Te2String(proj->datum().xShift(),15) + ",";
+	sql += " dy=" + Te2String(proj->datum().yShift(),15) + ",";
+	sql += " dz=" + Te2String(proj->datum().zShift(),15) ;
+	sql += " WHERE projection_id = " + Te2String(proj->id());
+	return this->execute(sql);
+}
+
+TeProjection* 
+TeDatabase::loadProjection (int projId)
+{
+	TeDatabasePortal* portal = this->getPortal();
+
+	string sql ="SELECT * FROM te_projection WHERE projection_id = " + Te2String (projId);
+
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return 0;
+	}
+
+	// Look for the projection
+	if (!portal->fetchRow())
+	{
+		delete portal;
+		return 0;
+	}
+
+	TeProjection* proj = 0;
+	if(!portal->getProjection(&proj))
+	{
+		if(proj)
+			delete proj;
+		delete portal;
+		return 0;
+	}
+
+	delete portal;
+	return proj;
+}
+
+bool
+TeDatabase::insertPolygonSet(const string& table, TePolygonSet &ps)
+{
+	if (!beginTransaction())
+		return false;
+	for (unsigned int i = 0; i < ps.size(); i++ )
+	{
+		TePolygon& poly = ps [i];
+		if (!insertPolygon (table,poly))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updatePolygonSet (const string& table, TePolygonSet &ps)
+{
+ 	if (!beginTransaction())
+		return false;
+	for (unsigned int i = 0; i < ps.size(); i++ )
+	{
+		TePolygon& poly = ps [i];
+		if (!updatePolygon (table,poly))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::selectPolygonSet (const string& table, const string& criteria, TePolygonSet &ps)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	string sql ="SELECT * FROM " + table;
+	if (!criteria.empty())
+		sql += " WHERE " + criteria;
+	sql += " ORDER BY object_id ASC, parent_id, num_holes DESC, ext_max ASC";
+	 
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return false;
+	}
+	if (!portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+		ps.add(poly);
+	}
+	while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::loadPointSet(TeTheme* theme, TePointSet &ps)
+{
+	string collTable = theme->collectionTable();
+	if (collTable.empty())
+		return false;
+
+	TeLayer* themeLayer = theme->layer();
+	if (!themeLayer->hasGeometry(TePOINTS))
+		return false;
+	
+	string pointTable = themeLayer->tableName(TePOINTS);
+	if (pointTable.empty())
+		return false;
+
+	string sql = "SELECT * FROM (" + pointTable + " RIGHT JOIN " + collTable;
+	sql = sql + " ON " + pointTable + ".object_id = " + collTable + ".object_id)";
+
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	if (!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	bool flag = true;
+	do {
+		TePoint pt;
+		flag =  portal->fetchGeometry(pt);
+		ps.add(pt);
+	}
+	while (flag);
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::loadLineSet(TeTheme* theme, TeLineSet &ls)
+{
+	string collTable = theme->collectionTable();
+	if (collTable.empty())
+		return false;
+
+	TeLayer* themeLayer = theme->layer();
+	if (!themeLayer->hasGeometry(TeLINES))
+		return false;
+	
+	string lineTable = themeLayer->tableName(TeLINES);
+	if (lineTable.empty())
+		return false;
+
+	string sql = "SELECT * FROM (" + lineTable + " RIGHT JOIN " + collTable;
+	sql = sql + " ON " + lineTable + ".object_id = " + collTable + ".object_id)";
+
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	if (!portal->query(sql)  || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	bool flag;
+	do 
+	{
+		TeLine2D lin;
+		flag = portal->fetchGeometry(lin);
+		ls.add(lin);
+	}while(flag);
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::loadPolygonSet (const string& table, const string& geoid, TePolygonSet &ps)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+
+	if (!geoid.empty())
+		q += " WHERE object_id = '" + geoid +"'";
+	q += " ORDER BY parent_id, num_holes DESC, ext_max ASC";
+
+	if (!portal->query(q))
+	{	
+		delete portal;
+		return false;
+	}
+
+	if (!portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+		ps.add(poly);
+	}
+	while (flag);
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::loadPolygonSet (const string& table, TeBox &bb, TePolygonSet &polSet)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE ";
+	q += this->getSQLBoxWhere (bb, TePOLYGONS);
+	q += " ORDER BY parent_id, num_holes DESC, ext_max ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+		polSet.add(poly);
+	}
+	while (flag);
+	delete portal;
+	return true;
+}
+
+TeDatabasePortal* 
+TeDatabase::loadPolygonSet(const string& table, TeBox &box)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return 0;
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE ";
+	q += this->getSQLBoxWhere (box, TePOLYGONS);
+	q += " ORDER BY parent_id, num_holes DESC, ext_max ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return 0;
+	}
+	else 
+		return portal;
+}
+
+
+bool 
+TeDatabase::locatePolygon (const string& table, TeCoord2D &pt, TePolygon &polygon, const double& tol)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE lower_x < " + Te2String(box.x2(),15);
+	q += " AND upper_x > " + Te2String(box.x1(),15);
+	q += " AND lower_y < " + Te2String(box.y2(),15);
+	q += " AND upper_y > " + Te2String(box.y1(),15);
+	q += " ORDER BY parent_id, num_holes DESC, ext_max ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+		if (TeWithin (TePoint(pt), poly))
+		{
+			polygon = poly;
+			delete portal;
+			return true;
+		}
+	}
+	while (flag);
+	delete portal;
+	return false;
+}
+
+
+bool 
+TeDatabase::locatePolygonSet (const string& table, TeCoord2D &pt, double tol, TePolygonSet &polygons)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE lower_x < " + Te2String(box.x2(),6);
+	q += " AND upper_x > " + Te2String(box.x1(),6);
+	q += " AND lower_y < " + Te2String(box.y2(),6);
+	q += " AND upper_y > " + Te2String(box.y1(),6);
+	q += " ORDER BY parent_id, num_holes DESC, ext_max ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	bool flag = true;
+	polygons.clear();
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+		if (TeWithin (TePoint(pt), poly))
+			polygons.add(poly);
+	}
+	while (flag);
+	delete portal;
+
+	if(polygons.size())
+		return (true);
+	return false;
+}
+
+bool 
+TeDatabase::loadPolygonSet(TeTheme* theme, TePolygonSet &ps)
+{
+	string collTable = theme->collectionTable();
+	if (collTable.empty())
+		return false;
+
+	TeLayer* themeLayer = theme->layer();
+	if (!themeLayer->hasGeometry(TePOLYGONS))
+		return false;
+	
+	string polygonTable = themeLayer->tableName(TePOLYGONS);
+	if (polygonTable.empty())
+		return false;
+
+	string sql = "SELECT * FROM (" + polygonTable + " RIGHT JOIN " + collTable;
+	sql = sql + " ON " + polygonTable + ".object_id = " + collTable + ".object_id)";
+	sql += " ORDER BY " + polygonTable + ".parent_id, ";
+	sql += polygonTable + ".num_holes DESC, " + polygonTable + ".ext_max ASC";
+
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	if (!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+		ps.add ( poly );
+	}
+	while (flag);		
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::insertLineSet	(const string& table, TeLineSet &ls)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < ls.size(); i++ )
+	{
+		TeLine2D& line = ls [i];
+		if (!insertLine (table,line))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updateLineSet	(const string& table, TeLineSet &ls)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < ls.size(); i++ )
+	{
+		TeLine2D line = ls [i];
+		if (!updateLine (table,line))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::loadLineSet (const string& table, const string& geoid, TeLineSet &ls)
+{
+	TeDatabasePortal *portal = this->getPortal();
+
+	string q ="SELECT * FROM " + table;
+
+	if (!geoid.empty())
+		q += " WHERE object_id = '" + geoid +"'";
+
+	q += " ORDER BY ext_max DESC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	bool flag = true;
+	do 
+	{
+		TeLine2D line;
+		flag = portal->fetchGeometry(line);
+		ls.add ( line );
+	}while(flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::loadLineSet (const string& table, TeBox &bb, TeLineSet &linSet)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE ";
+	q += this->getSQLBoxWhere (bb, TeLINES);
+	q += " ORDER BY ext_max DESC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	bool flag = true;
+	do
+	{
+		TeLine2D lin;
+		flag = portal->fetchGeometry(lin);
+		linSet.add(lin);
+	}
+	while (flag);
+	delete portal;
+	return true;
+}
+
+TeDatabasePortal* 
+TeDatabase::loadLineSet (const string& table, TeBox &box)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return 0;
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE ";
+	q += this->getSQLBoxWhere (box, TeLINES);
+	q += " ORDER BY ext_max DESC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return 0;
+	}
+	return portal;
+}
+
+bool 
+TeDatabase::selectLineSet (const string& table, const string& criteria, TeLineSet &ls)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+	if (!criteria.empty())
+		q += " WHERE " + criteria;
+	q += " ORDER BY object_id ASC, geom_id ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	bool flag = true;
+	do 
+	{
+		TeLine2D line;
+		flag = portal->fetchGeometry(line);
+		ls.add ( line );
+	}while(flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::locateLine (const string& table, TeCoord2D &pt, TeLine2D &line, const double& tol)
+{
+	TeDatabasePortal* portal = this->getPortal();
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE lower_x < %f AND upper_x > %f AND lower_y < %f AND upper_y > %f",
+		box.x2(),box.x1(),box.y2(),box.y1());
+	q += buf;
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	// Get all lines
+	TeLineSet ls;
+	int k;
+	bool flag = true;
+	do 
+	{
+		TeLine2D l;
+		flag = portal->fetchGeometry( l );
+		ls.add ( l );
+	} while (flag);
+
+	delete portal;
+
+	TeCoord2D paux;
+
+	if (TeNearest (pt, ls, k, paux, tol))
+	{
+		line = ls[k];
+		return true;
+	}
+	return false;
+}
+
+bool 
+TeDatabase::insertPointSet	(const string& table, TePointSet &ps)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < ps.size(); i++ )
+	{
+		TePoint& point = ps [i];
+		if (!insertPoint (table,point))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updatePointSet (const string& table, TePointSet &ps)
+{
+	if (!beginTransaction())
+		return false;
+	
+	for (unsigned int i = 0; i < ps.size(); i++ )
+	{
+		TePoint point = ps [i];
+		if (!updatePoint (table,point))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::loadPointSet (const string& table, const string& geoid, TePointSet &ps)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+
+	if (!geoid.empty())
+		q += " WHERE object_id = '" + geoid +"'";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	do 
+	{
+		TePoint point;
+		flag = portal->fetchGeometry (point);
+		ps.add ( point );
+	}while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::loadPointSet (const string& table, TeBox &bb, TePointSet &ps)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE ";
+	q += this->getSQLBoxWhere (bb, TePOINTS);
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+	bool flag = true;
+	do
+	{
+		TePoint pt;
+		flag = portal->fetchGeometry(pt);
+		ps.add(pt);
+	}
+	while (flag);
+	delete portal;
+	return true;
+}
+
+TeDatabasePortal* 
+TeDatabase::loadPointSet(const string& table, TeBox &box)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	if (!portal)
+		return 0;
+
+	string q;
+	q = "SELECT * FROM " + table + " WHERE ";
+	q += this->getSQLBoxWhere (box, TePOINTS);
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{	
+		delete portal;
+		return 0;
+	}
+	return portal;
+}
+
+bool 
+TeDatabase::selectPointSet (const string& table, const string& criteria, TePointSet &ps)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+	if (!criteria.empty())
+		q += " WHERE " + criteria;
+	q += " ORDER BY object_id ASC, geom_id ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	do 
+	{
+		TePoint point;
+		flag = portal->fetchGeometry (point);
+		ps.add ( point );
+	}while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::locatePoint (const string& table, TeCoord2D &pt, TePoint &point, const double& tol)
+{
+	TeDatabasePortal* portal = this->getPortal();
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE x < %f AND x > %f AND y < %f AND y > %f",
+		box.x2(),box.x1(),box.y2(),box.y1());
+	q += buf;
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	TePointSet ps;
+	bool flag = true;
+	do 
+	{
+		TePoint point;
+		flag = portal->fetchGeometry (point);
+		ps.add ( point );
+	}while (flag);
+
+	delete portal;
+	int k;
+	if (TeNearest (pt, ps, k, tol))
+	{
+		point = ps[k];
+		return true;
+	}
+	return false;
+}
+
+bool 
+TeDatabase::insertTextSet	(const string& table, TeTextSet &ts)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < ts.size(); i++ )
+	{
+		TeText& text = ts [i];
+		if (!insertText (table,text))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updateTextSet	(const string& table, TeTextSet &ts)
+{
+	if (!beginTransaction())
+		return false;
+	for ( unsigned int i = 0; i < ts.size(); i++ )
+	{
+		TeText text = ts [i];
+		if (!updateText (table,text))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::loadTextSet (const string& table, const string& geoid, TeTextSet &ts)
+{
+	TeDatabasePortal *portal = this->getPortal();
+	
+	string q ="SELECT * FROM " + table;
+	if (!geoid.empty())
+		q += " WHERE object_id = '" + geoid +"'";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	// Look for all texts
+	bool flag  = true;
+	do
+	{
+		TeText p;
+		flag = portal->fetchGeometry(p);
+		ts.add ( p );
+	} while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::selectTextSet (const string& table, const string& criteria, TeTextSet &ts)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+	if (!criteria.empty())
+		q += " WHERE " + criteria;
+	q += " ORDER BY object_id ASC, geom_id ASC";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	// Look for all texts
+	bool flag = true;
+	do
+	{
+		TeText p;
+		flag = portal->fetchGeometry(p);
+		ts.add ( p );
+	} while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::updateText(const string& table, TeText &t)
+{
+	string sql;
+	sql = "UPDATE " + table + " SET ";
+    sql += "x=" + Te2String(t.location().x(),15) + ", ";
+	sql += "y=" + Te2String(t.location().y(),15) + ", ";
+	sql += "text_value='" + t.textValue() + "', ";
+	sql += "angle=" + Te2String(t.angle(),15) + ", ";
+	sql += "height=" + Te2String(t.height(),15) + ",";
+	sql += "alignment_vert=" + Te2String(t.alignmentVert(),15) + ",";
+	sql += "alignment_horiz=" + Te2String(t.alignmentHoriz(),15);
+    sql += " WHERE geom_id=" + Te2String(t.geomId());
+	return (this->execute(sql));
+}
+
+bool 
+TeDatabase::updateNode(const string& table, TeNode &node)
+{
+	string sql;
+	sql = "UPDATE " + table + " SET ";
+    sql += "x=" + Te2String(node.location().x(),15) + ", ";
+	sql += "y=" + Te2String(node.location().y(),15);
+    sql += " WHERE geom_id = " + Te2String(node.geomId());
+	return (this->execute(sql));
+}
+
+bool 
+TeDatabase::updatePoint(const string& table, TePoint &p)
+{
+	string sql;
+	sql = "UPDATE " + table + " SET ";
+    sql += "x=" + Te2String(p.location().x(),15) + ", ";
+	sql += "y=" + Te2String(p.location().y(),15);
+    sql += " WHERE geom_id = " + Te2String(p.geomId());
+	return (this->execute(sql));
+}
+
+bool TeDatabase::locateText (const string& table, TeCoord2D &pt, TeText &text, const double& tol)
+{
+	TeDatabasePortal* portal = this->getPortal();
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE x < %f AND x > %f AND y < %f AND y > %f",
+		box.x2(),box.x1(),box.y2(),box.y1());
+	q += buf;
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	// Look for all texts
+	bool flag = true;
+	TeTextSet ts;
+	do
+	{
+		TeText p;
+		flag = portal->fetchGeometry(p);
+		ts.add ( p );
+	} while (flag);
+
+	delete portal;
+
+	int k;
+	if (TeNearest (pt, ts, k, tol))
+	{
+		text = ts[k];
+		return true;
+	}
+	return false;
+}
+
+bool 
+TeDatabase::insertArcSet	(const string& table, TeArcSet &as)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < as.size(); i++ )
+	{
+		TeArc& arc = as [i];
+		if (!insertArc (table,arc))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updateArcSet	(const string& table, TeArcSet &as)
+{
+	if (!beginTransaction())
+		return false;
+
+	for ( unsigned int i = 0; i < as.size(); i++ )
+	{
+		TeArc arc = as [i];
+		if (!updateArc (table,arc))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::loadArcSet (const string& table, const string& geoid, TeArcSet &as)
+{
+
+	TeDatabasePortal* portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+	if (!geoid.empty())
+		q += " WHERE object_id = " + geoid;
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	// Look for all nodes
+	bool flag;
+	do 
+	{
+		TeArc arc;
+		flag = portal->fetchGeometry(arc);
+		as.add (arc);
+	} while (flag);
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::updateArc(const string& table, TeArc &arc)
+{
+	string sql;
+	sql = "UPDATE"+ table +" SET ";
+    sql += "from_node=" + Te2String(arc.fromNode().geomId()) + ", ";
+	sql += "to_node=" + Te2String(arc.toNode().geomId());
+    sql += " WHERE geom_id = " + arc.geomId();
+	return (this->execute(sql));
+}
+
+bool 
+TeDatabase::insertNodeSet	(const string& table, TeNodeSet &ns)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < ns.size(); i++ )
+	{
+	     TeNode& no = ns [i];
+	     if (!insertNode (table,no))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::updateNodeSet	(const string& table, TeNodeSet &ns)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < ns.size(); i++ )
+	{
+		TeNode no = ns [i];
+		if (!updateNode (table,no))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::loadNodeSet (const string& table, const string& geoid, TeNodeSet &ns)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+	if (!geoid.empty())
+		q += " WHERE object_id = " + geoid;
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	bool flag = true;
+	do 
+	{
+		TeNode n;
+		flag = portal->fetchGeometry(n);
+		ns.add ( n );
+	}while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::insertCellSet	(const string& table, TeCellSet &cs)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < cs.size(); i++ )
+	{
+		TeCell& cell = cs [i];
+		if (!insertCell (table,cell))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool
+TeDatabase::updateCellSet	(const string& table, TeCellSet &cs)
+{
+	if (!beginTransaction())
+		return false;
+
+	for (unsigned int i = 0; i < cs.size(); i++ )
+	{
+		TeCell cell = cs [i];
+		if (!updateCell (table,cell))
+		{
+			rollbackTransaction();
+			return false;
+		}
+	}
+	if (!commitTransaction())
+	{
+		rollbackTransaction();
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::loadCellSet (const int& layerId, const string& table, const string& geoid, TeCellSet &cs)
+{
+
+	TeDatabasePortal *portal = this->getPortal();
+
+	// Get the cell set resolution
+	string q  = "SELECT * FROM te_representation WHERE layer_id = " + Te2String(layerId);
+	q += " AND geom_type = " + Te2String(TeCELLS);
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	cs.resX(portal->getDouble("res_x"));
+	cs.resY(portal->getDouble("res_y"));
+	
+	portal->freeResult();
+		
+	q = "SELECT * FROM " + table;
+	if (!geoid.empty())
+		q += " WHERE object_id = '" + geoid +"'";
+	q += " ";
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	bool flag;
+	do 
+	{
+		TeCell cell;
+		flag = portal->fetchGeometry(cell);
+		cs.add ( cell );
+	} while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::selectCellSet (const int& layerId, const string& table, const string& criteria, TeCellSet &cs)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	string q = "SELECT * FROM te_representation WHERE layer_id = " ;
+	q += Te2String(layerId) + " AND geom_type = " + Te2String(TeCELLS);
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	cs.resX(portal->getDouble("res_x"));
+	cs.resY(portal->getDouble("res_y"));
+	portal->freeResult();
+	
+	q ="SELECT * FROM " + table;
+	if (!criteria.empty())
+		q += " WHERE " + criteria;
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	bool flag;
+	do 
+	{
+		TeCell cell;
+		flag = portal->fetchGeometry(cell);
+		cs.add ( cell );
+	} while (flag);
+
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::updateCell(const string& table, TeCell &c)
+{
+	TeBox b = c.box();
+
+	string sql;
+	sql = "UPDATE "+ table +"  SET ";
+	sql += "lower_x=" + Te2String(b.lowerLeft().x(),15) + ", ";
+	sql += "lower_y=" + Te2String(b.lowerLeft().y(),15) + ", ";
+	sql += "upper_x=" + Te2String(b.upperRight().x(),15) + ", ";
+	sql += "upper_y=" + Te2String(b.upperRight().y(),15) + ", ";
+	sql += "col_number=" + Te2String(c.column()) + ", ";
+	sql += "row_number=" + Te2String(c.line());
+	sql += " WHERE geom_id = " + c.geomId();
+	return (this->execute(sql));
+}
+
+bool 
+TeDatabase::locateCell (const string& table, TeCoord2D &pt, TeCell &cell, const double& /* tol */)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE lower_x < %f AND upper_x > %f AND lower_y < %f AND upper_y > %f",
+		pt.x(),pt.x(),pt.y(),pt.y());
+	q += buf;
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	portal->fetchGeometry(cell);
+	delete portal;
+	return true;
+}
+
+bool
+TeDatabase::inClauseValues(const string& query, const string& /* attribute */, vector<string>& inClauseVector)
+{
+	inClauseVector.push_back( "(" + query + ")" );
+	return true;
+}
+
+//Spatial query
+//retornam um portal
+
+bool 
+TeDatabase::spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeDatabasePortal *portal, int relate, const string& actCollTable)
+{
+	return (TeTopologicalRelation(actGeomTable, actRep, actIdsIn, portal, relate, actCollTable));
+}
+
+bool 
+TeDatabase::spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, const string& visGeomTable, TeGeomRep visRep, TeDatabasePortal *portal, int relate, const string& visCollTable)
+{
+	return (TeTopologicalRelation(actGeomTable, actRep, actIdsIn, visGeomTable, visRep, portal, relate, visCollTable));
+}
+
+bool 
+TeDatabase::spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, TeDatabasePortal *portal, int relate, const string& actCollTable)
+{
+	return (TeTopologicalRelation(actGeomTable, actRep, geom, portal, relate, actCollTable));
+}
+
+//retornam um vetor de object_ids resultantes da consulta
+bool 
+TeDatabase::spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeKeys& actIdsOut, int relate, const string& actCollTable)
+{
+	return (TeTopologicalRelation(actGeomTable, actRep, actIdsIn, actIdsOut, this, relate, actCollTable));
+}
+
+bool 
+TeDatabase::spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, const string& visGeomTable, TeGeomRep visRep, TeKeys& visIdsOut, int relate, const string& visCollTable, TeDatabase* dbVis)
+{
+	return (TeTopologicalRelation(actGeomTable, actRep, actIdsIn, visGeomTable, visRep, visIdsOut, this, relate, visCollTable, dbVis));
+}
+
+bool 
+TeDatabase::spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, TeKeys& actIdsOut, int relate, const string& actCollTable)
+{
+	return (TeTopologicalRelation(actGeomTable, actRep, geom, actIdsOut, this, relate, actCollTable));
+}
+
+//metric functions
+bool
+TeDatabase::calculateArea(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, double &area)
+{
+	return (TeGetArea(actGeomTable, actRep, actIdsIn, this, area));
+}
+
+bool 
+TeDatabase::calculateLength(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn , double& length )
+{
+	return (TeGetLength(actGeomTable, actRep, actIdsIn, this, length));
+}
+
+bool 
+TeDatabase::calculateDistance(const string& actGeomTable, TeGeomRep actRep, TeKeys& Ids, double& distance)
+{
+	return (TeGetDistance(actGeomTable, actRep, Ids, this, distance));
+}
+
+bool 
+TeDatabase::calculateDistance(const string& /* actGeomTable */, TeGeomRep /*actRep */, const string& /* objId1 */, const string& /* visGeomTable */, TeGeomRep /* visRep */, const string& /* objId2 */, double& /* distance */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::withinDistance(const string& actGeomTable, TeGeomRep actRep, const TeCoord2D& coord, TeKeysToDist& IdsDistOut, const double& max_distance, const string& actCollTable)
+{
+	return (TeGetWithinDistance(actGeomTable, actRep, coord, IdsDistOut, this, max_distance, actCollTable));
+}
+
+// functions that generate new geometry
+bool 
+TeDatabase::buffer(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TePolygonSet& bufferSet, double dist)
+{
+	return (TeGetBuffer(actGeomTable, actRep, actIds, this, bufferSet, dist));
+}
+
+bool 
+TeDatabase::centroid(const string&  actGeomTable , TeGeomRep actRep, TePointSet& centroidSet, TeKeys actIds, const string& actCollTable)
+{
+	return (TeGetCentroid(actGeomTable, actRep, this, centroidSet, actIds, actCollTable));
+}
+
+bool 
+TeDatabase::convexHull(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TePolygonSet& convexHullSet)
+{
+	return (TeGetConvexHull(actGeomTable, actRep, actIds, this, convexHullSet));
+}
+
+bool 
+TeDatabase::nearestNeighbors(const string& /* actGeomTable */, const string& /* actCollTable */, TeGeomRep /* actRep */, const string& /* objId1 */, TeKeys& /* actIdsOut */, int /* numRes */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::nearestNeighbors(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* visGeomTable */, const string& /* visCollTable */, TeGeomRep /* visRep */, TeKeys& /* visIdsOut */, int /* numRes */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::nearestNeighbors(const string& /* actGeomTable */, const string& /* actCollTable */, TeGeomRep /* actRep */, const string& /* objId1 */, TeDatabasePortal* /* portal */, int /* numRes */)
+{
+	return false;
+}
+	
+bool 
+TeDatabase::nearestNeighbors(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* visGeomTable */, const string& /* visCollTable */, TeGeomRep /* visRep */, TeDatabasePortal* /* portal */, int /* numRes */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::geomIntersection(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeGeometryVect& geomVect)
+{
+	return (TeGetOverlay(actGeomTable, actRep, actIds, this, geomVect, TeINTERSECTION));
+}
+	
+bool 
+TeDatabase::geomIntersection(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* visGeomTable */, TeGeomRep /* visRep */, const string& /* objId2 */, TeGeometryVect& /* geomVect */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::geomDifference(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& objId2, TeGeometryVect& geomVect)
+{
+	TeKeys actIds;
+	actIds.push_back(objId1);
+	actIds.push_back(objId2);
+
+	return (TeGetOverlay(actGeomTable, actRep, actIds, this, geomVect, TeDIFFERENCE));
+
+}
+
+bool 
+TeDatabase::geomDifference(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* visGeomTable */, TeGeomRep /* visRep */, const string& /* objId2 */, TeGeometryVect& /* geomVect */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::geomUnion(const string&  actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeGeometryVect& geomVect)
+{
+    return (TeGetOverlay(actGeomTable, actRep, actIds, this, geomVect, TeUNION));
+}
+
+bool 
+TeDatabase::geomUnion(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* visGeomTable */, TeGeomRep /* visRep */, const string& /* objId2 */, TeGeometryVect& /* geomVect */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::geomXOr(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* objId2 */, TeGeometryVect& /* geomVect */)
+{
+	return false;
+}
+
+bool 
+TeDatabase::geomXOr(const string& /* actGeomTable */, TeGeomRep /* actRep */, const string& /* objId1 */, const string& /* visGeomTable */, TeGeomRep /* visRep */, const string& /* objId2 */, TeGeometryVect& /* geomVect */)
+{
+	return false;
+}
+
+// Operation with Image
+
+bool 
+TeDatabase::zonal(const string& rasterTable, const string& actGeomTable, TeKeys& Ids, TeObjectStatistics& result)
+{
+	TeDatabasePortal* portal=getPortal();
+	if (!portal)
+		return false;
+	
+	//recuperar o raster!!!
+	string sql = "SELECT layer_id FROM te_representation";
+	sql += " WHERE geom_table = '" + rasterTable +"'";
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	int layerId = atoi(portal->getData(0));
+	TeRaster* raster = loadLayerRaster(layerId);
+
+	//recuperar as geometrias
+	portal->freeResult();
+	
+	string objIds = getStringIds(Ids);
+	sql = "SELECT * FROM "+ actGeomTable;
+	sql+= " WHERE object_id IN ("+ objIds +")";
+
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+
+		TeStatisticsDimensionVect st;
+
+		TeRaster::iteratorPoly itBegin = raster->begin(poly, TeBoxPixelIn);
+		TeRaster::iteratorPoly itEnd = raster->end(poly, TeBoxPixelIn);
+	
+		if(!TeCalculateStatistics (itBegin, itEnd, st))
+		{
+			delete portal;
+			return false;
+		}
+	
+		result[poly.objectId()] = st;
+
+	}while (flag);
+
+	
+	delete raster;
+	delete portal;
+	return true;
+}
+	
+bool 
+TeDatabase::zonal(const string& rasterTable, const string& actGeomTable, const string& actCollTable, TeObjectStatistics& result)
+{
+	TeDatabasePortal* portal=getPortal();
+	if (!portal)
+		return false;
+	
+	//recuperar o raster
+	string sql = "SELECT layer_id FROM te_representation";
+	sql += " WHERE geom_table = '" + rasterTable +"'";
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	int layerId = atoi(portal->getData(0));
+	TeRaster* raster = loadLayerRaster(layerId);
+
+	//recuperar as geometrias
+	portal->freeResult();
+	
+	sql = "SELECT * FROM "+ actGeomTable;
+
+	if(!actCollTable.empty())
+	{
+		sql += " ,"+ actCollTable;
+		sql += " WHERE object_id = c_object_id ";
+	}
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	do
+	{
+		TePolygon poly;
+		flag = portal->fetchGeometry(poly);
+
+		TeStatisticsDimensionVect st;
+		
+		TeRaster::iteratorPoly itBegin = raster->begin(poly, TeBoxPixelIn);
+		TeRaster::iteratorPoly itEnd = raster->end(poly, TeBoxPixelIn);
+	
+		if(!TeCalculateStatistics (itBegin, itEnd, st))
+		{
+			delete portal;
+			return false;
+		}
+		result[poly.objectId()] = st;
+
+	}while (flag);
+
+	
+	delete raster;
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::zonal(const string& rasterTable, TePolygon& poly, TeStatisticsDimensionVect& result)
+{
+	TeDatabasePortal* portal=getPortal();
+	if (!portal)
+		return false;
+	
+	//recuperar o raster!!!
+	string sql = "SELECT layer_id FROM te_representation";
+	sql += " WHERE geom_table = '" + rasterTable +"'";
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	int layerId = atoi(portal->getData(0));
+	TeRaster* raster = loadLayerRaster(layerId);
+
+	delete portal;
+
+	TeRaster::iteratorPoly itBegin = raster->begin(poly, TeBoxPixelIn);
+	TeRaster::iteratorPoly itEnd = raster->end(poly, TeBoxPixelIn);
+	
+	if(!TeCalculateStatistics (itBegin, itEnd, result))
+		return false;
+
+	delete raster;
+	return true;
+}
+
+
+bool 
+TeDatabase::mask(const string& rasterTable, const string& actGeomTable, const string& objId, const string& nameLayerOut, TeStrategicIterator st)
+{
+	TeDatabasePortal* portal=getPortal();
+	if (!portal)
+		return false;
+	
+	//recuperar o raster!!!
+	string sql = "SELECT layer_id FROM te_representation";
+	sql += " WHERE geom_table = '" + rasterTable +"'";
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	int layerId = atoi(portal->getData(0));
+	TeRaster* raster = loadLayerRaster(layerId);
+
+	//recuperar a geometria
+	portal->freeResult();
+	
+	sql = "SELECT * FROM "+ actGeomTable;
+	sql+= " WHERE object_id = '" + objId + "'"; 
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	TePolygon poly;
+	portal->fetchGeometry(poly);
+	delete portal;
+
+	TeRaster* rasterOut = TeMask (raster, poly, st);
+	if(!rasterOut)
+		return false;
+
+	TeLayer* res = TeImportRaster(nameLayerOut, rasterOut, this);
+	delete raster;
+	delete rasterOut;
+	return (res != 0);
+}
+
+
+
+bool
+TeDatabase::mask(const string& rasterTable, TePolygon& poly, const string& nameLayerOut, TeStrategicIterator st)
+{
+	TeDatabasePortal* portal=getPortal();
+	if (!portal)
+		return false;
+	
+	string sql = "SELECT layer_id FROM te_representation";
+	sql += " WHERE geom_table = '" + rasterTable +"'";
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	TeRaster* raster = loadLayerRaster(atoi(portal->getData(0)));
+	delete portal;
+
+	TeRaster* rasterOut = TeMask (raster, poly, st);
+	if(!rasterOut)
+		return false;
+
+	TeLayer* res = TeImportRaster(nameLayerOut, rasterOut, this);
+	delete raster;
+	delete rasterOut;
+	return (res != 0);
+}
+
+
+string
+TeDatabase::getSQLBoxWhere (TeBox &box, TeGeomRep rep)
+{
+	string wherebox;
+	string lowerX, lowerY, upperX, upperY;
+	if(rep == TePOLYGONS || rep == TeLINES || rep == TeCELLS || rep == TeRASTER || rep == TeRASTERFILE)
+	{
+		lowerX = "lower_x";
+		lowerY = "lower_y";
+		upperX = "upper_x";
+		upperY = "upper_y";
+	}
+	else if(rep == TePOINTS || rep == TeTEXT)
+	{
+		lowerX = "x";
+		lowerY = "y";
+		upperX = "x";
+		upperY = "y";
+	}
+	wherebox = "NOT("+ lowerX +" > " + Te2String(box.x2_, 12) + " OR ";
+	wherebox += upperX +" < " + Te2String(box.x1_, 12) + " OR ";
+	wherebox += lowerY +" > " + Te2String(box.y2_, 12) + " OR ";
+	wherebox += upperY +" < " + Te2String(box.y1_, 12) + ")";
+	return wherebox;
+}
+
+
+string 
+TeDatabase::getSQLBoxWhere (const string& table1, const string& table2, TeGeomRep rep2, TeGeomRep /* rep1 */)
+{
+	string wherebox;
+
+	if(rep2 == TePOLYGONS || rep2 == TeLINES || rep2 == TeCELLS || rep2 == TeRASTER || rep2 == TeRASTERFILE)
+	{
+		wherebox = " NOT( ";
+		wherebox += table2 +".lower_x > "+ table1 +".upper_x  OR ";
+		wherebox += table2 +".upper_x < "+ table1 +".lower_x  OR ";
+		wherebox += table2 +".lower_y > "+ table1 +".upper_y  OR ";
+		wherebox += table2 +".upper_y < "+ table1 +".lower_y )";
+	}
+	else if(rep2 == TePOINTS || rep2 == TeTEXT)
+	{
+		wherebox = " NOT( ";
+		wherebox += table2 +".x > "+ table1 +".upper_x  OR ";
+		wherebox += table2 +".x < "+ table1 +".lower_x  OR ";
+		wherebox += table2 +".y > "+ table1 +".upper_y  OR ";
+		wherebox += table2 +".y < "+ table1 +".lower_y )";
+	}
+	
+	return wherebox;
+}
+
+
+string 
+TeDatabase::getSQLBoxSelect (const string& tableName, TeGeomRep /* rep */)
+{
+	string sql = tableName +".* ";
+	return sql;
+}
+
+
+string
+TeDatabase::getSQLStatistics (TeGroupingAttr& attrs)
+{
+	string sql = "";
+	string virg = "";
+
+	TeGroupingAttr::iterator it = attrs.begin();
+	int count = 0;
+	while(it != attrs.end())
+	{
+		if(count>0)
+			virg = ",";
+
+		switch ((*it).second)
+		{
+			case TeSUM:
+				sql += virg +" SUM( "+ (*it).first.name_ +") AS SUM_"+ Te2String(count);
+				(*it).second = TeNOSTATISTIC;
+				++count;
+				break;
+			case TeMAXVALUE:
+				sql += virg +" MAX( "+ (*it).first.name_ +") AS MAX_"+ Te2String(count);
+				(*it).second = TeNOSTATISTIC; 
+				++count;
+				break;
+			case TeMINVALUE:
+				sql += virg +" MIN( "+ (*it).first.name_ +") AS MIN_"+ Te2String(count);
+				(*it).second = TeNOSTATISTIC;
+				++count;
+				break;
+			case TeCOUNT:
+				sql += virg +" COUNT( "+ (*it).first.name_ +") AS COUNT_"+ Te2String(count);
+				(*it).second = TeNOSTATISTIC;
+				++count;
+				break;
+			case TeMEAN:
+				sql += virg +" AVG( "+ (*it).first.name_ +") AS AVG_"+ Te2String(count);
+				(*it).second = TeNOSTATISTIC;
+				++count;
+				break;
+			default:
+				break;
+		}
+		++it;
+	}
+	return sql;
+}
+
+string 
+TeDatabase::getSQLAutoNumber(const string& /* table */)
+{
+	return "";
+}
+
+string 
+TeDatabase::getSQLTemporalWhere (TeTimeInterval& timeInterval, TeTemporalRelation timeOperator, const string& initialTime, const string& finalTime)
+{
+	string sql;
+	string t1 = getSQLTime(timeInterval.getT1()); 
+	string t2 = getSQLTime(timeInterval.getT2());
+	
+	switch(timeOperator)
+	{
+		case TeTIMEBEFORE:  
+			sql = finalTime +" < "+ t1;
+			break;
+		case TeTIMEAFTER:  
+			sql = initialTime +" > "+ t2;
+			break;
+		case TeTIMEEQUAL:             
+			sql = "( "+ initialTime +" >= "+ t1;
+			sql += " AND "+ initialTime +" <= "+ t2 +" )";
+			if (initialTime != finalTime)
+			{
+				sql += " AND ";
+				sql += "( "+ finalTime +" >= "+ t1;
+				sql += " AND "+ finalTime +" <= "+ t2 +" )";
+			}
+			break;
+
+		case TeTIMEMEETS:             
+			sql = finalTime +" = "+ t1;
+			sql += " OR "+ initialTime +" = "+ t2;
+			break;
+
+		case TeTIMEDURING: 
+			sql = initialTime +" >= "+ t1;
+			sql += " AND "+ initialTime +" <= "+ t2;
+			if (initialTime != finalTime)
+			{
+				sql += " AND "+ finalTime +" >= "+ t1;
+				sql += " AND "+ finalTime +" <= "+ t2;
+			}
+			break;
+
+		case TeTIMEOVERLAPS:             
+			sql = "( "+ initialTime +" < "+ t1;
+			sql += " AND "+ finalTime +" > "+ t1;
+			sql += " AND "+ finalTime +" < "+ t2 +" )";
+			sql += " OR ";
+			sql += "( "+ initialTime +" > "+ t1;
+			sql += " AND "+ initialTime +" < "+ t2;
+			sql += " AND "+ finalTime +" > "+ t2 +" )";
+			break;
+
+		case TeTIMEENDS:
+			sql = finalTime +" = "+ t2;
+			break;
+
+		case TeTIMESTARTS:
+			sql = initialTime +" = "+ t1;
+			break;
+
+        default:
+            break;
+	}
+
+	return sql; 
+}
+
+string
+TeDatabase::getSQLTemporalWhere(int time1, int time2, TeChronon chr, TeTemporalRelation rel, 
+						   const string& initialTime, const string& finalTime)
+{
+	//rever os chronons definidos - alterar o parser para restri��o temporal
+	string func, sql;
+	switch(chr)
+	{
+		case TeSECONDOFMINUTE:  
+		   func = " second"; 
+		break;
+		
+		case TeMINUTEOFHOUR:  
+		   func = " minute";
+		break;
+		
+		case TeHOUROFDAY:             
+			func = " hour";
+		break;
+		
+		case TeDAYOFMONTH:             
+			func = " day";
+		break;
+
+		case TeDAYOFWEEK:
+			func = " weekday";
+		break;
+		
+		case TeMONTHOFYEAR:
+		   func = " month";
+		break;
+
+		case TeYEAR:             
+		   func = " year";
+		break;
+
+		default:
+			return "";
+	}
+
+	switch(rel)
+	{
+		case TeTIMEBEFORE:  
+			sql = func +"("+ finalTime +") < "+ Te2String(time1);
+		break;
+		
+		case TeTIMEAFTER:  
+			sql = func +"("+ initialTime +") > "+ Te2String(time2);
+		break;
+		
+		case TeTIMEEQUAL:  
+			sql = func +"("+ initialTime +") = "+ Te2String(time1);
+			sql += " AND "+ func +"(" + finalTime +") = "+ Te2String(time2);
+		break;
+
+		case TeTIMEMEETS:     
+			sql = func +"("+ finalTime +") = "+ Te2String(time1);
+			sql += " OR "+ func +"(" + initialTime +") = "+ Te2String(time2);
+		break;
+
+		case TeTIMEDURING: 
+			sql = func +"("+ initialTime +") >= "+ Te2String(time1);
+			sql += " AND "+ func +"("+ initialTime +") <= "+ Te2String(time2);
+			sql += " AND "+ func +"("+ finalTime +") >= "+ Te2String(time1);
+			sql += " AND "+ func +"("+ finalTime +") <= "+ Te2String(time2);
+		break;
+
+		case TeTIMEOVERLAPS:         
+			sql =  "("+ func +"("+ initialTime +") <= "+ Te2String(time1);
+			sql += " AND "+ func +"("+ finalTime +") >= "+ Te2String(time1);
+			sql += " AND "+ func +"("+ finalTime +") <= "+ Te2String(time2) +")";
+			sql += " OR ";
+			sql += "("+ func +"("+ initialTime +") >= "+ Te2String(time1);
+			sql += " AND "+ func +"("+ initialTime +") <= "+ Te2String(time2);
+			sql += " AND "+ func +"("+ finalTime +") >= "+ Te2String(time2) +")";
+		break;
+
+		case TeTIMEENDS:
+			sql = func +"("+ finalTime +") = "+ Te2String(time2);
+		break;
+
+		case TeTIMESTARTS:
+			sql = func +"("+ initialTime +") = "+ Te2String(time1);
+
+		default:
+			break;
+	}
+	
+	return sql;
+}
+
+string 
+TeDatabase::getSQLTemporalWhere (const string& temporalRest)
+{
+	string result, tableName, initialCol, finalCol, time1, time2, mask; 
+	TeTemporalRelation rel = TeTIMEUNDEFINED;
+	TeChronon chronon = TeNOCHRONON; 
+	
+	string temp = temporalRest;
+	bool flag = true;
+	int cont = 0;
+		
+	while(flag)
+	{
+		string element;
+		int pos = temp.find (";");
+		if(pos<0)
+		{
+			flag = false;
+			element = temp;
+		}
+		else
+		{
+			element = temp.substr(0, pos);
+			temp = temp.substr (pos+1);
+		}
+
+		if(cont==0) //table name
+			tableName = element;
+		else if(cont==1) //column name (initial time) 
+			initialCol = element; 
+		else if(cont==2) //column name (final time)
+			finalCol = element;
+		else if(cont==3) //TeTemporalRelation 
+		{
+			if(element=="TeTIMEEQUAL")
+				rel = TeTIMEEQUAL;
+			else if (element=="TeTIMEBEFORE")
+				rel = TeTIMEBEFORE;
+			else if (element=="TeTIMEAFTER")
+				rel = TeTIMEAFTER;
+			else if (element=="TeTIMEMEETS")
+				rel = TeTIMEMEETS;
+			else if (element=="TeTIMEDURING")
+				rel = TeTIMEDURING;
+			else if (element=="TeTIMEOVERLAPS")
+				rel = TeTIMEOVERLAPS;
+			else if (element=="TeTIMEENDS")
+				rel = TeTIMEENDS;
+			else if (element=="TeTIMESTARTS")
+				rel = TeTIMESTARTS;
+		}
+		else if(cont==4) //time 1
+			time1 = element;
+		else if(cont==5) //time 2
+		{
+			if(element.empty())
+				time1 = time2;
+			else
+				time2 = element;
+		}
+		else if(cont==6)
+			mask = element;
+		else if(cont==7) //TeChronon  
+		{
+			if (element=="TeSECOND")
+				chronon = TeSECOND;
+			else if (element=="TeMINUTE")
+				chronon = TeMINUTE;
+			else if (element=="TeHOUR")
+				chronon = TeHOUR;
+			else if (element=="TeDAY")
+				chronon = TeDAY;
+			else if (element=="TeMONTH")
+				chronon = TeMONTH;
+			else if (element=="TeYEAR")
+				chronon = TeYEAR;
+			else if (element=="TeDAYOFWEEK")
+				chronon = TeDAYOFWEEK;
+			else if (element=="TeMONTHOFYEAR")
+				chronon = TeMONTHOFYEAR;
+			else if (element=="TeSEASON")
+				chronon = TeSEASON;
+			else if (element=="TeWEEKOFYEAR")
+				chronon = TeWEEKOFYEAR;
+		}
+
+		++cont;
+	}
+
+	int posMask = mask.find ("s");
+	if(posMask<0) 
+	{
+		result = " "+ getSQLTemporalWhere(atoi(time1.c_str()), atoi(time2.c_str()), chronon, rel, (tableName+"."+initialCol), (tableName+"."+finalCol)) +" ";
+	}
+	else
+	{
+		TeTimeInterval interval(time1, time2, chronon, mask);
+		result = " "+ getSQLTemporalWhere(interval, rel, (tableName+"."+initialCol), (tableName+"."+finalCol)) + " "; 
+	}
+
+	return result;
+}
+
+
+string 
+TeDatabase::getSQLTemporalFunction (TeChronon chr, const string& colName)
+{
+	string func;
+	switch(chr)
+	{
+		case TeYEAR:             
+			func = " year ("+ colName +")";
+		break;
+
+		case TeMONTH:			// Fev/2003 != Fev/2004
+			func = " year ("+ colName +"), month ("+ colName +") ";
+		break;
+
+		case TeMONTHOFYEAR:		// Fev/2003 == Fev/2004
+			func = " month ("+ colName +")";
+		break;
+
+		case TeDAY:				// 01/01/2003 != 01/01/2004 != 01/02/2004             
+			func = " year ("+ colName +"), month ("+ colName +"), day("+ colName +") ";
+		break;
+
+		case TeDAYOFMONTH:		// 01/01/2003 == 01/01/2004 == 01/02/2004             
+			func = " day("+ colName +") ";
+		break;
+
+		case TeDAYOFYEAR:		// 01/01/2003 == 01/01/2004 != 01/02/2004             
+			func = " month ("+ colName +"), day("+ colName +") ";
+		break;
+
+		case TeDAYOFWEEK:		// 01/01/2003 != 01/01/2004 != 01/02/2004             
+			func = " weekday ("+ colName +") ";
+		break;
+
+		case TeHOUR:			// 01/01/2003 10:00 != 01/01/2004 10:00 != 01/02/2004 10:00             
+			func = " year ("+ colName +"), month ("+ colName +"), day("+ colName +"), hour("+ colName +") ";
+		break;
+
+		case TeHOUROFDAY:       // 01/01/2003 10:00 == 01/01/2004 10:00 == 01/02/2004 10:00    
+			func = " hour ("+ colName +")";
+		break;
+
+		case TeMINUTE:			// 01/01/2003 10:30 != 01/01/2004 10:30 != 01/02/2004 10:30 
+		   func = " year ("+ colName +"), month ("+ colName +"), day("+ colName +"), hour("+ colName +"), minute("+ colName +") ";
+		break;
+
+		case TeMINUTEOFHOUR:   // 01/01/2003 10:30 == 01/01/2004 10:30 == 01/02/2004 10:30 != 01/02/2004 10:31
+			func = " minute("+ colName +") ";
+		break;
+
+		case TeSECOND:  // 01/01/2003 10:30:04 != 01/01/2004 10:30:04 != 01/02/2004 10:30:04 
+		   func = " year ("+ colName +"), month ("+ colName +"), day("+ colName +"), hour("+ colName +"), minute("+ colName +"), second("+ colName +") ";
+		break;
+
+		case TeSECONDOFMINUTE:  // 01/01/2003 10:30:04 == 01/01/2004 10:30:04 == 01/02/2004 10:30:04 != 01/02/2004 10:30:07
+		   func = " second("+ colName +") "; 
+		break;
+		
+		default:
+			return "";
+	}
+	
+	return func;
+}
+ 
+
+bool
+TeDatabase::getMBRGeom(string tableGeom, string object_id, TeBox& box, string /* colGeom */)
+{
+	double xmin = TeMAXFLOAT;
+	double xmax = -TeMAXFLOAT;
+	double ymin = TeMAXFLOAT;
+	double ymax = -TeMAXFLOAT;
+			
+	TeDatabasePortal* portal = getPortal();
+	if(!portal)
+		return false;
+
+	string sel = "SELECT lower_x, upper_x, lower_y, upper_y FROM " + tableGeom;
+	sel += " WHERE object_id = '" + object_id + "'";
+
+	if(!portal->query(sel))
+	{
+		delete portal;
+		return false;
+	}
+		
+	bool b = portal->fetchRow();
+	if(!b)
+	{
+		delete portal;
+		return false;
+	}
+	
+	while(b)
+	{
+		xmin = MIN(xmin, portal->getDouble(0));
+		xmax = MAX(xmax, portal->getDouble(1));
+		ymin = MIN(ymin, portal->getDouble(2));
+		ymax = MAX(ymax, portal->getDouble(3));
+		b = portal->fetchRow();	
+	}
+			
+	TeBox bb(xmin, ymin, xmax, ymax);
+	box = bb;
+	delete portal;
+	return true;
+}
+
+bool 
+TeDatabase::getMBRSelectedObjects(string /* geomTable */,string /* colGeom */, string fromClause, string whereClause, string afterWhereClause, TeGeomRep repType,TeBox &bout, const double& tol)
+{
+	string	fields;
+	string	query;
+	bool	status = false;
+
+	TeBox	box;
+	bout = box;
+
+	TeDatabasePortal* portal = this->getPortal();
+
+	switch(repType)
+	{
+		case TePOLYGONS:
+		case TeLINES:
+		case TeCELLS:
+			fields = "MIN(lower_x), MIN(lower_y), MAX(upper_x), MAX(upper_y)";
+			query =  " SELECT " + fields;
+			query += " FROM " + fromClause; 
+			if (!whereClause.empty())
+				query += " WHERE " + whereClause;
+			if (!afterWhereClause.empty())
+				query += afterWhereClause;
+
+			if (portal->query (query))
+			{
+				bool b = portal->fetchRow();
+				while(b)
+				{
+					string vxmin = portal->getData(0);
+					string vymin = portal->getData(1);
+					string vxmax = portal->getData(2);
+					string vymax = portal->getData(3);
+					if(vxmin.empty() || vymin.empty() || vxmax.empty() || vymax.empty())
+					{
+						b = portal->fetchRow();
+						continue;
+					}
+					double xmin = atof(vxmin.c_str());
+					double ymin = atof(vymin.c_str());
+					double xmax = atof(vxmax.c_str());
+					double ymax = atof(vymax.c_str());
+					TeBox	ibox(xmin, ymin, xmax, ymax);
+					updateBox (bout, ibox);
+					b = portal->fetchRow();
+					status = true;
+				}
+			}
+			break;
+
+		case TePOINTS:
+		case TeTEXT:
+			fields = "MIN(x), MIN(y), MAX(x), MAX(y)";
+			query =  " SELECT " + fields;
+			query += " FROM " + fromClause; 
+			if (!whereClause.empty())
+				query += " WHERE " + whereClause;
+			if (!afterWhereClause.empty())
+				query += afterWhereClause;
+			
+			if (portal->query (query))
+			{
+				bool b = portal->fetchRow();
+				while(b)
+				{
+          string vxmin = portal->getData(0);
+          string vymin = portal->getData(1);
+          string vxmax = portal->getData(2);
+          string vymax = portal->getData(3);
+          if(vxmin.empty() || vymin.empty() || vxmax.empty() || vymax.empty())
+          {
+            b = portal->fetchRow();
+            continue;
+          }
+          double xmin = atof(vxmin.c_str());
+          double ymin = atof(vymin.c_str());
+          double xmax = atof(vxmax.c_str());
+          double ymax = atof(vymax.c_str());
+          
+          TeBox ibox;
+          if (xmin == xmax) {
+            ibox.x1_ = xmin - tol;
+            ibox.x2_ = xmax + tol;
+          }
+          else{
+            ibox.x1_ = xmin;
+            ibox.x2_ = xmax;
+          }
+          if (ymin == ymax) {
+            ibox.y1_ = ymin - tol;
+            ibox.y2_ = ymax + tol;
+          }
+          else {
+            ibox.y1_ = ymin;
+            ibox.y2_ = ymax;
+          }
+					updateBox (bout, ibox);
+					b = portal->fetchRow();
+					status = true;
+				}
+			}
+			break;
+
+
+		default:
+			status = false;
+			break;
+	}
+	delete portal;
+	return status;
+}
+
+bool 
+TeDatabase::getAttributeList(const string& tableName,TeAttributeList& attList)
+{
+	TeDatabasePortal* portal = this->getPortal();
+	if (!portal)
+		return false;
+
+	string sql = "SELECT * FROM " + tableName + " WHERE 1=2";
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return false;
+	}
+	else
+		attList = portal->getAttributeList();
+	delete portal;
+	return true;
+}
+
+
+bool TeDatabase::insertRasterVisual (int themeId , TeRasterVisual* vis)
+{
+	TeRasterTransform::TeRasterTransfFunctions tf = vis->getTransfFunction();
+		
+	if (tf == TeRasterTransform::TeNoTransf)
+		return true;
+
+	string sql = "DELETE FROM te_visual_raster WHERE theme_id = " + Te2String(themeId);
+	if (!this->execute(sql))
+		return false;
+
+	if (tf == TeRasterTransform::TeMono2Three ||
+		tf == TeRasterTransform::TePall2Three || 
+		tf == TeRasterTransform::TeLUT2Three)
+	{
+		sql = "INSERT INTO te_visual_raster (theme_id, band_in, transf_type) VALUES (";
+		sql += Te2String(themeId) + "," + Te2String(vis->getSrcBand()) + ",";
+		sql += Te2String(static_cast<short>(tf)) + ")";
+		if (!this->execute(sql))
+			return false;
+		return true;
+	}
+
+	if (tf == TeRasterTransform::TeExtractBand)
+	{
+		sql = "INSERT INTO te_visual_raster (theme_id, band_in, band_out, transf_type) VALUES (";
+		sql += Te2String(themeId) + "," + Te2String(vis->getSrcBand()) + ",";
+		sql += Te2String(vis->getDestBand()) + "," + Te2String(static_cast<short>(tf))+ ")";
+		if (!this->execute(sql))
+			return false;
+		return true;
+	}
+
+	if (tf == TeRasterTransform::TeExtractBands || tf == TeRasterTransform::TeExtractRGB)
+	{
+		map<TeRasterTransform::TeRGBChannels,short>& RGBmap = vis->getRGBMap();
+		map<TeRasterTransform::TeRGBChannels,short>::iterator it = RGBmap.begin();
+		while (it != RGBmap.end())
+		{
+			sql = "INSERT INTO te_visual_raster (theme_id, band_in, band_out, transf_type) VALUES (";
+			sql += Te2String(themeId) + "," + Te2String(static_cast<short>(it->second)) + ",";
+			sql += Te2String(static_cast<short>(it->first)) + "," + Te2String(static_cast<short>(tf))+ ")";
+			if (!this->execute(sql))
+				return false;
+			++it;
+		}
+		return true;
+	}
+	return false;
+}
+
+
+bool 
+TeDatabase::locateLineSet (const string& table, TeCoord2D &pt, TeLineSet &ls, const double& tol)
+{
+	bool located=false;
+	TeDatabasePortal* portal = this->getPortal();
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE lower_x < %f AND upper_x > %f AND lower_y < %f AND upper_y > %f",
+		box.x2(),box.x1(),box.y2(),box.y1());
+	q += buf;
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+
+	// Get all lines
+	bool flag = true;
+	do 
+	{
+		TeLine2D l;
+		TeLineSet tmp;
+		int index;
+		double dist;
+		TeCoord2D pout;
+
+		flag = portal->fetchGeometry( l );
+		tmp.add(l);
+		if(TeNearest(pt,tmp,index,pout,dist,tol))
+			{
+				ls.add ( l );
+				located=true;
+			}
+	} while (flag);
+
+	delete portal;
+	return located;
+}
+
+
+bool 
+TeDatabase::locatePointSet (const string& table, TeCoord2D &pt, TePointSet &pointSet, const double& tol)
+{
+	bool located=false;
+
+	TeDatabasePortal* portal = this->getPortal();
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE x < %f AND x > %f AND y < %f AND y > %f",
+		box.x2(),box.x1(),box.y2(),box.y1());
+	q += buf;
+
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	do 
+	{
+		TePoint point;
+		flag = portal->fetchGeometry (point);
+		pointSet.add ( point );
+		located=true;
+	}while (flag);
+
+	delete portal;
+	return located;
+}
+
+
+bool 
+TeDatabase::locateTextSet (const string& table, TeCoord2D &pt, TeTextSet& textSet, const double& tol)
+{
+	bool located=false;
+
+	TeDatabasePortal* portal = this->getPortal();
+
+	TeBox box (pt.x()-tol,pt.y()-tol,pt.x()+tol,pt.y()+tol);
+	string q ="SELECT * FROM " + table;
+	char buf [1024];
+	sprintf (buf," WHERE x < %f AND x > %f AND y < %f AND y > %f",
+		box.x2(),box.x1(),box.y2(),box.y1());
+	q += buf;
+	if (!portal->query(q) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	// Look for all texts
+	bool flag = true;
+	
+	do
+	{
+		TeText p;
+		flag = portal->fetchGeometry(p);
+		textSet.add ( p );
+		located=true;
+	} while (flag);
+
+	delete portal;
+	return located;
+}
+
+bool 
+TeDatabase::updateVersionStamp(const string& DBversion )
+{
+	TeTable versionTable;
+	if( !loadTable( "te_database", versionTable ) )
+		return false;
+	if ( versionTable.size() ) //no empty
+	{
+		string deleteVersionTb = "DELETE FROM te_database";
+		if( !execute( deleteVersionTb ) )
+			return false;
+	}
+	//insert
+	string insVersionTb = "INSERT INTO te_database (db_version) VALUES('" + DBversion + "')";
+	if( !execute(insVersionTb) )
+		return false;
+	return true;
+}
+
+bool 
+TeDatabase::loadVersionStamp(string& DBversion)
+{
+	DBversion.clear();
+	TeTable versionTable;	
+	if( !loadTable("te_database",versionTable) )
+		return false;
+	if ( versionTable.size() == 0 )
+		return false;
+	std::vector<std::string> attrs;
+	versionTable.attributeNames( attrs );
+	for (unsigned int i = 0; i < attrs.size(); i++ )
+	{
+		if ( TeStringCompare(attrs[i], "db_version", false ) )
+		{
+			DBversion = versionTable(0, i);
+			break;
+		}
+	}
+	return false;
+}
+
+bool 
+TeDatabase::updateLayerBox(TeLayer* layer)
+{
+	if (!layer)
+		return false;
+	TeBox box = layer->box();
+	string sql = "UPDATE te_layer SET lower_x = " + Te2String(box.x1(),15);
+		   sql += ", lower_y = " + Te2String(box.y1(),15);
+		   sql += ", upper_x = " + Te2String(box.x2(),15);
+		   sql += ", upper_y = " + Te2String(box.y2(),15);
+		   sql += " WHERE layer_id=" + Te2String(layer->id());
+	return execute(sql);
+}
+
+//! Load information about all projects stored in the database
+bool 
+TeDatabase::loadProjectSet()
+{
+	//clear map
+	TeProjectMap::iterator projectIt;
+	for (projectIt = metaModel_->projectMap().begin(); projectIt != metaModel_->projectMap().end(); ++projectIt)
+	{
+		if (projectIt->second)
+			delete projectIt->second;
+	}
+	metaModel_->projectMap().clear();
+	
+	//sql
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+
+	string get = " SELECT te_project.*, te_project_view.* ";
+	get += " FROM te_project LEFT JOIN te_project_view ";
+	get += " ON te_project.project_id = te_project_view.project_id ";
+	get += " ORDER BY te_project.project_id, te_project_view.view_id";
+
+	if (!portal->query(get))
+	{	
+		delete portal;
+		return false;
+	}
+
+	bool flag = portal->fetchRow();
+	while (flag)
+	{
+		TeProject* project = new TeProject(portal->getInt(0), this);
+		project->setName(string(portal->getData(1)));
+		project->setDescription(string(portal->getData(2)));
+//		project->setCurrentViewId(portal->getInt(3));
+		int pId = portal->getInt(3);
+		
+		//load all views
+		bool hasViews = true;
+		while(hasViews)
+		{
+			project->addView(portal->getInt(5));
+			flag = portal->fetchRow();
+			if(!flag || (portal->getInt(0)!=project->id()))
+				hasViews = false;
+		}
+		
+		project->setCurrentViewId(pId);
+		metaModel_->projectMap()[project->id()] = project;
+	}
+
+	delete portal;
+	return true;
+
+}
+
+//! Load information about a particular project
+bool 
+TeDatabase::loadProject(TeProject* project)
+{
+	if(!project)
+		return false;
+	
+	//sql
+	string get = " SELECT te_project.*, te_project_view.* ";
+	get += " FROM te_project LEFT JOIN te_project_view ";
+	get += " ON te_project.project_id = te_project_view.project_id ";
+
+	if(project->id()>0)
+		get += " WHERE  te_project.project_id = "+ Te2String(project->id());
+	else if (!project->name().empty())
+		get += " WHERE  te_project.name = '"+ project->name() +"'";
+	else 
+		return false;
+
+	get += " ORDER BY te_project.project_id, te_project_view.view_id";
+
+	TeDatabasePortal* portal = this->getPortal();
+	if(!portal)
+		return false;
+	if (!portal->query(get) || !portal->fetchRow())
+	{	
+		delete portal;
+		return false;
+	}
+
+	project->setId (portal->getInt(0));
+	project->setDatabase(this);
+	project->setName(string(portal->getData(1)));
+	project->setDescription(string(portal->getData(2)));	
+	int currentViewId = portal->getInt(3);
+	
+	//load all views
+	bool hasViews = true;
+	while(hasViews)
+	{
+		project->addView(portal->getInt(5));
+		bool flag = portal->fetchRow();
+		if(!flag || (portal->getInt(0)!=project->id()))
+			hasViews = false;
+	}
+	project->setCurrentViewId(currentViewId); //the views vector need be filled
+		
+	metaModel_->projectMap()[project->id()] = project;
+	delete portal;
+	return true;
+}
+	
+//! Update information about a layer
+bool 
+TeDatabase::updateProject(TeProject *project)
+{
+	if (!project)
+		return false;
+	int projectId = project->id();
+	if (projectId <= 0)
+		return false;
+
+	//update project information
+	string sql = " UPDATE te_project SET ";
+	sql += " name = '" + project->name() +"'";
+	sql += ", description = '" + project->description() +"'";
+	sql += ", current_view = "+ Te2String(project->getCurrentViewId());
+	sql += " WHERE project_id = "+ Te2String(project->id());
+	if (!this->execute (sql))
+	{
+		this->errorMessage_ = "\nError updating project information";
+		return false;
+	}	
+	
+	//delete relation
+	sql = "DELETE FROM te_project_view WHERE project_id =" + Te2String(project->id());
+	if (!this->execute (sql))
+	{
+		this->errorMessage_ = "Error deleting project/view relation";
+		return false;
+	}
+	const TeViewVector vv = project->getViewVector();
+	for (unsigned int i=0; i<vv.size(); ++i)
+	{
+		sql = "INSERT INTO te_project_view VALUES(" + Te2String(projectId) + "," + Te2String(vv[i]) + ")";
+		if (!this->execute (sql))
+		{
+			this->errorMessage_ = "Error inserting project/view relation";
+			return false;
+		}
+	}
+	return true;
+}
+
+//! Delete a project from the database
+bool 
+TeDatabase::deleteProject(int projectId)
+{
+	string sql = "DELETE FROM te_project_view WHERE project_id =" + Te2String(projectId);
+	if (!this->execute (sql))
+	{
+		this->errorMessage_ = "Error deleting project/view relation";
+		return false;
+	}
+	sql = "DELETE FROM te_project WHERE project_id =" + Te2String(projectId);
+	if (!this->execute (sql))
+	{
+		this->errorMessage_ = "Error deleting te_project entry";
+		return false;
+	}
+	
+	// delete project and its entry in the project map
+	TeProject* proj = metaModel_->projectMap()[projectId];
+	metaModel_->projectMap().erase(projectId);
+	if(proj)
+		delete proj;
+	return true;
+}
+
+//! Insert a project/view relation
+bool 
+TeDatabase::insertProjectViewRel(int projectId, int viewId)
+{
+	string sql = "INSERT INTO te_project_view VALUES(" + Te2String(projectId) + "," + Te2String(viewId) + ")";
+	if (!this->execute (sql))
+	{
+		this->errorMessage_ = "Error inserting project/view relation";
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDatabase::deleteProjectViewRel(int projectId, int viewId)
+{
+	string sql ="DELETE FROM te_project_view WHERE project_id = ";
+	       sql += Te2String(projectId);
+		   sql += " AND view_id = ";
+		   sql += Te2String(viewId);
+	if (!this->execute (sql))
+	{
+		this->errorMessage_ = "Error removing project/view relation";
+		return false;
+	}
+	return true;
+}
+
+bool TeDatabase::projectExist(const string& projectName)
+{
+	TeDatabasePortal* portal = this->getPortal();
+
+	if(!portal)
+		return false;
+
+	string sql = "SELECT name FROM te_project WHERE " +  this->toUpper("name") + " = '" + TeConvertToUpperCase(projectName) + "'";
+
+	if(!portal->query(sql))
+	{	
+		portal->freeResult();
+		delete portal;
+		return false;
+	}
+
+	if(portal->fetchRow())
+	{
+		portal->freeResult();
+		delete portal;
+		return true;		
+	}
+
+	portal->freeResult();
+	delete portal;
+	return false;
+}
+
+bool TeDatabase::createPolygonGeometry(const string& tableName)
+{
+	if(tableName.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attSpatial;
+	attSpatial.rep_.name_ = "spatial_data";
+	attSpatial.rep_.type_ = TePOLYGONTYPE;
+	attList.push_back(attSpatial);}
+
+	if(!createTable(tableName, attList))
+		return false;
+
+	string idxName = "te_idx_"  + tableName + "_obj";
+
+	return createIndex(tableName, idxName, "object_id");
+}
+
+bool TeDatabase::createLineGeometry(const string& tableName) 
+{
+	if(tableName.empty())
+		return false;
+
+	TeAttributeList attList;
+
+	{TeAttribute attGeomId;
+	attGeomId.rep_.name_ = "geom_id";
+	attGeomId.rep_.type_ = TeUNSIGNEDINT;
+	attGeomId.rep_.isAutoNumber_ = true;
+	attGeomId.rep_.isPrimaryKey_ = true;
+	attGeomId.rep_.null_ = false;
+	attList.push_back(attGeomId);}
+
+	{TeAttribute attObjId;
+	attObjId.rep_.name_ = "object_id";
+	attObjId.rep_.type_ = TeSTRING;
+	attObjId.rep_.numChar_ = 255;
+	attObjId.rep_.null_ = false;
+	attList.push_back(attObjId);}
+
+	{TeAttribute attSpatial;
+	attSpatial.rep_.name_ = "spatial_data";
+	attSpatial.rep_.type_ = TeLINE2DTYPE;
+	attList.push_back(attSpatial);}
+
+	if(!createTable(tableName, attList))
+		return false;
+
+	string idxName = "te_idx_"  + tableName + "_obj";
+
+	return createIndex(tableName, idxName, "object_id");
+}
+
+bool 
+TeDatabase::deleteRelation(const string& name, const string& table)
+{
+	string relation = "ALTER TABLE " + table + " DROP ";
+	relation += " CONSTRAINT " + name;
+	return execute(relation);
+}
+
+bool 
+TeDatabase::dropDBView(const string& dbViewName)
+{
+   string del = "DROP VIEW " + dbViewName;
+   return (execute(del));
+} 
+
+bool 
+TeDatabase::updateBBox(const string& tableName, const string& keyColumnName, int keyValue, const TeBox& box)
+{
+	string upd = "UPDATE "+tableName+" SET lower_x=" + Te2String(box.x1_,15);
+	upd += ", lower_y=" + Te2String(box.y1_, 15);
+	upd += ", upper_x=" + Te2String(box.x2_, 15);
+	upd += ", upper_y=" + Te2String(box.y2_, 15);
+	upd += " WHERE " + keyColumnName + "=" + Te2String(keyValue);
+	return execute(upd);
+}
+bool 
+TeDatabase::beginTransaction()
+{
+	transactionCounter_++; 
+	return true;
+} 
+
+bool 
+TeDatabase::commitTransaction()
+{
+	transactionCounter_ = max(transactionCounter_-1, 0);
+	return true;
+} 
+
+bool 
+TeDatabase::rollbackTransaction()
+{
+	transactionCounter_ = max(transactionCounter_-1, 0);
+	return true;
+} 
+
+TeBox 
+TeDatabase::getThemeBox(TeTheme* theme)
+{
+	TeBox bb;
+	if (!theme)
+		return bb;
+
+	TeLayer* layer = theme->layer();
+	if (layer->hasGeometry(TeRASTER))
+		bb = layer->box();
+
+	if (layer->hasGeometry(TeRASTERFILE))
+		updateBox(bb,layer->getRepresentation(TeRASTERFILE)->box_);
+
+	string colTabName = theme->collectionTable();
+	if (colTabName.empty())
+		return bb;
+
+	string sqlfrom;
+	string geomTable;
+	if (layer->hasGeometry(TePOINTS))
+	{
+		geomTable = layer->tableName(TePOINTS);
+		sqlfrom = colTabName + " LEFT JOIN " + geomTable;
+		sqlfrom += " ON " + colTabName + ".c_object_id = " + geomTable + ".object_id";
+		TeBox bpt;
+		if (getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TePOINTS,bpt))
+			updateBox(bb,bpt);
+	}
+	if (layer->hasGeometry(TeLINES))
+	{
+		geomTable = layer->tableName(TeLINES);
+		sqlfrom = colTabName + " LEFT JOIN " + geomTable;
+		sqlfrom += " ON " + colTabName + ".c_object_id = " + geomTable + ".object_id";
+		TeBox bln;
+		if (getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TeLINES,bln))
+			updateBox(bb,bln);
+	}
+	if (layer->hasGeometry(TePOLYGONS))
+	{
+		geomTable = layer->tableName(TePOLYGONS);
+		sqlfrom = colTabName + " LEFT JOIN " + geomTable;
+		sqlfrom += " ON " + colTabName + ".c_object_id = " + geomTable + ".object_id";
+		TeBox bpol;
+		if (getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TePOLYGONS,bpol))
+			updateBox(bb,bpol);
+	}
+
+	if (layer->hasGeometry(TeCELLS))
+	{
+		geomTable = layer->tableName(TeCELLS);
+		sqlfrom = colTabName + " LEFT JOIN " + geomTable;
+		sqlfrom += " ON " + colTabName + ".c_object_id = " + geomTable + ".object_id";
+		TeBox bpol;
+		if (getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TeCELLS,bpol))
+			updateBox(bb,bpol);
+	}
+
+	if (layer->hasGeometry(TeTEXT))
+	{
+		geomTable = layer->tableName(TeTEXT);
+		sqlfrom = colTabName + " LEFT JOIN " + geomTable;
+		sqlfrom += " ON " + colTabName + ".c_object_id = " + geomTable + ".object_id";
+		TeBox bpol;
+		if (getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TeTEXT,bpol))
+			updateBox(bb,bpol);
+	}	
+
+	return bb;
+}
+
+// End TeDatabase Methods
+
+// Begin TeDatabasePortal Methods
+
+TeDatabasePortal::TeDatabasePortal():
+	db_(0),			
+	numRows_(0),
+	numFields_ (0),	
+	errorMessage_(""),
+	errorNumber_(0)
+	{}
+
+TeDatabasePortal::~TeDatabasePortal ()
+{
+}
+
+double 
+TeDatabasePortal::getDouble (int i)
+{  
+	char* val = getData(i); 
+	return atof(val); 
+}
+
+double 
+TeDatabasePortal::getDouble (const string& s)
+{  
+	char* val = getData(s); 
+	return atof(val); 
+}
+
+int 
+TeDatabasePortal::getInt (int i)
+{  
+	char* val = getData(i); 
+	return atoi(val); 
+}
+
+int 
+TeDatabasePortal::getInt (const string& s)
+{  
+	char* val = getData(s); 
+	return atoi(val); 
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TePolygon& geom, const unsigned int&)
+{
+	return fetchGeometry(geom);
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TeLine2D& geom, const unsigned int&)
+{
+	return fetchGeometry(geom);
+}
+	
+bool 
+TeDatabasePortal::fetchGeometry (TeNode& geom, const unsigned int&)
+{
+	return fetchGeometry(geom);
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TePoint& geom, const unsigned int&)
+{
+	return fetchGeometry(geom);
+}
+
+bool
+TeDatabasePortal::fetchGeometry (TeCell& cell)
+{
+	int index = atoi(getData("geom_id"));
+	string object_id = getData("object_id");
+	TeBox b (atof(getData("lower_x")),atof(getData("lower_y")),atof(getData("upper_x")),atof(getData("upper_y")));
+	cell.geomId(index);
+	cell.objectId(object_id);
+	cell.setBox (b);
+	cell.column(atoi(getData("col_number")));
+	cell.line(atoi(getData("row_number")));
+	return (fetchRow());
+}
+
+bool
+TeDatabasePortal::fetchGeometry (TeCell& cell, const unsigned int& initIndex)
+{
+	int index = atoi(getData(initIndex));
+	string object_id = getData(initIndex+1);
+	TeBox b (atof(getData(initIndex+2)),atof(getData(initIndex+3)),atof(getData(initIndex+4)),atof(getData(initIndex+5)));
+	cell.geomId(index);
+	cell.objectId(object_id);
+	cell.setBox (b);
+	cell.column(atoi(getData(initIndex+6)));
+	cell.line(atoi(getData(initIndex+7)));
+	return (fetchRow());
+}
+
+TeAttribute TeDatabasePortal::getAttribute (int i)
+{
+	TeAttributeList::iterator it = attList_.begin();
+	int j = 0;
+	while ( it != attList_.end() )
+	{
+		if (i == j)
+			return (*it);
+		++it;
+		j++;
+	}
+	return TeAttribute();
+}
+
+TeAttribute TeDatabasePortal::getAttribute (const string& s)
+{
+	TeAttributeList::iterator it = attList_.begin();
+	while ( it != attList_.end() )
+	{
+		if (TeConvertToUpperCase(s) == TeConvertToUpperCase((*it).rep_.name_))
+			return (*it);
+		++it;
+	}
+	return TeAttribute();
+}
+
+int 
+TeDatabasePortal::getColumnIndex (const string& s)
+{
+	TeAttributeList::iterator it = attList_.begin();
+	int j = 0;
+	while ( it != attList_.end() )
+	{
+		if (TeConvertToUpperCase(s) == TeConvertToUpperCase((*it).rep_.name_))
+			return j;
+		++it;
+		j++;
+	}
+	return -1;
+}
+
+string 
+TeDatabasePortal::getColumnName (int i)
+{
+	TeAttributeList::iterator it = attList_.begin();
+	int j=0;
+	while ( it != attList_.end() )
+	{
+		if (j==i)
+			return (*it).rep_.name_;
+		++it;
+		j++;
+	}
+	return "";
+}
+
+
+TeViewTree*
+TeDatabasePortal::getViewTree ()
+{
+	TeViewTree *tree = new TeViewTree();
+	tree->id (atoi(getData("theme_id")));
+	tree->name (getData("name"));
+	tree->priority(atoi(getData("priority")));
+	//Update the tree also with parent_id and node_type from te_theme table
+	tree->parentId(atoi(getData("parent_id")));
+	tree->type(atoi(getData("node_type")));	
+	//Is it necessary to set parent??
+	return tree;
+}
+
+TeLegendEntry 
+TeDatabasePortal::getLegend ()
+{
+	TeLegendEntry leg;
+	leg.id (atoi(getData("legend_id")));
+	leg.theme (atoi(getData("theme_id")));
+	leg.group (atoi(getData("group_id")));
+
+	string data;
+	data = getData("num_objs");
+	leg.count(atoi(data.c_str()));
+	data = getData("lower_value");
+	leg.from(data);
+	data = getData("upper_value");
+	leg.to(data);
+	data = getData("label");
+	leg.label(data);
+	return leg;
+}
+
+void
+TeDatabasePortal::getVisual(TeVisual* vis)
+{
+	TeGeomRep rep = (TeGeomRep)atoi (getData("geom_type"));
+
+	TeColor cor(atoi(getData("red")),atoi(getData("green")),atoi(getData("blue")));
+	vis->color(cor);
+	vis->transparency(atoi(getData("transparency")));
+
+	TeColor ccor(atoi(getData("contour_red")),atoi(getData("contour_green")),atoi(getData("contour_blue")));
+	vis->contourColor(ccor);
+	vis->contourWidth(atoi(getData("contour_width")));
+	vis->contourTransparency(atoi(getData("contour_transp")));
+
+	if(rep == TePOLYGONS || rep == TeCELLS)
+	{
+		vis->contourWidth(atoi(getData("width")));
+		vis->contourStyle(atoi(getData("contour_symb_id")));
+		vis->style(atoi(getData("symb_id")));
+	}
+	else if(rep == TeLINES)
+	{
+		vis->width(atoi(getData("width")));
+		vis->style(atoi(getData("symb_id")));
+	}
+	else if(rep == TePOINTS)
+	{
+		vis->size(atoi(getData("size_value")));
+		vis->style(atoi(getData("symb_id")));
+	}
+	else if(rep == TeTEXT)
+		vis->size(atoi(getData("size_value")));
+
+	vis->family(getData("family"));
+	vis->bold (getBool("bold"));
+	vis->italic (getBool("italic"));
+	vis->fixedSize (getBool("fixed_size"));
+
+	vis->alignmentVert(getDouble("alignment_vert"));
+	vis->alignmentHoriz(getDouble("alignment_horiz"));
+
+	vis->tabSize(atoi(getData("tab_size")));
+	vis->lineSpace(atoi(getData("line_space")));
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TeText& t)
+{
+	TeCoord2D c(getDouble("x"), getDouble("y"));
+	string txt = getData ("text_value");
+	TeText t2(c,txt);
+	t2.geomId(atoi(getData("geom_id")));
+	t2.objectId(string(getData("object_id")));
+	t2.setAngle (getDouble("angle"));
+	t2.setHeight (getDouble("height"));
+	t2.setAlignmentVert(getDouble("alignment_vert"));
+	t2.setAlignmentHoriz(getDouble("alignment_horiz"));
+	t = t2;
+	return (fetchRow());
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TeText& t, const unsigned int& initIndex)
+{
+	TeCoord2D c(getDouble(initIndex+2), getDouble(initIndex+3));
+	string txt = getData(initIndex+4);
+	TeText t2(c,txt);
+	t2.geomId(atoi(getData(initIndex)));
+	t2.objectId(string(getData(initIndex+1)));
+	t2.setAngle (getDouble(initIndex+5));
+	t2.setHeight (getDouble(initIndex+6));
+	t2.setAlignmentVert(getDouble(initIndex+7));
+	t2.setAlignmentHoriz(getDouble(initIndex+8));
+	t = t2;
+	return (fetchRow());
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TeArc& arc)
+{
+	arc.fromId(atoi(getData(2)));
+	arc.toId(atoi(getData(3)));
+	arc.geomId(atol(getData(0)));
+	arc.objectId(string(getData(1)));
+	return fetchRow();
+}
+
+bool 
+TeDatabasePortal::fetchGeometry (TeArc& arc, const unsigned int& initIndex)
+{
+	arc.fromId(atoi(getData(initIndex+2)));
+	arc.toId(atoi(getData(initIndex+3)));
+	arc.geomId(atol(getData(initIndex+0)));
+	arc.objectId(string(getData(initIndex+1)));
+	return fetchRow();
+}
+
+bool	
+TeDatabasePortal::getVisual(TeVisual* vis, TeGeomRep& rep, const unsigned int& initIndex)
+{
+	string legendId = this->getData(initIndex);
+	if(legendId.empty())
+		return false;
+
+	rep = (TeGeomRep)atoi (getData(initIndex+1)); //geom_type = 1
+
+	TeColor cor(atoi(getData(initIndex+3)),atoi(getData(initIndex+4)),atoi(getData(initIndex+5)));
+	vis->color(cor);
+	vis->transparency(atoi(getData(initIndex+6)));
+
+	TeColor ccor(atoi(getData(initIndex+9)),atoi(getData(initIndex+10)),atoi(getData(initIndex+11)));
+	vis->contourColor(ccor);
+	vis->contourWidth(atoi(getData(initIndex+13)));
+	vis->contourTransparency(atoi(getData(initIndex+12)));
+
+	if(rep == TePOLYGONS || rep == TeCELLS)
+	{
+		vis->contourWidth(atoi(getData(initIndex+13)));
+		vis->contourStyle(atoi(getData(initIndex+8)));
+		vis->style(atoi(getData(initIndex+2)));
+	}
+	else if(rep == TeLINES)
+	{
+		vis->width(atoi(getData(initIndex+7)));
+		vis->style(atoi(getData(initIndex+2)));
+	}
+	else if(rep == TePOINTS)
+	{
+		vis->size(atoi(getData(initIndex+14)));
+		vis->style(atoi(getData(initIndex+2)));
+	}
+	else if(rep == TeTEXT)
+		vis->size(atoi(getData(initIndex+14)));
+
+	vis->family(getData(initIndex+16));
+	vis->bold (getBool(initIndex+17));
+	vis->italic (getBool(initIndex+18));
+	vis->fixedSize (getBool(initIndex+23));
+
+	vis->alignmentVert(getDouble(initIndex+19));
+	vis->alignmentHoriz(getDouble(initIndex+20));
+
+	vis->tabSize(atoi(getData(initIndex+21)));
+	vis->lineSpace(atoi(getData(initIndex+22)));
+	return true;
+}
+
+bool	
+TeDatabasePortal::getRasterVisual(TeRasterVisual& vis, const unsigned int& initIndex)
+{
+	string themeId = getData(initIndex);
+	if(themeId.empty())
+		return false;
+
+	vis.setSrcBand(getInt(initIndex+1));
+	vis.setDestBand(getInt(initIndex+2));
+	vis.setTransfFunction(static_cast<TeRasterTransform::TeRasterTransfFunctions>(getInt(initIndex+3)));
+	if (vis.getTransfFunction() == TeRasterTransform::TeExtractRGB || 
+		vis.getTransfFunction() == TeRasterTransform::TeExtractBands)
+	{
+		vis.setBChannelMapping(getInt(initIndex+1),static_cast<TeRasterTransform::TeRGBChannels>(getInt(initIndex+2)));
+	}
+	
+	return true;
+}
+
+
+TeColor 
+TeDatabasePortal::getColor ()
+{
+	TeColor c(atoi(getData("red")), atoi(getData("green")), atoi(getData("blue")));
+	return c;
+}
+
+bool	
+TeDatabasePortal::getView(TeView& view, const unsigned int& initIndex)
+{
+	string viewId = getData(initIndex);
+	if(viewId.empty())
+		return false;
+	view.id(atoi(viewId.c_str()));
+	view.name(getData(initIndex+2));
+	view.user(getData(initIndex+3));
+	view.isVisible(getBool(initIndex+4));
+	view.setCurrentBox(TeBox(getDouble(initIndex+5), getDouble(initIndex+6), getDouble(initIndex+7), getDouble(initIndex+8)));
+	if(getData(initIndex+9) == "")
+		view.setCurrentTheme(-1);
+	else
+		view.setCurrentTheme(getInt(initIndex+9));
+	return true;
+}
+
+bool	
+TeDatabasePortal::getProjection(TeProjection** proj, const unsigned int& initIndex)
+{
+	string projId = getData(initIndex);
+	if(projId.empty())
+		return false;
+
+	TeDatum datum (	getData(initIndex+11),
+					getDouble(initIndex+12),
+					getDouble(initIndex+13),
+					getDouble(initIndex+14),
+					getDouble(initIndex+15),
+					getDouble(initIndex+16));
+
+	TeProjectionParams mProjPars;
+	mProjPars.datum = datum;
+	mProjPars.name = getData(initIndex+1);
+	mProjPars.lat0 = getDouble(initIndex+3)*TeCDR;
+	mProjPars.lon0 = getDouble(initIndex+2)*TeCDR;
+	mProjPars.offx = getDouble(initIndex+4);
+	mProjPars.offy = getDouble(initIndex+5);
+	mProjPars.stlat1 = getDouble(initIndex+6)*TeCDR;
+	mProjPars.stlat2 = getDouble(initIndex+7)*TeCDR;
+	mProjPars.units = getData(initIndex+8);
+	mProjPars.scale = getDouble(initIndex+9);
+	mProjPars.hemisphere = (TeHemisphere)getInt(initIndex+10);
+
+	*proj = TeProjectionFactory::make(mProjPars);
+	if(!*proj)
+		return false;
+
+	(*proj)->id(atoi(projId.c_str()));
+	return true;
+}
+
+void
+TeDatabasePortal::getViewNodeParams (TeViewNodeParams& params, const unsigned int& initIndex)
+{
+	params.name_ = string (this->getData(initIndex+3));	//name
+	params.id_ = this->getInt(initIndex);				// id
+	params.viewId_ = this->getInt(initIndex+2);			//view id
+	params.nodeType_ = 	this->getInt(initIndex+6);		//node type
+	params.priority_ = 	this->getInt(initIndex+5);		//priority  
+	params.myParentId_ = this->getInt(initIndex+4);	//parent id
+}
+
+bool
+TeDatabasePortal::getTheme(TeAbstractTheme& theme, const unsigned int& initIndex)
+{
+	string themeId = getData(initIndex);
+	if(themeId.empty())
+		return false;
+		
+	theme.id(atoi(themeId.c_str()));
+	theme.view (atoi(this->getData (initIndex+2)));
+	theme.name(string (this->getData(initIndex+3)));
+	theme.parentId( atoi(this->getData (initIndex+4)));
+	theme.type ((TeViewNodeType)this->getInt(initIndex+6));
+	theme.priority(this->getInt(initIndex+5));
+	theme.minScale (this->getDouble (initIndex+7));
+	theme.maxScale (this->getDouble (initIndex+8));
+	theme.attributeRest(string(this->getData (initIndex+9)));
+	theme.spatialRest(string(this->getData (initIndex+10)));
+	theme.temporalRest(string(this->getData (initIndex+11)));
+	theme.visibleRep(atoi(this->getData (initIndex+13)));
+	theme.visibility(atoi(this->getData (initIndex+14)));
+	theme.setThemeBox(TeBox(getDouble(initIndex+15), getDouble(initIndex+16), getDouble(initIndex+17), getDouble(initIndex+18)));
+
+	if(theme.type()==TeTHEME)
+	{
+		static_cast<TeTheme&>(theme).collectionTable(string(this->getData (initIndex+12)));
+		static_cast<TeTheme&>(theme).collectionAuxTable(static_cast<TeTheme&>(theme).collectionTable() + "_aux");
+		static_cast<TeTheme&>(theme).layerId (atoi(this->getData(initIndex+1)));
+	}
+	else if(theme.type()==TeEXTERNALTHEME)
+	{
+		static_cast<TeExternalTheme&>(theme).collectionTable(string(this->getData (initIndex+12)));
+		static_cast<TeExternalTheme&>(theme).collectionAuxTable(static_cast<TeExternalTheme&>(theme).collectionTable() + "_aux");
+	}
+	else if(theme.type()==TeEXTERNALTHEME)
+	{
+		static_cast<TeTheme&>(theme).collectionTable(string(this->getData (initIndex+12)));
+		static_cast<TeTheme&>(theme).collectionAuxTable(static_cast<TeTheme&>(theme).collectionTable() + "_aux");
+	}
+	return true;
+}
+
+bool	
+TeDatabasePortal::getGrouping(TeGrouping& group, const unsigned int& initIndex)
+{
+	string groupThemeId = getData(initIndex);
+	if(groupThemeId.empty())
+		return false;
+
+	TeAttributeRep atRep;
+	string attname = getData (initIndex+2);
+	string norname = getData (initIndex+5);
+	int f = attname.find("(");
+	if(f >= 0)
+	{
+		string alias = attname;
+		attname = attname.substr(0, f);
+		alias = alias.substr(f+1);
+		alias = alias.substr(0, alias.size()-1);
+		map<string, string>& m = this->getDatabase()->mapThemeAlias()[atoi(groupThemeId.c_str())];
+		m[attname] = alias;
+	}
+	f = norname.find("(");
+	if(f >= 0)
+	{
+		string alias = norname;
+		norname = norname.substr(0, f);
+		alias = alias.substr(f+1);
+		alias = alias.substr(0, alias.size()-1);
+		map<string, string>& m = this->getDatabase()->mapThemeAlias()[atoi(groupThemeId.c_str())];
+		m[norname] = alias;
+	}
+
+	if(attname=="NONE")
+		attname = "";
+	
+	if(norname=="NONE")
+		norname = "";
+		
+	atRep.name_ = attname;
+	atRep.type_ = TeAttrDataType(atoi(getData(initIndex+3)));
+	group.groupAttribute_ = atRep;
+	group.groupNormAttribute_ = norname;
+	group.groupMode_ = TeGroupingMode(getInt(initIndex+4));
+	group.groupNumSlices_ = getInt(initIndex+1);
+	group.groupPrecision_ = getInt(initIndex+7);
+	group.groupStdDev_ = getDouble(initIndex+6);
+	group.groupFunction_ = getData(initIndex+8);
+	group.groupChronon_ = TeChronon(getInt(initIndex+9));
+	return true;
+}
+
+bool 
+TeDatabasePortal::getLegend (TeLegendEntry& leg, const unsigned int& initIndex)
+{
+	string legId = getData(initIndex);
+	if(legId.empty())
+		return false;
+
+	leg.id(atoi(getData(initIndex)));
+	leg.theme (atoi(getData(initIndex+1)));
+	leg.group (atoi(getData(initIndex+2)));
+	leg.count (atoi(getData(initIndex+3)));
+
+  std::string lower_value_str( getData(initIndex+4) );
+  leg.from( lower_value_str );
+  
+  std::string upper_value_str( getData(initIndex+5) );
+  leg.to( upper_value_str );
+  
+  std::string label_str( getData(initIndex+6) );
+  leg.label( label_str );
+    
+	return true;
+}
+
+bool	
+TeDatabasePortal::getAttrTable(TeTable& table, const unsigned int& initIndex)
+{
+	string tableName = this->getData(initIndex+2);
+	if(tableName.empty())
+		return false;
+
+	table.name (tableName);
+	table.setId(this->getInt(initIndex+0));
+	table.setLinkName(this->getData(initIndex+4));
+	table.setUniqueName(this->getData(initIndex+3));
+	table.attInitialTime(this->getData(initIndex+5));
+	table.attFinalTime(this->getData(initIndex+6));
+	table.attTimeUnit(TeChronon(this->getInt(initIndex+7)));
+	table.setTableType((TeAttrTableType)this->getInt(initIndex+8));
+	return true;
+}
+
+bool	
+TeDatabasePortal::getLayer(TeLayer& layer, const unsigned int& initIndex)
+{
+	string layerId = this->getData(initIndex);
+	if(layerId.empty())
+		return false;
+
+    layer.id(atoi(layerId.c_str()));
+	layer.name(string (this->getData(initIndex+2)));
+
+	std::string x1 = this->getData("te_layer.lower_x");
+	std::string y1 = this->getData("te_layer.lower_y");
+	std::string x2 = this->getData("te_layer.upper_x");
+	std::string y2 = this->getData("te_layer.upper_y");
+
+	layer.setLayerBox(TeBox(this->getDouble(initIndex+3),
+						this->getDouble(initIndex+4),
+						this->getDouble(initIndex+5),
+						this->getDouble(initIndex+6)));
+	return true;
+}
+
+bool	
+TeDatabasePortal::getRepresentation(TeRepresentation& rep, const unsigned int& initIndex)
+{
+	string repId = this->getData(initIndex);
+	if(repId.empty())
+		return false;
+
+	rep.id_ = atoi(repId.c_str());
+	TeGeomRep g = (TeGeomRep)atoi(this->getData(initIndex+2));
+	rep.geomRep_ = g;
+	rep.tableName_ = this->getData(initIndex+3);
+	rep.description_ = this->getData(initIndex+4);
+	rep.box_ = TeBox(this->getDouble(initIndex+5),
+				this->getDouble(initIndex+6),
+				this->getDouble(initIndex+7),
+				this->getDouble(initIndex+8));
+	rep.resX_ = this->getDouble(initIndex+9);
+	rep.resY_ = this->getDouble(initIndex+10);
+	rep.nCols_ = this->getInt(initIndex+11);
+	rep.nLins_ = this->getInt(initIndex+12);
+	return true;
+}
+
+
+
+// End TeDatabasePortal Methods
+
+
diff --git a/src/terralib/kernel/TeDatabase.h b/src/terralib/kernel/TeDatabase.h
new file mode 100644
index 0000000..1eeddb2
--- /dev/null
+++ b/src/terralib/kernel/TeDatabase.h
@@ -0,0 +1,1695 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDatabase.h
+    \brief This file contains structures and definitions about database support in TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_DATABASE_H
+#define  __TERRALIB_INTERNAL_DATABASE_H
+
+#ifdef WIN32 
+#pragma warning ( disable: 4786 ) 
+#endif
+
+#include "TeDefines.h"
+
+#include "TeDefines.h"
+#include "TeDataTypes.h"
+#include "TeTable.h"
+#include "TeGeometry.h"
+#include "TeStatistics.h"
+#include "TeProject.h"
+#include "TeRaster.h"
+#include "TeView.h"
+#include "TeVisual.h"
+#include "TeMetaModelCache.h"
+#include "TeSharedPtr.h"
+
+class TeLayer;
+class TeDatabaseFactoryParams;
+class TeRasterParams;
+class TeTheme;
+class TeTime;
+class TeTimeInterval;
+
+#include <set>
+using namespace std;
+
+          
+/*! \enum TeCursorLocation
+	Location of a cursor on record set
+ */
+enum TeCursorLocation { TeCLIENTESIDE, TeSERVERSIDE };
+
+/*! \enum TeCursorType
+	Type of cursor on record set
+ */
+enum TeCursorType { TeUNIDIRECTIONAL, TeBIDIRECTIONAL, TeRANDOMACCESS };
+
+/*! \enum TeCursorEditType
+	Type of edition on record set cursor
+ */
+enum TeCursorEditType { TeREADONLY, TeREADWRITE };
+
+/*! \enum TeCursorDataType
+	Type of edition on record set cursor
+ */
+enum TeCursorDataType { TeBINARYCURSOR, TeTEXTCURSOR };
+
+
+/*! \enum TeSpatialIndexType
+	Type of spatial index
+ */
+enum TeSpatialIndexType {TeRTREE, TeQUADTREE};
+
+//! A vector of objects identifications (object_id)
+typedef vector<string>				TeKeys;
+
+//! A Map of objects identifications (object_id) to a distance value
+typedef map<string, double>			TeKeysToDist;
+
+//! A Vector of pointers to TeGeometry 
+typedef vector<TeGeometry*> TeGeometryVect;
+
+//! A Map of the objects identifications to a set of statistical values
+typedef map<string, TeStatisticsDimensionVect>  TeObjectStatistics;
+
+
+class TeDatabasePortal;
+
+
+//! An abstract database class
+/*!
+	Instances of this classes represent connections
+	to a database server. It includes the host name, 
+	user name and password parameters of the connection.
+	It should be implemented by the drivers to specific
+	database servers as: MySQL, Ado, PostgreSQL or any
+	other server to be used in TerraLib applications.
+	When possible, default implementations using ANSI SQL
+	are provided. 
+	Methods that rely on special features of the derived
+	driver are left as purely virtual.
+
+  \sa
+  TeTheme, TeView, TeLayer, TeAttribute
+*/
+class TL_DLL TeDatabase 
+{
+public: 
+	//! Empty constructor
+	TeDatabase();
+
+	//! Destructor
+	virtual ~TeDatabase();
+
+	//! Assignment operator
+	virtual TeDatabase& operator=(const TeDatabase& other);
+
+	//! Operator ==
+	virtual bool operator== (const TeDatabase& other) const
+	{	
+		if (dbmsName_ != other.dbmsName_ ||
+			database_ != other.database_ ||
+			host_  != other.host_ ||
+			user_ != other.user_ )
+			return false;
+		return true;
+	}
+	/** @name Members
+	*  Methods to access class private members
+	*/
+	//@{		
+	//! Returns the error message from the server
+	virtual string errorMessage ()
+	{ return errorMessage_; }
+
+	//! Returns the error number from the server
+	virtual int	errorNum ()
+	{	return errorNumber_; }
+
+	//! Return the user name of the connection opened
+	string	user () 
+	{ return user_; }
+
+	//! Set the current user name to view
+	void user(string value) { user_=value;}
+
+	//! Returns the host name of the connection opened
+	string	host () 
+	{ return host_; }
+
+	//! Returns the user's password of the connection opened
+	string	password () 
+	{ return password_; }
+
+	//! Returns the database name of the connection opened
+	string	databaseName () 
+	{ return database_; }
+	
+	//! Returns the Database Management System name
+	string	dbmsName () 
+	{ return dbmsName_; }
+
+	//! Returns the port number of the connection opened
+	int	portNumber () 
+	{ return portNumber_; }
+
+	//! Returns the  map of layers in the database
+	TeLayerMap&	layerMap () 
+	{ return metaModel_->layerMap(); }
+
+	//! Returns the  map of views in the database
+	TeViewMap&	viewMap () 
+	{ return metaModel_->viewMap(); }
+
+	//! Returns the  map of themes in the database
+	TeThemeMap&	themeMap () 
+	{ return metaModel_->themeMap(); }
+
+	//! Returns the map of invalid themes in the database
+	TeThemeMap&	invalidThemeMap() 
+	{ return metaModel_->invalidThemeMap(); }
+
+	//! Returns the  map of projects in the database
+	TeProjectMap&  projectMap ()
+   { return metaModel_->projectMap(); }
+
+	//! Returns the  map of legends in the database
+	TeLegendEntryMap& legendMap () 
+	{ return metaModel_->legendMap(); }
+
+	//! Returns the set of relations between tables
+	multiset<int>& relationMSet () 
+	{ return metaModel_->relationMSet(); }
+
+	//! Clears structures in memory (legendMap, layerMap, viewMap...) used to optimize database access
+	virtual void clear();
+
+	//@}
+
+	/** @name Database
+	*  Methods related to database and connection creation. 
+	*  These methods return TRUE when the operation was successfull.
+	*  Otherwise return FALSE and when possible an error message is captured.
+	*/
+	//@{	
+	//! Creates a new database and open a connection to it
+	virtual bool newDatabase(const string& database, const string& user, const string& password, const string& host, const int &port=-1, bool terralibModel=true) = 0;
+	
+	//! Opens a connection to a database server passing all parameters needed
+	virtual bool connect (const string& host, const string& user, const string& password, const string& database, int port = -1) = 0;
+
+	//! Show the server databases (only for MySQL, Oracle and PostgreSQL)
+	virtual bool showDatabases (const string& /* host */, const string& /* user */, const string& /* password */, vector<string>& /* dbNames */ , int /* port */ = -1)
+	{ return true; }
+
+	//! Opens a connection without parameters. When possible, should be implemented by the derived classes 
+	virtual bool connect (const string&  = "") { return false; };
+
+	//! Check if there is an opened connection
+	bool isConnected () 
+	{ return isConnected_; }
+
+	//! Closes the connection
+	virtual void close() = 0;
+
+	//! Returns a string that the describes the parameters of the database connected
+	/*
+		The expected return value is similar to: dbms_server;hostname;portnumber;databasename;user;password
+	*/
+	virtual string getDatabaseDescription();
+	
+  
+  /**
+   *  This is for TeFactory compatibility ( Invalid TeDatabaseFactory
+   *  requests will try to create an default object using this function ).
+   */
+  static TeDatabase* DefaultObject( const TeDatabaseFactoryParams& )
+  {
+    std::cout << std::endl << "TeDatabase::DefaultObject - " <<
+      " - Trying to create an invalid TeDatabase default object." <<
+      std::endl;
+    throw;
+      
+    return 0;
+  };
+  
+	//@}
+
+	/** @name Tables
+	  Methods related to table manipulation.
+		\note refer to data model documentation in order to understand the meanning of 
+		each tables and its fields
+	*/
+	//@{	
+
+	//! Returns a list of tables in a database
+	virtual bool listTables(vector<string>& /* tableList */) { return false; }
+
+	//! Verifies if a table exist in the database
+	virtual bool tableExist(const string& table) = 0;
+	
+	//! Verifies if a table has a column
+	virtual bool columnExist(const string& table, const string& column, TeAttribute& attr) = 0;
+
+	//! Update a column
+	virtual bool allowEmptyString(const string& /* tableName */, const string& /* column */) { return false; }
+
+	//! Verifies and modifies the column names of the table. It returns if the table was modified  
+	virtual bool validTable (TeTable& table);
+
+	//! Return the name of an attribute table given its identifier
+	string getTableName(int tableId);
+
+	//! Return a valid name for a table from a initial one
+	string getNewTableName(const string& n);
+
+	//! Concatenate field values
+	/*!
+      \param fNamesVec vector containing the fields to be concatenated
+	*/
+	virtual string getConcatFieldsExpression(const vector<string>& fNamesVec);
+
+	//! Creates a table
+	/*!
+      \param table table name
+      \param attr table list of attributes
+	 */
+	virtual bool createTable(const string& table, TeAttributeList &attr) = 0;
+
+	//! Deletes a table. Do not allow the deletion of model tables
+	 virtual bool deleteTable (const string& table);
+
+	//! Adds a column to a table
+	/*!
+      \param table table name
+      \param rep representation of the column being created
+	*/
+	virtual bool addColumn (const string& table, TeAttributeRep &rep) = 0;
+
+	//! Deletes a column to a table
+	/*!
+      \param table table name
+      \param colName name of the column being deleted
+	*/
+	virtual bool deleteColumn (const string& table, const string& colName);
+	
+	//! Creates a reationship between two tables
+	/*!
+      \param relName relationship name
+      \param table table that will receive the foreign key
+	  \param fieldName column that will be foreign key
+	  \param relatedTable table that exports the foreign key
+	  \param relatedField field that will the exported foreign key
+	  \param cascadeDeletion flag that indicates if the deletion should be propagated
+	*/
+	virtual bool createRelation (const string& relName, const string& table, const string& fieldName, 
+						const string& relatedTable, const string& relatedField, bool cascadeDeletion) = 0;
+
+	//! Checks if a relation exist
+	/*!
+      \param tableName table where the relashionship exists
+	  \param relName relationship name
+	*/
+	virtual TeDBRelationType existRelation(const string& tableName, const string& relName) = 0;
+
+	//! Removes a relation exist
+	/*!
+	  \param name relationship name
+      \param table table where the relashionship exists
+	  \return TRUE if succeed and FALSE otherwise
+	*/
+	virtual bool deleteRelation(const string& name, const string& table);
+
+	//@}
+	
+	/** @name Query
+	*  Methods related to query the database
+	*/
+	//@{	
+	//! Executes a SQL command that doesnt return a record set. Tipically a data definition comand
+	virtual bool execute ( const string &sql) = 0;
+
+	//! Returns a database portal.
+	/*!
+		A database portal is used to submit queries to the database and to navigate over the
+		resulting record set
+	*/
+	virtual TeDatabasePortal* getPortal () = 0;
+
+	//! Get the values that satisfy the query 
+	virtual bool inClauseValues(const string& query , const string& attribute, vector<string>& inClauseVector);
+
+	//@}
+
+	/** @name  Data Model
+		 Methods that create the database model suggested in TerraLib. 
+		 Classes in TerraLib materialize the DataModel suggested.
+	*/
+	//@{
+	//! Creates the entire TerraLib conceptual model.
+	/*
+      \param withIntegrity flag that indicates that the referencial integrity should be implemented.
+	  \param createIndex flag that indicate that the indexes should be created
+	*/
+	virtual bool createConceptualModel(bool withIntegrity = true, bool newDatabase = true, bool createIndex = true);
+
+	//! Creates the referencial integrity of the conceptual model
+	virtual bool defineIntegrity(void);
+
+	//! Create the indexes for the tables in the conceptual model
+	virtual bool createIndex(const string& tableName, const string& indexName, const string& columnsName);
+
+	//! Creates a table to store version database information 
+	virtual bool createDatabaseTable(); 
+	
+	//! Creates a table to store projectinon information
+	virtual bool createProjectionTable();
+
+	//! Creates a table to store Layers information
+	virtual bool createLayerTable ();
+
+	//! Creates a table to store Representations information
+	virtual bool createRepresentationTable ();
+
+	//! Creates a table to store Views information
+	virtual bool createViewTable ();
+
+	//! Creates a table to store Themes information
+	virtual bool createThemeTable ();
+
+	//! Creates a table to store the groupings associated with a theme
+	virtual bool createGroupingTable();
+
+	//! Creates a table to store information about the attribute tables used by a theme
+	virtual bool createThemeTablesTable();
+
+	//! Creates a table to store legends
+	virtual bool createLegendTable ();
+
+	//! Creates a table to store visual definitions
+	virtual bool createVisualTable();
+
+	//! Creates a table to store raster visual definitions
+	virtual bool createVisualRasterTable();
+
+	//! Creates a table to store information about the non-spatial tables associated to this layer
+	virtual bool createLayerTableTable();
+
+	//! Creates a table to store information about the external tables related to non-spatial tables of layers
+	virtual bool createTablesRelationTable();
+
+	//! Creates a table to store information about projects: an structure that groups views
+	virtual bool createProjectTable();
+
+	//! Creates a table to store the relation between project/views information
+	virtual bool createProjectViewTable();
+	//@}
+
+	/** @name  Project
+		 Methods related to the manipulation of projects
+	*/
+	//@{
+	//! Load information about all projects stored in the database
+	virtual bool loadProjectSet(); 
+
+	//! Load information about a particular project
+	virtual bool loadProject(TeProject* project); 
+	
+	//! Insert information about a project
+	virtual bool insertProject(TeProject *project) = 0;
+	
+	//! Update information about a project
+	virtual bool updateProject(TeProject *project);	
+
+	//! Delete a project from the database
+	virtual bool deleteProject(int projectId);	
+
+	//! Insert a project/view relation
+	virtual bool insertProjectViewRel(int projectId, int viewId);
+
+	//! Deletes a project/view relation
+	virtual bool deleteProjectViewRel(int projectId, int viewId);
+
+	//! Check whether a given project already exists in the database (it is not case sensitive).
+	virtual bool projectExist(const string& projectName);
+	//@}
+
+	/** @name  Geometries
+		 Methods that create tables that store the spatial data
+	*/
+	//@{
+
+	//! Creates a table for a polygon geometries
+	virtual bool createPolygonGeometry (const string& tableName);
+
+	//! Creates a table for line geometries
+	virtual bool createLineGeometry (const string& tableName);
+
+	//! Creates a table for point geometries
+	virtual bool createPointGeometry (const string& tableName);
+
+	//! Creates a table for cell geometries
+	virtual bool createCellGeometry (const string& tableName);
+ 
+	//! Creates a table for a text geometries
+	virtual bool createTextGeometry (const string& tableName);
+
+	//! Creates a table for a arc geometries
+	virtual bool createArcGeometry (const string& tableName);
+
+	//! Creates a table for a node geometries
+	virtual bool createNodeGeometry (const string& tableName);
+
+	//! Creates a table to store raster representations of objects
+	virtual bool createRasterGeometry(const string& tableName);
+
+	//! Creates a table to store information about raster representation
+	virtual bool createRasterMetadataTable(const string& tableName);
+	
+    //! Creates a table for raster geometries
+	virtual bool createRasterTable (const string& tableName);
+
+	//! Creates a table to store information about objects in a theme
+	virtual bool createCollectionTable(const string& tableName);
+	//@}
+
+	/** @name Non-spatial tables
+	*  Retrieving/Inserting/Modifying generic tables in the database. 
+	*/
+	//@{
+	//! Retrieves information about some tables
+	/*
+		\param atts returning vector of tables information 
+		\param attType type of the tables that are being looked for (optional)
+		\return TRUE if any table was found and FALSE otherwise
+	*/
+	virtual bool getAttrTables(TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
+
+	//! Inserts information about a link to an external table
+	/*
+		\param tableId table identification (from te_layer_table)
+		\param tField link column name of the static table
+		\param eTable name of the external table
+		\param eField name of the link column of the related table
+		\param relId returns the identification of the relation
+	*/
+	virtual bool insertRelationInfo(const int tableId, const string& tField,
+									const string& rTable, const string& rField, int& relId) = 0;
+
+	//! Inserts information about an attribute table
+	virtual bool insertTableInfo (int layerId, TeTable &table, const string& user="") = 0;
+
+	//! Updates information about an attribute table
+	virtual bool updateTableInfo (int layerId, TeTable &table, const string user="");
+
+	//! Retrieves the metainformation about an attribute table
+	virtual bool loadTableInfo(TeTable& table);
+
+	//! Saves a table and its contents in the database
+	virtual bool insertTable(TeTable &table);
+
+	//! Alter a property of a table 
+	virtual bool alterTable(const string& tableName, TeAttributeRep& rep, const string& oldColName="");
+
+	//! Alter the table name 
+	virtual bool alterTable(const string& oldTableName, const string& newTablename);
+
+	//! Saves a large binary objects (BLOB) in a row table 
+	virtual bool insertBlob (const string& tableName, const string& columnBlob, TeAttributeRep& columnId, const string& valueId, unsigned char* data, int size);
+
+	//! Saves a large binary objects (BLOB) in a row table 
+	virtual bool insertBlob (const string& tableName, const string& columnBlob, TeAttributeRep& columnId, const string& valueId, const string& fileName);
+
+	//! Saves a large binary objects (BLOB) in a row table 
+	virtual bool insertBlob (const string& tableName, const string& columnBlob, const string& whereClause, unsigned char* data, int size) = 0;
+
+	//! Saves a large binary objects (BLOB) in a row table 
+	virtual bool insertBlob (const string& tableName, const string& columnBlob, const string& whereClause, const string& fileName);
+	
+	//! Updates a table and its contents in the database
+	virtual bool updateTable	(TeTable &table);
+
+	//! Retrieves a table and its contents from the database
+	virtual bool loadTable		(const string& tableName, TeTable &table);
+
+	//! Retrieves a table (or part of it) accordingly to a criteria written in SQL
+	virtual bool selectTable	(const string& tableName, const string& criteria, TeTable &table);
+
+	//!	Deletes all tables, of a particular type, associated to a layer
+	virtual bool deleteLayerTable	(int layerId, TeAttrTableType ttype = TeAttrStatic);
+	//@}
+
+	/** @name Projection
+	*  Accessing/Inserting/Modifying projection information into the database. 
+	*/
+	//@{ 	
+
+	//! Insert information about a geographical projection
+	virtual bool insertProjection (TeProjection *proj) = 0;	
+
+	//! Updates information about a geographical projection
+	virtual bool updateProjection (TeProjection *proj);	
+
+	//! Retrieves information about a geographical projection identified by its database id
+	virtual TeProjection* loadProjection (int id);
+	//@}
+
+	/** @name Layers
+	*  Retrieving/Inserting/Modifying/Deleting layers in the database. 
+	*/
+	//@{ 
+	//! Insert information about a layer
+	virtual bool insertLayer	(TeLayer *layer) = 0;
+	
+	//! Update information about a layer
+	virtual bool updateLayer	(TeLayer *layer);	
+
+	//! Load information about all layers stored in the database
+	/*
+		\param loadAttrList  indicates if the attribute list of each attribute table should be loaded
+	*/
+	virtual bool loadLayerSet	(const bool& loadAttrList = true);
+
+	//! Load information about a particular layer 
+	/*
+		\param layer		a pointer to a layer that will be loaded from database
+		\param loadAttrList indicates if the attribute list of each attribute table should be loaded
+	*/
+	virtual bool loadLayer		(TeLayer* layer, const bool& loadAttrList = true);
+
+	//! Load layer tables 
+	/*
+		\param layer		a pointer to a layer whose attribute table will be loaded from database
+		\param loadAttrList indicates if the attribute list of each attribute table should be loaded
+	*/
+	virtual bool loadLayerTable (TeLayer* layer, const bool& loadAttrList = true);
+
+	//! Delete a particular layer passing its id
+	virtual bool deleteLayer	(int layerId);
+
+	//! Check if a particular layer exists (passing its id)
+	virtual bool layerExist		(int id);
+
+	//! Check if a particular layer exists (passing its name)
+	virtual bool layerExist		(string layerName);
+
+	//! Checks whether a given layer name is valid or already exists in the database
+	/*!
+		\param n		layer name to be checked
+		\return the modified valid layer name
+	*/	
+	virtual string getNewLayerName(const string& n);
+	//@}
+
+	/** @name Representation
+	*  Retrieving/Inserting/Modifying/Deleting representations in the database. 
+	*/
+	//@{ 
+	//! Inserts information about a geometrical representation
+	virtual bool insertRepresentation (int layerId, TeRepresentation& rep) = 0;	
+
+	//! Updates information about a geometrical representation
+	virtual bool updateRepresentation (int layerId, TeRepresentation& rep);	
+
+	//! Updates the box information of a layer in the corresponding metadata table
+	virtual bool updateLayerBox(TeLayer* layer);
+
+	//@}
+
+	/** @name Raster Tables
+	*  Retrieving/Inserting/Modifying/Deleting raster representations in the database. 
+	*/
+	//@{ 
+	//! Inserts information about a raster geometry associated to an object
+	/*!
+		\param tableName name of the table that stores the raster representation
+		\param par raster parameters 
+		\param objectId identification of the object associated to the raster geometry
+	*/
+	virtual bool insertRasterGeometry(const string& tableName, TeRasterParams& par, const string& objectId = "");
+
+	//! Updates the information about the raster geometry associated to an object of a layer
+	/*!
+		\param layerId layer unique database identification
+		\param par raster parameters 
+		\param objectId identification of the object associated to the raster geometry
+	*/
+	virtual bool updateRasterRepresentation(int layerId, TeRasterParams& par, const string& objectId="");
+
+	//! Returns the name of the table where the raster geometry associated to an object of a leyr
+	/*!
+		\param layerId layer unique database identification
+		\param objectId identification of the object associated to the raster geometry
+	*/
+	virtual string getRasterTable(int layerId, const string& objectId);
+	
+	//! Inserts metadata information about a particular raster geometry
+	/*!
+		\param tableName name of the table that stores the metadata
+		\param geomId  geometry unique database identification
+		\param par raster parameters 
+	*/
+	virtual bool insertRasterMetadata (const string& tableName, int geomId, TeRasterParams& par);
+
+	//! Updates metadata information about a particular raster geometry
+	/*!
+		\param tableName name of the table that stores the metadata
+		\param geomId  geometry unique database identification
+		\param par raster parameters 
+
+	*/	
+	virtual bool updateRasterMetadata (const string& tableName, int geomId, TeRasterParams& par);
+	//@}
+	/** @name Views
+	*  Retrieving/Inserting/Modifying/Deleting views in the database. 
+	*/
+	//@{ 
+	//! Inserts a view
+	virtual bool insertView (TeView *view) = 0;	
+
+	//! Updates a view
+	virtual bool updateView (TeView *view);	
+
+	//! Loads a set of views belonging to a user
+	/*
+		\param user			 the user name 
+		\param loadAttrList  indicates if the attribute list of each attribute table should be loaded
+		\param visualClass  identifies which concrete class od visual should be instantiated.
+		The default is TerraLib basic visual.
+	*/
+	virtual bool loadViewSet (const string& user, const bool& loadAttrList = true, const string& visualClass="tevisual");
+
+	//! Load a view
+	/*
+		\param view			a pointer to a view that will be loaded from database
+		\param loadAttrList indicates if the attribute list of each attribute table should be loaded
+		\param visualClass  identifies which concrete class od visual should be instantiated.
+		The default is TerraLib basic visual.
+	*/
+	virtual bool loadView (TeView* view, const bool& loadAttrList = true, const string& visualClass="tevisual");
+
+	//! Delete a view
+	virtual bool deleteView (int viewId);
+
+	//! Recursive inserting of a view tree.
+	virtual bool insertViewTree (TeViewTree *tree) = 0;	
+
+	//! Recursive load view tree.
+	/*
+		\param view			a pointer to a view that will be loaded from database
+		\param id			a specific theme or viewtree id of this view that will be loaded from database
+		\param loadAttrList indicates if the attribute list of each attribute table should be loaded
+		\param visualClass  identifies which concrete class od visual should be instantiated.
+		The default is TerraLib basic visual.
+	*/
+	virtual TeViewTree* loadViewTree(TeView* view, int id, const bool& loadAttrList = true, const string& visualClass = "tevisual");
+
+	//! Recusive updating of a view tree.
+	virtual bool updateViewTree (TeViewTree *tree);
+	
+	//! Check whether a given view already exists in the database
+	virtual bool viewExist(string viewName);
+
+	//@}
+
+	/** @name Themes
+	*  Retrieving/Inserting/Modifying/Deleting themes and group of themes in the database. 
+	*/
+	//@{ 
+	//! Inserts a group of themes in the database
+	virtual bool insertThemeGroup	(TeViewTree* tree) = 0;
+
+	//! Inserts an abstract theme in the database.
+	virtual bool insertTheme		(TeAbstractTheme *theme) = 0; 	
+
+	//! Updates an asbtract theme in the database
+	virtual bool updateTheme		(TeAbstractTheme *theme);
+
+	//! Loads a theme from the database
+	virtual bool loadTheme			(TeAbstractTheme *theme, const bool& loadAttrList = true, const string& visualClass = "tevisual");
+
+	//! Loads all attribute tables of a theme
+	virtual bool loadThemeTable		(TeTheme* theme, const bool& loadAttrList = true);
+
+	//! Erases the theme group identified by themeId
+	virtual bool deleteThemeGroup	(int themeId);
+
+	//! Erases the theme identified by themeId
+	virtual bool deleteTheme		(int themeId);
+
+	//! Erases the legends of a theme identified by themeId
+	virtual bool deleteLegend		(int themeId);
+	
+	//! Inserts information about a table used by a theme 
+	bool insertThemeTable(TeTheme *theme, TeTable& inputTable);
+
+	//! Inserts information about a table used by a theme 
+	virtual bool insertThemeTable	(int themeId, int tableId, int relationId, int tableOrder) = 0; 
+
+	//! Updates  information about the tables used by a theme 
+	virtual bool updateThemeTable	(TeTheme *theme);
+	
+	//! Removes a table from the theme
+	bool removeThemeTable(TeTheme *theme, int tableOrder);
+
+	//! Inserts information about a grouping used in a theme
+	virtual bool insertGrouping (int themeId, const TeGrouping& grouping);
+
+	//! Updates information about a grouping used in a theme
+	virtual bool updateGrouping (int themeId, const TeGrouping& grouping);
+
+	//! Generates the label position (x,y) to each object of a theme or of a particular object
+	virtual bool generateLabelPositions(TeTheme *theme, const std::string& objectId = "");
+
+	//! Check whether a given theme already exists in the database
+	virtual bool themeExist(string themeName);
+
+	//! Checks whether a given theme name is valid or already exists in the database
+	/*!
+		\param n		theme name to be checked
+		\return the modified valid theme name
+	*/	
+	virtual string getNewThemeName(const string& n);
+
+	//@}
+
+	/** @name Legend
+	*  Retrieving/Inserting/Modifying/Deleting legends in the database. 
+	*/
+	//@{ 
+	//! Inserts legend in the database
+	virtual bool insertLegend	(TeLegendEntry *legend) = 0;	
+	//! Updates legend entries in the database
+	virtual bool updateLegend	(TeLegendEntry *legend);	
+
+	virtual bool updateLegend   (vector<TeLegendEntry>& legVec);
+	virtual bool loadLegend		(TeAbstractTheme *theme, const string& visualClass = "tevisual");
+	virtual bool updateVisual	(TeLegendEntry *legend);
+	virtual bool updateVisual   (vector<TeLegendEntry>& legVec);
+	//@}
+
+	/** @name Polygon
+	// Accessing/Inserting/Modifying polygon geometries into the database
+	*/
+	//@{ 
+	//! Inserts a polygon set in a geometry table
+	virtual bool insertPolygonSet (const string& table, TePolygonSet &ps);	
+
+	//! Updates a polygon set in a geometry table
+	virtual bool updatePolygonSet (const string& table, TePolygonSet &ps);	
+
+	//! Returns all polygons in a table given a criteria expressed as an SQL where statement
+	virtual bool selectPolygonSet (const string& table, const string& criteria, TePolygonSet &ps);
+
+	//! Returns all polygons that represents objects of a particular theme
+	virtual bool loadPolygonSet	(TeTheme* theme, TePolygonSet &ps);
+
+	//! Returns all polygons  that represents objects of a particular geoid
+	virtual bool loadPolygonSet	(const string& table, const string& geoid, TePolygonSet &ps);
+
+	//! Returns all polygons inside a given box
+	virtual bool loadPolygonSet	(const string& table, TeBox &box, TePolygonSet &ps);
+
+	//! Returns a database portal to iterate over the polygons that are inside a given box
+	/*
+		\return A database portal pointer if there is any polygons inside the box
+		\return A null pointer if there isn't polygons to iterate
+		\note The database portal pointer should be deleted by the application
+	*/
+	virtual TeDatabasePortal* loadPolygonSet(const string& table, TeBox &box);
+
+	//! Returns the first polygon that contais a given coordinate
+	virtual bool locatePolygon		(const string& table, TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
+
+	//! Returns the polygons that contains a give coordinate
+	virtual bool locatePolygonSet   (const string& table, TeCoord2D &pt, double tol, TePolygonSet &polygons);
+
+	//! Inserts a polygon in a geometry table
+	virtual bool insertPolygon		(const string& table, TePolygon &p) = 0;	
+
+	//! Updates a polygon in a geometry table
+	virtual bool updatePolygon		(const string& table, TePolygon &p) = 0;
+	//@}
+
+	/** @name Line
+	*  Accessing/Inserting/Modifying Line geometries into the database. 
+	*/
+	//@{ 	
+	// Accessing/Inserting line geometries into the database
+	virtual bool insertLineSet	(const string& table, TeLineSet &ls);	
+	virtual bool updateLineSet	(const string& table,TeLineSet &ls);
+	virtual bool loadLineSet	(const string& table, const string& geoid, TeLineSet &ls);
+    virtual bool loadLineSet	(TeTheme* theme, TeLineSet &ls);
+	virtual bool loadLineSet	(const string& table, TeBox &box, TeLineSet &linSet);
+	virtual TeDatabasePortal*    loadLineSet (const string& table, TeBox &box);
+	virtual bool selectLineSet	(const string& table, const string& criteria, TeLineSet &ls);
+
+    virtual bool insertLine		(const string& table, TeLine2D &l) = 0;		
+	virtual bool updateLine		(const string& table, TeLine2D &l) = 0;
+	virtual bool locateLine		(const string& table, TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
+	virtual bool locateLineSet	(const string& table, TeCoord2D &pt, TeLineSet & ls, const double& tol = 0.0);
+
+	//@}
+
+	/** @name Point
+	*  Accessing/Inserting/Modifying Point geometries into the database. 
+	*/
+	//@{ 	
+	// Accessing/Inserting point geometries into the database
+	virtual bool insertPointSet	(const string& table, TePointSet &ps);	
+    virtual bool updatePointSet (const string& table, TePointSet &ps);
+	virtual bool loadPointSet	(const string& table, TeBox &box, TePointSet &ps);
+	virtual TeDatabasePortal* loadPointSet	(const string& table, TeBox &box);
+	virtual bool loadPointSet	(const string& table, const string& geoid, TePointSet &ps);
+	virtual bool loadPointSet	(TeTheme* theme, TePointSet &ps);
+	virtual bool selectPointSet (const string& table, const string& criteria, TePointSet &ps);
+
+    virtual bool insertPoint	(const string& table, TePoint &p) = 0;	
+	virtual bool updatePoint	(const string& table, TePoint &p);
+	virtual bool locatePoint	(const string& table, TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
+	virtual bool locatePointSet (const string& table, TeCoord2D &pt, TePointSet &pointSet, const double& tol=0.0);
+	//@}
+
+	/** @name Text
+	*  Accessing/Inserting/Modifying Text geometries into the database. 
+	*/
+	//@{ 	
+	// Accessing/Inserting text geometries into the database
+	virtual bool insertTextSet	(const string& table, TeTextSet &ts);	
+	virtual bool updateTextSet	(const string& table, TeTextSet &ts);	
+	virtual bool loadTextSet	(const string& table, const string& geoid, TeTextSet &ts);
+	virtual bool selectTextSet	(const string& table, const string& criteria, TeTextSet &ts);
+
+	virtual bool insertText		(const string& table, TeText &t) = 0;	
+	virtual bool updateText		(const string& table, TeText &t);
+	virtual bool locateText		(const string& table, TeCoord2D &pt, TeText &text, const double& tol = 0.0);
+	virtual bool locateTextSet	(const string& table, TeCoord2D &pt, TeTextSet &textSet, const double& tol = 0.0);
+	//@}
+
+	/** @name Arc
+	*  Accessing/Inserting/Modifying Arc geometries  into the database. 
+	*/
+	//@{ 	
+	//! Inserts an arc set geometry in the database.
+	virtual bool insertArcSet	(const string& table, TeArcSet &as);	
+
+	//! Updates arc set geometry in the database.
+	virtual bool updateArcSet	(const string& table, TeArcSet &as);	
+
+	//! Loads an arc geometry from the database that has the specified object id (geoid).
+	virtual bool loadArcSet		(const string& table, const string& geoid, TeArcSet &as);
+
+	//! Inserts an arc geometry in the database.
+	virtual bool insertArc		(const string& table,TeArc &arc) = 0;
+
+	//! Updates an arc geometry in the database.
+	virtual bool updateArc		(const string& table,TeArc &arc);
+	//@}
+
+	/** @name Node
+	*  Accessing/Inserting/Modifying Node geometries into the database. 
+	*/
+	//@{ 	
+	// Accessing/Inserting node geometries into the database
+	virtual bool insertNodeSet	(const string& table, TeNodeSet &ns);	
+	virtual bool updateNodeSet	(const string& table, TeNodeSet &ns);	
+	virtual bool loadNodeSet	(const string& table, const string& geoid, TeNodeSet &ps);
+
+	virtual bool insertNode		(const string& table, TeNode &node) = 0;	
+	virtual bool updateNode		(const string& table, TeNode &node);	
+	//@}
+
+	/** @name Cell
+	*  Accessing/Inserting/Modifying Cell geometries  into the database. 
+	*/
+	//@{ 	
+	// Accessing/Inserting cell geometries into the database
+	virtual bool insertCellSet	(const string& table, TeCellSet &cs);	
+	virtual bool updateCellSet	(const string& table, TeCellSet &cs);	
+	virtual bool loadCellSet	(const int& layerId, const string& table, const string& geoid, TeCellSet &cs);
+	virtual bool selectCellSet	(const int& layerId, const string& table, const string& criteria, TeCellSet &cs);
+
+	virtual bool insertCell		(const string& table, TeCell &c) = 0;
+	virtual bool updateCell		(const string& table, TeCell &c);
+	virtual bool locateCell		(const string& table, TeCoord2D &pt, TeCell &c, const double& tol = 0.0);
+	//@}
+	
+	//! Insert a raster block into the database
+	/*!
+      \param table table name
+	  \param blockId block unique identifier
+	  \param ll  block lower left coordinate
+	  \param ur  block upper right coordinate
+	  \param buf block binary data
+	  \param size block size
+	  \param band block band
+	  \param res block resolution factor
+	  \param subband sub band definitiion
+	*/
+	virtual	bool insertRasterBlock(const string& table, const string& blockId, const TeCoord2D& ll, const TeCoord2D& ur, unsigned char *buf,unsigned long size, int band=0, unsigned int res=1, unsigned int subband=0) = 0;
+
+	//! Inserts the entire visual of a Legend
+	virtual	bool insertVisual (TeLegendEntry *legend);
+
+	//! Insert raster visual
+	virtual bool insertRasterVisual (int themeId , TeRasterVisual* rasterVisual);
+
+	//! Returns the raster associated to a layer
+	virtual TeRaster* loadLayerRaster(int layerId, const string& objectId="", const char& mode = 'r');
+
+	//! Creates a lookup table (used for pallete raster representations)
+	virtual bool createLUTTable(const string& name);
+
+	//! Loads a look up table associated to a raster and fills its parameters
+	virtual bool loadRasterLUT(TeRasterParams* par);
+
+	//! Creates a spatial index for a spatial table. In order to get correct column names to index, see getSpatialIdxColumn method.
+	virtual bool createSpatialIndex(const string& table, const string& columns, TeSpatialIndexType /*type*/ = TeRTREE,short /* level */ =0,short /* tile */ =0);
+
+	//! Creates a spatial metadata for a spatial table. It is implemented only in spatial databases.
+	virtual bool insertMetadata(const string& /* table */, const string& /* column */, double /* tolx */, double /* toly */,TeBox &/* box */,short /* srid */ =0) { return true; };
+
+	//! Returns the name of the column that wiil be the spatially indexed, for a given type of geometry table 
+	virtual string getSpatialIdxColumn(TeGeomRep rep);
+
+	//! Update box information in a table that has a set of columns to store a box value
+	/*
+		This method gives to the drivers the ability to update box columns, considering precision issues
+		that are particular to the driver. The box should be stored in 4 columns (lower_x, lower_y, upper_x, upper_y)
+		\param tableName table name
+		\param keyColumnName name of the column that is primary key
+		\param idValue key value of the row that should be updated
+		\param box new box value
+	*/
+   virtual bool updateBBox(const string& tableName, const string& keyColumnName, int keyValue, const TeBox& box);  
+
+
+	/** @name Spatial Operations with vector data
+	*  spatial operations over geometries into the database. 
+	*/
+	//@{ 	
+
+	/** @name topologic relation query
+	*  topologic relation query over geometries into the database. 
+	*/
+	//@{
+	/*!
+	  \brief Returns the geometries of a geometric table (actGeomTable) that have a specific spatial relation (relate) with a subset of geometries of this table (actGeomTable)   
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the geometric table
+	  \param actIdsIn		identifiers of a geometry subset of the actGeomTable table 
+	  \param portal			a pointer to a database portal that will contain the resulted geometries
+	  \param relate			spatial relation
+	  \param actCollTable	collection table name
+	 */
+	virtual bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+		TeDatabasePortal *portal, int relate, const string& actCollTable="");
+	
+	/*!
+	  \brief Returns the geometries of a geometric table (visGeomTable) that have a specific spatial relation (relate) with a subset of geometries of other geometric table (actGeomTable)   
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the actGeomTable table
+	  \param actIdsIn		identifiers of a geometry subset of the actGeomTable table 
+	  \param visGeomTable	geometric table name
+	  \param visRep			geometric representation of the visGeomTable table
+	  \param portal			a pointer to a database portal that will contain the resulted geometries
+	  \param relate		 	spatial relation
+	  \param visCollTable	collection table name associated with the visGeomTable table
+	 */
+	virtual bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+		const string& visGeomTable, TeGeomRep visRep, TeDatabasePortal *portal, 
+		int relate, const string& visCollTable=""); 
+
+	/*!
+	  \brief Returns the geometries of a geometric table (actGeomTable) that have a specific spatial relation (relate) with a geometry in memory (geom)
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the actGeomTable table
+	  \param geom			a pointer to a geometry in memory
+	  \param portal			a pointer to a database portal that will contain the resulted geometries
+	  \param relate			spatial relation
+	  \param actCollTable	collection table name associated with the actGeomTable table
+	 */
+	virtual bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, 
+		TeDatabasePortal *portal, int relate, const string& actCollTable=""); 
+		
+	/*!
+	  \brief Returns the geometries of a geometric table (actGeomTable) that have a specific spatial relation (relate) with a subset of geometries of this table (actGeomTable)   
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the geometric table
+	  \param actIdsIn		identifiers of a geometry subset of the actGeomTable table 
+	  \param actIdsOut		structure that will contain the identifiers of the resulted geometries
+	  \param relate			spatial relation
+	  \param actCollTable	collection table name
+	 */
+	virtual bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+		TeKeys& actIdsOut, int relate, const string& actCollTable="");
+
+	/*!
+	  \brief Returns the geometries of a geometric table (visGeomTable) that have a specific spatial relation (relate) with a subset of geometries of other geometric table (actGeomTable)   
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the actGeomTable table
+	  \param actIdsIn		identifiers of a geometry subset of the actGeomTable table 
+	  \param visGeomTable	geometric table name
+	  \param visRep			geometric representation of the visGeomTable table
+	  \param visIdsOut		structure that will contain the identifiers of the resulted geometries
+	  \param relate			spatial relation
+	  \param visCollTable	collection table name associated with the visGeomTable table
+	 */
+	virtual bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+		const string& visGeomTable, TeGeomRep visRep, TeKeys& visIdsOut, int relate, 
+		const string& visCollTable="", TeDatabase* = 0); 
+
+	/*!
+	  \brief Returns the geometries of a geometric table (actGeomTable) that have a specific spatial relation (relate) with a geometry in memory (geom)
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the actGeomTable table
+	  \param geom			a pointer to a geometry in memory
+	  \param actIdsOut		structure that will contain the identifiers of the resulted geometries
+	  \param relate			spatial relation
+	  \param actCollTable	collection table name associated with the actGeomTable table
+	*/
+	virtual bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, 
+		TeKeys& actIdsOut, int relate, const string& actCollTable=""); 
+	//@}
+	
+	/** @name metric functions
+	*  metric functions over geometries into the database. 
+	*/
+	//@{
+	/*!
+		\brief Calculates the area of a geometry set of the geometric table (actGeomTable) 
+		\param actGeomTable	geometric table name
+		\param actRep		geometric representation of the geometric table
+		\param actIdsIn		identifiers of the geometry set of the actGeomTable table 
+		\param area			the returned area value 
+	 */
+	virtual bool calculateArea(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, double &area);
+
+	/*!
+		\brief Calculates the length of a geometry set of the actGeomTable table 
+		\param actGeomTable	geometric table name
+		\param actRep		geometric representation of the geometric table
+		\param actIdsIn		identifiers of the geometry set of the actGeomTable table 
+		\param length		the returned length value 
+	 */
+	virtual bool calculateLength(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, double &length);
+	
+	/*!
+		\brief Calculates the distance between two geometries of the actGeomTable table 
+		\param actGeomTable	geometric table name
+		\param actRep		geometric representation of the geometric table
+		\param Ids			identifiers of the two geometries of the actGeomTable table 
+		\param distance		the returned distance value 
+	 */
+	virtual bool calculateDistance(const string& actGeomTable, TeGeomRep actRep, TeKeys& Ids, double& distance);
+
+	/*!
+		\brief Calculates the distance between a geometry of a geometric table (actGeomTable) and a geometry of other geometric table (visGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of the geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visRep			geometric representation of the visGeomTable table
+		\param objId2			identifier of the geometry of the visGeomTable table
+		\param distance			the returned distance value 
+	 */
+	virtual bool calculateDistance(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& visGeomTable, TeGeomRep visRep, const string& objId2, double& distance);
+
+	/*!
+	  \brief Returns the geometries of a geometric table (actGeomTable) that are within a specific distance from a point in memory 
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the actGeomTable table
+	  \param point			a point in memory
+	  \param IdsDistOut		structure that will contain the identifiers of the resulted geometries and their distances
+	  \param max_distance	maximum distance 
+	  \param actCollTable	collection table name associated with the actGeomTable table
+	*/
+	virtual bool withinDistance(const string& actGeomTable, TeGeomRep actRep, const TeCoord2D& point, 
+		TeKeysToDist& IdsDistOut, const double& max_distance, const string& actCollTable="");
+	//@}
+
+
+	/** @name functions that generate new geometries 
+	*  functions that generate new geometries over geometries into the database. 
+	*/
+	//@{
+	/*!
+		\brief Returns the buffers with a specific distance of a geometry set of a geometric table (actGeomTable)
+		\param actGeomTable	geometric table name
+		\param actRep		geometric representation of the geometric table
+		\param actIds		identifiers of the geometry set of the actGeomTable table 
+		\param bufferSet	the returned buffers 
+		\param dist			the distance of the buffers
+	 */
+	virtual bool buffer(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TePolygonSet& bufferSet, double dist);
+
+	/*!
+		\brief Returns the centroids of a geometry set of a geometric table (actGeomTable)
+		\param actGeomTable	geometric table name
+		\param actRep		geometric representation of the geometric table
+		\param centroidSet	the returned centroids 
+		\param actIds		identifiers of the geometry set of the actGeomTable table 
+		\param actCollTable collection table name associated with the actGeomTable table 
+	*/
+	virtual bool centroid(const string& actGeomTable, TeGeomRep actRep, TePointSet& centroidSet, TeKeys actIds = vector<string>(), const string& actCollTable = "");
+
+	/*!
+		\brief Returns the convex geometries of a geometries set of a geometric table (actGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the geometric table
+		\param actIds			identifiers of the geometry set of the actGeomTable table 
+		\param convexHullSet	the returned convex geometries 
+	*/
+	virtual bool convexHull(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TePolygonSet& convexHullSet);
+	//@}
+
+	/*!
+		\brief Returns the nearest neighbors of a specific geometry of a geometric table (actGeomTable)
+		\param actGeomTable		geometric table name
+		\param actCollTable		collection table name associated with the actGeomTable table
+		\param actRep			geometric representation of the geometric table
+		\param objId1			identifier of the geometry of the actGeomTable table
+	    \param actIdsOut		structure that will contain the identifiers of the nearest neighbors 
+		\param numRes			the number of nearest neighbors that will be returned
+	*/
+	virtual bool nearestNeighbors(const string& actGeomTable, const string& actCollTable,
+		TeGeomRep actRep, const string& objId1, TeKeys& actIdsOut, int numRes=1);
+	
+	/*!
+		\brief Returns the nearest neighbors of a geometric table (visGeomTable) of a specific geometry of other geometric table (actGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of the geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visCollTable		collection table name associated with the visGeomTable table
+		\param visRep			geometric representation of the visGeomTable table
+	    \param visIdsOut		structure that will contain the identifiers of the nearest neighbors 
+		\param numRes			the number of nearest neighbors that will be returned
+	*/
+	virtual bool nearestNeighbors(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& visGeomTable, const string& visCollTable, 
+		TeGeomRep visRep, TeKeys& visIdsOut, int numRes=1); 
+
+	/*!
+		\brief Returns the nearest neighbors of a specific geometry of a geometric table (actGeomTable)
+		\param actGeomTable		geometric table name
+		\param actCollTable		collection table name associated with the actGeomTable table
+		\param actRep			geometric representation of the geometric table
+		\param objId1			identifier of the geometry of the actGeomTable table
+	    \param portal			a pointer to a database portal that will contain the identifiers of the nearest neighbors 
+		\param numRes			the number of nearest neighbors that will be returned
+	*/
+	virtual bool nearestNeighbors(const string& actGeomTable, const string& actCollTable, 
+		TeGeomRep actRep, const string& objId1, TeDatabasePortal* portal, int numRes=1);
+
+	/*!
+		\brief Returns the nearest neighbors of a geometric table (visGeomTable) of a specific geometry of other geometric table (actGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of the geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visCollTable		collection table name associated with the visGeomTable table
+		\param visRep			geometric representation of the visGeomTable table
+	    \param portal			a pointer to a database portal that will contain the identifiers of the nearest neighbors 
+		\param numRes			the number of nearest neighbors that will be returned
+	*/
+	virtual bool nearestNeighbors(const string& actGeomTable, TeGeomRep actRep, 
+		const string& objId1, const string& visGeomTable, const string& visCollTable, 
+		TeGeomRep visRep, TeDatabasePortal* portal, int numRes=1); 
+
+	/** @name set functions
+	*  functions of set: union, intersection, difference and symmetrical difference. 
+	*/
+	//@{
+
+	/*!
+		\brief Returns the intersection between two geometries of a geometric table (actGeomTable) 
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param actIds		identifiers of the geometry set of the actGeomTable table 
+		\param geomVect			the returned intersection 
+	 */
+	virtual bool geomIntersection(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the intersection between a geometry of a geometric table (actGeomTable) and a geometry of other geometric table (visGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of a geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visRep			geometric representation of the visGeomTable table
+		\param objId2			identifier of other geometry of the visGeomTable table
+		\param geomVect			the returned intersection 
+	 */
+	virtual bool geomIntersection(const string& actGeomTable, TeGeomRep actRep, const string& objId1,
+		const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the difference between two geometries of a geometric table (actGeomTable) 
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of a geometry of the actGeomTable table
+		\param objId2			identifier of other geometry of the actGeomTable table
+		\param geomVect			the returned difference 
+	 */
+	virtual bool geomDifference(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& objId2, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the difference between a geometry of a geometric table (actGeomTable) and a geometry of other geometric table (visGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of a geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visRep			geometric representation of the visGeomTable table
+		\param objId2			identifier of other geometry of the visGeomTable table
+		\param geomVect			the returned difference 
+	 */
+	virtual bool geomDifference(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the union between geometries of a geometric table (actGeomTable) 
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param actIds			identifiers of the geometry set of the actGeomTable table 
+		\param geomVect			the returned union 
+	 */
+	virtual bool geomUnion(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the union between a geometry of a geometric table (actGeomTable) and a geometry of other geometric table (visGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of a geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visRep			geometric representation of the visGeomTable table
+		\param objId2			identifier of other geometry of the visGeomTable table
+		\param geomVect			the returned union 
+	 */
+	virtual bool geomUnion(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the symmetrical difference between two geometries of a geometric table (actGeomTable) 
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of a geometry of the actGeomTable table
+		\param objId2			identifier of other geometry of the actGeomTable table
+		\param geomVect			the returned symmetrical difference 
+	 */
+	virtual bool geomXOr(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& objId2, TeGeometryVect& geomVect);
+
+	/*!
+		\brief Returns the symmetrical difference between a geometry of a geometric table (actGeomTable) and a geometry of other geometric table (visGeomTable)
+		\param actGeomTable		geometric table name
+		\param actRep			geometric representation of the actGeomTable table
+		\param objId1			identifier of a geometry of the actGeomTable table
+		\param visGeomTable		geometric table name
+		\param visRep			geometric representation of the visGeomTable table
+		\param objId2			identifier of other geometry of the visGeomTable table
+		\param geomVect			the returned symmetrical difference 
+	 */
+	virtual bool geomXOr(const string& actGeomTable, TeGeomRep actRep, const string& objId1, 
+		const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);	
+	//@}
+
+	/** @name Spatial Operations with raster data
+	*  spatial operations over raster data into the database. 
+	*/
+	//@{ 	
+	/*!
+		\brief Returns the statistics of raster data regions inside a geometry set of a geometric table (actGeomTable)
+		\param rasterTable		raster table name
+		\param actGeomTable		geometric table name that contains polygons
+		\param Ids				identifiers of the geometries of the actGeomTable table that define the regions in the raster data  
+		\param result			structure that will contain the resulted statistics 
+	*/
+	virtual bool zonal(const string& rasterTable, const string& actGeomTable, TeKeys& Ids, TeObjectStatistics& result);
+	
+	/*!
+		\brief Returns the statistics of raster data regions inside a geometry set of a geometric table (actGeomTable)
+		\param rasterTable		raster table name
+		\param actGeomTable		geometric table name that contains polygons
+		\param actCollTable		collection table that contains the identifiers of the geometries of the actGeomTable table that define the regions in the raster data  
+		\param result			structure that will contain the resulted statistics 
+	*/
+	virtual bool zonal(const string& rasterTable, const string& actGeomTable, const string& actCollTable, TeObjectStatistics& result);
+	
+	/*!
+		\brief Returns the statistics of a raster data region inside a geometry in memory 
+		\param rasterTable		raster table name
+		\param poly				the geometry in memory that define a region in the raster data 
+		\param result			structure that will contain the resulted statistics 
+	*/
+	virtual bool zonal(const string& rasterTable, TePolygon& poly, TeStatisticsDimensionVect& result);
+
+	/*!
+		\brief Clips a raster data from a geometry of a geometric table (actGeomTable)
+		\param rasterTable		raster table name
+		\param actGeomTable		geometric table name that contains polygons
+		\param objId			identifier of the geometry of the actGeomTable table 
+		\param nameLayerOut		the layer name that will contain the result 
+		\param st				the strategy used in the clipping of the raster data
+	*/
+	virtual bool mask(const string& rasterTable, const string& actGeomTable, const string& objId, const string& nameLayerOut, TeStrategicIterator st);
+	
+	/*!
+		\brief Clips a raster data from a geometry in memory (poly)
+		\param rasterTable		raster table name
+		\param poly				a geometry in memory 
+		\param nameLayerOut		the layer name that will contain the result 
+		\param st				the strategy used in the clipping of the raster data
+	*/
+	virtual bool mask(const string& rasterTable, TePolygon& poly, const string& nameLayerOut, TeStrategicIterator st);
+	//@}
+	
+	/** @name specifics SQLs
+	*  return SQL strings 
+	*/
+	//@{ 	
+	//! Return a string that describes a where clause in SQL to return the geometries inside the box
+	virtual string getSQLBoxWhere (TeBox &box, TeGeomRep rep);
+
+	//! Return a string that describes a where clause in SQL to return the geometries of the table2 that are 
+	//! inside the geometries box of the table1 (table1 must have lower_x, lower_y...) 
+	virtual string getSQLBoxWhere (const string& table1, const string& table2, TeGeomRep rep2, TeGeomRep rep1 = TePOLYGONS);
+
+	//! Return a string SQL to be used in the clause SELECT to select the box (lower_x, lower_y, upper_x, upper_y)
+	virtual string getSQLBoxSelect (const string& tableName, TeGeomRep rep);
+
+	//! Return a string SQL to calculate the statistics of some attributes
+	virtual string getSQLStatistics (TeGroupingAttr& attrs);
+	
+	//! Return the database function in SQL to generate autonumber values
+	virtual string getSQLAutoNumber(const string& table);
+
+	//! Return a string SQL to temporal where
+	virtual string getSQLTemporalWhere (TeTimeInterval& /* timeInterval */, TeTemporalRelation /* timeOperator */, const string& /* initialTime */, const string& /* finalTime */ );
+
+	//! Return a string SQL to temporal where 
+	virtual string getSQLTemporalWhere (const string& temporalRest);
+		
+	//! Return a string SQL to temporal where
+	virtual string getSQLTemporalWhere(int /* time1 */, int /* time2 */, TeChronon /* chr */, TeTemporalRelation /* rel */, const string& /* initialTime */, const string& /* finalTime */);
+
+	//! Returns a valid SQL time string
+	virtual string getSQLTime(TeTime& /* time */) { return ""; };
+
+	//! Returns a SQL temporal expression applied to a column
+	virtual string getSQLTemporalFunction (TeChronon chr, const string& colName);
+	//@}
+
+	//! Return the box of a specific geometry (object_id)  
+	virtual bool getMBRGeom(string tableGeom, string object_id, TeBox& box, string colGeom);
+
+	//! Return the box of a select objects set 
+	virtual bool getMBRSelectedObjects(string geomTable,string colGeom, string fromClause, 
+		string whereClause, string afterWhereClause, TeGeomRep repType,TeBox &bout, const double& tol = 0.0);
+
+	//! Gets the list of attributes of a table
+	virtual bool getAttributeList(const string& tableName,TeAttributeList& attList);
+
+	//! Escape special characters in a string to be used in a SQL statement
+	virtual string  escapeSequence(const string& from) = 0;
+
+	//! Returns theme box
+	virtual TeBox getThemeBox(TeTheme* theme);
+
+	//! Returns the container of legend title alias
+	map<int, map<string, string> >& mapThemeAlias() {return metaModel_->mapThemeAlias();}
+
+	//! Concat values in a vector using unionString as the join between each value
+	virtual string concatValues(vector<string>& values, const string& unionString) = 0;
+
+	//! Returns the SQL function for upper case
+	virtual string toUpper(const string& value) = 0;
+
+	//! Returns the SQL function for substring that starts from left to right with informed length.
+	virtual string leftString(const string& /*name*/, const int& /*length*/){return "";}
+
+	//! Write the given version as the terralib version in the database
+	virtual	bool updateVersionStamp(const string& version ); 
+
+	//! Read and returns the terralib version from the database
+	virtual	bool loadVersionStamp( string& version ); 
+
+   /** @name Transaction control methods 
+	\Note should be implemented by the drivers that has it. Default implementation
+	is DO NOTHING.
+   */
+   //@{ 
+   //! Begins a transaction
+   virtual bool beginTransaction(); 
+
+   //! Commits a transaction
+   virtual bool commitTransaction();
+
+   //! Rollbacks a transaction
+   virtual bool rollbackTransaction();
+   //@}
+
+   //! Drops a database view
+   virtual bool dropDBView(const string& dbViewName);
+
+protected :
+
+	bool				isConnected_;			//!< indicates if the connection is open
+	string				host_;					//!< host name of the database server
+	string				user_;					//!< user name 
+	string				password_;				//!< user password
+	string				database_;				//!< database name
+	int					portNumber_;			//!< port number
+	int					errorNumber_;			//!< error number
+	string				errorMessage_;			//!< error message
+	string				dbmsName_;				//!< DBMS name (Ado, MySQL, Postgres, OracleSpatial)
+	TeSharedPtr<TeMetaModelCache> metaModel_;	//!< Meta model: Layers, Themes, Views...
+
+	//! Update metadata about an attribute table that had its name or columns changed
+	void alterTableInfoInMemory(const string& updatedTableName, string oldTableName="");
+
+	int               transactionCounter_;//!< counts how many nested transactions have been opened
+
+private:
+
+	TeDatabase(const TeDatabase& other);
+};
+
+//! An abstract access portal to a database
+/*! A portal has a concept of a record set, that is generated by a selection (query) on
+	the data accessible through a connection to a database server.
+  \sa TeDatabase, TeGeometry, TeTable, TeTheme, TeView, TeLayer
+
+  */
+class TL_DLL TeDatabasePortal {
+protected:
+	
+
+	TeDatabase*		db_;			//!< the database associated to this portal
+	TeAttributeList	attList_;		//!< the list of attributes associated to this portal
+	int				numRows_;		//!< the number of rows in this portal
+	int				numFields_;		//!< the number of fields in this portal
+	string          errorMessage_;	//!< error message
+	int				errorNumber_;	//!< error number
+
+public :
+
+	//!Constructor 
+	TeDatabasePortal ();
+
+	//! Destructor
+	virtual ~TeDatabasePortal ();
+	
+	//! Returns the database associated to this portal 
+	TeDatabase* getDatabase()
+	{ return db_; }
+
+	//! Executes a SQL query that opens a record set
+	virtual bool query ( const string &qry, TeCursorLocation l = TeSERVERSIDE, TeCursorType t = TeUNIDIRECTIONAL, TeCursorEditType e = TeREADONLY, TeCursorDataType dt = TeTEXTCURSOR ) = 0;
+
+	//! Fetchs the next row in a record set that shouldve been previously opened
+	virtual bool fetchRow () = 0;
+
+	//! Fetchs a particular row
+	virtual bool fetchRow (int i) = 0;
+
+	//! Frees the current record set
+	virtual void freeResult () = 0;
+
+	//! Gets the last error message
+	virtual string	errorMessage ()
+	{ return errorMessage_; }
+
+	//! Gets the number of the last error message
+	virtual int errorNum ()
+	{ return errorNumber_; }
+	
+//	virtual bool loadNetwork (TeLayer *layer) = 0;
+
+// specific SQL SELECT command methods
+
+	/*! \brief Retrieves the number of rows in a portal. Some drivers
+	           (like PostgreSQL and PostGIS) brings to the client only
+			   a part of the row, and then this number can be less than
+			   the number of rows returned by query.
+    */
+	int numRows () 
+	{ return numRows_;}
+
+	//! Retrieves the number of fields in this portal
+	int numFields () 
+	{ return numFields_; }
+
+	//! Retrieves attribute list in this portal
+	TeAttributeList& getAttributeList()	
+	{ return attList_; }
+
+	//! Retrieves the i-th attribute in this portal
+	TeAttribute getAttribute (int i);
+
+	//! Retrieves an attribute by name
+	TeAttribute getAttribute (const string& s);
+
+	//! Gets the value of the i-th attribute as a literal
+	virtual char* getData (int i) = 0;
+
+	//! Gets the value of a named attribute as a literal
+	virtual char* getData (const string& s) = 0;
+
+	//! Gets the value of the i-th attribute as a double
+	virtual double getDouble (int i);
+
+	//! Gets the value of a named attribute as a double
+	virtual double getDouble (const string& s);
+
+	//! Gets the value of the i-th attribute as an integer
+	virtual int getInt (int i);
+
+	//! Gets the value of a named attribute as an integer
+	virtual int getInt (const string& s);
+
+	//! Gets the value of a named attribute as a boolean
+	virtual bool getBool (const string& s) = 0;
+
+	//! Gets the value of the i-th attribute as a boolean
+	virtual bool getBool (int i) = 0;
+
+	//! Gets the value of the i-th attribute as a date 
+	virtual TeTime getDate (int i) = 0;
+
+	//! Gets the value of a named attribute as a date 
+	virtual TeTime getDate (const string& s) = 0;
+
+	//! Gets the of a date/time attribute as a string formatted as accepted in further SQL statements
+	virtual string getDateAsString(int i) = 0;
+
+	//! Gets the of a date/time attribute as a string formatted as accepted in further SQL statements
+	virtual string getDateAsString(const string& s) = 0;
+
+	//! Gets the value of a named BLOB attribute 
+	virtual bool getBlob(const string& s, unsigned char* &data, long& size) = 0;
+
+	//! Gets the index of a named attribute
+	int getColumnIndex (const string& s);
+
+	//! Gets the name of the i-th attribute
+	string getColumnName (int i);
+
+	/** @name Data Model
+	  The following methods decodify structures as stored 
+	  in the database according to the data model proposed in TerraLib. 
+	*/
+	//@{ 	
+	virtual TeViewTree*		getViewTree ();
+	virtual TeLegendEntry	getLegend();
+	virtual void			getVisual(TeVisual*);
+	virtual bool			getVisual(TeVisual* vis, TeGeomRep& rep, const unsigned int& initIndex);
+	virtual bool			getRasterVisual(TeRasterVisual& vis, const unsigned int& initIndex=0);
+	virtual TeColor			getColor(); 
+	virtual bool	getRasterBlock(unsigned long& size, unsigned char* ptData)=0;
+	virtual bool	getView(TeView& view, const unsigned int& initIndex=0);
+	virtual bool	getProjection(TeProjection** proj, const unsigned int& initIndex=0);
+	virtual void	getViewNodeParams (TeViewNodeParams& params, const unsigned int& initIndex=0);
+	virtual bool	getTheme(TeAbstractTheme& theme, const unsigned int& initIndex=0);
+	virtual bool	getGrouping(TeGrouping& group, const unsigned int& initIndex=0);
+	virtual bool	getLegend(TeLegendEntry& leg, const unsigned int& initIndex=0);
+	virtual bool	getAttrTable(TeTable& table, const unsigned int& initIndex=0);
+	virtual bool	getLayer(TeLayer& layer, const unsigned int& initIndex=0);
+	virtual bool	getRepresentation(TeRepresentation& rep, const unsigned int& initIndex=0);
+
+	//@}
+
+	/** @name Fetch Geometry
+	  The following methods decodify geometries as stored 
+	  in the database according to the data model proposed in TerraLib.
+	  \param geom		the geometry that will be filled from portal
+	  \param initIndex  the position index in the portal where begins the geometry information 
+	  \return The fetchGeometry methods advance the portal to the next record and 
+	  they return TRUE if there are more records to be read and FALSE otherwise.
+	*/
+	//@{ 	
+	virtual	bool fetchGeometry (TePolygon& geom) = 0;
+	virtual	bool fetchGeometry (TePolygon& geom, const unsigned int& initIndex); 
+	virtual	bool fetchGeometry (TeLine2D& geom) = 0;
+	virtual	bool fetchGeometry (TeLine2D& geom, const unsigned int& initIndex); 
+	virtual	bool fetchGeometry (TeNode& geom) = 0;
+	virtual	bool fetchGeometry (TeNode& geom, const unsigned int& initIndex);
+	virtual	bool fetchGeometry (TePoint& geom) = 0;
+	virtual	bool fetchGeometry (TePoint& geom, const unsigned int& initIndex);
+	virtual	bool fetchGeometry (TeCell& geom);
+	virtual	bool fetchGeometry (TeCell& geom, const unsigned int& initIndex);
+	virtual	bool fetchGeometry (TeArc& geom);
+	virtual	bool fetchGeometry (TeArc& geom, const unsigned int& initIndex);
+	virtual	bool fetchGeometry (TeText& geom);
+	virtual	bool fetchGeometry (TeText& geom, const unsigned int& initIndex);
+	//@}
+};
+
+
+/*! \example createDatabase.cpp
+	Shows how to create a TerraLib database.
+ */
+
+/*! \example databaseQuery.cpp
+	Shows how to retrieve an existing layer from a TerraLib database, 
+	and execute some queries on its polygon geometry table.
+ */
+
+/*! \example databaseSQLQuery.cpp
+	Shows how retrieve geometries (polygons) using an SQL query.
+ */
+ 
+/*! \example spatialQuery.cpp
+	Shows how  to use the database interface to do some	spatial queries 
+	involving objects with points, lines and polygon geometries.
+ */
+
+/*! \example spatialQueryAndBuffer.cpp
+	Shows to use the database interface to do some  spatial queries involving 
+	objects with points, lines and polygon geometries, and to generate a buffer operation.
+ */
+#endif
+	
diff --git a/src/terralib/kernel/TeDatabaseFactory.h b/src/terralib/kernel/TeDatabaseFactory.h
new file mode 100644
index 0000000..b4eb3ee
--- /dev/null
+++ b/src/terralib/kernel/TeDatabaseFactory.h
@@ -0,0 +1,59 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDatabaseFactory.h
+    \brief This file implements a factory of TerraLib database handlers
+*/
+
+#ifndef TEDATABASEFACTORY_H
+  #define TEDATABASEFACTORY_H
+
+  #include <TeDatabaseFactoryParams.h>
+  #include <TeDatabase.h>
+
+  /**
+   * @brief This is the class for TeDatabase factory.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup DatabaseUtils
+   */
+  class TL_DLL TeDatabaseFactory : 
+    public TeFactory< TeDatabase, TeDatabaseFactoryParams >
+  {
+    public :
+      
+      /**
+       * @brief Default Destructor
+       */
+      virtual ~TeDatabaseFactory() {};
+      
+    protected :
+      
+      /**
+       * @brief Default constructor
+       *
+       * @param factoryName Factory name.
+       */
+      TeDatabaseFactory( const std::string& factoryName )
+      : TeFactory< TeDatabase, TeDatabaseFactoryParams >( factoryName ) {};
+  };
+
+#endif
diff --git a/src/terralib/kernel/TeDatabaseFactoryParams.cpp b/src/terralib/kernel/TeDatabaseFactoryParams.cpp
new file mode 100644
index 0000000..2c78166
--- /dev/null
+++ b/src/terralib/kernel/TeDatabaseFactoryParams.cpp
@@ -0,0 +1,77 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDatabaseFactoryParams.h"
+
+
+TeDatabaseFactoryParams::TeDatabaseFactoryParams()
+{
+  dbms_name_ = "";
+  host_ = "";
+  user_ = "";
+  password_ = "";
+  database_ = "";
+  port_ = 0;
+}
+
+
+TeDatabaseFactoryParams::~TeDatabaseFactoryParams()
+{
+}
+
+
+bool TeDatabaseFactoryParams::operator==( 
+  const TeDatabaseFactoryParams& external ) const
+{
+  if( ( dbms_name_ == external.dbms_name_ ) &&
+      ( host_ == external.host_ ) &&
+      ( user_ == external.user_ ) &&
+      ( password_ == external.password_ ) &&
+      ( database_ == external.database_ ) &&
+      ( port_ == external.port_ ) ) {
+  
+    return true;
+  } else {
+    return false;
+  }
+}
+
+
+const TeDatabaseFactoryParams& TeDatabaseFactoryParams::operator=( 
+  const TeDatabaseFactoryParams& external )
+{
+  dbms_name_ = external.dbms_name_;
+  host_ = external.host_;
+  user_ = external.user_;
+  password_ = external.password_;
+  database_ = external.database_;
+  port_ = external.port_;
+  
+  return external;
+}
+
+
+std::string TeDatabaseFactoryParams::decName() const
+{
+  return dbms_name_;
+}
diff --git a/src/terralib/kernel/TeDatabaseFactoryParams.h b/src/terralib/kernel/TeDatabaseFactoryParams.h
new file mode 100644
index 0000000..82ecb4c
--- /dev/null
+++ b/src/terralib/kernel/TeDatabaseFactoryParams.h
@@ -0,0 +1,71 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDatabaseFactoryParams.h
+    \brief This file contains the definition of parameters necessary to build a TeDatabase
+*/
+
+#ifndef TEDATABASEFACTORYPARAMS_H
+  #define TEDATABASEFACTORYPARAMS_H
+
+  #include "TeDefines.h"
+  #include <string>
+
+  /**
+   * @brief This is the class for TeDatabase factory parameters .
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup DatabaseUtils
+   */
+  class TL_DLL TeDatabaseFactoryParams
+  {
+    public :
+    
+      std::string dbms_name_;	//!< DBMS name (like PostgreSQL, PostGIS, MySQL and others).
+      std::string host_;		//!< Host name.
+      std::string user_;		//!< User name in order to stabilish a connection.
+      std::string password_;	//!< User password.
+      std::string database_;	//!< Database name.
+      int port_;				//!< Port number for network connection.
+
+      //! Default constructor
+      TeDatabaseFactoryParams();
+      
+      //! Default Destructor
+      virtual ~TeDatabaseFactoryParams();
+      
+      //! operator== implementation.
+	  /*! \param external External reference.
+	      \return true if both instances are equal, false if not.
+      */
+      bool operator==( const TeDatabaseFactoryParams& external ) const;
+      
+      //! operator= implementation.
+	  /*! \param external External reference.
+	      \return A const reference to the external object instance.
+      */
+      const TeDatabaseFactoryParams& operator=( 
+        const TeDatabaseFactoryParams& external );      
+
+      //! This is for TeFactory compatibility.
+      std::string decName() const;
+  };
+#endif
diff --git a/src/terralib/kernel/TeDatum.cpp b/src/terralib/kernel/TeDatum.cpp
new file mode 100644
index 0000000..d5ec863
--- /dev/null
+++ b/src/terralib/kernel/TeDatum.cpp
@@ -0,0 +1,522 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include <cstdlib> //FAMI
+#include <cstring>
+#include <map>
+
+using namespace std;
+
+#include "TeDatum.h"
+#include "TeException.h"
+#include "TeUtils.h"
+
+const int NUMDATUM = 9; // number of datum
+const int NUMSPH   = 8; // number of ellipsoids
+
+bool tokenizeWKT(char** wkt, vector<string>& tokens);
+
+struct SphParam 
+{
+	double rd;
+	double flt;
+};
+
+typedef map<string, SphParam> SphMap;
+
+// Spheroid       Radius(Semi Major Axis)        Flattening
+const char* ellipsoidList [] = 
+{ 
+"Airy",	       "6.3775634e+06", "3.340906e-03",	  
+"Clarke-1866", "6.378206e+06",	"3.390060e-03",	 
+"EarthRadius", "6.371000e+06",	"0.000000e+00",
+"Everest",     "6.3772763e+06", "3.324468e-03",
+"GRS80",       "6.378137e+06",  "3.352811e-03",
+"Hayford", 	   "6.378388e+06",  "3.367003e-03", 	 
+"UGGI67", 	   "6.378160e+06",	"3.352892e-03",	 
+"WGS84",	   "6.378137e+06",	"3.352811e-03"
+};
+
+
+
+// DatumName    Spheroid        Shift_X           Shift_Y           Shift_Z
+
+const char* datumList [] = 
+{ 
+"Astro-Chua",   "Hayford",      "-7.700000e+01",  "2.390000e+02",  "5.000000e+00",
+"CorregoAlegre","Hayford",	    "-1.387000e+02",  "1.644000e+02",  "3.440000e+01",
+"Indian",	    "Everest",	    "0.000000e+00",   "0.000000e+00",  "0.000000e+00",
+"NAD27",	    "Clarke-1866",	"0.000000e+00",   "0.000000e+00",  "0.000000e+00",
+"NAD83",	    "GRS80",	    "0.000000e+00",   "0.000000e+00",  "0.000000e+00",
+"SAD69", 	    "UGGI67",       "0.000000e+00",   "0.000000e+00",  "0.000000e+00",
+"Spherical",	"EarthRadius",  "0.000000e+00",   "0.000000e+00",  "0.000000e+00",
+"WGS84",	    "WGS84",	    "6.687000e+01",   "-4.370000e+00", "3.852000e+01",
+"Aratu",	    "Hayford",	    "-7.81300e+01",   "2.9163000e+02", "-1.08480e+02"
+};
+
+const char** TeGetDatumList()
+{
+	return datumList;
+}
+
+
+typedef map<string, TeDatum> DatumMap;
+
+
+TeDatum::TeDatum(const TeDatum& other)
+{
+	name_ = other.name_;
+	rd_ = other.rd_ ;
+	flt_= other.flt_;
+	dx_ = other.dx_;
+	dy_= other.dy_;
+	dz_ = other.dz_;
+}
+
+TeDatum&
+TeDatum::operator=(const TeDatum& rhs)
+{
+	if ( this != &rhs )
+	{
+		name_ = rhs.name_;
+		rd_ = rhs.rd_;
+		flt_= rhs.flt_;
+		dx_ = rhs.dx_;
+		dy_= rhs.dy_;
+		dz_ = rhs.dz_;
+	}
+	return *this;
+}
+
+string
+TeDatum::getProj4Description()
+{
+	double shiftX, shiftY,shiftZ;
+	shiftX = shiftY = shiftZ = 0.0;
+
+	string datumProj4 = "";
+	if (name_ == "WGS84")
+	{
+		datumProj4 += " +ellps=WGS84";
+		return datumProj4;
+	}
+	else if (name_ == "Spherical")
+	{
+		datumProj4 += " +R="  + Te2String(rd_,6);
+	}
+	else if (name_ == "SAD69")
+	{
+		shiftX = -66.87;
+		shiftY = 4.37;
+		shiftZ = -38.52;
+
+		datumProj4 += " +ellps=GRS67";
+	}
+	else if (name_ == "CorregoAlegre")
+	{
+		shiftX = -205.57;
+		shiftY = 168.77;
+		shiftZ = -4.12;
+		datumProj4 += " +ellps=intl";
+	}
+	else
+	{
+		datumProj4 += " +a="  + Te2String(rd_,6);
+		datumProj4 += " +f="  + Te2String(flt_,6);
+	}
+
+	if (shiftX != 0.0 && shiftY != 0.0 && shiftZ != 0.0)
+		datumProj4 += " +towgs84=" + Te2String(shiftX,4) + "," +  Te2String(shiftY,4)+ "," +  Te2String(shiftZ,4);
+	return datumProj4;
+}
+
+string
+TeDatum::getWKTDescription()
+{
+	string sph_epsgcode = "";
+	string dtm_epsgcode = "";
+	string spheroid = "";
+	string crs_epsgcode = "";
+	string datumWKT = "GEOGCS[\"" + name_ + "\"," + "DATUM[\"" + name_ + "\", SPHEROID[\"";
+	if (name_ == "Astro-Chua")
+	{
+		spheroid = "Hayford";
+		sph_epsgcode = "7022";
+		dtm_epsgcode = "6224";
+		crs_epsgcode = "4224";
+	}
+	else if (name_ == "CorregoAlegre")
+	{
+		spheroid = "Hayford";
+		sph_epsgcode = "7022";
+		dtm_epsgcode = "6225";
+		crs_epsgcode = "4225";
+	}
+	else if (name_ == "Indian")
+	{
+		spheroid = "Everest";
+		sph_epsgcode = "7015";
+		dtm_epsgcode = "6239";
+		crs_epsgcode = "4240";
+	}
+	else if (name_ == "NAD27")
+	{
+		spheroid = "Clarke 1866";
+		sph_epsgcode = "7008";
+		dtm_epsgcode = "6609";
+		crs_epsgcode = "4267";
+	}
+	else if (name_ == "NAD83")
+	{
+		spheroid = "GRS80";
+		sph_epsgcode = "7019";
+		dtm_epsgcode = "6326";
+		crs_epsgcode = "4269";
+	}
+	else if (name_ == "WGS84")
+	{
+		spheroid = "GRS80";
+		sph_epsgcode = "7019";
+		dtm_epsgcode = "6326";
+		crs_epsgcode = "4326";
+	}
+	else if (name_ == "SAD69")
+	{
+		spheroid = "UGGI67";
+		sph_epsgcode = "7036";
+		dtm_epsgcode = "6291";
+		crs_epsgcode = "4618";
+	}
+	else if (name_ == "Spherical")
+	{
+		spheroid = "EarthRadius";
+		sph_epsgcode = "7035";
+	}
+	else
+		spheroid = "UserDefined";
+	datumWKT += spheroid + "\"," + Te2String(rd_,6) + ", " + Te2String(1.0/flt_,6);
+	if (!sph_epsgcode.empty())
+		datumWKT +=",AUTHORITY[\"EPSG\"," + sph_epsgcode + "]";
+	datumWKT += "]";
+	double shiftX, shiftY, shiftZ;
+	shiftX = shiftY = shiftZ = 0.0;
+	if (name_ == "SAD69")
+	{
+		shiftX = -66.87;
+		shiftY = 4.37;
+		shiftZ = -38.52;
+	}
+	else if (name_ == "CorregoAlegre")
+	{
+		shiftX = -205.57;
+		shiftY = 168.77;
+		shiftZ = -4.12;
+	}
+	if (shiftX != 0.0 && shiftY != 0.0 && shiftZ != 0.0)
+		datumWKT += ",TOWGS84[" + Te2String(shiftX,4) + "," + Te2String(shiftY,4) + "," + Te2String(shiftZ,4) + ",0.0,0.0,0.0,0.0]";
+
+	if (!dtm_epsgcode.empty())
+		datumWKT += ",AUTHORITY[\"EPSG\"," + dtm_epsgcode + "]";
+	datumWKT += "]";
+	if (!crs_epsgcode.empty())
+		datumWKT += ",AUTHORITY[\"EPSG\"," + crs_epsgcode + "]";
+	datumWKT += "]";
+	return datumWKT;
+}
+
+TeDatum
+TeDatumFactory::make( const string& name )
+{
+
+	DatumMap datumMap_;
+	// Step 1 - Read the Spheroids - Put in a Map
+
+	SphMap sphMap;
+
+	SphParam sphPar;
+
+	int i, k = 0;
+
+	for ( i = 0; i < NUMSPH; i++ )
+	{
+		string name = ellipsoidList [k++];
+		sphPar.rd  = atof ( ellipsoidList [k++] );
+		sphPar.flt = atof ( ellipsoidList [k++] );
+
+		sphMap [ name ] = sphPar;
+	}
+	
+	// Step 2 - Read the Datum List, create a Map
+
+
+	k = 0;
+
+	for ( i = 0; i < NUMDATUM; i++ )
+	{
+			string name = datumList [k++];
+			
+			string sphname = datumList [ k++];
+
+			double 	dx  = atof ( datumList [k++] );
+			double  dy  = atof ( datumList [k++] );
+			double  dz  = atof ( datumList [k++] );
+
+			SphMap::iterator it = sphMap.find ( sphname );
+			
+			if ( it == sphMap.end() )
+			{
+				throw TeException ( DATUM_ERROR );
+			}
+			else 
+				sphPar = (*it).second;
+
+			TeDatum dat ( name, sphPar.rd, sphPar.flt, dx, dy, dz );
+
+			datumMap_ [ name ] = dat; // create a datum map
+	}
+
+	DatumMap::iterator it = datumMap_.find ( name );
+
+	if ( it != datumMap_.end() ) // found it
+		return (*it).second;
+
+	return TeDatum ("Spherical");
+}
+
+TeDatum 
+TeDatumFactory::makeFromEPSGCode(const std::string epsgCode)
+{
+	string dname;
+	if (epsgCode == "6224")
+	{
+		dname = "Astro-Chua";
+	}
+	else if (epsgCode == "6225")
+	{
+		dname = "CorregoAlegre";
+	}
+	else if (epsgCode == "6240")
+	{
+		dname = "Indian";
+	}
+	else if (epsgCode == "6609")
+	{
+		dname = "NAD27";
+	}
+	else if (epsgCode == "6152")
+	{
+		dname = "NAD83";
+	}
+	else if (epsgCode == "6326")
+	{
+		dname = "WGS84";
+	}
+	else if (epsgCode == "6618")
+	{
+		dname = "SAD69";
+	}
+	else 
+	{
+		dname = "Spherical";
+	}
+	TeDatum dat = TeDatumFactory::make(dname);
+	return dat;
+}
+
+
+TeDatum 
+TeDatumFactory::makeFromWKT(const std::string wktDatumDescription)
+{
+	TeDatum dat;
+	vector<string> tokens;
+	char* wktchar = new char[wktDatumDescription.size()];
+	strcpy(wktchar,wktDatumDescription.c_str());
+	if (!tokenizeWKT((char **) &wktchar, tokens))
+	{
+		return dat;
+	}
+	unsigned int i =0;
+	while (i<tokens.size() && tokens[i] != "DATUM")
+		++i;
+
+	if (i== tokens.size())
+		return dat;
+	++i;
+
+	map<string,string> ewktToTeDatum;
+	ewktToTeDatum["D_Chua"] = "Astro-Chua";
+	ewktToTeDatum["D_Corrego_Alegre"] = "CorregoAlegre";
+	ewktToTeDatum["D_Indian_1975"] = "Indian";
+	ewktToTeDatum["D_North_American_1927"] = "NAD27";
+	ewktToTeDatum["D_North_American_1983"] = "NAD83";
+	ewktToTeDatum["D_South_American_1969"] = "SAD69";
+	ewktToTeDatum["D_WGS_1984"] = "WGS84";
+	ewktToTeDatum["D_Aratu"] = "Aratu";
+	// lets the ESRI's WKT format 
+	TeTrim(tokens[i]);
+	map<string,string>::iterator it = ewktToTeDatum.find(tokens[i]);
+	if (it != ewktToTeDatum.end())
+	{
+		dat = TeDatumFactory::make(it->second);
+		return dat;
+	}
+
+	map<string,string> wktToTeDatum;
+	wktToTeDatum["Chua"] = "Astro-Chua";
+	wktToTeDatum["Corrego_Alegre"] = "CorregoAlegre";
+	wktToTeDatum["Indian_1975"] = "Indian";
+	wktToTeDatum["North_American_Datum_1927"] = "NAD27";
+	wktToTeDatum["North_American_Datum_1983"] = "NAD83";
+	wktToTeDatum["South_American_Datum_1969"] = "SAD69";
+	wktToTeDatum["Unknown"] = "Spherical";
+	wktToTeDatum["WGS_1984"] = "WGS84";
+	wktToTeDatum["Aratu"] = "Aratu";
+
+	// lets try OGC's SFS WKT format 
+	it = wktToTeDatum.find(tokens[i]);
+	if (it != wktToTeDatum.end())
+	{
+		dat = TeDatumFactory::make(it->second);
+		return dat;
+	}
+
+	// lets try EPSG authority codes 
+	unsigned int is = i;
+	while (i<tokens.size() && tokens[i] != "AUTHORITY")
+		++i;
+	if (i== tokens.size())
+		return dat;
+	++i;
+	if (tokens[i]=="EPSG")
+	{
+		++i;
+		dat = TeDatumFactory::makeFromEPSGCode(tokens[i]);
+		return dat;
+	}
+
+	// so let's try according to the parameters
+	i = is;	
+	dat.name(tokens[i]);
+	while (i<tokens.size() && tokens[i] != "SPHEROID")
+		++i;
+	if (i== tokens.size())
+		return dat;
+	++i; ++i;
+	dat.radius(atof(tokens[i].c_str()));
+	++i;
+	dat.flattening(1/atof(tokens[i].c_str()));
+	++i;
+	if (tokens[i] == "TOWGS84" && i<tokens.size())
+	{
+		++i;
+		double dx = (atof(tokens[i].c_str()));
+		++i;
+		double dy = (atof(tokens[i].c_str()));
+		++i;
+		double dz = (atof(tokens[i].c_str()));
+		++i;
+		++i;
+		++i;
+		++i;
+		if ( dx==0.0 && dy== 0 && dz == 0.0)
+		{
+			dat = TeDatum("WGS84",6378137,0.003352811,66.87,-4.37,38.52);
+		}
+		// this is a SAD69
+		else if (dx == -66.87 && dy == 4.37 && dz == -38.52)
+		{
+			dat = TeDatum("SAD69",6378160,0.003352892,0.0,0.0,0.0);
+		}
+		else
+		{
+			dat.dx_ = dx;
+			dat.dy_ = dy;
+			dat.dz_ = dz;
+		}
+	}
+	return dat;
+}
+
+
+bool findDatum(double semiMajor, double flatenning, TeDatum& datum)
+{
+	DatumMap datumMap_;
+
+	// Step 1 - Read the Spheroids - Put in a Map
+
+	SphMap sphMap;
+	SphParam sphPar;
+
+	int i, k = 0;
+
+	for ( i = 0; i < NUMSPH; i++ )
+	{
+		string name = ellipsoidList [k++];
+		sphPar.rd  = atof ( ellipsoidList [k++] );
+		sphPar.flt = atof ( ellipsoidList [k++] );
+
+		sphMap [ name ] = sphPar;
+	}
+	
+	// Step 2 - Read the Datum List, create a Map
+	k = 0;
+
+	for ( i = 0; i < NUMDATUM; i++ )
+	{
+		string name = datumList [k++];
+		string sphname = datumList [ k++];
+		double 	dx  = atof ( datumList [k++] );
+		double  dy  = atof ( datumList [k++] );
+		double  dz  = atof ( datumList [k++] );
+
+		SphMap::iterator it = sphMap.find ( sphname );
+			
+		if ( it == sphMap.end() )
+		{
+			throw TeException ( DATUM_ERROR );
+		}
+		else 
+			sphPar = (*it).second;
+		TeDatum dat ( name, sphPar.rd, sphPar.flt, dx, dy, dz );
+		datumMap_ [ name ] = dat; // create a datum map
+	}
+
+	DatumMap::iterator it = datumMap_.begin();
+	while (it != datumMap_.end())
+	{
+		TeDatum dt = (*it).second;
+		if ( TeCompareDouble(dt.radius(),semiMajor,6) &&
+			 TeCompareDouble(dt.flattening(),flatenning,6))
+		{
+
+			datum = dt;
+			return true;
+		}
+		++it;
+	}
+	return false;
+}
diff --git a/src/terralib/kernel/TeDatum.h b/src/terralib/kernel/TeDatum.h
new file mode 100644
index 0000000..06768ea
--- /dev/null
+++ b/src/terralib/kernel/TeDatum.h
@@ -0,0 +1,161 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDatum.h
+    \brief This file contains structures and definitions to support the concept of a planimetric datum
+*/
+
+#ifndef  __TERRALIB_INTERNAL_DATUM_H
+#define  __TERRALIB_INTERNAL_DATUM_H
+
+#include <string>
+#include "TeUtils.h"
+
+//! Number of supported datum in TerraLib
+const int NUM_DATUM = 9; 
+
+TL_DLL const char** TeGetDatumList();
+
+
+//! Implements valid Datum options and related parameters which account for different earth spheroids.
+/*! Specifies planimetric TeDatum parameters to be used for defining geodetic
+	coordinates, which are necessary to establish a map projection system.
+	It encapsulates the following important information regarding 
+	a planimetric Datum such as:
+	\li	Datum name;
+	\li	Earth equatorial radius;
+	\li	Earth flatenning;
+	\li	Datum shifts. 
+
+	\author
+	 Ubirajara Freitas, Julio d'Alge.
+
+	\sa TeDatumFactory
+*/
+class TL_DLL TeDatum
+{
+private:
+	std::string	name_;		//!< Planimetric TeDatum name
+	double	rd_,		//!< Earth equatorial radius (m) 
+			flt_;		//!< Earth flattening 
+public:
+	double	dx_,		//!< TeDatum shift along x axis (m)
+			dy_,		//!< TeDatum shift along y axis (m)
+			dz_;		//!< TeDatum shift along z axis (m) 
+
+	//!	Constructor.
+	TeDatum ( std::string name = "Spherical", double rd = 6.371000e+06 , double flt = 0., 
+			  double dx = 0., double dy= 0., double dz = 0.):
+	name_ ( name ),
+	rd_   (  rd  ),
+	flt_  ( flt  ),
+	dx_   (  dx  ),
+	dy_   (  dy  ),
+	dz_   (  dz  )
+	{ }
+
+	//! Copy constructor
+	TeDatum(const TeDatum& other);
+
+	//! Operator =
+	TeDatum& operator=(const TeDatum& rhs);
+
+	//!	Destructor.
+	~TeDatum () {}
+
+	//! Returns the datum name
+	std::string 	name()	 const			
+	{ return name_;} 
+
+	//! Sets the datum name
+	void name(const std::string& name)	 			
+	{	name_ = name;	} 
+
+	//! Returns Earth equatorial radius (m)
+	double radius() const
+	{ return rd_; }
+
+	//! Sets Earth equatorial radius (m)
+	void radius(const double rd) 
+	{ rd_ = rd; }
+
+	//! Returns the Earth equatorial radius (m) (m)
+	double flattening() const
+	{ return flt_; }
+
+	//! Sets the Earth equatorial radius (m) (m)
+	void flattening(const double flt) 
+	{ flt_ = flt; }
+
+	//! Returns the shift along x axis (m)
+	double	xShift() const
+	{ return dx_; }
+ 
+	//! Returns the shift along y axis (m)
+	double  yShift() const 
+	{ return dy_; }
+
+	//! Returns the shift along z axis (m)
+	double zShift()  const
+	{ return dz_; }
+
+
+//!		Verifies if current TeDatum is equal to TeDatum& dat. 
+	bool operator== (const TeDatum& dat) const 
+	{
+		return (TeFPEquals(rd_,dat.rd_,0.0000000001) 
+			   && TeFPEquals(flt_,dat.flt_,0.0000000001)
+			   && TeFPEquals(dx_,dat.dx_,0.0000000001) 
+			   && TeFPEquals(dy_,dat.dy_,0.0000000001) 
+			   && TeFPEquals(dz_,dat.dz_,0.0000000001)); 
+	}
+
+	//! Returns the Datum description in PROJ4 format
+	string getProj4Description();
+
+	//! Returns the Datum description in WKT format
+	string getWKTDescription();
+
+};
+
+//! Produces a Datum accordingly to an specified name
+class TL_DLL TeDatumFactory
+{
+public:
+	//! Builds a datum from a TerraLib name
+	static	TeDatum make ( const std::string& name );
+
+	//! Builds a datum from its EPSG code
+	static TeDatum makeFromEPSGCode(const std::string epsgCode);
+
+	//! Builds a datum from its OGC's WKT description
+	static TeDatum makeFromWKT(const std::string wktDatumDescription);
+};
+
+/*! 
+   \fn   findDatum(double semiMajor, double flatenning, TeDatum& datum)
+   \brief Tries to find the a TeDatum according to givem semi major axis and earth flattening
+ */
+TL_DLL bool findDatum(double semiMajor, double flatenning, TeDatum& datum);
+
+#endif
+
diff --git a/src/terralib/kernel/TeDecoder.h b/src/terralib/kernel/TeDecoder.h
new file mode 100644
index 0000000..bc1bd79
--- /dev/null
+++ b/src/terralib/kernel/TeDecoder.h
@@ -0,0 +1,214 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2005 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoder.h
+    \brief This file deals with decoding of raster structures 
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODER_H
+#define  __TERRALIB_INTERNAL_DECODER_H
+
+#include "TeDefines.h"
+#include "TeFactory.h"
+#include "TeCoord2D.h"
+#include "TeRasterParams.h"
+
+using namespace std;
+#include <string>
+#include <list>
+#include <map>
+
+class TeRaster;
+class TeDecoderMemory;
+class TeProjection;
+struct TeBox;
+
+//! An abstract class to decode raster data 
+/* 
+	A decoder keeps its own copy of the  parameters associated
+	to the raster being decoded.
+*/
+class TL_DLL TeDecoder {
+
+public:
+	//! Empty constructor
+	TeDecoder() {}
+
+	//! Constructor from  raster parameters
+	/*!
+		\param par raster parameters
+	*/
+	TeDecoder(const TeRasterParams& par) : params_(par) {}
+
+	//! Virtual destructor 
+	virtual ~TeDecoder() {}	
+
+	//! Returns the raster parameters
+	TeRasterParams& params()
+		{ return params_; }
+
+	//! Updates the raster parameters
+	void updateParams(TeRasterParams& par)
+	{	params_ = par; }
+
+	//! Sets the value of a specific raster element 
+	/*!
+		\param col	element column identifier
+		\param lin	element line identifier
+		\param val	element value being inserted
+		\param band element band identifier
+	*/
+	virtual bool setElement(int col, int lin, double val, int band=0 ) = 0;
+
+	//! An optimizated method to set values raster images
+	/*
+		This method should be used only to set the values of images with 3 bands associated
+		to the three colour channes: RGB
+		\param col column of the image
+		\param lin line of the image
+		\param Rval the value associated to the band 0 (associated to the R colour Channel)
+		\param Gval the value associated to the band 1 (associated to the G colour Channel)
+		\param Bval the value associated to the band 2 (associated to the B colour Channel)
+		\param transp an optional transparency degree, with a range of 0 (totally transparent) to 255 (totally opaque)
+		\return true if if succeed and false otherwise
+	*/
+	virtual bool setElementRGB(int col, int lin, double Rval, double Gval, double Bval, unsigned int /*transp*/ = 255)
+	{
+		if (!setElement(col,lin,Rval,0))
+			return false;
+		if (!setElement(col,lin,Gval,1))
+			return false;		
+		if (!setElement(col,lin,Bval,2))
+			return false;
+		return true;
+	}
+
+	//! Gets an specific element (col, lin, band) of a raster data
+	/*!
+		\param col	element column identifier
+		\param lin	element line identifier
+		\param val	element value being retrieved
+		\param band element band identifier
+	*/
+	virtual bool getElement(int col, int lin, double& val, int band=0 ) = 0;
+
+	//! Transforms a geographical coordinate to an index (lin, col) coordinate
+	virtual TeCoord2D coord2Index (TeCoord2D &pt)
+	{	return params_.coord2Index(pt);	}
+
+	//! Transforms an index (lin, col) coordinate to a geographical coordinate
+	virtual TeCoord2D index2Coord (TeCoord2D &pt)
+	{	return params_.index2Coord(pt);	}
+
+	//! Initializes the internal structures of the decoder from a raster parameters structure
+	/*  
+	    \param par the raster parameters structure
+	*/
+	virtual void init( TeRasterParams& par ) 
+	{ params_= par; init();}
+
+	//! Initializes the internal structures of the decoder
+	virtual void init() = 0;
+
+	//! Clears its internal structures
+	virtual bool clear() = 0;
+
+	//! Returns a default object - for compatibility reasons with TeDecoderFactory
+	static TeDecoder* DefaultObject( const TeRasterParams& /* par */) 
+	{ return 0; }
+
+/** @name Selection
+  These routines are used to implement a selection of blocks or tiles 
+  that intercept a given bounding box, and provide sequential access to them.
+  These routines should be implemented by concrete decoders to formats that support tilling.
+*/
+//@{ 
+	//! Returns TRUE if it there are raster blocks that intersect a given box
+	/*
+		\param bb		box	that represents the interest region
+		\param resFac	resolution factor
+		\param parBlock to return the common parameters of the blocks that are selected
+		\returns TRUE if could select at least one block and FALSE otherwise
+	*/
+	virtual bool selectBlocks(TeBox& /* bb */, int /* resFac */, TeRasterParams& /*parBlock*/)  
+	{ return false; }
+
+	//! Returns the number of blocks selected in the last block selection
+	virtual int numberOfSelectedBlocks()
+	{	return 0; }	
+	
+	//! Gets a decoder to the current selected block
+	virtual bool getSelectedRasterBlock(TeDecoderMemory* /* memDec */) 
+	{ return false; }
+
+	//! Clear a previous block selection
+	virtual void clearBlockSelection() {}
+
+	//! Returns the raster best resolution level available to fill a given bounding box with a given number of lines and columns in a given projection
+	/*
+		\param bb		box that represents the interest region
+		\param ncols	number of columns in the box
+		\param nlines	number of lines in the box
+		\param proj		pointer to the projection of the box
+	*/
+	virtual int bestResolution(TeBox& /*bb*/, int /*ncols*/, int /*nlines*/, TeProjection* /*proj*/)
+	{	return 1; }
+
+	//! Returns the raster resolution level available that is more similiar to a given desired resolution
+	virtual int bestResolution(double /*res*/)
+	{	return 1; }
+
+
+//@}
+
+protected:
+
+//! The parameters that describes a raster data
+	TeRasterParams  params_;	
+};
+
+//! A decoder abstract factory
+/*! 
+	Implements an abstract factory that builds appropriate decoders
+	according to a string identifier.
+*/
+class TL_DLL TeDecoderFactory: public TeFactory<TeDecoder,TeRasterParams> 
+{
+public:
+
+	//! Maps synonyms to decoders identifiers (example "TIFF" or "tif" to a decoder to TIFF format)
+	typedef map<string,string> TeNames2Decoders;
+
+	//! Unique instance instance of map from synonyms to decoder identifiers
+	static TeNames2Decoders& instanceName2Dec ()
+	{ 
+		static TeNames2Decoders names2dec_;
+		return names2dec_;
+	}
+
+	//! Builds an appropriate decoder from a identifier
+	TeDecoderFactory(const string& name) : TeFactory<TeDecoder,TeRasterParams>(name) { }
+
+	//! Virtual destructor
+	virtual ~TeDecoderFactory() {}
+};
+
+#endif
diff --git a/src/terralib/kernel/TeDecoderASCIIGrid.cpp b/src/terralib/kernel/TeDecoderASCIIGrid.cpp
new file mode 100644
index 0000000..0128b95
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderASCIIGrid.cpp
@@ -0,0 +1,416 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeException.h"
+#include "TeDecoderASCIIGrid.h"
+#include "TeAsciiFile.h"
+#include "TeUtils.h"
+
+#include <cstring>
+#include <fstream>
+using std::ifstream;
+using std::ofstream;
+
+/*
+Expected format for ESRI ASCII GRID Files (Copied from the ArcWorkstation 8.3 Help File):
+
+<NCOLS xxx>
+<NROWS xxx>
+<XLLCENTER xxx | XLLCORNER xxx>
+<YLLCENTER xxx | YLLCORNER xxx>
+<CELLSIZE xxx>
+{NODATA_VALUE xxx}
+row 1
+row 2
+.
+.
+.
+row n
+*/
+
+TeDecoderASCIIGrid::TeDecoderASCIIGrid (const TeRasterParams& par) : 
+	isModified_(false),
+	size_(0),
+	myData_(0)
+{	
+	params_.errorMessage_.clear();
+	if (par.fileName_.empty())
+		return;
+	params_ = par;
+	params_.decoderIdentifier_ = "ASCIIGRID";
+	if (params_.mode_ == 'w' || params_.mode_ == 'r')
+		readParameters();
+}
+
+TeDecoderASCIIGrid::~TeDecoderASCIIGrid ()
+{
+	if ( isModified_ && (params_.mode_ == 'w' || params_.mode_ == 'c'))
+	{			// save contents to disk
+		try
+		{
+			TeAsciiFile sFile(params_.fileName_,"w+");
+			if (writeParameters(sFile))
+				saveData(sFile);
+		}
+		catch (...)
+		{
+		}
+	}
+	delete [] myData_;
+}
+
+bool
+TeDecoderASCIIGrid::clear()
+{
+	if ( isModified_ && (params_.mode_ == 'w' || params_.mode_ == 'c'))
+	{			// save contents to disk
+		try
+		{
+			TeAsciiFile sFile(params_.fileName_,"w+");
+			if (writeParameters(sFile))
+				saveData(sFile);
+		}
+		catch (...)
+		{
+		}
+		isModified_ = false;
+	}
+	if (myData_)
+		delete [] myData_;
+	myData_ = 0;
+	return true;
+}
+
+bool 
+TeDecoderASCIIGrid::readParameters()
+{
+	try
+	{
+		TeAsciiFile	pFile (params_.fileName_);
+		string name;
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (TeStringCompare(name,"NCOLS"))
+				break;
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		params_.ncols_ = pFile.readInt();
+		pFile.findNewLine();
+
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (TeStringCompare(name,"NROWS"))
+				break;
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		params_.nlines_ = pFile.readInt();
+		pFile.findNewLine();
+
+		bool isCenter = false;
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (TeStringCompare(name,"XLLCENTER"))
+			{
+				isCenter = true; 
+				break;
+			}
+			else if (TeStringCompare(name,"XLLCORNER"))
+				break;
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		double llx = pFile.readFloat();
+		pFile.findNewLine();
+
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (TeStringCompare(name,"YLLCENTER"))
+			{
+				isCenter = true; 
+				break;
+			}
+			else if (TeStringCompare(name,"YLLCORNER"))
+				break;
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		double lly = pFile.readFloat();	
+		pFile.findNewLine();
+
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (TeStringCompare(name,"CELLSIZE"))
+				break;
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		params_.resx_ = params_.resy_ = pFile.readFloat();		
+		pFile.findNewLine();
+
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (TeStringCompare(name,"NODATA_VALUE"))
+				break;
+		}
+		double dummy = -9999.0;
+		if (pFile.isNotAtEOF())					// unexpected end of file: NODATA statment is not present
+			dummy = pFile.readFloat();		
+		params_.nBands(1);
+		params_.setDataType(TeFLOAT);		
+		params_.setDummy(dummy);
+		params_.setPhotometric(TeRasterParams::TeMultiBand);
+		params_.lowerLeftResolutionSize(llx,lly,params_.resx_,params_.resy_,
+				                      params_.ncols_,params_.nlines_,isCenter);
+		TeProjection* pp = new TeNoProjection();
+		params_.projection(pp);
+		delete pp;
+	}
+	catch(...)
+	{
+		params_.errorMessage_ = "Fail to read the parameters from the raster the file.";
+		return false;
+	}
+	return true;
+}
+
+bool
+TeDecoderASCIIGrid::readFile(const string& filename)
+{
+	string valstring;
+	try 
+	{
+		TeAsciiFile	pFile (filename);
+		string name;
+		while (pFile.isNotAtEOF() && !TeStringCompare(name,"NODATA_VALUE"))
+			name = pFile.readString();
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		pFile.findNewLine();
+		double val;
+		for (int lin = 0; lin < params_.nlines_; ++lin)
+		{
+			for (int col = 0; col < params_.ncols_; ++col)
+			{
+				val = pFile.readFloat();
+				if (val != params_.dummy_[0])
+				{
+					setElement(col,lin,val);
+					if (val < params_.vmin_[0])
+						params_.vmin_[0] = val;
+					if (val > params_.vmax_[0])
+						params_.vmax_[0] = val;
+				}
+			}
+		}
+	}
+	catch(...)
+	{
+		params_.errorMessage_ = "Fail to read the data from the raster the file.";
+		return false;
+	}
+	return true;
+}
+
+void
+TeDecoderASCIIGrid::init()
+{
+	params_.status_= TeRasterParams::TeNotReady;
+	int nb = params_.nBands();
+	if (nb != 1 )
+	{
+		params_.errorMessage_ = "Ascii-GRID can store raster with only 1 band.";
+		return;
+	}
+
+	// try to allocate enough memory to hold the data
+	if (size_ != params_.nlines_*params_.ncols_*params_.nBands())
+	{
+		size_ = params_.nlines_*params_.ncols_*params_.nBands();
+		if (myData_)
+			delete [] myData_;
+		myData_ = new float [size_];
+	}
+	if (!myData_)
+		return;
+
+	for (long i=0; i<size_; myData_[i]=static_cast<float>(params_.dummy_[0]),++i);
+
+	if (params_.mode_ == 'c')	// creating a new file
+	{
+		ofstream dataFile(params_.fileName_.c_str()); // try to (re)create the file
+		if (!dataFile)
+		{
+			params_.errorMessage_ = "Fail to (re)create the raster the file:" + params_.fileName_;
+			return;
+		}
+		dataFile.close();
+		try
+		{
+			TeAsciiFile sFile(params_.fileName_,"w+");
+			if (!writeParameters(sFile) || !saveData(sFile))
+			{
+				params_.errorMessage_ = "Fail to write the raster to file";
+				return;
+			}
+			else
+			{
+				params_.status_ = TeRasterParams::TeReadyToWrite;
+			}
+		}
+		catch (...)
+		{
+			params_.errorMessage_ = "Fail to write the raster to file";
+			return;
+		}
+	}
+	else if (params_.mode_ == 'w')
+	{
+		ifstream dataFile(params_.fileName_.c_str()); // check if file exists
+		if (!dataFile)
+		{
+			params_.errorMessage_ = "Fail to open the raster the file:" + params_.fileName_;
+			return; 
+		}
+		dataFile.close();	
+		if (!readFile(params_.fileName_))
+		{
+			params_.errorMessage_ = "Fail to read the raster the file:" + params_.fileName_;
+			return; 
+		}
+		params_.status_ = TeRasterParams::TeReadyToWrite;
+	}
+	else if (params_.mode_ == 'r')
+	{
+		ifstream dataFile(params_.fileName_.c_str()); // check if file exists
+		if (!dataFile)
+		{
+			params_.errorMessage_ = "Fail to open the raster the file:" + params_.fileName_;
+			return; 
+		}
+		dataFile.close();	
+		if (!readFile(params_.fileName_))
+		{
+			params_.errorMessage_ = "Fail to read the raster the file:" + params_.fileName_;
+			return; 
+		}
+		params_.status_ = TeRasterParams::TeReadyToRead;	
+	}
+}
+
+bool 
+TeDecoderASCIIGrid::writeParameters(TeAsciiFile& pFile)
+{
+	string name;
+	try
+	{
+		TeBox box = params_.box();
+		name = "NCOLS " + Te2String(params_.ncols_) + "\n";
+		pFile.writeString(name);
+		name = "NROWS " + Te2String(params_.nlines_) + "\n";
+		pFile.writeString(name);
+		name = "XLLCENTER " + Te2String(box.x1_,6) + "\n";
+		pFile.writeString(name);
+		name = "YLLCENTER " + Te2String(box.y2_,6) + "\n";
+		pFile.writeString(name);
+		name = "CELLSIZE " + Te2String(params_.resx_,6) + "\n";
+		pFile.writeString(name);
+		name = "NODATA_VALUE " + Te2String(params_.dummy_[0],6) + "\n";
+		pFile.writeString(name);
+	}
+	catch (...)
+	{
+		params_.errorMessage_ = "Fail to write raster parameters to the file";
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDecoderASCIIGrid::saveData(TeAsciiFile& pFile)
+{
+	bool isi = (params_.dataType_[0] != TeDOUBLE) && (params_.dataType_[0] != TeFLOAT);
+
+	FILE* fp = pFile.FilePtr();
+	char fmt[100];
+	if (isi)
+		strcpy(fmt,"%.0f ");
+	else
+		strcpy(fmt,"%f ");
+	try
+	{
+		double d;
+		for (int l=0; l<params_.nlines_; ++l)
+		{
+			for (int c=0; c<params_.ncols_; ++c)
+			{
+				getElement(c,l,d);
+				fprintf(fp,fmt,d);
+			}
+			pFile.writeNewLine();
+		}
+	}
+	catch(...)
+	{
+		params_.errorMessage_ = "Fail to write raster data to the file";
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDecoderASCIIGrid::getElement (int col,int lin, double& val,int band)
+{
+	if (col < 0 || lin < 0 || col >= params_.ncols_ || lin >= params_.nlines_)
+		return false;
+	
+	int position = params_.nBands()*(params_.ncols_*lin+col)+band;
+	val = myData_[position];
+	return true;
+}
+
+bool 
+TeDecoderASCIIGrid::setElement (int col, int lin, double val,int band)
+{
+	if (col < 0 || lin < 0 || col >= params_.ncols_ || lin >= params_.nlines_)
+		return false;
+	int position = params_.nBands()*(params_.ncols_*lin+col)+band;
+	myData_[position] = static_cast<float>(val);
+	isModified_ = true;
+	return true;
+}
+
+TeDecoderASCIIGridFactory::TeDecoderASCIIGridFactory(const string& name): 
+	TeDecoderFactory(name) 
+{
+	TeDecoderFactory::instanceName2Dec()["GRD"]  = "ASCIIGRID";	
+	TeDecoderFactory::instanceName2Dec()["ASC"]  = "ASCIIGRID";	
+	TeDecoderFactory::instanceName2Dec()["TXT"]  = "ASCIIGRID";	
+}
diff --git a/src/terralib/kernel/TeDecoderASCIIGrid.h b/src/terralib/kernel/TeDecoderASCIIGrid.h
new file mode 100644
index 0000000..fcd2637
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderASCIIGrid.h
@@ -0,0 +1,97 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderASCIIGrid.h
+    \brief This file deals with decoding of raster data in a ASCII SPRING format
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERASCIIGrid_H
+#define  __TERRALIB_INTERNAL_DECODERASCIIGrid_H
+
+#include "TeDecoder.h"
+
+class TeAsciiFile;
+
+//! Implements a decoder for rasters in ESRI, Inc.'s ASCII Grid format
+/*!
+	The default file extension associated to this decoder ".grd", ".asc" and ".txt".
+*/
+class TL_DLL TeDecoderASCIIGrid : public TeDecoder
+{
+public:
+	//! Empty constructor
+	TeDecoderASCIIGrid();
+
+	//! Constructor from some parameters
+	TeDecoderASCIIGrid(const TeRasterParams& par);
+
+	//! Destructor
+	~TeDecoderASCIIGrid();
+
+	//! Initializes the internal structures of the decoder.
+	void init();
+
+	//! Clears its internal structures.
+	bool clear();
+
+	//! Writes an element
+	bool setElement(int col,int lin, double val, int band=0);
+
+	//! Reads an element
+	bool getElement(int col,int lin, double &val,int band=0);
+
+private:
+
+	bool isModified_;
+	long size_;
+	float* myData_;
+
+	//! Reads the data from a raster file.
+    bool readFile(const string& filename);
+
+	//! Reads raster file header information.
+	bool readParameters();
+
+	//! Writes header information to raster file.
+	bool writeParameters(TeAsciiFile& pFile);
+
+	//! Saves data to raster file.
+	bool saveData(TeAsciiFile& pFile);
+
+};
+
+//! Implements a factory to build decoders for ESRI's ASCII Grid raster format
+class TL_DLL TeDecoderASCIIGridFactory : public TeDecoderFactory
+{
+public:
+	//! Constructor
+	TeDecoderASCIIGridFactory(const string& name);
+
+	//! Implementation for the abstract TeFactory::build.
+	/*!
+	    \param arg A const reference to the used parameters.
+		\return A pointer to the new generated instance.
+    */
+	TeDecoder* build (const TeRasterParams& arg)
+	{  return new TeDecoderASCIIGrid(arg); }
+
+};
+#endif
diff --git a/src/terralib/kernel/TeDecoderDatabase.cpp b/src/terralib/kernel/TeDecoderDatabase.cpp
new file mode 100644
index 0000000..e83bcd6
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderDatabase.cpp
@@ -0,0 +1,534 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDecoderDatabase.h"
+#include "TeDecoderMemory.h"
+#include "TeRasterRemap.h"
+#include "TeVectorRemap.h"
+#include "TeDataTypes.h"
+#include "TeProgress.h"
+
+#include <zlib.h>
+
+#ifndef NO_TEJPEG //FAMI
+#include "TeLibJpegWrapper.h"
+#endif
+
+TeDecoderDatabase::TeDecoderDatabase(const TeRasterParams& par ):
+	TeDecoderVirtualMemory(par),
+	db_(par.database_),
+	blockPortal_(0),
+	memAux_(0),
+	nSelectedBlocks_(0)
+{
+	params_ = par;
+	params_.decoderIdentifier_ = "DB";
+	params_.errorMessage_.clear();
+}
+
+TeDecoderDatabase::~TeDecoderDatabase()
+{
+	if (blockPortal_)
+	{
+		delete blockPortal_;
+		blockPortal_ = 0;
+	}
+	clear();
+}
+
+bool
+TeDecoderDatabase::create()
+{
+	if (db_ == 0)
+		return false;
+
+	// Create raster table in database
+  	if (!db_->createRasterTable(params_.fileName_))
+		return false;
+	return true;
+}
+
+void
+TeDecoderDatabase::init()
+{
+	if (blockPortal_)
+	{
+		blockPortal_->freeResult();
+		delete blockPortal_;
+		blockPortal_ = 0;
+	}
+	clear();
+	params_.status_= TeRasterParams::TeNotReady;
+	if (db_ == 0)			// there is not valid database connection
+	{
+		params_.errorMessage_ = "There is no database pointer associated to raster.";
+		return;
+	}
+
+	if (params_.mode_ == 'c')
+	{
+		if (db_->tableExist(params_.fileName_))
+		{
+			string sql = "DROP TABLE " + params_.fileName_;
+			db_->execute(sql);
+		}
+  		if (!db_->createRasterTable(params_.fileName_))
+		{
+			params_.errorMessage_ = "Fail to create the raster table: " + params_.fileName_;
+			return;
+		}
+		else 
+			params_.status_ = TeRasterParams::TeReadyToWrite;
+	}
+	else if (params_.mode_ == 'w')
+	{
+		if (db_->tableExist(params_.fileName_))
+			params_.status_ = TeRasterParams::TeReadyToWrite;
+	}
+	else if (params_.mode_ == 'r')
+	{
+		if (db_->tableExist(params_.fileName_))
+			params_.status_ = TeRasterParams::TeReadyToRead;		
+	}
+	TeDecoderVirtualMemory::init();
+}
+
+bool
+TeDecoderDatabase::clear()
+{
+	if (db_ == 0)
+		return false;
+	TeDecoderVirtualMemory::clear();
+	if (blockPortal_)
+	{
+		blockPortal_->freeResult();
+	}
+	if (memAux_)
+		delete []memAux_;
+	memAux_ = 0;
+	params_.status_ = TeRasterParams::TeNotReady;
+	if (params_.mode_ == 'c' || params_.mode_ == 'w' && 
+	   (!params_.objectId_.empty() && params_.layerId_ > 0))
+	{
+		TeDatabasePortal* portal = db_->getPortal();
+		string sql = "SELECT geom_table FROM te_representation WHERE geom_type = 512";
+		sql += " AND layer_id = " + Te2String(params_.layerId_);
+		if (portal->query(sql) && portal->fetchRow())
+		{
+			string tName = portal->getData(0);
+			portal->freeResult();
+			sql = "SELECT geom_id FROM " + tName + " WHERE object_id = '" + params_.objectId_ + "'";
+			if (portal->query(sql) && portal->fetchRow())
+			{
+				tName += "_metadata";
+				db_->updateRasterMetadata(tName,portal->getInt(0),params_);
+			}
+		}
+		delete portal;
+	}
+	return true;
+}
+
+string 
+TeDecoderDatabase::codifyId(int col, int lin, int band, int res, int subb)
+{
+	return codifyId(blockIndex(col, lin, band), res, subb);
+}
+
+string TeDecoderDatabase::codifyId(const TeBlockIndex& idx, int res, int subb)
+{
+	char id[32];
+	sprintf(id, "X%dY%dB%dR%dS%d", idx.col_, idx.lin_, idx.band_, res, subb);
+	return string(id);
+}
+
+
+TeBlockIndex 
+TeDecoderDatabase::blockIndex(int col, int lin, int band)
+{
+	if (params_.tiling_type_ != TeRasterParams::TeExpansible)
+		return TeDecoderVirtualMemory::blockIndex(col, lin, band);
+
+	TeBlockIndex bl_idx;
+	bl_idx.band_ = band;
+
+	TeCoord2D tmpCoord = TeCoord2D(col,lin);
+	TeCoord2D xy = params_.index2Coord(tmpCoord);
+
+	double bXSize = params_.blockWidth_*params_.resx_;
+	double bYSize = params_.blockHeight_*params_.resy_;
+
+	if ( xy.x() < 0)
+		bl_idx.col_ = (int)(xy.x()/bXSize - 1);
+	else
+		bl_idx.col_ = (int)(xy.x()/bXSize);
+
+	if (xy.y() < 0)
+		bl_idx.lin_ = (int) (xy.y()/bYSize-1);
+	else
+		bl_idx.lin_ = (int) (xy.y()/bYSize);
+
+	return bl_idx;
+}
+
+void 
+TeDecoderDatabase::decodifyId(const string& id, int& col,int& lin, int& band, int& res, int& subb)
+{
+	int r, s;
+	TeBlockIndex bl_idx;
+	sscanf(id.c_str(),"%*c%d%*c%d%*c%d%*c%d%*c%d", 
+		&bl_idx.col_, &bl_idx.lin_, &bl_idx.band_, &r, &s);
+	blockIndexPos(bl_idx, col, lin, band);
+	res = r;
+	subb = s;
+}
+
+void TeDecoderDatabase::blockIndexPos( const TeBlockIndex& index, int& ulCol, int& ulLin, int& band)
+{
+	if (params_.tiling_type_ != TeRasterParams::TeExpansible)
+		return TeDecoderVirtualMemory::blockIndexPos(index, ulCol, ulLin, band);
+
+	band = index.band();
+
+	double bXSize = params_.blockWidth_*params_.resx_;
+	double bYSize = params_.blockHeight_*params_.resy_;
+
+	TeCoord2D xy(index.column()*bXSize+params_.resx_/2,index.line()*bYSize+params_.resy_/2);
+	xy = params_.coord2Index(xy);
+	ulLin = TeRound(xy.y())-params_.blockHeight_+1;
+	ulCol = TeRound(xy.x());
+}
+
+
+bool TeDecoderDatabase::getRasterBlock(const TeBlockIndex& index, void *block)
+{
+	string index_str;
+	index_str = codifyId(index, params_.resolution_);
+	return getRasterBlock(index_str, block);
+}
+
+bool 
+TeDecoderDatabase::getRasterBlock(const string& index, void *block)
+{
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal) 
+		return false;
+	
+	string q;					// try to get the tile from databatase
+	q ="SELECT * FROM " + params_.fileName_ + " WHERE block_id='" + index + "'";
+
+	if (!portal->query(q))		// error submting query 
+	{
+		delete portal;
+		return 0;
+	}
+	int band=0;
+	if (!portal->fetchRow())	// tile is not in the database
+	{
+		delete portal;
+		return 0;
+	}
+
+	unsigned char*  memread_ptr = 0;
+	if(params_.compression_[band] != TeRasterParams::TeNoCompression)
+	{
+		if(!memAux_)
+		{
+			long size = params_.blockHeight_ * params_.blockWidth_ * params_.elementSize();
+			memAux_ = new unsigned char[size];
+		}
+		memread_ptr = memAux_;
+	}
+	else
+		memread_ptr = reinterpret_cast<unsigned char*>(block);
+
+	// tile is already in the database
+	unsigned long blobLen;
+	if (!portal->getRasterBlock(blobLen,memread_ptr))
+	{
+		delete portal;
+		return false;
+	}
+
+	// decompress blob into a tile (previously allocated) 
+	if (params_.compression_[band] == TeRasterParams::TeZLib)		// zlib compression
+	{
+		unsigned long blockLen = params_.blockHeight_ * params_.blockWidth_ * params_.elementSize();	// size after decompression
+		uncompress (reinterpret_cast<unsigned char*>(block),&blockLen,memread_ptr,blobLen);
+	}
+#ifndef NO_TEJPEG //FAMI
+	else if (params_.compression_[band] == TeRasterParams::TeJpeg) //jpeg compression
+	{
+		int nb;
+		if (!Jpeg::DecompressBuffer(memAux_,blobLen,reinterpret_cast<unsigned char*>(block),params_.blockWidth_,params_.blockHeight_,nb))
+		{
+			delete portal;
+			return false;
+		}
+	}
+#endif
+	delete portal;
+	return true;
+}
+
+bool 
+TeDecoderDatabase::putRasterBlock(const TeBlockIndex& index, void *block, long bsize)
+{
+	string index_str;
+	index_str = codifyId(index, params_.resolution_);
+	return putRasterBlock(index_str, block, bsize);
+}
+
+bool 
+TeDecoderDatabase::putRasterBlock(const string& index, void *block, long bsize)
+{
+	if (db_ == 0 || index.empty())
+		return false;
+
+	// decodify tile parameters from index
+	int res, subb, band, blin, bcol;
+	decodifyId(index,bcol,blin,band,res, subb);
+
+	// calculates the box coordinates of the tile
+	TeCoord2D llt(bcol, blin+params_.blockHeight_-1);
+	TeCoord2D urt(bcol+params_.blockWidth_-1, blin);
+	TeCoord2D ll = params_.index2Coord(llt);
+	TeCoord2D ur = params_.index2Coord(urt);
+
+	TeBox blockbb(ll.x()-params_.resx_/2.,ll.y()-params_.resy_/2.,ur.x()+params_.resx_/2.,ur.y()+params_.resy_/2.);
+	bool status;
+
+	// verify compression option
+	if (params_.compression_[band] == TeRasterParams::TeNoCompression)
+	{
+		status = db_->insertRasterBlock(params_.fileName_,index,blockbb.lowerLeft(),blockbb.upperRight(),reinterpret_cast<unsigned char*>(block),bsize,band,res,subb);
+		return status;
+	}
+	unsigned long finalsize = bsize;  // final size after compression
+	if (!memAux_)
+	{
+		long size = params_.blockHeight_ * params_.blockWidth_ * params_.elementSize();
+		memAux_ = new unsigned char[int(size*1.1 + 12.)];
+	}
+	if (params_.compression_[band] == TeRasterParams::TeZLib)		// ZLib compression
+	{
+		// zlib needs some more space)
+		finalsize = (unsigned long)(bsize*1.1 + 12.);
+		compress (memAux_, &finalsize,reinterpret_cast<unsigned char*>(block),bsize);
+		return db_->insertRasterBlock(params_.fileName_,index,blockbb.lowerLeft(),blockbb.upperRight(),memAux_,finalsize,band,res,subb);
+	}
+#ifndef NO_TEJPEG //FAMI
+	else if (params_.compression_[band] == TeRasterParams::TeJpeg)	// JPEG compression
+	{
+		int sizec = int(bsize*1.1 + 12.);
+		if (!Jpeg::CompressToBuffer(reinterpret_cast<unsigned char*>(block),params_.blockWidth_,params_.blockHeight_,1,memAux_,sizec,75))
+			return false;
+		finalsize = sizec;
+		return db_->insertRasterBlock(params_.fileName_,index,blockbb.lowerLeft(),blockbb.upperRight(),memAux_,finalsize,band,res,subb);
+	}
+#endif
+	return false;
+}
+
+bool
+TeDecoderDatabase::saveLUTTable()
+{
+	if (params_.lutName_.empty())
+		return false;
+	if (!db_ || !db_->createLUTTable(params_.lutName_))
+		return false;
+	for (unsigned int i=0; i<params_.lutb_.size(); i++)
+	{
+		string sql = "INSERT INTO " + params_.lutName_ + " VALUES(";
+		sql += Te2String(i) + ", ";
+		sql += Te2String(params_.lutr_[i]) + ", ";
+		sql += Te2String(params_.lutg_[i]) + ", ";
+		sql += Te2String(params_.lutb_[i]) + ")";
+		if (!db_->execute(sql))
+			return false;
+	}
+	return true;
+}
+
+bool
+TeDecoderDatabase::selectBlocks(TeBox& bb, int resFac, TeRasterParams& parBlock)  
+{ 
+	if (!db_)
+		return false;
+
+	if (blockPortal_)
+		delete blockPortal_;
+
+	blockPortal_ = db_->getPortal();
+	if (!blockPortal_)
+		return false;
+
+	string sql;
+	string sel = db_->getSQLBoxSelect(params_.fileName_, TeRASTER);
+	string where = db_->getSQLBoxWhere (bb, TeRASTER);
+
+	sql = "SELECT "+ sel;
+	sql += " FROM " + params_.fileName_;
+	sql += " WHERE " + where + " AND resolution_factor = " + Te2String(resFac);
+	sql += " ORDER BY lower_x, lower_y, upper_x, upper_y, block_id";
+	
+	if (!blockPortal_->query(sql))
+	{
+		delete blockPortal_;
+		blockPortal_ = 0;
+		return false;
+	}
+	nSelectedBlocks_ = blockPortal_->numRows();
+	parBlock.projection(params_.projection());
+	parBlock.resx_ = params_.resx_*resFac;
+	parBlock.resy_ = params_.resy_*resFac;
+	parBlock.nlines_ = params_.blockHeight_;
+	parBlock.ncols_= params_.blockWidth_;
+	parBlock.nBands(params_.nBands());
+	parBlock.dataType_ = params_.dataType_;
+	parBlock.dummy_ = params_.dummy_;
+	parBlock.useDummy_ = params_.useDummy_;
+	parBlock.photometric_ = params_.photometric_;
+	parBlock.vmax_ = params_.vmax_;
+	parBlock.vmin_ = params_.vmin_;
+	parBlock.lutr_ = params_.lutr_;
+	parBlock.lutg_ = params_.lutg_;
+	parBlock.lutb_ = params_.lutb_;
+	parBlock.interleaving_ = TeRasterParams::TePerBand;
+	return blockPortal_->fetchRow();
+}
+
+bool
+TeDecoderDatabase::getSelectedRasterBlock(TeDecoderMemory* memDec) 
+{ 
+	if (!blockPortal_)
+		return 0;
+	unsigned long srcLen;
+	int i = 0;
+
+	if (!memAux_ )
+	{
+		long size = params_.blockHeight_ * params_.blockWidth_ * params_.elementSize();
+		memAux_ = new unsigned char[size];
+	}
+	int res;
+	TeBox bbBlock;
+	string blockId;
+	do
+	{
+		double lx = 0;
+		double ly = 0;
+		double ux = 0;
+		double uy = 0; 
+		lx = blockPortal_->getDouble("lower_x");
+		ly = blockPortal_->getDouble("lower_y");
+		ux = blockPortal_->getDouble("upper_x");
+		uy = blockPortal_->getDouble("upper_y");
+
+		bbBlock = TeBox(lx, ly, ux, uy);
+
+		blockId = blockPortal_->getData("block_id");
+		res = blockPortal_->getInt("resolution_factor");
+
+	int banda;
+    if(params_.nBands() > 1)
+    {
+		  int col, lin, res, subb;
+		  this->decodifyId(blockId, col, lin, banda, res, subb);
+    }
+	else
+      banda = 0;
+    
+	if (params_.compression_[banda] == TeRasterParams::TeNoCompression)
+		  blockPortal_->getRasterBlock(srcLen, reinterpret_cast<unsigned char*>(memDec->data(banda)));
+    else
+    {
+		blockPortal_->getRasterBlock(srcLen,memAux_);
+
+		if (params_.compression_[banda] == TeRasterParams::TeZLib)
+		{
+			TeRasterParams& par = memDec->params();
+			unsigned long destLen = par.ncols_ * par.nlines_ * par.elementSize();
+			int status;
+			status = uncompress (reinterpret_cast<unsigned char*>(memDec->data(banda)),&destLen,memAux_,srcLen);
+		}
+#ifndef NO_TEJPEG //FAMI
+		else if (params_.compression_[banda] == TeRasterParams::TeJpeg)
+		{
+			int nb = 1;
+			Jpeg::DecompressBuffer(memAux_,srcLen,reinterpret_cast<unsigned char*>(memDec->data(banda)),params_.blockWidth_,params_.blockHeight_,nb);
+		}
+#endif
+    }
+		i++;
+	}while (i<params_.nBands() && blockPortal_->fetchRow());
+	
+	memDec->params().boundingBoxResolution(bbBlock.x1(),bbBlock.y1(),bbBlock.x2(),bbBlock.y2(),
+		                                   params_.resx_*res,params_.resy_*res);
+	memDec->params().blockId_ = blockId;
+	return blockPortal_->fetchRow();
+}
+
+void
+TeDecoderDatabase::clearBlockSelection() 
+{
+	if (blockPortal_)
+		delete blockPortal_;
+	blockPortal_ = 0;
+	nSelectedBlocks_ = 0;
+}
+
+int 
+TeDecoderDatabase::bestResolution(TeBox& bb, int ncols, int nlines, TeProjection* proj)
+{
+	TeBox box = bb;
+	if (proj)
+		box = TeRemapBox(bb, proj, params_.projection());
+	
+	double resx = box.width()/ncols;
+	double resy = box.height()/nlines;
+	
+	double auxx = resx/params_.resx_;
+	double auxy = resy/params_.resy_;
+
+	int aux = (int) (min(auxx,auxy));
+
+	string sql = "SELECT resolution_factor FROM " + params_.fileName_;
+	sql += " WHERE resolution_factor <= " + Te2String(aux) + " ORDER BY resolution_factor DESC";
+
+	TeDatabasePortal* portal = params_.database_->getPortal();
+	if (!portal)
+		return 1;
+
+	if (!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return 1;
+	}
+
+	int res = atoi(portal->getData(0));
+	delete portal;
+	return res;
+}
+
+
diff --git a/src/terralib/kernel/TeDecoderDatabase.h b/src/terralib/kernel/TeDecoderDatabase.h
new file mode 100644
index 0000000..d913536
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderDatabase.h
@@ -0,0 +1,158 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderDatabase.h
+    \brief This file deals with decoding of raster structures stored in a TerraLib database
+*/
+
+#ifndef  __TERRALIB_INTERNAL_DECODERDATADASE_H
+#define  __TERRALIB_INTERNAL_DECODERDATABASE_H
+
+#include "TeDefines.h"
+#include "TeDecoderVirtualMemory.h"
+#include "TeDatabase.h"
+
+//! A concrete class to manipulate raster data stored in a TerraLib database
+/*
+	TeDecoderDatabase uses a virtual memory, to handle the raster blocks 
+	(as proposed by the TerraLib data model to store raster data) traffic from
+	memory to database and vice versa.
+
+	\sa TeDatabase TeDecoderVirtualMemory
+*/
+class TL_DLL TeDecoderDatabase: public TeDecoderVirtualMemory
+{
+public:
+	//! Empty constructor
+	TeDecoderDatabase() :
+		db_(0),	
+		blockPortal_(0),
+		memAux_(0),
+		nSelectedBlocks_(0)
+	{	params_.decoderIdentifier_ = "DB"; }
+
+	//! Constructor from parameters
+	TeDecoderDatabase( const TeRasterParams& par );
+
+	//! Destructor
+	~TeDecoderDatabase();
+
+	//! Sets the database pointer associated to this decoder
+	void setDB (TeDatabase* db) 
+	{ db_ = db; }
+
+	//! Initializes the decoder
+	virtual void init();
+
+	//! Creates the decoder
+	virtual bool create();
+
+	//! Clears the decoder
+	virtual bool clear();
+
+	//! Gets the raster block with index identifier
+	/*!
+		\param index tile unique identifier
+		\param buf pointer to a raster tile in memory
+	*/
+	bool getRasterBlock(const string& index, void *buf);
+
+	//! Saves a raster tile from a virtual memory to permanent storage
+	/*! 
+	    \param index tile unique identifier 
+		\param buf pointer to a raster tile in memory
+		\param bsize size of the block in bytes
+	*/	
+	bool putRasterBlock(const string& index, void *buf, long bsize);
+
+	//! Codifiy the index for the block that contains an element
+	string codifyId(int col, int lin, int band, int res, int subb);
+
+	//! Decodify the parameters of the block that has an index 
+	void decodifyId(const string& id, int& col,int& lin, int& band, int& res, int& subb);
+
+
+	//! Saves the lut table of the raster associated to this decoder
+	bool saveLUTTable();
+
+	//! Search for tiles of image that intersects a certain bounding box in a given resolution
+	/* 
+		\param bb bounding box that should be filled
+		\param resFac resolution factor that identify a level of resolution
+		\param parBlock returns the basic parameters  of the selected tiles
+		\note Resolution factor in decoder database is a multiplier of the original resolution
+		and assume integer multiples of two. Smaller resolution has resolution factor
+		of 1 and the higher resolution have multiple of two values (2,4,8, 16...)
+	*/
+	int bestResolution(TeBox& bb, int ncols, int nlines, TeProjection* proj);
+
+	//! Select the stored raster blocks with a certain resolution to fill a given bounding box
+	/*
+		\param bb bounding box that should be filled 
+		\param the resolution factor desired
+		\param parBlock common parameters of the blocks selected
+		\returns TRUE if could select at least one block and FALSE otherwise
+	*/
+	bool selectBlocks(TeBox& bb, int resFac, TeRasterParams& parBlock);
+
+	//! Gets current raster block an outputs it in a memory decoder
+	bool getSelectedRasterBlock(TeDecoderMemory* memDec);
+
+	//! Clears selected blocks portal
+	void clearBlockSelection();
+
+	//! Returns the number of selectd raster blocks
+	int numberOfSelectedBlocks()
+	{	return nSelectedBlocks_; }
+
+	//! Decodifies the position of a block within the raster from its index
+	virtual void blockIndexPos( const TeBlockIndex& index, int& ulCol, int& ulLin, int& band); 
+
+protected:
+
+	virtual TeBlockIndex blockIndex(int col, int lin, int band);  
+	virtual string codifyId(const TeBlockIndex& idx, int res = 1, int subb = 0); 
+
+	bool getRasterBlock(const TeBlockIndex& index, void *buf);
+	bool putRasterBlock(const TeBlockIndex& index, void *buf, long bsize);
+
+private:
+	TeDatabase			*db_;
+	TeDatabasePortal	*blockPortal_;
+	unsigned char		*memAux_;
+	int					nSelectedBlocks_;
+};
+
+//! Implements a factory to build database decoders
+class TL_DLL TeDecoderDatabaseFactory : public TeDecoderFactory
+{
+public:
+
+	//! Constructor
+	TeDecoderDatabaseFactory(const string& name) : TeDecoderFactory(name) {}
+
+	//! Builds a database decoder
+	virtual TeDecoder* build (const TeRasterParams& arg)
+	{  return new TeDecoderDatabase(arg); }
+};
+#endif
+
diff --git a/src/terralib/kernel/TeDecoderFile.cpp b/src/terralib/kernel/TeDecoderFile.cpp
new file mode 100644
index 0000000..326b851
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderFile.cpp
@@ -0,0 +1,361 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include <TeDecoderFile.h>
+
+#ifdef WIN32
+
+TeDecoderFile::TeDecoderFile ( const TeRasterParams& par )
+{
+	params_ = par;
+	dataInitPos_ = 0;
+	dataInitPos_ = par.offset_;
+	m_dwPosition = 0;
+	m_dwWordSize = params_.elementSize();
+	params_.blockHeight_ = 1;
+	params_.blockWidth_ = params_.ncols_;
+	params_.decoderIdentifier_ = "RAW";
+}
+
+TeDecoderFile::~TeDecoderFile ()
+{
+	if (m_hFile != NULL)
+		clear();
+}
+
+void
+TeDecoderFile::init()
+{
+	clear();
+
+	// First open the file
+	m_hFile = CreateFileA(
+		params_.fileName_.c_str(),	// File name
+		GENERIC_READ | GENERIC_WRITE,	// Read-write
+		FILE_SHARE_READ
+		| FILE_SHARE_WRITE,		// Allow sharing-- we're only doing a quick scan
+		NULL,					// No security attributes
+		OPEN_EXISTING,			// Only open an existing file
+		0,						// Ignore file attributes
+		NULL);					// Ignore hTemplateFile
+
+	if (m_hFile == INVALID_HANDLE_VALUE) 
+			return ;		// could not open file
+
+// Get the file's size
+	m_dwSize = GetFileSize(m_hFile, NULL);
+	if (m_dwSize == 0xffffffff)
+	{
+		m_hFile = NULL;
+		return ;
+	}
+
+// Allocate buffer to get raster line from file
+
+	long mBufferSize = params_.ncols_;
+	if (params_.interleaving_ == TeRasterParams::TePerPixel)
+		mBufferSize *= params_.nBands();
+
+	switch (params_.dataType_[0]) {
+	case (TeUNSIGNEDCHAR):
+		m_buffer = new unsigned char[mBufferSize];
+		break;
+	case (TeCHAR) :
+		m_buffer = new char[mBufferSize];
+		break;
+	case (TeUNSIGNEDSHORT):
+		m_buffer = new unsigned short[mBufferSize];
+		break;
+	case (TeSHORT):
+		m_buffer = new short[mBufferSize];
+		break;
+	case (TeUNSIGNEDLONG):
+		m_buffer = new unsigned long[mBufferSize];
+		break;
+	case (TeLONG):
+		m_buffer = new long[mBufferSize];
+		break;
+	case (TeFLOAT):
+		m_buffer = new float[mBufferSize];
+		break;
+	case (TeDOUBLE):
+		m_buffer = new double[mBufferSize];
+		break;
+	}
+	if ( m_buffer == NULL )
+		return ;
+	else
+		return ;
+		
+}
+
+bool
+TeDecoderFile::create()
+{
+	m_hFile = CreateFileA(
+		params_.fileName_.c_str(),	// File name
+		GENERIC_READ | GENERIC_WRITE,	// Read-write
+		FILE_SHARE_READ
+		| FILE_SHARE_WRITE,		// Allow sharing-- we're only doing a quick scan
+		NULL,					// No security attributes
+		CREATE_NEW,			    // Open a new file
+		0,						// Ignore file attributes
+		NULL);					// Ignore hTemplateFile
+  
+	if ( m_hFile == INVALID_HANDLE_VALUE) 
+		return false;		// could not open file
+
+	char			lpBuffer[1024];
+	unsigned long	nNumberOfBytesToWrite=(long)params_.nBands() * (long)params_.ncols_ * (long)params_.nlines_;    // number of bytes to write
+	nNumberOfBytesToWrite *= (long)params_.nbitsperPixel_[0]/8;    // number of bytes to write
+	unsigned long	nNumberOfBytesWritten;  // pointer to number of bytes written
+
+	for (;nNumberOfBytesToWrite > 1024; nNumberOfBytesToWrite-=1024)
+	{
+		if ( !WriteFile(
+			m_hFile,                // handle to file to write to
+			lpBuffer,               // pointer to data to write to file
+			1024,					// number of bytes to write
+			&nNumberOfBytesWritten,  // pointer to number of bytes written
+			NULL					// pointer to structure for overlapped I/O
+			))
+ 			return false;			// could not write to file
+	}
+
+	if ( !WriteFile(
+		m_hFile,                // handle to file to write to
+		lpBuffer,               // pointer to data to write to file
+		nNumberOfBytesToWrite,	// number of bytes to write
+		&nNumberOfBytesWritten,  // pointer to number of bytes written
+		NULL					// pointer to structure for overlapped I/O
+		))
+ 		return false;			// could not write to file
+	
+	SetFilePointer (m_hFile, NULL, NULL, FILE_BEGIN);
+
+// Allocate buffer to get raster line from file
+
+	switch (params_.dataType_[0]) {
+	case (TeUNSIGNEDCHAR):
+		m_buffer = new unsigned char[params_.ncols_];
+		break;
+	case (TeCHAR) :
+		m_buffer = new char[params_.ncols_];
+		break;
+	case (TeUNSIGNEDSHORT):
+		m_buffer = new unsigned short[params_.ncols_];
+		break;
+	case (TeSHORT):
+		m_buffer = new short[params_.ncols_];
+		break;
+	case (TeUNSIGNEDLONG):
+		m_buffer = new unsigned long[params_.ncols_];
+		break;
+	case (TeLONG):
+		m_buffer = new long[params_.ncols_];
+		break;
+	case (TeFLOAT):
+		m_buffer = new float[params_.ncols_];
+		break;
+	case (TeDOUBLE):
+		m_buffer = new double[params_.ncols_];
+		break;
+	}
+
+	if ( m_buffer == NULL )
+		return false;
+
+	if (params_.dummy_[0])
+	{
+		for (int b=0; b<params_.nBands();b++)
+			for (int l=0; l<params_.nlines_;l++)
+				for (int c=0; c<params_.ncols_;c++)
+					setElement ( c, l, params_.dummy_[0], b);
+	}
+	return true;
+}
+
+bool
+TeDecoderFile::clear()
+{
+	if (!m_hFile)
+		return true;
+
+	CloseHandle(m_hFile);
+	m_hFile = NULL;
+	delete m_buffer;
+	m_buffer = 0;
+	params_.status_ = TeRasterParams::TeNotReady;
+	return true;
+}
+
+
+bool
+TeDecoderFile::getRasterBlock(const TeBlockIndex& index, void *buf)
+{   
+	int ulCol, ulLin, band;
+        blockIndexPos(index, ulCol, ulLin, band);
+
+	int nb = params_.nBands();
+	DWORD position;
+	DWORD nBytesToRead;
+	int inc, inic;
+	if (params_.interleaving_ == TeRasterParams::TePerPixel)
+	{
+		inc = nb;
+		inic = index.band();
+		position = dataInitPos_ + params_.ncols_*(nb* ulLin);
+		nBytesToRead = m_dwWordSize*params_.ncols_*nb;
+	}
+	else
+	{
+		inc = 1;
+		inic = 0;
+		position = dataInitPos_ + params_.ncols_*(nb*ulLin + band);
+		nBytesToRead = m_dwWordSize*params_.ncols_;
+	}
+	DWORD diff = position - m_dwPosition;
+	if (diff != 0)
+		m_dwPosition = SetFilePointer (m_hFile, diff, NULL, FILE_CURRENT);
+	unsigned long nBytesRead;
+	if (!ReadFile(m_hFile, m_buffer, nBytesToRead, &nBytesRead, NULL))
+		return false;
+	m_dwPosition += nBytesRead;
+
+	int i,n;
+	switch (params_.dataType_[0]) 
+	{
+	case (TeUNSIGNEDCHAR):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((unsigned char*)buf)[n] = ((unsigned char*)m_buffer)[i];
+		break;
+	case (TeCHAR) :
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((char*)buf)[n] = ((char*)m_buffer)[i];
+		break;
+	case (TeUNSIGNEDSHORT):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((unsigned short*)buf)[n] = ((unsigned short*)m_buffer)[i];
+		break;
+	case (TeSHORT):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((short*)buf)[n] = ((short*)m_buffer)[i];
+		break;
+	case (TeUNSIGNEDLONG):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((unsigned long*)buf)[n] = ((unsigned long*)m_buffer)[i];
+		break;
+	case (TeLONG):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((long*)buf)[n] = ((long*)m_buffer)[i];
+		break;
+	case (TeFLOAT):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((float*)buf)[n] = ((float*)m_buffer)[i];
+		break;
+	case (TeDOUBLE):
+		for (i=inic,n=0;i<params_.ncols_*nb;i+=inc, n++)
+			((double*)buf)[n] = ((double*)m_buffer)[i];
+		break;
+	}
+
+	return true;
+}
+
+
+
+bool 
+TeDecoderFile::putRasterBlock(const TeBlockIndex& index, void *buf, long bsize)
+{
+	int band,ulCol,ulLin;
+  blockIndexPos(index, ulCol, ulLin, band);
+
+	DWORD position = dataInitPos_ + params_.ncols_*(params_.nBands()*ulLin + band);
+	DWORD diff = position - m_dwPosition;
+	if (diff != 0)
+		SetFilePointer (m_hFile, diff, NULL, FILE_CURRENT);
+	DWORD nBytesToWrite = m_dwWordSize*params_.ncols_,
+		nBytesWritten;
+	int i;
+	switch (params_.dataType_[0]) 
+	{
+	case (TeUNSIGNEDCHAR):
+		for (i=0;i<params_.ncols_;i++)
+			((unsigned char*)m_buffer)[i] = ((unsigned char*)buf)[i];
+		break;
+	case (TeCHAR) :
+		for (i=0;i<params_.ncols_;i++)
+			((char*)m_buffer)[i] = ((char*)buf)[i];
+		break;
+	case (TeUNSIGNEDSHORT):
+		for (i=0;i<params_.ncols_;i++)
+			((unsigned short*)m_buffer)[i] = ((unsigned short*)buf)[i];
+		break;
+	case (TeSHORT):
+		for (i=0;i<params_.ncols_;i++)
+			((short*)m_buffer)[i] = ((short*)buf)[i];
+		break;
+	case (TeUNSIGNEDLONG):
+		for (i=0;i<params_.ncols_;i++)
+			((unsigned long*)m_buffer)[i] = ((unsigned long*)buf)[i];
+		break;
+	case (TeLONG):
+		for (i=0;i<params_.ncols_;i++)
+			((long*)m_buffer)[i] = ((long*)buf)[i];
+		break;
+	case (TeFLOAT):
+		for (i=0;i<params_.ncols_;i++)
+			((float*)m_buffer)[i] = ((float*)buf)[i];
+		break;
+	case (TeDOUBLE):
+		memcpy (m_buffer,buf,params_.ncols_);
+		break;
+	}
+
+	if (!WriteFile(m_hFile, m_buffer, nBytesToWrite, &nBytesWritten, NULL))
+		return false;
+
+	m_dwPosition += nBytesWritten;
+
+	return true;
+}
+
+TeBlockIndex TeDecoderFile::blockIndex(int col, int lin, int band)
+{
+  TeBlockIndex bl_index;
+
+  bl_index.band_ = band;
+  bl_index.lin_ = lin;
+  bl_index.col_ = 0;
+
+  return bl_index;
+}
+
+void TeDecoderFile::blockIndexPos(const TeBlockIndex& index, int& ulCol, int& ulLin, int& band)
+{
+  ulCol = 0;
+  ulLin = index.line() * params_.blockWidth_;
+  band = index.band();
+}
+
+#endif
diff --git a/src/terralib/kernel/TeDecoderFile.h b/src/terralib/kernel/TeDecoderFile.h
new file mode 100644
index 0000000..9ce051c
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderFile.h
@@ -0,0 +1,84 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderFile.h
+    \brief This file deals with decoding of raster structures in a binary file using Windows support
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERFILE_H
+#define  __TERRALIB_INTERNAL_DECODERFILE_H
+
+#ifdef WIN32
+#include "TeDecoderVirtualMemory.h"
+#include <windows.h>
+#include <winbase.h>
+
+//! Implements decoder to raster data stored in a file in a binary raw format
+/*	\note This implementation is valid only for the windows platform
+*/
+class TL_DLL TeDecoderFile : public TeDecoderVirtualMemory
+{
+public:
+	//! Constructor
+	TeDecoderFile ( const TeRasterParams& );
+
+	//! Destructor
+	~TeDecoderFile ();
+
+	//! Initalizes its internal structures
+	void init	();
+
+	//! Created a handle
+	bool create	();
+
+	//! Releases the internal structures
+	bool clear	();
+
+protected:
+	bool	getRasterBlock(const TeBlockIndex& index, void *buf); 
+	bool	putRasterBlock(const TeBlockIndex& index, void *buf, long bsize);
+	TeBlockIndex blockIndex(int col, int lin, int band);
+	void blockIndexPos(const TeBlockIndex& index, int& ulCol, int& ulLin, int& band);
+	
+private:
+
+	unsigned long	dataInitPos_;
+	HANDLE  m_hFile;			// Handle to file we're currently zapping
+	LPVOID  m_buffer;			// Pointer to view of file mapped to memory
+	DWORD	m_dwSize;			// File size in bytes
+	DWORD	m_dwPosition;		// Current file pointer position
+	DWORD	m_dwWordSize;		// word size in bytes
+};
+
+//! Implements a factory to build file decoders
+class TL_DLL TeDecoderFileFactory : public TeDecoderFactory
+{
+public:
+
+	TeDecoderFileFactory(const string& name) : TeDecoderFactory(name) {}
+
+	//! Builds a file decoder
+	virtual TeDecoder* build (const TeRasterParams& arg)
+	{  return new TeDecoderFile(arg); }
+};
+
+#endif
+#endif
diff --git a/src/terralib/kernel/TeDecoderMemory.cpp b/src/terralib/kernel/TeDecoderMemory.cpp
new file mode 100644
index 0000000..f4775ec
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderMemory.cpp
@@ -0,0 +1,591 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDecoderMemory.h"
+#include "TeException.h"
+
+#include <assert.h>
+#include <cstring> //FAMI
+
+TeDecoderMemory::TeDecoderMemory(): 
+	nelems_(0),
+	size_(0),
+	getelement_ptr_(0),
+	setelement_ptr_(0),	
+	data_TeUNSIGNEDCHAR_(0),  
+	data_TeCHAR_(0),  
+	data_TeUNSIGNEDSHORT_(0),  
+	data_TeSHORT_(0),  
+	data_TeINTEGER_(0), 
+	data_TeUNSIGNEDLONG_(0), 
+	data_TeLONG_(0),  
+	data_TeFLOAT_(0),
+	data_TeDOUBLE_(0)
+{
+	 params_.decoderIdentifier_ = "MEM";
+}
+
+TeDecoderMemory::TeDecoderMemory(const TeRasterParams& par): 
+	nelems_(0),
+	size_(0),
+	getelement_ptr_(0),
+	setelement_ptr_(0),	
+	data_TeUNSIGNEDCHAR_(0),  
+	data_TeCHAR_(0),  
+	data_TeUNSIGNEDSHORT_(0),  
+	data_TeSHORT_(0),  
+	data_TeINTEGER_(0), 
+	data_TeUNSIGNEDLONG_(0), 
+	data_TeLONG_(0),  
+	data_TeFLOAT_(0),
+	data_TeDOUBLE_(0)
+{	
+	params_ = par; 
+	params_.decoderIdentifier_ = "MEM"; 
+}
+
+TeDecoderMemory::~TeDecoderMemory ()
+{
+	clear();
+}
+
+void*	
+TeDecoderMemory::data(int band)
+{
+	// this is possible when band interleaved data
+	if (params_.interleaving_ != TeRasterParams::TePerBand)
+		return 0;
+
+	void* pt = 0;
+	switch (params_.dataType_[band]) 
+	{
+	case TeUNSIGNEDCHAR:
+		pt =  (data_TeUNSIGNEDCHAR_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	case TeCHAR:
+		pt =  (data_TeCHAR_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	case TeUNSIGNEDSHORT:
+		pt = (data_TeUNSIGNEDSHORT_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	case (TeSHORT):
+		pt = (data_TeSHORT_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+    case (TeINTEGER):
+        pt = (data_TeINTEGER_) + (params_.ncols_ * params_.nlines_*band);
+        break;                
+	case (TeUNSIGNEDLONG):
+		pt = (data_TeUNSIGNEDLONG_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	case (TeLONG):
+		pt = (data_TeLONG_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	case (TeFLOAT):
+		pt = (data_TeFLOAT_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	case (TeDOUBLE):
+		pt = (data_TeDOUBLE_) + (params_.ncols_ * params_.nlines_*band);
+		break;
+	default:
+		break;
+	}
+	return (void*) pt;
+}
+
+void 
+TeDecoderMemory::init()
+{	
+	params_.errorMessage_.clear();
+	params_.status_= TeRasterParams::TeNotReady;
+	nelems_ = params_.nlines_*params_.ncols_*params_.nBands();
+	if (!allocateMemory() || !resetMemory())
+	{
+		params_.errorMessage_ = "Fail to allocate enough memory to hold the raster.";
+		return;
+	}
+	updateFuncPtr();
+
+	// this decoder always grant an read/write access
+	params_.status_ = TeRasterParams::TeReadyToWrite;
+}
+
+bool 
+TeDecoderMemory::getElement (int col,int lin, double& val,int band)
+{
+	unsigned long position = 0;
+	switch (params_.interleaving_)
+	{
+	case TeRasterParams::TePerPixel:
+		position = params_.nBands()*(params_.ncols_*lin+col)+band;
+		break;
+	case TeRasterParams::TePerLine:
+		position = (params_.nBands()*params_.ncols_*lin)+band*params_.ncols_+col;
+		break;
+	case TeRasterParams::TePerBand:
+		position = band*(params_.ncols_*params_.nlines_)+(params_.ncols_*lin+col);
+		break;
+	}
+	assert(position < nelems_);
+	(this->*( getelement_ptr_))(position,val);
+	return true;
+}
+
+bool 
+TeDecoderMemory::setElement (int col, int lin, double val,int band)
+{
+	unsigned long position = 0;
+	switch (params_.interleaving_)
+	{
+	case TeRasterParams::TePerPixel:
+		position = params_.nBands()*(params_.ncols_*lin+col)+band;
+		break;
+	case TeRasterParams::TePerLine:
+		position = (params_.nBands()*params_.ncols_*lin)+band*params_.ncols_+col;
+		break;
+	case TeRasterParams::TePerBand:
+		position = band*(params_.ncols_*params_.nlines_)+(params_.ncols_*lin+col);
+		break;
+	}
+	assert(position < nelems_);
+	(this->*( setelement_ptr_))(position,val);
+	return true;
+}
+
+void TeDecoderMemory::updateFuncPtr()
+{
+	if ( getelement_ptr_ != 0 ) 
+		getelement_ptr_ = 0;
+
+	if ( setelement_ptr_ != 0 ) 
+		setelement_ptr_ = 0;
+
+	switch ( params_.dataType_[0] ) 
+	{
+		case (TeCHAR) :
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeCHAR;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeCHAR;
+			break;
+		}
+		case (TeUNSIGNEDSHORT):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeUNSIGNEDSHORT;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeUNSIGNEDSHORT;
+			break;
+		}
+		case (TeSHORT):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeSHORT;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeSHORT;
+			break;
+		}
+		case (TeINTEGER):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeINTEGER;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeINTEGER;
+			break;
+		}
+		case (TeUNSIGNEDLONG):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeUNSIGNEDLONG;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeUNSIGNEDLONG;
+			break;
+		}
+		case (TeLONG):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeLONG;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeLONG;
+			break;
+		}
+		case (TeFLOAT):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeFLOAT;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeFLOAT;
+			break;
+		}
+		case (TeDOUBLE):
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeDOUBLE;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeDOUBLE;
+			break;
+		}
+		default:
+		{
+			getelement_ptr_ = &TeDecoderMemory::getElement_TeUNSIGNEDCHAR;
+			setelement_ptr_ = &TeDecoderMemory::setElement_TeUNSIGNEDCHAR;
+			break;
+		}				
+	}
+}
+
+bool 
+TeDecoderMemory::allocateMemory()
+{
+	long nelems = params_.nlines_*params_.ncols_*params_.nBands();
+
+	// allocate necessary memory
+	switch (params_.dataType_[0]) 
+	{
+	case (TeUNSIGNEDCHAR):
+		if ((nelems*sizeof(unsigned char)) == (nelems_*sizeof(unsigned char)) && data_TeUNSIGNEDCHAR_)
+			return true;
+        data_TeUNSIGNEDCHAR_ = new unsigned char [nelems_];
+		if (!data_TeUNSIGNEDCHAR_)
+			return false;
+		size_ = nelems_ * sizeof(unsigned char);
+		break;
+
+	case (TeCHAR):
+		if ((nelems*sizeof(char)) == (nelems_*sizeof(char)) && data_TeCHAR_)
+			return true;
+		data_TeCHAR_ = new char [nelems_];
+		if (!data_TeCHAR_)
+			return false;
+		size_ = nelems_ * sizeof(char);
+		break;
+
+	case (TeUNSIGNEDSHORT):
+		if ((nelems*sizeof(unsigned short)) == (nelems_*sizeof(unsigned short)) && data_TeUNSIGNEDSHORT_)
+			return true;
+		data_TeUNSIGNEDSHORT_ = new unsigned short [nelems_];
+		if (!data_TeUNSIGNEDSHORT_)
+			return false;
+		size_ = nelems_ * sizeof(unsigned short);
+		break;
+
+	case (TeSHORT):
+		if ((nelems*sizeof( short)) == (nelems_*sizeof(short)) && data_TeSHORT_)
+			return true;
+		data_TeSHORT_ = new short [nelems_];
+		if (!data_TeSHORT_)
+			return false;
+		size_ = nelems_ * sizeof(short);
+		break;
+
+    case (TeINTEGER):
+ 		if ((nelems*sizeof(int)) == (nelems_*sizeof(int)) && data_TeINTEGER_)
+			return true;
+       data_TeINTEGER_ = new int [nelems_];
+        if (!data_TeINTEGER_)
+			return false;
+        size_ = nelems_ * sizeof(int);
+        break;
+
+	case (TeUNSIGNEDLONG):
+		if ((nelems*sizeof(unsigned long)) == (nelems_*sizeof(unsigned long)) && data_TeUNSIGNEDLONG_)
+			return true;
+		data_TeUNSIGNEDLONG_ = new unsigned long [nelems_];
+		if (!data_TeUNSIGNEDLONG_)
+			return false;
+		size_ = nelems_ * sizeof(unsigned long);
+		break;
+
+	case (TeLONG):
+		if ((nelems*sizeof(long)) == (nelems_*sizeof(long)) && data_TeLONG_)
+			return true;
+		data_TeLONG_ = new long [nelems_];
+		if (!data_TeLONG_)
+			return false;
+		size_ = nelems_ * sizeof(long);
+		break;
+
+	case (TeFLOAT):
+		if ((nelems*sizeof(float)) == (nelems_*sizeof(float)) && data_TeFLOAT_)
+			return true;
+		data_TeFLOAT_ = new float [nelems_];
+		if (!data_TeFLOAT_)
+			return false;
+		size_ = nelems_ * sizeof(float);
+		break;
+
+	case (TeDOUBLE):
+		if ((nelems*sizeof(double)) == (nelems_*sizeof(double)) && data_TeDOUBLE_)
+			return true;
+		data_TeDOUBLE_ = new double [nelems_];
+		if (!data_TeDOUBLE_)
+			return false;
+		size_ = nelems_ * sizeof(double);
+		break;
+
+	default:
+		return false;
+	}
+	return true;
+}
+
+
+bool 
+TeDecoderMemory::resetMemory()
+{
+	unsigned int i;
+	switch (params_.dataType_[0]) 
+	{
+	case (TeBIT):
+	case (TeCHAR):
+		if (!data_TeCHAR_)
+			return false;
+		for(i=0; i<nelems_; data_TeCHAR_[i]=static_cast<char>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeUNSIGNEDCHAR):
+		if (!data_TeUNSIGNEDCHAR_)
+			return false;
+		for(i=0; i<nelems_; data_TeUNSIGNEDCHAR_[i]=static_cast<unsigned char>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeUNSIGNEDSHORT):
+		if (!data_TeUNSIGNEDSHORT_)
+			return false;
+		for(i=0; i<nelems_; data_TeUNSIGNEDSHORT_[i]=static_cast<unsigned short>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeSHORT):
+		if (!data_TeSHORT_)
+			return false;
+		for(i=0; i<nelems_; data_TeSHORT_[i]=static_cast<short>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeINTEGER):
+		if (!data_TeINTEGER_)
+			return false;
+		for(i=0; i<nelems_; data_TeINTEGER_[i]=static_cast<int>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeUNSIGNEDLONG):
+		if (!data_TeUNSIGNEDLONG_)
+			return false;
+		for(i=0; i<nelems_; data_TeUNSIGNEDLONG_[i]=static_cast<unsigned long>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeLONG):
+		if (!data_TeLONG_)
+			return false;
+		for(i=0; i<nelems_; data_TeLONG_[i]=static_cast<long>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeFLOAT):
+		if (!data_TeFLOAT_)
+			return false;
+		for(i=0; i<nelems_; data_TeFLOAT_[i]=static_cast<float>(params_.dummy_[0]),++i);
+		break;
+
+	case (TeDOUBLE):
+		if (!data_TeDOUBLE_)
+			return false;
+		for(i=0; i<nelems_; data_TeDOUBLE_[i]=static_cast<double>(params_.dummy_[0]),++i);
+		break;
+
+	default:
+		break;	
+}
+
+	return true;
+}
+
+bool
+TeDecoderMemory::clear()
+{
+	if (data_TeUNSIGNEDCHAR_)
+	{
+		delete [] data_TeUNSIGNEDCHAR_;
+		data_TeUNSIGNEDCHAR_ = 0;
+		return true;
+	}
+	if (data_TeCHAR_)
+	{
+		delete [] data_TeCHAR_; 
+		data_TeCHAR_ = 0;
+		return true;
+	}
+	if (data_TeUNSIGNEDSHORT_)
+	{
+		delete [] data_TeUNSIGNEDSHORT_;  
+		data_TeUNSIGNEDSHORT_ = 0;
+		return true;
+	}
+	if (data_TeSHORT_)
+	{
+		delete [] data_TeSHORT_;  
+		data_TeSHORT_ = 0;
+		return true;
+	}
+	if (data_TeINTEGER_) 
+	{
+		delete [] data_TeINTEGER_;  
+		data_TeINTEGER_ = 0;
+		return true;
+	}
+	if (data_TeUNSIGNEDLONG_)
+	{
+		delete [] data_TeUNSIGNEDLONG_;  
+		data_TeUNSIGNEDLONG_ = 0;
+		return true;
+	}
+	if (data_TeLONG_)
+	{
+		delete [] data_TeLONG_;  
+		data_TeLONG_ = 0;
+		return true;
+	}
+	if (data_TeFLOAT_)
+	{
+		delete [] data_TeFLOAT_;
+		data_TeFLOAT_ = 0;
+		return true;
+	}
+	if (data_TeDOUBLE_)
+	{
+		delete [] data_TeDOUBLE_;
+		data_TeDOUBLE_ = 0;
+		return true;
+	}
+	params_.status_ = TeRasterParams::TeNotReady;
+	return true;
+}
+
+
+inline void TeDecoderMemory::setElement_TeUNSIGNEDCHAR(const long& pos, const double& val)
+{
+	assert(data_TeUNSIGNEDCHAR_ != 0 );
+	data_TeUNSIGNEDCHAR_[pos] = (unsigned char)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeCHAR(const long& pos, const double& val)
+{
+	assert(data_TeCHAR_ != 0 );
+	data_TeCHAR_[pos] = (char)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeUNSIGNEDSHORT(const long& pos, const double& val)
+{
+	assert(data_TeUNSIGNEDSHORT_ != 0 );
+	data_TeUNSIGNEDSHORT_[pos] = (unsigned short)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeSHORT(const long& pos, const double& val)
+{
+	assert(data_TeSHORT_ != 0 );
+	data_TeSHORT_[pos] = (short)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeINTEGER(const long& pos, const double& val)
+{
+	assert(data_TeINTEGER_ != 0 );
+	data_TeINTEGER_[pos] = (int)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeUNSIGNEDLONG(const long& pos, const double& val)
+{
+	assert(data_TeUNSIGNEDLONG_ != 0 );
+	data_TeUNSIGNEDLONG_[pos] = (unsigned long)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeLONG(const long& pos, const double& val)
+{
+	assert(data_TeLONG_ != 0 );
+	data_TeLONG_[pos] = (long)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeFLOAT(const long& pos, const double& val)
+{
+	assert(data_TeFLOAT_ != 0 );
+	data_TeFLOAT_[pos] = (float)val;
+}
+
+
+inline void TeDecoderMemory::setElement_TeDOUBLE(const long& pos, const double& val)
+{
+	assert(data_TeDOUBLE_ != 0 );
+	data_TeDOUBLE_[pos] = val;
+}
+
+
+inline void TeDecoderMemory::getElement_TeUNSIGNEDCHAR(const long& pos, double& val)
+{
+	assert(data_TeUNSIGNEDCHAR_ != 0 );
+	val = (double)data_TeUNSIGNEDCHAR_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeCHAR(const long& pos, double& val)
+{
+	assert(data_TeCHAR_ != 0 );
+	val = (double)data_TeCHAR_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeUNSIGNEDSHORT(const long& pos, double& val)
+{
+	assert(data_TeUNSIGNEDSHORT_ != 0 );
+	val = (double)data_TeUNSIGNEDSHORT_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeSHORT(const long& pos, double& val)
+{
+	assert(data_TeSHORT_ != 0 );
+	val = (double)data_TeSHORT_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeINTEGER(const long& pos, double& val)
+{
+	assert(data_TeINTEGER_ != 0 );
+	val = (double)data_TeINTEGER_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeUNSIGNEDLONG(const long& pos, double& val)
+{
+	assert(data_TeUNSIGNEDLONG_ != 0 );
+	val = (double)data_TeUNSIGNEDLONG_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeLONG(const long& pos,double& val)
+{
+	assert(data_TeLONG_ != 0 );
+	val = (double)data_TeLONG_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeFLOAT(const long& pos, double& val)
+{
+	assert(data_TeFLOAT_ != 0 );
+	val = (double)data_TeFLOAT_[pos];
+}
+
+
+inline void TeDecoderMemory::getElement_TeDOUBLE(const long& pos, double& val)
+{
+	assert(data_TeDOUBLE_ != 0 );
+	val = (double)data_TeDOUBLE_[pos];
+}
+
diff --git a/src/terralib/kernel/TeDecoderMemory.h b/src/terralib/kernel/TeDecoderMemory.h
new file mode 100644
index 0000000..3eb7852
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderMemory.h
@@ -0,0 +1,279 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderMemory.h
+    \brief This file deals with decoding of raster structures as a mulitdimensional matrix in memory.
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERMEMORY_H
+#define  __TERRALIB_INTERNAL_DECODERMEMORY_H
+
+#include "TeDecoder.h"
+
+//! Implements a decoder to a raster stored as a as a mulitdimensional matrix in memory
+/*
+	This classes tries to allocate the matrix in the memory RAM. No strategies or policies
+	to allocate huge matrices are applied. It also doesn't support multiple bands with different types.
+	For overcome this limitations use the class TeDecoderSmartMem.
+	\sa TeDecoderSmartMem
+*/
+class TL_DLL TeDecoderMemory : public TeDecoder
+{
+public:
+	//! Empty constructor
+	TeDecoderMemory();
+
+	//! Constructor from parameters
+	TeDecoderMemory (const TeRasterParams& par);
+
+	//! Destructor
+	~TeDecoderMemory ();
+
+	//! Writes an element
+	bool setElement (int col,int lin, double val, int band=0);
+
+	//! Reads an element
+	bool getElement (int col,int lin, double &val,int band=0);
+
+	//! Retuns a pointer to a given band
+	/*
+		\note This method is applicable only when band interleaved organization
+	*/
+	void* data (int band=0);
+
+	//! Initalizes the internal structures
+	void init();
+
+	//! Releases the internal structures
+	bool clear();
+
+	//! Allocates the necessary memory
+	bool allocateMemory();
+
+	//! Deallocates the used memory
+	bool resetMemory();
+
+private:
+
+	unsigned int nelems_;
+	unsigned int size_;
+
+	//! Type definition for the getElement function pointer      
+	typedef void (TeDecoderMemory::*GetEleFunctPtrT)( const long& pos, double& val );
+
+	//! Type definition for the setElement function pointer     
+	typedef void (TeDecoderMemory::*SetEleFunctPtrT)( const long& pos, const double& val );
+
+	//! A pointer to the current getElement method following the current data type
+	GetEleFunctPtrT getelement_ptr_;
+
+	//! A pointer to the current setElement method following the current data
+	SetEleFunctPtrT setelement_ptr_;
+
+	//! A casted pointer to the current data
+	unsigned char* data_TeUNSIGNEDCHAR_;  
+
+	//! A casted pointer to the current data
+	char* data_TeCHAR_;  
+
+	//! A casted pointer to the current data
+	unsigned short* data_TeUNSIGNEDSHORT_;  
+
+	//! A casted pointer to the current data
+	short* data_TeSHORT_;  
+
+	//! A casted pointer to the current data
+	int* data_TeINTEGER_;  
+
+	//! A casted pointer to the current data
+	unsigned long* data_TeUNSIGNEDLONG_;  
+
+	//! A casted pointer to the current data
+	long* data_TeLONG_;  
+
+	//! A casted pointer to the current data
+	float* data_TeFLOAT_;
+
+	//! A casted pointer to the current data
+	double* data_TeDOUBLE_;  
+
+	//! Update the function pointer using the current raster parameters   
+	void updateFuncPtr();  
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/      
+	inline void setElement_TeUNSIGNEDCHAR( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/   
+	inline void setElement_TeCHAR( const long& pos, const double& val );  
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/   
+	inline void setElement_TeUNSIGNEDSHORT( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/   
+	inline void setElement_TeSHORT( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/   
+	inline void setElement_TeINTEGER( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/   
+	inline void setElement_TeUNSIGNEDLONG( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/      
+	inline void setElement_TeLONG( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/     
+	inline void setElement_TeFLOAT( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/    
+	inline void setElement_TeDOUBLE( const long& pos, const double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/     
+	inline void getElement_TeUNSIGNEDCHAR( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/  
+	inline void getElement_TeCHAR( const long& pos, double& val );  
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/  
+	inline void getElement_TeUNSIGNEDSHORT( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/   
+	inline void getElement_TeSHORT( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/    
+	inline void getElement_TeINTEGER( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/      
+	inline void getElement_TeUNSIGNEDLONG( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/      
+	inline void getElement_TeLONG( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/      
+	inline void getElement_TeFLOAT( const long& pos, double& val );
+
+	/*! \brief Method overload.
+		\param line Line.
+		\param col Column.
+		\param band Band.
+		\param val Pixel value.
+	*/
+	inline void getElement_TeDOUBLE( const long& pos, double& val );  
+};
+
+//! Implements a factory to build decoder to MEMORY raster
+class TL_DLL TeDecoderMemoryFactory : public TeDecoderFactory
+{
+public:
+
+	//! Factory constructor
+	TeDecoderMemoryFactory(const string& name) : TeDecoderFactory(name) {}
+
+	//! Build an object
+	TeDecoder* build (const TeRasterParams& arg)
+	{  return new TeDecoderMemory(arg); }
+};
+#endif
+
diff --git a/src/terralib/kernel/TeDecoderMemoryMap.cpp b/src/terralib/kernel/TeDecoderMemoryMap.cpp
new file mode 100644
index 0000000..1a4def6
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderMemoryMap.cpp
@@ -0,0 +1,430 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDecoderMemoryMap.h"
+#include "TeUtils.h"
+#include "TeAsciiFile.h"
+#include <map>
+#include <string>
+
+TeDecoderMemoryMap::TeDecoderMemoryMap ( const TeRasterParams& par )
+{
+	params_ = par;
+	dataInitPos_ = 0;
+	dataInitPos_ = par.offset_;
+	m_lpszFile = 0;
+	m_hFile = 0;
+	params_.decoderIdentifier_ = "MEMMAP";
+	params_.errorMessage_.clear();
+}
+
+TeDecoderMemoryMap::~TeDecoderMemoryMap ()
+{
+	if (m_hFile != 0)
+		clear();
+}
+bool
+TeDecoderMemoryMap::getElement (int col,int lin, double& val,int band)
+{
+	unsigned long position = 0;
+	switch (params_.interleaving_)
+	{
+	case TeRasterParams::TePerPixel:
+		position = params_.nBands()*(params_.ncols_*lin+col)+band;
+		break;
+	case TeRasterParams::TePerLine:
+		position = (params_.nBands()*params_.ncols_*lin)+band*params_.ncols_+col;
+		break;
+	case TeRasterParams::TePerBand:
+		position = band*(params_.ncols_*params_.nlines_)+(params_.ncols_*lin+col);
+		break;
+	}
+	
+	position += dataInitPos_;
+    switch (params_.dataType_[0])
+	{
+	case (TeUNSIGNEDCHAR):
+		val = ((unsigned char*)m_lpszFile)[position];
+		break;
+	case (TeCHAR) :
+		val = ((char*) m_lpszFile)[position];
+		break;
+	case (TeUNSIGNEDSHORT):
+		unsigned short uval;
+		if (params_.swap_)
+			uval = swaps(((unsigned short*)m_lpszFile)[position]);
+		else
+			uval = ((unsigned short*)m_lpszFile)[position];
+		val = uval;
+		break;
+	case (TeSHORT):
+		if (params_.swap_)
+			val = swaps(((short*)m_lpszFile)[position]);
+		else
+			val = ((short*)m_lpszFile)[position];
+		break;
+	case (TeINTEGER):
+		val = ((int*)m_lpszFile)[position];
+		break;
+	case (TeUNSIGNEDLONG):
+		val = ((unsigned long*)m_lpszFile)[position];
+		break;
+	case (TeLONG):
+		val = ((long*)m_lpszFile)[position];
+		break;
+	case (TeFLOAT):
+		val = ((float*)m_lpszFile)[position];
+		break;
+	case (TeDOUBLE):
+		val = ((double*)m_lpszFile)[position];
+		break;
+	default:
+		return false;
+	}
+	return true;
+}
+
+bool
+TeDecoderMemoryMap::setElement (int col,int lin, double val, int band)
+{
+	unsigned long position = 0;
+	switch (params_.interleaving_)
+	{
+	case TeRasterParams::TePerPixel:
+		position = params_.nBands()*(params_.ncols_*lin+col)+band;
+		break;
+	case TeRasterParams::TePerLine:
+		position = (params_.nBands()*params_.ncols_*lin)+band*params_.ncols_+col;
+		break;
+	case TeRasterParams::TePerBand:
+		position = band*(params_.ncols_*params_.nlines_)+(params_.ncols_*lin+col);
+		break;
+	}
+	
+	position += dataInitPos_;
+	switch (params_.dataType_[0])
+	{
+	case (TeUNSIGNEDCHAR):
+		((unsigned char*)m_lpszFile)[position] = (unsigned char) val;
+		break;
+	
+	case (TeCHAR) :
+		((char*) m_lpszFile)[position] = (char) val;
+		break;
+
+	case (TeUNSIGNEDSHORT):
+		if (params_.swap_)
+			((unsigned short*)m_lpszFile)[position] = swaps((unsigned short) val);
+		else
+			((unsigned short*)m_lpszFile)[position] = (unsigned short) val;
+		break;
+
+	case (TeSHORT):
+		if (params_.swap_)
+			((short*)m_lpszFile)[position] = swaps((short) val);
+		else
+			((short*)m_lpszFile)[position] = (short) val;
+		break;
+
+	case (TeINTEGER):
+		((int*)m_lpszFile)[position] = (int) val;
+		break;
+
+	case (TeUNSIGNEDLONG):
+		((unsigned long*)m_lpszFile)[position] = (unsigned long) val;
+		break;
+	
+	case (TeLONG):
+		((long*)m_lpszFile)[position] = (long) val;
+		break;
+
+	case (TeFLOAT):
+		((float*)m_lpszFile)[position] = (float) val;
+		break;
+	
+	case (TeDOUBLE):
+		((double*)m_lpszFile)[position] = val;
+    break;
+    
+	default:
+		return false;
+	}
+	return true;
+}
+
+#ifdef WIN32
+void
+TeDecoderMemoryMap::init()
+{
+	clear();
+	DWORD dwDesiredAccess, dwCreationDisposition, flProtect,dwDesiredAccessV ;
+	if (params_.mode_ == 'c')
+	{
+		params_.writeParametersFile();
+		dwCreationDisposition = CREATE_ALWAYS;
+		dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
+		flProtect = PAGE_READWRITE;
+		dwDesiredAccessV = FILE_MAP_WRITE;
+	}
+	else if (params_.mode_ == 'w')
+	{
+		params_.readParametersFile();
+		dwCreationDisposition = OPEN_ALWAYS;
+		dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;		
+		flProtect = PAGE_READWRITE;
+		dwDesiredAccessV = FILE_MAP_WRITE;
+	}
+	else 	// default mode: reading
+	{
+		params_.readParametersFile();
+		dwCreationDisposition = OPEN_EXISTING;
+		dwDesiredAccess = GENERIC_READ;		
+		flProtect = PAGE_READONLY;
+		dwDesiredAccessV = FILE_MAP_READ;
+	}
+
+	
+	// calculate the expected file size accordingly to the parameters
+	unsigned long fsize = (long)(params_.nBands()*params_.ncols_*params_.nlines_);    
+	fsize *= params_.elementSize(0);
+	
+	if (fsize <= 0)
+		return;
+	
+	// First open the file
+	m_hFile = CreateFileA(
+		params_.fileName_.c_str(),	// File name
+		dwDesiredAccess,			// Desired access
+		FILE_SHARE_READ| FILE_SHARE_WRITE,	// Allow sharing-- we're only doing a quick scan
+		NULL,								// No security attributes
+		dwCreationDisposition,				// Creation disposition
+		0,									// Ignore file attributes
+		NULL);								// Ignore hTemplateFile
+
+	if (m_hFile == INVALID_HANDLE_VALUE)
+		return;		// could not open file
+			
+	// get the file's size
+	m_dwSize = GetFileSize(m_hFile, NULL);
+	if (m_dwSize == 0xffffffff)
+	{
+		m_hFile = NULL;
+		return;
+	}
+	
+	if (params_.mode_ == 'c')	
+	{
+		if (m_dwSize < fsize)
+		{
+			char lpBuffer[1024];
+			int nNumberOfBytesToWrite = fsize-m_dwSize;
+			unsigned long nNumberOfBytesWritten;  // pointer to number of bytes written
+			for (;nNumberOfBytesToWrite > 1024; nNumberOfBytesToWrite-=1024)
+			{
+				if (!WriteFile(m_hFile, lpBuffer, 1024, &nNumberOfBytesWritten, NULL))
+				{
+					CloseHandle(m_hFile);
+					m_hFile = NULL;
+					return;
+				}
+			}
+			if (!WriteFile(m_hFile, lpBuffer, nNumberOfBytesToWrite, &nNumberOfBytesWritten, NULL))
+			{
+				CloseHandle(m_hFile);
+				m_hFile = NULL;
+				return;
+			}	
+		}
+	}
+	else
+	{
+		if (m_dwSize < fsize)
+			return;
+	}
+
+	// Create a mapping object from the file
+	m_hMapping = CreateFileMapping(
+		m_hFile,		// Handle we got from CreateFile
+		NULL,			// No security attributes
+		flProtect,		// read-write
+		0, 0,			// Max size = current size of file
+		NULL);			// Don't name the mapping object
+		
+	if ( m_hMapping == NULL )
+	{
+		CloseHandle(m_hFile);
+		m_hFile = NULL;
+		return;
+	}
+
+	// Map the file to memory
+	switch (params_.dataType_[0]) {
+	case (TeUNSIGNEDCHAR):
+		m_lpszFile = (unsigned char*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0,	0);
+		break;
+	case (TeCHAR) :
+		m_lpszFile = (char*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0, 0);
+		break;
+	case (TeUNSIGNEDSHORT):
+		m_lpszFile = (unsigned short*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0, 0);
+		break;
+	case (TeSHORT):
+		m_lpszFile = (short*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0,	0);
+		break;
+	case (TeUNSIGNEDLONG):
+		m_lpszFile = (unsigned long*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0,	0);
+		break;
+	case (TeLONG):
+		m_lpszFile = (long*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0, 0);
+		break;
+	case (TeFLOAT):
+		m_lpszFile = (float*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0,	0);
+		break;
+	case (TeDOUBLE):
+		m_lpszFile = (double*) MapViewOfFile(m_hMapping, dwDesiredAccessV, 0, 0, 0);
+		break;
+	}
+	if ( m_lpszFile == NULL )
+		return ;
+
+	if (params_.mode_ == 'c')
+	{
+		int b, l, c;
+		for (b=0; b<params_.nBands();++b)
+			for (l=0; l<params_.nlines_;++l)
+				for (c=0; c<params_.ncols_;++c)
+					setElement(c, l, params_.dummy_[b], b);
+	}
+	if (params_.mode_ =='c' || params_.mode_ == 'w')
+		params_.status_ = TeRasterParams::TeReadyToWrite;
+	else 
+		params_.status_ = TeRasterParams::TeReadyToRead;	
+	return;
+}
+
+bool
+TeDecoderMemoryMap::clear()
+{
+	params_.status_ = TeRasterParams::TeNotReady;
+	params_.errorMessage_.clear();
+	if (m_hFile == NULL)
+		return true;
+
+	if ( !UnmapViewOfFile(m_lpszFile) )
+		return false;
+
+	CloseHandle(m_hMapping);
+	CloseHandle(m_hFile);
+	m_hFile = NULL;
+	return true;
+}
+#else
+// Linux version: uses mmap
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+void
+TeDecoderMemoryMap::init()
+{
+	clear();
+	mode_t	mode=0;
+	if (params_.mode_ == 'c') 
+	{
+		m_dwSize = (long)(params_.nBands()*params_.ncols_*params_.nlines_);    
+		m_dwSize *= params_.elementSize(0);
+		if (m_dwSize <= 0)
+			return;
+		params_.writeParametersFile();
+		m_hFile = open(params_.fileName_.c_str(),O_RDWR|O_CREAT,S_IRWXU);
+		mode =  (PROT_READ | PROT_WRITE);
+      		lseek(m_hFile, m_dwSize - 1, SEEK_SET);
+      		write(m_hFile, '\0', 1);	
+	}
+	else if (params_.mode_ == 'r') 
+	{	
+		params_.readParametersFile();
+		m_dwSize = (long)(params_.nBands()*params_.ncols_*params_.nlines_);    
+		m_dwSize *= params_.elementSize(0);
+		if (m_dwSize <= 0)
+			return;
+		m_hFile = open(params_.fileName_.c_str(),O_RDONLY,S_IRWXU);	
+		mode = PROT_READ;
+	}
+	else
+	{
+		params_.readParametersFile();
+		m_dwSize = (long)(params_.nBands()*params_.ncols_*params_.nlines_);    
+		m_dwSize *= params_.elementSize(0);
+		if (m_dwSize <= 0)
+			return;	
+		m_hFile = open(params_.fileName_.c_str(),O_RDWR,S_IRWXU);
+		mode = (PROT_READ | PROT_WRITE);
+	}
+	
+	if (m_hFile == -1)
+		return;				// could not open file
+
+	m_lpszFile  =  mmap(0, m_dwSize, mode, MAP_SHARED, m_hFile, 0);
+	if (((long) m_lpszFile)  == -1 )
+		return;
+
+	if (params_.mode_ == 'c')	
+	{
+		int b, l, c;
+		for (b=0; b<params_.nBands();++b)
+			for (l=0; l<params_.nlines_;++l)
+				for (c=0; c<params_.ncols_;++c)
+					setElement(c, l, params_.dummy_[b], b);
+	}
+	
+	if (params_.mode_ =='c' || params_.mode_ == 'w')
+		params_.status_ = TeRasterParams::TeReadyToWrite;
+	else 
+		params_.status_ = TeRasterParams::TeReadyToRead;	
+	return;
+}
+
+bool
+TeDecoderMemoryMap::clear()
+{
+	params_.status_ = TeRasterParams::TeNotReady;
+	params_.errorMessage_.clear();
+	if (m_lpszFile == 0)
+		return true;
+
+	if ( munmap(m_lpszFile, m_dwSize) == -1)
+		return false;
+	m_lpszFile = 0;
+	close(m_hFile);
+	m_hFile = 0;
+	return true;
+}
+#endif
+
+TeDecoderMemoryMapFactory::TeDecoderMemoryMapFactory(const string& name) : 
+	TeDecoderFactory(name) 
+{
+	TeDecoderFactory::instanceName2Dec()["RAW"] = "MEMMAP";
+}
diff --git a/src/terralib/kernel/TeDecoderMemoryMap.h b/src/terralib/kernel/TeDecoderMemoryMap.h
new file mode 100644
index 0000000..3131ac2
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderMemoryMap.h
@@ -0,0 +1,94 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderMemoryMap.h
+    \brief This file deals with decoding of raster data in a bynary file, using the memory map operation system functionality
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERMEMORYMAP_H
+#define  __TERRALIB_INTERNAL_DECODERMEMORYMAP_H
+
+#include "TeDecoder.h"
+
+#ifdef WIN32
+#include <windows.h>
+#include <winbase.h>
+#else
+#include <sys/mman.h>
+#endif
+
+ 
+//! Implements a decoder to raster data in a bynary file, using the memory map operation system functionality
+/*
+	Due to limits set by the operating system, the maximum amount of data you can map 
+	with a single instance of a memory map is 2^31 - 1 (or 2 GB).
+*/
+class TL_DLL TeDecoderMemoryMap : public TeDecoder
+{
+public:
+	//! Constructor
+	TeDecoderMemoryMap ( const TeRasterParams& );
+
+	//! Destructor
+	~TeDecoderMemoryMap ();
+
+	//! Reads an element
+	bool setElement (int col,int lin, double val, int band=0);
+
+	//! Writes an element
+	bool getElement (int col,int lin, double &val,int band=0);
+
+	//! Initalizes the internal structures
+	virtual void init();
+
+	//! Releases the internal structures
+	virtual bool clear();
+
+private:
+	long	dataInitPos_;
+#ifdef WIN32
+// Windows support to file memory mapping
+	HANDLE  m_hFile;			// Handle to file we're currently zapping
+	HANDLE	m_hMapping;			// Handle to memory-mapping of that file
+	LPVOID  m_lpszFile;			// Pointer to view of file mapped to memory
+	DWORD	m_dwSize;
+#else
+// Linux support to file memory mapping
+	int	m_hFile;			//(fd) Handle to file we're currently zapping
+	void*	m_lpszFile;			// Pointer to view of file mapped to memory
+	long	m_dwSize;
+#endif
+};
+
+//! Implements a factory to build memory map decoder
+class TL_DLL TeDecoderMemoryMapFactory : public TeDecoderFactory
+{
+public:
+
+	//! Factory constructor
+	TeDecoderMemoryMapFactory(const string& name);
+
+	//! Builds the object
+	virtual TeDecoder* build (const TeRasterParams& arg)
+	{  return new TeDecoderMemoryMap(arg); }
+};
+#endif
+
diff --git a/src/terralib/kernel/TeDecoderSPR.cpp b/src/terralib/kernel/TeDecoderSPR.cpp
new file mode 100644
index 0000000..1335950
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderSPR.cpp
@@ -0,0 +1,399 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeException.h"
+#include "TeDecoderSPR.h"
+#include "TeAsciiFile.h"
+#include "TeUtils.h"
+
+#include <cstdlib>
+#include <cstring>
+#include <fstream>
+using std::ifstream;
+using std::ofstream;
+
+TeDecoderSPR::TeDecoderSPR() : 
+	TeDecoderSmartMem(),
+	isModified_(false)
+{	
+	params_.decoderIdentifier_ = "SPR";	
+}
+
+TeDecoderSPR::TeDecoderSPR (const TeRasterParams& par) : 
+	TeDecoderSmartMem(),
+	isModified_(false)
+{	
+	params_.errorMessage_.clear();
+	if (par.fileName_.empty())
+		return;
+	params_ = par;
+	params_.decoderIdentifier_ = "SPR";
+	if (params_.mode_ == 'w' || params_.mode_ == 'r')
+		readParameters();
+}
+
+TeDecoderSPR::~TeDecoderSPR()
+{
+	if ( isModified_ && (params_.mode_ == 'w' || params_.mode_ == 'c'))
+	{			// save contents to disk
+		try
+		{
+			TeAsciiFile sFile(params_.fileName_,"w+");
+			if (writeParameters(sFile))
+				saveData(sFile);
+		}
+		catch (...)
+		{
+		}
+	}
+	TeDecoderSmartMem::clear();
+}
+
+bool
+TeDecoderSPR::clear()
+{
+	if ( isModified_ && (params_.mode_ == 'w' || params_.mode_ == 'c'))
+	{			// save contents to disk
+		try
+		{
+			TeAsciiFile sFile(params_.fileName_,"w+");
+			if (writeParameters(sFile))
+				saveData(sFile);
+		}
+		catch (...)
+		{
+		}
+		isModified_ = false;
+	}
+	TeDecoderSmartMem::clear();
+	return true;
+}
+
+bool 
+TeDecoderSPR::readParameters()
+{
+	try
+	{
+		TeAsciiFile	pFile (params_.fileName_);
+		string name;
+
+		// check if there is the GRIDDEF section
+		while (pFile.isNotAtEOF())
+		{
+			name = pFile.readString();
+			if (name[0] =='/' && name[1] == '/')	// skip comments
+				pFile.findNewLine();
+			else if (name == "GRIDDEF")
+				break;
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+		
+		// read INFO section
+		double x1, y2;
+		int ncols;
+		double dummy;
+
+		// Expected format to grid definition:
+		// GRIDDEF  <ncols>  <nlins>  <X1>  <Y2>  <resX>  <resY>  <nodatavalue>
+		params_.ncols_ = ncols = pFile.readInt();
+		params_.nlines_ = pFile.readInt();
+		x1 = pFile.readFloat();
+		y2 = pFile.readFloat();
+		params_.resx_ = pFile.readFloat();
+		params_.resy_ = pFile.readFloat();
+		params_.nBands(1);
+		dummy = pFile.readFloat();
+		params_.useDummy_ = true;
+		params_.setDummy(dummy);
+
+		do
+		{
+			name = pFile.readString();
+			if (name[0] =='/' && name[1] == '/')	// skip comments
+				pFile.findNewLine();
+		} while (pFile.isNotAtEOF() && name != "GRIDCLASS" && name != "INFO_END");
+		
+		if (name == "GRIDCLASS" )
+		{
+			params_.setPhotometric(TeRasterParams::TePallete);
+			params_.setDataType(TeUNSIGNEDCHAR);
+
+			// Expected format GRIDCLASS  <nclass>  <ncolorR>  <ncolorG>  <ncolorB>  <nameclass>
+			params_.lutr_.clear();
+			params_.lutg_.clear();
+			params_.lutb_.clear();
+
+			params_.lutr_.insert(params_.lutr_.begin(),256,0);
+			params_.lutg_.insert(params_.lutg_.begin(),256,0);
+			params_.lutb_.insert(params_.lutb_.begin(),256,0);
+			
+			vector<string> lnames;
+			name = pFile.readString();
+			while (pFile.isNotAtEOF() && name != "INFO_END") // loop through all class definitions
+			{
+				int index = atoi(name.c_str());
+				params_.lutr_[index] = pFile.readInt(); 
+				params_.lutg_[index] = pFile.readInt(); 
+				params_.lutb_[index] = pFile.readInt(); 
+				lnames.clear();
+				pFile.readStringList(lnames);   // class name			
+				name = pFile.readString();	 // next index		
+			} 
+
+			if (!pFile.isNotAtEOF())	// unexpected end of file
+				return false;
+		}
+		else if (name == "INFO_END")
+		{
+			params_.setDataType(TeDOUBLE);
+			params_.setPhotometric(TeRasterParams::TeMultiBand);
+		}
+		params_.topLeftResolutionSize(x1,y2,params_.resx_,params_.resy_,
+				                      params_.ncols_,params_.nlines_,false);
+		TeProjection* pp = new TeNoProjection();
+		params_.projection(pp);
+		delete pp;
+	}
+	catch(...)
+	{
+		return false;
+	}
+	return true;
+}
+
+bool
+TeDecoderSPR::readFile(const string& filename)
+{
+	string valstring;
+	try 
+	{
+		TeAsciiFile	pFile (filename);
+		string name;
+		while (pFile.isNotAtEOF() && name != "INFO_END")
+		{
+			name = pFile.readString();
+			if (name[0] =='/' && name[1] == '/')	// skip comments
+				pFile.findNewLine();
+		}
+		if (!pFile.isNotAtEOF())					// unexpected end of file
+			return false;
+
+		for (int lin = 0; lin < params_.nlines_; lin++)
+		{
+			for (int col = 0; col < params_.ncols_; col++)
+			{
+				valstring = pFile.readString();
+				setElement(col,lin,atof(valstring.c_str()));
+			}
+		}
+	}
+	catch(...)
+	{
+		return false;
+	}
+	return true;
+}
+
+void
+TeDecoderSPR::init()
+{
+	params_.status_= TeRasterParams::TeNotReady;
+	int nb = params_.nBands();
+	if (nb != 1 )
+	{
+		params_.errorMessage_ = "Ascii SPRING can store raster with only 1 band.";
+		return;
+	}
+
+	// 1 - check if file exists and has the necessary permission
+	if (params_.mode_ == 'c')	// creating a new file
+	{
+		ofstream dataFile(params_.fileName_.c_str()); // try to (re)create the file
+		if (!dataFile)
+		{
+			params_.errorMessage_ = "Fail to (re)create the raster the file:" + params_.fileName_;
+			return;
+		}
+	}
+	else if (params_.mode_ == 'w')
+	{
+		ifstream dataFile(params_.fileName_.c_str()); // check if file exists
+		if (!dataFile)
+		{
+			params_.errorMessage_ = "Fail to open the raster the file:" + params_.fileName_;
+			return; 
+		}
+		dataFile.close();
+	}
+	else if (params_.mode_ == 'r')
+	{
+		ifstream dataFile(params_.fileName_.c_str()); // check if file exists
+		if (!dataFile)
+		{
+			params_.errorMessage_ = "Fail to open the raster the file:" + params_.fileName_;
+			return; 
+		}
+		dataFile.close();	
+	}
+
+	// 2 - check if there is memory enough to handle the data
+	TeDecoderSmartMem::init();		
+	if (params_.status_ == TeRasterParams::TeNotReady)
+		return;
+
+	// 3 - try to read the data
+	if (params_.mode_ == 'c')	// creating a new file
+	{
+		try
+		{
+			params_.status_ = TeRasterParams::TeNotReady;
+			TeAsciiFile sFile(params_.fileName_,"w+");
+			if (!writeParameters(sFile) || !saveData(sFile))
+			{
+				params_.errorMessage_ = "Fail to write the raster to file";
+				return;
+			}
+			params_.status_ = TeRasterParams::TeReadyToWrite;
+		}
+		catch (...)
+		{
+			params_.errorMessage_ = "Fail to write the raster to file";
+		}
+	}
+	else if (params_.mode_ == 'w')
+	{
+		if (!readFile(params_.fileName_))
+		{
+			params_.status_ = TeRasterParams::TeNotReady;
+			params_.errorMessage_ = "Fail to read the raster the file:" + params_.fileName_;
+			return; 
+		}
+		params_.status_ = TeRasterParams::TeReadyToWrite;
+	}
+	else if (params_.mode_ == 'r')
+	{
+		if (!readFile(params_.fileName_))
+		{
+			params_.status_ = TeRasterParams::TeNotReady;
+			params_.errorMessage_ = "Fail to read the raster the file:" + params_.fileName_;
+			return; 
+		}
+		params_.status_ = TeRasterParams::TeReadyToRead;	
+	}
+}
+
+bool 
+TeDecoderSPR::writeParameters(TeAsciiFile& pFile)
+{
+	string name;
+	try
+	{
+		TeBox box = params_.boundingBox();
+		name = "GRIDREG\nINFO\n";
+		pFile.writeString(name);
+		name = "//Formato GRIDDEF  <ncols>  <nlins>  <X1>  <Y2>  <resX>  <resY>  <nodatavalue>\n";
+		pFile.writeString(name);
+		name = "GRIDDEF ";
+		pFile.writeString(name);
+		name = Te2String(params_.ncols_) + " " + Te2String(params_.nlines_) + " ";
+		pFile.writeString(name);
+		name = Te2String(box.x1_,6) + " " + Te2String(box.y2_,6) + " ";
+		pFile.writeString(name);
+		name = Te2String(params_.resx_,6) + " " + Te2String(params_.resy_,6) + " ";
+		pFile.writeString(name);
+		name = Te2String(params_.dummy_[0],6) + "\n";
+		pFile.writeString(name);
+
+		if (params_.photometric_[0] == TeRasterParams::TePallete)
+		{
+			name = "GRIDCLASS\n";
+			for (unsigned int nc=0; nc<params_.lutr_.size(); ++nc)
+			{
+				name = Te2String(nc) + " " + Te2String(params_.lutr_[nc]);
+				name += " " + Te2String(params_.lutg_[nc]) + " " + Te2String(params_.lutb_[nc]);
+				name += " c" + Te2String(nc) + "\n";
+				pFile.writeString(name);
+			}
+		}
+		name = "INFO_END\n";
+		pFile.writeString(name);
+	}
+	catch (...)
+	{
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDecoderSPR::saveData(TeAsciiFile& pFile)
+{
+	bool isi = (params_.dataType_[0] != TeDOUBLE) && (params_.dataType_[0] != TeFLOAT);
+
+	FILE* fp = pFile.FilePtr();
+	char fmt[100];
+	if (isi)
+		strcpy(fmt,"%.0f ");
+	else
+		strcpy(fmt,"%f ");
+	try
+	{
+		double d;
+		for (int l=0; l<params_.nlines_; ++l)
+		{
+			for (int c=0; c<params_.ncols_; ++c)
+			{
+				TeDecoderSmartMem::getElement(c,l,d);
+				fprintf(fp,fmt,d);
+			}
+			pFile.writeNewLine();
+		}
+		string spc = "END\n";
+		pFile.writeString(spc);
+	}
+	catch(...)
+	{
+		return false;
+	}
+	return true;
+}
+
+bool 
+TeDecoderSPR::setElement (int col,int lin, double val, int band)
+{
+	if (TeDecoderSmartMem::setElement(col,lin,val,band))
+	{
+		isModified_ = true;
+		return true;
+	}
+	else
+		return false;
+}
+
+
+TeDecoderSPRFactory::TeDecoderSPRFactory(const string& name): 
+	TeDecoderFactory(name) 
+{
+	TeDecoderFactory::instanceName2Dec()["SPR"] = "SPR";
+}
diff --git a/src/terralib/kernel/TeDecoderSPR.h b/src/terralib/kernel/TeDecoderSPR.h
new file mode 100644
index 0000000..3586944
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderSPR.h
@@ -0,0 +1,80 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderSPR.h
+    \brief This file deals with decoding of raster data in a ASCII SPRING format
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERSPR_H
+#define  __TERRALIB_INTERNAL_DECODERSPR_H
+
+#include "TeDecoderSmartMem.h"
+
+class TeAsciiFile;
+
+//! Implements a decoder for raster data in ASCII-SPRING format
+/*! The description of this format can be found at SPRING website <http://www.dpi.inpe.br/spring>.\par
+	The default file extension associated to this format is ".spr".
+*/
+class TL_DLL TeDecoderSPR : public TeDecoderSmartMem
+{
+public:
+	//! Empty constructor
+	TeDecoderSPR();
+
+	//! Constructor from some parameters
+	TeDecoderSPR(const TeRasterParams& par);
+
+	//! Destructor
+	~TeDecoderSPR();
+
+	//! Intializes the internal structures
+	void init();
+
+	//! Releases the internal structures
+	bool clear();
+
+	//! Writes an element
+	bool setElement (int col,int lin, double val, int band=0);
+
+private:
+
+	bool isModified_;
+
+    bool readFile(const string& filename);
+	bool readParameters();
+	bool writeParameters(TeAsciiFile& pFile);
+	bool saveData(TeAsciiFile& pFile);
+};
+
+//! Implements a factory to build decoders to ASCII-SPRING raster
+class TL_DLL TeDecoderSPRFactory : public TeDecoderFactory
+{
+public:
+	//! Factory constructor
+	TeDecoderSPRFactory(const string& name);
+
+	//! Builds the object
+	TeDecoder* build (const TeRasterParams& arg)
+	{  return new TeDecoderSPR(arg); }
+};
+
+#endif
diff --git a/src/terralib/kernel/TeDecoderSmartMem.cpp b/src/terralib/kernel/TeDecoderSmartMem.cpp
new file mode 100644
index 0000000..855bf50
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderSmartMem.cpp
@@ -0,0 +1,539 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDecoderSmartMem.h"
+
+#include "TeException.h"
+#include "TeAgnostic.h"
+
+
+TeDecoderSmartMem::TeDecoderSmartMem ()
+{ 
+  initVars();
+  
+  params_.decoderIdentifier_ = "SMARTMEM";
+};
+
+
+TeDecoderSmartMem::TeDecoderSmartMem ( const TeRasterParams& par )
+{
+  initVars();
+  
+  params_ = par; 
+  params_.decoderIdentifier_ = "SMARTMEM"; 
+};
+
+
+
+TeDecoderSmartMem::~TeDecoderSmartMem ()
+{
+  clear();
+}
+
+void TeDecoderSmartMem::init()
+{
+  clear();
+  
+  /* Creating the new data structures */
+
+  if( ( params_.nBands() > 0 ) && 
+      ( params_.nlines_ > 0 ) &&
+      ( params_.ncols_ > 0 ) ) {
+  
+    std::vector< unsigned int > tiles_sizes;
+    
+    for( int band_index = 0 ; band_index < params_.nBands() ; 
+      ++band_index ) {
+      
+      tiles_sizes.push_back( params_.elementSize( band_index ) * params_.ncols_ );
+    }
+
+    if( man_manager_.reset( params_.nBands(), params_.nlines_, 
+      tiles_sizes, TeRasterMemManager::AutoMemPol ) ) {
+      
+      if (params_.mode_ == 'c' || params_.mode_ == 'w') // creating a new file
+      {
+        params_.status_ = TeRasterParams::TeReadyToWrite;
+      } else if (params_.mode_ == 'r') {
+        params_.status_ = TeRasterParams::TeReadyToRead;      
+      }
+      
+      updateFuncPtrVectors();
+      dummyFill();    
+    } else {
+      clear();
+    }
+  }
+}
+
+bool TeDecoderSmartMem::clear()
+{
+  man_manager_.clear();
+  
+  if( getelement_ptrs_vec_ != 0 ) {
+    delete[] getelement_ptrs_vec_;
+    getelement_ptrs_vec_ = 0;
+  }
+  
+  if( setelement_ptrs_vec_ != 0 ) {
+    delete[] setelement_ptrs_vec_;
+    setelement_ptrs_vec_ = 0;
+  }
+  
+  params_.status_= TeRasterParams::TeNotReady;
+  
+  return true;
+}
+
+
+void TeDecoderSmartMem::initVars()
+{ 
+  getelement_ptrs_vec_ = 0;
+  setelement_ptrs_vec_ = 0;
+};
+
+
+void TeDecoderSmartMem::updateFuncPtrVectors()
+{
+  if( params_.nBands() > 0 ) {
+    getelement_ptrs_vec_ = new GetEleFunctPtrT[ params_.nBands() ];
+    if( getelement_ptrs_vec_ == 0 ) {
+      throw TeException( UNKNOWN_ERROR_TYPE, 
+        "Unable to allocate GET function pointers vector", false );
+    }
+
+    setelement_ptrs_vec_ = new SetEleFunctPtrT[ params_.nBands() ];
+    if( setelement_ptrs_vec_ == 0 ) {
+      throw TeException( UNKNOWN_ERROR_TYPE, 
+        "Unable to allocate SET function pointers vector", false );
+    }
+    
+    for( int band = 0 ; band < params_.nBands() ; ++band ) {
+      switch ( params_.dataType_[ band ] ) {
+        case (TeUNSIGNEDCHAR):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeUNSIGNEDCHAR;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeUNSIGNEDCHAR;
+            break;
+          }
+        case (TeCHAR) :
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeCHAR;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeCHAR;          
+            break;
+          }
+        case (TeUNSIGNEDSHORT):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeUNSIGNEDSHORT;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeUNSIGNEDSHORT;
+            break;
+          }
+        case (TeSHORT):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeSHORT;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeSHORT;
+            break;
+          }
+        case (TeINTEGER):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeINTEGER;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeINTEGER;
+            break;
+          }
+        case (TeUNSIGNEDLONG):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeUNSIGNEDLONG;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeUNSIGNEDLONG;
+            break;
+          }
+        case (TeLONG):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeLONG;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeLONG;
+            break;
+          }
+        case (TeFLOAT):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeFLOAT;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeFLOAT;
+            break;
+          }
+        case (TeDOUBLE):
+          {
+            getelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::getElement_TeDOUBLE;
+            setelement_ptrs_vec_[ band ] = 
+              &TeDecoderSmartMem::setElement_TeDOUBLE;
+            break;
+          }
+        default:
+          {
+            TEAGN_LOG_AND_THROW( "Invalid raster data type" );
+            break;
+          }
+      }
+    }
+  }
+}
+
+
+void TeDecoderSmartMem::dummyFill()
+{
+  TEAGN_DEBUG_CONDITION( 
+    ( params_.status_ != TeRasterParams::TeNotReady),
+    "Raster not Ready" );
+  
+  /* Checking if dummy fill is required */
+  
+  if( ! params_.useDummy_ ) {
+    return;
+  }
+  
+  /* Dummy fill */
+      
+  const unsigned int nlines = (unsigned int )params_.nlines_;
+  const unsigned int ncols = (unsigned int )params_.ncols_;
+
+  unsigned int line = 0;
+  unsigned int col = 0;
+  double double_dummy_value = 0;
+  
+  for( int band = 0 ; band < params_.nBands() ; ++band ) {
+    if( params_.useDummy_ ) {
+      double_dummy_value = params_.dummy_[ band ];
+    } else {
+      double_dummy_value = 0;
+    }
+  
+    switch ( params_.dataType_[ band ] ) {
+      case (TeUNSIGNEDCHAR):
+        {
+          unsigned char dummy_value = (unsigned char)double_dummy_value;
+          unsigned char* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (unsigned char*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeCHAR) :
+        {
+          char dummy_value = (char)double_dummy_value;
+          char* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (char*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeUNSIGNEDSHORT):
+        {
+          unsigned short dummy_value = (unsigned short)double_dummy_value;
+          unsigned short* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (unsigned short*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeSHORT):
+        {
+          short dummy_value = (short)double_dummy_value;
+          short* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (short*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeINTEGER):
+        {
+          int dummy_value = (int)double_dummy_value;
+          int* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (int*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeUNSIGNEDLONG):
+        {
+          unsigned long dummy_value = (unsigned long)double_dummy_value;
+          unsigned long* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (unsigned long*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeLONG):
+        {
+          long dummy_value = (long)double_dummy_value;
+          long* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (long*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeFLOAT):
+        {
+          float dummy_value = (float)double_dummy_value;
+          float* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (float*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = dummy_value;
+            }
+          }
+          
+          break;
+        }
+      case (TeDOUBLE):
+        {
+          double* line_ptr = 0;
+          
+          for( line = 0 ; line < nlines ; ++line ) {
+            line_ptr = (double*) man_manager_.getTilePointer( band, 
+              line );
+          
+            for( col = 0 ; col < ncols ; ++col ) {
+              line_ptr[ col ] = double_dummy_value;
+            }
+          }
+          
+          break;
+        }
+      default:
+        {
+          TEAGN_LOG_AND_THROW( "Invalid raster data type" );
+          break;
+        }
+    }
+  }  
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeUNSIGNEDCHAR( const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (unsigned char*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (unsigned char)val;
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeCHAR(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (char*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (char)val;  
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeUNSIGNEDSHORT(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (unsigned short*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (unsigned short)val;  
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeSHORT(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (short*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (short)val;
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeINTEGER(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (int*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (int)val;
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeUNSIGNEDLONG(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (unsigned long*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (unsigned long)val;  
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeLONG(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (long*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (long)val;  
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeFLOAT(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (float*)man_manager_.getTilePointer( band, lin ) ) + col ) = 
+    (float)val;    
+}
+
+
+inline void TeDecoderSmartMem::setElement_TeDOUBLE(const int& col, 
+  const int& lin, const double& val, const int& band )
+{
+  *( ( (double*)man_manager_.getTilePointer( band, lin ) ) + col ) = val;    
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeUNSIGNEDCHAR( const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (unsigned char*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeCHAR(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (char*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeUNSIGNEDSHORT(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (unsigned short*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeSHORT(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (short*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeINTEGER(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (int*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeUNSIGNEDLONG(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (unsigned long*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeLONG(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (long*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeFLOAT(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = (double)( *( ( (float*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
+
+inline void TeDecoderSmartMem::getElement_TeDOUBLE(const int& col, 
+  const int& lin, double& val, const int& band )
+{
+  val = ( *( ( (double*)man_manager_.getTilePointer( band, 
+    lin ) ) + col ) );
+}
+
diff --git a/src/terralib/kernel/TeDecoderSmartMem.h b/src/terralib/kernel/TeDecoderSmartMem.h
new file mode 100644
index 0000000..f6b993c
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderSmartMem.h
@@ -0,0 +1,382 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderSmartMem.h
+    \brief This file deals with decoding of raster structures as a mulitdimensional matrix in memory
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERSMARTMEM_H
+#define  __TERRALIB_INTERNAL_DECODERSMARTMEM_H
+
+#include "TeDecoder.h"
+#include "TeRasterMemManager.h"
+#include "TeAgnostic.h"
+
+/** 
+ * @brief Implements a decoder to a raster stored as a as a mulitdimensional 
+ * matrix in memory.
+ * @note The used memory ( RAM or mapped memory ) will be automatically choosed
+ * following the current system resources.
+ * @note No interleaving support.
+ */
+class TL_DLL TeDecoderSmartMem : public TeDecoder
+{
+
+public:
+
+  //! @brief Empty constructor
+  TeDecoderSmartMem ();
+
+  //! @brief Constructor from parameters
+  TeDecoderSmartMem ( const TeRasterParams& par );
+
+  //! @brief Destructor
+  virtual ~TeDecoderSmartMem ();
+
+  //! @brief Sets the value of a specific raster element 
+  /*!
+    \param col  element column identifier
+    \param lin  element line identifier
+    \param val  element value being inserted
+    \param band element band identifier
+  */  
+  inline bool setElement (int col,int lin, double val, int band=0)
+  {
+    TEAGN_DEBUG_CONDITION( ( setelement_ptrs_vec_ != 0 ),
+      "invalid setElement function pointers vector" )
+    TEAGN_DEBUG_CONDITION( ( col < params_.ncols_ ),
+      "Invalid number of columns" )
+    TEAGN_DEBUG_CONDITION( ( lin < params_.nlines_ ),
+      "Invalid number of lines" )
+    TEAGN_DEBUG_CONDITION( ( band < params_.nBands() ),
+      "Invalid band" )
+    TEAGN_DEBUG_CONDITION( 
+      ( params_.status_ != TeRasterParams::TeNotReady),
+      "Raster not Ready" );      
+    
+    ( this->*( setelement_ptrs_vec_[ band ] ) )( col, lin, val, band );
+  
+    return true;  
+  };
+  
+  //! @brief Gets an specific element (col, lin, band) of a raster data
+  /*!
+    \param col  element column identifier
+    \param lin  element line identifier
+    \param val  element value being retrieved
+    \param band element band identifier
+  */  
+  inline bool getElement (int col,int lin, double &val,int band=0)
+  {
+    TEAGN_DEBUG_CONDITION( ( getelement_ptrs_vec_ != 0 ),
+      "invalid getElement function pointers vector" )
+    TEAGN_DEBUG_CONDITION( ( col < params_.ncols_ ),
+      "Invalid number of columns" )
+    TEAGN_DEBUG_CONDITION( ( lin < params_.nlines_ ),
+      "Invalid number of lines" )
+    TEAGN_DEBUG_CONDITION( ( band < params_.nBands() ),
+      "Invalid band" )    
+    TEAGN_DEBUG_CONDITION( 
+      ( params_.status_ != TeRasterParams::TeNotReady),
+      "Raster not Ready" );      
+    
+    ( this->*( getelement_ptrs_vec_[ band ] ) )( col, lin, val, band );
+    
+    return true;  
+  };
+
+  //! @brief Initializes the internal structures of the decoder
+  virtual void  init  ();
+  
+  //! @brief Clears its internal structures
+  virtual bool  clear  ();
+
+protected:
+
+  /**
+   * @brief Type definition for the getElement function pointer.
+   *
+   * @param line Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  typedef void (TeDecoderSmartMem::*GetEleFunctPtrT)( const int& col,
+    const int& lin, double& val, const int& band );
+
+  /**
+   * @brief Type definition for the setElement function pointer.
+   *
+   * @param line Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  typedef void (TeDecoderSmartMem::*SetEleFunctPtrT)( const int& col, 
+    const int& lin, const double& val, const int& band );
+  
+  /**
+   * @brief Internal memory manager instance.
+   */
+  TeRasterMemManager man_manager_;
+
+  /**
+   * @brief A vector of pointers to the current getElement method following the 
+   * current data bype of each band (indexed by the band index).
+   */
+  GetEleFunctPtrT* getelement_ptrs_vec_;
+
+  /**
+   * @brief A vector of pointers to the current setElement method following the 
+   * current data bype of each band (indexed by the band index).
+   */
+  SetEleFunctPtrT* setelement_ptrs_vec_;
+  
+  /**
+   * @brief Set all internal variables to their initial values.
+   */   
+  void initVars();
+  
+  /**
+   * @brief Update the function pointers vectors using the current
+   * raster parameters.
+   */   
+  void updateFuncPtrVectors();  
+  
+  /**
+   * @brief Fill data with dummy values.
+   */   
+  void dummyFill();    
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeUNSIGNEDCHAR( const int& col, const int& lin, 
+    const double& val, const int& band );
+  
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeCHAR( const int& col, const int& lin, 
+    const double& val, const int& band );  
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeUNSIGNEDSHORT( const int& col, const int& lin, 
+    const double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeSHORT( const int& col, const int& lin, 
+    const double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeINTEGER( const int& col, const int& lin, 
+    const double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeUNSIGNEDLONG( const int& col, const int& lin, 
+    const double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeLONG( const int& col, const int& lin, 
+    const double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeFLOAT( const int& col, const int& lin, 
+    const double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void setElement_TeDOUBLE( const int& col, const int& lin, 
+    const double& val, const int& band );
+  
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeUNSIGNEDCHAR( const int& col, const int& lin, 
+    double& val, const int& band );
+  
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeCHAR( const int& col, const int& lin, 
+    double& val, const int& band );  
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeUNSIGNEDSHORT( const int& col, const int& lin, 
+    double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeSHORT( const int& col, const int& lin, 
+    double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeINTEGER( const int& col, const int& lin, 
+    double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeUNSIGNEDLONG( const int& col, const int& lin, 
+    double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeLONG( const int& col, const int& lin, 
+    double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param line Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeFLOAT( const int& col, const int& lin, 
+    double& val, const int& band );
+
+  /**
+   * @brief Method overload.
+   *
+   * @param lin Line.
+   * @param col Column.
+   * @param band Band.
+   * @param val Pixel value.
+   */      
+  inline void getElement_TeDOUBLE( const int& col, const int& lin, 
+    double& val, const int& band );  
+  
+};
+
+//! Implements a factory to build decoder to MEMORY raster
+class TL_DLL TeDecoderSmartMemFactory : public TeDecoderFactory
+{
+public:
+
+  //! Factory constructor
+  TeDecoderSmartMemFactory(const string& name) : TeDecoderFactory(name) {}
+
+  //! Builds the object
+  virtual TeDecoder* build (const TeRasterParams& arg)
+  {  return new TeDecoderSmartMem(arg); }
+};
+#endif
+
diff --git a/src/terralib/kernel/TeDecoderVirtualMemory.cpp b/src/terralib/kernel/TeDecoderVirtualMemory.cpp
new file mode 100644
index 0000000..92894cf
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderVirtualMemory.cpp
@@ -0,0 +1,473 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDecoderVirtualMemory.h"
+#include <cstring>
+
+TeMemoryPage::TeMemoryPage(const TeMemoryPage& rhs)
+{
+	data_ = rhs.data_;
+	used_ = rhs.used_;
+	defValue_ = rhs.defValue_;
+	dataType_ = rhs.dataType_;
+}
+
+//! Operator =
+TeMemoryPage& 
+TeMemoryPage::operator=(const TeMemoryPage& rhs)
+{
+	if (this != &rhs)
+	{
+		data_ = rhs.data_;
+		used_ = rhs.used_;
+		size_ = rhs.size_;
+		defValue_ = rhs.defValue_;
+		dataType_ = rhs.dataType_;
+	}
+	return *this;
+}
+
+//! Destructor
+TeMemoryPage::~TeMemoryPage()
+{
+	if (this->data_ != 0)
+	{
+		switch (dataType_)
+		{
+		case (TeUNSIGNEDCHAR):
+			delete [](unsigned char*)data_;
+			break;
+		case (TeCHAR) :
+			delete (char*)data_;
+			break;
+		case (TeUNSIGNEDSHORT):
+			delete [](unsigned short*)data_;
+			break;
+		case (TeSHORT):
+			delete (short*) data_;
+			break;
+		case (TeUNSIGNEDLONG):
+			delete [](unsigned long*)data_;
+			break;
+		case (TeLONG):
+			delete [](long*) data_;
+			break;
+		case (TeFLOAT):
+			delete [](float*)data_;
+			break;
+		case (TeDOUBLE):
+			delete [](double*) data_;
+			break;
+		default:
+			break;
+		}
+		data_ = 0;
+	}
+}
+
+TeMemoryPage::TeMemoryPage(unsigned long size, double defValue, TeDataType dataType):
+		used_(false),
+		size_(size),
+		defValue_(defValue),
+		dataType_(dataType)
+{
+	data_ = 0;
+	try 
+	{
+		unsigned int i;
+		// Try to allocate the necessary memory
+		switch (dataType_) {
+		case (TeUNSIGNEDCHAR):
+			data_ = new unsigned char [size_];
+			memset(data_, (int)defValue, size);
+			break;
+		case (TeCHAR) :
+			data_ = new char [size_];
+			memset(data_, (int)defValue, size);
+			break;
+		case (TeUNSIGNEDSHORT):
+			data_ = new unsigned short [size_];
+			for (i=0;i<size;((unsigned short*)data_)[i]= (unsigned short) defValue_,i++);
+			break;
+		case (TeSHORT):
+			data_ = new short [size_];
+			for (i=0;i<size;((short*)data_)[i]=(short)defValue_,i++);
+			break;
+		case (TeUNSIGNEDLONG):
+			data_ = new unsigned long [size_];
+			for (i=0;i<size;((unsigned long*)data_)[i]=(unsigned long)defValue_,i++);
+			break;
+		case (TeLONG):
+			data_ = new long [size_];
+			for (i=0;i<size;((long*)data_)[i]=(long)defValue_,i++);
+			break;
+		case (TeFLOAT):
+			data_ = new float [size_];
+			for (i=0;i<size;((float*)data_)[i]=(float)defValue_,i++);
+			break;
+		case (TeDOUBLE):
+			data_ = new double [size_];
+			for (i=0;i<size;((double*)data_)[i]=(double)defValue_,i++);
+			break;
+		default:
+			break;
+		}
+	}
+	catch (...)
+	{
+	}
+}
+
+void
+TeMemoryPage::clear()
+{	
+	unsigned int i;
+	switch (dataType_) 
+	{
+	case (TeUNSIGNEDCHAR):
+	case (TeCHAR) :
+		memset((void*)data_, (int)defValue_, size_);
+		break;
+	case (TeUNSIGNEDSHORT):
+		for (i=0;i<size_;((unsigned short*)data_)[i]= (unsigned short) defValue_,i++);
+		break;
+	case (TeSHORT):
+		for (i=0;i<size_;((short*)data_)[i]=(short)defValue_,i++);
+		break;
+	case (TeUNSIGNEDLONG):
+		for (i=0;i<size_;((unsigned long*)data_)[i]=(unsigned long)defValue_,i++);
+		break;
+	case (TeLONG):
+		for (i=0;i<size_;((long*)data_)[i]=(long)defValue_,i++);
+		break;
+	case (TeFLOAT):
+		for (i=0;i<size_;((float*)data_)[i]=(float)defValue_,i++);
+		break;
+	case (TeDOUBLE):
+		for (i=0;i<size_;((double*)data_)[i]=(double)defValue_,i++);
+		break;
+	default:
+		break;
+	}
+}
+
+long
+TeMemoryPage::pageSize()
+{
+	long s;
+	switch (dataType_) 
+	{
+	case (TeCHAR) :
+		s = size_*sizeof(char);
+		break;
+	case (TeUNSIGNEDSHORT):
+		s = size_*sizeof(unsigned short);
+		break;
+	case (TeSHORT):
+		s = size_*sizeof(short);
+		break;
+	case (TeUNSIGNEDLONG):
+		s = size_*sizeof(unsigned long);
+		break;
+	case (TeLONG):
+		s = size_*sizeof(long);
+		break;
+	case (TeFLOAT):
+		s = size_*sizeof(float);
+		break;
+	case (TeDOUBLE):
+		s = size_*sizeof(double);
+		break;
+	default:
+		s = size_*sizeof(unsigned char);
+	}
+	return s;
+}
+
+double 
+TeMemoryPage::getVal(int col,int lin, int nCols)
+{
+	unsigned long offset = (lin-ulLin_)*nCols+(col-ulCol_);
+	double val = defValue_;
+
+	if (offset < size_) // solucao temporaria, rever
+	{
+		switch (dataType_) 
+		{
+		case (TeUNSIGNEDCHAR):
+			val = ((unsigned char*)data_)[offset];
+			break;
+		case (TeCHAR) :
+			val = ((char*) data_)[offset];
+			break;
+		case (TeUNSIGNEDSHORT):
+			val = ((unsigned short*)data_)[offset];
+			break;
+		case (TeSHORT):
+			val = ((short*)data_)[offset];
+			break;
+		case (TeUNSIGNEDLONG):
+			val = ((unsigned long*)data_)[offset];
+			break;
+		case (TeLONG):
+			val = ((long*)data_)[offset];
+			break;
+		case (TeFLOAT):
+			val = ((float*)data_)[offset];
+			break;
+		case (TeDOUBLE):
+			val = ((double*)data_)[offset];
+			break;
+		default:
+			break;
+		}
+	}
+
+	return val;
+}
+
+void 
+TeMemoryPage::setVal(int col,int lin,int nCols, double val)
+{
+	unsigned long offset = (lin-ulLin_)*nCols+(col-ulCol_);
+	if (offset < size_) 
+	{
+		switch (dataType_) 
+		{
+		case (TeUNSIGNEDCHAR):
+			((unsigned char*)data_)[offset] = (unsigned char) val;
+			break;
+		
+		case (TeCHAR) :
+			((char*) data_)[offset] = (char) val;
+			break;
+		
+		case (TeUNSIGNEDSHORT):
+			((unsigned short*)data_)[offset] = (unsigned short) val;
+			break;
+		
+		case (TeSHORT):
+			((short*)data_)[offset] = (short) val;
+			break;
+		
+		case (TeUNSIGNEDLONG):
+			((unsigned long*)data_)[offset] = (unsigned long) val;
+			break;
+		
+		case (TeLONG):
+			((long*)data_)[offset] = (long) val;
+			break;
+		
+		case (TeFLOAT):
+			((float*)data_)[offset] = (float) val;
+			break;
+		
+		case (TeDOUBLE):
+			((double*)data_)[offset] = val;
+
+		default:
+			break;
+		}
+	}
+	return;
+}
+
+TeDecoderVirtualMemory::TeDecoderVirtualMemory(const TeRasterParams par)
+{
+	params_ = par;
+}
+
+TeDecoderVirtualMemory::~TeDecoderVirtualMemory()
+{
+	if (!pagesQueue_.empty())
+		TeDecoderVirtualMemory::clear();
+}
+
+TeMemoryPage* TeDecoderVirtualMemory::loadBlock(int col,int lin, int band)
+{
+	// If element is outside raster boundaries return
+	if(col < 0 || lin < 0 || col > params_.ncols_ || lin > params_.nlines_)
+		return NULL;
+
+	TeBlockIndex index = blockIndex(col,lin,band);
+	TeMemoryPage* block = NULL;
+
+	// check band cache first
+	if (pageCache_[band] != NULL && indexCache_[band] == index)
+		block = pageCache_[band];
+	else
+	{
+		// check if page is already in memory
+		MapMemoryPageIterator p = virtualMemory_.find(index);
+		if (p != virtualMemory_.end()) // use it
+			block = p->second;
+		else
+		{
+			// page is not in memory
+			// check whether there is space in memory to bring another page
+			if (virtualMemory_.size() >= (unsigned int)params_.nTilesInMemory_)
+			{
+				// FIFO strategy: replace the oldest page in memory
+				TeBlockIndex first = pagesQueue_.front();
+				pagesQueue_.pop();
+				p = virtualMemory_.find(first); 
+				if (p != virtualMemory_.end())
+				{
+					block = p->second;
+					if (block->used_)
+						putRasterBlock(first,block->data_,block->pageSize());
+
+					block->used_ = false;
+					block->clear();				// reuse the allocated memory
+					virtualMemory_.erase(first);
+				}
+			}
+			else // bring the page to memory
+				block = new TeMemoryPage(params_.blockHeight_*params_.blockWidth_, params_.dummy_[band],params_.dataType_[band]);
+
+			virtualMemory_.insert(MapMemoryPage::value_type(index,block));
+			pagesQueue_.push(index);
+			getRasterBlock(index,block->data_);
+			int band_out;
+			blockIndexPos(index, block->ulCol_, block->ulLin_, band_out);
+		}
+		indexCache_[band] = index;
+		pageCache_[band] = block;
+	}
+  return block;
+}
+
+bool
+TeDecoderVirtualMemory::getElement(int col,int lin, double &val,int band)
+{
+	TeMemoryPage* block = loadBlock(col, lin, band);
+	if(block == NULL)
+	{
+		val = params_.dummy_[band];
+		return false;
+	}
+	val = block->getVal(col,lin,params_.blockWidth_);
+	return true;
+}
+
+bool
+TeDecoderVirtualMemory::setElement(int col, int lin, double val,int band)
+{
+	TeMemoryPage* block = loadBlock(col, lin, band);
+	if(block == NULL)
+		return false;
+
+	block->setVal(col,lin,params_.blockWidth_,val);
+	block->used_ = true;
+	return true;
+}
+
+TeBlockIndex TeDecoderVirtualMemory::blockIndex(int col, int lin, int band)
+{
+	TeBlockIndex bl_idx;
+
+	bl_idx.band_ = band;
+	bl_idx.col_ = (int)(col/params_.blockWidth_);
+	bl_idx.lin_ = (int)(lin/params_.blockHeight_);
+	return bl_idx;
+}
+
+void TeDecoderVirtualMemory::blockIndexPos( const TeBlockIndex& index, int& ulCol, int& ulLin, int& band)
+{
+	ulCol = index.column()*params_.blockWidth_;
+	ulLin = index.line()*params_.blockHeight_;
+	band = index.band();
+}
+
+void
+TeDecoderVirtualMemory::init()
+{
+	TeDecoderVirtualMemory::clear();
+	if (params_.nBands() == 0 || params_.ncols_ <= 0 || params_.nlines_ == 0)
+	{
+		params_.errorMessage_ = "Raster doesnt have valid dimensions.";
+		params_.status_ = TeRasterParams::TeNotReady;
+		return;
+	}
+	if ( params_.nTilesInMemory_ == 0 )
+		params_.nTilesInMemory_ = params_.nBands() * (params_.ncols_ / params_.blockWidth_+1) ;
+}
+
+bool
+TeDecoderVirtualMemory::clear()
+{
+	TeMemoryPage* block;
+	TeBlockIndex index;
+	MapMemoryPageIterator p;
+	while (!pagesQueue_.empty() )
+	{
+		index = pagesQueue_.front();
+		pagesQueue_.pop();
+		p = virtualMemory_.find(index);
+		if (p != virtualMemory_.end())
+		{
+			block = p->second;
+			if (block->used_)
+				putRasterBlock(index,block->data_,block->pageSize());
+			delete block;
+			virtualMemory_.erase(index);
+		}
+	}
+	
+	pageCache_.resize(params_.nBands());
+	for(unsigned int i = 0; i < pageCache_.size(); ++i)
+	{
+		pageCache_[i] = NULL;
+	}
+
+	indexCache_.resize(params_.nBands());
+	for(unsigned int i = 0; i < indexCache_.size(); ++i)
+	{
+		indexCache_[i] = TeBlockIndex();
+	}
+
+	return true;
+}
+
+void TeDecoderVirtualMemory::setCacheSize(int size)
+{
+	int block_size = params_.blockHeight_ * params_.blockWidth_;
+	setCacheNTiles((int)(size / block_size));  
+}
+
+int TeDecoderVirtualMemory::getCacheSize()
+{
+	int block_size = params_.blockHeight_ * params_.blockWidth_;
+	return getCacheNTiles() * block_size;
+}
+
+void TeDecoderVirtualMemory::setCacheNTiles(int n)
+{
+	params_.nTilesInMemory_ = n;
+	TeDecoderVirtualMemory::clear();
+}
+
+int TeDecoderVirtualMemory::getCacheNTiles()
+{
+	return params_.nTilesInMemory_;
+}
diff --git a/src/terralib/kernel/TeDecoderVirtualMemory.h b/src/terralib/kernel/TeDecoderVirtualMemory.h
new file mode 100644
index 0000000..1069742
--- /dev/null
+++ b/src/terralib/kernel/TeDecoderVirtualMemory.h
@@ -0,0 +1,241 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDecoderVirtualMemory.h
+    \brief This file supports a virtual memory strategy to deal whith raster structures
+*/
+#ifndef  __TERRALIB_INTERNAL_DECODERVIRTUALMEMORY_H
+#define  __TERRALIB_INTERNAL_DECODERVIRTUALMEMORY_H
+
+#include "TeDefines.h"
+#include "TeDecoder.h"
+
+#include <queue>
+#include <vector>
+
+using namespace std;
+
+//! A page of memory
+class TL_DLL TeMemoryPage
+{
+public:
+	void*   data_;			//<! Pointer to the data in memory
+	bool	used_;			//<! Flag that indicate if the page was modified in memory
+	unsigned long size_;	//<! Page number of elements
+
+	int ulLin_;				//<! Line index of the upper-left corner
+	int ulCol_;				//<! Column index of the upper-left corner
+	double   defValue_;		//<! Default value (fo initially fill the page)
+	TeDataType dataType_;	//<! Pixel data type
+
+	//! Constructor
+	TeMemoryPage(unsigned long size, double defValue, TeDataType dataType = TeDOUBLE);
+	
+	//! Destructor
+	~TeMemoryPage();
+
+	//! Copy constructor
+	TeMemoryPage(const TeMemoryPage& rhs);
+	
+	//! Operator =
+	TeMemoryPage& operator=(const TeMemoryPage& rhs);
+
+	//! Returns the value of on position within the block
+	/*
+		\par col column identifier of the position
+		\par lin line identifier of the position
+		\par nCols number of columns per line of the block
+		\returns the value of the position indicated by (col x lin)
+	*/
+	double getVal(int col,int lin, int nCols);
+
+	//! Sets the value of a position within the block
+	/*
+		\par col column identifier of the position
+		\par lin line identifier of the position
+		\par nCols number of columns per line of the block
+		\par val the value to be put in the position
+	*/
+	void setVal(int col,int lin,int nCols, double val);
+
+	//! Set all positions of the page to the default value;
+	void clear();
+
+	//! Returns the physical size of a memory page
+	long pageSize();
+};
+
+class TL_DLL TeBlockIndex{
+public:
+	TeBlockIndex()
+	{
+		col_ = 0;
+		lin_ = 0;
+		band_ = -1;
+	}
+
+	int col_;
+	int lin_;
+	int band_;
+
+	int column()  const
+	{
+		return col_;
+	}
+
+	int line() const
+	{
+		return lin_;
+	}
+
+	int band() const
+	{
+		return band_;
+	}
+
+	int operator==(const TeBlockIndex& idx2) const
+	{
+		if(col_ != idx2.col_)
+			return 0;
+
+		if(lin_ != idx2.lin_)
+			return 0;
+
+		return (band_ == idx2.band_);
+	}
+};
+
+//! Implements a virtual memory strategy to decode raster in blocks
+/*
+	It should be used as a parent class of decoder that access raster
+	blocks from a physical storage
+*/
+class TL_DLL TeDecoderVirtualMemory: public TeDecoder
+{
+public:
+
+	//! Empty constructor
+	TeDecoderVirtualMemory() {};
+	
+	//! Constructor from parameters
+	TeDecoderVirtualMemory( const TeRasterParams par);
+
+	//! Destructor
+	virtual ~TeDecoderVirtualMemory();
+
+	//! Sets the value of a specific raster pixel 
+	/*!
+		\param col pixel column identifier
+		\param lin pixel line identifier
+		\param val pixel value being inserted
+		\param band pixel band identifier
+	*/
+	bool getElement(int col,int lin, double &val,int band);
+
+	//! Gets an specific element (col, lin, band) of a raster data
+	/*!
+		\param col pixel column identifier
+		\param lin pixel line identifier
+		\param val pixel value being retrieved
+		\param band pixel band identifier
+	*/
+	bool setElement(int col, int lin, double val,int band);
+
+	//! Initializes the internal structures of the decoder, from its raster parameters structure.
+	void init();
+
+	//! Clears  the decoder internal structures
+	bool clear();
+
+	//! Defines the physical size of the cache
+	void setCacheSize(int size);  
+
+	//! Returns the physical size of the cache
+	int getCacheSize();
+
+	//! Defines the number of tiles in the cache
+	void setCacheNTiles(int n);
+
+	//! Returns the number of tiles in the cache
+	int getCacheNTiles();
+
+protected:
+	struct TeBlockIndexMapFunc
+	{
+		bool operator()(const TeBlockIndex& idx1, const TeBlockIndex& idx2) const;
+	};
+
+	//! Saves a raster tile from a virtual memory to permanent storage
+	/*! 
+	    \param index block index
+		\param buf pointer to a raster tile in memory
+		\param bsize block size
+	*/	
+	virtual bool putRasterBlock(const TeBlockIndex& index, void *buf, long bsize) = 0; /******/
+
+	//! Gets the raster block with index identifier
+	/*!
+		\param index block index
+		\param buf pointer to a raster tile in memory
+	*/
+	virtual bool getRasterBlock(const TeBlockIndex& index, void *buf) = 0; /******/
+
+	//! Codifies the unique identifier of the raster block that contains a certain pixel
+	/*!
+		\param col column number
+		\param lin  pixel line number
+		\param band pixel band 
+		\return block index
+	*/
+	virtual TeBlockIndex blockIndex(int col, int lin, int band); 
+
+	//! Returns the parameters of a tile from its indexs
+	virtual void blockIndexPos( const TeBlockIndex& index, int& ulCol, int& ulLin, int& band); /******/
+
+	//! Retrieve a block of the cache that contains an element
+	TeMemoryPage* loadBlock(int col,int lin, int band);
+
+private:
+
+	//! A map of string identifiers to pointer to memory pages 
+	typedef map<TeBlockIndex, TeMemoryPage*, TeBlockIndexMapFunc> MapMemoryPage; 
+
+	//! A const iterator to a map of pages
+	typedef MapMemoryPage::const_iterator MapMemoryPageIterator;
+
+	MapMemoryPage virtualMemory_;
+	queue<TeBlockIndex> pagesQueue_; 
+	vector<TeBlockIndex> indexCache_; 
+	vector<TeMemoryPage*> pageCache_;
+};
+
+inline bool TeDecoderVirtualMemory::TeBlockIndexMapFunc::operator()(const TeBlockIndex& idx1, const TeBlockIndex& idx2) const
+{
+  if(idx1.band_ != idx2.band_)
+    return (idx1.band_ < idx2.band_);
+
+  if(idx1.lin_ != idx2.lin_)
+    return idx1.lin_ < idx2.lin_;
+
+  return (idx1.col_ < idx2.col_);
+}
+#endif
diff --git a/src/terralib/kernel/TeDefines.h b/src/terralib/kernel/TeDefines.h
new file mode 100644
index 0000000..9442e69
--- /dev/null
+++ b/src/terralib/kernel/TeDefines.h
@@ -0,0 +1,238 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDefines.h
+    \brief Provides a set of general definitions used by Terralib
+*/
+#ifndef  __TERRALIB_INTERNAL_DEFINES_H
+#define  __TERRALIB_INTERNAL_DEFINES_H
+
+#include <string> 
+
+/** @defgroup Defines Defines and constants
+  @{
+ */
+
+ 
+/** @defgroup PlatformDetection Platform detection macros.
+  @{
+ */
+/** @brief Microsoft Windows platform code */ 
+#define TePLATFORMCODE_MSWINDOWS 1
+/** @brief Generic Linux platform code */ 
+#define TePLATFORMCODE_LINUX 2
+/** @brief Solaris platform code */ 
+#define TePLATFORMCODE_SOLARIS 3
+/** @brief Apple platform code */ 
+#define TePLATFORMCODE_APPLE 4
+/** @brief IBM AIX platform code */ 
+#define TePLATFORMCODE_AIX 5
+
+#if defined( WIN32 ) || defined( __WIN32__ ) || defined ( _WIN32 ) || defined( WIN64 ) || defined( _WIN32_WCE )
+  #define TePLATFORM TePLATFORMCODE_MSWINDOWS
+#elif defined( __LINUX__ ) || defined( linux ) || defined( __linux__ ) ||defined( __FreeBSD__ ) //FAMI
+  #define TePLATFORM TePLATFORMCODE_LINUX
+#elif defined( __APPLE_CC__ ) || defined( APPLE_CC )
+  #define TePLATFORM TePLATFORMCODE_LINUX
+  #define __unix__
+#elif defined(sparc) && defined(sun) && defined(unix) 
+  #define TePLATFORM TePLATFORMCODE_SOLARIS
+#elif defined(_AIX)
+  #define TePLATFORM TePLATFORMCODE_AIX
+  #ifndef __unix__  
+   #define __unix__
+  #endif 
+#else
+  #error "ERROR: Unknown platform"
+#endif
+/** @} */ 
+
+/** @defgroup CompilerDetection Compiler detection macros.
+  @{
+ */
+/** @brief MS Visual Studio c++ code */ 
+#define TeCOMPILERCODE_VCPLUSPLUS 1
+/** @brief Borland c++ code */ 
+#define TeCOMPILERCODE_BCPLUSPLUS 2
+/** @brief GNU Compiler code */ 
+#define TeCOMPILERCODE_GNUC 3
+/** @brief CodeWarrior code */ 
+#define TeCOMPILERCODE_CODEWARRIOR 4
+/** @brief Sun Forte code */ 
+#define TeCOMPILERCODE_SUNFORTE7 5
+/** @brief AIX xlC code */ 
+#define TeCOMPILERCODE_XLC 6
+
+#if defined( _MSC_VER )
+  #define TeCOMPILER TeCOMPILERCODE_VCPLUSPLUS
+#elif defined( __BORLANDC__ ) || defined( __BCPLUSPLUS__ )
+  #define TeCOMPILER TeCOMPILERCODE_BCPLUSPLUS
+#elif defined( __GNUC__ )
+  #define TeCOMPILER TeCOMPILERCODE_GNUC
+#elif defined( __MWERKS__ )
+  #define TeCOMPILER TeCOMPILERCODE_CODEWARRIOR
+#elif defined( __SUNPRO_CC)
+  #define TeCOMPILER TeCOMPILERCODE_SUNFORTE7
+#elif defined( __xlC__ )
+  #define TeCOMPILER TeCOMPILERCODE_XLC
+#else
+  #error "ERROR: Unknown compiler"
+#endif
+/** @} */ 
+
+
+/** @defgroup MathConst Mathematical constants and macro definitions
+  @{
+ */
+//! A default name length
+const int	TeNAME_LENGTH = 2000;			//!< A default name length
+const double	TeMAXFLOAT =	3.4E37;			//!< Maximum float value
+const double	TeMINFLOAT =	3.4E-37;		//!< Minimum float value
+const double	TePI  =	3.14159265358979323846;		//!< The ratio of the circumference to the diameter of a circle
+const double	TeCDR =	0.01745329251994329576;		//!< Conversion factor: degrees to radians
+const double	TeCRD = 57.29577951308232087679;	//!< Conversion factor: radians to degrees
+const double 	TeEARTHRADIUS   = 6378160.;		//!< Int. Astronomical Union - 1965
+
+#ifndef MAX
+#define MAX(a,b) ( (a>b) ? a : b )	//!< Macro that returns max between two values
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ( (a<b) ? a : b )	//!< Macro that returns min between two values
+#endif
+
+#ifndef ABS
+#define ABS(x) 	( ((x) >= 0) ? (x) : -(x) )	//!< Macro that returns the absolute value
+#endif
+/** @} */
+
+
+/** @defgroup Selection Mode for the objects
+	@{
+ */
+#define TeDEFAULT			0	//!< default selection
+#define TePOINTED			1	//!< object pointed
+#define TeQUERIED   		2	//!< object queried
+#define TePOINTED_QUERIED	3	//!< object pointed and queried
+/** @} */	// end Selection Mode
+
+
+/** @defgroup Orient Ring orientation
+	@{
+ */
+#define TeNOTURN			 0	//!< Unknown orientation
+#define TeCOLLINEAR			 0	//!< Collinear
+#define TeCLOCKWISE   		-1	//!< Clockwise orientation
+#define TeCOUNTERCLOCKWISE	 1	//!< Counter-Clockwise orientation
+/** @} */	// end Orientation
+
+/** @defgroup TopDefines Topology related defines
+    @{
+ */
+/** @defgroup InOut Inside/Outside positioning
+	@ingroup TopDefines
+    @{
+ */
+#define	TeUNKNOWNPOSITION  0	//!< unknown position
+#define	TeINSIDE		   1	//!< inside position
+#define	TeOUTSIDE		   2	//!< outside position
+#define	TeBOUNDARY		   4	//!< on the boundary position
+/** @} */
+
+
+/** @defgroup Inter Intersection types
+	@ingroup TopDefines
+    @{
+ */
+/** @defgroup GeneralInter General intersection
+	@ingroup Inter
+	@{
+ */
+#define TeINTERIORINTERIOR 8	//!< interior and interior intersection
+#define TeINTERIORBOUNDARY 16	//!< interior and boundary intersection
+#define TeINTERIOREXTERIOR 32	//!< interior and exterior intersection
+#define TeBOUNDARYINTERIOR 64	//!< boundary and interior intersection
+#define TeBOUNDARYBOUNDARY 128	//!< boundary and boundary intersection
+#define TeBOUNDARYEXTERIOR 256	//!< boundary and exterior intersection
+#define TeEXTERIORINTERIOR 512	//!< exterior and interior intersection
+#define TeEXTERIORBOUNDARY 1024	//!< exterior and boundary intersection
+#define TeEXTERIOREXTERIOR 2048	//!< exterior and exterior intersection
+/** @} */ // end GeneralInter
+
+/** @defgroup SegInter Segments intersection
+	@ingroup Inter
+	@{
+ */
+#define TeDONT_INTERSECT 0		//!< segments don't intersects
+#define TeDO_INTERSECT   1		//!< segments intersects
+#define TeAT_ENDPOINT    4		//!< segments intersects at end points
+/** @} */	// end SegInter
+/** @} */  // end Inte
+
+/** @defgroup TopOper Topological operations
+	@{
+ */
+#define TeDIFFERENCE   1	//!< Difference operation
+#define TeUNION        2	//!< Union operation
+#define TeINTERSECTION 4	//!< Intersection operation
+/** @} */ // end TopOper
+/** @} */ // end TopDefines
+/** @} */ // end Defines
+
+//! Current terralib database version
+const std::string TeDBVERSION = "3.2.0.1"; 		
+
+/* @brief TeISNAN definition */
+
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  #include <float.h>
+  #define TeISNAN( x ) _isnan( x )
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  #include <math.h>
+  #define TeISNAN( x ) isnan( x )
+#else
+  #include <math.h>  
+  #define TeISNAN( x ) isnan( x )
+#endif
+
+/** @defgroup TerraLib_AS_DLL macros.
+  @{
+ */
+#if defined( WIN32 ) || defined( __WIN32__ ) || defined ( _WIN32 ) || defined( WIN64 ) || defined( _WIN32_WCE )
+
+#if defined(_MSC_VER) /* MSVC Compiler */
+#pragma warning(disable: 4251)
+#endif
+
+#ifdef TL_AS_DLL
+#define TL_DLL __declspec(dllexport)
+#else
+#define TL_DLL __declspec(dllimport)
+#endif
+
+#else
+#define TL_DLL
+#endif
+/** @} */ 
+
+#endif
+
diff --git a/src/terralib/kernel/TeErrorLog.cpp b/src/terralib/kernel/TeErrorLog.cpp
new file mode 100644
index 0000000..f104ed8
--- /dev/null
+++ b/src/terralib/kernel/TeErrorLog.cpp
@@ -0,0 +1,184 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeErrorLog.h"
+#include "TeAsciiFile.h"
+#include "TeUtils.h"
+#include "TeException.h"
+
+TeErrorLog::TeErrorLog():logFile_ ( 0 )
+{
+	errorMessage_ [ LOG_MESSAGE             ] = "Message ";
+
+	errorMessage_ [ EMPTY_FILE_NAME         ] = "Empty File Name";
+	errorMessage_ [ CANNOT_OPEN_FILE        ] = "Could Not Open File";
+    errorMessage_ [ CANNOT_READ_FILE		] = "Could Not Read File";
+    errorMessage_ [ CANNOT_WRITE_FILE   	] = "Could Not Write File";
+    errorMessage_ [ CANNOT_CLOSE_FILE		] = "Could Not Close File";
+    errorMessage_ [ END_OF_FILE_REACHED 	] = "End of File Reached";
+
+
+// Errors associated with projection
+
+    errorMessage_ [  DATUM_ERROR              ] = "Error when creating Datum";
+    errorMessage_ [  PROJECTION_NOT_AVAILABLE ] = "Projection not available in TerraLib";
+
+// Error codes for MIF files
+    errorMessage_ [   NOT_MIF_FILE			] = "Not a MIF File";
+    errorMessage_ [   MIF_REGION_CLOSE		] = "Error - MIF Region is not Closed";
+    errorMessage_ [   MIF_CONVERSION_ERROR	] = "Error during conversion of MIF data";
+    errorMessage_ [   NOT_CSV               ] = "Data not separated by commas";
+    errorMessage_ [   NOT_ENOUGH_ROWS       ] = "Less rows in MID file than regions in MIF file";
+    errorMessage_ [   NOT_POLYGON_FILE		] = "Not a polygon (planar areas) file";
+    errorMessage_ [   PLINE_ERROR			] = "Wrongly defined PLINE attribute"; 
+    errorMessage_ [   NO_DTM_QUOTE_VALUE    ] = "Unable to define an attribute as a DTM quote file";
+
+// Error Codes for shapefiles
+    errorMessage_ [  POLYSHAPE_IS_NOT_RING  ] = "Shape PolyShape is not a ring";
+    errorMessage_ [  UNHANDLED_SHP_TYPE     ] = "Shape type unhandled currently";
+
+// Error Codes for DBF files
+
+    errorMessage_ [  UNABLE_TO_OPEN_DBF_FILE  ] = "Unable to Open DBF file";
+    errorMessage_ [  NO_DATA_IN_DBF_FILE      ] = "No Data in DBF File";
+    errorMessage_ [  ATTRIBUTE_INDEX_MISMATCH ] = "Mismatch between attribute index and number of geometries";
+
+// Error codes for E00 Files
+    errorMessage_ [  NOT_E00_FILE            ] = "Not an E00 File";
+
+// Error codes for algorithms
+    errorMessage_ [  CENTROID_NOT_FOUND   ] = "Could not find centroid of a polygon";
+    errorMessage_ [  REGIONS_WITH_HOLES   ] = "Problems in regions with holes";
+    errorMessage_ [  LINE_IS_NOT_RING	  ] = "Tried to a create a ring from a non-closed line";
+
+// Error codes for tables
+
+    errorMessage_ [  ROW_MISMATCH		  ] = "Unable to insert a row into a table (attribute mismatch)";
+    errorMessage_ [  NO_SUCH_ATTRIBUTE    ] = "Attribute does not exist in the table";
+
+	// Error codes for Raster stuff
+    errorMessage_ [  UNKNOWN_DECODER_TECHNOLOGY_TYPE ] = "Decoder technology not specified";
+    errorMessage_ [  UNKNOWN_RASTER_FORMAT	         ] = "Raster format not supported";
+
+	// Error codes for layer stuff
+	errorMessage_ [  GEOMETRY_REPRESENTATION_MISMATCH ] = "Geometry representation has not been created";
+  
+  // TeFactory related errors
+  errorMessage_ [  FACTORY_PRODUCT_INSTATIATION_ERROR ] = 
+    "Factory product instatiation error";
+
+	errorMessage_ [  UNKNOWN_ERROR_TYPE ] = "";
+}
+
+TeErrorLog::~TeErrorLog()
+{
+  endSession();
+}
+string
+TeErrorLog::message( const TeErrorType msgCode )
+{
+	// find the message associated to the errorcode
+	map <TeErrorType, string>::iterator it = errorMessage_.find ( msgCode );
+	if ( it != errorMessage_.end()  )
+		return (*it).second;
+	else
+		return errorMessage_ [ UNKNOWN_ERROR_TYPE ];
+}
+
+void
+TeErrorLog::insert ( TeErrorType code, const string& msg )
+{
+	// create a new logfile, if needed
+	if ( logFile_  == 0 )
+		//logFile_ = new TeAsciiFile ( "terralib.err", "rw" );
+		return;
+
+	string log = errorMessage_ [ code ] + " " + msg;
+	logFile_->writeString ( log );
+  logFile_->writeNewLine();
+
+	// increment the count associated to this error type
+	map<TeErrorType, int>::iterator it = errorLog_.find( code );
+	if ( it == errorLog_.end() )
+		errorLog_[ code ] = 1;
+	else
+	{ 
+		int count = (*it).second;
+		errorLog_[ code ] = ++count;
+	}
+}
+
+
+void 
+TeErrorLog::startSession ( const string& errLogFileName)
+{
+  endSession();
+  
+	// create a new logfile
+	logFile_ = new TeAsciiFile ( errLogFileName, "w+" );
+  
+  if( logFile_ == 0 ) {
+    throw TeException( UNKNOWN_ERROR_TYPE, "Unable to create log file", 
+      false );
+  }
+}
+
+int
+TeErrorLog::endSession ()
+{
+  if( logFile_ == 0 ) {
+    errorLog_.clear ();
+    return 0;
+  }
+
+	int numerr =  errorLog_.size();
+
+	// increment the count associated to this error type
+	map<TeErrorType, int>::iterator it = errorLog_.begin();
+
+	while ( it != errorLog_.end() )
+	{
+		int count = (*it).second;
+		string log = "Number of Error of Type " + errorMessage_ [ (*it).first ] 
+			+ " = " + Te2String ( count );
+		logFile_->writeString ( log );
+    logFile_->writeNewLine();
+    
+    ++it;
+	}
+
+	// close the log file
+	delete logFile_;
+  logFile_ = 0;
+
+	// clear the stack
+	errorLog_.clear ();
+
+  return numerr;
+}
+ 
+ 
diff --git a/src/terralib/kernel/TeErrorLog.h b/src/terralib/kernel/TeErrorLog.h
new file mode 100644
index 0000000..53bc89a
--- /dev/null
+++ b/src/terralib/kernel/TeErrorLog.h
@@ -0,0 +1,142 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeErrorLog.h
+    \brief This file deals log of errors in TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_ERRORLOG_H
+#define  __TERRALIB_INTERNAL_ERRORLOG_H
+
+#include "TeSingleton.h"
+
+#include <string>
+#include <stack>
+#include <map>
+using namespace std;
+
+class TeAsciiFile;
+
+enum TeErrorType
+{
+
+	// Generic message inserted to log file
+	LOG_MESSAGE,
+
+	// Errors associated to files
+	EMPTY_FILE_NAME,
+	CANNOT_OPEN_FILE,
+    CANNOT_READ_FILE,
+    CANNOT_WRITE_FILE,
+    CANNOT_CLOSE_FILE,
+    END_OF_FILE_REACHED,
+
+	// Errors associated with projection
+    DATUM_ERROR,
+    PROJECTION_NOT_AVAILABLE,
+
+// Error codes for MIF files
+    NOT_MIF_FILE,
+    MIF_REGION_CLOSE,
+    MIF_CONVERSION_ERROR,
+    NOT_CSV,
+    NOT_ENOUGH_ROWS,
+    NOT_POLYGON_FILE,
+    PLINE_ERROR,
+    NO_DTM_QUOTE_VALUE,
+
+// Error Codes for shapefiles
+    POLYSHAPE_IS_NOT_RING,
+    UNHANDLED_SHP_TYPE,
+
+// Error Codes for DBF files
+
+    UNABLE_TO_OPEN_DBF_FILE,
+    NO_DATA_IN_DBF_FILE,
+    ATTRIBUTE_INDEX_MISMATCH,
+
+	// Error codes for E00 Files
+    NOT_E00_FILE,
+
+	// Error codes for algorithms
+    CENTROID_NOT_FOUND,
+    REGIONS_WITH_HOLES,
+    LINE_IS_NOT_RING,
+
+	// Error codes for tables
+
+    ROW_MISMATCH,
+    NO_SUCH_ATTRIBUTE,
+
+	// Error codes for Raster stuff
+    UNKNOWN_DECODER_TECHNOLOGY_TYPE,
+    UNKNOWN_RASTER_FORMAT,
+
+	// Layer stuff
+	GEOMETRY_REPRESENTATION_MISMATCH,
+  
+  // TeFactory related errors
+  FACTORY_PRODUCT_INSTATIATION_ERROR,
+
+	// Other
+	UNKNOWN_ERROR_TYPE
+};
+
+typedef map<TeErrorType, string> TeErrorTypeMap;
+
+typedef map<TeErrorType, int> TeErrorLogMap;
+
+//! Describes a class for describing error logging in TerraLib
+/*!
+	All errors in TerraLib may be  logged into an error file. 
+	The error logging facilities include the notion of a 
+	session, using the "start" and "end" methods, of a 
+	dump method for acessing the contenst
+
+\sa TeException, TeSingleton
+*/
+class TL_DLL TeErrorLog: public TeSingleton<TeErrorLog>
+{
+public:
+	TeErrorLog();
+
+	~TeErrorLog();
+	
+	string message(const TeErrorType code);
+	
+	virtual void insert ( TeErrorType code, const string& msg = "" );
+
+	virtual void startSession ( const string& errLogFileName = "terralib.err");
+
+	virtual int endSession ();
+
+private:
+		
+    TeAsciiFile* logFile_;
+
+	TeErrorLogMap errorLog_;
+
+	TeErrorTypeMap  errorMessage_;
+};
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeErrorMessage.cpp b/src/terralib/kernel/TeErrorMessage.cpp
new file mode 100644
index 0000000..0f5a1a6
--- /dev/null
+++ b/src/terralib/kernel/TeErrorMessage.cpp
@@ -0,0 +1,33 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeErrorMessage.h"
+#include <map>
+using namespace std;
+static map<string, string> errorMessage_;
+
+
diff --git a/src/terralib/kernel/TeErrorMessage.h b/src/terralib/kernel/TeErrorMessage.h
new file mode 100644
index 0000000..c63934f
--- /dev/null
+++ b/src/terralib/kernel/TeErrorMessage.h
@@ -0,0 +1,110 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeErrorMessage.h
+    \brief This file contains some definitions issuing error messages to the user
+*/
+#ifndef TeErrorMessage_H
+#define TeErrorMessage_H
+
+#include <string>
+using namespace std;
+
+#include "TePrototype.h"
+#include "TeSingleton.h"
+
+/*!
+\enum TeMessageType 
+
+Te_ABORTRETRYIGNORE   
+	The message box contains three pushbuttons: Abort, Retry, and Ignore.
+Te_OK   The message box contains one pushbutton: OK.
+Te_OKCANCEL   The message box contains two pushbuttons: OK and Cancel.
+Te_RETRYCANCEL   The message box contains two pushbuttons: Retry and Cancel.
+Te_YESNO   The message box contains two pushbuttons: Yes and No.
+Te_YESNOCANCEL   The message box contains three pushbuttons: Yes, No, and Cancel. 
+
+---*/
+enum TeMessageType
+{ Te_ABORTRETRYIGNORE, Te_OK, Te_OKCANCEL, Te_RETRYCANCEL, Te_YESNO, Te_YESNOCANCEL };
+
+  
+/*!
+\enum TeMessageIcon
+
+Te_ICONEXCLAMATION   An exclamation-point icon appears in the message box.
+Te_ICONINFORMATION   An icon consisting of an i in a circle appears in the message box.
+Te_ICONQUESTION   A question-mark icon appears in the message box.
+Te_ICONSTOP   A stop-sign icon appears in the message box. 
+-----*/
+  
+enum TeMessageIcon
+{	Te_ICONEXCLAMATION, Te_ICONINFORMATION, Te_ICONQUESTION, Te_ICONSTOP };
+
+/*---------
+Return Value
+
+Zero if there is not enough memory to display the message box; 
+otherwise one of the following values is returned: 
+
+Te_IDABORT   The Abort button was selected.
+Te_IDCANCEL   The Cancel button was selected.
+Te_IDIGNORE   The Ignore button was selected.
+Te_IDNO   The No button was selected.
+Te_IDOK   The OK button was selected.
+Te_IDRETRY   The Retry button was selected.
+Te_IDYES   The Yes button was selected. 
+
+----*/
+
+enum TeMessageReturn
+{ Te_IDABORT, Te_IDCANCEL, Te_IDIGNORE, Te_IDNO, Te_IDOK, Te_IDRETRY, Te_IDYES };
+
+//!  Provides a convenience class for issuing error messages to the user
+/*
+	  Based on a configuration parameter, provide implementations
+	  for console (stdio), MFC and QT
+  
+	  \sa TeException 
+*/
+class TL_DLL TeErrorMessage
+{
+public:
+	//! Constructor
+	TeErrorMessage(){}
+
+	virtual ~TeErrorMessage(){}
+
+	virtual TeMessageReturn apply ( 
+				  const string& appName, 
+				  const string & msgText, 
+				  TeMessageType	msgType,
+				  TeMessageIcon iconType ) = 0; 
+};
+
+class TL_DLL TeErrorMessagePrototype: public TePrototype<TeErrorMessage>
+{
+	virtual TeErrorMessage* build() = 0;
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeException.cpp b/src/terralib/kernel/TeException.cpp
new file mode 100644
index 0000000..6b9dae1
--- /dev/null
+++ b/src/terralib/kernel/TeException.cpp
@@ -0,0 +1,52 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeException.h"
+#include "TeErrorLog.h"
+#include <cstring>
+#include <errno.h>
+
+TeException::TeException ( TeErrorType msgCode, const string& userText, bool haserrno ):
+		userText_ ( userText )
+{			
+		if ( haserrno )
+			userText_ = userText + " " + strerror ( errno );
+		
+		TeErrorLog::instance().insert( msgCode, userText_ );
+}
+
+string 
+TeException::message() const
+{
+	return TeErrorLog::instance().message ( msgCode_ ) + " " + userText_;
+}
+
+TeErrorType
+TeException::code () const
+{
+	return msgCode_;
+}
diff --git a/src/terralib/kernel/TeException.h b/src/terralib/kernel/TeException.h
new file mode 100644
index 0000000..5b7e03b
--- /dev/null
+++ b/src/terralib/kernel/TeException.h
@@ -0,0 +1,72 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeException.h
+    \brief This file deals Eexception throwing in TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_EXCEPTION_H
+#define  __TERRALIB_INTERNAL_EXCEPTION_H
+
+#ifdef WIN32
+#pragma warning ( disable: 4355 )
+#endif
+
+#include "TeSingleton.h"
+#include "TeErrorLog.h"
+
+#include <string>
+#include <map>
+using namespace std;
+
+
+//!  Provides a class for handling exceptions on Terralib
+class TL_DLL TeException {
+public:
+
+// -- Contructors
+	
+	TeException ( TeErrorType msgCode, const string& userText = "", bool hasErrno = false );
+
+// -- Destructor
+
+	virtual ~TeException() {}  // base class
+
+// --  Members
+
+	string			message () const;
+	TeErrorType	    code() const;
+	
+protected:
+	
+// -- Members
+
+//! code associated with TeException
+	TeErrorType 	msgCode_;   
+
+//! message associated with TeException
+	string			userText_;
+
+private:
+
+};
+#endif
+
diff --git a/src/terralib/kernel/TeExternalTheme.cpp b/src/terralib/kernel/TeExternalTheme.cpp
new file mode 100644
index 0000000..dde5450
--- /dev/null
+++ b/src/terralib/kernel/TeExternalTheme.cpp
@@ -0,0 +1,1447 @@
+#include "TeExternalTheme.h"
+#include "TeLayer.h"
+#include "TeDatabase.h"
+#include "TeDatabaseFactoryParams.h"
+#include "TeDBConnectionsPool.h"
+#include "TeGroupingAlgorithms.h"
+#include "TeQuerier.h"
+#include "TeQuerierParams.h"
+#include "TeRasterTransform.h"
+
+
+TeExternalTheme::TeExternalTheme(TeDatabase* sourceDB, const string& name, TeViewNode* parent, const int& view, const int& id)
+	: TeTheme(name, 0, parent, view, id), remoteTheme_(0), sourceDB_(sourceDB)
+{
+	type(TeEXTERNALTHEME);
+}
+
+TeExternalTheme::TeExternalTheme(const TeViewNodeParams& params)
+	: TeTheme(params), remoteTheme_(0), sourceDB_(0)
+{ 
+}
+
+TeExternalTheme::~TeExternalTheme()
+{
+}
+
+TeExternalTheme::TeExternalTheme(const TeExternalTheme& rhs) :
+	TeTheme(rhs.viewNodeParams_)
+{ 
+//	*(TeTheme*)this = rhs;
+	remoteTheme_ = rhs.remoteTheme_;
+	sourceDB_ = rhs.sourceDB_;
+	remoteDBConn_ = rhs.remoteDBConn_;
+}
+
+TeExternalTheme& TeExternalTheme::operator=(TeExternalTheme& rhs)
+{
+	*(TeTheme*)this = rhs;
+	remoteTheme_ = rhs.remoteTheme_;
+	sourceDB_ = rhs.sourceDB_;
+	remoteDBConn_ = rhs.remoteDBConn_;
+	return *this;
+}
+
+void 
+TeExternalTheme::setSourceDatabase(TeDatabase* db)
+{	
+	this->sourceDB_ = db; 
+}
+
+TeDatabase* 
+TeExternalTheme::getSourceDatabase()
+{ 
+	return sourceDB_; 
+}
+
+TeTheme* 
+TeExternalTheme::getRemoteTheme() const
+{
+	return remoteTheme_;
+}
+
+void 
+TeExternalTheme::setRemoteTheme(TeTheme* theme)
+{ 
+	this->remoteTheme_ = theme; 
+}
+
+string 
+TeExternalTheme::getRemoteThemeName()
+{ 
+	return remoteTheme_->name();
+}
+
+void 
+TeExternalTheme::loadObjectLegendMap()
+{
+	objLegendMap_.clear();
+	objOwnLegendMap_.clear();
+	objStatusMap_.clear();
+	itemStatusMap_.clear();
+
+	TeDatabasePortal* portal = sourceDB_->getPortal();
+
+	if(!portal->query("SELECT c_object_id, c_legend_id, c_legend_own, c_object_status FROM " + collectionTable()))
+		return;
+
+	while(portal->fetchRow())
+	{
+		string objId = portal->getData(0);
+		int status = portal->getInt(3);
+		if(portal->getInt(1) != 0)
+			objLegendMap_[portal->getData(0)] = portal->getInt(1);
+		if(portal->getInt(2) != 0)
+			objOwnLegendMap_[portal->getData(0)] = portal->getInt(2);
+		if(status != 0)
+			objStatusMap_[objId] = status;
+	}
+
+	portal->freeResult();
+
+	if(!portal->query("SELECT object_id, unique_id, grid_status FROM " + collectionAuxTable()))
+		return;
+	
+	while(portal->fetchRow())
+	{
+		if(portal->getInt(2) != 0)
+		{
+			itemStatusMap_[portal->getData(1)] = portal->getInt(2);
+		}
+	}
+
+	portal->freeResult();
+	delete portal;
+}
+
+int 
+TeExternalTheme::getGridStatus(const int uniqueId, const std::string /* objectId */)
+{
+	string aux = Te2String(uniqueId);
+	std::map<std::string, int >::iterator itGridStatus = itemStatusMap_.find(aux);
+	if(itGridStatus == itemStatusMap_.end())
+		return 0;
+	return itGridStatus->second;
+}
+		
+int 
+TeExternalTheme::getObjectStatus(const std::string objectId)
+{
+	std::map<std::string, int>::iterator it = objStatusMap_.find(objectId);
+	if(it == objStatusMap_.end())
+		return 0;
+	
+	return it->second;
+}
+
+bool 
+TeExternalTheme::setObjectLegendStatusMap(const std::string objId, const int status)
+{
+	if(objId.empty())
+		return false;
+	
+	if( status == 0)
+	{
+		map<std::string, int>::iterator itLegStatus = objStatusMap_.find(objId);
+
+		if(itLegStatus != objStatusMap_.end())
+		{
+			objStatusMap_.erase(itLegStatus);
+			return true;
+		}
+		return false;
+	}
+	
+	objStatusMap_[objId] = status;
+
+	return true;
+}
+
+bool 
+TeExternalTheme::setObjectGridStatusMap(const std::string objId, const int uniqueId, const int status)
+{
+	string aux = Te2String(uniqueId);
+	if(objId.empty() || aux.empty())
+		return false;
+	
+	if( status == 0 )
+	{
+		std::map<std::string, int >::iterator itGridStatus = itemStatusMap_.find(aux);
+
+		if(itGridStatus != itemStatusMap_.end())
+		{
+			itemStatusMap_.erase(itGridStatus);
+			return true;
+		}
+		return false;
+	}
+	
+	itemStatusMap_[aux] = status;
+
+	return true;
+}
+
+int 
+TeExternalTheme::layerId()
+{
+	return -1;
+}
+
+void 
+TeExternalTheme::layerId(int)
+{
+}
+
+void 
+TeExternalTheme::layer(TeLayer* layer)
+{
+	if(remoteTheme_)
+		remoteTheme_->layer(layer);
+}
+
+TeLayer*  
+TeExternalTheme::layer()
+{
+	if(remoteTheme_)
+		return remoteTheme_->layer();
+	return 0;
+}
+
+TeProjection* 
+TeExternalTheme::getThemeProjection()
+{
+	if(remoteTheme_ && remoteTheme_->layer())
+		return remoteTheme_->layer()->projection();
+	return 0;
+}
+
+bool 
+TeExternalTheme::hasRestriction()
+{
+	return false;
+}
+
+bool TeExternalTheme::hasAttrRest()
+{
+	return false;
+}
+
+bool TeExternalTheme::hasTemporalRest()
+{
+	return false;
+}
+
+bool TeExternalTheme::hasSpatialRest()
+{
+	return false;
+}
+
+string TeExternalTheme::sqlWhereRestrictions(TeRepresentation* /* rep */)
+{
+	return string("");
+}
+
+void TeExternalTheme::loadTablesJoin(const string& geomTable)
+{
+	remoteTheme_->loadTablesJoin(geomTable);
+}
+
+string TeExternalTheme::sqlGridJoin()
+{
+	return remoteTheme_->sqlGridJoin();
+}
+
+string TeExternalTheme::sqlGridFrom(const string& geomTable)
+{
+	return remoteTheme_->sqlGridFrom(geomTable);
+}
+
+bool TeExternalTheme::save(TeDatabase* db)  
+{
+	if(!db)
+		return false;
+
+	//insert theme in database 
+	//TeDatabase::insertTheme and TeDatabase::updateTheme use the method saveMetadata
+	if(id()==0)
+	{
+		if(!db->insertTheme(this)) //updateThemeTable
+		{
+			db->deleteTheme(this->id());
+			return false;
+		}
+	}
+	else
+	{
+		if(!db->updateTheme(this)) //updateThemeTable
+		{
+			db->deleteTheme(this->id());
+			return false;
+		}
+	}
+	
+	//collection table 
+	if(collectionTable().empty())
+		collectionTable("te_collection_"+ Te2String(id())); 
+
+	if(!db->createCollectionTable(collectionTable_))
+	{
+		db->deleteTheme(this->id());
+		return false;
+	}
+
+	//collection aux table
+	collectionAuxTable(collectionTable() + "_aux");
+	
+	if(!TeTheme::createCollectionAuxTable(db))
+	{
+		db->deleteTheme(this->id());
+		return false;
+	}
+
+	return true;
+}
+
+bool TeExternalTheme::save()
+{
+	if(!save(sourceDB_))
+		return false;
+	
+	// a map to identify legends id between local theme and remote theme during copy.
+	std::map<int, int> mapIdLegend;	
+
+	createLegendMapId(mapIdLegend);
+
+	if(!mapIdLegend.empty())
+		copyRemoteCollection(mapIdLegend);
+	
+	mapIdLegend.clear();
+
+	loadObjectLegendMap();
+
+	return true;
+}
+
+bool TeExternalTheme::createCollectionAuxTable()
+{
+	return TeTheme::createCollectionAuxTable(sourceDB_);
+}
+
+bool TeExternalTheme::populateCollectionAux(std::string /* objectId */)
+{
+	throw;
+	return false;
+}
+
+bool TeExternalTheme::buildGrouping(const TeGrouping& g, TeSelectedObjects /* selectedObjects */,
+				                  vector<double>* dValuesVec)
+{
+	TeDatabase* db = remoteTheme_->layer()->database();
+	if(!db)
+		return false;
+	
+	grouping_ = g;
+	unsigned int i;
+	vector<TeSlice> slices;
+	int	nullValues = 0;
+	if (grouping_.groupMode_ == TeRasterSlicing)
+	{
+		int b = atoi(grouping_.groupAttribute_.name_.c_str());
+		if (!remoteTheme_->layer()->raster() ||  
+			b < 0 ||
+			b > remoteTheme_->layer()->raster()->params().nBands() ||
+			grouping_.groupNumSlices_ <= 0)
+			return false;
+
+		if (grouping_.groupMaxVal_ == TeMINFLOAT)
+			grouping_.groupMaxVal_ = remoteTheme_->layer()->raster()->params().vmax_[b];
+
+		if (grouping_.groupMinVal_ == TeMAXFLOAT)
+			grouping_.groupMinVal_ = remoteTheme_->layer()->raster()->params().vmin_[b];
+
+		TeGroupByEqualStep(grouping_.groupMinVal_, grouping_.groupMaxVal_,
+			grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+	}
+	else
+	{
+        if(grouping_.groupAttribute_.name_.empty())
+			return false;
+
+		TeDatabasePortal* portal = db->getPortal();
+		string query;
+		bool normal = false;
+		string aggrFunc = "";
+		if(grouping_.groupFunction_.empty())
+			aggrFunc = " MIN";
+		else
+			aggrFunc = grouping_.groupFunction_;
+
+		if(grouping_.groupNormAttribute_.empty())
+		{
+			query = " SELECT "+ aggrFunc +"("+ grouping_.groupAttribute_.name_ +")";  
+		}
+		else
+		{
+			query = " SELECT "+ aggrFunc +"("+ grouping_.groupAttribute_.name_ +") / "+ aggrFunc +"("+ grouping_.groupNormAttribute_ + ")";
+			normal = true;
+		}
+		query += sqlGridFrom(); 
+		query += " GROUP BY " + remoteTheme_->collectionTable() + ".c_object_id";
+		if(!portal->query(query) || !portal->fetchRow())
+		{
+			delete portal;
+			return false;
+		}
+		vector<double> dValues;  //inputvect
+		vector<string> sValues;	//svec
+		double mean, sum; 
+		mean = sum = 0.;
+		do  
+		{
+			string val = portal->getData(0);
+			string valNorm = Te2String(atof(val.c_str()), grouping_.groupPrecision_);
+
+			if (!val.empty())
+			{
+				if(grouping_.groupMode_== TeUniqueValue)
+				{
+					if(normal)
+						sValues.push_back(valNorm);
+					else
+						sValues.push_back(val);
+				}
+				else
+				{
+					dValues.push_back(atof(valNorm.c_str()));
+					sum += atof(valNorm.c_str());
+				}
+
+			}
+			else
+				nullValues++;
+		}while(portal->fetchRow());
+		
+		delete portal;
+		
+		if(dValues.empty() && sValues.empty())
+			return false;
+
+		if(grouping_.groupMode_== TeEqualSteps)
+			TeGroupByEqualStep(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeQuantil)
+			TeGroupByQuantil(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeStdDeviation)
+		{
+			string m = Te2String(mean);
+			TeGroupByStdDev(dValues.begin(), dValues.end(), grouping_.groupStdDev_, slices, m, grouping_.groupPrecision_);
+		}
+		else if(grouping_.groupMode_== TeUniqueValue)
+		{
+			if(grouping_.groupFunction_ == "COUNT")
+				TeGroupByUniqueValue(sValues, TeINT, slices, grouping_.groupPrecision_);
+			else
+				TeGroupByUniqueValue(sValues, grouping_.groupAttribute_.type_, slices, grouping_.groupPrecision_);
+		}
+
+		if (dValuesVec)
+		{
+			for (i = 0; i < dValues.size(); ++i)
+				dValuesVec->push_back(dValues[i]);
+		}
+	}
+	if(grouping_.groupNullAttr_ && nullValues > 0)
+	{
+		TeSlice ps;
+		ps.count_ = nullValues;
+		ps.from_ = "Missing Data";
+		slices.push_back(ps);
+		grouping_.groupNumSlices_ = slices.size() - 1;
+	}
+	else
+		grouping_.groupNumSlices_ = slices.size();
+
+	legend_.clear(); 
+	for(i=0; i<slices.size(); ++i)
+	{
+		TeLegendEntry legend(slices[i]);
+		legend.group(i);
+		legend.theme(id());
+		legend_.push_back(legend);
+	}
+	return true;
+}
+
+bool TeExternalTheme::buildGrouping(const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec)
+{
+	TeDatabase* db = remoteTheme_->layer()->database();
+
+	if(!db || chr == TeNOCHRONON)
+		return false;
+
+	grouping_ = g;
+
+	unsigned int i;
+	vector<TeSlice> slices;
+	vector<double> dValues;  //inputvect
+	vector<string> sValues;	//svec
+	double mean, sum; 
+	mean = sum = 0.;
+	int	nullValues = 0;
+	string val;
+
+	if (grouping_.groupMode_ == TeRasterSlicing)
+	{
+		int b = atoi(grouping_.groupAttribute_.name_.c_str());
+		if (!remoteTheme_->layer()->raster() ||  
+			b < 0 ||
+			b > remoteTheme_->layer()->raster()->params().nBands() ||
+			grouping_.groupNumSlices_ <= 0)
+			return false;
+
+		if (grouping_.groupMaxVal_ == TeMINFLOAT)
+			grouping_.groupMaxVal_ = remoteTheme_->layer()->raster()->params().vmax_[b];
+
+		if (grouping_.groupMinVal_ == TeMAXFLOAT)
+			grouping_.groupMinVal_ = remoteTheme_->layer()->raster()->params().vmin_[b];
+
+		TeGroupByEqualStep(grouping_.groupMinVal_, grouping_.groupMaxVal_,
+			grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+	}
+	else
+	{
+		string func;
+		TeStatisticType statType = TeNOSTATISTIC;
+		if (grouping_.groupMode_ == TeUniqueValue && grouping_.groupAttribute_.type_ == TeSTRING)
+			func = "MIN";
+		else
+			func = grouping_.groupFunction_;
+
+		if (func == "MIN")
+			statType = TeMINVALUE;
+		else if (func == "MAX")
+			statType = TeMAXVALUE;
+		else if (func == "MEAN")
+			statType = TeMEAN;
+		else if (func == "SUM")
+			statType = TeSUM;
+		else if (func == "COUNT")
+			statType = TeCOUNT;
+
+		// Set the flag that indicates the geometries must not be loaded
+		bool loadGeometries = false;
+
+		// Insert the attributes in a multimap that relates the attribute 
+		// representation and its statistic type
+		TeGroupingAttr attrMMap;
+		pair<TeAttributeRep, TeStatisticType> attr1 (
+			TeAttributeRep(grouping_.groupAttribute_), statType);
+		attrMMap.push_back(attr1);
+
+		// Set querier parameters
+		TeQuerierParams querierParams(loadGeometries, attrMMap);
+		querierParams.setParams(this, chr);
+
+		TeQuerier querier(querierParams);
+
+		// Load instances based on the querier parameters given
+		int numFrames = querier.getNumTimeFrames();
+		TeSTInstance sti;
+		string objId;
+		TePropertyVector vec;
+		mapObjValVec.resize(numFrames);
+
+		for (int frame = 0; frame < numFrames; ++frame)
+		{
+			if (querier.loadInstances(frame) == false)
+				continue;
+
+			// Traverse all the instances
+			while(querier.fetchInstance(sti))
+			{
+				objId = sti.objectId();
+				vec = sti.getPropertyVector();
+				val = vec[0].value_;
+				dValues.push_back(atof(val.c_str()));
+				sValues.push_back(val);
+				map<string, string>& objValMap = mapObjValVec[frame];
+				objValMap.insert(make_pair(objId, val));
+			}
+		}
+
+		if(grouping_.groupMode_== TeEqualSteps)
+			TeGroupByEqualStep(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeQuantil)
+			TeGroupByQuantil(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeStdDeviation)
+		{
+			string m = Te2String(mean);
+			TeGroupByStdDev(dValues.begin(), dValues.end(), grouping_.groupStdDev_, slices, m, grouping_.groupPrecision_);
+		}
+		else if(grouping_.groupMode_== TeUniqueValue)
+		{
+			if(grouping_.groupFunction_ == "COUNT")
+				TeGroupByUniqueValue(sValues, TeINT, slices, grouping_.groupPrecision_);
+			else
+				TeGroupByUniqueValue(sValues, grouping_.groupAttribute_.type_, slices, grouping_.groupPrecision_);
+		}
+	}
+
+	if(grouping_.groupNullAttr_ && nullValues > 0)
+	{
+		TeSlice ps;
+		ps.count_ = nullValues;
+		ps.from_ = "Missing Data";
+		slices.push_back(ps);
+		grouping_.groupNumSlices_ = slices.size() - 1;
+	}
+	else
+		grouping_.groupNumSlices_ = slices.size();
+
+	legend_.clear(); 
+	for(i=0; i<slices.size(); ++i)
+	{
+		TeLegendEntry legend(slices[i]);
+		legend.group(i);
+		legend.theme(id());
+		legend_.push_back(legend);
+	}
+	
+	return true;
+}
+					
+bool TeExternalTheme::saveGrouping(TeSelectedObjects selectedObjects)
+{
+	return TeTheme::saveGrouping(sourceDB_, selectedObjects);
+}
+
+bool TeExternalTheme::saveLegendInCollection(TeSelectedObjects selectedObjects, std::string objectId)
+{
+	return saveLegendInCollection(sourceDB_, selectedObjects, objectId);
+}
+
+bool TeExternalTheme::saveLegendInCollection(TeDatabase* db, TeSelectedObjects /* selectedObjects */, std::string objectId)
+{
+	unsigned int i;
+	if(grouping_.groupMode_ == TeNoGrouping)
+		return false; 
+
+	TeAttrDataType		type = grouping_.groupAttribute_.type_;
+	TeLegendEntryVector legVec = legend_;
+	string			groupingAttr = grouping_.groupAttribute_.name_;
+
+	string collectionTableRemote = remoteTheme_->collectionTable();
+	string func;
+
+	if(grouping_.groupFunction_.empty())
+		func = " MIN";
+	else
+		func = grouping_.groupFunction_;
+
+	if(grouping_.groupFunction_ == "COUNT")
+		type = TeINT;
+
+	string query = "SELECT MIN(" + collectionTableRemote + ".c_object_id)";
+	if(grouping_.groupNormAttribute_.empty())
+		query += ", "+ func +"(" + groupingAttr + ")" + remoteTheme_->sqlGridFrom();
+	else
+		query += ", "+ func +"(" + groupingAttr + ") / "+ func +"(" + grouping_.groupNormAttribute_ + ")" + remoteTheme_->sqlGridFrom();
+	
+	query += " GROUP BY " + collectionTableRemote + ".c_object_id";
+
+	map<int, vector<string> > legMap;
+	
+	TeDatabasePortal* portal = remoteTheme_->layer()->database()->getPortal();
+	if(portal->query(query) == false)
+	{
+		delete portal;
+		return false;
+	}
+
+	vector<string> idVec;
+	vector<string> nullIdVec;
+	vector<string> valVec;
+	while(portal->fetchRow())
+	{
+		
+		string val = portal->getData(1);
+		string oid = portal->getData(0);
+		if (val.empty() == false)
+		{
+			idVec.push_back(oid);
+			valVec.push_back(val);
+		}
+		else
+			nullIdVec.push_back(oid);
+	}
+	if (grouping_.groupMode_ == TeUniqueValue)
+	{
+		unsigned int j = 0;
+		while( j < idVec.size())
+		{
+			string val = valVec[j];
+			string oid = idVec[j];
+			if(type == TeREAL)
+			{
+				double a = atof(val.c_str());
+				val = Te2String(a, grouping_.groupPrecision_);
+			}
+			else if(type == TeINT)
+			{
+				int a = atoi(val.c_str());
+				val = Te2String(a);
+			}
+				
+			unsigned int siz = legend_.size();
+			if(grouping_.groupNullAttr_ && nullIdVec.size() > 0)
+				--siz;
+			for(i=0; i < siz; i++)
+			{
+				TeLegendEntry& leg = legend_[i];
+				if(val == leg.from())
+				{
+					legMap[leg.id()].push_back(oid);
+					break;
+				}
+			}
+			j++;
+		}
+	}
+	else
+	{
+		unsigned int j = 0;
+		while(j < idVec.size())
+		{
+			string val = valVec[j];
+			string oid = idVec[j];
+			if(type == TeREAL)
+			{
+				double a = atof(val.c_str());
+				val = Te2String(a, grouping_.groupPrecision_);
+			}
+			
+			unsigned int siz = legend_.size();
+			if(grouping_.groupNullAttr_ && !nullIdVec.empty())
+               --siz; 
+			for(i=0; i < siz; i++)
+			{
+				TeLegendEntry& leg = legend_[i];
+				int f = leg.from().find("mean");
+				if(f >= 0)
+					continue;
+				double dval = atof(val.c_str());
+				double dfrom = atof(leg.from().c_str());
+				double dto = atof(leg.to().c_str());
+				if(i < legend_.size()-1)
+				{
+					if(dval >= dfrom && dval < dto)
+					{
+						legMap[leg.id()].push_back(oid);
+						break;
+					}
+				}
+				else
+				{
+					if(dval >= dfrom && dval <= dto)
+					{
+						legMap[leg.id()].push_back(oid);
+						break;
+					}
+				}
+			}
+			j++;
+		}
+	}
+	delete portal;
+
+	int legId = defaultLegend_.id();
+	if (grouping_.groupNullAttr_)
+		legId = legend_[legend_.size()-1].id();	
+	for(i = 0; i < nullIdVec.size(); ++i)
+	{
+		string oid = nullIdVec[i];
+		legMap[legId].push_back(oid);
+	}
+
+	vector<string> svec;
+	map<int, vector<string> > :: iterator it = legMap.begin();
+	while(it != legMap.end())
+	{
+    	// --- Generate In Clauses ----
+		unsigned int i, j, k, size, chunkSize = 200, nChunks;
+		string inClause;
+		size = it->second.size();
+		if (size % chunkSize)
+			nChunks = size / chunkSize + 1;
+		else
+			nChunks = size / chunkSize;
+
+		j = 0;		
+		for (k = 0; k < nChunks; ++k)
+		{
+			i = 0;
+			inClause = "(";
+			while (j < size && i < chunkSize)
+			{
+				inClause += "'" + db->escapeSequence(it->second[j]) + "',";
+				i++;
+				j++;
+			}
+			inClause[inClause.size() - 1] = ')';
+			svec.push_back(inClause);
+		}
+
+		//--- generateInClause
+
+		for(i=0; i<svec.size(); ++i)
+		{
+			string up = "UPDATE " + collectionTable_ + " SET c_legend_id = " + Te2String(it->first);
+			up += " WHERE c_object_id IN " + svec[i];
+			if (!objectId.empty())
+				up += " AND c_object_id='"+objectId+"'";
+			if(db->execute(up) == false)
+				continue;
+		}
+		it++;
+		svec.clear();
+	}
+	if(legend_.size())
+		visibleRep_ = visibleRep_ | 0x40000000;
+	else
+		visibleRep_ = visibleRep_ | 0xbfffffff;
+	string upVis = "UPDATE te_theme SET visible_rep=" + Te2String(visibleRep_) + " WHERE theme_id=" + Te2String(id());
+	
+	if(!db->execute(upVis))
+		return false;
+	
+	loadObjectLegendMap();
+
+	return true;
+}
+
+void TeExternalTheme::setLegendsForObjects()
+{
+}
+
+bool TeExternalTheme::generateLabelPositions(const std::string& /* objectId */)
+{
+	throw;
+	return false;
+}
+
+bool TeExternalTheme::deleteGrouping()
+{
+	TeDatabase* db = sourceDB_;
+	if(!db)
+		return false;
+
+	resetGrouping();
+	
+	//delete te_legend table
+	if(!db->deleteLegend (this->id()))
+		return false;
+	
+	//delete te_grouping table
+	string sql = "DELETE FROM te_grouping WHERE theme_id= "+ Te2String(this->id());
+	db->execute (sql);
+
+	return true;
+}
+
+void TeExternalTheme::createRasterVisual(TeRaster* rst)
+{
+	if (rasterVisual_)
+		delete rasterVisual_;
+
+	if (!rst)
+		rst = remoteTheme_->layer()->raster();
+
+	if (!rst)
+		return;
+
+	rasterVisual_ = new TeRasterTransform();
+										
+	if (rst->params().photometric_[0] == TeRasterParams::TePallete)  // raster palette -> uses its palette
+	{
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Pallete2ThreeBand);
+		rasterVisual_->setLutSize(rst->params().lutr_.size());
+		return;
+	}
+
+	if (visibleRep_ & 0x40000000  &&		// sliced raster -> generate the
+		grouping_.groupMode_ == TeRasterSlicing)	// appropriate palette
+	{
+		int band = atoi(grouping_.groupAttribute_.name_.c_str());
+		rasterVisual_->setSrcBand(band);
+		if (rst->params().dataType_[band] != TeUNSIGNEDCHAR)
+			rasterVisual_->generateLUT(legend_, 1024, defaultLegend_.visual(TePOLYGONS)->color());
+		else
+			rasterVisual_->generateLUT(legend_, 256, defaultLegend_.visual(TePOLYGONS)->color());
+		rasterVisual_->setTransfFunction(&TeRasterTransform::LUT2ThreeBand);
+		return;
+	}
+
+	if (rst->params().dataType_[0] != TeUNSIGNEDCHAR)	// non unsigned char -> generate linear transformation
+		rasterVisual_->setLinearTransfParameters(rst->params().vmin_[0],rst->params().vmax_[0], 0, 255);
+
+	if (rst->params().nBands() == 1)				
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Mono2ThreeBand);
+	else if (rst->params().nBands() == 3)
+		rasterVisual_->setTransfFunction(&TeRasterTransform::ThreeBand2RGB);
+	else
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Band2Band);
+}
+
+bool TeExternalTheme::addThemeTable(TeTable& table)
+{
+	if( remoteTheme_ )
+		return remoteTheme_->addThemeTable(table);
+
+	return false;
+}
+
+void TeExternalTheme::addThemeTable(string tableName)
+{
+	if( remoteTheme_ )
+		return remoteTheme_->addThemeTable(tableName);
+
+	return;
+}
+
+bool TeExternalTheme::isThemeTable(int tableId)
+{
+	if( remoteTheme_ )
+		return remoteTheme_->isThemeTable(tableId);
+
+	return false;
+}
+
+bool TeExternalTheme::isThemeTable(string tableName)
+{
+	if( remoteTheme_ )
+		return remoteTheme_->isThemeTable(tableName);
+
+	return false;
+}
+
+TeAttrTableVector& TeExternalTheme::attrTables()
+{
+	if( remoteTheme_ )
+		return remoteTheme_->attrTables();
+	attTableVector_.clear();
+	return attTableVector_;
+}
+
+bool TeExternalTheme::setAttTables(TeAttrTableVector& attrs)
+{
+	if( remoteTheme_ )
+		return remoteTheme_->setAttTables(attrs);
+
+	return false;
+}
+
+bool TeExternalTheme::getAttTables(TeAttrTableVector& attrs, TeAttrTableType attType)
+{
+	if(remoteTheme_)
+		return remoteTheme_->getAttTables(attrs, attType);
+
+	return false;
+}
+
+bool TeExternalTheme::getTable(TeTable& table, const string tableName)
+{
+	if(remoteTheme_)
+		return remoteTheme_->getTable(table, tableName);
+
+	return false;
+}
+
+void TeExternalTheme::clearAttTableVector() 
+{
+	if(remoteTheme_)
+		remoteTheme_->clearAttTableVector();
+}
+
+bool TeExternalTheme::getTemporalTable(TeTable& table)
+{
+	if(remoteTheme_)
+		return remoteTheme_->getTemporalTable(table);
+
+	return false;
+}
+
+bool TeExternalTheme::removeThemeTable(unsigned int index)
+{
+	if(remoteTheme_)
+		return remoteTheme_->removeThemeTable(index);
+
+	return false;
+}
+
+string TeExternalTheme::getTableName(const string& attrName)
+{
+	if(remoteTheme_)
+		return remoteTheme_->getTableName(attrName);
+
+	return "";
+}
+
+string TeExternalTheme::getAttribute(unsigned int index)
+{
+	if(remoteTheme_)
+		return remoteTheme_->getAttribute(index);
+
+	return "";
+}
+
+
+bool TeExternalTheme::loadThemeTables()
+{
+	if(!remoteTheme_)
+		return false;
+
+	bool result = remoteTheme_->loadThemeTables();
+
+	if(result)
+	{
+		clearAttTableVector();
+		attrTables() = remoteTheme_->attrTables();
+	}
+
+	return result;
+}
+
+
+TeAttributeList TeExternalTheme::sqlAttList()
+{
+	if(remoteTheme_)
+		return remoteTheme_->sqlAttList();
+
+	return TeAttributeList();
+}
+
+void TeExternalTheme::clearAttList()
+{
+	if(remoteTheme_)
+		return remoteTheme_->clearAttList();
+}
+
+TeAttributeList TeExternalTheme::sqlNumAttList()
+{
+	if(remoteTheme_)
+		return remoteTheme_->sqlNumAttList();
+
+	return TeAttributeList();
+}
+
+void TeExternalTheme::clearNumAttList()
+{
+	if(remoteTheme_)
+		remoteTheme_->clearNumAttList();
+}
+
+string TeExternalTheme::sqlJoin()
+{
+	if(remoteTheme_)
+		return remoteTheme_->sqlJoin();
+
+	return "";
+}
+
+string TeExternalTheme::sqlFrom()
+{
+	if(remoteTheme_)
+		return remoteTheme_->sqlFrom();
+
+	return "";
+}
+
+vector<string>&	TeExternalTheme::aliasVector()
+{
+	if(remoteTheme_)
+		return remoteTheme_->aliasVector();
+	aliasVector_.clear();
+	return aliasVector_;
+}
+
+void TeExternalTheme::loadAliasVector()
+{
+	if(remoteTheme_)
+		return remoteTheme_->loadAliasVector();
+
+	return;
+}
+
+void TeExternalTheme::loadAttrLists()
+{
+	if(!remoteTheme_)
+		return;
+
+	remoteTheme_->loadAttrLists();
+
+	sqlAttList_.clear();
+	sqlNumAttList_.clear();
+
+	sqlAttList_ = remoteTheme_->sqlAttList();
+	sqlNumAttList_ = remoteTheme_->sqlNumAttList();
+
+}
+
+bool TeExternalTheme::locatePolygon(TeCoord2D &pt, TePolygon &polygon, const double& tol)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->locatePolygon(pt, polygon, tol);
+}
+
+bool TeExternalTheme::locatePolygonSet(TeCoord2D &pt, double tol, TePolygonSet &polygons)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->locatePolygonSet(pt, tol, polygons);
+}
+
+bool TeExternalTheme::locateLine(TeCoord2D &pt, TeLine2D &line, const double& tol)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->locateLine(pt, line, tol);
+}
+
+bool TeExternalTheme::locatePoint(TeCoord2D &pt, TePoint &point, const double& tol)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->locatePoint(pt, point, tol);
+}
+
+bool TeExternalTheme::locateCell(TeCoord2D &pt, TeCell &c, const double& tol)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->locateCell(pt, c, tol);
+}
+
+bool TeExternalTheme::hasObjectsWithoutGeometries(TeGeomRep geomRep)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->hasObjectsWithoutGeometries(geomRep);
+}
+
+bool TeExternalTheme::removeObjectsWithoutGeometries(TeGeomRep geomRep)
+{
+	if(!remoteTheme_)
+		return false;
+
+	return remoteTheme_->removeObjectsWithoutGeometries(geomRep);
+}
+
+int TeExternalTheme::createExternalThemeTable(TeDatabase* sourceDB)
+{
+	if(!sourceDB)
+		return 0;
+
+	if(sourceDB->tableExist("te_external_theme"))
+		return -1;
+
+	TeAttributeList attList;
+
+	TeAttribute att1;
+	att1.rep_.name_ = "theme_id";
+	att1.rep_.isAutoNumber_ = false;
+	att1.rep_.isPrimaryKey_ = true;
+	att1.rep_.null_ = false;
+	att1.rep_.type_ = TeINT;
+	att1.rep_.numChar_ = 0;
+	attList.push_back(att1);
+
+	TeAttribute att2;
+	att2.rep_.name_ = "database_id";
+	att2.rep_.isAutoNumber_ = false;
+	att2.rep_.isPrimaryKey_ = false;
+	att2.rep_.null_ = false;
+	att2.rep_.type_ = TeINT;
+	att2.rep_.numChar_ = 0;
+	attList.push_back(att2);
+
+	TeAttribute att3;
+	att3.rep_.name_ = "external_theme_id";
+	att3.rep_.isAutoNumber_ = false;
+	att3.rep_.isPrimaryKey_ = false;
+	att3.rep_.null_ = false;
+	att3.rep_.type_ = TeINT;
+	att3.rep_.numChar_ = 0;
+	attList.push_back(att3);
+
+	if(!sourceDB->createTable("te_external_theme", attList))
+		return 0;
+
+	return 1;
+}
+
+bool TeExternalTheme::populateCollection(std::string /* objectId */)
+{
+	throw;
+	return false;
+}
+
+void TeExternalTheme::createLegendMapId(std::map<int, int>& mapIdLegend)
+{
+	mapIdLegend.clear();
+
+	mapIdLegend[remoteTheme_->outOfCollectionLegend().id()] = outOfCollectionLegend().id();
+	mapIdLegend[remoteTheme_->withoutDataConnectionLegend().id()] = withoutDataConnectionLegend().id();
+	mapIdLegend[remoteTheme_->defaultLegend().id()] = defaultLegend().id();
+	mapIdLegend[remoteTheme_->pointingLegend().id()] = pointingLegend().id();
+	mapIdLegend[remoteTheme_->queryLegend().id()] = queryLegend().id();
+	mapIdLegend[remoteTheme_->queryAndPointingLegend().id()] = queryAndPointingLegend().id();
+
+	for (int i = 0; i < remoteTheme_->grouping().groupNumSlices_; ++i)
+	{
+		mapIdLegend[remoteTheme_->legend()[i].id()] = legend()[i].id();
+	}
+	
+	return;
+}
+
+bool TeExternalTheme::copyRemoteCollection(std::map<int, int>& mapIdLegend)
+{
+	if(mapIdLegend.empty())
+		return false;
+//copy collectionTable
+	TeDatabasePortal* remotePortal = remoteTheme_->layer()->database()->getPortal();
+	string strSQL  = "SELECT * from ";
+	strSQL	+= remoteTheme_->collectionTable();
+
+	if(remotePortal->query(strSQL))
+	{
+		while(remotePortal->fetchRow())
+		{
+			string c_obj_id = remotePortal->getData(0);
+			int c_leg_id = atoi(remotePortal->getData(1));
+			string lab_x = remotePortal->getData(2);
+			string lab_y = remotePortal->getData(3);
+//			string c_leg_own = remotePortal->getData(4);
+			string c_leg_own = "0";
+			string c_obj_stat = remotePortal->getData(5);
+
+			int new_c_leg_id = mapIdLegend[c_leg_id];
+
+			string strINS = "INSERT INTO ";
+			strINS += this->collectionTable();
+			strINS += " (c_object_id, c_legend_id, label_x, label_y, c_legend_own, c_object_status) ";
+			strINS += "VALUES (";
+			strINS += c_obj_id;
+			strINS += ", ";
+			strINS += Te2String(new_c_leg_id);
+			strINS += ", ";
+			strINS += lab_x;
+			strINS += ", ";
+			strINS += lab_y;
+			strINS += ", ";
+			strINS += c_leg_own;
+			strINS += ", ";
+			strINS += c_obj_stat;
+			strINS += ")";
+
+			if(!sourceDB_->execute(strINS))
+				return false;
+		}
+	}
+	else
+		return false;
+
+	remotePortal->freeResult();
+	delete remotePortal;
+
+
+//copy collectionTableAux
+	TeDatabasePortal* remotePortalAux = remoteTheme_->layer()->database()->getPortal();
+	string strSQLAux  = "SELECT * from ";
+	strSQLAux	+= remoteTheme_->collectionAuxTable();
+
+	if(remotePortalAux->query(strSQLAux))
+	{
+		while(remotePortalAux->fetchRow())
+		{
+			string c_obj_id = remotePortalAux->getData(0);
+			string unique_id = remotePortalAux->getData(1);
+			string grid_status = remotePortalAux->getData(2);
+
+			string strINSAux = "INSERT INTO ";
+			strINSAux += this->collectionAuxTable();
+			strINSAux += " (object_id, unique_id, grid_status) ";
+			strINSAux += "VALUES (";
+			strINSAux += c_obj_id;
+			strINSAux += ", ";
+			strINSAux += unique_id;
+			strINSAux += ", ";
+			strINSAux += grid_status;
+			strINSAux += ")";
+
+			if(!sourceDB_->execute(strINSAux))
+				return false;
+		}
+	}
+	else
+		return false;
+
+	remotePortalAux->freeResult();
+	delete remotePortalAux;
+
+	return true;
+}
+
+
+
+bool TeExternalTheme::getRemoteThemeInfo(int& remoteThemeId, int& databaseId)
+{
+	if(!sourceDB_)
+		return false;
+	
+	std::string strSQL = " SELECT * FROM te_external_theme, te_database_connection ";
+	strSQL += " WHERE te_external_theme.database_id = te_database_connection.connection_id ";
+	strSQL += " AND theme_id = " + Te2String(id());
+    
+	TeDatabasePortal* dbPortal = sourceDB_->getPortal();
+
+    if(!dbPortal)
+		return false;
+
+    if(!dbPortal->query(strSQL) || !dbPortal->fetchRow())
+    {
+        dbPortal->freeResult();
+        delete dbPortal;
+		return false;
+	}
+
+	databaseId = dbPortal->getInt("database_id");
+	remoteThemeId = dbPortal->getInt("external_theme_id");
+	string dbmsName = dbPortal->getData("dbms_name"); 
+	string hostName = dbPortal->getData("host_name"); 
+	string dbName = dbPortal->getData("database_name");
+	string userName = dbPortal->getData("user_name");
+	string userPass = dbPortal->getData("user_password");
+	int port = dbPortal->getInt("port_number");
+
+	TeDBConnection dbConn(hostName, dbName, userName, dbmsName, port, userPass, databaseId);
+	dbConn.setDatabase(0);
+	setRemoteDBConnection(dbConn);
+
+	dbPortal->freeResult();
+    delete dbPortal;
+	return true;
+}
+
+bool 
+TeExternalTheme::loadMetadata(TeDatabase* db)
+{
+	if(remoteTheme_ || !db)
+		return false;
+
+	int remoteThemeId = -1;
+	int remoteDBId = -1;
+
+	this->setSourceDatabase(db);
+
+	if(!getRemoteThemeInfo(remoteThemeId, remoteDBId))
+		return false;	
+	
+	TeDatabase* remotedb = TeDBConnectionsPool::instance().getDatabase(getRemoteDBConnection().getDbKey());
+		
+	if(!remotedb || !remotedb->isConnected())
+		return false;
+	
+	TeThemeMap::iterator itTheme = remotedb->themeMap().find(remoteThemeId);
+
+	if(itTheme != remotedb->themeMap().end())
+	{
+// is theme already loaded?
+		if(itTheme->second->getProductId()!=TeTHEME)
+			return false;
+		remoteTheme_ = static_cast<TeTheme*>(itTheme->second);
+	}
+	else
+	{
+// if theme is not loaded... we load it.
+		remoteTheme_ = new TeTheme();
+		remoteTheme_->id(remoteThemeId);
+		if(!remotedb->loadTheme(remoteTheme_))
+			return false;
+	}
+
+	loadObjectLegendMap();
+	return true;
+}
+
+bool TeExternalTheme::saveMetadata(TeDatabase* db)
+{
+	if(!remoteTheme_ || !remoteTheme_->layer() || !remoteTheme_->layer()->database())
+		return false;
+	
+	int idDatabase = this->getRemoteDBConnection().getId();
+	int themeId = this->id();
+	int remoteThemeId = remoteTheme_->id();
+
+	TeDatabasePortal* portal = db->getPortal();
+	if(!portal)
+		return false;
+	
+	string sql = "SELECT * FROM te_external_theme WHERE theme_id = "+ Te2String(themeId);
+	bool isUpdate = false;
+	if(!portal->query(sql))
+	{
+		delete portal;
+		return false;
+	}
+	if(portal->fetchRow())
+		isUpdate = true;
+	delete portal;
+
+	string strSQL;
+	if(isUpdate)
+	{
+		strSQL  = "UPDATE te_external_theme SET ";
+		strSQL += " theme_id = "+ Te2String(themeId);
+		strSQL += ", ";
+		strSQL += " database_id = "+ Te2String(idDatabase);
+		strSQL += ", ";
+		strSQL += " external_theme_id = "+ Te2String(remoteThemeId);
+		strSQL += " WHERE theme_id = "+ Te2String(themeId);
+	}
+	else
+	{
+		strSQL  = "INSERT INTO te_external_theme (theme_id, database_id, external_theme_id) VALUES (";
+		strSQL += Te2String(themeId);
+		strSQL += ", ";
+		strSQL += Te2String(idDatabase);
+		strSQL += ", ";
+		strSQL += Te2String(remoteThemeId);
+		strSQL += ")";
+	}
+
+	if(!db->execute(strSQL))
+		return false;
+
+	return true;
+}
+
+bool TeExternalTheme::eraseMetadata(TeDatabase* db)
+{
+	int themeId = this->id();
+	
+	string strSQL;
+	strSQL  = " DELETE FROM te_external_theme ";
+    strSQL += " WHERE theme_id = "+ Te2String(themeId);
+	
+	if(!db->execute(strSQL))
+		return false;
+	return true;
+}
+
diff --git a/src/terralib/kernel/TeExternalTheme.h b/src/terralib/kernel/TeExternalTheme.h
new file mode 100644
index 0000000..473260c
--- /dev/null
+++ b/src/terralib/kernel/TeExternalTheme.h
@@ -0,0 +1,422 @@
+/************************************************************************************
+ TerraLib - a library for developing GIS applications.
+Copyright � 2001-2006 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/** \file TeExternalTheme.h
+    \brief This file contains direct implementation of TeTheme in order to 
+	support themes from another TerraLib databases (remote databases).
+*/
+
+#ifndef  __TERRALIB_INTERNAL_EXTERNALTHEME_H
+#define  __TERRALIB_INTERNAL_EXTERNALTHEME_H
+
+#include <map>
+#include <string>
+
+#include "TeTheme.h"
+#include "TeDBConnection.h"
+
+/** \fn bool TeLoadConnectionsInfo(TeDatabase* sourceDB)
+    \brief Loads all connections information from source database and populates Remote theme database index.
+	\param sourceDB A connection to a TerraLib database that stores information about others databases that can be used by remote themes. (Input)
+ */
+TL_DLL bool TeLoadConnectionsInfo(TeDatabase* sourceDB);
+
+
+//! A class that implements the external theme concept  
+/*!
+	A external theme is a theme stored in a remote TerraLib database.
+	Some information about the external theme is stored in the local database, but
+	its geometries and attributes are stored in the remote database. 
+
+	\sa TeTheme
+  
+ */
+class TL_DLL TeExternalTheme : public TeTheme
+{
+	public:
+
+		//! Constructor.
+		TeExternalTheme(TeDatabase* sourceDB, const string& name = "", TeViewNode* parent = 0, const int& view = 0, const int& id = 0);
+
+		//! Constructor
+		TeExternalTheme(const TeViewNodeParams& params); 
+
+		//! Destructor.
+		virtual ~TeExternalTheme();
+	
+		//! Copy constructor
+		TeExternalTheme(const TeExternalTheme& rhs);
+
+		//! Operator =
+		TeExternalTheme& operator=(TeExternalTheme& rhs);
+
+
+		/** @name Remote Theme Accessor Methods
+		  * Methods related to the remote theme reference.
+		  */
+		//@{
+		virtual void setSourceDatabase(TeDatabase* db); 
+
+		virtual TeDatabase* getSourceDatabase(); 
+
+		virtual TeTheme* getRemoteTheme() const;
+		
+		virtual void setRemoteTheme(TeTheme* theme); 
+
+		virtual string getRemoteThemeName(); 
+		//@}
+
+
+		/** @name Object status containers
+		  * Methods to handle object status containers
+		  */
+		//@{
+		virtual void loadObjectLegendMap();
+		
+		virtual int getGridStatus(const int uniqueId, const std::string objectId);
+
+		virtual int getObjectStatus(const std::string objectId);
+
+		virtual bool setObjectLegendStatusMap(const std::string objId, const int status);
+		
+		virtual bool setObjectGridStatusMap(const std::string objId, const int uniqueId, const int status);
+		//@}
+
+		/** @name Layer accessor methods
+		  * Methods related to the layer that gives origin to this theme.
+		  */
+		//@{
+
+		/** \brief Returns the identification of the source layer.
+		    \note In a Remote Theme this will be always -1.
+		  */
+		virtual int layerId();
+
+		/** \brief Sets the identification of the source layer.
+		    \param i Layer identification value that will be used to set the source layer. (Input)
+			\note In a Remote Theme this method does nothing.
+		  */
+		virtual void layerId(int i);
+
+		/** \brief Sets the layer that is the source of objects of the theme.
+		    \param layer A pointer to a TeLayer. (Input)
+          */
+		virtual void layer(TeLayer* layer);
+
+		/** \brief Returns a pointer to the layer from which the theme get its objects.
+		    \note In a Remote Theme this method returns a NULL pointer.
+		  */
+		virtual TeLayer* layer();
+
+		//! Returns a pointer to the projection of the remote layer
+		virtual TeProjection* getThemeProjection();
+
+		//@}
+
+		/** @name 
+		  * Methods related to the restrictions over the theme used to generate this theme
+          */
+		//@{
+
+		/** \brief Verifies if this theme has any kind of restrictions.
+		    \note In a Remote Theme this method always returns FALSE.
+		  */
+		virtual bool hasRestriction();
+
+		/** \brief Returns if there is an attribute restriction.
+		    \note In a Remote Theme this method always returns FALSE.
+		  */
+		virtual bool hasAttrRest();
+
+		/** \brief Returns TRUE if there is a temporal restriction defined in the theme.
+		    \note In a Remote Theme this method always returns FALSE. 
+		  */
+		virtual bool hasTemporalRest();
+
+		/** \brief Returns TRUE if this theme has a spatial restriction.
+		    \note In a Remote Theme this method always returns FALSE.
+		  */
+		virtual bool hasSpatialRest();
+
+		/** \brief Returns the clause WHERE derived from the combination of all restricitions (spatial, attribute and temporal).
+		    \note In a Remote Theme this method always returns an empty string.
+		  */
+		virtual string sqlWhereRestrictions(TeRepresentation* rep = 0);
+
+		//@}
+
+		/** @name Collection
+		  * Methods related to the materialization in the database of the theme as a collection of objects 
+          */
+		//@{
+
+		/** \brief Fills the sqlGridJoin_ and sqlGridFrom_ statements according to the status of the database.
+		    \note In a Remote Theme this method does nothing.
+		  */
+		virtual void loadTablesJoin(const string& geomTable = "");
+
+		/** \brief Returns a SQL JOIN statement to get all the attributes of the theme objects, 
+		           the attributes of the collection table, and the attributes of the extended 
+                   collection table.
+		    \note In a Remote Theme this method returns an empty string.
+	      */
+		virtual string sqlGridJoin();
+
+		/** \brief Returns a FROM clause of a SQL statement to get attributes of the theme objects,
+		           the attributes of the collection table, and the attributes of the
+				   extended collection table .
+		    \note In a Remote Theme this method returns an empty string.
+	      */
+		virtual string sqlGridFrom(const string& geomTable="");
+
+		//! Save the the theme parameters in the database.
+		virtual bool save(TeDatabase* db); 
+		
+		//! Save the the theme parameters in the database.
+		virtual bool save();
+
+		/** \brief Create the auxiliar collection table used to represent objects with multiple versions in time.
+		    \note In a Remote Theme this method creates a local auxiliary collection table.
+		  */
+		virtual bool createCollectionAuxTable();
+
+		/** \brief Populate the auxiliar collection table used to represent objects with multiple versions in time.
+		    \note In a Remote Theme this method populates the local auxiliary collection.
+		  */
+		virtual bool populateCollectionAux(std::string objectId = "");
+
+		//@}
+
+		//! Save the grouping parameters in memory when there is no chronon.
+		virtual bool buildGrouping(const TeGrouping& g, TeSelectedObjects selectedObjects = TeAll,
+			                       vector<double>* dValuesVec = 0);
+
+		//! Save the grouping parameters in memory when there is chronon.
+		virtual bool buildGrouping(const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec);
+						   
+		//! Build the grouping and associate each object to its group in the collection table.
+		virtual bool saveGrouping(TeSelectedObjects selectedObjects = TeAll);
+
+		//! Save the theme grouping legends in the collection table.
+		virtual bool saveLegendInCollection(TeSelectedObjects selectedObjects = TeAll, std::string objectId = "");
+
+		//! Save the theme grouping legends in the collection table  
+		virtual bool saveLegendInCollection(TeDatabase* db, TeSelectedObjects selectedObjects = TeAll, std::string objectId = "");
+
+		///! Set the legend id for each object of the theme.
+		virtual void setLegendsForObjects();
+
+		//! Generates a optimized position (x,y) in the spatial extention of each object to position label or graphs.
+		virtual bool generateLabelPositions(const std::string& objectId = "");  
+
+		//! Delete grouping.
+		virtual bool deleteGrouping(); 
+		
+		//! Creates an appropriate visual presentation to the raster of the theme.
+		virtual void createRasterVisual(TeRaster* rst = 0);
+
+		/** @name Attribute Tables
+		  * A theme can use one or more attribute tables of the layer that gives its data.
+		  * These methods are related to the manipulation of these tables.
+          */
+		//@{	
+
+		//! Add a new attribute table to a theme.
+		virtual bool addThemeTable(TeTable& table);
+
+		//! Add a new attribute table to a theme.
+		virtual void addThemeTable(string tableName);
+
+		//! Verify if an attribute table is part of a theme.
+		virtual bool isThemeTable(int tableId);
+
+		//! Verify if an attribute table is part of a theme.
+		virtual bool isThemeTable(string tableName);
+
+		//! Returns the list of attribute tables used by this theme.
+		virtual TeAttrTableVector& attrTables();
+
+		//! Sets the entire list of attribute tables used by this theme.
+		virtual bool setAttTables(TeAttrTableVector& attrs);  
+
+		//! Returns a vector of attribute tables, of a specific type, used by this theme.
+		virtual bool getAttTables(TeAttrTableVector& attrs, TeAttrTableType attType = TeAllAttrTypes); 
+
+		//! Returns a representation of an attribute table  given name.
+		virtual bool getTable(TeTable& table, const string tableName);
+
+		//! Clears the list of attribute tables used by this theme.
+		virtual void clearAttTableVector();
+
+		/** \brief Returns the temporal attribute table of the theme (TeEvent or TeFixedGeomDynAttr).
+		    \note A theme supports only one temporal attribute table.
+		  */
+		virtual bool getTemporalTable(TeTable& table);
+
+		//! Removes an attribute table from the list of tables of a theme.
+		virtual bool removeThemeTable(unsigned int index);
+
+		//! Returns the the name of an attribute table that contains a given attribute.
+		virtual string getTableName(const string& attrName);
+
+		//! Returns the name of the index-th attribute resulting of the join of all attribute tables associated to the theme tables 
+		virtual string getAttribute(unsigned int index);
+
+		//! Loads the theme tables in the database
+		virtual bool loadThemeTables();
+		
+		//! Returns the list of attributes of theme tables.
+		virtual  TeAttributeList sqlAttList();
+		
+		//! Clears the list of attributes associated to the theme tables.
+		virtual void clearAttList();
+
+		//! Returns the list of numerical attributes of the theme tables.
+		virtual TeAttributeList sqlNumAttList();
+
+		//! Clears the list of numerical attributes associated to the theme tables.
+		virtual void clearNumAttList();
+
+		///! Returns a SQL JOIN statement to reach to all attribute tables used by this theme.
+		virtual string sqlJoin();
+
+		//! Returns a SQL FROM CLAUSE that gives access to all attribute tables used by this theme.
+		virtual string sqlFrom();
+
+		//! Returns the alias vector of the names of the theme tables.
+		virtual vector<string>&	aliasVector();
+
+		//! Fills aliasVector_.
+		virtual void loadAliasVector();
+
+		/** \brief Refresh list of attributes of all the theme tables.
+		    \note All attributes are stored into sqlAttList_ and numeric attributes are stored into sqlNumAttList_.
+          */
+		virtual void loadAttrLists();
+		//@}
+
+		/** @name Locate geometries
+		  * Returns the geometry(ies) of the theme given coordinate
+          */
+		//@{ 	
+
+		virtual bool locatePolygon(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
+		virtual bool locatePolygonSet(TeCoord2D &pt, double tol, TePolygonSet &polygons);
+		virtual bool locateLine(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
+		virtual bool locatePoint(TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
+		virtual bool locateCell(TeCoord2D &pt, TeCell &c, const double& tol = 0.0);
+
+		//@}
+
+		/** \brief Verifies if there are objects without geometries of a specific geometry representation.
+		  */
+		virtual bool hasObjectsWithoutGeometries(TeGeomRep geomRep);
+
+		/** \brief Removes the objects without geometries of a specific geometry representation.
+		  */
+		virtual bool removeObjectsWithoutGeometries(TeGeomRep geomRep);
+
+		/** \brief Creates a table to store information on how to connect to others databases and get remote theme.
+		    \param sourceDB A connection to a TerraLib database that stores information about others databases that can be used by remote themes. (Input)
+			\return Returns 1 if the table was created, -1 if it already exists and 0 on error.
+		  */
+		static int createExternalThemeTable(TeDatabase* sourceDB);
+
+		//! Save the theme metadata in database. 
+		virtual bool saveMetadata(TeDatabase* db); 
+
+		//! Get information about the remote database connection 
+		TeDBConnection& getRemoteDBConnection() { return remoteDBConn_; }
+
+		//! Set information about the remote database connection 
+		void setRemoteDBConnection(TeDBConnection& dbConn) {  remoteDBConn_ = dbConn; }
+		
+	protected:
+
+		/** \brief Fill the sqlJoin_ and sqlFrom_ .
+		  */
+		//virtual void loadThemeTablesJoin();
+		
+		/** \brief Populate the collection table based in the theme restrictions.
+		  */
+		virtual bool populateCollection(std::string objectId = "");
+
+		/** \brief Populate map with relationateds ids from local theme and remote theme.
+		  */
+		virtual void createLegendMapId(std::map<int, int>& mapIdLegend);
+
+		/** \brief Copy the respective collection table from remoteTheme to localTheme.
+		  */
+		virtual bool copyRemoteCollection(std::map<int, int>& mapIdLegend);
+
+				
+		/** \brief Retrieves remote theme information from the database.
+		  */
+		bool getRemoteThemeInfo(int& remoteThemeId, int& databaseId);
+
+		//! Load the external theme metadata from database. 
+		virtual bool loadMetadata(TeDatabase* db);
+
+		//! Erase the theme metadata in database. 
+		virtual bool eraseMetadata(TeDatabase* db); 
+
+	protected:
+        //! A pointer to a theme in a remote database.
+		TeTheme* remoteTheme_;	
+
+		//! Information about the remote database connection 
+		TeDBConnection remoteDBConn_;
+
+		//! A pointer to the source database (where the metadata is stored)
+		TeDatabase* sourceDB_;	
+};
+
+
+//!  This class implements a factory to create external theme objects. 
+class TL_DLL TeExternalThemeFactory : public TeViewNodeFactory
+{
+public:
+	//! Constructor 
+	TeExternalThemeFactory() : TeViewNodeFactory((int)TeEXTERNALTHEME)
+	{}
+
+	//! Created theme objects 
+	TeViewNode* build(TeViewNodeParams* params)
+	{	
+		TeViewNodeParams auxParams = *params;
+		return new TeExternalTheme(auxParams);	
+	}
+	
+	//! Created theme objects 
+	TeViewNode* build()
+	{	
+		return new TeExternalTheme(0);	
+	}
+};
+
+namespace 
+{
+  static TeExternalThemeFactory externalThemeFactory;
+}; 
+
+#endif	// __TERRALIB_INTERNAL_REMOTETHEME_H
+
diff --git a/src/terralib/kernel/TeFactory.h b/src/terralib/kernel/TeFactory.h
new file mode 100644
index 0000000..d6e86c5
--- /dev/null
+++ b/src/terralib/kernel/TeFactory.h
@@ -0,0 +1,145 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeFactory.h
+    \brief This file deals with the Factory Pattern 
+*/
+#ifndef  __TERRALIB_INTERNAL_FACTORY_H
+#define  __TERRALIB_INTERNAL_FACTORY_H
+
+#include <map>
+#include <string>
+
+using namespace std;
+
+//!  Implements a template for the "TeFactory" pattern.
+/*
+  The "factory" pattern is a technique for creating new
+  instances of objects which defines an abstract interface,
+  (represented by the "Make" module). The subclasses of
+  factory decide which class to instantiate.
+  
+
+  Each subclass of factory "registers" itself at compile time;
+  therefore, the addition of a new factory requires no change
+  the parent class. 
+
+  \author Gilberto Camara
+*/
+template <class T, class Arg>
+class TeFactory
+{
+public:
+
+//! Dictionary of factories (indexed by name)
+	typedef map<string, TeFactory<T,Arg>* > TeFactoryMap; 
+
+//! Returns the single instance of the factory dictionay
+	static TeFactoryMap& instance ()
+	{ 
+		static TeFactoryMap Fmap_;
+		return Fmap_;
+		
+	}
+	
+	//! Normal Constructor
+	TeFactory (const string& factoryName);
+
+	virtual ~TeFactory() {}
+
+	//! Virtual constructor using name
+	static T* make  ( string name, const Arg& arg );
+
+	//! Virtual constructor using arguments
+	static T* make  ( const Arg& arg  );
+
+
+protected:
+
+	//!  Builds a new type (should be implemented by descendants)
+    virtual T* build ( const Arg& arg ) = 0;
+
+private:
+	string  Fname_;
+};
+
+// Initialisation of static variable
+//template <class T, class Arg>
+//TeFactory<T,Arg>::TeFactoryMap TeFactory<T,Arg>::Fmap_;
+
+
+// Constructor
+template <class T, class Arg>
+TeFactory<T,Arg>::TeFactory(const string& name):
+	Fname_(name)
+{
+	TeFactory<T,Arg>::instance()[name] = this;
+
+}
+
+// Destructor
+//template <class T, class Arg>
+//TeFactory<T,Arg>::~TeFactory<T,Arg> ()
+//{
+	// Remove the object from the factory dictionary
+	// Fmap_.erase ( Fname_ );
+//}
+
+//! Builds an object, based on the input parameters
+template <class T, class Arg> 
+T*
+TeFactory<T,Arg>::make ( string name, const Arg& arg )
+{
+	// try to find the name on the factory dictionary
+	typename TeFactoryMap::iterator i = TeFactory<T,Arg>::instance().find ( name );
+
+	// Not found ?  return the Default Object   
+	if ( i == TeFactory<T,Arg>::instance().end() )
+		return T::DefaultObject( arg );
+
+	// Create an object, based on the input parameters
+	return (*i).second->build ( arg );
+	return 0;
+
+}
+
+//! Builds an object, based on the input parameters
+template <class T, class Arg> 
+T*
+TeFactory<T,Arg>::make (const Arg& arg )
+{
+	string name = arg.decName();
+
+	// try to find the name on the factory dictionary
+	typename TeFactoryMap::iterator i = TeFactory<T,Arg>::instance().find ( name );
+
+	// Not found ?  return the Default Object   
+	if ( i == TeFactory<T,Arg>::instance().end() )
+		return T::DefaultObject( arg );
+
+	// Create an object, based on the input parameters
+	return (*i).second->build ( arg );
+	return 0;
+
+}
+#endif
+
diff --git a/src/terralib/kernel/TeFragmentation.cpp b/src/terralib/kernel/TeFragmentation.cpp
new file mode 100644
index 0000000..d56f26a
--- /dev/null
+++ b/src/terralib/kernel/TeFragmentation.cpp
@@ -0,0 +1,666 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeFragmentation.h"
+#include "TeGeometryAlgorithms.h"
+#include <algorithm>
+
+using namespace std;
+
+// estrutura auxiliar para implementar o funtor de ordenacao do algoritmo sort da STL:
+// os pontos de intersecao de um segmento de uma dada linha eh agrupado usando esse funtor.
+struct ipRedOrder	// XY order
+{
+	bool operator()(const TeINTERSECTOR2::TeBoundaryIP& ip1, const TeINTERSECTOR2::TeBoundaryIP& ip2) const
+	{
+		if(ip1.redPartNum_ < ip2.redPartNum_)
+			return true;
+
+		if(ip1.redPartNum_ > ip2.redPartNum_)
+			return false;
+
+		if(ip1.redSegNum_ < ip2.redSegNum_)
+			return true;
+
+		if(ip1.redSegNum_ > ip2.redSegNum_)
+			return false;
+
+		return false;
+	}
+};
+
+// estrutura auxiliar para implementar o funtor de ordenacao do algoritmo sort da STL:
+// os pontos de intersecao de um segmento de uma dada linha eh agrupado usando esse funtor.
+struct ipRedOrder2	// XY order
+{
+	bool operator()(const TeINTERSECTOR2::TeBoundaryIP& ip1, const TeINTERSECTOR2::TeBoundaryIP& ip2) const
+	{
+		if(ip1.redPolNum_ < ip2.redPolNum_)
+			return true;
+
+		if(ip1.redPolNum_ > ip2.redPolNum_)
+			return false;
+
+		if(ip1.redPartNum_ < ip2.redPartNum_)
+			return true;
+
+		if(ip1.redPartNum_ > ip2.redPartNum_)
+			return false;
+
+		if(ip1.redSegNum_ < ip2.redSegNum_)
+			return true;
+
+		if(ip1.redSegNum_ > ip2.redSegNum_)
+			return false;
+
+		if(ip1.coords_[0].x_ < ip2.coords_[0].x_)
+			return true;
+
+		if(ip1.coords_[0].x_ > ip2.coords_[0].x_)
+			return false;
+
+		if(ip1.coords_[0].y_ < ip2.coords_[0].y_)
+			return true;
+
+		if(ip1.coords_[0].y_ > ip2.coords_[0].y_)
+			return false;
+		
+		if(ip1.coords_.size() < ip2.coords_.size())
+			return true;
+
+		if(ip1.coords_.size() > ip2.coords_.size())
+			return false;
+
+		if((ip1.coords_.size() == 2) && (ip2.coords_.size() == 2))
+		{
+			if(ip1.coords_[1].x_ < ip2.coords_[1].x_)
+				return true;
+
+			if(ip1.coords_[1].x_ > ip2.coords_[1].x_)
+				return false;
+
+			if(ip1.coords_[1].y_ < ip2.coords_[1].y_)
+				return true;
+
+			if(ip1.coords_[1].y_ > ip2.coords_[1].y_)
+				return false;
+		}
+
+		return false;
+	}
+};
+
+// estrutura auxiliar para colocar os pontos de intersecao ao longo de um segment ordenados,
+// de modo a facilitar a fragmentacao do segmento.
+struct TeIPAux
+{
+	double x_;
+	double y_;
+	int type_;	//0 - Unico; 1 - Inicial de Overlap; 2 - Final de Overlap
+
+	TeIPAux(const double& x, const double& y, const int& t)
+		: x_(x), y_(y), type_(t)
+	{
+	}
+};
+
+// estrutura auxiliar para implementar o funtor de ordenacao do algoritmo sort da STL:
+// os pontos de intersecao de um segmento de uma dada linha serao ordenados por esse funtor.
+struct sortDist
+{
+	TeCoord2D c_;	// cordenada de referencia
+
+	sortDist(const TeCoord2D& c)
+		: c_(c)
+	{
+	}
+
+	bool operator()(const TeIPAux& ip1, const TeIPAux& ip2) const
+	{
+		double dist1 = ((ip1.x_ - c_.x_) * (ip1.x_ - c_.x_)) + ((ip1.y_ - c_.y_) * (ip1.y_ - c_.y_));
+		double dist2 = ((ip2.x_ - c_.x_) * (ip2.x_ - c_.x_)) + ((ip2.y_ - c_.y_) * (ip2.y_ - c_.y_));
+		if(dist1 < dist2)
+			return true;
+		return false;
+	}
+};
+
+
+// mario + gribeiro - 2006-03
+// remove pontos de intersecao com a mesma localizacao que foram reportados por segmentos diferentes,
+// deixandoo vetor "ips" na sequencia correta para uso da etapa de fragmentacao do segmento.
+// Essa rotin pode lancar uma excessao em um caso muito especial: um ponto final de overlap veio ante do ponto inicial de overlap.
+inline void cleanIntersections(TeINTERSECTOR2::TeVectorBoundaryIP& ips, const TeCoord2D& refCoord)
+{
+	vector<TeIPAux> vecips;
+	for(unsigned int i = 0; i < ips.size(); ++i)
+	{
+		if(ips[i].coords_.size() == 2)
+		{
+			double dist1 = ((ips[i].coords_[0].x_ - refCoord.x_) * (ips[i].coords_[0].x_ - refCoord.x_)) + ((ips[i].coords_[0].y_ - refCoord.y_) * (ips[i].coords_[0].y_ - refCoord.y_));
+			double dist2 = ((ips[i].coords_[1].x_ - refCoord.x_) * (ips[i].coords_[1].x_ - refCoord.x_)) + ((ips[i].coords_[1].y_ - refCoord.y_) * (ips[i].coords_[1].y_ - refCoord.y_)); 
+
+			if(dist1 < dist2)
+			{
+				TeIPAux ip1(ips[i].coords_[0].x_, ips[i].coords_[0].y_, 1);
+				TeIPAux ip2(ips[i].coords_[1].x_, ips[i].coords_[1].y_, 2);
+				vecips.push_back(ip1);
+				vecips.push_back(ip2);
+			}
+			else
+			{
+				TeIPAux ip1(ips[i].coords_[0].x_, ips[i].coords_[0].y_, 2);
+				TeIPAux ip2(ips[i].coords_[1].x_, ips[i].coords_[1].y_, 1);
+				vecips.push_back(ip1);
+				vecips.push_back(ip2);
+			}			
+		}
+		else
+		{
+			TeIPAux ip(ips[i].coords_[0].x_, ips[i].coords_[0].y_, 0);
+			vecips.push_back(ip);
+		}
+	}
+
+	sort(vecips.begin(), vecips.end(), sortDist(refCoord));
+
+    TeINTERSECTOR2::TeVectorBoundaryIP newips;
+
+	int cont = 0;
+
+	TeLine2D l;
+	TeLineSet lset;
+
+	for(unsigned int i = 0; i < vecips.size(); ++i)
+	{
+		TeCoord2D c(vecips[i].x_, vecips[i].y_);
+
+		if(vecips[i].type_ == 0)
+		{
+			if(l.size() > 0)
+			{
+				if(TeEquals(c, l[l.size() - 1]))
+				{
+					continue;
+				}
+				else if(cont == 0)
+				{
+					lset.add(l);
+					l = TeLine2D();
+					l.add(c);
+				}
+				else
+				{
+					l.add(c);
+				}
+			}
+			else
+			{				
+				l.add(c);
+			}
+		}
+		else if(vecips[i].type_ == 1)
+		{
+			if(l.size() > 0)
+			{
+				if(TeEquals(c, l[l.size() - 1]))
+				{
+					++cont;
+					continue;
+				}
+				else if(cont == 0)
+				{
+					lset.add(l);
+					l = TeLine2D();
+					l.add(c);
+				}
+				else
+				{
+					l.add(c);
+				}
+			}
+			else
+			{
+				l.add(c);
+			}
+
+			++cont;
+		}
+		else //else if(vecips[i].type == 2)
+		{
+			if(l.size() > 0)
+			{
+				if(TeEquals(c, l[l.size() - 1]))
+				{
+					--cont;
+					continue;
+				}
+				else if(cont == 0)
+				{
+					throw string("An overlap end point started before an overlap begin!");		// nao podia ter chegado ate aqui
+				}
+				else
+				{
+					l.add(c);
+				}
+			}
+			else
+			{
+				l.add(c);
+			}
+
+			--cont;
+		}
+	}
+
+	if(l.size() > 0)
+	{
+		lset.add(l);
+	}
+
+	for(unsigned int i = 0; i < lset.size(); ++i)
+	{
+		if(lset[i].size() == 1)
+		{
+			TeINTERSECTOR2::TeBoundaryIP newIp;
+			newIp.coords_.push_back(lset[i][0]);
+			newips.push_back(newIp);
+		}
+		else
+		{
+			for(unsigned int j = 1; j < lset[i].size(); ++j)
+			{
+				TeINTERSECTOR2::TeBoundaryIP newIp;
+				newIp.coords_.push_back(lset[i][j-1]);
+				newIp.coords_.push_back(lset[i][j]);
+				
+				newips.push_back(newIp);
+			}
+		}
+	}
+
+	ips.clear();
+	ips = newips;
+}
+
+// rotina que fragmenta uma aresta se necessario: aplica-se no caso de segmentos que nao fazem overlap
+inline void TeFragmentSegmentByNonOverlapping(const TeCoord2D& s1, const TeCoord2D& /* s2 */,
+									   TeINTERSECTOR2::TeVectorBoundaryIP& ips, 
+									   TeLine2D& currentFragment,
+									   TeLineSet& fragments)
+{
+// vamos deixar os pontos de intersecao numa sequencoa adequada para fragmentarmos este segmento
+	cleanIntersections(ips, s1);
+
+
+// eh so fragmentar o segmento ateh o ultimo ponto de interseccao dele
+	for(unsigned int k = 0; k < ips.size(); ++k)
+	{
+		if(TeEquals(ips[k].coords_[0], currentFragment[currentFragment.size() - 1]))	// Se o ponto de interseccao esta sobre o vehrtice do segmento
+		{
+			// fragmenta a linha caso haja mais de um ponto nela
+			if(currentFragment.size() > 1)								
+			{
+				fragments.add(currentFragment);
+
+				currentFragment = TeLine2D();
+				currentFragment.add(ips[k].coords_[0]);
+			}
+			else
+			{
+				continue;
+			}
+		}
+		else
+		{
+			currentFragment.add(ips[k].coords_[0]);
+
+			fragments.add(currentFragment);
+
+			currentFragment = TeLine2D();
+			currentFragment.add(ips[k].coords_[0]);
+		}
+	}
+}
+
+// fragmenta uma aresta que possui pontos de intersecao de overlap
+inline void TeFragmentSegmentByOverlapping(const TeCoord2D& s1, const TeCoord2D& /* s2 */,
+									   TeINTERSECTOR2::TeVectorBoundaryIP& ips,
+									   TeLine2D& currentFragment,
+									   TeLineSet& fragments, TeLineSet& boundaryFragments)
+{
+// vamos deixar os pontos de intersecao numa sequencoa adequada para fragmentarmos este segmento
+	cleanIntersections(ips, s1);
+
+	unsigned int i = 0;
+	
+// eh so fragmentar o segmento ateh o ultimo ponto de interseccao dele
+	for(i = 0; i < ips.size(); ++i)
+	{
+		if(TeEquals(ips[i].coords_[0], currentFragment[currentFragment.size() - 1]))	// Se o ponto de interseccao esta sobre o vehrtice do segmento
+		{
+			// fragmenta a linha caso haja mais de um ponto nela
+			if(currentFragment.size() > 1)
+			{
+				fragments.add(currentFragment);
+
+				currentFragment = TeLine2D();
+
+				if(ips[i].coords_.size() == 2)
+				{
+					TeLine2D l;
+					l.add(ips[i].coords_[0]);
+					l.add(ips[i].coords_[1]);
+					
+					boundaryFragments.add(l);
+
+					currentFragment.add(ips[i].coords_[1]);
+				}
+				else
+				{
+					currentFragment.add(ips[i].coords_[0]);
+				}
+			}
+			else
+			{
+				if(ips[i].coords_.size() == 2)
+				{
+					TeLine2D l;
+					l.add(ips[i].coords_[0]);
+					l.add(ips[i].coords_[1]);
+					
+					boundaryFragments.add(l);
+
+					currentFragment.clear();
+					currentFragment.add(ips[i].coords_[1]);
+				}
+			}
+		}
+		else
+		{
+
+			currentFragment.add(ips[i].coords_[0]);
+
+			if(ips[i].coords_.size() == 2)
+			{
+				fragments.add(currentFragment);
+
+				currentFragment = TeLine2D();
+				
+				currentFragment.add(ips[i].coords_[1]);
+
+				TeLine2D l;
+				l.add(ips[i].coords_[0]);
+				l.add(ips[i].coords_[1]);
+				
+				boundaryFragments.add(l);
+			}
+			else
+			{
+				fragments.add(currentFragment);
+
+				currentFragment = TeLine2D();
+				
+				currentFragment.add(ips[i].coords_[0]);
+			}			
+		}
+	}
+}
+
+// Adiciona o ponto de intersecao ao fragmento corrente, decidindo entre um ponto de intersecao e o ponto original
+void TeAddPoint(TeLine2D& lFrag, TeLine2D& currentLine, TeINTERSECTOR2::TeVectorBoundaryIP& ipsAux, const unsigned int& j)
+{
+	bool found = false;
+
+	for(unsigned int i = 0; i < ipsAux.size(); ++i)
+	{
+		if(TeEquals(ipsAux[i].coords_[0], currentLine[j]))
+		{
+			lFrag.add(ipsAux[i].coords_[0]);
+			found = true;
+			break;
+		}
+		else if(ipsAux[i].coords_.size() == 2)
+		{
+			if(TeEquals(ipsAux[i].coords_[1], currentLine[j]))
+			{
+				lFrag.add(ipsAux[i].coords_[1]);
+				found = true;
+				break;
+			}			
+		}
+	}
+
+	if(!found)
+		lFrag.add(currentLine[j]);
+}
+
+// rotina principal de fragmentacao de linhas
+void TeFragmentBoundary(const TeLineSet& lines, TeINTERSECTOR2::TeVectorBoundaryIP& ips, TeLineSet& boundaryFragments, TeLineSet& fragments)
+{
+// informacoes sobre os pontos de intersecao
+	unsigned int currentIP = 0;
+	unsigned int nthIP = ips.size();
+
+	// Informacoes sobre numero de linhas
+	unsigned int nthLine = lines.size();
+
+	// Ordena os pontos de intersecao
+	sort(ips.begin(), ips.end(), ipRedOrder());
+
+	for(unsigned int i = 0; i < nthLine; ++i)
+	{
+		if((currentIP < nthIP) && (ips[currentIP].redPartNum_ == i))	
+		{
+			// Se a linha corrente possui um ponto de intersecao entao ela devera ser fragmentada
+			TeLine2D& currentLine = lines[i];
+			
+			TeLine2D lFrag;
+
+			//unsigned int currentSegment = 0;
+			unsigned int nthSegment = currentLine.size() - 1;
+
+			for(unsigned int j = 0; j < nthSegment; ++j)
+			{
+				if((currentIP < nthIP) && (j == ips[currentIP].redSegNum_) && (ips[currentIP].redPartNum_ == i))	// Se ainda tenho pontos de interseccao e 
+				{															// o corrente pertence ao segmento atual
+					// Copias todos os pontos de interseccao do segmento para
+					// um vetor auxiliar e ja avanca o currentIP
+					TeINTERSECTOR2::TeVectorBoundaryIP ipsAux;
+
+					bool hasOverlap = false;
+
+					while((currentIP < nthIP) && (ips[currentIP].redSegNum_ == j) && (ips[currentIP].redPartNum_ == i))
+					{
+						if(ips[currentIP].coords_.size() == 2)
+							hasOverlap = true;
+
+						ipsAux.push_back(ips[currentIP]);
+
+						++currentIP;
+					}
+
+					// Adiciona o primeiro ponto da linha na lista do fragmento atual: mas precisamos decidir entre o vertice original ou o de intersecao => preferimos o de intersecao para amarrar com o segmento que intercepta este segmento
+					if((lFrag.size() == 0) || TeDisjoint(currentLine[j], lFrag[lFrag.size() - 1]))
+							TeAddPoint(lFrag, currentLine, ipsAux, j);
+
+					if(hasOverlap)	// Se houverem pontos de interseccao que fazem overlap
+					{						
+						TeFragmentSegmentByOverlapping(currentLine[j], currentLine[j + 1], ipsAux, lFrag, fragments, boundaryFragments);
+					}
+					else	// Se nao houver pontos de interseccao que fazem overlap
+					{
+						TeFragmentSegmentByNonOverlapping(currentLine[j], currentLine[j + 1], ipsAux, lFrag, fragments);
+					}
+				}
+				else
+				{
+					// Caso nao haja ponto de interseccao sobre o segmento,
+					// apenas insere o ponto no fragmento de linha
+					lFrag.add(currentLine[j]);
+				}
+			}
+			
+			if(lFrag.size() > 0)
+			{
+				if(TeDisjoint(currentLine[nthSegment], lFrag[lFrag.size() - 1]))
+				{
+					lFrag.add(currentLine[nthSegment]);
+
+					fragments.add(lFrag);
+				}
+				else if(lFrag.size() > 1)
+				{
+					fragments.add(lFrag);
+				}
+			}
+		}
+		else
+		{
+			// Caso contrario, se a linha nao possui ponto de intersecao
+			// eh so colocar ela na lista de linhas fragmentadas
+			fragments.add(lines[i]);
+		}
+	}
+	
+	return;
+}
+
+// rotina principal de fragmentacao de poligonos
+void TeFragmentBoundary(const TePolygonSet& polygons, TeINTERSECTOR2::TeVectorBoundaryIP& ips, TeLineSet& boundaryFragments, vector<pair<unsigned int, unsigned int> >& boundaryFragmentsIds, TeLineSet& fragments, vector<pair<unsigned int, unsigned int> >& fragmentsIds)
+{
+	// Informacoes sobre os pontos de intersecao
+	unsigned int currentIP = 0;
+	unsigned int nthIP = ips.size();	
+
+	// Ordena os pontos de intersecao
+	sort(ips.begin(), ips.end(), ipRedOrder2());
+
+	// Informacoes sobre numero de poligonos
+	unsigned int nthPol = polygons.size();
+
+	for(unsigned int polyIndex = 0; polyIndex < nthPol; ++polyIndex)
+	{
+		unsigned int nthLine = polygons[polyIndex].size();
+
+		for(unsigned int ringIndex = 0; ringIndex < nthLine; ++ringIndex)
+		{
+// temos intersecao no anel?
+            if((currentIP < nthIP) && (ips[currentIP].redPartNum_ == ringIndex) && (ips[currentIP].redPolNum_ == polyIndex))	
+			{
+				// Se a linha corrente possui um ponto de intersecao entao ela devera ser fragmentada
+				TeLine2D& currentLine = polygons[polyIndex][ringIndex];
+				
+				TeLine2D lFrag;
+
+				//unsigned int currentSegment = 0;
+				unsigned int nthSegment = currentLine.size() - 1;
+
+				TeCoord2D first(0,0);
+
+				for(unsigned int j = 0; j < nthSegment; ++j)
+				{
+// temos intersecao sobre o segmento corrente?
+					if((currentIP < nthIP) && (j == ips[currentIP].redSegNum_) && (ips[currentIP].redPartNum_ == ringIndex) && (ips[currentIP].redPolNum_ == polyIndex))	// Se ainda tenho pontos de interseccao e 
+					{
+						// Copias todos os pontos de interseccao do segmento para
+						// um vetor auxiliar e ja avanca o currentIP
+						TeINTERSECTOR2::TeVectorBoundaryIP ipsAux;
+
+						bool hasOverlap = false;
+
+						while((currentIP < nthIP) && (ips[currentIP].redSegNum_ == j) && (ips[currentIP].redPartNum_ == ringIndex) && (ips[currentIP].redPolNum_ == polyIndex))
+						{
+							if(ips[currentIP].coords_.size() == 2)
+								hasOverlap = true;
+
+							ipsAux.push_back(ips[currentIP]);
+
+							++currentIP;
+						}
+
+						// Adiciona o primeiro ponto da linha na lista do fragmento atual: mas precisamos decidir entre o vertice original ou o de intersecao => preferimos o de intersecao para amarrar com o segmento que intercepta este segmento
+						if((lFrag.size() == 0) || TeDisjoint(currentLine[j], lFrag[lFrag.size() - 1]))
+							TeAddPoint(lFrag, currentLine, ipsAux, j);
+
+						if(hasOverlap)	// Se houverem pontos de interseccao que fazem overlap
+						{						
+							TeFragmentSegmentByOverlapping(currentLine[j], currentLine[j + 1], ipsAux, lFrag, fragments, boundaryFragments);
+						}
+						else	// Se nao houver pontos de interseccao que fazem overlap
+						{
+							TeFragmentSegmentByNonOverlapping(currentLine[j], currentLine[j + 1], ipsAux, lFrag, fragments);
+						}
+					}
+					else
+					{
+						// Caso nao haja ponto de interseccao sobre o segmento,
+						// apenas insere o ponto no fragmento de linha
+						lFrag.add(currentLine[j]);
+					}
+				}
+				
+				if(lFrag.size() > 0)
+				{
+					if(TeDisjoint(currentLine[0], lFrag[lFrag.size() - 1]))
+					{
+						lFrag.add(currentLine[0]);
+
+						fragments.add(lFrag);
+					}
+					else if(lFrag.size() > 1)
+					{
+						fragments.add(lFrag);
+					}
+				}
+			}
+			else
+			{
+				// Caso contrario, se a linha nao possui ponto de intersecao
+				// e so colocar ela na lista de linhas fragmentadas
+				fragments.add(polygons[polyIndex][ringIndex]);
+			}
+
+			unsigned int numFragmentos = fragments.size();
+
+			for(unsigned int fragIdxCount = fragmentsIds.size(); fragIdxCount < numFragmentos; ++fragIdxCount)
+				fragmentsIds.push_back(pair<unsigned int, unsigned int>(polyIndex, ringIndex));
+
+
+//mario - 2006-03
+			unsigned int numFragmentosFronteira = boundaryFragments.size();
+
+			for(unsigned int fragIdxCount = boundaryFragmentsIds.size(); fragIdxCount < numFragmentosFronteira; ++fragIdxCount)
+			{
+				boundaryFragmentsIds.push_back(pair<unsigned int, unsigned int>(polyIndex, ringIndex));
+			}
+		}
+	}
+	
+	return;
+}
+
diff --git a/src/terralib/kernel/TeFragmentation.h b/src/terralib/kernel/TeFragmentation.h
new file mode 100644
index 0000000..8228dae
--- /dev/null
+++ b/src/terralib/kernel/TeFragmentation.h
@@ -0,0 +1,61 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeFragmentation.h
+    \brief This file contains Algorithms for Topological Operations.
+	       These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone because
+           THIS IS FOR INTERNAL USE ONLY.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_FRAGMENTATION_H
+#define  __TERRALIB_INTERNAL_FRAGMENTATION_H
+
+#include "TeGeometry.h"
+#include "TeIntersector.h"
+
+/** @defgroup FragmentAlgorithms Algorithms that performs fragmentation of lines
+	@ingroup GeometryAlgorithms
+    THIS IS FOR INTERNAL USE ONLY: TerraLib fragmentation algorithms. 
+ *  @{
+ */
+/** \brief Fragments the lines according intersection points (May rise an exception: you must use try and catch).
+	\param lines			  The lines to fragment.
+	\param ips			      The intersection points where the boundary will be fragmented.
+	\param boundaryFragments  Output list of segments in the boundary of another line.
+	\param fragments		  Output list of line fragmemts.
+*/
+TL_DLL void TeFragmentBoundary(const TeLineSet& lines, TeINTERSECTOR2::TeVectorBoundaryIP& ips, TeLineSet& boundaryFragments, TeLineSet& fragments);
+
+/**  Fragments the lines according intersection points (May rise an exception: you must use try and catch).	
+	\param polygons              List of polygons (lines to be fragmented).
+	\param ips				     Intersection points where the boundary will be fragmented.
+	\param boundaryFragments     Output list of segments in the boundary of another line.
+	\param boundaryFragmentsIds  Output list with the objects identifiers for each fragment (to be used by location, to decide in/out fragments).
+	\param fragments		     Output list of line fragmemts.
+	\param fragmentsIds		     Output list with the objects identifiers for each fragment (to be used by location, to decide in/out fragments).
+*/
+TL_DLL void TeFragmentBoundary(const TePolygonSet& polygons, TeINTERSECTOR2::TeVectorBoundaryIP& ips, 
+						TeLineSet& boundaryFragments, vector<pair<unsigned int, unsigned int> >& boundaryFragmentsIds, TeLineSet& fragments, vector<pair<unsigned int, unsigned int> >& fragmentsIds);
+
+/** @} */ // end of group  FragmentAlgorithms
+
+#endif	// __TERRALIB_INTERNAL_FRAGMENTATION_H
diff --git a/src/terralib/kernel/TeGTFactory.cpp b/src/terralib/kernel/TeGTFactory.cpp
new file mode 100644
index 0000000..d5e02e1
--- /dev/null
+++ b/src/terralib/kernel/TeGTFactory.cpp
@@ -0,0 +1,32 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/ 
+#include "TeGTFactory.h"
+
+TeGTFactory::TeGTFactory( const std::string& factoryName )
+: TeFactory< TeGeometricTransformation, TeGTParams >( factoryName )
+{
+};      
+
+TeGTFactory::~TeGTFactory()
+{
+};
diff --git a/src/terralib/kernel/TeGTFactory.h b/src/terralib/kernel/TeGTFactory.h
new file mode 100644
index 0000000..3d7e511
--- /dev/null
+++ b/src/terralib/kernel/TeGTFactory.h
@@ -0,0 +1,78 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeGTFactory.h
+    \brief This file supports the implementation of Geometric transformation factories.
+	\author Emiliano Ferreira Castejon <castejon at dpi.inpe.br>
+*/
+/**
+ * @defgroup TeGTFactories Geometric transformation factories.
+ * @ingroup Utils
+ */  
+
+#include "TeDefines.h"
+
+#ifndef TEGTFACTORIES_REGISTERED
+  #define TEGTFACTORIES_REGISTERED
+
+  #include "TeAffineGTFactory.h"
+  #include "TeProjectiveGTFactory.h"
+#endif 
+
+#ifndef TEGTFACTORY_H
+  #define TEGTFACTORY_H
+
+  #include "TeGeometricTransformation.h"
+  #include "TeGTParams.h"
+  #include "TeFactory.h"
+  
+  #include <string>
+  
+  /**
+   * @brief This is the class for geometric transformations factory.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup TeGTFactories
+   */
+  class TL_DLL TeGTFactory : 
+    public TeFactory< TeGeometricTransformation, TeGTParams >
+  {
+    public :
+      
+      /**
+       * Default Destructor
+       */
+      virtual ~TeGTFactory();
+      
+    protected :
+      
+      /**
+       * Default constructor
+       *
+       * @param factoryName Factory name.
+       */
+      TeGTFactory( const std::string& factoryName );
+  };
+  
+#endif
+
+
+
diff --git a/src/terralib/kernel/TeGTParams.cpp b/src/terralib/kernel/TeGTParams.cpp
new file mode 100644
index 0000000..393385f
--- /dev/null
+++ b/src/terralib/kernel/TeGTParams.cpp
@@ -0,0 +1,86 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeGTParams.h"
+
+#include <float.h>
+
+TeGTParams::TeGTParams()
+{
+  reset();  
+}
+
+
+TeGTParams::TeGTParams( const TeGTParams& external )
+{
+  operator=( external );
+}
+
+
+TeGTParams::~TeGTParams()
+{
+  reset();
+}
+
+
+const TeGTParams& TeGTParams::operator=( 
+  const TeGTParams& external )
+{
+  transformation_name_ = external.transformation_name_;
+  out_rem_strat_ = external.out_rem_strat_;
+  max_dmap_error_ = external.max_dmap_error_;
+  max_imap_error_ = external.max_imap_error_;
+  tiepoints_ = external.tiepoints_;
+  direct_parameters_ = external.direct_parameters_;
+  inverse_parameters_ = external.inverse_parameters_;
+  maxIters_          = external.maxIters_;
+  tolerance_         = external.tolerance_;
+  useAdaptiveParams_ = external.useAdaptiveParams_;  
+  WMatrix_ = external.WMatrix_;
+  
+  return external;
+}
+
+
+std::string TeGTParams::decName() const
+{
+  return transformation_name_;
+}
+
+
+void TeGTParams::reset()
+{
+  transformation_name_ = "affine";
+  out_rem_strat_ = NoOutRemotion;
+  max_dmap_error_ = DBL_MAX;
+  max_imap_error_ = DBL_MAX;
+  maxIters_  = 20;
+  tolerance_ = 0.0001;
+  useAdaptiveParams_ = false; 
+  
+  direct_parameters_.Clear();
+  inverse_parameters_.Clear();
+  tiepoints_.clear();
+  WMatrix_.Clear();
+}
+
diff --git a/src/terralib/kernel/TeGTParams.h b/src/terralib/kernel/TeGTParams.h
new file mode 100644
index 0000000..ef7485e
--- /dev/null
+++ b/src/terralib/kernel/TeGTParams.h
@@ -0,0 +1,186 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeGTParams.h
+    \brief This file contains the definition of parameters necessary to build a    TeGeometricTransformation instance.
+*/
+
+#include "TeDefines.h"
+
+#ifndef TEGTPARAMS_H
+  #define TEGTPARAMS_H
+  
+  #include "TeMatrix.h"
+  #include "TeCoord2D.h"
+  #include "TeSharedPtr.h"
+
+  #include <string>
+
+  /**
+   * @brief This is the class for geometric transformation parameters .
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  class TL_DLL TeGTParams
+  {
+    public :
+    
+      /** 
+       * @typedef TeSharedPtr< TeGTParams > pointer
+       * Type definition for a TeGTParams instance pointer. 
+       */
+      typedef TeSharedPtr< TeGTParams > pointer;    
+      
+      /**
+       * @enum OutRemStrategy
+       * Outliers remotion strategy.
+       */ 
+      enum OutRemStrategy {
+        /**
+         * @brief No outliers remotion applied.
+         */
+        NoOutRemotion,
+        /**
+         * @brief Exaustive outliers remotion (all
+         * possible tie-points combinations will be
+         * tested.
+         */
+        ExaustiveOutRemotion,
+        /**
+         * @brief LOA (leave-worse-out) will
+         * be performed.
+         */
+        LWAOutRemotion
+      };      
+    
+      /**
+       * @brief Transformation name.
+       *
+       * @note Default value = affine.
+       */
+      std::string transformation_name_;
+      
+      /** 
+       * @brief The outliers remotion strategy.  
+       *
+       * @note Default value = NoOutRemotion.    
+       */
+      OutRemStrategy out_rem_strat_;
+      
+      /**
+       * @brief The maximum allowed direct mapping error.
+       *
+       * @note Default value = Positive infinite.    
+       */         
+      double max_dmap_error_;
+      
+      /**
+       * @brief The maximum allowed inverse mapping error.
+       *
+       * @note Default value = Positive infinite.    
+       */         
+      double max_imap_error_;      
+    
+      /**
+       * @brief The current direct mapping transformation parameters.
+       * @note Default value = An empty matrix.    
+       */    
+      TeMatrix direct_parameters_;
+      
+      /**
+       * @brief The current inverse mapping transformation parameters.
+       * @note Default value = An empty matrix.    
+       */    
+      TeMatrix inverse_parameters_;      
+
+      /**
+       * @brief The current transformation tie-points.
+       * @note Default value = An empty vector.    
+       */    
+      std::vector< TeCoordPair > tiepoints_;       
+      
+      /**
+       * @brief The weight matrix used by least square method.
+       *
+       * @note Default value = empty matrix.
+       */         
+      TeMatrix WMatrix_;
+      
+      /**
+       * @brief The maximun number of iterations while processing.
+       *
+       * @note Default value = 20.
+       */         
+      unsigned int maxIters_;
+      
+      /**
+       * @brief The tolerance used while executing an iterative processing.
+       *
+       * @note Default value = 0.0001.
+       */         
+      double tolerance_;
+      
+      /**
+       * @brief Indicates whether use adaptive parameters or not.
+       *
+       * @note Default value = false.
+       */         
+      bool useAdaptiveParams_;      
+
+      /**
+       * @brief Default constructor
+       */
+      TeGTParams();
+      
+      /**
+       * @brief Alternative constructor
+       * @param external External reference.
+       */
+      TeGTParams( const TeGTParams& external );      
+      
+      /**
+       * @brief Default Destructor
+       */
+      ~TeGTParams();
+      
+      /**
+       * @brief operator= implementation.
+       *
+       * @param external External reference.
+       * @return A const reference to the external object instance.
+       */
+      const TeGTParams& operator=( 
+        const TeGTParams& external );      
+
+      /**
+       * @brief This is for TeFactory compatibility.
+       */
+      std::string decName() const;
+      
+      /**
+       * @brief Reset to the default parameters.
+       */
+      void reset();      
+            
+  };
+
+#endif
diff --git a/src/terralib/kernel/TeGeometricTransformation.cpp b/src/terralib/kernel/TeGeometricTransformation.cpp
new file mode 100644
index 0000000..1eb4316
--- /dev/null
+++ b/src/terralib/kernel/TeGeometricTransformation.cpp
@@ -0,0 +1,637 @@
+/*
+TerraLib - a library for developing GIS applications.
+Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular
+purpose. The library provided hereunder is on an "as is" basis, and the
+authors have no obligation to provide maintenance, support, updates,
+enhancements, or modifications.
+In no event shall INPE be held liable to any party
+for direct, indirect, special, incidental, or consequential damages arising
+out of the use of this library and its documentation.
+*/
+
+#include "TeGeometricTransformation.h"
+
+#include <TeAgnostic.h>
+
+#include <math.h>
+#include <float.h>
+
+#include <iostream>
+
+
+TeGeometricTransformation::TeGeometricTransformation()
+{
+}
+
+
+TeGeometricTransformation::~TeGeometricTransformation()
+{
+}
+
+
+void TeGeometricTransformation::getParameters( TeGTParams& params ) const
+{
+  params = internal_params_;
+}
+
+
+bool TeGeometricTransformation::reset( const TeGTParams& newparams )
+{
+  /* If previous calculated parameters were supplied, no need to do calcules */
+
+  if( ( newparams.direct_parameters_.Nrow() > 0 ) && 
+    ( newparams.direct_parameters_.Ncol() > 0 ) &&
+    ( newparams.inverse_parameters_.Nrow() > 0 ) &&
+    ( newparams.inverse_parameters_.Ncol() > 0 ) 
+    ) {
+    
+    internal_params_ = newparams;
+    return true;
+  } else {
+    /* No previous parameters given - Need to calculate the new transformation
+       parameters */
+       
+    TEAGN_TRUE_OR_THROW( ( newparams.max_dmap_error_ >= 0 ),
+      "Invalid maximum allowed direct mapping error" );
+    TEAGN_TRUE_OR_THROW( ( newparams.max_imap_error_ >= 0 ),
+      "Invalid maximum allowed inverse mapping error" );
+       
+    const unsigned int req_tie_pts_nmb = getMinRequiredTiePoints();
+
+    if( newparams.tiepoints_.size() < req_tie_pts_nmb ) {
+      return false;
+    } else {
+      internal_params_ = newparams;
+      
+      switch( newparams.out_rem_strat_ ) {
+        case TeGTParams::NoOutRemotion :
+        {
+          if( computeParameters( internal_params_ ) ) {
+            
+            if( ( newparams.max_dmap_error_ >= 
+              getDirectMappingError( internal_params_ ) ) &&
+              ( newparams.max_imap_error_ >= 
+              getInverseMappingError( internal_params_ ) ) ) {
+              
+              return true;
+            }
+          }   
+        
+          break;
+        }
+        case TeGTParams::ExaustiveOutRemotion :
+        {
+          if( exaustiveOutRemotion( internal_params_ ) ) {
+            return true;
+          }
+        
+          break;
+        }
+        case TeGTParams::LWAOutRemotion :
+        {
+          if( LWAOutRemotion( internal_params_ ) ) {
+            return true;
+          }
+                  
+          break;
+        }        
+        default : 
+        {
+          TEAGN_LOG_AND_THROW( 
+            "Invalid outliers remotion strategy" )
+          break;
+        }
+      
+      }
+    }
+  }
+  
+  internal_params_.reset();
+  
+  return false;
+}
+
+
+double TeGeometricTransformation::getDirectMappingError(  
+  const TeGTParams& params ) const
+{
+  unsigned int tiepoints_size = params.tiepoints_.size();
+  
+  TEAGN_DEBUG_CONDITION( ( tiepoints_size > 0 ),
+    "Invalid tie-points size" )
+  
+  double max_error = 0;
+  double current_error = 0;
+  
+  for( unsigned int tpindex = 0 ; tpindex < tiepoints_size ; ++tpindex ) {
+    current_error = getDirectMappingError( params.tiepoints_[ tpindex ], 
+      params );
+    
+    if( current_error > max_error ) {
+      max_error = current_error;
+    }
+  }
+  
+  return max_error;
+}
+
+
+double TeGeometricTransformation::getInverseMappingError(  
+  const TeGTParams& params ) const
+{
+  unsigned int tiepoints_size = params.tiepoints_.size();
+  
+  TEAGN_DEBUG_CONDITION( ( tiepoints_size > 0 ),
+    "Invalid tie-points size" )
+
+  
+  double max_error = 0;
+  double current_error = 0;
+  
+  for( unsigned int tpindex = 0 ; tpindex < tiepoints_size ; ++tpindex ) {
+    current_error = getInverseMappingError( params.tiepoints_[ tpindex ], 
+      params );
+    
+    if( current_error > max_error ) {
+      max_error = current_error;
+    }
+  }
+  
+  return max_error;
+}
+
+
+double TeGeometricTransformation::getDirectMappingError( 
+  const TeCoordPair& tie_point, const TeGTParams& params ) const
+{
+  TeCoord2D direct_mapped_point;
+
+  directMap( params, tie_point.pt1, direct_mapped_point );
+    
+  double diff_x = tie_point.pt2.x() - direct_mapped_point.x();
+  double diff_y = tie_point.pt2.y() - direct_mapped_point.y();
+    
+  return hypot( diff_x, diff_y );
+}
+
+
+double TeGeometricTransformation::getInverseMappingError( 
+  const TeCoordPair& tie_point, const TeGTParams& params ) const
+{
+  TeCoord2D inverse_mapped_point;
+
+  inverseMap( params, tie_point.pt2, inverse_mapped_point );
+    
+  double diff_x = tie_point.pt1.x() - inverse_mapped_point.x();
+  double diff_y = tie_point.pt1.y() - inverse_mapped_point.y();
+    
+  return hypot( diff_x, diff_y );
+}
+
+
+bool TeGeometricTransformation::recombineSeed( std::vector<unsigned int>& seed, 
+  const unsigned int& seedpos, const unsigned int& elements_nmb ) const
+{
+  unsigned int seed_size = seed.size();
+  
+  if( seedpos >= seed_size ) {
+    return false;
+  }
+
+  if( seed[ seedpos ]  >= ( elements_nmb - seed_size + seedpos + 1 ) ) {
+    if( seedpos == seed_size - 1 ) {
+      return false;
+    } else if( seedpos == 0 ) {
+      return recombineSeed( seed, seedpos + 1, elements_nmb ) ;
+    } else {
+      return recombineSeed( seed, seedpos + 1, elements_nmb ) ;
+    };
+  } else if( seed[ seedpos ]  == 0 ) {
+    if( seedpos == 0 ) {
+      seed[ seedpos ] = 1 ;
+      return recombineSeed( seed, seedpos + 1, elements_nmb );
+    } else if( seedpos == seed_size - 1 ) {
+      seed[ seedpos ] = seed[ seedpos - 1 ] + 1;
+      return true;
+    } else {
+      seed[ seedpos ] = seed[ seedpos - 1 ] + 1;
+      seed[ seedpos + 1 ] = 0;
+      return recombineSeed( seed, seedpos + 1, elements_nmb );
+    }
+  } else {
+    if( seedpos == seed_size - 1 ) {
+      seed[ seedpos ] = seed[ seedpos ] + 1;
+      return true;
+    } else if( seedpos == 0 ) {
+      if( recombineSeed( seed, seedpos + 1, elements_nmb ) ) {
+        return true;
+      } else {
+        seed[ seedpos ] = seed[ seedpos ] + 1;
+        seed[ seedpos + 1 ] = 0;
+        return recombineSeed( seed, seedpos + 1, elements_nmb );
+      }
+    } else {
+      if( recombineSeed( seed, seedpos + 1, elements_nmb ) ) {
+        return true;
+      } else {
+        seed[ seedpos ] = seed[ seedpos ] + 1;
+        seed[ seedpos + 1 ] = 0;
+        return recombineSeed( seed, seedpos + 1, elements_nmb );
+      }
+    }
+  }
+}
+
+
+TeGeometricTransformation* TeGeometricTransformation::DefaultObject( 
+  const TeGTParams& )
+{ 
+  throw TeException( UNKNOWN_ERROR_TYPE, 
+      "Trying to create an invalid TeGemetricTransformation instance" );
+  
+  return 0;
+}; 
+
+
+bool TeGeometricTransformation::exaustiveOutRemotion( 
+  TeGTParams& params )
+{
+  TEAGN_DEBUG_CONDITION( ( params.out_rem_strat_ == 
+    TeGTParams::ExaustiveOutRemotion ), 
+    "Inconsistent outliers remotion strategy" )
+    
+  const unsigned int req_tie_pts_nmb = getMinRequiredTiePoints();
+    
+  /* Initiating seed */
+  
+  std::vector<unsigned int> comb_seed_vec;
+  
+  for( unsigned int comb_seed_vec_index = 0 ; 
+    comb_seed_vec_index < req_tie_pts_nmb ;
+    ++comb_seed_vec_index ) {
+    
+    comb_seed_vec.push_back( 0 );
+  }
+  
+  /* Trying to find the best tie-points by building 
+    the transformation with the highest number of
+    tie-points, but with an acceptable mapping error */
+    
+  std::vector< TeCoordPair > best_tie_points;
+  
+  const unsigned int tiepoints_size = params.tiepoints_.size();
+  unsigned int tiepoints_index = 0;
+  bool point_already_present = false;
+  TeGTParams curr_params = params;
+  
+  while( recombineSeed( comb_seed_vec, 0, tiepoints_size ) ) {
+    /* Extracting tie-points from the original vector */
+    
+    curr_params.tiepoints_.clear();
+    
+    for( unsigned int comb_seed_vec_index_2 = 0 ; 
+      comb_seed_vec_index_2 < req_tie_pts_nmb ;
+      ++comb_seed_vec_index_2 ) {
+      
+      curr_params.tiepoints_.push_back( 
+        params.tiepoints_[ comb_seed_vec[ comb_seed_vec_index_2 ] - 
+        1 ] );
+    }
+    
+    /* Trying to generate a valid transformation */
+    
+    if( computeParameters( curr_params ) ) {
+    
+      if( ( params.max_dmap_error_ >= getDirectMappingError( 
+        curr_params ) ) &&
+        ( params.max_imap_error_ >= getInverseMappingError( 
+        curr_params ) ) ) {
+      
+        /* Trying to insert more tie-points into current 
+            transformation */
+        
+        for( tiepoints_index = 0 ; tiepoints_index < tiepoints_size ;
+          ++tiepoints_index ) {
+          
+          /* Verifying if the current tie-point is already present */
+          
+          point_already_present = false;
+          
+          for( unsigned int comb_seed_vec_index_3 = 0 ; 
+            comb_seed_vec_index_3 < req_tie_pts_nmb ;
+            ++comb_seed_vec_index_3 ) {
+          
+            if( tiepoints_index == ( 
+              comb_seed_vec[ comb_seed_vec_index_3 ] - 1 ) ) {
+            
+              point_already_present = true;
+              break;
+            }
+          }
+          
+          if( ! point_already_present ) {
+            curr_params.tiepoints_.push_back( 
+              params.tiepoints_[ tiepoints_index ] );
+            
+            /* Verifying if the new tie-point insertion does not generate 
+              an invalid transformation */
+            
+            if( computeParameters( curr_params ) ) {
+                
+              if( ( params.max_dmap_error_ < 
+                getDirectMappingError( curr_params ) ) ||
+                ( params.max_imap_error_ < 
+                getInverseMappingError( curr_params ) ) ) {
+                
+                curr_params.tiepoints_.pop_back();
+              }
+            } else {
+              curr_params.tiepoints_.pop_back();
+            }
+          }
+        }
+        
+        /* A valid transformation was generated, now verifying if the
+          number of tie-poits is greater then the current best 
+          transformation
+        */            
+        
+        if( curr_params.tiepoints_.size() > best_tie_points.size() ) {
+          best_tie_points = curr_params.tiepoints_;
+        }          
+      }
+    }
+  }
+  
+  if( best_tie_points.size() >= req_tie_pts_nmb ) {
+    curr_params.tiepoints_ = best_tie_points;
+  
+    if( computeParameters( curr_params ) ) {
+      if( ( params.max_dmap_error_ >= getDirectMappingError( 
+        curr_params ) ) &&
+        ( params.max_imap_error_ >= getInverseMappingError( 
+        curr_params ) ) ) {
+        
+        params = curr_params;
+        
+        return true;
+      }
+    }
+  }
+  
+  return false;      
+}
+
+
+bool TeGeometricTransformation::LWAOutRemotion( 
+  TeGTParams& params )
+{
+  TEAGN_DEBUG_CONDITION( ( params.out_rem_strat_ == 
+    TeGTParams::LWAOutRemotion ), 
+    "Inconsistent outliers remotion strategy" )
+    
+  const unsigned int req_tie_pts_nmb = getMinRequiredTiePoints();
+  
+  if( params.tiepoints_.size() == req_tie_pts_nmb ) {
+    return computeParameters( params );
+  } else if( params.tiepoints_.size() > req_tie_pts_nmb ) {
+  
+    /* Computing the initial global transformation */
+    
+    if( ! computeParameters( params ) ) {
+      return false;
+    }    
+    
+    if( ( getDirectMappingError( params ) <= 
+      params.max_dmap_error_ ) && 
+      ( getInverseMappingError( params ) <= 
+      params.max_imap_error_ ) ) {
+    
+      /* This transformation has no outliers */
+      
+      return true;
+    }
+    
+    /* Global vars */
+    
+    const double max_dmap_error = params.max_dmap_error_;
+    const double max_imap_error = params.max_imap_error_;
+      
+    TeGTParams params_aux = params;
+    
+    TeGTParams best_params;
+    double best_params_dmap_error = DBL_MAX;
+    double best_params_imap_error = DBL_MAX;
+    
+    unsigned int tpindex = 0;
+    unsigned int tpsize = 0;
+    double curr_dmap_error = 0;
+    double curr_imap_error = 0;
+    TeCoordPair* curr_tp_ptr = 0;
+    TeCoordPair* curr_canditate_tp_ptr = 0;
+    bool transformation_not_updated = false;
+    
+    /* vectors with direct and inverse mapping errors for
+       the current transformation */
+    std::vector< double > curr_trans_dmap_err_vec;
+    curr_trans_dmap_err_vec.reserve( params.tiepoints_.size() );
+    std::vector< double > curr_trans_imap_err_vec;
+    curr_trans_imap_err_vec.reserve( params.tiepoints_.size() );
+    
+    /* The min and max values from the vectors above */
+    
+    double curr_trans_dmap_err_vec_min = 0;
+    double curr_trans_dmap_err_vec_max = 0;
+    double curr_trans_dmap_err_vec_range = 0;
+    double curr_trans_imap_err_vec_min = 0;
+    double curr_trans_imap_err_vec_max = 0;
+    double curr_trans_imap_err_vec_range = 0;
+    
+    /* A map of tie-points pointers ordered by the mean of
+       normalized direct and inverse mapping errors */
+    std::map< double, TeCoordPair* > aux_tps_map;
+    
+    std::map< double, TeCoordPair* >::const_reverse_iterator 
+      aux_tps_map_it;
+    std::map< double, TeCoordPair* >::const_reverse_iterator 
+      aux_tps_map_it_end;      
+    
+    /* Iterating over the current transformation tie-points */
+  
+    while( params.tiepoints_.size() > req_tie_pts_nmb ) {
+      tpsize = params.tiepoints_.size();
+      transformation_not_updated = true;
+      
+      /* Calculating the two mapping errors vectors */
+      
+      curr_trans_dmap_err_vec_min = DBL_MAX;
+      curr_trans_dmap_err_vec_max = ( -1.0 ) * DBL_MAX;
+      curr_trans_imap_err_vec_min = DBL_MAX;
+      curr_trans_imap_err_vec_max = ( -1.0 ) * DBL_MAX;      
+      
+      for( tpindex = 0 ; tpindex < tpsize ; ++tpindex ) {
+        curr_trans_dmap_err_vec[ tpindex ] = 
+          getDirectMappingError( params.tiepoints_[ tpindex ], 
+          params );
+        if( curr_trans_dmap_err_vec_min > 
+          curr_trans_dmap_err_vec[ tpindex ] ) {
+          
+          curr_trans_dmap_err_vec_min = 
+            curr_trans_dmap_err_vec[ tpindex ];
+        }
+        if( curr_trans_dmap_err_vec_max <
+          curr_trans_dmap_err_vec[ tpindex ] ) {
+          
+          curr_trans_dmap_err_vec_max = 
+            curr_trans_dmap_err_vec[ tpindex ];
+        }        
+        
+        curr_trans_imap_err_vec[ tpindex ] = 
+          getInverseMappingError( params.tiepoints_[ tpindex ],
+          params );
+        if( curr_trans_imap_err_vec_min > 
+          curr_trans_imap_err_vec[ tpindex ] ) {
+          
+          curr_trans_imap_err_vec_min = 
+            curr_trans_imap_err_vec[ tpindex ];
+        }
+        if( curr_trans_imap_err_vec_max <
+          curr_trans_imap_err_vec[ tpindex ] ) {
+          
+          curr_trans_imap_err_vec_max = 
+            curr_trans_imap_err_vec[ tpindex ];
+        }            
+      }
+      
+      curr_trans_dmap_err_vec_range = curr_trans_dmap_err_vec_max -
+        curr_trans_dmap_err_vec_min;
+      if( curr_trans_dmap_err_vec_range == 0.0 ) {
+        curr_trans_dmap_err_vec_range = 1.0;
+      }
+              
+      curr_trans_imap_err_vec_range = curr_trans_imap_err_vec_max -
+        curr_trans_imap_err_vec_min;
+      if( curr_trans_imap_err_vec_range == 0 ) {
+        curr_trans_imap_err_vec_range = 1.0;
+      }        
+      
+      /* Creating a map with the current tie-points ordered
+         by the normalized mapping errors means */
+         
+      aux_tps_map.clear();
+
+      for( tpindex = 0 ; tpindex < tpsize ; ++tpindex ) {
+        aux_tps_map[ 
+          ( 
+            ( 
+              ( 
+                curr_trans_dmap_err_vec[ tpindex ] - 
+                curr_trans_dmap_err_vec_min
+              ) 
+              / curr_trans_dmap_err_vec_range 
+            ) 
+            + 
+            ( 
+              (  
+                curr_trans_imap_err_vec[ tpindex ] - 
+                curr_trans_imap_err_vec_min              
+              ) 
+              / curr_trans_imap_err_vec_range 
+            ) 
+          )
+        ] = &(params.tiepoints_[ tpindex ]);
+      }
+      
+      /* Generating all possible transformations without 
+         each tie-point */
+      
+      aux_tps_map_it = aux_tps_map.rbegin();
+      aux_tps_map_it_end = aux_tps_map.rend();
+      
+      while( aux_tps_map_it != aux_tps_map_it_end ) {
+        curr_canditate_tp_ptr = aux_tps_map_it->second;
+        
+        /* Generating a transformation parameters without the
+           current tie-point */
+           
+        params_aux.tiepoints_.clear();
+        params_aux.direct_parameters_.Clear();
+        params_aux.inverse_parameters_.Clear();
+            
+        for( tpindex = 0 ; tpindex < tpsize ; ++tpindex ) {
+          curr_tp_ptr = &(params.tiepoints_[ tpindex ]);
+          
+          if( curr_tp_ptr != curr_canditate_tp_ptr ) {
+            params_aux.tiepoints_.push_back( *curr_tp_ptr );
+          }
+        }            
+      
+        /* Trying to generate a transformation without the current
+            tie-point with tpindex index */      
+        
+        if( computeParameters( params_aux ) ) {
+          curr_dmap_error = getDirectMappingError( params_aux );
+          curr_imap_error = getInverseMappingError( params_aux );
+          
+          if( ( best_params_dmap_error > curr_dmap_error ) && 
+            ( best_params_imap_error > curr_imap_error ) ) {
+            
+            best_params_dmap_error = curr_dmap_error;
+            best_params_imap_error = curr_imap_error;
+            best_params = params_aux;
+            
+            params = params_aux;
+            
+            transformation_not_updated = false;
+            
+            break; /* break the current tie-points loop */
+          }
+        }      
+        
+        ++aux_tps_map_it;
+      }//while( aux_tps_map_it != aux_tps_map_it_end ) {
+      
+      if( transformation_not_updated ) {
+        /* There is no way to improve the current transformation
+           since all tie-points were tested */
+        
+        break; /* break the loop */
+      } else {
+        if( ( max_dmap_error >= best_params_dmap_error ) && 
+            ( max_imap_error >= best_params_imap_error ) ) {
+            
+          /* A valid transformation was found */
+          break;
+        }
+      }
+    }//while( params.tiepoints_.size() > req_tie_pts_nmb ) {
+    
+    if( ( best_params.tiepoints_.size() >= req_tie_pts_nmb ) &&
+        ( max_dmap_error >= best_params_dmap_error ) && 
+        ( max_imap_error >= best_params_imap_error ) ) {
+        
+      params = best_params;
+      
+      return true;
+    } else {
+      return false;
+    }    
+  }
+  
+  return false;
+}
+
+
diff --git a/src/terralib/kernel/TeGeometricTransformation.h b/src/terralib/kernel/TeGeometricTransformation.h
new file mode 100644
index 0000000..bb3dff8
--- /dev/null
+++ b/src/terralib/kernel/TeGeometricTransformation.h
@@ -0,0 +1,322 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeGeometricTransformation.h
+   \brief Geometric trasformations base class.
+*/
+
+#ifndef TEGEOMETRICTRANSFORMATION_H
+  #define TEGEOMETRICTRANSFORMATION_H
+  
+  #include "TeDefines.h"
+  #include "TeCoord2D.h"
+  #include "TeMatrix.h"
+  #include "TeGTParams.h"
+  #include "TeSharedPtr.h"
+  #include "TeAgnostic.h"
+  
+  #include <vector>
+  
+  /**
+   * @brief This is the base class to deal with a geometric trasformation
+   * direct and inverse mapping the tie-points TeCoordPair::pt1 space into 
+   * TeCoordPair::pt2 space.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  class TL_DLL TeGeometricTransformation {
+    public :
+
+      /** 
+       * @typedef TeSharedPtr< TeGeometricTransformation > pointer
+       * Type definition for a TeGeometricTransformation instance pointer. 
+       */
+      typedef TeSharedPtr< TeGeometricTransformation > pointer;
+      
+      /**
+       * @brief Default Destructor
+       */
+      virtual ~TeGeometricTransformation();
+      
+      /**
+       * @brief Direct mapping ( from pt1 space into pt2 space ).
+       *
+       * @param pt1 pt1 coordinate.
+       * @param pt2 pt2 coordinate.
+       */      
+      inline void directMap( const TeCoord2D& pt1, TeCoord2D& pt2 ) const
+      {
+        TEAGN_DEBUG_CONDITION(
+          ( internal_params_.direct_parameters_.Ncol() > 0 ),
+          "Invalid number of parameters columns" )
+        TEAGN_DEBUG_CONDITION(
+          ( internal_params_.direct_parameters_.Nrow() > 0 ),
+          "Invalid number of parameters rows" )
+        
+        directMap( internal_params_, pt1, pt2 );
+      };
+      
+      /**
+       * @brief Inverse mapping ( from pt2 space into pt1 space ).
+       *
+       * @param pt2 pt2 coordinate.
+       * @param pt1 pt1 coordinate.
+       */      
+      inline void inverseMap( const TeCoord2D& pt2, 
+        TeCoord2D& pt1 ) const
+      {
+        TEAGN_DEBUG_CONDITION(
+          ( internal_params_.inverse_parameters_.Ncol() > 0 ),
+          "Invalid number of parameters columns" )
+        TEAGN_DEBUG_CONDITION(
+          ( internal_params_.inverse_parameters_.Nrow() > 0 ),
+          "Invalid number of parameters rows" )            
+      
+        inverseMap( internal_params_, pt2, pt1 );
+      };
+      
+      /**
+       * @brief Reset the current transformation following the new supplied 
+       * parameters.
+       *
+       * @param newparams The new parameters.
+       * @return true if OK, false on errors.
+       */      
+      bool reset( const TeGTParams& newparams );
+      
+      /**
+       * @brief Returns a copy of the current internal transformation parameters.
+       *
+       * @param params The internal parameters copy.
+       */        
+      void getParameters( TeGTParams& params ) const;
+      
+      /**
+       * @brief Calculates the current transformation maximum direct mapping 
+       * error ( from pt1 space into pt2 space ).
+       *
+       * @return The current maximum direct mapping error.
+       */        
+      inline double getDirectMappingError() const
+      {
+        TEAGN_DEBUG_CONDITION( 
+          ( internal_params_.tiepoints_.size() > 0 ),
+          "Invalid tie-points vector size" )
+        
+        return getDirectMappingError( internal_params_ );
+      };
+      
+      /**
+       * @brief Calculates the current transformation maximum inverse mapping 
+       * error ( from pt2 space into pt1 space ).
+       *
+       * @return The current maximum inverse mapping error.
+       */        
+      inline double getInverseMappingError() const
+      {
+        TEAGN_DEBUG_CONDITION( 
+          ( internal_params_.tiepoints_.size() > 0 ),
+          "Invalid tie-points vector size" )
+        
+        return getInverseMappingError( internal_params_ );
+      };      
+      
+      /**
+       * @brief Calculates the direct mapping error for the supplied tie-point
+       * ( from pt1 space into pt2 space ).
+       *
+       * @param tie_point The tie-point.
+       * @return The current direct mapping error.
+       */        
+      inline double getDirectMappingError( const TeCoordPair& tie_point ) const
+      {
+        TEAGN_DEBUG_CONDITION( 
+          ( internal_params_.tiepoints_.size() > 0 ),
+          "Invalid tie-points vector size" )
+      
+        return getDirectMappingError( tie_point, internal_params_ );      
+      };
+      
+      /**
+       * @brief Calculates the inverse mapping error for the supplied tie-point
+       * ( from pt2 space into pt1 space ).
+       *
+       * @param tie_point The tie-point.
+       * @return The current inverse mapping error.
+       */        
+      inline double getInverseMappingError( const TeCoordPair& tie_point ) const
+      {
+        TEAGN_DEBUG_CONDITION( 
+          ( internal_params_.tiepoints_.size() > 0 ),
+          "Invalid tie-points vector size" )
+      
+        return getInverseMappingError( tie_point, internal_params_ );      
+      };      
+      
+      /**
+       * @brief Returns the minimum number of required tie-points for the current
+       * transformation.
+       *
+       * @return The minimum number of required tie-points for the current
+       * transformation.
+       */       
+      virtual unsigned int getMinRequiredTiePoints() const = 0;      
+      
+      /**
+       * @brief Returns a default object.
+       *
+       * @return A default object.
+       */
+      static TeGeometricTransformation* DefaultObject( 
+        const TeGTParams& );
+
+    protected :
+    
+      /**
+       * @brief Default Constructor.
+       */
+      TeGeometricTransformation();
+      
+      /**
+       * @brief Direct mapping ( from pt1 space into pt2 space ).
+       *
+       * @param params Transformation parameters.
+       * @param pt1 pt1 coordinate.
+       * @param pt2 pt2 coordinate.
+       */      
+      virtual void directMap( const TeGTParams& params,
+        const TeCoord2D& pt1, TeCoord2D& pt2 ) const = 0;
+      
+      /**
+       * @brief Inverse mapping ( from pt2 space into pt1 space ).
+       *
+       * @param params Transformation parameters.
+       * @param pt2 pt2 coordinate.
+       * @param pt1 pt1 coordinate.
+       */      
+      virtual void inverseMap( const TeGTParams& params,
+        const TeCoord2D& pt2, 
+        TeCoord2D& pt1 ) const = 0;      
+      
+      /**
+       * @brief Calculate the transformation parameters following the
+       * new supplied tie-points.
+       *
+       * @param params Transformation parameters.
+       * @return true if OK, false on errors.
+       */       
+      virtual bool computeParameters( TeGTParams& params ) = 0;
+        
+      /**
+       * @brief Calculates maximum direct mapping error for the supplied 
+       * parameters ( from pt1 space into pt2 space ).
+       *
+       * @param params Transformation parameters.       
+       * @return The maximum direct mapping error for the supplied parameters.
+       */        
+      double getDirectMappingError( const TeGTParams& params ) const;        
+      
+      /**
+       * @brief Calculates maximum inverse mapping error for the supplied 
+       * parameters ( from pt2 space into pt1 space ).
+       *
+       * @param params Transformation parameters.       
+       * @return The maximum inverse mapping error for the supplied parameters.
+       */        
+      double getInverseMappingError( const TeGTParams& params ) const;      
+        
+      /**
+       * @brief Calculates the direct mapping error for the supplied tie-point.
+       * ( from pt1 space into pt2 space ).
+       *
+       * @param tie_point The tie-point.
+       * @param params Transformation parameters.        
+       * @return The current maximum direct mapping error.
+       */        
+      double getDirectMappingError( const TeCoordPair& tie_point,
+        const TeGTParams& params ) const;
+
+      /**
+       * @brief Calculates the inverse mapping error for the supplied tie-point.
+       * ( from pt2 space into pt1 space ).
+       *
+       * @param tie_point The tie-point.
+       * @param params Transformation parameters.        
+       * @return The current maximum inverse mapping error.
+       */        
+      double getInverseMappingError( const TeCoordPair& tie_point,
+        const TeGTParams& params ) const;
+                
+    private :
+    
+      /**
+       * @brief The current internal parameters.
+       */
+      TeGTParams internal_params_;
+      
+      /**
+       * @brief Operator= overload.
+       *
+       * @param external External instance reference.
+       *
+       * @return The external instance reference.
+       */        
+      const TeGeometricTransformation& operator=( 
+        const TeGeometricTransformation& ) { return *this; };
+        
+      /**
+       * @brief Recombine a seed vector without repetition (the number of combined 
+       * elements on each iteration will follow the vectors size.
+       *
+       * @param seed Seed vector.
+       * @param elements_nmb Number of elements to be permutated
+       * @param seedpos Location inside the seed vector where to begin
+       * the permutation.
+       * @return TRUE if a permutation was made, FALSE if no more
+       * permutation are left to made.
+       *
+       * @note All initial fields must be set to value 0 for the initial seed.
+      */
+      bool recombineSeed( std::vector<unsigned int>& seed, 
+        const unsigned int& seedpos, const unsigned int& elements_nmb ) const;        
+        
+      /**
+       * @brief Exaustive outliers remotion strategy (All tie-points
+       * combinations will be tested).
+       * @param params The current transformation parameters.
+       * @return TRUE if OK, false on errors.
+      */        
+      bool exaustiveOutRemotion( TeGTParams& params );
+      
+      /**
+       * @brief Leave-worse-out outliers remotion strategy 
+       * (On each iteration the worse tie-point will be
+       * removed).
+       * @param params The current transformation parameters.
+       * @return TRUE if OK, false on errors.
+      */        
+      bool LWAOutRemotion( TeGTParams& params );      
+
+  };
+  
+#endif
+
diff --git a/src/terralib/kernel/TeGeometry.cpp b/src/terralib/kernel/TeGeometry.cpp
new file mode 100644
index 0000000..5abf4c1
--- /dev/null
+++ b/src/terralib/kernel/TeGeometry.cpp
@@ -0,0 +1,146 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeGeometry.h"
+#include "TeException.h"
+
+// TeLine2D
+
+bool
+TeLine2D::isRing() const
+{
+	if ( size() <= 3 )
+			return false;
+		return ( pImpl_->operator[] (0) == pImpl_->operator[] ( pImpl_->size() - 1 ) );
+
+}
+
+
+// TeLinearRing
+
+TeLinearRing::TeLinearRing ( TeLine2D& line ): TeLine2D ( line ) 
+{
+	if ( ! line.isRing() )
+	{
+		line.add (line[0]);
+//		throw TeException ( LINE_IS_NOT_RING );
+	}
+}
+
+
+ostream& operator<<(ostream& os, TeNode& N)
+{
+	os << Te2String(N.geomId());
+    return os;
+}
+
+ostream& operator<<(ostream& os, const TeArc& N)
+{
+	TeArc a = N;
+	os << a.objectId();
+    return os;
+}
+
+void 
+TeLineSet::copyElements ( const TeLineSet& other )
+{
+	geomId_ = other.geomId();
+	objectId_ = other.objectId();
+
+	for (unsigned int i=0; i<other.size(); ++i) // for each line
+	{
+		TeLine2D line; 
+		line.copyElements(other[i]);
+		this->add (line);
+	}
+}
+
+void 
+TePolygon::copyElements ( const TePolygon& other )
+{
+	geomId_ = other.geomId();
+	objectId_ = other.objectId();
+
+	for (unsigned int i = 0; i < other.size(); ++i) // for each linear ring
+	{
+		TeLine2D line; 
+		line.copyElements(other[i]);
+		this->add (line);
+	}
+}
+
+
+void 
+TePolygonSet::copyElements ( const TePolygonSet& other )
+{
+	geomId_ = other.geomId();
+	objectId_ = other.objectId();
+
+	for (unsigned int i = 0; i < other.size(); ++i) // for each polygon
+	{
+		TePolygon poly;
+		poly.copyElements (other[i]);
+		this->add (poly);
+	}
+}
+
+
+TePointSet makePointSet( const TeLinearRing& lr )
+{
+  TePointSet outps;
+  TePoint temp_point;
+  
+  const unsigned int lr_size = lr.size();
+  
+  for( unsigned int lr_index = 0 ; lr_index < lr_size ; ++lr_index ) {
+    TePoint temp_point;
+    temp_point.add( lr[ lr_index ] );
+    
+    outps.add( temp_point );
+  }
+  
+  return outps;
+}
+
+
+TePointSet makePointSet( const TePolygon& p )
+{
+  TePointSet outps;
+
+  const unsigned int p_size = p.size();
+  unsigned p_index = 0;
+  unsigned int lrps_size = 0;
+  unsigned int lrps_index = 0;
+  
+  for( p_index = 0 ; p_index < p_size ; ++p_index ) {
+    TePointSet lrps = makePointSet( p[ p_index ] );
+    lrps_size = lrps.size();
+  
+    for( lrps_index = 0 ; lrps_index < lrps_size ; ++lrps_index ) {
+      outps.add( lrps[ lrps_index ] );
+    }
+  }
+  
+  return outps;
+}
+
diff --git a/src/terralib/kernel/TeGeometry.h b/src/terralib/kernel/TeGeometry.h
new file mode 100644
index 0000000..15095f6
--- /dev/null
+++ b/src/terralib/kernel/TeGeometry.h
@@ -0,0 +1,979 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeGeometry.h
+    \brief This file contains structures and definitions about	geometries support in TerraLib
+*/
+
+#ifndef __TERRALIB_INTERNAL_GEOMETRY_H
+#define __TERRALIB_INTERNAL_GEOMETRY_H
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeDefines.h"
+#include "TeBox.h"
+#include "TeCoord2D.h"
+#include "TeComposite.h"
+#include "TeMeasure.h"
+#include "TeUtils.h"
+#include "TeDataTypes.h"
+
+#include <string>
+#include <iostream>
+
+
+using namespace std;
+
+//!  A basic class for handling geometries in TerraLib
+/*! 
+	 All geometric classes of TerraLib are derived from
+	 TeGeometry. This class keep track of a geometryId and of a bounding box for the geometry
+	
+	 \note The Geometry classes in TerraLib use the Composite and the Visitor patterns
+	 \sa TeBox TeGeomComposite, TeGeomSingle 
+*/
+class TL_DLL TeGeometry
+{
+public:
+
+	//! Empty constructor
+	TeGeometry(): box_ ( TeMAXFLOAT, TeMAXFLOAT, -TeMAXFLOAT, -TeMAXFLOAT ),
+		geomId_  ( 0 ), objectId_ ("") {}
+
+	//! Copy Constructor
+	TeGeometry ( const TeGeometry& other ) 
+	{
+		box_    = other.box_;
+		geomId_ = other.geomId_;
+		objectId_ = other.objectId_;
+	}
+	
+	//! Destructor
+	virtual ~TeGeometry() {}
+
+	//! Sets the bounding box for the object
+	void setBox ( const TeBox & box )
+	{ box_  = box; }
+	
+	//! Returns the constant bounding box
+	const TeBox& box () const 
+	{ return box_; }
+
+	//! Returns the bounding box
+	TeBox& box ()
+	{ return box_; }
+
+	//! Returns the geometry Id
+	int geomId() const
+	{ return geomId_; }
+
+	//! Sets the geometryId.
+	void geomId( int id )
+	{ geomId_ = id; }
+
+	//! Returns the object unique identification
+	virtual string objectId() const
+	{ return objectId_; }
+
+	//! Sets the objectId 
+	virtual void objectId ( const string& id )
+	{ objectId_ = id; }
+
+	//! Return the geometry size 
+	virtual unsigned int size() const
+	{ return 0; }
+
+	//! Outputs the geometical identification to an output stream
+	ostream& operator<<(ostream& os)
+	{
+		os << Te2String(geomId_);
+		return os;
+	}
+
+	//! Returns TRUE if a geometry is a closed ring  
+	virtual bool isRing() const
+	{ return false; }
+
+	//! Returns the basic geometry type in a set of geometries structure
+	virtual TeGeomRep elemType() 
+	{ return TeGEOMETRYNONE; }
+	
+protected:
+
+	TeBox	box_;		//!<  The bounding box of the geometry
+	int	geomId_;		//!<  The unique geometry identification
+	string	objectId_;	//!<  The unique object identification associated to a geometry
+};
+
+
+//! A class that represents a non existent geometry
+/*!
+	This class is used to deal in a similar way with objects with or without geometry 
+*/
+class TL_DLL TeGeometryNone:  public TeGeometry
+{
+public: 
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeGEOMETRYNONE; }
+
+	//! Removes geometry elements
+	void clear () { return; }
+};
+
+//! A class to handle vector geometries
+class TL_DLL TeVector : public TeGeometry
+{
+};
+
+//!   TeGeomSingle: A class for handling geometries in TerraLib which consist of one location
+/*!  
+  \sa TePoint, TeSample 
+*/
+template <class T>
+class TeGeomSingle : public TeVector
+{
+public:
+
+    //! Exports the type of the element of a TeGeomSingle
+	typedef  T value_type;
+
+	//! Empty constructor
+	TeGeomSingle<T>() {}
+
+	//! Constructor from the single element of the container
+	TeGeomSingle<T> (const T& elem ): elem_ ( elem  ) 
+	{	updateBox ( box_, elem ); }
+
+	//! Copy Constructor
+	TeGeomSingle ( const TeGeomSingle& other ) : TeVector()
+	{
+		box_    = other.box_;
+		geomId_ = other.geomId_;
+		objectId_ = other.objectId_;
+		elem_ = other.elem_;
+	}
+
+	//! Equal Operator
+	TeGeomSingle& operator = ( const TeGeomSingle& other )
+	{
+		box_    = other.box_;
+		geomId_ = other.geomId_;
+		objectId_ = other.objectId_;
+		elem_ = other.elem_;
+		return *this;
+	}
+
+	//! Destructor
+	virtual ~TeGeomSingle<T>() {}
+
+	//! Changes the unique element
+	void add ( T& elem )
+	{
+		elem_ = elem;
+		box_ = TeBox(TeMAXFLOAT, TeMAXFLOAT,-TeMAXFLOAT,-TeMAXFLOAT); // invalidates its box
+		updateBox ( box_, elem );
+	}
+
+	//! Returns the unique element
+	T&	location ()
+	{	return elem_; }
+
+	//! Returns the unique element
+	const T& location () const
+	{	return elem_; }
+
+	//! Returns the unique element
+	T& elem ()
+	{	return elem_; }
+
+	//! Returns the unique element
+	const T& elem () const
+	{	return elem_; }
+
+	//! Returns the unique element
+	T& operator [] ( int /* i */) 
+	{	return elem_; }
+
+	//! Returns TRUE if a TeGeomSingle is equal to other
+	bool operator== (const TeGeomSingle& other) const
+	{	return elem_ == other.elem(); }
+
+	//! Returns the size of a TeGeomSingle: always 1
+	int size() { return 1; }
+
+protected:
+	T	elem_;
+
+};
+
+
+
+//!  TeGeomComposite: A template class for handling a hierarchy of geometries in TerraLib
+/*!
+
+	  Used for instantiating the different geometries. Provide a vector to store the 2D 
+	  coordinates of a ring. Multiple copies of a geometry are allowed to share the same 
+	  coordinates by means of a "handle/body"  idiom.
+
+	\sa  TeLine2D TePolygon TeLineSet TePolygonSet
+*/
+
+template <class T>  
+class TeGeomComposite: public TeVector
+{
+public:
+
+	//! Constructor
+	TeGeomComposite()
+	{
+		pImpl_ = new TeComposite<T>;
+		pImpl_->attach();
+	}
+
+	//! Destructor
+	virtual ~TeGeomComposite()
+	{	pImpl_->detach();	}
+
+
+	//! Copy Constructor
+	TeGeomComposite ( const TeGeomComposite& other ) : TeVector()
+	{
+		pImpl_ = other.pImpl_;
+		pImpl_->attach();
+		box_    = other.box_;
+		geomId_ = other.geomId_;
+		objectId_ = other.objectId_;
+	}
+
+	//! Operator =
+	TeGeomComposite& operator= ( const TeGeomComposite& other )
+	{
+		if ( this != &other )
+		{	
+			other.pImpl_->attach();
+			pImpl_->detach();
+			pImpl_  = other.pImpl_;
+			box_    = other.box_;
+			geomId_ = other.geomId_;
+			objectId_ = other.objectId_;
+		}
+		return *this;
+	}
+
+	//! Returns the identification of the object associated to this geometry
+	virtual string objectId() const
+	{ return objectId_; }
+
+	//! Sets the identification of the object associated to this geometry
+	virtual void objectId (const string& id )
+	{ 
+		objectId_ = id; 
+		typename TeComposite<T>::iterator it = pImpl_->begin();
+		while (it != pImpl_->end())
+		{
+			it->objectId(id);
+			++it;
+		}
+	}
+
+	//! Copy two composites, duplicating elements (breaking handle/body idiom)
+	void copyElements ( const TeGeomComposite& other )
+	{
+		geomId_ = other.geomId_;
+		objectId_ = other.objectId_;
+
+		for (unsigned int i = 0; i < other.pImpl_->size(); i++)
+			add (other.pImpl_->operator[](i));
+	}
+
+	//! Returns TRUE if two composites have exactly the same elements
+	bool operator== (const TeGeomComposite& other) const
+	{	
+		if ( this->size() != other.size() )
+			return false;
+
+		for (unsigned int i = 0; i < other.pImpl_->size(); i++)
+			if ( (pImpl_->operator[](i))==(other.pImpl_->operator[]( i )) )
+				return false;
+		return true; 
+	}
+
+	//! Adds a new component
+	void add ( const T& elem )
+	{	
+		pImpl_->add ( elem );
+		updateBox ( box_, elem );
+	}
+
+	//! Removes the i-th component
+	bool erase ( int i )
+	{ 	
+		bool status = pImpl_->erase (i);
+
+		if (status)	// recalculates the box
+		{
+			box_ = TeBox(TeMAXFLOAT, TeMAXFLOAT,-TeMAXFLOAT,-TeMAXFLOAT);
+			for (unsigned int j = 0; j < pImpl_->size(); j++)
+				updateBox(box_,pImpl_->operator[](j));
+		}
+		return status;
+	}
+
+	//! Removes an element
+	bool erase ( T& object )
+	{	
+		bool status = pImpl_->erase ( object ); 
+		if (status)	// recalculates the box
+		{
+			box_ = TeBox(TeMAXFLOAT, TeMAXFLOAT,-TeMAXFLOAT,-TeMAXFLOAT);
+			for (unsigned int j = 0; j < pImpl_->size(); j++)
+				updateBox(box_,pImpl_->operator[](j));
+		}
+		return status;
+	}
+
+	//! Removes the element pointed by an interator
+	typename TeComposite<T>::iterator erase(typename TeComposite<T>::iterator it)
+	{	
+		typename TeComposite<T>::iterator res = pImpl_->erase(it); 
+		box_ = TeBox(TeMAXFLOAT, TeMAXFLOAT,-TeMAXFLOAT,-TeMAXFLOAT);
+		for (unsigned int j = 0; j < pImpl_->size(); j++)
+			updateBox(box_,pImpl_->operator[](j));
+		return res;
+	}
+
+	//! Removes all elements
+	void clear ()
+	{	
+		pImpl_->clear ();		// remove all elements
+		box_ = TeBox(TeMAXFLOAT, TeMAXFLOAT,-TeMAXFLOAT,-TeMAXFLOAT); // invalidates its box
+	}
+	
+	//! Returns the size of the composite
+	unsigned int size() const
+	{	return ( (unsigned int) pImpl_->size() ); }
+
+	//! Reserves space for a given number of elements (reserve is available for vectors)  
+	void reserve(int nelem)
+	{ pImpl_->reserve(nelem); }
+
+	//! Returns the i-th element
+	T& operator [] ( int i ) const
+	{	return pImpl_->operator[] ( i ); }
+
+	//! Returns the first element
+	T& first() const
+	{	return pImpl_->operator[] ( 0 ); }
+	
+	//! Returns the i-th element
+	T& last() const
+	{	return pImpl_->operator[] ( pImpl_->size()-1 ); }
+	
+	//! Returns TRUE if composite is empty
+	bool empty () const
+	{	return pImpl_->empty (); }
+
+	//! An Iterator that enables forward traversal of a TeGeomComposite
+	typedef typename TeComposite<T>::iterator iterator;
+
+	//! The type of the value obtained by dereferencing a TeGeomComposite iterator
+//	typedef typename T value_type;
+	typedef  T value_type;
+
+	//! The iterator to the first position in the TeGeomComposite
+	typename TeComposite<T>::iterator begin()
+	{ return pImpl_->begin(); }
+
+	//! The iterator to the first position in the TeGeomComposite
+	typename TeComposite<T>::iterator const begin() const
+	{ return pImpl_->begin(); }
+
+	//! The iterator to the last plus one position in the TeGeomComposite
+	typename TeComposite<T>::iterator end()
+	{ return pImpl_->end(); }
+
+	//! The iterator to the last plus one position in the TeGeomComposite
+	typename TeComposite<T>::iterator const end() const
+	{ return pImpl_->end(); }
+
+	//! An Iterator that enables backward traversal of a TeGeomComposite
+	typedef typename TeComposite<T>::reverse_iterator reverse_iterator;
+
+	//! The iterator to the first position in the TeGeomComposite in reverse order
+	typename TeComposite<T>::reverse_iterator rbegin()
+	{ return pImpl_->rbegin(); }
+
+	//! The iterator to the last plus one position in the TeGeomComposite in reverse order
+	typename TeComposite<T>::reverse_iterator rend()
+	{ return pImpl_->rend(); }
+
+protected:
+
+	//! Pointer to the implementation of a composite<T>
+	TeComposite<T> * pImpl_; 
+};
+
+//!  TeLine2D: Supports a simple 2D line,  composed of 2D xy points
+/*!
+	\sa TeGeometry TeLinearRing
+*/
+class TL_DLL TeLine2D : public TeGeomComposite<TeCoord2D>
+{
+public:
+	//! Check if a line2D is a closed ring
+	bool isRing() const;	
+
+	//! Returns the identification of the object associated to this geometry
+	string objectId() const
+	{ return objectId_; }
+	
+	//! Sets the identification of the object associated to this geometry
+	void objectId (const string& id )
+	{  objectId_ = id; }
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeLINES; }
+};
+
+//!  TeLineSet: Supports a composite of lines
+/*!
+  \sa TeGeomComposite
+*/
+class TL_DLL TeLineSet: public TeGeomComposite<TeLine2D>
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeLINES; }
+
+	//! Executes a real copy of two sets (duplicate the elements)
+	void copyElements (const TeLineSet& other ); 
+}; 
+
+//!  TeLinearRing: Provides support for a 2D linear ring
+/*!
+	 A linear ring is a 2D line (without self-intersections) whose 
+	 first point is the same as the last point.  A linear ring cannot be created 
+	 directly, but is instantiated from a 2D line.
+
+   \sa TePolygon 
+*/
+class TL_DLL TeLinearRing : public TeLine2D  {
+public:
+
+	//! Empty constructor
+	TeLinearRing() : TeLine2D() {}
+
+	//! Contructor from a line
+	TeLinearRing ( TeLine2D& line );
+};
+
+
+//!  TePolygon: A class for handling 2D polygons. 
+/*!
+	In TerraLib, a 2D polygon consists of an outer ring and a list
+	of inner rings 
+*/
+class TL_DLL TePolygon: public TeGeomComposite<TeLinearRing>  
+{
+public:
+	
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TePOLYGONS; }
+
+	//! Executes a real copy of two sets (duplicate the elements)
+	void copyElements ( const TePolygon& other );
+};
+
+//!  TePolygonSet: A class for handling sets of 2D polygons. 
+class TL_DLL TePolygonSet: public TeGeomComposite<TePolygon> 
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TePOLYGONS; }
+
+	//! Executes a real copy of two sets (duplicate the elements)
+	void copyElements ( const TePolygonSet& other );
+};
+
+	
+//!  TePoint: A class for handling 2D Points. 
+class TL_DLL TePoint : public TeGeomSingle<TeCoord2D>
+{
+public:
+	//! Default constructor
+	TePoint(const double& x = 0., const double& y = 0. ):
+		TeGeomSingle<TeCoord2D> ( )
+	{
+			elem_ = TeCoord2D(x,y);
+			setBox(TeBox(x,y,x,y)); // the box of a point is the point itself
+	}
+
+	//! Copy constructor
+	TePoint(TeCoord2D& c):
+		TeGeomSingle<TeCoord2D> ( )
+	{
+			elem_ = c;
+			setBox(TeBox(c.x(),c.y(),c.x(),c.y())); // the box of a point is the point itself
+	}
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TePOINTS; }
+
+	//! Returns the identification of the object associated to this geometry
+	string objectId() const
+	{ return objectId_; }
+	
+	//! Sets the identification of the object associated to this geometry
+	void objectId (const string& id )
+	{  objectId_ = id; }
+
+};
+
+//!  TePointSet:  A class for handling sets of 2D polygons. 
+class TL_DLL TePointSet: public  TeGeomComposite<TePoint> 
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TePOINTS; }
+};
+
+//!  TeText : A class for handling text.
+class TL_DLL TeText: public TeGeomSingle<TeCoord2D>
+{
+public:
+	//! Default contructor
+	/*!
+      \param txt the string of character that form the text (default is an empty string)
+	*/
+	TeText(const string& txt="" ):
+		TeGeomSingle<TeCoord2D> ( ),
+		angle_(0),
+		height_(0),
+		textValue_(txt),
+		alignmentVert_(0),
+		alignmentHoriz_(0)
+	{
+		elem_ = TeCoord2D(0,0);
+		setBox(TeBox(0.0,0.0,0.0,0.0));
+	}
+
+	//! Constructor
+	/*!
+		\param location basic position of the text
+		\param txt the string of character that form the text (default is an empty string)
+	*/
+
+	TeText( TeCoord2D& location, const string& txt="" ):
+		TeGeomSingle<TeCoord2D> ( location ),
+		angle_(0),
+		height_(0),
+		textValue_(txt),
+		alignmentVert_(0),
+		alignmentHoriz_(0)
+	{
+		setBox(TeBox(location,location));
+	}
+
+	//! Copy constructor
+	TeText(const TeText& other ) : TeGeomSingle<TeCoord2D>()
+	{
+		angle_ = other.angle_;
+		height_ = other.height_;
+		textValue_ = other.textValue_;
+		alignmentVert_ = other.alignmentVert_;
+		alignmentHoriz_ = other. alignmentHoriz_;
+		setBox(other.box());
+		elem_ = other.elem_;
+		geomId_ = other.geomId_;
+		objectId_ = other.objectId_;
+	}
+
+	//! Operator =
+	TeText& operator= ( const TeText& other )
+	{
+		if ( this != &other )
+		{	
+			angle_ = other.angle_;
+			height_ = other.height_;
+			textValue_ = other.textValue_;
+			alignmentVert_ = other.alignmentVert_;
+			alignmentHoriz_ = other. alignmentHoriz_;
+			setBox(other.box());
+			elem_ = other.elem_;
+			geomId_ = other.geomId_;
+			objectId_ = other.objectId_;
+		}
+		return *this;
+	}
+
+	//! Returns TRUE if a text is equal to other
+	bool operator== (const TeText& tx) const 
+	{
+		return (angle_ == tx.angle_ &&
+			height_ == tx.height_ &&
+			textValue_ == tx.textValue_ &&
+			alignmentVert_ == tx.alignmentVert_ &&
+			alignmentHoriz_ == tx.alignmentHoriz_ &&
+			elem_ == tx.elem_ &&
+			geomId_ == tx.geomId_ &&
+			objectId_ == tx.objectId_);
+	}
+
+	//! Sets anew value for the location of the text
+	void setLocation(TeCoord2D& l)
+	{	elem_ = l; setBox(TeBox(l,l));	}
+
+	//! Returns the string value of a text
+	string textValue () const
+	{ return textValue_; }
+	
+	//! Sets the string value of a text
+	void setTextValue (const string &text) 
+	{ textValue_ = text; }
+
+	//! Returns the text inclination
+	double angle () const
+	{ return angle_; }
+
+	//! Sets the text inclination
+	void setAngle (double angle) 
+	{ angle_ = angle; }
+
+	//! Returns the text height
+	double height () const
+	{ return height_ ; }
+
+	//! Sets the text height
+	void setHeight (double height) 
+	{ height_ = height; }
+
+	//! Returns the text vertical alignment
+	double alignmentVert () const
+	{ return alignmentVert_ ; }
+
+	//! Sets the text vertical alignment
+	void setAlignmentVert (double alig) 
+	{ alignmentVert_ = alig; }
+
+	//! Returns the text horizontal alignment
+	double alignmentHoriz () const
+	{ return alignmentHoriz_ ; }
+
+	//! Sets the text horizontal alignment
+	void setAlignmentHoriz (double alig) 
+	{ alignmentHoriz_ = alig; }
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeTEXT; }
+
+private:
+	double angle_;	
+	double height_;
+	string textValue_;
+	double alignmentVert_;
+	double alignmentHoriz_;
+};
+
+
+//!  TeTextSet : A class for handling sets of TeText.
+class TL_DLL TeTextSet : public TeGeomComposite<TeText> 
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure
+	TeGeomRep elemType() { return TeTEXT; }
+
+};
+
+
+//! TeNode:  A class for handling 2D Nodes.
+class TL_DLL TeNode: public TeGeomSingle<TeCoord2D>
+{
+public:
+	//! Returns TRUE if nodes are equal
+	bool operator== (const TeNode& node) const
+	{
+		TeCoord2D p1 = elem_;
+		TeCoord2D p2 = node.elem_;
+		return p1==p2;
+	}
+
+	//! Outputs the geometrical identification of a node
+	ostream& operator<<(ostream& os)
+	{
+		os << Te2String(geomId_);
+		return os;
+	}
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeNODES; }
+
+};
+
+//! Outputs the geometrical identification of a node
+TL_DLL ostream& operator<<(ostream& os, TeNode& N);
+
+//!  TeNodeSet :  A class for handling sets of 2D Nodes. 
+class TL_DLL TeNodeSet : public TeGeomComposite<TeNode> 
+
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure
+	TeGeomRep elemType() { return TeNODES; }
+
+};
+
+//!  TeArc : Provides support for a 2D arc.
+class TL_DLL TeArc : public TeVector 
+{
+public:
+
+	//! Empty contructors
+	TeArc(): ifrom_ (-1), ito_ (-1){}
+
+	//! Construtor
+	/*!
+		\param from the starting node of an arc
+		\param to the ending node of an arc
+	*/
+	TeArc(TeNode& from, TeNode& to)
+	{
+		from_ = from;
+		to_ = to;
+		updateBox ( box_, from );
+		updateBox ( box_, to );
+	}
+
+	//! Construtor
+	/*!
+		\param from the geometrical identification of the  starting node of an arc
+		\param to the geometrical identification of the ending node of an arc
+	*/
+	TeArc(int from, int to): ifrom_ (from), ito_ (to) {}
+
+// -- Methods
+
+	//! Returns the starting node 
+	TeNode& fromNode () 
+	{ return from_; }
+
+	//! Returns the ending node 
+	TeNode& toNode () 
+	{ return to_; }
+
+	//! Returns the geometrical identification of the starting node 
+	int fromId () const
+	{ return ifrom_; }
+
+	//! Sets the geometrical identification of the starting node 
+	void fromId (int i) 
+	{ ifrom_ = i; }
+
+	//! Returns the geometrical identification of the ending node 
+	int toId () const
+	{ return ito_; }
+
+	//! Sets the geometrical identification of the ending node 
+	void toId (int i)
+	{ ito_ = i; }
+	
+	//! Sets the starting and ending node 
+	void setNodes (TeNode& from, TeNode& to)
+	{ 
+		from_ = from;
+		to_ = to;
+		updateBox ( box_, from );
+		updateBox ( box_, to );
+	}
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeARCS; }
+
+	//! Returns TRUE if a TeArc is equal to other
+	bool operator== (const TeArc& other) const
+	{
+		if((from_ == other.from_) &&
+	       (to_ == other.to_) &&
+		   (ifrom_ == other.ifrom_) &&
+           (ito_ != other.ito_))
+			return true;
+
+		return false;
+	}
+
+private:
+
+	TeNode	from_, to_;
+	int		ifrom_, ito_;
+};
+
+//! Outputs the description of an arc
+TL_DLL ostream& operator<<(ostream& os, const TeArc& N);
+
+
+//!  TeArcSet: Provides support for a set of 2D arc.
+class TL_DLL TeArcSet: public TeGeomComposite <TeArc> 
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeARCS; }
+};
+
+//!  TeSample: A class for handling 2D Points with an associated measure.
+class TL_DLL TeSample: public TeGeomSingle<TeCoord2D>, public TeMeasure
+{
+public:
+	//! Constructor
+	/*!
+		\param location the position of the sample
+		\param measure the value associated to the sample
+	*/
+	TeSample ( TeCoord2D& location, double measure = 0.  ):
+		TeGeomSingle<TeCoord2D> ( location ), TeMeasure ( measure ) {}
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+};
+
+//!  TeSampleSet: A class for handling sets of 2D samples
+class TL_DLL TeSampleSet: public TeGeomComposite<TeSample>
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeSAMPLES; }
+};
+
+//!  TeContourLine: A class for handling 2D countour lines
+class TL_DLL TeContourLine: public TeLine2D, public TeMeasure
+{
+public:
+	//! Constructor
+	/*!
+		\param line the contour line
+		\param measure the value associated to the contour line
+	*/
+	TeContourLine ( TeLine2D& line, double measure = 0. )
+		: TeLine2D ( line ), TeMeasure ( measure )
+	{}
+};
+
+
+//!  TeContourLineSet: A class for handling sets of 2D countour lines
+class TL_DLL TeContourLineSet: public  TeGeomComposite <TeContourLine> 
+{
+public:
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeSAMPLES; }
+};
+
+
+//!    A class for handling cells. 
+class TL_DLL TeCell : public TeVector 
+{
+	int column_;	//!< the column number of this cell	
+	int line_;		//!< the line number of this cell
+
+public:
+	//! Empty constructor
+	TeCell():
+	  column_(-1),
+	  line_(-1) {}
+
+	TeCell(TeBox& box, int col, int lin):
+	  column_(col),
+	  line_(lin) { setBox(box); }
+
+	//! Returns the column identification of the cell
+	int	column () const
+	{ return column_; }
+
+	//! Sets the column identification of the cell
+	void column (int column) 
+	{ column_ =  column; }
+
+	//! Returns the line identification of the cell
+	int	line () const
+	{ return line_; }
+
+	//! Sets the line identification of the cell
+	void line (int line) 
+	{ line_ =  line; }
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeCELLS; }
+
+	//! Returns TRUE if a TeCell is equal to other
+	bool operator== (const TeCell& other) const
+	{
+		if((column_ == other.column_) &&
+	       (line_ == other.line_))
+			return true;
+
+		return false;
+	}
+};
+
+//!  A class for handling sets of cells.
+class TL_DLL TeCellSet: public  TeGeomComposite<TeCell> 
+{
+	double	resX_;	//!< the X resolution of a set of cells
+	double	resY_;	//!< the Y resolution of a set of cells
+
+public:
+
+	//! Returns the X resolution of a cell set
+	double resX () const
+	{ return resX_; }
+
+	//! Returns the Y resolution of a cell set
+	double resY () const
+	{ return resY_; }
+
+	//! Sets the X resolution of a cell set
+	void resX (double reX) 
+	{ resX_ = reX; }
+
+	//! Sets the Y resolution of a cell set
+
+	void resY (double reY) 
+	{ resY_ = reY; }
+
+	//! Returns the basic geometry in a set of geometries structure 
+	TeGeomRep elemType() { return TeCELLS; }
+
+};
+
+
+/*! \fn TePointSet makePointSet( const TeLinearRing& lr )
+   \brief builds a TePointSet geometry from a TeLinearRing
+ */
+TL_DLL TePointSet makePointSet( const TeLinearRing& lr );
+
+
+/*! \fn TePointSet makePointSet( const TePolygon& p )
+   \brief builds a TePointSet geometry from a TePolygon
+ */
+TL_DLL TePointSet makePointSet( const TePolygon& p );
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeGeometryAlgorithms.cpp b/src/terralib/kernel/TeGeometryAlgorithms.cpp
new file mode 100644
index 0000000..1f5fb6b
--- /dev/null
+++ b/src/terralib/kernel/TeGeometryAlgorithms.cpp
@@ -0,0 +1,2834 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeAssertions.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeDefines.h"
+
+#include "TeIntersector.h"
+#include "TeFragmentation.h"
+
+#include <algorithm>
+#include <set>
+
+
+using namespace std;
+
+//---------- Local Functions ans Structures ----------//
+
+//! Instead of using arctan, use this to compare angles, so given two points return a number to be used in place of the angle formed by the segment.
+double Theta(const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	register double dx = c2.x() - c1.x();
+	register double ax = fabs(dx);
+	register double dy = c2.y() - c1.y();
+	register double ay = fabs(dy);
+	register double t = 0.0;
+
+	if((dx == 0.0) && (dy == 0.0))
+		t = 0.0;
+	else
+		t = dy / (ax + ay);
+
+	if(dx < 0.0)
+		t = 2 - t;
+	else
+		if(dy < 0.0)
+			t = 4.0 + t;
+
+	return t * 90.0;
+}
+
+//! This struct is used for compare angles between two points and an anchor.
+struct ThetaOrder
+{
+	//! A fixed coordinate to be used to compare.
+	TeCoord2D anchor;
+
+	ThetaOrder(const TeCoord2D& c)
+		: anchor(c)
+	{
+	}
+
+	// Return true if c1 and anchor has a smaller angle than c2 and anchor.
+	bool operator()(const TeCoord2D& c1, const TeCoord2D& c2) const
+	{
+		register double t1 = Theta(anchor, c1);
+		register double t2 = Theta(anchor, c2);
+
+		if(t1 < t2)
+			return true;
+		
+		if(t1 > t2)
+			return false;
+
+		if(c1.x() < c2.x())
+			return true;
+
+		if(c1.x() > c2.x())
+			return false;
+
+		return false;		
+	}
+};
+
+/*! \struct xOrder
+    \brief  Returns true if c1 < c2 otherwise, returns false.
+ */
+template<class T> struct xOrder
+{
+	bool operator()(T c1, T c2)
+	{
+		if(c1.x() < c2.x())
+			return true;
+
+		if(c1.x() > c2.x())
+			return false;
+
+		if(c1.y() < c2.y())
+			return true;		
+
+		return false;
+	}
+};
+
+/*! \fn double TeArea(TeLinearRing& r);
+    \brief This function returns twice the area of a ring treated as a simple polygon (no holes).
+	\param r  The ring.
+
+	This function returns twice the area of a ring treated as a simple polygon (no holes).
+	May return a negative number => it will be used in Orientation tests.
+*/
+double Te2Area(const TeLinearRing& r)
+{
+	double S2 = 0.0;
+
+	TeLinearRing::iterator it = r.begin();
+	TeLinearRing::iterator end = r.end() - 1;
+	while(it != end)
+	{
+		S2 += (it->x() + (it + 1)->x()) * ((it + 1)->y() - it->y());
+		++it;
+	}
+
+	return S2;
+}
+
+/*! \fn short TeConverseRelation(const short& rel)
+    \brief This function returns the complements relation of one given relation.
+	\param rel  The relation.
+*/
+inline short ConverseRelation(const short& rel)
+{
+	switch(rel)
+	{
+		case TeCOVEREDBY  :  return TeCOVERS;
+		case TeWITHIN     :  return TeCONTAINS;
+		case TeCOVERS     :  return TeCOVEREDBY;
+		case TeCONTAINS   :  return TeWITHIN;
+		default			  :  return rel;
+	}	
+}
+
+/*! \fn bool MayTouches(const TeLine2D& lRed, const TeLine2D& lBlue, TeINTERSECTOR2::TeReportTree& report)
+    \brief This function verifies if the two lines may touches.
+	\param lRed   The first line.
+	\param lBlue  The second line.
+	\param report The intersection point list.
+*/
+bool MayTouches(const TeLine2D& lRed, const TeLine2D& lBlue, TeINTERSECTOR2::TeVectorBoundaryIP& report)
+{
+	if(lRed.isRing() && lBlue.isRing())
+		return false;
+
+	TeINTERSECTOR2::TeVectorBoundaryIP::iterator it = report.begin();
+	TeINTERSECTOR2::TeVectorBoundaryIP::iterator it_end = report.end();
+
+
+	// Get the boundaries' coordinate.
+	TeCoord2D line1_boundary1 = lRed[0];
+	TeCoord2D line1_boundary2 = lRed[lRed.size() - 1u];
+
+	TeCoord2D line2_boundary1 = lBlue[0];
+	TeCoord2D line2_boundary2 = lBlue[lBlue.size() - 1u];
+
+	// Verifies if intersection points are on boundary of one of the blue line
+	while(it != it_end)
+	{	// Get intersection point coordinate.
+
+		for(unsigned int i = 0; i < it->coords_.size(); ++i)
+		{
+			TeCoord2D ip_coord = it->coords_[i];
+
+			if(lRed.isRing())
+			{
+				if(!(TeEquals(ip_coord, line2_boundary1) || TeEquals(ip_coord, line2_boundary2)))
+					return false;
+			}
+			else if(lBlue.isRing())
+			{
+				if(!(TeEquals(ip_coord, line1_boundary1) || TeEquals(ip_coord, line1_boundary2)))
+					return false;
+			}
+			else
+			{
+				if(!(TeEquals(ip_coord, line1_boundary1) || TeEquals(ip_coord, line1_boundary2) || TeEquals(ip_coord, line2_boundary1) || TeEquals(ip_coord, line2_boundary2)))
+					return false;
+			}
+		}
+
+		++it;
+	}
+
+	return true;		// The lines touches.
+}
+
+/*! \fn short Relation(const TeLine2D& lRed, const TeLine2D& lBlue, TeINTERSECTOR2::TeReportTree& report, const short& relation)
+    \brief This function returns the relation between two lines.
+	\param lRed     The first line.
+	\param lBlue    The second line.
+	\param report   The intersection point list.
+	\param relation The relation that stop the search.
+
+	This function returns the relation between lines. May be: TeDISJOINT, TeTOUCHES, TeWITHIN, TeCROSSES, TeCOVEREDBY, TeEQUALS.
+	Obs: Doesn't do box elimination. You must implement the test in your own functions.
+*/
+short Relation(const TeLine2D& lRed, const TeLine2D& lBlue, TeINTERSECTOR2::TeVectorBoundaryIP& report, const short& relation)
+{
+	if(report.size() == 0u)
+		return TeDISJOINT;
+
+	// Do fragmentation
+	//bool hasContour = false;	// This will decide between CROSSES and OVERLAPS.
+
+	bool mayTouches = MayTouches(lRed, lBlue, report);
+
+	// Stop to check, because touches can't occur anymore
+	if(relation == TeTOUCHES && !mayTouches)
+		return TeUNDEFINEDREL;
+
+
+	TeLineSet redFragments;
+	TeLineSet redBoundaryFragments;
+	TeLine2D lRedAux;
+	lRedAux.copyElements(lRed);
+	TeLineSet lSet; lSet.add(lRedAux);
+
+	TeFragmentBoundary(lSet, report, redBoundaryFragments, redFragments);
+
+	unsigned int redFragmentsSize = redFragments.size();
+
+	short mask = TeUNKNOWNPOSITION;
+
+	if(redBoundaryFragments.size() > 0u)
+		mask |= TeINSIDE;
+
+	// Do a position test for each fragment and stop if all relations have been found.
+	for(unsigned int j = 0u; j < redFragmentsSize; ++j)
+	{	
+		TeCoord2D middle;			
+
+		if(redFragments[j].size() ==  2u)	// If the fragment has two points I need to check the middle point of this fragment.
+			TeGetMiddlePoint(redFragments[j][0u], redFragments[j][1u], middle);
+		else	// If the fragment has more than two points so I check one point between the end points.
+			middle = redFragments[j][(unsigned int)((double(redFragments[j].size()) / 2.0 + 0.5)) - 1];
+
+		if(TeIsOnLine(middle, lBlue))
+			mask |= TeINSIDE;
+		else
+			mask |= TeOUTSIDE;		
+
+		if((mask & TeOUTSIDE) && (mask & TeINSIDE))
+			break;		
+	}
+
+	// If the intersection is only at end points and there is no part of red line inside blue line so they touches
+	if(mayTouches && mask == TeOUTSIDE)
+	{
+		return TeTOUCHES;
+	}
+	
+	// Stop to check, because touches can't occur anymore
+	if(relation == TeTOUCHES)
+		return TeUNDEFINEDREL;
+
+
+	// if there is no fragments in line blue interiors, so line red cross line blue
+	if(mask == TeOUTSIDE)
+		return TeCROSSES;
+
+	// Stop to check, because crosses can't occur anymore
+	if(relation == TeCROSSES)
+		return TeUNDEFINEDREL;
+
+	TeCoord2D firstRedCoord = lRed[0];
+	TeCoord2D lastRedCoord  = lRed[lRed.size() - 1];
+
+	TeCoord2D firstBlueCoord = lBlue[0];
+	TeCoord2D lastBlueCoord  = lBlue[lBlue.size() - 1];		
+
+
+	// If there is no part of red line outside blue line => must decide within, covered by and equals
+	if(!(mask & TeOUTSIDE))
+	{
+		// So, if we arrived here, blue line contains red line, but needs to decide between equal, coveredby and within.
+
+		if(TeEquals(firstRedCoord, firstBlueCoord) || TeEquals(firstRedCoord, lastBlueCoord))
+		{
+			if(TeEquals(lastRedCoord, firstBlueCoord) || TeEquals(lastRedCoord, lastBlueCoord))
+			{
+				return TeEQUALS;
+			}
+			else
+			{
+				if(lBlue.isRing())
+					return TeWITHIN;
+				else
+					return TeCOVEREDBY;
+			}
+		}
+
+		if(TeEquals(lastRedCoord, firstBlueCoord) || TeEquals(lastRedCoord, lastBlueCoord))
+		{
+			if(lBlue.isRing())
+				return TeWITHIN;
+			else
+				return TeCOVEREDBY;
+		}
+
+		return TeWITHIN;
+	}
+
+	return TeUNDEFINEDREL;
+}
+
+/*! \fn short Relation(const TeLine2D& line, const TeLinearRing& ring, const short& relation)
+    \brief This function returns the relation between a line and a linear ring (treated as a simple polygon with no holes).
+	\param line     The line.
+	\param ring     The simple polygon ring.
+	
+	This function returns how the points of input line are related with interior, boundary, and
+	exterior of polygon. The mask may be a combination of the following values: TeOUTSIDE, TeINSIDE and TeBOUNDARY.
+	Obs: Do box elimination.
+*/
+short Relation(const TeLine2D& line, const TeLinearRing& ring)
+{
+	if(TeDisjoint(line.box(), ring.box()))
+		return TeOUTSIDE;
+
+	TeINTERSECTOR2::TeVectorBoundaryIP report;
+
+	if(TeINTERSECTOR2::TeSafeIntersections(line, ring, report))
+	{
+		short mask = TeBOUNDARY;	// It will be at least intersections between boundaries.
+
+		// Fragments line.
+		TeLineSet lSet;
+		TeLineSet boundaryFragments;
+		TeLine2D lineAux;
+		lineAux.copyElements(line);
+		TeLineSet auxLineSet; auxLineSet.add(lineAux);
+		
+		TeFragmentBoundary(auxLineSet, report, boundaryFragments, lSet);
+
+
+		unsigned int lSetSize = lSet.size();
+
+		// Do a position test for each fragment and stop if al relations has been found.
+		for(unsigned int j = 0; j < lSetSize; ++j)
+		{	
+			TeCoord2D middle;
+			
+			if(lSet[j].size() ==  2)	// If the fragment has two points I need to check the middle point of this fragment.
+				TeGetMiddlePoint(lSet[j][0], lSet[j][1], middle);
+			else	// If the fragment has more than two points so I check one point between the end points.
+				middle = lSet[j][(unsigned int)((double(lSet[j].size()) / 2.0 + 0.5)) - 1];
+
+			
+			mask |= TeRelation(middle, ring);
+
+			if((mask & TeOUTSIDE) && (mask & TeINSIDE))
+				break;			
+		}
+
+		return mask;
+	}
+	else
+		return TeRelation(line[0], ring);	// Needs to test only one point of the line, and its location defines the line location.
+}
+
+/*! \fn short TopologicRelation(const TeLine2D& line, const TeLinearRing& r)
+    \brief This function returns the relation between a line and a linear ring (treated as a simple polygon with no holes).
+	\param line     The line.
+	\param r        The simple polygon ring.
+
+	This function returns the topologic relation between the line and
+	the ring. The result may be: DISJOINT, WITHIN, TOUCHES, CROSSES or COVERED BY.
+	Obs: Doesn't do box elimination. Just uses from TeRelation.
+*/
+short TopologicRelation(const TeLine2D& line, const TeLinearRing& r)
+{
+	short mask = Relation(line, r);
+
+	if(mask & TeBOUNDARY)	// TOUCHES or CROSSES or COVERED BY
+	{
+		if(mask & TeOUTSIDE)	// TOUCHES or CROSSES
+		{
+			if(mask & TeINSIDE)
+				return TeCROSSES;
+			else
+				return TeTOUCHES;
+		}
+		else	// COVERED BY
+			return TeCOVEREDBY;
+
+	}
+	else	// DISJOINT or WITHIN
+	{
+		if(mask & TeINSIDE)	
+			return TeWITHIN;
+		else				
+			return TeDISJOINT;
+	}
+}
+
+/*! \fn short TopologicRelation(const TeLinearRing& rRed, const TeLinearRing& rBlue)
+    \brief This function returns the relationship between two rings (treated as simple polygons with no holes).
+	\param rRed  The ring to test relationship.
+	\param rBlue The ring to test relationship.
+
+	This function returns the relationship between two rings.
+*/
+short TopologicRelation(const TeLinearRing& rRed, const TeLinearRing& rBlue)
+{
+	// See the intersection between the points of rRed and the three components of rBlue (Boundary, Exterior, Interior)
+	short rel = Relation(rRed, rBlue);
+
+	if((rel & TeOUTSIDE) && (rel & TeINSIDE) && (rel & TeBOUNDARY))
+		return TeOVERLAPS;
+
+	if((rel & TeOUTSIDE) && !(rel & TeINSIDE) && (rel & TeBOUNDARY))
+	{
+		if(TeWithinOrCoveredByOrEquals(rBlue.box(), rRed.box()))
+		{
+			short rel_aux = Relation(rBlue, rRed);
+
+			if((rel_aux & TeINSIDE) && !(rel_aux & TeOUTSIDE) && (rel_aux & TeBOUNDARY))
+				return TeCOVERS;
+		}
+		
+		return TeTOUCHES;
+	}
+
+	if((rel & TeOUTSIDE) && !(rel & TeINSIDE) && !(rel & TeBOUNDARY))
+	{
+		if(TeWithinOrCoveredByOrEquals(rBlue.box(), rRed.box()))
+		{
+			if(TeRelation(rBlue[0], rRed) == TeINSIDE)
+				return TeCONTAINS;
+		}
+		
+		return TeDISJOINT;
+	}
+
+	if(!(rel & TeOUTSIDE) && (rel & TeINSIDE) && !(rel & TeBOUNDARY))
+		return TeWITHIN;
+
+	if(!(rel & TeOUTSIDE) && (rel & TeINSIDE) && (rel & TeBOUNDARY))
+		return TeCOVEREDBY;
+
+	if(rel == TeBOUNDARY)
+		return TeEQUALS;
+
+	return TeINTERSECTS;
+}
+
+/*! \fn short TeTopologicRelation(const TeLinearRing& rRed, const TeLinearRing& rBlue, vector<TeLinearRing>& rings, short& rel)
+    \brief This function returns the relationship between the ring and the polygon inner rings.
+	\param rRed  The ring to test relationship.
+	\param pBlue The polygon to test relationship.
+	\param rings Inner rings from blue polygon that is inside or is covered by red external polygon.
+	\param rel   The relation between external red ring and external blue ring.
+
+	This function returns the relationship between the ring and the polygon inner rings.
+*/
+short LookAtInnerRings(const TeLinearRing& rRed, const TePolygon& pBlue, vector<TeLinearRing>& rings, short& rel)
+{
+	register unsigned int i = 1;
+	register unsigned int nRings = pBlue.size();
+
+	for(; i < nRings; ++i)
+	{
+		switch(TopologicRelation(rRed, pBlue[i]))
+		{
+			case TeCOVEREDBY : return TeTOUCHES;
+
+			case TeWITHIN	 : return TeDISJOINT;
+
+			case TeOVERLAPS  : return TeOVERLAPS;
+
+			case TeEQUALS    : return TeTOUCHES;
+
+			case TeDISJOINT  : continue;	// this ring is outside the external ring, so it doesn't contribute to the relationship.
+
+			case TeTOUCHES    : rel = TeCOVEREDBY;	// change rel if rel is within.
+				                continue;
+
+			case TeCOVERS    : rings.push_back(pBlue[i]);
+							   rel = TeCOVEREDBY;
+							   break;
+
+			case TeCONTAINS  : rings.push_back(pBlue[i]);
+							   break;
+		}
+	}
+
+	return TeUNDEFINEDREL;
+}
+
+/*! \fn short TestInnerRings(const TePolygon& pRed, vector<TeLinearRing>& rings)
+    \brief This function returns the relationship between the ring and the polygon inner rings.
+	\param pRed  The inner rings from pRed to test relationship.
+	\param rings Inner rings from blue polygon that is inside or is covered by red external polygon.
+
+	This function returns the relationship between the inner ring of pRed and the inner rings in rings.
+*/
+short TestInnerRings(const TePolygon& pRed, vector<TeLinearRing>& rings)
+{
+	unsigned int nRedRings = pRed.size();
+	unsigned int nBlueRings = rings.size();
+
+	if((nRedRings - 1) != nBlueRings)
+		return TeOVERLAPS;
+
+	unsigned int i = 1;
+	unsigned int j = 0;
+
+	bool find = false;
+
+	set<unsigned int> blueRingsProcessed;
+
+	set<unsigned int> redRingsContainsCovers;
+
+	short rel = 0;
+
+	for(; i < nRedRings; ++i)
+	{
+		find = false;
+
+		for(j = 0; j < nBlueRings; ++j)
+		{
+			if(blueRingsProcessed.find(j) != blueRingsProcessed.end())
+				continue;
+
+			switch(TopologicRelation(pRed[i], rings[j]))
+			{
+				case TeDISJOINT  : continue;	// so it doesn't contribute to the relationship yet.
+
+				case TeEQUALS    :
+									rel |= TeEQUALS;
+					                blueRingsProcessed.insert(j);
+									find = true;
+									break;
+
+				case TeCONTAINS  :
+									if(redRingsContainsCovers.find(i) != redRingsContainsCovers.end())
+										return TeOVERLAPS;
+									
+									rel |= TeCONTAINS;
+
+									redRingsContainsCovers.insert(i);
+									blueRingsProcessed.insert(j);
+									find = true;
+									break;
+
+				case TeCOVERS	:
+									if(redRingsContainsCovers.find(i) != redRingsContainsCovers.end())
+										return TeOVERLAPS;
+									
+									rel |= TeCOVERS;
+
+									redRingsContainsCovers.insert(i);
+									blueRingsProcessed.insert(j);
+									find = true;
+									break;
+									
+
+				default          :  return TeOVERLAPS;
+			}
+
+			if(find)
+				break;
+		}
+
+		if(!find)
+			return TeOVERLAPS;
+	}
+
+	return rel;
+}
+
+//---------- Topological Function ----------//
+
+// EQUALS
+template<> bool TeEquals(const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(c1.x(), c2.x()))
+		return false;
+
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(c1.y(), c2.y()))
+		return false;
+
+	return true;
+}
+
+template<> bool TeEquals(const TePoint& p1, const TePoint& p2)
+{
+	return TeEquals(p1.location(), p2.location());
+}
+
+template<> bool TeEquals(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeEquals(redLine.box(), blueLine.box()))
+		return TeRelation(redLine, blueLine, TeEQUALS) == TeEQUALS;
+	else
+		return false;
+}
+
+template<> bool TeEquals(const TePolygon& redPol, const TePolygon& bluePol)
+{
+	if(TeEquals(redPol.box(), bluePol.box()))
+	{
+		if(redPol.size() != bluePol.size())
+			return false;
+
+		return TeRelation(redPol, bluePol) == TeEQUALS;
+	}
+	else
+		return false;
+}
+
+template<> bool TeEquals( const TePolygonSet& ps1, const TePolygonSet& ps2 )
+{
+  if( ps1.size() == ps2.size() ) {
+    TePolygonSet::iterator it1 = ps1.begin();
+    TePolygonSet::iterator it1_end = ps1.end();
+    TePolygonSet::iterator it2 = ps2.begin();
+    
+    while( it1 != it1_end ) {
+      if( ! TeEquals( (*it1), (*it2) ) ) {
+        return false;
+      }
+      
+      ++it1;
+      ++it2;
+    }
+  
+    return true;
+  } else {
+    return false;
+  }
+}
+
+template<> bool TeEquals(const TeBox& bx1, const TeBox& bx2)
+{
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(bx1.x1(), bx2.x1()))
+		return false;
+
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(bx1.y1(), bx2.y1()))
+		return false;
+
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(bx1.x2(), bx2.x2()))
+		return false;
+	
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(bx1.y2(), bx2.y2()))
+		return false;
+
+	return true;
+}
+
+template<> bool TeEquals(const TeCell& cell1, const TeCell& cell2)
+{
+	return TeEquals(cell1.box(), cell2.box());
+}
+
+
+// DISJOINT
+bool TeDisjoint(const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(c1.x(), c2.x()))
+		return true;
+
+	if(TeGeometryAlgorithmsPrecision::IsDifferent(c1.y(), c2.y()))
+		return true;
+
+	return false;
+}
+
+bool TeDisjoint(const TeCoord2D& c, const TeBox& b)
+{
+	// c to the right of b
+	if(TeGeometryAlgorithmsPrecision::IsGreater(c.x(), b.x2())) 
+		return true;
+
+	// c to the left of b
+	if(TeGeometryAlgorithmsPrecision::IsGreater(b.x1(), c.x())) 
+		return true;
+
+	// c is above b
+	if(TeGeometryAlgorithmsPrecision::IsGreater(c.y(), b.y2())) 
+		return true;
+
+	// c is below b 
+	if(TeGeometryAlgorithmsPrecision::IsGreater(b.y1(), c.y())) 
+		return true;
+
+	return false;
+}
+
+bool TeDisjoint(const TeBox& bx1, const TeBox& bx2)
+{
+	// B1 to the right of B2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.x1(), bx2.x2())) 
+		return true;
+
+	// B1 to the left of B2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.x1(), bx1.x2())) 
+		return true;
+
+	// B2 is above B1
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.y1(), bx1.y2())) 
+		return true;
+
+	// B2 is below B1 
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.y1(), bx2.y2())) 
+		return true;
+
+	return false;
+}
+
+bool TeDisjoint(const TeCoord2D& c, const TeLine2D& l)
+{
+	return TeRelation(c, l) == TeOUTSIDE;
+}
+
+bool TeDisjoint(const TeCoord2D& c, const TePolygon& pol)
+{
+	return TeRelation(c, pol) == TeOUTSIDE;
+}
+
+bool TeDisjoint(const TePoint& p1, const TePoint& p2)
+{
+	return TeDisjoint(p1.location(), p2.location());
+}
+
+bool TeDisjoint(const TePoint& p, const TeLine2D& l)
+{
+	return TeDisjoint(p.location(), l);
+}
+
+bool TeDisjoint(const TePoint& p, const TePolygon& pol)
+{
+	return TeDisjoint(p.location(), pol);
+}
+
+bool TeDisjoint(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeDisjoint(redLine.box(), blueLine.box()))
+		return true;
+
+	return !TeINTERSECTOR2::TeIntersects(redLine, blueLine);
+}
+
+bool TeDisjoint(const TeLine2D& l, const TePolygon& pol)
+{
+	if(TeDisjoint(l.box(), pol.box()))
+		return true;
+
+	return TeRelation(l, pol) == TeDISJOINT;
+}
+
+bool TeDisjoint(const TePolygon& redPol, const TePolygon& bluePol)
+{
+	if(TeDisjoint(redPol.box(), bluePol.box()))
+		return true;
+	else
+		return TeRelation(redPol, bluePol) == TeDISJOINT;
+}
+
+bool TeDisjoint(const TeCell& cell1, const TeCell& cell2)
+{
+	return TeDisjoint(cell1.box(), cell2.box());
+}
+
+bool TeDisjoint(const TeCell& cell, const TeLine2D& line)
+{
+	return TeDisjoint(line, TeMakePolygon(cell.box()));
+}
+
+bool TeDisjoint(const TeCell& cell, const TePolygon& pol)
+{
+	return TeDisjoint(pol, TeMakePolygon(cell.box()));
+}
+
+bool TeDisjoint(const TeCell& cell, const TePoint& point)
+{
+	return TeDisjoint(point.location(), cell.box());
+}
+
+
+// INTERSECTS
+
+template<> bool TeIntersects(const TeCoord2D& c, const TeBox& b)
+{
+	// c to the right of b
+	if(TeGeometryAlgorithmsPrecision::IsGreater(c.x(), b.x2())) 
+		return false;
+
+	// c to the left of b
+	if(TeGeometryAlgorithmsPrecision::IsGreater(b.x1(), c.x())) 
+		return false;
+
+	// c is above b
+	if(TeGeometryAlgorithmsPrecision::IsGreater(c.y(), b.y2())) 
+		return false;
+
+	// c is below b 
+	if(TeGeometryAlgorithmsPrecision::IsGreater(b.y1(), c.y())) 
+		return false;
+
+	return true;
+}
+
+template<> bool TeIntersects(const TePoint& p, const TeBox& b)
+{
+	return TeIntersects(p.location(), b);
+}
+
+template<> bool TeIntersects(const TeBox& bx1, const TeBox& bx2)
+{
+	// B1 to the right of B2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.x1(), bx2.x2())) 
+		return false;
+
+	// B1 to the left of B2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.x1(), bx1.x2())) 
+		return false;
+
+	// B2 is above B1
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.y1(), bx1.y2())) 
+		return false;
+
+	// B2 is below B1 
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.y1(), bx2.y2())) 
+		return false;
+
+	return true;
+}
+
+
+// TOUCHES
+bool TeTouches(const TeCoord2D& c, const TeLine2D& l)
+{
+	return TeRelation(c, l) == TeBOUNDARY;
+}
+
+bool TeTouches(const TeCoord2D& c, const TePolygon& pol)
+{
+	return TeRelation(c, pol) == TeBOUNDARY;
+}
+
+bool TeTouches(const TePoint& p, const TeLine2D& l)
+{
+	return TeTouches(p.location(), l);
+}
+
+bool TeTouches(const TePoint& p, const TePolygon& pol)
+{
+	return TeTouches(p.location(), pol);
+}
+
+bool TeTouches(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeDisjoint(redLine.box(), blueLine.box()))
+		return false;
+
+	return TeRelation(redLine, blueLine, TeTOUCHES) == TeTOUCHES;	
+}
+
+bool TeTouches(const TeLine2D& l, const TePolygon& pol)
+{
+	if(TeDisjoint(l.box(), pol.box()))
+		return false;
+
+	return TeRelation(l, pol) == TeTOUCHES;
+}
+
+bool TeTouches(const TePolygon& redPol, const TePolygon& bluePol)
+{
+	if(TeDisjoint(redPol.box(), bluePol.box()))
+		return false;
+
+	return TeRelation(redPol, bluePol) == TeTOUCHES;
+}
+
+bool TeTouches(const TeBox& bx1, const TeBox& bx2)
+{	
+	// bx1 may touches its right wall in bx2 left wall
+	// or bx1 may touches its left wall in bx2 right wall
+	if(TeGeometryAlgorithmsPrecision::IsEqual(bx1.x2(), bx2.x1()) || TeGeometryAlgorithmsPrecision::IsEqual(bx1.x1(), bx2.x2()))
+	{
+		// bx1 is below bx2
+		if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.y1(), bx1.y2()))
+			return false;
+
+		// bx1 is above bx2
+		if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.y1(), bx2.y2()))
+			return false;
+
+		// touches
+		return true;	
+	}
+
+	// bx1 may touches its bottom wall in bx2 top wall
+	// or bx1 may touches its top wall in bx2 bottom wall
+	if(TeGeometryAlgorithmsPrecision::IsEqual(bx1.y1(), bx2.y2()) || TeGeometryAlgorithmsPrecision::IsEqual(bx1.y2(), bx2.y1()))
+	{
+		// bx1 is left of bx2
+		if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.x1(), bx1.x2()))
+			return false;
+
+		// bx1 is right of bx2
+		if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.x1(), bx2.x2()))
+			return false;
+
+		// touches
+		return true;
+	}
+
+	// doesn't touches
+	return false;
+}
+
+bool TeTouches(const TeCell& c1, const TeCell& c2)
+{
+	return TeTouches(c1.box(), c2.box());
+}
+
+bool TeTouches(const TeLine2D& line, const TeCell& cell)
+{
+	return TeTouches(line, TeMakePolygon(cell.box()));
+}
+
+bool TeTouches(const TeCell& c1, const TePolygon& poly)
+{
+	return  TeTouches (poly, TeMakePolygon(c1.box()));
+}
+
+bool TeTouches(const TePoint& point,const TeCell& c1)
+{
+	return TeTouches(point.location(), TeMakePolygon(c1.box()));
+}
+
+
+// CROSSES
+bool TeCrosses(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeDisjoint(redLine.box(), blueLine.box()))
+		return false;
+	else
+		return TeRelation(redLine, blueLine, TeCROSSES) == TeCROSSES;
+}
+
+bool TeCrosses(const TeLine2D& l, const TePolygon& pol)
+{
+	if(TeDisjointOrTouches(l.box(), pol.box()))
+		return false;
+	else
+		return TeRelation(l, pol) == TeCROSSES;
+}
+
+bool TeCrosses(const TeLine2D& l, const TeCell& cell)
+{
+	return TeCrosses(l, TeMakePolygon(cell.box()));
+}
+
+
+// WITHIN
+bool TeWithin(const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	return TeEquals(c1, c2);
+}
+
+bool TeWithin(const TeCoord2D& c, const TeBox& b)
+{
+	// c to the right of b left wall AND c to the left of b right wall
+	// AND c below b top wall AND c above b bottom wall => then c is on b interior.
+	return (TeGeometryAlgorithmsPrecision::IsGreater(c.x(), b.x1()) && TeGeometryAlgorithmsPrecision::IsGreater(b.x2(), c.x()) && TeGeometryAlgorithmsPrecision::IsGreater(b.y2(), c.y()) && TeGeometryAlgorithmsPrecision::IsGreater(c.y(), b.y1()));
+}
+
+bool TeWithin(const TeCoord2D& c, const TeLine2D& l)
+{
+	return TeRelation(c, l) == TeINSIDE;
+}
+
+bool TeWithin(const TeCoord2D& c, const TePolygon& pol)
+{
+	return TeRelation(c, pol) == TeINSIDE;
+}
+
+bool TeWithin(const TePoint& p1, const TePoint& p2)
+{
+	return TeWithin(p1.location(), p2.location());
+}
+
+bool TeWithin(const TePoint& p, const TeLine2D& l)
+{
+	return TeWithin(p.location(), l);
+}
+
+bool TeWithin(const TePoint& p, const TePolygon& pol)
+{
+	return TeWithin(p.location(), pol);
+}
+
+bool TeWithin(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeWithinOrCoveredByOrEquals(redLine.box(), blueLine.box()))
+		return TeRelation(redLine, blueLine, TeWITHIN) == TeWITHIN;	
+	else
+		return false;
+}
+
+bool TeWithin(const TeLine2D& l, const TePolygon& pol)
+{
+	if(TeWithinOrCoveredByOrEquals(l.box(), pol.box()))	
+		return TeRelation(l, pol) == TeWITHIN;
+
+
+	return false;
+}
+
+bool TeWithin(const TePolygon& redPol, const TePolygon& bluePol)
+{
+	if(TeWithinOrCoveredByOrEquals(redPol.box(), bluePol.box()))	
+		return TeRelation(redPol, bluePol) == TeWITHIN;
+	else
+		return false;
+}
+
+bool TeWithin(const TeBox& bx1, const TeBox& bx2)
+{
+	// bx1 left wall is left of or on bx2 left wall
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx2.x1(), bx1.x1()))
+		return false;
+
+	// bx1 right wall is right of or on bx2 right wall
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx1.x2(), bx2.x2()))
+		return false;
+
+	// bx1 is below bx2 or on.
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx2.y1(), bx1.y1()))
+		return false;
+
+	// bx1 is above bx2 or on
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx1.y2(), bx2.y2()))
+		return false;
+
+	return true;	
+}
+
+bool TeWithin(const TeCell& cell1, const TeCell& cell2)
+{
+	return TeWithin(cell1.box(), cell2.box());
+}
+
+bool TeWithin(const TeLine2D& line, const TeCell& cell)
+{
+	return TeWithin(line, TeMakePolygon(cell.box()));
+}
+
+
+bool TeWithin(const TeCell& cell, const TePolygon& poly)
+{
+	return TeWithin(TeMakePolygon(cell.box()), poly);
+}
+
+bool TeWithin(const TePoint& point, const TeCell& cell)
+{
+	return TeWithin(point.location(), cell.box());
+}
+
+
+// OVERLAPS
+bool TeOverlaps(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeDisjoint(redLine.box(), blueLine.box()))
+		return false;
+	else
+		return TeRelation(redLine, blueLine, TeOVERLAPS) == TeOVERLAPS;
+}
+
+bool TeOverlaps(const TePolygon& redPol, const TePolygon& bluePol)
+{
+	//if(TeDisjoint(redPol.box(), bluePol.box()))
+	if(TeDisjointOrTouches(redPol.box(), bluePol.box()))
+		return false;
+	else
+		return TeRelation(redPol, bluePol) == TeOVERLAPS;
+}
+
+bool TeOverlaps(const TeCell& cell1, const TeCell& cell2)
+{
+	return TeOverlaps(TeMakePolygon(cell1.box()), TeMakePolygon(cell2.box()));
+}
+
+bool TeOverlaps(const TeCell& cell, const TePolygon& poly)
+{
+	return TeOverlaps(TeMakePolygon(cell.box()), poly);
+}
+
+
+// COVERED BY
+bool TeCoveredBy(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(TeWithinOrCoveredByOrEquals(redLine.box(), blueLine.box()))
+		return TeRelation(redLine, blueLine, TeCOVEREDBY) == TeCOVEREDBY;
+	else
+		return false;
+}
+
+bool TeCoveredBy(const TeLine2D& l, const TePolygon& pol)
+{
+	if(TeWithinOrCoveredByOrEquals(l.box(), pol.box()))
+		return TeRelation(l, pol) == TeCOVEREDBY;
+	else
+		return false;
+}
+
+bool TeCoveredBy(const TePolygon& redPol, const TePolygon& bluePol)
+{
+	if(TeWithinOrCoveredByOrEquals(redPol.box(), bluePol.box()))
+		return TeRelation(redPol, bluePol) == TeCOVEREDBY;
+	else
+		return false;
+}
+
+bool TeCoveredBy(const TeCell& cell1, const TeCell& cell2)
+{
+	return TeCoveredBy(TeMakePolygon(cell1.box()), TeMakePolygon(cell2.box()));
+}
+
+bool TeCoveredBy(const TePolygon& poly, const TeCell& cell)
+{
+	return TeCoveredBy(poly, TeMakePolygon(cell.box()));
+}
+
+bool TeCoveredBy(const TeLine2D& line, const TeCell& cell)
+{
+	return TeCoveredBy(line, TeMakePolygon(cell.box()));
+}
+
+//---------- Box Tests ----------//
+
+bool TeDisjointOrTouches(const TeBox& bx1, const TeBox& bx2)
+{
+	// B1 to the right of or on B2
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx1.x1(), bx2.x2())) 
+		return true;
+
+	// B1 to the left of or on B2
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx2.x1(), bx1.x2())) 
+		return true;
+
+	// B2 is above or on B1
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx2.y1(), bx1.y2())) 
+		return true;
+
+	// B2 is below or on B1 
+	if(TeGeometryAlgorithmsPrecision::IsGreaterEqual(bx1.y1(), bx2.y2())) 
+		return true;
+
+	return false;
+}
+
+template<>
+bool TeWithinOrCoveredByOrEquals(const TeBox& bx1, const TeBox& bx2)
+{
+	// bx1 left wall is left of bx2 left wall
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.x1(), bx1.x1()))
+		return false;
+
+	// bx1 right wall is right of bx2 right wall
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.x2(), bx2.x2()))
+		return false;
+
+	// bx1 is below bx2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx2.y1(), bx1.y1()))
+		return false;
+
+	// bx1 is above bx2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(bx1.y2(), bx2.y2()))
+		return false;
+
+	return true;	
+}
+
+template<>
+bool TeWithinOrCoveredByOrEquals(const TeLine2D& line1, const TeLine2D& line2)
+{
+	if(TeWithinOrCoveredByOrEquals(line1.box(), line2.box()))
+	{
+		short r;
+		short rel = TeRelation(line1, line1, r);
+
+		if((rel&TeWITHIN) || (rel&TeCOVEREDBY) || (rel&TeEQUALS))
+		   return true;
+
+		return false;
+	}
+	return false;
+}
+
+template<>
+bool TeWithinOrCoveredByOrEquals(const TeLine2D& line1, const TePolygon& pol)
+{
+	if(TeWithinOrCoveredByOrEquals(line1.box(), pol.box()))
+	{
+		short rel = TeRelation(line1, pol);
+
+		if((rel&TeWITHIN) || (rel&TeCOVEREDBY))
+		   return true;
+
+		return false;
+	}
+	return false;
+}
+
+template<>
+bool TeWithinOrCoveredByOrEquals(const TePolygon& pol1, const TePolygon& pol2)
+{
+	if(TeWithinOrCoveredByOrEquals(pol1.box(), pol2.box()))
+	{
+		short rel = TeRelation(pol1, pol2);
+
+		if((rel&TeWITHIN) || (rel&TeCOVEREDBY) || (rel&TeEQUALS))
+		   return true;
+
+		return false;
+	}
+	return false;
+}
+
+
+bool TeWithinOrTouches(const TeCoord2D& c, const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	// c is to the right of c1 and c2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(c.x(), c1.x()) && TeGeometryAlgorithmsPrecision::IsGreater(c.x(), c2.x()))
+		return false;
+
+	// c is above c1 and c2
+	if(TeGeometryAlgorithmsPrecision::IsGreater(c.y(), c1.y()) && TeGeometryAlgorithmsPrecision::IsGreater(c.y(), c2.y()))
+		return false;
+
+	// c is to the left of c1 and c2
+	if(TeGeometryAlgorithmsPrecision::IsSmaller(c.x(), c1.x()) && TeGeometryAlgorithmsPrecision::IsSmaller(c.x(), c2.x()))
+		return false;
+
+	// c is below c1 and c2
+	if(TeGeometryAlgorithmsPrecision::IsSmaller(c.y(), c1.y()) && TeGeometryAlgorithmsPrecision::IsSmaller(c.y(), c2.y()))
+		return false;
+
+	return true;	
+}
+
+
+//---------- Intersection Functions ----------//
+
+bool TeIntersection(const TeBox& bx1, const TeBox& bx2, TeBox& bout)
+{
+	if(TeDisjoint(bx1, bx2))
+		return false;
+
+	double x1 = MAX(bx1.x1(),bx2.x1());
+	double x2 = MIN(bx1.x2(),bx2.x2());
+	double y1 = MAX(bx1.y1(),bx2.y1());
+	double y2 = MIN(bx1.y2(),bx2.y2());
+
+	bout = TeBox(x1, y1, x2, y2);
+
+	return true;
+}
+
+TeCoordPairVect	TeGetIntersections(const TePolygon &poly, const double& y)
+{
+	TeCoordPairVect		Segments;
+	vector<double>		crossList, segListInY;
+	unsigned int		nholes = poly.size();
+			
+	//for each ring of the polygon
+	for (unsigned int count=0; count<nholes; count++ ) 		
+	{
+		TeLinearRing coords = poly[count];
+		//for each segment of the ring
+		for  (unsigned int j=0;  j < (coords.size() - 1); j++ ) 		
+		{
+			// Get one segment
+			TeCoord2D coord0 = coords[j];
+			TeCoord2D coord1 = coords[j+1];
+
+			bool yflag0 = ( coord0.y() > y );  
+			bool yflag1 = ( coord1.y() > y ); 
+
+			//treating a special case: when the segment touches or is ON the y axe  
+			//if there is a special case, we must test if the middle point
+			//of each segment is inside or outside of the polygon 
+			if((coord0.y()!=y) && (coord1.y()==y)) 
+			{
+				bool pointsInY = true;
+				bool lowerY1 = coord0.y()<y;
+                unsigned int i = j+2;
+				
+				TeCoord2D lastPointInY;
+				TeCoord2D firstPointOutY = coord1;
+				
+				while(pointsInY) 
+				{
+					lastPointInY = firstPointOutY; 
+
+					// Get the next point 
+					if(i>=coords.size())
+						i=1;
+                    firstPointOutY = coords[i];
+					++i;
+
+					//Verify if it is on the y axe
+					pointsInY = firstPointOutY.y()==y;
+				}
+
+				bool lowerY2 = firstPointOutY.y()<y;
+				//the segment touches the y axe only in one point and cross the axe Y
+				if((lastPointInY==coord1) && (lowerY1!=lowerY2)) 
+					crossList.push_back(coord1.x());	
+				else 
+				{
+					segListInY.push_back (coord1.x());
+					segListInY.push_back (lastPointInY.x());
+				}
+			}
+			else if(coord0.y()==y)
+				continue;
+			// line crosses ring horizontally 
+			else if ( yflag0 != yflag1 )
+			{ 
+				double slope =  ( coord1.x() - coord0.x() ) / ( coord1.y() - coord0.y());
+				double xcross = ( y -   coord0.y() )* slope + coord0.x();
+				crossList.push_back (xcross);	
+			}
+		}
+	}
+	
+	if(crossList.empty())
+		crossList = segListInY;
+	else if(!segListInY.empty())
+	{
+		//insert segListInY in the cross list 
+		for(unsigned i=0; i<segListInY.size(); ++i) 
+			crossList.push_back (segListInY[i]);
+
+		sort (crossList.begin(), crossList.end());
+
+		vector<double> aux;
+		//Verify if the segment middle point intersects the polygon 
+		for(unsigned i=1; i<crossList.size(); ++i)
+		{
+			//calculates the middle point
+			double x0 = crossList[i-1];
+			double x1 = crossList[i];
+			double x = x0 + (x1-x0)/2;
+			
+			TeCoord2D pt (x, y);
+			if (!TeDisjoint(pt, poly)) 
+			{
+				aux.push_back (x0);
+				aux.push_back (x1);
+			}
+		}
+		crossList.clear();
+		crossList = aux;
+    }
+	
+	// Sort the x-intersections
+	sort (crossList.begin(), crossList.end());
+	
+	// Make the result segments
+	vector<double>::iterator it = crossList.begin();
+	while ( it != crossList.end())
+	{
+		TeCoordPair cp;
+
+		cp.pt1 = TeCoord2D ( (*it), y);
+		++it;
+		if ( it == crossList.end() ) 
+			break;
+
+		cp.pt2 = TeCoord2D ( (*it), y);
+		++it;
+
+		Segments.push_back ( cp );
+	}
+	return Segments;
+}
+
+//---------- Union Operators ----------//
+
+TeBox TeUnion(const TeBox& bx1, const TeBox& bx2)
+{
+	double x1 = MIN(bx1.x1(), bx2.x1());
+	double y1 = MIN(bx1.y1(), bx2.y1());
+		
+	double x2 = MAX(bx1.x2(), bx2.x2());
+	double y2 = MAX(bx1.y2(), bx2.y2());		
+
+	return TeBox(x1, y1, x2, y2);
+}
+
+
+//---------- Localization Functions ----------//
+
+bool TePointInPoly(const TeCoord2D& c, const TeLinearRing& r)
+{
+	if(r.size() < 4)
+		return false;
+
+	register double	ty, tx;
+
+	register const unsigned int nVertices = r.size();
+
+	register bool inside_flag = false;
+
+	register int j, yflag0, yflag1;
+
+	TeLinearRing::iterator vtx0, vtx1;
+
+	tx = c.x();
+    ty = c.y();
+    
+	vtx0 = r.end() - 2;
+
+    yflag0 = (vtx0->y() >= ty);
+
+    vtx1 = r.begin();
+
+    for(j = nVertices; --j; )
+	{
+		yflag1 = (vtx1->y() >= ty);
+		
+		if(yflag0 != yflag1)
+		{
+			if(((vtx1->y() - ty) * (vtx0->x() - vtx1->x()) >=
+		        (vtx1->x() - tx) * (vtx0->y() - vtx1->y())) == yflag1)
+			{
+				inside_flag = !inside_flag ;
+			}
+		}
+
+		yflag0 = yflag1 ;
+		vtx0 = vtx1 ;
+		vtx1++;
+    }
+
+	return inside_flag;
+}
+
+bool TeIsOnSegment(const TeCoord2D& c, const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	if(TeWithinOrTouches(c, c1, c2))
+	{
+		bool aux = false;
+
+		return TeINTERSECTOR2::TeCCW(c1, c2, c, aux) == TeNOTURN;
+	}
+
+	return false;	
+}
+
+bool TeIsOnLine(const TeCoord2D& c, const TeLine2D& l)
+{
+	if(l.size() < 2)
+		return false;
+
+	if(TeDisjoint(c, l.box()))
+		return false;
+
+	TeLine2D::iterator it = l.begin();
+
+	unsigned int nstep = l.size() - 1;
+
+	for(unsigned int i = 0; i < nstep; ++i)
+	{
+		if(TeIsOnSegment(c, *(it), *(it + 1)))
+			return true;
+		
+		++it;
+	}
+	
+	return false;
+}
+
+bool TeLocateLineSegment (TeCoord2D& pin, TeLine2D& line, int& segment, double /*tol*/)
+{
+	if (line.size() < 2) 
+		return false;
+
+	TeCoord2D pout;
+		
+	segment = 0;
+	double min_dist = TeMinimumDistance(line[0], line[1], pin, pout);
+	
+	for (unsigned int i = 2; i < line.size(); i++)
+	{
+		double dist;
+		if ((dist = TeMinimumDistance (line[i-1],line[i], pin, pout)) < min_dist)
+		{		
+				min_dist = dist;
+				segment = i - 1;
+		}
+	}
+
+	return true;
+}
+
+
+//---------- Area Functions ----------//
+
+template<> double TeGeometryArea(const TePolygon& p)
+{
+	if(p.size() > 0)
+	{
+		TePolygon::iterator it = p.begin();
+	
+		double area = fabs(Te2Area(*it));
+
+		++it;
+		
+		// subtract inner rings area.
+		while(it != p.end())
+		{
+			area -= fabs(Te2Area(*it));
+			++it;
+		}
+
+		return (area / 2.0);
+	}
+	
+	return 0.0;
+}
+
+template<> double TeGeometryArea(const TePolygonSet& ps)
+{
+	TePolygonSet::iterator it = ps.begin();
+	
+	double area = 0.0;
+	
+	while(it != ps.end())
+	{
+		area += TeGeometryArea(*it);
+		++it;
+	}
+
+	return (area);
+}
+
+template<> double TeGeometryArea(const TeBox& b)
+{
+	return ((b.x2() - b.x1()) * (b.y2() - b.y1()));
+}
+
+template<> double TeGeometryArea(const TeMultiGeometry& mGeom)
+{
+	if(mGeom.hasPolygons())
+	{
+		TePolygonSet pSet;
+		mGeom.getGeometry(pSet);
+		return TeGeometryArea(pSet);
+	}
+	else if(mGeom.hasCells())
+	{
+		TeCellSet cSet;
+		mGeom.getGeometry(cSet);
+		return TeGeometryArea(cSet);
+	}
+	return 0.;
+}
+
+//---------- ConvexHull ----------//
+
+//! If we have the  two end point equals, so we remove it.
+void removeDuplicatedCoords(vector<TeCoord2D>& coordSet)
+{
+	if(coordSet[0] == coordSet[coordSet.size() - 1])
+		coordSet.erase(coordSet.end() - 1);
+
+	return;
+}
+
+// Return a linear ring that is the convex hull of a given list of coords
+TePolygon ConvexHull(vector<TeCoord2D>& coordSet)
+{
+	// sorting the coords
+	sort(coordSet.begin(), coordSet.end(), xOrder<TeCoord2D>());
+
+	register unsigned int i = 0;
+	register unsigned int n = coordSet.size();
+
+	TeLine2D upperHull;
+	TeLine2D lowerHull;
+
+	lowerHull.add(coordSet[0]);
+	lowerHull.add(coordSet[1]);
+
+	unsigned int count = 2;
+
+	bool aux = false;
+	
+	for(i = 2; i < n; ++i)
+	{
+		lowerHull.add(coordSet[i]);
+
+		++count;
+
+		while(count > 2 && TeINTERSECTOR2::TeCCW(lowerHull[count - 3], lowerHull[count - 2], lowerHull[count - 1], aux) <= TeNOTURN)
+		{
+			lowerHull.erase(count - 2);
+			--count;
+		}
+	}
+
+	upperHull.add(coordSet[n - 1]);
+	upperHull.add(coordSet[n - 2]);
+
+	count = 2;
+
+	for(i = n - 2;  i > 0;  --i)
+	{
+		upperHull.add(coordSet[i - 1]);
+		++count;
+
+		while(count > 2 && TeINTERSECTOR2::TeCCW(upperHull[count - 3], upperHull[count - 2], upperHull[count - 1], aux) <= TeNOTURN)
+		{
+			upperHull.erase(count - 2);
+			--count;
+		}
+	}
+
+	
+	upperHull.erase(0);
+	upperHull.erase(upperHull.size() - 1);
+	
+	lowerHull.copyElements(upperHull);
+	lowerHull.add(lowerHull[0]);
+
+	TeLinearRing aux_ring(lowerHull);
+	TePolygon p;
+	p.add(aux_ring);
+	return p;
+}
+
+template<class T> TePolygon TeConvexHull(const T& coordSet)
+{
+	// creates an auxiliary line with the points of the ring
+	vector<TeCoord2D> aux;
+
+	typename T::iterator it = coordSet.begin();
+	
+	while(it != coordSet.end())
+	{
+		aux.push_back(*it);
+		++it;
+	}
+
+	// removes duplicated coords from structs like ring
+	removeDuplicatedCoords(aux);
+
+	return ConvexHull(aux);
+}
+
+template<> TePolygon TeConvexHull(const TePolygon& p)
+{
+	vector<TeCoord2D> coords;
+	back_insert_iterator<vector<TeCoord2D> > it(coords);
+	// Copy the first ring of each polygon without the last point (that is equals to the first).
+	
+	copy(p[0].begin(), p[0].end() - 1, it);
+
+	return ConvexHull(coords);
+}
+
+template<> TePolygon TeConvexHull(const TePolygonSet& ps)
+{
+	vector<TeCoord2D> coords;
+	back_insert_iterator<vector<TeCoord2D> > it(coords);
+	// Copy the first ring of each polygon without the last point (that is equals to the first).
+	
+	TePolygonSet::iterator it_ps = ps.begin();
+	while(it_ps != ps.end())
+	{
+		TeLinearRing r = (*it_ps)[0];
+		copy(r.begin(), r.end() - 1, it);
+		++it_ps;
+	}
+
+	return ConvexHull(coords);
+}
+
+template<> TePolygon TeConvexHull(const TePointSet& ps)
+{
+	vector<TeCoord2D> coords;
+	// Copy the first ring of each polygon without the last point (that is equals to the first).
+	
+	TePointSet::iterator itr = ps.begin();
+	
+	while(itr != ps.end())
+	{
+		coords.push_back(itr->location());
+
+		++itr;
+	}
+
+	return ConvexHull(coords);
+}
+
+//---------- Utilities Functions ----------//
+
+
+
+//---------- Validation Functions ----------//
+
+bool TeIsConvex(const TeLinearRing& ring)
+{
+	bool aux = false;
+
+	short orientation = TeINTERSECTOR2::TeCCW(*(ring.end() - 2), ring[0], ring[1], aux);
+
+	const unsigned int nStep = ring.size() - 1;
+	
+	for(unsigned int i = 1; i <  nStep; ++i)
+	{
+		short this_orientation = TeINTERSECTOR2::TeCCW(ring[i-1], ring[i], ring[i+1], aux);
+		
+		if(this_orientation == TeNOTURN)
+			continue;
+
+		if((orientation != TeNOTURN) && (orientation != this_orientation))
+			return false;
+
+		orientation = this_orientation;		
+	}
+
+	return true;
+}
+
+short TeOrientation(const TeLinearRing& r)
+{
+	double area = Te2Area(r);
+
+	if(area >  0.0)
+		return TeCOUNTERCLOCKWISE; 
+
+	if(area < 0.0)
+		return TeCLOCKWISE;  
+
+	return TeNOTURN;
+}
+
+void TeGetMiddlePoint(const TeCoord2D &first, const TeCoord2D &last, TeCoord2D &middle)
+{
+	double	lenght,parts,curlenght,incx,incy,
+			deltax,deltay,dx,dy;
+	short	i,nparts;
+	
+	lenght = TeDistance(first,last);
+	if(lenght == 0.)
+	{
+		middle = first;
+		return;
+	}
+
+	nparts = 2;	
+	parts = lenght/2.;
+// verify segment orientation
+	if(first.x() < last.x())
+		incx = 1.;
+	else
+		incx = -1.;
+
+	if(first.y() < last.y())
+		incy = 1.;
+	else
+		incy = -1.;
+
+	curlenght = 0.;
+	deltax = fabs(first.x()-last.x());
+	deltay = fabs(first.y()-last.y());
+	for(i=0;i<(nparts-1);i++)
+	{
+		curlenght = curlenght + parts;
+		// vertical segment
+		if(first.x() == last.x())
+		{
+			middle = TeCoord2D(first.x(),first.y()+(curlenght*incy));
+			continue;
+		}
+				
+		// horizontal segment
+		if(first.y() == last.y())
+		{
+			middle = TeCoord2D(first.x()+(curlenght*incx),first.y());
+			continue;
+		}
+		
+		// inclined segment
+		
+		// calculating X coordinate
+		dx = curlenght*deltax/lenght;
+		
+		// calculating Y coordinate
+		dy = curlenght*deltay/lenght;
+		middle = TeCoord2D(first.x()+(dx*incx),first.y()+(dy*incy));
+	}
+}
+
+//---------- Metric Functions ----------//
+
+double TeDistance(const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	return sqrt(((c2.x() - c1.x()) * (c2.x() - c1.x())) + ((c2.y()-c1.y()) * (c2.y() - c1.y())));
+}
+
+double TeLength(const TeLine2D& l)
+{
+	double len = 0.0;
+
+	unsigned int nStep = l.size() - 1;
+
+	for(unsigned int i = 0 ; i < nStep; ++i)
+		len += TeDistance(l[i], l[i+1]);
+	
+	return len;
+}
+
+double TePerpendicularDistance(const TeCoord2D& first, const TeCoord2D& last, const TeCoord2D& pin, TeCoord2D &pinter)
+{
+	double	d12,xmin,ymin;
+
+	double xi = first.x();
+	double xf = last.x();
+	double yi = first.y();
+	double yf = last.y();
+	double x = pin.x();
+	double y = pin.y();
+		
+	double dx = xf - xi;
+	double dy = yf - yi;
+	double a2 = (y - yi) * dx - (x - xi)*dy;
+	
+    if(dx==0. && dy==0.)
+	{
+		d12= sqrt(((x - xi) * (x - xi)) + ((y - yi) * (y - yi)));
+		d12 *= d12;
+	}
+	else
+		d12= a2 * a2 / (dx * dx + dy * dy);
+
+	if (dx == 0.)
+	{
+		xmin = xi;
+		ymin = y;
+	}
+	else if (dy == 0.)
+	{
+		xmin = x;
+		ymin = yi;
+	}
+	else
+	{
+		double alfa = dy / dx;
+		xmin = (x + alfa * (y - yi) + alfa * alfa * xi) / (1. + alfa * alfa);
+		ymin = (x - xmin) / alfa + y;	
+	}
+	
+	pinter = TeCoord2D(xmin, ymin);		
+	return (sqrt(d12));
+}
+
+double TeMinimumDistance (const TeCoord2D& first, const TeCoord2D& last, const TeCoord2D& pin, TeCoord2D& pout, double /*tol*/)
+{
+	TeCoord2D	pinter;
+	TeBox 		sbox(MIN(first.x(),last.x()),
+					 MIN(first.y(),last.y()),
+					 MAX(first.x(),last.x()),
+					 MAX(first.y(),last.y()));
+
+	double d = TePerpendicularDistance (first, last, pin, pinter);
+	double dmin = TeMAXFLOAT;
+
+	// Perpendicular minimum distance point was found.
+	if (TeIntersects (pinter, sbox))
+	{
+		dmin = d;
+		pout = pinter;
+	}
+	else  
+	{
+		// Perpendicular minimum distance point could not be found. 
+		// The segment vertices distances will analyzed
+		double d1 = TeDistance (first, pin);
+		double d2 = TeDistance (last, pin);
+		if (d1 <= d2) 
+		{
+			dmin = d1;
+			pout = first;
+		}
+		else if (d2 < dmin) 
+		{
+			dmin = d2;
+			pout = last;
+		}
+	}
+
+	return dmin;
+}
+
+
+//---------- Relation Functions ----------//
+
+short TeRelation(const TeCoord2D& c, const TeLine2D& l)
+{
+	if(TeEquals(c, l[0]) || TeEquals(c, l[l.size() - 1]))
+	{
+		// Ring doesn't have bundaries, only interiors.
+		if(l.isRing())
+			return TeINSIDE;
+
+		return TeBOUNDARY;
+	}
+
+	if(TeIsOnLine(c, l))
+		return TeINSIDE;
+
+	return TeOUTSIDE;
+}
+
+short TeRelation(const TeCoord2D& c, const TeLinearRing& r)
+{
+	if(TeDisjoint(c, r.box()))
+		return TeOUTSIDE;
+
+	if(TeIsOnLine(c, r))
+		return TeBOUNDARY;
+
+	if(TePointInPoly(c, r))
+		return TeINSIDE;
+	else
+		return TeOUTSIDE;
+}
+
+short TeRelation(const TeCoord2D& c, const TePolygon& pol)
+{
+	short rel = TeRelation(c, pol[0]);
+	
+	if(rel != TeINSIDE)
+		return rel;
+	else	// If point is inside exterior ring
+	{
+		unsigned int size = pol.size();
+
+		for(unsigned int i = 1; i < size; ++i)
+		{
+			rel = TeRelation(c, pol[i]);
+		
+			switch(rel)
+			{
+				// If point is inside a hole so it is on polygon's outside.
+				case TeINSIDE    :	return TeOUTSIDE;
+
+				// If point is on boundary so it is on polygon's boundary.
+				case TeBOUNDARY  :  return TeBOUNDARY;
+			}
+		}
+	}
+
+	// If the point is inside exterior ring and is not on one of the holes so it is in polygon's interior.
+	return TeINSIDE;
+}
+
+short TeRelation(const TePoint& p, const TePolygon& pol)
+{ 
+	return (TeRelation(p.location(), pol)); 
+}
+
+short TeRelation(const TeCoord2D& c, const TePolygonSet& pSet)
+{
+	if(TeDisjoint(c, pSet.box()))
+		return TeOUTSIDE;
+
+	unsigned int size = pSet.size();
+
+	for(unsigned int i = 0; i < size; ++i)
+	{
+		short rel = TeRelation(c, pSet[i]);
+		
+		if(rel & TeINSIDE)
+			return TeINSIDE;
+		
+		if(rel & TeBOUNDARY)
+			return TeBOUNDARY;
+	}
+
+	return TeOUTSIDE;
+}
+
+short TeRelation(const TeLine2D& lRed, const TeLine2D& lBlue, const short& relation)
+{
+	TeINTERSECTOR2::TeVectorBoundaryIP report;
+
+	if(TeINTERSECTOR2::TeSafeIntersections(lRed, lBlue, report))
+	{
+		short rel = Relation(lRed, lBlue, report, relation);		
+
+		// Stop to check, because touches can't occur anymore
+		if((relation == TeTOUCHES || relation == TeCROSSES) && rel != relation)
+			return TeUNDEFINEDREL;
+
+		if(rel != TeUNDEFINEDREL)
+			return rel;
+
+		TeINTERSECTOR2::TeVectorBoundaryIP::iterator it = report.begin();
+		TeINTERSECTOR2::TeVectorBoundaryIP::iterator it_end = report.end();
+		
+		for(unsigned int i = 0; i < report.size(); ++i)
+		{
+			swap(report[i].redPartNum_, report[i].bluePartNum_);
+			swap(report[i].redSegNum_, report[i].blueSegNum_);
+		}
+
+		rel = Relation(lBlue, lRed, report, relation);
+
+		if(rel != TeUNDEFINEDREL)
+			return ConverseRelation(rel);
+		else
+			return TeOVERLAPS;
+	}
+	else
+		return TeDISJOINT;
+}
+
+short TeRelation(const TeLine2D& line, const TePolygon& pol)
+{
+	short rel = TopologicRelation(line, pol[0]);
+
+	if(rel & TeTOUCHES || rel & TeCROSSES || rel & TeDISJOINT)
+		return rel;
+
+	// If relation is WITHIN or COVERED BY we need to test inner rings.
+	register unsigned int i = 1;
+	register unsigned int nRings = pol.size();
+
+	for(; i < nRings; ++i)
+	{
+		short rel_aux = TopologicRelation(line, pol[i]);
+
+		switch(rel_aux)
+		{
+			case TeCROSSES   : return TeCROSSES;
+
+			case TeCOVEREDBY : return TeTOUCHES;
+
+			case TeTOUCHES   : rel = TeCOVEREDBY;
+				               break;	// Needs to check other holes.
+
+			case TeWITHIN    : return TeDISJOINT;
+
+			case TeDISJOINT  : break;	// Keeps rel and check other inner rings
+		}
+	}
+
+	return rel;
+}
+
+short TeRelation(const TePolygon& pRed, const TePolygon& pBlue)
+{
+
+	short rel = TopologicRelation(pRed[0], pBlue[0]);
+
+	if(rel & TeTOUCHES || rel & TeOVERLAPS || rel & TeDISJOINT)
+		return rel;
+
+	
+	short rel_external_ring = TeUNDEFINEDREL;
+
+	bool converse = false;
+
+	vector<TeLinearRing> innerRingsToTest;
+
+	switch(rel)
+	{
+		case TeWITHIN		: 
+		case TeCOVEREDBY	:
+	                          // if pBlue has inner rings.
+			                  if(pBlue.size() > 1)
+							  {
+								  rel_external_ring = LookAtInnerRings(pRed[0], pBlue, innerRingsToTest, rel);	
+							  }
+							  else	// else if it hasn't
+							  {
+								  if(pRed.size() > 1)	// but pRed has
+									  return TeOVERLAPS;	// they overlaps
+								  else
+									  return rel;
+							  }
+							  break;
+
+		case TeCONTAINS		:
+		case TeCOVERS		: 
+							  // if pRed has inner rings.
+			                  if(pRed.size() > 1)
+							  {
+								  rel_external_ring = LookAtInnerRings(pBlue[0], pRed, innerRingsToTest, rel);							      
+							  }
+							  else	// else if it hasn't
+							  {
+								  if(pBlue.size() > 1)	// but pBlue has
+									  return TeOVERLAPS;	// they overlaps
+								  else
+									  return rel;
+							  }
+
+							  converse = true;
+							  break;
+
+		case TeEQUALS		:
+			                  if(pRed.size() != pBlue.size())
+								  return TeOVERLAPS;
+
+							  if(pRed.size() == 1 && pBlue.size() == 1)
+								  return rel;
+
+							  for(unsigned int k = 1; k < pBlue.size(); k++)
+								  innerRingsToTest.push_back(pBlue[k]);
+
+							  rel_external_ring = TeUNDEFINEDREL;
+	}
+	
+	if(rel_external_ring != TeUNDEFINEDREL)	
+		return rel_external_ring;	
+
+	// If we are here, so we need to test 
+	if(converse)	// COVERS or CONTAINS
+	{
+		if(pBlue.size() == 1 && innerRingsToTest.size() == 0)
+			return rel;
+
+		// The result may be: overlap or equals.
+		short rel_aux = TestInnerRings(pBlue, innerRingsToTest);
+
+		if(rel_aux & TeOVERLAPS)
+			return TeOVERLAPS;
+
+		if(rel_aux & TeCOVERS)
+			return TeCOVERS;
+
+		if(rel_aux & TeCONTAINS)
+			return TeCONTAINS;
+	}
+	else	// EQUALS, COVERED BY or WITHIN
+	{
+		if(pRed.size()  == 1 && innerRingsToTest.size() == 0)
+			return rel;
+
+		short rel_aux = TestInnerRings(pRed, innerRingsToTest);
+
+		if(rel_aux & TeOVERLAPS)
+			return TeOVERLAPS;
+
+		if((rel_aux == TeEQUALS) && (rel == TeEQUALS))
+			return TeEQUALS;
+
+		if((rel_aux & TeCOVERS) || (rel_aux & TeEQUALS))
+			return TeCOVEREDBY;	
+
+		if(rel_aux & TeCONTAINS)
+		{
+			if((rel == TeEQUALS) || (rel == TeCOVEREDBY))
+				return TeCOVEREDBY;
+
+			return TeWITHIN;
+		}
+	}
+
+	return TeUNDEFINEDREL;
+}
+
+
+//---------- Generate Geometry Functions ----------//
+
+TePolygon TeMakePolygon(const TeBox& b)
+{
+	TeLine2D l;
+	
+	l.add(b.lowerLeft());
+	l.add(TeCoord2D(b.x2(), b.y1()));
+	l.add(b.upperRight());
+	l.add(TeCoord2D(b.x1(), b.y2()));
+	l.add(b.lowerLeft());
+	l.setBox(b);
+
+	TePolygon p;
+	p.add(TeLinearRing(l));
+	p.setBox(b);
+
+	return p;
+}
+
+TeLinearRing TeSimpleClosedPath(const TePointSet& pSet)
+{
+	TeLine2D l;
+
+	for(register unsigned int i = 0; i < pSet.size(); ++i)
+		l.add(pSet[i].location());
+
+	ThetaOrder tr(pSet[0].location());
+
+	sort(l.begin(), l.end(), tr);
+
+	l.add(l[0]);
+
+	return TeLinearRing(l);
+}
+
+
+//---------- Nearest ----------//
+
+bool TeNearest ( TeCoord2D& pt, TeNodeSet& ns , int& k, const double& tol)
+{
+	double d,dmin = TeMAXFLOAT;
+	bool flag = false;
+
+	k = -1;
+	for (unsigned int i=0; i < ns.size() ; i++)
+	{
+		d = TeDistance (pt, ns[i].location());
+		if ( d <= tol && d < dmin)
+		{
+			dmin = d;
+			k = i;
+			flag = true;
+		}
+	}
+	return flag;
+}
+
+bool TeNearest ( TeCoord2D& pt, TePointSet& ps , int& k, const double& tol)
+{
+	double d,dmin = TeMAXFLOAT;
+	bool flag = false;
+
+	k = -1;
+	for (unsigned int i=0; i < ps.size() ; i++)
+	{
+		d = TeDistance (pt, ps[i].location());
+		if ( d <= tol && d < dmin)
+		{
+			dmin = d;
+			k = i;
+			flag = true;
+		}
+	}
+	return flag;
+}
+
+bool TeNearest ( TeCoord2D& pt, TeTextSet& ts , int& k, const double& tol)
+{
+	double d,dmin = TeMAXFLOAT;
+	bool flag = false;
+
+	k = -1;
+	for (unsigned int i=0; i < ts.size() ; i++)
+	{
+		d = TeDistance (pt, ts[i].location());
+		if ( d <= tol && d < dmin)
+		{
+			dmin = d;
+			k = i;
+			flag = true;
+		}
+	}
+	return flag;
+}
+
+bool TeNearest(TeCoord2D& pt, TeLineSet& ls , int& k, TeCoord2D& pi, const double& tol)
+{
+	double d,dmin = TeMAXFLOAT;
+	bool flag = false;
+
+	k = -1;
+	for (unsigned int i=0 ; i<ls.size() ; i++)
+	{
+		TeLine2D line = ls[i];
+		TeBox lb = line.box();
+		TeBox box(lb.x1()-tol,lb.y1()-tol,lb.x2()+tol,lb.y2()+tol);
+		if (TeIntersects(pt, box))
+		{
+			for (unsigned int j=0 ; j<line.size()-1 ; j++)
+			{
+				TeCoord2D	pinter;
+				TeBox		sbox(MIN(line[j].x(),line[j+1].x()),
+								MIN(line[j].y(),line[j+1].y()),
+								MAX(line[j].x(),line[j+1].x()),
+								MAX(line[j].y(),line[j+1].y()));
+				d = TePerpendicularDistance (line[j],line[j+1],pt, pinter);
+				if((d <= tol) && (d < dmin) && TeIntersects(pinter, sbox))
+				{
+					dmin = d;
+					k = i;
+					pi = pinter;
+					flag = true;
+				}
+			}
+		}
+	}
+	return flag;
+}
+
+
+bool TeNearest (TeCoord2D& pt,TeLineSet& ls, int& lindex, TeCoord2D& pout, double& dmin, const double& tol)
+{
+	bool flag = false;
+	TeCoord2D	pinter;
+
+	dmin = TeMAXFLOAT;
+	lindex = -1;
+
+	for (unsigned int i = 0 ; i < ls.size(); i++)
+	{
+		TeLine2D line = ls[i];
+
+		for (unsigned int j = 0 ; j < line.size() - 1 ; j++)
+		{
+			double d = TeMinimumDistance (line[j], line[j + 1], pt, pinter, tol);
+			if (d < dmin)
+			{
+				lindex = i;
+				pout = pinter;
+				dmin = d;
+				flag = true;
+			}
+		}
+	}
+	return flag;
+}
+
+bool TeNearest(TeCoord2D& pt, TePolygonSet& ps , int& k, const double& /*tol*/)
+{
+	bool flag = false;
+
+	k = -1;
+	
+	TePoint ptaux(pt);
+
+	for (unsigned int i=0; i < ps.size() ; i++)
+	{
+		if (TeIntersects(ptaux,ps[i]))
+		{
+			k = i;
+			flag = true;
+		}
+	}
+	return flag;
+}
+
+bool TeNearestByPoints ( TeCoord2D& pt, TeLineSet& ls , int& k, double& dist, const double& tol)
+{
+	double d,dmin = TeMAXFLOAT;
+	bool flag = false;
+
+	k = -1;
+	for (unsigned int i=0 ; i<ls.size() ; i++)
+	{
+		TeLine2D line = ls[i];
+		TeBox lb = line.box();
+		TeBox box(lb.x1()-tol,lb.y1()-tol,lb.x2()+tol,lb.y2()+tol);
+		if (TeIntersects (pt,box))
+		{
+			for (unsigned int j=0 ; j<line.size()-1 ; j++)
+			{
+				d = TeDistance (line[j],pt);
+				if ( d <= tol && d < dmin )
+				{
+					dmin = d;
+					dist = dmin;
+					k = i;
+					flag = true;
+				}
+			}
+		}
+	}
+	return flag;
+}
+
+
+//---------- TIN ----------//
+
+bool TeFindTriangleCenter(const TeCoord2D& vert0, const TeCoord2D& vert1, const TeCoord2D& vert2, TeCoord2D& pc )
+{
+	if ( vert0 == vert1 || vert0 == vert2 )
+		return false; // pontos sao iguais-> retorna
+
+	//	calcula o coeficiente angular perpendicular a reta 1
+ 	bool perpvert1 = false,	// perpendicular vertical ao segmento 1 
+		 perpvert2 = false;	// perpendicular vertical ao segmento 2 
+	double	m1 = 10., m2 =10.;	// normais aos segmentos 1 e 2
+	double prcsion = 1.0e-10;	// Precision to be used for equal comparison
+	double oldPrcsion = TePrecision::instance().precision();
+	TePrecision::instance().setPrecision(prcsion);
+
+	if ( TeCoord2D( 0., vert0.y() ) == TeCoord2D( 0., vert1.y() ) )
+		perpvert1 = true;
+	else 
+		m1 = -(vert1.x() - vert0.x()) / (vert1.y() - vert0.y());
+
+//	calcula o coeficiente angular da perpendicular a reta 2
+	if ( TeCoord2D( 0., vert1.y() ) == TeCoord2D( 0., vert2.y() ) )
+		perpvert2 = true;
+	else
+		m2 = -(vert2.x() - vert1.x()) / (vert2.y() - vert1.y());
+
+	TePrecision::instance().setPrecision(oldPrcsion);
+//	Caso as retas sejam coincidentes, uma circunferencia 
+//	 nao eh definida
+	if (fabs( m1 - m2 ) > prcsion)
+	{
+
+//	passou pelos testes: os pontos definem uma circunferencia
+//	calculo do ponto medio do segmento ponto0-ponto1 (segmento 1)
+		TeCoord2D ptm1 = vert0;
+		ptm1 += vert1;
+		ptm1.scale ( 0.5, 0.5);
+
+//	calculo do ponto medio do segmento ponto1-ponto2 (segmento 2)
+		TeCoord2D ptm2 = vert1;
+		ptm2 += vert2;
+		ptm2.scale ( 0.5, 0.5);
+
+//	calculo das coordenadas do centro: ponto de interseccao das mediatrizes
+//	 dos segmentos ponto0-ponto1 e ponto1-ponto2
+  		if (perpvert1 == true)
+		{
+   			pc.x( ptm1.x() );
+  			pc.y( ptm2.y() + m2 * ( pc.x() - ptm2.x() ) );
+ 		}
+		else if (perpvert2 == true)
+		{
+   			pc.x( ptm2.x() );
+			pc.y( ptm1.y() + m1 * ( pc.x() - ptm1.x() ) );
+		}
+		else
+		{
+			pc.x( (m1*ptm1.x() - m2*ptm2.x() - ptm1.y() + ptm2.y())/(m1-m2) );
+			pc.y( ptm1.y() + m1 * ( pc.x() - ptm1.x() ) );
+		}
+		return true;
+	}
+	return false;
+}
+
+bool TeLineSimplify(TeLine2D& ptlist, double snap, double maxdist)
+{
+//	If snap is zero, don't worry
+	if (snap == 0.0)
+		return true;
+//	If line is too short do nothing
+	int npts = ptlist.size();
+	if ( npts <= 3 )
+		return true;
+	int npte = npts;
+
+	double snap2 = maxdist*maxdist;
+	TeLine2D vxy;
+	vxy.copyElements(ptlist);
+
+//	Check for islands before defining number of points to be used
+	int npt;
+	if ( ptlist.last() == vxy.first() )
+		npt = npte - 1;
+	else
+		npt = npte;
+	ptlist.clear();
+
+//	initialize variables
+	int i     = 0;
+	int numa  = 0;
+	int numpf = npt - 1;
+
+//	define anchor
+	TeCoord2D axy = vxy[numa];
+
+//	define floating point
+	TeCoord2D pfxy = vxy[numpf];
+
+	while (numa < (npt-1))
+	{
+		bool retv (false);
+		double aa1 = 0.;
+		double a = 0.;
+		double b = 0.;
+//		Compute coeficients of straight line y=ax+b
+		if (pfxy.x() == axy.x())
+			retv = true;
+		else
+		{
+			a = (pfxy.y() - axy.y())/(pfxy.x() - axy.x());
+			b = pfxy.y() - a * pfxy.x();
+			aa1	= sqrt(a * a + 1.);
+		}
+
+		double d    = 0;
+		double dmax = 0;
+		int numdmax = numpf;
+
+		int k;
+		for (k = numa + 1; k <= numpf; k++)
+		{
+//			Distance between point and line
+			if (retv)
+				d = fabs(axy.x() - vxy[k].x());
+			else
+				d = fabs(vxy[k].y() - a*vxy[k].x() - b)/aa1;
+
+			if (d > dmax)
+			{
+				dmax	= d;
+				numdmax	= k;
+			}
+		}
+
+		if (dmax <= snap)
+		{
+//			Store selected point
+			if (i > (npt-1))
+				return false;
+			vxy[i++] = axy;
+			
+			double axbx = pfxy.x()-axy.x();
+			double ayby = pfxy.y()-axy.y();
+			double dist2 = axbx*axbx + ayby*ayby;
+			if (dist2 > snap2)
+			{
+				for (k = numpf; k > numa+1; k--)
+				{
+					axbx = vxy[k].x()-axy.x();
+					ayby = vxy[k].y()-axy.y();
+					dist2 = axbx*axbx + ayby*ayby;
+					if (dist2 < snap2)
+						break;
+				}
+//				Shift anchor
+				numa = k;
+				axy = vxy[k];
+			}
+			else
+			{
+//				Shift anchor
+				numa = numpf;
+				axy = vxy[numpf];
+			}
+			numpf = npt - 1;
+		}
+		else
+		{
+//			Shift floating point
+			numpf = numdmax;
+		}
+
+		pfxy = vxy[numpf];
+	}
+
+//	Store results
+	vxy[i] = vxy[numa];
+	npts = i+1;
+
+	if ( vxy[i] == vxy[i-1] )
+		npts = i;
+
+	for (i = 0; i < npts; i++)
+		ptlist.add( vxy[i] );
+
+//	Case islands
+	if (vxy[0] == vxy[npte-1])
+		ptlist.add( vxy[0] );
+
+	return true;
+}
+
+bool TeSegmentsIntersectPoint(const TeCoord2D& fr0, const TeCoord2D& to0, const TeCoord2D& fr1, const TeCoord2D& to1, TeCoord2D& pi)
+{
+//	Adapted from TWO-DIMENSIONAL CLIPPING: A VECTOR-BASED APPROACH
+//	Hans J.W. Spoelder, Fons H. Ullings in:
+//	Graphics Gems I, pp.701, 
+
+	double	a, b, c,
+		px, py, lx, ly, lpx, lpy,
+		s;
+
+	px  = to0.x() - fr0.x();
+	py  = to0.y() - fr0.y();
+	lx  = to1.x() - fr1.x();
+	ly  = to1.y() - fr1.y();
+	lpx = fr0.x() - fr1.x();
+	lpy = fr0.y() - fr1.y();
+
+	a = py * lx - px * ly;
+	b = lpx * ly - lpy * lx;
+	c = lpx * py - lpy * px;
+
+	if (a == 0) // Linhas paralelas
+		return false;
+	else
+	{
+		if (a > 0)
+		{
+			if ((b < 0) || (b > a) || (c < 0) || (c > a))
+				return false;
+		}
+		else
+		{
+			if ((b > 0) || (b < a) || (c > 0) || (c < a))
+				return false;
+		}
+		s = b/a;
+		pi.x(fr0.x() + (px*s));
+		pi.y(fr0.y() + (py*s));
+	}
+	return true;
+}
+
+//---------- Curve ----------//
+
+/*! \fn void TeSwap(TePoint &p1, TePoint &p2)
+    \brief Swaps to points.
+	\param p1 The first point.
+	\param p2 The second point.
+*/
+void TeSwap(TePoint& p1, TePoint& p2)
+{
+	TePoint temp;
+
+	temp = p1;
+	p1 = p2;
+	p2 = temp;
+
+	return;
+}
+
+bool TeGetCenter(TePoint p1, TePoint p2, TePoint p3, TePoint& center)
+{
+	double x, y;
+	double ma=0., mb= 0.;
+	bool result = true;
+
+	//we don't want infinite slopes, or 0 slope for line 1, since we'll divide by "ma" below
+	if ((p1.location().x()==p2.location().x()) || (p1.location().y()==p2.location().y())) 
+		TeSwap(p2,p3);
+	  
+	if (p2.location().x()==p3.location().x()) 
+		TeSwap(p1,p2);
+
+	if (p1.location().x()!=p2.location().x())
+		ma=(p2.location().y()-p1.location().y())/(p2.location().x()-p1.location().x());
+	else 
+		result=false;
+	  
+	if (p2.location().x()!=p3.location().x()) 
+		mb=(p3.location().y()-p2.location().y())/(p3.location().x()-p2.location().x());
+	else 
+	  result=false;
+	  
+	if ((ma==0) && (mb==0)) 
+		result=false;
+	  
+	if (result) 
+	{
+		x=(ma*mb*(p1.location().y()-p3.location().y())+mb*(p1.location().x()+p2.location().x())-ma*(p2.location().x()+p3.location().x()))/(2*(mb-ma));
+		y=-(x-(p1.location().x()+p2.location().x())/2)/ma + (p1.location().y()+p2.location().y())/2;
+		
+		double w= x;  //TeRound(x);
+		double z= y;  //TeRound(y);	
+		TeCoord2D coord(w,z);
+		center.add(coord);
+	}
+  return result;
+}
+
+double TeGetRadius(TePoint& p1, TePoint& p2, TePoint& p3)
+{
+	double s,a,b,c, result;
+	a=sqrt(pow(p1.location().x()-p2.location().x(),2)+pow(p1.location().y()-p2.location().y(),2));  //sqr: square of the param
+	b=sqrt(pow(p2.location().x()-p3.location().x(),2)+pow(p2.location().y()-p3.location().y(),2));
+	c=sqrt(pow(p3.location().x()-p1.location().x(),2)+pow(p3.location().y()-p1.location().y(),2));
+	s=(a+b+c)/2;
+	result=(a*b*c)/(4*sqrt(s*(s-a)*(s-b)*(s-c)));
+	return result;
+}
+
+bool TeGenerateArc(TePoint& p1, TePoint& p2, TePoint& p3, TeLine2D& arcOut, const short& NPoints)
+{	
+	TePoint center;
+	double radius;
+
+	if(!TeGetCenter(p1, p2, p3, center))
+		return false;
+
+	radius = TeGetRadius(p1, p2, p3);
+
+	//calculate the distance between the points p1 and p3
+	double length = TeDistance(p1.location(),p3.location());
+
+	double val = length/(2*radius);
+	if(val>1)
+		return false;
+
+	//calculate the angle (in radians) between the segments (p1 - p3) in the circle center 
+	//asin : arco seno
+	//http://mathforum.org/dr.math/faq/faq.circle.segment.html#7
+	double thetaR = 2 * asin(val);	
+	
+	//calculate the variation of the angle in radians for each point
+	double deltaR = thetaR/(NPoints+1); 
+
+	//verify if is counterclockwise or clockwise
+	TeLine2D line;
+	line.add(p1.location());
+	line.add(p2.location());
+	line.add(p3.location());
+	line.add(p1.location());
+	TeLinearRing ring(line);
+	
+	short orient = TeOrientation(ring);
+
+	//calculate the coseno e seno of the angle (beta) between the circle center (horizontal segment) and the first point  
+	//http://mathforum.org/library/drmath/view/55327.html
+	double cosBeta = (p1.location().x()-center.location().x())/radius; 
+	double sinBeta = (p1.location().y()-center.location().y())/radius;
+
+	//rela�es trigonom�ricas
+	//sin(x+y) = sin(x)cos(y) + cos(x)sin(y),
+    //cos(x+y) = cos(x)cos(y) - sin(x)sin(y),
+	//sin(x-y) = sin(x)cos(y) - cos(x)sin(y),
+	//cos(x-y) = cos(x)cos(y) + sin(x)sin(y),
+
+	arcOut.add(p1.location());
+	double angle = deltaR;
+	for (int i=0; i<(NPoints+1); i++)
+	{
+		double x = 0.,y = 0.;
+		if(orient==TeCOUNTERCLOCKWISE)
+		{
+			//c = h + r*cos(B+A),
+			//d = k + r*sin(B+A),
+			x = center.location().x() + radius * ((cosBeta*cos(angle))-(sinBeta*sin(angle))); //cos(beta+angle) 
+			y = center.location().y() + radius * ((sinBeta*cos(angle))+(cosBeta*sin(angle))); //sin(beta+angle)
+		}
+		else if (orient==TeCLOCKWISE)
+		{
+			//c = h + r*cos(B-A),
+			//d = k + r*sin(B-A),
+			x = center.location().x() + radius * ((cosBeta*cos(angle))+(sinBeta*sin(angle))); //cos(beta-angle)
+			y = center.location().y() + radius * ((sinBeta*cos(angle))-(cosBeta*sin(angle))); //sin(beta-angle)
+		}
+
+		TeCoord2D coord(x,y);
+		arcOut.add(coord);
+		angle += deltaR;
+	}
+	arcOut.add(p3.location());
+	return true;
+}
+
+bool TeGenerateCircle(TePoint& center, const double& radius, TeLine2D& circle, const short& NPoints)
+{
+	//angle (in radians) of the circumference (2*Pi)
+	double thetaR = 2 * 3.14159; 	
+	
+	//calculate the variation of the angle in radians for each point
+	double deltaR = thetaR/(NPoints+1); 
+
+	//calculate a point P1 of the  circumference
+	TePoint p1(center.location().x()+radius, center.location().y());
+	
+	//calculate the coseno e seno of the angle (beta) between the center and the point P1  
+	//http://mathforum.org/library/drmath/view/55327.html
+	double cosBeta = 1;
+	double sinBeta = 0;
+
+	//rela�es trigonom�ricas
+	//sin(x+y) = sin(x)cos(y) + cos(x)sin(y),
+    //cos(x+y) = cos(x)cos(y) - sin(x)sin(y),
+	//sin(x-y) = sin(x)cos(y) - cos(x)sin(y),
+	//cos(x-y) = cos(x)cos(y) + sin(x)sin(y),
+
+	circle.add(p1.location());
+	double angle = deltaR;
+	for (int i=0; i<(NPoints+1); i++)
+	{
+		double x,y;
+		
+		//TeCOUNTERCLOCKWISE
+		//c = h + r*cos(B+A),
+		//d = k + r*sin(B+A),
+		
+		x = center.location().x() + radius * ((cosBeta*cos(angle))-(sinBeta*sin(angle))); //cos(beta+angle) 
+		y = center.location().y() + radius * ((sinBeta*cos(angle))+(cosBeta*sin(angle))); //sin(beta+angle)
+		
+		TeCoord2D coord(x,y);
+		circle.add(coord);
+		angle += deltaR;
+	}
+	circle.add(p1.location());
+	return true;
+}
+
+double TeGetPrecision(TeProjection* proj)
+{
+	if(!proj)
+		return 0.000000001;
+
+	if(proj->units() == "Meters")
+	{
+		return 0.001;
+	}
+	
+	return 0.000000001;	// Lat/Long e NoProjection
+}
+
+
diff --git a/src/terralib/kernel/TeGeometryAlgorithms.h b/src/terralib/kernel/TeGeometryAlgorithms.h
new file mode 100644
index 0000000..886e51f
--- /dev/null
+++ b/src/terralib/kernel/TeGeometryAlgorithms.h
@@ -0,0 +1,1019 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeGeometryAlgorithms.h
+    \brief This file contains Algorithms for Topological Operations.
+	\author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+*/
+#ifndef  __TERRALIB_INTERNAL_GEOMETRYALGORITHMS_H
+#define  __TERRALIB_INTERNAL_GEOMETRYALGORITHMS_H
+
+#include "TeGeometry.h"
+#include "TeMultiGeometry.h"
+
+#include "TePrecision.h"
+#include "TeProjection.h"
+
+//! Intersection coordinates of two segments.
+typedef vector<TeCoord2D> TeIntersCoordsVec;
+
+/** @defgroup GeometryAlgorithms Geometry algorithms
+	TerraLib geometry algorithms.
+	@{
+*/
+
+/** @defgroup TopologicalOperators Topological operators
+    @ingroup  GeometryAlgorithms
+	Functions that test topologival relation between two objects.
+\verbatim
+	The topological operators are based on the intersection of interior, exterior and boundary of geometries:
+  ------------------------------------------------------------------------------------------------------------------
+ | TeGeometry   |  INTERIOR                        | BOUNDARY           | EXTERIOR                                |
+  ------------------------------------------------------------------------------------------------------------------
+ | TePoint      | The point itself                 | Empty              | Everything except interior              |
+ | TeLine2D     | All points except the end points | The two end points | Everything except interior and boundary |
+ | TeLinearRing | All points                       | Empty              | Everything except interior and boundary |
+ | TePolygon    | Everything between the external  | All rings          | Everything except interior and boundary |
+ |              | ring and the inner rings         |                    |                                         |
+  ------------------------------------------------------------------------------------------------------------------
+ 
+We use:
+	- I: for Interior
+	- E: for Exterior
+	- B: for Boundary
+	- inter: Intersects
+	- ^: AND
+	- v: OR
+	- A = refer to two-dimensional geometries (TePolygon and TePolygonSet)
+	- L = refer to one-dimensional geometries (TeLine2D and TeLineSet)
+	- P = refer to 0-dimensional geometries   (TePoint and TePointSet)
+ \endverbatim
+@{
+*/
+
+/** @defgroup TeEquals Equals test
+    @ingroup TopologicalOperators
+    Check if one object is equal another object.
+\verbatim
+ Applies to: P/P, L/L and A/A.
+ TeEquals(x, y) => (x inter y = x) ^ (y inter x = y)
+                   (B(x) inter I(y) = false) ^ (B(x) inter E(y) = false) 
+\endverbatim
+@{
+*/
+//! If a specialized function is not used, returns false.
+template<class T1, class T2>
+inline bool TeEquals(const T1& /*o1*/, const T2& /*o2*/)
+{
+	return false;
+}
+
+//! Check if coordinate 1 and coordinate 2 are equal
+template<>
+TL_DLL bool TeEquals(const TeCoord2D& c1, const TeCoord2D& c2);
+
+//!  Check if point 1 and point 2 are equal
+template<>
+TL_DLL bool TeEquals(const TePoint& p1, const TePoint& p2);
+
+//! Check if lineRed and lineBlue are equal
+template<>
+TL_DLL bool TeEquals(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if polygon red and polygon blue are equal
+template<>
+TL_DLL bool TeEquals(const TePolygon& redPol, const TePolygon& bluePol);
+
+//! Check if polygonset1 and polygonset1 are equal
+template<>
+TL_DLL bool TeEquals( const TePolygonSet& ps1, const TePolygonSet& ps2 );
+
+//! Check if box 1 and box 2 are equal 
+template<>
+TL_DLL bool TeEquals(const TeBox& bx1, const TeBox& bx2);
+
+//! Check if cell 1 and cell 2 are equal
+template<>
+TL_DLL bool TeEquals(const TeCell& cell1, const TeCell& cell2);
+/** @} */ 
+
+/** @defgroup TeDisjoint Disjoint test
+    @ingroup TopologicalOperators
+ Check if two objects are disjoint.
+\verbatim
+ Applies to all geometries.
+ TeDisjoint(x, y) => (x inter y = false)
+                     (I(x) inter I(y) = false) ^ (I(x) inter B(y) = false) ^ (B(x) inter I(y) = false) ^ (B(x) inter B(y) = false)
+\endverbatim
+@{
+*/
+//! Check if coordinate cl and coordinate c2 are disjoint
+TL_DLL bool TeDisjoint(const TeCoord2D& c1, const TeCoord2D& c2);
+
+//! Check if coordinate and box are disjoint
+TL_DLL bool TeDisjoint(const TeCoord2D& c, const TeBox& b);
+
+//! Check if box 1 and box 2 are disjoint
+TL_DLL bool TeDisjoint(const TeBox& bx1, const TeBox& bx2);
+
+//! Check if coordinate and line are disjoint
+TL_DLL bool TeDisjoint(const TeCoord2D& c, const TeLine2D& l);
+
+//! Check if coordinate and polygon are disjoint
+TL_DLL bool TeDisjoint(const TeCoord2D& c, const TePolygon& pol);
+
+//! Check if point l and point 2 are disjoint
+TL_DLL bool TeDisjoint(const TePoint& p1, const TePoint& p2);
+
+//! Check if point and object are disjoint
+TL_DLL bool TeDisjoint(const TePoint& p, const TeLine2D& l);
+
+//! Check if point and object are disjoint
+TL_DLL bool TeDisjoint(const TePoint& p, const TePolygon& pol);
+
+//! Check if lines are disjoint
+TL_DLL bool TeDisjoint(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if line and polygon are disjoint
+TL_DLL bool TeDisjoint(const TeLine2D& l, const TePolygon& pol);
+
+//! Check if polygons are disjoint
+TL_DLL bool TeDisjoint(const TePolygon& redPol, const TePolygon& bluePol);
+
+//! Check if cell 1 and cell 2 are disjoint
+TL_DLL bool TeDisjoint(const TeCell& cell1, const TeCell& cell2);
+
+//! Check if cell and line are disjoint
+TL_DLL bool TeDisjoint(const TeCell& cell, const TeLine2D& line);
+
+//! Check if cell and polygon are disjoint
+TL_DLL bool TeDisjoint(const TeCell& cell, const TePolygon& pol);
+
+//! Check if cell and point are disjoint
+TL_DLL bool TeDisjoint(const TeCell& cell, const TePoint& point);
+/** @} */
+
+
+/** @defgroup TeIntersects Intersects test
+    @ingroup TopologicalOperators
+	Check if one object intersects another object.
+\verbatim
+  Applies to all geometries.
+  TeIntersects(x, y) => !TeDisjoint(x, y)
+                     => (I(x) inter I(y) = true) v (I(x) inter B(y) = true) v (B(x) inter I(y) = true) v (B(x) inter B(y) = true)
+\endverbatim
+@{
+*/
+//! If a specialized function is not used, returns the disjoint negation
+
+template<class T1, class T2>
+bool TeIntersects(const T1& o1, const T2& o2)
+{
+	return !TeDisjoint(o1, o2);
+}
+
+//! Check if coordinate and box intersects
+template<>
+TL_DLL bool TeIntersects(const TeCoord2D& c, const TeBox& b);
+
+//! Check if point and box intersects
+template<>
+TL_DLL bool TeIntersects(const TePoint& p, const TeBox& b);
+
+//! Check if boxes intersects
+template<>
+TL_DLL bool TeIntersects(const TeBox& bx1, const TeBox& bx2);
+/** @} */
+
+
+/** @defgroup TeTouches Touch test
+	@ingroup TopologicalOperators
+	Check if two objects touches.
+\verbatim
+ Applies to A/A, L/L, L/A, P/A, P/L.
+ TeTouches(x, y) => (I(x) inter I(y) = false) ^ (x inter y = true)
+				    => (I(x) inter I(y) = false) ^ ((B(x) inter I(y) = true) v (I(x) inter B(y) = true) v (B(x) inter B(y) = true))
+ \endverbatim
+ @{
+*/
+
+//! Check if coordinate and line touches
+TL_DLL bool TeTouches(const TeCoord2D& c, const TeLine2D& l);
+
+//! Check if coordinate and polygon touches
+TL_DLL bool TeTouches(const TeCoord2D& c, const TePolygon& pol);
+
+//! Check if point and object touches
+TL_DLL bool TeTouches(const TePoint& p, const TeLine2D& l);
+
+//! Check if point and object touches
+TL_DLL bool TeTouches(const TePoint& p, const TePolygon& pol);
+
+//! Check if line and line touches
+TL_DLL bool TeTouches(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if line and polygon
+TL_DLL bool TeTouches(const TeLine2D& l, const TePolygon& pol);
+
+//! Check if polygons touches
+TL_DLL bool TeTouches(const TePolygon& redPol, const TePolygon& bluePol);
+
+//! Check if boxes touches
+TL_DLL bool TeTouches(const TeBox& bx1, const TeBox& bx2);
+
+//! Check if cells touches
+TL_DLL bool TeTouches(const TeCell& c1, const TeCell& c2);
+
+//! Check if cell and line touches
+TL_DLL bool TeTouches(const TeLine2D& line, const TeCell& cell);
+
+//! Check if cell and polygon touches
+TL_DLL bool TeTouches(const TeCell& c1, const TePolygon& poly);
+
+//! Check if cell and point touches
+TL_DLL bool TeTouches( const TePoint& point, const TeCell& c1);
+/** @} */
+
+/** @defgroup TeCrosses Crosses test
+    @ingroup TopologicalOperators
+	Check if one object crosses another object.
+\verbatim
+  TeCrosses(x, y) => dim(I(x) inter I(y)) = (max(dim(I(x)), dim(I(y))) - 1) ^ (x inter y != x) ^ (x inter y != y) 
+  Case 1: x = TeLine2D and y = TePolygon
+          => (I(x) inter I(y) = true) ^ (I(x) inter E(y) = true)
+  Case 2: x = TeLine2D and y = TeLine2D
+          => dim(I(x) inter I(y)) = 0
+\endverbatim
+@{
+*/
+
+//! Check if red line crosses blue line
+TL_DLL bool TeCrosses(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if line crosses polygon
+TL_DLL bool TeCrosses(const TeLine2D& l, const TePolygon& pol);
+
+//! Check if line and cell crosses
+TL_DLL bool TeCrosses(const TeLine2D& l, const TeCell& cell);
+/** @} */
+
+
+/** @defgroup TeWithin Within test
+ *  @ingroup TopologicalOperators
+ *  Check if one object is within another object.
+ \verbatim
+   TeWithin(x, y) => (x inter y = x) ^ (I(x) inter I(y) = true)
+   Case 1: P/P, P/L and P/A
+           => (I(x) inter I(y) = true)
+   Case 2: L/L and A/A
+           => (I(x) inter I(y) = true) ^ (I(x) inter E(y) = false) ^ (B(x) inter E(y) = false) ^ (B(x) inter B(y) = false)
+   Case 3: L/A
+           => (I(x) inter I(y) = true) ^ (I(x) inter E(y) = false) ^ (B(x) inter E(y) = false) ^ (B(x) inter B(y) = false) ^ (I(x) inter B(y) = false)
+\endverbatim
+ @{
+*/
+
+//! Check if coordinate 1 is within coordinate 2
+TL_DLL bool TeWithin(const TeCoord2D& c1, const TeCoord2D& c2);
+
+//! Check if coordinate is within a box
+TL_DLL bool TeWithin(const TeCoord2D& c, const TeBox& b);
+
+//! Check if a cordinate is within a line
+bool TeWithin(const TeCoord2D& c, const TeLine2D& l);
+
+//! Check if a cordinate is within a polygon
+TL_DLL bool TeWithin(const TeCoord2D& c, const TePolygon& pol);
+
+//! Check if point 1 is within point 2
+TL_DLL bool TeWithin(const TePoint& p1, const TePoint& p2);
+
+//! Check if point is within object
+TL_DLL bool TeWithin(const TePoint& p, const TeLine2D& l);
+
+//! Check if point is within object
+TL_DLL bool TeWithin(const TePoint& p, const TePolygon& pol);
+
+//! Check if red line is within blue line
+TL_DLL bool TeWithin(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if line is within polygon
+TL_DLL bool TeWithin(const TeLine2D& l, const TePolygon& pol);
+
+//! Check if red polygon is within blue polygon
+TL_DLL bool TeWithin(const TePolygon& redPol, const TePolygon& bluePol);
+
+//! Check if box1 is within box2
+TL_DLL bool TeWithin(const TeBox& bx1, const TeBox& bx2);
+
+//! Check if cell1 is within cell2
+TL_DLL bool TeWithin(const TeCell& cell1, const TeCell& cell2);
+
+//! Check if line is within cell
+TL_DLL bool TeWithin(const TeLine2D& line, const TeCell& cell);
+
+//! Check if cell is within polygon
+TL_DLL bool TeWithin(const TeCell& cell, const TePolygon& poly);
+
+//! Check if point is within cell
+TL_DLL bool TeWithin(const TePoint& point, const TeCell& cell);
+/** @} */
+
+/** @defgroup TeContains Contains test
+    @ingroup TopologicalOperators
+    Check if one object contains another object.
+    TeContains(x, y) = TeWithin(y, x)
+@{
+*/
+
+//! If a specialized function is not used, returns false
+template<class T1, class T2>
+inline bool TeContains(const T1& o1, const T2& o2)
+{
+	return TeWithin(o2, o1);
+}
+/** @} */
+
+/** @defgroup TeOverlaps Overlaps test
+	@ingroup TopologicalOperators
+    Check if one object overlaps another object.
+\verbatim
+   TeOverlaps(x, y) => (dim(I(x)) = dim(I(y)) = dim(I(x) inter I(y))) ^ (x inter y != x) ^ (x inter y != y)
+   Case 1: (x = TePolygon  and y = TePolygon)
+           => (I(x) inter I(y) = true) ^ (I(x) inter E(y) = true) ^ (E(x) inter I(y) = true)
+   Case 2: x = TeLine2D and y = TeLine2D
+           => (dim(I(x) inter I(y)) = 1) ^ (I(x) inter E(y) = true) ^ (E(x) inter I(y) = true)
+ \endverbatim
+@{
+*/
+
+//! Check if red red overlaps blue line
+TL_DLL bool TeOverlaps(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if red polygon overlaps blue polygon
+TL_DLL bool TeOverlaps(const TePolygon& redPol, const TePolygon& bluePol);
+
+//! Check if cell1 overlaps cell2
+TL_DLL bool TeOverlaps(const TeCell& cell1, const TeCell& cell2);
+
+//! Check if cell overlaps polygon
+TL_DLL bool TeOverlaps(const TeCell& cell, const TePolygon& poly);
+/** @} */
+
+
+/** @defgroup TeCoveredBy Covered by test
+  @ingroup TopologicalOperators
+  Check if one object is covered by another object.
+  \verbatim
+ TeCoveredBy(x, y) => (x inter y = x) ^ (I(x) inter I(y) = true)
+   - Case 1: (x = TePolygon and y = TePolygon) or (x = TeLine2D and y = TeLine2D)
+             => (I(x) inter I(y) = true) ^ (I(x) inter E(y) = false) ^ (B(x) inter E(y) = false) ^ (B(x) inter B(y) = true)
+   - Case 2: x = TeLine2D and y = TePolygon
+             => (I(x) inter I(y) = true) ^ (I(x) inter E(y) = false) ^ (B(x) inter E(y) = false) ^ ((B(x) inter B(y) = true) v (I(x) inter B(y) = true))
+ \endverbatim
+ @{
+ */
+
+//! Check if red line is covered by blue line
+TL_DLL bool TeCoveredBy(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+//! Check if line is covered by polygon
+TL_DLL bool TeCoveredBy(const TeLine2D& l, const TePolygon& pol);
+
+//! Check if red polygon is covered by blue polygon
+TL_DLL bool TeCoveredBy(const TePolygon& redPol, const TePolygon& bluePol);
+
+//! Check if cell1 is covered by cell2
+TL_DLL bool TeCoveredBy(const TeCell& cell1, const TeCell& cell2);
+
+//! Check if polygon is covered by cell
+TL_DLL bool TeCoveredBy(const TePolygon& poly, const TeCell& cell);
+
+//! Check if line is covered by cell
+TL_DLL bool TeCoveredBy(const TeLine2D& line, const TeCell& cell);
+/** @} */
+
+/** @defgroup TeCovers Covers test
+    @ingroup TopologicalOperators
+    Check if one object covers another object.
+    TeCovers(x, y) => TeCoveredBy(y, x)
+@{
+*/
+//! Check if one object covers another object
+template<typename T1, typename T2>
+inline bool TeCovers(T1& o1, T2& o2)
+{
+	return TeCoveredBy(o2, o1);
+}
+/** @} */
+
+/** @defgroup TeRelation Relation test
+ *  @ingroup TopologicalOperators
+ *  Return the relation between two objects.
+ *  @{
+ */
+/** \brief Returns the relation between coordinate c and line l.
+	\param c  The coordinate.
+	\param l  The line.
+	\return one of the relations: INSIDE, OUTSIDE or BOUNDARY.
+	\note It doesn't do box elimination, just uses from TeIsOnLine(coordinate, line) elimination
+ */
+TL_DLL short TeRelation(const TeCoord2D& c, const TeLine2D& l);
+ 
+ /** \brief Point in polygon inside/outside/boundary code.
+	 \param c    The coordinate to test.
+	 \param r    The simple polygon to test.
+	 \return one of the relations: INSIDE, OUTSIDE or BOUNDARY.
+	 \note	The ring is treated as a simple polygon (no holes). Does box elimination.
+*/
+TL_DLL short TeRelation(const TeCoord2D& c, const TeLinearRing& r);
+
+/** \brief Coordinate in polygon inside/outside/boundary code.
+	\param c    The coordinate to test.
+	\param pol  The polygon to test.
+	\return one of the relations: INSIDE, OUTSIDE or BOUNDARY.
+	\note It doesn't do box elimination, just uses from TeRelation(coordinate, line) elimination
+*/
+TL_DLL short TeRelation(const TeCoord2D& c, const TePolygon& pol);
+
+/** \brief Point in polygon inside/outside/boundary code.
+	\param p    The coordinate to test.
+	\param pol  The polygon to test.
+	\return one of the relations: INSIDE, OUTSIDE or BOUNDARY.
+	\note It doesn't do box elimination, just uses from TeRelation(coordinate, line) elimination
+*/
+TL_DLL short TeRelation(const TePoint& p, const TePolygon& pol); 
+
+/** \brief Point in polygon set inside/outside/boundary code.
+	\param c     The coordinate to test.
+	\param pSet  The polygon set to test.
+	\return one of the relations: INSIDE, OUTSIDE or BOUNDARY.
+	\note Does box elimination.
+*/
+TL_DLL short TeRelation(const TeCoord2D& c, const TePolygonSet& pSet);
+
+/** \brief This function returns the relation between two lines.
+	\param lRed     The first line.
+	\param lBlue    The second line.
+	\param relation To return the relation that stop the search: TeDISJOINT, TeTOUCHES, TeWITHIN, TeCONTAINS, TeCROSSES, TeOVERLAPS, TeCOVEREDBY, TeCOVERS, TeEQUALS
+	\note Doesn't do box elimination. You must implement the test in your own functions.
+*/
+TL_DLL short TeRelation(const TeLine2D& lRed, const TeLine2D& lBlue, const short& relation);
+
+/** \brief This function returns the relation between a line and a polygon.
+	\param line   The line.
+	\param pol    The polygon.
+	\return one of the relations:  TeDISJOINT, TeTOUCHES, TeWITHIN (THE LINE IS WITHIN), TeCROSSES, TeCOVEREDBY (THE LINE IS COVERED BY).
+	\note Doesn't do box elimination. You must implement the test in your own functions.
+*/
+TL_DLL short TeRelation(const TeLine2D& line, const TePolygon& pol);
+
+/** \brief This function returns the relation between two polygons.
+	\param pRed   The first polygon.
+	\param pBlue  The second polygon.
+	\return one of the relations: TeEQUALS, TeDISJOINT, TeTOUCHES, TeWITHIN (pRed IS WITHIN pBlue), TeCONTANS (pBlue CONTAINS pRed), TeOVERLAPS, TeCOVEREDBY (pRed IS COVERED BY pBlue) or TeCOVERS (pRed COVERS pBlue).
+	\note Doesn't do box elimination. You must implement the test in your own functions.
+*/
+TL_DLL short TeRelation(const TePolygon& pRed, const TePolygon& pBlue);
+/** @}	*/
+/** @}	*/
+
+/** @defgroup BoxTests Special box tests
+ *  @ingroup GeometryAlgorithms
+ *  Box tests.
+ *  @{
+*/
+//! Check if box1 is DISJOINT or TOUCHes box2
+TL_DLL bool TeDisjointOrTouches(const TeBox& bx1, const TeBox& bx2);
+
+//! Check if coordinate c is WITHIN or TOUCHes segments c1 and c2 
+bool TeWithinOrTouches(const TeCoord2D& c, const TeCoord2D& c1, const TeCoord2D& c2);
+/** @} */
+
+
+/** @defgroup GeometryTests Special Geometry tests
+ *  @ingroup GeometryAlgorithms
+ *  Geometry tests.
+ *  @{
+*/
+//! Check if geom1 is WITHIN, COVERED BY or EQUAL to geom2
+
+
+template<class T1, class T2> 
+bool TeWithinOrCoveredByOrEquals(const T1& geom1, const T2& geom2)
+{
+	short rel = TeRelation(geom1, geom2);
+
+	if((rel&TeINSIDE) || (rel&TeBOUNDARY))
+	   return true;
+
+	return false;
+}
+
+//! Check if box1 is WITHIN, COVERED BY or EQUAL to box2
+template<>
+TL_DLL bool TeWithinOrCoveredByOrEquals(const TeBox& bx1, const TeBox& bx2);
+
+//! Check if line1 is WITHIN, COVERED BY or EQUAL to line2
+template<>
+TL_DLL bool TeWithinOrCoveredByOrEquals(const TeLine2D& line1, const TeLine2D& line2);
+
+//! Check if line1 is WITHIN or COVERED BY to pol
+template<>
+TL_DLL bool TeWithinOrCoveredByOrEquals(const TeLine2D& line1, const TePolygon& pol);
+
+//! Check if pol1 is WITHIN, COVERED BY or EQUAL to pol2
+template<>
+TL_DLL bool TeWithinOrCoveredByOrEquals(const TePolygon& pol1, const TePolygon& pol2);
+/** @} */
+
+
+/** @defgroup IntersectionOperators Intersection Operators
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that calculate the intersection among objects or do intersection test.
+ *  @{
+ */
+
+/** \brief Performs the intersection between  box b1 and b2, returning the resulting box bout.
+	\param bx1  The first box to do the intersection.
+	\param bx2  The second box to do the intersection.
+	\param bout The box formed by the intersection of bx1 and bx2.
+*/
+TL_DLL bool TeIntersection(const TeBox& bx1, const TeBox& bx2, TeBox& bout);
+
+/** \brief Returns the segments that intersept the poly polygon in the line y.
+	\param poly    A polygon.
+	\param y    The ordinate that cuts the polygons edges.
+*/
+TL_DLL TeCoordPairVect	TeGetIntersections(const TePolygon &poly, const double& y);
+/** @} */
+
+
+/** @defgroup UnionOperators Union Operators
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that compute the union of objects.
+ *  @{
+ */
+
+/** \brief Combine two box, make one that includes both.
+	\param bx1  The first box to do the union.
+	\param bx2  The second box to do the union.
+*/
+TL_DLL TeBox TeUnion(const TeBox& bx1, const TeBox& bx2);
+
+/** @} */
+
+/** @defgroup TeLocationFunctions Functions that finds the localization of objects.
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that finds the localization of objects.
+ *  @{
+ */
+/** \brief Point in polygon inside/outside/boundary code.
+	\param c    The coordinate to test.
+	\param r The simple polygon to test.
+
+	\note Check if point is INSIDE of a given ring.
+	      The ring is treated as a simple polygon (no holes).
+	      Adapted from:
+		  Samosky, Joseph, "SectionView: A system for interactively specifying and
+		  visualizing sections through three-dimensional medical image data,
+		  M.S. Thesis, Department of Electrical Engineering and Computer Science,
+		  Massachusetts Institute of Technology, 1993.
+		 Obs: Doesn't do box elimination.
+*/
+TL_DLL bool TePointInPoly(const TeCoord2D& c, const TeLinearRing& r);
+
+/** \brief Check if coordinate c is on segment (segment is closed).
+	\param c   The coordinate to be tested.
+	\param c1  The first segment's coordinate.
+	\param c2  The second segment's coordinate.
+*/
+TL_DLL bool TeIsOnSegment(const TeCoord2D& c, const TeCoord2D& c1, const TeCoord2D& c2);
+
+/** \brief Check if coordinate c is on line boundary or on line interior (see explanation above for definition of boundary and interior of a line).
+	\param c   The coordinate to be tested.
+	\param l   The line used in the test.
+
+	Obs: Do box elimination.
+*/
+TL_DLL bool TeIsOnLine(const TeCoord2D& c, const TeLine2D& l);
+
+/** \brief Locate the nearest line segment of a coordinate.
+	\param pin		The coordinate.
+	\param line		The line.
+	\param segment  The position of the segment in the line  
+	\param tol		Tolerance.
+*/
+TL_DLL bool TeLocateLineSegment(TeCoord2D& pin, TeLine2D& line, int& segment, double tol);
+/** @} */
+
+/** @defgroup TeConvexHull Functions to compute the Convex Hull
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that returns the convex hull of a point list.
+ *  @{
+ */
+ /** \brief Returns the convexhull of a given list of coords in counterclockwise.
+	 \param coordSet A list with coordinates without duplicated coordinates.
+
+	\note This algorithm is based on the book Computational Geometry
+	      by M. de Berg, M. van Kreveld, M. Overmars and O. Schwarzkopf - Springer Verlag - pp. 6.
+	      It is O(N log N).
+*/
+template<class T>
+TePolygon TeConvexHull(const T& coordSet);
+
+//! This is a explicit specialization that returns the convex hull of a TePolygon
+template<>
+TL_DLL TePolygon TeConvexHull(const TePolygon& p);
+
+//! This is a explicit specialization that returns the convex hull of a TePolygonSet
+template<>
+TL_DLL TePolygon TeConvexHull(const TePolygonSet& ps);
+
+//! This is a explicit specialization that returns the convex hull of a TePointSet. Must be defined!
+template<>
+TL_DLL TePolygon TeConvexHull(const TePointSet& ps);
+
+/** @} */
+
+/** @defgroup TeUtils Utilities functions.
+ *  @ingroup  GeometryAlgorithms
+ *  @{
+ */
+//! Given a projection "proj" returns a tolerance value in the same unit of projection to be used in geometric operations
+TL_DLL double TeGetPrecision(TeProjection* proj);
+
+//! This class implements the Epsilon-tweaking used in calculus.
+class TL_DLL TeGeometryAlgorithmsPrecision
+{
+	protected:
+
+		//! Constructor
+		TeGeometryAlgorithmsPrecision();
+
+	public:		
+
+		//! Tells if d1 is greater than d2 according to tolerance factor.
+		static bool IsGreater(const double& d1, const double& d2)
+		{
+			return ((d1 - d2) > TePrecision::instance().precision());
+		}
+
+		//! Tells if d1 is greater than or equal to d2 according to tolerance factor.
+		static bool IsGreaterEqual(const double& d1, const double& d2)
+		{
+			return ((d1 - d2) >= (-TePrecision::instance().precision()));
+		}
+
+		//! Tells if d1 is smaller than d2 according to a tolerance factor.
+		static bool IsSmaller(const double& d1, const double& d2)
+		{
+			return ((d1 - d2) < -(TePrecision::instance().precision()));
+		}
+
+		//! Tells if d1 is smaller than or equals to d2 according to a tolerance factor.
+		static bool IsSmallerEqual(const double& d1, const double& d2)
+		{
+			return ((d1 - d2) <= TePrecision::instance().precision());
+		}
+
+		//! Tells if d1 is equals to d2 according to a tolerance factor.
+		static bool IsEqual(const double& d1, const double& d2)
+		{
+			return (fabs(d1 - d2) <= TePrecision::instance().precision());
+		}
+
+		//! Tells if d1 is different from d2 according to a tolerance factor.
+		static bool IsDifferent(const double& d1, const double& d2)
+		{
+			return (fabs(d1 - d2) > TePrecision::instance().precision());
+		}
+};
+
+//! Removes the duplicate coordinates of a line
+TL_DLL inline void TeRemoveDuplicatedCoordinates(TeLine2D& l)
+{
+	for(unsigned int i = 0; i < l.size() - 1; ++i)
+		if(TeEquals(l[i], l[i + 1]))
+		{
+			l.erase(i);
+			--i;
+		}
+
+	return;
+}
+
+//! Removes the duplicate coordinates of a polygon
+TL_DLL inline void TeRemoveDuplicatedCoordinates(TePolygon& p)
+{
+	for(unsigned int i = 0; i < p.size(); ++i)
+		TeRemoveDuplicatedCoordinates(p[i]);		
+
+	return;
+}
+
+/** \brief Reverses the orientation of a line.
+	\param lin  The line to be reversed.
+*/
+TL_DLL inline void TeReverseLine(TeLine2D& lin)
+{
+	for(unsigned int i=0,j=lin.size()-1 ; i<lin.size()/2 ; ++i,--j)
+	{
+		TeCoord2D p = lin[i];
+		lin[i] = lin[j];
+		lin[j] = p;
+	}
+
+	return;
+}
+
+
+/** \brief Verifies if a simple polygon defined as a linear ring is convex or not.
+	\param ring  The polygon to test convexity.
+*/
+TL_DLL bool TeIsConvex(const TeLinearRing& ring);
+
+/** \brief Returns the orientation of the ring (CLOCKWISE or COUNTERCLOCKWISE);
+	\param r The ring to be checked.
+*/
+TL_DLL short TeOrientation(const TeLinearRing& r);
+
+/** @} */
+
+/** @defgroup MetricOperators Metric operators
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that do some usefull metric operations.
+ *  @{
+ */
+
+/** \brief Returns the middle point of a segment.
+	\param first   The first segment's coordinate.
+	\param last    The second segment's coordinate.
+	\param middle  The middle point.
+*/
+TL_DLL void TeGetMiddlePoint(const TeCoord2D& first, const TeCoord2D& last, TeCoord2D& middle);
+
+/** \brief Calculates the Euclidian distance between two points.
+	\param c1 First coordinate;
+	\param c2 Second coordinate;
+*/
+TL_DLL double TeDistance(const TeCoord2D& c1, const TeCoord2D& c2);
+
+/** \brief Returns the length of a Line 2D.
+	\param l  The line to calculate the length.	
+*/
+TL_DLL double TeLength(const TeLine2D& l);
+
+/** \brief Perpendicular distance from point to segment.
+	\param first  The first segment's coordinate.
+	\param last   The second segment's coordinate.
+	\param pin    The point to get the distance from the segment.
+	\param pinter The point of intersection on the segment.
+*/
+TL_DLL double TePerpendicularDistance(const TeCoord2D& first, const TeCoord2D& last, const TeCoord2D& pin, TeCoord2D &pinter);
+
+/** \brief Minimal distance from point to segment.
+	\param first	The first segment's coordinate.
+	\param last		The second segment's coordinate.
+	\param pin		The point to get the minimal distance from the segment. This point is inside the segment  
+	\param pout		The nearest segment point of the pin point.
+	\param tol		Numerical tolerance
+*/
+TL_DLL double TeMinimumDistance (const TeCoord2D& first, const TeCoord2D& last, const TeCoord2D& pin, TeCoord2D& pout, double tol = 0.0);
+
+/** \brief Template class to compute the area of a geometry
+	\param geom The geometry whose area we want to known.
+	\note This algorithm is based on the book Spatial Databases with Application to GIS
+	      by Philippe Rigaux, Michel O. Scholl and Agnes Voisard.
+
+*/
+
+template<class T>
+double TeGeometryArea(const T& /* geom */)
+{
+	return 0.0;
+}
+
+//! This is a explicit specialization that returns the area of a TePolygon
+template<>
+TL_DLL double TeGeometryArea(const TePolygon& p);
+
+//! This is a explicit specialization that returns the area of a TePolygonSet
+template<>
+TL_DLL double TeGeometryArea(const TePolygonSet& ps);
+
+//! This is a explicit specialization that returns the area of a Box
+template<>
+TL_DLL double TeGeometryArea(const TeBox& b);
+
+//! This is a explicit specialization that returns the area of a Box
+template<>
+TL_DLL double TeGeometryArea(const TeMultiGeometry& mGeom);
+/** @} */
+
+/** @defgroup GeometryFunction Functions that return geometries.
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that return geometries.
+ *  @{
+ */
+/** \brief Given a box return its polygon representation.
+	\param b  The box to create a polygon.
+*/
+TL_DLL TePolygon TeMakePolygon(const TeBox& b);
+
+/** \brief Given N points, finds a path that doesn't self-intersects
+	\note Given N points, finds a path that doesn't self-intersects, visiting all points and returning 
+	      to the begginning one. It is based on the book Algorithms by Robert Sedgewick, Addisson-Wesley, 1988;
+	\param pSet The point set to form a path.
+*/
+TL_DLL TeLinearRing TeSimpleClosedPath(const TePointSet& pSet);
+/** @} */
+
+
+/** @defgroup TeFindCentroid Functions to compute the centroid
+ *  @ingroup  GeometryAlgorithms
+ *  Functions that return the centroid.
+ *  @{
+ */
+
+/** \brief Calculates the centroid of a multi geometry.
+	\param p A multi geometry whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(TeMultiGeometry& mGeom);
+
+/** \brief Calculates the centroid of a polygon.
+	\param p A TePolygon whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TePolygon& p);
+
+/** \brief Calculates a reference point.
+	\param l A TeLine whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TeLine2D& l);  
+
+/*! \fn TeCoord2D TeFindCentroid(const TeCell& c );
+    \brief Calculates the centroid of a cell.
+	\param c A TeCell whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TeCell& c);
+
+/** \brief Calculates the centroid of a point.
+	\param p A TePoint whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TePoint& p);
+
+/** \brief Calculates the centroid of a text.
+	\param t A TeText whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TeText& t);
+
+/** \brief Calculates the centroid of a polygon set.
+	\param s A TePolygon set whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TePolygonSet& s); 
+
+/** Calculates the centroid of a line set.
+	\param s A TeLine set whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TeLineSet& s); 
+
+/** \brief Calculates the centroid of a cell set.
+	\param s A TeCell set whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(const TeCellSet& s);
+
+/** \brief Calculates the centroid of a point set.
+	\param ps A TePointSet set whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(TePointSet& ps);
+
+/** \brief Calculates the centroid of a text set.
+	\param ts A TeTextSet set whose centroid we want to known.
+*/
+TL_DLL TeCoord2D TeFindCentroid(TeTextSet& ts);
+
+/** \brief Calculates the center of a triangle.
+	\param vert0 First triagle's vertex.
+	\param vert1 Second triagle's vertex.
+	\param vert2 Third triagle's vertex.
+	\param pc    The triangle center.
+*/
+TL_DLL bool TeFindTriangleCenter(const TeCoord2D& vert0, const TeCoord2D& vert1, const TeCoord2D& vert2, TeCoord2D& pc); 
+/** \brief Calculates intersection between two segments.
+	\param fr0 First point of first segment.
+	\param to0 Second point of first segment.
+	\param fr1 First point of second segment.
+	\param to1 Second point of second segment.
+	\param pi    The intersection point coordinates.
+	\return true is intersects, false otherwise.
+*/
+
+TL_DLL bool TeSegmentsIntersectPoint(const TeCoord2D& fr0, const TeCoord2D& to0, const TeCoord2D& fr1, const TeCoord2D& t1, TeCoord2D& pi); 
+
+/** @} */
+
+
+/** @defgroup TeNearest Functions to compute the nearest part of an object to a point.
+  *  @ingroup  GeometryAlgorithms
+  *  Auxiliary functions.
+  *  @{
+  */
+//! Nearest node in set from location pt (i = the node index in the nodeset)
+TL_DLL bool TeNearest(TeCoord2D& pt, TeNodeSet& ns , int& i, const double& tol = 0.0);
+
+//! Nearest point in set from location pt (i = the point index in the pointset)
+TL_DLL bool TeNearest(TeCoord2D& pt, TePointSet& ps , int& i, const double& tol = 0.0);
+
+//! Nearest text in set from location pt (i = the text index in the textset)
+TL_DLL bool TeNearest(TeCoord2D& pt, TeTextSet& ts , int& i, const double& tol = 0.0);
+
+//! Nearest line in set from location pt (i = the line index in the lineset and pi = the closest point)
+//! The pi point can be outside a line of the line set
+TL_DLL bool TeNearest(TeCoord2D& pt, TeLineSet& ls , int& i, TeCoord2D& pi, const double& tol);
+
+//! Nearest line in set from location pt (i = the line index in the lineset and pout = the closest point)
+//! The pout point must be inside a line of the line set
+TL_DLL bool TeNearest (TeCoord2D& pt,TeLineSet& ls, int& lindex, TeCoord2D& pout, double& dmin, const double& tol = 0.0); 
+
+//! Nearest polygon in set from location pt (i = the polygon index in the polygonset).
+TL_DLL bool TeNearest(TeCoord2D& pt, TePolygonSet& ps , int& i, const double& tol = 0.0);
+
+//! Nearest line in set from location pt (i = the line index in lineset) calculated by the vertex of the lines
+TL_DLL bool TeNearestByPoints(TeCoord2D& pt, TeLineSet& ls , int& i, double& dist, const double& tol = 0.0);
+/** @} */
+
+/** @defgroup CurveFunctions Functions used to deal with smooth curves
+  *  @ingroup  GeometryAlgorithms
+  *  @{
+  */
+/** \brief Given three points of a circunference, returns its center point.
+	\param p1      First point.
+	\param p2      Second point.
+	\param p3      Third point.
+	\param center  Circunference center.
+	This algorithm is adapted from http://www.delphiforfun.org/Programs/Math_Topics/circle_from_3_points.htmbook.
+*/
+TL_DLL bool TeGetCenter(TePoint p1, TePoint p2, TePoint p3, TePoint &center);
+
+/** \brief Given three points of a circunference, returns the radius.
+	\param p1      First point.
+	\param p2      Second point.
+	\param p3      Third point.
+	This algorithm is adapted from http://www.delphiforfun.org/Programs/Math_Topics/circle_from_3_points.htmbook.
+*/
+TL_DLL double TeGetRadius(TePoint &p1, TePoint &p2, TePoint &p3);
+
+/** \brief Given three points returns a smooth arc as a TeLine2D that contains a given total number of points.
+
+	\param p1      First point.
+	\param p2      Second point.
+	\param p3      Third point.
+	\param arcOut  The return arc.
+	\param NPoints Number of arc points.	
+	
+	This algorithm is adapted from http://mathforum.org/dr.math/
+  
+*/
+TL_DLL bool TeGenerateArc(TePoint& p1, TePoint& p2, TePoint& p3, TeLine2D& arcOut, const short& NPoints);
+
+/** \brief Given a center point and a radius, returns the circle  as a TeLine2D interpolated by a given number of points
+	\param center  Center point of the circle.
+	\param radius  radius of the circle.
+	\param circle  The return circle
+	\param NPoints Number of circle points.	
+*/
+TL_DLL bool TeGenerateCircle(TePoint& center, const double& radius, TeLine2D& circle, const short& NPoints);
+
+/** \brief Performs a line simplication
+	\param line		The line to be simplified
+	\param snap		Simplification threshold
+	\param maxdist	The maximum distance between intermediary segments
+*/
+TL_DLL bool TeLineSimplify(TeLine2D& line, double snap, double maxdist);
+
+
+/** @} */
+
+/** @} */ // end of group  GeometryAlgorithms
+
+
+#endif	// __TERRALIB_INTERNAL_GEOMETRYALGORITHMS_H
diff --git a/src/terralib/kernel/TeGroupingAlgorithms.cpp b/src/terralib/kernel/TeGroupingAlgorithms.cpp
new file mode 100644
index 0000000..0f4754d
--- /dev/null
+++ b/src/terralib/kernel/TeGroupingAlgorithms.cpp
@@ -0,0 +1,112 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeGroupingAlgorithms.h"
+
+void
+TeGroupByUniqueValue(vector<string>& vec, TeAttrDataType tipo, vector<TeSlice>& result, int precision)
+{
+	unsigned int i, j;
+		
+	if (tipo == TeINT)
+	{
+		vector<int> v;
+		for (i = 0; i < vec.size(); ++i)
+			v.push_back(atoi(vec[i].c_str()));
+		sort(v.begin(), v.end());
+
+		for (i = 0; i < v.size(); ++i)
+			vec[i] = Te2String(v[i]);
+	}
+	else if (tipo == TeREAL)
+	{
+		vector<double> v;
+		for (i = 0; i < vec.size(); ++i)
+		{
+			double a = atof(vec[i].c_str());
+			v.push_back(a);
+		}
+		stable_sort(v.begin(), v.end());
+
+		for (i = 0; i < v.size(); ++i)
+			vec[i] = Te2String(v[i], precision);
+	}
+	else
+	{
+		sort(vec.begin(), vec.end());
+	}
+
+	// Check the elements that are equal, incrementing
+	// the variable count associated to each one
+	int count = 1;
+	TeSlice slice;
+	unsigned int sz = vec.size();
+	for (i = 0, j = 1; i < sz - 1 && j < sz; ++i, ++j)
+	{
+		if (vec[i] == vec[j])
+			++count;
+		else
+		{
+			slice.from_ = vec[i];
+			slice.count_ = count;
+			result.push_back(slice);
+			count = 1;
+		}
+	}
+
+   if ( (i>1) && (vec[i] == vec[i-1]) ) 
+   {
+       slice.from_ = vec[i];
+       slice.count_ = count;
+       result.push_back(slice);
+   }
+   else
+   {
+       slice.from_ = vec[i];
+       slice.count_ = 1;
+       result.push_back(slice);
+   } 
+}
+
+void
+TeGroupByEqualStep(double min, double max, int nstep, vector<TeSlice>& result, int precision)
+{
+	double slice = (max - min)/double(nstep);
+	int ns;
+	for (ns=0;ns<nstep;ns++)
+	{
+		TeSlice ps;
+		ps.count_ = 0;
+		ps.from_ = Te2String(min+double(ns)*slice, precision);
+		ps.to_ = Te2String(min+double(ns+1)*slice, precision);
+		result.push_back(ps);
+	}
+	min = TeAdjustToPrecision(min, precision, true);
+	result[0].from_ = Te2String(min, precision);
+	max = TeAdjustToPrecision(max, precision);
+	result[result.size()-1].to_ = Te2String(max, precision);
+}
diff --git a/src/terralib/kernel/TeGroupingAlgorithms.h b/src/terralib/kernel/TeGroupingAlgorithms.h
new file mode 100644
index 0000000..f5612a7
--- /dev/null
+++ b/src/terralib/kernel/TeGroupingAlgorithms.h
@@ -0,0 +1,281 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeGroupingAlgorithms.h
+    \brief This file contains some generic grouping algorithms (based on iterators)
+*/
+
+#ifndef  __TERRALIB_INTERNAL_GROUPINGALGORITHMS_H
+#define  __TERRALIB_INTERNAL_GROUPINGALGORITHMS_H
+
+#include "TeDefines.h"
+#include "TeSlice.h"
+#include "TeUtils.h"
+#include "TeDataTypes.h"
+
+#include <math.h>
+#include <time.h>
+#include <algorithm>
+
+
+//! Finds the element with minimum value among the elements contained in a range of iterators
+template<typename It>
+void TeMinimumValue(It begin, It end, vector<double>& minValue, double dummy=-9999.99, bool usesDummy=false)
+{
+	for (int i=0; i<minValue.size(); i++)
+		minValue[i] = TeMAXFLOAT;
+
+	It it = begin;
+	double val;
+	while ( it != end) 
+	{
+		if (!(usesDummy && dummy == val))
+			for (int i=0; i<minValue.size(); i++)
+			{
+				val= (*it)[i];
+				if (val < minValue[i])
+					minValue[i] = val;
+			}
+		it++;
+	}
+}
+
+//! Finds the element with maximum value among the elements contained in a range of iterators
+template<typename It>
+void TeMaximumValue(It begin, It end, vector<double>& maxValue, double dummy=-9999.99, bool usesDummy=false)
+{
+	for (int i=0; i<maxValue.size(); i++)
+		maxValue[i] = -TeMAXFLOAT;
+
+	It it = begin;
+	double val;
+	while ( it != end) 
+	{
+		if (!(usesDummy && dummy == val))
+			for (int i=0; i<maxValue.size(); i++)
+			{
+				val= (*it)[i];
+				if (val > maxValue[i])
+					maxValue[i] = val;
+			}
+		it++;
+	}
+}
+
+//! Defines the classes (slices) of a equal step grouping
+TL_DLL void TeGroupByEqualStep(double min, double max, int nstep, vector<TeSlice>& result, int precision=0);
+
+/** @defgroup GenGroupAlg Generic Algorithms to do grouping
+ *  A set of of generic functions to do grouping
+ *  @{
+ */
+
+//! Groups a set of elements defined by a range of iterators in nstep groups, using Equal Step algorithm
+template<class iterator>
+void TeGroupByEqualStep(iterator begin, iterator end, int nstep, vector<TeSlice>& result,
+				   int precision=0, bool countElements = true)
+{
+	double	min = TeMAXFLOAT;
+	double	max = -TeMAXFLOAT;
+
+	iterator it=begin;
+	while(it < end)
+	{
+		min = MIN(min, *it);
+		max = MAX(max, *it);
+		it++;
+	}
+	double slice = (max - min)/double(nstep);
+	int ns;
+	for (ns=0;ns<nstep;ns++)
+	{
+		TeSlice ps;
+		ps.count_ = 0;
+		ps.from_ = Te2String(min+double(ns)*slice, precision);
+		ps.to_ = Te2String(min+double(ns+1)*slice, precision);
+		result.push_back(ps);
+	}
+	min = TeAdjustToPrecision(min, precision, true);
+	result[0].from_ = Te2String(min, precision);
+	max = TeAdjustToPrecision(max, precision);
+	result[result.size()-1].to_ = Te2String(max, precision);
+
+	// Set the number of elements for each slice
+	if (countElements == true)
+		TeElemCountingBySlice(begin, end, result);
+}
+
+//! Groups a set of elements defined by a range of iterators in nstep groups, using Quantil algorithm
+template<class iterator>
+void TeGroupByQuantil(iterator begin, iterator end, int nstep, vector<TeSlice>& result,
+				 int precision = 0, bool countElements = true)
+{
+	sort(begin, end);
+
+	int size = end - begin;
+	double	step = (double)size / (double)nstep;
+
+	int	n = 0;
+	iterator it = begin;
+	while(it < end)
+	{
+		TeSlice	ps;
+		ps.from_ = Te2String((*it), precision);
+		int p = (int)(step * (double)++n + .5);
+		it = begin + p;
+		if(it < end)
+			ps.to_ = Te2String((*it), precision);
+		else
+			ps.to_ = Te2String(*(it-1), precision);
+		result.push_back(ps);
+	}
+	if(end-begin > 1)
+	{
+		double min = (*begin);
+		double max = (*(end-1));
+		min = TeAdjustToPrecision(min, precision, true);
+		result[0].from_ = Te2String(min, precision);
+		max = TeAdjustToPrecision(max, precision);
+		result[result.size()-1].to_ = Te2String(max, precision);
+	}
+
+	// Set the number of elements for each slice
+	if (countElements == true)
+		TeElemCountingBySlice(begin, end, result);
+}
+
+//! Groups a set of elements defined by a range of iterators in ndev groups, using Standanrd deviation algorithm
+template<class iterator>
+void TeGroupByStdDev(iterator begin, iterator end, double ndev, vector<TeSlice>& result, string& rmean,
+				int precision = 0, bool countElements = true)
+{
+	// Compute mim, max and mean
+	double	min = TeMAXFLOAT;
+	double	max = -TeMAXFLOAT;
+	long double	sum=0.;
+	long double	sm2=0.;
+	iterator it=begin;
+	while(it < end)
+	{
+		min = MIN(min, *it);
+		max = MAX(max, *it);
+		sum += (*it);
+		sm2 += ((*it) * (*it));
+		it++;
+	}
+	double cont = (double)(end - begin);
+	double	mean = (double)(sum/cont);
+	long double var = (sm2 / cont) - (mean * mean);
+	double	sdev = sqrt(var);
+
+	double	slice = sdev * ndev;
+
+	vector<TeSlice>	aux;
+	rmean = Te2String(mean, precision);
+	double	val = mean;
+	while(val-slice > min-slice)
+	{
+		TeSlice ps;
+		double v = val - slice;
+		ps.from_ = Te2String(v, precision);
+		ps.to_ = Te2String(val, precision);
+		aux.push_back(ps);
+		val = v;
+	}
+
+	if(aux.size())
+	{
+		typename vector<TeSlice>::iterator sit = aux.end() - 1;
+		while(sit >= aux.begin())
+			result.push_back(*sit--);
+	}
+
+	string media = "mean = " + rmean;
+	TeSlice ps;
+	ps.from_ = media;
+	ps.to_.clear();
+	result.push_back(ps);
+	val = mean;
+	while(val+slice < max+slice)
+	{
+		TeSlice ps;
+		double	v = val + slice;
+		ps.from_ = Te2String(val, precision);
+		ps.to_ = Te2String(v, precision);
+		result.push_back(ps);
+		val = v;
+	}
+	if(result.size() > 2)
+	{
+		if (result[0].from_.find("mean")  == string::npos)
+		{
+			min = TeAdjustToPrecision(min, precision, true);
+			result[0].from_ = Te2String(min, precision);
+		}
+		if (result[result.size()-1].from_.find("mean")  == string::npos)
+		{
+			max = TeAdjustToPrecision(max, precision);
+			result[result.size()-1].to_ = Te2String(max, precision);
+		}
+	}
+
+	// Set the number of elements for each slice
+	if (countElements == true)
+		TeElemCountingBySlice(begin, end, result);
+}
+
+
+//! Counts the number of elements, from a general container, per slice of a vector of slices
+template<class iterator>
+void TeElemCountingBySlice(iterator begin, iterator end, vector<TeSlice>& result)
+{
+	iterator it;
+	double from, to;
+
+	for (unsigned int i = 0; i < result.size(); ++i)
+	{
+		TeSlice& sl = result[i];
+		sl.count_ = 0;
+		from = atof(sl.from_.c_str());
+		to = atof(sl.to_.c_str());
+		for (it = begin; it != end; ++it)
+		{
+			if (*it >= from && *it < to)
+				++sl.count_;
+		}
+	}
+}
+
+
+//! Groups a set of elements in a vector of string  using Unique Value algorithm
+TL_DLL void TeGroupByUniqueValue(vector<string>& vec, TeAttrDataType tipo, vector<TeSlice>& result, int precision);
+
+/** @} */ 
+#endif
+
+
+
+
+
+ 
+
+
diff --git a/src/terralib/kernel/TeImportRaster.cpp b/src/terralib/kernel/TeImportRaster.cpp
new file mode 100644
index 0000000..3b1c0b2
--- /dev/null
+++ b/src/terralib/kernel/TeImportRaster.cpp
@@ -0,0 +1,687 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeRasterRemap.h"
+#include "TeDecoderDatabase.h"
+#include "TeRaster.h"
+#include "TeDecoderMemory.h" 
+#include "TeRasterParams.h"
+#include "TeProgress.h"
+#include "TeVectorRemap.h"
+#include "TeImportRaster.h"
+
+//FAMI #include "TeLibJpegWrapper.h" //not used; otherwise, needs to define macro JPEG_DEFINED
+
+
+TeLayer* 
+TeImportRaster (const string& layerName, TeRaster* rasterIn, TeDatabase* database)
+{
+	if (!database || layerName.empty() || !rasterIn || 
+		(rasterIn->params().status_ != TeRasterParams::TeReadyToRead && 
+		 rasterIn->params().status_ != TeRasterParams::TeReadyToWrite))
+		return 0;
+
+	// find a valid layer name
+	string newLayerName = layerName;
+	TeLayerMap& layerMap = database->layerMap();
+	TeLayerMap::iterator it;
+	bool flag = true;
+	int n = 1;
+	while (flag)
+	{
+		for (it = layerMap.begin(); it != layerMap.end(); ++it)
+		{
+			if (TeStringCompare(it->second->name(),newLayerName))
+				break;
+		}
+		if (it == layerMap.end())
+			flag = 0;
+		else
+			newLayerName = layerName + "_" +Te2String(n);
+		n++;	
+	}
+
+	TeLayer* newLayer = new TeLayer(newLayerName,database,rasterIn->projection());
+	if (newLayer->id() <= 0 )
+		return 0;				// couldn�t create new layer
+
+	// block dimension guessing
+	unsigned int bw = 512;
+	unsigned int bh = 512;		// an initial guess...
+
+	// if raster is up to 512x512 store it in one block
+	if (rasterIn->params().nlines_< 512 && rasterIn->params().ncols_< 512)
+	{
+		bw = rasterIn->params().ncols_;
+		bh = rasterIn->params().nlines_;
+	}
+	// if ncols<1024 build blocks of 1 line
+	else if (rasterIn->params().ncols_ < 1024)  
+	{
+		bw = rasterIn->params().ncols_;
+		bh = 1;
+	}
+
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+
+	bool res = TeImportRaster(newLayer, rasterIn, bw, bh, TeRasterParams::TeNoCompression, 
+		"", rasterIn->params().dummy_[0], rasterIn->params().useDummy_, TeRasterParams::TeNoExpansible);
+	if (res)
+		return newLayer;
+
+	database->deleteLayer(newLayer->id());
+	delete newLayer;
+	return 0;
+}
+
+
+// This function mosaics an input raster to one previsously existing in a TerraLib layer
+bool TeMosaicRaster(TeRaster* rasterIn, TeLayer* layer,  const string& objectId)
+{
+
+	// layer must exist and input raster should be read to be read
+	if (!layer || !rasterIn  || rasterIn->params().status_ != TeRasterParams::TeReadyToRead)
+		return false;
+	
+	TeRaster* rasterOut;
+	if (!objectId.empty())	// if object id informed try to get raster associated to it
+		rasterOut = layer->raster(objectId,'w');
+	else					// else try to get first one found
+		rasterOut = layer->raster();
+
+	if (!rasterOut)			// no raster asked or no raster at all
+		return false;				// can not do mosaic
+
+	if (rasterOut->params().tiling_type_==TeRasterParams::TeNoExpansible)
+		return false;				// can mosaic if is not possible
+
+	// allows mosaic of same photometric types only
+	if (rasterOut->params().photometric_[0] != rasterIn->params().photometric_[0])
+		return false;
+
+	// increases output box to: input raster box + output raster box 
+	TeBox boxIn = rasterIn->params().box();
+
+	// if necessary remap input box to output projection 
+	if (!(*(rasterIn->projection()) == *(rasterOut->projection())))
+		boxIn = TeRemapBox(boxIn,rasterIn->projection(),rasterOut->projection());
+
+	// adjust it to expansible values
+	boxIn = adjustToCut(boxIn, rasterOut->params().blockWidth_*rasterOut->params().resx_, 
+							   rasterOut->params().blockHeight_*rasterOut->params().resy_);
+
+	// sum stored and input boxes
+	TeBox newBox = rasterOut->params().boundingBox();
+	updateBox(newBox,boxIn);
+
+	// update box in parameters of the raster and it's decoder
+	rasterOut->params().boundingBoxResolution(newBox.x1_,newBox.y1_,newBox.x2_,newBox.y2_,
+											  rasterOut->params().resx_, rasterOut->params().resy_);
+
+	rasterOut->decoder()->params().boundingBoxResolution(newBox.x1_,newBox.y1_,newBox.x2_,newBox.y2_,
+											  rasterOut->params().resx_, rasterOut->params().resy_);
+	rasterOut->params().nTilesInMemory_ = 0;
+	
+	// creates a remapping from input raster to output raster
+	TeRasterRemap remap(rasterIn, rasterOut);
+	if (remap.apply(true))			// o.k.
+	{
+		TeRasterParams rp = rasterOut->params();
+
+		// atualizes the representation box in memory
+		TeRepresentation* repp = layer->getRepresentation(TeRASTER);
+		TeBox boxNew = rp.box();
+		updateBox(repp->box_,rp.box());
+		repp->nCols_ = rp.ncols_;
+		repp->nLins_ = rp.nlines_;
+		repp->resX_ = rp.resx_;
+		repp->resY_ = rp.resy_;
+
+		// atualizes representation in the database
+		layer->database()->updateRasterRepresentation(layer->id(),rp,objectId);
+		layer->updateLayerBox(rp.boundingBox());
+		rasterOut->clear();
+		return true;
+	}
+	return false;
+}
+
+
+bool TeImportRaster (TeLayer* layer, TeRaster* rasterIn, 
+					 unsigned int bWidth, unsigned int bHeight,TeRasterParams::TeRasterCompressionMode compress,
+					 const string& objectId, double dummy, bool useDummy,
+					 TeRasterParams::TeRasterTilingType indext)
+{	
+
+	if (!layer || !rasterIn)
+		return false;
+
+	string objId;
+	if (objectId.empty())
+		objId = "O1";
+	else
+		objId = objectId;
+
+
+	// check if there  is a raster geometry to be modified
+	string tableGeo;
+	TeRepresentation* repp = 0;
+	repp = layer->getRepresentation(TeRASTER);
+	if (!repp || !layer->raster(objectId))	// layer doesn�t have any 
+	{										// or the desired raster geometry
+											// a new one should be created
+		TeProjection* projIn = rasterIn->projection();	
+		TeProjection* projOut = layer->projection();
+
+		TeRasterParams parOut = rasterIn->params();		// parameters of the raster being created	
+														// start with the same parameters as input raster
+		
+		parOut.setCompressionMode(compress);		// overwrites some parameters 
+		parOut.nTilesInMemory_ = 0;					// according to the specified in the interface
+		parOut.blockHeight_ = bHeight;
+		parOut.blockWidth_ = bWidth;
+		parOut.setDummy(dummy);
+		parOut.useDummy_ = useDummy;
+		parOut.tiling_type_ = indext;
+
+		TeBox newBox = rasterIn->params().boundingBox();
+
+		// if input raster has some rotation associated it has to be corrected 
+		// during the importing
+		if (parOut.dxI_ != 0. || parOut.dyJ_ != 0.)
+		{
+			parOut.boundingBoxResolution(newBox.x1_,newBox.y1_,newBox.x2_,newBox.y2_,parOut.resx_,parOut.resy_);
+			parOut.dxI_= 0.0;							  
+			parOut.dyJ_= 0.0;							 
+			parOut.dxJ_ = 0.0;
+			parOut.dyI_ = 0.0;	
+		}
+		
+		bool diffProj = false;
+		parOut.projection(projOut);
+		if (projIn && projOut && !(*projIn == *projOut))
+		{
+			diffProj = true;
+			TeBox boxIn = rasterIn->params().boundingBox();
+			newBox = TeRemapBox (boxIn,projIn,projOut);
+			parOut.resx_ = newBox.width()/parOut.ncols_;	// recalculates resolutions 
+			parOut.resy_ = newBox.height()/parOut.nlines_;  // for the new projection
+			parOut.boundingBoxResolution(newBox.x1_,newBox.y1_,newBox.x2_,newBox.y2_,parOut.resx_,parOut.resy_);
+			newBox = parOut.box();
+		}
+	
+		if (indext == TeRasterParams::TeExpansible)			// if mosaicable adjust box 
+			parOut.resizeToTiling(newBox,bWidth,bHeight);	// to be cut in blocks of bWidth X bHeight (in projection units)
+
+		parOut.decoderIdentifier_ = "DB";					// parameters of the decoder
+		parOut.fileName_ = "RasterLayer" + Te2String(layer->id()) + "_R_" + objId;
+
+		if (parOut.photometric_[0] == TeRasterParams::TePallete)
+			parOut.lutName_ = parOut.fileName_ + "_LUT";
+
+		if (!layer->addRasterGeometry(parOut,objId))		// creates the empty raster geometry
+			return false;
+
+		// create a decoder to raster in a TerraLib database 
+		parOut.mode_ = 'w';
+		TeDecoderDatabase *dbDecoder = new TeDecoderDatabase(parOut);
+		dbDecoder->setDB(layer->database());
+
+		// optimization: we don't need to go through remap routines.
+		// just cut the input raster and save the tiles
+		bool res=false;
+		TeRasterParams parF;
+		if (indext == TeRasterParams::TeNoExpansible && !diffProj)
+		{
+			int ntiles = (parOut.nlines_/parOut.blockHeight_)*(parOut.ncols_/parOut.blockWidth_);
+			if(TeProgress::instance())
+				TeProgress::instance()->setTotalSteps(ntiles);
+			int count = 0;
+			clock_t	ti, tf;
+			int x=0, y=0, b, nb=parOut.nBands(),lx, ly;
+			double val= parOut.dummy_[0];
+			TeMemoryPage page(parOut.blockHeight_*parOut.blockWidth_,val,parOut.dataType_[0]);
+			string index;
+			ti = clock();
+			while (y<parOut.nlines_)  // for each row of tiles
+			{
+				page.ulLin_ = y;
+				x=0;
+				while (x<parOut.ncols_)	// for each tile in a row
+				{
+					page.clear();
+					page.ulCol_= x;
+					for (b=0; b<nb; ++b)    // for each band;
+					{
+						for (ly=0; ly<parOut.blockHeight_; ++ly)
+						{
+							for (lx=0; lx<parOut.blockWidth_; ++lx)  // write the tile
+							{
+								if (rasterIn->getElement(x+lx,y+ly,val,b))
+								{
+									page.setVal(x+lx,y+ly,parOut.blockWidth_,val);
+									if (val<parOut.vmin_[b])
+										parOut.vmin_[b] = val;
+									if (val>parOut.vmax_[b])
+										parOut.vmax_[b] = val;
+								}
+							}
+						}
+						index = dbDecoder->codifyId(x,y,b,1,0);
+						if (!dbDecoder->putRasterBlock(index,page.data_,page.pageSize()))
+							res=false;
+						page.clear();
+					}
+					x+= parOut.blockWidth_;
+					++count;
+					if(TeProgress::instance())
+					{
+						tf = clock();
+						if (int((tf-ti)/CLOCKS_PER_SEC) > 3)
+						{
+							if (TeProgress::instance()->wasCancelled())
+								break;
+							TeProgress::instance()->setProgress(count);
+							ti = tf;
+						}
+					}
+				}
+				y+= parOut.blockHeight_;
+			}
+			if (TeProgress::instance())
+				TeProgress::instance()->reset();
+
+			// atualizes the representation box in memory
+			TeRepresentation* repp = layer->getRepresentation(TeRASTER);
+			updateBox(repp->box_,parOut.box());
+			repp->nCols_ = parOut.ncols_;
+			repp->nLins_ = parOut.nlines_;
+			repp->resX_ = parOut.resx_;
+			repp->resY_ = parOut.resy_;
+			layer->updateLayerBox(parOut.boundingBox());
+			layer->database()->updateRasterRepresentation(layer->id(),dbDecoder->params(),objectId);
+			// atualizes representation in the database
+			for (b=0; b<nb; ++b)
+			{
+				dbDecoder->params().vmax_[b]=parOut.vmax_[b];
+				dbDecoder->params().vmin_[b]=parOut.vmin_[b];
+			}
+			layer->database()->updateRasterRepresentation(layer->id(),dbDecoder->params(),objectId);
+			dbDecoder->clear();
+			res=true;
+		}
+		else
+		{
+			TeRaster* rasterOut = new TeRaster();
+			rasterOut->setDecoder(dbDecoder);
+			rasterOut->init();
+			TeRasterRemap remap(rasterIn, rasterOut);
+			if (remap.apply(true))
+			{
+				TeRepresentation* repp = layer->getRepresentation(TeRASTER);
+				updateBox(repp->box_,rasterOut->params().box());
+				repp->nCols_ = rasterOut->params().ncols_;
+				repp->nLins_ = rasterOut->params().nlines_;
+				repp->resX_ = rasterOut->params().resx_;
+				repp->resY_ = rasterOut->params().resy_;
+
+				// atualizes representation in the database
+				layer->database()->updateRasterRepresentation(layer->id(),rasterOut->params(),objectId);
+				layer->updateLayerBox(rasterOut->params().boundingBox());
+				rasterOut->clear();
+				res = true;
+			}
+		}
+		if (res)			
+		{
+			//	create spatial index in the block box
+			string tableR = layer->database()->getRasterTable(layer->id(),objectId);
+			layer->database()->insertMetadata(tableR,layer->database()->getSpatialIdxColumn(TeRASTER), 0.000005,0.000005,layer->box());		
+			layer->database()->createSpatialIndex(tableR,layer->database()->getSpatialIdxColumn(TeRASTER), (TeSpatialIndexType)TeRTREE);
+		}
+		delete dbDecoder;
+		return res;
+	}
+	else
+	{
+		// layer contains already a raster representation associated to the
+		// object id: calls mosaic operation
+		return TeMosaicRaster(rasterIn,layer,objId);
+	}
+}
+
+bool 
+TeBuildLowerResolution(TeLayer* layer, TeRaster* rasterIn, int resFac, const string& objectId)
+{
+	if (!layer || !rasterIn)	// layer and input raster pointers shouldn't be null
+		return false;
+
+	string objId;				// if empty try to get the default object identification
+	if (objectId.empty())
+		objId = "O1";
+	else
+		objId = objectId;	
+	
+	string tableName;
+	TeRepresentation* repp = layer->getRepresentation(TeRASTER);
+	if (repp)
+	{
+		tableName = layer->database()->getRasterTable(layer->id(), objId);
+		if (tableName.empty())	
+			return false;		// layer doesn�t have a raster geometry to this object id
+	}
+	else					
+		return false;			// layer doesn�t have any raster geometry
+
+	// retrieves the original raster
+	TeRaster* originalRaster = layer->raster(objId);
+	TeBox bbOriginalRes = originalRaster->params().boundingBox();
+
+	// builds some parameters relative to the new resolution
+	TeRasterParams parNewRes = originalRaster->params();
+	parNewRes.resolution_ = resFac;
+	parNewRes.mode_ = 'w';
+	parNewRes.boundingBoxResolution(bbOriginalRes.x1_, bbOriginalRes.y1_,bbOriginalRes.x2_, bbOriginalRes.y2_,
+									parNewRes.resx_*resFac, parNewRes.resy_*resFac);
+
+	// adjust box to tiling in geographical coordinates
+	if (originalRaster->params().tiling_type_ == TeRasterParams::TeExpansible)
+	{
+		TeBox b = parNewRes.boundingBox();
+		int w = parNewRes.blockWidth_;
+		int h = parNewRes.blockHeight_;
+		parNewRes.resizeToTiling(b, w, h);
+	} 
+
+
+	// create a decoder to raster in a TerraLib database 
+	TeDecoderDatabase *dbDecoder = new TeDecoderDatabase(parNewRes);
+	dbDecoder->setDB (layer->database());
+
+	TeRaster* rasterOut = new TeRaster();
+	rasterOut->setDecoder(dbDecoder);
+	rasterOut->init();
+
+	// remap;
+	TeRasterRemap remap;
+	remap.setInput(rasterIn);
+	remap.setOutput(rasterOut);
+	bool status = remap.apply(true);
+	rasterOut->clear();
+	delete dbDecoder;
+	return status;
+}
+
+
+
+void
+TeCalculateMean(TeDecoderMemory* decMem, vector<TeMemoryPage*> pages,int ulColStart,int ulLinStart)
+{
+	int i,j, c=ulColStart, l=ulLinStart;
+	unsigned int b;
+	int npixels;
+	double mean,val;
+	int nlines = decMem->params().nlines_-1;
+	int ncols = decMem->params().ncols_-1;
+	double dummy;
+
+	for (b=0; b<pages.size(); ++b)
+	{
+		dummy = decMem->params().dummy_[b];
+		l=ulLinStart;
+		for (i=0; i<nlines; i+=2)
+		{
+			c=ulColStart;
+			for (j=0; j<ncols; j+=2)
+			{
+				mean = 0.0;
+				npixels = 0;
+				if ((j>0) && (i>0) && decMem->getElement(j-1,i-1,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if ((i>0) && decMem->getElement(j,i-1,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if ((i>0) && (j<ncols-1) && decMem->getElement(j+1,i-1,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}	
+				
+				if ((j>0) && decMem->getElement(j-1,i,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if (decMem->getElement(j,i,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if ((j<ncols-1) && decMem->getElement(j+1,i,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}				
+			
+				if ((j>0) && (i<nlines-1) && decMem->getElement(j-1,i+1,val) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if ((i<nlines-1) && decMem->getElement(j,i+1,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if ((j<ncols-1) && (i<nlines-1) && decMem->getElement(j+1,i+1,val,b) && val != dummy)
+				{
+					mean += val;
+					npixels ++;
+				}
+				if (npixels)
+				{
+					mean = mean/npixels;
+					pages[b]->setVal(c,l,decMem->params().ncols_,mean);
+				}
+				c++;
+			}
+			l++;
+		}
+	}
+}
+
+
+/*
+This routine builds a multi-resolution pyramid with nLevels in a raster representation.
+The raster representation should be a raster stored in a TerraLib database.
+The raster representation should have been built in blocks with width and height power of 2.
+*/
+bool TeBuildMultiResolutionPyramid(TeRaster* rst, int nLevels)
+{
+	if (!rst)
+		return false;
+	if (nLevels <= 1)
+		return false;
+	if (rst->params().decoderIdentifier_ != "DB")
+		return false;
+	int bw = rst->params().blockWidth_;
+	int bh = rst->params().blockHeight_;
+
+	/* check to see if bw and bh are power of 2 */
+	if (bw == 0 || bh == 0 ||
+	   (bw & (bw - 1)) != 0  || (bh & (bh - 1)) != 0)
+	{
+		return false;
+	}
+	
+	TeBox rstBB = rst->params().boundingBox();
+
+	// build a vector of pages in memory
+	vector<TeMemoryPage*> pages;
+	int b;
+	for (b=0; b<rst->params().nBands(); ++b)
+	{
+		TeMemoryPage* block = new TeMemoryPage(bh*bw, 
+											   rst->params().dummy_[b],
+											   rst->params().dataType_[b]);
+		block->ulCol_ = 0;
+		block->ulLin_ = 0;
+		pages.push_back(block);
+	}
+
+	// auxiliary variables
+	int ulCol, 
+		ulLin, 
+		band, 
+		res, 
+		subb, 
+		ulColStart, 
+		ulLinStart;
+
+	// parameters of a upper level
+	TeRasterParams parUp = rst->params();
+	parUp.mode_ = 'w';
+
+	// a decoder im memory for the lower level blocks
+	TeDecoderMemory*	decMem    = new TeDecoderMemory();
+
+	// a decoder database for the upper level of the pyramid
+	TeDecoderDatabase*	decDBUpperLevel = new TeDecoderDatabase(parUp);
+
+	// more auxiliary variables
+	int pxBUp=-1, pyBUp=-1;
+	int xBUp, yBUp;
+	int bUlx, bUly;
+
+	bool flag = true;
+	string bid;
+	char baux[60];
+
+	TeRasterParams parBlock;
+	int r = 2;
+	for (int nl=0; nl<nLevels; ++nl)
+	{
+		// select all the blocks from lower level
+		if (!rst->selectBlocks(rstBB,r/2,parBlock) )
+		{
+			delete decMem;
+			delete decDBUpperLevel;
+			return false;
+		}
+
+		decMem->updateParams(parBlock);
+		decMem->init();
+		parUp.boundingBoxResolution(rstBB.x1_, rstBB.y1_, rstBB.x2_, rstBB.y2_,
+	    							rst->params().resx_*r,rst->params().resy_*r,
+									TeBox::TeLOWERLEFT);
+		parUp.resolution_ = r;
+		decDBUpperLevel->updateParams(parUp);
+		
+		pxBUp=-1;
+		pyBUp=-1;
+		// for each block of the lower level
+		do
+		{
+			// retrieve the lower level block
+			flag = rst->fetchRasterBlock(decMem);
+			TeRasterParams& par = decMem->params();
+
+			// get the coordinate of the  lower level block upper left corner
+			TeBox blockBox = par.boundingBox();
+			TeCoord2D auxC(blockBox.x1_+4*par.resx_,blockBox.y2_-4*par.resy_);
+			TeCoord2D ij = parUp.coord2Index(auxC);
+			ulColStart = TeRoundRasterIndex(ij.x_);
+			ulLinStart = TeRoundRasterIndex(ij.y_);
+			
+			// find the correspondent upper level block that contains the coordinate
+			bid = decDBUpperLevel->codifyId(ulColStart,ulLinStart,0,r,0);
+			sscanf(bid.c_str(),"X%dY%d",&xBUp,&yBUp);
+			decDBUpperLevel->decodifyId(bid,bUlx,bUly,band,res,subb);
+
+			// check to which quadrant in the upper level block the lower level block fits
+			if (ulColStart >= (bUlx+bw/2))
+				ulColStart = bUlx+bw/2;
+			else
+				ulColStart = bUlx;
+
+			if (ulLinStart >= (bUly+bh/2))
+				ulLinStart = bUly+bh/2;
+			else
+				ulLinStart = bUly;
+
+			// check if the upper level block is in already in memory
+			if (pxBUp != xBUp || pyBUp != yBUp)
+			{	
+				for (b=0; b<rst->params().nBands(); ++b)
+				{
+					// if it is not the first blocks do the swapping from memory to db
+					if (pxBUp >= 0 && pyBUp >= 0)
+					{
+						// save blocks from memory
+						sprintf(baux,"X%dY%dB%dR%dS0",pxBUp, pyBUp,b,r);
+						decDBUpperLevel->putRasterBlock(baux,pages[b]->data_, parUp.blockHeight_*parUp.blockWidth_);
+					}
+					// get the needed one
+					pages[b]->clear();
+					sprintf(baux,"X%dY%dB%dR%dS0",xBUp,yBUp,b,r);
+					decDBUpperLevel->getRasterBlock(baux,pages[b]->data_);
+					TeBlockIndex index;
+					index.band_ = b;
+					index.col_ = xBUp;
+					index.lin_ = yBUp;
+					decDBUpperLevel->blockIndexPos(index,ulCol,ulLin,b);
+					pages[b]->ulLin_ = ulLin;
+					pages[b]->ulCol_ = ulCol;
+				}
+				// keep track of the blocks in memory
+				pxBUp = xBUp;
+				pyBUp = yBUp;
+			}
+			// write lower level block into upper level block using a 3x3 smoothing window (mean)
+			TeCalculateMean(decMem,pages,ulColStart,ulLinStart);
+
+		}while (flag);
+
+		// save the last blocks in memory
+		for (b=0; b<rst->params().nBands(); ++b)
+		{
+			sprintf(baux,"X%dY%dB%dR%dS0",xBUp,yBUp,b,r);
+			decDBUpperLevel->putRasterBlock(baux,pages[b]->data_, parUp.blockHeight_*parUp.blockWidth_);
+		}
+		// reset level selection
+		rst->clearBlockSelection();
+		decMem->resetMemory();
+		r *= 2;
+	}
+	delete decMem;
+	delete decDBUpperLevel;
+	for (b=0; b<rst->params().nBands(); ++b)
+		delete pages[b];
+	return true;
+}
diff --git a/src/terralib/kernel/TeImportRaster.h b/src/terralib/kernel/TeImportRaster.h
new file mode 100644
index 0000000..73dfdb9
--- /dev/null
+++ b/src/terralib/kernel/TeImportRaster.h
@@ -0,0 +1,105 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeImportRaster.h
+    \brief This file contains functions to support importing of raster data into a TerraLib database
+*/
+#ifndef __TERRALIB_INTERNAL_IMPORTRASTER_H
+#define __TERRALIB_INTERNAL_IMPORTRASTER_H
+
+#include "TeDataTypes.h"
+#include "TeRasterParams.h"
+
+#include <string>
+using namespace std;
+
+class TeLayer;
+class TeRaster;
+/** @defgroup RasterFunctions Functions to deal with raster data
+ *  @{
+*/
+//! Imports a TeRaster object to a database creationg a new TeLayer
+/*!
+	This function imports a raster to the database, generating a new layer.
+      \param layerName name of the layer to be created
+      \param rasterIn a pointer to the raster representation to be imported
+      \param database a pointer to the database where the raster will be imported
+	  \returns a pointer to the generated layer
+*/
+TL_DLL TeLayer* TeImportRaster (const string& layerName, TeRaster* rasterIn, TeDatabase* database);
+
+//! Imports a TeRaster object to a TeLayer
+/*!
+	This function imports a raster as a geometry of an object of a layer.
+      \param layer pointer to a layer already created
+      \param rasterIn a raster representation
+	  \param bWidth width of the blocks used to store the raster
+	  \param bHeight height of the blocks used to store the raster
+	  \param compress compression type
+	  \param objectId object identification associated to this raster
+	  \param dummy value to be used as a no data value when importing
+	  \param useDummy flag used to indicate that imported raster will have a dummy value
+	  \param indext type of tiling used to import raster
+	  \returns true or false whether the raster was imported successfully
+*/
+TL_DLL bool TeImportRaster (TeLayer* layer, TeRaster* rasterIn, unsigned int bWidth=512, unsigned int bHeight=512, 
+		TeRasterParams::TeRasterCompressionMode compress = TeRasterParams::TeNoCompression, 
+		const string& objectId="", double dummy=255,bool useDummy = false, 
+		TeRasterParams::TeRasterTilingType indext=TeRasterParams::TeNoExpansible);
+
+//! This function mosaics an input raster to one previsously existing in a TerraLib layer
+/*!
+     \param rasterIn a raster representation
+     \param layer pointer to an existing layer 
+	 \param objectId object identification associated to this raster
+	 \returns true or false whether the mosaic operation was successfull
+*/
+TL_DLL bool TeMosaicRaster(TeRaster* rasterIn, TeLayer* layer,  const string& objectId="");
+
+//! Builds a degraded resolution of a raster data
+/*!
+      \param layer pointer to a layer already created 
+      \param rasterIn a raster representation
+	  \param resFac  value to multiply the original resolution
+	  \param objectId object identification associated to this raster
+	  \returns true or false whether the raster was imported successfully
+*/
+TL_DLL bool TeBuildLowerResolution(TeLayer* layer, TeRaster* rasterIn, int resFac, const string& objectId="");
+
+//! Builds the multi resolution pyramid for a given raster
+TL_DLL bool TeBuildMultiResolutionPyramid(TeRaster* rst, int nLevels);
+/** @} */ 
+
+/** \example importJPEG.cpp
+	Shows how to import a JPEG file
+ */
+
+/** \example importGridData.cpp
+	Shows how a raster data: a binary raw grid data
+ */
+
+/** \example mosaciTIFFImages.cpp
+ * This is an example of how to build a mosaic of images as a layer in a TerraLib database
+ */
+
+#endif
+
diff --git a/src/terralib/kernel/TeInitRasterDecoders.cpp b/src/terralib/kernel/TeInitRasterDecoders.cpp
new file mode 100644
index 0000000..c0bc4a1
--- /dev/null
+++ b/src/terralib/kernel/TeInitRasterDecoders.cpp
@@ -0,0 +1,77 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeInitRasterDecoders.h"
+#include "TeDecoderMemoryMap.h"
+#include "TeDecoderMemory.h"
+#include "TeDecoderSmartMem.h"
+
+#ifndef NO_TETIFF //FAMI
+#include "TeDecoderTIFF.h"
+#endif
+
+#ifndef NO_TEJPEG //FAMI
+#include "TeDecoderJPEG.h"
+#endif
+
+#include "TeDecoderDatabase.h"
+#include "TeDecoderFile.h"
+#include "TeDecoderSPR.h"
+#include "TeDecoderASCIIGrid.h"
+
+#include <map>
+
+void 
+TeInitRasterDecoders()
+{
+	static bool TeRasterDecoderFactoryInitalized__ = false;
+
+	if (!TeRasterDecoderFactoryInitalized__)
+	{
+		TeRasterDecoderFactoryInitalized__ = true;
+
+		static TeDecoderDatabaseFactory theDecoderDatabaseFactory("DB");
+
+		static TeDecoderMemoryFactory theDecoderMemoryFactory("MEM");
+
+		static TeDecoderSmartMemFactory teDecoderSmartMemFactory("SMARTMEM");
+
+		static TeDecoderMemoryMapFactory theDecoderMemoryMapFactory("MEMMAP");
+
+#ifndef NO_TETIFF //FAMI
+		static TeDecoderTIFFFactory theDecoderTIFFFactory("TIF");
+#endif
+
+		static TeDecoderSPRFactory theDecoderSPRFactory("SPR");
+
+		static TeDecoderASCIIGridFactory theDecoderASCIIGridFactory("ASCIIGRID");
+
+#ifndef NO_TEJPEG //FAMI
+		static TeDecoderJPEGFactory theDecoderJPEGFactory("JPEG");
+#endif
+
+#ifdef WIN32
+		static TeDecoderFileFactory theDecoderFileFactory("RAW");
+#endif	
+   }
+}
diff --git a/src/terralib/kernel/TeInitRasterDecoders.h b/src/terralib/kernel/TeInitRasterDecoders.h
new file mode 100644
index 0000000..4ada2ab
--- /dev/null
+++ b/src/terralib/kernel/TeInitRasterDecoders.h
@@ -0,0 +1,37 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeInitRasterDecoders.h
+    \brief This file contains functions to deal with the initialization of raster decoding tool
+*/
+#ifndef TeInitRasterDecoders_H
+#define TeInitRasterDecoders_H
+
+#include "TeDefines.h"
+
+//! Initializes the system of decoding raster data by using the basic decoders provided by TerraLib
+/*! 
+	\sa TeRaster TeDecoder TeRasterParams
+*/
+TL_DLL void TeInitRasterDecoders();
+#endif
+
diff --git a/src/terralib/kernel/TeIntersector.cpp b/src/terralib/kernel/TeIntersector.cpp
new file mode 100644
index 0000000..da42877
--- /dev/null
+++ b/src/terralib/kernel/TeIntersector.cpp
@@ -0,0 +1,1056 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeIntersector.h"
+#include "TeRTree.h"
+#include "TeGeometryAlgorithms.h"
+#include <map>
+
+using namespace std;
+
+short TeINTERSECTOR2::TeCCW(const TeCoord2D& c1, const TeCoord2D& c2, const TeCoord2D& c3, bool& between)
+{
+	double dx1 = c2.x() - c1.x();
+	double dx2 = c3.x() - c1.x();
+	double dy1 = c2.y() - c1.y();
+	double dy2 = c3.y() - c1.y();
+
+	double dx1y2 = dx1 * dy2;
+	double dy1x2 = dy1 * dx2;
+
+	double coef = fabs(dx1y2 - dy1x2);
+
+	if(coef == 0.0)
+	{
+		// check if c3 is between c1 and c2
+		TeBox b;
+		b.x1_ = MIN(c1.x(), c2.x());
+		b.y1_ = MIN(c1.y(), c2.y());
+		b.x2_ = MAX(c1.x(), c2.x());
+		b.y2_ = MAX(c1.y(), c2.y());
+
+		if(::TeIntersects(c3, b))
+			between = true;
+
+		return TeNOTURN;
+	}
+	else
+	{
+		TeCoord2D pinter;
+		double dist = TePerpendicularDistance(c1, c2, c3, pinter); 
+
+		if(dist <= TePrecision::instance().precision())
+		{
+			// check if c3 is between c1 and c2
+			TeBox b;
+			b.x1_ = MIN(c1.x(), c2.x());
+			b.y1_ = MIN(c1.y(), c2.y());
+			b.x2_ = MAX(c1.x(), c2.x());
+			b.y2_ = MAX(c1.y(), c2.y());
+
+			if(::TeIntersects(c3, b))
+				between = true;
+
+			return TeNOTURN;
+		}
+		else			
+		{
+			if(dx1y2 > dy1x2)
+			{
+				return TeCOUNTERCLOCKWISE;
+			}
+			else
+			{
+				return TeCLOCKWISE;
+			}
+		}
+	}
+}
+
+bool TeINTERSECTOR2::TeIntersection(const TeCoord2D& a, const TeCoord2D& b, const TeCoord2D& c, const TeCoord2D& d, TeBoundaryIP& ips, TeSegmentIntersectionType& intersectionType)
+{
+	if(TeEquals(a, b))
+		return false;
+
+	if(TeEquals(c, d))
+		return false;
+
+	double xmin1 = MIN(a.x(), b.x());
+	double ymin1 = MIN(a.y(), b.y());
+	double xmax1 = MAX(a.x(), b.x());
+	double ymax1 = MAX(a.y(), b.y());
+	TeBox b1(xmin1, ymin1, xmax1, ymax1);
+
+	double xmin2 = MIN(c.x(), d.x());
+	double ymin2 = MIN(c.y(), d.y());
+	double xmax2 = MAX(c.x(), d.x());
+	double ymax2 = MAX(c.y(), d.y());
+	TeBox b2(xmin2, ymin2, xmax2, ymax2);
+
+	if(::TeIntersects(b1, b2))
+	{
+		if((TeEquals(a, c) || TeEquals(a, d)) && (TeEquals(b, c) || TeEquals(b, d)))
+		{
+			intersectionType = TeImproperIntersection;
+
+			ips.coords_.push_back(c);
+			ips.coords_.push_back(d);
+
+			return true;
+		}
+
+		bool between1 = false;
+		short sign1 = TeINTERSECTOR2::TeCCW(a, b, c, between1);
+
+		bool between2 = false;
+		short sign2 = TeINTERSECTOR2::TeCCW(a, b, d, between2);
+
+		bool between3 = false;
+		short sign3 = TeINTERSECTOR2::TeCCW(c, d, a, between3);
+
+		bool between4 = false;
+		short sign4 = TeINTERSECTOR2::TeCCW(c, d, b, between4);
+
+		if(((sign1 * sign2) <= 0) && ((sign3 * sign4) <= 0))	// if there is an intersection
+		{
+			intersectionType = TeProperIntersection;
+
+			if(between1)
+			{			
+				intersectionType = TeImproperIntersection;
+				ips.coords_.push_back(c);
+			}
+			
+			if(between2)
+			{
+				intersectionType = TeImproperIntersection;
+				ips.coords_.push_back(d);
+			}
+
+			if(between3 && !TeEquals(a, c) && !TeEquals(a, d))
+			{
+				intersectionType = TeImproperIntersection;
+
+				if(ips.coords_.size() == 2)
+					return true;
+
+				if(ips.coords_.size() == 1)
+				{
+					if(TeEquals(ips.coords_[0], a))
+						return true;
+				}
+
+				ips.coords_.push_back(a);
+			}
+			
+			if(between4 && !TeEquals(b, c) && !TeEquals(b, d))
+			{
+				intersectionType = TeImproperIntersection;
+
+				if(ips.coords_.size() == 2)
+					return true;
+
+				if(ips.coords_.size() == 1)
+				{
+					if(TeEquals(ips.coords_[0], b))
+						return true;
+				}
+
+				ips.coords_.push_back(b);
+			}
+
+			if(intersectionType == TeImproperIntersection)
+				return true;
+
+			double denominator = (d.y() - c.y()) * (b.x() - a.x()) - (d.x() - c.x()) * (b.y() - a.y());
+			
+			if(denominator == 0.0)	// parallel can not occur here any more! I expect this is true!
+				return false;		
+
+			// parameters
+			double Ua = ((d.x() - c.x()) * (a.y() - c.y()) - (d.y() - c.y()) * (a.x() - c.x())) / denominator; 
+			//double Ub = ((b.x() - a.x()) * (a.y() - c.y()) - (b.y() - a.y()) * (a.x() - c.x())) / denominator; 
+
+			TeCoord2D caux(a.x() + Ua * (b.x() - a.x()), a.y() + Ua * (b.y() - a.y()));
+
+			if(TeEquals(caux, a))
+			{
+				ips.coords_.push_back(a);
+				return true;
+			}
+
+			if(TeEquals(caux, b))
+			{
+				ips.coords_.push_back(b);
+				return true;
+			}
+
+			if(TeEquals(caux, c))
+			{
+				ips.coords_.push_back(c);
+				return true;
+			}
+
+			if(TeEquals(caux, d))
+			{
+				ips.coords_.push_back(d);
+				return true;
+			}
+
+			ips.coords_.push_back(caux);
+			
+			return true;
+		}
+	}
+
+	intersectionType = TeImproperIntersection;
+
+	return false;
+}
+
+bool TeINTERSECTOR2::TeIntersects(const TeCoord2D& a, const TeCoord2D& b, const TeCoord2D& c, const TeCoord2D& d, TeSegmentIntersectionType& intersectionType)
+{	
+	if(TeEquals(a, b))
+		return false;
+
+	if(TeEquals(c, d))
+		return false;
+
+	double xmin1 = MIN(a.x(), b.x());
+	double ymin1 = MIN(a.y(), b.y());
+	double xmax1 = MAX(a.x(), b.x());
+	double ymax1 = MAX(a.y(), b.y());
+	TeBox b1(xmin1, ymin1, xmax1, ymax1);
+
+	double xmin2 = MIN(c.x(), d.x());
+	double ymin2 = MIN(c.y(), d.y());
+	double xmax2 = MAX(c.x(), d.x());
+	double ymax2 = MAX(c.y(), d.y());
+	TeBox b2(xmin2, ymin2, xmax2, ymax2);
+
+	if(::TeIntersects(b1, b2))
+	{
+		if((TeEquals(a, c) || TeEquals(a, d)) && (TeEquals(b, c) || TeEquals(b, d)))
+		{
+			intersectionType = TeImproperIntersection;
+
+			return true;
+		}
+
+		bool between1 = false;
+		short sign1 = TeINTERSECTOR2::TeCCW(a, b, c, between1);
+
+		bool between2 = false;
+		short sign2 = TeINTERSECTOR2::TeCCW(a, b, d, between2);
+
+		bool between3 = false;
+		short sign3 = TeINTERSECTOR2::TeCCW(c, d, a, between3);
+
+		bool between4 = false;
+		short sign4 = TeINTERSECTOR2::TeCCW(c, d, b, between4);
+
+		if((sign1 * sign2) <= 0 && (sign3 * sign4 <= 0))	// if there is an intersection
+		{
+			intersectionType = TeProperIntersection;
+
+			if(between1 || between2 || between3 || between4)
+			{			
+				intersectionType = TeImproperIntersection;
+			}			
+
+			return true;
+		}
+	}
+		
+	return false;
+}
+
+bool TeINTERSECTOR2::TeIntersects(const TeLine2D& redLine, const TeLine2D& blueLine)
+{
+	if(redLine.size() < 2 || blueLine.size() < 2) 
+		return false; 
+
+	if(TeDisjoint(redLine.box(), blueLine.box()))
+		return false;
+
+	unsigned int i = 0;
+	unsigned int j = 0;
+
+	TeBox interBox;
+	
+	// Creates a intersection box from lines boxes.
+	::TeIntersection(redLine.box(), blueLine.box(), interBox);
+
+	unsigned int nstep_redLine  = redLine.size() - 1;
+	unsigned int nstep_blueLine = blueLine.size() - 1;
+
+	TeSegmentIntersectionType t = TeImproperIntersection;
+
+	for(i = 0; i < nstep_redLine; ++i)
+	{
+		// Creates the segment box.
+		TeBox red_box = makeBox(redLine[i].x(), redLine[i].y(), redLine[i+1].x(), redLine[i+1].y());
+
+		// See if red segment box intersects with the intersection box.
+		if(TeDisjoint(interBox, red_box))
+			continue;	// If it doesn't intersect, go to another segment => skip comparasion beteween other "m" segments.
+
+		for(j = 0; j < nstep_blueLine; ++j)
+		{
+			// Check intersection.
+			if(TeINTERSECTOR2::TeIntersects(redLine[i], redLine[i+1], blueLine[j], blueLine[j+1], t))
+				return true;
+		}
+	}	
+
+	return false;
+}
+
+bool TeINTERSECTOR2::TeSafeIntersections(const TeLine2D& redLine, const TeLine2D& blueLine, TeVectorBoundaryIP& report, const unsigned int& redObjId, const unsigned int& blueObjId)
+{
+	if(redLine.size() < 2 || blueLine.size() < 2) 
+		return false; 
+
+	if(TeDisjoint(redLine.box(), blueLine.box()))
+		return false;
+
+	unsigned int i = 0;
+	unsigned int j = 0;
+
+	TeBox interBox;
+	
+	bool hasIntersections = false;
+
+	// Creates a intersection box from lines boxes.
+	::TeIntersection(redLine.box(), blueLine.box(), interBox);
+
+	unsigned int nstep_redLine  = redLine.size() - 1;
+	unsigned int nstep_blueLine = blueLine.size() - 1;
+
+	TeSegmentIntersectionType t = TeImproperIntersection;
+
+	for(i = 0; i < nstep_redLine; ++i)
+	{
+		// Creates the segment box.
+		TeBox red_box = makeBox(redLine[i].x_, redLine[i].y_, redLine[i+1].x_, redLine[i+1].y_);
+
+		// See if red segment box intersects with the intersection box.
+		if(TeDisjoint(interBox, red_box))
+			continue;	// If it doesn't intersect, go to another segment => skip comparasion beteween other "m" segments.
+
+		for(j = 0; j < nstep_blueLine; ++j)
+		{
+			// Check intersection.
+			TeBoundaryIP ip;
+
+			if(TeIntersection(redLine[i], redLine[i+1], blueLine[j], blueLine[j+1], ip, t))
+			{
+				hasIntersections = true;
+
+				ip.redPartNum_ = redObjId;
+				ip.redSegNum_ = i;
+				ip.bluePartNum_ = blueObjId;
+				ip.blueSegNum_ = j;
+
+				if(ip.coords_.size() == 2)	//overlap
+				{
+					// Verificar se os pontos est�o em ordem crescente
+					if(ip.coords_[0].x_ < ip.coords_[1].x_)
+					{
+						report.push_back(ip);
+					}
+					else if(ip.coords_[0].x_ > ip.coords_[1].x_)
+					{
+						swap(ip.coords_[0], ip.coords_[1]);
+						report.push_back(ip);
+					}
+					else if(ip.coords_[0].y_ < ip.coords_[1].y_)
+					{
+						report.push_back(ip);						
+					}
+					else
+					{
+						swap(ip.coords_[0], ip.coords_[1]);
+						
+						report.push_back(ip);						
+					}
+
+				}
+				else
+				{
+					report.push_back(ip);
+				}
+			}
+		}
+	}	
+
+	return hasIntersections;
+}
+
+bool TeINTERSECTOR2::TeSafeIntersections(const TePolygonSet& redPols, const TePolygonSet& bluePols, TeVectorBoundaryIP& report)
+{
+	unsigned int redPart = 0;
+	unsigned int redPolsSize = redPols.size();
+
+	unsigned int i, k;
+	register unsigned int j, l;
+
+	// Loops through red polygons
+	for(i = 0; i < redPolsSize; ++i)
+	{
+		TePolygon redPol = redPols[i];
+		unsigned int redPolSize = redPol.size();
+
+		// Loops through red polygons rings
+		for(j = 0; j < redPolSize; ++j)
+		{
+			TeLinearRing redRing = redPol[j];			
+
+			// Loops through blue polygons
+			unsigned int bluePart = 0;
+			unsigned int bluePolsSize =  bluePols.size();
+
+			for(k = 0; k < bluePolsSize; ++k)
+			{
+				// Loops through blue polygons rings
+				TePolygon bluePol = bluePols[k];
+
+				unsigned int bluePolSize = bluePol.size();
+
+				for(l = 0; l < bluePolSize; ++l)
+				{
+					TeLinearRing blueRing = bluePol[l];
+
+					TeSafeIntersections(redRing, blueRing, report, redPart, bluePart);
+
+					++bluePart;
+				}
+			}
+
+			++redPart;
+		}
+	}
+
+	return !report.empty();
+}
+
+// Put polygon set segments into the index
+void TeINTERSECTOR2::TeIndexPolygonSet(const TePolygonSet& polygons, TeINTERSECTOR2::TeSegmentRTree& tree)
+{
+	unsigned int nPols = polygons.size();	
+	unsigned int i, j, k;
+
+	for(i = 0; i < nPols; ++i)
+	{
+		unsigned int nRings = polygons[i].size();
+
+		for(j = 0; j < nRings; ++j)
+		{
+			unsigned int nSegs = polygons[i][j].size() - 1;
+
+			for(k = 0; k < nSegs; ++k)
+			{
+				TeBox b;
+
+				b.x1_ = MIN(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y1_ = MIN(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+				b.x2_ = MAX(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y2_ = MAX(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+
+				TeINTERSECTOR2::TeSegIdInPolygonSet sid;
+
+				sid.polId_  = i;
+				sid.lineId_   = j;
+				sid.segId_ = k;
+
+				tree.insert(b, sid);
+			}
+		}
+	}
+
+	return;
+}
+
+// Estrutura auxiliar para indexar cada um dos pontos de intersecao em um multimap
+struct TeIntersectionIndexKey
+{
+	unsigned int segNum_;
+	unsigned int partNum_;
+	unsigned int polNum_;
+
+	TeIntersectionIndexKey()
+		: segNum_(0), partNum_(0), polNum_(0)
+	{
+	}
+
+	TeIntersectionIndexKey(const unsigned int& segNum, const unsigned int& partNum, const unsigned int& polNum)
+		: segNum_(segNum), partNum_(partNum), polNum_(polNum)
+	{
+	}
+
+	bool operator<(const TeIntersectionIndexKey& rhs) const
+	{
+		if(polNum_ < rhs.polNum_)
+			return true;
+
+		if(polNum_ > rhs.polNum_)
+			return false;
+
+		if(partNum_ < rhs.partNum_)
+			return true;
+
+		if(partNum_ > rhs.partNum_)
+			return false;
+
+		if(segNum_ < rhs.segNum_)
+			return true;
+
+		if(segNum_ > rhs.segNum_)
+			return false;
+
+		return false;
+	}
+};
+
+
+typedef multimap<TeIntersectionIndexKey, unsigned int> TeIntersectionIndex;
+
+// Dado um ponto de intersecao, faz a normalizacao do mesmo: procura um ponto correlato na lista de intersecao e tenta usar as mesmas coordenadas
+void TeNormalizeIntersection(TeINTERSECTOR2::TeBoundaryIP& ip, TeINTERSECTOR2::TeVectorBoundaryIP& report, TeIntersectionIndex& interIndex)
+{
+	TeIntersectionIndexKey key(ip.blueSegNum_, ip.bluePartNum_, ip.bluePolNum_);
+
+	pair<TeIntersectionIndex::iterator, TeIntersectionIndex::iterator> its = interIndex.equal_range(key);
+
+//	bool eraseOwn = false;
+
+	while(its.first != its.second)
+	{
+// se achamos um indice, vamos verificar se ele possui um ponto de intersecao que seja igual ao que temos em maos, segundo a tolerancia
+		unsigned int position = its.first->second;
+
+		if(TeEquals(report[position].coords_[0], ip.coords_[0]))
+		{
+			ip.coords_[0] = report[position].coords_[0];
+		}
+
+		if(ip.coords_.size() == 2 && report[position].coords_.size() == 1)
+		{
+			if(TeEquals(report[position].coords_[0], ip.coords_[1]))
+				ip.coords_[1] = report[position].coords_[0];			
+		}
+
+		if(ip.coords_.size() == 1 && report[position].coords_.size() == 2)
+		{
+			if(TeEquals(report[position].coords_[1], ip.coords_[0]))
+				ip.coords_[0] = report[position].coords_[1];			
+
+		}
+
+		if(ip.coords_.size() == 2 && report[position].coords_.size() == 2)
+
+		{
+			if(TeEquals(report[position].coords_[1], ip.coords_[1]))
+				ip.coords_[1] = report[position].coords_[1];
+
+			if(TeEquals(report[position].coords_[0], ip.coords_[1]))
+				ip.coords_[1] = report[position].coords_[0];
+
+
+			if(TeEquals(report[position].coords_[1], ip.coords_[0]))
+				ip.coords_[0] = report[position].coords_[1];
+		}
+
+		++its.first;
+	}
+}
+
+// insere a informacao da intersecao no indice
+void TeIndexIntersection(TeINTERSECTOR2::TeBoundaryIP& ip, const unsigned int& redPos, const unsigned int& bluePos, TeIntersectionIndex& interIndex)
+{
+	TeIntersectionIndexKey redkey(ip.redSegNum_, ip.redPartNum_, ip.redPolNum_);
+	TeIntersectionIndexKey bluekey(ip.blueSegNum_, ip.bluePartNum_, ip.bluePolNum_);
+
+	interIndex.insert(pair<TeIntersectionIndexKey, unsigned int>(redkey, redPos));
+	interIndex.insert(pair<TeIntersectionIndexKey, unsigned int>(bluekey, bluePos));
+}
+
+// insere o ponto de intersecao na lista
+void TeInsertIntersection(TeINTERSECTOR2::TeBoundaryIP& ip, TeINTERSECTOR2::TeVectorBoundaryIP& report)
+{
+	if(ip.coords_.size() == 2)	//overlap
+	{
+// put intersections in increase order of 'x'
+		if(ip.coords_[0].x_ < ip.coords_[1].x_)
+		{
+			report.push_back(ip);
+		}
+		else if(ip.coords_[0].x_ > ip.coords_[1].x_)
+		{
+			swap(ip.coords_[0], ip.coords_[1]);
+			report.push_back(ip);			
+		}
+		else if(ip.coords_[0].y_ < ip.coords_[1].y_)
+		{
+			report.push_back(ip);						
+		}
+		else
+		{
+			swap(ip.coords_[0], ip.coords_[1]);							
+			report.push_back(ip);
+		}
+	}
+	else
+	{
+		report.push_back(ip);
+	}
+}
+
+// Find intersection into two distinct sets: red and blue
+bool TeINTERSECTOR2::TeIntersection(const TePolygonSet& redPolygons, TeINTERSECTOR2::TeSegmentRTree& redTree, const TePolygonSet& bluePolygons, TeINTERSECTOR2::TeVectorBoundaryIP& report)
+{
+// if index is empty, so we index first
+	if(redTree.isEmpty())
+		TeINTERSECTOR2::TeIndexPolygonSet(redPolygons, redTree);
+
+	TeIntersectionIndex interIndex;
+
+	unsigned int nPols = bluePolygons.size();	
+
+	TeSegmentIntersectionType t = TeImproperIntersection;
+
+	unsigned int i, j, k, l;
+	for(i = 0; i < nPols; ++i)
+	{
+		unsigned int nRings = bluePolygons[i].size();
+
+		for(j = 0; j < nRings; ++j)
+		{
+			unsigned int nSegs = bluePolygons[i][j].size() - 1;
+
+// for each blue segment, find the one's that can intersects it into the red index tree
+			for(k = 0; k < nSegs; ++k)
+			{
+				TeBox b;
+
+				b.x1_ = MIN(bluePolygons[i][j][k].x(), bluePolygons[i][j][k + 1].x());
+				b.y1_ = MIN(bluePolygons[i][j][k].y(), bluePolygons[i][j][k + 1].y());
+				b.x2_ = MAX(bluePolygons[i][j][k].x(), bluePolygons[i][j][k + 1].x());
+				b.y2_ = MAX(bluePolygons[i][j][k].y(), bluePolygons[i][j][k + 1].y());
+
+				vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+
+				redTree.search(b, segs);
+
+				unsigned int nSegsInter = segs.size();
+
+// depois tentamos achar os pontos de intersecao
+				for(l = 0; l < nSegsInter; ++l)
+				{
+					TeINTERSECTOR2::TeBoundaryIP ip1;
+
+					if(TeINTERSECTOR2::TeIntersection(bluePolygons[i][j][k], bluePolygons[i][j][k + 1], redPolygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_], redPolygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_ + 1], ip1, t))
+					{
+						ip1.redPolNum_ = segs[l].polId_;
+						ip1.redPartNum_ = segs[l].lineId_;
+						ip1.redSegNum_ = segs[l].segId_;
+
+						ip1.bluePolNum_ = i;
+						ip1.bluePartNum_ = j;
+						ip1.blueSegNum_ = k;
+
+						// normaliza a intersecao: se achar um outro pontos na lista de intersecao semelhante, usaremos o semelhante!
+						TeNormalizeIntersection(ip1, report, interIndex);
+
+
+						TeINTERSECTOR2::TeBoundaryIP ip2;	// objeto auxiliar
+						ip2.redPolNum_ = i;
+						ip2.redPartNum_ = j;
+						ip2.redSegNum_ = k;
+
+						ip2.bluePolNum_ = segs[l].polId_;
+						ip2.bluePartNum_ = segs[l].lineId_;
+						ip2.blueSegNum_ = segs[l].segId_;
+
+						ip2.coords_ = ip1.coords_;
+
+						TeNormalizeIntersection(ip2, report, interIndex);
+
+						ip1.coords_ = ip2.coords_;
+
+						TeInsertIntersection(ip1, report);						
+
+						TeIndexIntersection(ip1, report.size() - 1, report.size() - 1, interIndex);
+					}
+				}
+			}			
+		}
+	}
+
+	return !report.empty();
+}
+
+bool TeINTERSECTOR2::TeIsSimple(const TePolygonSet& polygons, vector<TeINTERSECTOR2::TePairSegIdInPolygonSet>& selfIntersectionList)
+{
+	bool hasSelfIntersection = false;
+
+	TeSegmentIntersectionType t = TeImproperIntersection;
+
+// create index tree
+	TeINTERSECTOR2::TeSegmentRTree tree(polygons.box());
+
+// loop through segments
+	unsigned int nPols = polygons.size();	
+
+	unsigned int i, j, k, l;
+
+	for(i = 0; i < nPols; ++i)
+	{
+		unsigned int nRings = polygons[i].size();
+
+		for(j = 0; j < nRings; ++j)
+		{
+			unsigned int nSegs = polygons[i][j].size() - 1;
+
+			for(k = 0; k < nSegs; ++k)
+			{
+				TeBox b;
+
+				b.x1_ = MIN(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y1_ = MIN(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+				b.x2_ = MAX(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y2_ = MAX(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+
+				TeINTERSECTOR2::TeSegIdInPolygonSet sid;
+
+				sid.polId_  = i;
+				sid.lineId_   = j;
+				sid.segId_ = k;
+
+// try to find filter segments that boxe intersects this segment
+				vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+	
+				tree.search(b, segs);
+
+				unsigned int nSegsInter = segs.size();
+
+// if found, loops through segments to see if there are intersections
+				for(l = 0; l < nSegsInter; ++l)
+				{
+					TeINTERSECTOR2::TeBoundaryIP ip;
+
+					if(TeIntersection(polygons[i][j][k], polygons[i][j][k + 1], polygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_], polygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_ + 1], ip, t))
+					{
+// if there is intersection, we have to cases:
+						if(ip.coords_.size() == 2)
+						{
+// first, the segment overlaps another: so this configures a selfintersection
+							hasSelfIntersection = true;
+
+							selfIntersectionList.push_back(TePairSegIdInPolygonSet(sid, segs[l]));
+						}
+						else
+						{
+// second, the segment intersects in one point: so this may be a selft-intersection or may be a intersection between the posterior segment (already inserted) in this second, no worry it is right
+							if((sid.polId_ != segs[l].polId_) || (sid.lineId_ != segs[l].lineId_))
+							{
+								hasSelfIntersection = true;
+
+								selfIntersectionList.push_back(TePairSegIdInPolygonSet(sid, segs[l]));
+							}
+							else
+							{
+// we must look if they are consecutives (remeber last an firt will have intersections) 
+								int auxSegId = (int)sid.segId_;
+								int otherSegId = (int)(segs[l].segId_);
+
+// if it intersects the previous or the next, it's ok!
+								if((auxSegId == (otherSegId + 1)) || (auxSegId == (otherSegId -1)))
+								{
+									continue;
+								}
+								else
+								{
+// we need to see if it is not between last and first
+									if(auxSegId == (int)(polygons[sid.polId_][sid.lineId_].size() - 2))
+									{
+// ok, it is a consecutive intersection between last and first
+										if(otherSegId == 0)
+											continue;
+									}
+									else if(auxSegId == 0)
+									{
+// ok, it is a consecutive intersection between first and last
+										if(otherSegId == (int)(polygons[segs[l].polId_][segs[l].lineId_].size() - 2))
+											continue;
+									}
+
+									hasSelfIntersection = true;
+
+									selfIntersectionList.push_back(TePairSegIdInPolygonSet(sid, segs[l]));
+								}
+							}
+						}
+
+					}
+				}
+
+// inserts the segment into the tree
+				tree.insert(b, sid);
+			}
+		}
+	}
+
+	tree.clear();
+
+	return !hasSelfIntersection;
+}
+
+// Find intersection into two distinct sets: red lines and blue polygons
+bool TeINTERSECTOR2::TeIntersection(const TeLineSet& redLines, const TePolygonSet& bluePolygons, TeSegmentRTree& blueTree, TeINTERSECTOR2::TeVectorBoundaryIP& report)
+{
+// if index is empty, so we index the segments from polygonset first
+	if(blueTree.isEmpty())
+		TeINTERSECTOR2::TeIndexPolygonSet(bluePolygons, blueTree);
+
+// for each lines we must compute intersections
+	unsigned int nLines = redLines.size();	
+
+	TeSegmentIntersectionType t = TeImproperIntersection;
+
+	unsigned int i, j, l;
+
+	for(i = 0; i < nLines; ++i)
+	{
+		unsigned int nSegs = redLines[i].size() - 1;
+
+		for(j = 0; j < nSegs; ++j)
+		{
+// for each segment we compute intersections
+			TeBox b;
+
+			b.x1_ = MIN(redLines[i][j].x(), redLines[i][j + 1].x());
+			b.y1_ = MIN(redLines[i][j].y(), redLines[i][j + 1].y());
+			b.x2_ = MAX(redLines[i][j].x(), redLines[i][j + 1].x());
+			b.y2_ = MAX(redLines[i][j].y(), redLines[i][j + 1].y());
+
+			vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+
+			blueTree.search(b, segs);
+
+			unsigned int nSegsInter = segs.size();
+
+// depois tentamos achar os pontos de intersecao
+			for(l = 0; l < nSegsInter; ++l)
+			{
+				TeINTERSECTOR2::TeBoundaryIP ip1;
+
+				if(TeINTERSECTOR2::TeIntersection(redLines[i][j], redLines[i][j + 1], bluePolygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_], bluePolygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_ + 1], ip1, t))
+				{
+					ip1.redPolNum_ = 0;
+					ip1.redPartNum_ = i;
+					ip1.redSegNum_ = j;
+
+					ip1.bluePolNum_ = segs[l].polId_;
+					ip1.bluePartNum_ = segs[l].lineId_;
+					ip1.blueSegNum_ = segs[l].segId_;
+
+					if(ip1.coords_.size() == 2)	//overlap
+					{
+						// Verificar se os pontos estao em ordem crescente
+						if(ip1.coords_[0].x_ < ip1.coords_[1].x_)
+						{
+							report.push_back(ip1);
+						}
+						else if(ip1.coords_[0].x_ > ip1.coords_[1].x_)
+						{
+							swap(ip1.coords_[0], ip1.coords_[1]);
+							report.push_back(ip1);
+						}
+						else if(ip1.coords_[0].y_ < ip1.coords_[1].y_)
+						{
+							report.push_back(ip1);						
+						}
+						else
+						{
+							swap(ip1.coords_[0], ip1.coords_[1]);							
+							report.push_back(ip1);						
+						}
+					}
+					else
+					{
+						report.push_back(ip1);
+					}
+				}
+			}
+		}
+	}
+
+	return !report.empty();
+}
+
+// Find intersection between segments into polygonset list
+bool TeINTERSECTOR2::TeIntersection(const TePolygonSet& polygons, TeINTERSECTOR2::TeSegmentRTree& tree, TeINTERSECTOR2::TeVectorBoundaryIP& report)
+{
+// clear tree before start process
+	tree.clear();
+
+	TeIntersectionIndex interIndex;
+
+	unsigned int nPols = polygons.size();	
+
+	if(nPols == 0)
+		return false;
+
+	unsigned int nLines = polygons[0].size();	
+
+	unsigned int i, j, k, l;
+
+// the first polygon's segments are all indexed into the tree
+	for(i = 0; i < nLines; ++i)
+	{
+		unsigned int nSegs = polygons[0][i].size() - 1;
+
+		for(j = 0; j < nSegs; ++j)
+		{
+			TeBox b;
+
+			b.x1_ = MIN(polygons[0][i][j].x(), polygons[0][i][j + 1].x());
+			b.y1_ = MIN(polygons[0][i][j].y(), polygons[0][i][j + 1].y());
+			b.x2_ = MAX(polygons[0][i][j].x(), polygons[0][i][j + 1].x());
+			b.y2_ = MAX(polygons[0][i][j].y(), polygons[0][i][j + 1].y());
+
+			TeINTERSECTOR2::TeSegIdInPolygonSet sid;
+
+			sid.polId_  = 0;
+			sid.lineId_   = i;
+			sid.segId_ = j;
+
+			tree.insert(b, sid);
+		}
+	}
+	
+	TeSegmentIntersectionType t = TeImproperIntersection;
+
+// for each polygon, we first test intersection of all segments  and then put them into the index
+	for(i = 1; i < nPols; ++i)
+	{
+		unsigned int nLines = polygons[i].size();	
+
+// for each line of the polygon, verifies intersection against the segments into the index
+		for(j = 0; j < nLines; ++j)
+		{
+			unsigned int nSegs = polygons[i][j].size() - 1;
+
+			for(k = 0; k < nSegs; ++k)
+			{
+// for each segment we find the one's that intersects its bounding box
+				TeBox b;
+
+				b.x1_ = MIN(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y1_ = MIN(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+				b.x2_ = MAX(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y2_ = MAX(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+
+				vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+
+				tree.search(b, segs);
+
+				unsigned int nSegsInter = segs.size();
+
+// if there are candidates, try to find intersections
+				for(l = 0; l < nSegsInter; ++l)
+				{
+					TeINTERSECTOR2::TeBoundaryIP ip1;
+
+					TeINTERSECTOR2::TeBoundaryIP ip2;
+
+					if(TeINTERSECTOR2::TeIntersection(polygons[i][j][k], polygons[i][j][k + 1], polygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_], polygons[segs[l].polId_][segs[l].lineId_][segs[l].segId_ + 1], ip1, t))
+					{
+// if the segment intersects a candidate, stores theirs intersection points
+						ip1.redPolNum_  = i;
+						ip1.redPartNum_ = j;
+						ip1.redSegNum_  = k;
+						ip1.bluePolNum_ = segs[l].polId_;
+						ip1.bluePartNum_ = segs[l].lineId_;
+						ip1.blueSegNum_ = segs[l].segId_;
+
+						// normaliza a intersecao: se achar um outro pontos na lista de intersecao semelhante, usaremos o semelhante!
+						TeNormalizeIntersection(ip1, report, interIndex);						
+
+						ip2.redPolNum_ = segs[l].polId_;
+						ip2.redPartNum_ = segs[l].lineId_;
+						ip2.redSegNum_ = segs[l].segId_;
+
+						ip2.bluePolNum_ = i;
+						ip2.bluePartNum_ = j;
+						ip2.blueSegNum_ = k;
+
+						ip2.coords_ = ip1.coords_;
+
+						TeNormalizeIntersection(ip2, report, interIndex);
+
+						ip1.coords_ = ip2.coords_;
+
+// insere os pontos de intersecao na lista de intersecao e no multi-map
+						TeInsertIntersection(ip1, report);						
+						TeInsertIntersection(ip2, report);
+
+						TeIndexIntersection(ip1, report.size() - 2, report.size() - 1, interIndex);	
+					}
+				}
+			}
+		}
+	
+// after the search for intersection, put segfments into index
+		for(j = 0; j < nLines; ++j)
+		{
+			unsigned int nSegs = polygons[i][j].size() - 1;
+
+			for(k = 0; k < nSegs; ++k)
+			{
+				TeBox b;
+
+				b.x1_ = MIN(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y1_ = MIN(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+				b.x2_ = MAX(polygons[i][j][k].x(), polygons[i][j][k + 1].x());
+				b.y2_ = MAX(polygons[i][j][k].y(), polygons[i][j][k + 1].y());
+
+				TeSegIdInPolygonSet sid;
+
+				sid.polId_ = i;
+				sid.lineId_ = j;
+				sid.segId_ = k;
+
+				tree.insert(b, sid);
+			}
+		}
+	}
+
+	return !report.empty();
+}
+
diff --git a/src/terralib/kernel/TeIntersector.h b/src/terralib/kernel/TeIntersector.h
new file mode 100644
index 0000000..cd2df83
--- /dev/null
+++ b/src/terralib/kernel/TeIntersector.h
@@ -0,0 +1,214 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file  TeIntersector.h
+    \brief This file contains structures and definitions for line intersection algorithms.
+	\note  These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone because
+           THIS IS FOR INTERNAL USE ONLY.
+    \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+*/
+
+#ifndef  __TERRALIB_INTERNAL_INTERSECTOR2_H
+#define  __TERRALIB_INTERNAL_INTERSECTOR2_H
+
+//TerraLib's include
+#include "TeCoord2D.h"
+#include "TeRTree.h"
+
+//STL's include
+#include <vector>
+
+using namespace std;
+
+/* 
+ *  WARNING: These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone because
+ *           the support and interfaces can be changed in future. THIS IS FOR INTERNAL USE ONLY.
+ */
+
+/*! \brief Contains structures and definitions needed by line intersection algorithms (FOR INTERNAL USE ONLY).
+*/
+namespace TeINTERSECTOR2
+{
+//! An epsilon value used to compare two real numbers
+#define EPSILON_COMPARE 1.0e-15
+
+/** @defgroup IntersectionAlgorithms Intersection Algorithms
+ *  Intersection Algorithms and data structures, used internally.
+ *  @{
+ */
+
+//! This struct is used to represent a point intersection between two segments on boundary of a TePolygon or TeLine2D.
+struct TL_DLL TeBoundaryIP
+{
+	vector<TeCoord2D> coords_;		//!< Points of intersection ocurried along these two segments (red and blue).
+
+	unsigned int redSegNum_;		//!< Red segment number.
+	unsigned int redPartNum_;		//!< Line number in a polygon that a red segment belongs.
+	unsigned int redPolNum_;		//!< Polygon number in a vector of polygons that a segment belongs.
+
+	unsigned int blueSegNum_;		//!< Blue segment number.
+	unsigned int bluePartNum_;		//!< Line number in a polygon that a blue segment belongs.
+	unsigned int bluePolNum_;		//!< Polygon number in a vector of polygons that a segment belongs.
+};
+
+//! This is the type of intersection point list.
+typedef vector<TeBoundaryIP> TeVectorBoundaryIP;
+
+//! This struct represents an index to the right place of a segment in a TeLineSet, TeLine2D, TePolygon or TePolygonSet.
+struct TL_DLL TeSegIdInPolygonSet
+{
+	unsigned int polId_;	//!<  The polygon id, when used in a polygonset.
+	unsigned int lineId_;	//!<  The line id, when used in a lineset or in a polygon.
+	unsigned int segId_;	//!<  The segment id into a specified line.
+};
+
+//! This pair is used to index two segments that intersects.
+typedef pair<TeSegIdInPolygonSet, TeSegIdInPolygonSet> TePairSegIdInPolygonSet;
+
+//! This is the type used to index the segments in the boundary of a TeLine2D, TeLineSet, TePolygon or TePolygonSet.
+typedef TeSAM::TeRTree<TeSegIdInPolygonSet, 8> TeSegmentRTree;
+
+/** \brief Tells if three points makes a right turn, a left turn or are collinear.
+    \param c1       The first coordinate.
+	\param c2       The second coordinate.
+	\param c3       The coordinate to test the relative position.
+	\param between  Tells if c3 is between c1 and c2.
+	\return			The orientation: TeCLOCKWISE, TeCOUNTERCLOCKWISE or TeNOTURN.
+*/
+TL_DLL short TeCCW(const TeCoord2D& c1, const TeCoord2D& c2, const TeCoord2D& c3, bool& between);
+
+/** \brief Returns the intersection point of the segments.
+    \param a                 The first coordinate of the first segment.
+	\param b                 The second coordinate of the first segment.
+	\param c                 The first coordinate of the second segment.
+	\param d                 The second coordinate of the second segment.
+	\param ips               The intersection coordinates (0, 1 or 2).
+	\param intersectionType  An intersection may be proper or improper.
+	\return					 Returns true if there is an intersection between segments defined by end coordinates.
+*/
+TL_DLL bool TeIntersection(const TeCoord2D& a, const TeCoord2D& b, const TeCoord2D& c, const TeCoord2D& d, TeBoundaryIP& ips, TeSegmentIntersectionType& intersectionType);
+
+
+/** \brief Tells if two segments intersects.
+    \param a                 The first coordinate of the first segment.
+	\param b                 The second coordinate of the first segment.
+	\param c                 The first coordinate of the second segment.
+	\param d                 The second coordinate of the second segment.
+	\param intersectionType  An intersection may be proper or improper.
+	\return					 Returns true if there is an intersection between segments defined by end coordinates.
+*/
+TL_DLL bool TeIntersects(const TeCoord2D& a, const TeCoord2D& b, const TeCoord2D& c, const TeCoord2D& d, TeSegmentIntersectionType& intersectionType);
+
+
+/** \brief Verifies if there is an intersection between two given polygonsets.
+    \param redPols  The first polygonset to test.
+	\param bluePols The second polygonset to test.
+	\param report   A list with the intersection points.
+	\return			Returns true if there is an intersection between segments of the polygons.
+	
+	\note WARNING: this is deprecated and will be replaced by another function in near future.
+
+    This is a lazy algorithm. It can be used, for example, in intersections between a box and a line.
+	It is O(n*m) - where n and m are the numbers of segments in the first and second polygonsets.
+ */
+TL_DLL bool TeSafeIntersections(const TePolygonSet& redPols, const TePolygonSet& bluePols, TeVectorBoundaryIP& report);
+
+/** \brief Verifies if there is an intersection between two given lines.
+    \param redLine   The first line to test.
+	\param blueLine  The second line to test.
+	\param report    A list with the intersection points.
+	\param redObjId  Red line object id.
+	\param blueObjId Blue line object id.
+	\return			 Returns true if there is an intersection between segments of the lines.
+	
+	\note WARNING: this is deprecated and will be replaced by another function in near future.
+
+    This is a lazy algorithm. It can be used, for example, in intersections between a box and a line.
+	It is O(n*m) - where n and m are the numbers of segments in the first and second lines.
+ */
+TL_DLL bool TeSafeIntersections(const TeLine2D& redLine, const TeLine2D& blueLine, TeVectorBoundaryIP& report, const unsigned int& redObjId = 0, const unsigned int& blueObjId = 0);
+
+/** \brief Returns true if the lines intersects.
+	\param redLine			The line to test.
+	\param blueLine			The line to test.
+	\return			        Returns true if there is an intersection between segments of the lines.
+
+	\note WARNING: this is deprecated and will be replaced by another function in near future.
+ */
+TL_DLL bool TeIntersects(const TeLine2D& redLine, const TeLine2D& blueLine);
+
+/**	\brief Reports intersections between segments of polygons in the polygonset list.
+	\param polygons		A list of polygons to test self intersections.
+	\param tree			The tree with all index segments, it WILL BE filled inside this method.
+	\param report		A report list of intersection points.
+	\return				Returns true if there is an intersection.
+
+	\note				This function will not returns intersections between segments of the same polygon. It will only
+	                    report intersection between different polygons. The index tree MUST BE EMPTY, othewise, the
+						result is undefined. The result may have duplicated points because intersections are reported 
+						twice: this will turn fragmentation easier.
+ */
+TL_DLL bool TeIntersection(const TePolygonSet& polygons, TeSegmentRTree& tree, TeVectorBoundaryIP& report);
+
+/** \brief Reports intersections between segments of two diferent polygonsets.
+	\param redPolygons	A list of polygons without self intersections.
+	\param redTree		A tree with all red segment already indexed or not, if it is empty, so, it will be filled inside this method.
+	\param bluePolygons	A list of polygons without self intersections.
+	\param report		A report list of intersection points.
+	\return				Returns true if there is an intersection between a red segment and a blue segment.
+
+	\note				This function will not returns intersections between segments of the same polygon. It will only
+	                    report intersection between different polygons. The result may have duplicated points because intersections are reported 
+						twice: this will turn fragmentation easier.
+ */
+TL_DLL bool TeIntersection(const TePolygonSet& redPolygons, TeSegmentRTree& redTree, const TePolygonSet& bluePolygons, TeINTERSECTOR2::TeVectorBoundaryIP& report);
+
+/** \brief Reports intersections between segments of a lineset and a polygonset.
+	\param redLines	    A list of lines without self intersections.
+	\param bluePolygons	A list of polygons without self intersections.
+	\param blueTree		A tree with all segments from the polygonset already indexed or not, if it is empty, so, it will be filled inside this method.
+	\param report		A report list of intersection points.
+	\return				Returns true if there is an intersection between a red segment from the lineset and a blue segment from the polygonset.
+
+	\note				This function will not returns intersections between segments of the same polygon or lineset. It will only
+	                    report intersection between segments from different sets.
+ */
+TL_DLL bool TeIntersection(const TeLineSet& redLines, const TePolygonSet& bluePolygons, TeSegmentRTree& blueTree, TeINTERSECTOR2::TeVectorBoundaryIP& report);
+
+/** \brief Tells if there is a self-intersection between segments.
+	\param polygons					A list of polygons to test self intersections.
+	\param selfIntersectionList		A report list with all self-intersections.
+	\return							Returns true if there is not a self-intersection.
+ */
+TL_DLL bool TeIsSimple(const TePolygonSet& polygons, vector<TePairSegIdInPolygonSet>& selfIntersectionList);
+
+/** \brief Index polygon's segments.
+	\param polygons		A list of polygons to index it segment's.
+	\param tree			The tree if indexed segments.
+ */
+TL_DLL void TeIndexPolygonSet(const TePolygonSet& polygons, TeSegmentRTree& tree);
+
+/** @} */ 
+
+}	// end namespace TeINTERSECTOR2
+#endif //__TERRALIB_INTERNAL_INTERSECTOR2_H
+
diff --git a/src/terralib/kernel/TeKdTree.h b/src/terralib/kernel/TeKdTree.h
new file mode 100644
index 0000000..d615b63
--- /dev/null
+++ b/src/terralib/kernel/TeKdTree.h
@@ -0,0 +1,1190 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file   TeKdTree.h
+    \brief  This file contains an implementation of kdtree data structures in main memory for two dimensions.
+	\note   These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone because
+	        THIS IS FOR INTERNAL USE ONLY.
+    \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>    
+*/
+
+#ifndef  __TERRALIB_INTERNAL_KDTREE_H
+#define  __TERRALIB_INTERNAL_KDTREE_H
+
+#include "TeGeometry.h"
+
+/** 
+ * WARNING: These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone because
+ *          the support and interfaces can be changed in future. THIS IS FOR INTERNAL USE ONLY.
+ *
+ */
+
+namespace TeSAM
+{
+/** @defgroup PartitionAlgorithms Partition Algorithms
+ *  Partition Algorithms.
+ *  @{
+ */
+
+//! This function partition the conteiner in two parts: k-1 elements to the left (elements less than or equals to k-th element) and the right part with all other elements (elements greater than or equal to k-th element)
+/*
+	\param A             Conteiner of elements to partition
+	\param kthElement    Position of the k-th element, around the conteiner will be pertitionated
+	\param firstElement  Position of the first element
+	\param lastElement   Position of the las element
+	\param compFunctor   Functor to compare elements: implements the function "less than"
+
+*/
+template<class CONTAINER, class COMPFUNCTOR> 
+void TeHoareFind(CONTAINER& A, const unsigned int& kthElement, const unsigned int& firstElement, const unsigned int& lastElement,  const COMPFUNCTOR& compFunctor)
+{
+	unsigned int m = firstElement;
+	unsigned int n = lastElement;
+
+// Test if the median is in the bounds
+	if((kthElement < firstElement) || (kthElement > lastElement))
+		return;	
+
+// Do conteiner partition
+	while(m < n)
+	{		
+		unsigned int i = m;
+		unsigned int j = n;
+
+		typename CONTAINER::value_type r = A[kthElement];
+
+		while(i <= j)
+		{
+			while(compFunctor(A[i], r))
+				++i;  
+
+			while(compFunctor(r, A[j]))
+				--j;
+			
+			if(i <= j)
+			{
+				typename CONTAINER::value_type w = A[i];
+				A[i] = A[j];
+				A[j] = w;
+				
+			    ++i;
+				--j;
+			}
+		}
+
+		if(kthElement <= j)			// if the meet point was to the right, so all points above j are greater than the k-th element
+			n = j;
+		else if(i <= kthElement)	// otherwise, if the meeting point was to the left of k-th, so all elements before i are already in the correct location
+			m = i;
+		else
+			break;
+	}
+}
+
+//! Partition the conteiner like a bidimensional K-d Tree using Hoare algorithms
+/*
+	\param dataSet					Conteinet elements to be sorted like a K-dTree
+	\param first					Position of the first element in conteiner, where the sort will begin
+	\param last						Position of the last element, where the sort ends
+	\param level					Indicates the axis to begin the sort ('x' or 'y') and is used during the recursion process
+	\param lessThanCompFunctorByX	Functor to compare elements along the 'x' axis
+	\param lessThanCompFunctorByY	Functor to compare elements along the 'y' axis
+
+  	The expected complexity is O(N log N), where N is the number of elements in conteiner.
+*/
+template<class CONTAINER, class LESSTHANX, class LESSTHANY> 
+void kdsort(CONTAINER& dataSet, const unsigned int& first, const unsigned int& last, const char& level, const LESSTHANX& lessThanCompFunctorByX, const LESSTHANY& lessThanCompFunctorByY)
+{
+	const unsigned int kth = (last - first + 1u) / 2u;
+
+	if(level == 'x')
+	{
+// Move data around X axis
+		TeHoareFind(dataSet, first + kth, first, last, lessThanCompFunctorByX);
+
+// Recursive sort the left half and right half
+		if((first + kth) > first)
+			kdsort(dataSet, first, first + kth - 1u, 'y', lessThanCompFunctorByX, lessThanCompFunctorByY);
+
+		if((first + kth) < last)
+			kdsort(dataSet, first + kth + 1u, last, 'y', lessThanCompFunctorByX, lessThanCompFunctorByY);
+	}
+	else
+	{
+// Move data around Y axis
+		TeHoareFind(dataSet, first + kth, first, last, lessThanCompFunctorByY);
+
+// Recursive sort the left half and right half
+		if((first + kth) > first)
+			kdsort(dataSet, first, first + kth - 1u, 'x', lessThanCompFunctorByX, lessThanCompFunctorByY);
+
+		if((first + kth) < last)
+			kdsort(dataSet, first + kth + 1u, last, 'x', lessThanCompFunctorByX, lessThanCompFunctorByY);
+	}
+}
+/** @} */
+
+//! Kd-tree node type for nodes with single elements (used by template instantiation).
+struct TL_DLL kd_node_data_single_tag {};
+
+//! Kd-Tree node type for nodes with multuple elements (used by template instantiation).
+struct TL_DLL kd_node_data_set_tag {};
+
+
+//! Class that represents a node of a TeKdTree
+/*!
+	Each node contains a pointer to its left and right subtree (NULL if it is not set),
+	one key used for insertion of the data into the tree.
+
+	WARNING: <BR>
+
+	1. The key must have methods called x() and y(). <BR>
+	
+	2. These kind of node stores the data in each node. <BR>
+
+	3. The nodes may contains one single element (kd_node_data_single_tag) or a set of values (kd_node_data_set_tag). <BR>
+	
+	4. If the node type is kd_node_data_single_tag than NodeData and NodeDataItem are the same types. And if
+	   one entry with the same key already exist, so they will be overwrite. <BR>
+	   
+	5. If the node type is kd_node_data_set_tag than NodeData mus have a method called push_back(NodeDataItem)
+	   that permits to store elements with the same key in the node. <BR>
+ */
+template<class NodeKey, class NodeData, class NodeDataItem,
+         class NodeDataTag = kd_node_data_single_tag>
+class TeKdTreeNode
+{
+	protected:
+
+		//! The key used to access this record
+		NodeKey key_;
+
+		//! The data stored in this record
+		NodeData data_;
+
+		//! Pointer to the left sub-tree.
+		TeKdTreeNode* left_;
+
+		//! Pointer to the right sub-tree.
+		TeKdTreeNode* right_;
+
+	public:
+
+		//! Export key type.
+		typedef NodeKey kdKey;
+
+		//! Export data type.
+		typedef NodeData kdData;
+
+		//! Export data item type.
+		typedef NodeDataItem kdDataItem;
+
+		//! Export data type.
+		typedef NodeDataTag  kdDataTag;
+
+		//! Constructor
+		TeKdTreeNode(const NodeKey& k)
+			: key_(k), left_(0), right_(0)
+		{
+		}
+
+		//! Sets the key to the node
+		void setKey(const NodeKey& k)
+		{
+			key_ = k;
+		}
+
+		//! Returns a reference to node key
+		const NodeKey& getKey(void) const
+		{
+			return key_;
+		}
+
+		//! Sets the data in the node
+		void setData(const NodeData& data)
+		{
+			data_ = data;
+		}
+
+		//! Returns a reference to data node
+		NodeData& getData(void)
+		{
+			return data_;
+		}
+
+		//! Sets the left child pointer
+		void setLeft(TeKdTreeNode* node)
+		{
+			left_ = node;
+		}
+
+		//! Sets the right child pointer
+		void setRight(TeKdTreeNode* node)
+		{
+			right_ = node;
+		}
+
+		//! Accessor for left child
+		TeKdTreeNode* getLeft(void) const
+		{
+			return left_;
+		}
+
+		//! Accessor for right child
+		TeKdTreeNode* getRight(void) const
+		{
+			return right_;
+		}		
+
+		//! Method to check if this has a left child
+		bool hasLeft(void) const
+		{
+			return (left_ != 0);
+		}
+		
+		//! Method to check if a this has a right child
+		bool hasRight(void) const
+		{
+			return (right_ != 0);
+		}
+
+		//! Method to check if this has no children
+		bool isLeaf(void) const
+		{
+			return !(hasLeft() || hasRight());
+		}		
+
+		//! Method to count the number of nodes below this
+		unsigned int descendants(void) const
+		{
+			unsigned int totalLeft  = 0u;
+			unsigned int totalRight = 0u;
+
+			if(hasLeft())
+				totalLeft = 1u + getLeft()->descendants();
+
+			if(hasRight())
+				totalRight = 1u + getRight()->descendants();
+
+			return (totalLeft + totalRight);
+		}
+
+	private:
+
+		//! No copy allowed
+		TeKdTreeNode(const TeKdTreeNode& other);
+
+		//! No copy allowed
+		TeKdTreeNode& operator=(const TeKdTreeNode& other);
+
+};	// end of class TeKdTreeNode
+
+//! A base class for Kd-Tree structures
+/*!
+	This class implements only common kdtree methods and properties.
+ */
+template<class KdTreeNode>
+class TeBasicKdTree
+{
+	protected:				
+
+		//! Pointer to the root node
+		KdTreeNode* root_;
+
+		//! Bounding box of all nodes
+		TeBox mbr_;
+
+		//! The size of the K-d Tree (number of nodes)
+		unsigned int size_;		
+
+	public:
+
+		//! Constructor
+		TeBasicKdTree(const TeBox& mbr)
+			: root_(0), mbr_(mbr), size_(0u)
+		{
+		}
+
+		//! Destructor
+		~TeBasicKdTree()
+		{		
+			clear();
+		}
+
+		//! Clear all tree nodes
+		void clear(void)
+		{
+			if(root_)
+			{
+				erase(root_);
+				root_ = 0;
+				size_ = 0;
+			}
+		}
+
+		//! The number of tree nodes
+		const unsigned int& size(void) const
+		{
+			return size_;
+		}
+		
+		//! Return true if the tree is empty
+		bool isEmpty(void) const
+		{
+			return root_ == 0;
+		}
+
+		//! Sets the bounding box of all elements in the tree
+		void setBox(const TeBox& mbr)
+		{
+			mbr_ = mbr;
+		}
+
+		//! Sets the bounding box of all elements in the tree
+		const TeBox& getBox(void) const
+		{
+			return mbr_;
+		}
+
+	protected:
+
+		//! Erases a node from the tree and all nodes below it.
+		void erase(KdTreeNode* node)
+		{
+			if(node->hasLeft())
+				erase(node->getLeft());
+
+			if(node->hasRight())
+				erase(node->getRight());
+
+			delete node;
+
+			return;
+		}
+
+	private:
+
+		//! No copy allowed
+		TeBasicKdTree(const TeBasicKdTree& other);
+
+		//! No copy allowed
+		TeBasicKdTree& operator=(const TeBasicKdTree& other);
+};
+
+
+//! A class that represents a two dimensional K-d Tree (2-d Tree)
+/*!	
+	WARNING:
+
+	1. This type of tree stores the data into nodes (not only in the leafs node).
+	
+	2. This tree may be built by two ways: <BR>
+	   2.1. Inserting each element in the tree. In this case the tree can becomes unbalanced, but in practical
+	        cases this is not the expected, and is the best way to construct the tree (faster way). <BR>
+	   2.2. Passing a container with pairs (key/data-item) and using the method buildOptimized after
+	        calling kdsort. The tree built this way is almost balanced but will be 
+			construct in time O(N log N).<BR>
+			WARNING: In this case items with the same key will be stores in different nodes!<BR>
+	
+	3. This type of tree may be of special interest of BOX SEARCH QUERIES.	
+
+	4. If the node type is kd_node_data_single_tag than NodeData and NodeDataItem are the same types. And if
+	   one entry with the same key already exist, so they will be overwrite.
+	   
+	5. If the node type is kd_node_data_set_tag than NodeData mus have a method called push_back(NodeDataItem)
+	   that permits to store elements with the same key in the node.
+ */
+template<class KdTreeNode>
+class TeKdTree : public TeBasicKdTree<KdTreeNode>
+{
+        using TeBasicKdTree<KdTreeNode>::root_;
+        using TeBasicKdTree<KdTreeNode>::size_;
+        using TeBasicKdTree<KdTreeNode>::mbr_;
+        
+	public:
+
+		//! Export key type.
+		typedef typename KdTreeNode::kdKey kdKey;
+
+		//! Export data type.
+		typedef typename KdTreeNode::kdData kdData;
+
+		//! Export data item type.
+		typedef typename KdTreeNode::kdDataItem kdDataItem;		
+
+		//! Export data type.
+		typedef typename KdTreeNode::kdDataTag kdDataTag;
+
+		//! Constructor
+		TeKdTree(const TeBox& mbr)
+			: TeBasicKdTree<KdTreeNode>(mbr)
+		{
+		}
+
+		//! Inserts the data with a given key in tree
+		inline void insert(const kdKey& key, const kdDataItem& item);
+
+		//! Inserts the data in the tree and and keeps it balanced: the kdsort algorithm must be called before
+		void buildOptimized(vector<pair<kdKey, kdDataItem> >& dataSet)
+		{
+			const unsigned int last = dataSet.size() - 1u;
+
+			root_ = buildOptimized(dataSet, 0u, last);			
+		}		
+
+		//! Range search query.
+		void search(const TeBox& rect, vector<KdTreeNode*>& report) const
+		{
+			if(root_)
+				search(rect, root_, 'x', report);
+
+			return;
+		}					
+
+	protected:
+
+		//! Inserts data for single nodes, i.e., nodes that stores only one element
+		void insertData(KdTreeNode*& node, const kdDataItem& data, const kd_node_data_single_tag&)
+		{
+			node->setData(data);
+		}
+
+		//! Inserts data for set nodes, i.e., nodes that may stores many element
+		void insertData(KdTreeNode*& node, const kdDataItem& data, const kd_node_data_set_tag&)
+		{
+			node->getData().push_back(data);
+		}
+
+		//! Recursive range query
+		inline void search(const TeBox& rect, KdTreeNode* node, const char& level, vector<KdTreeNode*>& report) const;
+
+		//! Builds the tree recursively
+		KdTreeNode* buildOptimized(vector<pair<kdKey, kdDataItem> >& dataSet, const unsigned int& first, const unsigned int& last)
+		{
+			const unsigned int kth = (last - first + 1u) / 2u;
+
+			KdTreeNode* newNode = new KdTreeNode(dataSet[first + kth].first);
+
+			newNode->setData(dataSet[first + kth].second);
+
+			++size_;
+
+			if((first + kth) > first)
+				newNode->setLeft(buildOptimized(dataSet, first, first + kth - 1u));
+
+			if((first + kth) < last)
+				newNode->setRight(buildOptimized(dataSet, first + kth + 1u, last));
+
+			return newNode;
+		}				
+
+	private:
+
+		//! No copy allowed
+		TeKdTree(const TeKdTree& other);
+
+		//! No copy allowed
+		TeKdTree& operator=(const TeKdTree& other);
+
+};	// end class TeKdTree
+
+template<class KdTreeNode>
+void TeKdTree<KdTreeNode>::insert(const kdKey& key, const kdDataItem& item)
+{
+	if(root_ == 0)
+	{
+		root_ = new KdTreeNode(key);
+
+		insertData(root_, item, kdDataTag());
+	}
+	else
+	{					
+		char level = 'x';
+
+		bool left = false;
+
+		KdTreeNode* x = root_;
+		KdTreeNode* y = 0;
+
+		while(x != 0)
+		{
+			y = x;
+
+			if(level == 'x')
+			{
+				if(key.x() > x->getKey().x())		// if the key is greater than, inserts in the right subtree
+				{
+					x = x->getRight();
+					left = false;
+				}
+				else if(key.x() < x->getKey().x())		// if the key is smaller than, inserts in the left subtree
+				{
+					x = x->getLeft();
+					left = true;
+				}
+				else if(key.y() == x->getKey().y())		// if the key already exist, in the case of single node the data will be overwrite and in the case of set node they will push_back the item
+                {
+					insertData(x, item, kdDataTag());
+
+					return;							
+				}
+				else					// found the same axis partition, so go left
+				{
+					x = x->getLeft();
+					left = true;
+				}						
+
+				level = 'y';
+			}
+			else
+			{
+				if(key.y() > x->getKey().y())
+				{
+					x = x->getRight();
+					left = false;
+				}
+				else if(key.y() < x->getKey().y())
+				{
+					x = x->getLeft();
+					left = true;
+				}
+				else if(key.x() == x->getKey().x())
+                                {
+					insertData(x, item, kdDataTag());
+
+					return;							
+				}
+				else
+				{
+					x = x->getLeft();
+					left = true;
+				}						
+
+				level = 'x';						
+			}
+		}
+
+		KdTreeNode* newNode = new KdTreeNode(key);
+
+		insertData(newNode, item, kdDataTag());
+
+		if(left)
+			y->setLeft(newNode);
+		else
+			y->setRight(newNode);
+	}
+
+	++size_;
+
+	return;
+}
+
+template<class KdTreeNode>
+void TeKdTree<KdTreeNode>::search(const TeBox& rect, KdTreeNode* node, const char& level, vector<KdTreeNode*>& report) const
+{
+	if((node->getKey().x() >= rect.x1_) && (node->getKey().x() <= rect.x2_) &&
+	   (node->getKey().y() >= rect.y1_) && (node->getKey().y() <= rect.y2_))
+		report.push_back(node);
+
+	if(level == 'x')
+	{
+		if(node->hasLeft())
+			if(node->getKey().x() >= rect.x1_)
+				search(rect, node->getLeft(), 'y', report);
+
+		if(node->hasRight())
+			if(node->getKey().x() <= rect.x2_)
+				search(rect, node->getRight(), 'y', report);
+	}
+	else
+	{
+		if(node->hasLeft())
+			if(node->getKey().y() >= rect.y1_)
+				search(rect, node->getLeft(), 'x', report);
+
+		if(node->hasRight())
+			if(node->getKey().y() <= rect.y2_)
+				search(rect, node->getRight(), 'x', report);
+	}
+
+	return;
+}
+
+//! Class that represents a node of a TeAdaptativeKdTree
+/*!
+	Each node contains a pointer to its left and right subtree (NULL if it is not set),
+	a discriminator that indicates the axis of partition, the partition key and
+	a set of data-items.
+
+	WARNING:
+
+	1. The key must have methods called x() and y().
+	
+	2. These kind of node stores the data only in the leafs.
+
+	3. The leaf nodes contains a set of values that forms a bucket (the size is controlled by the tree methods tha use this class).
+ */
+template<class NodeKey, class NodeData, class NodeDataItem>
+class TeAdaptativeKdTreeNode
+{
+protected:
+		//! The key used to access this record
+		double key_;
+
+		//! The data stored in this record
+		NodeData data_;
+
+		//! The discriminator used in partition
+		char discriminator_;
+
+		//! Pointer to the left sub-tree.
+		TeAdaptativeKdTreeNode* left_;
+
+		//! Pointer to the right sub-tree.
+		TeAdaptativeKdTreeNode* right_;
+
+public:
+		//! Export key type.
+		typedef NodeKey kdKey;
+
+		//! Export data type.
+		typedef NodeData kdData;
+
+		//! Export data item type.
+		typedef NodeDataItem kdDataItem;
+
+		//! Constructor
+		TeAdaptativeKdTreeNode(const double& k)
+			: key_(k), discriminator_('x'), left_(0), right_(0)
+		{ }
+
+		//! Sets the key to the node
+		void setKey(const double& k)
+		{
+			key_ = k;
+		}
+
+		//! Returns a reference to node key
+		const double& getKey(void) const
+		{
+			return key_;
+		}
+
+		//! Sets the data in the node
+		void setData(const NodeData& data)
+		{
+			data_ = data;
+		}
+
+		//! Returns a reference to data node
+		NodeData& getData(void)
+		{
+			return data_;
+		}
+
+		//! Sets the data in the node
+		void setDiscriminator(const char& d)
+		{
+			discriminator_ = d;
+		}
+
+		//! Returns a reference to discriminator
+		const char& getDiscriminator(void) const
+		{
+			return discriminator_;
+		}
+
+		//! Sets the left child pointer
+		void setLeft(TeAdaptativeKdTreeNode* node)
+		{
+			left_ = node;
+		}
+
+		//! Sets the right child pointer
+		void setRight(TeAdaptativeKdTreeNode* node)
+		{
+			right_ = node;
+		}
+
+		//! Accessor for left child
+		TeAdaptativeKdTreeNode* getLeft(void) const
+		{
+			return left_;
+		}
+
+		//! Accessor for right child
+		TeAdaptativeKdTreeNode* getRight(void) const
+		{
+			return right_;
+		}		
+
+		//! Method to check if this has a left child
+		bool hasLeft(void) const
+		{
+			return (left_ != 0);
+		}
+		
+		//! Method to check if a this has a right child
+		bool hasRight(void) const
+		{
+			return (right_ != 0);
+		}
+
+		//! Method to check if this has no children
+		bool isLeaf(void) const
+		{
+			return !(hasLeft() || hasRight());
+		}
+
+		//! Method to count the number of nodes below this
+		unsigned int descendants(void) const
+		{
+			unsigned int totalLeft  = 0u;
+			unsigned int totalRight = 0u;
+
+			if(hasLeft())
+				totalLeft = 1u + getLeft()->descendants();
+
+			if(hasRight())
+				totalRight = 1u + getRight()->descendants();
+
+			return (totalLeft + totalRight);
+		}		
+
+	private:
+
+		//! No copy allowed
+		TeAdaptativeKdTreeNode(const TeAdaptativeKdTreeNode& other);
+
+		//! No copy allowed
+		TeAdaptativeKdTreeNode& operator=(const TeAdaptativeKdTreeNode& other);
+
+};	// end of class TeAdaptativeKdTreeNode
+
+//! A class that represents a two dimensional K-d Tree (2-d Tree) that store data-elements into the leafs
+/*!	
+	WARNING:
+
+	1. This type of tree stores the data only in the leaf nodes.
+	
+	2. The process of construction expect that the tree is almost balanced
+    	
+	3. This type of tree may be of special interest of NEAREST NEIGHBOR SEARCH QUERIES.
+
+	4. After a box search it will be necessary to do a refinement.
+ */
+template<class KdTreeNode>
+class TeAdaptativeKdTree : public TeBasicKdTree<KdTreeNode>
+{
+	using TeBasicKdTree<KdTreeNode>::root_;
+	using TeBasicKdTree<KdTreeNode>::size_;
+	using TeBasicKdTree<KdTreeNode>::mbr_;
+        
+protected:				
+		//! Bucket size (maximum number of elements in each node)
+		unsigned int bucketSize_;
+		
+public:
+		//! Export key type.
+		typedef typename KdTreeNode::kdKey kdKey;		
+
+		//! Export data type.
+		typedef typename KdTreeNode::kdData kdData;		
+
+		//! Export data item type.
+		typedef typename KdTreeNode::kdDataItem kdDataItem;	
+
+		//! Export node type.
+		typedef KdTreeNode kdNode;		
+
+		//! Constructor
+		TeAdaptativeKdTree(const TeBox& box, const unsigned int& bucketSize = 12)
+			: TeBasicKdTree<KdTreeNode>(box), bucketSize_(bucketSize)
+		{
+		}
+
+		//! Sets bucket size for leaf nodes
+		void setBucketSize(const unsigned int& size)
+		{
+			bucketSize_ = size;
+		}
+
+		//! Sets bucket size for leaf nodes
+		const unsigned int& getBucketSize(void) const
+		{
+			return bucketSize_;
+		}
+
+		//! Inserts the data set into the tree
+		void build(vector<pair<kdKey, kdDataItem> >& dataSet)
+		{
+			root_ = build(dataSet, 0.0, mbr_);
+		}
+
+		//! Search the nearest data in nodes: you must pass an array of kdDataItem of size "k" with coordinates values (X() and Y()) adjusted to TeMAXFLOAT (this dummy values will be replaced at processing time), and if not all neighbors are found so sqrDists will contains TeMAXFLOAT in array index
+		void nearestNeighborSearch(const kdKey& key, vector<kdDataItem>& report, vector<double>& sqrDists, const unsigned int& k) const
+		{
+			if(root_)
+			{
+				sqrDists.clear();
+
+				for(unsigned int i = 0; i < k; ++i)
+					sqrDists.push_back(TeMAXFLOAT);
+				
+				TeBox rect(-TeMAXFLOAT, -TeMAXFLOAT, +TeMAXFLOAT, +TeMAXFLOAT);
+
+				nearestNeighborSearch(root_, key, report, sqrDists, rect);
+			}
+		}		
+
+		//! Range search query.
+		void search(const TeBox& rect, vector<KdTreeNode*>& report) const
+		{
+			if(root_)
+				search(rect, root_, report);
+
+			return;
+		}		
+
+		//! Range search query: the refinement is already done
+		inline void search(const TeBox& rect, vector<kdDataItem>& report) const;
+
+protected:			
+		//! Build the tree recursivily 
+		inline KdTreeNode* build(vector<pair<kdKey, kdDataItem> >& dataSet, double averageValue, const TeBox& mbr);
+
+		//! Recursive range query.
+		inline void search(const TeBox& rect, KdTreeNode* node, vector<KdTreeNode*>& report) const;
+
+		//! Recursive nearest neighbor search
+		inline void nearestNeighborSearch(KdTreeNode* node, const kdKey& key, vector<kdDataItem>& report, vector<double>& sqrDists, TeBox& rect) const;
+
+		//! Update neighbor list
+		inline void update(KdTreeNode* node, const kdKey& key, vector<kdDataItem>& report, vector<double>& sqrDists, TeBox& rect) const;
+
+		//! Returns the average value along the axis
+		double average(vector<pair<kdKey, kdDataItem> >& dataSet, const char& discriminator) const
+		{
+			const unsigned int size = dataSet.size();
+
+			double medianValue = 0.0;
+
+			if(discriminator == 'x')
+			{
+				for(unsigned int i = 0; i < size; ++i)
+					medianValue += dataSet[i].first.x();
+
+				return medianValue / size;
+			}
+			else
+			{
+				for(unsigned int i = 0; i < size; ++i)
+					medianValue += dataSet[i].first.y();
+
+				return medianValue / size;
+			}
+		}			
+		
+private:
+		//! No copy allowed
+		TeAdaptativeKdTree(const TeAdaptativeKdTree& other);
+
+		//! No copy allowed
+		TeAdaptativeKdTree& operator=(const TeAdaptativeKdTree& other);
+
+};	// end class TeAdaptativeKdTree
+
+template<class KdTreeNode>
+KdTreeNode* TeAdaptativeKdTree<KdTreeNode>::build(vector<pair<kdKey, kdDataItem> >& dataSet, double averageValue, const TeBox& mbr)
+{
+	++size_;
+
+	if(dataSet.size() <= bucketSize_)
+	{
+		KdTreeNode* node = new KdTreeNode(averageValue);
+
+		node->setDiscriminator('l');
+		//node->setBox(mbr);
+
+		unsigned int size = dataSet.size();
+
+		for(unsigned int i = 0; i < size; ++i)
+			node->getData().push_back(dataSet[i].second);
+
+		return node;
+	}
+
+	TeBox newMbr1(mbr);
+	TeBox newMbr2(mbr);	
+
+	char discriminator = 'x';
+
+	vector<pair<kdKey, kdDataItem> > leftDataSet;
+	vector<pair<kdKey, kdDataItem> > rightDataSet;
+
+// Finds the largest dimension
+	if((mbr.x2_ - mbr.x1_) > (mbr.y2_ - mbr.y1_))
+	{
+// Finds the median along "x" axis
+		averageValue = average(dataSet, 'x');
+
+// Adjust box for left and right branchs
+		newMbr1.x2_ = averageValue;
+		newMbr2.x1_ = averageValue;
+
+		unsigned int size = dataSet.size();
+
+		for(unsigned int i = 0; i < size; ++ i)
+		{
+			if(dataSet[i].first.x() <= averageValue)
+				leftDataSet.push_back(dataSet[i]);
+			else
+				rightDataSet.push_back(dataSet[i]);
+		}
+	}
+	else
+	{
+		discriminator = 'y';
+
+// Finds the median along "y" axis		
+		averageValue = average(dataSet, 'y');
+
+// Adjust box for left and right branchs
+		newMbr1.y2_ = averageValue;
+		newMbr2.y1_ = averageValue;
+
+		unsigned int size = dataSet.size();
+
+		for(unsigned int i = 0; i < size; ++ i)
+		{
+			if(dataSet[i].first.y() <= averageValue)
+				leftDataSet.push_back(dataSet[i]);
+			else
+				rightDataSet.push_back(dataSet[i]);
+		}
+	}
+
+	dataSet.clear();
+
+	KdTreeNode* node = new KdTreeNode(averageValue);
+	
+	//node->setBox(mbr);
+	
+	if(rightDataSet.size() == 0u)		// If all coordinates have the same coordinate values, the right vector will be empty so we need stop division to
+	{
+		node->setDiscriminator('l');
+		//node->setBox(newMbr1);
+
+		unsigned int size = leftDataSet.size();
+
+		for(unsigned int i = 0; i < size; ++i)
+			node->getData().push_back(leftDataSet[i].second);
+
+		//throw;
+	}
+	else if(leftDataSet.size() == 0u)		// If all coordinates have the same coordinate values, the left vector is empty, so we need to stop
+	{
+		node->setDiscriminator('l');
+		//node->setBox(newMbr2);
+
+		unsigned int size = rightDataSet.size();
+
+		for(unsigned int i = 0; i < size; ++i)
+			node->getData().push_back(rightDataSet[i].second);
+
+		//throw;
+	}
+	else
+	{
+		node->setDiscriminator(discriminator);
+		node->setLeft(build(leftDataSet, averageValue, newMbr1));
+		node->setRight(build(rightDataSet, averageValue, newMbr2));
+	}
+	
+	return node;
+}
+
+template<class KdTreeNode>
+void TeAdaptativeKdTree<KdTreeNode>::search(const TeBox& rect, vector<kdDataItem>& report) const
+{
+	vector<KdTreeNode*> reportNodes;
+
+	search(rect, reportNodes);
+
+    unsigned int nNodes = reportNodes.size();
+
+	for(unsigned int i = 0; i < nNodes; ++i)
+	{
+		unsigned int nElements = reportNodes[i]->getData().size();
+
+		for(unsigned int j = 0; j < nElements; ++j)
+		{
+            if(TeIntersects((reportNodes[i])->getData()[j], rect))
+			{
+				report.push_back((reportNodes[i])->getData()[j]);
+			}
+		}
+	}
+}
+
+template<class KdTreeNode>
+void TeAdaptativeKdTree<KdTreeNode>::search(const TeBox& rect, KdTreeNode* node, vector<KdTreeNode*>& report) const
+{
+	if(node->getDiscriminator() == 'x')
+	{
+		if(node->hasLeft())
+			if(rect.x1_ <= node->getKey())
+				search(rect, node->getLeft(), report);		
+
+		if(node->hasRight())
+			if(rect.x2_ >= node->getKey())
+				search(rect, node->getRight(), report);
+	}
+	else if(node->getDiscriminator() == 'y')
+	{
+		if(node->hasLeft())
+			if(rect.y1_ <= node->getKey())
+				search(rect, node->getLeft(), report);		
+
+		if(node->hasRight())
+			if(rect.y2_ >= node->getKey())
+				search(rect, node->getRight(), report);
+	}
+	else
+	{		
+		report.push_back(node);
+	}
+
+	return;
+}
+
+template<class KdTreeNode>
+void TeAdaptativeKdTree<KdTreeNode>::nearestNeighborSearch(KdTreeNode* node, const kdKey& key, vector<kdDataItem>& report, vector<double>& sqrDists, TeBox& rect) const
+{
+	if(node->getDiscriminator() == 'l')
+	{
+		update(node, key, report, sqrDists, rect);	// this is a leaf node -> update list of neighbours 
+	}
+	else if(node->getDiscriminator() == 'x')
+	{
+		if(key.x() <= node->getKey())
+		{
+			nearestNeighborSearch(node->getLeft(), key, report, sqrDists, rect);
+
+			if((rect.x1_ < node->getKey()) && (node->getKey() < rect.x2_))
+				nearestNeighborSearch(node->getRight(), key, report, sqrDists, rect);
+		}
+		else
+		{
+			nearestNeighborSearch(node->getRight(), key, report, sqrDists, rect);
+
+			if((rect.x1_ < node->getKey()) &&(node->getKey() < rect.x2_))
+				nearestNeighborSearch(node->getLeft(), key, report, sqrDists, rect);
+		}		
+	}
+	else if(node->getDiscriminator() == 'y')
+	{
+		 if(key.y() <= node->getKey())
+		{
+			nearestNeighborSearch(node->getLeft(), key, report, sqrDists, rect);
+
+			if((rect.y1_ < node->getKey()) &&(node->getKey() < rect.y2_ ))
+				nearestNeighborSearch(node->getRight(), key, report, sqrDists, rect);
+		}
+		else
+		{
+			nearestNeighborSearch(node->getRight(), key, report, sqrDists, rect);
+
+			if((rect.y1_ < node->getKey()) &&(node->getKey() < rect.y2_))
+				nearestNeighborSearch(node->getLeft(), key, report, sqrDists, rect);
+		}
+	}	
+	
+}
+
+template<class KdTreeNode>
+void TeAdaptativeKdTree<KdTreeNode>::update(KdTreeNode* node, const kdKey& key, vector<kdDataItem>& report, vector<double>& sqrDists, TeBox& rect) const
+{
+// rect is the bounding box of neighbors
+
+	const unsigned int size = node->getData().size();
+
+	const unsigned int nNeighbors = report.size();
+
+// for each element in the node, we need to search for distances less than of some one of sqrDists
+	for(unsigned int i = 0u; i < size; ++i)
+	{
+		double dx = (key.x() - node->getData()[i].location().x());
+		double dy = (key.y() - node->getData()[i].location().y());
+		
+		double dkp = (dx * dx) + (dy * dy);	// square distance from the key point to the node
+
+// if the distance of "i-th" element is less than the maximum distance in the sqrDists
+		if(dkp < sqrDists[nNeighbors - 1])
+		{
+// so the element must be reported
+
+// and the srqDists vector must be rearranged
+			for(unsigned int j = 0u; j < nNeighbors; ++j)
+			{
+				if(dkp < sqrDists[j])	// if the position is found
+				{  
+// move the elements to the right
+					for(unsigned int k = nNeighbors - 1; k > j; --k)
+					{
+						report[k]   = report[k - 1];
+						sqrDists[k] = sqrDists[k - 1];
+					} 
+
+// inserts the element in the report and update its distance
+					report[j] = node->getData()[i];
+
+					sqrDists[j] = dkp;
+
+					break;
+				}
+			}
+		}
+	}
+
+	double maxDist = sqrDists[nNeighbors - 1];
+
+	if(maxDist != TeMAXFLOAT)
+	{
+		maxDist = sqrt(maxDist);
+	}
+
+	rect.x1_ = key.x() - maxDist;
+	rect.y1_ = key.y() - maxDist;
+	rect.x2_ = key.x() + maxDist;
+	rect.y2_ = key.y() + maxDist;
+}
+/** @} */ 
+
+};	// end namespace TeSAM
+
+
+#endif	// __TERRALIB_INTERNAL_KDTREE_H
+
+
+
+
diff --git a/src/terralib/kernel/TeLayer.cpp b/src/terralib/kernel/TeLayer.cpp
new file mode 100644
index 0000000..8c5ea3b
--- /dev/null
+++ b/src/terralib/kernel/TeLayer.cpp
@@ -0,0 +1,1243 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeLayer.h"
+#include "TeUtils.h"
+#include "TeException.h"
+#include "TeDatabase.h"
+#include "TeRaster.h"
+#include "TeProjection.h"
+
+
+TeLayer::TeLayer(const string& name, TeDatabase* db, TeProjection* proj): 
+	name_(name),
+	id_(-1),
+	db_(db),
+	projection_ ( proj ),
+	raster_(0)
+{
+	if (!db_ || name.empty())
+		return;
+
+	// verifies if layer already exists in the database
+	string sql = "SELECT * FROM te_layer WHERE name = '" + name + "'";
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal)
+		return;
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return;
+	}
+	if (!portal->fetchRow()) 
+	{
+		if (!proj)	// provides a default projection No Projection
+			projection_ = new TeNoProjection();
+		else
+			projection_ = TeProjectionFactory::make (proj->params());
+		db_->insertLayer(this);
+	}
+	else
+		db_->loadLayer(this);
+	int pid = projection_->id();
+	delete projection_;
+	projection_ = db_->loadProjection(pid);
+	delete portal;
+}
+
+
+TeLayer::TeLayer(const string& name, TeDatabase* db, TeBox& box, TeProjection* proj):
+	name_(name),
+	id_(-1),
+	db_(db),
+	projection_(proj),
+	box_(box),
+	raster_(0)
+{
+	if (!db_ || name.empty())
+		return;
+
+	// verifies if layer already exists in the database
+	string sql = "SELECT * FROM te_layer WHERE name = '" + name + "'";
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal)
+		return;
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return;
+	}
+	if (!portal->fetchRow()) 
+	{
+		if (!proj)	// provides a default projection No Projection
+			projection_ = new TeNoProjection();
+		else
+			projection_ = TeProjectionFactory::make (proj->params());
+		db_->insertLayer(this);
+	}
+	else
+		db_->loadLayer(this);
+	delete portal;
+}
+
+TeLayer::~TeLayer()
+{
+	if ( projection_ != 0 )
+	{
+		delete projection_; 
+		projection_ = 0;
+	}
+	for (TeRepresPointerVectorIterator it = repVector_.begin(); it != repVector_.end(); it++)
+	{
+		if (*it)
+		{
+			delete (*it);
+			(*it) = 0;
+		}
+	}
+	repVector_.clear();
+	if (raster_!=0)
+	{
+		delete raster_;
+		raster_ = 0;
+	}
+}
+
+TeLayer::TeLayer( const TeLayer& other )
+{
+	if (projection_)
+		delete projection_;
+	projection_ = 0;
+	if (other.projection_)
+		projection_ = TeProjectionFactory::make ( other.projection_->params());
+	name_		= other.name_;
+	id_			= other.id_;
+	db_			= other.db_;
+}
+
+TeLayer& 
+TeLayer::operator= ( const TeLayer& other )
+{
+	if ( this != &other )
+	{	
+		if (projection_)
+			delete projection_;
+		projection_ = 0;
+		if (other.projection_)
+			projection_ = TeProjectionFactory::make ( other.projection_->params());
+		name_		= other.name_;
+		id_			= other.id_;
+		box_		= other.box_;
+		db_ = other.db_; 
+	}
+	return *this;
+}
+	
+
+void 
+TeLayer::setLayerBox(const TeBox& box)
+{   
+	box_ = box;
+	if ((id_ > -1) && db_)
+		db_->updateLayerBox(this);
+}
+
+void
+TeLayer::updateLayerBox(const TeBox& box)
+{
+	updateBox(box_,box);
+	if ((id_ > -1) && db_)
+		db_->updateLayerBox(this);
+}
+
+void
+TeLayer::updateLayerBox()
+{
+	if (id_ < 0 || !db_)
+		return;
+
+	string sql = "SELECT lower_x, lower_y, upper_x, upper_y FROM te_representation WHERE layer_id = " + Te2String(id_);
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal)
+		return;
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return;
+	}
+
+	TeBox box;
+	while (portal->fetchRow())
+	{
+		TeBox brep(portal->getDouble(0),portal->getDouble(1),portal->getDouble(2),portal->getDouble(3));
+		updateBox(box,brep);
+	}
+	delete portal;
+	box_ = box;
+	db_->updateLayerBox(this);
+	return;
+}
+
+int 
+TeLayer::getNewObjectId()
+{
+	if(!db_)
+		return -1;
+
+	TeDatabasePortal* portal = db_->getPortal();
+	if(!portal)
+		return -1;
+
+	try
+	{
+		int objId = 0;
+		string sql;
+		for (TeRepresPointerVectorIterator it = vectRepres().begin(); it != vectRepres().end(); it++)
+		{
+           TeRepresentation* rep = (*it);
+
+           sql = "SELECT MAX(geom_id) FROM ";
+           sql += rep->tableName_;
+           if (portal->query(sql) && portal->fetchRow())
+           {
+				string data = portal->getData(0);
+				int value = 0;
+				if(!data.empty())
+				   value = atoi(data.c_str());
+				objId += value;
+           }
+           portal->freeResult();
+       }
+       delete portal;
+       return ++objId;
+   }
+   catch(...)
+   {
+       if (portal)
+       {
+           delete portal;
+           return -1;
+       }
+   }
+    return -1;
+} 
+
+void  
+TeLayer::setProjection ( TeProjection* proj )
+{	
+	if (!proj)
+		return;
+
+	// if no database set just update pointer
+	if (!db_)
+	{
+		if ( projection_)
+			delete projection_;
+		projection_ = proj;
+		return;
+	}
+
+	if (projection_)
+	{
+		proj->id(projection_->id());
+		delete projection_;
+	}
+	projection_ = proj; 
+	bool status = true;
+	
+	if ( projection_->id() <= 0  )	// new projection not in the database
+	{
+		status = db_->insertProjection(projection_);
+		// update layer information
+		if (status && id_ > 0)
+		{
+			string sql = "UPDATE te_layer SET projection_id = " + Te2String(projection_->id());
+				sql += " WHERE layer_id=" + Te2String(id_);
+			db_->execute(sql);
+		}
+	}
+	else
+		status = db_->updateProjection(projection_);
+
+	if (raster_)
+	{
+		delete raster_;
+		raster_ = 0;
+	}
+}
+
+void 
+TeLayer::raster( TeRaster* raster)
+{	
+	if (raster_ )
+	{
+		delete raster_;
+		raster_ = 0;
+	}
+	raster_ = raster; 
+}
+
+bool
+TeLayer::hasGeometry (TeGeomRep rep)
+{ 
+	if (repVector_.empty())
+		return false;
+	TeRepresPointerVectorIterator it;
+	it = TeFindRepresentation(repVector_.begin(), repVector_.end(),rep);
+	return (it != repVector_.end());
+} 
+
+int
+TeLayer::geomRep()
+{
+	if (repVector_.empty())
+		return TeGEOMETRYNONE;
+	int r = 0;
+	TeRepresPointerVectorIterator it;
+	for (it=repVector_.begin(); it != repVector_.end(); ++it)
+		r = (int)(*it)->geomRep_ | r;
+	return r;
+}
+
+string
+TeLayer::tableName(TeGeomRep rep) 
+{
+	TeRepresPointerVectorIterator it;
+	it = TeFindRepresentation(repVector_.begin(), repVector_.end(),rep);
+	if (it != repVector_.end())
+		return (*it)->tableName_;
+	else
+		return string("");
+}
+
+int 
+TeLayer::nGeometries(TeGeomRep rep)
+{
+	TeRepresPointerVectorIterator it;
+	it = TeFindRepresentation(repVector_.begin(), repVector_.end(),rep);
+	int ngeo = 0;
+	if (it != repVector_.end())
+	{
+		string sql = "SELECT COUNT(geom_id) FROM " + (*it)->tableName_;
+		TeDatabasePortal* portal = db_->getPortal();
+		if (portal && portal->query(sql) && portal->fetchRow())
+			ngeo = portal->getInt(0);
+		delete portal;
+	}
+	return ngeo;
+}
+
+
+bool
+TeLayer::getRepresentation(TeGeomRep repType, TeRepresPointerVector& result)
+{
+	TeRepresPointerVectorIterator it;
+	it = repVector_.begin();
+	while (it != repVector_.end())
+	{
+		if ((*it)->geomRep_ == repType)
+			result.push_back((*it));
+		++it;
+	}
+	if (result.empty())
+		return false;
+	return true;
+}
+
+TeRepresentation*
+TeLayer::getRepresentation(TeGeomRep repType, const string& tName)
+{
+
+	TeRepresPointerVectorIterator it;
+	it = repVector_.begin();
+	while (it != repVector_.end())
+	{
+		if ((*it)->geomRep_ == repType)
+		{
+			if (tName.empty() || (*it)->tableName_== tName)
+				return (*it);
+		}
+		it++;
+	}
+	return 0;
+}
+
+bool 
+TeLayer::removeGeometry (TeGeomRep repType, const string& tName)
+{
+	if (!db_)
+		return false;
+
+	if (repType == TeTEXT && tName.empty())	// layer can have more than one TEXT table
+		return false;
+
+	TeRepresPointerVectorIterator it;
+	it = TeFindRepresentation(repVector_.begin(), repVector_.end(),repType);
+	while (it != repVector_.end())
+	{
+		if (tName.empty() || (*it)->tableName_== tName)
+		{
+			string del;
+			TeRepresentation* rep = (*it);
+			if (rep->id_ > 0)
+			{
+				del = "DELETE FROM te_representation WHERE repres_id=" + Te2String(rep->id_);
+				if (!db_->execute(del))
+					return false;
+			}
+
+			if (!rep->tableName_.empty())
+			{
+				if(rep->geomRep_ == TeRASTER || rep->geomRep_ == TeRASTERFILE)
+				{
+					TeDatabasePortal* portal = db_->getPortal();
+					string sql, tname;
+
+					sql = "SELECT lut_table, raster_table FROM " + rep->tableName_;
+					portal->query(sql);
+
+					while(portal->fetchRow())
+					{
+						// delete lut table
+						tname = portal->getData(0);
+						if(!tname.empty())
+							db_->deleteTable(tname);
+						// delete raster table
+						tname = portal->getData(1);
+						if(rep->geomRep_ != TeRASTERFILE && !tname.empty())
+							db_->deleteTable(tname);
+					}
+					portal->freeResult();
+					delete portal;
+
+					// delete metadata table
+					sql = "DROP TABLE " + rep->tableName_ + "_metadata";
+					db_->execute(sql);
+					if (raster_)
+					{
+						delete raster_;
+						raster_ = 0;
+					}
+				}
+				if (!db_->deleteTable(rep->tableName_))					
+					return false;
+			}
+			repVector_.erase(it);
+			delete rep;
+			break;
+		}
+		it++;
+		it = TeFindRepresentation(it,repVector_.end(),repType);
+	}
+	updateLayerBox();
+	return true;
+}
+
+bool TeLayer::addGeometry(TeGeomRep repType, const string& tName, const string& desc)
+{  
+	// check if representation is already in layer
+	if (repType == TeTEXT)
+	{
+		string tt;
+		if (!tName.empty())
+			tt = tName;
+		else
+			tt =  name_ + "Texts";
+		
+		if (getRepresentation(repType,tt))
+			return true;
+	}
+	else if (getRepresentation(repType))
+		return true;
+
+	if (!db_)			// layer has no database associated
+		return false;
+
+	if (id_ < 0)		// layer has not saved in the database
+	{
+		if (!db_->insertLayer (this))
+			return false;
+	}
+
+	TeRepresentation* represe = new TeRepresentation();
+	represe->geomRep_ = repType;
+	if (!tName.empty())
+		represe->tableName_ = tName;
+	if (!desc.empty())
+		represe->description_ = desc;
+
+	if (repType == TePOLYGONS)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Polygons" + Te2String(id_);
+		if (!db_->createPolygonGeometry (represe->tableName_))
+			return false;
+	}
+	else if (repType == TeLINES)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Lines" + Te2String(id_);
+		if (!db_->createLineGeometry (represe->tableName_))
+			return false;
+	}
+	else if (repType == TePOINTS)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Points" + Te2String(id_);
+		if (!db_->createPointGeometry (represe->tableName_))
+			return false;
+	}
+	else if (repType == TeTEXT)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Texts" + Te2String(id_);
+		if (!db_->createTextGeometry (represe->tableName_))
+			return false;
+	}
+	else if (repType == TeARCS)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Arcs"+ Te2String(id_);
+ 		if (!db_->createArcGeometry (represe->tableName_))
+			return false;
+	}
+	else if (repType == TeNODES)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Nodes"+ Te2String(id_);
+ 		if (!db_->createNodeGeometry (represe->tableName_))
+			return false;
+	}
+	else if (repType == TeCELLS)
+	{
+		if (tName.empty())
+			represe->tableName_ = "Cells"+ Te2String(id_);
+ 		if (!db_->createCellGeometry (represe->tableName_))
+			return false;
+	}
+	else
+	{
+		return false;
+	}
+
+	bool res =  db_->insertRepresentation(id_,*represe);
+
+	if (res) 
+		repVector_.push_back(represe);
+	else
+		return false;
+	return true;
+}
+
+bool 
+TeLayer::addRasterGeometry(TeRasterParams& par, const string& objectId, 
+						   const string& tName, const string& desc)
+{
+	string tableName = tName;
+	TeRepresentation* rep = getRepresentation(TeRASTER,tableName);
+	if (!rep)
+	{
+		rep = new TeRepresentation();
+		updateBox(rep->box_,par.boundingBox());
+
+		if (!tableName.empty())
+			rep->tableName_ = tableName;
+		else
+			rep->tableName_ = "RasterLayer" + Te2String(id_);
+
+		if (!desc.empty())
+			rep->description_ = desc;
+
+		rep->geomRep_ = TeRASTER;
+		if (!db_->insertRepresentation(id_,*rep))
+			return false;
+
+		tableName = rep->tableName_;
+		if (!db_->createRasterGeometry(tableName))
+			return false;
+
+		string metadataTableName = tableName+"_metadata";
+		if (!db_->createRasterMetadataTable(metadataTableName))
+			return false;
+
+		repVector_.push_back(rep);
+	}
+	else
+		tableName = rep->tableName_;
+
+	string oid = objectId;
+	if (oid.empty())
+		oid = "O1";
+
+	if (par.fileName_.empty())
+	{
+		string aux = "RasterLayer" + Te2String(id_) + "_R_" + objectId;
+		bool flag = db_->tableExist(aux);
+		short i=1;
+		while (flag)
+		{
+			aux = "RasterLayer" + Te2String(id_) + "_R_" + objectId + "_" + Te2String(i);
+			++i;
+		}
+		par.fileName_ = aux;
+	}
+
+	if (!db_->createRasterTable(par.fileName_))
+		return false;
+
+	if (!db_->insertRasterGeometry(tableName,par,objectId))
+		return false;
+
+	updateLayerBox(par.boundingBox());
+	par.layerId_ = id_;
+	par.objectId_ = oid;
+
+	return true;
+}
+
+bool
+TeLayer::addRasterFileGeometry(TeRaster* raster, const string& /* objectId */, const string& desc)
+{
+	if (!raster)
+		return false;
+	TeRepresentation* rep = getRepresentation(TeRASTERFILE);
+	if (!rep)
+	{
+		rep = new TeRepresentation();
+		updateBox(rep->box_,raster->params().boundingBox());
+		rep->tableName_ = "RasterLayer" + Te2String(id_);
+		rep->geomRep_ = TeRASTERFILE;
+		rep->resX_ = raster->params().resx_;
+		rep->resY_ = raster->params().resy_;
+		rep->nCols_= raster->params().ncols_;
+		rep->nLins_= raster->params().nlines_;
+		if (!desc.empty())
+			rep->description_ = desc;
+		if (!db_->insertRepresentation(id_,*rep))
+			return false;
+		if (!db_->createRasterGeometry(rep->tableName_))
+			return false;
+		if (!db_->createRasterMetadataTable(rep->tableName_+"_metadata"))
+			return false;
+		repVector_.push_back(rep);
+	}
+	string oid = TeGetBaseName(raster->params().fileName_.c_str());
+	if (oid.empty())
+		oid = "O1";
+	string sql = "delete from " +  rep->tableName_ + " where object_id = '" + oid + "'";
+	db_->execute(sql);
+	if (!db_->insertRasterGeometry(rep->tableName_,raster->params(),oid))
+		return false;
+	updateLayerBox(raster->params().boundingBox());
+	raster->params().layerId_ = id_;
+	raster->params().objectId_ = oid;
+	return true;
+}
+
+bool 
+TeLayer::addRasterGeometry(TeRaster* raster, const string& objectId)
+{
+	if (!raster)
+		return false;
+	TeRepresentation* rep = getRepresentation(TeRASTER);
+	if (!rep)
+	{
+		rep = new TeRepresentation();
+		updateBox(rep->box_,raster->params().boundingBox());
+		rep->tableName_ = "RasterLayer" + Te2String(id_);
+		rep->geomRep_ = TeRASTER;
+		if (!db_->insertRepresentation(id_,*rep))
+			return false;
+		if (!db_->createRasterGeometry(rep->tableName_))
+			return false;
+		if (!db_->createRasterMetadataTable(rep->tableName_+"_metadata"))
+			return false;
+		repVector_.push_back(rep);
+	}
+
+	string oid = objectId;
+	if (oid.empty())
+		oid = "O1";
+	string sql = "delete from " +  rep->tableName_ + " where object_id = '" + oid + "'";
+	db_->execute(sql);
+	if (!db_->insertRasterGeometry(rep->tableName_,raster->params(),oid))
+		return false;
+	updateLayerBox(raster->params().boundingBox());
+	raster->params().layerId_ = id_;
+	raster->params().objectId_ = oid;
+	return true;
+}
+
+TeRaster*
+TeLayer::raster(const string& objectId, const char& mode)
+{	
+   if (id_ <= 0 ||
+	  !(hasGeometry(TeRASTER) || hasGeometry(TeRASTERFILE)))
+       return 0; 
+
+	if (raster_  && !objectId.empty() && 
+	   (objectId != raster_->objectId() || 
+		mode != raster_->params().mode_ ))
+	{
+		delete raster_;
+		raster_ = 0; 
+	}
+
+	if (!raster_)
+		raster_ = db_->loadLayerRaster(id_,objectId, mode);
+	return raster_;
+}
+
+bool
+TeLayer::getRasterGeometries(vector<string>& objectIds, unsigned int tilingType)
+{
+	objectIds.clear();
+	if (!hasGeometry(TeRASTER) || id_ <= 0 )
+		return false;
+
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal)
+		return false;
+
+	string get = "SELECT geom_table FROM te_representation WHERE layer_id = " + Te2String(id_);
+	get += " AND geom_type = 512";
+	
+	// error executing query or no there is no raster representation 
+	if (!portal->query(get) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	string tableName = portal->getData(0);
+	if (tableName.empty())
+	{
+		delete portal;
+		return false;
+	}
+	portal->freeResult();
+	get = "SELECT object_id FROM " + tableName;
+	if (tilingType == 1 || tilingType == 2)
+		get += " WHERE tiling_type=" + Te2String(tilingType);
+
+	if (!portal->query(get))
+	{
+		delete portal;
+		return false;
+	}
+	while (portal->fetchRow())
+		objectIds.push_back(portal->getData(0));
+	delete portal;
+	return !objectIds.empty();
+}
+
+
+int 
+TeLayer::nObjects(const string& tName)
+{
+	if (attTables_.empty())
+		return 0;
+	string linkName;
+	vector<TeTable>::iterator it = attTables_.begin();
+	while (it != attTables_.end())
+	{
+		if ((*it).name() == tName)
+		{
+			linkName = (*it).linkName();
+			break;
+		}
+		it++;
+	}
+	if (linkName.empty())
+		return 0;
+	int no = 0;
+	string sql;
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal)
+		return 0;
+	sql = "SELECT COUNT(" + linkName + ") FROM " + (*it).name();
+	if (portal->query(sql) && portal->fetchRow())
+		no = portal->getInt(0);
+	delete portal;
+	return no;
+}
+
+
+bool 
+TeLayer::createAttributeTable(TeTable& table)
+{
+	if (!db_->tableExist(table.name()))
+	{
+		db_->validTable(table);
+  		if (!db_->createTable(table.name(),table.attributeList())) 
+			return false;
+	}
+	
+	if(!db_->insertTableInfo(id_,table))
+		return false;
+	
+	vector<TeTable>::iterator it = attTables_.begin();
+	while (it != attTables_.end())
+	{
+		if ((*it).name() == table.name())
+			return true;
+		++it;
+	}
+	attTables_.push_back(table);
+	return true;
+}
+
+bool 
+TeLayer::addAttributeTable(TeTable& table)
+{
+	vector<TeTable>::iterator it = attTables_.begin();
+	while (it != attTables_.end())
+	{
+		if ((*it).name() == table.name())
+			return false;
+		it++;
+	}
+	attTables_.push_back(table);
+	return true;
+}
+
+bool 
+TeLayer::removeAttributeTable(string tableName)
+{
+	vector<TeTable>::iterator it = attTables_.begin();
+	while (it != attTables_.end())
+	{
+		if ((*it).name() == tableName)
+		{
+			attTables_.erase(it);
+			return true;
+		}
+		it++;
+	}
+	return false;
+}
+
+void 
+TeLayer::updateAttributeTable(TeTable& table)
+{
+	vector<TeTable>::iterator it = attTables_.begin();
+	while (it != attTables_.end())
+	{
+		if ((*it).name() == table.name())
+		{
+			attTables_.erase(it);
+			break;
+		}
+		it++;
+	}
+	attTables_.push_back(table);
+}
+
+bool
+TeLayer::loadLayerTables() 
+{
+	TeDatabase *db = database();
+	if(!db)
+		return false;
+
+	attTables_.clear();
+	return(db->loadLayerTable(this));
+}
+
+bool 
+TeLayer::getAttrTables(TeAttrTableVector& atts, TeAttrTableType attType)
+{
+	TeAttrTableVector::iterator it = attTables_.begin();
+	while (it != attTables_.end())
+	{
+		if ((attType == TeAllAttrTypes) || ((*it).tableType() == attType))
+			atts.push_back((*it));
+		it++;
+	}
+	return (!atts.empty());
+}
+
+bool 
+TeLayer::getAttrTablesByName(vector<string> &tableNames, TeAttrTableVector& atts, TeAttrTableType attType)
+{
+	TeAttrTableVector::iterator it;
+	vector<string>::iterator it2;
+
+	for(it2 = tableNames.begin(); it2 != tableNames.end(); ++it2)
+	{
+		for(it = attTables_.begin(); it != attTables_.end(); ++it)
+		{
+			if ((attType == TeAllAttrTypes) || ((*it).tableType() == attType))
+			{
+				string name = (*it).name();
+				string name2 = (*it2);
+				if(name == name2)
+				{
+					atts.push_back((*it));
+					break;
+				}
+			}
+		}
+	}
+	return (!atts.empty());
+}
+
+
+bool 
+TeLayer::getAttrTablesByName(const string& attrTableName, TeTable& table, TeAttrTableType attType)
+{
+	TeAttrTableVector::iterator it;
+
+	for(it = attTables_.begin(); it != attTables_.end(); ++it)
+	{
+		if ((attType == TeAllAttrTypes) || ((*it).tableType() == attType))
+		{
+			string name = (*it).name();
+			if(name == attrTableName)
+			{
+				table = (*it);
+				return true;
+			}
+		}
+	}
+	
+	return false;
+}
+
+bool 
+TeLayer::addPolygons (TePolygonSet& polySet)
+{
+	if (!db_)
+		return false;
+
+	if (polySet.size() > 0 )
+	{
+		if (!this->hasGeometry(TePOLYGONS))
+			this->addGeometry(TePOLYGONS);
+
+		TeRepresentation* rep = getRepresentation(TePOLYGONS);
+		if (rep)
+		{
+			if (!db_->insertPolygonSet (rep->tableName_, polySet))
+				return false;
+			updateLayerBox(polySet.box());
+			updateBox(rep->box_,polySet.box());
+			if (!db_->updateRepresentation(id_,*rep))
+				return false;
+		}
+		else
+			return false;
+	}
+	return true;
+}
+
+bool 
+TeLayer::addLines (TeLineSet& lineSet)
+{
+	if (!db_)
+		return false;
+
+	if (lineSet.size() > 0)
+	{
+		if (!this->hasGeometry(TeLINES))
+			this->addGeometry(TeLINES);
+		TeRepresentation* rep = getRepresentation(TeLINES);
+		if (rep)
+		{
+			if (!db_->insertLineSet (rep->tableName_, lineSet))
+				return false;
+			updateLayerBox(lineSet.box());
+			updateBox(rep->box_,lineSet.box());
+			if (!db_->updateRepresentation(id_,*rep))
+				return false;
+		}
+		else
+			return false;
+	}
+	return true;
+}
+
+bool 
+TeLayer::addPoints (TePointSet& pointSet)
+{
+	if (!db_)
+		return false;
+
+	if (pointSet.size() > 0)
+	{
+		if (!this->hasGeometry(TePOINTS))
+			this->addGeometry(TePOINTS);
+		string tblName = tableName(TePOINTS);
+
+		TeRepresentation* rep = getRepresentation(TePOINTS);
+		if (rep)
+		{	
+			if (!db_->insertPointSet (rep->tableName_, pointSet))
+				return false;
+			updateLayerBox(pointSet.box());
+			updateBox(rep->box_,pointSet.box());
+			if (!db_->updateRepresentation(id_,*rep))
+				return false;
+		}
+		else
+			return false;
+	}
+	return true;
+}
+
+bool 
+TeLayer::addText (TeTextSet& textSet, const string& tName)
+{
+	if (!db_)
+		return false;
+
+	TeRepresentation* rep =0;
+	string tabName;
+	if (tName.empty())
+	{
+		int i=0;
+		string name; 
+		do
+		{
+			name = "Text_" + Te2String(id_) + "_" + Te2String(i); 
+			rep = getRepresentation(TeTEXT,name); 
+			++i;
+		}
+		while (rep); 
+		tabName = name;
+	}
+	else
+		tabName = tName;
+
+	if (textSet.size() > 0 )
+	{
+		rep = getRepresentation(TeTEXT,tabName);
+		if (!rep)
+		{
+			this->addGeometry(TeTEXT,tabName);
+			rep = getRepresentation(TeTEXT,tabName);
+		}
+		if (rep)
+		{	
+			if (!db_->insertTextSet (tabName, textSet))
+				return false;
+			updateLayerBox(textSet.box());
+			updateBox(rep->box_,textSet.box());
+			if (!db_->updateRepresentation(id_,*rep))
+				return false;
+		}
+		else
+			return false;
+	}
+	return true;
+}
+
+bool
+TeLayer::addCells(TeCellSet& cellSet)
+{
+	if (!db_)
+		return false;
+
+	if (cellSet.size() > 0)
+	{
+		string tblName = tableName(TeCELLS);
+		if (!this->hasGeometry(TeCELLS))
+			this->addGeometry(TeCELLS);
+
+		TeRepresentation* rep = getRepresentation(TeCELLS);
+		if (rep)
+		{
+			rep->resX_ = cellSet.resX();
+			rep->resY_ = cellSet.resY();
+			if (!db_->insertCellSet(tableName(TeCELLS), cellSet))
+				return false;
+			updateLayerBox(cellSet.box());
+			updateBox(rep->box_,cellSet.box());
+			if (!db_->updateRepresentation(id_,*rep))
+				return false;
+		}		
+		else
+			return false;
+	}
+	return true;
+}
+
+
+bool 
+TeLayer::saveAttributeTable(TeTable& table)
+{
+	if (!db_ || id_ <= 0)
+		return false;
+	if (!db_->tableExist(table.name()))
+	{
+		if (!db_->createTable(table.name(), table.attributeList()))
+			return false;
+	}
+	if (db_->insertTable (table))
+	{
+		if (table.id() <= 0)
+			return db_->insertTableInfo(id_,table);
+		else
+			return true;
+	}
+	return false;
+}
+
+bool
+TeLayer::getPolygons(TePolygonSet &ps, const string& whereClause)
+{
+	if (!hasGeometry(TePOLYGONS))
+		return false;
+	return db_->selectPolygonSet(tableName(TePOLYGONS), whereClause, ps);
+}
+
+bool
+TeLayer::getLines(TeLineSet &ls, const string& whereClause)
+{
+	if (!hasGeometry(TeLINES))
+		return false;
+	return db_->selectLineSet(tableName(TeLINES), whereClause, ls);
+}
+
+bool
+TeLayer::getPoints(TePointSet &ps, const string& whereClause)
+{
+	if (!hasGeometry(TePOINTS))
+		return false;
+	return db_->selectPointSet(tableName(TePOINTS), whereClause, ps);
+}
+
+bool
+TeLayer::getText(TeTextSet &ts, const string& whereClause)
+{
+	if (!hasGeometry(TeTEXT))
+		return false;
+	return db_->selectTextSet(tableName(TeTEXT), whereClause, ts);
+}
+
+bool
+TeLayer::getCells(TeCellSet &cs, const string& whereClause)
+{
+	if (!hasGeometry(TeCELLS))
+		return false;
+	return db_->selectCellSet(id_, tableName(TeCELLS), whereClause, cs);
+}
+
+bool 
+TeLayer::locatePolygon (TeCoord2D &pt, TePolygon &polygon, const double& tol)
+{
+	if (!hasGeometry(TePOLYGONS))
+		return false;
+	return db_->locatePolygon(tableName(TePOLYGONS),pt, polygon, tol);
+}
+
+bool 
+TeLayer::locateLine (TeCoord2D &pt, TeLine2D &line, const double& tol)
+{
+	if (!hasGeometry(TeLINES))
+		return false;
+	return db_->locateLine(tableName(TeLINES),pt, line, tol);
+}
+
+bool 
+TeLayer::locatePoint (TeCoord2D &pt, TePoint &point, const double& tol)
+{
+	if (!hasGeometry(TePOINTS))
+		return false;
+	return db_->locatePoint(tableName(TePOINTS), pt, point, tol);
+}
+
+bool 
+TeLayer::locateText(TeCoord2D &pt, TeText &text, const double& tol)
+{
+	if (!hasGeometry(TeTEXT))
+		return false;
+	return db_->locateText(tableName(TeTEXT), pt, text, tol);
+}
+
+bool 
+TeLayer::locateCell (TeCoord2D &pt, TeCell &cell, const double& tol)
+{
+	if (!hasGeometry(TeCELLS))
+		return false;
+	return db_->locateCell(tableName(TeCELLS), pt, cell, tol);
+}
+
+bool
+TeLayer::loadGeometrySet(const string& geoid, TePolygonSet &ps)
+{
+	if (!hasGeometry(TePOLYGONS))
+		return false;
+	return db_->loadPolygonSet(tableName(TePOLYGONS), geoid, ps);
+}
+
+bool
+TeLayer::loadGeometrySet (const string& geoid, TeLineSet &ls)
+{
+	if (!hasGeometry(TeLINES))
+		return false;
+	return db_->loadLineSet(tableName(TeLINES), geoid, ls);;
+}
+
+bool
+TeLayer::loadGeometrySet (const string& geoid, TePointSet &ps)
+{
+	if (!hasGeometry(TePOINTS))
+		return false;
+	return db_->loadPointSet(tableName(TePOINTS), geoid, ps);
+}
+
+bool
+TeLayer::loadGeometrySet (const string& geoid, TeCellSet &cs)
+{
+	if (!hasGeometry(TeCELLS))
+		return false;
+	return db_->loadCellSet(id_, tableName(TeCELLS), geoid, cs);
+}
+
+bool
+TeLayer::loadGeometrySet (const string& geoid, TeTextSet &ts)
+{
+	if (!hasGeometry(TeTEXT))
+		return false;
+	return db_->loadTextSet(tableName(TeTEXT), geoid, ts);
+}
+
+string
+TeLayer::mediaTable()
+{
+	TeAttrTableVector attrs;
+	getAttrTables(attrs, TeAttrMedia);
+
+	if(attrs.size()<1)
+		return "";
+
+	return (attrs[0].name());
+}
+
+void 
+TeLayer::mediaTable(const string& name)
+{
+	TeAttributeList attList;
+	TeTable table(name, attList,"object_id", "object_id", TeAttrMedia);
+	attTables_.push_back (table);
+}
diff --git a/src/terralib/kernel/TeLayer.h b/src/terralib/kernel/TeLayer.h
new file mode 100644
index 0000000..eac284a
--- /dev/null
+++ b/src/terralib/kernel/TeLayer.h
@@ -0,0 +1,432 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeLayer.h
+    \brief This file contains structures and definitions to deal with a layer
+*/
+#ifndef __TERRALIB_INTERNAL_LAYER_H
+#define __TERRALIB_INTERNAL_LAYER_H
+
+#include "TeGeometry.h"
+#include "TeDataTypes.h"
+#include "TeTable.h"
+#include "TeRepresentation.h"
+
+#include <string>
+#include <list>
+#include <map>
+
+class TeRaster;
+class TeDatabase;
+class TeRasterParams;
+class TeProjection;
+
+//!  A class for supporting a layer. 
+/*!  
+	 In TerraLib, a layer is a collection of geometries that share the same 
+     geographical projection, and are related in some way (e.g. a shapefile).
+	 A layer has a pointer to a database that effectively stores its atributes
+	 and geometries.
+	 
+	\sa
+     TeGeometry, TeProjection, TeBox, TeDatabase, TeTheme, TeTable
+*/
+class TL_DLL TeLayer {
+
+public:
+
+	//! Empty constructor
+	TeLayer():
+		id_(-1),
+		db_(0),
+		projection_ ( 0 ),
+		raster_(0)
+		{ }
+
+		
+	//! Constructor with parameters
+	/* 
+		\param name layer name (should be unique)
+		\param db a TerraLib database connection w
+		\param proj layer projection
+		\note 
+			\par If no database is informed, layer will exist only in memory.
+			\par If a layer with this name doesnt exist a layer will be 
+			 created and stored. If no projection is informed a default TeNoProjection
+			 will be used as layer projection.
+            \par If a layer with this name already exists it will be retrieved
+	*/	 
+	TeLayer(const string& name, TeDatabase* db=0, TeProjection* proj=0);
+
+	//! Constructor with parameters
+	/* 
+		\param name layer name (should be unique)
+		\param db TerraLib database connection where layer will be stored
+		\param box layer bounding box
+		\param proj layer projection
+		\note 
+			\par If no database is informed, layer will exist only in memory.
+			\par If a layer with this name doesnt exist a layer will be 
+			 created and stored. If no projection is informed a default TeNoProjection
+			 will be used as layer projection.
+            \par If a layer with this name already exists it will be retrieved
+	*/
+	TeLayer(const string& name, TeDatabase* db, TeBox& box, TeProjection* proj = 0);
+
+	//! Destructor
+	virtual ~TeLayer();
+
+	//! Copy Constructor
+	TeLayer ( const TeLayer& other );
+
+	//! Operator =
+	TeLayer& operator= ( const TeLayer& other );
+	
+	//! Retrieves the database associated to this layer
+	virtual TeDatabase* const database() 
+	{ return db_; }
+
+	//! Sets the layer database
+	virtual void setDatabase(TeDatabase* db)
+	{ db_ = db; }
+
+	//! Returns the layer id
+	virtual int id()
+	{ return id_; } 
+
+	//! Sets the layer id
+	virtual void id(int id)
+	{ id_ = id; } 
+
+	//! Returns the layer name
+	virtual string name()
+	{ return name_; }
+
+	//! Sets the layer name
+	virtual void name(const string &name)
+	{  name_ = name; }
+
+	//! Sets the  layer projection
+	virtual void  setProjection ( TeProjection* proj );
+
+	//! Retrieves the layer projection
+	virtual TeProjection* projection()
+	{	return projection_; }
+
+	//! Returns the layer bounding box
+	virtual TeBox&	box()
+	{	return box_; }
+
+	//! Sets the  bounding box of a layer
+	virtual void setLayerBox ( const TeBox& box );
+
+	//! Updates the bounding box of a layer
+	virtual void updateLayerBox(const TeBox& box);
+
+	//! Refreshes the bounding box of a layer according to its representation
+	virtual void updateLayerBox();
+
+	//! Returns a possible new object id based on the objects stored in database
+	virtual int getNewObjectId();
+
+	/** @name Attribute Tables
+	*  Methods to deal with the attribute tables of the layer
+	*/
+	//@{
+
+	//! Returns the number of distinct objects in the layer
+	virtual int nObjects(const string& tName);
+
+	//! Returns a vector with the definition of all attribute tables associated to layer
+	virtual TeAttrTableVector& attrTables () 
+	{ return attTables_; }
+
+	//! Creates a new attribute table for the layer
+	virtual bool createAttributeTable(TeTable& table);
+
+    //! Adds an attribute table definition to layer vector of attribute tables (in memory)
+	virtual bool addAttributeTable(TeTable& table);
+
+    //! Remove an attribute table definition to layer vector of attribute tables (in memory)
+	virtual bool removeAttributeTable(string tableName);
+
+     //! Update an attribute table definition to layer vector of attribute tables (in memory)
+	virtual void updateAttributeTable(TeTable& table);
+
+	//! Reload the tables definition from database to memory
+	virtual bool loadLayerTables();
+
+	//! Saves an attribute table into the database where layer is stored 
+	virtual bool saveAttributeTable(TeTable& table);
+
+	//! Gets all attribute tables associated to this layer that are of a certain type
+	virtual bool getAttrTables(TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
+
+	//! Gets a set of attribute table specifications associated to this layer that are of a certain type
+	/*
+		\param tableNames a vector that contains the name of the tables that are being searched
+		\param attType type of table that is being searched
+		\param atts returns a vector of tables found
+		\return true if at least one table was found and false otherwise
+	*/
+	virtual bool getAttrTablesByName(vector<string> &tableNames, TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
+
+	//! Gets an attribute table associated to a layer
+	/*
+		\param tableName name of the table being searched
+		\param attType type of table being searched
+		\param table returns the table found
+		\return true if table was found and false otherwise
+	*/
+	virtual bool getAttrTablesByName(const string& tableName, TeTable& table, TeAttrTableType attType = TeAllAttrTypes);
+
+	//! Gets the name of the media table associated to layer
+	virtual string mediaTable();
+
+	//! Sets the name of the media table associated to layer
+	virtual void mediaTable(const string& name);
+	//@}
+
+	/** @name Geometries
+	*  Methods to deal with the geometries of the objects of a layer
+	*/
+	//! Returns a pointer to the raster geometry associated to an object of this layer
+	/*!
+		\param objectId unique identification of the object (if empty it will look
+		for the first raster geometry found)
+		\param mode permission access ('r', 'w')
+	*/
+	virtual TeRaster* raster(const string& objectId="",const char& mode = 'r');
+
+	//! Sets the pointer to the raster representation
+	virtual void raster( TeRaster* raster);
+
+	//! Retrieves a polygon set given a selection criteria, expressed as a where clause 
+	virtual bool getPolygons(TePolygonSet &ps, const string& whereClause = "");
+
+	//! Retrieves a line set given a selection criteria, expressed as a where clause 
+	virtual bool getLines(TeLineSet &ls, const string& whereClause = "");
+
+	//! Retrieves a point set given a selection criteria, expressed as a where clause 
+	virtual bool getPoints(TePointSet &ps, const string& whereClause = "");
+
+	//! Retrieve a point set given a selection criteria, expressed as a where clause
+	virtual bool getText(TeTextSet &ts, const string& whereClause = "");
+
+	//! Retrieve a cell set given a selection criteria, expressed as a where clause
+	virtual bool getCells(TeCellSet &cs, const string& whereClause = "");
+
+	//! Locates a polygon that cointains a certain coordinate
+	virtual bool locatePolygon(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
+	
+	//! Locates a line that cointains a certain coordinate
+	virtual bool locateLine(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
+
+	//! Retrieves a point that cointains a certain coordinate
+	virtual bool locatePoint(TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
+
+	//! Retrieves a TeText that cointains a certain coordinate
+	virtual bool locateText(TeCoord2D &pt, TeText &text, const double& tol = 0.0);
+
+	//! Retrieves a point that cointains a certain coordinate
+	virtual bool locateCell(TeCoord2D &pt, TeCell &cell, const double& tol = 0.0);
+
+	//! Retrieves the set of polygons with a certain geoid
+	virtual bool loadGeometrySet	(const string& geoid, TePolygonSet &ps);
+
+	//! Retrieves the set of lines with a certain geoid
+	virtual bool loadGeometrySet (const string& geoid, TeLineSet &ls);
+
+	//! Retrieves the set of points with a certain geoid
+	virtual bool loadGeometrySet (const string& geoid, TePointSet &ps);
+
+	//! Retrieves the set of points with a certain geoid
+	virtual bool loadGeometrySet (const string& geoid, TeCellSet &cs);
+
+	//! Retrieves the set of texts with a certain geoid
+	virtual bool loadGeometrySet (const string& geoid, TeTextSet &cs);
+	
+	//! Adds a set of polygons to a layer
+	virtual bool addGeometrySet(TePolygonSet& polySet, const string& /* tName */ = "")
+	{ return addPolygons(polySet); }
+
+	//! Adds a set of lines to a layer
+	virtual bool addGeometrySet(TeLineSet& lineSet, const string& /* tName */ = "")
+	{ return addLines(lineSet); }
+
+	//! Adds a set of points to a layer
+	virtual bool addGeometrySet(TePointSet& pointSet, const string& /* tName */ = "")
+	{ return addPoints(pointSet); }
+
+	//! Adds a set of text to a layer
+	virtual bool addGeometrySet(TeTextSet& textSet, const string& tName = "")
+	{ return addText(textSet,tName); }
+	
+	//! Adds a set of cells to a layer
+	virtual bool addGeometrySet(TeCellSet& cellSet, const string& /* tName */ = "")
+	{ return addCells(cellSet); }
+
+	//! Adds a set of polygons to a layer
+	virtual bool addPolygons(TePolygonSet& polySet);
+
+	//! Adds a set of lines to a layer
+	virtual bool addLines (TeLineSet& lineSet);
+
+	//! Adds a set of points to a layer
+	virtual bool addPoints (TePointSet& pointSet);
+
+	//! Adds a set of text to a layer
+	virtual bool addText (TeTextSet& textSet,const string& tName);
+	
+	//! Adds a set of cells to a layer
+	virtual bool addCells(TeCellSet& cellSet);
+
+	//@}
+
+	/** @name Geometries
+	*  Methods to deal with geometrical representations of a layer
+	*/
+	//! Removes a geometry from layer
+	virtual bool removeGeometry (TeGeomRep repType, const string& tName="");
+
+	//! Indicates if layer has a geometry representation
+	virtual bool hasGeometry (TeGeomRep rep);
+
+    //! Retrieves the table name associated to a geometry representation
+	/*! \param rep geometrical representation
+		\note When there is more than one representation of a given type
+		 returns the table name associated to the first one encountered
+	*/
+	virtual string tableName(TeGeomRep rep); 
+
+	//! Retrieves the number of geometries of a type
+	/*! 
+		\param rep geometrical representation
+	*/	
+	virtual int nGeometries(TeGeomRep rep);
+
+	//! Gets all information about a representation
+	virtual bool getRepresentation(TeGeomRep repType, TeRepresPointerVector& result);
+
+	//! Gets an specific representation
+	/*! 
+		\param repType the geometrical representation being searched
+		\param tableName the table associated to this representation
+		\return the representation associated to a geometry with the given table name
+		\note if no table name is specified the first found is returned
+	*/
+	virtual TeRepresentation* getRepresentation(TeGeomRep repType, const string& tableName="");
+    
+	//! Creates a new geometry representation to a layer
+	/*
+		\param repType the geometrical representation being searched
+		\param tableName name of the table that will stored the geometries
+		\param desc description of the representation
+		\return true if success and false otherwise
+	*/
+	virtual bool addGeometry ( TeGeomRep repType, const string& tableName="", const string& desc = "");
+
+	//! Creates a new raster geometry to a layer
+	/*
+		\param par raster parameters
+		\param objectId identifier of the object that has the raster geometry
+		\param tableName name of the table that will stored the geometries
+		\param desc description of the representation
+		\return true if success and false otherwise
+	*/
+	virtual bool addRasterGeometry(TeRasterParams& par, const string& objectId, 
+						   const string& tableName="", const string& desc="");
+
+	//! Inserts a raster as a geometry of an object of the layer
+	/*
+		\param raster a pointer to a raster object
+		\param objectId identifier of the object that has the raster geometry
+		\param tableName the name of the table that will store the geometry (optional)
+		\return true if success and false otherwise
+		\note if there is already raster geometry associated to the object with id
+		object id, this reference is deleted.
+	*/	
+	bool addRasterGeometry(TeRaster* raster, const string& objectId="");
+
+	//! Inserts a reference to a raster file as a raster geometry of an object of the layer
+	/*
+		\param raster a pointer to a raster object
+		\param objectId identifier of the object that has the raster geometry
+		\param desc the description of the geometry (optional)
+		\return true if success and false otherwise
+		\note if there is already raster geometry associated to the object with id
+		object id, this reference is deleted.
+	*/	
+	bool addRasterFileGeometry(TeRaster* raster, const string& objectId="", const string& desc="");
+
+
+	//! Returns a vector with the identification of all objects of the layer that has a raster representation
+	/*
+		\param objectIds a vector to return the identification of the objects with a raster representation
+		\param tilingType used to express that only some types of representations are looked for: 
+			   0 any kind, 1 only the expansible and 2 only the non-expansible
+		\return true if layer has at least one raster object and false otherwise
+	*/
+	virtual bool getRasterGeometries(vector<string>& objectIds, unsigned int tilingType=0);
+
+	//! Returns a combination of all representations in the layer
+	virtual int geomRep();
+
+	//! Adds a representation to vector of representation of the layer
+	virtual void addVectRepres(TeRepresentation* rep)
+	{	repVector_.push_back(rep); }
+
+	//! Returns a vector with all representations in the layer
+	virtual TeRepresPointerVector& vectRepres()
+	{	return repVector_; }
+
+	//@}
+
+private:
+
+// -- Members
+
+// -- General Description of a layer
+
+	string		name_;					//!< layer name
+	int			id_;					//!< layer unique identification
+	TeDatabase*	db_;					//!< database connection to this layer
+	TeProjection*	projection_;		//!< layer projection
+	TeBox		box_;					//!< layer bounding box
+	TeRaster*	raster_;				//!< layer raster representation
+
+	TeAttrTableVector	attTables_; 	//!< Attributes associated to a layer
+	TeRepresPointerVector repVector_;	//!< vector of representations associated to this layer
+};
+
+//! A map from a integer unique identifier to a pointer to layer
+typedef map<int,TeLayer*> TeLayerMap;
+
+/** \example createLayer.cpp
+	Shows how to create a layer in a TerraLib database, and insert some vectorial data in this new layer
+ */
+
+/** \example addGeomRepresentation.cpp
+	Shows how to create a point representation (centroid of polygons) to a layer in a TerraLib database.
+ */
+#endif
+
diff --git a/src/terralib/kernel/TeLegendEntry.cpp b/src/terralib/kernel/TeLegendEntry.cpp
new file mode 100644
index 0000000..9a4ce1f
--- /dev/null
+++ b/src/terralib/kernel/TeLegendEntry.cpp
@@ -0,0 +1,174 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+#include <TeLegendEntry.h>
+
+TeLegendEntry::TeLegendEntry(const TeSlice& slice) :
+	slice_(slice),
+	id_(-1),
+	theme_(0),
+	group_(0)
+{
+	if (slice_.from_ == "Missing Data")
+		label_ = "Missing Data";
+	else 
+	{
+		int i = slice_.from_.find("mean = ");
+		if (i >= 0 || slice_.to_.empty())
+			label_ = slice_.from_;
+		else
+			label_ = slice_.from_ + " ~ " + slice_.to_;
+	}
+}
+
+
+TeLegendEntry::TeLegendEntry (const TeLegendEntry& leg)
+{
+	*this = leg;
+}
+
+TeLegendEntry&
+TeLegendEntry::operator = (const TeLegendEntry& leg)
+{
+	if ( this != &leg )
+	{	//clears the current map
+		TeGeomRepVisualMap::iterator currMapIt = visualMap_.begin();
+		while( currMapIt != visualMap_.end() )
+		{
+			if (currMapIt->second)
+			{
+				delete currMapIt->second;
+				currMapIt->second = NULL;
+			}				
+			++currMapIt;
+		}
+		visualMap_.clear();
+			
+		//copy the new map
+		TeGeomRepVisualMap::const_iterator it = leg.visualMap_.begin();
+		while( it != leg.visualMap_.end() )
+		{
+			if (it->second)
+			{
+				TeVisual* visual = it->second->copy();
+				visualMap_[ it->first ] = visual;
+			}
+			++it;
+		}
+		slice_ = leg.slice_;
+		label_ = leg.label_;
+		id_ = leg.id_;
+		theme_ = leg.theme_;
+		group_ = leg.group_;
+	}
+	return *this;
+}
+
+void
+TeLegendEntry::clear()
+{
+	slice_.from_.clear();
+	slice_.to_.clear();
+	label_.clear();
+
+	//clears the current map
+	TeGeomRepVisualMap::iterator currMapIt = visualMap_.begin();
+	while( currMapIt != visualMap_.end() )
+	{
+		if (currMapIt->second)
+		{
+			delete currMapIt->second;
+			currMapIt->second = NULL;
+		}
+		++currMapIt;
+	}
+	visualMap_.clear();
+}
+
+string 
+TeLegendEntry::label()
+{
+    if (label_.empty())
+    {
+        int npos = slice_.from_.find("mean = ");
+        if (npos >= 0 || slice_.to_.empty())
+            label_ = slice_.from_;
+        else 
+            label_ = slice_.from_ + " ~ " + slice_.to_;
+    }
+    return label_;
+} 
+
+TeVisual*
+TeLegendEntry::visual(TeGeomRep rep, const string& visualType)
+{ 
+	if(visualMap_.find(rep) == visualMap_.end())
+	{
+		TeVisual* visual = TeVisualFactory::make(visualType);
+        visualMap_[rep] = visual; 
+	}
+	return visualMap_[rep];
+}
+
+void 
+TeLegendEntry::color( TeColor& color )
+{
+	if(visualMap_.find(TePOLYGONS) != visualMap_.end())
+	{
+		TeVisual* tmpVisual = visualMap_[TePOLYGONS];
+		if (tmpVisual)
+		{
+			tmpVisual->color( color );
+			if ( tmpVisual->style() != 1 ) 
+				tmpVisual->contourColor( color );
+		}		
+	}
+	if(visualMap_.find(TeLINES) != visualMap_.end())
+	{
+		TeVisual* tmpVisual = visualMap_[TeLINES];
+		if (tmpVisual)
+			tmpVisual->color( color );
+	}
+	if(visualMap_.find(TePOINTS) != visualMap_.end())	
+	{
+		TeVisual* tmpVisual = visualMap_[TePOINTS];
+		if (tmpVisual)
+			tmpVisual->color( color );
+	}
+}
+
+void 
+TeLegendEntry::setVisual(TeVisual* vis, TeGeomRep rep) 
+{ 
+	if ( visualMap_.find(rep) != visualMap_.end() )
+	{
+		if ((visualMap_[rep] != NULL) && (visualMap_[rep] != vis))
+			delete visualMap_[rep];
+	}	
+	visualMap_[rep] = vis; 
+}
+
+void 
+TeLegendEntry::setVisual(TeVisual& vis, TeGeomRep rep) 
+{
+	return (setVisual(vis.copy(), rep));
+}
diff --git a/src/terralib/kernel/TeLegendEntry.h b/src/terralib/kernel/TeLegendEntry.h
new file mode 100644
index 0000000..3ffb0e4
--- /dev/null
+++ b/src/terralib/kernel/TeLegendEntry.h
@@ -0,0 +1,168 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeLegendEntry.h
+    \brief This file deals with legends in TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_LEGENDENTRY_H
+#define  __TERRALIB_INTERNAL_LEGENDENTRY_H
+
+#include <string>
+#include <vector>
+#include <map>
+
+using namespace std;
+
+#include "TeUtils.h"
+#include "TeDataTypes.h"
+#include "TeSlice.h"
+#include "TeVisual.h"
+
+class TeTheme;
+struct TeColor;
+
+//! A map from representation types to a presentation visual characteristics
+typedef map<TeGeomRep,TeVisual*> TeGeomRepVisualMap;
+
+
+//! A Legend Entry represents a group of objects of a theme
+/*!
+	A legend entry is associated to a  group of a theme. It has a label and a TeSlice
+	that defines a property of of the objects that fall into this legend.
+	A legend entry has an associated label and the visual presentation characteristics 
+	of the objects that fall into this legend.
+*/
+class TL_DLL TeLegendEntry
+{
+public:
+
+	//! Empty constructor
+	TeLegendEntry () : 
+		label_(""),
+		id_(-1),
+		theme_(0),
+		group_(0)
+		{}
+
+	//! Constructor from a slice
+	TeLegendEntry (const TeSlice& slice);
+	
+	//! Copy constructor
+	TeLegendEntry (const TeLegendEntry& leg);
+
+	//! Operator =
+	TeLegendEntry& operator = (const TeLegendEntry& leg);
+
+	//! Destructor
+	virtual ~TeLegendEntry()
+	{	clear(); }
+
+	//! Clear the legend
+	void clear();
+
+	//! Returns the legend id
+	int	id () 
+	{ return id_; }
+	//! Sets the legend id
+	void id (int i) { id_ = i; }
+
+	//! Returns the theme identifier to which the legend belongs
+	int	theme () { return theme_; }
+	//! Sets the theme id to which this legend belongs to
+	void theme (int i) { theme_ = i; }
+
+	//! Returns the group identifier associated to the legend
+	int	group () { return group_; }
+	//! Sets the group identification to which this legend refers to
+	void group (int i) { group_ = i; }
+
+	//! Returns the visual presentation characteristics associated to a given representation
+	TeVisual* visual (TeGeomRep rep, const string& visualType="tevisual");
+
+	//! Sets the visual presentation characteristics associated to a given representation
+	void setVisual (TeVisual* vis, TeGeomRep rep); 
+
+	//! Sets the visual presentation characteristics associated to a given representation
+	void setVisual (TeVisual& vis, TeGeomRep rep); 
+	
+	//! Return the visual presentation characteristics map
+	TeGeomRepVisualMap& getVisualMap()
+	{	return visualMap_; }
+
+	//! Returns the slice associated to this legend
+	TeSlice& slice()
+	{  return slice_; }
+	// Sets the slice associated to this legend
+	void setSlice(const TeSlice& sl)
+	{	slice_ = sl; }
+	//! Returns the number of objects of the legend
+	int count() 
+	{ return slice_.count_; }
+	//! Sets the number of objects with the legend
+	void count(int n) 
+	{ slice_.count_ = n; }
+	//! Increase the number of objects with the legend
+	void incCount(int n=1)
+	{	slice_.count_ += n; }
+	
+	//! Returns the lower value associated to the legend
+	string from()
+	{	return slice_.from_; }
+	//! Sets the lower value associated to the legend
+	void from(string& s)
+	{ slice_.from_ = s; }
+
+	//! Returns the upper value associated to the legend
+	string to()
+	{	return slice_.to_; }
+	//! Sets the upper value associated to the legend
+	void to(string& s)
+	{	slice_.to_ = s; }
+
+	//! Returns the label associated to the legend 
+	string label();
+	
+	//! Sets the label associated to the legend
+	void label(string& s)
+	{	label_ = s; }
+
+	//! Sets the color associated to the legend
+	void color(TeColor& color);
+
+private:
+
+	TeGeomRepVisualMap	visualMap_;
+	TeSlice				slice_;
+	string				label_;
+	int					id_;
+	int					theme_;
+	int					group_;
+};
+
+//! A vector of legendy entries
+typedef vector<TeLegendEntry> TeLegendEntryVector;
+
+//! A map of legend identifiers to legend entrie pointers
+typedef map<int, TeLegendEntry*> TeLegendEntryMap;
+
+#endif
+
diff --git a/src/terralib/kernel/TeMappedMemory.cpp b/src/terralib/kernel/TeMappedMemory.cpp
new file mode 100644
index 0000000..987f285
--- /dev/null
+++ b/src/terralib/kernel/TeMappedMemory.cpp
@@ -0,0 +1,415 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeMappedMemory.h"
+#include "TeException.h"
+#include "TeErrorLog.h"
+#include "TeUtils.h"
+#include "TeAgnostic.h"
+#include "TeDefines.h"
+
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  #include <io.h>
+  #include <fcntl.h>
+  #include <sys/stat.h>  
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  #include <sys/types.h>
+  #include <sys/stat.h>
+  #include <fcntl.h>
+  #include <unistd.h>
+#else
+  #error "Unsupported platform"
+#endif
+
+
+void TeMappedMemory::init()
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    m_hFile_ = 0;
+    m_hMapping_ = 0;
+    m_lpszFile_ = 0;
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    m_hFile_ = 0;
+    m_lpszFile_ = 0;
+  #else
+    #error "Unsupported platform"
+  #endif
+  
+  mapping_is_active_ = false;
+  curr_size_ = 0;
+  must_delete_file_ = false;
+};
+
+
+TeMappedMemory::TeMappedMemory()
+{
+  init();
+}
+
+
+TeMappedMemory::~TeMappedMemory()
+{
+  reset();
+}
+
+
+void TeMappedMemory::reset()
+{
+  TEAGN_TRUE_OR_THROW( toggle( false ), "Error disabling mapped memory" );
+  
+  if( must_delete_file_ ) {
+    remove( disk_file_name_.c_str() );
+  }
+  
+  disk_file_name_.clear();
+  
+  init();
+}
+
+
+bool TeMappedMemory::reset( unsigned long int size, bool enabled )
+{
+  reset();
+  
+  std::string disk_file_name;
+      
+  TEAGN_TRUE_OR_RETURN( TeGetTempFileName( disk_file_name ),
+    "Unable to get temporary file name" );
+    
+  return( reset( disk_file_name, size, false, enabled ) );
+}
+
+
+bool TeMappedMemory::reset( const std::string& filename, 
+  unsigned long int size, bool keep_disk_file, bool enabled )
+{
+  reset();
+
+  if( filename.empty() || ( size == 0 ) ) {
+    TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+      "Invalid mapped file name or invalid file size" ); 
+            
+    return false;
+  } else {
+    TEAGN_TRUE_OR_RETURN( createNewDiskFile( filename, size ),
+      "Unable to create memory mapped disk file" );
+      
+    disk_file_name_ = filename;
+    must_delete_file_ = ( ! keep_disk_file );
+    
+    if( toggle( enabled ) ) {
+      return true;
+    } else {
+      reset();
+      return false;
+    }
+  }
+}
+
+
+bool TeMappedMemory::reset( const std::string& filename, bool enabled )
+{
+  reset();
+  
+  disk_file_name_ = filename;
+  
+  if( toggle( enabled ) ) {
+    return true;
+  } else {
+    reset();
+    return false;
+  }  
+}
+
+
+bool TeMappedMemory::toggle( bool enabled )
+{
+  if( enabled  ) {
+    if( mapping_is_active_ ) {
+      return true;    
+    } else {
+      curr_size_ = 0;
+      
+      /* Activating mapping */    
+      
+      if( ! TeCheckFileExistence( disk_file_name_.c_str() ) ) {
+        return false;
+      }
+      
+      unsigned long int filesize = TeGetFileSize( disk_file_name_ );
+  
+      if( filesize > 0 ) {
+        #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+      
+          HANDLE m_hFile = CreateFileA(
+            disk_file_name_.c_str(), GENERIC_READ | GENERIC_WRITE, 
+            FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+            0, NULL);
+        
+          if( m_hFile == INVALID_HANDLE_VALUE ) {
+            TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+              "Temporary file creation error" );        
+       
+            return false;
+          }
+  
+          HANDLE m_hMapping = CreateFileMapping( m_hFile, NULL, PAGE_READWRITE,
+            0, 0, NULL );
+              
+          if( m_hMapping == NULL ) {
+            CloseHandle(m_hFile);
+        
+            TEAGN_LOGERR( "Mapping creation error - " +
+              getLastErrorStr() );
+              
+            return false;        
+          }
+        
+          LPVOID m_lpszFile = (LPVOID) MapViewOfFile( m_hMapping, 
+            FILE_MAP_ALL_ACCESS, 0, 0, 0);
+      
+          if( m_lpszFile == 0 ) {
+            CloseHandle( m_hMapping );
+            CloseHandle( m_hFile );
+            
+            TEAGN_LOGERR( "Mapping view creation error - " +
+              getLastErrorStr() );
+            
+            return false;        
+          }        
+      
+          m_hFile_ = m_hFile;
+          m_hMapping_ = m_hMapping;
+          m_lpszFile_ = m_lpszFile;
+          
+        #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+        
+          int m_hFile = open( disk_file_name_.c_str(), O_RDWR );
+
+          if( m_hFile == -1 ) {
+            TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+              "Temporary file creation error" );
+            
+            return false;         
+          }
+     
+          void* m_lpszFile  =  mmap(0, (long)filesize, (PROT_READ | PROT_WRITE), 
+            MAP_SHARED, m_hFile, 0);
+      
+          if( m_lpszFile == ((void*)-1) ) {
+            close( m_hFile );
+        
+            TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+              "Mapping creation error" );
+            
+            return false;            
+          }
+        
+          m_hFile_ = m_hFile;
+          m_lpszFile_ = m_lpszFile;
+        #else
+          #error "Unsupported platform"
+        #endif
+    
+        mapping_is_active_ = true;
+        curr_size_ = filesize;
+        
+        return true;
+      } else {     
+        return false;
+      }
+    }
+  } else {
+    if( mapping_is_active_ ) {
+      /* Disabling mapping */
+      
+      #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+        if( ! UnmapViewOfFile( m_lpszFile_ ) ) {
+          throw TeException( UNKNOWN_ERROR_TYPE, "Unable to unmap disk file",
+            false );
+        }
+          
+        CloseHandle( m_hMapping_ );
+        CloseHandle( m_hFile_ );
+      #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+        if( munmap( m_lpszFile_ , (long)curr_size_ ) == -1) {
+          throw TeException( UNKNOWN_ERROR_TYPE, "Unable to unmap disk file",
+            false );
+        }
+            
+        close(m_hFile_);
+      #else
+        #error "Unsupported platform"
+      #endif
+      
+      mapping_is_active_ = false;
+      curr_size_ = 0;
+    }
+        
+    return true;
+  }
+}
+
+
+void* TeMappedMemory::getPointer() const
+{
+  TEAGN_TRUE_OR_THROW( mapping_is_active_,
+    "Trying to access an inactive mapping" );
+    
+  return m_lpszFile_;
+}
+
+
+std::string TeMappedMemory::getFileName() const
+{
+  TEAGN_TRUE_OR_THROW( mapping_is_active_,
+    "Trying to access an inactive mapping" );
+    
+  return disk_file_name_;
+}
+
+
+bool TeMappedMemory::createNewDiskFile( const std::string& filename,
+  unsigned long int size ) const
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    int m_hFile = open( filename.c_str(),_O_RDWR|_O_CREAT,
+      _S_IREAD | _S_IWRITE);
+
+    if( m_hFile == -1 ) {
+      TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+        "Temporary file creation error" );
+              
+      return false;         
+    }
+    
+    off_t seek_off = ( off_t )( size - 1 );
+          
+    if( lseek(m_hFile, seek_off, SEEK_SET) == -1 ) {
+      close( m_hFile );
+          
+      TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+        "Temporary file seek error" );
+              
+      return false;           
+    }
+        
+    unsigned char c = '\0';
+    
+
+    if( write( m_hFile, (void*)&c, sizeof( unsigned char ) ) == -1 ) {
+      close( m_hFile );
+          
+      TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+        "Temporary file write error" );
+              
+      return false;            
+    }  
+    
+    close( m_hFile );  
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    int m_hFile = open( filename.c_str(),O_RDWR|O_CREAT,S_IRWXU);
+
+    if( m_hFile == -1 ) {
+      TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+        "Temporary file creation error" );
+              
+      return false;         
+    }
+    
+    off_t seek_off = ( off_t )( size - 1 );
+          
+    if( lseek(m_hFile, seek_off, SEEK_SET) == -1 ) {
+      close( m_hFile );
+          
+      TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+        "Temporary file seek error" );
+              
+      return false;           
+    }
+        
+    unsigned char c = '\0';
+    
+
+    if( write( m_hFile, (void*)&c, sizeof( unsigned char ) ) == -1 ) {
+      close( m_hFile );
+          
+      TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE,
+        "Temporary file write error" );
+              
+      return false;            
+    }  
+    
+    close( m_hFile );
+  #else
+    #error "Unsupported platform"
+  #endif
+  
+  return true;
+}
+
+
+std::string TeMappedMemory::getLastErrorStr()
+{
+  std::string error_string;
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+    LPVOID lpMsgBuf = 0;    
+    DWORD dw = GetLastError();
+    int written_chars_nmb = 0;
+    
+    written_chars_nmb = FormatMessage(
+          FORMAT_MESSAGE_ALLOCATE_BUFFER |
+            FORMAT_MESSAGE_FROM_SYSTEM | 
+            FORMAT_MESSAGE_IGNORE_INSERTS,
+          NULL,
+          dw,
+          0,
+          (LPTSTR) &lpMsgBuf,
+          1024, 
+          NULL );
+          
+    if( written_chars_nmb > 0 ) {
+      int str_size = MIN( 1024, 2 * written_chars_nmb );
+      error_string = std::string( ( (char*)lpMsgBuf ), 1024 );
+    }
+    
+    if( lpMsgBuf ) {
+      LocalFree(lpMsgBuf);
+    }
+    
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  
+  #else
+    #error "Unsuported platform"
+  #endif
+  
+  return error_string;
+}
+
+
+unsigned long int TeMappedMemory::size() const
+{
+  return curr_size_;
+}
diff --git a/src/terralib/kernel/TeMappedMemory.h b/src/terralib/kernel/TeMappedMemory.h
new file mode 100644
index 0000000..6abfe24
--- /dev/null
+++ b/src/terralib/kernel/TeMappedMemory.h
@@ -0,0 +1,232 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeMappedMemory.h
+    \brief This file deals with mapped memory resources
+*/
+
+#ifndef TEMAPPEDMEMORY_H
+  #define TEMAPPEDMEMORY_H
+  
+  #include "TeSharedPtr.h"
+  #include "TeDefines.h"
+  
+  #include <string>
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    #include <windows.h>
+    #include <winbase.h>
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    #include <sys/mman.h>
+  #else
+    #error "ERROR: Unsupported platform"
+  #endif  
+
+  /**
+    * @brief This is class deals with mapped memory resources.
+    * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+    * @ingroup Utils
+    */
+  class TL_DLL TeMappedMemory {
+    public :
+      typedef TeSharedPtr< TeMappedMemory > pointer;
+      typedef const TeSharedPtr< TeMappedMemory > const_pointer;    
+      
+      /**
+       * @brief Default Constructor.
+       */
+      TeMappedMemory();          
+      
+      /**
+       * @brief Default Destructor.
+       */
+      ~TeMappedMemory();
+      
+      /**
+       * @brief Reset the current instance (free all allocated resources).
+       */
+      void reset();
+      
+      /**
+       * @brief Reset the current instance to new size.
+       * @note The mapped memory file will be automatically created.
+       * @param size The new mapped memory size (bytes).
+       * @param enabled Mapping enabled/disabled state.
+       * @return true if OK. false on errors.
+       */
+      bool reset( unsigned long int size, bool enabled );
+      
+      /**
+       * @brief Reset the current instance using a new created disk file.
+       *
+       * @note The mapped memory size will follow the disk file size.
+       *
+       * @param filename The mapped memory disk file name.
+       * @param size The new mapped memory size (bytes).
+       * @param keep_disk_file if true, the file will not be deleted.
+       * @param enabled Mapping enabled/disabled state.
+       * @return true if OK. false on errors.
+       */
+      bool reset( const std::string& filename, unsigned long int size,
+        bool keep_disk_file, bool enabled );      
+      
+      /**
+       * @brief Reset the current instance using an exising disk file.
+       * @note The mapped memory size will follow the disk file size.
+       * @param filename The mapped memory disk file name.
+       * @param enabled Mapping enabled/disabled state.       
+       * @return true if OK. false on errors.
+       */
+      bool reset( const std::string& filename, bool enabled );      
+      
+      /**
+       * @brief Enable / disable the current mapping instance.
+       *
+       * @return true if OK. false on errors.
+       */
+      bool toggle( bool enabled );         
+      
+      /**
+       * @brief Returns a pointer reference to the mapped memory.
+       *
+       * @note Throws an exception if no mapped memory is active.
+       */
+      void* getPointer() const;
+      
+      /**
+       * @brief Returns the current mapped file name.
+       * @return The current mapped file name.
+       * @note Throws an exception if no mapped memory is active.
+       */
+      std::string getFileName() const;
+      
+      /**
+       * @brief The current allocated mapped memory size (bytes).
+       *
+       * @return The current allocated mapped memory size (bytes).
+       */
+      unsigned long int size() const;      
+      
+    protected :
+    
+      #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+      
+        /**
+         * @brief Handle to file we're currently zapping
+         */
+        HANDLE m_hFile_;
+        
+        /**
+         * @brief Handle to memory-mapping of that file
+         */
+        HANDLE m_hMapping_;
+        
+        /**
+         * @brief Pointer to mapped to memory
+         */
+        LPVOID m_lpszFile_;
+        
+      #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  
+        /**
+         * @brief Handle to file we're currently zapping
+         */
+        int m_hFile_;
+        
+        /**
+         * @brief Pointer to mapped to memory
+         */
+        void* m_lpszFile_;
+        
+      #else
+        #error "Unsuported platform"
+      #endif
+      
+      /**
+       * @brief A flag indicating when this map is active.
+       * @note Default value : false.
+       */        
+      bool mapping_is_active_;
+      
+      /**
+       * @brief The disk file name.
+       * @note Default value : empty string.
+       *
+       */        
+      std::string disk_file_name_;
+      
+      /**
+       * @brief The current mapped memory size.
+       * @note Default value : 0.
+       */    
+      unsigned long int curr_size_;
+     
+      /**
+       * @brief True if the mapped file must be deleted.
+       * @note Default value : false.
+       */    
+      bool must_delete_file_;
+      
+      /**
+       * @brief Initiates the global initial state.
+       *
+       */      
+      void init();
+      
+      /**
+       * @brief Create a new disk file suitable for memory mapping.
+       * @param filename The file name.
+       * @param size The file size.
+       * @return true if OK. false on errors.
+       */
+      bool createNewDiskFile( const std::string& filename, 
+        unsigned long int size ) const;
+        
+      /**
+       * @brief Generate the last error string.
+       * @return The last error string.
+       */        
+      std::string getLastErrorStr();
+      
+    private :
+    
+      /**
+       * @brief Alternative Constructor.
+       *
+       */
+      TeMappedMemory( const TeMappedMemory& ) {}; 
+          
+      /**
+       * @brief Operator= overload.
+       *
+       */
+      const TeMappedMemory& operator=( const TeMappedMemory& )
+      {
+        return *this;
+      };
+  };
+  
+/** @example TeMappedMemory_test.cpp
+ *    Shows how to use this class.
+ */    
+
+#endif
diff --git a/src/terralib/kernel/TeMatrix.cpp b/src/terralib/kernel/TeMatrix.cpp
new file mode 100644
index 0000000..9ddd11f
--- /dev/null
+++ b/src/terralib/kernel/TeMatrix.cpp
@@ -0,0 +1,1540 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+ // TeMatrix.c -- matrix of type double
+
+#include <TeMatrix.h>
+
+#include <TeAgnostic.h>
+
+#include <math.h>
+#include <stdio.h>
+
+
+TeMatrix::TeMatrix(){
+	nrow = 0;
+	ncol = 0;
+	mat  = NULL;
+	lixo = 0.;
+}
+
+void
+TeMatrix::Clear()
+{
+	if( mat != NULL ){
+		int i;
+		for( i = 0; i < nrow; i++ )
+			if( mat[i] != NULL )
+			{
+				delete []mat[i];
+				mat[i]=NULL;
+			}
+		delete []mat;
+		mat = NULL;
+	}
+	nrow = ncol = 0;
+	lixo = (double)0;
+}
+
+TeMatrix::~TeMatrix()
+{
+	Clear();
+}
+
+short
+TeMatrix::Alloc(int nl, int nc)
+{
+	Clear();
+	if( nl <= 0 || nc <= 0 ){
+		return true;
+	}
+	nrow = nl;
+	ncol = nc;
+	if (  (mat = new double*[nrow]) == NULL ){
+		Clear();
+		return false;
+	}
+	int i,j;
+	for( i = 0; i < nrow; i++ ) mat[i] = NULL;
+	for( i = 0; i < nrow; i++ ){
+		if( (mat[i] = new double[ncol]) == NULL ){
+			Clear();
+	       		return false;
+		}
+		for( j = 0; j < ncol; j++ ) mat[i][j] = (double)0.;
+	}
+	return true;
+}
+
+TeMatrix::TeMatrix(const TeMatrix& m)
+{
+     nrow = ncol = 0;
+     mat = NULL;
+     lixo = 0.;
+    *this = m;
+}
+
+int
+TeMatrix::Init( int nl, int nc , double* f )
+{
+ 	if( f == NULL )
+		return Init( nl, nc,  (double) 0 );
+	if( Alloc( nl, nc ) ){
+		int c=0;
+		int i,j;
+		for ( i = 0; i < nrow; i++)
+			for (j = 0; j < ncol; j++)
+				mat[i][j] = f[c++];
+		return true;
+	}
+	return false;
+}
+
+int
+TeMatrix::Init(int nl, int nc, double f )
+{
+ 	// initialize matrix
+	if( Alloc( nl, nc ) ){
+ 		int i,j;
+     		for (i = 0; i < nrow; i++)
+       			 for (j = 0; j < ncol; j++)
+        		 	mat[i][j] = f;
+		return true;
+	}
+	return false;
+}
+
+int
+TeMatrix::Init(int k, double* f)
+{
+ 	if( f == NULL )
+		return Init( k, k,  (double) 0 );
+	if( Alloc(k,k) == false ) 
+		return false;
+	int i,j;
+	for ( i = 0; i < nrow; i++  )
+    		for (j = 0; j < ncol; j++)
+        		mat[i][j] = (i==j)? f[i]: (double)0.;
+   	return true;
+}
+
+int
+TeMatrix::Init(int k, double f)
+{
+	if( Alloc(k,k) == false )
+		return false;
+	int i,j;
+	for (i=0; i<nrow; i++)
+		for (j=0; j<ncol; j++)
+			mat[i][j] = (i==j)? (double)f:0;
+	return true;
+}
+
+TeMatrix& 
+TeMatrix::operator=(const TeMatrix& m)
+{
+
+	if( Alloc(m.nrow,m.ncol) == false ){
+		printf("\nMatrix::operator=:no memory available \n");
+		return *this;
+    	}
+	int	i,j;
+    	for( i = 0; i < nrow; i++)
+     		for( j = 0; j < ncol; j++)
+       			mat[i][j] = m.mat[i][j];
+    	return *this;
+}
+
+int
+TeMatrix::operator==(const TeMatrix& m) const
+{
+	if( nrow != m.nrow || ncol != m.ncol )
+		return false;
+	int	i,j;
+	for ( i = 0; i < nrow; i++)
+		for ( j = 0; j < ncol; j++)
+			if ( mat[i][j]!= m.mat[i][j] )
+				return false;
+	return true;
+}
+
+void
+TeMatrix::operator*=(double f)
+{
+	int	i,j;
+	for( i = 0; i < nrow; i++)
+		for( j = 0; j < ncol; j++)
+			mat[i][j] *= f;
+	return;
+}
+
+
+//-------------------------------------------------------------friend methods
+
+TeMatrix
+operator+(const TeMatrix& m,const TeMatrix& n)
+{
+	if( m.nrow != n.nrow || m.ncol != n.ncol ){
+		printf("\nMatrix::operator+ >>> Operandos com tamanhos diferentes\n");
+	        return  m;
+	} 
+	TeMatrix rm;
+	if( rm.Init(m.Nrow(),m.Ncol()) == false ){
+		printf("\nMatrix::operator+ >>> Memoria nao disponivel\n");
+		return	m;
+	}
+	int	i,j;
+	for ( i = 0; i < m.Nrow(); i++)
+		for ( j = 0; j < m.Ncol(); j++)
+			rm.mat[i][j] = m.mat[i][j] + n.mat[i][j];
+	return rm;
+}
+
+TeMatrix
+operator-(const TeMatrix& m,const TeMatrix& n)
+{
+	if( m.nrow != n.nrow || m.ncol != n.ncol ){
+		printf("\nMatrix::operator+ >>> Operandos com tamanhos diferentes\n");
+	        return  m;
+	} 
+	TeMatrix rm;
+	if( rm.Init(m.Nrow(),m.Ncol()) == false ){
+		printf("\nMatrix::operator- >>> Memoria nao disponivel\n");
+		return	m;
+	}
+
+	int	i,j;
+	for ( i = 0; i <  m.Nrow(); i++)
+		for ( j = 0; j < m.Ncol(); j++)
+			rm.mat[i][j] = m.mat[i][j] - n.mat[i][j];
+	return rm;
+}
+
+TeMatrix
+TeMatrix::operator-()
+{
+	TeMatrix rm;  
+	if( rm.Init(Nrow(),Ncol()) == false ){
+		printf("\n operator-:no memory \n");
+		return	*this;
+	}
+	int i,j;
+	for (i=0; i<Nrow(); i++)
+		for (j=0; j<Ncol(); j++)
+			rm.mat[i][j] = -mat[i][j];
+	return rm;
+}
+
+TeMatrix 
+operator*(const TeMatrix& m,const TeMatrix& n)
+{
+	if ( m.Ncol() != n.Nrow() ) {
+		printf( "\nMatrix::operator* >>> Operandos com tamanhos diferentes\n");
+		return m;
+	}
+	int nr = m.Nrow(), nc =n.Ncol();
+	TeMatrix result;
+	if( result.Init(nr,nc) == false){
+		printf("\nMatrix::operator* >>> Memoria nao disponivel\n");
+		return	m;
+	}
+
+	double	sum = (double)0.;
+	int	l,c,i;
+
+	for ( l = 0; l < m.Nrow(); l++){
+		for ( c = 0; c < n.Ncol(); c++){
+        		sum = (double)0.;
+			for ( i = 0; i < m.Ncol(); i++)
+				sum += m.mat[l][i] * n.mat[i][c];
+    			result.mat[l][c] = sum;
+
+		}
+	}
+	return result; 
+}
+
+TeMatrix
+operator*(double f,const TeMatrix& m)
+{
+	int nr = m.Nrow(), nc =m.Ncol();
+	TeMatrix rm;
+	if( rm.Init(nr,nc) == false){
+		printf("\noperator*:no memory");
+		return m;
+	}
+	int i,j;
+	for (i = 0; i < rm.Nrow(); i++)
+		for (j = 0; j < rm.Ncol(); j++)
+			rm.mat[i][j] = f * m.mat[i][j];
+	return rm;
+}
+
+//VRMC 12/98
+int
+TeMatrix::isUpperTriangle() const
+{
+	// elements above diagonal != 0
+	int i,j;
+	for(j = 0; j < ncol; j++)
+		for(i = j+1; i < nrow; i++)
+			if ( mat[i][j]  != (double)0. )
+				return false;
+	return true;
+}
+
+//VRMC 12/98
+int
+TeMatrix::isLowerTriangle() const	
+{
+	// elements under diagonal different 0
+	int i,j;
+	// VRMC 11/98
+	for (i=0; i< nrow; i++)
+		for (j= i+1; j <ncol; j++)
+			if ( mat[i][j] != (double)0. )
+				return false;
+	return true;
+}
+
+double
+TeMatrix:: Determinant() const
+{
+	if (Nrow() != Ncol()) {
+		return lixo;
+	}
+	if (Nrow()==1) return mat[0][0];
+	if (Nrow()==2)
+		return mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];
+	if (Nrow()==3) 
+		return (  mat[0][0] * mat[1][1] * mat[2][2]
+			 +mat[0][1] * mat[1][2] * mat[2][0]
+			 +mat[0][2] * mat[1][0] * mat[2][1]
+			 -mat[0][1] * mat[1][0] * mat[2][2]
+			 -mat[0][0] * mat[1][2] * mat[2][1]
+ 			 -mat[0][2] * mat[1][1] * mat[2][0] );
+	if ( isUpperTriangle() ) {
+		double val = 1;
+		int i;
+		for (i = 0; i < Nrow(); i++) val *= mat[i][i];
+		return val;
+    	}
+	TeMatrix mt;
+	double val = 0;
+	double det;
+	int sign = 1;
+	int j;
+	for(j = 0; j < Ncol(); j++) {
+		if( CoFactor(0,j, mt) == false )
+			return (double)0;
+		det = mt.Determinant();		
+		val += sign * mat[0][j] * det;
+		sign *= -1;
+     	}
+	return val;
+}
+
+int
+TeMatrix::CoFactor(int irow, int jcol, TeMatrix& mt ) const
+{
+ 	if ( nrow == 1||ncol == 1 ) {
+		printf("\nMatrix::CoFactor >>>  can't CoFactor row or column matrix\n");
+		return false;
+   	}
+	if( mt.Init(nrow-1,ncol-1) == false){
+		printf("\nMatrix::CoFactor: Memoria nao disponivel\n");
+		return false;
+	}
+	int getcol, getrow =0;
+	int i,j;
+	for(i=0; i < mt.Nrow(); i++) {
+		if ( getrow == irow ) ++getrow;
+		if ( getrow == nrow ) break;
+		getcol = 0;
+		for(j=0; j < mt.Ncol(); j++) {
+			if ( getcol==jcol ) ++getcol;
+			if ( getcol==ncol ) continue;
+			mt.mat[i][j] = mat[getrow][getcol];
+			++getcol;
+		}
+		++getrow;
+	}
+	return true;
+}
+
+int 
+TeMatrix::Transpose( TeMatrix &rm ) const
+{
+	if( &rm == this ){
+		printf("\nMatrix::Transpose >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+
+	if( rm.Init( ncol, nrow ) == false){
+		printf("\nMatrix::Transpose >>> Memoria nao disponivel\n");
+		return false;
+	}
+	int i,j;
+	for(i = 0; i < ncol; i++)
+		for( j = 0; j < nrow; j++)
+			rm.mat[i][j] = mat[j][i];
+	return true;
+}
+
+// VRMC 12/98
+int
+TeMatrix::isSimetric()	const
+{
+	int i,j;
+
+	if (nrow != ncol){
+		printf("\nMatrix::isSimetric >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	for (i = 0; i < nrow; i++)
+		for (j = 0; j < ncol; j++)
+			if ( mat[i][j] != mat[j][i]) return false;
+
+	return	true;
+}
+
+// VRMC 12/98
+int		
+TeMatrix::isPositiveDefinide() const
+{
+	int i, j, dim, subdim;
+	TeMatrix	Submat;
+
+	if (nrow != ncol){
+		printf("\nMatrix::isPositiveDefinide >>> Matriz tem que ser quadrada\n");
+		return false;
+	}
+	dim = nrow;
+
+	for (subdim=1 ; subdim <= dim; subdim++)
+	{
+		if( Submat.Init( subdim,subdim ) == false ){
+			printf("\nMatrix::isPositiveDefinide>>>Memoria nao disponivel!\n");
+			return false;
+		}
+
+		for ( i=0; i < subdim; i++)
+			for (j = 0; j < subdim; j++)
+				Submat(i,j) = mat[i][j];
+		
+		if (Submat.Determinant() <= 0.) {
+			printf("\nMatrix::isPositiveDefinide>>>Matriz nao e positiva definida!\n");
+			return false;
+		}
+
+		Submat.Clear();
+	}
+	return true;
+}
+
+// VRMC 12/98
+int
+TeMatrix :: MatTransf( TeMatrix& mt )
+{
+	TeMatrix	TI;	// inverse of a inferior triangular matrix
+	int	dim;
+
+	if( &mt == this ){
+		printf("\nMatrix::MatTransf >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+
+	if( nrow <= 0 || ncol <= 0 ){
+		printf("\nMatrix::MatTransf >>> Dimensoes da matriz invalidas!\n");
+		return false;
+	}
+
+	if( nrow != ncol ){
+		printf("\nMatrix::MatTransf >>> Dimensoes da matriz invalidas!\n");
+		return false;
+	}
+
+	dim = nrow;
+	if( mat[0][0] <= 0. ){
+		printf("\nMatrix::MatTranf >>> ERROR\n");
+		return false;
+	}
+
+	if( TI.Init( dim, (double)0. ) == false ){
+		printf("\nMatrix::MatTransf >>> Memoria nao disponivel!\n");
+		return false;
+	}
+
+
+	//--	Calculate inferior triangular matrix by Cholesky decomposition method
+	if ((*this).CholeskyDecomp(TI) == false) {
+		printf("\nMatrix::MatTransf>>> Nao foi possivel decompor a matriz!\n");
+		return false;
+	}
+
+	//--	Calculate the inverse of Cholesky matrix
+//	if (TI.CholeskyInv(mt) != true)
+	if (!(TI.CholeskyInv(mt)))
+	{
+		printf("\nMatrix::MatTransf>>> Matriz nao inversivel!\n");
+		return false;
+	}
+
+	return true;
+}
+
+// VRMC 12/98			
+int
+TeMatrix::CholeskyInv (TeMatrix&	mt) const
+{
+	if( mt.Init(nrow,(double)0.) == false ){
+		printf("\nMatrix::CholeskyInv >>> Memoria nao disponivel!\n");
+		return false;
+	}
+
+	if( &mt == this ){
+		printf("\nMatrix::CholeskyInv >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+	if ( nrow != ncol ){
+       		printf("\nMatrix::CholeskyInv>>> Can't invert a non-square matrix");
+       		return false;
+   	}
+//	if (this->isLowerTriangle() != true) {
+	if (!(this->isLowerTriangle())) {
+		printf("\nMatrix::CholeskyInv >>> Matriz nao e triangular inferior\n");
+		return false;
+	}
+
+	int i; double rf;
+	for( i = 0; i < nrow; i++ ){
+		if( this->mat[i][i] == (double)0. ){
+			printf("\nMatrix::CholeskyInv >>> ERROR IV\n");
+			return false;
+		}
+		mt.mat[i][i] = (double)1. / this->mat[i][i];
+		int j,k;
+		for( j = i-1; j >= 0; j-- ){
+			rf = (double)0.;
+			for( k = j; k <= i-1; k++ ){
+				rf += ( this->mat[i][k] * mt.mat[k][j] );
+			}
+			mt.mat[i][j] = -rf * mt.mat[i][i];
+		}
+	}
+	return true;
+}
+	
+
+int
+TeMatrix::EigenValues( TeMatrix& mt ) const
+{
+	//---	calcula os eigenvalues  de uma
+	//	matriz representada na forma vetorial 
+	//	Os auto valores sao devolvidos em ordem decrescente    
+	//	e ocupam as posicoes:  0, 2, 5, 9, ... .       
+
+	if( &mt == this ){
+		printf("\nMatrix::EigenValues >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+
+double	*cov	= NULL,		/* matriz de covariancia	*/
+	*e_val	= NULL;		/*   "    de auto_valores	*/
+
+int 	dim = (*this).Nrow();		/* ordem da matriz*/
+
+int	i,j,k,		/*   cov[], e_val[]    */
+	ia,             /*                     */
+	ind,            /*     |0      |       */
+	l,m,            /*     |1 2    |       */
+	mq,lm,          /*     |3 4 5  |       */
+	ll,mm,          /*     |6 7 8 9|       */
+	ilq,imq,        /*                     */
+	im,iq,il,lq,    /*    (para DIM=4)     */
+	jq;
+
+double	range,          /*       e_vec[]       */
+	dim1,fdim,      /*                     */  
+	anorm,          /*    |0  4  8 12|     */
+	anrmx,          /*    |1  5  9 13|     */
+	thr,            /*    |2  6 10 14|     */
+	x,y,z,          /*    |3  7 11 15|     */
+	sinx,cosx,      /*                     */
+	sinx2,cosx2,
+	sincs;
+
+int 	fat = (dim*dim+dim)/2;
+
+	if( dim <= 0 ){
+		printf("\nMatrix::EigenValues >>> dimensao da matriz nula!\n");
+		return false;
+	}
+	if( mt.Init( dim, (double)1 ) == false ){
+		printf("\nMatrix::EigenValues >>> Memoria nao disponivel\n");
+		return false;
+	}
+	range = 1.0e-6 ;
+	dim1 = dim - 1 ;
+	fdim = dim;
+
+	cov = new double[fat];
+
+	if( cov == NULL ){
+		printf("\nMatrix::EigenValues >>> Memoria nao disponivel (COV)\n");
+		return false;
+	}
+
+	e_val = new double[fat];
+	if( e_val == NULL ){
+		delete []cov; //SSL0296
+		cov = NULL;
+		printf("\nMatrix::EigenValues >>> Memoria nao disponivel (EVAL)\n");
+		return false;
+	}
+	k = 0;
+	for ( i = 0; i< dim; i++)
+		for ( j = 0; j <= i; j++)
+			cov[k++] = mat[i][j];
+
+	for (i=0; i < ((dim*dim+dim)/2); i++) e_val[i] = cov[i];
+
+	anorm = 0.0;
+
+	for ( j = 0; j < dim; j++){
+		for (i = 0; i <= j; i++){
+			if (i != j){
+				ia = i + (j*j+j)/2;
+				anorm = anorm + e_val[ia] * e_val[ia];
+			}
+		}
+	}
+
+	if (anorm <= 0) goto l5;
+
+	anorm = 1.414 * sqrt((double)anorm);
+	anrmx = anorm * range/fdim;
+	ind   = 0;
+	thr   = anorm;
+
+l1:
+	thr = thr/fdim;
+l2:
+	l = 0;
+l3:
+	m = l+1;
+l4:
+	mq = (m*m + m)/2;
+	lq = (l*l + l)/2;
+	lm = l + mq;
+
+	if ( fabs((double)(e_val[lm])) >= thr )    
+	{
+		ind = 1;
+		ll = l + lq;
+		mm = m + mq;
+
+		x = 0.5 * (e_val[ll] - e_val[mm]);
+		z = e_val[lm] * e_val[lm] + x*x;
+		y = - e_val[lm] / sqrt((double)(z));
+
+		if (x < 0)  
+		{
+			y = -y;
+		}
+
+		z = sqrt( (double)(1.0-y*y) );
+		sinx = y / sqrt( (double)( 2.0*(1.0 + z) ) );
+		sinx2 = sinx * sinx;
+		
+		cosx = sqrt( (double)(1.0 - sinx2) );
+		cosx2 = cosx * cosx;
+
+		sincs = sinx * cosx;
+	
+		ilq = dim * l;
+		imq = dim * m;
+
+		for (i = 0; i < dim; i++)
+		{
+			iq = (i*i + i)/2;
+			if ( i != l )
+			{
+				if (i != m)
+				{
+					if (i > m) 
+						im = m + iq;
+					else
+						im = i + mq;
+					if (i < l)
+						il = i + lq;
+					else
+						il = l + iq;
+
+					x = e_val[il] * cosx - e_val[im] * sinx;
+					e_val[im] = e_val[il] * sinx + e_val[im] * cosx;
+					e_val[il] = x;
+				}
+			}
+		}
+		x = 2.0 * e_val[lm] * sincs;
+		y = e_val[ll] * cosx2 + e_val[mm] * sinx2 - x;
+		x = e_val[ll] * sinx2 + e_val[mm] * cosx2 + x;
+
+		e_val[lm] = (e_val[ll]-e_val[mm])*sincs+e_val[lm]*(cosx2-sinx2);
+		e_val[ll] = y;
+		e_val[mm] = x;
+	}
+
+	if (m != (dim-1))
+	{
+		m = m + 1;	goto l4;
+	}
+	if (l != (dim-2))
+	{
+		l = l + 1;	goto l3;
+	}
+	if (ind == 1)
+	{
+		ind = 0;	goto l2;
+	}
+	if (thr > anrmx) goto l1;
+
+l5:
+	iq = -dim;
+
+	for (i = 0; i < dim; i++)
+	{
+		iq = iq + dim;
+		ll = i + (i*i + i)/2;
+		jq = dim * (i-1);
+
+		for (j = i; j < dim; j++)
+		{
+			jq = jq + dim;
+			mm = j + (j*j + j)/2;
+
+			if (e_val[ll] < e_val[mm])
+			{
+				x = e_val[ll];
+				e_val[ll] = e_val[mm];
+				e_val[mm] = x;
+			}
+		}
+	}
+
+	for ( i = 0; i< dim; i++){
+		mt(i,0) = e_val[(i*(i+1))/2+i];
+	}
+
+	delete []cov;	//SSL0296
+	delete []e_val; //SSL0296
+
+	return true;
+}
+
+//--------------------------------------------------EigenVectors
+//
+//	Metodo adaptado a partir de uma implementacao em C
+//	utilizada no software SITIM.
+
+int
+TeMatrix::EigenVectors( TeMatrix& mt ) const
+{
+	if( &mt == this ){
+		printf("\nMatrix::EigenVectors >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+
+double	*cov	= NULL,		/* matriz de covariancia	*/
+	*e_val	= NULL,		/*   "    de auto_valores	*/
+	*e_vec	= NULL; 	/*   "    de auto_vetores	*/
+
+int 	dim = (*this).Nrow();		/* ordem da matriz*/
+
+int	i,j,ij,k,       /*   cov[], e_val[]    */
+	ia,             /*                     */
+	ind,            /*     |0      |       */
+	l,m,            /*     |1 2    |       */
+	mq,lm,          /*     |3 4 5  |       */
+	ll,mm,          /*     |6 7 8 9|       */
+	ilq,imq,        /*                     */
+	im,iq,il,lq,    /*    (para DIM=4)     */
+	ilr,imr,
+	jq;
+
+double	range,          /*       e_vec[]       */
+	dim1,fdim,      /*                     */  
+	anorm,          /*    |0  4  8 12|     */
+	anrmx,          /*    |1  5  9 13|     */
+	thr,            /*    |2  6 10 14|     */
+	x,y,z,          /*    |3  7 11 15|     */
+	sinx,cosx,      /*                     */
+	sinx2,cosx2,
+	sincs;
+
+	if( dim <= 0 ){
+		printf("\nMatrix::EigenValues >>> dimensao da matriz nula!\n");
+		return false;
+	}
+	if( mt.Init( dim, (double)1 ) == false ){
+		printf("\nMatriz::EigenVectors >>> Memoria nao disponivel!\n");
+		return false;
+	}
+
+	int fat =(dim*dim+dim)/2;
+	range = 1.0e-6 ;
+	dim1 = dim - 1 ;
+	fdim = dim;
+
+	cov   = new double[fat];
+	e_vec = new double[dim*dim];
+	e_val = new double[fat];
+
+	if( cov == NULL || e_vec == NULL || e_val == NULL ){
+		printf("\nMatrix::EigenVectors >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	k = 0;
+	for ( i = 0; i< dim; i++)
+		for ( j = 0; j <= i; j++)
+			cov[k++] = (*this)(i,j);
+
+	for (i=0; i < ((dim*dim+dim)/2); i++) e_val[i] = cov[i];
+
+	iq = -dim;
+	for (i = 0; i < dim; i++)
+	{
+		iq = iq + dim;
+		for ( j = 0; j < dim; j++)
+		{
+			ij = iq + j;
+			if (i == j)
+				e_vec[ij] = 1.0;
+			else
+				e_vec[ij] = 0.0;
+		}
+	}
+ 
+	anorm = 0.0;
+
+	for ( j = 0; j < dim; j++)
+	{	
+		for (i = 0; i <= j; i++)
+		{
+			if (i != j)
+			{
+				ia = i + (j*j+j)/2;
+				anorm = anorm + e_val[ia] * e_val[ia];
+			}
+		}
+	}
+
+	if (anorm <= 0) goto l5;
+
+	anorm = 1.414 * sqrt((double)anorm);
+	anrmx = anorm * range/fdim;
+	ind   = 0;
+	thr   = anorm;
+
+l1:
+	thr = thr/fdim;
+l2:
+	l = 0;
+l3:
+	m = l+1;
+l4:
+	mq = (m*m + m)/2;
+	lq = (l*l + l)/2;
+	lm = l + mq;
+
+	if ( fabs((double)(e_val[lm])) >= thr )    
+	{
+		ind = 1;
+		ll = l + lq;
+		mm = m + mq;
+
+		x = 0.5 * (e_val[ll] - e_val[mm]);
+		z = e_val[lm] * e_val[lm] + x*x;
+		y = - e_val[lm] / sqrt((double)(z));
+
+		if (x < 0)  
+		{
+			y = -y;
+		}
+
+		z = sqrt( (double)(1.0-y*y) );
+		sinx = y / sqrt( (double)( 2.0*(1.0 + z) ) );
+		sinx2 = sinx * sinx;
+		
+		cosx = sqrt( (double)(1.0 - sinx2) );
+		cosx2 = cosx * cosx;
+
+		sincs = sinx * cosx;
+	
+		ilq = dim * l;
+		imq = dim * m;
+
+		for (i = 0; i < dim; i++)
+		{
+			iq = (i*i + i)/2;
+			if ( i != l )
+			{
+				if (i != m)
+				{
+					if (i > m) 
+						im = m + iq;
+					else
+						im = i + mq;
+					if (i < l)
+						il = i + lq;
+					else
+						il = l + iq;
+
+					x = e_val[il] * cosx - e_val[im] * sinx;
+					e_val[im] = e_val[il] * sinx + e_val[im] * cosx;
+					e_val[il] = x;
+				}
+			}
+
+			//---	calculate eigenvectors
+
+			ilr = ilq + i;
+			imr = imq + i;
+			x   = e_vec[ilr] * cosx - e_vec[imr] * sinx;
+			e_vec[imr] = e_vec[ilr] * sinx + e_vec[imr] * cosx;
+			e_vec[ilr] = x;
+		}
+
+		x = 2.0 * e_val[lm] * sincs;
+		y = e_val[ll] * cosx2 + e_val[mm] * sinx2 - x;
+		x = e_val[ll] * sinx2 + e_val[mm] * cosx2 + x;
+
+		e_val[lm] = (e_val[ll]-e_val[mm])*sincs+e_val[lm]*(cosx2-sinx2);
+		e_val[ll] = y;
+		e_val[mm] = x;
+	}
+
+	if (m != (dim-1))
+	{
+		m = m + 1;	goto l4;
+	}
+	if (l != (dim-2))
+	{
+		l = l + 1;	goto l3;
+	}
+	if (ind == 1)
+	{
+		ind = 0;	goto l2;
+	}
+	if (thr > anrmx) goto l1;
+
+l5:
+	iq = -dim;
+
+	for (i = 0; i < dim; i++)
+	{
+		iq = iq + dim;
+		ll = i + (i*i + i)/2;
+		jq = dim * (i-1);
+
+		for (j = i; j < dim; j++)
+		{
+			jq = jq + dim;
+			mm = j + (j*j + j)/2;
+
+			if (e_val[ll] < e_val[mm])
+			{
+				x = e_val[ll];
+				e_val[ll] = e_val[mm];
+				e_val[mm] = x;
+
+				for (k = 0; k < dim; k++)
+				{
+					ilr = iq + k;
+					imr = jq + k;
+					x   = e_vec[ilr];
+					e_vec[ilr] = e_vec[imr];
+					e_vec[imr] = x;
+				}
+			}
+		}
+	}
+	
+	k=0;
+	for ( i = 0; i< dim; i++){
+		for ( j = 0; j< dim; j++)
+			mt(j,i) = e_vec[k++];
+	}
+
+	delete []cov;	//SSL0296
+	delete []e_vec;	//SSL0296
+	delete []e_val; //SSL0296
+
+	return true;
+}
+
+//--------------------------------------------------EigenVec
+//
+//	Metodo desenvolvido para suporte de decisao (suporte_stubs.cpp)
+//	Missae Yamamoto  (junho/1999)
+
+int
+TeMatrix::EigenVec( double e_vec[] )
+{
+
+double	*e_vec_aux	= NULL, soma = 0.0; 
+	
+int 	dim = (*this).Nrow();		/* ordem da matriz*/
+
+TeMatrix  aux1, aux2, mt;
+
+int	i,j,k;       
+	
+	if( dim <= 0 )
+	{
+		printf("\nMatrix::EigenVecVal >>> dimensao da matriz nula!\n");
+		return false;
+	}
+
+	if( aux1.Init( dim, (double)1 ) == false )
+	{
+		printf("\nMatrix::EigenVecVal >>> Memoria nao disponivel!\n");
+		return false;
+	}
+
+	if( aux2.Init( dim, (double)1 ) == false )
+	{
+		printf("\nMatrix::EigenVecVal >>> Memoria nao disponivel!\n");
+		return false;
+	}
+
+	e_vec_aux = new double[dim];
+
+	if( e_vec_aux == NULL )
+	{
+		printf("\nMatrix::EigenVecVal >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	for ( k = 0; k< dim; k++)
+	{
+		e_vec_aux[k] = 0.0;
+		e_vec[k] = 0.0;
+	}
+
+	aux1 = *this;
+	aux2 = *this;
+	
+	for (;;)
+	{
+		mt = aux1 * aux2;
+
+		for (i=0; i<dim; i++)
+		{
+			for (j=0; j<dim; j++)
+				 e_vec[i] = e_vec[i] + mt(i,j);
+			soma = soma + e_vec[i];
+		}
+
+		for (j=0; j<dim; j++)
+			e_vec[j] = e_vec[j] / soma;
+
+		for (j=0; j<dim; j++)
+		{
+			if ( fabs(e_vec_aux[j] - e_vec[j]) < 0.001 ) 
+			{
+				delete []e_vec_aux;	
+				return true;
+			}
+			e_vec_aux[j] = e_vec[j];
+		}
+
+		aux1 = mt;
+		aux2 = mt;
+	}
+
+}
+
+double TeMatrix::getTrace() const
+{
+  TEAGN_TRUE_OR_THROW( ( nrow == ncol ), 
+    "Cannot get trace from a non-square matrix" );
+    
+  double trace = 0.0;
+  
+  for( int curr_row = 0 ; curr_row < nrow ; ++curr_row ) {
+    trace += mat[ curr_row ][ curr_row ];
+  }
+  
+  return trace;
+}
+
+
+bool TeMatrix::getIdentity( TeMatrix& identity, unsigned int width )
+{
+  if( identity.Init( width, width, 0.0 ) == 0 ) return false;
+  
+  for( unsigned int curr_row = 0 ; curr_row < width ; ++curr_row ) {
+    identity( curr_row, curr_row ) = 1.0;
+  }
+  
+  return true;
+}
+
+//------------------------------------------ Print
+void
+TeMatrix::Print()
+{
+	//printf("\nMATRIZ ( %d, %d ) LIXO %f **mat %p\n", nrow,ncol, lixo, mat);
+	printf("\nMATRIZ ( %d, %d )\n\n", nrow,ncol);
+	if( mat == NULL ){
+		printf("\n>>> mat e NULL \n");
+		return;
+	}
+	int i,j;	
+	for(i = 0; i < nrow; i++){
+		for( j = 0; j < ncol;j++){
+			printf("%10.4f ",(float)mat[i][j]);
+		}
+		printf("\n\n");
+	}
+}
+
+// VRMC 12/98
+int
+TeMatrix::CholeskyDecomp( TeMatrix& mt )
+{
+
+	//--	Verify if the matrix is simetric
+	if ((*this).isSimetric() == false){
+		printf("\nMatrix::CholeskyDecomp >>> Matriz nao e simetrica!\n");
+		return false;
+	}
+	//--	Verify if the matrix is positive definide
+	if ((*this).isPositiveDefinide() == false){
+		printf("\nMatrix::CholeskyDecomp >>> Matriz nao e positiva definida!\n");
+		return false;
+	}
+	if( &mt == this ){
+		printf("\nMatrix::CholeskyDecomp >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+	if( mat[0][0] <= 0. ){
+		printf("\nMatrix::CholeskyDecomp >>> Posicao [0,0] e' nula\n");
+		return false;
+	}
+    if( mt.Init(nrow,ncol) == false ){
+		printf("\nMatrix::CholeskyDecomp>>>no memory \n");
+		return false;
+   	}
+	mt(0,0) = (double)sqrt((double)(*this)(0,0));
+
+	//---	Calculate the first column of the TeMatrix mt
+
+	int i,j,k;
+	for( i= 0; i < nrow; i++){
+		mt(i,0) = (*this)(i,0)/mt(0,0);
+	}
+	 
+	for( i= 1; i < nrow; i++){
+		for( j= 1; j <= i; j++){
+			//int m = (j*j - j)/2 + 1;
+			double rf = 0.;
+			//int k2 = j - 1;
+			//for( k = 0;k<=k2;k++)
+			for( k = 0;k < j;k++)
+				rf += mt(i,k) * mt(j,k);
+			if( i == j ){
+				rf = (*this)(i,j) - rf;
+				if( rf < 0. ){
+					printf("\nMatrix::CholeskyDecomp:ERRO \n");
+					return false;
+				}
+				mt(i,j) = (double)sqrt((double)rf);
+			}
+			else{
+				if( mt(j,j) == 0. ){
+					printf("\nMatrix::CholeskyDecomp:ERRO \n");
+					return false;
+				}
+				mt(i,j) = ((*this)(i,j)-rf)/mt (j,j );
+			}
+		}
+	}
+	return true;
+}
+
+
+//-------------------------------------------------Inverse(SITIM)
+//
+//---	Calcula a matriz inversa pelo metodo de Gauss-Jordan.
+//
+
+int
+TeMatrix::Inverse( TeMatrix& matinv ) const
+{
+
+	if( &matinv == this ){
+		printf("\nMatrix::Inverse >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+	if ( nrow != ncol ){
+       		printf("\nMatrix::Inverse: can't invert a non-square matrix");
+       		return false;
+   	 }
+
+	if( matinv.Init( this->nrow, (double)1 ) == false ){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+//---	Calculo da inversa se a matriz tem dimensao unitaria
+
+	if(nrow == 1){
+		if(mat[0][0] == 0.0) {
+		        printf("\noperator~: can't invert singular matrix");
+			return false;
+		}
+    		matinv(0,0) = 1. / mat[0][0];
+    		return true;
+	}
+  
+//---	Formacao da matriz aumentada mataum
+
+	int	m2   = 2 * nrow ;
+	TeMatrix	mataum;
+
+	if( mataum.Init( nrow , m2 ) == false ){
+	   printf("\nInverse:no memory");
+	   return false;
+       	}
+	
+	int i1,i2,i3;
+	for(i1 = 0 ; i1 < nrow ; i1++){
+		for( i2 = 0 ; i2 < ncol ; i2++)
+        		mataum(i1,i2) = mat[i1][i2];
+
+		for( i3 = nrow ; i3 < m2 ; i3++)
+        		mataum(i1,i3) = 0.0;
+
+		mataum( i1, i1 + nrow) = 1.0;
+	}
+
+//--	Inicializa ponteiro de linhas
+
+	double	*maxlinha = NULL;
+
+	if( ( maxlinha = new double[nrow] ) == NULL ){
+		printf("\nMatrix::Inverse>>no memory");
+		return false;
+	}
+
+	double	sup,lcon1,amul,pivo;
+	int	* lp = NULL;
+
+	if( (lp = new int[nrow]) == NULL ){
+		printf("\nMatrix::Inverse>>no memory");
+		if( maxlinha != NULL){delete []maxlinha; maxlinha = NULL;} //SSL0296
+		return false;
+	}
+
+	for(i1 = 0 ; i1 < nrow ; i1++)
+		lp[i1] = i1;
+
+	int	lcon = 0;
+	int	m1 = nrow - 1;
+
+	while(lcon < nrow){
+//---		Selecao do maior valor em cada linha . seu inverso e armazenado em maxlinha.
+		for(i1 = 0 ; i1 < nrow ; i1++){
+			sup = 0.0;
+			for(i2 = 0 ; i2 < nrow ; i2++){
+				lcon1 = (double)fabs(mataum(lp[i1],i2));
+				if((lcon1 - sup ) > 0.000001 )
+				sup = lcon1;
+			}
+			if(sup == 0.0){
+				if( maxlinha != NULL){ delete []maxlinha; maxlinha = NULL; } //SSL0296
+				if( lp != NULL){ delete []lp; lp = NULL; } //SSL0296
+				return false;
+			}
+			maxlinha[lp[i1]] = 1.0 / sup;
+		 }
+
+//---		Selecao do pivo em cada linha
+
+		int lpi;
+		double	supc = fabs((double)( mataum(lp[lcon],lcon) * maxlinha[lp[lcon]] ));
+		pivo = mataum(lp[lcon],lcon);
+		lpi  = lcon;
+		for(i1 = lcon ; i1 < nrow ; i1++){
+        		amul = mataum(lp[i1],lcon) * maxlinha[lp[i1]];
+			if (fabs(amul) > supc ){
+			supc = (fabs((double)amul));
+			pivo = mataum(lp[i1],lcon);
+			lpi  = i1;
+			}
+		}
+
+		if(pivo == 0.0){
+			if( maxlinha != NULL){ delete []maxlinha; maxlinha = NULL; } //SSL0296
+			if( lp != NULL){ delete []lp; lp = NULL; } //SSL0296
+			return false;
+		}
+     
+		/* troca de linhas */
+		i1 	 = lp[lcon];
+		lp[lcon] = lp[lpi];
+		lp[lpi]  = i1;
+	
+//---		Divide a linha pelo pivo
+		for(i2 = 0 ; i2 < m2 ; i2++){
+			mataum(lp[lcon],i2) = mataum(lp[lcon],i2) / pivo ;
+		}
+
+//---		Realiza subtracoes nas linhas de forma a zerar os elementos da coluna
+//---		dada pelo indice lcon
+
+		int	il = lcon;
+
+		for(i2 = 0; i2 < m1 ; i2++){
+	        	il = il + 1;
+			if(il >= nrow ) il = 0;
+			double	aux = - mataum(lp[il],lcon);
+			for(i3 = lcon; i3 < m2 ; i3++)
+				mataum(lp[il],i3) = mataum(lp[il],i3) + aux * mataum(lp[lcon],i3);
+
+			mataum(lp[il],lcon) = 0.0;
+		}
+
+		lcon = lcon + 1;
+	}
+
+//---	Copia a parte extendida de mataum em matinv que passa a ser a matriz inversa
+	for(i1 = 0 ; i1 < nrow ; i1++){
+		for(i2 = nrow ; i2 < m2 ; i2++)
+		{
+        		i3 = i2 - nrow ;
+			matinv(i1,i3) = mataum(lp[i1],i2);
+		}
+	}
+
+	if( maxlinha != NULL){
+		delete []maxlinha; //SSL0296
+		maxlinha = NULL;
+	}
+	if( lp != NULL){
+		delete []lp; //SSL0296
+		lp = NULL;
+	}
+
+	return true;
+}
+
+//	Esse mtodo, no esta correto 
+//------------------------------------------Inverse
+//	NIH library
+// 1. triangulate: *this = ~P*T
+// 2. when T isUpperTriangle ~T isUpperTriangle
+// 3. split: T = T.row(0) + subT
+// 4. I = ~T*T
+// 5. ~T.at(0,0) = 1/T.at(0,0)
+// 6. sub~T = ~(subT)
+// 7. ~T.row(0) = [1/T.at(0,0)]&B
+//    where T.at(0,0)*B = [t21 ... t2n]*~subT
+// 8. ~*this = ~T*P
+
+/*int 
+TeMatrix::InverseNIH( TeMatrix& mt ) const
+{
+	TeMatrix  r;
+	TeMatrix	_subT;
+	TeMatrix	B;
+	TeMatrix	val;
+
+	if ( nrow!=ncol || nrow <= 0 || ncol <= 0 ){
+		printf("\nMatrix::Inverse >>> Matriz nao inversivel!\n");
+		return false;
+	}
+
+	if( mt.Init( this->nrow, (double)1 ) == false ){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	if ( nrow==1 ){
+		if( mat[0][0] == (double)0 ){
+			printf("\nMatrix::Inverse >>> Matriz nao inversivel!\n");
+			return false;
+		}
+		mt.mat[0][0] = 1/mat[0][0];
+		return true;
+   	}
+	TeMatrix T(*this);
+	if( T.Initialized() == false ){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+		
+	// 1. triangulate: *this = ~P*T
+	TeMatrix P;
+	if( P.Init(nrow,ncol) == false){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+	if( T.UpperTriangle( P ) == false ){
+		printf("\nMatriz::Inverse >>> ERRO!\n");
+		return false;
+	}
+	if ( T.Determinant()==0 ) {
+		printf("\nMatrix::Inverse >>> can't invert singular matrix\n");
+		return false;
+	}      
+
+	// 2. when T isUpperTriangle ~T isUpperTriangle
+	// 3. split: T = T.row(0) + subT
+
+	if( r.Init(1,ncol-1,&(T.mat[0][1])) == false){
+		printf("\nMatrix::Inverse* >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	T.CoFactor(0,0,mt);
+	mt.Inverse(_subT);
+	if( _subT.Initialized()  == false){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+
+	B = (-(1/T.mat[0][0])*r*_subT);
+	if( B.Initialized() == false ){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	if( val.Init(nrow,ncol) == false){
+		printf("\nMatrix::Inverse >>> Memoria nao disponivel\n");
+		return false;
+	}
+
+	val.mat[0][0] = 1/T.mat[0][0];
+	int i;
+	for(i=1; i<ncol; i++) val.mat[0][i]=B.mat[0][i-1];
+	val.CoFactor(0,0,_subT);
+
+ 	mt = val*P; // P is now the row-reduction transformation
+
+	return true; 
+}
+*/
+
+// os mtodos switchRows e combineRows ficarao comentados 
+// pois s sao utilizados no calculo da matriz inversa NIH,
+// inversaNIH, que tambem foi comentado 
+/*void 
+TeMatrix::switchRows(int i,int j)
+{
+	double *tmp;
+
+	if( i < 0 || j < 0 || i >= nrow || j >= ncol ){
+		printf("\nMatrix::switchRows >>> Switching linhas invalidas\n");
+		return;
+	}
+	tmp    = mat[i];
+	mat[i] = mat[j];
+	mat[j] = tmp; 
+}
+
+void
+TeMatrix::combineRows(int i, double a, int j)
+{
+	if( i < 0 || j < 0 || i >= nrow || j >= ncol ){
+		printf("\nMatrix::combineRows >>> Combining linhas invalidas\n");
+		return;
+	}
+	int h;
+	for(h = 0; h < ncol; h++)
+	mat[i][h] += a * mat[j][h];
+}
+*/
+
+//--------Esse metodo nao esta correto e por isso ficar comentado VRMC
+//----------------------------------------------------
+/*int 
+TeMatrix::UpperTriangle( TeMatrix& mt )
+{
+	if( &mt == this ){
+		printf("\nMatrix::UpperTriangle >>> Operacao usa duas matrizes\n");
+		return false;
+	}
+	if( mt.Init(nrow,(double)1) == false){
+		printf("\nMatrix::UpperTriangle >>> Memoria nao disponivel\n");
+		return	false;
+	}	
+
+	if ( this->isUpperTriangle() )
+		return true;
+	
+	int j;
+	for(j = 0; j < ncol; j++) {
+		int b_row = nrow-1;  // 1st non-zero entry from bottom
+		int t_row = j;       // 1st zero entry from the top
+
+		//--- switch rows until all zeros are at
+		//--- the bottom of jTH column 
+
+		while ( b_row>=t_row ) { 
+			while ( b_row > j && mat[b_row][j] == 0. )
+				--b_row;
+			if ( b_row == j )
+				break; // bottom at diagonal
+			while ( b_row >= t_row && mat[t_row][j] != 0. )
+				++t_row;
+			if ( t_row == Nrow() )
+				break; // top at last row
+			if ( t_row > b_row )
+				break;
+			switchRows(b_row,t_row); 
+			mt.switchRows(b_row,t_row);
+		}
+
+		//--- now b_row is last non-zero entry from the top
+		//--- now t_row is first zero entry from the bottom
+		//--- combine until all entries below diagonal in jTH column = 0
+
+		if ( b_row <= j )
+			continue;
+			int i;
+		for( i = j+1; i<= b_row; i++) {
+			double f = -mat[i][j] / mat[j][j];
+			combineRows(i,f,j);
+			mt.combineRows(i,f,j);
+		}
+	}
+	return true;
+}
+*/
diff --git a/src/terralib/kernel/TeMatrix.h b/src/terralib/kernel/TeMatrix.h
new file mode 100644
index 0000000..12d1db0
--- /dev/null
+++ b/src/terralib/kernel/TeMatrix.h
@@ -0,0 +1,198 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeMatrix.h
+    \brief This file models the object matrix of type double
+*/
+#ifndef  __TERRALIB_INTERNAL_MATRIX_H
+#define  __TERRALIB_INTERNAL_MATRIX_H
+
+#include "TeDefines.h"
+#include <TeException.h>
+
+//! This class represents a matrix of elements of type double
+class TL_DLL TeMatrix
+{
+private:
+	int nrow;	// Number of rows
+	int ncol;	// Number of columns
+	double **mat;	// TeMatrix of double elements 
+	double lixo;	// Ancillary variable
+
+	//! Allocates memory to holds a matrix of l lines by c columns
+	short Alloc( int l, int c);
+
+public:
+	//! Normal constructor
+	TeMatrix();
+
+	//! Copy constructor
+	TeMatrix(const TeMatrix& );
+
+	//! Destructor
+	~TeMatrix();
+
+	//! Clear memory for matrix.
+	void Clear();
+
+	//! Checks if the matrix is initialized.
+	int Initialized(){ return ( nrow > 0 && ncol > 0 ) ? (true) : (false); }
+
+	//!	Initializes the matrix with a vector of values
+	int Init( int nrow = 1, int ncol = 1 , double* f=0);
+
+	//!	Initializes the matrix with the same value.
+	int Init( int nrow , int ncol , double f  );
+	
+	//! Diagonal matrix with different values.
+	int Init(int k, double* f);
+
+	//! Diagonal matrix with the same value
+	int Init(int k, double f); 
+
+  //! Acess element in position (lin,col)
+  const double& operator()( int lin, int col ) const {
+    if( ( lin >= 0 ) && ( lin < nrow ) && ( col >= 0 ) && 
+      ( col < ncol ) ) {
+      
+      return mat[lin][col];
+    } else {
+      throw TeException( UNKNOWN_ERROR_TYPE, 
+        "Trying to access an invalid matrix position" );
+            
+      return lixo;
+    }
+  }  
+      
+	//! Acess element in position (lin,col)
+	double& operator()( int lin, int col ){ 
+    if( ( lin >= 0 ) && ( lin < nrow ) && ( col >= 0 ) && 
+      ( col < ncol ) ) {
+      
+      return mat[lin][col];
+    } else {
+      throw TeException( UNKNOWN_ERROR_TYPE, 
+        "Trying to access an invalid matrix position" );
+            
+      return lixo;
+    }
+	}
+
+	//! Assign matrix values to another one using operator =
+	TeMatrix& operator=( const TeMatrix& m ); 
+
+	//! Compares two matrix using the operator ==
+	int 	operator==(const TeMatrix& m) const;
+
+	//! Operator *=
+	void 	operator*=(double);
+
+	//! Operator unary minus 
+	TeMatrix 	operator-();
+
+	//!	Returns the number of rows.
+	int	Nrow() const { return nrow; }
+ 	
+	//!	Returns the number of columns.
+	int	Ncol()	const { return ncol; } 
+
+	//!	Print the matrix elements .
+	void Print();
+
+	//!	Switches two rows "a" and "b".
+    void switchRows(int a ,int b);
+		
+	//! Combines two rows in according to row(i) += b*row(j)
+   void combineRows(int i,double b,int j);
+
+	//! 		Finds the transpose of a matrix.
+	int	Transpose( TeMatrix& mt ) const;
+	
+	//! 		Finds the inverse of a matrix, if any.
+	int	Inverse ( TeMatrix& mt ) const;
+
+	//!		Finds the inverse of a triangle matrix	acquired from Cholesky decomposition
+	int	CholeskyInv (TeMatrix&	mt) const;	
+		
+	//!	Calculates the inverse of a lowertriangle matrix aquired from the Cholesky decomposition of a simetric positive definide matrix.
+	int MatTransf( TeMatrix& mt );	
+
+//!	Checks if the matrix is an uppertriangle matrix.
+   	int isUpperTriangle() const;
+	
+//!	Checks if the matrix is an lowertriangle matrix.
+    int isLowerTriangle() const;	
+
+//!	Checks if the matrix is a simetric matrix
+	int	isSimetric()	const;		
+
+//!	Checks if the matrix is positive definide
+	int	isPositiveDefinide() const;
+
+//!	Calculates the cofactor value of a matrix.
+	int	CoFactor(int irow, int jcol, TeMatrix& m) const;
+
+//!	Calculates the determinant value.
+	double	Determinant() const;
+
+//	Extracts a triangle matrix from a simetric positive	definide one
+	int	CholeskyDecomp( TeMatrix& mt );	
+
+//!	Calculates the EigenVectors.
+	int	EigenVectors( TeMatrix& mt ) const;
+
+//!	Calculates the EigenValues.
+	int	EigenValues( TeMatrix& mt ) const;
+
+//!	Calculates the EigenVectors.
+	int EigenVec( double e_vec[] );
+	
+	/**
+	 * @brief	Matrix trace calcule (the sum of diagonal elements).
+	 * @return The matrix trace.
+	 */	
+	double getTrace() const;
+	
+	/**
+	 * @brief	Generate a identity matrix .
+	 * @param identity The generated identity matrix.
+	 * @param width The identity matrix width.
+	 * @return true if OK, false on errors.
+	 */
+	static bool getIdentity( TeMatrix& identity, unsigned int width );
+
+//!	Sums two matrices.
+	friend TL_DLL TeMatrix operator+(const TeMatrix& m1,const TeMatrix& m2);
+
+//!	Subtracts two matrices.
+	friend TL_DLL TeMatrix operator-(const TeMatrix&,const TeMatrix&);
+
+//!	Calculates the product of two matrices.
+	friend TL_DLL TeMatrix operator*(const TeMatrix&,const TeMatrix&);
+
+//!	Product of the matrix by a constant.
+	friend TL_DLL TeMatrix operator*(double c,const TeMatrix&);
+};
+
+
+#endif
+
diff --git a/src/terralib/kernel/TeMeasure.h b/src/terralib/kernel/TeMeasure.h
new file mode 100644
index 0000000..c9908da
--- /dev/null
+++ b/src/terralib/kernel/TeMeasure.h
@@ -0,0 +1,59 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeMeasure.h
+    \brief This file defines a class for handling a measure
+*/
+
+#ifndef  __TERRALIB_INTERNAL_MEASURE_H
+#define  __TERRALIB_INTERNAL_MEASURE_H
+
+//! A class for handling a measure
+/*!
+	Provide support and definition for a measured value for All application that 
+	require a field measure.
+	\sa TeSample, TeCountourLine
+*/
+
+#include "TeDefines.h"
+class TL_DLL TeMeasure 
+{
+public:
+
+	//! Constructor
+	TeMeasure( double value ) : value_( value ) {}
+
+	//! Destructor
+	~TeMeasure() {}
+
+	//! Return the value associated to the measure
+	double value()
+	{ return value_; }
+
+protected:
+	double value_;
+};
+
+
+//typedef TeComposite <TeMeasure> TeMeasureComposite;
+
+#endif
diff --git a/src/terralib/kernel/TeMetaModelCache.cpp b/src/terralib/kernel/TeMetaModelCache.cpp
new file mode 100644
index 0000000..04da12c
--- /dev/null
+++ b/src/terralib/kernel/TeMetaModelCache.cpp
@@ -0,0 +1,40 @@
+#include "TeMetaModelCache.h"
+
+void TeMetaModelCache::clear()
+{
+	TeViewMap::iterator viewIt;
+	for (viewIt = viewMap_.begin(); viewIt != viewMap_.end(); ++viewIt)
+	{
+		if(viewIt->second)
+			delete viewIt->second;
+	}
+
+	TeLayerMap::iterator layerIt;
+	for (layerIt = layerMap_.begin(); layerIt != layerMap_.end(); ++layerIt)
+	{
+		if (layerIt->second)
+			delete layerIt->second;
+	}
+
+	TeProjectMap::iterator projectIt;
+	for (projectIt = projectMap_.begin(); projectIt != projectMap_.end(); ++projectIt)
+	{
+		if (projectIt->second)
+			delete projectIt->second;
+	}
+
+	TeThemeMap::iterator invThemeIt;
+	for (invThemeIt = invalidThemeMap_.begin(); invThemeIt != invalidThemeMap_.end(); ++invThemeIt)
+	{
+		if (invThemeIt->second)
+			delete invThemeIt->second;
+	}
+
+	legendMap_.clear();
+	themeMap_.clear();
+	invalidThemeMap_.clear();
+	viewMap_.clear();
+	layerMap_.clear();
+	projectMap_.clear();
+}
+
diff --git a/src/terralib/kernel/TeMetaModelCache.h b/src/terralib/kernel/TeMetaModelCache.h
new file mode 100644
index 0000000..314a9e9
--- /dev/null
+++ b/src/terralib/kernel/TeMetaModelCache.h
@@ -0,0 +1,118 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeMetaModelCache.h
+    \brief This file contains structures and definitions about TerraLib database meta model.
+*/
+#ifndef  __TERRALIB_INTERNAL_METAMODELCACHE_H
+#define  __TERRALIB_INTERNAL_METAMODELCACHE_H
+
+#include "TeLayer.h"
+#include "TeAbstractTheme.h"
+#include "TeView.h"
+#include "TeProject.h"
+
+//! A class for storing TerraLib's metamodel objects (TeTheme, TeLayer, ...)
+/*!
+	An instance of this class keeps track of 
+	meta objects stored in a TerraLib Database.
+	This instance can be shared by all database connections.
+
+  \sa TeTheme, TeView, TeLayer, TeAttribute
+*/
+class TL_DLL TeMetaModelCache
+{
+	public: 
+
+
+        //! Empty constructor
+        TeMetaModelCache()
+		{}
+
+        //! Destructor
+        ~TeMetaModelCache()
+		{ clear(); }
+
+		//! Clears metadata
+		void clear();
+
+		//! Returns the  map of layers in the database
+		TeLayerMap&	layerMap () 
+		{ return layerMap_; }
+
+		//! Returns the  map of views in the database
+		TeViewMap&	viewMap () 
+		{ return viewMap_; }
+
+		//! Returns the  map of themes in the database
+		TeThemeMap&	themeMap () 
+		{ return themeMap_; }
+
+		//! Returns the  map of invalid themes in the database
+		TeThemeMap&	invalidThemeMap () 
+		{ return invalidThemeMap_; }
+
+		//! Returns the  map of projects in the database
+		TeProjectMap&  projectMap ()
+		{ return projectMap_; }
+
+		//! Returns the  map of legends in the database
+		TeLegendEntryMap& legendMap () 
+		{ return legendMap_; }
+
+		//! Returns the set of relations between tables
+		multiset<int>& relationMSet () 
+		{ return relationMSet_; }
+
+		map<int, map<string, string> >& mapThemeAlias()
+		{return mapThemeAlias_;}
+
+    private:
+
+        //! Copy constructor not allowed.
+        TeMetaModelCache(const TeMetaModelCache& rhs);
+
+		//! Assignment operator not allowed.
+        TeMetaModelCache& operator=(const TeMetaModelCache& rhs);
+
+	private:
+
+		TeLayerMap			layerMap_;			//!< layer map	  
+        TeViewMap			viewMap_;			//!< view map	  
+        TeThemeMap			themeMap_;			//!< theme map	
+		TeThemeMap			invalidThemeMap_;	//!< invalid theme map
+        TeLegendEntryMap	legendMap_;			//!< view map
+        TeProjectMap		projectMap_;		//!< project map
+        multiset<int>		relationMSet_;		//!< multiset of relations between tables
+		/*! \brief An associative container from theme identifier (int)
+		           to legend alias (map<string, string>). The theme alias
+                   is another container, where key is a string with a column name
+                   used in a group that maps to a legend alias (string value).
+		 */
+		map<int, map<string, string> > mapThemeAlias_;
+};
+
+
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeMultiContainer.h b/src/terralib/kernel/TeMultiContainer.h
new file mode 100644
index 0000000..c2a73c6
--- /dev/null
+++ b/src/terralib/kernel/TeMultiContainer.h
@@ -0,0 +1,625 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+/*! \file TeMultiContainer.h
+   \brief A container class to store multiple types os object copies.
+*/
+
+
+#ifndef TEMULTICONTAINER_H
+  #define TEMULTICONTAINER_H
+
+  #include "TeSharedPtr.h"
+  #include "TeMutex.h"
+  #include "TeAgnostic.h"
+  
+  #include <time.h>
+  
+  #include <vector>
+  #include <typeinfo>
+
+  /**
+    * @brief Multi-container node interface.
+    * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+    * @ingroup Utils
+    */    
+  template< typename TeMultiContainerKeyT >
+  class TeMCNodeInterface {
+    public :
+    
+      /**
+        * @brief Default Constructor.
+        */        
+      TeMCNodeInterface() {};
+      
+      /**
+        * @brief Default Destructor.
+        */        
+      virtual ~TeMCNodeInterface() {};
+      
+      /**
+        * @brief Copies the the current node instance by calling
+        * the operator= from the contained object instance.
+        * @return A pointer to the new node copy.
+        */            
+      virtual TeMCNodeInterface< TeMultiContainerKeyT >* clone() 
+        const = 0;
+        
+      /**
+        * @brief Get the internal object type info.
+        * @return The internal object type info.
+        */        
+      virtual const std::string& getObjTypeInfo() const = 0;
+      
+    private :
+    
+      /**
+        * @brief Alternative constructor.
+        */        
+      TeMCNodeInterface( 
+        const TeMCNodeInterface< TeMultiContainerKeyT >& ) {};    
+    
+      /**
+      * @brief operator= overload.
+      *
+      * @param ext_instance External instance reference.
+      * @return The external instance reference.
+      */
+      const TeMCNodeInterface< TeMultiContainerKeyT >& operator=( 
+        const TeMCNodeInterface< TeMultiContainerKeyT >& ) {};        
+  };
+
+
+  /**
+    * @brief Multi-container node class.
+    * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+    * @ingroup Utils
+    */       
+  template< typename ObjectT, typename TeMultiContainerKeyT >
+  class TeMCNode : public TeMCNodeInterface< TeMultiContainerKeyT > {
+    public :
+    
+      /**
+        * @brief Default Constructor.
+        */        
+      TeMCNode() 
+      {
+        obj_ptr_ = 0;
+      };
+      
+      /**
+        * @brief Default Destructor.
+        */        
+      ~TeMCNode()
+      {
+        if( obj_ptr_ ) {
+          delete obj_ptr_;
+        }
+      };
+      
+      /**
+        * @brief Copies the the current node instance by calling
+        * the operator= from the contained object instance.
+        * @return A pointer to the new node copy.
+        */              
+      TeMCNodeInterface< TeMultiContainerKeyT >* clone() const
+      {
+        TeMCNode< ObjectT, TeMultiContainerKeyT >* new_node_ptr =
+          new TeMCNode< ObjectT, TeMultiContainerKeyT >;
+          
+        if( obj_ptr_ ) {
+          new_node_ptr->obj_ptr_ = new ObjectT;
+          ( *( new_node_ptr->obj_ptr_ ) ) = ( *obj_ptr_ );
+          
+          new_node_ptr->obj_type_str_ = obj_type_str_;
+        }
+        
+        return new_node_ptr;
+      };
+      
+      /**
+        * @brief Set the internal object pointer.
+        * @param ptr Object pointer.
+        */        
+      void setObjPtr( ObjectT* ptr ) 
+      { 
+        TEAGN_DEBUG_CONDITION( ptr, "Invalid pointer" )
+        
+        if( obj_ptr_ ) {
+          delete obj_ptr_;
+        }      
+      
+        obj_ptr_ = ptr;
+        obj_type_str_ = std::string( typeid( *ptr ).name() );
+      };
+      
+      /**
+        * @brief Get the internal object pointer.
+        * @return The object pointer.
+        */        
+      ObjectT* getObjPtr() const
+      { 
+        return obj_ptr_; 
+      };
+      
+      /**
+        * @brief Get the internal object type info.
+        * @return The internal object type info.
+        */        
+      const std::string& getObjTypeInfo() const
+      { 
+        return obj_type_str_; 
+      };      
+      
+    protected :
+      
+      /**
+        * @brief The internal object pointer.
+        */
+      ObjectT* obj_ptr_;
+      
+      /**
+        * @brief The internal object type.
+        */
+      std::string obj_type_str_;      
+      
+  }; 
+
+ /**
+  * @brief A container class to store multiple types os object copies.
+  * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+  * @note This is a thread-safe class.
+  * @note Do not use this class with polymorphic types !!
+  * @ingroup Utils
+  */
+  template< typename TeMultiContainerKeyT >
+  class TeMultiContainer {
+  
+    public :
+    
+      /** @typedef TeSharedPtr< TeMultiContainer< TeMultiContainerKeyT > > pointer 
+          Type definition for a instance pointer */
+      typedef TeSharedPtr< TeMultiContainer< TeMultiContainerKeyT > > pointer;
+      
+      /** @typedef const TeSharedPtr< TeMultiContainer< TeMultiContainerKeyT > > const_pointer 
+          Type definition for a const instance pointer */
+      typedef const TeSharedPtr< TeMultiContainer< TeMultiContainerKeyT > > const_pointer;
+      
+      /**
+       * @brief Default Constructor
+       */
+      TeMultiContainer();
+      
+      /**
+       * @brief Alternative Constructor
+       * @param external External reference.
+       */
+      TeMultiContainer( 
+        const TeMultiContainer< TeMultiContainerKeyT >& external );      
+
+      /**
+       * @brief  Default Destructor
+       */
+      ~TeMultiContainer();
+                           
+      /**
+       * @brief Operator == overload.
+       *
+       * @param ext_instance External instance reference.
+       * @return true if this instance have the same internal
+       * update time that the external instance.
+       */
+      bool operator==( 
+        const TeMultiContainer< TeMultiContainerKeyT >& ext_instance ) const;
+      
+      /**
+       * @brief Operator != overload.
+       *
+       * @param ext_instance External instance reference.
+       * @return true if this instance don't have the same internal
+       * update time that the external instance.
+       */
+      bool operator!=( 
+        const TeMultiContainer< TeMultiContainerKeyT >& ext_instance ) const;
+      
+      /**
+       * @brief operator= overload.
+       *
+       * @param ext_instance External instance reference.
+       * @return The external instance reference.
+       */
+      const TeMultiContainer< TeMultiContainerKeyT >& operator=( 
+        const TeMultiContainer< TeMultiContainerKeyT >& ext_instance );
+      
+      /**
+       * @brief Clear all contents.
+       *
+       */
+      void clear();
+                         
+      /**
+       * @brief Store a object copy.
+       *
+       * @param obj_key Object key.
+       * @param obj_reference Object instance.
+       */                         
+      template< typename ObjectT >
+      void store( const TeMultiContainerKeyT& obj_key,
+                         const ObjectT& obj_reference );
+      
+      /**
+       * @brief Retrive a copy of a stored object.
+       *
+       * @param obj_key Object key.
+       * @param obj_reference Object instance.
+       * @return true if OK, false if the parameter was no found or error.
+       */      
+      template< typename ObjectT >
+      bool retrive( const TeMultiContainerKeyT& obj_key,
+        ObjectT& obj_reference ) const;
+        
+      /**
+       * @brief Retrive copies of all stored objects of a defined type.
+       *
+       * @param objs_vector A vector with copies of all found objects.
+       * @note An empty vector will be returned if no object was found.
+       */      
+      template< typename ObjectT >
+      void multiRetrive( std::vector< std::pair< TeMultiContainerKeyT, 
+        ObjectT > >& objs_vector ) const;        
+     
+      /** 
+       * @brief Checks if a object is stored.
+       * 
+       * @param obj_key Object key.
+       * @note The object type must be specified.
+       * @return true if OK, false if the object is not stored.
+       */
+      template< typename ObjectT >
+      bool isStored( const TeMultiContainerKeyT& obj_key ) const;
+      
+      /** 
+       * @brief Remove a stored object.
+       * 
+       * @param obj_key Object key.
+       */
+      void remove( const TeMultiContainerKeyT& obj_key );      
+      
+    protected :
+
+      /** @brief Internal container type definition. */
+      typedef typename std::map< TeMultiContainerKeyT,
+        TeMCNodeInterface< TeMultiContainerKeyT >* > IntContainerT;
+      
+      /** @brief The nodes container instance. */
+      IntContainerT container_instance_;    
+      
+      /**
+       * @brief The last update time.
+       */
+      time_t last_up_time_;
+      
+      /**
+       * @brief This instance locking mutex.
+       */    
+      mutable TeMutex lock_instance_;      
+
+      /**
+       * @brief Updates the internal last update time.
+       *
+       * @note Needed by comparison between two multi containers.
+       */
+      void update_time();            
+
+};
+
+
+template< typename TeMultiContainerKeyT >
+TeMultiContainer< TeMultiContainerKeyT >::TeMultiContainer()
+{
+  last_up_time_ = 0;
+}
+
+
+template< typename TeMultiContainerKeyT >
+TeMultiContainer< TeMultiContainerKeyT >::TeMultiContainer( 
+  const TeMultiContainer< TeMultiContainerKeyT >& external )
+{
+  last_up_time_ = 0;
+  
+  operator=( external );
+}
+
+
+template< typename TeMultiContainerKeyT >
+TeMultiContainer< TeMultiContainerKeyT >::~TeMultiContainer()
+{
+  clear();
+}
+
+
+template< typename TeMultiContainerKeyT >
+void TeMultiContainer< TeMultiContainerKeyT >::clear()
+{
+  lock_instance_.lock();
+  
+  typename IntContainerT::iterator it = container_instance_.begin();
+  typename IntContainerT::iterator it_end = container_instance_.end();
+  
+  while( it != it_end ) {
+    delete (it->second);
+    
+    ++it;
+  }
+  
+  container_instance_.clear();
+  
+  lock_instance_.unLock();
+}
+
+
+template< typename TeMultiContainerKeyT >
+bool TeMultiContainer< TeMultiContainerKeyT >::operator==( 
+  const TeMultiContainer< TeMultiContainerKeyT >& ext_instance ) const
+{
+  if( last_up_time_ == ext_instance.last_up_time_ ) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+
+template< typename TeMultiContainerKeyT >
+bool TeMultiContainer< TeMultiContainerKeyT >::operator!=( 
+  const TeMultiContainer< TeMultiContainerKeyT >& ext_instance ) 
+  const
+{
+  if( last_up_time_ == ext_instance.last_up_time_ ) {
+    return false;
+  } else {
+    return true;
+  }
+}
+
+
+template< typename TeMultiContainerKeyT >
+const TeMultiContainer< TeMultiContainerKeyT >& 
+TeMultiContainer< TeMultiContainerKeyT >::operator=( 
+  const TeMultiContainer< TeMultiContainerKeyT >& ext_instance )
+{
+  if( ( &ext_instance ) != this ) {
+    lock_instance_.lock();
+    
+    /* Clearing the current objects */
+    
+    typename IntContainerT::iterator my_container_it = 
+      container_instance_.begin();
+    typename IntContainerT::iterator my_container_it_end = 
+      container_instance_.end();
+    
+    while( my_container_it != my_container_it_end ) {
+      delete (my_container_it->second);
+      
+      ++my_container_it;
+    }    
+    
+    container_instance_.clear();
+    
+    /* Cloning external objects */
+    
+    ext_instance.lock_instance_.lock();
+  
+    typename IntContainerT::const_iterator container_it = 
+      ext_instance.container_instance_.begin();
+    typename IntContainerT::const_iterator container_it_end = 
+      ext_instance.container_instance_.end();
+          
+    while( container_it != container_it_end ) {
+      container_instance_[ container_it->first ] = 
+        container_it->second->clone();
+          
+      ++container_it;
+    }
+  
+    last_up_time_ = ext_instance.last_up_time_;
+  
+    ext_instance.lock_instance_.unLock();
+    
+    lock_instance_.unLock();
+  }
+
+  return *this;
+}
+
+
+template< typename TeMultiContainerKeyT >
+void TeMultiContainer< TeMultiContainerKeyT >::update_time()
+{
+  last_up_time_ = time( 0 );
+}
+
+
+template< typename TeMultiContainerKeyT >
+template< typename ObjectT >
+void TeMultiContainer< TeMultiContainerKeyT >::store( 
+  const TeMultiContainerKeyT& obj_key, const ObjectT& obj_reference )
+{
+  lock_instance_.lock();
+
+  /* Creating a new node */
+  
+  ObjectT* newobjptr = new ObjectT;
+  ( *newobjptr ) = obj_reference;
+  
+  TeMCNode< ObjectT, TeMultiContainerKeyT >* newnodeptr =
+    new TeMCNode< ObjectT, TeMultiContainerKeyT >;  
+  newnodeptr->setObjPtr( newobjptr );
+  
+  typename IntContainerT::iterator container_it = 
+    container_instance_.find( obj_key );
+    
+  /* If a old node with the same key exists, it will be deleted */
+    
+  if( container_it == container_instance_.end() ) {
+    container_instance_[ obj_key ] = newnodeptr;
+  } else {
+    delete (container_it->second);
+    
+    container_it->second = newnodeptr;
+  }
+      
+  update_time();
+  
+  lock_instance_.unLock();
+}
+
+
+template< typename TeMultiContainerKeyT >
+template< typename ObjectT >
+bool TeMultiContainer< TeMultiContainerKeyT >::retrive(
+  const TeMultiContainerKeyT& obj_key, ObjectT& obj_reference ) const
+{
+  lock_instance_.lock();
+  
+  typename IntContainerT::const_iterator container_it = 
+    container_instance_.find( obj_key );
+    
+  if( container_it == container_instance_.end() ) {
+    lock_instance_.unLock();
+    
+    return false;
+  } else {
+    if( typeid( ObjectT ).name() == 
+      container_it->second->getObjTypeInfo() ) {
+      
+      obj_reference = 
+        ( *( ( (TeMCNode< ObjectT, TeMultiContainerKeyT >* )
+        container_it->second )->getObjPtr() ) );
+    
+      lock_instance_.unLock();
+    
+      return true;
+    } else {
+      lock_instance_.unLock();
+    
+      return false;
+    }
+  }
+}
+
+
+template< typename TeMultiContainerKeyT >
+template< typename ObjectT >
+void TeMultiContainer< TeMultiContainerKeyT >::multiRetrive(
+  std::vector< std::pair< TeMultiContainerKeyT, 
+  ObjectT > >& objs_vector ) const
+{
+  objs_vector.clear();
+  
+  lock_instance_.lock();
+  
+  typename IntContainerT::const_iterator container_it = 
+    container_instance_.begin();
+  typename IntContainerT::const_iterator container_it_end = 
+    container_instance_.end();
+  
+  std::pair< TeMultiContainerKeyT, ObjectT > temp_pair;
+  
+  while( container_it != container_it_end ) {
+    if( typeid( ObjectT ).name() == 
+      container_it->second->getObjTypeInfo() ) {  
+      
+      temp_pair.first = container_it->first;
+      temp_pair.second = 
+        ( *( ( ( TeMCNode< ObjectT, TeMultiContainerKeyT >* )
+        container_it->second )->getObjPtr() ) );
+    
+      objs_vector.push_back( temp_pair );      
+    }  
+  
+    ++container_it;
+  }
+  
+  lock_instance_.unLock();
+}
+
+
+template< typename TeMultiContainerKeyT >
+template< typename ObjectT >
+bool TeMultiContainer< TeMultiContainerKeyT >::isStored( 
+  const TeMultiContainerKeyT& obj_key ) const
+{
+  lock_instance_.lock();
+  
+  typename IntContainerT::const_iterator container_it = 
+    container_instance_.find( obj_key );
+    
+  if( container_it == container_instance_.end() ) {
+    lock_instance_.unLock();
+    
+    return false;
+  } else {
+    if( typeid( ObjectT ).name() == 
+      container_it->second->getObjTypeInfo() ) {
+    
+      lock_instance_.unLock();
+    
+      return true;
+    } else {
+      lock_instance_.unLock();
+    
+      return false;
+    }
+  }
+}
+
+
+template< typename TeMultiContainerKeyT >
+void TeMultiContainer< TeMultiContainerKeyT >::remove( 
+  const TeMultiContainerKeyT& obj_key )
+{
+  lock_instance_.lock();
+  
+  typename IntContainerT::iterator container_it = 
+    container_instance_.find( obj_key );
+    
+  /* If a old node with the same key exists, it will be deleted */
+    
+  if( container_it != container_instance_.end() ) {
+    delete (container_it->second);
+    
+    container_instance_.erase( container_it );
+  }
+      
+  update_time();
+  
+  lock_instance_.unLock();
+}
+
+/** @example TeMultiContainer_test.cpp
+ *    Shows how to use this class.
+ */  
+
+#endif
+
diff --git a/src/terralib/kernel/TeMultiGeometry.cpp b/src/terralib/kernel/TeMultiGeometry.cpp
new file mode 100644
index 0000000..828c131
--- /dev/null
+++ b/src/terralib/kernel/TeMultiGeometry.cpp
@@ -0,0 +1,267 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeMultiGeometry.h"
+
+
+TeMultiGeometry::TeMultiGeometry(const TeMultiGeometry& other)
+{
+	polygons_.copyElements(other.polygons_);
+	lines_.copyElements(other.lines_);
+	points_.copyElements(other.points_);
+	cells_.copyElements(other.cells_);
+	texts_.copyElements(other.texts_); 
+}
+
+TeMultiGeometry& 	
+TeMultiGeometry::operator= (const TeMultiGeometry& other)
+{
+	if ( this != &other )
+	{
+		polygons_.copyElements(other.polygons_);
+		lines_.copyElements(other.lines_);
+		points_.copyElements(other.points_);
+		cells_.copyElements(other.cells_);
+		texts_.copyElements(other.texts_); 
+	}
+	return *this;
+}
+	
+	
+bool 
+TeMultiGeometry::getGeometry(TePolygonSet& result) const
+{
+	if(!hasPolygons())
+		return false;
+	result.copyElements(polygons_);
+	return true;
+}
+
+
+bool 
+TeMultiGeometry::getGeometry(TeLineSet& result) const
+{
+	if(!hasLines())
+		return false;
+	result.copyElements(lines_);
+	return true;
+}
+	
+bool 
+TeMultiGeometry::getGeometry(TePointSet& result) const
+{
+	if(!hasPoints())
+		return false;
+	result.copyElements(points_);
+	return true;
+}
+	
+bool 
+TeMultiGeometry::getGeometry(TeCellSet& result) const
+{
+	if(!hasCells())
+		return false;
+	result.copyElements(cells_);
+	return true;
+}
+
+bool 
+TeMultiGeometry::getGeometry(TeTextSet& result) const
+{
+	if(!hasTexts())
+		return false;
+	result.copyElements(texts_);
+	return true;
+}
+	
+bool 
+TeMultiGeometry::getGeometry(vector<TeGeometry*>& result)  
+{
+	bool status = false;
+	if(hasPolygons())
+	{
+		for(int i=0; i< (int)polygons_.size(); ++i)
+		{
+			TePolygon* pol = new TePolygon();
+			(*pol) = polygons_[i];
+			result.push_back (pol);
+			status = true;
+		}
+	}
+	if(hasLines())
+	{
+		for(int i=0; i< (int)lines_.size(); ++i)
+		{
+			TeLine2D* lin = new TeLine2D();
+			(*lin) = lines_[i];
+			result.push_back (lin);
+			status = true;
+		}
+	}
+	if(hasPoints())
+	{
+		for(int i=0; i< (int)points_.size(); ++i)
+		{
+			TePoint* pon = new TePoint();
+			(*pon) = points_[i];
+			result.push_back (pon);
+			status = true;
+		}
+	}
+	if(hasCells())
+	{
+		for(int i=0; i< (int)cells_.size(); ++i)
+		{
+			TeCell* cell = new TeCell();
+			(*cell) = cells_[i];
+			result.push_back (cell);
+			status = true;
+		}
+	}
+	return status;
+}
+
+void 
+TeMultiGeometry::setGeometry(const TePolygonSet& result) 
+{ 
+	polygons_ = result;
+}
+	
+void 
+TeMultiGeometry::setGeometry(const TeLineSet& result)     
+{ 
+	lines_ = result; 
+}
+	
+void 
+TeMultiGeometry::setGeometry(const TePointSet& result)	
+{ 
+	points_ = result; 
+}
+	
+void 
+TeMultiGeometry::setGeometry(const TeCellSet& result)		
+{ 
+	cells_ = result; 
+}
+	
+void 
+TeMultiGeometry::setGeometry(const TeTextSet& result)		
+{ 
+	texts_ = result; 
+}
+
+void 
+TeMultiGeometry::setGeometry(vector<TeGeometry*>& result)
+{
+	this->clear();
+	vector<TeGeometry*>::iterator it = result.begin();
+	
+	while(it!=result.end())
+	{
+		TeGeometry* geom = (*it);
+		
+		if(dynamic_cast<TePolygon*> (geom))
+			polygons_.add (*((TePolygon*)geom));
+		else if (dynamic_cast<TePolygonSet*> (geom))
+			polygons_ = *((TePolygonSet*) geom);
+		else if(dynamic_cast<TeLine2D*> (geom))
+			lines_.add (*((TeLine2D*)geom));
+		else if(dynamic_cast<TeLineSet*> (geom))
+			lines_ = *((TeLineSet*)geom);
+		else if(dynamic_cast<TePoint*> (geom))
+			points_.add (*((TePoint*)geom));
+		else if(dynamic_cast<TePointSet*> (geom))
+			points_ = *((TePointSet*)geom);
+		else if(dynamic_cast<TeCell*> (geom))
+			cells_.add (*((TeCell*)geom));
+		else if(dynamic_cast<TeCellSet*> (geom))
+			cells_ = *((TeCellSet*)geom);
+		else if(dynamic_cast<TeText*> (geom))
+			texts_.add (*((TeText*)geom));
+		++it;
+	}
+}
+	
+void 
+TeMultiGeometry::addGeometry(const TePolygon& poly)  
+{ 
+	polygons_.add(poly); 
+	polygons_.objectId(poly.objectId()); 
+}
+	
+void 
+TeMultiGeometry::addGeometry(const TeLine2D& line)     
+{ 
+	lines_.add(line); 
+	lines_.objectId(line.objectId()); 
+}
+	
+void 
+TeMultiGeometry::addGeometry(const TePoint& point)	
+{ 
+	points_.add(point); 
+	points_.objectId(point.objectId()); 
+} 
+	
+void 
+TeMultiGeometry::addGeometry(const TeCell& cell)		
+{ 
+	cells_.add(cell); 
+	cells_.objectId(cell.objectId()); 
+}
+
+void 
+TeMultiGeometry::addGeometry(const TeText& text)		
+{ 
+	texts_.add(text); 
+	texts_.objectId(text.objectId()); 
+}
+
+void 
+TeMultiGeometry::clear()
+{
+	polygons_.clear ();
+	lines_.clear ();
+	points_.clear ();
+	cells_.clear ();
+	texts_.clear();
+}
+
+TeBox 
+TeMultiGeometry::getBox()
+{
+	TeBox box;
+	if (hasPolygons())
+		updateBox(box,polygons_.box());
+	if (hasLines())
+		updateBox(box,lines_.box());
+	if (hasPoints())
+		updateBox(box,points_.box());
+	if (hasCells())
+		updateBox(box,cells_.box());
+	if (hasTexts())
+		updateBox(box,texts_.box());
+	return box;
+}
+
diff --git a/src/terralib/kernel/TeMultiGeometry.h b/src/terralib/kernel/TeMultiGeometry.h
new file mode 100644
index 0000000..322bf86
--- /dev/null
+++ b/src/terralib/kernel/TeMultiGeometry.h
@@ -0,0 +1,161 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeMultiGeometry.h
+    \brief This file contains structures and definitions to deal with a multigeometry. 
+*/
+
+#ifndef  __TERRALIB_MULTIGEOMETRY_H
+#define  __TERRALIB_MULTIGEOMETRY_H
+
+#include "TeGeometry.h"
+
+
+class TL_DLL TeMultiGeometry
+{
+
+public:
+	TePolygonSet		polygons_;
+	TeLineSet			lines_;
+	TePointSet			points_;
+	TeCellSet			cells_;
+	TeTextSet			texts_;
+	
+	//! Constructor
+	TeMultiGeometry() {};
+
+	//! Copy constructor
+	TeMultiGeometry(const TeMultiGeometry& other);
+	
+	//! Assignment operator
+	TeMultiGeometry& operator= (const TeMultiGeometry& other);
+	
+	//! Get a copy of polygon geometries. Return true if the geometries exit.  
+	bool getGeometry(TePolygonSet& result) const; 
+	
+	//! Get a copy of line geometries. Return true if the geometries exit.  
+	bool getGeometry(TeLineSet& result) const;
+	
+	//! Get a copy of point geometries. Return true if the geometries exit.  
+	bool getGeometry(TePointSet& result) const;
+	
+	//! Get a copy of cell geometries. Return true if the geometries exit.  
+	bool getGeometry(TeCellSet& result) const;
+
+	//! Get a copy of text geometries. Return true if the geometries exit.  
+	bool getGeometry(TeTextSet& result) const;
+	
+	//! Get a reference to the polygon geometry container  
+	TePolygonSet&  getPolygons() 
+	{	return polygons_; }
+	
+	//! Get a reference to the line geometry container  
+	TeLineSet&  getLines() 
+	{	return lines_; }
+
+	//! Get a reference to the point geometry container  
+	TePointSet&  getPoints() 
+	{	return points_; }
+
+	//! Get a reference to the cell geometry container  
+	TeCellSet&  getCells() 
+	{	return cells_; }
+
+	//! Get a reference to the text geometry container  
+	TeTextSet&  getTexts() 
+	{	return texts_; }
+
+	//! Get all geometries. Return true if the geometries exit.  
+	bool getGeometry(vector<TeGeometry*>& result);
+
+	//! Set polygon geometries
+	void setGeometry(const TePolygonSet& result);
+	
+	//! Set line geometries
+	void setGeometry(const TeLineSet& result);
+	
+	//! Set point geometries
+	void setGeometry(const TePointSet& result);
+	
+	//! Set cell geometries
+	void setGeometry(const TeCellSet& result);
+	
+	//! Set text geometries
+	void setGeometry(const TeTextSet& result); 
+	
+	//! Set all geometries
+	void setGeometry(vector<TeGeometry*>& result); 
+
+	//! Add polygon geometry 
+	void addGeometry(const TePolygon& poly); 
+	
+	//! Add line geometry
+	void addGeometry(const TeLine2D& line); 
+	
+	//! Add point geometry
+	void addGeometry(const TePoint& point); 
+	
+	//! Add cell geometry
+	void addGeometry(const TeCell& cell); 
+
+	//! Add cell geometry
+	void addGeometry(const TeText& text); 
+
+	//! Return true if this has polygons 
+	bool hasPolygons()	const
+	{ return (!polygons_.empty()); } 
+	
+	//! Return true if this has lines 
+	bool hasLines() const		
+	{ return (!lines_.empty()); } 
+	
+	//! Return true if this has points 
+	bool hasPoints() const		
+	{ return (!points_.empty()); } 
+	
+	//! Return true if this has cells 
+	bool hasCells()	const
+	{ return (!cells_.empty()); } 
+	
+	//! Return true if this has cells 
+	bool hasTexts()	const	
+	{ return (!texts_.empty()); } 
+	
+	//! Return true if there are not any geometry  
+	bool empty()  
+	{ 
+		return ( polygons_.empty() &&  lines_.empty() &&
+				 points_.empty()   &&  cells_.empty() &&  texts_.empty());
+	}
+
+	//! Clear geometries
+	void clear();
+
+	//! Get the total extension of the multi-geometry
+	TeBox getBox();
+
+	//! Get the total extension of the multi-geometry
+	TeBox box()
+	{ return this->getBox(); } 
+};
+
+#endif 
diff --git a/src/terralib/kernel/TeMutex.cpp b/src/terralib/kernel/TeMutex.cpp
new file mode 100644
index 0000000..925343b
--- /dev/null
+++ b/src/terralib/kernel/TeMutex.cpp
@@ -0,0 +1,59 @@
+#include "TeMutex.h"
+
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+
+  #include  <stdio.h>
+
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    
+#else
+    #error "Unsuported plataform"
+#endif   
+
+TeMutex::TeMutex()
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+    m_sa_.nLength = sizeof( m_sa_ );
+    m_sa_.lpSecurityDescriptor = NULL;
+    m_sa_.bInheritHandle = TRUE;
+
+    m_access_ = ::CreateMutex( &m_sa_, false, 0 );
+
+    TEAGN_TRUE_OR_THROW( ( m_access_ != 0 ),
+      "Unable to create mutex object instance" )
+  
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  
+    pthread_mutexattr_t access_attr;
+    TEAGN_TRUE_OR_THROW( ( pthread_mutexattr_init( &access_attr ) == 0 ),
+      "Unable to init mutex attributes" );
+
+    pthread_mutexattr_settype( &access_attr, PTHREAD_MUTEX_DEFAULT );
+    TEAGN_TRUE_OR_THROW( 
+      ( pthread_mutex_init( &m_access_, &access_attr ) == 0 ),
+      "Unable to init mutex" )
+  
+  #else
+    #error "Unsuported plataform"
+  #endif   
+}
+
+
+TeMutex::~TeMutex()
+{
+  unLock();
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+    ::CloseHandle( m_access_ );
+  
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  
+    pthread_mutex_destroy( &m_access_ );
+  
+  #else
+    #error "Unsuported plataform"
+  #endif   
+}
+
diff --git a/src/terralib/kernel/TeMutex.h b/src/terralib/kernel/TeMutex.h
new file mode 100644
index 0000000..1dd1256
--- /dev/null
+++ b/src/terralib/kernel/TeMutex.h
@@ -0,0 +1,179 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeMutex.h
+  \brief This file contains definitions about a class to deal with critical 
+  region locking.
+*/
+
+
+#ifndef TEMUTEX_H
+  #define TEMUTEX_H
+  
+  #include "TeAgnostic.h"
+  #include "TeDefines.h"
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    #include <windows.h>
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    #include <pthread.h>
+    #include <errno.h>
+  #else
+    #error "ERROR: Unsupported platform"
+  #endif  
+ 
+  /**
+   * @brief A class to deal with critical region locking.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   */
+  class TL_DLL TeMutex
+  {
+    public :
+    
+      /**
+       * @brief Default constructor.
+       */    
+      TeMutex();
+
+      /**
+       * @brief Default destructor.
+       */       
+      ~TeMutex();
+      
+      /**
+       * @brief Lock the current object instance.
+       * @note If section is already busy then the current thread will be 
+       * blocked until it's ready again.
+       */       
+      inline void lock()
+      {
+        #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+        
+          DWORD return_value = 0;
+          return_value = ::WaitForSingleObject( m_access_, INFINITE );
+          TEAGN_DEBUG_CONDITION( ( ( return_value == WAIT_ABANDONED ) ||
+            ( return_value == WAIT_OBJECT_0 ) ),
+            "Unable to get mutex lock" );
+        
+        #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+        
+          pthread_mutex_lock( &m_access_ );
+        
+        #else
+          #error "Unsuported plataform"
+        #endif  
+      };      
+      
+      /**
+       * @brief Try to lock the current object instance.
+       * @return true if OK, false if unable to lock.
+       * @note If section is busy, this method will return false 
+       * without blocking the current thread.
+       */       
+      inline bool tryLock()
+      {
+        #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+        
+          DWORD return_value = ::WaitForSingleObject( m_access_, 
+            10 );
+
+          if( ( return_value == WAIT_OBJECT_0 ) ||
+            ( return_value == WAIT_ABANDONED ) ) {
+
+            return true;
+          } else {
+            return false;
+          }
+        
+        #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+        
+          if( pthread_mutex_trylock( &m_access_ ) == EBUSY ) {
+            return false;
+          } else {
+            return true;
+          }
+        
+        #else
+          #error "Unsuported plataform"
+        #endif  
+      };      
+      
+      /**
+       * @brief Unlock the current object instance.
+       */       
+      inline void unLock()
+      {
+        #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+        
+          ::ReleaseMutex( m_access_ );
+        
+        #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+        
+          pthread_mutex_unlock( &m_access_ );
+        
+        #else
+          #error "Unsuported plataform"
+        #endif 
+      };      
+            
+    protected :
+   
+      #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    
+        /**
+        * @brief The mutex instance.
+        */      
+        HANDLE m_access_;
+        
+        /**
+        * @brief The mutex instance attributes.
+        */           
+        SECURITY_ATTRIBUTES m_sa_;
+      
+      #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+      
+        /**
+        * @brief The mutex instance.
+        */        
+        pthread_mutex_t m_access_;
+      
+      #else
+        #error "Unsuported plataform"
+      #endif   
+   
+    private :
+    
+      /**
+       * Alternative constructor.
+       */    
+      TeMutex(  const TeMutex& ) {};
+    
+   
+      /**
+       * operator= overload.
+       * @return A const reference to the current instance.
+       */      
+      const TeMutex& operator=( const TeMutex& ) { return *this; };
+ 
+  };
+
+#endif
diff --git a/src/terralib/kernel/TeNeighbours.cpp b/src/terralib/kernel/TeNeighbours.cpp
new file mode 100644
index 0000000..49b836e
--- /dev/null
+++ b/src/terralib/kernel/TeNeighbours.cpp
@@ -0,0 +1,221 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeNeighbours.h"
+
+TeProxMatrixAttributes::TeProxMatrixAttributes() 
+{
+	_weight = 1;					//default
+	_slice	= 1;					//default
+	_order  = 1;					//defaul
+	_centroid_distance	= -1.0;		//not computed
+	_borders_length		= -1.0;		//not computed
+	_net_objects_distance		= -1.0;   //not computed
+	_net_minimum_path= -1.0;		//not computed
+}  
+
+
+TeProxMatrixAttributes::TeProxMatrixAttributes (const TeProxMatrixAttributes& att) 
+{		
+	_weight = att._weight;
+	_slice = att._slice; 
+	_order = att._order; 
+	_centroid_distance = att._centroid_distance;
+	_borders_length = att._borders_length; 
+	_net_objects_distance = att._net_objects_distance;
+	_net_minimum_path = att._net_minimum_path;
+}
+
+
+TePropertyVector 
+TeProxMatrixAttributes::getProperties ()
+{
+	TePropertyVector vec;
+	TeProperty prop1; prop1.value_ = Te2String (_weight); vec.push_back ( prop1 );
+	TeProperty prop2; prop2.value_ = Te2String (_slice); vec.push_back ( prop2 );
+	TeProperty prop3; prop3.value_ = Te2String (_order); vec.push_back ( prop3 );
+	TeProperty prop4; prop4.value_ = Te2String (_borders_length); vec.push_back ( prop4 );
+	TeProperty prop5; prop5.value_ = Te2String (_centroid_distance); vec.push_back ( prop5 );	
+	TeProperty prop6; prop6.value_ = Te2String (_net_objects_distance); vec.push_back ( prop6 );	
+	TeProperty prop7; prop7.value_ = Te2String (_net_minimum_path); vec.push_back ( prop7 );
+	return vec; 
+}
+
+
+TeProxMatrixAttributes& 
+TeProxMatrixAttributes::operator= (const TeProxMatrixAttributes& att)
+{		
+	_weight = att._weight;
+	_slice = att._slice; 
+	_order = att._order; 
+	_centroid_distance = att._centroid_distance;
+	_borders_length = att._borders_length; 
+	_net_objects_distance = att._net_objects_distance;
+	_net_minimum_path = att._net_minimum_path;
+	return *this;
+}
+
+
+
+bool 
+TeProxMatrixAttributes::operator==(const TeProxMatrixAttributes& att) const
+{
+	return ((_weight == att._weight) && 
+		(_slice == att._slice) && 
+		(_order == att._order) && 
+		(_centroid_distance == att._centroid_distance) && 
+		(_borders_length == att._borders_length) &&  
+		(_net_objects_distance == att._net_objects_distance) && 
+		(_net_minimum_path == att._net_minimum_path));
+}
+
+
+TeNeighbours::TeNeighbours(const TeNeighboursMap& neigh)  
+{
+
+	TeNeighboursMap::const_iterator pos = neigh.begin(); 
+
+	for (pos = neigh.begin(); pos != neigh.end(); ++pos)
+		_neigh.push_back(make_pair (pos->first, pos->second));
+}
+
+
+
+TeNeighbours::TeNeighbours (const TeNeighbours& neigh)
+{
+	const_iterator it;
+	for (it = neigh._neigh.begin(); it != neigh._neigh.end(); ++it) 
+		_neigh.push_back(*it);
+}
+
+		
+string
+TeNeighbours::ObjectId (int n) 
+{
+	if (n < (int)_neigh.size()) 
+		return _neigh[n].first;
+
+	else {
+		string empty;
+		return empty;
+	}
+}
+
+
+string 
+TeNeighbours:: operator[](int n)
+{
+	if (n < (int)_neigh.size()) 
+		return _neigh[n].first;
+
+	else {
+		string empty;
+		return empty;
+	}
+}
+
+double 
+TeNeighbours:: Weight (int n)
+{
+	if (n < (int)_neigh.size()) 
+		return _neigh[n].second.Weight();
+
+	else
+		return 0.0;
+}		
+
+	
+double 
+TeNeighbours:: Weight (const string& object_id)
+{
+	for (unsigned int i = 0; i< _neigh.size(); ++i) {
+		if (object_id == _neigh[i].first) 
+			return _neigh[i].second.Weight();
+	}
+	return 0.0;
+}		
+
+	
+TeProxMatrixAttributes 
+TeNeighbours:: Attributes (int n)
+{
+	TeProxMatrixAttributes attr;
+
+	if (n < (int)_neigh.size()) 
+		return _neigh[n].second;
+	else
+		return attr;
+}
+	
+bool
+TeNeighbours:: operator== (const TeNeighbours& neigh)
+{
+	if (_neigh == neigh._neigh) return true;
+	else return false;
+}
+
+
+TeNeighbours& 
+TeNeighbours::operator= (const TeNeighbours& neigh)
+{
+	if (*this == neigh)
+	    return *this;
+
+	_neigh.clear();
+
+	const_iterator it;
+	for (it = neigh._neigh.begin(); it != neigh._neigh.end(); ++it) 
+		_neigh.push_back(*it);
+ 
+    return *this; 
+}
+
+
+bool
+TeNeighbours:: Insert (const string& object_id, const TeProxMatrixAttributes& attr)
+{
+	for (unsigned int i = 0; i< _neigh.size(); i++) {
+		if (object_id == _neigh[i].first) 
+			return false;
+	}
+	_neigh.push_back (make_pair (object_id, attr));
+	return true;
+}
+
+
+bool 
+TeNeighbours:: Remove (const string& object_id)
+{
+	iterator it = _neigh.begin();
+	while (it!= _neigh.end()) 
+		if (object_id == (*it).first)
+		{
+			_neigh.erase (it);
+			return true;
+		}
+	return false;
+}
diff --git a/src/terralib/kernel/TeNeighbours.h b/src/terralib/kernel/TeNeighbours.h
new file mode 100644
index 0000000..9d22dbc
--- /dev/null
+++ b/src/terralib/kernel/TeNeighbours.h
@@ -0,0 +1,207 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeNeighbours.h
+    \brief This file contains structures and definitions about neighborhood 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_NEGHBOURS_H
+#define  __TERRALIB_INTERNAL_NEGHBOURS_H
+
+#include "TeUtils.h"
+#include "TeAttribute.h"
+
+#include <vector> 
+#include <string>
+#include <map> 
+using namespace std;
+
+
+//! Attributes associated with each neighborhood of a proximity matrix  
+class TL_DLL TeProxMatrixAttributes  
+{
+	private:
+		double	_weight;
+		int		_slice;
+		int		_order;
+		double	_centroid_distance;
+		double	_borders_length;
+		double	_net_objects_distance;
+		double	_net_minimum_path;
+
+
+	public:
+		
+		//! Empty constructor 
+		TeProxMatrixAttributes(); 
+
+		//! Constructor 
+		TeProxMatrixAttributes(const double& w, const int& slice, const int& order, 
+			const double& cent_dist, const double& border_length, 
+			const double& net_distance, const double& net_minimun_path): 
+				_weight(w), _slice(slice), 
+				_order(order), _centroid_distance(cent_dist), 
+                _borders_length(border_length), 
+                _net_objects_distance(net_distance), 
+                _net_minimum_path(net_minimun_path)
+		{}
+		
+		//! Copy constuctor 
+		TeProxMatrixAttributes (const TeProxMatrixAttributes& att); 
+		
+		//! Return weight
+		double	Weight() {return _weight;}
+
+		//! Return slice
+		int		Slice () {return _slice;}
+
+		//! Return order
+		int		Order() {return _order;}
+
+		//! Return border length
+		double	BorderLength() {return _borders_length;}
+
+		//! Return centroid distance
+		double	CentroidDistance() {return _centroid_distance;}
+
+		//! Return network objects distance
+		double	NetworkObjectsDistance() {return _net_objects_distance;}
+
+		//! Return network minimum path
+		double	NetworkMinimumPath () {return _net_minimum_path;}
+
+		//! Set weight
+		void Weight(double w) {_weight = w;}
+
+		//! Set slice
+		void Slice (int s) {_slice = s;}
+		
+		//! Set order
+		void Order(int o) {_order = o;}
+
+		//! Set border length
+		void BorderLength(double l) {_borders_length = l;}
+
+		//! Set centroid distance
+		void CentroidDistance(double d) {_centroid_distance = d;}
+
+		//! Set network objects distance
+		void NetworkObjectsDistance(double d) {_net_objects_distance = d;}
+
+		//! Set network minimum path
+		void NetworkMinimumPath (double d) {_net_minimum_path = d;}
+
+		//! Return the attributes as a TePropertyVector
+		TePropertyVector getProperties ();
+
+		//! Return if the border length was computed 
+		bool WasBordersLengthComputed () {if (_borders_length == -1.0) return false; else return true;}
+		
+		//! Return if the centroid distance was computed
+		bool WasCentroidDistanceComputed () {if (_centroid_distance == -1.0) return false; else return true;}
+		
+		//! Return if the network objects distance was computed
+		bool WasNetworkObjectsDistanceComputed () {if (_net_objects_distance == -1.0) return false; else return true;}
+		
+		//! Return if the network minimal path was computed
+		bool WasNetworkMinimumPathComputed () {if (_net_minimum_path == -1.0) return false; else return true;}
+
+		//! Copy operator
+		TeProxMatrixAttributes& operator= (const TeProxMatrixAttributes& att); 
+		
+		//! Comparison Operator
+		bool operator==(const TeProxMatrixAttributes& att) const;
+			
+		//! Destructor
+		virtual ~TeProxMatrixAttributes() {}
+};
+
+//! A map from a object to its attributes
+typedef map<string, TeProxMatrixAttributes> TeNeighboursMap;
+
+
+//! A class to representate the neighbours of a object 
+class TL_DLL TeNeighbours  
+{
+private:
+	typedef pair<string, TeProxMatrixAttributes>	neigh_values;
+	typedef vector<neigh_values>					neigh_vector;
+
+	neigh_vector _neigh; 
+	
+
+public:
+
+	typedef neigh_vector::iterator iterator;
+	typedef neigh_vector::const_iterator const_iterator;
+
+	//! Empty constructor
+	TeNeighbours () {};
+
+	//! Copy constructor
+	TeNeighbours(const TeNeighboursMap& neigh);
+
+	//! Copy constructor
+	TeNeighbours(const TeNeighbours& neigh);
+	
+	//! Return the number of the neighbours
+	int size() const  { return _neigh.size();}
+
+	//! Return a iterator to the begin of the neighbours
+    iterator begin()     { return _neigh.begin();}
+
+	//! Return a iterator to the one past end of the neighbours
+    iterator end()       { return _neigh.end();}
+
+	//! Return the n-th neighbour object_id, if n < map size.
+	string ObjectId (int n);  
+
+	//! Return the n-th neighbour object_id, if n < map size.
+	string operator[](int n);  
+
+	//! Return the n-th connection weight (corresponding to the n-th neighbour), if n < map size.
+	double Weight (int n);		
+
+	//! Return the connection weight, given the neighbour object_id 
+	double Weight (const string& object_id);	
+	
+	//! Return the complete set of connection attributes (corresponding to the ith neighbour), packed in a TeProxMatrixAttributes object.
+	TeProxMatrixAttributes Attributes (int n);
+	
+	//! Insert a new neighbour
+	bool Insert (const string& object_id, const TeProxMatrixAttributes& attr);
+
+	//! Remove a neighbour
+	bool Remove (const string& object_id);
+
+	//! Copy operator
+	TeNeighbours& operator= (const TeNeighbours& neigh);
+
+	//! Comparison Operator
+	bool operator==(const TeNeighbours& p);
+
+	//! Destructor
+	virtual ~TeNeighbours() {}
+
+};
+
+#endif
diff --git a/src/terralib/kernel/TeNetwork.cpp b/src/terralib/kernel/TeNetwork.cpp
new file mode 100644
index 0000000..3b4a987
--- /dev/null
+++ b/src/terralib/kernel/TeNetwork.cpp
@@ -0,0 +1,578 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeNetwork.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeSTElementSet.h"
+#include "Gra_algo.h"
+
+
+
+TeGraphNetwork:: TeGraphNetwork (TeLineSet& ls)  : graph_ (false)
+{
+	TeLineSet ls2;
+  	ls2.copyElements(ls);
+
+// The initial and final points of each line will be the nodes
+	TeLineSet::iterator it = ls2.begin();
+	while (it != ls2.end())
+	{
+			insertLine  ((*it), TeLength(*it));
+			it++;
+	}
+}
+
+
+TeGraphNetwork:: TeGraphNetwork (TeLineSet& ls, map<string, double>& line_costs)  : graph_ (false)
+{
+	if (ls.size() == line_costs.size())
+	{
+		TeLineSet::iterator it_line = ls.begin();
+		
+		while (it_line != ls.end())
+		{
+			string id = (*it_line).objectId ();
+			map<string, double>:: iterator it_val = line_costs.find(id);
+			if (it_val != line_costs.end())
+				insertLine  ((*it_line), (*it_val).second); 
+			it_line++;
+		}
+	}
+
+}
+
+
+bool
+TeGraphNetwork:: Add (TeLineSet& ls, map<string, double>& line_costs) 
+{
+	if (ls.size() == line_costs.size())
+	{
+		TeLineSet::iterator it_line = ls.begin();
+		
+		while (it_line != ls.end())
+		{
+			string id = (*it_line).objectId ();
+			map<string, double>:: iterator it_val = line_costs.find(id);
+			if (it_val != line_costs.end())
+				insertLine  ((*it_line), (*it_val).second); 
+			it_line++;
+		}
+		return true;
+	}
+	else
+		return false;
+
+}
+
+
+TeGraphNetwork:: TeGraphNetwork (TeSTElementSet& stos, string& attrName)  : graph_ (false)
+{
+	TeSTElementSet::iterator it = stos.begin();
+	while (it != stos.end())
+	{
+		string value;
+		if ((*it).getPropertyValue (attrName, value))
+		{
+			double val = atof(value.c_str());	
+			TeLineSet objGeom;  
+			if ((*it).getGeometry(objGeom))
+			{
+				double total_length = 0.0;
+				TeLineSet::iterator it_geom = objGeom.begin();
+				while (it_geom != objGeom.end())
+				{
+					total_length += TeLength (*it_geom);
+					it_geom++;
+				}
+
+				it_geom = objGeom.begin();
+				while (it_geom != objGeom.end())
+				{
+					double w = TeLength(*it_geom)/total_length;
+					insertLine  (*it_geom, val*w);
+					it_geom++;
+				}	
+			}
+		}
+		++it;
+	}
+}	
+
+
+void
+TeGraphNetwork:: insertLine (TeLine2D& line, const double& attr) 
+{
+
+	// Change line identifiers, to allow lines from different layers
+	int j = line_set_.size(); 
+	string line_objId = "l" + Te2String (j);
+	line.objectId (line_objId); 
+
+
+	// The initial and final nodes will be the first and last points of the line
+	TeNode n1; 
+	n1.add(line.first());
+	string id1 = line.objectId() + "_p1"; 
+	n1.objectId (id1);
+	n1.geomId (0);
+
+	TeNode n2; 
+	n2.add(line.last());	
+	string id2 = line.objectId() + "_p2";
+
+	n2.objectId (id2);
+	n2.geomId (0);
+
+	for (unsigned int i = 0; i < graph_.size(); i++)
+	{
+		if (TeDistance (line.first(), graph_[i].first.location()) < 0.001)
+			n1 = graph_[i].first;
+			
+		if (TeDistance (line.last(), graph_[i].first.location()) < 0.001)
+			n2 = graph_[i].first;
+	}
+
+	if (n1 == n2)
+	{
+		cout << "linha circular" << endl;
+	}
+	else
+	{
+		graph_.insert (n1, n2, attr); // if graph is non-directed, edge from n2 to n1 will also be added
+		line_cost_ [line.objectId()] = attr;
+		line_set_.add (line);
+	}
+
+}
+
+
+
+bool 
+TeGraphNetwork:: minimumPath (TeNode& n1, TeNodeSet& nodeSet,vector<double>& result)
+{
+	vector<double> dist;
+	vector<int> pred;
+
+	// Compute minimum path to all vertex
+	unsigned int j = 0;
+	br_stl::Graph<TeNode, double>::iterator it = graph_.begin();
+	while (it != graph_.end())
+	{
+	   if ((*it).first == n1)  
+		    it = graph_.end();
+	   else
+	   {
+		   it++;
+		   j++;
+	   }
+	}
+	if (j == graph_.size()) return false;
+
+	br_stl::Dijkstra<br_stl::Graph<TeNode, double>, double> (graph_, dist, pred, j);
+
+	for (unsigned int i = 0; i< nodeSet.size(); i++)
+	{
+		br_stl::Graph<TeNode, double>::iterator it = graph_.begin();
+		unsigned int vertex = 0;
+		while (it != graph_.end())
+		{
+			if ((*it).first == nodeSet[i])  
+				it = graph_.end();
+			else
+			{  
+				it++;
+				vertex++;
+			}
+		}
+
+		if (vertex == graph_.size()) return false;
+		result.push_back (dist[vertex]);
+	}
+
+
+	return true;
+
+}
+
+bool 
+TeGraphNetwork::getNode (int i, TeNode& node)
+{ 
+	if ((i >0) && (i < (int) graph_.size())) 
+	{
+		node = graph_[i].first;
+		return true;
+	}
+	else 
+		return false;
+}
+
+bool
+TeGraphNetwork:: nearestNodePoint (TeCoord2D& p1, int& index, TeCoord2D& p2, double& distance, double tol)
+{
+		TeNodeSet node_set;
+		for (unsigned int i = 0; i < graph_.size(); i++) 
+			node_set.add (graph_[i].first);
+
+		if (node_set.size() == 0) return false;
+
+		TeNearest (p1, node_set, index, tol);
+		p2 = node_set[index].elem();
+		distance = TeDistance (p1, p2);
+		return true;
+}
+
+
+
+
+
+bool
+TeGraphNetwork:: breakLineSet (TeNode& node, int line)
+{
+
+	if ((line >= 0) && (line < (int) line_set_.size()))
+	{
+		// Break line
+		int segment;
+		if (TeLocateLineSegment (node.location(), line_set_[line], segment, 0.001))
+		{
+			if (segment <= (int) (line_set_[line].size()) - 2)
+			{
+				TeLine2D l1, l2;
+				int j = 0;
+				TeLine2D::iterator it = line_set_[line].begin();
+
+				while (j <= segment)
+				{
+					l1.add (*it);
+					it++;
+					j++;
+				}
+
+				l1.add (node.location());
+				l2.add (node.location ());
+
+				while (it != line_set_[line].end())
+				{
+					l2.add (*it);
+					it++;
+				}
+		
+				string old_line_id = line_set_[line].objectId();
+				string line1_id = old_line_id + "l1";
+				string line2_id = old_line_id + "l2";
+
+				l1.objectId(line1_id);
+				l2.objectId(line2_id);
+		
+			    // Compute proportional costs for broken lines
+
+				double d1   = TeLength (l1);
+				double d2   = TeLength (l2);
+				double d_tot = TeLength (line_set_[line]);
+
+				double w1 = d1/d_tot;
+				double w2 = d2/d_tot;
+
+				double val1 = w1*line_cost_[old_line_id];
+				double val2 = w2*line_cost_[old_line_id];
+
+				// update line cost
+
+				line_cost_[line1_id] = val1;
+				line_cost_[line2_id] = val2;
+				line_cost_.erase (old_line_id);
+
+     			// update line set
+
+				line_set_.add (l1);
+				line_set_.add (l2);
+				line_set_.erase (line);
+			
+				return true;
+				}
+			else return false;
+			}
+		else return false;
+		}
+	else return false;
+}
+
+
+
+
+bool
+TeGraphNetwork:: nearestNetworkPoint (TeCoord2D& p1, int& lindex, TeCoord2D& pinter, double& distance, double tol)
+{
+		if (line_set_.size() == 0) return false;
+		return TeNearest (p1, line_set_, lindex, pinter, distance, tol);
+
+		bool TeNearest(TeCoord2D& pt, TeLineSet& ls , int& i, TeCoord2D& pi, const double& tol);
+
+}
+
+
+///////////////////////////////////// Old version - not modified
+
+TeNetwork:: TeNetwork (TeLineSet& ls)  : graph_ (false)
+{
+	line_set_ = ls;
+
+
+	// The initial and final points of each line will be the nodes
+	TeLineSet::iterator it = ls.begin();
+	int j = 0;
+	while (it != line_set_.end())
+	{
+		string line_objId = "l" + Te2String (j);
+		(*it).objectId (line_objId); //ANAP: modified to be able to use more than on layer.
+		TeLine2D line = (*it);
+
+		TeNode n1; 
+		n1.add(line.first());
+		string id1 = line.objectId() + "_p1"; 
+		n1.objectId (id1);
+		n1.geomId (0);
+
+		TeNode n2; 
+		n2.add(line.last());	
+		string id2 = line.objectId() + "_p2";
+		n2.objectId (id2);
+		n2.geomId (0);
+
+		for (unsigned int i = 0; i < graph_.size(); i++)
+		{
+			if (TeDistance (line.first(), graph_[i].first.location()) < 0.01)
+				n1 = graph_[i].first;
+			
+			if (TeDistance (line.last(), graph_[i].first.location()) < 0.01)
+				n2 = graph_[i].first;
+		}
+
+		graph_.insert (n1, n2, TeLength(line));
+
+		TeArc arc (n1, n2);
+		// This is kept for updating purposes
+		arcs_map_[line.objectId()] = arc;
+		it++;
+		j++;
+	}
+}
+
+void
+TeNetwork:: insertLine (TeLine2D& line, const double& attr) 
+{
+
+	int j = line_set_.size();
+
+	// The initial and final points of each line will be the nodes
+	string line_objId = "l" + Te2String (j);
+	line.objectId (line_objId); //ANAP: modified to be able to use more than one layer.
+
+	TeNode n1; 
+	n1.add(line.first());
+	string id1 = line.objectId() + "_p1"; 
+	n1.objectId (id1);
+	n1.geomId (0);
+
+	TeNode n2; 
+	n2.add(line.last());	
+	string id2 = line.objectId() + "_p2";
+
+	n2.objectId (id2);
+	n2.geomId (0);
+
+	for (unsigned int i = 0; i < graph_.size(); i++)
+	{
+		if (TeDistance (line.first(), graph_[i].first.location()) < 0.01)
+			n1 = graph_[i].first;
+			
+		if (TeDistance (line.last(), graph_[i].first.location()) < 0.01)
+			n2 = graph_[i].first;
+	}
+
+	graph_.insert (n1, n2, attr);
+
+	TeArc arc (n1, n2);
+	// This is kept for updating purposes
+	arcs_map_[line.objectId()] = arc;
+	line_set_.add (line);
+
+}
+
+
+bool 
+TeNetwork:: insertNode (TeNode& node, int line)
+{
+	if ((line >= 0) && (line < (int) line_set_.size()))
+	{
+		// Break line
+		int segment;
+		if (TeLocateLineSegment (node.location(), line_set_[line], segment, 0.001))
+		{
+			if (segment <= (int) (line_set_[line].size()) - 2)
+			{
+				TeLine2D l1, l2;
+				int j = 0;
+				TeLine2D::iterator it = line_set_[line].begin();
+
+				while (j <= segment)
+				{
+					l1.add (*it);
+					it++;
+					j++;
+				}
+
+				l1.add (node.location());
+				l2.add (node.location ());
+
+				while (it != line_set_[line].end())
+				{
+					l2.add (*it);
+					it++;
+				}
+
+				// get new and old lines ids
+
+				string old_line_id = line_set_[line].objectId();
+				string line1_id = old_line_id + "l1";
+				string line2_id = old_line_id + "l2";
+
+				l1.objectId(line1_id);
+				l2.objectId(line2_id);
+		
+     			// update line set
+				line_set_.add (l1);
+				line_set_.add (l2);
+				line_set_.erase (line);
+	
+				// update map_nodes 
+				TeArc arc1 (arcs_map_[old_line_id].toNode(),  node);
+				arcs_map_[line1_id] = arc1;
+
+				TeArc arc2 (arcs_map_[old_line_id].fromNode(),node);
+				arcs_map_[line2_id] = arc2;
+				arcs_map_.erase(old_line_id);
+
+
+/*			// insert new arc connection in the network
+			graph_.insert (arcs_map_ [old_line_id].fromNode(),node, l1.length()); 
+			graph_.insert (arcs_map_ [old_line_id].toNode(),  node, l2.length()); 
+		//	graph_.remove (arcs_map_[old_line_id].fromNode(), _map_nodes[old_line_id].toNode()); 
+
+			
+*/
+				return true;
+				}
+			else return false;
+			}
+		else return false;
+		}
+	else return false;
+}
+
+
+bool 
+TeNetwork::getNode (int i, TeNode& node)
+{ 
+	if ((i >0) && (i < (int) graph_.size())) 
+	{
+		node = graph_[i].first;
+		return true;
+	}
+	else 
+		return false;
+}
+
+
+bool 
+TeNetwork:: minimumPath (TeNode& n1, TeNodeSet& nodeSet,vector<double>& result)
+{
+	vector<double> dist;
+	vector<int> pred;
+
+	// Compute minimum path to all vertex
+	unsigned int j = 0;
+	br_stl::Graph<TeNode, double>::iterator it = graph_.begin();
+	while (it != graph_.end())
+	{
+	   if ((*it).first == n1)  
+		    it = graph_.end();
+	   else
+	   {
+		   it++;
+		   j++;
+	   }
+	}
+	if (j == graph_.size()) return false;
+
+	br_stl::Dijkstra<br_stl::Graph<TeNode, double>, double> (graph_, dist, pred, j);
+
+	for (unsigned int i = 0; i< nodeSet.size(); i++)
+	{
+		br_stl::Graph<TeNode, double>::iterator it = graph_.begin();
+		unsigned int vertex = 0;
+		while (it != graph_.end())
+		{
+			if ((*it).first == nodeSet[i])  
+				it = graph_.end();
+			else
+			{  
+				it++;
+				vertex++;
+			}
+		}
+
+		if (vertex == graph_.size()) return false;
+		result.push_back (dist[vertex]);
+	}
+
+
+	return true;
+
+}
+
+
+bool
+TeNetwork:: nearestNodePoint (TeCoord2D& p1, int& index, TeCoord2D& p2, double& distance, double tol)
+{
+		TeNodeSet node_set;
+		for (unsigned int i = 0; i < graph_.size(); i++) 
+			node_set.add (graph_[i].first);
+
+		if (node_set.size() == 0) return false;
+
+		TeNearest (p1, node_set, index, tol);
+		p2 = node_set[index].elem();
+		distance = TeDistance (p1, p2);
+		return true;
+}
+
+bool
+TeNetwork:: nearestNetworkPoint (TeCoord2D& p1, int& lindex, TeCoord2D& pinter, double& distance, double tol)
+{
+		if (line_set_.size() == 0) return false;
+		return TeNearest (p1, line_set_, lindex, pinter, distance, tol);
+
+		bool TeNearest(TeCoord2D& pt, TeLineSet& ls , int& i, TeCoord2D& pi, const double& tol = 0.0);
+
+}
diff --git a/src/terralib/kernel/TeNetwork.h b/src/terralib/kernel/TeNetwork.h
new file mode 100644
index 0000000..7ad4c4e
--- /dev/null
+++ b/src/terralib/kernel/TeNetwork.h
@@ -0,0 +1,160 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeNetwork.h
+    \brief This file defines class for handling networks in Terralib
+*/
+#ifndef TeNetwork_H
+#define TeNetwork_H
+
+#include "TeGeometry.h"
+#include "graph.h"
+
+class TeSTElementSet;
+
+
+//! class for handling networks
+class TL_DLL TeGraphNetwork
+{
+protected:
+	//! Set of nodes and the cost of each edge
+	br_stl::Graph<TeNode, double>	graph_;
+
+	//! Set of geometric representation of edges
+	TeLineSet						line_set_;	
+	
+	//! A map to associate each edge (line object_id) to its cost 
+	map<string, double>				line_cost_;	
+
+	
+public:
+
+	//! Empty constructor
+	TeGraphNetwork() : graph_ (true) {}; // directed graph
+	
+		
+	//! Create a graph from TeLineSet; the line size is considered the cost. In this case, graph non-directed.  
+	TeGraphNetwork (TeLineSet& ls);
+	
+
+	//! Create a graph from TeLineSet; the cost is given by the map.    
+	TeGraphNetwork (TeLineSet& ls, map<string, double>& line_costs);
+	
+
+	//! Create a network from a set of line objects; the cost is given by the attrName sto property. The graph is non-directed.    
+	TeGraphNetwork (TeSTElementSet& stos, string& attrName);
+
+	
+	//! Assignment operator
+	TeGraphNetwork& operator=(TeGraphNetwork& other)
+	{
+		if(this != &other)
+		{
+			graph_ = other.graph_;
+			line_set_ = other.getLineSet();
+			line_cost_ = other.getLineCosts();
+		}
+		return (*this);
+	}
+
+	//! Add lineset to graph. Useful specially for directed graphs (lines must be entered in both directions. It has to be tested for existing graphs.
+	bool Add (TeLineSet& ls, map<string, double>& line_costs); 
+
+	//! Calculate the minimun path
+	bool minimumPath (TeNode& n1, TeNodeSet& set, vector<double>& dist);
+
+	//! Get the i-th node 
+	bool getNode (int i, TeNode& node); 
+	
+	//! Get the nearest network node of a specific point (p1)  
+	bool nearestNodePoint (TeCoord2D& p1, int& lindex, TeCoord2D& pinter, double& distance, double tol = 0.0);
+
+	//! Get the nearest network lines point from a specific point (p1) 
+	bool nearestNetworkPoint (TeCoord2D& p1, int& lindex, TeCoord2D& pinter, double& distance, double tol = 0.0);
+
+	//! Get line Set
+	TeLineSet getLineSet () { return line_set_;}
+
+	//! Get line costs
+	map<string, double>	getLineCosts () {return line_cost_;}
+
+	//! Insert a new line
+	void insertLine (TeLine2D& line, const double& attr);	
+
+	//! Insert a new node
+	bool breakLineSet (TeNode& node, int i); //maybe should be done externally.
+
+	//! Destructor
+	virtual ~TeGraphNetwork () {}
+
+};
+
+
+//! class for handling networks
+class TL_DLL TeNetwork
+{
+private:
+	//! Set of nodes and the cost of each edge
+	br_stl::Graph<TeNode, double>	graph_;
+	
+	//! Set of edges
+	TeLineSet						line_set_;	
+	
+	//! A map to associate each edge (line object_id) to its arc 
+	map<string, TeArc>				arcs_map_;	
+
+public:
+	//! Empty constructor
+	TeNetwork() : graph_ (false) { };
+
+	//! Create a graph from TeLineSet, the line size is considered the cost    
+	TeNetwork (TeLineSet& ls);  
+
+	//! Calculate the minimun path
+	bool minimumPath (TeNode& n1, TeNodeSet& set, vector<double>& dist);
+
+
+	//! Insert a new line
+	void insertLine (TeLine2D& line, const double& attr);
+
+
+	//! Insert a new node
+	bool insertNode (TeNode& node, int i);
+
+	//! Get the i-th node 
+	bool getNode (int i, TeNode& node); 
+
+	//! Get the nearest network point of a specific point (p1) 
+	bool nearestNetworkPoint (TeCoord2D& p1, int& lindex, TeCoord2D& pinter, double& distance, double tol = 0.0);
+	
+	//! Get the nearest network node of a specific point (p1)  
+	bool nearestNodePoint (TeCoord2D& p1, int& lindex, TeCoord2D& pinter, double& distance, double tol = 0.0);
+
+	//! Destructor
+	virtual ~TeNetwork () {}
+
+	//! Get line Set
+	TeLineSet getLineSet () { return line_set_;}
+
+};
+
+#endif 
diff --git a/src/terralib/kernel/TeOverlay.cpp b/src/terralib/kernel/TeOverlay.cpp
new file mode 100644
index 0000000..02708ff
--- /dev/null
+++ b/src/terralib/kernel/TeOverlay.cpp
@@ -0,0 +1,763 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+// TerraLib's include
+#include "TeOverlay.h"
+#include "TeOverlayUtils.h"
+#include "TeIntersector.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeFragmentation.h"
+#include "TeRTree.h"
+
+//---------------- Overlay operations ----------------//
+
+// Operacao de uniao otimizada: consome memoria!
+bool TeOVERLAY::TeUnion(TePolygonSet& polsIn, TePolygonSet& polsOut, const bool& makeCopy, const bool fixOrientation)
+{
+// limpa a lista de saida
+	polsOut.clear();
+
+// verifica se e necessario realizar uma copia dos pol�gonos
+	TePolygonSet polygonSetIn;
+
+	if(makeCopy)
+	{
+		if(!TeOVERLAY::TeClonePolygonSet(polsIn, polygonSetIn))
+			return false;
+        //polygonSetIn.copyElements(polsIn);
+	}
+	else
+	{
+		polygonSetIn = polsIn;
+	}
+
+	if(polygonSetIn.empty())
+		return false;
+
+	if(polygonSetIn.size() == 1)
+	{
+		polsOut.copyElements(polygonSetIn);
+
+		return true;
+	}
+
+// verifica a orientacao de cada linha se necessario: aneis externos devem estar no sentido horario e os internos devem estar no sentido anti-horario
+	if(fixOrientation)
+		TeFixOrientation(polygonSetIn, TeCOUNTERCLOCKWISE, TeCLOCKWISE);
+
+// cria uma arvore que indexara os segmentos de cada linha e
+// chama uma rotina que calcula os pontos de intersecao e ja indexa os segmentos
+	TeINTERSECTOR2::TeSegmentRTree segmentTree(polygonSetIn.box());
+
+	TeINTERSECTOR2::TeVectorBoundaryIP report;
+
+	TeINTERSECTOR2::TeIntersection(polygonSetIn, segmentTree, report);
+
+// fragmenta as linhas
+	TeLineSet fragments;
+	TeLineSet boundaryFragments;
+	vector<pair<unsigned int, unsigned int> > fragmentsIds;
+	vector<pair<unsigned int, unsigned int> > boundaryFragmentsIds;
+
+	TeFragmentBoundary(polygonSetIn, report, boundaryFragments, boundaryFragmentsIds, fragments, fragmentsIds);
+
+	report.clear();
+
+	short mask  = TeUNKNOWNPOSITION;
+
+// os fragmentos de fronteira ja sao separados
+	TeLineIndex boundaryFragmentsIndex;
+	unsigned int i;
+	if(boundaryFragments.size())
+	{
+		mask = TeBOUNDARY;
+
+		unsigned int boundaryFragmentsSize = boundaryFragments.size();
+
+		for(i = 0; i < boundaryFragmentsSize; ++i)
+			boundaryFragmentsIndex.insert(TeLineIndex::value_type(boundaryFragments[i][0], pair<unsigned int, TeLine2D>(i, boundaryFragments[i])));
+	}
+
+// escolhe os fragmentos que estiverem localizados dentro de cada pol�gono
+	short locationFragments  = TeOUTSIDE;	
+
+	TeLineIndex fragmentsIndex;
+
+	vector<TeLinearRing> rings;
+
+	TeRtreeGetFragments(polygonSetIn, segmentTree, fragments, fragmentsIds, locationFragments, mask, fragmentsIndex, rings);
+
+	// Tenta eliminar fragmentos de fronteira no mesmo sentido, deixando apenas um nesta direcao
+	TeRemoveSameBoundaryFragments(boundaryFragmentsIndex);
+
+	// Tenta eliminar fragmentos sobre fronteira opostos
+	TeRemoveOpositeBoundaryFragments(boundaryFragmentsIndex);
+
+	//--remover do boundaryfragments os fragmentos removidos do boundaryFragmentsIndex
+	TeRtreeRemoveFragments(polygonSetIn, segmentTree, boundaryFragmentsIndex, boundaryFragmentsIds, TeINSIDE, mask, rings);
+	segmentTree.clear();
+
+// Faz um merge dos fragmentos de fronteira para o �ndice de fragmentos normal
+	TeJoinFragments(fragmentsIndex, boundaryFragmentsIndex);
+
+// monta os poligonos a partir dos fragmentos
+	bool returnValue = TeMergeFragments(fragmentsIndex, rings, true);
+
+	vector<TeLinearRing> ringsOut;
+
+	bool resultSplit = true;
+
+	if(TeOVERLAY::TeSplitRings(rings, ringsOut) == false)
+	{
+		ringsOut.clear();
+
+		ringsOut = rings;
+
+		resultSplit = false;
+	}
+
+// separate holes from islands
+	vector<TeLinearRing> holes;
+
+	bool result = TeClassifyRings(ringsOut, polsOut, holes);
+
+// mount topology		
+	if((polsOut.size() == 0) && (holes.size() == 0))
+	{
+		return false;	// Na uniao deve haver a formacao de poligonos	
+	}
+	
+	bool mountResult = TeMountTopology(polsOut, holes);
+
+	return (returnValue && result &&  mountResult && resultSplit);
+}
+
+
+// Operacao geral de conjunto: uniao, intersecao e diferenca
+bool TeOverlay(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const short& operation, const bool& makeCopy, const bool fixOrientation)
+{
+// limpa a saida
+	vecPolsOut.clear();
+	resultVec.clear();
+
+// verifica se a lista dos poligonos vermelhos esta vazia
+	unsigned int numBluePols = bluePols.size();
+	unsigned int i;
+
+	if(redPols.empty())
+	{
+// se os poligonos vermelhos nao foram informados, no caso da uniao tenta copiar os azuis para o vetor de saida
+		if(operation == TeUNION)
+		{
+			for(i = 0; i < numBluePols; ++i)
+			{
+				TePolygonSet bluePolsInAux;
+
+				if(!TeOVERLAY::TeClonePolygonSet(bluePols[i], bluePolsInAux))
+					return false;
+
+				//bluePolsInAux.copyElements(bluePols[i]);
+
+// se nao existir tambem o poligono azul, entao retirn falso
+                vecPolsOut.push_back(bluePolsInAux);
+				resultVec.push_back	(true);
+			}
+
+			if(vecPolsOut.empty())
+				return false;
+
+			return true;
+		}
+		
+// TeDIFFERENCE ou TeINTERSECTION: resultado eh vazio, logo ja retorna true
+		return true;
+	}
+
+
+// Defines location to choose fragments
+	short locationRedFragments  = TeINSIDE;	
+	short locationBlueFragments  = TeINSIDE;
+
+	TeOVERLAY::TeChooseBoundaryLocation(operation, locationRedFragments, locationBlueFragments);
+
+// verifica se e necessario realizar uma copia dos poligonos
+	TePolygonSet redPolsIn;
+	vector<TePolygonSet> bluePolsIn;
+
+	if(makeCopy)
+	{
+		if(!TeOVERLAY::TeClonePolygonSet(redPols, redPolsIn))
+			return false;
+
+		//redPolsIn.copyElements(redPols);
+		
+		for(i = 0; i < numBluePols; ++i)
+		{
+			TePolygonSet bluePolsInAux;
+
+			if(!TeOVERLAY::TeClonePolygonSet(bluePols[i], bluePolsInAux))
+				return false;
+
+			//bluePolsInAux.copyElements(bluePols[i]);
+
+			bluePolsIn.push_back(bluePolsInAux);
+		}
+	}
+	else
+	{
+		redPolsIn = redPols;
+		
+		bluePolsIn = bluePols;
+	}
+
+
+// verifica a orientacao de cada linha se necessario: aneis externos devem estar no sentido horario e os internos devem estar no sentido anti-horario
+	if(fixOrientation)
+	{	
+		if(operation == TeINTERSECTION || operation == TeUNION)
+		{
+			TeOVERLAY::TeFixOrientation(redPolsIn, TeCOUNTERCLOCKWISE, TeCLOCKWISE);
+
+			for(i = 0; i < numBluePols; ++i)
+				TeOVERLAY::TeFixOrientation(bluePolsIn[i], TeCOUNTERCLOCKWISE, TeCLOCKWISE);
+		}
+		else
+		{
+			TeOVERLAY::TeFixOrientation(redPolsIn, TeCOUNTERCLOCKWISE, TeCLOCKWISE);
+
+			for(i = 0; i < numBluePols; ++i)
+				TeOVERLAY::TeFixOrientation(bluePolsIn[i], TeCLOCKWISE, TeCOUNTERCLOCKWISE);
+		}
+	}
+
+
+// cria uma arvore que indexara os segmentos dos poligonos vermelhos
+	TeINTERSECTOR2::TeSegmentRTree redSegmentTree(redPolsIn.box());
+	TeINTERSECTOR2::TeIndexPolygonSet(redPolsIn, redSegmentTree);
+
+	bool resultValue = true;
+
+// para cada conjunto de poligonos azuis, faz a operacao dele com os vermelhos
+	for(i = 0; i < numBluePols; ++i)
+	{
+// verifica se tem poligonos no polygonset azul
+		if(bluePolsIn[i].empty())
+		{
+			if((operation == TeUNION) || (operation == TeDIFFERENCE))
+			{
+				vecPolsOut.push_back(redPolsIn);
+				resultVec.push_back(true);	// mario - 2006-03
+			}
+			else
+			{
+                TePolygonSet emptySet;
+
+                vecPolsOut.push_back(emptySet);
+				resultVec.push_back(true);	// mario - 2006-03
+			}
+
+			continue;
+		}
+
+// Indexa os segmentos azuis
+		TeINTERSECTOR2::TeSegmentRTree blueSegmentTree(bluePolsIn[i].box());
+		TeINTERSECTOR2::TeIndexPolygonSet(bluePolsIn[i], blueSegmentTree);		
+
+// calcula os potos de intersecao dos vermelhos com os azuis
+		TeINTERSECTOR2::TeVectorBoundaryIP report;
+		TeINTERSECTOR2::TeIntersection(redPolsIn, redSegmentTree, bluePolsIn[i], report);
+
+// fragmenta as linhas vermelhas
+		TeLineSet redFragments;
+		TeLineSet redBoundaryFragments;
+		vector<pair<unsigned int, unsigned int> > redFragmentsIds;
+		vector<pair<unsigned int, unsigned int> > boundaryFragmentsIds;
+
+		TeFragmentBoundary(redPolsIn, report, redBoundaryFragments, boundaryFragmentsIds, redFragments, redFragmentsIds);
+
+		short mask  = TeUNKNOWNPOSITION;
+
+// os fragmentos de fronteira ja sao separados
+		TeOVERLAY::TeLineIndex boundaryFragmentsIndex;
+
+		unsigned int boundaryId_ = 0;
+
+		if(redBoundaryFragments.size())
+		{
+			mask = TeBOUNDARY;
+
+			unsigned int boundaryFragmentsSize = redBoundaryFragments.size();
+
+			for(unsigned int ti = 0; ti < boundaryFragmentsSize; ++ti)
+			{
+				boundaryFragmentsIndex.insert(TeOVERLAY::TeLineIndex::value_type(redBoundaryFragments[ti][0], pair<unsigned int, TeLine2D>(boundaryId_, redBoundaryFragments[ti])));
+				++boundaryId_;
+			}
+		}
+
+// escolhe os fragmentos vermelhos que estiverem localizados dentro/fora (dependendo da oparacao) dos poligonos azuis
+		vector<TeLinearRing> rings;
+
+		TeOVERLAY::TeLineIndex fragmentsIndex;
+
+		TeOVERLAY::TeRtreeGetFragments(bluePolsIn[i], blueSegmentTree, redFragments, locationRedFragments, mask, fragmentsIndex, rings);
+
+// inverte a ordem dos pontos de intersecao para fragmentar as linhas azuis
+		TeINTERSECTOR2::TeVectorBoundaryIP::iterator it     = report.begin();
+		TeINTERSECTOR2::TeVectorBoundaryIP::iterator it_end = report.end();
+		
+		while(it != it_end)
+		{
+			swap(it->bluePolNum_, it->redPolNum_);
+			swap(it->bluePartNum_, it->redPartNum_);
+			swap(it->blueSegNum_, it->redSegNum_);
+
+			if(it->coords_.size() == 2)	//overlap
+			{
+				// Verificar se os pontos estao em ordem crescente
+				if(it->coords_[0].x_ < it->coords_[1].x_)
+				{
+				}
+				else if(it->coords_[0].x_ > it->coords_[1].x_)
+				{
+					swap(it->coords_[0], it->coords_[1]);
+				}
+				else if(it->coords_[0].y_ < it->coords_[1].y_)
+				{
+
+				}
+				else
+				{
+					swap(it->coords_[0], it->coords_[1]);							
+				}
+			}
+
+			++it;
+		}
+
+// fragmenta as linhas azuis
+		TeLineSet blueFragments;
+		TeLineSet blueBoundaryFragments;
+		vector<pair<unsigned int, unsigned int> > blueFragmentsIds;
+		boundaryFragmentsIds.clear();
+
+		TeFragmentBoundary(bluePolsIn[i], report, blueBoundaryFragments, boundaryFragmentsIds, blueFragments, blueFragmentsIds);
+
+		report.clear();
+
+		mask  = TeUNKNOWNPOSITION;
+
+// os fragmentos de fronteira ja sao separados
+		if(blueBoundaryFragments.size())
+		{
+			mask = TeBOUNDARY;
+
+			unsigned int boundaryFragmentsSize = blueBoundaryFragments.size();
+
+			for(unsigned int ti = 0; ti < boundaryFragmentsSize; ++ti)
+			{
+				boundaryFragmentsIndex.insert(TeOVERLAY::TeLineIndex::value_type(blueBoundaryFragments[ti][0], pair<unsigned int, TeLine2D>(boundaryId_, blueBoundaryFragments[ti])));
+				++boundaryId_;
+			}
+		}
+
+// escolhe os fragmentos vermelhos que estiverem localizados fora dos poligonos azuis - fragmenta as linhas vermelhas
+		TeRtreeGetFragments(redPolsIn, redSegmentTree, blueFragments, locationBlueFragments, mask, fragmentsIndex, rings);
+
+// libera a memoria usada pelos indice azul
+		blueSegmentTree.clear();
+
+// tenta eliminar fragmentos de fronteira no mesmo sentido, deixando apenas um nesta direcao
+		TeRemoveSameBoundaryFragments(boundaryFragmentsIndex);
+
+// tenta eliminar fragmentos sobre fronteira opostos
+        TeRemoveOpositeBoundaryFragments(boundaryFragmentsIndex);
+
+// faz um merge dos fragmentos de fronteira para o indice de fragmentos normal
+		TeJoinFragments(fragmentsIndex, boundaryFragmentsIndex);
+
+// monta os poligonos a partir dos fragmentos
+		bool returnValue = TeMergeFragments(fragmentsIndex, rings, true);
+
+		// faz o split
+		vector<TeLinearRing> ringsOut;
+
+		bool resultSplit = true;
+
+		if(TeOVERLAY::TeSplitRings(rings, ringsOut) == false)
+		{
+			ringsOut.clear();
+
+			ringsOut = rings;
+
+			resultSplit = false;
+		}
+
+// separate holes from islands
+		vector<TeLinearRing> holes;
+		TePolygonSet polsOut;
+
+		bool result = TeOVERLAY::TeClassifyRings(ringsOut, polsOut, holes);
+
+		returnValue = returnValue && result && resultSplit;
+
+// mount topology		
+		if((polsOut.size() == 0) && (holes.size() == 0))
+		{
+			if(operation == TeUNION)			
+			{
+				resultVec.push_back(false);	// mario - 2006-03
+				resultValue = false;						// uniao nao pode dar vazio
+			}
+			else
+			{
+				resultVec.push_back(returnValue);	// mario - 2006-03
+				resultValue = (resultValue && returnValue);	// Diferenca e intersecao podem retornar vazio
+			}
+
+			vecPolsOut.push_back(polsOut);	// only to mark result			
+		}
+		else
+		{
+			bool mountResult = TeOVERLAY::TeMountTopology(polsOut, holes);
+
+			resultVec.push_back(returnValue && mountResult);	// mario - 2006-03
+
+			resultValue = resultValue && returnValue && mountResult;	
+
+			vecPolsOut.push_back(polsOut);
+		}		
+		
+	}
+
+	redSegmentTree.clear();
+
+	return resultValue;
+}
+
+bool TeOVERLAY::TeIntersection(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy, const bool fixOrientation)
+{
+	return TeOverlay(redPols, bluePols, vecPolsOut, resultVec, TeINTERSECTION, makeCopy, fixOrientation);
+}
+
+bool TeOVERLAY::TeUnion(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy, const bool fixOrientation)
+{
+	return TeOverlay(redPols, bluePols, vecPolsOut, resultVec, TeUNION, makeCopy, fixOrientation);
+}
+
+bool TeOVERLAY::TeDifference(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy, const bool fixOrientation)
+{
+	return TeOverlay(redPols, bluePols, vecPolsOut, resultVec, TeDIFFERENCE, makeCopy, fixOrientation);
+}
+
+// deprecated functions
+bool TeOVERLAY::TeOverlay(const TePolygonSet& redPols, const TePolygonSet& bluePols, TePolygonSet& polsOut, const short& operation)
+{
+	vector<TePolygonSet> bluePolsVec;
+	bluePolsVec.push_back(bluePols);
+	vector<TePolygonSet> resultPols;
+	TePolygonSet redPolsAux = redPols;
+	vector<bool> resultVec;
+
+	bool result = TeOverlay(redPolsAux, bluePolsVec, resultPols, resultVec, operation, true, true);
+
+	if(resultPols.size() > 0)
+		polsOut = resultPols[0];
+
+	return result;	
+}
+
+bool TeOVERLAY::TeUnion(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut)
+{
+	return TeOVERLAY::TeOverlay(redPols, bluePols, polsOut, TeUNION);
+}
+
+bool TeOVERLAY::TeIntersection(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut)
+{
+	return TeOVERLAY::TeOverlay(redPols, bluePols, polsOut, TeINTERSECTION);
+}
+
+bool TeOVERLAY::TeDifference(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut)
+{
+	return TeOVERLAY::TeOverlay(redPols, bluePols, polsOut, TeDIFFERENCE);
+}
+
+TeMultiGeometry TeOverlay(const TeLineSet& redLinesIn, const TePolygonSet& bluePolsIn, TeINTERSECTOR2::TeSegmentRTree& blueTree, const short& operation)
+{
+//	short location = TeUNKNOWNPOSITION;
+	short locationRedFragments = TeUNKNOWNPOSITION;
+	short locationBlueFragments = TeUNKNOWNPOSITION;
+
+	TeMultiGeometry mGeom;
+
+	TeLineSet redLines;
+	TePolygonSet bluePols;
+
+// copia o conteudo das linhas de entrada
+	redLines.copyElements(redLinesIn);
+
+// copia o conteudo dos poligonos de entrada
+	bluePols.copyElements(bluePolsIn);
+
+// determina a localizacao dos fragmentos que serao utilizados
+	TeOVERLAY::TeChooseBoundaryLocation(operation, locationRedFragments, locationBlueFragments);
+
+// gets intersection list
+	TeINTERSECTOR2::TeVectorBoundaryIP report;
+
+	TeINTERSECTOR2::TeIntersection(redLines, bluePols, blueTree, report);
+
+// fragment lines
+	TeLineSet redFragments;
+	TeLineSet redBoundaryFragments;
+	
+    TeFragmentBoundary(redLines, report, redBoundaryFragments, redFragments);
+
+// choose red fragments
+	vector<TeLinearRing> rings;
+
+	TeOVERLAY::TeLineIndex fragmentsIndex;
+
+	short mask = 0;
+
+	TeRtreeGetFragments(bluePols, blueTree, redFragments, locationRedFragments, mask, fragmentsIndex, rings);
+
+// report fragments from red lines
+	TeOVERLAY::TeLineIndex::iterator it = fragmentsIndex.begin();
+
+	while(it != fragmentsIndex.end())
+	{
+		mGeom.addGeometry(it->second.second);
+		++it;
+	}
+
+	unsigned int nrings = rings.size();
+	unsigned int i;
+	for(i = 0; i < nrings; ++i)
+	{
+		mGeom.addGeometry(rings[i]);
+	}
+
+// if the operaton is union, so push bluepols
+
+	if(operation == TeUNION)
+	{							
+		mGeom.setGeometry(bluePols);		
+	}
+
+	return mGeom;
+}
+
+void TeOverlay(vector<TeLineSet>& redLinesIn, const TePolygonSet& bluePolsIn, vector<TeMultiGeometry>& outPutGeoms, const short& operation)
+{
+	TeINTERSECTOR2::TeSegmentRTree blueTree(bluePolsIn.box());
+
+	unsigned int nLines = redLinesIn.size();
+	unsigned int i;
+	for(i = 0; i < nLines; ++i)
+	{
+		TeMultiGeometry mg;
+
+		mg = TeOverlay(redLinesIn[i], bluePolsIn, blueTree, operation);
+
+		outPutGeoms.push_back(mg);        		
+	}
+
+	blueTree.clear();
+
+	return;
+}
+
+// overlay for lines/polygons
+TeMultiGeometry TeOVERLAY::TeOverlay(const TeLineSet& redLinesIn, const TePolygonSet& bluePolsIn, const short& operation)
+{
+	vector<TeMultiGeometry> mgeoms;
+	vector<TeLineSet> redLines;
+	redLines.push_back(redLinesIn);
+	TeMultiGeometry outputGeom;
+
+	::TeOverlay(redLines, bluePolsIn, mgeoms, operation);
+
+	if(mgeoms.empty())
+		return outputGeom;
+
+	outputGeom = mgeoms[0];
+
+	return outputGeom;
+}
+
+TeMultiGeometry TeOVERLAY::TeUnion(TeLineSet& redLines, TePolygonSet& bluePols)
+{
+	return TeOVERLAY::TeOverlay(redLines, bluePols, TeUNION);
+}
+
+TeMultiGeometry TeOVERLAY::TeIntersection(TeLineSet& redLines, TePolygonSet& bluePols)
+{
+	return TeOVERLAY::TeOverlay(redLines, bluePols, TeINTERSECTION);
+}
+
+TeMultiGeometry TeOVERLAY::TeDifference(TeLineSet& redLines, TePolygonSet& bluePols)
+{
+	return TeOVERLAY::TeOverlay(redLines, bluePols, TeDIFFERENCE);
+}
+
+bool TeOVERLAY::TePairUnion(TePolygonSet& psetIn, TePolygonSet& psetOut)
+{
+	psetOut.clear();
+
+	vector<TePolygonSet> outPutSet;
+	unsigned int i;
+	for(i = 0; i < psetIn.size(); ++i)
+	{
+		TePolygonSet pset;
+		pset.add(psetIn[i]);
+		outPutSet.push_back(pset);
+	}
+
+	unsigned int outsize = outPutSet.size();
+
+	bool resultUnion = true;
+
+	while(outsize > 1)
+	{
+// une dois a dois
+		unsigned int auxsize = 0;
+		unsigned int i;
+		for(i = 0; i < outsize; i += 2)
+		{
+			TePolygonSet psRed = outPutSet[i];
+			if((i + 1) < outsize)
+			{
+				TePolygonSet psBlue = outPutSet[i+1];
+				TePolygonSet psUnidoAgregado;
+				resultUnion = resultUnion && TeOVERLAY::TeUnion(psRed, psBlue, psUnidoAgregado);
+				if(psUnidoAgregado.size() > 0)
+				{
+					outPutSet[auxsize] = psUnidoAgregado;
+					++auxsize;
+				}
+			}
+			else
+			{
+				outPutSet[auxsize] = psRed;
+				++auxsize;
+			}			
+		}
+
+		outsize = auxsize;
+	}
+
+	for(unsigned int i = 0; i < outsize; ++i)
+		for(unsigned int j = 0; j < outPutSet[i].size(); ++j)		
+			psetOut.add(outPutSet[i][j]);
+
+	return resultUnion;
+}
+
+bool TeOVERLAY::TeValidPolygonHoles(TePolygon& polygon, TePolygonSet& psValid)
+{
+	string objectId = polygon.objectId();
+	int geomId = polygon.geomId();
+
+	psValid.clear();
+
+	if(polygon.size() == 0)
+		return false;
+
+	if(polygon.size() == 1)
+	{	
+		TePolygon paux;
+		paux.copyElements(polygon);
+		paux.geomId(geomId);
+		paux.objectId(objectId);
+		psValid.add(paux);
+		return true;
+	}
+
+	TePolygon fixedPolygon;
+	fixedPolygon.add(polygon[0]);
+				
+//adiciona todos os buracos em um TePolygonSet
+	TePolygonSet psHoles;
+	unsigned int i;
+	for(i = 1; i < polygon.size(); i++)
+	{
+		TePolygon hole;
+		hole.add(polygon[i]);
+
+		psHoles.add(hole);
+	}
+
+//faz a uniao dos buracos
+	TePolygonSet psOut;	
+	if(!TeOVERLAY::TeUnion(psHoles, psOut))
+		return false;
+
+	psHoles = TePolygonSet();
+	psHoles.copyElements(psOut);
+	psOut = TePolygonSet();
+
+//faz a diferenca entre o poligono original e a uniao dos seus buracos 
+	TePolygonSet psTemp;
+	psTemp.add(fixedPolygon);
+
+	if(!TeOVERLAY::TeDifference(psTemp, psHoles, psOut))
+		return false;
+		
+	for(i = 0; i < psOut.size(); i++)
+	{
+		psOut[i].geomId(geomId);
+		psOut[i].objectId(objectId);
+		psValid.add(psOut[i]);
+	}
+
+	return true;
+}
+
+bool TeOVERLAY::TeValidPolygonHoles(TePolygonSet& polygons, TePolygonSet& psValid)
+{
+	psValid.clear();
+	unsigned int i, j;
+    for(i = 0; i < polygons.size(); ++i)
+	{
+// do valid for each polygon
+        TePolygon pol = polygons[i];
+
+        TePolygonSet psAux;
+
+        if(TeValidPolygonHoles(pol, psAux))
+		{
+			for(j = 0; j < psAux.size(); ++j)
+			{
+				psValid.add(psAux[j]);
+			}
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	return true;
+}
+
diff --git a/src/terralib/kernel/TeOverlay.h b/src/terralib/kernel/TeOverlay.h
new file mode 100644
index 0000000..01b3dff
--- /dev/null
+++ b/src/terralib/kernel/TeOverlay.h
@@ -0,0 +1,214 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeOverlay.h
+    \brief This file contains structures and definitions for set operation on polygons.
+	\author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ */
+
+#ifndef  __TERRALIB_INTERNAL_OVERLAY_H
+#define  __TERRALIB_INTERNAL_OVERLAY_H
+
+#include "TeMultiGeometry.h"
+
+/**
+ * @brief Contains structures and definitions needed to execute Set Operations for polygons and lines (union, intersection e difference).
+ */
+
+namespace TeOVERLAY
+{	
+/** @defgroup SetOperations Set Operations
+ *  Set operations for polygons and lines: intersection, union or difference.
+ *  @{
+ */
+
+/** \brief Executes one of the possible Set Operations on polygons. 
+    \param redPols		The first list of disjoint polygons (and without self-intersections).
+	\param bluePols		The second list of disjoint polygons (and without self-intersections).
+	\param polsOut		The polygon list from the operation result.
+	\param operation	Type of operation: TeUNION, TeINTERSECTION or TeDIFFERENCE.
+	\return				True if the operation success and false if an error has ocurried.
+	
+	\note Each polygon list must have disjoint polygons, otherwise, the result is undefined. This function must not be called directly,
+	      instead of call it, choose a specific function below, because, this signature is deprecated and will change in near future.
+*/
+TL_DLL bool TeOverlay(const TePolygonSet& redPols, const TePolygonSet& bluePols, TePolygonSet& polsOut, const short& operation);
+
+/** \brief Calculates the union Set Operation for polygons.
+    \param redPols		The first list of disjoint polygons (and without self-intersections).
+	\param bluePols		The second list of disjoint polygons (and without self-intersections).
+	\param polsOut		The polygon list from the operation result.
+	\return				True if the operation success and false if an error has ocurried.
+
+*/
+TL_DLL bool TeUnion(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut);
+
+
+/** \brief Calculates the  intersection Set Operation for polygons.
+    \param redPols      The first list of disjoint polygons (and without self-intersections).
+	\param bluePols		The second list of disjoint polygons (and without self-intersections).
+	\param polsOut      The polygon list from the operation result.
+	\return				True if the operation success and false if an error has ocurried.
+
+*/
+TL_DLL bool TeIntersection(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut);
+
+
+/** \brief Calculates the difference set operation for polygons (redPols minus bluePols).
+    \param redPols      The first list of disjoint polygons (and without self-intersections).
+	\param bluePols		The second list of disjoint polygons (and without self-intersections).
+	\param polsOut      The polygon list from the operation result.
+	\return				True if the operation success and false if an error has ocurried.
+
+*/
+TL_DLL bool TeDifference(TePolygonSet& redPols, TePolygonSet& bluePols, TePolygonSet& polsOut);
+
+
+/** \brief Executes one of the possible Set Operations for lines and polygons. 
+    \param redLines		A disjoint line list (and without self-intersections).
+	\param bluePols		A list of disjoint polygons (and without self-intersections).
+	\param operation    Type of operation: TeUNION, TeINTERSECTION or TeDIFFERENCE.
+	\return				A geometry that can contains only lines on intersection and difference cases, and lines + polygons on union case.
+
+	\note This function must not be called directly, instead of call it, choose a specific function below,
+	      because, this signature is deprecated and will change in near future.
+
+*/
+TL_DLL TeMultiGeometry TeOverlay(const TeLineSet& redLines, const TePolygonSet& bluePols, const short& operation);
+
+
+/** \brief Calculates the union set operation for lines and polygons.
+    \param redLines     A disjoint line list (and without self-intersections).
+	\param bluePols		A list of disjoint polygons (and without self-intersections).
+	\return				A geometry formed by lines and polygons or only by polygons.
+
+*/
+TL_DLL TeMultiGeometry TeUnion(TeLineSet& redLines, TePolygonSet& bluePols);
+
+
+/** \brief Calculates the intersection set operation for lines and polygons.
+    \param redLines     A disjoint line list (and without self-intersections).
+	\param bluePols		A list of disjoint polygons (and without self-intersections).
+	\return				A geometry formed only by lines or empty.
+
+*/
+TL_DLL TeMultiGeometry TeIntersection(TeLineSet& redLines, TePolygonSet& bluePols);
+
+
+/** \brief Calculates the defference set operation for lines and polygons.
+    \param redLines     A disjoint line list (and without self-intersections).
+	\param bluePols		A list of disjoint polygons (and without self-intersections).
+	\return				A geometry formed only by lines or empty.
+
+*/
+TL_DLL TeMultiGeometry TeDifference(TeLineSet& redLines, TePolygonSet& bluePols);
+
+
+/** \brief Calculates the union of all polygons passed in polsIn parameter, and returns a polygon set (polsOut).
+    \param polsIn            A list of polygons, may have overlap (disjoint or not).
+	\param polsOut           Where the union will be stored.
+	\param makeCopy          If true, before to start the union process a copy will be done for all coordinates, otherwise, the rings and coordinates of the input polygon will be used and so, the input can be invalidate (because of handle/body share of implementaton) bu this will save some memory.
+	\param fixOrientation    If true, the ring orientation is checked, otherwise, it is assumed that they are in correct order of processing (you may set to false only if you know implementation details otherwise an error may occur).
+*/
+TL_DLL bool TeUnion(TePolygonSet& polsIn, TePolygonSet& polsOut, const bool& makeCopy = true, const bool fixOrientation = true);
+
+
+/** \brief Calculates the intersection set operation for polygons. This version of intersection will reuse some pre-processing of redPols, and will do intersection between redPols and each polygonset in bluePols vector. The result of each individual operation (redPols x a polygonset from the blue vector) will be store in the output vector in the same order of polygonsets in bluePols. If an intersection is empty, an empty polygonset will be stored to indicate this.
+    \param redPols			A list of disjoint polygons (and without self-intersections) used as a mask to cut each polygonset in bluePols vector.
+	\param bluePols			A vector that contains polygonsets that will be individually cutted by redPols, and each blue polygonset must be disjoint (and without self-intersections).
+	\param vecPolsOut       A vector with the result of intersection between redPols and each polygonset in the blue polygonset vector.
+	\param resultVec        A vector of bool that tells if individual intersection succeed or not.
+	\param makeCopy         If true, before to start the union process a copy will be done for all coordinates, otherwise, the rings and coordinates of the input polygon will be used and so, the input can be invalidate (because of handle/body share of implementaton) bu this will save some memory.
+	\param fixOrientation   If true, the ring orientation is checked, otherwise, it is assumed that they are in correct order of processing (you may set to false only if you know implementation details otherwise an error may occur).
+	\return				True if the operation success and false if an error has ocurried.
+
+	\note The output vector may contains polygonsets thar are empty, only to indicate that intersection was empty, so be carefull.
+
+*/
+TL_DLL bool TeIntersection(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy = true, const bool fixOrientation = true);
+
+
+/** \brief Calculates the union set operation for polygons.
+           This version of union will reuse some pre-processing of redPols,
+		   and will do union between redPols and each polygonset in bluePols.
+		   The result of each individual operation (redPols x a polygonset from the blue vector)
+		   will be store in the output vector in the same order of polygonsets in bluePols.
+    \param redPols			A list of disjoint polygons (and without self-intersections) used as a mask to cut each polygonset in bluePols vector.
+	\param bluePols			A vector that contains polygonsets that will be individually cutted by redPols, and each blue polygonset must be disjoint (and without self-intersections).
+	\param vecPolsOut       A vector with the result of union between redPols and each polygonset in the blue polygonset vector.
+	\param resultVec        A vector of bool that tells if individual intersection succeed or not.
+	\param makeCopy         If true, before to start the union process a copy will be done for all coordinates, otherwise, the rings and coordinates of the input polygon will be used and so, the input can be invalidate (because of handle/body share of implementaton) bu this will save some memory.
+	\param fixOrientation   If true, the ring orientation is checked, otherwise, it is assumed that they are in correct order of processing (you may set to false only if you know implementation details otherwise an error may occur).
+	\return				True if the operation success and false if an error has ocurried.
+*/
+TL_DLL bool TeUnion(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy = true, const bool fixOrientation = true);
+
+
+/** \brief Calculates the difference set operation for polygons.
+           This version of difference will reuse some pre-processing of redPols,
+		   and will do difference between redPols and each polygonset in bluePols vector.
+		   The result of each individual operation (redPols x a polygonset from the blue vector)
+		   will be store in the output vector in the same order of polygonsets in bluePols.
+		   If an intersection is empty, an empty polygonset will be stored to indicate this.
+    \param redPols			A list of disjoint polygons (and without self-intersections) used as a mask to cut each polygonset in bluePols vector.
+	\param bluePols			A vector that contains polygonsets that will be individually cutted by redPols, and each blue polygonset must be disjoint (and without self-intersections).
+	\param vecPolsOut       A vector with the result of differnce between redPols and each polygonset in the blue polygonset vector.
+	\param resultVec        A vector of bool that tells if individual intersection succeed or not.
+	\param makeCopy         If true, before to start the union process a copy will be done for all coordinates, otherwise, the rings and coordinates of the input polygon will be used and so, the input can be invalidate (because of handle/body share of implementaton) bu this will save some memory.
+	\param fixOrientation   If true, the ring orientation is checked, otherwise, it is assumed that they are in correct order of processing (you may set to false only if you know implementation details otherwise an error may occur).
+	\return				True if the operation success and false if an error has ocurried.
+
+	\note The output vector may contains polygonsets thar are empty, only to indicate that intersection was empty, so be carefull.
+*/
+TL_DLL bool TeDifference(TePolygonSet& redPols, vector<TePolygonSet>& bluePols, vector<TePolygonSet>& vecPolsOut, vector<bool>& resultVec, const bool& makeCopy = true, const bool fixOrientation = true);
+
+/** \brief Calculates the union of all polygons passed in polsIn parameter,
+           and returns a polygon set (polsOut).
+	       This type of union use a different strategy from the
+		   previous one: do union for each pair and
+		   then repeat until we have only two pairs.
+    \param psetIn            A list of polygons, may have overlap (disjoint or not).
+	\param psetOut           Where the union will be stored.
+ */
+TL_DLL bool TePairUnion(TePolygonSet& psetIn, TePolygonSet& psetOut);
+
+/** \brief Valid polygon holes: if they have a commom edge,
+           they will be joined (THIS IS FOR INTERNAL USE ONLY).
+	\param  polygon		The polygon to check holes.
+	\param  psValid		The result polygon.
+	\return				Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeValidPolygonHoles(TePolygon& polygon, TePolygonSet& psValid);
+
+/** \brief Valid polygon holes: if they have a commom edge, they will be joined (THIS IS FOR INTERNAL USE ONLY).
+	\param  polygons	The polygons to check holes.
+	\param  psValid		The result polygon.
+	\return				Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeValidPolygonHoles(TePolygonSet& polygons, TePolygonSet& psValid);
+
+/** @} */ 
+
+}	// end namespace TeOVERLAY
+
+#endif //__TERRALIB_INTERNAL_OVERLAY_H
+
diff --git a/src/terralib/kernel/TeOverlayUtils.cpp b/src/terralib/kernel/TeOverlayUtils.cpp
new file mode 100644
index 0000000..2f178b5
--- /dev/null
+++ b/src/terralib/kernel/TeOverlayUtils.cpp
@@ -0,0 +1,1222 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright 2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeOverlayUtils.h"
+#include "TeGeometryAlgorithms.h"
+
+//---------------- Auxiliary operations for overlay ----------------//
+
+inline void TeOverlayMiddle(const TeCoord2D& c1, const TeCoord2D& c2, TeCoord2D& m)
+{
+	m.x_ = ((c1.x_ + c2.x_) / 2.0);
+	m.y_ = ((c1.y_ + c2.y_) / 2.0);
+}
+
+// Verifies orientation for each line of polygon set, and reverse the orientation if need
+void TeOVERLAY::TeFixOrientation(TePolygonSet& polSet, const short& outerOrientationToReverse, const short& innerOrientationToReverse)
+{
+	unsigned int polSetSize = polSet.size();
+
+	for(unsigned int i = 0; i < polSetSize; ++i)
+	{
+		if(TeOrientation(polSet[i][0]) == outerOrientationToReverse)
+			reverse(polSet[i][0].begin(), polSet[i][0].end());
+
+		unsigned int polSize = polSet[i].size();
+
+		for(unsigned int j = 1; j < polSize; ++j)
+		{
+			if(TeOrientation(polSet[i][j]) == innerOrientationToReverse)
+				reverse(polSet[i][j].begin(), polSet[i][j].end());
+		}
+	}
+}
+
+// For each operation (union, intersection and difference) defines location for retrieval of fragments
+void TeOVERLAY::TeChooseBoundaryLocation(const short& operation, short& locationRedFragments, short& locationBlueFragments)
+{
+	switch(operation)
+	{							
+// intersection: gets all fragments from red polygon wich are
+// inside the blue polygon and the blue fragments that are inside
+// the red polygon.
+		case TeINTERSECTION:  locationRedFragments  = TeINSIDE;
+			                  locationBlueFragments = TeINSIDE;
+							  break;
+
+// union: gets all fragments from red polygon wich are
+// outside the blue polygon and the blue fragments that are outside
+// the red polygon.
+		case TeUNION:         locationRedFragments  = TeOUTSIDE;
+			                  locationBlueFragments = TeOUTSIDE;
+							  break;
+
+// difference: gets all fragments from red polygon wich are
+// outside the blue polygon and the blue fragments that are inside
+// the red polygon.
+		case TeDIFFERENCE:	  locationRedFragments  = TeOUTSIDE;
+			                  locationBlueFragments = TeINSIDE;
+		                      break;
+	}
+}
+
+// Erases from fragmentsIndex boundary fragments that are in oposite direction: each fragment must have a unique identifier in the pair first field (pair<unsigned int, TeLine2D>)
+void TeOVERLAY::TeRemoveOpositeBoundaryFragments(TeLineIndex& fragmentsIndex)
+{
+	TeLineIndex::iterator indexIterator = fragmentsIndex.begin();
+	
+	while(indexIterator != fragmentsIndex.end())
+	{
+		pair<TeLineIndex::iterator, TeLineIndex::iterator> its = fragmentsIndex.equal_range(indexIterator->second.second[(indexIterator->second.second.size() - 1u)]);
+
+		bool eraseOwn = false;
+
+        while(its.first != its.second)
+		{
+// Se nao achei o proprio fragmento, entao posso ver se e possivel apagar
+			if(its.first->second.first != indexIterator->second.first)
+			{
+				if(TeEquals(its.first->second.second[its.first->second.second.size() - 1u], indexIterator->second.second[0u]))
+				{
+					TeLineIndex::iterator idxAux2 = its.first;
+					++(its.first);
+					fragmentsIndex.erase(idxAux2);
+
+					eraseOwn = true;
+				}
+				else
+				{
+					++(its.first);
+				}
+			}
+			else
+			{
+				++(its.first);
+			}
+		}
+
+		if(eraseOwn)
+		{
+			fragmentsIndex.erase(indexIterator);
+			indexIterator = fragmentsIndex.begin();
+		}
+		else
+		{
+			++indexIterator;
+		}
+	}
+}
+
+// Erases from fragmentsIndex boundary fragments that are equals to another boundary fragment
+void TeOVERLAY::TeRemoveSameBoundaryFragments(TeLineIndex& fragmentsIndex)
+{
+	TeLineIndex::iterator indexIterator = fragmentsIndex.begin();
+	
+	while(indexIterator != fragmentsIndex.end())
+	{
+		pair<TeLineIndex::iterator, TeLineIndex::iterator> its = fragmentsIndex.equal_range(indexIterator->second.second[0u]);
+
+        while(its.first != its.second)
+		{
+// Se nao achei o proprio fragmento, entao posso ver se e possivel apagar
+			if(its.first->second.first != indexIterator->second.first)
+			{
+				if(TeEquals(its.first->second.second[its.first->second.second.size() - 1u], indexIterator->second.second[indexIterator->second.second.size() - 1u]))
+				{
+					TeLineIndex::iterator idxAux2 = its.first;
+					++(its.first);
+					fragmentsIndex.erase(idxAux2);
+				}
+				else
+				{
+					++(its.first);
+				}
+			}
+			else
+			{
+				++(its.first);
+			}
+		}
+
+		++indexIterator;
+	}
+}
+
+// Merge fragments ito first index (fragmentsIndex)
+void TeOVERLAY::TeJoinFragments(TeLineIndex& fragmentsIndex, TeLineIndex& boundaryFragmentsIndex)
+{
+	TeLineIndex::iterator indexIterator = boundaryFragmentsIndex.begin();
+
+	while(indexIterator != boundaryFragmentsIndex.end())
+	{
+		fragmentsIndex.insert(*indexIterator);
+		++indexIterator;
+	}
+
+	boundaryFragmentsIndex.clear();	
+}
+
+// Moves closed rings from fragmentsIndex to rins vector
+void TeOVERLAY::TeFindAndMoveClosedRings(TeLineIndex& fragmentsIndex, vector<TeLinearRing>& rings)
+{
+	TeLineIndex::iterator indexIterator = fragmentsIndex.begin();
+
+	while(indexIterator != fragmentsIndex.end())
+	{
+		if(indexIterator->second.second.isRing())
+		{
+			rings.push_back(indexIterator->second.second);
+
+			TeLineIndex::iterator idxAux;
+			idxAux = indexIterator;
+			++indexIterator;
+			fragmentsIndex.erase(idxAux);
+		}
+		else
+			++indexIterator;
+	}
+}
+
+// Gets a polygonset with outer rings and a vector with holes and try to find to what polygon the hole belongs to
+bool TeOVERLAY::TeMountTopology(TePolygonSet& polysOut, vector<TeLinearRing>& holes)
+{
+	bool returnValue = true;
+
+	if((polysOut.size() == 0) && (holes.size() > 0))
+	{
+// Formou buracos e nao formou os aneis externos
+		return false;	
+	}
+
+	if(polysOut.size() == 1)
+	{
+		for(unsigned int i = 0; i < holes.size(); ++i)
+			polysOut[0].add(holes[i]);		
+	}
+	else
+	{
+		for(unsigned int i = 0; i < holes.size(); ++i)
+		{
+			TeLinearRing ring = holes[i];
+
+			vector<TePolygon> candidates;
+			vector<unsigned int> candidatesPos;
+
+			unsigned int j = 0;
+
+			for(j = 0; j < polysOut.size(); ++j)
+			{
+				if(TeWithinOrCoveredByOrEquals(ring.box(), polysOut[j].box()))
+				{
+					candidates.push_back(polysOut[j]);
+					candidatesPos.push_back(j);
+				}
+			}
+
+			if(candidates.size() == 1)
+			{
+				candidates[0].add(ring);
+				continue;
+			}
+
+			vector<TePolygon> newCandidates;
+
+			for(j = 0; j < candidates.size(); ++j)
+			{
+				short rel = TeBOUNDARY;
+
+				unsigned int nthVert = ring.size();
+				unsigned int iVert = 0u;
+
+				while(iVert < nthVert)
+				{
+					rel = TeRelation(ring[iVert], candidates[j][0]);
+
+					if(rel & TeINSIDE)
+					{				
+						newCandidates.push_back(candidates[j]);
+						break;
+					}
+					else if(rel & TeOUTSIDE)
+					{
+						break;
+					}
+				
+					++iVert;
+				}
+
+				if(iVert == nthVert)	
+				{
+// Topologycal error: every point is on ring boundary...
+					returnValue = false;
+
+					TePolygon topTest;
+					topTest.add(ring);
+
+					short whatRel = TeRelation(topTest, candidates[j]);
+
+// Se um buraco for igual ao exterior, existe um erro topologico
+// No momento, eliminamos o anel externo
+// e o interno... 
+// Se o buraco for coberto pelo poligono externo, entao ele ira ficar dentro deste
+// Caso contrario e erro sem possibilidades...
+					if(whatRel & TeEQUALS)
+					{						
+						polysOut.erase(candidatesPos[j]);
+						continue;
+					}
+				}				
+			}
+
+			if(newCandidates.size() <= 0)
+			{
+// Didn't find outer ring to this hole.
+				returnValue = false;
+				continue;
+			}
+
+			int idxMinArea = 0;
+			
+			double minArea = TeMAXFLOAT;
+
+			for(j = 0; j < newCandidates.size(); ++j)
+			{
+				if(TeGeometryArea(newCandidates[j].box()) < minArea)
+				{
+					idxMinArea = j;
+					minArea = TeGeometryArea(newCandidates[j].box());
+				}
+			}
+
+			newCandidates[idxMinArea].add(ring);
+		}
+	}
+
+	return returnValue;
+}
+
+// faz a tentativa ingenua!
+bool TeMergeFragmentsFB(TeOVERLAY::TeLineIndex& fragmentsIndex, TeLine2D& line)
+{
+	TeCoord2D endLineCoordinate = line[line.size() - 1];
+
+	TeOVERLAY::TeLineIndex::iterator indexIterator  = fragmentsIndex.begin();
+
+	while(indexIterator != fragmentsIndex.end())
+	{
+		if(TeEquals(endLineCoordinate, indexIterator->second.second[0]))
+		{
+			for(unsigned int i = 1; i < indexIterator->second.second.size(); ++i)
+				line.add(indexIterator->second.second[i]);
+
+			line.setBox(::TeUnion(line.box(), indexIterator->second.second.box()));
+			fragmentsIndex.erase(indexIterator);
+
+			return true;
+		}
+
+		++indexIterator;
+	}
+
+	return false;
+}
+
+// Make polygons from fragments.
+bool TeOVERLAY::TeMergeFragments(TeLineIndex& fragmentsIndex, vector<TeLinearRing>& rings, const bool& doExaustive)
+{
+	bool returnValue = true;
+
+	TeLine2D  lAux;	
+	TeCoord2D endLineCoordinate;
+
+	while(!(fragmentsIndex.empty()))
+	{
+		if(lAux.size() == 0)
+		{
+			TeLineIndex::iterator indexIterator  = fragmentsIndex.begin();
+			
+			if(indexIterator != fragmentsIndex.end())
+			{
+				if(indexIterator->second.second.isRing())
+				{
+					rings.push_back(indexIterator->second.second);
+					fragmentsIndex.erase(indexIterator);
+					continue;
+				}
+				
+				for(unsigned int i = 0; i < indexIterator->second.second.size(); ++i)
+					lAux.add(indexIterator->second.second[i]);
+
+				lAux.setBox(::TeUnion(lAux.box(), indexIterator->second.second.box()));
+
+				fragmentsIndex.erase(indexIterator);
+			}
+			else
+			{
+                returnValue = false;	//Nao poderia vir aqui, deveria ter saido no teste do laco!!
+			}
+		}	
+		else
+		{
+			endLineCoordinate = lAux[lAux.size() - 1];
+
+			// Try to find the beginning of the next fragment that is part of the polygon in the same list
+			TeLineIndex::iterator indexIterator = fragmentsIndex.find(endLineCoordinate);
+
+			if(indexIterator != fragmentsIndex.end())
+			{
+				for(unsigned int i = 1; i < indexIterator->second.second.size(); ++i)
+					lAux.add(indexIterator->second.second[i]);
+
+				lAux.setBox(::TeUnion(lAux.box(), indexIterator->second.second.box()));
+				fragmentsIndex.erase(indexIterator);
+			}			
+			else
+			{
+				if(doExaustive)
+				{
+					if(!TeMergeFragmentsFB(fragmentsIndex, lAux))
+					{
+	// Nao foi achada continuacao para a linha: nao fechou!
+						returnValue = false;	// Erro na topologia dos poligonos
+
+						// Clear auxiliary.
+						TeLine2D emptyLine;
+						lAux = emptyLine;
+					}
+				}
+				else
+				{
+					// Nao foi achada continuacao para a linha: nao fechou!
+					returnValue = false;	// Erro na topologia dos poligonos
+
+					// Clear auxiliary.
+					TeLine2D emptyLine;
+					lAux = emptyLine;
+				}
+			}
+			
+		}
+
+		if(lAux.isRing())
+		{  
+			// Add polygon
+			rings.push_back(TeLinearRing(lAux));
+			
+			// Clear auxiliary.
+			TeLine2D emptyLine;					
+			lAux = emptyLine;
+		}
+	}
+
+	if(lAux.size() > 0)
+		returnValue = false;	// Erro, alguma linha nao fechou!!!
+
+	return returnValue;
+}
+
+// For each linear ring, see it's orientation and classify in outer or inner ring
+bool TeOVERLAY::TeClassifyRings(vector<TeLinearRing>& rings, TePolygonSet& polsOut, vector<TeLinearRing>& holes)
+{
+	bool returnValue = true;
+
+	for(unsigned int z = 0; z < rings.size(); ++z)
+	{
+		short ori = TeOrientation(rings[z]);
+
+		if(ori == TeCOUNTERCLOCKWISE)	// It is a hole
+		{
+			holes.push_back(rings[z]);			// add to holes list
+		}
+		else if(ori == TeCLOCKWISE)		// else if island
+		{										// create a polygon
+			TePolygon p;
+			p.add(rings[z]);
+			polsOut.add(p);
+		}
+		else	
+		{
+			returnValue = false;	// Objeto sem area? Isso e um erro!
+		}
+	}
+
+	return returnValue;
+}
+
+// Seleciona os fragmentos quando existem dois conjuntos distintos: vermelho e azul
+void TeOVERLAY::TeRtreeGetFragments(const TePolygonSet& bluePolygons, TeINTERSECTOR2::TeSegmentRTree& blueTree, TeLineSet& redFragments, const short& locationFragments, short& mask, TeLineIndex& redFragmentsIndex, vector<TeLinearRing>& rings)
+{
+	//unsigned int lastId = redFragmentsIndex.size();
+
+	unsigned int redFragmentsSize = redFragments.size();	
+
+	TeBox b = blueTree.getBox();
+
+	for(unsigned int i = 0; i < redFragmentsSize; ++i)
+	{
+// Para cada fragmento vermelho escolhe um ponto para determinar a localizacao do fragmento
+		TeCoord2D middle;
+
+		unsigned int fragSize = redFragments[i].size();
+
+		TeCoord2D& cfrom = redFragments[i][0];
+		TeCoord2D& cto = redFragments[i][1];
+
+		if(fragSize ==  2)	// If the fragment has two points I need to check the middle point of this fragment.
+			TeOverlayMiddle(redFragments[i][0], redFragments[i][1], middle);
+		else	// If the fragment has more than two points so I check one point between the end points.
+			middle = redFragments[i][(unsigned int)((double(redFragments[i].size()) / 2.0 + 0.6)) - 1];
+
+// Monta um raio horizontal que vai ate o extremo de todos os poligonos, partindo do ponto medio (middle)
+		TeCoord2D c2 = middle;
+		c2.x_ = b.x2();
+
+		TeBox searchBox(middle, c2);
+
+		vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+
+        blueTree.search(searchBox, segs);
+
+        unsigned int nSegsInter = segs.size();
+
+// se nao achou nenhum segmento cruzando o raio, significa que o fragmento esta todo fora
+		if(nSegsInter > 0)
+		{
+// ordena os segmentos azuis para permitir realizar o teste de ponto em poligono
+			sort(segs.begin(), segs.end(), segOrder());
+
+			bool inside_flag = false;
+
+			unsigned int currentPolId = segs[0].polId_;
+
+			double tx = middle.x();
+		    double ty = middle.y();
+
+			int yflag0, yflag1;
+
+			for(unsigned int j = 0; j < nSegsInter; ++j)
+			{
+// Se passamos aos segmentos de outro poligono, temos que zerar o numero de cruzamentos
+				if(currentPolId != segs[j].polId_)
+				{
+					if(inside_flag)
+						break;
+
+					currentPolId = segs[j].polId_;
+				}
+
+				const TeCoord2D& vtx0 = bluePolygons[segs[j].polId_][segs[j].lineId_][segs[j].segId_];
+				const TeCoord2D& vtx1 = bluePolygons[segs[j].polId_][segs[j].lineId_][segs[j].segId_ + 1];
+
+				if((fragSize == 2) && (TeIsOnSegment(middle, vtx0, vtx1)))
+				{
+					
+					if((TeEquals(vtx0, cfrom) || TeEquals(vtx0, cto)) && (TeEquals(vtx1, cfrom) || TeEquals(vtx1, cto)))
+					{
+						if(locationFragments & TeINSIDE)
+							inside_flag = false;
+						else
+							inside_flag = true;						
+
+						break;
+					}
+				}
+
+				yflag0 = (vtx0.y() >= ty);
+				yflag1 = (vtx1.y() >= ty);
+
+				if(yflag0 != yflag1)
+				{
+					if(((vtx1.y() - ty) * (vtx0.x() - vtx1.x()) >=
+						(vtx1.x() - tx) * (vtx0.y() - vtx1.y())) == yflag1)
+					{
+						inside_flag = !inside_flag ;
+					}
+				}
+			}
+
+// ao sair do laco acima, se inside_flag for verdadeiro, entao o fragmento esta dentro, caso contrario, ele esta fora
+			if(inside_flag && (locationFragments & TeINSIDE))
+			{
+				if(redFragments[i].isRing())
+					rings.push_back(redFragments[i]);
+				else
+					redFragmentsIndex.insert(TeLineIndex::value_type(redFragments[i][0], pair<unsigned int, TeLine2D>(i, redFragments[i])));
+
+				mask |= TeINSIDE;
+			}
+			else if(!inside_flag && (locationFragments & TeOUTSIDE))
+			{
+				if(redFragments[i].isRing())
+					rings.push_back(redFragments[i]);
+				else
+					redFragmentsIndex.insert(TeLineIndex::value_type(redFragments[i][0], pair<unsigned int, TeLine2D>(i, redFragments[i])));
+
+				mask |= TeOUTSIDE;
+			}
+		}
+		else	// fragmento esta fora
+		{
+// Se a localizacao do fragmento for compativel, pegamos ele.
+			if(locationFragments & TeOUTSIDE)
+			{
+				if(redFragments[i].isRing())
+					rings.push_back(redFragments[i]);
+				else
+					redFragmentsIndex.insert(TeLineIndex::value_type(redFragments[i][0], pair<unsigned int, TeLine2D>(i, redFragments[i])));
+			}
+
+			mask |= TeOUTSIDE;
+		}
+	}
+}
+
+// Operacao especial que descobre a localizacao do fragmento dentro do proprio conjunto: usado na operacao de uniao otimizada
+void TeOVERLAY::TeRtreeGetFragments(const TePolygonSet& polygons, TeINTERSECTOR2::TeSegmentRTree& tree, TeLineSet& fragments, vector<pair<unsigned int, unsigned int> >& fragmentsIds, const short& locationFragments, short& mask, TeLineIndex& fragmentsIndex, vector<TeLinearRing>& rings)
+{
+	unsigned int fragmentsSize = fragments.size();	
+
+	TeBox b = tree.getBox();
+
+	for(unsigned int i = 0; i < fragmentsSize; ++i)
+	{
+// Para cada fragmento escolhe um ponto para determinar a localizacao do fragmento
+		TeCoord2D middle;
+
+		unsigned int fragSize = fragments[i].size();
+
+		TeCoord2D& cfrom = fragments[i][0];
+		TeCoord2D& cto = fragments[i][1];
+
+		if(fragSize ==  2)	// If the fragment has two points I need to check the middle point of this fragment.
+			TeOverlayMiddle(fragments[i][0], fragments[i][1], middle);
+		else	// If the fragment has more than two points so I check one point between the end points.
+			middle = fragments[i][(unsigned int)((double(fragments[i].size()) / 2.0 + 0.6)) - 1];
+
+// Monta um raio horizontal que vai ate o extremo de todos os poligonos, partindo do ponto medio (middle)
+		TeCoord2D c2 = middle;
+		c2.x_ = b.x2();
+
+		TeBox searchBox(middle, c2);
+
+		vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+
+        tree.search(searchBox, segs);
+
+        unsigned int nSegsInter = segs.size();
+
+// se nao achou nenhum segmento cruzando o raio, significa que o fragmento esta todo fora
+		if(nSegsInter > 0)
+		{
+// ordena os segmentos para permitir realizar o teste de ponto em poligono
+			sort(segs.begin(), segs.end(), segOrder());
+
+			bool inside_flag = false;
+
+			unsigned int currentPolId = segs[0].polId_;
+
+			double tx = middle.x();
+		    double ty = middle.y();
+
+			int yflag0, yflag1;
+
+			for(unsigned int j = 0; j < nSegsInter; ++j)
+			{
+// Se passamos aos segmentos de outro poligono, temos que zerar o numero de cruzamentos
+				if(currentPolId != segs[j].polId_)
+				{
+					if(inside_flag)
+						break;
+
+					currentPolId = segs[j].polId_;
+				}
+
+// Se os segmentos que estamos tratando sao do fratgmento, entao pulamos
+				if(segs[j].polId_ == fragmentsIds[i].first)
+					continue;
+
+				const TeCoord2D& vtx0 = polygons[segs[j].polId_][segs[j].lineId_][segs[j].segId_];
+				const TeCoord2D& vtx1 = polygons[segs[j].polId_][segs[j].lineId_][segs[j].segId_ + 1];
+
+				if((fragSize == 2) && (TeIsOnSegment(middle, vtx0, vtx1)))
+				{
+					
+					if((TeEquals(vtx0, cfrom) || TeEquals(vtx0, cto)) && (TeEquals(vtx1, cfrom) || TeEquals(vtx1, cto)))
+					{
+						if(locationFragments & TeINSIDE)
+							inside_flag = false;
+						else
+							inside_flag = true;
+
+						break;
+					}
+				}
+
+				yflag0 = (vtx0.y() >= ty);
+				yflag1 = (vtx1.y() >= ty);
+
+				if(yflag0 != yflag1)
+				{
+					if(((vtx1.y() - ty) * (vtx0.x() - vtx1.x()) >=
+						(vtx1.x() - tx) * (vtx0.y() - vtx1.y())) == yflag1)
+					{
+						inside_flag = !inside_flag ;
+					}
+				}
+			}
+
+// ao sair do laco acima, se inside_flag for verdadeiro, entao o fragmento esta dentro, caso contrario, ele esta fora
+			if(inside_flag && (locationFragments & TeINSIDE))
+			{
+				if(fragments[i].isRing())
+					rings.push_back(fragments[i]);
+				else
+					fragmentsIndex.insert(TeLineIndex::value_type(fragments[i][0], pair<unsigned int, TeLine2D>(i, fragments[i])));
+			}
+			else if(!inside_flag && (locationFragments & TeOUTSIDE))
+			{
+				if(fragments[i].isRing())
+					rings.push_back(fragments[i]);
+				else
+					fragmentsIndex.insert(TeLineIndex::value_type(fragments[i][0], pair<unsigned int, TeLine2D>(i, fragments[i])));
+			}
+
+		}
+		else	// fragmento esta fora
+		{
+// Se a localizacao do fragmento for compativel, pegamos ele.
+			if(locationFragments & TeOUTSIDE)
+			{
+				if(fragments[i].isRing())
+					rings.push_back(fragments[i]);
+				else
+					fragmentsIndex.insert(TeLineIndex::value_type(fragments[i][0], pair<unsigned int, TeLine2D>(i, fragments[i])));
+			}
+
+			mask |= TeOUTSIDE;
+		}
+	}
+}
+
+// Operacao especial que descobre a localizacao do fragmento dentro do proprio conjunto: usado na operacao de uniao otimizada
+void TeOVERLAY::TeRtreeRemoveFragments(const TePolygonSet& polygons, TeINTERSECTOR2::TeSegmentRTree& tree,
+		TeLineIndex &lineIndex, vector<pair<unsigned int, unsigned int> >& fragmentsIds,
+		const short& locationFragments, short& mask, vector<TeLinearRing>& /* rings */)
+{
+	TeBox b = tree.getBox();
+
+	TeLineIndex::iterator indexIterator = lineIndex.begin();
+	
+	while(indexIterator != lineIndex.end())
+	{
+		TeCoord2D middle;
+		TeOverlayMiddle(indexIterator->second.second[0], indexIterator->second.second[1], middle);
+
+		// Monta um raio horizontal que vai ate o extremo de todos os poligonos, partindo do ponto medio (middle)
+		TeCoord2D c2 = middle;
+		c2.x_ = b.x2();
+
+		TeBox searchBox(middle, c2);
+
+		vector<TeINTERSECTOR2::TeSegIdInPolygonSet> segs;
+
+        tree.search(searchBox, segs);
+
+        unsigned int nSegsInter = segs.size();
+
+		// se nao achou nenhum segmento cruzando o raio, significa que o fragmento esta todo fora
+		if(nSegsInter > 0)
+		{
+// ordena os segmentos para permitir realizar o teste de ponto em poligono
+			sort(segs.begin(), segs.end(), segOrder());
+
+			bool inside_flag = false;
+
+			unsigned int currentPolId = segs[0].polId_;
+
+			double tx = middle.x();
+		    double ty = middle.y();
+
+			int yflag0, yflag1;
+
+			for(unsigned int j = 0; j < nSegsInter; ++j)
+			{
+// Se passamos aos segmentos de outro poligono, temos que zerar o numero de cruzamentos
+				if(currentPolId != segs[j].polId_)
+				{
+					if(inside_flag)
+						break;
+
+					currentPolId = segs[j].polId_;
+				}
+
+// Se os segmentos que estamos tratando sao do fragmento, entao pulamos
+				if(segs[j].polId_ == fragmentsIds[indexIterator->second.first].first)
+					continue;
+
+				const TeCoord2D& vtx0 = polygons[segs[j].polId_][segs[j].lineId_][segs[j].segId_];
+				const TeCoord2D& vtx1 = polygons[segs[j].polId_][segs[j].lineId_][segs[j].segId_ + 1];
+
+				// o ponto esta no segmeto de vertices vtx0 e vtx1?
+				// se sim setar inside_flag como false e avancar o j ate mudar de poligino e pula pro inicio dessa secao (continue)
+				if(TeIsOnSegment(middle, vtx0, vtx1))
+				{
+					inside_flag = false;
+
+					while((j < nSegsInter) && currentPolId == segs[j].polId_)
+						++j;
+
+					if(j >= nSegsInter)
+						break;
+
+					--j;
+
+					continue;
+				}
+
+				yflag0 = (vtx0.y() >= ty);
+				yflag1 = (vtx1.y() >= ty);
+
+				if(yflag0 != yflag1)
+				{
+					if(((vtx1.y() - ty) * (vtx0.x() - vtx1.x()) >=
+						(vtx1.x() - tx) * (vtx0.y() - vtx1.y())) == yflag1)
+					{
+						inside_flag = !inside_flag ;
+					}
+				}
+			}
+
+// ao sair do laco acima, se inside_flag for verdadeiro, entao o fragmento esta dentro, caso contrario, ele esta fora
+			if(inside_flag && (locationFragments & TeINSIDE))
+			{
+				TeLineIndex::iterator it_aux =	indexIterator;
+				++(indexIterator);
+				lineIndex.erase(it_aux);				
+			}
+			else if(!inside_flag && (locationFragments & TeOUTSIDE))
+			{
+				TeLineIndex::iterator it_aux =	indexIterator;
+				++(indexIterator);
+				lineIndex.erase(it_aux);
+			}
+			else
+			{
+				++(indexIterator);
+			}
+
+		}
+		else	// fragmento esta fora
+		{
+// Se a localizacao do fragmento for compat�vel, pegamos ele.
+			if(locationFragments & TeOUTSIDE)
+			{
+				TeLineIndex::iterator it_aux =	indexIterator;
+				++(indexIterator);
+				lineIndex.erase(it_aux);				
+			}
+			else
+			{
+				++(indexIterator);
+			}
+
+			mask |= TeOUTSIDE;
+		}
+	}
+}
+
+// estrutura auxiliar utilizada no codigo do split
+struct TeSplitCoordSort
+{
+	bool operator()(pair<unsigned int, TeCoord2D> p1, pair<unsigned int, TeCoord2D> p2) const
+	{
+		if(p1.second.x() < p2.second.x())
+			return true;	
+		if(p1.second.x() > p2.second.x())
+			return false;
+		if(p1.second.y() < p2.second.y())
+			return true;	
+		if(p1.second.y() > p2.second.y())
+			return false;
+		if(p1.first < p2.first)
+			return true;
+
+		return false;
+	}
+};
+
+// estrutura auxiliar utilizada no codigo do split
+struct TeSIP
+{
+	vector<unsigned int>	indexes_;		
+	TeCoord2D				coord_;
+	bool					used_;
+
+	TeSIP() 
+	{
+	}
+
+	TeSIP(const TeCoord2D& coord)
+	{
+		indexes_.clear();
+		coord_ = coord;		
+		used_ = false;
+	}
+
+	bool exists(const unsigned int index)
+	{
+		for(unsigned int i = 0; i < indexes_.size(); i++)
+		{
+			if(index == indexes_[i])
+			{
+				return true;
+			}
+		}
+		return false;
+	}
+
+	unsigned int getFirstIndex()
+	{
+		unsigned int first = indexes_[0];
+		for(unsigned int i = 1; i < indexes_.size(); i++)
+		{
+			if(indexes_[i] < first)
+			{
+				first = indexes_[i];
+			}
+		}
+		return first;
+	}
+	unsigned int getLastIndex()
+	{
+		unsigned int last = indexes_[0];
+		for(unsigned int i = 1; i < indexes_.size(); i++)
+		{
+			if(indexes_[i] > last)
+			{
+				last = indexes_[i];
+			}
+		}
+		return last;
+	}
+};
+
+// funcao auxiliar
+inline bool TeSEquals(const TeCoord2D& c1, const TeCoord2D& c2)
+{
+	return (c1.x() == c2.x()) && (c1.y() == c2.y());
+}
+
+// estrutura auxiliar do split
+struct TeSFragment
+{
+	unsigned int	initialIndex_; //indice da coordenada inicial do fragmento
+	TeLine2D		line_;
+
+	TeSFragment()
+	{
+	}
+
+	TeSFragment(const unsigned int &initialIndex, const TeCoord2D &coord)
+	{
+		initialIndex_ = initialIndex;
+		line_.add(coord);
+	}
+};
+
+// Make rings from split fragments
+inline bool TeSMergeFragments(vector<TeSFragment> &fragments, vector<TeLinearRing>& rings)
+{
+	unsigned int fragmentsSize = fragments.size();
+
+	TeOVERLAY::TeLineIndex fragmentsIndex;
+
+	for(unsigned int i = 0; i < fragmentsSize; ++i)
+
+		fragmentsIndex.insert(TeOVERLAY::TeLineIndex::value_type(fragments[i].line_[0], pair<unsigned int, TeLine2D>(0, fragments[i].line_)));
+	return TeOVERLAY::TeMergeFragments(fragmentsIndex, rings);}
+
+
+bool TeOVERLAY::TeSplitRing(TeLinearRing& ring, TeLineSet& ringsOut)
+{
+	ringsOut.clear();
+
+	unsigned int ringSize = ring.size();
+
+	if(ringSize == 0)
+		return false;
+	
+//vector para armazenar os pontos da linha e sua respectiva posicao
+	vector< pair<unsigned int, TeCoord2D> > vecCoords;
+
+//adiciona os segmentos num vector de pontos, contendo o indice e a coordenada
+	for(unsigned int i = 0; i < ringSize; i++)
+	{
+		vecCoords.push_back( pair<unsigned int, TeCoord2D>(i, ring[i]));
+	}
+	unsigned int vecCoordsSize = vecCoords.size();
+
+	sort(vecCoords.begin(), vecCoords.end(), TeSplitCoordSort());
+
+	vector<TeSIP> ips;
+
+	bool usou = false;
+	//varre todas as coordenadas procurando por pontos de interseccao
+	for(unsigned int i = 1; i < vecCoordsSize; i++)
+	{	
+		//se o ponto corrente for igual ao anterior, entao existe interseccao
+		if(TeSEquals(vecCoords[i-1].second, vecCoords[i].second))
+		{
+			//armazenamos o ponto de interseccao e todos os indices em que este ponto apareceu
+			if(!usou)
+			{
+				//na primeira vez, criamos o ponto de interseccao
+				TeSIP ip(vecCoords[i].second);
+				ip.indexes_.push_back(vecCoords[i-1].first);
+				ip.indexes_.push_back(vecCoords[i].first);
+
+				ips.push_back(ip);
+
+				usou = true;
+			}
+			else
+			{
+				//da segunda em diante, apenas anotamos o indice em que este ponto apareceu
+				ips[ips.size() - 1].indexes_.push_back(vecCoords[i].first);				
+			}
+		}
+		else
+		{
+			usou = false;
+		}		
+	}
+
+	//so existe interseccao entre o inicio e o fim do pol
+	if(ips.size() == 1)
+	{
+		ringsOut.add(ring);	
+		return true;
+	}
+
+	//Gera os fragmentos
+	vector< TeSFragment > fragments;
+	TeSFragment currentFragment(0, ring[0]);
+
+	//vamos remontar a linha
+	for(unsigned int i = 1; i < ringSize; i++)
+	{		
+		unsigned int currentIPindex = 0;
+		bool isIP = false;
+		//verifica se o ponto corrente e um ponto de interseccao
+		for(unsigned j = 0; j < ips.size(); j++)
+		{
+			if(ips[j].exists(i))
+			{				
+				currentIPindex = j;
+				isIP = true;
+				break;
+			}
+		}		
+
+		///adiciono a coordenada corrente ao fragmento corrente
+		currentFragment.line_.add(ring[i]);
+
+		if(isIP)
+		{
+			//se fechou um anel, adiciona na lista de aneis
+			// e remove o ponto de interseccao corrente
+			if(currentFragment.line_.isRing())
+			{
+				ringsOut.add(currentFragment.line_);
+			}
+			else
+			{
+				//verifica se o IP ja passamos por este IP alguma vez
+				//se ja passamos, vamos formar um poligono com os fragmentos entre eles
+				if(ips[currentIPindex].used_)
+				{					
+					//se nao foi formado um anel, pegamos todos os fragmentos entre estes pontos de interseccao e
+					//tentamos formar um anel
+					unsigned int firstIndex = ips[currentIPindex].getFirstIndex();
+					unsigned int lastIndex = ips[currentIPindex].getLastIndex();
+
+					vector<unsigned int> remover;
+					vector< TeSFragment > auxFragments;
+					auxFragments.push_back(currentFragment);
+					for(unsigned int j = 0; j<fragments.size(); j++)
+					{			
+						if(fragments[j].initialIndex_ >= firstIndex &&  fragments[j].initialIndex_ < lastIndex )
+						{
+							remover.push_back(j);
+							auxFragments.push_back(fragments[j]);
+						}
+					}
+					vector<TeLinearRing> r;
+					if(auxFragments.size() >=2 && TeSMergeFragments(auxFragments, r))
+					{
+						for(unsigned int t = 0; t < r.size(); t++)
+						{
+							ringsOut.add(r[t]);
+						}
+
+						for(int j = remover.size()-1; j >= 0; j--)
+						{
+							fragments.erase(fragments.begin() + remover[j]);
+						}
+						ips[currentIPindex].used_ = false;
+					}
+					else
+					{
+						fragments.push_back(currentFragment);
+					}
+				}
+				else
+				{
+					fragments.push_back(currentFragment);
+					ips[currentIPindex].used_ = true;
+				}				
+			}
+
+			currentFragment = TeSFragment (i, ring[i]);			
+		}
+	}
+	
+	if(fragments.size() > 1)
+	{
+		vector<TeLinearRing> r;
+		if(TeSMergeFragments(fragments, r))
+		{
+			for(unsigned int t = 0; t < r.size(); t++)
+			{
+				ringsOut.add(r[t]);
+			}
+		}
+		else
+		{
+			return false;
+		}
+	}
+	else if(fragments.size() == 1)
+	{
+		return false;	
+	}
+
+	for(unsigned int i = 0; i < ringsOut.size(); i++)
+	{
+		ringsOut[i].objectId(ring.objectId());
+		ringsOut[i].geomId(ring.geomId());
+	}
+
+	return true;
+} 
+
+bool TeOVERLAY::TeSplitRings(vector<TeLinearRing>& rings, vector<TeLinearRing>& ringsOut)
+{
+	ringsOut.clear();
+
+	for(unsigned int i = 0; i < rings.size(); ++i)
+	{
+		TeLineSet ringsAux;
+		
+		if(TeOVERLAY::TeSplitRing(rings[i], ringsAux) == false)
+			return false;
+
+		for(unsigned int j = 0; j < ringsAux.size(); ++j)
+			ringsOut.push_back(ringsAux[j]);
+	}
+
+	return true;
+}
+
+bool TeOVERLAY::TeCloneLine(const TeLine2D& lineIn, TeLine2D& lineOut, const unsigned int& minPts)
+{
+	lineOut.clear();
+
+	unsigned int lineSize = lineIn.size();
+
+	if(lineSize < 2)
+		return false;
+
+	lineOut.add(lineIn[0]);
+
+	for(unsigned int i = 1; i < lineSize; ++i)
+	{
+		if(!TeEquals(lineIn[i - 1], lineIn[i]))
+		{
+			lineOut.add(lineIn[i]);
+		}
+	}
+
+	if(lineOut.size() < minPts)
+		return false;
+
+	return true;
+}
+
+
+bool TeOVERLAY::TeClonePolygon(const TePolygon& polIn, TePolygon& polOut)
+{
+	polOut.clear();
+
+	unsigned int polSize = polIn.size();
+
+	if(polSize == 0)
+		return false;
+
+	for(unsigned int i = 0; i < polSize; ++i)
+	{
+		TeLine2D lineOut;
+
+		if(!TeCloneLine(polIn[i], lineOut, 4))
+			return false;
+
+		TeLinearRing ringOut(lineOut);
+
+		polOut.add(ringOut);
+	}
+
+	return true;
+}
+
+bool TeOVERLAY::TeClonePolygonSet(const TePolygonSet& polsIn, TePolygonSet& polsOut)
+{
+	polsOut.clear();
+
+	unsigned int polsSize = polsIn.size();
+
+	if(polsSize == 0)
+		return false;
+
+	for(unsigned int i = 0; i < polsSize; ++i)
+	{
+		TePolygon pol;
+
+		if(!TeClonePolygon(polsIn[i], pol))
+			return false;
+
+		polsOut.add(pol);
+	}
+
+	return true;
+}
+
diff --git a/src/terralib/kernel/TeOverlayUtils.h b/src/terralib/kernel/TeOverlayUtils.h
new file mode 100644
index 0000000..e37ba2e
--- /dev/null
+++ b/src/terralib/kernel/TeOverlayUtils.h
@@ -0,0 +1,172 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/**
+ * @file TeOverlayUtils.h
+ * @brief This file contains support algorithms for set operations.
+ * These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone.
+ * THIS IS FOR INTERNAL USE ONLY.
+ */
+
+/** @ingroup SetOperations
+    THIS IS FOR INTERNAL USE ONLY: TerraLib set operation auxiliary functions. 
+ *  @{
+ */
+
+#ifndef  __TERRALIB_INTERNAL_OVERLAYUTILS_H
+#define  __TERRALIB_INTERNAL_OVERLAYUTILS_H
+
+// STL's include
+#include <map>
+#include <vector>
+#include <algorithm>
+using namespace std;
+
+#include "TeGeometry.h"
+#include "TeIntersector.h"
+
+
+namespace TeOVERLAY
+{
+
+//---------------- Auxiliary structures ----------------//
+//! Defines a functor for coordinate order during map insert and retrival: lexicograpgical order (xy)
+struct TL_DLL xyOrder
+{
+	//! Default operation for 'less than' tests.
+	bool operator()(const TeCoord2D& c1, const TeCoord2D& c2) const
+	{
+		if(c1.x_ < c2.x_)
+			return true;
+
+		if(c1.x_ > c2.x_)
+			return false;
+
+		if(c1.y_ < c2.y_)
+			return true;		
+
+		return false;
+	}
+};
+
+//! Type to index fragments end points: used during merge fase.
+typedef multimap<TeCoord2D, pair<unsigned int, TeLine2D>, xyOrder> TeLineIndex;
+
+//! Defines a functor for ordering segments during point in poly tests.
+struct TL_DLL segOrder
+{
+	//! Default operation for 'less than' tests.
+	bool operator()(const TeINTERSECTOR2::TeSegIdInPolygonSet& ip1, const TeINTERSECTOR2::TeSegIdInPolygonSet& ip2) const
+	{
+		if(ip1.polId_ < ip2.polId_)
+			return true;		
+
+		return false;
+	}
+};
+//---------------- Auxiliary operations for overlay ----------------//
+
+//! Verifies orientation for each line of polygon set, and reverse the orientation if need
+TL_DLL void TeFixOrientation(TePolygonSet& polSet, const short& outerOrientationToReverse, const short& innerOrientationToReverse);
+
+
+//! For each operation (union, intersection and difference) defines location for retrieval of fragments
+TL_DLL void TeChooseBoundaryLocation(const short& operation, short& locationRedFragments, short& locationBlueFragments);
+
+
+//! Erases from fragmentsIndex boundary fragments that are in oposite direction: each fragment must have a unique identifier in the pair first field (pair<unsigned int, TeLine2D>)
+TL_DLL void TeRemoveOpositeBoundaryFragments(TeLineIndex& fragmentsIndex);
+
+
+//! Erases from fragmentsIndex boundary fragments that are equals to another boundary fragment
+TL_DLL void TeRemoveSameBoundaryFragments(TeLineIndex& fragmentsIndex);
+
+//! Merge fragments ito first index (fragmentsIndex)
+TL_DLL void TeJoinFragments(TeLineIndex& fragmentsIndex, TeLineIndex& boundaryFragmentsIndex);
+
+//! Moves closed rings from fragmentsIndex to rins vector
+TL_DLL void TeFindAndMoveClosedRings(TeLineIndex& fragmentsIndex, vector<TeLinearRing>& rings);
+
+//! Gets a polygonset with outer rings and a vector with holes and try to find to what polygon the hole belongs to
+TL_DLL bool TeMountTopology(TePolygonSet& polysOut, vector<TeLinearRing>& holes);
+
+//! Make polygons from fragments.
+TL_DLL bool TeMergeFragments(TeLineIndex& fragmentsIndex, vector<TeLinearRing>& rings, const bool& doExaustive = false);
+
+//! For each linear ring, see it's orientation and classify in outer or inner ring
+TL_DLL bool TeClassifyRings(vector<TeLinearRing>& rings, TePolygonSet& polsOut, vector<TeLinearRing>& holes);
+
+//! Find fragments in the red set that satisfies locationFragments using blue set as reference
+TL_DLL void TeRtreeGetFragments(const TePolygonSet& bluePolygons, TeINTERSECTOR2::TeSegmentRTree& blueTree, TeLineSet& redFragments, const short& locationFragments, short& mask, TeLineIndex& redFragmentsIndex, vector<TeLinearRing>& rings);
+
+//! Find fragments in the same set that satisfies locationFragments
+TL_DLL void TeRtreeGetFragments(const TePolygonSet& polygons, TeINTERSECTOR2::TeSegmentRTree& tree, TeLineSet& fragments, vector<pair<unsigned int, unsigned int> >& fragmentsIds, const short& locationFragments, short& mask, TeLineIndex& fragmentsIndex, vector<TeLinearRing>& rings);
+
+//! Removes fragments that may overlap with others: used in special cases during union process
+TL_DLL void TeRtreeRemoveFragments(const TePolygonSet& polygons, TeINTERSECTOR2::TeSegmentRTree& tree, TeLineIndex &lineIndex, vector<pair<unsigned int, unsigned int> >& fragmentsIds, const short& locationFragments, short& mask, vector<TeLinearRing>& rings);
+
+//! Split rings if they have commom end points.
+/*
+	\param  ring		Ring to be broken.
+	\param  ringsOut	Resulting rings.
+	\return				Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeSplitRing(TeLinearRing& ring, TeLineSet& ringsOut);
+
+//! Split rings if they have commom end points.
+/*
+	\param  rings		A vector of linear rings to be broken.
+	\param  ringsOut	Resulting rings.
+	\return				Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeSplitRings(vector<TeLinearRing>& rings, vector<TeLinearRing>& ringsOut);
+
+//! Clone line point removing duplicated coordinates.
+/*
+	\param lineIn   Line to ble cloned.
+	\param lineOut  Cloned line without repeated points.  
+	\param minPts	This is a constant to check if the cloned line has the minimum number of points.
+	\return         Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeCloneLine(const TeLine2D& lineIn, TeLine2D& lineOut, const unsigned int& minPts);
+
+//! Clone polygon lines and try to remove duplicated coordinates from lines.
+/*
+	\param polIn       Polygon to be cloned.
+	\param polOut      Cloned polygon without repeated points.
+	\return            Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeClonePolygon(const TePolygon& polIn, TePolygon& polOut);
+
+//! Clone polygons lines and try to remove duplicated coordinates from lines.
+/*
+	\param polsIn       Polygons to be cloned.
+	\param polsOut      Cloned polygons without repeated points.
+	\return             Returns true if the operation successed otherwise returns false.
+ */
+TL_DLL bool TeClonePolygonSet(const TePolygonSet& polsIn, TePolygonSet& polsOut);
+
+}	// end namespace TeOVERLAY
+
+#endif	// __TERRALIB_INTERNAL_OVERLAYUTILS_H
+
+
diff --git a/src/terralib/kernel/TePieBar.h b/src/terralib/kernel/TePieBar.h
new file mode 100644
index 0000000..906406f
--- /dev/null
+++ b/src/terralib/kernel/TePieBar.h
@@ -0,0 +1,317 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TePieBar.h
+    \brief This file contains a class that represents a char (pie or bar)  
+*/
+#ifndef TEPIEBAR_H
+#define TEPIEBAR_H
+
+#include "TeDefines.h"
+
+//! A class that represents a chart (pie or bar)
+class TL_DLL TePieBar
+{
+public:
+	enum			TePieBarInput {ALL, TABSEL, QUERYSEL, LEGEND, NOTTABSEL, NOTQUERYSEL, NOTLEGEND};
+	string			type_; // PIECHART or BARCHART
+	int				themeId_;
+	double			maxDiameter_;	
+	double			minDiameter_;	
+	double			diameter_;
+	string			dimensionAttr_;
+	vector<string>	attrVector_;
+	vector<TeColor> colorVector_;
+	double			maxHeight_;
+	double			minHeight_;
+	double			width_;
+	double			maxValue_;
+	double			minValue_;
+	bool			keepDimension_;
+	int				inputType_;
+	TeDatabase		*db_;
+	string			keyMove_;
+
+	TePieBar() {}
+
+	TePieBar(int themeId, TeDatabase* db)
+	{
+		themeId_ = themeId;
+		db_ = db;
+	}
+
+	TePieBar (const TePieBar& pb )
+	{
+		type_ = pb.type_;
+		themeId_ = pb.themeId_;
+		maxDiameter_ = pb.maxDiameter_;	
+		minDiameter_ = pb.minDiameter_;	
+		diameter_ = pb.diameter_;
+		dimensionAttr_ = pb.dimensionAttr_;
+		maxHeight_ = pb.maxHeight_;
+		minHeight_ = pb.minHeight_;
+		width_ = pb.width_;
+		maxValue_ = pb.maxValue_;
+		minValue_ = pb.minValue_;
+		keepDimension_ = pb.keepDimension_;
+		inputType_ = pb.inputType_;
+		db_ = pb.db_;
+		keyMove_ = pb.keyMove_;
+
+		attrVector_.clear();
+		colorVector_.clear();
+		int size = pb.attrVector_.size();
+		int i = 0;
+		while(i < size)
+		{	attrVector_.push_back(pb.attrVector_[i]);
+			colorVector_.push_back(pb.colorVector_[i]);
+			i++;
+		}
+	}
+
+	TePieBar& operator=(const TePieBar& pb)
+	{
+		type_ = pb.type_;
+		themeId_ = pb.themeId_;
+		maxDiameter_ = pb.maxDiameter_;	
+		minDiameter_ = pb.minDiameter_;	
+		diameter_ = pb.diameter_;
+		dimensionAttr_ = pb.dimensionAttr_;
+		maxHeight_ = pb.maxHeight_;
+		minHeight_ = pb.minHeight_;
+		width_ = pb.width_;
+		maxValue_ = pb.maxValue_;
+		minValue_ = pb.minValue_;
+		keepDimension_ = pb.keepDimension_;
+		inputType_ = pb.inputType_;
+		db_ = pb.db_;
+		keyMove_ = pb.keyMove_;
+
+		attrVector_.clear();
+		colorVector_.clear();
+		int size = pb.attrVector_.size();
+		int i = 0;
+		while(i < size)
+		{	attrVector_.push_back(pb.attrVector_[i]);
+			colorVector_.push_back(pb.colorVector_[i]);
+			i++;
+		}
+		return *this;
+	}
+
+	~TePieBar() {}
+
+	void init(int themeId, TeDatabase* db)
+	{
+		themeId_ = themeId;
+		db_ = db;
+	}
+
+	bool locate(TeCoord2D pt, double delta)
+	{
+		keyMove_.clear();
+		string	TS = "AuxTheme" + Te2String(themeId_);
+		string xmin = Te2String(pt.x()-delta);
+		string xmax = Te2String(pt.x()+delta);
+		string ymin = Te2String(pt.y()-delta);
+		string ymax = Te2String(pt.y()+delta);
+
+		TeDatabasePortal* portal = db_->getPortal();
+		string sel = "SELECT SELKEY FROM " + TS + " WHERE ";
+		sel += "PIEBARX > " + xmin + " AND ";
+		sel += "PIEBARX < " + xmax + " AND ";
+		sel += "PIEBARY > " + ymin + " AND ";
+		sel += "PIEBARY < " + ymax;
+		if(portal->query(sel) == false)
+		{
+			delete portal;
+			return false;
+		}
+
+		bool b = portal->fetchRow(0);
+		if(b == true)
+			keyMove_ = portal->getData(0);
+		delete portal;
+
+		if(keyMove_.empty() == false)
+			return true;
+		return false;
+	}
+
+	void move(TeCoord2D pt)
+	{
+		if(keyMove_.empty() == true)
+			return;
+
+		string	x = Te2String(pt.x());
+		string	y = Te2String(pt.y());
+		string	TS = "AuxTheme" + Te2String(themeId_);
+		string mover = "UPDATE " + TS + " SET PIEBARX = " + x + ", PIEBARY = " + y;
+		mover += " WHERE SELKEY = '" + keyMove_ + "'";
+		db_->execute(mover);
+	}
+
+	bool load()
+	{
+		TeDatabasePortal* portal = db_->getPortal();
+		string sel = "SELECT * FROM piebars WHERE themeId = " + Te2String(themeId_);
+		if(portal->query(sel))
+		{
+			bool b = portal->fetchRow(0);
+			if(b == false)
+			{
+				delete portal;
+				return false;
+			}
+			type_ = portal->getData("type");
+			maxDiameter_ = portal->getDouble("maxDiameter");
+			minDiameter_ = portal->getDouble("minDiameter");
+			diameter_ = portal->getDouble("diameter"));
+			string	attr = portal->getData("dimensionAttr");
+			dimensionAttr_ = attr;
+			maxHeight_ = portal->getDouble("maxHeight");
+			minHeight_ = portal->getDouble("minHeight");
+			width_ = portal->getDouble("width"));
+			maxValue_ = portal->getDouble("maxValue");
+			minValue_ = atof(portal->getData("minValue");
+			keepDimension_ = portal->getDouble("keepDimension");
+			inputType_ = portal->getDouble("inputType");
+			int i;
+			for(i=0; i<10; i++)
+			{
+				string attr = "attr" + Te2String(i+1);
+				string vattr = portal->getData(attr);
+				if(vattr.empty() == true)
+					break;
+				attrVector_.push_back(vattr);
+
+				string red = "red" + Te2String(i+1);
+				string green = "green" + Te2String(i+1);
+				string blue = "blue" + Te2String(i+1);
+				TeColor cor;
+				cor.red_ = atoi(portal->getData(red));
+				cor.green_ = atoi(portal->getData(green));
+				cor.blue_ = atoi(portal->getData(blue));
+				colorVector_.push_back(cor);
+			}
+			delete portal;
+			return true;
+		}
+		delete portal;
+		return false;
+	}
+	
+	void save()
+	{
+		int	i;
+		TeDatabasePortal* portal = db_->getPortal();
+		bool b = portal->query("SELECT * FROM piebars");
+		delete portal;
+		if(b == false)
+		{
+			string criar = "CREATE TABLE piebars (themeId INTEGER,";
+			criar += "type VARCHAR(16) DEFAULT NULL,";
+			criar += "maxDiameter DOUBLE DEFAULT NULL,";
+			criar += "minDiameter DOUBLE DEFAULT NULL,";
+			criar += "diameter DOUBLE DEFAULT NULL,";
+			criar += "dimensionAttr  VARCHAR(64) DEFAULT NULL,";
+			criar += "maxHeight DOUBLE DEFAULT NULL,";
+			criar += "minHeight DOUBLE DEFAULT NULL,";
+			criar += "width DOUBLE DEFAULT NULL,";
+			criar += "maxValue DOUBLE DEFAULT NULL,";
+			criar += "minValue DOUBLE DEFAULT NULL,";
+			criar += "keepDimension INTEGER DEFAULT 0,";
+			criar += "inputType INTEGER DEFAULT 0,";
+			for (i=0; i<10; i++)
+			{
+				criar += "attr" + Te2String(i+1) + " VARCHAR(64) DEFAULT NULL,";
+				criar += "red" + Te2String(i+1) + " INTEGER DEFAULT NULL,";
+				criar += "green" + Te2String(i+1) + " INTEGER DEFAULT NULL,";
+				criar += "blue" + Te2String(i+1) + " INTEGER DEFAULT NULL,";
+			}
+			criar.erase(criar.size()-1, 1);
+			criar += ")";
+			db_->execute(criar);
+		}
+
+		string del = "DELETE FROM piebars WHERE themeId = " + Te2String(themeId_);
+		db_->execute(del);
+
+		if(attrVector_.size() == 0)
+			return;
+		string up = "INSERT INTO piebars (themeId, type, maxDiameter, ";
+		up += "minDiameter, diameter, dimensionAttr, maxHeight, minHeight, ";
+		up += "width, maxValue, minValue, keepDimension, inputType, ";
+		for (i=0; i<attrVector_.size() && i<10; i++)
+		{
+			up += "attr" + Te2String(i+1) + ", ";
+			up += "red" + Te2String(i+1) + ", ";
+			up += "green" + Te2String(i+1) + ", ";
+			up += "blue" + Te2String(i+1) + ", ";
+		}
+		up.erase(up.size()-2, 2);
+		up += ")";
+
+		up += " VALUES (" + Te2String(themeId_) + ", ";
+		up += "'" + type_ + "', ";
+		up += Te2String(maxDiameter_) + ", ";
+		up += Te2String(minDiameter_) + ", ";
+		up += Te2String(diameter_) + ", ";
+		up += "'" + dimensionAttr_ + "', ";
+		up += Te2String(maxHeight_) + ", ";
+		up += Te2String(minHeight_) + ", ";
+		up += Te2String(width_) + ", ";
+		up += Te2String(maxValue_) + ", ";
+		up += Te2String(minValue_) + ", ";
+		up += Te2String(keepDimension_) + ", ";
+		up += Te2String(inputType_) + ", ";
+		for (i=0; i<attrVector_.size() && i<10; i++)
+		{
+			up += "'" + attrVector_[i] + "', ";
+			up += Te2String(colorVector_[i].red_) + ", ";
+			up += Te2String(colorVector_[i].green_) + ", ";
+			up += Te2String(colorVector_[i].blue_) + ", ";
+		}
+		up.erase(up.size()-2, 2);
+		up += ")";
+		db_->execute(up);
+	}
+	
+	void remove()
+	{
+		TeDatabasePortal* portal = db_->getPortal();
+		bool b = portal->query("SELECT * FROM piebars");
+		delete portal;
+		if(b == false)
+			return;
+
+		string del = "DELETE FROM piebars WHERE themeId = " + Te2String(themeId_);
+		db_->execute(del);
+	}
+};
+
+#endif
+
+
+
+
+
diff --git a/src/terralib/kernel/TePrecision.h b/src/terralib/kernel/TePrecision.h
new file mode 100644
index 0000000..0faf44d
--- /dev/null
+++ b/src/terralib/kernel/TePrecision.h
@@ -0,0 +1,61 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file  TePrecision.h
+    \brief This file contains a singleton to manage precision in TerraLib.
+*/
+#ifndef  __TERRALIB_INTERNAL_PRECISION_H
+#define  __TERRALIB_INTERNAL_PRECISION_H
+
+#include "TeSingleton.h"
+#include "TeDefines.h"
+
+//! Describes a class for supportin scale and representation dependency 
+/*! The entire set of geometric algorithms make use of this class,
+    an so it must be properly set. It will be used when dealling with approximate calculus
+	\sa TeSingleton 
+*/
+class TL_DLL TePrecision: public TeSingleton<TePrecision>
+{
+public:
+	//! Destructor
+	~TePrecision() {}
+
+	friend class TeSingleton<TePrecision>;
+
+	//! Sets the precision value to be considered
+	void setPrecision ( double precision )
+	{ precision_ = precision; }
+
+	//! Returns the precision value in use
+	double	precision ()
+	{ return precision_; }
+
+protected:
+	//! Constructor
+	TePrecision(): precision_ ( TeMINFLOAT )
+	{}
+
+	double precision_;	//!< Stores the precision.
+};
+
+#endif
diff --git a/src/terralib/kernel/TeProgress.cpp b/src/terralib/kernel/TeProgress.cpp
new file mode 100644
index 0000000..2e7acbf
--- /dev/null
+++ b/src/terralib/kernel/TeProgress.cpp
@@ -0,0 +1,37 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeProgress.h"
+
+TeProgressBase* TeProgress::instance_ = 0;
+
+
+TeProgressBase* TeProgress::instance()
+{
+	return instance_;
+}
+
+void TeProgress::setProgressInterf( TeProgressBase* interf )
+{
+	instance_ = interf;
+}
diff --git a/src/terralib/kernel/TeProgress.h b/src/terralib/kernel/TeProgress.h
new file mode 100644
index 0000000..7bc2b0f
--- /dev/null
+++ b/src/terralib/kernel/TeProgress.h
@@ -0,0 +1,67 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file  TeProgress.h
+    \brief This file contains a singleton for progress information.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_PROGRESS_H
+#define  __TERRALIB_INTERNAL_PROGRESS_H
+
+#include "TeProgressBase.h"
+
+//! Provides the suport to implement an instance of a progress bar interface
+/*
+	This class is based on a Singleton Design Pattern (See "Design Patterns" book, page 127).
+	Applications should set the Progress Interface that will be used by the TerraLib routines
+	able to indicate progress in executing a task.
+*/
+class TL_DLL TeProgress
+{
+public:
+
+	//! Returns the unique instance of a progress interface
+	static TeProgressBase* instance();
+
+	//! Sets the unique instance of a progress interface
+	static void setProgressInterf( TeProgressBase* interf );
+
+	//! Virtual destructor
+	virtual ~TeProgress() {}  
+
+protected:
+
+	//! Empty constructor
+	TeProgress() {}
+
+private:
+	
+	static TeProgressBase* instance_;	//!< The unique instance of a progress interface
+
+	//! No copy allowed
+	TeProgress(const TeProgress&);
+
+	//! No copy allowed
+	TeProgress& operator=(const TeProgress&){return *this;}
+};
+#endif
+
diff --git a/src/terralib/kernel/TeProgressBase.h b/src/terralib/kernel/TeProgressBase.h
new file mode 100644
index 0000000..70804a6
--- /dev/null
+++ b/src/terralib/kernel/TeProgressBase.h
@@ -0,0 +1,76 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file  TePrecision.h
+    \brief This file contains a singleton to manage precision in TerraLib.
+*/
+#ifndef  __TERRALIB_INTERNAL_PROGRESSBASE_H
+#define  __TERRALIB_INTERNAL_PROGRESSBASE_H
+
+#include "TeDefines.h"
+#include <string>
+using std::string;
+
+//! A generic Progress Interface.
+/*
+	It defines the methods that should be implemented by concrete classes.
+	Assumes that a progress interface has a Caption to indicate the task
+	being monitored and a Message to be displayed along with the progress 
+	indication. A progress interface also know the total number of steps 
+	required to finish the task being monitored.
+*/
+class TL_DLL TeProgressBase
+{
+public:
+
+	//! Constructor
+	TeProgressBase(){}
+
+	//! Destructor
+	virtual ~TeProgressBase() {}
+
+	//! Sets the total number of steps to n 
+	virtual void setTotalSteps(int n) =0;
+
+	//! Sets the current amount of progress made to n
+	virtual void setProgress(int n) = 0;
+
+	//! Resets the progress interface
+	virtual void reset() = 0;
+
+	//! Resets the progress dialog
+	virtual void cancel() = 0;
+
+	//! Sets the label's text
+	virtual void setMessage(const string& text) = 0;
+
+	//!Returns the label's text
+	virtual string getMessage() { return ""; }
+
+	//! Returns true whether the process was cancelled
+	virtual bool wasCancelled() = 0;
+	
+	//! Sets the caption associated to the progress interface
+	virtual void setCaption(const string& cap) = 0;
+
+};
+#endif
diff --git a/src/terralib/kernel/TeProject.cpp b/src/terralib/kernel/TeProject.cpp
new file mode 100644
index 0000000..2c4ef8d
--- /dev/null
+++ b/src/terralib/kernel/TeProject.cpp
@@ -0,0 +1,291 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2006 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+#include "TeProject.h"
+#include "TeDatabase.h"
+
+TeProject::TeProject():
+	id_(-1),
+	name_(""),
+	description_(""), 
+	currentViewIndex_(-1),
+	db_(0)
+{}
+
+//! Constructor from a identifier
+TeProject::TeProject(int id, TeDatabase* db):
+	id_(id),
+	name_(""),
+	description_(""), 
+	currentViewIndex_(-1),
+	db_(db)
+{
+	if (!db)
+		return;
+	string sql  = "SELECT name, decription, current_view, view_id ";
+	       sql += "FROM te_project INNER JOIN te_project_view ON te_project.project_id = te_project_view.project_id";
+		   sql += " WHERE te_project.project_id = " + Te2String(id);
+	sql += Te2String(id);
+	TeDatabasePortal* portal = db->getPortal();
+	if (!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return;
+	}
+	// use the first fetch to get basic information
+	name_ = portal->getData(0);
+	description_ = portal->getData(1);
+	int currentview = portal->getInt(2);
+	int viewid = portal->getInt(3);
+	views_.push_back(portal->getInt(3));
+	if (viewid == currentview)
+		currentViewIndex_ = 0;
+
+	// get the other views
+	while (portal->fetchRow())
+	{
+		viewid = portal->getInt(3);
+		views_.push_back(viewid);
+		if (viewid == currentview)
+			currentViewIndex_ = views_.size()-1;
+	}
+	delete portal;
+}
+
+	//! Constructor from a name
+TeProject::TeProject(const string& name, TeDatabase* db):
+	id_(-1),
+	name_(name),
+	description_(""), 
+	currentViewIndex_(-1),
+	db_(db)
+{
+	if (!db)
+		return;
+	string sql  = "SELECT te_project.project_id, decription, current_view, view_id ";
+	       sql += "FROM te_project INNER JOIN te_project_view ON te_project.project_id = te_project_view.project_id";
+		   sql += " WHERE name = '" + name + "'";
+
+	TeDatabasePortal* portal = db->getPortal();
+	if (!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return;
+	}
+	// use the first fetch to get basic information
+	id_ = portal->getInt(0);
+	description_ = portal->getData(1);
+	int currentview = portal->getInt(2);
+	int viewid = portal->getInt(3);
+	views_.push_back(portal->getInt(3));
+	if (viewid == currentview)
+		currentViewIndex_ = 0;
+
+	// get the other views
+	while (portal->fetchRow())
+	{
+		viewid = portal->getInt(3);
+		views_.push_back(viewid);
+		if (viewid == currentview)
+			currentViewIndex_ = views_.size()-1;
+	}
+	delete portal;
+}
+
+TeProject::TeProject(const TeProject& other)
+{
+	id_ = other.id_;
+	name_= other.name_;
+	description_= other.description_; 
+	views_= other.views_;
+	currentViewIndex_= other.currentViewIndex_;
+	db_= other.db_;
+}
+
+TeProject& 
+TeProject::operator= (const TeProject& other)
+{
+	if ( this != &other )
+	{
+		id_ = other.id_;
+		name_= other.name_;
+		description_= other.description_; 
+		views_= other.views_;
+		currentViewIndex_= other.currentViewIndex_;
+		db_= other.db_;
+	}
+	return *this;
+}
+
+//! Destructor
+TeProject::~TeProject()
+{
+	views_.clear();
+	db_=0;
+}
+
+	//! Returns TRUE if a view is part of a project and FALSE otherwise
+bool 
+TeProject::isProjectView(int viewId)
+{
+	TeViewVector::iterator it = find(views_.begin(), views_.end(), viewId);
+	return (it != views_.end());
+}
+
+	//! Returns TRUE if a project has a current view and FALSE otherwise
+bool
+TeProject::hasCurrentView()
+{	return (currentViewIndex_>=0 && currentViewIndex_< static_cast<int>(views_.size())); }
+
+
+//! Returns the id of the current view in the project 
+int
+TeProject::getCurrentViewId()
+{
+	if (currentViewIndex_>=0 && currentViewIndex_< static_cast<int>(views_.size()))
+		return views_[currentViewIndex_];
+	else
+		return -1;
+}
+
+//! Sets the id of the current view in the project 
+void 
+TeProject::setCurrentViewId(int viewId)
+{
+	currentViewIndex_ = -1;
+	for (unsigned int i=0; i<views_.size(); ++i)
+	{
+		if (views_[i] == viewId)
+		{
+			currentViewIndex_ = i;
+			break;
+		}
+	}
+}
+
+	//! Returns the id of the index-th view of the project
+int 
+TeProject::getViewId(int index)
+{
+	if (index >= 0 && index < static_cast<int>(views_.size()))
+		return views_[index];
+	else
+		return -1;
+}
+
+//!	Returns the names of the views in the project.
+TeViewNameVector
+TeProject::getViewNameVector()
+{
+	TeViewNameVector viewNames;
+	if (!db_ || views_.empty())
+		return viewNames;
+
+	string viewids = Te2String(views_[0]);
+	for (unsigned int i=1; i<views_.size(); ++i)
+	{
+		viewids += ",";
+		viewids += Te2String(views_[i]);
+	}
+	string sql  = "SELECT te_view.name ";
+	       sql += "FROM te_view INNER JOIN te_project_view ON te_view.view_id = te_project_view.view_id ";
+	       sql += "WHERE te_project_view.project_id = " + Te2String(id_);
+
+	TeDatabasePortal* portal = db_->getPortal();
+	if (!portal)
+		return viewNames;
+	if (!portal->query(sql))
+	{
+		delete portal;
+		return viewNames;
+	}
+	while (portal->fetchRow())
+		viewNames.push_back(portal->getData(0));
+	delete portal;
+	return viewNames;
+}
+
+int 
+TeProject::insertView(string name, TeProjection* projection)
+{
+	TeProjection* proj;
+	if (!db_)
+		return -1;
+	if (projection)
+		proj = projection;
+	else
+	{
+		TeDatum sad69 = TeDatumFactory::make("SAD69");
+		proj = new TeLatLong(sad69);
+	}
+	TeView* view = new TeView(name);
+	view->projection(proj);
+	view->user(db_->user());
+	if (db_->insertView(view))
+	{
+		return insertViewRel(view->id());
+	}
+	return -1;
+}
+
+int 
+TeProject::insertViewRel(int viewId)
+{
+	if (!db_)
+		return -1;
+
+	if(db_->insertProjectViewRel(id_,viewId))
+		return addView(viewId);
+
+	return -1;
+}
+
+int 
+TeProject::addView(int viewId)
+{
+	if (viewId <=0)
+		return -1;
+	views_.push_back(viewId);
+	currentViewIndex_ = views_.size()-1;
+	return viewId;
+}
+
+void 
+TeProject::deleteView(int viewId)
+{
+	if (!db_)
+		return;
+	TeViewVector::iterator pos = find(views_.begin(),views_.end(),viewId);
+	if (pos != views_.end())
+		views_.erase(pos);
+	db_->deleteView(viewId);
+}
+
+//! Clear the project
+void 
+TeProject::clearViews()
+{
+	views_.clear();
+	currentViewIndex_ = -1;
+}
+
+
diff --git a/src/terralib/kernel/TeProject.h b/src/terralib/kernel/TeProject.h
new file mode 100644
index 0000000..2d09a70
--- /dev/null
+++ b/src/terralib/kernel/TeProject.h
@@ -0,0 +1,176 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeProject.h
+    \brief This file contains structures and definitions to support the concept of a project in TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_PROJECT_H
+#define  __TERRALIB_INTERNAL_PROJECT_H
+
+#include "TeDefines.h"
+#include <string>
+#include <vector>
+#include <map>
+
+class TeDatabase;
+class TeProjection;
+class TeView;
+
+using std::vector;
+using std::string;
+using std::map;
+
+//! A vector of the identifiers of the maps in the project.
+typedef vector<int> TeViewVector;
+
+//! A vector of the names of the views in the project.
+typedef vector<string> TeViewNameVector;
+
+//! A vector of the identifiers of the projects.
+typedef vector<int> TeProjectIdVector;
+
+/*!
+   This class represents a project concept.
+   A project is a collection of views kept in a ordered list.
+   A project might have the information about the current view.
+*/
+class TL_DLL TeProject
+{
+public:
+
+	//! Empty constructor
+	TeProject();
+
+    //! Constructor from a identifier
+	TeProject(int id, TeDatabase* db);
+
+	//! Constructor from a name
+	TeProject(const string& name, TeDatabase* db);
+
+	//! Copy Constructor
+	TeProject(const TeProject& other);
+
+	//! Operator =
+	TeProject& operator= (const TeProject& other);
+
+	//! Destructor
+	virtual ~TeProject();
+
+	//! Sets the project name.
+	virtual void setId(int id) 
+	{id_ = id;}	
+	
+	//! Returns the project name.
+	virtual int id() 
+	{ return id_; }
+
+	//! Sets the project name.
+	virtual void setName(const string& name) 
+	{name_ = name;}	
+	
+	//! Returns the project name.
+	virtual string name() 
+	{ return name_; }
+
+	//! Returns the project description.
+	virtual string description() 
+	{ return description_; }
+
+	//! Sets the project description
+	virtual void setDescription(const string& desc) 
+	{ description_ = desc ; }
+
+	//! Sets the project database
+	virtual void setDatabase(TeDatabase* db)
+	{ db_ = db; }
+
+	//! Gets the project database
+	virtual TeDatabase* getDatabase()
+	{ return db_; }
+
+	//! Returns TRUE if a view is part of a project and FALSE otherwise
+	virtual bool isProjectView(int viewId);
+
+	//! Returns TRUE if a project has a current view and FALSE otherwise
+	virtual bool hasCurrentView();
+
+	//! Sets the id of the current view in the project 
+	virtual void setCurrentViewId(int viewId);
+
+	//! Returns the id of the current view in the project 
+	virtual int getCurrentViewId();
+
+	//! Sets the index in the list of the current view in the project 
+	virtual void setCurrentViewIndex(int index)
+	{ currentViewIndex_ = index; }
+
+	//! Returns position of the current view in the project
+	virtual int getCurrentViewIndex()
+	{ return currentViewIndex_; }
+
+	//! Returns a reference to the project list of views
+	const TeViewVector& getViewVector() const
+	{	return views_; }
+
+	//!	Returns the names of the views in the project.
+	virtual TeViewNameVector getViewNameVector();
+
+	//! Returns the id of the index-th view of the project
+	virtual int getViewId(int index);
+
+	//!	Creates a new view in the project and persists it in the database
+	/* 
+		\param name view name
+		\param projection view projection. If null uses as default LatLong/SAD69
+		\return the id of the new view
+	*/
+	virtual int insertView(string name, TeProjection* projection = NULL);
+
+	//!	Adds a new view relation with the project and persists it in the database
+	/* 
+	\param view The view object
+	\return the id of the new view
+	*/
+	virtual int insertViewRel(int viewId);
+
+	//! Adds an view id to the views project vector
+	virtual int addView(int viewId);
+
+	//! Removes a view from the project (and also from the database)
+	virtual void deleteView(int viewId);
+
+	//! Clear the project
+	virtual void clearViews();
+
+private: 
+	int id_;
+	string name_;
+	string description_; 
+	TeViewVector views_;
+	int currentViewIndex_;
+	TeDatabase* db_;
+};
+
+//! A map from a integer unique identifier to a pointer to project
+typedef map<int, TeProject*>  TeProjectMap;
+
+#endif
diff --git a/src/terralib/kernel/TeProjection.cpp b/src/terralib/kernel/TeProjection.cpp
new file mode 100644
index 0000000..d389ce3
--- /dev/null
+++ b/src/terralib/kernel/TeProjection.cpp
@@ -0,0 +1,2316 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeProjection.h"
+#include "TeException.h"
+#include "TeUtils.h"
+#include <cstdlib>  //FAMI
+#include <cstring>
+#include <stdio.h>
+#include <iostream> //FAMI
+
+bool tokenizeWKT(char** wkt, vector<string>& tokens);
+
+TeDatum  TeGetDatumFromWKT(const string& wkt);
+
+TeDatum  TeGetDatumFromProj4(const string& proj4);
+
+//=========================================================
+//
+//  PROJECTION INFORMATION 
+//
+//  Auxiliary functions which indicate the information
+//  associated to a projection
+//
+//  Used for reading and writing information
+//
+//==========================================================
+
+
+//FAMI: added Satellite
+// Name						Units  Long  Lat  Par1  Par2  Sca  Eas  Nor 
+const char* teProjInfo[]= {
+"Albers",					"1",  "1",  "1", "1",  "1",  "0", "1", "1", 
+"LatLong",					"1",  "0",  "0", "0",  "0",  "0", "0", "0",   
+"LambertConformal",			        "1",  "1",  "1", "1",  "1",  "0", "1", "1", 
+"Mercator",					"1",  "1",  "1", "1",  "0",  "0", "1", "1", 
+"Miller",					"1",  "1",  "0", "0",  "0",  "0", "1", "1", 
+"UTM",						"1",  "1",  "0", "0",  "0",  "1", "1", "1", 
+"Polyconic",				        "1",  "1",  "1", "0",  "0",  "0", "1", "1",
+"Sinusoidal",				        "1",  "1",  "0", "0",  "0",  "0", "1", "1",
+"CylindricalEquidistant",	                "1",  "1",  "0", "1",  "0",  "0", "1", "1",
+"PolarStereographic",		                "1",  "1",  "0", "0",  "0",  "0", "1", "1",
+"Satellite",		                        "1",  "1",  "1", "0",  "0",  "0", "1", "1",
+"NoProjection",				        "1",  "0",  "0", "0",  "0",  "0", "0", "0"		
+};
+
+
+const char** TeGetProjInfo()
+{
+	return teProjInfo;
+}
+
+TeProjInfo
+TeProjectionInfo ( const string& projName  )
+{
+
+	TeProjInfoMap pjMap;
+	TeProjInfo pjInfo;
+
+	int k = 0;
+
+	for ( int i = 0; i < NUM_PROJ; i++ )
+	{
+		string name = teProjInfo [k++];
+			
+	    pjInfo.hasUnits  = atoi ( teProjInfo [k++] );
+	    pjInfo.hasLon0   = atoi ( teProjInfo [k++] );
+	    pjInfo.hasLat0   = atoi ( teProjInfo [k++] );
+	    pjInfo.hasStlat1 = atoi ( teProjInfo [k++] );
+		pjInfo.hasStlat2 = atoi ( teProjInfo [k++] );
+		pjInfo.hasScale  = atoi ( teProjInfo [k++] );
+		pjInfo.hasOffx   = atoi ( teProjInfo [k++] );
+	    pjInfo.hasOffy   = atoi ( teProjInfo [k++] );
+
+		pjMap [ name ] = pjInfo;
+	}
+
+
+	TeProjInfoMap::iterator it = pjMap.find ( projName );
+
+	if ( it == pjMap.end() )
+		throw TeException ( PROJECTION_NOT_AVAILABLE );
+
+return (*it).second;
+}
+
+//========================================================
+//
+// PROJECTION FACTORY
+//
+// =======================================================
+
+TeProjection*
+TeProjectionFactory::make ( const TeProjectionParams& par )
+{
+	string punits;
+	if (par.units.empty())
+		punits = "Meters";
+	else
+		punits = par.units;
+
+	if ( par.name == "UTM" )
+		return new TeUtm ( par.datum, par.lon0, par.lat0,
+		par.offx, par.offy, punits, par.scale, par.hemisphere );
+
+	if ( par.name == "LambertConformal")
+		return new TeLambertConformal ( par.datum, par.lon0, par.lat0,
+		par.offx, par.offy, par.stlat1, par.stlat2, punits );
+	
+	if ( par.name == "Albers" )
+		return new TeAlbers ( par.datum, par.lon0, par.lat0,
+		par.offx, par.offy, par.stlat1, par.stlat2, punits );
+
+	if ( par.name == "Miller")
+		return new TeMiller ( par.datum, par.lon0, par.offx, par.offy, punits );
+
+	if ( par.name == "LatLong" )
+	{
+		if (par.units.empty())
+			punits = "DecimalDegrees";
+		else
+			punits = par.units;
+		return new TeLatLong ( par.datum, punits );
+	}
+
+	if ( par.name == "Polyconic" )
+		return new TePolyconic ( par.datum, par.lon0, par.lat0, par.offx, par.offy, punits); 
+
+	if ( par.name == "Mercator" )
+		return new TeMercator ( par.datum, par.lon0, par.lat0, 
+		par.offx, par.offy, par.stlat1, punits );
+
+	if ( par.name == "Sinusoidal")
+		return new TeSinusoidal ( par.datum, par.lon0, par.offx, par.offy, punits );
+
+	if ( par.name == "CylindricalEquidistant")
+		return new TeCylindricalEquidistant ( par.datum, par.lon0, par.offx, par.offy, par.stlat1, punits);
+
+	if ( par.name == "PolarStereographic")
+		return new TePolarStereographic ( par.datum, par.lon0, par.offx, par.offy,punits, par.hemisphere );
+
+//FAMI
+	if ( par.name == "Satellite")
+		return new TeSatelliteProjection ( par.datum, par.offx, par.offy, par.pri, par.prj, par.pis, par.pjs, par.lat0, par.lon0, par.prs, par.pscn, par.pyaw);
+
+	if ( par.name == "NoProjection")
+		return new TeNoProjection(par.datum,punits);	
+	return 0;
+}
+
+TeProjectionParams 
+TeProjection::params () const
+{
+	TeProjectionParams par;
+	
+	par.name  = GPname;
+	par.datum = GPdatum;
+	par.lon0  = GPlon0;
+	par.lat0  = GPlat0;
+	par.offx  = GPoffx;
+	par.offy  = GPoffy;
+	par.stlat1 = GPstlat1;
+	par.stlat2 = GPstlat2;
+	par.units  = GPunits;
+	par.scale  = GPscale;
+	par.hemisphere =  GPhemisphere;
+
+return par;
+}
+
+
+TeProjection::TeProjection(const TeProjection& rhs)
+{
+	GPname  = rhs.GPname;
+	GPdatum = rhs.GPdatum;
+	GPlon0  = rhs.GPlon0;
+	GPlat0  = rhs.GPlat0;
+	GPoffx  = rhs.GPoffx;
+	GPoffy  = rhs.GPoffy;
+	GPstlat1 = rhs.GPstlat1;
+	GPstlat2 = rhs.GPstlat2;
+	GPunits  = rhs.GPunits;
+	GPscale  = rhs.GPscale;
+	GPhemisphere = rhs.GPhemisphere;
+}
+
+TeProjection& 
+TeProjection::operator=(const TeProjection& rhs)
+{
+	if ( this != &rhs )
+	{
+		GPname  = rhs.GPname;
+		GPdatum = rhs.GPdatum;
+		GPlon0  = rhs.GPlon0;
+		GPlat0  = rhs.GPlat0;
+		GPoffx  = rhs.GPoffx;
+		GPoffy  = rhs.GPoffy;
+		GPstlat1 = rhs.GPstlat1;
+		GPstlat2 = rhs.GPstlat2;
+		GPunits  = rhs.GPunits;
+		GPscale  = rhs.GPscale;
+		GPhemisphere = rhs.GPhemisphere;
+	}
+	return *this;
+}
+
+
+
+/*******************************************************************
+	CHECKS IF A PROJECTION INSTANCE IS EQUAL TO ANOTHER
+********************************************************************/
+
+bool
+TeProjection::operator== (const TeProjection& proj)
+{
+	if (GPname == "NoProjection" && proj.GPname == "NoProjection")
+		return true;
+	if (GPname  != proj.GPname)
+		return false;
+	if (!(GPdatum==proj.GPdatum))
+		return false;
+	if (!TeFPEquals(GPlon0, proj.GPlon0, 0.0000000001))
+		return false;
+	if (!TeFPEquals(GPlat0, proj.GPlat0, 0.0000000001))
+		return false;
+	if (!TeFPEquals(GPoffx,proj.GPoffx,0.001))
+		return false;
+	if (!TeFPEquals(GPoffy,proj.GPoffy,0.001))
+		return false;
+	if (!TeFPEquals(GPstlat1,proj.GPstlat1,0.0000000001))
+		return false;
+	if (!TeFPEquals(GPstlat2,proj.GPstlat2,0.0000000001))
+		return false;
+	if (GPhemisphere!=proj.GPhemisphere)
+		return false;
+	if (GPunits != proj.GPunits)
+		return false;
+	if (!TeFPEquals(GPscale,proj.GPscale, 0.0000000001))
+		return false;
+
+	return true;
+}
+
+/*******************************************************************
+	PRINTS INFORMATION ABOUT A PROJECTION
+********************************************************************/
+
+
+void
+TeProjection::print ( FILE* file_ )
+{
+	TeProjInfo pjInfo = TeProjectionInfo ( GPname );
+
+	fprintf(file_,"%s\n", "// Projection Information" );
+	fprintf ( file_, "%s %s \n", "PROJECTION", GPname.c_str() );
+	fprintf ( file_, "%s %s \n", "DATUM", GPdatum.name().c_str() );
+	fprintf ( file_, "%s %s \n", "UNITS", GPunits.c_str() );
+	
+	if ( pjInfo.hasLon0 )
+		fprintf ( file_, "%s %17.6f \n", "ORIGIN LONG", GPlon0 );
+
+	if ( pjInfo.hasLat0 )
+		fprintf ( file_, "%s %17.6f \n", "ORIGIN LAT", GPlat0 );
+
+	if ( pjInfo.hasOffx )
+		fprintf ( file_, "%s %17.6f \n", "FALSE EASTING", GPoffx );
+
+	if ( pjInfo.hasOffy )
+		fprintf ( file_, "%s %17.6f \n", "FALSE NORTHING", GPoffy );
+	
+	if ( pjInfo.hasStlat1 )
+		fprintf ( file_, "%s %17.6f \n", "FIRST STANDARD PARALEL", GPstlat1 );
+	
+	if ( pjInfo.hasStlat2 )
+		fprintf ( file_, "%s %17.6f \n", "SECOND STANDARD PARALEL", GPstlat2 );
+
+	if ( pjInfo.hasScale )
+		fprintf ( file_, "%s %17.6f \n", "SCALE", GPscale );
+
+	fprintf(file_,"%s\n", "// End of Projection Information" );
+}
+
+
+string
+TeProjection::describe ()
+{
+	string desc;
+	if (GPname == "NoProjection")
+	{
+		desc = "NoProjection";
+		return desc;
+	}
+	desc = GPname;
+	TeProjInfo pjInfo = TeProjectionInfo ( GPname );
+
+	desc =  GPunits;
+	if ( pjInfo.hasLon0 )
+		desc += "," + Te2String(GPlon0*TeCRD,6);
+
+	if ( pjInfo.hasLat0 )
+		desc += "," + Te2String(GPlat0*TeCRD,6);
+
+	if ( pjInfo.hasStlat1 )
+		desc += ", " + Te2String(GPstlat1*TeCRD,6);
+	
+	if ( pjInfo.hasStlat2 )
+		desc += "," + Te2String(GPstlat2*TeCRD,6);
+
+	if ( pjInfo.hasOffx )
+		desc += "," + Te2String(GPoffx,6);
+
+	if ( pjInfo.hasOffy )
+		desc += "," + Te2String(GPoffy,6);
+	
+	if ( pjInfo.hasScale )
+		desc += "," + Te2String(GPscale,6);
+
+	return desc;
+}
+
+
+bool decodifyDescription(const string& projDescription, TeProjectionParams& pars)
+{
+	vector<string> projDesc;
+	if (TeSplitString(projDescription, ",", projDesc) <= 0)
+		return false;
+	unsigned int npar = projDesc.size();
+	TeProjInfo pjInfo = TeProjectionInfo (projDesc[0]);
+	pars.name = projDesc[0];
+	if (npar > 1)
+		pars.units = projDesc[1];
+	else 
+		return true;
+
+	unsigned int nextp = 2;
+	if (pjInfo.hasLon0)
+	{
+		 if (nextp < npar)
+		 {
+			pars.lon0 = atof(projDesc[nextp].c_str()) * TeCDR;
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+
+	if (pjInfo.hasLat0)
+	{
+		 if (nextp < npar)
+		 {
+			pars.lat0 = atof(projDesc[nextp].c_str()) * TeCDR;
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+
+	if (pjInfo.hasStlat1)
+	{
+		 if (nextp < npar)
+		 {
+			pars.stlat1 = atof(projDesc[nextp].c_str()) * TeCDR;
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+
+	if (pjInfo.hasStlat2)
+	{
+		 if (nextp < npar)
+		 {
+			pars.stlat2 = atof(projDesc[nextp].c_str()) * TeCDR;
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+
+	if (pjInfo.hasOffx)
+	{
+		 if (nextp < npar)
+		 {
+			pars.offx = atof(projDesc[nextp].c_str());
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+
+	if (pjInfo.hasOffy)
+	{
+		 if (nextp < npar)
+		 {
+			pars.offy = atof(projDesc[nextp].c_str());
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+	
+	if (pjInfo.hasScale)
+	{
+		 if (nextp < npar)
+		 {
+			pars.scale = atof(projDesc[nextp].c_str());
+			nextp++;
+		 }
+		 else
+			 return false;
+	}
+	return true;
+}
+
+/********************************************************************
+		Planimetric datum transformation 
+********************************************************************/
+void
+TeProjection :: ChangeLL (double &lon1, double &lat1)		
+{
+	double 	equad1,	// Squared eccentricity - datum 1
+			equad2,	// Squared eccentricity - datum 2
+			n1,		// Great normal of ellipsoid - datum 1
+			n2,		// Great normal od ellipsoid - datum 2
+			x1,		// Geocentric cartesian coordinates - datum 1 
+			y1,
+			z1,
+			x2,		// Geocentric cartesian coordinates - datum 2
+			y2,
+			z2,
+			d,lat2,		// Ancillary variable
+			lon2;
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+ 	if( GPdestination->GPdatum.radius() == 0.) return;
+
+	int	flt1 = (int)(Pflt*1000000000.);
+	int	flt2 = (int)(GPdestination->GPdatum.flattening()*1000000000.);
+	if (Prd == GPdestination->GPdatum.radius() && flt1==flt2)
+		return;
+
+// Geocentric cartesian coordinates calculation - datum 1
+	equad1 = 2.*Pflt;
+	equad1 -= Pflt*Pflt;
+	double a1,a2,a3;
+	a1 = sin(lat1);
+	a1 *= a1;
+	a1 *= equad1;
+	a2 = 1-a1;
+	n1 = Prd/sqrt(a2);
+	x1 = n1*cos(lat1)*cos(lon1);
+	y1 = n1*cos(lat1)*sin(lon1);
+	z1 = (n1*(1-equad1))*sin(lat1);
+
+// Geocentric cartesian coordinates calculation - datum 2
+	if (GPdatum.xShift() == TeMAXFLOAT || GPdestination->GPdatum.xShift() == TeMAXFLOAT)
+	{
+		x2 = x1; 
+		y2 = y1;
+		z2 = z1;
+	}
+	else
+	{	
+		x2 = x1 + (GPdatum.xShift() - GPdestination->GPdatum.xShift());
+		y2 = y1 + (GPdatum.yShift() - GPdestination->GPdatum.yShift());
+		z2 = z1 + (GPdatum.zShift() - GPdestination->GPdatum.zShift());
+	}
+
+// Geodetic coordinates calculation - datum 2
+	equad2 = 2.*GPdestination->GPdatum.flattening();
+	equad2 -= (GPdestination->GPdatum.flattening())*(GPdestination->GPdatum.flattening());
+	lat2 = lat1;
+	do
+	{
+		a1 = sin(lat2);
+		a1 *= a1;
+		a1 *= equad2;
+		a2 = 1-a1;
+		n2 = GPdestination->GPdatum.radius()/sqrt(a2);
+		a1 = equad2*sin(lat2);
+		a1 *= n2;
+		a1 += z2;
+		a2 = x2*x2;
+		a2 += (y2*y2);
+		a3 = sqrt(a2);
+		lat2 = atan2(a1,a3);
+		a1 = sin(lat2);
+		a1 *= a1;
+		a1 *= equad2;
+		a2 = 1-a1;
+		a3 = sqrt(a2);
+		d = (GPdestination->GPdatum.radius()/a3)-n2;
+	}
+	while (fabs(d) > 0.0000001);
+	lon2 = atan2(y2,x2);
+	lat1 = lat2;
+	lon1 = lon2;
+}
+
+/********************************************************************
+		GEODETIC TO UTM COORDINATES
+********************************************************************/
+
+
+TeCoord2D
+TeUtm :: LL2PC (TeCoord2D& ptll)
+{
+
+	double	k0,		// Scale factor
+		equad,		// Squared eccentricity
+		n,		// Great normal of ellipsoid
+		elinquad,	// ancillary variables 
+		aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9,
+		aux10,aux11,aux12,aux13,t,c,ag,m,ptllx,ptlly;
+
+	double Pflt = GPdatum.flattening();
+	ptllx = ptll.x();
+	ptlly = ptll.y();
+	k0 = 1. - (1./2500.);
+	equad = 2.*Pflt;	
+	equad -= Pflt*Pflt;
+	elinquad = equad/(1. - equad);
+	aux1 = equad*equad;
+	aux2 = aux1*equad;
+	aux3 = sin((double)2*ptlly);
+	aux4 = sin((double)4*ptlly);
+	aux5 = sin((double)6*ptlly);
+
+	double a1, a2, a3;
+	a1 = equad/4.;
+	a2 = 3.*aux1/64.;
+	a3 = 5.*aux2/256.;
+	aux6 = (1-a1-a2-a3)*ptlly;
+
+	a1 = 3.*equad/8.;
+	a2 = 3.*aux1/32.;
+	a3 = 45.*aux2/1024.;
+	aux7 = (a1+a2+a3)*aux3;
+
+	a1 = 15.*aux1/256.;
+	a2 = 45.*aux2/1024.;
+	aux8 = (a1+a2)*aux4;
+
+	aux9 = 35.*aux2;
+	aux9 /= 3072.;
+	aux9 *= aux5;
+
+	a1 = sin(ptlly);	
+	a1 *= a1;		
+	a1 *= equad;		
+	n = GPdatum.radius()/sqrt((double)1-a1);
+
+
+	t = tan(ptlly);		
+	t *= t;			
+
+	c = cos(ptlly);		
+	c *= c;			
+	c *= elinquad;		
+	ag = (ptllx-GPlon0)*cos(ptlly);
+	m = GPdatum.radius()*(aux6 - aux7 + aux8 - aux9);
+
+
+	a1 = ag*ag*ag;
+	aux10 = (1.-t+c)*a1/6.;
+
+	a1 = 5.-(18.*t);
+	a2 = a1+t*t;
+	a1 = a2+72.*c;
+	a2 = a1-(58.*elinquad);
+	a1 = ag*ag*ag;		
+	a1 *= ag;		
+	a1 *= ag;		
+	aux11 = a2*a1/120.;	
+
+	a1 = 5.-t+9.*c;
+	a2 = 4.*c*c;
+	a3 = ag*ag;
+	a3 *= ag;
+	a3 *= ag;
+	aux12 = (a1+a2)*a3/24.;
+
+	a1 = 61.-(58.*t) ;
+	a2 = a1+(t*t);
+	a1 = a2+(600.*c);
+	a2 = a1-(330.*elinquad);
+	a1 = ag*ag*ag;		
+	a1 *= ag;		
+	a1 *= ag;		
+	a1 *= ag;		
+	aux13 = a2*a1/720.;	
+
+	ptllx = k0*n*(ag + aux10 + aux11);
+
+	a1 = ag*ag/2;
+	a2 = a1+aux12+aux13;
+	a3 = n*tan(ptlly);
+	a1 = a2*a3;
+	ptlly = k0*(m+a1);
+
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));
+}
+
+
+/********************************************************************
+		UTM TO GEODETIC COORDINATES
+********************************************************************/
+
+TeCoord2D
+TeUtm :: PC2LL (TeCoord2D& ptpc)
+{
+	double  k0,             	// Scale factor
+		equad,			// Squared eccentricity
+		n1,			// Great normal of ellipsoid
+		elinquad,		// Ancillary variables
+		e1,aux1,aux2,aux3,aux4,aux5,m,mi,aux6,aux7,aux8,lat1,
+		c1,t1, quoc,r1,d,aux9,aux10,aux11,aux12,ptpcx,ptpcy;
+
+	double Prd  = GPdatum.radius();
+	double Pflt = GPdatum.flattening();
+	
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;		
+
+	k0 = 1. - (1./2500.);
+	equad = 2.*Pflt;		
+	equad -= Pflt*Pflt;		
+	elinquad = equad/(1. - equad);
+
+	double a1,a2,a3;
+	a1 = sqrt((double)1-equad);
+	e1 = (1.-a1)/(1.+a1);
+
+	aux1 = equad*equad;
+	aux2 = aux1*equad;
+	aux3 = e1*e1;
+	aux4 = e1*aux3;
+	aux5 = aux4*e1;
+
+	m = ptpcy/k0;
+
+
+	a1 = 1.-(equad/4.);
+	a2 = 3.*(aux1/64.);
+	a3 = 5.*(aux2/256.);
+	mi = m/(Prd*(a1-a2-a3));
+
+
+	a1 = 3.*(e1/2.);
+	a2 = 27.*(aux4/32.);
+	a3 = sin((double)2*mi);
+	aux6 = (a1-a2)*a3;
+
+	a1 = 21.*(aux3/16.);
+	a2 = 55.*(aux5/32.);
+	a3 = sin((double)4*mi);
+	aux7 = (a1-a2)*a3;
+
+	a1 = 151.*(aux4/96.);
+	a2 = sin((double)6*mi);
+	aux8 = a1*a2;
+
+	lat1 = mi + aux6 + aux7 + aux8;
+
+	c1 = cos(lat1);			
+	c1 *= c1;			
+	c1 *= elinquad;			
+
+	t1 = tan(lat1);			
+	t1 *= t1;			
+
+	a1 = sin(lat1);			
+	a1 *= a1;			
+	a1 *= equad;			
+	a2 = 1.-a1;
+	n1 = Prd/sqrt(a2);
+
+	a1 = sin(lat1);
+	a1 *= a1;
+	a1 *= equad;
+	a2 = 1.-a1;
+	quoc = a2*a2*a2;
+
+	r1 = Prd*(1.-equad);
+	r1 /= sqrt(quoc);
+
+	d = ptpcx;
+	d /= (n1*k0);
+
+
+	a1 = 5.+(3.*t1);
+	a1 += (10.*c1);
+	a1 += (-4.*(c1*c1));
+	a1 += (-9.*elinquad);
+	a1 *= d;
+	a1 *= d;
+	a1 *= d;
+	a1 *= d;
+	aux9 = a1/24.;
+
+	a1 = 61.+(90.*t1);
+	a1 += (298.*c1);
+	a1 += (45.*(t1*t1));
+	a1 += (-252.*elinquad);
+	a1 += (-3.*c1*c1);
+	aux10 = d*d*d;			
+	aux10 *= d;			
+	aux10 *= d;			
+	aux10 *= d;			
+	aux10 *= a1;
+	aux10 /= 720.;
+
+	a1 = d*d*d;
+	a1 /= 6.;
+	a2 = 2.*t1;
+	a2 += (1.+c1);
+	aux11 = d-a2*a1;
+
+	a1 = 5.-(2.*c1);
+	a1 += (28.*t1);
+	a1 += (-3.*c1*c1);
+	a1 += (8.*elinquad);
+	a1 += (24.*t1*t1);
+	aux12 = d*d*d;			
+	aux12 *= d;			
+	aux12 *= d;			
+	aux12 *= a1;			
+	aux12 /= 120.;			
+
+	a1 = d*d/2.;
+	a1 += (- aux9 + aux10);
+	a2 = tan(lat1)/r1;
+	a2 *= n1;
+	ptpcy = lat1-a2*a1;
+
+	ptpcx= GPlon0 + (aux11 + aux12)/cos(lat1);
+
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return(TeCoord2D(ptpcx,ptpcy));
+}
+
+/********************************************************************
+		GEODETIC TO MERCATOR COORDINATES
+********************************************************************/
+TeCoord2D
+TeMercator :: LL2PC (TeCoord2D& ptll)
+{
+	double	equad,			//Squared eccentricity
+		aux1,			// Ancillary variables
+		aux2,aux3,aux4,aux5,aux6,ptllx,ptlly;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptllx = ptll.x();		
+	ptlly = ptll.y();		
+
+	equad = 2.*Pflt;		
+	equad -= Pflt*Pflt;		
+	double	a1,a2,a3;		
+ 
+	a1 = tan(ptlly/(double)2);	
+	a2 = 1.+a1;			
+	a3 = 1.-a1;			
+	aux1 = a2/a3;			
+ 
+	a1 = equad*equad/4.;		
+	a1 += equad;			
+	a2 = equad*equad*equad/8.;	
+	a3 = sin(ptlly);		
+	aux2 = (a1+a2)*a3;		
+ 
+	a1 = equad*equad/12.;		
+	a2 = equad*equad*equad/16.;	
+	a3 = sin((double)3*ptlly);	
+	aux3 = (a1+a2)*a3;		
+ 
+	a1 = equad*equad*equad/80.;	
+	a2 = sin((double)5*ptlly);	
+	aux4 = a1*a2;			
+	aux5 = cos(GPstlat1);
+ 
+	a1 = sin(GPstlat1);		
+	a1 *= a1;			
+	a1 *= equad;			
+	a2 = sqrt((double)1-a1);	
+	aux6 = 1./a2;			
+
+	ptllx = Prd*(ptllx - GPlon0)*aux5*aux6;
+	ptlly = Prd*(log(aux1) - aux2 + aux3 - aux4)*aux5*aux6;
+
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));	
+}
+
+/********************************************************************
+		MERCATOR TO GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeMercator :: PC2LL (TeCoord2D& ptpc)
+{
+	double	equad,			//Squared eccentricity 
+	        pi,			// PII value
+		t,			// Ancillary variables
+		xx,aux1,aux2,aux3,aux4,aux5,ptpcx,ptpcy;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	equad = 2.*Pflt;		
+	equad -= Pflt*Pflt;		
+	pi = 4.*atan((double)1);
+	double	a1,a2;		
+	aux1 = cos(GPstlat1);
+
+	a1 = sin(GPstlat1);		
+	a1 *= a1;			
+	a1 *= equad;			
+	a2 = sqrt((double)1-a1);	
+	aux2 = 1./a2;			
+	ptpcx = ptpcx/(aux1*aux2);
+	ptpcy = ptpcy/(aux1*aux2);
+	t = exp(-ptpcy/Prd);
+	xx = pi/2. - 2.*atan(t);
+ 
+	a1 = equad/2.;			
+	a1 += 5.*equad*equad/24.;	
+	a1 += equad*equad*equad/12.;	
+	a2 = sin((double)4*atan(t));	
+	aux3 = a1*a2;			
+ 
+	a1 = 7.*equad*equad/48.;	
+	a1 += 29.*equad*equad*equad/240.;	
+	a2 = sin((double)8*atan(t));	
+	aux4 = -a1*a2;			
+ 
+	a1 = 7.*equad*equad*equad/120.;	
+	a2 = sin((double)12*atan(t));	
+	aux5 = a1*a2;		 
+
+	ptpcy = xx + aux3 + aux4 + aux5;
+	ptpcx = ptpcx/Prd + GPlon0;
+	
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return(TeCoord2D(ptpcx,ptpcy));
+}
+
+
+
+
+/********************************************************************
+		GEODETIC TO LAMBERT CONIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeLambertConformal :: LL2PC (TeCoord2D& ptll)
+{
+
+	double	equad,			// Squared eccentricity
+		e,			// Ancillary variables
+		m1,m2,aux1,aux2,aux0,t1,t2,t0,n,efe,ro0,aux,
+		t,ro,teta,ptllx,ptlly;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptllx = (double)ptll.x();
+	ptlly = (double)ptll.y();
+
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+	e = sqrt(equad);
+
+	m1 = cos(GPstlat1)/sqrt((double)1-equad*pow(sin(GPstlat1),(double)2));
+	m2 = cos(GPstlat2)/sqrt((double)1-equad*pow(sin(GPstlat2),(double)2));
+	aux1 = sqrt(((double)1-e*sin(GPstlat1))/((double)1+e*sin(GPstlat1)));
+	aux2 = sqrt(((double)1-e*sin(GPstlat2))/((double)1+e*sin(GPstlat2)));
+	aux0 = sqrt(((double)1-e*sin(GPlat0))/((double)1+e*sin(GPlat0)));
+	t1 = ((1.-tan(GPstlat1/(double)2))/(1.+tan(GPstlat1/(double)2)))/pow(aux1,e);
+	t2 = ((1.-tan(GPstlat2/(double)2))/(1.+tan(GPstlat2/(double)2)))/pow(aux2,e);
+	t0 = ((1.-tan(GPlat0/(double)2))/(1.+tan(GPlat0/(double)2)))/pow(aux0,e);
+
+	if (GPstlat1 == GPstlat2)
+		n = sin(GPstlat1);
+	else
+		n = (log(m1)-log(m2))/(log(t1)-log(t2));
+
+	efe = m1/(n*pow(t1,n));
+	ro0 = Prd*efe*pow(t0,n);
+
+	aux = sqrt(((double)1-e*sin(ptlly))/((double)1+e*sin(ptlly)));
+	t = ((1.-tan(ptlly/(double)2))/(1.+tan(ptlly/(double)2)))/pow(aux,e);
+	ro = Prd*efe*pow(t,n);
+	teta = n*(ptllx - GPlon0);
+	ptllx = ro*sin(teta);
+	ptlly = ro0 - ro*cos(teta);
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));	
+}
+
+
+
+/********************************************************************
+		LAMBERT CONIC TO GEODETIC COORDINATES
+ ********************************************************************/
+TeCoord2D
+TeLambertConformal :: PC2LL (TeCoord2D& ptpc)
+{
+	double	equad,			// Squared eccentricity 
+		pi,			// PI value
+		e,m1,m2,aux1,aux2,aux0,t1,t2,t0,n,efe,ro0,ro,teta,
+		t,xx,aux3,aux4,aux5,ptpcx,ptpcy;
+
+	int	sinal;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+	
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+	e = sqrt(equad);
+	pi = 4.*atan((double)1);
+
+	m1 = cos(GPstlat1)/sqrt((double)1-equad*pow(sin(GPstlat1),(double)2));
+	m2 = cos(GPstlat2)/sqrt((double)1-equad*pow(sin(GPstlat2),(double)2));
+	aux1 = sqrt(((double)1-e*sin(GPstlat1))/((double)1+e*sin(GPstlat1)));
+	aux2 = sqrt(((double)1-e*sin(GPstlat2))/((double)1+e*sin(GPstlat2)));
+	aux0 = sqrt(((double)1-e*sin(GPlat0))/((double)1+e*sin(GPlat0)));
+	t1 = ((1.-tan(GPstlat1/(double)2))/(1.+tan(GPstlat1/(double)2)))/pow(aux1,e);
+	t2 = ((1.-tan(GPstlat2/(double)2))/(1.+tan(GPstlat2/(double)2)))/pow(aux2,e);
+	t0 = ((1.-tan(GPlat0/(double)2))/(1.+tan(GPlat0/(double)2)))/pow(aux0,e);
+
+	if (GPstlat1 == GPstlat2)
+		n = sin(GPstlat1);
+	else
+		n = (log(m1)-log(m2))/(log(t1)-log(t2));
+
+	efe = m1/(n*pow(t1,n));
+	ro0 = Prd*efe*pow(t0,n);
+
+	sinal = (int)(n/fabs(n));
+	ro = sqrt(ptpcx*ptpcx + (ro0-ptpcy)*(ro0-ptpcy));
+	ro *= sinal;
+	teta = atan(ptpcx/(ro0-ptpcy));
+	t = pow((ro/(Prd*efe)),(double)1/n);
+	xx = pi/2. - 2.*atan(t);
+	aux3 = equad/2. + 5.*equad*equad/24. + equad*equad*equad/12.;
+	aux4 = 7.*equad*equad/48. + 29.*equad*equad*equad/240.;
+	aux5 = (7.*equad*equad*equad/120.)*sin(12.*atan(t));
+
+	ptpcy = xx + aux3*sin(4.*atan(t)) - aux4*sin(8.*atan(t)) + aux5;
+	ptpcx = teta/n + GPlon0;
+	
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return (TeCoord2D(ptpcx,ptpcy));
+}
+
+/********************************************************************
+		GEODETIC TO POLYCONIC COORDINATES
+********************************************************************/
+TeCoord2D
+TePolyconic :: LL2PC (TeCoord2D& ptll)
+{
+	double	equad,			// Squared eccentricity 
+		n,			// Great normal of ellipsoid
+		aux01,			// Ancillary variables
+		aux02,aux03,aux04,m0,aux1,aux2,aux3,
+		aux4,m,e,ptllx,ptlly;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptllx = (double)ptll.x();
+	ptlly = (double)ptll.y();
+
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+
+	aux01 = (1.-equad/4.-3.*equad*equad/64.-5.*equad*equad*equad/256.)*GPlat0;
+	aux02 = (3.*equad/8+3.*equad*equad/32.+45.*equad*equad*equad/1024.)*sin((double)2*GPlat0);
+	aux03 = (15.*equad*equad/256.+45.*equad*equad*equad/1024.)*sin((double)4*GPlat0);
+	aux04 = (35.*equad*equad*equad/3072.)*sin((double)6*GPlat0);
+	m0 = Prd*(aux01 - aux02 + aux03 - aux04);
+
+	if (ptlly == 0.)
+	{
+		ptllx = Prd*(ptllx - GPlon0);
+		ptlly = -m0;
+	}
+	else
+	{
+		aux1 = (1.-equad/4.-3.*equad*equad/64.-5.*equad*equad*equad/256.)*ptlly;
+		aux2 = (3.*equad/8+3.*equad*equad/32.+45.*equad*equad*equad/1024.)*sin((double)2*ptlly);
+		aux3 = (15.*equad*equad/256.+45.*equad*equad*equad/1024.)*sin((double)4*ptlly);
+		aux4 = (35.*equad*equad*equad/3072.)*sin((double)6*ptlly);
+		m = Prd*(aux1 - aux2 + aux3 - aux4);
+		n = Prd/sqrt((double)1-equad*pow(sin(ptlly),(double)2));
+		e = (ptllx - GPlon0)*sin(ptlly);
+		ptllx = n*sin(e)/tan(ptlly);
+		ptlly = m - m0 + (n*(1. - cos(e))/tan(ptlly));
+	}
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));	
+}
+
+/*******************************************************************
+		POLYCONIC TO GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TePolyconic :: PC2LL (TeCoord2D& ptpc)
+{	
+	double	A,	
+		B,
+		C,
+		equad,			// Squared eccentricity
+		aux01,			// Ancillary variables
+		aux02,aux03,aux04,m0,mn,mnl,ma,cp,lat1,lat2,aux05,
+		aux06,aux07,aux08,aux09,aux10,aux11,aux12,aux21,
+		aux22,aux23,aux24,ptpcx,ptpcy;
+
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+
+	// Initialize latitude with latitude of origin
+	aux01 = (1.-equad/4.-3.*equad*equad/64.-5.*equad*equad*equad/256.)*GPlat0;
+	aux02 = (3.*equad/8+3.*equad*equad/32.+45.*equad*equad*equad/1024.)*sin((double)2*GPlat0);
+	aux03 = (15.*equad*equad/256.+45.*equad*equad*equad/1024.)*sin((double)4*GPlat0);
+	aux04 = (35.*equad*equad*equad/3072.)*sin((double)6*GPlat0);
+	m0 = Prd*(aux01 - aux02 + aux03 - aux04);
+
+	if (ptpcy == (-m0))
+	{
+		ptpcy= 0.;
+		ptpcx = ptpcx/Prd + GPlon0;
+	}
+	else
+	{
+		A = (m0 + ptpcy)/Prd;
+		B = ((ptpcx*ptpcx)/(Prd*Prd)) +(A*A);
+
+		lat2 = A;
+
+		do
+		{
+			C = (sqrt(1.- equad*sin(lat2)*sin(lat2)))*tan(lat2);
+
+			// mn calculation	
+			aux21 = (1.-equad/4.-3.*equad*equad/64.-5.*equad*equad*equad/256.)*lat2;
+			aux22 = (3.*equad/8.+3.*equad*equad/32.+45.*equad*equad*equad/1024.)*sin((double)2*lat2);
+			aux23 = (15.*equad*equad/256.+45.*equad*equad*equad/1024.)*sin((double)4*lat2);
+			aux24 = (35.*equad*equad*equad/3072.)*sin((double)6*lat2);
+			mn = Prd*(aux21 - aux22 + aux23 - aux24);
+		
+			// mnl calculation
+			aux05 = 1.- equad/4.-3.*equad*equad/64.-5.*equad*equad*equad/256.;
+			aux06 = 2.*(3.*equad/8.+3.*equad*equad/32.+45.*equad*equad*equad/1024.)*cos((double)2*lat2);
+			aux07 = 4.*(15.*equad*equad/256.+45.*equad*equad*equad/1024.)*cos((double)4*lat2);
+			aux08 = 6.*(35.*equad*equad*equad/3072.)*cos((double)6*lat2);
+			mnl = aux05 - aux06 + aux07- aux08;
+
+			// ma calculation
+			ma = mn/Prd;
+
+			aux09 = (A*(C*ma+1)-ma)-(0.5*(ma*ma+B)*C);
+			aux10 = equad*sin((double)2*lat2)*(ma*ma+B-2.*A*ma);
+			aux11 = 4.*C+(A-ma);
+			aux12 = C*mnl-(2./sin((double)2*lat2));
+
+			// New latitude calculation 
+			lat1 = lat2 - (aux09/((aux10/(aux11*aux12)) - mnl));
+			cp = fabs(lat1-lat2) ;
+			lat2 = lat1;
+
+
+		}while(cp > 0.0000000001);
+
+		ptpcy = lat1;
+		ptpcx = ((asin((ptpcx*C)/Prd))/(sin(lat1))) + GPlon0;
+	}
+
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return (TeCoord2D(ptpcx,ptpcy));	
+
+}
+
+/********************************************************************
+	GEODETIC TO LAT LONG
+********************************************************************/
+TeCoord2D
+TeLatLong :: LL2PC (TeCoord2D& ptll)
+{
+	return TeCoord2D( ptll.x()*TeCRD, ptll.y()*TeCRD ); 
+}
+
+//FAMI
+void
+TeLatLong :: LL2PC (double xi, double yi, double& xo, double& yo) const
+{
+	xo = xi*TeCRD;
+	yo = yi*TeCRD;
+	return;
+}
+
+/********************************************************************
+	LAT LONG TO GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeLatLong :: PC2LL (TeCoord2D& ptpc)
+{
+	double ptpcx, ptpcy;
+
+	ptpcx = ptpc.x()*TeCDR;
+	ptpcy = ptpc.y()*TeCDR;
+	
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return TeCoord2D(ptpcx,ptpcy); 
+}
+
+//FAMI
+void
+TeLatLong :: PC2LL (double xi, double yi, double& ptpcx, double& ptpcy)
+{
+	ptpcx = xi*TeCDR;
+	ptpcy = yi*TeCDR;
+	
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return; 
+}
+
+/********************************************************************
+	GEODETIC TO ALBERS EQUAL-AREA COORDINATES
+********************************************************************/
+TeCoord2D
+TeAlbers :: LL2PC (TeCoord2D& ptll)
+{
+
+	double	equad,			// Squared eccentricity
+		e,			// Ancillary variables
+		m1,m2,aux1,aux10,aux11,aux12,aux2,aux20,aux21,
+		aux22,q0,q1,q2,q,n,c,ro0,teta,ro,ptllx,ptlly;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptllx = (double)ptll.x();
+	ptlly = (double)ptll.y();
+
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+	e = sqrt(equad);
+
+	m1 = cos(GPstlat1)/sqrt((double)1-equad*pow(sin(GPstlat1),(double)2));
+	m2 = cos(GPstlat2)/sqrt((double)1-equad*pow(sin(GPstlat2),(double)2));
+	aux1 = sin(ptlly)/((double)1-equad*pow(sin(ptlly),(double)2));
+	aux10 = sin(GPlat0)/((double)1-equad*pow(sin(GPlat0),(double)2));
+	aux11 = sin(GPstlat1)/((double)1-equad*pow(sin(GPstlat1),(double)2));
+	aux12 = sin(GPstlat2)/((double)1-equad*pow(sin(GPstlat2),(double)2));
+	aux2 = log((1. - e*sin(ptlly))/(1. + e*sin(ptlly)));
+	aux20 = log((1. - e*sin(GPlat0))/(1. + e*sin(GPlat0)));
+	aux21 = log((1. - e*sin(GPstlat1))/(1. + e*sin(GPstlat1)));
+	aux22 = log((1. - e*sin(GPstlat2))/(1. + e*sin(GPstlat2)));
+	q0 = (1. - equad)*(aux10 - (1./(2.*e))*aux20);
+	q1 = (1. - equad)*(aux11 - (1./(2.*e))*aux21);
+	q2 = (1. - equad)*(aux12 - (1./(2.*e))*aux22);
+	q = (1. - equad)*(aux1 - (1./(2.*e))*aux2);
+	n = (m1*m1 - m2*m2)/(q2 - q1);
+	c = m1*m1 + n*q1;
+	ro0 = Prd*sqrt(c - n*q0)/n;
+	teta = n*(ptllx - GPlon0);
+	ro = Prd*sqrt(c - n*q)/n;
+
+	ptllx = ro*sin(teta);
+	ptlly = ro0 - ro*cos(teta);
+
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));	
+}
+
+
+/********************************************************************
+		ALBERS EQUAL-AREA TO GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeAlbers :: PC2LL(TeCoord2D& ptpc)
+{
+
+	double	equad,			// Squared eccentricity
+		e,			// Eccentricity
+		m1,			// Ancillary variable
+		m2,aux10,aux11,aux12,aux20,aux21,aux22,q0,q1,q2,
+		n,c,ro0,ro,q,aux,beta,aux1,aux2,aux3,teta,ptpcx,ptpcy;
+
+	int	sinal;			// Ancillary variable	
+
+	
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	sinal = (int)(GPstlat2/fabs(GPstlat2));
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+	e = sqrt(equad);
+
+	m1 = cos(GPstlat1)/sqrt((double)1-equad*pow(sin(GPstlat1),(double)2));
+	m2 = cos(GPstlat2)/sqrt((double)1-equad*pow(sin(GPstlat2),(double)2));
+	aux10 = sin(GPlat0)/((double)1-equad*pow(sin(GPlat0),(double)2));
+	aux11 = sin(GPstlat1)/((double)1-equad*pow(sin(GPstlat1),(double)2));
+	aux12 = sin(GPstlat2)/((double)1-equad*pow(sin(GPstlat2),(double)2));
+	aux20 = log((1. - e*sin(GPlat0))/(1. + e*sin(GPlat0)));
+	aux21 = log((1. - e*sin(GPstlat1))/(1. + e*sin(GPstlat1)));
+	aux22 = log((1. - e*sin(GPstlat2))/(1. + e*sin(GPstlat2)));
+	q0 = (1. - equad)*(aux10 - (1./(2.*e))*aux20);
+	q1 = (1. - equad)*(aux11 - (1./(2.*e))*aux21);
+	q2 = (1. - equad)*(aux12 - (1./(2.*e))*aux22);
+	n = (m1*m1 - m2*m2)/(q2 - q1);
+	c = m1*m1 + n*q1;
+	ro0 = Prd*sqrt(c - n*q0)/n;
+	ro = sqrt(ptpcx*ptpcx + (ro0 - ptpcy)*(ro0 - ptpcy));
+	q = (c - (ro*ro*n*n/(Prd*Prd)))/n;
+	aux = ((1. - equad)/(2.*e))*log((1. - e)/(1. + e));
+	beta = asin(q/(1. - aux));
+	aux1 = (equad/3. + 31.*equad*equad/180.+517.*equad*equad*equad/5040.)*sin(2.*beta);
+	aux2 = (23.*equad*equad/360.+251.*equad*equad*equad/3780.)*sin(4.*beta);
+	aux3 = (761.*equad*equad*equad/45360.)*sin(6.*beta);
+	teta = fabs(atan(ptpcx/(ro0 - ptpcy)));
+
+	if (sinal == 1)
+	{
+		if (ptpcx < 0.)
+			teta = -teta;
+	}
+
+	if (sinal == -1)
+	{
+		if (ptpcx > 0.)
+			teta *= sinal;
+	}
+
+	ptpcy = beta + aux1 + aux2 + aux3;
+	ptpcx = GPlon0 + (teta/n);
+
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return (TeCoord2D(ptpcx,ptpcy));
+}
+
+/*******************************************************************
+		GEODETIC TO MILLER COORDINATES
+********************************************************************/
+TeCoord2D
+TeMiller :: LL2PC (TeCoord2D& ptll)
+{
+
+	double	pi,		// PI value
+		ptllx,ptlly;	// Ancillary variables 
+
+	int	sinal;		// Ancillary variables
+
+	double Prd  = GPdatum.radius();
+	
+	ptllx = (double)ptll.x();
+	ptlly = (double)ptll.y();
+
+	pi = 4.*atan((double)1);
+	sinal = (int)(fabs(ptlly)/ptlly);
+	
+	ptllx = Prd*(ptllx - GPlon0);
+
+	if (sinal == 1)
+		ptlly = (Prd/0.8)*(log(tan(pi/4. + 0.4*ptlly)));
+	else
+	{
+		ptlly *= sinal;
+		ptlly = (Prd/0.8)*(log(tan(pi/4. + 0.4*ptlly)));
+		ptlly *= sinal;
+	}
+
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));	
+}
+
+
+/********************************************************************
+		MILLER TO GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeMiller :: PC2LL (TeCoord2D& ptpc)
+{
+
+	double	e,		// Neperian logarithm base 
+		pi,		// PI value
+		ptpcx,ptpcy;	// Ancillary variables
+
+	int	sinal;		// Ancillary variable
+
+	double Prd  = GPdatum.radius();
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	e = 2.718281828;
+	pi = 4.*atan((double)1);
+	sinal = (int)(fabs(ptpcy)/ptpcy);
+
+	ptpcx = GPlon0 + (ptpcx/Prd);
+
+	if (sinal == 1)
+		ptpcy = 2.5*atan(pow(e,(0.8*ptpcy/Prd)))-5.*pi/8.;
+	else
+	{
+		ptpcy *= sinal;
+		ptpcy = 2.5*atan(pow(e,(0.8*ptpcy/Prd))) - 5.*pi/8.;
+		ptpcy *= sinal;
+	}
+
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return(TeCoord2D(ptpcx,ptpcy));
+}
+
+
+/*******************************************************************
+		GEODETIC TO SINUSOIDAL COORDINATES
+********************************************************************/
+TeCoord2D
+TeSinusoidal :: LL2PC (TeCoord2D& ptll)
+{
+
+	double	ptllx,ptlly;	// Ancillary variables 
+
+	double Prd  = GPdatum.radius();
+	
+	ptllx = (double)ptll.x();
+	ptlly = (double)ptll.y();
+	
+	ptllx = Prd*(ptllx - GPlon0);
+	ptllx *= cos(ptlly);
+
+	ptlly = Prd*ptlly;
+	
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));	
+}
+
+
+/********************************************************************
+		SINUSOIDAL TO GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeSinusoidal :: PC2LL (TeCoord2D& ptpc)
+{
+
+	double	ptpcx,ptpcy;	// Ancillary variables
+
+	double Prd  = GPdatum.radius();
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	ptpcy = ptpcy/Prd;
+
+	ptpcx = GPlon0 + (ptpcx/(Prd*cos(ptpcy)));
+	
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return(TeCoord2D(ptpcx,ptpcy));
+}
+
+/*******************************************************************
+		GEODETIC TO CYLINDRICAL EQUIDISTANT COORDINATES
+********************************************************************/
+TeCoord2D
+TeCylindricalEquidistant :: LL2PC (TeCoord2D& ptll)
+{
+	double	ptllx,ptlly;
+
+	double Prd  = GPdatum.radius();
+
+	ptllx = ptll.x();
+	ptlly = ptll.y();
+
+	ptllx = Prd*(ptllx - GPlon0)*cos(GPstlat1);
+	ptlly = Prd*ptlly;
+
+	return(TeCoord2D(ptllx+GPoffx,ptlly+GPoffy));
+}
+
+
+/*******************************************************************
+	CYLINDRICAL EQUIDISTANT TO	GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TeCylindricalEquidistant :: PC2LL (TeCoord2D& ptpc)
+{
+	double	ptpcx,ptpcy;
+
+	double Prd  = GPdatum.radius();
+
+	ptpcx = ptpc.x()-GPoffx;
+	ptpcy = ptpc.y()-GPoffy;
+
+	ptpcy = ptpcy/Prd;
+	ptpcx = GPlon0 + ptpcx/(Prd*cos(GPstlat1));
+
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return (TeCoord2D(ptpcx,ptpcy));
+}
+
+/*******************************************************************
+		GEODETIC TO POLAR STEREOGRAPHIC COORDINATES
+********************************************************************/
+TeCoord2D
+TePolarStereographic :: LL2PC (TeCoord2D& ptll)
+{
+	double	k0,				// Scale factor
+		e,					// Eccentricity
+		pi,					// Auxillary variables
+		lon0,				// auxilliary origin longitude
+		t,ro,aux1,aux2,aux3,ptllx,ptlly;
+	
+	int GPhemis;
+	if (GPhemisphere == TeNORTH_HEM)
+		GPhemis = 1;
+	else
+		GPhemis = -1;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+	
+	ptllx = ptll.x();
+	ptlly = ptll.y();
+
+	k0 = 0.933;	// Standard parallel 60 degrees 
+	e = sqrt((double)2*Pflt - pow(Pflt,(double)2));
+	pi = 4.*atan((double)1);
+
+	ptlly *= GPhemis;
+	ptllx *= GPhemis;
+	lon0 = (GPhemis == 1) ? GPlon0 : -GPlon0;
+
+	aux1 = (1. - e*sin(ptlly))/(1. + e*sin(ptlly));
+	t = tan((pi/4.) - (ptlly/2.))/pow(aux1,(e/(double)2));
+	aux2 = pow(((double)1 + e),((double)1 + e));
+	aux3 = pow(((double)1 - e),((double)1 - e));
+	ro = 2.*Prd*k0*t/sqrt(aux2*aux3);
+
+	aux1   = ro*sin(ptllx - lon0);
+	ptlly = -ro*cos(ptllx - lon0);
+	aux1 *= GPhemis;
+	ptlly *= GPhemis;
+	
+	if (GPhemis == -1)
+	{
+		aux1 *= GPhemis;
+		ptlly *= GPhemis;
+	}
+//	return(Point((float)aux1,(float)ptlly));
+	return (TeCoord2D(aux1+GPoffx,ptlly+GPoffy));
+
+}
+
+//FAMI
+void
+TePolarStereographic :: LL2PC (double xi, double yi, double& xo, double& yo) const
+{
+	double	k0,				// Scale factor
+		e,					// Eccentricity
+		pi,					// Auxillary variables
+		lon0,				// auxilliary origin longitude
+		t,ro,aux1,aux2,aux3,ptllx,ptlly;
+	
+	int GPhemis;
+	if (GPhemisphere == TeNORTH_HEM)
+		GPhemis = 1;
+	else
+		GPhemis = -1;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+	
+	ptllx = xi;
+	ptlly = yi;
+
+	k0 = 0.933;	// Standard parallel 60 degrees 
+	e = sqrt((double)2*Pflt - pow(Pflt,(double)2));
+	pi = 4.*atan((double)1);
+
+	ptlly *= GPhemis;
+	ptllx *= GPhemis;
+	lon0 = (GPhemis == 1) ? GPlon0 : -GPlon0;
+
+	aux1 = (1. - e*sin(ptlly))/(1. + e*sin(ptlly));
+	t = tan((pi/4.) - (ptlly/2.))/pow(aux1,(e/(double)2));
+	aux2 = pow(((double)1 + e),((double)1 + e));
+	aux3 = pow(((double)1 - e),((double)1 - e));
+	ro = 2.*Prd*k0*t/sqrt(aux2*aux3);
+
+	aux1   = ro*sin(ptllx - lon0);
+	ptlly = -ro*cos(ptllx - lon0);
+	aux1 *= GPhemis;
+	ptlly *= GPhemis;
+	
+	if (GPhemis == -1)
+	{
+		aux1 *= GPhemis;
+		ptlly *= GPhemis;
+	}
+
+	xo = aux1+GPoffx;
+	yo = ptlly+GPoffy;
+	return;
+}
+
+//FAMI
+void TePolarStereographic :: LL2PC (ostream& java) const 
+{
+	double	k0,			// Scale factor
+		equad,			// Squared eccentricity
+		e,		        // Eccentricity
+		pi,			// Ancillary variables
+		lon0,			// auxilliary origin longitude
+		aux1,aux2,aux3,aux4,aux5, aux6, aux7;
+	
+		
+	//java << "\tpx = xpc - " << GPoffx << ";\n";
+	//java << "\tpy = ypc - " << GPoffy << ";\n";
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+	k0   = 0.933;
+	
+	pi = 4.*atan((double)1); 
+	equad =  2.*Pflt - pow(Pflt,(double)2);
+	e = sqrt(equad);
+	
+	
+	if (GPhemisphere != TeNORTH_HEM) {
+		//java << "\tpx *= -1;\n";
+		//java << "\tpy *= -1;\n";
+	}
+	lon0 = (GPhemisphere == TeNORTH_HEM) ? GPlon0 : -GPlon0;
+	string name = (GPhemisphere == TeNORTH_HEM) ? "polar_north" : "polar_south";
+	//java << "\tro = Math.sqrt(px*px + py*py);\n";	
+	aux1 = pow(((double)1 + e),((double)1 + e));
+    aux6 = pow(((double)1 + e),((double)1 + e));
+    aux7 = pow(((double)1 - e),((double)1 - e));
+	aux2 = 2.*Prd*k0;
+	
+	//java << "\tt = (ro* " << sqrt(aux1*aux2) << ")/(" << 2.*Prd*k0 << ") " << ";\n";
+	//java << "\txx = " << pi/2. << " - 2.*Math.atan(t);\n";
+	
+	aux3 =  equad/2. + 5.*equad*equad/24. + equad*equad*equad/12.;
+	aux4 = 7.*equad*equad/48. + 29.*equad*equad*equad/240.;
+	aux5 = 7.*equad*equad*equad/120.;
+	
+	
+		java <<     "\"name\" : \"" <<  name << "\"," ;
+		java <<     "\"GPoffx\" : " <<  GPoffx << ",";
+		java <<     "\"GPoffy\" : " <<  GPoffy << ",";
+		java <<     "\"lon0\" : " << GPlon0 << "," ;
+        java <<     "\"e\" : " << e << "," ;
+		java <<     "\"coeff1\" : " << aux1 << "," ;
+		java <<     "\"coeff2\" : " << aux2 << "," ;
+		java <<     "\"coeff3\" : " << aux3 << "," ;
+		java <<     "\"coeff4\" : " << aux4 << "," ;
+		java <<     "\"coeff5\" : " << aux5 <<  "," ;
+		java <<     "\"coeff6\" : " << aux6 <<  "," ;
+		java <<     "\"coeff7\" : " << aux7 <<  "," ;
+        
+		
+		
+
+	//java << "\tyll = xx + " << aux3 << "*Math.sin(2*xx) + " << aux4 << "*Math.sin(4*xx) + "<< aux5 << "*Math.sin(6*xx);\n";
+
+	//java << "\tif (py != 0.) \n";
+	//java << "\t\txll = " << lon0 << "+ Math.atan(px/(-py));\n";
+
+	if (GPhemisphere == TeNORTH_HEM)
+	{
+		//java << "\tif (and(greater(px, 0.), greater(py,0.)))\n";
+		//java << "\t\txll = xll + " << pi << ";\n";
+		//java << "\telse if (and(smaller(px,0.), greater(py,0.)))\n";
+		//java << "\t\txll = xll - " << pi << ";\n";
+		//java << "\telse if (and(greater(px, 0.), equal(py,0.)))\n";
+		//java << "\t\txll = " << lon0  << "+ " << pi << "/ 2.;\n";
+		//java << "\telse if (and(smaller(px, 0.),  equal(py,0.)))\n";
+		//java << "\t\txll = " << lon0 << " - " << pi << "/ 2.;\n";
+		//java << "\telse if (and(equal(px,0.), equal(py, 0.)))\n";
+		//java << "\t\txll = " << lon0 << ";\n";
+	}
+	else
+	{
+		//java << "\tyll = -yll;\n";
+		//java << "\txll = -xll;\n";
+
+		//java << "\tif (and(greater(px,0.), smaller(py,0)))\n";
+		//java << "\t\txll = xll + " << pi << ";\n";
+		//java << "\telse if (and (smaller(px, 0.),  smaller(py,0)))\n";
+		//java << "\t\txll = xll - " << pi << ";\n";
+		//java << "\telse if (and(greater(px,0.), equal(py,0.)))\n";
+		//java << "\t\txll = " << lon0 << " + " << pi << "/ 2.;\n";
+		//java << "\telse if (and(smaller(px,0.), equal(py, 0.)))\n";
+		//java << "\t\txll = " << lon0 << " - " << pi << " / 2.;\n";
+		//java << "\telse if (and(equal(px,0.), equal(py, 0.)))\n";
+		//java << "\t\txll = " << lon0 << ";\n";
+	}
+
+	//java << "\tif (smaller(xll, (-" << pi << ") )) xll += 2.* "<< pi << ";\n";
+	//java << "\telse if (greater(xll, " << pi << ")  )    xll -= 2.*" << pi << ";\n";
+	
+	//java << "\txll = xll * " << 180/3.14159 << ";\n";
+	//java << "\tyll = yll * " << 180/3.14159 << ";\n\n";
+
+	//java << "\treturn { lon :  xll, lat : yll } ;\n";
+	//java << "}\n";
+	
+}
+/*******************************************************************
+	POLAR STEREOGRAPHIC TO	GEODETIC COORDINATES
+********************************************************************/
+TeCoord2D
+TePolarStereographic :: PC2LL (TeCoord2D& ptpc)
+{
+	double	k0,			// Scale factor
+
+		equad,			// Squared eccentricity
+		e,		        // Eccentricity
+		pi,			// Ancillary variables
+		lon0,			// auxilliary origin longitude
+		ro,t,xx,aux1,aux2,aux3,aux4,aux5,ptpcx=0.,ptpcy,px,py;
+
+	px = (double)ptpc.x()-GPoffx;
+	py = (double)ptpc.y()-GPoffy;
+
+	int GPhemis;
+	if (GPhemisphere == TeNORTH_HEM)
+		GPhemis = 1;
+	else
+		GPhemis = -1;
+
+	double Pflt = GPdatum.flattening();
+	double Prd  = GPdatum.radius();
+
+//	k0 = 0.994;	// Standard parallel 80.1 degrees 
+	k0 = 0.933;	// Standard parallel 60 degrees
+	pi = 4.*atan((double)1);
+	equad = 2.*Pflt - pow(Pflt,(double)2);
+	e = sqrt(equad);
+
+	if (GPhemis == -1)
+	{
+		px *= GPhemis;
+		py *= GPhemis;
+	}
+
+	lon0 = (GPhemis == 1) ? GPlon0 : -GPlon0;
+
+	ro = sqrt(px*px + py*py);
+	aux1 = pow(((double)1 + e),((double)1 + e));
+	aux2 = pow(((double)1 - e),((double)1 - e));
+	t = (ro*sqrt(aux1*aux2))/(2.*Prd*k0);
+	xx = pi/2. - 2.*atan(t);
+	aux3 = equad/2. + 5.*equad*equad/24. + equad*equad*equad/12.;
+	aux4 = 7.*equad*equad/48. + 29.*equad*equad*equad/240.;
+	aux5 = 7.*equad*equad*equad/120.;
+
+	ptpcy = xx + aux3*sin((double)2*xx) + aux4*sin((double)4*xx) + aux5*sin((double)6*xx);
+
+	if (py != 0.)
+		ptpcx = lon0 + atan(px/(-py));
+
+
+	if (GPhemis == 1)
+	{
+		if (px > 0. && py > 0.)
+			ptpcx = ptpcx + pi;
+		else if (px < 0. && py > 0.)
+			ptpcx = ptpcx - pi;
+		else if (px > 0. && py == 0.)
+			ptpcx = lon0 + pi / 2.;
+		else if (px < 0. && py == 0.)
+			ptpcx = lon0 - pi / 2.;
+		else if (px == 0. && py == 0.)
+			ptpcx = lon0;
+	}
+	else
+	{
+		ptpcy *= GPhemis;
+		ptpcx *= GPhemis;
+
+		if (px > 0. && py < 0.)
+			ptpcx = ptpcx + pi;
+		else if (px < 0. && py < 0.)
+			ptpcx = ptpcx - pi;
+		else if (px > 0. && py == 0.)
+			ptpcx = lon0 + pi / 2.;
+		else if (px < 0. && py == 0.)
+			ptpcx = lon0 - pi / 2.;
+		else if (px == 0. && py == 0.)
+			ptpcx = lon0;
+	}
+
+	if (ptpcx < (-pi)) ptpcx += 2.*pi;
+	else if (ptpcx > pi)    ptpcx -= 2.*pi;
+
+	if( GPdestination && !(datum() == GPdestination->datum()))
+		ChangeLL(ptpcx,ptpcy);
+
+	return (TeCoord2D(ptpcx,ptpcy));
+}
+
+//FAMI
+/************************************************************************
+		GEODETIC COORDINATES TO SATELLITE PROJECTION
+*************************************************************************/
+TeCoord2D 
+TeSatelliteProjection::LL2PC(TeCoord2D& ptll)
+{
+	double equad, n, x, y, z, sn, dp, dl,xlo,yla,lin,col,resx,resy;
+	double x1, x2, a, b, c,  Rd2, Rm, Rm2, Rs2, v;
+
+//	xlo = ptpc.x()-GPoffx;
+//	yla = ptpc.y()-GPoffy;
+	xlo = ptll.x();
+	yla = ptll.y();
+
+	// Cartesian geocentric coordinates
+	xlo = xlo - GPlon0;
+	yla = yla - GPlat0;
+	equad = 2.*GPdatum.flattening() - pow(GPdatum.flattening(),(double)2);
+	n = GPdatum.radius()/sqrt((double)1-equad*pow(sin(yla),(double)2));
+	x = n*cos(yla)*cos(xlo);
+	y = n*cos(yla)*sin(xlo);
+	z = (n*(1-equad))*sin(yla);
+ 
+	// Field of view angles
+	dp = atan(y / (SPrs - x));
+	dl = atan(z * cos(dp) /(SPrs - x));
+
+	// Visibility test
+	if ( x < 0.0 )
+	{
+		col = TeMAXFLOAT;
+		lin = TeMAXFLOAT;
+		return (TeCoord2D(col,lin));
+	}
+	else
+	{
+		Rd2 = GPdatum.radius() * GPdatum.radius() ;
+		Rm  = GPdatum.radius() * (1 - GPdatum.flattening());
+		Rm2 = Rm * Rm ;
+		Rs2 = SPrs * SPrs;
+
+		v = (tan(dp)*tan(dp)*cos(dp)*cos(dp)*Rm2)+(tan(dl)*tan(dl)*Rd2);
+		a = cos(dp)*cos(dp)*Rm2 + v;      
+		b = -2.*SPrs*v;
+		c = Rs2*v-Rd2*Rm2*cos(dp)*cos(dp);
+
+		// Equation Resolution a*x**2+b*x+c=0 
+		v = (b*b) - (4.*a*c);
+		if (v < 0.0) v=0.0;
+   		x1 = (-b + sqrt(v)) / (2.*a);
+		x2 = (-b - sqrt(v)) / (2.*a);
+		if (x1 < x2)  x1 = x2;
+
+		if ( fabs(x-x1) > 1.0 )
+		{
+			col = TeMAXFLOAT;
+			lin = TeMAXFLOAT;
+			return (TeCoord2D(col,lin));
+		}
+	}
+	// Line and column of image
+	if (SPscn == 0.) sn = 1.0;  else sn = -1.0;
+	col = (sn * dp / SPrj + SPjs );
+	lin = (-sn * dl / SPri + SPis);
+
+	// Axis rotation correction due to yaw angle
+	col = col*cos(SPyaw) - lin*sin(SPyaw);
+	lin = lin*cos(SPyaw) + col*sin(SPyaw);
+	resx = tan(SPrj) * (SPrs - GPdatum.radius());
+	resy = tan(SPri) * (SPrs - GPdatum.radius());
+
+	return (TeCoord2D(col*resx,-(lin*resy)));
+}
+
+/************************************************************************
+		SATELLITE PROJECTION TO GEODETIC COORDINATES
+************************************************************************/
+TeCoord2D
+TeSatelliteProjection::PC2LL(TeCoord2D& ptpc)
+{
+	double	dl, dp, x, y, z, x1, x2, equad, n, d, sn,
+		a, b, c,  Rd2, Rm,Rm2, Rs2,v,ptpcx,ptpcy,
+		yla,xlo,resx,resy;
+
+	resx = tan(SPrj) * (SPrs - GPdatum.radius());
+	resy = tan(SPri) * (SPrs - GPdatum.radius());
+	ptpcx = ptpc.x()/resx;
+	ptpcy = -ptpc.y()/resy;
+
+	// Axis rotation correction due yaw angle
+	ptpcx = ptpcx*cos(SPyaw) + ptpcy*sin(SPyaw);
+	ptpcy = ptpcy*cos(SPyaw) - ptpcx*sin(SPyaw);
+
+	// Field of view angles
+	if (SPscn == 0.) sn =  1.0;
+	else 		 sn = -1.0;
+	dl = - sn * ((ptpcy - SPis) * SPri);
+	dp =   sn * ((ptpcx - SPjs) * SPrj);
+
+	// Cartesian coordinates
+	Rd2 = GPdatum.radius() * GPdatum.radius() ;
+	Rm  = GPdatum.radius() * (1 - GPdatum.flattening());
+	Rm2 = Rm * Rm ;
+	Rs2 = SPrs * SPrs;
+
+	v = (tan(dp)*tan(dp)*cos(dp)*cos(dp)*Rm2)+(tan(dl)*tan(dl)*Rd2);
+	a = cos(dp)*cos(dp)*Rm2 + v;      
+	b = -2.*SPrs*v;
+	c = Rs2*v-Rd2*Rm2*cos(dp)*cos(dp);
+
+	// Equation Resolution a*x**2+b*x+c=0 
+	v = (b*b) - (4.*a*c);
+	if (v < 0)
+	{
+		xlo = TeMAXFLOAT;
+		yla = TeMAXFLOAT;
+		return (TeCoord2D(xlo,yla));
+	}
+
+   	x1 = (-b + sqrt(v)) / (2.*a);
+	x2 = (-b - sqrt(v)) / (2.*a);
+
+	if ( x1 >= x2)  x = x1;
+	else		  x = x2;
+
+	z = (SPrs - x) * tan(dl) / cos(dp);
+	y = (SPrs - x) * tan(dp);
+
+	// Geodetic coordinates
+	equad 	= 2. * GPdatum.flattening() - GPdatum.flattening() * GPdatum.flattening();
+
+	double aux = SPrs * dl / GPdatum.radius();
+	if (aux > 1.0) aux = 1.0;
+	if (aux < -1.0) aux = -1.0;
+
+	yla = asin(aux);
+	
+	do
+	{
+		n= GPdatum.radius()/sqrt((double)1-equad*pow(sin(yla),(double)2));
+		yla = atan((z + n*equad*sin(yla))/sqrt(x*x + y*y));
+		d = GPdatum.radius()/sqrt((double)1-equad*pow(sin(yla),(double)2)) - n;
+	}
+	while (fabs(d) > 0.001);
+
+	xlo = atan(y/x) + GPlon0;
+	yla = yla + GPlat0;
+
+	return (TeCoord2D(xlo,yla));
+}
+
+TeProjectionParams 
+TeSatelliteProjection::params () const
+{
+	TeProjectionParams par;
+	par = TeProjection::params();
+
+	par.pri  = SPri;
+	par.prj  = SPrj;
+	par.pis  = SPis;
+	par.pjs  = SPjs;
+	par.prs  = SPrs;
+	par.pscn = SPscn;
+	par.pyaw = SPyaw;
+
+return par;
+}
+
+TeDatum 
+TeGetDatumFromProj4(const string& proj4)
+{
+	unsigned int pos;
+    string attribute;
+    string value;
+	double dx, dy, dz;
+	dx = dy = dz = 0.0;
+
+	TeDatum dat;
+	dat.name("UserDefined");
+	for(unsigned int i = 0; i < proj4.size(); i++)
+    {
+        for( pos = i; i != proj4.size() && proj4[i] != '=';i++);
+
+        attribute = proj4.substr(pos+1, i-pos-1);
+
+        for(pos = i; i != proj4.size() && proj4[i] != ' ';i++);
+
+        if(proj4[i] == ' ') value = proj4.substr(pos+1, i-pos-1);
+        else                value = proj4.substr(pos+1, i-pos);
+		
+		double b;
+		// Datum parameters
+        if(attribute == "R")	// radius for a spherical ellipsoid
+		{
+			dat = TeDatum("Spherical",atof(value.c_str()));
+			return dat;
+		}
+		else if(attribute == "a")   // Earth equatorial radius
+			dat.radius(atof(value.c_str()));
+		else if (attribute == "b")
+			b = atof(value.c_str());
+	    else if(attribute == "f")	// Earth flattening
+			dat.flattening(atof(value.c_str()));
+	    else if(attribute == "rf")	// Earth  reverse flattening (f = 1/rf)
+			dat.flattening(1/atof(value.c_str()));
+		else if (attribute == "es") // eccentricity squared (f=1-(1-es)^0.5) 
+			dat.flattening(1-sqrt(1-atof(value.c_str())));
+		else if (attribute == "e")	// eccentricity (f=1-(1-es^2)^0.5)
+			dat.flattening(1-sqrt(1-pow(atof(value.c_str()),2)));
+		else if (attribute == "ellps")
+			dat.name(value);
+		else if (attribute == "towgs84")
+		{
+			vector<string> deltas;
+			TeSplitString(value, ",", deltas);
+			
+			if (deltas.size()>=3)
+			{
+				dx = atof(deltas[0].c_str());
+				dy = atof(deltas[1].c_str());
+				dz = atof(deltas[2].c_str());
+			}
+		}
+	}
+	if ( dx==0.0 && dy== 0 && dz == 0.0)
+	{
+		dat = TeDatum("WGS84",6378137,0.003352811,66.87,-4.37,38.52);
+	}
+	// this is a SAD69
+	else if (dx == -66.87 && dy == 4.37 &&  dz == -38.52)
+	{
+		dat = TeDatum("SAD69",6378160,0.003352892,0.0,0.0,0.0);
+	}
+	else
+	{
+		dat.dx_ = dx;
+		dat.dy_ = dy;
+		dat.dz_ = dz;
+	}
+	return dat;
+}
+
+TeProjection* TeGetTeProjectionFromSProj(const string& proj4)
+{
+	// a map from sproj4 projections to TerraLib projections
+	map<string,string> sprojToTeProj;
+	sprojToTeProj["aea"] = "Albers";
+	sprojToTeProj["latlong"] = "LatLong";
+	sprojToTeProj["lcc"] = "LambertConformal";
+	sprojToTeProj["merc"] = "Mercator";
+	sprojToTeProj["mill"] = "Miller";
+	sprojToTeProj["utm"] = "UTM";
+	sprojToTeProj["sinu"] = "Sinusoidal";
+	sprojToTeProj["poly"] = "Polyconic";
+	sprojToTeProj["eqc"] = "CylindricalEquidistant";
+	sprojToTeProj["ups"] = "PolarStereographic";
+	sprojToTeProj["sat"] = "Satellite"; //FAMI
+
+    unsigned int pos;
+    string attribute;
+    string value;
+
+  	TeProjectionParams par;
+	par.hemisphere = TeNORTH_HEM;
+	par.offx = 500000;
+	par.offy = 0;
+	par.units = "";
+    for(unsigned int i = 0; i < proj4.size(); i++)
+    {
+        for( pos = i; i != proj4.size() && proj4[i] != '=';i++);
+
+        attribute = proj4.substr(pos+1, i-pos-1);
+
+        for(pos = i; i != proj4.size() && proj4[i] != ' ';i++);
+
+        if(proj4[i] == ' ') value = proj4.substr(pos+1, i-pos-1);
+        else                value = proj4.substr(pos+1, i-pos);
+
+        if(attribute == "proj")
+		{
+			map<string,string>::iterator it = sprojToTeProj.find(value);
+			if (it != sprojToTeProj.end())
+				par.name = sprojToTeProj[value];
+			else
+				par.name = "NoProjection"; 
+		}
+	// Currently this routine understands the following parameters from
+	// a sproj description: lon_0, lat_0, lat_1, lat_2, k, zone, x_0, y_0
+
+        else if(attribute == "lon_0") 
+			par.lon0 = atof(value.c_str())*TeCDR;
+        else if(attribute == "lat_0") 
+			par.lat0 = atof(value.c_str())*TeCDR;
+        else if(attribute == "lat_1") 
+			par.stlat1 = atof(value.c_str())*TeCDR;
+        else if(attribute == "lat_2") 
+			par.stlat2 = atof(value.c_str())*TeCDR;
+        else if(attribute == "k") 
+			par.scale = atof(value.c_str());
+        else if(attribute == "zone") 
+			par.lon0 = (-183 + 6*(atoi(value.c_str()))*TeCDR);
+		else if (attribute == "south") 
+		{
+			par.hemisphere = TeSOUTH_HEM;
+			par.offy = 10000000;
+		}
+		else if(attribute == "x_0") 
+			par.offx = atof(value.c_str());
+ 		else if(attribute == "y_0") 
+			par.offy = atof(value.c_str());
+		else if (attribute == "units")
+			par.units = value;
+// TODO: sproj4 also allowd the selection of standard, predefined
+// ellipsoid figures using the option +ellps=acronym. But we are not decoding 
+// them yet because of our problem with the shiftings from SAD69
+    }
+	par.datum = TeGetDatumFromProj4(proj4);
+	return TeProjectionFactory::make(par);
+}
+
+string TeGetSProjFromTeProjection(TeProjection* teproj)
+{
+	map<string,string> teProjToSProj;
+	teProjToSProj["Albers"] = "aea";
+	teProjToSProj["LatLong"] = "latlong";
+	teProjToSProj["LambertConformal"] = "lcc";
+	teProjToSProj["Mercator"] = "merc";
+	teProjToSProj["Miller"] = "mill";
+	teProjToSProj["UTM"] = "utm";
+	teProjToSProj["Sinusoidal"] = "sinu";
+	teProjToSProj["Polyconic"] = "poly";
+	teProjToSProj["CylindricalEquidistant"] = "eqc";
+	teProjToSProj["PolarStereographic"] = "ups";
+	teProjToSProj["Satellite"] = "sat"; //FAMI
+
+    string sresp = "+proj=";
+	map<string,string>::iterator it = teProjToSProj.find(teproj->name());
+	if (it == teProjToSProj.end())
+	{
+		sresp += "noprojection";
+		return sresp;
+	}
+	else
+		sresp += it->second;
+
+	TeProjInfo pjInfo = TeProjectionInfo(teproj->name());
+	if ( pjInfo.hasLon0 )
+		sresp += " +lon_0=" + Te2String(teproj->lon0()*TeCRD,6);
+
+	if ( pjInfo.hasLat0 )
+		sresp += " +lat_0=" + Te2String(teproj->lat0()*TeCRD,6);
+
+	if ( pjInfo.hasStlat1 )
+		sresp += " +lat_1=" + Te2String(teproj->stLat1()*TeCRD,6);
+	
+	if ( pjInfo.hasStlat2 )
+		sresp += " +lat_2=" +Te2String(teproj->stLat2()*TeCRD,6);
+
+	if ( pjInfo.hasOffx )
+		sresp += " +x_0=" + Te2String(teproj->offX(),6);
+
+	if ( pjInfo.hasOffy )
+		sresp += " +y_0=" + Te2String(teproj->offY(),6);
+	
+	if ( pjInfo.hasScale )
+		sresp += " +k="  + Te2String(teproj->scale(),6);
+
+	string datumD = teproj->datum().getProj4Description();
+	if (!datumD.empty())
+		sresp += datumD;
+	return sresp;
+}
+
+string 
+TeGetWKTFromTeProjection(TeProjection* teproj)
+{
+	string wkt = "";
+	if (!teproj)
+		return wkt;
+
+	string wktDatum = teproj->datum().getWKTDescription();
+	if (teproj->name() == "LatLong")
+		return wktDatum;
+
+	map<string,string> teProjToWKT;
+	teProjToWKT["Albers"] = "Albers_Conic_Equal_Area";
+	teProjToWKT["LambertConformal"] = "Lambert_Conformal_Conic_1SP";
+	teProjToWKT["Mercator"] = "Mercator_1SP";
+	teProjToWKT["Miller"] = "Miller_Cylindrical";
+	teProjToWKT["UTM"] = "Transverse_Mercator";
+	teProjToWKT["Sinusoidal"] = "Sinusoidal";
+	teProjToWKT["Polyconic"] = "Polyconic";
+	teProjToWKT["CylindricalEquidistant"] = "Equirectangular";
+	teProjToWKT["PolarStereographic"] = "Polar_Stereographic";
+	teProjToWKT["Satellite"] = "Satellite"; //FAMI
+	teProjToWKT["NoProjection"] = "Unknown";
+
+	wkt = "PROJCS[\"" + teproj->name() + "\",";
+	wkt += wktDatum;
+	wkt += ",PROJECTION[\"" + teProjToWKT[teproj->name()] + "\"]";
+
+	TeProjInfo pjInfo = TeProjectionInfo(teproj->name());
+	if (pjInfo.hasLon0)
+		wkt +=",PARAMETER[\"central_meridian\","+ Te2String(teproj->lon0()*TeCRD,6)+"]";
+
+	if (pjInfo.hasLat0)
+		wkt +=",PARAMETER[\"latitude_of_origin\","+ Te2String(teproj->lat0()*TeCRD,6)+"]";
+
+	if (pjInfo.hasStlat1)
+		wkt +=",PARAMETER[\"standard_parallel_1\","+ Te2String(teproj->stLat1()*TeCRD,6)+"]";
+	
+	if (pjInfo.hasStlat2)
+		wkt +=",PARAMETER[\"standard_parallel_2\","+ Te2String(teproj->stLat2()*TeCRD,6)+"]";
+
+	if (pjInfo.hasOffx)
+		wkt +=",PARAMETER[\"false_easting\","+ Te2String(teproj->offX(),6)+"]";
+
+	if (pjInfo.hasOffy)
+		wkt +=",PARAMETER[\"false_northing\","+ Te2String(teproj->offY(),6)+"]";
+
+	if (pjInfo.hasScale)
+		wkt +=",PARAMETER[\"scale_factor\","+ Te2String(teproj->scale(),6)+"]";
+	
+	wkt += ",UNIT[\"meter\",1]]";
+	return wkt;
+}
+
+bool tokenizeWKT(char** wkt, vector<string>& tokens)
+{
+	const char *pszInput =  *wkt;
+	int isInQuote = false;
+	
+	string token = "";
+	int  sizeToken = 0;
+	while (*pszInput != '\0')
+	{
+		if (*pszInput == '"')
+		{
+			isInQuote = !isInQuote;
+		}
+		else if (!isInQuote && 
+				(*pszInput == '[' || *pszInput == ']' || *pszInput == ',' || 
+					*pszInput == '(' || *pszInput == ')' ))
+		{
+			break;
+		}
+		else if (!isInQuote && 
+				(*pszInput == ' ' || *pszInput == '\t' || 
+				*pszInput == 10 || *pszInput == 13))
+		{
+		/* just skip over whitespace */
+		} 
+		else
+		{
+			token += *pszInput;
+			++sizeToken;
+		}
+		pszInput++;
+	}
+	if (*pszInput == '\0')
+		return true;
+		
+	tokens.push_back(token);
+	
+	bool result;  // read sublist
+	if( *pszInput == '[' || *pszInput == '(' )
+	{
+		do
+		{
+			pszInput++; // Skip bracket or comma.
+			result = tokenizeWKT((char **) &pszInput, tokens);
+			if (!result )
+				return result;          
+		}while (*pszInput == ',');
+	
+		if (*pszInput != ')' && *pszInput != ']')
+			return result;
+		pszInput++;
+	}
+	*wkt = (char *) pszInput;
+	return true;
+}
+
+
+
+TeProjection* 
+TeGetTeProjectionFromWKT(const string& wkt)
+{
+	map<string,string> wktToTeProj;
+	wktToTeProj["Albers_Conic_Equal_Area"] = "Albers";
+	wktToTeProj["Lambert_Conformal_Conic_1SP"] = "LambertConformal";
+	wktToTeProj["Mercator_1SP"] = "Mercator";
+	wktToTeProj["Miller_Cylindrical"] = "Miller";
+	wktToTeProj["Transverse_Mercator"] = "UTM";
+	wktToTeProj["Sinusoidal"] = "Sinusoidal";
+	wktToTeProj["Polyconic"] = "Polyconic";
+	wktToTeProj["Equirectangular"] = "CylindricalEquidistant";
+	wktToTeProj["Polar_Stereographic"] = "PolarStereographic";
+	wktToTeProj["Satellite"] = "Satellite"; //FAMI
+
+	TeDatum dat = TeDatumFactory::makeFromWKT(wkt);
+	vector<string> tokens;
+	char* wktchar = new char[wkt.size()];
+	strcpy(wktchar,wkt.c_str());
+	bool res = tokenizeWKT((char **) &wktchar, tokens);
+	if (!res)
+		return 0;
+
+	// geographic coordinates 
+
+	TeProjectionParams par;
+	unsigned int i = 1;
+	bool isProjected = false;
+	if (tokens[0] == "GEOGCS")
+	{
+		isProjected = false;
+		par.name = "LatLong";
+	}
+	else if (tokens[0] == "PROJCS")
+	{
+		isProjected = true;
+	}
+	else
+		return 0;
+	par.datum = dat;
+	if (!isProjected)
+		return TeProjectionFactory::make(par);
+
+	while (i<tokens.size() && tokens[i] != "PROJECTION")
+		++i;
+	if (i== tokens.size())
+		return 0;
+	map<string,string>::iterator it = wktToTeProj.find(tokens[++i]);
+	if (it != wktToTeProj.end())
+		par.name = it->second;
+	else
+		return 0;
+	while (tokens[++i] == "PARAMETER")
+	{
+		++i;
+		if (TeStringCompare(tokens[i],"latitude_of_origin",false))
+			par.lat0 = atof(tokens[++i].c_str())*TeCDR;
+		else if (TeStringCompare(tokens[i],"central_meridian",false))
+			par.lon0 = atof(tokens[++i].c_str())*TeCDR;
+ 		else if (TeStringCompare(tokens[i],"standard_parallel_1",false))
+			par.stlat1 = atof(tokens[++i].c_str())*TeCDR;
+ 		else if (TeStringCompare(tokens[i],"standard_parallel_2",false))
+			par.stlat2 = atof(tokens[++i].c_str())*TeCDR;
+ 		else if (TeStringCompare(tokens[i],"false_easting",false))
+			par.offx = atof(tokens[++i].c_str());
+ 		else if (TeStringCompare(tokens[i],"false_northing",false))
+			par.offy = atof(tokens[++i].c_str());
+ 		else if (TeStringCompare(tokens[i],"scale_factor",false))
+			par.scale = atof(tokens[++i].c_str());
+	}
+	return TeProjectionFactory::make(par);
+}
+
diff --git a/src/terralib/kernel/TeProjection.h b/src/terralib/kernel/TeProjection.h
new file mode 100644
index 0000000..e93d49d
--- /dev/null
+++ b/src/terralib/kernel/TeProjection.h
@@ -0,0 +1,796 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeProjection.h
+    \brief This file contains support do deal with geographical projections
+*/
+
+#ifndef  __TERRALIB_INTERNAL_PROJECTION_H
+#define  __TERRALIB_INTERNAL_PROJECTION_H
+
+#include "TeCoord2D.h"
+#include "TeDefines.h"
+#include "TeDatum.h"
+
+#include <stdio.h>
+#include <map>
+#include <string>
+
+using namespace std;
+
+//! Earth hemispheres 
+enum TeHemisphere
+{ TeNORTH_HEM, TeSOUTH_HEM };
+
+//! Number of supported projections in TerraLib
+const int NUM_PROJ = 11; 
+
+//! Set of informations required by projections
+struct TL_DLL TeProjInfo 
+{
+	int hasUnits;
+	int hasLon0;
+	int hasLat0;
+	int hasStlat1;
+	int hasStlat2;
+	int hasScale;
+	int hasOffx;
+	int hasOffy;
+};
+
+//! A map from name of projections to a set of informations that it requires
+typedef map<string,TeProjInfo> TeProjInfoMap;
+
+//! Returns the set of informations required by a given projection
+TL_DLL TeProjInfo TeProjectionInfo ( const string& projName  );
+
+TL_DLL const char** TeGetProjInfo();
+
+// ============ PROJECTION PARAMETERS ===============
+
+class TeProjection;
+
+//FAMI Added Satellite parameters
+//! Set of parameters that define a geographical projection
+struct TL_DLL TeProjectionParams
+{
+	string	name;	     //!< projection name
+	TeDatum datum;       //!< spheroid
+        double	lon0;	     //!< Longitude of origin (rad)
+	double  lat0;	     //!< Latitude of origin (rad)  
+	double	offx;	     //!< X (projection coordinate) offset (m)
+	double	offy;	     //!< Y (projection coordinate) offset (m)
+	double	stlat1;	     //!< First standard parallel (rad)
+	double  stlat2;      //!< Second standard paralel (rad)
+	string  units;       //!< units
+	double  scale;       //!< projection scale (used in UTM)
+	TeHemisphere hemisphere; //!< Hemisphere
+	double  pri;         //!< Sensor angle resolution along y axis (rad) (used in Satellite)
+	double  prj;         //!< Sensor angle resolution along x axis (rad) (used in Satellite)
+	double  pis;         //!< Y-coordinate of sub-satellite point (used in Satellite)
+	double  pjs;         //!< X-coordinate of sub-satellite point (used in Satellite)
+	double  prs;         //!< Radius of satellite orbit (m) (used in Satellite)
+	double  pscn;        //!< Scanning mode: 0-WE/NS, 1-SN/EW (used in Satellite)
+	double  pyaw;        //!< Grid orientation, i.e., angle in radians between the increasing y axis and the meridian of the sub-satellite point along the direction of increasing latitude (used in Satellite)
+
+};
+
+//========== PROJECTION FACTORY
+//! A factory of projections
+class TL_DLL TeProjectionFactory 
+{
+public:
+	static TeProjection* make( const TeProjectionParams& );
+};
+
+//!  Provides methods that are required to handle all map projection definitions and georeferencing of satellite images.
+/*!
+  Specifies earth and projection parameters that represent a common
+  ground in terms of defining conventional map projections, navigating
+  on low-resolution images of geostationary satellites.
+*/
+class TL_DLL TeProjection 
+{
+protected:
+	string	GPname;	             // projection name
+	TeDatum GPdatum;             // spheroid
+	double	GPlon0;	             // Longitude of origin (rad)
+	double  GPlat0;	             // Latitude of origin (rad)  
+	double	GPoffx;	             // X (projection coordinate) offset (m)
+	double	GPoffy;	             // Y (projection coordinate) offset (m)
+	double	GPstlat1;            // First standard parallel (rad)
+	double  GPstlat2;            // Second standard parallel (rad)
+	string  GPunits;             // units
+	double  GPscale;             // scale (used for UTM)
+	TeHemisphere  GPhemisphere;  // Hemisphere
+	TeProjection* GPdestination; // destination projection
+	int	      GPid;          // id
+
+	//! Changes planimetic datum
+	/*!	Computes changes in geodetic coordinates due to
+		planimetric datum changes. First, the method finds
+		geocentric cartesian coordinates on the initial datum,
+		then applies datum shifts, and finally computes the
+		new geodetic coordinates on the final datum. The new
+		geodetic latitude is computed iteractively, the old
+		geodetic latitude being used as initial guess.
+		
+		\param	x	Initial longitude (rad);
+		\param	y	Initial latitude (rad).
+		\return x	Final longitude (rad);
+		\return y	Final latitude (rad).
+		
+		\note
+			x must be a valid longitude ([0,pi] or [0,-pi]) and
+			y must be a valid latitude ([0,pi/2] or [0,-pi/2]).
+	*/
+	void 	ChangeLL (double &x, double &y); 
+
+public:
+
+	//! Normal constructor
+	/*!	
+		Initializes projection parameters 
+		\param name			projection name
+		\param datum		spheroid
+		\param lon0			longitude of origin (in radians)
+		\param lat0			latitude of origin (in radians)  
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param stlat1		first standard parallel (in radians)
+		\param stlat2		second standard parallel (in radians)
+		\param units		projection unit
+		\param scale		scale (used for UTM)
+		\param hem			hemisphere
+	*/
+	TeProjection ( const string& name, const TeDatum& datum,
+		double lon0 = 0., double lat0=0., double offx = 0., double offy = 0.,
+		double stlat1 = 0., double stlat2 = 0., 
+		const string units = "Meters",
+		double scale = 1., TeHemisphere hem = TeSOUTH_HEM):
+		GPname   ( name ),
+		GPdatum  ( datum ),
+	    GPlon0   ( lon0 ),
+	    GPlat0   ( lat0  ),
+	    GPoffx   ( offx  ),
+	    GPoffy   ( offy ),
+	    GPstlat1 ( stlat1 ),
+	    GPstlat2 ( stlat2 ),
+	    GPunits  ( units ),
+	    GPscale  ( scale ),
+	    GPhemisphere ( hem ),
+		GPdestination (0),
+		GPid(0)
+		{}
+
+		TeProjection ():
+		GPname   ( "NoProjection" ),
+	    GPlon0   ( 0. ),
+	    GPlat0   ( 0. ),
+	    GPoffx   ( 0. ),
+	    GPoffy   ( 0. ),
+	    GPstlat1 ( 0. ),
+	    GPstlat2 ( 0. ),
+	    GPunits  ( "Units" ),
+	    GPscale  ( 1 ),
+	    GPhemisphere ( TeSOUTH_HEM ),
+		GPdestination (0),
+		GPid(0)
+	{}
+
+	//! Copy Constructor
+	TeProjection(const TeProjection&);
+
+	//! Operator =
+	TeProjection& operator=(const TeProjection&);
+
+	//!	Destructor.
+	virtual ~TeProjection (){}
+
+	//! Returns the projection name;
+	string& name() 
+	{ return GPname; }
+
+	//! Returns the projection datum
+	TeDatum datum()
+	{ return GPdatum; }
+
+	//! Sets the datum associated to the projection 
+	void setDatum(const TeDatum& datum)
+	{	GPdatum = datum; }
+
+	//! Return the projection units 
+	string& units()
+	{ return GPunits; }
+
+	//! Return the longitude of origin ( in rad)
+	double	lon0() { return GPlon0;	}
+	
+	//! Return the Latitude of origin (rad)
+	double  lat0() { return GPlat0;	}	  
+
+	//! Return  X (projection coordinate) offset (m)
+	double	offX() { return GPoffx; }	 
+    
+	//! Return  Y (projection coordinate) offset (m)
+	double	offY() { return GPoffy;	 }
+    
+	//!  Return First standard parallel (rad)
+	double	stLat1() { return GPstlat1; }
+	
+	//! Return the second standard parallel (rad)
+	double  stLat2() { return GPstlat2; }
+	
+	//! Return the scale (used for UTM)
+	double  scale()  { return GPscale;   }
+
+	//! Return the  Hemisphere
+	TeHemisphere hemisphere() {	return GPhemisphere; }
+		
+	// Returns a the parameters of this projection
+	virtual TeProjectionParams params () const; //FAMI
+
+	bool operator== (const TeProjection& proj);
+
+	//!	Pure virtual method that transforms geodetic into projection coordinates
+	/*!		
+		This method is implemented for each available
+		projection class and represents the so-called
+		direct formulas, which compute projection 
+		coordinates from geodetic coordinates.
+		 
+		\param	p 	Geodetic coordinates (radian).
+		\return p  	Projection coordinates (m).
+		\note
+			Geodetic coordinates must be a valid latitude
+			([0,pi/2] or [0,-pi/2]) and a valid longitude
+			([0,pi] or [0,-pi]).
+	*/
+	virtual	TeCoord2D LL2PC (TeCoord2D& p) = 0;
+	virtual	void	  LL2PC (ostream&) const {} //FAMI
+
+	//! Pure virtual method that transforms projection into geodetic coordinates.
+	/*!
+		This method is implemented for each available
+		projection class and represents the so-called
+		inverse formulas, which compute geodetic
+		coordinates from projection coordinates.
+		\param p 	Projection coordinates (m).
+		\return p	Geodetic coordinates (rad).
+		\note X and Y projection coordinates must be both valid,
+		 within the typical range of each projection class.
+	*/
+	virtual	TeCoord2D	PC2LL (TeCoord2D& p) = 0;
+
+	virtual	void LL2PC (double, double, double&, double&) const {printf("\nWRONG"); return;} //FAMI
+	virtual	void PC2LL (double, double, double&, double&) {printf("\nWRONG"); return;} //FAMI
+
+	//!	Sets the projection to which a Latitude/Longitude value will be generated by the current projection by calling changeLL in PC2LL method
+	void setDestinationProjection (TeProjection* proj)
+	{ GPdestination = proj; }
+	
+	//! Concrete method that prints information about a projection
+	void print ( FILE* file_ );
+
+	//! Concrete method that prints information about a projection in a string
+	string describe ();
+
+	//! Get projection unique id in the database
+	int	id() { return GPid;}
+
+	//! Set projection unique id in the database
+	void id(int i) { GPid = i;}
+};
+
+
+//!  Provides methods that are required to handle the UTM map projection.
+/*!
+	  Specifies methods that are necessary to establish the relation between
+	  geodetic and UTM coordinates. UTM is a conformal projection system that
+	  uses the planimetric datum Sad69 or Corrego Alegre  (Hayford ellipsoid).
+
+	 \sa TeCoord2D TeDatum TeProjection.
+*/
+class TL_DLL TeUtm : public TeProjection
+{
+public:
+
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param long0		longitude of origin (in radians)
+		\param lat0		latitude of origin (in radians)  
+		\param offx		X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param units		projection unit
+		\param scale		scale (used for UTM)
+		\param hemisphere	hemisphere
+	*/
+	TeUtm ( const TeDatum& datum, double long0, double lat0 = 0., 
+		     double offx = 500000., double offy = 10000000., 
+			 const string& units = "Meters",
+			 double scale = 0.9996, TeHemisphere hemisphere = TeSOUTH_HEM ):
+	TeProjection ( "UTM", datum, long0, lat0, offx, offy, 0., 0., units, scale,
+		hemisphere)
+
+	{
+		if ( hemisphere == TeNORTH_HEM )
+			GPoffy = 0.;
+	}
+
+	//! Destructor
+	~TeUtm () {}
+
+	//! This implementation of a pure virtual method defined in Projection transforms geodetic into UTM coordinates.
+	/*!		 
+		\param	p	Geodetic coordinates (rad).
+		\return	p:	UTM coordinates (m).
+		\note
+			Geodetic coordinates must be a valid latitude
+			([0,pi/2] or [0,-pi/2]) and a valid longitude
+			([0,pi] or [0,-pi]). Conventional UTM offsets
+			(500,000 m and 10,000,000 m) are always added
+			to the resulting projection coordinates.
+	*/
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	//!	This implementation of a pure virtual method defined in
+	/*	Projection transforms UTM into geodetic coordinates.
+		\param p:	UTM coordinates (m).
+		\return p:	Geodetic coordinates (rad).
+		\note
+		X and Y UTM coordinates must be both valid, within
+		their typical range. Conventional UTM offsets are
+		handled in this method, and therefore must not be 
+		previously subtracted.
+	*/
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+};
+
+//!  Provides methods that are required to handle Lambert conformal conic map projection..
+/*!
+  Specifies methods that are necessary to establish the relation between
+  geodetic and Lambert conformal conic coordinates. 
+  \sa TeCoord2D TeDatum TeProjection.
+*/
+class TL_DLL TeLambertConformal : public TeProjection
+{
+public :
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param long0		longitude of origin (in radians)
+		\param lat0		latitude of origin (in radians)  
+		\param offx		X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param stlat1		first standard parallel (in radians)
+		\param stlat2		second standard parallel (in radians)
+		\param units		projection unit
+	*/
+	TeLambertConformal ( const TeDatum& datum, 
+		                 double long0,
+			             double lat0, 
+						 double offx, 
+						 double offy,
+						 double stlat1, 
+						 double stlat2, 
+						 const string& units = "Meters" ):
+	TeProjection ( "LambertConformal", datum, long0, lat0, offx, offy, stlat1, stlat2, units)
+	{}
+
+	//! Destructor
+	~TeLambertConformal () {}
+
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual	TeCoord2D PC2LL(TeCoord2D& p);
+};
+
+//!  Provides methods that are required to handle the Mercator map projection.
+/*! 
+  Specifies methods that are necessary to establish the relation between
+  geodetic and Mercator coordinates.  
+*/
+class TL_DLL TeMercator : public TeProjection
+{
+
+public:
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param long0			longitude of origin (in radians)
+		\param lat0			latitude of origin (in radians)  
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param stlat1		first standard parallel (in radians)
+		\param units		projection unit
+	*/
+	TeMercator ( const TeDatum& datum,  
+		         double long0, 
+				 double lat0 = 0.,
+				 double offx = 0., 
+				 double offy = 0.,
+				 double stlat1 = 0.,
+				 const string& units = "Meters"): 
+	TeProjection ( "Mercator", datum, long0, lat0, offx, offy, stlat1, 0., units )
+	{}
+
+	//! Destructor
+	~TeMercator () {}
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+
+};
+
+
+
+//! Provides methods that are required to handle the Polyconic map projection.
+/*!  
+	Specifies methods that are necessary to establish the relation between
+    geodetic and Polyconic coordinates. Polyconic is a projection system that
+    is neither conformal nor equal-area. 
+*/  
+class TL_DLL TePolyconic : public TeProjection
+{
+public:
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param long0			longitude of origin (in radians)
+		\param lat0			latitude of origin (in radians)  
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param units		projection unit
+	*/
+	TePolyconic (const TeDatum& datum,  
+		         double long0, 
+				 double lat0 = 0.,
+				 double offx = 0., 
+				 double offy = 0.,
+				 const string& units = "Meters"): 
+	TeProjection ( "Polyconic", datum, long0, lat0, offx, offy, 0., 0., units )
+	{}  
+
+	//! Destructor
+	~TePolyconic () {}
+
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+};
+
+//!  Provides methods that are required to handle the Equidistant Cylindrical  map projection.
+class TL_DLL TeLatLong : public TeProjection
+{
+
+public :
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param units		projection unit
+	*/
+	TeLatLong( const TeDatum& datum, const string& units = "DecimalDegrees" ):
+	   TeProjection ( "LatLong", datum, 0., 0., 0., 0., 0., 0., units )
+	{}
+
+	//! Destructor
+	~TeLatLong () {}
+
+	//! Returns the same coordinate
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	//! Returns the same coordinate
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+
+	virtual void LL2PC(double xi, double yi, double& xo, double& yo) const; //FAMI
+	virtual void PC2LL(double xi, double yi, double& xo, double& yo); //FAMI
+
+};
+
+//!  Provides methods that are required to handle the Albers Conic map  projection.
+/*
+  Specifies methods that are necessary to establish the relation between
+  geodetic and Albers Conic coordinates. Albers Conic is an equal-area
+  projection system. 
+*/
+class TL_DLL TeAlbers : public TeProjection
+{
+public:
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param lon0			longitude of origin (in radians)
+		\param lat0			latitude of origin (in radians)  
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param stlat1		first standard parallel (in radians)
+		\param stlat2		second standard parallel (in radians)
+		\param units		projection unit
+	*/
+	TeAlbers( const TeDatum& datum, 
+		      double lon0,
+			  double lat0, 
+			  double offx, 
+			  double offy,
+			  double stlat1, 
+			  double stlat2, 
+			  const string& units = "Meters" ):
+		TeProjection ( "Albers", datum, lon0, lat0, offx, offy, stlat1, stlat2, units )
+	{} 
+
+	//! Destructor
+	~TeAlbers () { }
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+};
+
+//!  Provides methods that are required to handle the Miller map projection.
+/*!
+  Specifies methods that are necessary to establish the relation between
+  geodetic and Miller coordinates. Miller is a projection system that
+  is neither conformal nor equal-area."
+*/
+class TL_DLL TeMiller : public TeProjection	
+{
+public:
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param long0		longitude of origin (in radians)
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param units		projection unit
+	*/
+	TeMiller ( const TeDatum& datum,  
+		         double long0, 
+				 double offx = 0., 
+				 double offy = 0.,
+				 const string& units = "Meters"): 
+	TeProjection ( "Miller", datum, long0, 0., offx, offy, 0., 0., units )
+	{}
+
+	//! Destructor
+	~TeMiller () {}
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+
+};
+
+//! Provides methods that are required to handle the Sinusoidal map projection.
+/*!
+  Specifies methods that are necessary to establish the relation between
+  geodetic and Sinusoidal coordinates. Sinusoidal is a projection system that
+  is equal-area. Being not an interrupted form, 
+  this implementation assumes a single central meridian. Spheroid options 
+  can be redefined by editing the file "TeDatum.cpp"
+*/
+class TL_DLL TeSinusoidal : public TeProjection	
+{
+public:
+
+//!	Constructor.
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param long0		longitude of origin (in radians)
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param units		projection unit
+	*/
+	TeSinusoidal (const TeDatum& datum,  
+		         double long0, 
+				 double offx = 0., 
+				 double offy = 0.,
+				 const string& units = "Meters"): 
+	TeProjection ( "Sinusoidal", datum, long0, 0., offx, offy, 0., 0., units )
+	{}
+
+//! Empty destructor.
+	~TeSinusoidal () {}
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+};
+
+//! Provides methods that are required to handle the Cylindrical Equidistant map projection
+class TL_DLL TeCylindricalEquidistant : public TeProjection
+{
+public:
+
+//!	Constructor.
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param lon0			longitude of origin (in radians)
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param stlat1		first standard parallel (in radians)
+		\param units		projection unit
+	*/
+	TeCylindricalEquidistant (const TeDatum& datum,  
+		         double lon0, 
+				 double offx = 0., 
+				 double offy = 0.,
+				 double stlat1 = 0.,
+				 const string& units = "Meters"):
+			TeProjection ( "CylindricalEquidistant", datum, lon0, 0., offx, offy, stlat1, 0,units)
+		{}
+//! Empty destructor.
+	~TeCylindricalEquidistant () {}
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+};
+
+//! Provides methods that are required to handle the Polar Stereographic map projection
+class TL_DLL TePolarStereographic : public TeProjection
+{
+public:
+	//! Constructor
+	/*!	
+		Initializes projection parameters 
+		\param datum		spheroid
+		\param lon0			longitude of origin (in radians)
+		\param offx			X (projection coordinate) offset (m)
+		\param offy 		Y (projection coordinate) offset (m)
+		\param units		projection unit
+		\param hem	hemisphere
+	*/
+	TePolarStereographic ( const TeDatum& datum,  
+		         double lon0,  
+				 double offx = 0., 
+				 double offy = 0.,
+				 const string& units = "Meters",
+				 const TeHemisphere hem = TeSOUTH_HEM ):
+	TeProjection ( "PolarStereographic", datum, lon0, 0., offx, offy, 0, 0, units, 1, hem )
+	{}
+
+	//! Destructor
+	~TePolarStereographic () {}
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+	virtual	void	LL2PC (ostream&) const; //FAMI
+	virtual TeCoord2D PC2LL(TeCoord2D& p);
+
+	virtual void LL2PC(double xi, double yi, double& xo, double& yo) const; //FAMI
+};
+
+//FAMI
+class TL_DLL TeSatelliteProjection : public TeProjection
+{
+
+private:
+	
+	double	SPri,	// Sensor angle resolution along y axis in radians
+		SPrj,	// Sensor angle resolution along x axis in radians
+		SPis,	// Y-coordinate of sub-satellite point 
+		SPjs,	// X-coordinate of sub-satellite point
+	        SPrs,   // Radius of satellite orbit in meters
+		SPscn,	// Scanning mode: 0-WE/NS, 1-SN/EW
+		SPyaw;  // Grid orientation, i.e., angle in radians between
+			// the increasing y axis and the meridian of the
+			// sub-satellite point along the direction of
+			// increasing latitude.
+public:
+
+	//! Constructor
+	/*
+		\param datum: 	planimetric datum
+		\param offx: 	x offset
+		\param offy: 	y offset
+		\param Pri:     Sensor angle resolution along y axis in radians
+		\param Prj: 	Sensor angle resolution along x axis in radians
+		\param Pis:     Y-coordinate of sub-satellite point 
+		\param Pjs: 	X-coordinate of sub-satellite point
+		\param Pla0: 	Latitude of sub-satellite point in radians
+		\param Plo0: 	Longitude of sub-satellite point in radians
+		\param Prs: 	Radius of satellite orbit in meters
+		\param Pscn: 	Scanning mode: 0-WE/NS, 1-SN/EW
+		\param Pyaw: 	Grid orientation, i.e., angle in radians between
+				the increasing y axis and the meridian of the
+				sub-satellite point along the direction of
+				increasing latitude.
+		*/
+	TeSatelliteProjection(const TeDatum& datum, double offx, double offy,  
+			      double Pri, double Prj, double Pis, double Pjs, double Pla0, double Plon0, 
+			      double Prs,double Pscn, double Pyaw):
+			TeProjection("Satellite", datum, Plon0, Pla0, offx, offy, 0., 0.,"Meters",1.,TeSOUTH_HEM),
+			SPri(Pri),
+			SPrj(Prj),
+			SPis(Pis),
+			SPjs(Pjs),		
+			SPrs(Prs),
+			SPscn(Pscn),
+			SPyaw(Pyaw)	{}
+
+	~TeSatelliteProjection() {}
+
+	virtual TeCoord2D LL2PC(TeCoord2D& p);
+
+	virtual	TeCoord2D PC2LL(TeCoord2D& p);
+
+	// Returns a the parameters of this projection
+	virtual TeProjectionParams params () const;
+
+	double RadiusSatOrbit () { return SPrs; }
+};
+
+class TL_DLL TeNoProjection : public TeProjection
+{
+public:
+	TeNoProjection(const TeDatum& datum = TeDatum(), const string& units = "Units"):
+		TeProjection ( "NoProjection", datum, 0., 0., 0., 0., 0, 0, units, 1, TeSOUTH_HEM )
+
+	{	GPname = "NoProjection", GPunits = units; }
+
+		~TeNoProjection () {}
+
+		virtual TeCoord2D LL2PC(TeCoord2D& p) { return p; }
+
+		virtual TeCoord2D PC2LL(TeCoord2D& p) {return p;};
+};
+
+bool TL_DLL decodifyDescription(const string& projDescription, TeProjectionParams& pars);
+
+//! Creates a TeProjection instance from a PROJ4 description
+/*
+	\note This function works only for sproj descriptionsgenerated by TerraLib
+*/
+TL_DLL TeProjection* TeGetTeProjectionFromSProj(const string& sproj4desc);
+
+//! Generates a PROJ4 description from a TerraLib instance
+TL_DLL string TeGetSProjFromTeProjection(TeProjection* teproj);
+
+//! Generates OGC WKT Spatial Reference description from a TerraLib instance
+TL_DLL string TeGetWKTFromTeProjection(TeProjection* proj);
+
+//! Creates a TeProjection instance from a OGC WKT Spatial Reference description
+/*
+	\note This function works only for sproj descriptions generated by TerraLib
+*/
+TL_DLL TeProjection* TeGetTeProjectionFromWKT(const string& wkt);
+
+/** \example convertCoordinates.cpp
+ * This is an example of how to convert a coordinate from a projection to another
+ */
+
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeProjectiveGT.cpp b/src/terralib/kernel/TeProjectiveGT.cpp
new file mode 100644
index 0000000..6064ee9
--- /dev/null
+++ b/src/terralib/kernel/TeProjectiveGT.cpp
@@ -0,0 +1,571 @@
+/*
+TerraLib - a library for developing GIS applications.
+Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular
+purpose. The library provided hereunder is on an "as is" basis, and the
+authors have no obligation to provide maintenance, support, updates,
+enhancements, or modifications.
+In no event shall INPE be held liable to any party
+for direct, indirect, special, incidental, or consequential damages arising
+out of the use of this library and its documentation.
+*/
+
+#include "TeProjectiveGT.h"
+#include "TeGeometry.h"
+
+#include <assert.h>
+#include <math.h>
+
+
+TeProjectiveGT::TeProjectiveGT() :
+  deltaX_( 0 ), deltaY_( 0 ), deltaU_( 0 ), deltaV_( 0 )
+{
+}
+
+
+TeProjectiveGT::~TeProjectiveGT()
+{
+}
+
+
+void TeProjectiveGT::directMap( const TeGTParams& params, const TeCoord2D& pt1, 
+    TeCoord2D& pt2 ) const
+{
+  assert( params.direct_parameters_.Ncol() == 3 );
+  assert( params.direct_parameters_.Nrow() == 3 );
+
+  double x = pt1.x();
+  double y = pt1.y();
+
+  if( ! params.useAdaptiveParams_ ) 
+  {
+    // denominador da fc projetiva    
+    double den = params.direct_parameters_( 2, 0 ) * x + params.direct_parameters_( 2, 1 ) * y + 1;
+  
+    pt2.x( ( params.direct_parameters_( 0, 0 ) * x + 
+      params.direct_parameters_( 0, 1 ) * y + 
+      params.direct_parameters_( 0, 2 ) ) / den );
+    pt2.y( ( params.direct_parameters_( 1, 0 ) * x + 
+      params.direct_parameters_( 1, 1 ) * y + 
+      params.direct_parameters_( 1, 2 ) ) / den ); 
+  }
+  else // use Adaptive parameters
+  {
+    x -= deltaX_;
+    y -= deltaY_;
+    
+    double den = params.direct_parameters_( 2, 0 ) * x + params.direct_parameters_( 2, 1 ) * y + 1;
+    
+    pt2.x( ( params.direct_parameters_( 0, 0 ) * x + 
+      params.direct_parameters_( 0, 1 ) * y + 
+      params.direct_parameters_( 0, 2 ) ) / den 
+      + deltaU_ );
+    pt2.y( ( params.direct_parameters_( 1, 0 ) * x + 
+      params.direct_parameters_( 1, 1 ) * y + 
+      params.direct_parameters_( 1, 2 ) ) / den 
+      + deltaV_ ); 
+  }
+}
+
+
+void TeProjectiveGT::inverseMap( const TeGTParams& params, const TeCoord2D& pt2, 
+  TeCoord2D& pt1 ) const
+{
+  assert( params.inverse_parameters_.Ncol() == 3 );
+  assert( params.inverse_parameters_.Nrow() == 3 );
+
+  double u = pt2.x();
+  double v = pt2.y();
+
+  if( ! params.useAdaptiveParams_  ) 
+  {
+    // denominador da fc projetiva
+    double den = params.inverse_parameters_( 2, 0 ) * u + params.inverse_parameters_( 2, 1 ) * v + 1;
+
+    pt1.x( ( params.inverse_parameters_( 0, 0 ) * u + 
+      params.inverse_parameters_( 0, 1 ) * v + 
+      params.inverse_parameters_( 0, 2 ) ) / den );
+    pt1.y( ( params.inverse_parameters_( 1, 0 ) * u + 
+      params.inverse_parameters_( 1, 1 ) * v + 
+      params.inverse_parameters_( 1, 2 ) ) / den );
+  }
+  else // use Adaptive parameters
+  {
+    u -= deltaU_;
+    v -= deltaV_;
+    
+    double den = params.inverse_parameters_( 2, 0 ) * u + params.inverse_parameters_( 2, 1 ) * v + 1;
+
+    pt1.x( ( params.inverse_parameters_( 0, 0 ) * u + 
+      params.inverse_parameters_( 0, 1 ) * v + 
+      params.inverse_parameters_( 0, 2 ) ) / den 
+      + deltaX_ );
+    pt1.y( ( params.inverse_parameters_( 1, 0 ) * u + 
+      params.inverse_parameters_( 1, 1 ) * v + 
+      params.inverse_parameters_( 1, 2 ) ) / den 
+      + deltaY_ );
+  }
+}
+
+
+unsigned int TeProjectiveGT::getMinRequiredTiePoints() const
+{
+  // At least four points
+  return 4;
+}
+
+
+bool TeProjectiveGT::computeParameters( TeGTParams& params )
+{
+  TEAGN_DEBUG_CONDITION( ( params.tiepoints_.size() > 3 ),
+    "Invalid tie-points size" )
+    
+  // calcula os parametros adaptativos
+  // caso contrario, reinicia o estado
+  if( params.useAdaptiveParams_ )
+    setAdaptativeParameters( params.tiepoints_ );
+  else
+    deltaX_ = deltaY_ = deltaU_ = deltaV_ = 0;
+
+  // a forma do calculo depende da qtd pontos
+  const unsigned int tiepoints_size = params.tiepoints_.size();
+
+  if( tiepoints_size > 4 ) 
+  {
+    // Solucao com sobredeterminacao -> ajustamento
+    // mapeamento direto
+    if( ! useAdjustment( params, true ) )
+      return false;
+
+    // mapeamento inverso
+    return useAdjustment( params, false );
+  } 
+  else 
+  {
+    // Solucao deterministica
+    // mapeamento direto
+    if( ! useDeterministic( params, true ) )
+      return false;
+
+    // mapeamento inverso
+    return useDeterministic( params, false );
+    
+  } // fim if tiepoints
+
+}
+
+bool TeProjectiveGT::useAdjustment( TeGTParams& params, bool isDirectMapping )
+{
+    /* 
+        u = b11.x + b12.y + b13
+            -------------------
+               b31.x + b32.y
+            
+        v = b21.x + b22.y + b23
+            -------------------
+               b31.x + b32.y
+               
+        Method adapted from Albertz and Kreiling (1989).
+        Reference: Albertz, J.; Kreiling, W. Photogrametriches taschenbuch. 
+        Karlsruhe: Wichmann, 1989.
+        
+        Adaptive parameters by Xavier et al. (2007).
+        Reference: Xavier, E.; Fonseca, L.; d'Alge, J.; Castejon, E. Implementacao 
+        da transformacao projetiva na TerraLib: uma analise comparativa com a 
+        transformacao afim. Anais do XIII Simposio Brasileiro de Sensoriamento 
+        Remoto. <http://www.dsr.inpe.br/sbsr2007/>, 2007.
+    */
+
+  // inicializacao das variaveis
+  
+  // tamanho de Lb
+  // Lb : vetor das observacoes brutas (originais)
+  const unsigned int tiepoints_size = params.tiepoints_.size();
+
+  // A: matriz do sistema de equacoes
+  // inicializa com zeros
+  TeMatrix A;
+  if( ! A.Init( 2*tiepoints_size, 8, 0.0 ) ) 
+  {
+    return false;
+  }
+
+  // L: vetor das correcoes das observacoes
+  TeMatrix L;
+  if( ! L.Init( 2*tiepoints_size, 1 ) ) 
+  {
+    return false;
+  }
+
+  // At: transposta de A
+  TeMatrix At;
+
+  // N = At*P*A
+  TeMatrix N;
+
+  // N_inv : inversa de N
+  TeMatrix N_inv;
+
+  // U = At*P*Lb
+  TeMatrix U;
+
+  // Xa : vetor dos parametros ajustados
+  TeMatrix Xa;
+
+  // X0 : vetor dos parametros iniciais 
+  TeMatrix X0;
+
+  // X = Xa-X0 : vetor das correcoes 
+  TeMatrix X;
+
+  // W: matriz peso das observacoes
+  bool hasWMatrix = ( ( params.WMatrix_.Nrow() == 
+    (int)( tiepoints_size * 2 ) ) && ( params.WMatrix_.Ncol() == 
+    (int)( tiepoints_size * 2 ) ) ) ? true : false;
+
+  // V: residuos das observacoes
+
+  // iterador p/ correr as observacoes
+  std::vector< TeCoordPair >::const_iterator iterator;  
+
+  // Inicializacao de X0
+  // [1 0 0 0 1 0 0 0]t
+  X0.Init( 8, 1, 0.0 );
+  X0(0, 0) = 1;
+  X0(4, 0) = 1;
+
+
+  /**************************************************************\
+  Solucao com sobredeterminacao -> ajustamento
+  \**************************************************************/
+
+  // 0) Montando o laco while ate q o valor convirja (isTolReached) 
+  // ou alcance o Nr max de iteracoes (maxIters_)
+
+  // contagem das iteracoes
+  unsigned int iter = 0;
+
+  // alcancou a tolerancia?
+  bool isTolReached = false;
+
+  while( iter++ < params.maxIters_ && ! isTolReached ) 
+  {
+    // inicializando o iterador dos pontos observados (u/v)
+    iterator = params.tiepoints_.begin();
+
+    for ( unsigned int i = 0; i < tiepoints_size; ++i ) 
+    {
+      // pontos usados em todo o laco
+      // xi,yi : from
+      // ui,ui : to
+      double xi, yi; 
+      double ui, vi;
+      
+      if( isDirectMapping ) 
+      {
+        xi = iterator->pt1.x() - deltaX_;
+        yi = iterator->pt1.y() - deltaY_;
+        ui = iterator->pt2.x() - deltaU_;
+        vi = iterator->pt2.y() - deltaV_;
+      } 
+      else 
+      {
+        xi = iterator->pt2.x() - deltaU_;
+        yi = iterator->pt2.y() - deltaV_;
+        ui = iterator->pt1.x() - deltaX_;
+        vi = iterator->pt1.y() - deltaY_;
+      }
+
+      // denominador da fc projetiva
+      // den = b31 * xi + b32 * yi + 1
+      double den = X0( 6, 0 ) * xi + X0( 7, 0 ) * yi + 1;
+
+      // funcao projetiva p/ U e V
+      // U = ( b11 * xi + b12 * yi + b13 ) / den
+      double funcU = ( X0( 0, 0 ) * xi + X0( 1, 0 ) * yi + X0( 2, 0 ) - xi * ui * X0( 6, 0 ) -yi * ui * X0( 7, 0 ) );
+
+      // V = ( b21 * xi + b22 * yi + b23 ) / den
+      double funcV = ( X0( 3, 0 ) * xi + X0( 4, 0 ) * yi + X0( 5, 0 ) - xi * vi * X0( 6, 0 ) -yi * vi * X0( 7, 0 ) );
+
+      // 1) Calculo de L
+      // L = L0 - Lb 
+      L( 2*i  , 0 ) = (funcU - ui) / den;
+      L( 2*i+1, 0 ) = (funcV - vi) / den;
+
+      // 2) Montagem de A
+      // lembrando q jah tem zero em tudo
+      A( 2*i   , 0 ) = xi / den;
+      A( 2*i   , 1 ) = yi / den;
+      A( 2*i   , 2 ) = 1  / den;
+      A( 2*i   , 6 ) = -xi*ui/den;
+      A( 2*i   , 7 ) = -yi*ui/den;
+
+      A( 2*i+1 , 3 ) = A( 2*i, 0 );
+      A( 2*i+1 , 4 ) = A( 2*i, 1 );
+      A( 2*i+1 , 5 ) = A( 2*i, 2 );
+      A( 2*i+1 , 6 ) = -xi*vi/den;
+      A( 2*i+1 , 7 ) = -yi*vi/den;
+
+      ++iterator;
+    } // fim for_tiepoints
+
+    // 3) Calculo de N
+    A.Transpose( At );
+
+    // Se W_ esta definida
+    if( hasWMatrix ) 
+    {
+      N = At * params.WMatrix_;
+      N = N * A;
+    } 
+    else 
+      N = At * A;
+
+    // 4) Calculo de U
+    // Se W_ esta definida
+    if( hasWMatrix ) 
+    {
+      U = At * params.WMatrix_;
+      U = U * L;
+    } 
+    else 
+      U = At * L;
+
+    // 5) Calculo de X
+    if( ! N.Inverse( N_inv ) )
+      return false;
+
+    X = - N_inv * U;
+
+    // 6) Calculo de Xa
+    Xa = X0 + X;
+
+    // 7) Atualiza o X0 p/ proxima iteracao
+    X0 = Xa;
+
+    // 8) Checando se a tolerancia foi atingida
+
+    isTolReached = true;
+    for( unsigned int j = 0; j < 8; ++j ) 
+    {
+      if( fabs( X( j, 0 ) ) > params.tolerance_ ) 
+      {
+        isTolReached = false;
+        break;
+      }
+    }
+
+  } // fim while
+
+  // final - montagem da resposta
+  
+
+  if( isDirectMapping ) 
+  {
+    if( ! params.direct_parameters_.Init( 3, 3 ) )
+      return false;
+    
+    params.direct_parameters_(0,0) = Xa(0,0);
+    params.direct_parameters_(0,1) = Xa(1,0);
+    params.direct_parameters_(0,2) = Xa(2,0);
+  
+    params.direct_parameters_(1,0) = Xa(3,0);
+    params.direct_parameters_(1,1) = Xa(4,0);
+    params.direct_parameters_(1,2) = Xa(5,0);
+  
+    params.direct_parameters_(2,0) = Xa(6,0);
+    params.direct_parameters_(2,1) = Xa(7,0);
+    params.direct_parameters_(2,2) = 1;
+  }
+  else
+  {
+    if( ! params.inverse_parameters_.Init( 3, 3 ) )
+      return false;
+    
+    params.inverse_parameters_(0,0) = Xa(0,0);
+    params.inverse_parameters_(0,1) = Xa(1,0);
+    params.inverse_parameters_(0,2) = Xa(2,0);
+  
+    params.inverse_parameters_(1,0) = Xa(3,0);
+    params.inverse_parameters_(1,1) = Xa(4,0);
+    params.inverse_parameters_(1,2) = Xa(5,0);
+  
+    params.inverse_parameters_(2,0) = Xa(6,0);
+    params.inverse_parameters_(2,1) = Xa(7,0);
+    params.inverse_parameters_(2,2) = 1;
+  }
+
+  return true;
+}
+
+
+bool TeProjectiveGT::useDeterministic( TeGTParams& params, bool isDirectMapping )
+{
+
+  // Solucao deterministica, da forma:
+  // X = A^-1 . L
+
+  // o vetor de ptos sempre tera tamanho 4
+  const unsigned int tiepoints_size = 4;
+
+  // A: matriz do sistema de equacoes
+  // inicializa com zeros
+  TeMatrix A;
+  if( ! A.Init( 2*tiepoints_size, 8, 0.0 ) ) 
+  {
+    return false;
+  }
+
+  // L: vetor das observacoes
+  TeMatrix L;
+  if( ! L.Init( 2*tiepoints_size, 1 ) ) 
+  {
+    return false;
+  }
+
+  // inversa de A
+  TeMatrix A_inv;
+
+  // resultado
+  TeMatrix X;
+
+  // iterador p/ correr as observacoes
+  std::vector< TeCoordPair >::const_iterator iterator = params.tiepoints_.begin();;  
+
+  // montagem de A e L
+  for ( unsigned int i = 0; i < tiepoints_size; ++i ) {
+
+    // pontos usados em todo o laco
+    // xi,yi : from
+    // ui,ui : to
+    double xi, yi; 
+    double ui, vi;
+
+    if( isDirectMapping ) 
+    {
+      xi = iterator->pt1.x();
+      yi = iterator->pt1.y();
+      ui = iterator->pt2.x();
+      vi = iterator->pt2.y();
+    } 
+    else 
+    {
+      xi = iterator->pt2.x();
+      yi = iterator->pt2.y();
+      ui = iterator->pt1.x();
+      vi = iterator->pt1.y();
+    }
+
+    // 1) Calculo de L
+    L( 2*i  , 0 ) = ui;
+    L( 2*i+1, 0 ) = vi;
+
+    // 2) Montagem de A
+    // lembrando q jah tem zero em tudo
+    A( 2*i   , 0 ) = xi;
+    A( 2*i   , 1 ) = yi;
+    A( 2*i   , 2 ) = 1;
+    A( 2*i   , 6 ) = - xi * ui;
+    A( 2*i   , 7 ) = - yi * ui;
+
+    A( 2*i+1 , 3 ) = xi;
+    A( 2*i+1 , 4 ) = yi;
+    A( 2*i+1 , 5 ) = 1;
+    A( 2*i+1 , 6 ) = - xi * vi;
+    A( 2*i+1 , 7 ) = - yi * vi;
+
+    ++iterator;
+
+  } // fim for_tiepoints
+
+  // 3) Calculo de A_inv
+  A.Inverse( A_inv );
+
+  // 4) Calculo de X
+  X = A_inv * L;
+
+  // final - montagem da resposta
+  
+    if( isDirectMapping ) 
+  {
+    if( ! params.direct_parameters_.Init( 3, 3 ) )
+      return false;
+    
+    params.direct_parameters_(0,0) = X(0,0);
+    params.direct_parameters_(0,1) = X(1,0);
+    params.direct_parameters_(0,2) = X(2,0);
+  
+    params.direct_parameters_(1,0) = X(3,0);
+    params.direct_parameters_(1,1) = X(4,0);
+    params.direct_parameters_(1,2) = X(5,0);
+  
+    params.direct_parameters_(2,0) = X(6,0);
+    params.direct_parameters_(2,1) = X(7,0);
+    params.direct_parameters_(2,2) = 1;
+  }
+  else
+  {
+    if( ! params.inverse_parameters_.Init( 3, 3 ) )
+      return false;
+    
+    params.inverse_parameters_(0,0) = X(0,0);
+    params.inverse_parameters_(0,1) = X(1,0);
+    params.inverse_parameters_(0,2) = X(2,0);
+  
+    params.inverse_parameters_(1,0) = X(3,0);
+    params.inverse_parameters_(1,1) = X(4,0);
+    params.inverse_parameters_(1,2) = X(5,0);
+  
+    params.inverse_parameters_(2,0) = X(6,0);
+    params.inverse_parameters_(2,1) = X(7,0);
+    params.inverse_parameters_(2,2) = 1;
+  }
+
+  return true;
+}
+
+void TeProjectiveGT::setAdaptativeParameters( const std::vector< TeCoordPair >& tiepoints )
+{
+  deltaX_ = TeMAXFLOAT;
+  deltaY_ = TeMAXFLOAT;
+  deltaU_ = TeMAXFLOAT;
+  deltaV_ = TeMAXFLOAT;
+  
+  const unsigned int tiepoints_size = tiepoints.size();
+  
+  // iterador p/ correr as observacoes
+  std::vector< TeCoordPair >::const_iterator iterator = tiepoints.begin();
+  
+  for ( unsigned int i = 0; i < tiepoints_size; ++i ) 
+  {
+    double xi, yi; 
+    double ui, vi;
+      
+    // obtem os valores
+    xi = iterator->pt1.x();
+    yi = iterator->pt1.y();
+    ui = iterator->pt2.x();
+    vi = iterator->pt2.y();
+    
+    // checa se eh o menor - cada um
+    if( xi < deltaX_ ) deltaX_ = xi;
+    if( yi < deltaY_ ) deltaY_ = yi;
+    if( ui < deltaU_ ) deltaU_ = ui;
+    if( vi < deltaV_ ) deltaV_ = vi;
+    
+  }
+
+}
+
diff --git a/src/terralib/kernel/TeProjectiveGT.h b/src/terralib/kernel/TeProjectiveGT.h
new file mode 100644
index 0000000..f425df1
--- /dev/null
+++ b/src/terralib/kernel/TeProjectiveGT.h
@@ -0,0 +1,118 @@
+/*
+TerraLib - a library for developing GIS applications.
+Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular
+purpose. The library provided hereunder is on an "as is" basis, and the
+authors have no obligation to provide maintenance, support, updates,
+enhancements, or modifications.
+In no event shall INPE be held liable to any party
+for direct, indirect, special, incidental, or consequential damages arising
+out of the use of this library and its documentation.
+*/
+
+#ifndef TEPROJECTIVEGT_H
+#define TEPROJECTIVEGT_H
+
+#include <TeGeometricTransformation.h>
+
+/**
+* @brief This is the class to deal projective geometric trasformation.
+* @author Emerson M.A. Xavier <emerson at dpi.inpe.br>
+* @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+* @ingroup Utils
+*/
+class TL_DLL TeProjectiveGT : public TeGeometricTransformation {
+public :
+
+  /**
+  * Default Constructor.
+  */
+  TeProjectiveGT();
+
+  /**
+  * Default Destructor
+  */
+  ~TeProjectiveGT();
+
+  /**
+  * Returns the minimum number of required tie-points for the current
+  * transformation.
+  *
+  * @return The minimum number of required tie-points for the current
+  * transformation.
+  */       
+  unsigned int getMinRequiredTiePoints() const;      
+
+protected :
+
+  /**
+     * @brief Direct mapping ( from pt1 space into pt2 space ).
+     *
+     * @param params Transformation parameters.
+     * @param pt1 pt1 coordinate.
+     * @param pt2 pt2 coordinate.
+     */      
+    void directMap( const TeGTParams& params, const TeCoord2D& pt1, 
+      TeCoord2D& pt2 ) const;
+      
+    /**
+     * @brief Inverse mapping ( from pt2 space into pt1 space ).
+     *
+     * @param params Transformation parameters.
+     * @param pt2 pt2 coordinate.
+     * @param pt1 pt1 coordinate.
+     */      
+    void inverseMap( const TeGTParams& params, const TeCoord2D& pt2, 
+      TeCoord2D& pt1 ) const;      
+      
+    /**
+     * @brief Calculate the transformation parameters following the
+     * new supplied tie-points.
+     *
+     * @param params Transformation parameters.
+     * @return true if OK, false on errors.
+     */       
+    bool computeParameters( TeGTParams& params );
+  
+
+private:  
+
+  /** 
+   * @brief When using more than four tiepoints, use adjustment.
+   */
+  bool useAdjustment( TeGTParams& params, bool isDirectMapping );
+
+  /** 
+   * @brief When using exactly four tiepoints, use deterministic solution.
+   */
+  bool useDeterministic( TeGTParams& params, bool isDirectMapping );
+
+  /** 
+   * @brief Set adaptative parameters
+   *
+   * @note This method is called whether the flag "useAdaptiveParameters" is on. 
+   */
+  void setAdaptativeParameters( const std::vector< TeCoordPair >& tiepoints );
+  
+
+  double deltaX_; //!< Adaptive parameters: Delta X.
+  double deltaY_; //!< Adaptive parameters: Delta Y.
+  double deltaU_; //!< Adaptive parameters: Delta U.
+  double deltaV_; //!< Adaptive parameters: Delta V.
+
+};
+
+#endif // TEPROJECTIVEGT_H
+
diff --git a/src/terralib/kernel/TeProjectiveGTFactory.cpp b/src/terralib/kernel/TeProjectiveGTFactory.cpp
new file mode 100644
index 0000000..df223cb
--- /dev/null
+++ b/src/terralib/kernel/TeProjectiveGTFactory.cpp
@@ -0,0 +1,49 @@
+/*
+TerraLib - a library for developing GIS applications.
+Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular
+purpose. The library provided hereunder is on an "as is" basis, and the
+authors have no obligation to provide maintenance, support, updates,
+enhancements, or modifications.
+In no event shall INPE be held liable to any party
+for direct, indirect, special, incidental, or consequential damages arising
+out of the use of this library and its documentation.
+*/
+
+#include "TeProjectiveGTFactory.h"
+#include <TeProjectiveGT.h>
+#include <TeException.h>
+
+TeProjectiveGTFactory::TeProjectiveGTFactory()
+: TeGTFactory( std::string( "projective" ) )
+{
+};      
+
+TeProjectiveGTFactory::~TeProjectiveGTFactory()
+{
+};
+
+
+TeGeometricTransformation* TeProjectiveGTFactory::build ( 
+  const TeGTParams& )
+{
+  TeGeometricTransformation* instance_ptr = new TeProjectiveGT();
+  
+  if( ! instance_ptr ) {
+    throw TeException( FACTORY_PRODUCT_INSTATIATION_ERROR );
+  }
+  
+  return instance_ptr;
+}
diff --git a/src/terralib/kernel/TeProjectiveGTFactory.h b/src/terralib/kernel/TeProjectiveGTFactory.h
new file mode 100644
index 0000000..e40deb1
--- /dev/null
+++ b/src/terralib/kernel/TeProjectiveGTFactory.h
@@ -0,0 +1,67 @@
+/*
+TerraLib - a library for developing GIS applications.
+Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular
+purpose. The library provided hereunder is on an "as is" basis, and the
+authors have no obligation to provide maintenance, support, updates,
+enhancements, or modifications.
+In no event shall INPE be held liable to any party
+for direct, indirect, special, incidental, or consequential damages arising
+out of the use of this library and its documentation.
+*/
+
+#ifndef TEPROJECTIVEGTFACTORY_H
+  #define TEPROJECTIVEGTFACTORY_H
+  
+  #include <TeGTFactory.h>
+
+  /**
+   * @brief This is the projective geometric trasformation factory.
+   * @author Emerson M.A. Xavier <emerson at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  class TL_DLL TeProjectiveGTFactory : public TeGTFactory
+  {
+    public :
+      
+      /**
+       * Default constructor
+       */
+      TeProjectiveGTFactory();      
+      
+      /**
+       * Default Destructor
+       */
+      ~TeProjectiveGTFactory();
+      
+    protected :  
+    
+      /**
+       * Implementation for the abstract TeFactory::build.
+       *
+       * @param arg A const reference to the used parameters.
+       * @return A pointer to the new generated instance.
+       */
+      TeGeometricTransformation* build( const TeGTParams& arg );
+      
+  };
+
+  namespace
+  {  
+    static TeProjectiveGTFactory TeProjectiveGTFactory_instance;
+  };
+  
+#endif
+
diff --git a/src/terralib/kernel/TePrototype.h b/src/terralib/kernel/TePrototype.h
new file mode 100644
index 0000000..f13b809
--- /dev/null
+++ b/src/terralib/kernel/TePrototype.h
@@ -0,0 +1,83 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TePrototype.h
+    \brief This file contains a template for the "TePrototype" pattern.
+*/
+#ifndef TePrototype_H
+#define TePrototype_H
+//!  Implements a template for the "Prototype" pattern.
+/*
+	See the book "Design Patterns - Elements of Reusable Object-Oriented Software", by Gamma et. al.
+	for further documentation.
+*/
+
+#include "TeDefines.h"
+
+template <class T>
+class TePrototype
+{
+public:
+
+	//! Export pointer to the structure
+	typedef  TePrototype<T>* TePrototypePtr;
+
+// -- Normal Constructor
+
+	//! Constructor
+	TePrototype ();
+	
+	//! Destructor
+	virtual ~TePrototype() {}
+
+	//! Virtual Constructor 
+	static T* clone ();
+
+	//! Builds a new type (should be implemented by descendants)
+    virtual T* build () = 0;
+
+private:
+	static TePrototypePtr instance_;
+};
+
+// Initialisation of static variable
+template <class T>
+typename TePrototype<T>::TePrototypePtr TePrototype<T>::instance_;
+
+// Constructor
+template <class T>
+TePrototype<T>::TePrototype()
+{
+	// Put the object in the factory dictionary
+	instance_ = this;
+}
+
+// Virtual Constructor
+template <class T> 
+T*
+TePrototype<T>::clone ()
+{
+	return instance_->build();
+}
+
+#endif
+
diff --git a/src/terralib/kernel/TeProxMatrixConstructionStrategy.cpp b/src/terralib/kernel/TeProxMatrixConstructionStrategy.cpp
new file mode 100644
index 0000000..1c55fc1
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixConstructionStrategy.cpp
@@ -0,0 +1,922 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+
+#include "TeProxMatrixConstructionStrategy.h"
+#include "TeProgress.h"
+#include "TeSTEvent.h"
+#include "TeSTInstance.h"
+
+//////////////////////////////////////////////////////////////////////
+// Auxiliary Functions for construction strategies
+//////////////////////////////////////////////////////////////////////
+
+bool
+TeFindObjectCentroid (TeMultiGeometry& mGeom, TeGeomRep rep, TeCoord2D& p)
+{		
+		if(rep == TePOLYGONS)
+		{
+			TePolygonSet pols;
+			if(mGeom.getGeometry(pols))
+				p = TeFindCentroid (pols);
+			else
+				return false;
+		}
+		else if (rep == TeLINES)
+		{
+			TeLineSet lines;
+			if(mGeom.getGeometry (lines))
+				p = TeFindCentroid (lines);
+			else
+				return false;
+		}
+		else if (rep == TePOINTS)
+		{
+			TePointSet points;
+			if(mGeom.getGeometry (points))
+				p = TeFindCentroid (points);
+			else
+				return false;
+		}
+		else if (rep == TeCELLS)
+		{
+			TeCellSet cells;
+			if(mGeom.getGeometry (cells))
+				p = TeFindCentroid (cells);
+			else
+				return false;
+		}
+		else if (rep == TeTEXT)
+		{
+			TeTextSet texts;
+			if(mGeom.getGeometry (texts))
+				p = TeFindCentroid (texts);
+			else
+				return false;
+		}		
+		return true;
+}
+
+bool
+TeFindObjectsCentroid (TeSTElementSet* objects, const string& object_id, TeGeomRep rep, TeCoord2D& p)
+{
+	if(rep==TePOLYGONS)
+	{
+		TePolygonSet polygons;
+		if(objects->getGeometry (object_id, polygons))
+			p = TeFindCentroid (polygons);
+	}
+	else if (rep==TeLINES)
+	{
+		TeLineSet lines;
+		if(objects->getGeometry (object_id, lines))
+			p = TeFindCentroid (lines);		
+	}
+	else if (rep==TePOINTS)
+	{
+		TePointSet points;
+		if(objects->getGeometry (object_id, points))
+			p = TeFindCentroid (points);					
+	}
+	else if (rep==TeCELLS)
+	{
+		TeCellSet cells;
+		if(objects->getGeometry(object_id, cells))
+			p = TeFindCentroid (cells);
+	}
+	return true;
+}
+
+
+bool  TeSelectEntryPoints (TeNodeSet  entry_set, map<string, string> entry_geom_map, TeGraphNetwork* net,
+						double max_dist, TeSTElementSet* objects, TeGeomRep rep, TeProxMatrixImplementation* imp)
+{
+
+	// Compute minimum path for all the new nodes/geometries near the network
+	// and connect the ones close enough
+	TeNodeSet::iterator it_node1 = entry_set.begin();
+	while ( it_node1 != entry_set.end())
+	{
+		vector<double> minimum_path;
+		if (net->minimumPath ((*it_node1), entry_set, minimum_path))
+		{
+		int j  = 0;
+		// Check maximum connection distance and connect selected objects
+		TeNodeSet::iterator it_node2 = entry_set.begin();
+		while ( it_node2 != entry_set.end())
+		{
+			// Get ids to simplify the code
+			string node1_id   = (*it_node1).objectId(); // Created Node id, nearest point to Geom1
+			string node2_id   = (*it_node2).objectId();	// Created Node id, nearest point to Geom1		
+			string object1_id = entry_geom_map[node1_id]; // Input Geom1 id
+			string object2_id = entry_geom_map[node2_id]; // Input Geom2 id
+
+			// Check identity and maximum allowed distance through the network
+	  		if ((object1_id != object2_id) && (minimum_path[j] <= max_dist))
+				{	
+					// Compute attributes and connect objects
+					TeProxMatrixAttributes attr;
+					
+					TeCoord2D p1, p2;
+					if (!TeFindObjectsCentroid (objects, object1_id, rep, p1))
+						return false;
+
+					if (!TeFindObjectsCentroid (objects, object2_id, rep, p2))
+						return false;
+				
+					// Local istance between input geometries
+					attr.CentroidDistance (TeDistance (p1, p2));
+
+					// Total distance from input geometries centroids to network
+					attr.NetworkObjectsDistance (TeDistance (p1, (*it_node1).location()) + 
+												 TeDistance (p2, (*it_node2).location()));	
+				
+					// Minimum path from the nodes relatives to the two geometries
+					attr.NetworkMinimumPath (minimum_path[j]);  
+			
+					imp->connectObjects (object1_id, object2_id, attr); // for networks, only one direction is connected
+				}
+			it_node2++;
+			j++;
+		}
+		}
+		it_node1++;
+	}
+	return true;
+}
+
+
+bool  TeSelectEntryPoints2 (TeNodeSet    entry_set1,
+						  TeNodeSet    entry_set2,
+						map<string, string> entry_geom_map,
+						TeGraphNetwork* net,
+						double max_dist, 
+						TeSTElementSet* objects1,
+						TeGeomRep rep1,
+						TeSTElementSet* objects2,
+						TeGeomRep rep2,
+						TeProxMatrixImplementation* imp)
+{
+
+	// Compute minimum path for all the new nodes/geometries near the network
+	// and connect the ones close enough
+	TeNodeSet::iterator it_node1 = entry_set1.begin();
+	while ( it_node1 != entry_set1.end())
+	{
+		vector<double> minimum_path;
+		net->minimumPath ((*it_node1), entry_set2, minimum_path); 
+		if (minimum_path.size() > 0)
+		{
+			int j  = 0;
+		// Check maximum connection distance and connect selected objects
+			TeNodeSet::iterator it_node2 = entry_set2.begin();
+			while ( it_node2 != entry_set2.end())
+			{
+			    // Get ids to simplify the code
+				string node1_id   = (*it_node1).objectId(); // Created Node id, nearest point to Geom1
+				string node2_id   = (*it_node2).objectId();	// Created Node id, nearest point to Geom1		
+				string object1_id = entry_geom_map[node1_id]; // Input Geom1 id
+				string object2_id = entry_geom_map[node2_id]; // Input Geom2 id
+	
+		
+				// Check identity and maximum allowed distance through the network
+	  			if ((object1_id != object2_id) && (minimum_path[j] <= max_dist))
+				{
+					
+					// Compute attributes and connect objects
+					TeProxMatrixAttributes attr;
+
+					TeCoord2D p1, p2;
+					if (!TeFindObjectsCentroid (objects1, object1_id, rep1, p1))
+						return false;
+
+					if (!TeFindObjectsCentroid (objects2, object2_id, rep2,  p2))
+						return false;
+		
+					// Local distance
+					attr.CentroidDistance (TeDistance (p1, p2));
+
+					// Total distance from input geometries centroids to network
+					attr.NetworkObjectsDistance (TeDistance (p1, (*it_node1).location()) + 
+												 TeDistance (p2, (*it_node2).location()));	
+				
+					// Minimum path from the nodes relatives to the two geometries
+					attr.NetworkMinimumPath (minimum_path[j]);  
+			
+					imp->connectObjects (object1_id, object2_id, attr); // for networks, only one direction is connected
+				}
+				it_node2++;
+				j++;
+			}
+		}
+		it_node1++;
+	}
+	return true;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// TeProxMatrixLocalAdjacencyStrategy 
+//////////////////////////////////////////////////////////////////////
+
+TeProxMatrixLocalAdjacencyStrategy::TeProxMatrixLocalAdjacencyStrategy () : 
+		TeProxMatrixConstructionStrategy<TeSTElementSet> (0, TeGEOMETRYNONE, TeAdjacencyStrategy)
+		{ }
+
+
+TeProxMatrixLocalAdjacencyStrategy::TeProxMatrixLocalAdjacencyStrategy (TeSTElementSet*  objects, TeGeomRep	geomRep, bool calcDistance):
+		TeProxMatrixConstructionStrategy<TeSTElementSet> (objects, geomRep, TeAdjacencyStrategy)
+		{
+			params_.calculate_distance_=calcDistance;
+		}
+
+
+TeProxMatrixLocalAdjacencyStrategy::TeProxMatrixLocalAdjacencyStrategy (TeProxMatrixLocalAdjacencyStrategy& st):
+		TeProxMatrixConstructionStrategy<TeSTElementSet> (st)
+		{ }
+
+bool 
+TeProxMatrixLocalAdjacencyStrategy::Construct (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) 
+		return false;
+	
+	// Iterate over all selected objects, selecting their neighbours
+	TeSTElementSet::iterator itobj1 = objects_->begin();
+	
+	// ----- progress bar
+	int step = 0;
+	if(TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(objects_->numSTInstance());
+	// -----
+
+	TeProjection* proj = 0;
+	if(objects_->theme())
+		proj = objects_->theme()->layer()->projection();
+	else if(objects_->getLayer())
+		proj = objects_->getLayer()->projection();
+	TePrecision::instance().setPrecision(TeGetPrecision(proj));
+		
+	while ( itobj1 != objects_->end())
+	{
+		// Gets the possible adjacent objects from RTree in the element set
+		vector<TeSTInstance*> result;
+		objects_->search((*itobj1).getGeometries().getBox(), result);
+		string object_id1 = (*itobj1).getObjectId(); 
+
+		TePolygonSet	polSet1;
+		TeCellSet		cellSet1;
+		itobj1->getGeometry(polSet1);
+		itobj1->getGeometry(cellSet1);
+        
+		for(unsigned int i=0; i<result.size(); ++i)
+		{
+			string object_id2 = result[i]->getObjectId(); 
+
+			if(object_id1==object_id2)
+				continue;
+			
+			bool touch = false; 
+			if(params_.geom_rep1_==TePOLYGONS)
+			{				
+				TePolygonSet polSet2;
+				result[i]->getGeometry(polSet2);
+				for(unsigned int index=0; index<polSet1.size(); ++index)
+				{					
+					for(unsigned int index2=0; index2<polSet2.size(); ++index2)
+					{
+                        bool curTouches = TeTouches(polSet1[index], polSet2[index2]);
+						if(touch && !curTouches)
+						{
+							//verifies if the current polygons are disjunt
+							if(!TeDisjoint(polSet1[index], polSet2[index2]))
+							{
+								touch = false;
+								index = polSet1.size();
+								break;
+							}
+						}
+						touch = curTouches;
+					}
+				}
+			}
+			else if(params_.geom_rep1_==TeCELLS)
+			{
+				TeCellSet cellSet2;
+				result[i]->getGeometry(cellSet2);
+				for(unsigned int index=0; index<cellSet1.size(); ++index)
+				{					
+					for(unsigned int index2=0; index2<cellSet2.size(); ++index2)
+					{
+                        bool curTouches = TeTouches(cellSet1[index], cellSet2[index2]);
+						if(touch && !curTouches)
+						{
+							//verifies if the current polygons are disjoint
+							if(!TeDisjoint(cellSet1[index], cellSet2[index2]))
+							{
+								touch = false;
+								index = cellSet1.size();
+								break;
+							}
+						}
+						touch = curTouches;
+					}
+				}
+			}
+
+			if(touch)
+			{
+				if (!imp->isConnected (object_id1,object_id2))
+				{
+					TeProxMatrixAttributes attr;
+
+					if(params_.calculate_distance_)
+					{
+						TeCoord2D p1 = (*itobj1).getCentroid();
+						TeCoord2D p2 = result[i]->getCentroid();
+						attr.CentroidDistance (TeDistance (p1, p2)); 
+					}
+					imp->connectObjects (object_id2, object_id1, attr);
+					imp->connectObjects (object_id1, object_id2, attr);
+				}
+			}
+		}
+
+		if(TeProgress::instance())
+		{
+			if (TeProgress::instance()->wasCancelled())
+			{
+				TeProgress::instance()->reset();
+				return false;
+			}
+			else
+				TeProgress::instance()->setProgress(step);
+		}	
+		++step;
+		++itobj1;
+	}
+		
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+	return true; 
+}
+
+
+TeProxMatrixLocalAdjacencyStrategy& 
+TeProxMatrixLocalAdjacencyStrategy::operator= (const TeProxMatrixLocalAdjacencyStrategy& rhs)
+{
+	if ( this != &rhs )
+	{
+		objects_ = rhs.objects_;
+		params_ = rhs.params_;
+	}
+	return *this;
+}
+
+bool 
+TeProxMatrixLocalAdjacencyStrategy::operator== (const TeProxMatrixLocalAdjacencyStrategy& rhs) const   
+{ 
+	return (TeProxMatrixConstructionStrategy<TeSTElementSet>::IsEqual(rhs)); 
+}
+	
+
+
+
+//////////////////////////////////////////////////////////////////////
+// TeProxMatrixNearestNeighbourStrategy 
+//////////////////////////////////////////////////////////////////////
+TeProxMatrixNearestNeighbourStrategy::TeProxMatrixNearestNeighbourStrategy ():
+	TeProxMatrixConstructionStrategy<TeSTEventSet> () 
+	{ }
+
+TeProxMatrixNearestNeighbourStrategy::TeProxMatrixNearestNeighbourStrategy (TeSTEventSet* objects, int num_neighbours):
+	TeProxMatrixConstructionStrategy<TeSTEventSet> (objects, TePOINTS, TeNearestNeighboursStrategy) 
+	{
+		params_.num_neighbours_=num_neighbours;
+	}
+	
+TeProxMatrixNearestNeighbourStrategy::TeProxMatrixNearestNeighbourStrategy (const TeProxMatrixNearestNeighbourStrategy& st):
+	TeProxMatrixConstructionStrategy<TeSTEventSet>(st)
+	{} 
+	
+bool 
+TeProxMatrixNearestNeighbourStrategy::Construct (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) 
+		return false;
+
+	// ----- progress bar
+	int step = 0;
+	if(TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(objects_->numSTInstance());
+	// -----
+
+	TePrecision::instance().setPrecision(TeGetPrecision(objects_->getTheme()->layer()->projection()));
+	TeSTEventSet::iterator it = objects_->begin();
+	while(it!=objects_->end())
+	{
+		TePoint p = (*it).getGeometries();
+		string object_id1=(*it).getObjectId();
+
+		vector<TeSTEvent*>  result;
+		vector<double>  dists;
+		
+		if(!objects_->nearestNeighbourSearch(p.location(), result, dists, (params_.num_neighbours_+1)))
+		{
+			++it;
+			continue;
+		}
+
+		for(unsigned int j=0; j<result.size(); ++j)
+		{
+			if(dists[j]==TeMAXFLOAT)
+				continue;
+
+			string object_id2 = result[j]->getObjectId();
+		
+			if ((object_id1 != object_id2) && (!imp->isConnected (object_id1,object_id2)))
+			{
+				TeProxMatrixAttributes attr;
+				attr.CentroidDistance (dists[j]); 
+				
+				imp->connectObjects (object_id1, object_id2, attr);
+			}
+		}
+
+
+		//------ progress bar
+		if(TeProgress::instance())
+		{
+			if (TeProgress::instance()->wasCancelled())
+			{
+				TeProgress::instance()->reset();
+				return false;
+			}
+			else
+				TeProgress::instance()->setProgress(step);
+		}	
+		++step;
+		
+		++it;
+	}
+
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+	return true; 
+}
+
+bool 
+TeProxMatrixNearestNeighbourStrategy::operator== (const TeProxMatrixNearestNeighbourStrategy& s) const
+{
+	return (TeProxMatrixConstructionStrategy<TeSTEventSet>::IsEqual(s)); 
+}
+		
+TeProxMatrixNearestNeighbourStrategy& 
+TeProxMatrixNearestNeighbourStrategy::operator= (const TeProxMatrixNearestNeighbourStrategy& rhs)
+{
+	if ( this != &rhs )
+	{
+		objects_ = rhs.objects_;
+		params_ = rhs.params_;
+	}
+	return *this;
+}
+
+//////////////////////////////////////////////////////////////////////
+// TeProxMatrixClosedNetworkStrategy 
+//////////////////////////////////////////////////////////////////////
+
+TeProxMatrixClosedNetworkStrategy::TeProxMatrixClosedNetworkStrategy (TeSTElementSet*  objects,
+										TeGeomRep rep, double max_local_distance,
+										double max_net_distance, double  max_connection_distance, 
+										TeGraphNetwork* input_net) : 	
+	TeProxMatrixConstructionStrategy<TeSTElementSet>(objects, rep, TeClosedNetworkStrategy),
+	net_ (input_net) 
+	{
+		params_.max_distance_= max_local_distance; 
+		params_.max_net_distance_ = max_net_distance; 
+		params_.max_connection_distance_= max_connection_distance; 
+	}
+
+
+
+TeProxMatrixClosedNetworkStrategy::TeProxMatrixClosedNetworkStrategy (const TeProxMatrixClosedNetworkStrategy& rhs) :
+	TeProxMatrixConstructionStrategy<TeSTElementSet>(rhs)
+{
+		TeGraphNetwork* n = new TeGraphNetwork();
+		*n = *rhs.net_; 
+		net_ = n;
+}
+
+	  
+bool 
+TeProxMatrixClosedNetworkStrategy::Construct (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) return false;
+
+	// Connect local neighbours, based on the Local Distance Strategy
+
+	TeProxMatrixLocalDistanceStrategy<TeSTElementSet> local(objects_, params_.geom_rep1_, params_.max_distance_);
+	local.Construct (imp);
+
+	// Connect neighbours through the network. The process is the following:
+	// 1. The nearest node (entry points) in the network for all the input geometries
+	//    are computed;
+	// 2. If the distance from the geometry centroid to the entry point is smaller than the maximum allowed, 
+	//    create a new node in the network corresponding to this entry point.
+	// 3. Compute the minimum path among all these new nodes (entry points).
+	// 4. For each pair of entry points, if the minimum path distance is smaller than the
+	//    maximum allowed, the corresponding geometries will be connected.
+
+	if (net_ == 0) return false;
+
+	map<string, string> entry_geom_map; // maps input geometries to network entry points
+	TeNodeSet entry_set; // entry points
+
+	// ----- progress bar
+	int step = 0;
+	if(TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(objects_->numSTInstance());
+	// -----
+
+	// Iterate over all objects and select the ones that are close enough to the network
+	TeSTElementSet::iterator itobj1 = objects_->begin();
+	while ( itobj1 != objects_->end())
+	{
+		// Get object1 id and representation
+		string object_id1 = (*itobj1).getObjectId(); 
+		TeCoord2D p1, p2; 
+			
+
+		int i = 0;
+		double min_distance = 0.;
+	
+		net_->nearestNodePoint (p1, i, p2, min_distance);
+				
+		TeNode node;
+		if ((min_distance <= params_.max_net_distance_) && net_->getNode(i, node))
+		{
+			entry_geom_map[node.objectId()] = object_id1; // Associates geometry with closest net nodes
+			entry_set.add (node);  // This set will be used as initial points in the shortest path algorithm
+		}
+
+		if(TeProgress::instance())
+		{
+			if (TeProgress::instance()->wasCancelled())
+			{
+				TeProgress::instance()->reset();
+				return false;
+			}
+			else
+				TeProgress::instance()->setProgress(step);
+		}
+		++step;
+		++itobj1;
+	}
+
+	TeSelectEntryPoints (entry_set, entry_geom_map, net_, params_.max_connection_distance_, objects_, params_.geom_rep1_, imp);
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+		
+	return true;
+}
+
+
+bool 
+TeProxMatrixClosedNetworkStrategy::IsEqual (const TeProxMatrixConstructionStrategy<TeSTElementSet>& other) const
+{
+	return (*this == (TeProxMatrixClosedNetworkStrategy&) other); 
+}
+	
+TeProxMatrixClosedNetworkStrategy& 
+TeProxMatrixClosedNetworkStrategy::operator= (const TeProxMatrixClosedNetworkStrategy& rhs)
+{
+	if (!(this==&rhs))
+	{
+		objects_ = rhs.objects_;
+		params_ = rhs.params_;
+			
+		TeGraphNetwork* n = new TeGraphNetwork(); 
+		*n = *rhs.net_; 
+		net_ = n;       
+	}
+	return (*this);
+}
+
+	
+bool 
+TeProxMatrixClosedNetworkStrategy::operator== (const TeProxMatrixClosedNetworkStrategy& other) const 
+{
+	return (TeProxMatrixConstructionStrategy<TeSTElementSet>::IsEqual(other));
+}
+	   
+//////////////////////////////////////////////////////////////////////
+// TeProxMatrixOpenNetworkStrategy 
+//////////////////////////////////////////////////////////////////////
+
+TeProxMatrixOpenNetworkStrategy::TeProxMatrixOpenNetworkStrategy (TeSTElementSet*  objects, TeGeomRep rep, 
+										double max_local_distance, 
+										double	max_net_distance, double  max_connetion_distance, 
+										TeGraphNetwork* input_net) : 	
+	TeProxMatrixConstructionStrategy<TeSTElementSet>(objects, rep, TeOpenNetworkStrategy),
+	net_ (input_net)
+	{
+		params_.max_distance_= max_local_distance; 
+		params_.max_net_distance_ = max_net_distance; 
+		params_.max_connection_distance_= max_connetion_distance; 
+	}
+
+
+TeProxMatrixOpenNetworkStrategy::TeProxMatrixOpenNetworkStrategy (const TeProxMatrixOpenNetworkStrategy& rhs): 
+	TeProxMatrixConstructionStrategy<TeSTElementSet>(rhs)
+{
+	TeGraphNetwork* n = new TeGraphNetwork();
+	*n = *rhs.net_; 
+	net_ = n;
+}
+
+bool 
+TeProxMatrixOpenNetworkStrategy::Construct (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) 
+		return false;
+
+	// Connect local neighbours, based on the Local Distance Strategy
+	if (params_.max_distance_ > 0)
+	{
+		TeProxMatrixLocalDistanceStrategy<TeSTElementSet> local(objects_, params_.geom_rep1_, params_.max_distance_);
+		local.Construct (imp);
+	}
+
+	// Connect neighbours through the network. The process is the following:
+	// 1. The nearest point (entry points) in the network for all the input geometries
+	//    are computed;
+	// 2. If the distance from the geometry centroid to the entry point is smaller than the maximum allowed, 
+	//    create a new node in the network corresponding to this entry point.
+	// 3. Compute the minimum path among all these new nodes (entry points).
+	// 4. For each pair of entry points, if the minimum path distance is smaller than the
+	//    maximum allowed, the corresponding geometries will be connected.
+	if (net_ == 0) 
+		return false;
+
+	map<string, string> entry_geom_map; // maps input geometries to network entry points
+	TeNodeSet entry_set; // entry points
+
+	// Iterate over all objects and select the ones that are close enough to the network
+	TeSTElementSet::iterator itobj1 = objects_->begin();
+	int id = 0;  // Nodes to be created will have sequential object_ids. 
+				 // The existing network nodes have object_id equal to their position
+	while ( itobj1 != objects_->end())
+
+	{
+		// Get object1 id and representation
+		string object_id1 = (*itobj1).getObjectId();
+		cout << object_id1 << "id " << id << endl;
+
+		TeCoord2D p1; 
+		if (!TeFindObjectCentroid (itobj1->getGeometries(), params_.geom_rep1_, p1))
+			return false;
+
+
+		int line_index;
+		TeCoord2D pinter;
+		double min_dist;
+
+		if (net_->nearestNetworkPoint (p1, line_index, pinter, min_dist))
+		{
+			if (min_dist < params_.max_net_distance_)
+			{
+				TeNode new_node;
+				new_node.add (pinter);
+				new_node.objectId (Te2String (id));
+				id++;
+
+				net_->breakLineSet (new_node, line_index);
+				entry_geom_map[new_node.objectId()] = object_id1; // Associates geometry with closest net nodes
+				entry_set.add (new_node);  // This set will be used as initial points in the shortest path algorithm
+			}
+		}
+		++itobj1;
+	}
+
+    TeLineSet lineSet = net_->getLineSet();
+    map<string, double> lineCosts =  net_->getLineCosts();
+	TeGraphNetwork net(lineSet, lineCosts);
+	TeSelectEntryPoints (entry_set, entry_geom_map, &net, params_.max_connection_distance_, objects_, params_.geom_rep1_, imp);
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+	return true;
+}
+
+
+bool 
+TeProxMatrixOpenNetworkStrategy::IsEqual (const TeProxMatrixConstructionStrategy<TeSTElementSet>& other) const
+{
+	return ((*this)==(TeProxMatrixOpenNetworkStrategy&)other); 
+}
+
+bool 
+TeProxMatrixOpenNetworkStrategy::operator== (const TeProxMatrixOpenNetworkStrategy& other) const 
+{
+	return (TeProxMatrixConstructionStrategy<TeSTElementSet>::IsEqual(other));
+}
+
+
+TeProxMatrixOpenNetworkStrategy& 
+TeProxMatrixOpenNetworkStrategy::operator= (const TeProxMatrixOpenNetworkStrategy& rhs)
+{
+	if (!(this==&rhs))
+	{
+		params_ = rhs.params_;
+		objects_ = rhs.objects_;
+		
+		TeGraphNetwork* n = new TeGraphNetwork(); 
+		*n = *rhs.net_;                           
+		net_ = n;								
+	}
+	return (*this);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+// TeProxMatrixOpenNetworkStrategy2 
+//////////////////////////////////////////////////////////////////////
+
+TeProxMatrixOpenNetworkStrategy2::TeProxMatrixOpenNetworkStrategy2 (TeSTElementSet*  objects1, 
+										TeGeomRep rep1,
+										TeSTElementSet*  objects2, TeGeomRep rep2,
+										double max_local_distance, 
+										double	max_net_distance, double  max_connetion_distance, 
+										TeGraphNetwork* input_net) : 	
+	TeProxMatrixConstructionStrategy<TeSTElementSet>(objects1, rep1, TeOpenNetworkStrategy2),
+	objects2_ (objects2),
+	net_ (input_net)
+	{
+		if(objects2_->theme())
+			params_.theme_id2_=objects2_->theme()->id();
+		params_.geom_rep2_=rep2;
+		params_.max_distance_= max_local_distance; 
+		params_.max_net_distance_ = max_net_distance; 
+		params_.max_connection_distance_= max_connetion_distance; 
+	}  
+
+TeProxMatrixOpenNetworkStrategy2::TeProxMatrixOpenNetworkStrategy2 (const TeProxMatrixOpenNetworkStrategy2& rhs)
+                    : TeProxMatrixConstructionStrategy<TeSTElementSet>(rhs)
+{
+	objects2_ = rhs.objects2_;
+	params_ = rhs.params_;
+	
+	TeGraphNetwork* n = new TeGraphNetwork();
+	*n = *rhs.net_; 
+	net_ = n;
+}
+
+
+bool 
+TeProxMatrixOpenNetworkStrategy2:: Construct (TeProxMatrixImplementation* imp)
+	{
+		if (imp == 0) 
+			return false;
+
+
+		// Connect neighbours through the network. The process is the following:
+		// 1. The nearest point (entry points) in the network for all the input geometries
+		//    are computed;
+		// 2. If the distance from the geometry centroid to the entry point is smaller than the maximum allowed, 
+		//    create a new node in the network corresponding to this entry point.
+		// 3. Compute the minimum path among all these new nodes (entry points).
+		// 4. For each pair of entry points, if the minimum path distance is smaller than the
+		//    maximum allowed, the corresponding geometries will be connected.
+		if (net_ == 0) 
+			return false;
+
+		map<string, string> entry_geom_map; // maps input geometries to network entry points
+
+	
+		int id = 0;  // Nodes to be created will have sequential object_ids. 
+					 // The existing network nodes have object_id equal to their position
+		// Iterate over all objects and select the ones that are close enough to the network
+
+		TeNodeSet entry_set1; // entry points
+		TeSTElementSet::iterator itobj1 = objects_->begin();	
+		while ( itobj1 != objects_->end())
+		{
+			// Get object1 id and representation
+			string object_id1 = (*itobj1).getObjectId();
+					cout << "object1 " << object_id1 << "id" << id << endl;
+
+			TeCoord2D p1; 
+			if (!TeFindObjectCentroid (itobj1->getGeometries(), params_.geom_rep1_, p1))
+				return false;
+		
+
+			int line_index;
+			TeCoord2D pinter;
+			double min_dist;
+
+			if (net_->nearestNetworkPoint (p1, line_index, pinter, min_dist))
+			{
+				if (min_dist < params_.max_net_distance_)
+				{
+					TeNode new_node;
+					new_node.add (pinter);
+					new_node.objectId (Te2String (id));
+					id++;
+
+					net_->breakLineSet (new_node, line_index);
+					entry_geom_map[new_node.objectId()] = object_id1; // Associates geometry with closest net nodes
+					entry_set1.add (new_node);  // This set will be used as initial points in the shortest path algorithm
+				}
+			}
+			++itobj1;
+		}
+
+
+	// Iterate over all objects of interst (objects2) 
+		TeNodeSet entry_set2; // entry points
+		TeSTElementSet::iterator itobj2 = objects2_->begin();		
+		while ( itobj2 != objects2_->end())
+		{
+			// Get object1 id and representation
+			string object_id2 = (*itobj2).getObjectId();
+					cout << "object2 " << object_id2 << "id" << id << endl;
+
+			TeCoord2D p2; 
+			if (!TeFindObjectCentroid (itobj1->getGeometries(), params_.geom_rep2_, p2))
+				return false;
+		
+			int line_index;
+			TeCoord2D pinter;
+			double min_dist;
+
+			if (net_->nearestNetworkPoint (p2, line_index, pinter, min_dist))
+			{ 
+				TeNode new_node;
+				new_node.add (pinter);
+				new_node.objectId (Te2String (id));
+				id++;
+
+				net_->breakLineSet (new_node, line_index);
+				entry_geom_map[new_node.objectId()] = object_id2; // Associates geometry with closest net nodes
+				entry_set2.add (new_node);  // This set will be used as initial points in the shortest path algorithm
+			}
+			++itobj2;
+		}
+
+        TeLineSet lineSet = net_->getLineSet();
+        map<string, double> lineCosts = net_->getLineCosts();
+		TeGraphNetwork net(lineSet, lineCosts);
+		TeSelectEntryPoints2 (entry_set1, entry_set2, entry_geom_map, &net, params_.max_connection_distance_, 
+			objects_, params_.geom_rep1_, objects2_, params_.geom_rep2_, imp);
+			return true;
+	}
+
+bool 
+TeProxMatrixOpenNetworkStrategy2::IsEqual (const TeProxMatrixConstructionStrategy<TeSTElementSet>& other) const
+{
+	return ((*this)==(TeProxMatrixOpenNetworkStrategy2&)other); 
+}
+
+bool 
+TeProxMatrixOpenNetworkStrategy2:: operator== (const TeProxMatrixOpenNetworkStrategy2& other) const 
+{
+	return (TeProxMatrixConstructionStrategy<TeSTElementSet>::IsEqual(other));
+}
+
+TeProxMatrixOpenNetworkStrategy2& 
+TeProxMatrixOpenNetworkStrategy2:: operator= (const TeProxMatrixOpenNetworkStrategy2& rhs)
+{
+		if (!(this==&rhs))
+		{
+			params_ = rhs.params_;
+			objects_ = rhs.objects_;
+			objects2_ = rhs.objects2_;
+		
+			TeGraphNetwork* n = new TeGraphNetwork(); 
+			*n = *rhs.net_;  
+			net_ = n;       
+		}
+		return (*this);
+}
+
+
diff --git a/src/terralib/kernel/TeProxMatrixConstructionStrategy.h b/src/terralib/kernel/TeProxMatrixConstructionStrategy.h
new file mode 100644
index 0000000..d24cc47
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixConstructionStrategy.h
@@ -0,0 +1,491 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeProxMatrixConstructionStrategy.h
+    \brief This file contains structures and definitions about construction strategies of proximity matrix 
+*/
+
+#ifndef TeProxMatrixConstructionStrategy_H
+#define TeProxMatrixConstructionStrategy_H
+
+#include "TeProxMatrixImplementation.h"
+#include "TeSTElementSet.h"
+#include "TeNetwork.h"
+#include "TeDatabase.h"
+#include "TeMultiGeometry.h"
+
+
+class TeSTEventSet;
+
+TL_DLL bool TeFindObjectCentroid (TeMultiGeometry& mGeom, TeGeomRep rep, TeCoord2D& p);
+
+struct TL_DLL TeProxMatrixConstructionParams
+{
+public:
+
+	//construction parameters
+	int						theme_id1_;
+	TeGeomRep				geom_rep1_;
+	int						theme_id2_;
+	TeGeomRep				geom_rep2_;
+	TeGPMConstructionStrategy		strategy_;
+	double						max_distance_;
+	int							num_neighbours_;
+	double						max_net_distance_;
+	double						max_connection_distance_;
+	bool						calculate_distance_;
+
+	//! Empty contructor 
+	TeProxMatrixConstructionParams():
+		theme_id1_(-1),  
+		geom_rep1_(TeGEOMETRYNONE), 
+		theme_id2_(-1), 
+		geom_rep2_(TeGEOMETRYNONE), 
+		strategy_(TeAdjacencyStrategy), 
+		max_distance_(0.), 
+		num_neighbours_(0), 
+		max_net_distance_(0.),
+		max_connection_distance_(0.), 
+		calculate_distance_(false)
+	{ }
+	
+	//! Constructor
+	TeProxMatrixConstructionParams(const int& theme1, const TeGeomRep& geomRep1, const TeGPMConstructionStrategy& strType):
+		theme_id1_(theme1), 
+		geom_rep1_(geomRep1), 
+		theme_id2_(-1), 
+		geom_rep2_(TeGEOMETRYNONE), 
+		strategy_(strType),
+		max_distance_(0.), 
+		num_neighbours_(0),
+		max_net_distance_(0.),
+		max_connection_distance_(0.), 
+		calculate_distance_(false)
+	{ }
+			
+	//! Operator ==
+	bool operator==(const TeProxMatrixConstructionParams& other) const
+	{
+		return(	(theme_id1_==other.theme_id1_) && (geom_rep1_==other.geom_rep1_) &&
+				(theme_id2_==other.theme_id2_) && (geom_rep2_==other.geom_rep2_) &&
+				(strategy_==other.strategy_) && (max_distance_==other.max_distance_) &&
+				(num_neighbours_==other.num_neighbours_) && (max_net_distance_==other.max_net_distance_) && 
+				(max_connection_distance_==other.max_connection_distance_) &&
+				(calculate_distance_==other.calculate_distance_));
+	}
+};
+
+//! A templated class to representate construction strategies of proximity matrix
+template<typename T>
+class TeProxMatrixConstructionStrategy 
+{
+protected:
+	//! Set of objetcs used to construct the matrix
+	T*   objects_;
+
+	//! Construction paramas
+	TeProxMatrixConstructionParams  params_;
+
+	//! Construct
+	TeProxMatrixConstructionStrategy(); 
+
+	//! Construct
+	TeProxMatrixConstructionStrategy(T* objects, TeGeomRep geomRep, const TeGPMConstructionStrategy& type=TeAdjacencyStrategy);
+
+	//! Copy construct
+	TeProxMatrixConstructionStrategy(const TeProxMatrixConstructionStrategy& st);
+
+public:
+	//! Construct the proximity matrix 
+	virtual bool Construct(TeProxMatrixImplementation*)=0;
+
+	//! Destructor
+	virtual ~TeProxMatrixConstructionStrategy() 
+	{}
+
+	//! Set the set of objects and its geometry representation
+	void setSTObjects (T*  objects, TeGeomRep  geomRep); 
+	
+	//! Get the objects used to construct the matrix
+	T* objects()  { return objects_; } 
+
+	//! Returns the construction params
+	TeProxMatrixConstructionParams& constructionParams() { return params_; }
+	
+	//! Verify if the type of the strategy, the object set and its geometry representation are equal
+	virtual bool IsEqual (const TeProxMatrixConstructionStrategy<T>& other) const;  
+};
+
+template<typename T> 
+TeProxMatrixConstructionStrategy<T>::TeProxMatrixConstructionStrategy() : 
+	objects_(0), 
+	params_(-1, TeGEOMETRYNONE, TeAdjacencyStrategy)
+	{ } 
+
+template<typename T> 
+TeProxMatrixConstructionStrategy<T>::TeProxMatrixConstructionStrategy(T*  objects, TeGeomRep geomRep, const TeGPMConstructionStrategy& type) :
+	objects_(objects)
+	{
+		if(objects->theme())
+			params_.theme_id1_ = objects->theme()->id();
+		params_.geom_rep1_ = geomRep;
+		params_.strategy_ = type;
+	} 
+
+template<typename T> 
+TeProxMatrixConstructionStrategy<T>::TeProxMatrixConstructionStrategy (const TeProxMatrixConstructionStrategy& st)
+{
+	objects_ = st.objects_; 
+	params_ = st.params_;
+}
+
+template<typename T> void 
+TeProxMatrixConstructionStrategy<T>::setSTObjects (T*  objects, TeGeomRep  geomRep)
+{	
+	objects_ = objects; 
+	if(objects->theme())
+		params_.theme_id1_ = objects->theme()->id();
+	params_.geom_rep1_ = geomRep; 
+}
+
+template<typename T> bool 
+TeProxMatrixConstructionStrategy<T>::IsEqual (const TeProxMatrixConstructionStrategy<T>& other) const
+{
+	return ((params_==other.params_) && 
+		((&objects_)==(&other.objects_))); 
+}
+
+
+//! A class to implement the local adjacency strategy of proximity matrix
+class TL_DLL TeProxMatrixLocalAdjacencyStrategy : public  TeProxMatrixConstructionStrategy<TeSTElementSet>
+{
+public:
+
+	//! Constructor
+	TeProxMatrixLocalAdjacencyStrategy (); 
+
+	//! Constructor
+	TeProxMatrixLocalAdjacencyStrategy (TeSTElementSet*  objects, TeGeomRep	geomRep, bool calcDistance=false);
+	
+	//! Copy constructor
+	TeProxMatrixLocalAdjacencyStrategy (TeProxMatrixLocalAdjacencyStrategy& st);  
+	 
+	 //! Destructor
+	virtual ~TeProxMatrixLocalAdjacencyStrategy() {}
+	
+	//! Construct the proximity matrix through local adjacency strategy 
+	virtual bool Construct (TeProxMatrixImplementation* imp);
+		
+	//! Equal operator 
+	bool operator== (const TeProxMatrixLocalAdjacencyStrategy& rhs) const;  
+	
+	//! Assignment operator 
+	TeProxMatrixLocalAdjacencyStrategy& operator= (const TeProxMatrixLocalAdjacencyStrategy& rhs); 
+
+};
+
+
+//! A class to implement the local distance strategy of proximity matrix
+template<typename Set>
+class TeProxMatrixLocalDistanceStrategy : public TeProxMatrixConstructionStrategy<Set>
+{
+public:
+
+	//! Constructor
+	TeProxMatrixLocalDistanceStrategy ();
+	
+	//! Constructor
+	TeProxMatrixLocalDistanceStrategy (Set*  objects, TeGeomRep geomRep, double max_distance); 
+	
+	//! Copy constructor
+	TeProxMatrixLocalDistanceStrategy (const TeProxMatrixLocalDistanceStrategy<Set>& st); 
+	
+	//! Destructor
+	virtual ~TeProxMatrixLocalDistanceStrategy(){}
+	
+	//! Construct the proximity matrix through local distance strategy 
+	virtual bool Construct (TeProxMatrixImplementation* imp); 
+
+	//! Equal operator 
+	bool operator== (const TeProxMatrixLocalDistanceStrategy<Set>& s) const; 
+		
+	//! Assignment operator
+	TeProxMatrixLocalDistanceStrategy<Set>& operator= (const TeProxMatrixLocalDistanceStrategy<Set>& rhs);
+
+};
+
+
+//! A class to implement the nearest neighbour strategy of proximity matrix
+class TL_DLL TeProxMatrixNearestNeighbourStrategy : public  TeProxMatrixConstructionStrategy<TeSTEventSet>
+{
+public:
+	//! Empty constructor
+	TeProxMatrixNearestNeighbourStrategy ();
+
+	//! Constructor
+	// The STEventSet must be created with geometries, using kdTree and ordered by object_id
+	TeProxMatrixNearestNeighbourStrategy (TeSTEventSet* objects, int num_neighbours);
+	
+	//! Copy constructor
+	TeProxMatrixNearestNeighbourStrategy (const TeProxMatrixNearestNeighbourStrategy& st); 
+	
+	//! Destructor
+	virtual ~TeProxMatrixNearestNeighbourStrategy(){}
+	
+	//! Construct the proximity matrix through local distance strategy 
+	virtual bool Construct (TeProxMatrixImplementation* imp); 
+
+	//! Equal operator 
+	bool operator== (const TeProxMatrixNearestNeighbourStrategy& s) const; 
+		
+	//! Assignment operator
+	TeProxMatrixNearestNeighbourStrategy& operator= (const TeProxMatrixNearestNeighbourStrategy& rhs);
+
+};
+
+
+//! A class to implement the closed network strategy of proximity matrix
+class TL_DLL TeProxMatrixClosedNetworkStrategy : public TeProxMatrixConstructionStrategy<TeSTElementSet>
+{
+private:
+	TeGraphNetwork*		net_;
+ 
+public:
+	//! Constructor
+	TeProxMatrixClosedNetworkStrategy (	TeSTElementSet*  objects, TeGeomRep rep, double max_local_distance,
+										double max_net_distance, double  max_connection_distance, 
+										TeGraphNetwork* input_net); 
+
+	//! Copy constructor
+	TeProxMatrixClosedNetworkStrategy (const TeProxMatrixClosedNetworkStrategy& rhs);
+		  
+	//! Destructor
+	virtual ~TeProxMatrixClosedNetworkStrategy()
+	{	
+		if(net_)
+			delete (net_); 
+	}
+
+	//! Construct the proximity matrix through closed network strategy 
+	virtual bool Construct (TeProxMatrixImplementation* imp); 
+	
+	//! Verify if is equal
+	virtual bool IsEqual (const TeProxMatrixConstructionStrategy<TeSTElementSet>& other) const; 
+	
+	//! Assignment operator
+	TeProxMatrixClosedNetworkStrategy& operator= (const TeProxMatrixClosedNetworkStrategy& rhs);
+
+	//! Equal operator
+	bool operator== (const TeProxMatrixClosedNetworkStrategy& other) const;  
+
+	//! Get the objects used to construct the matrix
+	TeSTElementSet* objects() { return objects_; }
+};
+
+//! A class to implement the open network strategy of proximity matrix (among a set of objetcs)
+class TL_DLL TeProxMatrixOpenNetworkStrategy : public TeProxMatrixConstructionStrategy<TeSTElementSet>
+{
+private:
+	TeGraphNetwork*		net_;
+
+public:
+
+	//! Constructor
+	TeProxMatrixOpenNetworkStrategy (	TeSTElementSet*  objects, TeGeomRep rep, double max_local_distance, 
+										double	max_net_distance, double  max_connetion_distance, 
+										TeGraphNetwork* input_net); 
+	//! Copy constructor
+	TeProxMatrixOpenNetworkStrategy (const TeProxMatrixOpenNetworkStrategy& rhs); 
+	
+	//! Destructor
+	virtual ~TeProxMatrixOpenNetworkStrategy()
+	{
+		if(net_)
+			delete (net_); 
+	}
+
+	//! Construct the proximity matrix through open network strategy
+	virtual bool Construct (TeProxMatrixImplementation* imp); 
+
+	//! Verify if is equal
+	virtual bool IsEqual (const TeProxMatrixConstructionStrategy<TeSTElementSet>& other) const; 
+
+	//! Equal operator
+	bool operator== (const TeProxMatrixOpenNetworkStrategy& other) const; 
+	
+	//! Assignment operator
+	TeProxMatrixOpenNetworkStrategy& operator= (const TeProxMatrixOpenNetworkStrategy& rhs);
+};
+
+
+//! A class to implement the open network strategy of proximity matrix (relationships among objetc of two differnt sets)
+class TL_DLL TeProxMatrixOpenNetworkStrategy2 : public TeProxMatrixConstructionStrategy<TeSTElementSet>
+{
+private:
+	TeSTElementSet*		objects2_;
+	TeGraphNetwork*		net_;
+public:
+
+	//! Constructor
+	TeProxMatrixOpenNetworkStrategy2 (	TeSTElementSet*  objects1, TeGeomRep rep1,
+										TeSTElementSet*  objects2, TeGeomRep rep2,
+										double max_local_distance, 
+										double	max_net_distance, double  max_connetion_distance, 
+										TeGraphNetwork* input_net); 
+	//! Copy constructor
+	TeProxMatrixOpenNetworkStrategy2 (const TeProxMatrixOpenNetworkStrategy2& rhs); 
+	
+	//! Destructor
+	virtual ~TeProxMatrixOpenNetworkStrategy2 ()
+	{
+		if(net_)
+			delete (net_); 
+	}
+
+	//! Construct the proximity matrix through open network strategy
+	virtual bool Construct (TeProxMatrixImplementation* imp); 
+
+	//! Verify if is equal
+	virtual bool IsEqual (const TeProxMatrixConstructionStrategy<TeSTElementSet>& other) const; 
+
+	//! Equal operator
+	bool operator== (const TeProxMatrixOpenNetworkStrategy2& other) const; 
+	
+	//! Assignment operator
+	TeProxMatrixOpenNetworkStrategy2& operator= (const TeProxMatrixOpenNetworkStrategy2& rhs);
+
+};
+
+//////////////////////////////////////////////////////////////////////
+// TeProxMatrixLocalDistanceStrategy 
+//////////////////////////////////////////////////////////////////////
+template<typename Set> 
+TeProxMatrixLocalDistanceStrategy<Set>::TeProxMatrixLocalDistanceStrategy ():
+		TeProxMatrixConstructionStrategy<Set> (0, TeGEOMETRYNONE, TeDistanceStrategy) 
+		{}
+
+
+template<typename Set> 
+TeProxMatrixLocalDistanceStrategy<Set>::TeProxMatrixLocalDistanceStrategy (Set*  objects, TeGeomRep geomRep, double max_distance): 
+		TeProxMatrixConstructionStrategy<Set>(objects, geomRep, TeDistanceStrategy)
+		{
+			TeProxMatrixConstructionStrategy<Set>::params_.max_distance_ = max_distance; 
+		}
+
+	
+template<typename Set> 
+TeProxMatrixLocalDistanceStrategy<Set>::TeProxMatrixLocalDistanceStrategy (const TeProxMatrixLocalDistanceStrategy<Set>& st): 
+		TeProxMatrixConstructionStrategy<Set>(st)
+		{} 
+
+template<typename Set> bool 
+TeProxMatrixLocalDistanceStrategy<Set>::Construct(TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) 
+		return false;
+	
+	// Iterate over all selected objects, selecting their neighbours
+	TeSTElementSet::iterator itobj1 = TeProxMatrixConstructionStrategy<Set>::objects_->begin();
+	
+	// ----- progress bar
+	int step = 0;
+	if(TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(TeProxMatrixConstructionStrategy<Set>::objects_->numSTInstance());
+	// -----
+
+	TeProjection* proj = 0;
+	if(TeProxMatrixConstructionStrategy<Set>::objects_->theme())
+		proj = TeProxMatrixConstructionStrategy<Set>::objects_->theme()->layer()->projection();
+	else if(TeProxMatrixConstructionStrategy<Set>::objects_->getLayer())
+		proj = TeProxMatrixConstructionStrategy<Set>::objects_->getLayer()->projection();
+
+	TePrecision::instance().setPrecision(TeGetPrecision(proj));
+	double max_d = TeProxMatrixConstructionStrategy<Set>::params_.max_distance_;
+		
+	while ( itobj1 != TeProxMatrixConstructionStrategy<Set>::objects_->end())
+	{
+		// Gets the possible objects from RTree in the element set
+		vector<TeSTInstance*> result;
+		TeBox b = (*itobj1).getGeometries().getBox();
+		TeBox bAux(b.x1()-max_d, b.y1()-max_d, b.x2()+max_d, b.y2()+max_d);
+		
+		TeProxMatrixConstructionStrategy<Set>::objects_->search(bAux, result);
+
+		string object_id1 = (*itobj1).getObjectId();
+		TeCoord2D coord1 = itobj1->getCentroid();
+		for(unsigned int index =0; index<result.size(); ++index)
+		{
+			string object_id2 = result[index]->getObjectId();
+			if(object_id1==object_id2)
+				continue;
+			
+			TeCoord2D coord2 = result[index]->getCentroid();
+			double dist = TeDistance(coord1, coord2);
+			if(dist <= max_d)
+			{
+				if(!imp->isConnected (object_id1,object_id2))
+				{
+					TeProxMatrixAttributes attr;
+					attr.CentroidDistance (dist);
+					imp->connectObjects (object_id1, object_id2, attr);
+					imp->connectObjects (object_id2, object_id1, attr);
+				}
+			}
+		}
+
+		if(TeProgress::instance())
+		{
+			if (TeProgress::instance()->wasCancelled())
+			{
+				TeProgress::instance()->reset();
+				return false;
+			}
+			else
+				TeProgress::instance()->setProgress(step);
+		}	
+		++step;
+		++itobj1;
+	}
+	
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+	return true;
+}
+
+template<typename Set> bool 
+TeProxMatrixLocalDistanceStrategy<Set>::operator== (const TeProxMatrixLocalDistanceStrategy<Set>& s) const 
+{
+	return ( TeProxMatrixConstructionStrategy<Set>::IsEqual(s)); 
+}
+	
+template<typename Set> TeProxMatrixLocalDistanceStrategy<Set>& 
+TeProxMatrixLocalDistanceStrategy<Set>::operator= (const TeProxMatrixLocalDistanceStrategy<Set>& rhs)
+{
+	if ( this != &rhs )
+	{
+		TeProxMatrixConstructionStrategy<Set>::objects_ = rhs.objects_;
+		TeProxMatrixConstructionStrategy<Set>::params_ = rhs.params_;
+	}
+	return *this;
+}
+
+#endif
diff --git a/src/terralib/kernel/TeProxMatrixImplementation.cpp b/src/terralib/kernel/TeProxMatrixImplementation.cpp
new file mode 100644
index 0000000..b5a7a17
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixImplementation.cpp
@@ -0,0 +1,498 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeProxMatrixImplementation.h"
+
+#include <stdio.h>
+
+TeProxMatrixGraphBreymann:: TeProxMatrixGraphBreymann () : 
+      TeProxMatrixImplementation(TeGraphBreymann), graph_(true)
+{ }
+
+TeProxMatrixGraphBreymann:: TeProxMatrixGraphBreymann (TeProxMatrixGraphBreymann&  other) : 
+      TeProxMatrixImplementation(TeGraphBreymann), graph_(true)
+{	
+//	graph_ = other.graph_;
+	map_ = other.map_;
+}
+
+	
+TeProxMatrixGraphBreymann&
+TeProxMatrixGraphBreymann:: operator= (TeProxMatrixGraphBreymann& other)
+{
+	type_ = other.type_;
+//	graph_ = other.graph_;  
+	map_ = other.map_;
+	return (*this);
+}
+ 
+
+void 
+TeProxMatrixGraphBreymann::connectObjects (const string& object_id1, const string& object_id2, const TeProxMatrixAttributes& attr)
+{
+	int pos1 = graph_.insert (object_id1);
+	int pos2 = graph_.insert (object_id2);
+
+	graph_.connectVertices (pos1, pos2, attr);
+
+	map_[object_id1] = pos1;
+	map_[object_id2] = pos2;
+}
+
+
+bool 
+TeProxMatrixGraphBreymann::setConnectionAttributes (const string& object_id1, const string& object_id2, const TeProxMatrixAttributes& attr)
+{
+	return(graph_.setEdgeValue (object_id1, object_id2, attr));
+}
+
+bool 
+TeProxMatrixGraphBreymann::getConnectionAttributes (const string& object_id1, const string&object_id2, TeProxMatrixAttributes& attr)
+{
+	map_iterator pos1, pos2;
+
+	if ((pos1 = map_.find(object_id1)) == map_.end()) 
+		return false; // object_id1 not in the graph
+
+	if ((pos2 = map_.find(object_id2)) == map_.end()) 
+		return false; // object_id2 not in the graph
+
+	// Object_id1 neighbours iterator
+	br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+			start	= graph_[(*pos1).second].second.begin(),
+			end		= graph_[(*pos1).second].second.end();
+
+	while (start != end) 
+	{	
+		if ((*start).first == (*pos2).second) {
+				attr = (*start).second;
+				return true;
+		}
+		++start;
+	}
+	return false;		
+}
+
+bool 
+TeProxMatrixGraphBreymann::getNeighboursNeighbours (const string& object_id, TeNeighbours& neigh, int max_order )
+{
+	bool ret_value = getNeighboursNeighbours (object_id, neigh, max_order, 1);
+	neigh.Remove (object_id);
+	return ret_value;
+}
+
+bool 
+TeProxMatrixGraphBreymann::getNeighboursNeighbours (const string& object_id, TeNeighbours& neigh, int max_order, int current_order)
+{
+
+	map_iterator pos;
+
+	if ((pos = map_.find(object_id)) == map_.end()) 
+		return false; // object_id not in the graph
+
+	// Object_id1 neighbours iterator
+	br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+			start	= graph_[(*pos).second].second.begin(),
+			end		= graph_[(*pos).second].second.end();
+
+	// Insert all neighbours
+	while (start != end) 
+	{	
+		TeProxMatrixAttributes attr = (*start).second;
+		attr.Order (current_order); //Update attr attribute for that specific object
+		if (neigh.Insert (graph_[(*start).first].first, attr)) 
+		{
+				// Get neighbours of neighbours that were not inserted before
+			for (int recursive_loop = max_order - 1; recursive_loop > 0; --recursive_loop)
+				getNeighboursNeighbours (graph_[(*start).first].first, neigh, recursive_loop, ++current_order);
+	
+		}
+		++start;
+	}
+	return true;
+
+}
+
+
+bool
+TeProxMatrixGraphBreymann::getNeighbours (const string& object_id, TeNeighbours& neigh)
+{
+	map_iterator pos;
+
+	if ((pos = map_.find(object_id)) == map_.end()) 
+		return false; // object_id not in the graph
+
+	br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+			start	= graph_[(*pos).second].second.begin(),
+			end		= graph_[(*pos).second].second.end();
+
+	while (start != end) 
+	{
+		neigh.Insert (graph_[(*start).first].first, (*start).second);
+		++start;
+	}
+
+	return true;
+	
+}
+
+bool
+TeProxMatrixGraphBreymann::getNeighbours (int i, string& object_id, TeNeighbours& neigh)
+{
+
+	if (i > (int) graph_.size())
+		return false;
+
+	// find object_id
+	map_iterator pos = map_.begin();
+	while (pos != map_.end())
+	{
+		if ((*pos).second == i)
+		{
+			object_id = (*pos).first;
+			pos = map_.end();
+		}
+		else pos++;
+	}
+
+	br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+			start	= graph_[i].second.begin(),
+			end		= graph_[i].second.end();
+
+
+	while (start != end) 
+	{
+		neigh.Insert (graph_[(*start).first].first, (*start).second);
+		start++;
+	}
+
+	return true;
+	
+}
+
+
+
+TeProxMatrixImplementation* 
+TeProxMatrixGraphBreymann::createCopy ()
+{
+	TeProxMatrixGraphBreymann* imp = new TeProxMatrixGraphBreymann (*this);
+	return imp;
+
+}
+
+
+bool
+TeProxMatrixGraphBreymann::saveTextFile (const string& name, map<string, string>* ids)
+{
+	string complete_name = name + ".txt";
+
+	FILE*	fp = fopen(complete_name.c_str(),"w");
+	if (fp)
+	{
+		fprintf (fp, "%d\n", ids->size()); //number of objects
+	
+		map<string, string>::iterator it;
+		for (unsigned int i = 0; i < graph_.size(); i++)
+		{
+
+			string objId1, objId2;
+			objId1 = graph_[i].first;
+			if(ids)
+			{
+				it=ids->find(graph_[i].first);
+				if(it!=ids->end())
+					objId1 = it->second;
+			}
+						
+			fprintf (fp, " %s ", objId1.c_str());
+			
+			br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+				start	= graph_[i].second.begin(),
+				end		= graph_[i].second.end();
+			//double sum = 0.0;
+			while (start != end) 
+			{
+				objId2 = graph_[(*start).first].first;
+				if(ids)
+				{
+					it=ids->find(objId2);
+					if(it!=ids->end())
+						objId2 = it->second;
+				}
+				
+				fprintf (fp, " %s ", objId2.c_str());  
+				//sum += (*start).second.Weight();
+				start++;
+			}
+
+			//fprintf (fp, "Weights sum: %3.7f\n", sum);
+			fprintf (fp, "\n");
+		}
+		fclose (fp);
+		return true;
+	}
+	else 
+		return false;
+}
+
+
+bool
+TeProxMatrixGraphBreymann::saveGALFile (const string& name, map<string, string>* ids)
+{
+
+	string complete_name = name + ".GAL";
+	FILE*	fp = fopen(complete_name.c_str(),"w");
+	if (fp)
+	{
+		fprintf (fp, "%d\n", ids->size() ); // first line: number of elements in matrix
+		map<string, string>::iterator it;
+		for (unsigned int i = 0; i < graph_.size(); i++)
+		{
+			string objId1, objId2;
+			objId1 = graph_[i].first;
+			if(ids)
+			{
+				it = ids->find(objId1);
+				if(it!=ids->end())
+					objId1 = it->second;
+			}
+			
+			fprintf (fp, "%s %d\n", objId1.c_str(), graph_[i].second.size());
+			br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+				start	= graph_[i].second.begin(),
+				end		= graph_[i].second.end();
+			while (start != end) 
+			{
+				//fprintf (fp, "%s   %3.7f\n", graph_[(*start).first].first.c_str(), (*start).second.Weight() );
+				objId2 = graph_[(*start).first].first;
+				if(ids)
+				{
+					it=ids->find(objId2);
+					if(it!=ids->end())
+                        objId2 = it->second;
+				}				
+
+                fprintf (fp, "%s  ", objId2.c_str());
+				start++;
+			}
+			fprintf (fp, "\n");
+		}
+		fclose (fp);
+		return true;
+	}
+	else return false;
+	
+}
+
+
+bool
+TeProxMatrixGraphBreymann::saveGWTFile (const string& name, map<string, string>* ids)
+{
+
+	string complete_name = name + ".GWT";
+	FILE*	fp = fopen(complete_name.c_str(),"w");
+	if (fp)
+	{
+		fprintf (fp, "%d\n", ids->size() ); // first line: number of elements in matrix
+		map<string, string>::iterator it;
+		for (unsigned int i = 0; i < graph_.size(); i++)
+		{
+			br_stl::Graph<string, TeProxMatrixAttributes>::Successor::iterator 
+				start	= graph_[i].second.begin(),
+				end		= graph_[i].second.end();
+			while (start != end) 
+			{
+				string objId1, objId2;
+				objId1 = graph_[i].first;
+				objId2 = graph_[(*start).first].first;
+				if(ids)
+				{
+					it=ids->find(graph_[i].first);
+					if(it!=ids->end())
+						objId1 = it->second;
+					it=ids->find(graph_[(*start).first].first);
+					if(it!=ids->end())
+						objId2 = it->second;
+				}
+				fprintf (fp, "%s %s		%3.7f\n", objId1.c_str(), objId2.c_str(), (*start).second.CentroidDistance());
+				start++;
+			}
+		}
+		fclose (fp);
+		return true;
+	}
+	else 
+		return false;
+	
+}
+
+// -------- save from vector
+
+bool
+TeProxMatrixGraphBreymann::saveTextFile (const string& name, vector<string>* ids)
+{
+	string complete_name = name + ".txt";
+
+	FILE*	fp = fopen(complete_name.c_str(),"w");
+	if (fp)
+	{
+		fprintf (fp, "%d\n", ids->size()); //number of objects
+	
+		vector<string>::iterator it = ids->begin();
+		int Id=1;
+		while(it!=ids->end())
+		{
+			string objId1, objId2;
+			objId1 = Te2String(Id);
+			
+			fprintf (fp, " %s ", objId1.c_str());
+
+			TeNeighbours neigs;
+			this->getNeighbours((*it), neigs);
+
+			for(int j=0; j<neigs.size(); ++j)
+			{
+				string objId2aux = neigs[j];
+				objId2 ="";
+				for(unsigned int n=0; n<ids->size(); ++n)
+				{
+					if(objId2aux==ids->operator [](n))
+					{
+						objId2 = Te2String(n+1);
+						break;
+					}
+				}
+				fprintf (fp, " %s ", objId2.c_str());  
+			}
+
+			fprintf (fp, "\n");
+
+			++it;
+			++Id;
+		}
+
+		fclose (fp);
+		return true;
+	}
+	else 
+		return false;
+}
+
+
+bool
+TeProxMatrixGraphBreymann::saveGALFile (const string& name, vector<string>* ids)
+{
+
+	string complete_name = name + ".GAL";
+	FILE*	fp = fopen(complete_name.c_str(),"w");
+	if (fp)
+	{
+		fprintf (fp, "%d\n", ids->size() ); // first line: number of elements in matrix
+		
+		vector<string>::iterator it = ids->begin();
+		int Id=1;
+		while(it!=ids->end())
+		{
+			string objId1, objId2;
+			objId1 = Te2String(Id);
+			
+			TeNeighbours neigs;
+			this->getNeighbours((*it), neigs);
+
+			fprintf (fp, "%s %d\n", objId1.c_str(), neigs.size());
+
+			for(int j=0; j<neigs.size(); ++j)
+			{
+				string objId2aux = neigs[j];
+				objId2 ="";
+				for(unsigned int n=0; n<ids->size(); ++n)
+				{
+					if(objId2aux==ids->operator[](n))
+					{
+						objId2 = Te2String(n+1);
+						break;
+					}
+				}
+				fprintf (fp, "%s  ", objId2.c_str());  
+			}
+
+			fprintf (fp, "\n");
+
+			++it;
+			++Id;
+		}
+		
+		fclose (fp);
+		return true;
+	}
+	else 
+		return false;
+	
+}
+
+
+bool
+TeProxMatrixGraphBreymann::saveGWTFile (const string& name, vector<string>* ids)
+{
+
+	string complete_name = name + ".GWT";
+	FILE*	fp = fopen(complete_name.c_str(),"w");
+	if (fp)
+	{
+		fprintf (fp, "%d\n", ids->size() ); // first line: number of elements in matrix
+		vector<string>::iterator it = ids->begin();
+		int Id=1;
+		while(it!=ids->end())
+		{
+			string objId1, objId2;
+			objId1 = Te2String(Id);
+			
+			TeNeighbours neigs;
+			this->getNeighbours((*it), neigs);
+
+			for(int j=0; j<neigs.size(); ++j)
+			{
+				string objId2aux = neigs[j];
+				double dist = (neigs.Attributes(j)).CentroidDistance();
+				objId2 ="";
+				for(unsigned int n=0; n<ids->size(); ++n)
+				{
+					if(objId2aux==ids->operator[](n))
+					{
+						objId2 = Te2String(n+1);
+						break;
+					}
+				}
+				fprintf (fp, "%s %s		%3.7f\n", objId1.c_str(), objId2.c_str(), dist);
+			}
+			++it;
+			++Id;
+		}
+				
+		fclose (fp);
+		return true;
+	}
+	else 
+		return false;
+	
+}
diff --git a/src/terralib/kernel/TeProxMatrixImplementation.h b/src/terralib/kernel/TeProxMatrixImplementation.h
new file mode 100644
index 0000000..25088d1
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixImplementation.h
@@ -0,0 +1,215 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeProxMatrixImplementation.h
+    \brief This file contains structures and definitions about different representations of proximity matrix 
+*/
+
+#ifndef TeProxMatrixImplementation_H
+#define TeProxMatrixImplementation_H
+
+#include "TeNeighbours.h"
+#include <graph.h>
+
+//! An abstract class to represent proximity matrix   
+class TL_DLL TeProxMatrixImplementation  
+{
+protected:
+	//! Type of the representation
+	TeGPMImplementation type_;
+	
+	//! Empty constructor 
+	TeProxMatrixImplementation(const TeGPMImplementation& type): type_(type)
+		{}
+
+public:
+	//! Verify if two objects are neighbour or connected
+	bool isConnected (const string& object_id1, const string& object_id2) 
+	{
+		TeProxMatrixAttributes attr; 
+		return getConnectionAttributes (object_id1, object_id2, attr);
+	}
+
+	//! Connect two objects
+	virtual void connectObjects (const string& , const string& , const TeProxMatrixAttributes& ) = 0;
+
+	//! Disconnect two objects
+	virtual bool disconnectObjects (const string& , const string& ) { return false; }
+
+	//! Remove an object
+	virtual bool removeObject (const string& ) { return false; }
+
+	//! Get connection attributes
+	virtual bool getConnectionAttributes (const string&, const string&, TeProxMatrixAttributes& )= 0;
+
+	//! Set connection attributes
+	virtual bool setConnectionAttributes (const string&, const string&, const TeProxMatrixAttributes&) =0;
+
+	//! Get the neighbours of an object
+	virtual bool getNeighbours (const string& , TeNeighbours& )=0;
+
+	//! Get the obj-th neighbour of an object 
+	virtual bool getNeighbours (int, string& , TeNeighbours& )=0;	
+
+	//! Get the neighbours of an object
+	virtual bool getNeighboursNeighbours (const string&, TeNeighbours&, int /* max_order */ = 2)=0;
+
+	//! Return the number of objects
+	virtual int  numberOfObjects()=0;
+
+	//! Return the type of the representation 
+	TeGPMImplementation type() {return type_;}
+
+	//! Create a copy
+	virtual TeProxMatrixImplementation* createCopy ()=0;
+	
+	//! Verify if is equal
+	virtual bool isEqual (TeProxMatrixImplementation& other)
+	{
+		if (type_ == other.type_) 
+			return true; 
+		return false;
+	}
+
+	//! Equal operator
+	virtual bool operator== (const TeProxMatrixImplementation& ) const { return false; } 
+		
+	//! Save the proximity matrix in a text file
+	virtual bool saveTextFile (const string&, map<string, string>*)=0;
+
+	//! Save the proximity matrix in a GAL format text file 
+	virtual bool saveGALFile (const string&, map<string, string>*)=0;
+
+	//! Save the proximity matrix in a GWT format text file 
+	virtual bool saveGWTFile (const string&, map<string, string>*)=0;
+
+	//! Save the proximity matrix in a text file
+	virtual bool saveTextFile (const string&, vector<string>*)=0;
+
+	//! Save the proximity matrix in a GAL format text file 
+	virtual bool saveGALFile (const string&, vector<string>*)=0;
+
+	//! Save the proximity matrix in a GWT format text file 
+	virtual bool saveGWTFile (const string&, vector<string>*)=0;
+
+	//! Destructor
+	virtual ~TeProxMatrixImplementation(){}
+};
+
+
+//! A class to represent proximity matrix utilising the Breymann graph
+class TL_DLL TeProxMatrixGraphBreymann : public  TeProxMatrixImplementation
+{
+private:
+	br_stl::Graph<string, TeProxMatrixAttributes> graph_;
+
+	typedef map<string, int> Object_id_map_type;
+	Object_id_map_type  map_;
+
+	typedef Object_id_map_type::iterator map_iterator;
+	typedef Object_id_map_type::const_iterator map_const_iterator;
+
+	bool getNeighboursNeighbours (const string& object_id, TeNeighbours& neigh, int max_order = 2, int current_order = 1);
+
+public:
+	//! Empty constructor - graph must be directed then the graph constructor receive true 
+	TeProxMatrixGraphBreymann (); 
+																	 
+	//! Copy constructor
+	TeProxMatrixGraphBreymann(TeProxMatrixGraphBreymann& imp);
+
+	//! Connect two objects
+	virtual void connectObjects (const string& object_id1, const string& object_id2, const TeProxMatrixAttributes& attr);
+	
+	//! Get connection attributes 
+	virtual bool getConnectionAttributes (const string& object_id1, const string& object_id2, TeProxMatrixAttributes& attr);
+	
+	//! Set connection attributes 
+	virtual bool setConnectionAttributes (const string& object_id1, const string& object_id2, const TeProxMatrixAttributes& attr);
+
+	//! Get the neighbours of an object
+	virtual bool getNeighbours (const string& object_id, TeNeighbours& neigh);
+
+	//! Get the obj-th neighbour of an object 
+	virtual bool getNeighbours (int obj, string& object_id, TeNeighbours& neigh); 
+	
+	//! Get the neighbours of an object
+	virtual bool getNeighboursNeighbours (const string& object_id, TeNeighbours& neigh, int max_order = 2);
+
+	//! Return the number of the objects
+	virtual int  numberOfObjects () {return graph_.size();}
+
+	//! Create a copy
+	virtual TeProxMatrixImplementation* createCopy ();
+
+	//! Verify if is equal
+	virtual bool isEqual (TeProxMatrixImplementation& other) 
+	{
+		if (type_ == other.type()) 
+			return (*this == (TeProxMatrixGraphBreymann&)other); 
+		return false;
+	}
+
+	//! Assignment operator 
+	TeProxMatrixGraphBreymann& operator= (TeProxMatrixGraphBreymann& imp); 
+	
+	//! Destructor
+	virtual ~TeProxMatrixGraphBreymann() {}
+
+	//! Save the proximity matrix in a text file 
+	virtual bool saveTextFile (const string& name, map<string, string>* ids=0);
+
+	//! Save the proximity matrix in a GAL text file 
+	virtual bool saveGALFile (const string& name, map<string, string>* ids=0);
+
+	//! Save the proximity matrix in a GWT text file 
+	virtual bool saveGWTFile (const string& name, map<string, string>* ids=0);
+
+	//! Save the proximity matrix in a text file
+	virtual bool saveTextFile (const string& name, vector<string>* ids);
+
+	//! Save the proximity matrix in a GAL format text file 
+	virtual bool saveGALFile (const string& name, vector<string>* ids);
+
+	//! Save the proximity matrix in a GWT format text file 
+	virtual bool saveGWTFile (const string& name, vector<string>* ids);
+};
+
+
+//! An abstract factory of proximity matrix representations  
+class TL_DLL TeProxMatrixAbstractFactory  
+{
+public:
+	static TeProxMatrixImplementation* MakeConcreteImplementation (const TeGPMImplementation& impl_type = TeGraphBreymann)
+	{
+		if (impl_type == TeGraphBreymann) 
+				return new TeProxMatrixGraphBreymann();
+
+		return new TeProxMatrixGraphBreymann();
+	}
+	
+};
+
+/*! \example createProximityMatrix.cpp
+	This is an example of how to  how to create a proximity matrix from a  Spatial Temporal Element Set (STElementSet)
+ */
+#endif
diff --git a/src/terralib/kernel/TeProxMatrixSlicingStrategy.h b/src/terralib/kernel/TeProxMatrixSlicingStrategy.h
new file mode 100644
index 0000000..ad975d2
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixSlicingStrategy.h
@@ -0,0 +1,113 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeProxMatrixSlicingStrategy.h
+    \brief This file contains structures and definitions about slicing strategies of proximity matrix 
+*/
+
+
+#ifndef TeProxMatrixSlicingStrategy_H
+#define TeProxMatrixSlicingStrategy_H
+
+#include "TeProxMatrixImplementation.h"
+
+struct TL_DLL TeProxMatrixSlicingParams
+{
+public:
+	TeGPMSlicingStrategy		strategy_;
+	double						zone_dist_;
+	bool						zone_local_;
+
+	TeProxMatrixSlicingParams(const TeGPMSlicingStrategy& type=TeNoSlicingStrategy):
+		strategy_(type), zone_dist_(0.), zone_local_(false)
+		{}
+
+	bool operator==(const TeProxMatrixSlicingParams& other) const
+	{
+		return ((strategy_==other.strategy_) && (zone_dist_==other.zone_dist_) &&
+			(zone_local_==other.zone_local_));
+	}
+};
+
+
+//! An abstract class to representate slicing strategies of proximity matrix    
+class TL_DLL TeProxMatrixSlicingStrategy  
+{
+protected:
+	//! Slicing type
+	TeProxMatrixSlicingParams params_; 
+
+	//! Empty constructor
+	TeProxMatrixSlicingStrategy(const TeGPMSlicingStrategy& type): params_(type) {}
+
+public:
+	//! Destructor
+	virtual ~TeProxMatrixSlicingStrategy() {}
+
+	//! Slice the proximity matrix 
+	virtual bool Slice(TeProxMatrixImplementation* )=0;
+
+	//! Equal operator
+	virtual bool operator== (const TeProxMatrixSlicingStrategy& s) const {return (params_==s.params_);}
+
+	//! Returns the slicing params
+	TeProxMatrixSlicingParams& slicingParams() { return params_; }
+
+};
+
+
+//! A class to implement the no slicing strategy of proximity matrix (i.e., all neighbour are considered to be in the first slice).
+class TL_DLL TeProxMatrixNoSlicingStrategy : public TeProxMatrixSlicingStrategy
+{
+public:
+	//! Empty constructor
+	TeProxMatrixNoSlicingStrategy (): TeProxMatrixSlicingStrategy(TeNoSlicingStrategy)
+	{}
+
+	//! No slice the proximity matrix 
+	virtual bool Slice(TeProxMatrixImplementation* ) {return true;}
+
+	//! Destructor
+	~TeProxMatrixNoSlicingStrategy() {}
+};
+
+
+//! A class to implement the zone slicing strategy of proximity matrix (by local or newtork connection distance);
+class TL_DLL TeProxMatrixZonesSlicingStrategy : public TeProxMatrixSlicingStrategy
+{
+public:
+	//! Constructor
+	TeProxMatrixZonesSlicingStrategy (double dist, bool local = true):
+	  TeProxMatrixSlicingStrategy(TeZonesSlicingStrategy)
+	  {
+		  params_.zone_dist_=dist;
+		  params_.zone_local_=local;
+	  }
+
+	//! Slice the proximity matrix through zone strategy 
+	virtual bool Slice(TeProxMatrixImplementation* imp);
+
+	//! Destructor
+	~TeProxMatrixZonesSlicingStrategy() {}
+};
+
+#endif
diff --git a/src/terralib/kernel/TeProxMatrixStrategies.cpp b/src/terralib/kernel/TeProxMatrixStrategies.cpp
new file mode 100644
index 0000000..7198417
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixStrategies.cpp
@@ -0,0 +1,296 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeProxMatrixSlicingStrategy.h"
+#include "TeProxMatrixWeightsStrategy.h"
+
+
+// zone slicing strategy
+bool TeProxMatrixZonesSlicingStrategy::Slice (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) return false;
+
+	for (int obj = 0; obj < imp->numberOfObjects(); obj++)
+	{
+		TeNeighbours neigh;
+		string object_id;
+		TeProxMatrixAttributes attr;
+		if (imp->getNeighbours (obj, object_id, neigh))
+		{
+			for (int i = 0; i < neigh.size(); i++)
+			{
+				attr = neigh.Attributes(i);
+		
+				double distance, d_centr, d_net, d_conn;
+
+				if (attr.WasCentroidDistanceComputed())
+					d_centr = attr.CentroidDistance();
+				else
+					d_centr = 0;
+				
+
+				if (attr.WasNetworkObjectsDistanceComputed())
+					d_net = attr.NetworkObjectsDistance();
+				else
+					d_net = 0;
+				
+
+				if (attr.WasNetworkMinimumPathComputed())
+					d_conn = attr.NetworkMinimumPath();
+				else
+					d_conn = 0;
+				
+			
+			   if (params_.zone_local_) 
+				   distance = d_centr;
+			   else
+				   distance = d_net + d_conn;
+
+			   int zone = (int) (distance/params_.zone_dist_);
+			   attr.Slice (zone);
+			   imp->setConnectionAttributes (object_id, neigh[i], attr);
+
+			}
+
+		}
+	}
+	return true;
+}
+
+
+// inverse distance weight strategy
+bool TeProxMatrixInverseDistanceStrategy:: 
+ComputeWeigths (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) return false;
+
+	for (int obj = 0; obj < imp->numberOfObjects(); obj++)
+	{
+		TeNeighbours neigh;
+		string object_id;
+		TeProxMatrixAttributes attr;
+		if (imp->getNeighbours (obj, object_id, neigh))
+		{
+			double tot = 0.0;
+			vector<double> w_vec;
+	
+			for (int i = 0; i < neigh.size(); i++)
+			{
+				TeProxMatrixAttributes attr = neigh.Attributes(i);
+				double w = 1;
+				double d_centr, d_net, d_conn;
+				if (attr.WasCentroidDistanceComputed())
+					if ((d_centr = attr.CentroidDistance()) != 0.0) 
+							w += (params_.a_)*1/d_centr;
+
+				if (attr.WasNetworkObjectsDistanceComputed())
+					if ((d_net = attr.NetworkObjectsDistance()) != 0.0) 
+							w += (params_.b_)*1/d_net;
+
+				if (attr.WasNetworkMinimumPathComputed())
+					if ((d_conn = attr.NetworkMinimumPath()) != 0.0) 
+							w += (params_.c_)*1/d_conn;
+
+				if (w != 1) w -= 1;
+
+				w_vec.push_back (w*params_.factor_);
+				tot += w;
+			}
+	
+		
+			for (int j = 0; j < neigh.size(); j++)
+			{
+					TeProxMatrixAttributes attr = neigh.Attributes(j);
+					double w = w_vec[j];
+					if (params_.norm_)
+						if (tot != 0) w = w/tot;
+					attr.Weight (w);
+					imp->setConnectionAttributes (object_id, neigh[j], attr);
+			}
+		}
+	}
+	return true;
+}
+
+
+
+// inverse distance weight strategy
+bool TeProxMatrixSquaredInverseDistanceStrategy:: 
+ComputeWeigths (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) return false;
+
+	for (int obj = 0; obj < imp->numberOfObjects(); obj++)
+	{
+		TeNeighbours neigh;
+		string object_id;
+		TeProxMatrixAttributes attr;
+		if (imp->getNeighbours (obj, object_id, neigh))
+		{
+			double tot = 0.0;
+			vector<double> w_vec;
+	
+			for (int i = 0; i < neigh.size(); i++)
+			{
+				TeProxMatrixAttributes attr = neigh.Attributes(i);
+				double w = 1;
+				double d_centr, d_net, d_conn;
+				if (attr.WasCentroidDistanceComputed())
+					if ((d_centr = attr.CentroidDistance()) != 0.0) 
+							w += (params_.a_)*1/(d_centr*d_centr);
+
+				if (attr.WasNetworkObjectsDistanceComputed())
+					if ((d_net = attr.NetworkObjectsDistance()) != 0.0) 
+							w += (params_.b_)*1/(d_net*d_net);
+
+				if (attr.WasNetworkMinimumPathComputed())
+					if ((d_conn = attr.NetworkMinimumPath()) != 0.0) 
+							w += (params_.c_)*1/(d_conn*d_conn);
+
+				if (w != 1) w -= 1;
+
+				w_vec.push_back (w*params_.factor_);
+				tot += w;
+			}
+	
+		
+			for (int j = 0; j < neigh.size(); j++)
+			{
+					TeProxMatrixAttributes attr = neigh.Attributes(j);
+					double w = w_vec[j];
+					if (params_.norm_)
+						if (tot != 0) w = w/tot;
+					attr.Weight (w);
+					imp->setConnectionAttributes (object_id, neigh[j], attr);
+			}
+		}
+	}
+	return true;
+}
+
+// inverse distance weight strategy
+bool TeProxMatrixConnectionStrenghtStrategy:: 
+ComputeWeigths (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) return false;
+
+	for (int obj = 0; obj < imp->numberOfObjects(); obj++)
+	{
+		TeNeighbours neigh;
+		string object_id;
+		TeProxMatrixAttributes attr;
+		if (imp->getNeighbours (obj, object_id, neigh))
+		{
+			double tot = 0.0;
+			vector<double> w_vec;
+			
+			for (int i = 0; i < neigh.size(); i++)
+			{
+				TeProxMatrixAttributes attr = neigh.Attributes(i);
+				double w = 1;
+				double d_centr = TeMAXFLOAT;
+				double d_net =   TeMAXFLOAT;
+				double d_conn =  TeMAXFLOAT;
+
+				if (attr.WasCentroidDistanceComputed())
+					d_centr = attr.CentroidDistance();
+
+				
+				if (d_centr == 0.0)
+				{
+					w = 1;
+				}
+				else
+				{
+					if (d_centr <= params_.max_local_dist_)
+					{
+						w = 1/d_centr;
+					}
+					else
+					{
+					
+						if (attr.WasNetworkObjectsDistanceComputed())
+							d_net = attr.NetworkObjectsDistance();
+
+						if (attr.WasNetworkMinimumPathComputed())
+							d_conn = attr.NetworkMinimumPath();
+
+						//double distance = (dist_ratio_*d_net + d_conn)/1000; Anap - Jul04
+						double distance = (params_.dist_ratio_*d_net + d_conn);
+						if (distance != 0.0)
+							w = 1/distance;
+					}
+				}
+				//if (w > 1.0) w = 1.0; n�o precisa: o objeto pode ser mais pr�ximo que 1 metro? jul04
+				w_vec.push_back (w*params_.factor_);
+				tot += w;
+			}
+		
+			for (int j = 0; j < neigh.size(); j++)
+			{
+					
+				TeProxMatrixAttributes attr = neigh.Attributes(j);
+				double w = w_vec[j];
+				if (params_.norm_)
+					if (tot != 0) w = w/tot;
+				attr.Weight (w);
+				imp->setConnectionAttributes (object_id, neigh[j], attr);
+				
+			}
+		}
+	}
+	return true;
+}
+
+
+
+bool TeProxMatrixNoWeightsStrategy:: 
+ComputeWeigths (TeProxMatrixImplementation* imp)
+{
+	if (imp == 0) return false;
+	// Normalize
+	if (params_.norm_)
+	{
+		for (int obj = 0; obj < imp->numberOfObjects(); obj++)
+		{
+			TeNeighbours neigh;
+			string object_id;
+			TeProxMatrixAttributes attr;
+			if (imp->getNeighbours (obj, object_id, neigh))
+			{
+	
+				for (int j = 0; j < neigh.size(); j++)
+				{
+					double size = (double) neigh.size();
+					double w = 1.0/size;
+					TeProxMatrixAttributes attr = neigh.Attributes(j);
+				
+					attr.Weight (w);
+					imp->setConnectionAttributes(object_id, neigh[j], attr);
+				}
+			}
+		}
+	}
+	return true;
+}
+
diff --git a/src/terralib/kernel/TeProxMatrixWeightsStrategy.h b/src/terralib/kernel/TeProxMatrixWeightsStrategy.h
new file mode 100644
index 0000000..7fce569
--- /dev/null
+++ b/src/terralib/kernel/TeProxMatrixWeightsStrategy.h
@@ -0,0 +1,168 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeProxMatrixWeightsStrategy.h
+    \brief This file contains structures and definitions about weight strategies of proximity matrix 
+*/
+
+
+#ifndef TeProxMatrixWeightsStrategy_H
+#define TeProxMatrixWeightsStrategy_H
+
+#include "TeProxMatrixImplementation.h"
+#include <vector>
+
+
+struct TL_DLL TeProxMatrixWeightsParams
+{
+public:
+	TeGPMWeightsStrategy		strategy_;
+	bool						norm_;
+	double						a_;
+	double						b_;
+	double						c_;
+	double						factor_;
+	double						dist_ratio_;
+	double						max_local_dist_;
+
+	TeProxMatrixWeightsParams(): 
+		strategy_(TeNoWeightsStrategy), norm_(false), a_(1.), 
+		b_(1.), c_(1.), factor_(1.), dist_ratio_(0.), max_local_dist_(0.)
+		{}
+
+	TeProxMatrixWeightsParams(bool norm, const TeGPMWeightsStrategy& type): 
+		strategy_(type), norm_(norm), a_(1.), b_(1.), c_(1.), 
+		factor_(1.), dist_ratio_(0.), max_local_dist_(0.)
+		{}
+
+	bool operator== (const TeProxMatrixWeightsParams& other) const
+	{
+		return ((strategy_==other.strategy_) && (norm_==other.norm_) &&
+			(a_==other.a_) && (b_==other.b_) && (c_==other.c_) &&
+			(factor_==other.factor_) && (dist_ratio_==other.dist_ratio_) &&
+			(max_local_dist_==other.max_local_dist_));
+	}
+};
+
+
+//! An abstract class to representate weight strategies of proximity matrix    
+class TL_DLL TeProxMatrixWeightsStrategy  
+{
+protected:
+	TeProxMatrixWeightsParams params_; 
+
+	//! Constructor
+	TeProxMatrixWeightsStrategy(bool norm = false, const TeGPMWeightsStrategy& type=TeNoWeightsStrategy ):
+		params_(norm, type)
+	 { }
+
+public:
+	//! Compute weigths
+	virtual bool ComputeWeigths (TeProxMatrixImplementation* ) =0;
+
+	//! Destructor
+	virtual ~TeProxMatrixWeightsStrategy() {}
+
+	//! Equal operator
+	virtual bool operator== (const TeProxMatrixWeightsStrategy& w) const {return (params_==w.params_);}
+
+	//! Returns the strategy to weigt the matrix
+	TeProxMatrixWeightsParams& weightsParams() { return params_; }
+};
+
+//! A class to implement the no weight strategy of proximity matrix (i.e., all weights are 1, only indicating that a connection exists).
+class TL_DLL TeProxMatrixNoWeightsStrategy : public TeProxMatrixWeightsStrategy
+{
+public:
+	//! Constructor
+	TeProxMatrixNoWeightsStrategy (bool norm = true) : TeProxMatrixWeightsStrategy(norm, TeNoWeightsStrategy)
+	{ }
+
+	//! Compute weigths
+	virtual bool ComputeWeigths (TeProxMatrixImplementation* imp);
+
+	//! Destructor
+	~TeProxMatrixNoWeightsStrategy() {}
+};
+
+
+//! A class to implement the inverse distance weight strategy of proximity matrix; if network distances were computed, they can be also considered.
+//! Formula: w = (a*1/dist_centroids + b*1/dist_to_net + c*1/dist_net_connection)*factor
+//! These values can be normalized or not.
+class TL_DLL TeProxMatrixInverseDistanceStrategy : public TeProxMatrixWeightsStrategy
+{
+public:
+	//! Constructor
+	TeProxMatrixInverseDistanceStrategy  (double a = 1.0, double b = 1.0, double c = 1.0, double factor = 1.0, bool norm = true) : 
+	  TeProxMatrixWeightsStrategy (norm, TeInverseDistanceStrategy)
+	{ params_.a_ = a; params_.b_ = b; params_.c_ = c; params_.factor_ = factor;}
+
+	//! Compute weights
+	virtual bool ComputeWeigths (TeProxMatrixImplementation* imp); 
+
+	//! Destructor	
+	~TeProxMatrixInverseDistanceStrategy() {}
+};
+
+
+//! A class to implement the inverse distance weight strategy of proximity matrix; if network distances were computed, they can be also considered.
+//! Formula: w = (a*1/(dist_centroids)2 + b*1/(dist_to_net)2 + c*1/(dist_net_connection)2)*factor
+//! These values can be normalized or not.
+class TL_DLL TeProxMatrixSquaredInverseDistanceStrategy : public TeProxMatrixWeightsStrategy
+{
+public:
+	//! Constructor
+	TeProxMatrixSquaredInverseDistanceStrategy  (double a = 1.0, double b = 1.0, double c = 1.0, double factor = 1.0, bool norm = true) : 
+	  TeProxMatrixWeightsStrategy (norm, TeSquaredInverseDistStrategy)
+	{ params_.a_ = a; params_.b_ = b; params_.c_ = c; params_.factor_ = factor;}
+
+	//! Compute weights
+	virtual bool ComputeWeigths (TeProxMatrixImplementation* imp); 
+
+	//! Destructor	
+	~TeProxMatrixSquaredInverseDistanceStrategy() {}
+};
+
+
+//! A class to implement the connection strenght weight strategy of proximity matrix
+//! If centroids distance is smaller them max_local_distance, w will be only the local distance inverse (multiplied by factor).
+//! otherwise, it will be w = 1/(dist_ratio*dist_to_net + dist_net_connection)*factor.
+class TL_DLL TeProxMatrixConnectionStrenghtStrategy : public TeProxMatrixWeightsStrategy
+{
+public:
+	//! Constructor
+	TeProxMatrixConnectionStrenghtStrategy  (double dist_ratio = 1.0, double max_local_distance = 0.0, double factor = 1.0, bool norm = true) 
+		: TeProxMatrixWeightsStrategy (norm, TeConnectionStrenghtStrategy )
+	{ 
+		params_.dist_ratio_ = dist_ratio;
+		params_.max_local_dist_ = max_local_distance;
+		params_.factor_ = factor;
+	}
+
+	//! Compute weights
+	virtual bool ComputeWeigths (TeProxMatrixImplementation* imp); 
+
+	//! Destructor	
+	~TeProxMatrixConnectionStrenghtStrategy() {}
+};
+
+#endif 
diff --git a/src/terralib/kernel/TeQuerier.cpp b/src/terralib/kernel/TeQuerier.cpp
new file mode 100644
index 0000000..5c4fcd6
--- /dev/null
+++ b/src/terralib/kernel/TeQuerier.cpp
@@ -0,0 +1,204 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeQuerier.h"
+#include "TeQuerierImpl.h"
+
+
+TeQuerier::TeQuerier(TeQuerierParams& params)
+{
+	Impl_ = TeQuerierImplFactory::make(params);
+}
+
+TeQuerier::TeQuerier(const TeQuerier& other)
+{
+	if(Impl_)
+		delete Impl_;
+
+	Impl_ = 0;
+	if(other.Impl_ && other.Impl_->params())
+	{
+		Impl_ = TeQuerierImplFactory::make(*(other.Impl_->params()));
+	}
+}
+
+TeQuerier&
+TeQuerier::operator=(const TeQuerier& other)
+{
+	if ( this != &other )
+	{
+		if(Impl_)
+			delete Impl_;
+
+		Impl_ = 0;
+		if(other.Impl_ && other.Impl_->params())
+		{
+			Impl_ = TeQuerierImplFactory::make(*(other.Impl_->params()));
+		}
+	}
+	return *this;
+}
+
+TeQuerier::~TeQuerier()
+{
+	if(Impl_)
+		delete (Impl_);
+}
+
+bool 
+TeQuerier::loadInstances(int frame)
+{
+	if(!Impl_)
+		return false;
+
+	return(Impl_->loadTimeFrameInstances(frame));
+}
+
+
+bool 
+TeQuerier::fetchInstance(TeSTInstance&  sto)
+{
+	if(!Impl_)
+		return false;
+
+	return(Impl_->fetchInstance(sto));
+}
+
+
+int 
+TeQuerier::getNumTimeFrames()
+{
+	if(!Impl_) 
+		return false;
+
+	return (Impl_->getNumTimeFrames());
+}
+
+bool 
+TeQuerier::getTSEntry(TeTSEntry& tsEntry, int frame)
+{
+	if(!Impl_) 
+		return false;
+
+	return(Impl_->getTSEntry(tsEntry, frame)); 
+}
+
+
+bool 
+TeQuerier::getTS(TeTemporalSeries& ts)
+{
+	if(!Impl_) 
+		return false;
+
+	return (Impl_->getTS(ts));
+}
+
+TeTheme* 
+TeQuerier::theme()
+{
+	if(!Impl_)
+		return 0;
+
+	return(Impl_->theme());
+}
+
+
+int 
+TeQuerier::numElemInstances()
+{
+	if(!Impl_)
+		return 0;
+
+	return (Impl_->numElemInstances());
+}
+
+TeQuerierParams&
+TeQuerier::params() 
+{ 
+	return (*(Impl_->params())); 
+}
+
+TeTSParams& 
+TeQuerier::getTSParams() 
+{ 
+	return (Impl_->getTSParams()); 
+}
+
+void 
+TeQuerier::clear()
+{
+	if(!Impl_)
+		return;
+
+	Impl_->clear();
+}
+
+TeAttributeList
+TeQuerier::getAttrList()
+{
+	TeAttributeList temp;
+	if(!Impl_)
+		return temp;
+
+	return (Impl_->getAttrList());
+}
+
+TeBox	
+TeQuerier::getBox()
+{
+	TeBox b;
+	if(!Impl_)
+		return b;
+
+	return (Impl_->params()->box());
+}
+
+void 
+TeQuerier::refresh(TeQuerierParams& params)
+{
+	if(Impl_)
+		delete (Impl_);
+	
+	Impl_ = TeQuerierImplFactory::make(params);
+}
+
+bool 
+TeQuerier::loadGeometries(TeMultiGeometry& geometries, unsigned int& index)
+{
+	if(!Impl_)
+		return false;
+
+	return (Impl_->loadGeometries(geometries, index));
+}
+
+
+bool 
+TeQuerier::loadGeometries(TeMultiGeometry& geometries)
+{
+	if(!Impl_)
+		return false;
+
+	return (Impl_->loadGeometries(geometries));
+}
+
+
diff --git a/src/terralib/kernel/TeQuerier.h b/src/terralib/kernel/TeQuerier.h
new file mode 100644
index 0000000..7a5e65d
--- /dev/null
+++ b/src/terralib/kernel/TeQuerier.h
@@ -0,0 +1,154 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeQuerier.h
+	\brief This file contains a mechanism named "Querier" that is responsible for loading spatio-temporal instances from different sources. 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_QUERIER_H
+#define  __TERRALIB_INTERNAL_QUERIER_H
+
+#include "TeSTInstance.h"
+#include "TeTemporalSeries.h"
+
+#include "TeQuerierDBStr1.h"
+#include "TeQuerierDBStr2.h"
+#include "TeQuerierDBStr3.h"
+
+class TeQuerierParams;
+class TeQuerierImpl; 
+
+/*! \class TeQuerier
+	\brief A class responsible for loading spatial temporal instances from different sources.
+
+	This class implements a mechanism that is responsible for loading
+	spatio-temporal instances (ST instances) from different sources. This mechanism can 
+	load ST instances from a layer or theme stored in a 
+	TerraLib database or in a shape file. The Querier is initialized for a set of
+	parameters that defines its behavior. 
+
+	\sa
+	TeSTInstance TeQuerierParams
+*/
+class TL_DLL TeQuerier
+{
+protected:
+		TeQuerierImpl*		Impl_;		//!<  querier implementation (handle/bory pattern)
+		
+public:	
+		//! Empty constructor
+		TeQuerier():
+			Impl_(0)
+			{} 
+			
+		//! Constructor from a set of parameters
+		TeQuerier(TeQuerierParams& params);
+
+		//! Copy constructor
+		TeQuerier(const TeQuerier& other);
+
+		//! Operator =
+		TeQuerier& operator= (const TeQuerier& other);
+				
+		//! Destructor
+		~TeQuerier(); 
+		
+		//! Returns the base theme
+		TeTheme* theme();
+		
+	 	//! Loads the ST instances. If frame > -1, loads only the instances of the frame-th time frame 
+		bool loadInstances(int frame=-1);  
+		
+		//! Gets the current ST instance and moves to the next one. Returns if there is a next instance. 
+		bool fetchInstance(TeSTInstance&  sto);
+
+		//! Returns the number of time frames generated by a specific chronon	
+		int getNumTimeFrames(); 
+
+		//! Gets a temporal serie entry associated to a time frame
+		bool getTSEntry(TeTSEntry& tsEntry, int frame);
+		
+		//! Gets the temporal series
+		bool getTS(TeTemporalSeries& ts); 
+		
+		//! Returns the temporal series parameters
+		TeTSParams& getTSParams();
+		
+		//! Gets the attribute list of the instances
+		TeAttributeList getAttrList();
+
+		//! Gets the minimal bounding box
+		TeBox	getBox();
+
+		//! Returns the number of instances loaded by the method "loadInstances"
+		int numElemInstances(); 
+
+		//! Returns the querier parameters
+		TeQuerierParams& params(); 
+
+		//! Clear querier structures
+		void clear(); 
+
+		//! Refreshes the querier based on a new querier parameters
+		void refresh(TeQuerierParams& params); 
+		
+		//! Loads all geometries of the index-th geometry representation  
+		bool loadGeometries(TeMultiGeometry& geometries, unsigned int& index); 
+
+		//! Loads all geometries 
+		bool loadGeometries(TeMultiGeometry& geometries);
+};
+
+ /** \example querierFromLayer.cpp
+	Shows how to use a querier from layer
+ */
+
+ /** \example querierFromTheme.cpp
+	Shows how to use a querier from theme
+ */
+
+ /** \example querierGroupChronon.cpp
+	Shows how to querier from theme, grouping spatiotemporal instances by a chronon
+ */
+
+ /** \example querierGroupElement.cpp
+	Shows how to use a querier from theme, grouping spatiotemporal instances by a element
+ */
+
+ /** \example querierGroupSpatialRest.cpp
+	Shows how to use a querier from theme, grouping all  
+   spatiotemporal instances that satisfy a spatial restriction
+ */
+
+ /** \example querierWithSpatialRestBox.cpp
+	Shows how to use a querier from theme, using a spatial restriction 
+	defined by a rectangle (TeBOX)
+ */
+
+ /** \example querierWithSpatialRestGeometry.cpp
+	Shows how to use a querier from theme, using a spatial restriction 
+	defined by a geometry (polygons, lines, cells and points) from another theme
+ */
+#endif 
+
+
+
diff --git a/src/terralib/kernel/TeQuerierDB.cpp b/src/terralib/kernel/TeQuerierDB.cpp
new file mode 100644
index 0000000..8b75191
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDB.cpp
@@ -0,0 +1,536 @@
+
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeQuerierDB.h"
+#include "TeDatabase.h"
+#include "TeSTInstance.h"
+#include "TeTemporalSeries.h"
+
+// Add geometries from portal to STO 
+bool 
+addGeometry(TeDatabasePortal* portal, TeGeomRep geomRep, TeSTInstance& sto, const int& linkIndex, const int& geomIdIndex) 
+{
+	bool flag=true;
+	map<int, int> geomIds;
+		
+	//verify if the portal has geometry (multi geometries)
+	string geomId = string(portal->getData(geomIdIndex));
+	string objId =  string(portal->getData(linkIndex)); 
+	int	gId = atoi(geomId.c_str());
+	
+	//There are no geometries in the portal. This happens when
+	//the objects have multi geometries (ex.: obj 1 is line and obj 2 is ponit).
+	//The portal must point to the next object.
+	if(geomId.empty())
+	{
+		do
+		{
+			flag = portal->fetchRow();
+		} while(flag && (string(portal->getData(linkIndex)) == sto.objectId()));
+		
+		return flag; 
+	}
+
+	//The portal points to other object. This happens when
+	//the objects have more than one geometrical representation and, at the same time, 
+	//the theme has an external table.
+	if(objId!=sto.objectId())
+	{
+		do
+		{
+			flag = portal->fetchRow();
+			objId = string(portal->getData(linkIndex));
+		} while(flag && ( objId != sto.objectId()));
+		
+		gId = atoi(portal->getData(geomIdIndex));
+	}
+
+	//There are geometries
+	while(	flag && (objId == sto.objectId()) &&
+			(geomIds.find(gId) == geomIds.end()))
+	{
+		geomIds[gId] = gId;
+		if(geomRep == TePOLYGONS)
+		{
+			TePolygon pol;
+			flag = portal->fetchGeometry(pol, geomIdIndex);
+			sto.addGeometry(pol);
+		}
+		else if (geomRep==TeLINES)
+		{
+			TeLine2D lin;
+			flag = portal->fetchGeometry(lin, geomIdIndex);
+			sto.addGeometry(lin);
+		}
+		else if (geomRep == TePOINTS)
+		{
+			TePoint point;
+			flag = portal->fetchGeometry(point, geomIdIndex);
+			sto.addGeometry(point);
+		}
+		else if (geomRep == TeCELLS)
+		{
+			TeCell cell;
+			flag = portal->fetchGeometry(cell, geomIdIndex);
+			sto.addGeometry(cell);
+		}
+		else if (geomRep == TeTEXT)
+		{
+			TeText text;
+			flag = portal->fetchGeometry(text, geomIdIndex);
+			sto.addGeometry(text); 
+		}
+		else
+			flag = portal->fetchRow();
+
+		if(flag)
+		{
+			gId = atoi(portal->getData(geomIdIndex));
+			objId =  string(portal->getData(linkIndex)); 
+		}
+	}
+
+	return flag;
+}
+
+// Add geometries from portal to STO considering the time value
+bool
+addGeometry(TeDatabasePortal* portal, TeGeomRep geomRep, TeSTInstance& sto, const int& linkIndex, 
+			const int& geomIdIndex, TeTimeInterval time, const int& initTimeIndex, const int& finalTimeIndex) 
+{
+	bool flag=true;
+	map<int, int> geomIds;
+	TeTime t1 = time.getT1();
+	TeTime t2 = time.getT2();
+			
+	//verify if the portal has geometry (multi geometries)
+	
+	string geomId = string(portal->getData(geomIdIndex));
+	string objId =  string(portal->getData(linkIndex)); 
+	int	gId = atoi(geomId.c_str());
+	
+	//There are no geometries in the portal. This happens when
+	//the objects have multi geometries (ex.: obj 1 is line and obj 2 is ponit).
+	//The portal must point to the next object.
+	if(geomId.empty())
+	{
+		do
+		{
+			flag = portal->fetchRow();
+			objId = string(portal->getData(linkIndex));
+		} while ( flag && 
+			 (objId == sto.objectId()) &&
+			 (portal->getDate(initTimeIndex) == t1) && 
+			 (portal->getDate(finalTimeIndex) == t2) );
+		
+		return flag; 
+	}
+
+	//The portal points to other object. This happens when
+	//the objects have more than one geometrical representation and, at the same time, 
+	//the theme has an external table.
+	if(objId!=sto.objectId())
+	{
+		do
+		{
+			flag = portal->fetchRow();
+			objId = string(portal->getData(linkIndex));
+		} while(flag && (objId != sto.objectId()));
+		
+		gId = atoi(portal->getData(geomIdIndex));
+	}
+
+
+	//There are geometries
+	while(	flag && (objId == sto.objectId()) &&
+			(geomIds.find(gId) == geomIds.end()) && 
+			(portal->getDate(initTimeIndex) == t1) && 
+			(portal->getDate(finalTimeIndex) == t2) )
+	{
+		geomIds[gId] = gId;
+		if(geomRep == TePOLYGONS)
+		{
+			TePolygon pol;
+			flag = portal->fetchGeometry(pol, geomIdIndex);
+			sto.addGeometry(pol);
+		}
+		else if (geomRep==TeLINES)
+		{
+			TeLine2D lin;
+			flag = portal->fetchGeometry(lin, geomIdIndex);
+			sto.addGeometry(lin);
+		}
+		else if (geomRep == TePOINTS)
+		{
+			TePoint point;
+			flag = portal->fetchGeometry(point, geomIdIndex);
+			sto.addGeometry(point);
+		}
+		else if (geomRep == TeCELLS)
+		{
+			TeCell cell;
+			flag = portal->fetchGeometry(cell, geomIdIndex);
+			sto.addGeometry(cell);
+		}
+		else if (geomRep == TeTEXT)
+		{
+			TeText text;
+			flag = portal->fetchGeometry(text, geomIdIndex);
+			sto.addGeometry(text); 
+		}
+		else
+			flag = portal->fetchRow();
+
+		if(flag)
+		{
+			gId = atoi(portal->getData(geomIdIndex));
+			objId =  string(portal->getData(linkIndex)); 
+		}
+	}
+
+	return flag;
+}
+
+bool 
+addGeometry(TeDatabasePortal* portal, TeGeomRep geomRep, TeMultiGeometry& geometries) 
+{
+	bool flag = true;
+	//There are geometries
+	do
+	{
+		if(geomRep == TePOLYGONS)
+		{
+			TePolygon pol;
+			flag = portal->fetchGeometry(pol);
+			geometries.getPolygons().add(pol);
+		}
+		else if (geomRep==TeLINES)
+		{
+			TeLine2D lin;
+			flag = portal->fetchGeometry(lin);
+			geometries.getLines().add(lin);
+		}
+		else if (geomRep == TePOINTS)
+		{
+			TePoint point;
+			flag = portal->fetchGeometry(point);
+			geometries.getPoints().add(point);
+		}
+		else if (geomRep == TeCELLS)
+		{
+			TeCell cell;
+			flag = portal->fetchGeometry(cell);
+			geometries.getCells().add(cell);
+		}
+		else if (geomRep == TeTEXT)
+		{
+			TeText text;
+			flag = portal->fetchGeometry(text);
+			geometries.getTexts().add(text);
+		}
+		else
+			flag = portal->fetchRow();
+	}while(flag);
+	return flag;
+}
+
+TeQuerierDB::~TeQuerierDB() 
+{
+	for(unsigned int i=0; i<portals_.size(); ++i)
+		delete (portals_[i]);
+
+	portals_.clear();
+	geomRepr_.clear();
+}
+
+
+void
+TeQuerierDB::clearVectors()
+{
+	vector<TeDatabasePortal*>::iterator itPortal = portals_.begin();
+	while(itPortal!=portals_.end())
+	{		
+		TeDatabasePortal* portal = *itPortal;
+		delete portal; 
+		++itPortal;
+	}
+	
+	portals_.clear();
+	geomRepr_.clear();
+	flagPortal_ = false;
+}
+
+void 
+TeQuerierDB::clear()
+{
+	clearVectors();
+}
+
+TeGeomRep 
+TeQuerierDB::geometryRep() 
+{  return TeGeomRep(params_->theme()->layer()->geomRep()); }
+
+string 
+TeQuerierDB::sqlWhereRestrictions(TeRepresentation* rep)
+{
+	TeKeys objs;
+	string whereClause= " 1 = 1 ";
+	TeDatabase* db = params_->theme()->layer()->database();
+	if(!db)
+		return "";
+	
+	// load the first representation 
+	if(!rep)
+		rep = (params_->theme()->layer()->vectRepres())[0];
+
+	// spatial restriction with other geometry representation
+	if (params_->hasSpatialRes() && rep)
+	{
+		if(params_->boxRest().isValid())
+		{
+            TeBox b =  params_->boxRest();
+            TeGeomRep gRep = rep->geomRep_;
+			whereClause += " AND "+ db->getSQLBoxWhere(b, gRep);
+		}
+		else if(params_->geomRest())
+		{
+			string geomTableRest = params_->theme()->layer()->tableName(params_->geomRepRest());
+			TePrecision::instance().setPrecision(TeGetPrecision(params_->theme()->layer()->projection()));
+
+			if((db->spatialRelation(geomTableRest, params_->geomRepRest(), params_->geomRest(),  
+							   objs, params_->spatialRelation())) && (!objs.empty()))
+			{
+				string obs;
+				for(unsigned int i=0; i<objs.size(); i++)
+				{
+					if(i!=0)
+						obs += ",";
+					obs += "'"+ objs[i] +"'";
+				}
+				
+				whereClause += " AND "+ rep->tableName_ +".object_id IN ("+ obs +")";
+			}
+			else
+				whereClause += " AND 1 <> 1 "; // no geometry was found 
+
+		}
+	}
+
+	//selected objects
+	switch (params_->selectedObjs())
+	{
+		case TeAll:
+			break;
+		
+		case TeSelectedByPointing:
+			whereClause += " AND (grid_status = 1 OR grid_status = 3";
+			whereClause += " OR (grid_status IS NULL AND (c_object_status = 1 OR c_object_status = 3)))";
+			break;
+		
+		case TeNotSelectedByPointing:
+			whereClause += " AND (grid_status = 0 OR grid_status = 2";
+			whereClause += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 2)))";
+			break;
+		
+		case TeSelectedByQuery:
+			whereClause += " AND (grid_status = 2 OR grid_status = 3";
+			whereClause += " OR (grid_status is null AND (c_object_status = 2 OR c_object_status = 3)))";
+			break;
+		
+		case TeNotSelectedByQuery:
+			whereClause += " AND (grid_status = 0 OR grid_status = 1";
+			whereClause += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 1)))";
+			break;
+	
+		case TeGrouped:
+			whereClause += " AND c_legend_id <> 0";
+			break;
+
+		case TeNotGrouped:
+			whereClause += " AND c_legend_id = 0";
+			break;
+
+		case TeSelectedByPointingAndQuery:
+			whereClause += " AND grid_status = 3";
+			whereClause += " OR (grid_status is null AND c_object_status = 3)";
+			break;
+
+		case TeSelectedByPointingOrQuery:
+			whereClause += " AND (grid_status = 1 OR grid_status = 2 OR grid_status = 3)";
+			whereClause += " OR  (grid_status is null AND (c_object_status = 3 OR c_object_status = 1 OR c_object_status = 2))";
+			break;	
+	}
+
+	return whereClause;
+}
+
+
+string 
+TeQuerierDB::sqlFrom(string geomTable)
+{
+	string fromPar = "";
+	string fromClause = "";
+	
+	//get collection tables 
+	string collAuxTable = params_->theme()->collectionAuxTable();
+	string collTable = params_->theme()->collectionTable();
+	
+	if(collAuxTable.empty() || collTable.empty())
+		return attrTable_.name();
+
+	if(attrTable_.name().empty())
+		return "";
+	
+	string uniqueIdName = attrTable_.name() +"."+ attrTable_.uniqueName(); 
+	string objectIdName = attrTable_.name() +"."+ attrTable_.linkName(); 
+	string linkName; 
+	if(attrTable_.tableType() != TeAttrExternal)
+		linkName = attrTable_.name() +"."+ attrTable_.linkName(); 
+	else
+		linkName = collTable +".c_object_id "; 
+
+	//load geometry table if there is spatial restriction
+	if(geomTable.empty() && params_->hasSpatialRes())
+	{
+		TeRepresentation* rep = (theme()->layer()->vectRepres())[0];
+		geomTable = theme()->layer()->tableName(rep->geomRep_);
+	}
+
+	//get the extern table position 
+	int posExtern = -1;
+	TeAttrTableVector attr = params_->theme()->attrTables();
+	for(unsigned int i=0; i<attr.size(); ++i)
+	{
+		if(attr[i].tableType() == TeAttrExternal)
+			++posExtern;
+	}
+	
+	//if the table is temporal   
+	if((attrTable_.tableType()==TeAttrEvent) || (attrTable_.tableType()==TeFixedGeomDynAttr))
+	{
+		fromPar += "((";
+		fromClause = attrTable_.name()+" RIGHT JOIN "+ collAuxTable; 
+				
+		if(attrTable_.tableType()==TeFixedGeomDynAttr)
+		{
+			fromClause += " ON "+ uniqueIdName +" = ";
+			fromClause += collAuxTable +".aux0";
+			fromClause += ")";
+		}
+		else
+		{
+			fromClause += " ON "+ objectIdName +" = ";
+			fromClause += collAuxTable +".object_id"+ ")";
+		}
+
+		fromClause += " LEFT JOIN "+ collTable; 
+		fromClause += " ON "+ collAuxTable +".object_id = "+ collTable +".c_object_id )";
+		
+		if(!geomTable.empty())
+		{
+			fromPar += "(";
+			fromClause += " LEFT JOIN "+ geomTable +" ON ";
+			fromClause += collAuxTable +".object_id = "+ geomTable +".object_id )";
+		}
+
+		if(params_->selectedObjs() != TeAll) //! join with collection table
+		{
+			fromPar += "(";
+			fromClause += " LEFT JOIN "+ collTable +" ON ";
+			fromClause += collAuxTable +".object_id = "+ collTable +".c_object_id )";
+		}
+	} 
+
+	else if (attrTable_.tableType()==TeAttrStatic)
+	{
+		fromPar += "(";
+		fromClause =  attrTable_.name()+" RIGHT JOIN "+ collTable; 
+		fromClause += " ON "+ linkName +" = "+ collTable +".c_object_id)";
+
+		if(!geomTable.empty()) //! join with geometry table
+		{
+			fromPar += "(";
+			fromClause += " LEFT JOIN "+ geomTable +" ON ";
+			fromClause += collTable +".c_object_id = "+ geomTable +".object_id )";
+		}
+
+		if(params_->selectedObjs() != TeAll) //! join with collection table
+		{
+			fromPar += "(";
+			fromClause += " LEFT JOIN "+ collAuxTable +" ON ";
+			fromClause += collTable +".c_object_id = "+ collAuxTable +".object_id )";
+		}
+	}
+	else if (attrTable_.tableType()==TeAttrExternal)
+	{
+		fromPar += "((";
+		fromClause = collAuxTable +" RIGHT JOIN "+ collTable; 
+		fromClause += " ON "+ collAuxTable +".object_id = "+ collTable +".c_object_id )";
+		fromClause += " LEFT JOIN "+ attrTable_.name() +" ON ";
+		fromClause +=  collAuxTable +".aux"+ Te2String(posExtern) +" = ";
+		fromClause +=  uniqueIdName +" )";
+
+		if(!geomTable.empty()) //! join with geometry table
+		{
+			fromPar += "(";
+			fromClause += " LEFT JOIN "+ geomTable +" ON ";
+			fromClause += collTable +".c_object_id = "+ geomTable +".object_id )";
+		} 
+	}
+		
+	return (fromPar+fromClause);
+}
+
+bool 
+TeQuerierDB::loadGeometries(TeMultiGeometry& geometries, unsigned int& index)
+{
+	if((portals_.size()<(index+1)) || (geomRepr_.size()<(index+1)))
+		return false;
+
+	TeDatabasePortal* portal = portals_[index]; 
+	TeRepresentation rep = geomRepr_[index];
+	if(!portal)
+		return false; 
+	
+	bool flag = addGeometry(portal, rep.geomRep_, geometries);
+
+	return flag;
+}
+
+bool 
+TeQuerierDB::loadGeometries(TeMultiGeometry& geometries) 
+{
+	bool flag = false;
+	
+	if(!params_->loadGeom())
+		return flag;
+	
+	for(unsigned int i=0; i<portals_.size(); ++i)
+		flag = loadGeometries(geometries, i);
+	
+	return flag;
+}
+
+
+
diff --git a/src/terralib/kernel/TeQuerierDB.h b/src/terralib/kernel/TeQuerierDB.h
new file mode 100644
index 0000000..3770f5e
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDB.h
@@ -0,0 +1,122 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeQuerierDB.h
+	\brief This file deals with strategies to retrieve spatio-temporal elements from a TerraLib database
+*/
+#ifndef  __TERRALIB_INTERNAL_QUERIER_DB_H
+#define  __TERRALIB_INTERNAL_QUERIER_DB_H
+
+#include "TeQuerierImpl.h"
+#include "TeRepresentation.h"
+
+class TeDatabasePortal;
+class TeTimeInterval;
+class TeTSEntry;
+
+//! auxiliary functions to add geometries in the TeSTInstance or TeMultiGeometry
+TL_DLL bool addGeometry(TeDatabasePortal* portal, TeGeomRep geomRep, TeSTInstance& sto, const int& linkIndex, const int& gIdIndex);
+TL_DLL bool addGeometry(TeDatabasePortal* portal, TeGeomRep geomRep, TeSTInstance& sto, const int& linkIndex, 
+			const int& geomIdIndex, TeTimeInterval time, const int& initTimeIndex, const int& finalTimeIndex); 
+TL_DLL bool addGeometry(TeDatabasePortal* portal, TeGeomRep geomRep, TeMultiGeometry& geometries); 
+
+
+//! An abstract class to build STOs (Spatial Temporal Objects) from a TerraLib database 
+class TL_DLL TeQuerierDB : public TeQuerierImpl
+{
+protected:
+	//! a portal to each geometry representation
+	vector<TeDatabasePortal*>	portals_;		
+	//! keep the geometry representation of each portal 
+	vector<TeRepresentation>	geomRepr_;	
+	//! internal information used to fill the stos
+	TeTable						attrTable_;	
+	//! flag to control the portal
+	bool						flagPortal_;	 
+	
+	//! map FROM each portal in the vector "portals_" TO the indexes of the unique attributes
+	map<int, vector<int> >		uniqueIndex_; 
+	
+	//! index of the link attributes in each portal in the vector "portals_"
+	vector<int>		linkIndex_;
+
+	//! index in the first portal of the first attribute
+	int				attrIndex1_;
+	//! index in the first portal of the last attribute
+	int				attrIndex2_;
+	//! index in the first portal of the group, if there is collection table
+	int				groupIndex_;
+	//! index where the geometry information begin in each portal in the vector "portals_"
+	vector<int>				geomIndex1_;
+	//! index where the geometry information finish in each portal in the vector "portals_"
+	vector<int>				geomIndex2_;
+	//! index of the initial time in each portal in the vector "portals_"  
+	vector<int>				timeIndex1_;
+	//! index of the final time in each portal in the vector "portals_"  
+	vector<int>				timeIndex2_;
+
+	//! map from legend identifier to group number  
+	map<int, int>			legendIdGroup_;
+			
+	//! clear internal vectors
+	void clearVectors(); 
+
+	//! Return a where clause in SQL that represent the querier restrictions
+	virtual string sqlWhereRestrictions(TeRepresentation* rep=0);
+
+	//! Build the sql from clause
+	string sqlFrom(string geomTable="");
+
+public:	
+	//! Constructor
+	TeQuerierDB(TeQuerierParams* params): TeQuerierImpl(params), flagPortal_(false) 
+	{}
+	
+	//! Destructor 
+	virtual ~TeQuerierDB();  
+	
+	//! Returns the pointer to the theme 
+	TeTheme* theme() {	return params_->theme();	}
+
+	//! Returns the pointer to the layer 
+	TeLayer* layer() {	return  params_->theme()->layer(); }
+
+	//! Returns the geometry representation of the theme
+	TeGeomRep geometryRep();
+
+	//! Loads the STOs from database
+	virtual bool loadInstances(TeTSEntry* ent=0) = 0;  
+	
+	//! Returns each loaded STO
+	virtual bool fetchInstance(TeSTInstance& stoi) = 0; 
+
+	//! Loads all geometries of the index-th geometry representation  
+	virtual bool loadGeometries(TeMultiGeometry& geometries, unsigned int& index); 
+
+	//! Loads all geometries 
+	virtual bool loadGeometries(TeMultiGeometry& geometries);
+	
+	//! Empties querier instances
+	void clear(); 
+};
+
+#endif
diff --git a/src/terralib/kernel/TeQuerierDBStr1.cpp b/src/terralib/kernel/TeQuerierDBStr1.cpp
new file mode 100644
index 0000000..e0f8249
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDBStr1.cpp
@@ -0,0 +1,1174 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeQuerierDBStr1.h"
+#include "TeDatabase.h"
+#include "TeTemporalSeries.h"
+#include "TeSTInstance.h"
+
+bool 
+TeQuerierDBStr1::initPortal(TeRepresentation& rep, TeTSEntry* ent)
+{
+	string selectClause, fromClause, whereClause, orderByClause, groupByClause, parClause;
+	
+	//Init portal indexes
+	isGroup_ = false;
+	uniqueIndex_.clear();
+	vector<int> indexesAux;
+	linkIndex_.clear();
+	linkIndex_.push_back(-1); 
+	attrIndex1_=-1;
+	attrIndex2_=-1;
+	groupIndex_=-1;
+	
+	geomIndex1_.clear();
+	geomIndex1_.push_back(-1);
+	geomIndex2_.clear();
+	geomIndex2_.push_back(-1);
+	timeIndex1_.clear();
+	timeIndex1_.push_back(-1);
+	timeIndex2_.clear();
+	timeIndex2_.push_back(-1);
+
+	//all vectors contains attributes with the table name and in upper case
+	vector<string>	attrs_select;	//contains the attributes that will be used to fill the TeSTInstance
+	vector<string>	geoms_select;	//contains the geometry attributes 
+	vector<string>	times_select;	//contains the date time attributes, when they are not in the attrs_select
+	vector<string>	unique_select;	//contains the unique attributes, when they are not in the attrs_select
+	
+	//------------------------------------------- begin get information
+	//get database
+	TeDatabase* db = params_->theme()->layer()->database();
+
+	//get attribute tables
+	TeAttrTableVector atts; 
+	params_->theme()->getAttTables(atts); 
+	
+	//verify if will be group the objects	
+	TeGroupingAttr groups = params_->groupAttr();  
+	bool groupAttr = !(groups.empty());
+		
+	//verify if the theme has collection table
+	bool hasCollTable = false;
+	legendIdGroup_.clear();
+	legendIdGroup_[0]=0;
+	if(db->tableExist(params_->theme()->collectionAuxTable()))
+	{
+		TeLegendEntryVector& legVec = params_->theme()->legend();
+		for(unsigned int l=0; l<legVec.size(); ++l)
+			legendIdGroup_[legVec[l].id()]=legVec[l].group();
+		hasCollTable = true;
+	}
+		
+	clearVectors();
+	params_->setLoadAttrs(params_->loadSetedAttrs()); //the original data
+	
+	//get the link name - the first attribute table or geometry table
+	linkName_ = rep.tableName_ +".object_id"; 
+	if(atts.size() > 0)
+		linkName_ = atts[0].name() +"."+ atts[0].linkName(); 
+			
+	if(params_->loadGeom())
+		geomRepr_.push_back(rep);
+	
+	//------------------------------------------- end get information
+	
+	//------------------------------------------- begin information to mount SQL
+	// -------- from
+	bool fromNeedGeomTable = false;
+	bool fromNeedCollTable = false;
+	
+	if(params_->loadGeom() || params_->hasSpatialRes() || atts.empty())
+		fromNeedGeomTable = true;
+	if(hasCollTable)
+		fromNeedCollTable = true;
+
+	// -------- group and order by 
+	bool useGroupByClause = false;	//group by object_id
+	bool useOrderByClause = false;  //order by object_id, geom_id
+	//Use group by clause when 
+	//1)it must group the attributes and 
+	//2)it must not load geometry and 
+	//3)all statistic functions exist in the SGBD 
+	string sGroup="";
+	if(groupAttr)
+	{
+		if(params_->loadGeom())
+			useGroupByClause = false; 
+		else
+		{
+			sGroup = db->getSQLStatistics(groups);
+			isGroup_ = true;
+			TeGroupingAttr::iterator it = groups.begin();
+			while(it!= groups.end())
+			{
+				if(it->second != TeNOSTATISTIC)
+					isGroup_ = false;
+				++it;
+			}
+			if(isGroup_)
+				useGroupByClause = true; 
+		}
+		groupInMemory_ = !useGroupByClause;
+	}
+	else
+		useOrderByClause = true;
+
+	// -------- select
+	bool selectNeedGeom = false;
+	if(params_->loadGeom())
+		selectNeedGeom = true;
+	
+	//------------------------------------------- end information to mount SQL
+	
+	//------------------------------------------- begin mount SQL
+	// order and group by clause
+	orderByClause = " ORDER BY "+ linkName_; 
+	if(selectNeedGeom)
+		orderByClause += ", "+ rep.tableName_ +".geom_id";
+	groupByClause = " GROUP BY "+ linkName_;
+
+	// ------------- select clause
+	if(groupAttr)
+	{
+		if(!groupInMemory_) //use statistic function database
+		{
+			bool flag = true;
+			string auxS = sGroup;
+			while(flag)
+			{
+				size_t pos = auxS.find(",", 0, 1);
+				if (pos == string::npos)
+				{
+					attrs_select.push_back(auxS);
+					flag = false;
+				}
+				else
+				{
+					attrs_select.push_back(auxS.substr(0, pos));
+					auxS = auxS.substr(pos+1);
+				}
+			}
+		}
+		else //load the attributes from TeGroupingAttr
+		{
+			//fill select clause from set of attributes
+			string lastAttr = "";
+			TeGroupingAttr::iterator it = groups.begin(); 
+			while(it!= groups.end())
+			{
+				if(lastAttr != it->first.name_) 
+					attrs_select.push_back(it->first.name_);
+				lastAttr = it->first.name_;
+				++it;
+			}
+
+			// select datatime information
+			if(!attrTable_.name().empty())
+			{
+				times_select.push_back(attrTable_.name()+"."+attrTable_.attInitialTime());
+
+				if(attrTable_.attInitialTime()!=attrTable_.attFinalTime())
+					times_select.push_back(attrTable_.name()+"."+attrTable_.attFinalTime());
+			}
+		}
+	}
+	else // load all attributes or the attributes that are in the vector
+	{
+		// get some information about the attribute tables required
+		for(unsigned int i=0; i<atts.size(); i++)
+		{
+			//date time information
+			if((atts[i].tableType()==TeAttrEvent) || (atts[i].tableType()==TeFixedGeomDynAttr))
+			{
+				attrTable_ = atts[i]; 
+				times_select.push_back(atts[i].name()+"."+attrTable_.attInitialTime());
+				times_select.push_back(atts[i].name()+"."+attrTable_.attFinalTime());
+			}
+		
+			//unique information
+			unique_select.push_back(atts[i].name()+"."+atts[i].uniqueName());
+			indexesAux.push_back(-1);
+						
+			//fill vector of attributes and sql string with all attributes
+			if(params_->loadAllAttr())
+			{
+				TeAttributeList::iterator itAttr = atts[i].attributeList().begin();
+				while(itAttr!= atts[i].attributeList().end())
+				{
+					string attribute = atts[i].name() +"."+ (*itAttr).rep_.name_;
+					attrs_select.push_back(attribute);
+                    ++itAttr;
+				}
+			}
+		}
+
+		if(!params_->loadAllAttr())
+		{
+			vector<string>::iterator itVec = params_->loadAttrs().begin();
+			while(itVec!=params_->loadAttrs().end())
+			{
+				//insert in select clause itVec: deve estar no formato tableName.attrName
+				attrs_select.push_back (*itVec);
+				++itVec;
+			}
+		}
+	}
+	
+	if(selectNeedGeom)
+	{
+		TeAttributeList attrs;
+		if (!db->getAttributeList(rep.tableName_, attrs))
+			return false; 
+
+		for(unsigned int i=0; i<attrs.size(); ++i)
+			geoms_select.push_back(rep.tableName_+"."+ attrs[i].rep_.name_);
+		
+		// order by clause
+		if((rep.geomRep_ == TePOLYGONS) && (db->dbmsName() != "OracleSpatial") && (db->dbmsName() != "PostGIS") )
+			orderByClause += ", parent_id ASC, num_holes DESC";
+	}
+	
+	// ------------- from and where clause
+	if(!fromNeedCollTable)
+	{
+		if(fromNeedGeomTable)
+			fromClause = " FROM " + tableJoin(atts, rep.tableName_, "object_id");
+		else
+			fromClause = " FROM " + tableJoin(atts);
+		
+		//if the theme does not have collection, it must apply its restrictions (attribute, temporal and spatial)
+		whereClause = params_->theme()->sqlWhereRestrictions(&rep); 
+	}
+	else
+	{
+		if(fromNeedGeomTable)
+			fromClause = params_->theme()->sqlGridFrom(rep.tableName_);
+		else
+			fromClause = params_->theme()->sqlGridFrom();
+	}
+
+	if(ent)
+	{
+		if(attrTable_.name().empty())
+			params_->theme()->getTemporalTable(attrTable_);
+
+		string iniTime = attrTable_.name()+"."+attrTable_.attInitialTime(); 
+		string finTime = attrTable_.name()+"."+attrTable_.attFinalTime(); 
+		if(!whereClause.empty())
+			whereClause += " AND ";
+
+		if ((params_->chronon()==TeMONTHOFYEAR) || (params_->chronon()==TeDAYOFWEEK))
+			whereClause += db->getSQLTemporalWhere(ent->timeInt_, ent->timeInt_, params_->chronon(), TeTIMEDURING, iniTime, finTime);    
+		else
+		{
+			TeTimeInterval interval = ent->time_;
+			interval.intervalChronon(params_->chronon());
+
+			whereClause += db->getSQLTemporalWhere(interval, TeTIMEDURING, iniTime, finTime);
+		}
+	}
+
+	if(!objectId().empty())
+	{
+		if(!whereClause.empty())
+			whereClause += " AND ";
+		
+		whereClause += linkName_ +" = '"+ objectId() +"'";  
+	}
+
+	//---------- mount select clause and get the indexes
+	unsigned int index=0;
+	unsigned int count=0;
+	selectClause = "";
+	uniqueIndex_[0] = indexesAux;
+	
+	//this attribute list can contain datetime, link and unique information
+	attrIndex1_ = count;
+	for(index=0; index<attrs_select.size(); ++index)
+	{
+		if(!selectClause.empty())
+			selectClause += ", ";
+		selectClause += attrs_select[index];
+		//link index
+		if(TeConvertToUpperCase(linkName_)==TeConvertToUpperCase(attrs_select[index]))
+			linkIndex_[0] = count;
+		//unique index
+		for(unsigned int i=0; i<unique_select.size(); ++i)
+		{
+			if(TeConvertToUpperCase(unique_select[i])==TeConvertToUpperCase(attrs_select[index]))
+				uniqueIndex_[0][i] = count;
+		}
+		
+		//time index
+		for(unsigned int i=0; i<times_select.size(); ++i)
+		{
+			if(TeConvertToUpperCase(times_select[i])==TeConvertToUpperCase(attrs_select[index]))
+			{
+				if(i==0)
+					timeIndex1_[0] = count;
+				else
+					timeIndex2_[0] = count;
+			}
+		}
+		if(timeIndex1_[0]>=0 && timeIndex2_[0]<0)
+			timeIndex2_[0] = timeIndex1_[0];
+		
+		attrIndex2_ = count;
+		++count;
+	}
+
+	//link attribute
+	if(linkIndex_[0]<0)
+	{
+		if(!selectClause.empty())
+			selectClause += ", ";
+		selectClause += linkName_;
+		linkIndex_[0] = count;
+		++count;
+	}
+	
+	//unique attributes
+	for(index=0; index<unique_select.size(); ++index)
+	{
+		if(uniqueIndex_[0][index]<0)
+		{
+			//verify if the unique name is equal to link name
+			if(TeConvertToUpperCase(unique_select[index]) == TeConvertToUpperCase(linkName_))
+				uniqueIndex_[0][index] = linkIndex_[0];
+			else
+			{
+				//adds the unique attributes that were not added
+				if(!selectClause.empty())
+					selectClause += ", ";
+				selectClause += unique_select[index];
+				uniqueIndex_[0][index] = count; 
+				++count;
+			}
+		}
+	}
+
+	//group index
+	if(hasCollTable)
+	{
+		if(!selectClause.empty())
+			selectClause += ", ";
+		if(useGroupByClause)
+			selectClause += " MIN("+ params_->theme()->collectionTable()+".c_legend_id )";
+		else
+			selectClause += params_->theme()->collectionTable()+".c_legend_id";
+			
+		groupIndex_ = count;
+		++count;
+	}
+
+	//time attributes
+	if(timeIndex1_[0]<0 && (!times_select.empty()))
+	{
+		timeIndex1_[0] = count;
+		for(index=0; index<times_select.size(); ++index)
+		{
+			if(!selectClause.empty())
+				selectClause += ", ";
+			selectClause += times_select[index];
+			timeIndex2_[0] = count;
+			++count;
+		}
+	}
+
+	//geometries
+	if(!geoms_select.empty())
+		geomIndex1_[0] = count;
+	for(index=0; index<geoms_select.size(); ++index)
+	{
+		if(!selectClause.empty())
+			selectClause += ", ";
+		selectClause += geoms_select[index];
+		geomIndex2_[0] = count;
+		++count;
+	}
+	
+	//---------- querier restriction
+	string sqlQuerierRest = sqlWhereRestrictions(&rep);
+	if(!whereClause.empty())
+		whereClause += " AND ";
+
+	whereClause += sqlQuerierRest;
+
+	fromClause_ = fromClause;
+	whereClause_ = whereClause;
+    string sql = "SELECT "+ selectClause + fromClause;
+	if(!whereClause.empty())
+		sql += " WHERE "+ whereClause;
+	
+	if(useGroupByClause)
+		sql += " "+ groupByClause;
+	else
+		sql += " "+ orderByClause;
+	
+	//------------------------------------------- end mount SQL
+
+	// --------- Submit the query
+	portals_.clear();
+	TeDatabasePortal* portal = db->getPortal();
+	
+	if(!portal)
+		return false;
+	
+	if(!portal->query(sql))
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	if(!portal->fetchRow())
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	string id = portal->getData(linkIndex_[0]);
+	bool flag = true;
+	while(id.empty() && flag) 
+	{
+		flag = portal->fetchRow();
+		if(flag)
+			id = portal->getData(0); //object_Id
+	}
+	
+	if(id.empty() || (!flag))
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	portals_.push_back (portal);
+	flagPortal_ = true;
+	lastObjId_ ="";
+	return true;
+}
+
+bool 
+TeQuerierDBStr1::initGeomPortal(TeRepresentation& rep, TeTSEntry* ent)
+{
+	string selectClause, fromClause, whereClause, orderByClause, parClause;
+	string initialTime, finalTime;
+	string uniqueName;
+	vector<int> indexesAux;
+	linkIndex_.push_back(-1); 
+	geomIndex1_.push_back(-1);
+	geomIndex2_.push_back(-1);
+	timeIndex1_.push_back(-1);
+	timeIndex2_.push_back(-1);
+	
+	TeDatabase* db = params_->theme()->layer()->database();
+
+	//------- Get geometry table
+	geomRepr_.push_back(rep);
+	if(rep.tableName_.empty())
+		return false;
+
+	int ind = linkIndex_.size()-1; //the last position in the vectors
+	
+	selectClause = linkName_; 
+	orderByClause = " ORDER BY "+ linkName_;  
+	linkIndex_[ind] = 0;
+	
+	if((rep.geomRep_ == TePOLYGONS) && (db->dbmsName() != "OracleSpatial") && (db->dbmsName() != "PostGIS") )
+		orderByClause += " , parent_id ASC, num_holes DESC";
+	
+	//------- Get temporal attribute 
+	if(!attrTable_.name().empty())
+	{
+		initialTime = attrTable_.name() +"."+ attrTable_.attInitialTime ();
+		finalTime = attrTable_.name() +"."+ attrTable_.attFinalTime ();
+			
+		// fill vector of unique name 
+		uniqueName = attrTable_.name()+"."+attrTable_.uniqueName();
+								
+		selectClause += ", "+ uniqueName;
+		indexesAux.push_back(1);
+		selectClause += ", "+ initialTime;
+		timeIndex1_[ind] = 2;
+		timeIndex2_[ind] = 2;
+
+		if (initialTime != finalTime)
+		{
+			selectClause += ", "+ finalTime;
+			timeIndex2_[ind] = 3;
+		}
+	}
+
+	//adds geometry attributes
+	selectClause += ","+ rep.tableName_ +".* ";
+	uniqueIndex_[ind] = indexesAux;
+	if(indexesAux.empty())
+		geomIndex1_[ind] = 1;
+	else if(timeIndex1_[ind]==timeIndex2_[ind])
+		geomIndex1_[ind] = 3;
+	else
+		geomIndex1_[ind] = 4;
+	
+	if(!db->tableExist(params_->theme()->collectionAuxTable()))
+	{
+		TeAttrTableVector atts; 
+		params_->theme()->getAttTables(atts); 
+
+		if(atts.empty())
+			return false;
+
+		fromClause = " FROM " + tableJoin(atts, rep.tableName_, "object_id");
+		whereClause = params_->theme()->sqlWhereRestrictions(&rep);
+	}
+	else
+		fromClause = params_->theme()->sqlGridFrom(rep.tableName_);
+	
+	if(ent)
+	{
+		string iniTime = attrTable_.name()+"."+initialTime;
+		string finTime = attrTable_.name()+"."+finalTime;
+		if(!whereClause.empty())
+			whereClause += " AND ";
+
+		if ((params_->chronon()==TeMONTHOFYEAR) || (params_->chronon()==TeDAYOFWEEK))
+			whereClause += db->getSQLTemporalWhere(ent->timeInt_, ent->timeInt_, params_->chronon(), TeTIMEDURING, iniTime, finTime);    
+		else
+		{
+			TeTimeInterval interval = ent->time_;
+			interval.intervalChronon(params_->chronon());
+
+			whereClause += db->getSQLTemporalWhere(interval, TeTIMEDURING, iniTime, finTime);
+		}
+	}
+
+	//where clause
+	if(!objectId().empty())
+	{
+		if(!whereClause.empty())
+			whereClause += " AND ";
+		
+		whereClause += rep.tableName_+".object_id = '"+ objectId() +"'";  
+	}
+
+	//---------- querier restriction
+	string sqlQuerierRest = sqlWhereRestrictions(&rep);
+	if(!whereClause.empty())
+		whereClause += " AND ";
+
+	whereClause += sqlQuerierRest;
+
+	//----------
+
+	string sql = "SELECT "+ selectClause + fromClause;
+	if(!whereClause.empty())
+		sql += " WHERE "+ whereClause;
+	sql += orderByClause;
+
+	//------ Submit the query
+	TeDatabasePortal* portal = db->getPortal();
+	if(!portal)
+		return false;
+	
+	if(!portal->query(sql))
+	{
+		delete portal;
+		return false;
+	}
+
+	if(portal->fetchRow())
+		portals_.push_back (portal); 
+	else
+		delete portal;
+
+	return true;
+}
+
+
+// ---------- final - initPortal
+// It is used in two cases:
+// 1) when it must return all instances of an object 
+// 2) when the attributes was grouped by sql functions - without geometry 
+
+bool
+TeQuerierDBStr1::fillSTOGrouped(TeSTInstance& sto, bool fetchInstance)
+{
+	if(portals_.empty()) 
+		return false;
+
+	TeDatabasePortal* portal = portals_[0]; 
+	if(!portal) 
+		return false; 
+
+	TeRepresentation* rep = 0;
+	if(!geomRepr_.empty())
+		rep = &(geomRepr_[0]);
+
+	TeTime  minT1, maxT2;
+	
+	// builds a ST object instance
+	TeTime t1, t2;
+	vector<string> attrValues;
+
+	// verify if exist several geometries for an object
+	bool flagGeom = true;
+	while(flagGeom && fetchInstance)
+	{
+		sto.objectId (portal->getData(linkIndex_[0]));
+						
+		if(rep && (!params_->loadGeom()))
+		{
+			int geomId = portal->getInt(rep->tableName_ +".geom_id");
+			
+			if(sto.objectId()==lastObjId_) 
+			{
+				if (geomId_!=geomId)
+				{
+					flagGeom = portal->fetchRow();
+					continue;
+				}
+			}
+			else
+				geomId_ = geomId;
+		}
+		flagGeom = false;
+	}	
+	
+	// ------------- begin fill attribute
+	// process the records filling the parameters of each instance
+	TeAttributeList& attrsPortal = portal->getAttributeList();
+	
+	//get the attributes
+	for(int s=attrIndex1_; s<=attrIndex2_; ++s)
+	{
+		if(s<0)
+			break;
+		attrValues.push_back(portal->getData(s));
+		if(!fetchInstance) //fill the attribute list
+			attrList_->push_back(attrsPortal[s]);
+	}
+
+	//get the group index
+	if(groupIndex_!=-1)
+	{
+		int gIndex = portal->getInt(groupIndex_);
+		sto.setSlice(legendIdGroup_[gIndex]);
+	}
+	
+	if(isGroup_)  // it was grouped by sql functions and without geometry 
+		sto.addUniqueId(string(portal->getData(linkIndex_[0])));
+	else
+	{
+		//unique id
+		for(unsigned int s=0; s<uniqueIndex_[0].size(); ++s)
+		{
+			string uniqueValue = portal->getData(uniqueIndex_[0][s]);
+			sto.addUniqueId(uniqueValue);
+		}
+
+		//date time information
+		if(timeIndex1_[0]>=0 && timeIndex2_[0]>=0)
+		{
+			t1 = portal->getDate(timeIndex1_[0]);
+			t2 = portal->getDate(timeIndex2_[0]);
+			sto.timeInterval(TeTimeInterval(t1,t2));
+		}
+	}
+
+	//! Set the property in the stoInstance
+	sto.setProperties(attrValues); 
+	sto.setAttrList(attrList_);
+
+	if(!fetchInstance) //only to get the attributes
+		return true;
+
+	// ------------- end fill attribute
+	//total time
+	if(t1.isValid() && t1<minT1)
+		minT1 = t1;
+	if(t2.isValid() && maxT2<t2)
+		maxT2 = t2;
+		
+	// ------------- begin fill geometries  
+	if(params_->loadGeom())
+	{
+		if(t1.isValid() && t2.isValid())
+			flagPortal_ = addGeometry(portal, rep->geomRep_, sto, linkIndex_[0], geomIndex1_[0], TeTimeInterval(t1,t2), timeIndex1_[0], timeIndex2_[0]);
+		else
+			flagPortal_ = addGeometry(portal, rep->geomRep_, sto, linkIndex_[0], geomIndex1_[0]);
+	}
+	else
+		flagPortal_ = portal->fetchRow();
+
+	// ------------- end fill geometries
+	
+	lastObjId_ = sto.objectId(); 
+	return true;
+}
+
+bool 
+TeQuerierDBStr1::fillGeomSTO(TeSTInstance& sto, unsigned int index)
+{
+	if((portals_.size()<(index+1)) || (geomRepr_.size()<(index+1)))
+		return false;
+
+	TeDatabasePortal* portal = portals_[index]; 
+	TeRepresentation rep = geomRepr_[index];
+	if(!portal)
+		return false; 
+
+	TeTimeInterval time = sto.timeInterval();
+	bool flag = false;
+	if(time.isValid())
+		flag = addGeometry(portal, rep.geomRep_, sto, linkIndex_[index], geomIndex1_[index], time, timeIndex1_[index], timeIndex2_[index]);
+	else
+		flag = addGeometry(portal, rep.geomRep_, sto, linkIndex_[index], geomIndex1_[index] );
+
+	if(flag==false)
+		flagPortal_ = false; 
+	
+	return true;
+}
+
+// It is used in a case:
+// 1) when the attributes of the object instances must be grouping in memory - with or without geometry 
+bool
+TeQuerierDBStr1::fillSTONoGrouped(TeSTInstance& sto)
+{
+	int s;
+	if(portals_.empty())
+		return false;
+
+	TeDatabasePortal* portal = portals_[0]; 
+	if(!portal) 
+		return false; 
+
+	TeRepresentation* rep = 0; 
+	if(!geomRepr_.empty())
+		rep = &(geomRepr_[0]);
+	
+	map<int, vector<double> >	valuesDouble;
+	map<int, vector<string> >	valuesString;
+	string lastObj = "";
+
+	TeAttributeList& attrsPortal = portal->getAttributeList();
+	
+	//get the group index
+	if(groupIndex_!=-1)
+	{
+		int gIndex = portal->getInt(groupIndex_);
+		sto.setSlice(legendIdGroup_[gIndex]);
+	}
+
+	//when there is spatial restriction, the querier can not group the attributes and
+	//get the geometry at the same time. In this case, it do not get the geometry.
+	if(!params_->loadGeom() || params_->hasSpatialRes())
+	{
+		int cont = 0;
+		do
+		{
+			string objId = portal->getData(linkIndex_[0]);
+			//if there is a spatial restriction, it groups all instances of all objects of the portal 
+			if(!params_->hasSpatialRes() && (!lastObj.empty() && objId != lastObj))
+				break;  
+					
+			string val = ""; 
+			//portal has the attributes that will be grouped 
+			for(s=attrIndex1_; s<=attrIndex2_; ++s)
+			{
+				if(s<0)
+					break;
+				val = portal->getData(s);
+				if((attrsPortal[s].rep_.type_==TeREAL) || (attrsPortal[s].rep_.type_==TeINT))
+				{
+					if(val.empty())
+						valuesDouble[s].push_back (TeMAXFLOAT);  //invalid value
+					else
+						valuesDouble[s].push_back (atof(val.c_str()));
+				}
+				else
+					valuesString[s].push_back(val);
+			}
+
+			flagPortal_ = portal->fetchRow();
+			lastObj = objId;
+			++cont;
+
+		} while(flagPortal_);
+	}
+	else // -- when it must fill the geometry
+	{		
+		//------- first: load the geometry, attributes and time of the first object 
+		//object id
+		lastObj = portal->getData(linkIndex_[0]);
+		
+		//attribute val
+		string val = ""; 
+		
+		for(s=attrIndex1_; s<=attrIndex2_; ++s)
+		{
+			val = portal->getData(s);
+			if((attrsPortal[s].rep_.type_==TeREAL) || (attrsPortal[s].rep_.type_==TeINT))
+			{
+				if(val.empty())
+					valuesDouble[s].push_back (TeMAXFLOAT);  //invalid value
+				else
+					valuesDouble[s].push_back (atof(val.c_str()));
+			}
+			else
+				valuesString[s].push_back (val);
+		}
+
+		//time
+		TeTime t1, t2;
+		if(!attrTable_.name().empty())
+		{
+			t1 = portal->getDate(timeIndex1_[0]);
+			t2 = portal->getDate(timeIndex2_[0]);
+		}
+		
+		sto.objectId(lastObj);
+		if(t1.isValid() && t2.isValid())
+			flagPortal_ = addGeometry(portal, rep->geomRep_, sto, linkIndex_[0], geomIndex1_[0], TeTimeInterval(t1,t2), timeIndex1_[0], timeIndex2_[0]);
+		else
+			flagPortal_ = addGeometry(portal, rep->geomRep_, sto, linkIndex_[0], geomIndex1_[0]);
+				
+		//------- second: load the attributes of the other objects
+		int cont = 0;   
+		while (flagPortal_)
+		{
+			string objId = portal->getData(linkIndex_[0]);
+			//if there is a spatial restriction, it groups all instances of all objects of the portal 
+			if(objId != lastObj)
+				break;  
+			
+			//same object id
+			string gId = portal->getData (geomIndex1_[0]);
+			int geomId = atoi(gId.c_str());
+			if(gId.empty())
+				geomId = cont;   
+			
+			if(!cont)
+				geomId_ = geomId;  //first geom_id 
+			
+			//verify the geomId
+			if(geomId==geomId_)   
+			{
+				flagPortal_ = portal->fetchRow();
+				lastObj = objId;
+				continue;
+			}
+							
+			val = ""; 
+			for(s=attrIndex1_; s<=attrIndex2_; ++s)
+			{
+				val = portal->getData(s);
+				if((attrsPortal[s].rep_.type_==TeREAL) || (attrsPortal[s].rep_.type_==TeINT))
+				{
+					if(val.empty())
+						valuesDouble[s].push_back (TeMAXFLOAT);  //invalid value
+					else
+						valuesDouble[s].push_back (atof(val.c_str()));
+				}
+				else
+					valuesString[s].push_back (val);
+			}
+
+			flagPortal_ = portal->fetchRow();
+			lastObj = objId; 
+			++cont;
+		}
+	}
+
+	//fill the property from portal 
+	//calculate the statistics
+	string lastAttr = "";
+	unsigned int j=0;
+	string colName = "";
+	TeGroupingAttr::iterator it = params()->groupAttr().begin(); 
+
+	TeStatisticValMap		statDouble;
+	TeStatisticStringValMap statString;
+	
+	TeAttrDataType attrType = TeSTRING;
+	while(it!=params()->groupAttr().end())
+	{
+		if(lastAttr != it->first.name_)
+		{
+			statDouble.clear();
+			statString.clear();
+			//if((it->first.type_==TeREAL) || (it->first.type_==TeINT))
+			if((attrsPortal[j].rep_.type_==TeREAL) || (attrsPortal[j].rep_.type_==TeINT))
+			{
+				TeCalculateStatistics(valuesDouble[j].begin(), valuesDouble[j].end(), statDouble);
+				attrType = TeREAL;
+			}
+			else
+			{
+				TeCalculateStatistics(valuesString[j].begin(), valuesString[j].end(), statString);
+				attrType = TeSTRING;
+			}
+			
+			colName = attrsPortal[j].rep_.name_;
+			++j;
+		}
+
+		double resultD=0;
+		string resultS="";
+		string prefix;
+		switch(it->second)
+		{
+			case TeCOUNT:
+				resultD = statDouble[TeCOUNT]; 
+				resultS = statString[TeCOUNT];
+				prefix = "count";
+				break;
+			case TeVALIDCOUNT:
+				resultD = statDouble[TeVALIDCOUNT]; 
+				resultS = statString[TeVALIDCOUNT];
+				prefix = "valCount";
+				break;
+			case TeMINVALUE:
+				resultD = statDouble[TeMINVALUE];
+				resultS = statString[TeMINVALUE];
+				prefix = "min";
+				break;
+			case TeMAXVALUE:
+				resultD = statDouble[TeMAXVALUE];
+				resultS = statString[TeMAXVALUE];
+				prefix = "max";
+				break;
+			case TeSUM:
+				resultD = statDouble[TeSUM]; 
+				prefix = "sum";
+				break;
+			case TeMEAN:
+				resultD = statDouble[TeMEAN]; 
+				prefix = "mean";
+				break;
+			case TeSTANDARDDEVIATION:
+				resultD = statDouble[TeSTANDARDDEVIATION];
+				prefix = "stDeviation";
+				break;
+			case TeVARIANCE:
+				resultD = statDouble[TeVARIANCE];
+				prefix = "variance";
+				break;
+			case TeSKEWNESS:
+				resultD = statDouble[TeSKEWNESS];
+				prefix = "skwness";
+				break;
+			case TeKURTOSIS:
+				resultD = statDouble[TeKURTOSIS]; 
+				prefix = "kurtosis";
+				break;
+			case TeAMPLITUDE:
+				resultD = statDouble[TeAMPLITUDE]; 
+				prefix = "amplitude";
+				break;
+			case TeMEDIAN:
+				resultD = statDouble[TeMEDIAN]; 
+				prefix = "median";
+				break;
+			case TeVARCOEFF:
+				resultD = statDouble[TeVARCOEFF]; 
+				prefix = "varcoeff";
+				break;
+			case TeMODE: 
+				resultD = statDouble[TeMODE]; 
+				prefix = "mode";
+				break;
+			default:
+				break;
+		}
+		
+		lastAttr = it->first.name_; 
+		++it;
+
+		//fill the property 
+		if(attrType == TeREAL)
+			sto.addPropertyValue(Te2String(resultD));
+		else
+			sto.addPropertyValue(resultS);
+	}
+	
+	//adds the property in the stoInstance
+	if(!params_->hasSpatialRes())
+	{
+		sto.addUniqueId(lastObj);
+		sto.objectId(lastObj);
+	}
+	sto.setAttrList(attrList_);
+
+	lastObjId_ = sto.objectId(); 
+	return true;
+}
+
+
+bool
+TeQuerierDBStr1::loadInstances(TeTSEntry* ent)
+{
+	if(!params_->theme())
+		return false;
+
+	TeRepresPointerVector repres = params_->theme()->layer()->vectRepres();
+	TeRepresentation rep;
+	
+	//fill instances - first fill the geometry representation of the spatial restriction 
+	if(params_->theme()->hasSpatialRest())
+		rep = **(TeFindRepresentation(repres.begin(), repres.end(), params_->theme()->geomRepRestriction()));
+	else
+	{
+		for(int i=0; i<(int)repres.size(); ++i)
+		{
+			rep = *repres[i];
+			break;
+		}
+	}
+	
+	if(!initPortal(rep, ent))
+		return false;
+
+	//get the attribute list
+	attrList_->clear();
+	if(!groupInMemory_)
+	{
+		TeSTInstance i;
+		fillSTOGrouped(i, false);
+	}
+	else
+	{
+		TeGroupingAttr::iterator it = params()->groupAttr().begin();
+		while(it!=params()->groupAttr().end())
+		{
+			TeAttribute at;
+			at.rep_ = it->first;
+			attrList_->push_back (at);
+			++it;
+		}
+	}
+			
+	if(!params_->loadGeom())
+		return true;
+
+	//set a invalid box
+	TeBox box;
+	params_->box(box);
+	
+	for(unsigned int i=0; i<repres.size(); ++i)
+	{
+		if(repres[i]->geomRep_ == rep.geomRep_)
+			continue;
+
+		if(!initGeomPortal(*(repres[i]), ent))
+		{
+			clearVectors();
+			return false;
+		}
+	}
+	return true;
+}
+
+bool 
+TeQuerierDBStr1::fetchInstance(TeSTInstance&  sto)  
+{
+	sto.clear();
+	bool flag = false;
+
+	if(!flagPortal_)
+	{
+		clearVectors();
+		return false;
+	}
+
+	if(groupInMemory_)
+		flag = fillSTONoGrouped(sto); 
+	else
+		flag = fillSTOGrouped(sto); 
+	
+	if((flag==false) || (!params_->loadGeom()))
+		return flag;
+    	
+	for(unsigned int i=1; i<portals_.size(); ++i)
+		flag = fillGeomSTO(sto, i);
+
+	updateBox(params_->box(), sto.getGeometries().getBox());
+	return flag;
+}
+
+int 
+TeQuerierDBStr1::numElemInstances()
+{
+	//from clause has the geom table
+	if(params_->loadGeom() || params_->hasSpatialRes())
+	{
+		//load the attribute tables
+		TeAttrTableVector atts; 
+		params_->theme()->getAttTables(atts); 
+		if(atts.empty())
+			return 0;
+
+		string selectClause = " DISTINCT ";
+		for(unsigned int i=0; i<atts.size(); ++i)
+		{
+			if(i>0)
+				selectClause+= ",";
+			selectClause+= atts[i].name() +"."+ atts[i].linkName();
+
+			if(atts[i].linkName()!=atts[i].uniqueName())
+				selectClause+= ","+ atts[i].name() +"."+ atts[i].uniqueName();
+		}
+		
+        string sql = "SELECT "+ selectClause + fromClause_;
+		if(!whereClause_.empty())
+			sql += " WHERE "+ whereClause_;
+
+		TeDatabasePortal* portal = params_->theme()->layer()->database()->getPortal();
+		if(!portal)
+			return 0;
+		
+		if(!portal->query(sql) || !portal->fetchRow())
+		{
+			delete (portal);
+			return 0;
+		}
+		int result = portal->numRows();
+		delete portal;
+		return result;
+	}
+		
+	if((portals_.empty()))
+		return 0;
+
+	//get the first portal
+	if(!portals_[0])
+		return 0;
+
+	return (portals_[0]->numRows());
+}
+
+
+
+
diff --git a/src/terralib/kernel/TeQuerierDBStr1.h b/src/terralib/kernel/TeQuerierDBStr1.h
new file mode 100644
index 0000000..7f71719
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDBStr1.h
@@ -0,0 +1,123 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+/*! \file TeQuerierDBStr1.h
+	\brief This file contains a mechanism named "TeQuerierDBStr1" that is 
+	responsible for loading spatio-temporal elements from a TerraLib database. 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_QUERIER_DBSTR1_H
+#define  __TERRALIB_INTERNAL_QUERIER_DBSTR1_H
+
+#include "TeQuerierDB.h"
+
+/*! \class TeQuerierDBStr1
+	\brief A class responsible for loading spatio-temporal elements from a TerraLib database.
+
+	This class implements a mechanism that is responsible for loading 
+	spatio-temporal elements from a TerraLib database, following a specific strategy. 
+	Each spatio-temporal elements is represented through a TeSTInstance class. 
+	This class is internally used by the factory of queriers. It should NOT be used 
+	by anyone. 
+
+	\sa
+	TeQuerierDB TeQuerierParams TeSTInstance 
+*/
+class TL_DLL TeQuerierDBStr1 : public TeQuerierDB
+{
+private:		
+	vector<string>				uniqueNames_;
+	string						lastObjId_;
+	int							geomId_;
+	bool						isGroup_;			//! if the portal was built with statistics sql funcionts
+	bool						groupInMemory_;		//! if it must group the object instances in the memory 
+	string						linkName_;
+	
+	string						fromClause_;   //store the sql clause(from and where) to return the number of instances
+	string						whereClause_;
+	
+	/* @name Internal functions to initialize portals */
+	//@{
+	bool initPortal(TeRepresentation& rep, TeTSEntry* ent=0);     
+	bool initGeomPortal(TeRepresentation& rep, TeTSEntry* ent=0); 
+	//@}
+
+	/* @name Internal functions to fill the STOs from portals */
+	//@{
+	bool fillSTOGrouped(TeSTInstance& sto, bool fetchInstance = true);
+	bool fillSTONoGrouped(TeSTInstance& sto);
+	bool fillGeomSTO(TeSTInstance& sto, unsigned int index);
+	//@}
+
+public:
+	//! Constructor
+	TeQuerierDBStr1(TeQuerierParams* params) : 
+		TeQuerierDB(params), 
+		lastObjId_(""),
+		isGroup_(false),
+		groupInMemory_(false),
+		linkName_(""),
+		fromClause_(""),
+		whereClause_("")
+	{}
+	
+	//! Loads instances
+	bool loadInstances(TeTSEntry* ent=0); 
+	
+	//! Returns each loaded instance
+	bool fetchInstance(TeSTInstance&  sto); 
+
+	//! Returns the number of instances 
+	int numElemInstances(); 
+};
+
+/*! \class TeQuerierDBStr1Factory
+	\brief A class that define a factory to build a querier strategy (strategy 1) from TerraLib database.
+
+	\sa
+	TeQuerierImplFactory TeQuerierDBStr1
+*/
+class TL_DLL TeQuerierDBStr1Factory : public TeQuerierImplFactory
+{
+public:
+	//! Constructor
+	TeQuerierDBStr1Factory(const string& name) : TeQuerierImplFactory(name) {}
+
+	//! Builds a database querier
+	virtual TeQuerierImpl* build (const TeQuerierParams& arg)
+	{  
+		TeQuerierParams* tempArg = new TeQuerierParams();
+		*tempArg = arg;
+		return new TeQuerierDBStr1(tempArg); 
+	}
+};
+
+//! Creates a static factory to build TeQuerierDBStr1 
+namespace 
+{
+  static TeQuerierDBStr1Factory querierDBStr1("querierDBStr1");
+};
+
+
+#endif
+
diff --git a/src/terralib/kernel/TeQuerierDBStr2.cpp b/src/terralib/kernel/TeQuerierDBStr2.cpp
new file mode 100644
index 0000000..13b41bb
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDBStr2.cpp
@@ -0,0 +1,350 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeQuerierDBStr2.h"
+#include "TeDatabase.h"
+#include "TeSTInstance.h"
+
+//It must group the attributes of ONE attribute table using DBMS functions
+// and do not load geometries. It must be used with theme (with collection table).
+bool
+TeQuerierDBStr2::initPortal(TeTSEntry* ent)  
+{
+	string selectClause, fromClause, whereClause, groupByClause;
+	string initialTime, finalTime;
+	linkIndex_.clear();
+	linkIndex_.push_back(-1); 
+	attrIndex1_=-1;
+	attrIndex2_=-1;
+	timeIndex1_.clear();
+	timeIndex1_.push_back(-1);
+	timeIndex2_.clear();
+	timeIndex2_.push_back(-1);
+	groupIndex_=-1;
+
+	TeDatabase* db = params_->theme()->layer()->database();
+
+	if(params_->groupAttr().empty())
+		return false;
+
+	//get the table name (there is only one attribute table)
+	string tableName;
+	TeGroupingAttr groupAttr = params_->groupAttr();
+	TeGroupingAttr::iterator it = groupAttr.begin();
+	size_t pos = (it->first.name_).find(".", 0, 1);
+	if (pos != string::npos)
+		tableName = (it->first.name_).substr(0,pos);
+
+	//group information
+	legendIdGroup_.clear();
+	legendIdGroup_[0]=0;
+	TeLegendEntryVector& legVec = params_->theme()->legend();
+	for(unsigned int l=0; l<legVec.size(); ++l)
+		legendIdGroup_[legVec[l].id()]=legVec[l].group();
+		
+	clearVectors();
+
+	// ---------------------------------------------  Mount SQL
+	
+	//------- Select and Group By clause
+	//load the attribute table 
+	int index = -1;
+	TeAttrTableVector attr = params_->theme()->attrTables();
+	for(unsigned int i=0; i<attr.size(); ++i)
+	{
+		if(TeConvertToUpperCase(attr[i].name()) == TeConvertToUpperCase(tableName))
+		{
+			index = i;
+			attrTable_ = attr[i];
+			break;
+		}
+	}
+	
+	//not find the table
+	if(index<0)
+		return false;
+
+	//verify the attribute table
+	if((ent) && (attrTable_.tableType()!=TeAttrEvent) && (attrTable_.tableType()!=TeFixedGeomDynAttr))
+		return false;
+ 	
+	//object_id
+	string linkName; 
+	if(attrTable_.tableType() != TeAttrExternal)
+		linkName = attrTable_.name() +"."+ attrTable_.linkName(); 
+	else
+		linkName = params_->theme()->collectionTable() +".c_object_id "; 
+
+	if(params_->hasSpatialRes())
+		selectClause = " MIN("+ linkName +")";		
+	else
+		selectClause = linkName;	
+	linkIndex_[0]=0;
+
+	if(ent)
+	{
+		//date
+		initialTime = attrTable_.name() +"."+ attrTable_.attInitialTime();
+		
+		groupByClause = db->getSQLTemporalFunction(params_->chronon(), initialTime);
+		if(!params_->hasSpatialRes())
+			groupByClause += ","+ linkName;
+				
+		selectClause += ", MAX("+ initialTime +")";
+		timeIndex1_[0]=1;
+		timeIndex2_[0]=1;
+	}
+	else 
+		groupByClause = linkName;
+
+	
+	//statistic
+	selectClause += ","+ db->getSQLStatistics(groupAttr);  
+	if(timeIndex1_[0]<0)
+		attrIndex1_=1;
+	else
+		attrIndex1_=2;
+	attrIndex2_ = attrIndex1_+(params_->groupAttr().size()-1);
+
+	//group index
+	selectClause += ", MIN("+ params_->theme()->collectionTable()+".c_legend_id )";
+	groupIndex_ = attrIndex2_+1;		
+
+	//---- from clause 
+	if(params_->hasSpatialRes())
+	{
+		groupByClause = ""; //It groups all attributes from all objects 
+		string gTable = params_->theme()->layer()->tableName(params_->geomRepRest());
+		fromClause = this->sqlFrom(gTable);
+	}
+	else
+		fromClause = this->sqlFrom();
+	
+	if(fromClause.empty())
+		return false;
+	
+	//where clause
+	if(!params_->objId().empty())
+		whereClause = linkName +" = '"+ params_->objId() +"'";  
+
+	//---------- querier restriction
+	string sqlQuerierRest = sqlWhereRestrictions();
+	if(!whereClause.empty())
+		whereClause += " AND ";
+
+	whereClause += sqlQuerierRest;
+
+	//----------
+	
+	string sql = " SELECT "+ selectClause; 
+	sql += " FROM "+ fromClause;
+	if(!whereClause.empty())
+		sql += " WHERE "+ whereClause; 
+	if(!groupByClause.empty())
+		sql += " GROUP BY "+ groupByClause;
+	
+	// ---------------------------------------------  Submit the query
+	
+	portals_.clear();
+	TeDatabasePortal* portal = db->getPortal();
+	
+	if(!portal)
+		return false;
+	
+	if(!portal->query(sql))
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	if(!portal->fetchRow())
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	string id = portal->getData(linkIndex_[0]); //object_Id
+	bool flag = true;
+	while(id.empty() && flag) 
+	{
+		flag = portal->fetchRow();
+		if(flag)
+			id = portal->getData(linkIndex_[0]); //object_Id
+	}
+	
+	if(id.empty() || (!flag)) //se o id �vazio ou chegou ao final do portal 
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	portals_.push_back (portal);
+	flagPortal_ = true;
+	return true;
+}
+
+
+bool
+TeQuerierDBStr2::fillSTO(TeSTInstance& sto)  
+{
+	if(portals_.empty())
+		return false;
+
+	TeDatabasePortal* portal = portals_[0]; 
+	if(!portal) 
+		return false; 
+
+	if(!flagPortal_) // end of portal
+	{
+		clearVectors();
+		return false; 
+	}
+
+	if(TSEntry_.timeFrame_ > -1)
+	{
+		// first : verify the time
+		TeTime t1 = portal->getDate(timeIndex1_[0]);		
+		t1.chronon ((TSEntry_.time_).intervalChronon());
+			
+		//if the time is before the requested interval 
+		while ( (TSEntry_.time_).before(t1) && flagPortal_)
+		{
+			flagPortal_ = portal->fetchRow();
+			t1 = portal->getDate(timeIndex1_[0]);
+			t1.chronon ((TSEntry_.time_).intervalChronon());
+		}
+	
+		if(!(TSEntry_.time_).during(t1))
+			return false;
+		
+		TeTimeInterval interval(t1, t1);
+		sto.timeInterval(interval);
+
+		timeFramePortal_ = (TSEntry_.timeFrame_)+1; //next time frame 
+	}
+
+	//if there is spatial restriction, it groups all instances of all objects
+	if(!params_->hasSpatialRes())
+	{
+		// get object_id
+		string objId = string(portal->getData(linkIndex_[0]));  // 0: object_id
+		sto.objectId (objId);
+		sto.addUniqueId (objId);
+
+		//get the group index
+		if(groupIndex_!=-1)
+		{
+			int gIndex = portal->getInt(groupIndex_);
+			sto.setSlice(legendIdGroup_[gIndex]);
+		}
+	}
+
+	//get property
+	for(int s=attrIndex1_; s<=attrIndex2_; ++s)  
+		sto.addPropertyValue(string(portal->getData(s)));
+
+	sto.setAttrList(attrList_);
+	flagPortal_ = portal->fetchRow();
+	return true;
+}
+
+
+bool
+TeQuerierDBStr2::loadInstances(TeTSEntry* ent) 
+{
+	if(!params_->theme())
+		return false;
+
+	//set a invalid box
+	TeBox box;
+	params_->box(box);
+
+	if(ent)
+	{
+		//if the portal was not initialised (timeFramePortal_==-1) or
+		//if the time frame requested is lesser than the time frame appointed by the portal
+		if((timeFramePortal_<0) || (ent->timeFrame_<timeFramePortal_))
+		{
+			if(!initPortal(ent))
+				return false;
+
+			timeFramePortal_ = 0;
+		}
+		TSEntry_ = (*ent);
+	}
+	else // no chronon
+	{
+		if(!initPortal())
+			return false;
+ 
+		timeFramePortal_ = -1;
+	}
+
+	attrList_->clear();
+	TeAttribute at;
+	TeGroupingAttr::iterator it = params()->groupAttr().begin();
+	while(it!=params()->groupAttr().end())
+	{
+		TeAttribute at;
+		at.rep_ = it->first;
+		attrList_->push_back (at);
+		++it;
+	}
+
+	return true;
+}
+
+bool
+TeQuerierDBStr2::fetchInstance(TeSTInstance&  sto) 
+{
+	sto.clear();
+
+	if(!fillSTO(sto))
+		return false; 
+	
+	//build a temporal serie to one object
+	string val;
+	sto.getPropertyValue(val, 0);
+	if((ts_) && (ts_->setTSEntryValue(TSEntry_.timeFrame_, atof(val.c_str()), TeDATA)))
+		filledSerie_ = true;
+	
+	return true;
+}
+
+int 
+TeQuerierDBStr2::numElemInstances()
+{
+	if((portals_.empty()))
+		return 0;
+
+	//get the first portal
+	if(!portals_[0])
+		return 0;
+
+	return (portals_[0]->numRows());
+}
+
+
diff --git a/src/terralib/kernel/TeQuerierDBStr2.h b/src/terralib/kernel/TeQuerierDBStr2.h
new file mode 100644
index 0000000..3127c71
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDBStr2.h
@@ -0,0 +1,106 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeQuerierDBStr2.h
+	\brief This file contains a mechanism named "TeQuerierDBStr2" that is 
+	responsible for loading spatio-temporal elements from a TerraLib database. 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_QUERIER_DBSTR2_H
+#define  __TERRALIB_INTERNAL_QUERIER_DBSTR2_H
+
+#include "TeQuerierDB.h"
+#include "TeTemporalSeries.h"
+
+/*! \class TeQuerierDBStr2
+	\brief A class responsible for loading spatio-temporal elements from a TerraLib database.
+
+	This class implements a mechanism that is responsible for loading 
+	spatio-temporal elements from a TerraLib database, following a specific strategy (Strategy 2). 
+	Each spatio-temporal elements is represented through a TeSTInstance class. 
+	This class is internally used by the factory of queriers. It should NOT be used 
+	by anyone. This Strategy 2 works with simple chronon, without geometry, 
+	theme with collection table and existence operator in the DBMS.  
+
+	\sa
+	TeQuerierDB TeQuerierParams TeSTInstance 
+*/
+
+class TL_DLL TeQuerierDBStr2: public TeQuerierDB
+{
+private:
+	int				timeFramePortal_;  // the time frame appointed by the portal 
+	TeTSEntry		TSEntry_;
+	
+	/* @name Internal functions to initialize portals */
+	//@{
+	bool initPortal(TeTSEntry* ent=0); 
+	//@}
+
+	//! Internal function to fill STO
+	bool fillSTO(TeSTInstance& sto); 
+	
+public:
+	//! Constructor
+	TeQuerierDBStr2(TeQuerierParams* params): 
+		TeQuerierDB(params), 
+		timeFramePortal_(-1)
+	{} 
+
+	//! Loads the instances
+	bool loadInstances(TeTSEntry* ent=0); 
+
+	//! Returns each loaded STO
+	bool fetchInstance(TeSTInstance&  sto); 
+
+	//! Returns the number of instances 
+	int  numElemInstances();
+};
+
+/*! \class TeQuerierDBStr2Factory
+	\brief A class that define a factory to build a querier strategy (strategy 2) from TerraLib database.
+
+	\sa
+	TeQuerierImplFactory TeQuerierDBStr2
+*/
+class TL_DLL TeQuerierDBStr2Factory : public TeQuerierImplFactory
+{
+public:
+	//! Constructor
+	TeQuerierDBStr2Factory(const string& name) : TeQuerierImplFactory(name) {}
+
+	//! Builds a database querier
+	virtual TeQuerierImpl* build (const TeQuerierParams& arg)
+	{  
+		TeQuerierParams* tempArg = new TeQuerierParams();
+		*tempArg = arg;
+		return new TeQuerierDBStr2(tempArg); 
+	}
+};
+
+//! Creates a static factory to build TeQuerierDBStr2 
+namespace 
+{
+  static TeQuerierDBStr2Factory querierDBStr2("querierDBStr2");
+};
+
+#endif
diff --git a/src/terralib/kernel/TeQuerierDBStr3.cpp b/src/terralib/kernel/TeQuerierDBStr3.cpp
new file mode 100644
index 0000000..55d7dcc
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDBStr3.cpp
@@ -0,0 +1,421 @@
+ /************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include <TeQuerierDBStr3.h>
+#include <TeDatabase.h>
+#include <TeSTInstance.h>
+#include <TeLayer.h>
+
+//It must group the attributes of ONE attribute table and 
+//load geometries of ONE representation (cells or points) 
+//It must be used with theme (with collection table)
+bool
+TeQuerierDBStr3::initPortal(TeTSEntry* ent)  
+{
+	string selectClause, fromClause, whereClause, groupByClause;
+	string initialTime, finalTime;
+	linkIndex_.clear();
+	linkIndex_.push_back(-1); 
+	attrIndex1_=-1;
+	attrIndex2_=-1;
+	timeIndex1_.clear();
+	timeIndex1_.push_back(-1);
+	timeIndex2_.clear();
+	timeIndex2_.push_back(-1);
+	geomIndex1_.clear();
+	geomIndex1_.push_back(-1);
+	groupIndex_=-1;
+
+	TeDatabase* db = params_->theme()->layer()->database();
+
+	if(params_->groupAttr().empty())
+		return false;
+
+	//get the table name
+	string tableName;
+	TeGroupingAttr groupAttr = params_->groupAttr();
+	TeGroupingAttr::iterator it = groupAttr.begin();
+	size_t pos = (it->first.name_).find(".", 0, 1);
+	if (pos != string::npos)
+		tableName = (it->first.name_).substr(0,pos);
+
+	//group information
+	legendIdGroup_.clear();
+	legendIdGroup_[0]=0;
+	TeLegendEntryVector& legVec = params_->theme()->legend();
+	for(unsigned int l=0; l<legVec.size(); ++l)
+		legendIdGroup_[legVec[l].id()]=legVec[l].group();
+			
+	clearVectors();
+
+	// ---------------------------------------------  Monut SQL
+	
+	//------- Select and Group By clause
+
+	//load the attribute table 
+	int index = -1;
+	unsigned int i=0;
+	TeAttrTableVector attr = params_->theme()->attrTables();
+	for(i=0; i<attr.size(); ++i)
+	{
+		if(TeConvertToUpperCase(attr[i].name()) == TeConvertToUpperCase(tableName))
+		{
+			index = i;
+			attrTable_ = attr[i];
+			break;
+		}
+	}
+ 
+	//not find the table
+	if(index<0)
+		return false;
+
+	//verify the attribute table
+	if((ent) && (attrTable_.tableType()!=TeAttrEvent) && (attrTable_.tableType()!=TeFixedGeomDynAttr))
+		return false;
+
+	//geometric Table
+	TeAttributeList geomTableAttrs;
+	string geomTable;
+	if(params_->theme()->layer()->hasGeometry(TePOINTS))
+	{
+		geomTable = params_->theme()->layer()->tableName(TePOINTS);
+		if(!db->getAttributeList(geomTable, geomTableAttrs))
+			return false; 
+		rep_ = TePOINTS;
+	} 
+	else if (params_->theme()->layer()->hasGeometry(TeCELLS))
+	{
+		geomTable = params_->theme()->layer()->tableName(TeCELLS);
+		if(!db->getAttributeList(geomTable, geomTableAttrs))
+			return false; 
+		rep_ = TeCELLS;
+	}
+	else
+		return false; //this strategy is valid only for cells and point geometry
+
+	//object_id
+	string linkName = attrTable_.name() +"."+ attrTable_.linkName(); //geomTable.name()+ ".object_id ";
+	string uniqueIdName = attrTable_.name() +"."+ attrTable_.uniqueName(); 
+	
+	if(params_->hasSpatialRes())
+		selectClause = " MIN("+ linkName +")";		
+	else
+		selectClause = linkName;	
+	linkIndex_[0]=0;
+
+	if(ent)
+	{
+		//date
+		initialTime = attrTable_.name() +"."+ attrTable_.attInitialTime();
+
+		groupByClause = db->getSQLTemporalFunction(params_->chronon(), initialTime);
+		if(!params_->hasSpatialRes())
+			groupByClause += ","+ linkName;
+		
+		selectClause += ", MAX("+ initialTime +")";
+		timeIndex1_[0]=1;
+		timeIndex2_[0]=1;
+	}
+	else if(!params_->hasSpatialRes())
+		groupByClause = linkName;
+
+	//statistic
+	selectClause += ","+ db->getSQLStatistics(groupAttr);   
+	if(timeIndex1_[0]<0)
+		attrIndex1_=1;
+	else
+		attrIndex1_=2;
+	attrIndex2_ = attrIndex1_+(params_->groupAttr().size()-1);
+
+	//group index
+	selectClause += ", MIN("+ params_->theme()->collectionTable()+".c_legend_id )";
+	groupIndex_ = attrIndex2_+1;	
+	
+	//----- insert geometrical information in the select clause
+	for(i=0; i<geomTableAttrs.size(); ++i)
+		selectClause += ", MIN( "+ geomTable +"."+ geomTableAttrs[i].rep_.name_ +" ) AS "+ geomTableAttrs[i].rep_.name_;
+	geomIndex1_[0] = attrIndex2_+2;
+	//-----	
+
+	//------- From clause 
+	fromClause = this->sqlFrom(geomTable);
+	if(fromClause.empty())
+		return false;
+
+	//where clause
+	if(!params_->objId().empty())
+		whereClause = linkName +" = '"+ params_->objId() +"'";  
+
+	//---------- querier restriction
+	TeRepresentation rep;
+	rep.tableName_ = geomTable;
+	rep.geomRep_ = rep_;
+
+	string sqlQuerierRest = sqlWhereRestrictions(&rep);
+	if(!whereClause.empty())
+		whereClause += " AND ";
+
+	whereClause += sqlQuerierRest;
+
+	//----------
+	fromClause_ = fromClause;
+	whereClause_ = whereClause;
+
+	string sql = " SELECT "+ selectClause; 
+	sql += " FROM "+ fromClause; 
+	if(!whereClause.empty())
+		sql += " WHERE "+ whereClause; 
+	if(!groupByClause.empty())
+		sql += " GROUP BY "+ groupByClause;
+	
+	// ---------------------------------------------  Submit the query
+	
+	portals_.clear();
+	TeDatabasePortal* portal = db->getPortal();
+	
+	if(!portal)
+		return false;
+	
+	if(!portal->query(sql))
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	if(!portal->fetchRow())
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	string id = portal->getData(linkIndex_[0]); //object_Id
+	bool flag = true;
+	while(id.empty() && flag) 
+	{
+		flag = portal->fetchRow();
+		if(flag)
+			id = portal->getData(linkIndex_[0]); //object_Id
+	}
+	
+	if(id.empty() || (!flag))
+	{
+		delete (portal);
+		flagPortal_ = false;
+		return false;
+	}
+
+	portals_.push_back (portal);
+	flagPortal_ = true;
+	return true;
+}
+
+
+bool
+TeQuerierDBStr3::fillSTO(TeSTInstance& sto)  
+{
+	if(portals_.empty())
+		return false;
+
+	TeDatabasePortal* portal = portals_[0]; 
+	if(!portal) 
+		return false; 
+
+	if(!flagPortal_)  //end of portal
+	{
+		clearVectors();
+		return false; 
+	}
+
+	
+	// first : verify the time
+	if(TSEntry_.timeFrame_ > -1)
+	{
+		TeTime t1 = portal->getDate(timeIndex1_[0]);		
+		t1.chronon ((TSEntry_.time_).intervalChronon());
+		
+		//if the time is before the requested interval 
+		while ( (TSEntry_.time_).before(t1) && flagPortal_)
+		{
+			flagPortal_ = portal->fetchRow();
+			t1 = portal->getDate(timeIndex1_[0]);
+			t1.chronon ((TSEntry_.time_).intervalChronon());
+		}
+		
+		if(!(TSEntry_.time_).during(t1))
+			return false;
+		
+		TeTimeInterval interval(t1, t1);
+		sto.timeInterval(interval);
+
+		timeFramePortal_ = (TSEntry_.timeFrame_)+1; //next time frame 
+	}
+	
+	//if there is spatial restriction, it groups all instances of all objects
+	if(!params_->hasSpatialRes())
+	{
+		// get object_id
+		string objId = string(portal->getData(linkIndex_[0]));  // 0: object_id
+		sto.objectId (objId);
+		sto.addUniqueId (objId);
+
+		//get the group index
+		if(groupIndex_!=-1)
+		{
+			int gIndex = portal->getInt(groupIndex_);
+			sto.setSlice(legendIdGroup_[gIndex]);
+		}
+	}
+
+	sto.setAttrList(attrList_);
+
+	//get property
+	for(int s=attrIndex1_; s<=attrIndex2_; ++s)  
+		sto.addPropertyValue(portal->getData(s));
+
+	// get geometry 
+	if(rep_ == TePOINTS)
+	{
+		TePoint point;
+		flagPortal_ = portal->fetchGeometry(point,geomIndex1_[0]);
+		sto.addGeometry (point);
+	}
+	else
+	{
+		TeCell cell;
+		flagPortal_ = portal->fetchGeometry(cell, geomIndex1_[0]);
+		sto.addGeometry (cell);
+	}
+
+	return true;
+}
+
+
+bool
+TeQuerierDBStr3::loadInstances(TeTSEntry* ent) 
+{
+	if(!params_->theme())
+		return false;
+
+	//set a invalid box
+	TeBox box;
+	params_->box(box);
+
+	if(ent)
+	{
+		//if the portal was not initialised (timeFramePortal_==-1) or
+		//if the time frame requested is lesser than the time frame appointed by the portal
+		if((timeFramePortal_<0) || (ent->timeFrame_<timeFramePortal_))
+		{
+			if(!initPortal(ent))
+				return false;
+
+			timeFramePortal_ = 0;
+		}
+		TSEntry_ = (*ent);
+	}
+	else // no chronon
+	{
+		if(!initPortal())
+			return false;
+ 
+		timeFramePortal_ = -1;
+	}
+
+	attrList_->clear();
+	TeAttribute at;
+	TeGroupingAttr::iterator it = params()->groupAttr().begin();
+	while(it!=params()->groupAttr().end())
+	{
+		TeAttribute at;
+		at.rep_ = it->first;
+		attrList_->push_back (at);
+		++it;
+	}
+
+	return true;
+}
+
+
+bool
+TeQuerierDBStr3::fetchInstance(TeSTInstance&  sto)
+{
+	sto.clear();
+
+	if(!fillSTO(sto))
+		return false; 
+	
+	//build a temporal serie to one object
+	string val;
+	sto.getPropertyValue(val, 0);
+	if((ts_) && (ts_->setTSEntryValue(TSEntry_.timeFrame_, atof(val.c_str()), TeDATA)))
+		filledSerie_ = true;
+	
+	updateBox(params_->box(), sto.getGeometries().getBox());
+	return true;
+}
+
+int 
+TeQuerierDBStr3::numElemInstances()
+{
+	//load the attribute tables
+	TeAttrTableVector atts; 
+	params_->theme()->getAttTables(atts); 
+	if(atts.empty())
+		return 0;
+
+	string selectClause = " DISTINCT ";
+	for(unsigned int i=0; i<atts.size(); ++i)
+	{
+		if(i>0)
+			selectClause+= ",";
+		selectClause+= atts[i].name() +"."+ atts[i].linkName();
+
+		if(atts[i].linkName()!=atts[i].uniqueName())
+			selectClause+= ","+ atts[i].name() +"."+ atts[i].uniqueName();
+	}
+	
+    string sql = "SELECT "+ selectClause + fromClause_;
+	if(!whereClause_.empty())
+		sql += " WHERE "+ whereClause_;
+
+	TeDatabasePortal* portal = params_->theme()->layer()->database()->getPortal();
+	if(!portal)
+		return 0;
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete (portal);
+		return 0;
+	}
+	int result = portal->numRows();
+	delete portal;
+	return result;
+}
+
+
+
+
+
diff --git a/src/terralib/kernel/TeQuerierDBStr3.h b/src/terralib/kernel/TeQuerierDBStr3.h
new file mode 100644
index 0000000..7836ed9
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierDBStr3.h
@@ -0,0 +1,112 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeQuerierDBStr3.h
+	\brief This file contains a mechanism named "TeQuerierDBStr3" that is 
+	responsible for loading spatio-temporal elements from a TerraLib database.
+*/
+#ifndef  __TERRALIB_INTERNAL_QUERIER_DBSTR3_H
+#define  __TERRALIB_INTERNAL_QUERIER_DBSTR3_H
+
+#include "TeQuerierDB.h"
+#include "TeTemporalSeries.h"
+
+/*! \class TeQuerierDBStr3
+	\brief A class responsible for loading spatio-temporal elements from a TerraLib database.
+
+	This class implements a mechanism that is responsible for loading 
+	spatio-temporal elements from a TerraLib database, following a specific strategy (Strategy 3). 
+	Each spatio-temporal elements is represented through a TeSTInstance class. 
+	This class is internally used by the factory of queriers. It should NOT be used 
+	by anyone. This Strategy 2 works with simple chronon, with geometry (points or cells), 
+	theme with collection table and existence operator in the DBMS.  
+
+	\sa
+	TeQuerierDB TeQuerierParams TeSTInstance 
+*/
+
+class TL_DLL TeQuerierDBStr3: public TeQuerierDB
+{
+private:
+	int				timeFramePortal_;	// the time frame appointed by the portal 
+	TeTSEntry		TSEntry_;
+	TeGeomRep		rep_;
+
+	string						fromClause_;   //store the sql clause(from and where) to return the number of instances
+	string						whereClause_;
+		
+	/* @name Internal functions to initialize portals */
+	//@{
+	bool initPortal(TeTSEntry* ent=0); 
+	//@}
+
+	//! Internal function to fill STO
+	bool fillSTO(TeSTInstance& sto); 
+	
+public:	
+	//! Constructor
+	TeQuerierDBStr3(TeQuerierParams* params): 
+		TeQuerierDB(params), 
+		timeFramePortal_(-1),
+		fromClause_(""),
+		whereClause_("")
+	{} 
+
+	//! Loads the instances
+	bool loadInstances(TeTSEntry* ent=0); 
+
+	//! Returns each loaded STO
+	bool fetchInstance(TeSTInstance&  sto); 
+
+	//! Returns the number of instances 
+	int  numElemInstances();
+};
+
+/*! \class TeQuerierDBStr3Factory
+	\brief A class that define a factory to build a querier strategy (strategy 3) from TerraLib database.
+
+	\sa
+	TeQuerierImplFactory TeQuerierDBStr3
+*/
+class TL_DLL TeQuerierDBStr3Factory : public TeQuerierImplFactory
+{
+public:
+
+	//! Constructor
+	TeQuerierDBStr3Factory(const string& name) : TeQuerierImplFactory(name) {}
+
+	//! Builds a database querier
+	virtual TeQuerierImpl* build (const TeQuerierParams& arg)
+	{  
+		TeQuerierParams* tempArg = new TeQuerierParams();
+		*tempArg = arg;
+		return new TeQuerierDBStr3(tempArg); 
+	}
+};
+
+//! Creates a static factory to build TeQuerierDBStr3 
+namespace 
+{
+  static TeQuerierDBStr3Factory querierDBStr3("querierDBStr3");
+};
+
+#endif
diff --git a/src/terralib/kernel/TeQuerierImpl.cpp b/src/terralib/kernel/TeQuerierImpl.cpp
new file mode 100644
index 0000000..46b993b
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierImpl.cpp
@@ -0,0 +1,144 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeQuerierImpl.h"
+#include "TeTemporalSeries.h"
+
+	
+TeQuerierImpl::TeQuerierImpl(TeQuerierParams* par): params_(par), filledSerie_(false)
+{
+	TeAttributeList* att = new TeAttributeList();
+	attrList_ = TeSharedPtr<TeAttributeList>(att);
+	ts_ = 0;
+	if(par->chronon()!=TeNOCHRONON) //if there is a chronon, build ts
+	{
+		TeGroupingAttr::iterator it = par->groupAttr().begin();
+		if(it!=par->groupAttr().end())
+			ts_ = new TeTemporalSeries(par->theme(), par->objId(), par->chronon(), it->first.name_, it->first.name_, it->second, it->second);
+		else
+			ts_ = new TeTemporalSeries(par->chronon(), par->theme());
+		ts_->buildFrameIntervals();
+	}
+}
+
+TeQuerierImpl::TeQuerierImpl( const TeQuerierImpl& other)
+{
+	if(ts_)
+		delete ts_;
+
+	if(params_)
+		delete params_;
+
+	ts_ = 0;
+	params_ = 0;
+	if(other.params_) 
+	{
+		params_ = new TeQuerierParams();
+		*params_ = *(other.params_);
+	}
+	filledSerie_ = other.filledSerie_;
+	attrList_ = other.attrList_;
+}
+
+TeQuerierImpl& 
+TeQuerierImpl::operator= (const TeQuerierImpl& other)
+{
+	if ( this != &other )
+	{
+		if(ts_)
+			delete ts_;
+
+		if(params_)
+			delete params_;
+
+		ts_ = 0;
+		params_ = 0;
+		if(other.params_) 
+		{
+			params_ = new TeQuerierParams();
+			*params_ = *(other.params_);
+		}
+		filledSerie_ = other.filledSerie_;
+		attrList_ = other.attrList_;
+	}
+	return *this;
+}
+
+TeQuerierImpl::~TeQuerierImpl() 
+{	
+	if(ts_)
+		delete (ts_);
+
+	if(params_)
+		delete params_;
+}
+
+bool 
+TeQuerierImpl::loadTimeFrameInstances(int frame)
+{
+	if(frame>-1) 
+	{
+		TeTSEntry ent;
+		if(!getTSEntry(ent, frame))
+			return false;
+		
+		return(loadInstances(&ent));
+	}
+	else
+		return(loadInstances());
+}
+
+bool 
+TeQuerierImpl::getTSEntry(TeTSEntry& tsEntry, int frame)
+{
+	if(!ts_)
+		return false;
+
+	return(ts_->getTSEntry(tsEntry, frame)); 
+}
+
+int 
+TeQuerierImpl::getNumTimeFrames()
+{
+	if(!ts_)
+		return 0;
+
+	return (ts_->numTimeFrames());
+}
+
+bool 
+TeQuerierImpl::getTS(TeTemporalSeries& ts)
+{
+	if(!ts_)
+		return false;
+	
+	ts = (*ts_);
+	return true;
+}
+
+TeTSParams& 
+TeQuerierImpl::getTSParams() 
+{ 
+	return (ts_->TSparams_); 
+}
+
diff --git a/src/terralib/kernel/TeQuerierImpl.h b/src/terralib/kernel/TeQuerierImpl.h
new file mode 100644
index 0000000..d675147
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierImpl.h
@@ -0,0 +1,122 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeQuerierDB.h
+	\brief This file deals an abstract querier class to build STOs (Spatial Temporal Objects)
+*/
+#ifndef  __TERRALIB_INTERNAL_QUERIER_IMPL_H
+#define  __TERRALIB_INTERNAL_QUERIER_IMPL_H
+
+#include "TeQuerierParams.h"
+#include "TeFactory.h" 
+#include "TeSharedPtr.h" 
+
+class TeTSEntry;
+class TeTSParams;
+class TeSTInstance;
+class TeTemporalSeries;
+class TeMultiGeometry;
+
+//! An abstract querier class to build STOs (Spatial Temporal Objects)
+class TL_DLL TeQuerierImpl
+{
+protected:
+	//! querier parameters that define the used querier strategy  
+	TeQuerierParams*				params_;
+	TeTemporalSeries*				ts_;			//! temporal series
+	bool							filledSerie_;	//! this flag indicates if the temporal serie was filled 
+	TeSharedPtr<TeAttributeList>	attrList_;		//! list of the attributes of the querier 
+		
+public:
+	//! Constructor
+	TeQuerierImpl(TeQuerierParams* par); 
+
+	//! Copy constructor
+	TeQuerierImpl( const TeQuerierImpl& other);
+
+	//! Operator =
+	TeQuerierImpl& operator= (const TeQuerierImpl& other);
+
+	//! Destructor
+	virtual ~TeQuerierImpl(); 
+
+	//! Returns the object identifier
+	string objectId() { return params_->objId();}
+
+	//! Returns the theme pointer
+	TeTheme* theme() { return params_->theme();} 
+
+	//! Loads the STOs
+	bool loadTimeFrameInstances(int frame=-1); 
+
+	//! Gets each temporal serie entry, for each time frame
+	bool getTSEntry(TeTSEntry& tsEntry, int frame);
+	
+	//! Gets the number of generated time frames 
+	int getNumTimeFrames(); 
+
+	//! Gets the full temporal serie
+	bool getTS(TeTemporalSeries& ts);
+
+	//! Returns the temporal serie params
+	TeTSParams& getTSParams();
+
+	//! Gets the attribute list from querier
+	TeAttributeList getAttrList() { return (*attrList_); }
+
+	//! Returns a default object
+	static TeQuerierImpl* DefaultObject(const TeQuerierParams& /*params*/)  { return 0; }
+
+	//! Returns the querier parameters
+	TeQuerierParams* params() { return params_; }
+	
+	//! Loads the STOs
+	virtual bool loadInstances(TeTSEntry* ent=0) = 0; 
+	
+	//! Returns each loaded STO
+	virtual bool fetchInstance(TeSTInstance& stoi)= 0;  
+
+	//! Loads all geometries of the index-th geometry representation  
+	virtual bool loadGeometries(TeMultiGeometry& geometries, unsigned int& index) = 0; 
+
+	//! Loads all geometries 
+	virtual bool loadGeometries(TeMultiGeometry& geometries) = 0;
+
+	//! Returns the number of instances to each time frame
+	virtual int numElemInstances() { return 0;}
+
+	//! Empties querier instances
+	virtual void clear() { return; }
+};
+
+//! A class that define a factory to build querier strategies 
+class TL_DLL TeQuerierImplFactory : public TeFactory<TeQuerierImpl, TeQuerierParams>
+{
+public:
+	//! Builds an appropriate decoder from a identifier
+	TeQuerierImplFactory(const string& name) : TeFactory<TeQuerierImpl, TeQuerierParams>(name) { }
+
+	//! Destructor
+	virtual ~TeQuerierImplFactory() {}
+};
+
+#endif
diff --git a/src/terralib/kernel/TeQuerierParams.cpp b/src/terralib/kernel/TeQuerierParams.cpp
new file mode 100644
index 0000000..8e07106
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierParams.cpp
@@ -0,0 +1,286 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation. 
+*************************************************************************************/
+
+#include "TeQuerierParams.h" 
+#include "TeDatabase.h"
+
+TeQuerierParams::~TeQuerierParams()
+{
+	if(themeFlag_)
+		delete theme_;
+}
+
+TeQuerierParams::TeQuerierParams(const TeQuerierParams& rhs)
+{
+	loadGeometries_ = rhs.loadGeometries_;  
+	loadAllAttributes_ = rhs.loadAllAttributes_;
+	loadAttrNames_ = rhs.loadAttrNames_;
+	loadAttrNamesSeted_ = rhs.loadAttrNamesSeted_;
+	themeFlag_ = false;
+	layer_ = rhs.layer_;
+
+	if ((rhs.themeFlag_) && layer_)
+	{
+		theme_ = new TeTheme("theme_", layer_); 
+		TeAttrTableVector attrTables;
+		layer_->getAttrTables(attrTables);
+		theme_->setAttTables(attrTables);
+		themeFlag_ = true;
+	}
+	else
+		theme_ = rhs.theme_;
+
+	fileName_ = rhs.fileName_;
+	chr_ = rhs.chr_;
+	objId_ = rhs.objId_;
+	groupingAttr_ = rhs.groupingAttr_;
+	strategy_ = rhs.strategy_;
+
+	//restrictions
+	selectedObjs_ = rhs.selectedObjs_;  
+	spatialRelation_ = rhs.spatialRelation_; 
+	hasSpatialRes_ = rhs.hasSpatialRes_; 
+	boxRest_ = rhs.boxRest_;	
+	geomRest_ = rhs.geomRest_;
+	geomRepRest_ = rhs.geomRepRest_;
+}
+
+
+TeQuerierParams&
+TeQuerierParams::operator=(const TeQuerierParams& rhs)
+{
+	if (&rhs != this)
+	{
+		loadGeometries_ = rhs.loadGeometries_;  
+		loadAllAttributes_ = rhs.loadAllAttributes_;
+		loadAttrNames_ = rhs.loadAttrNames_;
+		loadAttrNamesSeted_ = rhs.loadAttrNamesSeted_;
+		themeFlag_ = false;
+		layer_ = rhs.layer_;
+
+		if ((rhs.themeFlag_) && layer_)
+		{
+			theme_ = new TeTheme("theme_", layer_); 
+			TeAttrTableVector attrTables;
+			layer_->getAttrTables(attrTables);
+			theme_->setAttTables(attrTables);
+			themeFlag_ = true;
+		}
+		else
+			theme_ = rhs.theme_;
+
+		fileName_ = rhs.fileName_;
+		chr_ = rhs.chr_;
+		objId_ = rhs.objId_;
+		groupingAttr_ = rhs.groupingAttr_;
+		strategy_ = rhs.strategy_;
+
+		//restrictions
+		selectedObjs_ = rhs.selectedObjs_;  
+		spatialRelation_ = rhs.spatialRelation_; 
+		hasSpatialRes_ = rhs.hasSpatialRes_; 
+		boxRest_ = rhs.boxRest_;	
+		geomRest_ = rhs.geomRest_;
+		geomRepRest_ = rhs.geomRepRest_;
+	}
+	return *this;
+}
+
+void 
+TeQuerierParams::setParams(TeLayer* layer)
+{
+	layer_ = layer;
+	if(theme_ == 0)
+	{
+		theme_ = new TeTheme("theme_", layer_); 
+		TeAttrTableVector attrTables;
+		theme_->layer(layer_);
+		layer_->getAttrTables(attrTables);
+		theme_->setAttTables(attrTables);
+		themeFlag_ = true;
+	}
+	strategy_ = "querierDBStr1";
+}	
+
+void 
+TeQuerierParams::setParams(TeTheme* theme, TeChronon chr)
+{
+	theme_ = theme;
+	chr_ = chr;
+	strategy_ = "querierDBStr1"; 
+
+	bool geomRep = (theme_->layer()->hasGeometry (TeCELLS) || theme_->layer()->hasGeometry (TePOINTS));
+	int numRepres = theme_->layer()->vectRepres().size();
+	
+	bool groupAttr = !(groupingAttr_.empty());
+	bool hasOneTable = true;
+
+	if(groupAttr)
+	{
+		string lastTable = "";
+		TeGroupingAttr::iterator it = groupingAttr_.begin();
+		while(it!=groupingAttr_.end())
+		{
+			string tableName;
+			size_t pos = (it->first.name_).find(".", 0, 1);
+			if (pos != string::npos)
+				tableName = (it->first.name_).substr(0,pos);
+
+			if((!lastTable.empty()) && (lastTable!=tableName))
+			{
+				hasOneTable = false;
+				break;
+			}
+			lastTable = tableName;
+			++it;
+		}
+		
+		//verify if the statistis can be calculated by SGBD
+		TeGroupingAttr groups = groupingAttr_; 
+		string sGroup = theme->layer()->database()->getSQLStatistics(groups);
+		TeGroupingAttr::iterator itgroup = groups.begin();
+		while(itgroup!= groups.end())
+		{
+			if(itgroup->second != TeNOSTATISTIC)
+			{
+				strategy_ = "querierDBStr1";
+				return;
+			}
+			++itgroup;
+		}
+	}
+
+	if( groupAttr && hasOneTable && (!loadGeom()))
+		strategy_ = "querierDBStr2";
+	else if( groupAttr && hasOneTable && loadGeom() && geomRep && (numRepres==1))
+		strategy_ = "querierDBStr3";
+
+	return;
+}
+
+void 
+TeQuerierParams::setParams(TeTheme* theme, const string& objId, TeChronon chr)
+{
+	objId_ = objId;
+	setParams(theme, chr);
+}
+
+void 
+TeQuerierParams::setParams(const string& fileName, TeChronon chr)
+{
+	fileName_ = fileName;
+	chr_ = chr;
+	strategy_ = "querierSHP";
+}
+
+
+void 
+TeQuerierParams::setFillParams(bool loadGeom, bool loadAllAttr, vector<string> loadAttr)
+{
+	loadGeometries_ = loadGeom;
+	loadAllAttributes_ = loadAllAttr;
+	
+	if(!loadAttr.empty()) 
+		loadAllAttributes_ = false;
+	
+	loadAttrNames_ = loadAttr;
+	loadAttrNamesSeted_ = loadAttr;
+	groupingAttr_.clear(); 
+
+	if(theme_)
+		setParams(theme_, objId_, chr_);
+}
+
+void 
+TeQuerierParams::setFillParams(bool loadGeom, TeGroupingAttr attrG)
+{
+	loadGeometries_ = loadGeom;
+	loadAttrNames_.clear(); 
+	loadAttrNamesSeted_.clear(); 
+	groupingAttr_ = attrG;
+
+	if(theme_)
+		setParams(theme_, objId_, chr_);
+}
+
+void 
+TeQuerierParams::setSpatialRest(TeBox& box, int relation, TeGeomRep rep)
+{
+	hasSpatialRes_ = true;
+	boxRest_ = box;
+	spatialRelation_ = relation;
+	
+	if(rep==TeGEOMETRYNONE)
+		geomRepRest_ = theme_->layer()->vectRepres()[0]->geomRep_;
+	else
+		geomRepRest_ = rep;
+	
+	geomRest_ = 0;
+}
+
+void 
+TeQuerierParams::setSpatialRest(TeGeometry* geom, int relation, TeGeomRep rep)
+{
+	hasSpatialRes_ = true;
+	geomRest_ = geom;
+	spatialRelation_ = relation;
+	
+	if(rep==TeGEOMETRYNONE)
+		geomRepRest_ = theme_->layer()->vectRepres()[0]->geomRep_;
+	else
+		geomRepRest_ = rep;
+	
+	boxRest_ = TeBox();
+}
+
+TeBox& 
+TeQuerierParams::box()
+{
+	return box_; 
+}
+
+void
+TeQuerierParams::clear()
+{
+	loadAttrNames_.clear();			
+	loadAttrNamesSeted_.clear();	
+	groupingAttr_.clear();
+	if(themeFlag_)
+		delete theme_;
+	themeFlag_=false;
+	theme_ = 0;
+	layer_ = 0;				
+	fileName_ = "";
+	box_ = TeBox();
+	chr_ = TeNOCHRONON; 
+	objId_ = "";
+	strategy_="";
+	selectedObjs_=TeAll;  
+	spatialRelation_=TeUNDEFINEDREL;	
+	hasSpatialRes_ = false;		
+	boxRest_=TeBox();
+	geomRest_=0;	
+	geomRepRest_=TeGEOMETRYNONE;	
+}
+
+
diff --git a/src/terralib/kernel/TeQuerierParams.h b/src/terralib/kernel/TeQuerierParams.h
new file mode 100644
index 0000000..1b3ac0f
--- /dev/null
+++ b/src/terralib/kernel/TeQuerierParams.h
@@ -0,0 +1,233 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeQuerierParams.h
+	\brief This file contains a class responsible for defining the querier mechanism behavior. 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_QUERIER_PARAMS_H
+#define  __TERRALIB_INTERNAL_QUERIER_PARAMS_H
+
+#include "TeTheme.h"
+
+/*! \class TeQuerierParams
+	\brief A class responsible for defining the querier mechanism behavior.
+
+	This class contains a set of attributes that define the querier behavior, 
+	for example, which instances the querier will load or if the querier will load
+	the geometries and which attributes.
+	It is used in the querier constructor. 
+
+	\sa
+	TeQuerier
+*/
+class TL_DLL TeQuerierParams
+{
+protected:	
+	bool					loadGeometries_;		//!< if the querier must load the geometries of each instance
+	bool					loadAllAttributes_;		//!< if the querier must load all attributes of each instance
+	vector<string>			loadAttrNames_;			//!< which attributes the querier must load
+	vector<string>			loadAttrNamesSeted_;	//!< internal structure
+	TeGroupingAttr			groupingAttr_;			//!< which attributes will be load and which aggregate function will be used in each attribute 
+	
+	bool					themeFlag_;		//!< if the theme is temporary
+	TeTheme*				theme_;			//!< pointer to a source theme 
+	TeLayer*				layer_;			//!< pointer to a source layer 
+	
+	string					fileName_;		//!< source file name (.shp, etc)
+	TeBox					box_;			//!< minimal bounding box that contains all geometries returned by this querier 
+
+	TeChronon				chr_;		//!< chronon used to generate time frames 
+	string					objId_;		//!< object identification
+	
+	//TeStatisticType		tsOper_;		//operator used in the construction of temporal series
+	
+	string					strategy_;		//! querier strategy name
+
+	TeSelectedObjects		selectedObjs_;  //!< if the querier must load only the instances pointed or queried
+	
+	int						spatialRelation_;	//!< spatial relation used by spatial restriction
+	bool					hasSpatialRes_;		//!< Verifies if there is a spatial restriction defined 
+	TeBox					boxRest_;			//!< A bounding box used by spatial restriction 
+	TeGeometry*				geomRest_;			//!< A geometry pointer used by spatial restriction 
+	TeGeomRep				geomRepRest_;		//!< geometric representation of the theme that will be considered by spatial restriction  
+
+public:
+	//! Constructor
+	TeQuerierParams(bool loadGeom = false, bool loadAllAttr = true): 
+			loadGeometries_(loadGeom),
+			loadAllAttributes_(loadAllAttr),
+			themeFlag_(false),
+			theme_ (0),
+			layer_ (0),
+			fileName_(""),
+			box_(TeBox()),
+			chr_ (TeNOCHRONON),
+			objId_(""),
+			selectedObjs_(TeAll),
+			spatialRelation_(0),
+			hasSpatialRes_(false),
+			geomRest_(0)
+			{ }
+
+	//! Constructor
+	TeQuerierParams(bool loadGeom, const vector<string>& loadAttr): 
+			loadGeometries_(loadGeom),
+			loadAllAttributes_(false),
+			themeFlag_(false),
+			theme_ (0),
+			layer_ (0),
+			fileName_(""),
+			box_(TeBox()),
+			chr_ (TeNOCHRONON),
+			objId_(""),
+			selectedObjs_(TeAll),
+			spatialRelation_(0),
+			hasSpatialRes_(false),
+			geomRest_(0)
+			{
+				loadAttrNamesSeted_.clear();
+				loadAttrNamesSeted_ = loadAttr;
+			}
+
+
+	//! Constructor
+	TeQuerierParams(bool loadGeom, TeGroupingAttr& groupAttr): 
+			loadGeometries_(loadGeom),
+			loadAllAttributes_(false),
+			themeFlag_(false),
+			theme_ (0),
+			layer_ (0),
+			fileName_(""),
+			box_(TeBox()),
+			chr_ (TeNOCHRONON),
+			objId_(""),
+			selectedObjs_(TeAll),
+			spatialRelation_(0),
+			hasSpatialRes_(false),
+			geomRest_(0)
+			{
+				groupingAttr_.clear();
+				groupingAttr_ = groupAttr;
+			}
+	
+	//! Destructor
+	virtual ~TeQuerierParams();
+
+	//! Copy Constructor
+	TeQuerierParams(const TeQuerierParams& qp);
+
+	//! Assignment operator
+	virtual TeQuerierParams& operator=(const TeQuerierParams& rhs);
+
+	//! Sets the layer that will be used as source of instances 
+	virtual void setParams(TeLayer* layer);
+
+	//! Sets the theme that will be used as source of instances and a chronon that defines the time frames
+	virtual void setParams(TeTheme* theme, TeChronon chr=TeNOCHRONON); 
+
+	//! Sets the theme that will be used as source of instances of a specific object and a chronon that defines the time frames
+	virtual void setParams(TeTheme* theme, const string& objId, TeChronon chr=TeNOCHRONON);
+
+	//! Sets the file name that will be used as source of instances and a chronon that defines the time frames
+	virtual void setParams(const string& fileName, TeChronon chr=TeNOCHRONON);
+	
+	//! Sets the parameters used to fill the instances 
+	virtual void setFillParams(bool loadGeom, bool loadAllAttr, vector<string> loadAttr = vector<string>());
+
+	//! Sets the parameters used to fill the instances
+	virtual void setFillParams(bool loadGeom, TeGroupingAttr attrG);
+	
+	//! Sets a spatial restriction (a spatial relation and a bounding box) 
+	virtual void setSpatialRest(TeBox& box, int relation = TeWITHIN, TeGeomRep rep = TeGEOMETRYNONE); 
+
+	//! Sets a spatial restriction (a spatial relation and a geometry) 
+	virtual void setSpatialRest(TeGeometry* geom, int relation = TeWITHIN, TeGeomRep rep = TeGEOMETRYNONE); 
+
+	//! Sets the selected objects
+	virtual void setSelecetObjs(TeSelectedObjects so) { selectedObjs_ = so; }
+
+	//! Sets which attributes must be loaded
+	virtual void setLoadAttrs(const vector<string>& vec) { loadAttrNames_ = vec; }
+
+	//! Returns the identification of the strategy associated to the querier
+	virtual string decName() const { return strategy_; }
+
+	//! Returns the source theme
+	virtual TeTheme* theme() { return theme_; }
+
+	//! Returns the source layer
+	virtual TeLayer* layer() { return layer_; }
+
+	//! Returns the source file name
+	virtual string fileName() { return fileName_; }
+
+	//! Returns the minimal bounding box
+	virtual TeBox& box();
+
+	//! Sets the minimal bounding box 
+	virtual void box(TeBox& b) { box_ = b; }
+
+	//! Returns the chronon used to create the time frames
+	virtual TeChronon chronon()	{ return chr_; }
+	
+	//! Returns the object identification
+	virtual string objId() { return objId_; }
+	
+	//! Returns which attributes will be loaded and how they will be grouped
+	virtual TeGroupingAttr& groupAttr() { return groupingAttr_;}
+
+	//! Returns if the querier must load the geometries
+	virtual bool loadGeom ()  { return	loadGeometries_; }
+	
+	//! Returns if the querier must load all attributes
+	virtual bool loadAllAttr() { return loadAllAttributes_;}
+
+	//! Returns the subset of attributes that will be loaded
+	virtual vector<string>& loadAttrs() { return loadAttrNames_;}
+
+	//! Internal function. Returns the subset of attributes that will be loaded
+	virtual vector<string>& loadSetedAttrs() { return loadAttrNamesSeted_;}
+
+	//! Returns which objects must be loaded
+	virtual TeSelectedObjects selectedObjs() { return selectedObjs_; }
+	
+	//! Returns the spatial relation 
+	virtual int spatialRelation() { return spatialRelation_; }
+
+	//! Verifies if there is a spatial restriction defined
+	virtual bool hasSpatialRes() { return hasSpatialRes_;}
+	
+	//! Returns the bounding box associated to the spatial restriction
+	virtual TeBox boxRest() { return boxRest_; } 
+
+	//! Returns the geometry associated to the spatial restriction
+	virtual TeGeometry* geomRest() { return geomRest_; }
+
+	//! Returns which theme geometric representation must be considered by the spatial restriction  
+	virtual TeGeomRep  geomRepRest() { return geomRepRest_; }
+
+	//! Clear querier params
+	virtual void clear();
+};
+
+#endif
diff --git a/src/terralib/kernel/TeRTree.h b/src/terralib/kernel/TeRTree.h
new file mode 100644
index 0000000..fc23221
--- /dev/null
+++ b/src/terralib/kernel/TeRTree.h
@@ -0,0 +1,980 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file   TeRTree.h
+    \brief  This file contains an implementation of rtree data structures in main memory for two dimensions.
+	\note   These data structures and algorithms MUST BE USED ONLY BY TerraLib kernel and should NOT be used by anyone because
+	        THIS IS FOR INTERNAL USE ONLY.
+    \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+*/
+
+#ifndef  __TERRALIB_INTERNAL_RTREE_H
+#define  __TERRALIB_INTERNAL_RTREE_H
+
+#include "TeGeometry.h"
+#include "TeGeometryAlgorithms.h"
+
+/*! \brief This namespace contain the definitions of various Spatial Data Structures,
+           like K-d-Tree and R-Tree, ONLY FOR INTERNAL USE (must NOT be used by anyone).
+*/
+namespace TeSAM
+{
+//! Class that represents a node of a TeRTree
+/*!
+	If level is 0 so this is a leaf node otherwise this is a internal node.
+
+	WARNING:
+
+	1. A branch is a union, so be carefull with the types used here!
+	
+ */
+template<class DATATYPE, int MAXNODES = 8, int MINNODES = MAXNODES / 2>
+class TeRTreeNode
+{
+	public:
+
+		//! Struct that represents a node-branch of a TeRTree
+		/*!
+			May be data or may be another subtree, if parents level is 0 so this is a data in a leaf node.
+
+		*/
+		struct TeRTreeBranch
+		{
+			TeBox rect_;	//!<	Bounding box for branch or object (if this is a leaf).
+
+			union
+			{
+				TeRTreeNode* child_;		//!< Child node pointer.
+				DATATYPE data_;				//!< Data Id or Ptr.
+			};
+		};
+
+	public:
+
+		int count_;			//!< Count.
+
+		int level_;			//!< Leaf is zero, others positive.
+
+		TeRTreeBranch branch_[MAXNODES];	//!< Branch.
+
+		//! Constructor.
+
+
+		TeRTreeNode()
+			: count_(0), level_(-1)
+		{
+		}
+
+		//! Returns true if this is a internal node.
+        bool isInternalNode() const
+		{
+			return (level_ > 0);
+		}
+
+		//! Returns true if this is a leaf node.
+        bool isLeaf() const
+		{
+			return (level_ == 0);
+		}
+
+		//! This method is used by split, when a node is re-filled.
+		void init()
+		{
+			count_ = 0;
+
+			level_ = -1;
+		}
+
+	private:
+
+		//! No copy allowed
+		TeRTreeNode(const TeRTreeNode& other);
+
+		//! No copy allowed
+		TeRTreeNode& operator=(const TeRTreeNode& other);
+
+};	// end of class TeRTreeNode
+
+//! A class that represents a two dimensional R-Tree
+/*!	
+	This implementation is based on:
+	Antonin Guttman. R-Trees: A Dynamic Index Structure for Spatial Searching. ACM SIGMOD: International Conference on Management of Data, 1984, pp. 47-57.	
+
+	and in his original source code. <BR>
+
+	WARNING: <BR>
+
+	1. Don't use this class! It is for TerraLib internal use. <BR>
+
+	2. Only the basic methods for inserting and searching were implemented. <BR>
+
+	3. In future we will implement: <BR>
+		- the delete method. <BR>
+		- the near query <BR>
+		- point query <BR>
+ */
+template<class DATATYPE, int MAXNODES = 8, int MINNODES = MAXNODES / 2>
+class TeRTree
+{
+	public:
+
+		//! Export this typename.
+		typedef TeRTreeNode<DATATYPE, MAXNODES, MINNODES> TeRTreeNodeType;
+
+		//! Export this typename.
+		typedef typename TeRTreeNodeType::TeRTreeBranch TeRTreeBranch;
+
+	protected:
+
+		//! Structure of auxiliary variables for finding a split partition.
+		struct TePartitionVars
+		{
+			int partition_[MAXNODES + 1];	//!< Auxiliary partition vector.
+			int taken_[MAXNODES + 1];		//!< Flag to indicate that entry is ok.
+			int count_[2];					//!< Number of entries in each new page.
+			TeBox cover_[2];				//!< Auxiliary box of each new page.
+			double area_[2];				//!< Auxiliary area of each new page.
+
+			TeRTreeBranch branchBuf_[MAXNODES + 1];	//!< Auxiliary branch buffer.
+			TeBox coverSplit_;						//!< Auxiliary box covering branchBuf.
+
+			//! Initializes partition vars.
+			void init()
+			{
+				count_[0] = 0;
+				count_[1] = 0;
+
+                for(int i = 0; i <= MAXNODES; ++i)
+                {
+                    taken_[i] = 0;
+                    partition_[i] = -1;
+                }
+			}
+		};		
+		
+		TeRTreeNodeType* root_;		//!< Pointer to root node
+
+		TeBox mbr_;					//!< Bounding box of the tree
+        		
+		mutable unsigned int size_;			//!< The size of R-Tree (number of nodes)		
+
+	public:
+
+		//! Construtor
+		TeRTree(const TeBox& mbr)
+			: root_(0), mbr_(mbr), size_(0)
+		{
+			++size_;
+			root_ = new TeRTreeNodeType();
+            root_->level_ = 0;
+		}
+
+		//! Destructor
+		~TeRTree()
+		{
+			clear();
+
+			if(root_)
+				delete root_;
+		}
+
+		//! The number of elements of the tree
+		const unsigned int& size(void) const
+		{
+			return size_;
+		}
+		
+		//! Return true if the tree is empty
+		bool isEmpty(void) const
+		{
+			return (root_->count_ == 0);
+		}
+
+		//! Clear all tree nodes
+		void clear(void)
+		{
+			if(root_)
+			{
+				erase(root_);
+				root_ = 0;
+				
+				size_ = 1;
+				root_ = new TeRTreeNodeType();
+				root_->level_ = 0;
+			}
+		}
+
+		//! Inserts item into the tree
+		void insert(const TeBox& rect, const DATATYPE& data)
+		{
+			insert(rect, data, &root_, 0);
+		}
+
+		//! Removes item from tree
+		bool remove(const TeBox& rect, const DATATYPE& data)
+		{
+			return remove(rect, data, &root_);
+		}
+
+		//! Range search query
+		int search(const TeBox& rect, vector<DATATYPE>& report) const
+		{
+			int foundObjs = 0;
+
+			if(root_)
+				search(rect, root_, report, foundObjs);
+
+			return foundObjs;
+		}
+
+		//! Sets the bounding box of all elements in the tree
+		void setBox(const TeBox& mbr)
+		{
+			mbr_ = mbr;
+		}
+
+		//! Gets the bounding box of all elements in the tree
+		const TeBox& getBox(void) const
+		{
+			return mbr_;
+		}
+
+	protected:
+
+		//! Insert a data rectangle into an index structure.
+		/*!
+			Insert provides for splitting the root. <BR>
+			Returns true if root was split, false if it was not. <BR>
+			The level argument specifies the number of steps up from the leaf
+			level to insert; e.g. a data rectangle goes in at level = 0. <BR>
+			chooseLeaf does the recursion.
+		*/
+		inline bool insert(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType** root, int level);
+
+		//! Delete a data rectangle from an index structure.		   
+		/*!
+			Pass in a pointer to a Rect, the tid of the record, ptr to ptr to root node. <BR>
+			Returns 1 if record not found, 0 if success. <BR>
+			DeleteRect provides for eliminating the root.
+		*/
+		inline bool remove(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType** root);
+
+		//! Delete a rectangle from non-root part of an index structure.		   
+		/*!
+			Called by DeleteRect. <BR>
+			Descends tree recursively,
+			merges branches on the way back up.
+		*/
+		inline bool remove2(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType* n, vector<TeRTreeNodeType*>& ee);
+
+		//! Disconnect a dependent node.
+		inline void disconBranch(TeRTreeNodeType* n, int i);
+
+		//! Inserts a new data rectangle into the index structure.		   
+		/*!
+			Recursively descends tree, propagates splits back up.
+			Returns false if node was not split.  Old node updated.
+			If node was split, returns true and sets the pointer pointed to by
+			new to point to the new node.  Old node updated to become one of two.
+			The level argument specifies the number of steps up from the leaf
+			level to insert; e.g. a data rectangle goes in at level = 0.
+		*/
+		inline bool chooseLeaf(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType* node, TeRTreeNodeType** newNode, int level);
+
+		//! Recursive range query
+		inline void search(const TeBox& rect, TeRTreeNodeType* node, vector<DATATYPE>& report, int& foundObjs) const;
+
+		//! Find the smallest rectangle that includes all rectangles in branches of a node
+		inline TeBox nodeCover(TeRTreeNodeType* n) const;
+
+		//! Combine two rectangles into larger one containing both
+		inline TeBox combineRect(const TeBox& rectA, const TeBox& rectB) const;
+
+		//! Add a branch to a node.
+		/*!
+			Split the node if necessary. <BR>
+			Returns false if node not split. <BR>
+			Old node updated. <BR>
+			Returns true if node split, sets *new to address of new node. <BR>
+			Old node updated, becomes one of two.
+		*/
+		inline bool addBranch(TeRTreeBranch* branch, TeRTreeNodeType* node, TeRTreeNodeType** newNode) const;
+
+		//! Pick a branch.
+		/*!
+			Pick the one that will need the smallest increase
+			in area to accomodate the new rectangle.  This will result in the
+			least total area for the covering rectangles in the current node.
+			In case of a tie, pick the one which was smaller before, to get
+			the best resolution when searching.
+		*/
+		inline int pickBranch(const TeBox& rect, TeRTreeNodeType* node) const;
+
+		//! Split a node.
+		/*!
+			Divides the nodes branches and the extra one between two nodes. <BR>
+			Old node is one of the new ones, and one really new one is created.
+		*/
+		inline void splitNode(TeRTreeNodeType* node, TeRTreeBranch* branch, TeRTreeNodeType** newNode) const;
+
+		//! Load branch buffer with branches from full node plus the extra branch.
+		inline void getBranches(TeRTreeNodeType* n, TeRTreeBranch* b, TePartitionVars& p) const;
+
+		//! Method 0 for finding a partition.
+		/*!
+		   First find two seeds, one for each group, well separated.
+           Then put other rects in whichever group will be smallest after addition.
+	    */
+		inline void methodZero(TePartitionVars& p) const;
+
+		//! Pick two rects from set to be the first elements of the two groups.
+		/*!	
+		   Pick the two that are separated most along any dimension, or overlap least.
+           Distance for separation or overlap is measured modulo the width of the
+           space covered by the entire set along that dimension.
+	     */
+		inline void pickSeeds(TePartitionVars& p) const;
+
+		//! Put a branch in one of the groups
+		inline void classify(int i, int group, TePartitionVars& p) const;
+
+		//! Put each rect that is not already in a group into a group.
+		/*!	
+           Process one rect at a time, using the following hierarchy of criteria.
+           In case of a tie, go to the next test.<BR>
+           1) If one group already has the max number of elements that will allow
+              the minimum fill for the other group, put r in the other.<BR>
+           2) Put r in the group whose cover will expand less.  This automatically
+		      takes care of the case where one group cover contains r.<BR>
+		   3) Put r in the group whose cover will be smaller.  This takes care of the
+              case where r is contained in both covers.<BR>
+           4) Put r in the group with fewer elements.<BR>
+           5) Put in group 1 (arbitrary).<BR>
+
+           Also update the covers for both groups.
+	     */
+		inline void pigeonhole(TePartitionVars& p) const;
+
+		//! Copy branches from the buffer into two nodes according to the partition.
+		inline void loadNodes(TeRTreeNodeType* n, TeRTreeNodeType* q, TePartitionVars& p) const;
+
+		//! Calculate rect area
+		double rectArea(const TeBox& b) const
+		{
+			return b.width() * b.height();
+		}
+
+		//! Erases a node from the tree and all nodes below it.
+		void erase(TeRTreeNodeType* node)
+		{
+			if(node->isLeaf())
+			{
+				delete node;
+
+				return;
+			}
+
+			for(int i = 0u; i < node->count_; ++i)
+				erase(node->branch_[i].child_);
+	
+			delete node;
+
+			return;
+		}
+
+		//! Only to determine if the two box intersects withou using an epsilon
+		bool rtreeBoxIntersects(const TeBox& bx1, const TeBox& bx2) const
+		{
+			return ::TeIntersects(bx1, bx2);
+		}		
+
+	private:
+
+		//! No copy allowed
+		TeRTree(const TeRTree& other);
+
+		//! No copy allowed
+		TeRTree& operator=(const TeRTree& other);
+
+};	// end of class TeRTree
+
+
+//------------------- Implementation of the templates classes
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+bool TeRTree<DATATYPE, MAXNODES, MINNODES>::insert(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType** root, int level)
+{
+// this is the algorithm insert
+    TeRTreeNodeType* newRoot;
+	TeRTreeNodeType* newNode;
+    TeRTreeBranch    branch;
+
+    if(chooseLeaf(rect, data, *root, &newNode, level))  // I1
+    {
+// I4
+// if root was split
+// grow a new root, make tree taller
+		++size_;
+        newRoot = new TeRTreeNodeType();  
+
+        newRoot->level_ = (*root)->level_ + 1;
+
+// first half node
+        branch.rect_  = nodeCover(*root);
+        branch.child_ = *root;
+        addBranch(&branch, newRoot, 0);
+
+// second half node
+        branch.rect_ = nodeCover(newNode);
+        branch.child_ = newNode;        
+		addBranch(&branch, newRoot, 0);
+
+        *root = newRoot;
+
+        return true;
+    }
+
+    return false;
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+bool TeRTree<DATATYPE, MAXNODES, MINNODES>::remove(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType** root)
+{
+	int i;
+	TeRTreeNodeType *t;
+	vector<TeRTreeNodeType*> reInsertList;
+	
+	if(remove2(rect, data, *root, reInsertList))
+	{
+// if we are here, so we have found and deleted a data item
+
+// reinsert any branches from eliminated nodes
+		while(!reInsertList.empty())
+		{
+			t = reInsertList[0];
+			for(i = 0; i < t->count_; ++i)
+				insert(t->branch_[i].rect_, t->branch_[i].data_, root, t->level_);
+	
+// erase node from list
+			reInsertList.erase(reInsertList.begin());
+
+// remove node card from memory
+			delete t;
+			--size_;
+		}
+		
+		/* check for redundant root (not leaf, 1 child) and eliminate */
+		if(((*root)->count_ == 1) && ((*root)->isInternalNode()))
+		{
+			t = (*root)->branch_[0].child_;
+
+			delete (*root);
+			--size_;
+
+			*root = t;
+		}
+		
+		return true;
+	}
+	
+	return false;
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+bool TeRTree<DATATYPE, MAXNODES, MINNODES>::remove2(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType* n, vector<TeRTreeNodeType*>& ee)
+{
+	int i;	
+
+	if(n->isInternalNode()) /* not a leaf node */
+	{
+		for(i = 0; i < n->count_; ++i)
+		{
+			if(rtreeBoxIntersects(rect, n->branch_[i].rect_))
+			{
+				if(remove2(rect, data, n->branch_[i].child_, ee))
+				{
+					if(n->branch_[i].child_->count_ >= MINNODES)
+						n->branch_[i].rect_ = nodeCover(n->branch_[i].child_);
+					else
+					{
+						/* not enough entries in child, eliminate child node */
+						ee.push_back(n->branch_[i].child_);	//reInsert(n->branch_[i].child_, ee);
+						disconBranch(n, i);
+					}
+
+					return true;	// found item
+				}
+			}
+		}
+
+		return false;	// din't find item
+	}
+	else  /* a leaf node */
+	{
+		for(i = 0; i < n->count_; ++i)
+		{
+			if(n->branch_[i].data_ == data)
+			{
+				disconBranch(n, i);
+				return true;	// found item
+			}
+		}
+
+		return false;	// didn't find item
+	}
+}
+
+/*template<class DATATYPE, int MAXNODES, int MINNODES> void TeRTree<DATATYPE, MAXNODES, MINNODES>::reInsert(TeRTreeNodeType* n, vector<TeRTreeNodeType*>& ee)
+{
+	ee.push_back(n);
+}*/
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::disconBranch(TeRTreeNodeType* n, int i)
+{
+// remove element copying the last element in array
+	n->branch_[i] = n->branch_[n->count_ - 1];
+
+	--(n->count_);
+}
+
+// CHOOSELEAF
+template<class DATATYPE, int MAXNODES, int MINNODES>
+bool TeRTree<DATATYPE, MAXNODES, MINNODES>::chooseLeaf(const TeBox& rect, const DATATYPE& data, TeRTreeNodeType* node, TeRTreeNodeType** newNode, int level)
+{
+	TeRTreeBranch    b;
+	TeRTreeNodeType* n2;	
+	
+	if(node->level_ > level)
+	{
+// Still above level for insertion, go down tree recursively
+		int i = pickBranch(rect, node);		// CL3
+
+		if(!chooseLeaf(rect, data, node->branch_[i].child_, &n2, level))
+		{
+// child was not split
+			node->branch_[i].rect_ = combineRect(rect, node->branch_[i].rect_);
+
+			return false;
+		}
+		else		
+		{
+// child was split
+			node->branch_[i].rect_ = nodeCover(node->branch_[i].child_);
+
+			b.child_ = n2;
+			b.rect_ = nodeCover(n2);
+
+			return addBranch(&b, node, newNode);
+		}
+	}
+	else if (node->level_ == level)
+	{
+// have reached level for insertion. Add rect, split if necessary
+
+		b.rect_ = rect;
+		//b.child_ = (TeRTreeNodeType*) data;
+		b.data_ = data;
+
+// child field of leaves contains tid of data record
+		return addBranch(&b, node, newNode);
+	}
+	else
+	{
+// Not supposed to happen
+		throw;
+		return false;
+	}
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::search(const TeBox& rect, TeRTreeNodeType* node, vector<DATATYPE>& report, int& foundObjs) const
+{
+	int i;
+// S1
+    if(node->isInternalNode()) // This is an internal node in the tree
+	{
+        for(i = 0; i < node->count_; ++i)
+		{
+            if(rtreeBoxIntersects(rect, node->branch_[i].rect_))
+                search(rect, node->branch_[i].child_, report, foundObjs);
+		}
+	}
+// S2
+	else	// This is a leaf node
+	{
+        for(i = 0; i < node->count_; ++i)
+		{
+            if(rtreeBoxIntersects(rect, node->branch_[i].rect_))
+			{
+                DATATYPE& id = node->branch_[i].data_;
+
+				report.push_back(id);
+
+                ++foundObjs;
+			}
+		}
+	}
+
+	return;
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+TeBox TeRTree<DATATYPE, MAXNODES, MINNODES>::nodeCover(TeRTreeNodeType* n) const
+{
+	bool flag = true;
+
+	TeBox r;
+	
+	for(int i = 0; i < n->count_; ++i)
+	{
+        if(flag)
+		{
+			r = n->branch_[i].rect_;
+			flag = false;
+		}
+		else
+			r = combineRect(r, n->branch_[i].rect_);
+	}
+
+	return r;
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+TeBox TeRTree<DATATYPE, MAXNODES, MINNODES>::combineRect(const TeBox& rectA, const TeBox& rectB) const
+{
+    TeBox newRect;
+
+	newRect.x1_ = MIN(rectA.x1_, rectB.x1_);
+	newRect.y1_ = MIN(rectA.y1_, rectB.y1_);
+	newRect.x2_ = MAX(rectA.x2_, rectB.x2_);
+	newRect.y2_ = MAX(rectA.y2_, rectB.y2_);
+
+	return newRect;
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+bool TeRTree<DATATYPE, MAXNODES, MINNODES>::addBranch(TeRTreeBranch* branch, TeRTreeNodeType* node, TeRTreeNodeType** newNode) const
+{
+    if(node->count_ < MAXNODES)		/* split won't be necessary */
+	{
+		node->branch_[node->count_] = *branch;
+
+		++(node->count_);
+
+		return false;
+	}
+	else
+	{
+        splitNode(node, branch, newNode);
+
+		return true;
+	}
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+int TeRTree<DATATYPE, MAXNODES, MINNODES>::pickBranch(const TeBox& rect, TeRTreeNodeType* node) const
+{
+// CL3
+	bool flag = true;
+
+	double bestIncr = -1.0;
+
+	double bestArea = 0.;
+
+    int best = 0;
+	
+	for(int i = 0; i < node->count_; ++i)
+	{
+		TeBox rr = node->branch_[i].rect_;
+		double area = rectArea(rr);
+
+		rr = combineRect(rect, rr);
+        
+		double increase = rectArea(rr) - area;
+
+        if((increase <  bestIncr) || flag)
+		{
+			best = i;
+
+            bestArea = area;
+            bestIncr = increase;
+
+            flag = false;
+		}
+		else if((increase == bestIncr) && (area < bestArea))
+		{
+			best = i;
+			bestArea = area;
+			bestIncr = increase;
+		}
+	}
+
+	return best;
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::splitNode(TeRTreeNodeType* node, TeRTreeBranch* branch, TeRTreeNodeType** newNode) const
+{
+    TePartitionVars partitions;
+
+// load all the branches into a buffer, initialize old node
+	int level = node->level_;
+
+	getBranches(node, branch, partitions);
+
+// find partition
+	methodZero(partitions);
+
+// put branches from buffer into 2 nodes according to chosen partition
+	++size_;
+
+	*newNode = new TeRTreeNodeType();
+	(*newNode)->level_ = node->level_ = level;
+
+	loadNodes(node, *newNode, partitions);
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::getBranches(TeRTreeNodeType* n, TeRTreeBranch* b, TePartitionVars& p) const
+{
+	int i;
+// load the branch buffer
+	for(i = 0; i < MAXNODES; ++i)
+	{
+		p.branchBuf_[i] = n->branch_[i];
+	}
+
+	p.branchBuf_[MAXNODES] = *b;
+
+// calculate rect containing all in the set
+	p.coverSplit_ = p.branchBuf_[0].rect_;
+
+	for(i = 1; i <= MAXNODES; ++i)
+		p.coverSplit_ = combineRect(p.coverSplit_, p.branchBuf_[i].rect_);
+
+	n->init();
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::methodZero(TePartitionVars& p) const
+{
+	p.init();
+	pickSeeds(p);
+	pigeonhole(p);
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::pickSeeds(TePartitionVars& p) const
+{
+	double w;
+	double separation;
+	double bestSep;
+	double width[2];
+	int leastUpper[2];
+	int greatestLower[2];
+	int seed0;
+	int seed1;
+	int i;
+// LPS1
+// find the rectangles farthest out in each direction along dimens "x"
+	greatestLower[0] = leastUpper[0] = 0;
+
+	for(i = 1; i <= MAXNODES; ++i)
+	{
+		TeBox& r = p.branchBuf_[i].rect_;
+
+		if(r.x1_ > p.branchBuf_[greatestLower[0]].rect_.x1_)
+			greatestLower[0] = i;
+
+		if(r.x2_ < p.branchBuf_[leastUpper[0]].rect_.x2_)
+			leastUpper[0] = i;
+	}
+
+// LPS2
+// LPS3
+// find the width of the whole collection along this dimension
+	width[0] = p.coverSplit_.x2_ - p.coverSplit_.x1_;
+
+// find the rectangles farthest out in each direction along dimens "y"
+	greatestLower[1] = leastUpper[1] = 0;
+
+	for(i = 1; i <= MAXNODES; ++i)
+	{
+		TeBox& r = p.branchBuf_[i].rect_;
+
+		if(r.y1_ > p.branchBuf_[greatestLower[1]].rect_.y1_)
+			greatestLower[1] = i;
+
+		if(r.y2_ < p.branchBuf_[leastUpper[1]].rect_.y2_)
+			leastUpper[1] = i;
+	}
+
+// LPS2
+// LPS3
+// find the width of the whole collection along this dimension
+	width[1] = p.coverSplit_.y2_ - p.coverSplit_.y1_;
+
+
+// pick the best separation dimension and the two seed rects
+
+// divisor for normalizing by width
+
+// x
+	if(width[0] == 0.0)
+		w = 1.0;
+	else
+		w = width[0];
+
+	TeBox rlow  = p.branchBuf_[leastUpper[0]].rect_;
+    TeBox rhigh = p.branchBuf_[greatestLower[0]].rect_;
+
+    seed0 = leastUpper[0];
+	seed1 = greatestLower[0];
+    
+	bestSep = (rhigh.x1_ - rlow.x2_) / w;
+
+// y
+	if(width[1] == 0.0)
+		w = 1.0;
+	else
+		w = width[1];
+
+	rlow  = p.branchBuf_[leastUpper[1]].rect_;
+    rhigh = p.branchBuf_[greatestLower[1]].rect_;
+
+    separation = (rhigh.y1_ - rlow.y2_) / w;
+
+// LPS3
+	if(separation > bestSep)
+	{
+		seed0 = leastUpper[1];
+		seed1 = greatestLower[1];
+
+		bestSep = separation;
+	}
+
+	if(seed0 != seed1)
+	{
+		classify(seed0, 0, p);
+		classify(seed1, 1, p);
+	}
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::classify(int i, int group, TePartitionVars& p) const
+{
+    p.partition_[i] = group;
+	p.taken_[i] = 1;
+
+	if(p.count_[group] == 0)
+		p.cover_[group] = p.branchBuf_[i].rect_;
+	else
+		p.cover_[group] = combineRect(p.branchBuf_[i].rect_, p.cover_[group]);
+
+	p.area_[group] = rectArea(p.cover_[group]);
+
+	++(p.count_[group]);
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::pigeonhole(TePartitionVars& p) const
+{
+	TeBox newCover[2];
+	
+	double newArea[2];
+	double increase[2];
+
+	for(int i = 0; i <= MAXNODES; ++i)
+	{
+		if(p.taken_[i] == 0)
+		{
+// if one group too full, put rect in the other regardless
+			if(p.count_[0] >= (MAXNODES + 1 - MINNODES))
+			{
+				classify(i, 1, p);
+
+				continue;
+			}
+			else if(p.count_[1] >= (MAXNODES + 1 - MINNODES))
+			{
+				classify(i, 0, p);
+
+				continue;
+			}
+
+// find the areas of the two groups' old and new covers
+			for(int group = 0; group < 2; ++group)
+			{
+				if(p.count_[group] > 0)
+				{
+					newCover[group] = combineRect(p.branchBuf_[i].rect_, p.cover_[group]);
+				}
+				else
+				{
+					newCover[group] = p.branchBuf_[i].rect_;
+				}
+
+				newArea[group] = rectArea(newCover[group]);
+				increase[group] = newArea[group] - p.area_[group];
+			}
+
+// put rect in group whose cover will need to expand less
+			if(increase[0] < increase[1])
+				classify(i, 0, p);
+			else if(increase[1] < increase[0])
+				classify(i, 1, p);
+// put rect in group that will have a smaller area cover
+			else if(p.area_[0] < p.area_[1])
+				classify(i, 0, p);
+			else if(p.area_[1] < p.area_[0])
+				classify(i, 1, p);
+// put rect in group with fewer elements
+			else if(p.count_[0] < p.count_[1])
+				classify(i, 0, p);
+			else
+				classify(i, 1, p);
+		}
+	}
+}
+
+template<class DATATYPE, int MAXNODES, int MINNODES>
+void TeRTree<DATATYPE, MAXNODES, MINNODES>::loadNodes(TeRTreeNodeType* n, TeRTreeNodeType* q, TePartitionVars& p) const
+{
+	for(int i = 0; i <= MAXNODES; ++i)
+	{
+		if(p.partition_[i] == 0)
+			addBranch(&(p.branchBuf_[i]), n, 0);
+		else if(p.partition_[i] == 1)
+			addBranch(&(p.branchBuf_[i]), q, 0);
+		//else
+		//	throw;	// ERROR
+	}
+}
+};	// end namespace TeSAM
+
+
+#endif	// __TERRALIB_INTERNAL_RTREE_H
+
+
+
+
diff --git a/src/terralib/kernel/TeRaster.cpp b/src/terralib/kernel/TeRaster.cpp
new file mode 100644
index 0000000..201b9b1
--- /dev/null
+++ b/src/terralib/kernel/TeRaster.cpp
@@ -0,0 +1,1049 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include <TeRaster.h>
+#include <TeDecoder.h>
+#include <TeUtils.h>
+#include <TeStdFile.h>
+#include <TeException.h>
+#include "TeRasterRemap.h"
+#include "TeDecoderMemory.h"
+#include <TeInitRasterDecoders.h>
+#include <TeVectorRemap.h>
+#include <algorithm>
+
+
+//!	virtual class that define the strategics of the iteratorPoly, each strategic is a functor
+class TeStrategic
+{
+protected:
+	TeRaster*		raster_;
+	double			y_;
+	TeCoordPairVect	SegOut_;   //line and column index 
+
+public:
+	TeStrategic(TeRaster* r=0, double y=0): raster_(r), y_(y) {}
+
+    virtual ~TeStrategic() {}
+
+	void Init(TeRaster* r, double y)
+	{
+		raster_ = r;
+		y_ = y;
+	}
+	
+	virtual void strateg(double xMin, double xMax, double y) = 0;  
+
+	void operator() (TeCoordPair& pair)
+	{
+		//xmin and xmax of the segment (line and column index)
+		TeCoord2D minSegLC = raster_->coord2Index(TeCoord2D(pair.pt1.x_, y_));
+		TeCoord2D maxSegLC = raster_->coord2Index(TeCoord2D(pair.pt2.x_, y_));
+
+		double xMinLCd = minSegLC.x_;
+		double xMaxLCd = maxSegLC.x_;
+		double yLC = maxSegLC.y_;
+		
+		//verify if is outside raster area 
+		if(xMinLCd<-0.5)
+		{
+			if(xMaxLCd<-0.5)
+				return;
+			else
+				xMinLCd=-0.5;
+		}
+		strateg(xMinLCd, xMaxLCd, yLC);
+	}
+	TeCoordPairVect result() const {return SegOut_;}
+};
+
+
+//!	functor TePixelBoxInPoly
+/*
+	return the elements of the raster which box is 
+	contained in the polygon
+*/
+class TePixelBoxInPoly: public TeStrategic
+{
+
+public:
+	TePixelBoxInPoly(TeRaster* r=0, double y=0): TeStrategic(r,y) {}
+
+    virtual ~TePixelBoxInPoly() {}
+
+    void strateg(double xMin, double xMax, double y)
+	{
+		//verify if contain the element center 
+		int xMinLCi = TeRoundRasterIndex(xMin);
+		int xMaxLCi = TeRoundRasterIndex(xMax);
+		
+		if (xMinLCi < xMin)
+			xMinLCi++;
+
+		if (xMaxLCi > xMax)
+			xMaxLCi--;
+
+		if (xMinLCi <= xMaxLCi)
+		{
+			//new segment 
+			TeCoord2D minLC (xMinLCi, y);
+			TeCoord2D maxLC (xMaxLCi, y);
+
+			TeCoordPair res(minLC,maxLC);
+			SegOut_.push_back (res);
+		}
+	}
+	
+};
+
+
+//!	functor TePixelBBInterPoly
+/*
+	return the elements of the raster "cujo" boundingbox 
+	intersects the polygon
+*/
+class TePixelBBInterPoly: public TeStrategic
+{
+	
+public:
+	TePixelBBInterPoly(TeRaster* r=0, double y=0): TeStrategic(r,y) {}
+
+    virtual ~TePixelBBInterPoly() {}
+
+	void strateg(double xMin, double xMax, double y)
+	{		
+		//element center 
+		int xMinLCi = TeRoundRasterIndex(xMin);
+		int xMaxLCi = TeRoundRasterIndex(xMax);
+
+		if (SegOut_.size()>0)
+		{
+			TeCoordPair prev = SegOut_[SegOut_.size()-1];
+			if (xMinLCi == prev.pt2.x())
+				xMinLCi++;
+			if (xMinLCi > xMaxLCi)
+				return;
+		}
+		
+		TeCoord2D minLC (xMinLCi, y);
+		TeCoord2D maxLC (xMaxLCi, y);
+			
+		TeCoordPair res(minLC,maxLC);
+
+		SegOut_.push_back (res);
+	}
+};
+
+
+TeCoordPairVect 
+applyStrategic(double& y, double ymin, double xmin, TeStrategicIterator st, TeRaster* raster, TePolygon& poly)
+{
+	TeCoordPairVect Segments = TeGetIntersections(poly, y);
+	double resy = raster->params().resy_;
+
+	//In polygon
+	if((st==TeBoxPixelIn) || (st==TeBBoxPixelInters))
+	{
+		bool empty=false;
+		if(Segments.empty())
+		{
+			empty = true;
+			y -= resy; 
+
+			while((y>=ymin) && (empty)) 
+			{
+				Segments = TeGetIntersections(poly, y);
+				if(!Segments.empty())
+					empty = false;
+				else
+					y -=resy;
+			}
+		}
+		if(!empty)
+		{
+			if (st==TeBoxPixelIn)
+			{
+				TePixelBoxInPoly strat(raster,y);
+				strat = for_each(Segments.begin (), Segments.end(), strat);
+				return strat.result();
+			}
+			else
+			{
+				TePixelBBInterPoly strat(raster,y);
+				strat = for_each(Segments.begin (), Segments.end(), strat);
+				return strat.result();
+			}
+		}
+	}
+	//Out polygon
+	else if((st==TeBoxPixelOut) || (st==TeBBoxPixelNotInters))
+	{
+		int nCols = raster->params().ncols_;
+	
+		//se o segmento for vazio, no h interseo entre essa linha e o polgono
+		//fazer um segmento de todas as colunas
+		if(Segments.empty())
+		{
+			//passar para indice: linha e coluna
+			TeCoord2D coordCM (xmin, y);
+			double linLC = (raster->coord2Index(coordCM)).y();
+			
+			int lin = TeRoundRasterIndex(linLC);
+			
+			TeCoord2D index1(0, lin);
+			TeCoord2D index2(nCols-1,lin);
+			
+			TeCoordPair pair(index1,index2);
+
+			Segments.push_back(pair);
+			return Segments;
+		}
+		else
+		{
+			TeCoordPairVect segsIn, segResult;
+			
+			if(st==TeBoxPixelOut)
+			{
+				TePixelBoxInPoly strat(raster,y);
+				//return the segments in the polygon
+				strat = for_each(Segments.begin (), Segments.end(), strat);
+				segsIn = strat.result();
+			}
+			else
+			{
+				TePixelBBInterPoly strat(raster,y);
+				//return the segments in the polygon
+				strat = for_each(Segments.begin (), Segments.end(), strat);
+				segsIn = strat.result();
+			}
+			
+			TeCoordPairVect::iterator it = segsIn.begin();
+
+			double colMin = 0;
+			double colMax = 0;
+			double lin = 0;
+
+			while(it!=segsIn.end())
+			{
+				TeCoord2D coord1 = (*it).pt1;
+				TeCoord2D coord2 = (*it).pt2;
+				lin = coord1.y();
+				
+				colMax = coord1.x()-1;
+
+				if (colMax >= colMin)
+				{
+					TeCoord2D index1(colMin, lin);
+					TeCoord2D index2(colMax, lin);
+				
+					TeCoordPair pair(index1,index2);
+
+					segResult.push_back(pair);
+				}
+				colMin = coord2.x()+1;
+				++it;
+			}
+
+			//Montar o ltimo segmento
+			TeCoord2D index1(colMin, lin);
+			TeCoord2D index2(nCols-1,lin);
+			
+			TeCoordPair pair(index1,index2);
+			segResult.push_back(pair);
+			return segResult;
+		}
+	}
+	
+	return Segments;
+}
+
+
+
+TeRaster::TeRaster( TeRasterParams& pars ) 
+{
+	TeInitRasterDecoders();
+	decoder_ = 0;
+	string decName;
+	params_.status_ = TeRasterParams::TeNotReady;
+	pars.errorMessage_ = "";
+	if (pars.decoderIdentifier_.empty())   // the decoder is not specified in raster parameters
+	{	
+		if (!pars.fileName_.empty())     // try to guess from the file name
+		{	
+			string ext = TeConvertToUpperCase(TeGetExtension(pars.fileName_.c_str()));
+			decName = TeDecoderFactory::instanceName2Dec()[ext];
+			if ( decName.empty())
+			{
+				pars.errorMessage_ = "Can not instantiate a decoder from the raster file (or table) name.";
+				return;
+			}
+			pars.decoderIdentifier_ = decName;
+		}
+		else // no decoder type, and no filename
+		{
+			pars.errorMessage_ = "Can not instantiate a decoder for the raster data.";
+			return;
+		}
+	}
+	decoder_ = TeDecoderFactory::make(pars);
+	if (decoder_)
+	{
+		params_ = decoder_->params();
+		box_ = decoder_->params().box();
+	}
+}
+
+TeRaster::TeRaster( const string& filename, const char& mode ) 
+{
+	TeInitRasterDecoders();
+	params_.fileName_ = filename;
+	params_.mode_ = mode;
+	decoder_ = 0;
+	params_.status_ = TeRasterParams::TeNotReady;
+	string decName;
+	if (!filename.empty())
+	{
+		string ext = TeConvertToUpperCase(TeGetExtension(filename.c_str()));
+		decName = TeDecoderFactory::instanceName2Dec()[ext];
+		if (decName.empty())
+		{
+			params_.errorMessage_ = "Can not instantiate a decoder from the raster file (or table) name.";
+			return;
+		}
+	}
+	else
+	{
+		params_.errorMessage_ = "Can not instantiate a decoder for the raster data.";
+		return;
+	}
+	params_.decoderIdentifier_= decName;
+	decoder_ = TeDecoderFactory::make(params_);
+	if (decoder_)
+	{
+		params_ = decoder_->params();
+		box_ = decoder_->params().box();
+	}
+}
+
+
+TeRaster::TeRaster(int ncols, int nlines, int nbands, TeDataType elemType)
+{
+	params_.decoderIdentifier_= "MEM";
+	params_.ncols_ = ncols;
+	params_.nlines_ = nlines;
+	params_.nBands(nbands);
+	params_.setDataType(elemType);
+	params_.mode_ = 'c';
+	params_.lowerLeftResolutionSize(0.5,0.5,1.0,1.0,params_.ncols_,params_.nlines_,true);
+	TeProjection* proj = new TeNoProjection();
+	params_.projection(proj);
+	decoder_ = new TeDecoderMemory(params_);
+	delete proj;
+	if (decoder_)
+	{
+		params_ = decoder_->params();
+		box_ = decoder_->params().box();
+	}
+}
+
+
+TeRaster::~TeRaster( ) 
+{
+	if (decoder_)
+		delete decoder_;
+}
+
+void TeRaster::updateParams( TeRasterParams& par)
+{
+	params_ = par;	// update raster parameters
+	if (decoder_)
+		decoder_->updateParams(par);		// update its decoder parameters
+	box_ = params_.box();
+}
+
+void TeRaster::setDecoder( TeDecoder* dec )
+{ 
+	if (dec)
+	{
+		decoder_ = dec;					// set the decoder
+		params_ = decoder_->params();	// copy decoder parameters to raster
+		box_ = params_.box();
+	}
+}
+
+void TeRaster::clear()
+{
+	if (decoder_)
+		decoder_->clear();
+}
+
+TeRaster::iterator TeRaster::begin() 
+{
+	return iterator(0,0, params_.ncols_,params_.nlines_, params_.nBands(), this);
+}
+
+TeRaster::iterator TeRaster::end() 
+{
+	return iterator(params_.ncols_,params_.nlines_-1,params_.ncols_,params_.nlines_, params_.nBands(), this);
+}
+
+TeRaster::iteratorPoly TeRaster::end(TePolygon& poly, TeStrategicIterator st, int band) 
+{
+	return iteratorPoly(params_.ncols_,params_.nlines_-1,params_.ncols_,params_.nlines_, params_.nBands(), this, poly, st, band);
+}
+
+bool TeRaster::selectBlocks(TeBox& bb, int resFac, TeRasterParams& parBlock) 
+{
+	if (!decoder_)
+		return false;
+	return decoder_->selectBlocks(bb,resFac,parBlock);
+}
+
+int TeRaster::numberOfSelectedBlocks()
+{
+	if (!decoder_)
+		return 0;
+	return decoder_->numberOfSelectedBlocks();
+}
+
+bool TeRaster::fetchRasterBlock(TeDecoderMemory* memDec)
+{
+	if (!decoder_)
+		return false;
+	return decoder_->getSelectedRasterBlock(memDec);
+}
+
+void TeRaster::clearBlockSelection()
+{
+	if (!decoder_)
+		return ;
+	decoder_->clearBlockSelection();
+}
+
+void TeRaster::iterator::moveForward()
+{
+	this->operator++();
+}
+
+bool TeRaster::iterator::operator==(const iterator& rhs) const
+{
+	return (this->colCurrent_ == rhs.colCurrent_ && this->linCurrent_== rhs.linCurrent_);
+}
+
+bool TeRaster::iterator::operator!=(const iterator& rhs) const
+{
+	return (this->colCurrent_ != rhs.colCurrent_ || this->linCurrent_!= rhs.linCurrent_);
+}
+
+void TeRaster::iteratorPoly::moveForward()
+{
+	this->operator++();
+}
+
+bool TeRaster::init( TeRasterParams& pars )
+{ 
+	if (!decoder_ )	
+	{
+		params_.status_ = TeRasterParams::TeNotReady;
+		string decName;
+		if (params_.decoderIdentifier_.empty())   // the decoder is not especified in raster parameters
+		{	
+			if (!params_.fileName_.empty())     // try to guess from the file name
+			{	
+				string ext = TeConvertToUpperCase(TeGetExtension(params_.fileName_.c_str()));
+				decName = TeDecoderFactory::instanceName2Dec()[ext];
+				if ( decName.empty())
+				{
+					pars.errorMessage_ = "Can not instantiate a decoder from the raster file (or table) name.";
+					return false;
+				}
+				params_.decoderIdentifier_ = decName;
+			}
+			else // no decoder type, and no filename
+			{
+				pars.errorMessage_ = "Can not instantiate a decoder for the raster data.";
+				return false;
+			}
+		}
+		decoder_ = TeDecoderFactory::make(params_);
+		if (!decoder_)
+		{
+			pars.errorMessage_ = "Can not instantiate a decoder for the raster data.";
+			return false;
+		}
+	}
+	decoder_->init(pars);
+	params_ = decoder_->params();
+	box_ = decoder_->params().box();
+	return (params_.status_ != TeRasterParams::TeNotReady);
+}
+
+bool TeRaster::init()
+{ 
+	if (decoder_)
+	{
+		decoder_->init(params_);
+		params_ = decoder_->params();	
+		return (params_.status_ != TeRasterParams::TeNotReady);
+	}
+	params_.errorMessage_ = "There is no decoder associated to the raster data.";
+	return false;
+}
+
+bool TeRaster::setElement (int col, int lin, double val,int band)
+{
+	if (params_.status_!= TeRasterParams::TeReadyToWrite)
+	{
+		params_.errorMessage_ = "Raster is not properly initalizated to be written.";
+		return false;
+	}
+	if ( col < 0 || col >= params_.ncols_ ||
+		 lin < 0 || lin >= params_.nlines_ ||
+		 band < 0 || band >= params_.nBands())
+	{
+		params_.errorMessage_ = "Fail to access element out of the range of the raster dimensions.";
+		return false;
+	}
+
+	bool res = decoder_->setElement(col,lin,val,band);
+	if ( res && (!params_.useDummy_ || val != params_.dummy_[band]))
+	{
+		// check if should update min and max values
+		if (val < params_.vmin_[band])
+		{
+			params_.vmin_[band] = val;
+			decoder_->params().vmin_[band] = val;
+		}
+
+		if (val > params_.vmax_[band])
+		{
+			params_.vmax_[band] = val;
+			decoder_->params().vmax_[band] = val;
+		}
+	}
+	return res;
+}
+
+bool TeRaster::getElement (int col, int lin, double& val,int band) 
+{
+	if (!params_.status_ || col < 0 || col >= params_.ncols_  || 
+		 lin < 0 || lin >= params_.nlines_  ||
+		 band < 0 || band >= params_.nBands())
+	{
+		params_.errorMessage_ = "Fail to access element out of the range of the raster dimensions.";
+		return false;
+	}
+
+	if (decoder_->getElement (col,lin,val,band) && 
+	   (!params_.useDummy_ || val != params_.dummy_[band]))	
+		return true;
+	else
+		return false;
+}
+
+bool TeRaster::setElement(int col, int lin, double Rval, double Gval, double Bval, unsigned int transp) 
+{
+	if (params_.status_!= TeRasterParams::TeReadyToWrite)
+	{
+		params_.errorMessage_ = "Raster is not properly initalizated to be written.";
+		return false;
+	}
+	if ( params_.nBands() != 3 ||
+		 col < 0 || col >= params_.ncols_ ||
+		 lin < 0 || lin >= params_.nlines_ )
+	{
+		params_.errorMessage_ = "Fail to access element out of the range of the raster dimensions.";
+		return false;
+	}
+	return decoder_->setElementRGB(col, lin, Rval, Gval, Bval, transp);
+}
+
+TeRaster::iteratorPoly 
+TeRaster::begin(TePolygon& poly, TeStrategicIterator st, int band)
+{
+	double	minLinLC, maxLinLC, minColLC, maxColLC; //index
+	double	minLinCM, maxLinCM, minColCM, maxColCM; //world coordinates 
+	int		nlines = 0; 
+	int		ncols = 0;
+	double	resy = params_.resy_;
+	bool	end = false;
+
+	//box (world coordinates) of the polygon
+	TeBox boxPol = poly.box();
+	if((st==TeBoxPixelOut) || (st==TeBBoxPixelNotInters))  //out polygon
+	{
+		minLinLC = (params_.nlines_-1);
+		maxLinLC = 0.0;
+		minColLC = 0.0;
+		maxColLC = (params_.ncols_-1);
+	}
+	else  //in polygon
+	{
+		//change to line and column index
+		TeCoord2D minColLinLC = coord2Index(boxPol.lowerLeft());
+		TeCoord2D maxColLinLC = coord2Index(boxPol.upperRight());
+
+		//segment that pass by center of the element  
+		minLinLC = TeRound(minColLinLC.y());
+		maxLinLC = TeRound(maxColLinLC.y());
+		minColLC = TeRound(minColLinLC.x());
+		maxColLC = TeRound(maxColLinLC.x());
+		
+		//number of lines and columns of the polygon box 
+		nlines = (int)((minLinLC - maxLinLC)+1);
+		ncols = (int)((maxColLC - minColLC)+1);
+
+
+		//if is negative 
+		if(minLinLC<-0.5)
+		{
+			if(maxLinLC<-0.5)
+				end=true;
+			else
+				minLinLC = -0.5;
+		}
+
+		if(minColLC<-0.5)
+		{
+			if(maxColLC<-0.5)
+				end=true;
+			else
+				minColLC = -0.5;
+		}
+	}
+	
+	TeCoord2D MinColLinLC(minColLC, minLinLC); 
+	TeCoord2D MaxColLinLC(maxColLC, maxLinLC);
+
+	//calculate the minimal and maximal line and minimal column (in world coordinates) 
+	TeCoord2D MinColLinCM = index2Coord(MinColLinLC);
+	minLinCM = MinColLinCM.y();
+	minColCM = MinColLinCM.x();
+	maxLinCM = index2Coord(MaxColLinLC).y();
+	maxColCM = index2Coord(MaxColLinLC).x();
+
+	TeCoordPairVect segRes;
+	bool empty = true;
+	bool first = true;
+	
+	while(empty && (maxLinCM >= minLinCM))  
+	{
+		if(!first)
+		{
+			maxLinCM -= resy;
+			TeCoord2D maxColLinLC = coord2Index(TeCoord2D(maxColCM,maxLinCM));
+			maxLinLC = TeRound(maxColLinLC.y());
+		}
+			
+		segRes = applyStrategic(maxLinCM, minLinCM, minColCM, st, this, poly);
+		empty = segRes.empty();
+		first = false;
+	}
+
+	if(!segRes.empty())
+	{
+		minColLC = segRes[0].pt1.x();
+		double lMin = segRes[0].pt1.y();
+		maxColLC = segRes[0].pt2.x();
+	
+		int cCurr = TeRound(minColLC);  //column current
+		int lCurr = TeRound(lMin);		//line current
+
+		iteratorPoly itPoly(cCurr, lCurr, params_.ncols_, params_.nlines_, params_.nBands(), this, poly, 
+						st, maxLinLC, minLinLC, minColLC, maxColLC, segRes, 
+						0, nlines, ncols, end, minLinCM);
+		return itPoly;
+	
+	}
+	else
+	{
+		iteratorPoly itPoly = this->end(poly, st, band);
+		return itPoly;
+	}
+}
+
+
+bool
+TeRaster::fillRaster(TeRaster* dstRaster, TeRasterTransform* transf, bool bestRes)
+{	
+	if (!dstRaster ||
+		 dstRaster->params().status_ != TeRasterParams::TeReadyToWrite)
+	{
+		params_.errorMessage_ == "Destination raster non-existing or not ready to write";
+		return false;
+	}
+
+	if (params_.status_ != TeRasterParams::TeReadyToRead &&
+		params_.status_ != TeRasterParams::TeReadyToWrite)
+	{
+		params_.errorMessage_ == "Raster not ready to be extracted";
+		return false;
+	}
+
+	int dt = CLOCKS_PER_SEC/4;
+	int dt2 = CLOCKS_PER_SEC * 5;
+	clock_t	t0, t1, t2;
+
+	TeRasterRemap fillRemap;
+	fillRemap.setOutput(dstRaster);
+	fillRemap.setInput(this);
+	if (transf)
+		fillRemap.setTransformer(transf);
+	int res = 1;
+	TeBox b = dstRaster->params().boundingBox();
+	if (bestRes)
+	   res = decoder_->bestResolution(b, dstRaster->params().nlines_, dstRaster->params().ncols_,
+									  dstRaster->params().projection());
+	this->clearBlockSelection();
+	bool result = true;
+	TeRasterParams parBlock;
+	if (selectBlocks(b, res, parBlock))
+	{
+		if (TeProgress::instance())
+			TeProgress::instance()->setTotalSteps(this->numberOfSelectedBlocks());
+		TeRaster* block = new TeRaster;
+		TeDecoderMemory* decMem = new TeDecoderMemory(parBlock);
+		decMem->init();
+		int n = 0;
+		t2 = clock();
+		t0 = t1 = t2;
+		bool flag = true;
+		do
+		{
+			flag = fetchRasterBlock(decMem);
+			block->setDecoder(decMem);
+			fillRemap.setInput(block);
+			if (!fillRemap.apply())
+				break;
+			n++;
+			if (TeProgress::instance())
+			{
+				t2 = clock();
+				if (int(t2-t1) > dt)
+				{
+					t1 = t2;
+					if (TeProgress::instance()->wasCancelled())
+						break;
+					if((int)(t2-t0) > dt2)	// show progress 
+						TeProgress::instance()->setProgress(n);
+				}
+			}
+		}while (flag);
+		decMem->clear();
+		delete block;
+	}
+	else
+		result =  fillRemap.apply();
+	this->clearBlockSelection();
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+	return result;
+}
+
+//! Prefix move forward operator
+TeRaster::iterator& 
+TeRaster::iterator::operator++()
+{
+	if (++colCurrent_ == nCols_)
+	{
+		if (linCurrent_ < nLines_-1)
+		{
+			linCurrent_++;
+			colCurrent_ = 0;
+		}
+	}
+	return *this;
+}
+
+TeRaster::iterator
+TeRaster::iterator::operator++(int)	
+{
+	iterator temp = *this;
+	++(*this);
+	return temp;
+}
+
+vector<double> 
+TeRaster::iterator::operator*()
+{
+	vector<double> vt(nBands_);
+	if ((linCurrent_ < nLines_) && (colCurrent_ < nCols_))
+	{
+		for (int n=0; n<nBands_; n++)
+			raster_->getElement(colCurrent_,linCurrent_,vt[n],n);
+	}
+	return vt;
+}
+
+double 
+TeRaster::iterator::operator*(int band)
+{
+	double val = this->raster_->params().dummy_[band];
+	if ((linCurrent_ < nLines_) && (colCurrent_ < nCols_))
+	{
+		if (raster_->getElement(colCurrent_,linCurrent_,val,band))
+			return val;
+	}
+	return val;
+}
+
+void 
+TeRaster::iteratorPoly::getNewSegment(int linCurr)
+{
+	//change to world coordinates
+	TeCoord2D coord(colMin_,linCurr);
+	TeCoord2D colLinCM = raster_->index2Coord(coord);
+	
+	double linCM = colLinCM.y();
+	double colMinCM = colLinCM.x();
+	
+	//applyStrategic: return the segments 
+	segments_ = applyStrategic(linCM, linMinCM_, colMinCM, strategy_, raster_, poly_);
+
+	if(segments_.empty())
+	{
+		colCurrent_=(int)colMax_;
+		return;
+	}
+	
+	colMin_ = segments_[0].pt1.x();
+	colMax_ = segments_[0].pt2.x();
+	
+	colCurrent_=(int)colMin_;
+	posSegments_ = 0;
+	end_ = false;
+}
+
+//! Prefix move forward operator
+TeRaster::iteratorPoly& 
+TeRaster::iteratorPoly::operator++() //prefix
+{
+	if (++colCurrent_>colMax_)
+	{
+		if((++posSegments_ > (int)(segments_.size()-1)) || (segments_.size()<1))
+		{
+			if(++linCurrent_>linMax_)
+			{
+				end_ = true;
+				*this = raster_->end(poly_,strategy_);
+			}
+			else
+			{	
+				segments_.clear();
+				do
+				{
+					getNewSegment(linCurrent_);
+					if (segments_.empty())
+						linCurrent_++;
+					else
+						break;
+				} while (linCurrent_<=linMax_);
+				if (linCurrent_ > linMax_)
+				{
+					end_ = true;
+					*this = raster_->end(poly_,strategy_);
+				}
+			}
+		}
+		else
+		{
+			colMin_ = segments_[posSegments_].pt1.x();
+			colMax_ = segments_[posSegments_].pt2.x();
+			colCurrent_=(int)colMin_;
+		}
+	}
+	return *this;
+}
+
+TeRaster::iteratorPoly 
+TeRaster::iteratorPoly::operator++(int)
+{
+	iteratorPoly temp = *this;
+	++(*this);
+	return temp;
+}
+
+double 
+TeRaster::iteratorPoly::operator*() 
+{
+	double val = 0.0;
+	if ((linCurrent_ < nLines_) && (colCurrent_ < nCols_))
+	{
+		if (raster_->getElement(colCurrent_,linCurrent_,val,band_))
+			return val;
+	}
+	return 0.0;
+}
+
+//! Returns the value of a given band of the element pointed by the iterator 
+double 
+TeRaster::iteratorPoly::operator*(int band)
+{
+	double val = 0.0;
+	if ((linCurrent_ < nLines_) && (colCurrent_ < nCols_))
+	{
+		if (raster_->getElement(colCurrent_,linCurrent_,val,band))
+			return val;
+	}
+	return 0.0;
+}
+
+bool 
+TeRaster::iteratorPoly::getProperty(TeProperty& prop) 
+{
+	double val = 0.0;
+	prop.attr_.rep_.type_ = TeREAL;
+	if (!raster_) prop.attr_.rep_.name_ = raster_->params().fileName_ + Te2String(band_);
+	prop.value_ = Te2String (val);
+	
+	if ((linCurrent_ < nLines_) && (colCurrent_ < nCols_))
+	{
+		if (raster_->getElement(colCurrent_,linCurrent_,val,band_))
+		{
+			prop.value_ = Te2String(val);
+			return true;
+		}
+	}
+	return false;
+}
+
+TeRaster*
+TeRasterClipping(TeRaster* whole, TePolygonSet& mask, TeProjection* geomProj, const string& clipName, double background, const string& decId)
+{
+  if( decId.empty() ) {
+    throw TeException( UNKNOWN_DECODER_TECHNOLOGY_TYPE, "Invalid decoder", 
+      false );
+  }
+  
+  if( whole == 0 ) {
+    throw TeException( UNKNOWN_ERROR_TYPE, "Invalid raster pointer", 
+      false );
+  }  
+
+  if( mask.empty() ) {
+    throw TeException( UNKNOWN_ERROR_TYPE, "Invalid polygon set mask", 
+      false );
+  }  
+  
+  if( ( decId != "MEM" ) && clipName.empty() ) {
+    throw TeException( UNKNOWN_ERROR_TYPE, "Invalid clipname", 
+      false );
+  }    
+    
+  if( geomProj == 0 ) {
+    throw TeException( UNKNOWN_ERROR_TYPE, "Invalid projection pointer", 
+      false );
+  }    
+
+	if (whole->params().status_ != TeRasterParams::TeReadyToRead && 
+		whole->params().status_ != TeRasterParams::TeReadyToWrite )
+		return 0;
+	
+	bool isEqualProj = (*whole->projection() == *geomProj);
+	if (!isEqualProj &&
+		(geomProj->name() == "NoProjection" || whole->projection()->name() == "NoProjection"))
+		return 0;
+
+	TePolygonSet mask2;
+	if (!isEqualProj)
+		TeVectorRemap(mask,geomProj,mask2,whole->projection());
+	else
+		mask2 = mask;
+
+	if (!TeIntersects(mask2.box(),whole->params().boundingBox()))
+		return 0;
+
+	TeRasterParams par = whole->params();
+	if (!decId.empty())
+	{
+		par.decoderIdentifier_ = decId;
+		if (decId == "DB")
+		{
+			if (!par.database_)
+				return 0;
+		}
+	}
+	par.fileName_ = clipName;
+	par.mode_ = 'c';
+	TeCoord2D bll = whole->coord2Index(mask2.box().lowerLeft());
+	TeCoord2D bur = whole->coord2Index(mask2.box().upperRight());
+	
+	bll = whole->index2Coord(TeCoord2D(TeRoundRasterIndex(bll.x_),TeRoundRasterIndex(bll.y_)));
+	bur = whole->index2Coord(TeCoord2D(TeRoundRasterIndex(bur.x_),TeRoundRasterIndex(bur.y_)));
+
+	par.boxResolution(bll.x_, bll.y_, bur.x_, bur.y_,par.resx_, par.resy_);
+	par.setDummy(background);
+	TeRaster*  clip = new TeRaster(par);
+	clip->init();
+	if (clip->params().status_ != TeRasterParams::TeReadyToWrite)
+		return 0;
+	
+	TeCoord2D cd = TeCoord2D(0,0);
+	TeCoord2D ul = clip->params().index2Coord(cd);
+	TeCoord2D dxdy = whole->params().coord2Index(ul);
+	int j = TeRoundRasterIndex(dxdy.x_); // column delta
+	int i = TeRoundRasterIndex(dxdy.y_); // line delta
+	unsigned int np = mask2.size();
+	unsigned int nb = whole->params().nBands();
+	unsigned int band;
+	double val;
+
+	//progress bar
+	if(TeProgress::instance())
+	{
+		string caption = "Raster Clipping operation";
+		TeProgress::instance()->setCaption(caption.c_str());
+		string msg = "Executing clipping operation. Please, wait!";
+		TeProgress::instance()->setMessage(msg);
+		TeProgress::instance()->setTotalSteps(np);
+	}
+	for (unsigned int p=0; p<np; ++p)
+	{
+		TeRaster::iteratorPoly it = whole->begin(mask2[p],TeBoxPixelIn);
+		while (!it.end())
+		{
+			for(band = 0; band < nb; ++band)
+			{
+				if (whole->getElement(it.currentColumn(),it.currentLine(),val,band))
+					clip->setElement(it.currentColumn()-j,it.currentLine()-i,val,band);
+			}
+			++it;
+		}
+		//progress bar
+		if(TeProgress::instance())
+		{
+			if(TeProgress::instance()->wasCancelled())
+			{
+				TeProgress::instance()->reset();
+				break;
+			}
+			TeProgress::instance()->setProgress(p);
+		}
+	}
+	if(TeProgress::instance())
+		TeProgress::instance()->reset();
+	clip->clear();
+	clip->params().mode_ = 'r';
+	clip->init();
+	return clip;
+}
diff --git a/src/terralib/kernel/TeRaster.h b/src/terralib/kernel/TeRaster.h
new file mode 100644
index 0000000..583a597
--- /dev/null
+++ b/src/terralib/kernel/TeRaster.h
@@ -0,0 +1,525 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeRaster.h
+    \brief This file contains structures and definitions to deal with raster structures
+*/
+#ifndef  __TERRALIB_INTERNAL_RASTER_H
+#define  __TERRALIB_INTERNAL_RASTER_H
+
+#include "TeDecoder.h"
+#include "TeDataTypes.h"
+#include "TeCoord2D.h"
+#include "TeAttribute.h"
+#include "TeGeometry.h"
+#include "TeGeometryAlgorithms.h"
+
+class TeRasterTransform;
+
+#include <map>
+
+//! Strategy used to decide if a pixel is inside/outside a polygon
+enum TeStrategicIterator
+{	TeBoxPixelIn,			//!< center of pixel is inside the geometry
+	TeBBoxPixelInters,		//!< bounding box of pixel intercepts the geometry
+	TeBoxPixelOut,			//!< center of pixel is outside the geometry
+	TeBBoxPixelNotInters	//!< bounding box of pixel do not intercept the geometry
+};
+
+/*! \fn bool TeCoordPairVect applyStrategic(double& y, double ymin, double xmin, TeStrategicIterator st, TeRaster* raster, TePolygon& poly);
+    \brief Returns  
+	\param y         
+	\param ymin         
+	\param xmin         
+	\param st pixel in polygon strategy       
+    \param raster pointer to raster
+	\param poly polygon        
+	*/
+TL_DLL TeCoordPairVect applyStrategic(double& y, double ymin, double xmin, 
+			   TeStrategicIterator st, TeRaster* raster, TePolygon& poly);
+
+//! Support for a raster geometry 
+/*
+	\par A Raster Geometry is made of a matrix of ncolumns x nlines elements
+	with nBands dimension. Each element, or pixel, of the raster its is
+	indexed by a column, line and band and has a double value associated.
+	\par Each Raster geometry has a decoder associated to it. Its decoder 
+	knows how to get return the value (as a double) of each pixel.
+	\par All information about the data is stored in a TeRasterParams structure
+	that is duplicated in its decoder.
+	\sa TeDecoder TeRasterParams
+*/
+class TL_DLL TeRaster : public TeGeometry
+{
+	TeRasterParams  params_;	//!< structure that describes all information about a raster 
+	TeDecoder		*decoder_;	//!< pointer to a decoder of values
+
+public:
+	//! Constructor from file
+	/*!
+	  This method tries to instatiate a decoder for this data from the 
+	  file extension of the filename. 
+      \param filename the name of a file that contains the raster data
+      \param mode file opening mode ('r', 'w' or 'c')
+	  \par Obs: the method init should be called before any attempt to read or write this raster data 
+	*/
+	TeRaster(const string& filename, const char& mode = 'r');
+
+	//! Constructor from parameters
+	/*!
+	  This method tries to instatiate a decoder for this data. It uses the identification
+	  explicitly described or the extension of a file name specified in the parameters.
+      \param pars a raster parameters structure that contains information about the raster
+	  \par Obs: the method init should be called before any attempt to read or write data 
+	  to the raster.
+	*/
+	TeRaster(TeRasterParams& pars);
+
+	//! Contructor from commom parameters
+	/*
+		This method creates a raste data in memory, using only the most basic
+		parameters:
+		\par ncols number of columns
+		\par nlines number of lines
+		\par nbands number of bands
+		\par elemType size of each element
+	*/
+	TeRaster(int ncols, int nlines, int nbands, TeDataType elemType);
+
+	//! Empty constructor
+	TeRaster() : decoder_(0) {}
+
+	//! Destructor
+	~TeRaster ();
+
+	//! Returns the parameters of the raster
+	TeRasterParams& params();
+	
+	//! Returns the number of lines of the raster
+	int nBands();
+
+	//! Update the parametes of a raster file
+	/*!
+      \param par a new raster parameters structure
+	*/
+	void updateParams(TeRasterParams& par);
+
+	//! Returns the type of the geometry
+	TeGeomRep elemType();
+
+	//! Associate a decoder to a raster
+	/*!
+      \param dec pointer to a raster decoder
+	*/
+	void setDecoder(TeDecoder* dec);
+
+	//! Returns status of the raster as a Boolean value
+	/*
+		\return true if raster is ready to be read or written and false otherwise
+	*/
+	bool status();
+
+	//! Returns a pointer to the decoder associated to this raster
+	TeDecoder* decoder();
+
+	//! Returns a pointer to the raster projection
+	TeProjection* projection(); 
+
+	//! Sets the value of a element of the raster 
+	/*!
+      \param col column number
+	  \param lin line number
+	  \param val element value
+	  \param band band number
+	*/
+	bool setElement (int col, int lin, double val, int band=0);
+
+	//! Gets the value of a element of the raster 
+	/*!
+      \param col column number
+	  \param lin line number
+	  \param val element value
+	  \param band band number
+	*/
+	bool getElement (int col, int lin, double& val, int band=0);
+
+	//! Fills a destination raster with the raster elements
+	/*
+		\param dstRaster destination raster
+		\param transf pixel evaluator to be used
+		\param bestRes flag to indicate that it should use the best resolution available
+	*/
+	bool fillRaster (TeRaster* dstRaster, TeRasterTransform* transf=0, bool bestRes = true);
+
+	//! Initalize the raster decoding tool from its parameters
+	/*! The result of this method depends on the mode_ specified in the parameters. 
+		\par 'r' : initializes a raster with reading only permission. If the source
+		of the data does not exist it will fail.
+		\par 'w' : initializes a raster with reading and writting permission. If the source
+		of the data does not exist it will fail.
+		\par 'c' : creates a new raster data with default values. Initializes it with 
+		reading and writting permision. Fails if creation fails.
+	*/
+	bool init();
+
+	//! Initalize the raster decoding tool from a raster parameters structure
+	/*!
+		\return true if raster is read to be read/written and false otherwise.
+	*/
+	bool init(TeRasterParams& pars);
+  
+	//! Clear internal structures and disable the raster decoding tool
+	void clear();
+
+	//! Transform a coordinate from line/column domain to projection domain
+	TeCoord2D index2Coord(TeCoord2D pt);
+
+	//! Transform a coordinate from projection domain domain to line/column
+	TeCoord2D coord2Index(TeCoord2D pt);
+
+	//----------------
+	//! A raster iterator
+	/*! 
+		An strucuture that allows the traversal over the raster elements 
+		(pixels) in a similar way as the STL iterators. 
+	*/
+	class TL_DLL iterator
+	{
+		public:
+		//! Constructor
+		/*!
+			\param c0 initial column
+			\param l0 initial line
+			\param nc number of columns
+			\param nl number of lines
+			\param nb number of bands
+			\param pt pointer to the raster to iterate
+		*/
+			iterator(int c0=0, int l0=0, int nc=0, int nl=0, int nb=0, TeRaster* pt=0) : 
+			linCurrent_(l0),
+			colCurrent_(c0),
+			nLines_(nl),
+			nCols_(nc),
+			nBands_(nb),
+			raster_(pt)
+			{}
+			
+			//! Destructor
+			virtual ~iterator()
+			{}
+
+			//! Move iterator forward
+			virtual void moveForward();
+
+			//! Prefix move forward operator
+			iterator& operator++();
+		
+			//! Posfix move forward operator
+			iterator operator++(int);
+
+			//! Returns iterator current line 
+			int currentLine();
+
+			//! Returns iterator current column
+			int currentColumn();
+
+			//! Returns the number of bands
+			int nBands(void);
+
+			//! Iterator de-referencing operator
+			/*!
+				\return a vector (with nbands_ size) with the values in
+				each band, of the element pointed by the iterator
+			*/
+			vector<double> operator*();
+			
+			//! Returns the value in a given band of a element pointed by the iterator 
+			double operator*(int band);
+
+			//! Returns whether two iterators point to the same element
+			bool operator==(const iterator& rhs) const;
+
+			//! Returns whether two iterators point to the different elements
+			bool operator!=(const iterator& rhs) const;
+
+		protected:
+			int linCurrent_, colCurrent_;
+			int nLines_, nCols_;
+			int nBands_;
+			TeRaster* raster_;
+		};   
+
+	// ---------------------  End of class raster Iterator
+
+	//----------------
+	//! A raster iterator with a restriction of area 
+	/*! 
+		A structure that allows to cover the raster elements 
+		(pixels) that are IN or OUT a specific region (polygon)  
+	*/
+	class TL_DLL iteratorPoly : public iterator
+	{
+		public:
+			//! Constructor
+			/*!
+			\param colCurr	initial column
+			\param linCurr	initial line
+			\param nc		number of columns
+			\param nl		number of lines
+			\param nb		number of bands
+			\param pt		pointer to the raster that will be covered
+			\param poly		polygon that defines a specific region 
+			\param str		strategic of the iterator, IN or OUT the polygon 
+			\param linMin	minimal line of the raster that will be covered
+			\param linMax	maximal line of the raster that will be covered
+			\param colMin	minimal column of the raster that will be covered
+			\param colMax	maximal column of the raster that will be covered
+			\param seg		the segments of intersection of the current line 
+			\param posSeg	the current segment 
+			\param nlInPoly		number of lines IN the polygon
+			\param nColsInPoly	number of columns IN the polygon 
+			\param e			iterator end
+			\param minLinCM		minimal line (in world coordinates)
+			\param band			band to iterate
+			*/
+			iteratorPoly(int colCurr, int linCurr, int nc, int nl, int nb, TeRaster* pt, TePolygon& poly,
+						 TeStrategicIterator str, double linMin=0.0, double linMax=0.0, double colMin=0.0, 
+						 double colMax=0.0, TeCoordPairVect seg=TeCoordPairVect(),  
+						 int posSeg=0, int nlInPoly=0, int nColsInPoly=0, bool e=true, double minLinCM=0.0, int band = 0):
+				iterator(colCurr,linCurr,nc,nl,nb,pt),
+				linMin_(linMin),
+				linMax_(linMax),
+				colMin_(colMin),
+				colMax_(colMax),
+				segments_(seg),
+				posSegments_(posSeg),
+				poly_(poly),
+				end_(e),
+				strategy_(str),
+				nLinesInPoly_(nlInPoly),
+				nColsInPoly_(nColsInPoly),
+				linMinCM_(minLinCM),
+				band_(band)
+				{}
+			
+			//! empty contructor
+			iteratorPoly(TeRaster* raster = 0): 
+				iterator(0,0,0,0,0,raster),
+				linMin_(0.0),
+				linMax_(0.0),
+				colMin_(0.0), 
+				colMax_(0.0),
+				posSegments_(0),
+				end_(true),
+				nLinesInPoly_(0),
+				nColsInPoly_(0),
+				band_(0)
+				{}
+
+			//! destructor
+			virtual ~iteratorPoly() {}
+
+			void moveForward();
+			
+			//! Prefix move forward operator
+			iteratorPoly& operator++();
+
+			//! Prefix move orward operator
+			iteratorPoly operator++(int);
+
+			//! Dereferencing operator
+			/*!
+				This operator was designed for compatibility reasons with standard
+				containers of STL. 
+				If there is a band restriction defined it will return the value associated to that band.
+				Otherwise will return the value associated to band 0.
+			*/
+			double operator*(); 
+
+			//! Returns the value of a given band of the element pointed by the iterator 
+			double operator*(int band);
+		
+		    //! Returns the value of of the element pointed by the iterator as TeProperty structure
+			/*!
+				If there is a band restriction defined it will return the value associated to that band.
+				Otherwise will return the value associated to band 0.
+			*/
+			bool getProperty(TeProperty& prop);
+
+			//! Returns the last past one element in the polygon
+			bool end();
+
+			//! Returns the number of lines covered by the iterator
+			int nLinesInPoly();
+
+			//! Returns the number of columns covered by the iterator
+			int nColsInPoly();
+
+		private:
+
+			//! calculate the segment of the current line that intersect the polygon  					
+			void getNewSegment(int linCurr);
+
+			double				linMin_, linMax_;  
+			double				colMin_, colMax_;
+			TeCoordPairVect		segments_;
+			int					posSegments_;
+			TePolygon			poly_;
+			bool				end_;
+			TeStrategicIterator strategy_;
+			int					nLinesInPoly_, nColsInPoly_;
+			double				linMinCM_;	//minimal line in world coordinates 
+			int					band_;		// band restriction
+	};
+
+	//! Returns  an iterator to the first element of the raster
+	iterator begin();
+
+	//! Returns an iterator to the first element of the raster IN or OUT the polygon 
+	/*!
+		\param poly polygon that delimitates the iterator traversal
+		\param st stragetegy used to decide if a pixel is in or out a polygon
+		\param band optional band restriction
+	*/
+	iteratorPoly begin(TePolygon& poly, TeStrategicIterator st, int band=0);
+
+	//! Returns the end past one position of the elements of the raster
+    iterator end() ;
+	//! Returns an iterator to the end element of the raster 
+	/*!
+		\param poly polygon that delimitates the iterator traversal
+		\param st stragetegy used to decide if a pixel is in or out a polygon
+		\param band optional band restriction
+	*/
+	iteratorPoly end(TePolygon& poly, TeStrategicIterator st, int band=0); 
+
+	//! Select all blocks of raster, in a certain resolution factor that intercepts a given bounding box
+	bool selectBlocks(TeBox& bb, int resFac, TeRasterParams& parBlock);
+
+	//! Returns the number of blocks selected by the last block selection
+	int numberOfSelectedBlocks();
+
+	//! Returns the current block of a set selected by the last block selection
+	bool fetchRasterBlock(TeDecoderMemory* memDec);
+
+	//! Clears the current selection of a set selected by the last block selection
+	void clearBlockSelection();
+
+	//! An optimizated method to set values raster images
+	/*
+		This method should be used only to set the values of images with 3 bands associated
+		respectively to the three colour channes Red, Green and Blue
+		\param col column of the image
+		\param lin line of the image
+		\param Rval the value associated to the band 0 (associated to the R colour Channel)
+		\param Gval the value associated to the band 1 (associated to the G colour Channel)
+		\param Bval the value associated to the band 2 (associated to the B colour Channel)
+		\param transp an optional transparency degree, with a range of 0 (totally transparent) to 255 (totally opaque)
+		\return true if if succeed and false otherwise
+	*/
+	bool setElement(int col, int lin, double Rval, double Gval, double Bval, unsigned int /*transp*/ = 255);
+
+	//! Give access to the last message detected by the raster manipulation
+	const string& errorMessage() const;
+	
+  private :
+  
+	  //! Building a raster instance from another one is forbiden !
+	  TeRaster( const TeRaster& ) : TeGeometry()
+	  {}
+
+	  //! Copying a raster instance from another one is forbiden !
+	  const TeRaster& operator=( const TeRaster& ) { return *this; };	
+
+};
+	
+inline TeRasterParams& TeRaster::params()
+{ return params_; }
+
+inline int TeRaster::nBands()
+{ return params_.nBands(); }
+
+inline TeGeomRep TeRaster::elemType() 
+{ return TeRASTER; }
+
+inline bool TeRaster::status()
+{	return params_.status_ != TeRasterParams::TeNotReady; }
+
+inline TeDecoder* TeRaster::decoder()
+{ return decoder_; }
+
+inline TeProjection* TeRaster::projection() 
+{ return params_.projection(); }
+
+inline TeCoord2D TeRaster::index2Coord(TeCoord2D pt)
+{ return decoder_->index2Coord(pt); }
+
+inline TeCoord2D TeRaster::coord2Index(TeCoord2D pt)
+{ return decoder_->coord2Index(pt); }
+
+	
+inline const string& TeRaster::errorMessage() const
+{	return params_.errorMessage_; }
+
+inline int TeRaster::iterator::currentLine()
+{ return linCurrent_;}
+
+inline int TeRaster::iterator::currentColumn()
+{return colCurrent_; }
+
+inline int TeRaster::iterator::nBands(void)
+{	return nBands_; }
+
+inline bool TeRaster::iteratorPoly::end()
+{	return end_; }
+
+inline int TeRaster::iteratorPoly::nLinesInPoly()
+{ return nLinesInPoly_;}
+
+inline int TeRaster::iteratorPoly::nColsInPoly()
+{ return nColsInPoly_;}
+
+/** @defgroup RasterFunc Raster functions
+	A set of functions that manipulates raster representations
+ *  @{
+ */
+/**	Clips a raster representation using a polygon set as a mask
+	\param	whole		pointer to the raster to be clipped
+	\param  mask		the polygon set used as the mask to clip the raaster
+	\param  geomProj	pointer the projection of the polygons used as mask
+	\param  clipName	name of the file (or database table) that will contains the clipped raster
+	\param  background	value to be used as the background of the clipped raster
+	\param	decId		optional parameter that explicitly indicates the decoder (or format) used to generate the clipped raster
+	\return a pointer to the generated clipped raster if it succeed or a null pointer otherwise.
+	
+	If the decId is equal to "DB" it is assumed that the clipped raster will be generated
+	in the same database as the input raster. If the input raster is not in a database, the 
+	routine returns a error.
+*/
+TL_DLL TeRaster*
+TeRasterClipping(TeRaster* whole, TePolygonSet& mask, TeProjection* geomProj, const string& clipName, double background, const string& decId="");
+
+//@}
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeRasterMemManager.cpp b/src/terralib/kernel/TeRasterMemManager.cpp
new file mode 100644
index 0000000..8435add
--- /dev/null
+++ b/src/terralib/kernel/TeRasterMemManager.cpp
@@ -0,0 +1,404 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+#include "TeRasterMemManager.h"
+
+#include "TeUtils.h"
+#include "TeErrorLog.h"
+#include "TeAgnostic.h"
+
+
+TeRasterMemManager::TeRasterMemManager()
+{
+  init();
+}
+
+
+TeRasterMemManager::~TeRasterMemManager()
+{
+  clear();
+}
+
+
+void TeRasterMemManager::clear()
+{
+  /* Cleaning the ram tiles and related structures */
+  
+  TilesPtrsStlVecT::iterator ram_tiles_it = ram_tiles_vec_.begin();
+  TilesPtrsStlVecT::iterator ram_tiles_it_end = ram_tiles_vec_.end();
+  
+  while( ram_tiles_it != ram_tiles_it_end ) {
+    delete[] ( (TilePtrT)(*ram_tiles_it) );
+    ++ram_tiles_it;
+  }
+  
+  if( all_tiles_ptrs_vec_ ) {
+    delete[] all_tiles_ptrs_vec_;
+  }
+  
+  /* cleaning containers */
+  
+  bands_tiles_sizes_.clear();
+  ram_tiles_vec_.clear();
+  mm_objs_vec_.clear();
+  tile2mm_vec_.clear();
+  mm2tile_map_.clear();
+
+  /* Reseting the the default values */
+  
+  init();
+}
+
+bool TeRasterMemManager::reset( unsigned int bands, 
+  unsigned int tiles_per_band, const std::vector< unsigned int >& tiles_sizes,
+  MemoryPolicy mem_pol )
+{
+  clear();
+  
+  TEAGN_TRUE_OR_RETURN( ( ( bands != 0 ) && ( tiles_per_band != 0 ) &&
+    ( tiles_sizes.size() == bands ) ), "Invalid parameters" );
+
+  tiles_per_band_ = tiles_per_band;
+  bands_nmb_ = bands;
+  bands_tiles_sizes_ = tiles_sizes;
+  
+  const unsigned int total_tiles_number = tiles_per_band_ * bands_nmb_;
+  
+  /* Allocating the tiles vector */
+  
+  all_tiles_ptrs_vec_ = new TilePtrT[ total_tiles_number ];
+  TEAGN_TRUE_OR_RETURN( all_tiles_ptrs_vec_,
+    "Unable to allocate the tiles pointers vector" )
+  
+  for( unsigned int tiles_vects_index = 0 ; 
+    tiles_vects_index < total_tiles_number ;
+    ++tiles_vects_index ) {
+      
+    all_tiles_ptrs_vec_[ tiles_vects_index ] = 0;
+  }     
+  
+  /* Allocating tiles */
+  
+  if( mem_pol == DiskMemPol ) {
+    return allocateMMTiles( 0, 0 );
+  } else {
+    unsigned int curr_band = 0;
+    unsigned int curr_tile = 0;
+    TilePtrT newtile_ptr = 0;
+    const unsigned long int max_ram_tiles = getMaxRAMTiles( bands_nmb_,
+      tiles_per_band_, bands_tiles_sizes_ );
+    unsigned int curr_ram_tiles_nmb = 0; 
+    
+    for( curr_band = 0 ; curr_band < bands ; ++curr_band ) {
+      unsigned int tile_bytes = bands_tiles_sizes_[ curr_band ];
+      TEAGN_TRUE_OR_THROW( ( tile_bytes > 0 ), "Invalid tile bytes" );      
+      
+      unsigned long int curr_tile_index = 0;
+      
+      for( curr_tile = 0 ; curr_tile < tiles_per_band_ ; ++curr_tile ) {
+        curr_tile_index = ( curr_band * tiles_per_band_ ) + curr_tile;
+        
+        switch( mem_pol ) {
+          case RAMMemPol :
+          {
+            newtile_ptr = (TilePtrT) new TileDataT[ tile_bytes ];
+              
+            if( newtile_ptr == 0 ) {
+              clear();
+              
+              return false;
+            } else {
+              all_tiles_ptrs_vec_[ curr_tile_index ] = 
+                newtile_ptr;
+                
+              ram_tiles_vec_.push_back( newtile_ptr );
+            }
+              
+            break;
+          }
+          case AutoMemPol :
+          {
+            if( curr_ram_tiles_nmb <= max_ram_tiles ) {
+              newtile_ptr = (TilePtrT) new TileDataT[ tile_bytes ];
+                
+              if( newtile_ptr == 0 ) {
+                return allocateMMTiles( curr_band, curr_tile );
+              } else {
+                all_tiles_ptrs_vec_[ curr_tile_index ] = 
+                  newtile_ptr;
+                  
+                ram_tiles_vec_.push_back( newtile_ptr );
+                
+                ++curr_ram_tiles_nmb;
+              }
+            } else {
+              return allocateMMTiles( curr_band, curr_tile );
+            }
+                            
+            break;
+          }
+          default :
+          {
+            clear();
+            
+            TEAGN_LOG_AND_THROW( "Invalid memory policy" );
+      
+            break;
+          }
+        }
+      }
+    }
+  }
+  
+  return true;
+}
+
+
+void TeRasterMemManager::init()
+{
+  tiles_per_band_ = 0;
+  bands_nmb_ = 0;
+  max_mm_file_file_size_ = 1024 * 1024 * 10;
+  current_active_mmobj_ptr_ = 0;
+  all_tiles_ptrs_vec_ = 0;
+}
+
+
+bool TeRasterMemManager::allocateMMTiles( 
+  unsigned int starting_band_index, unsigned int starting_tile_index )
+{
+  TEAGN_TRUE_OR_THROW( ( bands_tiles_sizes_.size() == bands_nmb_ ),
+    "Invalid tile sizes vector" );    
+  TEAGN_TRUE_OR_THROW( ( starting_band_index < bands_nmb_ ),
+    "Invalid starting_band_index" );    
+  TEAGN_TRUE_OR_THROW( ( starting_tile_index < tiles_per_band_ ),
+    "Invalid starting_tile_index" );    
+    
+  /* Resizing the tiles vector */
+  
+  const unsigned long int total_tiles_number = tiles_per_band_ * bands_nmb_;
+  
+  tile2mm_vec_.resize( total_tiles_number );
+  
+  for( unsigned int tile2mm_vec_index = 0 ; 
+    tile2mm_vec_index < total_tiles_number ;
+    ++tile2mm_vec_index ) {
+      
+    tile2mm_vec_[ tile2mm_vec_index ] = 0;
+  } 
+  
+  /* Allocating mapped memory objects */    
+  
+  for( unsigned int curr_band = starting_band_index ; curr_band < bands_nmb_ ; 
+    ++curr_band ) {
+  
+    const unsigned int tile_size = bands_tiles_sizes_[ curr_band ];
+    TEAGN_TRUE_OR_THROW( ( tile_size <= max_mm_file_file_size_ ), 
+      "Invalid tile size" );
+    
+    const unsigned long int tiles_per_file = ( unsigned long int )
+      floor( ( (double)max_mm_file_file_size_ ) / ( (double) tile_size ) );
+      
+    const unsigned long int file_size = (unsigned long int)
+      ( tiles_per_file * tile_size );
+    
+    unsigned int curr_tiles_in_file = tiles_per_file + 1;
+      
+    unsigned int curr_tile = 0;
+    if( curr_band == starting_band_index ) {
+      curr_tile = starting_tile_index;
+    }
+    
+    unsigned long int curr_tile_index = 0;
+    
+    TeMappedMemory* last_mm_ptr = 0;
+      
+    while( curr_tile < tiles_per_band_ ) {
+      curr_tile_index = ( curr_band * tiles_per_band_ ) + curr_tile;
+    
+      if( curr_tiles_in_file >= tiles_per_file ) {
+        TeSharedPtr< TeMappedMemory > mm_ptr( 
+          new TeMappedMemory() );   
+             
+        if( ! mm_ptr.isActive() ) {
+          TEAGN_LOGERR( "Unable to create mapped memory object" );
+          
+          clear();
+          
+          return false;        
+        }
+        
+        if( ! mm_ptr->reset( file_size, false ) ) {
+          TEAGN_LOGERR( "Unable to allocate memory mapped file" );
+
+          clear();
+          
+          return false;        
+        }
+        
+        last_mm_ptr = mm_ptr.nakedPointer();
+        
+        mm_objs_vec_.push_back( mm_ptr );
+        
+        MM2TileMapNodeT new_mm2tile_node;
+        new_mm2tile_node.first = curr_tile_index;
+        new_mm2tile_node.second = curr_tile_index;
+        
+        mm2tile_map_[ last_mm_ptr ] = new_mm2tile_node;
+        
+        curr_tiles_in_file = 0;
+      }
+      
+      tile2mm_vec_[ curr_tile_index ] = last_mm_ptr;
+      
+      mm2tile_map_[ last_mm_ptr ].second = curr_tile_index;
+      
+      ++curr_tiles_in_file;
+      
+      ++curr_tile;
+    }
+    
+  }
+  
+  return true;
+}
+
+
+unsigned long int TeRasterMemManager::getMaxRAMTiles( unsigned int bands, 
+  unsigned int tiles_per_band,
+  const std::vector< unsigned int >& tiles_sizes)
+{
+  unsigned long int max_ram_tiles = 0;
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    const unsigned int max_ram  = (unsigned int)
+      ( 0.90 * ( (double)TeGetFreePhysicalMemory() ) );
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX  
+    const unsigned int max_ram  = (unsigned int)
+      ( 0.75 * ( (double)TeGetTotalPhysicalMemory() ) );    
+  #else
+    #error "Unsupported platform"
+  #endif    
+  
+  unsigned long int curr_used_ram = 0;
+  
+  for( unsigned int curr_band = 0 ; curr_band < bands ; 
+    ++curr_band ) {
+  
+    const unsigned int tile_size = tiles_sizes[ curr_band ];
+    
+    for( unsigned int curr_tile = 0 ; curr_tile < tiles_per_band ;
+      ++curr_tile ) {
+      
+      if( ( curr_used_ram + tile_size ) > max_ram ) {
+        curr_tile = tiles_per_band;
+        curr_band = bands;
+      } else {
+        ++max_ram_tiles;
+        curr_used_ram += tile_size;
+      }
+    }
+  }
+
+  return max_ram_tiles;
+}
+
+
+void* TeRasterMemManager::getTilePointer( const unsigned int& band, 
+  const unsigned int& tile)
+{
+  const unsigned int tileindex = ( band * tiles_per_band_ ) + tile;
+  
+  TEAGN_DEBUG_CONDITION( ( tileindex < ( tiles_per_band_ * bands_nmb_ ) ),
+    "The required band/tile out of range" );
+    
+  TilePtrT tileptr = all_tiles_ptrs_vec_[ tileindex ];
+  
+  if( tileptr == 0 ) {
+    /* Disabling the current mapping - only one active mapping allowed */
+  
+    if( current_active_mmobj_ptr_ ) {
+      MM2TilesMapT::iterator it = 
+        mm2tile_map_.find( current_active_mmobj_ptr_ );
+        
+      TEAGN_DEBUG_CONDITION( ( it != mm2tile_map_.end() ), 
+        "Cannot find tile into mapped memory to tiles map" );
+    
+      current_active_mmobj_ptr_->toggle( false );
+      
+      const unsigned long int first_tile_index = it->second.first;
+      const unsigned long int last_tile_index_bound = it->second.second + 1;
+      
+      for( unsigned long int all_tiles_ptrs_vec_index = first_tile_index ;
+        all_tiles_ptrs_vec_index < last_tile_index_bound ; 
+        ++all_tiles_ptrs_vec_index ) {
+        
+        all_tiles_ptrs_vec_[ all_tiles_ptrs_vec_index ] = 0;
+      }
+    }
+    
+    /* Enabling the required mapping */
+    
+    TEAGN_DEBUG_CONDITION( ( tileindex < tile2mm_vec_.size() ),
+      "Tiles to mapped memory objects vector index mismatch" );
+    
+    current_active_mmobj_ptr_ = tile2mm_vec_[ tileindex ];
+    TEAGN_DEBUG_CONDITION( ( current_active_mmobj_ptr_ != 0 ),
+      "Invalid active mapping object" );
+    TEAGN_TRUE_OR_THROW( current_active_mmobj_ptr_->toggle( true ),
+      "Unable to activate mapped memory" );
+    
+    /* Updating main vactor mapped memory tiles pointers */
+    
+    TilePtrT mm_start_ptr = ( TilePtrT )
+      current_active_mmobj_ptr_->getPointer();
+      
+    TEAGN_DEBUG_CONDITION( ( band < bands_tiles_sizes_.size() ),
+      "Invalid band" );
+    const unsigned long int tile_size = bands_tiles_sizes_[ band ];    
+    
+    MM2TilesMapT::iterator it = 
+      mm2tile_map_.find( current_active_mmobj_ptr_ );
+    TEAGN_DEBUG_CONDITION( ( it != mm2tile_map_.end() ),
+      "Cannot find tile into mapped memory to tiles map" );     
+      
+    const unsigned long int first_tile_index = it->second.first;
+    const unsigned long int last_tile_index_bound = it->second.second + 1;
+    
+    for( unsigned long int all_tiles_ptrs_vec_index = first_tile_index ;
+      all_tiles_ptrs_vec_index < last_tile_index_bound ; 
+      ++all_tiles_ptrs_vec_index ) {
+      
+      all_tiles_ptrs_vec_[ all_tiles_ptrs_vec_index ] = mm_start_ptr;
+      
+      mm_start_ptr += tile_size;
+    }    
+    
+    tileptr = all_tiles_ptrs_vec_[ tileindex ];
+  }
+  
+  TEAGN_DEBUG_CONDITION( ( tileptr != 0 ), "Invalid tile pointer" )
+  
+  return tileptr;
+}
+
+
diff --git a/src/terralib/kernel/TeRasterMemManager.h b/src/terralib/kernel/TeRasterMemManager.h
new file mode 100644
index 0000000..0fde0a2
--- /dev/null
+++ b/src/terralib/kernel/TeRasterMemManager.h
@@ -0,0 +1,240 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeRasterMemManager.h
+    \brief This file contains a class that deals with a raster memory management
+*/
+
+#ifndef TERASTERMEMMANAGER_H
+  #define TERASTERMEMMANAGER_H
+
+  #include "TeMappedMemory.h"
+  #include "TeSharedPtr.h"
+  
+  #include <vector>
+  #include <map>
+  
+  /**
+   * @brief This class deals with a raster memory management.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   */
+  class TL_DLL TeRasterMemManager {
+  
+    public :
+    
+      /**
+       * @enum Memory policy.
+       */ 
+      enum MemoryPolicy {
+        /**
+         * @brief Automatic memory policy ( Try to use RAM or DISK, 
+         * if there is no avaliable RAM ).
+         */
+        AutoMemPol = 1,
+        /**
+         * @brief RAM memory policy.
+         */
+        RAMMemPol = 2,
+        /**
+         * @brief Disk memory policy ( virtual mapped memory ).
+         */
+        DiskMemPol = 3
+      };    
+    
+      /**
+       * @brief Default Constructor.
+       */
+      TeRasterMemManager();    
+
+      /**
+       * @brief Default Destructor
+       */
+      ~TeRasterMemManager();
+      
+      /**
+       * @brief Clear all data structures.
+       */
+      void clear();
+      
+      /**
+       * @brief Reset the instance following new raster parameters.
+       * @param bands The number of bands (channels).
+       * @param tiles_per_band The tiles inside each band.
+       * @param tiles_sizes The tile size (bytes) for each band.
+       * @param mem_pol Memory policy.
+       * @return true if OK, false on errors.
+       */
+      bool reset( unsigned int bands, unsigned int tiles_per_band,
+        const std::vector< unsigned int >& tiles_sizes,
+         MemoryPolicy mem_pol );
+
+      /**
+       * @brief Returnas a pointer to a internal allocated tile.
+       * @param band Band index.
+       * @param tile Tile index.
+       * @return a pointer to a internal allocated tile. 
+       * @note This pointer is only valid until the next call to this function.
+       */
+      void* getTilePointer( const unsigned int& band, 
+        const unsigned int& tile );      
+      
+    protected :
+    
+      /**
+       * @typedef unsigned char TileDataT 
+       * Tile data type.
+       */    
+      typedef unsigned char TileDataT;    
+    
+      /**
+       * @typedef TileDataT* TilePtrT
+       * Tile pointer type.
+       */    
+      typedef TileDataT* TilePtrT;
+      
+      /**
+       * @typedef std::vector< TilePtrT > TilesPtrsStlVecT 
+       * RAM Tiles vector type.
+       */    
+      typedef std::vector< TilePtrT > TilesPtrsStlVecT;   
+      
+      /**
+       * @typedef std::vector< TeSharedPtr< TeMappedMemory > > MMemsVecT 
+       * Mapped memory objects vector type.
+       */      
+      typedef std::vector< TeSharedPtr< TeMappedMemory > > MMemsVecT;
+      
+      /**
+       * @typedef std::pair< unsigned long int, unsigned long int > MM2TileMapNodeT
+       * Mapped memory to first and last tiles indexes map node type.
+       */       
+      typedef std::pair< unsigned long int, unsigned long int > 
+        MM2TileMapNodeT;
+      
+      /**
+       * @typedef std::multimap< TeMappedMemory*, std::pair< unsigned long int, unsigned long int > MM2TilesMapT
+       * Mapped memory to first and last tiles indexes map type.
+       */        
+      typedef std::map< TeMappedMemory*, MM2TileMapNodeT > MM2TilesMapT;
+      
+      /**
+       * @brief Tiles per band.
+       */    
+      unsigned int tiles_per_band_;
+      
+      /**
+       * @brief The number of bands.
+       */    
+      unsigned int bands_nmb_;
+      
+      /**
+       * @brief The maximum mapped memory file size.
+       */     
+      unsigned long int max_mm_file_file_size_;      
+      
+      /**
+       * @brief A pointer to the current active memory map object.
+       */     
+      TeMappedMemory* current_active_mmobj_ptr_;
+      
+      /**
+       * @brief A vector of tiles sizes for each band.
+       */        
+      std::vector< unsigned int > bands_tiles_sizes_;
+    
+      /**
+       * @brief A vector of pointers to all allocated tiles.
+       * @note Declared as a simple vector to optimize the
+       * tile access.
+       */     
+      TilePtrT* all_tiles_ptrs_vec_;
+      
+      /**
+       * @brief RAM bands pointers vector.
+       */    
+      TilesPtrsStlVecT ram_tiles_vec_;
+      
+      /**
+       * @brief Mapped memory objects pointers vector.
+       */    
+      MMemsVecT mm_objs_vec_;      
+      
+      /**
+       * @brief A vector mapping tiles indexes to their respective mapped 
+       * memory object.
+       */        
+      std::vector< TeMappedMemory* > tile2mm_vec_;
+
+      /**
+       * @brief A map from mapped memory object pointers to their respective
+       * tile indexes.
+       */        
+      MM2TilesMapT mm2tile_map_;
+            
+      /**
+       * @brief Initiates the internal variables to their default values.
+       */    
+      void init();
+      
+      /**
+       * @brief Allocate mapped memory tiles starting at a specific
+       * band and tile number.
+       * @param starting_band_index Starting Band index.
+       * @param starting_tile_index Starting tile index.
+       * @return true if OK, false on errors.
+       * @note bands_ptr_ must be previously allocated.
+       */    
+      bool allocateMMTiles( 
+        unsigned int starting_band_index,
+        unsigned int starting_tile_index );
+        
+      /**
+       * @brief Return the maximum RAM tiles that can fit in the
+       * current RAM for all bands.
+       * @param bands The number of bands (channels).
+       * @param tiles_per_band The tiles inside each band.
+       * @param tiles_sizes The tile size (bytes) for each band.       
+       * @return Return the maximum RAM tiles.
+       */    
+      unsigned long int getMaxRAMTiles( unsigned int bands, 
+        unsigned int tiles_per_band,
+        const std::vector< unsigned int >& tiles_sizes );        
+      
+    private :
+    
+      /**
+       * @brief Alternative Constructor.
+       * @param ext External reference.
+       */    
+      TeRasterMemManager( const TeRasterMemManager& ) {};
+       
+      /**
+       * @brief =operator implementation.
+       * @param ext External reference.
+       */    
+      const TeRasterMemManager& operator=( const TeRasterMemManager& )
+        { return *this; };
+      
+  };
+  
+#endif
+
diff --git a/src/terralib/kernel/TeRasterParams.cpp b/src/terralib/kernel/TeRasterParams.cpp
new file mode 100644
index 0000000..e0aa52d
--- /dev/null
+++ b/src/terralib/kernel/TeRasterParams.cpp
@@ -0,0 +1,877 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32 
+#pragma warning ( disable: 4786 ) 
+#endif
+
+#include "TeRasterParams.h"
+#include "TeUtils.h"
+#include "TeAsciiFile.h"
+#include "TeAgnostic.h"
+#include <cstdlib>
+
+// copy constructor
+TeRasterParams::TeRasterParams(const TeRasterParams& other)
+{
+	resolution_ = other.resolution_;
+	subBand_  = other.subBand_;
+	nlines_		= other.nlines_;
+	ncols_		= other.ncols_;
+	nbands_		= other.nbands_;
+	lutName_	= other.lutName_;
+	swap_		= other.swap_;
+	useDummy_	= other.useDummy_;
+
+	nbitsperPixel_.clear();
+	vmin_.clear();
+	vmax_.clear();
+	bands_.clear();
+	photometric_.clear();
+	dataType_.clear();
+	dummy_.clear();
+	compression_.clear();
+
+	nbitsperPixel_= other.nbitsperPixel_;
+	vmin_= other.vmin_;
+	vmax_= other.vmax_;
+	bands_= other.bands_;
+	photometric_= other.photometric_;
+	dataType_= other.dataType_;
+	dummy_= other.dummy_;
+	compression_= other.compression_;
+
+	resx_ = other.resx_;
+	resy_ = other.resy_;
+	fileName_ = other.fileName_;
+	mode_ = other.mode_;
+	status_ = other.status_;
+	offset_ = other.offset_;
+	tiling_type_ = other.tiling_type_;
+	blockHeight_ = other.blockHeight_;
+	blockWidth_ = other.blockWidth_;
+	decoderIdentifier_ = other.decoderIdentifier_;
+	nTilesInMemory_ = other.nTilesInMemory_;
+	if (other.projection_)
+		projection_ = TeProjectionFactory::make(other.projection_->params());
+	else
+		projection_=0;
+	box_ = other.box_;
+	database_ = other.database_;
+	layerId_ = other.layerId_;
+	objectId_ = other.objectId_;
+
+	interleaving_ = other.interleaving_;
+
+	lutr_.clear();
+	lutg_.clear();
+	lutb_.clear();
+	lutr_ = other.lutr_;
+	lutg_ = other.lutg_;
+	lutb_ = other.lutb_;
+
+	dyJ_ = other.dyJ_;
+	dxI_ = other.dxI_;
+	dyI_ = other.dyI_;
+	dxJ_ = other.dxJ_;
+	x0_ = other.x0_;
+	y0_ = other.y0_;
+	errorMessage_ = other.errorMessage_;
+	hasSetDummy_ = other.hasSetDummy_;
+}
+
+// operator =
+TeRasterParams& 
+TeRasterParams::operator=(const TeRasterParams& rhs)
+{
+	if ( this != &rhs )
+	{
+		resolution_ = rhs.resolution_;
+		subBand_  = rhs.subBand_;
+		nlines_		= rhs.nlines_;
+		ncols_		= rhs.ncols_;
+		nbands_		= rhs.nbands_;
+		swap_		= rhs.swap_;
+		useDummy_	= rhs.useDummy_;
+		lutName_	= rhs.lutName_;
+
+		nbitsperPixel_.clear();
+		vmin_.clear();
+		vmax_.clear();
+		bands_.clear();
+		photometric_.clear();
+		dataType_.clear();
+		dummy_.clear();
+		compression_.clear();
+
+		nbitsperPixel_= rhs.nbitsperPixel_;
+		vmin_= rhs.vmin_;
+		vmax_= rhs.vmax_;
+		bands_= rhs.bands_;
+		photometric_= rhs.photometric_;
+		dataType_= rhs.dataType_;
+		dummy_= rhs.dummy_;
+		compression_= rhs.compression_;
+
+		resx_ = rhs.resx_;
+		resy_ = rhs.resy_;
+		fileName_ = rhs.fileName_;
+		mode_ = rhs.mode_;
+		status_ = rhs.status_;
+		offset_ = rhs.offset_;
+		tiling_type_ = rhs.tiling_type_;
+		blockHeight_ = rhs.blockHeight_;
+		blockWidth_ = rhs.blockWidth_;
+		decoderIdentifier_ = rhs.decoderIdentifier_;
+		nTilesInMemory_ = rhs.nTilesInMemory_;
+		if (projection_)
+		{
+			delete projection_;
+			projection_ = 0;
+		}
+		if (rhs.projection_)
+			projection_ = TeProjectionFactory::make(rhs.projection_->params());
+		box_ = rhs.box_;
+		database_ = rhs.database_;			
+		layerId_ = rhs.layerId_;
+		objectId_ = rhs.objectId_;
+		interleaving_ = rhs.interleaving_;
+
+		lutr_.clear();
+		lutg_.clear();
+		lutb_.clear();
+		lutr_ = rhs.lutr_;
+		lutg_ = rhs.lutg_;
+		lutb_ = rhs.lutb_;
+
+		dyJ_ = rhs.dyJ_;
+		dxI_ = rhs.dxI_;
+		x0_ = rhs.x0_;
+		y0_ = rhs.y0_;
+		dyI_ =  rhs.dyI_;
+		dxJ_ =  rhs.dxJ_;
+		errorMessage_ = rhs.errorMessage_;
+		hasSetDummy_ = rhs.hasSetDummy_;
+	}
+	return *this;
+}
+
+void
+TeRasterParams::resizeToTiling(TeBox& bb, int bWidth, int bHeight)
+{
+	blockHeight_ = bHeight;
+	blockWidth_ = bWidth;
+
+	double bXSize = bWidth*resx_;
+	double bYSize = bHeight*resy_;
+	
+	TeBox baux = adjustToCut(bb, bXSize, bYSize);
+	this->boundingBoxResolution(baux.x1_,baux.y1_,baux.x2_,baux.y2_,resx_,resy_);
+}
+
+//! Calculates the *bounding box* when box coordinates are relative to the center of the pixel
+TeBox	
+TeRasterParams::boundingBox ()
+{ return TeBox (box_.x1()-resx_/2.,
+				box_.y1()-resy_/2.,
+				box_.x2()+resx_/2.,
+				box_.y2()+resy_/2.);
+}
+
+void	
+TeRasterParams::boundingBoxResolution (double x1, double y1, double x2, double y2, double resx, double resy, TeBox::TeBoxCorner lock)
+{
+	double xx2 = x2; //FAMI
+
+	resx_ = resx;
+	resy_ = resy;
+	ncols_  = (int)((x2-x1)/resx_+0.5);
+//FAMI BEGIN
+	if ( (x1+360.) == x2 ) //around the globe
+	{
+		ncols_--;
+		xx2 = x2 - resx_;
+	}
+//FAMI END
+	nlines_ = (int)((y2-y1)/resy_+0.5);
+
+	if (lock == TeBox::TeUPPERLEFT)
+		box_ = TeBox(x1+0.5*resx_, y2-nlines_*resy_+0.5*resy_,
+		             x1+ncols_*resx_-0.5*resx_, y2-0.5*resy_);
+
+	else if (lock == TeBox::TeLOWERLEFT)
+		box_ = TeBox(x1+0.5*resx_, y1+0.5*resy_,
+		             x1+ncols_*resx_-0.5*resx_, y1+nlines_*resy_-0.5*resy_);
+
+	else if (lock == TeBox::TeUPPERRIGHT)
+//FAMI		box_ = TeBox(x2-ncols_*resx_+0.5*resx_, y2-nlines_*resy_+0.5*resy_,
+//FAMI			         x2-0.5*resx_,y2-0.5*resy_);
+		box_ = TeBox(xx2-ncols_*resx_+0.5*resx_, y2-nlines_*resy_+0.5*resy_,
+			         xx2-0.5*resx_,y2-0.5*resy_);
+
+	else		// TeLOWERRIGHT
+//FAMI		box_ = TeBox(x2-ncols_*resx_+0.5*resx_,y1+0.5*resy_,
+//FAMI		             x2-0.5*resx_,y1+nlines_*resy_-0.5*resy_);
+		box_ = TeBox(xx2-ncols_*resx_+0.5*resx_,y1+0.5*resy_,
+		             xx2-0.5*resx_,y1+nlines_*resy_-0.5*resy_);
+}
+
+void	
+TeRasterParams::boundingBoxLinesColumns (double x1, double y1, double x2, double y2, 
+										 int nlines, int ncols, TeBox::TeBoxCorner lock)
+{
+	nlines_ = nlines;
+	ncols_ = ncols;
+	
+	resx_ = (x2-x1)/ncols_;
+	resy_ = (y2-y1)/nlines_;
+
+	if (lock == TeBox::TeUPPERLEFT)
+		box_ = TeBox(x1+0.5*resx_, y2-nlines_*resy_+0.5*resy_,
+		             x1+ncols_*resx_-0.5*resx_, y2-0.5*resy_);
+
+	else if (lock == TeBox::TeLOWERLEFT)
+		box_ = TeBox(x1+0.5*resx_, y1+0.5*resy_,
+		             x1+ncols_*resx_-0.5*resx_, y1+nlines_*resy_-0.5*resy_);
+
+	else if (lock == TeBox::TeUPPERRIGHT)
+		box_ = TeBox(x2-ncols_*resx_+0.5*resx_, y2-nlines_*resy_+0.5*resy_,
+			         x2-0.5*resx_,y2-0.5*resy_);
+
+	else		// TeLOWERRIGHT
+		box_ = TeBox(x2-ncols_*resx_+0.5*resx_,y1+0.5*resy_,
+		             x2-0.5*resx_,y1+nlines_*resy_-0.5*resy_);
+}
+
+void	
+TeRasterParams::boxResolution (double x1, double y1, double x2, double y2, 
+							   double resx, double resy, TeBox::TeBoxCorner lock)
+{
+	resx_ = resx;
+	resy_ = resy;
+
+	ncols_  = (int)((x2-x1)/resx_+0.45)+1;
+	nlines_ = (int)((y2-y1)/resy_+0.45)+1;
+
+	if (lock == TeBox::TeUPPERLEFT)
+		box_ = TeBox(x1, y2-(nlines_-1)*resy_,x1+(ncols_-1)*resx_,y2);
+
+	else if (lock == TeBox::TeLOWERLEFT)
+		box_ = TeBox(x1, y1,x1+(ncols_-1)*resx_,y1+(nlines_-1)*resy_);
+
+	else if (lock == TeBox::TeUPPERRIGHT)
+		box_ = TeBox(x2-(ncols_-1)*resx_, y2-(nlines_-1)*resy_,x2,y2);
+
+	else		// TeLOWERRIGHT
+		box_ = TeBox(x2-(ncols_-1)*resx_,y1,x2,y1+(nlines_-1)*resy_);
+}
+
+void	
+TeRasterParams::boxLinesColumns (double x1, double y1, double x2, double y2, 
+								 int nlines, int ncols, TeBox::TeBoxCorner lock)
+{
+	nlines_ = nlines;
+	ncols_ = ncols;
+
+	resx_ = (x2-x1)/(ncols_-1);
+	resy_ = (y2-y1)/(nlines_-1);
+
+	if (lock == TeBox::TeUPPERLEFT)
+		box_ = TeBox(x1, y2-(nlines_-1)*resy_,x1+(ncols_-1)*resx_,y2);
+
+	else if (lock == TeBox::TeLOWERLEFT)
+		box_ = TeBox(x1, y1,x1+(ncols_-1)*resx_,y1+(nlines_-1)*resy_);
+
+	else if (lock == TeBox::TeUPPERRIGHT)
+		box_ = TeBox(x2-(ncols_-1)*resx_, y2-(nlines_-1)*resy_,x2,y2);
+
+	else		// TeLOWERRIGHT
+		box_ = TeBox(x2-(ncols_-1)*resx_,y1,x2,y1+(nlines_-1)*resy_);
+}
+
+void	
+TeRasterParams::topLeftResolutionSize (double left, double top, 
+									   double resx, double resy, 
+									   int ncol, int nlin, 
+									   bool coordIsCentrePixel)
+{
+	resx_ = resx;
+	resy_ = resy;
+	ncols_  = ncol;
+	nlines_ = nlin;
+	
+	if (coordIsCentrePixel)
+		box_ = TeBox(left,top-(nlin-1)*resy_,left+(ncol-1)*resx_,top);
+	else
+	{
+		TeBox bb(left,top-nlines_*resy_,left+ncols_*resx_,top);
+		box_ = TeBox(bb.x1()+resx_/2.,
+					 bb.y1()+resy_/2.,
+					 bb.x2()-resx_/2.,
+					 bb.y2()-resy_/2.);
+	}
+}
+
+void	
+TeRasterParams::lowerLeftResolutionSize (double left, double lower, 
+										 double resx, double resy, 
+										 int ncol, int nlin, 
+										 bool coordIsCentrePixel)
+{
+	resx_ = resx;
+	resy_ = resy;
+	ncols_  = ncol;
+	nlines_ = nlin;
+	
+	if (coordIsCentrePixel)
+		box_ = TeBox(left,lower,left+(ncol-1)*resx_,lower+(nlin-1)*resy_);
+	else
+	{
+		TeBox bb(left,lower,left+ncols_*resx_,lower+nlines_*resy_);
+		box_ = TeBox(bb.x1()+resx_/2.,
+					 bb.y1()+resy_/2.,
+					 bb.x2()-resx_/2.,
+					 bb.y2()-resy_/2.);
+	}
+}
+
+void 
+TeRasterParams::nBands(int n)
+{
+  TEAGN_TRUE_OR_THROW( ( n > 0 ), "Invalid number of bands" )
+  
+	if (nbands_ != n)
+	{
+		if ( nbands_ == 0 ) {
+		  nbitsperPixel_.resize(nbands_);
+		  vmin_.resize(nbands_);
+		  vmax_.resize(nbands_);
+		  bands_.resize(nbands_);
+		  photometric_.resize(nbands_);
+		  dataType_.resize(nbands_);
+		  dummy_.resize(nbands_);
+		  compression_.resize(nbands_);
+		  double d = dummy_[0];
+		  for (int i = 0; i<n; i++)
+		  {
+			  bands_[i] = i;
+			  vmin_[i] = TeMAXFLOAT;
+			  vmax_[i] = -TeMAXFLOAT;
+			  dataType_[i] = TeUNSIGNEDCHAR;
+			  photometric_[i] = TeRasterParams::TeUnknown;
+			  dummy_[i] = d;
+		  }
+		} else if ( nbands_ > n ) {
+		  for( unsigned int count = ( nbands_ - n ) ; count > 0 ; --count ) {
+		    nbitsperPixel_.pop_back();
+		    vmin_.pop_back();
+		    vmax_.pop_back();
+		    bands_.pop_back();
+		    photometric_.pop_back();
+		    dataType_.pop_back();
+		    dummy_.pop_back();
+		    compression_.pop_back();		  
+		  }
+		} else {
+		  /* nbands_ < n */
+		
+		  for( unsigned int count = ( n - nbands_ ) ; count > 0 ; --count ) {
+		    nbitsperPixel_.push_back( nbitsperPixel_[ nbands_ - 1 ] );
+		    vmin_.push_back( vmin_[ nbands_ - 1 ] );
+		    vmax_.push_back( vmax_[ nbands_ - 1 ] );
+		    bands_.push_back( bands_[ nbands_ - 1 ] );
+		    photometric_.push_back( photometric_[ nbands_ - 1 ] );
+		    dataType_.push_back( dataType_[ nbands_ - 1 ] );
+		    dummy_.push_back( dummy_[ nbands_ - 1 ] );
+		    compression_.push_back( compression_[ nbands_ - 1 ] );  
+		  }		
+		}
+		
+		nbands_ = n;
+	}
+}
+
+void 
+TeRasterParams::projection(TeProjection* proj)
+{
+	if (projection_)
+	{
+		delete projection_;
+		projection_ = 0;
+	}
+	if (proj)
+		projection_ = TeProjectionFactory::make(proj->params());
+}
+
+void 
+TeRasterParams::setDataType(TeDataType type, int band)
+{
+	int nb = 8;
+	double defValue = 0.0;
+	switch (type) {
+	case TeUNSIGNEDCHAR:
+		nb = sizeof(unsigned char)*8;
+		defValue = 255;
+		break;
+	case TeCHAR :
+		defValue = 255;
+		nb = sizeof(char)*8;
+		break;
+	case TeUNSIGNEDSHORT:
+		nb = sizeof(unsigned short)*8;
+		defValue = pow(2.,nb)-1;
+		break;
+	case (TeSHORT):
+		nb = sizeof(short)*8;
+		defValue = pow(2.,nb)-1;
+		break;
+	case (TeUNSIGNEDLONG):
+		nb = sizeof(unsigned long)*8;
+		defValue = pow(2.,nb)-1;
+		break;
+	case (TeLONG):
+		nb = sizeof(long)*8;
+		break;
+	case (TeFLOAT):
+		nb = sizeof(float)*8;
+		defValue = pow(2.,nb)-1;
+		break;
+	case (TeDOUBLE):
+		nb = sizeof(double)*8;
+		defValue = TeMAXFLOAT;
+        break;
+    default:
+        break;
+	}
+	if (band<0 || band>= (int)dataType_.size())
+		for (unsigned int i=0; i<dataType_.size();++i)
+		{
+			dataType_[i]=type;
+			nbitsperPixel_[i]=nb;
+			if (!hasSetDummy_)
+				dummy_[i]=defValue;
+		}
+	else
+	{
+		dataType_[band]=type;
+		nbitsperPixel_[band]=nb;
+		dummy_[band]=defValue;
+	}
+}
+
+int TeRasterParams::elementSize(int band)
+{
+	switch (dataType_[band]) {
+	case TeUNSIGNEDCHAR:
+		return sizeof(unsigned char);
+	case TeCHAR :
+		return sizeof(char);
+	case TeUNSIGNEDSHORT:
+		return sizeof(unsigned short);
+	case (TeSHORT):
+		return sizeof(short);
+	case TeINTEGER:
+		return sizeof(int);
+	case (TeUNSIGNEDLONG):
+		return (sizeof(unsigned long));
+	case (TeLONG):
+		return (sizeof(long));
+	case (TeFLOAT):
+		return (sizeof(float));
+	default:
+		return (sizeof(double));
+	}
+}
+
+
+void 
+TeRasterParams::setPhotometric(TeRasterParams::TeRasterPhotometricInterpretation photom, int band)
+{
+	if (band<0 || band>= (int)photometric_.size())
+		for (unsigned int i=0; i<photometric_.size(); photometric_[i]=photom,i++);
+	else
+		photometric_[band]=photom;
+}
+
+void 
+TeRasterParams::setCompressionMode(TeRasterParams::TeRasterCompressionMode cmode, int band)
+{
+	if (band<0 || band>= (int)compression_.size())
+		for (unsigned int i=0; i<compression_.size(); compression_[i]=cmode,i++);
+	else
+		compression_[band] = cmode;
+}
+
+void 
+TeRasterParams::setDummy(double dummy, int band)
+{
+	if (band<0 || band>= (int)dummy_.size())
+		for (unsigned int i=0; i<dummy_.size(); dummy_[i]=dummy,i++);
+	else
+		dummy_[band] = dummy;
+	this->useDummy_ = true;
+	hasSetDummy_ = true;
+}
+
+TeCoord2D 
+TeRasterParams::coord2Index (const TeCoord2D& pt) const
+{
+	double i, j;
+	if (dxI_ != 0 || dyJ_ != 0)
+	{
+		double x = pt.x();
+		double y = pt.y();
+		
+		i = (dyJ_*(x-x0_)-dxJ_*(y-y0_))/(dxI_*dyJ_-dxJ_*dyI_);
+		j = (x-x0_-i*dxI_)/dxJ_;
+		return TeCoord2D (j,i);
+	}
+	else
+	{
+		i = (pt.x() - box_.x1()) / resx_;
+		j = (box_.y2() - pt.y()) / resy_;
+		return TeCoord2D (i,j);
+	}
+}
+
+TeCoord2D 
+TeRasterParams::index2Coord (const TeCoord2D& pt) const
+{
+	double x,y;
+	double i = pt.y();
+	double j = pt.x();
+		
+	if (dxI_ != 0 || dyJ_ != 0)
+	{
+		x = x0_ + i*dxI_ + j*dxJ_;
+		y = y0_ + i*dyI_ + j*dyJ_;
+	}
+	else
+	{
+		x = box_.x1() + pt.x() * resx_;
+		y = box_.y2() - pt.y() * resy_;
+	}
+	return TeCoord2D (x,y);
+}
+
+void
+TeRasterParams::writeParametersFile()
+{
+	string metFileName = TeGetName (fileName_.c_str())+".met";
+	try {
+		TeAsciiFile metFile(metFileName,"w");
+		string line = "%Raw raster file metadata\n";
+		metFile.writeString(line);
+		line = "NROWS " + Te2String(nlines_);
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		line = "NCOLS " + Te2String(ncols_);
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		line = "NBANDS " + Te2String(this->nBands());
+		metFile.writeString(line);
+		metFile.writeNewLine();
+
+		if (this->nBands() > 1)
+		{
+			line = "INTERLEAVING ";
+			if (interleaving_ == TeRasterParams::TePerPixel)
+				line += "BIP";
+			else if (interleaving_ == TeRasterParams::TePerLine)
+				line += "BIL";
+			else
+				line += "BSQ";
+			metFile.writeString(line);
+			metFile.writeNewLine();
+		}
+
+		int ndecimals = 0;
+		line = "DATATYPE ";
+		if (dataType_[0] == TeBIT)
+			line += "bit";
+		else if (dataType_[0] == TeUNSIGNEDCHAR)
+			line += "unsignedchar";
+		else if (dataType_[0] == TeCHAR)
+			line += "char";
+		else if (dataType_[0] == TeUNSIGNEDSHORT)
+			line += "unsignedshort";
+		else if (dataType_[0] == TeSHORT)
+			line += "short";
+		else if (dataType_[0] == TeINTEGER)
+			line += "integer";
+		else if (dataType_[0] == TeUNSIGNEDLONG)
+			line += "unsignedlong";
+		else if (dataType_[0] == TeLONG)
+			line += "long";
+		else if (dataType_[0] == TeFLOAT)
+		{
+			line += "float";
+			ndecimals = 6;
+		}
+		else if (dataType_[0] == TeDOUBLE)
+		{
+			line += "double";	
+			ndecimals = 10;
+		}
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		
+		if (swap_)
+		{
+			line = "SWAPPED yes";
+			metFile.writeString(line);
+			metFile.writeNewLine();
+		}
+		else
+			line.clear();
+		if (useDummy_)
+		{
+			line += "NO_DATA " + Te2String(dummy_[0], ndecimals);
+			metFile.writeString(line);
+			metFile.writeNewLine();
+		}
+    
+    if( projection_ ) {
+      if (projection_->name() == "NoProjection" ||
+        projection_->name() == "LatLong") {
+        
+        ndecimals = 8;
+      } else {
+        ndecimals = 3;
+      }
+    } else {
+      ndecimals = 8;
+    }
+
+		line = "RESOLUTION_X " + Te2String(resx_,ndecimals);
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		line = "RESOLUTION_Y " + Te2String(resy_,ndecimals);
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		line = "LOWERLEFT_X " + Te2String(this->box().x1_,ndecimals);
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		line = "LOWERLEFT_Y " + Te2String(this->box().y1_,ndecimals);
+		metFile.writeString(line);
+		metFile.writeNewLine();
+		if (this->projection())
+		{
+			line = "PROJECTION ";
+			line += this->projection()->describe();
+			metFile.writeString(line);
+			metFile.writeNewLine();
+			line = "DATUM " +  this->projection()->datum().name();
+			metFile.writeString(line);
+		}
+	}
+	catch(...)
+	{
+	}
+}
+
+
+
+void 
+TeRasterParams::readParametersFile()
+{
+	// read all keys in the metadata file (there is no order expected) 
+	string metFileName = TeGetName (fileName_.c_str())+".met";
+	map<string,string> metadata;
+	try {
+		TeAsciiFile metFile(metFileName,"r");
+		string key, value;
+		while (metFile.isNotAtEOF())
+		{
+			key = metFile.readString();
+			if (key[0] == '%')
+			{
+				metFile.findNewLine();
+				continue;
+			}
+			value = metFile.readString();
+			metadata.insert(make_pair(key,value));
+			metFile.findNewLine();
+		}
+	}
+	catch(...)
+	{
+	}
+	if (!metadata.empty())
+	{
+		double xll=0, yll=0;
+		map<string,string>::iterator it;
+		it = metadata.find("NROWS");
+		if (it != metadata.end())
+			nlines_ = atoi(it->second.c_str());
+		it = metadata.find("NCOLS");
+		if (it != metadata.end())
+			ncols_ = atoi(it->second.c_str());
+		it = metadata.find("NBANDS");
+		if (it != metadata.end())
+			this->nBands(atoi(it->second.c_str()));
+		else
+			this->nBands(1);
+		it = metadata.find("RESOLUTION_X");
+		if (it != metadata.end())
+			resx_ = atof(it->second.c_str());
+		it = metadata.find("RESOLUTION_Y");
+		if (it != metadata.end())
+			resy_ = atof(it->second.c_str());
+		it = metadata.find("LOWERLEFT_X");
+		if (it != metadata.end())
+		{
+			xll = atof(it->second.c_str());
+			it = metadata.find("LOWERLEFT_Y");
+			if (it != metadata.end())
+			{
+				yll = atof(it->second.c_str());
+				lowerLeftResolutionSize(xll,yll, resx_, resy_,ncols_, nlines_);
+			}
+		}
+		it = metadata.find("INTERLEAVING");
+		if (it != metadata.end())
+		{
+			if (it->second == "BIL")
+				interleaving_ = TeRasterParams::TePerLine;
+			else if (it->second == "BSQ")
+				interleaving_ = TeRasterParams::TePerBand;
+			else  interleaving_ = TeRasterParams::TePerPixel;
+		}
+
+		it = metadata.find("DATATYPE");
+		if (it != metadata.end())
+		{
+			if (it->second == "bit")
+				this->setDataType(TeBIT);
+			else if (it->second == "unsignedchar")
+				this->setDataType(TeUNSIGNEDCHAR);
+			else if (it->second == "char")
+				this->setDataType(TeCHAR);
+			else if (it->second == "unsignedshort")
+				this->setDataType(TeUNSIGNEDSHORT);
+			else if (it->second == "short")
+				this->setDataType(TeSHORT);
+			else if (it->second == "integer")
+				this->setDataType(TeINTEGER);
+			else if (it->second == "unsignedlong")
+				this->setDataType(TeUNSIGNEDLONG);
+			else if (it->second == "long")
+				this->setDataType(TeLONG);
+			else if (it->second == "float")
+				this->setDataType(TeFLOAT);
+			else if (it->second == "double")
+				this->setDataType(TeDOUBLE);
+		}
+		it = metadata.find("SWAPPED");
+		if (it != metadata.end() && it->second == "yes")
+			swap_ = true;
+
+		it = metadata.find("NO_DATA");
+		if (it != metadata.end())
+		{
+			useDummy_ = true;
+			this->setDummy(atof(it->second.c_str()));
+		}
+			
+		it = metadata.find("PROJECTION");
+		if (it != metadata.end())
+		{
+			string projdesc = it->second;
+			TeProjectionParams pars;
+			it = metadata.find("DATUM");
+			if (it != metadata.end())
+			{
+				TeDatum dat = TeDatumFactory::make(it->second);
+				pars.datum = dat;
+			}
+			if (decodifyDescription(projdesc,pars))
+			{
+				TeProjection* proj = TeProjectionFactory::make(pars);
+				this->projection(proj);
+			}
+		}
+	}
+}
+
+void 
+TeRasterParams::setNavigationParameters(const vector<double>& nwf)
+{
+	if (nwf.size() < 6)
+		return;
+
+	dxJ_ = nwf[0];
+	dxI_ = nwf[1];
+	dyJ_ = nwf[2];
+	dyI_ = nwf[3];
+	x0_ = nwf[4];
+	y0_ = nwf[5];
+	resx_ = dxJ_;
+	resy_ = ABS(dyI_);
+
+	if (nwf[1] == 0. && nwf[2] == 0)
+	{
+		this->topLeftResolutionSize(nwf[4],nwf[5],nwf[0],-1*nwf[3],ncols_,nlines_);
+		return;
+	}
+
+	// set the bounding box considering the navigation parameters 
+	// assumes that: x0 and y0 are relative to the center of the raster element
+
+	double xmin = min(x0_-0.5*dxJ_-0.5*dxI_,x0_-0.5*dxJ_+(nlines_-0.5)*dxI_);
+	double xmax = max(x0_+(ncols_-0.5)*dxJ_-0.5*dxI_,x0_+(ncols_-0.5)*dxJ_+(nlines_-0.5)*dxI_);
+	double ymin = min(y0_+(nlines_-0.5)*dyI_-0.5*dyJ_,y0_+(nlines_-0.5)*dyI_+(ncols_*0.5)*dyJ_);
+	double ymax = max(y0_-0.5*dyI_-0.5*dyJ_,y0_-0.5*dyI_+(ncols_*0.5)*dyJ_);
+	boundingBoxLinesColumns(xmin,ymin,xmax,ymax,nlines_,ncols_);
+}
+
+void 
+TeRasterParams::getNavigationParameters(vector<double>& nwf)
+{
+	nwf.clear();
+	if (dxI_ != 0. || dyJ_ != 0.)
+	{
+		nwf.push_back(dxJ_);
+		nwf.push_back(dxI_);
+		nwf.push_back(dyJ_);
+		nwf.push_back(dyI_);
+		nwf.push_back(x0_);
+		nwf.push_back(y0_);
+	}
+	else
+	{
+		nwf.push_back(resx_);
+		nwf.push_back(0.);
+		nwf.push_back(0.);
+		nwf.push_back(-1*resy_);
+		nwf.push_back(box_.x1_);
+		nwf.push_back(box_.y2_);
+	}
+}
+
+void 
+TeRasterParams::setNLinesNColumns(int nlines, int ncolumns)
+{
+	this->lowerLeftResolutionSize(0.5,0.5,1,1,ncolumns, nlines);
+}
+
diff --git a/src/terralib/kernel/TeRasterParams.h b/src/terralib/kernel/TeRasterParams.h
new file mode 100644
index 0000000..11e3b85
--- /dev/null
+++ b/src/terralib/kernel/TeRasterParams.h
@@ -0,0 +1,500 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeRasterParams.h
+    \brief This file contains definitions about parameters of a raster structure
+*/
+#ifndef  __TERRALIB_INTERNAL_RASTERPARAMS_H
+#define  __TERRALIB_INTERNAL_RASTERPARAMS_H
+
+#include "TeProjection.h"
+#include "TeBox.h"
+#include "TeDataTypes.h"
+
+#include <string>
+#include <list>
+#include <vector>
+
+using namespace std;
+
+class TeDatabase;
+
+//!  A class to handle the parameters set associated with a raster data
+/*! 
+This class is a data structure to store and manipulate a set of parameters and definitions that characterizes 
+a raster data. It contains parameters relative to storaging, geographical or interpretation aspects.
+Not all parameters are valid, or make sense, for all raster data.
+Most parameters are public and can be accessed directly. The private ones should be acessed
+through the methods provided.
+\sa TeRaster
+*/
+class TL_DLL TeRasterParams
+{
+public:
+
+	//! Pixels interleaving mode: used by rasters in memory and files in raw formats
+	enum TeRasterInterLeavingMode
+	{	
+		TePerPixel, // BIP - Band Interleaved by Pixel
+		TePerLine,	// BIL - Band Interleaved by Line
+		TePerBand	// BSQ - Band Sequential
+	};
+	
+	//! Photometric interpretation of a raster data
+	enum TeRasterPhotometricInterpretation
+	{ TeUnknown, TePallete, TeMultiBand, TeRGB };
+	
+	//! Status of a raster data, in terms of reading and writting possibilities
+	enum TeRasterStatus
+	{ TeNotReady, TeReadyToRead, TeReadyToWrite };
+
+	//! Compression modes of a raster data 
+	enum TeRasterCompressionMode
+	{ TeNoCompression, TeZLib, TeJpeg, TeTiffCompression };
+	
+	//! Tiling type modes to store raster data in a TerraLib database 
+	enum TeRasterTilingType
+	{  TeExpansible=1, TeNoExpansible=2 };
+	
+
+	//! Default contructor
+	TeRasterParams () :
+		nlines_(0),
+		ncols_(0),
+		resx_(1),
+		resy_(1),
+		swap_(false),
+		useDummy_(false),
+		mode_('r'),
+		status_(TeRasterParams::TeNotReady),
+		resolution_(1),
+		subBand_(0),
+		offset_(0),
+		tiling_type_(TeRasterParams::TeExpansible),
+		blockHeight_(0),
+		blockWidth_(0),
+		nTilesInMemory_(0),
+		blockId_(""),	
+		decoderIdentifier_(""),	
+		database_ (0),
+		layerId_(-1),
+		objectId_(""),
+		interleaving_(TeRasterParams::TePerPixel),
+		lutName_(""),
+		dxJ_(0.0),
+		dxI_(0.0),
+		dyJ_(0.0),
+		dyI_(0.0),
+		x0_(0.0),
+		y0_(0.0),
+		box_(TeBox()),
+		projection_(0)
+	{
+		nbands_= 1;
+		nbitsperPixel_.resize(nbands_);
+		vmin_.resize(nbands_);
+		vmax_.resize(nbands_);
+		bands_.resize(nbands_);
+		photometric_.resize(nbands_);
+		dataType_.resize(nbands_);
+		dummy_.resize(nbands_);
+		compression_.resize(nbands_);
+		for (int i=0; i<nbands_; i++)
+		{
+			bands_[i] = i;
+			vmin_[i] = TeMAXFLOAT;
+			vmax_[i] = -TeMAXFLOAT;
+			dataType_[i] = TeUNSIGNEDCHAR;
+			photometric_[i] = TeRasterParams::TeMultiBand;
+			dummy_[i] = 255;
+		}
+		hasSetDummy_ = false;
+	}
+
+	//! Copy constructor
+	TeRasterParams(const TeRasterParams& other);
+
+	//! Operator=
+	TeRasterParams& operator=(const TeRasterParams& rhs);
+
+	//! Destructor
+	virtual ~TeRasterParams()
+	{
+		bands_.clear();
+		vmin_.clear();
+		vmax_.clear();
+		if (!lutr_.empty())
+		{
+			lutr_.clear();
+			lutg_.clear();
+			lutb_.clear();
+		}
+		photometric_.clear();
+		dataType_.clear();
+		dummy_.clear();
+		compression_.clear();
+		if (projection_)
+			delete projection_;
+		hasSetDummy_ = false;
+	}
+	
+	/** @name Extension
+	*  Methods to deal with the spatial extensions of a raster data
+	*/
+	//@{	
+	//! Returns the box based on the coordinates of center of the corner elements
+	const TeBox& box()
+	{ return box_; }
+
+	//! Returns the outline box 
+	TeBox boundingBox();
+
+	//! Sets extension parameters
+	/*
+		This methods recalculates the number of lines and columns and box accordingly to 
+		an input bounding box and X and Y resolutions
+		\param x1 bounding box lower left point X coordinate 
+		\param y1 bounding box lower left point Y coordinate 
+		\param x2 bounding box upper right point X coordinate
+		\param y2 bounding box upper right point Y coordinate
+		\param resx X resolution
+		\param resy Y resolution
+		\param lock corner of the bounding box that should be preserved
+	*/
+	void boundingBoxResolution (double x1, double y1, double x2, double y2, double resx, double resy, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
+
+	//! Sets extension parameters
+	/*
+		This methods recalculates the resolutions and box accordingly to 
+		a given bounding box and number of lines and columns
+		\param x1 bounding box lower left point X coordinate 
+		\param y1 bounding box lower left point Y coordinate 
+		\param x2 bounding box upper right point X coordinate
+		\param y2 bounding box upper right point Y coordinate
+		\param nlines  number of lines
+		\param ncols number of columns
+		\param lock corner of the bounding box that should be preserved
+	*/
+	void boundingBoxLinesColumns (double x1, double y1, double x2, double y2, 
+		                          int nlines, int ncols, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
+
+	//! Sets extension parameters
+	/*
+		This methods recalculates the number of lines and columns and box accordingly to 
+		a given box and X and Y resolutions
+		\param x1 box lower left point X coordinate 
+		\param y1 box lower left point Y coordinate 
+		\param x2 box upper right point X coordinate
+		\param y2 box upper right point Y coordinate
+		\param resx X resolution
+		\param resy Y resolution
+		\param lock corner of the bounding box that should be preserved
+	*/
+	void boxResolution (double x1, double y1, double x2, double y2, 
+		                double resx, double resy, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
+
+	//! Sets extension parameters
+	/*
+		This methods recalculates the resolutions and box accordingly to 
+		a given box and number of lines and columns
+		\param x1 box lower left point X coordinate 
+		\param y1 box lower left point Y coordinate 
+		\param x2 box upper right point X coordinate
+		\param y2 box upper right point Y coordinate
+		\param nlines  number of lines
+		\param ncols number of columns
+		\par Calculates X resolution and Y resolution 
+		\param lock corner of the bounding box that should be preserved
+	*/
+	void boxLinesColumns (double x1, double y1, double x2, double y2, 
+		                  int nlines, int ncols, TeBox::TeBoxCorner lock = TeBox::TeUPPERLEFT);
+
+	//! Sets extension parameters
+	/*
+		\param left lower left point X coordinate 
+		\param top  upper right point Y coordinate
+		\param resx X resolution
+		\param resy Y resolution
+		\param nlines  number of lines
+		\param ncols number of columns
+		\param coordIsCentrePixel flag to indicate that top left coordinate is centre of pixel
+	*/
+	void topLeftResolutionSize (double left, double top, double resx, double resy, int ncol, int nlin, bool coordIsCentrePixel=true);
+		
+	//! Sets extension parameters
+	/*
+		\param left lower left point X coordinate 
+		\param lower lower left point Y coordinate
+		\param resx X resolution
+		\param resy Y resolution
+		\param nlines  number of lines
+		\param ncols number of columns
+		\param coordIsCentrePixel flag to indicate that top left coordinate is centre of pixel
+	*/
+	void lowerLeftResolutionSize (double left, double lower, double resx, double resy, int ncol, int nlin, bool coordIsCentrePixel=true);
+
+	//! Sets default extension parameters
+	/* 
+		Sets a valid bouding box, considering a resolution of 1x1 and
+		that the coordinate of the center of lower-left element is (0.5,0.5)
+		\param nlines  number of lines
+		\param ncols number of columns
+	*/
+	void setNLinesNColumns(int nlines, int ncolumns);
+
+	//! Resizes the raster bounding box to cut it exactly in tiles of a give size
+	/*! 
+		\param bb an initial bounding box
+		\param bWidth block width (in number of elements/pixels)
+		\param bHeight block height (in number of elements/pixels)
+		\note keeps the defined X an Y resolutions
+	*/ 
+	void resizeToTiling(TeBox& bb, int bWidth, int bHeight);
+	//@}
+
+	//! Sets the number of bands, or dimentions in a raster data
+	/*
+		\param n number of bands
+		\note If the required number of bands is greater than the 
+		current number of bands, the last band characteristics 
+		will be copied to the new defined bands.
+	*/
+	void nBands(int n);
+
+	//! Sets the projection
+	/*
+		\param proj a pointer to a terralib projection instance
+		A new instance of projection is created according to the parameters described by proj.
+	*/
+	void projection(TeProjection* proj);
+
+	//! Returns the projection
+	TeProjection* projection()
+	{	return projection_; }
+	
+
+	//! Transform a coordinate from world domain to line/column domain
+	TeCoord2D coord2Index (const TeCoord2D& pt) const;
+
+	//! Transform a coordinate from line/column domain to world domain
+	TeCoord2D index2Coord (const TeCoord2D& pt) const;
+
+
+	int nlines_;			//!< number of lines
+	int ncols_;			//!< number of columns
+
+	double	resx_,			//!< horizontal resolution
+		resy_;			//!< vertical resolution	
+
+	bool swap_;			//!< a flag to indicate that the values of the elements of the raster are swapped
+	bool useDummy_;			//!< a flag to indicate that raster has dummy values
+	char	mode_;			//!< a character indicating the access mode to the raster data: 'r', 'w' or 'c'
+	TeRasterStatus 	status_;	//! Status for reading and writing to raster	
+	
+	/** @name Parameters variable per band
+	*/
+	//@{	
+	vector<int>	nbitsperPixel_;		//!< number of bits per pixel 
+	vector<double>	vmin_;			//!< minimum value 
+	vector<double>	vmax_;			//!< maximum value 
+	vector<int>	bands_;			//!< bands information 
+	vector<double>	dummy_;			//!< no data value
+	vector<TeRasterPhotometricInterpretation>   photometric_;	//!< photometric interpretation
+	vector<TeRasterCompressionMode>	compression_;	//!< compression type 
+	vector<TeDataType> 		dataType_;	//!< computational size of elements
+
+	//! Sets the size of the elements in a particular or in every band
+	/*
+		\param type the computational data type
+		\param band number of the band. Default: all bands 
+	*/
+	void setDataType(TeDataType type, int band=-1);
+
+	//! Returns the size in bytes of each raster element
+	int elementSize(int band=0);
+
+	//! Sets the photometric type in a particular or in every band
+	/*
+		\param photom the photometric interpretation
+		\param band number of the band. Default: all bands 
+	*/
+	void setPhotometric(TeRasterPhotometricInterpretation photom, int band=-1);
+
+	//! Sets the compression mode of each band
+	/*
+		\param cmode the compression mode
+		\param band number of the band. Default: all bands 
+	*/
+	void setCompressionMode(TeRasterCompressionMode cmode, int band=-1);
+
+	//! Sets the dummy value in each band
+	/*
+		\param dummy dummy value
+		\param band number of the band. Default: all bands 
+	*/
+	void setDummy(double dummy, int band=-1);
+	//@}
+
+	/** @name Resolution level parameters
+	* Used when raster has different levels of resolution
+	*/
+	//@{
+	int resolution_;		//! resolution level 
+	int subBand_;			//! sub band identification 
+	//@}
+
+	/** @name File parameters
+	* Used when raster is stored in files
+	*/
+	//@{	
+	string	fileName_;		//!< name of a raster file
+	int offset_;			//!< offset 
+	//@}
+		
+	/** @name Tilling parameters
+	*/
+	//@{
+	TeRasterTilingType	tiling_type_; //!< raster tiling mode 
+	int blockHeight_;		//!< tiles height 
+	int blockWidth_;		//!< tiles width 
+	int nTilesInMemory_;		//!< number of tiles to be kept in memory
+	string blockId_;		//!< tiles identification  
+	//@}
+
+	string	decoderIdentifier_;	//!< decoder associated to his raster
+	
+	//! Returns the identifier of the decoder associated to the raster
+	const string& decName() const 
+	{ return decoderIdentifier_; }
+	//set  the identifier of the decoder associated to the raster
+	void  decName(const string& decoder)  
+	{ decoderIdentifier_ = decoder; }
+		
+		
+	/** @name Tilling parameters
+	*/
+	//@{
+	TeDatabase*	database_;	//!< pointer to a TerraLib database where the raster is stored
+	int 		layerId_;	//!< identification of the layer that contains the raster
+	string 		objectId_;	//!< identification of an object associated to this raster geometry
+	//@}
+
+	TeRasterInterLeavingMode interleaving_;	//!< interleaving mode
+
+	/** @name Raster pallete
+	*  Look up table associated to a raster 
+	*/
+	//@{ 
+	string	lutName_;		//!< name of a lut table associated to this raster
+	vector<unsigned short> lutr_;  	//!< red pallete
+	vector<unsigned short> lutg_;  	//!< green pallete
+	vector<unsigned short> lutb_;  	//!< blue pallete
+
+	//! Returns the name of the lut 
+	const string& lutName() 
+	{ return lutName_; }
+	//@}
+
+	/** @name Navigation parameters
+	*  Parameters associated to translation/rotation of the positioning of the raster data
+	*/
+	//@{ 
+	double dxJ_;	//!< X offset due to increase of one column position		       
+	double dxI_;	//!< X offset due to increase of one line position		       
+	double dyJ_;	//!< Y offset due to increase of one column position		       
+	double dyI_;	//!< Y offset due to increase of one line position		       
+	double x0_;		//!< X coordinate of the upper left raster element
+	double y0_;		//!< Y coordinate of the upper left raster element
+
+	/** Sets the navigation parameters
+		\param nwf the navigation parameters set
+		\note this method should be called after the number of lines and columns has been set
+
+		\verbatim
+		The Navigation parameters describe a transformation from column/line domain (i,j)
+        to geographical world (x,y), so that:
+		| x = x0 + i*dxJ + j*dxI
+		| y = y0 + i*dyJ + j*dyI
+
+		and:
+
+		|i = (dyI*(x-x0) - dxI*(y-y0)) / (dxJ*dyI-dyJ*dxI)
+		|j = (dyJ*(x-x0) - dxJ*(y-y0)) / (dyJ*dxI-dxJ*dyI)
+
+		where:
+		nwf[0] = dxJ : the offset in the X direction along each column
+		nwf[1] = dxI : the offset in the X direction along each line
+		nwf[2] = dyJ : the offset in the Y direction along each column
+		nwf[3] = dyI : the offset in the Y direction along each line
+		nwf[4] = x0  : X coordinate of the center of the upper left raster element
+		nwf[5] = y0  : Y coordinate of the center of the upper left raster element
+		\endverbatim
+	*/
+	void setNavigationParameters(const vector<double>& nwf);
+
+	/** Returns the georeferecing parameters 
+		\param nwf vector of double to return the navigation parameters set
+		\verbatim
+		The Navigation parameters describe a transformation from column/line domain (i,j)
+        to geographical world (x,y), so that:
+		| x = x0 + i*dxJ + j*dxI
+		| y = y0 + i*dyJ + j*dyI
+
+		and:
+
+		|i = (dyI*(x-x0) - dxI*(y-y0)) / (dxJ*dyI-dyJ*dxI)
+		|j = (dyJ*(x-x0) - dxJ*(y-y0)) / (dyJ*dxI-dxJ*dyI)
+
+		where:
+		nwf[0] = dxJ : the offset in the X direction along each column
+		nwf[1] = dxI : the offset in the X direction along each line
+		nwf[2] = dyJ : the offset in the Y direction along each column
+		nwf[3] = dyI : the offset in the Y direction along each line
+		nwf[4] = x0  : X coordinate of the center of the upper left raster element
+		nwf[5] = y0  : Y coordinate of the center of the upper left raster element
+		\endverbatim
+	*/
+	void getNavigationParameters(vector<double>& nwf);
+	//@}
+
+	//! Returns the number of bands of the raster
+	int nBands() const
+	{ return nbands_; }
+	
+	//! Saves the parameters in a ASCII File, in TerraLib format
+	void writeParametersFile();
+	
+	//! Reads the parameters described in a ASCII File, in TerraLib format
+	void readParametersFile();
+
+	//! String that contains any error or warning message that raster manipulation might have detected
+	string errorMessage_;
+	
+private:
+	int	nbands_;		//!< number of bands
+	TeBox	box_;			//!< raster box in center of pixel coordinates
+	TeProjection* projection_;	//!< raster projection
+	bool hasSetDummy_;
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeRasterRemap.cpp b/src/terralib/kernel/TeRasterRemap.cpp
new file mode 100644
index 0000000..f0140eb
--- /dev/null
+++ b/src/terralib/kernel/TeRasterRemap.cpp
@@ -0,0 +1,697 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeDefines.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeRasterRemap.h"
+#include "TeVectorRemap.h"
+#include "TeProgress.h"
+#include <time.h>
+
+
+#include <algorithm>	// for max and min
+#include <cstdlib>		// for abs
+
+bool TePointOnLine (TeCoord2D& p, TeCoord2D& q, TeCoord2D& t, double tol)
+{
+	int	tx, ty, px, py, qx, qy, dx, dy;
+
+	px = (int)(p.x () / tol);
+	py = (int)(p.y () / tol);
+
+	qx = (int)(q.x () / tol);
+	qy = (int)(q.y () / tol);
+
+	tx = (int)(t.x () / tol);
+	ty = (int)(t.y () / tol);
+
+	dx = abs(px-qx);
+	dy = abs(py-qy);
+
+	if (dx <=2 && dy <= 2)
+		return true;
+
+	int q1 = (qy-py)*(tx-px);
+	int q2 = (ty-py)*(qx-px);
+	int q3 = qx-px;
+	int q4 = qy-py;
+
+	if (q1 == 0 && q2 == 0 && q3 == 0 && q4 == 0)
+		return true;
+	if (abs(q1 - q2) > (std::max(abs(q3), abs(q4))))
+		return false;
+	return true;
+}
+
+bool TeRasterRemap::setROI(TeBox& roi)
+{	
+	if (roi.isValid())
+	{
+		TeBox bb;
+		if (rasterIn_ && !TeIntersection(roi,rasterIn_->params().boundingBox(),bb))
+			return false;
+		ROI_ = roi;	
+		return true;
+	}
+	return false;
+}
+
+void TeRasterRemap::TeInterpolateIn ( TeBox &box )
+{
+	TeRasterParams paramIn = rasterIn_->params();
+	TeRasterParams paramOut = rasterOut_->params();
+
+	TeProjection *projIn = paramIn.projection();
+	TeProjection *projOut = paramOut.projection();
+
+	if (!projIn || !projOut)
+		return;
+
+	projIn->setDestinationProjection(projOut);
+	projOut->setDestinationProjection(projIn);
+
+// Take coordinates of box corners in output raster projection
+
+	TeCoord2D poll = box.lowerLeft ();
+	TeCoord2D pour = box.upperRight ();
+
+// Bring output coordinates to output line/column domain
+
+	TeCoord2D pxoll = rasterOut_->coord2Index (poll);
+	TeCoord2D pxour = rasterOut_->coord2Index (pour);
+
+// Round output coordinates to nearest exact pixel
+
+	int x1,y1;
+	x1 = (int) (pxoll.x() - 0.5);
+	y1 = (int) (pxoll.y() + 0.5);
+	pxoll = TeCoord2D (x1,y1);
+
+	int x2,y2;
+	x2 = (int)(pxour.x() + 0.5);
+	y2 = (int)(pxour.y() - 0.5);
+	pxour = TeCoord2D (x2,y2);
+//	fprintf (loga,"Coordenadas de saida - x1=%d  x2=%d y1=%d y2=%d\n",x1,x2,y1,y2);
+
+	poll = rasterOut_->index2Coord (pxoll);
+	pour = rasterOut_->index2Coord (pxour);
+//	fprintf (loga,"Box de saida        - x1=%f  x2=%f y1=%f y2=%f\n\n",poll.x(),pour.x(),poll.y(),pour.y());
+
+	TeCoord2D poul = TeCoord2D(poll.x(),pour.y());
+	TeCoord2D polr = TeCoord2D(pour.x(),poll.y());
+
+//FAMI:BEGIN
+// If desired area on output image is too small, let's perform 
+// the interpolation point by point.
+	double	   x,y;
+	int	   i, j;
+	TeCoord2D  paux;
+	if (box.width () < 3.*paramOut.resx_ || box.height () < 3.*paramOut.resy_)
+	{
+	     y = (float)poul.y();
+	     for (i=y2;i<y1;i++,y-=paramOut.resy_) //y2 < y1, bottom > top
+	     {
+		 x = (float)poul.y();
+		 for (j=x1;j<x2;j++,x+=paramOut.resx_)
+		 {
+		     paux.setXY(x,y);
+		     paux = projOut->PC2LL (paux);
+		     if (paux.tooBig ()) continue;
+		     paux = projIn->LL2PC (paux);
+		     if (paux.tooBig ()) continue;
+		     paux = rasterIn_->coord2Index (paux);
+
+                     // linear or bilinear (InterpolateAt) ????
+		     if (interpolation_ == 0)
+		     {
+			     transformer_->apply((int)(paux.x()+0.5),(int)(paux.y()+0.5),j,i);
+//FAMI			     (transformer_.*transform_)((int)(paux.x()+0.5),(int)(paux.y()+0.5),j,i);
+		     }
+//		     if ( (*this)(i,j) == outsidevalue )
+//			    (*this)(i,j) = imi->InterpolateAt(paux);
+		  }
+	     }
+	     return;
+	}
+
+//FAMI:END
+
+// Bring coordinates of box four corners to input raster projection
+#if 0 //FAMI:BEGIN
+	TeCoord2D pill = projOut->PC2LL (poll);
+	TeCoord2D piur = projOut->PC2LL (pour);
+	TeCoord2D piul = projOut->PC2LL (poul);
+	TeCoord2D pilr = projOut->PC2LL (polr);
+
+	pill = projIn->LL2PC (pill);
+	piur = projIn->LL2PC (piur);
+	piul = projIn->LL2PC (piul);
+	pilr = projIn->LL2PC (pilr);
+#else
+	TeCoord2D piul = projOut->PC2LL (poul);
+	if (piul.tooBig()) piul.setXY(-TeMAXFLOAT,TeMAXFLOAT);
+	else
+	{
+		piul = projIn->LL2PC (piul);
+		if (piul.tooBig()) piul.setXY(-TeMAXFLOAT,TeMAXFLOAT);
+	}
+
+	TeCoord2D piur = projOut->PC2LL (pour);
+	if (piur.tooBig()) piur.setXY(TeMAXFLOAT,TeMAXFLOAT);
+	else
+	{
+		piur = projIn->LL2PC (piur);
+		if (piur.tooBig()) piur.setXY(TeMAXFLOAT,TeMAXFLOAT);
+	}
+
+	TeCoord2D pill = projOut->PC2LL (poll);
+	if (pill.tooBig()) pill.setXY(-TeMAXFLOAT,-TeMAXFLOAT);
+	else
+	{
+		pill = projIn->LL2PC (pill);
+		if (pill.tooBig()) pill.setXY(-TeMAXFLOAT,-TeMAXFLOAT);
+	}
+
+	TeCoord2D pilr = projOut->PC2LL (polr);
+	if (pilr.tooBig()) pilr.setXY(TeMAXFLOAT,-TeMAXFLOAT);
+	else
+	{
+		pilr = projIn->LL2PC (pilr);
+		if (pilr.tooBig()) pilr.setXY(TeMAXFLOAT,-TeMAXFLOAT);
+	}
+#endif
+//FAMI:END
+
+// Check if linear interpolation may be performed on input raster
+// Evaluate point at middle of the edges in output domain and check if their 
+// corresponding points belong to the edges in input domain. If they belong, 
+// a linear interpolation may be performed, else divide output image 
+// in four quadrants and try interpolating again
+
+
+	TeCoord2D	pou((pour.x()-poul.x())/2.+poul.x(), poul.y()), // upper edge
+				pob((polr.x()-poll.x())/2.+poll.x(), poll.y()), // bottom edge
+				pol(poll.x(), (poul.y()-poll.y())/2.+poll.y()), // left edge
+				por(polr.x(), (pour.y()-polr.y())/2.+polr.y()); // right edge
+
+// Evaluate corresponding points in input raster domain
+	TeCoord2D	piu, pib, pil, pir;
+
+	piu = projOut->PC2LL (pou);
+	pib = projOut->PC2LL (pob);
+	pil = projOut->PC2LL (pol);
+	pir = projOut->PC2LL (por);
+
+#if 0 //FAMI:BEGIN
+	piu = projIn->LL2PC (piu);
+	pib = projIn->LL2PC (pib);
+	pil = projIn->LL2PC (pil);
+	pir = projIn->LL2PC (pir);
+#else
+	if (!piu.tooBig()) piu = projIn->LL2PC (piu);
+	if (!pib.tooBig()) pib = projIn->LL2PC (pib);
+	if (!pil.tooBig()) pil = projIn->LL2PC (pil);
+	if (!pir.tooBig()) pir = projIn->LL2PC (pir);
+
+// Check special case for Satellite projection, when an area
+// outside the globe is being remapped, therefore none of these 
+// points will have valid values and we will give up.
+
+	if (	piu.tooBig ()  && pib.tooBig () &&
+		pil.tooBig ()  && pir.tooBig () &&
+		piul.tooBig () && piur.tooBig () &&
+		pilr.tooBig () && pill.tooBig () )
+	{
+		return;
+	}
+#endif
+//FAMI: END
+
+// Check if middle points belong to the edges
+
+	double tol = MAX(paramIn.resx_ ,paramIn.resy_ );
+
+//	if (!TeIsOnSegment (piu,piul,piur/*,tol*/) ||
+//		!TeIsOnSegment (pir,pilr,piur/*,tol*/) ||
+//		!TeIsOnSegment (pib,pill,pilr/*,tol*/) ||
+//		!TeIsOnSegment (pil,pill,piul/*,tol*/))
+
+	if ( piul.tooBig() || pilr.tooBig() || pill.tooBig() || piur.tooBig() ||
+		!TePointOnLine (piul,piur,piu,tol) ||
+		!TePointOnLine (pilr,piur,pir,tol) ||
+		!TePointOnLine (pill,pilr,pib,tol) ||
+		!TePointOnLine (pill,piul,pil,tol))
+	{
+// If one of them does not belong to correspondig edge, divide output in four quadrants
+		TeCoord2D	pom ((por.x()-pol.x())/2.+pol.x(), (pou.y()-pob.y())/2.+pob.y()); // center point
+		TeBox quadrantul (pol, pou);
+		TeInterpolateIn ( quadrantul );
+		TeBox quadrantur (pom, pour);
+		TeInterpolateIn ( quadrantur );
+		TeBox quadrantll (poll, pom);
+		TeInterpolateIn ( quadrantll );
+		TeBox quadrantlr (pob, por);
+		TeInterpolateIn ( quadrantlr );
+		return;
+	}
+
+// Start linear interpolation on input image.
+
+	double	xl,	// x at the beginning of the line
+		yl,	// y at the beginning of the line
+		xr,	// x at the end of the line
+		yr,	// y at the end of the line
+		dx,	// inner loop x increment
+		dy,	// inner loop y increment
+		dxl,	// x increment at the beginning of line
+		dyl,	// y increment at the beginning of line
+		dxr,	// x increment at the end of line
+		dyr;	// y increment at the end of line
+
+	TeCoord2D pxill = rasterIn_->coord2Index (pill);
+	TeCoord2D pxiul = rasterIn_->coord2Index (piul);
+	TeCoord2D pxilr = rasterIn_->coord2Index (pilr);
+	TeCoord2D pxiur = rasterIn_->coord2Index (piur);
+
+// Evaluate the increments in x and y on both sides of input image
+
+//FAMI	int	i, j;
+//FAMI	double	x,y;
+
+	x1 = (int)pxoll.x()-1;
+	y1 = (int)pxour.y()-1;
+
+	x2 = (int)pxour.x()+1;
+	y2 = (int)pxoll.y()+1;
+
+	dxl = ( (pxill.x()-pxiul.x())/(y2-y1) );
+	dyl = ( (pxill.y()-pxiul.y())/(y2-y1) );
+
+	dxr = ( (pxilr.x()-pxiur.x())/(y2-y1) );
+	dyr = ( (pxilr.y()-pxiur.y())/(y2-y1) );
+
+// Set initial values for x and y at beginning point on input image
+
+	xl = pxiul.x() - 1;
+	yl = pxiul.y() - 1;
+
+// Set initial values for x and y at end point on input image
+
+	xr = pxiur.x() + 1;
+	yr = pxiur.y() + 1;
+
+// Evaluate increments for the first line
+
+	dx = (xr-xl)/(x2-x1);
+	dy = (yr-yl)/(x2-x1);
+
+	x = xl;		// round to left pixel
+	y = yl;		// round to left pixel
+
+	for (j=y1;j<=y2;j++)
+	{
+		for (i=x1;i<=x2;i++)
+		{
+			if (interpolation_ == 0)
+				transformer_->apply((int)(x+0.5),(int)(y+0.5),i,j);
+ 			x += dx;
+			y += dy;
+		}
+
+		xl += dxl;
+		x = xl;
+		xr += dxr;
+		yl += dyl;
+		y = yl;
+		yr += dyr;
+		dx = (xr-xl)/(x2-x1);
+		dy = (yr-yl)/(x2-x1);
+	}
+}
+
+bool TeRasterRemap::apply( bool showProgress )
+{
+	// check if input and output raster are set
+	if (!rasterIn_ || !rasterOut_)
+		return false;
+
+	TeRasterParams paramIn = rasterIn_->params();
+	TeRasterParams paramOut = rasterOut_->params();
+
+	TeProjection* projIn = paramIn.projection();
+	TeProjection* projOut = paramOut.projection();
+
+	// if only one of the rasters dont have projection cant do remapping
+	if ((projIn && !projOut) || (projOut && !projIn))
+		return false;
+
+	showProgress_ = showProgress;
+
+	// if no transformer defined create a new on based on typical cases of 
+	// visualization and import operations
+	bool delTransf = false;
+	if (!transformer_)
+	{
+		delTransf = true;		// remember to delete it 
+		transformer_ = new TeRasterTransform();
+		transformer_->setRasterIn(rasterIn_);
+		transformer_->setRasterOut(rasterOut_);
+
+		// pallete raster to a RGB device -> apply input raster pallete
+		if ((paramIn.photometric_[0] == TeRasterParams::TePallete) &&
+			 paramOut.nBands() == 3)
+			transformer_->setTransfFunction(&TeRasterTransform::Pallete2ThreeBand);
+		// mono band raster to a RGB device -> repeat band to 3 channels
+		else if (paramIn.nBands() == 1 && paramOut.nBands() == 3)
+			transformer_->setTransfFunction(&TeRasterTransform::Mono2ThreeBand);
+		// copy first n input bands to first n output bands
+		else		
+			transformer_->setTransfFunction(&TeRasterTransform::Band2Band);
+	}
+	else if(transformer_->getTransfFunction() == TeRasterTransform::TeNoTransf)
+	{
+		transformer_->setTransfFunction(&TeRasterTransform::Band2Band);
+	}
+
+	bool result;
+	// check if datum's are different
+	if (projIn->datum().name() != projOut->datum().name())
+	{
+		projIn->setDestinationProjection(projOut);
+		projOut->setDestinationProjection(projIn);
+	}
+
+	if (projIn && projOut && (*projIn == *projOut))	// same projection
+	{
+		TeBox	boxIn = paramIn.box();
+		TeBox	boxOut = paramOut.box();
+
+		
+		if (!(boxIn == boxOut) ||					// different resolutions or boxes
+			paramIn.resx_   != paramOut.resx_ || 
+			paramIn.resy_   != paramOut.resy_ ||
+			paramIn.ncols_  != paramOut.ncols_ ||
+			paramIn.nlines_ != paramOut.nlines_ )
+			result = resample();
+		else										// same dimensions
+			result = copy();
+	}
+	else											// different projection
+		result = remap();
+
+	if (delTransf)
+	{
+		delete transformer_;
+		transformer_ = 0;
+	}
+	return result;
+}
+
+bool TeRasterRemap::copy ()
+{
+	const TeRasterParams& paramOut = rasterOut_->params();
+	if(showProgress_ && TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(paramOut.nlines_);
+
+	int li, lf, ci, cf;
+	if (ROI_.isValid())
+	{
+		TeCoord2D aux = rasterIn_->coord2Index(ROI_.lowerLeft());
+		lf = TeRoundRasterIndex(aux.y_);
+		ci = TeRoundRasterIndex(aux.x_);
+		aux = rasterIn_->coord2Index(ROI_.upperRight());
+		li = TeRoundRasterIndex(aux.y_);
+		cf = TeRoundRasterIndex(aux.x_);
+	}
+	else
+	{
+		li = ci = 0;
+		lf = paramOut.nlines_;
+		cf = paramOut.ncols_;
+	}
+
+	int c, l;
+	clock_t	ti, tf;
+	ti = clock();
+	for (l=li; l<lf; ++l)
+	{
+		for (c=ci; c<cf; ++c)
+			transformer_->apply(c,l,c,l);
+
+		if (showProgress_ && TeProgress::instance())
+		{
+			tf = clock();
+			if (int((tf-ti)/CLOCKS_PER_SEC) > 3)
+			{
+				if (TeProgress::instance()->wasCancelled())
+					break;
+				TeProgress::instance()->setProgress(l);
+				ti = tf;
+			}
+		}
+	}
+	if(showProgress_ && TeProgress::instance())
+		TeProgress::instance()->reset();
+	return true;
+}
+
+bool TeRasterRemap::resample ()
+{
+	TeRasterParams paramIn = rasterIn_->params();
+	TeRasterParams paramOut = rasterOut_->params();
+
+	TeBox	boxIn = paramIn.boundingBox();  
+	TeBox	boxOut = paramOut.boundingBox(); 
+
+// Evaluate intersection of input and output rasters in output raster projection domain
+
+	TeBox boxInter;
+
+	if (!TeIntersection (boxIn,boxOut,boxInter))
+		return false;
+
+	if (ROI_.isValid())
+	{
+		if (!TeIntersection (ROI_,boxInter,boxInter))
+			return false;
+	}
+
+// Take coordinates of intersection box
+
+	TeCoord2D poll = boxInter.lowerLeft ();
+	TeCoord2D pour = boxInter.upperRight ();
+
+// Bring it to output line/column domain
+
+	TeCoord2D pxoll = rasterOut_->coord2Index (poll);
+	TeCoord2D pxour = rasterOut_->coord2Index (pour);
+
+// Round it to nearest pixel
+	int x1,y1,x2,y2;
+	x1 = TeRoundRasterIndex(pxoll.x_) - 1;
+	y2 = TeRoundRasterIndex(pxoll.y_) + 1;
+	pxoll = TeCoord2D (x1,y2);
+
+	x2 = TeRoundRasterIndex(pxour.x_) + 1;
+	y1 = TeRoundRasterIndex(pxour.y_) - 1;
+	pxour = TeCoord2D (x2,y1);
+		
+// Bring it to output projection domain
+	poll = rasterOut_->index2Coord (pxoll);
+	pour = rasterOut_->index2Coord (pxour);
+
+// Bring upper left point to input line/column domain
+	TeCoord2D ulPoint = rasterIn_->coord2Index(TeCoord2D(poll.x(),pour.y()));
+
+//  - -
+// |A|B|
+//  - - 
+// |C| |
+//  - -
+// Get output projection domain of corner ABC
+	TeCoord2D A = rasterOut_->index2Coord(TeCoord2D(0,0));
+	TeCoord2D B = rasterOut_->index2Coord(TeCoord2D(1,0));
+	TeCoord2D C = rasterOut_->index2Coord(TeCoord2D(0,1));
+
+// Calculate equivalent input line/column coordinates 
+	TeCoord2D Ae = rasterIn_->coord2Index(A);
+	TeCoord2D Be = rasterIn_->coord2Index(B);
+	TeCoord2D Ce = rasterIn_->coord2Index(C);
+
+// Calculate input increments in both directions, in number of pixels
+// for each output 1 pixel increment in 
+	double eDxJ = Be.x()-Ae.x();		// increment in X direction when moving from A->B	
+	double eDyJ = Be.y()-Ae.y();		// increment in Y direction when moving from A->B
+	double eDyI = Ce.y()-Ae.y();		// increment in Y direction when moving from C->A
+	double eDxI = Ce.x()-Ae.x();		// increment in X direction when moving from C->A
+
+	int lin_sai,col_sai;
+	double lin_entra,col_entra; 
+
+	double lin_entra_i = ulPoint.y();	// starting at the upper-left corner	
+	double col_entra_i = ulPoint.x();
+
+	if( showProgress_ && TeProgress::instance())
+		TeProgress::instance()->setTotalSteps((int)(y2-y1));
+
+	int count = 1;
+	clock_t	ti, tf;
+	ti = clock();
+	for (lin_sai=y1;lin_sai<=y2;lin_sai++)
+	{
+		lin_entra = lin_entra_i;
+		col_entra = col_entra_i;
+		for (col_sai=x1;col_sai<=x2;col_sai++)
+		{
+			transformer_->apply(TeRoundRasterIndex(col_entra),TeRoundRasterIndex(lin_entra),col_sai,lin_sai);
+  			col_entra += eDxJ;
+			lin_entra += eDyJ;
+		}
+		count++;
+		lin_entra_i += eDyI;
+		col_entra_i += eDxI;
+		if(showProgress_ && TeProgress::instance())
+		{
+			tf = clock();
+			if (int((tf-ti)/CLOCKS_PER_SEC) > 3)
+			{
+				if (TeProgress::instance()->wasCancelled())
+					break;
+				TeProgress::instance()->setProgress(count);
+				ti = tf;
+			}
+		}
+	}
+	if (showProgress_ && TeProgress::instance())
+		TeProgress::instance()->reset();
+	return true;
+}
+
+bool TeRasterRemap::remap()
+{
+
+	TeRasterParams paramIn = rasterIn_->params();
+	TeRasterParams paramOut = rasterOut_->params();
+
+	TeProjection *projIn = paramIn.projection();
+	TeProjection *projOut = paramOut.projection();
+
+
+	if ( projIn == 0 || projOut == 0)
+		return false;
+
+	projIn->setDestinationProjection(projOut);
+
+	TeBox	boxIn =  paramIn.box();
+	TeBox	boxOut = paramOut.box();
+
+	// Evaluate intersection of input and output rasters in output raster projection domain
+	// FAMI **************VERY IMPORTANT**********************
+	// There is a problem here for input Satellite image.
+	// The boxIn in projection coords when converted to geodetic coords,
+	// projIn->PC2LL(boxIn), gives TeMaxDouble. Consequently, this value
+	// applied to projOut->LL2PC() gives also wrong values. We need to
+	// do something here...
+	TeBox boxInter;
+	boxIn = TeRemapBox (boxIn, projIn, projOut);
+
+#if 0 //FAMI
+	if (!TeIntersection (boxIn,boxOut,boxInter))
+		return false;
+#else
+	// Test code for satellite image being remaped to cylindrical
+	// and polar stereographic projections.
+	// REMOVE THIS CODE WHEN THE PROBLEM IS FIXED.
+	// For cylindrical projection, function TeInterpolateIn does not work
+	// if the output area is bigger than the satellite image area. The
+	// temporary solution is to calculate an intersection area between
+	// the satellite and the user requested area.
+	// For polar stereographic projection, function TeInterpolateIn works.
+	string name = projIn->name();
+	if (name == "Satellite")
+	{
+		// compute the longitude's extreme values
+		 TeSatelliteProjection* proj = (TeSatelliteProjection*)paramIn.projection();
+		double lon = proj->lon0();  //origin longitude
+		double altitude = proj->RadiusSatOrbit()*1000000. / TeEARTHRADIUS;
+		double tetha = acos(TeEARTHRADIUS / (TeEARTHRADIUS + altitude));
+		double x1 = (lon-tetha)*TeCRD;
+		double x2 = (lon+tetha)*TeCRD;
+		TeBox bIn(x1,-65.,x2,65.);  //maximum area for satellite image
+
+		// Convert user's output area to geodetic coordinates
+		// The intersection function is performed in geodetic coords.
+		TeCoord2D p1(boxOut.x1(),boxOut.y1());
+		TeCoord2D p2(boxOut.x2(),boxOut.y2());
+		p1 = projOut->PC2LL(p1);
+		p2 = projOut->PC2LL(p2);
+		boxOut = TeBox(p1.x()*TeCRD,p1.y()*TeCRD,p2.x()*TeCRD,p2.y()*TeCRD);
+//cout << boxOut.x1() << " " << boxOut.x2() << " " << boxOut.y1() << " " << boxOut.y2() << " " << endl;
+//cout << bIn.x1() << " " << bIn.x2() << " " << bIn.y1() << " " << bIn.y2() << " " << endl;
+
+		// Compute common area between the maximum area for satellite
+		// image and the user's output area
+		// If there is no intersection, try to shift the coordinates by
+		// 360 degrees (geographical areas can be defined between -360
+		// and +360 degrees)
+		// 
+		if ( projOut->name() == "PolarStereographic" )
+			boxInter = boxOut;
+		else
+		{
+			if ( !TeIntersection (boxOut,bIn,boxInter) )
+			{
+//cout << boxInter.x1() << " " << boxInter.x2() << " " << boxInter.y1() << " " << boxInter.y2() << " " << endl;
+				bIn = TeBox(x1+360.,-65.,x2+360.,65.);
+				if ( !TeIntersection (boxOut,bIn,boxInter) )
+					return false;
+			}
+		}
+
+		// Convert common area to projection coordinates
+//cout << boxInter.x1() << " " << boxInter.x2() << " " << boxInter.y1() << " " << boxInter.y2() << " " << endl;
+		p1 = TeCoord2D(boxInter.x1()*TeCDR,boxInter.y1()*TeCDR);
+		p2 = TeCoord2D(boxInter.x2()*TeCDR,boxInter.y2()*TeCDR);
+		p1 = projOut->LL2PC(p1);
+		p2 = projOut->LL2PC(p2);
+		boxInter = TeBox(p1,p2);
+	}
+	else   //non satellite data
+//FAMI1010 Removed this code temporarily. We need to talk to Terralib people to
+// update this routine for Polar Stereographic projection
+//	        if (!TeIntersection (boxIn,boxOut,boxInter))
+//			return false;
+		boxInter = boxOut;
+#endif
+
+	if (ROI_.isValid())
+	{
+		boxIn = TeRemapBox (ROI_, projIn, projOut);
+		if (!TeIntersection (boxIn,boxInter,boxInter))
+			return false;
+	}
+
+	// Start trying to remap the input quadrilateral
+	TeInterpolateIn ( boxInter );
+	return true;
+}
diff --git a/src/terralib/kernel/TeRasterRemap.h b/src/terralib/kernel/TeRasterRemap.h
new file mode 100644
index 0000000..3249e30
--- /dev/null
+++ b/src/terralib/kernel/TeRasterRemap.h
@@ -0,0 +1,131 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeRasterRemap.h
+    \brief This file contains definitions the class and functions need to transform a raster geometry into another geometry
+*/
+#ifndef  __TERRALIB_INTERNAL_RASTERREMAP_H
+#define  __TERRALIB_INTERNAL_RASTERREMAP_H
+
+#include "TeRaster.h"
+#include "TeGeometry.h"
+#include "TeRasterTransform.h"
+
+//!  A functional class to transform a raster geometry into another geometry 
+/*!  
+	RasterRemap class provides functions to remap a raster strtucture into another.
+	The two raster can have a different projections, different bounding boxes and/or 
+	different resolutions. 
+ 
+	\sa
+     TeRaster, TeRasterParams, TeRasterTransform, TeProjection, TeBox
+
+	\note Raster representation in TerraLib is under development, all files that deal
+	with raster representation should be considered as a beta version.
+*/
+class TL_DLL TeRasterRemap
+{
+protected:
+	TeRaster*	rasterIn_;		//!< input raster
+	TeRaster*	rasterOut_;		//!< output raster
+
+	TeRasterTransform* transformer_;	
+
+	int	 interpolation_;
+	bool showProgress_;
+
+
+	TeBox ROI_;					// region of interest (from input) where the remmaping should be done
+
+	void TeInterpolateIn (TeBox &box);
+
+	bool remap ();
+	bool copy ();
+	bool resample ();
+
+public:
+
+	//! Constructor
+	/*
+		\param rasterIn pointer to the input raster
+		\param rasterOut pointer to the output raster
+		\para showProgress flag to indicate that a progress status hould be reported
+	*/
+	TeRasterRemap (TeRaster* rasterIn=0, TeRaster* rasterOut=0, bool showProgress = false):
+		rasterIn_(rasterIn),
+		rasterOut_(rasterOut),
+		transformer_(0),
+		interpolation_(0),
+		showProgress_(showProgress),
+		ROI_(TeBox())
+		{}
+
+	//! Sets the input raster
+	void setInput(TeRaster* rasterIn)
+	{	
+		rasterIn_ = rasterIn; 
+		if (transformer_)
+			transformer_->setRasterIn(rasterIn_);
+	}
+	
+	//! Sets the output raster
+	void setOutput(TeRaster* rasterOut)
+	{	
+		rasterOut_ = rasterOut; 
+		if (transformer_)
+			transformer_->setRasterOut(rasterOut_);
+	}
+	
+	//! Sets the interpolation flag
+	void setInterpolation(int interpolation)
+	{	interpolation_ = interpolation; }
+
+	//! Sets the transformation to be used when doing remap
+	void setTransformer(TeRasterTransform* transf)
+	{	
+		if (transf)
+		{
+			transformer_ = transf; 
+			transformer_->setRasterOut(rasterOut_);
+			transformer_->setRasterIn(rasterIn_);
+		}
+	}
+	
+	//! Returns the transformation to be used when doing remap
+	TeRasterTransform* transformer()
+	{	return transformer_;	}
+
+	//! Applies the remaping
+	bool apply(bool showProgress = false);
+
+	//! Defines a region of interest where the remmaping should be done
+	/*
+		\par roi a box that represents the region of interest. It should
+		be inside the raster in bounding box;
+		\return false if the roi in invalid or it is not within the input
+		raster. True otherwise
+	*/
+	bool setROI(TeBox& roi);
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeRasterTransform.cpp b/src/terralib/kernel/TeRasterTransform.cpp
new file mode 100644
index 0000000..64e78ba
--- /dev/null
+++ b/src/terralib/kernel/TeRasterTransform.cpp
@@ -0,0 +1,136 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeRasterTransform.h"
+#include "TeVisual.h"
+
+void 
+TeRasterTransform::generateLUT(TeLegendEntryVector& legs, unsigned int nentries, TeColor& backColor)
+{
+	// find the range covered by the legends
+	unsigned int n;
+	double vmin = TeMAXFLOAT;
+	double vmax = TeMINFLOAT;
+	for (n=0; n <legs.size(); n++)
+	{
+		if (atof(legs[n].slice().from_.c_str()) < vmin)
+			vmin = atof(legs[n].slice().from_.c_str());
+		if (atof(legs[n].slice().to_.c_str()) > vmax)
+			vmax = atof(legs[n].slice().to_.c_str());
+	}
+	// do a linear transformation from the range defined by the legend to the number of entries
+	this->setLinearTransfParameters(vmin,vmax, 0, nentries-1);
+
+	// initialize lut with the background color
+	lutr_.clear();
+	lutg_.clear();
+	lutb_.clear();
+
+	lutr_.insert(lutr_.begin(),nentries,backColor.red_);
+	lutg_.insert(lutg_.begin(),nentries,backColor.green_);
+	lutb_.insert(lutb_.begin(),nentries,backColor.blue_);
+
+	// to each entry define its equivalent range of indexes on the LUT
+	int nunIndx = 0;
+	int indexFrom, indexTo;
+	for (n=0; n <legs.size(); n++)
+	{
+		// find the range of entries that
+		indexFrom = (int)(atof(legs[n].slice().from_.c_str()) * gain_ + offset_);
+		if (indexFrom < 0)
+			indexFrom = 0;
+		indexTo = (int)(atof(legs[n].slice().to_.c_str()) * gain_ + offset_);
+		if (indexTo > (int)nentries)
+			indexTo = nentries;
+		nunIndx = indexTo - indexFrom + 1;
+		if (nunIndx >= 1)
+		{
+			fill_n(&lutr_[indexFrom],nunIndx,legs[n].getVisualMap()[TePOLYGONS]->color().red_);
+			fill_n(&lutg_[indexFrom],nunIndx,legs[n].getVisualMap()[TePOLYGONS]->color().green_);
+			fill_n(&lutb_[indexFrom],nunIndx,legs[n].getVisualMap()[TePOLYGONS]->color().blue_);
+		}
+	}
+	lutSize_ = lutr_.size();
+}
+
+TeRasterTransform::TeRasterTransfFunctions TeRasterTransform::getTransfFunction()
+{
+	if (transfFuncPtr_ == 0)
+		return TeNoTransf;
+
+	if (transfFuncPtr_ == &TeRasterTransform::Mono2ThreeBand)
+		return TeMono2Three;
+
+	if (transfFuncPtr_ == &TeRasterTransform::Band2Band)
+		return TeBand2Band;
+
+	if (transfFuncPtr_ == &TeRasterTransform::Pallete2ThreeBand)
+		return TePall2Three;
+
+	if (transfFuncPtr_ == &TeRasterTransform::LUT2ThreeBand)
+		return TeLUT2Three;
+
+	if (transfFuncPtr_ == &TeRasterTransform::ExtractRGB)
+		return TeExtractRGB;
+
+	if (transfFuncPtr_ == &TeRasterTransform::ExtractBand)
+		return TeExtractBand;
+
+	if (transfFuncPtr_ == &TeRasterTransform::ExtractBands)
+		return TeExtractBands;
+
+	if (transfFuncPtr_ == &TeRasterTransform::ThreeBand2RGB)
+		return TeThreeBand2RGB;
+	else
+		return TeNoTransf;
+}
+
+void TeRasterTransform::setTransfFunction(TeRasterTransfFunctions func)
+{
+	if (func == TeMono2Three)
+		transfFuncPtr_ = &TeRasterTransform::Mono2ThreeBand;
+
+	else if (func == TeBand2Band)
+		transfFuncPtr_ = &TeRasterTransform::Band2Band;
+
+	else if (func == TePall2Three)
+		transfFuncPtr_ = &TeRasterTransform::Pallete2ThreeBand; 
+
+	else if (func == TeLUT2Three)
+		transfFuncPtr_ = &TeRasterTransform::LUT2ThreeBand;
+		
+	else if (func == TeExtractRGB)
+		transfFuncPtr_ = &TeRasterTransform::ExtractRGB;
+
+	else if (func == TeExtractBand)
+		transfFuncPtr_ = &TeRasterTransform::ExtractBand;
+
+	else if (func == TeExtractBands)
+		transfFuncPtr_ = &TeRasterTransform::ExtractBands;
+
+	else if (func == TeThreeBand2RGB)
+		transfFuncPtr_ = &TeRasterTransform::ThreeBand2RGB;
+
+	else
+		transfFuncPtr_ = 0;
+}
diff --git a/src/terralib/kernel/TeRasterTransform.h b/src/terralib/kernel/TeRasterTransform.h
new file mode 100644
index 0000000..11b3d3a
--- /dev/null
+++ b/src/terralib/kernel/TeRasterTransform.h
@@ -0,0 +1,357 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeRasterTransform.h
+    \brief This file deals with the transformation functions over raster pixels
+*/
+#ifndef  __TERRALIB_INTERNAL_RASTERTRANSFORM_H
+#define  __TERRALIB_INTERNAL_RASTERTRANSFORM_H
+
+#include "TeRaster.h"
+#include "TeLegendEntry.h"
+
+#include <map>
+#include <vector>
+using namespace std;
+
+//! This class defines a way of evaluating the final value of a raster element
+class TL_DLL TeRasterTransform
+{
+public:
+
+	//! The three channels of a display
+	enum TeRGBChannels { TeREDCHANNEL=0, TeGREENCHANNEL=1, TeBLUECHANNEL=2 };
+
+	enum TeRasterTransfFunctions
+	{	TeNoTransf=0, TeMono2Three=1, TeBand2Band=2, TePall2Three=3, TeLUT2Three=4, 
+		TeExtractRGB=5, TeExtractBand=6, TeExtractBands=7, TeThreeBand2RGB=8	};
+
+	//! One of the available transformation methods 
+	typedef void (TeRasterTransform::*TransformFunction)(double, double, double, double);
+
+private:
+
+	TeRaster* rasterIn_;			
+	TeRaster* rasterOut_;
+
+	double gain_, offset_;
+
+	map<TeRGBChannels,short> rgbmap_;
+
+	short mband_, mbout_;
+
+	TransformFunction transfFuncPtr_;
+
+	double rmin_, rmax_;
+
+	int lutSize_;
+
+	double contrastR_, contrastG_, contrastB_;
+	double contrastM_;
+
+	unsigned int transp_;
+
+public:
+
+	vector<unsigned char> lutr_;
+	vector<unsigned char> lutg_;
+	vector<unsigned char> lutb_;
+
+	//! Constructor 
+	TeRasterTransform(TeRaster* rIn=0, TeRaster* rOut=0):  
+	  rasterIn_(rIn),
+	  rasterOut_(rOut),
+	  gain_(1),
+	  offset_(0),
+	  mband_(0), 
+	  mbout_(0),
+	  transfFuncPtr_(&TeRasterTransform::Band2Band),
+	  rmax_(TeMAXFLOAT),
+	  lutSize_(0),
+	  contrastR_(1.0),
+	  contrastG_(1.0),
+	  contrastB_(1.0),
+	  contrastM_(1.0),
+	  transp_(255)
+	  { 
+		  rmin_ = -1 * TeMAXFLOAT;
+	 }
+
+	//! Destructor
+	~TeRasterTransform()
+	{
+		lutr_.clear();
+		lutb_.clear();
+		lutg_.clear();
+		rgbmap_.clear();
+		transfFuncPtr_ = 0;
+	}
+
+	//! Sets the size of the LUT being used
+	void setLutSize(int n)
+	{	lutSize_ = n; }
+
+	//! Gets the size of the LUT being used
+	int getLutSize()
+	{	return lutSize_; }
+
+	//! Sets the input raster
+	void setRasterIn(TeRaster* rIn)
+	{	rasterIn_ = rIn; }
+
+	//! Sets the input raster
+	void setRasterOut(TeRaster* rOut)
+	{	rasterOut_ = rOut; }
+	
+	//! Sets the gain
+	void setGain(double g) 
+	{	gain_= g;	}
+
+	//! Sets the offset
+	void setOffset(double o) 
+	{	offset_= o;	}
+
+	//! Sets the transformation method to be used 
+	void setTransfFunction(TeRasterTransform::TransformFunction transfFuncPtr)
+	{	transfFuncPtr_ = transfFuncPtr; }
+
+	//! Sets the mapping from bands to R,G and B channels 
+	void setRGBmap (map<TeRGBChannels,short>& rgbmap)
+	{
+		if (rgbmap.size() < 3)
+			return;
+		rgbmap_.clear();
+		rgbmap_ = rgbmap;
+	}
+
+	//! Sets the mapping from a particular input band to a particular output channel
+	void setBChannelMapping(short bIn, TeRGBChannels bOut)
+	{
+		rgbmap_[bOut] = bIn;
+	}
+
+	//! Clears current mapping from bands to channel
+	void clearRGBMap()
+	{
+		rgbmap_.clear();
+	}
+
+	//! Returns the mapping from a particular input band to a particular output channel
+	map<TeRGBChannels,short>& getRGBMap()
+	{
+		return rgbmap_;
+	}
+
+	//! Sets the mono band to be transformed
+	void setSrcBand(short n)
+	{ mband_ = n; }
+
+	//! Gets the mono band to be transformed
+	short getSrcBand()
+	{	return mband_; }
+
+	//! Sets the destination of the mono band
+	void setDestBand(short n)
+	{ mbout_ = n; }
+
+	//! Gets the destination of the mono band
+	short getDestBand()
+	{	return mbout_;	}
+	
+	//! Generates a LUT with nentries to display the vector of legends
+	void generateLUT(TeLegendEntryVector& legs, unsigned int nentries, TeColor& backColor);
+
+	//! Set parameters of linear transformation
+	/*!
+		\param vmin smallest input value
+		\param vmax largest input value
+		\param rmin smallest value of the output range
+		\param rmax largest value of the output range
+	*/
+	void setLinearTransfParameters(double vmin, double vmax, double rmin, double rmax)
+	{
+		rmin_ = rmin;
+		rmax_ = rmax;
+		gain_ = (double)(rmax-rmin)/(vmax-vmin);
+		offset_ = -1*gain_*vmin+rmin;
+	}
+
+//--- Simple contrast linear factors
+	void setContrastR(double cR)
+	{	contrastR_ = cR;	}
+	void setContrastG(double cG)
+	{	contrastG_ = cG;	}
+	void setContrastB(double cB)
+	{	contrastB_ = cB;	}
+	void setContrastM(double cM)
+	{	contrastM_ = cM;	}
+
+	double getContrastR()
+	{	return contrastR_;	}
+	double getContrastG()
+	{	return contrastG_;	}
+	double getContrastB()
+	{	return contrastB_;	}
+	double getContrastM()
+	{	return contrastM_;	}
+
+
+	void setTransparency(unsigned int transp)
+	{	transp_ = transp; }
+	unsigned int getTransparency()
+	{	return transp_;	}
+//---
+
+	//! Applies the selected transformation method
+	void apply(double icol, double ilin, double ocol, double olin)
+	{	(this->*transfFuncPtr_)(icol,ilin,ocol,olin); }
+
+	//! Returns the identifier of the transformation function currently set
+	TeRasterTransfFunctions getTransfFunction();
+
+	//! Sets the associated transformation function from an identifier
+	void setTransfFunction(TeRasterTransfFunctions func);
+
+// --- The transformation functions  available ----
+	//! This transformation repeats the value of the first band in input three bands of the output
+	void Mono2ThreeBand(double icol, double ilin, double ocol, double olin)
+	{
+		double val;
+		if (rasterIn_->getElement((int)icol,(int)ilin,val,mband_))
+		{
+			val = (val*gain_ + offset_)*contrastM_;
+			if (val < rmin_)
+				val = rmin_;
+			else if (val > rmax_)
+				val = rmax_;
+			rasterOut_->setElement((int)ocol,(int)olin, val, val, val, transp_);
+		}
+	}
+
+	//! This transformation repeats the value of each band in input to the same band in output
+	void Band2Band(double icol, double ilin, double ocol, double olin)
+	{
+		double val;
+		int n = rasterOut_->params().nBands();
+		for (int i=0; i<n; i++)
+			if (rasterIn_->getElement((int)icol,(int)ilin,val,i))
+			{
+				val = val*gain_ + offset_;
+				if (val < rmin_)
+					val = rmin_;
+				else if (val > rmax_)
+					val = rmax_;
+				rasterOut_->setElement((int)ocol,(int)olin,val,i);
+			}
+	}
+
+	//! This transformation repeats the value of the raster LUT in input to the first 3 bands of output
+	void Pallete2ThreeBand(double icol, double ilin, double ocol, double olin)
+	{
+		double val;
+		if (rasterIn_->getElement((int)icol,(int)ilin,val))
+		{
+			if (val>= 0 && (unsigned int)val < rasterIn_->params().lutr_.size())
+			{
+				rasterOut_->setElement((int)ocol,(int)olin,rasterIn_->params().lutr_[(int)val],
+														   rasterIn_->params().lutg_[(int)val],
+														   rasterIn_->params().lutb_[(int)val], transp_);
+			}
+		}
+	}
+
+	//! This transformation repeats the value of the first band in input three bands of the output
+	void ThreeBand2RGB(double icol, double ilin, double ocol, double olin)
+	{
+		double valR, valG, valB;
+		bool flag = rasterIn_->getElement((int)icol,(int)ilin,valR,0);
+		flag = rasterIn_->getElement((int)icol,(int)ilin,valG,1) || flag;
+		flag = rasterIn_->getElement((int)icol,(int)ilin,valB,2) || flag;
+
+		if (flag)
+			rasterOut_->setElement((int)ocol,(int)olin, (valR*gain_ + offset_)*contrastR_, 
+														(valG*gain_ + offset_)*contrastG_, 
+														(valB*gain_ + offset_)*contrastB_, transp_);
+	}
+
+	//! This transformation repeats the value of an external LUT to the first 3 bands of output
+	void LUT2ThreeBand(double icol, double ilin, double ocol, double olin)
+	{
+		double idx, val; 
+		if (rasterIn_->getElement((int)icol,(int)ilin,val,mband_))
+		{
+			idx = (val*gain_) + offset_;
+			if (idx >= 0 && idx < lutSize_)
+			{
+				rasterOut_->setElement((int)ocol,(int)olin,lutr_[(int)idx]*contrastR_,
+														   lutg_[(int)idx]*contrastG_,
+														   lutb_[(int)idx]*contrastB_, transp_);
+			}
+		}
+	}
+
+	// This transformation is used to define a particular mapping from input bands to RGB channels
+	void ExtractRGB(double icol, double ilin, double ocol, double olin)
+	{
+		double valR, valG, valB;
+		bool flag = rasterIn_->getElement((int)icol,(int)ilin,valR,rgbmap_[TeREDCHANNEL]);
+		     flag = rasterIn_->getElement((int)icol,(int)ilin,valG,rgbmap_[TeGREENCHANNEL]) || flag;
+		     flag = rasterIn_->getElement((int)icol,(int)ilin,valB,rgbmap_[TeBLUECHANNEL]) || flag;
+
+		if (flag)
+			rasterOut_->setElement((int)ocol,(int)olin, (valR*gain_ + offset_)*contrastR_, 
+														(valG*gain_ + offset_)*contrastG_, 
+														(valB*gain_ + offset_)*contrastB_, transp_);
+	}
+
+	//! This transformation repeats the value of a particular band in input to a particular band of the output
+	void ExtractBand(double icol, double ilin, double ocol, double olin)
+	{
+		double val;
+		if (rasterIn_->getElement((int)icol,(int)ilin,val,mband_))
+		{
+			val = val*gain_ + offset_;
+			if (val < rmin_)
+				val = rmin_;
+			else if (val > rmax_)
+				val = rmax_;
+			rasterOut_->setElement((int)ocol,(int)olin,val*contrastM_,mbout_);
+		}
+	}
+
+	// This transformation extracts selected bands of the input raster and 
+	// writes each to a particular band of the output
+	void ExtractBands(double icol, double ilin, double ocol, double olin)
+	{
+		double val;
+		map<TeRGBChannels,short>::iterator it = rgbmap_.begin();
+		while (it != rgbmap_.end())
+		{
+			if (rasterIn_->getElement((int)icol,(int)ilin,val,it->second))
+				rasterOut_->setElement((int)ocol,(int)olin,val,it->first);
+		}
+	}
+
+};
+#endif
+
+
diff --git a/src/terralib/kernel/TeRepresentation.cpp b/src/terralib/kernel/TeRepresentation.cpp
new file mode 100644
index 0000000..b22ac06
--- /dev/null
+++ b/src/terralib/kernel/TeRepresentation.cpp
@@ -0,0 +1,34 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32 
+#pragma warning ( disable: 4786 ) 
+#endif
+
+#include "TeRepresentation.h"
+
+TeRepresPointerVectorIterator 
+TeFindRepresentation(TeRepresPointerVectorIterator begin, TeRepresPointerVectorIterator end, TeGeomRep rep)
+{
+	return find_if(begin,end,TeRepres_eq(rep));
+}
diff --git a/src/terralib/kernel/TeRepresentation.h b/src/terralib/kernel/TeRepresentation.h
new file mode 100644
index 0000000..cb7cb36
--- /dev/null
+++ b/src/terralib/kernel/TeRepresentation.h
@@ -0,0 +1,78 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeRepresentation.h
+    \brief This file contains structures and definitions to deal with a geometrical representation
+*/
+#ifndef  __TERRALIB_INTERNAL_REPRESENTATION_H
+#define  __TERRALIB_INTERNAL_REPRESENTATION_H
+
+#include "TeDataTypes.h"
+#include "TeBox.h"
+
+#include <algorithm>
+#include <string>
+
+//!  A class to supporting a geometrical representation 
+struct TL_DLL TeRepresentation
+{
+	int id_;				//!< representation unique dabatase identifier
+	TeGeomRep geomRep_;		//!< representation type (
+	std::string	tableName_;		//!< name of the table that stores the geometries associated to this representation
+	TeBox	box_;			//!< representation bounding box
+	std::string	description_;	//!< representation description
+	double	resX_;			//!< the x resolution of the layer cell set geometry
+	double	resY_;			//!< the y resolution of the layer cell set geometry
+	int		nCols_;			//!< number of columns in raster geometry
+	int		nLins_;			//!< number of columns in raster geometry
+
+	//! Constructor
+	TeRepresentation() :
+		resX_(0.0),
+		resY_(0.0),
+		nCols_(0),
+		nLins_(0)
+		{}
+};
+
+//! A functor class to compare representations by its type
+class TL_DLL TeRepres_eq : public unary_function<TeRepresentation*,bool>
+{
+	TeGeomRep r;
+public:
+	explicit TeRepres_eq(TeGeomRep rr): r(rr) {}
+	bool operator()(const TeRepresentation* rep) const { return rep->geomRep_ == r; }
+};
+
+//! An iterator to a std::vector of TeRepresentation 
+typedef std::vector<TeRepresentation* >::iterator TeRepresPointerVectorIterator;
+
+//! A std::vector of pointers to TeRepresentation
+typedef std::vector<TeRepresentation* > TeRepresPointerVector;
+
+//! Finds the first representation of a given type in a std::vector of representations
+TL_DLL TeRepresPointerVectorIterator 
+TeFindRepresentation(TeRepresPointerVectorIterator begin, TeRepresPointerVectorIterator end, TeGeomRep rep);
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeSTEFunctionsDB.h b/src/terralib/kernel/TeSTEFunctionsDB.h
new file mode 100644
index 0000000..23d8041
--- /dev/null
+++ b/src/terralib/kernel/TeSTEFunctionsDB.h
@@ -0,0 +1,432 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library p rovided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSTEFunctionsDB.h
+    \brief This file contains a set of functions to build spatio-temporal sets from a TerraLib databse  
+*/
+#ifndef  __TERRALIB_INTERNAL_STOFUNCTIONS_H
+#define  __TERRALIB_INTERNAL_STOFUNCTIONS_H
+
+#include "TeDatabase.h"
+#include "TeProgress.h"
+#include <vector>
+#include <string>
+
+//! Builds the spatial object set from database according to the restrictions previously defined
+/*! 
+	\param stoset				the STOSet that will be filled 
+	\param loadGeometries		if the STOSet will be filled with the geometries 
+	\param loadAllAttributes	if the STOSet will be filled with all attributes of the tables of the STOSet 
+	\param attrNames			a subset of the attribute names that will be loaded, if the param loadAllAttributes is false 
+*/
+template<typename elementSet>
+bool TeSTOSetBuildDB(elementSet* stoset, bool loadGeometries = false, bool loadAllAttributes = false, vector<string> attrNames = vector<string>());
+
+//! Builds the spatial object set from database according to the restrictions previously defined
+/*! 
+	\param stoset				the STOSet that will be filled 
+	\param groupAttr			a map from attribute name to statistic type  
+	\param loadGeometries		if the STOSet will be filled with the geometries 
+*/
+template<typename elementSet>
+bool TeSTOSetBuildDB(elementSet* stoset, TeGroupingAttr& groupAttr, bool loadGeometries = false);
+
+
+//! Updates or inserts a database table from a spatial object set
+/*! 
+	\param elemSet		the set of spatial objects that will be inserted or updated into database
+	\param tableName	database table name that will be updated  
+	\param indexes		the attribute indexes of the spatial objects that must be updated
+*/
+template<typename elementSet> 
+bool TeUpdateDBFromSet (elementSet* elemSet, const string& tableName, vector<int>* indexes = 0);
+
+
+//! Auxiliary function to insert a row
+template<typename Element> 
+bool insertRow (Element* elem, TeTable& table, const string& uniqueValue, TeDatabase* db, vector<int>* indexes=0);
+
+//! Auxiliary function to update a row
+template<typename Element>
+bool updateRow (Element* elem, TeTable table, const string& uniqueId, TeDatabase* db, vector<int>* indexes=0);
+
+
+//--------------- Implementation
+
+template<typename elementSet> 
+bool TeSTOSetBuildDB(elementSet* stoset, bool loadGeometries, bool loadAllAttributes, vector<string> attrNames)
+{
+	if(!stoset->build(loadGeometries, loadAllAttributes, attrNames))
+		return false;
+	return true;
+}
+
+template<typename elementSet>
+bool TeSTOSetBuildDB(elementSet* stoset, TeGroupingAttr& groupAttr, bool loadGeometries)
+{
+	if(!stoset->build(groupAttr, loadGeometries))
+		return false;
+	return true;
+}
+
+template<typename elementSet>  
+bool TeUpdateDBFromSet (elementSet* elemSet, const string& tableName, vector<int>* indexes)
+{
+	TeDatabase* db = 0;
+	if((elemSet->getTheme()) && (elemSet->theme()->layer()))
+		db = elemSet->getTheme()->layer()->database();
+	else if(elemSet->getLayer())
+		db = elemSet->getLayer()->database();
+	
+	if(!db)
+		return false;
+	 
+	//progress bar
+	int step = 0;
+	int numSteps = elemSet->numSTInstance();
+	if(TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(numSteps);
+	
+	try
+	{
+		TeAttrTableVector attrTables;
+		if(elemSet->getTheme())
+			elemSet->getTheme()->getAttTables(attrTables); 
+		else if(elemSet->getLayer())
+			elemSet->getLayer()->getAttrTables(attrTables); 
+
+		if(attrTables.empty())
+			return false;	
+
+		TeTable table;
+		int	uniqueIndex = -1;
+	
+		//! verify if the table is in the stoset
+		for(unsigned int i=0; i<attrTables.size(); i++)
+		{
+			if(attrTables[i].name()==tableName)
+			{
+				uniqueIndex = i;
+				table = attrTables[i];
+				break;
+			}
+		}
+		
+		if((uniqueIndex==-1) || ((table.tableType()!=TeAttrEvent) && 
+								 (table.tableType()!=TeAttrStatic) && 
+								 (table.tableType()!=TeFixedGeomDynAttr) &&
+								 (table.tableType()!=TeAttrExternal)))
+			return false;
+
+		// get some information about the attribute table required
+		string uniqueIdName = table.uniqueName();
+	
+		TeDatabasePortal* portal = db->getPortal();
+		if(!portal)
+			return false;
+
+		map<string, string> uniqueIds;
+		string sql = "SELECT "+ uniqueIdName +" FROM "+ table.name();
+		
+		if(!portal->query (sql))
+		{
+			delete portal;
+			return false;
+		}
+
+		while(portal->fetchRow())
+			uniqueIds[string(portal->getData(0))] = string(portal->getData(0));
+		
+		delete portal;
+
+		//verifies if the attribute column exists in the table
+		TeAttributeList attList = elemSet->getAttributeList();
+		for(unsigned int i=0; i<attList.size(); ++i)
+		{
+			if(indexes && (find(indexes->begin(), indexes->end(),(int)i) == indexes->end()))
+				continue;
+
+			//verify if the table has this column 
+			string attrName = attList[i].rep_.name_;
+			size_t pos = attrName.find(".", 0, 1);
+			if (pos != string::npos)
+				attList[i].rep_.name_ = attrName.substr(pos+1);
+
+			if (!db->columnExist(tableName, attList[i].rep_.name_, attList[i]))
+			{
+				if(!db->addColumn (tableName, attList[i].rep_))
+					return false; 
+
+				TeAttributeList attrListTable = table.attributeList();
+				attrListTable.push_back (attList[i]);
+				table.setAttributeList(attrListTable);
+			}
+		}
+		
+		// Update all the objects 
+		typename elementSet::iterator itObj = elemSet->begin();
+		while (itObj != elemSet->end())
+		{
+			string uniqueId =  (*itObj).getUniqueId(uniqueIndex); 
+
+			if(uniqueIds.find(uniqueId) ==  uniqueIds.end())
+			{	
+				if (!insertRow (&(*itObj), table, uniqueId, db, indexes))
+					return false;
+
+				uniqueIds[uniqueId] = uniqueId;
+			}
+			else
+			{	
+				if (!updateRow (&(*itObj), table, uniqueId, db, indexes))
+					return false;
+			}
+					
+			++itObj;
+
+			if(TeProgress::instance())
+			{
+				if (TeProgress::instance()->wasCancelled())
+				{
+					TeProgress::instance()->reset();
+					return false;
+				}
+				else
+					TeProgress::instance()->setProgress(step);
+			}	
+			++step;
+		}
+	}
+	catch(...)
+	{
+		if (TeProgress::instance())
+			TeProgress::instance()->reset();
+		return false;
+	}
+	
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+	
+	return true;
+}
+
+template<typename Element> 
+bool insertRow (Element* elem, TeTable& table, const string& uniqueValue, TeDatabase* db, vector<int>* indexes)
+{
+	vector<string> attrs;
+	table.attributeNames(attrs);
+	
+	string ins = " INSERT INTO "+ table.name() +" (";
+	string values = " VALUES ( ";
+	
+	TePropertyVector prop = elem->getPropertyVector();
+	int count=0;
+
+	for(unsigned int i=0; i<prop.size(); ++i)
+	{
+		if(indexes && (find(indexes->begin(), indexes->end(),(int)i) == indexes->end()))
+			continue;
+		
+		string attrName = prop[i].attr_.rep_.name_;
+		size_t pos = attrName.find(".", 0, 1);
+		if (pos != string::npos)
+			attrName = attrName.substr(pos+1);
+				
+		if( (find(attrs.begin(), attrs.end(), attrName)!=attrs.end()) &&
+			(TeStringCompare(attrName, table.uniqueName()) == false) && 
+			(TeStringCompare(attrName,table.linkName()) == false)&&
+			(TeStringCompare(attrName,table.attInitialTime()) == false)&&
+			(TeStringCompare(attrName,table.attFinalTime()) == false)  )
+			
+		{
+			if((prop[i].attr_.rep_.type_!=TeSTRING) && prop[i].value_.empty())
+				continue; 
+
+			if(count>0)
+			{
+				ins += ",";
+				values += ",";
+			}
+			++count;
+			ins += attrName;
+			if(prop[i].attr_.rep_.type_==TeSTRING)
+				values += "'"+ prop[i].value_ +"'";
+			else if(prop[i].attr_.rep_.type_==TeREAL)
+			{
+				std::string strValue = prop[i].value_;
+				replace (strValue.begin(), strValue.end(), ',', '.');
+				values += strValue;
+			}
+			else if(prop[i].attr_.rep_.type_==TeDATETIME)
+			{
+				TeTime time(prop[i].value_, prop[i].attr_.dateChronon_, prop[i].attr_.dateTimeFormat_, prop[i].attr_.dateSeparator_, prop[i].attr_.timeSeparator_);  
+				values += db->getSQLTime(time);
+			}
+			else
+				values += prop[i].value_;
+		}
+	}
+
+	// -------- object_id, unique_id and timeInterval
+		
+	if(count>0)
+	{
+		ins +=		" ,";
+		values +=	" ,";
+	}
+
+	ins +=		table.linkName();
+	values +=	"'"+ elem->objectId() +"'";
+
+	if(table.linkName() != table.uniqueName())
+	{
+		ins +=		", "+ table.uniqueName();
+		values +=	", '"+ uniqueValue +"'";
+	}
+
+	if(!table.attInitialTime().empty())
+	{
+		TeTime time (elem->timeInterval().getT1());
+		ins +=		", "+ table.attInitialTime();
+		values +=	", "+ db->getSQLTime(time); 
+	}
+
+	if((!table.attFinalTime().empty()) && (table.attInitialTime()!=table.attFinalTime()))
+	{
+		TeTime time (elem->timeInterval().getT2());
+		ins +=		", "+ table.attFinalTime();
+		values +=	", "+ db->getSQLTime(time); 
+	}
+	// ----------
+
+	ins += ") "+ values +" )";
+	
+	if(!db->execute (ins))
+		return false;
+
+	return true;
+}
+
+template<typename Element>
+bool updateRow (Element* elem, TeTable table, const string& uniqueId, TeDatabase* db, vector<int>* indexes)
+{
+	
+	vector<string> attrs;
+	table.attributeNames(attrs);
+
+	string ins = " UPDATE "+ table.name() +" SET ";
+	
+	TePropertyVector prop = elem->getPropertyVector();
+	int count = 0;
+	for(unsigned int i=0; i<prop.size(); ++i)
+	{
+		if(indexes && (find(indexes->begin(), indexes->end(),(int)i) == indexes->end()))
+			continue;
+
+		string attrName = prop[i].attr_.rep_.name_;
+		size_t pos = attrName.find(".", 0, 1);
+
+		std::string tableName; 
+		if (pos != string::npos)
+		{
+			attrName = attrName.substr(pos+1);
+			tableName = attrName.substr(0, pos-1);
+			if (tableName != table.name())
+               continue;
+		} 
+
+		if( (find(attrs.begin(), attrs.end(), attrName)!=attrs.end()) &&
+			(TeStringCompare(attrName,table.uniqueName()) == false) && 
+			(TeStringCompare(attrName,table.linkName()) == false) && 
+			(TeStringCompare(attrName,table.attInitialTime()) == false) && 
+			(TeStringCompare(attrName,table.attFinalTime()) == false) )
+		{
+		
+			if((prop[i].attr_.rep_.type_!=TeSTRING) && (prop[i].value_.empty()))
+				continue; 
+
+			if(count>0)
+				ins += ",";
+			
+			++count;
+			ins += attrName +" = ";
+		
+			if(prop[i].attr_.rep_.type_==TeSTRING)
+				ins += "'"+ prop[i].value_ +"'";
+			else if(prop[i].attr_.rep_.type_==TeREAL)
+			{
+				std::string strValue = prop[i].value_;
+				replace (strValue.begin(), strValue.end(), ',', '.');
+				ins += strValue;
+			}
+			else if(prop[i].attr_.rep_.type_==TeDATETIME)
+			{
+				TeTime time(prop[i].value_, prop[i].attr_.dateChronon_, prop[i].attr_.dateTimeFormat_, prop[i].attr_.dateSeparator_, prop[i].attr_.timeSeparator_);  
+				ins += db->getSQLTime(time);
+			}
+			else
+				ins += prop[i].value_;
+		}
+	}
+
+	// -------- timeInterval
+	if(!table.attInitialTime().empty())
+	{
+		TeTime time (elem->timeInterval().getT1());
+		if(count>0)
+			ins +=	", "; 
+		ins += table.attInitialTime() +" = ";
+		ins +=	db->getSQLTime(time); 
+		++count;
+	}
+
+	if((!table.attFinalTime().empty()) && (table.attInitialTime()!=table.attFinalTime()))
+	{
+		TeTime time (elem->timeInterval().getT2());
+		if(count>0)
+			ins +=	", "; 
+		ins += table.attFinalTime() +" = ";
+		ins +=	db->getSQLTime(time);
+		++count;
+	}
+	// ----------
+
+	if ( count == 0 ) 
+		return true; 
+
+	ins += " WHERE "+ table.uniqueName() +" = '"+ uniqueId +"'";
+	
+	if(!db->execute (ins))
+		return false;
+
+	return true;
+}
+ 
+/** \example createSTElementSetFromLayer.cpp
+ 	Shows how to create a new Spatial Temporal Element Set (STElementSet) from a layer
+ */
+
+/** \example createSTElementSetFromTheme.cpp
+ 	Shows how to create a new Spatial Temporal Element Set (STElementSet) from a theme
+ */
+#endif
+
diff --git a/src/terralib/kernel/TeSTElementSet.cpp b/src/terralib/kernel/TeSTElementSet.cpp
new file mode 100644
index 0000000..559e571
--- /dev/null
+++ b/src/terralib/kernel/TeSTElementSet.cpp
@@ -0,0 +1,256 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include <TeSTElementSet.h>
+#include <TeQuerier.h> 
+#include <TeQuerierParams.h>
+
+TeTimeInterval 
+TeSTElementSet::totalTime() 
+{	
+	return TeTimeInterval(this->getMinTime().getT1(),this->getMaxTime().getT2());
+} 
+
+void 
+TeSTElementSet::totalTime(TeTimeInterval t) 
+{	
+	minTime_ = TeTimeInterval(t.getT1(), t.getT1());
+	maxTime_ = TeTimeInterval(t.getT2(), t.getT2());
+}
+
+	
+bool 
+TeSTElementSet::hasElement(const string& objId) 
+{	
+	return (numSTInstance(objId)>0);  
+}
+
+bool 
+TeSTElementSet::setGeometry(const string& object_id, const TePolygonSet& geomSet, TeTimeInterval time)
+{
+	vector<TeSTInstance*> result;
+	this->getSTInstances(result, object_id, time);
+	vector<TeSTInstance*>::iterator it = result.begin();
+
+	while(it!=result.end())
+	{
+		(*it)->setGeometry(geomSet);
+		++it;
+	}
+	return true;
+}
+
+bool 
+TeSTElementSet::setGeometry(const string& object_id, const TeLineSet& geomSet, TeTimeInterval time)
+{
+	vector<TeSTInstance*> result;
+	this->getSTInstances(result, object_id, time);
+	vector<TeSTInstance*>::iterator it = result.begin();
+
+	while(it!=result.end())
+	{
+		(*it)->setGeometry(geomSet);
+		++it;
+	}
+	return true;
+}
+
+bool 
+TeSTElementSet::setGeometry(const string& object_id, const TePointSet& geomSet, TeTimeInterval time)
+{
+	vector<TeSTInstance*> result;
+	this->getSTInstances(result, object_id, time);
+	vector<TeSTInstance*>::iterator it = result.begin();
+
+	while(it!=result.end())
+	{
+		(*it)->setGeometry(geomSet);
+		++it;
+	}
+	return true;
+}
+
+bool 
+TeSTElementSet::setGeometry(const string& object_id, const TeCellSet& geomSet, TeTimeInterval time)
+{
+	vector<TeSTInstance*> result;
+	this->getSTInstances(result, object_id, time);
+	vector<TeSTInstance*>::iterator it = result.begin();
+
+	while(it!=result.end())
+	{
+		(*it)->setGeometry(geomSet);
+		++it;
+	}
+	return true;
+}
+
+bool 
+TeSTElementSet::setGeometry(const string& object_id, const TeTextSet& geomSet, TeTimeInterval time)
+{
+	vector<TeSTInstance*> result;
+	this->getSTInstances(result, object_id, time);
+	vector<TeSTInstance*>::iterator it = result.begin();
+
+	while(it!=result.end())
+	{
+		(*it)->setGeometry(geomSet);
+		++it;
+	}
+	return true;
+}
+
+
+bool 
+TeSTElementSet::getGeometry(const string& object_id, TePolygonSet& geomSet, TeTimeInterval time)
+{
+	TeSTInstance* result = this->getSTInstance(object_id, time);
+	if(!result)
+		return false; 
+	geomSet = result->getPolygons();
+	return true;
+}
+
+
+bool 
+TeSTElementSet::getGeometry(const string& object_id, TeLineSet& geomSet, TeTimeInterval time)
+{
+	TeSTInstance* result = this->getSTInstance(object_id, time);
+	if(!result)
+		return false; 
+	geomSet = result->getLines();
+	return true;
+}
+
+	
+bool 
+TeSTElementSet::getGeometry(const string& object_id, TePointSet& geomSet, TeTimeInterval time)
+{
+	TeSTInstance* result = this->getSTInstance(object_id, time);
+	if(!result)
+		return false; 
+	geomSet = result->getPoints();
+	return true;
+}
+
+	
+bool 
+TeSTElementSet::getGeometry(const string& object_id, TeCellSet& geomSet, TeTimeInterval time)
+{
+	TeSTInstance* result = this->getSTInstance(object_id, time);
+	if(!result)
+		return false; 
+	geomSet = result->getCells();
+	return true; 
+}
+
+bool 
+TeSTElementSet::getGeometry(const string& object_id, TeTextSet& geomSet, TeTimeInterval time)
+{
+	TeSTInstance* result = this->getSTInstance(object_id, time);
+	if(!result)
+		return false; 
+	geomSet = result->getTexts();
+	return true;
+}
+
+bool 
+TeSTElementSet::buildImpl(TeQuerier* querier, const int& slide)
+{
+	int dt = CLOCKS_PER_SEC/4, steps = 0;
+	int dt2 = CLOCKS_PER_SEC * 5;
+	clock_t	t0, t1, t2;
+	
+	t0=t1=t2=clock();
+
+	if(!querier)
+		return false;
+
+	if(!querier->loadInstances(slide))
+		return false;
+	
+	//clear all structures
+	attrList_->clear();
+	instances_.clear();
+	objectIdToInstances_.clear();
+	timeToInstances_.clear();
+	sliceToInstances_.clear();
+	if(rTree_)
+		delete rTree_;
+	rTree_ = 0;
+	
+	//Builts another rTree
+	TeBox b;
+	if(theme_)
+		b = theme_->box();
+	else if(layer_)
+		b = layer_->box();
+	else
+		b = this->box_; 
+	rTree_ = new TeSAM::TeRTree<int>(b); 
+
+	TeAttributeList l = querier->getAttrList();
+	setAttributeList(l);
+
+	int tot = querier->numElemInstances();
+	
+	if(TeProgress::instance())
+	{
+		TeProgress::instance()->reset();
+		string caption = "Building data";
+		TeProgress::instance()->setCaption(caption.c_str());
+		string msg = "Building in progress. Please, wait!";
+		TeProgress::instance()->setMessage(msg);
+		TeProgress::instance()->setTotalSteps(tot);
+		t2 = clock();
+		t0 = t1 = t2;
+	}
+	
+	TeSTInstance obj;
+	while(querier->fetchInstance(obj)) 
+	{
+		this->insertSTInstance(obj);
+		
+		obj.clear();
+		if(TeProgress::instance())
+		{
+			steps++;
+			t2 = clock();
+			if (int(t2-t1) > dt)
+			{
+				t1 = t2;
+				if(TeProgress::instance()->wasCancelled())
+					return false;
+				
+				if((int)(t2-t0) > dt2)
+					TeProgress::instance()->setProgress(steps);
+			}
+		}
+	}
+	if(TeProgress::instance())
+		TeProgress::instance()->reset();
+
+	return true;
+}
+
+
diff --git a/src/terralib/kernel/TeSTElementSet.h b/src/terralib/kernel/TeSTElementSet.h
new file mode 100644
index 0000000..ecb9ec9
--- /dev/null
+++ b/src/terralib/kernel/TeSTElementSet.h
@@ -0,0 +1,125 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSTElementSet.h
+	\brief This file contains structures to deal with a set of spatio-temporal 
+	instances. These instances can belong to a specific layer or theme.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_STELEMENTSET_H
+#define  __TERRALIB_INTERNAL_STELEMENTSET_H
+
+#include "TeBaseSTInstanceSet.h"
+#include "TeSTInstance.h"
+#include "TeTimeInterval.h"
+#include "TeMultiGeometry.h"
+
+class TeQuerier;
+class TeTheme;
+class TeLayer;
+
+
+/*! \class TeSTElementSet
+	\brief A class that represents a set of spatial temporal instances.
+
+	This class specializes the abstract class TeBaseSTInstanceSet representing
+	each spatial temporal instance of the set as a TeSTInstance type. That is, the 
+	geometries of each instance in this set is represented as multi geometries 
+	(TeMultiGeometry class)and its valid time as a time interval (TeTimeInterval class). 
+
+	\sa TeBaseSTInstanceSet TeSTInstance TeMultiGeometry TeTimeInterval TeTheme TeLayer
+*/
+class TL_DLL TeSTElementSet  : public TeBaseSTInstanceSet<TeMultiGeometry, TeTimeInterval, TeSTInstance>
+{
+protected:
+
+	//! Builds the set using a given querier and a specific slice
+	bool buildImpl(TeQuerier* querier, const int& slide = -1);
+
+public:
+	//! Constructor
+	TeSTElementSet() : TeBaseSTInstanceSet<TeMultiGeometry, TeTimeInterval, TeSTInstance>()
+	{ }
+
+	//! Constructor 
+	TeSTElementSet(TeTheme* theme, TeAttributeList attList = TeAttributeList()) : 
+		TeBaseSTInstanceSet<TeMultiGeometry, TeTimeInterval, TeSTInstance>(theme, attList)
+	{ }
+	
+	//! Constructor 
+	TeSTElementSet(TeLayer* layer, TeAttributeList attList = TeAttributeList()) : 
+		TeBaseSTInstanceSet<TeMultiGeometry, TeTimeInterval, TeSTInstance>(layer, attList)
+	{ }
+
+
+	//! Constructor 
+	TeSTElementSet(const TeBox& box, const TeAttributeList& attrList) :
+		TeBaseSTInstanceSet<TeMultiGeometry, TeTimeInterval, TeSTInstance>(box, attrList)
+	{ }
+
+
+	//! Returns the valid time interval for all ST instances
+	TeTimeInterval totalTime(); 
+
+	//! Sets the valid time interval for all ST instances
+	void totalTime(TeTimeInterval t); 
+
+	//! Deprecated: Verifies if there is a specific element or object in the set 
+	bool hasElement(const string& objId);
+
+	//! Sets a polygon set and its valid time interval to a specific object or element
+	bool setGeometry(const string& object_id, const TePolygonSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Sets a line set and its valid time interval to a specific object or element
+	bool setGeometry(const string& object_id, const TeLineSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Sets a point set and its valid time interval to a specific object or element
+	bool setGeometry(const string& object_id, const TePointSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Sets a cell set and its valid time interval to a specific object or element
+	bool setGeometry(const string& object_id, const TeCellSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Sets a text set and its valid time interval to a specific object or element
+	bool setGeometry(const string& object_id, const TeTextSet& geomSet, TeTimeInterval time = TeTimeInterval()); 
+
+	//! Gets a polygon set of an element or object and its valid time interval
+	bool getGeometry(const string& object_id, TePolygonSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Gets a line set of an element or object and its valid time interval
+	bool getGeometry(const string& object_id, TeLineSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Gets a point set of an element or object and its valid time interval
+	bool getGeometry(const string& object_id, TePointSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Gets a cell set of an element or object and its valid time interval
+	bool getGeometry(const string& object_id, TeCellSet& geomSet, TeTimeInterval time = TeTimeInterval());
+	//! Gets a text set of an element or object and its valid time interval
+	bool getGeometry(const string& object_id, TeTextSet& geomSet, TeTimeInterval time = TeTimeInterval());
+};
+
+
+/*! \example createSTElementSetFromLayer.cpp
+	Shows how to create a spatio-temporal element set from a layer.
+ */
+
+/*! \example createSTElementSetFromShapeFile.cpp
+	Shows how to create aspatio-temporal element set from a shapefile.
+ */
+
+/*! \example createSTElementSetFromTheme.cpp
+	Shows how to create aspatio-temporal element set from a theme.
+ */
+#endif
+
diff --git a/src/terralib/kernel/TeSTEvent.cpp b/src/terralib/kernel/TeSTEvent.cpp
new file mode 100644
index 0000000..c544c51
--- /dev/null
+++ b/src/terralib/kernel/TeSTEvent.cpp
@@ -0,0 +1,207 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeSTEvent.h"
+
+///------------ TeSTEvent
+void 
+TeSTEvent::clear()
+{
+	TeBaseSTInstance<TePoint, long>::clear();
+	geometries_ = TePoint(); 
+	time_ = -1;
+}
+
+bool 
+TeSTEvent::isTimeValid() 
+{
+	return (time_>=0);
+}
+
+///------------ TeSTEventSet
+
+TeSTEventSet::TeSTEventSet(TeTheme* theme, const TeAttributeList& attrList) : 
+	TeBaseSTInstanceSet<TePoint, long, TeSTEvent>(theme, attrList)
+{
+	kdTree_ = 0;
+}
+
+TeSTEventSet::~TeSTEventSet()
+{
+	if(kdTree_)
+		delete kdTree_;
+	kdTree_ = 0;
+}
+
+bool TeSTEventSet::buildKdTree(const int& n)
+{
+	if(!theme_)
+		return false;
+    if(kdTree_)
+		delete kdTree_;
+
+	vector<pair<TeCoord2D, TePoint> >	dataSetAux; //auxiliary structure for kdTree
+	TeSTEventSet::iterator it = this->begin();
+	int index=0;
+	while(it!=this->end())
+	{
+		TePoint point = it->getGeometries();
+		point.geomId(index);
+		dataSetAux.push_back(pair<TeCoord2D, TePoint>(point.location(), point));
+		++it;
+		++index;
+	}
+
+	int bucketSize; 
+	if(n<0)
+		bucketSize= 30;
+	else
+		bucketSize= 2*n;
+	kdTree_ = new kdTree(theme_->box(), bucketSize);
+	kdTree_->build(dataSetAux);
+	return true;
+}
+
+bool TeSTEventSet::search(const TeBox& b, vector<TeSTEvent* >& result)
+{
+	if(!kdTree_)
+		return false;
+	
+	vector<kdNode*> nodes;
+	kdTree_->search(b, nodes);
+	for(unsigned int i=0; i<nodes.size(); ++i)
+	{
+		for(unsigned int j=0; j<nodes[i]->getData().size(); ++j) //vector<TePoint>
+		{
+			int index = ((nodes[i]->getData())[j]).geomId(); 
+			TeSTEvent* ev = dynamic_cast<TeSTEvent*> (this->getSTInstance(index));
+			result.push_back(ev); 
+		}
+	}
+	return true;
+}
+
+bool TeSTEventSet::nearestNeighbourSearch(const TeCoord2D& coord, vector<TeSTEvent* >& result, 
+										  vector<double>& distances, const unsigned int& k)
+{
+	vector<TePoint> res;
+	for(unsigned int n=0; n<k; ++n)
+		res.push_back (TePoint(TeMAXFLOAT,TeMAXFLOAT));
+	kdTree_->nearestNeighborSearch(coord, res, distances, k); 
+	for(unsigned int j=0; j<res.size(); ++j)
+		result.push_back(dynamic_cast<TeSTEvent*>(getSTInstance(res[j].geomId()))); 
+	return true;
+}
+
+void TeSTEventSet::clear()
+{
+	TeBaseSTInstanceSet<TePoint, long, TeSTEvent>::clear();
+	if(kdTree_)
+		delete kdTree_;
+	kdTree_ = 0;
+}
+
+bool 
+TeSTEventSet::buildImpl(TeQuerier* querier, const int& slide)
+{
+	int dt = CLOCKS_PER_SEC/4, steps = 0;
+	int dt2 = CLOCKS_PER_SEC * 5;
+	clock_t	t0, t1, t2;
+	
+	t0=t1=t2=clock();
+
+	if(!querier)
+		return false;
+
+	if(!querier->loadInstances(slide))
+		return false;
+
+	//clear all structures
+	attrList_->clear();
+	instances_.clear();
+	objectIdToInstances_.clear();
+	timeToInstances_.clear();
+	sliceToInstances_.clear();
+	if(rTree_)
+		delete rTree_;
+	rTree_ = 0; 
+	kdTree_->clear();
+	
+	//Builts another rTree
+	TeBox b;
+	if(theme_)
+		b = theme_->box();
+	else if(layer_)
+		b = layer_->box();
+	else
+		b = this->box_; 
+	rTree_ = new TeSAM::TeRTree<int>(b); 
+	
+	TeAttributeList l = querier->getAttrList();
+	setAttributeList(l);
+
+	int tot = querier->numElemInstances();
+	if(TeProgress::instance())
+	{
+		string caption = "Building data";
+		TeProgress::instance()->setCaption(caption.c_str());
+		string msg = "Building in progress. Please, wait!";
+		TeProgress::instance()->setMessage(msg);
+		TeProgress::instance()->setTotalSteps(tot);
+		t2 = clock();
+		t0 = t1 = t2;
+	}
+	
+	TeSTInstance obj;
+	while(querier->fetchInstance(obj)) 
+	{
+		TeCoord2D p;
+		obj.centroid(p);
+
+		TeSTEvent event(obj.getObjectId(), TePoint(p), obj.getProperties(), 0, -1);
+		this->insertSTInstance(event);
+
+		if(TeProgress::instance())
+		{
+			steps++;
+			t2 = clock();
+			if (int(t2-t1) > dt)
+			{
+				t1 = t2;
+				if(TeProgress::instance()->wasCancelled())
+					return false;
+				
+				if((int)(t2-t0) > dt2)
+					TeProgress::instance()->setProgress(steps);
+			}
+		}
+	}
+	if(TeProgress::instance())
+		TeProgress::instance()->reset();
+
+	return true;
+}
+
+
+
+
diff --git a/src/terralib/kernel/TeSTEvent.h b/src/terralib/kernel/TeSTEvent.h
new file mode 100644
index 0000000..52b1dbe
--- /dev/null
+++ b/src/terralib/kernel/TeSTEvent.h
@@ -0,0 +1,132 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSTEvent.h
+	\brief This file contains structures and definitions to deal with spatial 
+	temporal events. 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_STEVENT_H
+#define  __TERRALIB_INTERNAL_STEVENT_H
+
+#include "TeBaseSTInstance.h"
+#include "TeBaseSTInstanceSet.h"
+#include "TeGeometry.h"
+#include "TeKdTree.h"
+
+
+/*! \class TeSTEvent
+	\brief A class that represents spatial temporal events (STEvent).
+
+	A spatial temporal event is represented by a location (point), 
+	a time when it happened and a set of attributes. This class 
+	specializes the base class TeBaseSTInstance representing the geometries 
+	as points (TePoint) and the valid time as a integer (long).
+
+	\sa TeBaseSTInstance TePoint 
+*/
+class TL_DLL TeSTEvent : public TeBaseSTInstance<TePoint, long>
+{	
+public:
+	
+	//! Empty constructor
+	TeSTEvent() : TeBaseSTInstance<TePoint, long>()
+	{ }
+
+	//! Constructor
+	TeSTEvent(const string& objId, const TePoint& point, const long& time) :
+		TeBaseSTInstance<TePoint, long>(objId, point, time)
+	{ }
+
+	//! Constructor
+	TeSTEvent(const string& objId, const TePoint& point, const vector<string>& attrValues, 
+		TeAttributeList* attList, const long& time) :
+		TeBaseSTInstance<TePoint, long>(objId, attrValues, attList, point, -1, time)
+	{ }
+
+	//! Clear
+	virtual void clear(); 
+	
+	//! Verifies if the time associated to this event is valid
+	virtual bool isTimeValid(); 
+
+	//! Deprecated: Gets the event location (point)
+	void getGeometry(TePoint& result)
+	{	result = this->geometries(); }
+
+	//! Deprecated: Returns the valid time 
+	virtual TeTimeInterval timeInterval () 
+	{	TeTimeInterval t; return t;	}
+};
+
+
+/*! \class TeSTEventSet
+	\brief A class that represents a set of spatial temporal events.
+
+	This class specializes the abstract class TeBaseSTInstanceSet representing
+	each spatial temporal instance of the set as a TeSTEvent type. That is, the 
+	geometries of each instance or event in this set is represented as a point 
+	(TePoint class)and its valid time as a simple number (long type). 
+
+	\sa TeBaseSTInstanceSet TeSTEvent TePoint TeTheme TeLayer
+*/
+class TL_DLL TeSTEventSet : public TeBaseSTInstanceSet<TePoint, long, TeSTEvent>
+{
+protected:
+
+	typedef TeSAM::TeAdaptativeKdTreeNode<TeCoord2D, vector<TePoint>, TePoint> kdNode;
+	typedef TeSAM::TeAdaptativeKdTree<kdNode> kdTree;
+
+	//! Index structure (KD Tree) to index the point locations
+	kdTree*		kdTree_;
+
+	//! Build the set using querier
+	bool buildImpl(TeQuerier* querier, const int& slide = -1);
+
+public:			
+	//! Constructor	
+	TeSTEventSet(TeTheme* theme=0, const TeAttributeList& attrList = TeAttributeList()); 
+
+	//! Destructor	
+	~TeSTEventSet();
+
+	//! Build a index structure (kdTree) over all event points in this set
+	virtual bool buildKdTree(const int& n); 
+	
+	//! Searchs the event points inside a specific bounding box 
+	virtual bool search(const TeBox& b, vector<TeSTEvent* >& result);
+
+	//! Searchs the k-nearest neighbours of a specific coordinate
+	virtual bool nearestNeighbourSearch(const TeCoord2D& coord, vector<TeSTEvent* >& result, vector<double>& distances, const unsigned int& k);
+	
+	//! Clears the event set 
+	virtual void clear(); 
+};
+
+#endif
+
+
+
+
+
+
+
diff --git a/src/terralib/kernel/TeSTInstance.cpp b/src/terralib/kernel/TeSTInstance.cpp
new file mode 100644
index 0000000..172ebeb
--- /dev/null
+++ b/src/terralib/kernel/TeSTInstance.cpp
@@ -0,0 +1,353 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+
+#include <TeSTInstance.h>
+
+
+TeSTInstance::TeSTInstance (const string& object_id, TeProperty& prop) :
+	TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>()
+{
+	object_id_ = object_id;
+	properties_.push_back(prop.value_);
+}
+
+void 
+TeSTInstance::clear() 
+{
+	TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>::clear();
+	geometries_.clear(); 
+	time_ = TeTimeInterval();
+}
+
+
+bool 
+TeSTInstance::isTimeValid()
+{
+	return (this->time_.isValid());
+}
+	
+bool 
+TeSTInstance::hasPolygons()	
+{ 
+	return (geometries_.hasPolygons()); 
+} 
+	
+bool 
+TeSTInstance::hasLines()		
+{ 
+	return (geometries_.hasLines()); 
+} 
+	
+bool 
+TeSTInstance::hasPoints()		
+{ 
+	return (geometries_.hasPoints()); 
+} 
+	
+bool 
+TeSTInstance::hasCells()		
+{ 
+	return (geometries_.hasCells()); 
+} 
+
+bool 
+TeSTInstance::hasTexts()		
+{ 
+	return (geometries_.hasTexts()); 
+} 
+	
+bool 
+TeSTInstance::getGeometry(TePolygonSet& result)
+{
+	if(geometries_.getGeometry(result))
+		return true;
+	return false;
+}
+	
+bool 
+TeSTInstance::getGeometry(TeLineSet& result)
+{
+	if(geometries_.getGeometry(result))
+		return true;
+	return false;
+}
+
+bool 
+TeSTInstance::getGeometry(TePointSet& result)
+{
+	if(geometries_.getGeometry(result))
+		return true;
+	return false;
+}
+
+bool 
+TeSTInstance::getGeometry(TeCellSet& result)
+{
+	if(geometries_.getGeometry(result))
+		return true;
+	return false;
+}
+
+bool 
+TeSTInstance::getGeometry(TeTextSet& result)
+{
+	if(geometries_.getGeometry(result))
+		return true;
+	return false;
+}
+
+bool 
+TeSTInstance::getGeometry(vector<TeGeometry*>& result)
+{
+	if(geometries_.getGeometry(result))
+		return true;
+	return false;
+}
+
+bool 
+TeSTInstance::getGeometry(TeMultiGeometry& result)
+{
+	if(!geometries_.empty())
+	{
+		result = geometries_;
+		return true; 
+	}
+
+	geometries_.getGeometry (result.polygons_);
+	geometries_.getGeometry (result.lines_);
+	geometries_.getGeometry (result.points_);
+	geometries_.getGeometry (result.cells_);
+	
+	return (!result.empty());
+}
+
+TePolygonSet&  
+TeSTInstance::getPolygons()
+{	
+	return geometries_.getPolygons(); 
+}
+	
+TeLineSet&  
+TeSTInstance::getLines()
+{	
+	return geometries_.getLines(); 
+}
+
+TePointSet&  
+TeSTInstance::getPoints()
+{	
+	return geometries_.getPoints(); 
+}
+
+TeCellSet&  
+TeSTInstance::getCells()
+{	
+	return geometries_.getCells(); 
+}
+
+TeTextSet&  
+TeSTInstance::getTexts()
+{	
+	return geometries_.getTexts(); 
+}
+
+void 
+TeSTInstance::setGeometry(const TePolygonSet& result)
+{ 
+	geometries_.setGeometry(result); 
+}
+	
+void 
+TeSTInstance::setGeometry(const TeLineSet& result)
+{ 
+	geometries_.setGeometry(result); 
+}
+	
+void 
+TeSTInstance::setGeometry(const TePointSet& result)
+{ 
+	geometries_.setGeometry(result); 
+}
+	
+void 
+TeSTInstance::setGeometry(const TeCellSet& result)
+{ 
+	geometries_.setGeometry(result); 
+}
+	
+void 
+TeSTInstance::setGeometry(const TeTextSet& result)
+{ 
+	geometries_.setGeometry(result); 
+}
+
+void 
+TeSTInstance::setGeometry(const TeMultiGeometry& result)
+{ 
+	geometries_ = result; 
+}
+ 
+bool 
+TeSTInstance::addGeometry(const TePolygon& poly)  
+{ 
+	if(poly.objectId() == objectId())
+	{
+		geometries_.addGeometry (poly);
+		return true;
+	}
+	return false;
+}
+	
+bool 
+TeSTInstance::addGeometry(const TeLine2D& line)     
+{ 
+	if(line.objectId() == objectId())
+	{
+		geometries_.addGeometry (line);
+		return true;
+	}
+	return false; 
+}
+	
+bool 
+TeSTInstance::addGeometry(const TePoint& point)	
+{ 
+	if(point.objectId() == objectId())
+	{
+		geometries_.addGeometry (point);
+		return true;
+	}
+	return false;  
+} 
+	
+bool
+TeSTInstance::addGeometry(const TeCell& cell)		
+{ 
+	if(cell.objectId() == objectId())
+	{
+		geometries_.addGeometry (cell);
+		return true;
+	}
+	return false;  
+}
+
+bool
+TeSTInstance::addGeometry(const TeText& text)		
+{ 
+	if(text.objectId() == objectId())
+	{
+		geometries_.addGeometry (text);
+		return true;
+	}
+	return false;  
+}
+
+void 
+TeSTInstance::centroid(TeCoord2D& centroid, TeGeomRep geomRep)
+{
+	if(geomRep==TePOLYGONS)
+	{ 
+		TePolygonSet pols;
+		if(getGeometry(pols))
+		{
+			centroid = TeFindCentroid(pols);
+			return;
+		}
+	}
+	if(geomRep==TeLINES)
+	{
+		TeLineSet lins; 
+		if(getGeometry(lins))
+		{
+			centroid = TeFindCentroid(lins);
+			return;
+		}
+	}
+	if(geomRep==TePOINTS)
+	{
+		TePointSet points; 
+		if(getGeometry(points))
+		{
+			centroid = TeFindCentroid(points);
+			return;
+		}
+	}
+	if(geomRep==TeCELLS)
+	{
+		TeCellSet cells; 
+		if(getGeometry(cells))
+		{
+			centroid = TeFindCentroid(cells);
+			return;
+		}
+	}
+	if(geomRep==TeGEOMETRYNONE)
+	{
+		if(hasPolygons())
+			this->centroid(centroid, TePOLYGONS);
+		else if(hasLines())
+			this->centroid(centroid, TeLINES);
+		else if (hasPoints())
+			this->centroid(centroid, TePOINTS);
+		else if (hasCells())
+			this->centroid(centroid, TeCELLS);
+	}
+
+	return;
+}
+
+void 
+TeSTInstance::area(double& a, TeGeomRep geomRep)
+{
+	a = 0.;
+	if(geomRep==TePOLYGONS)
+	{ 
+		TePolygonSet pols;
+		if(getGeometry(pols))
+		{
+			a = TeGeometryArea(pols);
+			return;
+		}
+	}
+	if(geomRep==TeCELLS)
+	{
+		TeCellSet cells; 
+		if(getGeometry(cells))
+		{
+			a = TeGeometryArea(cells);
+			return;
+		}
+	}
+	if(geomRep==TeGEOMETRYNONE)
+	{
+		if(hasPolygons())
+			this->area(a, TePOLYGONS);
+		else if (hasCells())
+			this->area(a, TeCELLS);
+	}
+
+	return;
+}
+
+
diff --git a/src/terralib/kernel/TeSTInstance.h b/src/terralib/kernel/TeSTInstance.h
new file mode 100644
index 0000000..bd6490a
--- /dev/null
+++ b/src/terralib/kernel/TeSTInstance.h
@@ -0,0 +1,174 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSTInstance.h
+	\brief This file contains a class called TeSTInstance that represents 
+	an instance in time of a geographical object or element.  
+*/
+
+#ifndef  __TERRALIB_INTERNAL_STINSTANCE_H
+#define  __TERRALIB_INTERNAL_STINSTANCE_H
+
+#include "TeTimeInterval.h"
+#include "TeMultiGeometry.h"
+#include "TeBaseSTInstance.h"
+
+#include <string>
+#include <map> 
+#include <vector>
+using namespace std;
+
+/*! \class TeSTInstance
+	\brief A class that represents an instance in a time of a spatial object.
+
+	A spatio-temporal instance (STInstance) is composite of an attribute set and geometries 
+	of a spatial element or object that are valid in a specific time. This class 
+	specializes the base class TeBaseSTInstance representing the geometries 
+	as multigeometries (TeMultiGeometry) and the valid time as a time interval (TeTimeInterval).
+
+	\sa TeBaseSTInstance TeMultiGeometry TeTimeInterval
+	
+*/
+class TL_DLL TeSTInstance : public TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>
+{
+public:		
+
+	//! Constructor
+	TeSTInstance() : 
+		TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>() 
+	{ }
+
+	//! Deprecated: Constructor
+	TeSTInstance (const string& object_id, TeProperty& prop); 
+
+	//! Constructor 
+	TeSTInstance (const string& object_id, vector<string>& prop, TeAttributeList* attList = 0, const int& s = -1) : 
+		TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>(object_id, prop, attList, s)
+	{ }
+
+	//! Constructor
+	TeSTInstance (const string& object_id, const TeMultiGeometry& geometries, 
+		const TeTimeInterval& time, const int& s = -1) : 
+		TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>(object_id, geometries, time, s)
+	{ }
+
+	//! Constructor 
+	TeSTInstance (const string& object_id, vector<string>& prop, TeAttributeList* attList, 
+		TeMultiGeometry& geometries, int& slice, TeTimeInterval& time ) :
+		TeBaseSTInstance<TeMultiGeometry, TeTimeInterval>(object_id, prop, attList, geometries, slice, time)
+	{ }
+
+	//! Clear 
+	virtual void clear(); 
+	
+	//! Verifies if the its time is valid
+	virtual bool isTimeValid();
+	
+	//! Deprecated: Verifies if the instance has polygons
+	bool hasPolygons();	
+	//! Deprecated: Verifies if the instance has lines
+	bool hasLines();		
+	//! Deprecated: Verifies if the instance has points
+	bool hasPoints();		
+	//! Deprecated: Verifies if the instance has cells
+	bool hasCells();		
+	//! Deprecated: Return true if this has texts
+	bool hasTexts();		
+	
+	//! Deprecated: Gets a copy of the ST instance polygon set
+	bool getGeometry(TePolygonSet& result); 
+	//! Deprecated: Gets a copy of the ST instance line set
+	bool getGeometry(TeLineSet& result);
+	//! Deprecated: Gets a copy of the ST instance point set
+	bool getGeometry(TePointSet& result);
+	//! Deprecated: Gets a copy of the ST instance cell set
+	bool getGeometry(TeCellSet& result);
+	//! Deprecated: Gets a copy of the ST instance text set
+	bool getGeometry(TeTextSet& result);
+	//! Deprecated: Gets a copy of the ST instance geometry vector
+	bool getGeometry(vector<TeGeometry*>& result);
+	//! Deprecated: Gets a copy of the ST instance multi geometry
+	bool getGeometry(TeMultiGeometry& result);
+
+	//! Deprecated: Get a reference to the ST instance polygon geometry
+	TePolygonSet&  getPolygons();
+	//! Deprecated: Get a reference to the ST instance line geometry
+	TeLineSet&  getLines();
+	//! Deprecated: Get a reference to the ST instance point geometry 
+	TePointSet&  getPoints();
+	//! Deprecated: Get a reference to the ST instance cell geometry  
+	TeCellSet&  getCells();
+	//! Deprecated: Get a reference to the ST instance text geometry 
+	TeTextSet&  getTexts();
+
+	//! Deprecated: Sets a polygon set to the instance 
+	void setGeometry(const TePolygonSet& result); 
+	//! Deprecated: Sets a line set to the instance 
+	void setGeometry(const TeLineSet& result);
+	//! Deprecated: Sets a point set to the instance 
+	void setGeometry(const TePointSet& result);
+	//! Deprecated: Sets a cell set to the instance 
+	void setGeometry(const TeCellSet& result);
+	//! Deprecated: Sets a text set to the instance 
+	void setGeometry(const TeTextSet& result);
+	//! Deprecated: Sets a text set to the instance 
+	void setGeometry(const TeMultiGeometry& result);
+			
+	//! Deprecated: Adds a polygon to the instance
+	bool addGeometry(const TePolygon& poly);  
+	//! Deprecated: Adds a line to the instance
+	bool addGeometry(const TeLine2D& line);
+	//! Deprecated: Adds a point to the instance
+	bool addGeometry(const TePoint& point);	
+	//! Deprecated: Adds a cell to the instance
+	bool addGeometry(const TeCell& cell);		
+	//! Deprecated: Adds a text to the instance
+	bool addGeometry(const TeText& cell);		
+
+	//! Returns a centroid of a geometry representation 
+	virtual void centroid(TeCoord2D& centroid, TeGeomRep geomRep=TeGEOMETRYNONE); 
+	
+	//! Returns an area of a geometry representation
+	virtual void area(double& a, TeGeomRep geomRep=TeGEOMETRYNONE);
+
+	//! Deprecated: Returns the valid time 
+	virtual TeTimeInterval timeInterval () 
+	{	return getTime();	}
+	
+	//! Deprecated: Sets the valid time interval
+	virtual void timeInterval (const TeTimeInterval& t) 
+	{	setTime(t);	}
+
+	//! Returns the initial time (as a string) of the valid time interval
+	virtual string getInitialDateTime(const string& mask="YYYYsMMsDDsHHsmmsSS") 
+	{	return time_.getInitialDateTime(mask);	}
+	
+	//! Returns the final time (as a string) of the valid time interval
+	virtual string getFinalDateTime(const string& mask="YYYYsMMsDDsHHsmmsSS") 
+	{	return time_.getFinalDateTime(mask);	}
+	
+};
+
+//! A spatial temporal element or object (TeSTElement) is composite of a set of spatial temporal instances related to it.  
+typedef vector<TeSTInstance>  TeSTElement;
+
+#endif 
diff --git a/src/terralib/kernel/TeSharedPtr.h b/src/terralib/kernel/TeSharedPtr.h
new file mode 100644
index 0000000..8603644
--- /dev/null
+++ b/src/terralib/kernel/TeSharedPtr.h
@@ -0,0 +1,435 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSharedPtr.h
+    \brief This file contains a class to deal with automatic dynamic memory allocation / desallocationn
+*/
+#ifndef TESHAREDPTR_H
+  #define TESHAREDPTR_H
+
+  #include "TeMutex.h"
+  #include "TeAgnostic.h"
+
+  /**
+   * @brief This is the class to deal with automatic dynamic memory
+   * allocation / desallocation.
+   * @note This is a thread-safe class.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  template< class T >
+  class TeSharedPtr {
+    public :
+      /**
+       * @brief Default Constructor( Shared ).
+       *
+       * @param pointer A pointer the the active object.
+       */
+      explicit TeSharedPtr( T* pointer = 0 );
+        
+      /**
+       * @brief Alternative Constructor.
+       *
+       * @param external External object reference.
+       * @param not_shared_flag A flag indication for a static
+       * assignment ( the pointed object will not be deleted at the
+       * this object destruction ).       
+       */
+      TeSharedPtr( const TeSharedPtr< T >& external );        
+        
+      /**
+       * @brief Alternative Constructor.
+       *
+       * @param pointer A pointer the the active object.
+       * @param not_shared_flag A flag indication for a static
+       * assignment ( the pointed object will not be deleted at the
+       * this object destruction ).
+       */
+      explicit TeSharedPtr( T* pointer,  bool not_shared_flag );        
+
+      /**
+       * @brief Default Destructor
+       */
+      ~TeSharedPtr();
+
+      /**
+       * @brief Verifies if the current pointer points to an active object.
+       *
+       * @return true if active, false if not.
+       */
+      inline bool isActive() const;
+      
+      /**
+       * @brief Verifies if the current pointer is shared.
+       *
+       * @return true if shared, false if not.
+       */
+      inline bool isShared() const;      
+
+      /**
+       * @brief Reset the active instance the the new pointer.
+       *
+       * @param pointer A pointer the the active object.
+       * @param not_shared_flag A flag indication for a static
+       * assignment ( the pointed object will not be deleted at the
+       * this object destruction ).
+       */
+      void reset( T* pointer = 0, bool not_shared_flag = false );
+
+      /**
+       * @brief Operator = overload.
+       *
+       * @param external External instance reference.
+       * @return A reference to the current pointer.
+       */
+      TeSharedPtr< T >& operator=( const TeSharedPtr< T >& external );
+
+      /**
+       * @brief Operator * overload.
+       *
+       * @return The internal instance reference.
+       */
+      inline T& operator*() const;
+
+      /**
+       * @brief Operator -> overload.
+       *
+       * @return The internal instance pointer.
+       */
+      inline T* operator->() const;
+
+      /**
+       * @brief Operator == overload.
+       *
+       * @param external The external instance reference.
+       * @return true if the current pointer and the external pointer
+       * are pointing to the same object.
+       */
+      inline bool operator==( const TeSharedPtr< T >& external ) const;
+      
+      /**
+       * @brief Operator< overload.
+       *
+       * @param external The external instance reference.
+       * @return true if the current pointer pointed address has a lower value 
+       * then the external shared pointer pointed address.
+       */
+      inline bool operator<( const TeSharedPtr< T >& external ) const;      
+
+      
+      /**
+       * @brief Operator> overload.
+       *
+       * @param external The external instance reference.
+       * @return true if the current pointer pointed address has a lower value 
+       * then the external shared pointer pointed address.
+       */
+      inline bool operator>( const TeSharedPtr< T >& external ) const;      
+
+            
+      /**
+       * @brief Operator != overload.
+       *
+       * @param external The external instance reference.
+       * @return true if the current pointer and the external pointer
+       * are not pointing to the same object.
+       */
+      inline bool operator!=( const TeSharedPtr< T >& external ) const;
+
+      /**
+       * @brief A Naked Pointer to the encapsulated object.
+       *
+       * @return The internal instance pointer.
+       */
+      inline T* nakedPointer() const;
+      
+      /**
+       * @brief Builds a non-shared pointer copy from the current instance.
+       *
+       * @return The non-shared pointer copy.
+       */
+      TeSharedPtr< T > getNonSharedCopy() const;      
+      
+      /**
+       * @brief The number of current references to the pointed object.
+       *
+       * @return The number of current references to the pointed object.
+       */
+      unsigned long int getRefCount() const;            
+
+    protected :
+    
+      /**
+       * @brief This instance locking mutex.
+       */    
+      mutable TeMutex this_lock_instance_;
+      
+      /**
+       * @brief A pointer to the shared counter locking mutex.
+       */    
+      mutable TeMutex* counter_lock_instance_ptr_;      
+
+      /**
+       * @brief A pointer to the current number of active users of this pointer.
+       */
+      mutable unsigned long int* counter_;
+
+      /**
+       * @brief A pointer to the current object encapsulated by this
+       * shared pointer.
+       */
+      mutable T* reference_;
+
+      /**
+       * @brief A flag indicating if this shared pointer was created by a
+       * dynamic assignment ( false value ) or by a static
+       * assignment( true value - the encapsulated object will not
+       * be destroyed at the end.
+       */
+      mutable bool not_shared_flag_;
+      
+      /**
+       * @brief Set all internal variables to default values.
+       *
+       */
+      void init();
+  };
+
+  
+  template< class T >
+  TeSharedPtr< T >::TeSharedPtr( T* pointer )
+  {
+    init();
+    reset( pointer, not_shared_flag_ );
+  }
+ 
+   
+  template< class T >
+  TeSharedPtr< T >::TeSharedPtr( const TeSharedPtr< T >& external )
+  {
+    init();
+    operator=( external );
+  } 
+
+    
+  template< class T >
+  TeSharedPtr< T >::TeSharedPtr( T* pointer, bool not_shared_flag )
+  {
+    init();
+    reset( pointer, not_shared_flag );
+  }  
+
+
+  template< class T >
+    TeSharedPtr< T >::~TeSharedPtr()
+  {
+    reset( 0, 0 );
+  }
+
+
+  template< class T >
+  inline bool TeSharedPtr< T >::isActive() const
+  {
+    return ( ( reference_ == 0 ) ? false : true );
+  }
+  
+  
+  template< class T >
+  inline bool TeSharedPtr< T >::isShared() const
+  {
+    return ( ! not_shared_flag_ );
+  }  
+
+
+  template< class T >
+  void TeSharedPtr< T >::reset( T* pointer, bool not_shared_flag )
+  {
+    this_lock_instance_.lock();
+    
+    /* updating the shared objects */
+    
+    if( ( reference_ != 0 ) && ( ! not_shared_flag_ ) ) {
+      counter_lock_instance_ptr_->lock();
+    
+      --(*counter_);
+      
+      /* Cleanning the shared pointed objects if necessary */
+
+      if( (*counter_) == 0 ) {
+        delete counter_;
+        delete reference_;
+        delete counter_lock_instance_ptr_;
+      } else {
+        counter_lock_instance_ptr_->unLock();
+      }
+    }
+     
+    init();
+    
+    /* Acquiring the pointed object */
+
+    if( pointer != 0 ) {
+      if( ! not_shared_flag ) {
+        counter_ = new unsigned long int;
+        (*counter_) = 1;
+        counter_lock_instance_ptr_ = new TeMutex;
+      }
+
+      reference_ = pointer;
+      not_shared_flag_ = not_shared_flag;
+    }
+    
+    this_lock_instance_.unLock();
+  }
+
+
+  template< class T >
+  TeSharedPtr< T >& TeSharedPtr< T >::operator=(
+    const TeSharedPtr< T >& external )
+  {
+    if( ( &external ) != this ) {
+      reset();
+  
+      this_lock_instance_.lock();
+      
+      if( (&external) != 0 ) {
+        external.this_lock_instance_.lock();
+      
+        if( external.isActive() ) {
+          reference_ = external.reference_;
+        
+          if( ( ! not_shared_flag_ ) && ( ! external.not_shared_flag_ ) ) {
+            
+            counter_ = external.counter_;
+            (*counter_) = (*counter_) + 1;
+            
+            counter_lock_instance_ptr_ = external.counter_lock_instance_ptr_;
+          } else {
+            not_shared_flag_ = true;
+          }
+        }
+        
+        external.this_lock_instance_.unLock();
+      }
+      
+      this_lock_instance_.unLock();
+    }
+
+    return *this;
+  }
+
+
+  template< class T >
+  inline T& TeSharedPtr< T >::operator*() const
+  {
+    TEAGN_DEBUG_CONDITION( isActive(), 
+      "Trying to use an inactive shared pointer instance" );
+
+    return *reference_;
+  }
+
+
+  template< class T >
+  inline T* TeSharedPtr< T >::operator->() const
+  {
+    TEAGN_DEBUG_CONDITION( isActive(), 
+      "Trying to use an inactive shared pointer instance" );
+    
+    return reference_;
+  }
+
+
+  template< class T >
+  inline bool TeSharedPtr< T >::operator==(
+    const TeSharedPtr< T >& external ) const
+  {
+    return ( ( reference_ == external.reference_ ) ? true : false );
+  }
+  
+  
+  template< class T >
+  inline bool TeSharedPtr< T >::operator<(
+    const TeSharedPtr< T >& external ) const
+  {
+    return ( ( reference_ < external.reference_ ) ? true : false );
+  }  
+
+
+  template< class T >
+  inline bool TeSharedPtr< T >::operator>(
+    const TeSharedPtr< T >& external ) const
+  {
+    return ( ( reference_ > external.reference_ ) ? true : false );
+  }  
+    
+
+  template< class T >
+  inline bool TeSharedPtr< T >::operator!=(
+    const TeSharedPtr< T >& external ) const
+  {
+    return ( ( reference_ == external.reference_ ) ? false : true );
+  }
+
+
+  template< class T >
+  inline T* TeSharedPtr< T >::nakedPointer() const
+  {
+    return reference_;
+  }
+  
+  template< class T >
+  TeSharedPtr< T > TeSharedPtr< T >::getNonSharedCopy() const
+  {
+    TeSharedPtr< T > outptr;
+    outptr.reset( reference_, true );
+    return outptr;
+  }
+  
+  template< class T >
+  unsigned long int TeSharedPtr< T >::getRefCount() const
+  {
+    if( reference_ ) {
+      if( counter_) {
+        return (*counter_);
+      } else {
+        return 1;
+      }
+    } else {
+      return 0;
+    }
+  }  
+  
+  template< class T >
+  void TeSharedPtr< T >::init()
+  {
+    counter_ = 0;
+    reference_ = 0;
+    counter_lock_instance_ptr_ = 0;
+    not_shared_flag_ = false;  
+  }  
+
+/** @example TeSharedPtr_test.cpp
+ *    Shows how to use this class.
+ */  
+  
+#endif
+
diff --git a/src/terralib/kernel/TeSingleton.h b/src/terralib/kernel/TeSingleton.h
new file mode 100644
index 0000000..f7190dd
--- /dev/null
+++ b/src/terralib/kernel/TeSingleton.h
@@ -0,0 +1,67 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSingleton.h
+    \brief This file contains a template for the "Singleton" pattern.
+*/
+#ifndef  __TERRALIB_INTERNAL_SINGLETON_H
+#define  __TERRALIB_INTERNAL_SINGLETON_H
+
+//!  Provides a template support for the "Singleton" pattern
+/*!
+	\note See "Design Patterns" book, page 127
+*/
+
+#include "TeDefines.h"
+
+template <class T>
+class TeSingleton {
+public:
+
+	static T& instance ()
+	{ 
+		static 	T	instance_;
+		return		instance_;
+	}
+	
+// -- Destructor
+
+	virtual ~TeSingleton() {}  // base class
+
+protected:
+
+// -- Contructors
+
+	TeSingleton() {}
+
+
+private:
+
+// No copy allowed
+
+	TeSingleton(const TeSingleton&);
+	TeSingleton& operator=(const TeSingleton&){return *this;}
+
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeSlice.h b/src/terralib/kernel/TeSlice.h
new file mode 100644
index 0000000..6065fb4
--- /dev/null
+++ b/src/terralib/kernel/TeSlice.h
@@ -0,0 +1,77 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSlice.h
+    \brief This file provides support for a slice structure
+*/
+#ifndef  __TERRALIB_INTERNAL_SLICE_H
+#define  __TERRALIB_INTERNAL_SLICE_H
+
+#include "TeUtils.h"
+
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+using namespace std;
+
+/*! 
+A Slice is a structure that defines an interval of values and associates a
+number of objects that have a certain property, or attribute, whithin this
+interval.
+*/ 
+class TL_DLL TeSlice
+{
+public:
+	int			count_;			//! number of objects container in the interval
+	string		from_;			//! interval lower value 
+	string		to_;			//! interval upper value
+	
+	//! Constructor
+	TeSlice () : count_(0),from_(""),to_("") {}
+
+	//! Constructor
+	TeSlice(const string& from, const string& to, int count=0) :
+     count_(count),
+		from_(from),
+		to_(to) {}
+
+	TeSlice(const TeSlice& slice)
+	{
+		from_ = slice.from_;
+		to_ = slice.to_;
+		count_ = slice.count_;
+	}
+
+	TeSlice& operator=(const TeSlice& slice)
+	{
+		from_ = slice.from_;
+		to_ = slice.to_;
+		count_ = slice.count_;
+		return *this;
+	}
+};
+
+//! A vector of slices
+typedef vector<TeSlice> TeSliceVector;
+#endif
+
diff --git a/src/terralib/kernel/TeSpatialOperations.cpp b/src/terralib/kernel/TeSpatialOperations.cpp
new file mode 100644
index 0000000..d414e43
--- /dev/null
+++ b/src/terralib/kernel/TeSpatialOperations.cpp
@@ -0,0 +1,1660 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeSpatialOperations.h"
+#include "TeGeometryAlgorithms.h"
+#include "TeRasterRemap.h"
+#include "TeStatistics.h"
+#include "TeOverlay.h"
+#include "TeBufferRegion.h"
+#include "TeProgress.h"
+#include "TeVectorRemap.h"
+
+#include <algorithm>
+
+
+TeProjection*
+getProjectionFromGeomTable(const string& geomTable, TeDatabase* db)
+{
+	TeLayerMap layerMap = db->layerMap();
+	TeLayerMap::iterator it = layerMap.begin();
+	while(it!=layerMap.end())
+	{
+		TeLayer* layer = it->second;
+		TeRepresPointerVector::iterator itRep = layer->vectRepres().begin();
+		while(itRep!=layer->vectRepres().end())
+		{
+			if(TeConvertToUpperCase((*itRep)->tableName_)==TeConvertToUpperCase(geomTable))
+				return layer->projection();
+			++itRep;
+		}
+		++it;
+	}
+	return 0; 
+}
+
+
+// Return if exist or not a totpological relation between two geometries
+// Use the TerraLib topological functions
+bool TeTopologicalRelation(const TePolygon* geom1, const TePolygon* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)  
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2);
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2);
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom1, *geom2);
+		break;
+
+		case TeOVERLAPS:
+			result = TeOverlaps(*geom1, *geom2);
+		break;
+
+		case TeCOVERS:
+			result = TeCovers(*geom1, *geom2);
+		break;
+
+		case TeCOVEREDBY:
+			result = TeCoveredBy(*geom1, *geom2);
+		break;
+		
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2);
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom1, *geom2);
+		break;
+		
+		case TeEQUALS:
+			result = TeEquals(*geom1, *geom2);
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY) :
+			result = TeWithinOrCoveredByOrEquals(*geom1, *geom2);
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = ( (TeOverlaps(*geom1, *geom2)) || (TeWithinOrCoveredByOrEquals(*geom1, *geom2)));
+		break;
+	}
+	return result;
+}
+
+
+bool TeTopologicalRelation(const TePolygon* geom1, const TeLine2D* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom2, *geom1); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom2, *geom1); 
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom2, *geom1);  
+		break;
+
+		case TeCOVERS:
+			result = TeCovers(*geom1, *geom2);  
+		break;
+
+		case TeCOVEREDBY:
+			result = TeCoveredBy(*geom2, *geom1);  
+		break;
+		
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom2, *geom1); 
+		break;
+		
+		case TeCROSSES:
+			result = TeCrosses(*geom2, *geom1); 
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY):
+			result = TeWithinOrCoveredByOrEquals(*geom2, *geom1);
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = ( (TeCrosses(*geom2, *geom1)) || (TeWithinOrCoveredByOrEquals(*geom2, *geom1)));
+		break;
+	}
+	return result;
+}
+
+
+bool TeTopologicalRelation(const TePolygon* geom1, const TePoint* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom2, *geom1); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom2, *geom1); 
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom2, *geom1);  
+		break;
+
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom2, *geom1); 
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY):
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = TeWithinOrCoveredByOrEquals((*geom2).location(), *geom1);
+		break;
+	}
+	return result;
+}
+
+bool TeTopologicalRelation(const TeLine2D* geom1, const TeLine2D* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)  
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2); 
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom1, *geom2); 
+		break;
+
+		case TeOVERLAPS:
+			result = TeOverlaps(*geom1, *geom2); 
+		break;
+
+		case TeCOVERS:
+			result = TeCovers(*geom1, *geom2); 
+		break;
+
+		case TeCOVEREDBY:
+			result = TeCoveredBy(*geom1, *geom2); 
+		break;
+		
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom1, *geom2); 
+		break;
+		
+		case TeEQUALS:
+			result = TeEquals(*geom1, *geom2); 
+		break;
+
+		case TeCROSSES:
+			result = TeCrosses(*geom1, *geom2); 
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = ( (TeCrosses(*geom1, *geom2)) || (TeWithinOrCoveredByOrEquals(*geom1, *geom2)));
+		break;
+	}
+	return result;
+}
+
+bool TeTopologicalRelation(const TeLine2D* geom1, const TePoint* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)  
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom2, *geom1); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom2, *geom1); 
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom2, *geom1); 
+		break;
+
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom2, *geom1); 
+		break;
+		
+		case (TeWITHIN | TeCOVEREDBY):
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = TeWithinOrCoveredByOrEquals((*geom2).location(), *geom1);
+		break;
+	}
+	return result;
+}
+
+bool TeTopologicalRelation(const TePoint* geom1, const TePoint* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)  
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2); 
+		break;
+		
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom1, *geom2); 
+		break;
+		
+		case TeEQUALS:
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = TeEquals(*geom1, *geom2); 
+		break;
+	}
+	return result;
+}
+
+bool TeTopologicalRelation(const TeCell* geom1, const TeCell* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)  
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2);
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2);
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom1, *geom2);
+		break;
+
+		case TeOVERLAPS:
+			result = TeOverlaps(*geom1, *geom2);
+		break;
+
+		case TeCOVERS:
+			result = TeCovers(*geom1, *geom2);
+		break;
+
+		case TeCOVEREDBY:
+			result = TeCoveredBy(*geom1, *geom2);
+		break;
+		
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2);
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom1, *geom2);
+		break;
+		
+		case TeEQUALS:
+			result = TeEquals(*geom1, *geom2);
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY):
+			result = TeWithinOrCoveredByOrEquals((*geom1).box(), (*geom2).box());
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = ( (TeOverlaps(*geom1, *geom2)) || (TeWithinOrCoveredByOrEquals((*geom1).box(), (*geom2).box())));
+		break;
+	}
+	return result;
+}
+
+bool TeTopologicalRelation(const TeCell* geom1, const TePolygon* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)  
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2);
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2);
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom1, *geom2);
+		break;
+
+		case TeOVERLAPS:
+			result = TeOverlaps(*geom1, *geom2);
+		break;
+
+		case TeCOVERS:
+			result = TeCovers(*geom1, *geom2);
+		break;
+
+		case TeCOVEREDBY:
+			result = TeCoveredBy(TeMakePolygon((*geom1).box()), *geom2);
+		break;
+		
+		case TeCONTAINS:
+			result = TeWithin(*geom2, TeMakePolygon((*geom1).box()));
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom1, *geom2);
+		break;
+		
+		case TeEQUALS:
+			result = TeEquals(*geom1, *geom2);
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY):
+			result = TeWithinOrCoveredByOrEquals(TeMakePolygon((*geom1).box()), *geom2);
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = ( (TeOverlaps(*geom1, *geom2)) || (TeWithinOrCoveredByOrEquals(TeMakePolygon((*geom1).box()) , *geom2)));
+		break;
+	}
+	return result;
+}
+
+bool TeTopologicalRelation(const TeCell* geom1, const TeLine2D* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2); 
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom2, *geom1);  
+		break;
+
+		case TeCOVERS:
+			result = TeCovers(*geom1, *geom2);  
+		break;
+
+		case TeCOVEREDBY:
+			result = TeCoveredBy(*geom2, *geom1);  
+		break;
+		
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom2, *geom1); 
+		break;
+		
+		case TeCROSSES:
+			result = TeCrosses(*geom2, *geom1); 
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY):
+			result = TeWithinOrCoveredByOrEquals(*geom2, TeMakePolygon((*geom1).box()));
+		break;
+
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = ( (TeCrosses(*geom2, *geom1)) || (TeWithinOrCoveredByOrEquals(*geom2, TeMakePolygon((*geom1).box()))));
+		break;
+	}
+	return result;
+
+}
+
+bool TeTopologicalRelation(const TeCell* geom1, const TePoint* geom2, int relation)
+{
+	bool result = false;
+	switch (relation)
+	{		
+		case TeDISJOINT:
+			result = TeDisjoint(*geom1, *geom2); 
+		break;
+
+		case TeINTERSECTS:
+			result = TeIntersects(*geom1, *geom2); 
+		break;
+		
+		case TeTOUCHES:
+			result = TeTouches(*geom2, *geom1);  
+		break;
+
+		case TeCONTAINS:
+			result = TeContains(*geom1, *geom2); 
+		break;
+		
+		case TeWITHIN:
+			result = TeWithin(*geom2, *geom1); 
+		break;
+
+		case (TeWITHIN & TeCOVEREDBY):
+		case (TeWITHIN | TeCOVEREDBY | TeOVERLAPS | TeCROSSES):
+			result = TeWithinOrCoveredByOrEquals((*geom2).location(), TeMakePolygon((*geom1).box()));
+		break;
+	}
+	return result;
+
+}
+
+
+// Return a string with the identifications of the selected geometries 
+string 
+getStringIds(TeKeys& IdsIn)
+{
+	string Ids = "";
+	int cont = 0;
+	
+	TeKeys::iterator itIdIn = IdsIn.begin();
+	while (itIdIn != IdsIn.end())
+	{
+		if(cont)
+			Ids += ","; 
+		Ids += "'" + (*itIdIn) + "'";
+		itIdIn++;
+		cont++;
+	}
+
+	return Ids;
+}
+
+// fill the geometries vector from a portal
+string
+mountSelect(string geomTable, string colTable, TeGeomRep rep, TeBox& box, int relate, TeDatabasePortal *portal)
+{
+	
+	string sql = "SELECT * FROM "+ geomTable;
+	
+	if(!colTable.empty())
+		sql +=", "+ colTable +" WHERE c_object_id = object_id ";
+		
+	//If not disjoint
+	if(box.isValid() && (relate!=TeDISJOINT))
+	{
+		if(!colTable.empty())
+			sql += " AND ";
+		else
+			sql += " WHERE ";
+
+		sql += portal->getDatabase()->getSQLBoxWhere (box, rep);
+	}
+	return sql;
+}
+
+//fill the result vector of the geometries identificators  
+bool
+fillSelectedGeomVector(TeGeomRep actRep, TeSelectedGeom& vetGeom, TeDatabasePortal *portal, TeProjection* projAct=0, TeProjection* projVis=0)
+{
+	bool flag = true;
+	bool remap = false;
+
+	if((projAct!=0) && (projVis!=0) && (projAct!=projVis))
+		remap = true;
+	
+	try
+	{
+		do
+		{
+			if(actRep == TePOLYGONS)
+			{
+				TePolygon   poly, *pol;
+				flag = portal->fetchGeometry(poly); 
+				pol = new TePolygon;
+				if(remap)
+				{
+					TePolygon pout;
+					TeVectorRemap (poly, projAct, pout, projVis);
+					*pol = pout;
+				}
+				else
+					*pol = poly;
+				vetGeom.push_back(pol);
+			}
+			else if(actRep == TeLINES)
+			{
+				TeLine2D	line, *lin;
+				flag = portal->fetchGeometry(line); 
+				lin = new TeLine2D();
+				if(remap)
+				{
+					TeLine2D gout;
+					TeVectorRemap (line, projAct, gout, projVis);
+					*lin = gout;
+				}
+				else
+					*lin = line;
+				vetGeom.push_back(lin);
+			}
+			else if(actRep == TePOINTS)
+			{
+				TePoint		point, *pnt;
+				flag = portal->fetchGeometry(point); 
+				pnt = new TePoint();
+				if(remap)
+				{
+					TePoint gout;
+					TeVectorRemap (point, projAct, gout, projVis);
+					*pnt = gout;
+				}
+				else
+					*pnt = point;
+				vetGeom.push_back(pnt);
+			}
+			else if(actRep == TeCELLS)
+			{
+				TeCell		cell, *cll;
+				flag = portal->fetchGeometry(cell); 
+				cll = new TeCell();
+				if(remap)
+				{
+					TeCell gout;
+					TeVectorRemap (cell, projAct, gout, projVis);
+					*cll = gout;
+				}
+				else
+					*cll = cell;
+				vetGeom.push_back(cll);
+			}
+		} while (flag);
+	}
+	catch(...)
+	{
+		TeSelectedGeom::iterator it;
+		for(it = vetGeom.begin(); it != vetGeom.end(); it++)
+			delete (*it);
+		return false;
+	}
+
+	return true;
+}
+
+//geom: selected geometries
+//obj: portal geometries
+//basic idea: obj "relate" geom
+bool
+fillResultIdsVector(TeGeometry *geom, TeDatabasePortal *portal, TeGeomRep portalRep, int relate, TeKeys& resultIds)
+{
+	bool flag = false;
+	bool result = false;
+	TeGeomRep geomRep = geom->elemType();
+	bool isSet = false;
+	int setSize = 1;
+
+	if ( (dynamic_cast<TePolygonSet*> (geom)) ||
+		 (dynamic_cast<TeLineSet*> (geom)) ||
+		 (dynamic_cast<TePointSet*> (geom)) ||
+		 (dynamic_cast<TeCellSet*> (geom)) )
+	{
+		isSet = true;
+		setSize = geom->size();
+	}
+
+	try
+	{
+		do
+		{
+			TeGeometry* obj = 0;
+			if(portalRep == TePOLYGONS)
+			{
+				TePolygon   poly, *pol;
+				flag = portal->fetchGeometry (poly);
+				pol = new TePolygon();
+				*pol = poly;
+				obj = pol;
+			}
+			else if(portalRep == TeLINES)
+			{
+				TeLine2D	line, *lin;
+				flag = portal->fetchGeometry (line);
+				lin = new TeLine2D();
+				*lin = line;
+				obj = lin;
+			}
+			else if(portalRep == TePOINTS)
+			{
+				TePoint		point, *pnt;
+				flag = portal->fetchGeometry (point);
+				pnt = new TePoint();
+				*pnt = point;
+				obj = pnt;
+			}
+			else if(portalRep == TeCELLS)
+			{
+				TeCell		cell, *cll;
+				flag = portal->fetchGeometry (cell);
+				cll = new TeCell();
+				*cll = cell;
+				obj = cll;
+			}
+
+			result = false;
+
+			//for each geometry 	
+			for(int i=0; i<setSize; ++i)
+			{
+				TeGeometry* geomTemp = 0;
+				if(isSet)
+				{
+					if(geomRep==TePOLYGONS)
+						geomTemp = &(((TePolygonSet*)geom)->operator[](i));
+					else if (geomRep==TeLINES)
+						geomTemp = &(((TeLineSet*)geom)->operator[](i));
+					else if (geomRep==TePOINTS)
+						geomTemp = &(((TePointSet*)geom)->operator[](i));
+					else if (geomRep==TeCELLS)
+						geomTemp = &(((TeCellSet*)geom)->operator[](i));
+				}
+				else
+					geomTemp = geom;
+				
+				switch (geomRep | portalRep)   //geom: selected and obj: portal
+				{
+						
+					case 1: //polygon with polygon
+						result = TeTopologicalRelation((TePolygon*)obj, (TePolygon*)geomTemp, relate);
+					break;
+
+					case 2://line with line 
+						result = TeTopologicalRelation((TeLine2D*)obj, (TeLine2D*)geomTemp, relate);
+					break;
+			
+					case 3://polygon with line
+						if(geomRep == TePOLYGONS)
+							result = TeTopologicalRelation((TePolygon*)geomTemp, (TeLine2D*)obj, relate);
+						else
+							result = TeTopologicalRelation((TePolygon*)obj, (TeLine2D*)geomTemp, relate);
+					break;
+				
+					case 4://point with point
+						result = TeTopologicalRelation((TePoint*)obj, (TePoint*)geomTemp, relate);
+					break;
+				
+					case 5://polygon with point
+						if(geomRep == TePOLYGONS)
+							result = TeTopologicalRelation((TePolygon*)geomTemp, (TePoint*)obj, relate);
+						else
+							result = TeTopologicalRelation((TePolygon*)obj, (TePoint*)geomTemp, relate);
+					break;
+
+					case 6://line with point 
+						if(geomRep == TeLINES)
+							result = TeTopologicalRelation((TeLine2D*)geomTemp, (TePoint*)obj, relate);
+						else
+							result = TeTopologicalRelation((TeLine2D*)obj, (TePoint*)geomTemp, relate);
+					break;
+					
+					case 256://cell with cell 
+						result = TeTopologicalRelation((TeCell*)obj, (TeCell*)geomTemp, relate);
+					break;
+
+					case 257://cell with polygon 
+						if(geomRep == TePOLYGONS)
+							result = TeTopologicalRelation((TeCell*)obj, (TePolygon*)geomTemp, relate);
+						else
+							result = TeTopologicalRelation((TeCell*)geomTemp, (TePolygon*)obj, relate);
+					break;
+					
+					case 258://cell with line 
+						if(geomRep == TeLINES)
+							result = TeTopologicalRelation((TeCell*)obj,  (TeLine2D*)geomTemp, relate);
+						else
+							result = TeTopologicalRelation((TeCell*)geomTemp, (TeLine2D*)obj, relate);
+					break;
+
+					case 260://cell with point
+						if(geomRep == TeCELLS)
+							result = TeTopologicalRelation((TeCell*)geomTemp, (TePoint*)obj, relate);
+						else
+							result = TeTopologicalRelation((TeCell*)obj,  (TePoint*)geomTemp, relate);
+					break;
+				}
+						
+				if(result)
+				{
+					string objId = obj->objectId();
+					resultIds.push_back(objId);
+				}
+			}//for
+
+			delete obj;
+		} while (flag); //fetchrow
+	}
+	catch(...)
+	{
+		return false;
+	}
+	return true;
+}
+
+
+bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   TeDatabasePortal *portal, int relation, const string& actColTable)
+{
+	TeKeys  resultIds;
+
+	if(!TeTopologicalRelation(actGeomTable, actRep, actIdsIn, resultIds, portal->getDatabase(), relation, actColTable))
+		return false;
+
+	string Ids = getStringIds(resultIds);
+	
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	portal->freeResult();
+
+	if(!portal->query(sql) || !portal->fetchRow())
+		return false;
+	
+	return true;
+}
+
+bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   const string& visGeomTable,  TeGeomRep visRep, TeDatabasePortal *portal, 
+						   int relation, const string& visColTable)
+{
+	TeKeys  resultIds;
+
+	if(!TeTopologicalRelation(actGeomTable, actRep, actIdsIn, visGeomTable, visRep, resultIds, portal->getDatabase(), relation, visColTable))
+		return false;
+	
+	string Ids = getStringIds(resultIds);
+
+	portal->freeResult ();
+
+	string sql = "SELECT * FROM " + visGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+	if(visRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+
+	if(!portal->query(sql) || !portal->fetchRow())
+		return false;
+		
+	return true;
+}
+
+bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, 
+						   TeDatabasePortal *portal, int relation, const string& actCollTable)
+{
+	
+	TeKeys	resultIds;
+	
+	if(!TeTopologicalRelation(actGeomTable, actRep, geom, resultIds, portal->getDatabase(), relation, actCollTable))
+		return false;
+	
+	string Ids = getStringIds(resultIds);
+
+	portal->freeResult();
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+
+	if(!portal->query(sql) || !portal->fetchRow())
+		return false;
+	
+	return true;
+}
+	
+bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   TeKeys& actIdsOut, TeDatabase* db, int relation, const string& actCollTable)
+{
+	TeSelectedGeom	vetGeom;
+			
+	string Ids = getStringIds(actIdsIn);
+
+	TeDatabasePortal* portal = db->getPortal();
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	
+	//order by clause
+	string sqlOrderBy = " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sqlOrderBy += ", parent_id ASC, num_holes DESC ";
+
+	sql += sqlOrderBy;
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	if(!fillSelectedGeomVector(actRep,vetGeom,portal))
+	{
+		delete portal;
+		return false; 
+	}
+
+	//iterators
+	TeSelectedGeom::iterator it;
+	actIdsOut.clear();
+	double prec = TePrecision::instance().precision();
+	
+	for (it = vetGeom.begin(); it != vetGeom.end(); it++)
+	{
+		portal->freeResult();
+		TeBox box = (**it).box();
+
+		TeBox temp (box.x1()-prec, box.y1()-prec, box.x2()+prec, box.y2()+prec); 
+		
+		sql = mountSelect(actGeomTable, actCollTable, actRep, temp, relation, portal);
+		if(relation != TeEQUALS)
+			sql += " AND object_id NOT IN (" + Ids + ")";
+		sql += sqlOrderBy;
+
+		if(!portal->query(sql)) 
+		{
+			delete portal;
+			return false;
+		}
+
+		if(!portal->fetchRow())
+			continue;
+
+		fillResultIdsVector((*it), portal, actRep, relation, actIdsOut);
+	
+	} 
+		
+	sort(actIdsOut.begin(), actIdsOut.end());
+	unique(actIdsOut.begin(), actIdsOut.end());
+
+	delete portal;
+	
+	for (it = vetGeom.begin(); it != vetGeom.end(); it++)
+		delete (*it);
+
+	return true;
+}
+
+bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   const string& visGeomTable, TeGeomRep visRep, TeKeys& visIdsOut, 
+						   TeDatabase* db, int relation, const string& visCollTable, TeDatabase* dbVis)
+{
+	TeSelectedGeom	vetGeom;
+			
+	string Ids = getStringIds(actIdsIn);
+	if(dbVis == 0)
+		dbVis = db;
+
+	//verify projection
+	TeProjection* projAct = getProjectionFromGeomTable(actGeomTable, db);
+	TeProjection* projVis = getProjectionFromGeomTable(visGeomTable, dbVis);
+	
+	TeDatabasePortal* portal = db->getPortal();
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	if(!portal->query(sql)|| !portal->fetchRow ())
+	{
+		delete portal;
+		return false;
+	}
+	
+	if(!fillSelectedGeomVector(actRep,vetGeom,portal,projAct, projVis))
+	{
+		delete portal;
+		return false; 
+	}
+
+	if(db != dbVis)
+	{
+		delete portal;
+		portal = dbVis->getPortal();
+	}
+
+	//iterators
+	TeSelectedGeom::iterator it;
+	visIdsOut.clear();
+	double prec = TePrecision::instance().precision();
+
+	for (it = vetGeom.begin(); it != vetGeom.end(); it++)
+	{
+		portal->freeResult();
+		TeBox box = (**it).box();
+		
+		TeBox temp (box.x1()-prec, box.y1()-prec, box.x2()+prec, box.y2()+prec); 
+		
+		sql = mountSelect(visGeomTable, visCollTable, visRep, temp, relation, portal);
+		sql += " ORDER BY object_id ASC ";
+		if(visRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+			sql += ", parent_id ASC, num_holes DESC ";
+
+		if(!portal->query(sql)) 
+		{
+			delete portal;
+			return false;
+		}
+
+		if(!portal->fetchRow())
+			continue;
+	
+		fillResultIdsVector((*it), portal, visRep, relation, visIdsOut);
+
+	}
+						
+	delete portal;
+	
+	sort(visIdsOut.begin(), visIdsOut.end());
+	unique(visIdsOut.begin(), visIdsOut.end());
+
+	for (it = vetGeom.begin(); it != vetGeom.end(); it++)
+		delete (*it);
+
+	return true;
+}
+
+bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, 
+						   TeKeys& actIdsOut, TeDatabase* db, int relation, const string& actCollTable)
+{
+	TeDatabasePortal* portal = db->getPortal();
+	TeBox box = geom->box();
+
+	double prec = TePrecision::instance().precision();
+	TeBox temp (box.x1()-prec, box.y1()-prec, box.x2()+prec, box.y2()+prec); 
+
+	string sql = mountSelect(actGeomTable, actCollTable, actRep, temp, relation, portal);
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	actIdsOut.clear();
+	
+	fillResultIdsVector(geom, portal, actRep, relation, actIdsOut);
+
+	delete portal;
+	
+	sort(actIdsOut.begin(), actIdsOut.end());
+	unique(actIdsOut.begin(), actIdsOut.end());
+
+	return true;
+}
+
+bool TeGetWithinDistance(const string& actGeomTable, TeGeomRep actRep, const TeCoord2D& point, TeKeysToDist& IdsDistOut,
+						 TeDatabase* db, const double& max_dist, const string& actCollTable)
+{
+	if(!db)
+		return false;
+	
+	TeDatabasePortal* portal = db->getPortal();
+	if(!portal)
+		return false;
+
+	TeBox box (point.x()-max_dist, point.y()-max_dist,point.x()+max_dist, point.y()+max_dist); 
+
+	string sql = mountSelect(actGeomTable, actCollTable, actRep, box, TeWITHIN, portal);
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+
+	if(!portal->query(sql)) 
+	{
+		delete portal;
+		return false;
+	}
+
+	if(!portal->fetchRow())
+	{
+		delete portal;
+		return true;
+	}
+
+	bool flag = true;
+	do
+	{
+		TeCoord2D centroid2;
+		string objId;
+		if(actRep == TePOLYGONS)
+		{
+			TePolygon   poly;
+			flag = portal->fetchGeometry (poly);
+			objId = poly.objectId ();
+			centroid2 = TeFindCentroid(poly);
+		}
+		else if(actRep == TeLINES)
+		{
+			TeLine2D	line;
+			flag = portal->fetchGeometry (line);
+			objId = line.objectId ();
+			centroid2 = TeFindCentroid(line);
+		}
+		else if(actRep == TePOINTS)
+		{
+			TePoint		point;
+			flag = portal->fetchGeometry (point);
+			objId = point.objectId ();
+			centroid2 = TeFindCentroid(point);
+		}
+		else if(actRep == TeCELLS)
+		{
+			TeCell		cell;
+			flag = portal->fetchGeometry (cell);
+			objId = cell.objectId ();
+			centroid2 = TeFindCentroid(cell);
+		}
+		
+		double dist = TeDistance(point, centroid2);
+		if(dist<=max_dist)
+			IdsDistOut[objId] = dist;
+
+	} while (flag); //fetchrow
+	
+	//sort(IdsDistOut.begin(), IdsDistOut.end());
+
+	delete portal;
+	return true;
+}
+
+bool TeGetArea(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeDatabase* db, double& area)
+{
+	if(actRep != TePOLYGONS && actRep != TeCELLS )
+		return false;
+
+	string Ids = getStringIds(actIdsIn);
+	
+	TeDatabasePortal* portal = db->getPortal();
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+
+	if((actRep == TePOLYGONS) && (portal->getDatabase()->dbmsName() != "PostGIS"))
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = false;
+	double sumArea = 0.;
+	do
+	{
+		if(actRep == TePOLYGONS)
+		{
+			TePolygon poly;
+			flag = portal->fetchGeometry(poly);
+			sumArea+= TeGeometryArea(poly);
+		}
+		else if(actRep == TeCELLS)
+		{
+			TeCell cell;
+			flag = portal->fetchGeometry(cell);
+			sumArea+= TeGeometryArea(cell.box());
+		}
+	}while (flag);
+	
+	area = sumArea;
+	delete portal;
+	return true;
+}
+
+
+bool TeGetLength(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeDatabase* db, double& length)
+{
+	if((actRep != TePOLYGONS) && (actRep != TeLINES) && (actRep != TeCELLS) )
+		return false;
+
+	string Ids = getStringIds(actIdsIn);
+	
+	TeDatabasePortal* portal = db->getPortal();
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+
+	if((actRep == TePOLYGONS) && (portal->getDatabase()->dbmsName() != "PostGIS"))
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = false;
+	double sumLen = 0.;
+	do
+	{
+		if(actRep == TePOLYGONS)
+		{
+			TePolygon p;
+			flag = portal->fetchGeometry(p);
+			
+			for(unsigned int i=0; i<p.size(); i++)
+				sumLen += TeLength(p[i]);
+		}
+		else if (actRep == TeLINES)
+		{
+			TeLine2D l;
+			flag = portal->fetchGeometry(l);
+			sumLen += TeLength(l);
+		}
+		else if (actRep == TeCELLS)
+		{
+			TeCell c;
+			flag = portal->fetchGeometry(c);
+
+			TePolygon p = TeMakePolygon(c.box());
+			sumLen += TeLength(p[0]);
+		}
+		
+	}while (flag);
+	
+	length = sumLen;
+	delete portal;
+	return true;
+}
+
+
+bool TeGetDistance(const string& actGeomTable, TeGeomRep actRep, TeKeys& IdsIn, TeDatabase* db, double& distance)
+{
+	string Ids = getStringIds(IdsIn);
+	
+	TeDatabasePortal* portal = db->getPortal();
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN (" + Ids + ")";
+	sql += " ORDER BY object_id ASC ";
+
+	if((actRep == TePOLYGONS) && (portal->getDatabase()->dbmsName() != "PostGIS"))
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;  
+	}
+	
+	bool flag = false;
+	string lastObjId ="";
+	TeCoord2D coord1, coord2; 
+	int step = 0;
+	do
+	{
+		TeCoord2D coord;
+		string objId;
+		
+		if(actRep == TePOLYGONS)
+		{
+			TePolygon p;
+			flag = portal->fetchGeometry(p);
+			objId = p.objectId();
+			if(lastObjId==objId)
+				continue;
+			coord = TeFindCentroid(p);
+		}
+		else if (actRep == TeLINES)
+		{
+			TeLine2D l;
+			flag = portal->fetchGeometry(l);
+			objId = l.objectId ();
+			if(lastObjId==objId)
+				continue;
+			coord = TeFindCentroid(l);
+		}
+		else if (actRep == TePOINTS)
+		{
+			TePoint p;
+			flag = portal->fetchGeometry(p);
+			coord = p.location();
+		}
+		else if (actRep == TeCELLS)
+		{
+			TeCell c;
+			flag = portal->fetchGeometry(c);
+			objId = c.objectId ();
+			if(lastObjId==objId)
+				continue;
+			coord = TeFindCentroid(c);
+		}
+		
+		if(step==0)
+			coord1 = coord;
+		else
+			coord2 = coord;
+
+		lastObjId = objId;
+		++step;
+
+	}while (flag);
+	
+	distance = TeDistance(coord1, coord2);
+	delete portal;
+	return true;
+}
+
+bool TeGetConvexHull(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeDatabase* db, TePolygonSet& convexHullSet)
+{
+	if(actRep != TePOLYGONS)
+		return false;
+
+	TeDatabasePortal* portal = db->getPortal();
+	string Ids = getStringIds(actIds);
+
+	string sql = "SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN ("+ Ids +")";
+	sql += " ORDER BY object_id ASC ";
+
+	if(portal->getDatabase()->dbmsName() != "PostGIS")
+		sql += ", parent_id ASC, num_holes DESC ";
+		
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	do
+	{
+		TePolygon   poly, result;
+		flag = portal->fetchGeometry(poly);
+		TePolygon pol = TeConvexHull(poly);
+		result.add(pol[0]);
+		convexHullSet.add(result);
+	} while (flag);
+	
+	delete portal;
+	return true;
+}
+
+bool TeGetCentroid(const string& actGeomTable, TeGeomRep actRep, TeDatabase* db, TePointSet& centroidSet, TeKeys& actIds, const string& actCollTable)
+{
+	TeDatabasePortal* portal = db->getPortal();
+	string Ids = getStringIds(actIds);
+
+	string select = " SELECT * "; 
+	string from  =  " FROM " + actGeomTable;
+	string where =  " WHERE 1=1 ";
+
+	if(!actCollTable.empty())
+	{
+		select += ", "+ actCollTable;
+		where += " AND object_id = c_object_id ";
+	}
+
+	//if empty it calculates the centroids to all geometries 
+	if(!Ids.empty())
+		where += " AND object_id IN ("+ Ids +")";
+			
+	string orderBy = " ORDER BY object_id ASC ";
+	
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")
+		orderBy += ", parent_id ASC, num_holes DESC ";
+	
+	// ---- progress bar 
+	int numSteps = 0;
+	string sqlProg = " SELECT COUNT(*) "+ from + where; 
+	if(portal->query(sqlProg) && portal->fetchRow())
+		numSteps = portal->getInt(0);
+	
+	portal->freeResult();
+
+	if(TeProgress::instance())
+		TeProgress::instance()->setTotalSteps(numSteps);
+	//------
+	
+	string sql = select + from + where + orderBy;
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	string lastObjId ="";
+	int step = 0;
+	do
+	{
+		TeCoord2D coord;
+		string objId;
+		
+		if(actRep == TePOLYGONS)
+		{
+			TePolygon p;
+			flag = portal->fetchGeometry(p);
+			objId = p.objectId();
+			if(lastObjId==objId)
+				continue;
+			coord = TeFindCentroid(p);
+		}
+		else if (actRep == TeLINES)
+		{
+			TeLine2D l;
+			flag = portal->fetchGeometry(l);
+			objId = l.objectId ();
+			if(lastObjId==objId)
+				continue;
+			coord = TeFindCentroid(l);
+		}
+		else if (actRep == TeCELLS)
+		{
+			TeCell c;
+			flag = portal->fetchGeometry(c);
+			objId = c.objectId ();
+			if(lastObjId==objId)
+				continue;
+			coord = TeFindCentroid(c);
+		}
+		
+		lastObjId = objId;
+		TePoint point(coord);
+		point.objectId (objId);
+		centroidSet.add(point);
+
+		if(TeProgress::instance())
+		{
+			if (TeProgress::instance()->wasCancelled())
+			{
+				TeProgress::instance()->reset();
+				return false;
+			}
+			else
+				TeProgress::instance()->setProgress(step);
+		}	
+		++step;
+
+	} while (flag);
+	
+	if (TeProgress::instance())
+		TeProgress::instance()->reset();
+
+	delete portal;
+	return true;
+}
+
+
+bool TeGetBuffer(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeDatabase* db, TePolygonSet& bufferSet, double dist)
+{
+	
+	if(actIds.empty())
+		return false;
+	
+	string Ids = getStringIds(actIds);
+
+	TeDatabasePortal* portal = db->getPortal();
+	if(!portal)
+		return false;
+	
+	string sql = " SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN ("+ Ids +")";
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+	
+	bool flag = true;
+	bool res = true;
+	do
+	{
+		TePolygonSet polSet;
+
+		if(actRep == TePOINTS)
+		{
+			TePoint p;
+			TePolygon pol;
+			flag = portal->fetchGeometry(p);
+			res = TeBUFFERREGION::TeBufferRegion(p.location(), dist, 16, pol);
+			polSet.add (pol);
+		}
+
+		else if(actRep == TeLINES)
+		{
+			TeLine2D l;
+			flag = portal->fetchGeometry(l);
+			res = TeBUFFERREGION::TeBufferRegion(l, dist, 8, polSet);
+		}
+
+		else if(actRep == TePOLYGONS)
+		{
+			TePolygon p;
+			flag = portal->fetchGeometry(p);
+			res = TeBUFFERREGION::TeBufferRegion(p, dist, 8, polSet);
+		}	
+
+		else if(actRep == TeCELLS)
+		{
+			TeCell c;
+			flag = portal->fetchGeometry(c);
+			res = TeBUFFERREGION::TeBufferRegion(TeMakePolygon(c.box()), dist, 8, polSet);
+		}	
+		
+		if(res)
+		{
+			for(unsigned int i=0; i<polSet.size(); i++)
+				bufferSet.add(polSet[i]);
+		}
+	
+	} while (flag && res);
+
+	delete portal;
+	return true;
+}
+
+
+bool TeGetOverlay(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeDatabase* db, TeGeometryVect& geomVect, const short& operation)
+{
+	if((actIds.empty()) || (actRep!=TePOLYGONS && actRep!=TeCELLS))
+		return false;
+	
+	string Ids = getStringIds(actIds);
+
+	TeDatabasePortal* portal = db->getPortal();
+	if(!portal)
+		return false;
+
+	string sql = " SELECT * FROM " + actGeomTable;
+	sql += " WHERE object_id IN ("+ Ids +")";
+	sql += " ORDER BY object_id ASC ";
+	if(actRep == TePOLYGONS && portal->getDatabase()->dbmsName() != "PostGIS")	
+		sql += ", parent_id ASC, num_holes DESC ";
+	
+	if(!portal->query(sql) || !portal->fetchRow())
+	{
+		delete portal;
+		return false;
+	}
+		
+	bool flag = true;
+	TePolygonSet polSet1;
+	
+	if(actRep == TePOLYGONS)
+	{
+		TePolygon p;
+		flag = portal->fetchGeometry(p);
+		polSet1.add (p);
+	}
+	else if(actRep == TeCELLS)
+	{
+		TeCell c; 
+		flag = portal->fetchGeometry(c);
+		polSet1.add(TeMakePolygon(c.box()));
+	}
+
+	while (flag)
+	{
+		TePolygonSet polSet2, polInter;
+
+		if(actRep == TePOLYGONS)
+		{
+			TePolygon p;
+			flag = portal->fetchGeometry(p);
+			polSet2.add (p);
+		}	
+
+		else if(actRep == TeCELLS)
+		{
+			TeCell c;
+			flag = portal->fetchGeometry(c);
+			polSet2.add(TeMakePolygon(c.box()));
+		}
+		
+		if(operation==TeUNION)
+		{
+			if(!TeOVERLAY::TeUnion(polSet1, polSet2, polInter))
+				return false;
+		}
+		else if (operation==TeINTERSECTION)
+		{
+			if(!TeOVERLAY::TeIntersection(polSet1, polSet2, polInter))
+				return false;
+		}
+		else if (operation==TeDIFFERENCE)
+		{
+			if(!TeOVERLAY::TeDifference(polSet1, polSet2, polInter))
+				return false;
+		}
+
+		polSet1 = polInter;
+	}
+
+	TeGeometry* geom;
+	TePolygonSet* pol = new TePolygonSet();
+	*pol = polSet1;
+	geom = pol;
+	
+	geomVect.push_back (geom);
+	delete portal;
+	return true;
+}
+
+
+TeRaster*
+TeMask(TeRaster* whole, TePolygon& poly, TeStrategicIterator st)
+{
+	if (!whole || (whole->params().status_ != TeRasterParams::TeReadyToRead && 
+		whole->params().status_ != TeRasterParams::TeReadyToWrite))
+		return 0;
+
+	if (!TeIntersects(poly.box(),whole->params().boundingBox()))
+		return 0;
+	
+	TeRasterParams par = whole->params();
+	par.decoderIdentifier_ = "MEM";
+	par.mode_ = 'c';
+	par.setDummy(0);
+
+	TeCoord2D bll = whole->coord2Index(poly.box().lowerLeft());
+	TeCoord2D bur = whole->coord2Index(poly.box().upperRight());
+
+	bll = whole->index2Coord(TeCoord2D(TeRoundRasterIndex(bll.x_),TeRoundRasterIndex(bll.y_)));
+	bur = whole->index2Coord(TeCoord2D(TeRoundRasterIndex(bur.x_),TeRoundRasterIndex(bur.y_)));
+
+	par.boxResolution(bll.x_, bll.y_, bur.x_, bur.y_,par.resx_, par.resy_);
+	par.setDummy(0.0);
+	par.useDummy_ = true;
+
+	TeRaster*  clip = new TeRaster(par);
+	clip->init();
+	if (clip->params().status_ != TeRasterParams::TeReadyToWrite)
+		return 0;
+
+	TeCoord2D cd = TeCoord2D(0,0);
+	TeCoord2D ul = clip->params().index2Coord(cd);
+	TeCoord2D dxdy = whole->params().coord2Index(ul);
+	int j = TeRoundRasterIndex(dxdy.x_); // column delta
+	int i = TeRoundRasterIndex(dxdy.y_); // line delta
+
+	TeRaster::iteratorPoly it = whole->begin(poly, st);
+//	int nlines = it.nLinesInPoly();
+//	int ncols = it.nColsInPoly();
+	while(!it.end())
+    {
+		int lin = it.currentLine();
+		int col = it.currentColumn();
+		int nbands = it.nBands();
+		vector<double> vals;
+		vals = (*(TeRaster::iterator)it);
+		for (int b=0; b<nbands; b++)
+			clip->setElement(col-j,lin-i,vals[b],b);
+		++it;
+	}
+	return clip;
+}
+
+
+
+
+
diff --git a/src/terralib/kernel/TeSpatialOperations.h b/src/terralib/kernel/TeSpatialOperations.h
new file mode 100644
index 0000000..20dedc0
--- /dev/null
+++ b/src/terralib/kernel/TeSpatialOperations.h
@@ -0,0 +1,283 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeSpatialOperations.h
+    \brief This file contains functions to spatial operations with geographical objects that are in a SGBD 
+*/
+
+#ifndef  __TERRALIB_INTERNAL_SPATIALOPERATIONS_H
+#define  __TERRALIB_INTERNAL_SPATIALOPERATIONS_H
+
+#include "TeDatabase.h"
+#include "TeRaster.h"
+
+//! Keep the selected geometries in the canvas
+typedef vector<TeGeometry*> TeSelectedGeom;
+
+//! Return a string with the identifications of the selected geometries 
+TL_DLL string  getStringIds(TeKeys& IdsIn);
+
+
+//! Return a portal with the geometries of a spatial table that have a topological relation with specifics geometries of this spatial table
+/*!
+	Calculate the topological relation between all geometries of a spatial table and
+	specifics geometries of this spatial table
+	\param actGeomTable	spatial table name that contains all the geometries
+	\param actRep		geometrical representation of the spatial table 
+	\param actIdsIn		identifications of the specifics geometries (object_id)
+	\param portal		returned with the resultants geometries 
+	\param relation		topological relation that will be computed
+	\param actColTable	collection table name that contains a set of geometries of the spatial table 
+*/
+TL_DLL bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   TeDatabasePortal *portal, int relation, const string& actColTable="");
+
+
+//! Return a portal with the geometries of a spatial table that have a topological relation with specifics geometries of other spatial table 
+/*!
+	Calculate the topological relation between all geometries of a spatial table and
+	specifics geometries of other spatial table
+	\param actGeomTable	first spatial table name that contains the specifics geometries
+	\param actRep		geometrical representation of the first spatial table 
+	\param actIdsIn		identifications of specifics geometries of the first spatial table (object_id)
+	\param visGeomTable	second spatial table name that contains the others geometries
+	\param visRep		geometrical representation of the second spatial table 
+	\param portal		returned with the resultants geometries 
+	\param relation		topological relation that will be computed 
+	\param visColTable	collection table name that contains a set of geometries of the second spatial table 
+*/
+TL_DLL bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   const string& visGeomTable, TeGeomRep visRep, TeDatabasePortal *portal, 
+						   int relation, const string& visColTable="");
+
+
+//! Return a portal with the geometries of a spatial table that have a topological relation with a specific geometry  
+/*!
+	Calculate the topological relation between all geometries of a spatial table and a specific geometry 
+	\param actGeomTable	spatial table name that contains the geometries
+	\param actRep		geometrical representation of the spatial table 
+	\param geom			a specific geometry 
+	\param portal		returned with the resultants geometries 
+	\param relation		topological relation that will be computed 
+	\param actCollTable	collection table name that contains a set of geometries of the spatial table 
+*/
+TL_DLL bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, 
+						   TeDatabasePortal *portal, int relation, const string& actCollTable="");
+
+
+//! Return the identications of the geometries of a spatial table that have a topological relation with specifics geometries of this spatial table
+/*!
+	Calculate the topological relation between all geometries of a spatial table and
+	specifics geometries of this spatial table
+	\param actGeomTable	spatial table name that contains all the geometries
+	\param actRep		geometrical representation of the spatial table 
+	\param actIdsIn		identifications of the specifics geometries (object_id)
+	\param actIdsOut	returned with the identications of the resultants geometries (object_id)
+	\param db			a TeDatabase pointer 
+	\param relation		topological relation that will be computed 
+	\param actCollTable	collection table name that contains a set of geometries of the spatial table 
+*/
+TL_DLL bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   TeKeys& actIdsOut, TeDatabase* db, int relation, const string& actCollTable="");
+
+
+//! Return the identications of the geometries of a spatial table that have a topological relation with specifics geometries of other spatial table 
+/*!
+	Calculate the topological relation between all geometries of a spatial table and
+	specifics geometries of other spatial table
+	\param actGeomTable	first spatial table name that contains the specifics geometries
+	\param actRep		geometrical representation of the first spatial table 
+	\param actIdsIn		identifications of specifics geometries of the first spatial table (object_id)
+	\param visGeomTable	second spatial table name that contains the others geometries
+	\param visRep		geometrical representation of the second spatial table 
+	\param visIdsOut	returned with the identications of the resultants geometries (object_id)
+	\param db			a TeDatabase pointer 
+	\param relation		topological relation that will be computed 
+	\param visCollTable	collection table name that contains a set of geometries of the second spatial table 
+*/
+TL_DLL bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, 
+						   const string& visGeomTable, TeGeomRep visRep, TeKeys& visIdsOut, 
+						   TeDatabase* db, int relation, const string& visCollTable="", TeDatabase* = 0);
+
+//! Return the identications of the geometries of a spatial table that have a topological relation with a specific geometry  
+/*!
+	Calculate the topological relation between all geometries of a spatial table and a specific geometry 
+	\param actGeomTable	spatial table name that contains the geometries
+	\param actRep		geometrical representation of the spatial table 
+	\param geom			a specific geometry 
+	\param actIdsOut	returned with the identications of the resultants geometries (object_id)
+	\param db			a TeDatabase pointer 
+	\param relation		topological relation that will be computed 
+	\param actCollTable	collection table name that contains a set of geometries of the spatial table 
+*/
+TL_DLL bool TeTopologicalRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, 
+						   TeKeys& actIdsOut, TeDatabase* db, int relation, const string& actCollTable="");
+
+//! Return whether the specified topological relation holds between two polygon
+/*!
+	\param geom1	a polygon
+	\param geom2	another polygon
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TePolygon* geom1, const TePolygon* geom2, int relation);
+
+//! Return whether the specified topological relation holds between a polygon and a line
+/*!
+	\param geom1	a polygon
+	\param geom2	a line
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TePolygon* geom1, const TeLine2D* geom2, int relation);
+
+//! Return whether the specified topological relation holds between a polygon and a point
+/*!
+	\param geom1	a polygon
+	\param geom2	a point
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TePolygon* geom1, const TePoint* geom2, int relation);
+
+//! Return whether the specified topological relation holds between two lines
+/*!
+	\param geom1	a line
+	\param geom2	another line
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TeLine2D* geom1, const TeLine2D* geom2, int relation);
+
+//! Return whether the specified topological relation holds between a line and a point
+/*!
+	\param geom1	a line
+	\param geom2	a point
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TeLine2D* geom1, const TePoint* geom2, int relation);
+
+//! Return whether the specified topological relation holds between two points
+/*!
+	\param geom1	a point
+	\param geom2	another point
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TePoint* geom1, const TePoint* geom2, int relation);
+
+//! Return whether the specified topological relation holds between two cells
+/*!
+	\param geom1	a cell
+	\param geom2	another cell
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TeCell* geom1, const TeCell* geom2, int relation);
+
+//! Return whether the specified topological relation holds between a cell and a polygon
+/*!
+	\param geom1	a cell
+	\param geom2	a polygon
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TeCell* geom1, const TePolygon* geom2, int relation);
+
+//! Return whether the specified topological relation holds between a cell and a line
+/*!
+	\param geom1	a cell
+	\param geom2	a line
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TeCell* geom1, const TeLine2D* geom2, int relation);
+
+//! Return whether the specified topological relation holds between a cell and a point
+/*!
+	\param geom1	a cell
+	\param geom2	a point
+	\param relation		topological relation to be verified
+*/
+TL_DLL bool TeTopologicalRelation(const TeCell* geom1, const TePoint* geom2, int relation);
+
+//! Returns the geometries of a geometric table (actGeomTable) that are within a specific distance from a point in memory 
+/*!
+	  \param actGeomTable	geometric table name
+	  \param actRep			geometric representation of the actGeomTable table
+	  \param point			a point in memory
+	  \param IdsDistOut		structure that will contain the identifiers of the resulted geometries and their distances
+	  \param db				a TeDatabase pointer 
+	  \param max_dist		maximum distance 
+	  \param actCollTable	collection table name associated with the actGeomTable table
+*/
+TL_DLL bool TeGetWithinDistance(const string& actGeomTable, TeGeomRep actRep, const TeCoord2D& point, TeKeysToDist& IdsDistOut,
+						 TeDatabase* db, const double& max_dist, const string& actCollTable="");
+
+
+//! Return the area of some specifics geometries of a spatial table 
+/*!
+	\param actGeomTable	spatial table name that contains the geometries
+	\param actRep		geometrical representation of the spatial table 
+	\param actIdsIn		identifications of the specifics geometries (object_id)
+	\param db			a TeDatabase pointer 
+	\param area			area returned
+*/
+TL_DLL bool TeGetArea(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeDatabase* db, double& area);
+
+
+//! Return the length of some specifics geometries of a spatial table 
+TL_DLL bool TeGetLength(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeDatabase* db, double& length);
+
+
+//! Return the distance between two geometries
+TL_DLL bool TeGetDistance(const string& actGeomTable, TeGeomRep actRep, TeKeys& IdsIn, TeDatabase* db, double& distance);
+
+//! Return the convexhull geometries of specifics geometries of a spatial table 
+/*!
+	\param actGeomTable		spatial table name that contains the geometries
+	\param actRep			geometrical representation of the spatial table 
+	\param actIds			identifications of the specifics geometries (object_id)
+	\param db				a TeDatabase pointer 
+	\param convexHullSet	the convexhull geometries returned
+*/
+TL_DLL bool TeGetConvexHull(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeDatabase* db, 
+					 TePolygonSet& convexHullSet);
+
+
+//! Return the centroids of specifics geometries of a spatial table 
+TL_DLL bool TeGetCentroid(const string& actGeomTable, TeGeomRep actRep, TeDatabase* db, TePointSet& centroidSet,
+				   TeKeys& actIds, const string& actCollTable="");
+
+
+//! Return the buffer 
+TL_DLL bool TeGetBuffer(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeDatabase* db, 
+				 TePolygonSet& bufferSet, double dist);
+
+
+//! Return intersection
+TL_DLL bool TeGetOverlay(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeDatabase* db, 
+				  TeGeometryVect& geomVect, const short& operation);
+
+/*!	
+	\brief Clip a raster from a polygon. Return the clipped raster 
+	\param rasterIn	TeRaster pointer that will be clipped
+	\param poly		polygon that defines the clipping
+	\param st		strategic to the iterator of the raster  
+*/
+TL_DLL TeRaster*
+TeMask (TeRaster* rasterIn, TePolygon& poly, TeStrategicIterator st);
+
+#endif
+
diff --git a/src/terralib/kernel/TeStatistics.h b/src/terralib/kernel/TeStatistics.h
new file mode 100644
index 0000000..6af6390
--- /dev/null
+++ b/src/terralib/kernel/TeStatistics.h
@@ -0,0 +1,664 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeStatistics.h
+    \brief This file contains functions for calculate statistics  
+*/
+
+#ifndef TeStatistics_H
+#define TeStatistics_H
+
+#include "TeDataTypes.h"
+
+#include <string>
+#include <map>
+
+using namespace std;
+
+/** @defgroup Stat Statistical functions
+  @{
+ */
+//! vector of statistics
+typedef vector<double>	stats;
+
+//! Associate a statistics set for each dimension 
+struct TL_DLL TeStatisticsDimension
+{
+	int					dimension_;
+	TeStatisticValMap	stat_;
+
+	TeStatisticsDimension(int d, TeStatisticValMap& st): 
+	dimension_(d), 
+	stat_(st)
+	{}
+};
+
+//! vector of the statistics associated with the dimensions 
+typedef vector<TeStatisticsDimension>	TeStatisticsDimensionVect;
+
+//! map each value to its count: histogram
+typedef map<double, int> TeHistogram;
+
+
+/** Calculates the histrogram of a set of values kept in a data structure 
+	\param itBegin	the iterator to the begin of the data structure 
+	\param itEnd	the iterator to the end of the data structure
+	\param histOut	to return the histogram  
+*/
+template<typename T>
+bool TeCalculateHistogram(const T& itBegin, const T& itEnd, TeHistogram& histOut)  
+{
+	T it = itBegin;
+
+	//initialization 
+	while(it!=itEnd)
+	{
+		double val = (*it); 
+		histOut[val] = 0;
+		it++;
+	}
+	
+	it= itBegin;
+	
+	//calcule histogram
+	while(it!=itEnd)
+	{
+		double val = (*it); 
+		histOut[val]++;
+		it++;
+	}
+	
+	return true;
+}
+
+/** Calculates the statistics of a specific dimension of a data structure 
+	\param itBegin	the iterator to the begin of the data structure
+	\param itEnd	the iterator to the end of the data structure
+	\param stat		to return the statistics  
+	\param dim		the dimension of the data structure  
+*/
+template<typename It>  
+bool TeCalculateStatistics(const It& itBegin, const It& itEnd, TeStatisticValMap& stat, int dim)
+{
+	double	sum, mean, minValue, maxValue, variance, assim, 
+			curtose, stDev, coefVar, amplitude, moda, median;  
+	sum=mean=variance=assim=curtose=stDev=coefVar=amplitude=0.0;
+	
+	minValue = TeMAXFLOAT;
+	maxValue = TeMINFLOAT;
+
+	vector<double> values;
+	int count=0;
+	int countTotal = 0;
+	It itt = itBegin;	
+	while(itt != itEnd)
+    {
+		double val;
+		val = (*itt)[dim];
+		
+		if(val!=TeMAXFLOAT)  // MAXFLOAT is considered invalid value
+		{
+			values.push_back (val);
+			sum += val;
+		
+			if(minValue>val)
+				minValue = val;
+			if(maxValue<val)
+				maxValue = val;
+			
+			++count;
+			mean = sum/count;
+		}
+		
+		++itt;
+		++countTotal;
+	}
+
+	for(int i=0; i<count; i++)
+	{
+		double v= values[i];
+		variance += pow((v-mean),2); 
+		assim += pow((v-mean),3);   
+		curtose += pow((v-mean),4); 
+	}
+	
+	if(!count)
+		return false;
+
+	variance /= count; 
+	stDev = pow(variance,0.5); 
+	assim /= count;
+	assim /= pow(stDev,3); 
+	curtose /= count;
+	curtose /= pow(stDev,4); 
+
+	coefVar = (100*stDev)/mean;
+	amplitude = maxValue-minValue;  
+
+	sort(values.begin(), values.end());
+		
+	//calculate median 
+	if((count%2)==0)
+		median = (values[(count/2)]+values[(count/2-1)])/2;
+	else
+		median = values[(count-1)/2];
+
+	//calculate the mode
+	TeHistogram histog;
+	TeCalculateHistogram(values.begin(),values.end(), histog);
+		
+	TeHistogram::iterator itHist = histog.begin();
+	int nCount=0;
+	while(itHist!=histog.end())
+	{
+		int hCount = itHist->second; 
+		if (hCount > nCount)
+		{
+			nCount = hCount;
+			moda = itHist->first;
+		}
+		itHist++;	
+	}
+	
+	//fill results
+	stat[TeCOUNT] = countTotal; 
+	stat[TeVALIDCOUNT] = count;
+	stat[TeMINVALUE] = minValue;
+	stat[TeMAXVALUE] = maxValue;
+	stat[TeSUM] = sum;
+	stat[TeMEAN] = mean;
+	stat[TeSTANDARDDEVIATION] = stDev;
+	stat[TeVARIANCE] = variance;
+	stat[TeSKEWNESS] = assim;
+	stat[TeKURTOSIS] = curtose;
+	stat[TeAMPLITUDE] = amplitude;
+	stat[TeMEDIAN] = median;		
+	stat[TeVARCOEFF] = coefVar;		
+	stat[TeMODE] = moda;
+ 
+	return true;
+}
+
+
+/**  Calculates the statistics of a string data structure 
+	\param itBegin	the iterator to the begin of the data structure
+	\param itEnd	the iterator to the end of the data structure
+	\param stat		to return the statistics  
+*/
+template<typename It>  
+bool TeCalculateStatistics(const It& itBegin, const It& itEnd, TeStatisticStringValMap& stat)
+{
+	string min, max, val;
+	int	count = 0;
+
+	It it = itBegin;
+	int totalCount = 0;
+
+	if(it != itEnd)
+		min = max = (*it);
+	while(it != itEnd)
+	{
+		val = (*it);
+		if(val.empty() == false)
+		{
+			count++;
+			min = MIN(min, val);
+			max = MAX(max, val);
+		}
+		++it;
+		++totalCount;
+	}
+
+	stat[TeMINVALUE] = min;
+	stat[TeMAXVALUE] = max;
+	stat[TeCOUNT] = Te2String(totalCount); 
+	stat[TeVALIDCOUNT] = Te2String(count); 
+	return true;
+}
+
+
+/** Calculates the statistics of a data structure 
+	\param itBegin	the iterator to the begin of the data structure
+	\param itEnd	the iterator to the end of the data structure
+	\param stat		to return the statistics  
+*/
+template<typename It>  
+bool TeCalculateStatistics(const It& itBegin, const It& itEnd, TeStatisticValMap& stat)
+{
+	double	sum, mean, minValue, maxValue, variance, assim, 
+			curtose, stDev, coefVar, amplitude, moda, median;  
+	sum=mean=variance=assim=curtose=stDev=coefVar=amplitude=moda=0.0;
+	
+	minValue = TeMAXFLOAT;
+	maxValue = TeMINFLOAT;
+
+	vector<double>	values;
+
+	int	totalCount = 0;
+	int count=0;
+	It itt = itBegin;	
+	while(itt != itEnd)
+    {
+		double val = (*itt);
+		if(val != TeMAXFLOAT) // MAXFLOAT is considered invalid value
+		{
+			values.push_back (val);
+			sum += val;
+			minValue = MIN(minValue, val);
+			maxValue = MAX(maxValue, val);
+		}
+		
+		++itt;
+		++totalCount;
+	}
+
+	count = values.size();
+	mean = sum/count;
+
+	for(int i=0; i<count; i++)
+	{
+		double v= values[i];
+		variance += pow((v-mean),2); 
+		assim += pow((v-mean),3);   
+		curtose += pow((v-mean),4); 
+	}
+	
+	if(!count)
+		return false;
+
+	variance /= count; 
+	stDev = pow(variance,0.5); 
+	assim /= count;
+	assim /= pow(stDev,3); 
+	curtose /= count;
+	curtose /= pow(stDev,4); 
+
+	coefVar = (100*stDev)/mean;
+	amplitude = maxValue-minValue;  
+
+	sort(values.begin(), values.end());
+		
+	//calculate median 
+	if((count%2)==0)
+		median = (values[(count/2)]+values[(count/2-1)])/2;
+	else
+		median = values[(count-1)/2];
+
+	//calculate the mode
+	TeHistogram histog;
+	TeCalculateHistogram(values.begin(),values.end(), histog);
+		
+	TeHistogram::iterator itHist = histog.begin();
+	int nCount=0;
+	while(itHist!=histog.end())
+	{
+		int hCount = itHist->second; 
+		if (hCount > nCount)
+		{
+			nCount = hCount;
+			moda = itHist->first;
+		}
+		itHist++;	
+	}
+	
+	//fill results
+	stat[TeVALIDCOUNT] = count; 
+	stat[TeCOUNT] = totalCount; 
+	stat[TeMINVALUE] = minValue;
+	stat[TeMAXVALUE] = maxValue;
+	stat[TeSUM] = sum;
+	stat[TeMEAN] = mean;
+	stat[TeSTANDARDDEVIATION] = stDev;
+	stat[TeVARIANCE] = variance;
+	stat[TeSKEWNESS] = assim;
+	stat[TeKURTOSIS] = curtose;
+	stat[TeAMPLITUDE] = amplitude;
+	stat[TeMEDIAN] = median;		
+	stat[TeVARCOEFF] = coefVar;		
+	stat[TeMODE] = moda;
+ 
+	return true;
+}
+
+
+/** Calculates the statistics of all dimensions of a data structure 
+	\param itBegin	the iterator to the begin of the data structure
+	\param itEnd	the iterator to the end of the data structure
+	\param stat		to return the statistics  
+*/
+template<typename It>  
+bool TeCalculateStatistics(It& itBegin, It& itEnd, TeStatisticsDimensionVect& stat)
+{
+	
+	vector<double>	sum, mean, minValue, maxValue, variance, assim, curtose, 
+					stDev, coefVar, amplitude, moda, median;  
+	
+	int nb = itBegin.nBands();
+	
+	//initialization of the vetors
+	for (int i=0; i<nb; i++)
+	{
+		sum.push_back(0.0); 
+		mean.push_back(0.0); 
+		variance.push_back(0.0);
+		assim.push_back(0.0); 
+		curtose.push_back(0.0); 
+		stDev.push_back(0.0);
+		coefVar.push_back(0.0);	
+		amplitude.push_back(0.0);
+		median.push_back (0.0);
+		moda.push_back (0.0);
+		minValue.push_back(TeMAXFLOAT);
+		maxValue.push_back(TeMINFLOAT);
+	}
+			
+	map<int,stats> bandValues;
+	
+	int count=0;
+	It itt = itBegin;	
+	
+	while(itt != itEnd)
+    {
+		for (int j=0; j<nb; j++)
+		{
+			double val = itt.operator* (j);
+			bandValues[j].push_back(val);
+			sum[j] += val;
+			
+			if(minValue[j]>val)
+				minValue[j] = val;
+			if(maxValue[j]<val)
+				maxValue[j] = val;
+
+			int size = bandValues[j].size();
+			mean[j] = sum[j]/size;
+		}
+		
+		++itt;
+		++count;
+	}
+
+	if(!count)
+		return false;
+
+	for (int jj=0; jj<nb; jj++)
+	{
+		for(int i=0; i<count; i++)
+		{	
+			double v = bandValues[jj][i];
+			variance[jj] += pow((v-mean[jj]),2);
+			assim[jj] += pow((v-mean[jj]),3);
+			curtose[jj] += pow((v-mean[jj]),4);
+		}
+
+		variance[jj] /= count;
+		stDev[jj] = pow(variance[jj],0.5);
+		assim[jj] /= count;
+		assim[jj] /= pow(stDev[jj],3);
+		curtose[jj] /= count;
+		curtose[jj] /= pow(stDev[jj],4);
+
+		coefVar[jj] = (100*stDev[jj])/mean[jj];
+		amplitude[jj] = maxValue[jj]-minValue[jj];
+
+		sort(bandValues[jj].begin(), bandValues[jj].end());
+		
+		//calculate median
+		if((count%2)==0)
+			median[jj] = ((bandValues[jj][(count/2)])+(bandValues[jj][(count/2-1)]))/2;
+		else
+			median[jj] = bandValues[jj][(count-1)/2];
+
+		//calculate the mode
+		TeHistogram histog;
+		TeCalculateHistogram(bandValues[jj].begin(),bandValues[jj].end(), histog);
+			
+		TeHistogram::iterator itHist = histog.begin();
+		int nCount=0;
+		while(itHist!=histog.end())
+		{
+			int hCount = itHist->second; 
+			if (hCount > nCount)
+			{
+				nCount = hCount;
+				moda[jj] = itHist->first;
+			}
+			itHist++;	
+		}
+			
+		//fill results
+		TeStatisticValMap statVal;
+
+		statVal[TeCOUNT] = count; 
+		statVal[TeMINVALUE] = minValue[jj];
+		statVal[TeMAXVALUE] = maxValue[jj];
+		statVal[TeSUM] = sum[jj];
+		statVal[TeMEAN] = mean[jj];
+		statVal[TeSTANDARDDEVIATION] = stDev[jj];
+		statVal[TeVARIANCE] = variance[jj];
+		statVal[TeSKEWNESS] = assim[jj];
+		statVal[TeKURTOSIS] = curtose[jj];
+		statVal[TeAMPLITUDE] = amplitude[jj];
+		statVal[TeMEDIAN] = median[jj];
+		statVal[TeVARCOEFF] = coefVar[jj];
+		statVal[TeMODE] = moda[jj];
+
+		TeStatisticsDimension statBand(jj, statVal);
+		stat.push_back(statBand);
+	}
+	
+	return true;
+}
+
+
+//!	Returns the sum of the elements of a specific dimension 
+template <typename It> 
+double TeSum (It begin, It end, int dim)
+{
+	double sum = 0.;
+	while ( begin != end)
+	{
+		if(((*begin)[dim])!= TeMAXFLOAT) // MAXFLOAT is considered invalid value
+			sum += (*begin)[dim];
+		
+		++begin;
+	}
+	return sum;
+}
+
+
+//!	Return the sum of the elements
+template <typename It> 
+double TeSum (It begin, It end)
+{
+	double sum = 0.;
+	while ( begin != end)
+	{
+		if((*begin)!= TeMAXFLOAT) // MAXFLOAT is considered invalid value
+			sum += (*begin);
+		
+		++begin;
+	}
+	return sum;
+}
+
+
+//! Calculates the mean (first moment) of the elements of a specific dimension
+template <typename It> 
+double TeFirstMoment (It begin, It end, int dim)
+{
+	int number = 0;
+	double mean = 0.;
+	while (begin != end)
+	{
+		if(((*begin)[dim])!= TeMAXFLOAT) // MAXFLOAT is considered invalid value
+		{
+			mean += (*begin)[dim];
+			number++; 
+		}
+		++begin;
+	}
+	return mean /= number;
+}
+
+
+//! Calculates the mean (first moment) of the elements
+template <typename It> 
+double TeFirstMoment (It begin, It end)
+{
+	int number = 0;
+	double mean = 0.;
+	while (begin != end)
+	{
+		if((*begin)!= TeMAXFLOAT) // MAXFLOAT is considered invalid value
+		{
+			mean += (*begin);
+			number++; 
+		}
+		begin++;
+	}
+	return mean /= number;
+}
+
+
+//! Calculates the second moment
+template <typename It> 
+double TeSecondMoment (It begin, It end, double mean)
+{
+	int number = 0;
+	double SSD = 0;  //sum of squares of desviation
+
+	while (begin != end)
+	{
+		if((*begin)!= TeMAXFLOAT) // MAXFLOAT is considered invalid value
+		{
+			SSD += pow(( (*begin) - mean), 2);
+			number++; 
+		}
+		begin++;
+	}
+	return SSD /= number;
+}
+
+
+//! Calculates the second moment
+template <typename It> 
+double TeSecondMoment (It begin, It end, double mean, int dim)
+{
+	int number = 0;
+	double SSD = 0;  //sum of squares of desviation
+
+	while (begin != end)
+	{
+		if(((*begin)[dim])!= TeMAXFLOAT) // MAXFLOAT is considered invalid value
+		{
+			SSD += pow(((*begin)[dim] - mean), 2);
+			number++; 
+		}
+		++begin;
+	}
+	return SSD /= number;
+}
+
+
+
+//!	calculates the vector with the means of the attributs
+template <typename It, typename T> 
+bool TeMeanVector ( It begin, It end, T& result)
+{
+	int i = 0;
+	int dim = result.size();
+	T soma;
+
+	for (int m = 0; m < dim ; m++)
+		soma.push_back(0.);
+
+	while (begin != end)
+	{
+		for( int j = 0; j < dim; j++)
+		{
+			if(((*begin)[j]) != TeMAXFLOAT) // MAXFLOAT is considered invalid value 
+			{
+				soma[j]+= (*begin)[j];
+				i++;
+			}
+			else
+				soma[j]= TeMAXFLOAT;
+		}
+		begin++;
+	}
+	
+	for (int k = 0; k < dim; k++)
+	{
+		if(soma[k] != TeMAXFLOAT) 
+			result[k] = soma[k]/i;
+		else
+			result[k] = TeMAXFLOAT;
+	}
+
+	return true;
+}
+
+//! Calculates the deviations in relation to mean
+template <typename It> 
+bool TeDeviation ( It begin, It end, It result, double mean)
+{
+	while (begin != end)
+	{
+		if((*begin) != TeMAXFLOAT) // MAXFLOAT is considered invalid value 
+			*result = double(*begin) - mean;
+		else
+			*result = TeMAXFLOAT;
+
+		begin++; result++;
+	}
+	return true;
+}
+
+
+//! calculates the deviations in relation to mean
+template <typename iteratorSet> 
+bool TeDeviation ( iteratorSet begin, iteratorSet end, double mean, int index=0)
+{
+	//Adds a new attribute in the attribute list of the set
+	TeAttribute attrRep;
+	attrRep.rep_.name_ = "Z";
+	attrRep.rep_.type_ = TeREAL;
+	begin->addProperty(attrRep);
+	
+	while (begin != end)
+	{
+		double result;
+		
+		if(((*begin)[index]) != TeMAXFLOAT) // MAXFLOAT is considered invalid value 
+			result = ((*begin)[index]) - mean;
+		else
+			result = TeMAXFLOAT;
+		
+		(*begin).addPropertyValue(Te2String(result, 9)); 
+		++begin; 
+	}
+	return true;
+}
+/** @} */
+#endif
+
diff --git a/src/terralib/kernel/TeStdFile.cpp b/src/terralib/kernel/TeStdFile.cpp
new file mode 100644
index 0000000..83d0008
--- /dev/null
+++ b/src/terralib/kernel/TeStdFile.cpp
@@ -0,0 +1,60 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include "TeStdFile.h"
+#include "TeException.h"
+
+
+
+// -- Constructor
+
+TeStdFile::TeStdFile ( const string& name, const char* mode ):
+	file_ ( 0 ), fileName_ ( name ), mode_ ( mode )
+{
+	const char* inputFile = fileName_.c_str();
+	if ( name.size() <= 1 )
+		throw TeException ( EMPTY_FILE_NAME, name, false );
+	
+	if ( ( file_ = fopen( inputFile, mode ) ) == 0 )
+	{
+		bool hasErrno = true;
+		throw TeException ( CANNOT_OPEN_FILE, name, hasErrno );
+	}
+}
+
+TeStdFile::~TeStdFile() 
+{ 
+	if(file_ ) 
+		fclose(file_);
+}
+
+void
+TeStdFile::rewind()
+{
+	if (file_)
+		fseek(file_,0,0);
+}
diff --git a/src/terralib/kernel/TeStdFile.h b/src/terralib/kernel/TeStdFile.h
new file mode 100644
index 0000000..cfe5230
--- /dev/null
+++ b/src/terralib/kernel/TeStdFile.h
@@ -0,0 +1,84 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeStdFile.h
+    \brief This file contains a class for handling "stdio" files
+*/
+#ifndef  __TERRALIB_INTERNAL_STDFILE_H
+#define  __TERRALIB_INTERNAL_STSFILE_H
+
+#include "TeDefines.h"
+#include <stdio.h>
+#include <string>
+using namespace std;
+
+//! A class for handling "stdio" files
+/*  Provide support for using a file as a class, and 
+    throws exceptions if things go wrong
+	\sa TeException TeAsciiFile
+*/
+class TL_DLL TeStdFile {
+public:
+
+//! Simple constructor taking the file name and the mode of oppening
+		TeStdFile(const string& name, const char* mode = "r");
+	
+	virtual ~TeStdFile(); 
+
+//! Return true if the file pointer is not at the end of file
+	bool isNotAtEOF()
+	{ 
+		if ( feof ( file_ ) != 0  )
+			return false;
+		return true;
+	}
+
+// name
+	string name ()
+	{ return fileName_; }
+
+// -- operator ()	
+	operator FILE*() { return file_; }
+
+// -- returns the file pointer
+	FILE* FilePtr() { return file_; }
+
+	void rewind();
+
+protected:
+	
+// -- File pointer
+
+	FILE *file_;
+	string fileName_;
+	string mode_;
+
+private:
+	
+// No copy allowed
+	TeStdFile(const TeStdFile&);
+	TeStdFile& operator=(const TeStdFile&);
+
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeTable.cpp b/src/terralib/kernel/TeTable.cpp
new file mode 100644
index 0000000..909bed6
--- /dev/null
+++ b/src/terralib/kernel/TeTable.cpp
@@ -0,0 +1,376 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeTable.h"
+#include "TeUtils.h"
+#include <iostream>
+
+using namespace std;
+
+
+string tableJoin(TeAttrTableVector& vecTable, string geomTable, string attrLink)
+{
+	string parClause = "";
+	string fromResult = "";
+	string firstTable = "";
+	string cJoin = "";
+
+	TeAttrTableVector::iterator it; 
+	
+	if(geomTable.empty())
+	{
+		//find the first static table
+		it = vecTable.begin();
+		while(it!=vecTable.end())
+		{
+			if((*it).tableType() != TeAttrExternal)
+			{
+				firstTable = (*it).name();
+				attrLink = (*it).linkName();
+				break;
+			}
+			++it;
+		}
+		cJoin = " LEFT "; //the first table is a attribute table
+	}
+	else
+	{
+		firstTable = geomTable;
+		cJoin = " LEFT "; //the first table is a geometry table
+	}
+		
+	
+	fromResult += firstTable; 
+	
+	
+	//if don�t exist a table static or temporal 
+	if(firstTable.empty() || attrLink.empty())	
+		return "";
+			
+	it = vecTable.begin();
+
+	while(it!=vecTable.end())
+	{
+		if( ((*it).name()!=firstTable) && ((*it).tableType()!=TeAttrExternal))
+		{
+			fromResult += " "+ cJoin +" JOIN "+ (*it).name() +" ON "+ firstTable;
+			fromResult += "."+ attrLink +" = "+ (*it).name() +"."+ (*it).linkName() +")";
+			parClause += "(";
+		}
+
+		else if ((*it).name()!=firstTable)
+		{
+			int idTableStatic = (*it).relatedTableId();
+			string colTableStatic = (*it).relatedAttribute();
+			string nameTableStatic;   
+
+			//verify if static table is in the vector of the attribute tables
+			for(unsigned int j=0; j<vecTable.size(); j++)
+			{
+				if(vecTable[j].id()==idTableStatic)
+				{
+					nameTableStatic = vecTable[j].name();
+					break;
+				}
+			}
+
+			if(nameTableStatic.empty())
+				return "";
+
+			fromResult += " "+ cJoin +" JOIN "+ (*it).name() +" ON "+ nameTableStatic +"."+ colTableStatic;
+			fromResult += " = " + (*it).name() +"."+ (*it).linkName() +")";
+			parClause += "(";
+		}
+
+		++it;
+		cJoin = " LEFT ";
+	}
+
+	return (parClause + fromResult);
+}
+
+
+// ---- Handle class - TeTable
+
+TeTable::TeTable():
+	id_(-1),
+	name_(""),
+	type_(TeAttrStatic),
+	order_(-1),
+	attLink_(""),
+	attUnique_(""),
+	separator_(','),
+	attInitialTime_(""),
+	attFinalTime_(""),
+	attTimeUnit_(TeSECOND),
+	relatedTableId_(-1),
+	relatedAttribute_("")
+{
+	pImpl_ = new TeTableImpl;
+	pImpl_->refCount_ = 1;	
+}
+
+TeTable::TeTable(const string& name):
+	id_(-1),
+	name_(name),
+	type_(TeAttrStatic),
+	order_(-1),
+	attLink_(""),
+	attUnique_(""),
+	separator_(','),
+	attInitialTime_(""),
+	attFinalTime_(""),
+	attTimeUnit_(TeSECOND),
+	relatedTableId_(-1),
+	relatedAttribute_("")
+{
+	pImpl_ = new TeTableImpl;
+	pImpl_->refCount_ = 1;	
+}
+
+TeTable::TeTable(const string& name, const TeAttributeList& attList, const string& uniqueName,
+				 const string& linkName, TeAttrTableType tableType):
+	id_(-1),
+	name_(name),
+	type_(tableType),
+	order_(-1),
+	attList_(attList),
+	attLink_(linkName),
+	attUnique_(uniqueName),
+	separator_(','),
+	attInitialTime_(""),
+	attFinalTime_(""),
+	attTimeUnit_(TeSECOND),
+	relatedTableId_(-1),
+	relatedAttribute_("")
+{
+	pImpl_ = new TeTableImpl;
+	pImpl_->refCount_ = 1;	
+}
+
+TeTable::~TeTable()
+{
+	if ( --(pImpl_->refCount_) <= 0 )
+		delete pImpl_;	
+	attList_.clear();
+}
+
+// Copy constructor
+// copies the representation pointer
+// increments the reference counter
+
+TeTable::TeTable(const TeTable& other)
+{
+	id_= other.id_;
+	name_ = other.name_;
+	type_ = other.type_;
+	attLink_ = other.attLink_;
+	attUnique_ = other.attUnique_;
+	separator_ = other.separator_;
+	order_ = other.order_;
+	attInitialTime_ = other.attInitialTime_;
+	attFinalTime_ = other.attFinalTime_;
+	attTimeUnit_ = other.attTimeUnit_;
+	attList_.clear();
+	attList_.resize(other.attList_.size());
+	attList_=other.attList_;
+	relatedTableId_ = other.relatedTableId_;
+	relatedTableName_ = other.relatedTableName_;
+	relatedAttribute_ = other.relatedAttribute_;
+	pImpl_ = other.pImpl_;
+	pImpl_->refCount_++;
+}
+
+// Operator =
+// Copies the representation pointer
+// Decrements the reference counter of the current object
+// Increments the reference counter for the new object
+TeTable& 
+TeTable::operator=(const TeTable& rhs)
+{
+	if ( this != &rhs )
+	{
+		rhs.pImpl_->refCount_++;
+	
+		if ( --(pImpl_->refCount_) <= 0 )
+			delete pImpl_;
+		pImpl_ = rhs.pImpl_;
+
+		separator_ = rhs.separator_;
+		attLink_ = rhs.attLink_;
+		attUnique_ = rhs.attUnique_;
+		order_ = rhs.order_;
+		attInitialTime_ = rhs.attInitialTime_;
+		attFinalTime_ = rhs.attFinalTime_;
+		attTimeUnit_ = rhs.attTimeUnit_;
+		type_ = rhs.type_;
+		name_ = rhs.name_;	
+		attList_.clear();
+		attList_ = rhs.attList_;
+		relatedTableId_ = rhs.relatedTableId_;
+		relatedTableName_ = rhs.relatedTableName_;
+		relatedAttribute_ = rhs.relatedAttribute_;
+		id_ = rhs.id_;
+	}
+	return *this;
+}
+
+bool 
+TeTable::setTableType( TeAttrTableType attType, int relatedTableId, const string& relatedAttribute)
+{ 
+	type_ = attType; 
+	if ( attType == TeAttrExternal && relatedTableId > 0 && !relatedAttribute.empty())
+	{
+		relatedTableId_ = relatedTableId;
+		relatedAttribute_ = relatedAttribute;
+
+		return true;
+	}
+	return false;
+}
+
+void
+TeTable::add ( const TeTableRow& row )
+{
+	pImpl_->add ( row );
+}
+
+void
+TeTable::setValue (int row, int col, string& val)
+{
+	pImpl_->setValue (row,col,val);
+}
+
+unsigned int
+TeTable::size ()
+{
+	return pImpl_->size();
+}
+
+void TeTable::clear ()
+{
+	pImpl_->clear();
+}
+
+TeTableRow
+TeTable::operator [] (int i) 
+{
+	return pImpl_->operator [] ( i );
+}
+
+string 
+TeTable::operator () ( int row, int col )
+{
+	return pImpl_->operator () (row, col );
+}
+
+
+bool
+TeTable::attrLink(TeAttribute& att)
+{	
+	TeAttributeList::iterator it = attList_.begin();
+	while (it != attList_.end())
+	{
+		if (TeConvertToUpperCase((*it).rep_.name_) == TeConvertToUpperCase(attLink_))
+		{
+			att = (*it);
+			return true;
+		}
+		++it;
+	}
+	return false;
+}
+
+bool 
+TeTable::attrUnique(TeAttribute& attr)
+{
+	TeAttributeList::iterator it = attList_.begin();
+	while(it!=attList_.end())
+	{
+		if(TeConvertToUpperCase((*it).rep_.name_) == TeConvertToUpperCase(attUnique_))
+		{
+			attr = (*it);
+			return true;
+		}
+		++it;
+	}
+	return false;
+}
+
+int
+TeTable::attrLinkPosition()
+{
+	int i = 0;
+	TeAttributeList::iterator it = attList_.begin();
+	while (it != attList_.end())
+	{
+		if (TeConvertToUpperCase((*it).rep_.name_) == TeConvertToUpperCase(attLink_))
+			return i;
+		++it;
+		++i;
+	}
+	return -1;
+}
+
+int
+TeTable::attrUniquePosition()
+{
+	int i = 0;
+	TeAttributeList::iterator it = attList_.begin();
+	while (it != attList_.end())
+	{
+		if (TeConvertToUpperCase((*it).rep_.name_) == TeConvertToUpperCase(attUnique_))
+			return i;
+		++it;
+		++i;
+	}
+	return -1;
+}
+
+bool 
+TeTable::attributeNames(vector<string>& attrs)
+{
+	attrs.clear();
+	TeAttributeList::iterator it = attList_.begin();
+	while(it!=attList_.end())
+	{
+		attrs.push_back((*it).rep_.name_);
+		++it;
+	}
+	return true;
+}
+
+
+void 
+TeTable::primaryKeys(vector<string>& keys)
+{
+	keys.empty();
+	TeAttributeList::iterator it = attList_.begin();
+	while(it!=attList_.end())
+	{
+		if((*it).rep_.isPrimaryKey_)
+			keys.push_back((*it).rep_.name_);
+		++it;
+	}
+	return;
+}
diff --git a/src/terralib/kernel/TeTable.h b/src/terralib/kernel/TeTable.h
new file mode 100644
index 0000000..19be8a1
--- /dev/null
+++ b/src/terralib/kernel/TeTable.h
@@ -0,0 +1,393 @@
+ /************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeTable.h
+    \brief This file contains class TeTable definitions.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_TABLE_H
+#define  __TERRALIB_INTERNAL_TABLE_H
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include <string>
+#include <vector>
+#include "TeComposite.h"
+using namespace std;
+
+#include "TeAttribute.h"
+
+class TeTableImpl;
+
+//! A table row is a vector of strings
+typedef vector<string> TeTableRow;
+
+//! The table implementation, this is the body class, of the handle/body idiom
+/*!
+	All members are private. This class is used only through the TeTable class
+*/
+class TL_DLL TeTableImpl: public TeComposite<TeTableRow>
+{
+
+friend class TeTable;
+
+	int refCount_;
+
+	//! Empty constructor
+	TeTableImpl(): refCount_(0){}
+
+	//! Returns the value of a cell in table
+	string operator () ( int row, int col )
+	{
+		return components_[row].operator[] ( col );
+	}
+
+	void setValue (int row, int col, string& val)
+	{
+		TeTableRow tRow = components_[row];
+		if (col >= (int)(tRow.size()))
+			tRow.resize(col+1);
+		tRow[col] = val;
+		components_[row] = tRow;
+	}
+
+};
+
+//! An attribute table in memory
+/*!
+	Instances of this classes represent non-spatial tables, or tables
+	that don�t have a spatial data as one of its columns.
+	The class stores the table schema and it also can store rows of data.
+
+	Rows of data are stored according to handle/hody idiom, to make
+	copies optimized.
+
+  \sa
+  TeAttribute TeTableImpl
+*/
+class TL_DLL TeTable
+{
+public:
+	//! Empty constructor
+	/*!
+		\note
+		Instance of TeTable will be created with the following default values:
+		\arg name: "" (empty)
+		\arg id_:  -1 (no database identifier)
+        \arg type_: static attribute table
+		\arg attList: empty list of attributes
+        \arg attLink_:	"" (no index to geometries)
+        \arg attUnique_: "" (no unique values)
+		\arg separator_: ','  comma separator (used to read ASCII tables from files)
+		\arg attInitialTime_: ""  no initial time information
+		\arg attFinalTime_: ""  no final time information
+		\arg attTimeUnit_: TeYear 
+		\arg relatedTableId: -1 (no relation to other table)
+		\arg relatedTableName: "" (name of the related table)
+		\arg relatedAttribute: "" (attribute of the related table)
+	*/
+	TeTable();
+
+	//! Constructor by name
+	/*!
+		\param name table name
+		\note
+		Instance of TeTable will be created with the following default values:
+		\arg id_:  -1 (no database identifier)
+        \arg tableType_: static attribute table
+		\arg attList: empty list of attributes
+        \arg attLink_:	"" (no index to geometries)
+        \arg attUnique_: "" (no unique values)
+		\arg separator_: ','  comma separator (used to read ASCII tables from files)
+		\arg attInitialTime_: ""  no initial time information
+		\arg attFinalTime_: ""  no final time information
+		\arg attTimeUnit_: TeYear 
+		\arg relatedTableId: -1 (no relation to other table)
+		\arg relatedTableName: "" (name of the related table)
+		\arg relatedAttribute: "" (attribute of the related table)
+	*/
+	TeTable(const string& name);
+
+	//! Constructor by name and attribute list
+	/*!
+      \param name table name
+      \param attList list of attributes
+	  \param uniqueName column that unique attributes to be used as a primary key
+	  \param linkName column that links attributes to geometries
+	  \param tableType type of attribute table
+	  \note
+		Instance of TeTable will be created with the following default values:
+	   \arg id_:  -1 (no database identifier)
+	   \arg separator_: ','  comma separator (used to read ASCII tables from files)
+	   \arg attInitialTime_: ""  no initial time information
+	   \arg attFinalTime_: ""  no final time information
+	   \arg attTimeUnit_: TeYear 
+	   \arg relatedTableId: -1 (no relation to other table)
+	   \arg relatedTableName: "" (name of the related table)
+	   \arg relatedAttribute: "" (attribute of the related table)
+	*/
+	TeTable(const string& name, const TeAttributeList& attList, const string& uniqueName,
+			const string& linkName="", TeAttrTableType tableType=TeAttrStatic);
+
+	 //! Destructor
+	~TeTable();
+
+	//! Copy Constructor
+	/*! Copies the representation pointer increments the reference counter	*/
+	TeTable(const TeTable&);
+
+	//! Operator =
+	/*!
+		Copies the representation pointer
+		Decrements the reference counter of the current object
+		Increments the reference counter for the new object
+	*/
+	TeTable& operator=(const TeTable&);
+
+// -- Methods
+
+	//! Returns the table name
+	string name()
+	{ return name_; }
+
+	//! Sets the table name
+	void name(const string& n)
+	{ name_ = n; }
+
+	//! Returns the unique id of the table in a database
+	int id() { return id_; }
+
+	//! Sets the id of the table
+	void setId(int n) { id_ = n; }
+
+	//! Set the position of the table in a join
+	void setOrder(int n) { order_ = n; }
+
+	//! Get the position of the table in a join
+	int getOrder() { return order_;}
+	
+	//! Defines the list of attributes of this table
+	void setAttributeList ( const TeAttributeList& attList)
+	{ attList_ = attList; }
+
+	//! Retrieves the list of attributes of this table
+	TeAttributeList& attributeList()
+	{ return attList_; }
+
+	//! Retrieves the list of attribute names of this table
+	bool attributeNames(vector<string>& attrs);
+	
+	//! Returns the type of this attribute table
+	TeAttrTableType tableType()
+	{ return type_; }
+
+	//! Sets the table separator
+	void setSeparator ( const char& c )
+	{ separator_ = c ; }
+
+	//! Returns the table separator
+	char separator ()
+	{ return separator_; }
+
+	//! Sets the table type
+	/*!
+      \param attType table type
+	  \note In case of external tables
+      \param relatedTableId is the id of the related table 
+	  \param relatedAttribute is column name of the related table
+	*/
+	bool setTableType( TeAttrTableType attType, int relatedTableId=-1, const string& relatedAttribute="");
+
+	//! Sets an attribute as the table index.
+	/*!
+		Index in this context, means an attribute that is a link between
+		the attribute table and a spatial table (a table of geometrical
+		representation of objects).
+	*/
+	void setLinkName ( const string& linkName ) { attLink_ = linkName;}
+
+	//! Returns the name of the column used as link between the attribute table and a spatial table
+	string linkName()
+	{	return attLink_; }
+
+	//! Sets the name of the column that has unique values
+	void setUniqueName ( const string& uniqueName ) { attUnique_ = uniqueName; }	
+
+	//! Returns the name of the column used as primary key
+	string uniqueName()
+	{	return attUnique_;	}
+
+	//! If there is one, returns the attribute used as an index
+	/*!
+		\param att to return the attribute used as an index
+		\return TRUE if there is an index, FALSE otherwise
+	*/
+	bool attrLink(TeAttribute& att);
+
+	//! If there is one, returns the attribute used as primary key
+	/*!
+		\param attr to return the attribute used as primary key
+		\return TRUE if there is an index, FALSE otherwise
+	*/
+	bool attrUnique(TeAttribute& attr);
+	
+	//! Returns the position of the link attribute in the attribute list
+	int attrLinkPosition();
+
+	//! Returns the position of the unique attribute in the attribute list
+	int attrUniquePosition();
+
+	/** @name External tables
+	    The following members are used to manipulate information about tables that
+		are external: don�t have a direct link to geometries, but can be linked by
+		a column to another attribute table
+	*/
+	//@{
+	//! Sets the  id of a table to which this is related (only for TeAttrExternal tables)
+	void relatedTableId(int id)
+	{   relatedTableId_ = id; }
+
+	//! Returns the id of a related table (only for TeAttrExternal tables)
+	int relatedTableId()
+	{   return relatedTableId_; }
+
+	//! Sets the name of a table to which this is related (only for TeAttrExternal tables)
+	void relatedTableName(string tableName)
+	{   relatedTableName_ = tableName; }
+
+	//! Returns the name of a related table (only for TeAttrExternal tables)
+	string relatedTableName()
+	{   return relatedTableName_; }
+
+	//! Set the name of a column to link to a related table (only for TeAttrExternal tables)
+	void relatedAttribute(const string& columnName)
+	{	relatedAttribute_ = columnName; }
+
+	//! Return the column that links to a related table (only for TeAttrExternal tables)
+	string relatedAttribute()
+	{ return relatedAttribute_; }
+
+	//@}
+
+	/** @name Temporal Attributes
+	    The following members are used to manipulate the attribute tables with temporal
+		information.
+		\par Temporal tables contains columns to store a time interval in which the 
+		 attributes (or a row) of an object is valid.
+	*/
+	//@{		
+
+	//! Sets the name of the column that has the initial time of the validity interval
+	void attInitialTime(const string& t)
+	{	attInitialTime_ = t; }
+
+	//! Returns the name of the column that has the initial time of the validity interval
+	string attInitialTime()
+	{	return attInitialTime_; }
+
+	//! Sets the name of the column that has the final time of the validity interval
+	void attFinalTime(const string& t)
+	{	attFinalTime_ = t; }
+
+	//! Returns the name of the column that has the final time of the validity interval
+	string attFinalTime()
+	{	return attFinalTime_; }
+
+	//! Sets the time unit relative to the validity interval
+	void attTimeUnit(TeChronon t)
+	{	attTimeUnit_ = t; }
+
+	//! Returns the time unit relative to the validity interval
+	TeChronon attTimeUnit()
+	{	return attTimeUnit_; }
+	//@}
+
+	/** @name Data in Memory
+	    The following members are used to manipulate rows of the table in memory
+	*/
+	//@{
+	//! Add a row to a table
+	void add ( const TeTableRow& row );
+
+	//! Returns the i-th row
+	TeTableRow operator [] ( int row ) ;
+
+	//! Returns the element indexed by (row,col)
+	string operator () ( int row, int col );
+
+	//! Sets the value of a cell indexed by row x col to value val
+	void setValue (int row, int col, string& val);
+
+	//! Returns the number of rows in a table
+	unsigned int size ();
+
+	//! Clears the table storage in memory
+	void clear ();
+	//@}
+
+	//! Returns the primary key names of the table 
+	void primaryKeys(vector<string>& keys);
+
+private:
+	
+	int					id_;	// unique id from a database where this table may be stored
+	string				name_;	// name
+	TeAttrTableType		type_;	// type of table
+	int					order_; // the table position relative to others in a join 
+
+	TeAttributeList		attList_;		// list of attributes
+	string				attLink_;		// attribute that links objects to their spatial representation
+										// in case of external table it is used to link to the related table
+	string				attUnique_;		// primary key 
+	char                separator_;		// in case of CSV table 
+
+// --- The following attributes are relative to tables with temporal information
+ 
+	string		attInitialTime_;	// initial time attribute
+	string		attFinalTime_;		// final time attribute
+	TeChronon	attTimeUnit_;		// time granularity
+
+// --- The following attributes are relative to external tables
+ 	int		relatedTableId_;	// id of a table to which this is related	
+ 	string	relatedTableName_;	// name of a table to which this is related	
+	string  relatedAttribute_;	// column name of table which this is related
+
+// -- Table Implementation
+	TeTableImpl* pImpl_;		// the rows of a table
+
+};
+
+//! A vector of tables
+typedef vector<TeTable> TeAttrTableVector;
+
+//! Return the sql join related with the table vector  
+TL_DLL string tableJoin(TeAttrTableVector& vecTable, string firstTable="", string attrLink=""); 
+
+/*! \example createTable.cpp
+	Shows how to execute some operations relative to attribute tables.
+ */
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeTemporalSeries.cpp b/src/terralib/kernel/TeTemporalSeries.cpp
new file mode 100644
index 0000000..638a6fb
--- /dev/null
+++ b/src/terralib/kernel/TeTemporalSeries.cpp
@@ -0,0 +1,290 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeTemporalSeries.h"
+#include "TeDatabase.h"
+
+
+TeTSEntry::TeTSEntry(const double& val, TeTimeInterval& time, int timeFrame, int nItens, TeTSDataType dType)
+{
+	timeFrame_= timeFrame;
+	value_ = val;
+	type_ = dType;
+	nItens_ = nItens;
+	time_ = time;
+	timeInt_ = -1;
+
+	if (time.intervalChronon()==TeMONTHOFYEAR) 
+		timeInt_ = time.getT1().month();
+	else if(time.intervalChronon()==TeDAYOFMONTH)
+		timeInt_ = time.getT1().day();
+	else if(time.intervalChronon()==TeDAYOFWEEK)
+		timeInt_ = time.getT1().weekDay();
+	else if(time.intervalChronon()==TeDAYOFYEAR)
+		timeInt_ = time.getT1().yearDay();
+	else if(time.intervalChronon()==TeHOUROFDAY)
+		timeInt_ = time.getT1().hour();
+	else if(time.intervalChronon()==TeMINUTEOFHOUR)
+		timeInt_ = time.getT1().minute();
+	else if(time.intervalChronon()==TeSECONDOFMINUTE)
+		timeInt_ = time.getT1().hour();
+}
+
+
+
+TeTSEntry& 
+TeTSEntry::operator=(const TeTSEntry& other)
+{
+	if ( this != &other )
+	{
+		timeFrame_ = other.timeFrame_;
+		value_ = other.value_;
+		time_ = other.time_;
+		nItens_ = other.nItens_;
+		type_ = other.type_;
+		timeInt_ = other.timeInt_;
+	}
+	return (*this);
+}
+
+TeTSParams& 
+TeTSParams::operator=(const TeTSParams& other)
+{
+	if ( this != &other )
+	{
+		type_ = other.type_;
+  		chronon_ = other.chronon_;
+  		time_ = other.time_; 
+  		timeOper_ = other.timeOper_;
+  		spatOper_ = other.spatOper_;
+  	  	orTheme_ = other.orTheme_;
+		objectId_ = other.objectId_;
+  		attrTable_ = other.attrTable_;	
+		attrColumn_ = other.attrColumn_;
+	}
+	return (*this);
+}
+
+
+TeTemporalSeries& 
+TeTemporalSeries::operator=(const TeTemporalSeries& other)
+{
+	if ( this != &other )
+	{
+		TSparams_ = other.TSparams_;
+		series_ = other.series_;
+	}
+	return (*this);
+}
+
+
+bool 
+TeTemporalSeries::getTSEntry(TeTSEntry& ts, unsigned int frame)
+{
+	if(frame >= (series_.size()))
+		return false;
+
+	ts = series_[frame];
+	return true;
+}
+
+bool 
+TeTemporalSeries::buildFrameIntervals()
+{
+	// ----- information about temporal table 
+	TeTable tempTable;
+	TeDatabase* db = TSparams_.orTheme_->layer()->database();
+
+	if(!TSparams_.orTheme_->getTemporalTable(tempTable))
+		return false;
+
+	TSparams_.attrTable_ = tempTable.name();
+	string initialtime = tempTable.name() +"."+ tempTable.attInitialTime(); 
+	string finaltime = tempTable.name() +"."+ tempTable.attFinalTime(); 
+
+	TeTime iTime, fTime;
+	
+	// ----- fill time interval
+	// ---------------------------- you don�t know how many time frames will be generated
+
+	if(	(TSparams_.chronon_==TeYEAR)   || (TSparams_.chronon_==TeMONTH) ||
+		(TSparams_.chronon_==TeDAY)    || (TSparams_.chronon_==TeHOUR)  ||
+		(TSparams_.chronon_==TeMINUTE) || (TSparams_.chronon_==TeSECOND) )
+	{
+		
+		string fromClause, whereClause;
+		if(!db->tableExist(TSparams_.orTheme_->collectionAuxTable()))
+		{
+			TeAttrTableVector atts; 
+			TSparams_.orTheme_->getAttTables(atts); 
+			if(atts.empty())
+				return false;
+
+			fromClause = " FROM " + tableJoin(atts);
+			whereClause = TSparams_.orTheme_->sqlWhereRestrictions();
+		}
+		else
+		{
+			//fromClause = TSparams_.orTheme_->sqlGridFrom();
+			string collAuxTable = TSparams_.orTheme_->collectionAuxTable();
+			string uniqueIdName = tempTable.name() +"."+ tempTable.uniqueName(); 
+			string objectIdName = tempTable.name() +"."+ tempTable.linkName(); 
+
+			fromClause = " FROM "+ tempTable.name()+" RIGHT JOIN "+ collAuxTable; 
+			
+			if(tempTable.tableType()==TeFixedGeomDynAttr)
+			{
+				fromClause += " ON "+ uniqueIdName +" = ";
+				fromClause += collAuxTable +".aux0";
+			}
+			else
+			{
+				fromClause += " ON "+ objectIdName +" = ";
+				fromClause += collAuxTable +".object_id";
+			}
+		}
+
+		string sql = " SELECT min("+ initialtime +"), max("+ finaltime +") ";
+		sql += fromClause;	
+		
+		if(!whereClause.empty())
+			sql += " WHERE "+ whereClause;
+
+		TeDatabasePortal* portal = db->getPortal();
+		if(!portal)
+			return false;
+
+		if((!portal->query(sql)) || (!portal->fetchRow()))
+		{
+			delete portal;
+			return false;
+		}
+
+		//fill the temporal series
+        TeTime date1 =  portal->getDate(0);
+        TeTime date2 =  portal->getDate(1);
+		TeTimeInterval interval(date1, date2);
+		interval.intervalChronon(TSparams_.chronon_); //min/max
+
+		iTime = interval.getT1();
+ 		fTime = interval.getT2();
+
+		delete (portal);
+	}
+
+	// ---------------------------- you know how many time frames will be generated
+
+	else if (TSparams_.chronon_==TeMONTHOFYEAR) 
+	{
+		TeTime t1("01/01/2001", TeMONTHOFYEAR, "DDsMMsYYYY");
+		TeTime t2("01/12/2001", TeMONTHOFYEAR, "DDsMMsYYYY");
+		iTime = t1;
+		fTime = t2;
+	}
+	else if(TSparams_.chronon_==TeDAYOFMONTH)
+	{
+		TeTime t1("01/01/2001", TeDAYOFMONTH, "DDsMMsYYYY");
+		TeTime t2("31/01/2001", TeDAYOFMONTH, "DDsMMsYYYY");
+		iTime = t1;
+		fTime = t2;
+	}
+	else if(TSparams_.chronon_==TeDAYOFWEEK)
+	{
+		TeTime t1("07/01/2001", TeDAYOFWEEK, "DDsMMsYYYY");
+		TeTime t2("13/01/2001", TeDAYOFWEEK, "DDsMMsYYYY");
+		iTime = t1;
+		fTime = t2;
+	}
+	else if(TSparams_.chronon_==TeDAYOFYEAR)
+	{
+		TeTime t1("01/01/2001", TeDAYOFYEAR, "DDsMMsYYYY");
+		TeTime t2("31/12/2001", TeDAYOFYEAR, "DDsMMsYYYY");
+		iTime = t1;
+		fTime = t2;
+	}
+	else if(TSparams_.chronon_==TeHOUROFDAY)
+	{
+		TeTime t1("01/01/2001 00", TeHOUROFDAY, "DDsMMsYYYYsHH");
+		TeTime t2("01/01/2001 23", TeHOUROFDAY, "DDsMMsYYYYsHH");
+		iTime = t1;
+		fTime = t2;
+	}
+	else if(TSparams_.chronon_==TeMINUTEOFHOUR)
+	{
+		TeTime t1("01/01/2001 00:00", TeMINUTEOFHOUR, "DDsMMsYYYYsHHsmm");
+		TeTime t2("01/01/2001 00:59", TeMINUTEOFHOUR, "DDsMMsYYYYsHHsmm");
+		iTime = t1;
+		fTime = t2;
+	}
+	else if(TSparams_.chronon_==TeSECONDOFMINUTE)
+	{
+		TeTime t1("01/01/2001 00:00:00", TeSECONDOFMINUTE, "DDsMMsYYYYsHHsmmsSS");
+		TeTime t2("01/01/2001 00:00:59", TeSECONDOFMINUTE, "DDsMMsYYYYsHHsmmsSS");
+		iTime = t1;
+		fTime = t2;
+	}
+
+	int timeFrame = 0;
+	while (iTime <= fTime)
+	{
+		TeTimeInterval inter(iTime,iTime);
+		inter.intervalChronon(TSparams_.chronon_); //min/max
+		TeTSEntry tsEntry(0., inter, timeFrame);
+		this->series_.push_back(tsEntry);
+		++iTime;
+		++timeFrame;
+	}
+
+	return true;
+}
+
+bool 
+TeTemporalSeries::setTSEntryValue(unsigned int frame, double val, TeTSDataType type)
+{
+
+	TeTSEntry entry;
+	if(!getTSEntry(entry, frame))
+		return false;
+
+	double val1 = entry.value_;
+	double result = val1;
+
+	if(TSparams_.timeOper_==TeCOUNT)
+		result += 1;
+	else if (TSparams_.timeOper_==TeSUM)
+		result += val;
+	else if ((TSparams_.timeOper_==TeMAXVALUE) && (val>val1))
+		result = val;
+	else if((TSparams_.timeOper_==TeMINVALUE) && (val<val1))
+		result = val;
+	else if(TSparams_.timeOper_==TeMEAN)
+		result = (val1+val)/2;
+
+	series_[frame].value_ = result;
+	series_[frame].type_ = type;
+	return true;
+}
+
+
+
+
diff --git a/src/terralib/kernel/TeTemporalSeries.h b/src/terralib/kernel/TeTemporalSeries.h
new file mode 100644
index 0000000..c4630b3
--- /dev/null
+++ b/src/terralib/kernel/TeTemporalSeries.h
@@ -0,0 +1,192 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeTemporalSeries.h
+    \brief This file contains structures and definitions to deal with temporal series.
+*/
+
+#ifndef  __TERRALIB_INTERNAL_TS_H
+#define  __TERRALIB_INTERNAL_TS_H
+
+
+#include "TeTheme.h"
+#include "TeTimeInterval.h"
+
+
+/* 
+	ATTR_DYN: a spatial object with a dynamic attribute 
+	ATTR_DYN_GROUP: some spatial objects with a dynamic attribute table 
+	EVENT: count of events
+	ATTR_EVENT: grouping the attributes of the events
+*/
+//!	type of temporal series
+enum TeTSType  { TeATTRDYN, TeATTRDYNGROUP, TeEVENT, TeATTREVENT};
+
+ 
+//! type of the data collected in the serie temporal 
+enum TeTSDataType  { TeDATA, TeMISSING, TeDMISSING, TeOUTLIER, TeDOUTLIER, TePREDICTION };
+
+
+//! A class that represent each time frame of a temporal series
+class TL_DLL TeTSEntry
+{
+public:
+	int					timeFrame_;  //the time frame of the temporal series 
+	double 				value_;
+	TeTSDataType 		type_; 
+	int 				nItens_; //number of instances
+	TeTimeInterval		time_;
+	int					timeInt_;
+
+	//! Constructor
+	TeTSEntry(): 
+		timeFrame_(-1),
+		value_(0), 
+		type_(TeMISSING), 
+		nItens_(0),
+		timeInt_(-1)
+		{}
+
+	//! Constructor
+	TeTSEntry(const double& val, TeTimeInterval& time, int timeFrame=-1, int nItens=0, TeTSDataType dType=TeMISSING); 
+		
+	
+	//! Copy constructor
+	TeTSEntry(const TeTSEntry& other)
+	{
+		timeFrame_ = other.timeFrame_;
+		value_ = other.value_;
+		time_ = other.time_;
+		nItens_ = other.nItens_;
+		type_ = other.type_;
+		timeInt_ = other.timeInt_;
+	}
+
+	//! Operator = 
+	TeTSEntry& operator=(const TeTSEntry& other); 
+
+};
+
+//! Parameters of a temporal series
+class TL_DLL TeTSParams 
+{
+public:
+	TeTSType			type_;			//! type of the series
+  	TeChronon			chronon_;		//! Chronon used to generated the series
+  	TeTimeInterval		time_;			//! Date/Time validy 
+  	TeStatisticType		timeOper_; 		//! operator to temporal grouping - to group objects in each time frame
+  	TeStatisticType		spatOper_; 		//! operator to spatial grouping - to group instances to each object 
+  
+	// Measures
+  	TeTheme*		orTheme_;		//Pointer to the origin theme 
+	string			objectId_;
+  	string			attrTable_;	    //temporal table 
+	string			attrColumn_;	//date column 
+
+
+	//! Empty constructor
+	TeTSParams():
+		chronon_(TeNOCHRONON),
+		timeOper_(TeNOSTATISTIC),
+		spatOper_(TeNOSTATISTIC),
+		orTheme_(0),
+		objectId_(""),
+		attrTable_(""),
+		attrColumn_("")
+		{ }
+
+	//! Constructor - - serie type is ATTR_DYN_GROUP, EVENT, ATTR_EVENT
+	TeTSParams(TeTheme* theme, TeChronon chr, const string& table, const string& col, TeStatisticType tOper, TeStatisticType sOper):
+		chronon_(chr),
+		timeOper_(tOper), 
+		spatOper_(sOper),
+		orTheme_(theme),
+		objectId_(""),
+		attrTable_(table),
+		attrColumn_(col)
+		{}
+
+	//! Constructor - serie type is ATTR_DYN
+	TeTSParams(TeTheme* theme, const string& objId, TeChronon chr, const string& table, const string& col, TeStatisticType tOper, TeStatisticType sOper):
+		chronon_(chr),
+		timeOper_(tOper),
+		spatOper_(sOper),
+		orTheme_(theme),
+		objectId_(objId),
+		attrTable_(table),
+		attrColumn_(col)
+		{}
+
+	//! Operator = 
+	TeTSParams& operator=(const TeTSParams& other); 
+}; 
+
+//! A class to represent temporal series
+class TL_DLL TeTemporalSeries
+{
+public:
+	TeTSParams			TSparams_; 
+	vector<TeTSEntry> 	series_; //! serie
+
+	//! Constructor
+	TeTemporalSeries(): 
+		TSparams_(TeTSParams())
+	{}
+
+	//! Constructor
+	TeTemporalSeries(TeChronon chr, TeTheme* theme=0, const string& table="", const string& col="", TeStatisticType tOper=TeNOSTATISTIC, TeStatisticType sOper=TeNOSTATISTIC): 
+		TSparams_(TeTSParams(theme, chr, table, col, tOper, sOper))
+	{}
+
+	//! Constructor
+	TeTemporalSeries(TeTheme* theme, const string& objId, TeChronon chr, const string& table, const string& col, TeStatisticType tOper, TeStatisticType sOper): 
+		TSparams_(TeTSParams(theme, objId, chr, table, col, tOper, sOper))
+	{}
+
+	//! Gets the time frame  (0 until n-1)
+	bool getTSEntry(TeTSEntry& ts, unsigned int frame); 
+
+	//! Operator = 
+	TeTemporalSeries& operator=(const TeTemporalSeries& other); 
+
+	//! Fills the time interval for each frame
+	bool buildFrameIntervals();
+
+	//! Returns the number of time frames
+	int numTimeFrames() { return series_.size(); }
+
+	//! Returns the time of each frame
+	int timeInt(int frame) { return ((series_[frame-1]).timeInt_); }
+
+	//! Sets the temporal series entry value
+	bool setTSEntryValue(unsigned int frame, double val, TeTSDataType type); 
+
+	//! Returns the time of each frame
+	TeTimeInterval time(int frame) { return ((series_[frame-1]).time_); }
+
+};
+
+#endif
+
+
+
+
diff --git a/src/terralib/kernel/TeTheme.cpp b/src/terralib/kernel/TeTheme.cpp
new file mode 100644
index 0000000..8930063
--- /dev/null
+++ b/src/terralib/kernel/TeTheme.cpp
@@ -0,0 +1,2493 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeTheme.h"
+#include "TeDatabase.h"
+#include "TeGroupingAlgorithms.h"
+#include "TeDatabaseUtils.h"
+#include "TeRasterTransform.h"
+#include "TeQuerier.h"
+#include "TeQuerierParams.h"
+
+extern int  yyparse(string& sqlOut);
+extern int  initParse(const string& strIn, TeDatabase* db);
+
+static TeThemeFactory themeFactory;  
+
+TeTheme::TeTheme( const string& name, TeLayer* layer, TeViewNode* parent, const int& view, const int& id)
+		: TeAbstractTheme(name, parent, view, id, TeTHEME),
+		layer_(layer)
+{
+	//layer id
+	if(layer)
+	{
+		layerId_ = layer->id();
+		if (layer_->database())
+			themeBox_ = layer_->box();
+	}
+	else
+		layerId_ = -1;
+}
+
+TeTheme::TeTheme(const TeViewNodeParams& params) : TeAbstractTheme(params),	layer_(0), layerId_(-1)
+{ }
+
+
+// Copy constructor
+TeTheme::TeTheme (const TeTheme& other) : 
+	TeAbstractTheme(other.viewNodeParams_) 
+{
+	layerId_ = other.layerId_;
+	layer_ = other.layer_;      //the same layer pointer
+	collectionTable_ = other.collectionTable_;
+	collectionAuxTable_ = other.collectionAuxTable_;
+	
+	attTableVector_ = other.attTableVector_;
+	sqlFrom_ =  other.sqlFrom_;		
+	sqlJoin_ = other.sqlGridJoin_;
+	sqlGridFrom_ = other.sqlGridFrom_;
+	sqlGridJoin_ = other.sqlGridJoin_;
+	aliasVector_ = other.aliasVector_;
+	sqlAttList_ = other.sqlAttList_;
+	sqlNumAttList_ = other.sqlNumAttList_;		
+}
+
+
+// Destructor
+TeTheme::~TeTheme () 
+{ 
+	clearAttTableVector();
+	clearAttList();
+	collectionTable_.clear();
+	collectionAuxTable_.clear();
+	sqlFrom_.clear();
+	sqlJoin_.clear();
+	sqlGridFrom_.clear();
+	sqlGridJoin_.clear();
+	aliasVector_.clear();
+	sqlAttList_.clear();
+	sqlNumAttList_.clear();
+}
+
+TeTheme& 
+TeTheme::operator= (const TeTheme& other)
+{
+	if ( this != &other )
+	{
+		TeAbstractTheme* absTheme = (TeAbstractTheme*)this;
+		absTheme->operator=(other);
+		layerId_ = other.layerId_;
+		layer_ = other.layer_;      //the same layer pointer
+		
+		collectionTable_ = other.collectionTable_;
+		collectionAuxTable_ = other.collectionAuxTable_;
+		
+		attTableVector_ = other.attTableVector_;
+		sqlFrom_ =  other.sqlFrom_;		
+		sqlJoin_ = other.sqlGridJoin_;
+		sqlGridFrom_ = other.sqlGridFrom_;
+		sqlGridJoin_ = other.sqlGridJoin_;
+		aliasVector_ = other.aliasVector_;
+		sqlAttList_ = other.sqlAttList_;
+		sqlNumAttList_ = other.sqlNumAttList_;
+	}
+	return *this;
+}
+
+
+void TeTheme::layer(TeLayer* layer)
+{
+	layer_ = layer;
+	if (layer)
+	{
+		layerId_ = layer->id();
+//		themeBox_ = layer_->box();
+	}
+}
+
+void 
+TeTheme::setSpatialRest(TeBox& box, TeGeomRep rep, TeSpatialRelation relation)
+{
+	hasSpatialRes_ = true;
+	boxRest_ = box;
+	spatialRelation_ = relation;
+	
+	if(rep==TeGEOMETRYNONE)
+		geomRepRest_ = layer()->vectRepres()[0]->geomRep_;
+	else
+		geomRepRest_ = rep;
+	
+	geomRest_ = 0;
+}
+
+void 
+TeTheme::setSpatialRest(TeGeometry* geom, TeGeomRep rep, TeSpatialRelation relation)
+{
+	hasSpatialRes_ = true;
+	geomRest_ = geom;
+	spatialRelation_ = relation;
+	
+	if(rep==TeGEOMETRYNONE)
+		geomRepRest_ = layer()->vectRepres()[0]->geomRep_;
+	else
+		geomRepRest_ = rep;
+	
+	boxRest_ = TeBox();
+}
+
+string 
+TeTheme::sqlWhereRestrictions(TeRepresentation* rep)
+{
+	TeKeys objs;
+	string whereClause= " 1 = 1 ";
+	TeDatabase* db = layer()->database();
+	
+	// load the first representation 
+	if(!rep)
+		rep = (layer()->vectRepres())[0];
+
+	// temporal restrictions are applied only to temporal tables
+	if(hasTemporalRest())
+	{
+		string result = "";
+		
+		initParse(temporalRest(), db); 
+				
+		if(!yyparse(result))  //0: accept  1: reject
+			whereClause += " AND "+ result;
+		else 
+			return "";
+	}
+			
+	// we should test if the attribute restriction is valid
+	if (hasAttrRest())
+		whereClause += " AND "+ attributeRest();
+
+	// spatial restriction with other geometry representation
+	if (hasSpatialRest() && rep)
+	{
+		if(boxRestriction().isValid())
+		{
+            TeBox b =  boxRestriction();
+            TeGeomRep gRep = rep->geomRep_;
+//			whereClause += " AND "+ db->getSQLBoxWhere(boxRestriction(), rep->geomRep_);
+			whereClause += " AND "+ db->getSQLBoxWhere(b, gRep);
+		}
+		else if(geomRestriction())
+		{
+			string geomTableRest = layer()->tableName(geomRepRestriction());
+			TePrecision::instance().setPrecision(TeGetPrecision(layer()->projection()));
+
+			if(db->spatialRelation(geomTableRest, geomRepRestriction(), geomRestriction(),  
+							   objs, spatialRelation()))
+			{
+				string obs;
+				for(unsigned int i=0; i<objs.size(); i++)
+				{
+					if(i!=0)
+						obs += ",";
+					obs += "'"+ objs[i] +"'";
+				}
+				
+				whereClause += " AND "+ rep->tableName_ +".object_id IN ("+ obs +")";
+			}
+		}
+	}
+	return whereClause;
+}
+
+void TeTheme::createRasterVisual(TeRaster* rst)
+{
+	if (rasterVisual_)
+		delete rasterVisual_;
+
+	if (!rst)
+		rst = layer_->raster();
+
+	if (!rst)
+		return;
+
+	rasterVisual_ = new TeRasterTransform();
+										
+	if (rst->params().photometric_[0] == TeRasterParams::TePallete)  // raster palette -> uses its palette
+	{
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Pallete2ThreeBand);
+		rasterVisual_->setLutSize(rst->params().lutr_.size());
+		return;
+	}
+
+	if (visibleRep_ & 0x40000000  &&		// sliced raster -> generate the
+		grouping_.groupMode_ == TeRasterSlicing)	// appropriate palette
+	{
+		int band = atoi(grouping_.groupAttribute_.name_.c_str());
+		rasterVisual_->setSrcBand(band);
+		if (rst->params().dataType_[band] != TeUNSIGNEDCHAR)
+			rasterVisual_->generateLUT(legend_, 1024, defaultLegend_.visual(TePOLYGONS)->color());
+		else
+			rasterVisual_->generateLUT(legend_, 256, defaultLegend_.visual(TePOLYGONS)->color());
+		rasterVisual_->setTransfFunction(&TeRasterTransform::LUT2ThreeBand);
+		return;
+	}
+
+	if (rst->params().dataType_[0] != TeUNSIGNEDCHAR)	// non unsigned char -> generate linear transformation
+		rasterVisual_->setLinearTransfParameters(rst->params().vmin_[0],rst->params().vmax_[0], 0, 255);
+
+	if (rst->params().nBands() == 1)				
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Mono2ThreeBand);
+	else if (rst->params().nBands() == 3)
+		rasterVisual_->setTransfFunction(&TeRasterTransform::ThreeBand2RGB);
+	else
+		rasterVisual_->setTransfFunction(&TeRasterTransform::Band2Band);
+}
+
+
+
+bool
+TeTheme::buildCollection(std::string objectId)
+{
+	if(id()==0)
+		return false;
+	
+	if(!populateCollection(objectId))
+		return false;
+
+	if(!populateCollectionAux(objectId))
+		return false;
+
+	return true;
+}
+
+bool  
+TeTheme::buildGrouping(const TeGrouping& g, TeSelectedObjects selectedObjects, 
+						 vector<double>* dValuesVec)   
+{
+	return buildGrouping(layer_->database(), g, selectedObjects, dValuesVec);
+}
+
+bool  
+TeTheme::buildGrouping(TeDatabase* db, const TeGrouping& g, TeSelectedObjects selectedObjects, vector<double>* dValuesVec)   
+{ 
+	if(!db)
+		return false;
+	grouping_ = g;
+	unsigned int i;
+	vector<TeSlice> slices;
+	int	nullValues = 0;
+	if (grouping_.groupMode_ == TeRasterSlicing)
+	{
+		int b = atoi(grouping_.groupAttribute_.name_.c_str());
+		if (!layer_->raster() ||  
+			b < 0 ||
+			b > layer_->raster()->params().nBands() ||
+			grouping_.groupNumSlices_ <= 0)
+			return false;
+
+		if (grouping_.groupMaxVal_ == TeMINFLOAT)
+			grouping_.groupMaxVal_ = layer_->raster()->params().vmax_[b];
+
+		if (grouping_.groupMinVal_ == TeMAXFLOAT)
+			grouping_.groupMinVal_ = layer_->raster()->params().vmin_[b];
+
+		TeGroupByEqualStep(grouping_.groupMinVal_, grouping_.groupMaxVal_,
+			grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+	}
+	else
+	{
+        if(grouping_.groupAttribute_.name_.empty())
+			return false;
+
+		//verify what the objects will be considered
+		string	input;
+		if(selectedObjects == TeSelectedByPointing)
+		{
+			input = " WHERE (grid_status = 1 OR grid_status = 3";
+			input += " OR (grid_status is null AND (c_object_status = 1 OR c_object_status = 3)))";
+		}
+		else if(selectedObjects == TeNotSelectedByPointing)
+		{
+			input = " WHERE (grid_status = 0 OR grid_status = 2";
+			input += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 2)))";
+		}
+		else if(selectedObjects == TeSelectedByQuery)
+		{
+			input = " WHERE (grid_status = 2 OR grid_status = 3";
+			input += " OR (grid_status is null AND (c_object_status = 2 OR c_object_status = 3)))";
+		}
+		else if(selectedObjects == TeNotSelectedByQuery)
+		{
+			input = " WHERE (grid_status = 0 OR grid_status = 1";
+			input += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 1)))";
+		}
+		else if(selectedObjects == TeGrouped)
+		{
+			input = " WHERE c_legend_id <> 0";
+		}
+		else if(selectedObjects == TeNotGrouped)
+		{
+			input = " WHERE c_legend_id = 0";
+		}
+
+		TeDatabasePortal* portal = db->getPortal();
+		string query;
+		bool normal = false;
+		string aggrFunc = "";
+		if(grouping_.groupFunction_.empty())
+			aggrFunc = " MIN";
+		else
+			aggrFunc = grouping_.groupFunction_;
+
+		if(grouping_.groupNormAttribute_.empty())
+		{
+			query = " SELECT "+ aggrFunc +"("+ grouping_.groupAttribute_.name_ +")";  
+		}
+		else
+		{
+			query = " SELECT "+ aggrFunc +"("+ grouping_.groupAttribute_.name_ +") / "+ aggrFunc +"("+ grouping_.groupNormAttribute_ + ")";
+			normal = true;
+		}
+		query += sqlGridFrom(); 
+		
+		if(selectedObjects != TeAll)
+			query += input;
+		query += " GROUP BY " + collectionTable() + ".c_object_id";
+		if(!portal->query(query) || !portal->fetchRow())
+		{
+			delete portal;
+			return false;
+		}
+		vector<double> dValues;  //inputvect
+		vector<string> sValues;	//svec
+		double mean, sum; 
+		mean = sum = 0.;
+		do  
+		{
+			string val = portal->getData(0);
+			string valNorm = Te2String(atof(val.c_str()), grouping_.groupPrecision_);
+
+			if (!val.empty())
+			{
+				if(grouping_.groupMode_== TeUniqueValue)
+				{
+					if(normal)
+						sValues.push_back(valNorm);
+					else
+						sValues.push_back(val);
+				}
+				else
+				{
+					dValues.push_back(atof(valNorm.c_str()));
+					sum += atof(valNorm.c_str());
+				}
+
+			}
+			else
+				nullValues++;
+		}while(portal->fetchRow());
+		
+		delete portal;
+		
+		if(dValues.empty() && sValues.empty())
+			return false;
+
+		if(grouping_.groupMode_== TeEqualSteps)
+			TeGroupByEqualStep(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeQuantil)
+			TeGroupByQuantil(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeStdDeviation)
+		{
+			string m = Te2String(mean);
+			TeGroupByStdDev(dValues.begin(), dValues.end(), grouping_.groupStdDev_, slices, m, grouping_.groupPrecision_);
+		}
+		else if(grouping_.groupMode_== TeUniqueValue)
+		{
+			if(grouping_.groupFunction_ == "COUNT")
+				TeGroupByUniqueValue(sValues, TeINT, slices, grouping_.groupPrecision_);
+			else
+				TeGroupByUniqueValue(sValues, grouping_.groupAttribute_.type_, slices, grouping_.groupPrecision_);
+		}
+
+		if (dValuesVec)
+		{
+			for (i = 0; i < dValues.size(); ++i)
+				dValuesVec->push_back(dValues[i]);
+		}
+	}
+	if(grouping_.groupNullAttr_ && nullValues > 0)
+	{
+		TeSlice ps;
+		ps.count_ = nullValues;
+		ps.from_ = "Missing Data";
+		slices.push_back(ps);
+		grouping_.groupNumSlices_ = slices.size() - 1;
+	}
+	else
+		grouping_.groupNumSlices_ = slices.size();
+
+	legend_.clear(); 
+	for(i=0; i<slices.size(); ++i)
+	{
+		TeLegendEntry legend(slices[i]);
+		legend.group(i);
+		legend.theme(id());
+		legend_.push_back(legend);
+	}
+	return true;
+}
+
+bool  
+TeTheme::buildGrouping(const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec)   
+{ 
+	return buildGrouping(layer_->database(), g, chr, mapObjValVec);   
+}
+
+bool  
+TeTheme::buildGrouping(TeDatabase* db, const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec)   
+{ 
+	if(!db || chr == TeNOCHRONON)
+		return false;
+
+	grouping_ = g;
+
+	unsigned int i;
+	vector<TeSlice> slices;
+	vector<double> dValues;  //inputvect
+	vector<string> sValues;	//svec
+	double mean, sum; 
+	mean = sum = 0.;
+	int	nullValues = 0;
+	string val;
+
+	if (grouping_.groupMode_ == TeRasterSlicing)
+	{
+		int b = atoi(grouping_.groupAttribute_.name_.c_str());
+		if (!layer_->raster() ||  
+			b < 0 ||
+			b > layer_->raster()->params().nBands() ||
+			grouping_.groupNumSlices_ <= 0)
+			return false;
+
+		if (grouping_.groupMaxVal_ == TeMINFLOAT)
+			grouping_.groupMaxVal_ = layer_->raster()->params().vmax_[b];
+
+		if (grouping_.groupMinVal_ == TeMAXFLOAT)
+			grouping_.groupMinVal_ = layer_->raster()->params().vmin_[b];
+
+		TeGroupByEqualStep(grouping_.groupMinVal_, grouping_.groupMaxVal_,
+			grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+	}
+	else
+	{
+		string func;
+		TeStatisticType statType = TeNOSTATISTIC;
+		if (grouping_.groupMode_ == TeUniqueValue && grouping_.groupAttribute_.type_ == TeSTRING)
+			func = "MIN";
+		else
+			func = grouping_.groupFunction_;
+
+		if (func == "MIN")
+			statType = TeMINVALUE;
+		else if (func == "MAX")
+			statType = TeMAXVALUE;
+		else if (func == "MEAN")
+			statType = TeMEAN;
+		else if (func == "SUM")
+			statType = TeSUM;
+		else if (func == "COUNT")
+			statType = TeCOUNT;
+
+		// Set the flag that indicates the geometries must not be loaded
+		bool loadGeometries = false;
+
+		// Insert the attributes in a multimap that relates the attribute 
+		// representation and its statistic type
+		TeGroupingAttr attrMMap;
+		pair<TeAttributeRep, TeStatisticType> attr1 (
+			TeAttributeRep(grouping_.groupAttribute_), statType);
+		attrMMap.push_back(attr1);
+
+		// Set querier parameters
+		TeQuerierParams querierParams(loadGeometries, attrMMap);
+		querierParams.setParams(this, chr);
+
+		TeQuerier querier(querierParams);
+
+		// Load instances based on the querier parameters given
+		int numFrames = querier.getNumTimeFrames();
+		TeSTInstance sti;
+		string objId;
+		TePropertyVector vec;
+		mapObjValVec.resize(numFrames);
+
+		for (int frame = 0; frame < numFrames; ++frame)
+		{
+			if (querier.loadInstances(frame) == false)
+				continue;
+
+			// Traverse all the instances
+			while(querier.fetchInstance(sti))
+			{
+				objId = sti.objectId();
+				sti.getPropertyValue(val, 0);
+
+				dValues.push_back(atof(val.c_str()));
+				sValues.push_back(val);
+				map<string, string>& objValMap = mapObjValVec[frame];
+				objValMap.insert(make_pair(objId, val));
+			}
+		}
+
+		if(grouping_.groupMode_== TeEqualSteps)
+			TeGroupByEqualStep(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeQuantil)
+			TeGroupByQuantil(dValues.begin(), dValues.end(), grouping_.groupNumSlices_, slices, grouping_.groupPrecision_);
+		else if(grouping_.groupMode_== TeStdDeviation)
+		{
+			string m = Te2String(mean);
+			TeGroupByStdDev(dValues.begin(), dValues.end(), grouping_.groupStdDev_, slices, m, grouping_.groupPrecision_);
+		}
+		else if(grouping_.groupMode_== TeUniqueValue)
+		{
+			if(grouping_.groupFunction_ == "COUNT")
+				TeGroupByUniqueValue(sValues, TeINT, slices, grouping_.groupPrecision_);
+			else
+				TeGroupByUniqueValue(sValues, grouping_.groupAttribute_.type_, slices, grouping_.groupPrecision_);
+		}
+	}
+
+	if(grouping_.groupNullAttr_ && nullValues > 0)
+	{
+		TeSlice ps;
+		ps.count_ = nullValues;
+		ps.from_ = "Missing Data";
+		slices.push_back(ps);
+		grouping_.groupNumSlices_ = slices.size() - 1;
+	}
+	else
+		grouping_.groupNumSlices_ = slices.size();
+
+	legend_.clear(); 
+	for(i=0; i<slices.size(); ++i)
+	{
+		TeLegendEntry legend(slices[i]);
+		legend.group(i);
+		legend.theme(id());
+		legend_.push_back(legend);
+	}
+	
+	return true;
+}
+
+bool 
+TeTheme::getAttTables(TeAttrTableVector& attrs, TeAttrTableType attType)
+{
+	TeAttrTableVector::iterator it = attTableVector_.begin();
+	while (it != attTableVector_.end())
+	{
+		if ((attType == TeAllAttrTypes) || ((*it).tableType() == attType))
+			attrs.push_back((*it));
+		++it;
+	}
+	return (!attrs.empty());
+}
+
+bool 
+TeTheme::getTable(TeTable& table, const string tableName)
+{
+	unsigned int i;
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].name() == tableName)
+		{
+			table = attTableVector_[i];
+			return true;
+		}
+	}
+	return false;
+}
+
+bool 
+TeTheme::getTemporalTable(TeTable& table)
+{
+	TeAttrTableVector::iterator it = attTableVector_.begin();
+	while (it != attTableVector_.end())
+	{
+		if (((*it).tableType() == TeAttrEvent) || ((*it).tableType() == TeFixedGeomDynAttr))
+		{
+			table = (*it); 
+			return true;
+		}
+		++it;
+	}
+	return false;
+}
+
+bool
+TeTheme::saveGrouping(TeSelectedObjects selectedObjects)
+{ 
+	return saveGrouping(layer_->database(), selectedObjects);
+}
+
+bool
+TeTheme::saveGrouping(TeDatabase* db, TeSelectedObjects)
+{ 
+	if(!db)
+		return false;
+
+	vector<TeLegendEntry> legVec = legend_;
+
+	// Delete the theme grouping(if any) from the database
+	if(db->deleteLegend(id()) == false)
+		return false;
+
+	if(grouping_.groupMode_ == TeNoGrouping)
+		return true;
+
+	// Insert the new grouping
+	if(db->insertGrouping(id(), grouping_) == false)
+		return false;
+	
+	legend_ = legVec;
+	// Update (insert) the new legends
+	if (db->updateLegend(legend_) == false)
+		return false;
+
+	setLegendsForObjects();
+
+	if(legend_.size())
+		visibleRep_ = visibleRep_ | 0x40000000;
+	else
+		visibleRep_ = visibleRep_ | 0xbfffffff;
+	string upVis = "UPDATE te_theme SET visible_rep=" + Te2String(visibleRep_) + " WHERE theme_id=" + Te2String(id());
+	return (db->execute(upVis));
+
+	return true;
+}
+
+bool 
+TeTheme::loadThemeTables() 
+{
+	clearAttTableVector();
+	TeDatabase* db = this->layer()->database(); 
+	if(!db)
+		return false;
+	return (db->loadThemeTable(this));
+}
+
+bool 
+TeTheme::addThemeTable(TeTable& inputTable)  
+{
+	bool result = true;
+	TeAttrTableType type = inputTable.tableType();
+
+	if(inputTable.name() == collectionAuxTable_)
+	{
+		loadTablesJoin();
+		return false;
+	}
+	
+	if (type == TeAttrMedia)
+		return false; 
+
+	if(type != TeAttrStatic)
+	{
+		bool hasTemporal = false;
+		bool hasExtern = false; 
+
+		TeAttrTableVector::iterator it = attTableVector_.begin();
+		while(it!=attTableVector_.end())
+		{
+			//temporal
+			if( (it->tableType()==TeAttrEvent) || 
+				(it->tableType()==TeFixedGeomDynAttr) ||
+				(it->tableType()==TeDynGeomDynAttr))
+				hasTemporal = true;
+
+			//extern
+			if((it->tableType())==TeAttrExternal)
+				hasExtern = true;
+
+			++it;
+		}
+
+		if( ((type==TeAttrEvent) || 
+			(type==TeFixedGeomDynAttr) ||
+			(type==TeDynGeomDynAttr)) && (hasTemporal || hasExtern))
+			result = false;
+		else if ((type==TeAttrExternal) && hasTemporal)
+			result = false;
+	}
+
+	if(!result)
+		return false;
+
+	attTableVector_.push_back(inputTable);
+	loadAliasVector();
+	loadAttrLists();
+	loadTablesJoin(); 
+	return true;
+}
+
+void 
+TeTheme::addThemeTable(string tableName)
+{
+	TeTable table(tableName);
+	addThemeTable(table);
+}
+
+bool
+TeTheme::setAttTables(TeAttrTableVector& attrs)
+{	
+	attTableVector_.clear();	
+	int countTemporal = 0;
+	int countExtern = 0;
+	bool result = true;
+
+	TeAttrTableVector::iterator it = attrs.begin();
+	while(it!=attrs.end())
+	{
+		//temporal
+		if( (it->tableType()==TeAttrEvent) || 
+			(it->tableType()==TeFixedGeomDynAttr) ||
+			(it->tableType()==TeDynGeomDynAttr))
+			++countTemporal;
+
+		//extern
+		if(it->tableType()==TeAttrExternal)
+			++countExtern;
+
+		if( (it->tableType()==TeAttrMedia)     ||
+			(countTemporal>0 && countExtern>0) ||
+			(countTemporal>1) ||
+			(it->name() == collectionAuxTable_) )
+		{
+			result = false;
+		}
+		else
+		{
+			attTableVector_.push_back(*it);
+			loadAliasVector();
+			loadAttrLists();
+			loadTablesJoin(); 
+		}
+		++it;
+	}
+	return result;
+}
+
+bool 
+TeTheme::removeThemeTable(unsigned int index)  
+{
+	if (index > (attTableVector_.size() - 1))
+		return false;
+
+	TeAttrTableVector::iterator it;
+	it = attTableVector_.begin() + index;
+
+	attTableVector_.erase(it);
+	loadAliasVector();
+	loadAttrLists();
+	loadTablesJoin();
+	return true; 
+}
+
+string
+TeTheme::getAttribute(unsigned int pos)
+{
+	unsigned int i;
+	unsigned int sumCols = 0, tableCol;
+	bool found = false;
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		TeAttributeList& attrList = attTableVector_[i].attributeList();
+		if (pos < (sumCols + attrList.size()))
+		{
+			if (i == 0)
+				tableCol = pos;
+			else
+				tableCol = pos - sumCols;
+			found = true;
+			break;
+		}
+		sumCols += attrList.size();
+	}
+
+	if (found == false)
+		return "";
+
+	TeAttributeList& attrList = attTableVector_[i].attributeList();
+	string attrName = attTableVector_[i].name() + "." + attrList[tableCol].rep_.name_;
+	return attrName;
+}
+
+bool
+TeTheme::isIndex(unsigned int pos)
+{
+	string fullAttrName = getAttribute(pos);
+	if (fullAttrName.empty() == true)
+		return false;
+
+	size_t idx = fullAttrName.find(".");
+	string tableName = fullAttrName.substr(0, idx);
+	string attrName = fullAttrName.substr(idx+1);
+
+	// Get the representation of a table given an attribute name
+	TeTable table;
+	if (getTable(table, tableName) == false)
+		return false;
+
+	// Check if the attribute is index or not
+	if(table.uniqueName() == attrName)
+		return true;
+
+	return false;
+}
+
+bool 
+TeTheme::isThemeTable(int tableId)  
+{
+	bool isThemeTable = false;
+	unsigned int i;
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].id() == tableId)
+		{
+			isThemeTable = true;
+			break;
+		}
+	}
+	return isThemeTable;
+}
+
+bool 
+TeTheme::isThemeTable(string tableName)  
+{
+	bool isThemeTable = false;
+	for (unsigned int i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].name() == tableName)
+		{
+			isThemeTable = true;
+			break;
+		}
+	}
+	return isThemeTable;
+}
+
+string
+TeTheme::getTableName(const string& attrName)
+{
+	string tableName;
+	size_t pos = attrName.find(".");
+
+	if (pos != string::npos)
+		return tableName = attrName.substr(0, pos);
+
+	for (unsigned int i = 0; i < attTableVector_.size(); ++i)
+	{
+		TeAttributeList& attrList = attTableVector_[i].attributeList();
+		for (unsigned j = 0; j < attrList.size(); ++j)
+		{
+			if (attrList[j].rep_.name_ == attrName)
+			{
+				tableName = attTableVector_[i].name();
+				return tableName;
+			}
+		}	
+	}
+
+	return tableName;
+}
+
+
+bool 
+TeTheme::deleteGrouping()  
+{
+	TeDatabase* db = layer_->database();
+	if(!db)
+		return false;
+
+	resetGrouping();
+	
+	//delete te_legend table
+	if(!db->deleteLegend (this->id()))
+		return false;
+	
+	//delete te_grouping table
+	string sql = "DELETE FROM te_grouping WHERE theme_id= "+ Te2String(this->id());
+	db->execute (sql);
+
+	return true;
+}
+
+bool 
+TeTheme::createCollectionAuxTable()
+{
+	return createCollectionAuxTable(layer_->database());
+}
+
+bool 
+TeTheme::createCollectionAuxTable(TeDatabase* db)   
+{
+	unsigned int i, j;
+	bool status;
+	vector<string> indexes;
+	
+	if(!db)
+		return false;
+
+	if(!db->tableExist(collectionTable_))
+		return false;
+
+	if(db->tableExist(collectionAuxTable_))
+	{
+		status = db->execute("DROP TABLE " + collectionAuxTable_);
+		if(db->tableExist(collectionAuxTable_))
+		{
+			if(!status)
+				return false; 
+		}
+	}
+
+	TeAttributeList attList;
+
+	TeAttribute at;
+	at.rep_.type_ = TeSTRING;
+	at.rep_.numChar_ = 50;
+	at.rep_.name_ = "object_id";
+	attList.push_back(at);
+
+	j = 0;
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].tableType() == TeAttrExternal ||
+			attTableVector_[i].tableType() == TeFixedGeomDynAttr)
+		{
+			at.rep_.name_ = "aux" + Te2String(j++);
+			attList.push_back(at);
+			indexes.push_back(at.rep_.name_);
+		}
+	}
+
+	at.rep_.isPrimaryKey_ = true;
+	at.rep_.numChar_ = 0;
+	at.rep_.name_ = "unique_id";
+	at.rep_.isAutoNumber_ = true;
+	at.rep_.type_ = TeINT;
+	attList.push_back(at);
+	
+	at.rep_.name_ = "grid_status";
+	at.rep_.isPrimaryKey_ = false;
+	at.rep_.isAutoNumber_ = false;
+	at.rep_.numChar_ = 0;
+	attList.push_back(at);	
+	
+	status = db->createTable(collectionAuxTable_,attList);
+	if(!status)
+		return false;
+
+	string idxName = "te_idx_caux"+ Te2String(this->id());
+
+	//create index to object_id
+	db->createIndex(collectionAuxTable_, idxName+"_objId", "object_id"); 
+
+	for(unsigned int i=0; i<indexes.size(); ++i)
+		db->createIndex(collectionAuxTable_, idxName+"_"+indexes[i], indexes[i]); 
+
+	return true;
+} 
+
+bool 
+TeTheme::populateCollectionAux(std::string objectId)  
+{	
+	TeDatabase* db = layer_->database();
+	if((!db) || (collectionTable_.empty()) || (collectionAuxTable_.empty()))
+		return false;
+	
+	string whereClause; 
+
+	whereClause = " WHERE 1=1 ";
+	
+	// Populate the collection auxiliary table
+	string ins = "INSERT INTO " + collectionAuxTable_ + " (object_id";
+    unsigned int i, j;
+	j = 0;
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].tableType() == TeAttrExternal ||
+			attTableVector_[i].tableType() == TeFixedGeomDynAttr)
+			ins += ", aux" + Te2String(j++);
+	}
+
+	ins += ", grid_status) SELECT c_object_id";
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].tableType() == TeAttrExternal ||
+			attTableVector_[i].tableType() == TeFixedGeomDynAttr)
+			ins += "," + aliasVector()[i] + "." + attTableVector_[i].uniqueName();
+	}
+
+	ins += ",c_object_status";
+
+	//attribute restriction
+	if(!generateAttributeRest_.empty())
+		whereClause += " AND "+ generateAttributeRest_; 
+
+	//temporal restriction
+	if(!generateTemporalRest_.empty())
+	{
+		string sqlTemp;
+		initParse(generateTemporalRest_, db); 
+				
+		if(!yyparse(sqlTemp))  //0: accept  1: reject
+			whereClause += " AND "+ sqlTemp;
+		else
+			return false;
+	}
+
+	//spatial restriction is already stored in the collection table
+	
+	bool usaTemporal = false;
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		if (attTableVector_[i].tableType() == TeFixedGeomDynAttr ||
+			attTableVector_[i].tableType() == TeDynGeomDynAttr)
+			usaTemporal = true;
+	}
+	loadThemeTablesJoin();
+	string result = ins + sqlFrom() + whereClause + " ";
+	if (!objectId.empty() && !whereClause.empty())
+		result += " AND c_object_id = '"+objectId+"'";
+	if (!db->execute(result))
+		return false;
+
+	if(usaTemporal) // filter collection table
+	{
+		string s = "DELETE FROM " + collectionTable_ + " WHERE c_object_id NOT IN";
+		s += " (SELECT DISTINCT object_id FROM " + collectionAuxTable_ + ")";
+		return(db->execute(s));
+	}
+	return true;
+}
+
+
+bool 
+TeTheme::locatePolygon (TeCoord2D &pt, TePolygon &polygon, const double& tol)  
+{
+	if (!layer()->database() || collectionTable().empty())
+		return false;
+
+	string geomTable = layer()->tableName(TePOLYGONS);
+	string sqlFrom = " "+ geomTable +" INNER JOIN " + collectionTable();
+	sqlFrom += " ON "+ collectionTable() +".c_object_id = "+ geomTable +".object_id "; 
+
+	if(!layer()->database()->locatePolygon(sqlFrom, pt, polygon, tol))
+		return false;
+
+	return true;
+}
+
+
+bool 
+TeTheme::locatePolygonSet (TeCoord2D &pt, double tol, TePolygonSet &polygons)  
+{
+	if (!layer()->database() || collectionTable().empty())
+		return false;
+
+	string geomTable = layer()->tableName(TePOLYGONS);
+	string sqlFrom = " "+ geomTable +" INNER JOIN " + collectionTable();
+	sqlFrom += " ON "+ collectionTable() +".c_object_id = "+ geomTable +".object_id "; 
+
+	if(!layer()->database()->locatePolygonSet(sqlFrom, pt, tol, polygons))
+		return false;
+
+	return true;
+}
+
+bool 
+TeTheme::locateLine (TeCoord2D &pt, TeLine2D &line, const double& tol)  
+{
+	if (!layer()->database() || collectionTable().empty())
+		return false;
+
+	string geomTable = layer()->tableName(TeLINES);
+	string sqlFrom = " "+ geomTable +" INNER JOIN " + collectionTable();
+	sqlFrom += " ON "+ collectionTable() +".c_object_id = "+ geomTable +".object_id "; 
+
+	if(!layer()->database()->locateLine(sqlFrom, pt, line, tol))
+		return false;
+
+	return true;
+}
+
+bool 
+TeTheme::locatePoint (TeCoord2D &pt, TePoint &point, const double& tol)  
+{
+	if (!layer()->database() || collectionTable().empty())
+		return false;
+
+	string geomTable = layer()->tableName(TePOINTS);
+	string sqlFrom = " "+ geomTable +" INNER JOIN " + collectionTable();
+	sqlFrom += " ON "+ collectionTable() +".c_object_id = "+ geomTable +".object_id "; 
+
+	if(!layer()->database()->locatePoint(sqlFrom, pt, point, tol))
+		return false;
+
+	return true;
+}
+
+bool 
+TeTheme::locateCell (TeCoord2D &pt, TeCell &cell, const double&  tol)  
+{
+	if (!layer()->database() || collectionTable().empty())
+		return false;
+
+	string geomTable = layer()->tableName(TeCELLS);
+	string sqlFrom = " "+ geomTable +" INNER JOIN " + collectionTable();
+	sqlFrom += " ON "+ collectionTable() +".c_object_id = "+ geomTable +".object_id "; 
+
+	if(!layer()->database()->locateCell(sqlFrom, pt, cell, tol))
+		return false;
+
+	return true;
+}
+
+//------------------------------ protected methods
+void 
+TeTheme::loadAliasVector()  
+{
+	unsigned int i, count;
+	TeTable table;
+	multimap<string, int> tableMMap;
+
+	aliasVector_.clear();
+
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		table = attTableVector_[i];
+
+		if (table.tableType() != TeAttrExternal)
+			aliasVector_.push_back(table.name());
+		else
+		{
+			count = tableMMap.count(table.name());
+			if (count == 0)
+				aliasVector_.push_back(table.name());
+			else
+				aliasVector_.push_back(table.name() + "_" + Te2String(count));
+
+			tableMMap.insert(multimap<string,int>::value_type(table.name(), ++count));
+		}
+	}
+}
+
+string 
+TeTheme::sqlGridFrom(const string& geomTable) 
+{ 
+	if(geomTable.empty())
+		return sqlGridFrom_; 
+	
+	string result;
+	loadTablesJoin(geomTable);
+	result = sqlGridFrom_;
+	loadTablesJoin();
+	return result;
+}
+
+bool 
+TeTheme::generateLabelPositions(const std::string& objectId)
+{ 
+	TeDatabase* db = layer()->database();
+	if(!db)
+		return false;
+
+	return (db->generateLabelPositions(this, objectId)); 
+}
+
+void 
+TeTheme::loadTablesJoin(const string& geomTable)  //sqlGridFrom and sqlGridJoin
+{
+	unsigned int i, count;
+	multimap<string, int> tableMMap;
+    TeTable table;
+    bool hasExternalTable = false;
+
+    // Set the new sqlGridFrom_ clause and the new sqlGridJoin_ string
+    sqlGridFrom_.clear();
+    sqlGridJoin_.clear();
+
+    TeAttrTableVector tableVec;
+    vector<string>    aliasVec;
+
+    if(!geomTable.empty())
+    {
+        TeTable table;
+        table.name(geomTable);
+        table.setLinkName("object_id");
+        table.setUniqueName("object_id");
+        table.setTableType(TeAttrStatic);
+        tableVec.push_back(table);
+
+        for(i=0; i<attTableVector_.size(); ++i)
+            tableVec.push_back(attTableVector_[i]);
+
+        aliasVec.push_back(geomTable);
+        for(i=0; i<aliasVector_.size(); ++i)
+            aliasVec.push_back(aliasVector_[i]);
+    }
+    else
+    {
+        tableVec = attTableVector_;
+        aliasVec = aliasVector_;
+    }
+
+    //verify if there is external table
+    for (i = 0; i < tableVec.size(); ++i)
+    {
+        if (tableVec[i].tableType() == TeAttrExternal)
+        {
+            hasExternalTable = true;
+            break;
+        }
+    }
+   
+    if(!collectionAuxTable_.empty())
+    {
+        sqlGridFrom_ = " FROM ";
+
+        for (i = 0; i <= tableVec.size(); ++i)
+            sqlGridFrom_ += "(";
+
+        sqlGridFrom_ += collectionAuxTable_;
+        sqlGridJoin_ = "SELECT ";
+
+        if(hasExternalTable)
+            sqlGridFrom_ += " RIGHT JOIN "+ collectionTable_;
+        else
+            sqlGridFrom_ += " LEFT JOIN "+ collectionTable_;
+
+        sqlGridFrom_ += " ON "+ collectionAuxTable_ +".object_id = "+ collectionTable_ +".c_object_id )";
+
+        int numAux = 0;
+        for (i = 0; i < tableVec.size(); ++i)
+        {
+            table = tableVec[i];
+            if ((table.tableType()==TeAttrStatic) || (table.tableType()==TeAttrMedia) || (table.tableType()==TeAttrEvent))
+            {
+                sqlGridFrom_ += " LEFT JOIN " + aliasVec[i];
+                sqlGridFrom_ += " ON " + collectionTable_ +".c_object_id = " + aliasVec[i] + "." + table.linkName() +")";
+            }
+            else if (table.tableType() == TeAttrExternal)
+            {
+				count = tableMMap.count(table.name());
+				if (count == 0)
+					sqlGridFrom_ += " LEFT JOIN " + aliasVec[i];		
+				else
+					sqlGridFrom_ += " LEFT JOIN " + table.name() + " AS " + aliasVec[i];
+
+				tableMMap.insert(multimap<string,int>::value_type(table.name(), ++count));
+                sqlGridFrom_ += " ON " + collectionAuxTable_ + ".aux" + Te2String(numAux++) +" = "+ aliasVec[i] +"."+ table.uniqueName() +")";
+            }
+            else
+            {
+                sqlGridFrom_ += " LEFT JOIN " + aliasVec[i];
+                sqlGridFrom_ += " ON " + collectionAuxTable_ + ".aux" + Te2String(numAux++) +" = "+ aliasVec[i] +"."+ table.uniqueName() +")";
+            }
+           
+            sqlGridJoin_ += aliasVec[i] + ".*,";
+        }
+
+        sqlGridJoin_ += collectionTable_ + ".*, " +  collectionAuxTable_ + ".* " + sqlGridFrom_;
+    }
+
+	loadThemeTablesJoin();
+ }
+
+void TeTheme::loadThemeTablesJoin()  ////sqlJoin and sqlFrom
+{
+	unsigned int i, count;
+	multimap<string, int> tableMMap;
+	TeTable table;
+
+	// Set the new from clause and the new join string
+	sqlFrom_.clear();
+	sqlJoin_.clear();
+
+	sqlFrom_ = " FROM ";
+	sqlJoin_ = "SELECT ";
+
+	if (collectionTable_.empty() == false)
+	{
+		for (i = 0; i < attTableVector_.size(); ++i)
+			sqlFrom_ += "(";
+		sqlFrom_ += collectionTable_;
+
+		for (i = 0; i < attTableVector_.size(); ++i)
+		{
+			table = attTableVector_[i];
+			if (table.tableType() != TeAttrExternal)
+			{
+				sqlFrom_ += " LEFT JOIN " + aliasVector_[i];
+				sqlFrom_ += " ON " + collectionTable_ + ".c_object_id = " + aliasVector_[i] + "." + table.linkName() + ")";
+			}
+			else
+			{
+				count = tableMMap.count(table.name());
+				if (count == 0)
+					sqlFrom_ += " LEFT JOIN " + aliasVector_[i];		
+				else
+					sqlFrom_ += " LEFT JOIN " + table.name() + " AS " + aliasVector_[i];
+
+				tableMMap.insert(multimap<string,int>::value_type(table.name(), ++count));
+				
+				sqlFrom_ += " ON " + table.relatedTableName() + "." + table.relatedAttribute() + " = ";
+				sqlFrom_ +=  aliasVector_[i] + "." + table.linkName() + ")";
+			}
+
+			sqlJoin_ += aliasVector_[i] + ".*,";
+		}
+
+		sqlJoin_ += collectionTable_ + ".*" + sqlFrom_;
+	}
+	else
+	{
+		if (attTableVector_.size() == 1)
+		{
+			table = attTableVector_[0];
+			sqlFrom_ += table.name();
+			sqlJoin_ = "SELECT " + table.name() + ".*" + sqlFrom_;
+		}
+		else
+		{
+			for (i = 0; i < attTableVector_.size() - 1; ++i)
+				sqlFrom_ += "(";
+
+			TeTable firstTable = attTableVector_[0];
+			sqlFrom_ += firstTable.name();
+			sqlJoin_ += firstTable.name() + ".*,";
+			for (i = 1; i < attTableVector_.size(); ++i)
+			{
+				table = attTableVector_[i];
+				sqlFrom_ += " LEFT JOIN " + aliasVector_[i];
+				sqlFrom_ += " ON " + firstTable.name() + "." + firstTable.linkName() + " = " + aliasVector_[i] + "." + table.linkName() + ")";
+
+				if (i == attTableVector_.size() - 1)
+					sqlJoin_ += aliasVector_[i] + ".*";
+				else
+					sqlJoin_ += aliasVector_[i] + ".*,";
+			}
+
+			sqlJoin_ += sqlFrom_;
+		}
+	}
+	return;
+}
+
+void 
+TeTheme::loadAttrLists()  
+{
+	// Set the new list of attributes of all the theme tables and its new numerical list,
+	unsigned int i, j, count;
+	TeTable table;
+	multimap<string, int> attrMMap;
+	string attrName;
+
+	sqlAttList_.clear();
+	sqlNumAttList_.clear();
+
+	if (layer() == 0)
+		return;
+	TeDatabase *db = layer()->database();
+
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		table = attTableVector_[i];
+		// Set the map of attribute names
+		if(table.attributeList().empty())
+			db->getAttributeList(table.name(), table.attributeList());
+
+		for (j = 0; j < table.attributeList().size(); ++j)
+		{
+			attrName = table.attributeList()[j].rep_.name_; 
+			count = attrMMap.count(attrName);
+			attrMMap.insert(multimap<string,int>::value_type(attrName, ++count));
+		}
+	}
+
+	// Set the list of attribute names that contains all the attribute names
+	// of the theme tables
+	for (i = 0; i < attTableVector_.size(); ++i)
+	{
+		table = attTableVector_[i];
+		TeAttributeList attrList=table.attributeList();
+		if(attrList.empty())
+			db->getAttributeList(table.name(), attrList);
+		for (j = 0; j < attrList.size(); ++j)
+		{
+			attrName = attrList[j].rep_.name_; 
+			count = attrMMap.count(attrName);
+			if (count == 1)
+				attrList[j].rep_.name_ = attrName;
+			else
+				attrList[j].rep_.name_ = aliasVector_[i] + "." + attrName;
+
+			sqlAttList_.push_back(attrList[j]);
+		}		
+	}
+
+	// Set the list of attribute names that contains all the numeric attribute names
+	// of the theme tables
+	for(i = 0; i < sqlAttList_.size(); ++i)
+	{
+		if(sqlAttList_[i].rep_.type_ == TeREAL || sqlAttList_[i].rep_.type_ == TeINT)
+			sqlNumAttList_.push_back(sqlAttList_[i]);
+	}
+}
+
+void
+TeTheme::setLegendsForObjects()
+{
+	if(grouping_.groupMode_ == TeNoGrouping || attTableVector_.empty())
+		return;
+
+	unsigned int i, j;
+	string func, query, oid, val;
+
+	TeDatabase *db = layer_->database();
+	TeDatabasePortal* portal = db->getPortal();
+ 
+	TeAttrDataType type = grouping_.groupAttribute_.type_;
+	string	groupingAttr = grouping_.groupAttribute_.name_;
+	
+	vector<string> oidVec;
+	vector<string> oidWithNullValVec;
+	vector<string> valVec;
+	map<int, set<string> > legObjSetMap;
+
+	objLegendMap_.clear();
+
+	if(grouping_.groupFunction_.empty())
+		func = "MIN";
+	else
+		func = grouping_.groupFunction_;
+
+	if(grouping_.groupFunction_ == "COUNT")
+		type = TeINT;
+
+	query = "SELECT MIN(" + attTableVector_[0].uniqueName() + ")";
+	query += ", " + func + "(" + groupingAttr + ")" + sqlFrom_;
+	query += " GROUP BY " + attTableVector_[0].uniqueName();
+
+	if(portal->query(query) == false)
+	{
+		delete portal;
+		return;
+	}
+
+	while(portal->fetchRow())
+	{
+		oid = portal->getData(0);
+		val = portal->getData(1);
+		if (val.empty() == false)
+		{
+			oidVec.push_back(oid);
+			valVec.push_back(val);
+		}
+		else
+			oidWithNullValVec.push_back(oid);
+	}
+
+	unsigned int legSize = legend_.size();
+	if(grouping_.groupNullAttr_ && oidWithNullValVec.size() > 0)
+		--legSize;
+
+	if (grouping_.groupMode_ == TeUniqueValue)
+	{
+		for (i = 0; i < oidVec.size(); ++i)
+		{
+			oid = oidVec[i];
+			val = valVec[i];
+
+			if(type == TeREAL)
+				val = Te2String(atof(val.c_str()), grouping_.groupPrecision_);
+			else if(type == TeINT)
+				val = Te2String(atoi(val.c_str()));
+
+			for(j = 0; j < legSize; ++j)
+			{
+				TeLegendEntry& leg = legend_[j];
+				if(val == leg.from())
+				{
+					objLegendMap_[oid] = leg.id();
+					set<string>& oidSet = legObjSetMap[leg.id()];
+					oidSet.insert(oid);
+					break;
+				}
+			}
+		}		
+	}
+	else
+	{
+		for (i = 0; i < oidVec.size(); ++i)
+		{
+			double dVal, dFrom, dTo;
+			oid = oidVec[i];
+			val = valVec[i];
+
+			if (type == TeREAL)
+				val = Te2String(atof(val.c_str()), grouping_.groupPrecision_);
+			
+			for (j = 0; j < legSize; ++j)
+			{
+				TeLegendEntry& leg = legend_[j];
+				if (leg.from().find("mean") != string::npos)
+					continue;
+
+				dVal  = atof(val.c_str());
+				dFrom = atof(leg.from().c_str());
+				dTo = atof(leg.to().c_str());
+
+				if (j < (legSize - 1))
+				{
+					if(dVal >= dFrom && dVal < dTo)
+					{
+						objLegendMap_[oid] = leg.id();
+						set<string>& oidSet = legObjSetMap[leg.id()];
+						oidSet.insert(oid);
+						break;
+					}
+				}
+				else
+				{
+					if(dVal >= dFrom && dVal <= dTo)
+					{
+						objLegendMap_[oid] = leg.id();
+						set<string>& oidSet = legObjSetMap[leg.id()];
+						oidSet.insert(oid);
+						break;
+					}
+				}
+			}
+		}
+	}
+	delete portal;
+
+	// Set the leg id for the objects with null values
+	int legId = defaultLegend_.id();
+	if (grouping_.groupNullAttr_)
+		legId = legend_[legend_.size() - 1].id();	
+
+	for (i = 0; i < oidWithNullValVec.size(); ++i)
+	{
+		oid = oidWithNullValVec[i];
+		objLegendMap_[oid] = legId;
+		set<string>& oidSet = legObjSetMap[legId];
+		oidSet.insert(oid);
+	}
+
+/*
+	// Insert the legends in the te_legend table
+	map<int, set<string> >::iterator mapIt;
+	set<string>::iterator setIt;
+	unsigned char *data;
+	string where = " theme_id = " + Te2String(id());
+	for (mapIt = legObjSetMap.begin(); mapIt != legObjSetMap.end(); ++mapIt)
+	{
+		legId = mapIt->first;
+		set<string>& oidSet = mapIt->second;
+		string whereClause = where;
+		whereClause +=  " AND legend_id = " + Te2String(legId);
+		string objStr;
+		for (setIt = oidSet.begin(); setIt != oidSet.end(); ++setIt)
+			objStr += *setIt + ';';
+		data = (unsigned char*)objStr.c_str();
+		db->insertBlob("te_legend", "object_list", whereClause, data, objStr.size());
+	}
+*/
+}
+
+void
+TeTheme::setOwnLegendsForObjects()
+{
+
+}
+
+bool
+TeTheme::saveLegendInCollection(TeSelectedObjects selectedObjects, std::string objectId) 
+{
+	return saveLegendInCollection(layer()->database(), selectedObjects, objectId); 
+}
+
+bool
+TeTheme::saveLegendInCollection(TeDatabase* db, TeSelectedObjects selectedObjects, std::string objectId) 
+{
+	unsigned int i;
+	if(!db || grouping_.groupMode_ == TeNoGrouping)
+		return false; 
+
+	TeAttrDataType		type = grouping_.groupAttribute_.type_;
+	TeLegendEntryVector legVec = legend_;
+	string			groupingAttr = grouping_.groupAttribute_.name_;
+	
+	string input;
+	if(selectedObjects == TeSelectedByPointing)
+	{
+		input = " WHERE (grid_status = 1 OR grid_status = 3";
+		input += " OR (grid_status IS NULL AND (c_object_status = 1 OR c_object_status = 3)))";
+	}
+	else if(selectedObjects == TeNotSelectedByPointing)
+	{
+		input = " WHERE (grid_status = 0 OR grid_status = 2";
+		input += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 2)))";
+	}
+	else if(selectedObjects == TeSelectedByQuery)
+	{
+		input = " WHERE (grid_status = 2 OR grid_status = 3";
+		input += " OR (grid_status is null AND (c_object_status = 2 OR c_object_status = 3)))";
+	}
+	else if(selectedObjects == TeNotSelectedByQuery)
+	{
+		input = " WHERE (grid_status = 0 OR grid_status = 1";
+		input += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 1)))";
+	}
+	else if(selectedObjects == TeGrouped)
+		input = " WHERE c_legend_id <> 0";
+	else if(selectedObjects == TeNotGrouped)
+		input = " WHERE c_legend_id = 0";
+	
+
+	string func;
+	if(grouping_.groupFunction_.empty())
+		func = " MIN";
+	else
+		func = grouping_.groupFunction_;
+
+	if(grouping_.groupFunction_ == "COUNT")
+		type = TeINT;
+
+	string query = "SELECT MIN(" + collectionTable_ + ".c_object_id)";
+	if(grouping_.groupNormAttribute_.empty())
+		query += ", "+ func +"(" + groupingAttr + ")" + sqlGridFrom();
+	else
+		query += ", "+ func +"(" + groupingAttr + ") / "+ func +"(" + grouping_.groupNormAttribute_ + ")" + sqlGridFrom();
+	
+	if(selectedObjects != TeAll)
+		query += input;
+
+	query += " GROUP BY " + collectionTable_ + ".c_object_id";
+
+	map<int, vector<string> > legMap;
+	
+	TeDatabasePortal* portal = db->getPortal();
+	if(portal->query(query) == false)
+	{
+		delete portal;
+		return false;
+	}
+
+	vector<string> idVec;
+	vector<string> nullIdVec;
+	vector<string> valVec;
+	while(portal->fetchRow())
+	{
+		string val = portal->getData(1);
+		string oid = portal->getData(0);
+		if (val.empty() == false)
+		{
+			idVec.push_back(oid);
+			valVec.push_back(val);
+		}
+		else
+			nullIdVec.push_back(oid);
+	}
+	if (grouping_.groupMode_ == TeUniqueValue)
+	{
+		unsigned int j = 0;
+		while( j < idVec.size())
+		{
+			string val = valVec[j];
+			string oid = idVec[j];
+			if(type == TeREAL)
+			{
+				double a = atof(val.c_str());
+				val = Te2String(a, grouping_.groupPrecision_);
+			}
+			else if(type == TeINT)
+			{
+				int a = atoi(val.c_str());
+				val = Te2String(a);
+			}
+				
+			unsigned int siz = legend_.size();
+			if(grouping_.groupNullAttr_ && nullIdVec.size() > 0)
+				--siz;
+			for(i=0; i < siz; i++)
+			{
+				TeLegendEntry& leg = legend_[i];
+				if(val == leg.from())
+				{
+					legMap[leg.id()].push_back(oid);
+					break;
+				}
+			}
+			j++;
+		}
+	}
+	else
+	{
+		unsigned int j = 0;
+		while(j < idVec.size())
+		{
+			string val = valVec[j];
+			string oid = idVec[j];
+			if(type == TeREAL)
+			{
+				double a = atof(val.c_str());
+				val = Te2String(a, grouping_.groupPrecision_);
+			}
+			
+			unsigned int siz = legend_.size();
+			if(grouping_.groupNullAttr_ && !nullIdVec.empty())
+               --siz; 
+			for(i=0; i < siz; i++)
+			{
+				TeLegendEntry& leg = legend_[i];
+				int f = leg.from().find("mean");
+				if(f >= 0)
+					continue;
+				double dval = atof(val.c_str());
+				double dfrom = atof(leg.from().c_str());
+				double dto = atof(leg.to().c_str());
+				if(i < legend_.size()-1)
+				{
+					if(dval >= dfrom && dval < dto)
+					{
+						legMap[leg.id()].push_back(oid);
+						break;
+					}
+				}
+				else
+				{
+					if(dval >= dfrom && dval <= dto)
+					{
+						legMap[leg.id()].push_back(oid);
+						break;
+					}
+				}
+			}
+			j++;
+		}
+	}
+	delete portal;
+
+	int legId = defaultLegend_.id();
+	if (grouping_.groupNullAttr_)
+		legId = legend_[legend_.size()-1].id();	
+	for(i = 0; i < nullIdVec.size(); ++i)
+	{
+		string oid = nullIdVec[i];
+		legMap[legId].push_back(oid);
+	}
+
+	vector<string> svec;
+	map<int, vector<string> > :: iterator it = legMap.begin();
+	while(it != legMap.end())
+	{
+    	// --- Generate In Clauses ----
+		unsigned int i, j, k, size, chunkSize = 200, nChunks;
+		string inClause;
+		size = it->second.size();
+		if (size % chunkSize)
+			nChunks = size / chunkSize + 1;
+		else
+			nChunks = size / chunkSize;
+
+		j = 0;		
+		for (k = 0; k < nChunks; ++k)
+		{
+			i = 0;
+			inClause = "(";
+			while (j < size && i < chunkSize)
+			{
+				inClause += "'" + db->escapeSequence(it->second[j]) + "',";
+				i++;
+				j++;
+			}
+			inClause[inClause.size() - 1] = ')';
+			svec.push_back(inClause);
+		}
+
+		//--- generateInClause
+
+		for(i=0; i<svec.size(); ++i)
+		{
+			string up = "UPDATE " + collectionTable_ + " SET c_legend_id = " + Te2String(it->first);
+			up += " WHERE c_object_id IN " + svec[i];
+			if (!objectId.empty())
+				up += " AND c_object_id='"+objectId+"'";
+			if(db->execute(up) == false)
+				continue;
+		}
+		it++;
+		svec.clear();
+	}
+	if(legend_.size())
+		visibleRep_ = visibleRep_ | 0x40000000;
+	else
+		visibleRep_ = visibleRep_ | 0xbfffffff;
+	string upVis = "UPDATE te_theme SET visible_rep=" + Te2String(visibleRep_) + " WHERE theme_id=" + Te2String(id());
+	return (db->execute(upVis));
+}
+
+bool 
+TeTheme::populateCollection(std::string objectId)  
+{
+	TeDatabase* db = layer_->database();
+	if(!db || collectionTable_.empty())
+		return false;
+
+	if(attTableVector_.empty())
+		attTableVector_ = layer_->attrTables();
+	
+	TeRepresPointerVector& represVec = layer_->vectRepres();
+	for (unsigned int i = 0; i < represVec.size(); ++i)
+	{
+		TeRepresentation* rep = represVec[i];
+		if(rep->geomRep_ == TeTEXT)
+			continue;
+
+		string geomTable = layer_->tableName(rep->geomRep_); 
+
+		string sqlSelect, sqlFrom, sqlWhere;
+		
+		sqlSelect = " SELECT DISTINCT "+ geomTable +".object_id ";  
+		sqlFrom = tableJoin(attTableVector_, geomTable, "object_id");
+		
+		sqlWhere  = " WHERE NOT EXISTS (SELECT * FROM " + collectionTable_; 
+		sqlWhere += " WHERE "+ collectionTable_ +".c_object_id = "+ geomTable +".object_id )";
+		sqlWhere += " AND " + geomTable + ".object_id IS NOT NULL ";
+		
+		//attribute restriction
+		if(!generateAttributeRest_.empty())
+			sqlWhere += " AND ("+ generateAttributeRest_ +" )"; 
+
+		//temporal restriction
+		if(!generateTemporalRest_.empty())
+		{
+			string sqlTemp;
+			initParse(generateTemporalRest_, db); 
+					
+			if(!yyparse(sqlTemp))  //0: accept  1: reject
+				sqlWhere += " AND "+ sqlTemp;
+			else
+				return false;
+		}
+
+		TeKeys objs;
+
+		//spatial restriction
+		if(hasSpatialRes_)
+		{
+			if(boxRest_.isValid())
+			{
+				TeBox box = boxRest_;
+				sqlWhere += " AND "+ db->getSQLBoxWhere(box, geomRepRest_);
+			}
+			else if (geomRest_)
+			{
+				TePrecision::instance().setPrecision(TeGetPrecision(layer()->projection()));
+
+				if(db->spatialRelation(geomTable, geomRepRest_, geomRest_, objs, spatialRelation_))
+				{
+					string obs;
+					for(unsigned int i=0; i<objs.size(); i++)
+					{
+						if(i!=0)
+							obs += ",";
+						obs += "'"+ objs[i] +"'";
+					}
+						
+					sqlWhere += " AND "+ geomTable +".object_id IN ("+ obs +")";
+				}
+			}
+		}
+
+		//populate the collection table
+		string popule;
+		popule = " INSERT INTO "+ collectionTable_ +" (c_object_id) ";
+		popule += sqlSelect +" FROM "+ sqlFrom + sqlWhere; 	
+		if (!objectId.empty())
+		{
+			if (sqlWhere.length())
+				popule += " AND ";
+			popule += geomTable +".object_id='" +objectId+ "'";
+		}		
+
+		if (!db->execute(popule))
+		{
+			//Treats an error in the MySQL database system
+			//Error: 1062 SQLSTATE: 23000 (ER_DUP_ENTRY) 
+			//Message: Duplicate entry '%s' for key %d 
+			if(db->dbmsName() != "MySQL" || db->errorNum()!=1062)
+                return false;
+		}
+	}
+
+//	int defaultLegend = defaultLegend_.id();
+	string popule = "UPDATE " + collectionTable_;
+	popule += " SET c_legend_id=0, c_legend_own=0, c_object_status=0 ";
+	
+	if (!objectId.empty())
+		popule += " WHERE c_object_id='"+objectId+"'";
+
+	if (!db->execute(popule))
+		return false;
+
+	themeBox_= getThemeBox();
+	return true;
+}
+
+
+bool TeTheme::hasObjectsWithoutGeometries(TeGeomRep geomRep)
+{
+	if(!layer() || !layer()->database())
+		return true;
+	
+	//get the geometry table
+	string geomTable = layer()->tableName(geomRep);
+	if(geomTable.empty())
+		return true;
+
+	TeDatabasePortal* portal = layer()->database()->getPortal();
+	if(!portal)
+		return true;
+
+	//Verify the collection table or attribute tables
+	if(layer()->database()->tableExist(collectionTable()))
+	{
+		string s = " SELECT COUNT(*) ";
+		s+= " FROM "+  collectionTable();
+		s+= " WHERE NOT EXISTS ";
+		s+= " (SELECT * FROM "+ geomTable;
+		s+= " WHERE "+ collectionTable() +".c_object_id "; 
+		s+= " = "+ geomTable +".object_id ) ";
+		
+		if(!portal->query(s) || !portal->fetchRow())
+		{
+			delete portal;
+			return true;
+		}
+
+		int numObjs = atoi(portal->getData(0));
+		if(numObjs>0)
+		{
+			delete portal;
+			return true;
+		}
+	}
+	else
+	{
+		//for each static table
+		for(unsigned int i=0; i<this->attrTables().size(); ++i)
+		{
+			if(	this->attrTables()[i].tableType() == TeAttrExternal ||
+				this->attrTables()[i].tableType() == TeAttrMedia || 
+				this->attrTables()[i].tableType() == TeGeocodingData)
+				continue;
+
+			string s = " SELECT COUNT(*) ";
+			s+= " FROM "+  attrTables()[i].name();
+			s+= " WHERE NOT EXISTS ";
+			s+= " (SELECT * FROM "+ geomTable;
+			s+= " WHERE "+ attrTables()[i].name() +"."+ attrTables()[i].linkName();
+			s+= " = "+ geomTable +".object_id ) ";
+
+			if(!portal->query(s) || !portal->fetchRow())
+			{
+				delete portal;
+				return true;
+			}
+
+			int numObjs = atoi(portal->getData(0));
+			if(numObjs>0)
+			{
+				delete portal;
+				return true;
+			}
+		}
+	}
+
+	delete portal;
+	return false;
+}
+
+bool TeTheme::removeObjectsWithoutGeometries(TeGeomRep geomRep)
+{
+	if(!layer() || !layer()->database() || !layer()->database()->tableExist(collectionTable()))
+		return true;
+	
+	//get the geometry table
+	string geomTable = layer()->tableName(geomRep);
+	if(geomTable.empty())
+		return true;
+
+	string del = " DELETE FROM "+ collectionTable();
+	del += " WHERE NOT EXISTS ";
+	del += " (SELECT * FROM "+ geomTable; 
+	del += " WHERE "+ collectionTable() +".c_object_id = ";
+	del += geomTable +".object_id) ";
+
+	if(!layer()->database()->execute(del))
+		return false;
+
+	del = " DELETE FROM "+ collectionAuxTable();
+	del += " WHERE NOT EXISTS ";
+	del += " (SELECT * FROM "+ geomTable; 
+	del += " WHERE "+ collectionAuxTable() +".object_id = ";
+	del += geomTable +".object_id) ";
+
+	if(!layer()->database()->execute(del))
+		return false;
+
+	return true;
+}
+
+bool 
+TeTheme::save()  
+{
+	TeDatabase* db = layer()->database();
+	if(!db)
+		return false;
+
+	//insert theme in database 
+	if(id()==0)
+	{
+		if(!db->insertTheme(this)) //updateThemeTable
+		{
+			db->deleteTheme(this->id());
+			return false;
+		}
+	}
+	
+	//collection table 
+	if(collectionTable().empty())
+		collectionTable("te_collection_"+ Te2String(id())); 
+
+	if(!db->createCollectionTable(collectionTable_))
+	{
+		db->deleteTheme(this->id());
+		return false;
+	}
+
+	//collection aux table
+	collectionAuxTable(collectionTable() + "_aux");
+	addThemeTable(collectionAuxTable());
+
+	if(!createCollectionAuxTable())
+	{
+		db->deleteTheme(this->id());
+		return false;
+	}
+
+	return true;
+}
+
+set<string> TeTheme::getObjects(TeSelectedObjects selectedObjects)
+{
+	if (selectedObjects == TeAll)
+	{
+		if (objectSet_.empty() == false)
+			return objectSet_;
+		else
+		{
+			if (attTableVector_.empty())
+				return set<string>();
+
+			// Set the new set of objects
+			if (layer_->hasGeometry(TeRASTER) == false)
+			{
+				TeDatabase *db = layer_->database();
+				TeDatabasePortal* portal = db->getPortal();
+
+				string q = "SELECT " + attTableVector_[0].name() + "." + attTableVector_[0].uniqueName() + sqlFrom();
+				if (portal->query(q) == false)
+				{
+					delete portal;
+					return set<string>();
+				}
+
+				while (portal->fetchRow())
+					objectSet_.insert(portal->getData(0));
+
+				delete portal;
+				return objectSet_;
+			}
+		}
+	}
+
+	set<string> oidSet;
+	map<string, int>::iterator it;
+	string oid;
+
+	if (selectedObjects == TeSelectedByPointing)
+	{
+		for (it = objStatusMap_.begin(); it != objStatusMap_.end(); ++it)
+		{
+			oid = it->first;
+			if (objStatusMap_[oid] == TePOINTED || objStatusMap_[oid] == TePOINTED_QUERIED)
+				oidSet.insert(oid);
+		}
+	}
+	else if (selectedObjects == TeNotSelectedByPointing)
+	{
+		oidSet = getObjects();
+		for (it = objStatusMap_.begin(); it != objStatusMap_.end(); ++it)
+		{
+			oid = it->first;
+			if (objStatusMap_[oid] == TePOINTED || objStatusMap_[oid] == TePOINTED_QUERIED)
+				oidSet.erase(oid);
+		}
+	}
+	else if (selectedObjects == TeSelectedByQuery)
+	{
+		for (it = objStatusMap_.begin(); it != objStatusMap_.end(); ++it)
+		{
+			oid = it->first;
+			if (objStatusMap_[oid] == TeQUERIED || objStatusMap_[oid] == TePOINTED_QUERIED)
+				oidSet.insert(oid);
+		}
+	}
+	else if (selectedObjects == TeNotSelectedByQuery)
+	{
+		oidSet = getObjects();
+		for (it = objStatusMap_.begin(); it != objStatusMap_.end(); ++it)
+		{
+			oid = it->first;
+			if (objStatusMap_[oid] == TeQUERIED || objStatusMap_[oid] == TePOINTED_QUERIED)
+				oidSet.erase(oid);
+		}
+	}
+	else if(selectedObjects == TeGrouped)
+	{
+		map<string, int>& objLegendMap = getObjLegendMap();
+		for (it = objLegendMap.begin(); it != objLegendMap.end(); ++it)
+		{
+			string oid = it->first;
+			if (objLegendMap[oid] != 0)
+				oidSet.insert(oid);
+		}
+	}
+	else if(selectedObjects == TeNotGrouped)
+	{
+		oidSet = getObjects();
+		map<string, int>& objLegendMap = getObjLegendMap();
+		for (it = objLegendMap.begin(); it != objLegendMap.end(); ++it)
+			oidSet.erase(it->first);
+	} 
+	else if(selectedObjects == TeSelectedByPointingOrQuery)
+	{
+		oidSet = getObjects();
+		for (it = objStatusMap_.begin(); it != objStatusMap_.end(); ++it)
+		{
+			oid = it->first;
+			if (objStatusMap_[oid] == TeQUERIED || objStatusMap_[oid] == TePOINTED)
+				oidSet.insert(oid);
+		}
+	} 
+	else if(selectedObjects == TeSelectedByPointingAndQuery )
+	{
+		oidSet = getObjects();
+		for (it = objStatusMap_.begin(); it != objStatusMap_.end(); ++it)
+		{
+			oid = it->first;
+			if (objStatusMap_[oid] == TePOINTED_QUERIED )
+				oidSet.insert(oid);
+		}
+	}
+
+	return oidSet;
+}
+
+vector<string> TeTheme::getItemVector(TeSelectedObjects selectedObjects)
+{
+	vector<string> itemVec;
+
+	//======================================================================================
+	//Get all the items
+	vector<string> allItemVec;
+	string item;
+	unsigned int i;
+
+	if (selectedObjects == TeAll || selectedObjects == TeNotSelectedByPointing ||
+		selectedObjects == TeNotSelectedByQuery)
+	{
+		vector<TeTable> tableVec;
+		getAttTables(tableVec);
+		
+		string q = "SELECT ";
+		for (i = 0; i < tableVec.size(); ++i)
+		{
+			if (i != 0)
+				q += ",";
+			q += tableVec[i].uniqueName();
+		}
+		q += sqlFrom();
+
+		TeDatabase* db = layer()->database();
+		TeDatabasePortal* portal = db->getPortal();
+
+		if (portal->query(q) == false)
+		{
+			delete portal;
+			return itemVec;
+		}
+
+		while(portal->fetchRow())
+		{
+			item = portal->getData(tableVec[0].uniqueName());
+			for (i = 1; i < tableVec.size(); ++i)
+				item += portal->getData(tableVec[i].uniqueName());
+			allItemVec.push_back(item);
+		}
+
+		delete portal;
+	}
+
+	//======================================================================================
+	// Get the items according to the selectedObjects variable
+	map<string, int>& itemStatusMap = getItemStatusMap();
+	map<string, int>::iterator it;
+
+	if (selectedObjects == TeAll)
+		return allItemVec;
+	else if(selectedObjects == TeSelectedByPointing)
+	{
+		for (it = itemStatusMap.begin(); it != itemStatusMap.end(); ++it)
+		{
+			item = it->first;
+			if (itemStatusMap[item] == TePOINTED || itemStatusMap[item] == TePOINTED_QUERIED)
+				itemVec.push_back(item);
+		}
+	}
+	else if(selectedObjects == TeNotSelectedByPointing)
+	{
+		for (i = 0; i < allItemVec.size(); ++i)
+		{
+			item = allItemVec[i];
+			if (itemStatusMap[item] == TeDEFAULT || itemStatusMap[item] == TeQUERIED)
+				itemVec.push_back(item);
+
+			if (itemStatusMap[item] == TeDEFAULT)
+				itemStatusMap.erase(item);
+		}
+	}
+	else if(selectedObjects == TeSelectedByQuery)
+	{
+		for (it = itemStatusMap.begin(); it != itemStatusMap.end(); ++it)
+		{
+			item = it->first;
+			if (itemStatusMap[item] == TeQUERIED || itemStatusMap[item] == TePOINTED_QUERIED)
+				itemVec.push_back(item);
+		}
+	}
+	else if(selectedObjects == TeNotSelectedByQuery)
+	{
+		for (i = 0; i < allItemVec.size(); ++i)
+		{
+			item = allItemVec[i];
+			if (itemStatusMap[item] == TeDEFAULT || itemStatusMap[item] == TePOINTED)
+				itemVec.push_back(item);
+
+			if (itemStatusMap[item] == TeDEFAULT)
+				itemStatusMap.erase(item);
+		}
+	}
+	else if(selectedObjects == TeGrouped)
+	{
+		set<string> oidSet;
+		map<string, int>& objLegendMap = getObjLegendMap();
+		for (it = objLegendMap.begin(); it != objLegendMap.end(); ++it)
+		{
+			string oid = it->first;
+			if (objLegendMap[oid] != 0)
+				oidSet.insert(oid);
+		}
+
+		itemVec = getItemVector(oidSet);
+	}
+	else if(selectedObjects == TeNotGrouped)
+	{
+		set<string> oidSet = getObjects();
+		map<string, int>& objLegendMap = getObjLegendMap();
+		for (it = objLegendMap.begin(); it != objLegendMap.end(); ++it)
+			oidSet.erase(it->first);
+
+		itemVec = getItemVector(oidSet);
+	}
+	else if(selectedObjects == TeSelectedByPointingOrQuery )
+	{
+		for (it = itemStatusMap.begin(); it != itemStatusMap.end(); ++it)
+		{
+			item = it->first;
+			if( (itemStatusMap[item] == TePOINTED ) ||
+			  (itemStatusMap[item] == TeQUERIED ) ) {
+			  
+				itemVec.push_back(item);
+			}
+		}
+	}	
+
+	return itemVec;
+}
+
+vector<string> TeTheme::getItemVector(const set<string>& oidSet)
+{
+	vector<string> itemVec;
+	vector<TeTable> tableVec = attrTables();
+	set<string>::const_iterator it;
+	unsigned int i;
+
+	if (tableVec.size() == 1)
+	{
+		for (it = oidSet.begin(); it != oidSet.end(); ++it)
+			itemVec.push_back(*it);
+		return itemVec;
+	}
+
+	// Set the expression that represents the concatenation 
+	// of the unique names of each theme table
+	string concatIndexStr;
+	vector<string> indexVec;
+	TeDatabase* db = layer()->database();
+	for (i = 0; i < tableVec.size(); ++i)
+		indexVec.push_back(tableVec[i].name() + "." + tableVec[i].uniqueName());
+
+	concatIndexStr = db->getConcatFieldsExpression(indexVec);
+
+	vector<string> queryVec;
+	string query;
+
+
+	set<string>::const_iterator itB = oidSet.begin();
+	set<string>::const_iterator itE = oidSet.end();
+	vector<string> inClauseVec = generateInClauses(itB, itE, db);
+	for (i = 0; i < inClauseVec.size(); ++i)
+	{
+		query = "SELECT " + tableVec[i].name() + "." + tableVec[i].uniqueName();
+		query += ", " + concatIndexStr + sqlFrom() + " WHERE ";
+		query += tableVec[i].name() + "." + tableVec[i].uniqueName() + " IN " + inClauseVec[i];
+		queryVec.push_back(query);
+	}
+
+	TeDatabasePortal* portal = db->getPortal();
+	for (i = 0; i < queryVec.size(); ++i)
+	{
+		if (i != 0)
+			portal->freeResult();
+
+		if(portal->query(queryVec[i]) == false)
+		{
+			delete portal;
+			return itemVec;
+		}
+
+		while(portal->fetchRow())
+			itemVec.push_back(portal->getData(1));
+	}
+
+	delete portal;
+	return itemVec;
+}
+
+
+set<string> TeTheme::getObjects(const vector<string>& itemVec)
+{
+	set<string> oidSet;
+
+	unsigned int i;
+	TeDatabase* db = layer()->database();
+
+	// Get the vector of tables of the theme
+	vector<TeTable> tableVec;
+	getAttTables(tableVec);
+
+	vector<string> indexVec;
+	for (i = 0; i < tableVec.size(); ++i)
+		indexVec.push_back(tableVec[i].name() + "." + tableVec[i].uniqueName());
+
+	string concatIndexStr = db->getConcatFieldsExpression(indexVec);
+
+	std::vector<string>::const_iterator itemVec_it_begin( itemVec.begin() );
+	std::vector<string>::const_iterator itemVec_it_end( itemVec.end() );
+  
+	vector<string> inClauseVec = generateInClauses( itemVec_it_begin, 
+    itemVec_it_end, db);
+
+	vector<string> queryVec;
+	string selectClause = "SELECT " + concatIndexStr + ", ";
+	selectClause += tableVec[0].name() + "." + tableVec[0].uniqueName() + " " + sqlFrom();
+
+	for (i = 0; i < inClauseVec.size(); ++i)
+	{
+		string query = selectClause + " WHERE " + concatIndexStr + " IN " + inClauseVec[i];
+		queryVec.push_back(query);
+	}
+
+	TeDatabasePortal *portal = db->getPortal();
+	for (i = 0; i < queryVec.size(); ++i)
+	{
+		if (i != 0)
+			portal->freeResult();
+
+		if (portal->query(queryVec[i]))
+		{
+			while (portal->fetchRow())
+				oidSet.insert(portal->getData(1));
+		}
+	}
+	delete portal;
+
+	return oidSet;
+}
+
+unsigned int 
+TeTheme::getNumberOfObjects()
+{
+	int numRows = 0;
+	string s = "SELECT COUNT(*) " + this->sqlFrom();	
+	TeDatabasePortal* portal = this->layer()->database()->getPortal();
+	if(portal->query(s) && portal->fetchRow() )
+	{
+		numRows = atoi(portal->getData(0));
+	}
+	delete portal;
+	return numRows;
+}
+
+TeProjection* 
+TeTheme::getThemeProjection()
+{
+	if (layer_)
+		return layer_->projection();
+	else
+		return 0;
+}
+
diff --git a/src/terralib/kernel/TeTheme.h b/src/terralib/kernel/TeTheme.h
new file mode 100644
index 0000000..5d01f2a
--- /dev/null
+++ b/src/terralib/kernel/TeTheme.h
@@ -0,0 +1,443 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeTheme.h
+	\brief This file contains definitions about a theme in TerraLib database
+*/
+#ifndef  __TERRALIB_INTERNAL_THEME_H
+#define  __TERRALIB_INTERNAL_THEME_H
+
+#include "TeAbstractTheme.h"
+#include "TeLayer.h"
+
+using namespace std;
+
+//! TerraLib definition of a Theme
+/*!
+\par 
+A TeTheme represents a collection of objects selected from a TeLayer. This selection is based
+on restrictions that can be non-spatial (e.g. POP > 10000), spatial (e.g. "inside box(0,0,100,100)
+or temporal. The most simple selection is "all" objects of a layer.
+\par 
+A TeTheme contains the list of attribute tables of the layer used by a theme.
+\par 
+A TeTheme contains the visual presentation parameters for the objects that contains, for
+all of its geometrical representations.
+\par 
+A TeTheme can store the parameters associated to how to separate its objects in groups. 
+\par 
+A TeTheme can store parameters associated to the creation of individual graphs on its objects
+(e.g. pie bars that relate two or more of its attributes).
+\par 
+A TeTheme store the range of scales within it should be visible. 
+\sa TeView TeTable
+*/
+class TL_DLL TeTheme: public TeAbstractTheme
+{
+public:
+	//! Constructor
+    TeTheme( const string& name="", TeLayer* layer=0, TeViewNode* parent=0, const int& view=0, const int& id=0);
+
+	//! Constructor
+	TeTheme(const TeViewNodeParams& params); 
+
+	//! Copy constructor
+	TeTheme (const TeTheme& other);
+
+	//! Destructor
+	~TeTheme ();
+
+	//! Assignment operator
+	TeTheme& operator= (const TeTheme& other); 
+
+	/** @name Layer
+		Methods related to the layer that gives origin to this theme.
+	*/
+	//@{	
+	//! Returns the id of the source layer
+	virtual int layerId() 
+	{	return layerId_; }
+
+	//! Sets the id of the source layer
+	virtual void layerId(int i)
+	{	layerId_ = i; }
+
+	//! Sets the layer that is the source of objects of the theme
+	/*! 
+		\param layer a pointer to a TeLayer
+	*/
+	virtual void layer(TeLayer* layer);
+
+	//! Returns a pointer to the layer from which the theme get its objects
+	virtual TeLayer* layer() { return layer_; }
+
+	//! Returns a pointer to a projection that is the spatial reference for the objects of this theme: same as of its layer
+	virtual TeProjection* getThemeProjection();
+	//@}
+
+	//! Sets the spatial restriction to be a spatial relation with a box
+	virtual void setSpatialRest(TeBox& box, TeGeomRep rep = TeGEOMETRYNONE, TeSpatialRelation relation = TeWITHIN); 
+
+	//! Sets the spatial restriction to be a spatial relation with a geometry
+	virtual void setSpatialRest(TeGeometry* geom, TeGeomRep rep = TeGEOMETRYNONE, TeSpatialRelation relation = TeWITHIN); 
+
+	//! Returns the clause WHERE derived from the combination of all restricitions (spatial, attribute and temporal)
+	virtual string sqlWhereRestrictions(TeRepresentation* rep=0);
+
+	//! Creates an appropriate visual presentation to the raster of the theme
+    virtual void createRasterVisual(TeRaster* rst=0);
+
+	/** @name Collection
+		Methods related to the materialization in the database of the theme as a collection of objects 
+	*/
+	//@{
+	//! Returns the name of a table used to store the ids of the objects belonging to the theme
+	virtual string	collectionTable() { return collectionTable_; }
+
+	//! Sets the name of a table used to store the ids of the objects belonging to the theme
+	virtual void collectionTable(const string& s) { collectionTable_ = s; }
+
+	//! Returns the name of the collection auxiliary table
+	virtual string collectionAuxTable() { return collectionAuxTable_; }
+
+	//! Sets the name of the collection auxiliary table
+	virtual void collectionAuxTable(string name) { collectionAuxTable_ = name; }
+
+	//! Generates a optimized position (x,y) in the spatial extention of each object to position label ou graphs
+	virtual bool generateLabelPositions(const std::string& objectId = ""); 
+
+	//! Fills the sqlGridJoin_ and sqlGridFrom_ statements according to the status of the database
+	virtual void loadTablesJoin(const string& geomTable="");
+
+	/**
+		Returns a SQL JOIN statement to get all the attributes of the theme objects, 
+	    the attributes of the collection table, and the attributes of the extended 
+		collection table 
+	**/
+	virtual string sqlGridJoin() { return sqlGridJoin_; }
+
+	/** Returns a FROM clause of a SQL statement to get attributes of the theme objects, the attributes of the 
+	collection table, and the attributes of the extended collection table 
+	**/
+	virtual string sqlGridFrom(const string& geomTable=""); 
+
+	//! Build the theme collection: materializes the selection described in the theme in a collection table
+	virtual bool buildCollection(std::string objectId = "");
+
+	//! Create the auxiliar collection table used to represent objects with multiple versions in time  
+	virtual bool createCollectionAuxTable();
+
+	//! Populate the auxiliar collection table used to represent objects with multiple versions in time
+	virtual bool populateCollectionAux(std::string objectId = "");
+	//@}
+		
+	/** @name Grouping
+		Methods related to grouping of objects of the theme. 
+	*/
+	//@{
+	//! Save the grouping parameters in memory when there is no chronon
+	virtual bool buildGrouping(const TeGrouping& g, TeSelectedObjects selectedObjects = TeAll,
+		               vector<double>* dValuesVec = 0);
+
+	//! Save the grouping parameters in memory when there is chronon
+	virtual bool buildGrouping(const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec);
+	
+	//! Build the grouping and associate each object to its group in the collection table 
+	virtual bool saveGrouping(TeSelectedObjects selectedObjects = TeAll);
+
+	//! Save the theme grouping legends in the collection table  
+	virtual bool saveLegendInCollection(TeSelectedObjects selectedObjects = TeAll, std::string objectId = "");
+
+	//! Set the legend id for each object of the theme 
+	virtual void setLegendsForObjects();
+
+	//! Set the own legend id for each object of the theme 
+	virtual void setOwnLegendsForObjects();
+
+	//! Delete grouping
+	virtual bool deleteGrouping(); 
+	//@}
+
+	/** @name Attribute Tables
+		A theme can use one or more attribute tables of the layer that gives its data.
+		These methods are related to the manipulation of these tables.
+	*/
+	//@{
+
+	//! Loads the theme tables in the database
+	virtual bool loadThemeTables(); 
+
+	//! Add a new attribute table to a theme 
+	virtual bool addThemeTable (TeTable& table);
+
+	//! Add a new attribute table to a theme
+	virtual void addThemeTable (string tableName);
+
+	//! Verify if an attribute table is part of a theme
+	virtual bool isThemeTable(int tableId);
+
+	//! Verify if an attribute table is part of a theme
+	virtual bool isThemeTable(string tableName);
+
+	//! Returns the list of attribute tables used by this theme 
+	virtual TeAttrTableVector& attrTables()
+	{	return attTableVector_; }
+
+	//! Sets the entire list of attribute tables used by this theme 
+	virtual bool setAttTables(TeAttrTableVector& attrs);  
+
+	//! Returns a vector of attribute tables, of a specific type, used by this theme
+	virtual bool getAttTables(TeAttrTableVector& attrs, TeAttrTableType attType = TeAllAttrTypes); 
+
+	//! Returns a representation of an attribute table  given name 
+	virtual bool getTable(TeTable& table, const string tableName);
+
+	//! Clears the list of attribute tables used by this theme
+	virtual void clearAttTableVector() 
+	{	attTableVector_.clear();	}
+
+	//! Returns the temporal attribute table of the theme (TeEvent or TeFixedGeomDynAttr)
+	/*
+		\note A theme supports only one temporal attribute table
+	*/
+	virtual bool getTemporalTable(TeTable& table);
+
+	//! Removes an attribute table from the list of tables of a theme
+	virtual bool removeThemeTable(unsigned int index);
+
+	//! Returns the the name of an attribute table that contains a given attribute
+	virtual string getTableName(const string& attrName);
+
+	/**
+		Returns the full name of the i-th attribute resulting of the join of all attribute
+		tables associated to the theme tables 
+	*/
+	virtual string getAttribute(unsigned int i);
+
+	/**
+		Check if the name of the i-th attribute resulting of the join of all attribute
+		tables is an index or not
+	*/
+	virtual bool isIndex(unsigned int i);
+
+	//! Returns the list of attributes of theme tables 
+	virtual TeAttributeList sqlAttList() { return sqlAttList_;}
+
+	//! Clears the list of attributes associated to the theme tables 
+	virtual void clearAttList() {sqlAttList_.clear();}
+
+	//! Returns the list of numerical attributes of the theme tables 
+	virtual TeAttributeList sqlNumAttList() { return sqlNumAttList_;}
+
+	//! Clears the list of numerical attributes associated to the theme tables 
+	virtual void clearNumAttList() {sqlNumAttList_.clear();}
+
+	//! Returns a SQL JOIN statement to reach to all attribute tables used by this theme
+	virtual string	sqlJoin() { return sqlJoin_;}
+
+	//! Returns a SQL FROM CLAUSE that gives access to all attribute tables used by this theme
+	virtual string	sqlFrom() { return sqlFrom_;}
+
+	//! Returns the string containing the SQL WHERE clause 
+	virtual string&	sqlWhere() { return sqlWhere_;}
+
+	//! Returns the alias vector of the names of the theme tables
+	virtual vector<string>&	aliasVector() { return aliasVector_; }
+
+	//! fill aliasVector_
+	virtual void loadAliasVector();
+
+	//! Refresh list of attributes of all the theme tables.
+	/*
+		\note All attributes are stored into sqlAttList_ and numeric attributes are stored into sqlNumAttList_.
+	*/
+	virtual void loadAttrLists();
+	//@}
+
+	//! Refreshes the bounding box of a theme according to its representation
+	/*
+		\note This functions is being kept for compatibility reasons with derived
+		classes. IT SHOULD NOT BE USED BY APPLICATION USING ONLY THE BASIC CLASS.
+	*/
+	virtual void updateThemeBox() {}
+
+	//! Updates the bounding box of a theme (in the database)
+	/*
+		\note This functions is being kept for compatibility reasons with derived
+		classes. IT SHOULD NOT BE USED BY APPLICATION USING ONLY THE BASIC CLASS.
+	*/
+	virtual void updateThemeBox(const TeBox& /*box*/) {}
+	//@}
+
+	/** @name Locate geometries
+	    Returns the geometry(ies) of the theme given coordinate
+	*/
+	//@{ 	
+	virtual bool locatePolygon		(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
+	virtual bool locatePolygonSet   (TeCoord2D &pt, double tol, TePolygonSet &polygons);
+	virtual bool locateLine		(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
+	virtual bool locatePoint	(TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
+	virtual bool locateCell		(TeCoord2D &pt, TeCell &c, const double& tol = 0.0);
+	//@}
+	
+	//! Get the set of objects corresponding to the object selection criteria
+	virtual set<string> getObjects(TeSelectedObjects selectedObjects = TeAll);
+
+	//! Get the set of objects corresponding to the list of items
+	virtual set<string> getObjects(const vector<string>& itemVec);
+
+	//! Get the set of items corresponding to the object selection criteria
+	virtual vector<string> getItemVector(TeSelectedObjects selectedObjects);
+
+	//! Get the set of items corresponding to the set of objects
+	virtual vector<string> getItemVector(const set<string>& oidSet);
+
+	//! Verifies if there are objects without geometries of a specific geometry representation
+	virtual bool hasObjectsWithoutGeometries(TeGeomRep geomRep);
+
+	//! Removes the objects without geometries of a specific geometry representation
+	virtual bool removeObjectsWithoutGeometries(TeGeomRep geomRep);
+
+	//! Save the the theme parameters in the database
+	virtual bool save(); 
+
+	//! Get the number of objects acessible by this theme
+	virtual unsigned int getNumberOfObjects();
+
+	//! Save the theme metadata in database. In this case, this metadata is saved by TeDatabase
+	virtual bool saveMetadata(TeDatabase*) { return true; } 
+	
+protected:
+	
+	//! Create the auxiliar collection table used to represent objects with multiple versions in time  
+	virtual bool createCollectionAuxTable(TeDatabase* db);
+
+	//! Save the grouping parameters in memory when there is no chronon
+	virtual bool buildGrouping(TeDatabase* db, const TeGrouping& g, TeSelectedObjects selectedObjects = TeAll,
+		                       vector<double>* dValuesVec = 0);
+
+	//! Save the grouping parameters in memory when there is chronon
+	virtual bool buildGrouping(TeDatabase* db, const TeGrouping& g, TeChronon chr, vector<map<string, string> >& mapObjValVec);
+
+	//! Build the grouping and associate each object to its group in the collection table 
+	virtual bool saveGrouping(TeDatabase* db, TeSelectedObjects selectedObjects = TeAll);
+
+	//! Save the theme grouping legends in the collection table  
+	virtual bool saveLegendInCollection(TeDatabase* db, TeSelectedObjects selectedObjects = TeAll, std::string objectId = "");
+	
+	//! Fill the sqlJoin_ and sqlFrom_ 
+	virtual void loadThemeTablesJoin();
+	
+	//! Populate the collection table based in the theme restrictions
+	virtual bool populateCollection(std::string objectId = ""); 
+
+	//! list of attribute tables of the theme
+	TeAttrTableVector	attTableVector_;
+
+	//! List containing all the attributes of the theme tables
+	TeAttributeList	sqlAttList_;
+	
+	//! List containing only the numeric attributes of the theme tables
+	TeAttributeList	sqlNumAttList_;		
+
+	//! Pointer to the layer that gives origin to this theme
+	TeLayer*	layer_;
+
+	//! Layer id
+	int			layerId_;	
+	
+	// collection table name
+	string		collectionTable_;
+	string		collectionAuxTable_;
+
+	// ----------------- theme tables information -----------------
+
+	//! clause FROM: join with the theme tables and collection table
+	string	sqlFrom_;		
+	
+	//! clause SELECT and FROM: join with the theme tables and collection table
+	string	sqlJoin_;
+	
+	//! string containing the WHERE clause
+	string sqlWhere_;
+
+	//! clause FROM: join with the theme tables and auxiliar collection table
+	string	sqlGridFrom_;
+	
+	//! clause SELECT and FROM: join with the theme tables and auxiliar collection table
+	string	sqlGridJoin_;
+
+	//! vector of alias to the attribute tables that are used more than once  
+	vector<string>	aliasVector_;
+
+	//! Load the theme metadata from database. In this case, this metadata is loaded by TeDatabase
+	virtual bool loadMetadata(TeDatabase* ) { return true; } 
+
+	//! Erase the theme metadata in database. In this case, this metadata is erased by TeDatabase
+	virtual bool eraseMetadata(TeDatabase* ) { return true; } 
+};
+
+
+//!  This class implements a factory to create theme objects. 
+/*!  
+	 This class is a factory that create view nodes 
+	 of the type TeTHEME, that is, theme objects.
+
+	\sa
+     TeViewNodeFactory TeViewNodeParams TeTheme  
+*/
+class TL_DLL TeThemeFactory : public TeViewNodeFactory
+{
+public:
+	//! Constructor 
+	TeThemeFactory() : TeViewNodeFactory((int)TeTHEME)
+	{}
+
+	//! Created theme objects 
+	TeViewNode* build(TeViewNodeParams* params)
+	{	
+		TeViewNodeParams auxParams = *params;
+		return new TeTheme(auxParams);	
+	}
+
+	TeViewNode* build()
+	{
+		return new TeTheme();
+	}
+};
+
+
+/*! \example createTheme.cpp
+	Shows how to create themes in TerraLib.
+ */
+
+/*! \example themeGrouping.cpp
+	Shows how to do a grouping on the objects of a TerraLib theme.
+ */
+
+/*! \example rasterSlicing.cpp
+	Shows how to  create a legend over a raster data, stored in a layer TerraLib.
+ */
+
+
+#endif
+
diff --git a/src/terralib/kernel/TeThread.cpp b/src/terralib/kernel/TeThread.cpp
new file mode 100644
index 0000000..f3717a3
--- /dev/null
+++ b/src/terralib/kernel/TeThread.cpp
@@ -0,0 +1,263 @@
+#include "TeThread.h"
+#include "TeAgnostic.h"
+
+TeThread::TeThread()
+{
+	init();
+}
+
+TeThread::~TeThread()
+{
+	TEAGN_TRUE_OR_THROW( ( threadStatus_ == TeThreadStopped ),
+		                 "Trying to delete a running thread handler instance" )
+  freeResources();
+}
+
+bool TeThread::start()
+{
+  if( threadStatus_ != TeThreadStopped )
+	{
+        return false;
+  }
+	else
+	{
+    freeResources();
+    
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+		threadId_ = 0;
+        threadHandler_ = 0;
+		threadHandler_ = CreateThread(NULL, 0, 
+      (LPTHREAD_START_ROUTINE)TeThread::startThread,
+      (LPVOID)(this), 0, (LPDWORD) &threadId_);
+
+    TEAGN_TRUE_OR_RETURN( ( threadHandler_ != 0 ),
+      "Thread creation failed" )
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+		TEAGN_TRUE_OR_RETURN( ( pthread_attr_init(&threadAttr_) == 0 ),
+      "Unable to init thread attributes" )
+		TEAGN_TRUE_OR_RETURN( ( pthread_attr_setdetachstate( &threadAttr_, 
+      PTHREAD_CREATE_JOINABLE ) == 0 ),
+      "Unable to set thread detach attribute" );
+
+    TEAGN_TRUE_OR_RETURN( ( pthread_create( &threadId_, &threadAttr_, 
+      TeThread::startThread, (void *) this ) == 0 ),
+      "Thread creation failed" )
+#else
+#error "ERROR: Unsupported platform"
+#endif
+
+		threadStatus_ = TeThreadRunning;
+
+    if( threadCurrPriority_ != TeThreadNormalPriority )
+		{
+      TEAGN_TRUE_OR_LOG( setPriority(threadCurrPriority_ ), 
+        "Unable to set thread priority" );
+    }
+
+    return true;
+  }
+}
+
+
+const TeThreadStatus& TeThread::getStatus() const
+{
+  return threadStatus_;
+}
+
+const TeThreadPriority& TeThread::getPriority() const
+{
+  return threadCurrPriority_;
+}
+
+
+bool TeThread::setPriority( const TeThreadPriority& newPriority )
+{
+  if( threadStatus_ == TeThreadRunning ) {
+    #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+      int new_prio_value = THREAD_PRIORITY_NORMAL;
+      
+      switch( newPriority ) {
+        case TeThreadIdlePriority :
+        {
+          new_prio_value = THREAD_PRIORITY_IDLE;
+          break;
+        }
+        case TeThreadBelowNormalPriority :
+        {
+          new_prio_value = THREAD_PRIORITY_BELOW_NORMAL;
+          break;
+        }
+        case TeThreadNormalPriority :
+        {
+          new_prio_value = THREAD_PRIORITY_NORMAL;
+          break;
+        }
+        case TeThreadAboveNormalPriority :
+        {
+          new_prio_value = THREAD_PRIORITY_ABOVE_NORMAL;
+          break;
+        }
+        case TeThreadTimeCriticalPriority :
+        {
+          new_prio_value = THREAD_PRIORITY_TIME_CRITICAL;
+          break;
+        }
+        default :
+        {
+          TEAGN_LOG_AND_THROW( "Invalid thread priority" )
+          break;
+        }                                      
+      }
+      
+      if( SetThreadPriority( threadHandler_, new_prio_value ) ) {
+        threadCurrPriority_ = newPriority;
+        return true;
+      } else {
+        return false;
+      }      
+    #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+      int curr_policy = 0;
+      struct sched_param curr_sched_param; 
+      
+      TEAGN_TRUE_OR_THROW( ( pthread_getschedparam( threadId_, &curr_policy,
+        &curr_sched_param ) == 0 ),
+        "Unable to get thread scheduler parameters" );
+
+	    int min_prio = sched_get_priority_min( curr_policy );
+      int max_prio = sched_get_priority_max( curr_policy );
+      
+      switch( newPriority ) {
+        case TeThreadIdlePriority :
+        {
+          curr_sched_param.sched_priority = min_prio;
+          break;
+        }
+        case TeThreadBelowNormalPriority :
+        {
+          curr_sched_param.sched_priority = (int)
+            ( ( max_prio - min_prio ) / 4 );
+          break;
+        }
+        case TeThreadNormalPriority :
+        {
+          curr_sched_param.sched_priority = (int)
+            ( 2 * ( max_prio - min_prio ) / 4 );
+          break;
+        }
+        case TeThreadAboveNormalPriority :
+        {
+          curr_sched_param.sched_priority = (int)
+            ( 3 * ( max_prio - min_prio ) / 4 );
+          break;
+        }
+        case TeThreadTimeCriticalPriority :
+        {
+          curr_sched_param.sched_priority = max_prio;
+          break;
+        }
+        default :
+        {
+          TEAGN_LOG_AND_THROW( "Invalid thread priority" )
+          break;
+        }                                      
+      }
+      
+      if( pthread_setschedparam( threadId_, curr_policy,
+        &curr_sched_param ) == 0 ) {
+        
+        threadCurrPriority_ = newPriority;
+        return true;        
+      } else {
+        return false;
+      }  
+    #else
+      #error "ERROR: Unsupported platform"
+    #endif    
+  } else {
+    /* Thread not running */
+    
+    threadCurrPriority_ = newPriority;
+    
+    return true;
+  }
+}
+
+bool TeThread::waitToFinish()
+{
+  if( threadStatus_ != TeThreadStopped ) {
+    #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+      TEAGN_TRUE_OR_RETURN( ( WaitForSingleObjectEx( 
+							threadHandler_, INFINITE, false ) == WAIT_OBJECT_0 ),
+							"Thread joinning failed" )
+    #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+      TEAGN_TRUE_OR_RETURN( ( pthread_join( threadId_, 0 ) == 0 ),
+							"Thread joinning failed" )
+    #else
+      #error "ERROR: Unsupported platform"
+    #endif  
+
+    freeResources();
+  }
+  
+  return true;
+}
+
+void TeThread::init()
+{
+	threadStatus_ = TeThreadStopped;
+
+	threadCurrPriority_ = TeThreadNormalPriority;
+
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+	threadHandler_ = 0;
+	threadId_ = 0;
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  threadId_ = 0;
+#else
+#error "ERROR: Unsupported platform"
+#endif 
+} 
+
+void TeThread::freeResources()
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    if( threadHandler_ != 0 ) {
+      WaitForSingleObjectEx( threadHandler_, INFINITE, false );
+            
+      TEAGN_TRUE_OR_THROW( CloseHandle( threadHandler_ ),
+        "Error closing thread handle" );
+        
+      threadHandler_ = 0;
+      threadId_ = 0;
+
+    }
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    if( threadId_ != 0 ) {
+      pthread_join( threadId_, 0 );
+      
+      threadId_ = 0;
+      
+      TEAGN_TRUE_OR_THROW( ( pthread_attr_destroy( &threadAttr_ ) == 0 ),
+        "Unable to destroy thread attributes" )        
+    } 
+  #else
+    #error "ERROR: Unsupported platform"
+  #endif  
+}
+
+void* TeThread::startThread( void* threadPtr )
+{
+  TEAGN_DEBUG_CONDITION( ( threadPtr != 0 ),
+    "Invalid thread parameter pointer" )
+
+	TeThread* thread = (TeThread*)threadPtr;
+
+	thread->run();
+	thread->threadStatus_ = TeThreadStopped;
+
+	return 0;
+}
+
+
+
+
diff --git a/src/terralib/kernel/TeThread.h b/src/terralib/kernel/TeThread.h
new file mode 100644
index 0000000..acdff2a
--- /dev/null
+++ b/src/terralib/kernel/TeThread.h
@@ -0,0 +1,157 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/** \file TeThread.h
+ *  \brief This file contains the base thread class.
+ *  \author Emiliano F. Castejon <castejon at dpi.inpe.br>
+ *  \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ */
+
+#ifndef __TERRALIB_INTERNAL_TETRHEAD_H
+#define __TERRALIB_INTERNAL_TETRHEAD_H
+  
+#include "TeThreadDatatypes.h"
+#include "TeDefines.h"
+  
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+#include <windows.h>
+#define TeDelayThread( seconds ) Sleep( seconds * 1000)
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+#include <pthread.h>
+#include <unistd.h>
+#define TeDelayThread( seconds ) sleep( seconds )
+#else
+#error "ERROR: Unsupported platform"
+#endif
+
+
+/** \class TeThead
+ *  \brief xxxxx
+ *
+ *
+ *  If you are interested in using TerraLib thread
+ *  support in a object-oriented way, you should create
+ *  a subclass of TeThread in order to creata a threadable
+ *  class. Subclasses must implement the method "run".
+ *  Than in the main thread, you can call the start method,
+ *  it is non-blocking.<br>
+ *  If you have a function and want to make it a thread,
+ *  you should look TeThreadFunctor class.
+ *  
+ *
+ *  \sa TeThreadFunctor
+ *  \author Emiliano F. Castejon <castejon at dpi.inpe.br>
+ *  \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ *  \ingroup Utils
+ *
+ */  
+class TL_DLL TeThread
+{
+    public :
+      
+      
+      /** \brief Default constructor.
+       */
+      TeThread();             
+      
+      /** \brief Virtual destructor
+       */
+      virtual ~TeThread();
+
+      /** \brief Starts the current thread.
+       *  \return true if OK, false on errors.
+       */      
+      bool start();
+      
+      /** \brief Gets the current thread status.
+	     *  \return The current thread status.
+       */
+      const TeThreadStatus& getStatus() const;
+
+      /** \brief Returns the current thread priority.
+	     *  \return The current thread priority.
+       */
+      const TeThreadPriority& getPriority() const;
+
+      /** \brief Changes the current thread priority.
+       *  \param newPriority The new thread priority.
+       *  \return true if OK, false on errors.
+       */      
+      bool setPriority(const TeThreadPriority& newPriority);
+            
+      /** \brief Block the current thread until the thread
+	     *  handled by this instance terminates.
+       *  \return true if OK, false if wait failed.
+       */
+      bool waitToFinish();
+
+	protected:
+
+		/** \brief Thread execution method: this method will be called when the thread starts.
+		 *         Subclasses must reimplement it.
+     */
+		virtual void run() = 0;
+
+		/** \brief Initialize the internal default state.
+		 */
+		void init();
+
+		/** \brief Free all thread allocated resources.
+		 */      
+   void freeResources();
+
+	private:
+
+    /** \brief The thread start function.
+     *  \param threadPtr The thread class pointer.
+     */
+		static void* startThread(void* threadPtr );        
+
+		/** \brief Copy constructor not allowed.
+		 *  \param rhs External reference.
+		 */
+		TeThread(const TeThread& rhs);      
+    
+		/** \brief Assignment operator not aloowed.
+		 *  \param rhs External reference.
+		 *  \return A const reference.
+		 */
+		const TeThread& operator=(const TeThread& rhs);
+
+	protected:
+
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    HANDLE threadHandler_;			//!< Win32 thread handler.
+		LPDWORD threadId_;				//!< Win32 thread ID
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+		pthread_t threadId_;			//!< Pthread thread ID.
+		pthread_attr_t threadAttr_;		//!< Pthread thread attributes.
+#else
+#error "ERROR: Unsupported platform"
+#endif
+
+    TeThreadStatus threadStatus_;			//!< The current thread status variable.
+    TeThreadPriority threadCurrPriority_;   //!< The current thread priority.
+};
+  
+#endif	// __TERRALIB_INTERNAL_TETRHEAD_H
+
diff --git a/src/terralib/kernel/TeThreadDatatypes.h b/src/terralib/kernel/TeThreadDatatypes.h
new file mode 100644
index 0000000..34d643c
--- /dev/null
+++ b/src/terralib/kernel/TeThreadDatatypes.h
@@ -0,0 +1,59 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/** \file TeThreadDatatypes.h
+ *  \brief xxxxxxx.
+ *  \author Emiliano F. Castejon <castejon at dpi.inpe.br>
+ *  \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ */
+
+#ifndef __TERRALIB_INTERNAL_TETRHEADDATATYPES_H
+#define __TERRALIB_INTERNAL_TETRHEADDATATYPES_H
+
+  
+/**
+ *  \enum TeThreadStatus
+ *  \brief Possible thread status.
+ */
+enum TeThreadStatus
+{
+	TeThreadStopped,	//!< The thread is stopped: it has already finished the job or it doesn't have start it.
+	TeThreadRunning		//!< The thread is running.
+};
+
+
+/**
+ *  \enum TeThreadPriority
+ *  \brief Possible thread priorities.
+ */
+enum TeThreadPriority
+{
+	TeThreadIdlePriority,			/*!< Idle priority. */
+	TeThreadBelowNormalPriority,	/*!< Below normal priority. */
+	TeThreadNormalPriority,			/*!< Normal priority. */
+	TeThreadAboveNormalPriority,	/*!< Above normal priority. */     
+	TeThreadTimeCriticalPriority	/*!< Time critical priority. */
+};
+
+  
+#endif	// __TERRALIB_INTERNAL_TETRHEADDATATYPES_H
+
diff --git a/src/terralib/kernel/TeThreadFunctor.cpp b/src/terralib/kernel/TeThreadFunctor.cpp
new file mode 100644
index 0000000..969a15d
--- /dev/null
+++ b/src/terralib/kernel/TeThreadFunctor.cpp
@@ -0,0 +1,56 @@
+#include "TeThreadFunctor.h"
+#include "TeAgnostic.h"
+
+  
+TeThreadFunctor::TeThreadFunctor()
+	: threadReturnValue_(false), threadStartFuncPtr_(0)
+{
+}
+
+
+TeThreadFunctor::TeThreadFunctor( TeThreadStartFunctT startFuncPtr )
+	: threadReturnValue_(false)
+{
+
+    setStartFunctPtr( startFuncPtr  );
+}
+
+
+TeThreadFunctor::~TeThreadFunctor()
+{
+}
+
+const bool& TeThreadFunctor::getReturnValue() const
+{
+    return threadReturnValue_;
+}
+
+void TeThreadFunctor::setStartFunctPtr( TeThreadStartFunctT startFuncPtr )
+{
+    TEAGN_TRUE_OR_THROW( ( threadStatus_ == TeThreadStopped ),
+                          "Cannot change start function pointer of a running thread" )
+
+	TEAGN_TRUE_OR_THROW( ( startFuncPtr != 0 ),
+						 "Invalid thread start function pointer" )
+
+    threadStartFuncPtr_ = startFuncPtr;
+}
+
+void TeThreadFunctor::setParameters(const TeThreadParameters& params)
+{
+	TEAGN_TRUE_OR_THROW( ( threadStatus_ == TeThreadStopped ),
+                          "Cannot change thread parameters of a running thread" )
+
+	threadUserParams_ = params;
+}
+
+void TeThreadFunctor::run()
+{
+	TEAGN_TRUE_OR_THROW( ( threadStartFuncPtr_ != 0 ),
+						 "Invalid thread start function pointer" )
+
+	threadReturnValue_ = threadStartFuncPtr_(threadUserParams_);
+	
+	threadUserParams_.clear();
+}
+
diff --git a/src/terralib/kernel/TeThreadFunctor.h b/src/terralib/kernel/TeThreadFunctor.h
new file mode 100644
index 0000000..ad1e027
--- /dev/null
+++ b/src/terralib/kernel/TeThreadFunctor.h
@@ -0,0 +1,116 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/** \file TeThreadFunctor.h
+ *  \brief This file contains a base class for thread in function style manner.
+ *  \author Emiliano F. Castejon <castejon at dpi.inpe.br>
+ *  \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ */
+
+#ifndef __TERRALIB_INTERNAL_TETRHEADFUNCTOR_H
+#define __TERRALIB_INTERNAL_TETRHEADFUNCTOR_H
+  
+#include "TeThread.h"
+#include "TeThreadParameters.h"
+#include "TeSharedPtr.h"
+
+/** \class TeThreadFunctor
+ *  \brief A base class for thread in function style manner.
+ *
+ *
+ *  If you are interested in using TerraLib thread
+ *  support in a function style model, you should create
+ *  objects of this class by specifying a function to be called by
+ *  the thread when it starts.<br>
+ *  To start the thread, call start method,
+ *  it is non-blocking.<br>
+ *  If you want to use the thread support
+ *  in a object oriented way, see TeThread class.
+ *  
+ *
+ *  \sa TeThread
+ *  \author Emiliano F. Castejon <castejon at dpi.inpe.br>
+ *  \author Gilberto Ribeiro de Queiroz <gribeiro at dpi.inpe.br>
+ *  \ingroup Utils
+ *
+ */  
+class TL_DLL TeThreadFunctor : public TeThread
+{
+	public:
+
+        /** \brief Type definition for a thread start function pointer.
+		 *  \param params The thread parameters.
+         *  \return true if OK, false on erros.
+         */
+        typedef bool (*TeThreadStartFunctT)( const TeThreadParameters& params );
+        
+        /** @typedef TeSharedPtr< TeThread > pointer
+        * Type definition for an thread instance pointer. 
+        */
+        typedef TeSharedPtr< TeThreadFunctor > pointer;         
+
+		/** \brief Default Constructor.
+         */
+        TeThreadFunctor();             
+
+        /** \brief Alternate Constructor.
+		 *  \param startFuncPtr The thread start function pointer.
+         */
+        TeThreadFunctor( TeThreadStartFunctT startFuncPtr );
+
+        /** \brief Default Destructor
+		 */
+        ~TeThreadFunctor();
+
+        /** \brief Returns the current thread execution return value.
+         */      
+        const bool& getReturnValue() const;
+
+		/** \brief Change the internal thread start function pointer.
+		 *  \param startFuncPtr The new thread start function pointer.
+		 *  \note The thread mus be stopped for calling this method.
+         */      
+        void setStartFunctPtr( TeThreadStartFunctT startFuncPtr );
+
+		/** \brief Sets the parameter that will be passed to the function after
+		 *         the thread startup.
+		 *  \param params The parameters to the thread function.
+		 *  \note The thread mus be stopped for calling this method.
+		 */
+		void setParameters(const TeThreadParameters& params);
+
+	protected:
+
+		/** \brief This is the implementation of the thread execution method: this method
+		 *         will be called when the thread starts.
+         */
+		void run();
+
+	protected:
+
+		bool threadReturnValue_;					//!< User function return value.
+        TeThreadParameters threadUserParams_;		//!< The current user parameters instance.
+        TeThreadStartFunctT threadStartFuncPtr_;	//!< A pointer to the current user thread start function.
+};
+  
+#endif	// __TERRALIB_INTERNAL_TETRHEADFUNCTOR_H
+
diff --git a/src/terralib/kernel/TeThreadParameters.h b/src/terralib/kernel/TeThreadParameters.h
new file mode 100644
index 0000000..42803c6
--- /dev/null
+++ b/src/terralib/kernel/TeThreadParameters.h
@@ -0,0 +1,40 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeThreadParameters.h
+   \brief Thread parameters class.
+*/
+
+#ifndef TETRHEADPARAMETERS_H
+  #define TETRHEADPARAMETERS_H
+  
+  #include "TeMultiContainer.h"
+  
+  /**
+   * @brief Thread parameters class.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   * @ingroup Utils
+   */
+  class TL_DLL TeThreadParameters : public TeMultiContainer< std::string > {};
+  
+#endif
+
diff --git a/src/terralib/kernel/TeThreadSignal.cpp b/src/terralib/kernel/TeThreadSignal.cpp
new file mode 100644
index 0000000..c55d888
--- /dev/null
+++ b/src/terralib/kernel/TeThreadSignal.cpp
@@ -0,0 +1,192 @@
+#include "TeThreadSignal.h"
+
+#include "TeAgnostic.h"
+
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  #include  <stdio.h>
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  #include <sys/time.h>
+  #include <time.h>
+#else
+  #error "Unsuported plataform"
+#endif   
+
+TeThreadSignal::TeThreadSignal()
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+   waiters_count_ = 0;
+   wait_generation_count_ = 0;
+   release_count_ = 0;
+
+    // Create a manual-reset event.
+    event_ = CreateEvent (NULL,  // no security
+                          TRUE,  // manual-reset
+                          FALSE, // non-signaled initially
+                          NULL); // unnamed
+    
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+
+    /* Creating mutex */
+
+    pthread_mutexattr_t access_attr;
+    TEAGN_TRUE_OR_THROW( ( pthread_mutexattr_init( &access_attr ) == 0 ),
+      "Unable to init mutex attributes" );
+
+    pthread_mutexattr_settype( &access_attr, PTHREAD_MUTEX_DEFAULT );
+    TEAGN_TRUE_OR_THROW( 
+      ( pthread_mutex_init( &m_access_, &access_attr ) == 0 ),
+      "Unable to init mutex" )
+
+    /* Creating condition variable */
+  
+    TEAGN_TRUE_OR_THROW( ( pthread_cond_init( &condition_var_, 0 ) == 0 ),
+      "Unable to create a condition variable" );
+  
+  #else
+    #error "Unsuported plataform"
+  #endif   
+}
+
+
+TeThreadSignal::~TeThreadSignal()
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+    CloseHandle( event_ );
+    
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+
+    pthread_cond_destroy( &condition_var_ );
+  
+    pthread_mutex_destroy( &m_access_ );
+  
+  #else
+    #error "Unsuported plataform"
+  #endif   
+}
+
+
+void TeThreadSignal::emit()
+{
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+    waiters_count_lock_.lock();
+    
+    if ( waiters_count_ > 0) {  
+      SetEvent ( event_);
+      // Release all the threads in this generation.
+      release_count_ =  waiters_count_;
+
+      // Start a new generation.
+      wait_generation_count_++;
+    }
+    
+    waiters_count_lock_.unLock();
+
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+
+    TEAGN_TRUE_OR_THROW( ( pthread_cond_broadcast( &condition_var_ ) == 0 ),
+      "Error emiting signal" );
+
+  #else
+    #error "Unsupported platform"
+  #endif   
+}
+
+
+bool TeThreadSignal::wait( unsigned int waiting_time )
+{
+  bool return_value = true;
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  
+    // Avoid race conditions.
+    waiters_count_lock_.lock();
+
+    // Increment count of waiters.
+    waiters_count_++;
+
+    // Store current generation in our activation record.
+    int my_generation =  wait_generation_count_;
+
+    waiters_count_lock_.unLock();
+
+    for (;;) {
+      // Wait until the event is signaled.
+      if( waiting_time == 0 ) {
+        if( WaitForSingleObject ( event_, INFINITE ) != WAIT_OBJECT_0 ) {
+          return_value = false;
+          break;
+        }
+      } else {
+        if( WaitForSingleObject ( event_, waiting_time ) != WAIT_OBJECT_0 ) {
+          return_value = false;
+          break;
+        }      
+      }
+
+      waiters_count_lock_.lock();
+      // Exit the loop when the < event_> is signaled and
+      // there are still waiting threads from this <wait_generation>
+      // that haven't been released from this wait yet.
+      int wait_done =  release_count_ > 0
+                      &&  wait_generation_count_ != my_generation;
+      waiters_count_lock_.unLock();
+
+      if (wait_done)
+        break;
+    }
+
+    waiters_count_lock_.lock();
+    waiters_count_--;
+    release_count_--;
+    int last_waiter =  release_count_ == 0;
+    waiters_count_lock_.unLock();
+
+    if (last_waiter)
+      // We're the last waiter to be notified, so reset the manual event.
+      ResetEvent ( event_);
+
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+
+    TEAGN_TRUE_OR_THROW( ( pthread_mutex_lock( &m_access_ ) == 0 ),
+      "Unable to lock mutex" );
+    
+    if( waiting_time == 0 ) {
+      if( pthread_cond_wait( &condition_var_, &m_access_ ) != 0 ) {
+        return_value = false;
+      }
+    } else {
+      struct timeval timevalstr;
+
+      if( gettimeofday( &timevalstr, 0 ) == 0 ) {
+        struct timespec timespecstr;
+
+        /* seconds */
+        timespecstr.tv_sec = timevalstr.tv_sec + ( waiting_time / 1000 );
+        /* nano-seconds */
+        timespecstr.tv_nsec = ( timevalstr.tv_usec * 1000 ) +
+          ( ( waiting_time % 1000 ) * 1000000 );
+
+        if( pthread_cond_timedwait( &condition_var_, &m_access_, 
+          &timespecstr ) != 0 ) {
+  
+          return_value = false;
+        }
+      } else {
+        TEAGN_LOGWARN( "Unable to get the current time" );
+        return_value = false;
+      }
+    }
+
+    TEAGN_TRUE_OR_THROW( ( pthread_mutex_unlock( &m_access_ ) == 0 ),
+      "Unable to unlock mutex" );
+  
+  #else
+    #error "Unsuported plataform"
+  #endif   
+  
+  return return_value;
+}
+
diff --git a/src/terralib/kernel/TeThreadSignal.h b/src/terralib/kernel/TeThreadSignal.h
new file mode 100644
index 0000000..c30a4a4
--- /dev/null
+++ b/src/terralib/kernel/TeThreadSignal.h
@@ -0,0 +1,141 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeThreadSignal.h
+  \brief This file contains definitions about a class to deal thread 
+  signals.
+*/
+
+
+#ifndef TETHREADSIGNAL_H
+  #define TETHREADSIGNAL_H
+  
+  #include "TeDefines.h"
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    #include <windows.h>
+    #include "TeMutex.h"
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+    #include <pthread.h>
+    #include  <errno.h>
+  #else
+    #error "ERROR: Unsupported platform"
+  #endif  
+ 
+  /**
+   * @brief A class to deal with thread signals.
+   * @author Emiliano F. Castejon <castejon at dpi.inpe.br>
+   */
+  class TL_DLL TeThreadSignal
+  {
+    public :
+    
+      /**
+       * @brief Default constructor.
+       */    
+      TeThreadSignal();
+
+      /**
+       * @brief Default destructor.
+       */       
+      ~TeThreadSignal();
+      
+      /**
+       * @brief Emit a broadcast signal unblocking all waiting threads.
+       */       
+      void emit();      
+      
+      /**
+       * @brief Block the current thread waiting for a signal.
+       * @param waiting_time The maximim waiting time in milliseconds
+       * ( 0 == INFINITE ).
+       * @return true if a signal was received, false if the waiting
+       * time has finished or an error occurred.
+       */       
+      bool wait( unsigned int waiting_time = 0 );      
+      
+    protected :
+   
+      #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    
+        /**
+        * @brief Count of the number of waiters.
+        */      
+        int waiters_count_;
+
+        /**
+        * @brief Serialize access to waiters_count_.
+        */  
+        TeMutex waiters_count_lock_;
+        
+        /**
+        * @brief Number of threads to release via a 
+        * signal broadcast.
+        */ 
+        int release_count_;
+
+        /**
+        * @brief Keeps track of the current "generation" so that we 
+        * don't allow one thread to steal all the "releases" from the 
+        * broadcast.
+        */ 
+        int wait_generation_count_;
+
+        /**
+        * @brief A manual-reset event that's used to block and release 
+        * waiting threads.
+        */ 
+        HANDLE event_;
+      
+      #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+
+        /**
+        * @brief The mutex instance.
+        */        
+        pthread_mutex_t m_access_;
+        
+        /**
+        * @brief The condition var instance.
+        */        
+        pthread_cond_t condition_var_;
+
+      
+      #else
+        #error "Unsuported plataform"
+      #endif   
+   
+    private :
+    
+      /**
+       * @brief Alternative constructor.
+       */    
+      TeThreadSignal(  const TeThreadSignal& ) {};
+   
+      /**
+       * @brief operator= overload.
+       * @return A const reference to the current instance.
+       */      
+      const TeThreadSignal& operator=( const TeThreadSignal& ) { return *this; };
+ 
+  };
+
+#endif
diff --git a/src/terralib/kernel/TeTime.cpp b/src/terralib/kernel/TeTime.cpp
new file mode 100644
index 0000000..d50c7a6
--- /dev/null
+++ b/src/terralib/kernel/TeTime.cpp
@@ -0,0 +1,631 @@
+ /************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library. 
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include <TeTime.h>
+#include <memory.h>
+#include <TeUtils.h>
+#include <cstdlib>
+#include <iostream>
+
+//return the number of the month
+int getMonth(const std::string& month)
+{
+	std::string tempM = TeConvertToUpperCase(month);
+	if(tempM=="JAN")
+		return 0;
+	else if(tempM=="FEB")
+		return 1;
+	else if(tempM=="MAR")
+		return 2;
+	else if(tempM=="APR")
+		return 3;
+	else if(tempM=="MAY")
+		return 4; 
+	else if(tempM=="JUN")
+		return 5;
+	else if(tempM=="JUL")
+		return 6;
+	else if(tempM=="AUG")
+		return 7;
+	else if(tempM=="SEP")
+		return 8;
+	else if(tempM=="OCT")
+		return 9;
+	else if(tempM=="NOV")
+		return 10;
+	else if(tempM=="DEC")
+		return 11;
+
+	return -1;
+}
+
+//return the month 
+std::string getMonth(int i)
+{
+	if(i==0)
+		return "Jan";
+	else if(i==1)
+		return "Feb";
+	else if(i==2)
+		return "Mar";
+	else if(i==3)
+		return "Apr";
+	else if(i==4)
+		return "May";
+	else if(i==5)
+		return "Jun";
+	else if(i==6)
+		return "Jul";
+	else if(i==7)
+		return "Aug";
+	else if(i==8)
+		return "Sep";
+	else if(i==9)
+		return "Oct";
+	else if(i==10)
+		return "Nov";
+	else if(i==11)
+		return "Dec";
+
+	return "";
+}
+
+
+TeTime::TeTime()
+{
+    /*
+	set the tm_isdst field to 0 to indicate that standard time is in effect, 
+	or to a value greater than 0 to indicate that daylight savings time is in effect, 
+	or to a value less than zero to have the C run-time library code compute whether 
+	standard time or daylight savings time is in effect. 
+	(The C run-time library assumes the United States�s rules for implementing 
+	the calculation of Daylight Saving Time).
+	*/
+
+	chronon_ = TeSECOND;
+	ts_.tm_sec = 0;
+	ts_.tm_min = 0;
+	ts_.tm_hour = 0;
+	ts_.tm_isdst = -1;
+	ts_.tm_mday = 1;
+	ts_.tm_mon = 0;
+	ts_.tm_year = 0;
+}
+
+TeTime::TeTime(const TeTime& other)
+{
+	memcpy(&ts_, &other.ts_, sizeof(struct tm));
+	last_ = other.last_;
+	chronon_ = other.chronon_;
+}
+
+TeTime::TeTime(int h, int m, int s, TeChronon chronon)
+{
+	now();
+	ts_ = *localtime(&last_);
+	ts_.tm_sec = s;
+	ts_.tm_min = m;
+	ts_.tm_hour = h;
+	ts_.tm_isdst = -1;
+	ts_.tm_mday = 1;
+	ts_.tm_mon = 0;
+	ts_.tm_year = 0;
+	last_ = mktime(&ts_);
+	chronon_ = chronon;
+}
+
+TeTime::TeTime(const std::string& ds, TeChronon chronon, const std::string& mask, const std::string& dateS, const std::string& timeS, const std::string& indPM)
+{
+	chronon_ = chronon;
+	ts_.tm_sec = 0;
+	ts_.tm_min = 0;
+	ts_.tm_hour = 0;
+	ts_.tm_isdst = -1; 
+	ts_.tm_mday = 1;
+	ts_.tm_mon = 0;
+	ts_.tm_year = 0;
+	
+	bool flag = true;
+	std::string tempDT, tempM;
+	std::string maskTemp = mask;
+	
+	int posBeginMask = 0;
+	int posBeginDate = 0;
+	int posEndMask;
+	int posEndTotalMask = 0;
+	
+	if (mask == "YYYYMMDD" || mask == "yyyymmdd" || mask == "aaaammdd" || mask == "AAAAMMDD")
+	{
+		sscanf(ds.c_str(),"%4d%2d%2d",&ts_.tm_year,&ts_.tm_mon,&ts_.tm_mday);
+	}
+	else if (mask == "DDMMAAAA" || mask == "ddmmaaaa" || mask == "DDMMYYYY" || mask == "ddmmyyyy")
+	{
+		sscanf(ds.c_str(),"%2d%2d%4d",&ts_.tm_mday,&ts_.tm_mon,&ts_.tm_year);
+	}
+	else if (mask == "DDAAAAMM" || mask == "ddaaaamm" || mask == "DDYYYYMM" || mask == "ddyyyymm")
+	{
+		sscanf(ds.c_str(),"%2d%4d%2d",&ts_.tm_mday,&ts_.tm_year,&ts_.tm_mon);
+	}
+	else if (mask == "MMDDAAAA" || mask == "mmddaaaa" || mask == "MMDDYYYY" || mask == "mmddyyyy")
+	{
+		sscanf(ds.c_str(),"%2d%4d%2d",&ts_.tm_mon,&ts_.tm_mday,&ts_.tm_year);
+	}
+	else if (mask == "AAAADDMM" || mask == "aaaaddmm" || mask == "YYYYDDMM" || mask == "yyyyddmm")
+	{
+		sscanf(ds.c_str(),"%4d%2d%2d",&ts_.tm_year,&ts_.tm_mday,&ts_.tm_mon);
+	}
+	else
+	{
+		while(flag)
+		{
+			posEndMask = maskTemp.find("s");
+			posEndTotalMask += posEndMask;
+			
+			if(posEndMask==-1)
+			{
+				flag = false;
+				posEndTotalMask = mask.size();
+			}
+			else
+			{
+				if(posBeginMask>0)
+					++posEndTotalMask;
+				
+				maskTemp = maskTemp.substr(posEndMask+1);
+			}
+
+			tempDT.clear();
+			tempM = mask.substr(posBeginMask,(posEndTotalMask-posBeginMask));
+
+			//fill the datetime
+			std::string dt = ds.substr(posBeginDate,1);
+			while((dt!=dateS) && (dt!=timeS) && (dt!=" ") && (posBeginDate < (int)ds.size()))
+			{
+				tempDT += dt;
+				++posBeginDate;
+				dt = ds.substr(posBeginDate,1);
+			}
+			++posBeginDate;
+			
+			//day
+			if(tempM.find(68)==0)
+				ts_.tm_mday = atoi(tempDT.c_str());
+			
+			//month
+			else if (tempM.find(77)==0)
+			{
+				if(tempDT.size()>2)
+					ts_.tm_mon = getMonth(tempDT)+1;
+				else
+					ts_.tm_mon = atoi(tempDT.c_str());
+			}
+
+			//year
+			else if (tempM.find(89)==0)
+			{
+				ts_.tm_year = atoi(tempDT.c_str());
+				if(ts_.tm_year < 100) 
+					ts_.tm_year += 1900; 
+			}
+
+			//hour
+			else if (tempM.find(72)==0)
+				ts_.tm_hour = atoi(tempDT.c_str());
+			
+			//minute
+			else if (tempM.find(109)==0)
+				ts_.tm_min = atoi(tempDT.c_str());
+			
+			//second
+			else if (tempM.find(83)==0)
+				ts_.tm_sec = atoi(tempDT.c_str());
+			
+			//PM or AM indicator
+			else if ((tempM.find(84)==0) && (tempDT==indPM))
+				ts_.tm_hour += 12;
+				
+			posBeginMask = posEndTotalMask+1;
+
+			if((posBeginDate)>(int)(ds.size()-1) || (posBeginMask)>(int)(mask.size()-1))
+				flag = false;
+		}
+	}
+			
+	switch (chronon_) 
+	{
+	case TeYEAR :
+		ts_.tm_mon = 1;
+        break;
+	case TeMONTH :
+		ts_.tm_mday = 1;
+        break;
+	case TeDAY :
+		ts_.tm_hour = 0;
+        break;
+	case TeHOUR :
+		ts_.tm_min = 0;
+        break;
+	case TeMINUTE :
+		ts_.tm_sec = 0;
+        break;
+	default:
+        break;
+	}
+    
+	ts_.tm_year -= 1900;
+    --ts_.tm_mon;
+
+	last_ = mktime(&ts_);
+	if (last_ != time_t(-1))
+		ts_ = *localtime(&last_);
+}
+
+time_t TeTime::now(void)
+{
+	time(&last_);
+	ts_ = *localtime(&last_);
+	return last_;
+}
+
+std::string
+TeTime::getTime() 
+{
+	char tbuf[9];
+    sprintf(tbuf, "%02d:%02d:%02d",
+                                ts_.tm_hour,ts_.tm_min,ts_.tm_sec);
+    return tbuf;
+}
+
+
+std::string
+TeTime::getDate()  
+{
+	char dbuf[12];
+	sprintf(dbuf,"%4d-%02d-%02d",ts_.tm_year+1900,ts_.tm_mon+1,ts_.tm_mday);
+	return dbuf;
+}
+
+std::string
+TeTime::getDateTime (const std::string& mask, const std::string& dateS, const std::string& timeS, const std::string& indPM, const std::string& indAM)
+{
+	std::string result = "";
+
+	bool flag = true;
+	std::string tempM;
+	std::string maskTemp = mask;
+	
+	int posBeginMask = 0;
+	int posEndMask;
+	int posEndTotalMask = 0;
+
+	bool firstTime = true;
+	bool pm = false;
+	bool am = false;
+ 
+	//verify if the mask is AM and PM
+	std::string tempAPM = mask.substr(mask.size()-1, 1);
+	if(tempAPM=="T")
+	{
+		if((ts_.tm_hour>12) || ((ts_.tm_hour==12) && (ts_.tm_min>0)) ||
+			((ts_.tm_hour==12) && (ts_.tm_min==0) && (ts_.tm_sec>0)))
+			pm=true;
+		else
+			am=true;
+	}
+
+	while(flag)
+	{
+		posEndMask = maskTemp.find("s");
+		posEndTotalMask += posEndMask;
+
+		if(posEndMask==-1)
+		{
+			flag = false;
+			posEndTotalMask = mask.size();
+		}
+		else
+		{
+			if(posBeginMask>0)
+				++posEndTotalMask;
+
+			maskTemp = maskTemp.substr(posEndMask+1);
+		}
+
+		tempM = mask.substr(posBeginMask,(posEndTotalMask-posBeginMask));
+
+		//day
+		if(tempM.find(68)==0)
+			result +=  Te2String(ts_.tm_mday) + dateS;
+		
+		//month
+		else if (tempM.find(77)==0)
+		{
+			if(tempM=="MMM")
+				result += getMonth(ts_.tm_mon) + dateS;
+			else
+				result += Te2String(ts_.tm_mon+1) + dateS;
+		}
+
+		//year
+		else if (tempM.find(89)==0)
+		{
+			if(tempM=="YYYY")
+				result +=  Te2String(ts_.tm_year+1900) + dateS;
+			else
+			{
+				std::string tempY = Te2String(ts_.tm_year);
+				tempY = tempY.substr(tempY.size()-2, 2);
+				result += tempY + dateS;
+			}
+		}
+
+		//hour
+		else if (tempM.find(72)==0)
+		{
+			if(firstTime)
+				result.replace(result.size()-1, 1, " ");
+
+			if(pm)
+				result += Te2String(ts_.tm_hour-12) + timeS;
+			else
+				result += Te2String(ts_.tm_hour) + timeS;
+			
+			firstTime = false;
+		}
+
+		//minute
+		else if (tempM.find(109)==0)
+		{
+			if(firstTime)
+				result.replace(result.size()-1, 1, " ");
+
+			result += Te2String(ts_.tm_min) + timeS;
+			firstTime = false;
+		}
+
+		//second
+		else if (tempM.find(83)==0)
+		{
+			if(firstTime)
+				result.replace(result.size()-1, 1, " ");
+
+			result += Te2String(ts_.tm_sec) + timeS;
+			firstTime = false;
+		}
+		
+		//PM or AM indicator
+		else if (tempM.find(84)==0)
+		{
+			result.replace(result.size()-1, 1, " ");
+
+			if(pm)
+				result += indPM;
+			else if(am)
+				result += indAM; 
+			
+		}
+		
+		posBeginMask = posEndTotalMask+1;
+	}
+
+	if((!am) && (!pm))
+		result.replace(result.size()-1, 1, " ");
+
+	return result;
+}
+
+time_t 
+TeTime::Set(int y, int m, int d, int h, int mt, int s)
+{
+    if (y > -1) ts_.tm_year = y-1900;
+    if (m > -1) ts_.tm_mon = m-1;
+
+
+    if (d > -1) ts_.tm_mday = d;
+    if (h > -1) ts_.tm_hour = h;
+    if (mt > -1) ts_.tm_min = mt;
+    if (s > -1) ts_.tm_sec = s;
+	ts_.tm_isdst =-1;
+    last_ = mktime(&ts_);
+    if (last_ == -1) last_ = 0;
+    return last_;
+}
+
+TeTime& 
+TeTime::operator=(const TeTime& other)
+{
+	memcpy(&ts_, &other.ts_, sizeof(struct tm));
+	last_ = other.last_;
+	chronon_ = other.chronon_;
+	return *this;			
+}
+
+
+TeTime&
+TeTime::operator+=(int delta) 
+{
+	if (delta == 0)
+		return *this;
+
+	int deltaux=delta;
+	switch (chronon_)
+	{
+	case TeYEAR :
+		ts_.tm_isdst = -1;
+		ts_.tm_year += delta;	
+		last_ = mktime(&ts_);
+		break;
+	case TeMONTH :
+	case TeMONTHOFYEAR:
+		ts_.tm_isdst = -1;
+		ts_.tm_year += (ts_.tm_mon+delta)/12;
+		ts_.tm_mon = (ts_.tm_mon+delta)%12;
+		last_ = mktime(&ts_);
+		break;
+	case TeDAY :
+	case TeDAYOFMONTH:
+	case TeDAYOFWEEK:
+	case TeDAYOFYEAR:
+		deltaux *= 3600*24;
+		last_ += deltaux;
+		ts_ = *localtime(&last_);
+		break;
+	case TeHOUR :
+	case TeHOUROFDAY :
+		deltaux *= 3600;
+		last_ += deltaux;
+		ts_ = *localtime(&last_);
+		break;
+	case TeMINUTE :
+	case TeMINUTEOFHOUR:
+		deltaux *= 60;;
+		last_ += deltaux;
+		ts_ = *localtime(&last_);
+		break;
+	case TeSECOND :
+	case TeSECONDOFMINUTE :
+		last_ += deltaux;
+		ts_ = *localtime(&last_);
+		break;
+	default :
+		break;
+	}
+
+    return *this;
+}
+
+TeTime&
+TeTime::operator++() 
+{
+	this->operator +=(1);
+	return *this;
+}
+
+TeTime
+TeTime::operator+(int delta)
+{
+	TeTime temp(*this);
+    temp += delta;
+    return temp;
+}
+
+TeTime&
+TeTime::operator-=(int delta) 
+{
+    last_ -= delta;
+    ts_ = *localtime(&last_);
+    return *this;
+}
+
+bool 
+TeTime::operator==(const TeTime& time) const
+{
+	return ((chronon_==time.chronon_) && (ts_.tm_sec==time.ts_.tm_sec) && (ts_.tm_min==time.ts_.tm_min) && 
+		(ts_.tm_hour==time.ts_.tm_hour) && (ts_.tm_isdst==time.ts_.tm_isdst) && (ts_.tm_mday==time.ts_.tm_mday) &&
+		(ts_.tm_mon==time.ts_.tm_mon) && (ts_.tm_year==time.ts_.tm_year));
+}
+
+bool 
+TeTime::operator<(const TeTime& time) const  
+{
+	if(chronon_!=time.chronon_)
+		return false;
+	
+	if(ts_.tm_year>time.ts_.tm_year)
+		return false; 
+	else if(ts_.tm_year<time.ts_.tm_year)
+		return true;
+
+	if(ts_.tm_mon>time.ts_.tm_mon)
+		return false;
+	else if (ts_.tm_mon<time.ts_.tm_mon)
+		return true;
+
+	if(ts_.tm_mday>time.ts_.tm_mday) 
+		return false;
+	else if (ts_.tm_mday<time.ts_.tm_mday) 
+		return true;
+
+	if(ts_.tm_hour>time.ts_.tm_hour) 
+		return false;
+	else if (ts_.tm_hour<time.ts_.tm_hour)
+		return true;
+
+	if(ts_.tm_min>time.ts_.tm_min) 
+		return false;
+	else if (ts_.tm_min<time.ts_.tm_min)
+		return true;
+
+	if(ts_.tm_sec>time.ts_.tm_sec) 
+		return false;
+	else if (ts_.tm_sec<time.ts_.tm_sec)
+		return true;
+
+	return false;
+}
+
+bool 
+TeTime::operator<=(const TeTime& time) const 
+{
+	return (this->operator<(time) || this->operator==(time));
+}
+
+int 
+TeTime::operator-(const TeTime& other)
+{
+	if(this->chronon_!=other.chronon_)
+		return 0;
+	int t = (int)this->last_- other.last_;
+	return (t);
+}
+
+bool 
+TeTime::isValid()  
+{
+	if(	(chronon_==TeSECOND) && (ts_.tm_sec==0) && (ts_.tm_min==0) && 
+		(ts_.tm_hour==0) && (ts_.tm_mday==1) &&
+		(ts_.tm_mon==0) && (ts_.tm_year==0))
+		return false;
+	else
+		return true;
+}
+
+void 
+TeTime::chronon (TeChronon c)
+{
+	if(chronon_==c)
+		return;
+
+	chronon_=c;
+}
+
+
+std::ostream& operator<<(std::ostream& os, TeTime& N)
+{
+	os << N.getDateTime();
+	return os;
+}
+
+
+
+
diff --git a/src/terralib/kernel/TeTime.h b/src/terralib/kernel/TeTime.h
new file mode 100644
index 0000000..534e46b
--- /dev/null
+++ b/src/terralib/kernel/TeTime.h
@@ -0,0 +1,153 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeTime.h
+    \brief This file contains structures and definitions to deal with date and time
+*/
+#ifndef  __TERRALIB_INTERNAL_TIME_H
+#define  __TERRALIB_INTERNAL_TIME_H
+
+#include "TeDefines.h"
+#include "TeDataTypes.h"
+
+#include <time.h> 
+#include <stdio.h>
+#include <string>
+#include <iostream>
+
+//!  A class for supporting date and time. 
+class TL_DLL TeTime
+{
+    struct tm	ts_; 		// Unix time structure
+    time_t		last_;		// time in seconds
+	TeChronon	chronon_;
+
+public:
+	
+	//!	Set the date and time from the system clock.
+	time_t now(void);
+
+	//!	Set all time information with NULL value 
+	TeTime(void);
+	
+	//!	Copy constructor.
+	TeTime(const TeTime& t);
+
+	//!	Set the date from the system clock and the time from its parameter list. Chronon defaulted to second.
+	TeTime(int h, int m, int s, TeChronon chronon);
+
+	//!	Set date and time from arguments, though the time fields.  
+	TeTime(	const std::string& dt, TeChronon chronon, const std::string& mask, 
+			const std::string& dateS = "/", const std::string& timeS = ":", const std::string& indPM = "PM");
+
+	//!	Return a time of day std::string in format "hh:mm:ss"
+	std::string getTime();
+
+	//!	Return a std::string to the date in the form "yyyy-mm-dd"
+	std::string getDate(void);
+
+	//!	Return a pointer to the date and time in the form passed in mask.  
+	std::string getDateTime (const std::string& mask= "DDsMMsYYYYsHHsmmsSS", const std::string& dateS="/", const std::string& timeS=":", const std::string& indPM="PM", const std::string& indAM="AM");
+
+	//! Reset time to the specified arguments. Return time_t: number of seconds since 0:00:00 Jan 1 1987
+	/*!
+      \param y  year
+	  \param m  month
+	  \param d  day
+	  \param h  hour
+	  \param min  minutes
+      \param s  seconds
+	 */
+	time_t Set(int y, int m, int d, int h = 0, int min = 0, int s = 0);
+
+	//! Get year value as an four digit integer
+	int year()	{return ts_.tm_year+1900;}  
+	
+	//! Get month value
+	int month() {return ts_.tm_mon+1;}
+	
+	//! Get day of the month value
+	int day()	{return ts_.tm_mday;} 
+	
+	//! Get hour value as an integer
+	int hour()	{return ts_.tm_hour;}
+	
+	//! Get minute value as an integer
+	int minute() {return ts_.tm_min;}
+	
+	//! Get second value as an integer
+	int second() {return ts_.tm_sec;} 
+
+	//! Get week day as in integer
+	int weekDay() { return ts_.tm_wday;} //(0-6) 0=Sunday 
+
+	//! Get year day as in integer
+	int yearDay() { return ts_.tm_yday;} //(0-365) 01/01=0 
+	
+	//! Get chronon definition
+	TeChronon chronon () {return chronon_;}
+
+	//! Set chronon definition
+	void chronon (TeChronon c);  
+	
+	//!	Assignment operator for TeTime objects.
+	TeTime& operator=(const TeTime&);
+
+	//!	Add 'delta' chronon units to the current date. Return current date.
+	TeTime& operator+=(int delta);
+
+	//! Increase a chronon unit in the time (Prefix operator)
+	TeTime& operator++();
+
+	//!	Add 'delta' chronon units to the current date and return a new date. Return new date.
+	TeTime operator+(int delta);
+
+	//!	Subtract 'delta' chronon units from the current date. Return current date.
+	TeTime& operator-=(int delta);
+			
+	//! Operator ==
+	bool operator==(const TeTime& time) const;  
+
+	//! Operator <
+	bool operator<(const TeTime& time) const;
+
+	//! Operator <=
+	bool operator<=(const TeTime& time) const;
+
+	//!	Returns the difference betwwen the times in seconds
+	int operator-(const TeTime& other);
+	
+	//! Verify if the time has null values  
+	bool isValid();  
+
+    //!	Normal destructor.
+    ~TeTime(void) { }
+
+};
+
+//! Operator to display an instance of TeTime
+TL_DLL std::ostream& operator<<(std::ostream& os, TeTime& N);
+
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeTimeInterval.cpp b/src/terralib/kernel/TeTimeInterval.cpp
new file mode 100644
index 0000000..efd6d26
--- /dev/null
+++ b/src/terralib/kernel/TeTimeInterval.cpp
@@ -0,0 +1,181 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeTimeInterval.h"
+
+TeTimeInterval :: TeTimeInterval(const std::string& s1, const std::string& s2, TeChronon chronon, 
+								 const std::string& mask, const std::string& dateS, const std::string& timeS, 
+								 const std::string& indPM)
+{
+	intChronon_ = chronon;
+	//build t1 and t2 with the chronon parameter 
+	TeTime t1 (s1, chronon, mask, dateS, timeS, indPM);
+	TeTime t2 (s2, chronon, mask, dateS, timeS, indPM);
+	t1_ = t1;
+	t2_ = t2;
+	adjustIntervaltoChronon();
+
+}
+
+void 
+TeTimeInterval::intervalChronon(TeChronon c)
+{ 
+	intChronon_ = c; 
+	t1_.chronon(c); 
+	t2_.chronon(c); 
+	adjustIntervaltoChronon();
+}
+
+void  
+TeTimeInterval::adjustIntervaltoChronon ()
+{
+	int m2 = t2_.month();
+	int d2 = 31;
+	int d1 = 1;
+
+	if ((m2 == 4) || (m2 == 6) || (m2 == 9) || (m2 == 11))  //april, june, september, november
+		d2 = 30;
+	if (m2 == 2) //february
+		d2 = 28;
+
+	switch (intChronon_)
+	{
+	case TeYEAR :		
+	    t1_.Set(t1_.year(), 1 , 1, 0, 0, 0);
+		t2_.Set(t2_.year(), 12, 31, 23, 59, 59);
+	   break;
+	case TeMONTH :
+		t1_.Set(t1_.year(), t1_.month(), d1, 0, 0, 0);
+	    t2_.Set(t2_.year(), t2_.month(), d2, 23, 59, 59);
+	   break;
+	case TeDAY :
+		t1_.Set(t1_.year(), t1_.month(), t1_.day(), 0, 0, 0);
+	    t2_.Set(t2_.year(), t2_.month(), t2_.day(), 23, 59, 59);
+	   break;
+	case TeHOUR :
+		t1_.Set(t1_.year(), t1_.month(), t1_.day(), t1_.hour(), 0, 0);
+	    t2_.Set(t2_.year(), t2_.month(), t2_.day(), t2_.hour(), 59, 59);
+	   break;
+	case TeMINUTE :
+		t1_.Set(t1_.year(), t1_.month(), t1_.day(), t1_.hour(), t1_.minute(), 0);
+	    t2_.Set(t2_.year(), t2_.month(), t2_.day(), t2_.hour(), t2_.minute(), 59);
+        break;
+    default:
+        break;
+	}	
+}
+
+
+int 
+TeTimeInterval :: length ()
+{
+	return 1;
+}
+
+void  
+TeTimeInterval :: shift (const std::string& t)
+{
+	TeTime new_t1; 
+	if (t == "")  
+		TeTime new_t1 (t2_);  
+	else		  
+		TeTime new_t1 (t, t2_.chronon(), "YYYYsMMsDDsHHsmmsSS");
+
+	TeTime new_t2 = new_t1 + length();
+
+	t1_ = new_t1;
+	t2_ = new_t2;
+	adjustIntervaltoChronon();
+}
+
+
+void  
+TeTimeInterval :: shiftPlus (int delta)
+{
+	t1_ += delta;
+	t2_ = t1_ + (delta - 1);
+	adjustIntervaltoChronon();
+}
+
+
+void  
+TeTimeInterval :: shiftMinus (int delta)
+{
+	t1_ -= delta;  
+	t2_ = t1_ + (-delta); 
+	adjustIntervaltoChronon();
+}
+
+bool   
+TeTimeInterval :: during (TeTime& time)
+{
+	if(intChronon_==TeMONTHOFYEAR)
+		return ((this->getT1().month()<=time.month()) && (this->getT2().month()>=time.month()));
+	
+	if (intChronon_==TeDAYOFMONTH)
+		return ((this->getT1().day()<=time.day()) && (this->getT2().day()>=time.day()));
+
+	if (intChronon_== TeDAYOFWEEK)
+		return ((this->getT1().weekDay()<=time.weekDay()) && (this->getT2().weekDay()>=time.weekDay())); 
+
+	if (intChronon_== TeDAYOFYEAR)
+		return ((this->getT1().yearDay()<=time.yearDay()) && (this->getT2().yearDay()>=time.yearDay())); 
+		
+	if (intChronon_== TeHOUROFDAY)
+		return ((this->getT1().hour()<=time.hour()) && (this->getT2().hour()>=time.hour())); 
+		
+	if (intChronon_==TeMINUTEOFHOUR)
+		return ((this->getT1().minute()<=time.minute()) && (this->getT2().minute()>=time.minute())); 
+	
+	if (intChronon_==TeSECONDOFMINUTE)
+		return ((this->getT1().second()<=time.second()) && (this->getT2().second()>=time.second())); 
+
+	return ((this->getT1()<=time) && (time<=this->getT2())); 
+}
+
+bool   
+TeTimeInterval :: before (TeTime& time)
+{
+	if(intChronon_==TeMONTHOFYEAR)
+		return (time.month() < this->getT1().month());
+	
+	if (intChronon_==TeDAYOFMONTH)
+		return (time.day() < this->getT1().day());
+
+	if (intChronon_== TeDAYOFWEEK)
+		return (time.weekDay() < this->getT1().weekDay());
+
+	if (intChronon_== TeDAYOFYEAR)
+		return (time.yearDay() < this->getT1().yearDay());
+		
+	if (intChronon_== TeHOUROFDAY)
+		return (time.hour() < this->getT1().hour());
+		
+	if (intChronon_==TeMINUTEOFHOUR)
+		return (time.minute() < this->getT1().minute());
+	
+	if (intChronon_==TeSECONDOFMINUTE)
+		return (time.second() < this->getT1().second());
+
+	return (time < this->getT1());
+}
diff --git a/src/terralib/kernel/TeTimeInterval.h b/src/terralib/kernel/TeTimeInterval.h
new file mode 100644
index 0000000..3d653c1
--- /dev/null
+++ b/src/terralib/kernel/TeTimeInterval.h
@@ -0,0 +1,169 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeTimeInterval.h
+    \brief This file contains structures and definitions to deal with date and time intervals
+*/
+
+#ifndef  __TERRALIB_INTERNAL_TIMEINTERVAL_H
+#define  __TERRALIB_INTERNAL_TIMEINTERVAL_H
+
+#include "TeTime.h" 
+
+//! This class provides a set of functions for manipulating date and time intervals
+class TL_DLL TeTimeInterval
+{
+private:
+
+	TeTime  t1_;
+	TeTime  t2_;
+	TeChronon  intChronon_;
+
+	void adjustIntervaltoChronon ();
+
+public:
+	
+	//!	Set the date and time from the system clock
+	void now(void) {t1_.now(); t2_.now();}
+
+	//! Empty constructor
+	TeTimeInterval (void): 	t1_(), t2_() {}
+
+	//!	Set all time information from the system clock
+	TeTimeInterval (TeTime& t1, TeTime& t2): 	t1_(t1), t2_(t2) {}
+
+	//!	Copy constructor.
+	TeTimeInterval(const TeTimeInterval& t): t1_(t.t1_), t2_(t.t2_) {}
+
+	//!	Set date and time from arguments, though the time fields defaults to zero.
+	TeTimeInterval(const std::string& t1, const std::string& t2, TeChronon chronon=TeSECOND, const std::string& mask="YYYYsMMsDDsHHsmmsSS", const std::string& dateS = "/", const std::string& timeS = ":", const std::string& indPM = "PM");
+
+	//!	Set date and time from arguments, though the time fields defaults to zero.
+	TeTimeInterval(const std::string& t1, TeChronon chronon=TeSECOND, const std::string& mask="YYYYsMMsDDsHHsmmsSS", int delta = 0, int numsteps = 1): 
+		t1_ (t1,  chronon, mask)
+	{
+		t2_ = t1_ + (delta-1)*numsteps; 
+		adjustIntervaltoChronon();
+	}
+ 
+	//! Returns the chronon of the interval
+	TeChronon intervalChronon() { return  intChronon_; }
+
+	//! Sets the chronon of the interval
+	void intervalChronon(TeChronon c);  
+
+	//!	Return a time of day std::string in format "hh:mm:ss"
+	std::string getInitialTime()			{return t1_.getTime();}
+
+	//!	Return a time of day std::string in format "hh:mm:ss"
+	std::string getFinalTime()			{return t2_.getTime();}
+
+	//!	Return a std::string to the date in the form "yyyy-mm-dd"
+	std::string getInitialDate(void)		{return t1_.getDate();}
+
+	//!	Return a std::string to the date in the form "yyyy-mm-dd"
+	std::string getFinalDate(void)		{return t2_.getDate();}
+
+	//! Return the time t1_
+	TeTime& getT1 (void) {return t1_;}
+
+	//! Return the time t2_
+	TeTime& getT2 (void) {return t2_;}
+
+	//!	Return a pointer to the date and time in the form passed in mask.  
+	std::string getInitialDateTime (const std::string& mask="YYYYsMMsDDsHHsmmsSS", const std::string& dateS="/", const std::string& timeS=":", const std::string& indPM="PM", const std::string& indAM="AM") {return t1_.getDateTime(mask, dateS, timeS, indPM, indAM);}
+
+	//!	Return a pointer to the date and time in the form passed in mask.  
+	std::string getFinalDateTime (const std::string& mask="YYYYsMMsDDsHHsmmsSS", const std::string& dateS="/", const std::string& timeS=":", const std::string& indPM="PM", const std::string& indAM="AM") {return t2_.getDateTime(mask, dateS, timeS, indPM, indAM);}
+
+	
+	//! Reset time to the specified arguments. Return time_t: number of seconds since 0:00:00 Jan 1 1987
+	/*!
+      \param y  year
+	  \param m  month
+	  \param d  day
+	  \param h  hour
+	  \param min  minutes
+      \param s  seconds
+	*/
+	time_t setInitialTime (int y, int m, int d, int h = 0, int min = 0, int s = 0)
+	{return t1_.Set(y, m, d, h, min, s);}
+
+
+	//! Reset time to the specified arguments. Return time_t: number of seconds since 0:00:00 Jan 1 1987
+	/*!
+      \param y  year
+	  \param m  month
+	  \param d  day
+	  \param h  hour
+	  \param min  minutes
+      \param s  seconds
+	*/
+	time_t setFinalTime (int y, int m, int d, int h = 0, int min = 0, int s = 0) 
+	{return t2_.Set(y, m, d, h, min, s);}
+
+	//!	Assignment operator for TeTime objects.
+	TeTimeInterval& operator=(const TeTimeInterval& t) {t1_ = t.t1_;  t2_ = t.t2_; intChronon_ = t.intChronon_; return (*this);}
+
+	//! Operator ==
+	bool operator==(const TeTimeInterval& other) const { return (this->t1_ == other.t1_ && this->t2_ == other.t2_); } 
+
+	bool operator<(const TeTimeInterval& other) const { return (this->t1_ < other.t1_ && this->t2_ < other.t2_); } 
+
+	//! Compute legnth of time interval in units of chonon
+	int length ();
+
+	//! Shift the interval, begining at time t (in the form "yyyy-mm-dd hh:mm:ss").
+	/*!
+		If t is not provided, the current final time becomes the initial time. 
+		The interval length is maintained.
+	*/
+	void shift (const std::string& t = "");
+
+	
+	//! Shift the interval, begining delta units after the initial time. The interval length is maintained.
+	void shiftPlus (int delta);
+
+	//! Shift the interval, begining delta units before the initial time. The interval length is maintained.
+	void shiftMinus (int delta);
+
+	//! verify if the times have null values
+	bool isValid() 
+	{ return (t1_.isValid() || t2_.isValid()); } 
+	
+    //!	Normal destructor.
+	~TeTimeInterval(void) { }
+
+	//! Verify if a specific time is during the interval time
+	bool  during (TeTime& time);
+
+	//! Verify if a specific time is before the interval time
+	bool  before (TeTime& time);
+
+};
+
+//! Standard output operator definition
+TL_DLL std::ostream& operator<<(std::ostream& os, TeTime& N);
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeTin.cpp b/src/terralib/kernel/TeTin.cpp
new file mode 100644
index 0000000..8d796f3
--- /dev/null
+++ b/src/terralib/kernel/TeTin.cpp
@@ -0,0 +1,1796 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeTin.h"
+#include "TeStdFile.h"
+#include "TeException.h"
+#include "TeGeometryAlgorithms.h"
+
+#include <iostream>
+#include <fstream>
+#include <algorithm>
+
+// TeTinTriangleSet
+
+bool
+TeTinTriangleSet::loadFromFile(std::string &fileName)
+{
+//	Open tin triangles file
+	std::string trianglesFile = fileName;
+	trianglesFile += ".tpl";
+
+	std::ifstream inStream;
+	inStream.open( trianglesFile.data(), std::ios::in | std::ios::binary );
+
+	if (! inStream.good() )
+		return false;
+
+	long laux;
+//#if defined(SPRWIN) || defined(LITTLEENDIAN) - File is saved in LITTLEENDIAN
+	inStream.read((char*)&laux, sizeof(long));
+	long numTriangles = laux;
+
+//	Create and std::set tin triangles std::vector
+	if ( this->size () )
+		this->clear ();
+	this->reserve (numTriangles);
+
+//	Read file for triangles data load
+	long lineid [3];
+	for (long i = 0; i < numTriangles; i++)
+	{
+		for (long j = 0; j < 3; j++)
+		{
+			if (! inStream.good() )
+				return false;
+			inStream.read((char*)&laux, sizeof(long));
+			lineid[j] = laux;
+		}
+		this->add ( TeTinTriangle (lineid[0],lineid[1],lineid[2]) );
+//		triangles_[i].setEdges(lineid[0],lineid[1],lineid[2]);
+	}
+	return true;
+}
+
+bool
+TeTinVertexSet::loadFromFile(std::string &fileName)
+{
+//	Open tin vertices file
+	std::string verticesFile = fileName;
+	verticesFile += ".tnd";
+
+	std::ifstream inStream;
+	inStream.open( verticesFile.data(), std::ios::in | std::ios::binary );
+
+	if (! inStream.good() )
+		return false;
+
+	long laux;
+//#if defined(SPRWIN) || defined(LITTLEENDIAN) - File is saved in LITTLEENDIAN
+	inStream.read((char*)&laux, sizeof(long));
+	long numVertices = laux;
+
+//	Create and std::set tin vertices std::vector
+	if ( this->size () )
+		this->clear ();
+	this->reserve (numVertices);
+
+//	Read file for vertices data load
+	double x, y;
+	double value;
+	short vertexType;
+	for (long i = 0; i < numVertices; i++)
+	{
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&x, sizeof(double));
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&y, sizeof(double));
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&value, sizeof(double));
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&vertexType, sizeof(short));
+		this->add( TeTinVertex (TeCoord2D (x,y), value,
+			(TeTinVertexType) vertexType, -1 ) );
+	}
+	return true;
+}
+
+bool
+TeTinEdgeSet::loadFromFile(std::string &fileName)
+{
+//	Open tin edges file
+	std::string edgesFile = fileName;
+	edgesFile += ".tln";
+
+	std::ifstream inStream;
+	inStream.open( edgesFile.data(), std::ios::in | std::ios::binary );
+
+	if (! inStream.good() )
+		return false;
+
+	long laux;
+//#if defined(SPRWIN) || defined(LITTLEENDIAN) - File is saved in LITTLEENDIAN
+	inStream.read((char*)&laux, sizeof(long));
+	long numEdges = laux;
+
+//	Create and std::set tin edges std::vector
+	if ( this->size () )
+		this->clear ();
+	this->reserve (numEdges);
+
+//	Read file for edges data load
+	long from, to, left, right;
+	for (long i = 0; i < numEdges; i++)
+	{
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&from, sizeof(long));
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&to, sizeof(long));
+
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&left, sizeof(long));
+		if (! inStream.good() )
+			return false;
+		inStream.read((char*)&right, sizeof(long));
+
+		this->add( TeTinEdge (from, to, left, right, NORMALEDGE) );
+	}
+	return true;
+}
+
+
+// TeTin
+
+bool
+TeTin::loadFromFile(std::string &fileName)
+{
+	if ( triangleSet_.loadFromFile ( fileName ) )
+	{
+		if ( vertexSet_.loadFromFile ( fileName ) )
+		{
+			if ( edgeSet_.loadFromFile ( fileName ) )
+				return true;
+		}
+	}
+	return false;
+}
+
+bool
+TeTin::getLines(TeLineSet &lineSet)
+{
+	std::vector<TeTinEdge>::iterator i = edgeSet_.begin();
+	while ( i != edgeSet_.end() )
+	{
+		long from = (*i).from();
+		long to = (*i).to();
+		TeCoord2D ptf = vertexSet_[from].location();
+		TeCoord2D ptt = vertexSet_[to].location();
+		i++;
+
+		TeLine2D line;
+		line.add (ptf);
+		line.add (ptt);
+		lineSet.add(line);
+	}
+	return true;
+}
+
+long
+TeTin::oneEdgeWithVertex(long v)
+{
+	long vsize = vertexSet_.size();
+	long edge;
+	if (v < vsize)
+	{
+		TeTinVertex vv = vertexSet_[v];
+		edge = vv.oneEdge();
+	}
+	else
+		return -1;
+
+	// Test to make sure there is no wrong index
+	if ( edge != -1 )
+		if ( ( edgeSet_[edge].to() == v ) ||
+			 ( edgeSet_[edge].from() == v ) )
+		return edge;
+
+	//Fail safe code, must return from previous code
+	static long	oldedge = 0;	// Set one edge only once
+
+	long j = 0;
+	while (j < 2)
+	{
+		unsigned long i;
+		for (i = oldedge; i < edgeSet_.size(); i++)
+		{
+			long from = edgeSet_[i].from();
+			long to   = edgeSet_[i].to();
+			if ( from == -1 || to == -1 )
+				continue;
+			if (from == v || to == v)
+			{
+				oldedge = i;
+				return i;
+			}
+		}
+		oldedge = 0;
+		j++;
+	}
+	return -1;
+}
+
+long
+TeTin::edgeOppVertex(TeTinTriangle& t, long v)
+{
+	long edges[3];
+	t.edges(edges[0],edges[1],edges[2]);
+
+	for (long i = 0; i < 3; i++)
+	{
+		if ( edgeSet_[edges[i]].from() != v &&
+		     edgeSet_[edges[i]].to()   != v )
+			return edges[i];
+	}
+	return -1;
+}
+
+long
+TeTin::vertexOppEdge(long t, long e)
+{
+	long edges[3];
+	triangleSet_[t].edges(edges[0],edges[1],edges[2]);
+
+	long vef(-1), vet(-1);
+	unsigned long i;
+	for (i = 0; i < 3; i++)
+	{
+		if ( edges[i] == e )
+		{
+			vef = edgeSet_[edges[i]].from();
+			vet = edgeSet_[edges[i]].to();
+			break;
+		}
+	}
+	if ( vef == -1 )
+		return -1;
+
+	for (i = 0; i < 3; i++)
+	{
+		if ( edges[i] != e )
+		{
+			if ( vef == edgeSet_[edges[i]].from() ||
+			     vet == edgeSet_[edges[i]].from() )
+				return edgeSet_[edges[i]].to();
+			if ( vef == edgeSet_[edges[i]].to() ||
+			     vet == edgeSet_[edges[i]].to() )
+				return edgeSet_[edges[i]].from();
+			return -1;
+		}
+	}
+	return -1;
+}
+
+long
+TeTin::edgeWithVertexDiffFromEdge(long t, long v, long e)
+{
+	long edges[3];
+	triangleSet_[t].edges(edges[0],edges[1],edges[2]);
+
+	for (long i = 0; i < 3; i++)
+	{
+		if ( edges[i] == e )
+			continue;
+		if ( edgeSet_[edges[i]].from() == v ||
+		     edgeSet_[edges[i]].to()   == v )
+			return edges[i];
+	}
+	return -1;
+}
+
+bool
+TeTin::vertexOppEdges(long v, std::list<long> &edges)
+{
+//	Find one line that contains node
+	long a = oneEdgeWithVertex(v);
+	if (a == -1)
+		return false;
+
+//	1. Defina td como sendo o tri�ngulo que est� � direita da aresta a e
+	long td = edgeSet_[a].right(); // te como sendo o tri�ngulo que est�
+	long te = edgeSet_[a].left();  // � esquerda de a,
+
+	long ai = a; // 2. Defina ai como sendo aresta a 
+	long ti = td;//    e ti como sendo o tri�ngulo td,
+
+	long ao;
+ 
+	if ( ti != -1 ) // 3. Se o tri�ngulo ti n�o for nulo,
+	{				//    insira aresta ao de ti que n�o � diretamente
+		ao = edgeOppVertex ( ti, v );// conectado a v no conjunto A,
+		if (ao == -1)
+			return false;
+		edges.push_back (ao);
+	}
+
+	while (ti != te)// 4. Enquanto ti for diferente do tri�ngulo te,
+	{
+		if (ti == -1)//	4.1. Se o tri�ngulo ti � nulo (esta' na
+		{			 //  borda da triangula��o) fa�a:
+			ti = te; //	 4.1.1. Defina ti como sendo o tri�ngulo te,
+			te = -1; //  4.1.2. Defina te como sendo nulo,
+			ai = a;  //  4.1.3. Defina ai como sendo aresta a,
+			if ( ti != -1 ) // 4.1.4. Se o tri�ngulo ti n�o for nulo,
+			{				// insira aresta ao de ti que n�o � diretamente
+				ao = edgeOppVertex ( ti, v );// conectado a v
+				if (ao == -1)
+					return false;
+				edges.push_back (ao); // a v no conjunto A,
+			}
+			continue;//	 4.1.5. Retorne a 4.
+		}
+
+		long aaux = edgeWithVertexDiffFromEdge ( ti, v, ai );// 4.2. Defina a
+		if (aaux == -1)	 // aresta aaux do tri�ngulo ti que conecta o
+			return false;// v�rtice v e � diferente de ai,
+
+		long taux;
+		if (edgeSet_[aaux].right() == ti) // 4.3. Defina taux como sendo  
+			taux = edgeSet_[aaux].left();//  o tri�ngulo que compartilha
+		else if (edgeSet_[aaux].left() == ti)// a aresta aaux com ti,
+			taux = edgeSet_[aaux].right();
+		else
+			return false;
+
+		ti = taux;// 4.4. Defina ti como sendo o tri�ngulo taux e ai 
+		ai = aaux;//	  como sendo aresta aaux,
+
+		if ( ti != -1 )// 4.5. Se o tri�ngulo ti n�o for nulo, insira
+		{			   //      aresta ao de ti que n�o � diretamente
+			ao = edgeOppVertex ( ti, v ); // conectado a v
+			if (ao == -1)							// no conjunto A,
+				return false;
+			edges.push_back (ao);
+		}
+	} // 4.6. Retorne a 4.
+	return true;
+}
+
+bool
+TeTin::vertexEdges(long v, std::list<long> &edges)
+{
+//	Find one line that contains node
+	long a = oneEdgeWithVertex(v);
+	if (a == -1)
+		return false;
+
+//	1. Defina td como sendo o tri�ngulo que est� � direita da aresta a e
+	long td = edgeSet_[a].right(); // te como sendo o tri�ngulo que est�
+	long te = edgeSet_[a].left();  // � esquerda de a,
+
+	long ai = a; // 2. Defina ai como sendo aresta a 
+	long ti = td;//    e ti como sendo o tri�ngulo td,
+
+	edges.push_back (ai);//	3. Insira a aresta ai no conjunto A,
+
+	while (ti != te)//	4. Enquanto ti for diferente do tri�ngulo te,
+	{
+		if (ti == -1)
+		{// 4.1. Se o tri�ngulo ti � nulo (esta' na borda da triangula��o) fa�a:
+			ti = te;// 4.1.1. Defina ti como sendo o tri�ngulo te,
+			te = -1;// 4.1.2. Defina te como sendo nulo,
+			ai = a;// 4.1.3. Defina ai como sendo aresta a,
+			continue;// 4.1.4. Retorne a 4.
+		}
+
+		long aaux = edgeWithVertexDiffFromEdge ( ti, v, ai );// 4.2. Defina a
+		if (aaux == -1)	 // aresta aaux do tri�ngulo ti que conecta o
+			return false;// v�rtice v e � diferente de ai,
+
+		long taux;
+		if (edgeSet_[aaux].right() == ti) // 4.3. Defina taux como sendo  
+			taux = edgeSet_[aaux].left();//  o tri�ngulo que compartilha
+		else if (edgeSet_[aaux].left() == ti)// a aresta aaux com ti,
+			taux = edgeSet_[aaux].right();
+		else
+			return false;
+
+		ti = taux;// 4.4. Defina ti como sendo o tri�ngulo taux e ai 
+		ai = aaux;//	  como sendo aresta aaux,
+
+		edges.push_back (ai);// 4.5. Se o tri�ngulo ti n�o for nulo, insira
+	} // 4.6. Retorne a 4.
+	return true;
+}
+
+bool
+TeTin::vertexOppVertices(long v, std::list<long> &vertices)
+{
+//	Find one line that contains node
+	long a = oneEdgeWithVertex(v);
+	if (a == -1)
+		return false;
+
+//	1. Defina td como sendo o tri�ngulo que est� � direita da aresta a e
+	long td = edgeSet_[a].right(); // te como sendo o tri�ngulo que est�
+	long te = edgeSet_[a].left();  // � esquerda de a,
+
+	long ai = a; // 2. Defina ai como sendo aresta a 
+	long ti = td;//    e ti como sendo o tri�ngulo td,
+
+	long vi = edgeSet_[a].from();// 3. Insira o v�rtice diferente de v
+	if (vi == v)				// conectado � aresta ai no conjunto V,
+		vi = edgeSet_[a].to();
+	vertices.push_back (vi);
+
+	while (ti != te)// 4. Enquanto ti for diferente do tri�ngulo te,
+	{
+		if (ti == -1)// 4.1. Se o tri�ngulo ti � nulo (esta' na borda 
+		{			 // da triangula��o) fa�a:
+			ti = te; //	4.1.1. Defina ti como sendo o tri�ngulo te,
+			te = -1; //	4.1.2. Defina te como sendo nulo,
+			ai = a;  //	4.1.3. Defina ai como sendo aresta a,
+			continue;//	4.1.4. Retorne a 4.
+		}
+
+		long aaux = edgeWithVertexDiffFromEdge ( ti, v, ai );// 4.2. Defina a
+		if (aaux == -1)	 // aresta aaux do tri�ngulo ti que conecta o
+			return false;// v�rtice v e � diferente de ai,
+
+		long taux;
+		if (edgeSet_[aaux].right() == ti) // 4.3. Defina taux como sendo  
+			taux = edgeSet_[aaux].left();//  o tri�ngulo que compartilha
+		else if (edgeSet_[aaux].left() == ti)// a aresta aaux com ti,
+			taux = edgeSet_[aaux].right();
+		else
+			return false;
+
+		ti = taux;// 4.4. Defina ti como sendo o tri�ngulo taux e ai 
+		ai = aaux;//	  como sendo aresta aaux,
+
+		vi = edgeSet_[ai].from();//	4.5. Insira o v�rtice diferente
+		if (vi == v)	// de v conectado � aresta ai no conjunto V,
+			vi = edgeSet_[ai].to();
+		vertices.push_back (vi);
+	}//	4.6. Retorne a 4.
+	return true;
+}
+
+bool
+TeTin::vertexTriangles(long v, std::list<long> &triangles)
+{
+//	Find one line that contains node
+	long a = oneEdgeWithVertex(v);
+	if (a == -1)
+		return false;
+
+//	1. Defina td como sendo o tri�ngulo que est� � direita da aresta a e
+	long td = edgeSet_[a].right(); // te como sendo o tri�ngulo que est�
+	long te = edgeSet_[a].left();  // � esquerda de a,
+
+	long ai = a; // 2. Defina ai como sendo aresta a 
+	long ti = td;//    e ti como sendo o tri�ngulo td,
+ 
+	if ( ti != -1 ) // 3. Se o tri�ngulo ti n�o for nulo,
+	{				//    insira ti no conjunto T,
+		triangles.push_back (ti);
+	}
+
+	while (ti != te)// 4. Enquanto ti for diferente do tri�ngulo te,
+	{
+		if (ti == -1)//	4.1. Se o tri�ngulo ti � nulo (esta' na
+		{			 //  borda da triangula��o) fa�a:
+			ti = te; //	 4.1.1. Defina ti como sendo o tri�ngulo te,
+			te = -1; //  4.1.2. Defina te como sendo nulo,
+			ai = a;  //  4.1.3. Defina ai como sendo aresta a,
+			if ( ti != -1 ) // 4.1.4. Se o tri�ngulo ti n�o for nulo,
+			{				// insira ti no conjunto T,
+				triangles.push_back (ti);
+			}
+			continue;//	 4.1.5. Retorne a 4.
+		}
+
+		long aaux = edgeWithVertexDiffFromEdge ( ti, v, ai );// 4.2. Defina a
+		if (aaux == -1)	 // aresta aaux do tri�ngulo ti que conecta o
+			return false;// v�rtice v e � diferente de ai,
+
+		long taux;
+		if (edgeSet_[aaux].right() == ti) // 4.3. Defina taux como sendo  
+			taux = edgeSet_[aaux].left();//  o tri�ngulo que compartilha
+		else if (edgeSet_[aaux].left() == ti)// a aresta aaux com ti,
+			taux = edgeSet_[aaux].right();
+		else
+			return false;
+
+		ti = taux;// 4.4. Defina ti como sendo o tri�ngulo taux e ai 
+		ai = aaux;//	  como sendo aresta aaux,
+
+		if ( ti != -1 )// 4.5. Se o tri�ngulo ti n�o for nulo, insira
+		{			   //      aresta ao de ti que n�o � diretamente
+			triangles.push_back (ti);
+		}
+	} // 4.6. Retorne a 4.
+	return true;
+}
+
+bool
+TeTin::vertexOppEdges(long v, std::list<long> &triset, std::list<long> &edges)
+{
+	std::list<long>::iterator tii;
+	for (tii = triset.begin(); tii != triset.end(); tii++)
+	{
+		long ti = *tii;
+		long nedge = this->edgeOppVertex(ti, v);
+		edges.push_back(nedge);
+	}
+	return true;
+}
+
+long
+TeTin::oneTriangleWithVertex(long v)
+{
+//	Find one line that contains node
+	long a = oneEdgeWithVertex(v);
+	if (a == -1)
+		return -1;
+
+	long td = edgeSet_[a].right();
+	if ( td == -1 )
+		return edgeSet_[a].left();
+	else
+		return td;
+}
+
+bool
+TeTin::triangleContainsPoint(TeTinTriangle& t, TeCoord2D& pt) 
+{
+	double	totalArea, triangleArea;
+	TeCoord2D	vert[3];
+
+	this->trianglePoints(t, vert[0], vert[1], vert[2]);
+
+//	Calculate the base triangle area
+	triangleArea = fabs(( (vert[1].x() - vert[0].x()) *
+		              (vert[2].y() - vert[0].y()) ) -
+	 	            ( (vert[2].x() - vert[0].x()) *
+	 	              (vert[1].y() - vert[0].y()) ));
+	triangleArea *= 1.00001;
+	totalArea = fabs(( (vert[0].x() - pt.x()) * (vert[1].y() - pt.y()) ) -
+		         ( (vert[1].x() - pt.x()) * (vert[0].y() - pt.y()) ));
+	if (totalArea > triangleArea)
+		return false;
+
+	totalArea += fabs(( (vert[1].x() - pt.x()) * (vert[2].y() - pt.y()) ) -
+		          ( (vert[2].x() - pt.x()) * (vert[1].y() - pt.y()) ));
+	if (totalArea > triangleArea) 
+		return false;
+
+	totalArea += fabs(( (vert[0].x() - pt.x()) * (vert[2].y() - pt.y()) ) -
+		          ( (vert[2].x() - pt.x()) * (vert[0].y() - pt.y()) ));
+	if (totalArea > triangleArea) 
+		return false;
+
+	return true;
+}
+
+long
+TeTin::triangleAt (TeCoord2D& pt)
+{
+//Seja v um v�rtice qualquer da triangula��o T e p o ponto para o qual se deseja saber qual tri�ngulo t
+//	o cont�m.
+	long vi1;
+
+	TeTinEdgeSet::reverse_iterator i = edgeSet_.rbegin();
+	while ( i != edgeSet_.rend() )
+	{
+		vi1 = (*i++).from();
+		if (vi1 >= 0 ) // -1L)
+			break;
+	}
+	if ( i == edgeSet_.rend() )
+		return -1;
+
+//1. Defina o conjunto T={t1,..., tm} com os m tri�ngulos que compartilham o v�rtice vi,
+	std::list<long> triset;
+	this->vertexTriangles(vi1, triset);
+
+	TeCoord2D pf = vertexSet_[vi1].location();
+	if ( pf == pt )
+//2. Se vi � igual a p, o tri�ngulo que cont�m p � um dos tri�ngulos que compartilham vi.
+// Escolha qualquer um dos tri�ngulos e termine o algoritmo.
+		return ( *(triset.begin()) );
+
+//3. Defina A={a1,...,an} com as n arestas opostas a vi,
+	std::list<long> aedges;
+	this->vertexOppEdges(vi1, triset, aedges);
+
+//4. Defina V={v1,...,vm} com os m v�rtices dos tri�ngulos que cont�m o v�rtice vi,
+	std::list <long> vvertex;
+	this->vertexOppVertices(vi1, vvertex);
+
+//5. Insira o v�rtice v no conjunto VI de v�rtices intersectados,
+	std::set <long> viset;
+	viset.insert(vi1);
+
+//6. Defina o v�rtice auxiliar vaux como sendo vi,
+	long vaux = vi1;
+//   e aresta aaux como sendo inv�lida
+	long aaux = -1;
+	std::vector<long> auxset(3);
+	for (;;)
+	{
+//7. Para cada tri�ngulo ti de T, fa�a:
+		std::list<long>::iterator tii;
+		for (tii = triset.begin(); tii != triset.end(); tii++)
+		{
+			long ti = *tii;
+//7.1. Se o tri�ngulo ti cont�m o ponto pn, termine o algoritmo.
+			if ( this->triangleContainsPoint( ti, pt ) )
+				return ti;
+		}
+//8.	Para cada v�rtice vi de V, fa�a:
+		std::list<long>::iterator vii;
+		for (vii = vvertex.begin(); vii != vvertex.end(); vii++)
+		{
+			long vi = *vii;
+			TeCoord2D ptvi = vertexSet_[vi].location();
+			if ( ptvi == pt )
+//8.1. Se vi � igual a p, o tri�ngulo que cont�m p � um dos tri�ngulos que compartilham vi.
+			{
+				for (tii = triset.begin(); tii != triset.end(); tii++)
+				{
+					long ti = *tii;
+					long v0, v1, v2;
+					this->triangleVertices(ti, v0, v1, v2);
+					if ( v0 == vi || v1 == vi || v2 == vi)
+						return ti;
+				}
+				return -1;
+			}
+		}
+//9. Para cada v�rtice vi de V, fa�a:
+		for ( vii = vvertex.begin(); vii != vvertex.end(); vii++)
+		{
+			long vi = *vii;
+//9.1.	Se vi est� sobre r, fa�a:
+			TeCoord2D ptvi = vertexSet_[vi].location();
+			TeCoord2D pinter;
+			if ( TePerpendicularDistance(pf, pt, ptvi, pinter) < TePrecision::instance().precision() )
+			{
+				TeBox box1;
+				updateBox (box1, pf);
+				updateBox (box1, pt);
+
+				if (TeWithin (pinter, box1) )
+				{
+//9.1.1.	Redefina o conjunto A={a1,..., an} com as n arestas opostas a vi, diferentes de aaux,
+					aedges.clear();
+					this->vertexOppEdges(vi, aedges);
+//9.1.2.	Defina o conjunto Aaux={a1,..., am} com as m arestas compartilhadas por vaux,
+					std::list <long> vauxedges;
+					this->vertexEdges(vaux, vauxedges);
+//9.1.3.	Exclua do conjunto A todas as arestas que pertencem ao conjunto Aaux,
+					for (std::list<long>::iterator vai = vauxedges.begin(); vai != vauxedges.end(); vai++)
+						aedges.remove ( *vai );
+//9.1.4.	Exclua do conjunto A a aresta aaux,
+					aedges.remove ( aaux ); // better perfomance than remove algorithm
+//9.1.5.	Redefina o conjunto V={v1,..., vm} com os m v�rtices dos tri�ngulos que cont�m o v�rtice vi,
+//			diferentes de vaux,
+					vvertex.clear();
+					this->vertexOppVertices(vi, vvertex);
+//9.1.6.	Exclua do conjunto V todos os v�rtices que pertencem ao conjunto VI,
+					for (std::set<long>::iterator vvi = viset.begin(); vvi != viset.end(); vvi++)
+						vvertex.remove ( *vvi );
+//9.1.7.	Redefina o conjunto T={t1, ..., tk } com os k tri�ngulos que cont�m o v�rtice vi,
+					triset.clear();
+					this->vertexTriangles(vi, triset);
+//9.1.8.	Redefina o v�rtice auxiliar vaux como sendo vi,
+					vaux = vi;
+//9.1.8.	Insira o v�rtice vi no conjunto VI de v�rtices intersectados,
+					viset.insert(vi);
+//9.1.8.	Retorne a 7,
+					//pf = vertexSet_[vi].location();
+					break;
+				}
+			}
+		}
+		if ( vii != vvertex.end() )
+			continue; // do for (;;)
+
+//10.	Para cada aresta ai de A, fa�a:
+		std::list<long>::iterator aii;
+		for (aii = aedges.begin(); aii != aedges.end(); aii++)
+		{
+			long ai = *aii;
+//10.1.	Se o ponto p est� sobre ai, fa�a:
+			TeCoord2D pfr = vertexSet_[edgeSet_[ai].from()].location();
+			TeCoord2D pto = vertexSet_[edgeSet_[ai].to()].location();
+			TeCoord2D pinter;
+			if ( TePerpendicularDistance(pfr, pto, pt, pinter) < TePrecision::instance().precision() )
+			{
+				TeBox box1;
+				updateBox (box1, pfr);
+				updateBox (box1, pto);
+				if (TeWithin(pinter, box1) )
+				{
+//10.1.1. Escolha qualquer um dos tri�ngulos que compartilham ai.
+					long ti = edgeSet_[ai].left();
+//10.1.2.	Termine o algoritmo.
+					if ( (ti != -1) && (this->triangleContainsPoint(ti, pt)) )
+						return ( ti );
+					else
+					{
+						ti = edgeSet_[ai].right();
+						if ( (ti != -1) && (this->triangleContainsPoint(ti, pt)) )
+							return ( ti );
+						return -1;
+					}
+				}
+			}
+		}
+
+//11.	Para cada aresta ai de A, fa�a:
+		for (aii = aedges.begin(); aii != aedges.end(); aii++)
+		{
+			long ai = *aii;
+			long vt = edgeSet_[ai].to();
+			long vf = edgeSet_[ai].from();
+			TeCoord2D pi;
+//11.1.	Se ai intersecta r, fa�a:
+			if (TeSegmentsIntersectPoint(vertexSet_[vt].location(), vertexSet_[vf].location(), pf, pt, pi) )
+			{
+//11.1.2.	Defina os tri�ngulos t1 e t2 que compartilham a aresta ai.
+//11.1.3.	Se t2 est� contido no conjunto T , ent�o fa�a taux=t1,
+				long taux = edgeSet_[ai].left();
+				if (taux == -1)
+					return -1;
+				std::list<long>::iterator pos1 = find (triset.begin(), triset.end(), taux);
+				if ( pos1 != triset.end() )
+//11.1.4.	Sen�o, fa�a taux=t2,
+					taux = edgeSet_[ai].right();
+				if (taux == -1)
+					return -1;
+//11.1.5.	Se o tri�ngulo taux cont�m o ponto pn, termine o algoritmo.
+				if ( this->triangleContainsPoint( taux, pt ) )
+					return taux;
+//11.1.6.	Redefina o conjunto A={a1, a2} com as arestas do tri�ngulo taux diferentes de ai,
+				triangleSet_[taux].edges ( auxset[0], auxset[1], auxset[2] );
+				aedges.clear();
+				aedges.insert( aedges.begin(), auxset.begin(), auxset.end() );
+				aedges.remove( ai );
+//11.1.7.	Redefina o conjunto V={v1}. O v�rtice v1 � o v�rtice do tri�ngulo taux que n�o est�
+//			em nenhuma extremidade da aresta ai,
+				long vaux1 = edgeSet_[ai].from();
+				long vaux2 = edgeSet_[ai].to();
+				this->triangleVertices ( taux, auxset[0], auxset[1], auxset[2]);
+				vvertex.clear();
+				vvertex.insert ( vvertex.begin(), auxset.begin(), auxset.end() );
+				vvertex.remove ( vaux1 );
+				vvertex.remove ( vaux2 );
+
+//11.1.8.	Redefina o conjunto T={taux},
+				triset.clear();
+				triset.push_back ( taux );
+//11.1.9.	Redefina aaux como sendo ai,
+				aaux = ai;
+//11.1.10.	Retorne a 8;
+				break;
+			}
+		}
+//12.	Se n�o h� mais arestas em A, ent�o:
+		if ( aii == aedges.end() )
+		{
+//12.1.	Para cada tri�ngulo ti de T, fa�a:
+//			TeTinTriangleIterator tii;
+//			for ( tii = triangleBegin(); tii != triangleEnd(); tii++)
+			long ti;
+			long tEnd = triangleSet_.size();
+			for ( ti = 0; ti < tEnd; ti++)
+			{
+//				TeTinTriangle ti = *tii;
+	//12.1.1.	Se o tri�ngulo ti cont�m o ponto pn, termine o algoritmo.
+				if ( this->triangleContainsPoint( ti, pt ) )
+					return ti;
+			}
+			if (ti == tEnd )
+				return -1;
+		}
+	} // Do for (;;)
+	return -1;
+}
+
+bool
+TeTin::insertPoint(double x, double y, double value)
+{
+//	Get Point to be inserted from std::vector
+	TeCoord2D	pt(x,y);
+	if ( ! TeWithin (pt, vertexSet_.box()) )
+		return false;
+
+//	Find the triangle that owns the point pt	
+	long t = triangleAt ( pt );
+
+	if (t == -1)
+		return false;
+
+	TeCoord2D vert[3];
+	trianglePoints(t, vert[0], vert[1], vert[2]);
+
+	
+
+//	Verify if point is too close to one triangle vertex
+	long j;
+	for ( j = 0; j < 3; j++)
+	{
+		if (pt == vert[j]) // Using precision to compare
+			return false;
+	}
+
+//	Test if the point is on an edge
+	long nedge = -1;
+	double dmin = TeMAXFLOAT;
+	TeCoord2D pmin;
+	for (j = 0; j < 3; j++)
+	{
+		if ( TeWithinOrTouches (pt, vert[j], vert[(j+1)%3]) == false )
+			continue;
+
+		TeCoord2D paux;
+		double daux = TePerpendicularDistance(vert[j], vert[(j+1)%3], pt, paux);
+		if ((daux < TePrecision::instance().precision()) && (daux < dmin))
+		{//			On edge j
+			nedge = j;
+			dmin = daux;
+			pmin = paux;
+		}
+	}
+
+	vertexSet_.add( TeTinVertex (pt, value, NORMALVERTEX, -1 ) );
+	long v = vertexSet_.size()-1;
+
+	std::set<long> trianglesToTest;
+	if (nedge == -1)	// Not on an edge
+	{
+		this->twoNewTriangles(t, v, trianglesToTest);	//If not, split triang
+	}
+	else
+	{
+		long neighids[3];
+		this->triangle3Neighbors(t, neighids[0],neighids[1],neighids[2]);
+		long edges[3];
+		triangleSet_[t].edges( edges[0], edges[1], edges[2] );
+		for (j = 0; j < 3; j++)
+		{	// Check if neighbor triangle opposite vertex is too close
+			if ( neighids[j] == -1L )
+				continue;
+			long oppVertex = edgeOppVertex(neighids[j], edges[j]);
+			long vsize = vertexSet_.size();
+			if ( oppVertex < vsize )
+			{
+			TeCoord2D ptaux = vertexSet_[oppVertex].location();
+			if ( ptaux == pt )
+//			if ( vertexSet_[oppVertex].location() == pt )
+			{
+				// If necessary add code to change oppVertex type and value
+				return false;
+			}
+			}
+		}
+
+//		Duplicate triangle and its neighbor on the same edge
+		long an0 = this->duplicateTriangle( t, nedge, v, trianglesToTest);
+		if (neighids[nedge] != -1L)
+		{
+			long tv = neighids[nedge];
+			this->dupNeighTriangle( tv, an0, v, trianglesToTest);
+		}
+	}
+	this->testDelaunayForVertex(v, trianglesToTest);
+	return true;
+}
+
+bool
+TeTin::trianglePoints(TeTinTriangle& t, TeCoord2D& pt0, TeCoord2D& pt1, TeCoord2D& pt2)
+{
+	long vertex0, vertex1, vertex2;
+	this->triangleVertices(t, vertex0, vertex1, vertex2);
+
+	pt0 = vertexSet_[vertex0].location();
+	pt1 = vertexSet_[vertex1].location();
+	pt2 = vertexSet_[vertex2].location();
+
+	return true;
+}
+
+bool
+TeTin::triangleVertices(TeTinTriangle& t, long& vertex0, long& vertex1, long& vertex2)
+{
+	long edge0, edge1, edge2;
+	t.edges(edge0,edge1,edge2);
+
+	if (edgeSet_[edge0].to() == edgeSet_[edge1].to())
+	{
+		vertex0 = edgeSet_[edge0].from();
+		vertex1 = edgeSet_[edge0].to();
+		vertex2 = edgeSet_[edge1].from();
+	}
+	else if (edgeSet_[edge0].to() == edgeSet_[edge1].from())
+	{
+		vertex0 = edgeSet_[edge0].from();
+		vertex1 = edgeSet_[edge0].to();
+		vertex2 = edgeSet_[edge1].to();
+	}
+	else if (edgeSet_[edge0].from() == edgeSet_[edge1].from())
+	{
+		vertex0 = edgeSet_[edge0].to();
+		vertex1 = edgeSet_[edge0].from();
+		vertex2 = edgeSet_[edge1].to();
+	}
+	else if (edgeSet_[edge0].from() == edgeSet_[edge1].to())
+	{
+		vertex0 = edgeSet_[edge0].to();
+		vertex1 = edgeSet_[edge0].from();
+		vertex2 = edgeSet_[edge1].from();
+	}
+	else
+		return false;
+
+	return true;
+}
+
+bool
+TeTin::triangle3Neighbors(long t, long& neighbor0, long& neighbor1, long& neighbor2)
+{
+	long edge0, edge1, edge2;
+	triangleSet_[t].edges(edge0,edge1,edge2);
+
+	if (edgeSet_[edge0].left() == t)
+		neighbor0 = edgeSet_[edge0].right();
+	else
+		neighbor0 = edgeSet_[edge0].left();
+
+	if (edgeSet_[edge1].left() == t)
+		neighbor1 = edgeSet_[edge1].right();
+	else
+		neighbor1 = edgeSet_[edge1].left();
+
+	if (edgeSet_[edge2].left() == t)
+		neighbor2 = edgeSet_[edge2].right();
+	else
+		neighbor2 = edgeSet_[edge2].left();
+
+	return true;
+}
+
+long
+TeTin::triangleVertexAt(long t, long vertex)
+{
+	long vertices[3];
+	this->triangleVertices ( t, vertices[0],vertices[1],vertices[2] );
+
+	return vertices[vertex];
+}
+
+bool
+TeTin::twoNewTriangles(long t, long v, std::set<long>& triangles)
+{
+//1. Crie o v�rtice vn com os dados da amostra s,
+//	Sint4 vn = nodeId;
+
+//2. Crie 2 novos tri�ngulos t1 e t2,
+	long t1 = triangleSet_.size();
+	long t2 = t1+1;
+
+//3. Crie a nova aresta an0 que conecta os v�rtices vn e v0 e
+//   tem t e t1 como os tri�ngulos que compartilham a aresta.
+	long v0 = this->triangleVertexAt(t,0); //v0 e' o vertice 0 de t
+	edgeSet_.add( TeTinEdge (v, v0, t, t1, NORMALEDGE) );
+	long an0 = edgeSet_.size()-1;
+	vertexSet_[v].setOneEdge (an0);
+
+//4. Crie a nova aresta an1 que conecta os v�rtices vn e v1 e
+// 	tem t1 e t2 como os tri�ngulos que compartilham a aresta.
+	long v1 = this->triangleVertexAt(t,1); //v1 e' o vertice 1 de t
+	edgeSet_.add( TeTinEdge (v, v1, t1, t2, NORMALEDGE) );
+	long an1 = edgeSet_.size()-1;
+
+//5. Crie a nova aresta an2 que conecta os v�rtices vn e v2 e
+//	tem t2 e t como os tri�ngulos que compartilham a aresta.
+	long v2 = this->triangleVertexAt(t,2); //v2 e' o vertice 2 de t
+	edgeSet_.add( TeTinEdge (v, v2, t2, t, NORMALEDGE) );
+	long an2 = edgeSet_.size()-1;
+
+//6. Troque o tri�ngulo t por t1 na aresta a0,
+	long a0 = triangleSet_[t].edgeAt(0); // retorna aresta 0 de t
+	edgeSet_[a0].exchangeTriangle(t,t1);
+
+//7. Defina as arestas de t1 como sendo an0, a0 e an1,
+	triangleSet_.add ( TeTinTriangle (an0, a0, an1) );
+
+//8. Troque o tri�ngulo t por t2 na aresta a1,
+	long a1 = triangleSet_[t].edgeAt(1); // retorna aresta 1 de t
+	edgeSet_[a1].exchangeTriangle(t, t2);
+
+//9. Defina as arestas de t2 como sendo an1, a1 e an2,
+	triangleSet_.add ( TeTinTriangle (an1, a1, an2) );
+
+//10. Defina as arestas de t como sendo an2, a2 e an0,
+	long a2 = triangleSet_[t].edgeAt(2); // retorna aresta 2 de t
+	triangleSet_[t].setEdges(an2, a2, an0);
+
+	triangles.insert(t);
+	triangles.insert(t1);
+	triangles.insert(t2);
+	return true;
+}
+
+long
+TeTin::duplicateTriangle(long t, long n, long v, std::set<long>& triangles)
+{
+// Seja t o tri�ngulo que cont�m cuja n-�sima aresta an � a aresta 
+// pr�xima a amostra s ( n E {0,1,2} ). A aresta an conecta os v�rtices 
+// vn e vj, a aresta aj conecta os v�rtices vj e vk e a aresta ak conecta
+// os v�rtices vk e vn, sendo j o resto da divis�o de n+1 por 3 e k o resto
+// da divis�o de n+2 por 3.
+	long edges[3];
+	triangleSet_[t].edges(edges[0],edges[1],edges[2]);
+
+	long an = edges [ n ];
+	long aj = edges [ (n+1)%3 ];
+	long ak = edges [ (n+2)%3 ];
+
+	long vn = this->triangleVertexAt( t, n );
+
+//	1. Crie o v�rtice v com os dados da amostra s,
+//	2. Defina o tri�ngulo tv que compartilha a aresta an com t,
+	long tv = 0;
+	if (edgeSet_[an].left() == t)
+		tv = edgeSet_[an].right();
+	else if (edgeSet_[an].right() == t)
+		tv = edgeSet_[an].left();
+
+//	3. Defina o v�rtice vop do tri�ngulo t que n�o � conectado a aresta an,
+	long vop = this->triangleVertexAt ( t, (n+2)%3 );
+
+//	4. Crie o novo tri�ngulos t1,
+	long t1 = triangleSet_.size();
+
+//	5. Crie a nova aresta an0 que conecta os v�rtices v e vn e
+//	   tem t1 e tv como os tri�ngulos que compartilham a aresta.
+	edgeSet_.add( TeTinEdge (v, vn, t1, tv, NORMALEDGE) );
+	long an0 = edgeSet_.size()-1;
+
+//	6. Crie a nova aresta an1 que conecta os v�rtices v e vop e
+//	   tem t e t1 como os tri�ngulos que compartilham a aresta.
+	edgeSet_.add( TeTinEdge (v, vop, t, t1, NORMALEDGE) );
+	long an1 = edgeSet_.size()-1;
+
+//	7. Modifique a aresta an para conectar o v�rtice v ao inv�s de vn,
+	edgeSet_[an].exchangeVertex( vn, v );
+	vertexSet_[vn].setOneEdge ( an0 );
+
+//	8. Defina as arestas de t como sendo an, aj e an1,
+	triangleSet_[t].setEdges( an, aj, an1 );
+
+//	9. Modifique a aresta ak para compartilhar o tri�ngulo t1 ao inv�s de t,
+	edgeSet_[ak].exchangeTriangle( t, t1 );
+
+//	10. Defina as arestas de t1 como sendo an0, an1 e ak,
+	triangleSet_.add ( TeTinTriangle (an0, an1, ak) );
+
+	triangles.insert(t);
+	triangles.insert(t1);
+
+	return an0;
+}
+
+bool
+TeTin::dupNeighTriangle(long tv, long an0, long v, std::set<long>& triangles)
+{
+//	11.1. Crie o novo tri�ngulo t2,
+	long t2 = triangleSet_.size();
+
+//	11.2. Defina a aresta av do tri�ngulo tv que cont�m o v�rtice vn
+//	      (obs: s� h� uma aresta porque a outra foi modificada),
+	long vn = edgeSet_[an0].to(); //Due to assembly, dangerous
+	if ( vn == v )
+		vn = edgeSet_[an0].from();
+
+	long edges[3];
+	triangleSet_[tv].edges(edges[0],edges[1],edges[2]);
+	long i;
+	for (i = 0; i < 3; i++)
+	{
+		if ( (edgeSet_[edges[i]].from() == vn) ||
+			 (edgeSet_[edges[i]].to() == vn) )
+			break;
+	}
+	if (i == 3)
+		return false;
+	long av = edges[i];
+
+//	11.3. Defina as outras arestas de tv como sendo av1 e av2.
+	long av1 = edges[ (i+1)%3];
+	long av2 = edges[ (i+2)%3];
+
+//	11.4. Defina o v�rtice vvo conectado a vn por meio da aresta av,
+	long vvo;
+	if (edgeSet_[av].from() == vn)
+		vvo = edgeSet_[av].to();
+	else
+		vvo = edgeSet_[av].from();
+
+//	11.5. Crie a nova aresta an2 que conecta os v�rtices v e vvo e
+//	      tem t e t2 como os tri�ngulos que compartilham a aresta.
+	edgeSet_.add( TeTinEdge (v, vvo, tv, t2, NORMALEDGE) );
+	long an2 = edgeSet_.size()-1;
+
+//	11.6. Troque o tri�ngulo tv por t2 na aresta av,
+	edgeSet_[av].exchangeTriangle( tv, t2 );
+
+//	11.7. Troque o tri�ngulo tv por t2 na aresta an0,
+	edgeSet_[an0].exchangeTriangle( tv, t2 );
+
+//	11.8. Defina as arestas de tv como sendo an2, av1 e av2.
+	triangleSet_[tv].setEdges( an2, av1, av2 );
+
+//	11.9. Defina as arestas de t2 como sendo an0, av e an2,
+	triangleSet_.add ( TeTinTriangle ( an0, av, an2 ) );
+
+	triangles.insert(tv);
+	triangles.insert(t2);
+
+	return true;
+}
+
+void
+TeTin::testDelaunayForVertex(long v, std::set<long>& triangles)
+{
+	while ( triangles.size() )
+	{
+		std::set<long>::iterator i = triangles.begin();
+		long t = *i;
+		triangles.erase(t);
+		this->testDelaunayAt(t, v, triangles);
+	}
+}
+
+bool
+TeTin::testDelaunayAt(long t, long v, std::set<long>& triangles)
+{
+	//	Retrieve line of triangle common to neighbor triangle
+	long e = this->edgeOppVertex (t, v);
+
+//	Retrieve neighbour triangle (tviz) pointer
+	long tviz = edgeSet_[e].left();
+	if ( edgeSet_[e].left() == t )
+		tviz = edgeSet_[e].right();
+	if ( tviz == -1 )
+		return false;
+
+//	Define base triangle (tri) center point
+	TeCoord2D vert[3];
+	this->trianglePoints(t, vert[0], vert[1], vert[2]);
+
+//	Find opposite point to base triangle (tri) inside neighbour (tviz)
+	long vo = this->vertexOppEdge ( tviz, e );
+	TeCoord2D pto = vertexSet_[vo].location();
+
+//	To avoid overflow
+	TeCoord2D ptmin( TeMAXFLOAT, TeMAXFLOAT );
+	long i;
+	for (i = 0; i < 3; i++)
+		if ( vert[i] < ptmin )
+			ptmin = vert[i];
+
+	if ( ! ptmin.tooBig() )
+	{
+		TeCoord2D mptmin ( -ptmin.x(), -ptmin.y() );
+		for (i = 0; i < 3; i++)
+			vert[i] += mptmin;
+		pto += mptmin;
+	}
+
+	TeCoord2D ptc;
+	if ( ! TeFindTriangleCenter( vert[0], vert[1], vert[2], ptc ) )
+		return false;
+
+//	Calculate base triangle (tri) radius
+	double xaux = ptc.x() - vert[0].x();
+	double yaux = ptc.y() - vert[0].y();
+	double raio2 = xaux * xaux + yaux * yaux;
+
+//	Calculate distance from opposite point (tviz) to center point (tri)
+	xaux = ptc.x() - pto.x();
+	yaux = ptc.y() - pto.y();
+	double dist2 = xaux * xaux + yaux * yaux; 
+
+/*	float fr = (float)sqrt(raio2);
+	float fd = (float)sqrt(dist2);
+	if (fr <= fd)
+		return false; */
+
+	if ( raio2 <= dist2 )
+		return false;
+
+	//	If not, change edge between tri and ntri
+	bool status;
+	if ( status = this->swapEdges(t, tviz, e) )
+	{
+		triangles.insert(t);
+		triangles.insert(tviz);
+	}
+	return status;
+}
+
+bool
+TeTin::swapEdges( long t, long tv, long ai )
+{
+	if ( tv == -1 )
+		return false;
+// Seja t o tri�ngulo que cont�m cuja i-�sima aresta ai � a aresta
+//	que se deseja alterar ( i E {0,1,2} ). A aresta ai conecta os
+//	v�rtices vi e vj, a aresta aj conecta os v�rtices vj e vk e a
+//	aresta ak conecta os v�rtices vk e vi, sendo j o resto da divis�o
+//	de i+1 por 3 e k o resto da divis�o de i+2 por 3.
+
+	long tedges[3];
+	triangleSet_[t].edges ( tedges[0], tedges[1], tedges[2] );
+
+	long vertex[3];
+	this->triangleVertices ( t, vertex[0], vertex[1], vertex[2]);
+	long i;
+	for ( i= 0; i < 3; i++ )
+		if ( tedges[i] == ai )
+			break;
+
+	long aj = tedges [ (i+1) % 3 ];
+	long ak = tedges [ (i+2) % 3 ];
+
+	long vi = vertex [ i ];
+	long vj = vertex [ (i+1) % 3 ];
+	long vk = vertex [ (i+2) % 3 ];
+
+// Seja tv o tri�ngulo que compartilha a aresta ai com t. O v�rtice de
+//	tv que n�o � conectado pela aresta ai � o v�rtice vn. As outras
+//	arestas do tri�ngulo tv s�o am que conecta os v�rtices vi e vn e a
+//	aresta an conecta os v�rtices vn e vj.
+	
+	long vn = this->vertexOppEdge ( tv, ai );
+
+	long tvedges [3];
+	triangleSet_[tv].edges ( tvedges[0], tvedges[1], tvedges[2] );
+
+	long am, an = 0;
+	for ( long j = 0; j < 3; j++ )
+	{
+		if ( tvedges [ j ] == ai )
+			continue;
+
+		if ( edgeSet_[tvedges[j]].from() == vn )
+		{
+			if ( edgeSet_[tvedges[j]].to() == vi )
+				am = tvedges [ j ];
+			else if ( edgeSet_[tvedges[j]].to() == vj )
+				an = tvedges [ j ];
+		}
+		else if ( edgeSet_[tvedges[j]].to() == vn )
+		{
+			if ( edgeSet_[tvedges[j]].from() == vi )
+				am = tvedges [ j ];
+			else if ( edgeSet_[tvedges[j]].from() == vj )
+				an = tvedges [ j ];
+		}
+	}
+
+	TeCoord2D ptaux;
+	double tol = TePrecision::instance().precision();
+	if ( TePerpendicularDistance(vertexSet_[vk].location(), vertexSet_[vn].location(),
+								 vertexSet_[vi].location(), ptaux) < tol )
+		return false;
+	if ( TePerpendicularDistance(vertexSet_[vk].location(), vertexSet_[vn].location(),
+								 vertexSet_[vj].location(), ptaux) < TePrecision::instance().precision() )
+		return false;
+
+//	1. Se o segmento de reta formado conectando o v�rtice vk do
+//	   tri�ngulo t ao v�rtice vn de tv intersecta a aresta ai, fa�a:
+	TeCoord2D pi;
+	if (TeSegmentsIntersectPoint(vertexSet_[vi].location(), vertexSet_[vj].location(), vertexSet_[vk].location(), vertexSet_[vn].location(), pi) == false )
+		return false;
+
+//		1.1. Troque na aresta ai o v�rtice vi pelo vertice vk e o
+//			 v�rtice vj pelo v�rtice vn.
+	edgeSet_[ai].exchangeVertex ( vi, vk );
+	edgeSet_[ai].exchangeVertex ( vj, vn );
+
+	if ( vertexSet_[vi].oneEdge() == ai )
+		vertexSet_[vi].setOneEdge ( ak );
+	if ( vertexSet_[vj].oneEdge() == ai )
+		vertexSet_[vj].setOneEdge ( aj );
+
+//		1.2. Troque na aresta an o tri�ngulo tv pelo tri�ngulo t.
+	edgeSet_[an].exchangeTriangle( tv , t );
+
+//		1.3. Troque na aresta ak o tri�ngulo t pelo tri�ngulo tv.
+	edgeSet_[ak].exchangeTriangle( t, tv );
+
+//		1.4. Troque no tri�ngulo t a aresta ai pela aresta an e a
+//			 aresta ak pela aresta ai.
+	for ( i = 0; i < 3; i++ )
+		if ( tedges[i] == ai )
+			break;
+	tedges[i] = an;
+	tedges[(i+2)%3] = ai;
+	triangleSet_[t].setEdges ( tedges[0], tedges[1], tedges[2] );
+
+//		1.5. Troque no tri�ngulo tv a aresta ai pela aresta ak
+	for ( i = 0; i < 3; i++ )
+		if ( tvedges[i] == ai )
+			break;
+	tvedges [i] = ak;
+
+//		 e a aresta an pela aresta ai.
+	for ( i = 0; i < 3; i++ )
+		if (tvedges[i] == an )
+			break;
+	tvedges[i] = ai;
+
+	triangleSet_[tv].setEdges ( tvedges[0], tvedges[1], tvedges[2] );
+
+	return true;
+}
+
+bool
+TeTin::edgesInterBySegment( TeCoord2D& pf, TeCoord2D& pn, std::list<long> &aiset, std::list<long> &viset )
+{
+//		Seja o segmento de reta r que conecta os pontos pf  e pn,
+//1.	Defina o tri�ngulo tf que cont�m o ponto pf,
+	long tf = this->triangleAt (pf);
+	if (tf == -1)
+		return false;
+
+//2.	Defina o v�rtice vaux e aresta aaux, como sendo inv�lidos,
+	long vaux = -1;
+	long aaux = -1;
+
+//3.	Defina o conjunto A={a1, a2, a3} com as arestas de tf,
+	std::vector<long> auxset(3);
+	triangleSet_[tf].edges ( auxset[0], auxset[1], auxset[2] );
+	std::list<long> aedges ( auxset.begin(), auxset.end() );
+
+//4.	Defina o conjunto V={v1, v2, v3} com os v�rtices de tf,
+	this->triangleVertices ( tf, auxset[0], auxset[1], auxset[2]);
+	std::list <long> vvertex ( auxset.begin(), auxset.end() );
+
+//5.	Defina o conjunto T={tf},
+	std::list<long> triset( 1, tf );
+	std::set<long> visetaux;
+
+//6.	Para cada v�rtice vi de V, fa�a:
+	std::list<long>::iterator vii;
+	for (vii = vvertex.begin(); vii != vvertex.end(); vii++)
+	{
+		long vi = *vii;
+		TeCoord2D ptvi = vertexSet_[vi].location();
+		TeCoord2D pinter;
+
+//6.1.	Se o v�rtice vi coincide com pf, fa�a:
+		if ( ptvi == pf )
+		{
+//6.1.1.	Redefina A={a1,...,an} com as n arestas opostas a vi,
+			aedges.clear();
+			this->vertexOppEdges(vi, aedges);
+
+//6.1.2.	Redefina V={v1,...,vm} com os m v�rtices dos tri�ngulos que cont�m o v�rtice vi,
+			vvertex.clear();
+			this->vertexOppVertices(vi, vvertex);
+
+//6.1.3.	Redefina o conjunto T={t1,..., tm} com os m tri�ngulos que compartilham o v�rtice vi,
+			triset.clear();
+			this->vertexTriangles(vi, triset);
+
+//6.1.4.	Redefina o v�rtice auxiliar vaux como sendo vi,
+			vaux = vi;
+			visetaux.insert(vi);
+//6.1.5.	V� para 8,
+			break;
+		}
+	}
+	if ( vii == vvertex.end() )
+	{
+//7.	Para cada aresta ai de A, fa�a:
+		for (std::list<long>::iterator aii = aedges.begin(); aii != aedges.end(); aii++)
+		{
+			long ai = *aii;
+//7.1.	Se o ponto pf est� sobre ai, fa�a:
+			TeCoord2D pfr = vertexSet_[edgeSet_[ai].from()].location();
+			TeCoord2D pto = vertexSet_[edgeSet_[ai].to()].location();
+			TeCoord2D pinter;
+			if ( TePerpendicularDistance(pfr, pto, pf, pinter) < TePrecision::instance().precision() )
+			{
+//7.1.1.	Defina o tri�ngulo tv que compartilha ai com tf,
+				long tv = edgeSet_[ai].right();
+				if (tv == tf)
+					tv = edgeSet_[ai].left();
+				if (tv == -1)
+					return false;
+//7.1.2.	Redefina V={v1, v2, v3, v4} com os v�rtices de tv e tf,
+				vvertex.clear();
+				this->triangleVertices ( tv, auxset[0], auxset[1], auxset[2]);
+				vvertex.insert( vvertex.begin(), auxset.begin(), auxset.end() );
+				this->triangleVertices ( tf, auxset[0], auxset[1], auxset[2]);
+				vvertex.insert( vvertex.begin(), auxset.begin(), auxset.end() );
+				vvertex.sort();
+				vvertex.unique();
+//7.1.3.	Redefina A={a1, a2, a3, a4} com as arestas de tv e tf diferentes de ai,
+				aedges.clear();
+				triangleSet_[tv].edges ( auxset[0], auxset[1], auxset[2] );
+				aedges.insert( aedges.begin(), auxset.begin(), auxset.end() );
+				aedges.remove(ai);
+				triangleSet_[tf].edges ( auxset[0], auxset[1], auxset[2] );
+				aedges.insert( aedges.begin(), auxset.begin(), auxset.end() );
+				aedges.remove(ai);
+
+//7.1.4.	Redefina o conjunto T={tv, tf},
+				triset.push_back ( tv );
+//7.1.5.	Redefina a aresta auxiliar aaux como sendo ai,
+				aiset.push_back ( ai );
+				aaux = ai;
+//7.1.6.	V� para 8,
+				break;
+			}
+		}
+	}
+
+	for (;;)
+	{
+//8.	Para cada tri�ngulo ti de T, fa�a:
+		std::list<long>::iterator tii;
+		for ( tii = triset.begin(); tii != triset.end(); tii++)
+		{
+			long ti = *tii;
+//8.1.1.	Se o tri�ngulo ti cont�m o ponto pn, termine o algoritmo.
+			if ( this->triangleContainsPoint( ti, pn ) )
+				return true;
+		}
+//9.	Para cada v�rtice vi de V, fa�a:
+		std::list<long>::iterator vii;
+		for (vii = vvertex.begin(); vii != vvertex.end(); vii++)
+		{
+			long vi = *vii;
+			TeCoord2D ptvi = vertexSet_[vi].location();
+//9.1.	Se vi coincide com pn, fa�a:
+			if ( ptvi == pn )
+			{
+//9.1.1.	Insira o v�rtice vi no conjunto VI de v�rtices intersectados,
+				viset.push_back ( vi );
+//9.1.2.	Termine o algoritmo.
+				break;
+			}
+		}
+		if ( vii != vvertex.end() )
+			break; // do for (;;)
+
+//10.	Para cada v�rtice vi de V, fa�a:
+		for ( vii = vvertex.begin(); vii != vvertex.end(); vii++)
+		{
+			long vi = *vii;
+//10.1.	Se vi � diferente de vaux e est� sobre r, fa�a:
+			if ( vi != vaux )
+			{
+				TeCoord2D ptvi = vertexSet_[vi].location();
+				TeCoord2D pinter;
+				if ( TePerpendicularDistance(pf, pn, ptvi, pinter) < TePrecision::instance().precision() )
+				{
+					TeBox box1;
+					updateBox (box1, pf);
+					updateBox (box1, pn);
+					if (TeWithin (pinter, box1) )
+					{
+//10.1.1.	Redefina o conjunto A={a1,..., an} com as n arestas opostas a vi, excluindo as arestas de AI,
+						aedges.clear();
+						this->vertexOppEdges(vi, aedges);
+						std::list<long>::iterator aisi;
+						for ( aisi = aiset.begin(); aisi != aiset.end(); aisi++)
+							aedges.remove ( *aisi );
+//10.1.2.	Redefina o conjunto V={v1,..., vm} com os m v�rtices dos tri�ngulos que cont�m o v�rtice vi,
+//			excluindo os vertices de Vi,
+						vvertex.clear();
+						this->vertexOppVertices(vi, vvertex);
+						std::list<long>::iterator visi;
+						for ( visi = viset.begin(); visi != viset.end(); aisi++)
+							viset.remove ( *visi );
+//101.3.	Redefina o conjunto T={t1, ..., tk } com os k tri�ngulos que cont�m o v�rtice vi,
+						triset.clear();
+						this->vertexTriangles(vi, triset);
+//101.4.	Insira o v�rtice vi no conjunto VI de v�rtices intersectados,
+						viset.push_back ( vi );
+//101.5.	Defina o conjunto Ac={a1,..., aj} com as j arestas que cont�m vi, diferentes de aaux,
+//101.6.	Insira as arestas de Ac no conjunto AI de arestas intersectadas,
+						this->vertexEdges(vi, aiset);
+						aiset.sort();
+						aiset.unique();
+//10.7.	Redefina o v�rtice auxiliar vaux como sendo vi,
+						vaux = vi;
+//10.8.	Retorne a 8,
+						break;
+					}
+				}
+			}
+		}
+		if ( vii != vvertex.end() )
+			continue; // do for (;;)
+
+//11.	Para cada aresta ai de A, fa�a:
+		std::list<long>::iterator aii;
+		for (aii = aedges.begin(); aii != aedges.end(); aii++)
+		{
+			long ai = *aii;
+//11.1.	Se o ponto pn est� sobre ai, fa�a:
+			TeCoord2D pfr = vertexSet_[edgeSet_[ai].from()].location();
+			TeCoord2D pto = vertexSet_[edgeSet_[ai].to()].location();
+			TeCoord2D pinter;
+			if ( TePerpendicularDistance(pfr, pto, pn, pinter) < TePrecision::instance().precision() )
+			{
+				TeBox box1;
+				updateBox (box1, pfr);
+				updateBox (box1, pto);
+				if (TeWithin (pinter, box1) )
+				{
+//11.1.1.	Insira a aresta ai no conjunto AI de arestas intersectadas,
+					aiset.push_back ( ai );
+//11.1.2.	Termine o algoritmo.
+					break;
+				}
+			}
+		}
+		if ( aii != aedges.end() )
+			break; // do for (;;)
+
+//12.	Para cada aresta ai de A, fa�a:
+		for (aii = aedges.begin(); aii != aedges.end(); aii++)
+		{
+			long ai = *aii;
+			TeCoord2D pinter;
+			long vt = edgeSet_[ai].to();
+			long vf = edgeSet_[ai].from();
+//12.1.	Se ai intersecta r, fa�a:
+			if ( TeSegmentsIntersectPoint(vertexSet_[vt].location(), vertexSet_[vf].location(), pf, pn, pinter) )
+			{
+//12.1.1.	Insira a aresta ai no conjunto AI de arestas intersectadas,
+				aiset.push_back ( ai );
+//12.1.2.	Defina os tri�ngulos t1 e t2 que compartilham a aresta ai.
+//12.1.3.	Se t2 est� contido no conjunto T , ent�o fa�a taux=t1,
+				long taux = edgeSet_[ai].left();
+				if (taux == -1)
+					return false;
+				std::list<long>::iterator pos1 = find (triset.begin(), triset.end(), taux);
+				if ( pos1 != triset.end() )
+//12.1.4.	Sen�o, fa�a taux=t2,
+					taux = edgeSet_[ai].right();
+				if (taux == -1)
+					return false;
+//12.1.5.	Se o tri�ngulo taux cont�m o ponto pn, termine o algoritmo.
+				if ( this->triangleContainsPoint( taux, pn ) )
+					return true;
+//12.1.6.	Redefina o conjunto A={a1, a2} com as arestas do tri�ngulo taux diferentes de ai,
+				triangleSet_[taux].edges ( auxset[0], auxset[1], auxset[2] );
+				aedges.clear();
+				aedges.insert( aedges.begin(), auxset.begin(), auxset.end() );
+				aedges.remove( ai );
+//12.1.7.	Redefina o conjunto V={v1}. O v�rtice v1 � o v�rtice do tri�ngulo taux que n�o est�
+//			em nenhuma extremidade da aresta ai,
+				long vaux1 = edgeSet_[ai].from();
+				long vaux2 = edgeSet_[ai].to();
+				this->triangleVertices ( taux, auxset[0], auxset[1], auxset[2]);
+				vvertex.clear();
+				vvertex.insert ( vvertex.begin(), auxset.begin(), auxset.end() );
+				vvertex.remove ( vaux1 );
+				vvertex.remove ( vaux2 );
+
+//12.1.8.	Redefina o conjunto T={taux},
+				triset.clear();
+				triset.push_back ( taux );
+//12.1.9.	Redefina aaux como sendo ai,
+				aaux = ai;
+//12.1.10.	Retorne a 8;
+				break;
+			}
+		}
+	} // Do for (;;)
+	return true;
+}
+
+bool
+TeTin::insertSegment( TeCoord2D& pf, TeCoord2D& pn )
+{
+	if ( this->insertPoint( pf.x(), pf.y(), 100.) )
+	{
+		if ( this->insertPoint( pn.x(), pn.y(), 100.) )
+		{
+			std::list<long> aiset;
+			std::list<long> viset;
+			if ( this->edgesInterBySegment( pf, pn, aiset, viset ) )
+			{
+				if ( viset.size() == 0 )
+				{
+					while ( aiset.size() > 0 )
+					{
+//2.	Para cada aresta ai de A, fa�a:
+						std::list<long>::iterator aii;
+						for (aii = aiset.begin(); aii != aiset.end(); aii++)
+						{
+							long ai = *aii;
+//2.1.	Defina os tri�ngulos td e te compartilham ai,
+							long td = edgeSet_[ai].right();
+							long te = edgeSet_[ai].left();
+//2.2.	Defina os v�rtices vm e vn dos tri�ngulos td e te que n�o est�o sobre a aresta ai,
+							long vn = this->vertexOppEdge(td, ai);
+							long vm = this->vertexOppEdge(te, ai);
+//2.3.	Se r n�o intersecta o segmento que conecta os v�rtices vm e vn, fa�a:
+							TeCoord2D pi;
+							if ( TeSegmentsIntersectPoint(vertexSet_[vn].location(), vertexSet_[vm].location(), pf, pn, pi) )
+							{
+//2.3.1.	Se ai intersecta o segmento que conecta os v�rtices vm e vn, fa�a:
+								if ( this->swapEdges( td, te, ai ) )
+								{
+//2.3.1.1.	Redefina ai como sendo o segmento que conecta os v�rtices vm e vn,
+//2.3.1.2.	Redefina adequadamente os tri�ngulos tv e tf,
+//2.3.1.3.	Remova a aresta ai de A,
+									aiset.remove(ai);
+									break;
+								}
+							}
+						}
+						if ( aii != aiset.end() )
+							continue;
+//3.	Se n�o h� mais arestas em A, ent�o:
+//3.1.	Termine o algoritmo.
+//4.	Para cada aresta ai de A, fa�a:
+						aii = aiset.begin();
+						while ( aii != aiset.end() )
+						{
+							long ai = *aii;
+//4.1.	Defina os tri�ngulos td e te compartilham ai,
+							long td = edgeSet_[ai].right();
+							long te = edgeSet_[ai].left();
+//4.2.	Defina os v�rtices vm e vn dos tri�ngulos td e te que n�o est�o sobre a aresta ai,
+//4.3.	Se ai intersecta o segmento que conecta os v�rtices vm e vn, fa�a:
+							if ( this->swapEdges( td, te, ai ) )
+							{
+//4.3.1.	Redefina ai como sendo o segmento que conecta os v�rtices vm e vn,
+//4.3.2.	Redefina adequadamente os tri�ngulos tv e tf,
+								TeCoord2D pinter;
+								long vt = edgeSet_[ai].to();
+								long vf = edgeSet_[ai].from();
+								TeCoord2D pi;
+								if ( ( vertexSet_[vt].location() == pf ) ||
+									 ( vertexSet_[vf].location() == pf ) ||
+									 ( vertexSet_[vt].location() == pn ) ||
+									 ( vertexSet_[vf].location() == pn ) ||
+									 ( TeSegmentsIntersectPoint(vertexSet_[vt].location(), vertexSet_[vf].location(), pf, pn, pi) == false ))
+								{
+//4.3.3.	Se ai n�o intersecta r, fa�a:
+//4.3.3.1.	Remova a aresta ai de A
+									aiset.remove(ai);
+									aii = aiset.begin();
+								}
+								else
+									aii++;
+							}
+							else
+								aii++;
+						}
+//4.3.3.	Retorne a 2.
+					}
+					return true;
+				}
+			}
+		}
+	}
+	return false;
+}
+
+bool
+TeTin::createInitialTriangles(TeBox &box)
+{
+	// Make box 1% bigger
+	zoomOut(box, 1./1.01);
+
+	//	Create and insert initial nodes of the Tin
+ 	vertexSet_.add( TeTinVertex (box.lowerLeft(), TeMAXFLOAT, NORMALVERTEX, 0 ) ); //v0
+ 	vertexSet_.add( TeTinVertex (TeCoord2D(box.x1(),box.y2()), TeMAXFLOAT, NORMALVERTEX, 1 ) ); //v1
+ 	vertexSet_.add( TeTinVertex (box.upperRight(), TeMAXFLOAT, NORMALVERTEX, 2 ) ); //v2
+ 	vertexSet_.add( TeTinVertex (TeCoord2D(box.x2(),box.y1()), TeMAXFLOAT, NORMALVERTEX, 3 ) ); //v3
+
+//	Create and insert initial lines of the Tin
+	edgeSet_.add( TeTinEdge (0, 1, -1, 0, NORMALEDGE) ); //a0
+	edgeSet_.add( TeTinEdge (1, 2, -1, 0, NORMALEDGE) ); //a1
+	edgeSet_.add( TeTinEdge (2, 3, -1, 1, NORMALEDGE) ); //a2
+	edgeSet_.add( TeTinEdge (3, 0, -1, 1, NORMALEDGE) ); //a3
+	edgeSet_.add( TeTinEdge (0, 2,  0, 1, NORMALEDGE) ); //a4
+
+//	Create the two initial triangles of the Tin
+//	Update triangles edges
+	triangleSet_.add ( TeTinTriangle (0, 1, 4) );
+	triangleSet_.add ( TeTinTriangle (2, 3, 4) );
+
+	return true;
+}
+
+bool
+TeTin::insertLineSamples ( TeContourLine& line )
+{
+	TeLineSimplify(line, 20., 200.);
+	unsigned long i;
+	for ( i = 0; i < line.size(); i++ )
+	{
+		TeCoord2D pt = line[i];
+		this->insertPoint(pt.x(), pt.y(), line.value());
+	}
+	return true;
+}
+
+bool
+TeTin::isEdgeTriangle (long t)
+{
+	long neighids[3];
+	this->triangle3Neighbors(t, neighids[0],neighids[1],neighids[2]);
+
+	long i;
+	for (i = 0; i < 3; i++)
+		if ( neighids[i] == -1)
+			return true;
+	return false;
+}
+
+void
+TeTin::convexize ()
+{
+	unsigned long eii;
+
+	for (eii = 0; eii < edgeSet_.size(); eii++)
+	{
+		TeTinEdge ei = this->edge(eii);
+		if ((this->vertex(ei.from()).value() > TeTinBIGFLOAT ) ||
+			(this->vertex(ei.to  ()).value() > TeTinBIGFLOAT ) )
+		{
+			if ((this->vertex(ei.from()).value() > TeTinBIGFLOAT ) && 
+				(this->vertex(ei.to  ()).value() > TeTinBIGFLOAT ) )
+				continue;
+			else
+			{
+				long td = ei.right();
+				long te = ei.left();
+				if ( ! this->isEdgeTriangle(td) || ! this->isEdgeTriangle(te) )
+					this->swapEdges( td, te, eii );
+			}
+		}
+	}
+}
diff --git a/src/terralib/kernel/TeTin.h b/src/terralib/kernel/TeTin.h
new file mode 100644
index 0000000..bb63f67
--- /dev/null
+++ b/src/terralib/kernel/TeTin.h
@@ -0,0 +1,445 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeTin.h
+    \brief This file provides support for a TIN structure
+*/
+#ifndef  __TERRALIB_INTERNAL_TIN_H
+#define  __TERRALIB_INTERNAL_TIN_H
+
+#include "TeGeometry.h"
+#include <list>
+#include <set>
+
+/** @} */ 
+ 
+/** @defgroup MathConst Mathematical constants and macro definitions for use in Tin
+  @{
+ */
+const double	TeTinBIGFLOAT = TeMAXFLOAT / 10.;		//!< Near Maximum float value - TeMAXFLOAT / 10.
+
+//!  Tin Vertex types 
+enum TeTinVertexType 
+{ NORMALVERTEX = 0, ONCONTOURVERTEX = 1, ONBREAKLINEVERTEX = 0x10 };
+
+//!  A basic class for handling vertex of TIN
+/*!
+	\sa TeGeometry TeMeasure
+*/
+class TL_DLL TeTinVertex : public TeGeomSingle<TeCoord2D>, public TeMeasure
+{
+public:
+
+	//! Empty constructor
+	TeTinVertex() : TeMeasure ( TeMAXFLOAT ), oneEdge_ (-1) {}
+
+	//! Constructor with parameters
+	TeTinVertex( TeCoord2D xy, double value, TeTinVertexType type,
+		long edge ) :
+		TeGeomSingle<TeCoord2D> (xy), TeMeasure ( value ),
+		 type_ (type), oneEdge_ ( edge )
+		{ if ( ! xy.tooBig() ) TeGeometry::setBox(TeBox(xy,xy)); }
+
+// -- Methods
+//
+	//! Returns TRUE if a TeTinVertex is equal to other
+	bool operator== (const TeTinVertex& other) const
+	{
+		if((value_ == other.value_) && (type_ == other.type_) )
+		{
+			TeCoord2D p1 = location();
+			TeCoord2D p2 = other.location();
+			return p1==p2;
+		}
+		return false;
+	}
+
+	long oneEdge () 
+	{ return oneEdge_; }
+
+	void setOneEdge (long oneEdge) 
+	{ oneEdge_ = oneEdge; }
+
+	TeTinVertexType type () 
+	{ return type_; }
+
+	void setType (TeTinVertexType type) 
+	{ type_ = type; }
+
+	void value (double value) 
+	{ value_ = value; }
+
+	double value () 
+	{ return value_; }
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+
+private:
+
+	TeTinVertexType type_;
+	long oneEdge_;
+};
+
+//!  A basic class for handling a std::set of TeTinVertex
+class TL_DLL TeTinVertexSet : public TeGeomComposite <TeTinVertex>
+{
+public:
+
+// -- Constructors
+
+	TeTinVertexSet() {}
+
+// -- Methods
+
+	bool loadFromFile (std::string &fileName);
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+};
+
+//! Tin Edges type 
+enum TeTinEdgeType 
+{ NORMALEDGE, ONCONTOUREDGE, ONBREAKLINEEDGE };
+
+//!  A basic class for handling edges of a  TIN
+/*!
+	\sa TeGeometry
+*/
+class TL_DLL TeTinEdge : public TeGeometry
+{
+public:
+
+// -- Constructors
+
+	TeTinEdge() {}
+	TeTinEdge(long from, long to, long left, long right,
+		TeTinEdgeType type) :
+	from_ (from), to_ (to), left_ (left), right_ (right), type_ (type)
+	{}
+
+// -- Methods
+
+	//! Returns TRUE if a TeTinEdge is equal to other
+	bool operator== (const TeTinEdge& other) const
+	{
+		if( (to_ == other.to_) && (from_ == other.from_) &&
+			(left_ == other.left_) && (right_ == other.right_) &&
+			(type_ == other.type_) )
+			return true;
+
+		return false;
+	}
+
+	long from () 
+	{ return from_; }
+
+	long to () 
+	{ return to_; }
+
+	void setVertices (long from, long to)
+	{ 
+		from_ = from;
+		to_ = to;
+	}
+
+	void swapVertices ()
+	{ 
+		long aux = from_;
+		from_ = to_;
+		to_ = aux;
+	}
+
+	long left () 
+	{ return left_; }
+
+	long right ()
+	{ return right_; }
+
+	void setTriangles (long left, long right)
+	{ 
+		left_ = left;
+		right_ = right;
+	}
+
+	void swapTriangles ()
+	{ 
+		long aux = left_;
+		left_ = right_;
+		right_ = aux;
+	}
+	
+	void exchangeTriangle ( long t1, long t2 )
+	{
+		if (left_ == t1 )
+			left_ = t2;
+		else
+			right_ = t2;
+	}
+
+	void exchangeVertex ( long v1, long v2 )
+	{
+		if (from_ == v1 )
+			from_ = v2;
+		else
+			to_ = v2;
+	}
+
+	TeTinEdgeType type () 
+	{ return type_; }
+
+	void setType (TeTinEdgeType type) 
+	{ type_ = type; }
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+
+private:
+
+	long	from_, to_;
+	long	left_, right_;
+	TeTinEdgeType type_;
+};
+
+//!  A basic class for handling a std::set of TeTinEdge
+class TL_DLL TeTinEdgeSet : public TeGeomComposite<TeTinEdge>
+{
+public:
+
+// -- Constructors
+
+	TeTinEdgeSet()	{}
+
+// -- Methods
+
+	bool loadFromFile (std::string &fileName);
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+};
+
+//! TeTinTriangle: A class for handling a TIN triangle
+class TL_DLL TeTinTriangle : public TeGeometry
+{
+public:
+
+// -- Constructors
+
+	TeTinTriangle()
+	{
+		triEdges_[0] = -1;
+		triEdges_[1] = -1;
+		triEdges_[2] = -1;
+	}
+
+	TeTinTriangle(long first, long second, long third) 
+	{
+		triEdges_[0] = first;
+		triEdges_[1] = second;
+		triEdges_[2] = third;
+	}
+
+// -- Methods
+
+	//! Returns TRUE if a TeTinTriangle is equal to other
+	bool operator== (const TeTinTriangle& other) const
+	{
+		if( (triEdges_[0] == other.triEdges_[0]) &&
+			(triEdges_[1] == other.triEdges_[1]) &&
+			(triEdges_[2] == other.triEdges_[2]) )
+			return true;
+
+		return false;
+	}
+
+	void setEdges (long first, long second, long third)
+	{
+		triEdges_[0] = first;
+		triEdges_[1] = second;
+		triEdges_[2] = third;
+	}
+
+	//! Return triangle edges ids
+	/*!
+      \param first  first edge
+      \param second second edge
+      \param third  third edge
+	 */
+	void edges (long& first, long& second, long& third)
+	{
+		first  = triEdges_[0];
+		second = triEdges_[1];
+		third  = triEdges_[2];
+	}
+
+	long edgeAt (short num)
+	{
+		if ((num > -1) && (num < 3))
+			return triEdges_[num];
+		else
+			return -1;
+	}
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+
+private:
+
+	long	triEdges_[3];
+};
+
+//! TeTinTriangle: A class for handling a std::set of TIN triangles
+class TL_DLL TeTinTriangleSet : public TeGeomComposite<TeTinTriangle>
+{
+public:
+
+// -- Constructors
+
+	TeTinTriangleSet()	{}
+
+// -- Methods
+
+	bool loadFromFile (std::string &fileName);
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+};
+
+//! A class to handle a TIN
+class TL_DLL TeTin
+{
+public:
+
+// -- Constructors
+
+	TeTin() {}
+	TeTin(TeBox & /* box */) {}
+
+// -- Methods
+	void clear()
+	{
+		vertexSet_.clear();
+		triangleSet_.clear();
+		edgeSet_.clear();
+	}
+
+	TeBox box()
+	{ return vertexSet_.box(); }
+
+	bool createInitialTriangles(TeBox &box);
+	bool insertLineSamples ( TeContourLine& line );
+	bool loadFromFile(std::string &fileName);
+	bool getLines(TeLineSet &lineSet);
+	bool isEmpty ()
+	{ return ( vertexSet_.empty() && triangleSet_.empty() &&
+	           edgeSet_.empty() ); } 
+
+	TeTinEdge& edge (long i)
+	{ return edgeSet_[i]; }
+
+	TeTinVertex& vertex (long i)
+	{ return vertexSet_[i];	}
+
+	TeTinTriangle& triangle (long i)
+	{ return triangleSet_[i];	}
+
+	typedef TeTinVertexSet::iterator TeTinVertexIterator;
+
+	TeTinVertexIterator vertexBegin()
+	{ return vertexSet_.begin(); }
+
+	TeTinVertexIterator vertexEnd()
+	{ return vertexSet_.end(); }
+
+	typedef  TeTinEdgeSet::iterator TeTinEdgeIterator;
+
+	TeTinEdgeIterator edgeBegin()
+	{ return edgeSet_.begin(); }
+
+	TeTinEdgeIterator edgeEnd()
+	{ return edgeSet_.end(); }
+
+	typedef  TeTinTriangleSet::iterator TeTinTriangleIterator;
+
+	TeTinTriangleIterator triangleBegin()
+	{ return triangleSet_.begin(); }
+
+	TeTinTriangleIterator triangleEnd()
+	{ return triangleSet_.end(); }
+
+	bool triangleContainsPoint(TeTinTriangle& t, TeCoord2D& pt);
+	bool triangleContainsPoint(long t, TeCoord2D& pt)
+	{ return triangleContainsPoint(triangleSet_[t], pt); }
+
+	long edgeWithVertexDiffFromEdge(long t, long v, long e);
+	long oneTriangleWithVertex(long vertex);
+	long oneEdgeWithVertex(long vertex);
+
+	long edgeOppVertex(TeTinTriangle& triangle, long vertex);
+	long edgeOppVertex(long triangle, long vertex)
+	{ return edgeOppVertex(triangleSet_[triangle], vertex); }
+
+	long vertexOppEdge(long triangle, long edge);
+	bool vertexEdges(long vertex, std::list<long> &edges);
+	bool vertexOppEdges(long vertex, std::list<long> &edges);
+	bool vertexOppEdges(long v, std::list<long> &triset, std::list<long> &edges);
+
+	bool vertexOppVertices(long vertex, std::list<long> &vertices);
+	bool vertexSecondNeighVertices(long v, list<long> &vertices);
+	bool vertexTriangles(long vertex, std::list<long> &triangles);
+	bool triangle3Neighbors(long t, long& neighbor0, long& neighbor1, long& neighbor2);
+	long triangleAt (TeCoord2D& pt);
+
+	bool triangleVertices(TeTinTriangle& t, long& vertex0, long& vertex1, long& vertex2);
+	bool triangleVertices(long t, long& vertex0, long& vertex1, long& vertex2)
+	{ return this->triangleVertices(triangleSet_[t], vertex0, vertex1, vertex2); }
+
+	long triangleVertexAt(long t, long vertex);
+
+	bool trianglePoints(TeTinTriangle& t, TeCoord2D& pt0, TeCoord2D& pt1, TeCoord2D& pt2);
+	bool trianglePoints(long t, TeCoord2D& pt0, TeCoord2D& pt1, TeCoord2D& pt2)
+	{ return trianglePoints( triangleSet_[t], pt0, pt1, pt2); }
+	
+	bool twoNewTriangles(long t, long v, std::set<long>& triangles);
+	long duplicateTriangle(long t, long n, long v, std::set<long>& triangles);
+	bool dupNeighTriangle (long t, long e, long v, std::set<long>& triangles);
+
+	void testDelaunayForVertex(long v, std::set<long>& triangles);
+	bool testDelaunayAt(long t, long v, std::set<long>& triangles);
+
+	bool swapEdges( long t, long tv, long ai );
+
+	bool insertPoint(TeSample& xyz)
+	{ return insertPoint ( xyz.location().x(),xyz.location().y(),xyz.value() ); }
+
+	bool insertPoint(double x, double y, double value);
+
+	bool edgesInterBySegment( TeCoord2D& pf, TeCoord2D& pn, std::list<long> &aiset, std::list<long> &viset );
+	bool insertSegment( TeCoord2D& pf, TeCoord2D& pn );
+
+
+	void convexize ();
+	bool isEdgeTriangle (long t);
+
+	TeGeomRep elemType() { return TeSAMPLES; }
+private:
+
+	TeTinVertexSet		vertexSet_;
+	TeTinTriangleSet	triangleSet_;
+	TeTinEdgeSet		edgeSet_;
+};
+
+#endif
diff --git a/src/terralib/kernel/TeUtils.cpp b/src/terralib/kernel/TeUtils.cpp
new file mode 100644
index 0000000..9357a86
--- /dev/null
+++ b/src/terralib/kernel/TeUtils.cpp
@@ -0,0 +1,660 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#include "TeUtils.h"
+#include "TeDefines.h"
+#include "TeException.h"
+#include "TeAgnostic.h"
+
+#include <cstdlib>
+#include <stdio.h>
+#include <ctype.h>
+#include <cstring> //FAMI
+
+/* The following includes are needed for pysical memory checking */
+#if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+  #include <windows.h>
+  #include <winbase.h>
+#elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  #include <unistd.h>
+  #include <string.h>
+  #include <errno.h>
+  
+  #if defined( __FreeBSD__ ) || defined( __APPLE_CC__ )
+    #include <sys/sysctl.h> /* BSD workaround */
+  #endif
+#else
+  #error "Unsuported plataform for physical memory checking"
+#endif
+
+
+string
+Te2String ( const int value )
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf ( name, "%d", value );
+	return name;
+}
+
+string
+Te2String ( const unsigned int value )
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf ( name, "%u", value );
+	return name;
+}
+
+string
+Te2String ( const long value )
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf ( name, "%ld", value );
+	return name;
+}
+
+string
+Te2String ( const unsigned long value )
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf ( name, "%lu", value );
+	return name;
+}
+
+void
+TeTrim(string &str)
+{
+//empty strings are bad
+    if(str.empty())
+		return;
+//remove left whitespace, \t and \n
+	string::iterator it;
+    for(it=str.begin();it!=str.end() &&
+		((*it) == ' ' ||  (*it) == '\t' || (*it) == '\n');it++);
+		str.erase(str.begin(),it);
+//empty strings are bad
+    if(str.empty())
+		return;
+//remove right whitespace, \t and \n
+	it=str.end();
+    for(--it;it!=str.begin() && 
+	   ((*it) == ' ' ||  (*it) == '\t' || (*it) == '\n');--it);
+		str.erase(++it,str.end());
+}
+
+string
+TeRemoveSpecialChars ( string& str)
+{
+	string aux; 
+	string::iterator it;
+    for(it=str.begin();it!=str.end();it++)
+	{
+		if (isalnum(*it))
+			aux+=(*it);
+	}
+	return aux;
+}
+
+string
+Te2String ( const double value, int precision )
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf(name, "%.*f", precision, value );
+	return name;
+}
+
+
+string
+Te2String ( const double value )
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf ( name, "%e", value ); 
+	return name;
+}
+
+string 
+TeGetExtension ( const char* value )
+{
+	if (!value)
+		return string("");
+	string name = string(value);
+	int len = strlen ( value );
+	unsigned int ip = name.rfind('.');
+	if (ip == std::string::npos)
+		return "";
+	else
+		return name.substr(ip+1,len-1);
+}
+
+string 
+TeGetName ( const char* value )
+{
+	if (!value)
+		return string("");
+	string name = string(value);
+	int len = strlen ( value );
+
+	int sp = name.rfind('\\')+1;
+	int ip = (name.substr(sp,len-1)).rfind('.');
+	if (ip>0)
+		return name.substr(0,sp+ip);
+	else 
+		return name;
+}
+
+string
+TeGetBaseName ( const char* value )
+{
+	if (!value)
+		return string("");
+	string name = string(value);
+	int ip = name.rfind('.');
+	unsigned int is = name.rfind('\\');
+	if (is == std::string::npos)
+		is = name.rfind('/');
+	return name.substr(is+1,ip-is-1);
+}
+
+string 
+TeGetPath(const char* value)
+{
+	if (!value)
+		return string(".");
+	string name = string (value);
+	std::string::size_type ip = name.rfind('/');
+	if (ip == std::string::npos)
+		return string(".");
+	else
+		return name.substr(0,ip);
+}
+
+void
+TeConvertToUpperCase ( const string& name, char upName[] )
+{
+	
+	const char* old = name.c_str();
+
+	const char* p;
+	int i = 0;
+
+	for( p = old; p < old + strlen ( old) ; p++ )
+	{
+		if ( islower ( *p  ) )
+			upName[i] = toupper( *p );
+		else
+			upName [i] = *p;
+		i++;
+	}
+	upName[i] = '\0';
+}
+
+string
+TeConvertToUpperCase (const string &name)
+{
+	string aux = "";
+	for(unsigned int i=0; i < strlen(name.c_str()); i++)
+	{
+		if((name[i] >= 97) && (name[i] <= 122))
+			aux += name[i] - 32;
+       else
+			aux += name[i];
+    }
+	return aux;
+}
+
+
+string
+TeConvertToLowerCase (const string &name)
+{
+	string aux = "";
+	for(unsigned int i=0; i < strlen(name.c_str()); i++)
+	{
+		if((name[i] >= 65) && (name[i] <= 90))
+			aux += name[i] + 32;
+		else
+			aux += name[i];
+    }
+	return aux;
+}
+
+
+//-----------------------------------------------------------------------
+//
+//      Purpose:        STL split string utility
+//      Author:         Paul J. Weiss
+//      Extracted from: The Code Project (http://www.codeproject.com/)
+//
+//------------------------------------------------------------------------
+
+int TeSplitString(const string& input, const string& delimiter, vector<string>& results)
+{
+   int iPos = 0;
+   int newPos = -1;
+   int sizeS2 = delimiter.size();
+   int isize = input.size();
+
+   if (input.empty())
+	   return 0;
+  
+   vector<int> positions;
+
+   newPos = input.find (delimiter, 0);
+
+   if( newPos < 0 ) 
+   { 
+       results.push_back(input);
+	   return 1;
+   }
+
+   int numFound = 0;
+   while( newPos >= iPos )
+   {
+       numFound++;
+       positions.push_back(newPos);
+       iPos = newPos;
+       newPos = input.find (delimiter, iPos+sizeS2+1);
+   }
+
+   for( unsigned int i=0; i <= positions.size(); i++ )
+   {
+       string s;
+       if( i == 0 )
+	   {
+	   s = input.substr( i, positions[i] );
+	   }
+	   else
+	   {
+       int offset=0;
+	   if(i>0)	 offset= positions[i-1] + sizeS2;
+       if( offset < isize )
+       {
+           if( i == positions.size() )
+           {
+		s = input.substr(offset);
+           }
+           else if( i > 0 )
+           {
+                s = input.substr( positions[i-1] + sizeS2, positions[i] - positions[i-1] - sizeS2 );
+           }
+       }
+	   }
+       if( s.size() > 0 )
+       {
+               results.push_back(s);
+       }
+   }
+   return numFound;
+}
+
+bool TeNoCaseCmp(const char&  c1, const char& c2)
+{
+	return toupper(c1) == toupper(c2);
+}
+
+
+bool
+TeStringCompare(const string& str1, const string& str2, bool caseS)
+{
+	if (!caseS)
+	{
+		return ((str1.size() == str2.size()) &&
+			    equal(str1.begin(),str1.end(),str2.begin(),TeNoCaseCmp));
+	}
+	else
+		return (str1 == str2);
+}
+
+double 
+TeRoundD(double val, int precision)
+{
+	char name [ TeNAME_LENGTH ];
+	sprintf ( name, "%.*f", precision, val);
+	return atof(name);
+
+}
+
+bool
+TeCompareDouble(double a, double b, int precision)
+{
+	char bufa [ TeNAME_LENGTH ];
+	char bufb [ TeNAME_LENGTH ];
+	if (precision == 0)
+	{
+		sprintf ( bufa, "%f", a );
+		sprintf ( bufb, "%f", b );
+	}
+	else
+	{
+		sprintf ( bufa, "%.*f", precision, a );
+		sprintf ( bufb, "%.*f", precision, b );
+	}
+
+	string A = bufa;
+	string B = bufb;
+	return (A == B);
+}
+
+void TeWriteToFile(const string& fileName, const string& text, const string& mode)
+{
+	FILE *f;
+
+	f = fopen(fileName.c_str(), mode.c_str());
+
+	fprintf(f, "%s", text.c_str());
+
+	fclose(f);
+
+	return;
+}
+
+double TeAdjustToPrecision(double val, int precision, bool reduce)
+{
+	double p = pow(10.0, (double)-precision);
+	
+	if (reduce)
+		return (val - p);
+
+	return (val + p);
+}
+
+string TeCheckName(const string& name, bool& changed, string& invalidChar)
+{
+	string newName = name;
+	if(newName[0] >= 0x30 && newName[0] <= 0x39)
+	{
+		newName[0] = '_';
+		invalidChar = "begin with a numeric character";
+	}
+
+	int ff = newName.find(" ");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find(" ");
+		invalidChar = "blank space";
+	}
+
+	ff = newName.find(".");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find(".");
+		invalidChar = "dot .";
+	}
+
+	ff = newName.find("*");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("*");
+		invalidChar = "mathematical symbol *";
+	}
+
+	ff = newName.find("/");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("/");
+		invalidChar = "mathematical symbol /";
+	}
+
+	ff = newName.find("(");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("(");
+		invalidChar = "parentheses (";
+	}
+
+	ff = newName.find(")");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find(")");
+		invalidChar = "parentheses )";
+	}
+	ff = newName.find("-");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("-");
+		invalidChar = "mathematical symbol -";
+	}
+
+	ff = newName.find("+");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("+");
+		invalidChar = "mathematical symbol +";
+	}
+
+	ff = newName.find("%");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("%");
+		invalidChar = "mathematical symbol %";
+	}
+
+	ff = newName.find(">");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find(">");
+		invalidChar = "mathematical symbol >";
+	}
+
+	ff = newName.find("<");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("<");
+		invalidChar = "mathematical symbol <";
+	}
+
+	ff = newName.find("&");
+	while(ff >= 0)
+	{
+		newName.replace(ff, 1, "_");
+		ff = newName.find("&");
+		invalidChar = "mathematical symbol <";
+	}
+
+	string u = TeConvertToUpperCase(newName);
+	if(u=="OR" || u=="AND" || u=="NOT" || u=="LIKE" ||
+	   u=="SELECT" || u=="FROM" || u=="UPDATE" || u=="DELETE" ||u=="BY" || u=="GROUP" || u=="ORDER" ||
+	   u=="DROP" || u=="INTO" || u=="VALUE" || u=="IN" || u=="ASC" || u=="DESC"|| u=="COUNT" || u=="JOIN" ||
+	   u=="LEFT" || u=="RIGHT" || u=="INNER" || u=="UNION" || u=="IS" || u=="NULL" || u=="WHERE" ||
+	   u=="BETWEEN" || u=="DISTINCT" || u=="TRY" || u=="IT" || u=="INSERT" || u=="ALIASES" || u=="CREATE" ||
+	   u=="ALTER" || u=="TABLE" || u=="INDEX" || u=="ALL" || u=="HAVING" || u=="EXEC" || u== "SET" ||
+	   u == "AVG" || u == "MAX" || u == "MIN" || u == "SUM")
+	{
+		invalidChar = newName;	
+		newName += "_";
+	}
+
+	// check against geometry tables field names
+	string n = TeConvertToLowerCase(newName); 
+
+	if (n == "x" || n == "y" || n == "object_id" ||
+	   n == "geom_id" || n == "num_coords" || 
+	   n == "lower_x" || n == "lower_y" ||
+	   n == "upper_x" || n == "upper_y" ||
+	   n == "ext_max" || n == "spatial_data" ||
+	   n == "num_holes" || n == "parent_id" ||
+	   n == "col_number" || n == "row_number" || 
+	   n == "text_value" || n == "angle" ||
+	   n == "height" || n == "alignment_vert" ||
+	   n == "alignment_horiz" || n=="from_node" ||
+	   n == "to_node")
+	{
+			invalidChar = newName;
+			newName += "_";
+	}
+
+	// reserved words
+	if( (n=="zone") || (n=="comp") || (n=="no") || (n=="local") ||
+		(n=="level") || (n=="long"))
+	{
+		invalidChar = newName;
+		newName += "_";
+	}
+
+	changed = true;
+	if(name == newName)
+		changed = false;
+	return newName;
+}
+
+
+unsigned long int TeGetFreePhysicalMemory()
+{
+  unsigned long int freemem = 0;
+
+  #if defined __unix__
+    #if defined( __FreeBSD__ ) || defined( __APPLE_CC__ )
+      /* BSD workaround */
+      
+      unsigned int usermem;
+      size_t usermem_len = sizeof( usermem );
+      int mib[2] = { CTL_HW, HW_USERMEM };
+      
+      if( sysctl( mib, ( 2 * sizeof(int) ), &usermem, &usermem_len, NULL, 0 ) 
+        == 0 ) {
+        
+        freemem = (unsigned long int)usermem;
+      } else {
+        throw( "TeGetFreePhysicalMemory error" );
+      }
+    #else
+      /* Other linux stuff */
+      
+      freemem = (unsigned long int) sysconf( _SC_PAGESIZE ) *
+        (unsigned long int) sysconf( _SC_AVPHYS_PAGES );
+    #endif
+  #elif defined WIN32
+      LPMEMORYSTATUS status_buffer = new MEMORYSTATUS;
+      GlobalMemoryStatus( status_buffer );
+      freemem = (unsigned long int) status_buffer->dwAvailPhys;
+      delete status_buffer;
+  #else
+      #error "Unsuported plataform for physical memory checking"
+  #endif
+
+  return freemem;
+}
+
+
+unsigned long int TeGetTotalPhysicalMemory()
+{
+  unsigned long int totalmem = 0;
+
+  #if defined __unix__
+    #if defined( __FreeBSD__ ) || defined( __APPLE_CC__ )
+      /* BSD workaround */
+      
+      unsigned int physmem;
+      size_t physmem_len = sizeof( physmem );
+      int mib[2] = { CTL_HW, HW_PHYSMEM };
+      
+      if( sysctl( mib, ( 2 * sizeof(int) ), &physmem, &physmem_len, NULL, 0 ) 
+        == 0 ) {
+        
+        totalmem = (unsigned long int)physmem; 
+      } else {
+        throw( "TeGetTotalPhysicalMemory error" );
+      }
+    #else
+      /* Other linux stuff */  
+  
+      totalmem = (unsigned long int) sysconf( _SC_PAGESIZE ) *
+        (unsigned long int) sysconf( _SC_PHYS_PAGES );
+    #endif
+  #elif defined WIN32
+    LPMEMORYSTATUS status_buffer = new MEMORYSTATUS;
+    GlobalMemoryStatus( status_buffer );
+    totalmem = (unsigned long int) status_buffer->dwTotalPhys;
+    delete status_buffer;
+  #else
+    #error "Unsuported plataform for physical memory checking"
+  #endif
+
+  return totalmem;
+}
+
+
+unsigned int TeGetPhysProcNumber()
+{
+  unsigned int procnmb = 0;
+  
+  #if TePLATFORM == TePLATFORMCODE_MSWINDOWS
+    SYSTEM_INFO siSysInfo;
+    GetSystemInfo(&siSysInfo);
+    procnmb = (unsigned int)siSysInfo.dwNumberOfProcessors;
+  #elif TePLATFORM == TePLATFORMCODE_LINUX || TePLATFORM == TePLATFORMCODE_AIX
+  
+    procnmb = (unsigned int)sysconf(_SC_NPROCESSORS_ONLN );
+  #else
+    #error "ERROR: Unsupported platform"
+  #endif    
+
+  return procnmb;
+}
+  
+  
+bool TeGetTempFileName( std::string& filename )
+{
+    cerr << "ERROR - TeGetTempFileName() should have never be called!!!"<< endl;
+    return false;
+}
+
+
+unsigned long int TeGetFileSize( const std::string& filename )
+{
+  FILE* fileptr = fopen( filename.c_str(), "r" );
+  
+  if( fileptr == 0 ) {
+    throw TeException( CANNOT_OPEN_FILE, "File not found", false );
+  }
+  
+  fseek( fileptr, 0, SEEK_END );
+  
+  unsigned long int filesize = ( unsigned long int ) ftell( fileptr );
+  
+  fclose( fileptr );
+  
+  return filesize;
+}
+
+
+bool TeCheckFileExistence( const std::string& filename )
+{
+  FILE* fileptr = fopen( filename.c_str(), "r" );
+  
+  if( fileptr == 0 ) {
+    return false;
+  } else {
+    fclose( fileptr );
+    return true;
+  }
+}
diff --git a/src/terralib/kernel/TeUtils.h b/src/terralib/kernel/TeUtils.h
new file mode 100644
index 0000000..b0bc728
--- /dev/null
+++ b/src/terralib/kernel/TeUtils.h
@@ -0,0 +1,266 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2004 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeUtils.h
+     \brief This file contains some general purpose utilitary  functions
+*/
+#ifndef  __TERRALIB_INTERNAL_UTILS_H
+#define  __TERRALIB_INTERNAL_UTILS_H
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#include <string>
+#include <vector>
+#include <cstdio>
+#include <time.h>
+
+
+#include "TeCoord2D.h"
+#include "TeProgress.h"
+
+using namespace std;
+
+/** @defgroup Utils General purpose utilitary functions
+ *  General purpose utilitary functions
+ *  @{
+ */
+
+/** @defgroup FileNameFunctions Functions to manipulate file names 
+	@ingroup  Utils
+ *  @{
+ */
+	//! Get the extension part (right to the dot) of a string
+	TL_DLL string TeGetExtension ( const char* value );
+
+	//! Get the name part (left to the dot) of a string, path included
+	TL_DLL string TeGetName ( const char* value );
+
+	//! Get the base name part of a string, strip path information
+	TL_DLL string TeGetBaseName ( const char* value );
+
+	//! Get the path part of a file name
+	TL_DLL string TeGetPath(const char* value);
+
+	//! Writes a string to a file.
+	/*!
+		\param fileName the file name to write to, including the directory.
+		\param text     the string with the text to write to.
+		\param mode     the mode used to write to the file (a | w | r).
+	*/
+	TL_DLL void TeWriteToFile(const string& fileName, const string& text, const string& mode);
+/** @} */ 
+
+/** @defgroup C2StringFunctions Functions convert numbers to strings
+	@ingroup  Utils
+ *  @{
+ */
+	//! Transforms an integer to string
+	TL_DLL string Te2String ( const int value );
+
+	//! Transforms an unsigned integer to string
+	TL_DLL string Te2String ( const unsigned int value );
+
+	//! Transforms a long to string
+	TL_DLL string Te2String ( const long value );
+
+	//! Transforms an unsigned long to string
+	TL_DLL string Te2String ( const unsigned long value );
+
+	//! Transforms a double to string floating point notation with precision decimal places
+	TL_DLL string Te2String ( const double value, int precision );
+
+	//! Transforms a double to string in exponential notation
+	TL_DLL string Te2String ( const double value );
+
+/** @} */ 
+
+/** @defgroup StringFunctions Functions to manipulate strings
+ 	@ingroup  Utils
+*  @{
+ */
+	//! Converts a string to upper case
+	TL_DLL void TeConvertToUpperCase ( const string& , char* );
+
+	//! Converts a string to upper case
+	TL_DLL string TeConvertToUpperCase (const string &name);
+
+	//! Converts a string to lower case
+	TL_DLL string TeConvertToLowerCase (const string &name);
+
+	//! Removes special characteres from a string
+	TL_DLL string TeRemoveSpecialChars ( string& str);
+
+	//! Removes left and right blank, tab and carriage return characters of a string
+	TL_DLL void TeTrim(string &str);
+
+	//! Splits a string, given a separator, in a vector of parts
+	TL_DLL int TeSplitString(const string& input, const string& delimiter, vector<string>& results);
+
+	//! Compares two strings
+	/*
+		\params caseS flag indicating if it is a case sensitive comparation
+	*/
+	TL_DLL bool TeStringCompare(const string& str1, const string& str2, bool caseS=false);
+
+
+	//! Validate a string to check if it can be used as a column name
+	/*
+		\param name			string to be checked
+		\param changed		output flag to identify that string has changed
+		\param invalidChar	output or sequence of chars that are invalid in the name
+		\return the modified valid name
+	*/
+	TL_DLL string TeCheckName(const string& name, bool& changed, string& invalidChar);
+/** @} */ 
+
+/** @defgroup MathFunctions Mathematical functions
+ 	@ingroup  Utils
+*  @{
+ */
+	//! Rounds a double to int
+	TL_DLL inline int TeRound(double val)
+	{	
+		if (val>=0)
+			return (int)(val+.5);
+		else
+			return (int)(val-.5);
+	}
+
+	//! Rounds a double value to a given number of decimal digits
+	TL_DLL double TeRoundD(double val, int precision=8);
+
+	//! Compares two doubles
+	TL_DLL bool TeCompareDouble(double a, double b, int precision);
+
+	//! Adjust a number to a given precision 
+	/*
+		\param val the number to be adjusted
+		\param precision the number of decimals places to be used
+		\param reduce flag to indicate that the number should be reduced instead to increased
+		\return the adjusted number
+	*/
+	TL_DLL double TeAdjustToPrecision(double val, int precision, bool reduce=false);
+
+	//! Rounds a double raster element index to an integer
+	/*
+		Raster elements have area, so raster element in upper-left position has
+		index from [-0.5,+0.5) in i and j dimension.
+	*/
+	TL_DLL inline int TeRoundRasterIndex(double val)
+	{	
+		int ind = (int) val;
+		if (val < (ind-0.5))
+			ind -= 1;
+		else if (val >= (ind+0.5))
+			ind += 1;
+		return ind;
+	}
+	/**
+	* Cubic root from x.
+	*
+	* @param x X.
+	* @return The cubic root from x.
+	*/         
+	TL_DLL inline double TeCubicRoot( double x )
+	{
+		if( x < 0 ) {
+		return ( -1. ) * pow(  ( -1. ) * x, ( 1. / 3. ) );
+		} else {
+			return pow(  x, ( 1. / 3. ) );
+		}
+	};
+	
+	/*! Comparassion of two floating points, considering a given precision */
+	TL_DLL inline bool TeFPEquals(double d1, double d2, double precision)
+	{
+		double eps1 = fabs(d1), 
+			eps2 = fabs(d2), 
+			eps;
+		eps = (eps1 > eps2) ? eps1 : eps2;
+		if (eps == 0.0)
+			return true; //both numbers are 0.0
+		eps *= precision;
+		return (fabs(d1 - d2) < eps);
+	}
+
+	//! Swap the bytes of a short value
+	static inline short swaps(short value)
+	{
+		short svalue = ((value & 0x00ff) << 8) | ((value >> 8) & 0x00ff);
+		return svalue;
+	}
+  
+  /**
+   * Returns the amount of free physical memory (bytes).
+   *
+   * @return The amount of free physical memory (bytes).
+   */
+  TL_DLL unsigned long int TeGetFreePhysicalMemory();
+
+  /**
+   * Returns the amount of total physical memory (bytes).
+   *
+   * @return The amount of total physical memory (bytes).
+   */
+  TL_DLL unsigned long int TeGetTotalPhysicalMemory();
+  
+  /**
+   * Returns the number of physical processors.
+   *
+   * @return The number of physical processors.
+   */
+  TL_DLL unsigned int TeGetPhysProcNumber();  
+    
+  /**
+   * Generates a temporary unique file name.
+   *
+   * @param filename The generated file name.
+   * @return true if ok, false errors.
+   */
+  TL_DLL bool TeGetTempFileName( std::string& filename );    
+  
+  /**
+   * @brief The file size (bytes).
+   *
+   * @note Throws an exception if file not found. 
+   * @param filename The file name.
+   * @return The file size (bytes).
+   */
+  TL_DLL unsigned long int TeGetFileSize( const std::string& filename );  
+  
+  /**
+   * @brief Check the file existence.
+   *
+   * @param filename The file name.
+   * @return true if the file exists, false if not.
+   */
+  TL_DLL bool TeCheckFileExistence( const std::string& filename );   
+
+
+/** @} */ 
+/** @} */ 
+
+#endif
+
+
diff --git a/src/terralib/kernel/TeVectorRemap.cpp b/src/terralib/kernel/TeVectorRemap.cpp
new file mode 100644
index 0000000..e567321
--- /dev/null
+++ b/src/terralib/kernel/TeVectorRemap.cpp
@@ -0,0 +1,160 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32 
+#pragma warning ( disable: 4786 ) 
+#endif
+
+#include "TeVectorRemap.h"
+
+TeBox TeRemapBox ( TeBox& box, TeProjection* projFrom, TeProjection* projTo)
+{
+	if (projFrom == 0 || projTo == 0)
+		return box;
+
+	if (*projFrom == *projTo)
+		return box;
+
+	if(projFrom->name() == "NoProjection" || projTo->name() == "NoProjection")
+		return box;
+
+	if (projFrom->datum().name() != projTo->datum().name())
+	{
+		projFrom->setDestinationProjection(projTo);
+		projTo->setDestinationProjection(projFrom);
+	}
+
+	TeCoord2D	pll = box.lowerLeft (),
+				pur = box.upperRight (),
+				pul (pll.x(),pur.y()),
+				plr (pur.x(),pll.y());
+
+// Evaluate coordinates of box corners in Lat/Long
+
+	pll = projFrom->PC2LL (pll);
+	pur = projFrom->PC2LL (pur);
+	pul = projFrom->PC2LL (pul);
+	plr = projFrom->PC2LL (plr);
+
+// Evaluate the minimum box that includes all four corners
+
+	pll.x(std::min(pll.x(),pul.x()));
+	pll.y(std::min(pll.y(),plr.y()));
+	plr.x(std::max(plr.x(),pur.x()));
+	plr.y(std::min(pll.y(),plr.y()));
+	pur.x(std::max(pur.x(),plr.x()));
+	pur.y(std::max(pul.y(),pur.y()));
+	pul.x(std::min(pll.x(),pul.x()));
+	pul.y(std::max(pul.y(),pur.y()));
+
+
+// Bring coordinates of box corners to target projection
+
+	pll = projTo->LL2PC (pll);
+	pur = projTo->LL2PC (pur);
+	pul = projTo->LL2PC (pul);
+	plr = projTo->LL2PC (plr);
+
+// Evaluate the minimum box that includes all four corners
+
+	return TeBox (	std::min(pll.x(),pul.x()),
+					std::min(pll.y(),plr.y()),
+					std::max(pur.x(),plr.x()),
+					std::max(pul.y(),pur.y()));
+}
+
+void
+TeVectorRemap(TeCoord2D& c1, TeProjection* p1, TeCoord2D& c2, TeProjection* p2)
+{
+	p1->setDestinationProjection(p2);
+	TeCoord2D ll = p1->PC2LL(c1);
+	c2 = p2->LL2PC(ll);
+}
+
+void 
+TeVectorRemap(TeText& t1, TeProjection* p1, TeText& t2, TeProjection* p2)
+{
+	p1->setDestinationProjection(p2);
+	t2 = t1;
+	TeCoord2D nl = p1->PC2LL(t1.location());
+	TeCoord2D p =  p2->LL2PC(nl);
+	t2.setLocation(p);
+}
+
+void TeVectorRemap(TeCell& c1, TeProjection* p1, TeCell& c2, TeProjection* p2)
+{	
+	c2 = c1;
+	TeBox nb = TeRemapBox(c1.box(),p1,p2);
+	c2.setBox(nb);
+}
+
+TeBox TeRemapBoxPC2Geodetic (const TeBox& box, TeProjection* proj)
+{
+	if (proj == 0)
+		return box;
+
+	proj->setDestinationProjection(0);
+
+	TeCoord2D	pll = box.lowerLeft (),
+				pur = box.upperRight (),
+				pul (pll.x(),pur.y()),
+				plr (pur.x(),pll.y());
+
+	pll = proj->PC2LL (pll);
+	pur = proj->PC2LL (pur);
+	pul = proj->PC2LL (pul);
+	plr = proj->PC2LL (plr);
+
+// Evaluate the minimum box that includes all four corners
+
+	return TeBox (	std::min(pll.x(),pul.x()),
+					std::min(pll.y(),plr.y()),
+					std::max(pur.x(),plr.x()),
+					std::max(pul.y(),pur.y()));
+}
+
+TeBox TeRemapBoxGeodetic2PC (const TeBox& box, TeProjection* proj)
+{
+	if (proj == 0)
+		return box;
+
+	proj->setDestinationProjection(0);
+
+	TeCoord2D	pll = box.lowerLeft (),
+				pur = box.upperRight (),
+				pul (pll.x(),pur.y()),
+				plr (pur.x(),pll.y());
+
+	pll = proj->LL2PC (pll);
+	pur = proj->LL2PC (pur);
+	pul = proj->LL2PC (pul);
+	plr = proj->LL2PC (plr);
+
+// Evaluate the minimum box that includes all four corners
+
+	return TeBox (	std::min(pll.x(),pul.x()),
+					std::min(pll.y(),plr.y()),
+					std::max(pur.x(),plr.x()),
+					std::max(pul.y(),pur.y()));
+}
+
diff --git a/src/terralib/kernel/TeVectorRemap.h b/src/terralib/kernel/TeVectorRemap.h
new file mode 100644
index 0000000..6f79cc6
--- /dev/null
+++ b/src/terralib/kernel/TeVectorRemap.h
@@ -0,0 +1,86 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeVectorRemap.h
+    \brief This file contains functions to remap vector structures
+*/
+#ifndef  __TERRALIB_INTERNAL_VECTORREMAP_H
+#define  __TERRALIB_INTERNAL_VECTORREMAP_H
+
+#include "TeProjection.h"
+#include "TeGeometry.h"
+
+//! Remaps a geometry. Templated by the type of geometry.
+/*
+	\param g1 the input geometry
+	\param p1 the initial projection
+	\param g2 to receive the remapped geometry
+	\param p1 the destination projection
+*/
+template<typename G>
+void TeVectorRemap (G& g1, TeProjection* p1, G& g2, TeProjection* p2)
+{
+	int nItens = g1.size();
+	for (int i=0; i<nItens; i++)
+	{
+		typename G::value_type e1 = g1[i];
+		typename G::value_type e2;
+		TeVectorRemap(e1,p1,e2,p2);
+		g2.add(e2);
+	}
+}
+
+//! Especialized version to remap coordinates
+TL_DLL void TeVectorRemap(TeCoord2D& pt1, TeProjection* p1, TeCoord2D& pt2, TeProjection* p2);
+
+//! Especialized version to remap cells
+TL_DLL void TeVectorRemap(TeCell& c1, TeProjection* p1, TeCell& c2, TeProjection* p2);
+
+//! Especialized version to remap texts
+TL_DLL void TeVectorRemap(TeText& t1, TeProjection* p1, TeText& t2, TeProjection* p2);
+
+//! Remaps a box from one projection to another
+/*
+	\param box the input box
+	\param projFrom the initial projection
+	\param projTo the destination projection
+	\returns the remmaped box
+*/
+TL_DLL TeBox TeRemapBox (TeBox& box, TeProjection* projFrom, TeProjection* projTo);
+
+//! Remaps a box from plane coordinate to geodetic coordinate
+/*
+	\param box the input box
+	\param proj the data projection
+	\returns the remmaped box
+*/
+TL_DLL TeBox TeRemapBoxPC2Geodetic (const TeBox& box, TeProjection* proj);
+
+//! Remaps a box from geodetic coordinate to plane coordinate
+/*
+	\param box the input box
+	\param proj the data projection
+	\returns the remmaped box
+*/
+TL_DLL TeBox TeRemapBoxGeodetic2PC (const TeBox& box, TeProjection* proj);
+
+#endif
diff --git a/src/terralib/kernel/TeView.h b/src/terralib/kernel/TeView.h
new file mode 100644
index 0000000..352217c
--- /dev/null
+++ b/src/terralib/kernel/TeView.h
@@ -0,0 +1,233 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeView.h
+    \brief This file provides TerraLib's definition of a View
+*/
+#ifndef  __TERRALIB_INTERNAL_VIEW_H
+#define  __TERRALIB_INTERNAL_VIEW_H
+
+#include "TeLayer.h"
+#include "TeTheme.h"
+#include "TeProjection.h"
+#include "TeViewNode.h"
+#include <algorithm>
+
+using namespace std;
+
+//! A class to deal with views in TerraLib
+/*!
+	A View is a structure that aggregated themes to be visualized or
+	processed in its own projection. Views may belong to a particular user.
+	\sa TeTheme TeViewNode
+*/
+class TL_DLL TeView
+{
+public:
+	//! Constructor
+    TeView( const string& name="", const string& user="", int id=0)
+		: id_(id), name_(name), user_(user), proj_(0), is_visible_(true), connectedId_(0), currentTheme_(-1)
+	{}
+
+	//! Destructor
+	virtual ~TeView () 
+	{
+		if(proj_)
+			delete proj_;
+	}
+
+	//! Returns view unique id
+	virtual int	id () { return id_; }
+
+	//! Sets view unique id
+	virtual void id (int id)
+	{
+		id_ = id;	// update view id
+		for (unsigned int th=0;th<viewTree_.size();th++)	//update its themes
+			viewTree_.retrieve(th)->view (id_);
+		viewTree_.view(id); 
+	}
+
+	//! Returns the view name
+	virtual string	name () { return name_; }
+
+	//! Sets the view name
+	virtual void name (const string& s) { name_ = s; }
+
+	//! Returns the view user name
+	virtual string	user () { return user_; }
+
+	//! Sets the view user name
+	virtual void user (const string& i) { user_ = i; }
+
+	//! Returns the view projection
+	virtual TeProjection* projection () { return proj_; }
+
+	//! Sets the view projection
+	virtual void projection (TeProjection* p) { proj_ = p; }
+
+	//! Returns TRUE if view is visible
+	virtual bool isVisible () { return is_visible_; }
+
+	//! Sets whether view is visible
+	virtual void isVisible (bool v) { is_visible_ = v; }
+
+	//! Returns the current box
+	virtual TeBox& getCurrentBox () { return currentBox_; }
+
+	//! Sets the current box
+	virtual void setCurrentBox (const TeBox& b) { currentBox_ = b; }
+
+	//! Returns the current theme id
+	virtual int getCurrentTheme () { return currentTheme_; }
+
+	//! Sets the current theme id
+	virtual void setCurrentTheme (const int& id) { currentTheme_ = id; }
+	
+	//! Returns the view tree where view belongs
+	virtual TeViewTree* root () { return &viewTree_; }
+
+	//! Adds a view node to the view tree
+	virtual void add( TeViewNode* node )
+	{
+		node->view (id_);
+		viewTree_.add ( node );
+	}
+
+	//! Removes a view node through its name from the view tree
+	virtual TeViewNode* remove(string name)
+	{
+		return viewTree_.remove(name);
+	}
+
+	//! Removes a view node through its identifier from the view tree
+	virtual TeViewNode* remove (int id)
+	{
+		return viewTree_.removeID(id);
+	}
+
+	//! Moves a node up
+	virtual void moveUp (TeViewNode* node)
+	{
+		viewTree_.moveUp(node);
+	}
+
+	//! Moves a node down
+	virtual void moveDown(TeViewNode* node)
+	{
+		viewTree_.moveDown(node);
+	}
+
+	//! Returns a node identified by its position
+	virtual TeViewNode* get(int i)
+	{
+		return viewTree_.retrieve(i);
+	}
+
+	//! Returns a node identified by its name and version
+	virtual TeTheme* get(string themeName)
+	{
+		TeTheme *ret = 0;
+		for (unsigned int th = 0;th < viewTree_.size();th++)
+		{
+			TeViewNode *node = viewTree_.retrieve(th);
+			if (node->type() == TeTHEME)
+			{
+				TeTheme *tmp = (TeTheme*)node;
+				if (tmp->name() == themeName)
+				{
+					ret = tmp;
+					break;
+				}
+			}
+		}
+		return ret;
+	}
+	
+	//! Sort the themes in the view
+	virtual void sort() 
+	{ viewTree_.sort(); }
+
+	//! Swap the order of two themes
+	virtual void swap( unsigned int i, unsigned int j)
+	{
+		viewTree_.swap(i,j);
+	}
+
+	//! Sets the themes visibility 
+	virtual void visibility( int vis )
+	{
+		viewTree_.visibility( vis );
+	}
+
+	//! Returns the themes visibility 
+	virtual int visibility()
+	{
+		return viewTree_.visibility();
+	}
+
+	//! Returns the number of themes in the view
+	virtual unsigned int size()
+		{ return viewTree_.size() ; }
+
+	//! Returns the vector of themes of the view sorted according to their priorities
+	virtual vector<TeViewNode*>& themes()
+	{ return viewTree_.nodes();}
+
+	//! Sets the id of the connected view
+	virtual void connectedId(int id) {connectedId_ = id;}
+
+	//! Returns the id of the connected view
+	virtual int connectedId() {return connectedId_;}
+
+	/*! Returns the boundary box of the view themes
+		\param onlyVisible If is true, returns the boundary box of visible themes, otherwise returns the boundary box of all themes
+	*/
+	virtual TeBox box( bool onlyVisible )
+	{ 
+		TeBox retval;
+		if ( root() ) 
+			retval = root()->box(onlyVisible,proj_); 
+		return retval;		
+	}; 
+
+private:
+	int				id_;	// view id
+	string			name_;	// view name
+	string			user_;	// user id
+	TeProjection*   proj_;
+	bool			is_visible_;
+
+	TeViewTree		viewTree_;
+	int				connectedId_; // connected view
+
+	TeBox			currentBox_; // current box
+	int				currentTheme_; // current theme id
+};
+
+//! A map from identifiers to pointers to views
+typedef map<int,TeView*> TeViewMap;
+
+#endif
+
+
+
diff --git a/src/terralib/kernel/TeViewNode.cpp b/src/terralib/kernel/TeViewNode.cpp
new file mode 100644
index 0000000..aa28c7b
--- /dev/null
+++ b/src/terralib/kernel/TeViewNode.cpp
@@ -0,0 +1,362 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+#include "TeViewNode.h"
+#include "TeTheme.h"
+#include "TeLayer.h"
+#include "TeProjection.h"
+
+TeBox 
+TeViewTree::box(bool onlyVisible, TeProjection* destProjection)
+{
+	TeBox retval;
+	if ( destProjection  == 0 )
+		return retval;
+
+	for (vector<TeViewNode*>::iterator child = nodes_.begin(); child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		if( pt->type() == TeTREE )
+			updateBox( retval, ( (TeViewTree*)pt)->box( onlyVisible, destProjection ) );
+		else
+		{
+			
+			TeAbstractTheme* theme = (TeAbstractTheme*)(pt);
+
+			if( onlyVisible && !( theme->visibility() & 0x00000001 ) )
+				continue;
+
+			TeBox themeBox = theme->getThemeBox(); 
+			if(!themeBox.isValid()) 
+				continue;			
+			theme->getThemeProjection()->setDestinationProjection(destProjection);
+			TeCoord2D ll = themeBox.lowerLeft();
+			TeCoord2D ur = themeBox.upperRight();
+			TeBox convertedBox(theme->getThemeProjection()->PC2LL(ll),
+							theme->getThemeProjection()->PC2LL(ur));
+			ll = convertedBox.lowerLeft();
+			ur = convertedBox.upperRight();
+			convertedBox = TeBox(destProjection->LL2PC(ll),destProjection->LL2PC(ur));
+			updateBox(retval, convertedBox);
+		}
+	}
+	return retval;
+}
+
+bool 
+TeViewTree::assertsPriorities()
+{
+	bool updated = false;
+	for ( unsigned int i=0; i<nodes_.size(); ++i)
+	{
+		TeViewNode* node = nodes_[i];
+		if ( (node != NULL) && ( node->priority() != (int)i ) )
+		{
+			node->priority(i);
+			updated = true;
+		}
+		if ( node->type() == TeTREE )
+		{
+			TeViewTree* tree = (TeViewTree*)node;
+			if ( ( tree != NULL ) 
+				&& ( tree->assertsPriorities()== true) 
+				&& ( updated == false ) )
+				updated = true;
+		}	
+	}
+	return updated;
+}
+
+TeViewTree::~TeViewTree ()
+{
+	// For all my children, delete them
+    vector<TeViewNode*>::iterator child = nodes_.begin();
+    while( child != nodes_.end() ) 
+	{
+		// Create a temporary pointer to store the child's
+		// address
+		TeViewNode* pt = (*child);
+
+        // Remove the child from the list
+		nodes_.erase(child);
+		child = nodes_.begin();
+
+		// Ok, now the child's parent points to NULL and we can
+		// safely call the child's destructor
+		delete pt;
+		pt = 0;
+	}
+}
+
+void 
+TeViewTree::visibility(int vis)
+{
+	for (vector<TeViewNode*>::iterator child = nodes_.begin();
+			child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		pt->visibility( vis );
+	}
+}
+
+int TeViewTree::visibility()
+{
+	for (vector<TeViewNode*>::iterator child = nodes_.begin();
+			child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		if ( pt->visibility() == 1 )
+			return 1;
+	}
+	return 0;
+}
+
+void 
+TeViewTree::swap(unsigned int i, unsigned int j)
+{
+	if (i==j || i>=nodes_.size() || j>=nodes_.size())
+		return;
+	TeViewNode* temp = nodes_[i];
+	nodes_[i] = nodes_[j];
+	nodes_[j] = temp;
+	nodes_[i]->priority (i);
+	nodes_[j]->priority (j);
+}
+
+
+void
+TeViewTree::moveUp(TeViewNode* node)
+{
+	for (unsigned int i=0 ; i<nodes_.size() ; i++)
+	{
+		if (node == nodes_[i])
+		{
+			swap (i, i-1);
+			return;
+		}
+	}
+}
+
+void 
+TeViewTree::moveDown(TeViewNode* node)
+{
+	if (!node)
+		return;
+
+	for (unsigned int i=0 ; i<nodes_.size() ; ++i)
+	{
+		if (node == nodes_[i])
+		{
+			swap (i, i+1);
+			return;
+		}
+	}
+}
+
+void TeViewTree::add(TeViewNode* node)
+{
+	node->setParent ( this ); // I am the father
+	node->priority(static_cast<int>(nodes_.size()));
+	nodes_.push_back (node);
+}
+
+//!	Removes a node identified by its name
+TeViewNode* 
+TeViewTree::remove (const string& name)
+{
+	vector<TeViewNode*>::iterator child = nodes_.begin();
+	while ( child != nodes_.end() )
+	{
+		TeViewNode* pt = (*child);
+		if (pt->name() == name)
+		{
+			nodes_.erase(child);
+			return pt;
+		}
+		if(pt->type() == TeTREE)
+		{
+			TeViewNode* result = pt->remove(name);
+			if(result) return result;
+		}
+		++child;
+	}
+	return 0;
+}
+
+//!	Removes a node through its identifier
+TeViewNode* 
+TeViewTree::removeID (int id) 
+{ 
+	for (vector<TeViewNode*>::iterator child = nodes_.begin();
+			child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		if(pt->id() == id)
+		{
+			nodes_.erase(child);
+			return pt;
+		}
+		if(pt->type() == TeTREE)
+		{
+			TeViewNode* result = pt->removeID(id);
+			if(result) return result;
+		}
+	}
+	return 0;
+}
+
+void 
+TeViewTree::draw ()
+{				  
+	vector<TeViewNode*>::iterator child = nodes_.begin();
+	while ( child != nodes_.end() )
+	{
+		TeViewNode* pt = (*child);
+		pt->draw();
+		++child;
+	}
+}
+
+void 
+TeViewTree::sort()
+{
+	int i, j;
+	for (i = 0; i < (int)size() - 1; ++i)
+	{
+		for (j = i+1; j < (int)size(); ++j)
+		{
+			if (nodes_[i]->priority() > nodes_[j]->priority())
+			{
+				TeViewNode* temp = nodes_[i];
+				nodes_[i] = nodes_[j];
+				nodes_[j] = temp;
+			}
+		}
+	}
+}
+
+void 
+TeViewTree::clear()
+{
+	// For all my children, delete them
+    vector<TeViewNode*>::iterator child = nodes_.begin();
+    while( child != nodes_.end() ) 
+	{
+		// Create a temporary pointer to store the child's
+		// address
+		TeViewNode* pt = (*child);
+
+        // Remove the child from the list
+		nodes_.erase(child);
+
+		if( pt->type() == TeTREE )
+			((TeViewTree*)pt)->clear();
+		
+		child = nodes_.begin();
+	}
+}
+
+int 
+TeViewTree::moveTop (TeViewNode* node)
+{
+	TeViewNode* parent = node->parent();
+	if(parent == NULL) 
+		return -1;
+	if(parent->type() != TeTREE) 
+		return -1;
+	TeViewTree* tree = (TeViewTree*)parent;
+	int i = 0;
+	while(tree->retrieve(0) != node && tree->retrieve(0) != NULL)
+	{
+		tree->moveUp(node);
+		++i;
+	}
+	return i;
+}
+
+int 
+TeViewTree::moveBottom(TeViewNode* node)
+{
+	TeViewNode* parent = node->parent();
+	if (parent == 0 || parent->type() != TeTREE)
+		return -1;
+	TeViewTree* tree = (TeViewTree*)parent;
+	int i = 0;
+	while(tree->nodes().back() != node && tree->nodes().back() != 0)
+	{
+		tree->moveDown(node);
+		++i;
+	}
+	return i;
+}
+
+
+void 
+TeViewTree::insertFront(TeViewNode* node)
+{
+	node->setParent( this ); // I am the father
+	nodes_.insert(nodes_.begin(), node);
+	int ind = 0;
+	for (vector<TeViewNode*>::iterator child = nodes_.begin();
+			child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		if ( pt )
+			pt->priority( ind++ ); 
+	}
+}
+
+TeViewNode* 
+TeViewTree::find (int id) 
+{ 
+	for (vector<TeViewNode*>::iterator child = nodes_.begin();
+			child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		if(pt->id() == id)
+			return pt;
+		if(pt->type() == TeTREE)
+		{
+			TeViewNode* result = ((TeViewTree*)(pt))->find(id);
+			if(result) 
+				return result;
+		}
+	}
+	return 0;
+}
+TeViewNode* 
+TeViewTree::find( std::string name, bool caseS) 
+{ 
+	for (vector<TeViewNode*>::iterator child = nodes_.begin();
+			child != nodes_.end(); ++child)
+	{
+		TeViewNode* pt = (*child);
+		if( TeStringCompare( pt->name(), name, caseS ) )
+			return pt;
+		if( pt->type() == TeTREE )
+		{
+			TeViewNode* result = ((TeViewTree*)(pt))->find( name, caseS );
+			if (result) 
+				return result;
+		}
+	}
+	return 0;
+}
diff --git a/src/terralib/kernel/TeViewNode.h b/src/terralib/kernel/TeViewNode.h
new file mode 100644
index 0000000..efcc9bb
--- /dev/null
+++ b/src/terralib/kernel/TeViewNode.h
@@ -0,0 +1,404 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeViewNode.h
+    \brief This file provides TerraLib's tree structure of views
+*/
+#ifndef  __TERRALIB_INTERNAL_VIEWNODE_H
+#define  __TERRALIB_INTERNAL_VIEWNODE_H
+
+#define THEME_GROUP
+
+#include "TeDefines.h"
+#include "TeBox.h"
+#include "TeAbstractFactory.h"
+
+#include <iostream>
+#include <string>
+#include <vector>
+using namespace std;
+
+class TeProjection;
+class TeViewNode;
+
+//! Type of view node
+enum TeViewNodeType
+{ TeTHEME=0, TeTREE=1, TeEXTERNALTHEME=2, TeFILETHEME=3 }; 
+
+
+//!  A class to represent the view node parameters 
+/*!  
+	 This class contains the main view node parameters and it is used 
+	 by the factory responsible for creating view node objects. 
+	 
+	\sa
+     TeViewNode
+*/
+class TL_DLL TeViewNodeParams
+{
+public:
+	//! Constructor
+	TeViewNodeParams(const string& name="", const int& id=0, const int& viewId=0, 
+		const int nodeType=0, const int& priority=0, TeViewNode* parentNode=0,
+		const int parentId=0):
+		name_(name),
+		id_(id),
+		viewId_(viewId),
+		nodeType_(nodeType),
+		priority_(priority),
+		myParent_(parentNode),
+		myParentId_(parentId)
+	{ }
+
+	//! Copy constructor
+	TeViewNodeParams(const TeViewNodeParams& params)
+	{
+		name_ = params.name_;
+        id_ = params.id_;
+		viewId_ = params.viewId_; 
+        nodeType_ = params.nodeType_; 
+		priority_ = params.priority_;
+		myParent_ = params.myParent_;
+		myParentId_ = params.myParentId_; 
+	}
+
+	//! Returns the view node type 
+	int getProductId() { return nodeType_; }
+
+    //! Node name
+	string			name_;		
+	//! Node identity
+	int				id_;
+	//! View identity that contains this node 
+	int				viewId_;	
+	//! Node type
+	int				nodeType_;
+	//! Precedence when stored in a view
+	int				priority_;
+	//! Pointer to its parent 
+	TeViewNode* 	myParent_;  
+	//! Node parent id
+	int 			myParentId_;
+};
+
+
+//!  A class to deal with nodes of a view 
+/*!  
+	 In Terralib, a view is composed of nodes. This is a base class 
+	 used to specialize view node types. 
+
+	\sa
+     TeView TeViewNodeParams
+*/
+class TL_DLL TeViewNode
+{
+public:
+	//! Empty constructor
+    TeViewNode(const string& name="", TeViewNode* parent=0, const int& view=0, const int& id=0, const int& nodeType=0): 
+	  viewNodeParams_(name, id, view, nodeType, 0, parent)
+	{ }
+	
+	//! Constructor
+    TeViewNode(const TeViewNodeParams& viewNodeParams): 
+	  viewNodeParams_(viewNodeParams)
+	{ }
+
+	//! Destructor
+	virtual ~TeViewNode()
+	{}
+
+	//! Inserts a new child in the tree hierachy. Fails if the object is a leaf
+	virtual void add (TeViewNode*) {}
+
+    //!	Remove an existing child identified by its id from the tree hierarchy
+    /*!	
+		Fails if the object is a leaf
+	    Should be used in conjunction with a delete 
+	*/	
+	virtual TeViewNode* removeID (int /* id */) { return 0; }
+ 
+   //!	Remove an existing child identified by its name from the tree hierarchy
+    /*!	
+		Fails if the object is a leaf
+	    Should be used in conjunction with a delete 
+	*/	
+	virtual TeViewNode* remove (const string& /*name*/) { return 0; }
+
+	//! Retrieve a node identified by its identifier from the tree structure
+	virtual TeViewNode* retrieve (int)  { return 0; }
+
+	//! Returns a pointer to a parent node
+	virtual TeViewNode* parent()
+	{ return viewNodeParams_.myParent_; }
+
+	//! Returns the identifier of a node parent
+	virtual int parentId()
+	{
+		if (viewNodeParams_.myParent_)
+			return viewNodeParams_.myParent_->id(); 
+		else
+			return viewNodeParams_.myParentId_;
+	}
+
+	//! Sets the identification of the parent node
+	virtual void parentId(int i) 
+	{
+		if (viewNodeParams_.myParent_)
+			viewNodeParams_.myParent_->id(i);
+		viewNodeParams_.myParentId_ = i;
+	}
+
+	//! Sets the parent of node
+	virtual void setParent ( TeViewNode* node )
+	{ 
+		viewNodeParams_.myParent_ = node; 
+		viewNodeParams_.myParentId_ = (viewNodeParams_.myParent_)? viewNodeParams_.myParent_->id():0;
+	}
+
+	//! Returns the identification of a node
+	virtual int		id () { return viewNodeParams_.id_; }
+
+	//! Sets the identification of a node
+	virtual void	id (int i){ viewNodeParams_.id_ = i; }
+
+	//! Returns the name of a node
+	virtual string	name () { return viewNodeParams_.name_; }
+	//! Sets the name of a node
+	virtual void	name (const string& s) { viewNodeParams_.name_ = s; }
+
+	//! Returns the priority of a node
+	virtual int		priority() { return viewNodeParams_.priority_; }
+	//! Sets the priority of a node
+	virtual void	priority(int i) { viewNodeParams_.priority_ = i; }
+
+	//! Sets the view identification of a node
+	virtual void	view (int viewId) { viewNodeParams_.viewId_ = viewId; }
+	//! Returns the view identification of a node
+	virtual int		view () { return viewNodeParams_.viewId_ ; }
+
+	//! Returns the node type
+	virtual int type() { return viewNodeParams_.nodeType_; };
+	//! Sets the node type
+	virtual void type(const int& t) { viewNodeParams_.nodeType_ = t; }
+
+	//! Moves a node up in the tree structure
+	virtual void moveUp ()
+	{
+		if (viewNodeParams_.myParent_)
+			viewNodeParams_.myParent_->moveUp (this);
+	}
+	
+	//! Moves a node down in the tree structure
+	virtual void moveDown ()
+	{
+		if (viewNodeParams_.myParent_)
+			viewNodeParams_.myParent_->moveDown (this);
+	}
+
+	//! Swaps nodes 
+	virtual void swap ( unsigned int, unsigned int ) {}
+
+	//! Sets the nodes visibility 
+	virtual void visibility ( int ){}; 
+
+	//! Returns the nodes visibility 
+	virtual int visibility(){ return 1; };
+
+	//! Draws a node
+	virtual void draw() {}
+
+	//! Sorts the node
+	virtual void sort() {}
+	
+	static TeViewNode*	DefaultObject()
+	{	return 0; }
+
+	virtual int getProductId() const
+	{	return viewNodeParams_.nodeType_; }
+
+	virtual TeViewNodeParams& viewNodeParams()
+	{	return viewNodeParams_; }
+
+	virtual void viewNodeParams(TeViewNodeParams& p)
+	{	viewNodeParams_ = p; }
+
+
+protected:
+
+	virtual void	moveUp (TeViewNode*) {}
+	virtual void	moveDown (TeViewNode*) {}
+
+	//! Node parameters
+	TeViewNodeParams	viewNodeParams_;
+};
+
+
+//!  This class implements a virtual factory to create view node types. 
+/*!  
+	 This class is a base virtual factory used to specialize 
+	 other factories that create particular node view types. 
+
+	\sa
+     TeAbstractFactory TeViewNode TeViewNodeParams
+*/
+class TL_DLL TeViewNodeFactory : public TeAbstractFactory<TeViewNode,TeViewNodeParams, int>
+{
+public:
+	//! Constructor based on the view node type
+	TeViewNodeFactory(const int& nodeType) : 
+	  TeAbstractFactory<TeViewNode,TeViewNodeParams, int>(nodeType)
+	{ }
+};
+
+
+//! A class to deal with branchs in a view tree structure  
+class TL_DLL TeViewTree: public TeViewNode
+{
+public:
+
+	//! Constructor
+	TeViewTree(const string& name=""): TeViewNode(name, 0, 0, 0, (int)TeTREE)
+	{ }
+
+	//! Constructor
+    TeViewTree(const TeViewNodeParams& params): 
+	  TeViewNode(params)
+	{ }
+
+
+	//! Destructor
+	virtual ~TeViewTree ();
+
+	//! Sets the nodes visibility 
+	virtual void visibility (int vis);
+
+	//! Returns the nodes visibility 
+	virtual int visibility ();
+
+	//! Swap nodes
+	virtual void swap (unsigned int i, unsigned int j);
+
+	//! Moves a node up in the tree structure
+	virtual void moveUp (TeViewNode* node);
+
+	//! Moves a node down in the tree structure
+	virtual void moveDown (TeViewNode* node);
+
+	//! Adds a node to the structure
+	virtual void add (TeViewNode* node);
+
+    //!	Removes a node identified by its name
+	virtual TeViewNode* remove (const string& name);
+
+    //!	Removes a node through its identifier
+	virtual TeViewNode* removeID (int id) ;
+
+    //!	Retrieves a node through its index
+	virtual TeViewNode* retrieve (unsigned int i) 
+	{ return nodes_[i]; }
+
+	//! Draw a node
+	virtual void draw ();
+
+	//! Returns the size of the structure
+	unsigned int size()
+    { return nodes_.size(); }
+
+	//! Returns the vector of View nodes
+	vector<TeViewNode*>& nodes()
+	{ return nodes_; }
+
+	//! Sort the vector of nodes according to their priorities
+	void sort();
+
+	//! Unlinks the nodes from the view tree
+	virtual void clear();
+	
+	/*! Move the given node to the top of it's tree.
+	  \param node to be moved
+	  \return the number of positions the node has been moved
+	*/
+	virtual int moveTop (TeViewNode* node);
+
+	/*!	Move the given node to the bottom of it's tree.
+	  \param node to be moved
+	  \return the number of positions the node has been moved
+	*/
+	int moveBottom(TeViewNode* node);
+
+	/*!
+	Inserts the given node to at the begin of the view tree.
+	\param node node to be added
+	*/
+	virtual void insertFront(TeViewNode* node);
+
+	/*! Look at a View Tree for a node with the given id.
+		\param id Id of the node to be found
+	*/
+	virtual TeViewNode* find (int id);
+
+	/*! Look at a View Tree for a node with the given name.
+		\param name name of the node to be found
+		\param caseS(optional) true if the given name is case sensitive
+	*/
+	virtual TeViewNode* find( std::string name, bool caseS = false );
+
+	/*! Returns the boundary box of the tree view themes
+	\param projection The returned box coordinates will be in the given projection 
+	*/
+	virtual TeBox box(bool onlyVisible, TeProjection* projection );
+
+	/*!	Asserts the nodes priorities by the positions.
+		Returns true if any priority was updated, otherwise returns false.
+	*/
+	virtual bool assertsPriorities();
+
+private:
+	vector<TeViewNode*> nodes_;
+};
+
+
+//!  This class implements a factory to create view tree objects. 
+/*!  
+	 This class is a factory that create view nodes 
+	 of the type TeTREE, that is, view tree objects.
+
+	\sa
+     TeViewNodeFactory TeViewNodeParams TeViewTree  
+*/
+class TL_DLL TeViewTreeFactory : public TeViewNodeFactory
+{
+public:
+	//! Constructor 
+	TeViewTreeFactory() : TeViewNodeFactory((int)TeTREE)
+	{}
+
+	//! Created view tree objects 
+	TeViewTree* build(TeViewNodeParams* params)
+	{	
+		TeViewNodeParams auxParams = *params;
+		return new TeViewTree(auxParams);	
+	}
+};
+
+#endif
+
diff --git a/src/terralib/kernel/TeVisual.cpp b/src/terralib/kernel/TeVisual.cpp
new file mode 100644
index 0000000..2ea09d0
--- /dev/null
+++ b/src/terralib/kernel/TeVisual.cpp
@@ -0,0 +1,258 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+#include <TeVisual.h>
+
+TeBaseVisualParams::TeBaseVisualParams(TeGeomRep rep, const string& visualType) :
+		symbId_ (TePolyTypeFill),
+		color_ (255,0,0),
+	    transparency_ (0),
+		width_ (0),
+	   	contourSymbId_ (TeLnTypeContinuous),
+		contourColor_(0,255,255),
+		contourTransparency_ (0),
+		contourWidth_ (1),
+		sizeValue_ (0),
+		ptAngle_ (0),
+		family_ ("Verdana"),
+		bold_ (false),
+		italic_(false),
+		alignmentVert_(0),
+		alignmentHoriz_(0),
+		tabSize_(6),
+		lineSpace_(1),
+		fixedSize_(false),
+		visualType_(visualType),
+		geomRep_(rep)
+{
+	switch (rep)
+	{
+		case TePOLYGONS:
+		case TeCELLS:
+			symbId_= TePolyTypeFill;
+			contourSymbId_= TeLnTypeContinuous;
+			break;
+		case TeLINES:
+			symbId_= TeLnTypeContinuous;
+			width_ = 1;
+			break;
+		case TePOINTS:
+		case TeNODES:
+			symbId_= TePtTypeBox;
+			sizeValue_ = 3;
+			break;
+		case TeTEXT:
+			sizeValue_= 12;
+			break;
+		default:
+			break;
+	}
+}
+
+// Copy constructor
+TeBaseVisualParams::TeBaseVisualParams(const TeBaseVisualParams& other)
+{	
+	symbId_ = other.symbId_;
+	color_ = other.color_;
+	transparency_ = other.transparency_;
+	width_ = other.width_;
+
+	contourSymbId_ = other.contourSymbId_;
+	contourColor_ = other.contourColor_;
+	contourTransparency_ = other.contourTransparency_;
+	contourWidth_ = other.contourWidth_;
+		
+	sizeValue_ = other.sizeValue_;
+	ptAngle_ = other.ptAngle_;
+	
+	family_ = other.family_;
+	bold_ = other.bold_;
+	italic_ = other.italic_;
+	fixedSize_ = other.fixedSize_;
+	alignmentVert_ = other.alignmentVert_;
+	alignmentHoriz_ = other.alignmentHoriz_;
+	tabSize_ = other.tabSize_;
+	lineSpace_ = other.lineSpace_;
+
+	visualType_ = other.visualType_;
+	geomRep_ = other.geomRep_; 
+}
+
+// Assignment operator
+TeBaseVisualParams& 
+TeBaseVisualParams::operator=(const TeBaseVisualParams& vis)
+{
+	if ( this != &vis )
+	{
+		symbId_ = vis.symbId_;
+		color_ = vis.color_;
+		transparency_ = vis.transparency_;
+		width_ = vis.width_;
+
+		contourSymbId_ = vis.contourSymbId_;
+		contourColor_ = vis.contourColor_;
+		contourTransparency_ = vis.contourTransparency_;
+		contourWidth_ = vis.contourWidth_;
+		
+		sizeValue_ = vis.sizeValue_;
+		ptAngle_ = vis.ptAngle_;
+		
+		family_ = vis.family_;
+		bold_ = vis.bold_;
+		italic_ = vis.italic_;
+		fixedSize_ = vis.fixedSize_;
+		alignmentVert_ = vis.alignmentVert_;
+		alignmentHoriz_ = vis.alignmentHoriz_;
+		tabSize_ = vis.tabSize_;
+		lineSpace_ = vis.lineSpace_;
+
+		visualType_ = vis.visualType_;
+		geomRep_ = vis.geomRep_;
+	}
+	return *this;
+}
+
+// Returns TRUE if param1 is equal to param2 or FALSE if they are different.
+bool 
+TeBaseVisualParams::operator== (const TeBaseVisualParams& vis)
+{
+	return ( symbId_ == vis.symbId_ &&
+		color_ == vis.color_ &&
+		transparency_ == vis.transparency_ &&
+		width_ == vis.width_ &&
+		contourSymbId_ == vis.contourSymbId_ &&
+		contourColor_ == vis.contourColor_ &&
+		contourTransparency_ == vis.contourTransparency_ &&
+		contourWidth_ == vis.contourWidth_ &&
+		sizeValue_ == vis.sizeValue_ &&
+		ptAngle_ == vis.ptAngle_ &&
+		family_ == vis.family_ &&
+		bold_ == vis.bold_ &&
+		italic_ == vis.italic_ &&
+		fixedSize_ == vis.fixedSize_ &&
+		alignmentVert_ == vis.alignmentVert_ &&
+		alignmentHoriz_ == vis.alignmentHoriz_ &&
+		tabSize_ == vis.tabSize_ && 
+		lineSpace_ == vis.lineSpace_  &&
+		visualType_ == vis.visualType_ &&
+		geomRep_ == vis.geomRep_);
+}
+
+// Returns visual to the default parameters 
+void 
+TeBaseVisualParams::clear()
+{
+	symbId_ = TePolyTypeFill;
+	color_ = TeColor(255,0,0);
+	transparency_=0;
+	width_ = 0; 
+	contourSymbId_ = TeLnTypeContinuous;
+	contourColor_ = TeColor (0,255,255);
+	contourTransparency_ = 0;
+	contourWidth_ = 1;
+	sizeValue_ = 0;
+	ptAngle_ = 0;
+	family_ = "Verdana";
+	bold_  = false;
+	italic_ = false;
+	alignmentVert_ = 0;
+	alignmentHoriz_ = 0;
+	tabSize_ = 6;
+	lineSpace_ = 1;
+	fixedSize_ = false;
+	geomRep_ = TePOLYGONS;
+	visualType_="tevisual";
+}
+
+// Copies only the basic visual parameters from another visual
+void 
+TeBaseVisualParams::setBasic (TeBaseVisualParams &vis)
+{
+	symbId_ = vis.symbId_;
+	color_ = vis.color_;
+	transparency_ = vis.transparency_;
+	width_ = vis.width_;
+
+	contourSymbId_ = vis.contourSymbId_;
+	contourColor_ = vis.contourColor_;
+	contourTransparency_ = vis.contourTransparency_;
+	contourWidth_ = vis.contourWidth_;
+	
+	sizeValue_ = vis.sizeValue_;
+	ptAngle_ = vis.ptAngle_;
+	
+	family_ = vis.family_;
+	bold_ = vis.bold_;
+	italic_ = vis.italic_;
+	fixedSize_ = vis.fixedSize_;
+	alignmentVert_ = vis.alignmentVert_;
+	alignmentHoriz_ = vis.alignmentHoriz_;
+	tabSize_ = vis.tabSize_;
+	lineSpace_ = vis.lineSpace_;
+	geomRep_ = vis.geomRep_;
+	visualType_="tevisual";
+}
+
+//--------------
+
+TeVisual::TeVisual(TeGeomRep rep) : 
+		params_ (TeBaseVisualParams(rep, "tevisual"))
+{
+}
+		
+// Copy constructor
+TeVisual::TeVisual(const TeVisual& other)
+{	
+	params_ = other.params_;
+}
+
+// Assignment operator
+TeVisual& 
+TeVisual::operator=(const TeVisual& vis)
+{
+	if ( this != &vis )
+		params_ = vis.params_;
+	return *this;
+}
+
+// Returns TRUE if param1 is equal to param2 or FALSE if they are different.
+bool 
+TeVisual::operator== (const TeVisual& vis)
+{
+	return ( params_ == vis.params_);
+}
+
+// Returns visual to the default parameters 
+void 
+TeVisual::clear()
+{
+	params_.clear();
+}
+
+// Copies only the basic visual parameters from another visual
+void 
+TeVisual::setBasic (TeVisual &vis)
+{
+	params_.setBasic(vis.params_);
+}
+
+
diff --git a/src/terralib/kernel/TeVisual.h b/src/terralib/kernel/TeVisual.h
new file mode 100644
index 0000000..707e2d9
--- /dev/null
+++ b/src/terralib/kernel/TeVisual.h
@@ -0,0 +1,368 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright  2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeVisual.h
+    \brief This file deals with the visual presentation characteristics of geometries in TerraLib
+*/
+#ifndef  __TERRALIB_INTERNAL_VISUAL_H
+#define  __TERRALIB_INTERNAL_VISUAL_H
+
+#include "TeDataTypes.h"
+#include "TeAbstractFactory.h"
+
+class TeRasterTransform;
+
+#include <string>
+#include <map>
+
+using namespace std;
+
+
+//! A structure for supporting a color definition
+struct TL_DLL TeColor
+{
+	//! Red component
+	int red_;
+
+	//! Green component 
+	int green_; 	
+	
+	//! Blue component
+	int blue_;	
+	
+	//! Color name
+	string name_;
+	
+	//! Empty constructor
+	TeColor () : red_(0),green_(0),blue_(0), name_("") {}
+
+	//! Constructor with parameters
+	TeColor (int r, int g, int b, const string& name="") : red_(r),green_(g),blue_(b), name_(name) {}
+
+	//! Set parameters of colors
+	void init (int r, int g, int b, const string& name="") {red_=r,green_=g,blue_=b;name_=name; }
+
+
+	//! Returns TRUE if color1 is equal to color2 or FALSE if they are different.
+	bool operator== (const TeColor& color)
+	{
+		return (red_==color.red_ && green_==color.green_ && blue_==color.blue_);
+	}
+
+	//! Assignment operator
+	TeColor& operator= ( const TeColor& color )
+	{
+		if ( this != &color )
+		{	
+			red_ = color.red_;
+			green_ = color.green_;
+			blue_ = color.blue_;
+			name_ = color.name_;
+		}
+		return *this;
+	}
+};
+
+//!  A class to represent the base visual parameters 
+/*!  
+	 This class contains the base visual parameters and it is used 
+	 by the factory responsible for creating visual objects. 
+	 
+	\sa
+     TeVisual
+*/
+class TL_DLL TeBaseVisualParams
+{
+public:
+	//! Constructor
+	TeBaseVisualParams(TeGeomRep rep = TePOLYGONS, const string& visualType = "tevisual"); 
+
+	//! Copy constructor
+	TeBaseVisualParams(const TeBaseVisualParams& other);
+
+	//! Destructor
+	virtual ~TeBaseVisualParams() {}
+
+	//! Assignment operator
+	virtual TeBaseVisualParams& operator=(const TeBaseVisualParams& visParams);
+
+	//! Returns TRUE if param1 is equal to param2 or FALSE if they are different.
+	virtual bool operator== (const TeBaseVisualParams& visParams);
+
+	//! Returns visual to the default parameters 
+	virtual void clear();
+
+	//! Copies only the basic visual parameters from another visual
+	virtual void setBasic (TeBaseVisualParams &visParams);
+
+	//! Returns the visual params type 
+	string getProductId() { return visualType_; }
+
+	//! Symbol id that define the style for the geometry filling
+    int			symbId_;			
+	//! Color used for geometry filling (line, point and text color)
+	TeColor		color_;				
+	//! Percentage of transparency for the geometry filling
+	int			transparency_;		
+	//! Width for line geometry
+	int			width_;				
+	
+	//! Symbol id that define the style for the geometry outline
+	int			contourSymbId_;			
+	//! Contour color for the geometry outline
+	TeColor		contourColor_;			
+	//! Percentage of transparency for the geometry outline
+	int			contourTransparency_;	
+	//! Width for the geometry outline
+	int			contourWidth_;			
+
+	//! Point size
+	int			sizeValue_;	
+	//! Point angle
+	int			ptAngle_;				
+	
+	// Text attributes
+	//! Text family
+	string		family_;	
+	//! Flag to indicate if text is bold
+	bool		bold_;			
+	//! Flag to indicate if text is italic
+	bool		italic_;	
+	//! Position of vertical alignment
+	double		alignmentVert_;		
+	//! Position of horizontal alignment
+	double		alignmentHoriz_;	
+	//! Number of spaces defined in a tab character
+	int			tabSize_;		
+	//! Spacing between lines
+	int			lineSpace_;	
+	//! Flag to indicate that element has a fixed size, dont follow zoom operations	
+	bool		fixedSize_;			
+
+	//! Visual type used in factory strategy
+	string		visualType_;
+	//! Geometric representation associated with this visual 
+	TeGeomRep   geomRep_;				
+};
+
+//! This class is used to store the standard presentation characteristics of vector geometries
+class TL_DLL TeVisual
+{
+public :
+	
+	//! Empty constructor
+	TeVisual(TeGeomRep rep = TePOLYGONS);
+
+	//! Destructor
+	virtual ~TeVisual() {}
+
+	//! Copy constructor
+	TeVisual(const TeVisual& other);
+
+	//! Assignment operator
+	virtual TeVisual& operator=(const TeVisual& vis);
+
+	//! Returns TRUE if param1 is equal to param2 or FALSE if they are different.
+	virtual bool operator== (const TeVisual& vis);
+
+	//! Returns visual to the default parameters 
+	virtual void clear();
+
+	//! Copies only the basic visual parameters from another visual
+	virtual void setBasic (TeVisual &vis);
+
+	//! Sets the color used for geometry filling and line, point and text color
+	virtual void color(TeColor& color) 
+	{	params_.color_ = color;}
+
+	//! Returns the color used for geometry filling and line, point and text color
+	virtual TeColor& color() 
+	{ return params_.color_; }
+
+	//! Sets the style for the filling of geometries
+	virtual void style(int s) 
+	{ params_.symbId_ = s; }
+
+	//! Returns the style for the filling of geometries
+	virtual int	style() 
+	{ return params_.symbId_; }
+
+	//! Sets the percentage of transparency for polygons and cells
+	virtual void transparency(int t)
+	{ params_.transparency_ = t; }
+
+	//! Returns the percentage of transparency used in polygons and cells
+	virtual int transparency()
+	{ return params_.transparency_; }
+
+	//! Sets the color for the polygons and cells outlines
+	virtual void contourColor(TeColor& color) 
+	{ params_.contourColor_ = color;}
+
+	//! Returns the color used in the polygons and cells outlines
+	virtual TeColor& contourColor() 
+	{ return params_.contourColor_; }
+
+	//! Sets the percentage of transparency for the polygon ans cells outlines
+	virtual void contourTransparency(int t) 
+	{ params_.contourTransparency_ = t;}
+
+	//! Returns the color used in the polygons and cells outlines
+	virtual int	contourTransparency() 
+	{ return params_.contourTransparency_; }
+
+	//! Sets the contour width for the polygons and cells outlines
+	virtual void contourWidth(int w) 
+	{ params_.contourWidth_ = w; }
+
+	//! Returns the contour width used in the polygons and cells outlines
+	virtual int	contourWidth()  
+	{ return params_.contourWidth_; }
+
+	//! Sets the contour style for the polygons and cells outlines
+	virtual void contourStyle(int s) 
+	{ params_.contourSymbId_ = s; }
+
+	//! Returns the contour style used in the polygons and cells outlines
+	virtual int	contourStyle() 
+	{ return params_.contourSymbId_; }
+
+	//! Sets the width
+	virtual void width(int w) 
+	{ params_.width_ = w; }
+
+	//! Returns the width
+	virtual int	 width ()  
+	{ return params_.width_; }
+
+	//! Sets the point size
+	virtual void size (int s)  
+	{ params_.sizeValue_ = s; }
+
+	//! Returns the point size
+	virtual int	size ()  
+	{ return params_.sizeValue_; }
+
+	//! Sets the text family for fonts
+	virtual void family (string f) 
+	{ params_.family_ = f; }
+
+	//! Returns fonts family
+	virtual string family () 
+	{ return params_.family_ ; }
+
+	//! Sets the bold style for texts
+	virtual void bold (bool b) 
+	{ params_.bold_ = b; }
+
+	//! Returns the bold style used in the texts
+	virtual bool bold () 
+	{ return params_.bold_; }
+
+	//! Sets the italic style for texts
+	virtual void italic (bool i) 
+	{ params_.italic_ = i; }
+
+	//! Returns the italic style used in the texts
+	virtual bool italic () 
+	{ return params_.italic_; }
+
+	//!  Sets a flag indicating if the text will have a fixed size
+	virtual void fixedSize (bool i) 
+	{ params_.fixedSize_ = i; }
+
+	//!  Retuns a flag indicating if an text have a fixed size
+	virtual bool fixedSize () 
+	{ return params_.fixedSize_; }
+
+	//!  Sets the vertical alignment of texts
+	virtual void alignmentVert(double a) 
+	{ params_.alignmentVert_ = a; }
+
+	//!  Retuns the vertical alignment of texts
+	virtual double alignmentVert() 
+	{ return params_.alignmentVert_; }
+
+	//!  Sets the horizontal alignment of texts
+	virtual void alignmentHoriz(double a) 
+	{ params_.alignmentHoriz_ = a; }
+
+	//!  Retuns the horizontal alignment of texts
+	virtual double alignmentHoriz() 
+	{ return params_.alignmentHoriz_; }
+
+	//! Sets the number of spaces defined in a tab character
+	virtual void tabSize (int s) 
+	{ params_.tabSize_ = s; }
+
+	//! Returns the number of spaces defined in a tab character
+	virtual int	tabSize () 
+	{ return params_.tabSize_; }
+
+	//! Sets the spacing between lines
+	virtual void lineSpace (int s) 
+	{ params_.lineSpace_ = s; }
+
+	//! Returns the spacing between lines
+	virtual int	lineSpace () 
+	{ return params_.lineSpace_; }
+
+	//! Returns the angle of points and symbols
+	virtual int   ptAngle() 
+	{return params_.ptAngle_; }
+
+	//! Sets the angle of points and symbols
+	virtual void  ptAngle(int p) 
+	{params_.ptAngle_ = p;}
+
+	//! Creates another visual pointer and copies its content
+	virtual TeVisual* copy()
+	{
+		TeVisual* retval = new TeVisual();
+		*retval = *this;
+		return retval;
+	}
+
+	//! Returns a default visual object
+	static TeVisual* DefaultObject()  
+	{ return new TeVisual(); }
+
+protected:
+	TeBaseVisualParams	params_;
+};
+
+
+//! A factory to build TeVisual objects
+class TL_DLL TeVisualFactory : public TeAbstractFactory<TeVisual, TeBaseVisualParams, string>
+{
+public:
+	TeVisualFactory(const string& facName) : TeAbstractFactory<TeVisual, TeBaseVisualParams, string>(facName)
+	{}
+		virtual TeVisual* build ()
+	{	return new TeVisual(); }
+};
+
+//! Export the type that represents the definition of visual for raster data
+typedef TeRasterTransform TeRasterVisual;
+
+#endif
+
diff --git a/src/terralib/kernel/checkvec.h b/src/terralib/kernel/checkvec.h
new file mode 100644
index 0000000..50cbefb
--- /dev/null
+++ b/src/terralib/kernel/checkvec.h
@@ -0,0 +1,71 @@
+/************************************************************************************
+ TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+// include/checkvec : vector class with checked limits
+#ifndef CHECKVEC_H 
+#define CHECKVEC_H
+#include<cassert>
+#include<vector>
+
+namespace br_stl
+{
+	template<class T>
+	class checkedVector : public std::vector<T>
+	{
+	public:
+		// inherited types
+		typedef typename checkedVector::size_type size_type;
+		typedef typename checkedVector::iterator iterator;
+		typedef typename checkedVector::difference_type difference_type;
+		typedef typename checkedVector::reference reference;
+		typedef typename checkedVector::const_reference const_reference;
+
+		checkedVector() {
+		}
+
+		checkedVector(size_type n, const T& value = T())
+		: std::vector<T>(n, value) {
+		}
+
+	//	  checkedVector(iterator i, iterator j)
+	//      : std::vector<T>(i, j) {}
+
+		reference operator[](difference_type index) {
+			assert(index >=0 
+				&& index < static_cast<difference_type>(this->size()));
+			return std::vector<T>::operator[](index);
+		}
+
+
+			const_reference operator[](difference_type index) const {
+			assert(index >=0 
+				&& index < static_cast<difference_type>(this->size()));
+			return std::vector<T>::operator[](index);
+		}
+
+	};
+}
+
+
+#endif
+
diff --git a/src/terralib/kernel/dynpq.h b/src/terralib/kernel/dynpq.h
new file mode 100644
index 0000000..5b7f5cf
--- /dev/null
+++ b/src/terralib/kernel/dynpq.h
@@ -0,0 +1,190 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+// include/dynpq.h
+#ifndef DYNPQ_H
+#define DYNPQ_H
+#include<checkvec.h>
+#include<algorithm>
+#include<showseq.h>
+
+namespace br_stl
+{
+	// compares the associated values of passed iterators
+	template<class T>
+	struct IterGreater
+	{
+		bool operator()( T x,  T y) const
+		{
+			return *y < *x;
+		}
+	};
+
+	template <class key_type>
+	class dynamic_priority_queue
+	{
+	public:
+		// public type definitions
+		typedef typename std::vector<key_type>::size_type size_type;
+		typedef typename std::vector<key_type>::difference_type index_type;
+
+		// constructor
+		dynamic_priority_queue(std::vector<key_type>& v);
+
+		// change a value at position 'at'
+		void changeKeyAt(index_type at, key_type k);
+
+		// index of the smallest element (= highest priority)
+		index_type topIndex() const { return c.front() - first; }
+
+		// value of the smallest element (= highest priority)
+		const key_type& topKey() const { return *c.front(); }
+
+		void pop();       // remove smallest element from the heap
+
+		bool empty() const { return csize == 0;}
+		size_type size() const { return csize;}
+
+	private:
+	//    checkedVector<index_type> Indices;      // auxiliary vector ANAP
+		vector<index_type> Indices;      // auxiliary vector
+		typedef typename std::vector<key_type>::iterator randomAccessIterator;
+	//    checkedVector<randomAccessIterator> c;  // heap of iterators  ANAP
+		vector<randomAccessIterator> c;  // heap of iterators 
+		randomAccessIterator first;             // beginning of the external vector
+		IterGreater<randomAccessIterator> comp; // comparison object
+		index_type csize;                       // current heap size
+
+		// heap update (see below)
+		void goUp(index_type);
+		void goDown(index_type);
+	};
+
+	template <class key_type>
+	dynamic_priority_queue<key_type>::dynamic_priority_queue(
+		std::vector<key_type>& v)
+	: Indices(v.size()), c(v.size()), first(v.begin()),
+	csize(v.size())
+	{
+		// store iterators and generate heap
+		for(index_type i = 0; i< csize; ++i) 
+		c[i] = v.begin()+i;
+		make_heap(c.begin(), c.end(), comp);        // STL
+
+		// construct index array
+		for(index_type ii = 0; ii< csize; ++ii) // ANAP i-> ii
+		Indices[c[ii] - first] = ii;
+	}
+
+	template <class key_type>
+	void dynamic_priority_queue<key_type>::changeKeyAt(
+									index_type at, key_type k)
+	{
+	index_type idx = Indices[at];
+
+	//  if (idx < csize) //ANAP
+	// {
+	assert(idx < csize);   // value still present in the queue?
+
+	if(*c[idx] != k)       // in case of equality, do nothing
+		if(k > *c[idx])
+		{
+			*c[idx] = k;   // enter heavier value
+			goDown(idx);   // reorganize heap
+		}
+		else
+		{
+			*c[idx] = k;   // enter lighter value
+			goUp(idx);     // reorganize heap
+		}
+	//	 }
+	// else cout << "erro no dynamic_priority_queue<key_type>::changeKeyAt" << idx << csize << k << endl;
+	}
+
+	template <class key_type>
+	void dynamic_priority_queue<key_type>::goUp(index_type idx)
+	{
+		index_type Predecessor = (idx-1)/2;
+		randomAccessIterator temp = c[idx];
+
+		while(Predecessor != idx && comp(c[Predecessor], temp))
+		{
+			c[idx] = c[Predecessor];
+			Indices[c[idx]-first] = idx;
+			idx = Predecessor;
+			Predecessor = (idx-1)/2;
+		}
+	    
+		c[idx] = temp;
+		Indices[c[idx]-first] = idx;
+	}
+
+	template <class key_type>
+	void dynamic_priority_queue<key_type>::goDown(index_type idx)
+	{
+		index_type Successor = (idx+1)*2-1;
+
+		if(Successor < csize-1
+			&& comp(c[Successor], c[Successor+1]))
+			++Successor;
+		randomAccessIterator temp = c[idx];
+
+		while(Successor < csize && comp(temp, c[Successor]))
+		{
+			c[idx] = c[Successor];
+			Indices[c[idx]-first] = idx;
+			idx = Successor;
+			Successor = (idx+1)*2-1;
+
+			if(Successor < csize-1
+			&& comp(c[Successor], c[Successor+1]))
+				++Successor;
+		}
+		c[idx] = temp;
+		Indices[c[idx]-first] = idx;
+	}
+
+	/* The method pop() removes the topmost element from the heap. This is
+	done by moving the last element to the top and blocking the freed
+	position with --csize. Subsequently, the element sinks down to its
+	proper position. */
+
+	template <class key_type>
+	void dynamic_priority_queue<key_type>::pop()
+	{
+	// overwrite iterator at the top with the 
+	// address of the last element
+	c[0] = c[--csize];
+
+	// enter the new address 0 at the position belonging 
+	// to this element in the auxiliary array
+	Indices[c[0]-first] = 0;
+
+	// let the element at the top sink to the correct
+	// position corresponding to its weight
+	goDown(0);
+	}
+
+} // namespace br_stl
+#endif
+
diff --git a/src/terralib/kernel/graph.h b/src/terralib/kernel/graph.h
new file mode 100644
index 0000000..1c21b70
--- /dev/null
+++ b/src/terralib/kernel/graph.h
@@ -0,0 +1,379 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file graph.h
+    \brief This file contains structures and definitions used to manipulate a graph strucutre
+	\note this code came from the book "Desining Components with C++ STL" -
+	Ulrich Breymann - Addison-Wesley - pag 243
+*/
+#ifndef GRAPH_H
+#define GRAPH_H
+#include<cassert>
+#include<vector>
+#include<map>
+#include<stack>
+#include<iostream>
+#include <TeDefines.h>
+
+namespace br_stl
+{
+	// empty parameter class with a minimal set of operations
+	// if there are no weights for edges necessary
+	struct TL_DLL Empty
+	{
+	public:
+		Empty(int=0) {}
+		bool operator<(const Empty&) const { return true;}
+	};
+
+	inline std::ostream& operator<<(std::ostream& os, const Empty&) { return os;}
+	inline std::istream& operator>>(std::istream& is, Empty& ) { return is;}
+
+	template<class VertexType, class EdgeType>
+	class Graph
+	{
+	public:
+		// public type interface
+		typedef std::map<int, EdgeType > Successor;
+		typedef std::pair<VertexType, Successor> vertex;
+		typedef std::vector<vertex> GraphType;
+		typedef typename GraphType::iterator iterator;
+		typedef typename GraphType::const_iterator const_iterator;
+
+		/* The following constructor initializes the output channel with
+		cerr. A parameter must be specified as to whether the graph is
+		directed or undirected, because this is an essential property
+		of a graph. */
+
+		Graph(bool g, std::ostream& os = cerr)
+		: directed(g), pOut(&os) 
+		{ }
+
+		bool isDirected() const { return directed;}
+
+		/* A graph is a special kind of container to which something can
+		be added and whose elements can be accessed. Therefore, typical
+		container methods follow, which in their extent are limited to
+		those needed in the book's examples. Thus, there is no method
+		for explicit removal of a vertex or an edge from the graph. */
+
+		size_t size() const  { return C.size();}
+
+		iterator begin()     { return C.begin();}
+		iterator end()       { return C.end();}
+
+		// access to vertex i}
+		vertex& operator[](int i)
+		{
+			// the access is safe, because C is a checkedVector
+			return C[i];
+		}
+
+		// return the position of the vertex, if it does not exist return -1
+		int getPosition(const VertexType& e); 
+
+		// addition of a vertex
+		int  insert(const VertexType& e);
+
+		// addition of an edge between e1 and e2
+		void insert(const VertexType& e1, const VertexType& e2,
+					const EdgeType& Value);
+
+		// addition of an edge between vertices no. i and j
+		void connectVertices(int i, int j, const EdgeType& Value);
+
+		// set the edge value between vertices no. i and j
+		bool setEdgeValue(const VertexType& e1, const VertexType& e2, const EdgeType& Value);
+
+		/* The following methods are useful tools for displaying
+		information on a graph and check its structure.*/
+
+		// checking of a read data model
+		// output on the channel passed to check()
+		void check(std::ostream& = std::cout);
+
+		// determine the number of edges
+		size_t CountEdges();
+
+		/* determine whether the graph contains cycles and in which way it
+		is connected. The method combines two tasks, because they can
+		be carried out in a single run.*/
+		void CycleAndConnect(std::ostream& = cout);
+		int sucessors(int index);
+
+	private:
+		bool directed;
+		GraphType C;          // container
+		std::ostream* pOut;
+	};      // class Graph
+
+
+	template<class VertexType, class EdgeType>
+	int Graph<VertexType,EdgeType>::getPosition(const VertexType& e) 
+	{
+		for(size_t i = 0; i < size(); ++i)
+		if(e == C[i].first)
+			return i;
+
+		return -1;
+	}
+		
+	/* In order to avoid ambiguities, a vertex is only entered if it does
+	not yet exist. The sequential search is not particularly fast; on the
+	other hand, this process is only needed once during the construction
+	of the graph. The position of the vertex is returned. */
+
+	template<class VertexType, class EdgeType>
+	int Graph<VertexType,EdgeType>::insert(const VertexType& e) 
+	{
+		int pos = getPosition(e);
+		if(pos<0)
+		{
+			// if not found, insert:
+			C.push_back(vertex(e, Successor()));
+			return size()-1;
+		}
+
+		return pos;
+	}
+
+	/* An edge is inserted by first inserting the vertices, if needed, and
+	by determining their positions. The edge construction itself is 
+	carried out by the function connectVertices(). It is passed the
+	vertex numbers and, because of the absence of a search procedure, 
+	it is very fast. */
+
+	template<class VertexType, class EdgeType>
+	void Graph<VertexType,EdgeType>::insert(const VertexType& e1,
+										const VertexType& e2,
+										const EdgeType& Value)
+	{
+		int pos1 = insert(e1);
+		int pos2 = insert(e2);
+		connectVertices(pos1, pos2, Value);
+	}
+
+	template<class VertexType, class EdgeType>
+	void Graph<VertexType,EdgeType>::connectVertices(
+				int pos1, int pos2, const EdgeType& Value) 
+	{
+		(C[pos1].second)[pos2] = Value;
+
+		if(!directed)  // automatically insert opposite direction too
+		(C[pos2].second)[pos1] = Value;
+	}
+
+	template<class VertexType, class EdgeType>
+	bool Graph<VertexType,EdgeType>::setEdgeValue(const VertexType& e1,
+										const VertexType& e2,
+										const EdgeType& Value) 
+	{
+		int pos1 = getPosition(e1);
+		int pos2 = getPosition(e2);
+
+		if((pos1<0) || (pos2<0))
+			return false;
+
+		(C[pos1].second)[pos2] = Value;
+
+		if(!directed)  // automatically insert opposite direction too
+		(C[pos1].second)[pos2] = Value;
+
+		return true;
+	}
+
+
+	template<class VertexType, class EdgeType>
+	void Graph<VertexType,EdgeType>::check(std::ostream& os)
+	{
+		os << "The graph is ";
+		if(!isDirected())
+			os << "un";
+
+		os << "directed and has "
+		<< size() << " vertices and "
+		<< CountEdges()
+		<< " edges\n";
+		CycleAndConnect(os);
+	}
+
+	template<class VertexType, class EdgeType>
+	size_t Graph<VertexType,EdgeType>::CountEdges()
+	{
+		size_t edges = 0;
+		iterator temp = begin();
+
+		while(temp != end())
+			edges += (*temp++).second.size();
+
+		if(!directed)
+			edges /= 2;
+		return edges;
+	}
+
+	// Type for next function
+	enum VertStatus {notVisited, visited, processed};
+
+	template<class VertexType, class EdgeType>
+	int Graph<VertexType, EdgeType>::sucessors(int index) {
+		typename Successor::const_iterator
+		start  = operator[](index).second.begin(),
+		end    = operator[](index).second.end();
+		int nSucc = 0;
+		while(start != end)
+		{
+			nSucc++;
+			++start;
+		}
+
+		return nSucc;
+	}
+	template<class VertexType, class EdgeType>
+	void Graph<VertexType, EdgeType>::CycleAndConnect(std::ostream& os) {
+		int Cycles = 0;
+		int ComponentNumber = 0;
+		std::stack<int, std::vector<int> > verticesStack;  // vertices to be visited
+
+		/* In order to prevent multiple visits to vertices in possible
+		cycles, which entails the risk of infinite loops, the vertices
+		are marked for having been visited or finished being processed.
+		This purpose is served by the vector VertexState. */
+	       
+		// assign all vertices the state `not visited'
+		std::vector<VertStatus> VertexState(size(), notVisited);
+
+		/* If, starting from one vertex, an attempt is made to reach all
+		other vertices, success is not guaranteed in weakly or
+		non-connected graphs. Therefore, each vertex is visited. If it
+		is found that a vertex has already been visited, it does not
+		need to be processed any further. */
+
+		// visit all vertices
+		for(size_t i = 0; i < size(); ++i)
+		{
+			if(VertexState[i] == notVisited)
+			{
+				++ComponentNumber;
+				// store on stack for further processing
+				verticesStack.push(i);
+
+				// process stack
+				while(!verticesStack.empty())
+				{
+					int theVertex = verticesStack.top();
+					verticesStack.pop();
+					if(VertexState[theVertex] == visited)
+					VertexState[theVertex] = processed;
+					else
+					if(VertexState[theVertex] == notVisited)
+					{
+						VertexState[theVertex] = visited;
+						// new vertex, earmark for processed mark
+						verticesStack.push(theVertex);
+
+						/* If one of the successors of a newly found vertex
+							bears the visited mark, the algorithm has already
+							passed this point once, and there is a cycle. */
+		                     
+						// earmark successor:
+						typename Successor::const_iterator
+							start  = operator[](theVertex).second.begin(),
+							end    = operator[](theVertex).second.end();
+
+						while(start != end)
+						{
+							int Succ = (*start).first;
+
+							if(VertexState[Succ] == visited)
+							{
+								++Cycles;   // someone's been here already!
+								(*pOut) << "at least vertex "
+								<< operator[](Succ).first
+								<< " lies in a cycle\n";
+							}
+
+							/* Otherwise, the vertex has already been
+								processed and therefore should not be
+								considered again, or it has not yet been
+								visited and is earmarked on the stack. */
+		                          
+							if(VertexState[Succ] == notVisited)
+								verticesStack.push(Succ);
+							++start;
+						}
+					}
+				}  // stack empty?
+			}     //  if(VertexState}...
+		}       // for()} ...
+
+		/* Now we only need the output. In case of directed, weakly
+		connected graphs, the algorithm counts several components. In
+		order to make the output conform to the above definitions,
+		although with less content of information, a distinction is
+		made as to whether the graph is directed or not. */
+
+		if(directed)
+		{
+			if(ComponentNumber == 1)
+				os << "The graph is strongly connected.\n";
+			else
+				os << "The graph is not or weakly "
+					"connected.\n";
+		}
+		else
+			os	<< "The graph has "
+				<< ComponentNumber
+				<< " component(s)." << std::endl;
+
+		os << "The graph has ";
+		if(Cycles == 0)
+			os << "no ";
+		os << "cycles." << std::endl;
+	}
+
+	template<class VertexType, class EdgeType>
+	std::ostream& operator<<(std::ostream& os, Graph<VertexType,EdgeType>& G)
+	{
+		// display of vertices with successors
+		for(size_t i = 0; i < G.size(); ++i)
+		{
+			os << G[i].first << " <";
+			typename Graph<VertexType,EdgeType>::Successor::const_iterator
+								startN = G[i].second.begin(),
+								endN   = G[i].second.end();
+
+			while(startN != endN)
+			{
+				os << G[(*startN).first].first << ' ' // vertex
+				<< (*startN).second << ' ';        // edge value
+				++startN;
+			}
+			os << ">" << std::endl;
+		}
+		return os;
+	}
+} // namespace br_stl
+
+
+
+#endif
+
diff --git a/src/terralib/kernel/lexTemporal.cpp b/src/terralib/kernel/lexTemporal.cpp
new file mode 100644
index 0000000..55a0eae
--- /dev/null
+++ b/src/terralib/kernel/lexTemporal.cpp
@@ -0,0 +1,1927 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header: /home/terralib/src/terralib/kernel/lexTemporal.cpp,v 1.8 2007/01/16 16:52:24 lubia Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+#include <errno.h>
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ * 	if ( condition_holds )
+ *		yyless( 5 );
+ *	else
+ *		do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		*yy_cp = yy_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+	{
+	FILE *yy_input_file;
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
+
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
+
+	int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via yyrestart()), so that the user can continue scanning by
+	 * just pointing yyin at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+	};
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_is_interactive = is_interactive; \
+	}
+
+#define yy_set_bol(at_bol) \
+	{ \
+	if ( ! yy_current_buffer ) \
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	yy_current_buffer->yy_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+
+#define YY_USES_REJECT
+
+#define yywrap() 1
+#define YY_SKIP_YYWRAP
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern int yylineno;
+int yylineno = 1;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+	yytext_ptr = yy_bp; \
+	yyleng = (int) (yy_cp - yy_bp); \
+	yy_hold_char = *yy_cp; \
+	*yy_cp = '\0'; \
+	yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 35
+#define YY_END_OF_BUFFER 36
+static yyconst short int yy_acclist[257] =
+    {   0,
+       36,   34,   35,    1,    2,   34,   35,   33,   35,    2,
+       34,   35,    3,   34,   35,    4,   34,   35,   34,   35,
+       23,   34,   35,   34,   35,   34,   35,   26,   34,   35,
+       34,   35,   34,   35,   34,   35,    1,    3,    4,   31,
+       32,   23,   30,   30,   26,   30,   26,   30,   30,   27,
+       30,   30,   28,   30,   26,   30,   26,   30,   26,   30,
+       29,   30,   30,   30,   30,   30,   30,   30,   30,   26,
+       30,   26,   30,   26,   30,   26,   30,   30,   30,   30,
+       30,   30,   30,   30,   30,   24,   26,   30,   26,   30,
+       26,   30,   26,   30,   26,   30,   16,   30,   30,   30,
+
+       30,   30,   30,   30,   30,   30,   24,   26,   30,   26,
+       30,   26,   30,   26,   30,   26,   30,   26,   30,   30,
+       15,   30,   30,   30,   30,   30,   30,   30,   18,   30,
+       24,   26,   30,   26,   30,   26,   30,   26,   30,   26,
+       30,   26,   30,   30,   30,   17,   30,   30,   30,   30,
+       30,   30,   30,   30,   30,   30,   30,   26,   30,   26,
+       30,   26,   30,   26,   30,   26,   30,   30,   30,   14,
+       30,   21,   30,   13,   30,   30,   30,   30,   30,   30,
+       30,   30,   30,   30,   26,   30,   26,   30,   26,   30,
+       26,   30,   30,   30,   30,   30,   30,   30,   30,   30,
+
+       30,   30,   30,   26,   30,   26,   30,   26,   30,   30,
+       30,   30,   30,   30,   11,   30,   30,   30,   30,   30,
+       30,   25,   25,   26,   30,   26,   30,   19,   30,   20,
+       30,    7,   30,   30,   30,    5,   30,    8,   30,   30,
+       30,   30,   26,   30,    6,   30,    9,   30,   30,   12,
+       30,   22,   30,   30,   10,   30
+    } ;
+
+static yyconst short int yy_accept[189] =
+    {   0,
+        1,    1,    1,    2,    4,    8,   10,   13,   16,   19,
+       21,   24,   26,   28,   31,   33,   35,   37,   38,   39,
+       40,   41,   42,   42,   43,   44,   45,   47,   49,   50,
+       52,   53,   53,   55,   57,   59,   61,   63,   64,   65,
+       66,   67,   68,   69,   70,   70,   72,   74,   76,   78,
+       79,   80,   81,   82,   83,   84,   85,   86,   87,   89,
+       91,   93,   95,   97,   99,  100,  101,  102,  103,  104,
+      105,  106,  107,  107,  108,  110,  112,  114,  116,  118,
+      120,  121,  123,  124,  125,  126,  127,  128,  129,  131,
+      131,  132,  134,  136,  138,  140,  142,  144,  145,  146,
+
+      148,  149,  150,  151,  152,  153,  154,  155,  156,  157,
+      158,  158,  158,  160,  162,  164,  166,  168,  169,  170,
+      172,  174,  176,  177,  178,  179,  180,  181,  182,  183,
+      184,  185,  185,  185,  187,  189,  191,  193,  194,  195,
+      196,  197,  198,  199,  200,  201,  202,  203,  204,  204,
+      204,  206,  208,  210,  211,  212,  213,  214,  215,  217,
+      218,  219,  220,  221,  222,  223,  224,  226,  228,  230,
+      232,  234,  235,  236,  238,  240,  241,  242,  243,  245,
+      247,  249,  250,  252,  254,  255,  257,  257
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    1,    1,    1,    1,    1,    1,    5,
+        6,    7,    1,    1,    1,    1,    8,    9,    9,    9,
+        9,    9,    9,    9,    9,    9,    9,   10,    1,    1,
+        1,    1,    1,    1,   11,   12,   13,   14,   15,   16,
+       17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
+       27,   28,   29,   30,   31,   32,   33,   20,   34,   20,
+        1,    1,    1,    1,   35,    1,   20,   20,   20,   20,
+
+       36,   20,   20,   20,   20,   20,   20,   20,   37,   20,
+       20,   20,   20,   20,   38,   20,   20,   20,   20,   20,
+       20,   20,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst int yy_meta[39] =
+    {   0,
+        1,    1,    2,    1,    1,    1,    1,    1,    3,    1,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3
+    } ;
+
+static yyconst short int yy_base[190] =
+    {   0,
+        0,    0,  242,  581,  239,  581,  581,  234,  232,   32,
+       33,  213,    0,   29,  209,  205,  195,  228,  224,  222,
+      581,  581,  217,   36,    0,  211,   54,   79,  194,    0,
+      103,   40,    0,  124,  149,  185,    0,  211,  195,   31,
+      204,  199,  202,  200,  205,  173,  198,  175,  222,  175,
+      177,  182,  181,   40,  181,  188,  190,  191,  247,  272,
+      161,  296,  160,  172,  167,  163,  163,  163,  165,  174,
+      167,  157,  175,  173,  143,  321,  142,  345,  141,  370,
+      161,    0,  146,  157,  149,  149,  398,  146,    0,   45,
+       50,  132,  131,  414,  130,  439,  128,   28,  150,    0,
+
+      140,  146,  143,  142,  125,   46,  140,  122,  122,  135,
+      141,  140,  110,  108,  464,  107,  489,  129,  128,    0,
+        0,    0,  111,  124,  111,  121,  103,  116,  115,  118,
+       94,   55,   65,   89,   87,  514,   86,  108,  111,  105,
+       94,   99,   86,  103,   82,   83,   82,   94,   98,   97,
+       67,   66,  539,   82,   73,   72,   71,   74,    0,   74,
+       66,   72,   60,   78,   78,   69,   48,   47,    0,    0,
+        0,   69,   65,    0,    0,   70,   51,   48,   33,    0,
+        0,   43,    0,    0,   28,    0,  581,   43,  577
+    } ;
+
+static yyconst short int yy_def[190] =
+    {   0,
+      187,    1,  187,  187,  187,  187,  187,  187,  187,  187,
+      187,  188,  188,  188,  188,  188,  188,  187,  187,  187,
+      187,  187,  187,  187,  188,  188,  188,   14,  188,  188,
+      188,  187,  188,  188,   27,   35,  188,  188,  188,  188,
+      188,  188,  188,  188,  187,  188,   34,   47,   47,  188,
+      188,  188,  188,  188,  188,  188,  188,  189,  188,   46,
+       60,   60,   62,  188,  188,  188,  188,  188,  188,  188,
+      188,  188,  187,  189,   59,   59,   76,   76,   78,   78,
+      188,  188,  188,  188,  188,  188,  188,  188,  188,  187,
+      189,   76,   76,   76,   94,   94,   96,  188,  188,  188,
+
+      188,  188,  188,  188,  188,  188,  188,  188,  188,  188,
+      187,  187,   94,   94,   94,  115,  115,  188,  188,  188,
+      188,  188,  188,  188,  188,  188,  188,  188,  188,  188,
+      188,  187,  187,  115,  115,  115,  136,  188,  188,  188,
+      188,  188,  188,  188,  188,  188,  188,  188,  187,  187,
+      136,  136,  136,  188,  188,  188,  188,  188,  188,  188,
+      188,  188,  188,  188,  187,  187,  153,  153,  188,  188,
+      188,  188,  188,  188,  188,  188,  188,  188,  188,  188,
+      188,  188,  188,  188,  188,  188,    0,  187,  187
+    } ;
+
+static yyconst short int yy_nxt[620] =
+    {   0,
+        4,    5,    6,    7,    8,    9,    4,   10,   11,    4,
+       12,   13,   13,   14,   13,   13,   13,   14,   13,   13,
+       13,   13,   14,   15,   16,   13,   13,   13,   14,   17,
+       13,   13,   13,   14,    4,   13,   14,   13,   21,   22,
+       23,   24,   27,   23,   24,   25,   27,   45,   32,   52,
+       68,   27,   69,   90,  111,   53,  186,   27,   91,  112,
+      118,  119,   27,  132,  149,   27,   28,   34,  185,  126,
+      179,   34,  127,  133,  150,  184,   34,  166,  149,  183,
+      182,  181,   34,  180,  179,  167,  165,   34,  178,  177,
+       34,   35,   36,  176,  175,  174,   36,  173,  172,  171,
+
+      170,   36,  169,  167,  151,  166,  165,   36,  164,  163,
+      162,  161,   36,  160,  159,   36,   38,  158,  157,  156,
+       39,  155,  154,  153,  151,   40,  134,  148,  147,  146,
+      145,   41,   42,  144,  143,   43,   44,   46,  142,  141,
+      140,   46,  139,  138,  136,  134,   46,  113,  133,  132,
+      131,  130,   46,  129,  128,  125,  124,   46,  123,  122,
+       46,   47,   48,  121,  120,  117,   48,  115,  113,   92,
+      110,   48,  102,  101,  100,   99,   98,   48,   96,   94,
+       92,   91,   48,   90,   89,   48,   59,   88,   87,   86,
+       59,   85,   84,   83,   82,   59,   81,   80,   78,   74,
+
+       72,   59,   71,   70,   67,   66,   59,   65,   64,   59,
+       60,   61,   62,   58,   57,   61,   56,   55,   54,   51,
+       61,   50,   49,   37,   33,   32,   61,   20,   19,   18,
+       31,   61,   30,   29,   61,   63,   26,   20,   19,   63,
+       18,  187,  187,  187,   63,  187,  187,  187,  187,  187,
+       63,  187,  187,  187,  187,   63,  187,  187,   63,   49,
+       75,  187,  187,  187,   75,  187,  187,  187,  187,   75,
+      187,  187,  187,  187,  187,   75,  187,  187,  187,  187,
+       75,  187,  187,   75,   76,   77,  187,  187,  187,   77,
+      187,  187,  187,  187,   77,  187,  187,  187,  187,  187,
+
+       77,  187,  187,  187,  187,   77,  187,  187,   77,   79,
+      187,  187,  187,   79,  187,  187,  187,  187,   79,  187,
+      187,  187,  187,  187,   79,  187,  187,  187,  187,   79,
+      187,  187,   79,   62,   93,  187,  187,  187,   93,  187,
+      187,  187,  187,   93,  187,  187,  187,  187,  187,   93,
+      187,  187,  187,  187,   93,  187,  187,   93,   95,  187,
+      187,  187,   95,  187,  187,  187,  187,   95,  187,  187,
+      187,  187,  187,   95,  187,  187,  187,  187,   95,  187,
+      187,   95,   78,   97,  187,  187,  187,   97,  187,  187,
+      187,  187,   97,  187,  187,  187,  187,  187,   97,  187,
+
+      187,  187,  187,   97,  187,  187,   97,   80,  103,  104,
+      187,  105,  106,  187,  187,  187,  187,  187,  187,  187,
+      107,  187,  108,  187,  187,  187,  109,  114,  187,  187,
+      187,  114,  187,  187,  187,  187,  114,  187,  187,  187,
+      187,  187,  114,  187,  187,  187,  187,  114,  187,  187,
+      114,   94,  116,  187,  187,  187,  116,  187,  187,  187,
+      187,  116,  187,  187,  187,  187,  187,  116,  187,  187,
+      187,  187,  116,  187,  187,  116,   96,  135,  187,  187,
+      187,  135,  187,  187,  187,  187,  135,  187,  187,  187,
+      187,  187,  135,  187,  187,  187,  187,  135,  187,  187,
+
+      135,  115,  137,  187,  187,  187,  137,  187,  187,  187,
+      187,  137,  187,  187,  187,  187,  187,  137,  187,  187,
+      187,  187,  137,  187,  187,  137,  117,  152,  187,  187,
+      187,  152,  187,  187,  187,  187,  152,  187,  187,  187,
+      187,  187,  152,  187,  187,  187,  187,  152,  187,  187,
+      152,  136,  168,  187,  187,  187,  168,  187,  187,  187,
+      187,  168,  187,  187,  187,  187,  187,  168,  187,  187,
+      187,  187,  168,  187,  187,  168,  153,   73,  187,   73,
+        3,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
+      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+      187,  187,  187,  187,  187,  187,  187,  187,  187
+    } ;
+
+static yyconst short int yy_chk[620] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,   10,   10,
+       11,   11,   14,   24,   24,  188,   14,   32,   32,   40,
+       54,   14,   54,   90,   90,   40,  185,   14,   91,   91,
+       98,   98,   14,  132,  132,   14,   14,   27,  182,  106,
+      179,   27,  106,  133,  133,  178,   27,  166,  166,  177,
+      176,  173,   27,  172,  168,  167,  165,   27,  164,  163,
+       27,   27,   28,  162,  161,  160,   28,  158,  157,  156,
+
+      155,   28,  154,  152,  151,  150,  149,   28,  148,  147,
+      146,  145,   28,  144,  143,   28,   31,  142,  141,  140,
+       31,  139,  138,  137,  135,   31,  134,  131,  130,  129,
+      128,   31,   31,  127,  126,   31,   31,   34,  125,  124,
+      123,   34,  119,  118,  116,  114,   34,  113,  112,  111,
+      110,  109,   34,  108,  107,  105,  104,   34,  103,  102,
+       34,   34,   35,  101,   99,   97,   35,   95,   93,   92,
+       88,   35,   86,   85,   84,   83,   81,   35,   79,   77,
+       75,   74,   35,   73,   72,   35,   46,   71,   70,   69,
+       46,   68,   67,   66,   65,   46,   64,   63,   61,   58,
+
+       57,   46,   56,   55,   53,   52,   46,   51,   50,   46,
+       46,   47,   48,   45,   44,   47,   43,   42,   41,   39,
+       47,   38,   36,   29,   26,   23,   47,   20,   19,   18,
+       17,   47,   16,   15,   47,   49,   12,    9,    8,   49,
+        5,    3,    0,    0,   49,    0,    0,    0,    0,    0,
+       49,    0,    0,    0,    0,   49,    0,    0,   49,   49,
+       59,    0,    0,    0,   59,    0,    0,    0,    0,   59,
+        0,    0,    0,    0,    0,   59,    0,    0,    0,    0,
+       59,    0,    0,   59,   59,   60,    0,    0,    0,   60,
+        0,    0,    0,    0,   60,    0,    0,    0,    0,    0,
+
+       60,    0,    0,    0,    0,   60,    0,    0,   60,   62,
+        0,    0,    0,   62,    0,    0,    0,    0,   62,    0,
+        0,    0,    0,    0,   62,    0,    0,    0,    0,   62,
+        0,    0,   62,   62,   76,    0,    0,    0,   76,    0,
+        0,    0,    0,   76,    0,    0,    0,    0,    0,   76,
+        0,    0,    0,    0,   76,    0,    0,   76,   78,    0,
+        0,    0,   78,    0,    0,    0,    0,   78,    0,    0,
+        0,    0,    0,   78,    0,    0,    0,    0,   78,    0,
+        0,   78,   78,   80,    0,    0,    0,   80,    0,    0,
+        0,    0,   80,    0,    0,    0,    0,    0,   80,    0,
+
+        0,    0,    0,   80,    0,    0,   80,   80,   87,   87,
+        0,   87,   87,    0,    0,    0,    0,    0,    0,    0,
+       87,    0,   87,    0,    0,    0,   87,   94,    0,    0,
+        0,   94,    0,    0,    0,    0,   94,    0,    0,    0,
+        0,    0,   94,    0,    0,    0,    0,   94,    0,    0,
+       94,   94,   96,    0,    0,    0,   96,    0,    0,    0,
+        0,   96,    0,    0,    0,    0,    0,   96,    0,    0,
+        0,    0,   96,    0,    0,   96,   96,  115,    0,    0,
+        0,  115,    0,    0,    0,    0,  115,    0,    0,    0,
+        0,    0,  115,    0,    0,    0,    0,  115,    0,    0,
+
+      115,  115,  117,    0,    0,    0,  117,    0,    0,    0,
+        0,  117,    0,    0,    0,    0,    0,  117,    0,    0,
+        0,    0,  117,    0,    0,  117,  117,  136,    0,    0,
+        0,  136,    0,    0,    0,    0,  136,    0,    0,    0,
+        0,    0,  136,    0,    0,    0,    0,  136,    0,    0,
+      136,  136,  153,    0,    0,    0,  153,    0,    0,    0,
+        0,  153,    0,    0,    0,    0,    0,  153,    0,    0,
+        0,    0,  153,    0,    0,  153,  153,  189,    0,  189,
+      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
+      187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+      187,  187,  187,  187,  187,  187,  187,  187,  187
+    } ;
+
+static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;
+static char *yy_full_match;
+static int yy_lp;
+#define REJECT \
+{ \
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
+yy_cp = yy_full_match; /* restore poss. backed-over text */ \
+++yy_lp; \
+goto find_rule; \
+}
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#define INITIAL 0
+/*
+* Lex
+*/
+#include <string.h>
+#include <yyTemporal.h>
+
+extern const char *myinputptr;	/* current position in myinput */
+extern long  myinputlim;		/* end of data */
+
+int   lineno;
+char lexOut[1000];
+char sqlOutLex[1000];
+
+#undef YY_INPUT
+extern int my_yyinput(char* buf, int max_size);
+#define YY_INPUT(buffer, result, size) (result=my_yyinput(buffer,size))
+
+void initLexOut()
+{
+	for(int i=0; i<1000; ++i)
+	{
+		lexOut[i] = '\0';
+		sqlOutLex[i] = '\0';
+	}
+	return;
+}
+
+int my_yyinput(char* buf, int max_size)
+{
+	int n = max_size;
+//	int s = myinputlim - (int)myinputptr;
+	long s = myinputlim - (long)myinputptr;
+	if(max_size>s)
+		n = s;
+		
+	//int n = min(max_size, myinputlim - (int)myinputptr);
+	if(n>0)
+	{
+		initLexOut(); 
+		memcpy(buf, myinputptr, n);		
+		myinputptr += n;
+	}	
+	return n;
+}
+
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+	if ( yy_current_buffer->yy_is_interactive ) \
+		{ \
+		int c = '*', n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( yyin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else \
+		{ \
+		errno=0; \
+		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+			{ \
+			if( errno != EINTR) \
+				{ \
+				YY_FATAL_ERROR( "input in flex scanner failed" ); \
+				break; \
+				} \
+			errno=0; \
+			clearerr(yyin); \
+			} \
+		}
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+	YY_USER_ACTION
+
+YY_DECL
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
+
+
+
+
+	if ( yy_init )
+		{
+		yy_init = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! yy_start )
+			yy_start = 1;	/* first start state */
+
+		if ( ! yyin )
+			yyin = stdin;
+
+		if ( ! yyout )
+			yyout = stdout;
+
+		if ( ! yy_current_buffer )
+			yy_current_buffer =
+				yy_create_buffer( yyin, YY_BUF_SIZE );
+
+		yy_load_buffer_state();
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		yy_cp = yy_c_buf_p;
+
+		/* Support of yytext. */
+		*yy_cp = yy_hold_char;
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+		yy_current_state = yy_start;
+		yy_state_ptr = yy_state_buf;
+		*yy_state_ptr++ = yy_current_state;
+yy_match:
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 188 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			*yy_state_ptr++ = yy_current_state;
+			++yy_cp;
+			}
+		while ( yy_base[yy_current_state] != 581 );
+
+yy_find_action:
+		yy_current_state = *--yy_state_ptr;
+		yy_lp = yy_accept[yy_current_state];
+/* find_rule:  we branch to this label when backing up */
+		for ( ; ; ) /* until we find what rule we matched */
+			{
+			if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] )
+				{
+				yy_act = yy_acclist[yy_lp];
+					{
+					yy_full_match = yy_cp;
+					break;
+					}
+				}
+			--yy_cp;
+			yy_current_state = *--yy_state_ptr;
+			yy_lp = yy_accept[yy_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+		if ( yy_act != YY_END_OF_BUFFER )
+			{
+			int yyl;
+			for ( yyl = 0; yyl < yyleng; ++yyl )
+				if ( yytext[yyl] == '\n' )
+					++yylineno;
+			}
+
+do_action:	/* This label is used only to access EOF actions. */
+
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+case 1:
+YY_RULE_SETUP
+{ ; } 
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+{ ; }
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+{	strncat(sqlOutLex, yytext, strlen(yytext)); };
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+{  strncat(sqlOutLex, yytext, strlen(yytext)); };
+	YY_BREAK
+case 5:
+case 6:
+case 7:
+case 8:
+case 9:
+case 10:
+case 11:
+case 12:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext));
+		strncat(lexOut, ";", 1); 
+		return TEMPORALRELATION; }
+	YY_BREAK
+case 13:
+case 14:
+case 15:
+case 16:
+case 17:
+case 18:
+case 19:
+case 20:
+case 21:
+case 22:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext)); 
+		  return CHRONON; }
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext)); strncat(lexOut, ";", 1); return NUMBER;}
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext)); strncat(lexOut, ";", 1); return NUMBER;  }
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext)); strncat(lexOut, ";", 1); return NUMBER; }
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext)); strncat(lexOut, ";", 1); return MASK;}
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+{strncat(sqlOutLex, yytext, strlen(yytext)); return OR;} 
+	YY_BREAK
+case 28:
+YY_RULE_SETUP
+{strncat(sqlOutLex, yytext, strlen(yytext)); return AND;}
+	YY_BREAK
+case 29:
+YY_RULE_SETUP
+{strncat(sqlOutLex, yytext, strlen(yytext)); return NOT;}
+	YY_BREAK
+case 30:
+YY_RULE_SETUP
+{ strncat(lexOut, yytext, strlen(yytext)); strncat(lexOut, ";", 1); return NAME; }
+	YY_BREAK
+case 31:
+YY_RULE_SETUP
+{
+#if TePLATFORM != TePLATFORMCODE_AIX
+		int	yyinput();
+#endif
+		unsigned char c1=0,c2=yyinput();
+		while (1)
+		{
+			if ((char)c2==EOF) break;
+			if ((c1=='*') && (c2=='/')) break;
+			if (c2=='\n') {lineno++;}
+			c1=c2;
+			c2=yyinput();
+		}
+	}
+	YY_BREAK
+case 32:
+YY_RULE_SETUP
+{
+#if TePLATFORM != TePLATFORMCODE_AIX
+		int	yyinput();
+#endif
+		unsigned char c1=yyinput();
+		while (1)
+		{
+			if (c1=='\n') {lineno++;break;}
+			c1=yyinput();
+		}
+	}
+	YY_BREAK
+case 33:
+YY_RULE_SETUP
+{ lineno++; }
+	YY_BREAK
+case 34:
+YY_RULE_SETUP
+{ return yytext[0]; }
+	YY_BREAK
+case YY_STATE_EOF(INITIAL):
+{ return 0; }
+	YY_BREAK
+case 35:
+YY_RULE_SETUP
+ECHO;
+	YY_BREAK
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = yy_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed yyin at a new source and called
+			 * yylex().  If so, then we have to assure
+			 * consistency between yy_current_buffer and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			yy_n_chars = yy_current_buffer->yy_n_chars;
+			yy_current_buffer->yy_input_file = yyin;
+			yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state();
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+			yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++yy_c_buf_p;
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+				yy_cp = yy_c_buf_p;
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer() )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				yy_did_buffer_switch_on_eof = 0;
+
+				if ( yywrap() )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * yytext, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				yy_c_buf_p =
+					yytext_ptr + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				yy_c_buf_p =
+				&yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+				yy_current_state = yy_get_previous_state();
+
+				yy_cp = yy_c_buf_p;
+				yy_bp = yytext_ptr + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+	{
+	register char *dest = yy_current_buffer->yy_ch_buf;
+	register char *source = yytext_ptr;
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( yy_current_buffer->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+	else
+		{
+		int num_to_read =
+			yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+			YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = yy_current_buffer;
+
+			int yy_c_buf_p_offset =
+				(int) (yy_c_buf_p - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				int new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					yy_flex_realloc( (void *) b->yy_ch_buf,
+							 b->yy_buf_size + 2 );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = yy_current_buffer->yy_buf_size -
+						number_to_move - 1;
+#endif
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+			yy_n_chars, num_to_read );
+
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	if ( yy_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			yyrestart( yyin );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			yy_current_buffer->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	yy_n_chars += number_to_move;
+	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+	return ret_val;
+	}
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+	{
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
+
+	yy_current_state = yy_start;
+	yy_state_ptr = yy_state_buf;
+	*yy_state_ptr++ = yy_current_state;
+
+	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+		{
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 188 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		*yy_state_ptr++ = yy_current_state;
+		}
+
+	return yy_current_state;
+	}
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+	{
+	register int yy_is_jam;
+
+	register YY_CHAR yy_c = 1;
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 188 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 187);
+	if ( ! yy_is_jam )
+		*yy_state_ptr++ = yy_current_state;
+
+	return yy_is_jam ? 0 : yy_current_state;
+	}
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+	{
+	register char *yy_cp = yy_c_buf_p;
+
+	/* undo effects of setting up yytext */
+	*yy_cp = yy_hold_char;
+
+	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		register int number_to_move = yy_n_chars + 2;
+		register char *dest = &yy_current_buffer->yy_ch_buf[
+					yy_current_buffer->yy_buf_size + 2];
+		register char *source =
+				&yy_current_buffer->yy_ch_buf[number_to_move];
+
+		while ( source > yy_current_buffer->yy_ch_buf )
+			*--dest = *--source;
+
+		yy_cp += (int) (dest - source);
+		yy_bp += (int) (dest - source);
+		yy_current_buffer->yy_n_chars =
+			yy_n_chars = yy_current_buffer->yy_buf_size;
+
+		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--yy_cp = (char) c;
+
+	if ( c == '\n' )
+		--yylineno;
+
+	yytext_ptr = yy_bp;
+	yy_hold_char = *yy_cp;
+	yy_c_buf_p = yy_cp;
+	}
+#endif	/* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+	{
+	int c;
+
+	*yy_c_buf_p = yy_hold_char;
+
+	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+			/* This was really a NUL. */
+			*yy_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			int offset = yy_c_buf_p - yytext_ptr;
+			++yy_c_buf_p;
+
+			switch ( yy_get_next_buffer() )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					yyrestart( yyin );
+
+					/* fall through */
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( yywrap() )
+						return EOF;
+
+					if ( ! yy_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return yyinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					yy_c_buf_p = yytext_ptr + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */
+	*yy_c_buf_p = '\0';	/* preserve yytext */
+	yy_hold_char = *++yy_c_buf_p;
+
+	if ( c == '\n' )
+		++yylineno;
+
+	return c;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+	{
+	if ( ! yy_current_buffer )
+		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+	yy_init_buffer( yy_current_buffer, input_file );
+	yy_load_buffer_state();
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+	{
+	if ( yy_current_buffer == new_buffer )
+		return;
+
+	if ( yy_current_buffer )
+		{
+		/* Flush out information for old buffer. */
+		*yy_c_buf_p = yy_hold_char;
+		yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+		yy_current_buffer->yy_n_chars = yy_n_chars;
+		}
+
+	yy_current_buffer = new_buffer;
+	yy_load_buffer_state();
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (yywrap()) processing, but the only time this flag
+	 * is looked at is after yywrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	yy_did_buffer_switch_on_eof = 1;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+	{
+	yy_n_chars = yy_current_buffer->yy_n_chars;
+	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+	yyin = yy_current_buffer->yy_input_file;
+	yy_hold_char = *yy_c_buf_p;
+	}
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_buf_size = size;
+
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+	b->yy_is_our_buffer = 1;
+
+	yy_init_buffer( b, file );
+
+	return b;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+	{
+	if ( ! b )
+		return;
+
+	if ( b == yy_current_buffer )
+		yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+	if ( b->yy_is_our_buffer )
+		yy_flex_free( (void *) b->yy_ch_buf );
+
+	yy_flex_free( (void *) b );
+	}
+
+
+#ifndef _WIN32
+#include <unistd.h>
+#else
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+//extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+	{
+	yy_flush_buffer( b );
+
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+	b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+	b->yy_is_interactive = 0;
+#else
+//	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+	}
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+	{
+	if ( ! b )
+		return;
+
+	b->yy_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->yy_buf_pos = &b->yy_ch_buf[0];
+
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == yy_current_buffer )
+		yy_load_buffer_state();
+	}
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	yy_switch_to_buffer( b );
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+	{
+	int len;
+	for ( len = 0; yy_str[len]; ++len )
+		;
+
+	return yy_scan_bytes( yy_str, len );
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+	{
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	int i;
+
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) yy_flex_alloc( n );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = yy_scan_buffer( buf, n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+	{
+	if ( yy_start_stack_ptr >= yy_start_stack_depth )
+		{
+		yy_size_t new_size;
+
+		yy_start_stack_depth += YY_START_STACK_INCR;
+		new_size = yy_start_stack_depth * sizeof( int );
+
+		if ( ! yy_start_stack )
+			yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+		else
+			yy_start_stack = (int *) yy_flex_realloc(
+					(void *) yy_start_stack, new_size );
+
+		if ( ! yy_start_stack )
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
+		}
+
+	yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+	BEGIN(new_state);
+	}
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+	{
+	if ( --yy_start_stack_ptr < 0 )
+		YY_FATAL_ERROR( "start-condition stack underflow" );
+
+	BEGIN(yy_start_stack[yy_start_stack_ptr]);
+	}
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+	{
+	return yy_start_stack[yy_start_stack_ptr - 1];
+	}
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+	{
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+	}
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up yytext. */ \
+		yytext[yyleng] = yy_hold_char; \
+		yy_c_buf_p = yytext + n; \
+		yy_hold_char = *yy_c_buf_p; \
+		*yy_c_buf_p = '\0'; \
+		yyleng = n; \
+		} \
+	while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+	{
+	register int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+	}
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+	{
+	register int n;
+	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+	}
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+	{
+	return (void *) malloc( size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+	{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+	{
+	free( ptr );
+	}
+
+#if YY_MAIN
+int main()
+	{
+	yylex();
+	return 0;
+	}
+#endif
+
diff --git a/src/terralib/kernel/showseq.h b/src/terralib/kernel/showseq.h
new file mode 100644
index 0000000..04276a8
--- /dev/null
+++ b/src/terralib/kernel/showseq.h
@@ -0,0 +1,23 @@
+// Template zur Anzeige von Sequenzen
+// Template for the display of sequences (file include/showseq)
+#ifndef SHOWSEQ_H
+#define SHOWSEQ_H
+
+#include<iostream>
+
+namespace br_stl {
+
+template<class Container>
+void showSequence(const Container& s, const char* sep = " ",
+                  std::ostream& where = std::cout) {
+   typename Container::const_iterator iter = s.begin();
+   while(iter != s.end())
+      where << *iter++ << sep;
+   where << std::endl;
+}
+
+
+} // namespace br_stl
+
+#endif
+
diff --git a/src/terralib/kernel/yyTemporal.cpp b/src/terralib/kernel/yyTemporal.cpp
new file mode 100644
index 0000000..01aaa45
--- /dev/null
+++ b/src/terralib/kernel/yyTemporal.cpp
@@ -0,0 +1,495 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifdef WIN32
+#pragma warning ( disable: 4786 )
+#endif
+
+#ifndef lint
+static char const 
+yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
+#endif
+#include <stdlib.h>
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYLEX yylex()
+#define YYEMPTY -1
+#define yyclearin (yychar=(YYEMPTY))
+#define yyerrok (yyerrflag=0)
+#define YYRECOVERING() (yyerrflag!=0)
+static int yygrowstack();
+#define YYPREFIX "yy"
+#include <stdio.h>
+#include <iostream>
+#include <string.h>
+#include <TeDatabase.h>
+
+extern int yylex();
+extern void initLexOut();
+
+extern char lexOut[1000];
+extern char sqlOutLex[1000];
+
+char sqlOut[1000];
+char tempSql[1000];
+string aux;
+
+const char*	myinputptr;
+string  myinputptr_aux;
+long myinputlim;	
+
+TeDatabase* database_;
+
+int initParse(const string& strIn, TeDatabase* db)
+{	
+	for(int i=0; i<1000; ++i)
+	{
+		sqlOut[i] = '\0';
+		tempSql[i]= '\0';
+	}
+
+	//myinputptr = new char();
+	//memcpy(myinputptr, strIn.c_str(), strIn.size ());
+	myinputptr_aux = strIn;
+	myinputptr = myinputptr_aux.c_str();
+	
+	myinputlim = (long)myinputptr + strIn.size ();	
+	database_ = db;
+	return 1;
+}
+
+void yyerror(char* msg)
+{	
+	if(strcmp(msg,"syntax error"))
+		printf(" Syntax Error : %s\n", msg);
+}
+
+#define YYERRCODE 256
+#define TEMPORALRELATION 257
+#define CHRONON 258
+#define NAME 259
+#define NUMBER 260
+#define MASK 261
+#define OR 262
+#define AND 263
+#define NOT 264
+const short yylhs[] = {                                        -1,
+    0,    0,    0,    0,    0,
+};
+const short yylen[] = {                                         2,
+   15,    2,    3,    3,    3,
+};
+const short yydefred[] = {                                      0,
+    0,    0,    0,    0,    0,    2,    0,    0,    0,    0,
+    3,    0,    4,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    1,
+};
+const short yydgoto[] = {                                       4,
+};
+const short yysindex[] = {                                    -40,
+  -52,  -40,  -40, -260, -251,    0,  -37,  -40,  -40,  -50,
+    0, -253,    0, -246,  -45, -242,  -43, -243,  -41, -241,
+  -39, -240,  -36, -236,    0,
+};
+const short yyrindex[] = {                                      0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    1,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,
+};
+const short yygindex[] = {                                      3,
+};
+#define YYTABLESIZE 263
+const short yytable[] = {                                       3,
+    5,    8,    9,   11,    6,    7,    5,   10,   14,    9,
+   12,   13,   15,   16,   17,   18,   19,   20,   21,   22,
+   23,   25,   24,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    5,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    1,    0,
+    0,    0,    0,    2,    8,    9,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    5,
+};
+const short yycheck[] = {                                      40,
+    0,  262,  263,   41,    2,    3,   59,  259,   59,  263,
+    8,    9,  259,   59,  257,   59,  260,   59,  260,   59,
+  261,  258,   59,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   41,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  259,   -1,
+   -1,   -1,   -1,  264,  262,  263,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,  262,
+};
+#define YYFINAL 4
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 264
+#if YYDEBUG
+const char * const yyname[] = {
+"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"TEMPORALRELATION",
+"CHRONON","NAME","NUMBER","MASK","OR","AND","NOT",
+};
+const char * const yyrule[] = {
+"$accept : exp",
+"exp : NAME ';' NAME ';' NAME ';' TEMPORALRELATION ';' NUMBER ';' NUMBER ';' MASK ';' CHRONON",
+"exp : NOT exp",
+"exp : '(' exp ')'",
+"exp : exp AND exp",
+"exp : exp OR exp",
+};
+#endif
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+#if YYDEBUG
+#include <stdio.h>
+#endif
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+#define YYINITSTACKSIZE 200
+int yydebug;
+int yynerrs;
+int yyerrflag;
+int yychar;
+short *yyssp;
+YYSTYPE *yyvsp;
+YYSTYPE yyval;
+YYSTYPE yylval;
+short *yyss;
+short *yysslim;
+YYSTYPE *yyvs;
+int yystacksize;
+
+
+/* allocate initial stack or double stack size, up to YYMAXDEPTH */
+static int yygrowstack()
+{
+    int newsize, i;
+    short *newss;
+    YYSTYPE *newvs;
+
+    if ((newsize = yystacksize) == 0)
+        newsize = YYINITSTACKSIZE;
+    else if (newsize >= YYMAXDEPTH)
+        return -1;
+    else if ((newsize *= 2) > YYMAXDEPTH)
+        newsize = YYMAXDEPTH;
+    i = yyssp - yyss;
+    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
+      (short *)malloc(newsize * sizeof *newss);
+    if (newss == NULL)
+        return -1;
+    yyss = newss;
+    yyssp = newss + i;
+    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
+      (YYSTYPE *)malloc(newsize * sizeof *newvs);
+    if (newvs == NULL)
+        return -1;
+    yyvs = newvs;
+    yyvsp = newvs + i;
+    yystacksize = newsize;
+    yysslim = yyss + newsize - 1;
+    return 0;
+}
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+
+#ifndef YYPARSE_PARAM
+#if defined(__cplusplus) || __STDC__
+#define YYPARSE_PARAM_ARG void
+#define YYPARSE_PARAM_DECL
+#else	/* ! ANSI-C/C++ */
+#define YYPARSE_PARAM_ARG
+#define YYPARSE_PARAM_DECL
+#endif	/* ANSI-C/C++ */
+#else	/* YYPARSE_PARAM */
+#ifndef YYPARSE_PARAM_TYPE
+#define YYPARSE_PARAM_TYPE void *
+#endif
+#if defined(__cplusplus) || __STDC__
+#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL
+#else	/* ! ANSI-C/C++ */
+#define YYPARSE_PARAM_ARG YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
+#endif	/* ANSI-C/C++ */
+#endif	/* ! YYPARSE_PARAM */
+
+int
+yyparse (string& sql/*, YYPARSE_PARAM_ARG*/)
+    YYPARSE_PARAM_DECL
+{
+    register int yym, yyn, yystate;
+	string aux = "";
+#if YYDEBUG
+    register const char *yys;
+
+    if ((yys = getenv("YYDEBUG")))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = (-1);
+
+    if (yyss == NULL && yygrowstack()) goto yyoverflow;
+    yyssp = yyss;
+    yyvsp = yyvs;
+    *yyssp = yystate = 0;
+
+yyloop:
+    if ((yyn = yydefred[yystate])) goto yyreduce;
+    if (yychar < 0)
+    {
+        if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, reading %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: state %d, shifting to state %d\n",
+                    YYPREFIX, yystate, yytable[yyn]);
+#endif
+        if (yyssp >= yysslim && yygrowstack())
+        {
+            goto yyoverflow;
+        }
+        *++yyssp = yystate = yytable[yyn];
+        *++yyvsp = yylval;
+        yychar = (-1);
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#if defined(lint) || defined(__GNUC__)
+	yyerror("syntax error");
+   ++yynerrs;
+#endif
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
+#endif
+                if (yyssp >= yysslim && yygrowstack())
+                {
+                    goto yyoverflow;
+                }
+                *++yyssp = yystate = yytable[yyn];
+                *++yyvsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: error recovery discarding state %d\n",
+                            YYPREFIX, *yyssp);
+#endif
+                if (yyssp <= yyss) goto yyabort;
+                --yyssp;
+                --yyvsp;
+            }
+        }
+    }
+    else
+    {
+        if (yychar == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+                    YYPREFIX, yystate, yychar, yys);
+        }
+#endif
+        yychar = (-1);
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+                YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 1:
+{	 
+				strncat(sqlOut, sqlOutLex, strlen(sqlOutLex));
+				aux = database_->getSQLTemporalWhere (string(lexOut)); 
+				memcpy(tempSql, aux.c_str(), aux.size());
+				strncat(sqlOut, tempSql, strlen(tempSql));
+				initLexOut(); 
+			}
+break;
+    }
+    yyssp -= yym;
+    yystate = *yyssp;
+    yyvsp -= yym;
+    yym = yylhs[yyn];
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yyssp = YYFINAL;
+        *++yyvsp = yyval;
+        if (yychar < 0)
+        {
+            if ((yychar = yylex()) < 0) yychar = 0;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
+                if (!yys) yys = "illegal-symbol";
+                printf("%sdebug: state %d, reading %d (%s)\n",
+                        YYPREFIX, YYFINAL, yychar, yys);
+            }
+#endif
+        }
+        if (yychar == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yyssp, yystate);
+#endif
+    if (yyssp >= yysslim && yygrowstack())
+    {
+        goto yyoverflow;
+    }
+    *++yyssp = yystate;
+    *++yyvsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    return (1);
+yyaccept:
+    {
+		sql = string(sqlOut);
+		//delete(myinputptr); cai!!!!
+		return (0);
+	}
+}
diff --git a/src/terralib/kernel/yyTemporal.h b/src/terralib/kernel/yyTemporal.h
new file mode 100644
index 0000000..0ddc760
--- /dev/null
+++ b/src/terralib/kernel/yyTemporal.h
@@ -0,0 +1,35 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+
+#ifndef YYERRCODE
+#define YYERRCODE 256
+#endif
+
+#define TEMPORALRELATION 257
+#define CHRONON 258
+#define NAME 259
+#define NUMBER 260
+#define MASK 261
+#define OR 262
+#define AND 263
+#define NOT 264
diff --git a/src/terralib/utils/TeDatabaseUtils.h b/src/terralib/utils/TeDatabaseUtils.h
new file mode 100644
index 0000000..be24446
--- /dev/null
+++ b/src/terralib/utils/TeDatabaseUtils.h
@@ -0,0 +1,167 @@
+/************************************************************************************
+TerraLib - a library for developing GIS applications.
+Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
+
+This code is part of the TerraLib library.
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library.
+
+The authors reassure the license terms regarding the warranties.
+They specifically disclaim any warranties, including, but not limited to,
+the implied warranties of merchantability and fitness for a particular purpose.
+The library provided hereunder is on an "as is" basis, and the authors have no
+obligation to provide maintenance, support, updates, enhancements, or modifications.
+In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
+indirect, special, incidental, or consequential damages arising out of the use
+of this library and its documentation.
+*************************************************************************************/
+/*! \file TeDatabaseUtils.h
+    \brief This file contains some utilitary functions to extended the TerraLib data model for TerraView like applications.
+*/
+#ifndef __TERRALIB_INTERNAL_DATABASEUTILS_H
+#define __TERRALIB_INTERNAL_DATABASEUTILS_H
+
+
+#include <TeDatabase.h>
+#include <TeExternalTheme.h>
+#include <string>
+#include <vector>
+using std::string;
+using std::vector;
+
+
+/** @defgroup DBUtils Utilitary functions
+    @ingroup  DatabaseUtils
+	A set of utilitary functions
+ *  @{
+ */
+/**  This function copies the contents of a TerraLib database to another TerraLib database
+	\param dbFrom A pointer to the source database
+	\param dbTo	  A pointer to the destination database
+*/
+bool TeCopyDatabase(TeDatabase* dbFrom, TeDatabase* dbTo);
+
+
+/** Returns true whether a database contains the TerraLib data model
+	\param db	pointer do a TerraLib database
+*/
+bool isTerralibModel(TeDatabase* db);
+
+vector<string> generateItemsInClauseVec(TeTheme* theme, string& where);
+
+vector<string> getObjects(TeTheme* theme, int sel);
+
+vector<string> getItems(TeTheme* theme, int sel);
+
+vector<string> getObjects(TeTheme* theme, vector<string>& itens);
+
+map<string, vector<string> > getObject2ItemsMap(TeTheme* theme, vector<string>& itens);
+
+vector<string> getItems(TeTheme* theme, vector<string>& objcts);
+
+//! Breaks a collection of strings into a series of IN clauses to be used in query expressions
+/*
+	\params begin Iterator that p oints to the beginning of the collection
+	\params end Iterator that points to the end of the collection
+	\param db pointer to the database where the query expression will be applied
+	\param addPlicae flat to indicate that the character ' should enclose each string
+*/
+template <typename Iterator>
+vector<string>
+generateInClauses(Iterator& begin, Iterator& end, TeDatabase* db, bool addPlicae=true)
+{
+	int i, chunkSize = 200;
+	string inClause;
+	vector<string> inClauseVector;
+
+	Iterator temp = begin;
+	i = 0;
+	while (temp != end)
+	{
+		if (i%chunkSize == 0)
+		{
+			if (!inClause.empty())
+			{
+				inClause[inClause.size() - 1] = ')';
+				inClauseVector.push_back(inClause);
+				inClause.clear();
+			}
+			inClause = "(";
+		}
+
+		if (addPlicae)
+			inClause += "'" + db->escapeSequence(*temp) + "',";
+		else
+			inClause += db->escapeSequence(*temp) + ",";
+		i++;
+		++temp;
+	}
+	if (!inClause.empty())
+	{
+		inClause[inClause.size() - 1] = ')';
+		inClauseVector.push_back(inClause);
+	}
+	return inClauseVector;
+}
+
+template <typename Iterator>
+vector<string>
+generateItemsInClauses(Iterator& begin, Iterator& end, TeTheme* theme)
+{
+	vector<string> itenVec;
+	Iterator temp = begin;
+	while (temp != end)
+	{
+		itenVec.push_back(*temp);
+		temp++;
+	}
+
+	map<string, vector<string> > objMap = getObject2ItemsMap(theme, itenVec);
+	map<string, vector<string> >::iterator mit;
+	vector<string>::iterator it;
+
+	int i, chunkSize = 200;
+	string inClause;
+	vector<string> inClauseVector;
+	
+	i = 0;
+	bool chunk = true;
+	for(mit=objMap.begin(); mit!=objMap.end(); ++mit)
+	{
+		if (chunk == true)
+		{
+			chunk = false;
+			if (!inClause.empty())
+			{
+				inClause[inClause.size() - 1] = ')';
+				inClauseVector.push_back(inClause);
+				inClause.clear();
+			}
+			inClause = "(";
+		}
+		for(it=mit->second.begin(); it!=mit->second.end(); ++it)
+		{
+			inClause += *it + ",";
+			i++;
+			if (i%chunkSize == 0)
+				chunk = true;
+		}
+	}
+	if (!inClause.empty())
+	{
+		inClause[inClause.size() - 1] = ')';
+		inClauseVector.push_back(inClause);
+	}
+	return inClauseVector;
+}
+
+
+//@}
+
+#endif
+
diff --git a/src/visualisers/Akima474.cc b/src/visualisers/Akima474.cc
new file mode 100644
index 0000000..f90aa18
--- /dev/null
+++ b/src/visualisers/Akima474.cc
@@ -0,0 +1,1365 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Akima474.cc
+    Implementation of Akima474 class.
+    
+    Magics Team - ECMWF 2004
+   
+    Created: Wed 14-Apr-2004
+    
+*/
+
+#include "Akima474Method.h"
+#include "MagLog.h"
+#include "Timer.h"
+//#include "Filter.h"  //test, remove later
+
+using namespace magics;
+
+
+Akima474::Akima474(const AbstractMatrix& matrix, const Akima474MethodAttributes& attr) :
+    MatrixHandler(matrix),
+    mono_(matrix), 
+//    matrix1_(mono_), 
+//    mono_(matrix1_),
+  
+    attr_(attr)
+{
+      // Compute matrix output sizes
+	double aux = (mono_.regular_column( mono_.columns()-1) - mono_.regular_column(0)) / attr_.resolutionX_;
+       if ( (double)(int(aux)) != aux ) aux += 1.; //next integer number
+       ncols_ = int(aux + 1.);                  //must include the first and the last input coordinates
+
+       aux = (mono_.regular_row( mono_.rows()-1) - mono_.regular_row(0)) / attr_.resolutionY_;
+       if ( (double)(int(aux)) != aux ) aux += 1.; //next integer number
+       nrows_ = int(aux + 1.);                  //must include the first and the last input coordinates
+
+       // Check for missing values
+       missingValues_ = mono_.hasMissingValues() ? true : false;
+
+//Test. If this is ok create a new function setRowAxis
+#if 0
+int ind;
+double val;
+rowsAxis_.reserve(nrows_);
+for (ind = 0; ind < nrows_; ind++)
+{
+	val = ind*attr_.resolutionY_ + mono_.regular_row(0);
+        rowsAxis_.push_back(val);
+}
+columnsAxis_.reserve(ncols_);
+for (ind = 0; ind < ncols_; ind++)
+{
+	val = ind*attr_.resolutionX_ + mono_.regular_column(0);
+        columnsAxis_.push_back(val);
+}
+#endif
+}
+
+
+double Akima474::regular_row(int i) const
+{
+//Remove later. Why this function is called so many times ???
+//static long itest=0;
+//MagLog::debug() << "Akima474 row=" << itest++ << "\n";
+
+	return (i*attr_.resolutionY_ + mono_.regular_row(0));
+//	return rowsAxis_[i];  //this could make it faster
+}
+
+
+double Akima474::row(int i, int) const
+{
+
+
+	return regular_row(i);
+
+}
+
+
+double Akima474::regular_column(int j) const
+{ 
+//Remove later. Why this function is called so many times ???
+//static long jtest=0;
+//MagLog::debug() << "Akima474 column=" << jtest++ << "\n";
+
+	return (j*attr_.resolutionX_ + mono_.regular_column(0));
+//	return columnsAxis_[j];  //this could make it faster
+}
+
+
+double Akima474::column(int, int j) const
+{
+
+
+	return regular_column(j);
+
+}
+
+
+double Akima474::operator()(int  i, int  j) const
+{
+#if 0
+         // Calculate coordinates of (l,c) in the output matrix
+	 double col = (regular_column(j) - mono_.regular_column(0)) / Iresx_;
+	 double lin = (regular_row(i) - mono_.regular_row(0)) / Iresy_;
+
+	 // Compute interpolated value
+	 return InterpolateBicubicAt(lin,col);
+#else
+//MagLog::dev()<< i << " " << j << " " << regular_row(i) << " " << regular_column(j) << endl;
+	return itplbv(regular_column(j),regular_row(i));
+
+#endif
+}
+
+
+double Akima474::itplbv (double col, double lin) const
+{
+
+//     ALGORITHM 474 COLLECTED ALGORITHMS FROM ACM.
+//     ALGORITHM APPEARED IN COMM. ACM, VOL. VV, NO. NN,
+//     P. 000.
+//      SUBROUTINE ITPLBV(LX, LY, X, Y, Z, N, U, V, W)
+// BIVARIATE INTERPOLATION
+// THIS SUBROUTINE INTERPOLATES, FROM VALUES OF THE FUNCTION
+// GIVEN AT INPUT GRID POINTS IN AN X-Y PLANE AND FOR A GIVEN
+// SET OF POINTS IN THE PLANE, THE VALUES OF A SINGLE-VALUED
+// BIVARIATE FUNCTION Z = Z(X,Y).
+// THE METHOD IS BASED ON A PIECE-WISE FUNCTION COMPOSED OF
+// A SET OF BICUBIC POLYNOMIALS IN X AND Y.  EACH POLYNOMIAL
+// IS APPLICABLE TO A RECTANGLE OF THE INPUT GRID IN THE X-Y
+// PLANE.  EACH POLYNOMIAL IS DETERMINED LOCALLY.
+//
+// This routine was adapted to C++ by Fernando Ii, 05/04
+//
+// THE INPUT PARAMETERS ARE:
+// LX  = NUMBER OF INPUT GRID POINTS IN THE X COORDINATE
+//       (MUST BE 2 OR GREATER)
+// LY  = NUMBER OF INPUT GRID POINTS IN THE Y COORDINATE
+//       (MUST BE 2 OR GREATER)
+// X   = ARRAY OF DIMENSION LX STORING THE X COORDINATES
+//       OF INPUT GRID POINTS (IN ASCENDING ORDER)
+// Y   = ARRAY OF DIMENSION LY STORING THE Y COORDINATES
+//       OF INPUT GRID POINTS (IN ASCENDING ORDER)
+// Z   = DOUBLY-DIMENSIONED ARRAY OF DIMENSION (LX,LY)
+//       STORING THE VALUES OF THE FUNCTION (Z VALUES)
+//       AT INPUT GRID POINTS
+// N   = NUMBER OF POINTS AT WHICH INTERPOLATION OF THE
+//       Z VALUE IS DESIRED (MUST BE 1 OR GREATER)
+// U   = ARRAY OF DIMENSION N STORING THE X COORDINATES
+//       OF DESIRED POINTS
+// V   = ARRAY OF DIMENSION N STORING THE Y COORDINATES
+//       OF DESIRED POINTS
+// THE OUTPUT PARAMETER IS
+// W   = ARRAY OF DIMENSION N WHERE THE INTERPOLATED Z
+//       VALUES AT DESIRED POINTS ARE TO BE DISPLAYED
+//       SOME VARIABLES INTERNALLY USED ARE
+// ZA  = DIVIDED DIFFERENCE OF Z WITH RESPECT TO X
+// ZB  = DIVIDED DIFFERENCE OF Z WITH RESPECT TO Y
+// ZAB = SECOND ORDER DIVIDED DIFFERENCE OF Z WITH
+//       RESPECT TO X AND Y
+// ZX  = PARTIAL DERIVATIVE OF Z WITH RESPECT TO X
+// ZY  = PARTIAL DERIVATIVE OF Z WITH RESPECT TO Y
+// ZXY = SECOND ORDER PARTIAL DERIVATIVE OF Z WITH
+//       RESPECT TO X AND Y
+
+// DECLARATION STATEMENTS
+      double a, b, c, d, e;
+      double Z33;
+
+      double ZA[2][5], ZB[5][2], ZAB[3][3], ZX[4][4], ZY[4][4], ZXY[4][4];
+      double &Z3A1=ZA[0][0], &Z3A2=ZA[0][1], &Z3A3=ZA[0][2], &Z3A4=ZA[0][3], &Z3A5=ZA[0][4],
+	       &Z4A1=ZA[1][0], &Z4A2=ZA[1][1], &Z4A3=ZA[1][2], &Z4A4=ZA[1][3], &Z4A5=ZA[1][4];
+      double &Z3B1=ZB[0][0], &Z3B2=ZB[1][0], &Z3B3=ZB[2][0], &Z3B4=ZB[3][0], &Z3B5=ZB[4][0],
+	       &Z4B1=ZB[0][1], &Z4B2=ZB[1][1], &Z4B3=ZB[2][1], &Z4B4=ZB[3][1], &Z4B5=ZB[4][1];
+
+      double &ZA2B2=ZAB[0][0], &ZA3B2=ZAB[0][1], &ZA4B2=ZAB[0][2],
+	       &ZA2B3=ZAB[1][0], &ZA3B3=ZAB[1][1], &ZA4B3=ZAB[1][2],
+	       &ZA2B4=ZAB[2][0], &ZA3B4=ZAB[2][1], &ZA4B4=ZAB[2][2];
+
+      double &ZX33=ZX[1][1], &ZX43=ZX[1][2], &ZX34=ZX[2][1], &ZX44=ZX[2][2];
+      double &ZY33=ZY[1][1], &ZY43=ZY[1][2], &ZY34=ZY[2][1], &ZY44=ZY[2][2];
+      double &ZXY33=ZXY[1][1], &ZXY43=ZXY[1][2], &ZXY34=ZXY[2][1], &ZXY44=ZXY[2][2];
+
+      double &P00=Z33, &P01=ZY33, &P10=ZX33, &P11=ZXY33;
+
+//      double LX0,ZX(1)), (LXM1,ZX(4)), (LXM2,ZX(13)),
+//     * (LXP1,ZX(16)), (LY0,ZY(1)), (LYM1,ZY(4)), (LYM2,ZY(13)),
+//     * (LYP1,ZY(16)), (IX,ZXY(1)), (IY,ZXY(4)), (IXPV,ZXY(13)),
+//     * (IYPV,ZXY(16))
+
+//      int (IMN,JX), (IMX,JY), (JXM2,JX1), (JYM2,JY1)
+//      double (UK,DX), (VK,DY)
+
+//      double (A1,A5,B1,B5,ZX(2),A,Q0),
+      double A1,A5,B1,B5,Q0;
+
+//     * (A2,ZX(5),B,Q1), 
+      double A2=0.,Q1; 
+
+//    (A4,ZX(8),C,Q2)
+      double A4=0.,Q2;
+
+//    (B2,ZY(2),D,Q3),
+      double B2=0.,Q3;
+
+//     * (B4,ZY(14),E),
+      double B4=0.;
+
+//    (X2,ZX(3),A3SQ),
+      double X2=0., A3SQ;
+
+//    (X4,ZX(9)), (X5,ZX(12)),
+      double X4,X5=0.;
+
+//     * (Y2,ZX(14)), (Y4,ZY(3),B3SQ), (Y5,ZX(15),P02),
+      double Y2=0.,Y4,B3SQ,Y5=0.,P02;
+
+//     * (Z23,ZY(5),P03), (Z24,ZY(8),P12), (Z32,ZY(9),P13),
+      double Z23 = 0.,P03 = 0.,Z24 = 0.,P12 = 0.,Z32 = 0.,P13 = 0.;
+
+//     * (Z34,ZY(12),P20), (Z35,ZY(15),P21), (Z42,ZXY(2),P22),
+      double Z34,P20,Z35=0.,P21,Z42=0.,P22;
+
+//     * (Z43,ZXY(5),P23), (Z44,ZXY(3),P30), (Z45,ZXY(8),P31),
+      double Z43,P23,Z44,P30,Z45=0.,P31;
+
+//     * (Z53,ZXY(9),P32), (Z54,ZXY(12),P33), (W2,WY2,W4),
+      double Z53=0.,P32,Z54=0.,P33,W2,WY2,W4;
+
+//     * (W3,WY3,W1,W5), (WX2,ZXY(14)), (WX3,ZXY(15))
+      double W3,WY3,W1,W5,WX2,WX3;
+
+//      DIMENSION X(LX), Y(LY), Z(LX,LY), U(N), V(N), W(N)
+
+      // Auxiliary variables
+      int    IX,IY,JX,JY,JX1,JY1;
+      int    JXM2,JXML,JYM2,JYML;
+      int    LX,LY,LX0,LXM1,LXM2,LXP1,LY0,LYM1,LYM2,LYP1;
+      int    INXI,INYI;
+      double UK,VK,DX,DY,SW;
+      
+      double X3,Y3,A3,B3,ZX3B3,ZX4B3,ZY3A3,ZY4A3;
+      
+      double WK;
+
+      // PRELIMINARY PROCESSING
+      // SETTING OF SOME INPUT PARAMETERS TO LOCAL VARIABLES
+      LX   = mono_.columns();
+      LY   = mono_.rows();
+      LX0  = LX;
+      LXM1 = LX0 - 1;
+      LXM2 = LXM1 - 1;
+      LXP1 = LX0 + 1;
+      LY0  = LY;
+      LYM1 = LY0 - 1;
+      LYM2 = LYM1 - 1;
+      LYP1 = LY0 + 1;
+
+      // ERROR CHECK
+      if (LXM2 < 0 || LYM2 < 0)
+      {
+	      MagLog::debug() << "LX/LY = 1 OR LESS" << endl;
+	      MagLog::debug() << LX << " " << LY << endl;
+	      return mono_.missing();
+      }
+
+      // INITIAL SETTING OF PREVIOUS VALUES OF IX AND IY
+//      IXPV = 0;
+//      IYPV = 0;
+
+      // ROUTINES TO LOCATE THE DESIRED POINT
+
+//???????????????????????????
+// IMPORTANT IMPORTANT IMPORTANT
+      // THE OLD FORTRAN STYLE CODE ROUTINE IS RUNNING IN
+      // PARALLEL WITH THE C++ CODE, TO MAKE SURE THAT THE
+      // C++ CODE IS CORRECT. REMOVE THE FORTRAN STYLE CODE
+      // LATER.
+//???????????????????????????
+
+      // IX/IY POINT TO 2 POSITIONS AHEAD IN THE ARRAY BECAUSE:
+      // 1. FORTRAN STYLE INDEX (START WITH 1, INSTEAD OF 0)
+      //    THIS IS COMPENSATE LATER IN THE CODE.
+      // 2. ROUTINE 'lowerColumn' AND 'lowerRow' RETURNS THE
+      //    'LOWER' VALUE INDEX, WHICH MEANS X(IX-1) OR Y(IY-1),
+      //    INSTEAD OF X(IX) OR Y(IY)
+
+      // TO FIND OUT THE IX VALUE FOR WHICH
+      // (U(K).GE.X(IX-1)).AND.(U(K).LT.X(IX))
+
+      UK = col;
+      VK = lin;
+
+      if (UK <= mono_.regular_column(0)) INXI = -1;
+      else                       INXI = mono_.lowerColumn(UK);
+
+      if (VK <= mono_.regular_row(0)) INYI = -1;
+      else                    INYI = mono_.lowerRow(VK);
+
+      if (LXM2 == 0) IX = 2;
+      else if (UK >= mono_.regular_column(LX0-1)) IX = LXP1;
+      else if (UK < mono_.regular_column(0)) IX = 1;
+      else
+      {
+#if 0  //REMOVE LATER
+	      int IMN,IMX;
+	      IMN = 2;
+	      IMX = LX0;
+ll:
+	      IX = (IMN+IMX)/2;
+	      if (UK >= mono_.regular_column(IX-1))
+	       IMN = IX + 1;
+	      else
+               IMX = IX;
+
+	      if (IMX > IMN) goto ll;
+	      IX = IMX;
+	      JX1 = IX;
+#endif
+	      IX = mono_.lowerColumn(UK)+2;
+
+#if 0  //REMOVE LATER
+     if (JX1 != IX){
+       MagLog::dev()<< "SERIOUS ERROR FINDING INDEXES" << endl;
+       return -9999999.;
+     }
+#endif
+//      MagLog::dev()<< UK << " " << VK << "   " << IX << "   " << JX1 << endl;
+
+      }
+      // TO FIND OUT THE IY VALUE FOR WHICH
+      // (V(K).GE.Y(IY-1)).AND.(V(K).LT.Y(IY))
+      if (LYM2 == 0) IY = 2;
+      else if (VK >= mono_.regular_row(LY0-1)) IY = LYP1;
+      else if (VK < mono_.regular_row(0)) IY = 1;
+      else
+      {
+#if 0  //REMOVE LATER
+	      int IMN,IMX;
+	      IMN = 2;
+	      IMX = LY0;
+ll1:
+	      IY = (IMN+IMX)/2;
+	      if (VK >= mono_.regular_row(IY-1))
+	       IMN = IY + 1;
+	      else
+	       IMX = IY;
+
+	      if (IMX > IMN) goto ll1;
+	      IY = IMX;
+	      JY1 = IY;
+#endif
+	      IY = mono_.lowerRow(VK)+2;
+#if 0  //REMOVE LATER
+     if (JY1 != IY){
+       MagLog::dev()<< "SERIOUS ERROR FINDING INDEXES" << endl;
+       return -9999999.;
+     }
+#endif
+//      MagLog::dev()<< UK << " " << VK << "   " << IY << "   " << JY1 << endl;
+      }
+
+      // TO CHECK IF THE DESIRED POINT IS IN THE SAME RECTANGLE
+      // AS THE PREVIOUS POINT.  IF YES, SKIP TO THE COMPUTATION
+      // OF THE POLYNOMIAL
+// maybe this is a good idea to increase performance
+//  160   IF (IX.EQ.IXPV .AND. IY.EQ.IYPV) GO TO 690
+//      IXPV = IX;
+//      IYPV = IY;
+
+      // ROUTINES TO PICK UP NECESSARY X, Y, AND Z VALUES, TO
+      // COMPUTE THE ZA, ZB, AND ZAB VALUES, AND TO ESTIMATE THEM
+      // WHEN NECESSARY
+      JX = IX;
+      if (JX == 1) JX = 2;
+      if (JX == LXP1) JX = LX0;
+      JY = IY;
+      if (JY == 1) JY = 2;
+      if (JY == LYP1) JY = LY0;
+      JXM2 = JX - 2;
+      JXML = JX - LX0;
+      JYM2 = JY - 2;
+      JYML = JY - LY0;
+
+      // CHECK FOR MISSING VALUES
+      if ( missingValues_ ) 
+	      if (this->CheckMissingValues(JX,JY) == 0)
+		      return this->missing();
+
+      // IN THE CORE AREA, I.E., IN THE RECTANGLE THAT CONTAINS
+      // THE DESIRED POINT
+      X3 = mono_.regular_column(JX-2);
+      X4 = mono_.regular_column(JX-1);
+
+      A3 = 1.0/(X4-X3);
+      Y3 = mono_.regular_row(JY-2);
+      Y4 = mono_.regular_row(JY-1);
+      B3 = 1.0/(Y4-Y3);
+      Z33 = mono_(JY-2,JX-2);
+      Z43 = mono_(JY-2,JX-1);
+      Z34 = mono_(JY-1,JX-2);
+      Z44 = mono_(JY-1,JX-1);
+      Z3A3 = (Z43-Z33)*A3;
+      Z4A3 = (Z44-Z34)*A3;
+      Z3B3 = (Z34-Z33)*B3;
+      Z4B3 = (Z44-Z43)*B3;
+      ZA3B3 = (Z4B3-Z3B3)*A3;
+
+      // IN THE X DIRECTION
+      if (LXM2 == 0)
+      {
+	      Z3A2 = Z3A3;
+	      Z4A2 = Z4A3;
+	      Z3A4 = Z3A3 + Z3A3 - Z3A2;
+	      Z4A4 = Z4A3 + Z4A3 - Z4A2;
+	      goto l190;
+      }
+      else if (JXM2 != 0)
+      {
+	      X2 = mono_.regular_column(JX-3);
+	      A2 = 1.0/(X3-X2);
+	      Z23 = mono_(JY-2,JX-3);
+	      Z24 = mono_(JY-1,JX-3);
+	      Z3A2 = (Z33-Z23)*A2;
+	      Z4A2 = (Z34-Z24)*A2;
+	      if (JXML == 0)
+	      {
+		      Z3A4 = Z3A3 + Z3A3 - Z3A2;
+		      Z4A4 = Z4A3 + Z4A3 - Z4A2;
+		      goto l190;
+	      }
+      }
+      X5 = mono_.regular_column(JX);
+      A4 = 1.0/(X5-X4);
+      Z53 = mono_(JY-2,JX);
+      Z54 = mono_(JY-1,JX);
+      Z3A4 = (Z53-Z43)*A4;
+      Z4A4 = (Z54-Z44)*A4;
+      if (JXM2 == 0)
+      {
+	      Z3A2 = Z3A3 + Z3A3 - Z3A4;
+	      Z4A2 = Z4A3 + Z4A3 - Z4A4;
+      }
+
+l190:
+      ZA2B3 = (Z4A2-Z3A2)*B3;
+      ZA4B3 = (Z4A4-Z3A4)*B3;
+      if (JX <= 3)
+      {
+	      Z3A1 = Z3A2 + Z3A2 - Z3A3;
+	      Z4A1 = Z4A2 + Z4A2 - Z4A3;
+      }
+      else
+      {
+	      A1 = 1.0/(X2-mono_.regular_column(JX-4));
+	      Z3A1 = (Z23-mono_(JY-2,JX-4))*A1;
+	      Z4A1 = (Z24-mono_(JY-1,JX-4))*A1;
+      }
+ 
+      if (JX >= LXM1)
+      {
+	      Z3A5 = Z3A4 + Z3A4 - Z3A3;
+	      Z4A5 = Z4A4 + Z4A4 - Z4A3;
+      }
+      else
+      {
+	      A5 = 1.0/(mono_.regular_column(JX+1)-X5);
+	      Z3A5 = (mono_(JY-2,JX+1)-Z53)*A5;
+	      Z4A5 = (mono_(JY-1,JX+1)-Z54)*A5;
+      }
+
+      // IN THE Y DIRECTION
+      if (LYM2 == 0)
+      {
+	      Z3B2 = Z3B3;
+	      Z4B2 = Z4B3;
+	      Z3B4 = Z3B3 + Z3B3 - Z3B2;
+	      Z4B4 = Z4B3 + Z4B3 - Z4B2;
+	      goto l270;
+      }
+      else if (JYM2 != 0)
+      {
+	      Y2 = mono_.regular_row(JY-3);
+	      B2 = 1.0/(Y3-Y2);
+	      Z32 = mono_(JY-3,JX-2);
+	      Z42 = mono_(JY-3,JX-1);
+	      Z3B2 = (Z33-Z32)*B2;
+	      Z4B2 = (Z43-Z42)*B2;
+	      if (JYML == 0)
+	      {
+		      Z3B4 = Z3B3 + Z3B3 - Z3B2;
+		      Z4B4 = Z4B3 + Z4B3 - Z4B2;
+		      goto l270;
+	      }
+       }
+       Y5 = mono_.regular_row(JY);
+       B4 = 1.0/(Y5-Y4);
+       Z35 = mono_(JY,JX-2);
+       Z45 = mono_(JY,JX-1);
+       Z3B4 = (Z35-Z34)*B4;
+       Z4B4 = (Z45-Z44)*B4;
+       if (JYM2 == 0)
+       {
+	       Z3B2 = Z3B3 + Z3B3 - Z3B4;
+	       Z4B2 = Z4B3 + Z4B3 - Z4B4;
+       }
+
+l270:
+       ZA3B2 = (Z4B2-Z3B2)*A3;
+       ZA3B4 = (Z4B4-Z3B4)*A3;
+       if (JY <= 3)
+       {
+	      Z3B1 = Z3B2 + Z3B2 - Z3B3;
+	      Z4B1 = Z4B2 + Z4B2 - Z4B3;
+       }
+       else
+       {
+	      B1 = 1.0/(Y2-mono_.regular_row(JY-4));
+	      Z3B1 = (Z32-mono_(JY-4,JX-2))*B1;
+	      Z4B1 = (Z42-mono_(JY-4,JX-1))*B1;
+       }
+
+       if (JY >= LYM1)
+       {
+	      Z3B5 = Z3B4 + Z3B4 - Z3B3;
+	      Z4B5 = Z4B4 + Z4B4 - Z4B3;
+       }
+       else
+       {
+	      B5 = 1.0/(mono_.regular_row(JY+1)-Y5);
+	      Z3B5 = (mono_(JY+1,JX-2)-Z35)*B5;
+	      Z4B5 = (mono_(JY+1,JX-1)-Z45)*B5;
+       }
+ 
+       // IN THE DIAGONAL DIRECTIONS
+       if (LXM2 == 0)
+       {
+	       ZA2B2 = ZA3B2;
+	       ZA4B2 = ZA3B2;
+	       ZA2B4 = ZA3B4;
+	       ZA4B4 = ZA3B4;
+       }
+       else if (LYM2 == 0)
+       {
+	       ZA2B2 = ZA2B3;
+	       ZA2B4 = ZA2B3;
+	       ZA4B2 = ZA4B3;
+	       ZA4B4 = ZA4B3;
+       }
+       else if (JXML == 0)
+       {
+	       if (JYM2 == 0)
+	       {
+		       ZA2B4 = (Z3B4-(mono_(JY,JX-3)-Z24)*B4)*A2;
+	               ZA2B2 = ZA2B3 + ZA2B3 - ZA2B4;
+	       }
+	       else
+	       {
+		       ZA2B2 = (Z3B2-(Z23-mono_(JY-3,JX-3))*B2)*A2;
+	               if (JYML == 0)
+			       ZA2B4 = ZA2B3 + ZA2B3 - ZA2B2;
+		       else
+			       ZA2B4 = (Z3B4-(mono_(JY,JX-3)-Z24)*B4)*A2;
+	       }
+	       ZA4B2 = ZA3B2 + ZA3B2 - ZA2B2;
+	       ZA4B4 = ZA3B4 + ZA3B4 - ZA2B4;
+       }
+       else if (JYM2 == 0)
+       {
+	       ZA4B4 = ((mono_(JY,JX)-Z54)*B4-Z4B4)*A4;
+	       ZA4B2 = ZA4B3 + ZA4B3 - ZA4B4;
+               if (JXM2 == 0)
+	       {
+		       ZA2B2 = ZA3B2 + ZA3B2 - ZA4B2;
+		       ZA2B4 = ZA3B4 + ZA3B4 - ZA4B4;
+	       }
+	       else
+	       {
+		       ZA2B4 = (Z3B4-(mono_(JY,JX-3)-Z24)*B4)*A2;
+		       ZA2B2 = ZA2B3 + ZA2B3 - ZA2B4;
+	       }
+       }
+       else
+       {
+	       ZA4B2 = ((Z53-mono_(JY-3,JX))*B2-Z4B2)*A4;
+	       if (JYML == 0)
+	       {
+		       ZA4B4 = ZA4B3 + ZA4B3 - ZA4B2;
+		       if (JXM2 == 0)
+		       {
+			       ZA2B2 = ZA3B2 + ZA3B2 - ZA4B2;
+			       ZA2B4 = ZA3B4 + ZA3B4 - ZA4B4;
+		       }
+		       else
+		       {
+			       ZA2B2 = (Z3B2-(Z23-mono_(JY-3,JX-3))*B2)*A2;
+			       ZA2B4 = ZA2B3 + ZA2B3 - ZA2B2;
+		       }
+	       }
+	       else
+	       {
+		       ZA4B4 = ((mono_(JY,JX)-Z54)*B4-Z4B4)*A4;
+		       if (JXM2 == 0)
+		       {
+			       ZA2B2 = ZA3B2 + ZA3B2 - ZA4B2;
+			       ZA2B4 = ZA3B4 + ZA3B4 - ZA4B4;
+		       }
+		       else
+		       {
+			       ZA2B2 = (Z3B2-(Z23-mono_(JY-3,JX-3))*B2)*A2;
+			       ZA2B4 = (Z3B4-(mono_(JY,JX-3)-Z24)*B4)*A2;
+		       }
+		}
+       }
+
+       //NUMERICAL DIFFERENTIATION   ---   TO DETERMINE PARTIAL
+       // DERIVATIVES ZX, ZY, AND ZXY AS WEIGHTED MEANS OF DIVIDED
+       // DIFFERENCES ZA, ZB, AND ZAB, RESPECTIVELY
+       for (JY=2; JY <= 3; JY++)
+       {
+          for (JX=2; JX <= 3; JX++)
+	  {
+		  W2 = abs(ZA[JY-2][JX+1]-ZA[JY-2][JX]);
+		  W3 = abs(ZA[JY-2][JX-1]-ZA[JY-2][JX-2]);
+		  SW = W2 + W3;
+                  if (SW == 0.0)
+	          {
+			  WX2 = 0.5;
+			  WX3 = 0.5;
+	          }
+		  else
+		  {
+			  WX2 = W2/SW;
+			  WX3 = W3/SW;
+		  }
+
+		  ZX[JY-1][JX-1] = WX2*ZA[JY-2][JX-1] + WX3*ZA[JY-2][JX];
+		  W2 = abs(ZB[JY+1][JX-2]-ZB[JY][JX-2]);
+		  W3 = abs(ZB[JY-1][JX-2]-ZB[JY-2][JX-2]);
+		  SW = W2 + W3;
+		  if (SW == 0.0)
+		  {
+			  WY2 = 0.5;
+			  WY3 = 0.5;
+		  }
+		  else
+		  {
+			  WY2 = W2/SW;
+			  WY3 = W3/SW;
+		  }
+
+		  ZY[JY-1][JX-1]  = WY2*ZB[JY-1][JX-2] + WY3*ZB[JY][JX-2];
+		  ZXY[JY-1][JX-1] = WY2*(WX2*ZAB[JY-2][JX-2] + WX3*ZAB[JY-2][JX-1]) + WY3*(WX2*ZAB[JY-1][JX-2] + WX3*ZAB[JY-1][JX-1]);
+	  }
+       }
+
+       // WHEN (U(K).LT.X(1)).OR.(U(K).GT.X(LX))
+       if (IX == LXP1 || IX == 1)
+       {
+          if (IX == LXP1)
+          {
+	       W4 = A2*(3.0*A3+A2);
+	       W5 = 2.0*A3*(A3-A2) + W4;
+	       for (JY = 2; JY <= 3; JY++)
+	       {
+		       ZX[JY-1][3] = (W4*ZA[JY-2][3] + W5*ZA[JY-2][4]) / (W4+W5);
+		       ZY[JY-1][3] = ZY[JY-1][2] + ZY[JY-1][2] - ZY[JY-1][1];
+		       ZXY[JY-1][3] = ZXY[JY-1][2] + ZXY[JY-1][2] - ZXY[JY-1][1];
+	               for (JX = 2; JX <= 3; JX++)
+		       {
+			       ZX[JY-1][JX-1]  = ZX[JY-1][JX];
+			       ZY[JY-1][JX-1]  = ZY[JY-1][JX];
+			       ZXY[JY-1][JX-1] = ZXY[JY-1][JX];
+		       }
+		}
+
+	       X3 = X4;
+	       Z33 = Z43;
+	       for (JY = 1; JY <= 5; JY++)
+	             ZB[JY-1][0] = ZB[JY-1][1];
+
+	       A3 = A2;
+	       JX = 3;
+          }
+          else if (IX == 1)
+          {
+	       W2 = A4*(3.0*A3+A4);
+	       W1 = 2.0*A3*(A3-A4) + W2;
+	       for (JY = 2; JY <= 3; JY++)
+	       {
+		       ZX[JY-1][0] = (W1*ZA[JY-2][0] + W2*ZA[JY-2][1]) / (W1+W2);
+		       ZY[JY-1][0] = ZY[JY-1][1] + ZY[JY-1][1] - ZY[JY-1][2];
+		       ZXY[JY-1][0] = ZXY[JY-1][1] + ZXY[JY-1][1] - ZXY[JY-1][2];
+		       for (JX1 = 2; JX1 <= 3; JX1++)
+		       {
+			       JX = 5 - JX1;
+			       ZX[JY-1][JX-1] = ZX[JY-1][JX-2];
+			       ZY[JY-1][JX-1] = ZY[JY-1][JX-2];
+			       ZXY[JY-1][JX-1] = ZXY[JY-1][JX-2];
+		       }
+	        }
+
+		X3 = X3 - 1.0/A4;
+		Z33 = Z33 - Z3A2/A4;
+		for (JY = 1; JY <= 5; JY++)
+			ZB[JY-1][1] = ZB[JY-1][0];
+
+		for (JY = 2; JY <= 4; JY++)
+			ZB[JY-1][0] = ZB[JY-1][0] - ZAB[JY-2][0]/A4;
+
+		A3 = A4;
+		JX = 1;
+          }
+
+          ZA[0][2] = ZA[0][JX];
+          for (JY = 1; JY <= 3; JY++)
+	       ZAB[JY-1][1] = ZAB[JY-1][JX-1];
+       }  
+
+       // WHEN (V(K).LT.Y(1)).OR.(V(K).GT.Y(LY))
+
+       if (IY == LYP1 || IY == 1)
+       {
+          if (IY == LYP1)
+          {
+	       W4 = B2*(3.0*B3+B2);
+	       W5 = 2.0*B3*(B3-B2) + W4;
+	       for (JX = 2; JX <= 3; JX++)
+	       {
+		       if (!( (JX == 3 && IX == LXP1) || (JX == 2 && IX == 1) ))
+		       {
+			       ZY[3][JX-1] = (W4*ZB[3][JX-2] + W5*ZB[4][JX-2]) / (W4+W5);
+			       ZX[3][JX-1] = ZX[2][JX-1] + ZX[2][JX-1] - ZX[1][JX-1];
+			       ZXY[3][JX-1] = ZXY[2][JX-1] + ZXY[2][JX-1] - ZXY[1][JX-1];
+		       }
+
+		       for (JY = 2; JY <= 3; JY++)
+		       {
+			       ZY[JY-1][JX-1] = ZY[JY][JX-1];
+			       ZX[JY-1][JX-1] = ZX[JY][JX-1];
+			       ZXY[JY-1][JX-1] = ZXY[JY][JX-1];
+		       }
+	       }
+
+	       Y3 = Y4;
+	       Z33 = Z33 + Z3B3/B3;
+	       Z3A3 = Z3A3 + ZA3B3/B3;
+	       Z3B3 = Z3B4;
+	       ZA3B3 = ZA3B4;
+	       B3 = B2;
+          }
+          else if (IY == 1)
+          {
+	       W2 = B4*(3.0*B3+B4);
+	       W1 = 2.0*B3*(B3-B4) + W2;
+	       for (JX = 2; JX <= 3; JX++)
+	       {
+		       if ( !( (JX == 3 && IX == LXP1) || (JX == 2 && IX == 1) ) )
+		       {
+			       ZY[0][JX-1] = (W1*ZB[0][JX-2] + W2*ZB[1][JX-2]) / (W1+W2);
+			       ZX[0][JX-1] = ZX[1][JX-1] + ZX[1][JX-1] - ZX[2][JX-1];
+			       ZXY[0][JX-1] = ZXY[1][JX-1] + ZXY[1][JX-1] - ZXY[2][JX-1];
+		       }
+
+		       for (JY1 = 2; JY1 <= 3; JY1++)
+		       {
+			       JY = 5 - JY1;
+			       ZY[JY-1][JX-1] = ZY[JY-2][JX-1];
+			       ZX[JY-1][JX-1] = ZX[JY-2][JX-1];
+			       ZXY[JY-1][JX-1] = ZXY[JY-2][JX-1];
+		       }
+	        }
+
+	       Y3 = Y3 - 1.0/B4;
+	       Z33 = Z33 - Z3B2/B4;
+	       Z3A3 = Z3A3 - ZA3B2/B4;
+	       Z3B3 = Z3B2;
+	       ZA3B3 = ZA3B2;
+	       B3 = B4;
+          }
+
+         if (IX == 1 || IX == LXP1)
+         {
+		 JX = IX/LXP1 + 2;
+		 JX1 = 5 - JX;
+		 JY = IY/LYP1 + 2;
+		 JY1 = 5 - JY;
+		 ZX[JY-1][JX-1]  = ZX[JY-1][JX1-1] + ZX[JY1-1][JX-1] - ZX[JY1-1][JX1-1];
+		 ZY[JY-1][JX-1]  = ZY[JY-1][JX1-1] + ZY[JY1-1][JX-1] - ZY[JY1-1][JX1-1];
+		 ZXY[JY-1][JX-1] = ZXY[JY-1][JX1-1] + ZXY[JY1-1][JX-1] - ZXY[JY1-1][JX1-1];
+	  }
+       }
+
+       // DETERMINATION OF THE COEFFICIENTS OF THE POLYNOMIAL
+
+       ZX3B3 = (ZX34-ZX33)*B3;
+       ZX4B3 = (ZX44-ZX43)*B3;
+       ZY3A3 = (ZY43-ZY33)*A3;
+       ZY4A3 = (ZY44-ZY34)*A3;
+       a = ZA3B3 - ZX3B3 - ZY3A3 + ZXY33;
+       b = ZX4B3 - ZX3B3 - ZXY43 + ZXY33;
+       c = ZY4A3 - ZY3A3 - ZXY34 + ZXY33;
+       d = ZXY44 - ZXY43 - ZXY34 + ZXY33;
+       e = a + a - b - c;
+       A3SQ = A3*A3;
+       B3SQ = B3*B3;
+       P02 = (2.0*(Z3B3-ZY33)+Z3B3-ZY34)*B3;
+       P03 = (-2.0*Z3B3+ZY34+ZY33)*B3SQ;
+       P12 = (2.0*(ZX3B3-ZXY33)+ZX3B3-ZXY34)*B3;
+       P13 = (-2.0*ZX3B3+ZXY34+ZXY33)*B3SQ;
+       P20 = (2.0*(Z3A3-ZX33)+Z3A3-ZX43)*A3;
+       P21 = (2.0*(ZY3A3-ZXY33)+ZY3A3-ZXY43)*A3;
+       P22 = (3.0*(a+e)+d)*A3*B3;
+       P23 = (-3.0*e-b-d)*A3*B3SQ;
+       P30 = (-2.0*Z3A3+ZX43+ZX33)*A3SQ;
+       P31 = (-2.0*ZY3A3+ZXY43+ZXY33)*A3SQ;
+       P32 = (-3.0*e-c-d)*B3*A3SQ;
+       P33 = (d+e+e)*A3SQ*B3SQ;
+
+       // COMPUTATION OF THE POLYNOMIAL
+       DY = VK - Y3;
+       Q0 = P00 + DY*(P01+DY*(P02+DY*P03));
+       Q1 = P10 + DY*(P11+DY*(P12+DY*P13));
+       Q2 = P20 + DY*(P21+DY*(P22+DY*P23));
+       Q3 = P30 + DY*(P31+DY*(P32+DY*P33));
+       DX = UK - X3;
+       WK = Q0 + DX*(Q1+DX*(Q2+DX*Q3));
+
+       return WK;
+}
+
+
+// The following points are searched:
+//
+//  -    -    X    X     -    -
+//  -    X    X    X     X    -
+//  X    X    X    X     X    X
+//  X    X    X    X    col   X
+//  -    X    X   lin    X    -
+//  -    -    X    X     -    -
+//
+
+int Akima474::CheckMissingValues (int col, int lin) const
+{
+      const int NIND = 24;
+      int i,ix,iy;
+
+      int ind[NIND][2] = {              {-4,-2},{-4,-1},
+			        {-3,-3},{-3,-2},{-3,-1},{-3,0},
+			{-2,-4},{-2,-3},{-2,-2},{-2,-1},{-2,0},{-2,1},
+			{-1,-4},{-1,-3},{-1,-2},{-1,-1},{-1,0},{-1,1},
+			        { 0,-3},{ 0,-2},{ 0,-1},{ 0,0},
+			                { 1,-2},{ 1,-1}
+                        };
+
+      for (i = 0; i < NIND; i++)
+      {
+	      ix = col + ind[i][1];
+	      iy = lin + ind[i][0];
+MagLog::dev()<< ix << " " << iy << " " << mono_.columns() << " " << mono_.rows() << endl;
+	      if ( iy < 0 || iy >= mono_.rows() ||
+		   ix < 0 || ix >= mono_.columns() )
+		      continue;
+
+	      if ( mono_(iy,ix) == mono_.missing() )
+	      {
+		      MagLog::debug() <<  mono_(iy,ix) << endl;
+		      return 0;
+	      }
+      }
+
+      return 1;
+}
+
+#if 0
+
+double Akima474::InterpolateBicubicAt (double lin, double col) const
+{
+	int i,j;   // auxiliary variables
+
+//remove later
+#if 1
+if ((col < 2.) || (col >= (float)(mono_.columns()-3)) || (lin < 2.) || (lin >= (float)(mono_.rows()-3)))
+{
+    int ll, cc;
+    if (col < 1.)                        cc = 0;
+    else if (col < 2.)                   cc = 1;
+    else if (col >= mono_.columns()-2) cc = mono_.columns()-1;
+    else if (col >= mono_.columns()-3) cc = mono_.columns()-2;
+    else                                 cc = (int)col;
+		
+    if (lin < 1.)                      ll = 0;
+    else if (lin < 2.)                 ll = 1;
+    else if (lin >= mono_.rows()-2)  ll = mono_.rows()-1;
+    else if (lin >= mono_.rows()-3)  ll = mono_.rows()-2;
+    else                               ll = (int)lin;
+
+    return mono_(ll,cc);
+}
+#endif
+
+// put it back later
+#if 0
+	if ( (col < 0.) || (col >= mono_.columns()-1.) || (lin < 0.) || (lin >= mono_.rows()-1.) )
+	{
+		double ll, cc;
+		if (col < 0.)                      cc = 0;
+		else if (col >= mono_.columns()) cc = mono_.columns()-1;
+		else                               cc = col;
+		
+		if (lin < 0.)                      ll = 0;
+		else if (lin >= mono_.rows())    ll = mono_.rows()-1;
+		else                               ll = lin;
+
+		return mono_(ll,cc);
+	}
+#endif
+
+	// Set coordinates
+	int u = (int)col;
+	int v = (int)lin;
+	double dx = col - (double)u;
+//F	dy = (double)v - y;
+	double dy = lin - (double)v;
+
+        // Set the vx and vy values
+//F1
+#if 0 
+	double vx[6], vy[6];
+	for(i=0; i<6; i++)
+	{
+		vx[i] = Iresx_/2. + (double)(u-2+i)*Iresx_;
+//F		vy[i] = (float)(Y2() - ResolutionY()/2. - (float)(v-2+i)*ResolutionY());
+		vy[i] = Iresy_/2. + (double)(v-2+i)*Iresy_;
+	}
+#endif
+        // Define the coefficients of the polinomium q[j]
+	double q[4];
+	double vz[6], vzaux[6];
+
+	dx *= Iresx_;
+	for(j = 0; j < 6; j++)
+	{
+                // Set the z values
+		for(i = 0; i < 6; i++)
+			vz[i] = mono_(v-2+j,u-2+i);
+
+//F1		if ( Def_polynom(vx,vz,q) == false )
+		if ( Def_polynom(Iresx_,vz,q) == false )
+		{
+			MagLog::debug() << "Error at Akima474::InterpolateBicubicAt" << "\n";
+			return mono_.missing();
+		}
+
+                // Calculate intermediate z values vzaux
+		if (q[0] >= mono_.missing())
+			vzaux[j] = mono_.missing();
+		else
+			vzaux[j] = q[0] + q[1]*dx + q[2]*dx*dx + q[3]*dx*dx*dx;
+			
+	}
+
+	// Interpolate at opposite direction
+//F1	if ( Def_polynom(vy,vzaux,q) == false )
+	if ( Def_polynom(Iresy_,vzaux,q) == false )
+	{
+		 MagLog::debug() << "Error at Akima474::InterpolateBicubicAt" << "\n";
+		 return mono_.missing();
+	}
+	dy *= Iresy_;
+
+	double  zvalue;
+	if ( q[0] >= mono_.missing() )
+		zvalue = InterpolateAt(lin, col);
+	else
+		zvalue = q[0] + q[1]*dy + q[2]*dy*dy + q[3]*dy*dy*dy;
+
+	return zvalue;
+}
+
+
+//F1bool Akima474::Def_polynom(double* x, double* y, double* p) const
+bool Akima474::Def_polynom(double x, double* y, double* p) const
+{
+	short	i;
+	double	m[6],  	// tangent vector
+		auxd1,	// auxiliar variable
+		d2,d3; 	// slope at points 2 e 3
+
+//F1	if( x[3] == x[2] ) return false; // points with the same x value
+
+	// Check the existence of dummy values among the y elements
+	if( y[2] >= mono_.missing() || y[3] >= mono_.missing() )
+	{
+		p[0]=p[1]=p[2]=p[3]=mono_.missing();
+		return true;
+	}
+	else if( y[0] >= mono_.missing() || y[1] >= mono_.missing() || y[4] >= mono_.missing() || y[5] >= mono_.missing() )
+	{
+		p[0] = y[2];
+//F		p[1] = (y[3]-y[2])/(x[3]-x[2]);
+		p[1] = (y[3]-y[2])/x;
+		p[2] = 0.; p[3] = 0.; 
+
+		return true;
+	}
+	
+	// Calculates the slope d2 (in the point 2) and d3 (in the point 3)
+	for (i = 0; i < 5; i++)
+	{
+//F1		if( x[i+1] == x[i] ) m[i] = (double)1.0e30;
+//F1		else                 m[i] = (y[i+1]-y[i]) / (x[i+1]-x[i]);
+		m[i] = (y[i+1]-y[i]) / x;
+	}
+
+	if(((m[0]==m[1])&&(m[2]==m[3])) || ((m[1]==m[2])&&(m[3]==m[4])))
+	{
+		d2 = .5 * (m[1]+m[2]);
+		d3 = .5 * (m[2]+m[3]);
+	}
+	else
+	{
+		d2 = (fabs(m[3]-m[2])*m[1] + fabs(m[1]-m[0])*m[2]) /
+		     (fabs(m[3]-m[2]) + fabs(m[1]-m[0]));
+
+		d3 = (fabs(m[4]-m[3])*m[2] + fabs(m[2]-m[1])*m[3]) /
+		     (fabs(m[4]-m[3]) + fabs(m[2]-m[1]));
+	}
+	
+	//Define the polinomium coefficients	
+//F1	auxd1 = x[3] - x[2];
+	auxd1 = x;
+	p[0]  = y[2];
+	p[1]  = d2;
+	p[2]  = (3.*m[2] - 2.*d2 - d3) / auxd1;
+	p[3]  = (d2 + d3 - 2.*m[2]) / (auxd1*auxd1);
+
+	return true;
+}
+
+// METHOD TO CALCULATE A Z VALUE USING BILINEAR INTERPOLATION
+
+double Akima474::InterpolateAt (double lin, double col) const
+{
+	double	dx, dy, dx1, dy1, p11, p12, p21, p22;
+	int	u, v;
+
+	if (col < 0. || col >= (double)(mono_.columns()-1) || lin < 0. || lin >= (double)(mono_.rows()-1))
+		return mono_.missing();
+
+        // Compute weights
+	u   = (int)col;
+	v   = (int)lin;
+	dx  = col - (double)u;
+	dy  = lin - (double)v;
+	dx1 = 1. - dx;
+	dy1 = 1. - dy;
+
+	// Retrieve points
+	p11 = mono_(v,u);
+	p12 = mono_(v+1,u);
+	p21 = mono_(v,u+1);
+	p22 = mono_(v+1,u+1);
+
+	// Check for dummy values
+	if (p11 >= mono_.missing())
+	{
+		if (p12 >= mono_.missing())
+			return mono_.missing();
+		else
+		{
+			if (p21 >= mono_.missing())
+				return mono_.missing();
+			else
+			{
+				if (p22 >= mono_.missing())
+					return mono_.missing();
+				else
+					p11 = (p12 + p21 + p22) / 3.;
+			}
+		}
+	}
+	else
+	{
+		if (p12 >= mono_.missing())
+		{
+			if (p21 >= mono_.missing())
+				return mono_.missing();
+			else
+			{
+				if (p22 >= mono_.missing())
+					return mono_.missing();
+				else
+					p12 = (p11 + p21 + p22) / 3.;
+			}
+		}
+		else
+		{
+			if (p21 >= mono_.missing())
+			{
+				if (p22 >= mono_.missing())
+					return mono_.missing();
+				else
+					p21 = (p11 + p12 + p22) / 3.;
+			}
+			else
+				if (p22 >= mono_.missing())
+					p22 = (p11 + p12 + p21) / 3.;
+		}
+	}
+
+	// Interpolation
+	p11 = p11*dy1 + p12*dy;
+	p22 = p21*dy1 + p22*dy;
+
+	return(p11 * dx1 + p22 * dx);
+}
+#endif
+
+//TEST, REMOVE LATER
+#if 0
+#define   NXI 19
+#define   NYI 23
+
+void Akima474::test_build_data()
+{
+
+float     XIMN=-0.5;
+float	  XIMX= 8.5;
+float     YIMN=-0.5;
+float 	  YIMX=10.5;
+
+double    XI[NXI],YI[NYI];
+double    ZI[NYI][NXI];      
+
+      float     ANXIM1,ANYIM1,DXI,DYI;
+      int    ISEC,IXD,IXI,IXIMN,IXIMX,IYD,IYI,IYIR,MD,NXD1,NYD1;
+
+      //     ..Local Arrays ..
+      double     DZI[NYI][NXI];
+
+      // Initializations
+
+     double ZIE[NYI][NXI] = { -.847,-.533,
+                      -.274,-.117,-.031,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .401,.250,.119,.043,.011,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,-.665,-.376,-.143,-.033,-.007,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+		      .000,.000,.000,.000,
+		      .000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,2.449,
+                      1.368,.537,.149,.025,.000,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      5.083,3.200,1.642,.700,.187,.000,.000,.000,.000,
+                      .000,.000,.000,.000,.000,.000,.000,.000,.000,
+                      .000,6.588,5.234,3.878,2.542,1.188,.253,.026,
+                      .026,.007,.000,.000,.000,.000,.000,.000,.000,
+                      .000,.000,.000,8.017,7.400,6.400,4.800,2.963,
+                      1.400,.457,.100,.027,.000,.000,.000,.000,.000,
+		      .000,.000,.000,.000,.000,
+		      11.055,
+                      9.670,8.083,6.305,4.786,3.421,2.043,1.112,.565,
+                      .131,-.019,.000,.000,.000,.000,.000,.000,.000,
+                      .000,14.492,12.000,9.746,8.000,6.594,5.300,4.081,
+                      2.900,1.697,.600,.059,.000,.000,.000,.000,.000,
+                      .000,.000,.000,15.999,14.376,12.657,10.774,8.620,
+                      6.659,5.291,4.392,3.926,3.005,1.223,.139,.051,
+                      .025,.009,.000,.000,.000,-.005,15.525,16.800,
+                      16.749,14.400,10.956,8.100,6.735,6.900,7.298,
+                      6.200,3.010,.600,.248,.100,.024,.000,.006,.000,
+                      -.025,15.876,19.280,20.563,17.856,13.242,10.219,
+                      10.577,11.999,10.170,7.053,5.198,3.543,1.831,
+		      .350,-.130,.168,.408,.168,-.224,
+		      17.700,
+                      21.800,23.531,20.500,15.087,12.800,15.817,17.600,
+                      11.477,5.800,6.988,7.600,4.410,.800,-.392,.600,
+                      1.261,.600,-.417,17.913,22.788,24.944,21.881,
+                      16.302,14.382,18.557,20.807,11.916,4.561,7.327,
+                      8.518,5.133,1.284,-.013,1.201,1.998,1.200,-.065,
+                      16.383,22.400,25.330,22.500,16.796,14.600,19.172,
+                      22.500,13.159,4.700,6.689,7.200,4.392,1.800,
+                      1.150,2.100,2.734,2.100,1.025,18.109,26.756,
+                      31.311,28.143,21.004,18.237,24.236,28.979,17.970,
+                      7.469,10.467,11.985,9.022,6.833,6.901,8.292,
+                      9.186,8.524,7.101,24.667,37.200,44.007,40.000,
+                      30.508,27.000,34.974,41.300,27.136,14.100,20.473,
+                      24.500,20.557,17.300,17.639,20.200,21.826,20.800,
+		      18.458,
+		      33.414,
+                      48.009,56.017,51.561,40.817,36.922,45.856,52.860,
+                      37.376,23.200,30.839,36.192,31.969,28.037,28.437,
+                      31.604,33.579,32.332,29.561,44.842,58.200,65.537,
+                      61.500,51.657,47.900,55.899,62.300,47.891,34.600,
+                      41.239,45.500,41.479,38.200,38.591,41.200,42.823,
+                      41.700,39.192,58.284,68.917,74.644,71.333,63.413,
+                      60.125,66.293,71.400,59.129,47.725,52.451,54.592,
+		      50.842,48.483,48.639,50.142,51.089,50.200,48.268 };
+
+	int i,j;
+
+//*     ..
+//* Calculation
+//* Opens the output file and writes the input data.
+//
+      NXD1 = mono_.columns();
+      NYD1 = mono_.rows();
+      printf("\nPRG3P  Original Data  ZD(YD,XD)\n\n       ");
+      for (IXD = 0; IXD < NXD1; IXD++) printf("%7.1f",mono_.regular_column(IXD));
+      for (IYD = NYD1-1; IYD >= 0; IYD--)
+      {
+	      printf("\n%7.1f",mono_.regular_row(IYD));
+	      for (IXD = 0; IXD < NXD1; IXD++) printf("%7.1f",mono_(IYD,IXD));
+      }
+
+//* Program check for the RGBI3P subroutine
+//* - Performs interpolation and calculates the differences.
+      DXI = XIMX - XIMN;
+      ANXIM1 = NXI - 1;
+      printf("\n\nXI %d\n",NXI);
+      for (IXI = 0; IXI < NXI; IXI++)
+      {
+	      XI[IXI] = XIMN + DXI*float(IXI)/ANXIM1;
+	      printf("%5.1f",XI[IXI]);
+      }
+
+      DYI = YIMX - YIMN;
+      ANYIM1 = NYI - 1;
+      printf("\n\nYI %d\n",NYI);
+      for (IYI = 0; IYI < NYI; IYI++)
+      {
+	      YI[IYI] = YIMN + DYI*float(IYI)/ANYIM1;
+	      printf("%5.1f",YI[IYI]);
+      }
+
+      printf("\n\n PROCESSING\n");
+
+      for (IYI = 0; IYI < NYI; IYI++)
+      {
+	      for (IXI = 0; IXI < NXI; IXI++)
+	      {
+		      InterpolateBicubicAt(XI[IXI],YI[IYI],ZI[IYI][IXI]);
+		      DZI[IYI][IXI] = ZI[IYI][IXI] - ZIE[IYI][IXI];
+	      }
+      }
+
+//* - Writes the calculated results.
+      printf("\n\n\nTPRG3P  Program Check for RGBI3P   Calculated ZI Values\n");
+      for (ISEC = 1; ISEC < 3; ISEC++)
+      {
+	      if (ISEC == 1)
+	      {
+		  IXIMN = 0;
+		  IXIMX = 11;
+	      }
+	      else
+	      {
+		  IXIMN = 8;
+		  IXIMX = NXI;
+	      }
+
+	      printf("\n\n                ZI(XI,YI)\n\n     ");
+	      for (IXI = IXIMN; IXI < IXIMX; IXI++)
+		  printf("%7.1f",XI[IXI]);
+
+	      for (IYI = NYI-1; IYI >= 0; IYI--)
+	      {
+		      printf("\n%7.1f",YI[IYI]);
+		      for (IXI = IXIMN; IXI < IXIMX; IXI++)
+			      printf("%7.2f",ZI[IYI][IXI]);
+	      }
+      }
+
+//* - Writes the differences.
+      printf("\n\n\nTPRG3P  Program Check for RGBI3P   Differences\n");
+      for (ISEC = 1; ISEC < 3; ISEC++)
+      {
+	      if (ISEC == 1)
+	      {
+		  IXIMN = 0;
+		  IXIMX = 11;
+	      }
+	      else
+	      {
+		  IXIMN = 8;
+		  IXIMX = NXI;
+	      }
+
+	      printf("\n\n           DZI(YI,XI)\n\n       ");
+	      for (IXI = IXIMN; IXI < IXIMX; IXI++)
+		  printf("%7.1f",XI[IXI]);
+
+	      for (IYI = NYI-1; IYI >= 0; IYI--)
+	      {
+		      printf("\n%7.1f",YI[IYI]);
+		      for (IXI = IXIMN; IXI < IXIMX; IXI++)
+			      printf("%7.2f",DZI[IYI][IXI]);
+	      }
+      }
+
+      printf("\n\nEND TEST\n");
+}
+
+// to test high/low
+
+void Akima474::test_build_data_hl()
+{
+	Matrix matrix3(11, 9);
+#define   NXD 9
+#define   NYD 11
+	double     XD[NXD] = { 0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0 };
+	double     YD[NYD] = { 0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0 };
+	double     ZD[NYD][NXD] = { 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+				    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+				    0.0,0.0,-3.0,0.0,0.0,0.0,0.0,0.0,0.0,
+				    3.2,0.7,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
+				    7.4,4.8,1.4,0.1,0.0,0.0,0.0,0.0,0.0,
+				    12.0,8.0,5.3,2.9,0.6,0.0,0.0,0.0,0.0,
+				    16.8,14.4,8.1,6.9,6.2,0.6,0.1,0.0,0.0,
+				    21.8,20.5,12.8,17.6,5.8,7.6,0.8,0.6,0.6,
+				    22.4,22.5,14.6,22.5,4.7,7.2,1.8,2.1,2.1,
+				    37.2,40.0,27.0,41.3,14.1,24.5,17.3,20.2,20.8,
+				    58.2,61.5,47.9,62.3,34.6,45.5,38.2,41.2,41.7 };
+
+	int IXD,IYD;
+
+            for (int r = 0; r < NYD; r++)
+                for (int c = 0; c < NXD; c++) 
+                    matrix3.push_back(ZD[r][c]);
+
+            for (int r = 0; r < NYD; r++) matrix3.rowsAxis().push_back(YD[r]);
+            for (int c = 0; c < NXD; c++) matrix3.columnsAxis().push_back(XD[c]);
+            matrix3.setMapsAxis();
+
+	   
+	    MatrixHandler mm1(matrix3);
+
+      int dim=5;
+      MinMaxFilter fil(mm1,dim,dim);
+      fil.test_build_data();
+}
+#endif
diff --git a/src/visualisers/Akima474Method.h b/src/visualisers/Akima474Method.h
new file mode 100644
index 0000000..4e454ce
--- /dev/null
+++ b/src/visualisers/Akima474Method.h
@@ -0,0 +1,165 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Akima474Method.h
+    \brief Definition of the Template class Akima474Method.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 14-Apr-2004 
+    
+    Changes:
+    
+*/
+
+#ifndef Akima474Method_H
+#define Akima474Method_H
+
+#include "magics.h"
+
+#include "ContourMethod.h"
+#include "Akima474MethodAttributes.h"
+
+namespace magics {
+
+
+class Akima474 : public MatrixHandler
+{
+public : 
+
+    Akima474(const AbstractMatrix& matrix, const Akima474MethodAttributes&);
+
+    ~Akima474() {}; 
+    
+   
+    double operator()(int  i, int  j) const;
+/*
+    double interpolate(double  i, double  j) const { 
+    	return   mono_.interpolate(i,j); 
+   }  
+*/
+    int  rows() const {
+	    return nrows_;
+   }
+    int  columns() const { 
+	    return ncols_;
+    }
+    
+    double regular_row(int i) const;
+    double regular_column(int j) const;
+    
+    double row(int , int) const;
+    double column(int, int) const;
+
+    double missing() const { 
+    	return mono_.missing(); 
+    }
+
+#if 0 
+     //Code from Spring. Does not work for non-regular spaced
+     //interval. Remove this later.
+
+    // Calculate a Z value using Bicubic interpolation
+    double InterpolateBicubicAt(double lin, double col) const;
+
+    // Calculate a Z value using Bilinear interpolation
+    double InterpolateAt (double lin, double col) const;
+
+    // Calculate the weighting coefficients
+    bool Def_polynom(double x, double* y, double* p) const;
+#endif
+
+    //New code. If it works, remove the old code
+    // Rectangular-grid bivariate interpolation
+    double itplbv(double xi, double yi) const;
+
+    // Check missing values
+    int CheckMissingValues(int col, int lin) const;
+
+//TEST, REMOVE LATER
+//void test_build_data();
+//void test_build_data_hl();
+
+private:
+
+     MonotonicIncreasingMatrixHandler mono_; //Akima needs indexes in the monotonic increasing order
+    // CacheMatrixHandler mono_;
+     Akima474MethodAttributes    attr_;
+     int                   nrows_;         // number of rows
+     int                   ncols_;         // number of columns
+     bool                  missingValues_; // True: data has missing values
+//   magvector<double>   rowsAxis_;
+//   magvector<double>   columnsAxis_;
+
+};
+
+
+
+
+class Akima474Method: public ContourMethod, public Akima474MethodAttributes {
+public:
+	Akima474Method() { MagLog::dev() << "Akima474Method::Akima474Method-->" << *this << "\n"; } 
+	
+	virtual ~Akima474Method() {}
+	
+	ContourMethod* clone() const {
+    	Akima474Method* method = new Akima474Method();
+    	method->copy(*this);
+    	return method;
+    }
+
+    
+    virtual void set(const map<string, string>& map) {
+    	Akima474MethodAttributes::set(map);
+    }
+    
+    virtual void set(const XmlNode& node) {
+    	Akima474MethodAttributes::set(node);
+    }
+    virtual bool accept(const string& node) { return Akima474MethodAttributes::accept(node);; }
+
+    virtual MatrixHandler* handler(const AbstractMatrix& matrix, const BasicGraphicsObjectContainer&) {
+        return new Akima474(matrix,*this);
+	}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { 
+         out << "Akima474Method[";
+         Akima474MethodAttributes::print(out);
+         out << "]";
+	 }  
+
+private:
+    //! Copy constructor - No copy allowed
+	Akima474Method(const Akima474Method&); 
+    //! Overloaded << operator to copy - No copy allowed
+	Akima474Method& operator=(const Akima474Method&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Akima474Method& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+
+#endif
diff --git a/src/visualisers/Akima474MethodAttributes.h b/src/visualisers/Akima474MethodAttributes.h
new file mode 100644
index 0000000..05c706d
--- /dev/null
+++ b/src/visualisers/Akima474MethodAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file Akima474MethodAttributes.h
+    \brief Definition of Akima474Method Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef Akima474MethodAttributes_H
+#define Akima474MethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class Akima474MethodAttributes 
+{
+public:
+//  --  constructor
+    Akima474MethodAttributes();
+    
+//  --  destructor
+    virtual ~Akima474MethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const Akima474MethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double resolutionX_;
+	double resolutionY_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const Akima474MethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Akima760.cc b/src/visualisers/Akima760.cc
new file mode 100644
index 0000000..ecbe8c9
--- /dev/null
+++ b/src/visualisers/Akima760.cc
@@ -0,0 +1,1443 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Akima760.cc
+    Implementation of Akima760 class.
+    
+    Magics Team - ECMWF 2004
+   
+    Created: Fri 12-Mar-2004
+    
+*/
+
+#include "Akima760Method.h"
+#include "MagLog.h"
+#include "Timer.h"
+
+using namespace magics;
+
+
+Akima760::Akima760(const  AbstractMatrix& matrix, const Akima760MethodAttributes& attr) :
+    MatrixHandler(matrix), attr_(attr)
+{
+	MagLog::debug() << "Akima760 Constructor" << "\n";
+
+       int j;
+//     monoColumns_ = MatrixHandler::columns(); //syntax also valid
+       monoColumns_ = this->matrix_.columns();
+       monoRows_ = this->matrix_.rows();
+
+      // Compute matrix output sizes
+       double aux = (this->matrix_.regular_column( monoColumns_-1) - this->matrix_.regular_column(0)) / attr_.resolutionX_;
+       if ( (double)(int(aux)) != aux ) aux += 1.; //next integer number
+       ncols_ = int(aux + 1.);                  //must include the first and the last input coordinates
+
+       aux = (this->matrix_.regular_row( monoRows_-1) - this->matrix_.regular_row(0)) / attr_.resolutionY_;
+       if ( (double)(int(aux)) != aux ) aux += 1.; //next integer number
+       nrows_ = int(aux + 1.);                  //must include the first and the last input coordinates
+
+      // Allocate 3 auxiliary arrays where the estimated zx, zy, and zxy 
+      // values at the input-grid data points are to be stored.
+      WKZX_  = new double* [ monoRows_];
+      WKZY_  = new double* [ monoRows_];
+      WKZXY_ = new double* [ monoRows_];
+      for (j = 0; j <  monoRows_; j++)
+      {
+	      WKZX_[j]  = new double [monoColumns_];
+	      WKZY_[j]  = new double [monoColumns_];
+	      WKZXY_[j] = new double [monoColumns_];
+      }
+
+      // Check for missing values
+      missingValues_ = this->matrix_.hasMissingValues();
+
+      // Estimates partial derivatives at all input-grid data points
+      //{
+      Timer timer("Akima", "Time spent in interpolation");
+      rgpd3p();
+      //}
+      
+      double from = this->matrix_.regular_row(0);
+      for ( int i = 0; i < nrows_; i++) {
+    	  double pos = from + i *attr_.resolutionY_;
+    	  rowsMap_.insert(make_pair(pos, i));
+    	  rows_.push_back(pos);
+      }
+      from = this->matrix_.regular_column(0);
+      for ( int i = 0; i < ncols_; i++) {
+    	  double pos = from + i *attr_.resolutionX_;
+          	 columnsMap_.insert(make_pair(pos, i));
+          	columns_.push_back(pos);
+      }
+         
+          
+#if 0
+      // Print partial derivatives
+      int i;
+      MagLog::debug() << "WKZX" << "\n";;
+      for (i = 0; i < this->matrix_.rows(); i++)
+      {
+	      MagLog::debug() << "\n";;
+	      for (j = 0; j < this->matrix_.columns(); j++)
+		      MagLog::debug() << WKZX_[i][j] << " ";
+       }
+      MagLog::debug() << "\n" << "WKZY" << "\n";;
+      for (i = 0; i < this->matrix_.rows(); i++)
+      {
+	      MagLog::debug() << "\n";;
+	      for (j = 0; j < this->matrix_.columns(); j++)
+	      MagLog::debug() << WKZY_[i][j] << " ";
+       }
+      MagLog::debug() << "\n" << "WKZXY" << "\n";;
+      for (i = 0; i < this->matrix_.rows(); i++)
+      {
+	      MagLog::debug() << "\n";;
+	      for (j = 0; j < this->matrix_.columns(); j++)
+	      MagLog::debug() << WKZXY_[i][j] << " ";
+       }
+#endif
+}
+
+
+Akima760::~Akima760()
+{
+      int j;
+
+      // release memory
+      for (j = 0; j < monoRows_; j++)
+      {
+	      delete [] WKZX_[j];
+	      delete [] WKZY_[j];
+	      delete [] WKZXY_[j];
+	      WKZX_[j]  = NULL;
+	      WKZY_[j]  = NULL;
+	      WKZXY_[j] = NULL;
+      }
+
+      delete [] WKZX_;
+      delete [] WKZY_;
+      delete [] WKZXY_;
+      WKZX_  = NULL;
+      WKZY_  = NULL;
+      WKZXY_ = NULL; 
+}
+
+
+double Akima760::regular_row(int i) const
+{
+//Remove later. Why this function is called so many times ???
+//static long itest=0;
+//MagLog::debug() << "Akima760 row=" << itest++ << "\n";
+
+	// Check if the coordinate does not go beyond the upper limit
+	double aux = i*attr_.resolutionY_ + this->matrix_.regular_row(0);
+        return (aux > this->matrix_.regular_row(monoRows_-1) ? this->matrix_.regular_row(monoRows_-1) : aux);
+}
+
+
+double Akima760::row(int i, int j) const {
+	return this->real_row(regular_row(i), regular_column(j));
+	/*
+	double r = regular_row(i);
+	double c = regular_column(j);
+	
+	
+	int r1 = abs(r);
+	int c1 = abs(c); 
+	int r2 = abs(r);
+	int c2 = abs(c+1);
+	int r3 = abs(r+1);
+	int c3 = abs(c);	
+	int r4 = abs(r+1);
+	int c4 = abs(c+1);
+	
+	double row1 = this->real_row(r1, c1);
+	double row2 = this->real_row(r2, c2);
+	double row3 = this->real_row(r3, c3);
+	double row4 = this->real_row(r4, c4);
+
+	double w1 = (c2-c)/(c2-c1);
+	double w2 = (c-c1)/(c2-c1);
+	double row12 = 	(row1*w1) + (row2*w2);
+	
+	double w3 = (c4-c)/(c4-c3);
+	double w4 = (c-c3)/(c4-c3);
+	
+	double row34 = 	(row3*w3) + (row4*w4);
+	
+	double w5 = (r1-r)/(r3-r1);
+	double w6 = (r-r3)/(r3-r1);
+	
+	double row = (row12*w5) +  (row34*w6);
+
+	return row;
+    	
+    	*/
+    
+}
+
+
+double Akima760::regular_column(int j) const
+{ 
+//Remove later. Why this function is called so many times ???
+//static long jtest=0;
+//MagLog::debug() << "Akima760 column=" << jtest++ << "\n";
+
+	// Check if the coordinate does not go beyond the upper limit
+	double aux = j*attr_.resolutionX_ + this->matrix_.regular_column(0);
+        return (aux > this->matrix_.regular_column(monoColumns_-1) ? this->matrix_.regular_column(monoColumns_-1) : aux);
+}
+
+double Akima760::column(int i, int j) const {
+	
+	return this->real_column(regular_row(i), regular_column(j));
+	/*
+	double row = regular_row(i);
+	double column = regular_column(j);
+	
+	
+	int r1 = abs(row);
+	int c1 = abs(column);
+	int r2 = abs(row);
+	int c2 = abs(column+1);
+	int r3 = abs(row+1);
+	int c3 = abs(column);	
+	int r4 = abs(row+1);
+	int c4 = abs(column+1);
+	
+	double row1 = this->real_column(r1, c1);
+	double row2 = this->real_column(r2, c2);
+	double row3 = this->real_column(r3, c3);
+	double row4 = this->real_column(r4, c4);
+
+	double w1 = (c2-column)/(c2-c1);
+	double w2 = (column-c1)/(c2-c1);
+	double row12 = 	(row1*w1) + (row2*w2);
+	
+	double w3 = (c4-column)/(c4-c3);
+	double w4 = (column-c3)/(c4-c3);
+	
+	double row34 = 	(row3*w3) + (row4*w4);
+	
+	double w5 = (r1-row)/(r3-r1);
+	double w6 = (row-r3)/(r3-r1);
+	
+	row = (row12*w5) + ( row34*w6);
+
+	return row;
+    */	
+}
+
+double Akima760::operator()(int  i, int  j) const
+{
+	double value =  rgbi3p(regular_column(j), regular_row(i));
+	
+	return value;
+}
+
+
+void Akima760::rgpd3p()
+{
+//*
+//* Partial derivatives of a bivariate function on a rectangular grid
+//* (a supporting subroutine of the RGBI3P/RGSF3P subroutine package)
+//*
+//* Hiroshi Akima
+//* U.S. Department of Commerce, NTIA/ITS
+//* Version of 1995/08
+//*
+//* This subroutine estimates three partial derivatives, zx, zy, and
+//* zxy, of a bivariate function, z(x,y), on a rectangular grid in
+//* the x-y plane.  It is based on the revised Akima method that has
+//* the accuracy of a bicubic polynomial.
+//*
+//* The input arguments are
+//*   NXDF = number of the input-grid data points in the x
+//*         coordinate (must be 2 or greater),
+//*   NYDF = number of the input-grid data points in the y
+//*         coordinate (must be 2 or greater),
+//*   XD  = array of dimension NXDF containing the x coordinates
+//*         of the input-grid data points (must be in a
+//*         monotonic increasing order),
+//*   YD  = array of dimension NYDF containing the y coordinates
+//*         of the input-grid data points (must be in a
+//*         monotonic increasing order),
+//*   ZD  = two-dimensional array of dimension NXDF*NYDF
+//*         containing the z(x,y) values at the input-grid data
+//*         points.
+//*
+//* The output argument is
+//*   PDD = three-dimensional array of dimension 3*NXDF*NYDF,
+//*         where the estimated zx, zy, and zxy values at the
+//*         input-grid data points are to be stored.
+//*
+//* This routine was adapted to C++ by Fernando Ii, 02/04
+//*
+
+      double  B00=0., B00X=0., B00Y=0., B01=0., B10=0., B11=0., CX1=0., CX2=0., CX3=0., CY1=0., CY2=0.,
+              CY3=0., DISF =0., DNM =0., DZ00 =0., DZ01 =0., DZ02 = 0.,DZ03 =0., DZ10 =0., DZ11 =0., DZ12 = 0.,
+              DZ13 =0., DZ20 =0., DZ21 =0., DZ22 =0., DZ23 =0., DZ30 = 0.,DZ31 =0., DZ32 = 0.,DZ33 = 0.,
+              DZX10 =0., DZX20 = 0.,DZX30 =0., DZXY11 =0., DZXY12 =0., DZXY13 =0., DZXY21 = 0.,
+              DZXY22 =0., DZXY23 =0., DZXY31 =0., DZXY32 =0., DZXY33 =0., DZY01 =0., DZY02 = 0.,
+              DZY03 =0., EPSLN =0., PEZX =0., PEZXY =0., PEZY = 0.,SMPEF =0., SMPEI =0., SMWTF = 0.,
+              SMWTI = 0.,SX =0., SXX =0., SXXY =0., SXXYY =0., SXY =0., SXYY =0., SXYZ =0., SXZ =0., SY =0., SYY =0., 
+//              SYZ,SZ,VOLF,WT,X0,X1,X2,X3,XX1,XX2,XX3,Y0,Y1,Y2,
+              SYZ =0., SZ =0., VOLF =0., WT = 0.,X0 =0., X1 = 0.,X2 =0., X3 =0., Y0 =0., Y1 =0., Y2 =0., 
+              Y3 =0., Z00 = 0.,Z01 =0., Z02 = 0.,Z03 =0., Z10 =0., Z11 =0., Z12 =0., Z13 = 0.,Z20 =0., Z21 =0., Z22 = 0.,
+//              Z23,Z30,Z31,Z32,Z33,ZXDI,ZXYDI,ZYDI,ZZ0,ZZ1,ZZ2;
+              Z23 =0., Z30 =0., Z31 =0., Z32 =0., Z33 = 0.,ZXDI =0., ZXYDI =0., ZYDI = 0.0;
+
+      int  IPEX,IPEY,IX0,IX1,IX2,IX3,IY0,IY1,IY2,IY3,NX0,NY0;
+
+      int  NXDF,NYDF;       // input matrix dimensions
+
+      //*     .. Local Arrays .
+      double  B00XA[4],B00YA[4],B01A[4],B10A[4],CXA[3][4],
+              CYA[3][4],SXA[4],SXXA[4],SYA[4],SYYA[4],XA[3][4],
+              YA[3][4],Z0IA[3][4],ZI0A[3][4];
+
+      int     IDLT[3][4] = {{-3,-2,-1,1},{-2,-1,1,2},{-1,1,2,3}};
+
+      //* Statement Function definitions 
+#define Z2F(XX1,XX2,ZZ0,ZZ1) ((ZZ1-ZZ0)*XX2/XX1 + ZZ0)
+#define Z3F(XX1,XX2,XX3,ZZ0,ZZ1,ZZ2) (((ZZ2-ZZ0) * (XX3-XX1)/XX2  - (ZZ1-ZZ0) * (XX3-XX2)/XX1) * (XX3/ (XX2-XX1)) + ZZ0)
+
+      //* Initial setting of some local variables
+      NXDF = this->matrix_.columns();
+      NYDF = this->matrix_.rows();
+      NX0 = std::max((int)4,NXDF);
+      NY0 = std::max((int)4,NYDF);
+
+      //* Double DO-loop with respect to the input grid points
+      for (IY0 = 0; IY0 < NYDF; IY0++)
+      {
+	  for (IX0 = 0; IX0 < NXDF; IX0++)
+	  {
+	      // Check for missing values
+	      if ( missingValues_ )
+	      {
+		      if (CheckMissingValues(IX0,IY0) == 0)
+		      {
+			    WKZX_[IY0][IX0]  = missing();
+			    WKZY_[IY0][IX0]  = missing();
+			    WKZXY_[IY0][IX0] = missing();
+			    continue;
+		      }
+	      }
+
+              X0  = this->matrix_.regular_column(IX0);
+              Y0  = this->matrix_.regular_row(IY0);
+              Z00 = this->matrix_(IY0,IX0);
+//            Z00 = this->matrix_.operator()(IY0,IX0);  //also valid
+
+	      //* Part 1.  Estimation of ZXDI
+	      //* Initial setting
+              SMPEF = 0.0;
+              SMWTF = 0.0;
+              SMPEI = 0.0;
+              SMWTI = 0.0;
+
+	      //* DO-loop with respect to the primary estimate
+              for (IPEX = 0; IPEX < 4; IPEX++)
+	      {
+	          //* Selects necessary grid points in the x direction
+                  IX1 = IX0 + IDLT[0][IPEX];
+                  IX2 = IX0 + IDLT[1][IPEX];
+                  IX3 = IX0 + IDLT[2][IPEX];
+                  if ((IX1 < 0) || (IX2 < 0) || (IX3 < 0) ||
+                      (IX1 >= NX0) || (IX2 >= NX0) || (IX3 >= NX0)) continue;
+
+		  //* Selects and/or supplements the x and z values
+                  X1  = this->matrix_.regular_column(IX1) - X0;
+                  Z10 = this->matrix_(IY0,IX1);
+                  if (NXDF >= 4)
+		  {
+                      X2  = this->matrix_.regular_column(IX2) - X0;
+                      X3  = this->matrix_.regular_column(IX3) - X0;
+                      Z20 = this->matrix_(IY0,IX2);
+                      Z30 = this->matrix_(IY0,IX3);
+		  }
+                  else if (NXDF == 3)
+		  {
+                      X2  = this->matrix_.regular_column(IX2) - X0;
+                      Z20 = this->matrix_(IY0,IX2);
+                      X3  = 2*this->matrix_.regular_column(2) - this->matrix_.regular_column(1) - X0;
+                      Z30 = Z3F(X1,X2,X3,Z00,Z10,Z20);
+		  }
+                  else if (NXDF == 2)
+		  {
+                      X2  = 2*this->matrix_.regular_column(1) - this->matrix_.regular_column(0) - X0;
+                      Z20 = Z2F(X1,X2,Z00,Z10);
+                      X3  = 2*this->matrix_.regular_column(0) - this->matrix_.regular_column(1) - X0;
+                      Z30 = Z2F(X1,X3,Z00,Z10);
+		  }
+
+                  DZX10 = (Z10-Z00)/X1;
+                  DZX20 = (Z20-Z00)/X2;
+                  DZX30 = (Z30-Z00)/X3;
+
+		  //* Calculates the primary estimate of partial derivative zx as
+		  //* the coefficient of the bicubic polynomial
+                  CX1 = X2*X3/ ((X1-X2)* (X1-X3));
+                  CX2 = X3*X1/ ((X2-X3)* (X2-X1));
+                  CX3 = X1*X2/ ((X3-X1)* (X3-X2));
+                  PEZX = CX1*DZX10 + CX2*DZX20 + CX3*DZX30;
+
+		  //* Calculates the volatility factor and distance factor in the x
+		  //* direction for the primary estimate of zx
+                  SX   = X1 + X2 + X3;
+                  SZ   = Z00 + Z10 + Z20 + Z30;
+                  SXX  = X1*X1 + X2*X2 + X3*X3;
+                  SXZ  = X1*Z10 + X2*Z20 + X3*Z30;
+                  DNM  = 4.0*SXX - SX*SX;
+                  B00  = (SXX*SZ-SX*SXZ)/DNM;
+                  B10  = (4.0*SXZ-SX*SZ)/DNM;
+                  DZ00 = Z00 - B00;
+                  DZ10 = Z10 - (B00+B10*X1);
+                  DZ20 = Z20 - (B00+B10*X2);
+                  DZ30 = Z30 - (B00+B10*X3);
+                  VOLF = DZ00*DZ00 + DZ10*DZ10 + DZ20*DZ20 + DZ30*DZ30;
+                  DISF = SXX;
+
+		  //* Calculates the EPSLN value, which is used to decide whether or
+		  //* not the volatility factor is essentially zero
+                  EPSLN = (Z00*Z00 + Z10*Z10 + Z20*Z20 + Z30*Z30) * 1.0E-12;
+
+		  //* Accumulates the weighted primary estimates of zx and their weights
+                  if (VOLF > EPSLN)
+		  {
+		      //* - For a finite weight
+                      WT = 1.0/ (VOLF*DISF);
+                      SMPEF = SMPEF + WT*PEZX;
+                      SMWTF = SMWTF + WT;
+		  }
+                  else
+		  {
+		      //* - For an infinite weight
+                      SMPEI = SMPEI + PEZX;
+                      SMWTI = SMWTI + 1.0;
+		  }
+
+		  //* Saves the necessary values for estimating zxy
+                  XA[0][IPEX] = X1;
+                  XA[1][IPEX] = X2;
+                  XA[2][IPEX] = X3;
+                  ZI0A[0][IPEX] = Z10;
+                  ZI0A[1][IPEX] = Z20;
+                  ZI0A[2][IPEX] = Z30;
+                  CXA[0][IPEX] = CX1;
+                  CXA[1][IPEX] = CX2;
+                  CXA[2][IPEX] = CX3;
+                  SXA[IPEX] = SX;
+                  SXXA[IPEX] = SXX;
+                  B00XA[IPEX] = B00;
+                  B10A[IPEX] = B10;
+              } //end for IPX
+
+	      //* Calculates the final estimate of zx
+              if (SMWTI < 0.5) ZXDI = SMPEF/SMWTF;  //When no infinite weights exist
+              else	       ZXDI = SMPEI/SMWTI;  //When infinite weights exist
+
+	      //* End of Part 1
+	      //* Part 2.  Estimation of ZYDI
+	      //* Initial setting
+              SMPEF = 0.0;
+              SMWTF = 0.0;
+              SMPEI = 0.0;
+              SMWTI = 0.0;
+
+	      //* DO-loop with respect to the primary estimate
+              for (IPEY = 0; IPEY < 4; IPEY++)
+	      {
+		  //* Selects necessary grid points in the y direction
+                  IY1 = IY0 + IDLT[0][IPEY];
+                  IY2 = IY0 + IDLT[1][IPEY];
+                  IY3 = IY0 + IDLT[2][IPEY];
+                  if ((IY1 < 0) || (IY2 < 0) || (IY3 < 0) ||
+                      (IY1 >= NY0) || (IY2 >= NY0) || (IY3 >= NY0)) continue;
+
+		  //* Selects and/or supplements the y and z values
+                  Y1  = this->matrix_.regular_row(IY1) - Y0;
+                  Z01 = this->matrix_(IY1,IX0);
+                  if (NYDF >= 4)
+		  {
+                      Y2 = this->matrix_.regular_row(IY2) - Y0;
+                      Y3 = this->matrix_.regular_row(IY3) - Y0;
+                      Z02 = this->matrix_(IY2,IX0);
+                      Z03 = this->matrix_(IY3,IX0);
+		  }
+                  else if (NYDF == 3)
+		  {
+                      Y2 = this->matrix_.regular_row(IY2) - Y0;
+                      Z02 = this->matrix_(IY2,IX0);
+                      Y3 = 2*this->matrix_.regular_row(2) - this->matrix_.regular_row(1) - Y0;
+                      Z03 = Z3F(Y1,Y2,Y3,Z00,Z01,Z02);
+		  }
+                  else if (NYDF == 2)
+		  {
+                      Y2 = 2*this->matrix_.regular_row(1) - this->matrix_.regular_row(0) - Y0;
+                      Z02 = Z2F(Y1,Y2,Z00,Z01);
+                      Y3 = 2*this->matrix_.regular_row(0) - this->matrix_.regular_row(1) - Y0;
+                      Z03 = Z2F(Y1,Y3,Z00,Z01);
+		  }
+
+                  DZY01 = (Z01-Z00)/Y1;
+                  DZY02 = (Z02-Z00)/Y2;
+                  DZY03 = (Z03-Z00)/Y3;
+
+		  //* Calculates the primary estimate of partial derivative zy as
+		  //* the coefficient of the bicubic polynomial
+                  CY1 = Y2*Y3/ ((Y1-Y2)* (Y1-Y3));
+                  CY2 = Y3*Y1/ ((Y2-Y3)* (Y2-Y1));
+                  CY3 = Y1*Y2/ ((Y3-Y1)* (Y3-Y2));
+                  PEZY = CY1*DZY01 + CY2*DZY02 + CY3*DZY03;
+
+		  //* Calculates the volatility factor and distance factor in the y
+		  //* direction for the primary estimate of zy
+                  SY = Y1 + Y2 + Y3;
+                  SZ = Z00 + Z01 + Z02 + Z03;
+                  SYY = Y1*Y1 + Y2*Y2 + Y3*Y3;
+                  SYZ = Y1*Z01 + Y2*Z02 + Y3*Z03;
+                  DNM = 4.0*SYY - SY*SY;
+                  B00 = (SYY*SZ-SY*SYZ)/DNM;
+                  B01 = (4.0*SYZ-SY*SZ)/DNM;
+                  DZ00 = Z00 - B00;
+                  DZ01 = Z01 - (B00+B01*Y1);
+                  DZ02 = Z02 - (B00+B01*Y2);
+                  DZ03 = Z03 - (B00+B01*Y3);
+                  VOLF = DZ00*DZ00 + DZ01*DZ01 + DZ02*DZ02 + DZ03*DZ03;
+                  DISF = SYY;
+
+		  //* Calculates the EPSLN value, which is used to decide whether or
+		  //* not the volatility factor is essentially zero
+                  EPSLN = (Z00*Z00 + Z01*Z01 + Z02*Z02 + Z03*Z03) * 1.0E-12;
+
+		  //* Accumulates the weighted primary estimates of zy and their weights
+                  if (VOLF > EPSLN)
+		  {
+		      //* - For a finite weight
+                      WT = 1.0/ (VOLF*DISF);
+                      SMPEF = SMPEF + WT*PEZY;
+                      SMWTF = SMWTF + WT;
+		  }
+                  else
+		  {
+		      //* - For an infinite weight
+                      SMPEI = SMPEI + PEZY;
+                      SMWTI = SMWTI + 1.0;
+		  }
+
+		  //* Saves the necessary values for estimating zxy
+                  YA[0][IPEY] = Y1;
+                  YA[1][IPEY] = Y2;
+                  YA[2][IPEY] = Y3;
+                  Z0IA[0][IPEY] = Z01;
+                  Z0IA[1][IPEY] = Z02;
+                  Z0IA[2][IPEY] = Z03;
+                  CYA[0][IPEY] = CY1;
+                  CYA[1][IPEY] = CY2;
+                  CYA[2][IPEY] = CY3;
+                  SYA[IPEY] = SY;
+                  SYYA[IPEY] = SYY;
+                  B00YA[IPEY] = B00;
+                  B01A[IPEY] = B01;
+              } //end for IPEY
+
+	      //* Calculates the final estimate of zy
+              if (SMWTI < 0.5)	        //When no infinite weights exist
+                  ZYDI = SMPEF/SMWTF;
+              else                      //When infinite weights exist
+                  ZYDI = SMPEI/SMWTI;
+
+	      //* End of Part 2
+	      //* Part 3.  Estimation of ZXYDI
+	      //* Initial setting
+              SMPEF = 0.0;
+              SMWTF = 0.0;
+              SMPEI = 0.0;
+              SMWTI = 0.0;
+
+	      //* Outer DO-loops with respect to the primary estimates in the x direction
+              for (IPEX = 0; IPEX < 4; IPEX++)
+	      {
+                  IX1 = IX0 + IDLT[0][IPEX];
+                  IX2 = IX0 + IDLT[1][IPEX];
+                  IX3 = IX0 + IDLT[2][IPEX];
+                  if ((IX1 < 0) || (IX2 < 0) || (IX3 < 0) ||
+                      (IX1 >= NX0) || (IX2 >= NX0) || (IX3 >= NX0)) continue;
+
+		  //* Retrieves the necessary values for estimating zxy in the x direction
+                  X1 = XA[0][IPEX];
+                  X2 = XA[1][IPEX];
+                  X3 = XA[2][IPEX];
+                  Z10 = ZI0A[0][IPEX];
+                  Z20 = ZI0A[1][IPEX];
+                  Z30 = ZI0A[2][IPEX];
+                  CX1 = CXA[0][IPEX];
+                  CX2 = CXA[1][IPEX];
+                  CX3 = CXA[2][IPEX];
+                  SX = SXA[IPEX];
+                  SXX = SXXA[IPEX];
+                  B00X = B00XA[IPEX];
+                  B10 = B10A[IPEX];
+
+		  //* Inner DO-loops with respect to the primary estimates in the y direction
+                  for (IPEY = 0; IPEY < 4; IPEY++)
+		  {
+                      IY1 = IY0 + IDLT[0][IPEY];
+                      IY2 = IY0 + IDLT[1][IPEY];
+                      IY3 = IY0 + IDLT[2][IPEY];
+                      if ((IY1 < 0) || (IY2 < 0) || (IY3 < 0) ||
+		          (IY1 >= NY0) || (IY2 >= NY0) || (IY3 >= NY0)) continue;
+
+		      //* Retrieves the necessary values for estimating zxy in the y direction.
+                      Y1 = YA[0][IPEY];
+                      Y2 = YA[1][IPEY];
+                      Y3 = YA[2][IPEY];
+                      Z01 = Z0IA[0][IPEY];
+                      Z02 = Z0IA[1][IPEY];
+                      Z03 = Z0IA[2][IPEY];
+                      CY1 = CYA[0][IPEY];
+                      CY2 = CYA[1][IPEY];
+                      CY3 = CYA[2][IPEY];
+                      SY = SYA[IPEY];
+                      SYY = SYYA[IPEY];
+                      B00Y = B00YA[IPEY];
+                      B01 = B01A[IPEY];
+
+		      //* Selects and/or supplements the z values
+                      if (NYDF >= 4)
+		      {
+                          Z11 = this->matrix_(IY1,IX1);
+                          Z12 = this->matrix_(IY2,IX1);
+                          Z13 = this->matrix_(IY3,IX1);
+                          if (NXDF >= 4)
+			  {
+                              Z21 = this->matrix_(IY1,IX2);
+                              Z22 = this->matrix_(IY2,IX2);
+                              Z23 = this->matrix_(IY3,IX2);
+                              Z31 = this->matrix_(IY1,IX3);
+                              Z32 = this->matrix_(IY2,IX3);
+                              Z33 = this->matrix_(IY3,IX3);
+			  }
+                          else if (NXDF == 3)
+			  {
+                              Z21 = this->matrix_(IY1,IX2);
+                              Z22 = this->matrix_(IY2,IX2);
+                              Z23 = this->matrix_(IY3,IX2);
+                              Z31 = Z3F(X1,X2,X3,Z01,Z11,Z21);
+                              Z32 = Z3F(X1,X2,X3,Z02,Z12,Z22);
+                              Z33 = Z3F(X1,X2,X3,Z03,Z13,Z23);
+			  }
+                          else if (NXDF == 2)
+			  {
+                              Z21 = Z2F(X1,X2,Z01,Z11);
+                              Z22 = Z2F(X1,X2,Z02,Z12);
+                              Z23 = Z2F(X1,X2,Z03,Z13);
+                              Z31 = Z2F(X1,X3,Z01,Z11);
+                              Z32 = Z2F(X1,X3,Z02,Z12);
+                              Z33 = Z2F(X1,X3,Z03,Z13);
+			  }
+		      }
+                      else if (NYDF == 3)
+		      {
+                          Z11 = this->matrix_(IY1,IX1);
+                          Z12 = this->matrix_(IY2,IX1);
+                          Z13 = Z3F(Y1,Y2,Y3,Z10,Z11,Z12);
+                          if (NXDF >= 4)
+			  {
+                              Z21 = this->matrix_(IY1,IX2);
+                              Z22 = this->matrix_(IY2,IX2);
+                              Z31 = this->matrix_(IY1,IX3);
+                              Z32 = this->matrix_(IY2,IX3);
+			  }
+                          else if (NXDF == 3)
+			  {
+                              Z21 = this->matrix_(IY1,IX2);
+                              Z22 = this->matrix_(IY2,IX2);
+                              Z31 = Z3F(X1,X2,X3,Z01,Z11,Z21);
+                              Z32 = Z3F(X1,X2,X3,Z02,Z12,Z22);
+			  }
+                          else if (NXDF == 2)
+			  {
+                              Z21 = Z2F(X1,X2,Z01,Z11);
+                              Z22 = Z2F(X1,X2,Z02,Z12);
+                              Z31 = Z2F(X1,X3,Z01,Z11);
+                              Z32 = Z2F(X1,X3,Z02,Z12);
+                          }
+
+                          Z23 = Z3F(Y1,Y2,Y3,Z20,Z21,Z22);
+                          Z33 = Z3F(Y1,Y2,Y3,Z30,Z31,Z32);
+		      }
+                      else if (NYDF == 2)
+		      {
+                          Z11 = this->matrix_(IY1,IX1);
+                          Z12 = Z2F(Y1,Y2,Z10,Z11);
+                          Z13 = Z2F(Y1,Y3,Z10,Z11);
+                          if (NXDF >= 4)
+			  {
+                              Z21 = this->matrix_(IY1,IX2);
+                              Z31 = this->matrix_(IY1,IX3);
+			  }
+                          else if (NXDF == 3)
+			  {
+                              Z21 = this->matrix_(IY1,IX2);
+                              Z31 = Z3F(X1,X2,X3,Z01,Z11,Z21);
+			  }
+                          else if (NXDF == 2)
+			  {
+                              Z21 = Z2F(X1,X2,Z01,Z11);
+                              Z31 = Z2F(X1,X3,Z01,Z11);
+			  }
+
+                          Z22 = Z2F(Y1,Y2,Z20,Z21);
+                          Z23 = Z2F(Y1,Y3,Z20,Z21);
+                          Z32 = Z2F(Y1,Y2,Z30,Z31);
+                          Z33 = Z2F(Y1,Y3,Z30,Z31);
+                      }
+
+		      //* Calculates the primary estimate of partial derivative zxy as
+		      //* the coefficient of the bicubic polynomial
+                      DZXY11 = (Z11-Z10-Z01+Z00)/ (X1*Y1);
+                      DZXY12 = (Z12-Z10-Z02+Z00)/ (X1*Y2);
+                      DZXY13 = (Z13-Z10-Z03+Z00)/ (X1*Y3);
+                      DZXY21 = (Z21-Z20-Z01+Z00)/ (X2*Y1);
+                      DZXY22 = (Z22-Z20-Z02+Z00)/ (X2*Y2);
+                      DZXY23 = (Z23-Z20-Z03+Z00)/ (X2*Y3);
+                      DZXY31 = (Z31-Z30-Z01+Z00)/ (X3*Y1);
+                      DZXY32 = (Z32-Z30-Z02+Z00)/ (X3*Y2);
+                      DZXY33 = (Z33-Z30-Z03+Z00)/ (X3*Y3);
+                      PEZXY = CX1* (CY1*DZXY11+CY2*DZXY12+CY3*DZXY13) +
+                              CX2* (CY1*DZXY21+CY2*DZXY22+CY3*DZXY23) +
+                              CX3* (CY1*DZXY31+CY2*DZXY32+CY3*DZXY33);
+
+		      //* Calculates the volatility factor and distance factor in the x
+		      //* and y directions for the primary estimate of zxy
+                      B00 = (B00X+B00Y)/2.0;
+                      SXY = SX*SY;
+                      SXXY = SXX*SY;
+                      SXYY = SX*SYY;
+                      SXXYY = SXX*SYY;
+                      SXYZ = X1* (Y1*Z11+Y2*Z12+Y3*Z13) +
+                             X2* (Y1*Z21+Y2*Z22+Y3*Z23) +
+                             X3* (Y1*Z31+Y2*Z32+Y3*Z33);
+                      B11 = (SXYZ-B00*SXY-B10*SXXY-B01*SXYY)/SXXYY;
+                      DZ00 = Z00 - B00;
+                      DZ01 = Z01 - (B00+B01*Y1);
+                      DZ02 = Z02 - (B00+B01*Y2);
+                      DZ03 = Z03 - (B00+B01*Y3);
+                      DZ10 = Z10 - (B00+B10*X1);
+                      DZ11 = Z11 - (B00+B01*Y1+X1* (B10+B11*Y1));
+                      DZ12 = Z12 - (B00+B01*Y2+X1* (B10+B11*Y2));
+                      DZ13 = Z13 - (B00+B01*Y3+X1* (B10+B11*Y3));
+                      DZ20 = Z20 - (B00+B10*X2);
+                      DZ21 = Z21 - (B00+B01*Y1+X2* (B10+B11*Y1));
+                      DZ22 = Z22 - (B00+B01*Y2+X2* (B10+B11*Y2));
+                      DZ23 = Z23 - (B00+B01*Y3+X2* (B10+B11*Y3));
+                      DZ30 = Z30 - (B00+B10*X3);
+                      DZ31 = Z31 - (B00+B01*Y1+X3* (B10+B11*Y1));
+                      DZ32 = Z32 - (B00+B01*Y2+X3* (B10+B11*Y2));
+                      DZ33 = Z33 - (B00+B01*Y3+X3* (B10+B11*Y3));
+                      VOLF = DZ00*DZ00 + DZ01*DZ01 + DZ02*DZ02 + DZ03*DZ03 +
+                             DZ10*DZ10 + DZ11*DZ11 + DZ12*DZ12 + DZ13*DZ13 +
+                             DZ20*DZ20 + DZ21*DZ21 + DZ22*DZ22 + DZ23*DZ23 +
+                             DZ30*DZ30 + DZ31*DZ31 + DZ32*DZ32 + DZ33*DZ33;
+                      DISF = SXX*SYY;
+
+		      //* Calculates EPSLN
+                      EPSLN = (Z00*Z00 + Z01*Z01 + Z02*Z02 + Z03*Z03 + 
+			       Z10*Z10 + Z11*Z11 + Z12*Z12 + Z13*Z13 + 
+                               Z20*Z20 + Z21*Z21 + Z22*Z22 + Z23*Z23 + 
+			       Z30*Z30 + Z31*Z31 + Z32*Z32 + Z33*Z33) *
+                               1.0E-12;
+
+		      //* Accumulates the weighted primary estimates of zxy and their weights
+                      if (VOLF > EPSLN)
+		      {
+		          //* - For a finite weight
+                          WT = 1.0/ (VOLF*DISF);
+                          SMPEF = SMPEF + WT*PEZXY;
+                          SMWTF = SMWTF + WT;
+		      }
+                      else
+		      {
+		          //* - For an infinite weight
+                          SMPEI = SMPEI + PEZXY;
+                          SMWTI = SMWTI + 1.0;
+		      }
+
+                  } //end for IPEY
+              } // end for IPEX
+
+	      //* Calculates the final estimate of zxy
+              if (SMWTI < 0.5)         //When no infinite weights exist
+                  ZXYDI = SMPEF/SMWTF;
+              else		       //When infinite weights exist
+                  ZXYDI = SMPEI/SMWTI;
+
+	      //* End of Part 3
+
+              WKZX_[IY0][IX0]  = ZXDI;
+              WKZY_[IY0][IX0]  = ZYDI;
+              WKZXY_[IY0][IX0] = ZXYDI;
+
+          } //end for IX0
+      } //end for IY0
+      return;
+}
+
+// A 7x7 area surround the point is searched
+
+int Akima760::CheckMissingValues (int col, int lin) const
+{
+      int i,j,NXDF,NYDF;
+
+      //* Initial setting of some local variables
+      NXDF = std::max(4,this->matrix_.columns());
+      NYDF = std::max(4,this->matrix_.rows());
+
+      // Check a 7x7 area
+      for (i = lin-3; i <= lin+3; i++)
+      {
+	      if ( i < 0 || i >= NYDF ) continue;
+
+	      for (j = col-3; j <= col+3; j++)
+	      {
+		      if ( j < 0 || j >= NXDF ) continue;
+
+		      if ( this->matrix_(i,j) == this->matrix_.missing() )
+			      return 0;
+	      }
+      }
+
+      return 1;
+}
+
+#if 0
+// This subroutine is obsolet, no longer needed
+
+void Akima760::rglctn(double XII, double YII, int& INXI, int& INYI) const
+{
+//*
+//* Location of the desired points in a rectangular grid
+//* (a supporting subroutine of the RGBI3P/RGSF3P subroutine package)
+//*
+//* Hiroshi Akima
+//* U.S. Department of Commerce, NTIA/ITS
+//* Version of 1995/08
+//*
+//* This subroutine locates the desired point in a rectangular grid
+//* in the x-y plane.
+//*
+//* The grid lines can be unevenly spaced.
+//*
+//* The input arguments are
+//*   NXD  = number of the input-grid data points in the x
+//*          coordinate (must be 2 or greater),
+//*   NYDF  = number of the input-grid data points in the y
+//*          coordinate (must be 2 or greater),
+//*   XD   = array of dimension NXD containing the x coordinates
+//*          of the input-grid data points (must be in a
+//*          monotonic increasing order),
+//*   YD   = array of dimension NYDF containing the y coordinates
+//*          of the input-grid data points (must be in a
+//*          monotonic increasing order),
+//*   XI   = x coordinate of the output point to be located
+//*   YI   = y coordinate of the output point to be located
+//*
+//* The output arguments are
+//*   INXI = integer where the interval number of the element is to be stored
+//*   INYI = integer where the interval number of the element is to be stored
+//*
+//* The external arguments are
+//*   NXD          = number of the input-grid data points in the x
+//*                  coordinate (must be 2 or greater),
+//*   NYDF         = number of the input-grid data points in the y
+//*                  coordinate (must be 2 or greater),
+//*   column       = array of dimension NXD containing the x coordinates
+//*                  of the input-grid data points (must be in a
+//*                  monotonic increasing order),
+//*   row          = array of dimension NYDF containing the y coordinates
+//*                  of the input-grid data points (must be in a
+//*                  monotonic increasing order)
+//*
+//* The interval numbers are between 0 and NXD and between 0 and NYDF,
+//* respectively.
+//*
+//* This routine was adapted to C++ by Fernando Ii, 02/04
+//*
+//*
+
+      int    NXDF,NYDF;        // input matrix dimensions
+      int       IMD,IMN,IMX;    // aixiliary variables
+
+ 
+      //* Locates the output point by binary search. Determines INXI
+      //* for which XII lies between XD(INXI) and XD(INXI+1)
+
+//???????????????????????????
+// IMPORTANT IMPORTANT IMPORTANT
+      // THE OLD FORTRAN STYLE CODE ROUTINE IS RUNNING IN
+      // PARALLEL WITH THE C++ CODE, TO MAKE SURE THAT THE
+      // C++ CODE IS CORRECT. REMOVE THE FORTRAN STYLE CODE
+      // LATER.
+//???????????????????????????
+
+      // IX/IY POINT TO 2 POSITIONS AHEAD IN THE ARRAY BECAUSE:
+      // 1. FORTRAN STYLE INDEX (START WITH 1, INSTEAD OF 0)
+      //    THIS IS COMPENSATE LATER IN THE CODE.
+      // 2. ROUTINE 'lowerColumn' AND 'lowerRow' RETURNS THE
+      //    'LOWER' VALUE INDEX, WHICH MEANS X(IX-1) OR Y(IY-1),
+      //    INSTEAD OF X(IX) OR Y(IY)
+
+      NXDF = this->matrix_.columns();
+      NYDF = this->matrix_.rows();
+      int ji;
+      if (XII <= this->matrix_.regular_column(0))
+              INXI = -1;
+      else if (XII < this->matrix_.regular_column(NXDF-1))
+      {
+#if 1  //REMOVE LATER
+              IMN = 0;
+              IMX = NXDF-1;
+              IMD = (IMN+IMX)/2;
+ll:
+              if (XII >= this->matrix_.regular_column(IMD))
+		      IMN = IMD;
+              else
+                      IMX = IMD;
+
+              IMD = (IMN+IMX)/2;
+              if (IMD > IMN) goto ll;
+	      INXI = IMD;
+#endif
+	      ji = this->matrix_.lowerColumn(XII);
+
+#if 0  //REMOVE LATER
+     if (JX1 != IX){
+       MagLog::dev()<< "SERIOUS ERROR FINDING INDEXES" << endl;
+       return -9999999.;
+     }
+#endif
+//     MagLog::dev()<< XII << " " << INXI << " " << ji << endl;
+       }
+       else
+              INXI = NXDF-1;
+
+       //* Locates the output point by binary search. Determines INYI 
+       //*for which YII lies between YD(INYI) and YD(INYI+1)
+       if (YII <= this->matrix_.regular_row(0))
+               INYI = -1;
+       else if (YII < this->matrix_.regular_row(NYDF-1))
+       {
+#if 1  //REMOVE LATER
+               IMN = 0;
+               IMX = NYDF-1;
+               IMD = (IMN+IMX)/2;
+ll1:
+	       if (YII >= this->matrix_.regular_row(IMD))
+                      IMN = IMD;
+               else
+                      IMX = IMD;
+
+               IMD = (IMN+IMX)/2;
+               if (IMD > IMN) goto ll1;
+               INYI = IMD;
+#endif
+	      ji = this->matrix_.lowerRow(YII);
+#if 1  //REMOVE LATER
+     if (ji != INYI){
+       MagLog::dev()<< "SERIOUS ERROR FINDING INDEXES" << ji << " " <<  INYI << endl;
+       return -9999999.;
+     }
+#endif
+//      MagLog::dev()<< YII << " " << INYI << " " << ji << endl;
+      	}
+        else
+               INYI = NYDF-1;
+
+      return;
+}
+#endif
+
+
+void Akima760::rgplnl(double XII, double YII, int IXDI, int IYDI, double& ZII) const
+{
+
+////*
+////* Polynomials for rectangular-grid bivariate interpolation and
+////* surface fitting
+////* (a supporting subroutine of the RGBI3P/RGSF3P subroutine package)
+////*
+////* Hiroshi Akima
+////* U.S. Department of Commerce, NTIA/ITS
+////* Version of 1995/08
+////*
+////* This subroutine determines a polynomial in x and y for a rectangle
+////* of the input grid in the x-y plane and calculates the z value for
+////* the desired points by evaluating the polynomial for rectangular-
+////* grid bivariate interpolation and surface fitting.
+////*
+////* The input arguments are
+////*   NXD  = number of the input-grid data points in the x
+////*          coordinate (must be 2 or greater),
+////*   NYDF  = number of the input-grid data points in the y
+////*          coordinate (must be 2 or greater),
+////*   XD   = array of dimension NXDF containing the x coordinates
+////*          of the input-grid data points (must be in a
+////*          monotonic increasing order),
+////*   YD   = array of dimension NYDF containing the y coordinates
+////*          of the input-grid data points (must be in a
+////*          monotonic increasing order),
+////*   ZD   = two-dimensional array of dimension NXDF*NYDF
+////*          containing the z(x,y) values at the input-grid data
+////*          points,
+////*   PDD  = three-dimensional array of dimension 3*NXDF*NYDF
+////*          containing the estimated zx, zy, and zxy values
+////*          at the input-grid data points,
+////*   NIP  = number of the output points at which interpolation
+////*          is to be performed,
+////*   XII   = x coordinate of the output point,
+////*   YII   = y coordinate of the output points,
+////*   IXDXI = interval number of the input grid interval in the
+////*          x direction where the x coordinate of the output
+////*          point lie,
+////*   IYDI = interval number of the input grid interval in the
+////*          y direction where the y coordinate of the output
+////*          point lie.
+////*
+////* The output argument is
+////*   ZII   = interpolated z value at the output point.
+////*
+////* This routine was adapted to C++ by Fernando Ii, 02/04
+////*
+////*
+//
+//      
+// Check for missing values: only need to check one of the three
+// arrays (WKZX_,WKZY_,WKZXY_), since if there is a missing value
+// within a 7x7 region surround the central point, all the three
+// arrays point to a missing value.
+
+      // Variables definition
+      double   P00,P01,P02,P03,P10,P11;
+      double   P12,P13,P20,P21,P22,P23,P30,P31,P32,P33,Q0,Q1,Q2;
+      double   Q3,U,V,X0,Y0,Z00,Z01,Z0DX,Z0DY,Z10,Z11;
+      double   Z1DX,Z1DY,ZDXDY,ZX00,ZX01,ZX0DY,ZX10,ZX11;
+      double   ZX1DY,ZXY00,ZXY01,ZXY10,ZXY11,ZY00,ZY01,ZY0DX;
+      double   ZY10,ZY11,ZY1DX;
+      double   A;
+      double   B;
+      double   C;
+      double   DF; 
+      double   DX;
+      double   DXSQ;
+      double   DY; 
+      double   DYSQ;
+      int      IXD0,IXD1,IYD0,IYD1;
+      int      NXDF,NYDF;
+
+       //* Retrieves the z and partial derivative values at the origin of
+       //* the coordinate for the rectangle
+       NXDF = monoColumns_;
+       NYDF = monoRows_;
+       IXD0  = std::max(0,IXDI);
+       IYD0  = std::max(0,IYDI);
+       X0    = this->matrix_.regular_column(IXD0);
+       Y0    = this->matrix_.regular_row(IYD0);
+       Z00   = this->matrix_(IYD0,IXD0);
+       ZX00  = WKZX_[IYD0][IXD0];
+       ZY00  = WKZY_[IYD0][IXD0];
+       ZXY00 = WKZXY_[IYD0][IXD0];
+       if (ZX00 == missing()) 
+       {
+		ZII = missing();
+		return;
+       }
+
+// CHECK THESE INDEXES LATER ????????????????????????????
+
+       //* Case 1.  When the rectangle is inside the data area in both the
+       //* x and y directions
+       if (IXDI >= 0 && IXDI < NXDF-1 && IYDI >= 0 && IYDI < NYDF-1)
+       {
+	          //* Retrieves the z and partial derivative values at the other three
+	          //* vertexes of the rectangle
+                  IXD1 = IXD0 + 1;
+                  DX = this->matrix_.regular_column(IXD1) - X0;
+                  DXSQ = DX*DX;
+                  IYD1 = IYD0 + 1;
+                  DY = this->matrix_.regular_row(IYD1) - Y0;
+                  DYSQ = DY*DY;
+                  Z10 = this->matrix_(IYD0,IXD1);
+                  Z01 = this->matrix_(IYD1,IXD0);
+                  Z11 = this->matrix_(IYD1,IXD1);
+                  ZX10 = WKZX_[IYD0][IXD1];
+                  ZX01 = WKZX_[IYD1][IXD0];
+                  ZX11 = WKZX_[IYD1][IXD1];
+                  ZY10 = WKZY_[IYD0][IXD1];
+                  ZY01 = WKZY_[IYD1][IXD0];
+                  ZY11 = WKZY_[IYD1][IXD1];
+                  ZXY10 = WKZXY_[IYD0][IXD1];
+                  ZXY01 = WKZXY_[IYD1][IXD0];
+                  ZXY11 = WKZXY_[IYD1][IXD1];
+		  if (ZX10 == missing() || ZX01 == missing() || ZX11 == missing()) 
+		  {
+			 ZII = missing();
+			 return;
+		  }
+
+		  //* Calculates the polynomial coefficients
+                  Z0DX = (Z10-Z00)/DX;
+                  Z1DX = (Z11-Z01)/DX;
+                  Z0DY = (Z01-Z00)/DY;
+                  Z1DY = (Z11-Z10)/DY;
+                  ZX0DY = (ZX01-ZX00)/DY;
+                  ZX1DY = (ZX11-ZX10)/DY;
+                  ZY0DX = (ZY10-ZY00)/DX;
+                  ZY1DX = (ZY11-ZY01)/DX;
+                  ZDXDY = (Z1DY-Z0DY)/DX;
+                  A = ZDXDY - ZX0DY - ZY0DX + ZXY00;
+                  B = ZX1DY - ZX0DY - ZXY10 + ZXY00;
+                  C = ZY1DX - ZY0DX - ZXY01 + ZXY00;
+                  DF= ZXY11 - ZXY10 - ZXY01 + ZXY00;
+                  P00 = Z00;
+                  P01 = ZY00;
+                  P02 = (2.0* (Z0DY-ZY00)+Z0DY-ZY01)/DY;
+                  P03 = (-2.0*Z0DY+ZY01+ZY00)/DYSQ;
+                  P10 = ZX00;
+                  P11 = ZXY00;
+                  P12 = (2.0* (ZX0DY-ZXY00)+ZX0DY-ZXY01)/DY;
+                  P13 = (-2.0*ZX0DY+ZXY01+ZXY00)/DYSQ;
+                  P20 = (2.0* (Z0DX-ZX00)+Z0DX-ZX10)/DX;
+                  P21 = (2.0* (ZY0DX-ZXY00)+ZY0DX-ZXY10)/DX;
+                  P22 = (3.0* (3.0*A-B-C)+DF)/ (DX*DY);
+                  P23 = (-6.0*A+2.0*B+3.0*C-DF)/ (DX*DYSQ);
+                  P30 = (-2.0*Z0DX+ZX10+ZX00)/DXSQ;
+                  P31 = (-2.0*ZY0DX+ZXY10+ZXY00)/DXSQ;
+                  P32 = (-6.0*A+3.0*B+2.0*C-DF)/ (DXSQ*DY);
+                  P33 = (2.0* (2.0*A-B-C)+DF)/ (DXSQ*DYSQ);
+
+	      //* Evaluates the polynomial
+              U = XII - X0;
+              V = YII - Y0;
+              Q0 = P00 + V* (P01+V* (P02+V*P03));
+              Q1 = P10 + V* (P11+V* (P12+V*P13));
+              Q2 = P20 + V* (P21+V* (P22+V*P23));
+              Q3 = P30 + V* (P31+V* (P32+V*P33));
+              ZII = Q0 + U* (Q1+U* (Q2+U*Q3));
+	  }
+	  //* End of Case 1
+
+	  //* Case 2.  When the rectangle is inside the data area in the x
+	  //* direction but outside in the y direction
+          else if ((IXDI >= 0 && IXDI < NXDF-1) && (IYDI < 0 || IYDI >= NYDF-1))
+	  {
+	      //* Retrieves the z and partial derivative values at the other
+	      //* vertex of the semi-infinite rectangle
+                  IXD1 = IXD0 + 1;
+                  DX = this->matrix_.regular_column(IXD1) - X0;
+                  DXSQ = DX*DX;
+                  Z10 = this->matrix_(IYD0,IXD1);
+                  ZX10 = WKZX_[IYD0][IXD1];
+                  ZY10 = WKZY_[IYD0][IXD1];
+                  ZXY10 = WKZXY_[IYD0][IXD1];
+		  if (ZX10 == missing())
+		  {
+			 ZII = missing();
+			 return;
+		  }
+
+		  //* Calculates the polynomial coefficients
+                  Z0DX = (Z10-Z00)/DX;
+                  ZY0DX = (ZY10-ZY00)/DX;
+                  P00 = Z00;
+                  P01 = ZY00;
+                  P10 = ZX00;
+                  P11 = ZXY00;
+                  P20 = (2.0* (Z0DX-ZX00)+Z0DX-ZX10)/DX;
+                  P21 = (2.0* (ZY0DX-ZXY00)+ZY0DX-ZXY10)/DX;
+                  P30 = (-2.0*Z0DX+ZX10+ZX00)/DXSQ;
+                  P31 = (-2.0*ZY0DX+ZXY10+ZXY00)/DXSQ;
+
+	      //* Evaluates the polynomial
+              U = XII - X0;
+              V = YII - Y0;
+              Q0 = P00 + V*P01;
+              Q1 = P10 + V*P11;
+              Q2 = P20 + V*P21;
+              Q3 = P30 + V*P31;
+              ZII = Q0 + U* (Q1+U* (Q2+U*Q3));
+	  }
+	  //* End of Case 2
+
+	  //* Case 3.  When the rectangle is outside the data area in the x
+	  //* direction but inside in the y direction
+          else if ((IXDI < 0 || IXDI >= NXDF-1) && (IYDI >= 0 && IYDI < NYDF-1))
+	  {
+	      //* Retrieves the z and partial derivative values at the other
+	      //* vertex of the semi-infinite rectangle
+                  IYD1 = IYD0 + 1;
+                  DY = this->matrix_.regular_row(IYD1) - Y0;
+                  DYSQ = DY*DY;
+                  Z01 = this->matrix_(IYD1,IXD0);
+                  ZX01 = WKZX_[IYD1][IXD0];
+                  ZY01 = WKZY_[IYD1][IXD0];
+                  ZXY01 = WKZXY_[IYD1][IXD0];
+		  if (ZX01 == missing())
+		  {
+			  ZII = missing();
+			  return;
+		  }
+
+		  //* Calculates the polynomial coefficients
+                  Z0DY = (Z01-Z00)/DY;
+                  ZX0DY = (ZX01-ZX00)/DY;
+                  P00 = Z00;
+                  P01 = ZY00;
+                  P02 = (2.0* (Z0DY-ZY00)+Z0DY-ZY01)/DY;
+                  P03 = (-2.0*Z0DY+ZY01+ZY00)/DYSQ;
+                  P10 = ZX00;
+                  P11 = ZXY00;
+                  P12 = (2.0* (ZX0DY-ZXY00)+ZX0DY-ZXY01)/DY;
+                  P13 = (-2.0*ZX0DY+ZXY01+ZXY00)/DYSQ;
+
+	      //* Evaluates the polynomial
+              U = XII - X0;
+              V = YII - Y0;
+              Q0 = P00 + V* (P01+V* (P02+V*P03));
+              Q1 = P10 + V* (P11+V* (P12+V*P13));
+              ZII = Q0 + U*Q1;
+	  }
+	  //* End of Case 3
+
+	  //* Case 4.  When the rectangle is outside the data area in both the
+	  //* x and y direction
+          else if ((IXDI < 0 || IXDI >= NXDF-1) && (IYDI < 0 || IYDI >= NYDF-1))
+	  {
+	      //* Calculates the polynomial coefficients
+              P00 = Z00;
+              P01 = ZY00;
+              P10 = ZX00;
+              P11 = ZXY00;
+
+	      //* Evaluates the polynomial
+              U = XII - X0;
+              V = YII - Y0;
+              Q0 = P00 + V*P01;
+              Q1 = P10 + V*P11;
+              ZII = Q0 + U*Q1;
+	  }
+	  //* End of Case 4
+
+      return;
+}
+
+
+
+double Akima760::rgbi3p(double XI, double YI) const
+{
+//*
+//* Rectangular-grid bivariate interpolation
+//* (a master subroutine of the RGBI3P/RGSF3P subroutine package)
+//*
+//* Hiroshi Akima
+//* U.S. Department of Commerce, NTIA/ITS
+//* Version of 1995/08
+//*
+//* This subroutine performs interpolation of a bivariate function,
+//* z(x,y), on a rectangular grid in the x-y plane.  It is based on
+//* the revised Akima method.
+//*
+//* In this subroutine, the interpolating function is a piecewise
+//* function composed of a set of bicubic (bivariate third-degree)
+//* polynomials, each applicable to a rectangle of the input grid
+//* in the x-y plane.  Each polynomial is determined locally.
+//*
+//* This subroutine has the accuracy of a bicubic polynomial, i.e.,
+//* it interpolates accurately when all data points lie on a
+//* surface of a bicubic polynomial.
+//*
+//* The grid lines can be unevenly spaced.
+//*
+//* The input arguments are
+//*   MD  = mode of computation
+//*       = 1 for new XD, YD, or ZD data (default)
+//*       = 2 for old XD, YD, and ZD data,
+//*   NXDF = number of the input-grid data points in the x
+//*         coordinate (must be 2 or greater),
+//*   NYDF = number of the input-grid data points in the y
+//*         coordinate (must be 2 or greater),
+//*   XD  = array of dimension NXDF containing the x coordinates
+//*         of the input-grid data points (must be in a
+//*         monotonic increasing order),
+//*   YD  = array of dimension NYDF containing the y coordinates
+//*         of the input-grid data points (must be in a
+//*         monotonic increasing order),
+//*   ZD  = two-dimensional array of dimension NXDF*NYDF
+//*         containing the z(x,y) values at the input-grid data
+//*         points,
+//*   NIP = number of the output points at which interpolation
+//*         of the z value is desired (must be 1 or greater),
+//*   XI  = array of dimension NIP containing the x coordinates
+//*         of the output points,
+//*   YI  = array of dimension NIP containing the y coordinates
+//*         of the output points.
+//*
+//* The output arguments are
+//*   ZI  = array of dimension NIP where the interpolated z
+//*         values at the output points are to be stored,
+//*   IER = error flag
+//*       = 0 for no errors
+//*       = 1 for NXDF = 1 or less
+//*       = 2 for NYDF = 1 or less
+//*       = 3 for identical XD values or
+//*               XD values out of sequence
+//*       = 4 for identical YD values or
+//*               YD values out of sequence
+//*       = 5 for NIP = 0 or less.
+//*
+//* The other argument is
+//*   WK  = three dimensional array of dimension 3*NXDF*NYDF used
+//*         internally as a work area.
+//*
+//* The very fisrt call to this subroutine and the call with a new
+//* XD, YD, and ZD array must be made with MD=1.  The call with MD=2
+//* must be preceded by another call with the same XD, YD, and ZD
+//* arrays.  Between the call with MD=2 and its preceding call, the
+//* WK array must not be disturbed.
+//*
+//* The constant in the PARAMETER statement below is
+//*   NIPIMX = maximum number of output points to be processed
+//*            at a time.
+//* The constant value has been selected empirically.
+//*
+//* This subroutine calls the RGLCTN and RGPLNL subroutines.
+//*
+//* This routine was adapted to C++ by Fernando Ii, 02/04
+//*
+//* Specification statements
+//*     .. Parameters ..
+//
+
+//*   .. Scalar Arguments ..
+//      int          IER,MD,NIP,NXDF,NYDF;
+
+//*   .. Array Arguments ..
+//      double       WK[NYDF][NXDF][3],XD[NXDF],XI[NIP],YD[NYDF],YI[NIP],
+//                   ZD[NYDF][NXDF],ZI[NIP];
+
+      int    INXI,INYI;  // input point
+      double ZI;         // interpolated value
+
+      // Locates the output point
+      // It is not called anymore, but it is kept here
+      // for test purpose
+      //int col, row;
+      //rglctn(XI,YI,col,row );
+
+      if (XI <= this->matrix_.regular_column(0)) INXI = -1;
+      else if (XI < this->matrix_.regular_column(this->matrix_.columns()-1)) INXI = this->matrix_.lowerColumn(XI);
+      else INXI = this->matrix_.columns()-1;
+
+      if (YI <= this->matrix_.regular_row(0)) INYI = -1;
+      else if (YI < this->matrix_.regular_row(this->matrix_.rows()-1)) INYI = this->matrix_.lowerRow(YI);
+      else INYI = this->matrix_.rows()-1;
+
+//MagLog::dev()<< XI << " " << YI << "   " << INXI << " " << INYI << "   " << col << " " << row << endl;
+
+      // Calculates the z values at the output point
+      rgplnl(XI,YI,INXI,INYI,ZI);
+
+      return ZI;
+}
+
+
+
+int Akima760::rowIndex(double row) const
+{
+     map<double, int>::const_iterator i = rowsMap_.find(row);
+     if ( i != rowsMap_.end() ) return (*i).second;
+     return -1;
+}
+
+
+
+int Akima760::columnIndex(double row) const
+{
+      map<double, int>::const_iterator i = columnsMap_.find(row);
+      if ( i != columnsMap_.end() ) return (*i).second;
+      return -1;
+}
+
+
+
+void Akima760::boundRow(double r, double& row1, int& index1, double& row2, int& index2) const
+{
+//	unsigned int  nb =  rows_.size();
+
+	// first test if increasing!
+	if ( rows_.back() - rows_.front() > 0 ) {
+		index2 = 0;
+		while ( rows_[index2] < r ) {
+			index2++;
+		}
+		index1 = index2-1;		
+		row1 = rows_[index1];
+		row2 = rows_[index2];
+	}
+	else {
+		index1 = 0;
+		while ( rows_[index1] >  r ) {
+			index1++;
+		}
+		index2 = index1+1;	
+		row1 = rows_[index1];
+		row2 = rows_[index2];
+	}
+}
+
+
+
+void Akima760::boundColumn(double r, double& column1, int& index1, double& column2, int& index2) const
+{
+//	unsigned int  nb =  rows_.size();
+
+	// first test if increasing!
+	if ( columns_.back() - columns_.front() > 0 )
+	{
+		index2 = 0;
+		while ( columns_[index2] < r )
+		{
+				index2++;
+		}
+		index1 = index2-1;		
+		column1 = columns_[index1];
+		column2 = columns_[index2];
+	}
+	else {
+		index1 = 0;
+		while ( columns_[index1] >  r )
+		{
+			index1++;
+		}
+		index2 = index1+1;	
+		column1 = columns_[index1];
+		column2 = rows_[index2];
+	}
+}
diff --git a/src/visualisers/Akima760Method.h b/src/visualisers/Akima760Method.h
new file mode 100644
index 0000000..e807d23
--- /dev/null
+++ b/src/visualisers/Akima760Method.h
@@ -0,0 +1,173 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Akima760Method.h
+    \brief Definition of the Template class Akima760Method.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 11-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Akima760Method_H
+#define Akima760Method_H
+
+#include "magics.h"
+
+#include "ContourMethod.h"
+#include "Akima760MethodAttributes.h"
+
+namespace magics {
+
+
+class Akima760 : public MatrixHandler
+{
+public : 
+
+    Akima760(const AbstractMatrix& matrix, const Akima760MethodAttributes&);
+
+    ~Akima760(); 
+
+    double operator()(int  i, int  j) const;
+    int rowIndex(double r) const;
+    int columnIndex(double r) const;
+    void boundRow(double r, double& row1, int& index1, double& row2, int& index2) const;
+                     
+    void boundColumn(double r, double& column1, int& index1, double& column2, int& index2) const; 
+    /*
+    double interpolate(double  i, double  j) const { 
+    	return this->matrix_.interpolate(i,j); 
+   }  
+   */
+
+    int  rows() const {
+	    return nrows_;
+    }
+    int  columns() const { 
+	    return ncols_;
+    }
+    
+    double regular_row(int i) const;
+    double regular_column(int j) const;
+    
+    double column(int, int) const;
+    double row(int, int) const;
+    
+    double missing() const  { 
+    	return this->matrix_.missing(); 
+    }
+
+    // Compute partial derivatives of a bivariate function 
+    // on a rectangular grid
+    void rgpd3p();
+
+    // Rectangular-grid bivariate interpolation
+    double rgbi3p(double xi, double yi) const;
+
+    // Location of the desired points in a rectangular grid
+    // Remove  later
+    void rglctn(double xi, double yi, int& inxi, int& inyi) const;
+
+    // Polynomials for rectangular-grid bivariate interpolation
+    // and surface fitting
+    void rgplnl(double xi, double yi, int inxi, int inyi, double& zi) const;
+
+    // Check missing values
+    int CheckMissingValues(int col, int lin) const;
+
+//TEST, REMOVE LATER
+//void test_build_data();
+
+private:
+
+//     MonotonicIncreasingMatrixHandler mono1_; //Akima needs indexes in the monotonic increasing order
+//     MatrixHandler mono_;
+    //It is expected that the input Matrix is monotonic increasing and
+    //already cached
+     Akima760MethodAttributes attr_;
+     int                nrows_;         // number of rows
+     int                ncols_;         // number of columns
+     double             **WKZX_;        // working array
+     double             **WKZY_;        // working array
+     double             **WKZXY_;       // working array
+     int                monoRows_;
+     int                monoColumns_;
+     bool               missingValues_; // True: data has missing values
+     map<double, int> rowsMap_;
+     map<double, int> columnsMap_; 
+     vector<double> rows_;
+     vector<double> columns_;
+     
+};
+
+
+
+
+class Akima760Method: public ContourMethod, public Akima760MethodAttributes {
+public:
+	Akima760Method() { MagLog::dev() << "Akima760Method::Akima760Method-->" << *this << "\n"; } 
+	virtual ~Akima760Method() {}
+    
+    ContourMethod* clone() const {
+    	Akima760Method* method = new Akima760Method();
+    	method->copy(*this);
+    	return method;
+    }
+    
+    virtual void set(const map<string, string>& map) {
+    	Akima760MethodAttributes::set(map);
+    }
+    
+    virtual void set(const XmlNode& node) {
+    	Akima760MethodAttributes::set(node);
+    }
+    virtual bool accept(const string& node) { return Akima760MethodAttributes::accept(node);; }
+
+    virtual MatrixHandler* handler(const AbstractMatrix& matrix, const BasicGraphicsObjectContainer&) {
+        return new Akima760(matrix,*this);
+	}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { 
+         out << "Akima760Method[";
+         Akima760MethodAttributes::print(out);
+         out << "]";
+	 }  
+
+private:
+    //! Copy constructor - No copy allowed
+	Akima760Method(const Akima760Method&); 
+    //! Overloaded << operator to copy - No copy allowed
+	Akima760Method& operator=(const Akima760Method&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Akima760Method& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+
+#endif
diff --git a/src/visualisers/Akima760MethodAttributes.h b/src/visualisers/Akima760MethodAttributes.h
new file mode 100644
index 0000000..ad7c44c
--- /dev/null
+++ b/src/visualisers/Akima760MethodAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file Akima760MethodAttributes.h
+    \brief Definition of Akima760Method Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef Akima760MethodAttributes_H
+#define Akima760MethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class Akima760MethodAttributes 
+{
+public:
+//  --  constructor
+    Akima760MethodAttributes();
+    
+//  --  destructor
+    virtual ~Akima760MethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const Akima760MethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double resolutionX_;
+	double resolutionY_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const Akima760MethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Akima761Method.h b/src/visualisers/Akima761Method.h
new file mode 100644
index 0000000..6223b6d
--- /dev/null
+++ b/src/visualisers/Akima761Method.h
@@ -0,0 +1,302 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Akima761Method.h
+    \brief Definition of the Template class Akima761Method.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 11-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Akima761Method_H
+#define Akima761Method_H
+
+#include "magics.h"
+
+#include "ContourMethod.h"
+#include "Akima761MethodAttributes.h"
+#include "PointsHandler.h"
+
+// N1, N2, and N3 are the numbers of the data points used 
+// to determine the first-, second-, and third-degree 
+// polynomials
+#define N1_ 3
+#define N2_ 6
+#define N3_ 10
+
+namespace magics {
+
+template <class P>
+class Akima761 : public MatrixHandler<P>
+{
+public :
+
+    Akima761(const AbstractPoints<P>&, const Akima761Attributes&);
+    ~Akima761(); 
+
+    // Matrix operators
+    double operator()(int  i, int  j) const;
+    int  rows() const      //output number of rows
+    {
+	    return nrows_;
+    }
+    int  columns() const   //output number of columns
+    { 
+	    return ncols_;
+    }
+    
+    double row(int i) const;     //latitude value
+    double column(int j) const;  //longitude value
+
+    double missing() const          //missing value
+    { 
+    	return this->matrix_.missing(); 
+    }
+
+    // Initialization
+    int Init (int,double*,double*,double*,int NROW=6);
+
+    // Scaterred-data bivariate interpolation
+    int SDBI3P(double,double,double&) const;
+
+
+private:
+     
+     Akima761Attributes attr_;
+     Matrix   matrix_;    // output matrix
+     int   nrows_;     // number of rows
+     int   ncols_;     // number of columns
+     double minX_,maxX_, // bounding box
+	      minY_,maxY_;
+
+     double SWTOL_; // tolerance
+
+     int     MD_;    // mode of computation, 1 for new XD-YD (default)
+     int     NDP_;   // number of data points
+     int     NROW_;  // number of entries per triangle (6 or 9)
+     int     NT_;    // number of triangles (maximum is 2*NDP-5)
+     int     NL_;    // number of border line segments (maximum is NDP)
+     double  *XD_;   // X coordinates of the data points
+     double  *YD_;   // Y coordinates of the data points
+     double  *ZD_;   // Z coordinates of the data points
+
+     // Auxiliary variables
+     int     *LIST_;  // set of nodal indexes used in the triangulation
+     int     *LPTR_;  // set of pointers (LIST indexes)
+     int     *LEND_;  // set of pointers to adjacency lists
+     int     *LIST1_; // copy of LIST_ 
+     int     *LPTR1_; // copy of LPTR_
+     int     *LEND1_; // copy of LEND_
+
+     int     *IPT_[3]; // point numbers of the vertexes
+     int     *IPL_[2]; // point numbers of the end points of the 
+                       // (IL)th border line segment
+
+     int    **LTRI_;   // internal work area
+     int     *ITL_;    // internal work area
+
+     int     *IORD_;   // degree of the polynomial used to compute PDD (NDP)
+     int     *IDSQ_;   // internal work area (NDP)
+     int     *IPC_[9]; // internal work area (9*NDP)
+     int     *NCP_;    // internal work area (NDP)
+
+     double *PDD_[5];  // store estimated zx,zy,zxx,zxy,zyy values (5*NDP)
+     double *CF3_[9];  // internal work area (9*NDP)
+     double *CFL1_[2]; // internal work area (2*NDP)
+     double *DSQ_;     // internal work area (NDP)
+
+     // Member functions
+
+     // Initialize working arrays
+     int InitWorkingArrays();
+
+     //---------------------------------
+     //Terralib functions
+     //---------------------------------
+
+    // Triangulates the data area in the x-y plane with 
+    // a scattered data point set
+    int SDTRAN(int&,int&);
+
+    // Basic triangulation in the convex hull of a scattered
+    // data point set in a plane
+    int SDTRCH(int&,int&);
+
+    // Removal of thin triangles along the border line of triangulation
+    void SDTRTT(int&,int&);
+
+    // Partial derivatives for bivariate interpolation and surface
+    // fitting for scattered data
+    void SDPD3P();
+
+    // Selects, at each of the data points, nine data points closest to it
+    void SDCLDP();
+
+    // Computes coefficients of the third-degree polynomial for z(x,y)
+    void SDCF3P();
+
+    // Solution of a set of linear equations
+    void SDLEQN(int,double[N3_][N3_],double*,double*,double&,double&);
+
+    // Least squares fit of a linear surface (plane) to z(x,y) values
+    void SDLS1P();
+
+    // Estimates first and second partial derivatives at node K
+    int GRADC(int,int,int*,int,double&,double&,double&,double&,double&);
+
+    // Sets up the I-th row of an augmented regression matrix for a 
+    // weighted least squares fit of a cubic function f(x,y) to a set 
+    // of data values z, where f(XK,YK) = ZK
+    void SETRO3(double,double,double,double,double,double,double,double,double,double,double*);
+
+    // Constructs the Givens plane rotation
+    void GIVENS(double&,double&,double&,double&);
+
+    // Applies the Givens rotation to the 2 by N matrix
+    void ROTATE(int,double,double,double*,double*);
+
+    // Locating points in a scattered data point set
+    void SDLCTN(int,double*,double*,int*,int*) const;
+
+    // Compute the z value in a scattered data point set
+    void SDPLNL(int,double*,double*,int*,int*,double*) const;
+
+    //------------------------------------
+    // Tripack functions
+    //------------------------------------
+
+     // Creates a Delaunay triangulation
+     int TRMESH (int&);
+
+     // Determines whether node N0 is to the left or to the right 
+     // of the line through N1-N2 as viewed by an observer at N1 
+     // facing N2
+     bool LEFT (double,double,double,double,double,double);
+
+     // Updates the data structure with the addition of a new node 
+     // in position K
+     int ADDNOD (int,double,double,int,int,int*,int&,double*,double*,int*,int*,int*,int&);
+
+     // Locates a point P relative to a triangulation created by 
+     // subroutine TRMESH or TRMSHR
+     void TRFIND (int,double,double,double*,double*,int*,int*,int*,int&,int&,int&);
+
+     // Returns the index (LIST pointer) of NB in C the adjacency 
+     // list for N0, where LPL = LEND(N0)
+     int LSTPTR (int,int,int*,int*);
+
+     // Check if a triangle lies in a constraint region
+     bool CRTRI (int,int*,int,int,int);
+
+     // Returns the index, if any, of an exterior constraint curve 
+     int INDXCC (int,int*,int,int*,int*);
+
+     // Adds a boundary node to a triangulation of a set of points 
+     // in the plane
+     void BDYADD (int,int,int,int*,int*,int*,int&);
+
+     // Inserts a node as a neighbor of N1 following N2
+     void INSERT (int,int,int*,int*,int&);
+
+     // Adds an interior node to a triangulation of a set of points
+     // in the plane
+     void INTADD (int,int,int,int,int*,int*,int*,int&);
+
+     // Replaces a diagonal arc in a strictly convex quadrilateral 
+     // with the other diagonal
+     void SWAP (int,int,int,int,int*,int*,int*,int&);
+
+     // Applies the circumcircle test to a quadrilateral defined 
+     // by a pair of adjacent triangles
+     bool SWPTST (int,int,int,int,double*,double*);
+
+     // Converts a triangulation data structure from the linked list
+     // created by subroutine TRMESH or TRMSHR to a triangle list
+     int TRLIST (int,int*,int,int*,int*,int*,int,int&,int*);
+
+     // Sets NPTS(L) to the index of the next node in the sequence -- 
+     // the node, other than NPTS(1),...,NPTS(L-1), which is closest 
+     // to NPTS(1)
+     int GETNP (int,int*,int,double*,double*,int*,int*,int*,int,int*,double*);
+
+     // Given a pair of line segments P1-P2 and P3-P4, returns 'true'
+     // if and only if P1-P2 shares one or more points with P3-P4
+     bool INTSEC (double,double,double,double,double,double,double,double);
+
+};
+
+
+
+template <class P>
+class Akima761Method: public ContourMethod<P>, public Akima761MethodAttributes {
+public:
+	Akima761Method() { MagLog::dev() << "Akima761Method::Akima761Method-->" << *this << "\n"; } 
+	virtual ~Akima761Method() {}
+    
+    ContourMethod<P>* clone() const { 
+    	Akima761Method<P>* method = new Akima761Method<P>(); 
+    	method->copy(*this);
+    	return method;
+    }
+    
+    virtual void set(const map<string, string>& map) {
+    	Akima761MethodAttributes::set(map);
+    }
+    
+    virtual void set(const XmlNode& node) {
+    	Akima761MethodAttributes::set(node);
+    }
+    virtual bool accept(const string& node) { return Akima761MethodAttributes::accept(node);; }
+    virtual bool needPoints() { return true; }
+	virtual MatrixHandler<P>* handlePoints(const AbstractPoints<P>& points, const Layout&) {
+        return new Akima761<P>(points,*this);
+	}
+    virtual MatrixHandler<P>* handler(const AbstractMatrix&, const , const BasicGraphicsObjectContainer&) {
+        return 0;
+	}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { 
+         out << "Akima761Method[";
+         Akima761Attributes::print(out);
+         out << "]";
+	 }  
+
+private:
+    //! Copy constructor - No copy allowed
+	Akima761Method(const Akima761Method&); 
+    //! Overloaded << operator to copy - No copy allowed
+	Akima761Method& operator=(const Akima761Method&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Akima761Method<P>& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#include "Akima761.cc"
+#include "Tripack.cc"
+
+#endif
diff --git a/src/visualisers/ArrowPlotting.cc b/src/visualisers/ArrowPlotting.cc
new file mode 100644
index 0000000..1453644
--- /dev/null
+++ b/src/visualisers/ArrowPlotting.cc
@@ -0,0 +1,230 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file WindPlotting.cc
+    \brief Implementation of the Template class Wind.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+#include "LegendVisitor.h"
+#include "ArrowPlotting.h"
+#include "Histogram.h"
+
+using namespace magics;
+
+void ArrowPlotting::operator()(const UserPoint& geo, const PaperPoint& point, double x, double y, double val) 
+{ 
+   const double speed = this->speed(x, y, val);
+   if ( maxVelocity_ < speed )
+       maxVelocity_ = speed;
+   if (speed < this->min_speed_ || speed > this->max_speed_) return;
+
+   if ((*this->calm_)(point, x, y)) return; 
+
+   Colour colour = this->colour(*colour_, x, y, val);
+   if ( geo.y() >= 0 ) 
+	   northArrow(colour)->push_back(ArrowPoint(x, y, point));
+   else 
+	   southArrow(colour)->push_back(ArrowPoint(x, y, point));
+}
+
+
+
+//! Setting for south Hemisphere wind	
+Arrow* ArrowPlotting::southArrow(const Colour& colour)
+{
+	map<Colour, Arrow* >:: iterator arrow =  southArrows_.find(colour);
+	if ( arrow !=southArrows_.end()  ) 
+		return arrow->second;
+
+	 Arrow * south = new Arrow();
+	   south->setColour(colour);
+	   south->setThickness(this->thickness_);
+	   south->setStyle(this->style_);
+	   south->setScale(this->unit_velocity_);
+	   south->setHemisphere(SOUTH);
+	   south->setArrowPosition(this->origin_position_);
+	   south->setHeadIndex(this->head_);
+	   south->setHeadRatio(this->ratio_);
+	   southArrows_.insert(make_pair(colour, south));
+	   return south;
+}
+
+
+//! Setting for north Hemisphere wind
+Arrow* ArrowPlotting::northArrow(const Colour& colour)
+{
+	map<Colour, Arrow* >:: iterator arrow =  northArrows_.find(colour);
+	if ( arrow != northArrows_.end()  ) 
+	return arrow->second;
+
+	Arrow *north = new Arrow();
+	north->setColour(colour);
+	north->setThickness(this->thickness_);
+	north->setStyle(this->style_);
+	north->setScale(this->unit_velocity_);
+	north->setHemisphere(NORTH);
+	north->setArrowPosition(this->origin_position_);
+	north->setHeadIndex(this->head_);
+	north->setHeadRatio(this->ratio_); 
+	northArrows_.insert(make_pair(colour, north));
+	return north;
+}
+
+void ArrowPlotting::prepare(BasicGraphicsObjectContainer& out)
+{
+   // Calm Indicator 
+   (*this->calm_).colour(*this->colour_);
+   (*this->calm_).height(this->calm_indicator_size_);
+   (*this->calm_).below(this->calm_below_);
+   (*this->calm_).prepare(out);
+}
+
+void ArrowPlotting::prepare(BasicGraphicsObjectContainer& out, double res)
+{
+   // Calm Indicator 
+   (*this->calm_).colour(*this->colour_);
+   (*this->calm_).height(this->calm_indicator_size_);
+   (*this->calm_).below(this->calm_below_);
+   (*this->calm_).prepare(out);
+
+   if ( magCompare(unit_system_, "automatic") ) {
+	   // adjust the scaling factor!
+	   MagLog::dev() << "res-->" << res << endl;
+	   MagLog::dev() << "befor unit_velocity_-->" << this->unit_velocity_ << endl;
+	   double unit = res * out.transformation().unitToCm(out.absoluteWidth(), out.absoluteHeight());
+	   MagLog::dev() << "unit to cm -->" << out.transformation().unitToCm(out.absoluteWidth(), out.absoluteHeight()) << " unit->" << unit << endl;
+	   if(!zero(unit)) this->unit_velocity_ /= unit;
+	   MagLog::dev() << "unit_velocity_-->" << this->unit_velocity_ << endl;
+   }
+   else if ( magCompare(unit_system_, "paper") ) {
+	// adjust the scaling factor!
+	//this->unit_velocity_ /= out.transformation().unitToCm(out.absoluteWidth(), out.absoluteHeight());  			
+	MagLog::dev() << "unit_velocity_-->" << this->unit_velocity_ << endl;
+   }
+
+   this->maxVelocity_ = -1;
+/*
+   for (map<Colour, Arrow*>::iterator arrow = northArrows_.begin(); arrow != northArrows_.end(); ++ arrow)
+	   out.push_back(arrow->second);
+   for (map<Colour, Arrow*>::iterator arrow = southArrows_.begin(); arrow != southArrows_.end(); ++ arrow)
+   	   out.push_back(arrow->second);
+ */
+}
+
+
+struct SortHelper
+{
+	SortHelper() {}
+	~SortHelper() {}
+	MAGICS_NO_EXPORT bool operator()(const Arrow* first, const Arrow* second)
+	{
+ 		return first->size() > second->size();
+	}
+};
+
+void ArrowPlotting::finish(BasicGraphicsObjectContainer& out)
+{	
+	if ( this->legend_only_) return;
+	unit_velocity_ = (  unit_velocity_ == 0 ) ? maxVelocity_ :  unit_velocity_;
+	vector<Arrow*> arrows;
+	for ( map<Colour, Arrow*>::iterator arrow = northArrows_.begin(); arrow != northArrows_.end(); ++arrow) 
+		arrows.push_back(arrow->second);
+	
+	for ( map<Colour, Arrow*>::iterator arrow = southArrows_.begin(); arrow != southArrows_.end(); ++arrow) 
+		arrows.push_back(arrow->second);
+	
+	 std::sort(arrows.begin(), arrows.end(), SortHelper());
+
+	// Now we feed the task...     
+	for (vector<Arrow* >::iterator arrow = arrows.begin(); arrow != arrows.end(); ++arrow) {
+		if ( !(*arrow)->empty() ) {
+		     (*arrow)->setScale(this->unit_velocity_);
+		     out.push_back(*arrow);
+		}
+	}
+	// and now we reset 
+	northArrows_.clear();
+	southArrows_.clear();
+}
+
+
+void ArrowPlotting::visit(LegendVisitor& legend)
+{
+   if ( !this->legend_ ) return;
+
+   WindPlotting::visit(legend);
+   // const double scale = legend.transformation().unitToCm(legend.absoluteWidth(), legend.absoluteHeight());
+   const double scale= 1.;
+
+   const double speed = (this->unit_velocity_) ? this->unit_velocity_ : this->maxVelocity_;
+   Arrow* arrow = new Arrow();
+   (*arrow).setColour(*this->colour_);
+   arrow->setThickness(this->thickness_);
+   arrow->setScale(scale);
+
+   arrow->setArrowPosition(this->origin_position_);
+   arrow->setHeadIndex(this->head_);
+   arrow->setHeadRatio(this->ratio_);
+
+   if ( legend_text_.empty() || legend_text_ == "vector" ) {
+	ostringstream text;
+   	text <<  speed << " "<< legend_unit_;
+   	legend_text_ = text.str();
+   }
+
+   LegendEntry * entry = new ArrowEntry(legend_text_, arrow);
+
+   legend.add(entry);
+   legend.add(new EmptyEntry());
+}
+
+
+void ArrowPlotting::visit(Data& data, PointsHandler& points, HistoVisitor& visitor)
+{
+    IntervalMap<Colour> beans;
+    if ( !visitor.basic() ) {
+
+	vector<double>::iterator from = this->levels_->begin();
+        vector<double>::iterator to = this->levels_->begin();
+        ++to;
+        for (;  to != this->levels_->end(); ++to)
+	{
+	    	Colour colour;	    	
+	    	if (magCompare(advanced_method_, "advanced") ||  
+		    magCompare(advanced_method_, "on") ) 
+		{	  	  	
+			colour=colourMethod_->right(*from);
+		}
+		else
+		{
+		  	colour=*this->colour_;;
+		} 	
+            	beans.insert(make_pair(Interval(*from, *to), colour ));
+            	++from;
+        }		  	
+    }
+    
+    Histogram helper;
+    helper.visit(beans, data, points, visitor);
+}  
\ No newline at end of file
diff --git a/src/visualisers/ArrowPlotting.h b/src/visualisers/ArrowPlotting.h
new file mode 100644
index 0000000..318b341
--- /dev/null
+++ b/src/visualisers/ArrowPlotting.h
@@ -0,0 +1,101 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ArrowPlotting.h
+    \brief Definition of the Template class ArrowPlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ArrowPlotting_H
+#define ArrowPlotting_H
+
+#include "magics.h"
+
+#include "WindPlotting.h"
+#include "ArrowPlottingAttributes.h"
+#include "Arrow.h"
+
+namespace magics {
+
+
+class ArrowPlotting: public WindPlotting, public ArrowPlottingAttributes{
+
+public:
+	ArrowPlotting()  {}
+	virtual ~ArrowPlotting() {}
+
+	virtual void set(const map<string, string>& map) 
+		{ WindPlottingAttributes::set(map); ArrowPlottingAttributes::set(map); }
+
+	virtual void set(const XmlNode& node) 
+		{ 
+		WindPlottingAttributes::set(node); 
+		ArrowPlottingAttributes::set(node); }
+	
+	void copy(const ArrowPlotting& other) { WindPlottingAttributes::copy(other); ArrowPlottingAttributes::copy(other); }
+	bool accept(const string& node) { return ArrowPlottingAttributes::accept(node); }
+
+	virtual WindPlotting* clone() {
+		ArrowPlotting* object = new ArrowPlotting();
+		object->copy(*this);
+		return object;
+	}
+	
+	Arrow* southArrow(const Colour&);
+	Arrow* northArrow(const Colour&);
+	
+	
+
+	virtual void operator()(const UserPoint&, const PaperPoint& point, double x, double y, double val);
+
+	virtual void prepare(BasicGraphicsObjectContainer& out, double res);	
+	virtual void prepare(BasicGraphicsObjectContainer&);	
+	virtual void finish(BasicGraphicsObjectContainer&);
+	void visit(LegendVisitor& legend);
+	void visit(Data&, PointsHandler&, HistoVisitor&);
+	
+protected:
+        //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const
+	 	{ out << "ArrowPlotting<P>"; } 
+	map<Colour, Arrow*> southArrows_;
+	map<Colour, Arrow*> northArrows_;
+	double  maxVelocity_;
+
+private:
+	//! Copy constructor - No copy allowed
+	ArrowPlotting(const ArrowPlotting&);
+	//! Overloaded << operator to copy - No copy allowed
+	ArrowPlotting& operator=(const ArrowPlotting&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ArrowPlotting& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/AutomaticContourMethod.h b/src/visualisers/AutomaticContourMethod.h
new file mode 100644
index 0000000..d84cf22
--- /dev/null
+++ b/src/visualisers/AutomaticContourMethod.h
@@ -0,0 +1,311 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file AutomaticContourMethod.h
+    \brief Definition of the Template class AutomaticContourMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 4-Oct-2004
+    
+    Changes:
+    
+*/
+
+#ifndef AutomaticContourMethod_H
+#define AutomaticContourMethod_H
+
+#include "magics.h"
+
+#include "ContourMethod.h"
+#include "Akima760Method.h"
+#include "MatrixHandler.h"
+#include "BasicSceneObject.h"
+#include "SampleContourMethodAttributes.h"
+
+
+
+namespace magics {
+
+
+class SampleContourMethod: public ContourMethod, public SampleContourMethodAttributes {
+
+public:
+	SampleContourMethod() {}
+	virtual ~SampleContourMethod() {}
+	ContourMethod* clone() { return new SampleContourMethod(); }
+	virtual bool accept(const string& node) { return magCompare(node, "sample"); }
+    void set(const XmlNode& node) { SampleContourMethodAttributes::set(node); }
+    void set(const map<string, string>& map) { SampleContourMethodAttributes::set(map); }
+    virtual MatrixHandler* handler(const AbstractMatrix& matrix, const BasicGraphicsObjectContainer&)
+    {
+    	MagLog::dev() << "ThinningMatrixHandler--> " << x_ << ", " << y_ << endl;
+        return new ThinningMatrixHandler(matrix, x_, y_);
+    }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out <<  "SampleContourMethod" << "\n"; }
+
+private:
+    //! Copy constructor - No copy allowed
+	SampleContourMethod(const SampleContourMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	SampleContourMethod& operator=(const SampleContourMethod&);
+
+};
+
+
+
+
+class AutomaticContourMethod: public ContourMethod {
+
+public:
+	         AutomaticContourMethod() {}
+	virtual ~AutomaticContourMethod() {}
+	ContourMethod* clone() { return new AutomaticContourMethod(); }
+	virtual bool accept(const string& node) { return magCompare(node, "automatic"); }
+
+    virtual MatrixHandler* handler(const AbstractMatrix& matrix, const BasicGraphicsObjectContainer& owner)
+    {
+        // this is the ideal number of points per cm on the paper
+        const double fDesiredPointsPerCm = 5.0;  
+
+        // do not allow the resolution to go beyond this
+        const double fMinSensibleContourResolution = 0.01;   
+
+        // if the computed resolution is within this much of the native resolution,
+        // then just use the native resolution
+        const double fAutoContourRoundupProportion = 0.05;  
+
+        // we use this to reduce the aggressiveness of the subsampling calculation;
+        // the higher the number, the less subsampling will be done.
+        const double fSampleAdjustment = 1.7;
+
+        MatrixHandler data(matrix);
+        MatrixHandler* pMatrixHandler;
+        if ( matrix.akimaEnable() == false ) {
+        		
+                    ContourMethod * pContourMethod =new  ContourMethod();
+
+                    pMatrixHandler = pContourMethod->handler(matrix, owner);
+
+                    MagLog::debug() << "Linear contouring, "    << "\n";
+                    return pMatrixHandler;
+        }
+
+        double fGeoAreaWidth;
+        double fGeoAreaHeight;
+        double fPaperAreaWidth;
+        double fPaperAreaHeight;
+        double fContourResolutionX;
+        double fContourResolutionY;
+        double fDataResolutionX;
+        double fDataResolutionY;
+        double fMinX, fMaxX;
+        double fMinY, fMaxY;
+        int    nSampleX = 1, nSampleY = 1;
+        
+
+        // find the dimensions of the paper on which we will plot
+        fPaperAreaWidth  = owner.absoluteWidth();
+        fPaperAreaHeight = owner.absoluteHeight();
+
+        // retrieve the data's resolution
+        fDataResolutionX = fabs (data.XResolution());
+        fDataResolutionY = fabs (data.YResolution());
+
+        // retrieve the geographical area being used
+        fMinX = data.minX();
+        fMaxX = data.maxX();
+        fMinY = data.minY();
+        fMaxY = data.maxY();
+
+
+        // if the points given are extreme values, then it means there are no
+        // grid points - in this case, for the purposes of the algorithm, we will
+        // pretend that there are 4 points
+        
+        if (fMinX == INT_MAX)    // yes, INT_MAX!
+        {
+            fMinX = 0.0;
+            fMaxX = fMinX + fDataResolutionX;
+            fMinY = 0.0;
+            fMaxY = fMinY + fDataResolutionY;
+        }
+        else
+        {
+            // if only one grid point is in the area, then we may get min and max the same,
+            // which causes problems because their difference is then 0 and it forces the
+            // maximum possible Akima interpolation.
+
+            if (fMinX == fMaxX) fMaxX = fMinX + fDataResolutionX;  // pretend that we have 2 points!
+            if (fMinY == fMaxY) fMaxY = fMinY + fDataResolutionY;  // pretend that we have 2 points!
+        }
+
+
+        fGeoAreaWidth  = fMaxX - fMinX;
+        fGeoAreaHeight = fMaxY - fMinY;
+
+        // calculate the resolutions we need in order to fulfil our 
+        // 'desired points per cm' criteria
+        fContourResolutionX = fGeoAreaWidth  / (fDesiredPointsPerCm * fPaperAreaWidth);
+        fContourResolutionY = fGeoAreaHeight / (fDesiredPointsPerCm * fPaperAreaHeight);
+
+        // clip it to sensible limits so that we don't go overboard on the Akima interpolation
+        // XXX we may need to revise this, given that we're not always in geo projection
+
+        if (fContourResolutionX < fMinSensibleContourResolution)
+        {
+            fContourResolutionX = fMinSensibleContourResolution;
+        }
+
+        // otherwise, if we don't need every data point, then we maybe need to subsample.
+        // for example, if our desired contouring resolution (fContourResolutionX) is to
+        // have one point every 1.0 degree, but our data (fDataResolutionX) is one point
+        // every 0.5 degrees, then we only need to take every second point.
+        // But on top of that, we want to be a little bit cautious about removing data points,
+        // so we make an adjustment to the computation so that we don't subsample too aggressively.
+
+        else if (fContourResolutionX > fDataResolutionX - (fDataResolutionX * fAutoContourRoundupProportion))
+        {
+            nSampleX = static_cast<int>(fContourResolutionX / (fDataResolutionX * fSampleAdjustment));
+            if (nSampleX < 1) nSampleX = 1;
+            fContourResolutionX = fDataResolutionX; // only needed if we end up with linear contouring
+        }
+
+
+
+        // do all the same again for the Y direction
+
+        if (fContourResolutionY < fMinSensibleContourResolution)
+        {
+            fContourResolutionY = fMinSensibleContourResolution;
+        }
+
+        else if (fContourResolutionY > fDataResolutionY - (fDataResolutionY * fAutoContourRoundupProportion))
+        {
+            nSampleY = static_cast<int>(fContourResolutionY / (fDataResolutionY * fSampleAdjustment));
+            if (nSampleY < 1) nSampleY = 1;
+            fContourResolutionY = fDataResolutionY; // only needed if we end up with linear contouring
+        }
+
+
+
+        // compute some values for debug output, including some safety checking
+        
+        int nNumColumns = matrix.columns();
+        int nNumRows    = matrix.rows();
+        double fCol0    = (nNumColumns == 0) ? 0.0 : matrix.column (0,0);
+        double fColN    = (nNumColumns == 0) ? 0.0 : matrix.column (0,matrix.columns() - 1);
+        double fRow0    = (nNumRows    == 0) ? 0.0 : matrix.row (0,0);
+        double fRowN    = (nNumRows    == 0) ? 0.0 : matrix.row (matrix.rows() - 1,0);
+
+        MagLog::debug() << "\n*************************************************************\n"
+                     << "Automatic contour method\n"
+                     << "Points per cm (desired): " << fDesiredPointsPerCm << "\n"
+                     << "Your data X: " << fMaxX << " to "  << fMinX << "\n"
+                     << "Your data Y: " << fMaxY << " to "  << fMinY << "\n"
+                     << "Resolution:[ " << fDataResolutionX << ", "  << fDataResolutionY << "]\n"
+                     << "Cols: "  << nNumColumns  << "  Rows: " << nNumRows << "\n"
+                     << "Col 0: " << fCol0 << " Col n: " << fColN << "\n"
+                     << "Row 0: " << fRow0 << " Row n: " << fRowN << "\n"
+                     << "Paper dimension: [" << fPaperAreaWidth << ", " << fPaperAreaHeight << "]\n";
+
+
+
+        // check for the 'sampling' case where we can subsample our data by 2 or more points
+/* do not use sampling anymore!
+        if ((nSampleX > 1) && (nSampleY > 1))
+        {
+            //SampleContourMethod *am = static_cast < SampleContourMethod *> (MagTranslator<string, ContourMethod >()("sampling"));
+            SampleContourMethod *am =new  SampleContourMethod();
+
+            auto_ptr<SampleContourMethod > pSampleContourMethod(am);
+
+            pSampleContourMethod->setX (nSampleX);
+            pSampleContourMethod->setY (nSampleY);
+
+            pMatrixHandler = pSampleContourMethod->handler(matrix, owner);
+
+            MagLog::debug() << "Sampling every " << nSampleX << "x" << nSampleY << "\n"
+                         << "Resolution: "    << fDataResolutionX * nSampleX << "x" << fDataResolutionY * nSampleY    << "\n";
+        }
+*/
+        // Check for the linear case (contour resolution == data resolution).
+        // Also need to use linear contouring if we have missing values, because Akima will
+        // incorrectly interpolate them. Missing data is also handled correctly if we have high-res
+        // data, because the sub-sampling method (above) uses no interpolation.
+        if ((nSampleX > 1) && (nSampleY > 1))   {
+            ContourMethod* cm = MagTranslator<string, ContourMethod >()("linear");
+            auto_ptr<ContourMethod > pContourMethod(cm);
+
+            pMatrixHandler = pContourMethod->handler(matrix, owner);
+
+            MagLog::debug() << "Linear contouring, Res: " << fContourResolutionX << "x" << fContourResolutionY    << "\n";
+        }
+        else if (((fContourResolutionX == fDataResolutionX) && (fContourResolutionY == fDataResolutionY)) ||
+                 data.hasMissingValues())
+        {
+            ContourMethod* cm = MagTranslator<string, ContourMethod >()("linear");
+            auto_ptr<ContourMethod > pContourMethod(cm);
+
+            pMatrixHandler = pContourMethod->handler(matrix, owner);
+
+            MagLog::debug() << "Linear contouring, Res: " << fContourResolutionX << "x" << fContourResolutionY    << "\n";
+        }
+
+        // otherwise we use the Akima760 method
+        else
+        {
+            Akima760Method *am = static_cast < Akima760Method *> (MagTranslator<string, ContourMethod >()("akima760"));
+			auto_ptr<Akima760Method > pAkima760Method(am);
+
+            pAkima760Method->resolutionX_ = (fContourResolutionX);
+            pAkima760Method->resolutionY_ =  (fContourResolutionY);
+
+            pMatrixHandler = pAkima760Method->handler(matrix, owner);
+
+            MagLog::debug() << "Akima 760, Res: " << fContourResolutionX << "x" << fContourResolutionY << "\n";
+        }
+
+        MagLog::debug()  << "\n*************************************************************\n";
+
+        return pMatrixHandler;
+    }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out <<  "AutomaticContourMethod" << "\n"; }
+
+private:
+    //! Copy constructor - No copy allowed
+	AutomaticContourMethod(const AutomaticContourMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	AutomaticContourMethod& operator=(const AutomaticContourMethod&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AutomaticContourMethod& p)
+		{ p.print(s); return s; }
+};
+
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Axis.cc b/src/visualisers/Axis.cc
new file mode 100644
index 0000000..e1cfeb1
--- /dev/null
+++ b/src/visualisers/Axis.cc
@@ -0,0 +1,699 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Axis.cc
+    \brief Implementation of the Template class Axis.
+
+    Magics Team - ECMWF 2004
+
+    Started: Fri 7-May-2004
+
+    Changes:
+
+ */
+
+#include "Axis.h"
+#include "MagLog.h"
+#include "Factory.h"
+#include "Layout.h"
+
+#include "Polyline.h"
+#include "Text.h"
+#include "Layer.h"
+#include "SceneVisitor.h"
+
+using namespace magics;
+
+Axis::Axis() : currentLabel_(0)
+{
+	labelHelpers_["number"] = &Axis::number;
+	labelHelpers_["label_list"] = &Axis::labellist;
+	labelHelpers_["latitude"] = &Axis::latitude;
+	labelHelpers_["longitude"] = &Axis::longitude;
+	labelHelpers_["date"] = &Axis::basic;
+	labelHelpers_["geoline"] = &Axis::basic;
+	title_position_ = -1;
+}
+
+Axis::~Axis() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+ */
+void Axis::print(ostream& out)  const
+{
+	out << "Axis[";
+	AxisAttributes::print(out);
+	out << "]";
+}
+
+VerticalAxis::VerticalAxis()
+{
+	if ( !magCompare(position_, "left") && !magCompare(position_, "right"))
+		position_ = "left";
+}
+
+HorizontalAxis::HorizontalAxis()
+{
+	if ( !magCompare(position_, "bottom") && !magCompare(position_, "top"))
+		position_ = "bottom";
+}
+
+
+
+void Axis::ticks(double min, double max, vector<double>& ticks)
+{
+	const double step = (max - min)/10.;
+	const double log = log10(step);
+	const double istep = pow(10., int(log));
+	const double inc = ceil(step/istep)*istep;
+	double first = floor(min/inc)*inc;
+
+	if (first > min) first -= inc;
+
+	for (double val = first; val <= max; val += inc) {
+		ticks.push_back(val);
+	}
+	ticks.push_back(ticks.back() + inc);
+}
+
+void Axis::visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors)
+{
+	// First we create the layer!
+	// and push It to the parent layer!
+	StaticLayer* axis = new NoDataLayer(this);
+	axis->id(iconName_);
+	axis->name(iconName_);
+	layer.add(axis);
+
+	for  (vector<LayoutVisitor*>::iterator visitor = visitors.begin(); visitor != visitors.end(); ++visitor) {
+		axis->set(*visitor);
+		(*visitor)->visit(*this);
+	}
+}
+
+void Axis::visit(TextVisitor& )
+{
+	// Nothing to put in the title
+
+}
+
+
+void VerticalAxis::tick(VerticalAxisVisitor& axis)
+{
+	if (!tick_) return;
+
+	double x1, x2;
+
+	axis.tick(x1, x2, magCompare(tick_position_ , "out"));
+
+	const Transformation& transformation = axis.transformation();
+
+	for (AxisItems::const_iterator y = items_.begin(); y != items_.end(); ++y)
+	{
+		if ( !(*y)->isTick() ) continue;
+		if ( !transformation.inY((*y)->position()) ) continue;
+
+		Polyline* tick = new Polyline();
+		PaperPoint p1 = PaperPoint(x1,  transformation.y((*y)->position()));
+		PaperPoint p2 = PaperPoint(x2, transformation.y((*y)->position()));
+		tick->push_back(p1);
+		tick->push_back(p2);
+		Colour calcol =  (tick_colour_->automatic()) ? *line_colour_ : *tick_colour_;
+		tick->setColour(calcol);
+		tick->setThickness(tick_thickness_);
+		axis.push_back(tick);
+	}
+
+}
+
+void HorizontalAxis::tick(HorizontalAxisVisitor& axis)
+{
+	if ( !tick_ )
+		return;
+
+	double y1, y2;
+	axis.tick(y1, y2, magCompare(tick_position_ , "out"));
+
+	const Transformation& transformation = axis.transformation();
+
+	for (AxisItems::const_iterator x = items_.begin(); x != items_.end(); ++x)
+	{
+		if ( !(*x)->isTick() ) continue;
+		if ( !transformation.inX((*x)->position()) ) continue;
+		Polyline* tick = new Polyline();
+		double px = transformation.x((*x)->position());
+		tick->push_back(PaperPoint(px, y1));
+		tick->push_back(PaperPoint(px, y2));
+		Colour calcol =  (tick_colour_->automatic()) ? *line_colour_ : *tick_colour_;
+		tick->setColour(calcol);
+		tick->setThickness(tick_thickness_);
+		axis.push_back(tick);
+	}
+
+}
+void HorizontalAxis::line(TopAxisVisitor& out) const
+{
+	if (!line_)
+		return;
+	PaperPoint from(out.minX(), out.minY());
+	PaperPoint to(out.maxX(), out.minY());
+
+	Polyline* axis =  new Polyline();
+
+	axis->setColour(*line_colour_);
+	axis->setThickness(line_thickness_);
+	axis->setLineStyle(line_style_);
+	axis->push_back(from);
+	axis->push_back(to);
+	out.push_back(axis);
+}
+
+void HorizontalAxis::line(BottomAxisVisitor& out) const
+{
+	if (!line_)
+		return;
+	PaperPoint from(out.minX(), out.maxY());
+	PaperPoint to(out.maxX(), out.maxY());
+
+	Polyline* axis = new Polyline();
+
+	axis->setColour(*line_colour_);
+	axis->setThickness(line_thickness_);
+	axis->setLineStyle(line_style_);
+	axis->push_back(from);
+	axis->push_back(to);
+	out.push_back(axis);
+}
+
+
+
+
+
+void VerticalAxis::line(LeftAxisVisitor& out) const
+{
+	if (!line_)
+		return;
+	PaperPoint from(out.maxX(), out.minY());
+	PaperPoint to(out.maxX(), out.maxY());
+
+	Polyline* axis = new Polyline();
+
+	axis->setColour(*line_colour_);
+	axis->setThickness(line_thickness_);
+	axis->setLineStyle(line_style_);
+	axis->push_back(from);
+	axis->push_back(to);
+	out.push_back(axis);
+}
+
+void VerticalAxis::line(RightAxisVisitor& out) const
+{
+	if (!line_)
+		return;
+	PaperPoint from(out.minX(), out.minY());
+	PaperPoint to(out.minX(), out.maxY());
+
+	Polyline* axis = new Polyline();
+
+	axis->setColour(*line_colour_);
+	axis->setThickness(line_thickness_);
+	axis->setLineStyle(line_style_);
+	axis->push_back(from);
+	axis->push_back(to);
+	out.push_back(axis);
+}
+
+void HorizontalAxis::label(HorizontalAxisVisitor& axis)
+{
+	if ( !label_ )
+		return;
+	Justification justification =  axis.justificationTickLabel(label_orientation_);
+	const Transformation& transformation = axis.transformation();
+	double angle = ( magCompare(label_orientation_, "horizontal") ) ? 0 : -1.57;
+	int count = -1;
+	map<int, double> positions;
+	double y1, y2;
+	axis.tick(y1, y2, magCompare(tick_position_, "out"));
+	positions[-1] = y1;
+	title_position_ = y1;
+	for (AxisItems::const_iterator x = items_.begin(); x != items_.end(); ++x)
+	{
+		    if ( !transformation.inX((*x)->position()) ) continue;
+			if ( (*x)->isLabel() == false)
+				continue;
+        	if ( (*x)->isFirst() && !label_first_ ) continue;
+        	if ( (*x)->isLast() && !label_last_ ) continue;
+        	string label = createLabel(**x);
+          if ( label.empty() ) continue;
+        	 count++;
+        	if ( count % label_frequency_  ) continue;
+
+		double height = ((*x)->height() == DBL_MIN || (*x)->height() == 0) ? label_height_ : (*x)->height();
+		double pos = axis.offsetTickLabel(height, (*x)->level());
+
+		map<int, double>::iterator p = positions.find((*x)->level());
+
+		if ( p !=  positions.end() ) {
+			pos = p->second;
+
+		}
+		else {
+			 p =  positions.find((*x)->level()-1);
+			 pos = axis.offsetTickLabel(height, p->second);
+			 positions[(*x)->level()] = pos;
+
+			 title_position_ = pos;
+		}
+
+		PaperPoint point(transformation.x((*x)->position()), pos);
+
+		bool out = false;
+		if ( magCompare(label_position_, "inter_tick") ) {
+			AxisItems::const_iterator next = x;
+			next++;
+			while ( next != items_.end() && !(*next)->isLabel() )
+				next++;
+			out = true;
+			if ( next != items_.end() && (*x)->level() == (*next)->level() ) {
+				//string nlabel = createLabel(**next);
+				const double x1 = transformation.x((*x)->position());
+				const double x2 = transformation.x((*next)->position());
+				point = PaperPoint((x2+x1)/2, pos);
+				out = (!transformation.inX((x2+x1)/2)) ;
+			}
+		}
+
+
+		if ( out )
+			continue;
+		Text* text = new Text();
+
+		Colour newcolour;
+		if ((*x)->colour() != "undef" )
+			newcolour =  Colour((*x)->colour());
+		else
+			newcolour =  (label_colour_->automatic()) ? *line_colour_ : *label_colour_;
+
+
+		MagFont font(label_font_);
+		font.colour(newcolour);
+		font.style(label_font_style_);
+	    font.size( height );
+
+	    text->setFont(font);
+	    text->setText(label);
+	    text->setJustification(justification);
+	    text->setVerticalAlign(MBOTTOM);
+	    text->setAngle(angle);
+
+	    text->push_back(point);
+	    axis.push_back(text);
+	 }
+}
+
+
+
+
+void VerticalAxis::label(VerticalAxisVisitor& axis)
+{
+	if ( !label_ )
+		return;
+	Justification justification =  axis.justificationTickLabel(label_orientation_);
+	const Transformation& transformation = axis.transformation();
+
+	int count = -1;
+	map<int, double> positions;
+	double x1, x2;
+	axis.tick(x1, x2, magCompare(tick_position_, "out"));
+	x1 = axis.offsetTickLabel(0.025, x1);
+	positions[-1] = x1;
+	title_position_ = x1;
+
+
+
+	PaperPoint point;
+
+	for (AxisItems::const_iterator y = items_.begin(); y != items_.end(); ++y)
+	{
+		if ( (*y)->isLabel() == false)
+			continue;
+		if ( !transformation.inY((*y)->position()) ) continue;
+
+		if ( (*y)->isFirst()   && !label_first_ ) continue;
+		if ( (*y)->isLast() && !label_last_ ) continue;
+		string label = createLabel(**y);
+
+		if ( label.empty() ) continue;
+		count++;
+		if ( count % label_frequency_  ) continue;
+
+
+		double height = ((*y)->height() == DBL_MIN || (*y)->height() == 0 ) ? label_height_ : (*y)->height();
+		double pos;
+		map<int, double>::iterator p = positions.find((*y)->level());
+
+		if ( p !=  positions.end() ) {
+			pos = p->second - axis.offsetTickLabel(height, 0);;
+		}
+		else {
+			p =  positions.find((*y)->level()-1);
+			pos =  p->second;
+			double newpos = axis.offsetTickLabel(height, p->second);
+			positions[(*y)->level()] = newpos;
+
+			title_position_ = newpos;
+		}
+        PaperPoint point(pos, transformation.y((*y)->position()));
+
+		bool out = false;
+
+
+		if ( magCompare(label_position_, "inter_tick") ) {
+			AxisItems::const_iterator next = y;
+			next++;
+			while ( next != items_.end() && !(*next)->isLabel() )
+				next++;
+			out = true;
+			if (next != items_.end() && (*y)->level() == (*next)->level()) {
+        			const double y1 = transformation.y((*y)->position());
+        			const double y2 = transformation.y((*next)->position());
+        			point = PaperPoint(pos, (y2+y1)/2);
+					out = !transformation.inY((y2+y1)/2);
+			}
+		}
+
+
+		if ( out)
+			continue;
+		Text* text = new Text();
+		text->setJustification(justification);
+		Colour newcolour =  (label_colour_->automatic()) ? *line_colour_ : *label_colour_;
+
+		MagFont font(label_font_);
+		font.colour(newcolour);
+		font.style(label_font_style_);
+		font.size(height);
+		text->setFont(font);
+		text->setText(label);
+		text->setJustification(justification);
+		text->setVerticalAlign(MHALF);
+		text->push_back(point);
+		axis.push_back(text);
+	}
+}
+
+string Axis::number(const AxisItem& in)
+{
+	return in.label();
+}
+
+string Axis::labellist(const AxisItem& in)
+{
+	if ( label_labels_.empty() )
+		return in.label();
+
+
+
+	if ( currentLabel_ < label_labels_.size() ) {
+		string label = label_labels_[currentLabel_];
+		currentLabel_++;
+
+		return label;
+	}
+	else
+		return label_labels_.empty() ? in.label() : label_labels_.back();
+
+}
+
+string Axis::latitude(const AxisItem& item)
+{
+	ostringstream lat;
+	string ns = "°";
+	if ( item.position() < 0 ) ns += "S";
+	if ( item.position() >= 0 ) ns += "N";
+	float y = float(maground(abs(item.position())*100)) / 100;
+	lat <<  y << ns;
+	return lat.str();
+}
+
+string Axis::longitude(const AxisItem& item)
+{
+
+		ostringstream lon;
+		string ew = "°";
+		if (  item.position() < 0 ) ew += "W";
+		if (  item.position() >= 0 ) ew += "E";
+		float x = float(maground(abs( item.position())*100)) / 100;
+		lon << x << ew;
+		return lon.str();
+
+}
+string Axis::basic(const AxisItem& item)
+{
+		return item.label();
+}
+
+string Axis::createLabel(const AxisItem& in)
+{
+
+	MagLog::dev() << "Axis::createLabel " << in << " with method : " << label_type_ << endl;
+
+	map<string,  LabelHelper >::iterator helper = labelHelpers_.find(lowerCase(label_type_));
+	if ( helper != labelHelpers_.end() )
+		return (this->*helper->second)(in);
+	else {
+		MagLog::warning() << "Could not the method " << label_type_ << " to setup axis labels..." << endl;
+		return in.label();
+	}
+
+
+
+}
+
+void HorizontalAxis::title(HorizontalAxisVisitor& out)
+{
+	if ( !title_ )
+		return;
+	Text* text = new Text();
+
+	MagFont font(title_font_, title_font_style_, title_height_);
+	font.colour((title_colour_->automatic()) ? *line_colour_ : *title_colour_);
+	text->setVerticalAlign(out.textAlignment("horizontal"));
+	text->setFont(font);
+	text->setText(title_text_);
+
+	double x = (out.minX() + out.maxX())/2;
+	text->push_back(PaperPoint(x, out.offsetTickLabel(title_height_, title_position_)));
+
+	out.push_back(text);
+}
+
+void VerticalAxis::title(VerticalAxisVisitor& out)
+{
+	if ( !title_ )
+		return;
+	double angle = out.angleTitle();
+	double x = title_position_;
+
+	Text* text = new Text();
+	MagFont font(title_font_, title_font_style_, title_height_);
+	font.colour((title_colour_->automatic()) ? *line_colour_ : *title_colour_);
+	text->setAngle(( title_orientation_ == "horizontal" ) ? 0 : angle);
+	text->setFont(font);
+	text->setText(title_text_);
+
+    double y = (out.minY() + out.maxY())/2;
+	text->push_back(PaperPoint(x, y));
+
+	out.push_back(text);
+}
+
+void HorizontalAxis::grid(DrawingVisitor& out) const
+{
+	if ( !grid_ )
+		return;
+
+	double bottom = out.minY();
+	double top = out.maxY();
+	double pos;
+
+	const Transformation& transformation = out.transformation();
+	for (AxisItems::const_iterator x = items_.begin(); x != items_.end(); ++x)
+    {
+    	if ( !(*x)->isGrid() ) continue;
+    	pos = (*x)->position();
+    	if ( !transformation.inX(pos) ) continue;
+		Polyline* grid = new Polyline();
+		grid->push_back(PaperPoint(transformation.x(pos), bottom));
+		grid->push_back(PaperPoint(transformation.x(pos), top));
+		if ( pos == grid_reference_level_  ) {
+			Colour colour = !grid_reference_colour_->automatic() ? *grid_reference_colour_ : *grid_colour_;
+			grid->setColour(colour);
+			grid->setLineStyle(grid_reference_style_);
+			grid->setThickness(grid_reference_thickness_);
+		}
+		else {
+			grid->setColour(*grid_colour_);
+			grid->setLineStyle(grid_style_);
+			grid->setThickness(grid_thickness_);
+		}
+
+		out.push_back(grid);
+    }
+}
+
+void VerticalAxis::grid(DrawingVisitor& out) const
+{
+	if ( !grid_ )
+		return;
+	double left = out.minX();
+	double right =  out.maxX();
+	double pos;
+	const Transformation& transformation = out.transformation();
+	for (AxisItems::const_iterator y = items_.begin(); y != items_.end(); ++y)
+    {
+    	if (!(*y)->isGrid() ) continue;
+    	pos = (*y)->position();
+    	if ( !transformation.inY(pos) ) continue;
+    	Polyline* grid = new Polyline();
+		grid->push_back(PaperPoint(left, transformation.y(pos)));
+		grid->push_back(PaperPoint(right, transformation.y(pos)));
+		if ( pos == grid_reference_level_  ) {
+				Colour colour = !grid_reference_colour_->automatic() ? *grid_reference_colour_ : *grid_colour_;
+				grid->setColour(colour);
+				grid->setLineStyle(grid_reference_style_);
+				grid->setThickness(grid_reference_thickness_);
+		}
+		else {
+				grid->setColour(*grid_colour_);
+				grid->setLineStyle(grid_style_);
+				grid->setThickness(grid_thickness_);
+		}
+		out.push_back(grid);
+		 }
+}
+
+void VerticalAxis::minortick(VerticalAxisVisitor& axis)
+{
+	if ( !minor_tick_ )
+		return;
+	double x1, x2;
+	axis.minortick(x1, x2, magCompare(tick_position_, "out"));
+
+	const Transformation& projection = axis.transformation();
+
+	for (AxisItems::const_iterator y = items_.begin(); y != items_.end(); ++y)
+    {
+
+	        if ( !(*y)->isMinorTick() ) continue;
+	        if ( !projection.inY((*y)->position()) ) continue;
+	        Polyline* tick = new Polyline();
+	        tick->push_back(PaperPoint(x1, (*y)->position()));
+	        tick->push_back(PaperPoint(x2, (*y)->position()));
+	        Colour calcol =  (minor_tick_colour_->automatic()) ? *tick_colour_ : *minor_tick_colour_;
+	        tick->setColour(calcol);
+	        tick->setThickness(minor_tick_thickness_);
+	        axis.push_back(tick);
+    }
+
+}
+
+void HorizontalAxis::minortick(HorizontalAxisVisitor& axis)
+{
+	if ( !minor_tick_ )
+	return;
+	double y1, y2;
+	axis.minortick(y1, y2, magCompare(tick_position_, "out") );
+	const Transformation& projection = axis.transformation();
+	for (AxisItems::const_iterator x = items_.begin(); x != items_.end(); ++x)
+    {
+
+	        if ( !(*x)->isMinorTick() ) continue;
+	        if ( !projection.inX((*x)->position()) ) continue;
+
+	        Polyline* tick = new Polyline();
+
+	        tick->push_back(PaperPoint((*x)->position(), y1));
+	        tick->push_back(PaperPoint((*x)->position(), y2));
+	        Colour calcol =  (minor_tick_colour_->automatic()) ? *tick_colour_ : *minor_tick_colour_;
+	        tick->setColour(calcol);
+	        tick->setThickness(minor_tick_thickness_);
+	        axis.push_back(tick);
+    }
+}
+
+
+void  HorizontalAxis::tip(TopAxisVisitor& out) const
+{
+
+}
+
+void  HorizontalAxis::tip(BottomAxisVisitor& out) const
+{
+	if ( !tip_ )
+		return;
+	Text* text = new Text();
+
+	MagFont font;
+	font.size(tip_height_);
+	font.colour((tip_colour_->automatic()) ? *label_colour_ : *tip_colour_);
+	text->setFont(font);
+	text->setText(tip_text_);
+	text->setVerticalAlign(MTOP);
+
+	double x = out.maxX() - (out.maxX() -  out.minX())*0.05;
+
+	text->push_back(PaperPoint(x, title_position_));
+
+	out.push_back(text);
+}
+
+void  VerticalAxis::tip(LeftAxisVisitor& out) const
+{
+	if (!tip_)
+		return;
+	double angle = out.angleTip();
+	const double x = title_position_;
+
+	Text* text = new Text();
+	MagFont font;
+	font.size(tip_height_);
+	font.colour((tip_colour_->automatic()) ? *label_colour_ : *tip_colour_);
+	text->setFont(font);
+	text->setText(tip_text_);
+
+	text->setAngle(( orientation_ == "horizontal" ) ? 0 : angle);
+
+	double y  = out.maxY() - (out.maxY() -  out.minY())*0.05;;
+
+
+	text->push_back(PaperPoint(x, y));
+
+	out.push_back(text);
+}
+
+void  VerticalAxis::tip(RightAxisVisitor& out) const
+{
+
+}
+
+
+
diff --git a/src/visualisers/Axis.h b/src/visualisers/Axis.h
new file mode 100644
index 0000000..032f664
--- /dev/null
+++ b/src/visualisers/Axis.h
@@ -0,0 +1,242 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Axis.h
+    \brief Definition of the Template class Axis.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Fri 7-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Axis_H
+#define Axis_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+#include "AxisAttributes.h"
+#include "XmlNode.h"
+#include "MagicsEvent.h"
+namespace magics {
+	
+class XmlNode;
+
+class SceneLayer;
+class LayoutVisitor;
+class AxisItem;
+
+class Axis: public BasicSceneObject, public AxisAttributes  {
+
+public:
+	Axis();
+	virtual ~Axis();
+ 
+    void set(const XmlNode& node ) { AxisAttributes::set(node); }
+    void set(const map<string, string>& map ) { AxisAttributes::set(map); }
+    
+    void visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors);
+    void visit(TextVisitor& );
+
+    virtual void tick(VerticalAxisVisitor&) {}
+    virtual void tick(HorizontalAxisVisitor&) {}
+
+    virtual void minortick(VerticalAxisVisitor&) {}
+    virtual void minortick(HorizontalAxisVisitor&) {}
+
+    virtual void label(VerticalAxisVisitor&) {}
+    virtual void label(HorizontalAxisVisitor&) {}
+
+    virtual void title(VerticalAxisVisitor&) {}
+    virtual void title(HorizontalAxisVisitor&) {}
+
+    virtual void line(TopAxisVisitor& out) const 		{}
+    virtual void line(BottomAxisVisitor& out) const 	{}
+    virtual void line(LeftAxisVisitor& out) const 		{}
+    virtual void line(RightAxisVisitor& out) const 	{}
+
+    virtual void tip(TopAxisVisitor& out) const 		{}
+       virtual void tip(BottomAxisVisitor& out) const 	{}
+       virtual void tip(LeftAxisVisitor& out) const 		{}
+       virtual void tip(RightAxisVisitor& out) const 	{}
+
+    virtual void grid(DrawingVisitor&) const {}
+
+    string createLabel(const AxisItem&);
+
+    double min() const { return method_->min(); }
+    double max() const { return method_->max(); }
+
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     void ticks(double, double, vector<double>&);
+     AxisItems items_;
+
+
+     typedef string (Axis::*LabelHelper)(const AxisItem&);
+     map<string,  LabelHelper> labelHelpers_;
+
+     string number(const AxisItem&);
+     string labellist(const AxisItem&);
+     string latitude(const AxisItem&);
+     string longitude(const AxisItem&);
+     string basic(const AxisItem&);
+     double title_position_;
+
+     int currentLabel_;
+private:
+    //! Copy constructor - No copy allowed
+	Axis(const Axis&);
+    //! Overloaded << operator to copy - No copy allowed
+	Axis& operator=(const Axis&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Axis& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class HorizontalAxis : public Axis 
+{
+public :
+    HorizontalAxis();
+    ~HorizontalAxis() {}
+    
+    template <class V> 
+    void build(V& visitor) {
+    	if ( items_ .empty() )  {   		
+    		method_->updateX(visitor.transformation());
+    	    method_->prepare(*this, items_);
+    	}
+    	line(visitor);
+    	tick(visitor);
+    	label(visitor);
+    	title(visitor);
+    	minortick(visitor);
+    	tip(visitor);
+
+
+    	
+    }
+    
+    void visit(DrawingVisitor& visitor) {
+    	if ( items_ .empty() ) {
+    		method_->updateX(visitor.transformation());
+    		method_->prepare(*this, items_);
+    	}
+    	grid(visitor);
+    }
+    
+    void visit(TopAxisVisitor& visitor) {
+    	if ( magCompare(position_, "top") )
+    		build(visitor); 
+    }
+    void visit(BottomAxisVisitor& visitor) {  
+    	if ( magCompare(position_, "bottom") ) 
+    		build(visitor); 
+    }
+    
+    void set(const XmlNode& node) { 
+    	if ( magCompare(node.name(), "horizontal_axis") ) {
+    		XmlNode axis = node;
+    		axis.name("axis");    		
+    		AxisAttributes::set(axis);
+    	} 
+    }
+
+    void minortick(HorizontalAxisVisitor&);
+    void tick(HorizontalAxisVisitor&);
+    void label(HorizontalAxisVisitor&);
+    void title(HorizontalAxisVisitor&);
+
+    void line(TopAxisVisitor& out) const;
+    void line(BottomAxisVisitor& out) const;
+
+    void tip(TopAxisVisitor& out) const;
+    void tip(BottomAxisVisitor& out) const;
+
+    void grid(DrawingVisitor&) const;
+
+};
+
+class VerticalAxis : public Axis 
+{
+public :
+    VerticalAxis();
+    ~VerticalAxis() {}
+    template <class V>
+    void build(V& visitor) {
+    	if ( items_ .empty() ) {
+    		method_->updateY(visitor.transformation());
+    		method_->prepare(*this, items_);
+    	}
+       line(visitor);
+       tick(visitor);
+       label(visitor);
+       title(visitor);
+       minortick(visitor);
+       tip(visitor);
+
+        
+    }
+    void visit(DrawingVisitor& visitor) {
+      	if ( items_ .empty() ) {
+      		method_->updateY(visitor.transformation());
+      		method_->prepare(*this, items_);
+      	}
+      	grid(visitor);
+      }
+    void visit(LeftAxisVisitor& visitor) { 
+    	if ( magCompare(position_, "left") )
+    		build(visitor); 
+    }
+    void visit(RightAxisVisitor& visitor) { 	
+    	if ( magCompare(position_, "right") )
+    		build(visitor); 
+    }
+    void set(const XmlNode& node) { 
+    	if ( magCompare(node.name(), "vertical_axis") ) {
+    		XmlNode axis = node;
+    		axis.name("axis");    		
+    		AxisAttributes::set(axis);
+    	} 
+    }
+    void tick(VerticalAxisVisitor&);
+    void minortick(VerticalAxisVisitor&);
+    void label(VerticalAxisVisitor&);
+    void title(VerticalAxisVisitor&);
+
+    void line(LeftAxisVisitor& out) const;
+    void line(RightAxisVisitor& out) const;
+
+    void tip(LeftAxisVisitor& out) const;
+    void tip(RightAxisVisitor& out) const;
+
+    void grid(DrawingVisitor&) const;
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/AxisAttributes.cc b/src/visualisers/AxisAttributes.cc
new file mode 100644
index 0000000..02d6f70
--- /dev/null
+++ b/src/visualisers/AxisAttributes.cc
@@ -0,0 +1,463 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file AxisAttributes.cc
+    \brief Implementation of Axis Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "AxisAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+AxisAttributes::AxisAttributes():
+	orientation_(ParameterManager::getString("axis_orientation")),
+	position_(ParameterManager::getString("axis_position")),
+	method_(MagTranslator<string, AxisMethod>().magics("axis_type")),
+	interval_(ParameterManager::getDouble("axis_tick_interval")),
+	positions_(ParameterManager::getDoubleArray("axis_tick_position_list")),
+	line_(ParameterManager::getBool("axis_line")),
+	line_colour_(MagTranslator<string, Colour>().magics("axis_line_colour")),
+	line_style_(MagTranslator<string, LineStyle>().magics("axis_line_style")),
+	line_thickness_(ParameterManager::getInt("axis_line_thickness")),
+	grid_(ParameterManager::getBool("axis_grid")),
+	grid_colour_(MagTranslator<string, Colour>().magics("axis_grid_colour")),
+	grid_style_(MagTranslator<string, LineStyle>().magics("axis_grid_line_style")),
+	grid_thickness_(ParameterManager::getInt("axis_grid_thickness")),
+	grid_reference_level_(ParameterManager::getDouble("axis_grid_reference_level")),
+	grid_reference_colour_(MagTranslator<string, Colour>().magics("axis_grid_reference_colour")),
+	grid_reference_style_(MagTranslator<string, LineStyle>().magics("axis_grid_reference_line_style")),
+	grid_reference_thickness_(ParameterManager::getInt("axis_grid_reference_thickness")),
+	title_(ParameterManager::getBool("axis_title")),
+	title_text_(ParameterManager::getString("axis_title_text")),
+	title_orientation_(ParameterManager::getString("axis_title_orientation")),
+	title_colour_(MagTranslator<string, Colour>().magics("axis_title_colour")),
+	title_height_(ParameterManager::getDouble("axis_title_height")),
+	title_font_(ParameterManager::getString("axis_title_font")),
+	title_font_style_(ParameterManager::getString("axis_title_font_style")),
+	tick_(ParameterManager::getBool("axis_tick")),
+	tick_position_(ParameterManager::getString("axis_tick_position")),
+	tick_colour_(MagTranslator<string, Colour>().magics("axis_tick_colour")),
+	tick_length_(ParameterManager::getDouble("axis_tick_size")),
+	tick_thickness_(ParameterManager::getInt("axis_tick_thickness")),
+	label_(ParameterManager::getBool("axis_tick_label")),
+	label_type_(ParameterManager::getString("axis_tick_label_type")),
+	label_frequency_(ParameterManager::getInt("axis_tick_label_frequency")),
+	label_first_(ParameterManager::getBool("axis_tick_label_first")),
+	label_last_(ParameterManager::getBool("axis_tick_label_last")),
+	label_position_(ParameterManager::getString("axis_tick_label_position")),
+	label_orientation_(ParameterManager::getString("axis_tick_label_orientation")),
+	label_font_(ParameterManager::getString("axis_tick_label_font")),
+	label_font_style_(ParameterManager::getString("axis_tick_label_font_style")),
+	label_colour_(MagTranslator<string, Colour>().magics("axis_tick_label_colour")),
+	label_height_(ParameterManager::getDouble("axis_tick_label_height")),
+	label_labels_(ParameterManager::getStringArray("axis_tick_label_list")),
+	label_format_(ParameterManager::getString("axis_tick_label_format")),
+	minor_tick_(ParameterManager::getBool("axis_minor_tick")),
+	minor_tick_count_(ParameterManager::getInt("axis_minor_tick_count")),
+	minor_tick_colour_(MagTranslator<string, Colour>().magics("axis_minor_tick_colour")),
+	minor_tick_thickness_(ParameterManager::getInt("axis_minor_tick_thickness")),
+	tip_(ParameterManager::getBool("axis_tip_title")),
+	tip_text_(ParameterManager::getString("axis_tip_title_text")),
+	tip_colour_(MagTranslator<string, Colour>().magics("axis_tip_title_colour")),
+	tip_height_(ParameterManager::getDouble("axis_tip_title_height")),
+	tip_quality_(ParameterManager::getString("axis_tip_title_quality"))
+{
+} 
+
+
+
+AxisAttributes::~AxisAttributes()
+{
+}
+
+    
+void AxisAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(0);
+
+	setAttribute(prefix, "axis_orientation", orientation_, params);
+	setAttribute(prefix, "axis_position", position_, params);
+	setMember(prefix, "axis_type", method_, params);
+	setAttribute(prefix, "axis_tick_interval", interval_, params);
+	setAttribute(prefix, "axis_tick_position_list", positions_, params);
+	setAttribute(prefix, "axis_line", line_, params);
+	setAttribute(prefix, "axis_line_colour", line_colour_, params);
+	setAttribute(prefix, "axis_line_style", line_style_, params);
+	setAttribute(prefix, "axis_line_thickness", line_thickness_, params);
+	setAttribute(prefix, "axis_grid", grid_, params);
+	setAttribute(prefix, "axis_grid_colour", grid_colour_, params);
+	setAttribute(prefix, "axis_grid_line_style", grid_style_, params);
+	setAttribute(prefix, "axis_grid_thickness", grid_thickness_, params);
+	setAttribute(prefix, "axis_grid_reference_level", grid_reference_level_, params);
+	setAttribute(prefix, "axis_grid_reference_colour", grid_reference_colour_, params);
+	setAttribute(prefix, "axis_grid_reference_line_style", grid_reference_style_, params);
+	setAttribute(prefix, "axis_grid_reference_thickness", grid_reference_thickness_, params);
+	setAttribute(prefix, "axis_title", title_, params);
+	setAttribute(prefix, "axis_title_text", title_text_, params);
+	setAttribute(prefix, "axis_title_orientation", title_orientation_, params);
+	setAttribute(prefix, "axis_title_colour", title_colour_, params);
+	setAttribute(prefix, "axis_title_height", title_height_, params);
+	setAttribute(prefix, "axis_title_font", title_font_, params);
+	setAttribute(prefix, "axis_title_font_style", title_font_style_, params);
+	setAttribute(prefix, "axis_tick", tick_, params);
+	setAttribute(prefix, "axis_tick_position", tick_position_, params);
+	setAttribute(prefix, "axis_tick_colour", tick_colour_, params);
+	setAttribute(prefix, "axis_tick_size", tick_length_, params);
+	setAttribute(prefix, "axis_tick_thickness", tick_thickness_, params);
+	setAttribute(prefix, "axis_tick_label", label_, params);
+	setAttribute(prefix, "axis_tick_label_type", label_type_, params);
+	setAttribute(prefix, "axis_tick_label_frequency", label_frequency_, params);
+	setAttribute(prefix, "axis_tick_label_first", label_first_, params);
+	setAttribute(prefix, "axis_tick_label_last", label_last_, params);
+	setAttribute(prefix, "axis_tick_label_position", label_position_, params);
+	setAttribute(prefix, "axis_tick_label_orientation", label_orientation_, params);
+	setAttribute(prefix, "axis_tick_label_font", label_font_, params);
+	setAttribute(prefix, "axis_tick_label_font_style", label_font_style_, params);
+	setAttribute(prefix, "axis_tick_label_colour", label_colour_, params);
+	setAttribute(prefix, "axis_tick_label_height", label_height_, params);
+	setAttribute(prefix, "axis_tick_label_list", label_labels_, params);
+	setAttribute(prefix, "axis_tick_label_format", label_format_, params);
+	setAttribute(prefix, "axis_minor_tick", minor_tick_, params);
+	setAttribute(prefix, "axis_minor_tick_count", minor_tick_count_, params);
+	setAttribute(prefix, "axis_minor_tick_colour", minor_tick_colour_, params);
+	setAttribute(prefix, "axis_minor_tick_thickness", minor_tick_thickness_, params);
+	setAttribute(prefix, "axis_tip_title", tip_, params);
+	setAttribute(prefix, "axis_tip_title_text", tip_text_, params);
+	setAttribute(prefix, "axis_tip_title_colour", tip_colour_, params);
+	setAttribute(prefix, "axis_tip_title_height", tip_height_, params);
+	setAttribute(prefix, "axis_tip_title_quality", tip_quality_, params);
+}
+
+void AxisAttributes::copy(const AxisAttributes& other)
+{
+	orientation_ = other.orientation_;
+	position_ = other.position_;
+	method_ = auto_ptr<AxisMethod>(other.method_->clone());
+	interval_ = other.interval_;
+	positions_ = other.positions_;
+	line_ = other.line_;
+	line_colour_ = auto_ptr<Colour>(other.line_colour_->clone());
+	line_style_ = other.line_style_;
+	line_thickness_ = other.line_thickness_;
+	grid_ = other.grid_;
+	grid_colour_ = auto_ptr<Colour>(other.grid_colour_->clone());
+	grid_style_ = other.grid_style_;
+	grid_thickness_ = other.grid_thickness_;
+	grid_reference_level_ = other.grid_reference_level_;
+	grid_reference_colour_ = auto_ptr<Colour>(other.grid_reference_colour_->clone());
+	grid_reference_style_ = other.grid_reference_style_;
+	grid_reference_thickness_ = other.grid_reference_thickness_;
+	title_ = other.title_;
+	title_text_ = other.title_text_;
+	title_orientation_ = other.title_orientation_;
+	title_colour_ = auto_ptr<Colour>(other.title_colour_->clone());
+	title_height_ = other.title_height_;
+	title_font_ = other.title_font_;
+	title_font_style_ = other.title_font_style_;
+	tick_ = other.tick_;
+	tick_position_ = other.tick_position_;
+	tick_colour_ = auto_ptr<Colour>(other.tick_colour_->clone());
+	tick_length_ = other.tick_length_;
+	tick_thickness_ = other.tick_thickness_;
+	label_ = other.label_;
+	label_type_ = other.label_type_;
+	label_frequency_ = other.label_frequency_;
+	label_first_ = other.label_first_;
+	label_last_ = other.label_last_;
+	label_position_ = other.label_position_;
+	label_orientation_ = other.label_orientation_;
+	label_font_ = other.label_font_;
+	label_font_style_ = other.label_font_style_;
+	label_colour_ = auto_ptr<Colour>(other.label_colour_->clone());
+	label_height_ = other.label_height_;
+	label_labels_ = other.label_labels_;
+	label_format_ = other.label_format_;
+	minor_tick_ = other.minor_tick_;
+	minor_tick_count_ = other.minor_tick_count_;
+	minor_tick_colour_ = auto_ptr<Colour>(other.minor_tick_colour_->clone());
+	minor_tick_thickness_ = other.minor_tick_thickness_;
+	tip_ = other.tip_;
+	tip_text_ = other.tip_text_;
+	tip_colour_ = auto_ptr<Colour>(other.tip_colour_->clone());
+	tip_height_ = other.tip_height_;
+	tip_quality_ = other.tip_quality_;
+} 
+
+
+bool AxisAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "axis")  )
+		return true;
+
+	if ( acceptNode(node, method_) )
+		return true;
+	return false;
+}
+
+void AxisAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "axis") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), method_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), method_, *(*elt)); 
+	}
+}
+
+void AxisAttributes::print(ostream& out)  const
+{
+	out << "AxisAttributes[";
+	out << "orientation = " << orientation_;
+	out << ", position = " << position_;
+	out << ", method = " << *method_;
+	out << ", interval = " << interval_;
+	out << ", positions = " << positions_;
+	out << ", line = " << line_;
+	out << ", line_colour = " << *line_colour_;
+	out << ", line_style = " << line_style_;
+	out << ", line_thickness = " << line_thickness_;
+	out << ", grid = " << grid_;
+	out << ", grid_colour = " << *grid_colour_;
+	out << ", grid_style = " << grid_style_;
+	out << ", grid_thickness = " << grid_thickness_;
+	out << ", grid_reference_level = " << grid_reference_level_;
+	out << ", grid_reference_colour = " << *grid_reference_colour_;
+	out << ", grid_reference_style = " << grid_reference_style_;
+	out << ", grid_reference_thickness = " << grid_reference_thickness_;
+	out << ", title = " << title_;
+	out << ", title_text = " << title_text_;
+	out << ", title_orientation = " << title_orientation_;
+	out << ", title_colour = " << *title_colour_;
+	out << ", title_height = " << title_height_;
+	out << ", title_font = " << title_font_;
+	out << ", title_font_style = " << title_font_style_;
+	out << ", tick = " << tick_;
+	out << ", tick_position = " << tick_position_;
+	out << ", tick_colour = " << *tick_colour_;
+	out << ", tick_length = " << tick_length_;
+	out << ", tick_thickness = " << tick_thickness_;
+	out << ", label = " << label_;
+	out << ", label_type = " << label_type_;
+	out << ", label_frequency = " << label_frequency_;
+	out << ", label_first = " << label_first_;
+	out << ", label_last = " << label_last_;
+	out << ", label_position = " << label_position_;
+	out << ", label_orientation = " << label_orientation_;
+	out << ", label_font = " << label_font_;
+	out << ", label_font_style = " << label_font_style_;
+	out << ", label_colour = " << *label_colour_;
+	out << ", label_height = " << label_height_;
+	out << ", label_labels = " << label_labels_;
+	out << ", label_format = " << label_format_;
+	out << ", minor_tick = " << minor_tick_;
+	out << ", minor_tick_count = " << minor_tick_count_;
+	out << ", minor_tick_colour = " << *minor_tick_colour_;
+	out << ", minor_tick_thickness = " << minor_tick_thickness_;
+	out << ", tip = " << tip_;
+	out << ", tip_text = " << tip_text_;
+	out << ", tip_colour = " << *tip_colour_;
+	out << ", tip_height = " << tip_height_;
+	out << ", tip_quality = " << tip_quality_;
+	out << "]" << "\n";
+}
+
+
+void AxisAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"axis\"";
+	 out << ", \"axis_orientation\":";
+	 niceprint(out,orientation_);
+	 out << ", \"axis_position\":";
+	 niceprint(out,position_);
+	 out << ", \"axis_type\":";
+	 method_->toxml(out);
+	 out << ", \"axis_tick_interval\":";
+	 niceprint(out,interval_);
+	 out << ", \"axis_tick_position_list\":";
+	 niceprint(out,positions_);
+	 out << ", \"axis_line\":";
+	 niceprint(out,line_);
+	 out << ", \"axis_line_colour\":";
+	 niceprint(out, *line_colour_);
+	 out << ", \"axis_line_style\":";
+	 niceprint(out,line_style_);
+	 out << ", \"axis_line_thickness\":";
+	 niceprint(out,line_thickness_);
+	 out << ", \"axis_grid\":";
+	 niceprint(out,grid_);
+	 out << ", \"axis_grid_colour\":";
+	 niceprint(out, *grid_colour_);
+	 out << ", \"axis_grid_line_style\":";
+	 niceprint(out,grid_style_);
+	 out << ", \"axis_grid_thickness\":";
+	 niceprint(out,grid_thickness_);
+	 out << ", \"axis_grid_reference_level\":";
+	 niceprint(out,grid_reference_level_);
+	 out << ", \"axis_grid_reference_colour\":";
+	 niceprint(out, *grid_reference_colour_);
+	 out << ", \"axis_grid_reference_line_style\":";
+	 niceprint(out,grid_reference_style_);
+	 out << ", \"axis_grid_reference_thickness\":";
+	 niceprint(out,grid_reference_thickness_);
+	 out << ", \"axis_title\":";
+	 niceprint(out,title_);
+	 out << ", \"axis_title_text\":";
+	 niceprint(out,title_text_);
+	 out << ", \"axis_title_orientation\":";
+	 niceprint(out,title_orientation_);
+	 out << ", \"axis_title_colour\":";
+	 niceprint(out, *title_colour_);
+	 out << ", \"axis_title_height\":";
+	 niceprint(out,title_height_);
+	 out << ", \"axis_title_font\":";
+	 niceprint(out,title_font_);
+	 out << ", \"axis_title_font_style\":";
+	 niceprint(out,title_font_style_);
+	 out << ", \"axis_tick\":";
+	 niceprint(out,tick_);
+	 out << ", \"axis_tick_position\":";
+	 niceprint(out,tick_position_);
+	 out << ", \"axis_tick_colour\":";
+	 niceprint(out, *tick_colour_);
+	 out << ", \"axis_tick_size\":";
+	 niceprint(out,tick_length_);
+	 out << ", \"axis_tick_thickness\":";
+	 niceprint(out,tick_thickness_);
+	 out << ", \"axis_tick_label\":";
+	 niceprint(out,label_);
+	 out << ", \"axis_tick_label_type\":";
+	 niceprint(out,label_type_);
+	 out << ", \"axis_tick_label_frequency\":";
+	 niceprint(out,label_frequency_);
+	 out << ", \"axis_tick_label_first\":";
+	 niceprint(out,label_first_);
+	 out << ", \"axis_tick_label_last\":";
+	 niceprint(out,label_last_);
+	 out << ", \"axis_tick_label_position\":";
+	 niceprint(out,label_position_);
+	 out << ", \"axis_tick_label_orientation\":";
+	 niceprint(out,label_orientation_);
+	 out << ", \"axis_tick_label_font\":";
+	 niceprint(out,label_font_);
+	 out << ", \"axis_tick_label_font_style\":";
+	 niceprint(out,label_font_style_);
+	 out << ", \"axis_tick_label_colour\":";
+	 niceprint(out, *label_colour_);
+	 out << ", \"axis_tick_label_height\":";
+	 niceprint(out,label_height_);
+	 out << ", \"axis_tick_label_list\":";
+	 niceprint(out,label_labels_);
+	 out << ", \"axis_tick_label_format\":";
+	 niceprint(out,label_format_);
+	 out << ", \"axis_minor_tick\":";
+	 niceprint(out,minor_tick_);
+	 out << ", \"axis_minor_tick_count\":";
+	 niceprint(out,minor_tick_count_);
+	 out << ", \"axis_minor_tick_colour\":";
+	 niceprint(out, *minor_tick_colour_);
+	 out << ", \"axis_minor_tick_thickness\":";
+	 niceprint(out,minor_tick_thickness_);
+	 out << ", \"axis_tip_title\":";
+	 niceprint(out,tip_);
+	 out << ", \"axis_tip_title_text\":";
+	 niceprint(out,tip_text_);
+	 out << ", \"axis_tip_title_colour\":";
+	 niceprint(out, *tip_colour_);
+	 out << ", \"axis_tip_title_height\":";
+	 niceprint(out,tip_height_);
+	 out << ", \"axis_tip_title_quality\":";
+	 niceprint(out,tip_quality_);
+}
+static MagicsParameter<string> axis_orientation("axis_orientation", "horizontal", "");
+static MagicsParameter<string> axis_position("axis_position", "automatic", "");
+static MagicsParameter<string> axis_type("axis_type", "regular", "");
+static MagicsParameter<double> axis_tick_interval("axis_tick_interval", INT_MAX, "Default changed from '1/7 of axis length' to'INT_MAX' ");
+static MagicsParameter<floatarray> axis_tick_position_list("axis_tick_position_list", floatarray(), "Units have changed from 'cm' to user coordinates");
+static MagicsParameter<string> axis_line("axis_line", "on", "");
+static MagicsParameter<string> axis_line_colour("axis_line_colour", "automatic", "");
+static MagicsParameter<string> axis_line_style("axis_line_style", "solid", "");
+static MagicsParameter<int> axis_line_thickness("axis_line_thickness", 2, "");
+static MagicsParameter<string> axis_grid("axis_grid", "off", "");
+static MagicsParameter<string> axis_grid_colour("axis_grid_colour", "yellow", "2.13.5 - Default changed fronm YELLOW to BLACK");
+static MagicsParameter<string> axis_grid_line_style("axis_grid_line_style", "solid", "");
+static MagicsParameter<int> axis_grid_thickness("axis_grid_thickness", 1, "");
+static MagicsParameter<double> axis_grid_reference_level("axis_grid_reference_level", INT_MAX, "");
+static MagicsParameter<string> axis_grid_reference_colour("axis_grid_reference_colour", "automatic", "");
+static MagicsParameter<string> axis_grid_reference_line_style("axis_grid_reference_line_style", "solid", "");
+static MagicsParameter<int> axis_grid_reference_thickness("axis_grid_reference_thickness", 2, "");
+static MagicsParameter<string> axis_title("axis_title", "on", "");
+static MagicsParameter<string> axis_title_text("axis_title_text", "", "");
+static MagicsParameter<string> axis_title_orientation("axis_title_orientation", "parallel", "");
+static MagicsParameter<string> axis_title_colour("axis_title_colour", "automatic", "");
+static MagicsParameter<double> axis_title_height("axis_title_height", 0.4, "");
+static MagicsParameter<string> axis_title_font("axis_title_font", "sansserif", "");
+static MagicsParameter<string> axis_title_font_style("axis_title_font_style", "normal", "");
+static MagicsParameter<string> axis_tick("axis_tick", "on", "");
+static MagicsParameter<string> axis_tick_position("axis_tick_position", "out", "");
+static MagicsParameter<string> axis_tick_colour("axis_tick_colour", "automatic", "");
+static MagicsParameter<double> axis_tick_size("axis_tick_size", 0.175, "");
+static MagicsParameter<int> axis_tick_thickness("axis_tick_thickness", 2, "");
+static MagicsParameter<string> axis_tick_label("axis_tick_label", "on", "");
+static MagicsParameter<string> axis_tick_label_type("axis_tick_label_type", "number", "");
+static MagicsParameter<int> axis_tick_label_frequency("axis_tick_label_frequency", 1, "");
+static MagicsParameter<string> axis_tick_label_first("axis_tick_label_first", "on", "");
+static MagicsParameter<string> axis_tick_label_last("axis_tick_label_last", "on", "");
+static MagicsParameter<string> axis_tick_label_position("axis_tick_label_position", "on_tick", "");
+static MagicsParameter<string> axis_tick_label_orientation("axis_tick_label_orientation", "horizontal", "");
+static MagicsParameter<string> axis_tick_label_font("axis_tick_label_font", "sansserif", "");
+static MagicsParameter<string> axis_tick_label_font_style("axis_tick_label_font_style", "", "");
+static MagicsParameter<string> axis_tick_label_colour("axis_tick_label_colour", "automatic", "");
+static MagicsParameter<double> axis_tick_label_height("axis_tick_label_height", 0.3, "");
+static MagicsParameter<stringarray> axis_tick_label_list("axis_tick_label_list", stringarray(), "");
+static MagicsParameter<string> axis_tick_label_format("axis_tick_label_format", "(automatic)", "");
+static MagicsParameter<string> axis_minor_tick("axis_minor_tick", "off", "");
+static MagicsParameter<int> axis_minor_tick_count("axis_minor_tick_count", 2, "");
+static MagicsParameter<string> axis_minor_tick_colour("axis_minor_tick_colour", "automatic", "");
+static MagicsParameter<int> axis_minor_tick_thickness("axis_minor_tick_thickness", 1, "");
+static MagicsParameter<string> axis_tip_title("axis_tip_title", "off", "");
+static MagicsParameter<string> axis_tip_title_text("axis_tip_title_text", " ", "");
+static MagicsParameter<string> axis_tip_title_colour("axis_tip_title_colour", "automatic", "");
+static MagicsParameter<double> axis_tip_title_height("axis_tip_title_height", 0.4, "");
+static MagicsParameter<string> axis_tip_title_quality("axis_tip_title_quality", "medium", "");
+#include "AxisMethod.h"
+#include "DateAxis.h"
+static SimpleObjectMaker<AxisMethod, AxisMethod> regular_AxisMethod("regular");
+static SimpleObjectMaker<PositionListAxisMethod, AxisMethod> position_list_PositionListAxisMethod("position_list");
+static SimpleObjectMaker<LogarithmicAxisMethod, AxisMethod> logarithmic_LogarithmicAxisMethod("logarithmic");
+static SimpleObjectMaker<DateAxisMethod, AxisMethod> date_DateAxisMethod("date");
+static SimpleObjectMaker<HyperAxisMethod, AxisMethod> geoline_HyperAxisMethod("geoline");
diff --git a/src/visualisers/AxisAttributes.h b/src/visualisers/AxisAttributes.h
new file mode 100644
index 0000000..872311e
--- /dev/null
+++ b/src/visualisers/AxisAttributes.h
@@ -0,0 +1,133 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file AxisAttributes.h
+    \brief Definition of Axis Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef AxisAttributes_H
+#define AxisAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "AxisMethod.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class AxisAttributes 
+{
+public:
+//  --  constructor
+    AxisAttributes();
+    
+//  --  destructor
+    virtual ~AxisAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const AxisAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string orientation_;
+	string position_;
+	auto_ptr<AxisMethod> method_;
+	double interval_;
+	floatarray positions_;
+	bool line_;
+	auto_ptr<Colour> line_colour_;
+	LineStyle line_style_;
+	int line_thickness_;
+	bool grid_;
+	auto_ptr<Colour> grid_colour_;
+	LineStyle grid_style_;
+	int grid_thickness_;
+	double grid_reference_level_;
+	auto_ptr<Colour> grid_reference_colour_;
+	LineStyle grid_reference_style_;
+	int grid_reference_thickness_;
+	bool title_;
+	string title_text_;
+	string title_orientation_;
+	auto_ptr<Colour> title_colour_;
+	double title_height_;
+	string title_font_;
+	string title_font_style_;
+	bool tick_;
+	string tick_position_;
+	auto_ptr<Colour> tick_colour_;
+	double tick_length_;
+	int tick_thickness_;
+	bool label_;
+	string label_type_;
+	int label_frequency_;
+	bool label_first_;
+	bool label_last_;
+	string label_position_;
+	string label_orientation_;
+	string label_font_;
+	string label_font_style_;
+	auto_ptr<Colour> label_colour_;
+	double label_height_;
+	stringarray label_labels_;
+	string label_format_;
+	bool minor_tick_;
+	int minor_tick_count_;
+	auto_ptr<Colour> minor_tick_colour_;
+	int minor_tick_thickness_;
+	bool tip_;
+	string tip_text_;
+	auto_ptr<Colour> tip_colour_;
+	double tip_height_;
+	string tip_quality_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const AxisAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/AxisItem.cc b/src/visualisers/AxisItem.cc
new file mode 100644
index 0000000..b25a471
--- /dev/null
+++ b/src/visualisers/AxisItem.cc
@@ -0,0 +1,139 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file AxisItem.cc
+    \brief Implementation of the Template class AxisItem.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 11-Oct-2005
+    
+    Changes:
+    
+*/
+
+
+#include "AxisItem.h"
+#include <locale>
+#include <DateTime.h>
+#include "MagLog.h"
+#include <cfloat>
+#include <Axis.h>
+using namespace magics;
+
+AxisItem::AxisItem(double position, const string label, int level) :
+	position_(position), label_(label), level_(level), colour_("undef"), height_(DBL_MIN) 
+{
+	
+}
+
+AxisItem::AxisItem(double position, const string label, int level, const string& colour, double height) :
+	position_(position), label_(label), level_(level), colour_(colour), height_(height)
+{
+	
+}
+AxisItem::AxisItem(double position) :
+	position_(position), label_(tostring(position)), level_(0),  colour_("undef"), height_(DBL_MIN)
+{
+	if ( same(position_, 0) ) position_ = 0;
+	char tmp[1024];
+
+	sprintf(tmp, "%g", position_);
+
+	label_ = string(tmp);
+
+}
+
+
+
+AxisHyperItem::AxisHyperItem(double position, vector<double>& values) : AxisItem(position)	
+{
+	// Specialised in lat/lon axis!!!
+	double lat = values[1];
+	double lon = values[0];
+	
+	ostringstream lab;
+		string ns = "°";
+		if ( lat < 0 ) ns += "S";
+		if ( lat >= 0 ) ns += "N";
+		float y = float(maground(abs(lat)*100)) / 100;
+		lab <<  y << ns;
+		
+		
+		string ew = "°";
+			if ( lon < 0 ) ew += "W";
+			if ( lon >= 0 ) ew += "E";
+			float x = float(maground(abs(lon)*100)) / 100;
+			lab << "/" << x << ew;
+			
+
+		label_ =  lab.str();    
+}
+
+AxisHyperItem::~AxisHyperItem()
+{
+	
+	
+}
+
+AxisItem::~AxisItem() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void AxisItem::print(ostream& out)  const
+{
+	out << "AxisItem[";
+	out << label_ << " at " << position_;
+	out << "]";
+}
+
+AxisDateItem::AxisDateItem(double position, DateTime date, int level, const string& colour, double height)
+ : AxisItem(position, "", level, colour, height), date_(date), defaultColour_("undef")
+{ 
+	//format("%w");
+	//if (label_ == "0" ) colour_ = "red"; // Sunday!
+}
+
+void AxisDateItem::format(const string& format, int digit) const
+{	
+	std::locale loc("");
+    
+	ostringstream out;
+	out.imbue(loc);
+
+	const std::time_put<char>& facet = std::use_facet<std::time_put<char> >(loc); 
+  
+	tm convert = date_;
+	facet.put(out, out, ' ', &convert, format.c_str(), format.c_str()+format.length());    
+	string label = (digit == -1 ) ?  out.str() : out.str().substr(0, digit);
+	label_ = label;
+	id_ = label;
+	
+	//MagLog::dev() << " add Day ---> " << label_ << "\n";
+}
+
+bool AxisDateItem::sunday() const
+{ 
+	format("%w", -1);
+	return  (label_ == "0" );
+}
+
+
diff --git a/src/visualisers/AxisItem.h b/src/visualisers/AxisItem.h
new file mode 100644
index 0000000..f412d35
--- /dev/null
+++ b/src/visualisers/AxisItem.h
@@ -0,0 +1,170 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file AxisItem.h
+    \brief Definition of the Template class AxisItem.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 11-Oct-2005
+    
+    Changes:
+    
+*/
+
+#ifndef AxisItem_H
+#define AxisItem_H
+
+#include "magics.h"
+#include "VectorOfPointers.h"
+#include "DateTime.h"
+
+
+
+namespace magics {
+
+class Axis;
+
+class AxisItem 
+{
+
+public:
+	AxisItem(double position, const string label, int level = 0);
+	AxisItem(double position, const string label, int level, const string& colour, double height);
+	AxisItem(double x);
+	virtual ~AxisItem();
+	virtual AxisItem* clone() const { 
+		AxisItem* item = new AxisItem(position_, label_, level_, colour_, height_); 
+		return item;
+		}
+	virtual const string& id() const { return label_; }
+
+	virtual void format(const string&, int) const     {}
+	
+	virtual bool sunday() const { return false; }
+
+	virtual bool date() const { return false; }
+	
+	virtual bool isFirst() { return false; } 
+	virtual bool isLast() { return false; } 
+	
+	double  position() const { return position_; }
+	void    position(double position) { position_ = position; }
+
+	const string& label() const { return label_; }
+	const string& colour() const { return colour_; } 
+	void  colour(const string& colour)   { colour_ = colour; } 
+	void  resetColour() const { colour_ = "undef"; }
+	double height() const                { return height_; }
+	void   height(double height) const   { height_ = height; }
+	void   label(const string& label) { label_ = label; }
+
+	
+	int         level()  { return level_; }
+	void           level(int level)  { level_ = level;  }
+	virtual void id(const string&) {}
+	
+	virtual bool isTick() const { return true; }
+	virtual bool isLabel() const { return true; }
+	virtual bool isGrid() const { return true; }
+	virtual bool isMinorTick() const { return false; }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     double   position_;
+     mutable string  label_;
+     int  level_;
+     mutable string  colour_;
+     mutable double  height_;
+    
+private:
+    //! Copy constructor - No copy allowed
+	AxisItem(const AxisItem&);
+    //! Overloaded << operator to copy - No copy allowed
+	AxisItem& operator=(const AxisItem&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AxisItem& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class AxisHyperItem : public AxisItem
+{
+public:
+	AxisHyperItem(double, vector<double>&);
+	~AxisHyperItem();
+};
+
+class AxisTickItem : public AxisItem
+{
+public:
+	AxisTickItem(double pos) : AxisItem(pos) { label_ = ""; }
+	~AxisTickItem() {}
+	bool isLabel() const { return false; }
+
+};
+
+class AxisDateItem : public AxisItem
+{
+public:
+	AxisDateItem(double position, DateTime date, int level = 0, const string& colour ="undef", double height = 0.3 );
+	~AxisDateItem() {}
+	AxisItem* clone() const {
+		AxisDateItem* item = new AxisDateItem(position_, date_, level_, colour_, height_);
+		return item; 
+	}
+	const string& id () const { return id_; }
+	void format(const string&, int) const;
+	
+	string label(const Axis&) const  { return label_; }
+
+	bool sunday() const;
+	
+	bool date() const { return true; }
+	void id(const string& id) {id_ = id; }
+	
+	bool isTick() const   { return false; }
+	bool isGrid() const   { return false; }
+
+protected:
+	DateTime date_;
+	mutable string defaultColour_;
+	mutable string id_;
+	
+};
+
+class AxisMinorTickItem : public AxisItem
+{
+public:
+	AxisMinorTickItem(double pos) : AxisItem(pos) { label_ = ""; }
+	~AxisMinorTickItem() {}
+	bool isTick() const   { return false; }
+	bool isLabel() const { return false; }
+	bool isGrid() const { return false; }
+	bool isMinorTick() const { return true; }
+};
+
+
+typedef VectorOfPointers<vector<AxisItem*> > AxisItems;
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/AxisMethod.cc b/src/visualisers/AxisMethod.cc
new file mode 100644
index 0000000..a44d3ac
--- /dev/null
+++ b/src/visualisers/AxisMethod.cc
@@ -0,0 +1,325 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file AxisMethod.cc
+    \brief Implementation of the Template class AxisMethod.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 7-Oct-2005
+    
+    Changes:
+    
+*/
+
+#include <limits>
+
+#include "AxisMethod.h"
+#include "Axis.h"
+#include "Transformation.h"
+
+using namespace magics;
+
+AxisMethod::AxisMethod() 
+{
+}
+
+AxisMethod::~AxisMethod() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void AxisMethod::print(ostream& out)  const
+{
+	out << "AxisMethod[";
+	out << "]";
+}
+
+void LogarithmicAxisMethod::prepare(const Axis& axis,  AxisItems& items)
+{
+
+	    vector<int> factor;
+	    factor.push_back(1);
+	    factor.push_back(2);
+	    factor.push_back(5);
+
+	    double min = axis.min();
+	    double max = axis.max();
+
+	    int s1 = (min < 0) ? -1: 1;
+	    int s2 = (max < 0) ? -1: 1;
+
+
+	    int log1 =  s1 *((min) ? log10(s1*min) : -5);
+	    int log2 =  s2 *((max) ? log10(s2*max) : -5);
+
+	    bool reduce = (min*max) < 0;
+
+	    std::set<double> ticks;
+
+	    double from = std::min(min, max);
+	    double to = std::max(min, max);
+
+	    for (int i = std::min(log1, log2); i <= std::max(log1, log2); i +=1 ) {
+	        for ( vector<int>::iterator f = factor.begin(); f != factor.end(); ++f) {
+
+	        	double x;
+	        	if ( !reduce || ( reduce && i > -4)  ) {
+	        		x = (*f) * exp10(i);
+	        		if ( from <= x  && x <= to && x != 0 )
+	        			ticks.insert(x);
+	        		x = -x;
+	        		if ( from <= x  && x <= to && x != 0 )
+	        			ticks.insert(x);
+	        	}
+	        	if ( !reduce || ( reduce && -i > -4   )) {
+	        		x = (*f) * exp10(-i);
+	        		if ( from <= x  && x <= to && x != 0 )
+	        			ticks.insert(x);
+	        		x = -x;
+	        		if ( from <= x  && x <= to && x != 0)
+	                	ticks.insert(x);
+	        	}
+	        }
+	    }
+
+
+
+	for ( std::set<double>::const_iterator step = ticks.begin(); step != ticks.end(); ++step) {
+		items.push_back(new AxisItem(*step));
+	}
+}
+
+void  HyperAxisMethod::updateX(const Transformation& transformation)
+{
+	hyperMin_ = transformation.getDataVectorMinX();
+	hyperMax_ = transformation.getDataVectorMaxX();
+	
+}
+
+void  HyperAxisMethod::updateY(const Transformation& transformation)
+{
+	hyperMin_ = transformation.getDataVectorMinY();
+	hyperMax_ = transformation.getDataVectorMaxY();
+}
+
+void HyperAxisMethod::prepare(const Axis& axis, AxisItems& items)
+{
+	double inc;
+	int nb = 7;
+	double step;
+	double log, ws;
+
+	double min = hyperMin_.front();
+	double max = hyperMax_.front();
+
+	double wmax = std::max(hyperMin_.front(), hyperMax_.front());
+	double wmin = std::min(hyperMin_.front(), hyperMax_.front());
+	
+	if (axis.interval_ == INT_MAX ) {
+	
+		while (nb < 20) {
+			step = (wmax-wmin)/nb;
+			log = log10(step);
+			ws = pow(10., int(log));
+			inc = ceil(step/ws)*ws;
+			MagLog::dev() << "Automatic method ---> increment = " << inc << " ---> try base=" << inc/ws << endl;
+			
+			 if ( wmax-wmin/inc > 5 && (inc/ws == 1 || inc/ws == 2 || inc/ws == 3 || inc/ws == 5 || inc/ws == 10) ) {
+				MagLog::dev() << "Automatic method ---> increment " << inc << " OK! " << endl;
+				break;
+			}
+			nb++;
+			
+		}
+	}
+	
+	else {
+		inc = axis.interval_;
+	}
+	std::set<double> list;
+	//list.insert(value(min));
+	//ist.insert(value(max));
+	
+	
+    if ( min < max ) {
+		double first = floor(min/inc) *inc;
+		double last  = 0.;    
+		for (double val = first;  val <= max; val+=inc) {
+			if (val >= min && val <=max) {
+				list.insert(value(val));
+        		last = val;
+			}
+		}
+		list.insert(value(last+inc));
+		
+	}
+	else {
+		double first = floor(min/inc) *inc;    
+		double last  = 0.;  
+		for (double val = first;  val >= max; val-=inc) {
+			if (val >= wmin && val <= wmax) {
+				list.insert(value(val));       		
+        		last = val;
+			}
+		}
+		list.insert(value(last-inc));
+	}
+    
+    double imin = hyperMin_[0];
+    double imax = hyperMax_[0];
+    double jmin = hyperMin_[1];
+    double jmax = hyperMax_[1];;
+    double iw = imax - imin;
+    double jw = jmax - jmin;
+    
+    for (std::set<double>::iterator i = list.begin(); i != list.end(); ++i) {
+    	vector<double> val;
+    	val.push_back(*i);
+    	double j = jmin+((*i)-imin)*(jw/iw);
+    	val.push_back(j);
+    	items.push_back( new AxisHyperItem(*i, val));
+    }
+}
+
+
+void AxisMethod::prepare(const Axis& axis, AxisItems& items)
+{
+	double inc;
+	int nb = 7;
+	double step;
+	double log, ws;
+
+
+	double min = axis.min();
+	double max = axis.max();
+
+	double wmax = std::max(min, max);
+	double wmin = std::min(min, max);
+	bool automatic = false;
+	
+	if (axis.interval_ == INT_MAX ) {
+		automatic = true;
+		while (nb < 20) {
+			step = (wmax-wmin)/nb;
+			log = log10(step);
+			ws = pow(10., int(log));
+			inc = ceil(step/ws)*ws;
+			MagLog::dev() << "Automatic method ---> increment = " << inc << " ---> try base=" << inc/ws << endl;
+			
+			 if ( wmax-wmin/inc > 5 && (inc/ws == 1 || inc/ws == 2 || inc/ws == 3 || inc/ws == 5 || inc/ws == 10) ) {
+				MagLog::dev() << "Automatic method ---> increment " << inc << " OK! " << endl;
+				break;
+			}
+			nb++;
+			
+		}
+	}
+	
+	else {
+		inc = axis.interval_;
+	}
+	std::set<double> list;
+
+	if ( min < max )
+	{
+		double first = floor(min/inc) *inc;
+		double last  = 0.;    
+		for (double val = first;  val <= max; val+=inc) {
+			if (val >= min && val <=max) {
+				list.insert(value(val));
+        		last = val;
+			}
+		}
+		list.insert(value(last+inc));
+	}
+	else
+	{
+		double first = floor(min/inc) *inc;    
+		double last  = 0.;  
+		for (double val = first;  val >= max; val-=inc) {
+			if (val >= wmin && val <= wmax) {
+				list.insert(value(val));       		
+        			last = val;
+			}
+		}
+		list.insert(value(last-inc));
+	}
+	std::set<double> slist;
+	int mod  = (list.size() / 10);
+	mod++;
+
+
+
+	int i = 0;
+	for ( std::set<double>::iterator e = list.begin(); e !=  list.end(); ++e) {
+		if ( !automatic )
+			slist.insert(*e);
+		else if ( i %  mod == 0 )
+			slist.insert(*e);
+
+		i++;
+	}
+
+
+	// First we add the minor tich before the first one...
+	std::set<double>::iterator front = slist.begin();
+	double first = *front - inc;
+	step = inc/(axis.minor_tick_count_+1);
+	for ( double ii = first; ii < *front; ii+=step ) {
+		items.push_back(new AxisMinorTickItem(ii));
+	}
+
+	double last = std::numeric_limits<double>::max();
+	for (std::set<double>::iterator i = front; i != slist.end(); ++i) {
+		// Add the minor Axis Items!!! 
+		if ( last != std::numeric_limits<double>::max()) {
+			double step = (*i-last)/(axis.minor_tick_count_+1);
+			for ( double ii = last +step; ii < *i; ii+=step ) {
+				items.push_back(new AxisMinorTickItem(ii));
+			}
+		}
+		last = *i;
+		addItem(items,*i);
+	}
+}
+
+void AxisMethod::updateX(const Transformation& transformation)
+{
+	min_ = transformation.getMinX();
+	max_ = transformation.getMaxX();
+
+}
+
+void AxisMethod::updateY(const Transformation& transformation)
+{
+	min_ = transformation.getMinY();
+	max_ = transformation.getMaxY();
+
+}
+
+void     PositionListAxisMethod::prepare(const Axis& axis, AxisItems& items)
+{
+	for ( vector<double>::const_iterator tick = axis.positions_.begin(); tick != axis.positions_.end(); ++tick)
+	{
+		items.push_back(new AxisItem(*tick));
+	}
+}
+
diff --git a/src/visualisers/AxisMethod.h b/src/visualisers/AxisMethod.h
new file mode 100644
index 0000000..d1e26cb
--- /dev/null
+++ b/src/visualisers/AxisMethod.h
@@ -0,0 +1,148 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file AxisMethod.h
+    \brief Definition of the Template class AxisMethod.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 7-Oct-2005
+    
+    Changes:
+    
+*/
+
+#ifndef AxisMethod_H
+#define AxisMethod_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "AxisItem.h"
+#include "Transformation.h"
+#include "AxisMethodAttributes.h"
+
+
+namespace magics {
+
+class Box;
+class Axis;
+
+class AxisMethod: public AxisMethodAttributes {
+
+public:
+	AxisMethod();
+	virtual ~AxisMethod();
+
+	AxisMethod* clone() { assert(false); }
+	virtual void set(const map<string, string>& map) {
+		AxisMethodAttributes::set(map);
+	}
+	virtual void set(const XmlNode& node) {
+			AxisMethodAttributes::set(node);
+		}
+    virtual void updateX(const Transformation&);
+    virtual void updateY(const Transformation&);
+    virtual void prepare(const Axis&, AxisItems&);
+
+
+    double min() const { return min_; }
+    double max() const { return max_; }
+
+    virtual void addItem(AxisItems& items, double val) const 
+    	{ items.push_back(new AxisItem(val));  }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 virtual double value(double val) const { return val; }
+	 double min_;
+	 double max_;
+
+private:
+    //! Copy constructor - No copy allowed
+	AxisMethod(const AxisMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	AxisMethod& operator=(const AxisMethod&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const AxisMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+class LogarithmicAxisMethod : public AxisMethod
+{
+public:
+	LogarithmicAxisMethod() {}
+	virtual ~LogarithmicAxisMethod() {}
+	void     prepare(const Axis&, AxisItems&);
+	
+	double value(double val) const { return exp10(val); }
+	
+
+  
+}; 
+class HyperAxisMethod : public AxisMethod
+{
+public:
+	HyperAxisMethod() {}
+	virtual ~HyperAxisMethod() {}
+	void     prepare(const Axis&, AxisItems&);
+	
+	
+	
+
+	 void updateX(const Transformation&);
+	 void updateY(const Transformation&);
+	 
+protected:
+	vector<double> hyperMin_;
+	vector<double> hyperMax_;
+	
+		
+}; 
+class PositionListAxisMethod : public AxisMethod
+{
+public:
+	PositionListAxisMethod() {}
+	virtual ~PositionListAxisMethod() {}
+	void     prepare(const Axis&, AxisItems&);
+}; 
+
+
+
+template <>
+class MagTranslator<string, AxisMethod> { 
+public:
+	AxisMethod* operator()(const string& val )
+	{
+		return SimpleObjectMaker<AxisMethod>::create(val);
+	}     
+
+	AxisMethod* magics(const string& param)
+	{
+		AxisMethod* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/AxisMethodAttributes.cc b/src/visualisers/AxisMethodAttributes.cc
new file mode 100644
index 0000000..e2cb71e
--- /dev/null
+++ b/src/visualisers/AxisMethodAttributes.cc
@@ -0,0 +1,91 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file AxisMethodAttributes.cc
+    \brief Implementation of AxisMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "AxisMethodAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+AxisMethodAttributes::AxisMethodAttributes()
+{
+} 
+
+
+
+AxisMethodAttributes::~AxisMethodAttributes()
+{
+}
+
+    
+void AxisMethodAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(0);
+
+}
+
+void AxisMethodAttributes::copy(const AxisMethodAttributes& other)
+{
+} 
+
+
+bool AxisMethodAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "")  )
+		return true;
+	return false;
+}
+
+void AxisMethodAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	set(node.attributes());
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void AxisMethodAttributes::print(ostream& out)  const
+{
+	out << "AxisMethodAttributes[";
+	out << "]" << "\n";
+}
+
+
+void AxisMethodAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"\"";
+}
diff --git a/src/visualisers/Bar.cc b/src/visualisers/Bar.cc
new file mode 100644
index 0000000..bd7c88e
--- /dev/null
+++ b/src/visualisers/Bar.cc
@@ -0,0 +1,417 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Bar.cc
+    \brief Implementation of the Template class Bar.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "Bar.h"
+#include "PointsHandler.h"
+#include "LegendVisitor.h"
+#include "Flag.h"
+#include "XmlNode.h"
+using namespace magics;
+
+Bar::Bar() 
+{
+	renderers_["bar"] = &Bar::fullbar;
+	renderers_["linebar"] = &Bar::linebar;
+}
+
+
+Bar::~Bar() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Bar::print(ostream& out)  const
+{
+	out << "Bar[";
+	out << "]";
+}
+void Bar::set(const XmlNode& node) { 
+		// Set the name to bar! 
+		XmlNode bar = node;
+        bar.name("bar");
+    	BarAttributes::set(bar); 
+		
+		
+    	Graph::set(node);
+    }
+void  Bar::visit(Transformation& transformation, Data&)
+{
+	if ( !annotation_.empty() )
+		transformation.needTopAxis(true);
+}
+
+void Bar::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	vector<double> xpos;
+	
+	vector<double> ypos;
+    
+    const Transformation& transformation= out.transformation();
+    double y = transformation.getMinY() + (transformation.getMaxY()-transformation.getMinY())*0.2;
+
+	CustomisedPointsList points; 
+	std::set<string> request;
+	request.insert("bar");
+
+	data.customisedPoints(out.transformation(), request, points, true);
+	if (points.empty()) return;
+	double previous =  (**points.begin())["x"];
+	double next =  (**points.begin())["x"];
+	double x, top, bottom, left, right;
+	
+	if (width_ == INT_MAX) {
+		if ( points.size() > 1 ) 
+			width_ = abs((*points[0])["x"] - (*points[1])["x"])*0.8;
+		else 
+			width_ = abs((*points[0])["x"] - (*points[1])["x"]);
+			 
+	}
+	
+	vector<string>::iterator annotation = annotation_.begin();
+	
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point)
+	{
+		
+		x = (**point)["x"];
+		next = ((point+1) != points.end() ) ? (**(point+1))["x"] : x;
+		bottom = (min_value_ == INT_MAX) ? (**point)["y_lower"]: min_value_;
+		top = (**point)["y_upper"];
+		
+		map<string,  Renderer>::iterator renderer = renderers_.find(lowerCase(bar_style_) );
+
+		if ( renderer != renderers_.end() ) {
+			(this->*renderer->second)(x, top, bottom, out);
+		}
+		else {
+			MagLog::warning() << "Coud not find the method " << bar_style_ << " to plot the bar\n"
+					<< "      Revert to default : bar " << endl;
+			fullbar(x, top, bottom, out);
+		}
+		
+
+		
+
+		PaperPoint xy(transformation.x(x), y);
+		if ( annotation != annotation_.end() && transformation.in(xy) ) {
+			Text* annot = new Text();
+			MagFont font;
+			font.colour(*annotation_colour_);
+			font.size(annotation_size_);
+			annot->setFont(font);
+			annot->setText(*annotation);
+			annot->setVerticalAlign(MBOTTOM);
+			annot->push_back(xy);
+			texts_.push_back(annot);
+			annotation++;
+		}
+		
+
+	}
+
+
+
+}
+
+void Bar::fullbar(double x, double top, double bottom, BasicGraphicsObjectContainer& out)
+{
+	const Transformation& transformation= out.transformation();
+	double left = x - width_/2;
+	double right = x + width_/2;
+	if ( justification_ == MLEFT ) {
+		left = x-width_;
+		right = x;
+	}
+	if ( justification_ == MRIGHT ) {
+			left = x;
+			right = x+width_;
+	}
+
+
+	Polyline* box  = new Polyline();
+	box->setColour(*line_colour_);
+
+	box->setThickness(thickness_);
+	box->setLineStyle(style_);
+
+	box->push_back(transformation(UserPoint(left, bottom)));
+	box->push_back(transformation(UserPoint(left, top)));
+	box->push_back(transformation(UserPoint(right, top)));
+	box->push_back(transformation(UserPoint(right, bottom)));
+	box->push_back(transformation(UserPoint(left, bottom)));
+
+	(*shade_)(*box);
+	if (clipping_) {
+		transformation(*box, out);
+	}
+	else
+		out.push_back(box);
+
+}
+
+void Bar::linebar(double x, double top, double bottom, BasicGraphicsObjectContainer& out)
+{
+	const Transformation& transformation= out.transformation();
+	double left = x - width_/2;
+	double right = x + width_/2;
+
+	Polyline* line  = new Polyline();
+	line->setColour(*line_colour_);
+	line->setThickness(thickness_);
+	line->setLineStyle(style_);
+	line->push_back(transformation(UserPoint(x, bottom)));
+	line->push_back(transformation(UserPoint(x, top)));
+
+
+	Polyline* topline = new Polyline();
+	topline->setColour(*line_colour_);
+	topline->setThickness(thickness_);
+	topline->setLineStyle(style_);
+	topline->push_back(transformation(UserPoint(left, top)));
+	topline->push_back(transformation(UserPoint(right, top)));
+
+	Polyline* bottomline = new Polyline();
+	bottomline->setColour(*line_colour_);
+	bottomline->setThickness(thickness_);
+	bottomline->setLineStyle(style_);
+	bottomline->push_back(transformation(UserPoint(left, bottom)));
+	bottomline->push_back(transformation(UserPoint(right, bottom)));
+
+	transformation(*line, out);
+	transformation(*topline, out);
+	transformation(*bottomline, out);
+}
+
+void Bar::visit(LegendVisitor& legend)
+{
+	if ( !legend_) return;
+	if ( magCompare(bar_style_, "bar") ) {
+		Polyline* curve  = new Polyline();
+		curve->setColour(*colour_);
+		curve->setLineStyle(style_);
+		curve->setThickness(thickness_);
+		curve->setFilled(true);
+		shade_->legend(*curve);
+		LegendEntry * entry = new BoxEntry(legend_text_, curve);
+		entry->userText(legend_text_);
+		legend.add(entry);
+	}
+	else if ( magCompare(bar_style_, "linebar") ) {
+		Polyline* curve  = new Polyline();
+		curve->setColour(*colour_);
+		curve->setLineStyle(style_);
+		curve->setThickness(thickness_);
+		curve->setFilled(true);
+		shade_->legend(*curve);
+		LegendEntry * entry = new LineEntry(legend_text_, curve);
+		entry->userText(legend_text_);
+		legend.add(entry);
+	}
+}
+
+GraphFlag::GraphFlag() 
+{}
+
+
+GraphFlag::~GraphFlag() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+
+void GraphFlag::print(ostream& out)  const
+{
+	out << "GraphFlag[";
+	out << "]";
+}
+
+
+
+void GraphFlag::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	CustomisedPointsList points; 
+	std::set<string> request;
+	request.insert("intensity");
+	request.insert("direction");
+	data.customisedPoints(out.transformation(), request, points, true);
+    
+    if (points.empty() ) return;
+	
+	Flag* flags = new Flag();
+	flags->setColour(*colour_); 
+	flags->setLength(length_);
+   
+	flags->setOriginMarker("magics_15");
+	flags->setOriginHeight(0.05);
+	flags->setConvention(KNOTS);
+	int i = 0;
+	double x, y, missing;
+	double intensity, direction;
+    
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		i++;
+       
+		x = (**point)["x"];
+		y = (**point)["y"];
+		missing  = ((*point)->find("intensity") != (*point)->end()) ? (**point)["missing"] : -99999999;
+        double lat = 10;
+        if ( (*point)->find("latitude") != (*point)->end() )
+            lat = (**point)["latitude"];
+        flags->setHemisphere(lat >0 ? NORTH: SOUTH);
+		if ( (*point)->find("intensity") != (*point)->end() && (*point)->find("direction") != (*point)->end() )   {
+			intensity = (**point)["intensity"];
+			direction = (**point)["direction"];
+			if ( intensity == missing || direction == missing) 
+				continue;	
+			PaperPoint pos(x, y);
+			flags->push_back(ArrowPoint(intensity, direction, pos));
+			flags->back().set(intensity, direction);
+		}
+	}
+	if ( !flags->empty() ) out.push_back(flags);	
+	
+	
+
+}
+
+
+
+
+
+
+
+void GraphFlag::visit(LegendVisitor& legend)
+{
+	if ( !legend_) return;
+	Flag* flags = new Flag();
+	flags->setColour(*colour_);
+	flags->setLength(length_);
+
+	flags->setOriginMarker("magics_15");
+	flags->setOriginHeight(0.05);
+	flags->setConvention(KNOTS);
+
+
+	 LegendEntry * entry = new FlagEntry(legend_text_, flags);
+	 legend.add(entry);
+
+}
+GraphArrow::GraphArrow() 
+{}
+
+
+GraphArrow::~GraphArrow() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+
+void GraphArrow::print(ostream& out)  const
+{
+	out << "GraphArrow[";
+	out << "]";
+}
+
+
+
+void GraphArrow::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	CustomisedPointsList points; 
+	std::set<string> request;
+	request.insert("intensity");
+	request.insert("direction");
+	data.customisedPoints(out.transformation(), request, points, true);
+	
+	Arrow* arrow = new Arrow();
+	arrow->setColour(*colour_); 
+	
+   
+	arrow->setOriginMarker("magics_15");
+	arrow->setOriginHeight(0.05);
+	arrow->setScale(unit_velocity_);
+	int i = 0;
+	double x, y, missing;
+	double intensity, direction;
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		i++;
+       
+		x = (**point)["x"];
+		y = (**point)["y"];
+		missing  = ((*point)->find("intensity") != (*point)->end()) ? (**point)["missing"] : -99999999;
+        
+		if ( (*point)->find("intensity") != (*point)->end() && (*point)->find("direction") != (*point)->end() )   {
+			intensity = (**point)["intensity"];
+			direction = (**point)["direction"];
+			if ( intensity == missing || direction == missing) 
+				continue;	
+			PaperPoint pos(x, y);
+			arrow->push_back(ArrowPoint(intensity, direction, pos));
+			arrow->back().set(intensity, direction);
+		}
+	}
+	if ( !arrow->empty() ) out.push_back(arrow);	
+	
+	
+
+}
+
+
+
+
+void Bar::visit(TopAxisVisitor& top)
+{
+
+	for ( vector<Text*>::iterator text = texts_.begin(); text != texts_.end(); ++text)
+		top.push_back(*text);
+
+
+}
+
+
+void GraphArrow::visit(LegendVisitor& legend)
+{
+	if ( !legend_) return;
+	Arrow* arrow = new Arrow();
+	arrow->setColour(*colour_);
+
+
+	arrow->setOriginMarker("magics_15");
+	arrow->setOriginHeight(0.05);
+	arrow->setScale(unit_velocity_);
+	
+
+
+	LegendEntry * entry = new ArrowEntry(legend_text_, arrow);
+
+	 legend.add(entry);
+}
diff --git a/src/visualisers/Bar.h b/src/visualisers/Bar.h
new file mode 100644
index 0000000..33818f8
--- /dev/null
+++ b/src/visualisers/Bar.h
@@ -0,0 +1,165 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Bar.h
+    \brief Definition of the Template class Bar.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Bar_H
+#define Bar_H
+
+#include "magics.h"
+
+#include "BarAttributes.h"
+#include "GraphFlagAttributes.h"
+#include "GraphArrowAttributes.h"
+#include "Curve.h"
+#include "Polyline.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+class Bar: public BarAttributes, public Graph {
+
+public:
+	Bar();
+	virtual ~Bar();
+    // Implements the set method ...
+    void set(const XmlNode& node);
+    void set(const map<string, string>& map) { 
+    	BarAttributes::set(map); 
+    	Graph::set(map);
+	}
+    
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    void visit(TopAxisVisitor&);
+    void visit(Transformation&, Data&);
+    
+    void fullbar(double, double, double, BasicGraphicsObjectContainer&);
+    void linebar(double, double, double, BasicGraphicsObjectContainer&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 vector<Text*> texts_;
+
+	 typedef void (Bar::*Renderer)(double, double, double, BasicGraphicsObjectContainer&);
+	 map<string,  Renderer> renderers_;
+
+
+
+
+
+private:
+    //! Copy constructor - No copy allowed
+	Bar(const Bar&);
+    //! Overloaded << operator to copy - No copy allowed
+	Bar& operator=(const Bar&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Bar& p)
+		{ p.print(s); return s; }
+
+};
+class GraphFlag: public GraphFlagAttributes, public Graph {
+
+public:
+	GraphFlag();
+	virtual ~GraphFlag();
+    
+    void set(const XmlNode& node) { 
+    	GraphFlagAttributes::set(node); 
+    	Graph::set(node);
+    }
+    
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { GraphFlagAttributes::set(map); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	GraphFlag(const GraphFlag&);
+    //! Overloaded << operator to copy - No copy allowed
+	GraphFlag& operator=(const GraphFlag&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GraphFlag& p)
+		{ p.print(s); return s; }
+
+};
+
+class GraphArrow: public GraphArrowAttributes, public Graph {
+
+public:
+	GraphArrow();
+	virtual ~GraphArrow();
+    
+    void set(const XmlNode& node) { 
+    	GraphArrowAttributes::set(node); 
+    	Graph::set(node);
+    }
+    
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { GraphArrowAttributes::set(map); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+ 
+
+
+private:
+    //! Copy constructor - No copy allowed
+	GraphArrow(const GraphArrow&);
+    //! Overloaded << operator to copy - No copy allowed
+	GraphArrow& operator=(const GraphArrow&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GraphArrow& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/BothValuePlotMethod.h b/src/visualisers/BothValuePlotMethod.h
new file mode 100644
index 0000000..2517be8
--- /dev/null
+++ b/src/visualisers/BothValuePlotMethod.h
@@ -0,0 +1,118 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BothValuePlotMethod.h
+    \brief Definition of the Template class BothValuePlotMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 26-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef BothValuePlotMethod_H
+#define BothValuePlotMethod_H
+
+#include "magics.h"
+
+#include "ValuePlotMethod.h"
+#include "ValuePlotMethodAttributes.h"
+#include "BothValuePlotMethodAttributes.h"
+#include "Symbol.h"
+
+namespace magics {
+	
+class Transformation;
+
+
+class BothValuePlotMethod: public ValuePlotMethod, public BothValuePlotMethodAttributes {
+
+public:
+	BothValuePlotMethod() : marker_(0) {
+        
+    }
+	virtual ~BothValuePlotMethod() {}
+    virtual void set(const map<string, string>& map ) { 
+        BothValuePlotMethodAttributes::set(map); 
+        ValuePlotMethodAttributes::set(map);
+    }
+    virtual void set(const XmlNode& node ) { 
+        BothValuePlotMethodAttributes::set(node); 
+        ValuePlotMethodAttributes::set(node);
+    }
+     virtual ValuePlotMethod* clone() const {
+    	BothValuePlotMethod* object = new BothValuePlotMethod();
+    	object->clone(*this);
+    	return object;
+    }
+    
+     virtual void clone(const BothValuePlotMethod& from )
+        { BothValuePlotMethodAttributes::copy(from); 
+        ValuePlotMethodAttributes::copy(from);}
+    
+    
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const {
+         out << "BothValuePlotMethod[";
+         BothValuePlotMethodAttributes::print(out);
+         ValuePlotMethodAttributes::print(out);
+         out << "]";
+	 }
+	 void reset() { marker_ = 0; }
+ 
+    virtual void add(const PaperPoint& xy) {    
+        if (!marker_) {
+            marker_ = new TextSymbol();
+            marker_->position(Symbol::M_ABOVE);
+            marker_->setMarker(markerIndex_);
+            marker_->setColour(*markerColour_);
+            marker_->setHeight(markerHeight_);
+            MagFont font;
+            font.size(this->height_);
+            font.colour(*this->colour_);
+            marker_->font(font);
+            this->push_back(marker_); 
+         }   
+         marker_->push_back(xy, this->label(xy.value()));
+     
+    }
+    
+    TextSymbol* marker_;
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	BothValuePlotMethod(const BothValuePlotMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	BothValuePlotMethod& operator=(const BothValuePlotMethod&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BothValuePlotMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/BothValuePlotMethodAttributes.cc b/src/visualisers/BothValuePlotMethodAttributes.cc
new file mode 100644
index 0000000..fe48572
--- /dev/null
+++ b/src/visualisers/BothValuePlotMethodAttributes.cc
@@ -0,0 +1,125 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BothValuePlotMethodAttributes.cc
+    \brief Implementation of BothValuePlotMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "BothValuePlotMethodAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BothValuePlotMethodAttributes::BothValuePlotMethodAttributes():
+	markerHeight_(ParameterManager::getDouble("contour_grid_value_marker_height")),
+	markerColour_(MagTranslator<string, Colour>().magics("contour_grid_value_marker_colour")),
+	markerQuality_(ParameterManager::getString("contour_grid_value_marker_qual")),
+	markerIndex_(ParameterManager::getInt("contour_grid_value_marker_index"))
+{
+} 
+
+
+
+BothValuePlotMethodAttributes::~BothValuePlotMethodAttributes()
+{
+}
+
+    
+void BothValuePlotMethodAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(3);
+	prefix[0] = "contour_grid_value";
+	prefix[1] = "contour_grid_value";
+	prefix[2] = "contour";
+
+	setAttribute(prefix, "contour_grid_value_marker_height", markerHeight_, params);
+	setAttribute(prefix, "contour_grid_value_marker_colour", markerColour_, params);
+	setAttribute(prefix, "contour_grid_value_marker_qual", markerQuality_, params);
+	setAttribute(prefix, "contour_grid_value_marker_index", markerIndex_, params);
+}
+
+void BothValuePlotMethodAttributes::copy(const BothValuePlotMethodAttributes& other)
+{
+	markerHeight_ = other.markerHeight_;
+	markerColour_ = auto_ptr<Colour>(other.markerColour_->clone());
+	markerQuality_ = other.markerQuality_;
+	markerIndex_ = other.markerIndex_;
+} 
+
+
+bool BothValuePlotMethodAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "both")  )
+		return true;
+	return false;
+}
+
+void BothValuePlotMethodAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "both") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void BothValuePlotMethodAttributes::print(ostream& out)  const
+{
+	out << "BothValuePlotMethodAttributes[";
+	out << "markerHeight = " << markerHeight_;
+	out << ", markerColour = " << *markerColour_;
+	out << ", markerQuality = " << markerQuality_;
+	out << ", markerIndex = " << markerIndex_;
+	out << "]" << "\n";
+}
+
+
+void BothValuePlotMethodAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"both\"";
+	 out << ", \"contour_grid_value_marker_height\":";
+	 niceprint(out,markerHeight_);
+	 out << ", \"contour_grid_value_marker_colour\":";
+	 niceprint(out, *markerColour_);
+	 out << ", \"contour_grid_value_marker_qual\":";
+	 niceprint(out,markerQuality_);
+	 out << ", \"contour_grid_value_marker_index\":";
+	 niceprint(out,markerIndex_);
+}
+static MagicsParameter<double> contour_grid_value_marker_height("contour_grid_value_marker_height", 0.25, "");
+static MagicsParameter<string> contour_grid_value_marker_colour("contour_grid_value_marker_colour", "red", "");
+static MagicsParameter<string> contour_grid_value_marker_qual("contour_grid_value_marker_qual", "low", "");
+static MagicsParameter<int> contour_grid_value_marker_index("contour_grid_value_marker_index", 3, "");
diff --git a/src/visualisers/Boundaries.cc b/src/visualisers/Boundaries.cc
new file mode 100644
index 0000000..89ab77c
--- /dev/null
+++ b/src/visualisers/Boundaries.cc
@@ -0,0 +1,171 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Boundaries.cc
+    \brief Implementation of the Template class BoundariesBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 29-Aug-2006
+    
+    Changes:
+	     2010 JUL change from mapgen to shp
+    
+*/
+
+
+#include "Boundaries.h"
+#include "Polyline.h"
+#include "UserPoint.h"
+#include "ShapeDecoder.h"
+
+using namespace magics;
+
+Boundaries::Boundaries() 
+{
+}
+
+Boundaries::~Boundaries() 
+{
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Boundaries::print(ostream& out)  const
+{
+	out << "Boundaries[";
+	BoundariesAttributes::print(out);
+	out << "]";
+}
+
+
+void Boundaries::operator()(const map<string, string>& setting, BasicGraphicsObjectContainer& task)
+{
+	ShapeDecoder boundaries, disputed;    
+    boundaries.needHoles(true);
+    disputed.needHoles(true);
+
+	const string political_boundaries = setting.find("boundaries")->second;
+	const string administrative_boundaries = setting.find("administrative_boundaries")->second;
+	const string share_folder = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_;
+
+	string file = share_folder + political_boundaries;
+
+	boundaries.setPath(file);
+	vector<string> treaty;
+	treaty.push_back("Treaty");
+	treaty.push_back("Country_Boundary");
+
+	boundaries.decode(task.transformation(), "featurecla", treaty);
+	const Transformation& transformation = task.transformation();
+	
+	if ( admistrative_)
+	{
+		ShapeDecoder admistrative;
+        admistrative.needHoles(true);
+		file = share_folder + administrative_boundaries;
+
+		admistrative.setPath(file);
+		admistrative.decode(task.transformation(),"iso", administrative_list_);
+		const Transformation& transformation = task.transformation();
+
+		for ( ShapeDecoder::const_iterator boundary = admistrative.begin(); boundary != admistrative.end(); ++boundary)
+		{
+			Polyline poly;
+			poly.setColour( administrative_colour_->automatic() ? *colour_ : *administrative_colour_);
+			poly.setThickness(administrative_thickness_);
+			poly.setLineStyle(administrative_style_);
+
+
+			(**boundary).setToFirst();
+			while ((**boundary).more())
+			{
+				  poly.push_back(transformation((**boundary).current()));
+				  (**boundary).advance();
+			}
+			transformation(poly, task);
+		}
+	}
+
+	for ( ShapeDecoder::const_iterator boundary = boundaries.begin(); boundary != boundaries.end(); ++boundary)
+	{
+		Polyline poly;
+		poly.setColour(*colour_);
+		poly.setThickness(thickness_);
+		poly.setLineStyle(style_);
+		
+		(**boundary).setToFirst();
+		while ((**boundary).more())
+		{
+			  poly.push_back(transformation((**boundary).current()));
+			  (**boundary).advance();
+		}
+		transformation(poly, task);
+	}
+	
+	if ( disputed_)
+	{
+		ShapeDecoder disputed;
+        disputed.needHoles(true);
+	
+		vector<string> dis;
+		dis.push_back("Disputed");
+		file = share_folder + political_boundaries;
+	
+		disputed.setPath(file);
+		disputed.decode(task.transformation(),"featurecla", dis);
+		const Transformation& transformation = task.transformation();
+
+		for ( ShapeDecoder::const_iterator boundary = disputed.begin(); boundary != disputed.end(); ++boundary)
+		{
+			Polyline poly;
+			poly.setColour( disputed_colour_->automatic() ? *colour_ : *disputed_colour_);
+			poly.setThickness(disputed_thickness_);
+			poly.setLineStyle(disputed_style_);
+
+
+			(**boundary).setToFirst();
+			while ((**boundary).more())
+			{
+			  poly.push_back(transformation((**boundary).current()));
+			  (**boundary).advance();
+			}
+			transformation(poly, task);
+		}
+	}
+}
+
+
+NoBoundaries::NoBoundaries() 
+{
+}
+
+NoBoundaries::~NoBoundaries() 
+{
+}
+
+void NoBoundaries::print(ostream& out)  const
+{
+	out << "NoBoundaries[";
+	out << "]";
+}
+
+
+
diff --git a/src/visualisers/Boundaries.h b/src/visualisers/Boundaries.h
new file mode 100644
index 0000000..9f97f9f
--- /dev/null
+++ b/src/visualisers/Boundaries.h
@@ -0,0 +1,134 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Boundaries.h
+    \brief Definition of the Template class NoBoundaries.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 29-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef Boundaries_H
+#define Boundaries_H
+
+#include "BoundariesAttributes.h"
+#include "BasicGraphicsObject.h"
+#include "SceneVisitor.h"
+
+namespace magics {
+	
+class NoBoundaries {
+
+public:
+	NoBoundaries();
+	virtual ~NoBoundaries();
+    
+	virtual void set(const XmlNode&) {}
+	virtual bool accept(const string&) { return false; }
+	virtual void set(const map<string, string>&) {}
+	virtual NoBoundaries* clone() const
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new NoBoundaries();
+	}
+
+	virtual void toxml(ostream&, int = 0) const
+	{
+		MagLog::dev() << "NoBoundaries::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+	}
+
+	virtual void operator()(const map<string, string>&, BasicGraphicsObjectContainer&) {}
+    
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	NoBoundaries(const NoBoundaries&);
+	//! Overloaded << operator to copy - No copy allowed
+	NoBoundaries& operator=(const NoBoundaries&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoBoundaries& p)
+		{ p.print(s); return s; }
+};
+
+
+template <>
+class MagTranslator<string, NoBoundaries> { 
+public:
+	NoBoundaries* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoBoundaries>::create(val);
+	}     
+
+	NoBoundaries* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+
+class Boundaries : public NoBoundaries, public BoundariesAttributes {
+
+public:
+	Boundaries();
+	virtual ~Boundaries();
+    
+	virtual void set(const XmlNode& node)
+	{
+		BoundariesAttributes::set(node);
+	}
+
+	virtual void set(const map<string, string>& map)
+	{
+		BoundariesAttributes::set(map);
+	}
+
+	bool accept(const string& node) { return BoundariesAttributes::accept(node); }   
+
+	virtual NoBoundaries* clone() const
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new Boundaries();
+	}
+
+	void operator()(const map<string, string>&, BasicGraphicsObjectContainer&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	Boundaries(const Boundaries&);
+	//! Overloaded << operator to copy - No copy allowed
+	Boundaries& operator=(const Boundaries&);
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/BoundariesAttributes.h b/src/visualisers/BoundariesAttributes.h
new file mode 100644
index 0000000..da8fb9c
--- /dev/null
+++ b/src/visualisers/BoundariesAttributes.h
@@ -0,0 +1,93 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoundariesAttributes.h
+    \brief Definition of Boundaries Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef BoundariesAttributes_H
+#define BoundariesAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class BoundariesAttributes 
+{
+public:
+//  --  constructor
+    BoundariesAttributes();
+    
+//  --  destructor
+    virtual ~BoundariesAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const BoundariesAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	LineStyle style_;
+	auto_ptr<Colour> colour_;
+	int thickness_;
+	bool disputed_;
+	LineStyle disputed_style_;
+	auto_ptr<Colour> disputed_colour_;
+	int disputed_thickness_;
+	bool admistrative_;
+	stringarray administrative_list_;
+	LineStyle administrative_style_;
+	auto_ptr<Colour> administrative_colour_;
+	int administrative_thickness_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const BoundariesAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/BoxPlotBasicItem.h b/src/visualisers/BoxPlotBasicItem.h
new file mode 100644
index 0000000..55287b5
--- /dev/null
+++ b/src/visualisers/BoxPlotBasicItem.h
@@ -0,0 +1,332 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotBasicItem.h
+    \brief Definition of the Template class BoxPlotBasicItem.
+    \author Meteorological Visualisation Section, ECMWF
+
+    Started: Sep 2006
+
+*/
+
+#ifndef BoxPlotBasicItem_H
+#define BoxPlotBasicItem_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "Polyline.h"
+
+
+namespace magics {
+
+class CustomisedPoint;
+class PaperPoint;
+
+
+class NoBoxPlotBox {
+
+public:
+	NoBoxPlotBox() {}
+	virtual ~NoBoxPlotBox() {}
+	
+	void cm(double cm) { cm_ = cm; }
+	
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) { return false; }
+    virtual NoBoxPlotBox* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new NoBoxPlotBox();
+    }
+    virtual void toxml(ostream&) const {
+   		 MagLog::dev() << "toxml(ostream& out, int tab)---> to be checked!...\n";
+    }
+    virtual void operator()(BasicGraphicsObjectContainer&, const CustomisedPoint&) const {}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	 double cm_;
+
+private:
+    //! Copy constructor - No copy allowed
+	NoBoxPlotBox(const NoBoxPlotBox&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoBoxPlotBox& operator=(const NoBoxPlotBox&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoBoxPlotBox& p)
+		{ p.print(s); return s; }
+};
+
+
+class NoBoxPlotBoxBorder {
+
+public:
+	NoBoxPlotBoxBorder() {}
+	virtual ~NoBoxPlotBoxBorder() {}
+
+	void cm(double cm) { cm_ = cm; }
+
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) { return false; }
+    virtual NoBoxPlotBoxBorder* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new NoBoxPlotBoxBorder();
+    }
+    virtual void toxml(ostream&) const {
+   		 MagLog::dev() << "toxml(ostream& out, int tab)---> to be checked!...\n";
+    }
+
+    virtual void operator()(Polyline& poly) const { poly.setStroke(false); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const{} 
+	 double cm_;
+
+private:
+    //! Copy constructor - No copy allowed
+	NoBoxPlotBoxBorder(const NoBoxPlotBoxBorder&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoBoxPlotBoxBorder& operator=(const NoBoxPlotBoxBorder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoBoxPlotBoxBorder& p)
+		{ p.print(s); return s; }
+};
+
+
+template <>
+class MagTranslator<string, NoBoxPlotBoxBorder> { 
+public:
+	NoBoxPlotBoxBorder* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoBoxPlotBoxBorder>::create(val);
+	}     
+
+	NoBoxPlotBoxBorder* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+
+
+template <>
+class MagTranslator<string, NoBoxPlotBox> {
+public:
+	NoBoxPlotBox* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoBoxPlotBox>::create(val);
+	}
+
+	NoBoxPlotBox* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+
+class NoBoxPlotMedian {
+
+public:
+	NoBoxPlotMedian() {}
+	virtual ~NoBoxPlotMedian() {}
+	virtual bool accept(const string&) { return false; }
+	void cm(double cm) { cm_ = cm; }
+
+    virtual void set(const XmlNode&) {}
+    virtual void set(const map<string, string>&) {}
+    virtual NoBoxPlotMedian* clone() const { return new NoBoxPlotMedian(); }    
+    virtual void toxml(ostream&) const {}   
+
+    virtual void operator()(BasicGraphicsObjectContainer&, Polyline*) const {}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	 double cm_;
+
+private:
+    //! Copy constructor - No copy allowed
+	NoBoxPlotMedian(const NoBoxPlotMedian&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoBoxPlotMedian& operator=(const NoBoxPlotMedian&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoBoxPlotMedian& p)
+		{ p.print(s); return s; }
+};
+
+
+template <>
+class MagTranslator<string, NoBoxPlotMedian> { 
+public:
+	NoBoxPlotMedian* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoBoxPlotMedian>::create(val);
+	}
+
+	NoBoxPlotMedian* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+class NoBoxPlotWhisker {
+
+public:
+	NoBoxPlotWhisker() {}
+	virtual ~NoBoxPlotWhisker() {}
+	virtual bool accept(const string&) { return false; }
+
+	void cm(double cm) { cm_ = cm; }
+
+	virtual void set(const XmlNode&) {
+		MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+	}
+	virtual void set(const map<string, string>&) {
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+	}
+	virtual NoBoxPlotWhisker* clone() const {
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new NoBoxPlotWhisker();
+	}
+	virtual void toxml(ostream&) const {
+		MagLog::dev() << "toxml(ostream& out, int tab)---> to be checked!...\n";
+	}
+
+	virtual void top(BasicGraphicsObjectContainer&, const CustomisedPoint&) const {}
+	virtual void bottom(BasicGraphicsObjectContainer&, const CustomisedPoint&) const {}
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	 double cm_;
+
+private:
+    //! Copy constructor - No copy allowed
+	NoBoxPlotWhisker(const NoBoxPlotWhisker&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoBoxPlotWhisker& operator=(const NoBoxPlotWhisker&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoBoxPlotWhisker& p)
+		{ p.print(s); return s; }
+};
+
+
+
+template <>
+class MagTranslator<string, NoBoxPlotWhisker> { 
+public:
+	NoBoxPlotWhisker* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoBoxPlotWhisker>::create(val);
+	}     
+
+	NoBoxPlotWhisker* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+class NoBoxPlotWhiskerBorder {
+
+public:
+	NoBoxPlotWhiskerBorder() {}
+	virtual ~NoBoxPlotWhiskerBorder() {}
+	virtual bool accept(const string&) { return false; }
+
+	virtual void set(const XmlNode&) {
+		MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+	}
+	virtual void set(const map<string, string>&) {
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+	}
+	virtual NoBoxPlotWhiskerBorder* clone() const {
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new NoBoxPlotWhiskerBorder();
+	}
+	virtual void toxml(ostream& ) const {
+		MagLog::dev() << "toxml(ostream& out, int tab)---> to be checked!...\n";
+	}
+
+	virtual void operator()(Polyline&) const {}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	NoBoxPlotWhiskerBorder(const NoBoxPlotWhiskerBorder&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoBoxPlotWhiskerBorder& operator=(const NoBoxPlotWhiskerBorder&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoBoxPlotWhiskerBorder& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, NoBoxPlotWhiskerBorder> { 
+public:
+	NoBoxPlotWhiskerBorder* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoBoxPlotWhiskerBorder>::create(val);
+	}     
+
+	NoBoxPlotWhiskerBorder* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} //end namespace magics
+
+#endif
diff --git a/src/visualisers/BoxPlotBoxAttributes.cc b/src/visualisers/BoxPlotBoxAttributes.cc
new file mode 100644
index 0000000..4509c26
--- /dev/null
+++ b/src/visualisers/BoxPlotBoxAttributes.cc
@@ -0,0 +1,146 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotBoxAttributes.cc
+    \brief Implementation of BoxPlotBox Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotBoxAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotBoxAttributes::BoxPlotBoxAttributes():
+	colour_(MagTranslator<string, Colour>().magics("boxplot_box_colour")),
+	width_(ParameterManager::getDouble("boxplot_box_width")),
+	border_(MagTranslator<string, NoBoxPlotBoxBorder>().magics("boxplot_box_border")),
+	median_(MagTranslator<string, NoBoxPlotMedian>().magics("boxplot_median"))
+{
+} 
+
+
+
+BoxPlotBoxAttributes::~BoxPlotBoxAttributes()
+{
+}
+
+    
+void BoxPlotBoxAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "boxplot_box";
+	prefix[1] = "boxplot";
+
+	setAttribute(prefix, "boxplot_box_colour", colour_, params);
+	setAttribute(prefix, "boxplot_box_width", width_, params);
+	setMember(prefix, "boxplot_box_border", border_, params);
+	setMember(prefix, "boxplot_median", median_, params);
+}
+
+void BoxPlotBoxAttributes::copy(const BoxPlotBoxAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	width_ = other.width_;
+	border_ = auto_ptr<NoBoxPlotBoxBorder>(other.border_->clone());
+	median_ = auto_ptr<NoBoxPlotMedian>(other.median_->clone());
+} 
+
+
+bool BoxPlotBoxAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "box")  )
+		return true;
+
+	if ( acceptNode(node, border_) )
+		return true;
+
+	if ( acceptNode(node, median_) )
+		return true;
+	return false;
+}
+
+void BoxPlotBoxAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "box") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), border_, node);
+		setMember(node.name(), median_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), border_, *(*elt)); 
+		setMember((*elt)->name(), median_, *(*elt)); 
+	}
+}
+
+void BoxPlotBoxAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotBoxAttributes[";
+	out << "colour = " << *colour_;
+	out << ", width = " << width_;
+	out << ", border = " << *border_;
+	out << ", median = " << *median_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotBoxAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"box\"";
+	 out << ", \"boxplot_box_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"boxplot_box_width\":";
+	 niceprint(out,width_);
+	 out << ", \"boxplot_box_border\":";
+	 border_->toxml(out);
+	 out << ", \"boxplot_median\":";
+	 median_->toxml(out);
+}
+static MagicsParameter<string> boxplot_box_colour("boxplot_box_colour", "sky", "");
+static MagicsParameter<double> boxplot_box_width("boxplot_box_width", 1.0, "");
+static MagicsParameter<string> boxplot_box_border("boxplot_box_border", "on", "");
+static MagicsParameter<string> boxplot_median("boxplot_median", "on", "");
+#include "BoxPlotItem.h"
+#include "BoxPlotBasicItem.h"
+static SimpleObjectMaker<BoxPlotBoxBorder, NoBoxPlotBoxBorder> on_BoxPlotBoxBorder("on");
+static SimpleObjectMaker<BoxPlotBoxBorder, NoBoxPlotBoxBorder> border_BoxPlotBoxBorder("border");
+static SimpleObjectMaker<NoBoxPlotBoxBorder, NoBoxPlotBoxBorder> off_NoBoxPlotBoxBorder("off");
+static SimpleObjectMaker<NoBoxPlotBoxBorder, NoBoxPlotBoxBorder> noborder_NoBoxPlotBoxBorder("noborder");
+#include "BoxPlotItem.h"
+#include "BoxPlotBasicItem.h"
+static SimpleObjectMaker<BoxPlotMedian, NoBoxPlotMedian> on_BoxPlotMedian("on");
+static SimpleObjectMaker<BoxPlotMedian, NoBoxPlotMedian> median_BoxPlotMedian("median");
+static SimpleObjectMaker<NoBoxPlotMedian, NoBoxPlotMedian> off_NoBoxPlotMedian("off");
+static SimpleObjectMaker<NoBoxPlotMedian, NoBoxPlotMedian> nomedian_NoBoxPlotMedian("nomedian");
diff --git a/src/visualisers/BoxPlotBoxBorderAttributes.cc b/src/visualisers/BoxPlotBoxBorderAttributes.cc
new file mode 100644
index 0000000..4e6b43e
--- /dev/null
+++ b/src/visualisers/BoxPlotBoxBorderAttributes.cc
@@ -0,0 +1,117 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotBoxBorderAttributes.cc
+    \brief Implementation of BoxPlotBoxBorder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotBoxBorderAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotBoxBorderAttributes::BoxPlotBoxBorderAttributes():
+	colour_(MagTranslator<string, Colour>().magics("boxplot_box_border_colour")),
+	thickness_(ParameterManager::getInt("boxplot_box_border_thickness")),
+	style_(MagTranslator<string, LineStyle>().magics("boxplot_box_border_line_style"))
+{
+} 
+
+
+
+BoxPlotBoxBorderAttributes::~BoxPlotBoxBorderAttributes()
+{
+}
+
+    
+void BoxPlotBoxBorderAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "boxplot_box_border";
+	prefix[1] = "boxplot";
+
+	setAttribute(prefix, "boxplot_box_border_colour", colour_, params);
+	setAttribute(prefix, "boxplot_box_border_thickness", thickness_, params);
+	setAttribute(prefix, "boxplot_box_border_line_style", style_, params);
+}
+
+void BoxPlotBoxBorderAttributes::copy(const BoxPlotBoxBorderAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	thickness_ = other.thickness_;
+	style_ = other.style_;
+} 
+
+
+bool BoxPlotBoxBorderAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "box_border")  )
+		return true;
+	return false;
+}
+
+void BoxPlotBoxBorderAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "box_border") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void BoxPlotBoxBorderAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotBoxBorderAttributes[";
+	out << "colour = " << *colour_;
+	out << ", thickness = " << thickness_;
+	out << ", style = " << style_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotBoxBorderAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"box_border\"";
+	 out << ", \"boxplot_box_border_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"boxplot_box_border_thickness\":";
+	 niceprint(out,thickness_);
+	 out << ", \"boxplot_box_border_line_style\":";
+	 niceprint(out,style_);
+}
+static MagicsParameter<string> boxplot_box_border_colour("boxplot_box_border_colour", "navy", "");
+static MagicsParameter<int> boxplot_box_border_thickness("boxplot_box_border_thickness", 1, "");
+static MagicsParameter<string> boxplot_box_border_line_style("boxplot_box_border_line_style", "solid", "");
diff --git a/src/visualisers/BoxPlotItem.cc b/src/visualisers/BoxPlotItem.cc
new file mode 100644
index 0000000..8ea7c3c
--- /dev/null
+++ b/src/visualisers/BoxPlotItem.cc
@@ -0,0 +1,179 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotItem.cc
+    \brief Implementation of the Template class BoxPlotBox.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Fri 29-Sep-2006
+    
+    Changes:
+    
+*/
+
+#include "CustomisedPoint.h"
+#include "BoxPlotItem.h"
+#include "Polyline.h"
+#include "PaperPoint.h"
+#include "Transformation.h"
+using namespace magics;
+
+void BoxPlotBox::operator()(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const
+{
+	const Transformation& transformation = visitor.transformation();
+	Polyline* box  = new Polyline();				
+	box->setFilled(true);	
+	box->setFillColour(*colour_);
+	box->setShading(new FillShadingProperties());
+	
+	double width = (width_* cm_)/2; // Could later be expressed in %
+	CustomisedPoint::const_iterator upper = point.find("upper");
+	CustomisedPoint::const_iterator lower = point.find("lower");
+	CustomisedPoint::const_iterator x = point.find("x");
+	if ( x == point.end() || upper == point.end() || lower == point.end() ) return;
+	box->push_back(PaperPoint(x->second-width, upper->second));
+	box->push_back(PaperPoint(x->second+width, upper->second));
+	box->push_back(PaperPoint(x->second+width, lower->second));
+	box->push_back(PaperPoint(x->second-width, lower->second));
+	box->push_back(PaperPoint(x->second-width, upper->second));
+
+	(*border_)(*box);
+	visitor.push_back(box);
+
+	CustomisedPoint::const_iterator median = point.find("median");
+
+	if ( median == point.end() ) return;
+
+	Polyline* line  = new Polyline();	
+
+	line->push_back(PaperPoint(x->second-width, median->second));
+	line->push_back(PaperPoint(x->second+width, median->second));
+
+	(*median_)(visitor, line);
+}
+
+void BoxPlotBoxBorder::operator()(Polyline& box) const
+{
+	box.setColour(*colour_);
+	box.setLineStyle(style_);
+	box.setThickness(thickness_);
+		
+}
+
+void BoxPlotMedian::operator()(BasicGraphicsObjectContainer& visitor, Polyline* line) const
+{
+	
+	line->setColour(*colour_);
+	line->setLineStyle(style_);
+	line->setThickness(thickness_);
+	visitor.push_back(line);
+}
+
+
+void BoxPlotWhiskerBox::top(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const
+{
+	const Transformation& transformation = visitor.transformation();
+	Polyline* whisker  = new Polyline();			
+	whisker->setFilled(true);	
+	whisker->setFillColour(*colour_);
+	whisker->setShading(new FillShadingProperties());
+	double width = (width_* cm_)/2; // Could later be expressed in %
+	CustomisedPoint::const_iterator max = point.find("max");
+	CustomisedPoint::const_iterator upper = point.find("upper");
+	CustomisedPoint::const_iterator x = point.find("x");
+	if ( x == point.end() || max == point.end() || upper == point.end() ) return;
+	whisker->push_back(PaperPoint(x->second-width, max->second));
+	whisker->push_back(PaperPoint(x->second+width, max->second));
+	whisker->push_back(PaperPoint(x->second+width, upper->second));
+	whisker->push_back(PaperPoint(x->second-width, upper->second));
+	whisker->push_back(PaperPoint(x->second-width, max->second));
+
+	(*border_)(*whisker);
+	visitor.push_back(whisker);
+	
+}
+
+void BoxPlotWhiskerBox::bottom(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const
+{
+	const Transformation& transformation = visitor.transformation();
+	Polyline* whisker  = new Polyline();			
+	whisker->setFilled(true);	
+	whisker->setFillColour(*colour_);
+	whisker->setShading(new FillShadingProperties());
+	double width = (width_* cm_)/2; // Could later be expressed in %
+	CustomisedPoint::const_iterator min = point.find("min");
+	CustomisedPoint::const_iterator lower = point.find("lower");
+	CustomisedPoint::const_iterator x = point.find("x");
+	if ( x == point.end() || min == point.end() || lower == point.end() ) return;
+	whisker->push_back(PaperPoint(x->second-width, min->second));
+	whisker->push_back(PaperPoint(x->second+width, min->second));
+	whisker->push_back(PaperPoint(x->second+width, lower->second));
+	whisker->push_back(PaperPoint(x->second-width, lower->second));
+	whisker->push_back(PaperPoint(x->second-width, min->second));
+
+	(*border_)(*whisker);
+	visitor.push_back(whisker);
+}
+
+void BoxPlotWhiskerLine::top(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const
+{
+	Polyline* whisker  = new Polyline();				
+	whisker->setColour(*colour_);
+	whisker->setLineStyle(style_);
+	whisker->setThickness(thickness_);
+
+	CustomisedPoint::const_iterator max = point.find("max");
+	CustomisedPoint::const_iterator upper = point.find("upper");
+	CustomisedPoint::const_iterator x = point.find("x");
+	if ( x == point.end() || max == point.end() || upper == point.end() ) return;
+	whisker->push_back(PaperPoint(x->second, max->second));
+	whisker->push_back(PaperPoint(x->second, upper->second));
+	
+
+	
+	visitor.push_back(whisker);
+}
+
+void BoxPlotWhiskerLine::bottom(BasicGraphicsObjectContainer& visitor, const CustomisedPoint& point) const
+{
+	Polyline* whisker  = new Polyline();			
+	whisker->setColour(*colour_);
+	whisker->setLineStyle(style_);
+	whisker->setThickness(thickness_);
+
+	CustomisedPoint::const_iterator min = point.find("min");
+	CustomisedPoint::const_iterator lower = point.find("lower");
+	CustomisedPoint::const_iterator x = point.find("x");
+	if ( x == point.end() || min == point.end() || lower == point.end() ) return;
+	whisker->push_back(PaperPoint(x->second, min->second));
+	whisker->push_back(PaperPoint(x->second, lower->second));
+	
+
+	
+	visitor.push_back(whisker);
+}
+
+void BoxPlotWhiskerBorder::operator()(Polyline& whisker) const
+{
+	whisker.setColour(*colour_);
+	whisker.setLineStyle(style_);
+	whisker.setThickness(thickness_);
+}
+
+
diff --git a/src/visualisers/BoxPlotItem.h b/src/visualisers/BoxPlotItem.h
new file mode 100644
index 0000000..c79330f
--- /dev/null
+++ b/src/visualisers/BoxPlotItem.h
@@ -0,0 +1,231 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotItem.h
+    \brief Definition of the Template class BoxPlotItem.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Fri 29-Sep-2006
+    
+    Changes:
+    
+*/
+
+#ifndef BoxPlotItem_H
+#define BoxPlotItem_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "BoxPlotBasicItem.h"
+
+#include "BoxPlotBoxAttributes.h"
+#include "BoxPlotWhiskerLineAttributes.h"
+#include "BoxPlotWhiskerBoxAttributes.h"
+#include "BoxPlotBoxBorderAttributes.h"
+#include "BoxPlotWhiskerBorderAttributes.h"
+#include "BoxPlotMedianAttributes.h"
+
+namespace magics {
+
+
+class BoxPlotBox : public NoBoxPlotBox, public BoxPlotBoxAttributes
+{
+public:
+	BoxPlotBox() {}
+	virtual ~BoxPlotBox() {}
+	
+	
+    
+   void set(const XmlNode& node) { BoxPlotBoxAttributes::set(node);  }
+   void set(const map<string, string>& map) { BoxPlotBoxAttributes::set(map); }
+   bool accept(const string& node) { return BoxPlotBoxAttributes::accept(node); }
+   BoxPlotBox* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new BoxPlotBox();
+    }
+
+    void operator()(BasicGraphicsObjectContainer&, const CustomisedPoint&) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+private:
+    //! Copy constructor - No copy allowed
+	BoxPlotBox(const BoxPlotBox&);
+    //! Overloaded << operator to copy - No copy allowed
+	BoxPlotBox& operator=(const BoxPlotBox&);
+
+};
+
+
+class BoxPlotBoxBorder : public NoBoxPlotBoxBorder, public BoxPlotBoxBorderAttributes {
+
+public:
+	BoxPlotBoxBorder() {}
+	virtual ~BoxPlotBoxBorder() {}
+    
+    virtual void set(const XmlNode& node) {
+       BoxPlotBoxBorderAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        BoxPlotBoxBorderAttributes::set(map);
+    }
+    bool accept(const string& node) { return BoxPlotBoxBorderAttributes::accept(node); }
+    virtual NoBoxPlotBoxBorder* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new BoxPlotBoxBorder();
+    }
+    
+
+    virtual void operator()(Polyline&) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+
+
+};
+
+
+
+class BoxPlotMedian : public NoBoxPlotMedian, public BoxPlotMedianAttributes {
+
+public:
+	BoxPlotMedian() {}
+	virtual ~BoxPlotMedian() {}
+    
+    virtual void set(const XmlNode& node) {
+       BoxPlotMedianAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        BoxPlotMedianAttributes::set(map);
+    }
+    bool accept(const string& node) { return BoxPlotMedianAttributes::accept(node); }
+
+    virtual BoxPlotMedian* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new BoxPlotMedian();
+    }
+
+    
+     virtual void operator()(BasicGraphicsObjectContainer&, Polyline*) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+
+
+};
+
+
+class BoxPlotWhiskerBorder : public NoBoxPlotWhiskerBorder, public BoxPlotWhiskerBorderAttributes {
+
+public:
+	BoxPlotWhiskerBorder() {}
+	virtual ~BoxPlotWhiskerBorder() {}
+    
+    virtual void set(const XmlNode& node) {
+       BoxPlotWhiskerBorderAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        BoxPlotWhiskerBorderAttributes::set(map);
+    }
+    bool accept(const string& node) { return BoxPlotWhiskerBorderAttributes::accept(node); }
+
+    virtual NoBoxPlotWhiskerBorder* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new BoxPlotWhiskerBorder();
+    }
+
+    void operator()(Polyline&) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+
+
+};
+
+
+	
+class BoxPlotWhiskerBox : public NoBoxPlotWhisker, public BoxPlotWhiskerBoxAttributes {
+
+public:
+	BoxPlotWhiskerBox() {}
+	virtual ~BoxPlotWhiskerBox() {}
+    
+    virtual void set(const XmlNode& node) {
+       BoxPlotWhiskerBoxAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        BoxPlotWhiskerBoxAttributes::set(map);
+    }
+    virtual BoxPlotWhiskerBox* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new BoxPlotWhiskerBox();
+    }
+    bool accept(const string& node) { return BoxPlotWhiskerBoxAttributes::accept(node); }
+
+
+    void top(BasicGraphicsObjectContainer&, const CustomisedPoint&) const;
+    void bottom(BasicGraphicsObjectContainer&, const CustomisedPoint&) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+
+
+};
+
+class BoxPlotWhiskerLine : public NoBoxPlotWhisker, public BoxPlotWhiskerLineAttributes {
+
+public:
+	BoxPlotWhiskerLine() {}
+	virtual ~BoxPlotWhiskerLine() {}
+    
+    virtual void set(const XmlNode& node) {
+       BoxPlotWhiskerLineAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        BoxPlotWhiskerLineAttributes::set(map);
+    }
+    bool accept(const string& node) { return BoxPlotWhiskerLineAttributes::accept(node); }
+    virtual BoxPlotWhiskerLine* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new BoxPlotWhiskerLine();
+    }
+
+    void top(BasicGraphicsObjectContainer&, const CustomisedPoint&) const;
+    void bottom(BasicGraphicsObjectContainer&, const CustomisedPoint&) const;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+
+
+};
+
+
+
+
+
+}
+
+#endif
diff --git a/src/visualisers/BoxPlotMedianAttributes.cc b/src/visualisers/BoxPlotMedianAttributes.cc
new file mode 100644
index 0000000..191d880
--- /dev/null
+++ b/src/visualisers/BoxPlotMedianAttributes.cc
@@ -0,0 +1,117 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotMedianAttributes.cc
+    \brief Implementation of BoxPlotMedian Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotMedianAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotMedianAttributes::BoxPlotMedianAttributes():
+	colour_(MagTranslator<string, Colour>().magics("boxplot_median_colour")),
+	thickness_(ParameterManager::getInt("boxplot_median_thickness")),
+	style_(MagTranslator<string, LineStyle>().magics("boxplot_median_line_style"))
+{
+} 
+
+
+
+BoxPlotMedianAttributes::~BoxPlotMedianAttributes()
+{
+}
+
+    
+void BoxPlotMedianAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "boxplot_median";
+	prefix[1] = "boxplot";
+
+	setAttribute(prefix, "boxplot_median_colour", colour_, params);
+	setAttribute(prefix, "boxplot_median_thickness", thickness_, params);
+	setAttribute(prefix, "boxplot_median_line_style", style_, params);
+}
+
+void BoxPlotMedianAttributes::copy(const BoxPlotMedianAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	thickness_ = other.thickness_;
+	style_ = other.style_;
+} 
+
+
+bool BoxPlotMedianAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "median")  )
+		return true;
+	return false;
+}
+
+void BoxPlotMedianAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "median") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void BoxPlotMedianAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotMedianAttributes[";
+	out << "colour = " << *colour_;
+	out << ", thickness = " << thickness_;
+	out << ", style = " << style_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotMedianAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"median\"";
+	 out << ", \"boxplot_median_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"boxplot_median_thickness\":";
+	 niceprint(out,thickness_);
+	 out << ", \"boxplot_median_line_style\":";
+	 niceprint(out,style_);
+}
+static MagicsParameter<string> boxplot_median_colour("boxplot_median_colour", "navy", "");
+static MagicsParameter<int> boxplot_median_thickness("boxplot_median_thickness", 3, "");
+static MagicsParameter<string> boxplot_median_line_style("boxplot_median_line_style", "solid", "");
diff --git a/src/visualisers/BoxPlotVisualiser.cc b/src/visualisers/BoxPlotVisualiser.cc
new file mode 100644
index 0000000..e891efc
--- /dev/null
+++ b/src/visualisers/BoxPlotVisualiser.cc
@@ -0,0 +1,102 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotVisualiser.cc
+    \brief Implementation of the Template class BoxPlotVisualiser.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "BoxPlotVisualiser.h"
+#include "PointsHandler.h"
+#include "DateTime.h"
+#include "Text.h"
+
+
+
+using namespace magics;
+
+
+
+BoxPlotVisualiser::BoxPlotVisualiser() 
+{}
+
+
+BoxPlotVisualiser::~BoxPlotVisualiser() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void BoxPlotVisualiser::print(ostream& out)  const
+{
+	out << "BoxPlotVisualiser[";
+	out << "]";
+}
+
+
+
+void BoxPlotVisualiser::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	CustomisedPointsList points; 
+	std::set<string> request;
+	
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+	
+	double user = (transformation.getAbsoluteMaxX() - transformation.getAbsoluteMinX())/visitor.absoluteWidth();
+	
+	
+	
+	if (points.empty()) return;	
+	
+
+	box_->cm(user);	
+	whisker_->cm(user);
+	
+
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point)
+	{
+	
+		(*box_)(visitor, **point);
+	    
+		whisker_->top(visitor, **point);
+		whisker_->bottom(visitor, **point);		
+	}
+	
+
+		
+
+}
+
+void BoxPlotVisualiser::visit(LegendVisitor&)
+{
+	
+	// Not Yet!
+    
+   
+}
+
+
diff --git a/src/visualisers/BoxPlotVisualiser.h b/src/visualisers/BoxPlotVisualiser.h
new file mode 100644
index 0000000..8b92e0d
--- /dev/null
+++ b/src/visualisers/BoxPlotVisualiser.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotVisualiser.h
+    \brief Definition of the Template class BoxPlotVisualiser.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef BoxPlotVisualiser_H
+#define BoxPlotVisualiser_H
+
+#include "magics.h"
+
+
+#include "BoxPlotVisualiserAttributes.h"
+
+
+#include "magics.h"
+#include "Polyline.h"
+#include "Graph.h"
+
+namespace magics {
+
+class XmlNode;
+class LegendVisitor;
+
+class BoxPlotVisualiser: public BoxPlotVisualiserAttributes, public Visdef {
+
+
+
+public:
+	BoxPlotVisualiser();
+	virtual ~BoxPlotVisualiser();
+    
+   
+    
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { BoxPlotVisualiserAttributes::set(map); }
+    void set(const XmlNode& node) { BoxPlotVisualiserAttributes::set(node); }
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 double resolution_;
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	BoxPlotVisualiser(const BoxPlotVisualiser&);
+    //! Overloaded << operator to copy - No copy allowed
+	BoxPlotVisualiser& operator=(const BoxPlotVisualiser&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const BoxPlotVisualiser& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/BoxPlotVisualiserAttributes.cc b/src/visualisers/BoxPlotVisualiserAttributes.cc
new file mode 100644
index 0000000..07a04f1
--- /dev/null
+++ b/src/visualisers/BoxPlotVisualiserAttributes.cc
@@ -0,0 +1,132 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotVisualiserAttributes.cc
+    \brief Implementation of BoxPlotVisualiser Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotVisualiserAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotVisualiserAttributes::BoxPlotVisualiserAttributes():
+	box_(MagTranslator<string, NoBoxPlotBox>().magics("boxplot_box")),
+	whisker_(MagTranslator<string, NoBoxPlotWhisker>().magics("boxplot_whisker"))
+{
+} 
+
+
+
+BoxPlotVisualiserAttributes::~BoxPlotVisualiserAttributes()
+{
+}
+
+    
+void BoxPlotVisualiserAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(0);
+
+	setMember(prefix, "boxplot_box", box_, params);
+	setMember(prefix, "boxplot_whisker", whisker_, params);
+}
+
+void BoxPlotVisualiserAttributes::copy(const BoxPlotVisualiserAttributes& other)
+{
+	box_ = auto_ptr<NoBoxPlotBox>(other.box_->clone());
+	whisker_ = auto_ptr<NoBoxPlotWhisker>(other.whisker_->clone());
+} 
+
+
+bool BoxPlotVisualiserAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "boxplot")  )
+		return true;
+
+	if ( acceptNode(node, box_) )
+		return true;
+
+	if ( acceptNode(node, whisker_) )
+		return true;
+	return false;
+}
+
+void BoxPlotVisualiserAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "boxplot") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), box_, node);
+		setMember(node.name(), whisker_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), box_, *(*elt)); 
+		setMember((*elt)->name(), whisker_, *(*elt)); 
+	}
+}
+
+void BoxPlotVisualiserAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotVisualiserAttributes[";
+	out << "box = " << *box_;
+	out << ", whisker = " << *whisker_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotVisualiserAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"boxplot\"";
+	 out << ", \"boxplot_box\":";
+	 box_->toxml(out);
+	 out << ", \"boxplot_whisker\":";
+	 whisker_->toxml(out);
+}
+static MagicsParameter<string> boxplot_box("boxplot_box", "on", "");
+static MagicsParameter<string> boxplot_whisker("boxplot_whisker", "line", "");
+#include "BoxPlotItem.h"
+#include "BoxPlotBasicItem.h"
+static SimpleObjectMaker<BoxPlotBox, NoBoxPlotBox> on_BoxPlotBox("on");
+static SimpleObjectMaker<BoxPlotBox, NoBoxPlotBox> box_BoxPlotBox("box");
+static SimpleObjectMaker<NoBoxPlotBox, NoBoxPlotBox> off_NoBoxPlotBox("off");
+static SimpleObjectMaker<NoBoxPlotBox, NoBoxPlotBox> noBox_NoBoxPlotBox("noBox");
+#include "BoxPlotItem.h"
+#include "BoxPlotBasicItem.h"
+static SimpleObjectMaker<BoxPlotWhiskerBox, NoBoxPlotWhisker> box_BoxPlotWhiskerBox("box");
+static SimpleObjectMaker<BoxPlotWhiskerBox, NoBoxPlotWhisker> whiskerbox_BoxPlotWhiskerBox("whiskerbox");
+static SimpleObjectMaker<NoBoxPlotWhisker, NoBoxPlotWhisker> off_NoBoxPlotWhisker("off");
+static SimpleObjectMaker<NoBoxPlotWhisker, NoBoxPlotWhisker> nowhisker_NoBoxPlotWhisker("nowhisker");
+static SimpleObjectMaker<BoxPlotWhiskerLine, NoBoxPlotWhisker> line_BoxPlotWhiskerLine("line");
+static SimpleObjectMaker<BoxPlotWhiskerLine, NoBoxPlotWhisker> whiskerline_BoxPlotWhiskerLine("whiskerline");
diff --git a/src/visualisers/BoxPlotWhiskerBorderAttributes.cc b/src/visualisers/BoxPlotWhiskerBorderAttributes.cc
new file mode 100644
index 0000000..421721c
--- /dev/null
+++ b/src/visualisers/BoxPlotWhiskerBorderAttributes.cc
@@ -0,0 +1,119 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotWhiskerBorderAttributes.cc
+    \brief Implementation of BoxPlotWhiskerBorder Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotWhiskerBorderAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotWhiskerBorderAttributes::BoxPlotWhiskerBorderAttributes():
+	colour_(MagTranslator<string, Colour>().magics("boxplot_whisker_box_border_colour")),
+	thickness_(ParameterManager::getInt("boxplot_whisker_box_border_thickness")),
+	style_(MagTranslator<string, LineStyle>().magics("boxplot_whisker_box_border_line_style"))
+{
+} 
+
+
+
+BoxPlotWhiskerBorderAttributes::~BoxPlotWhiskerBorderAttributes()
+{
+}
+
+    
+void BoxPlotWhiskerBorderAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(4);
+	prefix[0] = "boxplot_whisker_box_border";
+	prefix[1] = "boxplot_whisker_box";
+	prefix[2] = "boxplot_whisker";
+	prefix[3] = "boxplot";
+
+	setAttribute(prefix, "boxplot_whisker_box_border_colour", colour_, params);
+	setAttribute(prefix, "boxplot_whisker_box_border_thickness", thickness_, params);
+	setAttribute(prefix, "boxplot_whisker_box_border_line_style", style_, params);
+}
+
+void BoxPlotWhiskerBorderAttributes::copy(const BoxPlotWhiskerBorderAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	thickness_ = other.thickness_;
+	style_ = other.style_;
+} 
+
+
+bool BoxPlotWhiskerBorderAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "whisker_border")  )
+		return true;
+	return false;
+}
+
+void BoxPlotWhiskerBorderAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "whisker_border") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void BoxPlotWhiskerBorderAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotWhiskerBorderAttributes[";
+	out << "colour = " << *colour_;
+	out << ", thickness = " << thickness_;
+	out << ", style = " << style_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotWhiskerBorderAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"whisker_border\"";
+	 out << ", \"boxplot_whisker_box_border_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"boxplot_whisker_box_border_thickness\":";
+	 niceprint(out,thickness_);
+	 out << ", \"boxplot_whisker_box_border_line_style\":";
+	 niceprint(out,style_);
+}
+static MagicsParameter<string> boxplot_whisker_box_border_colour("boxplot_whisker_box_border_colour", "navy", "");
+static MagicsParameter<int> boxplot_whisker_box_border_thickness("boxplot_whisker_box_border_thickness", 1, "");
+static MagicsParameter<string> boxplot_whisker_box_border_line_style("boxplot_whisker_box_border_line_style", "solid", "");
diff --git a/src/visualisers/BoxPlotWhiskerBoxAttributes.cc b/src/visualisers/BoxPlotWhiskerBoxAttributes.cc
new file mode 100644
index 0000000..51c7f7d
--- /dev/null
+++ b/src/visualisers/BoxPlotWhiskerBoxAttributes.cc
@@ -0,0 +1,129 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotWhiskerBoxAttributes.cc
+    \brief Implementation of BoxPlotWhiskerBox Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotWhiskerBoxAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotWhiskerBoxAttributes::BoxPlotWhiskerBoxAttributes():
+	colour_(MagTranslator<string, Colour>().magics("boxplot_whisker_box_colour")),
+	width_(ParameterManager::getDouble("boxplot_whisker_box_width")),
+	border_(MagTranslator<string, NoBoxPlotWhiskerBorder>().magics("boxplot_whisker_box_border"))
+{
+} 
+
+
+
+BoxPlotWhiskerBoxAttributes::~BoxPlotWhiskerBoxAttributes()
+{
+}
+
+    
+void BoxPlotWhiskerBoxAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(3);
+	prefix[0] = "boxplot_whisker_box";
+	prefix[1] = "boxplot_whisker";
+	prefix[2] = "boxplot";
+
+	setAttribute(prefix, "boxplot_whisker_box_colour", colour_, params);
+	setAttribute(prefix, "boxplot_whisker_box_width", width_, params);
+	setMember(prefix, "boxplot_whisker_box_border", border_, params);
+}
+
+void BoxPlotWhiskerBoxAttributes::copy(const BoxPlotWhiskerBoxAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	width_ = other.width_;
+	border_ = auto_ptr<NoBoxPlotWhiskerBorder>(other.border_->clone());
+} 
+
+
+bool BoxPlotWhiskerBoxAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "whisker_box")  )
+		return true;
+
+	if ( acceptNode(node, border_) )
+		return true;
+	return false;
+}
+
+void BoxPlotWhiskerBoxAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "whisker_box") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), border_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), border_, *(*elt)); 
+	}
+}
+
+void BoxPlotWhiskerBoxAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotWhiskerBoxAttributes[";
+	out << "colour = " << *colour_;
+	out << ", width = " << width_;
+	out << ", border = " << *border_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotWhiskerBoxAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"whisker_box\"";
+	 out << ", \"boxplot_whisker_box_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"boxplot_whisker_box_width\":";
+	 niceprint(out,width_);
+	 out << ", \"boxplot_whisker_box_border\":";
+	 border_->toxml(out);
+}
+static MagicsParameter<string> boxplot_whisker_box_colour("boxplot_whisker_box_colour", "sky", "");
+static MagicsParameter<double> boxplot_whisker_box_width("boxplot_whisker_box_width", 0.25, "");
+static MagicsParameter<string> boxplot_whisker_box_border("boxplot_whisker_box_border", "on", "");
+#include "BoxPlotItem.h"
+#include "BoxPlotBasicItem.h"
+static SimpleObjectMaker<BoxPlotWhiskerBorder, NoBoxPlotWhiskerBorder> on_BoxPlotWhiskerBorder("on");
+static SimpleObjectMaker<BoxPlotWhiskerBorder, NoBoxPlotWhiskerBorder> border_BoxPlotWhiskerBorder("border");
+static SimpleObjectMaker<NoBoxPlotWhiskerBorder, NoBoxPlotWhiskerBorder> off_NoBoxPlotWhiskerBorder("off");
+static SimpleObjectMaker<NoBoxPlotWhiskerBorder, NoBoxPlotWhiskerBorder> noborder_NoBoxPlotWhiskerBorder("noborder");
diff --git a/src/visualisers/BoxPlotWhiskerLineAttributes.cc b/src/visualisers/BoxPlotWhiskerLineAttributes.cc
new file mode 100644
index 0000000..13db4a5
--- /dev/null
+++ b/src/visualisers/BoxPlotWhiskerLineAttributes.cc
@@ -0,0 +1,118 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file BoxPlotWhiskerLineAttributes.cc
+    \brief Implementation of BoxPlotWhiskerLine Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "BoxPlotWhiskerLineAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+BoxPlotWhiskerLineAttributes::BoxPlotWhiskerLineAttributes():
+	colour_(MagTranslator<string, Colour>().magics("boxplot_whisker_line_colour")),
+	thickness_(ParameterManager::getInt("boxplot_whisker_line_thickness")),
+	style_(MagTranslator<string, LineStyle>().magics("boxplot_whisker_line_style"))
+{
+} 
+
+
+
+BoxPlotWhiskerLineAttributes::~BoxPlotWhiskerLineAttributes()
+{
+}
+
+    
+void BoxPlotWhiskerLineAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(3);
+	prefix[0] = "boxplot_whisker_line";
+	prefix[1] = "boxplot_whisker";
+	prefix[2] = "boxplot";
+
+	setAttribute(prefix, "boxplot_whisker_line_colour", colour_, params);
+	setAttribute(prefix, "boxplot_whisker_line_thickness", thickness_, params);
+	setAttribute(prefix, "boxplot_whisker_line_style", style_, params);
+}
+
+void BoxPlotWhiskerLineAttributes::copy(const BoxPlotWhiskerLineAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	thickness_ = other.thickness_;
+	style_ = other.style_;
+} 
+
+
+bool BoxPlotWhiskerLineAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "whisker_line")  )
+		return true;
+	return false;
+}
+
+void BoxPlotWhiskerLineAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "whisker_line") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void BoxPlotWhiskerLineAttributes::print(ostream& out)  const
+{
+	out << "BoxPlotWhiskerLineAttributes[";
+	out << "colour = " << *colour_;
+	out << ", thickness = " << thickness_;
+	out << ", style = " << style_;
+	out << "]" << "\n";
+}
+
+
+void BoxPlotWhiskerLineAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"whisker_line\"";
+	 out << ", \"boxplot_whisker_line_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"boxplot_whisker_line_thickness\":";
+	 niceprint(out,thickness_);
+	 out << ", \"boxplot_whisker_line_style\":";
+	 niceprint(out,style_);
+}
+static MagicsParameter<string> boxplot_whisker_line_colour("boxplot_whisker_line_colour", "navy", "");
+static MagicsParameter<int> boxplot_whisker_line_thickness("boxplot_whisker_line_thickness", 3, "");
+static MagicsParameter<string> boxplot_whisker_line_style("boxplot_whisker_line_style", "solid", "");
diff --git a/src/visualisers/CalculateColourTechnique.cc b/src/visualisers/CalculateColourTechnique.cc
new file mode 100644
index 0000000..2674cb7
--- /dev/null
+++ b/src/visualisers/CalculateColourTechnique.cc
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CalculateColourTechnique.cc
+    \brief Implementation of the Template class CalculateColourTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#include "CalculateColourTechnique.h"
+#include "LevelSelection.h"
+#include "ColourTableDefinitionCompute.h"
+
+using namespace magics;
+
+CalculateColourTechnique::CalculateColourTechnique() 
+{
+}
+
+
+CalculateColourTechnique::~CalculateColourTechnique() 
+{
+}
+
+void CalculateColourTechnique::set(ColourTable& table, int nb) const
+{
+	ColourTableDefinitionCompute helper;
+	helper.set(*this);
+	helper.set(table, nb);
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void CalculateColourTechnique::print(ostream& out)  const
+{
+	out << "CalculateColourTechnique[";
+	out << "]";
+}
+
+void CalculateColourTechnique::set(const ColourTechniqueInterface& attributes)
+{
+    max_ = auto_ptr<Colour>(attributes.getMaxColour().clone());
+    min_ = auto_ptr<Colour>(attributes.getMinColour().clone());
+	direction_ = attributes.getDirection();
+}
+
diff --git a/src/visualisers/CalculateColourTechnique.h b/src/visualisers/CalculateColourTechnique.h
new file mode 100644
index 0000000..361a92b
--- /dev/null
+++ b/src/visualisers/CalculateColourTechnique.h
@@ -0,0 +1,84 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CalculateColourTechnique.h
+    \brief Definition of the Template class CalculateColourTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef CalculateColourTechnique_H
+#define CalculateColourTechnique_H
+
+#include "magics.h"
+
+#include "ColourTechnique.h"
+#include "CalculateColourTechniqueAttributes.h"
+
+namespace magics {
+
+class CalculateColourTechnique: public ColourTechnique, public CalculateColourTechniqueAttributes {
+
+public:
+	CalculateColourTechnique();
+	virtual ~CalculateColourTechnique();
+    void set(const map<string, string>& map) { 
+        CalculateColourTechniqueAttributes::set(map);
+        }
+    void set(const XmlNode& node) { 
+        CalculateColourTechniqueAttributes::set(node); 
+    }
+     bool accept(const string& node) { return CalculateColourTechniqueAttributes::accept(node); }
+    
+    void set(const ColourTechniqueInterface&);
+    
+    
+    virtual ColourTechnique* clone() const {
+    	CalculateColourTechnique* object = new CalculateColourTechnique();
+    	object->copy(*this);
+    	return object;
+    }
+    const Colour& getMax() const { return *max_; }
+    const Colour& getMin() const { return *min_; }
+    const string& getDirection() const { return direction_; }
+
+protected:
+     void set(ColourTable&, int) const;
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	CalculateColourTechnique(const CalculateColourTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	CalculateColourTechnique& operator=(const CalculateColourTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CalculateColourTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/CalculateColourTechniqueAttributes.h b/src/visualisers/CalculateColourTechniqueAttributes.h
new file mode 100644
index 0000000..95c8f3b
--- /dev/null
+++ b/src/visualisers/CalculateColourTechniqueAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file CalculateColourTechniqueAttributes.h
+    \brief Definition of CalculateColourTechnique Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef CalculateColourTechniqueAttributes_H
+#define CalculateColourTechniqueAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "ColourTableDefinitionComputeInterface.h"
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class CalculateColourTechniqueAttributes : public ColourTableDefinitionComputeInterface
+{
+public:
+//  --  constructor
+    CalculateColourTechniqueAttributes();
+    
+//  --  destructor
+    virtual ~CalculateColourTechniqueAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const CalculateColourTechniqueAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<Colour> max_;
+	auto_ptr<Colour> min_;
+	string direction_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const CalculateColourTechniqueAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/CalmIndicator.h b/src/visualisers/CalmIndicator.h
new file mode 100644
index 0000000..801dd89
--- /dev/null
+++ b/src/visualisers/CalmIndicator.h
@@ -0,0 +1,141 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CalmIndicator.h
+    \brief Definition of the Template class CalmIndicator.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef CalmIndicator_H
+#define CalmIndicator_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "Symbol.h"
+
+
+namespace magics {
+	
+
+class CalmIndicator {
+public:
+	CalmIndicator() { marker_ = 1; }
+	virtual ~CalmIndicator() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual bool accept(const string& node) { return magCompare(node, "calm"); }
+	virtual void toxml(ostream&) {}
+	virtual CalmIndicator* clone() { return new CalmIndicator(); }
+	void colour(const Colour& colour) { colour_ = colour; }
+	void marker(double marker)      { marker_ = marker; }
+	void height(double height)      { height_ = height; }
+	void below(double below)        { below_  = below * below; }
+	
+	
+	virtual void prepare(BasicGraphicsObjectContainer& task) {
+		calm_ = new Symbol();
+		calm_->setColour(colour_);
+	    calm_->setMarker(marker_);
+	    calm_->setHeight(height_);
+	    task.push_back(calm_);
+	    
+	    dot_ = new Symbol();
+		dot_->setColour(colour_);
+	    dot_->setMarker(15);
+	    dot_->setHeight(0.1);
+		task.push_back(dot_);	
+	}
+		
+	
+	virtual bool operator()(const PaperPoint& point, double x, double y)
+	{
+		if ( ((x*x) + (y*y)) < below_ ) {
+			calm_->push_back(point);
+			dot_->push_back(point);
+			return true;
+		}
+		return false; 
+	}
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "CalmIndicator"; } 
+	 Symbol* calm_;
+	 Symbol* dot_;
+	 Colour     colour_;
+	 int     marker_;
+	 double   height_;
+	 double   below_;
+	 
+private:
+    //! Copy constructor - No copy allowed
+	CalmIndicator(const CalmIndicator&);
+    //! Overloaded << operator to copy - No copy allowed
+	CalmIndicator& operator=(const CalmIndicator&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CalmIndicator& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+class NoCalmIndicator : public CalmIndicator
+{
+public:
+	NoCalmIndicator()  {}
+	~NoCalmIndicator() {}
+	virtual CalmIndicator* clone() { return new NoCalmIndicator(); }
+	virtual bool accept(const string& node) { return magCompare(node, "nocalm"); }
+
+	
+	void prepare(BasicGraphicsObjectContainer&) {}
+	virtual bool operator()(const PaperPoint&, double x, double y)
+	{
+	    return (((x*x) + (y*y)) < this->below_ ) ? true : false;
+	}
+	
+	
+};
+
+template <>
+class MagTranslator<string, CalmIndicator> { 
+public:
+	CalmIndicator* operator()(const string& val ) {
+		 return SimpleObjectMaker<CalmIndicator >::create(val);
+	}     
+    CalmIndicator* magics(const string& param)
+    {
+        CalmIndicator* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+} // namespace magics
+#endif
diff --git a/src/visualisers/CdfGraphAttributes.cc b/src/visualisers/CdfGraphAttributes.cc
new file mode 100644
index 0000000..2fcd359
--- /dev/null
+++ b/src/visualisers/CdfGraphAttributes.cc
@@ -0,0 +1,137 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file CdfGraphAttributes.cc
+    \brief Implementation of CdfGraph Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "CdfGraphAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+CdfGraphAttributes::CdfGraphAttributes():
+	colour_(ParameterManager::getStringArray("cdf_lines_colour_array")),
+	style_(ParameterManager::getStringArray("cdf_lines_style_array")),
+	thickness_(ParameterManager::getIntArray("cdf_lines_thickness_array")),
+	clim_colour_(MagTranslator<string, Colour>().magics("cdf_clim_line_colour")),
+	clim_thickness_(ParameterManager::getInt("cdf_clim_line_thickness")),
+	clim_style_(MagTranslator<string, LineStyle>().magics("cdf_clim_line_style"))
+{
+} 
+
+
+
+CdfGraphAttributes::~CdfGraphAttributes()
+{
+}
+
+    
+void CdfGraphAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "cdf";
+
+	setAttribute(prefix, "cdf_lines_colour_array", colour_, params);
+	setAttribute(prefix, "cdf_lines_style_array", style_, params);
+	setAttribute(prefix, "cdf_lines_thickness_array", thickness_, params);
+	setAttribute(prefix, "cdf_clim_line_colour", clim_colour_, params);
+	setAttribute(prefix, "cdf_clim_line_thickness", clim_thickness_, params);
+	setAttribute(prefix, "cdf_clim_line_style", clim_style_, params);
+}
+
+void CdfGraphAttributes::copy(const CdfGraphAttributes& other)
+{
+	colour_ = other.colour_;
+	style_ = other.style_;
+	thickness_ = other.thickness_;
+	clim_colour_ = auto_ptr<Colour>(other.clim_colour_->clone());
+	clim_thickness_ = other.clim_thickness_;
+	clim_style_ = other.clim_style_;
+} 
+
+
+bool CdfGraphAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "cdfgraph")  )
+		return true;
+	return false;
+}
+
+void CdfGraphAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "cdfgraph") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void CdfGraphAttributes::print(ostream& out)  const
+{
+	out << "CdfGraphAttributes[";
+	out << "colour = " << colour_;
+	out << ", style = " << style_;
+	out << ", thickness = " << thickness_;
+	out << ", clim_colour = " << *clim_colour_;
+	out << ", clim_thickness = " << clim_thickness_;
+	out << ", clim_style = " << clim_style_;
+	out << "]" << "\n";
+}
+
+
+void CdfGraphAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"cdfgraph\"";
+	 out << ", \"cdf_lines_colour_array\":";
+	 niceprint(out,colour_);
+	 out << ", \"cdf_lines_style_array\":";
+	 niceprint(out,style_);
+	 out << ", \"cdf_lines_thickness_array\":";
+	 niceprint(out,thickness_);
+	 out << ", \"cdf_clim_line_colour\":";
+	 niceprint(out, *clim_colour_);
+	 out << ", \"cdf_clim_line_thickness\":";
+	 niceprint(out,clim_thickness_);
+	 out << ", \"cdf_clim_line_style\":";
+	 niceprint(out,clim_style_);
+}
+static MagicsParameter<stringarray> cdf_lines_colour_array("cdf_lines_colour_array", stringarray(), "");
+static MagicsParameter<stringarray> cdf_lines_style_array("cdf_lines_style_array", stringarray(), "");
+static MagicsParameter<intarray> cdf_lines_thickness_array("cdf_lines_thickness_array", intarray(), "");
+static MagicsParameter<string> cdf_clim_line_colour("cdf_clim_line_colour", "black", "");
+static MagicsParameter<int> cdf_clim_line_thickness("cdf_clim_line_thickness", 4, "");
+static MagicsParameter<string> cdf_clim_line_style("cdf_clim_line_style", "solid", "");
diff --git a/src/visualisers/CellShading.cc b/src/visualisers/CellShading.cc
new file mode 100644
index 0000000..f5a2169
--- /dev/null
+++ b/src/visualisers/CellShading.cc
@@ -0,0 +1,197 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CellShading.cc
+    \brief Implementation of the Template class CellShading.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 30-Aug-2005
+    
+    Changes:
+    
+*/
+
+#include "CellShading.h"
+#include "Image.h"
+#include "IsoPlot.h"
+#include "Symbol.h"
+#include <algorithm>
+#include <limits>
+
+using namespace magics;
+
+
+CellShading::CellShading()
+{
+}
+
+
+CellShading::~CellShading()
+{
+}
+
+
+void CellShading::operator()( MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+{
+	// Here we have to work using the parentput projection.
+	
+	const Transformation& projection = parent.transformation();
+	
+	double minc = projection.getMinPCX();
+	double maxc = projection.getMaxPCX();
+	double minr = projection.getMinPCY();
+	double maxr = projection.getMaxPCY();
+	
+	double width =  parent.absoluteWidth();
+	double height =  parent.absoluteHeight();
+	
+	MagLog::debug() << "minx="   << minc << endl;
+	MagLog::debug() << "maxx="   << maxc << endl;
+	MagLog::debug() << "miny="   << minr << endl;
+	MagLog::debug() << "maxy="   << maxr << endl;
+	MagLog::debug() << "width="  << width << endl;
+	MagLog::debug() << "height=" << height << endl;
+	MagLog::debug() << "resolution=" << resolution_ << endl;
+	
+	int rows    = int(height * resolution_);
+	int columns = int(width * resolution_);
+	double stepr = (maxr-minr)/(rows-1);
+	double stepc = (maxc-minc)/(columns-1);
+	MagLog::debug() << "stepy=" << stepr << endl;
+	MagLog::debug() << "stepx=" << stepc << endl;
+	MagLog::debug() << "rows=" << rows << endl;
+	MagLog::debug() << "columns=" << columns << endl;
+	
+	UserPoint point;
+	double value;
+	
+	Image* image = new Image();
+	image->set(rows, columns);
+	
+	double lat = maxr;
+	double lon = minc;
+	for ( int row = 0; row < rows; row++) {
+		lon = minc;
+		for ( int column = 0; column < columns; column++) {
+			projection.revert(PaperPoint(lon, lat), point);			
+			value = (magCompare(method_, "nearest") ) ?
+					data.nearest(point.y(), point.x()) :  data.interpolate(point.y(), point.x());
+		
+			image->push_back(map_.find(value,0));
+			lon += stepc;
+		}
+		lat -= stepr;
+	}
+	
+	
+    ColourTable table;
+    vector<Colour>::const_iterator colour = colours_.begin();
+    for (int i = 0; i <= *max_element(image->begin(), image->end()); i++)
+    {
+    	table.push_back(*colour);
+    	if ( ++colour == colours_.end() ) colour = colours_.begin();
+	}
+	
+
+	PaperPoint pp(minc, maxr);
+	image->setOrigin(pp);
+	MagLog::debug() << "origin--->" << pp << endl;
+	image->setWidth(maxc-minc);
+	image->setHeight(maxr-minr);
+	image->setColourTable(table);
+
+	
+	parent.push_back(image);
+}
+
+
+bool CellShading::prepare(const LevelSelection& levels, const ColourTechnique& technique)
+{
+	// First Interval ...
+	
+	map_.clear();
+	map_[Interval(INT_MIN, levels.front())] = 0;
+	colours_.push_back(Colour("none"));
+	for (unsigned int i = 0; i < levels.size() -1; i++)
+	{  
+		map_[Interval(levels[i], levels[i+1])] = i+1;
+		colours_.push_back(technique.right(levels[i]));
+	}
+	map_[Interval(levels.back(), std::numeric_limits<double>::max())] = levels.size();
+	colours_.push_back(Colour("none"));
+	return false;
+}
+
+
+void  CellShading::visit(LegendVisitor& node, const ColourTechnique&)
+{
+	
+	for ( IntervalMap<int>::const_iterator interval = map_.begin(); interval != map_.end(); ++interval) {
+	   
+	   Polyline* box = new Polyline();
+			      
+	   double min = interval->first.min_;
+	   double max = interval->first.max_;
+	   // We ignore the first and the last entries: no interest in the legend!  
+	   if (interval->second == 0) continue;
+	   if (interval->second == int(map_.size()-1)) continue;
+	   
+	   
+	   box->setFilled(true);
+	   box->setFillColour(colours_[interval->second]);
+	   		
+	   FillShadingProperties* shading = new FillShadingProperties();
+	    	    
+	  
+	          
+	   box->setShading(shading);
+
+
+	   
+	   node.add(new BoxEntry(min, max, box));	        
+	}
+
+	node.last();
+
+}
+
+
+/*!
+ Class information are given to the parentput-stream.
+*/	
+
+void CellShading::print(ostream& out)  const
+{
+	out << "CellShading";
+}
+
+
+
+
+void  CellShading::colour(double val, Colour& colour)
+{
+	colour = this->colours_[this->map_.find(val, 0)];
+}
+CellArray* CellShading::array(MatrixHandler& matrix, IntervalMap<int>& range,
+		const Transformation& transformation, int width, int height,
+		float resolution, const string& technique)
+{
+	return new CellArray(matrix, range, transformation, width, height, resolution, technique);
+
+}
diff --git a/src/visualisers/CellShading.h b/src/visualisers/CellShading.h
new file mode 100644
index 0000000..c55e930
--- /dev/null
+++ b/src/visualisers/CellShading.h
@@ -0,0 +1,96 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CellShading.h
+    \brief Definition of the Template class CellShading.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 30-Aug-2005
+    
+    Changes:
+    
+*/
+
+#ifndef CellShading_H
+#define CellShading_H
+
+#include "magics.h"
+
+#include "IsoShading.h"
+#include "CellShadingAttributes.h"
+
+#include "ColourTable.h"
+
+namespace magics {
+
+
+class CellShading: public ShadingTechnique, public CellShadingAttributes {
+
+public:
+	CellShading();
+	virtual ~CellShading();
+	void set(const map<string, string>& map ) { CellShadingAttributes::set(map); }
+	void set(const XmlNode& node ) { CellShadingAttributes::set(node); }
+	bool accept(const string& node) { return CellShadingAttributes::accept(node); }
+
+	virtual ShadingTechnique* clone() const {
+		CellShading* object = new CellShading();
+	    return object;
+	}
+	void copy(const CellShading& from)
+	{
+		CellShadingAttributes::copy(from);
+		//IsoShadingAttributes::copy(from);
+	}
+	
+	virtual void visit(LegendVisitor&, const ColourTechnique&);
+	bool hasLegend() { return true; } // Isolien legend is not needed!
+	virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
+    virtual bool prepare(const LevelSelection&, const ColourTechnique&);
+    virtual void colour(double, Colour&);
+    CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+    		const Transformation& transformation, int width, int height,
+    		float resolution, const string& technique);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 IntervalMap<int> map_;
+	 vector<Colour>      colours_;
+
+private:
+    //! Copy constructor - No copy allowed
+	CellShading(const CellShading&);
+    //! Overloaded << operator to copy - No copy allowed
+	CellShading& operator=(const CellShading&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CellShading& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/CellShadingAttributes.h b/src/visualisers/CellShadingAttributes.h
new file mode 100644
index 0000000..ed70501
--- /dev/null
+++ b/src/visualisers/CellShadingAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file CellShadingAttributes.h
+    \brief Definition of CellShading Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef CellShadingAttributes_H
+#define CellShadingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class CellShadingAttributes 
+{
+public:
+//  --  constructor
+    CellShadingAttributes();
+    
+//  --  destructor
+    virtual ~CellShadingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const CellShadingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double resolution_;
+	string method_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const CellShadingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Cities.cc b/src/visualisers/Cities.cc
new file mode 100644
index 0000000..a571f7c
--- /dev/null
+++ b/src/visualisers/Cities.cc
@@ -0,0 +1,193 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Cities.cc
+    \brief Implementation of the Template class CitiesBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 29-Aug-2006
+    
+    Changes:
+	     2010 JUL change from mapgen to shp
+    
+*/
+
+#include "Cities.h"
+#include "UserPoint.h"
+#include "ShapeDecoder.h"
+#include "Symbol.h"
+
+using namespace magics;
+
+
+Cities::Cities() 
+{
+}
+
+Cities::~Cities() 
+{
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Cities::print(ostream& out)  const
+{
+	out << "Cities[";
+	CitiesAttributes::print(out);
+	out << "]";
+}
+
+struct Radius 
+{
+    Radius(double radius, CustomisedPoint& reference): radius_(radius), reference_(reference) {}
+    ~Radius() {}
+    bool operator()(CustomisedPoint*& point)
+    {       
+      double dist = distance(*point, reference_);
+      if ( zero(dist) ) return false;
+      return  dist  < radius_ * radius_;
+    }    
+
+    double distance(CustomisedPoint& p1, CustomisedPoint& p2) {
+        return ((p1["x"] -p2["x"])*(p1["x"] -p2["x"])) + ((p1["y"] -p2["y"])*(p1["y"] -p2["y"]));
+    }
+    
+    double radius_;
+    CustomisedPoint& reference_;
+};
+
+
+void clean(CustomisedPointsList& filter, CustomisedPointsList::iterator point) {
+	double radius =1;
+	CustomisedPointsList::iterator last = std::remove_if(filter.begin(), filter.end(), Radius(radius, **point));	
+	filter.erase(last, filter.end());
+	point++;
+	if (point != filter.end()) 
+		clean(filter, point);
+}
+
+double distance(CustomisedPoint* pp1,  CustomisedPoint* pp2) {
+	CustomisedPoint& p1 = *pp1;
+	CustomisedPoint& p2 = *pp2;
+    return ((p1["x"] -p2["x"])*(p1["x"] -p2["x"])) + ((p1["y"] -p2["y"])*(p1["y"] -p2["y"]));
+}
+
+
+void Cities::operator()(const map<string, string>&, BasicGraphicsObjectContainer& task)
+{
+	static map<string, Symbol::TextPosition> positions;
+	
+	if ( positions.empty() ) {
+		positions["above"] = Symbol::M_ABOVE;
+		positions["below"] = Symbol::M_BELOW;
+		positions["right"] = Symbol::M_RIGHT;
+		positions["left"]  = Symbol::M_LEFT;
+	}
+
+	if ( magCompare(unit_, "percent") ) {
+		marker_height_ = (marker_height_/100) * task.absoluteHeight();
+		font_size_     = (font_size_/100)     * task.absoluteHeight();
+	}
+
+	const double radius = 2. * font_size_ * task.transformation().unitToCm(task.absoluteWidth(), task.absoluteHeight());
+
+	position_ = lowerCase(position_);
+
+	map<string, Symbol::TextPosition>::iterator pos = positions.find(position_);
+
+	Symbol::TextPosition position = (pos != positions.end() ) ? pos->second : Symbol::M_ABOVE;
+
+	string cities = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "10m/10m_populated_places_simple";
+	std::set<string> need;
+	CustomisedPointsList points;
+	const Transformation& transformation = task.transformation();
+    
+    ShapeDecoder decoder;
+     decoder.setPath(cities);
+     
+    TextSymbol* text = new TextSymbol();
+     text->position(position);
+     text->setSymbol(lowerCase(marker_));
+     text->setHeight(marker_height_);
+     text->setColour(*marker_colour_);
+     MagFont font(font_name_, font_style_, font_size_);
+     font.colour(*font_colour_);
+     text->font(font);
+    decoder.customisedPoints(need, points);
+    vector<CustomisedPoint*> filter;
+    for (CustomisedPointsList::iterator point = points.begin(); point != points.end(); ++point)
+    {
+    		UserPoint geo((*point)->longitude(), (*point)->latitude());
+    		if ( transformation.in(geo) && !(*point)->identifier().empty()) {
+    			
+    			PaperPoint xy = transformation(geo);
+    			(**point)["x"] = xy.x();
+    			(**point)["y"] = xy.y();
+    			filter.push_back(*point);
+    		}
+    		//if ( transformation.in(geo) && !(*point)->identifier().empty()) {
+    			//text->push_back(transformation(geo), (*point)->identifier());
+    		//}
+    }
+
+    /*
+    for (CustomisedPointsList::iterator p1 = filter.begin(); p1 != filter.end(); ++p1) {
+    	if ( (**p1)["plot"] == -1 ) {
+    		(**p1)["plot"] = 1;
+    		for (CustomisedPointsList::iterator p2  = p1; p2 != filter.end(); ++p2) {
+    		
+    			if ( distance(*p1, *p2) < 1) {
+    				(**p2)["plot"] = 0;
+    			}
+    			
+    		}
+    	}
+    }
+    */
+    
+    for (vector<CustomisedPoint*>::iterator point = filter.begin(); point != filter.end(); ++point) {
+    	vector<CustomisedPoint*>::iterator last = std::remove_if(filter.begin(), filter.end(), Radius(radius, **point));
+         filter.erase(last, filter.end());
+     }
+    
+    for (vector<CustomisedPoint*>::iterator point = filter.begin(); point != filter.end(); ++point) {
+    
+    	UserPoint geo((*point)->longitude(), (*point)->latitude());
+    	text->push_back(transformation(geo), (*point)->identifier());
+    }
+    task.push_back(text);
+}
+
+NoCities::NoCities() 
+{
+}
+
+NoCities::~NoCities() 
+{
+}
+
+void NoCities::print(ostream& out)  const
+{
+	out << "NoCities[";
+	out << "]";
+}
+
+
diff --git a/src/visualisers/Cities.h b/src/visualisers/Cities.h
new file mode 100644
index 0000000..24e9c2b
--- /dev/null
+++ b/src/visualisers/Cities.h
@@ -0,0 +1,134 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Cities.h
+    \brief Definition of the Template class NoCities.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 29-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef Cities_H
+#define Cities_H
+
+#include "CitiesAttributes.h"
+#include "BasicGraphicsObject.h"
+#include "SceneVisitor.h"
+
+namespace magics {
+	
+class NoCities {
+
+public:
+	NoCities();
+	virtual ~NoCities();
+    
+	virtual void set(const XmlNode&) {}
+	virtual bool accept(const string&) { return false; }
+	virtual void set(const map<string, string>&) {}
+	virtual NoCities* clone() const
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new NoCities();
+	}
+
+	virtual void toxml(ostream&, int = 0) const
+	{
+		MagLog::dev() << "NoCities::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+	}
+
+	virtual void operator()(const map<string, string>&, BasicGraphicsObjectContainer&) {}
+    
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	NoCities(const NoCities&);
+	//! Overloaded << operator to copy - No copy allowed
+	NoCities& operator=(const NoCities&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoCities& p)
+		{ p.print(s); return s; }
+};
+
+
+template <>
+class MagTranslator<string, NoCities> { 
+public:
+	NoCities* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoCities>::create(val);
+	}     
+
+	NoCities* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+
+class Cities : public NoCities, public CitiesAttributes {
+
+public:
+	Cities();
+	virtual ~Cities();
+    
+	virtual void set(const XmlNode& node)
+	{
+		CitiesAttributes::set(node);
+	}
+
+	virtual void set(const map<string, string>& map)
+	{
+		CitiesAttributes::set(map);
+	}
+
+	bool accept(const string& node) { return CitiesAttributes::accept(node); }   
+
+	virtual NoCities* clone() const
+	{
+		MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+		return new Cities();
+	}
+
+	void operator()(const map<string, string>&, BasicGraphicsObjectContainer&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	Cities(const Cities&);
+	//! Overloaded << operator to copy - No copy allowed
+	Cities& operator=(const Cities&);
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/CoastPlotting.cc b/src/visualisers/CoastPlotting.cc
new file mode 100644
index 0000000..2de1b8d
--- /dev/null
+++ b/src/visualisers/CoastPlotting.cc
@@ -0,0 +1,497 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CoastPlotting.cc
+    \brief Implementation of the Template class CoastPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "CoastPlotting.h"
+#include "Timer.h"
+#include "SceneVisitor.h"
+
+#include "ViewNode.h"
+#include "ShapeDecoder.h"
+#include "LegendVisitor.h"
+#include "Polyline.h"
+#include "ParameterSettings.h"
+
+//#define BOOST_VERSION 104701
+#define BOOST_GEOMETRY_OVERLAY_NO_THROW
+
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+#include <boost/geometry/geometries/box.hpp>
+
+
+
+using namespace magics;
+
+#define PATH(a) getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + a;
+
+
+bool test110(const UserPoint& from, const UserPoint& to)
+{
+	if  (from.x_ == to.x_ )
+		return true;
+	if (abs(from.x_ - to.x_) == 360. )
+		return true;
+	return false;
+}
+
+bool test(const UserPoint& from, const UserPoint& to)
+{
+	return ( abs(from.x_ - to.x_ ) > 1 || abs(from.y_ - to.y_ ) > 1);
+}
+
+
+CoastPlotting::CoastPlotting() 
+{
+	MagLog::debug() << "DELETE COAST PLOTTING! " << endl;
+}
+
+NoCoastPlotting::NoCoastPlotting() 
+{
+	riversMethods_["on"] = &CoastPlotting::rivers;
+	riversMethods_["off"] = &CoastPlotting::ignore;
+}
+
+void NoCoastPlotting::visit(LegendVisitor&)
+{
+}
+
+void CoastPlotting::visit(LegendVisitor& legend)
+{
+	return;
+/*
+	Polyline* coast  = new Polyline();
+	coast->setThickness(thickness_);
+	coast->setColour(*colour_);
+	coast->setLineStyle(style_);	
+
+	LineEntry* entry = new LineEntry("Coastlines", coast);
+	legend.add(entry);
+*/
+}
+
+
+
+void CoastPlotting::operator()(PreviewVisitor& parent)
+{
+	const Transformation& transformation = parent.transformation();
+	//transformation.coastSetting(coastSet_, 10, 5);
+	CoastPlotting& preview = parent.coastlines();
+	transformation.coastSetting(preview.coastSet_, 10, 5);
+	preview.decode(parent);
+
+	for (vector<Polyline>::iterator poly = preview.ocean_.begin(); poly != preview.ocean_.end(); ++poly)
+	{
+		Polyline* npoly= poly->clone();
+		npoly->setThickness(thickness_);
+		npoly->setColour(*colour_);
+		npoly->setLineStyle(style_);
+		FillShadingProperties* shading = new FillShadingProperties();
+		npoly->setFillColour(Colour("white"));
+		npoly->setShading(shading);
+		npoly->setFilled(true);
+		parent.push_back(npoly);
+	}
+
+	for (vector<Polyline>::iterator poly = preview.coast_.begin(); poly != preview.coast_.end(); ++poly)
+	{
+		Polyline* npoly= poly->clone();
+		npoly->setThickness(thickness_);
+		npoly->setColour(*colour_);
+		npoly->setLineStyle(style_);
+		FillShadingProperties* shading = new FillShadingProperties();
+		npoly->setFillColour(Colour("cream"));
+		npoly->setShading(shading);
+		npoly->setFilled(true);
+
+		parent.push_back(npoly);
+	}
+
+	// Now we add the frame
+	Polyline* frame = new Polyline();
+	frame->setAntiAliasing(false);
+	frame->setThickness(thickness_);
+	frame->setColour(Colour("tan"));
+	frame->setLineStyle(style_);	
+	frame->push_back(PaperPoint(transformation.getMinX(), transformation.getMinY()));
+	frame->push_back(PaperPoint(transformation.getMaxX(), transformation.getMinY()));
+	frame->push_back(PaperPoint(transformation.getMaxX(), transformation.getMaxY()));
+	frame->push_back(PaperPoint(transformation.getMinX(), transformation.getMaxY()));
+	frame->push_back(PaperPoint(transformation.getMinX(), transformation.getMinY()));
+	parent.push_back(frame);
+}
+
+
+void NoCoastPlotting::operator()(DrawingVisitor& parent)
+{
+	const Transformation& transformation = parent.transformation();
+	transformation.coastSetting(coastSet_, parent.layout().absoluteWidth(), parent.layout().absoluteHeight());
+	(*boundaries_)(coastSet_, parent.layout());
+	layers(riversMethods_, rivers_, parent);
+	(*cities_)(coastSet_, parent.layout());
+}
+
+
+void NoCoastPlotting::rivers(DrawingVisitor& visitor)
+{
+	const string file = PATH(coastSet_["rivers"]);
+
+	ShapeDecoder rivers;
+	rivers.setPath(file);
+	rivers.needHoles(true);
+	const Transformation& transformation = visitor.transformation();
+	rivers.decode(transformation);
+
+	for ( ShapeDecoder::const_iterator river = rivers.begin(); river != rivers.end(); ++river)
+	{
+		Polyline poly;
+		poly.setColour(*rivers_colour_);
+		poly.setThickness(rivers_thickness_);
+
+		poly.setLineStyle(rivers_style_);
+		(**river).setToFirst();
+		while ((**river).more())
+		{
+		  poly.push_back(transformation((**river).current()));
+		  (**river).advance();
+		}
+		transformation(poly, visitor.layout());
+	}
+}
+
+void NoCoastPlotting::layers(map<string, Action>& methods, const string& val, DrawingVisitor& visitor)
+{
+	const string lval(lowerCase(val));
+	map<string, Action>::iterator method = methods.find(lval);
+	if ( method != methods.end() )
+		(this->*method->second)(visitor);
+}
+
+
+
+
+/*! \brief Method to set resource files for GIS information
+ 
+  \note We have to use '10m' resolution for administrative Provinces since only this 
+   resolution contains data from OUTSIDE the USA and Canada
+*/
+void CoastPlotting::operator()(DrawingVisitor& parent)
+{
+  Timer timer("coastlines", "prepare the coastlines");
+  //if ( !layer_) layer_ = &parent;
+
+  const Transformation& transformation = parent.transformation();
+
+  transformation.collect(meta_);
+
+
+
+  coast_.clear();
+  ocean_.clear();
+  lake_.clear();
+
+  coastSet_["administrative_boundaries"] = "10m/10m_admin_1_states_provinces_shp";
+
+  if ( magCompare(NoCoastPlottingAttributes::resolution_, "full") ) {
+        string resol = "10m";
+        coastSet_["resolution"] = "10m full";
+        coastSet_["lakes"]      = resol + "_full/" + resol + "_lakes";
+        coastSet_["land"]       = resol + "_full/" + resol + "_land";
+        coastSet_["rivers"]     = resol + "_full/" + resol + "_rivers_lake_centerlines";
+        coastSet_["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+  }
+  else if ( magCompare(NoCoastPlottingAttributes::resolution_, "high") ) {
+        string resol = "10m";
+        coastSet_["resolution"] = resol;
+        coastSet_["lakes"]      = resol + "/" + resol + "_lakes";
+        coastSet_["land"]       = resol + "/" + resol + "_land";
+        coastSet_["rivers"]     = resol + "/" + resol + "_rivers_lake_centerlines";
+        coastSet_["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+  }
+  else if ( magCompare(NoCoastPlottingAttributes::resolution_, "medium") ) {
+        string resol = "50m";
+        coastSet_["resolution"] = resol;
+        coastSet_["lakes"]      = resol + "/" + resol + "_lakes";
+        coastSet_["land"]       = resol + "/" + resol + "_land";
+        coastSet_["rivers"]     = resol + "/" + resol + "_rivers_lake_centerlines";
+        coastSet_["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+  }
+  else if ( magCompare(NoCoastPlottingAttributes::resolution_, "low") ) {
+        string resol = "110m";
+        coastSet_["resolution"] = resol;
+        coastSet_["lakes"]      = resol + "/" + resol + "_lakes";
+        coastSet_["land"]       = resol + "/" + resol + "_land";
+        coastSet_["rivers"]     = resol + "/" + resol + "_rivers_lake_centerlines";
+        coastSet_["boundaries"] = resol + "/" + resol + "_admin_0_boundary_lines_land";
+  }
+  else {       // automatic
+        transformation.coastSetting(coastSet_, parent.layout().absoluteWidth(), parent.layout().absoluteHeight());
+  }
+
+  decode(parent.layout());
+
+  // Now we have the coastlines and lakes..
+  // let's call the relevant method!
+  if ( land_ ) {
+		if ( sea_ )
+			landsea(parent.layout());
+		else
+			landonly(parent.layout());
+  }
+  else {
+		if ( sea_ )
+			seaonly(parent.layout());
+  }
+
+  nolandsea(parent.layout());
+  (*boundaries_)(coastSet_, parent.layout());
+  (*cities_)(coastSet_, parent.layout());
+  layers(riversMethods_, rivers_, parent);
+}
+
+
+/*!
+  Here we send send a big rectangle for the ocean
+  We send the coastlines as land and lakes as holes of coastlines as polylines.
+*/
+void CoastPlotting::landsea(Layout& out)
+{
+	landonly(out);
+	seaonly(out);
+}
+
+
+Polyline*  CoastPlotting::ocean(Layout& out)
+{
+	const Transformation& transformation = out.transformation();
+	Polyline& box = transformation.getPCBoundingBox();
+	Polyline* ocean = box.clone();
+	setSeaShading(*ocean);
+
+	out.push_back(ocean);
+	return ocean;
+}
+
+
+
+/*!
+  Here we send the coastlines as land.
+  We send the lakes as holes ... and the holes in the lakes as land!
+*/
+void CoastPlotting::landonly(Layout& out)
+{
+	for (vector<Polyline>::iterator poly = coast_.begin(); poly != coast_.end(); ++poly)
+	{
+		Polyline* coast = poly->clone();
+		setLandShading(*coast);
+
+
+		out.push_back(coast);
+	}
+}
+
+
+/*!
+ Here we send send a big rectangle for the ocean.
+ We send the coastlines as holes of the big one.
+ We send the lakes as polylines ... and the holes in the lakes as holes!
+*/
+void CoastPlotting::seaonly(Layout& out)
+{
+	Polyline* big = ocean(out);
+
+	for (vector<Polyline>::iterator poly = coast_.begin(); poly != coast_.end(); ++poly)
+	{
+		big->newHole(*poly);
+
+		// Now we add the holes as sea polylines!
+		for (Polyline::Holes::const_iterator hole = poly->beginHoles(); hole!= poly->endHoles(); ++hole) {
+			Polyline* h = poly->getNew();
+			setSeaShading(*h);
+			poly->hole(hole, *h);
+			out.push_back(h);
+		}
+	}
+
+
+}
+
+#include <boost/geometry/algorithms/distance.hpp>
+
+void CoastPlotting::nolandsea(Layout& visitor)
+{
+
+
+	for (vector<Polyline>::iterator coast = coast_.begin(); coast != coast_.end(); ++coast)
+	{
+		if ( coast->empty() )
+			continue;
+
+		Polyline* poly = new Polyline();
+		setLine(*poly);
+		Polyline::MagLine::const_iterator point = coast->begin();
+		poly->push_back(*point);
+		++point;
+		while ( point!=coast->end() ) {
+
+			double dist = point->distance(poly->back());
+			double res = tonumber(coastSet_["resolution"]);
+
+			if ( dist > visitor.transformation().patchDistance(res) ) {
+					if ( !poly->empty() ) {
+						visitor.push_back(poly);
+						poly = new Polyline();
+						setLine(*poly);
+					}
+			}
+
+			poly->push_back(*point);
+			++point;
+
+		}
+		visitor.push_back(poly);
+		// now the lakes!
+		for (Polyline::Holes::const_iterator lake = coast->beginHoles(); lake != coast->endHoles(); ++lake) {
+			Polyline* poly = new Polyline();
+			setLine(*poly);
+			for ( Polyline::MagLine::const_iterator point = lake->begin(); point != lake->end(); ++point)
+				poly->push_back(*point);
+			visitor.push_back(poly);
+		}
+	}
+}
+
+
+void CoastPlotting::setLine(Polyline& line)
+{
+	line.setThickness(thickness_);
+	line.setColour(*colour_);
+	line.setLineStyle(style_);
+	line.setShading(0);
+	line.setFilled(false);
+}
+
+
+void CoastPlotting::setSeaShading(Polyline& line)
+{
+	FillShadingProperties* shading = new FillShadingProperties();
+	line.setFillColour(*sea_colour_);
+	line.setShading(shading);
+	line.setColour(*sea_colour_);
+	line.setFilled(true);
+	line.setStroke(false);
+}
+
+
+void CoastPlotting::setLandShading(Polyline& line)
+{
+	FillShadingProperties* shading = new FillShadingProperties();
+	line.setFillColour(*land_colour_);
+
+	line.setColour(*land_colour_);
+	line.setShading(shading);
+	line.setFilled(true);
+	line.setStroke(false);
+}
+
+
+CoastPlotting::~CoastPlotting() 
+{}
+
+
+/*!
+ Class information are given to the output-stream.
+*/
+void CoastPlotting::print(ostream& out)  const
+{
+	out << "CoastPlotting[";
+	CoastPlottingAttributes::print(out);
+	out << "] ";
+}
+
+
+void CoastPlotting::decode(const Layout& parent )
+{
+	//Read the shape file ...
+	Timer timer("geometry", "Simplify+clip");
+	
+	const Transformation& transformation = parent.transformation();
+
+
+
+
+
+
+	vector<Polyline> coastlines;
+	vector<Polyline> lakes;
+	coast_.clear();
+
+	ShapeDecoder coastline_decoder;
+	string file = PATH(coastSet_["land"]);
+	coastline_decoder.setPath(file);
+	coastline_decoder.decode(coastlines, transformation);
+
+	ShapeDecoder lake_decoder;
+	file = PATH(coastSet_["lakes"]);
+	lake_decoder.setPath(file);
+	lake_decoder.decode(lakes, transformation);
+
+
+
+
+	//! Secondly we try to put the lakes in the continents!!!
+	for (vector<Polyline>::iterator coast = coastlines.begin(); coast != coastlines.end(); ++coast )
+	{
+		vector<Polyline> todolakes;
+		for (vector<Polyline>::iterator l = lakes.begin(); l != lakes.end(); ++l )
+		{
+			// we find the lake!
+			bool inside = l->in(*coast);
+			if ( inside )
+			{
+				coast->newHole(*l);
+			}
+			else {
+				todolakes.push_back(*l);
+			}
+		}
+		lakes = todolakes;
+		coast_.push_back(*coast);
+	}
+
+}
+
+void NoCoastPlotting::visit(MetaDataCollector& meta)
+{
+	meta["Coastlines Resolution"] = coastSet_["resolution"];
+	meta["Coastlines DataSet"] = "Natural Earth";
+	for (map<string, string>::const_iterator entry = meta_.begin(); entry != meta_.end(); ++entry ) {
+		meta[entry->first] = entry->second;
+	}
+}
diff --git a/src/visualisers/CoastPlotting.h b/src/visualisers/CoastPlotting.h
new file mode 100644
index 0000000..1ba6b0d
--- /dev/null
+++ b/src/visualisers/CoastPlotting.h
@@ -0,0 +1,215 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CoastPlotting.h
+    \brief Definition of the Template class CoastPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+
+
+/*!
+  \defgroup coastlines Coastlines
+  
+  \section overviewCoast Overview
+  
+  Coastlines are stored in SHP files and are stored in <i>share/magics/??m</i> directories.
+  The shape files are downloaded from <a href="http://www.naturalearthdata.com/">http://www.naturalearthdata.com/</a>.
+  
+  \section sourceCode Coding
+  
+  - Parameters are defined in src/xml/CoastPlotting.xml
+  
+  - Generated files src/visualisers/BoundariesAttributes.cc src/visualisers/CoastPlottingAttributes.cc src/visualisers/CitiesAttributes.cc
+  
+  - Code for shape file reading is in src/decoders/ShapeDecoder.cc
+  
+  - Code for coastline processing src/visualisers/CoastPlotting.cc
+  
+  \section Boundaries Boundaries
+
+-   src/visualisers/Boundaries.cc
+  
+  \section readingOfShape Pre-processing and reading of Shape files
+
+  Only the following extensions are required for shape files: [ dbf, shp, shx, prj ]. Extensions .sbn and sbx are undocumented formats used only by ESRI software.
+
+  To extract subsets of shape files into other shape files use the ogr2ogr command line utility (from gdal) as follows:
+ 
+      ogr2ogr <output_folder> <input_shape_file>.shp -where "<condition>"
+
+  For example, to ignore minor feature data in the 10m shape files we did the following:
+
+      ogr2ogr output_folder 10m_lakes.shp -where "ScaleRank < 7"
+
+  Where 'ScaleRank' is one of the fields in the shape file. Information on which fields are present are given in the .dbf file (which can be opened with Open Office Spreadsheet).
+
+  Conditions can be combined, for example
+
+      ogr2ogr output_folder 10m_lakes.shp -where "ScaleRank = 1 AND Name2 != 'Great Lakes'"
+
+*/
+
+
+#ifndef CoastPlotting_H
+#define CoastPlotting_H
+
+#include "magics.h"
+
+#include "NoCoastPlottingAttributes.h"
+#include "CoastPlottingAttributes.h"
+#include "BasicSceneObject.h"
+#include "BasicGraphicsObject.h"
+#include "UserPoint.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "Polyline.h"
+#include "Layer.h"
+namespace magics {
+
+class PreviewVisitor;
+
+class NoCoastPlotting: public NoCoastPlottingAttributes{
+public :
+	NoCoastPlotting();
+	virtual ~NoCoastPlotting() {}
+
+	void set(const XmlNode& node)
+	{
+		NoCoastPlottingAttributes::set(node);
+	}
+
+	virtual void set(const map<string, string>& map)
+	{
+		NoCoastPlottingAttributes::set(map);
+	}
+	bool accept(const string& node) { return NoCoastPlottingAttributes::accept(node); }
+	virtual NoCoastPlotting* clone() const
+	{
+		return new NoCoastPlotting();
+	}
+	virtual void operator()(DrawingVisitor& parent);
+	virtual void operator()(PreviewVisitor&) {}
+	virtual void layer(BasicGraphicsObjectContainer*) {}
+	virtual void visit(LegendVisitor&);
+	virtual void visit(MetaDataCollector&);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "NoCoastPlotting\n"; }
+		typedef void (NoCoastPlotting::*Action)(DrawingVisitor&);
+		std::map<string, Action> riversMethods_;
+		
+		void rivers(DrawingVisitor&);
+		void ignore(DrawingVisitor&) {}
+		
+		void layers(map<string, Action>&, const string&, DrawingVisitor&);
+		map<string, string> coastSet_;
+		MetaDataCollector meta_;
+private:
+    //! Copy constructor - No copy allowed
+	NoCoastPlotting(const NoCoastPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoCoastPlotting& operator=(const NoCoastPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoCoastPlotting& p)
+		{ p.print(s); return s; }
+};
+
+
+
+class CoastPlotting: public NoCoastPlotting, public CoastPlottingAttributes {
+
+public:
+
+	CoastPlotting();
+	virtual ~CoastPlotting();
+	void set(const XmlNode& node) {
+			CoastPlottingAttributes::set(node);
+			NoCoastPlottingAttributes::set(node);
+	}
+
+	virtual void set(const map<string, string>& map)
+	{
+			NoCoastPlottingAttributes::set(map);
+			CoastPlottingAttributes::set(map);
+	}
+	bool accept(const string& node) { return NoCoastPlottingAttributes::accept(node); }
+
+	virtual NoCoastPlotting* clone() const {
+		CoastPlotting* object = new CoastPlotting();
+		//object->copy(*this);
+		return object;
+	}
+
+	virtual void visit(LegendVisitor&);
+	virtual void operator()(DrawingVisitor&);
+	virtual void operator()(PreviewVisitor&);
+
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const;
+
+	void decode(const Layout&);
+	
+	void landsea(Layout&);
+	void landonly(Layout&);
+	void seaonly(Layout&);
+	void nolandsea(Layout&);
+
+	void setLine(Polyline&);
+	void setSeaShading(Polyline&);
+	void setLandShading(Polyline&);
+	Polyline* ocean(Layout&);
+
+	string coast_resolution_;
+
+	vector<Polyline> coast_;
+	vector<Polyline> lake_;
+	vector<Polyline> ocean_;
+
+
+};
+
+
+template <>
+class MagTranslator<string, NoCoastPlotting> {
+public:
+	NoCoastPlotting* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoCoastPlotting>::create(val);
+	}
+
+	NoCoastPlotting* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/CoastPlottingAttributes.h b/src/visualisers/CoastPlottingAttributes.h
new file mode 100644
index 0000000..594e679
--- /dev/null
+++ b/src/visualisers/CoastPlottingAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file CoastPlottingAttributes.h
+    \brief Definition of CoastPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef CoastPlottingAttributes_H
+#define CoastPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class CoastPlottingAttributes 
+{
+public:
+//  --  constructor
+    CoastPlottingAttributes();
+    
+//  --  destructor
+    virtual ~CoastPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const CoastPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<Colour> colour_;
+	LineStyle style_;
+	int thickness_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const CoastPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Coastlines.cc b/src/visualisers/Coastlines.cc
new file mode 100644
index 0000000..94439a8
--- /dev/null
+++ b/src/visualisers/Coastlines.cc
@@ -0,0 +1,142 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Coastlines.cc 
+    \brief Implementation of the Template class Coastlines.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 29-Jan-2004
+    
+    Changes:
+    
+*/
+
+#include "Coastlines.h"
+#include "Layer.h"
+
+using namespace magics;
+ 
+Coastlines::Coastlines() 
+{
+	setInfo("_datatype","Coastlines");
+}
+
+Coastlines::~Coastlines() { if ( layer_ ) delete layer_; }
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Coastlines::print(ostream& out)  const
+{
+	out << "Coastlines[";
+	CoastlinesAttributes::print(out);
+	out << "]";
+}
+
+
+#include "Transformation.h"
+
+void Coastlines::visit(DrawingVisitor& parent)
+{
+
+	(*coastlines_)(parent);
+	
+	
+	(*grid_)(parent);
+	 
+
+	(*label_).prepare(*grid_);
+	
+	(*label_)(parent);
+
+}
+
+void Coastlines::visit(LeftAxisVisitor& parent)
+{
+	(*label_).prepare(*grid_); 
+	(*label_)(parent);
+}
+void Coastlines::visit(TextVisitor& )
+{
+	// Nothing to put in the title
+}
+void Coastlines::visit(LegendVisitor& legend)
+{
+	coastlines_->visit(legend);
+}
+void Coastlines::visit(RightAxisVisitor& parent)
+{
+	(*label_).prepare(*grid_); 
+	(*label_)(parent);
+}
+
+void Coastlines::visit(TopAxisVisitor& parent)
+{	
+	(*label_).prepare(*grid_); 
+	(*label_)(parent);
+}
+
+void Coastlines::visit(BottomAxisVisitor& parent)
+{
+	(*label_).prepare(*grid_); 
+	(*label_)(parent);
+}
+
+
+void Coastlines::visit(PreviewVisitor& preview)
+{	
+	(*coastlines_)(preview);
+}
+
+void Coastlines::visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors)
+{
+#ifdef MAG_NEXT
+	// First we create the layer!
+	// and push It to the parent layer! 
+	if (layer.state() == geometry_changed ) {
+		assert (layer_);
+		layer_->clean();
+	}
+	else 
+#endif
+    {
+    // First we create the layer!
+	// and push It to the parent layer! 
+		layer_ = new NoDataLayer(this);
+		layer_->id(iconName_);
+		layer_->name(iconName_);
+		layer.add(layer_);
+	}
+	for  (vector<LayoutVisitor*>::iterator visitor = visitors.begin(); visitor != visitors.end(); ++visitor) {
+		layer_->set(*visitor);
+		(*visitor)->visit(*this);
+	}
+	
+}
+void Coastlines::visit(MetaDataCollector& meta)
+{
+
+	MetviewIcon::visit(meta);
+	coastlines_->visit(meta);
+}
+
+void Coastlines::visit(Transformation& transformation)
+{
+	label_->label(transformation);
+}
diff --git a/src/visualisers/Coastlines.h b/src/visualisers/Coastlines.h
new file mode 100644
index 0000000..2b844cc
--- /dev/null
+++ b/src/visualisers/Coastlines.h
@@ -0,0 +1,86 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Coastlines.h
+    \brief Definition of the Template class Coastlines.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 29-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Coastlines_H
+#define Coastlines_H
+
+#include "magics.h"
+
+#include "SceneVisitor.h"
+#include "CoastlinesAttributes.h"
+#include "BasicSceneObject.h"
+#include "MagicsEvent.h"
+
+namespace magics {
+
+class ProgressObject;
+class StaticLayer;
+
+class Coastlines: public CoastlinesAttributes, public BasicSceneObject {
+
+public:
+	Coastlines();
+	virtual ~Coastlines();
+    
+	
+	
+	// New Interface!
+	void visit(DrawingVisitor& list);	
+	void visit(TextVisitor&);
+	void visit(LegendVisitor& );
+	void visit(LeftAxisVisitor& list);
+	void visit(BottomAxisVisitor& list);
+	void visit(TopAxisVisitor& list);
+	void visit(RightAxisVisitor& list);
+	void visit(MetaDataCollector& list);
+
+	void visit(PreviewVisitor& list);
+	void visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors);
+	void visit(Transformation& transformation);
+	void set(const map<string, string>& map ) { CoastlinesAttributes::set(map); }
+	void set(const XmlNode& node ) { CoastlinesAttributes::set(node); }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	StaticLayer* layer_;
+private:
+	//! Copy constructor - No copy allowed
+	Coastlines(const Coastlines&);
+	//! Overloaded << operator to copy - No copy allowed
+	Coastlines& operator=(const Coastlines&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Coastlines& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/CoastlinesAttributes.h b/src/visualisers/CoastlinesAttributes.h
new file mode 100644
index 0000000..4369f25
--- /dev/null
+++ b/src/visualisers/CoastlinesAttributes.h
@@ -0,0 +1,86 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file CoastlinesAttributes.h
+    \brief Definition of Coastlines Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef CoastlinesAttributes_H
+#define CoastlinesAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "GridPlotting.h"
+#include "LabelPlotting.h"
+#include "CoastPlotting.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class CoastlinesAttributes 
+{
+public:
+//  --  constructor
+    CoastlinesAttributes();
+    
+//  --  destructor
+    virtual ~CoastlinesAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const CoastlinesAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<NoCoastPlotting> coastlines_;
+	auto_ptr<NoGridPlotting> grid_;
+	auto_ptr<NoLabelPlotting> label_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const CoastlinesAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ColourSelection.h b/src/visualisers/ColourSelection.h
new file mode 100644
index 0000000..c218644
--- /dev/null
+++ b/src/visualisers/ColourSelection.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourSelection.h
+    \brief Definition of the Template class ColourSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ColourSelection_H
+#define ColourSelection_H
+
+#include "magics.h"
+
+#include "FloatSelection.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+namespace magics {
+
+class XmlNode;
+
+class ColourSelection: public FloatSelection {
+
+public:
+	ColourSelection();
+	virtual ~ColourSelection();
+    virtual void set(const map<string,string>&) {}
+	virtual void set(const XmlNode&) {}
+	 virtual void toxml(ostream&, int)  const {}
+	virtual ColourSelection* clone() const {
+    	ColourSelection* object = new ColourSelection();
+    	return object;
+    }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourSelection(const ColourSelection&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourSelection& operator=(const ColourSelection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourSelection& p)
+		{ p.print(s); return s; }
+
+};
+template<>
+class MagTranslator<string, ColourSelection> { 
+public:
+	ColourSelection* operator()(const string& val )
+	{
+		return SimpleObjectMaker<ColourSelection>::create(val);
+	}     
+
+	ColourSelection* magics(const string& param)
+	{
+		ColourSelection* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ColourSelectionCount.h b/src/visualisers/ColourSelectionCount.h
new file mode 100644
index 0000000..5f3b244
--- /dev/null
+++ b/src/visualisers/ColourSelectionCount.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourSelectionCount.h
+    \brief Definition of the Template class ColourSelectionCount.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ColourSelectionCount_H
+#define ColourSelectionCount_H
+
+#include "magics.h"
+
+#include "ColourSelection.h"
+#include "ColourSelectionCountAttributes.h"
+
+namespace magics {
+
+class ColourSelectionCount: public ColourSelection, public ColourSelectionCountAttributes {
+
+public:
+	ColourSelectionCount();
+	virtual ~ColourSelectionCount();
+    virtual void set(map<string,string> map) { ColourSelectionCountAttributes::set(map); }
+    virtual void prepare();
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourSelectionCount(const ColourSelectionCount&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourSelectionCount& operator=(const ColourSelectionCount&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourSelectionCount& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ColourSelectionList.h b/src/visualisers/ColourSelectionList.h
new file mode 100644
index 0000000..8dcb65f
--- /dev/null
+++ b/src/visualisers/ColourSelectionList.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourSelectionList.h
+    \brief Definition of the Template class ColourSelectionList.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ColourSelectionList_H
+#define ColourSelectionList_H
+
+#include "magics.h"
+
+#include "ColourSelection.h"
+#include "ColourSelectionListAttributes.h"
+
+namespace magics {
+
+class ColourSelectionList: public ColourSelection, public ColourSelectionListAttributes {
+
+public:
+	ColourSelectionList();
+	virtual ~ColourSelectionList();
+    virtual void set(map<string,string> map) { ColourSelectionListAttributes::set(map); }
+    void prepare();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ColourSelectionList(const ColourSelectionList&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourSelectionList& operator=(const ColourSelectionList&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourSelectionList& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ColourTechnique.cc b/src/visualisers/ColourTechnique.cc
new file mode 100644
index 0000000..2cae036
--- /dev/null
+++ b/src/visualisers/ColourTechnique.cc
@@ -0,0 +1,189 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTechnique.cc
+    \brief Implementation of the Template class ColourTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "ColourTechnique.h"
+#include "LevelSelection.h"
+#include "LegendVisitor.h"
+#include "Polyline.h"
+#include <limits>
+
+using namespace magics;
+
+ColourTechnique::ColourTechnique() 
+{
+}
+
+
+ColourTechnique::~ColourTechnique() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ColourTechnique::print(ostream& out)  const
+{
+	out << "ColourTechnique[";
+	out << "]";
+}
+
+void ColourTechnique::prepare(const LevelSelection& levels) 
+{
+	if (levels.empty() ) return; 
+	clear();
+	bands_.clear();
+	ColourTable table;
+	set(table, levels.size());
+	
+	if ( table.empty()) table.push_back(Colour("none"));
+    ColourTable::ColourIterator colour = table.begin(); 
+    
+    Colour left("NONE");
+    
+ 
+    Colour right = colour->colour();
+    double min = std::numeric_limits<double>::max();
+    
+    double previous = 0;
+    int index = 0;
+    
+    for (LevelSelection::const_iterator  val  = levels.begin();  val != levels.end(); ++val)
+    {               
+    	
+         (*this)[*val] = ColourInfo(index, *val, left, right);
+         ranges_[*val] = make_pair(previous, *val);
+         previous = *val;
+         index++;
+         if ( min != std::numeric_limits<double>::max() ) {
+            bands_.insert(make_pair(Interval(min, *val), left));
+            
+            MagLog::dev() << min << "<<" << left << "<<" << *val << endl;
+         }
+         min = *val;
+         left = right;            
+         colour++;         
+         if ( colour == table.end()) {
+         	right = Colour("NONE");
+         	colour--;
+         }
+         else right = colour->colour();
+         MagLog::dev() << (*this)[*val].left_ << "<" << *val << "<" << (*this)[*val].right_ << "\n";       
+    }
+    bands_.insert(make_pair(Interval(levels.back(), levels.back() + epsilon), left));
+} 
+
+Colour ColourTechnique::operator()(double value) const 
+{
+    const_iterator info = find(value);
+    if (info == end() ) {
+        //MagLog::warning() << "canot find a colour for " << value << "\n";
+        return Colour(-1, -1, -1);
+    }
+    return info->second.left_;
+} 
+
+Colour ColourTechnique::left(double value) const 
+{
+    const_iterator info = find(value);
+    if (info == end() ) {
+        //MagLog::warning() << "canot find a colour for " << value << "\n";
+        return Colour(-1,-1,-1);
+    }
+    return info->second.left_;
+} 
+
+Colour ColourTechnique::right(double value) const
+{
+    const_iterator info = find(value);
+    if (info == end() ) {
+        //MagLog::warning() << "canot find a colour for " << value << "\n";
+        return Colour(-1,-1,-1);
+    }
+    return info->second.right_;
+}
+double ColourTechnique::leftRange(double value) const 
+{
+    map<double, pair<double, double> >::const_iterator info = ranges_.find(value);
+    if (info == ranges_.end() ) {
+        //MagLog::warning() << "canot find a colour for " << value << "\n";
+        return INT_MAX;
+    }
+    return info->second.first;
+} 
+
+double ColourTechnique::rightRange(double value) const
+{
+    map<double, pair<double, double> >::const_iterator info = ranges_.find(value);
+    if (info == ranges_.end() ) {
+        //MagLog::warning() << "canot find a colour for " << value << "\n";
+    	 return INT_MAX;
+    }
+    return  info->second.second;
+}
+
+Colour ColourTechnique::colour(double value) const 
+{
+ 
+    return bands_.find(value, Colour("none"));; 
+} 
+
+
+void ColourTechnique::colours(vector<string>& colours) const
+{
+	for ( IntervalMap<Colour>::const_iterator band = bands_.begin(); band != bands_.end(); ++band) 	
+	    colours.push_back(band->second.name());
+		
+}
+
+void ColourTechnique::visit(LegendVisitor& legend) 
+{
+	for ( IntervalMap<Colour>::const_iterator band = bands_.begin(); band != bands_.end(); ++band) 
+	{
+		double min = band->first.min_;
+		double max = band->first.max_;
+		Polyline* box = new Polyline();
+		box->setColour(Colour("black"));
+		box->setFilled(true);
+		box->setFillColour(band->second);
+		//MagLog::dev()<< "From " << min << " to " << max << "-->" << band->second << endl;
+        FillShadingProperties* shading = new FillShadingProperties();
+       
+       
+        box->setShading(shading);
+     
+        
+        
+        legend.add(new BoxEntry(min, max, box));
+     
+	}	
+}
+
+
diff --git a/src/visualisers/ColourTechnique.h b/src/visualisers/ColourTechnique.h
new file mode 100644
index 0000000..bdc7bb4
--- /dev/null
+++ b/src/visualisers/ColourTechnique.h
@@ -0,0 +1,136 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ColourTechnique.h
+    \brief Definition of the Template class ColourTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ColourTechnique_H
+#define ColourTechnique_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "ColourTable.h"
+#include "IntervalMap.h"
+
+
+namespace magics {
+
+class LevelSelection;
+class LegendVisitor;
+
+struct ColourInfo 
+{
+    ColourInfo() :  index_(-1), level_(0), left_("NONE"), right_("NONE") {}
+    ColourInfo(int index, double level, const Colour& left, const Colour& right) :
+        index_(index), level_(level), left_(left), right_(right) {}
+    
+    int      index_;
+    double level_;
+    Colour   left_;
+    Colour   right_;
+};
+
+
+class ColourTechniqueInterface 
+{
+public:
+    virtual const Colour&  getMinColour() const = 0; 
+    virtual const Colour&  getMaxColour() const = 0;
+    virtual const string& getDirection() const = 0;
+    virtual stringarray getColours() const = 0;
+};
+
+
+
+
+class ColourTechnique : public map<double, ColourInfo>  {
+
+public:
+	ColourTechnique();
+	virtual ~ColourTechnique();
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual bool accept(const string&) { return false; }
+    virtual ColourTechnique* clone() const { return new ColourTechnique(); }
+    void toxml(ostream&)  const {}
+    virtual void set(const ColourTechniqueInterface&) {};
+    
+    Colour operator()(double) const;
+    Colour left(double) const;
+    Colour right(double) const;
+    Colour colour(double) const;
+    double leftRange(double) const;
+    double rightRange(double) const;
+    
+    virtual void set(ColourTable&, int) const {}
+    void prepare(const LevelSelection&);  
+    
+    void colours(vector<string>&) const; 
+    
+	void visit(LegendVisitor&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     IntervalMap<Colour> bands_;
+     
+     map<double, pair<double, double> > ranges_;
+     
+     
+    
+     
+private:
+    //! Copy constructor - No copy allowed
+	ColourTechnique(const ColourTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	ColourTechnique& operator=(const ColourTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ColourTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, ColourTechnique> { 
+public:
+	ColourTechnique* operator()(const string& val ) {
+		 return SimpleObjectMaker<ColourTechnique>::create(val);
+	}     
+    ColourTechnique* magics(const string& param)
+    {
+        ColourTechnique* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ContinuousLegendMethodAttributes.h b/src/visualisers/ContinuousLegendMethodAttributes.h
new file mode 100644
index 0000000..07ce6d8
--- /dev/null
+++ b/src/visualisers/ContinuousLegendMethodAttributes.h
@@ -0,0 +1,81 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ContinuousLegendMethodAttributes.h
+    \brief Definition of ContinuousLegendMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef ContinuousLegendMethodAttributes_H
+#define ContinuousLegendMethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ContinuousLegendMethodAttributes 
+{
+public:
+//  --  constructor
+    ContinuousLegendMethodAttributes();
+    
+//  --  destructor
+    virtual ~ContinuousLegendMethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ContinuousLegendMethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	int label_frequency_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ContinuousLegendMethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Contour.cc b/src/visualisers/Contour.cc
new file mode 100644
index 0000000..9602441
--- /dev/null
+++ b/src/visualisers/Contour.cc
@@ -0,0 +1,152 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Contour.cc
+    \brief Implementation of the Template class Contour.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 3-Mar-2004
+
+    Changes:
+    
+*/
+
+#include "Contour.h"
+#include "Layout.h"
+#include "Layer.h"
+#include "Text.h"
+#include "ContourLibrary.h"
+#include "HistoVisitor.h"
+
+using namespace magics;
+
+
+Contour::Contour() : matrix_(0)
+{
+}
+
+
+Contour::~Contour()
+{
+	if (matrix_) delete(matrix_);
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void Contour::print(ostream& out)  const
+{
+	out << "Contour[";
+	ContourAttributes::print(out);
+	out << "]";
+}
+
+
+class MatrixTreshold : public MatrixHandler
+{
+public :
+	MatrixTreshold(const AbstractMatrix& matrix, double min, double max) : 
+		MatrixHandler(matrix), min_(min), max_(max)
+	{
+	}
+	double operator()(int row, int column) const { 
+		double val = this->matrix_(row, column); 
+		if ( same(val, this->matrix_.missing()) ) 
+				return val;
+		if ( val  < min_ ) return min_;
+		if ( val  > max_ ) return max_;
+		return val; 
+	}
+	double min_;
+	double max_;
+};
+
+
+void Contour::operator()(Data& data, BasicGraphicsObjectContainer& parent)
+{
+    try {
+    	if (this->setting_ )
+	{
+    		// Here we try call the Contour libry to set up visual properties...
+    		MetaDataCollector needId,needAttributes;
+    		map<string, string> attributes;
+    		
+    		ContourLibrary library;
+		library.askId(needId);
+		data.visit(needId);
+		if(library.checkId(needId,needAttributes))
+		{			
+    			data.visit(needAttributes);
+    			library.getAttributes(needAttributes,attributes);
+    			this->set(attributes);
+    		}
+    	}
+    data.getReady(parent.transformation());
+	MatrixHandler* matrix = new MatrixHandler(data.matrix());
+	MatrixHandler* box =  parent.transformation().prepareData(*matrix);
+	if ( !box->rows() ||  !box->columns() ) {
+		delete box;
+		return;
+	}
+
+	matrix_ = (*this->method_).handler(*box, parent);
+
+	if (this->floor_ != -INT_MAX || this->ceiling_ != INT_MAX)
+		matrix_ = new MatrixTreshold(*matrix_, this->floor_, this->ceiling_);
+
+	(*this->contour_).adjust(matrix_->min(), matrix_->max());
+	(*this->contour_)(*matrix_, parent);
+
+	(*this->contour_)(data, parent);
+	if ( magCompare( this->grid_->getType(), "akima" ) )
+		(*this->grid_)(*matrix_, parent);
+	else 
+		(*this->grid_)(data, parent);
+	(*this->hilo_)(*matrix_, parent);
+
+// We do not need the box anymore!
+	delete box;
+
+    }
+    catch (MagicsException& e) 
+    {
+    	// Do nothing! 
+    }
+}
+
+
+void  Contour::visit(Data& data, HistoVisitor& visitor)
+{
+	if ( !matrix_ )
+		return;
+
+
+	contour_->visit(data, data.points(*visitor.dataLayoutTransformation(), false), visitor);
+	
+}
+
+
+void Contour::visit(Data& data, LegendVisitor& legend)
+{
+	if ( !this->legend_ ) return;
+	contour_->visit(data, legend);
+
+}
+
diff --git a/src/visualisers/Contour.h b/src/visualisers/Contour.h
new file mode 100644
index 0000000..0f088fa
--- /dev/null
+++ b/src/visualisers/Contour.h
@@ -0,0 +1,86 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Contour.h
+    \brief Definition of the Template class Contour.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 3-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Contour_H
+#define Contour_H
+
+#include "magics.h"
+
+#include "ContourAttributes.h"
+#include "Visdef.h"
+
+namespace magics {
+
+
+
+class Contour: public ContourAttributes, public Visdef {
+
+public:
+   
+	Contour();
+	virtual ~Contour();
+	
+	virtual Contour* clone() const {
+		Contour* contour = new Contour();
+		contour->copy(*this);
+		return contour;
+	}
+	bool needLegend() { return legend_; }
+	// Implements the set method ... 
+	void set(const XmlNode& node)                  { ContourAttributes::set(node); }
+	void set(const map<string, string>& map) { ContourAttributes::set(map); }
+	
+    // Implements the VisDefinterface 
+   virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+   virtual void visit(Data&, LegendVisitor&);
+    
+   void visit(Data&, HistoVisitor&);
+    
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 MatrixHandler* matrix_;
+
+private:
+    //! Copy constructor - No copy allowed
+	Contour(const Contour&);
+    //! Overloaded << operator to copy - No copy allowed
+	Contour& operator=(const Contour&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Contour& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ContourAttributes.cc b/src/visualisers/ContourAttributes.cc
new file mode 100644
index 0000000..c04806b
--- /dev/null
+++ b/src/visualisers/ContourAttributes.cc
@@ -0,0 +1,206 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ContourAttributes.cc
+    \brief Implementation of Contour Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "ContourAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+ContourAttributes::ContourAttributes():
+	legend_(ParameterManager::getBool("legend")),
+	contour_(MagTranslator<string, IsoPlot>().magics("contour")),
+	method_(MagTranslator<string, ContourMethod>().magics("contour_method")),
+	floor_(ParameterManager::getDouble("contour_interpolation_floor")),
+	ceiling_(ParameterManager::getDouble("contour_interpolation_ceiling")),
+	setting_(ParameterManager::getBool("contour_automatic_setting")),
+	library_path_(ParameterManager::getString("contour_automatic_library_path")),
+	hilo_(MagTranslator<string, HiLoBase>().magics("contour_hilo")),
+	grid_(MagTranslator<string, ValuePlotBase>().magics("contour_grid_value_plot"))
+{
+} 
+
+
+
+ContourAttributes::~ContourAttributes()
+{
+}
+
+    
+void ContourAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "contour";
+
+	setAttribute(prefix, "legend", legend_, params);
+	setMember(prefix, "contour", contour_, params);
+	setMember(prefix, "contour_method", method_, params);
+	setAttribute(prefix, "contour_interpolation_floor", floor_, params);
+	setAttribute(prefix, "contour_interpolation_ceiling", ceiling_, params);
+	setAttribute(prefix, "contour_automatic_setting", setting_, params);
+	setAttribute(prefix, "contour_automatic_library_path", library_path_, params);
+	setMember(prefix, "contour_hilo", hilo_, params);
+	setMember(prefix, "contour_grid_value_plot", grid_, params);
+}
+
+void ContourAttributes::copy(const ContourAttributes& other)
+{
+	legend_ = other.legend_;
+	contour_ = auto_ptr<IsoPlot>(other.contour_->clone());
+	method_ = auto_ptr<ContourMethod>(other.method_->clone());
+	floor_ = other.floor_;
+	ceiling_ = other.ceiling_;
+	setting_ = other.setting_;
+	library_path_ = other.library_path_;
+	hilo_ = auto_ptr<HiLoBase>(other.hilo_->clone());
+	grid_ = auto_ptr<ValuePlotBase>(other.grid_->clone());
+} 
+
+
+bool ContourAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "contour")  )
+		return true;
+
+	if ( acceptNode(node, contour_) )
+		return true;
+
+	if ( acceptNode(node, method_) )
+		return true;
+
+	if ( acceptNode(node, hilo_) )
+		return true;
+
+	if ( acceptNode(node, grid_) )
+		return true;
+	return false;
+}
+
+void ContourAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "contour") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), contour_, node);
+		setMember(node.name(), method_, node);
+		setMember(node.name(), hilo_, node);
+		setMember(node.name(), grid_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), contour_, *(*elt)); 
+		setMember((*elt)->name(), method_, *(*elt)); 
+		setMember((*elt)->name(), hilo_, *(*elt)); 
+		setMember((*elt)->name(), grid_, *(*elt)); 
+	}
+}
+
+void ContourAttributes::print(ostream& out)  const
+{
+	out << "ContourAttributes[";
+	out << "legend = " << legend_;
+	out << ", contour = " << *contour_;
+	out << ", method = " << *method_;
+	out << ", floor = " << floor_;
+	out << ", ceiling = " << ceiling_;
+	out << ", setting = " << setting_;
+	out << ", library_path = " << library_path_;
+	out << ", hilo = " << *hilo_;
+	out << ", grid = " << *grid_;
+	out << "]" << "\n";
+}
+
+
+void ContourAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"contour\"";
+	 out << ", \"legend\":";
+	 niceprint(out,legend_);
+	 out << ", \"contour\":";
+	 contour_->toxml(out);
+	 out << ", \"contour_method\":";
+	 method_->toxml(out);
+	 out << ", \"contour_interpolation_floor\":";
+	 niceprint(out,floor_);
+	 out << ", \"contour_interpolation_ceiling\":";
+	 niceprint(out,ceiling_);
+	 out << ", \"contour_automatic_setting\":";
+	 niceprint(out,setting_);
+	 out << ", \"contour_automatic_library_path\":";
+	 niceprint(out,library_path_);
+	 out << ", \"contour_hilo\":";
+	 hilo_->toxml(out);
+	 out << ", \"contour_grid_value_plot\":";
+	 grid_->toxml(out);
+}
+static MagicsParameter<string> legend("legend", "off", "");
+static MagicsParameter<string> contour("contour", "on", "");
+static MagicsParameter<string> contour_method("contour_method", "automatic", "");
+static MagicsParameter<double> contour_interpolation_floor("contour_interpolation_floor", -INT_MAX, "");
+static MagicsParameter<double> contour_interpolation_ceiling("contour_interpolation_ceiling", INT_MAX, "");
+static MagicsParameter<string> contour_automatic_setting("contour_automatic_setting", "off", "");
+static MagicsParameter<string> contour_automatic_library_path("contour_automatic_library_path", "", "");
+static MagicsParameter<string> contour_hilo("contour_hilo", "off", "");
+static MagicsParameter<string> contour_grid_value_plot("contour_grid_value_plot", "off", "");
+#include "IsoPlot.h"
+static SimpleObjectMaker<IsoPlot, IsoPlot> on_IsoPlot("on");
+static SimpleObjectMaker<IsoPlot, IsoPlot> isoline_IsoPlot("isoline");
+static SimpleObjectMaker<NoIsoPlot, IsoPlot> off_NoIsoPlot("off");
+static SimpleObjectMaker<NoIsoPlot, IsoPlot> noisoline_NoIsoPlot("noisoline");
+#include "Akima474Method.h"
+#include "ContourMethod.h"
+#include "AutomaticContourMethod.h"
+#include "Akima760Method.h"
+static SimpleObjectMaker<AutomaticContourMethod, ContourMethod> automatic_AutomaticContourMethod("automatic");
+static SimpleObjectMaker<SampleContourMethod, ContourMethod> sample_SampleContourMethod("sample");
+static SimpleObjectMaker<ContourMethod, ContourMethod> linear_ContourMethod("linear");
+static SimpleObjectMaker<Akima760Method, ContourMethod> akima760_Akima760Method("akima760");
+static SimpleObjectMaker<Akima474Method, ContourMethod> akima474_Akima474Method("akima474");
+#include "HiLo.h"
+static SimpleObjectMaker<HiLo, HiLoBase> on_HiLo("on");
+static SimpleObjectMaker<HiLo, HiLoBase> hilo_HiLo("hilo");
+static SimpleObjectMaker<NoHiLo, HiLoBase> off_NoHiLo("off");
+static SimpleObjectMaker<NoHiLo, HiLoBase> nohilo_NoHiLo("nohilo");
+static SimpleObjectMaker<HighHiLo, HiLoBase> hi_HighHiLo("hi");
+static SimpleObjectMaker<HighHiLo, HiLoBase> high_HighHiLo("high");
+static SimpleObjectMaker<LowHiLo, HiLoBase> lo_LowHiLo("lo");
+static SimpleObjectMaker<LowHiLo, HiLoBase> low_LowHiLo("low");
+#include "ValuePlot.h"
+static SimpleObjectMaker<ValuePlot, ValuePlotBase> on_ValuePlot("on");
+static SimpleObjectMaker<ValuePlot, ValuePlotBase> gridvalues_ValuePlot("gridvalues");
+static SimpleObjectMaker<NoValuePlot, ValuePlotBase> off_NoValuePlot("off");
+static SimpleObjectMaker<NoValuePlot, ValuePlotBase> nogridvalues_NoValuePlot("nogridvalues");
diff --git a/src/visualisers/ContourAttributes.h b/src/visualisers/ContourAttributes.h
new file mode 100644
index 0000000..1ae3a56
--- /dev/null
+++ b/src/visualisers/ContourAttributes.h
@@ -0,0 +1,93 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ContourAttributes.h
+    \brief Definition of Contour Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef ContourAttributes_H
+#define ContourAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "ValuePlotBase.h"
+#include "ContourMethod.h"
+#include "IsoPlot.h"
+#include "HiLoBase.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ContourAttributes 
+{
+public:
+//  --  constructor
+    ContourAttributes();
+    
+//  --  destructor
+    virtual ~ContourAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ContourAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	bool legend_;
+	auto_ptr<IsoPlot> contour_;
+	auto_ptr<ContourMethod> method_;
+	double floor_;
+	double ceiling_;
+	bool setting_;
+	string library_path_;
+	auto_ptr<HiLoBase> hilo_;
+	auto_ptr<ValuePlotBase> grid_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ContourAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ContourLibrary.cc b/src/visualisers/ContourLibrary.cc
new file mode 100644
index 0000000..f75332e
--- /dev/null
+++ b/src/visualisers/ContourLibrary.cc
@@ -0,0 +1,144 @@
+/*! \file ContourLibrary.cc
+    \brief Implementation of the Template class ContourLibrary.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Fri 16-Jul-2010
+    
+    Changes:
+    
+*/
+
+
+
+#include "ContourLibrary.h"
+#include "Layer.h"
+#include "VisDefInfo.h"
+
+using namespace magics;
+
+VisDefInfoBase* ContourLibrary::info_=0;
+
+ContourLibrary::ContourLibrary() 
+{	
+}
+
+
+ContourLibrary::~ContourLibrary() 
+{	
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ContourLibrary::print(ostream& out)  const
+{
+	out << "ContourLibrary[";
+	out << "]";
+}
+
+// sete meta["shortName"] =the meta dat to be collected 
+void ContourLibrary::askId(MetaDataCollector& meta)
+{
+	meta["observationDiagnostic"]="";
+
+	/*if(!obstat_)
+		obstat_ = new ObstatVisdefManager;
+
+	for(int i=0; i < obstat_->keys().size(); i++)
+	{
+		meta[obstat_->keys().at(i)]="";
+	}*/
+
+	//meta["shortName"] = "";
+	//meta["lev"] = "";
+}
+
+
+bool ContourLibrary::checkId(MetaDataCollector& metaId,MetaDataCollector& metaKey)
+{
+	//Obstat
+	if(metaId["observationDiagnostic"] !="")
+	{		
+		if(!setInfoObject("ObstatGrib"))
+		{
+			return false;
+		}
+	}
+	else
+	{
+		return false;
+	}
+
+	for(unsigned int i=0; i < info_->keys().size(); i++)
+	{
+		metaKey[info_->keys().at(i)]="";
+		if(metaId["observationDiagnostic"] !="")
+		{
+			MetaDataAttribute attr;
+			attr.setType(MetaDataAttribute::NumberType);
+			metaKey.setAttribute(info_->keys().at(i),attr);
+		}
+	}
+
+	return true;
+
+	//meta["shortName"] = "";
+	//meta["lev"] = "";
+}
+
+
+	
+// se the map to set the contour!
+void ContourLibrary::getAttributes(MetaDataCollector& meta, map<string, string>& attributes)
+{
+	MagLog::dev() << "ContourLibrary::set-->" << endl;
+
+	//Obstat
+	if(info_)
+	{
+		for(map<string,string>::iterator it=meta.begin(); it != meta.end(); it++)
+		{
+			MagLog::dev() << it->first << "--> " << it->second << endl; 
+		}
+
+		info_->getAttributes(meta,attributes);
+	}
+
+	/*if(!obstat_)
+		obstat_ = new ObstatVisdefManager;
+
+	MagLog::dev() << "ContourLibrary::set-->" << endl;
+
+	for(map<string,string>::iterator it=meta.begin(); it != meta.end(); it++)
+	{
+		MagLog::dev() << it.first << "--> " << it.second << endl; 
+	}
+	//MagLog::dev() << "shortName-->" << meta["shortName"] << endl;
+	//MagLog::dev() << "level-->" << meta["lev"] << endl;
+	
+	//attributes["contour_line_colour"] = "red";
+
+	obstat_->setVisDefAttributes(meta,attributes);*/
+	
+}	
+
+bool ContourLibrary::setInfoObject(string type)
+{
+	if(info_ && info_->type() != type)
+	{
+		delete info_;
+		info_=0;
+	}
+	if(!info_)
+	{
+		info_=VisDefInfoFactory::makeItem(type);
+	}
+
+	if(!info_)
+		return false;
+	else if(info_->isLoaded())
+		return true;
+	else 
+		return false;
+}
diff --git a/src/visualisers/ContourLibrary.h b/src/visualisers/ContourLibrary.h
new file mode 100644
index 0000000..236510e
--- /dev/null
+++ b/src/visualisers/ContourLibrary.h
@@ -0,0 +1,59 @@
+/*! \file ContourLibrary.h
+    \brief Definition of the Template class ContourLibrary.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Fri 16-Jul-2010
+    
+    Changes:
+    
+*/
+
+#ifndef ContourLibrary_H
+#define ContourLibrary_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class MetaDataCollector;
+class VisDefInfoBase;
+
+class ContourLibrary {
+
+public:
+	ContourLibrary();
+	virtual ~ContourLibrary();
+
+	// sete the meata dat to be collected 
+	void askId(MetaDataCollector&);
+
+	bool checkId(MetaDataCollector&,MetaDataCollector&);
+
+	// se the map to set the contour!
+	void getAttributes(MetaDataCollector&, map<string, string>&);
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ContourLibrary(const ContourLibrary&);
+    //! Overloaded << operator to copy - No copy allowed
+	ContourLibrary& operator=(const ContourLibrary&);
+	
+	bool setInfoObject(string);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ContourLibrary& p)
+		{ p.print(s); return s; }
+
+	static VisDefInfoBase* info_;
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ContourMethod.h b/src/visualisers/ContourMethod.h
new file mode 100644
index 0000000..a22bdb9
--- /dev/null
+++ b/src/visualisers/ContourMethod.h
@@ -0,0 +1,101 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ContourMethod.h
+    \brief Definition of the Template class ContourMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 11-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ContourMethod_H
+#define ContourMethod_H
+
+#include "magics.h"
+#include "MatrixHandler.h"
+#include "PointsHandler.h"
+
+namespace magics {
+    
+class BasicGraphicsObjectContainer;
+class XmlNode;
+
+
+class ContourMethod  {
+
+public:
+	ContourMethod() {}
+	virtual ~ContourMethod() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual bool accept(const string&) { return false; }
+	void toxml(ostream&)  const {}
+
+	virtual ContourMethod* clone()  const { return new ContourMethod(); }
+	virtual MatrixHandler* handler(const AbstractMatrix& matrix, const BasicGraphicsObjectContainer&)
+		{ return new MatrixHandler(matrix); }
+	virtual bool needPoints() { return false; }
+	virtual MatrixHandler* handlePoints(const AbstractPoints&, const Layout&)
+		{ throw MethodNotYetImplemented("ContourMethod<P>::handler(const AbstractPoints<P>& matrix, const Layout&)"); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "ContourMethod[]"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	ContourMethod(const ContourMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	ContourMethod& operator=(const ContourMethod&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ContourMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, ContourMethod > {
+public:
+	ContourMethod* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<ContourMethod >::create(val);
+	}
+
+	ContourMethod* magics(const char* param)
+	{
+		ContourMethod* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+	ContourMethod* magics(const string& param)
+	{
+	        ContourMethod* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/CountSelectionType.cc b/src/visualisers/CountSelectionType.cc
new file mode 100644
index 0000000..f05dedc
--- /dev/null
+++ b/src/visualisers/CountSelectionType.cc
@@ -0,0 +1,187 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file 
+.cc
+    \brief Implementation of the Template class CountSelectionType.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+ 
+#include "CountSelectionType.h"
+#include "PointsHandler.h"
+#include "UserPoint.h"
+
+using namespace magics;
+
+
+CountSelectionType::CountSelectionType() 
+{
+}
+
+
+void CountSelectionType::calculate(double min, double max, bool)
+{
+        clear();
+        double maxi = (max_ >  1000000000) ? max : max_;
+        double mini = (min_ < -1000000000) ? min : min_;
+        int i = 0;
+
+        i += ( max_ >  1000000000) ? 1 : 0;
+        i += ( min_ < -1000000000) ? 1 : 0;
+        
+        
+        
+        double nb = levelCount_-1;
+        if ( maxi ==  mini) {
+        	push_back(mini);
+        	return;
+        }
+        double step = (maxi - mini)/nb;
+        double toleranceProportion = (double)tolerance_ / (double)(levelCount_ + 1 + i);  // tolerance as a proportion of the number of levels
+                                     // we add 'i' here because it will be subtracted at the end (because this is the number
+                                     // of levels we will not actually plot, ie the min/max contours).
+        if (step == 0) {
+        	// Only one isoline!
+        	push_back(mini);
+        	return;
+        } 
+
+
+        // get the log of the step as an integer
+        int log = log10(step);
+        if (step < 1) log -= 1;
+
+        double inc;
+        double istep = pow(10., log);
+        double step0to10 = step/istep;
+        double stepTolerance = step0to10 * toleranceProportion * 0.95;
+
+
+        // we now have step0to10 as a number from 0 to 10, so we can
+        // set it to the nearest 'nice' number for contouring, with
+        // some bias for numbers such as 10 and 5.
+
+             if (fabs (step0to10 - 10) < stepTolerance) inc = 10;
+        else if (fabs (step0to10 -  5) < stepTolerance) inc =  5;
+        else
+        {
+            inc = static_cast<int>(step0to10 + 0.5);  // round to nearest integer
+
+
+            // will using this number be within our tolerance?
+            // i.e. will this give us approx the right number of contours?
+            // if not, then make an adjustment and test again. Do this
+            // until the adjustments get too small (avoid infinite loops!)
+
+            double diffFromIdeal = step0to10 - inc;
+            double incAdjustment = 0.5;
+
+            while (fabs(diffFromIdeal) > stepTolerance && incAdjustment > 0.1)
+            {
+                if (diffFromIdeal > stepTolerance)
+                {
+                    inc += incAdjustment;
+                }
+                else if (diffFromIdeal < -stepTolerance)
+                {
+                    inc -= incAdjustment;
+                }
+
+                diffFromIdeal = step0to10 - inc;
+                incAdjustment /= 2.0;
+            }
+        }
+
+        inc *= istep;  // convert back into proper range
+
+
+        double first = floor(mini/inc)*inc;
+  
+        while ( first > mini ) 
+        	first -=inc;
+        
+        push_back(mini);
+        first += inc;
+        double epsilon = inc/10000.0;
+       
+        for (double val = first; val < maxi; val += inc) {
+            // special case - if the value is close to zero then set it to precisely zero to avoid later formatting issues
+            if (fabs(val) < epsilon)
+                push_back(0.0);
+            else
+                push_back(val);
+        }
+	
+        push_back(maxi);
+        int si = static_cast<int>(size());
+
+
+        // last resort - if we have too many/few contours, then just do a 'blind' division
+        // so as to ensure the correct number, even if they are not nice
+
+        if ( si - i < levelCount_ - tolerance_ || si - i > levelCount_ + tolerance_ ) {
+            MagLog::debug() << "Not using nice levels[" << levelCount_ << ", " << tolerance_ << "]-->" << size()  << endl;
+            clear();
+            step = (maxi - mini)/(levelCount_-1);
+            double val = mini;
+            while ( 1 ) {
+                push_back(val);
+                if ( same(val, maxi) || val > maxi) break; 
+                val += step;
+            } 
+            MagLog::debug() << "New size-->" << size() << endl;
+        } 
+  
+        MagLog::debug() << "count=" << levelCount_ << ", tolerance=" << tolerance_ << ", result=" << size() << endl;
+
+        ostringstream level;
+        for (const_iterator l = begin(); l != end(); ++l) 
+            level << *l << " ";
+ 
+        MagLog::debug() << level.str() << endl;
+}
+
+
+CountSelectionType::~CountSelectionType() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void CountSelectionType::print(ostream& out)  const
+{
+	out << "CountSelectionType[";
+	out << "]";
+}
+
+void CountSelectionType::set(const LevelSelectionInterface& from) 
+{
+    levelCount_ = from.getCount();
+    tolerance_ = from.getTolerance();
+    reference_ = from.getReference();
+    min_ = from.getMin();
+    max_ = from.getMax();
+}
diff --git a/src/visualisers/CountSelectionType.h b/src/visualisers/CountSelectionType.h
new file mode 100644
index 0000000..cde83dc
--- /dev/null
+++ b/src/visualisers/CountSelectionType.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file CountSelectionType.h
+    \brief Definition of the Template class CountSelectionType.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+     
+*/
+
+#ifndef CountSelectionType_H
+#define CountSelectionType_H
+
+#include "magics.h"
+
+#include "CountSelectionTypeAttributes.h"
+#include "LevelSelection.h"
+#include "XmlNode.h"
+
+namespace magics {
+
+
+class CountSelectionType: public CountSelectionTypeAttributes, public LevelSelection {
+
+public:
+	CountSelectionType();
+	virtual ~CountSelectionType();
+
+
+
+    virtual void calculate(double min, double max, bool);
+    
+    void set(const map<string, string>& params) { 
+        CountSelectionTypeAttributes::set(params);
+        LevelSelection::set(params);
+    }
+    void set(const XmlNode& node) { 
+        CountSelectionTypeAttributes::set(node);
+        if ( magCompare(node.name(), "count") ) {
+        	XmlNode level = node;
+        	level.name("level");
+        	LevelSelection::set(level);
+        }
+    }
+    void set(const LevelSelectionInterface&);
+
+    double reference() const { return reference_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	CountSelectionType(const CountSelectionType&);
+    //! Overloaded << operator to copy - No copy allowed
+	CountSelectionType& operator=(const CountSelectionType&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CountSelectionType& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/CountSelectionTypeAttributes.h b/src/visualisers/CountSelectionTypeAttributes.h
new file mode 100644
index 0000000..613b38e
--- /dev/null
+++ b/src/visualisers/CountSelectionTypeAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file CountSelectionTypeAttributes.h
+    \brief Definition of CountSelectionType Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef CountSelectionTypeAttributes_H
+#define CountSelectionTypeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class CountSelectionTypeAttributes 
+{
+public:
+//  --  constructor
+    CountSelectionTypeAttributes();
+    
+//  --  destructor
+    virtual ~CountSelectionTypeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const CountSelectionTypeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	int levelCount_;
+	int tolerance_;
+	double reference_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const CountSelectionTypeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Curve.cc b/src/visualisers/Curve.cc
new file mode 100644
index 0000000..ca2dc9b
--- /dev/null
+++ b/src/visualisers/Curve.cc
@@ -0,0 +1,383 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Curve.cc
+    \brief Implementation of the Template class Curve.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "Curve.h"
+#include "PointsHandler.h"
+#include "LegendVisitor.h"
+#include "Symbol.h"
+
+using namespace magics;
+
+Curve::Curve() 
+{
+	missingMethods_["ignore"] = &Curve::ignore;
+	missingMethods_["join"] = &Curve::join;
+	missingMethods_["drop"] = &Curve::drop;
+}
+
+
+Curve::~Curve() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void Curve::print(ostream& out)  const
+{
+	out << "Curve[";
+	out << "]";
+}
+
+Polyline* Curve::newCurve(BasicGraphicsObjectContainer& task) const
+{
+
+	Polyline* curve  = new Polyline();
+	(*curve).setColour(*colour_);
+	(*curve).setLineStyle(style_);
+	(*curve).setThickness(thickness_);
+
+	return curve;
+	
+}
+	
+bool  Curve::missing(CustomisedPoint& point) const
+{
+	if ( point.missing() ) return true;
+	double x = point["x"];
+
+	if ( x < this->x_below_ ) return true;
+	if ( x > this->x_above_ ) return true;
+	if ( same(x, this->x_below_) ) return true;
+	if ( same(x, this->x_above_) ) return true;
+
+	double y = point["y"];
+
+	if ( y < this->y_below_ ) return true;
+	if ( y > this->y_above_ ) return true;
+	if ( same(y, this->y_below_) ) return true;
+	if ( same(y, this->y_above_) ) return true;
+	return false;
+}
+
+
+
+void Curve::operator()(Data& data, BasicGraphicsObjectContainer& task)
+{
+
+	vector<double> xpos;
+	vector<double> ypos;
+    const Transformation& transformation = task.transformation();
+
+
+    std::set<string> needs;
+    CustomisedPointsList points;
+
+    data.customisedPoints(transformation, needs, points, true);
+
+	if ( legend_text_ == "?" ) legend_text_ = data.legend(); 
+	
+	
+	Polyline* curve_ = newCurve(task);
+	bool last_out = false;	
+	
+	vector<PaperPoint> missing, sv;
+	PaperPoint last, current;
+	
+	CustomisedPointsList::iterator point = points.begin();
+
+    while ( point != points.end() ) {
+    	if ( this->missing(**point) ) {
+    		++point;
+    	}
+    	else
+    		break;
+    }
+    
+
+
+    while ( point != points.end() ) {
+
+    	UserPoint up((**point)["x"], (**point)["y"]);
+
+    	current = transformation(up);
+
+		if (!this->missing(**point) ) {
+			if ( last_out ) {
+				bool result;
+				std::map<string, MissingMethod>::iterator method = missingMethods_.find(lowerCase(missing_mode_));
+				result = (method == missingMethods_.end() ) ?
+							ignore(last, missing.front(), missing, task) :
+							(this->*method->second)(last, current, missing, task);
+				if ( result ) {
+					if ( line_ )
+						transformation(*curve_, task);
+					curve_ = newCurve(task);
+				}
+				missing.clear();
+			}
+
+			last = current;
+			last_out = false;
+			curve_->push_back(current);
+			sv.push_back(current);
+			  
+		} 
+		else {
+			missing.push_back( current );
+			last_out = true;
+		} 
+		++point;
+
+	}
+    if ( missing.empty() == false ) {
+    	std::map<string, MissingMethod>::iterator method = missingMethods_.find(lowerCase(missing_mode_));
+    	if ( method == missingMethods_.end() )
+    	{
+    		ignore(last, missing.front(), missing, task);
+    	}
+    	(this->*method->second)(last, missing.front(), missing, task);
+
+    }
+
+	
+	
+	// apply the symbol
+
+	if ( line_ ) transformation(*curve_, task);
+	 symbol(sv, task);
+
+}
+
+void CurveArea::operator()(Data& data, BasicGraphicsObjectContainer& task)
+{
+
+	vector<double> xpos;
+	vector<double> ypos;
+    const Transformation& transformation = task.transformation();
+
+
+    std::set<string> needs;
+    CustomisedPointsList points;
+    if ( shade_->needCustomised() ) {
+    	needs.insert("area");
+    }
+    data.customisedPoints(transformation, needs, points, true);
+
+	if ( legend_text_ == "?" ) legend_text_ = data.legend();
+
+
+	Polyline* curve_ = newCurve(task);
+	bool last_out = false;
+
+	vector<PaperPoint> missing, sv;
+	PaperPoint last, current;
+
+	CustomisedPointsList::iterator point = points.begin();
+
+    while ( point != points.end() ) {
+    	if ( this->missing(**point) ) {
+    		++point;
+    	}
+    	else
+    		break;
+    }
+
+
+
+    while ( point != points.end() ) {
+
+    	UserPoint up((**point)["x"], (**point)["y"]);
+
+    	current = transformation(up);
+
+		if (!this->missing(**point) ) {
+			if ( last_out ) {
+				bool result;
+				std::map<string, MissingMethod>::iterator method = missingMethods_.find(lowerCase(missing_mode_));
+				result = (method == missingMethods_.end() ) ?
+							ignore(last, missing.front(), missing, task) :
+							(this->*method->second)(last, missing.front(), missing, task);
+				if ( result ) {
+					if ( line_ )
+						transformation(*curve_, task);
+					curve_ = newCurve(task);
+				}
+				missing.clear();
+			}
+
+			last = current;
+			last_out = false;
+			curve_->push_back(current);
+			sv.push_back(current);
+
+		}
+		else {
+			missing.push_back( current );
+			last_out = true;
+		}
+		++point;
+
+	}
+    if ( missing.empty() == false ) {
+    	std::map<string, MissingMethod>::iterator method = missingMethods_.find(lowerCase(missing_mode_));
+    	if ( method == missingMethods_.end() )
+    	{
+    		ignore(last, missing.front(), missing, task);
+    	}
+    	(this->*method->second)(last, missing.front(), missing, task);
+
+    }
+
+
+
+	// apply the symbol
+
+	(*shade_)(*curve_);
+	if ( line_ ) transformation(*curve_, task);
+	 symbol(sv, task);
+	
+}
+
+
+class CurveEntry : public LegendEntry
+{
+public:
+	CurveEntry(const string& legend, Curve& curve) : 
+		LegendEntry(legend), curve_(curve) {}
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& legend) 
+		{ curve_.set(point, legend, *this); }
+protected:
+	Curve& curve_;
+};
+
+void Curve::visit(LegendVisitor& legend)
+{
+	if ( !legend_) return;
+	CurveEntry* entry = new CurveEntry(legend_text_, *this);
+	entry->userText(legend_text_);
+	legend.add(entry);
+}
+
+void  Curve::set(const PaperPoint& point, BasicGraphicsObjectContainer& legend, LegendEntry& entry)
+{
+	Polyline* curve  = new Polyline();
+	curve->setColour(*colour_);
+	curve->setLineStyle(style_);
+	curve->setThickness(thickness_);
+	
+	double width = entry.computeWidth(0.8)/2;
+
+	PaperPoint p = entry.centreSymbolBox(point);
+
+	
+	double x = p.x();
+	double y = point.y();
+
+	curve->push_back(PaperPoint(x-width, y));
+	curve->push_back(PaperPoint(x+width,  y));
+	
+
+	this->legend(*curve);
+	
+	    
+	legend.push_back(curve);
+	legend_symbol(p, legend);
+	
+}
+void CurveArea::legend(Polyline& curve)
+{
+	shade_->legend(curve);
+}
+void Curve::symbol(vector<PaperPoint>& points, BasicGraphicsObjectContainer& out)
+{
+	if ( !symbol_ ) return;
+
+	Symbol* symbol = new Symbol();
+
+    symbol->setMarker(symbol_marker_);
+    symbol->setHeight(symbol_height_);
+    symbol->setColour(*symbol_colour_);
+	const Transformation& transformation = out.transformation();
+
+    for ( vector<PaperPoint>::const_iterator point = points.begin(); point != points.end(); ++point) {
+    	if ( !point->missing() && transformation.in(*point) )
+    		symbol->push_back(transformation(*point));
+    }
+
+    out.push_back(symbol);
+}
+
+void Curve::legend_symbol(PaperPoint& point, BasicGraphicsObjectContainer& task)
+{
+	if ( !symbol_ ) return;
+
+	Symbol* symbol = new Symbol();
+
+    symbol->setMarker(symbol_marker_);
+    symbol->setHeight(symbol_height_);
+    symbol->setColour(*symbol_colour_);
+    symbol->push_back(point);
+
+    task.push_back(symbol);
+}
+
+
+bool Curve::ignore(const PaperPoint&, const PaperPoint&, const vector<PaperPoint>&, BasicGraphicsObjectContainer&)
+{
+	return true; // need new line!
+}
+
+bool Curve::join(const PaperPoint& p1, const PaperPoint& p2, const vector<PaperPoint>& , BasicGraphicsObjectContainer& task)
+{
+	Polyline* curve  = new Polyline();
+	(*curve).setColour(*missing_colour_);
+	(*curve).setLineStyle(missing_style_);
+	(*curve).setThickness(missing_thickness_);
+
+	curve->push_back(p1);
+	curve->push_back(p2);
+	task.transformation()(*curve, task);
+	return true;
+}
+bool Curve::drop(const PaperPoint& p1, const PaperPoint& p2, const vector<PaperPoint>& points, BasicGraphicsObjectContainer& task)
+{
+	Polyline* curve  = new Polyline();
+	(*curve).setColour(*missing_colour_);
+	(*curve).setLineStyle(missing_style_);
+	(*curve).setThickness(missing_thickness_);
+
+	curve->push_back(p1);
+	for ( vector<PaperPoint>::const_iterator point = points.begin(); point != points.end(); ++point)
+		curve->push_back(*point);
+	curve->push_back(p2);
+	task.transformation()(*curve, task);
+	return true;
+}
diff --git a/src/visualisers/Curve.h b/src/visualisers/Curve.h
new file mode 100644
index 0000000..4a44706
--- /dev/null
+++ b/src/visualisers/Curve.h
@@ -0,0 +1,120 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Curve.h
+    \brief Definition of the Template class Curve.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Curve_H
+#define Curve_H
+
+#include "magics.h"
+
+#include "CurveAttributes.h"
+#include "CurveAreaAttributes.h"
+#include "Graph.h"
+#include "Polyline.h"
+
+namespace magics {
+
+class XmlNode;
+class LegendEntry;
+
+
+class Curve: public CurveAttributes, public Graph {
+
+public:
+	Curve();
+	virtual ~Curve();
+    enum PointPosition { in , out , enter , exit };
+
+    
+    void set(const XmlNode& node) { Graph::set(node); CurveAttributes::set(node); }
+    
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    void set(const PaperPoint&, BasicGraphicsObjectContainer&, LegendEntry&);
+
+	Polyline* newCurve(BasicGraphicsObjectContainer&) const;
+	PointPosition where(const UserPoint& point) const;
+     
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { CurveAttributes::set(map); }
+    void symbol(vector<PaperPoint>& points, BasicGraphicsObjectContainer& out);
+    void legend_symbol(PaperPoint& point, BasicGraphicsObjectContainer& task);
+
+    typedef bool (Curve::*MissingMethod)(const PaperPoint&, const PaperPoint&, const vector<PaperPoint>&, BasicGraphicsObjectContainer&);
+    virtual void legend(Polyline&) {}
+    bool ignore(const PaperPoint&, const PaperPoint&, const vector<PaperPoint>&, BasicGraphicsObjectContainer&);
+    bool join(const PaperPoint&, const PaperPoint&, const vector<PaperPoint>&, BasicGraphicsObjectContainer&);
+    bool drop(const PaperPoint&, const PaperPoint&, const vector<PaperPoint>&, BasicGraphicsObjectContainer&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 bool  missing(CustomisedPoint&) const;
+	 std::map<string, MissingMethod> missingMethods_;
+private:
+    //! Copy constructor - No copy allowed
+	Curve(const Curve&);
+    //! Overloaded << operator to copy - No copy allowed
+	Curve& operator=(const Curve&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Curve& p)
+		{ p.print(s); return s; }
+
+};
+
+class CurveArea: public Curve, public CurveAreaAttributes {
+
+public:
+	CurveArea() {}
+	virtual ~CurveArea() {}
+
+	void operator()(Data&, BasicGraphicsObjectContainer&);
+	void legend(Polyline&);
+	
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const
+	 	{ out << "CurveArea";  Curve::print(out); }
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	CurveArea(const CurveArea&);
+    //! Overloaded << operator to copy - No copy allowed
+	CurveArea& operator=(const CurveArea&);
+
+
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/DateAxis.cc b/src/visualisers/DateAxis.cc
new file mode 100644
index 0000000..0dfe4bf
--- /dev/null
+++ b/src/visualisers/DateAxis.cc
@@ -0,0 +1,582 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DateAxisMethod.cc
+    \brief Implementation of the Template class DateAxisMethod.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 7-Oct-2005
+    
+    Changes:
+    
+*/
+
+#include "DateAxis.h"
+#include "Axis.h"
+
+using namespace magics;
+
+
+DateAxisMethod::DateAxisMethod()
+{
+	update();
+	dateCreators_["automatic"] = &DateAxisMethod::automatic;
+	dateCreators_["years"] = &DateAxisMethod::years;
+	dateCreators_["months"] = &DateAxisMethod::months;
+	dateCreators_["days"] = &DateAxisMethod::days;
+	dateCreators_["hours"] = &DateAxisMethod::hours;
+
+
+}
+
+
+DateAxisMethod::~DateAxisMethod()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void DateAxisMethod::print(ostream& out)  const
+{
+	out << "DateAxisMethod[";
+	out << "]";
+}
+
+double DateAxisMethod::getMin() const
+{
+	update();
+	return from_ - base_;
+}
+
+
+double DateAxisMethod::getMax() const
+{
+	update();
+	return to_  - base_;
+}
+
+void DateAxisMethod::update() const
+{ 
+	//from_ = (date_min_ != "undef" ) ? DateTime(date_min_) : DateTime();
+	//to_   = (date_max_ != "undef" ) ? DateTime(date_max_) : DateTime();
+
+	//base_ = (DateAxisMethodAttributes::reference_ != "undef" ) ? DateTime(DateAxisMethodAttributes::reference_) : from_;
+}
+
+
+void DateAxisMethod::prepare(const Axis& axis, AxisItems& items)
+{
+	update();
+	
+	interval_ = axis.interval_;
+	map<string,  DateHelper >::iterator method = dateCreators_.find(lowerCase(method_));
+	if ( method != dateCreators_.end() )
+		(this->*method->second)(items);
+	else {
+		MagLog::warning() << "Could not the method " << method_ << " to setup the axis date: using the automatic method..." << endl;
+		automatic(items);
+	}
+
+	
+
+	AxisItems dates;
+	for ( AxisItems::const_iterator item = items.begin(); item != items.end(); ++item) {
+		if ( (**item).date() )
+			dates.push_back((*item)->clone());
+	}
+	position_ = 0;
+	hours_label(dates, items);
+	days_label(dates, items);
+	months_label(dates, items);
+	years_label(dates, items);
+
+	for ( AxisItems::const_iterator item = items.begin(); item != items.end(); ++item)
+		{
+		if ( (**item).date() )
+			MagLog::dev() << " found at " << (**item).position() << " --->" << (**item).label() << "\n";
+		}
+
+
+	
+
+
+}
+
+
+
+void DateAxisMethod::updateX(const Transformation& transformation)
+{
+	const double min = transformation.getMinX();
+		const double max = transformation.getMaxX();
+
+
+		base_ = DateTime(transformation.getReferenceX());
+		from_ = base_ + Second(min);
+		to_ = base_ + Second(max);
+
+		MagLog::dev() << "base-> " << base_ << endl;
+		MagLog::dev() << "from-> " << from_ << endl;
+		MagLog::dev() << "to-> " << to_ << endl;
+
+}
+
+void DateAxisMethod::updateY(const Transformation& transformation)
+{
+	const double min = transformation.getMinY();
+	const double max = transformation.getMaxY();
+
+
+	base_ = DateTime(transformation.getReferenceY());
+	from_ = base_ + Second(min);
+	to_ = base_ + + Second(max);
+
+	MagLog::dev() << "base-> " << base_ << endl;
+	MagLog::dev() << "from-> " << from_ << endl;
+	MagLog::dev() << "to-> " << to_ << endl;
+}
+
+
+
+
+HyperAxis::HyperAxis()
+{
+}
+
+HyperAxis::~HyperAxis()
+{
+}
+
+	
+void HyperAxis::prepare(double, double, AxisItems&) const
+{
+}
+
+void HyperAxis::updateX(const Transformation&)
+{
+}
+
+void HyperAxis::updateY(const Transformation&) 
+{
+}
+
+void HyperAxis::print(ostream&) const
+{
+}
+
+void HyperAxis::update() const
+{
+}
+
+
+
+
+void DateAxisMethod::automatic(AxisItems& list)
+{
+
+	double days  = (to_-from_)/(24*3600);
+
+	if (days > 2500 ) { // 7 Years labels!
+		hours_ = false;
+		days_  = "off";
+		months_ = false;
+		years_ = true;
+		// axis_tick_label_frequency',3
+		years(list);
+		return;
+	}
+
+
+
+	if ( days > 300 ) {
+		hours_ = false;
+		days_  = "off";
+		years_ = true;
+		months(list);
+		//call psetr('axis_tick_interval',1.)
+		 //call pseti('axis_tick_label_frequency',2)
+		return;
+	}
+
+	if  (days > 3 ) {
+		hours_ = false;
+		months_ = true;
+		this->days(list);
+		return;
+	}
+
+
+	hours_ = true;
+
+	hours(list);
+
+}
+
+void DateAxisMethod::years(AxisItems& list)
+{
+
+		days_ = "off";
+		months_ = false;
+		DateTime label;
+		DateTime tick;
+
+		const DateTime& min = from_;
+		const DateTime& max = to_;
+		long position  =  0;
+
+		int frequency;
+		const long long seconds_a_year=24*3600*365;
+		const long decade=10;
+
+		if ( interval_ == INT_MAX ) {
+		    if ( max-min < 20*seconds_a_year ) {
+		    	frequency = 1;
+		    }
+		    else if ( max-min < 50*seconds_a_year ) {
+		    	frequency = 2;
+		    }
+		    else
+		    	frequency = 5;
+		}
+		else {
+			frequency = (int) interval_;
+		}
+		if ( frequency == 0)
+			frequency = 1;
+		int count = 0;
+
+		for ( int  year = min.date().year() ; year <= max.date().year() ; year++)
+		{
+			if ((count++ % frequency)==0) {
+				MagDate date(year, 1, 1);
+				label = DateTime(date, MagTime(position, 0, 0));
+				list.push_back(new AxisDateItem(label - base_, label));
+				tick = DateTime(date, MagTime(0, 0, 0));
+
+				list.push_back(new AxisTickItem(tick - base_));
+
+				if (frequency == 1) {
+					for ( int i = 0; i < 4; i++) {
+						MagDate t = MagDate(year, 1+(3*i), 1);
+						DateTime tick(t, MagTime(0,0,0) );
+						list.push_back(new AxisMinorTickItem(tick - base_));
+					}
+				}
+			}
+			else {
+				DateTime tick(MagDate(year, 1, 1), MagTime(0, 0, 0));
+				list.push_back(new AxisMinorTickItem(tick - base_));
+
+			}
+
+
+		}
+}
+void DateAxisMethod::years_label(AxisItems& in, AxisItems& list)
+{
+	if ( !years_ )
+		return;
+	string last;
+	for ( AxisItems::iterator item = in.begin(); item != in.end(); ++item) {
+		AxisItem* year = (*item)->clone();
+		year->format("%Y", -1);
+		if ( last == year->label() ) {
+			delete year;
+			continue;
+		}
+		last =  year->label();
+		year->level(position_);
+		year->height(year_height_);
+		year->colour(year_colour_->name());
+		list.push_back(year);
+	}
+
+}
+void DateAxisMethod::months(AxisItems& list)
+{
+	DateTime label;
+	DateTime tick;
+	days_ = "off";
+
+
+	const DateTime& min = from_;
+	const DateTime& max = to_;
+	long position  =  0;
+
+	int frequency;
+
+	if ( interval_ == INT_MAX ) {
+		if ( max-min  < 20*24*3600*30 ) {
+			frequency = 1;
+		}
+		else if ( max-min  < 120*24*3600*30 ) {
+			frequency = 2;
+		}
+		else {
+			frequency = 3;
+		}
+	}
+	else {
+		frequency = (int) interval_;
+	}
+	if ( frequency == 0)
+		frequency = 1;
+	int count = 0;
+
+
+	MagDate date = min.date();
+	while ( date <= max.date() ) {
+		int year  = date.year();
+		int month  = date.month();
+
+		if ((count++ % frequency)==0) {
+			label = DateTime(date, MagTime(position, 0, 0));
+			list.push_back(new AxisDateItem(label - base_, label));
+			tick = DateTime(date, MagTime(0, 0, 0));
+
+			list.push_back(new AxisTickItem(tick - base_));
+
+
+
+		}
+		else {
+			tick = DateTime(MagDate(year, month, 1), MagTime(0, 0, 0));
+			list.push_back(new AxisMinorTickItem(tick - base_));
+
+		}
+		month++;
+		if ( month == 13 ) {
+			year++;
+			month=1;
+		}
+
+		date = MagDate(year, month, 1);
+	}
+}
+void DateAxisMethod::months_label(AxisItems& in, AxisItems& list)
+{
+	if ( !months_ )
+		return;
+	map <string, pair<string, int> > formats;
+	formats["one"] = make_pair("%b", 1);
+	formats["full"] = make_pair("%B", -1);
+	formats["three"] = make_pair("%B", 3);
+	string last = "";
+
+	for ( AxisItems::iterator item = in.begin(); item != in.end(); ++item) {
+		AxisItem* month = (*item)->clone();
+		map <string, pair<string, int> >::iterator fmt = formats.find(lowerCase(month_composition_));
+		if ( fmt != formats.end() ) {
+			month->format(fmt->second.first, fmt->second.second);
+		}
+		else {
+			MagLog::warning() << "could not find type " << month_composition_ << "for formatting month lables" << endl;
+			month->format("%B", 3);
+		}
+		if ( last == month->label() ) {
+			delete month;
+			continue;
+		}
+		last =  month->label();
+		month->colour(month_colour_->name());
+		month->level(position_);
+		month->height(month_height_);
+
+		list.push_back(month);
+	}
+	position_++;
+}
+void DateAxisMethod::days(AxisItems& list)
+{
+
+	DateTime label;
+	DateTime tick;
+
+	const DateTime& min = from_;
+	const DateTime& max = to_;
+	long position  =  ( max-min  < 20*24*3600 ) ? 12 : 0;
+
+	int frequency;
+	int day = (max-min) / (24*3600);
+
+	if ( interval_ == INT_MAX ) {
+		if ( day  < 20 ) {
+			frequency = 1;
+		}
+		else if ( day < 60 ) {
+			frequency = 2;
+		}
+		else if ( day  < 120 ) {
+			frequency = 5;
+		}
+
+		else {
+			frequency = 10;
+		}
+	}
+	else {
+		frequency = (int) interval_;
+	}
+	if ( frequency == 0)
+		frequency = 1;
+	int count = 0;
+
+	for ( MagDate date = min.date(); date <= max.date(); ++date)
+	{
+		label = DateTime(date, MagTime(position, 0, 0));
+		if ((count++ % frequency) == 0 ) {
+
+			list.push_back(new AxisDateItem(label - from_, label));
+			tick = DateTime(date, MagTime(0, 0, 0));
+
+			list.push_back(new AxisTickItem(tick - from_));
+			if ( frequency == 1 ) {
+				for (int i = 6; i < 24; i+=6 ) {
+				tick = DateTime(date, MagTime(i, 0, 0));
+				list.push_back(new AxisMinorTickItem(tick - from_));
+				}
+			}
+		}
+		else {
+			tick = DateTime(date, MagTime(0, 0, 0));
+			list.push_back(new AxisMinorTickItem(tick - from_));
+		}
+
+	}
+}
+void DateAxisMethod::days_label(AxisItems& in, AxisItems& list)
+{
+	if ( magCompare(days_, "off" ) )
+		return;
+
+	map <string, pair<string, int> > formats;
+
+	if ( magCompare(days_, "number" ) ) {
+		formats["one"] = make_pair("%e", -1);
+		formats["three"] = make_pair("%e", -1);
+		formats["full"] = make_pair("%e", -1);
+	}
+	else {
+		formats["one"] = make_pair("%a", 1);
+		formats["three"] = make_pair("%a", 3);
+		formats["full"] = make_pair("%A", -1);
+	}
+
+
+	string last;
+	for ( AxisItems::iterator item = in.begin(); item != in.end(); ++item) {
+		if ( (*item)->date() == false )
+			continue;
+		AxisItem* day = (*item)->clone();
+		if (day->sunday() )
+			day->colour(sunday_colour_->name());
+		else
+			day->colour(day_colour_->name());
+		map <string, pair<string, int> >::iterator fmt = formats.find(lowerCase(day_composition_));
+		if ( fmt != formats.end() ) {
+			day->format(fmt->second.first, fmt->second.second);
+		}
+		else {
+			MagLog::warning() << "could not find type " << day_composition_ << "for formatting day labels" << endl;
+			day->format("%e", -1);
+		}
+		if ( magCompare(days_, "both" ) ) {
+			string label = day->label();
+			day->format("%e", -1);
+			label = label  + day->label();
+			day->label(label);
+		}
+		if ( last == day->label() ) {
+			delete day;
+			continue;
+		}
+		last = day->label();
+
+		day->level(position_);
+		day->height(day_height_);
+
+		list.push_back(day);
+	}
+	position_++;
+}
+void DateAxisMethod::hours(AxisItems& list)
+{
+	DateTime label;
+	DateTime tick;
+
+	const DateTime& min = ( from_ < to_ ) ? from_ : to_;
+	const DateTime& max = ( from_ < to_ ) ? to_ : from_;
+
+
+	int frequency;
+
+	if ( interval_ == INT_MAX ) {
+		    if ( max-min  < 24*3600 ) {
+			frequency = 1; // every hour
+		    }
+		    else if ( max-min < 2*24*3600 ) {
+			frequency = 2; // every other hour!
+		    }
+		    else {
+			frequency = 3;
+		    }
+		}
+		else {
+			frequency = (int) interval_;
+		}
+		if ( frequency == 0)
+			frequency = 1;
+		for ( MagDate date = min.date(); date <= max.date(); ++date)
+		{
+			for (int i = 0; i < 24; i++ )
+			{
+				tick = DateTime(date, MagTime(i, 0, 0));
+				if ( i%frequency == 0) {
+					list.push_back(new AxisDateItem(tick - base_, tick));
+					list.push_back(new AxisTickItem(tick - base_));
+				}
+				else {
+					list.push_back(new AxisMinorTickItem(tick - base_));
+				}
+			}
+		}
+}
+void DateAxisMethod::hours_label(AxisItems& in, AxisItems& list)
+{
+
+	if ( !hours_ )
+		return;
+	string last;
+	for ( AxisItems::iterator item = in.begin(); item != in.end(); ++item) {
+		AxisItem* hour = (*item)->clone();
+		hour->format("%H h", -1);
+		if ( last == hour->label() ) {
+			delete hour;
+			continue;
+		}
+		last = hour->label();
+		hour->level(position_);
+		hour->height(hour_height_);
+		hour->colour(hour_colour_->name());
+		list.push_back(hour);
+	}
+	position_++;
+}
+
+
diff --git a/src/visualisers/DateAxis.h b/src/visualisers/DateAxis.h
new file mode 100644
index 0000000..0cdd226
--- /dev/null
+++ b/src/visualisers/DateAxis.h
@@ -0,0 +1,132 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DateAxisMethod.h
+    \brief Definition of the Template class DateAxisMethod.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 7-Oct-2005
+    
+    Changes:
+    
+*/
+
+#ifndef DateAxisMethod_H
+#define DateAxisMethod_H
+
+#include "magics.h"
+
+#include "AxisMethod.h"
+#include "DateAxisMethodAttributes.h"
+
+namespace magics {
+
+class DateAxisMethod: public AxisMethod, public DateAxisMethodAttributes {
+
+public:
+	DateAxisMethod();
+	virtual ~DateAxisMethod();
+	
+	virtual void set(const map<string, string>& map) {
+		AxisMethod::set(map);
+		DateAxisMethodAttributes::set(map);
+	}
+	virtual void set(const XmlNode& node) {
+		AxisMethod::set(node);
+		DateAxisMethodAttributes::set(node);
+	}
+	virtual double getMin() const;
+    virtual double getMax() const;
+    
+     
+    void prepare(const Axis&, AxisItems&);
+   
+    void updateX(const Transformation&);
+    void updateY(const Transformation&);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void update() const;
+	 mutable DateTime from_;
+	 mutable DateTime to_;
+	 mutable DateTime base_;
+	double interval_;
+
+	typedef void (DateAxisMethod::*DateHelper)(AxisItems&);
+
+	map<string,  DateHelper> dateCreators_;
+	 
+	void automatic(AxisItems&);
+	void years(AxisItems&);
+	void months(AxisItems&);
+	void days(AxisItems&);
+	void hours(AxisItems&);
+
+	void years_label(AxisItems&, AxisItems&);
+	void months_label(AxisItems&, AxisItems&);
+	void days_label(AxisItems&, AxisItems&);
+	void hours_label(AxisItems&, AxisItems&);
+
+
+private:
+    //! Copy constructor - No copy allowed
+	DateAxisMethod(const DateAxisMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	DateAxisMethod& operator=(const DateAxisMethod&);
+	int position_;
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const DateAxisMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+class HyperAxis: public AxisMethod {
+
+public:
+	HyperAxis();
+	virtual ~HyperAxis();
+	
+	void set(const map<string, string>& map) {  }
+	void set(const XmlNode& node)                  { }
+	
+    void prepare(double, double, AxisItems&) const;
+    void updateX(const Transformation&);
+    void updateY(const Transformation&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void update() const;
+	
+	 
+private:
+    //! Copy constructor - No copy allowed
+	HyperAxis(const DateAxisMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	HyperAxis& operator=(const DateAxisMethod&);
+
+
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/DefinitionTable.cc b/src/visualisers/DefinitionTable.cc
new file mode 100644
index 0000000..3087c1f
--- /dev/null
+++ b/src/visualisers/DefinitionTable.cc
@@ -0,0 +1,128 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LocalTable.cc
+    \brief Implementation of the Template class LocalTable.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+#include "LocalTable.h"
+#include "MagException.h"
+#include "expat.h"
+#include <stdio.h>
+#include <string>
+using std::basic_string;
+
+using namespace magics;
+
+
+static void XMLCALL
+startElement(void *userData, const char *name, const char **atts)
+{
+	BaseTable* table  = (BaseTable*) userData; 
+	if (string(name) == table->info() )
+	{	
+        map<string, string> def;
+        while (*atts) {
+            def[*(atts)] = *(atts+1);
+            atts+=2;
+        }
+        table->add(def);
+	}
+}
+
+static void XMLCALL
+endElement(void *, const char *)
+{
+}
+
+//template <class D> 
+//map<string, DefinitionTable<D>* >* DefinitionTable<D>::tables_ = 0;
+
+template <class D> 
+D DefinitionTable<D>::unknown_;
+ 
+template <class D> 
+DefinitionTable<D>::DefinitionTable(const string& file, const string& keyword) : BaseTable(keyword) 
+{
+	string filename = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + file;
+	char buf[BUFSIZ];
+	XML_Parser parser = XML_ParserCreate(NULL);
+	int done;
+	XML_SetUserData(parser, this);
+	XML_SetElementHandler(parser, startElement, endElement);
+
+	FILE* in  = fopen(filename.c_str(), "r");
+
+	if (!in) return;
+
+	do
+	{
+		size_t len = fread(buf, 1, sizeof(buf), in);
+		done = len < sizeof(buf);
+		if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+		{
+			ostringstream s;
+			s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+			cerr <<  s.str() << "\n";
+			//throw MagicsException(s.str());
+		}
+	} while (!done);
+	XML_ParserFree(parser);
+	fclose(in);
+}
+
+template <class D> 
+const DefinitionTable<D>& DefinitionTable<D>::definitionTable(const string& file, const string& keyword)
+{
+    if (!tables_) tables_ = new map<string, DefinitionTable<D>* >();
+    typename map<string, DefinitionTable<D>*>::const_iterator local =  tables_->find(file);
+    if ( local == tables_->end() )
+    {
+       DefinitionTable<D>* newlocal = new DefinitionTable<D>(file, keyword);
+       (*tables_)[file] = newlocal;
+       return *newlocal;
+    }
+    return *(local->second);
+}
+
+template <class D>
+const D& DefinitionTable<D>::definitionInfo(const string& file, const string& keyword, int code)
+{
+    const DefinitionTable<D>& local = definitionTable(file, keyword); 
+    return local.definition(code);    
+}
+
+template <class D>
+DefinitionTable<D>::~DefinitionTable() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+template <class D>    
+void DefinitionTable<D>::print(ostream& out)  const
+{
+	out << "DefinitionTable[";
+	out << "]";
+}
diff --git a/src/visualisers/DefinitionTable.h b/src/visualisers/DefinitionTable.h
new file mode 100644
index 0000000..00aed87
--- /dev/null
+++ b/src/visualisers/DefinitionTable.h
@@ -0,0 +1,85 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef DefinitionTable_H
+#define DefinitionTable_H
+
+#include "magics.h"
+
+namespace magics {
+ 
+class BaseTable 
+{
+public:
+    BaseTable(const string& definition) : definition_(definition) {}
+    virtual ~BaseTable() {}
+    const string& info() const { return definition_; }
+    string definition_;
+    virtual void add(const map<string, string>&) = 0;
+   
+};
+
+template <class D>
+class DefinitionTable : public BaseTable, public map<int, D*>
+{
+public:
+	DefinitionTable(const string&, const string&);
+	virtual ~DefinitionTable();
+	 virtual void toxml(ostream&, int)  const {}
+    
+   
+   
+    const D& definition(int code) const {
+        typename map<int, D*>::const_iterator param = map<int, D*>::find(code);
+        if (param == this->end() ) return unknown_;
+        return *(param->second);
+    }
+    
+    static const DefinitionTable<D>& definitionTable(const string&, const string&);
+    static const D& definitionInfo(const string&, const string&, int code);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     string definition_;
+     
+     void add(const map<string, string>& def) 
+     {
+        D* param = new D(def);
+        (*this)[param->code()] = param;
+     } 
+     
+     static map<string, DefinitionTable<D>* >* tables_;
+     static D unknown_;
+   
+ 
+private:
+    //! Copy constructor - No copy allowed
+	DefinitionTable(const DefinitionTable<D>&);
+    //! Overloaded << operator to copy - No copy allowed
+	DefinitionTable& operator=(const DefinitionTable<D>&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const DefinitionTable<D>& p)
+		{ p.print(s); return s; }
+
+};
+
+#include "DefinitionTable.cc"
+} // namespace magics
+#endif
diff --git a/src/visualisers/DotPolyShadingMethod.h b/src/visualisers/DotPolyShadingMethod.h
new file mode 100644
index 0000000..5d96302
--- /dev/null
+++ b/src/visualisers/DotPolyShadingMethod.h
@@ -0,0 +1,85 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file DotPolyShadingMethod.h
+    \brief Definition of the Template class DotPolyShadingMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 25-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef DotPolyShadingMethod_H
+#define DotPolyShadingMethod_H
+
+#include "magics.h"
+#include "MagException.h"
+
+#include "PolyShadingMethod.h"
+#include "DotPolyShadingMethodAttributes.h"
+#include "IntervalMap.h"
+
+namespace magics {
+
+
+class DotPolyShadingMethod: public map<double, pair<double, double> >, public PolyShadingMethod, public DotPolyShadingMethodAttributes {
+
+public:
+	DotPolyShadingMethod() {}
+	virtual ~DotPolyShadingMethod() {}
+    
+    virtual void set(const map<string, string>& map) { DotPolyShadingMethodAttributes::set(map); }
+    virtual void set(const XmlNode& node) { DotPolyShadingMethodAttributes::set(node); }
+    virtual bool accept(const string& node) { return DotPolyShadingMethodAttributes::accept(node); }
+
+
+    virtual PolyShadingMethod* clone() const {
+		DotPolyShadingMethod* object = new DotPolyShadingMethod();
+		object->copy(*this);
+		return object;
+	}
+    
+    virtual void prepare(const LevelSelection& levels, const ColourTechnique& colours);
+
+    virtual void operator()(Polyline& poly) const;
+    	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+
+	 vector<float> dots_;
+private:
+    //! Copy constructor - No copy allowed
+	DotPolyShadingMethod(const DotPolyShadingMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	DotPolyShadingMethod& operator=(const DotPolyShadingMethod&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const DotPolyShadingMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+// Source in PolySghadingMethod.cc
+
+#endif
diff --git a/src/visualisers/DotPolyShadingMethodAttributes.h b/src/visualisers/DotPolyShadingMethodAttributes.h
new file mode 100644
index 0000000..1098635
--- /dev/null
+++ b/src/visualisers/DotPolyShadingMethodAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file DotPolyShadingMethodAttributes.h
+    \brief Definition of DotPolyShadingMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef DotPolyShadingMethodAttributes_H
+#define DotPolyShadingMethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class DotPolyShadingMethodAttributes 
+{
+public:
+//  --  constructor
+    DotPolyShadingMethodAttributes();
+    
+//  --  destructor
+    virtual ~DotPolyShadingMethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const DotPolyShadingMethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double size_;
+	double max_density_;
+	double min_density_;
+	double angle_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const DotPolyShadingMethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/EfiGraphAttributes.cc b/src/visualisers/EfiGraphAttributes.cc
new file mode 100644
index 0000000..d098c89
--- /dev/null
+++ b/src/visualisers/EfiGraphAttributes.cc
@@ -0,0 +1,172 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file EfiGraphAttributes.cc
+    \brief Implementation of EfiGraph Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "EfiGraphAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+EfiGraphAttributes::EfiGraphAttributes():
+	box_colour_(ParameterManager::getStringArray("efi_box_colour_array")),
+	border_colour_(MagTranslator<string, Colour>().magics("efi_box_border_colour")),
+	border_thickness_(ParameterManager::getInt("efi_box_border_thickness")),
+	border_style_(MagTranslator<string, LineStyle>().magics("efi_box_border_line_style")),
+	normal_colour_(MagTranslator<string, Colour>().magics("efi_normal_colour")),
+	normal_thickness_(ParameterManager::getInt("efi_normal_thickness")),
+	normal_style_(MagTranslator<string, LineStyle>().magics("efi_normal_line_style")),
+	font_(ParameterManager::getString("efi_font")),
+	font_size_(ParameterManager::getDouble("efi_font_size")),
+	font_style_(ParameterManager::getString("efi_font_style")),
+	font_colour_(MagTranslator<string, Colour>().magics("efi_font_colour"))
+{
+} 
+
+
+
+EfiGraphAttributes::~EfiGraphAttributes()
+{
+}
+
+    
+void EfiGraphAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "efi";
+
+	setAttribute(prefix, "efi_box_colour_array", box_colour_, params);
+	setAttribute(prefix, "efi_box_border_colour", border_colour_, params);
+	setAttribute(prefix, "efi_box_border_thickness", border_thickness_, params);
+	setAttribute(prefix, "efi_box_border_line_style", border_style_, params);
+	setAttribute(prefix, "efi_normal_colour", normal_colour_, params);
+	setAttribute(prefix, "efi_normal_thickness", normal_thickness_, params);
+	setAttribute(prefix, "efi_normal_line_style", normal_style_, params);
+	setAttribute(prefix, "efi_font", font_, params);
+	setAttribute(prefix, "efi_font_size", font_size_, params);
+	setAttribute(prefix, "efi_font_style", font_style_, params);
+	setAttribute(prefix, "efi_font_colour", font_colour_, params);
+}
+
+void EfiGraphAttributes::copy(const EfiGraphAttributes& other)
+{
+	box_colour_ = other.box_colour_;
+	border_colour_ = auto_ptr<Colour>(other.border_colour_->clone());
+	border_thickness_ = other.border_thickness_;
+	border_style_ = other.border_style_;
+	normal_colour_ = auto_ptr<Colour>(other.normal_colour_->clone());
+	normal_thickness_ = other.normal_thickness_;
+	normal_style_ = other.normal_style_;
+	font_ = other.font_;
+	font_size_ = other.font_size_;
+	font_style_ = other.font_style_;
+	font_colour_ = auto_ptr<Colour>(other.font_colour_->clone());
+} 
+
+
+bool EfiGraphAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "efigraph")  )
+		return true;
+	return false;
+}
+
+void EfiGraphAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "efigraph") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void EfiGraphAttributes::print(ostream& out)  const
+{
+	out << "EfiGraphAttributes[";
+	out << "box_colour = " << box_colour_;
+	out << ", border_colour = " << *border_colour_;
+	out << ", border_thickness = " << border_thickness_;
+	out << ", border_style = " << border_style_;
+	out << ", normal_colour = " << *normal_colour_;
+	out << ", normal_thickness = " << normal_thickness_;
+	out << ", normal_style = " << normal_style_;
+	out << ", font = " << font_;
+	out << ", font_size = " << font_size_;
+	out << ", font_style = " << font_style_;
+	out << ", font_colour = " << *font_colour_;
+	out << "]" << "\n";
+}
+
+
+void EfiGraphAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"efigraph\"";
+	 out << ", \"efi_box_colour_array\":";
+	 niceprint(out,box_colour_);
+	 out << ", \"efi_box_border_colour\":";
+	 niceprint(out, *border_colour_);
+	 out << ", \"efi_box_border_thickness\":";
+	 niceprint(out,border_thickness_);
+	 out << ", \"efi_box_border_line_style\":";
+	 niceprint(out,border_style_);
+	 out << ", \"efi_normal_colour\":";
+	 niceprint(out, *normal_colour_);
+	 out << ", \"efi_normal_thickness\":";
+	 niceprint(out,normal_thickness_);
+	 out << ", \"efi_normal_line_style\":";
+	 niceprint(out,normal_style_);
+	 out << ", \"efi_font\":";
+	 niceprint(out,font_);
+	 out << ", \"efi_font_size\":";
+	 niceprint(out,font_size_);
+	 out << ", \"efi_font_style\":";
+	 niceprint(out,font_style_);
+	 out << ", \"efi_font_colour\":";
+	 niceprint(out, *font_colour_);
+}
+static MagicsParameter<stringarray> efi_box_colour_array("efi_box_colour_array", stringarray(), "");
+static MagicsParameter<string> efi_box_border_colour("efi_box_border_colour", "black", "");
+static MagicsParameter<int> efi_box_border_thickness("efi_box_border_thickness", 1, "");
+static MagicsParameter<string> efi_box_border_line_style("efi_box_border_line_style", "solid", "");
+static MagicsParameter<string> efi_normal_colour("efi_normal_colour", "black", "");
+static MagicsParameter<int> efi_normal_thickness("efi_normal_thickness", 4, "");
+static MagicsParameter<string> efi_normal_line_style("efi_normal_line_style", "solid", "");
+static MagicsParameter<string> efi_font("efi_font", "sansserif", "");
+static MagicsParameter<double> efi_font_size("efi_font_size", 0.25, "");
+static MagicsParameter<string> efi_font_style("efi_font_style", "", "");
+static MagicsParameter<string> efi_font_colour("efi_font_colour", "black", "");
diff --git a/src/visualisers/EpsCloudAttributes.cc b/src/visualisers/EpsCloudAttributes.cc
new file mode 100644
index 0000000..2ef2492
--- /dev/null
+++ b/src/visualisers/EpsCloudAttributes.cc
@@ -0,0 +1,110 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file EpsCloudAttributes.cc
+    \brief Implementation of EpsCloud Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "EpsCloudAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+EpsCloudAttributes::EpsCloudAttributes():
+	colour_(MagTranslator<string, Colour>().magics("eps_rose_cloud_colour")),
+	border_colour_(MagTranslator<string, Colour>().magics("eps_rose_cloud_border_colour"))
+{
+} 
+
+
+
+EpsCloudAttributes::~EpsCloudAttributes()
+{
+}
+
+    
+void EpsCloudAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "eps_rose_cloud";
+	prefix[1] = "eps";
+
+	setAttribute(prefix, "eps_rose_cloud_colour", colour_, params);
+	setAttribute(prefix, "eps_rose_cloud_border_colour", border_colour_, params);
+}
+
+void EpsCloudAttributes::copy(const EpsCloudAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	border_colour_ = auto_ptr<Colour>(other.border_colour_->clone());
+} 
+
+
+bool EpsCloudAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "epscloud")  )
+		return true;
+	return false;
+}
+
+void EpsCloudAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "epscloud") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void EpsCloudAttributes::print(ostream& out)  const
+{
+	out << "EpsCloudAttributes[";
+	out << "colour = " << *colour_;
+	out << ", border_colour = " << *border_colour_;
+	out << "]" << "\n";
+}
+
+
+void EpsCloudAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"epscloud\"";
+	 out << ", \"eps_rose_cloud_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"eps_rose_cloud_border_colour\":";
+	 niceprint(out, *border_colour_);
+}
+static MagicsParameter<string> eps_rose_cloud_colour("eps_rose_cloud_colour", "black", "");
+static MagicsParameter<string> eps_rose_cloud_border_colour("eps_rose_cloud_border_colour", "none", "");
diff --git a/src/visualisers/EpsForecastPlot.h b/src/visualisers/EpsForecastPlot.h
new file mode 100644
index 0000000..b73b5d7
--- /dev/null
+++ b/src/visualisers/EpsForecastPlot.h
@@ -0,0 +1,136 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsForecastPlot.h
+    \brief Definition of the Template class EpsForecastPlot.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 15-Dec-2005
+    
+    Changes:
+    
+*/
+
+#ifndef EpsForecastPlot_H
+#define EpsForecastPlot_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class EpsForecastPlot {
+
+public:
+	EpsForecastPlot() {}
+	virtual ~EpsForecastPlot() {}
+    
+    virtual void set(const XmlNode&) {        
+    }
+    virtual void set(const map<string, string>&) {        
+    }
+    virtual EpsForecastPlot* clone() const {        
+        return new EpsForecastPlot();
+    }
+    
+    virtual bool forecast() { return true; }
+    virtual bool control() { return true; }
+    
+     virtual void toxml(ostream&, int)  const {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsForecastPlot(const EpsForecastPlot&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsForecastPlot& operator=(const EpsForecastPlot&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsForecastPlot& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsForecastOnly : public EpsForecastPlot
+{
+public:
+	EpsForecastOnly() {}
+	virtual ~EpsForecastOnly() {}
+    
+    virtual EpsForecastPlot* clone() const {        
+        return new EpsForecastOnly();
+    }
+    
+    virtual bool forecast() { return true; }
+    virtual bool control() { return false; }
+};
+
+class EpsControlOnly : public EpsForecastPlot
+{
+public:
+	EpsControlOnly() {}
+	virtual ~EpsControlOnly() {}
+    
+    virtual EpsForecastPlot* clone() const {        
+        return new EpsControlOnly();
+    }
+    
+    virtual bool forecast() { return false; }
+    virtual bool control() { return true; }
+};
+
+class EpsNoForecast : public EpsForecastPlot
+{
+public:
+	EpsNoForecast() {}
+	virtual ~EpsNoForecast() {}
+    
+    virtual EpsForecastPlot* clone() const {        
+        return new EpsNoForecast();
+    }
+    
+    virtual bool forecast() { return false; }
+    virtual bool control() { return false; }
+};
+
+template <>
+class MagTranslator<string, EpsForecastPlot> { 
+public:
+	EpsForecastPlot* operator()(const string& val )
+	{
+		return SimpleObjectMaker<EpsForecastPlot>::create(val);
+	}     
+
+	EpsForecastPlot* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/EpsGraph.cc b/src/visualisers/EpsGraph.cc
new file mode 100644
index 0000000..a925841
--- /dev/null
+++ b/src/visualisers/EpsGraph.cc
@@ -0,0 +1,2644 @@
+
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHvisitor WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsGraph.cc
+    \brief Implementation of the Template class EpsGraph.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "EpsGraph.h"
+#include "PointsHandler.h"
+#include "DateTime.h"
+#include "Text.h"
+#include "LegendVisitor.h"
+
+//#include "InteractiveSet.h"
+#include <cfloat>
+#include <locale>
+
+using namespace magics;
+
+string writeDate(DateTime& date, const string& format)
+{
+	std::locale loc("");
+
+	ostringstream visitor;
+	visitor.imbue(loc);
+
+	const std::time_put<char>& facet = std::use_facet<std::time_put<char> >(loc); 
+
+	tm convert = date;
+	facet.put(visitor, visitor, ' ', &convert, format.c_str(), format.c_str()+format.length());    
+
+	return visitor.str();
+}
+
+void tick(double min, double max, vector<double>& ticks)
+{
+	float inc;
+	int nb = 7;
+	float step;
+	float log, ws;
+
+	double wmax = std::max(min, max);
+	double wmin = std::min(min, max);
+	
+  //cvisitor << "min=" << min << " max=" << max << endl;
+	
+	while (nb < 20)
+	{
+		step = (wmax-wmin)/nb;
+		log = log10(step);
+		ws = pow(10., int(log));
+		inc = ceil(step/ws)*ws;
+		//MagLog::dev() << "Automatic method ---> increment = " << inc << " ---> try base=" << inc/ws << endl;
+			
+		if ( wmax-wmin != inc && (inc/ws == 1 || inc/ws == 2 || inc/ws == 5 || inc/ws == 10) ) {
+			//MagLog::dev() << "Automatic method ---> increment " << inc << " OK! " << endl;
+			break;
+		}
+		nb++;	
+	}
+	
+	float first = floor(min/inc) *inc; 
+	double val = first > min ? first-inc : first;
+        bool last = true;
+        while (  last )
+	{ 
+		if (val >= max ) last = false;
+		ticks.push_back(val);
+
+		//cvisitor << "val->" << val << endl;
+		 val+=inc;
+	}
+}
+class EmptyEntry : public LegendEntry
+{
+public:
+	EmptyEntry() : LegendEntry(" ") {}
+    void set(const PaperPoint&, BasicGraphicsObjectContainer&) {}
+};
+
+class EpsEntry : public LegendEntry
+{
+public:
+	EpsEntry() : LegendEntry(" ") {}
+	void colour(const Colour& colour) { colour_ = colour; }
+	void borderColour(const Colour& colour) { border_colour_ = colour; }
+	void font(const MagFont& font) { font_ = font; }
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+
+		double x = point.x();
+		double y = point.y() - 0.125 ;
+
+	
+		Polyline* box  = new Polyline();
+		box->setColour(border_colour_);
+		box->setFilled(true);
+		box->setShading(new FillShadingProperties());
+		box->setFillColour(colour_);
+		
+        
+
+		double width = 0.15;
+		double height = 1.5; 
+		double top = y+height;
+		double bottom = y-height;
+		box->push_back(PaperPoint(x-width, y));
+		box->push_back(PaperPoint(x-width, top));
+		box->push_back(PaperPoint(x+width, top));
+		box->push_back(PaperPoint(x+width, y));
+		box->push_back(PaperPoint(x-width, y));
+		box->push_back(PaperPoint(x-width, bottom));
+		box->push_back(PaperPoint(x+width, bottom));
+		box->push_back(PaperPoint(x+width, y));
+		box->push_back(PaperPoint(x-width, y));
+		visitor.push_back(box);
+		Polyline* up  = new Polyline();
+		up->setColour(border_colour_);
+		(*up).push_back(PaperPoint(x, top+height));
+		(*up).push_back(PaperPoint(x, top));
+		visitor.push_back(up);
+		Polyline* down  = new Polyline();
+		down->setColour(border_colour_);
+		(*down).push_back(PaperPoint(x, bottom));
+		(*down).push_back(PaperPoint(x, bottom-height));
+		visitor.push_back(down);
+		
+		// Now the text...
+		Text* max  = new Text();
+		max->setText("max");
+		max->setFont(font_);		
+		max->setJustification(MLEFT);
+		(*max).push_back(PaperPoint(x + 1*.2, bottom-height));
+		visitor.push_back(max);
+		
+		Text* min  = new Text();
+		min->setText("min");
+		min->setFont(font_);
+		min->setJustification(MLEFT);		
+		(*min).push_back(PaperPoint(x + 1*.2, top+height));
+		visitor.push_back(min);
+        
+       
+		Text* seventyfive  = new Text();
+		seventyfive->setText("75%");
+		seventyfive->setFont(font_);
+		seventyfive->setJustification(MLEFT);		
+		seventyfive->push_back(PaperPoint(x + 1*0.3, bottom));
+		visitor.push_back(seventyfive);
+		
+		Text* fifty  = new Text();
+		fifty->setText("median");
+		fifty->setFont(font_);
+		fifty->setJustification(MLEFT);
+		(*fifty).push_back(PaperPoint(x + 1*0.3, y));
+		visitor.push_back(fifty);
+		
+		Text* twentyfive  = new Text();
+		twentyfive->setText("25%");
+		twentyfive->setFont(font_);
+		twentyfive->setJustification(MLEFT);
+		twentyfive->push_back(PaperPoint(x + 1*0.3, top));
+		visitor.push_back(twentyfive);
+	}
+	
+protected:
+	Polyline*  box_;
+	Colour colour_;
+	Colour border_colour_;
+	MagFont font_;
+};
+
+
+class FullEpsEntry : public EpsEntry
+{
+public:
+	FullEpsEntry() {}
+
+	virtual void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+		
+
+		double x = point.x();
+		double y = point.y() ;
+
+		MagLog::dev() << "FulleEps Entry->  [" << x << ", " << y << "]" << endl;
+	
+		Polyline* box  = new Polyline();
+		box->setColour(border_colour_);
+		box->setFilled(true);
+		box->setFillColour(colour_);
+		box->setShading(new FillShadingProperties());
+
+		double width = 1*0.2;
+		double height = 1*0.2; 
+		double top1 = y+height;
+		double bottom1 = y-height;
+		double top2 = y+height+height;
+		double bottom2 = y-height-height;
+		box->push_back(PaperPoint(x-width, y));
+		box->push_back(PaperPoint(x-width, top1));
+		box->push_back(PaperPoint(x+(width/2), top1));
+		box->push_back(PaperPoint(x+(width/2), top2));
+		box->push_back(PaperPoint(x-(width/2), top2));
+		box->push_back(PaperPoint(x-(width/2), top1));
+		box->push_back(PaperPoint(x+width, top1));
+		box->push_back(PaperPoint(x+width, y));
+		box->push_back(PaperPoint(x-width, y));
+		box->push_back(PaperPoint(x-width, bottom1));
+		box->push_back(PaperPoint(x+(width/2), bottom1));
+		box->push_back(PaperPoint(x+(width/2), bottom2));
+		box->push_back(PaperPoint(x-(width/2), bottom2));
+		box->push_back(PaperPoint(x-(width/2), bottom1));
+		box->push_back(PaperPoint(x+width, bottom1));
+		box->push_back(PaperPoint(x+width, y));
+		box->push_back(PaperPoint(x-width, y));
+		visitor.push_back(box);
+		Polyline* up  = new Polyline();
+		up->setColour(border_colour_);
+		(*up).push_back(PaperPoint(x, top2+height));
+		(*up).push_back(PaperPoint(x, top2));
+		visitor.push_back(up);
+		Polyline* down  = new Polyline();
+		down->setColour(border_colour_);
+		(*down).push_back(PaperPoint(x, bottom2));
+		(*down).push_back(PaperPoint(x, bottom2-height));
+		visitor.push_back(down);
+		
+		// Now the text...
+		Text* max  = new Text();
+		max->setText("max");
+		max->setFont(font_);
+		max->setJustification(MLEFT);
+		max->push_back(PaperPoint(x + 0.5, bottom2-height));
+
+		visitor.push_back(max);
+		
+		Text* min  = new Text();
+		min->setText("min");
+		min->setFont(font_);
+		min->setJustification(MLEFT);
+		min->push_back(PaperPoint(x + 1*0.5, top2+height));
+		visitor.push_back(min);
+        
+		Text* ninety  = new Text();
+		ninety->setText("90%");
+		ninety->setFont(font_);
+		ninety->setJustification(MLEFT);
+		ninety->push_back(PaperPoint(x + 0.5, bottom2));
+		visitor.push_back(ninety);
+		
+		Text* ten  = new Text();
+		ten->setText("10%");
+		ten->setFont(font_);
+		ten->setJustification(MLEFT);
+		ten->push_back(PaperPoint(x + 0.5, top2));
+		visitor.push_back(ten);
+		
+		Text* seventyfive  = new Text();
+		seventyfive->setText("75%");
+		seventyfive->setFont(font_);
+		seventyfive->setJustification(MLEFT);
+		seventyfive->push_back(PaperPoint(x + 0.75, bottom1));
+		visitor.push_back(seventyfive);
+		
+		Text* fifty  = new Text();
+		fifty->setText("median");
+		fifty->setFont(font_);
+		fifty->setJustification(MLEFT);
+		(*fifty).push_back(PaperPoint(x + 0.75, y));
+		visitor.push_back(fifty);
+		
+		Text* twentyfive  = new Text();
+		twentyfive->setText("25%");
+		twentyfive->setFont(font_);
+		twentyfive->setJustification(MLEFT);
+		twentyfive->push_back(PaperPoint(x + 0.75, top1));
+
+		visitor.push_back(twentyfive);
+	}
+};
+
+class WindRoseEntry : public EpsEntry
+{
+public:
+	WindRoseEntry(const Colour& colour) { colour_ = colour; }
+
+	virtual void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+		
+
+		double x = point.x()-0.5;
+		double y = point.y() ;
+
+		MagLog::dev() << "FulleEps Entry->  [" << x << ", " << y << "]" << endl;
+	
+		
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	
+	float start = x;
+	
+	for ( int i = 0; i != 100; i ++ ) { 
+	    
+		Hsl hsl = colour_.hsl();    
+        float light = hsl.light_;        
+        hsl.light_ += (0.99 - light)*((100-i)/100.);
+    	Colour colour(hsl);
+		
+		Polyline* box  = new Polyline();
+		box->setColour(colour);
+		box->setFilled(true);
+		box->setFillColour(colour);
+		box->setShading(new FillShadingProperties());
+		
+		double width = 0.0225;
+		double height = 1*0.25; 
+		box->push_back(PaperPoint(start, y));
+		box->push_back(PaperPoint(start, y+height));
+		box->push_back(PaperPoint(start+width, y+height));
+		box->push_back(PaperPoint(start+width, y));
+		box->push_back(PaperPoint(start, y));		
+		visitor.push_back(box);
+		
+		start+=width;
+		
+	}
+		
+		Polyline* box  = new Polyline();
+		box->setColour(border_colour_);
+		box->setFilled(false);
+		
+		
+		double height = 1*0.25; 
+		box->push_back(PaperPoint(x, y));
+		box->push_back(PaperPoint(x, y+height));
+		box->push_back(PaperPoint(start, y+height));
+		box->push_back(PaperPoint(start, y));
+		box->push_back(PaperPoint(x, y));		
+		visitor.push_back(box);
+		
+		// Now the text...
+		Text* text  = new Text();
+		text->setText("0%");
+		text->setFont(font_);
+		text->setJustification(MLEFT);
+		text->push_back(PaperPoint(x, y-0.2));
+		visitor.push_back(text);
+		text  = new Text();
+		text->setText("25%");
+		text->setFont(font_);
+		text->setJustification(MLEFT);
+		text->push_back(PaperPoint(x+0.5, y-0.2));
+		visitor.push_back(text);	
+		text  = new Text();
+		text->setText("50%");
+		text->setFont(font_);
+		text->setJustification(MLEFT);
+		text->push_back(PaperPoint(x+1, y-0.2));
+		visitor.push_back(text);	
+		text  = new Text();
+		text->setText("75%");
+		text->setFont(font_);
+		text->setJustification(MLEFT);
+		text->push_back(PaperPoint(x+1.5, y-0.2));
+		visitor.push_back(text);
+		text  = new Text();
+		text->setText("100%");
+		text->setFont(font_);
+		text->setJustification(MLEFT);
+		text->push_back(PaperPoint(x+2, y-0.2));
+		visitor.push_back(text);		
+		
+		
+		
+		
+	}
+	string text_;
+	
+};
+
+
+class WaveRoseEntry : public EpsEntry
+{
+public:
+	WaveRoseEntry(vector<Colour>& colour) { colours_ = colour; }
+
+	virtual void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+
+		double x = point.x();
+		double y = point.y() ;
+
+		MagLog::dev() << "FulleEps Entry->  [" << x << ", " << y << "]" << endl;
+	
+		
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	
+	float start = x;
+	
+	
+	for ( vector<Colour>::const_iterator colour = colours_.begin(); colour != colours_.end(); ++colour) { 
+		
+		Polyline* box  = new Polyline();
+		box->setColour(*colour);
+		box->setFilled(true);
+		box->setShading(new FillShadingProperties());
+		box->setFillColour(*colour);
+		double width = 0.4;
+		double height = 1*0.25; 
+		box->push_back(PaperPoint(start, y));
+		box->push_back(PaperPoint(start, y+height));
+		box->push_back(PaperPoint(start+width, y+height));
+		box->push_back(PaperPoint(start+width, y));
+		box->push_back(PaperPoint(start, y));		
+		visitor.push_back(box);
+		
+		start+=width;
+		
+	}
+		
+		Polyline* box  = new Polyline();
+		box->setColour(border_colour_);
+		box->setFilled(false);
+		
+		double height = 1*0.25; 
+		box->push_back(PaperPoint(x, y));
+		box->push_back(PaperPoint(x, y+height));
+		box->push_back(PaperPoint(start, y+height));
+		box->push_back(PaperPoint(start, y));
+		box->push_back(PaperPoint(x, y));		
+		visitor.push_back(box);
+		
+		// Now the text...
+		Text* text  = new Text();
+		text->setText("1");
+		text->setFont(font_);
+		text->setJustification(MCENTRE);
+		text->push_back(PaperPoint(x+0.35, y-0.2));
+		visitor.push_back(text);
+		
+		text  = new Text();
+		text->setText("2.5");
+		text->setFont(font_);
+		text->setJustification(MCENTRE);
+		text->push_back(PaperPoint(x+0.8, y-0.2));
+		visitor.push_back(text);	
+
+		text  = new Text();
+		text->setText("4");
+		text->setFont(font_);
+		text->setJustification(MCENTRE);
+		text->push_back(PaperPoint(x+1.2, y-0.2));
+		visitor.push_back(text);	
+		
+		text  = new Text();
+		text->setText("6");
+		text->setFont(font_);
+		text->setJustification(MCENTRE);
+		text->push_back(PaperPoint(x+1.6, y-0.2));
+		visitor.push_back(text);
+		
+		text  = new Text();
+		text->setText("9 m");
+		text->setFont(font_);
+		text->setJustification(MLEFT);
+		text->push_back(PaperPoint(x+2.0, y-0.2));
+		visitor.push_back(text);		
+		
+		
+		
+		
+	}
+	string text_;
+	vector<Colour> colours_;
+	
+};
+
+
+class EpsControl : public LegendEntry
+{
+public:
+	EpsControl(double resolution, const string& type) : LegendEntry(" ")
+	{
+		ostringstream title;
+		// carefull here this text is depending of the resolution! 
+		MagLog::dev() << "EpsControl=>resolution" << resolution << endl; 
+        int km = maground(40000/(2*(resolution+1)+2));  
+		title << "EPS Control(" + tostring(km) + " km)";
+		title_ = title.str();
+	}
+	EpsControl(const string& title) : LegendEntry(" ")
+	{
+		
+		title_ = title;
+	}
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+		
+
+		double x = point.x();
+		double y = point.y() - 0.125;
+		
+
+		MagLog::dev() << "Legend at Point[" << point.x() << ", " << point.y() << "]" << endl;
+	
+		Text* text  = new Text();
+		text->addText(title_, Colour("red"),  0.3); // should be customisable
+		text->setJustification(MLEFT);
+		(*text).push_back(PaperPoint(x + 1*0.04, y));
+		visitor.push_back(text);
+	}
+	
+protected:
+	string title_;
+};
+
+
+class EpsForecast : public LegendEntry
+{
+public:
+	EpsForecast(double resolution, const string& type) : LegendEntry(" ")
+	{
+		MagLog::dev() << "EpsForecsat=>resolution" << resolution << endl; 
+		ostringstream title;
+        int km = maground(40000/(2*(2*resolution+1)+2));        
+		title << "High Resolution Deterministic(" + tostring(km) + " km)";
+		title_ = title.str();
+	}
+	
+	EpsForecast(const string& title) : LegendEntry(" ")
+		{
+			
+			title_ = title;
+		}	
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+	
+		
+
+		double x = point.x();
+		double y = point.y()- 0.125;
+
+		
+		Text* text  = new Text();
+		text->addText(title_, Colour("blue"),  0.3); // should be customisable
+		text->setJustification(MLEFT);
+		(*text).push_back(PaperPoint(x + 1*0.04, y));
+		visitor.push_back(text);
+	}
+	
+protected:
+	string title_;
+};
+
+
+class EpsCalval1 : public LegendEntry
+{
+public:
+	EpsCalval1(double) : LegendEntry(" ")
+	{
+		ostringstream title;
+		//title << "T" << (2*resolution)-1 << " OPS";
+        title << "CAL/VAL 1";
+		title_ = title.str();
+	}
+		
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+		
+	
+		
+	
+		double x = point.x();
+		double y = point.y()- 0.125;
+		Polyline* line  = new Polyline();
+		line->setColour(Colour("green"));
+		
+		line->setLineStyle(M_SOLID);
+		line->setThickness(2);
+		line->push_back(PaperPoint(x-1*0.025, y));
+		line->push_back(PaperPoint(x+1*0.025, y));
+		visitor.push_back(line);
+		
+		Text* text  = new Text();
+		text->setText(title_);
+		text->setJustification(MLEFT);
+		(*text).push_back(PaperPoint(x + 1*0.04, y));
+		visitor.push_back(text);
+	}
+	
+protected:
+	string title_;
+};
+
+class EpsCalval2 : public LegendEntry
+{
+public:
+	EpsCalval2(double) : LegendEntry(" ")
+	{
+		ostringstream title;
+		//title << "T" << (2*resolution)-1 << " OPS";
+        title << "CAL/VAL 2";
+		title_ = title.str();
+	}
+		
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+		
+		
+		
+	
+		double x = point.x();
+		double y = point.y()- 0.125;
+		Polyline* line  = new Polyline();
+		line->setColour(Colour("magenta"));
+		
+		
+		line->setThickness(2);
+		line->push_back(PaperPoint(x-1*0.025, y));
+		line->push_back(PaperPoint(x+1*0.025, y));
+		visitor.push_back(line);
+		
+		Text* text  = new Text();
+		text->addText(title_, Colour("blue"),  0.3); // should be customisable
+		text->setJustification(MLEFT);
+		(*text).push_back(PaperPoint(x + 1*0.04, y));
+		visitor.push_back(text);
+	}
+	
+protected:
+	string title_;
+};
+
+
+EpsGraph::EpsGraph() : forecast_(false), control_(false), eps_(true)
+{
+}
+
+
+EpsGraph::~EpsGraph() 
+{}
+
+/*!
+ Class information are given to the visitorput-stream.
+*/		
+void EpsGraph::print(ostream& visitor)  const
+{
+	visitor << "EpsGraph[";
+	visitor << "]";
+}
+
+
+
+void EpsGraph::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	
+	CustomisedPointsList points; 
+	std::set<string> request;
+
+	const Transformation& transformation = visitor.transformation();
+	
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	
+	if (points.empty()) return;
+	
+
+
+	
+	Polyline* control  = new Polyline();
+	control->setColour(*control_colour_);
+	control->setLineStyle(control_style_);
+	control->setThickness(control_thickness_);
+	
+	Polyline* forecast  = new Polyline();
+	forecast->setColour(*deterministic_colour_);
+	forecast->setThickness(deterministic_thickness_);
+	forecast->setLineStyle(deterministic_style_);
+    
+   
+	
+	
+
+	resolution_ = (*points.front())["resolution"];
+	
+	
+	
+		
+		DateTime base = points.front()->base();
+		
+	
+    vector<BasicGraphicsObject*> list, list2;
+    
+    
+    
+    if ( points.size() < 2 ) return;
+    fullEps_ = false;
+    
+    Colour colour = *colour_;
+    
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		resolution_ = (**point)["resolution"];
+		
+		double x = (**point)["step"] + box_shift_ *3600;
+		double width = (box_width_ == -1) ? (**point)["width"] : box_width_ * 3600;
+		
+		if ( (**point)["right"] ) colour = *right_colour_;
+		if ( (**point)["left"] )  colour = *left_colour_;
+		
+
+		double max = ((*point)->find("max") != (*point)->end()) ? (*point)->find("max")->second : (*point)->find("maximum")->second;
+		double min = ((*point)->find("min") != (*point)->end()) ? (*point)->find("min")->second : (*point)->find("minimum")->second;
+
+
+		CustomisedPoint::const_iterator ten   = (*point)->find("ten");
+        CustomisedPoint::const_iterator ninty = (*point)->find("ninty");
+
+
+
+		
+        
+
+        if ( (*point)->find("control") != (*point)->end() &&  (**point)["control"]!= 9999.  )
+        	control->push_back(PaperPoint(x, (**point)["control"]));		
+		if ( (*point)->find("forecast") != (*point)->end() &&  (**point)["forecast"] != 9999.)
+            forecast->push_back(PaperPoint(x, (**point)["forecast"]));
+        if ( (*point)->find("median") == (*point)->end() )  {        	
+            eps_ = false;  
+            continue;
+        }
+        if (  (**point)["median"] == 9999. ) {        	
+                   eps_ = false;  
+                   continue;
+               }
+        
+        double epsmin = (**point)["min"];
+        double eps10 = (**point)["ten"];
+        if (eps10 < epsmin) eps10 = epsmin;
+        double eps25 = (**point)["twentyfive"];
+        if (eps25 < eps10) eps25 = eps10;
+        double eps50 = (**point)["median"];
+        if (eps50 < eps25) eps50 = eps25;
+        double eps75 = (**point)["seventyfive"];
+        if (eps75 < eps50) eps75 = eps50;
+        double eps90 = (**point)["ninty"];
+        if (eps90 < eps75) eps90 = eps75;
+       
+		Polyline* box  = new Polyline();
+		box->setColour(*border_colour_);
+		box->setThickness(border_thickness_);
+
+		box->setColour(*border_colour_);
+		box->setFilled(true);
+		box->setThickness(border_thickness_);
+		box->setFillColour(colour);
+		box->setShading(new FillShadingProperties());
+      
+        Polyline* median  = new Polyline();
+        median->setColour(*median_colour_);
+        
+        Polyline* bar1  = new Polyline();
+        bar1->setColour(*border_colour_);
+        bar1->setThickness(border_thickness_);
+
+        Polyline* bar2  = new Polyline();
+        bar2->setColour(*border_colour_);
+        bar2->setThickness(border_thickness_);
+
+        box->push_back(PaperPoint(x-width, eps50));
+		box->push_back(PaperPoint(x-width, eps75));
+        
+        if ( ninty != (*point)->end() ) {
+        	fullEps_ = true;
+            box->push_back(PaperPoint(x-(width/2), eps75));
+            box->push_back(PaperPoint(x-(width/2), eps90) );
+            box->push_back(PaperPoint(x+(width/2), eps90));
+            box->push_back(PaperPoint(x+(width/2), eps75));
+            
+        }
+		box->push_back(PaperPoint(x+width, eps75));
+		//box->push_back(PaperPoint(x+width, (**point)["median"]));
+		box->push_back(PaperPoint(x+width, eps25));
+
+        if ( ten != (*point)->end() ) {
+            box->push_back(PaperPoint(x+(width/2), eps25));
+            box->push_back(PaperPoint(x+(width/2),eps10));
+            box->push_back(PaperPoint(x-(width/2), eps10));
+            box->push_back(PaperPoint(x-(width/2), eps25));
+            
+        }
+        box->push_back(PaperPoint(x-width, eps25));
+        box->push_back(PaperPoint(x-width, eps50));
+
+    	bar1->push_back(PaperPoint(x+width, eps25));
+    	bar1->push_back(PaperPoint(x-width, eps25));
+
+    	bar2->push_back(PaperPoint(x+width, eps75));
+    	bar2->push_back(PaperPoint(x-width, eps75));
+
+    	median->push_back(PaperPoint(x+width, eps50));
+		median->push_back(PaperPoint(x-width, eps50));
+		
+		
+		Polyline* top  = new Polyline();
+		top->setColour(*border_colour_);
+		top->setThickness(border_thickness_);
+		
+	     
+		(*top).push_back(PaperPoint(x, max > transformation.getMaxY() ? transformation.getMaxY() : max));
+		
+		if ( ninty != (*point)->end() ) 
+            (*top).push_back(PaperPoint(x, eps90));
+        else 
+            (*top).push_back(PaperPoint(x, eps75));
+		Polyline* bottom  = new Polyline();
+		bottom->setColour(*border_colour_);
+		bottom->setThickness(border_thickness_);
+		(*bottom).push_back(PaperPoint(x, min));
+        if ( ten != (*point)->end() ) 
+            (*bottom).push_back(PaperPoint(x, eps10));
+		else 
+           (*bottom).push_back(PaperPoint(x, eps25));
+		
+		if (whisker_) {
+            transformation(*box, visitor);
+            transformation(*top, visitor);
+            transformation(*bottom, visitor);
+            transformation(*median, visitor);
+            transformation(*bar1, visitor);
+            transformation(*bar2, visitor);
+		}
+		
+		// find the max! 
+		vector<double> ypos;
+		 for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		   		double max = ((*point)->find("max") != (*point)->end()) ? (*point)->find("max")->second : (*point)->find("maximum")->second;
+				double min = ((*point)->find("min") != (*point)->end()) ? (*point)->find("min")->second : (*point)->find("minimum")->second;
+		        ypos.push_back(max);
+				ypos.push_back(min);
+				if ( (*point)->find("control") != (*point)->end() )
+					ypos.push_back((**point)["control"]);
+			    if ( (*point)->find("forecast") != (*point)->end() )
+				    ypos.push_back((**point)["forecast"]);
+		    
+		    }
+		
+		    double maxy = *std::max_element(ypos.begin(), ypos.end());
+		    maxy = ( max_ > INT_MIN ) ? max_ : maxy;
+		    double maxlabel = DBL_MIN;
+		   		        if (max > maxy) 
+		   		        		maxlabel = max;
+		   		        if (min > maxy) 
+		   		        		maxlabel = min; 
+       
+       
+       if ( max > transformation.getMaxY() ) {
+       	 Text* label = new Text();
+		 MagFont font(max_font_name_, max_font_style_, max_font_size_);
+		 font.colour(*max_font_colour_);		
+		 label->setText(tostring(maground(max)));
+		 label->setFont(font);
+		 label->push_back(PaperPoint(x, transformation.getMaxY()*1.05));
+		 visitor.push_back(label);
+       }
+
+		 
+       }
+		
+	
+	
+	if ( !control->empty() && whisker_) {		
+		transformation(*control, visitor);
+		control_ = true;
+	}
+	else 
+		control_ = false;
+	if ( !forecast->empty() && deterministic_) {					
+		transformation(*forecast, visitor);
+		forecast_ = true;
+	}
+	else
+		forecast_ = false;
+	
+	
+
+     	
+		
+
+}
+
+void EpsGraph::visit(LegendVisitor& legend)
+{
+	
+    if ( !legend_ ) return;
+	EpsEntry* entry = fullEps_ ? new FullEpsEntry() : new EpsEntry();
+	
+    entry->colour(*colour_);
+	entry->borderColour(*border_colour_);
+	
+    MagFont font(font_);
+    font.style(font_style_);
+	font.size(font_size_);
+	font.colour(*font_colour_);
+	entry->font(font);
+	if ( whisker_ && eps_ )	
+        legend.add(entry);
+	
+     
+    if ( control_  )   {
+    	MagLog::dev() << "LEGEND-> " << legend_control_text_ << endl;
+    	if (legend_control_text_.empty() )
+    		legend.add(new EpsControl(resolution_, legend_resolution_));
+    	else 
+    		legend.add(new EpsControl(legend_control_text_));
+    }
+    if ( forecast_  ) {
+    	if (legend_forecast_text_.empty() )
+    	    legend.add(new EpsForecast(resolution_, legend_resolution_));
+    	else 
+    	    legend.add(new EpsForecast(legend_forecast_text_));
+    }
+    	
+   
+}
+
+
+
+void triangle2(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos, double max)
+{
+
+	
+	double shift = 3.14*0.125;
+	
+	Polyline* poly = new Polyline();
+
+	poly->setThickness(2);
+	
+	double c = 1 - point[direction.first]/200;
+	
+	ostringstream colour;
+	colour << "Rgb(" << c << ", " << c << ", " << c << ")" << endl; 
+	
+	poly->setFillColour(colour.str());	
+	poly->setColour(Colour("Rgb(0.5, 0.5, 0.5)"));
+	
+	double length = 9*3600;
+	double x0 = length;
+//	double y0 = 0;
+//	double a = length *tan(shift);
+//	double b = length *tan(-shift);
+	
+	double x = x0 * cos(direction.second);
+	double y = x0 * sin(direction.second);
+	double x1 = x0 * cos(direction.second - shift);
+	double y1 = x0 * sin(direction.second - shift);
+	double x2 = x0 * cos(direction.second + shift);
+	double y2 = x0 * sin(direction.second + shift);
+	
+	double xs = 0;
+	double ys = 0;
+	
+	if ( point[direction.first] == max) {
+		xs = 3*3600 * cos(direction.second);
+		ys = 3*3600 * sin(direction.second);
+	}
+	
+	poly->push_back(PaperPoint(pos + xs , ys ));	
+	poly->push_back(PaperPoint(pos + xs + x1, ys + y1));
+	poly->push_back(PaperPoint(pos + xs + x, ys + y));
+	poly->push_back(PaperPoint(pos + xs + x2, ys + y2));
+	poly->push_back(PaperPoint(pos + xs, ys));	
+	
+	poly->setFilled(true);
+	poly->setShading(new FillShadingProperties());
+	
+	visitor.push_back(poly);
+
+    if ( int(point[direction.first]/2) < 5 ) return;
+    Text* text = new Text();
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	text->setFont(font);
+	text->setText( tostring(int(point[direction.first]/2)) );
+		
+		text->push_back(PaperPoint(pos + 11*3600 * cos(direction.second), 11.5*3600 * sin(direction.second)));
+		visitor.push_back(text);
+		
+    
+}
+
+void triangle3(const Colour& colour, const Colour& border, const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos, double max)
+{
+    
+    Hsl hsl = colour.hsl();
+    
+    float light = hsl.light_;
+   
+    hsl.light_ += (0.99 - light)*((point["total"]- point[direction.first])/point["total"]);
+     
+	
+	double shift = 3.14*0.125;
+	
+	Polyline* poly = new Polyline();
+	poly->setThickness(1);
+	
+	
+	poly->setFillColour(Colour(hsl));	
+	poly->setColour(border);
+	
+	double length =  (point[direction.first]*(12*3600)/max);
+	double x0 = length;
+//	double y0 = 0;
+//	double a = length *tan(shift);
+//	double b = length *tan(-shift);
+	
+	double x = x0 * cos(direction.second);
+	double y = x0 * sin(direction.second);
+	double x1 = x0 * cos(direction.second - shift);
+	double y1 = x0 * sin(direction.second - shift);
+	double x2 = x0 * cos(direction.second + shift);
+	double y2 = x0 * sin(direction.second + shift);
+	
+	double xs = 0;
+	double ys = 0;
+	
+	
+	poly->push_back(PaperPoint(pos + xs , ys ));	
+	poly->push_back(PaperPoint(pos + xs + x1, ys + y1));
+	poly->push_back(PaperPoint(pos + xs + x, ys + y));
+	poly->push_back(PaperPoint(pos + xs + x2, ys + y2));
+	poly->push_back(PaperPoint(pos + xs, ys));	
+	
+	poly->setFilled(true);
+	poly->setShading(new FillShadingProperties());
+	
+	visitor.push_back(poly);
+
+    if ( int(point[direction.first]/2) < 5 ) return;
+    Text* text = new Text();
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	text->setFont(font);
+	text->setText( tostring(int(point[direction.first]/2)) );
+		
+		text->push_back(PaperPoint(pos + 11*3600 * cos(direction.second), 11.5*3600 * sin(direction.second)));
+		visitor.push_back(text);
+		
+    
+}
+
+void EpsCloud::triangle(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos)
+{
+    
+	 Hsl hsl = colour_->hsl();
+    
+    float light = hsl.light_;
+   
+    hsl.light_ += (0.99 - light)*((100- point[direction.first])/100);
+     
+	
+	double shift = 3.14*0.125;
+	
+	Polyline* poly = new Polyline();
+	poly->setStroke(true);
+	
+	
+	poly->setFillColour(Colour(hsl));	
+	poly->setColour(Colour(hsl));
+	
+	double x0= 12*3600;
+	
+	
+	double x = x0 * cos(direction.second);
+	double y = x0 * sin(direction.second);
+	double x1 = x0 * cos(direction.second - shift);
+	double y1 = x0 * sin(direction.second - shift);
+	double x2 = x0 * cos(direction.second + shift);
+	double y2 = x0 * sin(direction.second + shift);
+	
+	double xs = 0;
+	double ys = 0;
+	
+	
+	poly->push_back(PaperPoint(pos + xs , ys ));	
+	poly->push_back(PaperPoint(pos + xs + x1, ys + y1));
+	poly->push_back(PaperPoint(pos + xs + x, ys + y));
+	poly->push_back(PaperPoint(pos + xs + x2, ys + y2));
+	poly->push_back(PaperPoint(pos + xs, ys));	
+	
+	poly->setFilled(true);
+	poly->setShading(new FillShadingProperties());
+	
+	visitor.push_back(poly);
+
+	
+    
+}
+
+
+
+
+void triangle(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos, double)
+{
+
+	if ( !point[direction.first] ) return; 
+	double shift = 3.14*0.125;
+	
+	//cvisitor << "Triangle---->" << direction.first << "=" << point[direction.first] << " " << scale << endl;
+	Polyline* poly = new Polyline();
+
+	poly->setThickness(2);
+	poly->setFillColour(Colour("Rgb(0.7, 0.7, 0.7)"));	
+		poly->setColour(Colour("Rgb(0.5, 0.5, 0.5)"));
+	
+	double length = point[direction.first];
+	
+	if ( length > 100) 
+		length = ((3 * length /100 ) + 6 )*3600;
+	else 
+		if ( length >  50 )
+			length = ((3 *length/50) + 3 ) *3600;
+		else
+			length = (6*length/50) *3600;
+	
+		
+
+	double x0 = length;
+
+	
+	double x = x0 * cos(direction.second);
+	double y = x0 * sin(direction.second);
+	double x1 = x0 * cos(direction.second - shift);
+	double y1 = x0 * sin(direction.second - shift);
+	double x2 = x0 * cos(direction.second + shift);
+	double y2 = x0 * sin(direction.second + shift);
+	
+	poly->push_back(PaperPoint(pos, 0));	
+	poly->push_back(PaperPoint(pos + x1, y1));
+	poly->push_back(PaperPoint(pos + x, y));
+	poly->push_back(PaperPoint(pos + x2, y2));
+	poly->push_back(PaperPoint(pos, 0));	
+	
+	poly->setFilled(true);
+	poly->setShading(new FillShadingProperties());
+	
+	Polyline* median = new Polyline();
+	median->setColour(Colour("black"));
+	median->setThickness(1);
+	median->push_back(PaperPoint(pos, 0));	
+	median->push_back(PaperPoint(pos+x, y));	
+	
+	
+	visitor.push_back(poly);
+	
+    
+}
+
+
+void EpsWind::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{ 
+	CustomisedPointsList points; 
+	std::set<string> request;
+
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	if (points.empty()) return;
+	
+
+	
+
+	
+	
+	DateTime base = points.front()->base();
+
+	
+    
+	
+	
+	map<string, float> directions;
+	if ( magCompare(convention_, "oceanographic" ) ) {
+		directions["east"] = 0 + 3.14;
+		directions["nord"] = 3.14 * 0.5 +3.14;
+		directions["nord_east"] = 3.14*0.25  +3.14;
+		directions["nord_west"] = 3.14*0.75 +3.14;
+		directions["south"] = 3.14*1.5 +3.14;
+		directions["south_east"] = 3.14*1.75 +3.14;
+		directions["south_west"] = 3.14*1.25 +3.14;
+		directions["west"] = 3.14 +3.14;
+	}
+	else {
+		directions["east"] = 0;
+		directions["nord"] = 3.14 * 0.5;
+		directions["nord_east"] = 3.14*0.25;
+		directions["nord_west"] = 3.14*0.75;
+		directions["south"] = 3.14*1.5;
+		directions["south_east"] = 3.14*1.75;
+		directions["south_west"] = 3.14*1.25;
+		directions["west"] = 3.14;
+	}
+	
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {		
+		double total = 0;
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction) {
+			
+			if ( (*point)->find(direction->first) == (*point)->end() ) {
+				vector<string> classification;
+				classification.push_back("one");
+				classification.push_back("two");
+				classification.push_back("three");
+				classification.push_back("four");
+				classification.push_back("five");
+				classification.push_back("six");
+				double val = 0;
+				for ( vector<string>::const_iterator key = classification.begin(); key != classification.end(); ++key) {
+					CustomisedPoint::const_iterator value = (*point)->find(direction->first + "_" + *key);
+					if ( value != (*point)->end() ) 
+						val += ( value->second == 9999.) ? 0 :  value->second;
+				}			
+				(**point)[direction->first] = val;
+				
+				
+			}
+			total += (**point)[direction->first];
+		}
+		(**point)["total"] = total;
+		
+		
+		//InteractiveSet* iset = new InteractiveSet();
+		//iset->addAction("onmouseover", new InteractiveMagnify(4));
+		vector<double> values;
+		double scale = 0;	
+	    
+		
+    
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction)
+			values.push_back((**point)[direction->first]);
+			
+		double ms = *std::max_element(values.begin(), values.end());
+		double x = (**point)["step"] + (**point)["shift"];
+	
+		
+			Polyline* grid = new Polyline();
+			grid->setColour(Colour("grey"));
+			grid->setThickness(2);
+			grid->setLineStyle(M_DOT);		
+			scale = 200;
+			double l100 = 12*3600;
+			for (float angle = 0; angle <= 2; angle+=0.1) 	
+				grid->push_back(PaperPoint(x +(l100 * cos(3.14*angle)) , l100 * sin(3.14*angle)));					
+			//iset->push_back(grid);
+			
+		
+		
+
+
+		visitor.push_back(grid);
+		
+		
+		
+	
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction)
+				triangle(*direction, **point, visitor, x, ms);
+		
+	}
+	
+
+}
+
+void EpsWave::visit(LegendVisitor& legend)
+{
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	vector<Colour> colours;
+	colours.push_back(Colour("greenish_blue"));
+	colours.push_back(Colour("yellow_green"));
+	colours.push_back(Colour("greenish_yellow"));
+	colours.push_back(Colour("orangish_yellow"));
+	colours.push_back(Colour("yellowish_orange"));
+	colours.push_back(Colour("reddish_orange"));
+	
+	WaveRoseEntry* wave = new WaveRoseEntry(colours);
+	wave->borderColour(Colour("grey"));		
+	wave->font(font);
+		
+	legend.add(wave);
+}
+
+void EpsWind::visit(LegendVisitor& legend)
+{
+	
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	
+       WindRoseEntry* wind = new WindRoseEntry(*colour_);
+		
+		
+		
+		
+		wind->borderColour(*border_colour_);		
+		wind->font(font);
+		
+		legend.add(wind);
+    
+}
+void EpsCloud::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{ 
+	CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	map<string, float> directions;
+	
+				directions["1"] = 3.14 * 3/8;
+				directions["2"] = 3.14 * 1/8;
+				directions["3"] =  -3.14*1/8;
+				directions["4"] = -3.14* 3/8;
+				directions["5"] = -3.14* 5/8;
+				directions["6"] = -3.14* 7/8.;
+				directions["7"] = -3.14 *9/8;
+				directions["8"] =-3.14 *11/8; ;
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {	
+
+		(**point)["total"] = 100;
+		double x = (**point)["step"] + (**point)["shift"];
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction)
+				triangle(*direction, **point, visitor, x);
+	
+	Polyline* grid = new Polyline();
+				grid->setColour(Colour("grey"));
+				grid->setThickness(2);
+				grid->setLineStyle(M_DOT);		
+			
+				double l100 = 12*3600;
+				for (float angle = 0; angle <= 2; angle+=0.1) 	
+					grid->push_back(PaperPoint(x +(l100 * cos(3.14*angle)) , l100 * sin(3.14*angle)));					
+			
+					visitor.push_back(grid);
+	}		
+			
+
+
+		
+}
+
+void EpsBar::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	CustomisedPointsList points;
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	map<string, float> directions;
+
+				directions["1"] = 1;
+				directions["2"] = 2;
+				directions["3"] = 3;
+				directions["4"] = 4;
+				directions["5"] = 5;
+				directions["6"] = 6;
+				directions["7"] = 7;
+				directions["8"] = 8;
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+
+		(**point)["total"] = 100;
+		double x = (**point)["step"] + (**point)["shift"];
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction) {
+			 Hsl hsl = colour_->hsl();
+			 float light = hsl.light_;
+			 hsl.light_ += (0.99 - light)*((100- (**point)[direction->first])/100);
+			 Polyline* poly = new Polyline();
+			 poly->setThickness(1);
+			 poly->setFillColour(Colour(hsl));
+			 poly->setColour(Colour(hsl));
+			 x = x*3600;
+			 double width = 3 * 3600;
+			 poly->push_back(PaperPoint(x-width, direction->second-1));
+			 poly->push_back(PaperPoint(x+width, direction->second-1));
+			 poly->push_back(PaperPoint(x+width, direction->second));
+			 poly->push_back(PaperPoint(x-width, direction->second));
+			 poly->push_back(PaperPoint(x-width, direction->second-1));
+			 visitor.push_back(poly);
+
+		}
+	}
+
+
+
+
+
+}
+
+void EpsBar::visit(LegendVisitor& legend)
+{
+
+	MagLog::dev() << " EpsBar::visit(LegendVisitor&) --> to be implemented! " << endl;
+}
+
+void EpsCloud::visit(LegendVisitor& legend)
+{
+	
+	MagFont font("sansserif", "normal", 0.25);
+	font.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+	
+       WindRoseEntry* wind = new WindRoseEntry(*colour_);
+		
+		
+		
+		
+		wind->borderColour(*border_colour_);		
+		wind->font(font);
+		
+		legend.add(wind);
+    
+}
+void EpsWind::print(ostream&) const
+{
+}
+void EpsCloud::print(ostream&) const
+{
+}
+void EpsBar::print(ostream&) const
+{
+}
+void EpsWave::print(ostream&) const
+{
+}
+
+void triangle5(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos, double max)
+{
+	
+	vector<Colour> colours;
+	colours.push_back(Colour("greenish_blue"));
+	colours.push_back(Colour("yellow_green"));
+	colours.push_back(Colour("greenish_yellow"));
+	colours.push_back(Colour("orangish_yellow"));
+	colours.push_back(Colour("yellowish_orange"));
+	colours.push_back(Colour("reddish_orange"));
+	
+	vector<string> forces;
+	forces.push_back(direction.first + "_one");
+	forces.push_back(direction.first + "_two");
+	forces.push_back(direction.first + "_three");
+	forces.push_back(direction.first + "_four");
+	forces.push_back(direction.first + "_five");
+	forces.push_back(direction.first + "_six");
+	double total = 0;
+	Polyline* poly;
+	vector<Colour>::iterator colour = colours.begin();
+	Colour border("grey");
+	
+	double r = 12*3600;
+	double factor = r*r/max;
+	
+	double previous = 0;
+	double shift = 3.14*0.125;
+	
+	for (vector<string>::const_iterator force = forces.begin(); force != forces.end(); ++ force) {
+		double count =  point[*force];
+		if ( !count ) {
+			colour++; 
+			continue;
+		}
+		
+	    poly = new Polyline();
+	    poly->setThickness(1);
+		poly->setFillColour(*colour);	
+	    poly->setColour(border);
+		
+		total += count;	    
+		double length =  sqrt(total*factor);
+		double x0 = length;
+		
+	
+		double x = x0 * cos(direction.second);
+		double y = x0 * sin(direction.second);
+		double x1 = x0 * cos(direction.second - shift);
+		double y1 = x0 * sin(direction.second - shift);
+		double x2 = x0 * cos(direction.second + shift);
+		double y2 = x0 * sin(direction.second + shift);
+	   
+	    double px = previous * cos(direction.second);
+		double py = previous * sin(direction.second);
+		double px1 = previous * cos(direction.second - shift);
+		double py1 = previous * sin(direction.second - shift);
+		double px2 = previous * cos(direction.second + shift);
+		double py2 = previous * sin(direction.second + shift);
+		
+		previous = x0;
+        colour++;
+	
+	    
+	
+		poly->push_back(PaperPoint(pos + px1 , py1 ));	
+		poly->push_back(PaperPoint(pos + x1,  y1));
+		poly->push_back(PaperPoint(pos + x,  y));
+		poly->push_back(PaperPoint(pos +  x2,  y2));
+		poly->push_back(PaperPoint(pos + px2, py2));
+		poly->push_back(PaperPoint(pos + px, py));	
+		poly->push_back(PaperPoint(pos + px1, py1));	
+	
+		poly->setFilled(true);
+		poly->setShading(new FillShadingProperties());
+	
+		visitor.push_back(poly);
+	}
+	
+	
+
+        
+	
+}
+
+void EpsWave::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{ 
+	CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	if (points.empty()) return;
+	
+
+	vector<double> xpos;
+	
+
+	
+	
+	DateTime base = points.front()->base();
+
+	 for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {  	
+		xpos.push_back((**point)["last"]);		  
+    }
+    
+	
+	
+	map<string, float> directions;
+	//if ( magCompare(convention_, "oceanographic" ) ) {
+		directions["east"] = 0 + 3.14;
+		directions["nord"] = 3.14 * 0.5 +3.14;
+		directions["nord_east"] = 3.14*0.25  +3.14;
+		directions["nord_west"] = 3.14*0.75 +3.14;
+		directions["south"] = 3.14*1.5 +3.14;
+		directions["south_east"] = 3.14*1.75 +3.14;
+		directions["south_west"] = 3.14*1.25 +3.14;
+		directions["west"] = 3.14 +3.14;
+//	}
+//	else {
+//		directions["east"] = 0;
+//		directions["nord"] = 3.14 * 0.5;
+//		directions["nord_east"] = 3.14*0.25;
+//		directions["nord_west"] = 3.14*0.75;
+//		directions["svisitorh"] = 3.14*1.5;
+//		directions["svisitorh_east"] = 3.14*1.75;
+//		directions["svisitorh_west"] = 3.14*1.25;
+//		directions["west"] = 3.14;
+//	}
+	
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {		
+		double total = 0;
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction) {
+			
+			if ( (*point)->find(direction->first) == (*point)->end() ) {
+				vector<string> classification;
+				classification.push_back("one");
+				classification.push_back("two");
+				classification.push_back("three");
+				classification.push_back("four");
+				classification.push_back("five");
+				classification.push_back("six");
+				double val = 0;
+				for ( vector<string>::const_iterator key = classification.begin(); key != classification.end(); ++key) {
+					CustomisedPoint::const_iterator value = (*point)->find(direction->first + "_" + *key);
+					if ( value != (*point)->end() ) 
+						val += (value->second == 9999) ? 0 : value->second;
+				}			
+				(**point)[direction->first] = val;
+				
+			}
+			total += (**point)[direction->first];
+		}
+		(**point)["total"] = (total) ? total : 50;
+		
+		
+		//InteractiveSet* iset = new InteractiveSet();
+		//iset->addAction("onmouseover", new InteractiveMagnify(4));
+		vector<double> values;
+		double scale = 0;	
+	    
+		
+    
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction)
+			values.push_back((**point)[direction->first]);
+			
+		double ms = *std::max_element(values.begin(), values.end());
+		double x = (**point)["step"] + (**point)["shift"];
+	
+		
+			Polyline* grid = new Polyline();
+			grid->setColour(Colour("grey"));
+			grid->setThickness(2);
+			grid->setLineStyle(M_DOT);		
+			scale = 200;
+			double l100 = 12*3600;
+			for (float angle = 0; angle <= 2; angle+=0.1) 	
+				grid->push_back(PaperPoint(x +(l100 * cos(3.14*angle)) , l100 * sin(3.14*angle)));					
+				visitor.push_back(grid);
+			
+	
+		
+
+		//visitor.push_back(iset);
+		
+		
+		if (total == 0) continue;
+	
+		for ( map<string, float>::const_iterator direction = directions.begin(); direction != directions.end(); ++direction)
+			{
+				triangle5(*direction, **point, visitor, x, ms);
+			}
+	}
+	
+
+}
+
+
+
+
+CdfGraph::CdfGraph() 
+{
+}
+
+CdfGraph::~CdfGraph()
+{
+}
+void CdfGraph::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+
+	
+	CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+	
+	//visitor << "CdfGraph::preparePlot(Data<PaperPoint>& data, visitor&)" << endl;
+	
+	if (points.empty()) return;
+	
+	vector<string>::iterator icolour = colour_.begin();
+    // First make sure that we have enough colour/style/thicknes
+    
+    while (style_.size() < colour_.size()) 
+        style_.push_back("solid");
+    while (thickness_.size() < colour_.size()) 
+        thickness_.push_back(2);    
+    
+	
+	
+    // First set some defaults!
+	
+
+
+
+    
+    	
+    	
+    	Polyline* efi  = new Polyline();
+	    efi->setColour(*clim_colour_);
+	    efi->setLineStyle(clim_style_);
+	    efi->setThickness(clim_thickness_);
+	    vector<double> clim;
+		for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {		
+			
+			vector<double> steps;
+			for ( int i = 0; i <=100; i++) {		    
+				ostringstream key;
+				key << "clim_" << i;
+				map<string, double>::const_iterator step = (*point)->find(key.str());
+				if (step != (*point)->end() ) {
+                    MagLog::dev() << key.str() << ":" << step->second << "-->" << i << endl;
+					efi->push_back(PaperPoint(step->second, i));
+					clim.push_back(step->second);
+                }
+			}			
+		
+		}
+		
+		visitor.push_back(efi);
+		
+
+		Polyline* box = new Polyline();
+		box->setColour(Colour("navy"));
+		box->setFilled(true);      
+		box->setFillColour(Colour("white"));      
+			
+		FillShadingProperties* shading = new FillShadingProperties();          
+
+		box->setShading(shading);
+		
+		double w = 1.5*( transformation.getMaxX() - transformation.getMinX() )/ visitor.absoluteWidth();
+		
+		box->push_back(PaperPoint(transformation.getMaxX(), 43));
+		box->push_back(PaperPoint(transformation.getMaxX()-w, 43));
+		box->push_back(PaperPoint(transformation.getMaxX()-w, 57));
+		box->push_back(PaperPoint(transformation.getMaxX(), 57));
+		box->push_back(PaperPoint(transformation.getMaxX(), 43));
+		
+		
+		
+		Text* mint = new Text();
+		mint->setJustification(MLEFT);		
+		mint->push_back(PaperPoint(transformation.getMaxX()-(w*.95), 46));
+		
+		Text* maxt = new Text();
+		maxt->push_back(PaperPoint(transformation.getMaxX()-(w*0.95), 52));
+		maxt->setJustification(MLEFT);
+		
+		if ( !clim.empty() ) {
+			vector<double>::const_iterator min = std::min_element(clim.begin(), clim.end());
+			vector<double>::const_iterator max = std::max_element(clim.begin(), clim.end());
+			maxt->addText("Max: " +  tostring(maground(*max)) , Colour("navy"), 0.3);
+			mint->addText("Min : " +  tostring(maground(*min)) , Colour("navy"), 0.3);
+		}
+		else {
+			maxt->addText("Max: ?" , Colour("navy"), 0.3);
+			mint->addText( "Min : ?", Colour("navy"), 0.3);
+		}
+        
+		
+	vector<string>::iterator style = style_.begin();
+	vector<int>::iterator thickness = thickness_.begin();
+   
+	vector<BasicGraphicsObject*> sorter;
+	int step = 1;
+    while ( icolour != colour_.end() ) {
+    	Colour colour(*icolour);
+      
+    	
+    
+    	
+    	Polyline* efi  = new Polyline();
+	    efi->setColour(colour);
+	    efi->setLineStyle(MagTranslator<string, LineStyle>()(*style));
+	    efi->setThickness(*thickness);
+	    ++thickness;
+        ++style;
+		for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {		
+			
+			vector<double> steps;
+			for ( int i = 0; i <=100; i++) {		    
+				ostringstream key;
+				key << step << "_" << i;
+				map<string, double>::const_iterator step = (*point)->find(key.str());
+				if (step != (*point)->end() ) {
+                    MagLog::dev() << key.str() << ":" << step->second << "-->" << i << endl;
+					efi->push_back(PaperPoint(step->second, i));
+                }
+			}	
+			ostringstream key;
+			key << step << "_step";
+			map<string, double>::const_iterator info = (*point)->find(key.str());
+			int s = info->second;
+			ostringstream legend;
+			legend << "Eps t+ [" << s - 24 << "-" << s <<"h] " ;
+			legend_.push_back(legend.str());
+			
+		}
+		
+		if ( !efi->empty() ) {		
+			sorter.push_back(efi);
+			usedColours_.push_back(*icolour);
+		}
+		else 
+			delete efi;
+		
+	
+		// go to next step!
+		    ++icolour;
+		    step++;
+		}
+    
+    // Here we revert the curve to have the fisrt plotted last! 
+        for ( vector<BasicGraphicsObject*>::reverse_iterator object = sorter.rbegin(); object != sorter.rend(); ++object) 
+        	visitor.push_back(*object);
+            
+//        visitor.push_back(box);
+//		visitor.push_back(mint);
+//		visitor.push_back(maxt);/
+
+}
+
+
+void CdfGraph::visit(LegendVisitor& legend)
+
+{
+
+	
+	vector<string>::reverse_iterator style = style_.rbegin();
+	vector<int>::reverse_iterator thickness = thickness_.rbegin();
+	vector<string>::reverse_iterator text = legend_.rbegin();
+    
+   
+	for (vector<string>::reverse_iterator colour = usedColours_.rbegin(); colour != usedColours_.rend(); ++colour) {
+		Polyline* efi  = new Polyline();
+		efi->setColour(Colour(*colour));
+		
+       
+        efi->setLineStyle(MagTranslator<string, LineStyle>()(*style));
+		efi->setThickness(*thickness);
+		LineEntry* entry = new LineEntry(*text, efi);
+
+		legend.add(entry);
+        ++thickness;
+        ++style;
+        ++text;
+	}
+	 Polyline* efi  = new Polyline();
+			efi->setColour(*clim_colour_);
+			efi->setLineStyle(clim_style_);
+			efi->setThickness(clim_thickness_);
+			LineEntry* entry = new LineEntry("Climate t+[24-48h]", efi);
+			
+			legend.add(entry);    
+
+}
+
+void EpsShade::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+	
+	if (points.empty()) return;
+
+    
+	Polyline* first  = new Polyline();	
+	first->setLineStyle(line_style_);
+	first->setThickness(line_thickness_);
+	first->setFilled(true);
+	first->setShading(new FillShadingProperties());
+    
+    Polyline* firstmin = first->getNew();
+    Polyline* firstmax = first->getNew();
+    
+    Colour cmin = Colour("sky");
+    Colour cmax = Colour("RGB(1.0, 0.222, 0.222)");
+    
+    Polyline* second  = new Polyline();
+	
+	second->setLineStyle(line_style_);
+	second->setThickness(line_thickness_);
+	second->setFilled(true);
+	second->setShading(new FillShadingProperties());
+	Polyline* secondmin = second->getNew();
+    Polyline* secondmax = second->getNew();
+    
+    
+	Polyline* median  = new Polyline();
+	median->setLineStyle(line_style_);
+	median->setThickness(line_thickness_);
+    
+    Polyline* medianmin = median->getNew();
+    Polyline* medianmax = median->getNew();
+   
+	Polyline* backtop  = new Polyline();
+	//backtop->setLineStyle(M_DASH);
+	backtop->setThickness(2);
+    backtop->setColour(*colour_);
+    Polyline* backtopmin = backtop->getNew();
+    Polyline* backtopmax = backtop->getNew();
+    backtopmin->setColour(cmin);
+    backtopmax->setColour(cmax);
+   
+    Polyline* backbottom  = new Polyline();
+	//backbottom->setLineStyle(M_DOT);
+	backbottom->setThickness(2);
+    backbottom->setColour(*colour_);
+    
+    Polyline* backbottommin = backbottom->getNew();
+    Polyline* backbottommax = backbottom->getNew();
+    
+    backbottommin->setColour(cmin);
+    backbottommax->setColour(cmax);
+    
+    Hsl hsl = colour_->hsl();  
+    Hsl hslmin = cmin.hsl(); 
+    Hsl hslmax = cmax.hsl(); 
+    
+    float step = (0.9 - hsl.light_)/3.;
+    median->setColour(Colour(hsl));
+    medianmin->setColour(Colour(hslmin));
+    medianmax->setColour(Colour(hslmax));
+    
+    hsl.light_ += 2*step;     
+    hslmin.light_ += 2*step; 
+    hslmax.light_ += 2*step; 
+    second->setFillColour(Colour(hsl));
+    second->setColour(Colour(hsl));
+    secondmin->setFillColour(Colour(hslmin));
+    secondmin->setColour(Colour(hslmin));
+    secondmax->setFillColour(Colour(hslmax));
+    secondmax->setColour(Colour(hslmax));
+    
+    hsl.light_ += step;
+    hslmin.light_ += step; 
+    hslmax.light_ += step; 
+    first->setFillColour(Colour(hsl));   
+    first->setColour(Colour(hsl));
+    firstmin->setFillColour(Colour(hslmin));   
+    firstmin->setColour(Colour(hslmin));
+    firstmax->setFillColour(Colour(hslmax));   
+    firstmax->setColour(Colour(hslmax));
+    
+	
+	
+		
+
+	DateTime base = points.front()->base();
+   
+    
+    
+    
+    
+	vector<PaperPoint> ten, tenmin, tenmax;
+	vector<PaperPoint> ninty, nintymin, nintymax;;
+	vector<PaperPoint> twentyfive, twentyfivemin, twentyfivemax;
+	vector<PaperPoint> seventyfive, seventyfivemin, seventyfivemax;
+    vector<PaperPoint> one, onemin, onemax;
+	vector<PaperPoint> ninetynine, ninetyninemin, ninetyninemax;
+    
+    
+    
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		
+		double x = (**point)["step"];
+		
+        
+		
+		CustomisedPoint::const_iterator y1 = (*point)->find("1");       
+		CustomisedPoint::const_iterator y10 = (*point)->find("10");
+        CustomisedPoint::const_iterator y90 = (*point)->find("90");
+        CustomisedPoint::const_iterator y99 = (*point)->find("99");  
+		CustomisedPoint::const_iterator y50 = (*point)->find("50");
+		CustomisedPoint::const_iterator y25 = (*point)->find("25");
+		CustomisedPoint::const_iterator y75 = (*point)->find("75");
+        if ( (**point)["tmin"] ) {		
+            tenmin.push_back(PaperPoint(x, y10->second));
+		    nintymin.push_back(PaperPoint(x, y90->second));
+		    twentyfivemin.push_back(PaperPoint(x, y25->second));
+		    seventyfivemin.push_back(PaperPoint(x, y75->second));
+		    medianmin->push_back(PaperPoint(x, y50->second));
+            onemin.push_back(PaperPoint(x, y1->second));
+            ninetyninemin.push_back(PaperPoint(x, y99->second));
+        }
+        else if ( (**point)["tmax"] ) {
+            tenmax.push_back(PaperPoint(x, y10->second));
+		    nintymax.push_back(PaperPoint(x, y90->second));
+		    twentyfivemax.push_back(PaperPoint(x, y25->second));
+		    seventyfivemax.push_back(PaperPoint(x, y75->second));
+		    medianmax->push_back(PaperPoint(x, y50->second));
+            onemax.push_back(PaperPoint(x, y1->second));
+            ninetyninemax.push_back(PaperPoint(x, y99->second));
+        }
+        else {
+            ten.push_back(PaperPoint(x, y10->second));
+		    ninty.push_back(PaperPoint(x, y90->second));
+		    twentyfive.push_back(PaperPoint(x, y25->second));
+		    seventyfive.push_back(PaperPoint(x, y75->second));
+		    median->push_back(PaperPoint(x, y50->second));
+            one.push_back(PaperPoint(x, y1->second));
+            ninetynine.push_back(PaperPoint(x, y99->second));
+        }
+     }
+        
+     
+	
+     for (vector<PaperPoint>::iterator point = one.begin(); point != one.end(); ++point) 
+     	backbottom->push_back(*point); 
+     for (vector<PaperPoint>::reverse_iterator point = ninetynine.rbegin(); point != ninetynine.rend(); ++point)
+     	backtop->push_back(*point);
+     for (vector<PaperPoint>::iterator point = ten.begin(); point != ten.end(); ++point)
+     	first->push_back(*point);
+     for (vector<PaperPoint>::reverse_iterator point = ninty.rbegin(); point != ninty.rend(); ++point)
+     	first->push_back(*point);     
+     if ( !first->empty() )
+        first->push_back(first->front());      
+	 for (vector<PaperPoint>::iterator point = twentyfive.begin(); point != twentyfive.end(); ++point)
+     	second->push_back(*point);
+     for (vector<PaperPoint>::reverse_iterator point = seventyfive.rbegin(); point != seventyfive.rend(); ++point)
+     	second->push_back(*point);     	
+     if ( !second->empty() )
+        second->push_back(second->front());
+     
+     for (vector<PaperPoint>::iterator point = onemin.begin(); point != onemin.end(); ++point) 
+     	backbottommin->push_back(*point); 
+     for (vector<PaperPoint>::reverse_iterator point = ninetyninemin.rbegin(); point != ninetyninemin.rend(); ++point)
+     	backtopmin->push_back(*point);
+     for (vector<PaperPoint>::iterator point = tenmin.begin(); point != tenmin.end(); ++point)
+     	firstmin->push_back(*point);
+     for (vector<PaperPoint>::reverse_iterator point = nintymin.rbegin(); point != nintymin.rend(); ++point)
+     	firstmin->push_back(*point);     
+     if ( !firstmin->empty() ) 
+        firstmin->push_back(firstmin->front());      
+	 for (vector<PaperPoint>::iterator point = twentyfivemin.begin(); point != twentyfivemin.end(); ++point)
+     	secondmin->push_back(*point);
+     for (vector<PaperPoint>::reverse_iterator point = seventyfivemin.rbegin(); point != seventyfivemin.rend(); ++point)
+     	secondmin->push_back(*point);     	
+     if ( !secondmin->empty() )
+        secondmin->push_back(secondmin->front());
+     
+     for (vector<PaperPoint>::iterator point = onemax.begin(); point != onemax.end(); ++point) 
+     	backbottommax->push_back(*point); 
+     for (vector<PaperPoint>::reverse_iterator point = ninetyninemax.rbegin(); point != ninetyninemax.rend(); ++point)
+     	backtopmax->push_back(*point);
+     for (vector<PaperPoint>::iterator point = tenmax.begin(); point != tenmax.end(); ++point)
+     	firstmax->push_back(*point);
+     for (vector<PaperPoint>::reverse_iterator point = nintymax.rbegin(); point != nintymax.rend(); ++point)
+     	firstmax->push_back(*point);     
+     if ( !firstmax->empty() ) 
+        firstmax->push_back(firstmax->front());      
+	 for (vector<PaperPoint>::iterator point = twentyfivemax.begin(); point != twentyfivemax.end(); ++point)
+     	secondmax->push_back(*point);
+     for (vector<PaperPoint>::reverse_iterator point = seventyfivemax.rbegin(); point != seventyfivemax.rend(); ++point)
+     	secondmax->push_back(*point);     	
+     if ( !secondmax->empty() ) 
+        secondmax->push_back(secondmax->front());
+     
+   
+   
+    if ( !first->empty() ) visitor.push_back(first);
+	if ( !second->empty() ) visitor.push_back(second);
+	
+    if ( !firstmin->empty() ) visitor.push_back(firstmin);
+	if ( !secondmin->empty() ) visitor.push_back(secondmin);
+    
+	
+    if ( !firstmax->empty() ) visitor.push_back(firstmax);
+	if ( !secondmax->empty() ) visitor.push_back(secondmax);
+    
+	if ( !median->empty() ) visitor.push_back(median);
+    if ( !medianmin->empty() ) visitor.push_back(medianmin);
+    if ( !medianmax->empty() ) visitor.push_back(medianmax);
+    
+    if ( !backbottom->empty() ) visitor.push_back(backbottom);
+    if ( !backtop->empty() ) visitor.push_back(backtop);
+    if ( !backbottommin->empty() ) visitor.push_back(backbottommin);
+    if ( !backtopmin->empty() ) visitor.push_back(backtopmin);
+    if ( !backbottommax->empty() ) visitor.push_back(backbottommax);
+    if ( !backtopmax->empty() ) visitor.push_back(backtopmax);
+    
+	
+}
+class EpsShadeEntry : public LegendEntry
+{
+public:
+	EpsShadeEntry() : LegendEntry(" ")
+	{
+		
+	}
+		
+	void set(const PaperPoint& point, BasicGraphicsObjectContainer& visitor)
+	{
+        if (!first_) return;
+		
+        first_ = false;
+        double x = point.x();
+		double y = point.y();
+        
+      
+        double height1=0.6;
+        double height2=0.4;
+        double height3=0.2;
+        double width = 0.4;
+        double xtext= x+0.7;
+        
+        
+		
+	
+		
+        Colour colour("grey");
+        Polyline* median  = new Polyline();
+		median->setColour(colour);		
+		median->setLineStyle(M_SOLID);
+		median->setThickness(4);
+		median->push_back(PaperPoint(x-width, y));
+		median->push_back(PaperPoint(x+width, y));
+        
+        Polyline* top  = new Polyline();
+		top->setColour(colour);		
+		top->setLineStyle(M_DASH);
+		top->setThickness(2);
+		top->push_back(PaperPoint(x-width, y+height1));
+		top->push_back(PaperPoint(x+width, y+height1));
+        
+        Polyline* bottom  = new Polyline();
+		bottom->setColour(colour);		
+		bottom->setLineStyle(M_DASH);
+		bottom->setThickness(2);
+        bottom->push_back(PaperPoint(x-width, y-height1));
+		bottom->push_back(PaperPoint(x+width, y-height1));
+        
+        Hsl hsl = colour.hsl();
+        float step = (0.9 - hsl.light_)/3.;
+        
+       
+        hsl.light_ += 2*step;
+        
+        Polyline* second  = new Polyline();       
+	    second->setFilled(true);
+	    second->setShading(new FillShadingProperties());
+        second->setFillColour(Colour(hsl));
+        second->setColour(Colour(hsl));
+        second->push_back(PaperPoint(x-width, y-height3));
+		second->push_back(PaperPoint(x+width, y-height3));
+        second->push_back(PaperPoint(x+width, y+height3));
+		second->push_back(PaperPoint(x-width, y+height3));
+        
+        hsl.light_ += step;
+        
+        Polyline* first  = new Polyline();       
+	    first->setFilled(true);
+	    first->setShading(new FillShadingProperties());
+        first->setFillColour(Colour(hsl));
+        first->setColour(Colour(hsl));
+        first->push_back(PaperPoint(x-width, y-height2));
+		first->push_back(PaperPoint(x+width, y-height2));
+        first->push_back(PaperPoint(x+width, y+height2));
+		first->push_back(PaperPoint(x-width, y+height2));
+        
+    
+    
+	
+	   
+   
+	
+		
+        visitor.push_back(first);
+        visitor.push_back(second);
+        
+		visitor.push_back(top);
+        visitor.push_back(bottom);
+		visitor.push_back(median);
+        
+        Text* text  = new Text();
+		text->setText("M-Climate");
+        text->setFont(font_);
+		
+		text->push_back(PaperPoint(x+0.4, y-0.8));
+		visitor.push_back(text);
+        
+        Text* text99  = new Text();
+		text99->setText("99%");
+		text99->setFont(font_);
+		text99->setJustification(MLEFT);
+		text99->push_back(PaperPoint(xtext, y-height1));
+		visitor.push_back(text99);  
+        
+        Text* text90  = new Text();
+		text90->setText("90%");
+		text90->setFont(font_);
+		text90->setJustification(MLEFT);
+		text90->push_back(PaperPoint(xtext, y-height2));
+		visitor.push_back(text90);
+        
+        Text* text75  = new Text();
+		text75->setText("75%");
+		text75->setFont(font_);
+		text75->setJustification(MLEFT);
+		text75->push_back(PaperPoint(xtext, y-height3));
+		visitor.push_back(text75);
+        
+		Text* text50  = new Text();
+		text50->setText("median");
+		text50->setFont(font_);
+		text50->setJustification(MLEFT);
+		text50->push_back(PaperPoint(xtext, y));
+		visitor.push_back(text50);
+        
+        Text* text25  = new Text();
+		text25->setText("25%");
+		text25->setFont(font_);
+		
+		text25->setJustification(MLEFT);
+		text25->push_back(PaperPoint(xtext, y+height3));
+		visitor.push_back(text25);
+        
+        Text* text10  = new Text();
+		text10->setText("10%");
+		text10->setFont(font_);
+	
+		text10->setJustification(MLEFT);
+		text10->push_back(PaperPoint(xtext, y+height2));
+		visitor.push_back(text10);
+        
+        Text* text1  = new Text();
+		text1->setText("1%");
+        text1->setFont(font_);
+	
+		text1->setJustification(MLEFT);
+		text1->push_back(PaperPoint(xtext, y+height1));
+		visitor.push_back(text1);
+      
+	}
+    
+    MagFont font_;
+	
+protected:
+	static bool first_;
+};
+
+bool EpsShadeEntry::first_ = true;
+
+void EpsShade::visit(LegendVisitor& legend)
+{
+    EpsShadeEntry *entry = new EpsShadeEntry();
+    entry->font_ = MagFont("sansserif");
+    entry->font_.size(0.25);
+    entry->font_.colour(Colour("Rgb(0.2, 0.2, 0.2)"));
+    legend.add(entry);
+}
+
+EpsShade::EpsShade()
+{
+}
+
+EpsShade::~EpsShade()
+{
+}
+
+bool alldigit(const string& name)
+{
+	for (string::const_iterator c = name.begin(); c != name.end(); ++c)
+		if ( !isdigit(*c) ) return false;
+	return true;
+} 
+
+void EpsDirection::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+    CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	if (points.empty()) return;
+		
+
+	DateTime base = points.front()->base();
+	
+	
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {		
+	
+        
+		
+		
+		
+		//InteractiveSet* iset = new InteractiveSet();
+		//iset->addAction("onmouseover", new InteractiveMagnify(4));
+			
+			
+		
+		    double x = (**point)["step"] + (**point)["shift"];
+		    
+		    if ( (**point)[keyword_] == 9999 ) continue;
+		    
+	        double angle = ((2*3.14) - (((**point)[keyword_]-90)/180) * 3.14) + 3.14;
+		
+			Polyline* grid = new Polyline();
+			grid->setColour(*line_colour_);
+			grid->setThickness(line_thickness_);
+			grid->setLineStyle(line_style_);		
+			
+			double l100 = 12*3600;
+            grid->push_back(PaperPoint(x +(l100 * cos(angle)) , l100 * sin(angle)));	
+            
+            grid->push_back(PaperPoint(x, 0));	
+			
+            			
+			visitor.push_back(grid); //iset->push_back(grid);
+			
+		
+		
+
+		
+
+		//visitor.push_back(iset);
+		
+		
+		
+		
+	}
+	
+}
+void EpsWind::triangle(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos, double max)
+{
+    
+    Hsl hsl = colour_->hsl();
+    
+    float light = hsl.light_;
+   
+    hsl.light_ += (0.99 - light)*((point["total"]- point[direction.first])/point["total"]);
+     
+	
+	double shift = 3.14*0.125;
+	
+	Polyline* poly = new Polyline();
+	poly->setThickness(1);
+	
+	
+	poly->setFillColour(Colour(hsl));	
+	poly->setColour(*border_colour_);
+	
+	double r = 12*3600;
+	double val = point[direction.first];
+	double factor = r*r/max;
+	
+	
+	
+	double length =  sqrt(val*factor);
+	double x0 = length;
+//	double y0 = 0;
+//	double a = length *tan(shift);
+//	double b = length *tan(-shift);
+	
+	double x = x0 * cos(direction.second);
+	double y = x0 * sin(direction.second);
+	double x1 = x0 * cos(direction.second - shift);
+	double y1 = x0 * sin(direction.second - shift);
+	double x2 = x0 * cos(direction.second + shift);
+	double y2 = x0 * sin(direction.second + shift);
+	
+	double xs = 0;
+	double ys = 0;
+	
+	
+	poly->push_back(PaperPoint(pos + xs , ys ));	
+	poly->push_back(PaperPoint(pos + xs + x1, ys + y1));
+	poly->push_back(PaperPoint(pos + xs + x, ys + y));
+	poly->push_back(PaperPoint(pos + xs + x2, ys + y2));
+	poly->push_back(PaperPoint(pos + xs, ys));	
+	
+	poly->setFilled(true);
+	poly->setShading(new FillShadingProperties());
+	
+	visitor.push_back(poly);
+
+
+   
+}
+EpsPlume::EpsPlume()
+{
+	methods_["time_serie"] = &EpsPlume::timeserie;
+	methods_["vertical_profile"] = &EpsPlume::verticalprofile;
+}
+
+void EpsPlume::visit(LegendVisitor& legend)
+{
+	Polyline* forecast  = new Polyline();
+	forecast->setColour(*forecast_line_colour_);
+	forecast->setThickness(forecast_line_thickness_);
+	forecast->setLineStyle(forecast_line_style_);
+	legend.add(new LineEntry("Oper", forecast));
+
+	Polyline* control  = new Polyline();
+	control->setColour(*control_line_colour_);
+	control->setThickness(control_line_thickness_);
+	control->setLineStyle(control_line_style_);
+	legend.add(new LineEntry("Ctrl", control));
+
+
+	Polyline* line  = new Polyline();
+	line->setColour(*line_colour_);
+	line->setThickness(line_thickness_);
+	line->setLineStyle(line_style_);
+	legend.add(new LineEntry("EMem", line));
+}
+
+void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+
+	if (points.empty()) return;
+
+
+
+	map<string, Polyline* > lines;
+	Polyline* control  = new Polyline();
+	control->setColour(*control_line_colour_);
+	control->setThickness(control_line_thickness_);
+	control->setLineStyle(control_line_style_);
+
+	Polyline* forecast  = new Polyline();
+	forecast->setColour(*forecast_line_colour_);
+	forecast->setThickness(forecast_line_thickness_);
+	forecast->setLineStyle(forecast_line_style_);
+
+
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+
+		double x = (**point)["step"] + (**point)["shift"];
+
+
+
+		for ( map<string, double>::const_iterator value = (*point)->begin(); value != (*point)->end(); ++value) {
+			if ( alldigit(value->first) ) {
+				map<string, Polyline* >::iterator  iline = lines.find(value->first);
+				if ( iline == lines.end() ) {
+					Polyline* line  = new Polyline();
+					line->setColour(*line_colour_);
+					line->setThickness(line_thickness_);
+					line->setLineStyle(line_style_);
+					lines[value->first] = line;
+					iline = lines.find(value->first);
+				}
+				(iline->second)->push_back(PaperPoint(x, value->second));
+
+			}
+
+			if ( value->first == "forecast" )
+				forecast->push_back(PaperPoint(x, value->second));
+			if ( value->first == "control" )
+				control->push_back(PaperPoint(x, value->second));
+
+		}
+
+
+
+	}
+
+	for ( map<string, Polyline* >::const_iterator line = lines.begin(); line != lines.end(); ++line) {
+		visitor.push_back(line->second);
+	}
+	visitor.push_back(control);
+	visitor.push_back(forecast);
+}
+
+void EpsPlume::verticalprofile(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	CustomisedPointsList points;
+	std::set<string> request;
+	const Transformation& transformation = visitor.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+
+	if (points.empty()) return;
+
+
+
+	map<string, Polyline* > lines;
+	Polyline* control  = new Polyline();
+	control->setColour(*control_line_colour_);
+	control->setThickness(control_line_thickness_);
+	control->setLineStyle(control_line_style_);
+
+	Polyline* forecast  = new Polyline();
+	forecast->setColour(*forecast_line_colour_);
+	forecast->setThickness(forecast_line_thickness_);
+	forecast->setLineStyle(forecast_line_style_);
+
+
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		double y = (**point)["y"];
+		for ( map<string, double>::const_iterator value = (*point)->begin(); value != (*point)->end(); ++value) {
+			if ( value->second == (**point)["missing"] )
+				continue;
+			if ( alldigit(value->first) ) {
+				map<string, Polyline* >::iterator  iline = lines.find(value->first);
+				if ( iline == lines.end() ) {
+					Polyline* line  = new Polyline();
+					line->setColour(*line_colour_);
+					line->setThickness(line_thickness_);
+					line->setLineStyle(line_style_);
+					lines[value->first] = line;
+					iline = lines.find(value->first);
+				}
+				(iline->second)->push_back(transformation(UserPoint(value->second, y)));
+			}
+
+			if ( value->first == "forecast" )
+				forecast->push_back(transformation(UserPoint(value->second, y)));
+			if ( value->first == "control" )
+				control->push_back(transformation(UserPoint(value->second, y)));
+		}
+	}
+
+	for ( map<string, Polyline* >::const_iterator line = lines.begin(); line != lines.end(); ++line) {
+		visitor.push_back(line->second);
+	}
+	visitor.push_back(control);
+	visitor.push_back(forecast);
+}
+void EpsPlume::operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+{
+	method_ = lowerCase(method_);
+	std::map<string, Method>::iterator method = methods_.find(method_);
+	if ( method == methods_.end() ) {
+		MagLog::warning() << "Could not find method [" << method_ << "] for plotting : no plot could be done." << endl;
+		return;
+	}
+	(this->*method->second)(data, visitor);
+	
+	
+}    
+       
+
+EfiGraph::EfiGraph() {}
+EfiGraph::~EfiGraph() {}
+    
+    
+    
+void EfiGraph::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	CustomisedPointsList points;
+	std::set<string> request;
+	const Transformation& transformation = out.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+
+	vector<string>::iterator colour = box_colour_.begin();
+
+
+	Polyline* ref  = new Polyline();
+	ref->setColour(*normal_colour_);
+	ref->setThickness(normal_thickness_);
+	ref->setLineStyle(normal_style_);
+	ref->push_back(PaperPoint(0, 1));
+	MagFont font(font_, font_style_, font_size_);
+	font.colour(*font_colour_);
+
+	out.push_back(ref);
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+
+		ref->push_back(PaperPoint(0, (**point)["steps"]+1));
+		for (int i = 1; i <= (**point)["steps"]; i++) {
+			ostringstream key;
+			key << "efi" << i << "_value";
+			ostringstream step;
+			step << "efi" << i << "_step";
+			bool available = ((*point)->find(step.str()) != (*point)->end());
+
+			int s = (**point)[step.str()];
+			ostringstream legend;
+			legend << "Eps t+ [" << s - 36 << "-" << s - 12 <<"h] " ;
+
+			Polyline* box  = new Polyline();
+			box->setColour(*border_colour_);
+			box->setThickness(border_thickness_);
+			box->setLineStyle(border_style_);
+			box->setFilled(true);
+			box->setShading(new FillShadingProperties());
+			box->setFillColour(*colour);
+			++colour;
+			double val = (**point)[key.str()];
+			box->push_back(PaperPoint(0, i ));
+			box->push_back(PaperPoint(val, i ));
+			box->push_back(PaperPoint(val, i +1));
+			box->push_back(PaperPoint(0, i +1));
+			box->push_back(PaperPoint(0, i ));
+			out.push_back(box);
+			if ( available ) {
+				Text* text  = new Text();
+				text->setText(legend.str());
+				text->setJustification(MRIGHT);
+				text->setFont(font);
+				text->push_back(PaperPoint(-101 , i+0.5));
+				out.push_back(text);
+				Text* value  = new Text();
+				value->setText(tostring(maground(val))+"%");
+				value->setJustification(MLEFT);
+				value->setFont(font);
+				value->push_back(PaperPoint(101 , i+0.5));
+				out.push_back(value);
+			}
+		}
+	}
+	Text* text  = new Text();
+	text->setText("-100%");
+	text->setJustification(MCENTRE);
+	text->setFont(font);
+	text->push_back(PaperPoint(-100 , 0.5));
+	out.push_back(text);
+	text  = new Text();
+	text->setText("-50%");
+	text->setJustification(MCENTRE);
+	text->setFont(font);
+	text->push_back(PaperPoint(-50 , 0.5));
+	out.push_back(text);
+	text  = new Text();
+	text->setText("EFI");
+	text->setJustification(MCENTRE);
+	text->setFont(font);
+	text->push_back(PaperPoint(0 , 0.5));
+	out.push_back(text);
+	text  = new Text();
+	text->setText("50%");
+	text->setJustification(MCENTRE);
+	text->setFont(font);
+	text->push_back(PaperPoint(50 , 0.5));
+	out.push_back(text);
+	text  = new Text();
+	text->setText("100%");
+	text->setJustification(MCENTRE);
+	text->setFont(font);
+	text->push_back(PaperPoint(100 , 0.5));
+	out.push_back(text);
+}
+void EfiGraph::visit(LegendVisitor&)
+{
+}
+
+	
+
+	
diff --git a/src/visualisers/EpsGraph.h b/src/visualisers/EpsGraph.h
new file mode 100644
index 0000000..f5d567e
--- /dev/null
+++ b/src/visualisers/EpsGraph.h
@@ -0,0 +1,413 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsGraph.h
+    \brief Definition of the Template class EpsGraph.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef EpsGraph_H
+#define EpsGraph_H
+
+#include "magics.h"
+
+
+#include "EpsGraphAttributes.h"
+#include "EfiGraphAttributes.h"
+#include "CdfGraphAttributes.h"
+#include "EpsShadeAttributes.h"
+#include "EpsPlumeAttributes.h"
+#include "EpsWindAttributes.h"
+#include "EpsCloudAttributes.h"
+#include "EpsDirectionAttributes.h"
+
+#include "magics.h" 
+#include "Polyline.h"
+#include "Visdef.h"
+#include "BasicGraphicsObject.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+class EpsGraph: public EpsGraphAttributes, public Visdef {
+
+
+
+public:
+	EpsGraph();
+	virtual ~EpsGraph();
+    
+   
+    
+   virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { EpsGraphAttributes::set(map); }
+    void set(const XmlNode& node) { EpsGraphAttributes::set(node); }
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 double resolution_;
+	 bool   forecast_;
+	 bool   control_;
+	 bool   fullEps_;
+ 	 bool   eps_;
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsGraph(const EpsGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsGraph& operator=(const EpsGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsGraph& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsWind: public Visdef, public EpsWindAttributes {
+
+
+
+public:
+	EpsWind() {}
+	virtual ~EpsWind() {}
+     // Implements the set method ... 
+    void set(const map<string, string>& map ) { EpsWindAttributes::set(map); }
+    void set(const XmlNode& node) { EpsWindAttributes::set(node); }
+   
+    
+   virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+    
+    
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void triangle(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos, double max);
+
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsWind(const EpsGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsWind& operator=(const EpsGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsWind& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsCloud: public Visdef, public EpsCloudAttributes {
+
+
+
+public:
+	EpsCloud() {}
+	virtual ~EpsCloud() {}
+     // Implements the set method ... 
+    void set(const map<string, string>& map ) { EpsCloudAttributes::set(map); }
+    void set(const XmlNode& node) { EpsCloudAttributes::set(node); }
+   
+    
+   virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+    
+    
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void triangle(const pair<string, float>& direction, CustomisedPoint& point, BasicGraphicsObjectContainer& visitor, double pos);
+
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsCloud(const EpsGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsCloud& operator=(const EpsGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsCloud& p)
+		{ p.print(s); return s; }
+
+};
+class EpsBar: public Visdef, public EpsCloudAttributes {
+
+
+
+public:
+	EpsBar() {}
+	virtual ~EpsBar() {}
+     // Implements the set method ...
+    void set(const map<string, string>& map ) { EpsCloudAttributes::set(map); }
+    void set(const XmlNode& node) { EpsCloudAttributes::set(node); }
+
+
+   virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+
+
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const;
+
+
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsBar(const EpsGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsBar& operator=(const EpsGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsBar& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsWave: public Visdef {
+
+public:
+	EpsWave() {}
+	virtual ~EpsWave() {}
+	// Implements the set method ... 
+	void set(const map<string, string>&  ) { } // EpsWindAttributes::set(map); }
+	void set(const XmlNode& ) { } // EpsWindAttributes::set(node); }
+
+	virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsWave(const EpsWave&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsWave& operator=(const EpsWave&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsWave& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class EfiGraph: public Visdef, public EfiGraphAttributes {
+
+
+
+public:
+	EfiGraph();
+	virtual ~EfiGraph();
+    
+    void set(const XmlNode& node)            { EfiGraphAttributes::set(node); }
+    void set(const map<string, string>& map) { EfiGraphAttributes::set(map); }
+    
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const { /*EfiGraphAttributes::print(out);*/ }	 
+	
+	
+private:
+    //! Copy constructor - No copy allowed
+	EfiGraph(const EfiGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	EfiGraph& operator=(const EfiGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EfiGraph& p)
+		{ p.print(s); return s; }
+
+};
+
+class CdfGraph: public Visdef, public CdfGraphAttributes {
+
+
+
+public:
+	CdfGraph();
+	virtual ~CdfGraph();
+    
+    void set(const XmlNode& node)            { CdfGraphAttributes::set(node); }
+    void set(const map<string, string>& map) { CdfGraphAttributes::set(map); }
+    
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const { /*EfiGraphAttributes::print(out);*/ }	 
+	 vector<string> legend_;
+	 vector<string> usedColours_;
+	
+private:
+    //! Copy constructor - No copy allowed
+    CdfGraph(const CdfGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	CdfGraph& operator=(const CdfGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const CdfGraph& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsShade: public Visdef, public EpsShadeAttributes {
+
+
+public:
+	EpsShade();
+	virtual ~EpsShade();
+    
+    void set(const XmlNode& node)            { EpsShadeAttributes::set(node); }
+    void set(const map<string, string>& map) { EpsShadeAttributes::set(map); }
+    
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	virtual void visit(LegendVisitor&);
+    
+      
+    
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const { /*EfiGraphAttributes::print(out);*/ }
+	 
+	
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsShade(const EpsShade&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsShade& operator=(const EpsShade&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsShade& p)
+		{ p.print(s); return s; }
+
+};
+
+class EpsDirection: public Visdef, public EpsDirectionAttributes {
+
+
+public:
+	EpsDirection() {}
+	virtual ~EpsDirection() {}
+    
+    void set(const XmlNode& node)            { EpsDirectionAttributes::set(node); }
+    void set(const map<string, string>& map) { EpsDirectionAttributes::set(map); }
+    
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	
+    
+      
+    
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { EpsDirectionAttributes::print(out); }
+	 
+	
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsDirection(const EpsDirection&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsDirection& operator=(const EpsDirection&);
+
+
+};
+
+class EpsPlume: public Visdef, public EpsPlumeAttributes {
+
+
+public:
+	EpsPlume();
+	virtual ~EpsPlume() {}
+    
+    void set(const XmlNode& node)            { EpsPlumeAttributes::set(node); }
+    void set(const map<string, string>& map) { EpsPlumeAttributes::set(map); }
+    
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	void visit(LegendVisitor&);
+    
+
+    
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { EpsPlumeAttributes::print(out); }
+	 typedef void (EpsPlume::*Method)(Data&, BasicGraphicsObjectContainer&);
+
+	 std::map<string, Method> methods_;
+	
+	 void timeserie(Data&, BasicGraphicsObjectContainer&);
+	 void verticalprofile(Data&, BasicGraphicsObjectContainer&);
+
+private:
+    //! Copy constructor - No copy allowed
+	EpsPlume(const EpsPlume&);
+    //! Overloaded << operator to copy - No copy allowed
+	EpsShade& operator=(const EpsPlume&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EpsPlume& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/EpsGraphAttributes.cc b/src/visualisers/EpsGraphAttributes.cc
new file mode 100644
index 0000000..ac382d1
--- /dev/null
+++ b/src/visualisers/EpsGraphAttributes.cc
@@ -0,0 +1,312 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file EpsGraphAttributes.cc
+    \brief Implementation of EpsGraph Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "EpsGraphAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+EpsGraphAttributes::EpsGraphAttributes():
+	font_(ParameterManager::getString("eps_font")),
+	font_size_(ParameterManager::getDouble("eps_font_size")),
+	font_style_(ParameterManager::getString("eps_font_style")),
+	font_colour_(MagTranslator<string, Colour>().magics("eps_font_colour")),
+	colour_(MagTranslator<string, Colour>().magics("eps_box_colour")),
+	box_shift_(ParameterManager::getInt("eps_box_shift")),
+	right_colour_(MagTranslator<string, Colour>().magics("eps_right_box_colour")),
+	left_colour_(MagTranslator<string, Colour>().magics("eps_left_box_colour")),
+	border_colour_(MagTranslator<string, Colour>().magics("eps_box_border_colour")),
+	border_thickness_(ParameterManager::getInt("eps_box_border_thickness")),
+	median_thickness_(ParameterManager::getInt("eps_box_median_thickness")),
+	median_colour_(MagTranslator<string, Colour>().magics("eps_box_median_colour")),
+	max_(ParameterManager::getDouble("eps_maximum")),
+	max_font_name_(ParameterManager::getString("eps_maximum_font_name")),
+	max_font_style_(ParameterManager::getString("eps_maximum_font_style")),
+	max_font_size_(ParameterManager::getDouble("eps_maximum_font_size")),
+	max_font_colour_(MagTranslator<string, Colour>().magics("eps_maximum_font_colour")),
+	box_width_(ParameterManager::getDouble("eps_box_width")),
+	whisker_(ParameterManager::getBool("eps_whisker")),
+	legend_resolution_(ParameterManager::getString("eps_legend_resolution")),
+	legend_control_text_(ParameterManager::getString("eps_legend_control_text")),
+	legend_forecast_text_(ParameterManager::getString("eps_legend_forecast_text")),
+	deterministic_(ParameterManager::getBool("eps_deterministic")),
+	deterministic_colour_(MagTranslator<string, Colour>().magics("eps_deterministic_line_colour")),
+	deterministic_style_(MagTranslator<string, LineStyle>().magics("eps_deterministic_line_style")),
+	deterministic_thickness_(ParameterManager::getInt("eps_deterministic_line_thickness")),
+	control_(ParameterManager::getBool("eps_control")),
+	control_colour_(MagTranslator<string, Colour>().magics("eps_control_line_colour")),
+	control_style_(MagTranslator<string, LineStyle>().magics("eps_control_line_style")),
+	control_thickness_(ParameterManager::getInt("eps_control_line_thickness")),
+	legend_(ParameterManager::getBool("legend"))
+{
+} 
+
+
+
+EpsGraphAttributes::~EpsGraphAttributes()
+{
+}
+
+    
+void EpsGraphAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "eps";
+
+	setAttribute(prefix, "eps_font", font_, params);
+	setAttribute(prefix, "eps_font_size", font_size_, params);
+	setAttribute(prefix, "eps_font_style", font_style_, params);
+	setAttribute(prefix, "eps_font_colour", font_colour_, params);
+	setAttribute(prefix, "eps_box_colour", colour_, params);
+	setAttribute(prefix, "eps_box_shift", box_shift_, params);
+	setAttribute(prefix, "eps_right_box_colour", right_colour_, params);
+	setAttribute(prefix, "eps_left_box_colour", left_colour_, params);
+	setAttribute(prefix, "eps_box_border_colour", border_colour_, params);
+	setAttribute(prefix, "eps_box_border_thickness", border_thickness_, params);
+	setAttribute(prefix, "eps_box_median_thickness", median_thickness_, params);
+	setAttribute(prefix, "eps_box_median_colour", median_colour_, params);
+	setAttribute(prefix, "eps_maximum", max_, params);
+	setAttribute(prefix, "eps_maximum_font_name", max_font_name_, params);
+	setAttribute(prefix, "eps_maximum_font_style", max_font_style_, params);
+	setAttribute(prefix, "eps_maximum_font_size", max_font_size_, params);
+	setAttribute(prefix, "eps_maximum_font_colour", max_font_colour_, params);
+	setAttribute(prefix, "eps_box_width", box_width_, params);
+	setAttribute(prefix, "eps_whisker", whisker_, params);
+	setAttribute(prefix, "eps_legend_resolution", legend_resolution_, params);
+	setAttribute(prefix, "eps_legend_control_text", legend_control_text_, params);
+	setAttribute(prefix, "eps_legend_forecast_text", legend_forecast_text_, params);
+	setAttribute(prefix, "eps_deterministic", deterministic_, params);
+	setAttribute(prefix, "eps_deterministic_line_colour", deterministic_colour_, params);
+	setAttribute(prefix, "eps_deterministic_line_style", deterministic_style_, params);
+	setAttribute(prefix, "eps_deterministic_line_thickness", deterministic_thickness_, params);
+	setAttribute(prefix, "eps_control", control_, params);
+	setAttribute(prefix, "eps_control_line_colour", control_colour_, params);
+	setAttribute(prefix, "eps_control_line_style", control_style_, params);
+	setAttribute(prefix, "eps_control_line_thickness", control_thickness_, params);
+	setAttribute(prefix, "legend", legend_, params);
+}
+
+void EpsGraphAttributes::copy(const EpsGraphAttributes& other)
+{
+	font_ = other.font_;
+	font_size_ = other.font_size_;
+	font_style_ = other.font_style_;
+	font_colour_ = auto_ptr<Colour>(other.font_colour_->clone());
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	box_shift_ = other.box_shift_;
+	right_colour_ = auto_ptr<Colour>(other.right_colour_->clone());
+	left_colour_ = auto_ptr<Colour>(other.left_colour_->clone());
+	border_colour_ = auto_ptr<Colour>(other.border_colour_->clone());
+	border_thickness_ = other.border_thickness_;
+	median_thickness_ = other.median_thickness_;
+	median_colour_ = auto_ptr<Colour>(other.median_colour_->clone());
+	max_ = other.max_;
+	max_font_name_ = other.max_font_name_;
+	max_font_style_ = other.max_font_style_;
+	max_font_size_ = other.max_font_size_;
+	max_font_colour_ = auto_ptr<Colour>(other.max_font_colour_->clone());
+	box_width_ = other.box_width_;
+	whisker_ = other.whisker_;
+	legend_resolution_ = other.legend_resolution_;
+	legend_control_text_ = other.legend_control_text_;
+	legend_forecast_text_ = other.legend_forecast_text_;
+	deterministic_ = other.deterministic_;
+	deterministic_colour_ = auto_ptr<Colour>(other.deterministic_colour_->clone());
+	deterministic_style_ = other.deterministic_style_;
+	deterministic_thickness_ = other.deterministic_thickness_;
+	control_ = other.control_;
+	control_colour_ = auto_ptr<Colour>(other.control_colour_->clone());
+	control_style_ = other.control_style_;
+	control_thickness_ = other.control_thickness_;
+	legend_ = other.legend_;
+} 
+
+
+bool EpsGraphAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "epsgraph")  )
+		return true;
+	return false;
+}
+
+void EpsGraphAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "epsgraph") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void EpsGraphAttributes::print(ostream& out)  const
+{
+	out << "EpsGraphAttributes[";
+	out << "font = " << font_;
+	out << ", font_size = " << font_size_;
+	out << ", font_style = " << font_style_;
+	out << ", font_colour = " << *font_colour_;
+	out << ", colour = " << *colour_;
+	out << ", box_shift = " << box_shift_;
+	out << ", right_colour = " << *right_colour_;
+	out << ", left_colour = " << *left_colour_;
+	out << ", border_colour = " << *border_colour_;
+	out << ", border_thickness = " << border_thickness_;
+	out << ", median_thickness = " << median_thickness_;
+	out << ", median_colour = " << *median_colour_;
+	out << ", max = " << max_;
+	out << ", max_font_name = " << max_font_name_;
+	out << ", max_font_style = " << max_font_style_;
+	out << ", max_font_size = " << max_font_size_;
+	out << ", max_font_colour = " << *max_font_colour_;
+	out << ", box_width = " << box_width_;
+	out << ", whisker = " << whisker_;
+	out << ", legend_resolution = " << legend_resolution_;
+	out << ", legend_control_text = " << legend_control_text_;
+	out << ", legend_forecast_text = " << legend_forecast_text_;
+	out << ", deterministic = " << deterministic_;
+	out << ", deterministic_colour = " << *deterministic_colour_;
+	out << ", deterministic_style = " << deterministic_style_;
+	out << ", deterministic_thickness = " << deterministic_thickness_;
+	out << ", control = " << control_;
+	out << ", control_colour = " << *control_colour_;
+	out << ", control_style = " << control_style_;
+	out << ", control_thickness = " << control_thickness_;
+	out << ", legend = " << legend_;
+	out << "]" << "\n";
+}
+
+
+void EpsGraphAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"epsgraph\"";
+	 out << ", \"eps_font\":";
+	 niceprint(out,font_);
+	 out << ", \"eps_font_size\":";
+	 niceprint(out,font_size_);
+	 out << ", \"eps_font_style\":";
+	 niceprint(out,font_style_);
+	 out << ", \"eps_font_colour\":";
+	 niceprint(out, *font_colour_);
+	 out << ", \"eps_box_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"eps_box_shift\":";
+	 niceprint(out,box_shift_);
+	 out << ", \"eps_right_box_colour\":";
+	 niceprint(out, *right_colour_);
+	 out << ", \"eps_left_box_colour\":";
+	 niceprint(out, *left_colour_);
+	 out << ", \"eps_box_border_colour\":";
+	 niceprint(out, *border_colour_);
+	 out << ", \"eps_box_border_thickness\":";
+	 niceprint(out,border_thickness_);
+	 out << ", \"eps_box_median_thickness\":";
+	 niceprint(out,median_thickness_);
+	 out << ", \"eps_box_median_colour\":";
+	 niceprint(out, *median_colour_);
+	 out << ", \"eps_maximum\":";
+	 niceprint(out,max_);
+	 out << ", \"eps_maximum_font_name\":";
+	 niceprint(out,max_font_name_);
+	 out << ", \"eps_maximum_font_style\":";
+	 niceprint(out,max_font_style_);
+	 out << ", \"eps_maximum_font_size\":";
+	 niceprint(out,max_font_size_);
+	 out << ", \"eps_maximum_font_colour\":";
+	 niceprint(out, *max_font_colour_);
+	 out << ", \"eps_box_width\":";
+	 niceprint(out,box_width_);
+	 out << ", \"eps_whisker\":";
+	 niceprint(out,whisker_);
+	 out << ", \"eps_legend_resolution\":";
+	 niceprint(out,legend_resolution_);
+	 out << ", \"eps_legend_control_text\":";
+	 niceprint(out,legend_control_text_);
+	 out << ", \"eps_legend_forecast_text\":";
+	 niceprint(out,legend_forecast_text_);
+	 out << ", \"eps_deterministic\":";
+	 niceprint(out,deterministic_);
+	 out << ", \"eps_deterministic_line_colour\":";
+	 niceprint(out, *deterministic_colour_);
+	 out << ", \"eps_deterministic_line_style\":";
+	 niceprint(out,deterministic_style_);
+	 out << ", \"eps_deterministic_line_thickness\":";
+	 niceprint(out,deterministic_thickness_);
+	 out << ", \"eps_control\":";
+	 niceprint(out,control_);
+	 out << ", \"eps_control_line_colour\":";
+	 niceprint(out, *control_colour_);
+	 out << ", \"eps_control_line_style\":";
+	 niceprint(out,control_style_);
+	 out << ", \"eps_control_line_thickness\":";
+	 niceprint(out,control_thickness_);
+	 out << ", \"legend\":";
+	 niceprint(out,legend_);
+}
+static MagicsParameter<string> eps_font("eps_font", "sansserif", "");
+static MagicsParameter<double> eps_font_size("eps_font_size", 0.25, "");
+static MagicsParameter<string> eps_font_style("eps_font_style", "", "");
+static MagicsParameter<string> eps_font_colour("eps_font_colour", "blue", "");
+static MagicsParameter<string> eps_box_colour("eps_box_colour", "cyan", "");
+static MagicsParameter<int> eps_box_shift("eps_box_shift", 0, "");
+static MagicsParameter<string> eps_right_box_colour("eps_right_box_colour", "red", "");
+static MagicsParameter<string> eps_left_box_colour("eps_left_box_colour", "blue", "");
+static MagicsParameter<string> eps_box_border_colour("eps_box_border_colour", "black", "");
+static MagicsParameter<int> eps_box_border_thickness("eps_box_border_thickness", 3, "");
+static MagicsParameter<int> eps_box_median_thickness("eps_box_median_thickness", 3, "");
+static MagicsParameter<string> eps_box_median_colour("eps_box_median_colour", "black", "");
+static MagicsParameter<double> eps_maximum("eps_maximum", INT_MAX, "");
+static MagicsParameter<string> eps_maximum_font_name("eps_maximum_font_name", "sansserif", "");
+static MagicsParameter<string> eps_maximum_font_style("eps_maximum_font_style", "normal", "");
+static MagicsParameter<double> eps_maximum_font_size("eps_maximum_font_size", 0.25, "");
+static MagicsParameter<string> eps_maximum_font_colour("eps_maximum_font_colour", "red", "");
+static MagicsParameter<double> eps_box_width("eps_box_width", -1, "");
+static MagicsParameter<string> eps_whisker("eps_whisker", "on", "");
+static MagicsParameter<string> eps_legend_resolution("eps_legend_resolution", "truncature", "");
+static MagicsParameter<string> eps_legend_control_text("eps_legend_control_text", "", "");
+static MagicsParameter<string> eps_legend_forecast_text("eps_legend_forecast_text", "", "");
+static MagicsParameter<string> eps_deterministic("eps_deterministic", "on", "");
+static MagicsParameter<string> eps_deterministic_line_colour("eps_deterministic_line_colour", "blue", "");
+static MagicsParameter<string> eps_deterministic_line_style("eps_deterministic_line_style", "solid", "");
+static MagicsParameter<int> eps_deterministic_line_thickness("eps_deterministic_line_thickness", 2, "");
+static MagicsParameter<string> eps_control("eps_control", "on", "");
+static MagicsParameter<string> eps_control_line_colour("eps_control_line_colour", "red", "");
+static MagicsParameter<string> eps_control_line_style("eps_control_line_style", "dash", "");
+static MagicsParameter<int> eps_control_line_thickness("eps_control_line_thickness", 2, "");
+static MagicsParameter<string> legend("legend", "on", "");
diff --git a/src/visualisers/EpsPlumeAttributes.cc b/src/visualisers/EpsPlumeAttributes.cc
new file mode 100644
index 0000000..8e05a17
--- /dev/null
+++ b/src/visualisers/EpsPlumeAttributes.cc
@@ -0,0 +1,166 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file EpsPlumeAttributes.cc
+    \brief Implementation of EpsPlume Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "EpsPlumeAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+EpsPlumeAttributes::EpsPlumeAttributes():
+	method_(ParameterManager::getString("eps_plume_method")),
+	line_colour_(MagTranslator<string, Colour>().magics("eps_plume_line_colour")),
+	line_style_(MagTranslator<string, LineStyle>().magics("eps_plume_line_style")),
+	line_thickness_(ParameterManager::getInt("eps_plume_line_thickness")),
+	forecast_line_colour_(MagTranslator<string, Colour>().magics("eps_plume_forecast_line_colour")),
+	forecast_line_style_(MagTranslator<string, LineStyle>().magics("eps_plume_forecast_line_style")),
+	forecast_line_thickness_(ParameterManager::getInt("eps_plume_forecast_line_thickness")),
+	control_line_colour_(MagTranslator<string, Colour>().magics("eps_plume_control_line_colour")),
+	control_line_style_(MagTranslator<string, LineStyle>().magics("eps_plume_control_line_style")),
+	control_line_thickness_(ParameterManager::getInt("eps_plume_control_line_thickness"))
+{
+} 
+
+
+
+EpsPlumeAttributes::~EpsPlumeAttributes()
+{
+}
+
+    
+void EpsPlumeAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "eps_plume";
+	prefix[1] = "eps";
+
+	setAttribute(prefix, "eps_plume_method", method_, params);
+	setAttribute(prefix, "eps_plume_line_colour", line_colour_, params);
+	setAttribute(prefix, "eps_plume_line_style", line_style_, params);
+	setAttribute(prefix, "eps_plume_line_thickness", line_thickness_, params);
+	setAttribute(prefix, "eps_plume_forecast_line_colour", forecast_line_colour_, params);
+	setAttribute(prefix, "eps_plume_forecast_line_style", forecast_line_style_, params);
+	setAttribute(prefix, "eps_plume_forecast_line_thickness", forecast_line_thickness_, params);
+	setAttribute(prefix, "eps_plume_control_line_colour", control_line_colour_, params);
+	setAttribute(prefix, "eps_plume_control_line_style", control_line_style_, params);
+	setAttribute(prefix, "eps_plume_control_line_thickness", control_line_thickness_, params);
+}
+
+void EpsPlumeAttributes::copy(const EpsPlumeAttributes& other)
+{
+	method_ = other.method_;
+	line_colour_ = auto_ptr<Colour>(other.line_colour_->clone());
+	line_style_ = other.line_style_;
+	line_thickness_ = other.line_thickness_;
+	forecast_line_colour_ = auto_ptr<Colour>(other.forecast_line_colour_->clone());
+	forecast_line_style_ = other.forecast_line_style_;
+	forecast_line_thickness_ = other.forecast_line_thickness_;
+	control_line_colour_ = auto_ptr<Colour>(other.control_line_colour_->clone());
+	control_line_style_ = other.control_line_style_;
+	control_line_thickness_ = other.control_line_thickness_;
+} 
+
+
+bool EpsPlumeAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "epsplume")  )
+		return true;
+	return false;
+}
+
+void EpsPlumeAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "epsplume") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void EpsPlumeAttributes::print(ostream& out)  const
+{
+	out << "EpsPlumeAttributes[";
+	out << "method = " << method_;
+	out << ", line_colour = " << *line_colour_;
+	out << ", line_style = " << line_style_;
+	out << ", line_thickness = " << line_thickness_;
+	out << ", forecast_line_colour = " << *forecast_line_colour_;
+	out << ", forecast_line_style = " << forecast_line_style_;
+	out << ", forecast_line_thickness = " << forecast_line_thickness_;
+	out << ", control_line_colour = " << *control_line_colour_;
+	out << ", control_line_style = " << control_line_style_;
+	out << ", control_line_thickness = " << control_line_thickness_;
+	out << "]" << "\n";
+}
+
+
+void EpsPlumeAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"epsplume\"";
+	 out << ", \"eps_plume_method\":";
+	 niceprint(out,method_);
+	 out << ", \"eps_plume_line_colour\":";
+	 niceprint(out, *line_colour_);
+	 out << ", \"eps_plume_line_style\":";
+	 niceprint(out,line_style_);
+	 out << ", \"eps_plume_line_thickness\":";
+	 niceprint(out,line_thickness_);
+	 out << ", \"eps_plume_forecast_line_colour\":";
+	 niceprint(out, *forecast_line_colour_);
+	 out << ", \"eps_plume_forecast_line_style\":";
+	 niceprint(out,forecast_line_style_);
+	 out << ", \"eps_plume_forecast_line_thickness\":";
+	 niceprint(out,forecast_line_thickness_);
+	 out << ", \"eps_plume_control_line_colour\":";
+	 niceprint(out, *control_line_colour_);
+	 out << ", \"eps_plume_control_line_style\":";
+	 niceprint(out,control_line_style_);
+	 out << ", \"eps_plume_control_line_thickness\":";
+	 niceprint(out,control_line_thickness_);
+}
+static MagicsParameter<string> eps_plume_method("eps_plume_method", "time_serie", "");
+static MagicsParameter<string> eps_plume_line_colour("eps_plume_line_colour", "magenta", "");
+static MagicsParameter<string> eps_plume_line_style("eps_plume_line_style", "solid", "");
+static MagicsParameter<int> eps_plume_line_thickness("eps_plume_line_thickness", 1, "");
+static MagicsParameter<string> eps_plume_forecast_line_colour("eps_plume_forecast_line_colour", "cyan", "");
+static MagicsParameter<string> eps_plume_forecast_line_style("eps_plume_forecast_line_style", "dash", "");
+static MagicsParameter<int> eps_plume_forecast_line_thickness("eps_plume_forecast_line_thickness", 5, "");
+static MagicsParameter<string> eps_plume_control_line_colour("eps_plume_control_line_colour", "cyan", "");
+static MagicsParameter<string> eps_plume_control_line_style("eps_plume_control_line_style", "solid", "");
+static MagicsParameter<int> eps_plume_control_line_thickness("eps_plume_control_line_thickness", 5, "");
diff --git a/src/visualisers/EpsShadeAttributes.cc b/src/visualisers/EpsShadeAttributes.cc
new file mode 100644
index 0000000..6a10741
--- /dev/null
+++ b/src/visualisers/EpsShadeAttributes.cc
@@ -0,0 +1,123 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file EpsShadeAttributes.cc
+    \brief Implementation of EpsShade Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "EpsShadeAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+EpsShadeAttributes::EpsShadeAttributes():
+	colour_(MagTranslator<string, Colour>().magics("eps_shade_colour")),
+	line_colour_(MagTranslator<string, Colour>().magics("eps_shade_line_colour")),
+	line_style_(MagTranslator<string, LineStyle>().magics("eps_shade_line_style")),
+	line_thickness_(ParameterManager::getInt("eps_shade_line_thickness"))
+{
+} 
+
+
+
+EpsShadeAttributes::~EpsShadeAttributes()
+{
+}
+
+    
+void EpsShadeAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "eps";
+
+	setAttribute(prefix, "eps_shade_colour", colour_, params);
+	setAttribute(prefix, "eps_shade_line_colour", line_colour_, params);
+	setAttribute(prefix, "eps_shade_line_style", line_style_, params);
+	setAttribute(prefix, "eps_shade_line_thickness", line_thickness_, params);
+}
+
+void EpsShadeAttributes::copy(const EpsShadeAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	line_colour_ = auto_ptr<Colour>(other.line_colour_->clone());
+	line_style_ = other.line_style_;
+	line_thickness_ = other.line_thickness_;
+} 
+
+
+bool EpsShadeAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "epsshade")  )
+		return true;
+	return false;
+}
+
+void EpsShadeAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "epsshade") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void EpsShadeAttributes::print(ostream& out)  const
+{
+	out << "EpsShadeAttributes[";
+	out << "colour = " << *colour_;
+	out << ", line_colour = " << *line_colour_;
+	out << ", line_style = " << line_style_;
+	out << ", line_thickness = " << line_thickness_;
+	out << "]" << "\n";
+}
+
+
+void EpsShadeAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"epsshade\"";
+	 out << ", \"eps_shade_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"eps_shade_line_colour\":";
+	 niceprint(out, *line_colour_);
+	 out << ", \"eps_shade_line_style\":";
+	 niceprint(out,line_style_);
+	 out << ", \"eps_shade_line_thickness\":";
+	 niceprint(out,line_thickness_);
+}
+static MagicsParameter<string> eps_shade_colour("eps_shade_colour", "red", "");
+static MagicsParameter<string> eps_shade_line_colour("eps_shade_line_colour", "red", "");
+static MagicsParameter<string> eps_shade_line_style("eps_shade_line_style", "solid", "");
+static MagicsParameter<int> eps_shade_line_thickness("eps_shade_line_thickness", 1, "");
diff --git a/src/visualisers/EpsWindAttributes.cc b/src/visualisers/EpsWindAttributes.cc
new file mode 100644
index 0000000..f5fefab
--- /dev/null
+++ b/src/visualisers/EpsWindAttributes.cc
@@ -0,0 +1,117 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file EpsWindAttributes.cc
+    \brief Implementation of EpsWind Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "EpsWindAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+EpsWindAttributes::EpsWindAttributes():
+	colour_(MagTranslator<string, Colour>().magics("eps_rose_wind_colour")),
+	border_colour_(MagTranslator<string, Colour>().magics("eps_rose_wind_border_colour")),
+	convention_(ParameterManager::getString("eps_rose_wind_convention"))
+{
+} 
+
+
+
+EpsWindAttributes::~EpsWindAttributes()
+{
+}
+
+    
+void EpsWindAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "eps_rose_wind";
+	prefix[1] = "eps";
+
+	setAttribute(prefix, "eps_rose_wind_colour", colour_, params);
+	setAttribute(prefix, "eps_rose_wind_border_colour", border_colour_, params);
+	setAttribute(prefix, "eps_rose_wind_convention", convention_, params);
+}
+
+void EpsWindAttributes::copy(const EpsWindAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	border_colour_ = auto_ptr<Colour>(other.border_colour_->clone());
+	convention_ = other.convention_;
+} 
+
+
+bool EpsWindAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "epswind")  )
+		return true;
+	return false;
+}
+
+void EpsWindAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "epswind") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void EpsWindAttributes::print(ostream& out)  const
+{
+	out << "EpsWindAttributes[";
+	out << "colour = " << *colour_;
+	out << ", border_colour = " << *border_colour_;
+	out << ", convention = " << convention_;
+	out << "]" << "\n";
+}
+
+
+void EpsWindAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"epswind\"";
+	 out << ", \"eps_rose_wind_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"eps_rose_wind_border_colour\":";
+	 niceprint(out, *border_colour_);
+	 out << ", \"eps_rose_wind_convention\":";
+	 niceprint(out,convention_);
+}
+static MagicsParameter<string> eps_rose_wind_colour("eps_rose_wind_colour", "grey", "");
+static MagicsParameter<string> eps_rose_wind_border_colour("eps_rose_wind_border_colour", "grey", "");
+static MagicsParameter<string> eps_rose_wind_convention("eps_rose_wind_convention", "meteorological", "");
diff --git a/src/visualisers/EquidistantTableMode.cc b/src/visualisers/EquidistantTableMode.cc
new file mode 100644
index 0000000..57f6aff
--- /dev/null
+++ b/src/visualisers/EquidistantTableMode.cc
@@ -0,0 +1,186 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EquidistantTableMode.cc
+    \brief Implementation of the Template class EquidistantTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 17-May-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "EquidistantTableMode.h"
+
+using namespace magics;
+
+EquidistantTableMode::EquidistantTableMode()
+{
+	return;
+}
+
+
+EquidistantTableMode::~EquidistantTableMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void EquidistantTableMode::print(ostream& out)  const
+{
+	out << "EquidistantTableMode[";
+	//EquidistantTableModeAttributes::print(out);
+	LookupTableModeAttributes::print(out);
+	out << "]";
+}
+
+void EquidistantTableMode::operator()(Image& im, Raster& rd)
+{
+     int 	i;		 // auxiliary variables
+     long	acum;		 // accumulated population
+     long	pop;		 // total population
+     long       cutv;            // outlayer population
+
+     // Check outlayer value
+
+     if ( outlayer_ < 0. || outlayer_ > 0.5 )
+     {
+	  MagLog::error() << "Invalid outlayer value. Range between 0. and 0.5. Default value used (0.0)." << endl;
+	  outlayer_ = 0.;
+     }
+
+     // Check image range of values
+     int imin = (int)rd.min();
+     int imax = (int)rd.max();
+
+     if (imax > ETM_MLEN || imin < 0 )
+     {
+	  MagLog::error() << "EquidistantTableMode: Invalid range of image values (" << imin << "," << imax << ")\n"
+	               << "  Current implementation accepts values between 0 to " << ETM_MLEN << endl;
+	  return;
+     }
+
+     // Initialize lookuptable
+     ColourTable& table = im.getColourTable();
+     int nlevels = table.size();
+
+     // Reserve memory for the histogram and lut
+     imax++; //index imax is needed
+     vector<long> hist(imax,0L);
+     vector<short> lut(imax);
+
+     // Compute histogram (Maybe we do not need to use all values -> one every 10???)
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+	     // Remove this test later
+	     if(*val < imin || *val > imax-1)
+		     MagLog::error() << "EquidistantTableMode: ERROR in histogram!!!" << endl;
+
+	     hist[(int)*val]++;
+     }
+
+#if 0
+//test: remove later
+long aa=0L;
+for(i = 0; i < imax; i++) 
+{
+     aa += hist[i];
+     MagLog::dev()<< i << " " << hist[i] << endl;
+}
+MagLog::dev()<< "EquidistantTableMode: test aa =" << aa << endl;
+#endif
+
+     // Remove outlayers and compute minmax indexes
+     // Level imin is left out because it is the background
+     int minOut = imin;
+     int maxOut = imax-1;
+     pop  = (long)rd.getRows() * (long)rd.getColumns();
+     cutv = (long) ((double)pop * outlayer_ + 1.);
+     acum = 0L;
+
+     for (i = imin+1; i < imax; i++)
+     {
+	  acum += hist[i];
+	  if ( acum >= cutv )
+	  {
+	       minOut = i;
+	       break;
+	  }
+     }
+     acum = 0L;
+     for (i = imax-1; i > imin; i--)
+     {
+	  acum += hist[i];
+	  if ( acum >= cutv )
+	  {
+	       maxOut = i;
+	       break;
+	  }
+     }
+
+     // Create accumulate histogram
+     pop = hist[minOut];
+     for( i = minOut+1; i <= maxOut; i++)
+     {
+	  pop += hist[i];
+	  hist[i] = hist[i-1] + hist[i];
+     }
+
+     // Create lut
+     for( i = 0; i < imax; i++)
+     {
+	  if ( i < minOut ) 
+	       lut[i] = 0;
+	  else if (i >= maxOut)
+	       lut[i] = nlevels-1;
+	  else
+		  lut[i] = (short)( (double)hist[i] * (double)(nlevels-1) / (double)pop );
+     }
+
+#if 0
+//test: remove later
+MagLog::dev()<< "Accumulated histogram" << endl;
+for(i = 0; i < imax; i++) 
+	MagLog::dev()<< i << " " << hist[i] << " " << lut[i] << endl;
+#endif
+
+     // Create output image
+//vector<long> hist1(nlevels+1,0L); //test
+//long iii=0L;
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+	     im.push_back(lut[(int)*val]);
+//	     short ii = lut[(int)*val];
+//error	     table[ii].value(*val);
+//	     im.push_back(ii);
+//iii++;
+//hist1[ii]++;
+     }
+
+//MagLog::dev()<< "EquidistantTableMode::operator()" << endl;
+//for( i = 0; i < nlevels+1; i++)
+//     MagLog::dev()<< i << " " << hist1[i] << endl;
+//MagLog::dev()<< "total=" << iii<< endl;
+
+     return;
+}
diff --git a/src/visualisers/EquidistantTableMode.h b/src/visualisers/EquidistantTableMode.h
new file mode 100644
index 0000000..062912b
--- /dev/null
+++ b/src/visualisers/EquidistantTableMode.h
@@ -0,0 +1,73 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EquidistantTableMode.h
+    \brief Definition of the Template class EquidistantTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 17-May-2005
+    
+    Changes:
+    
+*/
+
+#ifndef EquidistantTableMode_H
+#define EquidistantTableMode_H
+
+#include "magics.h"
+
+#include "LookupTableMode.h"
+#include "EquidistantTableModeAttributes.h"
+
+#define ETM_MLEN 1024 //maximum number of elements of a histogram
+
+namespace magics {
+
+//class EquidistantTableMode: public LookupTableMode, public EquidistantTableModeAttributes {
+class EquidistantTableMode: public LookupTableMode {
+
+public:
+	EquidistantTableMode();
+	virtual ~EquidistantTableMode();
+	void set(const map<string, string>& ) // for MagML
+	{
+	   //LookupTableMode::set(map); 
+	   //EquidistantTableModeAttributes::set(map);
+	}
+
+	virtual void operator()(Image&, Raster&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	EquidistantTableMode(const EquidistantTableMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	EquidistantTableMode& operator=(const EquidistantTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const EquidistantTableMode& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/Filter.cc b/src/visualisers/Filter.cc
new file mode 100644
index 0000000..2ea8545
--- /dev/null
+++ b/src/visualisers/Filter.cc
@@ -0,0 +1,353 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Filter.cc
+    Implementation of Filter class.
+    
+    Magics Team - ECMWF 2004
+   
+    Created: Wed 14-Jun-2004
+    
+*/
+
+#include "Filter.h"
+#include "MagLog.h"
+#include "Timer.h"
+
+using namespace magics;
+
+
+Filter::Filter(MatrixHandler& matrix, int nrows, int ncols) : matrix_(matrix), nrows_(nrows), ncols_(ncols)
+{
+	flr_  = 0;
+	fbuf_ = NULL;
+
+        //Cache input data
+//	matrix.cache(matrix_);
+
+}
+
+
+Filter::~Filter()
+{
+	FreeImageBuffers();
+}
+
+
+bool Filter::AllocImageBuffers()
+{ 
+	int i;
+
+	FreeImageBuffers();
+
+	// Allocate space rotating buffer
+	fbuf_ = new double*[nrows_];
+	if( fbuf_ == NULL ) return false;
+	int nb_columns = matrix_.columns();
+	for (i = 0; i < nrows_; i++)
+	{
+		fbuf_[i] = NULL;
+		fbuf_[i] = new double [nb_columns];
+		if( fbuf_[i] == NULL ) return false;
+	}
+
+	return true;
+}
+
+
+void Filter:: FreeImageBuffers()
+{
+	if( fbuf_ == NULL ) return;
+	int i;
+	for ( i = 0; i < nrows_; i++)
+	{
+		if( fbuf_[i] != NULL )
+		{
+			delete [] fbuf_[i];
+			fbuf_[i] = NULL;
+		}
+	}
+
+	delete [] fbuf_;
+	fbuf_ = NULL;
+
+	return;
+}
+
+
+bool Filter::InitBuffer()
+{
+	int  lin, col;
+
+	// Allocate space for output buffer
+	if( AllocImageBuffers() == false ) return false;
+	int nb_columns = matrix_.columns();
+	// Fill buffer with first nrows_ input data
+	for( lin = 0; lin < nrows_; lin++ )
+	    for( col = 0; col < nb_columns; col++ )
+		 fbuf_[lin][col] = matrix_(lin,col);
+
+	flr_ = nrows_-1;
+
+	return true;
+}
+
+
+bool Filter::ScrollBuffer()
+{
+	int		ind,
+			col;
+	int             nr = nrows_-1;
+	double	*aux;
+	int nb_rows = matrix_.rows();
+	int nb_columns = matrix_.columns();
+
+	// verify if the line is within of the image
+	flr_++;
+ 	if( flr_ <  nb_rows)
+	{
+		aux = fbuf_[0];
+		for( ind = 0; ind < nrows_-1; ind++ ) fbuf_[ind] = fbuf_[ind+1];
+		fbuf_[ nr ] = aux;
+		for( col = 0; col < nb_columns; col++ )
+			fbuf_[nr][col] = matrix_(flr_,col);
+	}
+	else  return false;
+
+	return true;
+}
+
+
+MinMaxFilter::MinMaxFilter(MatrixHandler& matrix, int nrows, int ncols, int flag) : Filter(matrix,nrows,ncols), mflag_(flag)
+{
+}
+
+
+MinMaxFilter::~MinMaxFilter()
+{
+}
+
+/*!
+  \brief Method to find extrema
+*/
+
+bool MinMaxFilter::Process()
+{
+        if ( mflag_ == 0 ) return false;
+        double val;        //central point value
+        bool   found;
+        int    lin,col;
+        int    i,j;
+
+        int fcr = this->nrows_*.5;  //central line
+        int fcc = this->ncols_*.5;  //central column
+
+        const bool doMin = (mflag_ == 1 || mflag_ == 3) ? true : false;
+        const bool doMax = (mflag_ == 2 || mflag_ == 3) ? true : false;
+
+	// Initialize input buffer
+	if( this->InitBuffer() == false )
+	{
+		MagLog::debug() <<" InitBuffer Error" << "\n";
+		return false;
+	}
+
+	// Processing
+	long hi=0;
+	long lo=0;
+        double nb_rows = this->matrix_.rows()    - this->nrows_;
+	double nb_cols = this->matrix_.columns() - this->ncols_;
+
+        for( lin = 0; lin <= nb_rows; lin++ )
+	{
+              for( col = 0; col <= nb_cols; col++ )
+	      {
+		    // check min value
+		    if (doMin)
+		    {
+			val = this->fbuf_[fcr][col+fcc];
+			found = true;
+			for ( i = 0; i < this->nrows_; i++)
+			{
+			    for ( j = 0; j < this->ncols_; j++)
+			    {
+				    if ( val >= this->fbuf_[i][col+j] )
+				    {
+					    if( i!=fcr || j!=fcc )
+					    {
+						    found = false; //stop searching
+						    break;
+					    }
+				    }
+			    }
+			    if (!found) break;
+			}
+
+			if (found)   //minimum found
+			{
+//				MagLog::debug() << "Min " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n";
+				lo = lo+1;
+				push_back(UserPoint(this->matrix_.column(lin+fcr, col+fcc),this->matrix_.row(lin+fcr, col+fcc),val));
+				this->back().low(true);
+				this->back().high(false);
+			}
+		    }
+
+		    // check max value
+		    if (doMax)
+		    {
+			val = this->fbuf_[fcr][col+fcc];
+			found = true;
+			for ( i = 0; i < this->nrows_; i++)
+			{
+			    for ( j = 0; j < this->ncols_; j++)
+			    {
+				    if ( val <= this->fbuf_[i][col+j] )
+				    {
+					    if( i!=fcr || j!=fcc )
+					    {
+						    found = false; //stop searching
+						    break;
+					    }
+				    }
+			    }
+			    if (!found) break;
+			}
+
+			if (found)   //minimum found
+			{
+//				MagLog::debug() << "Max " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n";
+				hi = hi+1;
+				push_back(UserPoint(this->matrix_.column(lin+fcr, col+fcc),this->matrix_.row(lin+fcr, col+fcc),val));
+				this->back().high(true);
+				this->back().low(false);
+			}
+		    }
+	        } // end column
+
+	      if ( this->ScrollBuffer() == false ) break;
+	}
+
+        MagLog::debug() <<"TOTAL POINTS LOW = " << lo << "\n"
+                     <<"TOTAL POINTS HI  = " << hi << "\n";
+	return true;
+}
+
+
+//TEST, REMOVE LATER
+
+void MinMaxFilter::test_build_data()
+{
+      printf("\n\n TESTING   \n");
+	double val;        //central point value
+	bool     found;
+	int	 lin,col;
+	int	 i,j;
+
+	int fcr = this->nrows_/2;  //central line
+	int fcc = this->ncols_/2;  //central column
+
+	bool doMin = (mflag_ == 1 || mflag_ == 3) ? true : false;
+	bool doMax = (mflag_ == 2 || mflag_ == 3) ? true : false;
+
+	// Initialize input buffer
+	if( this->InitBuffer() == false )
+	{
+		MagLog::debug() <<" InitBuffer Error" << "\n";
+		return;
+	}
+
+	long hi=0;
+	long lo=0;
+	// Processing
+ 	for( lin = 0; lin <= this->matrix_.rows()-this->nrows_; lin++ )
+	{
+		printf("\n");
+		for ( i = 0; i < this->nrows_; i++)
+		{
+			for (j = 0; j < this->matrix_.columns(); j++) MagLog::debug() << this->fbuf_[i][j] << " ";
+			printf("\n");
+		}
+
+	      for( col = 0; col <= this->matrix_.columns()-this->ncols_; col++ )
+	      {
+		    // check min value
+		    if (doMin)
+		    {
+			val = this->fbuf_[fcr][col+fcc];
+			found = true;
+			for ( i = 0; i < this->nrows_; i++)
+			{
+			    for ( j = 0; j < this->ncols_; j++)
+			    {
+				    if ( val >= this->fbuf_[i][col+j] )
+				    {
+					    if( i!=fcr || j!=fcc )
+					    {
+						    found = false; //stop searching
+						    break;
+					    }
+				    }
+			    }
+			    if (!found) break;
+			}
+
+			if (found)   //minimum found
+			{
+				MagLog::debug() << "\n" << "Min " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n";
+				lo = lo+1;
+			}
+		    }
+
+		    // check max value
+		    if (doMax)
+		    {
+			val = this->fbuf_[fcr][col+fcc];
+			found = true;
+			for ( i = 0; i < this->nrows_; i++)
+			{
+			    for ( j = 0; j < this->ncols_; j++)
+			    {
+				    if ( val <= this->fbuf_[i][col+j] )
+				    {
+					    if( i!=fcr || j!=fcc )
+					    {
+						    found = false; //stop searching
+						    break;
+					    }
+				    }
+			    }
+			    if (!found) break;
+			}
+
+			if (found)   //minimum found
+			{
+				MagLog::debug() << "\n" << "Max " << lin+fcr+1 << " " << col+fcc+1 << " " << val << "\n";
+				hi = hi+1;
+			}
+		    }
+	        } // end column
+
+	      if ( this->ScrollBuffer() == false ) break;
+ 	}
+
+	MagLog::debug() <<"TOTAL POINTS LOW=" << lo << "\n";
+	MagLog::debug() <<"TOTAL POINTS HI =" << hi << "\n";
+
+	printf("\n\nEND TEST\n");
+}
diff --git a/src/visualisers/Filter.h b/src/visualisers/Filter.h
new file mode 100644
index 0000000..4df7f43
--- /dev/null
+++ b/src/visualisers/Filter.h
@@ -0,0 +1,146 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Filter.h
+    \brief Definition of the Template class Filter.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 14-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Filter_H
+#define Filter_H
+
+#include "magics.h"
+#include "UserPoint.h"
+#include "MatrixHandler.h"
+namespace magics {
+
+
+class Filter: public vector<UserPoint>
+{
+public : 
+
+    Filter(MatrixHandler& matrix, int nrows, int ncols);
+    virtual ~Filter(); 
+
+    //!  Get number of columns of the Mask
+    int DimensionX () const { return ncols_; }
+
+    //!  Get number of lines of the Mask
+    int DimensionY () const { return nrows_; }
+
+    //!  Start the processing of the filters
+    virtual bool Process () {}
+
+protected :
+
+    /*!
+      \brief Load the first lines in buffer.
+      Return:
+         true  if the operantion was successfull
+         false otherwise
+    */
+    bool InitBuffer();
+
+    /*!
+      \brief Scrolls buffer by saving the oldest line and loading the next line
+      Return:
+         true  if the operantion was successfull
+         false otherwise
+    */
+    bool ScrollBuffer();
+
+    /*!
+      \brief Allocate memory for the scroll buffer
+      Return:
+           true  if the operantion was successfull
+           false otherwise
+    */
+    bool AllocImageBuffers();
+
+    /*!
+       \brief Disallocate scroll buffer memory
+       Return:
+           true  if the operantion was successfull
+           false otherwise
+    */
+    void FreeImageBuffers();
+
+//TEST, REMOVE LATER
+void test_build_data();
+
+     MatrixHandler& matrix_;
+     int               nrows_;    //!< number of Mask rows
+     int               ncols_;    //!< number of Mask columns
+     int               flr_;      //!< current row
+     double            **fbuf_;	  //!< Rotating buffer
+};
+
+
+class MinMaxFilter: public Filter {
+public:
+//	MinMaxFilter (const BaseMatrixHandler& matrix, int nrows, int ncols);
+	MinMaxFilter (MatrixHandler& matrix, int nrows, int ncols, int flag=3);
+
+	virtual ~MinMaxFilter();
+    
+        /*!
+          Convolutes the filter over the input matrix
+          Return:
+             true  if the operantion was successfull
+             false otherwise
+        */
+        virtual bool Process ();
+
+        //! Set min/max flag
+	void SetMinMaxFlag (int flag) { mflag_ = flag; }
+        //! Get min/max flag
+        int  GetMinMaxFlag () { return mflag_; }
+
+//TEST, REMOVE LATER
+void test_build_data();
+
+private:
+    //! Copy constructor - No copy allowed
+    MinMaxFilter(const MinMaxFilter&);
+    //! Overloaded << operator to copy - No copy allowed
+    MinMaxFilter& operator=(const MinMaxFilter&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+    friend ostream& operator<<(ostream& s,const MinMaxFilter& p)
+        { return s; }
+
+    /*!
+      1 : compute low
+      2 : compute high
+      3 : compute high & low
+    */
+    int mflag_;
+};
+
+} // namespace magics
+
+
+
+#endif
diff --git a/src/visualisers/FixedTableModeAttributes.h b/src/visualisers/FixedTableModeAttributes.h
new file mode 100644
index 0000000..668045f
--- /dev/null
+++ b/src/visualisers/FixedTableModeAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file FixedTableModeAttributes.h
+    \brief Definition of FixedTableMode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef FixedTableModeAttributes_H
+#define FixedTableModeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class FixedTableModeAttributes 
+{
+public:
+//  --  constructor
+    FixedTableModeAttributes();
+    
+//  --  destructor
+    virtual ~FixedTableModeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const FixedTableModeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	intarray levels_;
+	intarray indexes_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const FixedTableModeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/FlagPlotting.cc b/src/visualisers/FlagPlotting.cc
new file mode 100644
index 0000000..2d5689a
--- /dev/null
+++ b/src/visualisers/FlagPlotting.cc
@@ -0,0 +1,145 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file WindPlotting.cc
+    \brief Implementation of the Template class Wind.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#include "FlagPlotting.h"
+#include "LegendVisitor.h"
+#include "Histogram.h"
+
+using namespace magics;
+
+void FlagPlotting::operator()(const UserPoint& geo, const PaperPoint& point, double x, double y,double) 
+{ 
+		double speed = sqrt((x*x)+(y*y));
+		if (speed < this->min_speed_ || speed > this->max_speed_) return;
+		
+	   if ((*this->calm_)(point, x, y)) return; 
+	
+		if ( geo.y() >= 0 ) 
+			northFlags_->push_back(ArrowPoint(x, y, point));
+		else southFlags_->push_back(ArrowPoint(x, y, point));
+		
+		
+}
+
+void FlagPlotting::prepare(BasicGraphicsObjectContainer& task, double)
+{ 
+
+    // Calm Indicator 
+    (*this->calm_).colour(*this->colour_);
+    (*this->calm_).height(this->calm_indicator_size_);
+    (*this->calm_).below(this->calm_below_);
+    (*this->calm_).prepare(task);
+    
+  
+    
+    
+    // Setting for south Hemisphere wind	
+	southFlags_ = new Flag();
+	southFlags_->setColour(*this->colour_); 
+	southFlags_->setThickness(this->thickness_);
+	southFlags_->setStyle(this->style_);
+	southFlags_->setCrossBoundary(this->cross_boundary_);
+	southFlags_->setHemisphere(SOUTH);
+	southFlags_->setOriginHeight(this->calm_indicator_size_);
+	southFlags_->setLength(this->length_);
+	
+	// Setting for south Hemisphere wind	
+	northFlags_ = new Flag();
+	northFlags_->setColour(*this->colour_); 
+	northFlags_->setThickness(this->thickness_);
+	northFlags_->setCrossBoundary(this->cross_boundary_);
+	northFlags_->setOriginHeight(this->calm_indicator_size_);
+	northFlags_->setHemisphere(NORTH);
+	northFlags_->setLength(this->length_);
+	
+	// Origin Indicator 	  
+    (*this->origin_).prepare(*southFlags_);
+    (*this->origin_).prepare(*northFlags_);
+    
+    northFlags_->setOriginHeight(this->origin_marker_size_);
+    southFlags_->setOriginHeight(this->origin_marker_size_);
+	if ( this->legend_only_) return;
+	task.push_back(southFlags_);	
+	task.push_back(northFlags_);	
+}
+
+void FlagPlotting::visit(LegendVisitor& legend)
+{
+	if ( !this->legend_ ) return;
+	   
+	   
+	  
+	   
+	  
+	   Flag* flags = new Flag();
+	   flags->setColour(*this->colour_); 
+	   flags->setThickness(this->thickness_);
+	   flags->setCrossBoundary(this->cross_boundary_); 
+	   (*this->origin_).prepare(*flags);
+	   flags->setOriginHeight(this->origin_marker_size_);
+	   flags->setHemisphere(NORTH);
+	   flags->setLength(this->length_);
+
+	   ostringstream text;
+
+	   if (legend_text_ == "vector" ) legend_text_ = " ";
+	   LegendEntry * entry = new FlagEntry(legend_text_, flags);
+
+	   legend.add(entry);
+	   legend.add(new EmptyEntry());
+}
+
+void FlagPlotting::visit(Data& data, PointsHandler& points, HistoVisitor& visitor)
+{
+    IntervalMap<Colour> beans;
+    if ( !visitor.basic() ) {
+
+	vector<double>::iterator from = this->levels_->begin();
+        vector<double>::iterator to = this->levels_->begin();
+        ++to;
+        for (;  to != this->levels_->end(); ++to)
+	{
+	    	Colour colour;	    	
+	    	if (magCompare(advanced_method_, "advanced") ||  
+		    magCompare(advanced_method_, "on") ) 
+		{	  	  	
+			colour=colourMethod_->right(*from);
+		}
+		else
+		{
+		  	colour=*this->colour_;;
+		} 	
+            	beans.insert(make_pair(Interval(*from, *to), colour ));
+            	++from;
+        }		  	
+    }
+    
+    Histogram helper;
+    helper.visit(beans, data, points, visitor);
+}  
\ No newline at end of file
diff --git a/src/visualisers/FlagPlotting.h b/src/visualisers/FlagPlotting.h
new file mode 100644
index 0000000..56577a4
--- /dev/null
+++ b/src/visualisers/FlagPlotting.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file FlagPlotting.h
+    \brief Definition of the Template class FlagPlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef FlagPlotting_H
+#define FlagPlotting_H
+
+#include "magics.h"
+
+#include "WindPlotting.h"
+#include "FlagPlottingAttributes.h"
+#include "Flag.h"
+
+namespace magics {
+
+class FlagPlotting: public WindPlotting, public FlagPlottingAttributes
+{
+
+public:
+	FlagPlotting() : northFlags_(0), southFlags_(0) {}
+	virtual ~FlagPlotting() {}
+	virtual void set(const map<string, string>& map) 
+		{ WindPlottingAttributes::set(map); FlagPlottingAttributes::set(map); }
+	virtual void set(const XmlNode& node) 
+		{ WindPlottingAttributes::set(node); FlagPlottingAttributes::set(node); }
+	bool accept(const string& node) { return FlagPlottingAttributes::accept(node);; }
+	void copy(const FlagPlotting& other) { WindPlottingAttributes::copy(other); FlagPlottingAttributes::copy(other); }
+	virtual WindPlotting* clone() {
+		FlagPlotting* object = new FlagPlotting();
+		object->copy(*this);
+		return object;
+	}
+	
+	virtual void operator()(const UserPoint&, const PaperPoint& point, double x, double y,double);
+
+	virtual void prepare(BasicGraphicsObjectContainer& task, double);
+	void visit(LegendVisitor& legend);
+	void visit(Data&, PointsHandler&, HistoVisitor&);
+	
+protected:     	 
+     	 //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const
+	 { out << "FlagPlotting<P>"; } 
+	  Flag* northFlags_;
+	  Flag* southFlags_;
+
+private:
+    //! Copy constructor - No copy allowed
+	FlagPlotting(const FlagPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	FlagPlotting& operator=(const FlagPlotting&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const FlagPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/FloatSelection.h b/src/visualisers/FloatSelection.h
new file mode 100644
index 0000000..38ca374
--- /dev/null
+++ b/src/visualisers/FloatSelection.h
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file FloatSelection.h
+    \brief Definition of the Template class FloatSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef FloatSelection_H
+#define FloatSelection_H
+
+#include "magics.h"
+
+
+namespace magics {
+
+class FloatSelection : public vector<double> {
+
+public:
+	FloatSelection();
+	virtual ~FloatSelection();
+    virtual void prepare() {}
+    
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     void calculate(double, double, int);
+     void calculate(const doublearray&);
+
+
+private:
+    //! Copy constructor - No copy allowed
+	FloatSelection(const FloatSelection&);
+    //! Overloaded << operator to copy - No copy allowed
+	FloatSelection& operator=(const FloatSelection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const FloatSelection& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/Graph.h b/src/visualisers/Graph.h
new file mode 100644
index 0000000..bbe95f4
--- /dev/null
+++ b/src/visualisers/Graph.h
@@ -0,0 +1,110 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Graph.h
+    \brief Definition of the Template class Graph.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Graph_H
+#define Graph_H
+
+#include "magics.h"
+
+#include "Visdef.h"
+#include "UserPoint.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "DateTime.h"
+#include "GraphAttributes.h"
+
+namespace magics {
+
+
+
+struct DateToFloat {
+	DateToFloat(const DateTime& reference) : reference_(reference) {}
+	~DateToFloat() {}
+	double operator()(const string& date) {
+		DateTime val(date);
+		return double(val - reference_);
+	}
+	const DateTime& reference_;
+		 
+};
+
+class Graph :public GraphAttributes {
+
+public:
+	Graph() {}
+	virtual ~Graph() {}
+    
+    virtual void set(const XmlNode& node ) { GraphAttributes::set(node); }
+	virtual void set(const map<string, string>& map) { GraphAttributes::set(map); }
+   
+    virtual Graph* clone() const { return new Graph(); }
+    virtual void toxml(ostream&)  const {}
+	virtual void operator()(Data&, BasicGraphicsObjectContainer&) {}
+	virtual void visit(LegendVisitor&) {}
+	virtual void visit(TopAxisVisitor&) {}
+	virtual void visit(Transformation&, Data&) {}
+    void legend(bool legend, const string& text) { legend_ = legend; legend_text_= text; }
+
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	 string legend_text_;
+	 bool legend_;
+private:
+	//! Copy constructor - No copy allowed
+	Graph(const Graph&);
+	//! Overloaded << operator to copy - No copy allowed
+	Graph& operator=(const Graph&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Graph& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, Graph> { 
+public:
+	Graph* operator()(const string& val ) {
+		 return SimpleObjectMaker<Graph>::create(val);
+	}
+    
+	Graph* magics(const string& param)
+	{
+		Graph* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/GraphPlotting.cc b/src/visualisers/GraphPlotting.cc
new file mode 100644
index 0000000..b5c145e
--- /dev/null
+++ b/src/visualisers/GraphPlotting.cc
@@ -0,0 +1,53 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GraphPlotting.cc
+    \brief Implementation of the Template class GraphPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#include "GraphPlotting.h"
+
+using namespace magics;
+
+GraphPlotting::GraphPlotting() 
+{
+	 type_->legend(legend_, legend_text_);  
+}
+
+
+GraphPlotting::~GraphPlotting() 
+{
+    
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GraphPlotting::print(ostream& out)  const
+{
+	out << "GraphPlotting[";
+	out << "]";
+}
+
diff --git a/src/visualisers/GraphPlotting.h b/src/visualisers/GraphPlotting.h
new file mode 100644
index 0000000..a1362a7
--- /dev/null
+++ b/src/visualisers/GraphPlotting.h
@@ -0,0 +1,83 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GraphPlotting.h
+    \brief Definition of the Template class GraphPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef GraphPlotting_H
+#define GraphPlotting_H
+
+#include "magics.h"
+
+#include "GraphPlottingAttributes.h"
+#include "Visdef.h"
+#include "UserPoint.h"
+
+
+namespace magics {
+	
+
+class DateTime;
+
+class GraphPlotting: public GraphPlottingAttributes, public Visdef {
+
+public:
+	GraphPlotting();
+	virtual ~GraphPlotting();
+    
+    // Implements the Visualiser interface  ... 
+   
+    void operator()(Data& data, BasicGraphicsObjectContainer& parent) {
+    		return (*type_)(data, parent); }
+    bool needLegend() { return legend_; }
+    void visit(LegendVisitor& legend) { type_->legend(legend_, legend_text_); type_->visit(legend); }
+    void visit(TopAxisVisitor& top) { type_->visit(top); }
+    virtual void visit(Transformation& transformation, Data& data)  { type_->visit(transformation, data); }
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { GraphPlottingAttributes::set(map); type_->set(map); }
+	void set(const XmlNode& node ) { GraphPlottingAttributes::set(node); type_->set(node);}
+
+	
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+   
+private:
+    //! Copy constructor - No copy allowed
+	GraphPlotting(const GraphPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	GraphPlotting& operator=(const GraphPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GraphPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/GraphShade.cc b/src/visualisers/GraphShade.cc
new file mode 100644
index 0000000..68d188a
--- /dev/null
+++ b/src/visualisers/GraphShade.cc
@@ -0,0 +1,123 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GraphShade.cc
+    \brief Implementation of the Template class GraphShade.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 17-Aug-2006
+    
+    Changes:
+    
+*/
+
+
+#include "GraphShade.h"
+#include "PaperPoint.h"
+#include "UserPoint.h"
+#include "Polyline.h"
+
+using namespace magics;
+
+GraphShade::GraphShade() 
+{
+}
+
+
+GraphShade::~GraphShade() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GraphShade::print(ostream& out)  const
+{
+	out << "GraphShade[";
+	GraphShadeAttributes::print(out);
+	out << "]";
+}
+
+
+void GraphShade::operator()(Polyline& box)
+{
+	// Make sure the polyline is closed! 
+	box.push_back(box.front());
+
+	(*style_)(box);
+}
+
+void GraphShade::legend(Polyline& box)
+{
+	
+	if ( !box.empty() ) {
+		// we make a box! 
+		float height = 0.5;
+		PaperPoint front = box.front();
+		PaperPoint back = box.back();
+		
+		double xb = back.x();
+		double yb = back.y();	
+		double xf = front.x();
+		double yf = front.y();
+		
+		box.push_back(PaperPoint(xb, yb+height));
+		box.push_back(PaperPoint(xf, yf +height));
+		box.push_back(front);
+	}
+	(*style_)(box);
+}
+void GraphShade::operator()(CustomisedPointsList& points, vector<UserPoint>& out)
+{
+	
+	for (CustomisedPointsList::iterator point = points.begin(); point != points.end(); ++point)
+		out.push_back(UserPoint((**point)["x"], (**point)["y"]));
+	CustomisedPointsList::const_reverse_iterator rpoint = points.rbegin(); 
+	CustomisedPointsList::const_reverse_iterator last = points.rend(); 
+
+	while ( rpoint != last ) {
+		out.push_back(UserPoint((**rpoint)["x2"], (**rpoint)["y2"]));
+		rpoint++;
+	}
+}
+
+void NoGraphShade::operator()(CustomisedPointsList& points, vector<UserPoint>& out)
+{
+	
+	for (CustomisedPointsList::iterator point = points.begin(); point != points.end(); ++point) {
+		CustomisedPoint::iterator x = (*point)->find("x");
+		CustomisedPoint::iterator y = (*point)->find("y");
+		if ( x != (*point)->end() && y != (*point)->end() ) {
+			out.push_back(UserPoint(x->second, y->second));
+			if ( (*point)->missing() )
+				out.back().flagMissing();
+		}
+
+	}
+		
+	
+}
+
+
+void NoGraphShade::print(ostream& out)  const
+{
+	out << "NoGraphShade[";
+	out << "]";
+}
+
diff --git a/src/visualisers/GraphShade.h b/src/visualisers/GraphShade.h
new file mode 100644
index 0000000..5f7c415
--- /dev/null
+++ b/src/visualisers/GraphShade.h
@@ -0,0 +1,129 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GraphShade.h
+    \brief Definition of the Template class GraphShade.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 17-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef GraphShade_H
+#define GraphShade_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "BasicGraphicsObject.h"
+#include "GraphShadeAttributes.h"
+#include "CustomisedPoint.h"
+#include "Polyline.h"
+
+namespace magics {
+
+class Polyline;
+class PaperPoint;
+class UserPoint;
+
+class GraphShade : public GraphShadeAttributes{
+
+public:
+	GraphShade();
+	virtual ~GraphShade();
+    
+    virtual void set(const XmlNode& node) {
+       GraphShadeAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        GraphShadeAttributes::set(map);
+    }
+    virtual GraphShade* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new GraphShade();
+    }
+  
+    virtual void operator()(Polyline&); 
+    virtual void legend(Polyline&); 
+    virtual void operator()(CustomisedPointsList&, vector<UserPoint>&); 
+    virtual bool needCustomised() { return true; }
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	GraphShade(const GraphShade&);
+    //! Overloaded << operator to copy - No copy allowed
+	GraphShade& operator=(const GraphShade&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GraphShade& p)
+		{ p.print(s); return s; }
+
+};
+
+class NoGraphShade : public GraphShade {
+
+public:
+	NoGraphShade() {}
+	virtual ~NoGraphShade() {}
+    
+    virtual void set(const XmlNode&) {}
+    virtual void set(const map<string, string>&) {}
+    virtual GraphShade* clone() const {      
+        return new NoGraphShade();
+    }
+    
+     virtual void operator()(Polyline& poly) { poly.setFilled(false); }
+     virtual void legend(Polyline&) {}
+     void operator()(CustomisedPointsList&, vector<UserPoint>&); 
+     bool needCustomised() { return false; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+
+};
+
+
+template <>
+class MagTranslator<string, GraphShade> { 
+public:
+	GraphShade* operator()(const string& val )
+	{
+		return SimpleObjectMaker<GraphShade>::create(val);
+	}     
+
+	GraphShade* magics(const string& param)
+	{
+		GraphShade* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/GraphShadeStyle.cc b/src/visualisers/GraphShadeStyle.cc
new file mode 100644
index 0000000..b3ebada
--- /dev/null
+++ b/src/visualisers/GraphShadeStyle.cc
@@ -0,0 +1,132 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GraphShadeStyle.cc
+    \brief Implementation of the Template class GraphShadeStyle.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 17-Aug-2006
+    
+    Changes:
+    
+*/
+
+#include "GraphShadeStyle.h"
+#include "Polyline.h"
+#include "PaperPoint.h"
+#include "PaperPoint.h"
+
+
+using namespace magics;
+
+GraphShadeStyle::GraphShadeStyle() 
+{
+}
+
+
+GraphShadeStyle::~GraphShadeStyle() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GraphShadeStyle::print(ostream& out)  const
+{
+	out << "GraphShadeStyle[";
+	out << "]";
+}
+
+void HatchGraphShadeStyle::print(ostream& out)  const
+{
+	out << "HatchGraphShadeStyle[";
+	GraphShadeStyle::print(out);
+	HatchGraphShadeStyleAttributes::print(out);
+	out << "]";
+}
+
+void DotGraphShadeStyle::print(ostream& out)  const
+{
+	out << "DotGraphShadeStyle[";
+	GraphShadeStyle::print(out);
+	DotGraphShadeStyleAttributes::print(out);
+	out << "]";
+}
+/*
+void GraphShadeStyle::operator()(Polyline* box, BasicGraphicsObjectContainer&)
+{
+	box->setFilled(true);
+	box->setFillColour(*colour_);
+	  ShadingProperties* shading = new FillShadingProperties();
+      shading->inColour_ = *colour_;
+      shading->outColour_ = Colour("NONE");
+      box->setShading(shading);
+}
+
+
+void DotGraphShadeStyle::operator()(Polyline* box, BasicGraphicsObjectContainer&)
+{
+	box->setFilled(true);
+	box->setFillColour(*colour_);
+	  ShadingProperties* shading = new DotShadingProperties();
+      shading->inColour_ = *colour_;
+      shading->outColour_ = Colour("NONE");
+      box->setShading(shading);
+      
+}
+
+void HatchGraphShadeStyle::operator()(Polyline* box, BasicGraphicsObjectContainer&)
+{
+	box->setFilled(true);
+	box->setFillColour(*colour_);
+	  ShadingProperties* shading = new HatchShadingProperties();
+      shading->inColour_ = *colour_;
+      shading->outColour_ = Colour("NONE");
+      box->setShading(shading);     
+}
+*/
+
+void GraphShadeStyle::operator()(Polyline& box)
+{
+	box.setFillColour(*colour_);
+	box.setFilled(true);
+	ShadingProperties* shading = new FillShadingProperties();
+	
+	box.setShading(shading);
+}
+
+void DotGraphShadeStyle::operator()(Polyline& box)
+{
+	box.setFillColour(*colour_);
+	box.setFilled(true);
+	ShadingProperties* shading = new DotShadingProperties();
+	
+	box.setShading(shading);
+}
+
+void HatchGraphShadeStyle::operator()(Polyline& box)
+{
+	box.setFillColour(*colour_);
+	box.setFilled(true);
+	HatchShadingProperties* shading = new HatchShadingProperties();
+	shading->index_ = 1;
+	
+	box.setShading(shading);
+}
+
diff --git a/src/visualisers/GraphShadeStyle.h b/src/visualisers/GraphShadeStyle.h
new file mode 100644
index 0000000..64d5a39
--- /dev/null
+++ b/src/visualisers/GraphShadeStyle.h
@@ -0,0 +1,158 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GraphShadeStyle.h
+    \brief Definition of the Template class GraphShadeStyle.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 17-Aug-2006
+    
+    Changes:
+    
+*/
+
+#ifndef GraphShadeStyle_H
+#define GraphShadeStyle_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "BasicGraphicsObject.h"
+#include "GraphShadeStyleAttributes.h"
+#include "HatchGraphShadeStyleAttributes.h"
+#include "DotGraphShadeStyleAttributes.h"
+
+namespace magics {
+	
+class Polyline;
+class PaperPoint;
+
+
+
+class GraphShadeStyle : public GraphShadeStyleAttributes {
+
+public:
+	GraphShadeStyle();
+	virtual ~GraphShadeStyle();
+    
+    virtual void set(const XmlNode& node) {
+        GraphShadeStyleAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        GraphShadeStyleAttributes::set(map);
+    }
+    virtual GraphShadeStyle* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new GraphShadeStyle();
+    }
+    //virtual void operator()(Polyline*, BasicGraphicsObjectContainer&);
+    virtual void operator()(Polyline&);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	GraphShadeStyle(const GraphShadeStyle&);
+    //! Overloaded << operator to copy - No copy allowed
+	GraphShadeStyle& operator=(const GraphShadeStyle&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GraphShadeStyle& p)
+		{ p.print(s); return s; }
+
+};
+
+class DotGraphShadeStyle : public GraphShadeStyle, public DotGraphShadeStyleAttributes {
+
+public:
+	DotGraphShadeStyle() {}
+	virtual ~DotGraphShadeStyle() {}
+    
+    virtual void set(const XmlNode& node) {
+        GraphShadeStyle::set(node);
+        DotGraphShadeStyleAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        GraphShadeStyle::set(map);
+        DotGraphShadeStyleAttributes::set(map);
+    }
+    virtual GraphShadeStyle* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new DotGraphShadeStyle();
+    }
+   // void operator()(Polyline*, BasicGraphicsObjectContainer&);
+    virtual void operator()(Polyline&);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+};
+
+class HatchGraphShadeStyle : public GraphShadeStyle, public HatchGraphShadeStyleAttributes {
+
+public:
+	HatchGraphShadeStyle() {}
+	virtual ~HatchGraphShadeStyle() {}
+    
+    virtual void set(const XmlNode& node) {
+        GraphShadeStyle::set(node);
+        HatchGraphShadeStyleAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        GraphShadeStyle::set(map);
+        HatchGraphShadeStyleAttributes::set(map);
+    }
+    virtual GraphShadeStyle* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new HatchGraphShadeStyle();
+    }
+   // void operator()(Polyline*, BasicGraphicsObjectContainer&);
+    void operator()(Polyline&);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+};
+
+
+template <>
+class MagTranslator<string, GraphShadeStyle> { 
+public:
+	GraphShadeStyle* operator()(const string& val )
+	{
+		return SimpleObjectMaker<GraphShadeStyle>::create(val);
+	}     
+
+	
+	
+	GraphShadeStyle* magics(const string& param)
+	{
+		GraphShadeStyle* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/GribTables.h b/src/visualisers/GribTables.h
new file mode 100644
index 0000000..5ef29c1
--- /dev/null
+++ b/src/visualisers/GribTables.h
@@ -0,0 +1,153 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GribTables.h
+    \brief Definition of the Template class GribTables.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef GribTables_H
+#define GribTables_H
+
+#include "magics.h"
+
+#include "DefinitionTable.h"
+
+
+namespace magics {
+
+
+class GeneralDef 
+{
+public :
+    GeneralDef(const map<string, string>& def)
+    {
+            map<string, string>::const_iterator info;
+    
+            info = def.find("code");
+            if ( info == def.end() ) code_ = -1;
+            else code_ =  atoi(info->second.c_str());
+            
+            info = def.find("long_title");
+            if ( info == def.end() ) longTitle_ = "Unknown";
+            else longTitle_ =  info->second;
+            
+            info = def.find("short_title");
+            if ( info == def.end() ) shortTitle_ =  "Unknown";
+            else shortTitle_ =  info->second;
+    }
+    
+    GeneralDef(): code_(-1), 
+        longTitle_("unknown"), 
+        shortTitle_("unknown") {}
+    virtual ~GeneralDef() {}
+    int code()                  { return code_; }
+    string longTitle() const    { return longTitle_; }
+    string shortTitle() const   { return shortTitle_; }
+   
+    
+protected:
+  //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const {
+        out << "GeneralDef[";
+        out << "code=" << code_;
+        out << ", long title=" <<  longTitle_;
+        out << ", short title=" <<  shortTitle_;
+        out << "]";
+	 }
+    
+    int    code_;
+    string longTitle_;
+    string shortTitle_;
+  
+    
+    // -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GeneralDef& p)
+		{ p.print(s); return s; }
+};
+
+template <> 
+map<string, DefinitionTable<GeneralDef>* >* DefinitionTable<GeneralDef>::tables_ = 0;
+class CentreTable : public DefinitionTable<GeneralDef>
+{
+public:
+	CentreTable() : DefinitionTable<GeneralDef>("centre.xml", "centre") {}
+    
+	virtual ~CentreTable() {}
+    static const GeneralDef& definition(int code) { return definitionInfo("centre.xml", "centre", code); } 
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	
+  
+private:
+    //! Copy constructor - No copy allowed
+	CentreTable(const CentreTable&);
+    //! Overloaded << operator to copy - No copy allowed
+	CentreTable& operator=(const CentreTable&);
+
+
+};
+
+class LevelTable : public DefinitionTable<GeneralDef>
+{
+public:
+	LevelTable() : DefinitionTable<GeneralDef>("level.xml", "level") {}
+    
+	virtual ~LevelTable() {}
+    static const GeneralDef& definition(int code) { return definitionInfo("level.xml", "level", code); } 
+
+	
+ 
+
+};
+
+class TypeTable : public DefinitionTable<GeneralDef>
+{
+public:
+	TypeTable() : DefinitionTable<GeneralDef>("type.xml", "type") {}
+    
+	virtual ~TypeTable() {}
+    static const GeneralDef& definition(int code) { return definitionInfo("type.xml", "type", code); } 
+    
+
+ 
+
+};
+class SatelliteTable : public DefinitionTable<GeneralDef>
+{
+public:
+	SatelliteTable() : DefinitionTable<GeneralDef>("satellite.xml", "identifier") {}
+    
+	virtual ~SatelliteTable() {}
+    static const GeneralDef& definition(int code) { return definitionInfo("satellite.xml", "identifier", code); } 
+    
+
+ 
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/GridPlotting.cc b/src/visualisers/GridPlotting.cc
new file mode 100644
index 0000000..9673fee
--- /dev/null
+++ b/src/visualisers/GridPlotting.cc
@@ -0,0 +1,203 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GridPlotting.cc
+    \brief Implementation of the Template class GridPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "GridPlotting.h"
+#include "../basic/BasicSceneObject.h"
+#include "Transformation.h"
+
+
+using namespace magics;
+
+GridPlotting::GridPlotting() : layer_(0)
+{
+}
+ 
+GridPlotting::~GridPlotting() 
+{
+}
+
+void NoGridPlotting::longitudes(vector<double>& lons, int freq) const
+{
+	 int i = 0;
+	 double min = minx_ - lonIncrement_;
+	 double max = maxx_ + lonIncrement_;
+	 for(double lon = lonReference_; lon > min; lon -= lonIncrement_)
+	 {
+		 if ( (i % freq) == 0) {
+			 lons.push_back(lon);
+
+		 }
+
+		 i++;
+	 }
+	 i = 0;
+	 for(double lon = lonReference_ +  lonIncrement_ ; lon < max; lon += lonIncrement_)
+	 {
+		 i++;
+		 if ( (i % freq) == 0) {
+			 lons.push_back(lon);
+
+		 }
+
+	  }
+
+}
+void NoGridPlotting::latitudes(vector<double>& lats, int freq) const
+{
+	 int i = 0;
+	 double min = miny_ - latIncrement_;
+	 double max = maxy_ + latIncrement_;
+	 for(double lat = latReference_; lat > min; lat -= latIncrement_)
+	 {
+		 if ( i % freq == 0) {
+			 lats.push_back(lat);
+
+		 }
+		 i++;
+	 }
+	 i = 0;
+	 for(double lat = latReference_ +  latIncrement_ ; lat < max; lat += latIncrement_)
+	 {
+		 i++;
+		 if ( i % freq == 0) {
+			 lats.push_back(lat);
+
+		 }
+	 }
+}
+
+const vector<double>& NoGridPlotting::longitudes(const Transformation& transformation) const
+{
+	transformation.boundingBox(minx_, miny_, maxx_, maxy_);
+	maxy_ = std::min(85., maxy_);
+	double min = minx_ - lonIncrement_;
+	double max = maxx_ + lonIncrement_;
+
+	if(longitudes_.empty())
+	{
+     	     for(double lon = lonReference_; lon > min; lon -= lonIncrement_)
+     	     {
+		     longitudes_.push_back(lon);
+     	     }
+	     for(double lon = lonReference_ +  lonIncrement_ ; lon < max; lon += lonIncrement_)
+     	     {
+		     longitudes_.push_back(lon);
+     	     }
+	} 
+
+	// Here we prepare a small point in the middle!
+
+	::sort(longitudes_.begin(), longitudes_.end(), std::greater<double>());
+	return longitudes_;
+}
+
+const vector<double>& NoGridPlotting::latitudes(const Transformation& transformation) const
+{
+	transformation.boundingBox(minx_, miny_, maxx_, maxy_);
+	maxy_ = std::min(85., maxy_);
+	double min = miny_ - latIncrement_;
+	double max = maxy_ + latIncrement_;
+	if(latitudes_.empty())
+	{
+	       for(double lat = latReference_; lat > min; lat -=latIncrement_)
+     	       {
+		       latitudes_.push_back(lat);
+     	       }
+	       for(double lat = latReference_ + latIncrement_; lat < max; lat += latIncrement_)
+     	       {
+		       latitudes_.push_back(lat);
+     	       }
+	}
+	::sort(latitudes_.begin(), latitudes_.end(), std::greater<double>());
+	return latitudes_;
+}    
+void NoGridPlotting::operator()(DrawingVisitor& out) {
+	
+	
+	const Transformation& transformation = out.transformation();
+
+	this->latitudes(transformation);
+	this->longitudes(transformation);
+}
+	
+void GridPlotting::operator()(DrawingVisitor& out)
+{
+	const Transformation& transformation = out.transformation();
+	
+
+	layer_ = out.layoutPtr();
+	
+
+
+		this->latitudes(transformation);
+		this->longitudes(transformation);
+
+	// Wrep :here we add a small line in the lowerleft corner..
+	// to force the driver to compute the output size even if 
+	// no grid are going to be plotted
+	Polyline* grid = new Polyline();
+	grid->setColour(Colour("none"));
+	grid->setThickness(0);
+
+	grid->push_back(PaperPoint(transformation.getMinPCX(), transformation.getMinPCY()));
+	grid->push_back(PaperPoint(transformation.getMinPCX(), transformation.getMinPCY()));
+	out.push_back(grid);
+
+	transformation.gridLongitudes(*this);
+	transformation.gridLatitudes(*this);
+}
+
+void GridPlotting::operator()(magics::PreviewVisitor&)
+{
+}
+
+void GridPlotting::add(Polyline& poly) const
+{
+    poly.setColour(*colour_);
+    poly.setThickness(thickness_);
+    poly.setLineStyle(style_);
+
+    poly.reproject(*layer_);
+    
+}
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void GridPlotting::print(ostream& out)  const
+{
+	out << "GridPlotting[";
+	GridPlottingAttributes::print(out);
+	out << "]";
+}
+
+
+
diff --git a/src/visualisers/GridPlotting.h b/src/visualisers/GridPlotting.h
new file mode 100644
index 0000000..6edd6a8
--- /dev/null
+++ b/src/visualisers/GridPlotting.h
@@ -0,0 +1,180 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file GridPlotting.h
+    \brief Definition of the Template class GridPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef GridPlotting_H
+#define GridPlotting_H
+
+#include "magics.h"
+
+#include "GridPlottingAttributes.h"
+#include "NoGridPlottingAttributes.h"
+#include "UserPoint.h"
+#include "Polyline.h"
+#include "SceneVisitor.h"
+
+
+namespace magics {
+
+
+
+class NoGridPlotting:public NoGridPlottingAttributes {
+
+public:
+	NoGridPlotting() {}
+	virtual ~NoGridPlotting() {}
+    
+    virtual void set(const XmlNode&) {}
+    virtual void set(const map<string, string>&) {}
+    virtual bool accept(const string&) { return false;}
+    virtual void toxml(ostream&, int = 0) const {}
+    virtual NoGridPlotting* clone() const { return new NoGridPlotting(); }
+    virtual void operator()(DrawingVisitor&);
+    virtual void operator()(PreviewVisitor&) {}
+   
+    const vector<double>& longitudes(const Transformation&) const;
+      const vector<double>& latitudes(const Transformation&) const;
+
+      const vector<double>& longitudes() const { return longitudes_; }
+      const vector<double>& latitudes() const  { return latitudes_; }
+      void longitudes(vector<double>&, int) const;
+      void latitudes(vector<double>&, int) const;
+    virtual string colour() const { return "NONE"; }
+    virtual void layer(BasicGraphicsObjectContainer*) {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "NoGridPlotting\n"; } 
+	 mutable vector<double> latitudes_;
+	 mutable vector<double> longitudes_;
+
+	 mutable double minx_;
+	 mutable double miny_;
+	 mutable double maxx_;
+	 mutable double maxy_;
+
+private:
+    //! Copy constructor - No copy allowed
+	NoGridPlotting(const NoGridPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoGridPlotting& operator=(const NoGridPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoGridPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, NoGridPlotting> { 
+public:
+	NoGridPlotting* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoGridPlotting>::create(val);
+	}     
+
+	NoGridPlotting* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+class GridPlotting: public NoGridPlotting, public GridPlottingAttributes {
+
+public:
+	GridPlotting();
+	virtual ~GridPlotting();
+    
+    virtual NoGridPlotting* clone() const {
+    	GridPlotting* object = new GridPlotting();
+    	object->copy(*this);
+    	return object;
+    }
+    
+    virtual void copy(const GridPlotting& other)
+    {
+    	NoGridPlottingAttributes::copy(other);
+    	GridPlottingAttributes::copy(other);
+    }
+ 	virtual void set(const XmlNode& node) {
+ 	   NoGridPlottingAttributes::set(node);
+       GridPlottingAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+    	  NoGridPlottingAttributes::set(map);
+        GridPlottingAttributes::set(map);
+    }
+    bool accept(const string& node) { return GridPlottingAttributes::accept(node); }
+    virtual void operator()(DrawingVisitor&);
+    virtual void operator()(PreviewVisitor&);
+    
+  
+    
+    void add(Polyline&) const;
+    void layer(BasicGraphicsObjectContainer* layer) { layer_ = layer; }
+   
+   
+    void visit(Transformation&) {}
+
+    
+   
+    
+    virtual string colour() const { return colour_->name(); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+     
+     BasicGraphicsObjectContainer *layer_;
+
+private:
+    //! Copy constructor - No copy allowed
+	GridPlotting(const GridPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	GridPlotting& operator=(const GridPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const GridPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/GridPlottingAttributes.h b/src/visualisers/GridPlottingAttributes.h
new file mode 100644
index 0000000..e4a33a9
--- /dev/null
+++ b/src/visualisers/GridPlottingAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file GridPlottingAttributes.h
+    \brief Definition of GridPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef GridPlottingAttributes_H
+#define GridPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class GridPlottingAttributes 
+{
+public:
+//  --  constructor
+    GridPlottingAttributes();
+    
+//  --  destructor
+    virtual ~GridPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const GridPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	LineStyle style_;
+	int thickness_;
+	auto_ptr<Colour> colour_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const GridPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/GridShadingAttributes.h b/src/visualisers/GridShadingAttributes.h
new file mode 100644
index 0000000..88fce64
--- /dev/null
+++ b/src/visualisers/GridShadingAttributes.h
@@ -0,0 +1,81 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file GridShadingAttributes.h
+    \brief Definition of GridShading Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef GridShadingAttributes_H
+#define GridShadingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class GridShadingAttributes 
+{
+public:
+//  --  constructor
+    GridShadingAttributes();
+    
+//  --  destructor
+    virtual ~GridShadingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const GridShadingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string position_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const GridShadingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HatchPolyShadingMethod.h b/src/visualisers/HatchPolyShadingMethod.h
new file mode 100644
index 0000000..925660b
--- /dev/null
+++ b/src/visualisers/HatchPolyShadingMethod.h
@@ -0,0 +1,81 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HatchPolyShadingMethod.h
+    \brief Definition of the Template class HatchPolyShadingMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 25-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HatchPolyShadingMethod_H
+#define HatchPolyShadingMethod_H
+
+#include "magics.h"
+
+#include "PolyShadingMethod.h"
+#include "HatchPolyShadingMethodAttributes.h"
+#include "IntervalMap.h"
+
+namespace magics {
+
+
+class HatchPolyShadingMethod: public PolyShadingMethod, public HatchPolyShadingMethodAttributes {
+
+public:
+	HatchPolyShadingMethod() {}
+	virtual ~HatchPolyShadingMethod() {}
+	
+	
+    
+    virtual void set(const map<string, string>& map) { HatchPolyShadingMethodAttributes::set(map); }
+    virtual void set(const XmlNode& node) { HatchPolyShadingMethodAttributes::set(node); }
+    virtual bool accept(const string& node) { return HatchPolyShadingMethodAttributes::accept(node); }
+    virtual PolyShadingMethod* clone() const {
+		HatchPolyShadingMethod* object = new HatchPolyShadingMethod();
+		object->copy(*this);
+		return object;
+	}
+
+    virtual void prepare(const LevelSelection& levels, const ColourTechnique&);
+    virtual void operator()(Polyline& poly) const;
+
+protected:  
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {} 
+	 vector<int> hatches_;
+private:
+    //! Copy constructor - No copy allowed
+	HatchPolyShadingMethod(const HatchPolyShadingMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	HatchPolyShadingMethod& operator=(const HatchPolyShadingMethod&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HatchPolyShadingMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HatchPolyShadingMethodAttributes.h b/src/visualisers/HatchPolyShadingMethodAttributes.h
new file mode 100644
index 0000000..94093a7
--- /dev/null
+++ b/src/visualisers/HatchPolyShadingMethodAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HatchPolyShadingMethodAttributes.h
+    \brief Definition of HatchPolyShadingMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef HatchPolyShadingMethodAttributes_H
+#define HatchPolyShadingMethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HatchPolyShadingMethodAttributes 
+{
+public:
+//  --  constructor
+    HatchPolyShadingMethodAttributes();
+    
+//  --  destructor
+    virtual ~HatchPolyShadingMethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HatchPolyShadingMethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	int index_;
+	int thickness_;
+	double density_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HatchPolyShadingMethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HeightSelection.h b/src/visualisers/HeightSelection.h
new file mode 100644
index 0000000..58dbd8f
--- /dev/null
+++ b/src/visualisers/HeightSelection.h
@@ -0,0 +1,90 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelection.h
+    \brief Definition of the Template class HeightSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HeightSelection_H
+#define HeightSelection_H
+
+#include "magics.h"
+
+#include "FloatSelection.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+namespace magics {
+
+class XmlNode;
+
+class HeightSelection: public FloatSelection {
+
+public:
+	HeightSelection();
+	virtual ~HeightSelection();
+    virtual void set(const map<string,string>&) {}
+    virtual void set(const XmlNode&) {}
+     virtual void toxml(ostream&, int)  const {}
+    virtual HeightSelection* clone() const {
+    	HeightSelection* object = new HeightSelection();
+    	return object;
+    }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	HeightSelection(const HeightSelection&);
+    //! Overloaded << operator to copy - No copy allowed
+	HeightSelection& operator=(const HeightSelection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HeightSelection& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, HeightSelection> { 
+public:
+	HeightSelection* operator()(const string& val )
+	{
+		return SimpleObjectMaker<HeightSelection>::create(val);
+	}     
+
+	HeightSelection* magics(const string& param)
+	{
+		HeightSelection* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HeightSelectionCount.h b/src/visualisers/HeightSelectionCount.h
new file mode 100644
index 0000000..054d66d
--- /dev/null
+++ b/src/visualisers/HeightSelectionCount.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelectionCount.h
+    \brief Definition of the Template class HeightSelectionCount.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HeightSelectionCount_H
+#define HeightSelectionCount_H
+
+#include "magics.h"
+
+#include "HeightSelection.h"
+#include "HeightSelectionCountAttributes.h"
+
+namespace magics {
+
+class HeightSelectionCount: public HeightSelection, public HeightSelectionCountAttributes {
+
+public:
+	HeightSelectionCount();
+	virtual ~HeightSelectionCount();
+    virtual void set(map<string,string> map) { HeightSelectionCountAttributes::set(map); }
+    void prepare();
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	HeightSelectionCount(const HeightSelectionCount&);
+    //! Overloaded << operator to copy - No copy allowed
+	HeightSelectionCount& operator=(const HeightSelectionCount&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HeightSelectionCount& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HeightSelectionList.h b/src/visualisers/HeightSelectionList.h
new file mode 100644
index 0000000..ca7d9f6
--- /dev/null
+++ b/src/visualisers/HeightSelectionList.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelectionList.h
+    \brief Definition of the Template class HeightSelectionList.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HeightSelectionList_H
+#define HeightSelectionList_H
+
+#include "magics.h"
+
+#include "HeightSelection.h"
+#include "HeightSelectionListAttributes.h"
+
+namespace magics {
+
+class HeightSelectionList: public HeightSelection, public HeightSelectionListAttributes {
+
+public:
+	HeightSelectionList();
+	virtual ~HeightSelectionList();
+    virtual void set(map<string,string> map) { HeightSelectionListAttributes::set(map); }
+    void prepare();
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	HeightSelectionList(const HeightSelectionList&);
+    //! Overloaded << operator to copy - No copy allowed
+	HeightSelectionList& operator=(const HeightSelectionList&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HeightSelectionList& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HeightTechnique.cc b/src/visualisers/HeightTechnique.cc
new file mode 100644
index 0000000..6dc17ef
--- /dev/null
+++ b/src/visualisers/HeightTechnique.cc
@@ -0,0 +1,133 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelection.cc
+    \brief Implementation of the Template class HeightSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "HeightTechnique.h"
+#include "LevelSelection.h"
+
+using namespace magics;
+
+HeightTechnique::HeightTechnique() 
+{
+}
+
+
+HeightTechnique::~HeightTechnique() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void HeightTechnique::print(ostream& out)  const
+{
+	out << "HeightTechnique[";
+	out << "]";
+}
+
+void HeightTechnique::set(const HeightTechniqueInterface&) 
+{
+    
+}
+
+
+ListHeightTechnique::ListHeightTechnique() 
+{
+}
+
+
+ListHeightTechnique::~ListHeightTechnique() 
+{
+}
+
+void ListHeightTechnique::set(const HeightTechniqueInterface& interface) 
+{
+	   list_ = interface.getHeights();
+	   policy_ = interface.getHeightPolicy();
+}
+
+void ListHeightTechnique::prepare(LevelSelection& levels) 
+{
+	heights_.clear();
+	if ( list_.empty() ) list_.push_back(0.2);
+	if ( levels.size() == 1) {
+		heights_[Interval(levels.front(), levels.front())] = list_.front();
+		return;
+	}
+	
+	LevelSelection::const_iterator level = levels.begin();
+	vector<double>::const_iterator height = list_.begin();
+	while (true) {
+		heights_[Interval(*level, *(level+1))] = *height;
+		height++;
+		level++;
+		if ( level == levels.end() ) break;
+		if ( height == list_.end() ) {
+			if (policy_ != M_LASTONE) 
+				height =  list_.begin();
+			else --height;
+		}
+	}
+}
+
+CalculateHeightTechnique::CalculateHeightTechnique() 
+{
+}
+
+
+CalculateHeightTechnique::~CalculateHeightTechnique() 
+{
+}
+
+void CalculateHeightTechnique::set(const HeightTechniqueInterface& interface) 
+{
+		min_ = interface.getMinHeight();
+		max_ = interface.getMaxHeight();
+		
+		
+   
+}
+
+void CalculateHeightTechnique::prepare(LevelSelection& levels) 
+{
+	assert(levels.size() > 1);
+	heights_.clear();
+	double step = (levels.size() == 2) ?  (max_ - min_)  : (max_ - min_) / (levels.size() - 2);
+	LevelSelection::const_iterator level = levels.begin();
+	double height = min_;
+	
+		while (true) {
+			MagLog::debug() << "[" << *level << ", " << *(level+1) << "]=" << height << "(height)" << endl;
+			heights_[Interval(*level, *(level+1))] = height;
+			height += step;			
+			level++;
+			if ( level == levels.end() ) break;			
+		}
+}
diff --git a/src/visualisers/HeightTechnique.h b/src/visualisers/HeightTechnique.h
new file mode 100644
index 0000000..29db47f
--- /dev/null
+++ b/src/visualisers/HeightTechnique.h
@@ -0,0 +1,137 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelection.h
+    \brief Definition of the Template class HeightSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HeightTechnique_H
+#define HeightTechnique_H
+
+#include "magics.h"
+
+
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "IntervalMap.h"
+
+namespace magics {
+
+class XmlNode;
+class LevelSelection;
+
+class HeightTechniqueInterface
+{
+public: 
+    HeightTechniqueInterface() {}
+    virtual ~HeightTechniqueInterface() {}
+	virtual double getMinHeight() const = 0;
+	virtual double getMaxHeight() const = 0;
+	virtual floatarray getHeights() const = 0;
+	virtual ListPolicy getHeightPolicy() const = 0;
+	
+};
+
+class HeightTechnique: public vector<float> {
+
+public:
+	HeightTechnique();
+	virtual ~HeightTechnique();
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual bool accept(const string&) { return false; }
+    
+    virtual HeightTechnique* clone() const { return new HeightTechnique(); }
+    
+    void toxml(ostream&)  const {}
+	
+	virtual void set(const HeightTechniqueInterface&); 
+	virtual void prepare(LevelSelection&) {}
+	double height(double val) { return heights_.find(val, 0.2); }
+   
+
+protected:
+     //! Method to print  about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	  IntervalMap<double> heights_;
+
+private:
+    //! Copy constructor - No copy allowed
+	HeightTechnique(const HeightTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	HeightTechnique& operator=(const HeightTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HeightTechnique& p)
+		{ p.print(s); return s; }
+};
+
+class ListHeightTechnique : public HeightTechnique
+{
+public:
+	ListHeightTechnique();
+	virtual ~ListHeightTechnique();
+	virtual void prepare(LevelSelection&);
+    virtual void set(const HeightTechniqueInterface&); 
+protected:
+	vector<double> list_;
+	ListPolicy policy_;
+};
+
+class CalculateHeightTechnique: public HeightTechnique
+{
+public:
+	CalculateHeightTechnique();
+	virtual ~CalculateHeightTechnique();
+	virtual void prepare(LevelSelection&);
+    virtual void set(const HeightTechniqueInterface&); 
+protected:
+	double min_;
+	double max_;
+	
+};
+
+
+
+template<>
+class MagTranslator<string, HeightTechnique> { 
+public:
+	HeightTechnique* operator()(const string& val )
+	{
+		return SimpleObjectMaker<HeightTechnique>::create(val);
+	}     
+
+	HeightTechnique* magics(const string& param)
+	{
+		HeightTechnique* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HiLo.cc b/src/visualisers/HiLo.cc
new file mode 100644
index 0000000..2d779c3
--- /dev/null
+++ b/src/visualisers/HiLo.cc
@@ -0,0 +1,171 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLo.cc
+    \brief Implementation of the Template class HiLo.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 22-Jun-2004
+    
+    Changes:
+    
+*/
+
+#include "HiLo.h"
+#include "Filter.h"
+#include "MatrixHandler.h"
+#include "Transformation.h"
+
+
+using namespace magics;
+
+
+HiLo::HiLo()
+{
+}
+
+
+HiLo::~HiLo()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void HiLo::print(ostream& out)  const
+{
+   out << "HiLo";
+}
+
+
+
+void HiLo::set(const map<string, string>& map)
+{
+   HiLoAttributes::set(map);
+}
+
+
+void HiLo::operator()(const PaperPoint& point)
+{
+    double value = point.value();
+    if ( value > this->hilo_max_value_ ) return;
+    if ( value < this->hilo_min_value_ ) return;
+    if ( point.high() ) {
+         if ( value > this->hi_max_value_ ) return;
+         if ( value < this->hi_min_value_ ) return;    
+    }
+    if ( point.low() ) {
+         if ( value > this->lo_max_value_ ) return;
+         if ( value < this->lo_min_value_ ) return;
+    }
+
+    (*this->type_)(point, *this);
+    (*this->marker_)(point, *this);
+    //(*this->position_write_)(point);
+}
+
+
+struct SortHiLo 
+{
+    SortHiLo() {}
+    ~SortHiLo() {}
+    bool operator()(const UserPoint& first, const UserPoint& second)
+    {   
+        if (first.high() && second.low()) return true;
+        if (first.low() && second.high()) return false;
+        if (first.low() && second.low())  return first.value() < second.value(); 
+        if (first.high() && second.high()) return first.value() > second.value(); 
+        return false;
+     }
+};
+
+
+struct Radius 
+{
+    Radius(double radius, const UserPoint& reference): radius_(radius), reference_(reference) {}
+    ~Radius() {}
+    bool operator()(const UserPoint& point)
+    {   
+      if (!same(point)) return false; 
+      double dist = distance(point, reference_);
+      if ( zero(dist) ) return false;
+      return  dist  < radius_ * radius_;
+    }
+    
+    bool same(const UserPoint& point) {
+        if ( reference_.high() ) return point.high();
+        if ( reference_.low() ) return point.low();
+        return false;
+    }
+
+    double distance(const UserPoint& p1, const UserPoint& p2) {
+        return ((p1.x() -p2.x())*(p1.x() -p2.x())) + ((p1.y() -p2.y())*(p1.y() -p2.y()));
+    }
+    
+    double radius_;
+    const UserPoint& reference_;
+};
+
+
+
+void HiLo::operator()(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+{
+    double radius;
+    double area_width, area_height, area_max;
+    const Transformation& transformation = parent.transformation();
+
+    MinMaxFilter filter(data, this->window_size_, this->window_size_);
+    filter.Process();
+
+    std::sort(filter.begin(), filter.end(), SortHiLo());
+
+    // compute a sensible radius within which we will not generate two Hi/Li close to each other
+    area_height = data.row    (data.rows()    -1, 0) - data.row    (0, 0);
+    area_width  = data.column (0, data.columns() -1) - data.column (0, 0);
+
+    area_max = max (area_height, area_width);
+    if (area_max > 180) area_max = 150;  // assumption: a width > 180 means polar-stereo - so adjust.
+
+    radius = (area_max / 10.0);
+
+    // printf ("area_height: %f, area_width: %f, area_max: %f, radius: %f\n", area_height, area_width, area_max, radius);
+
+    for (vector<UserPoint>::const_iterator point = filter.begin(); point != filter.end(); ++point) {
+        vector<UserPoint>::iterator last = std::remove_if(filter.begin(), filter.end(), Radius(radius, *point));
+        filter.erase(last, filter.end());
+    }
+
+    clear();
+
+    for (MinMaxFilter::const_iterator point = filter.begin(); point != filter.end(); ++point) {
+    	PaperPoint xy = transformation(*point);
+    	xy.low(point->low());
+    	xy.high(point->high());
+    	if ( transformation.in(xy) ) 
+        	(*this)(xy);
+    }
+   
+    // Now we feed the task
+    for ( vector<BasicGraphicsObject*>::const_iterator object = begin(); object != end(); ++object)
+    	parent.push_back(*object);
+}
+    
+
+
diff --git a/src/visualisers/HiLo.h b/src/visualisers/HiLo.h
new file mode 100644
index 0000000..dd9b81e
--- /dev/null
+++ b/src/visualisers/HiLo.h
@@ -0,0 +1,144 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLo.h
+    \brief Definition of the Template class HiLo.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 22-Jun-2004
+    
+    Changes:
+    
+*/
+
+/*! \defgroup hilo Computation of High and Lows
+
+   \section hiloOverview Overview
+
+   Magics++ supports the calculation of Highs and Lows.
+   These can be plotted (as Letters, Values or Symbols)
+   or written into a file.
+
+   In the past (MAGICS 6 and Magics++ <2.8.1) simple tests
+   were used to find local mins and maxs. This resulted in
+   comments that Magics did too many (not meaningful) extremas.
+
+   \sa MinMaxFilter::Process()
+*/
+
+#ifndef HiLo_H
+#define HiLo_H
+
+#include "magics.h"
+#include "BasicSceneObject.h"
+#include "HiLoBase.h"
+#include "HiLoAttributes.h"
+
+namespace magics {
+
+class MatrixHandler;
+
+class HiLo: public HiLoBase,  public HiLoAttributes, public vector<BasicGraphicsObject*> {
+
+public:
+   HiLo();
+   virtual ~HiLo();
+   virtual void set(const map<string, string>&);
+   virtual void set(const XmlNode& node) { HiLoAttributes::set(node); }
+   virtual bool accept(const string& node) { return HiLoAttributes::accept(node);; }
+
+   virtual HiLoBase* clone() const {
+      HiLo* hilo = new HiLo();
+      hilo->copy(*this);
+      return hilo;
+    }
+  
+    virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
+    virtual void operator()(const PaperPoint&); 
+    virtual void clear() {
+      this->type_->clear();
+      this->marker_->clear();
+      vector<BasicGraphicsObject*>::clear();
+    }
+
+protected:
+    //! Method to print string about this class on to a stream of type ostream (virtual).
+    virtual void print(ostream&) const;
+
+private:
+    //! Copy constructor - No copy allowed
+    HiLo(const HiLo&);
+    //! Overloaded << operator to copy - No copy allowed
+    HiLo& operator=(const HiLo&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+    friend ostream& operator<<(ostream& s,const HiLo& p)
+       { p.print(s); return s; }
+};
+class NoHiLo: public HiLoBase {
+public:
+	NoHiLo() {}
+	    virtual ~NoHiLo() {}
+	    HiLoBase* clone() const { return new NoHiLo(); }
+	    virtual void set(const map<string, string>&) {}
+	    virtual BasicGraphicsObject* next() { return 0; }
+	    virtual bool more() { return false; }
+	    virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&) {}
+	    void print(ostream& out)  const { out << "No HiLo";}
+	};
+
+
+class HighHiLo: public HiLo {
+
+public:
+   HighHiLo() {}
+   virtual ~HighHiLo() {}
+   HiLoBase* clone() const {
+      HiLo* hilo =  new HighHiLo();
+      //hilo->copy(*this);
+      return hilo;
+   }
+
+   void operator()(const PaperPoint& point)  {
+      if ( point.high() ) HiLo::operator()(point);
+   }
+};
+
+
+class LowHiLo: public HiLo {
+
+public:
+   LowHiLo() {}
+   virtual ~LowHiLo() {}
+   HiLoBase* clone() const {
+      HiLoBase* hilo =  new LowHiLo();
+      //hilo->copy(*this);
+      return hilo;
+   }
+
+   void operator()(const PaperPoint& point) {
+      if ( point.low() ) HiLo::operator()(point);
+   }
+};
+
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoAttributes.cc b/src/visualisers/HiLoAttributes.cc
new file mode 100644
index 0000000..48cd542
--- /dev/null
+++ b/src/visualisers/HiLoAttributes.cc
@@ -0,0 +1,187 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HiLoAttributes.cc
+    \brief Implementation of HiLo Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:15 2012
+*/    
+
+#include "HiLoAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+HiLoAttributes::HiLoAttributes():
+	type_(MagTranslator<string, HiLoTechnique>().magics("contour_hilo_type")),
+	window_size_(ParameterManager::getInt("contour_hilo_window_size")),
+	suppress_radius_(ParameterManager::getDouble("contour_hilo_suppress_radius")),
+	hilo_max_value_(ParameterManager::getDouble("contour_hilo_max_value")),
+	hilo_min_value_(ParameterManager::getDouble("contour_hilo_min_value")),
+	hi_max_value_(ParameterManager::getDouble("contour_hi_max_value")),
+	hi_min_value_(ParameterManager::getDouble("contour_hi_min_value")),
+	lo_max_value_(ParameterManager::getDouble("contour_lo_max_value")),
+	lo_min_value_(ParameterManager::getDouble("contour_lo_min_value")),
+	marker_(MagTranslator<string, HiLoMarkerBase>().magics("contour_hilo_marker"))
+{
+} 
+
+
+
+HiLoAttributes::~HiLoAttributes()
+{
+}
+
+    
+void HiLoAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "contour_hilo";
+	prefix[1] = "contour";
+
+	setMember(prefix, "contour_hilo_type", type_, params);
+	setAttribute(prefix, "contour_hilo_window_size", window_size_, params);
+	setAttribute(prefix, "contour_hilo_suppress_radius", suppress_radius_, params);
+	setAttribute(prefix, "contour_hilo_max_value", hilo_max_value_, params);
+	setAttribute(prefix, "contour_hilo_min_value", hilo_min_value_, params);
+	setAttribute(prefix, "contour_hi_max_value", hi_max_value_, params);
+	setAttribute(prefix, "contour_hi_min_value", hi_min_value_, params);
+	setAttribute(prefix, "contour_lo_max_value", lo_max_value_, params);
+	setAttribute(prefix, "contour_lo_min_value", lo_min_value_, params);
+	setMember(prefix, "contour_hilo_marker", marker_, params);
+}
+
+void HiLoAttributes::copy(const HiLoAttributes& other)
+{
+	type_ = auto_ptr<HiLoTechnique>(other.type_->clone());
+	window_size_ = other.window_size_;
+	suppress_radius_ = other.suppress_radius_;
+	hilo_max_value_ = other.hilo_max_value_;
+	hilo_min_value_ = other.hilo_min_value_;
+	hi_max_value_ = other.hi_max_value_;
+	hi_min_value_ = other.hi_min_value_;
+	lo_max_value_ = other.lo_max_value_;
+	lo_min_value_ = other.lo_min_value_;
+	marker_ = auto_ptr<HiLoMarkerBase>(other.marker_->clone());
+} 
+
+
+bool HiLoAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "hilo")  )
+		return true;
+
+	if ( acceptNode(node, type_) )
+		return true;
+
+	if ( acceptNode(node, marker_) )
+		return true;
+	return false;
+}
+
+void HiLoAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "hilo") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), type_, node);
+		setMember(node.name(), marker_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), type_, *(*elt)); 
+		setMember((*elt)->name(), marker_, *(*elt)); 
+	}
+}
+
+void HiLoAttributes::print(ostream& out)  const
+{
+	out << "HiLoAttributes[";
+	out << "type = " << *type_;
+	out << ", window_size = " << window_size_;
+	out << ", suppress_radius = " << suppress_radius_;
+	out << ", hilo_max_value = " << hilo_max_value_;
+	out << ", hilo_min_value = " << hilo_min_value_;
+	out << ", hi_max_value = " << hi_max_value_;
+	out << ", hi_min_value = " << hi_min_value_;
+	out << ", lo_max_value = " << lo_max_value_;
+	out << ", lo_min_value = " << lo_min_value_;
+	out << ", marker = " << *marker_;
+	out << "]" << "\n";
+}
+
+
+void HiLoAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"hilo\"";
+	 out << ", \"contour_hilo_type\":";
+	 type_->toxml(out);
+	 out << ", \"contour_hilo_window_size\":";
+	 niceprint(out,window_size_);
+	 out << ", \"contour_hilo_suppress_radius\":";
+	 niceprint(out,suppress_radius_);
+	 out << ", \"contour_hilo_max_value\":";
+	 niceprint(out,hilo_max_value_);
+	 out << ", \"contour_hilo_min_value\":";
+	 niceprint(out,hilo_min_value_);
+	 out << ", \"contour_hi_max_value\":";
+	 niceprint(out,hi_max_value_);
+	 out << ", \"contour_hi_min_value\":";
+	 niceprint(out,hi_min_value_);
+	 out << ", \"contour_lo_max_value\":";
+	 niceprint(out,lo_max_value_);
+	 out << ", \"contour_lo_min_value\":";
+	 niceprint(out,lo_min_value_);
+	 out << ", \"contour_hilo_marker\":";
+	 marker_->toxml(out);
+}
+static MagicsParameter<string> contour_hilo_type("contour_hilo_type", "text", " New Magics: Parameter contour_hilo_type sent to new Magics[HiLo].  ");
+static MagicsParameter<int> contour_hilo_window_size("contour_hilo_window_size", 3, " New Magics: Parameter contour_hilo_window_size sent to new Magics[HiLo].  ");
+static MagicsParameter<double> contour_hilo_suppress_radius("contour_hilo_suppress_radius", 15.0, " New Magics: Parameter contour_hilo_suppress_radius sent to new Magics[HiLo].  ");
+static MagicsParameter<double> contour_hilo_max_value("contour_hilo_max_value", 1.0e+21, " New Magics: Parameter contour_hilo_max_value sent to new Magics[HiLo].  ");
+static MagicsParameter<double> contour_hilo_min_value("contour_hilo_min_value", -1.0e+21, " New Magics: Parameter contour_hilo_min_value sent to new Magics[HiLo].  ");
+static MagicsParameter<double> contour_hi_max_value("contour_hi_max_value", 1.0e+21, " New Magics: Parameter contour_hi_max_value sent to new Magics[HiLo].  ");
+static MagicsParameter<double> contour_hi_min_value("contour_hi_min_value", -1.0e+21, " New Magics: Parameter contour_hi_min_value sent to new Magics[HiLo].  ");
+static MagicsParameter<double> contour_lo_max_value("contour_lo_max_value", 1.0e+21, "");
+static MagicsParameter<double> contour_lo_min_value("contour_lo_min_value", -1.0e+21, "");
+static MagicsParameter<string> contour_hilo_marker("contour_hilo_marker", "off", "");
+#include "HiLoBoth.h"
+#include "HiLoText.h"
+#include "HiLoNumber.h"
+static SimpleObjectMaker<HiLoText, HiLoTechnique> text_HiLoText("text");
+static SimpleObjectMaker<HiLoNumber, HiLoTechnique> number_HiLoNumber("number");
+static SimpleObjectMaker<HiLoBoth, HiLoTechnique> both_HiLoBoth("both");
+#include "HiLoMarker.h"
+static SimpleObjectMaker<HiLoMarker, HiLoMarkerBase> on_HiLoMarker("on");
+static SimpleObjectMaker<HiLoMarker, HiLoMarkerBase> marker_HiLoMarker("marker");
+static SimpleObjectMaker<NoHiLoMarker, HiLoMarkerBase> off_NoHiLoMarker("off");
+static SimpleObjectMaker<NoHiLoMarker, HiLoMarkerBase> nomarker_NoHiLoMarker("nomarker");
diff --git a/src/visualisers/HiLoAttributes.h b/src/visualisers/HiLoAttributes.h
new file mode 100644
index 0000000..266dfa3
--- /dev/null
+++ b/src/visualisers/HiLoAttributes.h
@@ -0,0 +1,92 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HiLoAttributes.h
+    \brief Definition of HiLo Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef HiLoAttributes_H
+#define HiLoAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "HiLoTechnique.h"
+#include "HiLoMarkerBase.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HiLoAttributes 
+{
+public:
+//  --  constructor
+    HiLoAttributes();
+    
+//  --  destructor
+    virtual ~HiLoAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HiLoAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<HiLoTechnique> type_;
+	int window_size_;
+	double suppress_radius_;
+	double hilo_max_value_;
+	double hilo_min_value_;
+	double hi_max_value_;
+	double hi_min_value_;
+	double lo_max_value_;
+	double lo_min_value_;
+	auto_ptr<HiLoMarkerBase> marker_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HiLoAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoBase.h b/src/visualisers/HiLoBase.h
new file mode 100644
index 0000000..4715ecc
--- /dev/null
+++ b/src/visualisers/HiLoBase.h
@@ -0,0 +1,113 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoBase.h
+    \brief Definition of the Template class HiLoBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 9-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoBase_H
+#define HiLoBase_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+#include "BasicSceneObject.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+class MatrixHandler;
+
+class HiLoBase {
+
+public:
+	HiLoBase() {}
+	virtual ~HiLoBase() {}
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "HiLoBase::set(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "HiLoBase::set(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual HiLoBase* clone() const { return 0; }
+    virtual bool accept(const string&) { return false; }
+
+    virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << "HiLoBase::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+    }    
+    virtual BasicGraphicsObject* next() { 
+    	MagLog::dev() << "HiLoBase::next()---> to be checked!...\n";
+    	return 0; 
+    }
+    virtual bool more() { 
+    	MagLog::dev() << "HiLoBase:: more(---> to be checked!...\n";
+    	return false; 
+    }
+    virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&) {}
+    virtual void visit(LegendVisitor&) {
+    	MagLog::dev() << "HiLoBase::visit(LegendBase&)---> to be checked!...\n";
+    }
+    virtual void clear() {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "HiLoBase\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	HiLoBase(const HiLoBase&);
+    //! Overloaded << operator to copy - No copy allowed
+	HiLoBase& operator=(const HiLoBase&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoBase& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, HiLoBase > {
+public:
+	HiLoBase* operator()(const string& val )
+	{
+		return SimpleObjectMaker<HiLoBase >::create(val);
+	}     
+
+	HiLoBase* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HiLoBoth.h b/src/visualisers/HiLoBoth.h
new file mode 100644
index 0000000..5fa898e
--- /dev/null
+++ b/src/visualisers/HiLoBoth.h
@@ -0,0 +1,135 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoBoth.h
+    \brief Definition of the Template class HiLoBoth.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 24-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoBoth_H
+#define HiLoBoth_H
+
+#include "magics.h"
+
+#include "HiLo.h"
+#include "HiLoTechnique.h"
+
+#include "HiLoTextAttributes.h"
+#include "HiLoMarkerAttributes.h"
+#include "MagicsFormat.h"
+#include "Symbol.h"
+
+namespace magics {
+
+
+class HiLoBoth: public HiLoTechnique, public HiLoTextAttributes, public HiLoMarkerAttributes {
+
+public:
+	HiLoBoth() :high_(0), low_(0) {}
+	virtual ~HiLoBoth() {}
+    void set(const map<string, string>& map) { 
+        HiLoTechnique::set(map);
+
+        HiLoTextAttributes::set(map);
+        HiLoMarkerAttributes::set(map);
+    }
+     void set(const XmlNode& node) { 
+        HiLoTechnique::set(node);
+
+        HiLoTextAttributes::set(node);
+        HiLoMarkerAttributes::set(node);
+    }
+     virtual HiLoTechnique* clone() const {
+		HiLoBoth* object = new HiLoBoth();
+		object->clone(*this);
+	    return object;
+	}
+	virtual void clone(const HiLoBoth& from)
+	{
+		 HiLoTechnique::copy(from);
+
+        HiLoTextAttributes::copy(from);
+        HiLoMarkerAttributes::copy(from);
+	}
+	void clear() {
+		high_ = 0;
+		low_ = 0;
+	}
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "HiLoBoth"; }
+     virtual void operator()(const PaperPoint& point, HiLo& hilo) {
+
+        
+        if (!high_) {
+            // Create Text List containing the position of the High
+            high_ = new TextSymbol();
+            high_->setMarker(index_);
+            high_->setColour(*colour_);
+            high_->setHeight(height_);
+            hilo.push_back(high_);
+        }
+        
+        if (!low_) {
+            // Create Text List containing the position of the High
+            low_ = new TextSymbol();
+            low_->setMarker(index_);
+            low_->setColour(*colour_);
+            low_->setHeight(height_);
+            hilo.push_back(low_);
+        }
+       
+        
+        if ( point.high()) {         
+            high_->push_back(point,   hi_text_);
+        }
+        else if ( point.low()) {
+             low_->push_back(point,   hi_text_);
+        } 
+        else {
+            MagLog::warning() << "high/low information not set in point-> the point is ignored" << "\n";
+         }
+        
+       
+     }
+     TextSymbol* high_;
+     TextSymbol* low_;
+     
+private:
+    //! Copy constructor - No copy allowed
+	HiLoBoth(const HiLoBoth&);
+    //! Overloaded << operator to copy - No copy allowed
+	HiLoBoth& operator=(const HiLoBoth&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoBoth& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoMarker.h b/src/visualisers/HiLoMarker.h
new file mode 100644
index 0000000..c20ab6f
--- /dev/null
+++ b/src/visualisers/HiLoMarker.h
@@ -0,0 +1,127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoMarker.h
+    \brief Definition of the Template class HiLoMarker.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 22-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoMarker_H
+#define HiLoMarker_H
+
+#include "magics.h"
+#include "MatrixHandler.h"
+#include "PointsHandler.h"
+#include "HiLoMarkerBase.h"
+#include "HiLoMarkerAttributes.h"
+#include "Symbol.h"
+#include "HiLo.h"
+namespace magics {
+
+
+
+class HiLoMarker: public HiLoMarkerBase, public HiLoMarkerAttributes {
+
+public:
+	HiLoMarker() : marker_(0) {}
+	virtual ~HiLoMarker() {}
+    void set(const map<string, string>& map) { 
+        HiLoMarkerAttributes::set(map); 
+    }
+    void set(const XmlNode& node) { 
+        HiLoMarkerAttributes::set(node); 
+    }
+    virtual bool accept(const string& node) { return HiLoMarkerAttributes::accept(node); }
+   
+    virtual HiLoMarker* clone() const {
+		HiLoMarker* object = new HiLoMarker();
+		object->copy(*this);
+	    return object;
+	}
+    virtual void clear() { marker_ = 0; }
+   
+    virtual void operator()(const PaperPoint& point, HiLo& hilo) {
+        if ( !marker_) {
+            marker_ = new Symbol();
+            marker_->setMarker(index_);
+            marker_->setColour(*colour_);
+            marker_->setHeight(height_);
+            hilo.push_back(marker_); 
+        }
+        marker_->push_back(point);
+    }
+    
+    
+    
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { 
+         out << "HiLoMarker[";
+         HiLoMarkerAttributes::print(out);
+         out << "]";
+	 }
+     double scaling_;
+     Symbol* marker_;
+     
+
+private:
+    //! Copy constructor - No copy allowed
+	HiLoMarker(const HiLoMarker&);
+    //! Overloaded << operator to copy - No copy allowed
+	HiLoMarker& operator=(const HiLoMarker&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoMarker& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class NoHiLoMarker: public HiLoMarkerBase{
+
+public:
+	NoHiLoMarker() {}
+	virtual ~NoHiLoMarker() {}
+	virtual HiLoMarkerBase* clone() const {
+		HiLoMarkerBase* object = new NoHiLoMarker();
+	    return object;
+	}
+	virtual bool accept(const string& node) { return magCompare(node, "nohilo"); }
+
+    
+    
+        
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "No HiLo Marker defined"; } 
+  
+
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HiLoMarkerAttributes.h b/src/visualisers/HiLoMarkerAttributes.h
new file mode 100644
index 0000000..3d683c7
--- /dev/null
+++ b/src/visualisers/HiLoMarkerAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HiLoMarkerAttributes.h
+    \brief Definition of HiLoMarker Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef HiLoMarkerAttributes_H
+#define HiLoMarkerAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HiLoMarkerAttributes 
+{
+public:
+//  --  constructor
+    HiLoMarkerAttributes();
+    
+//  --  destructor
+    virtual ~HiLoMarkerAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HiLoMarkerAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double height_;
+	int index_;
+	auto_ptr<Colour> colour_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HiLoMarkerAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoMarkerBase.h b/src/visualisers/HiLoMarkerBase.h
new file mode 100644
index 0000000..3b05133
--- /dev/null
+++ b/src/visualisers/HiLoMarkerBase.h
@@ -0,0 +1,110 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoMarkerBase.h
+    \brief Definition of the Template class HiLoMarkerBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Fri 10-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoMarkerBase_H
+#define HiLoMarkerBase_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+class HiLo;
+
+
+class HiLoMarkerBase {
+	// act like NoHiloMarker!
+
+public:
+	HiLoMarkerBase() {}
+	virtual ~HiLoMarkerBase() {}
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "HiLoMarkerBase::set(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "HiLoMarkerBase::set(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) { return false; }
+    virtual HiLoMarkerBase* clone() const {
+        MagLog::dev() << "HiLoMarkerBase::set(const map<string, string&)---> to be checked!...\n";
+        return new HiLoMarkerBase();
+    }
+    virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << "HiLoMarkerBase::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+    }  
+    
+   
+    virtual void operator()(const PaperPoint&, HiLo&) {
+    	
+    	
+    }
+   
+    virtual void clear()  {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "HiLoMarkerBase:same as NoHiloMarker\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	HiLoMarkerBase(const HiLoMarkerBase&);
+    //! Overloaded << operator to copy - No copy allowed
+	HiLoMarkerBase& operator=(const HiLoMarkerBase&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoMarkerBase& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, HiLoMarkerBase > {
+public:
+	HiLoMarkerBase* operator()(const string& val )
+	{
+		return SimpleObjectMaker<HiLoMarkerBase >::create(val);
+	}     
+
+	HiLoMarkerBase* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HiLoNumber.h b/src/visualisers/HiLoNumber.h
new file mode 100644
index 0000000..d4a94d6
--- /dev/null
+++ b/src/visualisers/HiLoNumber.h
@@ -0,0 +1,110 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoNumber.h
+    \brief Definition of the Template class HiLoNumber.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 24-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoNumber_H
+#define HiLoNumber_H
+
+#include "magics.h"
+
+#include "HiLoTechnique.h"
+#include "HiLoNumberAttributes.h"
+#include "MagicsFormat.h"
+#include "Text.h"
+#include "HiLo.h"
+namespace magics {
+
+
+class HiLoNumber: public HiLoTechnique, public HiLoNumberAttributes {
+
+public:
+	HiLoNumber() {}
+	virtual ~HiLoNumber() {}
+    void set(const map<string, string>& map) { 
+        HiLoTechnique::set(map);
+        HiLoNumberAttributes::set(map);
+    }
+    void set(const XmlNode& node) { 
+        HiLoTechnique::set(node);
+        HiLoNumberAttributes::set(node);
+    }
+     virtual HiLoTechnique* clone() const {
+		HiLoNumber* object = new HiLoNumber();
+		object->clone(*this);
+	    return object;
+	}
+	virtual void clone(const HiLoNumber& from)
+	{
+		HiLoTechnique::copy(from);
+        HiLoNumberAttributes::copy(from);
+      
+	}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	  virtual void print(ostream& out) const { out << "HiLoNumber"; }
+     virtual void operator()(const PaperPoint& point, HiLo& hilo) {
+     	ostringstream nice;
+    	nice << MagicsFormat(this->format_, point.value()); 
+	
+       
+        if ( point.high()) {
+             Text* text = new Text();
+             text->addText(nice.str(), *this->hi_colour_, this->contour_hilo_height_);
+             hilo.push_back(text);
+             text->setBlanking(this->blanking_);
+             text->push_back(point);
+        }
+        else if ( point.low()) {
+             Text* text = new Text();
+             text->addText(nice.str(), *this->lo_colour_, this->contour_hilo_height_);
+             hilo.push_back(text);
+             text->setBlanking(this->blanking_);
+             text->push_back(point);
+        } 
+        else {
+            MagLog::warning() << "high/low information not set in point-> the point is ignored" << "\n";
+         }
+     }
+      
+private:
+    //! Copy constructor - No copy allowed
+	HiLoNumber(const HiLoNumber&);
+    //! Overloaded << operator to copy - No copy allowed
+	HiLoNumber& operator=(const HiLoNumber&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoNumber& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoNumberAttributes.h b/src/visualisers/HiLoNumberAttributes.h
new file mode 100644
index 0000000..f94aef6
--- /dev/null
+++ b/src/visualisers/HiLoNumberAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HiLoNumberAttributes.h
+    \brief Definition of HiLoNumber Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef HiLoNumberAttributes_H
+#define HiLoNumberAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HiLoNumberAttributes 
+{
+public:
+//  --  constructor
+    HiLoNumberAttributes();
+    
+//  --  destructor
+    virtual ~HiLoNumberAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HiLoNumberAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string format_;
+	bool blanking_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HiLoNumberAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoTechnique.cc b/src/visualisers/HiLoTechnique.cc
new file mode 100644
index 0000000..e442314
--- /dev/null
+++ b/src/visualisers/HiLoTechnique.cc
@@ -0,0 +1,52 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoTechnique.cc
+    \brief Implementation of the Template class HiLoTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 24-Jun-2004
+    
+    Changes:
+    
+*/
+
+#include "HiLoTechnique.h"
+
+using namespace magics;
+
+template <class P>
+HiLoTechnique<P>::HiLoTechnique() 
+{
+}
+
+template <class P>
+HiLoTechnique<P>::~HiLoTechnique() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+template <class P>	
+void HiLoTechnique<P>::print(ostream& out)  const
+{
+	out << "HiLoTechnique<P>";
+}
+
diff --git a/src/visualisers/HiLoTechnique.h b/src/visualisers/HiLoTechnique.h
new file mode 100644
index 0000000..38dbab0
--- /dev/null
+++ b/src/visualisers/HiLoTechnique.h
@@ -0,0 +1,94 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoTechnique.h
+    \brief Definition of the Template class HiLoTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 24-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoTechnique_H
+#define HiLoTechnique_H
+
+#include "magics.h"
+#include "HiLoTechniqueAttributes.h"
+
+
+
+namespace magics {
+
+class HiLo;
+
+
+class HiLoTechnique: public HiLoTechniqueAttributes {
+
+public:
+	HiLoTechnique() {}
+	virtual ~HiLoTechnique() {}
+	virtual HiLoTechnique* clone() {
+		HiLoTechnique* object = new HiLoTechnique();
+		object->copy(*this);
+	    return object;
+	}
+    virtual void operator()(const PaperPoint&, HiLo&) {}
+    virtual void clear() {}
+    void set(const map<string, string>& map) { HiLoTechniqueAttributes::set(map); }
+	void set(const XmlNode& node) { HiLoTechniqueAttributes::set(node); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	HiLoTechnique(const HiLoTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	HiLoTechnique& operator=(const HiLoTechnique&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+template<>
+class MagTranslator<string, HiLoTechnique > {
+public:
+	HiLoTechnique* operator()(const string& val ) {
+		 return SimpleObjectMaker<HiLoTechnique >::create(val);
+	}     
+    HiLoTechnique* magics(const string& param)
+    {
+       	HiLoTechnique* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoTechniqueAttributes.h b/src/visualisers/HiLoTechniqueAttributes.h
new file mode 100644
index 0000000..df0c674
--- /dev/null
+++ b/src/visualisers/HiLoTechniqueAttributes.h
@@ -0,0 +1,85 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HiLoTechniqueAttributes.h
+    \brief Definition of HiLoTechnique Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef HiLoTechniqueAttributes_H
+#define HiLoTechniqueAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HiLoTechniqueAttributes 
+{
+public:
+//  --  constructor
+    HiLoTechniqueAttributes();
+    
+//  --  destructor
+    virtual ~HiLoTechniqueAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HiLoTechniqueAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double contour_hilo_height_;
+	string contour_hilo_quality_;
+	auto_ptr<Colour> hi_colour_;
+	auto_ptr<Colour> lo_colour_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HiLoTechniqueAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HiLoText.h b/src/visualisers/HiLoText.h
new file mode 100644
index 0000000..67d93a2
--- /dev/null
+++ b/src/visualisers/HiLoText.h
@@ -0,0 +1,106 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HiLoText.h
+    \brief Definition of the Template class HiLoText.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 24-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HiLoText_H
+#define HiLoText_H
+
+#include "magics.h"
+
+#include "HiLoTechnique.h"
+#include "HiLoTextAttributes.h"
+#include "Text.h"
+#include "HiLo.h"
+namespace magics {
+
+
+class HiLoText: public HiLoTechnique, public HiLoTextAttributes {
+
+public:
+	HiLoText() : high_(0), low_(0) {}
+	virtual ~HiLoText() {}
+	void operator()(const PaperPoint& point, HiLo& hilo)
+	{
+		if (!high_)
+		{
+			// Create Text List containing the position of the High
+			high_ = new Text();
+			high_->addText(hi_text_, *this->hi_colour_, this->contour_hilo_height_);		
+			high_->setBlanking(this->blanking_);
+			hilo.push_back(high_);
+		}
+
+		if (!low_)
+		{
+			// Create Text List containing the position of the High
+			low_ = new Text();
+			low_->addText(lo_text_, *this->lo_colour_, this->contour_hilo_height_);			
+			low_->setBlanking(this->blanking_);
+			hilo.push_back(low_);
+		}
+       
+		
+
+		if ( point.high() ) 
+			high_->push_back(point);  
+		else if ( point.low() ) 
+			low_->push_back(point);
+		else   
+			MagLog::warning() << "high/low information not set in point-> the point is ignored" << "\n";
+	}
+	void clear() {
+		high_ = 0;
+		low_ = 0;
+	}
+	void set(const map<string, string>& map)
+	{ 
+		HiLoTechnique::set(map);
+		HiLoTextAttributes::set(map);
+	}
+
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { out << "HiLoText"; } 
+	Text* high_;
+	Text* low_;
+
+private:
+	//! Copy constructor - No copy allowed
+	HiLoText(const HiLoText&);
+	//! Overloaded << operator to copy - No copy allowed
+	HiLoText& operator=(const HiLoText&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HiLoText& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HiLoTextAttributes.h b/src/visualisers/HiLoTextAttributes.h
new file mode 100644
index 0000000..5f1b7a0
--- /dev/null
+++ b/src/visualisers/HiLoTextAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HiLoTextAttributes.h
+    \brief Definition of HiLoText Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef HiLoTextAttributes_H
+#define HiLoTextAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HiLoTextAttributes 
+{
+public:
+//  --  constructor
+    HiLoTextAttributes();
+    
+//  --  destructor
+    virtual ~HiLoTextAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HiLoTextAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string hi_text_;
+	string lo_text_;
+	bool blanking_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HiLoTextAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HistoIndividualMode.h b/src/visualisers/HistoIndividualMode.h
new file mode 100644
index 0000000..47b423e
--- /dev/null
+++ b/src/visualisers/HistoIndividualMode.h
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HistoIndividualMode.h
+    \brief Definition of the Template class HistoIndividualMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 18-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HistoIndividualMode_H
+#define HistoIndividualMode_H
+
+#include "magics.h"
+
+#include "HistoMode.h"
+#include "HistoIndividualModeAttributes.h"
+
+namespace magics {
+
+class Box;
+
+class HistoIndividualMode: public HistoMode, public HistoIndividualModeAttributes {
+
+public:
+	HistoIndividualMode();
+	virtual ~HistoIndividualMode();
+    
+    void set(const map<string, string>& map ) { HistoIndividualModeAttributes::set(map); }
+    void set(const XmlNode& node) { HistoIndividualModeAttributes::set(node); }
+    HistoMode* clone() const {
+    	HistoIndividualMode* object;
+    	object->copy(*this);
+    	return object;
+    }
+    
+    virtual void count(double, double);
+    virtual void setToFirst(Layout&);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     Box* addButton(int var, int val, Layout&);
+
+     map<double, int> map_;
+
+private:
+    //! Copy constructor - No copy allowed
+	HistoIndividualMode(const HistoIndividualMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	HistoIndividualMode& operator=(const HistoIndividualMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HistoIndividualMode& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HistoMode.h b/src/visualisers/HistoMode.h
new file mode 100644
index 0000000..3ce48e6
--- /dev/null
+++ b/src/visualisers/HistoMode.h
@@ -0,0 +1,98 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HistoMode.h
+    \brief Definition of the Template class HistoMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 18-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HistoMode_H
+#define HistoMode_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "VectorOfPointers.h"
+#include "BasicGraphicsObject.h"
+
+
+namespace magics {
+
+
+class Layout;
+
+class HistoMode {
+
+public:
+	HistoMode();
+	virtual ~HistoMode();
+    
+    virtual void set(const map<string, string>&) = 0; 
+    virtual void set(const XmlNode&) = 0; 
+    virtual HistoMode* clone() const = 0;
+     virtual void toxml(ostream&, int)  const {}
+    virtual void count(double, double) {}
+    virtual void setToFirst(Layout&) {}
+    virtual BasicGraphicsObject* next()  { return *(current_++); }
+    virtual bool more()     		    { return current_ != objects_.end(); }
+    string button(int);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     
+    VectorOfPointers<vector<BasicGraphicsObject*> >			    objects_;
+    VectorOfPointers<vector<BasicGraphicsObject*> >::iterator	current_;
+    static int count_;
+
+private:
+    //! Copy constructor - No copy allowed
+	HistoMode(const HistoMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	HistoMode& operator=(const HistoMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HistoMode& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, HistoMode> { 
+public:
+	HistoMode* operator()(const string& val ) {
+		 return SimpleObjectMaker<HistoMode>::create(val);
+	}     
+    HistoMode* magics(const string& param)
+    {
+        HistoMode* object;
+		ParameterManager::update(param, object);
+		return object;
+    }
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/HistoTableMode.h b/src/visualisers/HistoTableMode.h
new file mode 100644
index 0000000..2da850d
--- /dev/null
+++ b/src/visualisers/HistoTableMode.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HistoTableMode.h
+    \brief Definition of the Template class HistoTableMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 18-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef HistoTableMode_H
+#define HistoTableMode_H
+
+#include "magics.h"
+
+#include "HistoMode.h"
+#include "HistoTableModeAttributes.h"
+
+namespace magics {
+
+class HistoTableMode: public HistoMode, public HistoTableModeAttributes {
+
+public:
+	HistoTableMode();
+	virtual ~HistoTableMode();
+    void set(const map<string, string>& map ) { HistoTableModeAttributes::set(map); }
+       void set(const XmlNode& node) { HistoTableModeAttributes::set(node); }
+    HistoMode* clone() const {
+    	HistoTableMode* object;
+    	object->copy(*this);
+    	return object;
+    }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	HistoTableMode(const HistoTableMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	HistoTableMode& operator=(const HistoTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const HistoTableMode& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/Histogram.cc b/src/visualisers/Histogram.cc
new file mode 100644
index 0000000..cfe85bd
--- /dev/null
+++ b/src/visualisers/Histogram.cc
@@ -0,0 +1,343 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Histogram.cc
+    \brief Implementation of the Template class Histogram.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 18-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "Histogram.h"
+#include "Layout.h"
+#include "PointsHandler.h"
+#include "IntervalMap.h"
+#include "CartesianTransformation.h"
+
+using namespace magics;
+
+
+
+Histogram::Histogram()
+{
+}
+
+
+Histogram::~Histogram()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+
+void Histogram::print(ostream& out)  const
+{
+	out << "Histogram[";
+	HistogramAttributes::print(out);
+	out << "]";
+}
+
+
+void Histogram::bean(PointsHandler& points)
+{
+	points.setToFirst();
+	mean_ = 0;
+	population_ = 0;
+	while (points.more()) {
+		try {
+			double val = points.current().value();						
+			IntervalMap<int>::iterator count = counter_.get(val);
+			mean_ += val;
+			population_++;
+			count->second++;
+		}
+		catch (...)
+		{
+			//MagLog::debug() <<  points.current().value() << " is not in range..." << endl;
+		}
+
+		points.advance();
+	}
+	mean_ /= population_;
+
+}
+
+
+
+void Histogram::prepare(PointsHandler& points)
+{
+		levels_->set(*this);
+		levels_->calculate(points.min(), points.max(), false);
+	
+		
+		double delta=0;
+		LevelSelection::const_iterator min = levels_->begin();
+		LevelSelection::const_iterator max = levels_->begin();
+		++max;
+		while ( max != levels_->end())
+		{
+			if(levels_->end()-max != 1 || !same(*min,*max))
+			{			  
+		  		counter_.insert(make_pair(Interval(*min, *max), 0));
+			}
+			
+			//If it is the last interval and the min and max are the same 
+			//we just increase max by the size of the previous interval to
+			//have a proper bin.
+			else
+			{
+			  	counter_.insert(make_pair(Interval(*min, (*max)+delta), 0));
+			}
+			
+			delta=(*max)-(*min);
+			
+			min++;
+			max++;			  	
+			
+		}
+		bean(points);
+}
+
+
+static double xmin_;
+static double xmax_;
+static double ymin_;
+static double ymax_;
+//static double width_;
+static double height_;
+
+
+IntervalMap<int>& Histogram::histogram(const IntervalMap<Colour>& beans, PointsHandler& points)
+{
+
+	for ( IntervalMap<Colour>::const_iterator entry = beans.begin(); entry != beans.end(); ++entry) {
+		counter_.insert(make_pair(Interval(entry->first.min_, entry->first.max_), 0));
+	}
+	bean(points);
+	return counter_;
+}
+
+
+void Histogram::visit(const IntervalMap<Colour>& beans, Data& data, PointsHandler& points, HistoVisitor& visitor)
+{
+	MagLog::dev() << *this << endl;
+	CartesianTransformation* cartesian = new CartesianTransformation();
+
+	ostringstream mins;
+	ostringstream maxs;
+	ostringstream vals;
+	ostringstream cols;
+
+	if ( beans.empty() ) {
+		prepare(points);
+	}
+
+	else {
+		for ( IntervalMap<Colour>::const_iterator entry = beans.begin(); entry != beans.end(); ++entry) {
+				counter_.insert(make_pair(Interval(entry->first.min_, entry->first.max_), 0));
+		}
+		bean(points);
+	}
+
+	if ( points.empty() || counter_.empty() )
+		return;
+		 vector<int> y;
+				   vector<double> x;
+				   for ( IntervalMap<int>::const_iterator count = counter_.begin(); count != counter_.end(); ++count) {
+					   y.push_back(count->second );
+					   x.push_back(count->first.min_ )	;
+					   x.push_back(count->first.max_ )	;
+					   MagLog::dev() << "[" << count->first.min_ << "-" <<  count->first.max_ << "]-->" <<  count->second << endl;
+				   }
+
+				   MagLog::dev()<< "minx=" << *std::min_element(x.begin(), x.end()) << endl;
+				   MagLog::dev()<<  "maxx=" << *std::max_element(x.begin(), x.end()) << endl;
+				   xmin_ = *std::min_element(x.begin(), x.end());
+				   ymin_ = 0;
+				   xmax_ = *std::max_element(x.begin(), x.end());
+				   ymax_ = *std::max_element(y.begin(), y.end());
+
+				   if ( xmin_ == xmax_ ) xmax_ = xmin_ +1;
+				   if ( ymin_ == ymax_ ) ymax_ = ymin_ +1;
+
+
+				   double step = (ymax_ - ymin_)/5;
+
+				   	double log = log10(step);
+				   	double ws = pow(10., int(log));
+				   	double inc = ceil(step/ws)*ws;
+				   	vector<double> ticks;
+				   	for (double x = ymin_; x <= ymax_ +inc; x+=inc)
+				   		ticks.push_back(x);
+				   	ymax_ = ticks.back();
+				   	cartesian->setAutomaticX(true);
+				   	cartesian->setAutomaticY(true);
+				   	cartesian->setMinX(xmin_-width_*0.1);
+				   cartesian->setMinX(xmin_-width_*0.1);
+				   cartesian->setMaxX(xmax_+width_*0.1);
+				   cartesian->setMinY(-height_*0.1);
+				   MagLog::dev()<<  "maxy=" << *std::max_element(y.begin(), y.end()) << endl;
+				   cartesian->setMaxY(ymax_+height_*0.1);
+				   visitor.transformation(cartesian);
+	Polyline* frame = new Polyline();
+	frame->setColour(Colour("navy"));
+	frame->setThickness(1);
+	frame->setLineStyle(M_SOLID);
+	frame->push_back(PaperPoint(xmin_, ymin_));
+	frame->push_back(PaperPoint(xmax_, ymin_));
+	frame->push_back(PaperPoint(xmax_, ymax_));
+	frame->push_back(PaperPoint(xmin_, ymax_));
+	frame->push_back(PaperPoint(xmin_, ymin_));
+
+
+	double left = xmin_ - (width_*0.05);
+	double bottom = ymin_ - height_ *0.1;
+
+	double font_size =0.12;
+	for (vector<double>::iterator tick = ticks.begin(); tick!=ticks.end(); ++tick){
+		Text* val = new Text();
+		val->addText(*tick, Colour("navy"), font_size);
+		val->push_back(PaperPoint(left, *tick));
+		val->setVerticalAlign(MHALF);
+		val->setJustification(MRIGHT);
+		visitor.push_back(val);
+		Polyline* grid = new Polyline();
+			grid->setColour(Colour("grey"));
+			grid->setThickness(1);
+			grid->setLineStyle(M_DOT);
+			grid->push_back(PaperPoint(xmin_, *tick));
+			grid->push_back(PaperPoint(xmax_, *tick));
+			visitor.push_back(grid);
+		grid = new Polyline();
+			grid->setColour(Colour("navy"));
+			grid->setThickness(1);
+			grid->setLineStyle(M_SOLID);
+			grid->push_back(PaperPoint(xmin_-(width_*0.025), *tick));
+			grid->push_back(PaperPoint(xmin_, *tick));
+			visitor.push_back(grid);
+	}
+
+
+	double last=0.;
+	string sep;
+	Polyline* bar = 0;
+	int barCnt=0;
+	int barLabelFreq=1+(counter_.size()/10) - ((counter_.size()%10 == 0)?1:0);
+	
+	for ( IntervalMap<int>::const_iterator count = counter_.begin(); count != counter_.end(); ++count, barCnt++) {
+		Polyline* grid = new Polyline();
+					grid->setColour(Colour("grey"));
+					grid->setThickness(1);
+					grid->setLineStyle(M_DOT);
+					grid->push_back(PaperPoint(count->first.min_, ymin_));
+					grid->push_back(PaperPoint(count->first.min_, ymax_));
+					visitor.push_back(grid);
+		Colour colour = beans.find(count->first.min_, *colour_);
+		if (bar)
+			visitor.push_back(bar);
+
+		bar = new Polyline();
+		bar->setColour(Colour("navy"));
+		bar->setThickness(1);
+		bar->setLineStyle(M_SOLID);
+		
+		bar->setFilled(true);
+	    bar->setFillColour(colour);
+
+	    mins << sep << count->first.min_;
+	    maxs << sep << count->first.max_;
+	    vals << sep << count->second;
+	    cols << sep << colour.red() << ":" << colour.green() << ":"  << colour.blue(); 	
+	    
+	    sep = "/";
+
+		FillShadingProperties* shading = new FillShadingProperties();
+          
+		bar->setShading(shading);
+		bar->push_back(PaperPoint(count->first.min_, 0));
+		bar->push_back(PaperPoint(count->first.min_, count->second));
+		bar->push_back(PaperPoint(count->first.max_, count->second));
+		bar->push_back(PaperPoint(count->first.max_, 0));
+		bar->push_back(PaperPoint(count->first.min_, 0));
+
+		
+		if(barCnt % barLabelFreq ==0)
+		{
+			Text* from = new Text();
+			from->addText(count->first.min_, Colour("navy"), font_size);
+			from->setVerticalAlign(MTOP);
+			from->setJustification(MLEFT);
+			from->setAngle(45.);
+			from->push_back(PaperPoint(count->first.min_, bottom));
+		
+			/*Text* to = new Text();
+			to->addText(count->first.min_, Colour("navy"), font_size);
+			to->setVerticalAlign(MTOP);
+			to->push_back(PaperPoint(count->first.max_, bottom));*/
+
+			visitor.push_back(from);
+		}
+		//visitor.push_back(to);
+		/*grid = new Polyline();
+		grid->setColour(Colour("navy"));
+		grid->setThickness(1);
+		grid->setLineStyle(M_DASH);
+		grid->push_back(PaperPoint(xmin_, count->second));
+		grid->push_back(PaperPoint(count->first.min_, count->second));
+		visitor.push_back(grid);*/
+
+		Polyline* vert = new Polyline();
+			vert->setColour(Colour("navy"));
+			vert->setThickness(1);
+			vert->setLineStyle(M_SOLID);
+			vert->push_back(PaperPoint(count->first.min_, ymin_));
+			vert->push_back(PaperPoint(count->first.min_, ymin_ - (height_*0.025)));
+			visitor.push_back(vert);
+
+		last = count->first.max_;
+	}
+
+	Polyline* vert = new Polyline();
+				vert->setColour(Colour("navy"));
+				vert->setThickness(1);
+				vert->setLineStyle(M_SOLID);
+				vert->push_back(PaperPoint(last, ymin_));
+				vert->push_back(PaperPoint(last, ymin_ - (height_*0.025)));
+				visitor.push_back(vert);
+
+	if (bar)
+			visitor.push_back(bar);
+	data.setInfo("histogram_min", mins.str());
+	data.setInfo("histogram_max", maxs.str());
+	data.setInfo("histogram_val", vals.str());
+	data.setInfo("histogram_col", cols.str());
+
+	visitor.push_back(frame);
+}
+
+
+void Histogram::visit(LegendVisitor& legend)
+{
+}
diff --git a/src/visualisers/Histogram.h b/src/visualisers/Histogram.h
new file mode 100644
index 0000000..0ed55ed
--- /dev/null
+++ b/src/visualisers/Histogram.h
@@ -0,0 +1,112 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Histogram.h
+    \brief Definition of the Template class Histogram.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 18-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Histogram_H
+#define Histogram_H
+
+#include "magics.h"
+
+#include "Visdef.h"
+#include "HistogramAttributes.h"
+#include "IntervalMap.h"
+#include "HistoVisitor.h"
+
+namespace magics {
+
+
+class Histogram: 
+	public Visdef,
+	public HistogramAttributes, 
+	public LevelSelectionInterface {
+
+public:
+	Histogram();
+	virtual ~Histogram();
+    
+	    void operator()(Data&, BasicGraphicsObjectContainer& ) { assert(false); }
+	    void visit(LegendVisitor& legend);
+	    // Implements the set method ... 
+	    void set(const map<string, string>& map ) { HistogramAttributes::set(map); }
+		void set(const XmlNode& node ) { HistogramAttributes::set(node); }
+		
+		void visit(const IntervalMap<Colour>&, Data&, PointsHandler& data, HistoVisitor& parent);
+		
+		void prepare(PointsHandler& data);
+		void bean(PointsHandler& data);
+		IntervalMap<int>& histogram(const IntervalMap<Colour>&, PointsHandler&);
+
+		double mean() { return mean_; }
+		double population() { return population_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 int getCount() const { return count_; }
+	 int getTolerance() const { return tolerance_; }
+	 double getReference() const { return reference_; }
+	 double getInterval() const { return interval_; }
+	 double getMin() const { return min_; }
+	 double getMax() const { return max_; }
+	 floatarray getList()  const { return list_; }
+     
+	  IntervalMap<int> counter_;
+
+	  double mean_;
+	  int population_;
+
+private:
+    //! Copy constructor - No copy allowed
+	Histogram(const Histogram&);
+    //! Overloaded << operator to copy - No copy allowed
+	Histogram& operator=(const Histogram&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Histogram& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, Histogram  > {
+public:
+	Histogram* operator()(const string& val ) {
+		 return SimpleObjectMaker<Histogram  >::create(val);
+	}
+    
+	Histogram* magics(const string& param)
+	{
+		Histogram* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/HistogramAttributes.cc b/src/visualisers/HistogramAttributes.cc
new file mode 100644
index 0000000..30bcfea
--- /dev/null
+++ b/src/visualisers/HistogramAttributes.cc
@@ -0,0 +1,175 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HistogramAttributes.cc
+    \brief Implementation of Histogram Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:13 2012
+*/    
+
+#include "HistogramAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+HistogramAttributes::HistogramAttributes():
+	levels_(MagTranslator<string, LevelSelection>().magics("histogram_selection_type")),
+	min_(ParameterManager::getDouble("histogram_min_value")),
+	max_(ParameterManager::getDouble("histogram_max_value")),
+	count_(ParameterManager::getInt("histogram_level_count")),
+	tolerance_(ParameterManager::getInt("histogram_level_tolerance")),
+	reference_(ParameterManager::getDouble("histogram_reference_level")),
+	interval_(ParameterManager::getDouble("histogram_interval")),
+	list_(ParameterManager::getDoubleArray("histogram_level_list")),
+	colour_(MagTranslator<string, Colour>().magics("histogram_bar_colour")),
+	width_(ParameterManager::getDouble("histogram_bar_width"))
+{
+} 
+
+
+
+HistogramAttributes::~HistogramAttributes()
+{
+}
+
+    
+void HistogramAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(0);
+
+	setMember(prefix, "histogram_selection_type", levels_, params);
+	setAttribute(prefix, "histogram_min_value", min_, params);
+	setAttribute(prefix, "histogram_max_value", max_, params);
+	setAttribute(prefix, "histogram_level_count", count_, params);
+	setAttribute(prefix, "histogram_level_tolerance", tolerance_, params);
+	setAttribute(prefix, "histogram_reference_level", reference_, params);
+	setAttribute(prefix, "histogram_interval", interval_, params);
+	setAttribute(prefix, "histogram_level_list", list_, params);
+	setAttribute(prefix, "histogram_bar_colour", colour_, params);
+	setAttribute(prefix, "histogram_bar_width", width_, params);
+}
+
+void HistogramAttributes::copy(const HistogramAttributes& other)
+{
+	levels_ = auto_ptr<LevelSelection>(other.levels_->clone());
+	min_ = other.min_;
+	max_ = other.max_;
+	count_ = other.count_;
+	tolerance_ = other.tolerance_;
+	reference_ = other.reference_;
+	interval_ = other.interval_;
+	list_ = other.list_;
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	width_ = other.width_;
+} 
+
+
+bool HistogramAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "histogram")  )
+		return true;
+
+	if ( acceptNode(node, levels_) )
+		return true;
+	return false;
+}
+
+void HistogramAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "histogram") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), levels_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), levels_, *(*elt)); 
+	}
+}
+
+void HistogramAttributes::print(ostream& out)  const
+{
+	out << "HistogramAttributes[";
+	out << "levels = " << *levels_;
+	out << ", min = " << min_;
+	out << ", max = " << max_;
+	out << ", count = " << count_;
+	out << ", tolerance = " << tolerance_;
+	out << ", reference = " << reference_;
+	out << ", interval = " << interval_;
+	out << ", list = " << list_;
+	out << ", colour = " << *colour_;
+	out << ", width = " << width_;
+	out << "]" << "\n";
+}
+
+
+void HistogramAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"histogram\"";
+	 out << ", \"histogram_selection_type\":";
+	 levels_->toxml(out);
+	 out << ", \"histogram_min_value\":";
+	 niceprint(out,min_);
+	 out << ", \"histogram_max_value\":";
+	 niceprint(out,max_);
+	 out << ", \"histogram_level_count\":";
+	 niceprint(out,count_);
+	 out << ", \"histogram_level_tolerance\":";
+	 niceprint(out,tolerance_);
+	 out << ", \"histogram_reference_level\":";
+	 niceprint(out,reference_);
+	 out << ", \"histogram_interval\":";
+	 niceprint(out,interval_);
+	 out << ", \"histogram_level_list\":";
+	 niceprint(out,list_);
+	 out << ", \"histogram_bar_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"histogram_bar_width\":";
+	 niceprint(out,width_);
+}
+static MagicsParameter<string> histogram_selection_type("histogram_selection_type", "count", "");
+static MagicsParameter<double> histogram_min_value("histogram_min_value", -1.e21, "");
+static MagicsParameter<double> histogram_max_value("histogram_max_value", 1.e21, "");
+static MagicsParameter<int> histogram_level_count("histogram_level_count", 10, "");
+static MagicsParameter<int> histogram_level_tolerance("histogram_level_tolerance", 2, "");
+static MagicsParameter<double> histogram_reference_level("histogram_reference_level", 0.0, "");
+static MagicsParameter<double> histogram_interval("histogram_interval", 8.0, "");
+static MagicsParameter<floatarray> histogram_level_list("histogram_level_list", floatarray(), "");
+static MagicsParameter<string> histogram_bar_colour("histogram_bar_colour", "evergreen", "");
+static MagicsParameter<double> histogram_bar_width("histogram_bar_width", 1, "");
+#include "CountSelectionType.h"
+#include "IntervalSelectionType.h"
+#include "LevelListSelectionType.h"
+static SimpleObjectMaker<CountSelectionType, LevelSelection> count_CountSelectionType("count");
+static SimpleObjectMaker<IntervalSelectionType, LevelSelection> interval_IntervalSelectionType("interval");
+static SimpleObjectMaker<LevelListSelectionType, LevelSelection> list_LevelListSelectionType("list");
diff --git a/src/visualisers/HistogramLegendMethodAttributes.h b/src/visualisers/HistogramLegendMethodAttributes.h
new file mode 100644
index 0000000..e86fb5f
--- /dev/null
+++ b/src/visualisers/HistogramLegendMethodAttributes.h
@@ -0,0 +1,92 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file HistogramLegendMethodAttributes.h
+    \brief Definition of HistogramLegendMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef HistogramLegendMethodAttributes_H
+#define HistogramLegendMethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class HistogramLegendMethodAttributes 
+{
+public:
+//  --  constructor
+    HistogramLegendMethodAttributes();
+    
+//  --  destructor
+    virtual ~HistogramLegendMethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const HistogramLegendMethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	int label_frequency_;
+	bool histo_border_;
+	auto_ptr<Colour> histo_border_colour_;
+	bool histo_mean_;
+	int histo_mean_marker_;
+	auto_ptr<Colour> histo_mean_colour_;
+	double histo_mean_size_;
+	bool histo_max_;
+	auto_ptr<Colour> histo_grid_colour_;
+	LineStyle histo_grid_style_;
+	int histo_grid_thickness_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const HistogramLegendMethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ImageCalculateColourTechnique.h b/src/visualisers/ImageCalculateColourTechnique.h
new file mode 100644
index 0000000..bbbac32
--- /dev/null
+++ b/src/visualisers/ImageCalculateColourTechnique.h
@@ -0,0 +1,74 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImageCalculateColourTechnique.h
+    \brief Definition of the Template class ImageCalculateColourTechnique.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 11-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImageCalculateColourTechnique_H
+#define ImageCalculateColourTechnique_H
+
+#include "magics.h"
+
+#include "ImageCalculateColourTechniqueAttributes.h"
+#include "ColourTableDefinitionCompute.h"
+
+namespace magics {
+
+class ImageCalculateColourTechnique: public ImageCalculateColourTechniqueAttributes, public ColourTableDefinitionCompute {
+
+public:
+	ImageCalculateColourTechnique() {}
+	virtual ~ImageCalculateColourTechnique() {}
+	
+	void prepare() { ColourTableDefinitionCompute::set(*this); }
+	
+	void set(const  map<string, string>& map) { ImageCalculateColourTechniqueAttributes::set(map); }
+	void set(const  XmlNode& node) { ImageCalculateColourTechniqueAttributes::set(node); }
+	bool accept(const string& node ) { return ImageCalculateColourTechniqueAttributes::accept(node); }
+
+	const Colour& getMax() const { return *max_; }
+	const Colour& getMin() const { return *min_; }
+	const string& getDirection() const { return ImageCalculateColourTechniqueAttributes::direction_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "ImageCalculateColourTechnique[]"; }
+
+private:
+    //! Copy constructor - No copy allowed
+	ImageCalculateColourTechnique(const ImageCalculateColourTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImageCalculateColourTechnique& operator=(const ImageCalculateColourTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImageCalculateColourTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ImageListColourTechnique.h b/src/visualisers/ImageListColourTechnique.h
new file mode 100644
index 0000000..81c1512
--- /dev/null
+++ b/src/visualisers/ImageListColourTechnique.h
@@ -0,0 +1,71 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImageListColourTechnique.h
+    \brief Definition of the Template class ImageListColourTechnique.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 11-Jul-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImageListColourTechnique_H
+#define ImageListColourTechnique_H
+
+#include "magics.h"
+
+#include "ImageListColourTechniqueAttributes.h"
+#include "ColourTableDefinitionList.h"
+
+namespace magics {
+
+class ImageListColourTechnique: public ImageListColourTechniqueAttributes, public ColourTableDefinitionList {
+
+public:
+	ImageListColourTechnique() {}
+	virtual ~ImageListColourTechnique() {} 
+	
+	void prepare() { ColourTableDefinitionList::set(*this); }
+	void set(const  map<string, string>& map) { ImageListColourTechniqueAttributes::set(map); }
+	void set(const  XmlNode& node) { ImageListColourTechniqueAttributes::set(node); }
+	bool accept(const string& node ) { return ImageListColourTechniqueAttributes::accept(node); }
+
+	virtual stringarray getValues() const { return values_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out ) const { out <<  "ImageListColourTechnique[]"; }
+
+private:
+    //! Copy constructor - No copy allowed
+	ImageListColourTechnique(const ImageListColourTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImageListColourTechnique& operator=(const ImageListColourTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImageListColourTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ImagePlotting.cc b/src/visualisers/ImagePlotting.cc
new file mode 100644
index 0000000..f43a729
--- /dev/null
+++ b/src/visualisers/ImagePlotting.cc
@@ -0,0 +1,292 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImagePlotting.cc
+    \brief Implementation of the Template class ImagePlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 13-Apr-2005
+    
+    Changes:
+    
+*/
+
+#include "ImagePlotting.h"
+#include "Image.h"
+
+
+#include "LookupTableMode.h"
+#include "TeDataTypes.h"
+#include "TeRasterParams.h"
+#include "TeDecoderMemory.h"
+#include "TeRasterRemap.h"
+#include "TeProjection.h"
+#include "LegendVisitor.h"
+#include "RasterData.h"
+
+using namespace magics;
+
+
+ImagePlotting::ImagePlotting()
+{
+}
+
+
+ImagePlotting::~ImagePlotting()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void ImagePlotting::print(ostream& out)  const
+{
+	out << "ImagePlotting[";
+	ImagePlottingAttributes::print(out);
+	out << "]";
+}
+
+
+void ImagePlotting::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	// Reproject input data using Terralib routines
+	RasterData& rdin = data.raster(out.transformation());  //input data
+	RasterData  rdout;                 //output data
+	MagLog::dev() << "ImagePlotting::operator()---> NEEDS TO BE IMPLENTED" << endl;
+	
+	if ( !createOutputRaster(out, rdin,rdout) )
+	{
+	     MagLog::dev() << "ERROR: ImagePlotting::createOutputRaster:" << *this << "\n";
+	     return;
+	}
+
+	// Create output image from Terralib reprojected data
+	Image* object = new Image();
+	PaperPoint pp(rdout.getLowerLeftCorner().x(),rdout.getUpperRightCorner().y(),0.);
+	object->setOrigin(pp);
+	object->setWidth(rdout.getUpperRightCorner().x()-rdout.getLowerLeftCorner().x());
+	object->setHeight(rdout.getUpperRightCorner().y()-rdout.getLowerLeftCorner().y());
+	object->set(rdout.getRows(),rdout.getColumns());
+//	    object->setFormat(format_);
+
+
+    ColourTable& table = object->getColourTable();
+	table.push_back(Colour("none"));
+	//count--;
+        (*colourMethod_).set(table, count_-1);
+//
+
+	(*mode_)(*object, rdout);
+	//table.visit(legend_);
+	// When the image is ready, we give it to the task 
+	//(the task will be responsible to send it to the driver when necessary)
+	out.push_back(object);
+	
+}
+
+//
+// IMPORTANT: The 2 routines below (createOutputRaster and reproject) have
+// two important issues that needs to be addressed in the future:
+// 1. Speed performance: currently, the input image matrix (Magics++
+//    structure) is copied to the Terralib environment and, after the 
+//    processing, it is copied back to the Magics++ structure.
+// 2. Pixel size: currently, this value is hardcoded to TeUNSIGNEDSHORT
+//     *IF THIS IS CHANGED, THEN metview/src/Reprojection/ReprojectService.cc
+//     WILL ALSO NEED TO BE UPDATED*
+
+bool ImagePlotting::createOutputRaster(const BasicGraphicsObjectContainer& owner, RasterData& rdin, RasterData& rdout)
+{
+	int i,j;
+	static TeDecoderMemoryFactory theDecoderMemoryFactory("MEM");
+	
+	// Initialize Terralib raster structure for input data
+	// Initialise parameters
+	
+	TeRasterParams parin;
+	parin.ncols_  = rdin.getColumns();
+	parin.nlines_ = rdin.getRows();
+	parin.resx_   = abs(rdin.getXResolution());
+	parin.resy_   = abs(rdin.getYResolution());
+	parin.decName("MEM");
+	
+	parin.projection(&rdin.getProjection());
+	UserPoint ll = rdin.getLowerLeftCorner();
+	UserPoint ur = rdin.getUpperRightCorner();
+	parin.boundingBoxLinesColumns(ll.x(),ll.y(),ur.x(),ur.y(),rdin.getRows(),  rdin.getColumns(), TeBox::TeLOWERLEFT);
+	parin.nBands(1);
+	parin.setDataType(TeUNSIGNEDSHORT);
+	parin.setCompressionMode(TeRasterParams::TeNoCompression);
+
+	// Copy input image to the raster structure
+	TeRaster rastin(parin);
+	rastin.params().decName("MEM");
+	bool ok = rastin.init(parin);
+	for (i = 0; i < parin.nlines_; i++)
+		for (j = 0; j < parin.ncols_; j++)
+			rastin.setElement(j,i,rdin(i,j),0);
+
+	// Initialize Terralib raster structure for output data
+	// Initialise parameters
+	
+	TeRasterParams parout;
+	
+	const Transformation& transf = owner.transformation();
+	TeProjection& projout = const_cast<Transformation * >(&transf)->getProjection();
+
+	parout.projection(&projout);
+	double minX = transf.getMinPCX();  
+	double maxX = transf.getMaxPCX();  
+	double minY = transf.getMinPCY();  
+	double maxY = transf.getMaxPCY();  
+
+	// Set output resolution and compute image size
+	// Set the same x/y resolution
+	double width  = owner.absoluteWidth();
+	int ifreq = max(int(parin.ncols_/(pixelFrequency_*width)),1);
+	int nnx   = (parin.ncols_ - 1) / ifreq + 1;
+	double res = (maxX-minX)/double(nnx-1);
+
+	parout.boundingBoxResolution(minX,minY,maxX,maxY,res,res, TeBox::TeLOWERLEFT);
+	parout.decName("MEM");
+	parout.nBands(1);
+	parout.setDummy(0);
+	parout.setDataType(TeUNSIGNEDSHORT); // see note 2 above
+	parout.setCompressionMode(TeRasterParams::TeNoCompression);
+
+	// Initialise raster structure
+	TeRaster rastout(parout);
+	rastout.params().decName("MEM");
+	ok = rastout.init(parout);
+
+	// Reproject input data
+	TeRasterRemap reproj(&rastin,&rastout);
+	ok = reproj.apply();
+
+	// Copy output raster structure to output image
+    rdout.setColumns(parout.ncols_);
+	rdout.setRows(parout.nlines_);
+
+	rdout.setXResolution(parout.resx_);
+	rdout.setYResolution(parout.resy_);
+	// boundingBox or box function ???
+	rdout.setUpperRightCorner(parout.boundingBox().x2(), parout.boundingBox().y2());
+	rdout.setLowerLeftCorner(parout.boundingBox().x1(), parout.boundingBox().y1());
+	rdout.reserve(parout.nlines_*parout.ncols_);
+	double val;
+	for (i = 0; i < parout.nlines_; i++)
+	{
+		for (j = 0; j < parout.ncols_; j++)
+		{
+			if (!rastout.getElement(j,i,val,0) )
+				val = 0;
+           //points outside the rectangle image area is set
+           //to 0 by the Terralib interpolation procedure
+  		   rdout.push_back(val);
+		}
+	}
+
+	return ok;
+}
+
+
+void ImagePlotting::visit(LegendVisitor& legend)
+{
+	//(*mode_)(legend);
+}
+
+bool ImagePlotting::reproject(RasterData& rdin, RasterData& rdout,
+	Transformation& transformation, double resx, double resy)
+{
+	int i,j;
+	
+	static TeDecoderMemoryFactory theDecoderMemoryFactory("MEM");
+
+	// Initialize Terralib raster structure for input data
+	// Initialise parameters
+	TeRasterParams parin;
+	parin.ncols_  = rdin.getColumns();
+	parin.nlines_ = rdin.getRows();
+	parin.resx_   = abs(rdin.getXResolution());
+	parin.resy_   = abs(rdin.getYResolution());
+	parin.projection (&rdin.getProjection());
+	UserPoint ll = rdin.getLowerLeftCorner();
+	UserPoint ur = rdin.getUpperRightCorner();
+	parin.boundingBoxResolution(ll.x(),ll.y(),ur.x(),ur.y(), parin.resx_, parin.resy_);
+	parin.nBands(1);
+	parin.setDataType(TeUNSIGNEDSHORT);
+	//parin.compressionType_ = TeNoCompression;
+    parin.setCompressionMode(TeRasterParams::TeNoCompression);
+	parin.decName("MEM");
+
+	// Copy input image to the raster structure
+	TeRaster rastin(parin);
+	bool ok = rastin.init(parin);
+	for (i = 0; i < parin.nlines_; i++)
+		for (j = 0; j < parin.ncols_; j++)
+			rastin.setElement(j,i,rdin(i,j),0); //too slow???
+
+	// Initialize Terralib raster structure for output data
+	// Initialise parameters
+	TeRasterParams parout;
+	TeProjection& projout = const_cast<Transformation * >(&transformation)->getProjection();
+	parout.projection(&projout);
+	parout.decName("MEM");
+
+	double minX = transformation.getMinPCX();  
+	double maxX = transformation.getMaxPCX();  
+	double minY = transformation.getMinPCY();  
+	double maxY = transformation.getMaxPCY();  
+
+	// Set output resolution
+	parout.boundingBoxResolution(minX,minY,maxX,maxY,resx,resx);
+
+	parout.nBands(1);
+	parout.setDataType(TeUNSIGNEDSHORT);   // see note 2 above
+	//parout.compressionType_ = TeNoCompression;
+    parout.setCompressionMode(TeRasterParams::TeNoCompression);
+
+	// Initialise raster structure
+	TeRaster rastout(parout);
+	ok = rastout.init(parout);
+
+	// Reproject input data
+	TeRasterRemap reproj(&rastin,&rastout);
+	ok = reproj.apply();
+
+	// Copy output raster structure to output image
+        rdout.setColumns(parout.ncols_);
+	rdout.setRows(parout.nlines_);
+// no need	rdout.setProjection(&projout);
+	rdout.setXResolution(parout.resx_);
+	rdout.setYResolution(parout.resy_);
+	// boundingBox or box function ???
+	rdout.setUpperRightCorner(parout.boundingBox().x2(), parout.boundingBox().y2());
+	rdout.setLowerLeftCorner(parout.boundingBox().x1(), parout.boundingBox().y1());
+	rdout.reserve(parout.nlines_*parout.ncols_);
+	double val;
+	for (i = 0; i < parout.nlines_; i++)
+		for (j = 0; j < parout.ncols_; j++)
+		{
+			rastout.getElement(j,i,val,0); //too slow???
+			rdout.push_back(val);
+		}
+
+	return ok;
+}
diff --git a/src/visualisers/ImagePlotting.h b/src/visualisers/ImagePlotting.h
new file mode 100644
index 0000000..eb1d60b
--- /dev/null
+++ b/src/visualisers/ImagePlotting.h
@@ -0,0 +1,86 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImagePlotting.h
+    \brief Definition of the Template class ImagePlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 13-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImagePlotting_H
+#define ImagePlotting_H
+
+#include "magics.h"
+
+#include "Visdef.h"
+#include "ImagePlottingAttributes.h"
+#include "LegendVisitor.h"
+
+namespace magics {
+	
+
+
+class ImagePlotting: public Visdef, public ImagePlottingAttributes {
+
+public:
+	ImagePlotting();
+	virtual ~ImagePlotting();
+	
+	virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+	
+	void set(const map<string, string>& map) { ImagePlottingAttributes::set(map); }
+	void set(const XmlNode& node) { ImagePlottingAttributes::set(node); }
+	ImagePlotting* clone() const {
+		ImagePlotting* object = new ImagePlotting();
+		object->copy(*this);
+		return object;
+	}
+	
+	void visit(LegendVisitor&);
+
+	bool reproject(RasterData& in, RasterData& out, Transformation&, double, double);
+		
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 vector<LegendEntry* > legend_;
+	 
+
+private:
+    //! Copy constructor - No copy allowed
+	ImagePlotting(const ImagePlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImagePlotting& operator=(const ImagePlotting&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImagePlotting& p)
+		{ p.print(s); return s; }
+
+	bool createOutputRaster(const BasicGraphicsObjectContainer&, RasterData&, RasterData& );
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/ImagePlottingAttributes.h b/src/visualisers/ImagePlottingAttributes.h
new file mode 100644
index 0000000..ac8df03
--- /dev/null
+++ b/src/visualisers/ImagePlottingAttributes.h
@@ -0,0 +1,86 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ImagePlottingAttributes.h
+    \brief Definition of ImagePlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef ImagePlottingAttributes_H
+#define ImagePlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "LookupTableMode.h"
+#include "ColourTableDefinition.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ImagePlottingAttributes 
+{
+public:
+//  --  constructor
+    ImagePlottingAttributes();
+    
+//  --  destructor
+    virtual ~ImagePlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ImagePlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<LookupTableMode> mode_;
+	auto_ptr<ColourTableDefinition> colourMethod_;
+	int count_;
+	int pixelFrequency_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ImagePlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ImportPlot.h b/src/visualisers/ImportPlot.h
new file mode 100644
index 0000000..93092e4
--- /dev/null
+++ b/src/visualisers/ImportPlot.h
@@ -0,0 +1,152 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ImportPlot.h
+    \brief Definition of the Template class ImportPlot.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 6-Apr-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ImportPlot_H
+#define ImportPlot_H
+
+#include "magics.h"
+
+#include "ImportPlotAttributes.h"
+#include "Visdef.h"
+#include "ImportObject.h"
+#include "LegendVisitor.h"
+
+namespace magics {
+
+
+class OverlayPlot: public ImportPlotAttributes, public Visdef {
+
+public:
+	OverlayPlot() {}
+	virtual ~OverlayPlot() {}
+	void set(const map<string, string>& map) { ImportPlotAttributes::set(map); }
+
+	virtual void operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+	{
+		// Here we work on projection coordinates!
+		ImportObject* object = new ImportObject();
+	    object->setPath(data.path());
+	    object->setOrigin(PaperPoint(x_, y_));
+	    object->setWidth(width_);
+	    object->setHeight(height_);
+	    object->setFormat(format_);
+	    object->setOriginReference(ImportObject::bottom_left);
+	   
+	    if ( crs_.empty() ) {
+	    	    	visitor.push_back(object);
+	    	    	return;
+	    	    }
+	    	    // here we are doing a bit of cheking for metview 
+	    	    if ( crs_ != "EPSG:4326" ) {
+	    	    	MagLog::warning() << " Magics canot handle crs:" << crs_ << endl;
+	    	    	return;
+	    	    }
+	    	    
+	    
+	    
+	    
+	}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const 
+	 	{ out << "OverlayPlot["; ImportPlotAttributes::print(out); out << "]";  }
+ 
+private:
+    //! Copy constructor - No copy allowed
+	OverlayPlot(const OverlayPlot&);
+    //! Overloaded << operator to copy - No copy allowed
+	OverlayPlot& operator=(const OverlayPlot&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const OverlayPlot& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class ImportPlot: public ImportPlotAttributes, public Visdef {
+
+public:
+	ImportPlot() {}
+	virtual ~ImportPlot() {}
+	void set(const map<string, string>& map) { ImportPlotAttributes::set(map); }
+
+	virtual void operator()(Data& data, BasicGraphicsObjectContainer& visitor)
+	{				
+		ImportObject* object = new ImportObject();
+	    object->setPath(data.path());
+	    object->setOrigin(PaperPoint(x_, y_));
+	    object->setWidth(width_);
+	    object->setHeight(height_);
+	    object->setFormat(format_);
+	    object->setOriginReference(ImportObject::bottom_left);
+
+	    if ( crs_.empty() ) {
+	    	visitor.push_back(object);
+	    	return;
+	    } 
+	    // here we are doing a bit of cheking for metview 
+	    if ( !visitor.transformation().verifyDef(crs_) ) {
+	    	MagLog::warning() << " incompatible projections ( in " << crs_  << " and out) " << crs_ << endl;
+	    	return;
+	    }
+	    
+	   
+	    object->setOrigin(PaperPoint(crs_minx_, crs_miny_));
+	    object->setWidth(crs_maxx_ - crs_minx_);
+	    object->setHeight(crs_maxy_ - crs_miny_);
+	    visitor.push_back(object);
+	}
+	void visit(LegendVisitor& legend) {
+		legend.add(new EmptyEntry());
+	}
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const 
+	 	{ out << "ImportPlot["; ImportPlotAttributes::print(out); out << "]";  }
+ 
+private:
+    //! Copy constructor - No copy allowed
+	ImportPlot(const ImportPlot&);
+    //! Overloaded << operator to copy - No copy allowed
+	ImportPlot& operator=(const ImportPlot&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ImportPlot& p)
+		{ p.print(s); return s; }
+
+};
+
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/ImportPlotAttributes.h b/src/visualisers/ImportPlotAttributes.h
new file mode 100644
index 0000000..0218764
--- /dev/null
+++ b/src/visualisers/ImportPlotAttributes.h
@@ -0,0 +1,91 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ImportPlotAttributes.h
+    \brief Definition of ImportPlot Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef ImportPlotAttributes_H
+#define ImportPlotAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ImportPlotAttributes 
+{
+public:
+//  --  constructor
+    ImportPlotAttributes();
+    
+//  --  destructor
+    virtual ~ImportPlotAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ImportPlotAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string format_;
+	string system_;
+	double x_;
+	double y_;
+	double width_;
+	string crs_;
+	double crs_minx_;
+	double crs_maxx_;
+	double crs_miny_;
+	double crs_maxy_;
+	double height_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ImportPlotAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/IntervalSelectionType.cc b/src/visualisers/IntervalSelectionType.cc
new file mode 100644
index 0000000..54e87fc
--- /dev/null
+++ b/src/visualisers/IntervalSelectionType.cc
@@ -0,0 +1,109 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IntervalSelectionType.cc
+    \brief Implementation of the Template class IntervalSelectionType.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "IntervalSelectionType.h"
+#include "UserPoint.h"
+#include "PointsHandler.h"
+
+using namespace magics;
+
+IntervalSelectionType::IntervalSelectionType() 
+{
+}
+
+
+IntervalSelectionType::~IntervalSelectionType() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void IntervalSelectionType::print(ostream& out)  const
+{
+	out << "IntervalSelectionType[";
+    IntervalSelectionTypeAttributes::print(out);
+	out << "]";
+}
+
+void IntervalSelectionType::calculate(double min, double max, bool shading) 
+{
+	
+    clear();
+    //double maxi = data.max();
+    //double mini = data.min();
+	std::set<double> levels;
+	
+	double lmax, lmin;
+	if ( shading) {
+	    if (  same(max_,1.0e+21) ) {
+	    	max_ = max_shade_;    	
+	    }
+	    if (  same(min_, -1.0e+21) ) {
+	    	min_ = min_shade_;   	
+	    }
+	}
+    
+
+       lmax = 	same(max_,1.0e+21) ?  max :max_;
+       lmin = 	same(min_,-1.0e+21) ?  min :min_;
+
+   
+   
+       
+    levels.insert(lmax);
+    levels.insert(lmin);
+    
+    
+    double level = reference_;
+    while ( level <= lmax ) {
+    	if ( level > lmin )
+    		levels.insert(level);
+        level += interval_;
+    }
+    level = reference_;
+    while ( level >= lmin ) {
+        if ( level < lmax )
+        	levels.insert(level);
+        level -= interval_;
+    }
+           
+    for (std::set<double>::const_iterator level = levels.begin(); level != levels.end(); ++level) {
+    	MagLog::dev() << "IntervalSelectionType-->" << *level << "\n";
+    	push_back(*level);
+    }
+    	
+    
+}
+
+
+
+
diff --git a/src/visualisers/IntervalSelectionType.h b/src/visualisers/IntervalSelectionType.h
new file mode 100644
index 0000000..92a8805
--- /dev/null
+++ b/src/visualisers/IntervalSelectionType.h
@@ -0,0 +1,91 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IntervalSelectionType.h
+    \brief Definition of the Template class IntervalSelectionType.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef IntervalSelectionType_H
+#define IntervalSelectionType_H
+
+#include "magics.h"
+
+#include "IntervalSelectionTypeAttributes.h"
+#include "LevelSelection.h"
+
+namespace magics {
+
+class IntervalSelectionType: public IntervalSelectionTypeAttributes, public LevelSelection {
+
+public:
+	IntervalSelectionType();
+	virtual ~IntervalSelectionType();
+	void set(const map<string, string>& params) { 
+        IntervalSelectionTypeAttributes::set(params);
+        LevelSelection::set(params);
+    }
+    void set(const XmlNode& node) { 
+        IntervalSelectionTypeAttributes::set(node);
+        LevelSelection::set(node);
+    }
+    void set(const LevelSelectionInterface& from) { 
+    	reference_ = from.getReference();
+        interval_ = from.getInterval();
+        min_ = from.getMin();
+        max_ = from.getMax();
+    }
+    virtual LevelSelection* clone() const {
+    	IntervalSelectionType* object = new IntervalSelectionType();
+    	object->copy(*this);
+    	return object;
+    }
+    void copy(const IntervalSelectionType& from) {
+    	 IntervalSelectionTypeAttributes::copy(from);
+         LevelSelection::copy(from);
+    }
+
+    void calculate(double min, double max, bool); 
+    double reference() const { return reference_; }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	IntervalSelectionType(const IntervalSelectionType&);
+    //! Overloaded << operator to copy - No copy allowed
+	IntervalSelectionType& operator=(const IntervalSelectionType&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const IntervalSelectionType& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/IntervalSelectionTypeAttributes.h b/src/visualisers/IntervalSelectionTypeAttributes.h
new file mode 100644
index 0000000..7535238
--- /dev/null
+++ b/src/visualisers/IntervalSelectionTypeAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IntervalSelectionTypeAttributes.h
+    \brief Definition of IntervalSelectionType Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef IntervalSelectionTypeAttributes_H
+#define IntervalSelectionTypeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class IntervalSelectionTypeAttributes 
+{
+public:
+//  --  constructor
+    IntervalSelectionTypeAttributes();
+    
+//  --  destructor
+    virtual ~IntervalSelectionTypeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const IntervalSelectionTypeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double reference_;
+	double interval_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const IntervalSelectionTypeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Intervals.h b/src/visualisers/Intervals.h
new file mode 100644
index 0000000..9965c7c
--- /dev/null
+++ b/src/visualisers/Intervals.h
@@ -0,0 +1,81 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Intervals.h
+    \brief Definition of the Template class Intervals.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 9-Jun-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Intervals_H
+#define Intervals_H
+
+#include "magics.h"
+#include "MagLog.h"
+
+
+namespace magics {
+
+struct Interval
+{
+    Interval(double min = 0, double max = 0) : min_(min), max_(max) 
+        {
+            MagLog::debug() << "Interval[" << min_ << "," << max_ << "]" << "\n";
+        }
+    bool between(double val) const { 
+        //MagLog::debug() << min_ << "<" << val << "<" << max_ << "?" << "\n";
+        return (min_ <= val && val < max_); 
+    }
+    double min_;
+    double max_;
+};
+
+
+class Intervals : public vector<Interval> { 
+
+public:
+	Intervals(const doublearray&);
+	virtual ~Intervals();
+    double find(double val) const;
+    void set(const doublearray&);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	Intervals(const Intervals&);
+    //! Overloaded << operator to copy - No copy allowed
+	Intervals& operator=(const Intervals&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Intervals& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/IsoHelper.cc b/src/visualisers/IsoHelper.cc
new file mode 100644
index 0000000..0fbf248
--- /dev/null
+++ b/src/visualisers/IsoHelper.cc
@@ -0,0 +1,192 @@
+/*! \file IsoHelper.cc
+    \brief Implementation of the Template class IsoHelper.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Thu 11-Mar-2010
+    
+    Changes:
+    
+*/
+
+
+
+#include "IsoHelper.h"
+#include "AutoLock.h"
+#include "Timer.h"
+using namespace magics;
+
+
+IsoHelper::IsoHelper(int n, vector<Polyline* >& lines, IsoData& segments) :
+ n_(n), lines_(lines),data_(segments)
+{
+	
+}
+
+
+
+void IsoHelper::concatenate_back(vector<Polyline* >& lines, Polyline* poly) 
+{
+	double x = poly->back().x();
+	double y = poly->back().y();
+
+	vector<Polyline* >::iterator todelete =  lines.end();
+	for (vector<Polyline* >::iterator line = lines.begin(); line != lines.end(); ++line) {
+		if ( *line == poly || (*line)->empty() ) {
+			continue;
+		}
+		
+		if (same((*line)->front().x(), x) && same((*line)->front().y(), y) ) {
+			poly->push_back(**line);
+
+			delete (*line);
+			*line = 0;
+			lines.erase(line);
+			return;
+		}
+	}
+	
+
+}
+
+void IsoHelper::concatenate_front(vector<Polyline* >& lines, Polyline* poly) 
+{
+	double x = poly->front().x();
+	double y = poly->front().y();
+
+	vector<Polyline* >::iterator todelete  = lines.end();
+	for (vector<Polyline* >::iterator line = lines.begin(); line != lines.end(); ++line) {
+		if ( *line == poly || (*line)->empty() ) {
+			continue;
+		}
+		
+		if (same((*line)->back().x(), x) && same((*line)->back().y(), y) ) {
+			poly->push_front(**line);
+			delete (*line);
+						*line = 0;
+						lines.erase(line);
+						return;
+		}
+	}
+	
+	
+	if ( todelete !=   lines.end() )
+			lines.erase(todelete);
+		
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void IsoHelper::print(ostream& out)  const
+{
+	out << "IsoHelper[";
+	out << "]";
+}
+
+static Mutex locklines_;
+
+void IsoHelper::run()
+{
+	deque<pair<double, pair<pair<double, double>, pair<double, double > > > > todo;
+
+    int last = 0;
+    
+    while ( true) {
+    
+    {// Block
+             AutoLock<MutexCond> lock(data_.cond_);
+             while(data_.more_ && data_.segments_.size() < 2000 )
+                 data_.cond_.wait();
+
+             if(!data_.more_ && data_.segments_.empty() ) {
+				
+				for (map<double, vector<Polyline*> >::iterator level = helpers_.begin(); level != helpers_.end(); ++level) 
+					for (vector<Polyline* >::iterator line = level->second.begin(); line != level->second.end(); ++line) 
+							
+						if ( !(*line)->empty() ) { 
+							AutoLock<Mutex> locklines(locklines_);
+							lines_.push_back(*line);
+						}
+				
+				
+					helpers_.clear();
+            	 	return;
+     
+             }
+             {
+             AutoLock<Mutex> locklines(locklines_);
+             // Deal with the segmsts
+             if (data_.segments_.size() > 2000|| !data_.more_) {
+            	 todo.clear();
+            	 std::copy(data_.segments_.begin(),  data_.segments_.end(), back_inserter(todo));
+            	 data_.segments_.clear();
+             }
+             
+           // Deal with the triangles;
+             }
+                                  
+             data_.cond_.signal();
+    }
+    
+    {AutoLock<Mutex> locklines(locklines_);
+    for ( deque<pair<double, pair<pair<double, double>, pair<double, double > > > >::iterator x = todo.begin();
+            x != todo.end(); ++x) {
+        
+    	
+        pair<pair<double, double>, pair<double, double > >& segment = x->second;  
+        
+        
+        double x1 = segment.first.first;
+        double y1 = segment.first.second;
+        bool missing1 = false;
+        double x2 = segment.second.first;
+        double y2 = segment.second.second;
+        bool missing2 = false;
+	    
+       bool doit = true;
+       
+       map<double, vector<Polyline*> >::iterator h = helpers_.find(x->first);
+       if ( h == helpers_.end() ) {
+    	   helpers_.insert(make_pair(x->first,  vector<Polyline*>()));
+       }
+       vector<Polyline*>& helper = helpers_[x->first];
+       
+       int length = helper.size();
+      
+    
+	    for (unsigned int i = 0; i < helper.size(); i++ ) {
+	    	   int j = (i + last) % length;
+				// try to add to the back ! 
+	    	   Polyline* line = helper[j];
+	    	
+				if (same(line->back().x(), x1) && same(line->back().y(), y1) ) {
+
+					line->push_back(PaperPoint(x2, y2, x->first,
+							missing2));
+					// Check if we can concatenate with another line...
+					concatenate_back(helper, line);
+					doit = false;
+					last = j;
+					break;
+				}
+				if (same(line->front().x(), x2) && same(line->front().y(), y2) ) {
+					line->push_front(PaperPoint(x1, y1, x->first,
+							missing1));
+					concatenate_front(helper, line);
+					doit = false;
+					last = j;
+					break;
+				}
+	    }
+	    if (doit) {
+	    	    last = helper.size();
+				helper.push_back(new Polyline());
+				helper.back()->push_back(PaperPoint(x1, y1, x->first, missing1));
+				helper.back()->push_back(PaperPoint(x2, y2, x->first, missing2));
+			}
+    } // next todo
+    todo.clear();
+    }
+    }
+}
diff --git a/src/visualisers/IsoHelper.h b/src/visualisers/IsoHelper.h
new file mode 100644
index 0000000..a0bfae9
--- /dev/null
+++ b/src/visualisers/IsoHelper.h
@@ -0,0 +1,87 @@
+/*! \file IsoHelper.h
+    \brief Definition of the Template class IsoHelper.
+    
+    Magics Team - ECMWF 2010
+    
+    Started: Thu 11-Mar-2010
+    
+    Changes:
+    
+*/
+
+#ifndef IsoHelper_H
+#define IsoHelper_H
+
+#include "magics.h"
+
+#include "Thread.h"
+#include "MutexCond.h"
+#include "Polyline.h"
+#include "IntervalMap.h"
+
+
+
+namespace magics {
+
+
+
+struct IsoData {
+public:
+    IsoData() { more_ = true; }
+    deque<pair<double, pair<pair<double, double>, pair<double, double > > > > segments_;
+    //deque<Shape*> shapes_;
+    
+    bool more_;
+    MutexCond cond_;
+};
+
+
+class IsoHelper: public Thread {
+
+public:
+	
+	
+	IsoHelper(int, vector<Polyline* >&, IsoData& data);
+	void run();	
+	
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+    
+    
+	int      n_;
+	
+	vector<Polyline* >& lines_;
+    map<double, vector<Polyline*> > helpers_;
+  
+	
+	
+	double level_;
+	IsoData& data_; 
+		
+
+	
+	//void reduce(vector<Shape*>&); 
+    void concatenate_back(vector<Polyline* >& lines, Polyline* poly);
+    void concatenate_front(vector<Polyline* >& lines, Polyline* poly);
+
+private:
+    //! Copy constructor - No copy allowed
+	IsoHelper(const IsoHelper&);
+    //! Overloaded << operator to copy - No copy allowed
+	IsoHelper& operator=(const IsoHelper&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const IsoHelper& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/IsoHighlight.h b/src/visualisers/IsoHighlight.h
new file mode 100644
index 0000000..7eb8801
--- /dev/null
+++ b/src/visualisers/IsoHighlight.h
@@ -0,0 +1,155 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoHighlight.h
+    \brief Definition of the Template class IsoHighlight.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 25-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef IsoHighlight_H
+#define IsoHighlight_H
+
+#include "magics.h"
+
+#include "IsoHighlightAttributes.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "Polyline.h"
+#include "LevelSelection.h"
+
+namespace magics {
+
+class NoIsoHighlight  {
+
+public:
+	NoIsoHighlight() {}
+	virtual ~NoIsoHighlight() {}
+	virtual NoIsoHighlight* clone() const {
+    	NoIsoHighlight* plot = new NoIsoHighlight();
+    	return plot;
+    }
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual void toxml(ostream&, int = 0) const {}
+	virtual bool accept(const string&) { return true;}
+		
+    virtual void prepare(const LevelSelection&) {} 
+    virtual void visit(Polyline*& ) {
+    
+    } 
+  
+    
+    virtual void operator()(Polyline&) {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	NoIsoHighlight(const NoIsoHighlight&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoIsoHighlight& operator=(const NoIsoHighlight&);
+	// -- Friends
+	    //! Overloaded << operator to call print().
+		friend ostream& operator<<(ostream& s,const NoIsoHighlight& p)
+			{ p.print(s); return s; }
+};
+
+class IsoHighlight: public NoIsoHighlight, public map<double, double>, public IsoHighlightAttributes {
+
+public:
+	IsoHighlight() {}
+	virtual ~IsoHighlight() {}
+	virtual NoIsoHighlight* clone() const {
+    	IsoHighlight* plot = new IsoHighlight();
+    	plot->copy(*this);
+    	return plot;
+    }
+	virtual void set(const map<string, string>& map) { IsoHighlightAttributes::set(map); }
+		virtual void set(const XmlNode& node) {  IsoHighlightAttributes::set(node); }
+
+		virtual bool accept(const string& tag) { return  IsoHighlightAttributes::accept(tag);}
+		 virtual void visit(Polyline*& line) {
+			    line = new Polyline();
+				line->setColour(*this->colour_);   
+			    line->setLineStyle(style_);
+				line->setThickness(this->thickness_);
+				
+		 }
+    virtual void prepare(const LevelSelection& levels) 
+    { 
+    	vector<double> todo;
+    	clear();
+    	levels.thinLevels(frequency_, todo);
+    	for (LevelSelection::const_iterator level = todo.begin(); level != todo.end(); ++level) {
+    	      (*this)[*level] = *level;
+    	}
+    }
+    
+    virtual void operator()(Polyline& poly) {
+    	if (poly.empty()) return;
+        PaperPoint point = poly.back();
+        //MagLog::dev() << "HIGHTLIGHT?--->" << point << "=" << point.value() << "\n";
+        const_iterator high = find(poly.back().value());
+        if ( high == end() ) return;
+        poly.setColour(*colour_);
+        poly.setLineStyle(style_);
+        //MagLog::dev() << "set--->" << thickness_ << "\n";
+        poly.setThickness(thickness_);
+    }
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	IsoHighlight(const IsoHighlight&);
+    //! Overloaded << operator to copy - No copy allowed
+	IsoHighlight& operator=(const IsoHighlight&);
+    
+
+
+};
+
+
+
+template<>
+class MagTranslator<string, NoIsoHighlight> { 
+public:
+	NoIsoHighlight* operator()(const string& val ) {
+		 return SimpleObjectMaker<NoIsoHighlight>::create(val);
+	}     
+    NoIsoHighlight* magics(const string& param)
+    {
+        NoIsoHighlight* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/IsoHighlightAttributes.h b/src/visualisers/IsoHighlightAttributes.h
new file mode 100644
index 0000000..ab17a27
--- /dev/null
+++ b/src/visualisers/IsoHighlightAttributes.h
@@ -0,0 +1,86 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IsoHighlightAttributes.h
+    \brief Definition of IsoHighlight Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef IsoHighlightAttributes_H
+#define IsoHighlightAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class IsoHighlightAttributes 
+{
+public:
+//  --  constructor
+    IsoHighlightAttributes();
+    
+//  --  destructor
+    virtual ~IsoHighlightAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const IsoHighlightAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	LineStyle style_;
+	double reference_;
+	auto_ptr<Colour> colour_;
+	int thickness_;
+	int frequency_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const IsoHighlightAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/IsoLabel.cc b/src/visualisers/IsoLabel.cc
new file mode 100644
index 0000000..adbcc7f
--- /dev/null
+++ b/src/visualisers/IsoLabel.cc
@@ -0,0 +1,112 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoLabel.cc
+    \brief Implementation of the Template class IsoLabel.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "IsoLabel.h"
+#include "Label.h"
+#include "MagicsFormat.h"
+#include "Polyline.h"
+using namespace magics;
+
+IsoLabel::IsoLabel() 
+{
+	methods_["text"] = &IsoLabel::text;
+	methods_["number"] = &IsoLabel::number;
+	methods_["both"] = &IsoLabel::both;
+}
+
+
+IsoLabel::~IsoLabel() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void IsoLabel::print(ostream& out)  const
+{
+	out << "IsoLabel[";
+	out << "]";
+}
+
+void IsoLabel::operator()(Polyline& object, double l)  const
+{
+	const_iterator do_it = find(l);
+	if ( do_it == end() ) {
+        	return;
+	}
+    Colour colour =  ( colour_ == "contour_line_colour" ) ? object.getColour() : Colour(colour_);
+	std::map<string, Method>::const_iterator method = methods_.find(lowerCase(type_));
+
+	string text;
+	if ( method == methods_.end() )
+	{
+		MagLog::warning() << "contour_label_type: " << type_ << " is unknown : use number instead" << endl; 
+		text = number(l);
+	}
+	else 
+		text = (this->*method->second)(l);
+	
+	Label label(text);
+
+	label.setVisible(true);
+	label.setHeight(height_);
+	label.setBlanking(blanking_);
+	MagFont font(font_, "", height_); 
+	font.colour(colour );
+	label.font(font);
+	object.setLabel(label);
+} 
+
+
+void NoIsoLabel::operator()(Polyline& /*object*/, double) const
+{ 
+	Label label("");
+	label.setVisible(false);
+	//object.setLabel(label);
+}
+
+
+string IsoLabel::number(double l) const
+{
+	ostringstream nice;
+	nice << MagicsFormat(format_, l); 
+	return nice.str();
+}
+
+string IsoLabel::text(double ) const {
+	return text_;
+}
+
+string IsoLabel::both(double l) const
+{
+	return number(l) + " " + text_;
+}
+
diff --git a/src/visualisers/IsoLabel.h b/src/visualisers/IsoLabel.h
new file mode 100644
index 0000000..6092b49
--- /dev/null
+++ b/src/visualisers/IsoLabel.h
@@ -0,0 +1,135 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoLabel.h
+    \brief Definition of the Template class IsoLabel.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef IsoLabel_H
+#define IsoLabel_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "LevelSelection.h"
+#include "IsoLabelAttributes.h"
+
+namespace magics {
+
+class NoIsoLabel {
+
+public:
+	NoIsoLabel() {}
+	virtual ~NoIsoLabel() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual void toxml(ostream&, int = 0) const {}
+	virtual bool accept(const string&) { return true;}
+	
+	virtual NoIsoLabel* clone() const {
+		NoIsoLabel* object = new NoIsoLabel();	
+		return object;
+	}
+	virtual void operator()(Polyline&, double) const; 
+	virtual void prepare(const LevelSelection&) {}
+	virtual void prepare(const LevelSelection&, const string&) { }
+	virtual bool label() { return false; }
+
+protected:
+    //! Method to print string about this class on to a stream of type ostream (virtual).
+    virtual void print(ostream& out) const { out << "NoIsoLabel[]"; } 
+    
+	// -- Friends
+	    //! Overloaded << operator to call print().
+	    friend ostream& operator<<(ostream& s,const  NoIsoLabel& p)
+	        { p.print(s); return s; }
+}; 
+
+class IsoLabel: public NoIsoLabel, public map<double, double>, public IsoLabelAttributes {
+
+public:
+   IsoLabel();
+   virtual ~IsoLabel();
+
+   virtual IsoLabel* clone() const {
+     IsoLabel* object = new IsoLabel();
+     object->copy(*this);
+     return object;
+   }
+   virtual void set(const map<string, string>& map) {  IsoLabelAttributes::set(map); }
+   	virtual void set(const XmlNode& node){  IsoLabelAttributes::set(node); }
+
+   	virtual bool accept(const string& verb) { return  IsoLabelAttributes::accept(verb); }
+   virtual void operator()(Polyline&, double) const;
+   virtual bool label() { return true; }
+   virtual void prepare(const LevelSelection& levels, const string& colour)
+   {
+//        int label = 0;
+
+
+        // first we find the reference ...
+        vector<double> todo;
+        levels.thinLevels(frequency_, todo);
+        for (LevelSelection::const_iterator level = todo.begin(); level != todo.end(); ++level) {
+                (*this)[*level] = *level;
+        }
+    }
+
+protected:
+    //! Method to print string about this class on to a stream of type ostream (virtual).
+    virtual void print(ostream&) const;
+
+    typedef string (IsoLabel::*Method)(double) const;
+    std::map<string, Method> methods_;
+    string number(double) const;
+    string text(double) const;
+    string both(double) const;
+
+private:
+    //! Copy constructor - No copy allowed
+    IsoLabel(const IsoLabel&);
+    //! Overloaded << operator to copy - No copy allowed
+    IsoLabel& operator=(const IsoLabel&);
+};
+
+
+
+
+template<>
+class MagTranslator<string, NoIsoLabel> {
+public:
+    NoIsoLabel* operator()(const string& val ) {
+       return SimpleObjectMaker<NoIsoLabel>::create(val);
+    }
+    NoIsoLabel* magics(const string& param)
+    {
+		NoIsoLabel* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+} // namespace magics
+#endif
diff --git a/src/visualisers/IsoLabelAttributes.h b/src/visualisers/IsoLabelAttributes.h
new file mode 100644
index 0000000..a5324eb
--- /dev/null
+++ b/src/visualisers/IsoLabelAttributes.h
@@ -0,0 +1,89 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IsoLabelAttributes.h
+    \brief Definition of IsoLabel Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef IsoLabelAttributes_H
+#define IsoLabelAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class IsoLabelAttributes 
+{
+public:
+//  --  constructor
+    IsoLabelAttributes();
+    
+//  --  destructor
+    virtual ~IsoLabelAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const IsoLabelAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string type_;
+	string text_;
+	double height_;
+	string format_;
+	bool blanking_;
+	string font_;
+	string style_;
+	string colour_;
+	int frequency_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const IsoLabelAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/IsoPlot.cc b/src/visualisers/IsoPlot.cc
new file mode 100644
index 0000000..8fecd6b
--- /dev/null
+++ b/src/visualisers/IsoPlot.cc
@@ -0,0 +1,1781 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoPlot.cc  
+ \brief Implementation of the Template class IsoPlot.
+ 
+ Magics Team - ECMWF 2004
+ 
+ Started: Wed 3-Mar-2004
+  
+ Changes:
+ */
+ 
+ 
+#include "IsoPlot.h"
+#include "Factory.h"
+#include "MatrixHandler.h"
+#include "Timer.h"
+#include "UserPoint.h"
+#include "IsoHighlight.h"
+#include "Colour.h"
+#include "AutoLock.h"
+#include "ThreadControler.h"
+#include "LegendVisitor.h"
+#include "Histogram.h"
+
+
+
+namespace magics {
+  
+ static double testLevels;
+
+static MutexCond producerMutex_;
+
+ IsoPlot::IsoPlot() {
+    setTag("isoline");
+}
+
+ IsoPlot::~IsoPlot() {
+}
+
+/*!
+ Class information are given to the output-stream.
+ */
+ void IsoPlot::print(ostream& out) const {
+    out << "IsoPlot[";
+    IsoPlotAttributes::print(out);
+    out << "]";
+}
+
+
+/*! \brief Helper class for Countouring
+ * 
+ */
+
+class CellBox : public VectorOfPointers<vector<CellBox* > >
+{
+public:
+    CellBox(const CellArray* parent, int row1, int row2, int column1, int column2) :
+             parent_(parent), row1_(row1), row2_(row2), column1_(column1), column2_(column2) {
+        shape_ = 0;
+
+
+    }
+
+    CellBox(const CellArray* parent) :
+            parent_(parent), row1_(0), row2_(parent->rows_-1), column1_(0), column2_(parent->columns_-1) {
+        shape_ = 0;
+    }
+    
+    CellBox() :
+            parent_(0), row1_(0), row2_(0), column1_(0), column2_(0) {
+    		shape_ = 0;
+    }
+
+     ~CellBox() {
+
+
+    }
+   
+     double value () {
+        return (*parent_)(row1_, column1_)->value(0);
+    }
+    
+     RangeType range()
+    {
+        // First try to finfd iif the cell is outOfRange...
+        bool out = true;
+        for (int row = row1_; row <= row2_; row++) {
+            for (int column = column1_; column <= column2_; column++) {
+                if ((*parent_)(row, column)->range() != outOfRange)
+                {
+                    out = false;
+                    break;
+                }
+            }
+        }
+        if ( out )
+            return outOfRange;
+
+        bool oneout = false;
+        int min = INT_MAX;
+        int max = INT_MIN;
+        for (int row = row1_; row <= row2_; row++)
+        {
+           for (int column = column1_; column <= column2_; column++)
+           {
+             Cell* cell = (*parent_)(row, column);
+             RangeType range   = cell->range();
+             if ( range == outOfRange) {
+                 oneout = true;
+            	 continue;
+             }
+
+             if (range == multipleRange)
+                return multipleRange;
+
+             min = ( min < cell->min_ ) ? min : cell->min_;
+             max = ( max > cell->max_ ) ? max : cell->max_;
+             if (max-min > 0 ) 
+                return multipleRange; 
+           }
+        }
+        if ( max-min == 0 ) {
+        	if ( oneout )
+        		return multipleRange;
+        	return singleRange;
+        }
+
+    }
+
+    void reshape(vector<Shape*>& shapes, vector<Shape*>& out)
+    {
+    	Timer timer("reduce", "reduce");
+    }
+
+
+    void reshape(Shape* cell)
+    {
+        int index = cell->index_;
+        if ( index == -1 ) {
+        	delete cell;
+        	return;
+        }
+        if ( cell->points_.size() < 2 ) {
+
+        	delete cell;
+        	return;
+        }
+        cell->points_.push_back(cell->points_.front());
+
+        if (SegmentJoiner::isHole(cell->points_) )
+        	std::reverse(cell->points_.begin(), cell->points_.end());
+
+
+
+        HelperStruct::iterator entry = helper_.find(index);
+        if (entry == helper_.end() ) {
+            helper_.insert(make_pair(index, vector<Shape*>())) ;
+            entry = helper_.find(index);
+        }
+
+        entry->second.push_back(cell);
+
+    }
+
+    void reshape(CellBox* parent)
+    {
+        if ( parent == this) return;
+        for (HelperStruct::iterator entry = helper_.begin(); entry != helper_.end(); ++entry) {
+                    for (vector<Shape*>::iterator shape = entry->second.begin(); shape != entry->second.end(); ++shape) {
+                            parent->reshape(*shape);                    
+                }
+        }
+        helper_.clear();
+    }
+
+    void split();
+    
+     Shape* shape(int index)
+    {
+        if (!shape_)
+        {
+        	shape_ = new Shape();
+            Cell* cell;
+            
+            // bottom 
+            for (int column = column1_; column <= column2_; column++) {
+                cell = (*parent_)(row1_, column);
+                shape_->push_back(cell->column(0), cell->row(0));
+            }
+
+            // right
+            for (int row = row1_; row <= row2_; row++) {
+                cell = (*parent_)(row, column2_);
+                shape_->push_back(cell->column(1), cell->row(1));
+            }
+
+            for (int column = column2_; column >= column1_; column--) {
+                cell = (*parent_)(row2_, column);
+                shape_->push_back(cell->column(2), cell->row(2));
+            }
+
+            for (int row = row2_; row >= row1_; row--) {
+                cell = (*parent_)(row, column1_);    
+                shape_->push_back(cell->column(3), cell->row(3));
+            }
+        }
+        shape_->index_= index;
+        return shape_;
+    }
+    
+    void shade(const IsoPlot& owner);
+    
+
+    void shade(const IsoPlot& owner, CellBox* parent) {
+        RangeType def = range();
+        switch (def)
+        {
+          case outOfRange : 
+                break;
+
+          case singleRange: 
+
+
+                parent->reshape(shape(owner.shadingIndex(value())));
+
+                break;
+
+          default:
+                split();        
+                if (empty()) {
+                    assert( row1_ == row2_);
+                    assert( column1_ == column2_);
+                    owner.isoline(*(*parent_)(row1_, column1_), this);
+
+                }
+                else {
+                    for (CellBox::iterator cell = begin(); cell != end(); ++cell) {
+                        (*cell)->shade(owner, parent);
+                        (*cell)->reshape(parent);
+                }
+
+                }
+        }
+    }
+    
+
+
+    void contour(const IsoPlot& owner)
+    {
+           for (int row = row1_; row <= row2_; row++) {
+                        for (int column = column1_; column <= column2_; column++) {                                                    
+                                    owner.isoline(*(*parent_)(row, column));
+                        }
+            }            
+    }
+
+    void feed(IsoPlot& owner, BasicGraphicsObjectContainer& out)
+    {
+    	const Transformation& transformation = out.transformation();
+    	for (vector<Polyline*>::iterator poly = polylines_.begin(); poly != polylines_.end(); ++poly) {
+
+    		(*owner.shading_)(*poly);
+    		(*poly)->correct();
+    		if ( (*owner.shading_).needClipping()  ) {
+    			transformation(**poly, out);
+    			delete *poly;
+    		}
+    		else {
+    			out.push_back(*poly);
+    		}
+
+
+    	}
+    	polylines_.clear();
+    }
+
+    void finish()
+    {
+
+        Timer timer("Feed", "Feed");
+        for ( HelperStruct::iterator index = helper_.begin(); index!= helper_.end(); ++index) {
+        	if (index->first == -1) {
+				continue;
+        	}
+        	SegmentJoiner joiner;
+        	int count = 0;
+
+        	for ( vector<Shape*>::iterator s = index->second.begin(); s != index->second.end(); ++s) {
+        		vector<Point>& points = (*s)->points_;
+
+
+        		count += (*s)->points_.size();
+
+
+        	}
+        	joiner.reserve(count);
+
+        	//cout << "SegmentJoiner-->(" << count << " points)" << endl;
+        	// feed the joiner
+        	for ( vector<Shape*>::iterator s = index->second.begin(); s !=index->second.end(); ++s) {
+        		vector<Point>& points = (*s)->points_;
+
+
+        		if ( SegmentJoiner::isHole(points) ) {
+
+        			vector<Point>::reverse_iterator from = points.rbegin();
+        			vector<Point>::reverse_iterator to = points.rbegin();
+        			to++;
+        			while ( to != points.rend() ) {
+
+        				joiner.push_back(*from, *to);
+        				++from;
+        				++to;
+        			}
+        		}
+        		else {
+
+        			vector<Point>::iterator from = points.begin();
+        			vector<Point>::iterator to = points.begin();
+        			to++;
+        			while ( to != points.end() ) {
+        				//cout << *from << " " << *to << endl;
+        				joiner.push_back(*from, *to);
+        				++from;
+        				++to;
+        			}
+        		}
+        	}
+
+
+
+
+        	vector<vector<Point> > result;
+        	vector<vector<Point> > polys;
+        	list<vector<Point> > holes;
+        	//cout << "<---SegmentJoiner" << endl;
+
+
+        	joiner.computePolygonLines(result);
+
+        	Polyline* poly = 0;
+
+
+
+            	 for(vector<vector<Point> >::iterator j = result.begin() ; j != result.end(); ++j) {
+            	        if(joiner.isHole((*j))) {
+            	            holes.push_back(vector<Point>());
+            	            std::swap((*j),holes.back());
+            	        }
+            	        else {
+            	            polys.push_back(vector<Point>());
+            	            std::swap((*j),polys.back());
+            	        }
+            	    }
+
+            	 for(vector<vector<Point> >::iterator j = polys.begin() ; j != polys.end(); ++j) {
+
+            		 poly = new Polyline();
+            		             	polylines_.push_back(poly);
+            		             	poly->reserve(j->size());
+
+
+            		             		poly->index(index->first);
+
+            		             	for (vector<Point>::iterator point = j->begin(); point != j->end(); ++point)
+            		             		poly->push_back(PaperPoint(point->x_, point->y_));
+
+
+            	        for(list<vector<Point> >::iterator h = holes.begin() ; h != holes.end(); ) {
+            	            list<vector<Point> >::iterator next = h; next++;
+
+
+            	            	if ( joiner.pointInPoly((*h).front(), *j) ) {
+
+
+            	            	poly->newHole();
+            	            	for (vector<Point>::iterator point = h->begin(); point != h->end(); ++point)
+            	            	   poly->push_back_hole(PaperPoint(point->x_, point->y_));
+
+            	            	 holes.erase(h);
+            	            }
+            	            h = next;
+            	        }
+
+            	 }
+
+        }
+
+        // Release the memory.
+        for ( HelperStruct::iterator colour = helper_.begin(); colour!= helper_.end(); ++colour) {
+        	for ( vector<Shape*>::iterator s = colour->second.begin(); s !=colour->second.end(); ++s) {
+        		delete *s;
+        		*s = 0;
+        	}
+        	colour->second.clear();
+
+        }
+
+        }
+    
+    Shape* shape_;
+    const CellArray* parent_;
+    int row1_;
+    int row2_;
+    int column1_;
+    int column2_;
+
+    typedef map<int, vector<Shape*> > HelperStruct;
+
+    HelperStruct helper_;
+    vector<Polyline*> polylines_;
+};
+
+
+}  // end magics namespace
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+void CellBox::shade(const IsoPlot& owner) {
+        shade(owner, this);
+}
+
+
+
+void CellBox::split()
+{
+    if ( row1_ == row2_ && column1_ ==  column2_ ) 
+            return;
+
+    const int row    = (row2_   + row1_) /2;
+    const int column = (column2_+ column1_)/2;
+
+    if (row2_- row1_ > 1&& column2_- column1_ > 1)
+    {
+       //try first 2 split in columns ...
+       CellBox* cell = new CellBox(parent_, row1_, row2_, column1_, column);
+       RangeType def = cell->range();
+            
+       if ( def != multipleRange ) {
+             push_back(cell);
+       }
+       else {
+             delete cell;
+             push_back(new CellBox(parent_, row1_, row, column1_, column));
+             push_back(new CellBox(parent_, row+1, row2_, column1_, column));
+       }
+       cell = new CellBox(parent_, row1_, row2_, column+1, column2_);
+       def = cell->range();
+
+       if ( def != multipleRange ) {
+             push_back(cell);
+       }
+       else {
+             delete cell;
+             push_back(new CellBox(parent_, row1_, row, column+1, column2_));
+             push_back(new CellBox(parent_, row+1, row2_, column+1, column2_));
+       }
+       return;
+    }
+
+    if (row2_- row1_ > 0) {
+       push_back(new CellBox(parent_, row1_, row, column1_, column2_));
+       push_back(new CellBox(parent_, row+1, row2_, column1_, column2_));
+       return;
+    }
+
+    if (column2_- column1_ > 0) {
+       push_back(new CellBox(parent_, row1_, row2_, column1_, column));
+       push_back(new CellBox(parent_, row1_, row2_, column+1, column2_));
+       return;
+    }
+}
+
+
+
+
+
+struct IsoProducerData {
+public:
+        IsoProducerData(bool shading, IsoPlot& parent, CellBox& cell):
+              shading_(shading), parent_(parent), cell_(cell) {
+           more_ = true;
+        }  
+        bool shading_;
+        IsoPlot& parent_;
+        CellBox& cell_;
+        bool more_;
+        MutexCond cond_;
+};
+
+
+class IsoProducer: public Thread {
+
+public:    
+    IsoProducer(int n, IsoProducerData& data) : n_(n), objects_(data) {}
+    void run()
+    {
+    	{
+    		Timer timer("cell", "shading");
+    		( objects_.shading_ ) ? objects_.cell_.shade(objects_.parent_) : objects_.cell_.contour(objects_.parent_);
+
+    	}
+        objects_.cell_.finish();
+    }
+     ~IsoProducer() {}
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+     void print(ostream&) const {}
+    int n_;
+    IsoProducerData&  objects_;
+
+private:
+    //! Copy constructor - No copy allowed
+    IsoProducer(const IsoProducer&);
+    //! Overloaded << operator to copy - No copy allowed
+    IsoProducer& operator=(const IsoProducer&);
+
+    // -- Friends
+    //! Overloaded << operator to call print().
+    friend ostream& operator<<(ostream& s,const IsoProducer& p)
+        { p.print(s); return s; }
+};
+
+
+
+
+void IsoPlot::isoline(Cell& cell, CellBox* box) const
+{
+   static int cases[3][3][3] = { { { 0, 1, 2 },   { 3, 4, 5 },    { 6, 7, 8 } }, 
+                               { { 9, 10, 11 }, { 12, 13, 14 }, { 15, 16, 17 } }, 
+                               { { 18, 19, 20 },{ 21, 22, 23 }, { 24, 25, 0 } } };
+   int p1, p2, p3;
+   int current;
+   double x1=0, x2=0, y1=0, y2=0;
+
+   RangeType def = cell.range();
+
+   if ( def == outOfRange )
+        return;
+   if ( def == singleRange )
+   {
+        if ( !box  ) // NO Shading == Nothing to do! 
+            return;
+        else {
+            const double contour = levels_[cell.min_];
+            Shape* x = new Shape();
+            for (int i = 0; i < 4; i++) {
+                    x->push_back(cell.column(i), cell.row(i));            
+            }
+            x->index_  = shading_->shadingIndex(cell.value(0));
+            box->reshape(x);
+            return;
+        }
+   }
+
+   for (int p=0; p<2; p++)
+   {
+        p1 = p;
+        p2 = p1+1;
+        p3 = 3;
+
+        //int count = 0;
+        if (cell.missing(p1) || cell.missing(p2) || cell.missing(p3)) {
+
+        continue;
+        }
+
+
+        vector<pair<Shape*, Shape*> > shapes;
+        
+        // First, build the list of isolines in this triangle...
+        vector<int> levels;        
+
+        for (int l = cell.min_; l != cell.max_; ++l) {
+            const double contour = levels_[l];
+            const int    out     = cases[cell.coef(p1, contour)][cell.coef(p2, contour)][cell.coef(p3, contour)];
+            if ( out != 0 ) {
+                levels.push_back(l);
+            }
+        }
+        
+        if ( levels.empty() && box ) {
+
+            Shape* shape = new Shape(shading_->shadingIndex(cell.value(p1)));
+            shape->push_back(cell.column(p1), cell.row(p1));
+            shape->push_back(cell.column(p2), cell.row(p2));
+            shape->push_back(cell.column(p3), cell.row(p3));
+
+
+            box->reshape(shape);
+
+        }
+        else {
+
+    bool complex = ( levels.size() > 1);
+    for (vector<int>::const_iterator l = levels.begin(); l != levels.end(); ++l)
+    {
+        int level = *l;                
+        // First make a quich check to see if there is at l
+        
+        const double contour=levels_[level];
+
+
+        current = cases[cell.coef(p1, contour)][cell.coef(p2, contour)][cell.coef(p3, contour)];
+
+        int add = 2;
+        Shape* leftcell  = (box) ? new Shape(shading_->leftIndex(contour))  :0;
+        Shape* rightcell = (box) ? new Shape(shading_->rightIndex(contour)) :0;
+        
+
+        switch (current)
+        {
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 0 -point out!
+        //-------------------------------------------------------------------------------------------------------
+        case 0:
+            add = 0;
+            break;
+            if ( !box ) break;
+            
+            if (cell.height(p1, contour) < 0) {
+                leftcell->push_back(cell.column(p1), cell.row(p1));
+                leftcell->push_back(cell.column(p2), cell.row(p2));
+                leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                rightcell->push_back(cell.column(p1), cell.row(p1));
+                rightcell->push_back(cell.column(p2), cell.row(p2));
+                rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 1 -Single point 3
+        //-------------------------------------------------------------------------------------------------------
+        case 1:
+            x1=cell.column(p3);
+            y1=cell.row(p3);
+            add = 1;
+            if ( !box) break;
+            if (cell.height(p1, contour) < 0) {
+                leftcell->push_back(cell.column(p1), cell.row(p1));
+                leftcell->push_back(cell.column(p2), cell.row(p2));
+                leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                rightcell->push_back(cell.column(p1), cell.row(p1));
+                rightcell->push_back(cell.column(p2), cell.row(p2));
+                rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 2 - Line between sides 2-3 and 3-1
+        //-------------------------------------------------------------------------------------------------------
+        case 2:
+            cell.xysect(p2,p3, contour, x1, y1);
+            cell.xysect(p3,p1, contour, x2, y2);
+        
+            if ( !box ) break;
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+            
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 3 -Single point 2
+        //-------------------------------------------------------------------------------------------------------
+        case 3:
+            x1=cell.column(p2);
+            y1=cell.row(p2);
+            add = 1;
+            if ( !box) break;
+            
+            if (cell.height(p1, contour) < 0) {
+                  leftcell->push_back(cell.column(p1), cell.row(p1));
+                  leftcell->push_back(cell.column(p2), cell.row(p2));
+                  leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                  rightcell->push_back(cell.column(p1), cell.row(p1));
+                  rightcell->push_back(cell.column(p2), cell.row(p2));
+                  rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 4 - Line between vertex 2 and vertex 3
+        //-------------------------------------------------------------------------------------------------------
+        case 4:
+            
+            x1=cell.column(p2);
+            y1=cell.row(p2);
+            x2=cell.column(p3);
+            y2=cell.row(p3);
+            if ( !box ) break;
+            
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 5 - Line between vertex 2 and side 3-1
+        //-------------------------------------------------------------------------------------------------------
+        case 5:            
+            x1=cell.column(p2);
+            y1=cell.row(p2);
+            
+            cell.xysect(p3,p1, contour,x2, y2);
+            if ( !box ) break;
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            rightcell->push_back(x2, y2);   
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 6 - Line between side 1-2  and side 2.3
+        //-------------------------------------------------------------------------------------------------------
+        case 6:
+            
+            cell.xysect(p1,p2, contour, x1, y1);
+            cell.xysect(p2,p3, contour, x2, y2);
+    
+            if ( !box ) break;
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+            
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(x2, y2);
+            
+            break;
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 7 - Line between sides 1-2 aanve vertex 3
+        //-------------------------------------------------------------------------------------------------------
+        case 7:
+            cell.xysect(p1,p2, contour, x1, y1);
+            x2=cell.column(p3);
+            y2=cell.row(p3);
+            
+            if ( !box ) break;
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 8 - Line between sides 1-2 and 3-1
+        //-------------------------------------------------------------------------------------------------------
+        case 8:            
+            cell.xysect(p1,p2, contour, x1, y1);
+            cell.xysect(p3,p1, contour, x2, y2);
+            
+            if ( !box ) break;
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            rightcell->push_back(x2, y2);            
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 9 -single point 1
+        //-------------------------------------------------------------------------------------------------------
+        case 9:            
+            x1=cell.column(p1);
+            y1=cell.row(p1);
+            add = 1;
+            if ( !box) break;
+            if (cell.height(p2, contour) < 0) {
+                   leftcell->push_back(cell.column(p1), cell.row(p1));
+                   leftcell->push_back(cell.column(p2), cell.row(p2));
+                   leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                   rightcell->push_back(cell.column(p1), cell.row(p1));
+                   rightcell->push_back(cell.column(p2), cell.row(p2));
+                   rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 10 - Line between vertex 3 and vertex 1
+        //-------------------------------------------------------------------------------------------------------
+        case 10:
+            
+            x1=cell.column(p3);
+            y1=cell.row(p3);
+            x2=cell.column(p1);
+            y2=cell.row(p1);
+            if ( !box) break;
+
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 11 - Line between side 3-2 and vertex 1
+        //-------------------------------------------------------------------------------------------------------
+        case 11:
+            cell.xysect(p3,p2, contour, x1, y1);
+            x2=cell.column(p1);
+            y2=cell.row(p1);
+            if ( !box ) break;
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+            leftcell->push_back(x1, y1);
+            
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 12 - Line between vertex 1 and vertex 2
+        //-------------------------------------------------------------------------------------------------------
+        case 12:
+            x1=cell.column(p1);
+            y1=cell.row(p1);
+            x2=cell.column(p2);
+            y2=cell.row(p2);
+            if ( !box ) break;
+        
+            leftcell->push_back(cell.column(p1), cell.row(p1));
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 13 - Flat Area all vertex have the isoline value!
+        //-------------------------------------------------------------------------------------------------------
+        case 13:
+            add = 0;
+            if ( !box ) break;
+            if (cell.height(p1, contour) < 0) {
+                   leftcell->push_back(cell.column(p1), cell.row(p1));
+                   leftcell->push_back(cell.column(p2), cell.row(p2));
+                   leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                   rightcell->push_back(cell.column(p1), cell.row(p1));
+                   rightcell->push_back(cell.column(p2), cell.row(p2));
+                   rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 14 - Line between vertex 2 and vertex 1
+        //-------------------------------------------------------------------------------------------------------
+        case 14:
+            x1=cell.column(p2);
+            y1=cell.row(p2);
+            x2=cell.column(p1);
+            y2=cell.row(p1);
+            if ( !box ) break;
+            
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 15 - Line between vertex 1 and side3-2
+        //-------------------------------------------------------------------------------------------------------
+        case 15:
+            x1=cell.column(p1);
+            y1=cell.row(p1);
+            cell.xysect(p3,p2, contour, x2, y2);
+            if ( !box ) break;
+
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+            
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 16 - Line between vertex 1 and vertex 3
+        //-------------------------------------------------------------------------------------------------------
+        case 16:
+            x1=cell.column(p1);
+            y1=cell.row(p1);
+            x2=cell.column(p3);
+            y2=cell.row(p3);
+            if ( !box ) break;
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(x2, y2);
+
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 17 - single point 1
+        //-------------------------------------------------------------------------------------------------------
+        case 17:
+            x1=cell.column(p1);
+            y1=cell.row(p1);
+            add = 1;
+            if ( !box ) break;
+            if (cell.height(p2, contour) < 0) {
+                      leftcell->push_back(cell.column(p1), cell.row(p1));
+                      leftcell->push_back(cell.column(p2), cell.row(p2));
+                      leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                      rightcell->push_back(cell.column(p1), cell.row(p1));
+                      rightcell->push_back(cell.column(p2), cell.row(p2));
+                      rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 18 - Line between side3-1 and side1-2
+        //-------------------------------------------------------------------------------------------------------
+        case 18:
+            cell.xysect(p3,p1, contour, x1, y1);
+            cell.xysect(p1,p2, contour, x2, y2);
+            
+            if ( !box ) break;
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+        
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(x2, y2);
+        
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 19 - Line between vertex 3 and side1-2
+        //-------------------------------------------------------------------------------------------------------
+        case 19:
+            x1=cell.column(p3);
+            y1=cell.row(p3);
+        
+            cell.xysect(p1,p2, contour, x2, y2);
+            
+            if ( !box ) break;
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+        
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 20 - Line between side3-2 and side1-2
+        //-------------------------------------------------------------------------------------------------------
+        case 20:
+            cell.xysect(p3,p2, contour, x1, y1);
+            cell.xysect(p1,p2, contour, x2, y2);
+            
+            if ( !box ) break;
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p2), cell.row(p2));
+        
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 21 - Line between side 3-1 and vertex 2 
+        //-------------------------------------------------------------------------------------------------------
+        case 21:
+            cell.xysect(p3,p1, contour, x1, y1);
+            
+            x2=cell.column(p2);
+            y2=cell.row(p2);
+            if ( !box ) break;
+            
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+                
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 22 - Line between vertex 3 and vertex 2
+        //-------------------------------------------------------------------------------------------------------
+        case 22:
+            x1=cell.column(p3);
+            y1=cell.row(p3);
+            x2=cell.column(p2);
+            y2=cell.row(p2);
+            if ( !box) break;
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(cell.column(p3), cell.row(p3));
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 23 - single point 2
+        //-------------------------------------------------------------------------------------------------------
+        case 23:
+            x1=cell.column(p2);
+            y1=cell.row(p2);
+            add = 1;
+            if ( !box) break;
+            if (cell.height(p1, contour) < 0) {
+                     leftcell->push_back(cell.column(p1), cell.row(p1));
+                     leftcell->push_back(cell.column(p2), cell.row(p2));
+                     leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                     rightcell->push_back(cell.column(p1), cell.row(p1));
+                     rightcell->push_back(cell.column(p2), cell.row(p2));
+                     rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 24 - Line between side1-3  and side3-2
+        //-------------------------------------------------------------------------------------------------------
+        case 24:
+            cell.xysect(p1,p3, contour, x1, y1);
+            cell.xysect(p3,p2, contour, x2, y2);
+            if ( !box) break;
+            leftcell->push_back(x1, y1);
+            leftcell->push_back(x2, y2);
+            leftcell->push_back(cell.column(p3), cell.row(p3));
+            
+            rightcell->push_back(x1, y1);
+            rightcell->push_back(cell.column(p1), cell.row(p1));
+            rightcell->push_back(cell.column(p2), cell.row(p2));
+            rightcell->push_back(x2, y2);
+            break;
+
+        //-------------------------------------------------------------------------------------------------------
+        //     Case 25 - single point C
+        //-------------------------------------------------------------------------------------------------------
+        case 25:
+            x1=cell.column(p3);
+            y1=cell.row(p3);
+            add = 1;
+            if ( !box) break;
+            if (cell.height(p1, contour) < 0) {
+                     leftcell->push_back(cell.column(p1), cell.row(p1));
+                     leftcell->push_back(cell.column(p2), cell.row(p2));
+                     leftcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            else {
+                     rightcell->push_back(cell.column(p1), cell.row(p1));
+                     rightcell->push_back(cell.column(p2), cell.row(p2));
+                     rightcell->push_back(cell.column(p3), cell.row(p3));
+            }
+            break;
+            
+        default:
+            break;
+        }
+        
+        if (add == 2 && needIsolines() )
+        {
+            // here we have 2 Points to add! 
+            // We send it to a thread! 
+            const int t = (*l) % threads_;
+            {     
+              AutoLock<MutexCond> lockproducer(producerMutex_);
+              {
+                 AutoLock<MutexCond> lock(segments_[t]->cond_);
+                 segments_[t]->segments_.push_back(make_pair(levels_[*l], 
+                                                   make_pair(make_pair(x1, y1), make_pair(x2, y2))));
+                 if ( segments_[t]->segments_.size() >= 2000 ) 
+                       segments_[t]->cond_.signal();
+                 }
+                 producerMutex_.signal();
+              }
+            }
+
+            if ( !box) {
+                continue;
+            }
+            
+            if ( !complex ) {
+
+            	box->reshape(leftcell);
+                box->reshape(rightcell);
+            }
+           else {
+                shapes.push_back(make_pair(leftcell, rightcell));
+           }
+        } // end of levels...
+        
+        if ( shapes.empty() ) continue;
+        
+
+        // Now we reduce the shape! 
+
+        vector<pair<Shape*, Shape*> >::iterator current = shapes.begin();    
+        vector<pair<Shape*, Shape*> >::iterator next = shapes.begin();
+        box->reshape(current->first);
+
+        next++;
+        while ( next != shapes.end() ) {
+            current->second->intersection(*next->second);
+            box->reshape(current->second);
+            delete next->first;
+            current++;
+            next++ ;
+        }
+        box->reshape(current->second);
+
+        }
+    } // step to next triangle
+}
+
+
+
+
+void IsoPlot::isoline(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+{
+    const Transformation& transformation = parent.transformation();
+    levels_.clear();
+
+    // Find the used levels!
+    const vector<double>::const_iterator end = (*levelSelection_).end();
+    vector<double>::const_iterator previous = (*levelSelection_).end();
+    vector<double>::const_iterator last = (*levelSelection_).end();
+
+    double min = data.min();
+    double max = data.max();
+
+
+    if ( (*levelSelection_).front()  > min )
+            levels_.push_back(min);
+
+    vector<double>::const_iterator level = levelSelection_->begin();
+
+    while (*level < min && level != end ) {
+    	last = level;
+    	++level;
+    }
+    if ( last != end)
+    	levels_.push_back(*last);
+    while (*level < max && level != end ) {
+    	levels_.push_back(*level);
+    	++level;
+    }
+    if ( level != end ) {
+    	levels_.push_back(*level);
+    }
+    else
+    	levels_.push_back(max);
+
+
+
+    
+    missing_ = data.missing();
+
+
+
+    IntervalMap<int> range;
+    int r= 1;
+    for (vector<double>::const_iterator level = levels_.begin(); level != levels_.end(); ++level) {
+       MagLog::debug()  << " level " << *level << endl;
+       if (level+1!= levels_.end() )
+          range.insert(make_pair(Interval(*level, *(level+1)), r++));
+       }
+      range.insert(make_pair(Interval(levels_.back(), levels_.back()+epsilon), r));
+       CellArray* array = shading_->array(data, range, transformation, parent.widthResolution(), parent.heightResolution(),
+	   		resolution_, technique_);
+       CellBox view(array);
+
+       threads_ = (needIsolines())  ? 4: 0;
+
+       vector<IsoHelper*> consumers_;
+       vector<IsoProducer* >  producers_;
+
+       {
+        VectorOfPointers<vector<ThreadControler *>  > consumers;
+        VectorOfPointers<vector<ThreadControler *>  > producers;
+        segments_.clear();
+        colourShapes_.clear();
+        lines_.clear();
+
+        for (int c = 0; c < threads_; c++) {
+            vector<Polyline* >* lines = new vector<Polyline*>();
+            lines_.push_back(lines);    
+            segments_.push_back(new IsoData()); 
+            consumers_.push_back(new IsoHelper(c, *lines,*(segments_.back())));
+            consumers.push_back(new ThreadControler(consumers_.back(), false));
+            consumers.back()->start();
+        }
+        
+        view.split();
+
+        // let's start 4 producers...
+        int c = 0;
+        VectorOfPointers<vector<IsoProducerData*> > datas;
+        //for (CellBox::iterator cell = view.begin(); cell != view.end(); ++cell)
+        for ( int i = 0; i < view.size(); i++)
+
+        {
+
+           IsoProducerData* data = new IsoProducerData(shading_->shadingMode(), *this, *(view[i]));
+           datas.push_back(data);
+           producers_.push_back(new IsoProducer(c, *data));
+           producers.push_back(new ThreadControler(producers_.back(), false));
+           producers.back()->start();
+           c++;
+
+        }
+
+        for (vector<ThreadControler *>::iterator producer = producers.begin(); 
+           producer != producers.end(); ++producer) {
+           (*producer)->wait();
+        }
+
+        // No more
+        { 
+           for (int i = 0; i < threads_; i++) {
+                 AutoLock<MutexCond> lock(segments_[i]->cond_);
+                 segments_[i]->more_ = false;
+                 segments_[i]->cond_.signal();
+           }     
+        }
+
+        for (vector<ThreadControler *>::iterator consumer = consumers.begin(); consumer != consumers.end(); ++consumer) {
+             (*consumer)->wait();
+        }
+       }
+
+       for (CellBox::iterator cell = view.begin(); cell != view.end(); ++cell) {
+           (*cell)->feed(*this,parent);        
+
+       }
+
+       delete array;
+       for ( vector<IsoData*>::iterator segment = segments_.begin(); segment != segments_.end(); ++segment)  {
+       	   delete *segment;
+       	   *segment = 0;
+       }
+       segments_.clear();
+
+}
+
+
+ bool IsoPlot::prepare(MatrixHandler& data)
+{
+	//double replaceMissing_ = 0;
+	//double min = std::min(replaceMissing_, data.min());
+	//double max = std::max(replaceMissing_, data.max());
+	double min = data.min();
+	double max = data.max();
+    (*levelSelection_).clear();
+    (*levelSelection_).calculate(min , max , shading_->shadingMode());
+    (*label_).prepare(*levelSelection_, (*colour_).name());
+    return (*shading_)(*levelSelection_);
+}
+
+
+/*!
+ * Get the triangles list ...
+ * Create the isolines...
+ */
+ void IsoPlot::operator()(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+{
+    prepare(data);
+    if ( legend_only_ ) return;
+    
+    {
+        Timer timer("contouring", "Time spent in contouring");
+        isoline(data, parent);
+    }
+
+#ifdef ISOPLOT_DEBUG
+    vector<Colour> colours;    
+    colours.push_back(Colour("red"));
+    colours.push_back(Colour("green"));
+    colours.push_back(Colour("blue"));
+    colours.push_back(Colour("orange"));
+    vector<Colour>::iterator colour = colours.begin();
+#endif
+
+    (*shading_)(data, parent);
+    (*highlight_).prepare(*levelSelection_);
+
+    // Now we feed the task...   
+    for (vector<vector<Polyline* >* >::const_iterator lines = lines_.begin(); lines != lines_.end(); ++lines)
+    {
+      for (vector<Polyline* >::const_iterator poly = (*lines)->begin(); poly != (*lines)->end(); ++poly)
+      {
+        if ( (*poly)->empty() ) continue;
+        (*poly)->setLineStyle(style_);
+        (*poly)->setThickness(thickness_);
+        (*poly)->setColour(*colour_);
+#ifdef ISOPLOT_DEBUG
+        (*poly)->setColour(*colour);
+        colour++;
+        if ( colour == colours.end()) 
+            colour = colours.begin();
+#endif
+        (*highlight_)(*(*poly));
+        (*label_)(**poly, (*poly)->front().value());
+
+        parent.push_back(*poly);
+      }
+      delete *lines;
+
+    }
+    lines_.clear();
+}
+
+
+ void NoIsoPlot::operator()(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+{
+    // Create the isolines...        
+    if ( !prepare(data) ) {    
+        if ( legend_only_ ) return;
+        (*shading_)(data, parent);
+        // do not send the isolines...  
+        return;
+    }
+    if ( legend_only_ ) return;
+    // The shading needs the isolines..
+    // WE will calculate them but will not send them to the printer     
+    {
+        Timer timer("contouring", "Time spent in contouring");
+        isoline(data, parent);
+    }
+
+    (*shading_)(data, parent);
+
+    // Now we feed the task...
+        for (vector<vector<Polyline* >* >::const_iterator lines = lines_.begin(); lines != lines_.end(); ++lines)
+        {
+          for (vector<Polyline* >::const_iterator poly = (*lines)->begin(); poly != (*lines)->end(); ++poly)
+          {
+            if ( (*poly)->empty() ) continue;
+            (*poly)->setThickness(0);
+            (*poly)->setColour(Colour("black"));
+            (*label_)(**poly, (*poly)->front().value());
+            parent.push_back(*poly);
+          }
+        }
+        lines_.clear();
+}
+
+
+
+void IsoPlot::visit(Data& data, LegendVisitor& legend) {
+
+	if ( magCompare(legend_special_, "spaghetti") ) {
+		Polyline* blue = new Polyline();
+		blue->setColour(Colour("blue"));
+		blue->setLineStyle(M_DASH);
+		Polyline* red = new Polyline();
+		red->setColour(Colour("red"));
+		red->setLineStyle(M_DASH);
+		Polyline* grey = new Polyline();
+		grey->setColour(Colour("grey"));
+		grey->setLineStyle(M_SOLID);
+		legend.add(new DoubleLineEntry("Det", blue,0));
+		legend.add(new DoubleLineEntry("Control", red,0));
+		legend.add(new DoubleLineEntry("EPS members", grey,0));
+		return;
+	}
+	switch (legend.legendType())  {
+		case LegendMethod::CONTINUOUS :
+		case LegendMethod::DISJOINT: {
+			(*shading_).visit(legend);
+			if (shading_->hasLegend() ) return;
+
+			Polyline* line1 = new Polyline();
+			Polyline* line2 = 0;
+			line1->setColour(*colour_);
+			line1->setLineStyle(style_);
+			line1->setThickness(thickness_);
+    
+			highlight_->visit(line2);
+			legend.add(new DoubleLineEntry(legend_text_, line1, line2));
+			// Should do something for the wrep legend!!!
+			if ( legend.size() < 3 && legend.wrep_ ) {
+				legend.add(new EmptyEntry());
+			}
+			break;
+		}
+		case LegendMethod::HISTOGRAM: {
+			legend.newLegend();
+			IntervalMap<Colour> beans;
+			vector<double>::iterator from = levelSelection_->begin();
+			vector<double>::iterator to = levelSelection_->begin();
+			++to;
+			for (;  to != levelSelection_->end(); ++to){
+				Colour colour = *colour_;
+				shading_->colour(*from, colour);
+				beans.insert(make_pair(Interval(*from, *to), colour ));
+				++from;
+			}
+			Histogram helper;
+			const Transformation& transformation = legend.transformation();
+			IntervalMap<int>& histogram = helper.histogram(beans, data.points(transformation,false));
+			int total = 0;
+			for (IntervalMap<int>::const_iterator  interval = histogram.begin(); interval != histogram.end(); ++interval){
+				total+=interval->second;
+			}
+			bool first = true;
+			for ( IntervalMap<Colour>::const_iterator interval = beans.begin(); interval != beans.end(); ++interval) {
+				   Polyline* box = new Polyline();
+
+				   double min =interval->first.min_;
+				   double max = interval->first.max_;
+
+				   box->setShading(new FillShadingProperties());
+				   box->setFillColour(interval->second);
+				   box->setFilled(true);
+				   BoxEntry* entry = new BoxEntry(min, max, box);
+				   int count = histogram.find(min, 0);
+				   entry->population(count);
+				   entry->totalPopulation(total);
+				   if (first) {
+					   entry->first();
+					   first = false;
+				   }
+
+
+				   legend.add(entry);
+
+			}
+
+			legend.last();
+		}
+	}
+    
+}
+
+
+ void NoIsoPlot::visit(Data& data, LegendVisitor& legend) {
+
+    switch (legend.legendType())  {
+    		case LegendMethod::CONTINUOUS :
+    		case LegendMethod::DISJOINT: {
+    			(*shading_).visit(legend);
+    			break;
+    		}
+    		case LegendMethod::HISTOGRAM: {
+    			legend.newLegend();
+    			IntervalMap<Colour> beans;
+    			vector<double>::iterator from = levelSelection_->begin();
+    			vector<double>::iterator to = levelSelection_->begin();
+    			++to;
+    			for (;  to != levelSelection_->end(); ++to){
+    				Colour colour = *colour_;
+    				shading_->colour(*from, colour);
+    				beans.insert(make_pair(Interval(*from, *to), colour ));
+    				++from;
+    			}
+    			Histogram helper;
+    			IntervalMap<int>& histogram = helper.histogram(beans, data.points(legend.transformation(), true));
+    			int total = 0;
+    			for (IntervalMap<int>::const_iterator  interval = histogram.begin(); interval != histogram.end(); ++interval){
+    				total+=interval->second;
+    			}
+    			bool first = true;
+    			for ( IntervalMap<Colour>::const_iterator interval = beans.begin(); interval != beans.end(); ++interval) {
+    				   Polyline* box = new Polyline();
+
+    				   double min =interval->first.min_;
+    				   double max = interval->first.max_;
+
+    				   box->setShading(new FillShadingProperties());
+    				   box->setFillColour(interval->second);
+    				   box->setFilled(true);
+    				   BoxEntry* entry = new BoxEntry(min, max, box);
+    				   int count = histogram.find(min, 0);
+    				   entry->population(count);
+    				   entry->totalPopulation(total);
+    				   if (first) {
+    					   entry->first();
+    					   first = false;
+    				   }
+
+
+    				   legend.add(entry);
+
+    			}
+
+    			legend.last();
+    		}
+    	}
+}
+
+
+
+void IsoPlot::visit(Data& data, PointsHandler& points, HistoVisitor& visitor)
+{
+    IntervalMap<Colour> beans;
+    if ( !visitor.basic() ) {
+
+        vector<double>::iterator from = levelSelection_->begin();
+        vector<double>::iterator to = levelSelection_->begin();
+        ++to;
+        for (;  to != levelSelection_->end(); ++to){
+            Colour colour = *colour_;
+            shading_->colour(*from, colour);
+            beans.insert(make_pair(Interval(*from, *to), colour ));
+            ++from;
+        }
+    }
+    Histogram helper;
+    helper.visit(beans, data, points, visitor);
+}
+
+CellArray::CellArray(MatrixHandler& data, IntervalMap<int>& range, const Transformation& transformation, int width, int height, float resol, const string& technique) :
+		data_(data), rangeFinder_(range)
+{
+	Timer timer("CellArray", "CellArray");
+	int r = height/resol;
+	int c = (int) width/resol;
+	rows_ = r;
+	columns_ = c;
+
+
+	points_.set(rows_+1, columns_+1);
+	reserve(rows_* columns_);
+
+//	int i = 0;
+
+	missing_ = data.missing();
+	double x = transformation.getMinPCX();
+	double y =  transformation.getMinPCY();
+
+	double stepx =  ( transformation.getMaxPCX() -  transformation.getMinPCX() )/ (columns_);
+	double stepy =  ( transformation.getMaxPCY() -  transformation.getMinPCY() )/ (rows_);
+
+	{
+		Timer timer("matrix", "prepare");
+
+		vector<pair<double, double> > xypoints;
+		vector<pair<double, double> > geopoints;
+		xypoints.reserve(rows_+1 * columns_+1);
+		for (int row = 0; row <= rows_; row++) {
+			    x =  transformation.getMinPCX();
+			    points_.rowsAxis().push_back(y);
+				for (int column = 0; column <= columns_; column++) {
+					xypoints.push_back(make_pair(x, y));
+					if ( row == 0) {
+						points_.columnsAxis().push_back(x);
+
+					}
+					x += stepx;
+				}
+
+				y += stepy;
+		}
+		transformation.revert(xypoints, geopoints);
+		vector<pair<double, double> >::iterator geo= geopoints.begin();
+		double min =  data.min();
+		double max =  data.max();
+		double missing =  data.missing();
+
+		MagLog::dev() << "min = " << data.min() << "  max = " << data.max() << endl;
+		for (vector<pair<double, double> >::iterator xy = xypoints.begin(); xy != xypoints.end(); ++xy) {
+
+					double value;
+					if  ( geo->second == -1000) {
+
+						value = missing;
+					}
+					else {
+						value = (magCompare(technique, "nearest")) ?
+							data.nearest(geo->second, geo->first):data.interpolate(geo->second, geo->first);
+						//value =data.nearest(geo->second, geo->first);
+					}
+					if (value != missing) {
+						if (value < min)
+							value = min;
+						if (value > max)
+							value=max;
+					}
+					//else value = 0;
+
+
+
+					points_.push_back(value);
+					++geo;
+		}
+		points_.setMapsAxis();
+
+	}
+
+	for (int row = 0; row < rows_; row++)
+		for (int column = 0; column < columns_; column++) {
+			push_back(new Cell(*this, row, column));
+		}
+}
+
+
+CellArray::CellArray(MatrixHandler& data, IntervalMap<int>& range) : data_(data), rangeFinder_(range)
+{
+
+}
+
+GridArray::GridArray(MatrixHandler& data, IntervalMap<int>& range, const Transformation& transformation, int width, int height, float resol, const string& technique) : CellArray(data, range)
+{
+	Timer timer("GridArray", "GridArray");
+	rows_ = data.rows();
+	columns_ = data.columns();
+	reserve(rows_*columns_);
+	for (int row = 0; row < rows_; row++)
+		for (int column = 0; column < columns_; column++) {
+			push_back(new GridCell(*this, row, column, transformation, technique));
+		}
+}
+
+
+GridCell::GridCell(const CellArray& data, int row, int column, const Transformation& transformation, const string& technique):
+		Cell(data), transformation_(transformation)  {
+
+		row_ = row;
+		column_ = column;
+		int row1 = (row) ? row - 1 : 0;
+		int row2 = ( row == data.data_.rows() -1 ) ? row : row + 1;
+		missing_ = data.missing_;
+		value_ = data.data_(row_, column_);
+		min_ = max_ = value_;
+		int column1 = column ? column - 1 : 0;
+		int column2 = ( column == data.data_.columns() -1 ) ? column : column + 1;
+
+
+		range_ = data.rangeFinder_.find(value_, -1);
+		min_ = max_ = range_;
+		if ( range_ == -1 )
+			outOfRange_ = 4;
+
+		if ( magCompare(technique, "middle")) {
+	        double rc1 = data.data_.column(row, column1);
+	        double crc = data.data_.column(row, column);
+	        double rc2 = data.data_.column(row, column2);
+	        double r1c = data.data_.row(row1, column);
+	        double r2c = data.data_.row(row2, column);
+	        double rrc = data.data_.row(row, column);
+
+			columns_[0] = (rc1 + crc)/2;
+			columns_[1] = (crc + rc2)/2;
+			columns_[2] = (crc + rc2)/2;
+			columns_[3] = (rc1 + crc)/2;
+			rows_[0] = (r1c + rrc)/2;
+			rows_[1] = (r1c + rrc)/2;
+			rows_[2] = (rrc + r2c)/2;
+			rows_[3] = (rrc + r2c)/2;
+		}
+
+		else {
+			columns_[0] = data.data_.column(row, column);
+			columns_[1] = data.data_.column(row, column2);
+			columns_[2] = data.data_.column(row, column2);
+			columns_[3] = data.data_.column(row, column);
+			rows_[0] = data.data_.row(row, column);
+			rows_[1] = data.data_.row(row, column);
+			rows_[2] = data.data_.row(row2, column);
+			rows_[3] =  data.data_.row(row2, column);
+			}
+
+		for (int i = 0; i < 4; i++) {
+			transformation.fast_reproject(columns_[i], rows_[i]);
+
+
+		}
+		////cout << "[-------------------]" << endl;
+	}
+void Shape::intersection(Shape& other) {
+
+	vector<Point > opoints = other.points_;
+
+		std::reverse(opoints.begin(), opoints.end());
+
+
+
+	vector<Point  >::iterator p1= points_.begin();
+
+	Point top;
+
+
+	while (p1!= points_.end() ) {
+		vector<Point  >::iterator p2= opoints.begin();
+		while ( p2!= opoints.end()) {
+			if ( *p1 == *p2) {
+				std::rotate(opoints.begin(), p2, opoints.end());
+				p1++;
+
+				points_.insert(p1, opoints.begin(), opoints.end());
+
+				//now we need to take off the duplicates!
+
+				stack<Point > helper;
+				vector<Point  >::const_iterator point = points_.begin();
+
+
+				for (point = points_.begin();  point != points_.end(); ++point) {
+					if ( helper.empty() ) {
+						helper.push(*point);
+						continue;
+					}
+
+					top =  helper.top();
+					helper.pop();
+
+					if ( !( top == *point ) ) {
+						helper.push(top);
+						helper.push(*point);
+					}
+
+				}
+				clean();
+
+
+
+				while ( !helper.empty() ) {
+					push_back(helper.top().x_, helper.top().y_);
+					helper.pop();
+				}
+
+				if ( SegmentJoiner::isHole(points_) ) {
+				       //cout << " hole -> revert! " << endl;
+				       std::reverse(points_.begin(), points_.end());
+
+				      }
+
+				return;
+			}
+			p2++;
+		}
+		p1++;
+	}
+
+
+}
diff --git a/src/visualisers/IsoPlot.h b/src/visualisers/IsoPlot.h
new file mode 100644
index 0000000..4841c7f
--- /dev/null
+++ b/src/visualisers/IsoPlot.h
@@ -0,0 +1,505 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+   
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoPlot.h
+    \brief Definition of the Template class IsoPlot.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 3-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef IsoPlot_H
+#define IsoPlot_H
+
+#include "magics.h"
+
+#include "IsoPlotAttributes.h"
+#include "BasicSceneObject.h"
+#include "Polyline.h"
+#include "VectorOfPointers.h"
+#include "XmlNode.h"
+#include "IsoHelper.h"
+#include "Timer.h"
+#include <limits>
+#include "SegmentJoiner.h"
+
+namespace magics {
+
+
+
+
+struct Shape
+{
+	Shape() : index_(-1),
+	minx_(numeric_limits<double>::max()), 
+	maxx_(-numeric_limits<double>::max()), 
+	miny_(numeric_limits<double>::max()), 
+	maxy_(-numeric_limits<double>::max()) {}
+
+	Shape(int index) :
+				index_(index),
+
+				minx_(numeric_limits<double>::max()), 
+				maxx_(-numeric_limits<double>::max()), 
+				miny_(numeric_limits<double>::max()), 
+				maxy_(-numeric_limits<double>::max()) {
+
+	}
+
+	int index_;
+	~Shape() {}
+
+
+	void push_back(double x, double y) {
+
+		points_.push_back(Point(x,y));
+
+
+		if ( x < minx_ ) minx_ = x;
+		if ( x > maxx_ ) maxx_ = x;
+		if ( y < miny_ ) miny_ = y;
+		if ( y > maxy_ ) maxy_ = y;
+	}
+
+
+	double minx_;
+	double maxx_;
+	double miny_;	
+	double maxy_;
+	vector<Point> points_;
+	
+
+	bool intersect(Shape& other) {
+		if ( minx_ > other.maxx_ ) return false;
+		if ( maxx_ < other.minx_ ) return false;
+		if ( miny_ > other.maxy_ ) return false;
+		if ( maxy_ < other.miny_ ) return false;
+		return true;
+	}
+	
+
+	void clean() {
+		points_.clear();
+
+		minx_ = numeric_limits<double>::max();
+		maxx_ = -numeric_limits<double>::max();
+		miny_ = numeric_limits<double>::max();
+		maxy_ = -numeric_limits<double>::max();
+	}
+
+
+	void intersection(Shape& other);
+
+	friend ostream& operator<<(ostream& s,const Shape& p) 
+	{
+	  s << "Shape[\n";
+
+	  s<< "]\n";
+	  return s; 
+	}
+};
+
+
+
+class Cell;
+
+class CellArray : public VectorOfPointers<vector<Cell* > > {
+public:
+	CellArray(MatrixHandler& data, IntervalMap<int>& range, const Transformation& transformation, int, int, float, const string&);
+	CellArray(MatrixHandler& data, IntervalMap<int>& range);
+	int columns_;
+	int rows_;
+	double missing_;
+	
+	Matrix points_;
+	IntervalMap<int> rangeFinder_;
+	MatrixHandler& data_;
+
+	Cell* operator()(int row, int column) const {
+		return (*this)[row*columns_ + column];
+	}
+	
+	double rows() const { return points_.rows(); }
+	double columns() const { return points_.columns(); }
+	double value(const pair<int, int>& pos)  const {
+		return points_(pos.first, pos.second);
+	}
+	double value(int row, int column)  const {
+			return points_(row, column);
+	}
+	double row(int row, int column)  const {
+			return points_.row(row, column);
+	}
+	double row(const pair<int, int>& pos)  const {
+				return points_.row(pos.first, pos.second);
+		}
+
+	double column(const pair<int, int>& pos) const {
+				return points_.column(pos.first, pos.second);
+	}
+	double column(int row, int column) const {
+		return points_.column(row, column);
+	}
+	double range(const pair<int, int>& pos)  const {
+					return rangeFinder_.find(points_(pos.first, pos.second), -1);	
+		}
+
+	~CellArray() { }
+};
+
+class GridArray : public CellArray {
+public:
+	GridArray(MatrixHandler& data, IntervalMap<int>& range, const Transformation& transformation, int, int, float, const string&);
+
+};
+
+
+enum RangeType { outOfRange, singleRange, multipleRange };
+
+
+class Cell 
+{
+public:	
+	Cell(const CellArray& parent) : parent_(parent), missing_(parent.missing_) { }
+	Cell(const CellArray& parent, int row, int column):  parent_(parent), row_(row), column_(column)  {
+		indexes_[0] = make_pair(row_, column_);
+		indexes_[1] = make_pair(row_, column_+1);
+		indexes_[2] = make_pair(row_+1, column_+1);
+		indexes_[3] = make_pair(row_+1, column_);
+			
+		min_  = 100000000;
+		max_ = -min_;
+		outOfRange_ = 0;
+		 missing_ = parent_.missing_;
+		for ( int i = 0; i < 4; i++ ) {
+			
+		    
+
+
+			int index = range(i);
+		    if (index != -1 ) {
+		    	if (  index   < min_ ) min_ =   index; 
+		    	if (  index   > max_ ) max_ = index; 	
+		    }
+		    else 
+		    	outOfRange_++;
+		  
+		}
+        
+
+        
+       
+	}
+	
+	 ~Cell() {  }
+	
+
+	const CellArray& parent_;
+	int row_;
+	int column_;
+	
+	 
+	
+	virtual RangeType range() {
+		if ( outOfRange_ == 4 ) 
+			return outOfRange;
+		if ( min_ == max_ && !outOfRange_ )
+			return singleRange;
+		return multipleRange;	
+	}
+
+  
+
+	
+	double missing_;
+	
+	bool missing(int i) 
+		{ return (same(missing_, this->parent_.value(this->indexes_[i])));	 }
+	
+	
+	int min_;
+	int max_;
+	
+	int outOfRange_;
+
+	pair<int, int> indexes_[4];
+	
+	
+	
+	
+	const pair<int, int>& index(int i) {
+		assert(i < 4);
+		return indexes_[i];		
+	}
+	
+	 virtual double value(int i) const {
+		return this->parent_.value(this->indexes_[i]);		
+	}
+	
+	 virtual double height(int i, double val) const {
+		    double value = this->parent_.value(this->indexes_[i]);
+		    
+			return  ( same(value, missing_) ) ? 0 : value - val;					
+	}
+	 virtual int coef(int i, double val) const {
+		double height = this->parent_.value(this->indexes_[i])-val;		
+		int c = ( height ) ? (height/abs(height))+1 : 1;
+
+		
+		return c;
+	}
+
+	 bool isMissing(int i) const {
+		return (same(missing_, this->parent_.value(this->indexes_[i])));		
+	}
+	
+	 virtual double column(int i) const {
+		return parent_.column(this->indexes_[i]);
+		}
+	void xysect(int i, int j, double value, double& x, double& y) const {
+	
+		double v1 = this->parent_.value(this->indexes_[i])-value;
+		double v2 = this->parent_.value(this->indexes_[j])-value;
+		
+		double x1 = this->parent_.column(this->indexes_[i]);
+	    double x2 = this->parent_.column(this->indexes_[j]);
+	    double y1 = this->parent_.row(this->indexes_[i]);
+	    double y2 = this->parent_.row(this->indexes_[j]);
+		x = (v2*x1-v1*x2)/(v2-v1);
+		y = (v2*y1-v1*y2)/(v2-v1);
+	}
+	
+	 virtual double row(int i) const {
+		return this->parent_.row(this->indexes_[i]);
+	}		
+	 virtual int range(int i) {
+			return this->parent_.range(this->indexes_[i]);
+		}		
+	 int findRange(double value) {
+		return this->parent_.rangeFinder_.find(value, -1);
+	}
+};
+
+
+class GridCell : public Cell
+{
+public:
+	GridCell(const CellArray&, int row, int column, const Transformation& transformation, const string&);
+
+	 ~GridCell() {  }
+
+    const Transformation& transformation_;
+	double columns_[4];
+	double rows_[4];
+	int range_;
+
+	RangeType range() {
+
+			return (range_ == -1 ) ? outOfRange : singleRange;
+
+	}
+
+
+
+
+	double missing_;
+	double value_;
+
+
+	bool missing(int i)
+		{ return (same(missing_, this->parent_.value(this->indexes_[i])));	 }
+
+
+	virtual double value(int i) const {
+			return value_;
+	}
+
+	virtual double row(int i) const {
+				return rows_[i];
+	}
+	virtual double column(int i) const {
+					return columns_[i];
+		}
+	const pair<int, int>& index(int i) {
+		assert(i < 4);
+		return indexes_[i];
+	}
+
+	 bool isMissing(int i) const {
+		return (same(missing_, this->parent_.value(this->indexes_[i])));
+	}
+
+
+
+	int range(int i) const{
+		return range_;
+	}
+
+	int findRange(double value) {
+		return this->parent_.rangeFinder_.find(value, -1);
+	}
+};
+
+
+class CellBox;
+
+
+class IsoPlot: public IsoPlotAttributes {
+
+public:
+	IsoPlot();
+	virtual ~IsoPlot();
+	
+	// Implements the Visdef Interface...
+	virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
+	virtual void visit(Data&, LegendVisitor&);
+
+	void set(const map<string, string>& map ) {
+		IsoPlotAttributes::set(map);
+	}
+
+	void set(const XmlNode& node )  {
+		IsoPlotAttributes::set(node);
+	}
+
+	void toxml(ostream& out)  const {
+		IsoPlotAttributes::toxml(out);
+	}
+
+	void setTag(const string&)  {
+		//IsoPlotAttributes::setTag(tag);
+	}
+
+	void adjust(double min, double max) 
+	{ min_ = min; max_ = max; }
+
+	virtual IsoPlot* clone() const {
+		IsoPlot* object = new IsoPlot();
+		object->copy(*this);
+		return object;
+	}
+
+	int shadingIndex( double value ) const {
+		return this->shading_->shadingIndex(value);
+	}
+
+	bool reshape(Shape&,Shape&);
+	void reshape(const Colour&, Shape&);
+	bool reduce( list<Shape>&, list<Shape>::iterator&);
+	void isoline(Cell&, CellBox* = 0) const;
+	virtual bool needIsolines() const { return true; }
+	void operator()(Data& data, BasicGraphicsObjectContainer& parent) {
+			(*this->shading_)(data, parent); 
+		}
+	virtual void visit(Data&, PointsHandler&, HistoVisitor&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+	void isoline(MatrixHandler&, BasicGraphicsObjectContainer&);
+	
+	bool prepare(MatrixHandler&);
+	
+	double min_;
+	double max_;
+
+        vector<vector<Polyline* >* > lines_;
+
+		double missing_;
+		vector<double>  levels_;
+		bool shadingMode_; 
+		
+		vector<IsoData*> segments_; 
+		
+		map<Colour, IsoData*> colourShapes_; 
+		int threads_;
+		
+	
+	
+
+private:
+	//! Copy constructor - No copy allowed
+	IsoPlot(const IsoPlot&);
+	//! Overloaded << operator to copy - No copy allowed
+	IsoPlot& operator=(const IsoPlot&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const IsoPlot& p)
+		{ p.print(s); return s; }
+    
+};
+
+
+class NoIsoPlot : public IsoPlot
+{
+public:
+	NoIsoPlot() { this->setTag("noisoline"); };
+	~NoIsoPlot() {};
+    
+	// Implements the Visualiser Interface...
+	void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
+	
+	void set(const XmlNode& node)  {
+		if ( magCompare(node.name(), "noisoline")  ) {
+			XmlNode iso = node;
+			iso.name("isoline");
+		    IsoPlotAttributes::set(iso);
+		} 
+		else 
+			IsoPlotAttributes::set(node);
+	}
+
+	IsoPlot* clone() const
+	{ 
+		IsoPlot* object = new NoIsoPlot();
+		return object;
+	}
+	bool needIsolines() { return this->label_->label(); }
+    void visit(Data&, LegendVisitor&);
+protected:
+ 	void print(ostream& out) const 
+ 	{ out << "NoIsoPlot" << "\n"; }
+};
+
+
+template <>
+class MagTranslator<string, IsoPlot > {
+public:
+	IsoPlot* operator()(const string& val) {
+		return SimpleObjectMaker<IsoPlot >::create(val);
+	}     
+
+	IsoPlot* magics(const string& param)
+	{
+		IsoPlot* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/IsoPlotAttributes.cc b/src/visualisers/IsoPlotAttributes.cc
new file mode 100644
index 0000000..a5fc461
--- /dev/null
+++ b/src/visualisers/IsoPlotAttributes.cc
@@ -0,0 +1,222 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IsoPlotAttributes.cc
+    \brief Implementation of IsoPlot Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "IsoPlotAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+IsoPlotAttributes::IsoPlotAttributes():
+	legend_special_(ParameterManager::getString("contour_special_legend")),
+	resolution_(ParameterManager::getDouble("contour_internal_reduction_factor")),
+	technique_(ParameterManager::getString("contour_internal_technique")),
+	legend_text_(ParameterManager::getString("contour_legend_text")),
+	style_(MagTranslator<string, LineStyle>().magics("contour_line_style")),
+	thickness_(ParameterManager::getInt("contour_line_thickness")),
+	colour_(MagTranslator<string, Colour>().magics("contour_line_colour")),
+	highlight_(MagTranslator<string, NoIsoHighlight>().magics("contour_highlight")),
+	levelSelection_(MagTranslator<string, LevelSelection>().magics("contour_level_selection_type")),
+	label_(MagTranslator<string, NoIsoLabel>().magics("contour_label")),
+	shading_(MagTranslator<string, NoIsoShading>().magics("contour_shade")),
+	legend_only_(ParameterManager::getBool("contour_legend_only"))
+{
+} 
+
+
+
+IsoPlotAttributes::~IsoPlotAttributes()
+{
+}
+
+    
+void IsoPlotAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(2);
+	prefix[0] = "contour_line";
+	prefix[1] = "contour";
+
+	setAttribute(prefix, "contour_special_legend", legend_special_, params);
+	setAttribute(prefix, "contour_internal_reduction_factor", resolution_, params);
+	setAttribute(prefix, "contour_internal_technique", technique_, params);
+	setAttribute(prefix, "contour_legend_text", legend_text_, params);
+	setAttribute(prefix, "contour_line_style", style_, params);
+	setAttribute(prefix, "contour_line_thickness", thickness_, params);
+	setAttribute(prefix, "contour_line_colour", colour_, params);
+	setMember(prefix, "contour_highlight", highlight_, params);
+	setMember(prefix, "contour_level_selection_type", levelSelection_, params);
+	setMember(prefix, "contour_label", label_, params);
+	setMember(prefix, "contour_shade", shading_, params);
+	setAttribute(prefix, "contour_legend_only", legend_only_, params);
+}
+
+void IsoPlotAttributes::copy(const IsoPlotAttributes& other)
+{
+	legend_special_ = other.legend_special_;
+	resolution_ = other.resolution_;
+	technique_ = other.technique_;
+	legend_text_ = other.legend_text_;
+	style_ = other.style_;
+	thickness_ = other.thickness_;
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	highlight_ = auto_ptr<NoIsoHighlight>(other.highlight_->clone());
+	levelSelection_ = auto_ptr<LevelSelection>(other.levelSelection_->clone());
+	label_ = auto_ptr<NoIsoLabel>(other.label_->clone());
+	shading_ = auto_ptr<NoIsoShading>(other.shading_->clone());
+	legend_only_ = other.legend_only_;
+} 
+
+
+bool IsoPlotAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "isoline")  )
+		return true;
+
+	if ( acceptNode(node, highlight_) )
+		return true;
+
+	if ( acceptNode(node, levelSelection_) )
+		return true;
+
+	if ( acceptNode(node, label_) )
+		return true;
+
+	if ( acceptNode(node, shading_) )
+		return true;
+	return false;
+}
+
+void IsoPlotAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "isoline") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), highlight_, node);
+		setMember(node.name(), levelSelection_, node);
+		setMember(node.name(), label_, node);
+		setMember(node.name(), shading_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), highlight_, *(*elt)); 
+		setMember((*elt)->name(), levelSelection_, *(*elt)); 
+		setMember((*elt)->name(), label_, *(*elt)); 
+		setMember((*elt)->name(), shading_, *(*elt)); 
+	}
+}
+
+void IsoPlotAttributes::print(ostream& out)  const
+{
+	out << "IsoPlotAttributes[";
+	out << "legend_special = " << legend_special_;
+	out << ", resolution = " << resolution_;
+	out << ", technique = " << technique_;
+	out << ", legend_text = " << legend_text_;
+	out << ", style = " << style_;
+	out << ", thickness = " << thickness_;
+	out << ", colour = " << *colour_;
+	out << ", highlight = " << *highlight_;
+	out << ", levelSelection = " << *levelSelection_;
+	out << ", label = " << *label_;
+	out << ", shading = " << *shading_;
+	out << ", legend_only = " << legend_only_;
+	out << "]" << "\n";
+}
+
+
+void IsoPlotAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"isoline\"";
+	 out << ", \"contour_special_legend\":";
+	 niceprint(out,legend_special_);
+	 out << ", \"contour_internal_reduction_factor\":";
+	 niceprint(out,resolution_);
+	 out << ", \"contour_internal_technique\":";
+	 niceprint(out,technique_);
+	 out << ", \"contour_legend_text\":";
+	 niceprint(out,legend_text_);
+	 out << ", \"contour_line_style\":";
+	 niceprint(out,style_);
+	 out << ", \"contour_line_thickness\":";
+	 niceprint(out,thickness_);
+	 out << ", \"contour_line_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"contour_highlight\":";
+	 highlight_->toxml(out);
+	 out << ", \"contour_level_selection_type\":";
+	 levelSelection_->toxml(out);
+	 out << ", \"contour_label\":";
+	 label_->toxml(out);
+	 out << ", \"contour_shade\":";
+	 shading_->toxml(out);
+	 out << ", \"contour_legend_only\":";
+	 niceprint(out,legend_only_);
+}
+static MagicsParameter<string> contour_special_legend("contour_special_legend", "", "");
+static MagicsParameter<double> contour_internal_reduction_factor("contour_internal_reduction_factor", 4, "");
+static MagicsParameter<string> contour_internal_technique("contour_internal_technique", "interpolate", "");
+static MagicsParameter<string> contour_legend_text("contour_legend_text", " ", "");
+static MagicsParameter<string> contour_line_style("contour_line_style", "solid", " New Magics: Parameter contour_line_style sent to new Magics[IsoPlot].  ");
+static MagicsParameter<int> contour_line_thickness("contour_line_thickness", 1, " New Magics: Parameter contour_line_thickness sent to new Magics[IsoPlot].  ");
+static MagicsParameter<string> contour_line_colour("contour_line_colour", "blue", " New Magics: Parameter contour_line_colour sent to new Magics[IsoPlot].  ");
+static MagicsParameter<string> contour_highlight("contour_highlight", "on", " New Magics: Parameter contour_highlight sent to new Magics[IsoPlot].  ");
+static MagicsParameter<string> contour_level_selection_type("contour_level_selection_type", "count", "");
+static MagicsParameter<string> contour_label("contour_label", "on", " New Magics: Parameter Contour sent to new Magics[Contour].  ");
+static MagicsParameter<string> contour_shade("contour_shade", "off", " New Magics: Parameter contour_label sent to new Magics[Contour].  ");
+static MagicsParameter<string> contour_legend_only("contour_legend_only", "off", "");
+#include "IsoHighlight.h"
+static SimpleObjectMaker<IsoHighlight, NoIsoHighlight> on_IsoHighlight("on");
+static SimpleObjectMaker<IsoHighlight, NoIsoHighlight> highlight_IsoHighlight("highlight");
+static SimpleObjectMaker<NoIsoHighlight, NoIsoHighlight> off_NoIsoHighlight("off");
+static SimpleObjectMaker<NoIsoHighlight, NoIsoHighlight> nohighlight_NoIsoHighlight("nohighlight");
+#include "CountSelectionType.h"
+#include "IntervalSelectionType.h"
+#include "LevelListSelectionType.h"
+static SimpleObjectMaker<CountSelectionType, LevelSelection> count_CountSelectionType("count");
+static SimpleObjectMaker<IntervalSelectionType, LevelSelection> interval_IntervalSelectionType("interval");
+static SimpleObjectMaker<LevelListSelectionType, LevelSelection> level_list_LevelListSelectionType("level_list");
+static SimpleObjectMaker<LevelListSelectionType, LevelSelection> list_LevelListSelectionType("list");
+#include "IsoLabel.h"
+static SimpleObjectMaker<IsoLabel, NoIsoLabel> on_IsoLabel("on");
+static SimpleObjectMaker<IsoLabel, NoIsoLabel> label_IsoLabel("label");
+static SimpleObjectMaker<NoIsoLabel, NoIsoLabel> off_NoIsoLabel("off");
+static SimpleObjectMaker<NoIsoLabel, NoIsoLabel> nolabel_NoIsoLabel("nolabel");
+#include "IsoShading.h"
+static SimpleObjectMaker<IsoShading, NoIsoShading> on_IsoShading("on");
+static SimpleObjectMaker<IsoShading, NoIsoShading> shading_IsoShading("shading");
+static SimpleObjectMaker<NoIsoShading, NoIsoShading> off_NoIsoShading("off");
+static SimpleObjectMaker<NoIsoShading, NoIsoShading> noshading_NoIsoShading("noshading");
diff --git a/src/visualisers/IsoPlotAttributes.h b/src/visualisers/IsoPlotAttributes.h
new file mode 100644
index 0000000..018c39b
--- /dev/null
+++ b/src/visualisers/IsoPlotAttributes.h
@@ -0,0 +1,97 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IsoPlotAttributes.h
+    \brief Definition of IsoPlot Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef IsoPlotAttributes_H
+#define IsoPlotAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "IsoLabel.h"
+#include "LevelSelection.h"
+#include "Colour.h"
+#include "IsoHighlight.h"
+#include "IsoShading.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class IsoPlotAttributes 
+{
+public:
+//  --  constructor
+    IsoPlotAttributes();
+    
+//  --  destructor
+    virtual ~IsoPlotAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const IsoPlotAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string legend_special_;
+	double resolution_;
+	string technique_;
+	string legend_text_;
+	LineStyle style_;
+	int thickness_;
+	auto_ptr<Colour> colour_;
+	auto_ptr<NoIsoHighlight> highlight_;
+	auto_ptr<LevelSelection> levelSelection_;
+	auto_ptr<NoIsoLabel> label_;
+	auto_ptr<NoIsoShading> shading_;
+	bool legend_only_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const IsoPlotAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/IsoShading.cc b/src/visualisers/IsoShading.cc
new file mode 100644
index 0000000..6afe86d
--- /dev/null
+++ b/src/visualisers/IsoShading.cc
@@ -0,0 +1,91 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoShading.cc
+    \brief Implementation of the Template class IsoShading.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "IsoShading.h"
+#include "Polyline.h"
+#include "UserPoint.h"
+#include "PaperPoint.h"
+#include "MatrixHandler.h"
+#include "PolyShadingMethod.h"
+#include "IsoPlot.h"
+
+using namespace magics;
+
+
+IsoShading::IsoShading()
+{
+ 
+  
+}
+
+
+IsoShading::~IsoShading()
+{
+}
+
+void IsoShading::operator()(Polyline* poly) const
+{
+    (*this->technique_)(poly);
+   
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void IsoShading::print(ostream& out)  const
+{
+	out << "IsoShading[";
+	out << "]";
+}
+
+CellArray* NoIsoShading::array(MatrixHandler& matrix, IntervalMap<int>& range,
+	        	    		const Transformation& transformation, int width, int height,
+	        	    		float resolution, const string& technique)
+{
+		 return new CellArray(matrix, range, transformation, width, height, resolution, technique);
+
+}
+int IsoShading::shadingIndex(double value)
+{
+	return technique_->index(value);
+}
+
+int IsoShading::leftIndex(double value)
+{
+	technique_->leftIndex(value);
+}
+
+int IsoShading::rightIndex(double value)
+{
+	return technique_->rightIndex(value);
+}
diff --git a/src/visualisers/IsoShading.h b/src/visualisers/IsoShading.h
new file mode 100644
index 0000000..cb90a71
--- /dev/null
+++ b/src/visualisers/IsoShading.h
@@ -0,0 +1,177 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file IsoShading.h
+    \brief Definition of the Template class IsoShading.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+*/
+
+#ifndef IsoShading_H
+#define IsoShading_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+#include "IsoShadingAttributes.h"
+#include "Colour.h"
+#include "LevelSelection.h"
+#include "Polyline.h"
+#include "MatrixHandler.h"
+#include "LegendVisitor.h"
+namespace magics {
+
+
+class NoIsoShading  {
+
+public:
+	NoIsoShading() {}
+	virtual ~NoIsoShading() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual void toxml(ostream&, int = 0) const {}
+	virtual bool accept(const string&) { return true;}
+    
+	virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&)
+			{  }
+		virtual void operator()(Data&, BasicGraphicsObjectContainer&)
+				{  }
+ 
+    
+    virtual NoIsoShading* clone() {
+		NoIsoShading* object = new NoIsoShading();
+	    return object;
+	}
+    virtual CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+        	    		const Transformation& transformation, int width, int height,
+        	    		float resolution, const string& technique);
+	void close(const MatrixHandler&) const {}
+	virtual bool shadingMode() { return false; }
+	virtual bool hasLegend() { return false; }
+	virtual int shadingIndex (double ) { return -1; }
+	virtual int leftIndex (double ) { return -1; }
+	virtual int rightIndex (double ) { return -1; }
+	virtual double  leftRange(double) { return 0; }
+	virtual double rightRange(double) { return 0; }
+	virtual bool operator()(const LevelSelection&) { return false; }
+	virtual void visit(LegendVisitor&) {} 
+	virtual void operator()(Polyline*) const {}
+	virtual void colour(double, Colour&) {}
+	virtual bool needClipping() { return false;}
+	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "No Shading"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	NoIsoShading(const NoIsoShading&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoIsoShading& operator=(const NoIsoShading&);
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoIsoShading& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class IsoShading: public NoIsoShading, public IsoShadingAttributes {
+
+public:
+	IsoShading();
+	 ~IsoShading();
+	void set(const map<string, string>& map ) { IsoShadingAttributes::set(map); }
+	void set(const XmlNode& node ) { IsoShadingAttributes::set(node); }
+	virtual void operator()(Polyline*) const;
+
+		virtual bool accept(const string&) { return true;}
+	virtual NoIsoShading* clone() const {
+		IsoShading* object = new IsoShading();
+		object->copy(*this);
+	    return object;
+	}
+	 CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+	        	    		const Transformation& transformation, int width, int height,
+	        	    		float resolution, const string& technique) {
+		 return technique_->array(matrix, range, transformation, width, height, resolution, technique); }
+	virtual void operator()(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+		{ (*this->technique_)(data, parent); }
+	virtual void operator()(Data& data, BasicGraphicsObjectContainer& parent)
+			{ (*this->technique_)(data, parent); }
+	virtual int     shadingIndex(double);
+	virtual int  leftIndex(double);
+	virtual int  rightIndex(double);
+
+	virtual bool needClipping() { return (*this->technique_).needClipping(); }
+	virtual bool operator()(const LevelSelection& list)
+	{ 
+		LevelSelection filter;
+		for (LevelSelection::const_iterator level = list.begin(); level != list.end(); ++level) 
+			if ( this->min_ <= *level && *level <= this->max_ ) 
+			          filter.push_back(*level); 
+		(*this->colourMethod_).prepare(filter); 
+		return (*this->technique_).prepare(filter, *this->colourMethod_);
+	}
+	// returns true, if the contouring lines have to be created... False, is the shading is finished...
+	virtual void visit(LegendVisitor& legend)  { 
+		legend.newLegend(); 
+			(*this->technique_).visit(legend, *this->colourMethod_); }
+	virtual bool shadingMode() { return (*this->technique_).shadingMode(); }
+	virtual bool hasLegend() { return (*this->technique_).hasLegend(); }
+
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	vector<Colour> colours_;
+	vector<Colour>::iterator colour_;
+
+private:
+	//! Copy constructor - No copy allowed
+	IsoShading(const IsoShading&);
+	//! Overloaded << operator to copy - No copy allowed
+	IsoShading& operator=(const IsoShading&);
+
+
+};
+
+template <>
+class MagTranslator<string, NoIsoShading > {
+public:
+	NoIsoShading* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<NoIsoShading >::create(val);
+	}     
+	NoIsoShading* magics(const string& param)
+	{
+		NoIsoShading* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/IsoShadingAttributes.cc b/src/visualisers/IsoShadingAttributes.cc
new file mode 100644
index 0000000..fe38b6d
--- /dev/null
+++ b/src/visualisers/IsoShadingAttributes.cc
@@ -0,0 +1,149 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IsoShadingAttributes.cc
+    \brief Implementation of IsoShading Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "IsoShadingAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+IsoShadingAttributes::IsoShadingAttributes():
+	technique_(MagTranslator<string, ShadingTechnique>().magics("contour_shade_technique")),
+	max_(ParameterManager::getDouble("contour_shade_max_level")),
+	min_(ParameterManager::getDouble("contour_shade_min_level")),
+	colourMethod_(MagTranslator<string, ColourTechnique>().magics("contour_shade_colour_method"))
+{
+} 
+
+
+
+IsoShadingAttributes::~IsoShadingAttributes()
+{
+}
+
+    
+void IsoShadingAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(5);
+	prefix[0] = "contour_shade";
+	prefix[1] = "contour_shade";
+	prefix[2] = "contour_shade";
+	prefix[3] = "contour";
+	prefix[4] = "contour";
+
+	setMember(prefix, "contour_shade_technique", technique_, params);
+	setAttribute(prefix, "contour_shade_max_level", max_, params);
+	setAttribute(prefix, "contour_shade_min_level", min_, params);
+	setMember(prefix, "contour_shade_colour_method", colourMethod_, params);
+}
+
+void IsoShadingAttributes::copy(const IsoShadingAttributes& other)
+{
+	technique_ = auto_ptr<ShadingTechnique>(other.technique_->clone());
+	max_ = other.max_;
+	min_ = other.min_;
+	colourMethod_ = auto_ptr<ColourTechnique>(other.colourMethod_->clone());
+} 
+
+
+bool IsoShadingAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "shading")  )
+		return true;
+
+	if ( acceptNode(node, technique_) )
+		return true;
+
+	if ( acceptNode(node, colourMethod_) )
+		return true;
+	return false;
+}
+
+void IsoShadingAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "shading") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), technique_, node);
+		setMember(node.name(), colourMethod_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), technique_, *(*elt)); 
+		setMember((*elt)->name(), colourMethod_, *(*elt)); 
+	}
+}
+
+void IsoShadingAttributes::print(ostream& out)  const
+{
+	out << "IsoShadingAttributes[";
+	out << "technique = " << *technique_;
+	out << ", max = " << max_;
+	out << ", min = " << min_;
+	out << ", colourMethod = " << *colourMethod_;
+	out << "]" << "\n";
+}
+
+
+void IsoShadingAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"shading\"";
+	 out << ", \"contour_shade_technique\":";
+	 technique_->toxml(out);
+	 out << ", \"contour_shade_max_level\":";
+	 niceprint(out,max_);
+	 out << ", \"contour_shade_min_level\":";
+	 niceprint(out,min_);
+	 out << ", \"contour_shade_colour_method\":";
+	 colourMethod_->toxml(out);
+}
+static MagicsParameter<string> contour_shade_technique("contour_shade_technique", "polygon_shading", "");
+static MagicsParameter<double> contour_shade_max_level("contour_shade_max_level", 1.0e+21, "");
+static MagicsParameter<double> contour_shade_min_level("contour_shade_min_level", -1.0e+21, "");
+static MagicsParameter<string> contour_shade_colour_method("contour_shade_colour_method", "calculate", "");
+#include "PolyShadingTechnique.h"
+#include "MarkerShadingTechnique.h"
+#include "CellShading.h"
+static SimpleObjectMaker<PolyShadingTechnique, ShadingTechnique> polygon_shading_PolyShadingTechnique("polygon_shading");
+static SimpleObjectMaker<PolyShadingTechnique, ShadingTechnique> polygon_PolyShadingTechnique("polygon");
+static SimpleObjectMaker<GridShading, ShadingTechnique> grid_shading_GridShading("grid_shading");
+static SimpleObjectMaker<CellShading, ShadingTechnique> cell_shading_CellShading("cell_shading");
+static SimpleObjectMaker<MarkerShadingTechnique, ShadingTechnique> marker_MarkerShadingTechnique("marker");
+#include "CalculateColourTechnique.h"
+#include "ListColourTechnique.h"
+static SimpleObjectMaker<CalculateColourTechnique, ColourTechnique> calculate_CalculateColourTechnique("calculate");
+static SimpleObjectMaker<ListColourTechnique, ColourTechnique> list_ListColourTechnique("list");
diff --git a/src/visualisers/IsoShadingAttributes.h b/src/visualisers/IsoShadingAttributes.h
new file mode 100644
index 0000000..9ba2b2e
--- /dev/null
+++ b/src/visualisers/IsoShadingAttributes.h
@@ -0,0 +1,86 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file IsoShadingAttributes.h
+    \brief Definition of IsoShading Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef IsoShadingAttributes_H
+#define IsoShadingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "ShadingTechnique.h"
+#include "ColourTechnique.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class IsoShadingAttributes 
+{
+public:
+//  --  constructor
+    IsoShadingAttributes();
+    
+//  --  destructor
+    virtual ~IsoShadingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const IsoShadingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<ShadingTechnique> technique_;
+	double max_;
+	double min_;
+	auto_ptr<ColourTechnique> colourMethod_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const IsoShadingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/LabelPlotting.cc b/src/visualisers/LabelPlotting.cc
new file mode 100644
index 0000000..116d4de
--- /dev/null
+++ b/src/visualisers/LabelPlotting.cc
@@ -0,0 +1,84 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LabelPlotting.cc
+    \brief Implementation of the Template class LabelPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+
+#include "LabelPlotting.h"
+#include "Text.h"
+#include "GridPlotting.h" 
+#include "BasicSceneObject.h" 
+using namespace magics;
+
+LabelPlotting::LabelPlotting() :layer_(0)
+{
+}
+
+LabelPlotting::~LabelPlotting() 
+{
+	if (layer_) layer_->clear();
+}
+
+void LabelPlotting::prepare(NoGridPlotting& grid)
+{
+
+	
+	
+	if ( *colour_ == "UNDEFINED" ) {
+
+		colour_ = auto_ptr<Colour>(new Colour(grid.colour()));
+	}
+	
+	if ( longitudes_.empty() )
+		grid.longitudes(longitudes_, lonFrequency_);
+
+	if ( latitudes_.empty() )
+		grid.latitudes(latitudes_, latFrequency_);
+
+    
+    
+        
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LabelPlotting::print(ostream& out)  const
+{
+	out << "LabelPlotting[";
+	LabelPlottingAttributes::print(out);
+	out << "] ";
+}
+
+void NoLabelPlotting::label(Transformation& transformation)
+{
+	transformation.needTopAxis(false);
+}
+void LabelPlotting::label(Transformation& transformation)
+{
+	transformation.needTopAxis(true);
+}
diff --git a/src/visualisers/LabelPlotting.h b/src/visualisers/LabelPlotting.h
new file mode 100644
index 0000000..fc6eb5a
--- /dev/null
+++ b/src/visualisers/LabelPlotting.h
@@ -0,0 +1,169 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LabelPlotting.h
+    \brief Definition of the Template class LabelPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 2-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef LabelPlotting_H
+#define LabelPlotting_H
+
+#include "magics.h"
+
+#include "SceneVisitor.h"
+#include "LabelPlottingAttributes.h"
+#include "UserPoint.h"
+#include "Text.h"
+#include "Symbol.h"
+#include "VectorOfPointers.h"
+#include "Transformation.h"
+
+
+namespace magics {
+
+class NoGridPlotting;
+
+
+
+class NoLabelPlotting {
+
+public:
+	NoLabelPlotting() {}
+	virtual ~NoLabelPlotting() {}
+    
+    virtual void set(const XmlNode&) {}
+    virtual void set(const map<string, string>&) {}
+    virtual void toxml(ostream&, int = 0) const {} 
+    virtual bool accept(const string&) { return false; }
+    virtual NoLabelPlotting* clone() const { return new NoLabelPlotting(); }
+    virtual void operator()(DrawingVisitor&) {}
+    virtual void prepare(NoGridPlotting&) {}
+    
+    virtual void operator()(LeftAxisVisitor&) {}
+    virtual void operator()(RightAxisVisitor&) {}
+    virtual void operator()(BottomAxisVisitor&) {}
+    virtual void operator()(TopAxisVisitor&) {}
+    
+    virtual void layer(BasicGraphicsObjectContainer*) {}
+     virtual void label(Transformation&);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "NoLabelPlotting\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	NoLabelPlotting(const NoLabelPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoLabelPlotting& operator=(const NoLabelPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoLabelPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, NoLabelPlotting> { 
+public:
+	NoLabelPlotting* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoLabelPlotting>::create(val);
+	}     
+
+	NoLabelPlotting* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+class LabelPlotting: public NoLabelPlotting, public LabelPlottingAttributes {
+
+public:
+	LabelPlotting();
+	virtual ~LabelPlotting();
+	void prepare(NoGridPlotting& grid);
+	
+	virtual LabelPlotting* clone() const
+	{
+		LabelPlotting* object = new LabelPlotting();
+		object->copy(*this);
+		return object;
+	}
+	virtual void set(const XmlNode& node) { LabelPlottingAttributes::set(node); }
+    virtual void set(const map<string, string>& map) { LabelPlottingAttributes::set(map);}
+	
+	bool accept(const string& node) { return LabelPlottingAttributes::accept(node); }
+
+	template <class V>
+	void label(V& visitor) {
+		if (!layer_) layer_ = &visitor.layout();
+		visitor.transformation().labels(*this, visitor);
+		layer_ = 0;
+	}
+	void operator()(DrawingVisitor& visitor)       { label(visitor); }
+	void operator()(LeftAxisVisitor& visitor)       { if ( left_ ) label(visitor); }
+	void operator()(RightAxisVisitor& visitor)     { if ( right_ ) label(visitor); }
+	void operator()(BottomAxisVisitor& visitor)  { if ( bottom_ ) label(visitor); }
+	void operator()(TopAxisVisitor& visitor)        { if (top_) label(visitor); }
+	void layer(BasicGraphicsObjectContainer* layer) { layer_ = layer; }
+	void label(Transformation&);
+	void add(Text* text) const
+	{
+		MagFont font;
+		font.colour(*colour_);
+		font.size(height_);
+		text->setFont(font);
+		text->setBlanking(true);
+		layer_->push_back(text);
+	}
+
+	const vector<double>& longitudes() const { return longitudes_; }
+	const vector<double>& latitudes()  const { return latitudes_; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const;  
+	vector<double> latitudes_;
+	vector<double> longitudes_;
+	BasicGraphicsObjectContainer* layer_;
+private:
+	//! Copy constructor - No copy allowed
+	LabelPlotting(const LabelPlotting&);
+	//! Overloaded << operator to copy - No copy allowed
+	LabelPlotting& operator=(const LabelPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LabelPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/LabelPlottingAttributes.h b/src/visualisers/LabelPlottingAttributes.h
new file mode 100644
index 0000000..16c96b3
--- /dev/null
+++ b/src/visualisers/LabelPlottingAttributes.h
@@ -0,0 +1,90 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LabelPlottingAttributes.h
+    \brief Definition of LabelPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef LabelPlottingAttributes_H
+#define LabelPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LabelPlottingAttributes 
+{
+public:
+//  --  constructor
+    LabelPlottingAttributes();
+    
+//  --  destructor
+    virtual ~LabelPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LabelPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string quality_;
+	auto_ptr<Colour> colour_;
+	double height_;
+	int latFrequency_;
+	int lonFrequency_;
+	bool left_;
+	bool right_;
+	bool top_;
+	bool bottom_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LabelPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/LandgramBox.cc b/src/visualisers/LandgramBox.cc
new file mode 100644
index 0000000..79f955a
--- /dev/null
+++ b/src/visualisers/LandgramBox.cc
@@ -0,0 +1,144 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LandgramBox.cc
+    \brief Implementation of the Template class LandgramBox.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "LandgramBox.h"
+#include "PointsHandler.h"
+#include "DateTime.h"
+#include "Text.h"
+#include "Polyline.h"
+#include "Graph.h"
+
+
+using namespace magics;
+
+
+
+LandgramBox::LandgramBox() 
+{}
+
+
+LandgramBox::~LandgramBox() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LandgramBox::print(ostream& out)  const
+{
+	out << "LandgramBox[";
+	out << "]";
+}
+
+
+
+void LandgramBox::operator()(Data& /*data*/, BasicGraphicsObjectContainer& /*out*/)
+{
+/*
+	CustomisedPointsList points; 
+	std::set<magstring> request;
+	data.customisedPoints(request, points);
+
+	Box& box = owner.layout().box("drawing_area");	
+	box.setClip(false);
+	
+	if (points.empty()) return;
+	
+	
+
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point)
+	{
+		    MagLog::dev() << **point << endl;
+		   
+		    double step = (**point)["step"];
+		    double top2 = (**point)["box2"];
+		    double top1 = (**point)["box1"];
+		    double bottom1 = (**point)["box-1"]; 
+		    double bottom2 = (**point)["box-2"];
+			Polyline<UserPoint>* box1  = new Polyline<UserPoint>(LayerManager::layer("landgram"), "drawing_area");				
+			box1->setFilled(true);	
+			box1->setFillColour(*top1_colour_);
+			box1->setColour(Colour("black"));
+			ShadingProperties* shading1 = (magCompare(top1_shading_, "solid") ) ? (ShadingProperties*)new FillShadingProperties() : (ShadingProperties*)new DotShadingProperties();
+			box1->setShading(shading1);			
+			
+			box1->push_back(UserPoint(step-width_, 0));
+			box1->push_back(UserPoint(step-width_, top1));
+			box1->push_back(UserPoint(step, top1));
+			box1->push_back(UserPoint(step, 0));
+				
+			Polyline<UserPoint>* box2  = new Polyline<UserPoint>(LayerManager::layer("landgram"), "drawing_area");				
+			box2->setFilled(true);	
+			box2->setFillColour(*top2_colour_);
+			box2->setColour(Colour("black"));
+			ShadingProperties* shading2 = (magCompare(top2_shading_, "solid") ) ? (ShadingProperties*)new FillShadingProperties() : (ShadingProperties*)new DotShadingProperties();
+			box2->setShading(shading2);			
+			
+			box2->push_back(UserPoint(step-width_, top1));
+			box2->push_back(UserPoint(step-width_, top2+top1));
+			box2->push_back(UserPoint(step, top2+top1));
+			box2->push_back(UserPoint(step, top1));
+			
+			Polyline<UserPoint>* box3  = new Polyline<UserPoint>(LayerManager::layer("landgram"), "drawing_area");				
+			box3->setFilled(true);	
+			box3->setFillColour(*bottom1_colour_);
+			box3->setColour(Colour("black"));
+			ShadingProperties* shading3 = (magCompare(bottom1_shading_, "solid") ) ? (ShadingProperties*)new FillShadingProperties() : (ShadingProperties* )new DotShadingProperties();
+			box3->setShading(shading3);			
+			
+			box3->push_back(UserPoint(step-width_, 0));
+			box3->push_back(UserPoint(step-width_, bottom1));
+			box3->push_back(UserPoint(step, bottom1));
+			box3->push_back(UserPoint(step, 0));
+				
+			Polyline<UserPoint>* box4  = new Polyline<UserPoint>(LayerManager::layer("landgram"), "drawing_area");				
+			box4->setFilled(true);	
+			box4->setFillColour(*bottom2_colour_);
+			box4->setColour(Colour("black"));
+			ShadingProperties* shading4 = (magCompare(bottom2_shading_, "solid") ) ? (ShadingProperties*) new FillShadingProperties() : (ShadingProperties*)new DotShadingProperties();
+			box4->setShading(shading4);			
+			
+			box4->push_back(UserPoint(step-width_, bottom1));
+			box4->push_back(UserPoint(step-width_, bottom2+bottom1));
+			box4->push_back(UserPoint(step, bottom2+bottom1));
+			box4->push_back(UserPoint(step, bottom1));
+			
+			out.push_back(box1);
+			out.push_back(box2);
+			out.push_back(box3);
+			out.push_back(box4);
+	}
+	*/	
+}
+
+void LandgramBox::visit(LegendVisitor&)
+{
+	//legend.push_back(new EpsEntry());
+}
diff --git a/src/visualisers/LandgramBox.h b/src/visualisers/LandgramBox.h
new file mode 100644
index 0000000..ff54521
--- /dev/null
+++ b/src/visualisers/LandgramBox.h
@@ -0,0 +1,87 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LandgramBox.h
+    \brief Definition of the Template class LandgramBox.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef LandgramBox_H
+#define LandgramBox_H
+
+#include "magics.h"
+
+
+#include "LandgramBoxAttributes.h"
+
+
+#include "magics.h"
+#include "UserPoint.h"
+#include "Visdef.h"
+namespace magics {
+
+class XmlNode;
+class LegendVisitor;
+
+class LandgramBox: public LandgramBoxAttributes, public Visdef {
+
+
+
+public:
+	LandgramBox();
+	virtual ~LandgramBox();
+    
+   
+    
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { LandgramBoxAttributes::set(map); }
+    void set(const XmlNode& node) { LandgramBoxAttributes::set(node); }
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	LandgramBox(const LandgramBox&);
+    //! Overloaded << operator to copy - No copy allowed
+	LandgramBox& operator=(const LandgramBox&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LandgramBox& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/LegendBoxAttributes.h b/src/visualisers/LegendBoxAttributes.h
new file mode 100644
index 0000000..e883da1
--- /dev/null
+++ b/src/visualisers/LegendBoxAttributes.h
@@ -0,0 +1,80 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LegendBoxAttributes.h
+    \brief Definition of LegendBox Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef LegendBoxAttributes_H
+#define LegendBoxAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LegendBoxAttributes 
+{
+public:
+//  --  constructor
+    LegendBoxAttributes();
+    
+//  --  destructor
+    virtual ~LegendBoxAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LegendBoxAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LegendBoxAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/LegendMethod.cc b/src/visualisers/LegendMethod.cc
new file mode 100644
index 0000000..224db21
--- /dev/null
+++ b/src/visualisers/LegendMethod.cc
@@ -0,0 +1,126 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LegendMethod.cc
+    \brief Implementation of the Template class LegendMethod.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 9-May-2006
+    
+    Changes:
+    
+*/
+
+#include "LegendMethod.h"
+#include "LegendVisitor.h"
+
+
+
+using namespace magics;
+
+LegendMethod::LegendMethod() 
+{
+}
+
+
+LegendMethod::~LegendMethod() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LegendMethod::print(ostream& out)  const
+{
+	out << "LegendMethod[";
+	out << "]";
+}
+
+void LegendMethod::row(LegendEntry& entry, double x, double y, Text& legend, BasicGraphicsObjectContainer& task) 
+{
+	PaperPoint middle(x, y);
+	entry.set(middle, task);
+	
+	legend.setJustification(MLEFT);		
+	legend.push_back(entry.leftTextBox(middle)); // WE attach the text on the rigth of the sumbol!
+} 	
+
+void LegendMethod::column(LegendEntry& entry, double x, double y, Text& legend, BasicGraphicsObjectContainer& task) 
+{
+	
+	PaperPoint middle(x, y);
+	entry.set(middle, task);
+    
+	legend.setJustification(MLEFT);
+	legend.push_back(entry.leftTextBox(middle)); // WE attach the text on the rigth of the sumbol!
+	
+
+} 
+
+void ContinuousLegendMethod::row(LegendEntry& entry, double x, double y, Text& legend, BasicGraphicsObjectContainer& task) 
+{
+	if ( labelCount_ % label_frequency_ != 0 )
+		entry.notext();
+	PaperPoint middle(x, y);
+	entry.rowBox(middle, task);
+
+	if ( entry.needContinuousText() ) {
+		legend.setJustification(MLEFT);		
+		legend.push_back(entry.leftTextBox(middle)); // WE attach the text on the bottom of the sumbol!
+	}
+
+	labelCount_++;
+} 		
+
+void ContinuousLegendMethod::column(LegendEntry& entry, double x, double y, Text& legend, BasicGraphicsObjectContainer& task) 
+{
+	if ( labelCount_ % label_frequency_ != 0 )
+		entry.notext();
+	entry.columnBox(PaperPoint(x, y), task);
+	if ( entry.needContinuousText() ) {
+		legend.setJustification(MLEFT);		
+		legend.push_back(PaperPoint(x+0.25, y)); // WE attach the text on the right of the sumbol!
+	}
+	labelCount_++;
+} 	
+void HistogramLegendMethod::row(LegendEntry& entry, double x, double y, Text&, BasicGraphicsObjectContainer& out)
+{
+	if ( labelCount_ % label_frequency_ != 0 )
+		entry.notext();
+	PaperPoint middle(x, y);
+	Colour colour = histo_border_ ? *histo_border_colour_ : Colour("automatic");
+	ostringstream m;
+	m << "magics_" << histo_mean_marker_;
+	entry.histogramInformation(this);
+	entry.rowHisto(middle, out, colour);
+	labelCount_++;
+}
+
+void HistogramLegendMethod::column(LegendEntry& entry, double x, double y, Text&, BasicGraphicsObjectContainer& out)
+{
+	if ( labelCount_ % label_frequency_ != 0 )
+		entry.notext();
+	PaperPoint middle(x, y);
+	Colour colour = histo_border_ ? *histo_border_colour_ : Colour("automatic");
+	ostringstream m;
+	m << "magics_" << histo_mean_marker_;
+	entry.histogramInformation(this);
+	entry.columnHisto(middle, out, colour);
+	labelCount_++;
+}
diff --git a/src/visualisers/LegendMethod.h b/src/visualisers/LegendMethod.h
new file mode 100644
index 0000000..b8571c4
--- /dev/null
+++ b/src/visualisers/LegendMethod.h
@@ -0,0 +1,159 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LegendMethod.h
+    \brief Definition of the Template class LegendMethod.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 9-May-2006
+    
+    Changes:
+    
+*/
+
+#ifndef LegendMethod_H
+#define LegendMethod_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "Text.h"
+#include "PaperPoint.h"
+#include "ContinuousLegendMethodAttributes.h"
+#include "HistogramLegendMethodAttributes.h"
+
+
+namespace magics {
+	
+class LegendEntry;
+class LegendTask;
+
+
+class LegendMethod {
+
+public:
+	LegendMethod();
+	virtual ~LegendMethod();
+	enum LegendType { DISJOINT, CONTINUOUS, HISTOGRAM };
+    virtual void set(const XmlNode&) {
+    }
+    virtual void set(const map<string, string>&) {
+    }
+    virtual bool accept(const string& node) {
+    	return magCompare(node, "disjoint");
+    }
+    virtual LegendMethod* clone() const {
+        return new LegendMethod();
+    }
+    void toxml(ostream&, int  = 0) const {}
+    virtual void row(LegendEntry&, double, double, Text&, BasicGraphicsObjectContainer&);
+    virtual void column(LegendEntry&, double, double, Text&, BasicGraphicsObjectContainer&);
+    virtual LegendType name() const { return DISJOINT; }
+
+ 
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	LegendMethod(const LegendMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	LegendMethod& operator=(const LegendMethod&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LegendMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+class ContinuousLegendMethod : public LegendMethod, public ContinuousLegendMethodAttributes
+{
+public:
+	ContinuousLegendMethod():labelCount_(0) {}
+	~ContinuousLegendMethod() {}
+	  virtual void set(const XmlNode& node) {
+		  ContinuousLegendMethodAttributes::set(node);
+	    }
+	    virtual void set(const map<string, string>& map) {
+	    	ContinuousLegendMethodAttributes::set(map);
+	    }
+	 virtual bool accept(const string& node) {
+    	return magCompare(node, "continuous");
+    }
+	 virtual LegendType name() const { return CONTINUOUS; }
+	LegendMethod* clone() const { return new ContinuousLegendMethod(); }
+	virtual void row(LegendEntry&, double, double, Text&, BasicGraphicsObjectContainer&);
+	virtual void column(LegendEntry&, double, double, Text&, BasicGraphicsObjectContainer&);
+protected:
+	int labelCount_;
+
+};
+
+class HistogramLegendMethod : public LegendMethod, public HistogramLegendMethodAttributes
+{
+public:
+	HistogramLegendMethod(): labelCount_(0) {}
+	~HistogramLegendMethod() {}
+	  virtual void set(const XmlNode& node) {
+		  HistogramLegendMethodAttributes::set(node);
+	    }
+	    virtual void set(const map<string, string>& map) {
+	    	HistogramLegendMethodAttributes::set(map);
+	    }
+	 virtual bool accept(const string& node) {
+    	return magCompare(node, "histogram");
+    }
+	 virtual LegendType name() const { return HISTOGRAM; }
+	LegendMethod* clone() const { return new HistogramLegendMethod(); }
+	virtual void row(LegendEntry&, double, double, Text&, BasicGraphicsObjectContainer&);
+	virtual void column(LegendEntry&, double, double, Text&, BasicGraphicsObjectContainer&);
+	const Colour& gridColour() const { return *histo_grid_colour_; }
+	int gridThickness() const  { return histo_grid_thickness_; }
+	LineStyle gridStyle() const  { return histo_grid_style_; }
+	bool max() const  { return histo_max_; }
+	bool mean() const  { return histo_mean_; }
+	const Colour& meanColour() const { return *histo_mean_colour_; }
+	int meanMarker() const { return histo_mean_marker_; }
+	double meanSize() const { return histo_mean_size_; }
+
+protected:
+	int labelCount_;
+
+};
+template <>
+class MagTranslator<string, LegendMethod> { 
+public:
+	LegendMethod* operator()(const string& val )
+	{
+		return SimpleObjectMaker<LegendMethod>::create(val);
+	}     
+
+	LegendMethod* magics(const string& param)
+	{
+		LegendMethod* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/LevelListSelectionType.cc b/src/visualisers/LevelListSelectionType.cc
new file mode 100644
index 0000000..e32223c
--- /dev/null
+++ b/src/visualisers/LevelListSelectionType.cc
@@ -0,0 +1,80 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LevelListSelectionType.cc
+    \brief Implementation of the Template class LevelListSelectionType.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 10-Mar-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "LevelListSelectionType.h"
+
+using namespace magics;
+
+LevelListSelectionType::LevelListSelectionType() 
+{
+}
+
+
+LevelListSelectionType::~LevelListSelectionType() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LevelListSelectionType::print(ostream& out)  const
+{
+	out << "LevelListSelectionType[";
+	LevelSelection::print(out);
+	LevelListSelectionTypeAttributes::print(out);
+	out << "]";
+}
+
+
+void LevelListSelectionType::calculate(double , double, bool) 
+{
+	clear();
+	
+
+
+	for (doublearray::const_iterator val = list_.begin(); val != list_.end(); ++val) {
+		MagLog::dev() << "LevelListSelectionType::calculate(double min, double max)--->" << *val << "\n";
+		if ( min_ <= *val && *val <= max_)
+			push_back(*val);
+	}
+
+	
+	ostringstream print;
+	print <<  "LevelListSelectionType::calculate-->";
+	string sep = "[";
+	for (vector<double>::const_iterator val = begin(); val != end(); ++val) {
+		print << sep << *val;
+		sep = ", ";
+	}
+	print << "]";
+	MagLog::dev() << print.str() << endl;
+}
+
diff --git a/src/visualisers/LevelListSelectionType.h b/src/visualisers/LevelListSelectionType.h
new file mode 100644
index 0000000..1c32e39
--- /dev/null
+++ b/src/visualisers/LevelListSelectionType.h
@@ -0,0 +1,93 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LevelListSelectionType.h
+    \brief Definition of the Template class LevelListSelectionType.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 10-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef LevelListSelectionType_H
+#define LevelListSelectionType_H
+
+#include "magics.h"
+
+#include "LevelListSelectionTypeAttributes.h"
+#include "LevelSelection.h"
+
+namespace magics {
+
+class LevelListSelectionType: public LevelListSelectionTypeAttributes, public LevelSelection {
+
+public:
+	LevelListSelectionType();
+	virtual ~LevelListSelectionType();
+
+   
+    void calculate(double min, double max, bool); 
+    void set(const map<string, string>& params) { 
+        LevelListSelectionTypeAttributes::set(params);
+        LevelSelection::set(params);
+    }
+    void set(const XmlNode& node) { 
+        LevelListSelectionTypeAttributes::set(node);
+        LevelSelection::set(node);
+    }
+    void set(const LevelSelectionInterface& from) {
+        list_ = from.getList();
+    }
+    virtual LevelSelection* clone() const {
+    	LevelListSelectionType* object = new LevelListSelectionType();
+    	object->copy(*this);
+    	return object;
+    }
+
+    double reference() const { return  empty() ? -9999:    front(); }
+
+    void copy(const LevelListSelectionType& from) {
+    	 LevelListSelectionTypeAttributes::copy(from);
+         LevelSelection::copy(from);
+    }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	LevelListSelectionType(const LevelListSelectionType&);
+    //! Overloaded << operator to copy - No copy allowed
+	LevelListSelectionType& operator=(const LevelListSelectionType&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LevelListSelectionType& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/LevelListSelectionTypeAttributes.h b/src/visualisers/LevelListSelectionTypeAttributes.h
new file mode 100644
index 0000000..fb99f55
--- /dev/null
+++ b/src/visualisers/LevelListSelectionTypeAttributes.h
@@ -0,0 +1,81 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LevelListSelectionTypeAttributes.h
+    \brief Definition of LevelListSelectionType Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef LevelListSelectionTypeAttributes_H
+#define LevelListSelectionTypeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LevelListSelectionTypeAttributes 
+{
+public:
+//  --  constructor
+    LevelListSelectionTypeAttributes();
+    
+//  --  destructor
+    virtual ~LevelListSelectionTypeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LevelListSelectionTypeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	floatarray list_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LevelListSelectionTypeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/LevelSelection.cc b/src/visualisers/LevelSelection.cc
new file mode 100644
index 0000000..8bc0ac6
--- /dev/null
+++ b/src/visualisers/LevelSelection.cc
@@ -0,0 +1,103 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LevelSelection.cc
+    \brief Implementation of the Template class LevelSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+#include "LevelSelection.h"
+
+using namespace magics;
+
+LevelSelection::LevelSelection() 
+{
+}
+
+
+LevelSelection::~LevelSelection() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LevelSelection::print(ostream& out)  const
+{
+	out << "LevelSelection[";
+	doublearray::print(out);
+	out << "]";
+}
+void LevelSelection::thinLevels(int frequency, vector<double>& out) const
+{
+	double ref = reference();
+	int count = 0;
+	// Fisrt is the reference in the levels list?
+
+	const_iterator reflev = find(begin(), end(), ref);
+	if ( reflev == end() )
+		reflev = begin();
+
+	for (const_iterator level = reflev; level != end(); ++level) {
+		if ( count%frequency == 0 )
+			out.push_back(*level);
+		count++;
+	}
+
+// now we have to reverse!
+	const_reverse_iterator rlevel = rbegin();
+
+	while ( rlevel != rend() ) {
+
+			if (*rlevel == *reflev )
+				break;
+			++rlevel;
+		}
+	count=1;
+	++rlevel;
+
+	for (rlevel; rlevel != rend(); ++rlevel) {
+		if ( count%frequency == 0 ) {
+			out.push_back(*rlevel);
+
+		}
+		count++;
+	}
+
+	sort(out.begin(), out.end());
+	ostringstream level;
+	ostringstream sel;
+	for (  vector<double>::const_iterator l = begin(); l != end(); ++l)
+		level << "  " << *l << "    ";
+
+	for (  vector<double>::iterator l = out.begin(); l != out.end(); ++l)
+		sel << "  " << *l << "    ";
+
+	MagLog::dev() << "Level --->" << level.str() << endl << "selection(" << frequency << ")--->" << sel.str() << endl;
+}
+
+double LevelSelection::reference() const
+{
+	return empty() ? -9999: front();
+}
diff --git a/src/visualisers/LevelSelection.h b/src/visualisers/LevelSelection.h
new file mode 100644
index 0000000..1070a54
--- /dev/null
+++ b/src/visualisers/LevelSelection.h
@@ -0,0 +1,105 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LevelSelection.h
+    \brief Definition of the Template class LevelSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Tue 9-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef LevelSelection_H
+#define LevelSelection_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "LevelSelectionAttributes.h"
+#include "Data.h"
+
+namespace magics {
+
+class UserPoint;
+class PointsHandler;
+
+class LevelSelectionInterface 
+{
+public:
+    virtual int getCount() const = 0; 
+    virtual int getTolerance() const = 0;
+    virtual double getReference() const = 0;
+    virtual double getInterval() const = 0;
+    virtual doublearray getList() const = 0;
+    virtual double getMin() const = 0;
+    virtual double getMax() const = 0;
+};
+
+class LevelSelection: public LevelSelectionAttributes, public doublearray
+{
+public:
+	LevelSelection();
+	virtual ~LevelSelection();
+	
+	virtual LevelSelection* clone() const {
+
+    	return 0;
+    } 
+    virtual void set(const XmlNode& node)          { LevelSelectionAttributes::set(node); }
+    virtual void set(const map<string,string>& map) { LevelSelectionAttributes::set(map); }
+    virtual void set(const LevelSelectionInterface&) {}
+    
+	virtual void calculate(double, double, bool) {};
+	virtual double reference() const;
+	virtual void thinLevels(int frequency, vector<double>&) const;
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	LevelSelection(const LevelSelection&);
+	//! Overloaded << operator to copy - No copy allowed
+	LevelSelection& operator=(const LevelSelection&);
+    
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LevelSelection& p)
+		{ p.print(s); return s; }
+};
+
+template<>
+class MagTranslator<string, LevelSelection> { 
+public:
+	LevelSelection* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<LevelSelection>::create(val);
+	}     
+	LevelSelection* magics(const string& param)
+	{
+		LevelSelection* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+} // namespace magics
+#endif
diff --git a/src/visualisers/LevelSelectionAttributes.h b/src/visualisers/LevelSelectionAttributes.h
new file mode 100644
index 0000000..6345fae
--- /dev/null
+++ b/src/visualisers/LevelSelectionAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LevelSelectionAttributes.h
+    \brief Definition of LevelSelection Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef LevelSelectionAttributes_H
+#define LevelSelectionAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LevelSelectionAttributes 
+{
+public:
+//  --  constructor
+    LevelSelectionAttributes();
+    
+//  --  destructor
+    virtual ~LevelSelectionAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LevelSelectionAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double max_;
+	double min_;
+	double max_shade_;
+	double min_shade_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LevelSelectionAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/LinearTableMode.cc b/src/visualisers/LinearTableMode.cc
new file mode 100644
index 0000000..1ffec95
--- /dev/null
+++ b/src/visualisers/LinearTableMode.cc
@@ -0,0 +1,156 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LinearTableMode.cc
+    \brief Implementation of the Template class LinearTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 17-May-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "LinearTableMode.h"
+#include "IntervalMap.h"
+
+using namespace magics;
+
+LinearTableMode::LinearTableMode()
+{
+	return;
+}
+
+
+LinearTableMode::~LinearTableMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LinearTableMode::print(ostream& out)  const
+{
+	out << "LinearTableMode[";
+	LookupTableModeAttributes::print(out);
+	out << "]";
+}
+
+void LinearTableMode::operator()(Image& im, Raster& rd)
+{
+     int 	i;		//auxiliary variables
+     double   rint;		//interval of levels
+
+     // Check image range of values
+//     double imin = (double)rd.min();
+//     double imax = (double)rd.max();
+     double imin = (minLevel_ < -1000000) ? (double)rd.min() : minLevel_;
+     double imax = (maxLevel_ >  1000000) ? (double)rd.max() : maxLevel_;
+
+     // Initialize lookuptable
+     ColourTable& table = im.getColourTable();
+     int nlevels = table.size();
+
+    // Create a map of image levels interval
+    IntervalMap<int> map;
+    rint = (imax-imin)/(double)nlevels;
+    double level = imin;
+    for( i = 0; i < nlevels; i++)
+    {
+         map[  Interval(level, level+rint) ] = i;
+//MagLog::dev()<< i << " " << level << " " << level+rint << endl;
+	 level += rint;
+    }
+
+     // Create output image
+//vector<long> hist1(nlevels,0L); //test
+//long iii=0L;
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+//	     im.push_back(lut[(int)*val]);
+	     short ii = map.find(*val,nlevels-1);
+	     im.push_back(ii);
+// iii++;
+// hist1[ii]++;
+     }
+
+//for( i = 0; i < nlevels; i++)
+//       MagLog::dev()<< i << " " << hist1[i] << endl;
+//MagLog::dev()<< "total=" << iii<< endl;
+
+     return;
+}
+
+#if 0
+void LinearTableMode::operator()(Image& im, Raster& rd)
+{
+     int 	i;		 //auxiliary variables
+     double   ratio;           // imagel level ratio
+
+     // Check image range of values
+     int imin = (int)rd.min();
+     int imax = (int)rd.max();
+#if 0 //remove later
+     if (imax > ETM_MLEN || imin < 0 )
+     {
+	  MagLog::dev()<< "LinearTableMode: Invalid range of image values (" << imin << "," << imax << ")" << endl;
+	  MagLog::dev()<< "Current implementation accepts values between 0 to " << ETM_MLEN << endl;
+	  return;
+     }
+#endif
+
+     // Initialize lookuptable
+     ColourTable& table = im.getColourTable();
+     int nlevels = table.size();
+
+     // Reserve memory for the lut
+     imax++; //index imax is needed
+     vector<short> lut(imax);
+   
+    // Create lut
+    ratio = (double)(imax-imin)/(double)nlevels;
+    for( i = 0; i < imax; i++)
+    {
+   	 if (i < imin)
+	     lut[i] = 0;
+	 else if (i > imax)
+	     lut[i] = nlevels-1;
+	 else
+       	     lut[i] =  (short)( (double)(i-imin)/ratio );
+     }
+
+     // Create output image
+vector<long> hist1(nlevels+1,0L); //test
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+//	     im.push_back(lut[(int)*val]);
+	     short ii = lut[(int)*val];
+	     im.push_back(ii);
+hist1[ii]++;
+     }
+
+     MagLog::dev()<< "LinearTableMode::operator()" << endl;
+     for( i = 0; i < nlevels+1; i++)
+	     MagLog::dev()<< i << " " << hist1[i] << endl;
+
+     return;
+}
+#endif
diff --git a/src/visualisers/LinearTableMode.h b/src/visualisers/LinearTableMode.h
new file mode 100644
index 0000000..1193593
--- /dev/null
+++ b/src/visualisers/LinearTableMode.h
@@ -0,0 +1,69 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LinearTableMode.h
+    \brief Definition of the Template class LinearTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 14-July-2005
+    
+    Changes:
+    
+*/
+
+#ifndef LinearTableMode_H
+#define LinearTableMode_H
+
+#include "magics.h"
+
+#include "LookupTableMode.h"
+
+namespace magics {
+
+class LinearTableMode: public LookupTableMode {
+
+public:
+	LinearTableMode();
+	virtual ~LinearTableMode();
+	void set(const XmlNode& node ) // for MagML
+			 { LookupTableModeAttributes::set(node); }
+	void set(const map<string, string>& map ) // for MagML
+		 { LookupTableModeAttributes::set(map); }
+
+	virtual void operator()(Image&, Raster&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	LinearTableMode(const LinearTableMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	LinearTableMode& operator=(const LinearTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LinearTableMode& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ListColourTechnique.cc b/src/visualisers/ListColourTechnique.cc
new file mode 100644
index 0000000..6a32931
--- /dev/null
+++ b/src/visualisers/ListColourTechnique.cc
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ListColourTechnique.cc
+    \brief Implementation of the Template class ListColourTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+
+#include "ListColourTechnique.h"
+#include "LevelSelection.h"
+#include "ColourTableDefinitionList.h"
+
+using namespace magics;
+
+ListColourTechnique::ListColourTechnique() 
+{
+    
+}
+
+void ListColourTechnique::set(ColourTable& table, int nb) const
+{
+    ColourTableDefinitionList helper;
+    helper.set(*this);
+    helper.set(table, nb);
+}
+
+
+ListColourTechnique::~ListColourTechnique() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void ListColourTechnique::print(ostream& out)  const
+{
+	out << "ListColourTechnique[";
+	out << "]";
+}
+
+void ListColourTechnique::set(const ColourTechniqueInterface& attributes)
+{
+	values_ = attributes.getColours();
+}
diff --git a/src/visualisers/ListColourTechnique.h b/src/visualisers/ListColourTechnique.h
new file mode 100644
index 0000000..62f78b6
--- /dev/null
+++ b/src/visualisers/ListColourTechnique.h
@@ -0,0 +1,81 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ListColourTechnique.h
+    \brief Definition of the Template class ListColourTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ListColourTechnique_H
+#define ListColourTechnique_H
+
+#include "magics.h"
+
+#include "ColourTechnique.h"
+#include "ListColourTechniqueAttributes.h"
+namespace magics {
+
+class ListColourTechnique: public ColourTechnique, public ListColourTechniqueAttributes {
+
+public:
+	ListColourTechnique();
+	virtual ~ListColourTechnique();
+    void set(const map<string, string>& map) { 
+        ListColourTechniqueAttributes::set(map); 
+    }
+    void set(const XmlNode& node) { 
+        ListColourTechniqueAttributes::set(node); 
+    }
+    bool accept(const string& node) { return ListColourTechniqueAttributes::accept(node); }
+    
+    virtual ColourTechnique* clone() const {
+    	ListColourTechnique* object = new ListColourTechnique();
+    	object->copy(*this);
+    	return object;
+    }
+   
+    virtual void set(ColourTable&, int) const;
+	void set(const ColourTechniqueInterface&);
+	stringarray getValues() const { return values_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     
+     
+private:
+    //! Copy constructor - No copy allowed
+	ListColourTechnique(const ListColourTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	ListColourTechnique& operator=(const ListColourTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ListColourTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ListColourTechniqueAttributes.h b/src/visualisers/ListColourTechniqueAttributes.h
new file mode 100644
index 0000000..b81bfcf
--- /dev/null
+++ b/src/visualisers/ListColourTechniqueAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ListColourTechniqueAttributes.h
+    \brief Definition of ListColourTechnique Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef ListColourTechniqueAttributes_H
+#define ListColourTechniqueAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "ColourTableDefinitionListInterface.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ListColourTechniqueAttributes : public ColourTableDefinitionListInterface
+{
+public:
+//  --  constructor
+    ListColourTechniqueAttributes();
+    
+//  --  destructor
+    virtual ~ListColourTechniqueAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ListColourTechniqueAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	stringarray values_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ListColourTechniqueAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/LookupTableMode.cc b/src/visualisers/LookupTableMode.cc
new file mode 100644
index 0000000..07173c0
--- /dev/null
+++ b/src/visualisers/LookupTableMode.cc
@@ -0,0 +1,104 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LookupTableMode.cc
+    \brief Implementation of the Template class LookupTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 17-May-2005
+    
+    Changes:
+    
+*/
+
+#include "LookupTableMode.h"
+#include "IntervalMap.h"
+
+using namespace magics;
+
+LookupTableMode::LookupTableMode() 
+{
+}
+
+
+LookupTableMode::~LookupTableMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void LookupTableMode::print(ostream& out)  const
+{
+	out << "LookupTableMode[";
+	LookupTableModeAttributes::print(out);
+	out << "]";
+}
+FixedTableMode::FixedTableMode()
+{
+	
+}
+
+
+FixedTableMode::~FixedTableMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void FixedTableMode::print(ostream& out)  const
+{
+	out << "FixedTableMode[";
+	FixedTableModeAttributes::print(out);
+	LookupTableModeAttributes::print(out);
+	out << "]";
+}
+
+void FixedTableMode::operator()(Image& im, Raster& rd)
+{
+     int 	i;		//auxiliary variables
+     
+     MagLog::dev() << *this << endl;
+
+     // Initialize lookuptable
+ //    ColourTable& table = im.getColourTable();
+     //int nlevels = table.size();
+
+    // Create a map of image levels interval
+    IntervalMap<int> map;
+    int level1 = levels_[0];
+
+    for( i = 1; i < (int)levels_.size(); i++)
+    {
+         map[ Interval(level1, levels_[i]) ] = indexes_[i-1];
+	 level1 = levels_[i];
+    }
+    map[Interval(level1, level1) ] = indexes_[indexes_.size()];
+
+     // Create output image
+
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+	     short ii = map.find(*val,0);
+	     im.push_back(ii);
+     }
+     return;
+}
+
diff --git a/src/visualisers/LookupTableMode.h b/src/visualisers/LookupTableMode.h
new file mode 100644
index 0000000..61abcc3
--- /dev/null
+++ b/src/visualisers/LookupTableMode.h
@@ -0,0 +1,127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file LookupTableMode.h
+    \brief Definition of the Template class LookupTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 17-May-2005
+    
+    Changes:
+    
+*/
+
+#ifndef LookupTableMode_H
+#define LookupTableMode_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+#include "LookupTableModeAttributes.h"
+#include "FixedTableModeAttributes.h"
+#include "PaperPoint.h"
+#include "Image.h"
+#include "RasterData.h"
+
+namespace magics {
+
+
+class LookupTableMode: public LookupTableModeAttributes {
+
+public:
+	LookupTableMode();
+	virtual ~LookupTableMode();
+	virtual void set(const map<string, string>& map ) // for MagML
+		 { LookupTableModeAttributes::set(map); }
+	virtual void set(const XmlNode& node) // for MagML
+		 { LookupTableModeAttributes::set(node); }
+	virtual LookupTableMode* clone() const { 
+		 LookupTableMode* object = new LookupTableMode();
+		 object->copy(*this);
+		 return object;
+	}
+
+	virtual void operator()(Image&, Raster&) {}
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	LookupTableMode(const LookupTableMode&);
+	//! Overloaded << operator to copy - No copy allowed
+	LookupTableMode& operator=(const LookupTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const LookupTableMode& p)
+		{ p.print(s); return s; }
+};
+
+
+
+class FixedTableMode : public LookupTableMode, public FixedTableModeAttributes {
+
+public:
+	FixedTableMode();
+	virtual ~FixedTableMode();
+	void set(const map<string, string>& map ) // for MagML
+	{
+	   LookupTableMode::set(map); 
+	   FixedTableModeAttributes::set(map);
+	}
+	void set(const XmlNode& node ) // for MagML
+	{
+	   LookupTableMode::set(node); 
+	   FixedTableModeAttributes::set(node);
+	}
+
+	virtual void operator()(Image&, Raster&);
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const FixedTableMode& p)
+		{ p.print(s); return s; }
+};
+
+
+template<>
+class MagTranslator<string, LookupTableMode> { 
+public:
+    LookupTableMode* operator()(const string& val )
+    {
+	return SimpleObjectMaker<LookupTableMode>::create(val);
+    }
+     
+    LookupTableMode* magics(const string& param)
+    {
+        LookupTableMode* object;
+	ParameterManager::update(param, object);
+	return object;
+    }
+
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/LookupTableModeAttributes.h b/src/visualisers/LookupTableModeAttributes.h
new file mode 100644
index 0000000..d84f725
--- /dev/null
+++ b/src/visualisers/LookupTableModeAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file LookupTableModeAttributes.h
+    \brief Definition of LookupTableMode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:15 2012
+*/
+   
+
+#ifndef LookupTableModeAttributes_H
+#define LookupTableModeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class LookupTableModeAttributes 
+{
+public:
+//  --  constructor
+    LookupTableModeAttributes();
+    
+//  --  destructor
+    virtual ~LookupTableModeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const LookupTableModeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	int minLevel_;
+	int maxLevel_;
+	double outlayer_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const LookupTableModeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Makefile.am b/src/visualisers/Makefile.am
new file mode 100644
index 0000000..d571295
--- /dev/null
+++ b/src/visualisers/Makefile.am
@@ -0,0 +1,192 @@
+noinst_LTLIBRARIES	= libvisualisers.la
+
+ATTRIBUTES =   CoastlinesAttributes.cc NoCoastPlottingAttributes.cc CoastPlottingAttributes.cc \
+	LabelPlottingAttributes.cc NoGridPlottingAttributes.cc GridPlottingAttributes.cc \
+	BoundariesAttributes.cc \
+	HiLoNumberAttributes.cc MarkerValuePlotMethodAttributes.cc HiLoMarkerAttributes.cc \
+	Akima474MethodAttributes.cc Akima760MethodAttributes.cc Akima761MethodAttributes.cc \
+	SampleContourMethodAttributes.cc HiLoTextAttributes.cc \
+	MarkerShadingTechniqueAttributes.cc \
+	IsoHighlightAttributes.cc HatchPolyShadingMethodAttributes.cc \
+	IntervalSelectionTypeAttributes.cc  \
+	GridShadingAttributes.cc CellShadingAttributes.cc DotPolyShadingMethodAttributes.cc \
+	CountSelectionTypeAttributes.cc ValuePlotMethodAttributes.cc  \
+	HiLoTechniqueAttributes.cc LevelSelectionAttributes.cc \
+	ListColourTechniqueAttributes.cc CalculateColourTechniqueAttributes.cc \
+	LevelListSelectionTypeAttributes.cc IsoLabelAttributes.cc \
+	SymbolPlottingAttributes.cc  SymbolModeAttributes.cc  SymbolTableModeAttributes.cc SymbolIndividualModeAttributes.cc \
+	ImageListColourTechniqueAttributes.cc ImageCalculateColourTechniqueAttributes.cc\
+	LookupTableModeAttributes.cc FixedTableModeAttributes.cc \
+	EquidistantTableModeAttributes.cc SimplePolylineAttributes.cc\
+	ObsPlottingAttributes.cc \
+	ImportPlotAttributes.cc ObsTableAttributes.cc ObsHeightAttributes.cc \
+	ObsWindAttributes.cc ObsStationRingAttributes.cc  \
+	ObsTimePlotAttributes.cc ObsDemoItem2Attributes.cc\
+	ObsTemperatureAttributes.cc\
+	ObsPressureAttributes.cc ObsPressureTendencyAttributes.cc \
+	ObsDewPointAttributes.cc ObsVisibilityAttributes.cc \
+	ObsPresentWeatherAttributes.cc ObsItemAttributes.cc \
+	ObsPressureLevelAttributes.cc ObsIdentifierAttributes.cc \
+	ObsCloudAttributes.cc ObsPastWeatherAttributes.cc ObsThicknessAttributes.cc\
+	EpsDirectionAttributes.cc \
+	SymbolAdvancedTableModeAttributes.cc  \
+	TaylorGridAttributes.cc\
+	ContinuousLegendMethodAttributes.cc HistogramLegendMethodAttributes.cc \
+	LegendBoxAttributes.cc GraphPlottingAttributes.cc LandgramBoxAttributes.cc \
+	CurveAttributes.cc BarAttributes.cc \
+	GraphFlagAttributes.cc GraphArrowAttributes.cc \
+	GraphAttributes.cc HatchGraphShadeStyleAttributes.cc \
+	GraphShadeStyleAttributes.cc DotGraphShadeStyleAttributes.cc GraphShadeAttributes.cc  \
+	WindPlottingAttributes.cc FlagPlottingAttributes.cc ArrowPlottingAttributes.cc \
+	CitiesAttributes.cc IsoPlotAttributes.cc ContourAttributes.cc\
+	ValuePlotAttributes.cc HiLoAttributes.cc WindAttributes.cc IsoShadingAttributes.cc \
+	PolyShadingTechniqueAttributes.cc  \
+	ImagePlottingAttributes.cc DateAxisMethodAttributes.cc \
+	CurveAreaAttributes.cc 
+
+include_H =  \
+	Title.h \
+	SymbolPlotting.h SymbolPlotting.cc Filter.h Filter.cc \
+	TitleBase.h ValuePlotBase.h  \
+	HiLoBase.h \
+	HiLoMarkerBase.h \
+	GraphShade.h GraphShadeStyle.h Boundaries.h \
+	Coastlines.h CoastlinesAttributes.h GridPlotting.h NoGridPlottingAttributes.h GridPlottingAttributes.h LabelPlottingAttributes.h CoastPlottingAttributes.h BoundariesAttributes.h  ContourAttributes.h \
+	IsoPlotAttributes.h LevelSelectionAttributes.h IsoLabelAttributes.h IsoHighlightAttributes.h IsoShadingAttributes.h IsoShadingAttributes.cc PolyShadingTechniqueAttributes.h LegendBoxAttributes.h PolyShadingTechniqueAttributes.cc \
+	HatchPolyShadingMethodAttributes.h DotPolyShadingMethodAttributes.h MarkerShadingTechniqueAttributes.h SymbolIndividualModeAttributes.h SymbolTableModeAttributes.h CellShadingAttributes.h GridShadingAttributes.h \
+	CalculateColourTechniqueAttributes.h ListColourTechniqueAttributes.h IsoPlotAttributes.cc CountSelectionTypeAttributes.h IntervalSelectionTypeAttributes.h LevelListSelectionTypeAttributes.h ContourAttributes.cc \
+	Akima474MethodAttributes.h Akima760MethodAttributes.h ContinuousLegendMethodAttributes.h  HistogramLegendMethodAttributes.h SampleContourMethodAttributes.h HiLoAttributes.h HiLoTechniqueAttributes.h HiLoAttributes.cc HiLoNumberAttributes.h HiLoTextAttributes.h HiLoMarkerAttributes.h  \
+	IsoHelper.h SegmentJoiner.h \
+	SymbolMode.h  \
+	CoastPlotting.h \
+	LabelPlotting.h \
+	Contour.h \
+	IsoPlot.h\
+	ValuePlot.h\
+	ValuePlotMethod.h MarkerValuePlotMethod.h \
+	BothValuePlotMethod.h \
+	IsoLabel.h IsoShading.h IsoShading.cc \
+	LandgramBox.h LevelSelection.h CountSelectionType.h \
+	LevelListSelectionType.h IntervalSelectionType.h \
+	ContourMethod.h \
+	Akima760Method.h Akima761Method.h  \
+	Akima474Method.h Akima474.cc \
+	Graph.h GraphPlotting.h \
+	 Curve.h Axis.h AxisItem.h \
+	FloatSelection.h ColourSelection.h MarkerSelection.h HeightSelection.h \
+	ColourSelectionCount.h ColourSelectionList.h \
+	MarkerSelectionCount.h MarkerSelectionList.h \
+	HeightSelectionCount.h HeightSelectionList.h \
+	Histogram.h Histogram.cc HistoMode.h HistoIndividualMode.h HistoTableMode.h Intervals.h \
+	HiLo.cc HiLo.h HiLoTechnique.cc HiLoTechnique.h \
+	HiLoMarker.h  HiLoText.h \
+	HiLoNumber.h HiLoBoth.h \
+	ShadingTechnique.h \
+	MarkerShadingTechnique.h MarkerShadingTechnique.cc PolyShadingTechnique.h ColourTechnique.h \
+	CalculateColourTechnique.h ListColourTechnique.h PolyShadingMethod.h \
+	DotPolyShadingMethod.h HatchPolyShadingMethod.h \
+	IsoHighlight.h \
+	AutomaticContourMethod.h \
+	DefinitionTable.h DefinitionTable.cc \
+	GribTables.h LegendMethod.h \
+	Wind.h Wind.cc WindPlotting.h \
+	FlagPlotting.h \
+	ArrowPlotting.h \
+	CalmIndicator.h OriginMarker.h \
+	ObsPlotting.h \
+	ImportPlot.h\
+	ImagePlotting.h ImagePlotting.cc \
+	LookupTableMode.h \
+	EquidistantTableMode.h \
+	NormalTableMode.h \
+	LinearTableMode.h \
+	ObsTable.h ObsItem.h ObsItemFamily.h \
+	ImageListColourTechnique.h \
+	ImageCalculateColourTechnique.h \
+	CellShading.h CellShading.cc \
+	EpsGraph.h BoxPlotVisualiser.h ObsStatGraph.h \
+	AxisMethod.h \
+	TextOrientation.h DateAxis.h  \
+	EpsForecastPlot.h \
+	Bar.h  \
+	BoxPlotItem.h TaylorGrid.h BoxPlotBasicItem.h \
+	MetgramGraph.h MetgramStyle.h \
+	SimplePolylineVisualiser.h  \
+	SymbolAdvancedTableMode.h HeightTechnique.h OutLayerTechnique.h ContourLibrary.h \
+	VisDefInfo.h  AxisAttributes.h  ObsPlottingAttributes.h ImportPlotAttributes.h \
+	ImagePlottingAttributes.h LookupTableModeAttributes.h FixedTableModeAttributes.h \
+	Cities.h
+
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= $(noinst_H)
+else
+include_HEADERS =
+noinst_HEADERS	= $(noinst_H) $(include_H)
+endif
+
+
+nodist_libvisualisers_la_SOURCES = ${ATTRIBUTES}
+
+axis= \
+	Axis.cc  \
+	DateAxis.cc \
+	AxisItem.cc  \
+	AxisMethod.cc \
+	TaylorGrid.cc  \
+	AxisAttributes.cc \
+	AxisMethodAttributes.cc
+
+metgram = \
+	EpsGraph.cc  \
+	MetgramGraph.cc MetgramStyle.cc \
+	BoxPlotVisualiser.cc\
+	BoxPlotItem.cc\
+	MetgramFlagsAttributes.cc \
+	EpsGraphAttributes.cc EpsWindAttributes.cc  EpsCloudAttributes.cc \
+	EfiGraphAttributes.cc CdfGraphAttributes.cc\
+	EpsPlumeAttributes.cc \
+	MetgramCurveAttributes.cc \
+	EpsShadeAttributes.cc MetgramGraphAttributes.cc BoxPlotVisualiserAttributes.cc \
+	BoxPlotBoxAttributes.cc BoxPlotBoxBorderAttributes.cc BoxPlotMedianAttributes.cc \
+	BoxPlotWhiskerBoxAttributes.cc BoxPlotWhiskerLineAttributes.cc BoxPlotWhiskerBorderAttributes.cc 
+
+obs=   ObsPlotting.cc ObsTable.cc \
+	ObsItemFamily.cc 
+
+libvisualisers_la_SOURCES	= ${axis} ${metgram} ${obs} ContourLibrary.cc Coastlines.cc CoastPlotting.cc \
+	ImagePlotting.cc WindPlotting.cc ArrowPlotting.cc FlagPlotting.cc \
+	IsoHelper.cc \
+	LabelPlotting.cc GridPlotting.cc Boundaries.cc \
+	ListColourTechnique.cc IntervalSelectionType.cc \
+	CountSelectionType.cc LevelSelection.cc \
+	ColourTechnique.cc CalculateColourTechnique.cc \
+	LevelListSelectionType.cc IsoLabel.cc \
+	TextOrientation.cc \
+	LegendMethod.cc SymbolMode.cc \
+	SimplePolylineVisualiser.cc \
+	LookupTableMode.cc \
+	EquidistantTableMode.cc \
+	NormalTableMode.cc LinearTableMode.cc \
+	BothValuePlotMethodAttributes.cc  \
+	SymbolAdvancedTableMode.cc HeightTechnique.cc \
+	OutLayerTechnique.cc \
+	HistogramAttributes.cc \
+	GraphPlotting.cc LandgramBox.cc Bar.cc Curve.cc  \
+	GraphShade.cc GraphShadeStyle.cc  \
+	VisDefInfo.cc Cities.cc \
+	Contour.cc IsoPlot.cc  ValuePlot.cc HiLo.cc Histogram.cc  \
+	Akima760.cc Akima474.cc Wind.cc IsoShading.cc\
+	PolyShadingMethod.cc CellShading.cc \
+	MarkerShadingTechnique.cc PolyShadingTechnique.cc SymbolPlotting.cc Filter.cc \
+	SegmentJoiner.cc
+
+
+libvisualisers_la_LDFLAGS	= -no-undefined
+EXTRA_DIST			= 
+
+AM_CPPFLAGS  = ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/common -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/drivers
+if MAGICS_QT
+AM_CPPFLAGS += -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+endif
diff --git a/src/visualisers/Makefile.in b/src/visualisers/Makefile.in
new file mode 100644
index 0000000..16c833c
--- /dev/null
+++ b/src/visualisers/Makefile.in
@@ -0,0 +1,1192 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_QT_TRUE@am__append_1 = -I$(top_srcdir)/src/drivers/MgQ $(QT_CPPFLAGS)
+subdir = src/visualisers
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libvisualisers_la_LIBADD =
+am__objects_1 = Axis.lo DateAxis.lo AxisItem.lo AxisMethod.lo \
+	TaylorGrid.lo AxisAttributes.lo AxisMethodAttributes.lo
+am__objects_2 = EpsGraph.lo MetgramGraph.lo MetgramStyle.lo \
+	BoxPlotVisualiser.lo BoxPlotItem.lo MetgramFlagsAttributes.lo \
+	EpsGraphAttributes.lo EpsWindAttributes.lo \
+	EpsCloudAttributes.lo EfiGraphAttributes.lo \
+	CdfGraphAttributes.lo EpsPlumeAttributes.lo \
+	MetgramCurveAttributes.lo EpsShadeAttributes.lo \
+	MetgramGraphAttributes.lo BoxPlotVisualiserAttributes.lo \
+	BoxPlotBoxAttributes.lo BoxPlotBoxBorderAttributes.lo \
+	BoxPlotMedianAttributes.lo BoxPlotWhiskerBoxAttributes.lo \
+	BoxPlotWhiskerLineAttributes.lo \
+	BoxPlotWhiskerBorderAttributes.lo
+am__objects_3 = ObsPlotting.lo ObsTable.lo ObsItemFamily.lo
+am_libvisualisers_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
+	$(am__objects_3) ContourLibrary.lo Coastlines.lo \
+	CoastPlotting.lo ImagePlotting.lo WindPlotting.lo \
+	ArrowPlotting.lo FlagPlotting.lo IsoHelper.lo LabelPlotting.lo \
+	GridPlotting.lo Boundaries.lo ListColourTechnique.lo \
+	IntervalSelectionType.lo CountSelectionType.lo \
+	LevelSelection.lo ColourTechnique.lo \
+	CalculateColourTechnique.lo LevelListSelectionType.lo \
+	IsoLabel.lo TextOrientation.lo LegendMethod.lo SymbolMode.lo \
+	SimplePolylineVisualiser.lo LookupTableMode.lo \
+	EquidistantTableMode.lo NormalTableMode.lo LinearTableMode.lo \
+	BothValuePlotMethodAttributes.lo SymbolAdvancedTableMode.lo \
+	HeightTechnique.lo OutLayerTechnique.lo HistogramAttributes.lo \
+	GraphPlotting.lo LandgramBox.lo Bar.lo Curve.lo GraphShade.lo \
+	GraphShadeStyle.lo VisDefInfo.lo Cities.lo Contour.lo \
+	IsoPlot.lo ValuePlot.lo HiLo.lo Histogram.lo Akima760.lo \
+	Akima474.lo Wind.lo IsoShading.lo PolyShadingMethod.lo \
+	CellShading.lo MarkerShadingTechnique.lo \
+	PolyShadingTechnique.lo SymbolPlotting.lo Filter.lo \
+	SegmentJoiner.lo
+am__objects_4 = CoastlinesAttributes.lo NoCoastPlottingAttributes.lo \
+	CoastPlottingAttributes.lo LabelPlottingAttributes.lo \
+	NoGridPlottingAttributes.lo GridPlottingAttributes.lo \
+	BoundariesAttributes.lo HiLoNumberAttributes.lo \
+	MarkerValuePlotMethodAttributes.lo HiLoMarkerAttributes.lo \
+	Akima474MethodAttributes.lo Akima760MethodAttributes.lo \
+	Akima761MethodAttributes.lo SampleContourMethodAttributes.lo \
+	HiLoTextAttributes.lo MarkerShadingTechniqueAttributes.lo \
+	IsoHighlightAttributes.lo HatchPolyShadingMethodAttributes.lo \
+	IntervalSelectionTypeAttributes.lo GridShadingAttributes.lo \
+	CellShadingAttributes.lo DotPolyShadingMethodAttributes.lo \
+	CountSelectionTypeAttributes.lo ValuePlotMethodAttributes.lo \
+	HiLoTechniqueAttributes.lo LevelSelectionAttributes.lo \
+	ListColourTechniqueAttributes.lo \
+	CalculateColourTechniqueAttributes.lo \
+	LevelListSelectionTypeAttributes.lo IsoLabelAttributes.lo \
+	SymbolPlottingAttributes.lo SymbolModeAttributes.lo \
+	SymbolTableModeAttributes.lo SymbolIndividualModeAttributes.lo \
+	ImageListColourTechniqueAttributes.lo \
+	ImageCalculateColourTechniqueAttributes.lo \
+	LookupTableModeAttributes.lo FixedTableModeAttributes.lo \
+	EquidistantTableModeAttributes.lo SimplePolylineAttributes.lo \
+	ObsPlottingAttributes.lo ImportPlotAttributes.lo \
+	ObsTableAttributes.lo ObsHeightAttributes.lo \
+	ObsWindAttributes.lo ObsStationRingAttributes.lo \
+	ObsTimePlotAttributes.lo ObsDemoItem2Attributes.lo \
+	ObsTemperatureAttributes.lo ObsPressureAttributes.lo \
+	ObsPressureTendencyAttributes.lo ObsDewPointAttributes.lo \
+	ObsVisibilityAttributes.lo ObsPresentWeatherAttributes.lo \
+	ObsItemAttributes.lo ObsPressureLevelAttributes.lo \
+	ObsIdentifierAttributes.lo ObsCloudAttributes.lo \
+	ObsPastWeatherAttributes.lo ObsThicknessAttributes.lo \
+	EpsDirectionAttributes.lo SymbolAdvancedTableModeAttributes.lo \
+	TaylorGridAttributes.lo ContinuousLegendMethodAttributes.lo \
+	HistogramLegendMethodAttributes.lo LegendBoxAttributes.lo \
+	GraphPlottingAttributes.lo LandgramBoxAttributes.lo \
+	CurveAttributes.lo BarAttributes.lo GraphFlagAttributes.lo \
+	GraphArrowAttributes.lo GraphAttributes.lo \
+	HatchGraphShadeStyleAttributes.lo GraphShadeStyleAttributes.lo \
+	DotGraphShadeStyleAttributes.lo GraphShadeAttributes.lo \
+	WindPlottingAttributes.lo FlagPlottingAttributes.lo \
+	ArrowPlottingAttributes.lo CitiesAttributes.lo \
+	IsoPlotAttributes.lo ContourAttributes.lo \
+	ValuePlotAttributes.lo HiLoAttributes.lo WindAttributes.lo \
+	IsoShadingAttributes.lo PolyShadingTechniqueAttributes.lo \
+	ImagePlottingAttributes.lo DateAxisMethodAttributes.lo \
+	CurveAreaAttributes.lo
+nodist_libvisualisers_la_OBJECTS = $(am__objects_4)
+libvisualisers_la_OBJECTS = $(am_libvisualisers_la_OBJECTS) \
+	$(nodist_libvisualisers_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libvisualisers_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+	$(AM_CXXFLAGS) $(CXXFLAGS) $(libvisualisers_la_LDFLAGS) \
+	$(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libvisualisers_la_SOURCES) \
+	$(nodist_libvisualisers_la_SOURCES)
+DIST_SOURCES = $(libvisualisers_la_SOURCES)
+am__include_HEADERS_DIST = Title.h SymbolPlotting.h SymbolPlotting.cc \
+	Filter.h Filter.cc TitleBase.h ValuePlotBase.h HiLoBase.h \
+	HiLoMarkerBase.h GraphShade.h GraphShadeStyle.h Boundaries.h \
+	Coastlines.h CoastlinesAttributes.h GridPlotting.h \
+	NoGridPlottingAttributes.h GridPlottingAttributes.h \
+	LabelPlottingAttributes.h CoastPlottingAttributes.h \
+	BoundariesAttributes.h ContourAttributes.h IsoPlotAttributes.h \
+	LevelSelectionAttributes.h IsoLabelAttributes.h \
+	IsoHighlightAttributes.h IsoShadingAttributes.h \
+	IsoShadingAttributes.cc PolyShadingTechniqueAttributes.h \
+	LegendBoxAttributes.h PolyShadingTechniqueAttributes.cc \
+	HatchPolyShadingMethodAttributes.h \
+	DotPolyShadingMethodAttributes.h \
+	MarkerShadingTechniqueAttributes.h \
+	SymbolIndividualModeAttributes.h SymbolTableModeAttributes.h \
+	CellShadingAttributes.h GridShadingAttributes.h \
+	CalculateColourTechniqueAttributes.h \
+	ListColourTechniqueAttributes.h IsoPlotAttributes.cc \
+	CountSelectionTypeAttributes.h \
+	IntervalSelectionTypeAttributes.h \
+	LevelListSelectionTypeAttributes.h ContourAttributes.cc \
+	Akima474MethodAttributes.h Akima760MethodAttributes.h \
+	ContinuousLegendMethodAttributes.h \
+	HistogramLegendMethodAttributes.h \
+	SampleContourMethodAttributes.h HiLoAttributes.h \
+	HiLoTechniqueAttributes.h HiLoAttributes.cc \
+	HiLoNumberAttributes.h HiLoTextAttributes.h \
+	HiLoMarkerAttributes.h IsoHelper.h SegmentJoiner.h \
+	SymbolMode.h CoastPlotting.h LabelPlotting.h Contour.h \
+	IsoPlot.h ValuePlot.h ValuePlotMethod.h \
+	MarkerValuePlotMethod.h BothValuePlotMethod.h IsoLabel.h \
+	IsoShading.h IsoShading.cc LandgramBox.h LevelSelection.h \
+	CountSelectionType.h LevelListSelectionType.h \
+	IntervalSelectionType.h ContourMethod.h Akima760Method.h \
+	Akima761Method.h Akima474Method.h Akima474.cc Graph.h \
+	GraphPlotting.h Curve.h Axis.h AxisItem.h FloatSelection.h \
+	ColourSelection.h MarkerSelection.h HeightSelection.h \
+	ColourSelectionCount.h ColourSelectionList.h \
+	MarkerSelectionCount.h MarkerSelectionList.h \
+	HeightSelectionCount.h HeightSelectionList.h Histogram.h \
+	Histogram.cc HistoMode.h HistoIndividualMode.h \
+	HistoTableMode.h Intervals.h HiLo.cc HiLo.h HiLoTechnique.cc \
+	HiLoTechnique.h HiLoMarker.h HiLoText.h HiLoNumber.h \
+	HiLoBoth.h ShadingTechnique.h MarkerShadingTechnique.h \
+	MarkerShadingTechnique.cc PolyShadingTechnique.h \
+	ColourTechnique.h CalculateColourTechnique.h \
+	ListColourTechnique.h PolyShadingMethod.h \
+	DotPolyShadingMethod.h HatchPolyShadingMethod.h IsoHighlight.h \
+	AutomaticContourMethod.h DefinitionTable.h DefinitionTable.cc \
+	GribTables.h LegendMethod.h Wind.h Wind.cc WindPlotting.h \
+	FlagPlotting.h ArrowPlotting.h CalmIndicator.h OriginMarker.h \
+	ObsPlotting.h ImportPlot.h ImagePlotting.h ImagePlotting.cc \
+	LookupTableMode.h EquidistantTableMode.h NormalTableMode.h \
+	LinearTableMode.h ObsTable.h ObsItem.h ObsItemFamily.h \
+	ImageListColourTechnique.h ImageCalculateColourTechnique.h \
+	CellShading.h CellShading.cc EpsGraph.h BoxPlotVisualiser.h \
+	ObsStatGraph.h AxisMethod.h TextOrientation.h DateAxis.h \
+	EpsForecastPlot.h Bar.h BoxPlotItem.h TaylorGrid.h \
+	BoxPlotBasicItem.h MetgramGraph.h MetgramStyle.h \
+	SimplePolylineVisualiser.h SymbolAdvancedTableMode.h \
+	HeightTechnique.h OutLayerTechnique.h ContourLibrary.h \
+	VisDefInfo.h AxisAttributes.h ObsPlottingAttributes.h \
+	ImportPlotAttributes.h ImagePlottingAttributes.h \
+	LookupTableModeAttributes.h FixedTableModeAttributes.h \
+	Cities.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = Title.h SymbolPlotting.h SymbolPlotting.cc \
+	Filter.h Filter.cc TitleBase.h ValuePlotBase.h HiLoBase.h \
+	HiLoMarkerBase.h GraphShade.h GraphShadeStyle.h Boundaries.h \
+	Coastlines.h CoastlinesAttributes.h GridPlotting.h \
+	NoGridPlottingAttributes.h GridPlottingAttributes.h \
+	LabelPlottingAttributes.h CoastPlottingAttributes.h \
+	BoundariesAttributes.h ContourAttributes.h IsoPlotAttributes.h \
+	LevelSelectionAttributes.h IsoLabelAttributes.h \
+	IsoHighlightAttributes.h IsoShadingAttributes.h \
+	IsoShadingAttributes.cc PolyShadingTechniqueAttributes.h \
+	LegendBoxAttributes.h PolyShadingTechniqueAttributes.cc \
+	HatchPolyShadingMethodAttributes.h \
+	DotPolyShadingMethodAttributes.h \
+	MarkerShadingTechniqueAttributes.h \
+	SymbolIndividualModeAttributes.h SymbolTableModeAttributes.h \
+	CellShadingAttributes.h GridShadingAttributes.h \
+	CalculateColourTechniqueAttributes.h \
+	ListColourTechniqueAttributes.h IsoPlotAttributes.cc \
+	CountSelectionTypeAttributes.h \
+	IntervalSelectionTypeAttributes.h \
+	LevelListSelectionTypeAttributes.h ContourAttributes.cc \
+	Akima474MethodAttributes.h Akima760MethodAttributes.h \
+	ContinuousLegendMethodAttributes.h \
+	HistogramLegendMethodAttributes.h \
+	SampleContourMethodAttributes.h HiLoAttributes.h \
+	HiLoTechniqueAttributes.h HiLoAttributes.cc \
+	HiLoNumberAttributes.h HiLoTextAttributes.h \
+	HiLoMarkerAttributes.h IsoHelper.h SegmentJoiner.h \
+	SymbolMode.h CoastPlotting.h LabelPlotting.h Contour.h \
+	IsoPlot.h ValuePlot.h ValuePlotMethod.h \
+	MarkerValuePlotMethod.h BothValuePlotMethod.h IsoLabel.h \
+	IsoShading.h IsoShading.cc LandgramBox.h LevelSelection.h \
+	CountSelectionType.h LevelListSelectionType.h \
+	IntervalSelectionType.h ContourMethod.h Akima760Method.h \
+	Akima761Method.h Akima474Method.h Akima474.cc Graph.h \
+	GraphPlotting.h Curve.h Axis.h AxisItem.h FloatSelection.h \
+	ColourSelection.h MarkerSelection.h HeightSelection.h \
+	ColourSelectionCount.h ColourSelectionList.h \
+	MarkerSelectionCount.h MarkerSelectionList.h \
+	HeightSelectionCount.h HeightSelectionList.h Histogram.h \
+	Histogram.cc HistoMode.h HistoIndividualMode.h \
+	HistoTableMode.h Intervals.h HiLo.cc HiLo.h HiLoTechnique.cc \
+	HiLoTechnique.h HiLoMarker.h HiLoText.h HiLoNumber.h \
+	HiLoBoth.h ShadingTechnique.h MarkerShadingTechnique.h \
+	MarkerShadingTechnique.cc PolyShadingTechnique.h \
+	ColourTechnique.h CalculateColourTechnique.h \
+	ListColourTechnique.h PolyShadingMethod.h \
+	DotPolyShadingMethod.h HatchPolyShadingMethod.h IsoHighlight.h \
+	AutomaticContourMethod.h DefinitionTable.h DefinitionTable.cc \
+	GribTables.h LegendMethod.h Wind.h Wind.cc WindPlotting.h \
+	FlagPlotting.h ArrowPlotting.h CalmIndicator.h OriginMarker.h \
+	ObsPlotting.h ImportPlot.h ImagePlotting.h ImagePlotting.cc \
+	LookupTableMode.h EquidistantTableMode.h NormalTableMode.h \
+	LinearTableMode.h ObsTable.h ObsItem.h ObsItemFamily.h \
+	ImageListColourTechnique.h ImageCalculateColourTechnique.h \
+	CellShading.h CellShading.cc EpsGraph.h BoxPlotVisualiser.h \
+	ObsStatGraph.h AxisMethod.h TextOrientation.h DateAxis.h \
+	EpsForecastPlot.h Bar.h BoxPlotItem.h TaylorGrid.h \
+	BoxPlotBasicItem.h MetgramGraph.h MetgramStyle.h \
+	SimplePolylineVisualiser.h SymbolAdvancedTableMode.h \
+	HeightTechnique.h OutLayerTechnique.h ContourLibrary.h \
+	VisDefInfo.h AxisAttributes.h ObsPlottingAttributes.h \
+	ImportPlotAttributes.h ImagePlottingAttributes.h \
+	LookupTableModeAttributes.h FixedTableModeAttributes.h \
+	Cities.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libvisualisers.la
+ATTRIBUTES = CoastlinesAttributes.cc NoCoastPlottingAttributes.cc CoastPlottingAttributes.cc \
+	LabelPlottingAttributes.cc NoGridPlottingAttributes.cc GridPlottingAttributes.cc \
+	BoundariesAttributes.cc \
+	HiLoNumberAttributes.cc MarkerValuePlotMethodAttributes.cc HiLoMarkerAttributes.cc \
+	Akima474MethodAttributes.cc Akima760MethodAttributes.cc Akima761MethodAttributes.cc \
+	SampleContourMethodAttributes.cc HiLoTextAttributes.cc \
+	MarkerShadingTechniqueAttributes.cc \
+	IsoHighlightAttributes.cc HatchPolyShadingMethodAttributes.cc \
+	IntervalSelectionTypeAttributes.cc  \
+	GridShadingAttributes.cc CellShadingAttributes.cc DotPolyShadingMethodAttributes.cc \
+	CountSelectionTypeAttributes.cc ValuePlotMethodAttributes.cc  \
+	HiLoTechniqueAttributes.cc LevelSelectionAttributes.cc \
+	ListColourTechniqueAttributes.cc CalculateColourTechniqueAttributes.cc \
+	LevelListSelectionTypeAttributes.cc IsoLabelAttributes.cc \
+	SymbolPlottingAttributes.cc  SymbolModeAttributes.cc  SymbolTableModeAttributes.cc SymbolIndividualModeAttributes.cc \
+	ImageListColourTechniqueAttributes.cc ImageCalculateColourTechniqueAttributes.cc\
+	LookupTableModeAttributes.cc FixedTableModeAttributes.cc \
+	EquidistantTableModeAttributes.cc SimplePolylineAttributes.cc\
+	ObsPlottingAttributes.cc \
+	ImportPlotAttributes.cc ObsTableAttributes.cc ObsHeightAttributes.cc \
+	ObsWindAttributes.cc ObsStationRingAttributes.cc  \
+	ObsTimePlotAttributes.cc ObsDemoItem2Attributes.cc\
+	ObsTemperatureAttributes.cc\
+	ObsPressureAttributes.cc ObsPressureTendencyAttributes.cc \
+	ObsDewPointAttributes.cc ObsVisibilityAttributes.cc \
+	ObsPresentWeatherAttributes.cc ObsItemAttributes.cc \
+	ObsPressureLevelAttributes.cc ObsIdentifierAttributes.cc \
+	ObsCloudAttributes.cc ObsPastWeatherAttributes.cc ObsThicknessAttributes.cc\
+	EpsDirectionAttributes.cc \
+	SymbolAdvancedTableModeAttributes.cc  \
+	TaylorGridAttributes.cc\
+	ContinuousLegendMethodAttributes.cc HistogramLegendMethodAttributes.cc \
+	LegendBoxAttributes.cc GraphPlottingAttributes.cc LandgramBoxAttributes.cc \
+	CurveAttributes.cc BarAttributes.cc \
+	GraphFlagAttributes.cc GraphArrowAttributes.cc \
+	GraphAttributes.cc HatchGraphShadeStyleAttributes.cc \
+	GraphShadeStyleAttributes.cc DotGraphShadeStyleAttributes.cc GraphShadeAttributes.cc  \
+	WindPlottingAttributes.cc FlagPlottingAttributes.cc ArrowPlottingAttributes.cc \
+	CitiesAttributes.cc IsoPlotAttributes.cc ContourAttributes.cc\
+	ValuePlotAttributes.cc HiLoAttributes.cc WindAttributes.cc IsoShadingAttributes.cc \
+	PolyShadingTechniqueAttributes.cc  \
+	ImagePlottingAttributes.cc DateAxisMethodAttributes.cc \
+	CurveAreaAttributes.cc 
+
+include_H = \
+	Title.h \
+	SymbolPlotting.h SymbolPlotting.cc Filter.h Filter.cc \
+	TitleBase.h ValuePlotBase.h  \
+	HiLoBase.h \
+	HiLoMarkerBase.h \
+	GraphShade.h GraphShadeStyle.h Boundaries.h \
+	Coastlines.h CoastlinesAttributes.h GridPlotting.h NoGridPlottingAttributes.h GridPlottingAttributes.h LabelPlottingAttributes.h CoastPlottingAttributes.h BoundariesAttributes.h  ContourAttributes.h \
+	IsoPlotAttributes.h LevelSelectionAttributes.h IsoLabelAttributes.h IsoHighlightAttributes.h IsoShadingAttributes.h IsoShadingAttributes.cc PolyShadingTechniqueAttributes.h LegendBoxAttributes.h PolyShadingTechniqueAttributes.cc \
+	HatchPolyShadingMethodAttributes.h DotPolyShadingMethodAttributes.h MarkerShadingTechniqueAttributes.h SymbolIndividualModeAttributes.h SymbolTableModeAttributes.h CellShadingAttributes.h GridShadingAttributes.h \
+	CalculateColourTechniqueAttributes.h ListColourTechniqueAttributes.h IsoPlotAttributes.cc CountSelectionTypeAttributes.h IntervalSelectionTypeAttributes.h LevelListSelectionTypeAttributes.h ContourAttributes.cc \
+	Akima474MethodAttributes.h Akima760MethodAttributes.h ContinuousLegendMethodAttributes.h  HistogramLegendMethodAttributes.h SampleContourMethodAttributes.h HiLoAttributes.h HiLoTechniqueAttributes.h HiLoAttributes.cc HiLoNumberAttributes.h HiLoTextAttributes.h HiLoMarkerAttributes.h  \
+	IsoHelper.h SegmentJoiner.h \
+	SymbolMode.h  \
+	CoastPlotting.h \
+	LabelPlotting.h \
+	Contour.h \
+	IsoPlot.h\
+	ValuePlot.h\
+	ValuePlotMethod.h MarkerValuePlotMethod.h \
+	BothValuePlotMethod.h \
+	IsoLabel.h IsoShading.h IsoShading.cc \
+	LandgramBox.h LevelSelection.h CountSelectionType.h \
+	LevelListSelectionType.h IntervalSelectionType.h \
+	ContourMethod.h \
+	Akima760Method.h Akima761Method.h  \
+	Akima474Method.h Akima474.cc \
+	Graph.h GraphPlotting.h \
+	 Curve.h Axis.h AxisItem.h \
+	FloatSelection.h ColourSelection.h MarkerSelection.h HeightSelection.h \
+	ColourSelectionCount.h ColourSelectionList.h \
+	MarkerSelectionCount.h MarkerSelectionList.h \
+	HeightSelectionCount.h HeightSelectionList.h \
+	Histogram.h Histogram.cc HistoMode.h HistoIndividualMode.h HistoTableMode.h Intervals.h \
+	HiLo.cc HiLo.h HiLoTechnique.cc HiLoTechnique.h \
+	HiLoMarker.h  HiLoText.h \
+	HiLoNumber.h HiLoBoth.h \
+	ShadingTechnique.h \
+	MarkerShadingTechnique.h MarkerShadingTechnique.cc PolyShadingTechnique.h ColourTechnique.h \
+	CalculateColourTechnique.h ListColourTechnique.h PolyShadingMethod.h \
+	DotPolyShadingMethod.h HatchPolyShadingMethod.h \
+	IsoHighlight.h \
+	AutomaticContourMethod.h \
+	DefinitionTable.h DefinitionTable.cc \
+	GribTables.h LegendMethod.h \
+	Wind.h Wind.cc WindPlotting.h \
+	FlagPlotting.h \
+	ArrowPlotting.h \
+	CalmIndicator.h OriginMarker.h \
+	ObsPlotting.h \
+	ImportPlot.h\
+	ImagePlotting.h ImagePlotting.cc \
+	LookupTableMode.h \
+	EquidistantTableMode.h \
+	NormalTableMode.h \
+	LinearTableMode.h \
+	ObsTable.h ObsItem.h ObsItemFamily.h \
+	ImageListColourTechnique.h \
+	ImageCalculateColourTechnique.h \
+	CellShading.h CellShading.cc \
+	EpsGraph.h BoxPlotVisualiser.h ObsStatGraph.h \
+	AxisMethod.h \
+	TextOrientation.h DateAxis.h  \
+	EpsForecastPlot.h \
+	Bar.h  \
+	BoxPlotItem.h TaylorGrid.h BoxPlotBasicItem.h \
+	MetgramGraph.h MetgramStyle.h \
+	SimplePolylineVisualiser.h  \
+	SymbolAdvancedTableMode.h HeightTechnique.h OutLayerTechnique.h ContourLibrary.h \
+	VisDefInfo.h  AxisAttributes.h  ObsPlottingAttributes.h ImportPlotAttributes.h \
+	ImagePlottingAttributes.h LookupTableModeAttributes.h FixedTableModeAttributes.h \
+	Cities.h
+
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(noinst_H) $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = $(noinst_H)
+nodist_libvisualisers_la_SOURCES = ${ATTRIBUTES}
+axis = \
+	Axis.cc  \
+	DateAxis.cc \
+	AxisItem.cc  \
+	AxisMethod.cc \
+	TaylorGrid.cc  \
+	AxisAttributes.cc \
+	AxisMethodAttributes.cc
+
+metgram = \
+	EpsGraph.cc  \
+	MetgramGraph.cc MetgramStyle.cc \
+	BoxPlotVisualiser.cc\
+	BoxPlotItem.cc\
+	MetgramFlagsAttributes.cc \
+	EpsGraphAttributes.cc EpsWindAttributes.cc  EpsCloudAttributes.cc \
+	EfiGraphAttributes.cc CdfGraphAttributes.cc\
+	EpsPlumeAttributes.cc \
+	MetgramCurveAttributes.cc \
+	EpsShadeAttributes.cc MetgramGraphAttributes.cc BoxPlotVisualiserAttributes.cc \
+	BoxPlotBoxAttributes.cc BoxPlotBoxBorderAttributes.cc BoxPlotMedianAttributes.cc \
+	BoxPlotWhiskerBoxAttributes.cc BoxPlotWhiskerLineAttributes.cc BoxPlotWhiskerBorderAttributes.cc 
+
+obs = ObsPlotting.cc ObsTable.cc \
+	ObsItemFamily.cc 
+
+libvisualisers_la_SOURCES = ${axis} ${metgram} ${obs} ContourLibrary.cc Coastlines.cc CoastPlotting.cc \
+	ImagePlotting.cc WindPlotting.cc ArrowPlotting.cc FlagPlotting.cc \
+	IsoHelper.cc \
+	LabelPlotting.cc GridPlotting.cc Boundaries.cc \
+	ListColourTechnique.cc IntervalSelectionType.cc \
+	CountSelectionType.cc LevelSelection.cc \
+	ColourTechnique.cc CalculateColourTechnique.cc \
+	LevelListSelectionType.cc IsoLabel.cc \
+	TextOrientation.cc \
+	LegendMethod.cc SymbolMode.cc \
+	SimplePolylineVisualiser.cc \
+	LookupTableMode.cc \
+	EquidistantTableMode.cc \
+	NormalTableMode.cc LinearTableMode.cc \
+	BothValuePlotMethodAttributes.cc  \
+	SymbolAdvancedTableMode.cc HeightTechnique.cc \
+	OutLayerTechnique.cc \
+	HistogramAttributes.cc \
+	GraphPlotting.cc LandgramBox.cc Bar.cc Curve.cc  \
+	GraphShade.cc GraphShadeStyle.cc  \
+	VisDefInfo.cc Cities.cc \
+	Contour.cc IsoPlot.cc  ValuePlot.cc HiLo.cc Histogram.cc  \
+	Akima760.cc Akima474.cc Wind.cc IsoShading.cc\
+	PolyShadingMethod.cc CellShading.cc \
+	MarkerShadingTechnique.cc PolyShadingTechnique.cc SymbolPlotting.cc Filter.cc \
+	SegmentJoiner.cc
+
+libvisualisers_la_LDFLAGS = -no-undefined
+EXTRA_DIST = 
+AM_CPPFLAGS = ${GRIBAPI_CXXFLAGS} -I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/basic \
+	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/decoders \
+	-I$(top_srcdir)/src/drivers $(am__append_1)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/visualisers/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/visualisers/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libvisualisers.la: $(libvisualisers_la_OBJECTS) $(libvisualisers_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libvisualisers_la_LINK)  $(libvisualisers_la_OBJECTS) $(libvisualisers_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima474.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima474MethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima760.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima760MethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Akima761MethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ArrowPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ArrowPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Axis.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AxisAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AxisItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AxisMethod.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/AxisMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Bar.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BarAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BothValuePlotMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Boundaries.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoundariesAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotBoxAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotBoxBorderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotItem.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotMedianAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotVisualiser.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotVisualiserAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotWhiskerBorderAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotWhiskerBoxAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BoxPlotWhiskerLineAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CalculateColourTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CalculateColourTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CdfGraphAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CellShading.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CellShadingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Cities.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CitiesAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CoastPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CoastPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Coastlines.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CoastlinesAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ColourTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ContinuousLegendMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Contour.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ContourAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ContourLibrary.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CountSelectionType.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CountSelectionTypeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Curve.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CurveAreaAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CurveAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DateAxis.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DateAxisMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DotGraphShadeStyleAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/DotPolyShadingMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EfiGraphAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsCloudAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsDirectionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsGraph.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsGraphAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsPlumeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsShadeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EpsWindAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EquidistantTableMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/EquidistantTableModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FixedTableModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FlagPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FlagPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphArrowAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphFlagAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphShade.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphShadeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphShadeStyle.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GraphShadeStyleAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GridPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GridPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GridShadingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HatchGraphShadeStyleAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HatchPolyShadingMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HeightTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLo.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoMarkerAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoNumberAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HiLoTextAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Histogram.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HistogramAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/HistogramLegendMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImageCalculateColourTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImageListColourTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImagePlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImagePlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ImportPlotAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IntervalSelectionType.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IntervalSelectionTypeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoHelper.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoHighlightAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoLabel.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoLabelAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoPlot.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoPlotAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoShading.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/IsoShadingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LabelPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LabelPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LandgramBox.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LandgramBoxAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LegendBoxAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LegendMethod.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LevelListSelectionType.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LevelListSelectionTypeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LevelSelection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LevelSelectionAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LinearTableMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ListColourTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ListColourTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LookupTableMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LookupTableModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MarkerShadingTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MarkerShadingTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MarkerValuePlotMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetgramCurveAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetgramFlagsAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetgramGraph.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetgramGraphAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MetgramStyle.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoCoastPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NoGridPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/NormalTableMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsCloudAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsDemoItem2Attributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsDewPointAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsHeightAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsIdentifierAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsItemAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsItemFamily.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPastWeatherAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPresentWeatherAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPressureAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPressureLevelAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsPressureTendencyAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsStationRingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsTable.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsTableAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsTemperatureAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsThicknessAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsTimePlotAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsVisibilityAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsWindAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/OutLayerTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolyShadingMethod.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolyShadingTechnique.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/PolyShadingTechniqueAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SampleContourMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SegmentJoiner.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SimplePolylineAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SimplePolylineVisualiser.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolAdvancedTableMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolAdvancedTableModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolIndividualModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolMode.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolPlottingAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/SymbolTableModeAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TaylorGrid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TaylorGridAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TextOrientation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ValuePlot.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ValuePlotAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ValuePlotMethodAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/VisDefInfo.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Wind.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindPlotting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WindPlottingAttributes.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/visualisers/MarkerSelection.h b/src/visualisers/MarkerSelection.h
new file mode 100644
index 0000000..d179178
--- /dev/null
+++ b/src/visualisers/MarkerSelection.h
@@ -0,0 +1,90 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MarkerSelection.h
+    \brief Definition of the Template class MarkerSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MarkerSelection_H
+#define MarkerSelection_H
+
+#include "magics.h"
+
+#include "FloatSelection.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+namespace magics {
+
+class XmlNode;
+
+class MarkerSelection: public FloatSelection {
+
+public:
+	MarkerSelection();
+	virtual ~MarkerSelection();
+    virtual void set(const map<string,string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual void toxml(ostream&, int)  const {}
+    virtual MarkerSelection* clone() const {
+    	MarkerSelection* object = new MarkerSelection();
+    	return object;
+    }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	MarkerSelection(const MarkerSelection&);
+    //! Overloaded << operator to copy - No copy allowed
+	MarkerSelection& operator=(const MarkerSelection&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MarkerSelection& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, MarkerSelection> { 
+public:
+	MarkerSelection* operator()(const string& val )
+	{
+		return SimpleObjectMaker<MarkerSelection>::create(val);
+	}     
+
+	MarkerSelection* magics(const string& param)
+	{
+		MarkerSelection* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/MarkerSelectionCount.h b/src/visualisers/MarkerSelectionCount.h
new file mode 100644
index 0000000..56fb0a1
--- /dev/null
+++ b/src/visualisers/MarkerSelectionCount.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MarkerSelectionCount.h
+    \brief Definition of the Template class MarkerSelectionCount.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MarkerSelectionCount_H
+#define MarkerSelectionCount_H
+
+#include "magics.h"
+
+#include "MarkerSelection.h"
+#include "MarkerSelectionCountAttributes.h"
+
+namespace magics {
+
+class MarkerSelectionCount: public MarkerSelection, public MarkerSelectionCountAttributes {
+
+public:
+	MarkerSelectionCount();
+	virtual ~MarkerSelectionCount();
+    virtual void set(map<string,string> map) { MarkerSelectionCountAttributes::set(map); }
+    void prepare();
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	MarkerSelectionCount(const MarkerSelectionCount&);
+    //! Overloaded << operator to copy - No copy allowed
+	MarkerSelectionCount& operator=(const MarkerSelectionCount&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MarkerSelectionCount& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/MarkerSelectionList.h b/src/visualisers/MarkerSelectionList.h
new file mode 100644
index 0000000..1dfc8ed
--- /dev/null
+++ b/src/visualisers/MarkerSelectionList.h
@@ -0,0 +1,66 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MarkerSelectionList.h
+    \brief Definition of the Template class MarkerSelectionList.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MarkerSelectionList_H
+#define MarkerSelectionList_H
+
+#include "magics.h"
+
+#include "MarkerSelection.h"
+#include "MarkerSelectionListAttributes.h"
+
+namespace magics {
+
+class MarkerSelectionList: public MarkerSelection, public MarkerSelectionListAttributes {
+
+public:
+	MarkerSelectionList();
+	virtual ~MarkerSelectionList();
+    virtual void set(map<string,string> map) { MarkerSelectionListAttributes::set(map); }
+    void prepare();
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	MarkerSelectionList(const MarkerSelectionList&);
+    //! Overloaded << operator to copy - No copy allowed
+	MarkerSelectionList& operator=(const MarkerSelectionList&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MarkerSelectionList& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/MarkerShadingTechnique.cc b/src/visualisers/MarkerShadingTechnique.cc
new file mode 100644
index 0000000..3e15a42
--- /dev/null
+++ b/src/visualisers/MarkerShadingTechnique.cc
@@ -0,0 +1,171 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MarkerShadingTechnique.cc
+    \brief Implementation of the Template class MarkerShadingTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 26-Aug-2004
+    
+    Changes:
+    
+*/
+
+#include "MarkerShadingTechnique.h"
+#include "LevelSelection.h"
+#include "MatrixHandler.h"
+#include "Symbol.h"
+#include "LegendVisitor.h"
+#include "IsoPlot.h"
+using namespace magics;
+
+
+
+MarkerShadingTechnique::MarkerShadingTechnique() 
+{
+}
+
+MarkerShadingTechnique::~MarkerShadingTechnique() 
+{
+}
+
+Symbol* MarkerShadingTechnique::operator()(double val)
+{
+     
+    for (map<Interval, Symbol* >::const_iterator interval = map_.begin(); interval != map_.end(); ++interval)
+    {
+            if (interval->first.between(val)) { 
+                
+                return interval->second;
+            }
+    }
+    return 0;
+}
+
+void MarkerShadingTechnique::operator()(const PaperPoint& point)
+{
+    Symbol* symbol = (*this)(point.value());
+    symbol->push_back(point);
+}
+
+void MarkerShadingTechnique::operator()(MatrixHandler& data, BasicGraphicsObjectContainer& out)
+{
+    OriginalMatrixHandler original(data);
+    int rows = original.rows();
+    int columns = original.columns();
+    const Transformation& transformation = out.transformation();
+    
+    for (int j = 0; j < rows ; j++) {
+        for (int i = 0; i < columns; i++) {
+            Symbol* symbol = (*this)(original(j,i));
+            PaperPoint pos=transformation(UserPoint(original.column(j, i), original.row(j, i), original(j,i)));
+            if ( transformation.in(pos) && symbol )
+            	symbol->push_back(pos);
+        } 
+    }     
+    
+    // Now we feed the task
+    
+    for ( vector<BasicGraphicsObject*>::iterator object = begin(); object != end(); ++object)
+    	out.push_back(*object);
+    
+}
+
+void MarkerShadingTechnique::visit(LegendVisitor& legend, const ColourTechnique&)
+{
+       
+     for (map<Interval, Symbol* >::const_iterator interval = legend_.begin(); interval != legend_.end(); ++interval)
+     {
+         Interval   range  = interval->first;
+         Symbol* symbol = interval->second;
+                 
+         legend.add(new SymbolEntry(range.min_, range.max_, symbol));
+     }
+
+}
+CellArray* MarkerShadingTechnique::array(MatrixHandler& matrix, IntervalMap<int>& range,
+		const Transformation& transformation, int width, int height,
+		float resolution, const string& technique)
+{
+	return new CellArray(matrix, range, transformation, width, height, resolution, technique);
+
+}
+
+bool MarkerShadingTechnique::prepare(const LevelSelection& levels, const ColourTechnique& technique)
+{
+    if ( colour_.empty() ) {       
+        technique.colours(colour_);
+         if ( colour_.empty() ) 
+         	colour_.push_back("blue");
+    }
+    if ( height_.empty() ) {
+        height_.push_back(0.2);
+    }
+    if ( marker_.empty() ) {
+        marker_.push_back(18);
+    }
+     
+    // Prepare the table ...
+    stringarray::iterator colour = colour_.begin();
+    doublearray::iterator height = height_.begin();
+    intarray::iterator marker = marker_.begin();
+
+
+    for (unsigned int i = 0; i < levels.size() -1; i++)
+    {
+        
+     
+        Symbol* symbol =  new Symbol();
+        symbol->setColour(Colour(*colour));
+        symbol->setMarker(*marker);
+        symbol->setHeight(*height);
+        Symbol* legend =  new Symbol();
+        legend->setColour(Colour(*colour));
+        legend->setMarker(*marker);
+        legend->setHeight(*height);
+        map_[Interval(levels[i], levels[i+1])] = symbol;
+        legend_[Interval(levels[i], levels[i+1])] = legend;
+        push_back(symbol);
+        if ( i+1 <  levels.size() -1) {
+	        if ( ++colour == colour_.end()) {
+	            MagLog::warning() << "MarkerShading --> not enough colours defined!\n";
+	            colour = colour_.begin();
+	        }  
+	        if ( ++height == height_.end())  {
+	            MagLog::warning() << "MarkerShading --> not enough heights defined!\n";
+	            height = height_.begin();
+	        }  
+	        if ( ++marker == marker_.end()) {
+	            MagLog::warning() << "MarkerShading --> not enough markers defined!\n";
+	            marker = marker_.begin();
+	        }
+        }
+    }
+    return false;
+}
+
+   
+/*!
+ Class information are given to the output-stream.
+*/	
+void MarkerShadingTechnique::print(ostream& out)  const
+{
+	out << "MarkerShadingTechnique";
+}
+
diff --git a/src/visualisers/MarkerShadingTechnique.h b/src/visualisers/MarkerShadingTechnique.h
new file mode 100644
index 0000000..4f7b4f9
--- /dev/null
+++ b/src/visualisers/MarkerShadingTechnique.h
@@ -0,0 +1,97 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MarkerShadingTechnique.h
+    \brief Definition of the Template class MarkerShadingTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 26-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MarkerShadingTechnique_H
+#define MarkerShadingTechnique_H
+
+#include "magics.h"
+
+#include "ShadingTechnique.h"
+#include "MarkerShadingTechniqueAttributes.h"
+#include "Symbol.h"
+#include "SymbolMode.h"
+
+namespace magics {
+
+
+class MarkerShadingTechnique: 
+    private vector<BasicGraphicsObject*>, // Internal buffer to store graphical objects during creation phase
+    public ShadingTechnique,
+    public MarkerShadingTechniqueAttributes {
+
+public:
+	MarkerShadingTechnique();
+	virtual ~MarkerShadingTechnique();
+    virtual void set(const map<string, string>& map) 
+        { MarkerShadingTechniqueAttributes::set(map); }
+    virtual void set(const XmlNode& node) 
+        { MarkerShadingTechniqueAttributes::set(node); }
+    virtual ShadingTechnique* clone() const {
+    	MarkerShadingTechnique* object = new MarkerShadingTechnique();
+    	object->copy(*this);
+    	return object;
+    }
+    
+    bool accept(const string& node) { return MarkerShadingTechniqueAttributes::accept(node); }
+
+    
+    Symbol* operator()(double);
+    virtual void operator()(const PaperPoint&);
+    virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
+    virtual bool prepare(const LevelSelection&, const ColourTechnique&);    
+    virtual void visit(LegendVisitor&, const ColourTechnique&);
+    bool hasLegend() { return true; } // Isolien legend is not needed!
+    CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+           		const Transformation& transformation, int width, int height,
+           		float resolution, const string& technique);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     vector<Symbol* >::iterator current_;
+     map<Interval, Symbol* > map_;
+     map<Interval, Symbol* > legend_;
+
+private:
+    //! Copy constructor - No copy allowed
+	MarkerShadingTechnique(const MarkerShadingTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	MarkerShadingTechnique& operator=(const MarkerShadingTechnique&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MarkerShadingTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/MarkerShadingTechniqueAttributes.h b/src/visualisers/MarkerShadingTechniqueAttributes.h
new file mode 100644
index 0000000..d9d9a0a
--- /dev/null
+++ b/src/visualisers/MarkerShadingTechniqueAttributes.h
@@ -0,0 +1,83 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file MarkerShadingTechniqueAttributes.h
+    \brief Definition of MarkerShadingTechnique Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef MarkerShadingTechniqueAttributes_H
+#define MarkerShadingTechniqueAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class MarkerShadingTechniqueAttributes 
+{
+public:
+//  --  constructor
+    MarkerShadingTechniqueAttributes();
+    
+//  --  destructor
+    virtual ~MarkerShadingTechniqueAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const MarkerShadingTechniqueAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	stringarray colour_;
+	floatarray height_;
+	intarray marker_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const MarkerShadingTechniqueAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/MarkerValuePlotMethod.h b/src/visualisers/MarkerValuePlotMethod.h
new file mode 100644
index 0000000..f380da2
--- /dev/null
+++ b/src/visualisers/MarkerValuePlotMethod.h
@@ -0,0 +1,102 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MarkerValuePlotMethod.h
+    \brief Definition of the Template class MarkerValuePlotMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 26-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MarkerValuePlotMethod_H
+#define MarkerValuePlotMethod_H
+
+#include "magics.h"
+
+#include "ValuePlotMethod.h"
+#include "MarkerValuePlotMethodAttributes.h"
+#include "Symbol.h"
+namespace magics {
+
+
+class MarkerValuePlotMethod: public ValuePlotMethod, public MarkerValuePlotMethodAttributes {
+
+public:
+	MarkerValuePlotMethod() : marker_(0) {
+       
+	}
+	virtual ~MarkerValuePlotMethod() {}
+    virtual void set(const map<string, string>& map ) 
+        { ValuePlotMethodAttributes::set(map);
+          MarkerValuePlotMethodAttributes::set(map); }
+    virtual void set(const XmlNode& node ) 
+        { ValuePlotMethodAttributes::set(node);
+          MarkerValuePlotMethodAttributes::set(node); }
+    virtual ValuePlotMethod* clone() const {
+    	MarkerValuePlotMethod* object = new MarkerValuePlotMethod();
+    	object->clone(*this);
+    	return object;
+    }
+    
+     virtual void clone(const MarkerValuePlotMethod& from )
+        { ValuePlotMethodAttributes::copy(from);
+          MarkerValuePlotMethodAttributes::copy(from); }
+    
+    
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const {
+         out << "MarkerValuePlotMethod[";
+         MarkerValuePlotMethodAttributes::print(out);
+         out << "]";
+	 }
+	 void reset() { marker_ = 0; }
+     virtual void add(const PaperPoint& xy) {        
+          if (!marker_) {
+            marker_ = new Symbol();
+            marker_->setMarker(markerIndex_);
+            marker_->setColour(*markerColour_);
+            marker_->setHeight(markerHeight_);
+            this->push_back(marker_); 
+         }   
+         marker_->push_back(xy);
+    }
+    Symbol* marker_;
+
+private:
+    //! Copy constructor - No copy allowed
+	MarkerValuePlotMethod(const MarkerValuePlotMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	MarkerValuePlotMethod& operator=(const MarkerValuePlotMethod&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MarkerValuePlotMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/MetgramCurveAttributes.cc b/src/visualisers/MetgramCurveAttributes.cc
new file mode 100644
index 0000000..7cebdd0
--- /dev/null
+++ b/src/visualisers/MetgramCurveAttributes.cc
@@ -0,0 +1,137 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file MetgramCurveAttributes.cc
+    \brief Implementation of MetgramCurve Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "MetgramCurveAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+MetgramCurveAttributes::MetgramCurveAttributes():
+	style_(MagTranslator<string, LineStyle>().magics("metgram_curve_line_style")),
+	style2_(MagTranslator<string, LineStyle>().magics("metgram_curve2_line_style")),
+	colour_(MagTranslator<string, Colour>().magics("metgram_curve_colour")),
+	colour2_(MagTranslator<string, Colour>().magics("metgram_curve2_colour")),
+	thickness_(ParameterManager::getInt("metgram_curve_thickness")),
+	thickness2_(ParameterManager::getInt("metgram_curve2_thickness"))
+{
+} 
+
+
+
+MetgramCurveAttributes::~MetgramCurveAttributes()
+{
+}
+
+    
+void MetgramCurveAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "metgram";
+
+	setAttribute(prefix, "metgram_curve_line_style", style_, params);
+	setAttribute(prefix, "metgram_curve2_line_style", style2_, params);
+	setAttribute(prefix, "metgram_curve_colour", colour_, params);
+	setAttribute(prefix, "metgram_curve2_colour", colour2_, params);
+	setAttribute(prefix, "metgram_curve_thickness", thickness_, params);
+	setAttribute(prefix, "metgram_curve2_thickness", thickness2_, params);
+}
+
+void MetgramCurveAttributes::copy(const MetgramCurveAttributes& other)
+{
+	style_ = other.style_;
+	style2_ = other.style2_;
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	colour2_ = auto_ptr<Colour>(other.colour2_->clone());
+	thickness_ = other.thickness_;
+	thickness2_ = other.thickness2_;
+} 
+
+
+bool MetgramCurveAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "metgraph")  )
+		return true;
+	return false;
+}
+
+void MetgramCurveAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "metgraph") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void MetgramCurveAttributes::print(ostream& out)  const
+{
+	out << "MetgramCurveAttributes[";
+	out << "style = " << style_;
+	out << ", style2 = " << style2_;
+	out << ", colour = " << *colour_;
+	out << ", colour2 = " << *colour2_;
+	out << ", thickness = " << thickness_;
+	out << ", thickness2 = " << thickness2_;
+	out << "]" << "\n";
+}
+
+
+void MetgramCurveAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"metgraph\"";
+	 out << ", \"metgram_curve_line_style\":";
+	 niceprint(out,style_);
+	 out << ", \"metgram_curve2_line_style\":";
+	 niceprint(out,style2_);
+	 out << ", \"metgram_curve_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"metgram_curve2_colour\":";
+	 niceprint(out, *colour2_);
+	 out << ", \"metgram_curve_thickness\":";
+	 niceprint(out,thickness_);
+	 out << ", \"metgram_curve2_thickness\":";
+	 niceprint(out,thickness2_);
+}
+static MagicsParameter<string> metgram_curve_line_style("metgram_curve_line_style", "solid", "");
+static MagicsParameter<string> metgram_curve2_line_style("metgram_curve2_line_style", "solid", "");
+static MagicsParameter<string> metgram_curve_colour("metgram_curve_colour", "red", "");
+static MagicsParameter<string> metgram_curve2_colour("metgram_curve2_colour", "blue", "");
+static MagicsParameter<int> metgram_curve_thickness("metgram_curve_thickness", 2, "");
+static MagicsParameter<int> metgram_curve2_thickness("metgram_curve2_thickness", 2, "");
diff --git a/src/visualisers/MetgramFlagsAttributes.cc b/src/visualisers/MetgramFlagsAttributes.cc
new file mode 100644
index 0000000..800e272
--- /dev/null
+++ b/src/visualisers/MetgramFlagsAttributes.cc
@@ -0,0 +1,116 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file MetgramFlagsAttributes.cc
+    \brief Implementation of MetgramFlags Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "MetgramFlagsAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+MetgramFlagsAttributes::MetgramFlagsAttributes():
+	colour_(MagTranslator<string, Colour>().magics("metgram_flag_colour")),
+	frequency_(ParameterManager::getInt("metgram_flag_frequency")),
+	length_(ParameterManager::getDouble("metgram_flag_length"))
+{
+} 
+
+
+
+MetgramFlagsAttributes::~MetgramFlagsAttributes()
+{
+}
+
+    
+void MetgramFlagsAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "metgram";
+
+	setAttribute(prefix, "metgram_flag_colour", colour_, params);
+	setAttribute(prefix, "metgram_flag_frequency", frequency_, params);
+	setAttribute(prefix, "metgram_flag_length", length_, params);
+}
+
+void MetgramFlagsAttributes::copy(const MetgramFlagsAttributes& other)
+{
+	colour_ = auto_ptr<Colour>(other.colour_->clone());
+	frequency_ = other.frequency_;
+	length_ = other.length_;
+} 
+
+
+bool MetgramFlagsAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "metflags")  )
+		return true;
+	return false;
+}
+
+void MetgramFlagsAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "metflags") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void MetgramFlagsAttributes::print(ostream& out)  const
+{
+	out << "MetgramFlagsAttributes[";
+	out << "colour = " << *colour_;
+	out << ", frequency = " << frequency_;
+	out << ", length = " << length_;
+	out << "]" << "\n";
+}
+
+
+void MetgramFlagsAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"metflags\"";
+	 out << ", \"metgram_flag_colour\":";
+	 niceprint(out, *colour_);
+	 out << ", \"metgram_flag_frequency\":";
+	 niceprint(out,frequency_);
+	 out << ", \"metgram_flag_length\":";
+	 niceprint(out,length_);
+}
+static MagicsParameter<string> metgram_flag_colour("metgram_flag_colour", "red", "");
+static MagicsParameter<int> metgram_flag_frequency("metgram_flag_frequency", 1, "");
+static MagicsParameter<double> metgram_flag_length("metgram_flag_length", 0.5, "");
diff --git a/src/visualisers/MetgramGraph.cc b/src/visualisers/MetgramGraph.cc
new file mode 100644
index 0000000..f90d976
--- /dev/null
+++ b/src/visualisers/MetgramGraph.cc
@@ -0,0 +1,77 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MetgramGraph.cc
+    \brief Implementation of the Template class MetgramGraph.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "MetgramGraph.h"
+#include "PointsHandler.h"
+#include "DateTime.h"
+#include "Text.h"
+#include "LegendVisitor.h"
+#include "Timer.h"
+
+
+using namespace magics;
+
+
+
+
+MetgramGraph::MetgramGraph() 
+{}
+
+
+MetgramGraph::~MetgramGraph() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MetgramGraph::print(ostream& out)  const
+{
+	out << "MetgramGraph[";
+	out << "]";
+}
+
+
+
+void MetgramGraph::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	CustomisedPointsList points; 
+	std::set<string> request;
+	const Transformation& transformation = out.transformation();
+	data.customisedPoints(transformation, request, points, true); // we want all the points!
+	
+	Timer timer("Graph","");	
+	(*style_)(points, out);
+}
+
+void MetgramGraph::visit(LegendVisitor& legend)
+{
+	style_->visit(legend);
+}
diff --git a/src/visualisers/MetgramGraph.h b/src/visualisers/MetgramGraph.h
new file mode 100644
index 0000000..3d33c3e
--- /dev/null
+++ b/src/visualisers/MetgramGraph.h
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MetgramGraph.h
+    \brief Definition of the Template class MetgramGraph.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef MetgramGraph_H
+#define MetgramGraph_H
+
+#include "magics.h"
+
+
+#include "MetgramGraphAttributes.h"
+
+
+#include "magics.h"
+#include "Polyline.h"
+#include "Graph.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+class MetgramGraph:  public MetgramGraphAttributes, public Visdef {
+
+
+
+public:
+	MetgramGraph();
+	virtual ~MetgramGraph();
+    
+   
+    
+	virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { MetgramGraphAttributes::set(map); }
+    void set(const XmlNode& node) { MetgramGraphAttributes::set(node); }
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 double resolution_;
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	MetgramGraph(const MetgramGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	MetgramGraph& operator=(const MetgramGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MetgramGraph& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/MetgramGraphAttributes.cc b/src/visualisers/MetgramGraphAttributes.cc
new file mode 100644
index 0000000..81f0b97
--- /dev/null
+++ b/src/visualisers/MetgramGraphAttributes.cc
@@ -0,0 +1,111 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file MetgramGraphAttributes.cc
+    \brief Implementation of MetgramGraph Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "MetgramGraphAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+MetgramGraphAttributes::MetgramGraphAttributes():
+	style_(MagTranslator<string, MetgramStyle>().magics("metgram_plot_style"))
+{
+} 
+
+
+
+MetgramGraphAttributes::~MetgramGraphAttributes()
+{
+}
+
+    
+void MetgramGraphAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "metgram";
+
+	setMember(prefix, "metgram_plot_style", style_, params);
+}
+
+void MetgramGraphAttributes::copy(const MetgramGraphAttributes& other)
+{
+	style_ = auto_ptr<MetgramStyle>(other.style_->clone());
+} 
+
+
+bool MetgramGraphAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "metgraph")  )
+		return true;
+
+	if ( acceptNode(node, style_) )
+		return true;
+	return false;
+}
+
+void MetgramGraphAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "metgraph") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), style_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), style_, *(*elt)); 
+	}
+}
+
+void MetgramGraphAttributes::print(ostream& out)  const
+{
+	out << "MetgramGraphAttributes[";
+	out << "style = " << *style_;
+	out << "]" << "\n";
+}
+
+
+void MetgramGraphAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"metgraph\"";
+	 out << ", \"metgram_plot_style\":";
+	 style_->toxml(out);
+}
+static MagicsParameter<string> metgram_plot_style("metgram_plot_style", "curve", "");
+#include "MetgramStyle.h"
+static SimpleObjectMaker<MetgramBar, MetgramStyle> bar_MetgramBar("bar");
+static SimpleObjectMaker<MetgramFlags, MetgramStyle> flags_MetgramFlags("flags");
+static SimpleObjectMaker<MetgramCurve, MetgramStyle> curve_MetgramCurve("curve");
diff --git a/src/visualisers/MetgramStyle.cc b/src/visualisers/MetgramStyle.cc
new file mode 100644
index 0000000..cdf39f2
--- /dev/null
+++ b/src/visualisers/MetgramStyle.cc
@@ -0,0 +1,320 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MetgramStyle.cc
+    \brief Implementation of the Template class MetgramStyle.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Mon 16-Oct-2006
+    
+    Changes:
+    
+*/
+
+#include "MetgramStyle.h"
+
+#include "DateTime.h"
+#include "Text.h"
+#include "Polyline.h"
+#include "Flag.h"
+
+#include "LegendVisitor.h"
+#include "Transformation.h"
+#include <cfloat>
+
+using namespace magics;
+
+MetgramStyle::MetgramStyle() 
+{
+}
+
+
+MetgramStyle::~MetgramStyle() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void MetgramStyle::print(ostream& out)  const
+{
+	out << "MetgramStyle[";
+	out << "]";
+}
+
+void MetgramBar::print(ostream& out)  const
+{
+	out << "MetgramBar[]";
+}
+
+void MetgramCurve::print(ostream& out)  const
+{
+	out << "MetgramCurve[]";
+}
+
+void MetgramFlags::print(ostream& out)  const
+{
+	out << "MetgramFlags[]";
+}
+
+DateTime readDate(CustomisedPoint& point)
+{
+	MagDate date1((long)point["year"], (long)point["month"], (long)point["day"]);
+	magics::MagTime time((long)point["hours"], (long)point["minutes"], (long)point["seconds"]);
+
+	//time -= Second(point["shift"] * 3600);
+	return DateTime(date1, time); 
+}
+
+void MetgramBar::operator()(CustomisedPointsList& points, BasicGraphicsObjectContainer& visitor) 
+{
+	vector<double> xpos;
+	vector<double> limits;
+	vector<double> ypos;
+	
+	Polyline* first  = new Polyline();
+	first->setColour(Colour("blue"));
+	first->setLineStyle(M_DASH);
+	
+	visitor.push_back(first);
+	Polyline* last  = new Polyline();
+	last->setColour(Colour("blue"));
+	last->setLineStyle(M_DASH);
+
+	visitor.push_back(last);
+
+	MagDate date((long)(*points.front())["year"], (long)(*points.front())["month"], (long)(*points.front())["day"]);
+	MagTime time((long)(*points.front())["hours"], (long)(*points.front())["minutes"], (long)(*points.front())["seconds"]);
+	DateTime  base = readDate(*points.front());
+	double left, right = 0.;
+
+	const Transformation& transformation = visitor.transformation();
+	double xmin =  transformation.getMinPCX();
+	double xmax =  transformation.getMaxPCX();
+
+	CustomisedPointsList::const_iterator previous = points.end();
+    
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) 
+	{
+		
+		DateTime step =  readDate(**point);
+		DateTime next;
+		double x = step - base;
+		point++;
+		if ( point != points.end()) 			
+			next = readDate(**point);			
+		else next = step;
+		point--;
+		  x -= (**point)["shift"];
+		xpos.push_back(x);
+	
+		Polyline* box  = new Polyline();	
+        box->setFilled(true);
+		box->setShading(new FillShadingProperties());
+		box->setFillColour(Colour("blue"));
+		box->setColour(Colour("blue"));
+
+		
+	
+		if  ( (*point)->find("as_rain") != (*point)->end() ) {
+			left = ( previous != points.end() ) ? right : x;
+			right = x;
+		}
+		else {
+			left = ( previous != points.end() ) ? right : x - (next - step)/2;
+			//left = ( previous != points.end() ) ? right : x; 
+			right = ( next - step ) ? x + (next - step)/2 : x + ( x - right);
+		}
+		
+		previous = point;
+
+		if (left < xmin) left = xmin; 
+		if (right > xmax) right = xmax; 
+		
+		if ( (*point)->find("curve1") != (*point)->end() )   {
+			box->push_back(PaperPoint(left, 0));
+			box->push_back(PaperPoint(left, (**point)["curve1"]));
+			box->push_back(PaperPoint(right, (**point)["curve1"]));
+			box->push_back(PaperPoint(right, 0));
+			box->push_back(PaperPoint(left, 0));
+			ypos.push_back((**point)["curve1"]);
+			limits.push_back(x);
+		}
+		visitor.push_back(box);
+	}
+	
+	double miny = *std::min_element(ypos.begin(), ypos.end());
+	double maxy = *std::max_element(ypos.begin(), ypos.end());
+	
+	if ( !limits.empty() ) {
+		first->push_back(PaperPoint(limits.front(), miny));
+		first->push_back(PaperPoint(limits.front(), maxy));
+	
+		last->push_back(PaperPoint(limits.back(), miny));
+		last->push_back(PaperPoint(limits.back(), maxy));
+	}
+}
+
+void MetgramCurve::operator()(CustomisedPointsList& points, BasicGraphicsObjectContainer& visitor) 
+{	
+	Polyline* curve1  = new Polyline();
+	curve1->setColour(*colour_);
+	curve1->setThickness(thickness_);
+	//curve1->setLineStyle(line_style_);
+	
+	Polyline* curve2  = new Polyline();
+	curve2->setColour(Colour("blue"));
+	curve2->setThickness(2); 
+	
+	vector<double> xpos;
+	vector<double> ypos;
+
+	MagDate date((long)(*points.front())["year"], (long)(*points.front())["month"], (long)(*points.front())["day"]);
+	MagTime time((long)(*points.front())["hours"], (long)(*points.front())["minutes"], (long)(*points.front())["seconds"]);
+	DateTime  base = DateTime(date, time);	
+
+	double x1 = 0.;
+	double x2 = 0.;
+	double y1 = DBL_MAX;
+	double y2 = DBL_MIN;
+
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		
+		MagDate date((long)(**point)["year"], (long)(**point)["month"], (long)(**point)["day"]);
+		MagTime time((long)(**point)["hours"], (long)(**point)["minutes"], (long)(**point)["seconds"]);
+
+		DateTime orig = DateTime(date, time);		
+		
+		double x = orig - base;		
+		xpos.push_back(x);		
+	    x -= (**point)["shift"];
+		
+		if ( (*point)->find("curve1") != (*point)->end() )   {
+			curve1->push_back(PaperPoint(x, (**point)["curve1"]));
+			ypos.push_back((**point)["curve1"]);
+			if ( (**point)["curve1"] < y1 ) {
+				x1 = x;
+				y1 = (**point)["curve1"];
+			}
+		}
+		
+		if ( (*point)->find("curve2") != (*point)->end() )   {
+			curve2->push_back(PaperPoint(x, (**point)["curve2"]));
+			ypos.push_back((**point)["curve2"]);
+			if ( (**point)["curve2"] > y2 ) {
+				x2 = x;
+				y2 = (**point)["curve2"];
+			}
+		}
+	}
+	
+	if ( !curve2->empty() ) visitor.push_back(curve2);
+	if ( !curve1->empty() ) visitor.push_back(curve1);
+	
+	double minx = -6*3600;
+	double maxx = *std::max_element(xpos.begin(), xpos.end()) + (6 *3600);
+	double miny = *std::min_element(ypos.begin(), ypos.end());
+	double maxy = *std::max_element(ypos.begin(), ypos.end());
+	
+	double height = maxy-miny;
+	double width = maxx-minx;
+	
+	if ( points.front()->find("temperature") !=  points.front()->end() ) {
+	
+	    Text* text1 = new Text();
+	    text1->addText("T2m", Colour("red"), 0.3);
+	    text1->push_back(PaperPoint(x1, y1+(height*.50)));
+	    visitor.push_back(text1);
+	    
+	    Polyline* arrow1 = new Polyline();
+	    arrow1->setColour(Colour("red"));
+	    arrow1->setThickness(2);
+	    arrow1->push_back(PaperPoint(x1-(width*0.003), y1+(height*.15)));    
+	    arrow1->push_back(PaperPoint(x1, y1+(height*.05)));
+	    arrow1->push_back(PaperPoint(x1, y1+(height*.4)));
+	    arrow1->push_back(PaperPoint(x1, y1+(height*.05))); 
+	    arrow1->push_back(PaperPoint(x1+(width*0.003), y1+(height*.15)));
+	    visitor.push_back(arrow1);
+	    
+	    Text* text2 = new Text();
+	    text2->addText("T850", Colour("blue"), 0.3);
+	    text2->push_back(PaperPoint(x2, y2-(height*.5)));
+	    visitor.push_back(text2);
+		
+	    Polyline* arrow2 = new Polyline();
+	    arrow2->setColour(Colour("blue"));
+	    arrow2->setThickness(2);
+	    arrow2->push_back(PaperPoint(x2-(width*0.005), y2-(height*.15)));    
+	    arrow2->push_back(PaperPoint(x2, y2-(height*0.05)));
+	    arrow2->push_back(PaperPoint(x2, y2-(height*.4)));
+	    arrow2->push_back(PaperPoint(x2, y2-(height*.05)));
+	    arrow2->push_back(PaperPoint(x2+(width*0.005), y2-(height*.15)));
+	    visitor.push_back(arrow2);
+	}
+}
+
+void MetgramFlags::operator()(CustomisedPointsList& points, BasicGraphicsObjectContainer& visitor)
+{
+	MagDate date((long)(*points.front())["year"], (long)(*points.front())["month"], (long)(*points.front())["day"]);
+	MagTime time((long)(*points.front())["hours"], (long)(*points.front())["minutes"], (long)(*points.front())["seconds"]);
+	DateTime  base = DateTime(date, time);	
+	
+	Flag* flags = new Flag();
+	flags->setColour(*colour_); 
+	flags->setLength(length_);
+   
+	flags->setOriginMarker("magics_15");
+	flags->setOriginHeight(0.05);
+	flags->setConvention(KNOTS);
+	int i = 0;
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		i++;
+        if ( i % frequency_ ) 
+            continue;
+		MagDate date((long)(**point)["year"], (long)(**point)["month"], (long)(**point)["day"]);
+		MagTime time((long)(**point)["hours"], (long)(**point)["minutes"], (long)(**point)["seconds"]);
+		
+		
+		DateTime orig = DateTime(date, time);				
+		double x = orig - base;		
+		  x -= (**point)["shift"];
+		
+        
+		if ( (*point)->find("curve1") != (*point)->end() && (*point)->find("curve2") != (*point)->end() )   {
+			PaperPoint pos(x, 0);
+			flags->push_back(ArrowPoint((**point)["curve1"], (**point)["curve2"], pos));
+		}
+	}
+	if ( !flags->empty() ) visitor.push_back(flags);	
+}
+
+void MetgramCurve::visit(LegendVisitor& legend) 
+{
+	MagLog::dev() << "MetgramGraph::visit(LegendBase&) " << endl;
+	Polyline* curve1  = new Polyline();
+	curve1->setColour(Colour("red"));
+	curve1->setThickness(2);
+	
+	Polyline* curve2  = new Polyline();
+	curve2->setColour(Colour("blue"));
+	curve2->setThickness(2);
+	legend.add(new LineEntry("curve1", curve1));
+	legend.add(new LineEntry("curve2", curve2));
+}
+
diff --git a/src/visualisers/MetgramStyle.h b/src/visualisers/MetgramStyle.h
new file mode 100644
index 0000000..ca5854f
--- /dev/null
+++ b/src/visualisers/MetgramStyle.h
@@ -0,0 +1,193 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MetgramStyle.h
+    \brief Definition of the Template class MetgramStyle.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Mon 16-Oct-2006
+    
+    Changes:
+    
+*/
+
+#ifndef MetgramStyle_H
+#define MetgramStyle_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "CustomisedPoint.h"
+#include "PaperPoint.h"
+#include "BasicGraphicsObject.h"
+#include "MetgramFlagsAttributes.h"
+#include "MetgramCurveAttributes.h"
+namespace magics {
+
+
+class LegendVisitor;
+class BasicSceneObject;
+
+class MetgramStyle {
+
+public:
+	MetgramStyle();
+	virtual ~MetgramStyle();
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) {
+        return false;
+    }
+    virtual MetgramStyle* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new MetgramStyle();
+    }
+        virtual void operator()(CustomisedPointsList&, BasicGraphicsObjectContainer&) {}
+
+	virtual void toxml(ostream&) const {
+   	
+    } 
+    virtual void visit(LegendVisitor&) {}
+ 
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	MetgramStyle(const MetgramStyle&);
+    //! Overloaded << operator to copy - No copy allowed
+	MetgramStyle& operator=(const MetgramStyle&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MetgramStyle& p)
+		{ p.print(s); return s; }
+
+};
+
+class MetgramBar: public MetgramStyle {
+
+public:
+	MetgramBar() {}
+	virtual ~MetgramBar() {}
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string& node) {
+        return magCompare(node, "bar");
+    }
+    virtual MetgramStyle* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new MetgramBar();
+    }
+    
+    virtual void operator()(CustomisedPointsList& points, BasicGraphicsObjectContainer& task);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+};
+
+class MetgramCurve: public MetgramStyle,public MetgramCurveAttributes {
+
+public:
+	MetgramCurve() {}
+	virtual ~MetgramCurve() {}
+    
+    virtual void set(const XmlNode& node) {
+    	MetgramCurveAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+    	MetgramCurveAttributes::set(map);
+    }
+    virtual MetgramStyle* clone() const {
+        return new MetgramCurve();
+    }
+     virtual bool accept(const string& node) {
+        return magCompare(node, "curve");
+    }
+    virtual void operator()(CustomisedPointsList& points, BasicGraphicsObjectContainer& task);
+    virtual void visit(LegendVisitor&);
+    virtual void set(const PaperPoint&, BasicGraphicsObjectContainer&) {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+};
+
+
+class MetgramFlags: public MetgramStyle, public MetgramFlagsAttributes
+{
+public:
+	MetgramFlags() {}
+	virtual ~MetgramFlags() {}
+    
+    virtual void set(const XmlNode& node) {
+        MetgramFlagsAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& node) {
+        MetgramFlagsAttributes::set(node);
+    }
+     virtual bool accept(const string& node) {
+        return magCompare(node, "flags");
+        
+    }
+    virtual MetgramStyle* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new MetgramFlags();
+    }
+    
+    virtual void operator()(CustomisedPointsList& points, BasicGraphicsObjectContainer& task);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+};
+
+template <>
+class MagTranslator<string, MetgramStyle> { 
+public:
+	MetgramStyle* operator()(const string& val )
+	{
+		return SimpleObjectMaker<MetgramStyle>::create(val);
+	}     
+
+	MetgramStyle* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/NoGridPlottingAttributes.h b/src/visualisers/NoGridPlottingAttributes.h
new file mode 100644
index 0000000..bbec009
--- /dev/null
+++ b/src/visualisers/NoGridPlottingAttributes.h
@@ -0,0 +1,84 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file NoGridPlottingAttributes.h
+    \brief Definition of NoGridPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:13 2012
+*/
+   
+
+#ifndef NoGridPlottingAttributes_H
+#define NoGridPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class NoGridPlottingAttributes 
+{
+public:
+//  --  constructor
+    NoGridPlottingAttributes();
+    
+//  --  destructor
+    virtual ~NoGridPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const NoGridPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double latReference_;
+	double latIncrement_;
+	double lonReference_;
+	double lonIncrement_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const NoGridPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/NormalTableMode.cc b/src/visualisers/NormalTableMode.cc
new file mode 100644
index 0000000..d903cfe
--- /dev/null
+++ b/src/visualisers/NormalTableMode.cc
@@ -0,0 +1,166 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NormalTableMode.h
+    \brief Implementation of the Template class NormalTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 14-July-2005
+    
+    Changes:
+    
+*/
+
+#include "NormalTableMode.h"
+
+#define ETM_MLEN 1024 //maximum number of elements of a histogram
+
+using namespace magics;
+
+NormalTableMode::NormalTableMode()
+{
+}
+
+
+NormalTableMode::~NormalTableMode()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NormalTableMode::print(ostream& out)  const
+{
+	out << "NormalTableMode[";
+	LookupTableModeAttributes::print(out);
+	out << "]";
+}
+
+void NormalTableMode::operator()(Image& im, Raster& rd)
+{
+//int normalslicing_ (Real *outlayer, int *value, int *nb, int *lut, 
+//					int* MLEN, int* min, int* max)
+
+     int 	i;		// auxiliary variables
+     long	acum;		// accumulated population
+     long	pop;		// total population
+     long       cutv;		// outlayer population
+     double	ratio;		// ratio value
+
+
+     // Check outlayer value
+     if ( outlayer_ < 0. || outlayer_ > 0.5 )
+     {
+	   MagLog::warning() << "Invalid outlayer value. Range between 0. and 0.5" << endl;
+	   MagLog::warning() << "Default value used (0.0)" << endl;
+	   outlayer_ = 0.;
+     }
+
+     // Check image range of values
+     int imin = (int)rd.min();
+     int imax = (int)rd.max();
+     if (imax > ETM_MLEN || imin < 0 )
+     {
+	  MagLog::error() << "NormalTableMode: Invalid range of image values (" << imin << "," << imax << ")\n"
+	               << "  Current implementation accepts values between 0 to " << ETM_MLEN << endl;
+	  return;
+     }
+
+     // Initialize lookuptable
+     ColourTable& table = im.getColourTable();
+     int nlevels = table.size();
+
+     // Reserve memory for the histogram and lut
+     imax++; //index imax is needed
+     vector<long> hist(imax,0L);
+     vector<short> lut(imax);
+
+
+     // Compute histogram (Maybe we do not need to use all values -> one every 10???)
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+	     // Remove this test later
+	     if(*val < imin || *val > imax-1)
+		     MagLog::warning() << "ERROR" << endl;
+
+	     hist[(int)*val]++;
+     }
+
+//remove later
+//long aa=0L;
+//for(i = 0; i < imax; i++) 
+//{
+//aa += hist[i];
+//MagLog::dev()<< i << " " << hist[i] << endl;
+//}
+
+     // Remove outlayers and compute minmax indexes
+     int minOut = 0;
+     int maxOut = imax-1;
+     pop  = (long)rd.getRows() * (long)rd.getColumns();
+     cutv = (long) ((double)pop * outlayer_ + 1.);
+     acum = 0L;
+     for (i = 0; i < imax; i++)
+     {
+	  acum += hist[i];
+	  if ( acum >= cutv )
+	  {
+	       minOut = i;
+	       break;
+	  }
+     }
+     acum = 0L;
+     for (i = imax-1; i >= 0; i--)
+     {
+	  acum += hist[i];
+	  if ( acum >= cutv )
+	  {
+	       maxOut = i;
+	       break;
+	  }
+     }
+
+     // Create lut
+     ratio = (double)(maxOut-minOut) / (double)nlevels;
+     for( i = 0; i < imax; i++)
+     {
+	  if ( i < minOut ) 
+	       lut[i] = 0;
+	  else if (i >= maxOut)
+	       lut[i] = nlevels-1;
+	  else
+		  lut[i] = (short)( (double)(i-minOut) / ratio);
+     }
+
+     // Create output image
+//vector<long> hist1(nlevels+1,0L); //test
+     for (vector<double>::const_iterator val = rd.begin(); val != rd.end(); ++val)
+     {
+//	     im.push_back(lut[(int)*val]);
+	     short ii = lut[(int)*val];
+	     im.push_back(ii);
+//hist1[ii]++;
+     }
+/*
+     MagLog::dev()<< "NormalTableMode::operator()" << endl;
+     for( i = 0; i < nlevels+1; i++)
+	     MagLog::dev()<< i << " " << hist1[i] << endl;
+*/
+     return;
+}
diff --git a/src/visualisers/NormalTableMode.h b/src/visualisers/NormalTableMode.h
new file mode 100644
index 0000000..2d399f2
--- /dev/null
+++ b/src/visualisers/NormalTableMode.h
@@ -0,0 +1,67 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file NormalTableMode.cc
+    \brief Definition of the Template class NormalTableMode.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Tue 14-July-2005
+    
+    Changes:
+    
+*/
+
+#ifndef NormalTableMode_H
+#define NormalTableMode_H
+
+#include "magics.h"
+
+#include "LookupTableMode.h"
+
+namespace magics {
+
+class NormalTableMode: public LookupTableMode {
+
+public:
+	NormalTableMode();
+	virtual ~NormalTableMode();
+	void set(const map<string, string>& map ) // for MagML
+		 { LookupTableModeAttributes::set(map); }
+
+	virtual void operator()(Image&, Raster&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	NormalTableMode(const NormalTableMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	NormalTableMode& operator=(const NormalTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NormalTableMode& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ObsItem.h b/src/visualisers/ObsItem.h
new file mode 100644
index 0000000..702d8f8
--- /dev/null
+++ b/src/visualisers/ObsItem.h
@@ -0,0 +1,96 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsItem.h
+    \brief Definition of the Template class ObsItem.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 18-May-2005
+    
+    Changes:
+    
+*/
+
+#ifndef ObsItem_H
+#define ObsItem_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "CustomisedPoint.h"
+#include "ObsItemAttributes.h"
+#include "Symbol.h"
+
+
+
+namespace magics {
+
+
+class ObsItem : public ObsItemAttributes {
+
+
+public:
+	ObsItem() {}
+	virtual ~ObsItem() {}
+	
+	virtual void set(const map<string, string>& map) { ObsItemAttributes::set(map); }
+	virtual void operator()(CustomisedPoint&, ComplexSymbol&) const {} 
+	virtual void visit(std::set<string>&) {}
+	
+	string find(const map<string, string>& def, const string& keyword, const string& defaut = "")
+	{
+		map<string, string>::const_iterator val = def.find(keyword);
+		return ( val != def.end() ) ?  val->second : defaut;
+	}
+ 
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "obsItem";  }
+
+private:
+    //! Copy constructor - No copy allowed
+	ObsItem(const ObsItem&);
+    //! Overloaded << operator to copy - No copy allowed
+	ObsItem& operator=(const ObsItem&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsItem& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, ObsItem> { 
+public:
+	ObsItem* operator()(const string& val )
+	{
+		return SimpleObjectMaker<ObsItem>::create(val);
+	}     
+
+	ObsItem* magics(const string& param)
+	{
+		ObsItem* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ObsItemFamily.cc b/src/visualisers/ObsItemFamily.cc
new file mode 100644
index 0000000..14475b0
--- /dev/null
+++ b/src/visualisers/ObsItemFamily.cc
@@ -0,0 +1,801 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsItemFamily.cc
+    \brief Implementation of the Template class ObsItemfamily.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+#include "ObsItemFamily.h"
+#include "iomanip"
+#include "Transformation.h"
+
+#include "Flag.h"
+#include "Text.h"
+#include "PaperPoint.h"
+
+using namespace magics;
+
+
+map<int, string> ObsCloudAndWind::origins_;
+
+void  ObsWind::setOrigins() 
+{
+	
+}
+void ObsWind::visit(std::set<string>& tokens)
+{
+	if (!attributes_ ) attributes_ = new ObsWindAttributes();
+	if ( !colour_.empty() )  attributes_->colour_ = auto_ptr<Colour>(new Colour(colour_));
+	if (!attributes_->visible_) return;
+	tokens.insert(speed_);
+	tokens.insert(direction_);
+
+}
+void ObsWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+
+	map<string, double>::iterator it = point.begin();
+	map<string, double>::iterator en = point.end();
+	for(;it != en; ++it)
+	{
+	 MagLog::debug() << " >>> "<<it->first<<" -> " << it->second << endl;
+	}
+
+	CustomisedPoint::const_iterator speed = point.find(speed_);
+	if ( speed == point.end() ) return; 
+	CustomisedPoint::const_iterator direction = point.find(direction_);
+	if ( direction == point.end() ) return; 
+
+	FlagItem* flag = new FlagItem();
+	flag->setColour(*attributes_->colour_);
+	flag->length(size_ * 1.5); // Size to be adjusted later!
+
+	const string origin = "circle";
+
+
+MagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: "<<point.longitude()<<" / "<<point.latitude()
+     << "\n\twind_speed:     " << point[speed_]
+     << "\n\twind_direction: " << point[direction_]
+     << "\n\tcloud amount:   " << point["cloud_amount"]<<" -> "<<origin <<endl;
+
+
+	flag->setOriginHeight(0.01);
+	flag->setOriginMarker(origin);
+	flag->x(0);
+	flag->y(0);
+	
+	const Transformation& transformation = symbol.parent().transformation();
+	PaperPoint pp(point.longitude(), point.latitude());
+	pair<double, double> wind = make_pair(speed->second, direction->second);
+	transformation.reprojectSpeedDirection(pp, wind);
+	
+	flag->speed(speed->second);
+	flag->direction(direction->second);
+
+	if (point.latitude() <0 ) 
+		flag->setHemisphere(SOUTH);
+	symbol.add(flag);
+}
+void  ObsCloudAndWind::setOrigins() 
+{
+	if ( !origins_.empty() ) return;
+	origins_[0] = "N_0";
+	origins_[1] = "N_1";
+	origins_[2] = "N_2";
+	origins_[3] = "N_3";
+	origins_[4] = "N_4";
+	origins_[5] = "N_5";
+	origins_[6] = "N_6";
+	origins_[7] = "N_7";
+	origins_[8] = "N_8";
+}
+
+void ObsCloudAndWind::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+
+	map<string, double>::iterator it = point.begin();
+	map<string, double>::iterator en = point.end();
+	for(;it != en; ++it)
+	{
+	 MagLog::debug() << " >>> "<<it->first<<" -> " << it->second << endl;
+	}
+
+	CustomisedPoint::const_iterator speed = point.find("wind_speed");
+	if ( speed == point.end() ) return; 
+	CustomisedPoint::const_iterator direction = point.find("wind_direction");
+	if ( direction == point.end() ) return; 
+
+	FlagItem* flag = new FlagItem();
+	flag->setColour(*attributes_->colour_);
+	flag->length(size_ * 1.5); // Size to be adjusted later!
+
+	map<int, string>::const_iterator marker = origins_.find(int(point["cloud_amount"]));
+	const string origin = ( marker != origins_.end()) ? marker->second : "magics_13";
+
+
+MagLog::debug() << "OBS ITEM - ObsWind - Lon/Lat: "<<point.longitude()<<" / "<<point.latitude()
+     << "\n\twind_speed:     " << point["wind_speed"] 
+     << "\n\twind_direction: " << point["wind_direction"]
+     << "\n\tcloud amount:   " << point["cloud_amount"]<<" -> "<<origin <<endl;
+
+	flag->setOriginHeight(size_);
+	flag->setOriginMarker(origin);
+	flag->x(0);
+	flag->y(0);
+	
+	const Transformation& transformation = symbol.parent().transformation();
+	PaperPoint pp(point.longitude(), point.latitude());
+	pair<double, double> wind = make_pair(speed->second, direction->second);
+	transformation.reprojectSpeedDirection(pp, wind);
+	
+	flag->speed(speed->second);
+	flag->direction(direction->second);
+
+	if (point.latitude() <0 ) 
+		flag->setHemisphere(SOUTH);
+	symbol.add(flag);
+}
+
+void ObsPressure::visit(std::set<string>& tokens)
+{
+	if ( !attributes_ ) attributes_ = new ObsPressureAttributes();
+	if (!attributes_->visible_) return;
+	if ( !colour_.empty() )  attributes_->colour_ = auto_ptr<Colour>(new Colour(colour_));
+	tokens.insert("msl_pressure");
+}
+
+void ObsPressure::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("msl_pressure");
+	if ( value == point.end() ) return;
+	
+	TextItem*  object = new TextItem();
+	// for the pressure we show the 3 last digits of the pressure in decaPascal.
+	object->x(column_);
+	object->y(row_);
+	MagFont font;
+	font.colour(*attributes_->colour_);
+	font.name("sansserif");
+	font.size(size_);
+	
+	ostringstream os;
+	double pressure = fmod(value->second/10, 1000);
+	os <<  setw(3) << setfill('0') << pressure;
+	object->text(os.str());
+
+
+	MagLog::debug() << "\tPressure:  " << value->second << " = " << pressure << " -> "<<os.str() << "\n";
+
+	object->font(font);
+	symbol.add(object);
+}
+
+void ObsPressureLevel::visit(std::set<string>& tokens)
+{
+	if ( !attributes_ ) attributes_ = new ObsPressureLevelAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("pressure");
+}
+
+void ObsPressureLevel::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("pressure");
+	if ( value == point.end() ) return;
+	TextItem*  object = new TextItem();
+	object->x(column_);
+	object->y(row_);
+	
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	
+	const double pressure = value->second/100.;
+
+	object->text(tostring(pressure));
+
+	MagLog::debug() << "\tPressureLevel: " << value->second << " = " << pressure << "\n";
+	font.size(size_);
+	object->font(font);
+	symbol.add(object);
+}
+	
+void ObsPressureTendency::visit(std::set<string>& tokens)
+{
+	if ( !attributes_ ) attributes_ = new ObsPressureTendencyAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("pressure_tendency_amount");
+	tokens.insert("pressure_tendency_characteristic");
+}
+	
+void ObsPressureTendency::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("pressure_tendency_amount");
+	if ( value == point.end() ) return; 
+	TextItem*  object = new TextItem();
+	object->x(column_);
+	object->y(row_);
+	
+	ostringstream os;	
+	if(value->second>0) os <<  setw(2) << setfill('0') << value->second * .1;
+	else os << "-" << setw(2) << setfill('0') << value->second * -.1;
+	
+	// The Pressure tendancy is red if negative!
+	MagFont font("sansserif");
+	font.colour(( value->second < 0 ) ? Colour("red") : *attributes_->colour_);
+
+	object->text(os.str());
+	font.size(size_);
+	object->font(font);
+	symbol.add(object);
+	value = point.find("pressure_tendency_characteristic");
+	if ( value == point.end() ) return; 
+	SymbolItem*  tendancy = new SymbolItem();
+	tendancy->x(column_+1);
+	tendancy->y(row_);	
+	
+	tendancy->colour(*attributes_->colour_);
+	ostringstream oss;	
+	oss << "a_"  << value->second;
+	tendancy->symbol(oss.str());
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tPressure tendency--->" << oss.str() << "\n";
+#endif
+	tendancy->height(size_);
+	symbol.add(tendancy);
+}
+
+	
+void ObsDewPoint::visit(std::set<string>& tokens)
+{
+	if ( !attributes_ ) attributes_ = new ObsDewPointAttributes();
+	if (!attributes_->visible_) return;
+	if ( !colour_.empty() )  attributes_->colour_ = auto_ptr<Colour>(new Colour(colour_));
+	tokens.insert("dewpoint");
+}
+
+void ObsDewPoint::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("dewpoint");
+	if ( value == point.end() ) return; 
+	TextItem*  object = new TextItem();
+	MagFont font("sansserif");
+	
+	font.colour(*attributes_->colour_);
+	font.size(size_);
+	object->x(column_);
+	object->y(row_);
+	
+	// The temperature is displayed in Celsius.
+	const double tempe = maground(value->second-273.25);
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tDewPoint--->" << point["dewpoint_2meters"] << " = " << tempe << "\n";
+#endif
+	object->text(tostring(tempe));
+	object->font(font);
+	//object->setJustification(MCENTRE);	
+	
+	symbol.add(object);
+}
+
+	
+void ObsVisibility::visit(std::set<string>& tokens)
+{
+	if ( !attributes_ ) attributes_ = new ObsVisibilityAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("horizontal_visibility");
+}
+/*! 
+   Documnetaion found at :	
+     http://www.zetnet.co.uk/sigs/weather/Met_Codes/vvcode.htm 
+*/
+void ObsVisibility::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("horizontal_visibility");
+	if ( value == point.end() ) return;
+
+	TextItem*  object = new TextItem();
+	object->x(column_);
+	object->y(row_);
+
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	
+	const double vv = value->second;
+	string val;
+	if ( vv <= 5000. )
+		val = tostring(vv/100.);
+	else if (vv <= 30000.)
+		val = tostring(vv/1000. + 50.);
+	else if (vv <= 70000.)
+		val = tostring((((vv/1000.)-30)/5) + 80);
+	else  
+		val = "99";
+
+	object->text(val);
+
+	MagLog::debug() << "\tVisibility: " << vv << " = " << val << "\n";
+
+	font.size(size_);
+	object->font(font);
+	//object->setJustification(MRIGHT);
+
+	symbol.add(object);
+}
+	
+void ObsPresentWeather::visit(std::set<string>& tokens)
+{
+	if ( !attributes_ ) attributes_ = new ObsPresentWeatherAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("present_weather");
+	if ( !colour_.empty() )  attributes_->colour_ = auto_ptr<Colour>(new Colour(colour_));
+}
+
+void ObsPresentWeather::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("present_weather");
+	if ( value == point.end() ) return; 
+	SymbolItem*  object = new SymbolItem();
+	object->x(column_);
+	object->y(row_);
+	
+	object->colour(*attributes_->colour_);
+	//object->setFont("sansserif");
+	ostringstream os;
+	
+	os << "ww_" << setw(2) << setfill('0') << value->second;
+
+	object->symbol(os.str());
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tPresent Weather--->" << os.str() << "\n";
+#endif
+	//time->setJustification(MRIGHT);
+	object->height(size_);
+	symbol.add(object);
+}
+
+
+void ObsTemperature::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const
+{
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("temperature");
+	if ( value == point.end() )  return;
+
+	TextItem*  object = new TextItem();
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	font.size(size_);
+	object->font(font);
+	object->x(column_);
+	object->y(row_);
+	
+	// The temperature is displayed in Celsius.		
+	double tempe = maground(value->second-273.25);
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tTemperature: " << tempe << " from "<<value->second<<"\n";
+#endif
+	object->text(tostring(tempe));
+	//object->setJustification(MCENTRE);
+
+	symbol.add(object);
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+
+void ObsTimePlot::visit(std::set<string>&) 
+{
+	if ( !attributes_ ) attributes_ = new ObsTimePlotAttributes();
+	if (!attributes_->visible_) return;
+}
+	
+void ObsTimePlot::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const 
+{ 
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("time");
+	if ( value == point.end() ) return;
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tTimePlot: " << value->second << "at[" << column_ << ", " << row_ << "]" << endl;
+#endif
+	TextItem*  time = new TextItem();
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	font.size(size_);
+	time->x(column_);
+	time->y(row_);
+	time->font(font);
+	time->text(tostring(value->second));
+	//time->setJustification(MRIGHT);
+	
+	symbol.add(time);
+} 
+
+/////////////////////////////////////////////////////////////////////////////////
+
+void ObsHeight::visit(std::set<string>& tokens ) 
+{
+	if ( !attributes_ ) attributes_ = new ObsHeightAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("geopotential");
+}
+	
+void ObsHeight::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const 
+{ 
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("geopotential");
+	if ( value == point.end() ) return;
+	double geop = maground(value->second/98.1);
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tGeopotential: " << geop << "at[" << column_ << ", " << row_ << "]" << endl;
+#endif
+	TextItem*  height = new TextItem();
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	font.size(size_);
+	height->x(column_);
+	height->y(row_);
+
+	height->text(tostring(geop));
+	//height->setJustification(MLEFT);
+	height->font(font);
+	symbol.add(height);
+} 
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ObsThickness::visit(std::set<string>& tokens ) 
+{
+	if ( !attributes_ ) attributes_ = new ObsThicknessAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("thickness");
+}
+
+
+void ObsThickness::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const 
+{ 
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("thickness");
+	if ( value == point.end() ) return;
+	const double thickness = maground(value->second/98.1);
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "\tThickness: " << thickness << "at[" << column_ << ", " << row_ << "]" << endl;
+#endif
+	TextItem*  object = new TextItem();
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	font.size(size_);
+	object->x(column_);
+	object->y(row_);
+	
+	object->text(tostring(thickness));
+	//object->setJustification(MLEFT);
+	object->font(font);
+	symbol.add(object);
+} 
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+
+void ObsIdentifier::visit(std::set<string>&) 
+{
+	if ( !attributes_ ) attributes_ = new ObsIdentifierAttributes();
+	MagLog::debug() << " ObsIdentifier" << *attributes_ << endl;
+	if (!attributes_->visible_) return;
+}
+	
+void ObsIdentifier::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const 
+{ 
+	if (!attributes_->visible_) return;
+	TextItem*  time = new TextItem();
+#ifdef OBS_DEBUG_
+	MagLog::debug() << "Identification for " << point.identifier() << "at[" << column_ << ", " << row_ << "]" << endl;
+#endif
+	MagFont font("sansserif");
+	font.colour(*attributes_->colour_);
+	font.size(size_);
+	time->x(column_);
+	time->y(row_);
+	time->text(point.identifier());
+	//time->setJustification(MRIGHT);
+	time->font(font);
+	
+	symbol.add(time);
+} 
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+void ObsPastWeather::visit(std::set<string>& tokens) 
+{
+	if ( !attributes_ ) attributes_ = new ObsPastWeatherAttributes();
+	if (!attributes_->visible_) return;
+	tokens.insert("past_weather_1");
+	tokens.insert("past_weather_2");
+}
+
+void ObsPastWeather::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const 
+{ 
+	if (!attributes_->visible_) return;
+	CustomisedPoint::const_iterator value = point.find("past_weather_1");
+	if ( value == point.end() ) return;
+	if(value->second > 2)
+	{
+		SymbolItem*  object = new SymbolItem();
+		object->x(column_);
+		object->y(row_);
+		object->colour(*attributes_->colour_);
+		ostringstream os;	
+		os << "W_"  << value->second;	
+		object->symbol(os.str());
+#ifdef OBS_DEBUG_
+		MagLog::debug() << "\tPast Weather 1-> " << os.str() << "\n";
+#endif
+		object->height(size_);
+		symbol.add(object);
+
+		//second past weather
+		value = point.find("past_weather_2");
+		if ( value == point.end() ) return;
+		if(value->second > 2)
+		{
+			SymbolItem* object2 = new SymbolItem();
+			object2->x(column_*2);
+			object2->y(row_);
+			object2->colour(*attributes_->colour_);
+			ostringstream os2;	
+			os2 << "W_"  << value->second;	
+			object2->symbol(os2.str());
+#ifdef OBS_DEBUG_
+			MagLog::debug() << "\tPast Weather 2-> " << os2.str() << "\n";
+#endif
+			object2->height(size_);
+			symbol.add(object2);
+		}
+	}
+} 
+
+///////////////////////////////////////////////////////////////////////////////////
+
+void ObsCloud::visit(std::set<string>& tokens) 
+{
+
+	if (!attributes_ ) attributes_ = new ObsCloudAttributes();
+	if (!attributes_->visible_) return;
+	if ( attributes_->low_ )
+	{
+		tokens.insert("low_cloud");
+		tokens.insert("low_cloud_nebulosity");
+		tokens.insert("low_cloud_height");
+	}
+	if ( attributes_->medium_ ) tokens.insert("medium_cloud");
+	if ( attributes_->high_ ) tokens.insert("high_cloud");
+	if ( !colour_.empty() )  {
+		cout << "set cloud Colour " << colour_ << endl;
+		attributes_->medium_colour_ = auto_ptr<Colour>(new Colour(colour_));
+		attributes_->low_colour_ = auto_ptr<Colour>(new Colour(colour_));
+		attributes_->high_colour_ = auto_ptr<Colour>(new Colour(colour_));
+	}
+}
+	
+void ObsCloud::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const 
+{ 
+	if (!attributes_->visible_) return;
+	
+	CustomisedPoint::const_iterator value = point.find("low_cloud");
+	if ( value != point.end() )
+	{
+		SymbolItem*  cloud = new SymbolItem();
+		cloud->x(lowColumn_);
+		cloud->y(lowRow_);
+		cloud->colour(*attributes_->low_colour_);
+		ostringstream oss;	
+		int type = int(value->second - (int (value->second/10) *10));
+		oss << "CL_"  << type;
+		cloud->symbol(oss.str());
+#ifdef OBS_DEBUG_
+		MagLog::debug() << "\tLow Cloud--->" << oss.str() << "\n";
+#endif
+		cloud->height(size_);
+		symbol.add(cloud);
+	}
+
+	CustomisedPoint::const_iterator height = point.find("low_cloud_height");
+	CustomisedPoint::const_iterator nebul = point.find("low_cloud_nebulosity");
+	ostringstream nh;
+	string sep = "";
+
+	if ( nebul != point.end() )
+	{
+		nh << nebul->second;
+		sep = "/";
+	}
+	if ( height != point.end() )
+	{
+		double x = height->second;
+		if (x<50) x = 0; 
+		else if (x<100) x = 1; 
+		else if (x<200) x = 2; 
+		else if (x<300) x = 3; 
+		else if (x<600) x = 4; 
+		else if (x<1000) x = 5; 
+		else if (x<1500) x = 6; 
+		else if (x<2000) x = 7; 
+		else if (x<2500) x = 8; 
+		else  x = 9; 
+		nh << sep << x;
+	}
+
+	if (!nh.str().empty())
+	{
+		TextItem*  object = new TextItem();
+		object->x(lowColumn_);
+		object->y(lowRow_-1);
+		MagFont font;
+		font.name("sansserif");
+		font.colour(*attributes_->low_colour_);
+		font.size(size_*.6);
+#ifdef OBS_DEBUG_
+		MagLog::debug() << "\tLow Cloud Nebulosity--->" << value->second << "\n";
+#endif
+		object->text(nh.str());
+		object->font(font);
+		symbol.add(object);
+	}
+
+	value = point.find("medium_cloud");
+	if ( value != point.end() )
+
+	value = point.find("medium_cloud");
+	if ( value != point.end() )
+	{
+		SymbolItem*  cloud = new SymbolItem();
+		cloud->x(mediumColumn_);
+		cloud->y(mediumRow_);
+		
+		cloud->colour(*attributes_->medium_colour_);
+		ostringstream oss;
+		int type = int(value->second - (int (value->second/10.) *10));
+		oss << "CM_"  << type;
+		cloud->symbol(oss.str());
+
+		MagLog::debug() << "\tMedium Cloud--->" <<value->second<<" > "<< oss.str() << "\n";
+
+		cloud->height(size_);
+		symbol.add(cloud);
+	}
+	
+	value = point.find("high_cloud");
+	if ( value != point.end() )
+	{
+		SymbolItem*  cloud = new SymbolItem();
+		cloud->x(highColumn_);
+		cloud->y(highRow_);
+		cloud->colour(*attributes_->high_colour_);
+		ostringstream oss;	
+		int type = int(value->second - (int (value->second/10) *10));
+		oss << "CH_"  << type;
+		cloud->symbol(oss.str());
+#ifdef OBS_DEBUG_
+		MagLog::debug() << "\tHigh Cloud--->" << oss.str() << "\n";
+#endif
+		cloud->height(size_);
+		symbol.add(cloud);
+	}
+}
+
+void ObsCloud::set(const map<string, string>& def)
+{   
+	lowRow_ = atoi(find(def, "low_row").c_str());
+	lowColumn_ = atoi(find(def, "low_column").c_str());
+
+	mediumRow_ = atoi(find(def, "medium_row").c_str());
+	mediumColumn_ = atoi(find(def, "medium_column").c_str());
+
+	highRow_ = atoi(find(def, "high_row").c_str());
+	highColumn_ = atoi(find(def, "high_column").c_str());
+
+	colour_ = find(def, "colour");
+}
+
+void ObsDemoItem1::visit(std::set<string>& tokens)
+{
+	tokens.insert("temperature");
+}
+
+void ObsDemoItem1::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const
+{
+	if ( point.find("temperature") == point.end() ) {
+			MagLog::debug() << "No info for temperature given!" << endl;
+			return;
+		}
+
+		TextItem*  object = new TextItem();
+		object->x(column_);
+		object->y(row_);
+
+		object->text(tostring(point["temperature"]/3));
+		symbol.add(object);
+}
+
+void ObsDemoItem2::visit(std::set<string>& tokens)
+{
+	tokens.insert("info_for_demo2");
+}
+
+void ObsDemoItem2::operator()(CustomisedPoint& point, ComplexSymbol& symbol) const
+{
+	string text;
+	if ( point.find("info_for_demo2") == point.end() )
+			text = attributes_->text_;
+
+	else
+		text=tostring(point["info_for_demo2"]);
+
+	TextItem*  object = new TextItem();
+	object->x(column_);
+	object->y(row_);
+	MagFont font;
+	font.name("sansserif");
+	font.colour(attributes_->text_colour_);
+	font.size(size_);
+	//object->colour(attributes_text_colour_);
+	object->text(text);
+	object->font(font);
+	symbol.add(object);
+}
+
+void ObsEra::set(const map<string, string>& def)
+{
+	key_ = find(def, "key");
+	colour_ = find(def, "colour");
+	row_ = atoi(find(def, "row").c_str());
+	column_ = atoi(find(def, "column").c_str());
+}
+
+void  ObsEra::visit(std::set<string>& tokens)
+{
+	tokens.insert(key_);
+}
+
+void  ObsEra::operator()(CustomisedPoint& point,  ComplexSymbol& symbol) const
+{
+
+	string text = tostring(point[key_]);
+	TextItem*  object = new TextItem();
+	object->x(column_);
+	object->y(row_);
+	MagFont font;
+	font.name("sansserif");
+	font.colour(colour_);
+	font.size(size_);
+
+	object->text(text);
+	object->font(font);
+	symbol.add(object);
+
+}
diff --git a/src/visualisers/ObsItemFamily.h b/src/visualisers/ObsItemFamily.h
new file mode 100644
index 0000000..d4733d6
--- /dev/null
+++ b/src/visualisers/ObsItemFamily.h
@@ -0,0 +1,384 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef ObsItemFamily_H
+#define ObsItemFamily_H
+
+
+
+
+#include "ObsItem.h"
+#include "UserPoint.h"
+#include "ObsWindAttributes.h"
+#include "ObsStationRingAttributes.h"
+#include "ObsIdentifierAttributes.h"
+#include "ObsTimePlotAttributes.h"
+#include "ObsTemperatureAttributes.h"
+#include "ObsPressureAttributes.h"
+#include "ObsPressureLevelAttributes.h"
+#include "ObsPressureTendencyAttributes.h"
+#include "ObsDewPointAttributes.h"
+#include "ObsVisibilityAttributes.h"
+#include "ObsPresentWeatherAttributes.h"
+#include "ObsPastWeatherAttributes.h"
+#include "ObsCloudAttributes.h"
+#include "ObsHeightAttributes.h"
+#include "ObsThicknessAttributes.h"
+#include "ObsDemoItem2Attributes.h"
+#include "Symbol.h"
+
+class ObsItemBox : public ObsItem
+{
+public:
+	ObsItemBox() {}
+	~ObsItemBox() {}
+	
+	virtual void set(const map<string, string>& def)
+	{   
+		row_ = atoi(find(def, "row").c_str());
+		column_ = atoi(find(def, "column").c_str());
+		colour_ = find(def, "colour");
+	}
+protected:		
+	int row_;
+	int column_;
+	string colour_;
+};
+
+class ObsStationRing : public ObsItemBox
+{
+public:
+	ObsStationRing() : attributes_(0)  {}
+	~ObsStationRing()  {}
+	void visit(std::set<string>& tokens)
+	{
+		if ( !attributes_ ) attributes_ = new ObsStationRingAttributes();
+		if (!attributes_->visible_) return;
+		tokens.insert("latitude");
+		tokens.insert("longitude");
+		tokens.insert("cloud_amount");
+	}
+
+	void operator()(CustomisedPoint&,  ComplexSymbol& symbol) const
+	{ 
+		if (!attributes_->visible_) return;
+		SymbolItem*  station = new SymbolItem();
+		station->x(column_);
+		station->y(row_);		
+		station->colour(*attributes_->colour_);
+		station->symbol("circle");
+		station->height(size_);
+		symbol.add(station);
+	} 
+
+protected:
+	void print(ostream& out) const { out << "ObsStationRing";  }
+	ObsStationRingAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsTimePlot : public ObsItemBox
+{
+public:
+	ObsTimePlot() : attributes_(0)  {}
+	~ObsTimePlot()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsTimePlot";  }
+	ObsTimePlotAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsWind : public ObsItemBox
+{
+public:
+	ObsWind() : attributes_(0) { setOrigins(); }
+	~ObsWind()  {}
+	void visit(std::set<string>& tokens);
+
+	virtual void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+	virtual void set(const map<string, string>& def)
+	{
+		row_ = atoi(find(def, "row").c_str());
+		column_ = atoi(find(def, "column").c_str());
+		colour_ = find(def, "colour");
+		speed_ = find(def, "wind_speed", "wind_speed");
+		direction_ = find(def, "wind_direction",  "wind_direction");
+	}
+protected:
+	string speed_;
+	string direction_;
+	void setOrigins();
+	void print(ostream& out) const { out << "ObsWind";  }
+	ObsWindAttributes* attributes_; // Here we are delegating instead of inheriting ...
+	
+};
+
+class ObsCloudAndWind : public ObsItemBox
+{
+public:
+	ObsCloudAndWind() : attributes_(0) { setOrigins(); }
+	~ObsCloudAndWind()  {}
+	void visit(std::set<string>& tokens)
+	{
+		if (!attributes_ ) attributes_ = new ObsWindAttributes();
+		if ( !colour_.empty() )  attributes_->colour_ = auto_ptr<Colour>(new Colour(colour_));
+		if (!attributes_->visible_) return;
+		tokens.insert("wind_speed");
+		tokens.insert("wind_direction");
+		tokens.insert("cloud_amount");
+	}
+
+	virtual void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void setOrigins();
+	void print(ostream& out) const { out << "ObsWind";  }
+	ObsWindAttributes* attributes_; // Here we are delegating instead of inheriting ...
+	static map<int, string> origins_;
+};
+
+
+
+class ObsTemperature : public ObsItemBox
+{
+public:
+	ObsTemperature() : attributes_(0) {}
+	~ObsTemperature()  {}
+	void visit(std::set<string>& tokens)
+	{
+		if ( !attributes_ ) attributes_ = new ObsTemperatureAttributes();
+		if ( !colour_.empty() )  attributes_->colour_ = auto_ptr<Colour>(new Colour(colour_));
+		if (!attributes_->visible_) return;
+		tokens.insert("temperature");
+	}
+	void operator()(CustomisedPoint&,  ComplexSymbol& symbol) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsTemperature";  }
+	ObsTemperatureAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsPressure : public ObsItemBox
+{
+public:
+	ObsPressure() : attributes_(0) {}
+	~ObsPressure()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsPressure";  }
+	ObsPressureAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsPressureLevel : public ObsItemBox
+{
+public:
+	ObsPressureLevel() : attributes_(0) {}
+	~ObsPressureLevel()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsPressureLevel";  }
+	ObsPressureLevelAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsPressureTendency : public ObsItemBox
+{
+public:
+	ObsPressureTendency() : attributes_(0) {}
+	~ObsPressureTendency()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsPressureTendency";  }
+	ObsPressureTendencyAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsThickness : public ObsItemBox
+{
+public:
+	ObsThickness() : attributes_(0) {}
+	~ObsThickness()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsThickness";  }
+	ObsThicknessAttributes* attributes_; // Here we are delegating instead of inheriting ...
+	
+};
+
+class ObsDewPoint : public ObsItemBox
+{
+public:
+	ObsDewPoint() : attributes_(0) {}
+	~ObsDewPoint()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsDewPoint";  }
+	ObsDewPointAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsHeight : public ObsItemBox
+{
+public:
+	ObsHeight() : attributes_(0) {}
+	~ObsHeight()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsHeight";  }
+	ObsHeightAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsVisibility : public ObsItemBox
+{
+public:
+	ObsVisibility() : attributes_(0) {}
+	~ObsVisibility()  {}
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsVisibility";  }
+	ObsVisibilityAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsPresentWeather : public ObsItemBox
+{
+public:
+	ObsPresentWeather() : attributes_(0) {}
+	~ObsPresentWeather()  {}
+	void visit(std::set<string>& tokens);	
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsPresentWeather";  }
+	ObsPresentWeatherAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsIdentifier : public ObsItemBox
+{
+public:
+	ObsIdentifier() : attributes_(0) {}
+	~ObsIdentifier()  {}
+	void visit(std::set<string>& tokens);	
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsIdentifier";  }
+	ObsIdentifierAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsPastWeather : public ObsItemBox
+{
+public:
+	ObsPastWeather() : attributes_(0) {}
+	~ObsPastWeather()  {}
+	void visit(std::set<string>& tokens);	
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsPastWeather";  }
+	ObsPastWeatherAttributes* attributes_; // Here we are delegating instead of inheriting ...
+};
+
+
+class ObsCloud : public ObsItemBox
+{
+public:
+	ObsCloud() : attributes_(0) {}
+	~ObsCloud()  {}
+	void set(const map<string, string>& def);
+	void visit(std::set<string>& tokens);	
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsCloud";  }
+	ObsCloudAttributes* attributes_; // Here we are delegating instead of inheriting ...
+	int lowRow_;
+	int lowColumn_;
+	int mediumRow_;
+	int mediumColumn_;
+	int highRow_;
+	int highColumn_;
+};
+
+class ObsDemoItem1 : public ObsItemBox
+{
+public:
+	ObsDemoItem1()  {}
+	~ObsDemoItem1()  {}
+
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsDemoItem1";  }
+
+
+};
+class ObsDemoItem2 : public ObsItemBox
+{
+public:
+	ObsDemoItem2()   { attributes_ = new ObsDemoItem2Attributes(); }
+	~ObsDemoItem2()  {}
+
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsDemoItem2";  }
+	ObsDemoItem2Attributes* attributes_; // Here we are delegating instead of inheriting ...
+
+};
+
+class ObsEra : public ObsItemBox
+{
+public:
+	ObsEra()   { }
+	~ObsEra()  {}
+	void set(const map<string, string>& def);
+	void visit(std::set<string>& tokens);
+	void operator()(CustomisedPoint&,  ComplexSymbol&) const;
+
+protected:
+	void print(ostream& out) const { out << "ObsEra";  }
+	string key_;
+	string colour_;
+
+};
+#endif
diff --git a/src/visualisers/ObsPlotting.cc b/src/visualisers/ObsPlotting.cc
new file mode 100644
index 0000000..2679663
--- /dev/null
+++ b/src/visualisers/ObsPlotting.cc
@@ -0,0 +1,145 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsPlotting.cc
+    \brief Implementation of the Template class ObsPlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 23-Mar-2005
+    
+    Changes:
+    
+*/
+
+#include "ObsPlotting.h"
+#include "ObsTable.h"
+#include "Layout.h"
+#include "MetaData.h"
+
+using namespace magics;
+
+ObsPlotting::ObsPlotting() 
+{
+}
+
+ObsPlotting::~ObsPlotting() 
+{
+}
+
+static int COUNT;
+void ObsPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	ObsTable::print();
+	std::set<string> needs;
+	std::set<string> info;
+	multimap<string, string> types;
+
+	info.insert("type");
+
+	data.getInfo(info, types);
+	
+	for (multimap<string, string>::const_iterator type = types.find("type"); type != types.end(); ++type)
+	{		
+		try {
+			const ObsTemplate& obs = ObsTable::getTemplate(type->second);
+			obs.visit(needs);
+		}
+		catch (std::exception&)
+		{
+			MagLog::warning() << " Magics++ has no observation template for: " << type->second << "\n"
+			               << " Please contact the Graphic team.\n";
+		}
+	}
+
+	CustomisedPointsList values;	
+	
+	const Transformation& transformation = out.transformation();
+	data.customisedPoints(transformation, needs, values, false); // we only need the points in the area
+
+
+	COUNT = values.size();
+	
+
+	for (multimap<string, string>::const_iterator type = types.find("type"); type != types.end(); ++type)
+	{
+		try {
+			const ObsTemplate& obs = ObsTable::getTemplate(type->second);
+			obs.set(apart_);
+		
+			for (CustomisedPointsList::const_iterator val = values.begin(); val != values.end(); ++val) 	{
+				if ( type->second == (*val)->type() ) { 
+					obs(*(*val), out);
+				}
+			}
+		}
+		catch (std::exception&)
+		{
+		}
+	}
+}
+
+//void ObsPlotting::filter(const CustomisedPointsList& in, CustomisedPointsList& out)
+//{
+//	out.push_back(in.front());
+//	const Transformation& transformation = getLayout().getTransformation();
+//	
+//	MagLog::dev()<< " ObsPlotting::filter--->" << transformation << endl;
+//	
+//	
+//	for (CustomisedPointsList::const_iterator point = in.begin(); point != in.end(); ++point) {
+//		out.push_back(*point);
+//	}
+//}
+	
+
+/*!
+ \brief Class information are given to the output-stream.
+*/		
+void ObsPlotting::print(ostream& out)  const
+{
+	out << "ObsPlotting[";
+	out << "]";
+}
+void ObsPlotting::visit(MetaDataVisitor& visitor)
+{
+	visitor.add("ObsPlotting", "info");
+	visitor.add("obs_plotted", tostring(COUNT));
+}
+
+
+#include "ObsItemFamily.h"
+static SimpleObjectMaker<ObsStationRing, ObsItem> ObsStationRing("obs_station_ring");
+static SimpleObjectMaker<ObsTimePlot, ObsItem> ObsTimePlot("obs_time_plot");
+static SimpleObjectMaker<ObsWind, ObsItem> ObsWind("obs_wind");
+static SimpleObjectMaker<ObsCloudAndWind, ObsItem> ObsCloudAndWind("obs_cloud_wind");
+static SimpleObjectMaker<ObsTemperature, ObsItem> ObsTemperature("obs_temperature");
+static SimpleObjectMaker<ObsPressure, ObsItem> ObsPressure("obs_pressure");
+static SimpleObjectMaker<ObsPressureTendency, ObsItem> ObsPressureTendency("obs_pressure_tendency");
+static SimpleObjectMaker<ObsDewPoint, ObsItem> ObsDewPoint("obs_dewpoint");
+static SimpleObjectMaker<ObsVisibility, ObsItem> ObsVisibility("obs_visibility");
+static SimpleObjectMaker<ObsPresentWeather, ObsItem> ObsPresentWeather("obs_present_weather");
+static SimpleObjectMaker<ObsPressureLevel, ObsItem> ObsPressureLevel("obs_pressure_level");
+static SimpleObjectMaker<ObsIdentifier, ObsItem> ObsIdentifier("obs_identification");
+static SimpleObjectMaker<ObsCloud, ObsItem> ObsCloud("obs_cloud");
+static SimpleObjectMaker<ObsPastWeather, ObsItem> ObsPastWeather("obs_past_weather");
+static SimpleObjectMaker<ObsHeight, ObsItem> ObsHeight("obs_height");
+static SimpleObjectMaker<ObsThickness, ObsItem> ObsThicjness("obs_thickness");
+static SimpleObjectMaker<ObsDemoItem1, ObsItem> ObsDemo1("obs_demo_item_1");
+static SimpleObjectMaker<ObsDemoItem2, ObsItem> ObsDemo2("obs_demo_item_2");
+static SimpleObjectMaker<ObsEra, ObsItem> Era("obs_era");
diff --git a/src/visualisers/ObsPlotting.h b/src/visualisers/ObsPlotting.h
new file mode 100644
index 0000000..d264ce5
--- /dev/null
+++ b/src/visualisers/ObsPlotting.h
@@ -0,0 +1,92 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsPlotting.h
+    \brief Definition of the Template class ObsPlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Wed 23-Mar-2005
+    
+    Changes:
+    
+*/
+
+/*!
+  \defgroup obs Plotting of observations
+  
+  Magics++ is able to plot observational data from ground, sea or space.
+  Data can be read from BUFR and ODBs.
+  
+  \section obs_overview Plotting using WMO convention
+
+  SYNOP, TEMP and METAR observations can be visulised with the so-called WMO convention
+  
+  \sa http://www.metoffice.gov.uk/corporate/library/factsheets/factsheet11.pdf
+
+  \sa ../../share/magics/obs.xml
+  
+  \sa ../../share/magics/bufr_98.xml
+  
+  \sa ObsDecoder ObsWind ObsItem ObsItemBox ObsStationRing ObsTimePlot CustomisedPoint ComplexSymbol
+
+*/
+
+#ifndef ObsPlotting_H
+#define ObsPlotting_H
+
+#include "magics.h"
+
+#include "Visdef.h"
+#include "ObsPlottingAttributes.h"
+#include "UserPoint.h"
+
+namespace magics {
+
+class ObsPlotting: public Visdef, public ObsPlottingAttributes {
+
+public:
+	ObsPlotting();
+	virtual ~ObsPlotting();
+	virtual void set(const map<string, string>& map) 
+		{  ObsPlottingAttributes::set(map); }
+	
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(MetaDataVisitor&);
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 //void filter(const CustomisedPointsList&, CustomisedPointsList&);
+
+
+private:
+    //! Copy constructor - No copy allowed
+	ObsPlotting(const ObsPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	ObsPlotting& operator=(const ObsPlotting&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ObsPlottingAttributes.h b/src/visualisers/ObsPlottingAttributes.h
new file mode 100644
index 0000000..133a3cf
--- /dev/null
+++ b/src/visualisers/ObsPlottingAttributes.h
@@ -0,0 +1,81 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ObsPlottingAttributes.h
+    \brief Definition of ObsPlotting Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:16 2012
+*/
+   
+
+#ifndef ObsPlottingAttributes_H
+#define ObsPlottingAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class ObsPlottingAttributes 
+{
+public:
+//  --  constructor
+    ObsPlottingAttributes();
+    
+//  --  destructor
+    virtual ~ObsPlottingAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const ObsPlottingAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	double apart_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const ObsPlottingAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ObsStatGraph.h b/src/visualisers/ObsStatGraph.h
new file mode 100644
index 0000000..73c3f26
--- /dev/null
+++ b/src/visualisers/ObsStatGraph.h
@@ -0,0 +1,90 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsStatGraph.h
+    \brief Definition of the Template class ObsStatGraph.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ObsStatGraph_H
+#define ObsStatGraph_H
+
+#include "magics.h"
+
+#ifdef LATER
+#include "ObsStatGraphAttributes.h"
+#endif
+
+#include "magics.h"
+#include "Polyline.h"
+#include "Graph.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+#ifdef LATER
+class ObsStatGraph: public ObsStatGraphAttribute, public Visualiser<PaperPoint> {
+#else 
+class ObsStatGraph: public Visualiser<PaperPoint>{
+#endif
+
+
+public:
+	ObsStatGraph();
+	virtual ~ObsStatGraph();
+    
+   
+    
+    void preparePlot(Data<PaperPoint>&, Task&);
+    void visit(LegendBase&);
+    
+    
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) {  }
+    void set(const XmlNode& node) {  }
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	ObsStatGraph(const ObsStatGraph&);
+    //! Overloaded << operator to copy - No copy allowed
+	ObsStatGraph& operator=(const ObsStatGraph&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsStatGraph& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ObsTable.cc b/src/visualisers/ObsTable.cc
new file mode 100644
index 0000000..3949ab8
--- /dev/null
+++ b/src/visualisers/ObsTable.cc
@@ -0,0 +1,162 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsTable.cc
+    \brief Implementation of the Template class LocalTable.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 21-Jun-2004
+    
+    Changes:
+    
+*/
+#include "ObsTable.h"
+#include "MagException.h"
+#include "expat.h"
+#include <string>
+#include "Layout.h"
+#include "Transformation.h"
+#include "Symbol.h"
+
+
+using std::basic_string;
+
+using namespace magics;
+
+
+static void XMLCALL
+startElement(void *userData, const char *name, const char **atts)
+{
+	ObsTable* table  = (ObsTable*) userData; 
+        map<string, string> def;
+        while (*atts) {
+            def[*(atts)] = *(atts+1);
+            atts+=2;
+        }
+        table->add(name, def);
+	
+}
+
+static void XMLCALL
+endElement(void *, const char *)
+{
+}
+
+ObsTable* ObsTable::table_ = 0;
+
+
+ObsTable::ObsTable() 
+{
+ 
+    string filename = path_.empty() ? getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "obs.xml" : path_;
+	char buf[BUFSIZ];
+	XML_Parser parser = XML_ParserCreate(NULL);
+	int done;
+	XML_SetUserData(parser, this);
+	XML_SetElementHandler(parser, startElement, endElement);
+
+	MagLog::dev() << "Load observation templates --->" << filename << endl;
+	FILE* in  = fopen(filename.c_str(), "r");
+
+	if (!in) throw NoSuchFileException(filename);
+
+	do
+	{
+		size_t len = fread(buf, 1, sizeof(buf), in);
+		done = len < sizeof(buf);
+		if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR)
+		{
+			ostringstream s;
+			s << "XmlMagException : " << XML_ErrorString(XML_GetErrorCode(parser))  << " at line  " <<  XML_GetCurrentLineNumber(parser)  << ends;
+			cerr <<  s.str() << "\n";
+			//throw MagicsException(s.str());
+		}
+	} while (!done);
+	XML_ParserFree(parser);
+	fclose(in);
+}
+
+
+ObsTable::~ObsTable() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+    
+void ObsTable::print(ostream& out)  const
+{
+	out << "ObsTable[";	
+	for ( const_iterator item = begin(); item != end(); ++item) 
+			    out << "\t" << item->first << "---->" << *(item->second) << "\n";
+			out << "\n";
+	out << "]";
+}
+
+void ObsTable::add(const string& tag, const map<string, string>& def) 
+{
+ 	if ( tag == "observations" ) return;
+ 	if ( tag == "obs_template" ) {
+ 		current_ = new ObsTemplate(def);
+ 		insert(make_pair(def.find("type")->second, current_));
+ 	} 
+ 	else {
+ 		try {
+ 			ObsItem* obs = SimpleObjectMaker<ObsItem>::create(tag);
+ 			obs->set(def);
+ 			current_->push_back(obs);
+ 		}
+ 		catch (NoFactoryException&) {
+ 			MagLog::dev() << "can not find ObsItem for : " << tag << "\n";
+ 		}
+ 	}
+}
+   
+const ObsTemplate& ObsTable::get(const string& type)
+{
+	const_iterator entry = find(type);
+	if ( entry != end() ) { return *(entry->second); }
+	else entry =  find("position");
+	return *(entry->second); 
+	throw MagicsException();
+}   
+
+
+void ObsTemplate::operator()(CustomisedPoint& obs, BasicGraphicsObjectContainer& out) const 
+{
+		if ( empty() ) 
+			return; // Nothing to display.
+			
+	
+		const Transformation& transformation = out.transformation();
+		
+		PaperPoint pp = transformation(UserPoint(obs.longitude(), obs.latitude()));
+	
+		
+		ComplexSymbol* symbol = new ComplexSymbol(rows_, columns_);
+		
+		symbol->push_back(pp);
+		symbol->setDistanceApart(apart_);
+		
+		out.push_back(symbol);
+
+		for ( const_iterator item = begin(); item != end(); ++item) 
+			    (*(*item))(obs, *symbol);
+}
diff --git a/src/visualisers/ObsTable.h b/src/visualisers/ObsTable.h
new file mode 100644
index 0000000..6093cd1
--- /dev/null
+++ b/src/visualisers/ObsTable.h
@@ -0,0 +1,120 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#ifndef ObsTable_H
+#define ObsTable_H
+
+#include "magics.h"
+#include "ObsItem.h"
+#include "PaperPoint.h"
+#include "BasicSceneObject.h"
+#include "ObsTableAttributes.h"
+
+namespace magics {
+
+
+
+class ObsTemplate: public vector<ObsItem*>
+{
+public:
+	ObsTemplate(const map<string, string>& def) {
+		    map<string, string>::const_iterator val = def.find("columns");
+		    columns_ = (val != def.end()) ? atoi(val->second.c_str()) : 3; 
+		    val= def.find("rows");
+		    rows_ = (val != def.end()) ? atoi(val->second.c_str()) : 3;
+		     
+	}
+	virtual ~ObsTemplate() {}
+	void visit(std::set<string>& tokens) const
+	{
+		for ( const_iterator item = begin(); item != end(); ++item) 
+			    (*item)->visit(tokens);
+	}
+	void set(double apart) const { apart_ = apart; }
+	void operator()(CustomisedPoint&, BasicGraphicsObjectContainer&) const;
+
+protected:
+	virtual void print(ostream& out) const 
+	{ 
+		out << "ObsTemplate:[\n";
+		for ( const_iterator item = begin(); item != end(); ++item) 
+			out << "\t" << *(*item) << "\n";
+		out << "\n";
+	}
+	double           columns_;
+	double           rows_;
+	mutable vector<PaperPoint> working_;
+	mutable double           apart_;
+	mutable string          box_;
+	
+	friend ostream& operator<<(ostream& s,const ObsTemplate& p)
+		{ p.print(s); return s; }
+};
+
+class ObsTable : public map<string, ObsTemplate*>, public ObsTableAttributes
+{
+public:
+	ObsTable();
+	virtual ~ObsTable();
+
+	void add(const string&, const map<string, string>&);
+
+	static void print()
+	{
+		if ( !table_ )  table_ = new ObsTable();
+	}
+	
+	static void release() 
+	{
+		if ( !table_ )  
+			delete table_;
+	}
+		
+
+	static const ObsTemplate& getTemplate(const string type)
+	{
+		if ( !table_ )  table_ = new ObsTable();
+		return table_->get(type);
+	}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const;
+	ObsTemplate* current_; 
+	double rows_;
+	double columns_;
+
+	const ObsTemplate& get(const string&); 
+
+	static ObsTable* table_;
+
+private:
+    //! Copy constructor - No copy allowed
+	ObsTable(const ObsTable&);
+    //! Overloaded << operator to copy - No copy allowed
+	ObsTable& operator=(const ObsTable&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsTable& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/OriginMarker.h b/src/visualisers/OriginMarker.h
new file mode 100644
index 0000000..2478c09
--- /dev/null
+++ b/src/visualisers/OriginMarker.h
@@ -0,0 +1,150 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file OriginMarker.h
+    \brief Definition of the Template class OriginMarker.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef OriginMarker_H
+#define OriginMarker_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "Transformation.h"
+#include "Arrow.h"
+
+
+namespace magics {
+
+class OriginMarker  {
+
+public:
+	OriginMarker() : marker_("none"), height_(0) {}
+	virtual ~OriginMarker() {}
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual bool accept(const string&) { return false; }
+
+	virtual void toxml(ostream&) {}
+	virtual OriginMarker* clone()
+	{
+		OriginMarker* object = new OriginMarker();
+		object->set(*this);
+		return object;
+	}
+  
+	void marker(const string& marker)      { marker_ = marker; }
+	void height(double height)      { height_ = height; }
+	void set(const OriginMarker& from)
+	{
+		marker_ = from.marker_;
+		height_ = from.height_;
+	}
+	virtual void prepare(ArrowProperties& object)
+	{
+		object.setOriginMarker(marker_);
+		//object.setOriginHeight(height_);
+	}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "OriginMarker"; }
+
+	 string  marker_;
+	 double   height_;
+
+private:
+    //! Copy constructor - No copy allowed
+	OriginMarker(const OriginMarker&);
+    //! Overloaded << operator to copy - No copy allowed
+	OriginMarker& operator=(const OriginMarker&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const OriginMarker& p)
+		{ p.print(s); return s; }
+};
+
+
+class NoOriginMarker: public OriginMarker {
+public:
+	NoOriginMarker() {}
+	~NoOriginMarker() {}
+	virtual OriginMarker* clone()  { return new NoOriginMarker(); }
+	virtual void prepare(ArrowProperties&) {}
+	void operator()(const PaperPoint&) {}
+    virtual bool accept(const string& node) { return magCompare(node, "nomarker"); }
+
+};
+
+
+class CircleOriginMarker: public OriginMarker {
+public:
+	CircleOriginMarker() { this->marker_ = "magics_1"; this->height_ = 0.3; }
+	virtual OriginMarker* clone()
+	{
+		OriginMarker* object = new CircleOriginMarker();
+		object->set(*this);
+		return object;
+	}
+	virtual bool accept(const string& node) { return magCompare(node, "circlemarker"); }
+
+	~CircleOriginMarker() {}
+};
+
+
+class DotOriginMarker: public OriginMarker {
+public:
+	DotOriginMarker() { this->marker_ = "magics_15"; this->height_ = 0.1; }
+	virtual OriginMarker* clone()
+	{
+		OriginMarker* object = new DotOriginMarker();
+		object->set(*this);
+		return object;
+	}
+	~DotOriginMarker() {}
+	virtual bool accept(const string& node) { return magCompare(node, "dotmarker"); }
+
+};
+
+template <>
+class MagTranslator<string, OriginMarker> { 
+public:
+	OriginMarker* operator()(const string& val )
+	{
+		 return SimpleObjectMaker<OriginMarker>::create(val);
+	}     
+	OriginMarker* magics(const string& param)
+	{
+		OriginMarker* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/OutLayerTechnique.cc b/src/visualisers/OutLayerTechnique.cc
new file mode 100644
index 0000000..ee7a97b
--- /dev/null
+++ b/src/visualisers/OutLayerTechnique.cc
@@ -0,0 +1,62 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelection.cc
+    \brief Implementation of the Template class HeightSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "OutLayerTechnique.h"
+
+using namespace magics;
+
+NoOutLayerTechnique::NoOutLayerTechnique() 
+{
+}
+
+
+NoOutLayerTechnique::~NoOutLayerTechnique() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void NoOutLayerTechnique::print(ostream& out)  const
+{
+	out << "OutLayerTechnique[";
+	out << "]";
+}
+
+SimpleOutLayerTechnique::SimpleOutLayerTechnique() 
+{
+}
+
+
+SimpleOutLayerTechnique::~SimpleOutLayerTechnique() 
+{
+}
+
diff --git a/src/visualisers/OutLayerTechnique.h b/src/visualisers/OutLayerTechnique.h
new file mode 100644
index 0000000..6872980
--- /dev/null
+++ b/src/visualisers/OutLayerTechnique.h
@@ -0,0 +1,117 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file HeightSelection.h
+    \brief Definition of the Template class HeightSelection.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 20-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef OutLayerTechnique_H
+#define OutLayerTechnique_H
+
+#include "magics.h"
+
+
+#include "MagTranslator.h"
+#include "Factory.h"
+
+namespace magics {
+
+class XmlNode;
+
+class OutLayerTechniqueInterface
+{
+public: 
+    OutLayerTechniqueInterface() {}
+    virtual ~OutLayerTechniqueInterface() {}
+	virtual float getMinOutlayer() const = 0;
+	virtual float getMaxOutlayer() const = 0;
+	
+};
+
+class NoOutLayerTechnique {
+
+public:
+	NoOutLayerTechnique();
+	virtual ~NoOutLayerTechnique();
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual bool accept(const string&) { return false; }
+    
+    virtual NoOutLayerTechnique* clone() const { return new NoOutLayerTechnique(); }
+    
+    void toxml(ostream&)  const {}
+	
+	
+	
+   
+
+protected:
+     //! Method to print  about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	NoOutLayerTechnique(const NoOutLayerTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	NoOutLayerTechnique& operator=(const NoOutLayerTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const NoOutLayerTechnique& p)
+		{ p.print(s); return s; }
+};
+
+class SimpleOutLayerTechnique : public NoOutLayerTechnique
+{
+public:
+	SimpleOutLayerTechnique();
+	virtual ~SimpleOutLayerTechnique();
+  
+	
+};
+
+
+
+
+
+template<>
+class MagTranslator<string, NoOutLayerTechnique> { 
+public:
+	NoOutLayerTechnique* operator()(const string& val )
+	{
+		return SimpleObjectMaker<NoOutLayerTechnique>::create(val);
+	}     
+
+	NoOutLayerTechnique* magics(const string& param)
+	{
+		NoOutLayerTechnique* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/PolyShadingMethod.cc b/src/visualisers/PolyShadingMethod.cc
new file mode 100644
index 0000000..36e77d5
--- /dev/null
+++ b/src/visualisers/PolyShadingMethod.cc
@@ -0,0 +1,203 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PolyShadingMethod.h
+    \brief Definition of the Template class PolyShadingMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:cc
+    
+*/
+
+
+#include "DotPolyShadingMethod.h"
+#include "HatchPolyShadingMethod.h"
+#include "LevelSelection.h"
+#include "IsoPlot.h"
+#include "PolyShadingTechnique.h"
+using namespace magics;
+
+
+
+	
+    
+void PolyShadingMethod::operator()(Polyline& poly) const
+    {
+       
+		int index = poly.index();
+        poly.setFilled(true);      
+        poly.setStroke(false);
+        poly.setFilled(true);
+        poly.setFillColour(colours_[index]);
+        FillShadingProperties* shading = new FillShadingProperties();                      
+        poly.setShading(shading);
+    };
+   
+void  PolyShadingMethod::visit(LegendVisitor& legend, const ColourTechnique& colour) {
+        
+        MagLog::dev() << "Create legend information"  << "\n";
+       
+        std::adjacent_find(colour.begin(), colour.end(), LegendEntryBuilder(legend, this, colour));
+     
+        legend.last(); // Flag the last entry as being the last! To get a nice labelling in countinuous mode!!!
+        
+    }
+
+int PolyShadingMethod::index(double value)
+{
+
+	return indexes_.find(value, -1);
+}
+
+int PolyShadingMethod::rightIndex(double value)
+{
+	if ( same(value, first_) ) return 0;
+	if ( same(value, last_)  ) return -1;
+	return indexes_.find(value, -1);
+}
+
+int PolyShadingMethod::leftIndex(double value)
+{
+	if ( value < first_) return -1;
+	if ( same(value, first_) ) return -1;
+	if ( same(value, last_) )  return indexes_.size() -1;
+	return indexes_.find(value, -1) - 1;
+
+}
+void PolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechnique& colours)
+{
+
+	if (levels.empty() )return;
+
+
+	LevelSelection::const_iterator from = levels.begin();
+	LevelSelection::const_iterator level = levels.begin();
+	level++;
+
+	first_ = levels.front();
+	last_ =  levels.back();
+
+	int index = 0;
+	for (  ;  level != levels.end(); ++level) {
+		indexes_.insert(make_pair(Interval(*from, *level), index));
+		colours_.push_back(colours.right(*from));
+		from++;
+		index++;
+
+
+	}
+
+}
+
+
+
+void DotPolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechnique& colours)
+{
+	if (levels.empty() )return;
+
+	float step = (max_density_ - min_density_)/(levels.size() - 1);
+	first_ = levels.front();
+	last_ =  levels.back();
+	LevelSelection::const_iterator from = levels.begin();
+	LevelSelection::const_iterator level = levels.begin();
+	level++;
+	float density = min_density_;
+	int index = 0;
+	for (  ;  level != levels.end(); ++level) {
+
+		indexes_.insert(make_pair(Interval(*from, *level), index));
+		colours_.push_back(colours.right(*from));
+		dots_.push_back(density);
+		from++;
+		index++;
+		density+=step;
+
+	}
+
+}
+
+
+void  DotPolyShadingMethod::operator()(Polyline& poly) const {
+    DotShadingProperties* shading = new DotShadingProperties();
+
+
+    int index = poly.index();
+
+
+
+
+    shading->size_ = size_;
+    shading->angle_ = angle_;
+    shading->density_ =  dots_[index];
+
+    poly.setFilled(true);
+    poly.setFillColour(colours_[index]);
+	poly.setStroke(false);
+    poly.setShading(shading);
+    //MagLog::dev() << "Attach DotShading Information" << *shading << "\n";
+}
+
+
+
+void HatchPolyShadingMethod::prepare(const LevelSelection& levels, const ColourTechnique& colours) {
+   	int index = 1;
+   	if (index_ >= 7 || index_ <0) {
+   		MagLog::warning() << "index should be < 7--> reset to 1 "<< endl;
+   		index_ = 1 ;
+   	}
+   	LevelSelection::const_iterator from = levels.begin();
+   	LevelSelection::const_iterator level = levels.begin();
+   	first_ = levels.front();
+	last_ =  levels.back();
+   	level++;
+   	int i = 0;
+   	for (  ;  level != levels.end(); ++level) {
+   		cout << *from << " << " <<  colours(*from).name() << "   " << i << "  " << index << " << " <<  *level << endl;
+   		indexes_.insert(make_pair(Interval(*from, *level), i));
+		colours_.push_back(colours.right(*from));
+   		hatches_.push_back((index_) ? index_ : index);
+   		index++;
+   		i++;
+   		from++;
+   		if ( index == 7 ) index = 1;
+   	}
+
+
+
+   }
+
+void HatchPolyShadingMethod::operator()(Polyline& poly) const
+{
+       int index = poly.index();
+
+       HatchShadingProperties* shading = new HatchShadingProperties();
+       shading->index_     = hatches_[index];
+
+       shading->density_   = density_;
+       shading->thickness_ = thickness_;
+       poly.setFilled(true);
+       poly.setFillColour(colours_[index]);
+       poly.setStroke(false);
+       poly.setShading(shading);
+
+}
+
+
diff --git a/src/visualisers/PolyShadingMethod.h b/src/visualisers/PolyShadingMethod.h
new file mode 100644
index 0000000..b2e6968
--- /dev/null
+++ b/src/visualisers/PolyShadingMethod.h
@@ -0,0 +1,108 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PolyShadingMethod.h
+    \brief Definition of the Template class PolyShadingMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef PolyShadingMethod_H
+#define PolyShadingMethod_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "Polyline.h"
+#include "ColourTechnique.h"
+#include "LegendVisitor.h"
+namespace magics {
+
+class LevelSelection;
+class PolyShadingMethod {
+
+public:
+	PolyShadingMethod() {}
+	virtual ~PolyShadingMethod() {}    
+	virtual void set(const map<string, string>&) {}
+	virtual void set(const XmlNode&) {}
+	virtual bool accept(const string& node) { return magCompare(node, "area_fill"); }
+	
+	virtual void toxml(ostream&) {}
+	virtual PolyShadingMethod* clone() const
+	{
+		PolyShadingMethod* object = new PolyShadingMethod();
+		return object;
+	}
+
+	virtual bool shadingMode() { return true; }
+	virtual int index(double);
+	virtual int rightIndex(double);
+	virtual int leftIndex(double);
+	virtual void prepare(const LevelSelection&, const ColourTechnique&);
+
+    virtual void operator()(Polyline& poly) const;
+
+    virtual void visit(LegendVisitor& legend, const ColourTechnique& colour);
+    IntervalMap<int> indexes_;
+    vector<Colour> colours_;
+    double first_;
+    double last_;
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	PolyShadingMethod(const PolyShadingMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	PolyShadingMethod& operator=(const PolyShadingMethod&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const PolyShadingMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+template <>
+class MagTranslator<string, PolyShadingMethod > {
+public:
+	PolyShadingMethod* operator()(const string& val ) {
+		 return SimpleObjectMaker<PolyShadingMethod >::create(val);
+	}     
+    PolyShadingMethod* magics(const string& param)
+    {
+        PolyShadingMethod* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/PolyShadingTechnique.cc b/src/visualisers/PolyShadingTechnique.cc
new file mode 100644
index 0000000..53a06fc
--- /dev/null
+++ b/src/visualisers/PolyShadingTechnique.cc
@@ -0,0 +1,70 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PolyShadingMethod.h
+    \brief Definition of the Template class PolyShadingMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+
+#include "PolyShadingTechnique.h"
+#include "IsoPlot.h"
+
+using namespace magics;
+
+CellArray* PolyShadingTechnique::array(MatrixHandler& matrix, IntervalMap<int>& range,
+  	    		const Transformation& transformation, int width, int height,
+  	    		float resolution, const string& technique)
+{
+
+	return new CellArray(matrix, range, transformation, width, height, resolution, technique);
+
+}
+void GridShading::visit(LegendVisitor& legend, const ColourTechnique& colour)
+{
+	MagLog::dev() << "Create legend information"  << "\n";
+
+	std::adjacent_find(colour.begin(), colour.end(), LegendEntryBuilder(legend, colour));
+
+	legend.last(); // Flag the last entry as being the last! To get a nice labelling in cotinuous mode!!!
+
+
+}
+CellArray* GridShading::array(MatrixHandler& matrix, IntervalMap<int>& range,
+		const Transformation& transformation, int width, int height,
+		float resolution, const string& technique)
+{
+	return new GridArray(matrix, range, transformation, width, height, resolution, position_);
+
+}
+void GridShading::operator()(Polyline* poly) const
+{
+	int index = poly->index();
+
+	        poly->setStroke(false);
+	        poly->setFilled(true);
+	        poly->setFillColour(method_->colours_[index]);
+	        FillShadingProperties* shading = new FillShadingProperties();
+	        poly->setShading(shading);
+}
diff --git a/src/visualisers/PolyShadingTechnique.h b/src/visualisers/PolyShadingTechnique.h
new file mode 100644
index 0000000..82d2fb0
--- /dev/null
+++ b/src/visualisers/PolyShadingTechnique.h
@@ -0,0 +1,171 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file PolyShadingTechnique.h
+    \brief Definition of the Template class PolyShadingTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef PolyShadingTechnique_H
+#define PolyShadingTechnique_H
+
+#include "magics.h"
+
+#include "ShadingTechnique.h"
+#include "PolyShadingTechniqueAttributes.h"
+#include "ColourTechnique.h"
+#include "DotPolyShadingMethod.h"
+#include "HatchPolyShadingMethod.h"
+#include "GridShadingAttributes.h"
+
+
+namespace magics {
+    
+class LevelSelection;
+
+
+class PolyShadingTechnique: public ShadingTechnique, public PolyShadingTechniqueAttributes {
+
+public:
+	PolyShadingTechnique() { }
+	virtual ~PolyShadingTechnique() {}
+    
+    void set(const map<string, string>& map) { PolyShadingTechniqueAttributes::set(map); }
+    void set(const XmlNode& node) { PolyShadingTechniqueAttributes::set(node); }
+    bool accept(const string& node) { return PolyShadingTechniqueAttributes::accept(node); }
+   
+    virtual ShadingTechnique* clone() const { return new PolyShadingTechnique(); }
+    
+    bool shadingMode() { return true; }
+    bool hasLegend() { return true; } // Isolien legend is not needed!
+    void operator()(Polyline* poly) const {
+    	 (*this->method_)(*poly);
+    }
+
+    void visit(LegendVisitor& legend, const ColourTechnique& colour) {
+        (*this->method_).visit(legend, colour); 
+    }   
+    
+    int index(double value) { return method_->index(value); }
+    int rightIndex(double value) { return method_->rightIndex(value); }
+    int leftIndex(double value) { return method_->leftIndex(value); }
+
+    virtual bool prepare(const LevelSelection& levels, const ColourTechnique& colours) {
+        method_->prepare(levels, colours);
+        // True if the shading technique needs the isolines to be calculated... 
+        return true; 
+    }   
+    virtual CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+    	    		const Transformation& transformation, int width, int height,
+    	    		float resolution, const string& technique);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+     
+     
+private:
+    //! Copy constructor - No copy allowed
+	PolyShadingTechnique(const PolyShadingTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	PolyShadingTechnique& operator=(const PolyShadingTechnique&);
+
+
+
+};
+
+class GridShading: public PolyShadingTechnique, public GridShadingAttributes {
+
+public:
+	GridShading() { }
+	virtual ~GridShading() {}
+
+    void set(const map<string, string>& map) {GridShadingAttributes::set(map); }
+    void set(const XmlNode& node) { GridShadingAttributes::set(node); }
+    bool accept(const string& node) { return GridShadingAttributes::accept(node); }
+
+    ShadingTechnique* clone() const { return new GridShading(); }
+    void operator()(Polyline* poly, const ColourTechnique& technique) const {
+   	 poly->setFilled(true);
+     poly->setStroke(false);
+     FillShadingProperties* shading = new FillShadingProperties();
+     poly->setShading(shading);
+   }
+   void operator()(Polyline* poly) const;
+    void visit(LegendVisitor& legend, const ColourTechnique& colour);
+    CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+    	    		const Transformation& transformation, int width, int height,
+    	    		float resolution, const string& technique);
+    virtual bool needClipping() { return true; }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 void print(ostream&) const {}
+
+
+private:
+    //! Copy constructor - No copy allowed
+	 GridShading(const GridShading&);
+    //! Overloaded << operator to copy - No copy allowed
+	 GridShading& operator=(const GridShading&);
+
+
+
+};
+struct LegendEntryBuilder
+{
+    LegendEntryBuilder(LegendVisitor& legend, const PolyShadingMethod* method,
+    	const ColourTechnique& colours) :
+    	legend_(legend), method_(method), colours_(colours)  {};
+    LegendEntryBuilder(LegendVisitor& legend,
+    	    	const ColourTechnique& colours) :
+    	    	legend_(legend), method_(0), colours_(colours)  {};
+    ~LegendEntryBuilder() {};
+    bool operator()(const pair<double, ColourInfo>& first, const pair<double, ColourInfo>& second) {
+        Polyline* box = new Polyline();
+
+        box->index_ = first.second.index_;
+        double min = first.second.level_;
+        double max = second.second.level_;
+
+        if( method_ )
+        	(*method_)(*box);
+        else
+        	box->setShading(new FillShadingProperties());
+        box->setFillColour(colours_.right(min));
+        box->setFilled(true);
+        box->setStroke(true);
+        box->setColour(Colour("black"));
+        legend_.add(new BoxEntry(min, max, box));
+        return false;
+
+    }
+    LegendVisitor& legend_;
+    const PolyShadingMethod* method_;
+    const ColourTechnique& colours_;
+};
+} // namespace magics
+
+
+
+#endif
diff --git a/src/visualisers/PolyShadingTechniqueAttributes.cc b/src/visualisers/PolyShadingTechniqueAttributes.cc
new file mode 100644
index 0000000..bfc90f0
--- /dev/null
+++ b/src/visualisers/PolyShadingTechniqueAttributes.cc
@@ -0,0 +1,117 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file PolyShadingTechniqueAttributes.cc
+    \brief Implementation of PolyShadingTechnique Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:14 2012
+*/    
+
+#include "PolyShadingTechniqueAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+PolyShadingTechniqueAttributes::PolyShadingTechniqueAttributes():
+	method_(MagTranslator<string, PolyShadingMethod>().magics("contour_shade_method"))
+{
+} 
+
+
+
+PolyShadingTechniqueAttributes::~PolyShadingTechniqueAttributes()
+{
+}
+
+    
+void PolyShadingTechniqueAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(5);
+	prefix[0] = "contour_shade";
+	prefix[1] = "contour_shade";
+	prefix[2] = "contour_shade";
+	prefix[3] = "contour";
+	prefix[4] = "contour";
+
+	setMember(prefix, "contour_shade_method", method_, params);
+}
+
+void PolyShadingTechniqueAttributes::copy(const PolyShadingTechniqueAttributes& other)
+{
+	method_ = auto_ptr<PolyShadingMethod>(other.method_->clone());
+} 
+
+
+bool PolyShadingTechniqueAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "polygon")  )
+		return true;
+
+	if ( acceptNode(node, method_) )
+		return true;
+	return false;
+}
+
+void PolyShadingTechniqueAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "polygon") )
+		set(node.attributes());
+	else {
+		setMember(node.name(), method_, node);
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+		setMember((*elt)->name(), method_, *(*elt)); 
+	}
+}
+
+void PolyShadingTechniqueAttributes::print(ostream& out)  const
+{
+	out << "PolyShadingTechniqueAttributes[";
+	out << "method = " << *method_;
+	out << "]" << "\n";
+}
+
+
+void PolyShadingTechniqueAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"polygon\"";
+	 out << ", \"contour_shade_method\":";
+	 method_->toxml(out);
+}
+static MagicsParameter<string> contour_shade_method("contour_shade_method", "dot", "");
+#include "HatchPolyShadingMethod.h"
+#include "DotPolyShadingMethod.h"
+#include "PolyShadingMethod.h"
+static SimpleObjectMaker<PolyShadingMethod, PolyShadingMethod> area_fill_PolyShadingMethod("area_fill");
+static SimpleObjectMaker<DotPolyShadingMethod, PolyShadingMethod> dot_DotPolyShadingMethod("dot");
+static SimpleObjectMaker<HatchPolyShadingMethod, PolyShadingMethod> hatch_HatchPolyShadingMethod("hatch");
diff --git a/src/visualisers/PolyShadingTechniqueAttributes.h b/src/visualisers/PolyShadingTechniqueAttributes.h
new file mode 100644
index 0000000..d31086e
--- /dev/null
+++ b/src/visualisers/PolyShadingTechniqueAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file PolyShadingTechniqueAttributes.h
+    \brief Definition of PolyShadingTechnique Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef PolyShadingTechniqueAttributes_H
+#define PolyShadingTechniqueAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "PolyShadingMethod.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class PolyShadingTechniqueAttributes 
+{
+public:
+//  --  constructor
+    PolyShadingTechniqueAttributes();
+    
+//  --  destructor
+    virtual ~PolyShadingTechniqueAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const PolyShadingTechniqueAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	auto_ptr<PolyShadingMethod> method_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const PolyShadingTechniqueAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/SampleContourMethodAttributes.h b/src/visualisers/SampleContourMethodAttributes.h
new file mode 100644
index 0000000..98e590a
--- /dev/null
+++ b/src/visualisers/SampleContourMethodAttributes.h
@@ -0,0 +1,82 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file SampleContourMethodAttributes.h
+    \brief Definition of SampleContourMethod Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef SampleContourMethodAttributes_H
+#define SampleContourMethodAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class SampleContourMethodAttributes 
+{
+public:
+//  --  constructor
+    SampleContourMethodAttributes();
+    
+//  --  destructor
+    virtual ~SampleContourMethodAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const SampleContourMethodAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	int x_;
+	int y_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const SampleContourMethodAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/SegmentJoiner.cc b/src/visualisers/SegmentJoiner.cc
new file mode 100644
index 0000000..9579116
--- /dev/null
+++ b/src/visualisers/SegmentJoiner.cc
@@ -0,0 +1,623 @@
+/*
+ * (C) Copyright 1996-2012 ECMWF.
+ *
+ * This software is licensed under the terms of the Apache Licence Version 2.0
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+ * In applying this licence, ECMWF does not waive the privileges and immunities
+ * granted to it by virtue of its status as an intergovernmental organisation nor
+ * does it submit to any jurisdiction.
+ */
+
+#include "SegmentJoiner.h"
+
+#include "marsmachine.h"
+#include "Timer.h"
+#include "MagExceptions.h"
+#include <cmath>
+#include <limits>
+
+#define CHECK_COLINEAR
+#define ONE_PASS
+#define xxxPROBE 8
+
+typedef uint64_t hash_t;
+
+class Hasher {
+
+    static const hash_t MIN_BITS = 8; // 256 entryes
+    static const hash_t MAX_BITS = 22; // 4194304 entries
+
+    hash_t bits_;
+    hash_t hashSize_;
+    hash_t hashMask_;
+
+    double sfx_;
+    double rvx_;
+    double sfy_;
+    double rvy_;
+
+public:
+
+    Hasher(const SegmentJoiner::SegList& v)
+    {
+
+
+        double minx =  numeric_limits<double>::infinity();
+        double maxx = -numeric_limits<double>::infinity();
+        double miny =  numeric_limits<double>::infinity();
+        double maxy = -numeric_limits<double>::infinity();
+
+        hash_t count = v.size();
+
+        // Compute "best" hash size
+        bits_= MIN_BITS;
+        hashSize_ = (1<<bits_);
+
+        // Size of the hash table
+        
+        while(hashSize_ <= count && bits_ < MAX_BITS) {
+            bits_ += 2;
+            hashSize_ = (1<<bits_);
+        }
+        hashMask_ = hashSize_-1;
+
+
+#ifdef PROBE
+        int miss = 0;
+        // Compute min/max coordinates
+        for(SegmentJoiner::SegList::const_iterator i = v.begin(); i != v.end(); ++i)
+        {
+            const Segment& s = (*i);
+            double x = s.from_.x_;
+            double y = s.from_.y_;
+            if(x > maxx) { maxx = x; miss = 0; }
+            if(x < minx) { minx = x;miss = 0; }
+
+            if(y > maxy)  { maxy = y;miss = 0; }
+            if(y < miny)  { miny = y;miss = 0; }
+
+            x = s.to_.x_;
+            y = s.to_.y_;
+            if(x > maxx)  { maxx = x;miss = 0; }
+            if(x < minx) { minx = x;miss = 0; }
+
+            if(y > maxy) { maxy = y;miss = 0; }
+            if(y < miny) { miny = y;miss = 0; }
+
+            if(miss++ > PROBE) break;
+        }
+
+        miss = 0;
+        // Compute min/max coordinates
+        for(SegmentJoiner::SegList::const_reverse_iterator i = v.rbegin(); i != v.rend(); ++i)
+        {
+            const Segment& s = (*i);
+            double x = s.from_.x_;
+            double y = s.from_.y_;
+            if(x > maxx) { maxx = x; miss = 0; }
+            if(x < minx) { minx = x;miss = 0; }
+
+            if(y > maxy)  { maxy = y;miss = 0; }
+            if(y < miny)  { miny = y;miss = 0; }
+
+            x = s.to_.x_;
+            y = s.to_.y_;
+            if(x > maxx)  { maxx = x;miss = 0; }
+            if(x < minx) { minx = x;miss = 0; }
+
+            if(y > maxy) { maxy = y;miss = 0; }
+            if(y < miny) { miny = y;miss = 0; }
+
+            if(miss++ > PROBE) break;
+        }
+#else
+        // Compute min/max coordinates
+        for(SegmentJoiner::SegList::const_iterator i = v.begin(); i != v.end(); ++i)
+        {
+            const Segment& s = (*i);
+            double x = s.from_.x_;
+            double y = s.from_.y_;
+            if(x > maxx) maxx = x;
+            if(x < minx) minx = x;
+
+            if(y > maxy) maxy = y;
+            if(y < miny) miny = y;
+
+            x = s.to_.x_;
+            y = s.to_.y_;
+            if(x > maxx) maxx = x;
+            if(x < minx) minx = x;
+
+            if(y > maxy) maxy = y;
+            if(y < miny) miny = y;
+        }
+#endif
+        bits_ /= 2;
+
+        // Compute scale factor/reference values
+        sfx_ = 1;
+        rvx_ = 0;
+        if(minx != maxx) {
+            sfx_ = double((1<<(bits_))-1) / (maxx - minx);
+            rvx_ = -minx;
+        }
+
+        sfy_ = 1;
+        rvy_ = 0;
+        if(miny != maxy) {
+            sfy_ = double((1<<(bits_))-1) / (maxy - miny);
+            rvy_ = -miny;
+        }
+
+    }
+
+    hash_t operator()(const Point& p) const {
+        return (((hash_t)((p.x_ + rvx_) * sfx_) << (bits_)) | ((hash_t)((p.y_ + rvy_) * sfy_))) & hashMask_;
+    }
+
+    hash_t hashSize() const {
+        return hashSize_;
+    }
+
+};
+
+static Segment* ok( vector<Segment*>& v) {
+    for(vector<Segment*>::iterator j = v.begin(); j != v.end(); ++j)
+        if((*j)->ok_)
+            return *j;
+    return 0;
+}
+
+static void fill_after(Segment* s, deque<Segment>& p)
+{
+    while( s)
+    {
+        if(!s->ok_) break;
+        s->ok_ = false;
+#ifdef CHECK_COLINEAR
+
+        if(!p.empty() && s->colinear(p.back()))
+        {
+            p.back().to_ = s->to_;
+        }
+        else
+#endif
+        {
+            p.push_back(*s);
+        }
+        s = ok(s->after_);
+    }
+}
+
+static void fill_before(Segment* s, deque<Segment>& p)
+{
+    while(s)
+    {
+        if(!s->ok_) break;
+        s->ok_ = false;
+#ifdef CHECK_COLINEAR
+        if(!p.empty() && s->colinear(p.front()))
+        {
+            p.front().from_ = s->from_;
+        }
+        else
+#endif
+        {
+            p.push_front(*s);
+        }
+        s = ok(s->before_);
+    }
+}
+
+static double compute(SegmentJoiner::SegList& v,list<deque<Segment> >& lines)
+{
+    //magics::Timer total("SegmentJoiner:: compute", "");
+
+    hash_t count = v.size();
+
+
+    Hasher hash(v);
+
+    hash_t  hashSize = hash.hashSize();
+
+    vector<Segment*> fromHash(hashSize, 0);
+    vector<Segment*> toHash(hashSize, 0);
+
+
+    vector<hash_t> H; H.reserve(hashSize);
+
+
+    {
+        // Compute the hash value of every points
+
+        //magics::Timer timer("SegmentJoiner:: hashing points", "");
+
+        for(SegmentJoiner::SegList::iterator i = v.begin(); i != v.end(); ++i)
+        {
+            Segment& s = (*i);
+            hash_t hf = s.fhash_ = hash(s.from_);
+            hash_t ht = s.thash_ = hash(s.to_);
+            s.fnext_ = fromHash[hf];
+            s.tnext_ = toHash[ht];
+
+          // if(fromHash[hf] == 0) { H.push_back(hf); }
+            fromHash[hf] = toHash[ht] = &s;
+        }
+    }
+
+    // << "HASH " << hashSize << " H " << H.size() << " " << double(H.size()) / double(hashSize)*100.0 << "%, avg= " << double(v.size())/double(H.size()) << endl;
+
+    {
+
+
+        int n = 0;
+
+        for(hash_t h = 0; h < hashSize; h++)
+           // for(vector<hash_t>::const_iterator j = H.begin(); j != H.end(); ++j)
+        {
+           // hash_t h = (*j);
+            Segment* from  = fromHash[h];
+            Segment* fprev = 0;
+
+            while(from)
+            {
+                Segment& s1 = *from;
+
+                if(s1.ok_) {
+                    Segment* tprev = 0;
+                    Segment* to    = toHash[h];
+
+                    while(to)
+                    {
+                        Segment& s2 = *to;
+
+                        if(s2.ok_)
+                        {
+#ifdef ONE_PASS
+                            if(s1.from_ == s2.to_)
+                            {
+                                if(s1.to_ == s2.from_) {
+                                    s1.ok_ = s2.ok_ = false;
+                                    if(tprev) { tprev->tnext_ = s2.tnext_; } else { toHash[h] = s2.tnext_; }
+                                    if(fprev) { fprev->fnext_ = s1.fnext_; } else { fromHash[h] = s1.fnext_; }
+                                    n++;
+                                }
+
+                                else
+                                {
+
+                                	s1.before_.push_back(to);
+                                	s2.after_.push_back(from);
+                                }
+
+                            }
+#else
+                            if(s1.cancels(s2)) {
+                                s1.ok_ = s2.ok_ = false;
+                                if(tprev) { tprev->tnext_ = s2.tnext_; } else { toHash[h] = s2.tnext_; }
+                                if(fprev) { fprev->fnext_ = s1.fnext_; } else { fromHash[h] = s1.fnext_; }
+                                n++;
+                            }
+#endif
+                        }
+                        else {
+                            if(tprev) { tprev->tnext_ = s2.tnext_; } else { toHash[h] = s2.tnext_; }
+                        }
+
+                        if(s2.ok_) {
+                            tprev = to;
+                        }
+                        to = s2.tnext_;
+                    }
+                }
+                else
+                {
+                    if(fprev) { fprev->fnext_ = s1.fnext_; } else { fromHash[h] = s1.fnext_; }
+                }
+
+                if(s1.ok_) {
+                    fprev = from;
+                }
+                from  = s1.fnext_;
+            }
+        }
+
+        //cout << "Segments  input=" << count << ", canceled=" << n << " => left=" << (count-n) << endl;
+    }
+#ifndef ONE_PASS
+    {
+
+
+        for(hash_t h = 0; h < hashSize; h++)
+        {
+            Segment* from = fromHash[h];
+
+            while(from)
+            {
+                Segment& s1 = *from;
+                if(s1.ok_)
+                {
+                    //                ASSERT(s1.ok_);
+
+                    Segment* to   = toHash[h];
+
+                    while(to)
+                    {
+                        Segment& s2 = *to;
+                        //                   ASSERT(s2.ok_);
+                        if(s2.ok_) {
+                            if(s1.from_ == s2.to_) {
+                                //ASSERT(!(s1.before_ && !s2.after_) || (s1.before_ && s2.after_));
+
+                                //if(!s1.before_ && !s2.after_)
+                                {
+                                    s1.before_.push_back(to);
+                                    s2.after_ .push_back(from);
+                                }
+                                break;
+
+                            }
+                        }
+                        to = s2.tnext_;
+                    }
+                }
+                from = s1.fnext_;
+            }
+        }
+    }
+#endif
+    {
+        //magics::Timer timer("SegmentJoiner:: join all connecting lines", "");
+
+        bool again = true;
+
+        for(SegmentJoiner::SegList::iterator i = v.begin(); i != v.end(); ++i)
+        {
+            Segment& s = (*i);
+            if(s.ok_) {
+                s.ok_ = false;
+                lines.push_back(deque<Segment>(1,s));
+                deque<Segment>& p = lines.back();
+                fill_before(ok(s.before_),p);
+                fill_after(ok(s.after_),p);
+
+                again = true;
+
+                while(again)
+                {
+                    again = false;
+
+                    Segment& s1 = p.back();
+                    size_t h = s1.thash_;
+                    Segment* from = fromHash[h];
+
+                    while(from)
+                    {
+                        Segment& s2 = *from;
+                        if(s2.ok_) {
+                            if(s2.from_ == s1.to_) {
+                                fill_after(from,p);
+                                again = true;
+                                break;
+                            }
+                        }
+                        from = s2.fnext_;
+                    }
+                }
+
+                again = true;
+
+                while(again)
+                {
+                    again = false;
+
+                    Segment& s1 = p.front();
+                    size_t h = s1.fhash_;
+                    Segment* to   = toHash[h];
+
+                    while(to)
+                    {
+                        Segment& s2 = *to;
+                        if(s2.ok_) {
+                            if(s2.to_ == s1.from_) {
+                                fill_before(to,p);
+                                again = true;
+                                break;
+                            }
+                        }
+                        to = s2.tnext_;
+                    }
+                }
+            }
+        }
+    }
+
+#ifdef CHECK_COLINEAR
+
+    // A bit of tidying up
+
+    for(list<deque<Segment> >::iterator k = lines.begin(); k != lines.end(); ++k)
+    {
+        deque<Segment>& p = (*k);
+        if(p.size() >= 2) {
+            Segment& f = p.front();
+            Segment& b = p.back();
+
+            if(f.from_ == b.to_)
+            {
+                if(f.colinear(b))
+                {
+                    b.to_ = f.to_;
+                    p.pop_front();
+                }
+            }
+        }
+    }
+#endif
+    // For debugging
+    //if(true) check(lines);
+
+    //return total.elapsed();
+    return 0;
+}
+
+
+double SegmentJoiner::computeSegmentLines(list<deque<Segment> >& result)
+{
+    if(dirty_) {
+        // In case the algo is ran again, the segments internal states need resetting
+        dirty_ = false;
+        for(SegmentJoiner::SegList::iterator j = segments_.begin(); j != segments_.end(); ++j) {
+            Segment& s = (*j);
+            s.ok_ = true;
+            s.before_.clear();
+            s.after_.clear();
+            s.fnext_ = s.tnext_ = 0;
+        }
+    }
+
+    result.clear(); // Just in case
+    double e = compute(segments_,result);
+    dirty_ = true; // The segements need reseting
+    return e;
+}
+
+double SegmentJoiner::computePolygonLines(vector<vector<Point> >& result)
+{
+    result.clear(); // Just in case
+    list<deque<Segment> > lines;
+
+    double e = computeSegmentLines(lines);
+
+    // magics::Timer timer("SegmentJoiner:: from segments to polygones", "");
+    result.resize(lines.size());
+
+
+    size_t i = 0;
+    for(list<deque<Segment> >::iterator k = lines.begin(); k != lines.end(); ++k, ++i)
+    {
+
+        deque<Segment>& p = (*k);
+        vector<Point>& w = result[i];
+        w.reserve(p.size()+1);
+
+        deque<Segment>::iterator j = p.begin();
+        // For the segement point, we add both points
+        w.push_back((*j).from_);
+        w.push_back((*j).to_);
+        ++j;
+
+        for(; j != p.end(); ++j) {
+            w.push_back((*j).to_);
+        }
+    }
+    return e;
+}
+
+double SegmentJoiner::area(const vector<Point> & poly)
+{
+    double area = 0;
+
+    for(int i = 0; i < poly.size()-1; i++)
+    {
+        area += (poly[i].x_*poly[i+1].y_) -  (poly[i+1].x_*poly[i].y_) ;
+    }
+
+    return area / 2.0;
+}
+
+
+
+bool SegmentJoiner::pointInPoly(const Point &p, const vector<Point> &poly) {
+    // Ray casting algo
+	int n = 0;
+	    int j = poly.size() - 1;
+	    for(int i = 0; i < poly.size(); i++) {
+	        if( (poly[i].y_ > p.y_) != (poly[j].y_ > p.y_) )
+	            if( p.x_ < (poly[j].x_ - poly[i].x_) * (p.y_ - poly[i].y_) / ( poly[j].y_ - poly[i].y_) + poly[i].x_)
+	            {
+	                n++;
+	            }
+	        j = i;
+	    }
+	    return (n%2 == 1);
+}
+
+double SegmentJoiner::punchHoles(vector<vector<Point> > &result) {
+    vector<vector<Point> > polys;
+    list<vector<Point> > holes;
+    for(vector<vector<Point> >::iterator j = result.begin() ; j != result.end(); ++j) {
+        if(!isHole((*j))) {
+            holes.push_back(vector<Point>());
+            std::swap((*j),holes.back());
+        }
+        else {
+            polys.push_back(vector<Point>());
+            std::swap((*j),polys.back());
+        }
+    }
+
+    for(vector<vector<Point> >::iterator j = polys.begin() ; j != polys.end(); ++j) {
+        for(list<vector<Point> >::iterator h = holes.begin() ; h != holes.end(); ) {
+            list<vector<Point> >::iterator next = h; next++;
+            if(pointInPoly((*h).front(), *j)) {
+                // If there are more holes, you need to choose different points
+                Point& p = (*j).back();
+
+                (*j).insert((*j).end(), (*h).rbegin(), (*h).rend());
+                (*j).push_back(p);
+
+                holes.erase(h);
+            }
+            h = next;
+        }
+    }
+
+    std::swap(polys,result);
+}
+
+//=================================================================================================
+// Below is just for debugging
+
+void SegmentJoiner::check(list<deque<Segment> >& lines)
+{
+
+    for(list<deque<Segment> >::iterator k = lines.begin(); k != lines.end(); ++k) {
+        deque<Segment>& p = (*k);
+        ASSERT(p.size());
+        deque<Segment>::iterator j = p.begin();
+        deque<Segment>::iterator i = j;
+        ++j;
+        for(; j != p.end(); ++j) {
+            ASSERT((*i).to_ == (*j).from_);
+            i = j;
+        }
+    }
+
+
+    for(list<deque<Segment> >::iterator j = lines.begin();  j != lines.end(); ++j)
+    {
+        deque<Segment>& p = (*j);
+
+        for(list<deque<Segment> >::iterator k = lines.begin(); k != lines.end(); ++k)
+        {
+            deque<Segment>& q = (*k);
+            if(k != j) {
+                ASSERT(!(p.back().to_ == q.front().from_));
+                ASSERT(!(q.back().to_ == p.front().from_));
+
+            }
+        }
+    }
+
+    int n =0;
+
+    for(list<deque<Segment> >::iterator k = lines.begin(); k != lines.end(); ++k) {
+        deque<Segment>& p = (*k);
+        n += p.size();
+    }
+
+
+}
+
+
diff --git a/src/visualisers/SegmentJoiner.h b/src/visualisers/SegmentJoiner.h
new file mode 100644
index 0000000..a361e65
--- /dev/null
+++ b/src/visualisers/SegmentJoiner.h
@@ -0,0 +1,155 @@
+/*
+ * (C) Copyright 1996-2012 ECMWF.
+ *
+ * This software is licensed under the terms of the Apache Licence Version 2.0
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+ * In applying this licence, ECMWF does not waive the privileges and immunities
+ * granted to it by virtue of its status as an intergovernmental organisation nor
+ * does it submit to any jurisdiction.
+ */
+
+// File Segmenter.h
+// Baudouin Raoult - ECMWF Aug 02
+
+#ifndef SegmentJoiner_H
+#define SegmentJoiner_H
+
+#include "marsmachine.h"
+#include "MagExceptions.h"
+#include <cmath>
+
+
+struct Point {
+    double x_;
+    double y_;
+
+    Point(double x = 0, double y = 0):
+        x_(x), y_(y)
+    {
+    }
+
+    friend bool operator ==(const Point& a,const Point& b)
+    {
+        return (a.x_ == b.x_) && (a.y_ == b.y_);
+    }
+
+    friend ostream& operator <<(ostream& s,const Point& p)
+    {
+        return s << "(" << p.x_ << "," << p.y_ << ")";
+    }
+};
+
+
+
+struct Segment {
+    bool ok_;
+    Point from_;
+    Point to_;
+
+    unsigned long phash_;
+
+    vector<Segment*> before_; // Index of segment before in polyline
+    vector<Segment*> after_;//  Index of segment after in polyline
+
+    Segment* fnext_; // Next is the "from" hash table, in case of collisions
+    Segment* tnext_; // Next is the "to" hash table, in case of collisions
+
+    unsigned long fhash_; // Hash value of the "from_" point
+    unsigned long thash_; // Hash value of the "to_" point
+
+
+    Segment(const Point& from, const Point& to):
+        ok_(true), from_(from), to_(to),  before_(0), after_(0), fnext_(0), tnext_(0){}
+
+    bool cancels(const Segment& other) const
+    { return from_ == other.to_ && to_ == other.from_; }
+
+    friend ostream& operator <<(ostream& s,const Segment& p)
+    { return s << "[from=" << p.from_ << ",to=" << p.to_ << "]"; }
+
+
+    double crossProduct(const Segment& other) const
+    {
+        double  ux = to_.x_ - from_.x_;
+        double  uy = to_.y_ - from_.y_;
+        double  vx = other.to_.x_ - other.from_.x_;
+        double  vy = other.to_.y_ - other.from_.y_;
+        return ux*vy-uy*vx;
+    }
+
+    bool colinear(const Segment& other) const
+    {
+        return fabs(crossProduct(other)) < 1e-10;
+    }
+};
+
+inline void reserve_(vector<Segment>& v,size_t s) { v.reserve(s); }
+inline void reserve_(list<Segment>& v,size_t s) {  }
+inline void reserve_(deque<Segment>& v,size_t s) {  }
+
+class SegmentJoiner {
+public:
+
+    typedef deque<Segment> SegList;
+
+    // -- Contructors
+
+    SegmentJoiner(): dirty_(false) {}
+
+    // -- Destructor
+
+    ~SegmentJoiner() {}
+
+    // -- Methods
+
+    void reserve(size_t size)
+    {
+        reserve_(segments_,size);
+    }
+
+
+    size_t size() const
+    { return segments_.size(); }
+
+    void push_back(const Segment& s)
+    {
+        if(!(s.from_ == s.to_))
+            segments_.push_back(s);
+    }
+
+    void push_back(const Point& from, const Point& to)
+    { segments_.push_back(Segment(from,to)); }
+
+    void push_back(double x1, double y1, double x2, double y2)
+    { segments_.push_back(Segment(Point(x1,y1),Point(x2,y2))); }
+
+    // Call this one...
+    double computePolygonLines(vector<vector<Point> >& result);
+
+    double computeSegmentLines(list<deque<Segment> >& result);
+
+    double punchHoles(vector<vector<Point> >& result);
+
+
+    static double area(const vector<Point>& );
+    static bool isHole(const vector<Point>& p) { return area(p) < 0; }
+
+    static bool pointInPoly(const Point&,const vector<Point>& p);
+    static void check(list<deque<Segment> >& lines);
+
+private:
+
+    // No copy allowed
+
+    SegmentJoiner(const SegmentJoiner&);
+    SegmentJoiner& operator=(const SegmentJoiner&);
+
+    // -- Members
+
+    SegList segments_;
+    bool dirty_;
+
+
+};
+
+#endif
diff --git a/src/visualisers/ShadingTechnique.h b/src/visualisers/ShadingTechnique.h
new file mode 100644
index 0000000..a2afd85
--- /dev/null
+++ b/src/visualisers/ShadingTechnique.h
@@ -0,0 +1,111 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ShadingTechnique.h
+    \brief Definition of the Template class ShadingTechnique.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 18-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ShadingTechnique_H
+#define ShadingTechnique_H
+
+#include "magics.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "ColourTechnique.h"
+
+
+namespace magics {
+
+class LevelSelection;
+class BasicGraphicsObject;
+class MatrixHandler;
+class Data;
+class BasicGraphicsObjectContainer;
+class Polyline;
+class CellArray;
+class Transformation;
+
+class ShadingTechnique  {
+
+
+public:
+	ShadingTechnique() {}
+	virtual ~ShadingTechnique() {}
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual bool accept(const string&) { return false; }
+    void toxml(ostream&)  const {}
+    virtual ShadingTechnique* clone() const { return 0; }
+    virtual bool more() { return false; }
+    virtual bool shadingMode() { return false; }
+    virtual bool hasLegend() { return false; }
+    virtual BasicGraphicsObject* next() { return 0; }
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&) {}
+	virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&) {}
+    virtual void operator()(Polyline*) const {};
+    virtual bool prepare(const LevelSelection&, const ColourTechnique&)  { return false; }   
+    virtual void visit(LegendVisitor&, const ColourTechnique&) {}   
+    virtual int index(double) {}
+    virtual int leftIndex(double) {}
+    virtual int rightIndex(double) {}
+    virtual CellArray* array(MatrixHandler& matrix, IntervalMap<int>& range,
+       		const Transformation& transformation, int width, int height,
+       		float resolution, const string& technique) { assert(0); }
+    virtual bool needClipping() { return false; }
+   
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const {}
+
+private:
+    //! Copy constructor - No copy allowed
+	ShadingTechnique(const ShadingTechnique&);
+    //! Overloaded << operator to copy - No copy allowed
+	ShadingTechnique& operator=(const ShadingTechnique&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ShadingTechnique& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, ShadingTechnique > {
+public:
+	ShadingTechnique* operator()(const string& val ) {
+		 return SimpleObjectMaker<ShadingTechnique >::create(val);
+	}     
+    ShadingTechnique* magics(const string& param)
+    {
+        ShadingTechnique* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/SimplePolylineVisualiser.cc b/src/visualisers/SimplePolylineVisualiser.cc
new file mode 100644
index 0000000..0c03552
--- /dev/null
+++ b/src/visualisers/SimplePolylineVisualiser.cc
@@ -0,0 +1,114 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file BoxPlotVisualiser.cc
+    \brief Implementation of the Template class BoxPlotVisualiser.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#include "SimplePolylineVisualiser.h"
+#include "PointsHandler.h"
+#include "Polyline.h"
+#include "LegendVisitor.h"
+#include "Data.h"
+
+
+using namespace magics;
+
+    
+SimplePolylineVisualiser::SimplePolylineVisualiser() 
+{}
+
+SimplePolylineVisualiser::~SimplePolylineVisualiser() 
+{}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void SimplePolylineVisualiser::print(ostream& out)  const
+{
+	out << "SimplePolylineVisualiser[";
+	out << "]";
+}
+
+
+void SimplePolylineVisualiser::operator()(Data& data, BasicGraphicsObjectContainer& parent)
+{
+   levelSelection_->set(*this);
+  
+   PointsHandler& points = data.points(parent.transformation(), true);
+   points.setToFirst();
+   
+   Polyline* line = 0;
+   levelSelection_->calculate(points.min(), points.max(), false);
+   
+   if (shade_) {
+   		colourMethod_->set(*this);
+   		colourMethod_->prepare(*levelSelection_);
+   }
+   const Transformation& transformation = parent.transformation();
+   
+   while ( points.more() )
+   {
+        if ( points.current().missing()  || line == 0 )
+	{
+            if ( line )  
+            	parent.transformation()(*line, parent);
+            line = new Polyline();
+            line->setColour(*colour_);
+            line->setLineStyle(style_);
+            line->setThickness(thickness_);
+            line->setFilled(shade_);            
+	}
+	if (!points.current().missing() )
+	{
+		line->push_back(transformation(points.current()));
+		if ( shade_ && points.current().value() >= min_ && points.current().value() <= max_) {
+			
+			line->setFillColour(colourMethod_->colour(points.current().value()));
+			FillShadingProperties* shading = new FillShadingProperties();    
+			line->setShading(shading);
+		}
+		else 
+			line->setFilled(false);
+	}
+	points.advance();
+   }
+   
+   if ( !line ) {
+	   MagLog::warning() << "Could not find lines to plot " << endl;
+	   return;
+   }
+
+   if ( !line->empty() )
+	   parent.transformation()(*line, parent);
+}
+
+
+void SimplePolylineVisualiser::visit(Data&, LegendVisitor& legend)
+{
+    if ( !legend_) return;
+	if ( shade_ ) 
+		colourMethod_->visit(legend);   
+}
diff --git a/src/visualisers/SimplePolylineVisualiser.h b/src/visualisers/SimplePolylineVisualiser.h
new file mode 100644
index 0000000..91935d0
--- /dev/null
+++ b/src/visualisers/SimplePolylineVisualiser.h
@@ -0,0 +1,99 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SimplePolylineVisualiser.h
+    \brief Definition of the Template class SimplePolylineVisualiser.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 5-May-2004
+    
+    Changes:
+    
+*/
+
+#ifndef SimplePolylineVisualiser_H
+#define SimplePolylineVisualiser_H
+#include "magics.h"
+
+
+#include "SimplePolylineAttributes.h"
+
+
+#include "magics.h"
+#include "UserPoint.h"
+#include "Visdef.h"
+#include "Data.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+class SimplePolylineVisualiser: public SimplePolylineAttributes, public Visdef {
+
+
+
+public:
+	SimplePolylineVisualiser();
+	virtual ~SimplePolylineVisualiser();
+    
+   
+    
+	void operator()(Data&, BasicGraphicsObjectContainer&);
+	void visit(Data&, LegendVisitor&);
+	bool needLegend() { return legend_; }
+    int getCount() const  { return count_; }
+    int getTolerance() const { return tolerance_; }
+    double getReference() const { return reference_; }
+    double getInterval() const  { return interval_; }
+    doublearray getList() const{ return list_; };
+    double getMin() const { return min_; }
+    double getMax() const{ return max_; }
+    
+    const Colour&  getMinColour() const { return *minColour_; }
+    const Colour&  getMaxColour() const { return *maxColour_; }
+    const string& getDirection() const{ return direction_; }
+     stringarray getColours() const { return colours_; }
+
+    // Implements the set method ... 
+    void set(const map<string, string>& map ) { SimplePolylineAttributes::set(map); }
+    void set(const XmlNode& node) { SimplePolylineAttributes::set(node); }
+    
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+ 
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	SimplePolylineVisualiser(const SimplePolylineVisualiser&);
+    //! Overloaded << operator to copy - No copy allowed
+	SimplePolylineVisualiser& operator=(const SimplePolylineVisualiser&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SimplePolylineVisualiser& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/SymbolAdvancedTableMode.cc b/src/visualisers/SymbolAdvancedTableMode.cc
new file mode 100644
index 0000000..a551788
--- /dev/null
+++ b/src/visualisers/SymbolAdvancedTableMode.cc
@@ -0,0 +1,311 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolAdvancedTableMode.h
+    \brief Implementation of the Template class SymbolAdvancedTableMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 21-Jan-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "SymbolAdvancedTableMode.h"
+#include "UserPoint.h"
+#include "Symbol.h"
+#include "SymbolPlotting.h"
+#include "LegendVisitor.h"
+#include "Histogram.h"
+#include "HistoVisitor.h"
+#include "CartesianTransformation.h"
+using namespace magics;
+
+map<string,  SymbolAdvancedTableMode::TextHandler> SymbolAdvancedTableMode::textHandlers_;
+
+SymbolAdvancedTableMode::SymbolAdvancedTableMode() 
+{
+	/*
+	if ( textHandlers_.empty() ) {
+		textHandlers_["none"] = &SymbolAdvancedTableMode::none;
+		textHandlers_["centre"] = &SymbolAdvancedTableMode::centre;
+		textHandlers_["top"] = &SymbolAdvancedTableMode::top;
+		textHandlers_["bottom"] = &SymbolAdvancedTableMode::bottom;
+		textHandlers_["right"] = &SymbolAdvancedTableMode::right;
+	}
+	*/
+}
+
+SymbolAdvancedTableMode::~SymbolAdvancedTableMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SymbolAdvancedTableMode::print(ostream& out)  const
+{
+    out << "SymbolAdvancedTableMode[";
+    SymbolAdvancedTableModeAttributes::print(out);
+    out << "]";
+}
+
+
+
+SymbolProperties SymbolAdvancedTableMode::operator()(double value) const 
+{	
+    return map_.find(value, SymbolProperties());   
+}
+
+
+
+bool SymbolAdvancedTableMode::accept(double value) const 
+{ 
+	return map_.accept(value);
+}
+
+
+
+void SymbolAdvancedTableMode::prepare()
+{
+  
+    
+    
+
+} 
+
+void SymbolAdvancedTableMode::adjust(double min, double max)
+{
+	static map<string, TextSymbol::TextPosition> texthandlers;
+	if ( texthandlers.empty() ) {
+		texthandlers["none"] = TextSymbol::M_NONE;
+		texthandlers["left"] = TextSymbol::M_LEFT;
+		texthandlers["top"] = TextSymbol::M_ABOVE;
+		texthandlers["bottom"] = TextSymbol::M_BELOW;
+		texthandlers["right"] = TextSymbol::M_RIGHT;
+	}
+	map_.clear();
+	MagLog::dev() << "Data going from " << min << " to " << max << endl;
+	levels_->set(*this);
+	
+	
+	
+	levels_->calculate(min, max, false);
+	if (levels_->size() == 1) {
+			levels_->push_back(levels_->front());
+	}
+	colourMethod_->set(*this);
+	height_method_->set(*this);
+	colourMethod_->prepare(*levels_);
+	height_method_->prepare(*levels_);
+	
+	if ( markers_.empty() ) {
+		markers_.push_back(15);
+	}
+	
+	TextSymbol::TextPosition position;
+	
+	
+	
+	if ( text_list_.empty() ) {
+		position = TextSymbol::M_NONE;
+		text_list_.push_back("");
+	}
+	else {
+		string type = lowerCase(text_display_type_);
+		map<string, TextSymbol::TextPosition>::iterator pos = texthandlers.find(type);
+		position = ( pos != texthandlers.end()) ? pos->second : TextSymbol::M_NONE;
+	}
+	
+	MagFont font(text_font_name_);
+	font.colour(*text_font_colour_);
+	font.size(text_font_size_);
+	font.style(text_font_style_);
+	
+
+	
+    LevelSelection::const_iterator level = levels_->begin();
+    vector<int>::const_iterator marker = markers_.begin();
+    SymbolProperties last;
+    vector<string>::const_iterator text = text_list_.begin();
+    while ( true) {
+    	if (level+1 == levels_->end() ) break;
+    	MagLog::debug() << "[" << *level << ", " << *(level+1) << "]=" << *marker << "(marker)" << *text << "(text)"<< endl;
+    	SymbolProperties properties(colourMethod_->right(*level), height_method_->height(*level),  *marker, *text);
+    	properties.position_ = position;
+    	properties.font_ = font;
+
+    	properties.outline_ = parent_->outline_;
+    	properties.outlineColour_ = *parent_->outline_colour_;
+    	properties.outlineStyle_ = parent_->outline_style_;
+    	properties.outlineThickness_ = parent_->outline_thickness_;
+
+    	properties.connectLine_ = parent_->connect_;
+    	properties.connectLineColour_ = (parent_->automatic_connect_colour_ ) ? colourMethod_->right(*level) : *parent_->connect_colour_;
+    	properties.connectLineStyle_ = parent_->connect_style_;
+    	properties.connectLineThickness_ = parent_->connect_thickness_;
+    	last = properties;
+    	map_[Interval(*level, *(level+1)) ] = properties;
+    	
+    	if ( marker+1 == markers_.end() ) {
+    		if ( marker_policy_ == M_CYCLE )
+                marker =  markers_.begin(); 
+    	}
+    	else 
+    		marker++;
+    	if ( text+1 == text_list_.end() ) {
+    	    	if ( text_policy_ == M_CYCLE )
+    	                text =  text_list_.begin(); 
+    	    	}
+    	    	else 
+    	    		text++;
+    	level++;
+    }
+    // Here we add a last interval to close to the right the lst Interval.
+
+    MagLog::debug() << "[" << *level << ", " << (*level)+epsilon << "]=" <<colourMethod_->right(*level) << *marker << "(marker)" << *text << "(text)"<< endl;
+    map_[Interval(*level, (*level)+epsilon) ] = last;
+
+}
+
+void build(const IntervalMap<SymbolProperties>& in, IntervalMap<Colour>& out)
+{
+	// Here we want to get the last interval ;
+
+
+
+	for ( IntervalMap<SymbolProperties>::const_iterator interval = in.begin(); interval != in.end(); ++interval)
+		out.insert(make_pair(Interval(interval->first.min_, interval->first.max_), interval->second.colour_));
+
+}
+
+
+void SymbolAdvancedTableMode::visit(Data& data, LegendVisitor& legend)
+{
+	legend.newLegend();
+	IntervalMap<SymbolProperties>::const_iterator last = map_.end();
+		    				--last;
+	IntervalMap<SymbolProperties>::reverse_iterator first = map_.rbegin();
+		    						    				++first;;
+	    	switch (legend.legendType())  {
+	    		case LegendMethod::CONTINUOUS:
+	    		{
+
+	    	    for ( IntervalMap<SymbolProperties>::const_iterator interval = map_.begin(); interval != last; ++interval) {
+	    			Polyline* box = new Polyline();
+	    	        
+	    	        double min =interval->first.min_;
+	    	        double max = interval->first.max_;
+	    	        
+	    	        box->setShading(new FillShadingProperties());
+	    	        
+	    	        box->setFillColour(interval->second.colour_);
+	    	        box->setFilled(true);
+	    	        
+	    	        legend.add(new BoxEntry(min, max, box));
+	    	    }
+	    	        break;
+	    		}
+	    		case LegendMethod::DISJOINT:
+	    		{
+	    			  for ( IntervalMap<SymbolProperties>::reverse_iterator interval = first; interval != map_.rend(); ++interval) {
+	    				Symbol* symbol = new Symbol();
+	    				(*symbol).setColour(interval->second.colour_);
+	    				(*symbol).setSymbol(interval->second.marker_);
+	    				(*symbol).setHeight(interval->second.height_);
+				
+					string str=data.legendText(interval->first.min_,interval->first.max_);
+					if(str.empty())
+					{				  	
+	    					ostringstream text;
+	    					text << interval->first.min_ << "-" <<  interval->first.max_;
+		        			str=text.str();
+					}	
+					legend.add(new SimpleSymbolEntry(interval->second.label_.empty() ? str : interval->second.label_, symbol));
+	    			}
+		        	break;
+	    		}
+	    		case LegendMethod::HISTOGRAM:
+	    		{
+	    			IntervalMap<Colour> beans;
+	    			build(map_, beans);
+	    			Histogram helper;
+	    			// here we need the transformation.. to know wich points where displayed!
+	    			IntervalMap<int>& histogram = helper.histogram(beans, data.points(legend.transformation(), false));
+	    			double mean = helper.mean();
+
+	    			int maxh = 0;
+	    			for (IntervalMap<int>::const_iterator  interval = histogram.begin(); interval != histogram.end(); ++interval){
+	    				if ( maxh < interval->second ) maxh = interval->second;
+	    			}
+	    			bool first = true;
+	    			for ( IntervalMap<SymbolProperties>::const_iterator interval = map_.begin(); interval != last; ++interval) {
+	    				   Polyline* box = new Polyline();
+
+	    				   double min =interval->first.min_;
+	    				   double max = interval->first.max_;
+
+	    				   box->setShading(new FillShadingProperties());
+	    				   box->setFillColour(interval->second.colour_);
+	    				   box->setFilled(true);
+	    				   BoxEntry* entry = new BoxEntry(min, max, box);
+	    				   int count = histogram.find(min, -1);
+	    				   // here we have to add the last interval!
+	    				   if ( max == levels_->back() ) {
+
+	    					   count +=  histogram.find(max, 0);
+	    				   }
+	    				   entry->population(count);
+	    				   entry->totalPopulation(maxh);
+	    				   if ( min <= mean && mean <= max ) {
+	    					   entry->mean(mean);
+
+	    				   }
+	    				   if (first) {
+	    					   entry->first();
+	    					   first = false;
+	    				   }
+
+
+	    				   legend.add(entry);
+
+	    			}
+	    			break;
+
+	    		}
+	    	
+	    }
+	    legend.last();
+}
+
+
+
+
+void SymbolAdvancedTableMode::visit(Data& data, HistoVisitor& visitor)
+{
+	IntervalMap<Colour> beans;
+	if ( !visitor.basic() ) // Why did we put this possibility???
+		build(map_, beans);
+	Histogram helper;
+	helper.visit(beans, data, data.points(*visitor.dataLayoutTransformation(), false), visitor);
+}
+
+
diff --git a/src/visualisers/SymbolAdvancedTableMode.h b/src/visualisers/SymbolAdvancedTableMode.h
new file mode 100644
index 0000000..9e9a02d
--- /dev/null
+++ b/src/visualisers/SymbolAdvancedTableMode.h
@@ -0,0 +1,141 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolAdvancedTableMode.cc
+    \brief Definition of the Template class SymbolAdvancedTableMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 21-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef SymbolAdvancedTableMode_H
+#define SymbolAdvancedTableMode_H
+
+#include "magics.h"
+
+#include "SymbolMode.h"
+#include "SymbolAdvancedTableModeAttributes.h"
+#include "IntervalMap.h"
+
+namespace magics {
+
+
+class SymbolAdvancedTableMode: 
+	public SymbolMode, 
+	public SymbolAdvancedTableModeAttributes,
+	public LevelSelectionInterface,
+	public ColourTechniqueInterface,
+	public HeightTechniqueInterface,
+	public OutLayerTechniqueInterface
+{
+
+public:
+	SymbolAdvancedTableMode();
+	virtual ~SymbolAdvancedTableMode();
+    virtual void prepare();
+    
+    bool accept(double) const;
+    SymbolProperties operator()(double) const;
+
+    void visit(Data&, LegendVisitor&);
+    void visit(Data&, HistoVisitor&);
+
+
+    void set(const map<string, string>& map ) { 
+        SymbolAdvancedTableModeAttributes::set(map); 
+        SymbolMode::set(map);
+        prepare();
+    }
+    void set(const XmlNode& node ) { 
+        SymbolAdvancedTableModeAttributes::set(node);
+        SymbolMode::set(node);
+        prepare();
+    }
+    
+
+    virtual bool accept(const string& node) {
+    		return SymbolAdvancedTableModeAttributes::accept(node);    
+    	}
+    	
+    	virtual SymbolMode* clone() const {
+    		SymbolAdvancedTableMode* object = new SymbolAdvancedTableMode();
+    		object->copy(*this);
+    		return object;
+    	}
+    	virtual void adjust(double , double );
+    
+    	 void copy(const SymbolAdvancedTableMode& other) {
+    		 SymbolAdvancedTableModeAttributes::copy(other);
+    		 SymbolModeAttributes::copy(other);
+    	 }
+        
+ 
+
+
+       
+
+        
+       
+        int getCount() const { return count_; }
+        int getTolerance() const { return tolerance_; }
+        double getReference() const { return reference_; }
+        double getInterval() const { return interval_; }
+        double getMin() const { return min_; }
+        double getMax() const { return max_; }
+        const Colour& getMinColour() const { return *minColour_; }
+        const Colour& getMaxColour() const { return *maxColour_; }
+        const string& getDirection() const { return direction_; }
+        stringarray getColours()  const { return colours_; }
+        floatarray getList()  const { return list_; }
+        double getMinHeight() const { return height_min_; }
+        double getMaxHeight() const { return height_max_; }
+        floatarray getHeights()  const { return heights_; }
+        ListPolicy getHeightPolicy() const { return height_policy_; }
+        int getLevels()  const { return nbLevels_; }
+        float getMinOutlayer() const { return outlayer_min_; }
+        float getMaxOutlayer() const { return outlayer_max_; }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     IntervalMap<SymbolProperties>  map_;
+     int nbLevels_;
+    
+    
+     typedef  bool (SymbolAdvancedTableMode::*TextHandler)(const string&, const SymbolProperties&, vector<Text* >& text) const;   
+     static map<string,  TextHandler> textHandlers_;
+     
+private:
+    //! Copy constructor - No copy allowed
+	SymbolAdvancedTableMode(const SymbolAdvancedTableMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	SymbolAdvancedTableMode& operator=(const SymbolAdvancedTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolAdvancedTableMode& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/SymbolIndividualModeAttributes.h b/src/visualisers/SymbolIndividualModeAttributes.h
new file mode 100644
index 0000000..07604dd
--- /dev/null
+++ b/src/visualisers/SymbolIndividualModeAttributes.h
@@ -0,0 +1,98 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file SymbolIndividualModeAttributes.h
+    \brief Definition of SymbolIndividualMode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef SymbolIndividualModeAttributes_H
+#define SymbolIndividualModeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+#include "Colour.h"
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class SymbolIndividualModeAttributes 
+{
+public:
+//  --  constructor
+    SymbolIndividualModeAttributes();
+    
+//  --  destructor
+    virtual ~SymbolIndividualModeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const SymbolIndividualModeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	string legend_text_;
+	string marker_mode_;
+	int marker_;
+	string symbol_;
+	auto_ptr<Colour> colour_;
+	double height_;
+	string image_path_;
+	string image_format_;
+	double image_width_;
+	double image_height_;
+	stringarray text_;
+	string text_position_;
+	string text_font_name_;
+	double text_font_size_;
+	string text_font_style_;
+	auto_ptr<Colour> text_font_colour_;
+	bool text_blanking_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const SymbolIndividualModeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/SymbolMode.cc b/src/visualisers/SymbolMode.cc
new file mode 100644
index 0000000..7010b3d
--- /dev/null
+++ b/src/visualisers/SymbolMode.cc
@@ -0,0 +1,397 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolMode.cc
+    \brief Implementation of the Template class SymbolMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 21-Jan-2004
+    
+    Changes:
+    
+*/
+
+
+
+#include "SymbolMode.h"
+#include "LegendVisitor.h"
+#include "CartesianTransformation.h"
+#include "Histogram.h"
+#include "HistoVisitor.h"
+#include "SymbolPlotting.h"
+
+using namespace magics;
+
+
+SymbolMode::SymbolMode() 
+{
+}
+
+
+SymbolMode::~SymbolMode() 
+{
+}
+void SymbolMode::visit(Data& data, HistoVisitor& visitor)
+{
+
+	IntervalMap<Colour> beans;
+	Histogram helper;
+	helper.visit(beans, data, data.points(*visitor.dataLayoutTransformation(), false), visitor);
+}
+
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SymbolMode::print(ostream& out)  const
+{
+	out << "SymbolMode";
+}
+
+SymbolIndividualMode::SymbolIndividualMode() 
+{
+  
+
+}
+
+
+
+SymbolIndividualMode::~SymbolIndividualMode() 
+{
+}
+
+void SymbolIndividualMode::update()
+{
+
+	if ( magCompare(marker_mode_, "index" ) ) {
+		ostringstream symbol;
+		symbol << "magics_" << marker_;
+		symbol_ = symbol.str();
+	}
+
+    current_ = text_.begin();
+
+    
+}
+
+void SymbolIndividualMode::properties() const
+{
+	static map<string, TextSymbol::TextPosition> texthandlers;
+	if ( texthandlers.empty() ) {
+		texthandlers["none"] = TextSymbol::M_NONE;
+		texthandlers["left"] = TextSymbol::M_LEFT;
+		texthandlers["top"] = TextSymbol::M_ABOVE;
+		texthandlers["bottom"] = TextSymbol::M_BELOW;
+		texthandlers["right"] = TextSymbol::M_RIGHT;
+		texthandlers["centre"] = TextSymbol::M_CENTRE;
+	}
+	TextSymbol::TextPosition position;
+	if ( magCompare(type_, "number")) {
+		position = TextSymbol::M_NONE;
+		properties_.colour_ = *colour_;
+	    properties_.height_ = height_;
+	}
+
+	else {
+		string type = lowerCase(text_position_);
+		map<string, TextSymbol::TextPosition>::iterator pos = texthandlers.find(type);
+		position = ( pos != texthandlers.end()) ? pos->second : TextSymbol::M_ABOVE;
+		if ( magCompare(type_, "text")  ) {
+			properties_.height_ = 0.01; // make a very small symbol
+			properties_.colour_ = Colour("none");
+		}
+		else {
+			properties_.colour_ = *colour_;
+			properties_.height_ = height_;
+		}
+	}
+	if ( magCompare(marker_mode_, "image" ) ) {
+		properties_.image_ = true;
+		properties_.image_path_ = image_path_;
+		properties_.image_width_ = image_width_;
+		properties_.image_height_ = image_height_;
+		properties_.image_format_ = image_format_;
+
+	}
+
+    properties_.outline_ = parent_->outline_;
+    properties_.outlineColour_ = *parent_->outline_colour_;
+    properties_.outlineStyle_ = parent_->outline_style_;
+    properties_.outlineThickness_ = parent_->outline_thickness_;
+
+    properties_.connectLine_ = parent_->connect_;
+    properties_.connectLineColour_ = (parent_->automatic_connect_colour_) ? *colour_ : *parent_->connect_colour_;
+    properties_.connectLineStyle_ = parent_->connect_style_;
+    properties_.connectLineThickness_ = parent_->connect_thickness_;
+
+    if ( current_ != text_.end() ) {
+    	properties_.label(*current_);
+    	++current_;
+    	if (current_ == text_.end() )
+    		current_ = text_.begin();
+    }
+
+    MagFont font(text_font_name_);
+    font.colour(text_font_colour_->automatic() ? *colour_ : *text_font_colour_);
+    font.size(text_font_size_);
+    font.style(text_font_style_);
+    properties_.font_ = font;
+    properties_.blanking_ = text_blanking_;
+    properties_.position_ = position;
+    properties_.setSymbol(symbol_, 0);
+
+    properties_.text_ = text_;
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SymbolIndividualMode::print(ostream& out)  const
+{
+    out << "SymbolIndividualMode[";
+    SymbolIndividualModeAttributes::print(out);
+    out << "]";
+}
+
+
+
+
+
+
+SymbolTableMode::SymbolTableMode() 
+{
+   
+}
+
+
+SymbolTableMode::~SymbolTableMode() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void SymbolTableMode::print(ostream& out)  const
+{
+    out << "SymbolTableMode[";
+    SymbolTableModeAttributes::print(out);
+    out << "]";
+}
+
+
+
+SymbolProperties SymbolTableMode::operator()(double value) const 
+{
+	return map_.find(value, SymbolProperties());
+    
+    
+}
+
+void SymbolTableMode::prepare()
+{
+	if ( colour_.empty()) {
+		MagLog::warning() << "SymbolTableMode: No colour table defined.\n";
+		colour_.push_back("red");
+	}
+	if ( height_.empty()) {
+		MagLog::warning() << "SymbolTableMode: No height table defined.\n";
+		height_.push_back(0.2);
+	}
+	if ( !marker_.empty()) {
+		symbol_.clear();
+		for (vector<int>::const_iterator marker = marker_.begin(); marker != marker_.end(); ++marker) 
+			symbol_.push_back(Symbol::convert(*marker));
+	}
+	
+	if ( symbol_.empty()) {
+		MagLog::warning() << "SymbolTableMode: No marker table defined.\n";
+		symbol_.push_back("magics_1");
+	}
+    doublearray::iterator max = max_.begin();
+    stringarray::iterator colour = colour_.begin();
+    doublearray::iterator height = height_.begin();
+    stringarray::iterator symbol = symbol_.begin();
+    
+    int index = 0;
+    
+  
+    
+    for (doublearray::const_iterator min = min_.begin(); min != min_.end(); ++min) {
+
+        map_[Interval(*min, *max) ] = SymbolProperties(Colour(*colour),  *height,  *symbol);
+        
+        if ( ++colour == colour_.end()) --colour;  
+        if ( ++height == height_.end())  --height;
+        if ( ++symbol == symbol_.end()) --symbol;
+//        label << *min << "-" << *max;
+//        map[index].label_ = label.str();
+     
+        if ( ++max == max_.end()) --max;
+        index++;
+    }
+} 
+
+bool  SymbolTableMode::accept(double value) 
+{
+	try {
+		map_.find(value);
+
+		return true;
+	}
+
+	catch (...) {
+		return false;
+	}
+}
+
+
+void SymbolTableMode::visit(LegendVisitor& legend)
+{
+    
+    IntervalMap<SymbolProperties>::const_iterator interval;
+    
+    for ( interval = map_.begin(); interval != map_.end(); ++interval) {
+	        Symbol* symbol = new Symbol();
+	        (*symbol).setColour(interval->second.colour_);
+	        (*symbol).setSymbol(interval->second.marker_);
+	        (*symbol).setHeight(interval->second.height_);
+	        legend.add(new SimpleSymbolEntry( interval->first.min_,  interval->first.max_, symbol));
+    }
+    legend.last();
+}
+
+void SymbolTableMode::visit(Data& data, HistoVisitor& visitor)
+{
+	IntervalMap<Colour> beans;
+	if ( !visitor.basic() ) 
+		buildBins(map_, beans);
+	Histogram helper;
+	helper.visit(beans, data, data.points(*visitor.dataLayoutTransformation(), false), visitor);
+
+}
+
+void SymbolTableMode::buildBins(const IntervalMap<SymbolProperties>& in, IntervalMap<Colour>& out)
+{
+	for ( IntervalMap<SymbolProperties>::const_iterator interval = in.begin(); interval != in.end(); ++interval)
+		out.insert(make_pair(Interval(interval->first.min_, interval->first.max_), interval->second.colour_));
+
+}
+
+void SymbolIndividualMode::visit(LegendVisitor& legend)
+{
+   
+	  Symbol* symbol = properties_.symbol("marker");
+      
+	  legend.add(new SimpleSymbolEntry(legend_text_, symbol));
+ 	
+}
+
+void SymbolIndividualMode::visit(Data& data, LegendVisitor& legend)
+{
+
+    Symbol* symbol = properties_.symbol("marker");
+    SimpleSymbolEntry *entry = new SimpleSymbolEntry(legend_text_, symbol);
+    entry->userText(legend_text_);
+    legend.add(entry);
+
+}
+void SymbolTableMode::visit(Data& data, LegendVisitor& legend)
+{
+		legend.newLegend();
+
+
+    	switch (legend.legendType())  {
+    		case LegendMethod::CONTINUOUS:
+    		{
+
+    	    for ( IntervalMap<SymbolProperties>::const_iterator interval = map_.begin(); interval != map_.end(); ++interval) {
+    			Polyline* box = new Polyline();
+
+    	        double min =interval->first.min_;
+    	        double max = interval->first.max_;
+
+    	        box->setShading(new FillShadingProperties());
+
+    	        box->setFillColour(interval->second.colour_);
+    	        box->setFilled(true);
+
+    	        legend.add(new BoxEntry(min, max, box));
+    	    }
+    	        break;
+    		}
+    		case LegendMethod::DISJOINT:
+    		{
+    			  for ( IntervalMap<SymbolProperties>::reverse_iterator interval = map_.rbegin(); interval != map_.rend(); ++interval) {
+    				Symbol* symbol = new Symbol();
+    				(*symbol).setColour(interval->second.colour_);
+    				(*symbol).setSymbol(interval->second.marker_);
+    				(*symbol).setHeight(interval->second.height_);
+
+				string str=data.legendText(interval->first.min_,interval->first.max_);
+				if(str.empty())
+				{
+    					ostringstream text;
+    					text << interval->first.min_ << "-" <<  interval->first.max_;
+	        			str=text.str();
+				}
+				legend.add(new SimpleSymbolEntry(interval->second.label_.empty() ? str : interval->second.label_, symbol));
+    			}
+	        	break;
+    		}
+    		case LegendMethod::HISTOGRAM:
+    		{
+    			IntervalMap<Colour> beans;
+    			buildBins(map_, beans);
+    			Histogram helper;
+    			// here we need the transformation.. to know wich points where displayed!
+    			IntervalMap<int>& histogram = helper.histogram(beans, data.points(legend.transformation(), false));
+
+    			int total = 0;
+    			for (IntervalMap<int>::const_iterator  interval = histogram.begin(); interval != histogram.end(); ++interval){
+    				total+=interval->second;
+    			}
+    			bool first = true;
+    			for ( IntervalMap<SymbolProperties>::const_iterator interval = map_.begin(); interval != map_.end(); ++interval) {
+    				   Polyline* box = new Polyline();
+
+    				   double min =interval->first.min_;
+    				   double max = interval->first.max_;
+
+    				   box->setShading(new FillShadingProperties());
+    				   box->setFillColour(interval->second.colour_);
+    				   box->setFilled(true);
+    				   BoxEntry* entry = new BoxEntry(min, max, box);
+    				   int count = histogram.find(min, -1);
+    				   entry->population(count);
+    				   entry->totalPopulation(total);
+    				   if (first) {
+    					   entry->first();
+    					   first = false;
+    				   }
+
+
+    				   legend.add(entry);
+
+    			}
+
+    		}
+
+    }
+    legend.last();
+    }
diff --git a/src/visualisers/SymbolMode.h b/src/visualisers/SymbolMode.h
new file mode 100644
index 0000000..d19a9ac
--- /dev/null
+++ b/src/visualisers/SymbolMode.h
@@ -0,0 +1,231 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolMode.h
+    \brief Definition of the Template class SymbolMode.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 21-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef SymbolMode_H
+#define SymbolMode_H
+
+#include "magics.h"
+
+#include "SymbolIndividualModeAttributes.h"
+#include "SymbolModeAttributes.h"
+#include "SymbolTableModeAttributes.h"
+
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "Colour.h"
+#include "IntervalMap.h"
+#include "Symbol.h"
+#include "UserPoint.h"
+#include "UserPoint.h"
+#include "Text.h"
+#include "Data.h"
+
+namespace magics {
+	
+class LegendVisitor;
+class HistoVisitor;
+class SymbolPlotting;
+
+
+class SymbolMode : public SymbolModeAttributes
+{
+
+public:
+	SymbolMode();
+	virtual ~SymbolMode();
+	
+	virtual SymbolMode* clone() const {
+		SymbolMode* object = new SymbolMode();
+		return object;
+	}
+   
+    virtual void set(const map<string, string>&) {}
+    virtual void set(const XmlNode&) {}
+    virtual bool accept(const string&) { return false; }
+    virtual void toxml(ostream&, int = 0) const {}
+    
+    virtual bool accept(double) { return true; }   
+    virtual void prepare() {}
+	virtual  SymbolProperties operator()(double) const { throw OutOfRangeMagException(); }
+	
+    void parent(SymbolPlotting* parent) { parent_ = parent; }
+
+    
+    virtual void visit(LegendVisitor&) {};
+    virtual void visit(Data&, LegendVisitor& legend) { visit(legend); }
+    virtual void visit(Data&, HistoVisitor&);
+
+	//virtual void adjust(double min, double max) {}
+	virtual void adjust(double , double ) {}
+	void set(const string& type) { type_ = type; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 SymbolPlotting* parent_;
+	 string type_;
+private:
+	//! Copy constructor - No copy allowed
+	SymbolMode(const SymbolMode&);
+	//! Overloaded << operator to copy - No copy allowed
+	SymbolMode& operator=(const SymbolMode&);
+
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolMode& p)
+		{ p.print(s); return s; }
+};
+
+class SymbolIndividualMode: public SymbolMode, public SymbolIndividualModeAttributes {
+
+public:
+	SymbolIndividualMode();
+	virtual ~SymbolIndividualMode();
+	virtual void set(const map<string, string>& map) {
+		SymbolMode::set(map);
+		SymbolIndividualModeAttributes::set(map);
+		update();
+		
+	}
+	virtual void set(const XmlNode& node) {
+		SymbolMode::set(node);
+		SymbolIndividualModeAttributes::set(node);
+		update();
+    
+	}
+
+	virtual bool accept(const string& node) {
+		return SymbolIndividualModeAttributes::accept(node);
+    
+	}
+	
+	virtual SymbolMode* clone() const {
+		SymbolIndividualMode* object = new SymbolIndividualMode();
+		//SymbolIndividualModeAttributes::copy(*this);
+		return object;
+	}
+   
+    
+    virtual void visit(LegendVisitor&);
+	void prepare() { update(); }
+    void update();
+    void properties() const;
+    SymbolProperties operator()(double) const {  properties(); return properties_; }
+    void visit(Data&, LegendVisitor&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     mutable SymbolProperties properties_;
+     mutable vector<string>::const_iterator current_;
+
+
+private:
+    //! Copy constructor - No copy allowed
+	SymbolIndividualMode(const SymbolIndividualMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	SymbolIndividualMode& operator=(const SymbolIndividualMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolIndividualMode& p)
+		{ p.print(s); return s; }
+
+};
+
+template<>
+class MagTranslator<string, SymbolMode> { 
+public:
+	SymbolMode* operator()(const string& val ) {
+		 return SimpleObjectMaker<SymbolMode>::create(val);
+	}
+   
+	SymbolMode* magics(const string& param)
+	{
+		SymbolMode* object;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+
+class SymbolTableMode: public SymbolMode, public SymbolTableModeAttributes {
+
+public:
+	SymbolTableMode();
+	virtual ~SymbolTableMode();
+    virtual void prepare();
+    virtual bool accept(double);
+    SymbolProperties operator()(double) const;
+
+    void set(const map<string, string>& map ) { 
+        SymbolTableModeAttributes::set(map);
+        SymbolMode::set(map);
+        prepare();
+    }
+    
+    virtual void set(const XmlNode& node) {
+		SymbolMode::set(node);
+		SymbolTableModeAttributes::set(node);
+		prepare();
+    
+	}
+    virtual bool accept(const string& node) {
+		return SymbolTableModeAttributes::accept(node);
+    
+	}
+    
+    void visit(LegendVisitor&); 
+    void visit(Data&, LegendVisitor&);
+    void visit(Data&, HistoVisitor&);
+    void buildBins(const IntervalMap<SymbolProperties>&, IntervalMap<Colour>&); 
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     IntervalMap<SymbolProperties>  map_;
+private:
+    //! Copy constructor - No copy allowed
+	SymbolTableMode(const SymbolTableMode&);
+    //! Overloaded << operator to copy - No copy allowed
+	SymbolTableMode& operator=(const SymbolTableMode&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolTableMode& p)
+		{ p.print(s); return s; }
+
+};
+
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/SymbolPlotting.cc b/src/visualisers/SymbolPlotting.cc
new file mode 100644
index 0000000..54e85bc
--- /dev/null
+++ b/src/visualisers/SymbolPlotting.cc
@@ -0,0 +1,209 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolPlotting.cc
+    \brief Implementation of the Template class SymbolPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 19-Jan-2004
+    
+    Changes:
+    
+*/
+
+#include "SymbolPlotting.h"
+#include "Factory.h"
+
+#include "ProgressObject.h"
+#include "MagicsFormat.h"
+
+using namespace magics;
+
+
+SymbolPlotting::SymbolPlotting()
+{
+}
+
+SymbolPlotting::~SymbolPlotting()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void SymbolPlotting::print(ostream& out)  const
+{
+	out << "SymbolPlotting[";
+	SymbolPlottingAttributes::print(out);
+	out << "]";
+}
+
+
+
+void SymbolPlotting::operator()(const PaperPoint& point, BasicGraphicsObjectContainer& out) const
+{
+	
+
+	try {
+    	
+    	if ( (*mode_).accept(point.value()) == false ) return;
+    	
+        SymbolProperties properties = (*mode_)(point.value());
+
+        string value;
+
+		if  ( magCompare(type_, "number") || magCompare(type_, "both")) {
+			ostringstream nice;
+			nice << MagicsFormat(format_, point.value());
+			value = nice.str();
+		}
+       
+       
+         map<SymbolProperties, Symbol* >::const_iterator symb = symbols_.find(properties);
+         if ( symb  != symbols_.end() )
+         {
+        	    symb->second->push_back(point, value);
+                return;
+         } 	
+        
+
+         Symbol* symbol = properties.symbol(type_);
+
+
+         symbols_[properties] = symbol;
+      
+         symbol->push_back(point, value);
+
+         
+         
+        	 
+         
+        
+    }
+    catch ( ... ) { }
+}
+
+struct Print
+{
+	void operator()(const UserPoint& point)
+	{ MagLog::debug() << point << "\n"; } 
+};
+
+
+struct SortHelper
+{
+	SortHelper() {}
+	~SortHelper() {}
+	MAGICS_NO_EXPORT bool operator()(const Symbol* first, const Symbol* second)
+	{
+ 		return first->size() > second->size();
+	}
+};
+
+
+
+void SymbolPlotting::operator()(Data& data, BasicGraphicsObjectContainer& out)
+{
+	mode_->parent(this);
+	mode_->prepare();
+    symbols_.clear();
+    vector<string> check;
+    check.push_back("text");
+    check.push_back("number");
+    check.push_back("marker");
+    check.push_back("both");
+
+    bool valid = false;
+
+    for ( vector<string>::iterator c = check.begin(); c != check.end(); ++c) {
+    	valid = magCompare(*c, type_);
+    	if ( valid)
+    		break;
+    }
+    if ( !valid ) {
+    	MagLog::warning() << type_ << " not yet implemented : reset to marker " << endl;
+    	type_ = "marker";
+    }
+    mode_->set(type_);
+
+
+    try {
+    	const Transformation& transformation = out.transformation();
+
+    	// If we need to connect the symbols with a line, we need all the poinst
+    	//to enable proper clipping of the line! Othewise wee just nedde to get the point
+    	// from the visible area.
+
+    	PointsHandler& points = data.points(transformation, connect_ );
+
+    	// Some Mode need to know the min and max of the data, in order to adjust the 
+    	// computation of the levels
+ 		(*mode_).adjust(points.min(), points.max());
+
+    	points.setToFirst();
+    	while (points.more()) {
+
+
+    			PaperPoint xy = transformation(points.current());
+    			(*this)(xy, out);
+
+
+    		points.advance();
+    	}
+
+	    // WE sort: send the longest one first!
+	    vector<Symbol* > work;
+	    for (map<SymbolProperties, Symbol* >::iterator symbol = symbols_.begin(); symbol != symbols_.end(); ++symbol)
+			work.push_back(symbol->second);
+	    
+	    std::sort(work.begin(), work.end(), SortHelper());
+	   
+	    // Now we feed the task...     
+	    for (vector<Symbol* >::iterator symbol = work.begin(); symbol != work.end(); ++symbol) {
+
+	     	if ( !(*symbol)->empty() ) {
+
+	     		(*symbol)->boundingbox(out.transformation().getPCBoundingBox());
+	     		out.push_back(*symbol);
+	     	}
+	    }
+	    
+	     for (vector<Text* >::iterator text = texts_.begin(); text != texts_.end(); ++text) {
+	     	out.push_back(*text);
+	    }
+    }
+    catch ( MagicsException& )
+    {
+    	// do nothing!  
+    }
+}
+
+void SymbolPlotting::visit(Data& data, LegendVisitor& legend)
+{
+	MagLog::debug() <<  " SymbolPlotting::visit to create a legend ... " << "\n";
+	if ( !legend_ ) return;
+	(*mode_).visit(data, legend);
+}
+
+void SymbolPlotting::visit(Data& data, HistoVisitor& histo)
+{
+	MagLog::debug() <<  " SymbolPlotting::visit to create a histogram! ... " << "\n";
+
+	mode_->visit(data, histo);
+}
diff --git a/src/visualisers/SymbolPlotting.h b/src/visualisers/SymbolPlotting.h
new file mode 100644
index 0000000..49f8028
--- /dev/null
+++ b/src/visualisers/SymbolPlotting.h
@@ -0,0 +1,91 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file SymbolPlotting.h
+    \brief Definition of the Template class SymbolPlotting.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Mon 19-Jan-2004
+    
+    Changes:
+    
+*/
+
+#ifndef SymbolPlotting_H
+#define SymbolPlotting_H
+
+#include "magics.h"
+
+#include "SymbolPlottingAttributes.h"
+#include "Visdef.h"
+#include "PointsHandler.h"
+#include "Symbol.h"
+
+namespace magics {
+
+class ProgressObject;
+
+
+class SymbolPlotting: public SymbolPlottingAttributes, public Visdef {
+
+public:
+	SymbolPlotting();
+	virtual ~SymbolPlotting();
+
+
+    // Implements the Visualiser Interface...
+   
+ 
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&);
+    virtual void visit(Data&, LegendVisitor&);
+    bool needLegend() { return legend_; }
+    virtual void visit(Data&, HistoVisitor&);
+    void operator()(const PaperPoint&, BasicGraphicsObjectContainer&) const; 
+    
+    
+    void set(const map<string, string>& map ) { SymbolPlottingAttributes::set(map); }
+    void set(const XmlNode& node ) { SymbolPlottingAttributes::set(node); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+     
+     mutable map<SymbolProperties, Symbol* >            symbols_;
+     map<SymbolProperties, Symbol* >::iterator current_;
+     mutable vector<Text* >                             texts_;
+     vector<string>::iterator text_;
+    
+
+private:
+    //! Copy constructor - No copy allowed
+	SymbolPlotting(const SymbolPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	SymbolPlotting& operator=(const SymbolPlotting&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const SymbolPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/SymbolTableModeAttributes.h b/src/visualisers/SymbolTableModeAttributes.h
new file mode 100644
index 0000000..e2ef866
--- /dev/null
+++ b/src/visualisers/SymbolTableModeAttributes.h
@@ -0,0 +1,86 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file SymbolTableModeAttributes.h
+    \brief Definition of SymbolTableMode Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: Wed Dec  5 12:07:14 2012
+*/
+   
+
+#ifndef SymbolTableModeAttributes_H
+#define SymbolTableModeAttributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+
+
+
+class SymbolTableModeAttributes 
+{
+public:
+//  --  constructor
+    SymbolTableModeAttributes();
+    
+//  --  destructor
+    virtual ~SymbolTableModeAttributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const SymbolTableModeAttributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+	floatarray min_;
+	floatarray max_;
+	intarray marker_;
+	stringarray symbol_;
+	stringarray colour_;
+	floatarray height_;
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const SymbolTableModeAttributes& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/TaylorGrid.cc b/src/visualisers/TaylorGrid.cc
new file mode 100644
index 0000000..00a7895
--- /dev/null
+++ b/src/visualisers/TaylorGrid.cc
@@ -0,0 +1,228 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expres  s or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TaylorGrid.cc
+    \brief Implementation of the Template class TaylorGrid.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 3-Oct-2006
+    
+    Changes:
+    
+*/
+
+
+
+#include "TaylorGrid.h"
+#include "Layout.h"
+#include "Polyline.h"
+#include "Text.h"
+#include "PaperPoint.h"
+#include "PaperPoint.h"
+#include"Transformation.h"
+#include "Layer.h"
+
+using namespace magics;
+
+TaylorGrid::TaylorGrid() 
+{
+}
+
+
+TaylorGrid::~TaylorGrid() 
+{
+}
+
+void TaylorGrid::list(double ref, double inc, std::set<double>& out) const {
+	Transformation& projection = transformation();
+	const double min = projection.getMinX();
+	const double max = projection.getMaxX();
+	
+	for (double val = ref; val <= max; val += inc ) 
+		out.insert(val);
+	for (double val = ref; val >= min; val -= inc ) 
+		out.insert(val);
+}
+
+void TaylorGrid::visit(DrawingVisitor& out)
+{
+	vector<double> labels;
+	labels.push_back(0.);
+	labels.push_back(0.1);
+	labels.push_back(0.2);
+	labels.push_back(0.3);
+	labels.push_back(0.4);
+	labels.push_back(0.5);
+	labels.push_back(0.6);
+	labels.push_back(0.7);
+	labels.push_back(0.8);
+	labels.push_back(0.9);
+	labels.push_back(0.95);
+	labels.push_back(0.99);
+
+	MagLog::dev() << "TaylorGrid::prepareGraphics()-->needs to be implemented! " <<  endl;
+	const Transformation& projection = out.transformation();
+	const double min = projection.getMinX();
+	const double max = projection.getMaxX();
+	
+	Polyline* horizontal = new Polyline();
+	horizontal->setThickness(primary_thickness_);
+	horizontal->setColour(*primary_colour_);
+	horizontal->push_back(projection(UserPoint(min,1)));
+	horizontal->push_back(projection(UserPoint(max,1)));
+	out.push_back(horizontal);
+
+	Polyline* vertical = new Polyline();
+	vertical->setThickness(primary_thickness_);
+	vertical->setColour(*primary_colour_);
+	vertical->push_back(projection(UserPoint(min,0)));
+	vertical->push_back(projection(UserPoint(max,0)));
+	
+	out.push_back(vertical);
+	
+	Polyline* border = new Polyline();	
+	border->setThickness(primary_thickness_);
+	border->setColour(*primary_colour_); 
+	for (double angle = 0.; angle <= 1.; angle += 0.01 ) { 
+		
+		border->push_back(projection(UserPoint(max, angle)));  
+	}
+	border->push_back(projection(UserPoint(max, 1)));
+	
+	std::set<double> values;
+	list(primary_reference_, primary_increment_, values);
+	
+	for (std::set<double>::iterator value = values.begin(); value != values.end(); ++value) {
+		Polyline* arc = new Polyline();
+		if (* value == primary_reference_ ) {
+			arc->setThickness(reference_thickness_);
+			arc->setColour(*reference_colour_); 
+			arc->setLineStyle(reference_style_); 
+		}
+		else {
+			arc->setThickness(primary_thickness_);
+			arc->setColour(*primary_colour_); 
+			arc->setLineStyle(primary_style_); 
+		}
+		for (double angle = 0.; angle <= 1.; angle += 0.01 ) {				 			
+			arc->push_back(projection(UserPoint(*value, angle)));	    
+		}
+		arc->push_back(projection(UserPoint(*value, 1)));
+		out.push_back(arc);
+	}
+	
+	for ( vector<double>::const_iterator angle = labels.begin(); angle != labels.end(); ++angle ) {				 
+		Polyline* line = new Polyline();
+		line->setLineStyle(primary_style_);
+		line->setThickness(primary_thickness_);
+		line->setColour(*primary_colour_);
+		
+		line->push_back(projection(UserPoint(max, *angle)));	
+		line->push_back(projection(UserPoint(min, 0)));	
+		out.push_back(line);
+		
+		if ( primary_label_ ) {
+		    Text* label = new Text();
+		    label->addText(*angle, *primary_label_colour_, primary_label_height_);
+		
+		    label->setAngle( (1.57-acos(*angle)));
+		  
+		    label->push_back(projection(UserPoint(max + 0.03, *angle)));	
+		    out.push_back(label);
+		}
+	   
+	}
+	if ( primary_label_ ) {
+		Text* label = new Text();
+		label->addText(label_,*label_colour_, label_height_ );
+		label->setAngle( 3.14/5.);   
+		label->push_back(projection(UserPoint(max + 0.08, 0.6 )));
+		out.push_back(label);
+	}
+	out.push_back(border);
+	if ( secondary_grid_ ) secondary(out);
+}
+
+void TaylorGrid::secondary(DrawingVisitor&  out)
+{	
+	std::set<double> values;
+	Transformation& projection = transformation();
+//	double min = projection.getMinX();
+//	double max = projection.getMaxX();
+	list(secondary_reference_, secondary_increment_, values);
+    
+	for(std::set<double>::iterator value = values.begin(); value != values.end(); ++value) {
+       
+	    Polyline* arc = new Polyline();	
+	    Text* label = new Text( );
+	    label->addText(*value, *secondary_colour_,0.35);
+
+            double radius = *value;
+            double centre = primary_reference_;
+            double pos = 1.4;
+            PaperPoint paper(centre + radius*cos(pos), radius*sin(pos));
+
+	    if ( projection.in(paper) )
+		label->push_back(paper);
+            else{
+                pos = 1.8;
+                paper = PaperPoint(centre + radius*cos(pos), radius*sin(pos));
+                if ( projection.in(paper) )
+			label->push_back(paper);
+	    }
+            if (!same(*value, 0)) out.push_back(label);
+
+	    arc->setThickness(secondary_thickness_);
+	    arc->setColour(*secondary_colour_); 
+	    arc->setLineStyle(secondary_style_); 
+
+	    for ( double angle = 0.; angle <= 3.2; angle += 0.01 ) {
+			PaperPoint paper(centre + radius*cos(angle), radius*sin(angle));
+
+			if ( projection.in(paper) )
+				arc->push_back(paper);
+	    }
+	    out.push_back(arc);
+	}
+}
+
+/*!
+ Class information are given to the output-stream.
+*/
+void TaylorGrid::print(ostream& out)  const
+{
+	out << "TaylorGrid[";
+	TaylorGridAttributes::print(out);
+	out << "]";
+}
+
+void TaylorGrid::visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors)
+{
+	// First we create the layer!
+	// and push It to the parent layer! 
+	StaticLayer* taylor = new NoDataLayer(this);
+	//taylor->id(iconName_);	
+	//taylor>name(iconName_);
+	layer.add(taylor);
+	
+	for  (vector<LayoutVisitor*>::iterator visitor = visitors.begin(); visitor != visitors.end(); ++visitor) {
+	    taylor->set(*visitor);
+		(*visitor)->visit(*this);
+	}
+}
diff --git a/src/visualisers/TaylorGrid.h b/src/visualisers/TaylorGrid.h
new file mode 100644
index 0000000..3c6d447
--- /dev/null
+++ b/src/visualisers/TaylorGrid.h
@@ -0,0 +1,74 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TaylorGrid.h
+    \brief Definition of the Template class TaylorGrid.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Tue 3-Oct-2006
+    
+    Changes:
+    
+*/
+
+#ifndef TaylorGrid_H
+#define TaylorGrid_H
+
+#include "magics.h"
+
+#include "BasicSceneObject.h"
+#include "TaylorGridAttributes.h"
+
+namespace magics {
+
+class TaylorGrid:   public BasicSceneObject, public TaylorGridAttributes {
+
+public:
+	TaylorGrid();
+	virtual ~TaylorGrid();
+	
+	// New Interface!
+   void visit(DrawingVisitor& list);
+   void secondary(DrawingVisitor& list);
+   void visit(SceneLayer& layer, vector<LayoutVisitor*>& visitors);
+
+   
+	void set(const map<string, string>& map ) { TaylorGridAttributes::set(map); }
+	void set(const XmlNode& node ) { TaylorGridAttributes::set(node); }
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 void list(double ref, double inc, std::set<double>& out) const;
+
+private:
+    //! Copy constructor - No copy allowed
+	TaylorGrid(const TaylorGrid&);
+    //! Overloaded << operator to copy - No copy allowed
+	TaylorGrid& operator=(const TaylorGrid&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TaylorGrid& p)
+		{ p.print(s); return s; }
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/TextOrientation.cc b/src/visualisers/TextOrientation.cc
new file mode 100644
index 0000000..cc3f826
--- /dev/null
+++ b/src/visualisers/TextOrientation.cc
@@ -0,0 +1,53 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TextOrientation.cc
+    \brief Implementation of the Template class TextOrientation.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 7-Oct-2005
+    
+    Changes:
+    
+*/
+
+
+
+#include "TextOrientation.h"
+
+using namespace magics;
+
+TextOrientation::TextOrientation() 
+{
+}
+
+
+TextOrientation::~TextOrientation() 
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/		
+void TextOrientation::print(ostream& out)  const
+{
+	out << "TextOrientation[";
+	out << "]";
+}
+
diff --git a/src/visualisers/TextOrientation.h b/src/visualisers/TextOrientation.h
new file mode 100644
index 0000000..2da7a33
--- /dev/null
+++ b/src/visualisers/TextOrientation.h
@@ -0,0 +1,93 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TextOrientation.h
+    \brief Definition of the Template class TextOrientation.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Fri 7-Oct-2005
+    
+    Changes:
+    
+*/
+
+#ifndef TextOrientation_H
+#define TextOrientation_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class TextOrientation {
+
+public:
+	TextOrientation();
+	virtual ~TextOrientation();
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual TextOrientation* clone() const {
+        MagLog::dev() << "(const map<string, string&)---> to be checked!...\n";
+        return new TextOrientation();
+    }
+     virtual void toxml(ostream&, int)  const {}
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	TextOrientation(const TextOrientation&);
+    //! Overloaded << operator to copy - No copy allowed
+	TextOrientation& operator=(const TextOrientation&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TextOrientation& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, TextOrientation> { 
+public:
+	TextOrientation* operator()(const string& val )
+	{
+		return SimpleObjectMaker<TextOrientation>::create(val);
+	}     
+
+	TextOrientation* magics(const string& param)
+	{
+		string val;
+		ParameterManager::get(param, val);
+		return (*this)(val);
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/Title.h b/src/visualisers/Title.h
new file mode 100644
index 0000000..05c8b31
--- /dev/null
+++ b/src/visualisers/Title.h
@@ -0,0 +1,123 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Title.h
+    \brief Definition of the Template class Title.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 12-Feb-2004
+    
+    Changes:
+    
+*/
+
+#ifndef Title_H
+#define Title_H
+
+#include "magics.h"
+#include "TitleAttributes.h"
+#include "TitleBase.h"
+
+
+
+namespace magics {
+
+class Node;
+
+
+
+class Title: public TitleBase, public TitleAttributes {
+
+public:
+	Title();
+	virtual ~Title();
+
+	virtual TitleBase* clone() const {
+		Title* object = new Title();
+		object->copy(*this);
+		return object;
+	}
+	
+    virtual void set(const XmlNode& node) {
+        TitleAttributes::set(node);
+    }
+    virtual void set(const map<string, string>& map) {
+        TitleAttributes::set(map);
+    }
+	virtual void add(const string& info) {
+		if (empty()) { push_back(new TitleEntry()); }
+		back()->add(info);
+	}
+	virtual void newline() {
+		push_back(new TitleEntry());
+	}
+	virtual bool on() { return true; }
+	void push_back(TitleEntry* entry) 
+	   { vector<TitleEntry*>::push_back(entry); }
+	MagFont font() const;
+	virtual Justification justification() const { return justification_; }
+	virtual string colour() const { return colour_->name(); }
+	
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream&) const; 
+
+private:
+	//! Copy constructor - No copy allowed
+	Title(const Title&);
+	//! Overloaded << operator to copy - No copy allowed
+	Title& operator=(const Title&);
+
+// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Title& p)
+		{ p.print(s); return s; }
+
+};
+
+
+class NoTitle: public TitleBase {
+
+public:
+	NoTitle() {}
+	virtual ~NoTitle() {}
+	virtual TitleBase* clone() const {
+		TitleBase* object = new NoTitle();
+		return object;
+	}
+	virtual void add(const string& ){
+	}
+	virtual void newline() {
+	}
+	virtual bool on() { return false; }
+
+protected:
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	virtual void print(ostream& out) const { out << "No Automatic Title"; } 
+
+private:
+	//! Copy constructor - No copy allowed
+	NoTitle(const NoTitle&);
+	//! Overloaded << operator to copy - No copy allowed
+	NoTitle& operator=(const NoTitle&);
+};
+
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/TitleBase.h b/src/visualisers/TitleBase.h
new file mode 100644
index 0000000..b44667f
--- /dev/null
+++ b/src/visualisers/TitleBase.h
@@ -0,0 +1,130 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file TitleBase.h
+    \brief Definition of the Template class TitleBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 9-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef TitleBase_H
+#define TitleBase_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "MagFont.h"
+
+
+namespace magics {
+
+class XmlNode;
+class TitleEntry {
+public:
+    TitleEntry(const string entry = "") : entry_(entry) {}
+    ~TitleEntry() {}
+    string entry();
+    string entry_;
+    void add(const string& info ) {
+        entry_ += info;
+    }
+};
+
+
+
+class TitleBase :public vector<TitleEntry*>  {
+
+public:
+	TitleBase() {}
+	virtual ~TitleBase() {}
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "TitleBase::set(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "TitleBase::set(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual TitleBase* clone() const {
+        MagLog::dev() << "TitleBase::set(const map<string, string&)---> to be checked!...\n";
+        return new TitleBase();
+    }
+    virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << "TitleBase::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+    }  
+    virtual void add(const string& info){
+    	if (empty()) { push_back(new TitleEntry()); }
+		back()->add(info);
+	}
+	virtual void newline() {
+		MagLog::dev() << "TitleBase::newline()---> to be checked!...\n";
+	}
+	virtual bool on() { 
+		MagLog::dev() << "TitleBase:: on()---> to be checked!...\n";
+		return false; 
+	}
+    virtual MagFont font() const  { return MagFont(); }
+    virtual Justification justification() const { return MLEFT; }
+	virtual string colour() const { return "NONE"; }
+	virtual void titles(vector<string>&) {}
+	
+	void update(const string&, const string&, const string&);
+ 	string get(const string&, const string&);
+ 	void reset() { definitions_.erase(definitions_.begin(), definitions_.end());}
+ 	
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "TitleBase\n"; } 
+	 typedef map<string, std::set<string> > DefList;
+     static map<string, DefList > definitions_;
+
+private:
+    //! Copy constructor - No copy allowed
+	TitleBase(const TitleBase&);
+    //! Overloaded << operator to copy - No copy allowed
+	TitleBase& operator=(const TitleBase&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const TitleBase& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, TitleBase> { 
+public:
+	TitleBase* operator()(const string& val )
+	{
+		return SimpleObjectMaker<TitleBase>::create(val);
+	}     
+
+	TitleBase* magics(const string& param)
+	{
+		TitleBase* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ValuePlot.cc b/src/visualisers/ValuePlot.cc
new file mode 100644
index 0000000..34695e3
--- /dev/null
+++ b/src/visualisers/ValuePlot.cc
@@ -0,0 +1,88 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ValuePlot.cc
+    \brief Implementation of the Template class ValuePlot.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 3-Mar-2004
+    
+    Changes:
+    
+*/
+
+#include "ValuePlot.h"
+#include "Symbol.h"
+#include "MarkerValuePlotMethod.h"
+#include "BothValuePlotMethod.h"
+#include "Data.h"
+
+using namespace magics;
+
+
+ValuePlot::ValuePlot()
+{
+   
+}
+
+
+ValuePlot::~ValuePlot()
+{
+}
+
+
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void ValuePlot::print(ostream& out)  const
+{
+	out << "ValuePlot[";
+	ValuePlotAttributes::print(out);
+	out << "]";
+}
+
+
+void ValuePlot::operator()(MatrixHandler& data, BasicGraphicsObjectContainer& parent)
+{
+	(*(this->method_)).clear();
+
+    (*(this->method_))(data, parent.transformation());
+    
+    // Now we feed the task
+    for ( vector<BasicGraphicsObject*>::const_iterator object = (*this->method_).begin(); object != (*this->method_).end(); ++object)
+    	parent.push_back(*object);
+}
+
+void ValuePlot::operator()(Data& data, BasicGraphicsObjectContainer& parent)
+{
+	(*(this->method_)).clear();
+    (*(this->method_))(data.points(parent.transformation(), false), parent.transformation());
+    
+    // Now we feed the task
+    for ( vector<BasicGraphicsObject*>::const_iterator object = (*this->method_).begin(); object != (*this->method_).end(); ++object)
+    	parent.push_back(*object);
+}
+
+void ValuePlot::visit(LegendVisitor&)
+{
+}
+    
+
diff --git a/src/visualisers/ValuePlot.h b/src/visualisers/ValuePlot.h
new file mode 100644
index 0000000..8605a4b
--- /dev/null
+++ b/src/visualisers/ValuePlot.h
@@ -0,0 +1,102 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ValuePlot.h
+    \brief Definition of the Template class ValuePlot.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Wed 3-Mar-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ValuePlot_H
+#define ValuePlot_H
+
+#include "magics.h"
+#include "ValuePlotBase.h"
+#include "ValuePlotAttributes.h"
+#include "BasicSceneObject.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+namespace magics {
+
+
+class ValuePlot: public ValuePlotBase, public ValuePlotAttributes {
+
+public:
+	ValuePlot();
+	virtual ~ValuePlot();
+   
+    virtual ValuePlotBase* clone() const {
+    	ValuePlot* plot = new ValuePlot();
+    	plot->copy(*this);
+    	return plot;
+    }
+    virtual bool accept(const string& node) { return ValuePlotAttributes::accept(node);; }
+
+   // Implements the VisualComponent Interface...
+    void operator()(MatrixHandler&, BasicGraphicsObjectContainer&);
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+
+
+    virtual void visit(LegendVisitor&);
+    virtual void set(const map<string, string>& map ) { ValuePlotAttributes::set(map); }
+	virtual void set(const XmlNode& node ) { ValuePlotAttributes::set(node); }
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+private:
+    //! Copy constructor - No copy allowed
+	ValuePlot(const ValuePlot&);
+    //! Overloaded << operator to copy - No copy allowed
+	ValuePlot& operator=(const ValuePlot&);
+   
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ValuePlot& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+class NoValuePlot : public ValuePlotBase
+{
+public:
+    NoValuePlot() {};
+    ~NoValuePlot() {};
+    ValuePlotBase* clone() const
+    { 
+    	return new NoValuePlot();
+    }
+    bool accept(const string& node) { return magCompare(node, "nogridvalues"); }
+ 
+    void operator()(MatrixHandler&, BasicGraphicsObjectContainer&) {}
+    void operator()(PointsHandler&, BasicGraphicsObjectContainer&) {}
+    void visit(LegendVisitor&) {}
+};
+
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/ValuePlotBase.h b/src/visualisers/ValuePlotBase.h
new file mode 100644
index 0000000..dd7e31d
--- /dev/null
+++ b/src/visualisers/ValuePlotBase.h
@@ -0,0 +1,110 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ValuePlotBase.h
+    \brief Definition of the Template class ValuePlotBase.
+    
+    Magics Team - ECMWF 2006
+    
+    Started: Thu 9-Feb-2006
+    
+    Changes:
+    
+*/
+
+#ifndef ValuePlotBase_H
+#define ValuePlotBase_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+
+
+
+namespace magics {
+
+class XmlNode;
+class MatrixHandler;
+class BasicGraphicsObjectContainer;
+class Data;
+class LegendVisitor;
+
+class ValuePlotBase {
+
+public:
+	ValuePlotBase() {}
+	virtual ~ValuePlotBase() {}
+    
+    virtual void set(const XmlNode&) {
+        MagLog::dev() << "ValuePlotBase::set(const XmlNode&)---> to be checked!...\n";
+    }
+    virtual void set(const map<string, string>&) {
+        MagLog::dev() << "ValuePlotBase::set(const map<string, string&)---> to be checked!...\n";
+    }
+    virtual bool accept(const string&) { return false; }
+
+    virtual ValuePlotBase* clone() const { return new ValuePlotBase(); }
+     virtual void toxml(ostream&, int = 0) const {
+    	 MagLog::dev() << "ValuePlotBase::virtual void toxml(ostream&, int = 0) const ---> to be checked!...\n";
+    } 
+    
+    virtual void operator()(MatrixHandler&, BasicGraphicsObjectContainer&) {}
+    virtual void operator()(Data&, BasicGraphicsObjectContainer&) {}
+    
+    virtual void visit(LegendVisitor&) {
+        MagLog::dev() << "ValuePlotBase::visit(LegendBase&)---> to be checked!...\n";
+    }
+    
+    virtual string getType() { return "unknown"; }
+    
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const { out << "ValuePlotBase\n"; } 
+
+private:
+    //! Copy constructor - No copy allowed
+	ValuePlotBase(const ValuePlotBase&);
+    //! Overloaded << operator to copy - No copy allowed
+	ValuePlotBase& operator=(const ValuePlotBase&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ValuePlotBase& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, ValuePlotBase > {
+public:
+	ValuePlotBase* operator()(const string& val )
+	{
+		return SimpleObjectMaker<ValuePlotBase >::create(val);
+	}     
+
+	ValuePlotBase* magics(const string& param)
+	{
+		ValuePlotBase* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+
+} // namespace magics
+#endif
diff --git a/src/visualisers/ValuePlotMethod.h b/src/visualisers/ValuePlotMethod.h
new file mode 100644
index 0000000..8832370
--- /dev/null
+++ b/src/visualisers/ValuePlotMethod.h
@@ -0,0 +1,151 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ValuePlotMethod.h
+    \brief Definition of the Template class ValuePlotMethod.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: Thu 26-Aug-2004
+    
+    Changes:
+    
+*/
+
+#ifndef ValuePlotMethod_H
+#define ValuePlotMethod_H
+
+#include "magics.h"
+
+#include "ValuePlotMethodAttributes.h"
+#include "MatrixHandler.h"
+#include "PointsHandler.h"
+#include "Text.h"
+#include "Transformation.h"
+#include "MagicsFormat.h"
+
+namespace magics {
+
+
+class ValuePlotMethod: public ValuePlotMethodAttributes, public vector<BasicGraphicsObject*> {
+
+public:
+	ValuePlotMethod() {}
+	virtual ~ValuePlotMethod() {}
+    virtual void set(const map<string, string>& map ) 
+        { ValuePlotMethodAttributes::set(map); }
+    virtual void set(const XmlNode& node ) 
+        { ValuePlotMethodAttributes::set(node); }
+    
+    virtual ValuePlotMethod* clone() const {
+    	ValuePlotMethod* object = new ValuePlotMethod();
+    	object->copy(*this);
+    	return object;
+    }
+    virtual void operator()(MatrixHandler& data, const Transformation& transformation) {
+        reset();
+    	int rows = data.rows();
+           int columns = data.columns();
+           for (int j = 0; j < rows ; j += lat_frequency_ ) {
+            for (int i = 0; i <columns; i += lon_frequency_) {
+                 double val =  data(j,i);
+                 if ( min_ <= val && val <= max_ && val != data.missing() ) {
+                	UserPoint point(data.column(j, i), data.row(j, i), data(j, i));
+                	PaperPoint xy = transformation(point);
+                 	if ( transformation.in(xy) ) 
+                    	add(xy);
+                 }
+            }
+           }
+        }
+      virtual void operator()(PointsHandler& data, const Transformation& transformation)
+      {
+    	  reset();
+    	 ThinningPointsHandler thinned(data, lon_frequency_, lat_frequency_);
+    	 thinned.setToFirst();
+    	 
+    	 while ( thinned.more() ) {
+    		 UserPoint point =  thinned.current();
+    		 double val = point.value();
+    		 if ( min_ <= val && val <= max_ )
+    		 {
+    			 PaperPoint xy = transformation(point);
+    			 if ( transformation.in(xy) )
+    				 add(xy);
+    	 	}
+    		 thinned.advance();
+    	 }  
+    }
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const {
+         out << "ValuePlotMethod[";
+         ValuePlotMethodAttributes::print(out);
+         out << "]";
+	 }
+	 virtual void reset() {} // For Metview, get ready for a second frame.
+     virtual void add(const PaperPoint& xy) {
+     	 ostringstream nice;
+    	 nice << MagicsFormat(format_, xy.value()); 
+         Text* text = new Text(); 
+         text->addText(nice.str(), *colour_, height_);
+         text->setJustification(MCENTRE);
+         text->push_back(xy);
+         push_back(text);
+    }
+     
+     string label(double val) {
+    	 ostringstream nice;
+    	 nice << MagicsFormat(format_, val);
+    	 return nice.str();
+     }
+
+private:
+    //! Copy constructor - No copy allowed
+	ValuePlotMethod(const ValuePlotMethod&);
+    //! Overloaded << operator to copy - No copy allowed
+	ValuePlotMethod& operator=(const ValuePlotMethod&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ValuePlotMethod& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, ValuePlotMethod > {
+public:
+	ValuePlotMethod* operator()(const string& val ) {
+		 return SimpleObjectMaker<ValuePlotMethod >::create(val);
+	}     
+    ValuePlotMethod* magics(const string& param)
+    {
+        ValuePlotMethod* object=0;
+		ParameterManager::update(param, object);
+		return object;
+    }
+
+};
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/VisDefInfo.cc b/src/visualisers/VisDefInfo.cc
new file mode 100644
index 0000000..2003845
--- /dev/null
+++ b/src/visualisers/VisDefInfo.cc
@@ -0,0 +1,253 @@
+#include <algorithm>
+
+#include "Layer.h"
+
+#include "VisDefInfo.h"
+
+
+//===============================================================
+//
+// VisDefInfoBase
+//
+//===============================================================
+
+VisDefInfoBase::VisDefInfoBase(string fConf, DataType dataType) : fConf_(fConf), dataType_(dataType)
+{
+	loaded_=false;
+	dataTypeName_[GribType]="GRIB";
+}
+
+
+VisDefInfoBase::~VisDefInfoBase()
+{
+	clear();
+}
+
+void VisDefInfoBase::clear()
+{
+	for(unsigned int i=0; i < items_.size(); i++)
+	{
+		delete items_[i];
+	}
+	items_.clear();
+}
+
+VisDefInfoItem* VisDefInfoBase::addItem(string name)
+{
+	VisDefInfoItem* item=new VisDefInfoItem(name);
+	items_.push_back(item);
+	return item;
+}
+
+void VisDefInfoBase::deleteItem(int /*index*/)
+{
+	//vector<MvKeyProfile*>::iterator it=begin()+index;
+	//delete (*it);
+	//erase(it);	
+}	
+	
+void VisDefInfoBase::collectKeys()
+{	
+	keys_.clear();
+	for(vector<VisDefInfoItem*>::iterator it=items_.begin(); it != items_.end(); it++)
+	{		
+		for(map<string,vector<string> >::const_iterator itK=(*it)->keys().begin(); itK != (*it)->keys().end(); itK++)
+		{
+
+			if(find(keys_.begin(), keys_.end(), itK->first) == keys_.end())
+			{
+				keys_.push_back(itK->first);
+			}
+
+		}
+	}	
+
+
+}
+
+
+//===============================================================
+//
+// MvQObstatVisDefInfo
+//
+//===============================================================
+
+
+ObstatVisDefInfo::ObstatVisDefInfo(string fConf, DataType dataType) : VisDefInfoBase(fConf,dataType) 
+{
+	fConf_ = getEnvVariable("MAGPLUS_HOME") + MAGPLUS_PATH_TO_SHARE_ + "ObstatGribVisDef.txt";
+
+	loadItems();
+
+	type_="ObstatGrib";
+
+	baseAttributes_["contour"] = "OFF";
+	//req("CONTOUR_MIN_LEVEL") = "10";
+	baseAttributes_["contour_level_selection_type"] = "INTERVAL";
+	//req("CONTOUR_INTERVAL") = "10";
+	baseAttributes_["contour_shade"] = "ON";
+	baseAttributes_["contour_shade_technique"] = "CELL_SHADING";
+	baseAttributes_["contour_shade_min_level_colour"] = "BLUE";
+	baseAttributes_["contour_shade_max_level_colour"] = "RED";
+	baseAttributes_["contour_shade_colour_direction"] = "ANTICLOCKWISE";
+	baseAttributes_["contour_shade_method"] = "AREA_FILL";
+	baseAttributes_["contour_label"] = "OFF";
+	baseAttributes_["contour_hilo"] = "OFF";
+
+}
+
+void ObstatVisDefInfo::loadItems()
+{
+	if(loaded_)
+		return;
+
+	//Obs        fgdep       bcor       Obstdv       fgdStdv    BcorSTDV      Count     Unit
+	char *statIdDef[]={"2","4","18","3","5","19","1"};
+	vector<string> statId(statIdDef,statIdDef + sizeof(statIdDef)/sizeof(char*));
+
+	ifstream in;
+	in.open(fConf_.c_str(),ifstream::in);
+
+	if(in.fail())
+	{
+		MagLog::warning() << "ObstatVisDefInfo::loadItems() --> Cannot open visdef file " << fConf_ << "\n";
+		return;
+	}
+
+        while(!in.eof())
+        {
+	        string line;
+		getline(in,line); 
+	       
+		if(line.find("#") == string::npos)
+		{
+			vector<string> lst;
+			string str;
+			stringstream iss(line,istringstream::in);
+			while( iss >> str )     
+			{
+				lst.push_back(str);
+
+			}
+		
+                   	if(lst.size() ==0 || lst[0].size() < 7)
+				continue;	
+
+			str=lst[0];
+			string id=removeZerosFromNumber(str.substr(0,3));
+			string sensor=removeZerosFromNumber(str.substr(3,3));
+			string channel=removeZerosFromNumber(str.substr(6));
+		
+			int statCnt=0;
+			for(unsigned int i=2; i < lst.size() && statCnt < 8; i+=4)
+			{
+				if(lst[i] !="|" && i+2 < lst.size())
+				{
+					VisDefInfoItem *visDef= new VisDefInfoItem("obstat");
+					items_.push_back(visDef);				
+					
+					string keyName, keyValue;
+
+					keyName="platform";
+					keyValue=id;
+					visDef->addKey(keyName,keyValue);
+
+					keyName="instrument";
+					keyValue=sensor;
+					visDef->addKey(keyName,keyValue);
+												
+					keyName="scaledValueOfFirstFixedSurface";
+					keyValue=channel;
+					visDef->addKey(keyName,keyValue);
+					
+					keyName="observationDiagnostic";
+					keyValue=statId[statCnt];
+					visDef->addKey(keyName,keyValue);
+
+					visDef->addAttribute("contour_min_level",lst[i]);
+					visDef->addAttribute("contour_interval",lst[i+1]);
+			
+					statCnt++;
+				}
+			}
+		}
+
+        }
+
+	in.close();
+
+	loaded_=true;
+
+	collectKeys();
+}
+	 
+void ObstatVisDefInfo::getAttributes(MetaDataCollector& meta, map<string, string>& attributes)
+{
+	for(vector<VisDefInfoItem*>::iterator it=items_.begin(); it != items_.end(); it++)
+	{
+		bool found;
+		for(map<string,vector<string> >::const_iterator itK=(*it)->keys().begin(); itK != (*it)->keys().end(); itK++)
+		{
+			string name=itK->first;
+			const vector<string>& value=itK->second;
+
+			found=false;
+			if(meta.find(name) != meta.end() &&
+			   find(value.begin(),value.end(),meta[name]) != value.end())
+			{
+					found=true;
+			}
+			else
+			{
+				break;
+			}
+		}
+		
+ 		if(found == true)
+		{			
+			for(map<string,string>::iterator itA=baseAttributes_.begin(); 
+			    itA != baseAttributes_.end(); itA++)
+			{
+				attributes[itA->first]=itA->second;
+			}
+
+			map<string,string> vAttr=(*it)->attributes();
+
+			if(vAttr["contour_min_level"] != "-99")
+				attributes["contour_min_level"]=vAttr["contour_min_level"];
+
+			attributes["contour_interval"]=vAttr["contour_interval"];
+
+			return;
+
+		}
+
+	}
+}
+
+string ObstatVisDefInfo::removeZerosFromNumber(string s)
+{
+	istringstream iss(s);
+	int num;
+	iss >> num;
+
+	stringstream ss;
+   	ss << num;
+   	return ss.str();
+}
+
+//===================================================
+//
+// VisDefInfoFactory
+//
+//===================================================
+
+VisDefInfoBase* VisDefInfoFactory::makeItem(string type)
+{
+	if(type == "ObstatGrib")
+  	{
+		return new ObstatVisDefInfo("",VisDefInfoBase::GribType);
+	}	
+
+	return 0;
+}
diff --git a/src/visualisers/VisDefInfo.h b/src/visualisers/VisDefInfo.h
new file mode 100644
index 0000000..169ae16
--- /dev/null
+++ b/src/visualisers/VisDefInfo.h
@@ -0,0 +1,127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file VisDefInfo.h
+    \brief Definition of class VisDefInfo.
+    
+    Magics Team - ECMWF 2004
+    
+    Started: August 2010
+    
+    Changes:
+    
+*/
+
+#ifndef VisDefInfo_H
+#define VisDefInfo_H
+
+#include "magics.h"
+
+namespace magics {
+
+class MetaDataCollector;
+
+class VisDefInfoItem
+{
+public:
+	VisDefInfoItem(string name) : name_(name) {};
+
+	string name() {return name_;}
+	const map<string,vector<string> > &keys() const {return keys_;}
+	const map<string,string>  &attributes() const {return attributes_;}	
+	void addKey(string name,string value) {keys_[name].push_back(value);}
+	void addAttribute(string name, string value) {attributes_[name]=value;}
+
+public:
+	string name_;
+	map<string,vector<string> > keys_;
+	map<string,string>  attributes_;
+}; 
+
+class VisDefInfoBase
+{
+public:
+	enum DataType {GribType};
+
+	virtual ~VisDefInfoBase();
+ 
+	VisDefInfoItem* addItem(string);
+	const vector<string>& keys() {return keys_;}
+	string type() {return type_;}
+
+	//virtual vector<string> visDefFile(MvKeyProfile*,int) {return QStringList();}
+	//virtual MvRequest visDefRequest(MvKeyProfile*,int) {return MvRequest();}
+
+	virtual void getAttributes(MetaDataCollector&, map<string, string>&) {};
+
+	bool isLoaded() {return loaded_;}
+	void clear();
+	void deleteItem(int);
+	virtual void loadItems()=0 ;
+	virtual void saveItems()=0 ;
+
+protected:
+	VisDefInfoBase(string,DataType);	
+	void collectKeys();
+
+	string fConf_;
+	DataType dataType_;
+	string type_;
+	map<DataType,string> dataTypeName_;
+	vector<VisDefInfoItem*> items_;
+	vector<string> keys_;
+	bool loaded_;
+
+	map<string,string> baseAttributes_;	
+};
+
+
+/*class VisDefInfo : public VisDefInfoBase
+{
+public:
+	MvQVisDefInfo(string,DataType);
+	~MvQVisDefInfo() {};
+
+	QStringList visDefFile(MvKeyProfile*,int);
+	void loadItems();
+	void saveItems();	
+};*/
+
+class ObstatVisDefInfo : public VisDefInfoBase
+{
+public:
+	ObstatVisDefInfo(string,DataType);
+	~ObstatVisDefInfo() {};
+
+	void getAttributes(MetaDataCollector&, map<string, string>&);
+	void loadItems();
+	void saveItems() {};
+
+protected:
+	string removeZerosFromNumber(string);	
+};
+
+class VisDefInfoFactory
+{
+public:	
+	VisDefInfoFactory() {};
+	static VisDefInfoBase*  makeItem(string);
+};
+} // namespace magics
+
+#endif
diff --git a/src/visualisers/Wind.cc b/src/visualisers/Wind.cc
new file mode 100644
index 0000000..07713dc
--- /dev/null
+++ b/src/visualisers/Wind.cc
@@ -0,0 +1,117 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Wind.cc
+    \brief Implementation of the Template class Wind.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#include "Wind.h"
+#include "MatrixHandler.h"
+#include "Layout.h"
+#include "CustomisedPoint.h"
+#include "HistoVisitor.h"
+
+using namespace magics;
+
+
+Wind::Wind()
+{
+}
+
+
+Wind::~Wind()
+{
+}
+
+/*!
+ Class information are given to the output-stream.
+*/	
+
+void Wind::print(ostream& out)  const
+{
+	out << "Wind";
+}
+
+
+void Wind::operator()(Data& data, BasicGraphicsObjectContainer& parent)
+{	
+	ThinningMethod* method=0;
+
+	const Transformation& transformation = parent.transformation();
+
+	try {
+		method = MagTranslator<string, ThinningMethod>()(this->thinning_method_);
+	}
+	catch (...) {
+	}
+	if(!method) method = new BasicThinningMethod();
+
+	method->set2D();
+
+	this->factor_ = maground(this->thinning_factor_);
+	this->nbPoints_ = this->thinning_factor_*transformation.dimension(parent);parent.absoluteHeight();
+	this->rawOnly_ = false;
+	method->set(*this);
+	
+
+	CustomisedPointsList points;
+	std::set<string> request;
+	request.insert("x_component");
+	request.insert("y_component");
+	request.insert("colour_component");
+	(*method)(data, transformation, request, points);
+	if (points.empty() )
+		return;
+		(*this->type_).prepare(parent, method->units());
+				
+		(*this->type_).adjust(points, transformation);
+
+		
+		for (vector<CustomisedPoint*>::const_iterator point =points.begin(); point != points.end(); ++point) {
+			 UserPoint position((*point)->longitude(), (*point)->latitude());
+			 PaperPoint pp = transformation(position);
+			 if ( transformation.in(pp) )  {
+				 pair<double, double> component = make_pair(  (**point)["x_component"], (**point)["y_component"]);		 
+				 transformation.reprojectComponents(position, component);
+				 (*this->type_)(position, pp, component.first,  component.second, (**point)["colour_component"]);
+			 }	
+		}
+	(*this->type_).finish(parent);
+}
+
+
+void Wind::visit(LegendVisitor& legend)
+{
+	(*this->type_).visit(legend);
+}
+
+void  Wind::visit(Data& data, HistoVisitor& visitor)
+{
+	//if ( !matrix_ )
+	//	return;
+
+	(*this->type_).visit(data, data.points(*visitor.dataLayoutTransformation(), false), visitor);
+	
+}
diff --git a/src/visualisers/Wind.h b/src/visualisers/Wind.h
new file mode 100644
index 0000000..1299a97
--- /dev/null
+++ b/src/visualisers/Wind.h
@@ -0,0 +1,81 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file Wind.h
+    \brief Definition of the Template class Wind.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef Wind_H
+#define Wind_H
+
+#include "magics.h"
+
+#include "Visdef.h"
+#include "WindAttributes.h"
+#include "ThinningMethod.h"
+
+namespace magics {
+
+
+class Wind: public Visdef, public WindAttributes, public ThinningMethodUI {
+
+public:
+	Wind();
+	virtual ~Wind();
+	
+	virtual void set(const map<string, string>& map) 
+		{ WindAttributes::set(map); }
+	virtual void set(const XmlNode& node) 
+		{ WindAttributes::set(node); }
+		
+	// implements the Visdef interface ...
+    void operator()(Data&, BasicGraphicsObjectContainer&);
+    void visit(LegendVisitor&);
+    bool needLegend() { return type_->needLegend(); }
+    void  visit(Data& data, HistoVisitor& visitor);
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 
+
+private:
+    //! Copy constructor - No copy allowed
+	Wind(const Wind&);
+    //! Overloaded << operator to copy - No copy allowed
+	Wind& operator=(const Wind&);
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const Wind& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+} // namespace magics
+
+
+#endif
diff --git a/src/visualisers/WindPlotting.cc b/src/visualisers/WindPlotting.cc
new file mode 100644
index 0000000..a1948ab
--- /dev/null
+++ b/src/visualisers/WindPlotting.cc
@@ -0,0 +1,168 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file WindPlotting.cc
+    \brief Implementation of the Template class Wind.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#include "WindPlotting.h"
+#include "LegendVisitor.h"
+#include "CustomisedPoint.h"
+#include "Polyline.h"
+
+using namespace magics;
+
+map<string,  WindPlotting::AdvancedMethod > WindPlotting::methods_;
+map<string,  WindPlotting::ColouringMethod > WindPlotting::colouringMethods_;
+
+WindPlotting::WindPlotting() 
+{
+	if ( methods_.empty() ) {
+		methods_["on"] = &WindPlotting::advanced;
+		methods_["advanced"] =&WindPlotting::advanced;
+		methods_["off"] = &WindPlotting::off;
+	}
+	
+	if ( colouringMethods_.empty() ) {
+		colouringMethods_["speed"] = &WindPlotting::speed;
+		colouringMethods_["parameter"] = &WindPlotting::parameter; 
+	}
+}
+
+
+void WindPlotting::adjust( CustomisedPointsList& points, const Transformation& transformation)
+{
+	//MagLog::dev() << "Data going from " << min << " to " << max << endl;
+	
+	vector<double> values;
+	if (points.empty()) return;
+	
+	for (CustomisedPointsList::const_iterator point = points.begin(); point != points.end(); ++point) {
+		if ( transformation.in((*point)->longitude(), (*point)->latitude()) ) 
+			values.push_back(value((**point)["x_component"], (**point)["y_component"],  (**point)["colour_component"]));		
+	}
+
+	if (values.empty() ) return;
+
+	double min = *std::min_element(values.begin(), values.end());
+	double max = *std::max_element(values.begin(), values.end());
+	
+	levels_->set(*this);	
+	colourMethod_->set(*this);
+	
+	levels_->calculate(min, max, false);
+	LevelSelection::const_iterator level = levels_->begin();
+	colourMethod_->prepare(*levels_);
+	Colour last;
+	 while ( true) {
+	    	if (level+1 == levels_->end() ) break;
+	    	MagLog::debug() << "[" << *level << ", " << *(level+1) << "]=" << colourMethod_->right(*level) << endl;
+	    	map_[ Interval(*level, *(level+1)) ] = colourMethod_->right(*level);
+	    	last = colourMethod_->right(*level);
+	    	++level;
+	 }
+	 // we add a last small one for the maax
+	 map_[ Interval(levels_->back(), levels_->back() + epsilon) ] = last;
+
+}
+
+
+Colour& WindPlotting::colour(Colour& colour, double x, double y, double col)
+{
+	string value = lowerCase(advanced_method_);
+	map<string,  AdvancedMethod >::const_iterator method = methods_.find(value);
+	if  ( method == methods_.end() ) {
+		MagLog::warning() << advanced_method_ << " is not valid value for  'wind_advanced_method': reset to default[off]" << endl;
+		return off(colour, x, y, col);
+	}
+	else 
+		return (this->*method->second)(colour, x, y, col);
+}
+
+double WindPlotting::parameter(double, double, double col)
+{
+	return col;
+}
+
+double WindPlotting::speed(double x, double y, double)
+{
+	return sqrt(x*x+y*y);
+}
+
+double WindPlotting::value(double x, double y, double col)
+{
+	string value = lowerCase(colour_method_);
+	map<string,  ColouringMethod >::const_iterator method = colouringMethods_.find(value);
+	if  ( method == colouringMethods_.end() ) {
+			MagLog::warning() << colour_method_ << " is not valid value for  'wind_advanced_colour_parameter': reset to default[speed]" << endl;
+			return speed( x, y, col);
+	}
+	else 
+			return   (this->*method->second)(x, y,col);
+}
+
+Colour& WindPlotting::advanced(Colour& colour, double u, double v, double col)
+{
+	static Colour x("red");
+	x = map_.find(value(u, v, col), colour);
+	return x;
+}
+ 
+void WindPlotting::visit(LegendVisitor& legend)
+{
+	if ( !legend_ )
+			return;
+    if (magCompare(advanced_method_, "advanced") ||  magCompare(advanced_method_, "on") ) {
+		
+	IntervalMap<Colour>::const_iterator interval;
+
+	for ( interval = map_.begin(); interval != map_.end(); ++interval) {
+		Polyline* box = new Polyline();
+
+		double min =interval->first.min_;
+		double max = interval->first.max_;
+
+		box->setShading(new FillShadingProperties());
+
+		box->setFillColour(interval->second);
+		box->setFilled(true);
+
+		legend.add(new BoxEntry(min, max, box));
+		/*   
+		Symbol* symbol = new Symbol();
+		(*symbol).setColour(interval->second.colour_);
+		(*symbol).setSymbol(interval->second.marker_);
+		(*symbol).setHeight(interval->second.height_);
+		ostringstream text;
+		text << interval->first.min_ << "-" <<  interval->first.max_;   
+		legend.add(new SimpleSymbolEntry(interval->second.label_.empty() ? text.str() : interval->second.label_, symbol));
+		*/
+	} 	
+	}
+    else {
+    	//legend.add(new LegendEntry("Not Yet available"));
+    }
+
+}
diff --git a/src/visualisers/WindPlotting.h b/src/visualisers/WindPlotting.h
new file mode 100644
index 0000000..c46c452
--- /dev/null
+++ b/src/visualisers/WindPlotting.h
@@ -0,0 +1,126 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file WindPlotting.h
+    \brief Definition of the Template class WindPlotting.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Thu 17-Mar-2005
+    
+    Changes:
+    
+*/
+
+#ifndef WindPlotting_H
+#define WindPlotting_H
+
+#include "magics.h"
+#include "MagTranslator.h"
+#include "Factory.h"
+#include "WindPlottingAttributes.h"
+#include "IntervalMap.h"
+#include "Transformation.h"
+
+namespace magics {
+
+
+
+class WindPlotting  :public WindPlottingAttributes,
+public LevelSelectionInterface,
+public ColourTechniqueInterface
+{
+
+public:
+	WindPlotting();
+	virtual ~WindPlotting() {}
+	virtual void set(const map<string, string>& map) { WindPlottingAttributes::set(map);  } ;
+	virtual void set(const XmlNode& node) { WindPlottingAttributes::set(node); }
+	virtual bool accept(const string& key) { return WindPlottingAttributes::accept(key); }
+	virtual void toxml(ostream&) {}
+	virtual WindPlotting* clone() { return 0; };
+	virtual void operator()(const UserPoint&, const PaperPoint&, double, double, double = 0) {}
+
+	virtual void prepare(BasicGraphicsObjectContainer&,double) {}
+	virtual void prepare(BasicGraphicsObjectContainer&) {}
+	virtual void finish(BasicGraphicsObjectContainer&) {}
+	virtual void visit(LegendVisitor&);
+	virtual void visit(Data&, PointsHandler&, HistoVisitor&) {};
+	virtual void adjust( CustomisedPointsList&,const Transformation&);
+	bool needLegend() { return legend_; }
+	Colour& colour(Colour& Colour, double, double, double);
+	
+	Colour& off(Colour& colour, double, double, double) { return colour; }
+	Colour& advanced(Colour& colour, double, double, double);
+	
+	double value(double, double, double);	
+	double speed(double, double, double);
+	double parameter(double, double, double);	
+	int getCount() const { return count_; }
+	int getTolerance() const { return tolerance_; }
+	double getReference() const { return reference_; }
+	double getInterval() const { return interval_; }
+	double getMin() const { return min_; }
+	double getMax() const { return max_; }
+	const Colour& getMinColour() const { return *minColour_; }
+	const Colour& getMaxColour() const { return *maxColour_; }
+	const string& getDirection() const { return direction_; }
+	stringarray getColours()  const { return colours_; }
+	floatarray getList()  const { return list_; }
+protected:
+     	 //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream& out) const
+	 {  out << "WindPlotting"; }
+	 typedef Colour& (WindPlotting::*AdvancedMethod)(Colour&, double, double, double);
+	 typedef double (WindPlotting::*ColouringMethod)(double, double, double);
+	 static map<string,  WindPlotting::AdvancedMethod > methods_;
+	 static map<string,  WindPlotting::ColouringMethod > colouringMethods_;
+	 IntervalMap<Colour>  map_;
+	 
+
+private:
+    //! Copy constructor - No copy allowed
+	WindPlotting(const WindPlotting&);
+    //! Overloaded << operator to copy - No copy allowed
+	WindPlotting& operator=(const WindPlotting&);
+	
+    
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const WindPlotting& p)
+		{ p.print(s); return s; }
+
+};
+
+template <>
+class MagTranslator<string, WindPlotting> { 
+public:
+	WindPlotting* operator()(const string& val ) {
+		 return SimpleObjectMaker<WindPlotting>::create(val);
+	}     
+	WindPlotting* magics(const string& param)
+	{
+		WindPlotting* object=0;
+		ParameterManager::update(param, object);
+		return object;
+	}
+
+};
+} // namespace magics
+
+#endif
diff --git a/src/web/MagConfig.cc b/src/web/MagConfig.cc
new file mode 100644
index 0000000..9b307f1
--- /dev/null
+++ b/src/web/MagConfig.cc
@@ -0,0 +1,90 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! 
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+
+
+#include "MagConfig.h"
+#include "MagLog.h"
+
+using namespace magics;
+using namespace json_spirit;
+
+
+MagConfigHandler::MagConfigHandler(const string& config, MagConfig& magics)
+{
+	ifstream is(config.c_str());
+
+	json_spirit::Value value;
+	try {
+		 json_spirit::read_or_throw( is, value );
+		 Object object = value.get_value< Object >();
+
+		 for (vector<Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+
+
+			 magics.callback(entry->name_, entry->value_);
+		   }
+	}
+	catch (std::exception e) {
+		  MagLog::fatal() << "Could not processed the file: " << config << ": " << e.what() << endl;
+		  abort();
+	}
+}
+
+MagConfigHandler::~MagConfigHandler()
+{
+	
+}
+
+void MagConfigHandler::dig(const json_spirit::Value&)
+{
+
+}
+
+void MagConfigHandler::print(ostream& out) const
+{
+	out << "MagConfigHandler[";
+	out << "]";
+}
+
+
+MagConfig::MagConfig()
+{
+
+}
+
+MagConfig::~MagConfig()
+{
+
+}
+
+
+
+
diff --git a/src/web/MagConfig.h b/src/web/MagConfig.h
new file mode 100644
index 0000000..291f7a6
--- /dev/null
+++ b/src/web/MagConfig.h
@@ -0,0 +1,90 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsgramDecoder.h
+    \brief Definition of the Template class EpsgramDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef MagConfig_H
+#define MagConfig_H
+
+#include "magics.h"
+
+
+
+#include "json_spirit.h"
+#include <limits>
+
+namespace magics {
+class MagConfig
+{
+public:
+	MagConfig();
+	~MagConfig();
+	virtual void callback(const string&, const json_spirit::Value&) = 0;
+
+};
+
+
+class MagConfigHandler
+
+{
+public:
+	MagConfigHandler(const string& config, MagConfig& object);
+	virtual ~MagConfigHandler();
+
+	void dig(const json_spirit::Value&);
+	void ignore(const json_spirit::Value&) {}
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+
+
+private:
+    //! Copy constructor - No copy allowed
+	MagConfigHandler(const MagConfigHandler&);
+    //! Overloaded << operator to copy - No copy allowed
+	MagConfigHandler& operator=(const MagConfigHandler&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const MagConfigHandler& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+
+
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/web/MagJSon.cc b/src/web/MagJSon.cc
new file mode 100644
index 0000000..9db6d40
--- /dev/null
+++ b/src/web/MagJSon.cc
@@ -0,0 +1,171 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include "MagJSon.h"
+
+
+using namespace magics;
+using namespace json_spirit;
+#include "XmlMagics.h"
+#include "XmlTree.h"
+
+
+MagJSon::MagJSon()
+{
+	patchs_["drivers"] = &MagJSon::drivers;
+	patchs_["definition"] = &MagJSon::definitions;
+}
+
+void MagJSon::execute(const string& magml, const map<string, string>& params)
+{
+	TempFile file;
+	
+	prepare(magml, params, file);
+	parse(file.name());
+}
+
+void MagJSon::parse(const string& file)
+{
+     MagLog::dev()<< "parse-->" << file.c_str() << endl; 
+
+		ifstream is( file.c_str());
+		json_spirit::Value value;      
+		json_spirit::read_or_throw( is, value );
+		magics(value);
+}
+
+void MagJSon::interpret(const string& def)
+{
+     MagLog::dev()<< "interpret-->" << def << endl;
+     istringstream is(def);
+
+	json_spirit::Value value;
+	json_spirit::read_or_throw(is, value );
+	assert( value.type() == obj_type );
+	Object object = value.get_value< Object >();
+	//buils the Magics XmlNode!
+	build(*tree_.root(), "magics", object);
+}
+
+void MagJSon::drivers(XmlNode& parent, const json_spirit::Value& value)
+{
+	assert (value.type() == array_type);
+	XmlNode* drivers = new XmlNode("drivers");
+	parent.push_back(drivers);
+	 Array all =  value.get_value< Array >();
+	
+	 for (Array::iterator entry = all.begin(); entry != all.end(); ++entry) {
+		 assert( entry->type() == obj_type);
+		 Object driver = entry->get_value< Object >();	     		
+		 map<string, string> attributes;
+		 for (vector<Pair>::const_iterator elt = driver.begin(); elt !=  driver.end(); ++elt) {
+	    	assert(elt->value_.type() == str_type);
+	    	attributes.insert(make_pair(elt->name_, elt->value_.get_value< string >()));
+	     }
+		 map<string, string>::iterator format = attributes.find("format");
+		 assert(format!=attributes.end());
+		 drivers->push_back(tree_.newNode(format->second, attributes));
+	  }
+}
+
+
+void MagJSon::definitions(XmlNode& parent, const json_spirit::Value& value)
+{
+	assert (value.type() == array_type);
+
+	XmlNode* definitions = new XmlNode("definition");
+	tree_.definition(definitions);
+	
+	 Array all =  value.get_value< Array >();
+	 for (Array::iterator entry = all.begin(); entry != all.end(); ++entry) {
+		 assert( entry->type() == obj_type);
+		 Object def = entry->get_value< Object >();	     		
+		 map<string, string> attributes;
+		 for (vector<Pair>::const_iterator elt = def.begin(); elt !=  def.end(); ++elt) {
+	    	assert(elt->value_.type() == str_type);
+	    	attributes.insert(make_pair(elt->name_, elt->value_.get_value< string >()));
+	     }
+		 map<string, string>::iterator type = attributes.find("class");
+		 assert(type!=attributes.end());
+		 definitions->push_back(tree_.newNode(type->second, attributes));
+	  }
+}
+
+
+void MagJSon::build(XmlNode& parent, const string& name, Object& object)
+{
+	map<string, string> attributes;
+	
+	for (vector<Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry)
+	{
+		      if ( entry->value_.type() == str_type) {
+		    	 attributes.insert(make_pair(entry->name_, entry->value_.get_value<string>()));
+		      }
+		      if ( entry->value_.type() == bool_type) {
+		    	  string value = entry->value_.get_value<bool>() ? "on" : "off";
+		    	  attributes.insert(make_pair(entry->name_, value));
+		      }
+		      if ( entry->value_.type() == int_type) {
+		    	  string value = tostring(entry->value_.get_value<int>());
+		    	  attributes.insert(make_pair(entry->name_, value));	    		    	
+		      }
+		      if ( entry->value_.type() ==real_type) {
+		    	  string value = tostring(entry->value_.get_value<double>());
+		    	  attributes.insert(make_pair(entry->name_, value));
+		      }
+	}
+	XmlNode* node = tree_.newNode(name, attributes);
+	parent.push_back(node);
+	for (vector<Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+			      
+			      // We can apply a patch ..
+			      map<string,  Patch >::iterator patch = patchs_.find(entry->name_);
+			      if ( patch != patchs_.end() ) {
+			    	  ( (this->*patch->second)(*node, entry->value_) );
+			            continue;
+			      }  	
+			     
+			      if  ( entry->value_.type() == obj_type) {
+			    	  Object object = entry->value_.get_value< Object >();
+			    	  build(*node, entry->name_, object);
+			      }
+			      if  ( entry->value_.type() == array_type) {
+			    	  
+			    	  	Array object =  entry->value_.get_value< Array >();
+			     		    for (Array::iterator val = object.begin(); val != object.end(); ++val) {
+			     		    	if ( val->type() == obj_type) {
+			     		    		Object object = val->get_value< Object >();	     		    		
+			     		    		build(*node, entry->name_, object);
+			     		    	}
+			     		    }
+			     	}
+		}
+}
+
+
+void MagJSon::magics(const json_spirit::Value& value)
+{
+	assert( value.type() == obj_type );
+	Object object = value.get_value< Object >();
+	
+	XmlMagics magics;
+	// buils the Magics XmlNode! 
+	build(*tree_.root(), "magics", object);
+
+	magics.execute(tree_);
+}
diff --git a/src/web/MagJSon.h b/src/web/MagJSon.h
new file mode 100644
index 0000000..f405c12
--- /dev/null
+++ b/src/web/MagJSon.h
@@ -0,0 +1,75 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file MagJSon.h
+    \brief Definition of the Template class MagJSon.
+    
+    Magics Team - ECMWF 2007
+    
+    Started: Tue 3-Apr-2007
+    
+    Changes:
+    
+*/
+
+#ifndef MagJSon_H
+#define MagJSon_H
+
+
+#include "WebFormat.h"
+#include "json_spirit.h"
+#include "XmlTree.h"
+
+namespace magics {
+
+
+
+class MagJSon : public WebFormat { 
+
+public:
+	MagJSon();
+	~MagJSon() {}
+    
+    void execute(const string&, const map<string, string>&);
+    
+
+    void magics(const json_spirit::Value&);
+    void build(XmlNode& parent, const string&, json_spirit::Object& object);
+    typedef void (MagJSon::*Patch)(XmlNode&, const json_spirit::Value&);
+     
+    map<string,  Patch > patchs_;
+    XmlTree tree_;
+    	
+    void drivers(XmlNode& parent, const json_spirit::Value&);
+    void definitions(XmlNode& parent, const json_spirit::Value& value);
+    void interpret(const string&);
+    
+protected:	
+	void print(ostream&) const {}
+	void parse(const string&);
+	
+
+
+};
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/web/Makefile.am b/src/web/Makefile.am
new file mode 100755
index 0000000..477bd20
--- /dev/null
+++ b/src/web/Makefile.am
@@ -0,0 +1,24 @@
+noinst_LTLIBRARIES	= libWeb.la
+
+include_H		= ObsJSon.h MagJSon.h WrepJSon.h json_spirit.h json_spirit_reader.h json_spirit_utils.h json_spirit_value.h json_spirit_writer.h MagConfig.h
+
+
+if MAGICS_ALLHEADERS
+include_HEADERS = $(include_H)
+noinst_HEADERS	= $(noinst_H)
+else
+include_HEADERS =
+noinst_HEADERS	= $(noinst_H) $(include_H)
+endif
+
+nodist_libWeb_la_SOURCES =
+libWeb_la_SOURCES	= MagJSon.cc WrepJSon.cc ObsJSon.cc ObsJSonAttributes.cc MagConfig.cc\
+			  WrepJSonAttributes.cc json_spirit_reader.cpp json_spirit_value.cpp json_spirit_writer.cpp
+libWeb_la_LDFLAGS	= -no-undefined -no-install
+
+AM_CPPFLAGS		= -I$(top_srcdir)/src -I$(top_srcdir)/src/basic -I$(top_srcdir)/src/terralib/kernel -I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/common -I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/visualisers
+
+if MAGICS_QT
+AM_CPPFLAGS += $(QT_CPPFLAGS)
+endif
+
diff --git a/src/web/Makefile.in b/src/web/Makefile.in
new file mode 100644
index 0000000..ec83ac2
--- /dev/null
+++ b/src/web/Makefile.in
@@ -0,0 +1,677 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_QT_TRUE@am__append_1 = $(QT_CPPFLAGS)
+subdir = src/web
+DIST_COMMON = $(am__include_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
+	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libWeb_la_LIBADD =
+am_libWeb_la_OBJECTS = MagJSon.lo WrepJSon.lo ObsJSon.lo \
+	ObsJSonAttributes.lo MagConfig.lo WrepJSonAttributes.lo \
+	json_spirit_reader.lo json_spirit_value.lo \
+	json_spirit_writer.lo
+nodist_libWeb_la_OBJECTS =
+libWeb_la_OBJECTS = $(am_libWeb_la_OBJECTS) \
+	$(nodist_libWeb_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+libWeb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(libWeb_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(libWeb_la_SOURCES) $(nodist_libWeb_la_SOURCES)
+DIST_SOURCES = $(libWeb_la_SOURCES)
+am__include_HEADERS_DIST = ObsJSon.h MagJSon.h WrepJSon.h \
+	json_spirit.h json_spirit_reader.h json_spirit_utils.h \
+	json_spirit_value.h json_spirit_writer.h MagConfig.h
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(includedir)"
+am__noinst_HEADERS_DIST = ObsJSon.h MagJSon.h WrepJSon.h json_spirit.h \
+	json_spirit_reader.h json_spirit_utils.h json_spirit_value.h \
+	json_spirit_writer.h MagConfig.h
+HEADERS = $(include_HEADERS) $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libWeb.la
+include_H = ObsJSon.h MagJSon.h WrepJSon.h json_spirit.h json_spirit_reader.h json_spirit_utils.h json_spirit_value.h json_spirit_writer.h MagConfig.h
+ at MAGICS_ALLHEADERS_FALSE@include_HEADERS = 
+ at MAGICS_ALLHEADERS_TRUE@include_HEADERS = $(include_H)
+ at MAGICS_ALLHEADERS_FALSE@noinst_HEADERS = $(noinst_H) $(include_H)
+ at MAGICS_ALLHEADERS_TRUE@noinst_HEADERS = $(noinst_H)
+nodist_libWeb_la_SOURCES = 
+libWeb_la_SOURCES = MagJSon.cc WrepJSon.cc ObsJSon.cc ObsJSonAttributes.cc MagConfig.cc\
+			  WrepJSonAttributes.cc json_spirit_reader.cpp json_spirit_value.cpp json_spirit_writer.cpp
+
+libWeb_la_LDFLAGS = -no-undefined -no-install
+AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/basic \
+	-I$(top_srcdir)/src/terralib/kernel \
+	-I$(top_srcdir)/src/decoders -I$(top_srcdir)/src/common \
+	-I$(top_srcdir)/src/drivers -I$(top_srcdir)/src/visualisers \
+	$(am__append_1)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .cpp .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/web/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu src/web/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libWeb.la: $(libWeb_la_OBJECTS) $(libWeb_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libWeb_la_LINK)  $(libWeb_la_OBJECTS) $(libWeb_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagConfig.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MagJSon.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsJSon.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ObsJSonAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WrepJSon.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/WrepJSonAttributes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/json_spirit_reader.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/json_spirit_value.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/json_spirit_writer.Plo at am__quote@
+
+.cc.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+	done
+
+uninstall-includeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+	for dir in "$(DESTDIR)$(includedir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-includeHEADERS install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-includeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/web/ObsJSon.cc b/src/web/ObsJSon.cc
new file mode 100644
index 0000000..8a00fc2
--- /dev/null
+++ b/src/web/ObsJSon.cc
@@ -0,0 +1,178 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! \file SpotDecoder.h
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+
+#include <locale>
+#include "ObsJSon.h"
+#include "CustomisedPoint.h"
+#include "json_spirit.h"
+#include "MetaData.h"
+
+using namespace magics;
+using namespace json_spirit;
+
+
+ObsJSon::ObsJSon() 
+{
+	methods_["latitude"] = &ObsJSon::latitude;
+	methods_["longitude"] = &ObsJSon::longitude;
+	methods_["type"] = &ObsJSon::type;
+	methods_["identifier"] = &ObsJSon::identifier;
+}
+
+ObsJSon::~ObsJSon()
+{
+}
+
+void ObsJSon::decode()
+{
+	points_.clear();
+
+	ifstream is( path_.c_str());
+
+	json_spirit::Value value;
+	try {
+		  json_spirit::read_or_throw(is, value );
+		  Object object = value.get_value< Object >();
+
+		  for (vector<Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+
+			  Array points = entry->value_.get_value< Array>();
+
+			  for (unsigned int i = 0; i < points.size(); i++) {
+
+				  points_.push_back(new CustomisedPoint());
+				  CustomisedPoint& current = *points_.back();
+				  Object point = points[i].get_value< Object >();
+				  for (vector<Pair>::const_iterator key = point.begin(); key !=  point.end(); ++key) {
+
+					  map<string,  Method >::iterator method = methods_.find(key->name_);
+					  if ( method != methods_.end() ) {
+					  	     (this->*method->second)(key->value_, current);
+					  }
+					  else {
+						  if ( key->value_.type() == real_type )
+							  current[key->name_] = key->value_.get_value< double>();
+						  if ( key->value_.type() == int_type )
+								  current[key->name_] = key->value_.get_value<int>();
+					  }
+				  }
+			  }
+		  }
+	 }
+	 catch (std::exception e)
+	 {
+		 MagLog::fatal() << "Could not processed the file: " << path_ << ": " << e.what() << endl;
+		 abort();
+	 }
+}
+
+void ObsJSon::print(ostream& out) const
+{	
+	out <<"ObsJSon[";
+	ObsJSonAttributes::print(out);
+	out << "]";
+}
+
+void ObsJSon::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	MagLog::dev() << "WrepJSon::customisedPoints" << *this <<endl;
+	
+	CustomisedPoint *point = new CustomisedPoint();
+
+	point->latitude(50.);
+	point->longitude(2.);
+
+	(*point)["temperature"] = 280.;
+
+	out.push_back(point);
+}
+
+void ObsJSon::customisedPoints(const Transformation&, const std::set<string>& what, CustomisedPointsList& out)
+{
+
+	decode();
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point) {
+			out.push_back(*point);
+			cout << **point << endl;
+	}
+}
+
+void ObsJSon::getInfo(const std::set<string>& what, multimap<string, string>& info)
+{
+
+	decode();
+	for (std::set<string>::const_iterator t = types_.begin(); t !=types_.end(); ++t) {
+
+			info.insert(make_pair("type", *t));
+	}
+}
+
+void ObsJSon::latitude(const json_spirit::Value& value, CustomisedPoint& point)
+{
+	assert( value.type() == real_type);
+	point.latitude(value.get_value< double>());
+}
+
+void ObsJSon::longitude(const json_spirit::Value& value, CustomisedPoint& point)
+{
+	assert( value.type() == real_type);
+	point.longitude(value.get_value< double>());
+}
+
+void ObsJSon::type(const json_spirit::Value& value, CustomisedPoint& point)
+{
+	assert( value.type() == str_type);
+	string type=value.get_value<string>();
+	point.type(type);
+	types_.insert(type);
+}
+
+void ObsJSon::identifier(const json_spirit::Value& value, CustomisedPoint& point)
+{
+	assert( value.type() == str_type);
+	string type=value.get_value<string>();
+	point.identifier(type);
+}
+
+void ObsJSon::visit(MetaDataVisitor& visitor)
+{
+
+	visitor.add("data", "{ \"objjson\": \"xxx\" }\n");
+
+	decode();
+	int i = 0;
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point) {
+
+		visitor.add("point_" + tostring(i), (*point)->identifier());
+		i++;
+	}
+}
diff --git a/src/web/ObsJSon.h b/src/web/ObsJSon.h
new file mode 100644
index 0000000..631f6a0
--- /dev/null
+++ b/src/web/ObsJSon.h
@@ -0,0 +1,106 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file ObsJSon.h
+    \brief Definition of the Template classBufrJSon.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2011
+    
+    Changes:
+    
+*/
+
+#ifndef ObsJSon_H
+#define ObsJSon_H
+
+#include "magics.h"
+
+
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "json_spirit.h"
+#include "ObsJSonAttributes.h"
+
+namespace magics {
+
+
+class ObsJSon:
+			public ObsJSonAttributes,
+			public Decoder,
+			public Data,
+			public PointsList
+{
+public:
+	ObsJSon();
+	virtual ~ObsJSon();
+	
+	void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList& );
+	void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+	{
+		customisedPoints(t, n, out);
+	}
+	PointsHandler& points(const Transformation&, bool) { assert(false); }
+
+	virtual void set(const map<string, string>& map) 	{ ObsJSonAttributes::set(map); }
+	virtual void set(const XmlNode& node) { ObsJSonAttributes::set(node); }
+	
+	void decode();
+	void  getInfo(const std::set<string>&, multimap<string, string>&);
+	void visit(MetaDataVisitor&);
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 vector<CustomisedPoint*> points_; 
+	 std::set<string>    types_;
+	 typedef void (ObsJSon::*Method)(const json_spirit::Value&, CustomisedPoint&);
+	 map<string,  Method > methods_;
+
+	 void latitude(const json_spirit::Value&, CustomisedPoint&);
+	 void longitude(const json_spirit::Value&, CustomisedPoint&);
+	 void type(const json_spirit::Value&, CustomisedPoint&);
+	 void identifier(const json_spirit::Value&, CustomisedPoint&);
+private:
+    //! Copy constructor - No copy allowed
+	ObsJSon(const ObsJSon&);
+    //! Overloaded << operator to copy - No copy allowed
+	ObsJSon& operator=(const ObsJSon&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const ObsJSon& p)
+		{ p.print(s); return s; }
+
+};
+
+
+
+
+
+
+
+
+
+
+
+} // namespace magics
+#endif
diff --git a/src/web/ObsJSonAttributes.cc b/src/web/ObsJSonAttributes.cc
new file mode 100644
index 0000000..9ebedf3
--- /dev/null
+++ b/src/web/ObsJSonAttributes.cc
@@ -0,0 +1,102 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file ObsJSonAttributes.cc
+    \brief Implementation of ObsJSon Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "ObsJSonAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+ObsJSonAttributes::ObsJSonAttributes():
+	path_(ParameterManager::getString("obsjson_input_filename"))
+{
+} 
+
+
+
+ObsJSonAttributes::~ObsJSonAttributes()
+{
+}
+
+    
+void ObsJSonAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "obsjson";
+
+	setAttribute(prefix, "obsjson_input_filename", path_, params);
+}
+
+void ObsJSonAttributes::copy(const ObsJSonAttributes& other)
+{
+	path_ = other.path_;
+} 
+
+
+bool ObsJSonAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "obsjson")  )
+		return true;
+	return false;
+}
+
+void ObsJSonAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "obsjson") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void ObsJSonAttributes::print(ostream& out)  const
+{
+	out << "ObsJSonAttributes[";
+	out << "path = " << path_;
+	out << "]" << "\n";
+}
+
+
+void ObsJSonAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"obsjson\"";
+	 out << ", \"obsjson_input_filename\":";
+	 niceprint(out,path_);
+}
+static MagicsParameter<string> obsjson_input_filename("obsjson_input_filename", "", "");
diff --git a/src/web/WrepJSon.cc b/src/web/WrepJSon.cc
new file mode 100644
index 0000000..fcc4431
--- /dev/null
+++ b/src/web/WrepJSon.cc
@@ -0,0 +1,1127 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+
+/*! 
+    \brief Implementation of the Template class SpotDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+ 
+
+#include <locale>
+#include "WrepJSon.h"
+#include "MetaData.h"
+#include "CustomisedPoint.h"
+#include "DateTime.h"
+#include "TextVisitor.h"
+#include "json_spirit.h"
+#include "IntervalMap.h"
+#include "EfiLegendEntry.h"
+
+using namespace magics;
+using namespace json_spirit;
+
+
+WrepJSon::WrepJSon()  : missing_(-9999),
+		height_(-9999),
+		mask_(9999),
+		station_latitude_(9999),
+		station_longitude_(9999), 
+		latitude_(0), longitude_(0)
+{
+	methods_["date"] = &WrepJSon::date;
+	methods_["time"] = &WrepJSon::time;
+	methods_["eps_height"] = &WrepJSon::epsz;
+	methods_["height"] = &WrepJSon::height;
+	methods_["deterministic_height"] = &WrepJSon::detz;
+	methods_["tracker"] = &WrepJSon::ignore;
+	methods_["missing"] = &WrepJSon::missing;
+	methods_["location"] = &WrepJSon::location;
+	methods_["requested_location"] = &WrepJSon::station;
+	methods_["land_sea_mask"] = &WrepJSon::mask;
+	methods_["metadata"] = &WrepJSon::metadata;
+	methods_["points_along_meridian"] = &WrepJSon::points_along_meridian;
+	
+	methods_["x_values"] = &WrepJSon::x_values;
+	methods_["x_date_values"] = &WrepJSon::x_date_values;
+	methods_["y_values"] = &WrepJSon::y_values;
+	methods_["y_date_values"] = &WrepJSon::y_date_values;
+
+	decoders_["eps"] = &WrepJSon::eps;
+	decoders_["profile"] = &WrepJSon::profile;
+	decoders_["efi"] = &WrepJSon::efi;
+	decoders_["cdf"] = &WrepJSon::cdf;
+	decoders_["basic"] = &WrepJSon::basic;
+	decoders_["data"] = &WrepJSon::data;
+	
+	transformationHandlers_["eps"] = &WrepJSon::eps;
+	transformationHandlers_["cdf"] = &WrepJSon::cdf;
+	transformationHandlers_["efi"] = &WrepJSon::efi;
+	transformationHandlers_["profile"] = &WrepJSon::profile;
+
+    heightCorrections_["forecast"] = &WrepJSon::correctDetz;
+    
+    metaMethods_["temperature_correction"] = &WrepJSon::temperature_correction;
+    metaMethods_["temperature_adjustment"] = &WrepJSon::temperature_adjustment;
+    metaMethods_["eps_resolution"] = &WrepJSon::eps_resolution;
+    metaMethods_["deterministic_resolution"] = &WrepJSon::deterministic_resolution;
+	
+	minx_ = std::numeric_limits<double>::max();
+	maxx_ = -std::numeric_limits<double>::max();
+	miny_ = std::numeric_limits<double>::max();
+	maxy_ = -std::numeric_limits<double>::max();
+	xdate_ = false;
+	ydate_ = false;
+
+}
+
+WrepJSon::~WrepJSon()
+{
+	
+}
+void WrepJSon::visit(Transformation& transformation)
+{
+	missing_ = missing_value_;
+	decode();
+	
+	if ( y_max_threshold_ < INT_MAX) 
+		maxy_ = (maxy_ < y_max_threshold_ )? y_max_threshold_ : maxy_; 
+ 
+
+	if ( miny_ == maxy_) {
+		if ( miny_ == missing_ )  {
+			miny_ = 0; 
+			maxy_ = 0; 
+		}
+		maxy_++;
+	}
+	map<string,  TransformationHandler>::iterator handler = transformationHandlers_.find(family_);
+
+	if ( handler !=  transformationHandlers_.end() ) {
+			       (this->*handler->second)(transformation);
+	}  		
+	else {
+		if ( xdate_ ) {
+			transformation.setDataMinX(minx_, xBase_);
+			transformation.setDataMaxX(maxx_, xBase_);
+		}
+		else {
+			transformation.setDataMinX(minx_);
+			transformation.setDataMaxX(maxx_);
+		}
+		if ( ydate_ ) {
+			transformation.setDataMinY(miny_, yBase_);
+			transformation.setDataMaxY(maxy_, yBase_);
+		}
+		else {
+			transformation.setDataMinY(miny_);
+			transformation.setDataMaxY(maxy_);
+		}
+
+	}
+}
+
+void WrepJSon::profile(Transformation& transformation)
+{
+
+	transformation.setDataMinX(minx_);
+	transformation.setDataMaxX(maxx_);
+
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy_);
+}
+void WrepJSon::eps(Transformation& transformation)
+{
+	transformation.setDataMinX(minx_  * 3600, base_);
+	transformation.setDataMaxX(maxx_ * 3600, base_);
+	
+	vector<double> maxs;
+	vector<double> allvalues;
+		
+		
+	for (vector<CustomisedPoint*>::iterator point = points_.begin(); point != points_.end(); ++point) {
+	    	maxs.push_back((**point)["max"]);
+	    	allvalues.push_back((**point)["seventyfive"]);
+	    	allvalues.push_back((**point)["ninty"]);
+	    	if ( (*point)->find("forecast") != (*point)->end() ) {
+	    		allvalues.push_back((**point)["forecast"]);
+	    		maxs.push_back((**point)["forecast"]);
+	    	}
+	    	if ( (*point)->find("control") != (*point)->end() ) {
+	    		allvalues.push_back((**point)["control"]);  
+	    		maxs.push_back((**point)["control"]);
+	    	}
+
+	    }
+	
+
+	
+	if ( threshold_ < 30) {
+	    	double limit = *std::max_element(allvalues.begin(), allvalues.end());
+	    	
+	    	std::sort(maxs.begin(), maxs.end());
+	    	double mm = maxs.back();
+	    
+	    	double p1 = 1;
+	    	double p2;
+	    	int i = maxs.size() -1 ;
+	    	int n = maxs.size();
+	    	for ( vector<double>::reverse_iterator val = maxs.rbegin(); val != maxs.rend(); ++val) {
+	    		p2 = (*val)/maxs.back();
+	    	
+	    		if ( p2 < (1 - i/n)*percentile_ && (p1-p2) > threshold_/n && *val >= limit ) {
+	    			mm = *val;  			
+	    		}
+	   			p1 = p2;    
+				i--;
+	    	}
+	    
+	    	maxy_ = std::max(mm, 1.);
+	    }
+	    
+	
+        miny_ = std::min(correctDetz(miny_), correctEpsz(miny_));
+        maxy_ = std::max(correctDetz(maxy_), correctEpsz(maxy_));
+
+	if ( same(miny_, maxy_) ) 
+        	maxy_ = miny_ +5.;
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy_);
+}
+void WrepJSon::cdf(Transformation& transformation)
+{
+	transformation.setDataMinX(minx_);
+	transformation.setDataMaxX(maxx_);
+	transformation.setDataMinY(0);
+	transformation.setDataMaxY(100);
+}
+void WrepJSon::efi(Transformation& transformation)
+{
+	transformation.setDataMinX(-100);
+	transformation.setDataMaxX(+100);
+	transformation.setDataMinY(miny_);
+	transformation.setDataMaxY(maxy_);
+}
+void WrepJSon::decode()
+{	
+	  map<string,  Decoder>::iterator decoder = decoders_.find(family_);
+
+	  if ( decoder != decoders_.end() ) {
+		       (this->*decoder->second)();
+		        		    	    }  		
+	  else 
+		  basic();
+	 
+}
+void WrepJSon::eps()
+{
+	if ( !points_.empty()) return;
+	
+	shift_ = 12;
+	methods_[param_] = &WrepJSon::parameter;
+	methods_[keyword_] = &WrepJSon::dig;
+	     
+    scaling_factor_ = param_scaling_factor_;
+    offset_factor_ = param_offset_factor_;    
+    file_ = path_;
+    current_ = &values_;
+    
+    basic();
+
+    
+   
+    base_ = DateTime(date_, time_);
+   
+    if ( values_.steps_.empty() ) {
+    	 MagLog::fatal() << "Could not find data for parameter: " << param_ << endl;
+    	 abort();
+    } 
+    minx_ = 0;
+    maxx_ = values_.steps_.back()+shift_;
+    vector<double> yval;
+    for (unsigned int i = 0; i < values_.steps_.size(); i++) {
+	map<string, vector<double> >::iterator values = values_.values_.find("1");
+	double value = (values ==  (values_.values_.end() ) ) ? 0 : values->second[i]; 
+	yval.push_back(value);
+    }
+    double yy =  *std::min_element(yval.begin(), yval.end());
+    MagLog::dev() << "minx= " <<  minx_ << "->maxx= " << maxx_ << endl;
+    map<string, vector<double> >::iterator intensity = values_.values_.find("intensity");
+    map<string, vector<double> >::iterator direction = values_.values_.find("direction");
+    map<string, vector<double> >::iterator val = values_.values_.find("1");
+	for (unsigned int i = 0; i < values_.steps_.size(); i++) {
+		
+		double value = (val ==  (values_.values_.end() ) ) ? 0 : val->second[i]; 
+		double speed = (intensity ==  (values_.values_.end() ) ) ? 0 : intensity->second[i]; 
+		double dir = (direction ==  (values_.values_.end() ) ) ? 0 : direction->second[i]; 
+		CustomisedPoint* point = new CustomisedPoint();		
+		point->longitude(values_.steps_[i] * 3600);		 
+		point->latitude(values_.steps_[i] * 3600);		 
+		(*point)["step"]    = values_.steps_[i] * 3600;
+		(*point)["x"]    = values_.steps_[i] * 3600;
+		(*point)["x_upper"]    = values_.steps_[i] * 3600;
+		(*point)["y_upper"]    = value;
+		(*point)["y_lower"]    = yy;
+		(*point)["y"]    = value;
+		(*point)["shift"] = 0;
+		(*point)["width"]    = 1 * 3600;
+		(*point)["intensity"]    = speed;
+		(*point)["direction"]    = dir;
+		(*point)["missing"]    = missing_;
+        (*point)["latitude"]    = latitude_;
+        (*point)["longitude"]    = longitude_;
+	
+		point->base(base_);
+		map<string, vector<double>  >& values = values_.values_;
+		
+		for ( map<string, vector<double>  >::iterator val = values.begin(); val != values.end(); ++val ) {
+            if ( val->first=="forecast" )  
+                 (*point)[val->first] = correctDetz((val->second)[i]);
+            else 
+			    (*point)[val->first] = correctEpsz((val->second)[i]);
+        }
+	
+		points_.push_back(point);
+	}
+	
+}
+void WrepJSon::profile()
+{
+	if ( !points_.empty()) return;
+
+	methods_[param_] = &WrepJSon::parameter;
+	methods_[keyword_] = &WrepJSon::dig;
+
+    scaling_factor_ = param_scaling_factor_;
+    offset_factor_ = param_offset_factor_;
+    file_ = path_;
+    current_ = &values_;
+
+    basic();
+
+
+
+
+
+    if ( values_.levels_.empty() ) {
+    	 MagLog::fatal() << "Could not find data for parameter: " << param_ << endl;
+    	 abort();
+    }
+    miny_ = values_.levels_.front();
+    maxy_ = values_.levels_.back();
+
+    MagLog::dev() << "minx= " <<  minx_ << "->maxx= " << maxx_ << endl;
+    map<string, vector<double> >::iterator intensity = values_.values_.find("intensity");
+    map<string, vector<double> >::iterator direction = values_.values_.find("direction");
+    map<string, vector<double> >::iterator val = values_.values_.find("1");
+    vector<double> minmax;
+
+	for (unsigned int i = 0; i < values_.levels_.size(); i++) {
+
+		double value = (val ==  (values_.values_.end() ) ) ? 0 : val->second[i];
+		double speed = (intensity ==  (values_.values_.end() ) ) ? 0 : intensity->second[i];
+		double dir = (direction ==  (values_.values_.end() ) ) ? 0 : direction->second[i];
+		CustomisedPoint* point = new CustomisedPoint();
+		point->longitude(value);
+		point->latitude(value);
+		(*point)["step"]    =value;
+		(*point)["x"]    = value;
+		(*point)["x_upper"]    = value;
+		(*point)["y_upper"]    = value;
+		(*point)["y_lower"]    = 1000;
+		(*point)["y"]    = values_.levels_[i];
+		(*point)["shift"] = 0;
+		(*point)["width"]    = 1 ;
+		(*point)["intensity"]    = speed;
+		(*point)["direction"]    = dir;
+		(*point)["missing"]    = missing_;
+        (*point)["latitude"]    = latitude_;
+        (*point)["longitude"]    = longitude_;
+
+		point->base(base_);
+		map<string, vector<double>  >& values = values_.values_;
+
+
+		for ( map<string, vector<double>  >::iterator val = values.begin(); val != values.end(); ++val ) {
+			if ( val->first=="forecast" ) {
+				double value =  (val->second)[i] == missing_ ? missing_ : correctDetz((val->second)[i]);
+
+				(*point)[val->first] = value;
+				if (value != missing_)
+					minmax.push_back(value);
+
+			}
+			else {
+				double value = (val->second)[i] == missing_ ? missing_ : correctEpsz((val->second)[i]);
+				(*point)[val->first] = value;
+				if (value != missing_)
+					minmax.push_back(value);
+
+			}
+
+		}
+
+		points_.push_back(point);
+	}
+
+	minx_ = *std::min_element(minmax.begin(), minmax.end());
+    maxx_ = *std::max_element(minmax.begin(), minmax.end());
+
+
+
+}
+void WrepJSon::customisedPoints(const Transformation& transformation, const std::set<string>& needs, CustomisedPointsList& out)
+{
+
+	decode();
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point) {
+		// Here we need to check we have date!
+		if ( xdate_ ) {
+			DateTime ref(transformation.getReferenceX());
+
+			double shift = ref - xBase_;
+			double x = (**point)["x"] - shift;
+			(**point)["x"] = x;
+		}
+		(**point)["resolution"] = points_along_meridian_;
+		out.push_back(*point);
+	}
+	points_.clear();
+
+}
+void WrepJSon::customisedPoints(const std::set<string>&, CustomisedPointsList& out)
+{
+	MagLog::dev() << "WrepJSon::customisedPoints" <<endl;
+	
+	decode();
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point) {
+		(**point)["resolution"] = points_along_meridian_;
+		out.push_back(*point);
+			
+
+	}
+}
+void WrepJSon::data()
+{
+	if ( points_.empty() ) {
+		methods_[keyword_] = &WrepJSon::dig;
+		file_ = path_;
+
+		basic();
+	}
+}
+
+void WrepJSon::basic()
+{
+	  ifstream is( file_.c_str());
+	    	 
+	     json_spirit::Value value;
+	         try {
+	        	  json_spirit::read_or_throw( is, value );
+	        	  Object object = value.get_value< Object >();
+	        		        
+	        	  for (vector<Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+	        		  map<string,  Method >::iterator method = methods_.find(entry->name_);
+	        		    	    if ( method != methods_.end() ) {
+	        		    	    	   ( (this->*method->second)(entry->value_) );
+	        		    	    }  		
+	        			    		
+	        	  }
+	         }
+	         catch (std::exception e)
+	         {
+	        	 MagLog::fatal() << "Could not processed the file: " << file_ << ": " << e.what() << endl;
+	        	 abort();
+	         }	
+}
+void WrepJSon::print(ostream& out) const
+{
+	out << "WrepJSon[";
+	out << "]";
+}
+
+void WrepJSon::metadata(const json_spirit::Value& value )
+{
+	metadata_ = value;
+	dig(value);
+}
+
+void WrepJSon::station(const json_spirit::Value& value )
+{
+	assert( value.type() == obj_type );
+	Object location = value.get_value<Object>();
+	const json_spirit::Value lat = find_value(location, "lat");
+	const json_spirit::Value lon = find_value(location, "lon");
+	station_latitude_=lat.get_value<double>();
+	station_longitude_=lon.get_value<double>();
+
+	MagLog::dev() << "found -> station_lat= " << station_latitude_ << endl;
+	MagLog::dev() << "found -> station_lon= " << station_longitude_ << endl;
+
+}
+
+void WrepJSon::location(const json_spirit::Value& value )
+{
+	
+	assert( value.type() == obj_type );
+	Object location = value.get_value<Object>();
+	const json_spirit::Value lat = find_value(location, "lat");
+	const json_spirit::Value lon = find_value(location, "lon");
+	latitude_=lat.get_value<double>();
+	longitude_=lon.get_value<double>();
+	MagLog::dev() << "found -> lat= " << latitude_ << endl;
+	MagLog::dev() << "found -> lon= " << longitude_ << endl;
+	
+}
+void WrepJSon::epsz(const json_spirit::Value& value)
+{
+	assert( value.type() == real_type);
+	epsz_ = value.get_value< double>();
+	MagLog::dev() << "found -> epsz= " <<  epsz_ << endl;
+}
+void WrepJSon::height(const json_spirit::Value& value)
+{
+    if ( value.type() == real_type) {
+     height_ = value.get_value< double>();
+    }
+    if ( value.type() == int_type) {
+       height_ = value.get_value< int>(); 
+    } 
+	MagLog::dev() << "found -> height= " <<  height_ << endl;
+}
+
+void WrepJSon::detz(const json_spirit::Value& value )
+{
+	assert( value.type() == real_type);
+	detz_ = value.get_value< double>();
+	MagLog::dev() << "found -> detz= " <<  detz_ << endl;
+}
+void WrepJSon::mask(const json_spirit::Value& value )
+{
+	assert( value.type() == real_type);
+	mask_ = value.get_value< double>();
+	MagLog::dev() << "found -> mask= " <<  mask_ << endl;
+}
+void WrepJSon::missing(const json_spirit::Value& value )
+{
+	assert( value.type() == str_type);
+	MagLog::dev() << "found -> missing= " <<  value.get_value<string>() << endl;
+	missing_ = tonumber(value.get_value<string>());
+}
+void WrepJSon::date(const json_spirit::Value& value)
+{
+	assert( value.type() == str_type);
+	MagLog::dev() << "found -> date= " <<  value.get_value<string>() << endl;
+	date_ =  value.get_value<string>();
+	
+}
+void WrepJSon::time(const json_spirit::Value& value)
+{
+	assert( value.type() == str_type);
+	MagLog::dev() << "found -> time= " <<  value.get_value<string>() << endl;
+	time_ =  value.get_value<string>();
+}
+
+void WrepJSon::parameter(const json_spirit::Value& value)
+{
+	assert( value.type() == obj_type );
+	Object param = value.get_value< Object >();
+	        		        
+	for (vector<Pair>::const_iterator info = param.begin(); info !=  param.end(); ++info) {
+				assert (info->value_.type() == array_type);
+	        	Array values = info->value_.get_value<Array>();
+	        	if ( info->name_ == "steps" ) {
+	        		for (unsigned int i = 0; i < values.size(); i++) {
+	        				current_->steps_.push_back( tonumber(values[i].get_value<string>()));
+	        			  
+	        	     }
+	        	}
+	        	else if ( info->name_ == "levels" ) {
+	        		for (unsigned int i = 0; i < values.size(); i++) {
+	        				current_->levels_.push_back( tonumber(values[i].get_value<string>()));
+
+	        	     }
+	        	}
+	        	else {
+	        		map<string, vector<double> >& xv = current_->values_;
+	        		xv.insert(make_pair(info->name_, vector<double>()));
+	        		vector<double>& vals =  xv[info->name_];
+				
+	        		for (unsigned int i = 0; i < values.size(); i++) {
+
+	        			double val = values[i].get_value<double>();
+	        			if ( val != missing_ ) {
+	        				val = (val * scaling_factor_) + offset_factor_;
+	        				if ( val < miny_) miny_ = val;
+	        				if ( val > maxy_) maxy_ = val;
+	        			}
+	        			vals.push_back(val);
+	        			
+	        			
+	        			
+	        		}
+	        	}
+	}
+	
+}
+void WrepJSon::dig(const json_spirit::Value& value)
+{
+	assert( value.type() == obj_type );
+	Object object = value.get_value< Object >();
+	  for (vector<Pair>::const_iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+      		  map<string,  Method >::iterator method = methods_.find(entry->name_);
+      		    	    if ( method != methods_.end() ) {
+      		    	    	   ( (this->*method->second)(entry->value_) );
+      		    	    }  		
+      			    		
+      	  }       		        
+	
+}
+
+MatrixHandler& WrepJSon::matrix()
+{
+	decode();
+	vector<double> values;
+	vector<double> steps;
+	// Find the min and the max ..
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+	{
+
+
+		 for ( int s = 0; s != 50; s++) {		    
+				string key = tostring(s);
+			    map<string, double>::const_iterator member = (*point)->find(key);
+				if ( member != (*point)->end() ) 
+					values.push_back(member->second );
+		 }
+
+		 steps.push_back((**point)["step"]);
+	}
+
+
+	double from = maground(*min_element(values.begin(), values.end())) - 1;
+	double to = maground(*max_element(values.begin(), values.end())) + 1 ;
+
+	IntervalMap<int> array;
+
+
+
+	for ( double a = from; a <= to; a = a + plumes_ ) {
+			array.insert(make_pair(Interval(a-plumes_, a+plumes_), 0));
+	}
+
+
+	
+	matrix_.set(array.size(), points_.size());
+	for (IntervalMap<int>::iterator interval = array.begin(); interval!= array.end(); ++interval) {
+		double row = (interval->first.max_ - interval->first.min_)/2 +interval->first.min_ ;
+		matrix_.rowsAxis().push_back(row);
+	}
+	for (vector<double>::iterator s = steps.begin(); s != steps.end(); ++s) {				
+		matrix_.columnsAxis().push_back(*s);
+	}
+
+	matrix_.setMapsAxis();
+	int column = 0;
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point)
+	{
+
+		for (IntervalMap<int>::iterator interval = array.begin(); interval!= array.end(); ++interval) {
+			interval->second = 0;
+		}
+		for ( int s = 0; s != 50; s++) {		    
+			string key = tostring(s);
+
+			map<string, double>::const_iterator step = (*point)->find(key);
+			if (step != (*point)->end() ) {
+			  IntervalMap<int>::iterator interval = array.get(step->second);
+			  interval->second++;
+		     }
+			}
+
+
+
+		int row = 0;
+		
+		for (IntervalMap<int>::iterator interval = array.begin(); interval!= array.end(); ++interval) {
+			list_.push_back(new UserPoint((**point)["step"], (interval->first.max_ - interval->first.min_)/2 + interval->first.min_, interval->second*2));
+			matrix_[column+row*steps.size()] = interval->second*2; // in percentage!
+			row++;
+		}
+	    column++;
+	}
+
+
+	matrix_.missing(std::numeric_limits<double>::max());
+	matrixHandlers_.push_back(new  MatrixHandler(matrix_));
+	return *(matrixHandlers_.back());
+}
+
+void WrepJSon::cdf() 
+{
+	if ( !clim_.empty() ) return;
+	
+	
+	 file_ = path_;
+	 methods_["clim"] =  &WrepJSon::clim;
+	 methods_["eps"] = &WrepJSon::eps;
+	 methods_["efi"] = &WrepJSon::efi;
+	 methods_[param_] =  &WrepJSon::parameter;
+	 scaling_factor_ = param_scaling_factor_;
+	 	offset_factor_ = param_offset_factor_;
+	 
+	    
+	basic();
+	// setminmax ...
+	minx_ = std::numeric_limits<double>::max();
+		maxx_ = -std::numeric_limits<double>::max();
+		for (map<string,  InputWrep>::iterator info = eps_.begin(); info !=  eps_.end(); ++info) {
+							
+							// find the index in the steps..
+							InputWrep& data = info->second;
+							int index = data.index(tonumber(info->first));
+							map<string, vector<double>  >& values = data.values_;					
+						
+							for (map<string,  vector<double> >::iterator val = values.begin(); val !=  values.end(); ++val) {
+								double value =  correctEpsz(val->second[index]);
+
+								if ( minx_ > value ) minx_ = value;
+								if ( maxx_ < value ) maxx_ = value;
+									
+							}
+							
+			}
+			int index = clim_.index(36);
+			for (map<string,  vector<double> >::iterator val = clim_.values_.begin(); val !=  clim_.values_.end(); ++val) {	
+				double value =  correctEpsz(val->second[index]);
+									if ( minx_ > value ) minx_ = value;
+									if ( maxx_ < value ) maxx_ = value;
+			}
+			
+
+			int steps = 1;
+			CustomisedPoint* point = new CustomisedPoint();		
+			points_.push_back(point);
+			(*point)["resolution"] = points_along_meridian_;
+			
+			for ( vector<int>::iterator step = steps_.begin(); step != steps_.end(); ++step) {
+				map<string,  InputWrep>::iterator info = eps_.find(tostring(*step));
+				if ( info != eps_.end() ) {
+						
+							// find the index in the steps..
+							InputWrep& data = info->second;
+							int s = tonumber(info->first);
+							int index = data.index(tonumber(info->first));
+							map<string, vector<double>  >& values = data.values_;		
+							ostringstream key;			
+							key << steps << "_step";
+							(*point)[key.str()] = s +12;
+							for (map<string,  vector<double> >::iterator val = values.begin(); val !=  values.end(); ++val) {			
+									if (isdigit(val->first[0]) == false ) continue;
+									ostringstream key;
+									int i = 2*tonumber(val->first);
+									key << steps << "_" << i;
+									(*point)[key.str()] = correctEpsz(val->second[index]);
+							}
+							steps++;
+				}
+			}
+			
+
+			
+			index = clim_.index(36);
+			for (map<string,  vector<double> >::iterator val = clim_.values_.begin(); val !=  clim_.values_.end(); ++val) {		
+									ostringstream key;									
+									key << "clim_" << val->first;
+									(*point)[key.str()] = correctEpsz(val->second[index]);
+			}
+}
+void WrepJSon::efi()
+{
+	if ( !efi_.empty() ) return;
+	
+	
+	 file_ = path_;
+	 methods_["clim"] =  &WrepJSon::ignore;
+	 methods_["eps"] = &WrepJSon::ignore;
+	 methods_["efi"] = &WrepJSon::efi;
+	 methods_[param_] =  &WrepJSon::parameter;
+
+	basic();
+	CustomisedPoint* point = new CustomisedPoint();		
+				points_.push_back(point);
+
+			int steps = 1;
+			
+
+			(*point)["steps"] = steps_.size();
+			
+			miny_ = steps_.size()+1;
+			maxy_ =  1;
+			
+			for ( vector<int>::iterator step = steps_.begin(); step != steps_.end(); ++step) {
+					int x = *step +12;
+					map<string,  InputWrep>::iterator info = efi_.find(tostring(x));
+					if ( info != efi_.end() ) {
+								
+								// find the index in the steps..
+								InputWrep& data = info->second;
+								int index = data.index(tonumber(info->first));
+								map<string, vector<double>  >& values = data.values_;		
+								ostringstream key;			
+								key << "efi" << steps << "_step";
+								(*point)[key.str()] = (tonumber(info->first)) +12;
+								for (map<string,  vector<double> >::iterator val = values.begin(); val !=  values.end(); ++val) {			
+										ostringstream key;
+										key << "efi" << steps << "_value";  
+										(*point)[key.str()] = val->second[index];		
+										
+								}
+								steps++;
+					}
+				}
+			
+}
+
+void WrepJSon::clim(const json_spirit::Value& value)
+{
+	
+	current_ = &clim_;
+	scaling_factor_ = param_scaling_factor_;
+	offset_factor_ = param_offset_factor_;
+	dig(value);
+	clim_.print();
+
+}
+void WrepJSon::efi(const json_spirit::Value& value)
+{
+	
+	assert( value.type() == obj_type );
+	Object param = value.get_value< Object >();
+	scaling_factor_ = 100;
+	offset_factor_ = 0;
+	        		        
+	for (vector<Pair>::const_iterator info = param.begin(); info !=  param.end(); ++info) {				
+	        	
+	        	efi_.insert(make_pair(info->name_, InputWrep()));
+	        	current_ = &(efi_[info->name_]);
+	        	dig(info->value_);   
+	  }
+	        
+	for (map<string,  InputWrep>::iterator info = efi_.begin(); info !=  efi_.end(); ++info) {
+		
+		info->second.print();
+	}
+	        
+	
+}
+
+void WrepJSon::eps(const json_spirit::Value& value)
+{
+	
+	scaling_factor_ = param_scaling_factor_;
+		offset_factor_ = param_offset_factor_;
+		assert( value.type() == obj_type );
+		Object param = value.get_value< Object >();
+		        		        
+		for (vector<Pair>::const_iterator info = param.begin(); info !=  param.end(); ++info) {				
+			        	
+			        	eps_.insert(make_pair(info->name_, InputWrep()));
+			        	current_ = &(eps_[info->name_]);
+			        	dig(info->value_);   
+			  }
+			        
+			for (map<string,  InputWrep>::iterator info = eps_.begin(); info !=  eps_.end(); ++info) {
+				
+				info->second.print();
+			}
+}
+	 
+double WrepJSon::correctDetz(double value)
+{
+
+    if (correction_ && height_ != -9999) {
+        double correction = ( height_ - detz_ ) * 0.0065;
+        
+        return value - correction;
+    }
+    
+    return value;
+  
+}
+
+double WrepJSon::correctEpsz(double value)
+{
+    if (correction_ && height_ != -9999) {
+        double correction = ( height_ - epsz_ ) * 0.0065;
+        
+        return value - correction;
+    }
+    
+    return value;
+   
+}
+
+void WrepJSon::visit(MetaDataVisitor& visitor)
+{
+
+
+	if (metadata_.type() == null_type) return;
+
+
+	// we visit the metadata to update it ..
+	Object object = metadata_.get_value< Object >();
+	for (vector<Pair>::iterator entry = object.begin(); entry !=  object.end(); ++entry) {
+
+		map<string,  MetaMethod >::iterator method = metaMethods_.find(entry->name_);
+		if ( method != metaMethods_.end() ) {
+			entry->value_ = ( (this->*method->second)() );
+		}
+	}
+
+	ostringstream json;
+	json_spirit::write(object, json);
+
+	visitor.add("metadata", json.str());
+
+
+
+}
+
+Value WrepJSon::temperature_correction()
+{
+	bool correction = (correction_ && height_ != -9999 );
+	Value value(correction);
+	return value;
+}
+Value  WrepJSon::temperature_adjustment()
+{
+	Value value;
+	if (correction_ && height_ != -9999) {
+		Object correction;;
+		correction.push_back(Pair( "deterministic_adjustement", -( height_ - detz_ ) * 0.0065  ) );
+		correction.push_back(Pair( "eps_adjustement", -( height_ - epsz_ ) * 0.0065  ) );
+		value = correction;
+	}
+	return value;
+
+}
+
+void WrepJSon::points_along_meridian(const json_spirit::Value& value)
+{
+	assert( value.type() == int_type);
+	points_along_meridian_ = value.get_value< int>();
+	MagLog::dev() << "found -> points_along_meridian_mask= " <<  mask_ << endl;
+}
+
+void WrepJSon::x_values(const json_spirit::Value& value)
+{
+	assert (value.type() == array_type);
+	Array values = value.get_value<Array>();
+	bool newpoint = points_.empty();
+	vector<double> minmax;
+
+	for (unsigned int i = 0; i < values.size(); i++) {
+		if ( newpoint ) {
+			CustomisedPoint* point = new CustomisedPoint();
+			(*point)["resolution"] = points_along_meridian_;
+			points_.push_back(point);
+		}
+		double val = values[i].get_value<double>();
+		if ( val == missing_ )  {
+			points_.back()->missing(true);
+		}
+		else
+			minmax.push_back(val);
+		(*points_[i])["x"] = val;
+
+	}
+	minx_ = *std::min_element(minmax.begin(), minmax.end());
+	maxx_ = *std::max_element(minmax.begin(), minmax.end());
+
+}
+void WrepJSon::y_values(const json_spirit::Value& value)
+{
+	assert (value.type() == array_type);
+	Array values = value.get_value<Array>();
+	bool newpoint = points_.empty();
+	vector<double> minmax;
+
+	for (unsigned int i = 0; i < values.size(); i++) {
+		if ( newpoint ) {
+			CustomisedPoint* point = new CustomisedPoint();
+			(*point)["resolution"] = points_along_meridian_;
+			points_.push_back(point);
+		}
+		double val = values[i].get_value<double>();
+		if ( val == missing_ )  {
+			points_[i]->missing(true);
+		}
+		else
+			minmax.push_back(val);
+		(*points_[i])["y"] = val;
+	}
+	if (minmax.empty()) {
+		miny_ = 0;
+		maxy_ = 1;
+		return;
+	}
+
+	miny_ = *std::min_element(minmax.begin(), minmax.end());
+	maxy_ = *std::max_element(minmax.begin(), minmax.end());
+}
+
+void WrepJSon::x_date_values(const json_spirit::Value& value)
+{
+
+	assert (value.type() == array_type);
+	Array values = value.get_value<Array>();
+	xdate_ = true;
+	xBase_ = DateTime(values[0].get_value<string>());
+	DateTime current;
+	bool newpoint = points_.empty();
+	vector<double> minmax;
+
+	for (unsigned int i = 0; i < values.size(); i++) {
+		current = DateTime(values[i].get_value<string>());
+
+		if ( newpoint ) {
+			CustomisedPoint* point = new CustomisedPoint();
+			(*point)["resolution"] = points_along_meridian_;
+			points_.push_back(point);
+		}
+		double val =  current - xBase_;
+		(*points_[i])["x"] = val;
+		minmax.push_back(val);
+	}
+	minx_ = *std::min_element(minmax.begin(), minmax.end());
+	maxx_ = *std::max_element(minmax.begin(), minmax.end());
+
+}
+
+void WrepJSon::y_date_values(const json_spirit::Value& value)
+{
+	assert (value.type() == array_type);
+	Array values = value.get_value<Array>();
+	ydate_ = true;
+	yBase_ = DateTime(values[0].get_value<string>());
+	DateTime current;
+	bool newpoint = points_.empty();
+	vector<double> minmax;
+
+	for (unsigned int i = 0; i < values.size(); i++) {
+		current = DateTime(values[i].get_value<string>());
+
+		if ( newpoint ) {
+			CustomisedPoint* point = new CustomisedPoint();
+			(*point)["resolution"] = points_along_meridian_;
+			points_.push_back(point);
+		}
+		double val =  current - yBase_;
+		(*points_[i])["y"] = val;
+		minmax.push_back(val);
+	}
+	miny_ = *std::min_element(minmax.begin(), minmax.end());
+	maxy_ = *std::max_element(minmax.begin(), minmax.end());
+
+}
+
+json_spirit::Value WrepJSon::eps_resolution()
+{
+	Value value(tostring(points_along_meridian_));
+	return value;
+}
+
+json_spirit::Value WrepJSon::deterministic_resolution()
+{
+	Value value(tostring(points_along_meridian_));
+	return value;
+}
+
+void WrepJSon::visit(TextVisitor& text)
+{
+
+	DateTime base(date_);
+
+
+	text.update("json", "date", base.tostring("%A %e %B %Y %H UTC"));
+	ostringstream location;
+	UserPoint point(longitude_, latitude_);
+	location << " " << point.asLatitude() << " " << point.asLongitude();
+	ostringstream height;
+
+	height << height_ <<  " m";
+	text.update("json", "height", height.str());
+	text.update("json", "location", location.str());
+	text.update("json", "grid_point", (mask_ < 0.5 ) ? " (EPS sea point) " : " (EPS land point) ");
+
+
+	ostringstream full_correction;
+	ostringstream short_correction;
+
+	int dett = (points_along_meridian_ * 2) -1;
+	int epst = points_along_meridian_ -1;
+	if ( (correction_ && height_ != -9999 && param_info_!= "none") ) {
+		full_correction << " reduced to the station height from " << maground(detz_) << " m (T" << dett << ") and " << maground(epsz_) <<  " m (T" << epst <<")";
+		short_correction << " reduced to the station height from " <<maground(epsz_) <<  " m (T" << epst <<")";
+	}
+
+	text.update("json", "full_temperature_correction_info", full_correction.str());
+	text.update("json", "short_temperature_correction_info", short_correction.str());
+	text.update("json", "parameter_info", (param_info_ == "none") ? "": param_info_ );
+
+
+
+
+	text.update("json", "product_info", product_info_);
+	text.update("json", "plumes_interval", tostring(plumes_));
+
+}
+
+void WrepJSon::points(const Transformation& transformation, vector<UserPoint>& points)
+{
+	decode();
+
+	for (vector<CustomisedPoint*>::const_iterator point = points_.begin(); point != points_.end(); ++point) {
+		// Here we need to check we have date!
+		double x = (**point)["x"];
+		if ( xdate_ ) {
+			DateTime ref(transformation.getReferenceX());
+			double shift = ref - xBase_;
+			x -= shift;
+		}
+		points.push_back(UserPoint(x, (**point)["y"]));
+		if ( (*point)->missing() )
+			points.back().flagMissing();
+	}
+}
+
+PointsHandler& WrepJSon::points(const Transformation& t, bool)
+{
+   pointsHandlers_.push_back(new PointsHandler(list_));
+   return *pointsHandlers_.back();
+}
diff --git a/src/web/WrepJSon.h b/src/web/WrepJSon.h
new file mode 100644
index 0000000..27e7e68
--- /dev/null
+++ b/src/web/WrepJSon.h
@@ -0,0 +1,225 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/*! \file EpsgramDecoder.h
+    \brief Definition of the Template class EpsgramDecoder.
+    
+    Magics Team - ECMWF 2005
+    
+    Started: Mon 19-Sep-2005
+    
+    Changes:
+    
+*/
+
+#ifndef EpsJSon_H
+#define EpsJSon_H
+
+#include "magics.h"
+
+
+#include "WrepJSonAttributes.h"
+
+#include "Decoder.h"
+#include "Data.h"
+#include "UserPoint.h"
+#include "DateTime.h"
+#include "json_spirit.h"
+#include "Matrix.h"
+#include <limits>
+
+namespace magics {
+
+
+struct InputWrep
+{
+	bool empty() { return steps_.empty(); }
+	 map<string, vector<double> > values_;
+	 vector<double> steps_;
+	 vector<double> levels_;
+	 int index(double val) {
+		 vector<double>::iterator step = steps_.begin();
+		 int index = 0;
+		 while ( *step != val ) {
+			 ++step;
+			 if ( step == steps_.end() ) {
+				 return -1; 
+			 }
+			 index++;
+		 }
+		 return index;
+	}
+	void print() {
+		 cout << "InputWrep" << endl;
+		 string sep = "steps[";
+		 for (vector<double>::iterator step = steps_.begin(); step != steps_.end(); ++ step) {
+			 cout << sep << *step;
+			 sep = ", ";
+		 }
+		 cout << "]" << endl;
+		 for (map< string, vector<double> >::iterator value = values_.begin(); value != values_.end(); ++ value) {
+			 string sep = value->first + "[";
+			 for (vector<double>::iterator val =  value->second.begin(); val !=  value->second.end(); ++ val) {
+			 	cout << sep << *val;
+			 	sep = ", ";
+			 }
+			 cout << "]" << endl;
+		}
+	}
+};
+
+
+class WrepJSon:
+			public Data,
+			public PointsList,
+			public WrepJSonAttributes 
+{
+public:
+	WrepJSon();
+	virtual ~WrepJSon();
+	
+	typedef void (WrepJSon::*Method)(const json_spirit::Value&);
+	typedef void (WrepJSon::*Decoder)();
+	typedef void (WrepJSon::*TransformationHandler)(Transformation&);
+    typedef double (WrepJSon::*HeightCorrection)(double);
+    typedef json_spirit::Value (WrepJSon::*MetaMethod)();
+	map<string,  Method> methods_;
+	map<string,  Decoder> decoders_;
+	map<string,  TransformationHandler> transformationHandlers_;
+	map<string,  HeightCorrection> heightCorrections_;
+	map<string,  MetaMethod> metaMethods_;
+
+	void efi();
+	void cdf();
+	void eps();
+	void basic();
+	void data();
+	void profile();
+	
+	void profile(Transformation&);
+	void eps(Transformation&);
+	void efi(Transformation&);
+	void cdf(Transformation&);
+	
+	void x_values(const json_spirit::Value&);
+	void y_values(const json_spirit::Value&);
+	void x_date_values(const json_spirit::Value&);
+	void y_date_values(const json_spirit::Value&);
+
+	void location(const json_spirit::Value&);
+	void epsz(const json_spirit::Value&);
+	void detz(const json_spirit::Value&);
+	void date(const json_spirit::Value&);
+	void height(const json_spirit::Value&);
+	void time(const json_spirit::Value&);
+	virtual void parameter(const json_spirit::Value&);
+	virtual void eps(const json_spirit::Value&);
+	virtual void clim(const json_spirit::Value&);
+	virtual void efi(const json_spirit::Value&);
+	void dig(const json_spirit::Value&);
+	void ignore(const json_spirit::Value&) {}
+	void missing(const json_spirit::Value&);
+	void mask(const json_spirit::Value&);
+	void station(const json_spirit::Value&);
+	void metadata(const json_spirit::Value&);
+	void temperature_correction(const json_spirit::Value&);
+	void points_along_meridian(const json_spirit::Value&);
+
+	json_spirit::Value temperature_correction();
+	json_spirit::Value temperature_adjustment();
+	json_spirit::Value eps_resolution();
+	json_spirit::Value deterministic_resolution();
+
+	MatrixHandler& matrix();
+	void customisedPoints(const std::set<string>&, CustomisedPointsList&);
+	void customisedPoints(const Transformation&, const std::set<string>&, CustomisedPointsList&);
+
+	virtual void set(const map<string, string>& map) 	{ WrepJSonAttributes::set(map);  }
+	virtual void set(const XmlNode& node) { WrepJSonAttributes::set(node); }
+	
+	virtual void visit(Transformation&);
+	virtual void visit(TextVisitor&);
+	void visit(const XmlNode& node);
+		
+	virtual void decode();
+    
+    double correctDetz(double);
+    double correctEpsz(double);
+
+    void visit(MetaDataVisitor&);
+    void points(const Transformation&, vector<UserPoint>&);
+    void customisedPoints(const Transformation& t, const std::set<string>& n, CustomisedPointsList& out, bool all)
+    {
+       	customisedPoints(t, n, out);
+     }
+     PointsHandler& points(const Transformation& t, bool);
+
+
+protected:
+     //! Method to print string about this class on to a stream of type ostream (virtual).
+	 virtual void print(ostream&) const; 
+	 DateTime base_;
+	 vector<CustomisedPoint*> points_; 
+	 PointsList list_;
+     double minx_;
+	 double maxx_;
+	 double miny_;
+	 double maxy_;
+	 double shift_;
+	 double missing_;
+	 double latitude_;
+	 double longitude_;
+	 double height_;
+     double epsz_;
+     double detz_;
+	 double scaling_factor_;
+	 double offset_factor_;
+	 double mask_;
+	 double station_latitude_;
+	 double station_longitude_;
+	 string date_;
+	 string time_;
+	 string file_;
+	 json_spirit::Value metadata_;
+	 InputWrep   values_;
+	 InputWrep* current_;
+	 InputWrep clim_;
+	 map<string, InputWrep> eps_;
+	 map<string, InputWrep> efi_;
+	 int points_along_meridian_;
+	 Matrix matrix_;
+
+	 bool xdate_;
+	 DateTime xBase_;
+	 bool ydate_;
+	 DateTime yBase_;
+
+private:
+    //! Copy constructor - No copy allowed
+	WrepJSon(const WrepJSon&);
+    //! Overloaded << operator to copy - No copy allowed
+	WrepJSon& operator=(const WrepJSon&);
+
+// -- Friends
+    //! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const WrepJSon& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
diff --git a/src/web/WrepJSonAttributes.cc b/src/web/WrepJSonAttributes.cc
new file mode 100644
index 0000000..1d60d6d
--- /dev/null
+++ b/src/web/WrepJSonAttributes.cc
@@ -0,0 +1,228 @@
+/*******************************  LICENSE  *******************************
+
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ *******************************  LICENSE  *******************************/
+
+/*! \file WrepJSonAttributes.cc
+    \brief Implementation of WrepJSon Attributes class.
+    \author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: Wed Dec  5 12:07:16 2012
+*/    
+
+#include "WrepJSonAttributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+
+WrepJSonAttributes::WrepJSonAttributes():
+	path_(ParameterManager::getString("wrepjson_input_filename")),
+	param_info_(ParameterManager::getString("wrepjson_parameter_information")),
+	product_info_(ParameterManager::getString("wrepjson_product_information")),
+	family_(ParameterManager::getString("wrepjson_family")),
+	plumes_(ParameterManager::getDouble("wrepjson_plumes_interval")),
+	information_(ParameterManager::getBool("wrepjson_information")),
+	keyword_(ParameterManager::getString("wrepjson_keyword")),
+	station_name_(ParameterManager::getString("wrepjson_station_name")),
+	param_(ParameterManager::getString("wrepjson_parameter")),
+	param_scaling_factor_(ParameterManager::getDouble("wrepjson_parameter_scaling_factor")),
+	param_offset_factor_(ParameterManager::getDouble("wrepjson_parameter_offset_factor")),
+	clim_param_(ParameterManager::getString("wrepjson_clim_parameter")),
+	clim_step_(ParameterManager::getInt("wrepjson_clim_step")),
+	steps_(ParameterManager::getIntArray("wrepjson_steps")),
+	percentile_(ParameterManager::getDouble("wrepjson_y_axis_percentile")),
+	threshold_(ParameterManager::getDouble("wrepjson_y_axis_threshold")),
+	y_max_threshold_(ParameterManager::getDouble("wrepjson_y_max_threshold")),
+	correction_(ParameterManager::getBool("wrepjson_temperature_correction")),
+	missing_value_(ParameterManager::getDouble("wrepjson_missing_value"))
+{
+} 
+
+
+
+WrepJSonAttributes::~WrepJSonAttributes()
+{
+}
+
+    
+void WrepJSonAttributes::set(const std::map<string, string>& params)
+{
+	vector<string> prefix(1);
+	prefix[0] = "wrepjson";
+
+	setAttribute(prefix, "wrepjson_input_filename", path_, params);
+	setAttribute(prefix, "wrepjson_parameter_information", param_info_, params);
+	setAttribute(prefix, "wrepjson_product_information", product_info_, params);
+	setAttribute(prefix, "wrepjson_family", family_, params);
+	setAttribute(prefix, "wrepjson_plumes_interval", plumes_, params);
+	setAttribute(prefix, "wrepjson_information", information_, params);
+	setAttribute(prefix, "wrepjson_keyword", keyword_, params);
+	setAttribute(prefix, "wrepjson_station_name", station_name_, params);
+	setAttribute(prefix, "wrepjson_parameter", param_, params);
+	setAttribute(prefix, "wrepjson_parameter_scaling_factor", param_scaling_factor_, params);
+	setAttribute(prefix, "wrepjson_parameter_offset_factor", param_offset_factor_, params);
+	setAttribute(prefix, "wrepjson_clim_parameter", clim_param_, params);
+	setAttribute(prefix, "wrepjson_clim_step", clim_step_, params);
+	setAttribute(prefix, "wrepjson_steps", steps_, params);
+	setAttribute(prefix, "wrepjson_y_axis_percentile", percentile_, params);
+	setAttribute(prefix, "wrepjson_y_axis_threshold", threshold_, params);
+	setAttribute(prefix, "wrepjson_y_max_threshold", y_max_threshold_, params);
+	setAttribute(prefix, "wrepjson_temperature_correction", correction_, params);
+	setAttribute(prefix, "wrepjson_missing_value", missing_value_, params);
+}
+
+void WrepJSonAttributes::copy(const WrepJSonAttributes& other)
+{
+	path_ = other.path_;
+	param_info_ = other.param_info_;
+	product_info_ = other.product_info_;
+	family_ = other.family_;
+	plumes_ = other.plumes_;
+	information_ = other.information_;
+	keyword_ = other.keyword_;
+	station_name_ = other.station_name_;
+	param_ = other.param_;
+	param_scaling_factor_ = other.param_scaling_factor_;
+	param_offset_factor_ = other.param_offset_factor_;
+	clim_param_ = other.clim_param_;
+	clim_step_ = other.clim_step_;
+	steps_ = other.steps_;
+	percentile_ = other.percentile_;
+	threshold_ = other.threshold_;
+	y_max_threshold_ = other.y_max_threshold_;
+	correction_ = other.correction_;
+	missing_value_ = other.missing_value_;
+} 
+
+
+bool WrepJSonAttributes::accept(const string& node)
+{	
+	if ( magCompare(node, "wrepjson")  )
+		return true;
+	return false;
+}
+
+void WrepJSonAttributes::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+
+	if ( magCompare(node.name(), "wrepjson") )
+		set(node.attributes());
+	else {
+	}
+	for (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {
+	}
+}
+
+void WrepJSonAttributes::print(ostream& out)  const
+{
+	out << "WrepJSonAttributes[";
+	out << "path = " << path_;
+	out << ", param_info = " << param_info_;
+	out << ", product_info = " << product_info_;
+	out << ", family = " << family_;
+	out << ", plumes = " << plumes_;
+	out << ", information = " << information_;
+	out << ", keyword = " << keyword_;
+	out << ", station_name = " << station_name_;
+	out << ", param = " << param_;
+	out << ", param_scaling_factor = " << param_scaling_factor_;
+	out << ", param_offset_factor = " << param_offset_factor_;
+	out << ", clim_param = " << clim_param_;
+	out << ", clim_step = " << clim_step_;
+	out << ", steps = " << steps_;
+	out << ", percentile = " << percentile_;
+	out << ", threshold = " << threshold_;
+	out << ", y_max_threshold = " << y_max_threshold_;
+	out << ", correction = " << correction_;
+	out << ", missing_value = " << missing_value_;
+	out << "]" << "\n";
+}
+
+
+void WrepJSonAttributes::toxml(ostream& out)  const
+{
+     out <<  "\"wrepjson\"";
+	 out << ", \"wrepjson_input_filename\":";
+	 niceprint(out,path_);
+	 out << ", \"wrepjson_parameter_information\":";
+	 niceprint(out,param_info_);
+	 out << ", \"wrepjson_product_information\":";
+	 niceprint(out,product_info_);
+	 out << ", \"wrepjson_family\":";
+	 niceprint(out,family_);
+	 out << ", \"wrepjson_plumes_interval\":";
+	 niceprint(out,plumes_);
+	 out << ", \"wrepjson_information\":";
+	 niceprint(out,information_);
+	 out << ", \"wrepjson_keyword\":";
+	 niceprint(out,keyword_);
+	 out << ", \"wrepjson_station_name\":";
+	 niceprint(out,station_name_);
+	 out << ", \"wrepjson_parameter\":";
+	 niceprint(out,param_);
+	 out << ", \"wrepjson_parameter_scaling_factor\":";
+	 niceprint(out,param_scaling_factor_);
+	 out << ", \"wrepjson_parameter_offset_factor\":";
+	 niceprint(out,param_offset_factor_);
+	 out << ", \"wrepjson_clim_parameter\":";
+	 niceprint(out,clim_param_);
+	 out << ", \"wrepjson_clim_step\":";
+	 niceprint(out,clim_step_);
+	 out << ", \"wrepjson_steps\":";
+	 niceprint(out,steps_);
+	 out << ", \"wrepjson_y_axis_percentile\":";
+	 niceprint(out,percentile_);
+	 out << ", \"wrepjson_y_axis_threshold\":";
+	 niceprint(out,threshold_);
+	 out << ", \"wrepjson_y_max_threshold\":";
+	 niceprint(out,y_max_threshold_);
+	 out << ", \"wrepjson_temperature_correction\":";
+	 niceprint(out,correction_);
+	 out << ", \"wrepjson_missing_value\":";
+	 niceprint(out,missing_value_);
+}
+static MagicsParameter<string> wrepjson_input_filename("wrepjson_input_filename", "", "");
+static MagicsParameter<string> wrepjson_parameter_information("wrepjson_parameter_information", "", "");
+static MagicsParameter<string> wrepjson_product_information("wrepjson_product_information", "", "");
+static MagicsParameter<string> wrepjson_family("wrepjson_family", "eps", "");
+static MagicsParameter<double> wrepjson_plumes_interval("wrepjson_plumes_interval", 1, "");
+static MagicsParameter<string> wrepjson_information("wrepjson_information", "on", "");
+static MagicsParameter<string> wrepjson_keyword("wrepjson_keyword", "", "");
+static MagicsParameter<string> wrepjson_station_name("wrepjson_station_name", "", "");
+static MagicsParameter<string> wrepjson_parameter("wrepjson_parameter", "1", "");
+static MagicsParameter<double> wrepjson_parameter_scaling_factor("wrepjson_parameter_scaling_factor", 1, "");
+static MagicsParameter<double> wrepjson_parameter_offset_factor("wrepjson_parameter_offset_factor", 0, "");
+static MagicsParameter<string> wrepjson_clim_parameter("wrepjson_clim_parameter", "", "");
+static MagicsParameter<int> wrepjson_clim_step("wrepjson_clim_step", 36, "");
+static MagicsParameter<intarray> wrepjson_steps("wrepjson_steps", intarray(), "");
+static MagicsParameter<double> wrepjson_y_axis_percentile("wrepjson_y_axis_percentile", 1, "");
+static MagicsParameter<double> wrepjson_y_axis_threshold("wrepjson_y_axis_threshold", 50, "");
+static MagicsParameter<double> wrepjson_y_max_threshold("wrepjson_y_max_threshold", INT_MAX, "");
+static MagicsParameter<string> wrepjson_temperature_correction("wrepjson_temperature_correction", "off", "");
+static MagicsParameter<double> wrepjson_missing_value("wrepjson_missing_value", -9999, "");
diff --git a/src/web/json_spirit.h b/src/web/json_spirit.h
new file mode 100644
index 0000000..46f0936
--- /dev/null
+++ b/src/web/json_spirit.h
@@ -0,0 +1,20 @@
+#ifndef JASON_SPIRIT
+#define JASON_SPIRIT
+
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 4.00
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include "json_spirit_value.h"
+#include "json_spirit_reader.h"
+#include "json_spirit_writer.h"
+#include "json_spirit_utils.h"
+
+#endif
diff --git a/src/web/json_spirit_reader.cpp b/src/web/json_spirit_reader.cpp
new file mode 100644
index 0000000..deabd68
--- /dev/null
+++ b/src/web/json_spirit_reader.cpp
@@ -0,0 +1,755 @@
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 4.00
+
+#include "json_spirit_reader.h"
+#include "json_spirit_value.h"
+
+//#define BOOST_SPIRIT_THREADSAFE  // uncomment for multithreaded use, requires linking to boost.thead
+
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+#include <boost/version.hpp>
+
+#if BOOST_VERSION >= 103800
+    #include <boost/spirit/include/classic_core.hpp>
+    #include <boost/spirit/include/classic_confix.hpp>
+    #include <boost/spirit/include/classic_escape_char.hpp>
+    #include <boost/spirit/include/classic_multi_pass.hpp>
+    #include <boost/spirit/include/classic_position_iterator.hpp>
+    using namespace boost::spirit::classic;
+#else
+    #include <boost/spirit/core.hpp>
+    #include <boost/spirit/utility/confix.hpp>
+    #include <boost/spirit/utility/escape_char.hpp>
+    #include <boost/spirit/iterator/multi_pass.hpp>
+    #include <boost/spirit/iterator/position_iterator.hpp>
+    using namespace boost::spirit;
+#endif
+
+using namespace json_spirit;
+using namespace std;
+using namespace boost;
+
+//
+
+Error_position::Error_position()
+:   line_( 0 )
+,   column_( 0 )
+{
+}
+
+Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason )
+:   line_( line )
+,   column_( column )
+,   reason_( reason )
+{
+}
+
+bool Error_position::operator==( const Error_position& lhs ) const
+{
+    if( this == &lhs ) return true;
+
+    return ( reason_ == lhs.reason_ ) &&
+           ( line_   == lhs.line_ ) &&
+           ( column_ == lhs.column_ ); 
+}
+
+//
+
+namespace
+{
+    const int_parser < int64_t >  int64_p  = int_parser < int64_t  >();
+    const uint_parser< uint64_t > uint64_p = uint_parser< uint64_t >();
+
+    template< class Iter_type >
+    bool is_eq( Iter_type first, Iter_type last, const char* c_str )
+    {
+        for( Iter_type i = first; i != last; ++i, ++c_str )
+        {
+            if( *c_str == 0 ) return false;
+
+            if( *i != *c_str ) return false;
+        }
+
+        return true;
+    }
+
+    template< class Char_type >
+    Char_type hex_to_num( const Char_type c )
+    {
+        if( ( c >= '0' ) && ( c <= '9' ) ) return c - '0';
+        if( ( c >= 'a' ) && ( c <= 'f' ) ) return c - 'a' + 10;
+        if( ( c >= 'A' ) && ( c <= 'F' ) ) return c - 'A' + 10;
+        return 0;
+    }
+
+    template< class Char_type, class Iter_type >
+    Char_type hex_str_to_char( Iter_type& begin )
+    {
+        const Char_type c1( *( ++begin ) );
+        const Char_type c2( *( ++begin ) );
+
+        return ( hex_to_num( c1 ) << 4 ) + hex_to_num( c2 );
+    }       
+
+    template< class Char_type, class Iter_type >
+    Char_type unicode_str_to_char( Iter_type& begin )
+    {
+        const Char_type c1( *( ++begin ) );
+        const Char_type c2( *( ++begin ) );
+        const Char_type c3( *( ++begin ) );
+        const Char_type c4( *( ++begin ) );
+
+        return ( hex_to_num( c1 ) << 12 ) + 
+               ( hex_to_num( c2 ) <<  8 ) + 
+               ( hex_to_num( c3 ) <<  4 ) + 
+               hex_to_num( c4 );
+    }
+
+    template< class String_type >
+    void append_esc_char_and_incr_iter( String_type& s, 
+                                        typename String_type::const_iterator& begin, 
+                                        typename String_type::const_iterator end )
+    {
+        typedef typename String_type::value_type Char_type;
+             
+        const Char_type c2( *begin );
+
+        switch( c2 )
+        {
+            case 't':  s += '\t'; break;
+            case 'b':  s += '\b'; break;
+            case 'f':  s += '\f'; break;
+            case 'n':  s += '\n'; break;
+            case 'r':  s += '\r'; break;
+            case '\\': s += '\\'; break;
+            case '/':  s += '/';  break;
+            case '"':  s += '"';  break;
+            case 'x':  
+            {
+                if( end - begin >= 3 )  //  expecting "xHH..."
+                {
+                    s += hex_str_to_char< Char_type >( begin );  
+                }
+                break;
+            }
+            case 'u':  
+            {
+                if( end - begin >= 5 )  //  expecting "uHHHH..."
+                {
+                    s += unicode_str_to_char< Char_type >( begin );  
+                }
+                break;
+            }
+        }
+    }
+
+    template< class String_type >
+    String_type substitute_esc_chars( typename String_type::const_iterator begin, 
+                                   typename String_type::const_iterator end )
+    {
+        typedef typename String_type::const_iterator Iter_type;
+
+        if( end - begin < 2 ) return String_type( begin, end );
+
+        String_type result;
+        
+        result.reserve( end - begin );
+
+        const Iter_type end_minus_1( end - 1 );
+
+        Iter_type substr_start = begin;
+        Iter_type i = begin;
+
+        for( ; i < end_minus_1; ++i )
+        {
+            if( *i == '\\' )
+            {
+                result.append( substr_start, i );
+
+                ++i;  // skip the '\'
+             
+                append_esc_char_and_incr_iter( result, i, end );
+
+                substr_start = i + 1;
+            }
+        }
+
+        result.append( substr_start, end );
+
+        return result;
+    }
+
+    template< class String_type >
+    String_type get_str_( typename String_type::const_iterator begin, 
+                       typename String_type::const_iterator end )
+    {
+        assert( end - begin >= 2 );
+
+        typedef typename String_type::const_iterator Iter_type;
+
+        Iter_type str_without_quotes( ++begin );
+        Iter_type end_without_quotes( --end );
+
+        return substitute_esc_chars< String_type >( str_without_quotes, end_without_quotes );
+    }
+
+    string get_str( string::const_iterator begin, string::const_iterator end )
+    {
+        return get_str_< string >( begin, end );
+    }
+
+    wstring get_str( wstring::const_iterator begin, wstring::const_iterator end )
+    {
+        return get_str_< wstring >( begin, end );
+    }
+    
+    template< class String_type, class Iter_type >
+    String_type get_str( Iter_type begin, Iter_type end )
+    {
+        const String_type tmp( begin, end );  // convert multipass iterators to string iterators
+
+        return get_str( tmp.begin(), tmp.end() );
+    }
+
+    // this class's methods get called by the spirit parse resulting
+    // in the creation of a JSON object or array
+    //
+    // NB Iter_type could be a std::string iterator, wstring iterator, a position iterator or a multipass iterator
+    //
+    template< class Value_type, class Iter_type >
+    class Semantic_actions 
+    {
+    public:
+
+        typedef typename Value_type::Config_type Config_type;
+        typedef typename Config_type::String_type String_type;
+        typedef typename Config_type::Object_type Object_type;
+        typedef typename Config_type::Array_type Array_type;
+        typedef typename String_type::value_type Char_type;
+
+        Semantic_actions( Value_type& value )
+        :   value_( value )
+        ,   current_p_( 0 )
+        {
+        }
+
+        void begin_obj( Char_type c )
+        {
+            assert( c == '{' );
+
+            begin_compound< Object_type >();
+        }
+
+        void end_obj( Char_type c )
+        {
+            assert( c == '}' );
+
+            end_compound();
+        }
+
+        void begin_array( Char_type c )
+        {
+            assert( c == '[' );
+     
+            begin_compound< Array_type >();
+       }
+
+        void end_array( Char_type c )
+        {
+            assert( c == ']' );
+
+            end_compound();
+        }
+
+        void new_name( Iter_type begin, Iter_type end )
+        {
+            assert( current_p_->type() == obj_type );
+
+            name_ = get_str< String_type >( begin, end );
+        }
+
+        void new_str( Iter_type begin, Iter_type end )
+        {
+            add_to_current( get_str< String_type >( begin, end ) );
+        }
+
+        void new_true( Iter_type begin, Iter_type end )
+        {
+            assert( is_eq( begin, end, "true" ) );
+
+            add_to_current( true );
+        }
+
+        void new_false( Iter_type begin, Iter_type end )
+        {
+            assert( is_eq( begin, end, "false" ) );
+
+            add_to_current( false );
+        }
+
+        void new_null( Iter_type begin, Iter_type end )
+        {
+            assert( is_eq( begin, end, "null" ) );
+
+            add_to_current( Value_type() );
+        }
+
+        void new_int( int64_t i )
+        {
+            add_to_current( i );
+        }
+
+        void new_uint64( uint64_t ui )
+        {
+            add_to_current( ui );
+        }
+
+        void new_real( double d )
+        {
+            add_to_current( d );
+        }
+
+    private:
+
+        Value_type* add_first( const Value_type& value )
+        {
+            assert( current_p_ == 0 );
+
+            value_ = value;
+            current_p_ = &value_;
+            return current_p_;
+        }
+
+        template< class Array_or_obj >
+        void begin_compound()
+        {
+            if( current_p_ == 0 )
+            {
+                add_first( Array_or_obj() );
+            }
+            else
+            {
+                stack_.push_back( current_p_ );
+
+                Array_or_obj new_array_or_obj;   // avoid copy by building new array or object in place
+
+                current_p_ = add_to_current( new_array_or_obj );
+            }
+        }
+
+        void end_compound()
+        {
+            if( current_p_ != &value_ )
+            {
+                current_p_ = stack_.back();
+                
+                stack_.pop_back();
+            }    
+        }
+
+        Value_type* add_to_current( const Value_type& value )
+        {
+            if( current_p_ == 0 )
+            {
+                return add_first( value );
+            }
+            else if( current_p_->type() == array_type )
+            {
+                current_p_->get_array().push_back( value );
+
+                return &current_p_->get_array().back(); 
+            }
+            
+            assert( current_p_->type() == obj_type );
+
+            return &Config_type::add( current_p_->get_obj(), name_, value );
+        }
+
+        Value_type& value_;             // this is the object or array that is being created
+        Value_type* current_p_;         // the child object or array that is currently being constructed
+
+        vector< Value_type* > stack_;   // previous child objects and arrays
+
+        String_type name_;              // of current name/value pair
+    };
+
+    template< typename Iter_type >
+    void throw_error( position_iterator< Iter_type > i, const std::string& reason )
+    {
+        throw Error_position( i.get_position().line, i.get_position().column, reason );
+    }
+
+    template< typename Iter_type >
+    void throw_error( Iter_type i, const std::string& reason )
+    {
+       throw reason;
+    }
+
+    // the spirit grammer 
+    //
+    template< class Value_type, class Iter_type >
+    class Json_grammer : public grammar< Json_grammer< Value_type, Iter_type > >
+    {
+    public:
+
+        typedef Semantic_actions< Value_type, Iter_type > Semantic_actions_t;
+
+        Json_grammer( Semantic_actions_t& semantic_actions )
+        :   actions_( semantic_actions )
+        {
+        }
+
+        static void throw_not_value( Iter_type begin, Iter_type end )
+        {
+    	    throw_error( begin, "not a value" );
+        }
+
+        static void throw_not_array( Iter_type begin, Iter_type end )
+        {
+    	    throw_error( begin, "not an array" );
+        }
+
+        static void throw_not_object( Iter_type begin, Iter_type end )
+        {
+    	    throw_error( begin, "not an object" );
+        }
+
+        static void throw_not_pair( Iter_type begin, Iter_type end )
+        {
+    	    throw_error( begin, "not a pair" );
+        }
+
+        static void throw_not_colon( Iter_type begin, Iter_type end )
+        {
+    	    throw_error( begin, "no colon in pair" );
+        }
+
+        static void throw_not_string( Iter_type begin, Iter_type end )
+        {
+    	    throw_error( begin, "not a string" );
+        }
+
+        template< typename ScannerT >
+        struct definition
+        {
+            definition( const Json_grammer& self )
+            {
+                typedef typename Value_type::String_type::value_type Char_type;
+
+                // first we convert the semantic action class methods to functors with the 
+                // parameter signature expected by spirit
+
+                typedef function< void( Char_type )            > Char_action;
+                typedef function< void( Iter_type, Iter_type ) > Str_action;
+                typedef function< void( double )               > Real_action;
+                typedef function< void( int64_t )              > Int_action;
+                typedef function< void( uint64_t )             > Uint64_action;
+
+                Char_action   begin_obj  ( bind( &Semantic_actions_t::begin_obj,   &self.actions_, _1 ) );
+                Char_action   end_obj    ( bind( &Semantic_actions_t::end_obj,     &self.actions_, _1 ) );
+                Char_action   begin_array( bind( &Semantic_actions_t::begin_array, &self.actions_, _1 ) );
+                Char_action   end_array  ( bind( &Semantic_actions_t::end_array,   &self.actions_, _1 ) );
+                Str_action    new_name   ( bind( &Semantic_actions_t::new_name,    &self.actions_, _1, _2 ) );
+                Str_action    new_str    ( bind( &Semantic_actions_t::new_str,     &self.actions_, _1, _2 ) );
+                Str_action    new_true   ( bind( &Semantic_actions_t::new_true,    &self.actions_, _1, _2 ) );
+                Str_action    new_false  ( bind( &Semantic_actions_t::new_false,   &self.actions_, _1, _2 ) );
+                Str_action    new_null   ( bind( &Semantic_actions_t::new_null,    &self.actions_, _1, _2 ) );
+                Real_action   new_real   ( bind( &Semantic_actions_t::new_real,    &self.actions_, _1 ) );
+                Int_action    new_int    ( bind( &Semantic_actions_t::new_int,     &self.actions_, _1 ) );
+                Uint64_action new_uint64 ( bind( &Semantic_actions_t::new_uint64,  &self.actions_, _1 ) );
+
+                // actual grammer
+
+                json_
+                    = value_ | eps_p[ &throw_not_value ]
+                    ;
+
+                value_
+                    = string_[ new_str ] 
+                    | number_ 
+                    | object_ 
+                    | array_ 
+                    | str_p( "true" ) [ new_true  ] 
+                    | str_p( "false" )[ new_false ] 
+                    | str_p( "null" ) [ new_null  ]
+                    ;
+
+                object_ 
+                    = ch_p('{')[ begin_obj ]
+                    >> !members_
+                    >> ( ch_p('}')[ end_obj ] | eps_p[ &throw_not_object ] )
+                    ;
+
+                members_
+                    = pair_ >> *( ',' >> pair_ )
+                    ;
+
+                pair_
+                    = string_[ new_name ]
+                    >> ( ':' | eps_p[ &throw_not_colon ] )
+                    >> ( value_ | eps_p[ &throw_not_value ] )
+                    ;
+
+                array_
+                    = ch_p('[')[ begin_array ]
+                    >> !elements_
+                    >> ( ch_p(']')[ end_array ] | eps_p[ &throw_not_array ] )
+                    ;
+
+                elements_
+                    = value_ >> *( ',' >> value_ )
+                    ;
+
+                string_ 
+                    = lexeme_d // this causes white space inside a string to be retained
+                      [
+                          confix_p
+                          ( 
+                              '"', 
+                              *lex_escape_ch_p,
+                              '"'
+                          ) 
+                      ]
+                    ;
+
+                number_
+                    = strict_real_p[ new_real   ] 
+                    | int64_p      [ new_int    ]
+                    | uint64_p     [ new_uint64 ]
+                    ;
+            }
+
+            rule< ScannerT > json_, object_, members_, pair_, array_, elements_, value_, string_, number_;
+
+            const rule< ScannerT >& start() const { return json_; }
+        };
+
+        Semantic_actions_t& actions_;
+    };
+
+    template< class Iter_type, class Value_type >
+    Iter_type read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value )
+    {
+        Semantic_actions< Value_type, Iter_type > semantic_actions( value );
+     
+        const parse_info< Iter_type > info = parse( begin, end, 
+                                                    Json_grammer< Value_type, Iter_type >( semantic_actions ), 
+                                                    space_p );
+
+        if( !info.hit )
+        {
+            assert( false ); // in theory MagException should already have been thrown
+            throw_error( info.stop, "error" );
+        }
+
+        return info.stop;
+    }
+
+    template< class Iter_type, class Value_type >
+    void add_posn_iter_and_read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value )
+    {
+        typedef position_iterator< Iter_type > Posn_iter_t;
+
+        const Posn_iter_t posn_begin( begin, end );
+        const Posn_iter_t posn_end( end, end );
+     
+        read_range_or_throw( posn_begin, posn_end, value );
+    }
+
+    template< class Iter_type, class Value_type >
+    bool read_range( Iter_type& begin, Iter_type end, Value_type& value )
+    {
+        try
+        {
+            begin = read_range_or_throw( begin, end, value );
+
+            return true;
+        }
+        catch( ... )
+        {
+            return false;
+        }
+    }
+
+    template< class String_type, class Value_type >
+    void read_string_or_throw( const String_type& s, Value_type& value )
+    {
+        add_posn_iter_and_read_range_or_throw( s.begin(), s.end(), value );
+    }
+
+    template< class String_type, class Value_type >
+    bool read_string( const String_type& s, Value_type& value )
+    {
+        typename String_type::const_iterator begin = s.begin();
+
+        return read_range( begin, s.end(), value );
+    }
+
+    template< class Istream_type >
+    struct Multi_pass_iters
+    {
+        typedef typename Istream_type::char_type Char_type;
+        typedef istream_iterator< Char_type, Char_type > istream_iter;
+        typedef multi_pass< istream_iter > multi_pass_iter;
+
+        Multi_pass_iters( Istream_type& is )
+        {
+            is.unsetf( ios::skipws );
+
+            begin_ = make_multi_pass( istream_iter( is ) );
+            end_   = make_multi_pass( istream_iter() );
+        }
+
+        multi_pass_iter begin_;
+        multi_pass_iter end_;
+    };
+
+    template< class Istream_type, class Value_type >
+    bool read_stream( Istream_type& is, Value_type& value )
+    {
+        Multi_pass_iters< Istream_type > mp_iters( is );
+
+        return read_range( mp_iters.begin_, mp_iters.end_, value );
+    }
+
+    template< class Istream_type, class Value_type >
+    void read_stream_or_throw( Istream_type& is, Value_type& value )
+    {
+        const Multi_pass_iters< Istream_type > mp_iters( is );
+
+        add_posn_iter_and_read_range_or_throw( mp_iters.begin_, mp_iters.end_, value );
+    }
+}
+
+bool json_spirit::read( const std::string& s, Value& value )
+{
+    return read_string( s, value );
+}
+
+void json_spirit::read_or_throw( const std::string& s, Value& value )
+{
+    read_string_or_throw( s, value );
+}
+
+bool json_spirit::read( std::istream& is, Value& value )
+{
+    return read_stream( is, value );
+}
+
+void json_spirit::read_or_throw( std::istream& is, Value& value )
+{
+    read_stream_or_throw( is, value );
+}
+
+bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
+{
+    return read_range( begin, end, value );
+}
+
+void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value )
+{
+    begin = read_range_or_throw( begin, end, value );
+}
+
+#ifndef BOOST_NO_STD_WSTRING
+
+bool json_spirit::read( const std::wstring& s, wValue& value )
+{
+    return read_string( s, value );
+}
+
+void json_spirit::read_or_throw( const std::wstring& s, wValue& value )
+{
+    read_string_or_throw( s, value );
+}
+
+bool json_spirit::read( std::wistream& is, wValue& value )
+{
+    return read_stream( is, value );
+}
+
+void json_spirit::read_or_throw( std::wistream& is, wValue& value )
+{
+    read_stream_or_throw( is, value );
+}
+
+bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
+{
+    return read_range( begin, end, value );
+}
+
+void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value )
+{
+    begin = read_range_or_throw( begin, end, value );
+}
+
+#endif
+
+bool json_spirit::read( const std::string& s, mValue& value )
+{
+    return read_string( s, value );
+}
+
+void json_spirit::read_or_throw( const std::string& s, mValue& value )
+{
+    read_string_or_throw( s, value );
+}
+
+bool json_spirit::read( std::istream& is, mValue& value )
+{
+    return read_stream( is, value );
+}
+
+void json_spirit::read_or_throw( std::istream& is, mValue& value )
+{
+    read_stream_or_throw( is, value );
+}
+
+bool json_spirit::read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
+{
+    return read_range( begin, end, value );
+}
+
+void json_spirit::read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value )
+{
+    begin = read_range_or_throw( begin, end, value );
+}
+
+#ifndef BOOST_NO_STD_WSTRING
+
+bool json_spirit::read( const std::wstring& s, wmValue& value )
+{
+    return read_string( s, value );
+}
+
+void json_spirit::read_or_throw( const std::wstring& s, wmValue& value )
+{
+    read_string_or_throw( s, value );
+}
+
+bool json_spirit::read( std::wistream& is, wmValue& value )
+{
+    return read_stream( is, value );
+}
+
+void json_spirit::read_or_throw( std::wistream& is, wmValue& value )
+{
+    read_stream_or_throw( is, value );
+}
+
+bool json_spirit::read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
+{
+    return read_range( begin, end, value );
+}
+
+void json_spirit::read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value )
+{
+    begin = read_range_or_throw( begin, end, value );
+}
+
+#endif
diff --git a/src/web/json_spirit_reader.h b/src/web/json_spirit_reader.h
new file mode 100644
index 0000000..a6bb306
--- /dev/null
+++ b/src/web/json_spirit_reader.h
@@ -0,0 +1,77 @@
+#ifndef JASON_SPIRIT_READER
+#define JASON_SPIRIT_READER
+
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   json spirit version 4.00
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include "json_spirit_value.h"
+#include <iostream>
+
+namespace json_spirit
+{
+    // An Error_position MagException is thrown by the "read_or_throw" functions below on finding an error.
+    // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" 
+    // functions that return a bool.
+    //
+    struct Error_position
+    {
+        Error_position();
+        Error_position( unsigned int line, unsigned int column, const std::string& reason );
+        bool operator==( const Error_position& lhs ) const;
+        unsigned int line_;
+        unsigned int column_;
+        std::string reason_;
+    };
+
+    // functions to reads a JSON values
+
+    bool read( const std::string& s, Value& value );
+    bool read( std::istream&  is,    Value& value );
+    bool read( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
+
+    void read_or_throw( const std::string& s, Value& value );  
+    void read_or_throw( std::istream&  is,    Value& value );
+    void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, Value& value );
+
+#ifndef BOOST_NO_STD_WSTRING
+
+    bool read( const std::wstring& s, wValue& value );
+    bool read( std::wistream&  is,    wValue& value );
+    bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );    
+
+    void read_or_throw( const std::wstring& s, wValue& value );
+    void read_or_throw( std::wistream&  is,    wValue& value );
+    void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wValue& value );
+
+#endif
+
+    bool read( const std::string& s, mValue& value );
+    bool read( std::istream&  is,    mValue& value );
+    bool read( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
+
+    void read_or_throw( const std::string& s, mValue& value );  
+    void read_or_throw( std::istream&  is,    mValue& value );
+    void read_or_throw( std::string::const_iterator& begin, std::string::const_iterator end, mValue& value );
+
+#ifndef BOOST_NO_STD_WSTRING
+
+    bool read( const std::wstring& s, wmValue& value );
+    bool read( std::wistream&  is,    wmValue& value );
+    bool read( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );    
+
+    void read_or_throw( const std::wstring& s, wmValue& value );
+    void read_or_throw( std::wistream&  is,    wmValue& value );
+    void read_or_throw( std::wstring::const_iterator& begin, std::wstring::const_iterator end, wmValue& value );
+
+#endif
+}
+
+#endif
diff --git a/src/web/json_spirit_utils.h b/src/web/json_spirit_utils.h
new file mode 100644
index 0000000..73be8d0
--- /dev/null
+++ b/src/web/json_spirit_utils.h
@@ -0,0 +1,63 @@
+#ifndef JASON_SPIRIT_UTILS
+#define JASON_SPIRIT_UTILS
+
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 4.00
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include "json_spirit_value.h"
+#include <map>
+
+namespace json_spirit
+{ 
+    template< class Obj_t, class Map_t >
+    void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
+    {
+        mp_obj.clear();
+
+        for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
+        {
+            mp_obj[ i->name_ ] = i->value_;
+        }
+    }
+
+    template< class Obj_t, class Map_t >
+    void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
+    {
+        obj.clear();
+
+        for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
+        {
+            obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
+        }
+    }
+
+    typedef std::map< std::string, Value > Mapped_obj;
+
+#ifndef BOOST_NO_STD_WSTRING
+    typedef std::map< std::wstring, wValue > wMapped_obj;
+#endif
+
+    template< class Object_type, class String_type >
+    const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
+    {
+        for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
+        {
+            if( i->name_ == name )
+            {
+                return i->value_;
+            }
+        }
+
+        return Object_type::value_type::Value_type::null;
+    }
+}
+
+#endif
diff --git a/src/web/json_spirit_value.cpp b/src/web/json_spirit_value.cpp
new file mode 100644
index 0000000..dd5b50e
--- /dev/null
+++ b/src/web/json_spirit_value.cpp
@@ -0,0 +1,8 @@
+/* Copyright (c) 2007 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 2.00
+
+#include "json_spirit_value.h"
diff --git a/src/web/json_spirit_value.h b/src/web/json_spirit_value.h
new file mode 100644
index 0000000..c386d28
--- /dev/null
+++ b/src/web/json_spirit_value.h
@@ -0,0 +1,558 @@
+#ifndef JASON_SPIRIT_VALUE
+#define JASON_SPIRIT_VALUE
+
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 4.00
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <vector>
+#include <map>
+#include <string>
+#include <cassert>
+#include <boost/config.hpp> 
+#include <boost/cstdint.hpp> 
+#include <boost/shared_ptr.hpp> 
+
+namespace json_spirit
+{
+    enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type };
+
+    template< class Config >    // Config determines whether the value uses std::string or std::wstring and
+                                // whether JSON Objects are represented as vectors or maps
+    class Value_impl
+    {
+    public:
+
+        typedef Config Config_type;
+        typedef typename Config::String_type String_type;
+        typedef typename Config::Object_type Object;
+        typedef typename Config::Array_type Array;
+        typedef typename String_type::const_pointer Const_str_ptr;  // eg const char*
+
+        Value_impl();  // creates null value
+        Value_impl( Const_str_ptr      value ); 
+        Value_impl( const String_type& value );
+        Value_impl( const Object&      value );
+        Value_impl( const Array&       value );
+        Value_impl( bool               value );
+        Value_impl( int                value );
+        Value_impl( boost::int64_t     value );
+        Value_impl( boost::uint64_t    value );
+        Value_impl( double             value );
+
+        Value_impl( const Value_impl& other );
+
+        bool operator==( const Value_impl& lhs ) const;
+
+        Value_impl& operator=( const Value_impl& lhs );
+
+        Value_type type() const;
+
+        bool is_uint64() const;
+        bool is_null() const;
+
+        const String_type& get_str()    const;
+        const Object&      get_obj()    const;
+        const Array&       get_array()  const;
+        bool               get_bool()   const;
+        int                get_int()    const;
+        boost::int64_t     get_int64()  const;
+        boost::uint64_t    get_uint64() const;
+        double             get_real()   const;
+
+        Object& get_obj();
+        Array&  get_array();
+
+        template< typename T > T get_value() const;  // example usage: int    i = value.get_value< int >();
+                                                     // or             double d = value.get_value< double >();
+
+        static const Value_impl null;
+
+    private:
+
+        Value_type type_;
+
+        typedef boost::shared_ptr< Object > Object_ptr;
+        typedef boost::shared_ptr< Array > Array_ptr;
+
+        String_type str_;
+        Object_ptr obj_p_;
+        Array_ptr array_p_;
+        union
+        {
+           bool bool_;
+           boost::int64_t i_;
+           double d_;
+        };
+        bool is_uint64_;
+    };
+
+    // vector objects
+
+    template< class Config >
+    struct Pair_impl
+    {
+        typedef typename Config::String_type String_type;
+        typedef typename Config::Value_type Value_type;
+
+        Pair_impl( const String_type& name, const Value_type& value );
+
+        bool operator==( const Pair_impl& lhs ) const;
+
+        String_type name_;
+        Value_type value_;
+    };
+
+    template< class String >
+    struct Config_vector
+    {
+        typedef String String_type;
+        typedef Value_impl< Config_vector > Value_type;
+        typedef Pair_impl < Config_vector > Pair_type;
+        typedef std::vector< Value_type > Array_type;
+        typedef std::vector< Pair_type > Object_type;
+
+        static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value )
+        {
+            obj.push_back( Pair_type( name , value ) );
+
+            return obj.back().value_;
+        }
+                
+        static String_type get_name( const Pair_type& pair )
+        {
+            return pair.name_;
+        }
+                
+        static Value_type get_value( const Pair_type& pair )
+        {
+            return pair.value_;
+        }
+    };
+
+    // typedefs for ASCII
+
+    typedef Config_vector< std::string > Config;
+
+    typedef Config::Value_type  Value;
+    typedef Config::Pair_type   Pair;
+    typedef Config::Object_type Object;
+    typedef Config::Array_type  Array;
+
+    // typedefs for Unicode
+
+#ifndef BOOST_NO_STD_WSTRING
+
+    typedef Config_vector< std::wstring > wConfig;
+
+    typedef wConfig::Value_type  wValue;
+    typedef wConfig::Pair_type   wPair;
+    typedef wConfig::Object_type wObject;
+    typedef wConfig::Array_type  wArray;
+#endif
+
+    // map objects
+
+    template< class String >
+    struct Config_map
+    {
+        typedef String String_type;
+        typedef Value_impl< Config_map > Value_type;
+        typedef std::vector< Value_type > Array_type;
+        typedef std::map< String_type, Value_type > Object_type;
+        typedef typename Object_type::value_type Pair_type;
+
+        static Value_type& add( Object_type& obj, const String_type& name, const Value_type& value )
+        {
+            return obj[ name ] = value;
+        }
+                
+        static String_type get_name( const Pair_type& pair )
+        {
+            return pair.first;
+        }
+                
+        static Value_type get_value( const Pair_type& pair )
+        {
+            return pair.second;
+        }
+    };
+
+    // typedefs for ASCII
+
+    typedef Config_map< std::string > mConfig;
+
+    typedef mConfig::Value_type  mValue;
+    typedef mConfig::Object_type mObject;
+    typedef mConfig::Array_type  mArray;
+
+    // typedefs for Unicode
+
+#ifndef BOOST_NO_STD_WSTRING
+
+    typedef Config_map< std::wstring > wmConfig;
+
+    typedef wmConfig::Value_type  wmValue;
+    typedef wmConfig::Object_type wmObject;
+    typedef wmConfig::Array_type  wmArray;
+
+#endif
+
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    //
+    // implementation
+
+    template< class Config >
+    const Value_impl< Config > Value_impl< Config >::null;
+
+    template< class Config >
+    Value_impl< Config >::Value_impl()
+    :   type_( null_type )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( const Const_str_ptr value )
+    :   type_( str_type )
+    ,   str_( value )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( const String_type& value )
+    :   type_( str_type )
+    ,   str_( value )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( const Object& value )
+    :   type_( obj_type )
+    ,   obj_p_( new Object( value ) )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( const Array& value )
+    :   type_( array_type )
+    ,   array_p_( new Array( value ) )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( bool value )
+    :   type_( bool_type )
+    ,   bool_( value )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( int value )
+    :   type_( int_type )
+    ,   i_( value )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( boost::int64_t value )
+    :   type_( int_type )
+    ,   i_( value )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( boost::uint64_t value )
+    :   type_( int_type )
+    ,   i_( static_cast< boost::int64_t >( value ) )
+    ,   is_uint64_( true )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( double value )
+    :   type_( real_type )
+    ,   d_( value )
+    ,   is_uint64_( false )
+    {
+    }
+
+    template< class Config >
+    Value_impl< Config >::Value_impl( const Value_impl< Config >& other )
+    :   type_( other.type() )
+    ,   is_uint64_( other.is_uint64_ )
+    {
+        switch( type_ )
+        {
+            case str_type:   str_     = other.get_str();                               break;
+            case obj_type:   obj_p_   = Object_ptr( new Object( other.get_obj() ) );   break;
+            case array_type: array_p_ = Array_ptr ( new Array ( other.get_array() ) ); break;
+            case bool_type:  bool_    = other.get_bool();                              break;
+            case int_type:   i_       = other.get_int64();                             break;
+            case real_type:  d_       = other.get_real();                              break;
+            case null_type:                                                            break;
+            default: assert( false );
+        };
+    }
+
+    template< class Config >
+    Value_impl< Config >& Value_impl< Config >::operator=( const Value_impl& lhs )
+    {
+        Value_impl tmp( lhs );
+
+        std::swap( type_, tmp.type_ );
+        str_    .swap( tmp.str_ );
+        obj_p_  .swap( tmp.obj_p_ );
+        array_p_.swap( tmp.array_p_ );
+        std::swap( is_uint64_, tmp.is_uint64_ );
+
+        switch( type_ )
+        {
+            case bool_type:  std::swap( bool_,      tmp.bool_ );      break;
+            case int_type:   std::swap( i_,         tmp.i_ );         break;
+            case real_type:  std::swap( d_,         tmp.d_ );         break;
+	    default:  break;
+        };
+
+        return *this;
+    }
+
+    template< class Config >
+    bool Value_impl< Config >::operator==( const Value_impl& lhs ) const
+    {
+        if( this == &lhs ) return true;
+
+        if( type() != lhs.type() ) return false;
+
+        switch( type_ )
+        {
+            case str_type:   return get_str()   == lhs.get_str();
+            case obj_type:   return get_obj()   == lhs.get_obj();
+            case array_type: return get_array() == lhs.get_array();
+            case bool_type:  return get_bool()  == lhs.get_bool();
+            case int_type:   return ( get_int64() == lhs.get_int64() ) &&
+                                    ( is_uint64() == lhs.is_uint64() );
+            case real_type:  return get_real()  == lhs.get_real();
+            case null_type:  return true;
+        };
+
+        assert( false );
+
+        return false; 
+    }
+
+    template< class Config >
+    Value_type Value_impl< Config >::type() const
+    {
+        return type_;
+    }
+
+    template< class Config >
+    bool Value_impl< Config >::is_uint64() const
+    {
+        return is_uint64_;
+    }
+
+    template< class Config >
+    bool Value_impl< Config >::is_null() const
+    {
+        return type() == null_type;
+    }
+
+    template< class Config >
+    const typename Config::String_type& Value_impl< Config >::get_str() const
+    {
+        assert( type() == str_type );
+
+        return str_;
+    }
+
+    template< class Config >
+    const typename Value_impl< Config >::Object& Value_impl< Config >::get_obj() const
+    {
+        assert( type() == obj_type );
+
+        return *obj_p_;
+    }
+     
+    template< class Config >
+    const typename Value_impl< Config >::Array& Value_impl< Config >::get_array() const
+    {
+        assert( type() == array_type );
+
+        return *array_p_;
+    }
+     
+    template< class Config >
+    bool Value_impl< Config >::get_bool() const
+    {
+        assert( type() == bool_type );
+
+        return bool_;
+    }
+     
+    template< class Config >
+    int Value_impl< Config >::get_int() const
+    {
+        assert( type() == int_type );
+
+        return static_cast< int >( i_ );
+    }
+    
+    template< class Config >
+    boost::int64_t Value_impl< Config >::get_int64() const
+    {
+        assert( type() == int_type );
+
+        return i_;
+    }
+    
+    template< class Config >
+    boost::uint64_t Value_impl< Config >::get_uint64() const
+    {
+        assert( type() == int_type );
+
+        return static_cast< boost::uint64_t >( i_ );
+    }
+
+    template< class Config >
+    double Value_impl< Config >::get_real() const
+    {
+        if( type() == int_type )
+        {
+            return is_uint64() ? static_cast< double >( get_uint64() )
+                               : static_cast< double >( get_int64() );
+        }
+
+        assert( type() == real_type );
+
+        return d_;
+    }
+
+    template< class Config >
+    typename Value_impl< Config >::Object& Value_impl< Config >::get_obj()
+    {
+        assert( type() == obj_type );
+
+        return *obj_p_;
+    }
+
+    template< class Config >
+    typename Value_impl< Config >::Array& Value_impl< Config >::get_array()
+    {
+        assert( type() == array_type );
+
+        return *array_p_;
+    }
+
+    template< class Config >
+    Pair_impl< Config >::Pair_impl( const String_type& name, const Value_type& value )
+    :   name_( name )
+    ,   value_( value )
+    {
+    }
+
+    template< class Config >
+    bool Pair_impl< Config >::operator==( const Pair_impl< Config >& lhs ) const
+    {
+        if( this == &lhs ) return true;
+
+        return ( name_ == lhs.name_ ) && ( value_ == lhs.value_ );
+    }
+
+    // converts a C string, ie. 8 bit char array, to a string object
+    //
+    template < class String_type >
+    String_type to_str( const char* c_str )
+    {
+        String_type result;
+
+        for( const char* p = c_str; *p != 0; ++p )
+        {
+            result += *p;
+        }
+
+        return result;
+    }
+
+    //
+
+    namespace internal_
+    {
+        template< typename T >
+        struct Type_to_type
+        {
+        };
+
+        template< class Value > 
+        int get_value( const Value& value, Type_to_type< int > )
+        {
+            return value.get_int();
+        }
+       
+        template< class Value > 
+        boost::int64_t get_value( const Value& value, Type_to_type< boost::int64_t > )
+        {
+            return value.get_int64();
+        }
+       
+        template< class Value > 
+        boost::uint64_t get_value( const Value& value, Type_to_type< boost::uint64_t > )
+        {
+            return value.get_uint64();
+        }
+       
+        template< class Value > 
+        double get_value( const Value& value, Type_to_type< double > )
+        {
+            return value.get_real();
+        }
+       
+        template< class Value > 
+        typename Value::String_type get_value( const Value& value, Type_to_type< typename Value::String_type > )
+        {
+            return value.get_str();
+        }
+       
+        template< class Value > 
+        typename Value::Array get_value( const Value& value, Type_to_type< typename Value::Array > )
+        {
+            return value.get_array();
+        }
+       
+        template< class Value > 
+        typename Value::Object get_value( const Value& value, Type_to_type< typename Value::Object > )
+        {
+            return value.get_obj();
+        }
+       
+        template< class Value > 
+        bool get_value( const Value& value, Type_to_type< bool > )
+        {
+            return value.get_bool();
+        }
+    }
+
+    template< class Config >
+    template< typename T > 
+    T Value_impl< Config >::get_value() const
+    {
+        return internal_::get_value( *this, internal_::Type_to_type< T >() );
+    }
+}
+
+#endif
diff --git a/src/web/json_spirit_writer.cpp b/src/web/json_spirit_writer.cpp
new file mode 100644
index 0000000..e8c75d7
--- /dev/null
+++ b/src/web/json_spirit_writer.cpp
@@ -0,0 +1,329 @@
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 4.00
+
+#include "json_spirit_writer.h"
+#include "json_spirit_value.h"
+
+#include <cassert>
+#include <sstream>
+#include <iomanip>
+
+using namespace json_spirit;
+using namespace std;
+
+namespace
+{
+    template< typename Char_type >
+    Char_type to_hex( Char_type c )
+    {
+        assert( c <= 0xF );
+
+        if( c < 10 ) return '0' + c;
+
+        return 'A' + c - 10;
+    }
+
+    template< class String_type >
+    String_type non_printable_to_string( unsigned int c )
+    {
+        String_type result( 6, '\\' );
+
+        result[1] = 'u';
+
+        result[ 5 ] = to_hex( c & 0x000F ); c >>= 4;
+        result[ 4 ] = to_hex( c & 0x000F ); c >>= 4;
+        result[ 3 ] = to_hex( c & 0x000F ); c >>= 4;
+        result[ 2 ] = to_hex( c & 0x000F );
+
+        return result;
+    }
+
+    template< typename Char_type, class String_type >
+    bool add_esc_char( Char_type c, String_type& s )
+    {
+        switch( c )
+        {
+            case '"':  s += to_str< String_type >( "\\\"" ); return true;
+            case '\\': s += to_str< String_type >( "\\\\" ); return true;
+            case '\b': s += to_str< String_type >( "\\b"  ); return true;
+            case '\f': s += to_str< String_type >( "\\f"  ); return true;
+            case '\n': s += to_str< String_type >( "\\n"  ); return true;
+            case '\r': s += to_str< String_type >( "\\r"  ); return true;
+            case '\t': s += to_str< String_type >( "\\t"  ); return true;
+        }
+
+        return false;
+    }
+
+    template< class String_type >
+    String_type add_esc_chars( const String_type& s )
+    {
+        typedef typename String_type::const_iterator Iter_type;
+        typedef typename String_type::value_type     Char_type;
+
+        String_type result;
+
+        const Iter_type end( s.end() );
+
+        for( Iter_type i = s.begin(); i != end; ++i )
+        {
+            const Char_type c( *i );
+
+            if( add_esc_char( c, result ) ) continue;
+
+            const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c );
+
+            if( iswprint( unsigned_c ) )
+            {
+                result += c;
+            }
+            else
+            {
+                result += non_printable_to_string< String_type >( unsigned_c );
+            }
+        }
+
+        return result;
+    }
+
+    // this class generates the JSON text,
+    // it keeps track of the indentation level etc.
+    //
+    template< class Value_type, class Ostream_type >
+    class Generator
+    {
+        typedef typename Value_type::Config_type Config_type;
+        typedef typename Config_type::String_type String_type;
+        typedef typename Config_type::Object_type Object_type;
+        typedef typename Config_type::Array_type Array_type;
+        typedef typename String_type::value_type Char_type;
+        typedef typename Object_type::value_type Obj_member_type;
+
+    public:
+
+        Generator( const Value_type& value, Ostream_type& os, bool pretty )
+        :   os_( os )
+        ,   indentation_level_( 0 )
+        ,   pretty_( pretty )
+        {
+            output( value );
+        }
+
+    private:
+
+        void output( const Value_type& value )
+        {
+            switch( value.type() )
+            {
+                case obj_type:   output( value.get_obj() );   break;
+                case array_type: output( value.get_array() ); break;
+                case str_type:   output( value.get_str() );   break;
+                case bool_type:  output( value.get_bool() );  break;
+                case int_type:   output_int( value );         break;
+                case real_type:  os_ << showpoint << setprecision( 16 ) 
+                                     << value.get_real();     break;
+                case null_type:  os_ << "null";               break;
+                default: assert( false );
+            }
+        }
+
+        void output( const Object_type& obj )
+        {
+            output_array_or_obj( obj, '{', '}' );
+        }
+
+        void output( const Array_type& arr )
+        {
+            output_array_or_obj( arr, '[', ']' );
+        }
+
+        void output( const Obj_member_type& member )
+        {
+            output( Config_type::get_name( member ) ); space(); 
+            os_ << ':'; space(); 
+            output( Config_type::get_value( member ) );
+        }
+
+        void output_int( const Value_type& value )
+        {
+            if( value.is_uint64() )
+            {
+                os_ << value.get_uint64();
+            }
+            else
+            {
+               os_ << value.get_int64();
+            }
+        }
+
+        void output( const String_type& s )
+        {
+            os_ << '"' << add_esc_chars( s ) << '"';
+        }
+
+        void output( bool b )
+        {
+            os_ << to_str< String_type >( b ? "true" : "false" );
+        }
+
+        template< class T >
+        void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char )
+        {
+            os_ << start_char; new_line();
+
+            ++indentation_level_;
+            
+            for( typename T::const_iterator i = t.begin(); i != t.end(); ++i )
+            {
+                indent(); output( *i );
+
+                typename T::const_iterator next = i;
+
+                if( ++next != t.end())
+                {
+                    os_ << ',';
+                }
+
+                new_line();
+            }
+
+            --indentation_level_;
+
+            indent(); os_ << end_char;
+        }
+        
+        void indent()
+        {
+            if( !pretty_ ) return;
+
+            for( int i = 0; i < indentation_level_; ++i )
+            { 
+                os_ << "    ";
+            }
+        }
+
+        void space()
+        {
+            if( pretty_ ) os_ << ' ';
+        }
+
+        void new_line()
+        {
+            if( pretty_ ) os_ << '\n';
+        }
+
+        Ostream_type& os_;
+        int indentation_level_;
+        bool pretty_;
+    };
+
+    template< class Value_type, class Ostream_type >
+    void write_( const Value_type& value, Ostream_type& os, bool pretty )
+    {
+        Generator< Value_type, Ostream_type >( value, os, pretty );
+    }
+
+    template< class Value_type >
+    typename Value_type::String_type write_( const Value_type& value, bool pretty )
+    {
+        typedef typename Value_type::String_type::value_type Char_type;
+
+        basic_ostringstream< Char_type > os;
+
+        write_( value, os, pretty );
+
+        return os.str();
+    }
+}
+
+void json_spirit::write( const Value& value, std::ostream& os )
+{
+    write_( value, os, false );
+}
+
+void json_spirit::write_formatted( const Value& value, std::ostream& os )
+{
+    write_( value, os, true );
+}
+
+std::string json_spirit::write( const Value& value )
+{
+    return write_( value, false );
+}
+
+std::string json_spirit::write_formatted( const Value& value )
+{
+    return write_( value, true );
+}
+
+#ifndef BOOST_NO_STD_WSTRING
+
+void json_spirit::write( const wValue& value, std::wostream& os )
+{
+    write_( value, os, false );
+}
+
+void json_spirit::write_formatted( const wValue& value, std::wostream& os )
+{
+    write_( value, os, true );
+}
+
+std::wstring json_spirit::write( const wValue&  value )
+{
+    return write_( value, false );
+}
+
+std::wstring json_spirit::write_formatted( const wValue&  value )
+{
+    return write_( value, true );
+}
+
+#endif
+
+void json_spirit::write( const mValue& value, std::ostream& os )
+{
+    write_( value, os, false );
+}
+
+void json_spirit::write_formatted( const mValue& value, std::ostream& os )
+{
+    write_( value, os, true );
+}
+
+std::string json_spirit::write( const mValue& value )
+{
+    return write_( value, false );
+}
+
+std::string json_spirit::write_formatted( const mValue& value )
+{
+    return write_( value, true );
+}
+
+#ifndef BOOST_NO_STD_WSTRING
+
+void json_spirit::write( const wmValue& value, std::wostream& os )
+{
+    write_( value, os, false );
+}
+
+void json_spirit::write_formatted( const wmValue& value, std::wostream& os )
+{
+    write_( value, os, true );
+}
+
+std::wstring json_spirit::write( const wmValue&  value )
+{
+    return write_( value, false );
+}
+
+std::wstring json_spirit::write_formatted( const wmValue&  value )
+{
+    return write_( value, true );
+}
+
+#endif
diff --git a/src/web/json_spirit_writer.h b/src/web/json_spirit_writer.h
new file mode 100644
index 0000000..d76011c
--- /dev/null
+++ b/src/web/json_spirit_writer.h
@@ -0,0 +1,52 @@
+#ifndef JASON_SPIRIT_WRITER
+#define JASON_SPIRIT_WRITER
+
+/* Copyright (c) 2007-2009 John W Wilkinson
+
+   This source code can be used for any purpose as long as
+   this comment is retained. */
+
+// json spirit version 4.00
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include "json_spirit_value.h"
+#include <iostream>
+
+namespace json_spirit
+{
+    // functions to convert JSON Values to text, 
+    // the "formatted" versions add whitespace to format the output nicely
+
+    void         write          ( const Value& value, std::ostream&  os );
+    void         write_formatted( const Value& value, std::ostream&  os );
+    std::string  write          ( const Value& value );
+    std::string  write_formatted( const Value& value );
+
+#ifndef BOOST_NO_STD_WSTRING
+
+    void         write          ( const wValue& value, std::wostream& os );
+    void         write_formatted( const wValue& value, std::wostream& os );
+    std::wstring write          ( const wValue& value );
+    std::wstring write_formatted( const wValue& value );
+
+#endif
+
+    void         write          ( const mValue& value, std::ostream&  os );
+    void         write_formatted( const mValue& value, std::ostream&  os );
+    std::string  write          ( const mValue& value );
+    std::string  write_formatted( const mValue& value );
+
+#ifndef BOOST_NO_STD_WSTRING
+
+    void         write          ( const wmValue& value, std::wostream& os );
+    void         write_formatted( const wmValue& value, std::wostream& os );
+    std::wstring write          ( const wmValue& value );
+    std::wstring write_formatted( const wmValue& value );
+
+#endif
+}
+
+#endif
diff --git a/src/xml/ActionRoutines.xml b/src/xml/ActionRoutines.xml
new file mode 100644
index 0000000..729ff42
--- /dev/null
+++ b/src/xml/ActionRoutines.xml
@@ -0,0 +1,167 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<actionroutine name='pcont' root_object='Contour' xml='contour'>
+  <documentation>
+    This action routine adds contours to a plot. Its parameters control the
+    plotting of isolines and high/low markers.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pcoast' root_object='Coastlines' xml='coastlines'>
+  <documentation>
+    This action routine adds coastlines to a plot. Its parameters control the
+    plotting of coastlines and latitude/longitude grids and labels.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pwind' root_object='Wind' xml='wind'>
+  <documentation>
+    This action routine adds wind symbols to a plot. Its parameters control 
+    all aspects of wind plotting.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pobs' root_object='ObsPlotting' xml='observation'>
+  <documentation>
+    This action routine adds observation symbols to a plot.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='psymb' root_object='SymbolPlotting' xml='symbol'>
+  <documentation>
+    This action routine adds symbols to a plot.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pgraph' root_object='GraphPlotting' xml='graph'>
+  <documentation>
+    This action routine plots graphs such as curves.
+  </documentation>
+</actionroutine>
+
+<actionroutine name='pboxplot' root_object='BoxPlotVisualiser' xml='boxplot'>
+  <documentation>
+    This action routine plots boxplots.
+  </documentation>
+</actionroutine>
+
+<actionroutine name='ptaylor' root_object='TaylorProjection' xml='taylor'>
+  <documentation>
+    This action routine plots Taylor diagrams.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pline' root_object='SimplePolyline' xml='pline'>
+  <documentation>
+    This action routine plots (optionally filled) polylines over geographical
+    areas.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='ptext' root_object='TextVisitor' xml='text'>
+  <documentation>
+    This action routine adds text to a plot. Its parameters control all
+    aspects of the text, whether it is for titles or annotations.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pimage' root_object='ImagePlotting' xml='image'>
+  <documentation>
+    This action routine controls the plotting of satellite images.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pnew(SUPER_PAGE)' root_object='FortranRootSceneNode' xml='superpage'>
+  <documentation>
+    This action routine controls the superpage layout.
+  </documentation>
+</actionroutine>
+
+<actionroutine name='pnew(PAGE)' root_object='FortranSceneNode' xml='page'>
+  <documentation>
+    This action routine controls the page layout.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pnew(SUBPAGE)' root_object='FortranViewNode' xml='subpage'>
+  <documentation>
+    This action routine controls the subpage layout.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='pnetcdf' root_object='NetcdfDecoder' xml='netcdf'>
+  <documentation>
+    This action routine controls the handling of netcdf files.
+  </documentation>
+</actionroutine>
+
+
+<!--
+<actionroutine name='podb' root_object='OdbDecoder' xml='odb'>
+  <documentation>
+    This action routine controls the handling of odb data.
+  </documentation>
+</actionroutine>
+-->
+
+<actionroutine name='pgrib' root_object='GribDecoder' xml='grib'>
+  <documentation>
+    This action routine controls the handling of grib data.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='paxis' root_object='Axis' xml='axis'>
+  <documentation>
+    This action routine controls the plotting of axes
+  </documentation>
+</actionroutine>
+
+
+
+<actionroutine name='pmetgram' root_object='ClassicMtgDecoder' xml='metgram'>
+  <documentation>
+    This action routine plots a classic metgram.
+  </documentation>
+</actionroutine>
+
+<actionroutine name='peps' root_object='EpsgramDecoder' xml='eps'>
+  <documentation>
+    This action routine plots an EPS metgram.
+  </documentation>
+</actionroutine>
+
+<actionroutine name='legend' root_object='LegendVisitor' xml='legend'>
+  <documentation>
+    These parameters control the plotting of legends.
+  </documentation>
+</actionroutine>
+
+
+<actionroutine name='input_matrix' root_object='InputMatrix' xml='matrix'>
+  <documentation>
+    Parameters to set input data.
+  </documentation>
+</actionroutine>
+
+
+<!--
+<actionroutine name='pinfo' root_object='' xml='info'>
+  <documentation>
+    This action routine prints data about the used version of magics and its host.
+  </documentation>
+</actionroutine>
+-->
+</magics>
diff --git a/src/xml/Akima.xml b/src/xml/Akima.xml
new file mode 100644
index 0000000..75ba53c
--- /dev/null
+++ b/src/xml/Akima.xml
@@ -0,0 +1,69 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='Akima761Method' action='pcont' inherits='ContourMethod' used_by='ContourTechnique' directory='visualisers'>
+  <documentation>
+  Generates contour lines from an irregularly-distributed set of points.
+  </documentation>
+  
+  <parameter name='contour_akima_x_resolution' from='float' to='float'
+             member='resolutionX' default='1.5' xml='x_resolution'>
+         <documentation> X Resolution of the Akima output matrix </documentation>
+         <migration> New Magics: Parameter resolutionX sent to new Magics[AKIMA760].  </migration>
+         <release>Magics++0.1</release>
+         <related_info> url_path </related_info>
+  </parameter>
+  
+  <parameter name='contour_akima_y_resolution' from='float' to='float'
+             member='resolutionY' default='1.5' xml='y_resolution'>
+         <documentation> Y Resolution of the Akima output matrix </documentation>
+         <migration> New Magics: Parameter resolutionY sent to new Magics[AKIMA760].  </migration>
+         <release>Magics++0.1</release>
+         <related_info> url_path </related_info>
+  </parameter>
+</class>
+<class name='Akima760Method' action='pcont' inherits='ContourMethod' used_by='ContourTechnique' directory='visualisers'>
+  <documentation>
+  Generates contour lines from a regular/irregular grid of data points.
+  First a denser regular grid is created based on the original grid and then
+  the isolines are produced by applying a simple linear contouring algorithm.
+  The user may, by calling the parameter setting routines, 
+  select the interpolation level which defines the density of the output 
+  grid, which then determines the smoothness of the isolines.
+  </documentation>
+  <parameter name='contour_akima_x_resolution' from='float' to='float'
+             member='resolutionX' default='1.5' xml='x_resolution'>
+         <documentation>X resolution of Akima interpolation</documentation>
+         <migration> New Magics: Parameter resolutionX sent to new Magics[AKIMA760].  </migration>
+         <release>Magics++0.1</release>
+         <related_info> url_path </related_info>
+  </parameter>
+  <parameter name='contour_akima_y_resolution' from='float' to='float'
+             member='resolutionY' default='1.5' xml='y_resolution'>
+         <documentation>Y resolution of Akima interpolation</documentation>
+         <migration> New Magics: Parameter resolutionY sent to new Magics[AKIMA760].  </migration>
+         <release>Magics++0.1</release>
+         <related_info> url_path </related_info>
+  </parameter>
+</class>
+
+<class name='Akima474Method' xmltag='akima474'  prefix='akima' action='pcont' inherits='ContourMethod' used_by='ContourTechnique' directory='visualisers'>
+  <documentation>
+  Generates contour lines from a regular/irregular grid of data points.
+  First a denser regular grid is created based on the original grid and then
+  the isolines are produced by applying a simple linear contouring algorithm.
+  The user may, by calling the parameter setting routines, 
+  select the interpolation level which defines the density of the output  
+  grid, which then determines the smoothness of the isolines.
+  </documentation>
+  <parameter name='contour_akima_x_resolution' xml='x_resolution' from='float' to='float'
+             member='resolutionX' default='1.5'>
+         <documentation> X Resolution </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  <parameter name='contour_akima_y_resolution' xml='y_resolution' from='float' to='float'
+             member='resolutionY' default='1.5'>
+         <documentation> Y Resolution </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+</class>
+</magics>
diff --git a/src/xml/Axis.xml b/src/xml/Axis.xml
new file mode 100644
index 0000000..0612b96
--- /dev/null
+++ b/src/xml/Axis.xml
@@ -0,0 +1,372 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='Axis' directory='visualisers'  xmltag='axis' metview='maxis'>
+  <documentation> This object creates an axis for non-geographical plots. </documentation>
+ <parameter name='axis_orientation' from='string' to='string' member='orientation' 
+ 	default='horizontal' values='horizontal/vertical'>
+         <documentation> Orientation of axis  </documentation>
+  </parameter>
+ <parameter name='axis_position' from='string' to='string' member='position' default='automatic' values='bottom/top/left/right/automatic'>
+         <documentation> Position of the axes  </documentation>
+        
+  </parameter>
+
+  <parameter name='axis_type' from='string' to='AxisMethod' member='method' default='regular' >
+         <documentation> Method to position ticks on an axis  </documentation>
+         <option name='AxisMethod' fortran='regular' xml='regular' include='AxisMethod.h'/>
+         <option name='PositionListAxisMethod' fortran='position_list' xml='position_list' include='AxisMethod.h'/>
+         <option name='LogarithmicAxisMethod' fortran='logarithmic' xml='logarithmic' include='AxisMethod.h'/>
+         <option name='DateAxisMethod' fortran='date' xml='date' include='DateAxis.h'/> 
+         <option name='HyperAxisMethod' fortran='geoline' xml='geoline' include='AxisMethod.h'/>
+         <set value='position_list' name='axis_tick_position_list'/>
+         <set value='regular' name='axis_tick_interval'/> 
+         <set value='geoline' name='axis_tick_interval'/> 
+         <set value='date' name='axis_tick_interval'/> 
+  </parameter>
+  
+   <parameter name='axis_tick_interval' from='float' to='float' member='interval' xml='interval' default='INT_MAX' >
+         <documentation> Interval between ticks in user units </documentation>
+         <migration>Default changed from '1/7 of axis length' to'INT_MAX' </migration>
+  </parameter>
+  
+   <parameter name='axis_tick_position_list' from='floatarray' to='floatarray' member='positions' xml='position_list' default='floatarray()'>
+         <documentation> Array specifying the positions of ticks (in user coordinates!)</documentation>    
+         <migration>Units have changed from 'cm' to user coordinates</migration>
+  </parameter>
+
+  <parameter name='axis_line' from='string' to='bool' member='line' default='on' >
+         <documentation> Plot the axis line </documentation>  
+         <set value='on' name='axis_line_colour'/>
+         <set value='on' name='axis_line_style'/>
+         <set value='on' name='axis_line_thickness'/>
+             
+  </parameter>
+   <parameter name='axis_line_colour' from='string' to='Colour' member='line_colour' default='automatic'>
+         <documentation> Colour of axis line</documentation>
+  </parameter>
+  <parameter name='axis_line_style' from='string' to='LineStyle' member='line_style'  default='solid'>
+         <documentation> Line Style of axis line </documentation>
+  </parameter>
+ 
+
+  <parameter name='axis_line_thickness' from='int' to='int' member='line_thickness'  default='2'>
+         <documentation>Thickness of axis line </documentation>
+  </parameter>
+  
+  
+
+
+  <parameter name='axis_grid' from='string' to='bool' member='grid'  default='off' >
+         <documentation> Plot axis grid lines </documentation>
+         <set value='on' name='axis_grid_colour'/>
+         <set value='on' name='axis_grid_line_style'/>
+         <set value='on' name='axis_grid_thickness'/>
+         <set value='on' name='axis_grid_reference_level'/>
+         <set value='on' name='axis_grid_reference_colour'/>
+         <set value='on' name='axis_grid_reference_line_style'/>  
+         <set value='on' name='axis_grid_reference_thickness'/>
+  </parameter>
+ <parameter name='axis_grid_colour' from='string' to='Colour' member='grid_colour' default='yellow' >
+         <documentation>Colour of grid lines</documentation>
+         <migration>2.13.5 - Default changed fronm YELLOW to BLACK</migration>
+  </parameter>
+ <parameter name='axis_grid_line_style' from='string' to='LineStyle' member='grid_style'  default='solid'>
+         <documentation> Line style of grid  </documentation>
+  </parameter>
+  
+  <parameter name='axis_grid_thickness' from='int' to='int' member='grid_thickness'  default='1'>
+         <documentation> Thickness of grid lines </documentation>
+  </parameter>
+  <parameter name='axis_grid_reference_level' from='float' to='float' member='grid_reference_level'  default='INT_MAX'>
+         <documentation> value to be used as reference for the grid</documentation> 
+  </parameter>
+ <parameter name='axis_grid_reference_colour' from='string' to='Colour' member='grid_reference_colour' default='automatic' >
+         <documentation> Colour of the reference  grid line</documentation>
+  </parameter>
+  <parameter name='axis_grid_reference_line_style' from='string' to='LineStyle' member='grid_reference_style'  default='solid'>
+         <documentation> Line style of the reference  grid line  </documentation>
+  </parameter>
+  <parameter name='axis_grid_reference_thickness' from='int' to='int' member='grid_reference_thickness'  default='2'>
+         <documentation> Thickness of the reference grid line </documentation>
+  </parameter>
+
+  <parameter name='axis_title' from='string' to='bool' member='title' default='on' >
+         <documentation> Plot axis title  </documentation>
+		<set value='on' name ='axis_title_text'/>   
+		<set value='on' name ='axis_title_orientation'/>   
+		<set value='on' name ='axis_title_colour'/> 
+		<set value='on' name ='axis_title_height'/> 
+		<set value='on' name ='axis_title_font'/> 
+		<set value='on' name ='axis_title_font_style'/>          
+  </parameter>
+  
+  <parameter name='axis_title_text' from='string' to='string' member='title_text'  xml='text' default='' >
+         <documentation> The axis title text </documentation>
+  </parameter>
+  <parameter name='axis_title_orientation' from='string' to='string' member='title_orientation' xml='title_orientation' default='parallel' >
+         <documentation> Orientation of the axis title (HORIZONTAL/VERTICAL/PARALLEL) </documentation>
+  </parameter>
+  
+ <parameter name='axis_title_colour' from='string' to='Colour' member='title_colour' default='automatic' >
+         <documentation> Colour of axis title</documentation>
+  </parameter>
+
+  <parameter name='axis_title_height' from='float' to='float' member='title_height' default='0.4'>
+         <documentation> Height of axis title</documentation>
+  </parameter>
+
+
+  <parameter name='axis_title_font' from='string' to='string' member='title_font'  default='sansserif'>
+         <documentation>Font of axis title </documentation>
+  </parameter>
+
+  <parameter name='axis_title_font_style' from='string' to='string' member='title_font_style'  default='normal'  >
+         <documentation>Font style of axis title </documentation>
+  </parameter>
+  
+ 
+  <parameter name='axis_tick' from='string' to='bool' member='tick' default='on'>
+         <documentation> Plot ticks </documentation>
+          <set value='on' name='axis_tick_interval'/>  
+          <set value='on' name='axis_tick_position'/>
+  		  <set value='on' name='axis_tick_colour'/>
+  		  <set value='on' name='axis_tick_size'/>
+  		  <set value='on' name='axis_tick_thickness'/>  
+  </parameter>
+ <parameter name='axis_tick_position' from='string' to='string' member='tick_position'  default='out' values='out/in' >
+         <documentation> Tick position, if in the ticks will positioned inside the frame.</documentation>
+  </parameter>
+ 
+  <parameter name='axis_tick_colour' from='string' to='Colour' member='tick_colour'  default='automatic' >
+         <documentation> Colour of ticks</documentation>
+  </parameter>
+
+  <parameter name='axis_tick_size' from='float' to='float' member='tick_length'  default='0.175'>
+         <documentation> Size of ticks </documentation>
+  </parameter>
+
+  <parameter name='axis_tick_thickness' from='int' to='int' member='tick_thickness' xml='thickness' default='2'>
+         <documentation> Thickness of tick marks </documentation>
+  </parameter>
+   <parameter name='axis_tick_label' from='string' to='bool' member='label'  default='on'>
+         <documentation> Plot tick labels (ON/OFF) </documentation>
+  		  <set value='on' name='axis_tick_label_type'/>
+  		  <set value='on' name='axis_tick_label_frequency'/>
+  		  <set value='on' name='axis_tick_label_first'/>
+  		  <set value='on' name='axis_tick_label_last'/>   		 
+  		  <set value='on' name='axis_tick_label_position'/>
+  		  <set value='on' name='axis_tick_label_orientation'/> 
+  		  <set value='on' name='axis_tick_label_font'/>
+  		  <set value='on' name='axis_tick_label_font_style'/> 
+  		  <set value='on' name='axis_tick_label_colour'/>
+  		  <set value='on' name='axis_tick_label_height'/> 
+  		  
+  </parameter> 
+
+  
+  <parameter name='axis_tick_label_type' from='string' to='string' member='label_type' default='number' values='number/label_list/latitude/longitude'>
+        <documentation> Type of tick labels required  </documentation>
+        <set value='label_list' name='axis_tick_label_list'/>
+        <set value='number' name='axis_tick_label_format'/>
+  </parameter>
+  
+  <parameter name='axis_tick_label_frequency' from='int' to='int' member='label_frequency'  default='1'>
+         <documentation> Label every nth tick mark </documentation>
+  </parameter>
+  
+  <parameter name='axis_tick_label_first' from='string' to='bool' member='label_first' default='on' xml='first_label'>
+         <documentation> Turn off first (left or bottom) tick label  </documentation>
+  </parameter>
+
+  <parameter name='axis_tick_label_last' from='string' to='bool' member='label_last' xml='last_label' default='on'>
+         <documentation> Turn off last (right or top) tick label  </documentation>
+  </parameter>
+  
+  <parameter name='axis_tick_label_position' from='string' to='string' member='label_position'  default='on_tick' values='on_tick/inter_tick'>
+         <documentation> Position labels on or between ticks </documentation>
+  </parameter>
+  <parameter name='axis_tick_label_orientation' from='string' to='string' member='label_orientation' default='horizontal'  values='horizontal/vertical/parallel'>
+         <documentation> Orientation of the tick labels</documentation>
+  </parameter>
+  
+  <parameter name='axis_tick_label_font' from='string' to='string' member='label_font' xml='font' default='sansserif'>
+	<documentation>Font name - please make sure this font is installed!</documentation>
+  </parameter> 
+  
+  <parameter name='axis_tick_label_font_style' from='string' to='string' member='label_font_style' default=''>
+	<documentation>Font style. Set this to an empty string in order to remove all styling.</documentation>
+  </parameter>
+   <parameter name='axis_tick_label_colour' from='string' to='Colour' member='label_colour'  default='automatic' xml='colour'>
+         <documentation> Colour of tick labels</documentation>
+  </parameter>
+  <parameter name='axis_tick_label_height' from='float' to='float' member='label_height' xml='height' default='0.3'>
+         <documentation> Height of tick labels </documentation>
+  </parameter>
+  <parameter name='axis_tick_label_list' from='stringarray' to='stringarray' member='label_labels' xml='list' default='stringarray()' >
+         <documentation> Array for passing user defined tick labels </documentation>
+  </parameter>
+  <parameter name='axis_tick_label_format' from='string' to='string' member='label_format' xml='format' default='(automatic)'>
+         <documentation> Format of tick label values  </documentation>
+  </parameter>
+  <parameter name='axis_minor_tick' from='string' to='bool' member='minor_tick' default='off'>
+         <documentation> Plot minor ticks (ON/OFF) </documentation>
+        <set value='on' name='axis_minor_tick_count'/>
+        <set value='on' name='axis_minor_tick_colour'/>
+        <set value='on' name='axis_minor_tick_thickness'/>
+  </parameter>
+  
+  <parameter name='axis_minor_tick_count' from='int' to='int' member='minor_tick_count'  default='2'>
+         <documentation> Number of minor tick marks between two ticks </documentation>
+  </parameter>
+  
+  <parameter name='axis_minor_tick_colour' from='string' to='Colour' member='minor_tick_colour' default='automatic' >
+         <documentation> Colour of minor ticks</documentation>
+  </parameter>
+  <parameter name='axis_minor_tick_thickness' from='int' to='int' member='minor_tick_thickness' xml='thickness' default='1'>
+         <documentation> Thickness of minor ticks</documentation>
+  </parameter>
+  
+  <parameter name='axis_tip_title' from='string' to='bool' member='tip' default='off' include="AxisTip.h">
+         <documentation> Plot ticks (ON/OFF) </documentation>
+         <set value='on' name='axis_tip_title_text'/>
+         <set value='on' name='axis_tip_title_colour'/>
+         <set value='on' name='axis_tip_title_height'/>
+         <set value='on' name='axis_tip_title_quality'/>
+          
+  </parameter>
+   <parameter name='axis_tip_title_text' from='string' to='string' member='tip_text'  default=' '>
+         <documentation>Text to show in the tip</documentation>
+  </parameter>
+ <parameter name='axis_tip_title_colour' from='string' to='Colour' member='tip_colour'  default='automatic' >
+   <documentation>Coloour of the tip</documentation>      
+  </parameter>
+
+  <parameter name='axis_tip_title_height' from='float' to='float' member='tip_height' default='0.4' >
+         <documentation>font size of the tip</documentation>
+  </parameter>
+
+  <parameter name='axis_tip_title_quality' from='string' to='string' member='tip_quality' default='medium' values='high/medium/low' >
+         <documentation>Quality of the font </documentation>
+  </parameter>
+
+ 
+</class>
+
+
+
+
+
+
+
+
+<class name='AxisMethod' directory='visualisers' include='AxisMethod.h'/>
+
+
+
+<class name='DateAxisMethod' xmltag='date' prefix='axis/axis_date'  inherits='AxisMethod'  directory='visualisers' include='DateAxis.h'>
+
+  <parameter name='axis_date_type' from='string' to='string' member='method' default='days' values='automatic/years/months/days/hours'>
+         <documentation> Select the type of date axis. </documentation>
+       
+  </parameter>
+
+ <parameter name='axis_years_label' from='string' to='bool' member='years' default='on'>
+         <documentation> controls the labeling of the years </documentation>   
+         <set value='on' name='axis_years_label_colour'/>
+         <set value='on' name='axis_years_label_quality'/>    
+         <set value='on' name='axis_years_label_height'/>         
+  </parameter> 
+  
+  <parameter name='axis_years_label_colour' from='string' to='Colour' member='year_colour' default='automatic' xml='colour' >
+         <documentation> Label colour for 'YEARS' </documentation> 
+  </parameter>
+
+  <parameter name='axis_years_label_quality' from='string' to='string' member='year_quality' xml='quality' default='medium '>
+         <documentation>Label quality (HIGH/MEDIUM/LOW)  </documentation>
+  </parameter>
+  
+  <parameter name='axis_years_label_height' from='float' to='float' member='year_height' xml='height' default='0.2'>
+         <documentation> Label height for 'YEARS'  </documentation>
+  </parameter>
+  
+ <parameter name='axis_months_label' from='string' to='bool' include='MonthDateAxis.h' member='months' default='on'>
+         <documentation> controls the labeling of the months </documentation>      
+         <set value='on' name='axis_months_label_composition'/>
+         <set value='on' name='axis_months_label_colour'/>
+         <set value='on' name='axis_months_label_quality'/>    
+         <set value='on' name='axis_months_label_height'/>   
+  </parameter> 
+  <parameter name='axis_months_label_composition' from='string' to='string' member='month_composition' default='three' values='one/two/three'>
+          <documentation> Number of letters per month to plot  </documentation>
+  </parameter>
+  
+  <parameter name='axis_months_label_colour' from='string' to='Colour' member='month_colour' xml='colour' default='automatic'>
+         <documentation> Label colour for months </documentation>
+  </parameter>
+
+  <parameter name='axis_months_label_quality' from='string' to='string' member='month_quality' xml='quality' default='medium'>
+         <documentation> Label quality for months (HIGH/MEDIUM/LOW)  </documentation>
+  </parameter>
+
+  <parameter name='axis_months_label_height' from='float' to='float' member='month_height' xml='height' default='0.2'>
+         <documentation> Label height for months  </documentation>
+  </parameter>
+
+  
+  
+  <parameter name='axis_days_label' from='string' to='string' member='days' default='both' 
+  		values='day/number/both/off' >
+         <documentation> controls the labeling of the hours </documentation>
+         <set value='on' name='axis_days_label_composition'/>
+         <set value='on' name='axis_days_label_colour'/> 
+         <set value='on' name='axis_days_sunday_label_colour'/>
+         <set value='on' name='axis_days_label_quality'/>    
+         <set value='on' name='axis_hours_label_height'/> 
+  </parameter>
+  
+  <parameter name='axis_days_label_composition' from='string' to='string' member='day_composition' default='three' 
+  		values='one/three/full'>
+      <documentation>  Number of letters per days to plot </documentation>   
+  </parameter>
+  
+  <parameter name='axis_days_label_colour' from='string' to='Colour' member='day_colour' default='black' >
+         <documentation> Label quality for days </documentation>
+  </parameter>
+  <parameter name='axis_days_sunday_label_colour' from='string' to='Colour' member='sunday_colour' default='red' >
+         <documentation> Label quality for days </documentation>
+  </parameter>
+  <parameter name='axis_days_label_quality' from='string' to='string' member='day_quality' xml='quality' default='medium' >
+         <documentation> Label quality for days </documentation>
+  </parameter>
+  
+  <parameter name='axis_days_label_height' from='float' to='float' member='day_height' default='0.2'>
+         <documentation> Label height for  days </documentation>
+  </parameter>
+
+  <parameter name='axis_hours_label' from='string' to='bool' member='hours' default='off'>
+         <documentation> controls the labeling of the hours </documentation>    
+		 <set value='on' name='axis_hours_label_colour'/>
+         <set value='on' name='axis_hours_label_quality'/>    
+         <set value='on' name='axis_hours_label_height'/>    
+  </parameter>  
+   <parameter name='axis_hours_label_colour' from='string' to='Colour' member='hour_colour' default='black' >
+         <documentation> Label quality for hours </documentation>
+  </parameter>
+  <parameter name='axis_hours_label_quality' from='string' to='string' member='hour_quality' xml='quality' default='medium' >
+         <documentation> Label quality for hours </documentation>
+  </parameter>
+  
+  <parameter name='axis_hours_label_height' from='float' to='float' member='hour_height' default='0.2'>
+         <documentation> Label height for  hours </documentation>
+  </parameter>
+ 
+</class>  
+ 
+
+<class name='PositionListAxisMethod' directory='visualisers' inherits='AxisMethod'  include='AxisMethod.h'/>
+<class name='LogarithmicAxisMethod' directory='visualisers' inherits='AxisMethod' include='AxisMethod.h'/>
+<class name='HyperAxisMethod' directory='visualisers' inherits='AxisMethod' include='AxisMethod.h' />
+      
+
+
+</magics>
diff --git a/src/xml/BaseDriver.xml b/src/xml/BaseDriver.xml
new file mode 100644
index 0000000..ce438a7
--- /dev/null
+++ b/src/xml/BaseDriver.xml
@@ -0,0 +1,79 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='BaseDriver' xmltag='driver' directory='drivers' prefix='output' abstract='yes'>
+<documentation for_docs='no'>
+  These parameters are common to all the output drivers and can be used whichever output format is selected.
+</documentation>
+
+<parameter name='output_title' from='string' to='string' member='title' default='Magics++ plot'>
+    <documentation>Defines a title for the output which gets displayed if the format supports it.</documentation>
+</parameter>
+
+<!--
+<parameter name='output_units' from='string' to='string' member='units' default='cm'>
+  <documentation>Units system used to define the document's dimension: Could be pixel or cm... </documentation>
+</parameter>
+-->
+
+
+<!--
+<parameter name='output_size' from='string' to='string' member='size' default='none'>
+  <documentation>Defines the dimension of the (graphical) output ("a4", "a3", "800x550", "24.1x14.6cm").</documentation>
+</parameter>
+-->
+
+<parameter name='output_name' from='string' to='string' member='name' default=''>
+    <documentation>Defines the root of output filename.</documentation>
+</parameter>
+
+<parameter name='output_name_first_page_number' from='string' to='bool' member='firstnumber' default='on'>
+  <documentation>Determines whether, for the first page of multipage output, the number is included in the filename. </documentation>
+</parameter>
+
+<parameter name='output_fullname' from='string' to='string' member='fullname' default='' >
+  <documentation>Alternative way of specifying the output filename. Will be overwritten by output_name if defined.</documentation>
+</parameter>
+
+<parameter name='output_legacy_name' from='string' to='string' member='legacyname' default='' visible='no'>
+  <documentation>Alternative way of specifying the output filename. Will be overwritten by output_name if defined.</documentation>
+</parameter>
+
+<parameter name='output_file_minimal_width' from='int' to='int' member='numberingwidth' default='1'>
+  <documentation>Width of numbering of multi-file outputs (eg, 'plot.1.png' or 'plot.001.png').</documentation>
+</parameter>
+
+<parameter name='output_file_separator' from='string' to='string' member='separator' default='.'>
+  <documentation>Defines the separator between root name and the page number. Default is a dot.</documentation>
+</parameter>
+
+<parameter name='output_mgb_template' from='string' to='string' member='mgb_template' default='' visible='no'>
+  <documentation for_docs='no'>Path to the magics binary file to be used as a template </documentation>
+</parameter>
+
+<parameter name='output_debug' from='string' to='bool' member='debug' default='off'>
+  <documentation>Defines if extra debug information are written in the output file (PS, EPS, SVG) or console (GIF/PNG).</documentation>
+  <release>2.1</release>        
+</parameter>
+<parameter name='output_width' from='int' to='int' member='width' default='800'>
+  <documentation>Defines the width of the image in pixels.(For GD and SVG)</documentation>
+</parameter>
+<parameter name='output_resolution' from='int' to='int' member='resolution' default='300'>
+  <documentation>Defines the resolution of the (graphical) output in dpi (72 - screen, 300 - print).</documentation>
+</parameter>
+
+<parameter name='output_filelist' from='string' to='bool' member='filelist' default='off'>
+ <documentation>Defines if a list of all generated files should be written.</documentation>
+ <set value='on' name='output_filelist_name'/>
+ <release>2.7.10</release>
+</parameter>   
+
+<parameter name='output_filelist_name' from='string' to='string' member='filelist_name' default='magics_outputs.lst'>
+ <documentation>Defines the name of the file containing the list of generated files.</documentation>
+ <release>2.7.10</release>
+</parameter>
+ 
+ <parameter name='output_frame_list' from='intarray' to='intarray' member='frame_list' default='intarray()' visible='no'>
+ <documentation for_docs='no'>Defines the list of frames to plot ( if empty, all the frames will be plotted!).</documentation>
+ </parameter>
+</class>
+</magics>
diff --git a/src/xml/BinaryDriver.xml b/src/xml/BinaryDriver.xml
new file mode 100644
index 0000000..4abccba
--- /dev/null
+++ b/src/xml/BinaryDriver.xml
@@ -0,0 +1,35 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<!--
+ ******************************** LICENSE ********************************
+ 
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************
+-->
+<magics>
+<class name='BinaryDriver' action='Binary' directory='drivers' inherits='BaseDriver'>
+	<documentation>
+		These are the attributes of the Binary output driver. This driver is still in the developing stage! 
+	</documentation>
+<!--
+	<parameter name='' from='string' to='string' member='' default='' xml=''>
+            <documentation></documentation>
+        </parameter>
+-->
+</class>
+</magics>
+
diff --git a/src/xml/BinningObject.xml b/src/xml/BinningObject.xml
new file mode 100644
index 0000000..1fa8c5d
--- /dev/null
+++ b/src/xml/BinningObject.xml
@@ -0,0 +1,75 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='BinningObject' action='pbinning' directory='decoders' xmltag='binning' prefix='binning' >
+	<documentation>
+		This is responsible for accessing biining data .. scattered data can displayed as matrix! 
+	</documentation>
+     
+	    <parameter name='binning_x_method' from='string' to='string'
+	       member='x' default ='count' >
+	    <documentation>Method to compute binns : count/list/interval </documentation>
+    </parameter>
+    <parameter name='binning_x_min_value' from='float' to='float'
+	       member='x_min' default ='-1.0e+21' >
+	    <documentation>Min value used to compute the binns  </documentation>
+    </parameter>
+     <parameter name='binning_x_max_value' from='float' to='float'
+	       member='x_max' default ='1.0e+21' >
+	    <documentation>Max value used to compute the binns  </documentation>
+    </parameter>
+    
+    <parameter name='binning_x_count' from='int' to='int'
+	       member='x_count' default ='10' >
+	    <documentation>Aprroximate number on binns when using the count method  </documentation>
+    </parameter> 
+    
+    <parameter name='binning_x_list' from='floatarray' to='floatarray'
+	       member='x_list' default ='floatarray()' >
+	    <documentation>list of binns when using the list method </documentation>
+    </parameter>
+    
+     <parameter name='binning_x_interval' from='float' to='float'
+	       member='x_interval' default ='10' >
+	    <documentation>list of binns when using the interval method </documentation>
+    </parameter>
+	
+	<parameter name='binning_x_reference' from='float' to='float'
+	       member='x_reference' default ='0' >
+	    <documentation> list of binns when using the interval method </documentation>
+    </parameter>
+	    <parameter name='binning_y_method' from='string' to='string'
+	       member='y' default ='count' >
+	    <documentation>Method to compute binns : count/list/interval </documentation>
+    </parameter>
+    <parameter name='binning_y_min_value' from='float' to='float'
+	       member='y_min' default ='-1.0e+21' >
+	    <documentation>Min value used to compute the binns  </documentation>
+    </parameter>
+     <parameter name='binning_y_max_value' from='float' to='float'
+	       member='y_max' default ='1.0e+21' >
+	    <documentation>Max value used to compute the binns  </documentation>
+    </parameter>
+    
+    <parameter name='binning_y_count' from='int' to='int'
+	       member='y_count' default ='10' >
+	    <documentation>Aprroximate number on binns when using the count method  </documentation>
+    </parameter> 
+    
+    <parameter name='binning_y_list' from='floatarray' to='floatarray'
+	       member='y_list' default ='floatarray()' >
+	    <documentation>list of binns when using the list method </documentation>
+    </parameter>
+    
+     <parameter name='binning_y_interval' from='float' to='float'
+	       member='y_interval' default ='10' >
+	    <documentation>list of binns when using the interval method </documentation>
+    </parameter>
+	
+	<parameter name='binning_y_reference' from='float' to='float'
+	       member='y_reference' default ='0' >
+	    <documentation> list of binns when using the interval method </documentation>
+    </parameter>
+</class>
+
+<class name='NoBinningObject' action='pbinning' include='BinningObject.h' directory='decoders' xmltag='binning' prefix='binning' inherits='BinningObject'/>
+</magics>
diff --git a/src/xml/BoxPlot.xml b/src/xml/BoxPlot.xml
new file mode 100644
index 0000000..8e5365a
--- /dev/null
+++ b/src/xml/BoxPlot.xml
@@ -0,0 +1,193 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='BoxPlotDecoder' directory='decoders' xmltag='boxplot_input' prefix='boxplot'>
+  <documentation>The following parameters allow the user to define both the data
+  and the plotting attributes of boxplots.</documentation>
+
+  <parameter name='boxplot_positions' from='floatarray' to='floatarray'
+             member='x' default='floatarray()'>
+         <documentation> Array containing the x-values</documentation>
+  </parameter>
+  
+  <parameter name='boxplot_date_positions' from='stringarray' to='stringarray'
+             member='date_x' default='stringarray()'>
+         <documentation> Array containing the dates X-values</documentation>
+  </parameter>
+  <parameter name='boxplot_minimum_values' from='floatarray' to='floatarray'
+             member='min'  default='floatarray()'>
+         <documentation> Array containing minimum values</documentation>
+  </parameter>
+  
+  <parameter name='boxplot_maximum_values' from='floatarray' to='floatarray'
+             member='max' default='floatarray()'>
+         <documentation> Array containing maximum values</documentation>
+  </parameter>
+  
+  <parameter name='boxplot_box_upper_values' from='floatarray' to='floatarray'
+             member='upper'  default='floatarray()'>
+         <documentation> Array containing the upper box values</documentation>
+  </parameter>
+  
+  <parameter name='boxplot_box_lower_values' from='floatarray' to='floatarray'
+             member='lower' default='floatarray()'>
+         <documentation> Array containing the lower box values</documentation>
+  </parameter>
+  
+  <parameter name='boxplot_median_values' from='floatarray' to='floatarray'
+             member='median' default='floatarray()'>
+         <documentation> Array containing the median values</documentation>
+  </parameter>
+
+</class>
+
+<class name='BoxPlotVisualiser' xmltag='boxplot' perfix='boxplot' 
+	directory='visualisers' inherits='BoxPlotDecoder'>
+  <documentation>The following parameters allow the user to define both the data
+  and the plotting attributes of boxplots.</documentation>
+
+  <parameter name='boxplot_box' from='string' to='NoBoxPlotBox'  include='BoxPlotBasicItem.h' 
+             member='box' default='on'>
+         <documentation> Turns the plotting of the box on or off</documentation>
+          <option name='BoxPlotBox'   fortran='on'  xml='box' include='BoxPlotItem.h'/>
+          <option name='NoBoxPlotBox' fortran='off' xml='noBox' include='BoxPlotBasicItem.h' />
+           <release>Magics++1.3</release>
+  </parameter>
+  
+  <parameter name='boxplot_whisker' from='string' to='NoBoxPlotWhisker'  include='BoxPlotBasicItem.h'
+             member='whisker' default='line'>
+         <documentation> Determines whether the whiskers are shown as lines, boxes or not at all</documentation>
+          <option name='BoxPlotWhiskerBox'  fortran='box'  xml='whiskerbox'  include='BoxPlotItem.h'/>
+          <option name='NoBoxPlotWhisker'   fortran='off'  xml='nowhisker'   include='BoxPlotBasicItem.h' />
+          <option name='BoxPlotWhiskerLine' fortran='line' xml='whiskerline' include='BoxPlotItem.h' />
+          <release>Magics++1.3</release>
+  </parameter>
+  
+ 
+  </class> 
+
+  <class name='BoxPlotMedian' xmltag='median' prefix='boxplot/boxplot_median' directory='visualisers'>
+   <parameter name='boxplot_median_colour' from='string' to='Colour'
+             member='colour' default='navy'>
+         <documentation>Colour of the median line</documentation>
+  </parameter>
+  
+   <parameter name='boxplot_median_thickness' from='int' to='int'
+             member='thickness' 
+			 default='3'>
+         <documentation>Thickness of the median line</documentation>
+  </parameter>
+  
+   <parameter name='boxplot_median_line_style' from='string' to='LineStyle'
+             member='style' default='solid'>
+         <documentation>Line style of the median line</documentation>
+  </parameter>
+  
+  
+   
+  </class>
+  
+  <class name='BoxPlotBox' xmltag='box' prefix='boxplot/boxplot_box' directory='visualisers'>
+	   <parameter name='boxplot_box_colour' from='string' to='Colour'
+	             member='colour' 	 default='sky'>
+	         <documentation>Colour of the box</documentation>
+	  </parameter>
+	  
+	  <parameter name='boxplot_box_width' from='float' to='float'
+	             member='width'	 default='1.0'>
+	         <documentation>Width of the box in centimeters</documentation>
+	  </parameter>
+	  
+	  <parameter name='boxplot_box_border' from='string' to='NoBoxPlotBoxBorder' include='BoxPlotBasicItem.h'
+	             member='border' default='on'>
+	         <documentation>Determines whether the box border is drawn or not</documentation>
+	         <option name='BoxPlotBoxBorder'   fortran='on'  xml='border' include='BoxPlotItem.h'/>
+             <option name='NoBoxPlotBoxBorder' fortran='off' xml='noborder' include='BoxPlotBasicItem.h' />
+	  </parameter>
+	  
+	   <parameter name='boxplot_median' from='string' to='NoBoxPlotMedian'  include='BoxPlotBasicItem.h'
+             member='median' default='on'>
+         <documentation>Determines whether the median line is drawn or not</documentation>
+          <option name='BoxPlotMedian'   fortran='on'  xml='median' include='BoxPlotItem.h'/>
+          <option name='NoBoxPlotMedian' fortran='off' xml='nomedian' include='BoxPlotBasicItem.h' />
+          <release>Magics++1.3</release>
+       </parameter>
+  
+  </class>
+  
+  <class name='BoxPlotBoxBorder' xmltag='box_border' prefix='boxplot/boxplot_box_border' directory='visualisers'>
+	  <parameter name='boxplot_box_border_colour' from='string' to='Colour'
+	             member='colour'  default='navy'>
+	         <documentation>Colour of the box border</documentation>
+	  </parameter>
+	  
+	   <parameter name='boxplot_box_border_thickness' from='int' to='int'
+	             member='thickness' default='1'>
+	         <documentation>Thickness of the box border</documentation>
+	  </parameter>
+	  
+	   <parameter name='boxplot_box_border_line_style' from='string' to='LineStyle'
+	             member='style' default='solid'>
+	         <documentation>Line style of the box border</documentation>
+	  </parameter>
+  
+  </class>
+  
+  <class name='BoxPlotWhiskerLine' xmltag='whisker_line' 
+  	prefix='boxplot/boxplot_whisker/boxplot_whisker_line' directory='visualisers'>
+  	<parameter name='boxplot_whisker_line_colour' from='string' to='Colour'
+             member='colour'  default='navy'>
+         <documentation>Colour of the whisker line</documentation>
+  </parameter>
+  
+   <parameter name='boxplot_whisker_line_thickness' from='int' to='int'
+             member='thickness'  default='3'>
+         <documentation>Thickness of the whisker line</documentation>
+  </parameter>
+  
+   <parameter name='boxplot_whisker_line_style' from='string' to='LineStyle'
+             member='style'  default='solid'>
+         <documentation>Line style of the whisker line</documentation>
+  </parameter>
+  </class>
+  
+  <class name='BoxPlotWhiskerBox' xmltag='whisker_box' 
+  	prefix='boxplot/boxplot_whisker/boxplot_whisker_box' directory='visualisers'>
+   <parameter name='boxplot_whisker_box_colour' from='string' to='Colour'
+             member='colour' default='sky'>
+         <documentation>Colour of the whisker box</documentation>
+  </parameter>
+  
+  <parameter name='boxplot_whisker_box_width' from='float' to='float'
+             member='width' default='0.25'>
+         <documentation>Width of the whisker box in centimeters</documentation>
+  </parameter>
+  
+    <parameter name='boxplot_whisker_box_border' from='string' to='NoBoxPlotWhiskerBorder' include='BoxPlotBasicItem.h'
+	             member='border' default='on'>
+	         <documentation>Determines whether the whisker box border is drawn or not</documentation>
+	         <option name='BoxPlotWhiskerBorder'   fortran='on'  xml='border' include='BoxPlotItem.h'/>
+             <option name='NoBoxPlotWhiskerBorder' fortran='off' xml='noborder' include='BoxPlotBasicItem.h' />
+	  </parameter>
+</class>
+
+ <class name='BoxPlotWhiskerBorder' xmltag='whisker_border' 
+  	prefix='boxplot/boxplot_whisker/boxplot_whisker_box/boxplot_whisker_box_border' directory='visualisers'>
+  <parameter name='boxplot_whisker_box_border_colour' from='string' to='Colour'
+             member='colour' default='navy'>
+         <documentation>Colour of the whisker box border</documentation>
+  </parameter>
+  
+   <parameter name='boxplot_whisker_box_border_thickness' from='int' to='int'
+             member='thickness' default='1'>
+         <documentation>Thickness of the whisker box border</documentation>
+  </parameter>
+  
+   <parameter name='boxplot_whisker_box_border_line_style' from='string' to='LineStyle'
+             member='style' default='solid'>
+         <documentation>Line style of the whisker box border</documentation>
+  </parameter>
+  
+  </class>
+ 
+
+</magics>
diff --git a/src/xml/CairoDriver.xml b/src/xml/CairoDriver.xml
new file mode 100644
index 0000000..1349781
--- /dev/null
+++ b/src/xml/CairoDriver.xml
@@ -0,0 +1,22 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+  <class name='CairoDriver' action='Cairo' prefix='output/output_cairo' xmltag='cairo' directory='drivers' include='CairoDriver.h' inherits='BaseDriver'>
+  <documentation for_docs='no'>
+   Output driver using the Cairo graphics library. This driver is still in the development stage!
+  </documentation>
+
+ <parameter name='output_cairo_drawing_context' from='cairo_t*' to='cairo_t*' metview='no' visible='no' member='context' default='0'>
+   <documentation> Programs can pass their own Cairo context for Magics to draw into it.</documentation>
+ </parameter> 
+
+ <parameter name='output_cairo_transparent_background' from='string' to='string' member='transparent' default='off' xml='transparent' values='on/off'>
+   <documentation>Defines the background to be transparent (only for PNG).</documentation>
+ </parameter>
+
+ <parameter name='output_cairo_antialias' from='string' to='string' member='antialias' default='on' xml='antialias' values='on/off'>
+   <documentation>Defines if lines are antialiased (only for PNG).</documentation>
+ </parameter>
+
+</class>
+</magics>
+   
diff --git a/src/xml/CoastPlotting.xml b/src/xml/CoastPlotting.xml
new file mode 100644
index 0000000..8d1e8b8
--- /dev/null
+++ b/src/xml/CoastPlotting.xml
@@ -0,0 +1,233 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='NoCoastPlotting' action='pcoast' used_by='Coastlines' 
+	directory='visualisers' prefix='map/map_coastline' xmltag='coast' include='CoastPlotting.h'>
+	<documentation>
+		Coastlines may be turned off by setting the parameter MAP_COASTLINE  to 'OFF' , 
+        the default being 'ON' . 
+        The parameters MAP_COASTLINE_STYLE  and MAP_COASTLINE_COLOUR control line style and colour respectively.
+        The default value for the coastlines have been changed from YELLOW to BLACK.
+	</documentation>
+
+
+rivers
+<!--
+<parameter name='map_coastline_simplification_factor' from='double' to='double' member='simplification' default='0' xml='simplification_factor' implemented='no'>
+ <documentation>Simplification factor: if 0, do not apply any simplification</documentation>
+</parameter>
+-->
+
+<parameter name='map_coastline_resolution' from='string' to='string' member='resolution' default='automatic' values='automatic/low/medium/high'>
+ <documentation>Select one of the pre-defined resolutions: automatic, low, medium, and high.
+  When set to AUTOMATIC, a resolution appropriate to the scale of the map is chosen in order to balance quality with speed.
+ </documentation>
+ <!-- Changed with 2.12 - before more levels were possible -->
+ <!-- Changed with 2.13.5 - now also with 'full' -->
+ <release>1.1</release>
+</parameter>
+
+
+       
+<parameter name='map_coastline_land_shade' from='string' to='bool' member='land' default='off'>
+ <documentation>Sets if land areas are shaded</documentation>
+   <set value='on' name='map_coastline_land_shade_colour' />
+</parameter>
+
+<parameter name='map_coastline_land_shade_colour' from='string' to='Colour' member='land_colour' default='green' xml='colour' priority='0.2' >
+ <documentation>Colour of Shading of land areas</documentation>
+   <set value='on' name='map_coastline_land_shade_colour' />
+</parameter>
+
+<parameter name='map_coastline_sea_shade' from='string' to='bool'  member='sea' default='off'>
+ <documentation>Shade the sea areas</documentation>
+   <set value='on' name='map_coastline_sea_shade_colour' />
+  </parameter>    
+<parameter name='map_coastline_sea_shade_colour' from='string' to='Colour' member='sea_colour' default='blue' xml='colour' priority='0.2'>
+ <documentation>Colour of Shading of sea areas</documentation>
+</parameter>
+<parameter name='map_boundaries' from='string' to='NoBoundaries' include='Boundaries.h' member='boundaries' default='off'>
+  <documentation>Add the political boundaries</documentation>
+    <option name='Boundaries'   fortran='on'  xml='boundaries' include='Boundaries.h'/>
+    <option name='NoBoundaries' fortran='off' xml='noboundaries' include='Boundaries.h'/>
+</parameter>
+
+<parameter name='map_cities' from='string' to='NoCities' include='Cities.h' member='cities' default='off'>
+  <documentation>Add the cities (capitals)</documentation>
+    <option name='Cities'   fortran='on'  xml='cities' include='Boundaries.h'/>
+    <option name='NoCities' fortran='off' xml='nocities' include='Boundaries.h'/>
+  <release>Work in progress</release>
+</parameter>
+
+<parameter name='map_preview' from='string' to='bool' member='preview' default='off' visible='no'>
+ <documentation for_docs='no'>Add a preview : only for metview</documentation>
+</parameter>
+
+<parameter name='map_rivers' from='string' to='string' member='rivers' default='off' values='on/off'>
+ <documentation>Display rivers (on/off)</documentation>
+  <set value='on' name='map_rivers_style'/>
+  <set value='on' name='map_rivers_colour'/>
+  <set value='on' name='map_rivers_thickness'/>           
+ <release>2.11</release>
+</parameter>
+        
+<parameter name='map_rivers_style' from='string' to='LineStyle' member='rivers_style' default='solid'>
+  <documentation>Line style for rivers</documentation>
+  <release>2.11</release>
+</parameter>       
+
+<parameter name='map_rivers_colour' from='string' to='Colour' member='rivers_colour' default="blue">
+ <documentation>Colour of the rivers</documentation>
+ <release>2.12</release>
+</parameter>
+
+<parameter name='map_rivers_thickness' from='int' to='int' member='rivers_thickness' default='1' xml='thickness'>
+  <documentation>Line thickness of rivers</documentation>
+  <release>2.12</release>
+</parameter>
+</class>
+
+
+<class name='Cities' action='pcoast' directory='visualisers' include='Cities.h'  inherits='NoCities'>
+
+<parameter name='map_cities_unit_system' from='string' to='string' member='unit' default='percent' values='percent/cm'>
+  <documentation>Unit for city name sizes.</documentation>
+</parameter>
+ 
+<parameter name='map_cities_font_name' from='string' to='string' member='font_name' default='sansserif'  >
+   <documentation>Font used to display the city names.</documentation>
+</parameter>
+ 
+<parameter name='map_cities_font_style' from='string' to='string' member='font_style'  default='normal'  >
+  <release>Work in progress</release>
+ <documentation>Font style used for city names.</documentation>
+</parameter>
+
+<parameter name='map_cities_font_size' from='float' to='float' member='font_size' default='2.5'  >
+ <documentation>Font size of city names.</documentation>
+</parameter>
+
+<parameter name='map_cities_font_colour' from='string' to='Colour' member='font_colour' default='navy'  >
+ <documentation>Colour used for city names.</documentation>
+</parameter>
+
+<parameter name='map_cities_name_position' from='string' to='string' member='position' default='above'  values='above/below/left/right'>
+ <documentation>Position where to display the city names.</documentation>
+</parameter>
+
+<parameter name='map_cities_marker' from='string' to='string' member='marker' default='plus'  values='circle/box/snowflake/plus'>
+  <documentation>Marker for cities.</documentation>
+</parameter>
+
+<parameter name='map_cities_marker_height' from='float' to='float' member='marker_height' default='0.7'  >
+  <documentation>Height of city markers.</documentation>
+ </parameter>
+
+<parameter name='map_cities_marker_colour' from='string' to='Colour' member='marker_colour' default='evergreen'  >
+  <documentation>Colour for city markers.</documentation>
+</parameter>
+
+</class>
+
+
+<class name='NoCities' action='pcoast' xmltag='noboundaries' directory='visualisers' include='Cities.h'>
+   <documentation>This object suppresses the plotting of cities.</documentation>
+</class>
+
+<class name='Boundaries' action='pcoast' directory='visualisers' include='Boundaries.h' 
+	xmltag='boundaries' prefix='map/map_boundaries/map_boundaries' inherits='NoBoundaries' >
+ <documentation>This object sets the properties of the political boundaries.</documentation>
+   
+
+<parameter name='map_boundaries_style' from='string' to='LineStyle' member='style' default='solid' xml='style'>
+  <documentation>Line style of boundaries</documentation>
+  <release>1.3</release>
+</parameter>
+
+<parameter name='map_boundaries_colour' from='string' to='Colour' member='colour' default='grey' xml='colour'>
+ <documentation>Colour of boundaries</documentation>
+ <release>1.3</release>
+</parameter>
+
+<parameter name='map_boundaries_thickness' from='int' to='int' member='thickness' default='1' xml='thickness'>
+ <documentation>Line thickness of boundaries</documentation>
+ <release>2.11</release>
+</parameter>
+
+<parameter name='map_disputed_boundaries' from='string' to='bool' member='disputed' default='on'>
+ <documentation>Display the disputed boundaries (on/off)</documentation>
+    <set value='on' name='map_disputed_boundaries_style'/>
+    <set value='on' name='map_disputed_boundaries_colour'/>
+    <set value='on' name='map_disputed_boundaries_thickness'/>           
+ <release>2.11</release>
+</parameter>
+
+<parameter name='map_disputed_boundaries_style' from='string' to='LineStyle' member='disputed_style' default='dash'>
+ <documentation>Line style of disputed boundaries</documentation>
+ <release>2.11</release>
+</parameter>       
+
+<parameter name='map_disputed_boundaries_colour' from='string' to='Colour' member='disputed_colour' default="automatic">
+ <documentation>Colour of disputed boundaries</documentation>
+ <release>2.11</release>
+</parameter>
+
+<parameter name='map_disputed_boundaries_thickness' from='int' to='int' member='disputed_thickness' default='1' xml='thickness'>
+ <documentation>Line thickness of disputed boundaries</documentation>
+ <release>2.11</release>
+</parameter>
+
+<parameter name='map_administrative_boundaries' from='string' to='bool' member='admistrative' default='off'>
+ <documentation>Display second level administrative boundaries (on/off)</documentation>
+    <set value='on' name='map_administrative_boundaries_countries_list'/>
+    <set value='on' name='map_administrative_boundaries_style'/>
+    <set value='on' name='map_administrative_boundaries_colour'/>
+    <set value='on' name='map_administrative_boundaries_thickness'/>
+</parameter>
+
+<parameter name='map_administrative_boundaries_countries_list' from='stringarray' to='stringarray' member='administrative_list' default='stringarray()' values='AGO:Angola/DZA:Algeria/EGY:Egypt/BGD:Bangladesh/NAM:Namibia/BOL:Bolivia/GHA:Ghana/CCK:Australia/PAK:Pakistan/LBY:Libya/MYS:Malaysia/PRK:Korea, North/TZA:Tanzania/BWA:Botswana/PRY:Paraguay/SAU:Saudi Arabia/MRT:Mauritania/CHL:Chile/CHN:China/LAO:Laos/GIB:United Kingdom/GIN:Guinea/FIN:Finland/URY:Uruguay/NPL:Nepal/CXR:Australia/MAR:M [...]
+  <documentation>List of countries for which to show second level administrative borders.</documentation>
+</parameter> 
+
+<parameter name='map_administrative_boundaries_style' from='string' to='LineStyle' member='administrative_style' default='dash'>
+  <documentation>Line style of second level administrative boundaries</documentation>
+  <release>2.11</release>
+</parameter>       
+
+<parameter name='map_administrative_boundaries_colour' from='string' to='Colour' member='administrative_colour' default="automatic">
+ <documentation>Colour of administrative boundaries</documentation>
+ <release>2.11</release>
+</parameter>
+
+<parameter name='map_administrative_boundaries_thickness' from='int' to='int' member='administrative_thickness' default='1' xml='thickness'>
+ <documentation>Line thickness of boundaries</documentation>
+ <release>2.11</release>
+</parameter>
+</class>
+
+
+<class name='NoBoundaries' action='pcoast' xmltag='noboundaries' directory='visualisers' include='Boundaries.h'>
+   <documentation>This object suppresses the political boundaries</documentation>
+</class>
+<class name='CoastPlotting' action='pcoast' used_by='Coastlines' 
+	directory='visualisers' prefix='map/map_coastline' xmltag='coast' inherits='NoCoastPlotting'>
+<parameter name='map_coastline_colour' from='string' to='Colour' member='colour' default='black'>
+ <documentation>Colour of coastlines</documentation>
+ <release>0.1</release>
+ <migration>Default changed from YELLOW to BLACK</migration>
+</parameter>
+<parameter name='map_coastline_style' from='string' to='LineStyle' member='style' default='solid'>
+ <documentation>Line style of coastlines</documentation>
+</parameter> 
+
+<parameter name='map_coastline_thickness' from='int' to='int' member='thickness' default='1'>
+ <documentation>Line thickness of coastlines</documentation>
+</parameter>	
+</class>
+
+
+
+
+
+
+
+</magics>
diff --git a/src/xml/Coastlines.xml b/src/xml/Coastlines.xml
new file mode 100644
index 0000000..09c6e8a
--- /dev/null
+++ b/src/xml/Coastlines.xml
@@ -0,0 +1,40 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics> 
+<class name='Coastlines' metview='MCOAST' action='pcoast' xmltag='coastlines' directory='visualisers' prefix='map'>
+	<documentation> 
+		The parameters relating to action routine PCOAST (C++ class Coastlines) enable
+        users to control the plotting of coastlines and grid lines. 
+	</documentation>
+        <parameter name='map_coastline' from='string' to='NoCoastPlotting' 
+        	member='coastlines' default='on' include='CoastPlotting.h'> 
+            <documentation> 
+             Plot coastlines on map (ON/OFF)
+           </documentation>
+            <option name='CoastPlotting'   fortran='on'  xml='coast' description='CoastPlotting.xml' include='CoastPlotting.h'/>
+            <option name='NoCoastPlotting' fortran='off' xml='nocoast' description='CoastPlotting.xml' include='CoastPlotting.h' />
+           <release>Magics++0.1</release>
+       </parameter> 
+       <parameter name='map_grid' from='string' to='NoGridPlotting'
+            member='grid' default='on' include='GridPlotting.h'> 
+            <documentation>
+            Plot grid lines on map (On/OFF)
+           </documentation>
+           <option name='GridPlotting'   fortran='on'  xml='grid' description='GridPlotting.xml' include='GridPlotting.h'/>
+           <option name='NoGridPlotting' fortran='off' xml='nogrid' description='GridPlotting.xml' include='GridPlotting.h'/>
+           <release>Magics++0.1</release>
+           <set value='on' name='map_grid_latitude_reference'/>
+           <set value='off' name='map_grid_latitude_reference'/>
+           '/>
+        </parameter>
+        <parameter name='map_label' from='string' to='NoLabelPlotting' include='LabelPlotting.h'
+            member='label' default='on'>
+            <documentation>
+            Plot label  on map grid lines (On/OFF)
+           </documentation>
+           <option name='LabelPlotting'   fortran='on'  xml='label' description='LabelPlotting.xml' include='LabelPlotting.h'/>
+           <option name='NoLabelPlotting' fortran='off' xml='nolabel' description='LabelPlotting.xml' include='LabelPlotting.h'/>
+           <release>Magics++0.1</release>
+        </parameter>
+</class>
+
+</magics>
diff --git a/src/xml/Contour.xml b/src/xml/Contour.xml
new file mode 100644
index 0000000..23679e0
--- /dev/null
+++ b/src/xml/Contour.xml
@@ -0,0 +1,94 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='Contour' fortan='pcont' metview='MCONT'  xmltag='contour'  action='pcont' root='contour' directory='visualisers' prefix='contour'>
+  <documentation>
+    This controls the plotting of isolines, contour bands and grid points.
+  </documentation>
+
+  <parameter name='legend' from='string' to='bool' member='legend' default='off'> 
+		<documentation> Turn legend on or off </documentation> 
+		<release>2.12</release>
+  </parameter>
+
+  <parameter name='contour' from='string' to='IsoPlot' member='contour' default='on'> 
+         <documentation> Turn contouring on or off  </documentation>
+          <option name='IsoPlot'   fortran='on'  xml='isoline' include='IsoPlot.h'/>
+          <option name='NoIsoPlot' fortran='off' xml='noisoline'  include='IsoPlot.h' />
+		 <unset value='off' name='contour_line_style'/>
+		 <unset value='off' name='contour_line_thickness'/>
+		 <unset value='off' name='contour_line_colour'/>
+  </parameter> 
+      
+  <parameter name='contour_method' from='string' to='ContourMethod' member='method' default='automatic'>
+         <documentation> Contouring method  </documentation>
+         <option name='AutomaticContourMethod'  fortran='automatic' xml='automatic' 
+         		include='AutomaticContourMethod.h' />
+           <option name='SampleContourMethod'   fortran='sample' xml='sample' 
+         		include='AutomaticContourMethod.h'  />		
+         <option name='ContourMethod'           fortran='linear'    xml='linear'
+         		include='ContourMethod.h'          />
+         <option name='Akima760Method'          fortran='akima760'  xml='akima760'
+         		include='Akima760Method.h'         />
+         <option name='Akima474Method'          fortran='akima474'  xml='akima474'
+         		include='Akima474Method.h'         />
+         <release>0.1</release>
+         <release>Two akima algorithms have been implemented akima760/akima474 </release>
+</parameter>
+
+<parameter name='contour_interpolation_floor' from='float' to='float' member='floor' default='-INT_MAX'>
+         <documentation>Any value below this floor will be forced  to the floor value.
+		avoid the bubbles artificially created by the interpolation method</documentation>
+         <release_info>2.8</release_info>
+</parameter>
+
+<parameter name='contour_interpolation_ceiling' from='float' to='float' member='ceiling'   default='INT_MAX'>
+         <documentation> any value above this ceiling will be forced  to the ceiling value.
+		avoid the bubbles artificially created by the interpolation method </documentation>
+         <release_info>2.8</release_info>
+</parameter>
+
+<parameter name='contour_automatic_setting' from='string' to='bool'  member='setting' default='off' visible='off'> 
+        <documentation> Turn the automatic setting of contouring attributes  </documentation>
+	<unset value='off' name='contour_automatic_library_path'/>
+</parameter>
+
+<parameter name='contour_automatic_library_path' from='string' to='string'  member='library_path' default='' visible='off'> 
+         <documentation> Users can give their own file to setup the automatic library of contours </documentation>
+</parameter>
+
+
+<parameter name='contour_hilo' from='string' to='HiLoBase' member='hilo' default='off'>
+         <documentation> Plot local maxima/minima  </documentation>
+         <option name='HiLo'   fortran='on'  xml='hilo' include='HiLo.h' />
+         <option name='NoHiLo' fortran='off' xml='nohilo'  include='HiLo.h' />
+         <option name='HighHiLo' fortran='hi' xml='high'  include='HiLo.h' />
+         <option name='LowHiLo' fortran='lo' xml='low'  include='HiLo.h' />
+</parameter>
+  
+
+<parameter name='contour_grid_value_plot' from='string' to='ValuePlotBase' member='grid'  default='off'>
+         <documentation> Plot Grid point values </documentation>
+         <option name='ValuePlot'   fortran='on'  xml='gridvalues' include='ValuePlot.h' />
+         <option name='NoValuePlot' fortran='off' xml='nogridvalues' include='ValuePlot.h' />
+         <release>Magics++0.3</release>
+</parameter>
+</class>
+
+
+<class name='ContourMethod' include='ContourMethod.h'  directory='visualisers'/>
+<class name='AutomaticContourMethod' include='AutomaticContourMethod.h'  inherits='ContourMethod' directory='visualisers'/>
+
+
+<class name='SampleContourMethod' include='AutomaticContourMethod.h'    inherits='ContourMethod' directory='visualisers'>
+
+<parameter name='contour_sample_x_interval' xml='x_interval' from='int' to='int' member='x' default='2'>
+    <documentation>X sampling interval used in 'sample' method (takes every nth point)</documentation>/>
+</parameter>
+
+<parameter name='contour_sample_y_interval' xml='y_interval' from='int' to='int' member='y' default='2'>
+    <documentation>Y sampling interval used in 'sample' method (takes every nth point)</documentation>/>
+</parameter>
+</class>
+
+</magics>
diff --git a/src/xml/Drivers.xml b/src/xml/Drivers.xml
new file mode 100644
index 0000000..9e554ce
--- /dev/null
+++ b/src/xml/Drivers.xml
@@ -0,0 +1,26 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<driver name='BaseDriver' root_object='BaseDriver' recursive_docs='do-recursive'>
+</driver>
+
+<driver name='PostScript' root_object='PostScriptDriver' recursive_docs='no-recursive'>
+</driver>
+
+<driver name='GD' root_object='GDDriver' recursive_docs='no-recursive'>
+</driver>
+
+<driver name='SVG' root_object='SVGDriver' recursive_docs='no-recursive'>
+</driver>
+
+<driver name='KML' root_object='KMLDriver' recursive_docs='no-recursive'>
+</driver>s
+
+<driver name='Qt' root_object='QtDriver' recursive_docs='no-recursive'>
+</driver>
+
+<driver name='Cairo' root_object='CairoDriver' recursive_docs='no-recursive'>
+</driver>
+
+</magics> 
+   
\ No newline at end of file
diff --git a/src/xml/EpsJSon.xml b/src/xml/EpsJSon.xml
new file mode 100644
index 0000000..b2d3901
--- /dev/null
+++ b/src/xml/EpsJSon.xml
@@ -0,0 +1,141 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name="WrepJSon" xmltag='wrepjson' prefix='wrepjson' action='pwrepjson'  
+           directory='web' include='EpsJSon.h' >
+ <parameter name='wrepjson_input_filename' from='string' to='string' 
+ 	    member='path' default=''>
+  	<documentation> Path to the file containing the Bufr data </documentation>
+ </parameter>
+    <parameter name='wrepjson_parameter_information' from='string' to='string'
+             member='param_info' default='' >
+         <documentation> Product information for  key=parameter_info  </documentation>
+        </parameter> 
+   <parameter name='wrepjson_product_information' from='string' to='string'
+             member='product_info' default='' >
+         <documentation> Product information for  key=product_info </documentation>
+        </parameter>
+    <parameter name='wrepjson_family' from='string' to='string' 
+             member='family' default='eps' >
+         <documentation> Forecast information to plot!  </documentation>
+   
+        </parameter>
+ 
+ <parameter name='wrepjson_plumes_interval' from='float' to='float' 
+ 	    member='plumes' default='1'>
+  	<documentation> plumes interval </documentation>
+ </parameter>
+  <parameter name='wrepjson_information' from='string' to='bool' 
+ 	    member='information' default='on'>
+  	<documentation> Plot or not information about station/forecast  in a long title   </documentation>  
+ </parameter>
+ <parameter name='wrepjson_keyword' from='string' to='string' 
+ 	    member='keyword' default=''>
+  	<documentation> if several eps data are put in the same json object, give the keyowrd to find them   </documentation>  
+ </parameter>
+   <parameter name='wrepjson_station_name' from='string' to='string'
+            member='station_name' default='' >
+       <documentation>Name of the station to use in the title </documentation>
+   </parameter>
+  <parameter name='wrepjson_parameter' from='string' to='string'
+            member='param' default='1'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+         <parameter name='wrepjson_parameter_scaling_factor' from='float' to='float'
+            member='param_scaling_factor' default='1'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+         <parameter name='wrepjson_parameter_offset_factor' from='float' to='float'
+            member='param_offset_factor' default='0'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+        <parameter name='wrepjson_clim_parameter' from='string' to='string'
+            member='clim_param' default='' >           
+            <documentation> date to select for the clim In date format (YYYYMMDDHHHH)</documentation>
+        </parameter>  
+        
+        
+        <parameter name='wrepjson_clim_step' from='int' to='int'
+            member='clim_step' default='36' >           
+            <documentation> date to select for the clim In date format (YYYYMMDDHHHH)</documentation>
+        </parameter> 
+        
+        <parameter name='wrepjson_steps' from='intarray' to='intarray'
+            member='steps' default='intarray()' >           
+            <documentation> steps to extract ( legend will use step+12) </documentation>
+        </parameter>
+         
+       <parameter name='wrepjson_y_axis_percentile' from='float' to='float'
+            member='percentile' default='1'>           
+        <documentation> use of threshold   </documentation>
+        </parameter>
+        
+         <parameter name='wrepjson_y_axis_threshold' from='float' to='float'
+            member='threshold' default='50'>           
+            <documentation> use of threshold   to get rid of the unlikely values</documentation>
+     
+        </parameter>
+         <parameter name='wrepjson_y_max_threshold' from='float' to='float'
+            member='y_max_threshold' default='INT_MAX'>           
+            <documentation> If all the values are below the threshold, use the threshold as max value when automatic setting of y axis</documentation>
+     
+        </parameter>
+
+	   <parameter name='wrepjson_temperature_correction' from='string' to='bool'
+            member='correction' default='off'>
+            <documentation> Temperature correction  </documentation>
+
+        </parameter>
+
+	   <parameter name='wrepjson_missing_value' from='float' to='float'
+            member='missing_value' default='-9999'>
+            <documentation> Missing value  </documentation>
+
+        </parameter>
+
+        
+</class>
+<class name="EfiJSon" xmltag='efijson' prefix='efijson' action='pmetgram'  directory='web' >
+	 <parameter name='efijson_input_filename' from='string' to='string' 
+ 	    member='path' default=''>
+  	<documentation> Path to the file containing the Efi data (JSon format) </documentation>
+ 	</parameter>
+ 	
+         
+        <parameter name='efi_long_title' from='string' to='bool'
+            member='long_title' default='off' xml='long_title'>
+            <documentation> efigram long title ( Point Position ... General title!) </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+        <parameter name='efi_title' from='string' to='bool'
+            member='title' default='off' xml='title'>
+            <documentation> epsgram title ( parameter name) </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+        
+        
+          <parameter name='efi_legend' from='string' to='bool'
+            member='legend' default='on'>           
+            <documentation> legend </documentation>
+        </parameter>  
+       
+        
+         <parameter name='efi_legend_colour_list' from='stringarray' to='stringarray'
+            member='legend_colours' default='stringarray()'>           
+            <documentation> legend box colour list  </documentation>
+        </parameter>
+         <parameter name='efi_legend_box_type' from='string' to='string'
+            member='legend_type' default='both'>           
+            <documentation> both/negative/positive </documentation>
+        </parameter>
+        <parameter name='efi_legend_normal_colour' from='string' to='Colour'
+            member='legend_normal_colour' default='black'>           
+            <documentation> legend colour box </documentation>
+        </parameter>
+          <parameter name='efi_legend_normal_thickness' from='int' to='int'
+            member='legend_normal_thickness' default='4'>           
+            <documentation> legend colour box </documentation>
+        </parameter>
+         
+ </class>
+</magics>
diff --git a/src/xml/Epsgram.xml b/src/xml/Epsgram.xml
new file mode 100644
index 0000000..40d46f7
--- /dev/null
+++ b/src/xml/Epsgram.xml
@@ -0,0 +1,812 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='ClassicMtgDecoder' xmltag='metgram' prefix='metgram' action='pmetgram'  directory='decoders' >
+	<documentation>
+		The Classic Metgram  is responsible for accessing the classic metgram database and prepare the data to plotting.
+	</documentation>
+		
+	   
+        <parameter name='metgram_database' from='string' to='string'
+            member='database' default='/vol/epsgram/data/spotbase/epsdb' xml='database'>
+           
+            <documentation> Classic Metgram Database Path </documentation>
+            <migration> New Magics: Parameter eps_database sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+          <parameter name='metgram_parameter' from='string' to='string'
+            member='param' default='' xml='parameter'>
+            <metview default='' class='' >  
+            </metview>
+            <documentation> Classic Metgram Parameter </documentation>
+            <migration> New Magics: Parameter eps_parameter sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='metgram_latitude' from='float' to='float'
+            member='latitude' default='0' xml='latitude'>
+           
+            <documentation> Classic Metgram  latitude </documentation>
+           
+        </parameter>
+        
+         <parameter name='metgram_parameter_scaling_factor' from='float' to='float'
+            member='param_scaling' default='1' xml='parameter_scaling_factor'>
+           
+            <documentation> metgram scaling factor : used only in case of an unknow parameter  </documentation>
+        </parameter>
+        
+          <parameter name='metgram_parameter_offset' from='float' to='float'
+            member='param_offset' default='0' xml='parameter_offset'>
+           
+            <documentation> metgram offset : used only in case of an unknow parameter  </documentation>
+        </parameter>
+        
+         <parameter name='metgram_parameter_title' from='string' to='string'
+            member='param_title' default='' xml='parameter_title'>
+           
+            <documentation> metgram parameter title : used only in case of an unknow parameter  </documentation>
+            <migration> New Magics: Parameter eps_latitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+       <parameter name='metgram_longitude' from='float' to='float'
+            member='longitude' default='0' xml='longitude'>
+            <metview default='0' class='' >  
+            </metview>
+            <documentation> Classic Metgram  longitude</documentation>
+            
+        </parameter>
+        <parameter name='metgram_date' from='string' to='string'
+            member='date' default='-1' xml='date'>
+            <metview default='-1' class='' >  
+            </metview>
+            <documentation>Classic Metgram  date</documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='metgram_time' from='string' to='string'
+            member='time' default='0000' xml='time'>
+            <metview default='0000' class='' >  
+            </metview>
+            <documentation> Classic Metgram  time</documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+		 <parameter name='metgram_long_title' from='string' to='bool'
+            member='long_title' default='off' xml='long_title'>
+            <documentation> epsgram long title </documentation>
+        </parameter>
+         <parameter name='metgram_station_name' from='string' to='string'
+            member='station' default='' xml='station'>
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='metgram_station_height' from='float' to='float'
+            member='height' default='-1.' xml='height'>
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='metgram_temperature_correction' from='string' to='bool'
+            member='correction' default='yes'>           
+            <documentation> Temperature correction  </documentation>
+            
+            <migration> New Magics: Parameter eps_temperature_correction sent to new Magics[EpsTempe].  </migration>
+        </parameter>
+        
+</class>
+
+
+
+<class name='EpsgramDecoder' action='peps'  xmltag='epsgram' prefix='eps' xml_data='eps_title' directory='decoders'>
+	<documentation>
+		The Epsgram is responsible for accessing the espgram database its data to MAGICS.
+	</documentation>
+		
+	    <parameter name='eps_title' from='stringarray' to='stringarray'
+             member='title' default='stringarray()' >
+         <documentation> text block to be plotted </documentation>
+        </parameter>
+        <parameter name='eps_type' from='string' to='string'
+             member='type' xml = 'type' default='eps10' >
+         <documentation>Eps Metgram type : eps10 or eps15  </documentation>
+        </parameter>
+        
+        <parameter name='eps_database' from='string' to='string'
+            member='database' default='/vol/epsgram/data/spotbase/epsdb' xml='database'>
+           
+            <documentation> Epsgram Database Path </documentation>
+            <migration> New Magics: Parameter eps_database sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+        <parameter name='eps_title_text' from='string' to='string'
+            member='title_text' default='EPS Meteogram'>
+            <metview default='' class='' >  
+            </metview>
+            <documentation> Epsgram Parameter </documentation>
+            <migration> New Magics: Parameter eps_parameter sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+          <parameter name='eps_parameter' from='string' to='string'
+            member='param' default='' xml='parameter'>
+            <metview default='' class='' >  
+            </metview>
+            <documentation> Epsgram Parameter </documentation>
+            <migration> New Magics: Parameter eps_parameter sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_parameter_title' from='string' to='string'
+            member='param_title' default='' xml='parameter_title'>
+           
+            <documentation> epsgram parameter title : used only in case of an unknow parameter  </documentation>
+            <migration> New Magics: Parameter eps_latitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_latitude' from='float' to='float'
+            member='latitude' default='0' xml='latitude'>
+            <metview default='0' class='' >  
+            </metview>
+            <documentation> epsgram latitude column name </documentation>
+            <migration> New Magics: Parameter eps_latitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+       <parameter name='eps_longitude' from='float' to='float'
+            member='longitude' default='0' xml='longitude'>
+            <metview default='0' class='' >  
+            </metview>
+            <documentation> epsgram longitude column name</documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_parameter_hour_shift' from='float' to='float'
+            member='param_hour_shift' default='0'>
+             <documentation> valid date is shifted ( temporary..)  </documentation>
+        </parameter>
+         <parameter name='eps_parameter_scaling_factor' from='float' to='float'
+            member='param_scaling_factor' default='1'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+         <parameter name='eps_parameter_offset_factor' from='float' to='float'
+            member='param_offset_factor' default='0'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+        <parameter name='eps_date' from='string' to='string'
+            member='date' default='-1' xml='date'>
+            <metview default='-1' class='' >  
+            </metview>
+            <documentation> epsgram longitude column name</documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_time' from='string' to='string'
+            member='time' default='0000' xml='time'>
+            <metview default='0000' class='' >  
+            </metview>
+            <documentation> epsgram date </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+		 <parameter name='eps_long_title' from='string' to='bool'
+            member='long_title' default='off' xml='long_title'>
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_long_title_station' from='string' to='bool'
+            member='long_title_station' default='on' xml='long_title_station'>
+            <documentation> epsgram long title : add the station name </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_long_title_height' from='string' to='bool'
+            member='long_title_height' default='on' xml='long_title_height'>
+            <documentation> epsgram long title: add the station height </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_long_title_point' from='string' to='bool'
+            member='long_title_point' default='on' xml='long_title_point'>
+            <documentation> epsgram long title: add the grid point position </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_station_name' from='string' to='string'
+            member='station' default='' xml='station'>
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_station_height' from='float' to='float'
+            member='height' default='INT_MAX' xml='height'>
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='eps_temperature_correction' from='string' to='bool'
+            member='correction' default='yes'>           
+            <documentation> Temperature correction  </documentation>
+            <available>yes</available>
+            <available>no</available>
+           
+            <migration> New Magics: Parameter eps_temperature_correction sent to new Magics[EpsTempe].  </migration>
+        </parameter>
+        
+        <parameter name='eps_y_axis_percentile' from='float' to='float'
+            member='percentile' default='1'>           
+            <documentation> Temperature correction  </documentation>
+            <available>yes</available>
+            <available>no</available>
+           
+            <migration> New Magics: Parameter eps_temperature_correction sent to new Magics[EpsTempe].  </migration>
+        </parameter>
+        
+         <parameter name='eps_y_axis_threshold' from='float' to='float'
+            member='threshold' default='50'>           
+            <documentation> Temperature correction  </documentation>
+            <available>yes</available>
+            <available>no</available>
+           
+            <migration> New Magics: Parameter eps_temperature_correction sent to new Magics[EpsTempe].  </migration>
+        </parameter>
+        
+</class>
+
+<class name='EpsWave'  xmltag='epswave' prefix='eps/eps_rose_wave' action='peps' directory='visualisers'  >
+	<documentation>
+		The Epsgraph is repsonsible for plotting the espgram using wind rose visualisation
+	</documentation>
+	<parameter name='eps_rose_wind_colour' from='stringarray' to='stringarray' 
+                member='colour' default='magstringarray()' > 
+    <documentation> Rose wind darker colour  </documentation>          
+    </parameter>
+</class>
+<class name='EpsWind'  xmltag='epswind' prefix='eps/eps_rose_wind' action='peps' directory='visualisers'  >
+	<documentation>
+		The Epsgraph is repsonsible for plotting the espgram using wind rose visualisation
+	</documentation>
+	<parameter name='eps_rose_wind_colour' from='string' to='Colour' 
+                member='colour' default='grey' > 
+    <documentation> Rose wind darker colour  </documentation>          
+    </parameter>
+    <parameter name='eps_rose_wind_border_colour' from='string' to='Colour' 
+                member='border_colour' default='grey' >    
+    <documentation> Rose wind border colour  </documentation>       
+    </parameter>
+    <parameter name='eps_rose_wind_convention' from='string' to='string' 
+                member='convention' default='meteorological' >    
+    <documentation> Define the convention to use to plot the wind direction 
+    	[ meteorological : Direction the parameter is coming from, 
+    	  oceanographic : Direction the parameter is goint to]  </documentation>       
+    </parameter>
+</class>  
+  <class name='EpsCloud'  xmltag='epscloud' prefix='eps/eps_rose_cloud' action='peps' directory='visualisers'  >
+	<documentation>
+		The EpsCloud is repsonsible for plotting the espgram using Cloud rose visualisation
+	</documentation>
+	<parameter name='eps_rose_cloud_colour' from='string' to='Colour' 
+                member='colour' default='black' > 
+    <documentation> Rose wind darker colour  </documentation>          
+    </parameter>
+    <parameter name='eps_rose_cloud_border_colour' from='string' to='Colour' 
+                member='border_colour' default='none' >    
+    <documentation> Rose wind border colour  </documentation>       
+    </parameter>
+    
+</class>    
+
+
+<class name='EpsGraph' xmltag='epsgraph' prefix='eps' action='peps' directory='visualisers'  >
+	<documentation>
+		The Epsgraph is repsonsible for plotting the espgram using box and whisker visualisation
+	</documentation>
+        <parameter name='eps_font' from='string' to='string' 
+                member='font' default='sansserif' xml='font'>           
+        </parameter>
+         <parameter name='eps_font_size' from='float' to='float' 
+                member='font_size' default='0.25' xml='font_size'>           
+        </parameter>
+        <parameter name='eps_font_style' from='string' to='string' 
+                member='font_style' default='' xml='font_style'>           
+        </parameter>
+        <parameter name='eps_font_colour' from='string' to='Colour' 
+                member='font_colour' default='blue' xml='font_colour'>           
+        </parameter>
+        <parameter name='eps_box_colour' from='string' to='Colour' 
+                member='colour' default='cyan' xml='box_colour' >           
+        </parameter>
+          <parameter name='eps_box_shift' from='int' to='int' 
+                member='box_shift' default='0'>           
+        </parameter>
+        <parameter name='eps_right_box_colour' from='string' to='Colour' 
+                member='right_colour' default='red' xml='right_box_colour' >           
+        </parameter>
+        <parameter name='eps_left_box_colour' from='string' to='Colour' 
+                member='left_colour' default='blue' xml='left_box_colour' >           
+        </parameter>
+        <parameter name='eps_box_border_colour' from='string' to='Colour' 
+                member='border_colour' default='black' xml='border_colour'>            
+        </parameter>
+        <parameter name='eps_box_border_thickness' from='int' to='int' 
+                member='border_thickness' default='3' xml='border_thickness'>            
+        </parameter>
+          <parameter name='eps_box_median_thickness' from='int' to='int' 
+                member='median_thickness' default='3'>            
+        </parameter>
+         <parameter name='eps_box_median_colour' from='string' to='Colour' 
+                member='median_colour' default='black'>            
+        </parameter>
+        <parameter name='eps_maximum' from='float' to='float' 
+                member='max' default='INT_MAX' xml='max'>            
+        </parameter>
+        <parameter name='eps_maximum_font_name' from='string' to='string' 
+                member='max_font_name' default='sansserif' xml='max_font_name'>            
+        </parameter>
+        <parameter name='eps_maximum_font_style' from='string' to='string' 
+                member='max_font_style' default='normal' xml='max_font_style'>            
+        </parameter>
+        <parameter name='eps_maximum_font_size' from='float' to='float' 
+                member='max_font_size' default='0.25' xml='max_font_size'>            
+        </parameter>
+         <parameter name='eps_maximum_font_colour' from='string' to='Colour' 
+                member='max_font_colour' default='red' xml='max_font_colour'>            
+        </parameter>
+        <parameter name='eps_box_width' from='float' to='float'
+        	 member='box_width' default='-1'/>
+        	 
+        <parameter name='eps_whisker' from='string' to='bool'
+        	 member='whisker' default='on' xml='whisker'/>
+        
+         <parameter name='eps_legend_resolution' from='string' to='string'
+        	 member='legend_resolution' default='truncature'/>	 
+        	       <parameter name='eps_legend_control_text' from='string' to='string'
+        	 member='legend_control_text' default=''/>	    
+        	  <parameter name='eps_legend_forecast_text' from='string' to='string'
+        	 member='legend_forecast_text' default=''/>	 
+        	 
+         <parameter name='eps_deterministic' from='string' to='bool'
+        	 member='deterministic' default='on'>
+        	 <documentation> plot the deterministic Forecast</documentation>
+        </parameter>
+         <parameter name='eps_deterministic_line_colour' from='string' to='Colour'
+        	 member='deterministic_colour' default='blue'>
+        	 <documentation>Colour of  deterministic Forecast</documentation>
+        </parameter>
+         
+          <parameter name='eps_deterministic_line_style' from='string' to='LineStyle'
+        	 member='deterministic_style' default='solid'>
+        	 <documentation>line style of  deterministic Forecast</documentation>
+        </parameter>
+        <parameter name='eps_deterministic_line_thickness' from='int' to='int'
+        	 member='deterministic_thickness' default='2'>
+        	 <documentation>line style of  deterministic Forecast</documentation>
+        </parameter>
+                 <parameter name='eps_control' from='string' to='bool'
+        	 member='control' default='on'>
+        	 <documentation> plot the deterministic Forecast</documentation>
+        </parameter>
+         <parameter name='eps_control_line_colour' from='string' to='Colour'
+        	 member='control_colour' default='red'>
+        	 <documentation>Colour of  deterministic Forecast</documentation>
+        </parameter>
+        
+          <parameter name='eps_control_line_style' from='string' to='LineStyle'
+        	 member='control_style' default='dash'>
+        	 <documentation>Control of  deterministic Forecast</documentation>
+        </parameter>
+        <parameter name='eps_control_line_thickness' from='int' to='int'
+        	 member='control_thickness' default='2'>
+        	 <documentation>line style of  deterministic Forecast</documentation>
+        </parameter>
+        	 
+        <parameter name='legend' from='string' to='bool' 
+                member='legend' default='on'>           
+        </parameter>	 
+</class>
+
+
+<class name='EfigramDecoder' xmltag='efigram' prefix='efi' action='pefigram' directory='decoders' >
+	<documentation>
+		The Epsgram is responsible for accessing the espgram database its data to MAGICS.
+	</documentation>
+         <parameter name='efi_root_database' from='string' to='string'
+            member='database' default='' xml='database' >           
+            <documentation> database to access </documentation>
+        </parameter> 
+        <parameter name='efi_legend_root_database' from='string' to='string'
+            member='legend_database' default='' xml='legend_database'>           
+            <documentation> legend </documentation>
+        </parameter>
+        <parameter name='efi_clim_root_database' from='string' to='string'
+            member='clim_database' default='' >           
+            <documentation> climatalogy database </documentation>
+        </parameter>
+         <parameter name='efi_dates' from='stringarray' to='stringarray'
+            member='dates' default='stringarray()' >           
+            <documentation> date to select In date format (YYYYMMDDHHHH)</documentation>
+        </parameter>   
+        <parameter name='efi_clim_parameter' from='string' to='string'
+            member='clim_param' default='' >           
+            <documentation> date to select for the clim In date format (YYYYMMDDHHHH)</documentation>
+        </parameter>  
+          <parameter name='efi_clim_date' from='string' to='string'
+            member='clim_date' default='' >           
+            <documentation> date to select for the clim In date format (YYYYMMDDHHHH)</documentation>
+        </parameter>  
+        
+        <parameter name='efi_clim_step' from='int' to='int'
+            member='clim_step' default='36' >           
+            <documentation> date to select for the clim In date format (YYYYMMDDHHHH)</documentation>
+        </parameter> 
+        
+        <parameter name='efi_steps' from='intarray' to='intarray'
+            member='steps' default='intarray()' >           
+            <documentation> steps to extract ( legend will use step+12) </documentation>
+        </parameter>
+         <parameter name='efi_parameter' from='string' to='string'
+            member='param' default='' xml='parameter'>
+            <metview default='0' class='' >  
+            </metview>
+            <documentation> epsgram latitude column name </documentation>
+            <migration> New Magics: Parameter eps_latitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         
+        <parameter name='efi_long_title' from='string' to='bool'
+            member='long_title' default='off' xml='long_title'>
+            <documentation> efigram long title ( Point Position ... General title!) </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+        <parameter name='efi_title' from='string' to='bool'
+            member='title' default='off' xml='title'>
+            <documentation> epsgram title ( parameter name) </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+        <parameter name='efi_latitude' from='float' to='float'
+            member='latitude' default='0' xml='latitude'>
+            <metview default='0' class='' >  
+            </metview>
+            <documentation> epsgram latitude column name </documentation>
+            <migration> New Magics: Parameter eps_latitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+       <parameter name='efi_longitude' from='float' to='float'
+            member='longitude' default='0' xml='longitude'>
+            <metview default='0' class='' >  
+            </metview>
+            <documentation> epsgram longitude column name</documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+        
+          <parameter name='efi_legend' from='string' to='bool'
+            member='legend' default='on'>           
+            <documentation> legend </documentation>
+        </parameter>  
+       
+        
+         <parameter name='efi_legend_colour_list' from='stringarray' to='stringarray'
+            member='legend_colours' default='stringarray()'>           
+            <documentation> legend box colour list  </documentation>
+        </parameter>
+         <parameter name='efi_legend_box_type' from='string' to='string'
+            member='legend_type' default='both'>           
+            <documentation> both/negative/positive </documentation>
+        </parameter>
+        <parameter name='efi_legend_normal_colour' from='string' to='Colour'
+            member='legend_normal_colour' default='black'>           
+            <documentation> legend colour box </documentation>
+        </parameter>
+          <parameter name='efi_legend_normal_thickness' from='int' to='int'
+            member='legend_normal_thickness' default='4'>           
+            <documentation> legend colour box </documentation>
+        </parameter>
+         
+       
+       
+         
+</class>
+
+
+
+<class name='EfiGraph' xmltag='efigraph' prefix='efi' action='pcdfgram' directory='visualisers' >
+	<documentation>
+		The Epsgram is responsible for accessing the espgram database its data to MAGICS.
+	</documentation>
+        <parameter name='efi_box_colour_array' from='stringarray' to='stringarray'
+            member='box_colour' default='stringarray()' >           
+            <documentation> Colour of the curve  </documentation>
+        </parameter>
+        
+        <parameter name='efi_box_border_colour' from='string' to='Colour'
+            member='border_colour' default='black'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+          <parameter name='efi_box_border_thickness' from='int' to='int'
+            member='border_thickness' default='1'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+          <parameter name='efi_box_border_line_style' from='string' to='LineStyle'
+            member='border_style' default='solid'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+            <parameter name='efi_normal_colour' from='string' to='Colour'
+            member='normal_colour' default='black'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+         <parameter name='efi_normal_thickness' from='int' to='int'
+            member='normal_thickness' default='4'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+          <parameter name='efi_normal_line_style' from='string' to='LineStyle'
+            member='normal_style' default='solid'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+         <parameter name='efi_font' from='string' to='string' 
+                member='font' default='sansserif' xml='font'>           
+        </parameter>
+         <parameter name='efi_font_size' from='float' to='float' 
+                member='font_size' default='0.25' xml='font_size'>           
+        </parameter>
+        <parameter name='efi_font_style' from='string' to='string' 
+                member='font_style' default='' xml='font_style'>           
+        </parameter>
+        <parameter name='efi_font_colour' from='string' to='Colour' 
+                member='font_colour' default='black' xml='font_colour'>           
+        </parameter>
+        
+</class>
+<class name='CdfGraph' xmltag='cdfgraph' prefix='cdf' action='pcdfgram' directory='visualisers' >
+	<documentation>
+		The Epsgram is responsible for accessing the espgram database its data to MAGICS.
+	</documentation>
+        <parameter name='cdf_lines_colour_array' from='stringarray' to='stringarray'
+            member='colour' default='stringarray()' >           
+            <documentation> Colour of the curve  </documentation>
+        </parameter>
+        
+        
+        <parameter name='cdf_lines_style_array' from='stringarray' to='stringarray'
+            member='style' default='stringarray()'>           
+            <documentation> Style of the curve  </documentation>
+        </parameter>
+        <parameter name='cdf_lines_thickness_array' from='intarray' to='intarray'
+            member='thickness' default='intarray()' >           
+            <documentation> Thickness of the curve  </documentation>
+        </parameter>
+        
+        <parameter name='cdf_clim_line_colour' from='string' to='Colour'
+            member='clim_colour' default='black'>           
+            <documentation> Colour of the clim curve  </documentation>
+        </parameter>
+        <parameter name='cdf_clim_line_thickness' from='int' to='int'
+            member='clim_thickness' default='4' >           
+            <documentation> Thickness of the clim curve  </documentation>
+        </parameter>
+        <parameter name='cdf_clim_line_style' from='string' to='LineStyle'
+            member='clim_style' default='solid' >           
+            <documentation> Style of the clim curve  </documentation>
+        </parameter>         
+</class>
+
+<class name='MetgramGraph' xmltag='metgraph' prefix='metgram' action='pmetgram' directory='visualisers' >
+	<documentation>
+		The Epsgram is responsible for accessing the espgram database its data to MAGICS.
+	</documentation>
+        <parameter name='metgram_plot_style' from='string' to='MetgramStyle'
+            member='style' default='curve'>           
+            <documentation> Type of plot  </documentation>
+            <option name='MetgramBar'   fortran='bar'  xml='bar' include='MetgramStyle.h'/>
+            <option name='MetgramFlags'   fortran='flags'  xml='flags' include='MetgramStyle.h'/>
+			<option name='MetgramCurve'   fortran='curve'  xml='curve' include='MetgramStyle.h'/>
+        </parameter>
+</class>
+<class name='MetgramFlags'  xmltag='metflags' prefix='metgram' action='pmetgram' directory='visualisers' >
+    <documentation>
+        The metgram curve will plot the metgram a s a curve! 
+    </documentation>
+        <parameter name='metgram_flag_colour' from='string' to='Colour'
+            member='colour' default='red'>           
+            <documentation> Colour of Flag  </documentation>
+        </parameter>
+        <parameter name='metgram_flag_frequency' from='int' to='int'
+            member='frequency' default='1'>           
+            <documentation> Frequency to plot the flags  </documentation>
+        </parameter>
+        <parameter name='metgram_flag_length' from='float' to='float'
+            member='length' default='0.5'>           
+            <documentation> length of the flag  </documentation>
+        </parameter>
+</class>
+<class name='MetgramCurve' xmltag='metgraph' prefix='metgram' action='pmetgram' directory='visualisers' >
+    <documentation>
+        The metgram curve will plot the metgram a s a curve! 
+    </documentation>
+        <parameter name='metgram_curve_line_style' from='string' to='LineStyle'
+            member='style' default='solid'>           
+            <documentation> LineStyle of the curve  </documentation>
+        </parameter>
+        <parameter name='metgram_curve2_line_style' from='string' to='LineStyle'
+            member='style2' default='solid'>           
+            <documentation> LineStyle of the second curve  </documentation>
+        </parameter>
+        <parameter name='metgram_curve_colour' from='string' to='Colour'
+            member='colour' default='red'>           
+            <documentation> Colour of the curve  </documentation>
+        </parameter>
+         <parameter name='metgram_curve2_colour' from='string' to='Colour'
+            member='colour2' default='blue'>           
+            <documentation> Colour of the second curve  </documentation>
+        </parameter>
+        <parameter name='metgram_curve_thickness' from='int' to='int'
+            member='thickness' default='2'>           
+            <documentation> Thickness of the curve  </documentation>
+        </parameter>
+        <parameter name='metgram_curve2_thickness' from='int' to='int'
+            member='thickness2' default='2'>           
+            <documentation> Thickness of the second curve  </documentation>
+        </parameter>
+</class>
+
+<class name='EpsShade' xmltag='epsshade' prefix='eps' action='pmetgram' directory='visualisers' >
+	<documentation>
+		The EpsSahde is responsible for plotting climate information as Shaded area.
+	</documentation>
+        <parameter name='eps_shade_colour' from='string' to='Colour'
+            member='colour' default='red'>           
+            <documentation> Colour of the darkest shade area ...  </documentation>
+        </parameter>
+        <parameter name='eps_shade_line_colour' from='string' to='Colour'
+            member='line_colour' default='red'>           
+            <documentation> Colour of the darkest shade area ...  </documentation>
+        </parameter>
+         <parameter name='eps_shade_line_style' from='string' to='LineStyle'
+            member='line_style' default='solid'>           
+            <documentation> Colour of the darkest shade area ...  </documentation>
+        </parameter>
+           <parameter name='eps_shade_line_thickness' from='int' to='int'
+            member='line_thickness' default='1'>           
+            <documentation> Colour of the darkest shade area ...  </documentation>
+        </parameter>
+</class>
+<class name='EpsPlume' xmltag='epsplume' prefix='eps/eps_plume' action='pmetgram' directory='visualisers' >
+	<documentation>
+		The EpsPlumeis responsible for plotting epsplume graph
+	</documentation>  
+		<parameter name='eps_plume_method' from='string' to='string' values='time_serie/vertical_profile'
+            member='method' default='time_serie'>           
+            <documentation> Type of visualisation required : time_serie or vertical_profile </documentation>
+        </parameter>
+        <parameter name='eps_plume_line_colour' from='string' to='Colour'
+            member='line_colour' default='magenta'>           
+            <documentation>Line colour of the eps members  </documentation>
+        </parameter>
+        
+         <parameter name='eps_plume_line_style' from='string' to='LineStyle'
+            member='line_style' default='solid'>           
+            <documentation> Line style of the eps members </documentation>
+        </parameter>
+           <parameter name='eps_plume_line_thickness' from='int' to='int'
+            member='line_thickness' default='1'>           
+            <documentation> Line thickness of the eps members  </documentation>
+        </parameter>
+        
+          <parameter name='eps_plume_forecast_line_colour' from='string' to='Colour'
+            member='forecast_line_colour' default='cyan'>           
+            <documentation> Line colour of the deterministic forecast  </documentation>
+        </parameter>
+        
+         <parameter name='eps_plume_forecast_line_style' from='string' to='LineStyle'
+            member='forecast_line_style' default='dash'>           
+            <documentation>   Line Style of the deterministic forecast </documentation>
+        </parameter>
+           <parameter name='eps_plume_forecast_line_thickness' from='int' to='int'
+            member='forecast_line_thickness' default='5'>           
+            <documentation>  Line thickness of the deterministic forecast  </documentation>
+        </parameter>
+        
+        <parameter name='eps_plume_control_line_colour' from='string' to='Colour'
+            member='control_line_colour' default='cyan'>           
+            <documentation>  Line colour of the control forecast  </documentation>
+        </parameter>
+        
+         <parameter name='eps_plume_control_line_style' from='string' to='LineStyle'
+            member='control_line_style' default='solid'>           
+            <documentation>  Line Style of the control forecast</documentation>
+        </parameter>
+           <parameter name='eps_plume_control_line_thickness' from='int' to='int'
+            member='control_line_thickness' default='5'>           
+            <documentation>  Line thickness of the deterministic forecast  </documentation>
+        </parameter>
+        
+</class>
+<class name='EpsDirection' xmltag='epsdirection' prefix='eps/eps_direction' action='pmetgram' directory='visualisers' >
+	<documentation>
+		The EpsPlumeis responsible for plotting epsplume graph
+	</documentation>
+    <parameter name='eps_direction_keyword' from='string' to='string'
+            member='keyword' default='forecast'>           
+            <documentation> keyword to plot : forecast/control! </documentation>
+        </parameter>
+        <parameter name='eps_direction_line_colour' from='string' to='Colour'
+            member='line_colour' default='red'>           
+            <documentation> Colour of lines ...  </documentation>
+        </parameter>
+        
+         <parameter name='eps_direction_line_style' from='string' to='LineStyle'
+            member='line_style' default='solid'>           
+            <documentation> Line Style </documentation>
+        </parameter>
+           <parameter name='eps_direction_line_thickness' from='int' to='int'
+            member='line_thickness' default='1'>           
+            <documentation> Thickness of the line ...  </documentation>
+        </parameter>
+</class>
+
+<class name="EpsXmlInput" xmltag='epsxml' prefix='epsxml' action='pmetgram'  directory='decoders' >
+ <parameter name='epsxml_input_filename' from='string' to='string' 
+ 	    member='path' default=''>
+  	<documentation> Path to the file containing the Xml Description </documentation>
+ </parameter>
+  <parameter name='epsxml_parameter' from='string' to='string' 
+ 	    member='param' default=''>
+  	<documentation> Parameter to extract </documentation>
+ </parameter>
+   <parameter name='epsxml_long_title' from='string' to='bool'
+            member='long_title' default='off' >
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         <parameter name='epsxml_title' from='string' to='bool'
+            member='short_title' default='on' >
+            <documentation> epsgram long title </documentation>
+            <migration> New Magics: Parameter eps_longitude sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+</class>
+
+<class name="EpsBufr" xmltag='epsbufr' prefix='epsbufr' action='pmetgram'  directory='decoders' >
+ <parameter name='epsbufr_input_filename' from='string' to='string' 
+ 	    member='path' default=''>
+  	<documentation> Path to the file containing the Bufr data </documentation>
+ </parameter>
+    <parameter name='epsbufr_title' from='string' to='string'
+             member='title' default='' >
+         <documentation> text block to be plotted </documentation>
+        </parameter>
+  <parameter name='epsbufr_parameter_title' from='string' to='string' 
+ 	    member='param_title' default=''>
+  	<documentation> Title to use to describe the parameter </documentation>
+ </parameter>
+  <parameter name='epsbufr_information' from='string' to='bool' 
+ 	    member='information' default='on'>
+  	<documentation> Plot or not information about station/forecast  in a long title   </documentation>  
+ </parameter>
+  <parameter name='epsbufr_short_title' from='string' to='bool' 
+ 	    member='short_title' default='on'>
+  	<documentation> Plot or not information about station/forecast  in a long title   </documentation>  
+ </parameter>
+ <parameter name='epsbufr_parameter_descriptor' from='int' to='int' 
+ 	    member='param_descriptor' default='0'>
+  		<documentation> Descriptor to use </documentation>
+  </parameter>
+  <parameter name='epsbufr_parameter_2_descriptor' from='int' to='int' 
+ 	    member='param_descriptor_2' default='0'>
+  		<documentation> Descriptor to use </documentation>
+  </parameter>
+  <parameter name='epsbufr_accumulated_parameter' from='string' to='bool' 
+ 	    member='accumulated' default='off'>
+  		<documentation> Descriptor to use </documentation>
+  </parameter>
+   <parameter name='epsbufr_station_name' from='string' to='string'
+            member='station_name' default='' >
+       <documentation>Name of the station to use in the title </documentation>
+   </parameter>
+   <parameter name='epsbufr_station_latitude' from='float' to='float'
+            member='latitude' default='0'>
+            <documentation>Latitude of the point to extract </documentation>
+        </parameter>
+         <parameter name='epsbufr_station_longitude' from='float' to='float'
+            member='longitude' default='0'>           
+            <documentation> Longitude of the point to extract </documentation>
+        </parameter>
+         <parameter name='epsbufr_parameter_scaling_factor' from='float' to='float'
+            member='param_scaling_factor' default='1'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+         <parameter name='epsbufr_parameter_offset_factor' from='float' to='float'
+            member='param_offset_factor' default='0'>
+             <documentation> Scaling factor to apply to the values</documentation>
+        </parameter>
+    <parameter name='epsbufr_y_axis_percentile' from='float' to='float'
+            member='percentile' default='1'>           
+            <documentation> Temperature correction  </documentation>
+            <available>yes</available>
+            <available>no</available>
+           
+            <migration> New Magics: Parameter eps_temperature_correction sent to new Magics[EpsTempe].  </migration>
+        </parameter>
+        
+         <parameter name='epsbufr_y_axis_threshold' from='float' to='float'
+            member='threshold' default='50'>           
+            <documentation> Temperature correction  </documentation>
+            <available>yes</available>
+            <available>no</available>
+           
+            <migration> New Magics: Parameter eps_temperature_correction sent to new Magics[EpsTempe].  </migration>
+        </parameter>
+</class>
+</magics>
diff --git a/src/xml/Frame.xml b/src/xml/Frame.xml
new file mode 100644
index 0000000..c59bc9e
--- /dev/null
+++ b/src/xml/Frame.xml
@@ -0,0 +1,45 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+
+
+<class name='Frame' action='pnew' used_by='XmlPage/XmlSubPage/Page' directory='common' inherits='FrameBase'>
+  <parameter name='frame_colour' from='string' to='Colour'
+             member='colour' xml='colour' default='blue' >
+         <release>Magics++0.5</release>
+         <documentation> Colour of  frame </documentation>
+  </parameter>
+
+  <parameter name='frame_line_style' from='string' to='LineStyle'
+             member='style' xml='line_style' default='solid' >
+         <release>Magics++0.5</release>
+         <documentation> Style of  frame(SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+  </parameter>
+
+  <parameter name='frame_thickness' from='int' to='int'
+             member='thickness' xml='thickness' default='1'>
+         <release>Magics++0.5</release>
+         <documentation> Thickness of  frame </documentation>
+  </parameter>
+  
+   <parameter name='frame_blanking' from='string' to='bool'
+             member='blanking' xml='blanking' default='on'>
+         <release>Magics++0.5</release>
+         <release_info>Work in progress...</release_info>
+         <documentation> blanking of the box </documentation>
+  </parameter>
+ </class>
+ 
+
+<class name='NoFrame' action='pnew' directory='common' include='Frame.h' inherits='FrameBase'>
+   <documentation>
+   This object suppresses plotting of a frame.
+   </documentation>
+</class>
+<class name='FrameBase' action='pnew' directory='common' include='FrameBase.h'>
+   <documentation>
+   Base Object for frame
+   </documentation>
+</class>
+  
+</magics>
diff --git a/src/xml/GDDriver.xml b/src/xml/GDDriver.xml
new file mode 100644
index 0000000..455b46c
--- /dev/null
+++ b/src/xml/GDDriver.xml
@@ -0,0 +1,33 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='GDDriver' xmltag='gd' prefix='output' directory='drivers' inherits='BaseDriver'>
+	<documentation for_docs='no'>
+		This output driver produces raster output in PNG, GIF, and JPEG format.
+		PNG output can be produced with a transparent background which can be used for overlays.
+
+		JPEG output is included here for backwards compatibility, but is not an ideal format for 
+		scientific plots in raster format. 
+
+		See also the parameters for the Base Driver.
+	</documentation>
+
+	<parameter name='output_jpeg_quality' from='int' to='int' member='quality' default='-1'>
+            <documentation>Defines the quality of Jpeg output. The default of -1 should yield a good general quality/size tradeoff. Should be a value in the range 0-95.</documentation>
+            <migration />
+        </parameter>
+
+	<parameter name='output_gif_delay' from='int' to='int' member='delay' default='100'>
+            <documentation>Defines the delay in 1/100 seconds for GIF animations.</documentation>
+        </parameter>
+
+	<parameter name='output_png_transparent' from='string' to='bool' member='transparent' default='off'>
+            <documentation>Sets the background to transparent for overlays. Works only with PNG output. (ON/OFF)</documentation>
+        </parameter>
+<!--
+	<parameter name='output_xml' from='string' to='bool' member='xml' default='off' >
+            <documentation>Should an XML description be output? (ON/OFF)</documentation>
+        </parameter>
+-->
+</class>
+
+</magics>
diff --git a/src/xml/GeoRectangularProjection.xml b/src/xml/GeoRectangularProjection.xml
new file mode 100644
index 0000000..b6e0cf9
--- /dev/null
+++ b/src/xml/GeoRectangularProjection.xml
@@ -0,0 +1,63 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<!--
+ ******************************** LICENSE ********************************
+ 
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************
+-->
+<magics> 
+<class name='GeoRectangularProjection' inherits='Transformation'
+	action='projection' directory='common' xmltag='cylindrical' prefix='subpage'>
+	<documentation>
+		These are the attributes of the GeoRectangular projection. 
+	</documentation>
+  <parameter name='subpage_lower_left_latitude' from='float' to='float'
+             member='min_latitude' default='-90.0'>
+         <release>Magics++0.1</release>
+         <documentation> Latitude of lower left corner of map. </documentation>
+  </parameter>
+
+  <parameter name='subpage_lower_left_longitude' from='float' to='float'
+             member='min_longitude' default='-180.0' >
+         <release>Magics++0.1</release>
+         <documentation> Longitude of lower left corner of map </documentation>
+  </parameter>
+
+  <parameter name='subpage_upper_right_latitude' from='float' to='float'
+             member='max_latitude' default='90.0' >
+         <release>Magics++0.1</release>
+         <documentation> Latitude of upper right corner of map </documentation>
+  </parameter>
+
+  <parameter name='subpage_upper_right_longitude' from='float' to='float'
+             member='max_longitude' default='180.0' >
+         <release>Magics++0.1</release>
+         <documentation> Longitude of upper right corner of map </documentation>
+  </parameter>
+  <parameter name='subpage_minimal_area'  from='float'  to='float'  member='min_area' default='0.1' visible='off' >
+         <release>Magics++2.11</release>
+         <documentation> Dimension in degrees of the minimal area to display  </documentation>
+  </parameter>
+</class>
+
+<class name='MercatorProjection' inherits='GeoRectangularProjection' include='GeoRectangularProjection.h'
+	action='projection' directory='common' xmltag='rectangular' prefix='subpage'/>
+
+
+</magics>
+
diff --git a/src/xml/Geopoints.xml b/src/xml/Geopoints.xml
new file mode 100644
index 0000000..3ad5aa1
--- /dev/null
+++ b/src/xml/Geopoints.xml
@@ -0,0 +1,186 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name = 'GeoPointsDecoder' xmltag='geopoints' prefix='geo/geo_input' action='pgeo' directory='decoders'>
+   <parameter name='geo_input_file_name' from='string' to='string'
+             member='path' default=''>
+         <release>Magics++1.1</release>
+         <documentation> The name of the input file containing the GeoPoints code field(s) </documentation>
+  </parameter>
+</class>
+   
+<class name = 'SimplePolylineInput'  xmltag='polyline_input' prefix='polyline/polyline_input' action='pline' directory='decoders' >
+  
+  <parameter name='polyline_input_latitudes' from='floatarray' to='floatarray'
+             member='latitudes' default='floatarray()'>
+         <release>Magics++2.1</release>
+         <documentation> Array containing the latitudes of the polylines. Each polyline is separated by the break value </documentation>
+  </parameter>
+  <parameter name='polyline_input_longitudes' from='floatarray' to='floatarray'
+             member='longitudes'  default='floatarray()'>
+         <release>Magics++2.1</release>
+         <documentation> Array containing the longitudes of the polylines. Each polyline is separated by the break value </documentation>
+  </parameter>
+   <parameter name='polyline_input_values' from='floatarray' to='floatarray'
+             member='values' default='floatarray()'>
+         <release>Magics++2.1</release>
+         <documentation> Array containing the values for each polyline </documentation>
+  </parameter>
+   <parameter name='polyline_input_break_indicator' from='float' to='float'   
+             member='breakvalue'  default='-999'>
+         <release>Magics++2.1</release>
+         <documentation> Value used as either a latitude or longitude to denote a separation between polylines </documentation>
+  </parameter>
+  <parameter name='polyline_input_positions_filename' from='string' to='string'
+             member='position_filename' xml='position_filename'
+			 default=''>
+         <release>Magics++2.1</release>
+         <documentation> Path to a file containing the coordinates for all polylines' points. </documentation>
+  </parameter>
+  <parameter name='polyline_input_values_filename' from='string' to='string'
+             member='values_filename'  default=''>
+         <release>Magics++2.1</release>
+         <documentation> Path to a file containing the values for each polyline. </documentation>
+  </parameter>
+</class>
+
+<class name = 'SimplePolyline'  xmltag='polyline' prefix='polyline/polyline_line' action='pline' directory='visualisers'  interface='ColourTechniqueInterface/LevelSelectionInterface' inherits='SimplePolylineInput'>
+ <parameter name='legend' from='string' to='bool'
+             member='legend' default='off'>
+         <release>Magics++2.80</release>
+         <documentation> Turn the legend on </documentation>
+  </parameter>
+  <parameter name='polyline_line_colour' from='string' to='Colour'
+             member='colour' default='blue'>
+         <release>Magics++2.1</release>
+         <documentation> Colour of the polylines </documentation>
+  </parameter>
+  <parameter name='polyline_line_style' from='string' to='LineStyle'
+             member='style' default='solid'>
+         <release>Magics++2.1</release>
+         <documentation> Style of the polylines (SOLID/ DASH/ DOT/ CHAIN_DASH/ CHAIN_DOT) </documentation>
+  </parameter>
+  <parameter name='polyline_line_thickness' from='int' to='int'
+             member='thickness' default='1'>
+         <release>Magics++2.1</release>
+         <documentation> Thickness of the polylines </documentation>
+  </parameter>
+  
+  <parameter name='polyline_level_count' from='int' to='int'
+             member='count'  default='10'>
+         <documentation> Count or number of levels to be plotted. Magics will try to find "nice levels", 
+         this means that the number of levels could be slightly different from the requested number of levels</documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+  <parameter name='polyline_level_tolerance' from='int' to='int'
+             member='tolerance'  default='2'>
+         <documentation> Tolerance: Do not use "nice levels" if the number of levels is really to different [count +/- tolerance] </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+  <parameter name='polyline_reference_level' from='float' to='float'
+             member='reference'  default='0.0'>
+         <documentation> Level from which the level interval is calculated </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+
+  <parameter name='polyline_interval' from='float' to='float'
+             member='interval'  default='8.0'>
+         <documentation> Interval in data units between different bands of shading </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+ <parameter name='polyline_level_list' from='floatarray' to='floatarray'
+             member='list'	 default='floatarray()'>
+         <documentation> List of shading band levels to be plotted </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+  
+  <parameter name='polyline_shade' from='string' to='bool'
+             member='shade' default='none'>
+         <release>Magics++2.1</release>
+         <documentation> Whether to shade polygons or not (ON/OFF) </documentation>
+  </parameter>
+  
+   <parameter name='polyline_shade_max_level' from='float' to='float'
+             member='max'  default='1.0e+21' >
+         <documentation> Maximum level for which shading is required </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+  <parameter name='polyline_shade_min_level' from='float' to='float'
+             member='min'  default='-1.0e+21'>
+         <documentation> Minimum level for which shading is required </documentation>
+         <release>Magics++2.1</release>
+       
+  </parameter>
+  
+  <parameter name='polyline_shade_level_selection_type' from='string' to='LevelSelection'
+             member='levelSelection'  default='count'>
+         <documentation> Can be set to one of: (COUNT/ INTERVAL/ LEVEL_LIST) </documentation>
+         <release>Magics++2.1</release>
+         <option name='CountSelectionType'     fortran='count'    xml='count'    docdive='no' include='CountSelectionType.h'/>
+         <option name='IntervalSelectionType'  fortran='interval' xml='interval' docdive='no' include='IntervalSelectionType.h'/>
+         <option name='LevelListSelectionType' fortran='list'     xml='list'     docdive='no' include='LevelListSelectionType.h'/>
+  </parameter>
+
+  <parameter name='polyline_shade_colour_method' from='string' to='ColourTechnique'
+             member='colourMethod' 	 default='calculate'>
+         <documentation> Method of generating the colours of the bands in polygon shading (LIST/CALCULATE) </documentation>
+         <option name='CalculateColourTechnique' fortran='calculate' xml='calculate' docdive='no' include='CalculateColourTechnique.h'/>
+         <option name='ListColourTechnique'      fortran='list'      xml='list'      docdive='no' include='ListColourTechnique.h'/>
+         <available>list</available>
+         <release>Magics++2.1</release>
+  </parameter>
+
+  <parameter name='polyline_shade_max_level_colour' from='string' to='Colour'
+             member='maxColour' default='blue'>
+         <documentation> Highest shading band colour </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+  <parameter name='polyline_shade_min_level_colour' from='string' to='Colour'
+             member='minColour'  default='red'>
+         <documentation> Lowest shading band colour </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+  <parameter name='polyline_shade_colour_direction' from='string' to='string'
+             member='direction' default='anti_clockwise'>
+         <documentation> Direction of colour sequencing for shading (CLOCKWISE/ ANTI_CLOCKWISE) </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+  <parameter name='polyline_shade_colour_list'  colourlist='on' from='stringarray' to='stringarray'
+             member='colours' default='stringarray()'>
+         <documentation> List of colours to be used in polygon shading. </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+
+</class>
+
+
+
+<class name = 'MapGenDecoder' xmltag='mapgen' perfix='mapgen' action='pmapgen' directory='decoders'>
+   <parameter name='mapgen_input_file_name' from='string' to='string'
+             member='path'  default=''>
+         <release>Magics++2.1</release>
+         <documentation> The name of the input file containing the MapGen data </documentation>
+  </parameter>
+   <parameter name='mapgen_record' from='int' to='int'
+             member='record'  default='-1'>
+         <release>Magics++2.1</release>
+         <documentation> The name of the input file containing the MapGen data to plot </documentation>
+  </parameter>
+</class>
+
+<class name = 'ShapeDecoder' xmltag='shape' prefix='shape' action='pshape' directory='decoders'>
+   <parameter name='shape_input_file_name' from='string' to='string'
+             member='path'  default=''>
+         <release>Magics++2.1</release>
+         <documentation> The name of the input file containing the shape data ( geography only) </documentation>
+  </parameter>
+   
+</class>
+
+</magics>
diff --git a/src/xml/Grib.xml b/src/xml/Grib.xml
new file mode 100644
index 0000000..e6e83a4
--- /dev/null
+++ b/src/xml/Grib.xml
@@ -0,0 +1,232 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name = 'GribDecoder' action='pgrib' directory='decoders' xmltag='grib' prefix='grib/grib'>
+	<documentation>
+		Responsible for reading and interpolating GRIB data.
+	</documentation>
+
+   <parameter name='grib_input_file_name' from='string' to='string'
+             member='file_name' default=''>
+         <release>Magics++0.1</release>
+         <documentation> The name of the input file containing the GRIB code field(s) </documentation>
+  </parameter>
+
+  <parameter name='grib_id' from='string' to='string'
+             member='id' default=''>
+         <release>Magics++2.6</release>
+         <documentation>Id used to identify a grib file in the title production</documentation>
+  </parameter>
+
+ 
+  <parameter name='grib_automatic_scaling' from='string' to='bool'
+             member='scaling' default='on'>
+         <release>Magics++0.3</release>
+         <documentation> Scaling of the decoded field </documentation>
+  </parameter>
+
+  <parameter name='grib_automatic_derived_scaling' from='string' to='bool' for_docs='no'
+             member='derived_scaling' default='off'>
+         <release>Magics++2.13.5</release>
+         <documentation> Scaling of the decoded derived field. A field is considered derived if the GRIB_API key generatingProcessIdentifier is 254. </documentation>
+  </parameter>
+
+  <parameter name='grib_scaling_factor' from='float' to='float'
+             member='scaling_factor' default='1'>
+         <release>Magics++2.10</release>
+         <documentation> Apply a scaling factor to the field. </documentation>
+  </parameter>
+  <parameter name='grib_scaling_offset' from='float' to='float'
+             member='scaling_offset' default='0'>
+         <release>Magics++2.10</release>
+         <documentation> Apply a scaling offset to the field. </documentation>
+  </parameter>
+
+ 
+  <parameter name='grib_text_experiment' from='string' to='bool'
+             member='expver'  default='off' visible='false'>
+         <release>Magics++0.3</release>
+         <documentation> Include the name or number of the experiment, used to generate the GRIB code field, in the automatic text  (ON/OFF)  </documentation>
+  </parameter>
+
+  <parameter name='grib_text_units' from='string' to='bool'
+             member='units' 	 default='off'  visible='false'>
+         <release>Magics++0.3</release>
+         <documentation> Include the units of the input field in the automatic text  </documentation>
+  </parameter>
+
+  
+
+  
+
+ 
+
+  <parameter name='grib_file_address_mode' from='string' to='GribAddressMode'
+             member='address_mode' 	 default='record' metview='on'>
+	     <option name='GribAddressRecordMode' fortran='record' xml='record' include='GribAddressMode.h'/>
+	     <option name='GribAddressByteMode' fortran='byte_offset' xml='byte_offset' include='GribAddressMode.h'/>
+         <documentation> Normally GRIB fields are stored as records on a file. If the BYTE offset method is being used, the parameter GRIB_FILE_ADDRESS_MODE should be set to 'BYTE_OFFSET'.(RECORD_NUMBER/BYTE_OFFSET) </documentation>
+  </parameter>
+
+  
+
+  <parameter name='grib_wind_mode' from='string' to='WindMode'
+             member='wind_mode'  default='uv'>
+         <documentation> The incoming wind field may contain data other than wind components, e.g. wave height and direction.
+	                 grib_wind_mode should be set to indicate how to interpret the incoming wind field, 
+	                 as u/v components, or speed/direction (uv/vd).
+         </documentation>
+         <option name='UVWindMode' fortran='uv' xml='uvmode' include='WindMode.h' />
+         <option name='SDWindMode' fortran='sd' xml='vdmode' include='WindMode.h' />
+  </parameter>
+
+  
+
+  <parameter name='grib_field_position' from='int' to='int'
+             member='grib_field_position'  default='1'>
+         <documentation> The position in the input file of a field other than a wind component </documentation>
+  </parameter>
+
+  
+  
+
+ 
+
+  <parameter name='grib_wind_position_1' from='int' to='int'
+             member='position_1' default='1'>
+         <documentation> The position in the input file of a wind component field </documentation>
+  </parameter>
+
+  <parameter name='grib_wind_position_2' from='int' to='int'
+             member='position_2' default='2'>
+         <documentation> The position in the input file of a wind component field </documentation>
+  </parameter>
+  
+
+  <parameter name='grib_wind_position_colour' from='int' to='int'
+             member='colour_position' default='3'>
+         <documentation> The position in the input file of a wind component field used to colour the flag</documentation>
+  </parameter>
+  
+  
+
+  <parameter name='grib_missing_value_indicator' from='float' to='float'
+             member='missing_value' 	 default='-1.5e+21' visible='false'>
+         <documentation> When MAGICS is decoding GRIB code, this is the value to be assigned to field values where data is missing, as indicated by the bit map in the GRIB file. </documentation>
+  </parameter>
+
+  
+</class>
+
+<class name='GribAddressMode' include='GribAddressMode.h' directory='decoders'/>
+
+<class name='GribAddressByteMode' include='GribAddressMode.h' inherits='GribAddressMode' directory='decoders'/>
+
+<class name='GribAddressRecordMode' include='GribAddressMode.h' inherits='GribAddressMode' directory='decoders'/>
+
+<class name='WindMode'   action='pgrib' directory='decoders' include='WindMode.h'/>
+<class name='UVWindMode' action='pgrib' directory='decoders' include='WindMode.h' inherits='WindMode'/>
+<class name='VDWindMode' action='pgrib' directory='decoders' include='WindMode.h' inherits='WindMode'/>
+<class name='SDWindMode' action='pgrib' directory='decoders' include='WindMode.h' inherits='WindMode'/>
+
+<class name = 'GribLoop' action='pgrib' directory='decoders' xmltag='gribloop' prefix='grib' include='GribDecoder.h'>
+	<documentation>
+		The purpose of the GRIB loop is to easily create an animation. This feature
+        is only available in MagML.
+	</documentation> 
+	<parameter name='grib_file_address_mode' from='string' to='GribAddressMode'
+             member='address_mode' 	 default='record'>
+	     <option name='GribAddressRecordMode' fortran='record' xml='record' include='GribAddressMode.h'/>
+	     <option name='GribAddressByteMode' fortran='byte_offset' xml='byte_offset' include='GribAddressMode.h'/>
+         <documentation> Normally GRIB fields are stored as records on a file. If the BYTE offset method is being used, the parameter GRIB_FILE_ADDRESS_MODE should be set to 'BYTE_OFFSET'.(RECORD_NUMBER/BYTE_OFFSET) </documentation>
+  </parameter>
+	<parameter name='grib_dimension' from='intarray' to='intarray'
+             member='dimension' default='intarray()'>
+         <documentation> Metview:dimension of the input : 1 for field, 2 for wind </documentation>
+  </parameter>
+  
+  <parameter name='grib_position_1' from='intarray' to='intarray'
+             member='dim_1' default='intarray()'>
+         <documentation> Metview:position of the fields for x component in the fieldset </documentation>
+  </parameter>
+  <parameter name='grib_position_2' from='intarray' to='intarray'
+             member='dim_2' default='intarray()'>
+         <documentation>  Metview:position of the fields for y component in the fieldset </documentation>
+  </parameter>
+  <parameter name='grib_position_colour' from='intarray' to='intarray'
+             member='dim_colour' default='intarray()'>
+         <documentation>  Metview:position of the fields for colour component in the fieldset </documentation>
+  </parameter>
+  <parameter name='grib_position' from='intarray' to='intarray'
+             member='dim' default='intarray()'>
+         <documentation> Metview:position of the fields to plot in the fieldset </documentation>
+  </parameter>
+	<parameter name='grib_loop_path' from='string' to='string'
+             member='path' default=''>
+         <documentation> Path of the grib to animate </documentation>
+    </parameter>
+    <parameter name='grib_loop_step' from='string' to='GribLoopStep'
+             member='step' default='loopondate' >
+	      <option name='DateGribLoopStep' xml='loopondate' fortran='loopondate' include='GribLoopStep.h' />
+	      <option name='ParamGribLoopStep' xml='looponparam' fortran='looponparam' include='GribLoopStep.h' />
+         <documentation> Method to create the steps names for each plot of the animation</documentation>
+    </parameter>
+    <parameter name='grib_automatic_scaling' from='string' to='bool'
+             member='scaling' default='on'>
+         <release>Magics++0.3</release>
+         <documentation> Scaling of the decoded field (ON/OFF) </documentation>
+  </parameter>
+  <parameter name='grib_automatic_derived_scaling' from='string' to='bool' for_docs='no'
+             member='derived_scaling' default='off'>
+         <release>Magics++2.13.5</release>
+         <documentation> Scaling of the decoded derived field (ON/OFF). A field is considered derived if the GRIB_API key generatingProcessIdentifier is 254. </documentation>
+  </parameter>
+  <parameter name='grib_scaling_factor' from='float' to='float'
+             member='scaling_factor' default='1'>
+         <release>Magics++2.10</release>
+         <documentation> Apply a scaling factor to the field. </documentation>
+  </parameter>
+  <parameter name='grib_scaling_offset' from='float' to='float'
+             member='scaling_offset' default='0'>
+         <release>Magics++2.10</release>
+         <documentation> Apply a scaling offset to the field. </documentation>
+  </parameter> 
+  <parameter name='grib_wind_mode' from='string' to='WindMode'
+             member='wind_mode'  default='uv'>
+         <documentation> The incoming wind field may contain data other than wind components, e.g. wave height and direction.
+	                 grib_wind_mode should be set to indicate how to interpret the incoming wind field, 
+	                 as u/v components, or speed/direction (uv/vd).
+         </documentation>
+         <option name='UVWindMode' fortran='uv' xml='uvmode' include='WindMode.h' />
+         <!--option name='VDWindMode' fortran='vd' xml='vdmode' include='WindMode.h' /-->
+         <option name='SDWindMode' fortran='sd' xml='sdmode' include='WindMode.h' />
+  </parameter>
+</class>
+<class name = 'GribLoopStep' action='pgrib' xmltag='loopondate' directory='decoders' prefix = 'grib/grib_loop_step' />
+<class name = 'ParamGribLoopStep' action='pgrib' xmltag='looponparam' directory='decoders' inherits='GribLoopStep' prefix = 'grib/grib_loop_step' include='GribLoopStep.h'>
+	<documentation/> 
+</class>
+<class name = 'DateGribLoopStep' action='pgrib' xmltag='loopondate' directory='decoders' inherits='GribLoopStep' prefix = 'grib/grib_loop_step' include='GribLoopStep.h'>
+	<documentation> 
+		Sets the parameters related to looping on dates in a GRIB loop. 
+	</documentation>
+	<parameter name='grib_loop_step_span' from='float' to='float'
+             member='span' xml='loop_step_span' default='3'>
+         <documentation> Time interval  </documentation>
+    </parameter>
+    
+    <parameter name='grib_file_address_mode' from='string' to='GribAddressMode'
+             member='address_mode' 	 default='record'>
+	     <option name='GribAddressRecordMode' fortran='record' xml='record' include='GribAddressMode.h'/>
+	     <option name='GribAddressByteMode' fortran='byte_offset' xml='byte_offset' include='GribAddressMode.h'/>
+         <documentation> Normally GRIB fields are stored as records on a file. If the BYTE offset method is being used, the parameter GRIB_FILE_ADDRESS_MODE should be set to 'BYTE_OFFSET'.(RECORD_NUMBER/BYTE_OFFSET) </documentation>
+  </parameter>
+
+  
+
+  
+    
+  
+    
+  
+</class>
+</magics>
diff --git a/src/xml/GridPlotting.xml b/src/xml/GridPlotting.xml
new file mode 100644
index 0000000..1ddfba2
--- /dev/null
+++ b/src/xml/GridPlotting.xml
@@ -0,0 +1,71 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='GridPlotting' action='pcoast' directory='visualisers' 
+	xmltag='grid' prefix='map/map_grid' inherits='NoGridPlotting' >
+	<documentation>
+		This object will control the settings of the Map Grids.
+	</documentation>
+        <parameter name='map_grid_line_style' from='string' to='LineStyle'
+            member='style' default='solid' >
+            <documentation>
+            Line style of map grid lines
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+      
+        <parameter name='map_grid_thickness' from='int' to='int'
+            member='thickness' default='1'>
+            <documentation>
+            Thickness of map grid lines
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+        <parameter name='map_grid_colour' from='string' to='Colour'
+            member='colour' default='BLACK'>
+            <documentation>
+            Colour of map grid lines
+           </documentation>
+           <release>Magics++0.1</release>
+           <migration> Default changed fronm YELLOW to BLACK </migration>
+       </parameter>
+      
+</class>
+
+
+<class name='NoGridPlotting' xmltag='nogrid' action='pcoast' directory='visualisers' include='GridPlotting.h' >
+   <documentation>
+   This object suppresses the plotting of the map grid.
+   </documentation> 
+   <parameter name='map_grid_latitude_reference' from='float' to='float'
+            member='latReference' default='0' metview='on'>
+            <documentation>
+            Reference Latitude from which all latitude lines are drawn
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+        <parameter name='map_grid_latitude_increment' from='float' to='float'
+            member='latIncrement' default='10' metview='on'>
+            <documentation>
+            Interval between latitude grid lines
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+        <parameter name='map_grid_longitude_reference' from='float' to='float'
+            member='lonReference' default='0' metview='on'>
+            <documentation>
+            Reference Longitude from which all longitude lines are drawn
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+        <parameter name='map_grid_longitude_increment' from='float' to='float'
+            member='lonIncrement' default='20' metview='on'>
+            <documentation>
+            Interval between longitude grid lines
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+</class>
+
+
+</magics>
diff --git a/src/xml/HiLo.xml b/src/xml/HiLo.xml
new file mode 100644
index 0000000..5a93af5
--- /dev/null
+++ b/src/xml/HiLo.xml
@@ -0,0 +1,186 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='HiLo' action='pcont'
+	xmltag='hilo' prefix='contour/contour_hilo'  directory='visualisers' inherits='HiLoBase' >
+  <documentation>
+  Maxima/minima may be plotted as text and/or as numerical values, 
+  default being symbols (H and L ). 
+  The user may, by calling the parameter setting routines, 
+  plot maxima/minima values in various colours, heights, qualities etc. 
+  Users have facilities for plotting only one of these values, 
+  i.e. local maxima or local minima.
+  </documentation>
+
+<parameter name='contour_hilo_type' from='string' to='HiLoTechnique' member='type'  default='text'>
+         <documentation> Type of high/low (TEXT/NUMBER/BOTH) </documentation>
+         <migration> New Magics: Parameter contour_hilo_type sent to new Magics[HiLo].  </migration>
+         <release>0.2</release>
+         <option name='HiLoText'   fortran='text'   xml='text' include='HiLoText.h'/>
+         <option name='HiLoNumber' fortran='number' xml='number' include='HiLoNumber.h' />
+         <option name='HiLoBoth'   fortran='both'   xml='both' include='HiLoBoth.h' />
+</parameter>
+
+<parameter name='contour_hilo_window_size' from='int' to='int' member='window_size' default='3' new_parameter='on'>
+         <documentation> Size of the window used to calculate the Hi/Lo </documentation>
+         <migration> New Magics: Parameter contour_hilo_window_size sent to new Magics[HiLo].  </migration>
+         <release>0.1</release>
+         <release_info>new Parameter : we envisage  to have different methods to calculate Hi/Lo in future releases</release_info>
+</parameter>
+
+<parameter name='contour_hilo_reduction_radius' from='float' to='float' member='reduction_radius'    default='0.0' implemented='no'>
+         <documentation> Search radius (in grid points) for reducing the number of minima </documentation>
+         <migration> New Magics: Parameter contour_hilo_reduction_radius sent to new Magics[HiLo].  </migration>
+         <release_info>Parameter defined but not implemented : expected in 0.7</release_info>
+</parameter>
+  
+<parameter name='contour_hilo_suppress_radius' from='float' to='float'
+             member='suppress_radius'  default='15.0'>
+         <documentation> Radius of HiLo search in grid points (default value is for global cylindrical map) </documentation>
+         <migration> New Magics: Parameter contour_hilo_suppress_radius sent to new Magics[HiLo].  </migration>
+         <release_info>Parameter defined but not implemented: expected in 0.7</release_info>
+</parameter>
+
+<parameter name='contour_hilo_max_value' from='float' to='float' member='hilo_max_value'   default='1.0e+21'>
+         <documentation> Local HiLo above specified value are not drawn </documentation>
+         <migration> New Magics: Parameter contour_hilo_max_value sent to new Magics[HiLo].  </migration>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_hilo_min_value' from='float' to='float' member='hilo_min_value'    default='-1.0e+21' >
+         <documentation> Local HiLo below specified value are not drawn </documentation>
+         <migration> New Magics: Parameter contour_hilo_min_value sent to new Magics[HiLo].  </migration>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_hi_max_value' from='float' to='float'
+             member='hi_max_value' default='1.0e+21'>
+         <documentation> Local HI above specified value are not drawn </documentation>
+         <migration> New Magics: Parameter contour_hi_max_value sent to new Magics[HiLo].  </migration>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_hi_min_value' from='float' to='float'
+             member='hi_min_value'   default='-1.0e+21' >
+         <documentation> Local HI below specified value are not drawn </documentation>
+         <migration> New Magics: Parameter contour_hi_min_value sent to new Magics[HiLo].  </migration>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_lo_max_value' from='float' to='float'
+             member='lo_max_value'  default='1.0e+21' >
+         <documentation> Local Lo above specified value are not drawn </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_lo_min_value' from='float' to='float' member='lo_min_value'   default='-1.0e+21' >
+         <documentation> Local Lo below specified value are not drawn </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_hilo_marker' from='string' to='HiLoMarkerBase' member='marker' default='off' >
+         <documentation> Plot hilo marker (ON/OFF) </documentation>
+         <option name='HiLoMarker'   fortran='on'  xml='marker' include='HiLoMarker.h' />
+         <option name='NoHiLoMarker' fortran='off' xml='nomarker'  include='HiLoMarker.h' />
+         <release>0.2</release>
+</parameter>
+
+
+</class>
+
+
+<class name='NoHiLo' xmltag='nohilo' action='pcont' directory='visualisers' include='HiLo.h'  inherits='HiLoBase' >
+   <documentation>This object suppresses Hi/Lo information.</documentation>
+</class>
+
+<class name='HighHiLo'  xmltag='high' action='pcont' directory='visualisers' include='HiLo.h'  inherits='HiLoBase'  />
+<class name='LowHiLo'  xmltag='low' action='pcont' directory='visualisers' include='HiLo.h'  inherits='HiLoBase' />
+<class name='HiLoBase'  include='HiLoBase.h' directory='visualisers' />
+<class name='HiLoMarkerBase' include='HiLoMarkerBase.h' directory='visualisers'/> 
+
+<class name='HiLoMarker' action='pcont'  xmltag='marker' prefix='contour/contour_hilo/contour_hilo_marker' directory='visualisers' inherits='HiLoMarkerBase' > 
+  <documentation>
+  The position of a maxima/minima value may be marked by plotting a symbol on the precise location. 
+  Users may define their own symbol by setting the parameter CONTOUR_HiLo_MARKER_INDEX
+  </documentation>
+
+<parameter name='contour_hilo_marker_height' from='float' to='float' member='height' default='0.1' >
+         <documentation> Height of HiLo marker symbol </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_hilo_marker_index' from='int' to='int' member='index' default='3' >
+         <documentation> Table number of marker symbol. See chapter on Plotting Attributes </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_hilo_marker_colour' from='string' to='Colour' member='colour' default='red' >
+         <documentation> Colour of grid point markers(Full choice of colours) </documentation>
+         <release>0.2</release>
+</parameter>
+
+</class>
+
+
+
+<class name='NoHiLoMarker' xmltag='nomarker' action='pcont' directory='visualisers'  include='HiLoMarker.h' inherits='HiLoMarkerBase'  >
+   <documentation>
+   This object suppresses the plotting of Hi/Lo markers
+   </documentation>
+</class>
+
+<class name='HiLoSaveBase'  action='pcont' directory='visualisers'/>
+
+
+<class name='HiLoSave' xmltag='save' prefix='contour/contour_hilo' action='pcont' directory='visualisers' inherits='HiLoSaveBase' >
+  <documentation>The User can dowload the positions of the High and Lows in a file. The information will be stored using the Metview GeoPoint file format.</documentation>
+
+<parameter name='contour_hilo_position_file_name' from='string' to='Path' member='file_name' xml='position_file_name' default=''>
+         <documentation> Path/filename of  HiLo file to write </documentation>
+         <release>0.2</release>
+</parameter>
+</class>
+
+<class name='NoHiLoSave' xmltag='nosave' action='pcont' directory='visualisers'  inherits='HiLoSaveBase' include='HiLoSave.h' >
+   <documentation>This object suppresses the saving of Hi/Lo information.</documentation>
+</class>
+
+<class name='HiLoNumber' xmltag='number' prefix='contour/contour_hilo' action='pcont' directory='visualisers' inherits='HiLoTechnique' >
+  <documentation>This object is reponsible for plotting the HI/Lo as text.</documentation>
+
+<parameter name='contour_hilo_format' from='string' to='string' member='format' xml='format' default='(automatic)' >
+         <documentation> Format of HiLo numbers (MAGICS Format/(AUTOMATIC)) </documentation>
+</parameter>
+
+<parameter name='contour_hilo_blanking' from='string' to='bool' member='blanking' default='off'>
+         <documentation>Blank around highs and lows (ON/OFF)</documentation>
+</parameter> 
+</class>
+
+
+<class name='HiLoTechnique' action='pcont' xmltag='hilo' prefix='contour/contour_hilo' directory='visualisers'>
+  <documentation> common attributes to the HiLo technique plotting</documentation> 
+
+<parameter name='contour_hilo_height' from='float' to='float' member='contour_hilo_height' xml='height' default='0.4'>
+         <documentation> Height of local maxima/minima text or numbers </documentation>
+         <release>0.1</release>
+</parameter>
+
+<parameter name='contour_hilo_quality' from='string' to='string' member='contour_hilo_quality' xml='quality' default='low'>
+         <documentation> (LOW/MEDIUM/HIGH) </documentation>
+         <release>0.1</release>
+</parameter>
+
+<parameter name='contour_hi_colour' from='string' to='Colour' member='hi_colour' xml='hi_colour' default='blue' >
+         <documentation> Colour of local maxima text or number </documentation>
+         <release>0.1</release>
+</parameter>
+
+<parameter name='contour_lo_colour' from='string' to='Colour' member='lo_colour' xml='lo_colour' default='blue'>
+         <documentation> Colour of local minima text or number </documentation>
+         <release>0.1</release>
+</parameter>
+</class> 
+
+
+<class name='HiLoBoth' action='pcont' xmltag='both' directory='visualisers'  inherits='HiLoTechnique'  />
+</magics>
diff --git a/src/xml/HiLoMarker.xml b/src/xml/HiLoMarker.xml
new file mode 100644
index 0000000..46879b1
--- /dev/null
+++ b/src/xml/HiLoMarker.xml
@@ -0,0 +1,41 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='HiLoMarkerBase' include='HiLoMarkerBase.h' directory='visualisers'/> 
+
+<class name='HiLoMarker' action='pcont' used_by='HiLo' directory='visualisers' inherits='HiLoMarkerBase'> 
+  <documentation>
+  The position of a maxima/minima value may be marked by plotting a symbol on the precise location. 
+  Users may define their own symbol by setting the parameter CONTOUR_HILO_MARKER_INDEX
+  </documentation>
+  <parameter name='contour_hilo_marker_height' from='float' to='float'
+             member='height' xml='height' default='0.1' >
+         <documentation> Height of HILO marker symbol </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+
+  <parameter name='contour_hilo_marker_index' from='int' to='int'
+             member='index' xml='index' default='3' >
+         <documentation> Table number of marker symbol. See chapter on Plotting Attributes </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+
+<parameter name='contour_hilo_marker_colour' from='string' to='Colour'
+           member='colour' xml='colour' default='red' >
+         <documentation> Colour of grid point markers(Full choice of colours) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+
+</class>
+
+
+
+<class name='NoHiLoMarker' action='pcont' directory='visualisers'include='HiLoMarker.h' inherits='HiLoMarkerBase'>
+   <documentation>
+   This object suppresses the plotting of Hi/Lo markers
+   </documentation>
+</class>
+ 
+
+
+
+</magics>
diff --git a/src/xml/HiLoNumber.xml b/src/xml/HiLoNumber.xml
new file mode 100644
index 0000000..fc07ae2
--- /dev/null
+++ b/src/xml/HiLoNumber.xml
@@ -0,0 +1,15 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='HiLoNumber' action='pcont' directory='visualisers' inherits='HiLoTechnique'>
+  <documentation>
+This object is reponsible for plotting the HI/Lo as text.
+  </documentation>
+  <parameter name='contour_hilo_format' from='string' to='string'
+             member='format' xml='format' default='(automatic)' >
+         <documentation> Format of HILO numbers (MAGICS Format/(AUTOMATIC)) </documentation>
+         <release>Magics++0.1</release>
+         <release_info>Parameter defined but not implemented : expected in 0.7</release_info>
+  </parameter> 
+ 
+</class>
+</magics>
diff --git a/src/xml/HiLoTechnique.xml b/src/xml/HiLoTechnique.xml
new file mode 100644
index 0000000..3c84367
--- /dev/null
+++ b/src/xml/HiLoTechnique.xml
@@ -0,0 +1,32 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+
+<class name='HiLoTechnique'action='pcont' used_by='HiLo' directory='visualisers'>
+  <documentation> common attributes to the HiLo technique plotting</documentation> 
+  <parameter name='contour_hilo_height' from='float' to='float'
+             member='contour_hilo_height' xml='height' default='0.4'>
+         <documentation> Height of local maxima/minima text or numbers </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+   <parameter name='contour_hilo_quality' from='string' to='string'
+             member='contour_hilo_quality' xml='quality' default='low'>
+         <documentation> (LOW/MEDIUM/HIGH) </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  <parameter name='contour_hi_colour' from='string' to='Colour'
+             member='hi_colour' xml='hi_colour' default='blue' >
+         <documentation> Colour of local maxima text or number </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='contour_lo_colour' from='string' to='Colour'
+             member='lo_colour' xml='lo_colour' default='blue'>
+         <documentation> Colour of local minima text or number </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+</class> 
+<class name='HiLoBoth' action='pcont' used_by='HiLo' directory='visualisers'  inherits='HiLoTechnique'  /> 
+
+</magics>
diff --git a/src/xml/HiLoText.xml b/src/xml/HiLoText.xml
new file mode 100644
index 0000000..0871d1a
--- /dev/null
+++ b/src/xml/HiLoText.xml
@@ -0,0 +1,23 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='HiLoText'  xmltag='text' prefix='contour' action='pcont' directory='visualisers' inherits='HiLoTechnique' >
+   <documentation>
+   This object is reponsible for plotting the HI/Lo as text.
+   </documentation>
+   <parameter name='contour_hi_text' from='string' to='string'
+              member='hi_text' xml='hi_text' default='H'>
+         <documentation> Text to represent local maxima </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='contour_lo_text' from='string' to='string'
+             member='lo_text' xml='lo_text' default='L'>
+         <documentation> Text to represent local minima </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+   <parameter name='contour_hilo_blanking' from='string' to='bool' member='blanking' default='off'>
+         <documentation> Blank around highs and lows (ON/OFF)</documentation>         
+         <release>Magics++2.6</release>
+  </parameter>
+</class>
+</magics>
diff --git a/src/xml/Histogram.xml b/src/xml/Histogram.xml
new file mode 100644
index 0000000..f068f2b
--- /dev/null
+++ b/src/xml/Histogram.xml
@@ -0,0 +1,79 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='Histogram' xmltag='histogram' directory='visualisers'>
+	<documentation>
+		Here comes the description of the Histogram action 
+	</documentation>
+
+    <parameter name='histogram_selection_type' 
+             from='string' to='LevelSelection'
+             member='levels' default='count'>
+         <documentation>  (COUNT/ INTERVAL/ LEVEL_LIST) </documentation>
+         <release>Magics++2.6</release>
+         <option name='CountSelectionType'   fortran='count'  xml='count' docdive='no' include='CountSelectionType.h'/>
+         <option name='IntervalSelectionType'   fortran='interval'  xml='interval' docdive='no' include='IntervalSelectionType.h'/>
+         <option name='LevelListSelectionType'   fortran='list'  xml='list' docdive='no' include='LevelListSelectionType.h'/>
+     </parameter>     
+
+  <parameter name='histogram_min_value' from='float' to='float'
+             member='min'  default='-1.e21'>
+         <documentation> Min value </documentation>
+         <release>Magics++2.6</release>
+  </parameter>
+  
+  <parameter name='histogram_max_value' from='float' to='float'
+             member='max'  default='1.e21'>
+         <documentation> max value to plot </documentation>
+         <release>Magics++2.6</release>
+  </parameter>
+  
+   <parameter name='histogram_level_count' from='int' to='int'
+             member='count'  default='10'>
+         <documentation> Count or number of levels to be plotted. Magics will try to find "nice levels", 
+         this means that the number of levels could be slightly different from the requested number of levels</documentation>
+         <release>Magics++2.6</release>
+  </parameter>
+  
+  <parameter name='histogram_level_tolerance' from='int' to='int'
+             member='tolerance'  default='2'>
+         <documentation> Tolerance: Do not use "nice levels" if the number of levels is really to different [count +/- tolerance] </documentation>
+         <release>Magics++2.6</release>
+  </parameter>
+  
+  <parameter name='histogram_reference_level' from='float' to='float'
+             member='reference'  default='0.0'>
+         <documentation> Level from which the level interval is calculated </documentation>
+         <release>Magics++2.6</release>
+  </parameter>
+
+
+  <parameter name='histogram_interval' from='float' to='float'
+             member='interval'  default='8.0'>
+         <documentation> Interval in data units between different bands of shading </documentation>
+         <release>Magics++2.6</release>
+  </parameter>
+
+ <parameter name='histogram_level_list' from='floatarray' to='floatarray'
+             member='list'	 default='floatarray()'>
+         <documentation> List of shading band levels to be plotted </documentation>
+         <release>Magics++2.6</release>
+  </parameter>  
+  
+  <parameter name='histogram_bar_colour' from='string' to='Colour'
+             member='colour'	 default='evergreen'>
+         <documentation> Colour of the bars. </documentation>
+         <release>Magics++2.6</release>
+  </parameter>  
+  
+  <parameter name='histogram_bar_width' from='float' to='float'
+             member='width'	 default='1'>
+         <documentation> Width of the bar in user unit </documentation>
+         <release>Magics++2.6</release>
+  </parameter>  
+           
+</class>
+
+
+
+
+</magics>
diff --git a/src/xml/ImagePlotting.xml b/src/xml/ImagePlotting.xml
new file mode 100644
index 0000000..d319c17
--- /dev/null
+++ b/src/xml/ImagePlotting.xml
@@ -0,0 +1,264 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='ImagePlotting' action = 'pimage' 
+	xmltag='image' prefix='image' directory='visualisers'>
+  <documentation> Here comes the documentation of the ImagePlotting object </documentation>
+
+<parameter name='image_colour_table_creation_mode' from='string' to='LookupTableMode'
+             member='mode' default='equidistant' >
+         <documentation> Method for computing the output image according to the Colour table. </documentation>
+         <available> normal </available>
+         <available> equidistant </available>
+         <available> default </available>
+          <option name='FixedTableMode' fortran='fixed' xml='lut_fixed' include='LookupTableMode.h'/>
+         <option name='NormalTableMode'      fortran='normal'      xml='lut_normal'     include='NormalTableMode.h'/>
+         <option name='EquidistantTableMode' fortran='equidistant' xml='lut_equidistant' include='EquidistantTableMode.h'/>
+         <option name='LinearTableMode'     fortran='linear'     xml='lut_linear'     include='LinearTableMode.h'/>
+         <release>Magics++0.7</release>     
+         <release_info>work in constant progress...</release_info>     
+  </parameter>
+  
+  <parameter name='image_colour_table_type' from='string' to='ColourTableDefinition'
+             member='colourMethod'  default='computed' >
+         <documentation> Method for setting Colour table for imaging. </documentation>
+         <option name='ImageListColourTechnique'    fortran='list'      xml='lut_list'     include='ImageListColourTechnique.h'/>
+         <option name='ImageCalculateColourTechnique' fortran='computed'  xml='lut_computed' include='ImageCalculateColourTechnique.h'/>
+
+         <release>Magics++0.8</release>     
+         <release_info>work in constant progress...</release_info>     
+         <migration>Default changde from calculate to computed </migration>
+  </parameter>
+
+  <parameter name='image_level_count' from='int' to='int'
+             member='count'  default='127' >
+         <documentation> Number of levels </documentation>
+         <release>Magics++0.8</release>     
+         <release_info>work in constant progress...</release_info>     
+  </parameter>
+
+    <parameter name='image_pixel_selection_frequency' from='int' to='int'
+             member='pixelFrequency' default='10'>
+         <documentation> Number of pixels/centimetre to be plotted 
+ </documentation>
+  </parameter>
+
+</class>
+
+<class name='ImageCalculateColourTechnique' 
+	xmltag='lut_computed' prefix='image' action='pimage' directory='visualisers' implements='ColourTableDefinitionComputeInterface'>
+  <parameter name='image_max_level_colour' from='string' to='Colour'
+             member='max' default='blue'>
+         <documentation> Highest image band colour </documentation>
+         <release>Magics++0.8</release>
+  </parameter>
+
+  <parameter name='image_min_level_colour' from='string' to='Colour'
+             member='min' default='red'>
+         <documentation> Lowest image band colour </documentation>
+         <migration> New Magics: Parameter Contour sent to new Magics[Image].  </migration>
+         <release>Magics++0.8</release>
+  </parameter>
+   <parameter name='image_colour_direction' from='string' to='string'
+             member='direction' default='anti_clockwise'>
+         <documentation> Direction of colour sequencing for image (CLOCKWISE / ANTI_CLOCKWISE) </documentation>
+         <migration> New Magics: Parameter image_colour_direction sent to new Magics[Image].  </migration>
+         <release>Magics++0.8</release>
+  </parameter>
+
+</class>
+
+
+<class name='ImageListColourTechnique' action='pcont' 
+	xmltag='list' prefix='image' directory='visualisers' implements='ColourTableDefinitionListInterface'>
+  <parameter name='image_colour_table' from='stringarray' to='stringarray'
+             member='values' default='stringarray()'>
+         <documentation> List of colours to be used in image plotting. </documentation>
+         <release>Magics++0.8</release>
+  </parameter>
+</class>
+
+
+
+
+<class name='LookupTableMode' prefix='image' directory='visualisers'>
+
+  <parameter name='image_min_level' from='int' to='int'
+             member='minLevel' default='-1.0e+21'>
+         <documentation> The lowest pixel value to be plotted  </documentation>
+         <migration> New Magics: Parameter image_min_level sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_max_level' from='int' to='int'
+             member='maxLevel'  default='1.0e+21'>
+         <documentation> The highest pixel value to be plotted  </documentation>
+         <migration> New Magics: Parameter image_max_level sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_outlayer_rejection' from='float' to='float'
+             member='outlayer'  default='0'>
+         <documentation> The outlayer rejection factor </documentation>
+         <migration> New Magics: Parameter image_outlayer_rejection sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+</class>
+
+
+<class name='FixedTableMode' inherits='LookupTableMode' directory='visualisers'>
+	<parameter name='image_level_list' from='intarray' to='intarray'
+             member='levels' default='intarray()'>
+         <documentation> The list  </documentation> 
+      </parameter>
+         <parameter name='image_index_list' from='intarray' to='intarray'
+             member='indexes' default='intarray()'>
+         <documentation> The list of indexes of the Lut to be used! (size of level_list -1 )  </documentation>
+      </parameter>
+       
+</class>
+
+<class name='EquidistantTableMode' implements='LookupTableMode' directory='visualisers'>
+	
+</class>
+
+<class name ='todo' directory='visualisers'>
+
+
+  <parameter name='image_colour_direction' from='string' to='string'
+             member='colour_direction' xml='colour_direction'
+			 default='' implemented='no'>
+         <documentation> Direction for pixel colour calculation
+ </documentation>
+         <migration> New Magics: Parameter image_colour_direction sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='(clockwise/anti_clockwise)' from='' to=''
+             member='(clockwise/anti_clockwise)' xml='(clockwise/anti_clockwise)'
+			 default='' implemented='no'>
+         <documentation>  </documentation>
+         <migration> New Magics: Parameter (clockwise/anti_clockwise) sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='clockwise' from='' to=''
+             member='clockwise' xml='clockwise' default='' implemented='no'>
+         <documentation> 
+ </documentation>
+         <migration> New Magics: Parameter clockwise sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_background_colour' from='string' to='string'
+             member='background_colour' xml='background_colour'
+			 default='grey' implemented='no'> 
+         <documentation> Colour of the area on the map that is not part of the satellite image. </documentation>
+         <migration> New Magics: Parameter image_background_colour sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_subarea_selection' from='string' to='string'
+             member='subarea_selection' xml='subarea_selection'
+			 default='' implemented='no'>
+         <documentation> Plot subarea of satellite projection
+ </documentation>
+         <migration> New Magics: Parameter image_subarea_selection sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  
+
+  <parameter name='image_legend' from='string' to='string'
+             member='legend' xml='legend'
+			 default='off' implemented='no'>
+         <documentation> Plot image legend (ON/OFF) </documentation>
+         <migration> New Magics: Parameter image_legend sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_title' from='string' to='string'
+             member='legend_title' xml='legend_title'
+			 default='off' implemented='no'>
+         <documentation> Plot image legend title (ON/OFF) </documentation>
+         <migration> New Magics: Parameter image_legend_title sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_title_text' from='string' to='string'
+             member='legend_title_text' xml='legend_title_text'
+			 default='legend' implemented='no'>
+         <documentation> Text string for plotting as image legend title </documentation>
+         <migration> New Magics: Parameter image_legend_title_text sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_text_quality' from='string' to='string'
+             member='legend_text_quality' xml='legend_text_quality'
+			 default='' implemented='no'>
+         <documentation> Quality of image legend text 
+ </documentation>
+         <migration> New Magics: Parameter image_legend_text_quality sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_text_colour' from='string' to='string'
+             member='legend_text_colour' xml='legend_text_colour'
+			 default='blue' implemented='no'>
+         <documentation> Colour of image legend text </documentation>
+         <migration> New Magics: Parameter image_legend_text_colour sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_border' from='string' to='string'
+             member='legend_border' xml='legend_border'
+			 default='on' implemented='no'>
+         <documentation> Draw border round image legend box (ON/OFF) </documentation>
+         <migration> New Magics: Parameter image_legend_border sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_border_line_style' from='string' to='string'
+             member='legend_border_line_style' xml='legend_border_line_style'
+			 default='solid' implemented='no'>
+         <documentation> Line style of image legend border </documentation>
+         <migration> New Magics: Parameter image_legend_border_line_style sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_border_colour' from='string' to='string'
+             member='legend_border_colour' xml='legend_border_colour'
+			 default='blue' implemented='no'>
+         <documentation> Colour of image legend border </documentation>
+         <migration> New Magics: Parameter image_legend_border_colour sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_border_thickness' from='int' to='int'
+             member='legend_border_thickness' xml='legend_border_thickness'
+			 default='1' implemented='no'>
+         <documentation> Thickness of image legend border </documentation>
+         <migration> New Magics: Parameter image_legend_border_thickness sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_box_blanking' from='string' to='string'
+             member='legend_box_blanking' xml='legend_box_blanking'
+			 default='off' implemented='no'>
+         <documentation> Blank area behind the legend box (ON/OFF) </documentation>
+         <migration> New Magics: Parameter image_legend_box_blanking sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_box_x_position' from='float' to='float'
+             member='legend_box_x_position' xml='legend_box_x_position'
+			 default='see text' implemented='no'>
+         <documentation> X position of image legend box within page  </documentation>
+         <migration> New Magics: Parameter image_legend_box_x_position sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_box_y_position' from='float' to='float'
+             member='legend_box_y_position' xml='legend_box_y_position'
+			 default='see text' implemented='no'>
+         <documentation> Y position of image legend box within page  </documentation>
+         <migration> New Magics: Parameter image_legend_box_y_position sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_box_x_length' from='float' to='float'
+             member='legend_box_x_length' xml='legend_box_x_length'
+			 default='see text' implemented='no'>
+         <documentation> X length of the image legend box </documentation>
+         <migration> New Magics: Parameter image_legend_box_x_length sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+  <parameter name='image_legend_box_y_length' from='float' to='float'
+             member='legend_box_y_length' xml='legend_box_y_length'
+			 default='see text' implemented='no'>
+         <documentation> Y length of the image legend box </documentation>
+         <migration> New Magics: Parameter image_legend_box_y_length sent to new Magics[ImagePlotting].  </migration>
+  </parameter>
+
+</class>
+</magics>
diff --git a/src/xml/Import.xml b/src/xml/Import.xml
new file mode 100644
index 0000000..efbbd80
--- /dev/null
+++ b/src/xml/Import.xml
@@ -0,0 +1,119 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+
+
+<class name='ImportPlot' action='pplot' directory='visualisers' >
+
+<parameter name='import_format' from='string' to='string' member='format' default='PNG'>
+  <documentation>Specify the format of the imported file </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+<parameter name='import_system_coordinates' from='string' to='string' member='system' default='user'>
+  <documentation>Specify the format of the imported file </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+<parameter name='import_x_position' from='float' to='float' member='x' default='0'>
+  <documentation>X position of the imported image </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+  
+<parameter name='import_y_position' from='float' to='float' member='y' default='0'>
+  <documentation>Y position of the imported image </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+<parameter name='import_width' from='float' to='float' member='width' default='-1'>
+  <documentation>Width of the imported image (-1 means use the dimension of the image)</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+<parameter name='crs' from='string' to='string' member='crs'  default=''>
+  <documentation>Metview info :Crs used for the import</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter> 
+<parameter name='crs_minx' from='float' to='float' member='crs_minx'  default='-180.'>
+  <documentation>Metview info :Crs used for the import</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter> 
+<parameter name='crs_maxx' from='float' to='float' member='crs_maxx'  default='180.'>
+  <documentation>Metview info :Crs used for the import</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+  </parameter> 
+  <parameter name='crs_miny' from='float' to='float' member='crs_miny'  default='-90.'>
+  <documentation>Metview info :Crs used for the import</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+  </parameter> 
+  <parameter name='crs_maxy' from='float' to='float' member='crs_maxy'  default='-90.'>
+  <documentation>Metview info :Crs used for the import</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+  </parameter> 
+    
+
+<parameter name='import_height' from='float' to='float' member='height'  default='-1'>
+  <documentation>Height of the imported image (-1 means use the dimension of the image)</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+
+</class>
+<class name='ImportAction' xmltag='import' prefix='import' action='pimport' directory='decoders' >
+  <documentation> Import facilities allow users to import external graphics files (jpeg/gif/eps) </documentation>
+
+  <parameter name='import_file_name' from='string' to='string'
+             member='path'  default=''>
+         <documentation>File to import </documentation>
+         <release>Basic implementation in Magics++0.6</release>
+  </parameter>
+  <parameter name='import_valid_time' from='string' to='string'
+             member='valid_time'  default=''>
+         <documentation>Valid Time  </documentation>
+         <release>Basic implementation in Magics++2.9</release>
+  </parameter>
+   <parameter name='service' from='string' to='string' member='service'  default=''>
+  <documentation>Metview info : which service created this image</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+<parameter name='url' from='string' to='string' member='url'  default=''>
+  <documentation>Metview info : which url created this image : add it in the titles</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+<parameter name='layers' from='string' to='string' member='short_name'  default=''>
+  <documentation>Metview info :Short name to be put in the layers!</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+</class> 
+
+<class name='ImportObjectHandler' action='pimport' directory='basic' xmltag='import'>
+ <parameter name='import_file_name' from='string' to='string'
+             member='path'  default=''>
+         <documentation>File to import </documentation>
+         <release>Basic implementation in Magics++0.6</release>
+  </parameter>
+<parameter name='import_format' from='string' to='string' member='format' default='PNG'>
+  <documentation>Specify the format of the imported file </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+<parameter name='import_x_position' from='float' to='float' member='x' default='0'>
+  <documentation>X position of the imported image </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+  
+<parameter name='import_y_position' from='float' to='float' member='y' default='0'>
+  <documentation>Y position of the imported image </documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+<parameter name='import_width' from='float' to='float' member='width' default='-1'>
+  <documentation>Width of the imported image (-1 means use the dimension of the image)</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+<parameter name='import_height' from='float' to='float' member='height'  default='-1'>
+  <documentation>Height of the imported image (-1 means use the dimension of the image)</documentation>
+  <release>Basic implementation in Magics++0.6</release>
+</parameter>
+
+</class>
+</magics>
diff --git a/src/xml/InputData.xml b/src/xml/InputData.xml
new file mode 100644
index 0000000..262eebb
--- /dev/null
+++ b/src/xml/InputData.xml
@@ -0,0 +1,94 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='InputData' directory='decoders'  xmltag='input' >
+  <documentation> Input data for curve </documentation>
+ 
+ <parameter name='input_x_type' from='string' to='string'
+             member='x_type' default='number'  values='date/number'>
+         <documentation>Type used for X values: number or date </documentation>
+         <set value='number' name='input_x_values'/>
+         <set value='date' name='input_date_x_values'/>
+  </parameter>
+  <parameter name='input_y_type' from='string' to='string'
+             member='y_type' default='number' values='date/number'>
+         <documentation>Type used for Y values: number or date </documentation> 
+		<set value='number' name='input_y_values'/>
+         <set value='date' name='input_date_y_values'/>
+  </parameter>
+  
+  <parameter name='input_x_values' from='floatarray' to='floatarray'
+             member='x' default='floatarray()' >
+         <documentation> X Values  </documentation>
+  </parameter>
+  <parameter name='input_y_values' from='floatarray' to='floatarray'
+             member='y' default='floatarray()' >
+         <documentation> Y Values  </documentation>
+  </parameter>
+  
+   <parameter name='input_date_x_values' from='stringarray' to='stringarray'
+             member='date_x' default='stringarray()' >
+         <documentation> X Date Values  </documentation>
+  </parameter>
+  <parameter name='input_date_y_values' from='stringarray' to='stringarray'
+             member='date_y' default='stringarray()' >
+         <documentation> Y Date Values  </documentation>
+  </parameter>
+  <parameter name='input_x2_values' from='floatarray' to='floatarray'
+             member='x2' default='floatarray()' >
+         <documentation> Array containing X positions for second AREA curve.  </documentation>
+  </parameter>
+  <parameter name='input_y2_values' from='floatarray' to='floatarray'
+             member='y2' default='floatarray()' >
+         <documentation> Array containing X positions for second AREA curve.  </documentation>
+  </parameter>
+  
+   <parameter name='input_date_x2_values' from='stringarray' to='stringarray'
+             member='date_x2' default='stringarray()' >
+         <documentation> Array containing X positions for second AREA curve when X axis is a DATE/TIME axis.  Format is YYYY-MM-DD HH:mm:ss </documentation>
+  </parameter>
+  <parameter name='input_date_y2_values' from='stringarray' to='stringarray'
+             member='date_y2' default='stringarray()' >
+         <documentation> Array containing Y positions for second AREA curve when X axis is a DATE/TIME axis.  Format is YYYY-MM-DD HH:mm:ss  </documentation>
+  </parameter>
+  
+  <parameter name='input_x_missing_value' from='float' to='float'
+             member='x_missing' default='-21.e6' >
+         <documentation> mssing value for x   </documentation> 
+  </parameter> 
+  <parameter name='input_y_missing_value' from='float' to='float'
+             member='y_missing' default='-21.e6' >
+         <documentation> missing value for x   </documentation>
+  </parameter>
+  <parameter name='input_values' from='floatarray' to='floatarray'
+             member='values' default='floatarray()' >
+         <documentation>  Values  </documentation>
+  </parameter>
+  
+   <parameter name='input_latitude_values' from='floatarray' to='floatarray'
+             member='latitudes' default='floatarray()' >
+         <documentation>  Latitudes  </documentation>
+  </parameter>
+ <parameter name='input_longitude_values' from='floatarray' to='floatarray'
+             member='longitudes' default='floatarray()' >
+         <documentation>  longitudes  </documentation>
+  </parameter>
+  <parameter name='input_x_component_values' from='floatarray' to='floatarray'
+             member='x_component' default='floatarray()' >
+         <documentation>  u components for vectors  </documentation>
+  </parameter>
+  <parameter name='input_y_component_values' from='floatarray' to='floatarray'
+             member='y_component' default='floatarray()' >
+         <documentation>  v components for vectors  </documentation>
+  </parameter>
+
+ <parameter name='input_binning' from='string' to='BinningObject' include='BinningObject.h'
+             member='input_binning' default='on' >
+         <documentation> Binning information </documentation>
+         <option name='NoBinningObject'   fortran='off'  xml='nobinning' include='BinningObject.h'/>
+         <option name='BinningObject'   fortran='on'  xml='binning' include='BinningObject.h'/>
+  </parameter>
+ </class>
+
+
+
+</magics>
diff --git a/src/xml/InputMatrix.xml b/src/xml/InputMatrix.xml
new file mode 100644
index 0000000..a9f53aa
--- /dev/null
+++ b/src/xml/InputMatrix.xml
@@ -0,0 +1,151 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='InputMatrix' directory='decoders'   prefix='input' xmltag='matrix' >
+  <documentation>
+    This object contains this attributes to set how to interpret data stored in 2-dimensional arrays in memory.
+ </documentation>
+
+  <parameter name='input_field' from='Matrix' to='Matrix' member='field' xml='field' default='Matrix()'>
+         <documentation> Array containing data for contouring </documentation>
+  </parameter>
+  
+  <parameter name='input_simple_field' from='string' to='bool' member='simple_field' xml='field' default='off'>
+         <documentation for_docs='no'>For internal testing only, or very specifivc users request!</documentation>
+  </parameter>
+  
+ <parameter name='input_wind_u_component' from='Matrix' to='Matrix' member='u_component' xml='u_component' default='Matrix()'>
+         <documentation> Array containing U velocity component for wind field </documentation>
+  </parameter>
+
+  <parameter name='input_wind_v_component' from='Matrix' to='Matrix' member='v_component' xml='v_component' default='Matrix()'>
+         <documentation> Array containing V velocity component for wind field </documentation>
+  </parameter>
+
+   <parameter name='input_field_organization' from='string' to='InputMatrixInterpretor' member='organization' xml='input_field_organization' default='regular'>
+         <option name='InputMatrixRegularInterpretor'   fortran='regular'  xml='gaussian' include='InputMatrixInterpretor.h'/>
+         <option name='InputMatrixIrregularInterpretor'   fortran='nonregular'  xml='irregular' include='InputMatrixInterpretor.h'/>
+         <documentation> How data is organized in the input field (REGULAR /IRREGULAR/) </documentation>
+  </parameter>
+
+  <parameter name='input_field_subpage_mapping' from='string' to='string' member='mapping' xml='input_field_subpage_mapping' default='upper_left'>
+         <documentation> Position of first point of array (1,1) on the subpage, (see text)(UPPER_LEFT / UPPER_RIGHT / LOWER_LEFT / LOWER_RIGHT /
+         UPPER_LEFT_TRANSPOSED / UPPER_RIGHT_TRANSPOSED / LOWER_LEFT_TRANSPOSED / LOWER_RIGHT_TRANSPOSED) </documentation>
+  </parameter>  
+   
+  <parameter name='input_wind_speed' from='Matrix' to='Matrix' member='wind_speed'  default='Matrix()'>
+         <documentation> Array containing speed component for wind field </documentation>
+  </parameter>
+
+  <parameter name='input_wind_direction' from='Matrix' to='Matrix' member='wind_direction' default='Matrix()'>
+         <documentation> Array containing direction component for wind field </documentation>
+  </parameter>
+
+     <parameter name='input_field_suppress_below' from='float' to='float' member='suppress_below' xml='input_field_suppress_below' default='-1.0e+21'>
+         <documentation> Values in the input field(s) below this value are to be suppressed, i.e. not to be taken into consideration for plotting purposes </documentation>
+  </parameter>
+
+  <parameter name='input_field_suppress_above' from='float' to='float' member='suppress_above' xml='input_field_suppress_above' default='1.0e+21'>
+         <documentation> Values in the input field(s) above this value are to be suppressed, i.e not to be taken into consideration for plotting purposes </documentation>
+  </parameter>
+</class>
+
+<class name='InputMatrixIrregularInterpretor' directory='decoders'>
+
+  <parameter name='input_field_latitudes' from='Matrix' to='Matrix' member='latitudes' default='Matrix()'>
+         <documentation> latitudes </documentation>
+  </parameter>
+  
+  <parameter name='input_field_longitudes' from='Matrix' to='Matrix' member='longitudes' default='Matrix()'>
+         <documentation> longitudes </documentation>
+  </parameter>
+  
+  <parameter name='input_field_y_coordinates' from='Matrix' to='Matrix' member='y' default='Matrix()'>
+         <documentation> y-coordinates of the field </documentation>
+  </parameter>
+  
+  <parameter name='input_field_x_coordinates' from='Matrix' to='Matrix' member='x' default='Matrix()'>
+         <documentation> x-coordinates of the field </documentation>
+  </parameter>
+ </class>
+ 
+ 
+<class name='InputMatrixRegularInterpretor' directory='decoders'>
+
+  <parameter name='input_field_initial_latitude' from='float' to='float' member='latitude' xml='origin_latitude' default='90'>
+         <documentation> used in a geographical projection context: Latitude of the point (1,1) in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_initial_longitude' from='float' to='float' member='longitude' xml='origin_longitude' default='0'>
+         <documentation> used in a geographical projection context: Longitude of the point (1,1) in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_latitude_step' from='float' to='float' member='latitude_step' xml='latitude_step' default='-1.5'>
+         <documentation> used in a geographical projection context: Distance between two latitude points in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_longitude_step' from='float' to='float' member='longitude_step' xml='longitude_step' default='1.5'>
+         <documentation> used in a geographical projection context: Distance between two longitude points in the input array </documentation>
+  </parameter>
+  
+    <parameter name='input_field_initial_y' from='float' to='float' member='y_first' default='0'>
+         <documentation> used in a cartesian projection context: y-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_final_x' from='float' to='float' member='x_last' default='100'>
+         <documentation> used in a cartesian projection context: x-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+  
+   <parameter name='input_field_final_y' from='float' to='float' member='y_last' default='100'>
+         <documentation> used in a cartesian projection context: y-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+  <parameter name='input_field_x_list' from='floatarray' to='floatarray' member='x_coords' default='floatarray()'>
+         <documentation> used in a cartesian projection context: vector containing the x-coordinates </documentation>
+  </parameter>
+   <parameter name='input_field_y_list' from='floatarray' to='floatarray' member='y_coords' default='floatarray()'>
+         <documentation> used in a cartesian projection context: vector containing the y-coordinates </documentation>
+  </parameter>
+   
+  <parameter name='input_field_initial_x' from='float' to='float' member='x_first' default='0'>
+         <documentation> used in a cartesian projection context: x-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+  
+    <parameter name='input_field_initial_y_date' from='string' to='string' member='y_first_date' default=''>
+         <documentation> used in a cartesian projection context: y-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_final_x_date' from='string' to='string' member='x_last_date' default=''>
+         <documentation> used in a cartesian projection context: x-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+  
+   <parameter name='input_field_final_y_date' from='string' to='string' member='y_last_date' default=''>
+         <documentation> used in a cartesian projection context: y-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_initial_x_date' from='string' to='string' member='x_first_date' default=''>
+         <documentation> used in a cartesian projection context: x-coordinate of the point (1,1) in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_y_step' from='float' to='float' member='y_step' default='1'>
+         <documentation> used in a cartesian projection context: y-step in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_x_step' from='float' to='float' member='x_step' default='1'>
+         <documentation> used in a cartesian projection context: x-step in the input array </documentation>
+  </parameter>
+
+  <parameter name='input_field_primary_index' from='string' to='string' member='primary_index' xml='input_field_primary_index' default='longitude' implemented='no'>
+         <documentation> Primary or first index of input array(LATITUDE/LONGITUDE) </documentation>
+  </parameter>
+
+  <parameter name='input_field_gradient_control' from='string' to='string'  member='input_field_gradient_control' xml='input_field_gradient_control' default='off' implemented='no'>
+         <documentation> How to calculate the contour gradients(LEAST/FLAT_ONLY/OFF) </documentation>
+  </parameter>
+
+  <parameter name='input_field_gradient_limitation' from='string' to='string' member='input_field_gradient_limitation' xml='input_field_gradient_limitation' default='off' implemented='no'>
+         <documentation> Set  gradient to 0 for minimum and/or maximum values(MINIMUM/MAXIMUM/BOTH/OFF) </documentation>
+  </parameter>
+  
+  
+</class>
+
+</magics>
diff --git a/src/xml/IsoHighlight.xml b/src/xml/IsoHighlight.xml
new file mode 100644
index 0000000..ca8bd98
--- /dev/null
+++ b/src/xml/IsoHighlight.xml
@@ -0,0 +1,43 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='IsoHighlight' action='pcont' xmltag='highlight' directory='visualisers'  inherits='NoIsoHighlight' prefix='contour/contour/contour_highlight'>
+<documentation> This object is responsible of plotting the hightlight isolines </documentation>
+  <parameter name='contour_highlight_style' from='string' to='LineStyle'
+             member='style' xml='style'
+			 default='solid' priority='0.2'>
+         <documentation> Style of highlighting (SOLID/ DASH/ DOT/ CHAIN_DASH/ CHAIN_DOT) </documentation>
+         <migration> New Magics: Parameter Contour sent to new Magics[Contour].  </migration>
+         <release>Magics++0.2</release>
+  </parameter>
+ <parameter name='contour_reference_level' from='float' to='float'
+             member='reference'  default='0.0'>
+         <documentation> Contour level reference </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  
+  <parameter name='contour_highlight_colour' from='string' to='Colour'
+             member='colour' default='blue' priority='0.2'>
+         <documentation> Colour of highlight line </documentation>
+         <release>Magics++0.2</release>
+         <migration> New Magics: Parameter Contour sent to new Magics[Contour].  </migration>
+  </parameter>
+
+  <parameter name='contour_highlight_thickness' from='int' to='int'
+             member='thickness' default='3' priority='0.2'>
+         <release>Magics++0.2</release>
+         <documentation> Thickness of highlight line </documentation>
+         <migration> New Magics: Parameter Contour sent to new Magics[Contour].  </migration>
+  </parameter>
+
+  <parameter name='contour_highlight_frequency' from='int' to='int'
+             member='frequency'  default='4'  priority='0.2'>
+         <release>Magics++0.2</release>
+         <documentation> Frequency of highlight line </documentation>
+         <migration> New Magics: Parameter contour_highlight_frequency sent to new Magics[Contour].  </migration>
+  </parameter>
+</class>
+
+<class name='NoIsoHighlight' action='pcont' xmltag='nohighlight' include='IsoHighlight.h'  doc_inherits='no' directory='visualisers' />
+
+</magics>
diff --git a/src/xml/IsoLabel.xml b/src/xml/IsoLabel.xml
new file mode 100644
index 0000000..681681f
--- /dev/null
+++ b/src/xml/IsoLabel.xml
@@ -0,0 +1,85 @@
+
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='IsoLabel' xmltag='label' inherits='NoIsoLabel' action='pcont' prefix='contour/contour/contour_label' directory='visualisers'>
+  <documentation>
+  The action routine PCONT will plot labels on contour lines either by default
+  or as directed by the user. 
+  Contour labels may be plotted with different attributes from the contour line, 
+  e.g. colour and thickness. 
+  Contour labels are, by default, plotted on every 2nd contour line, 
+  but this may be changed by the user, if desired.
+  </documentation>
+  <parameter name='contour_label_type' from='string' to='string'
+             member='type' default='number' >
+         <documentation> Type of label (TEXT/NUMBER/BOTH) </documentation>
+         <migration> New Magics: Parameter contour_label_type sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++2.8</release>
+         <release_info>number is used by default in: expected in 0.6 </release_info>
+  </parameter>
+  
+  <parameter name='contour_label_text' from='string' to='string' member='text' default='' >
+         <documentation> Text for labels </documentation>
+         <migration> New Magics: Parameter Contour sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++2.8</release>
+  </parameter>
+
+  <parameter name='contour_label_height' from='float' to='float' member='height' xml='height' default='0.3'>
+         <documentation> Height of contour labels </documentation>
+         <migration> New Magics: Parameter contour_label_height sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='contour_label_format' from='string' to='string' member='format' xml='format' default='(automatic)' >
+         <documentation> Format of contour labels (MAGICS Format/(AUTOMATIC)) </documentation>
+         <migration> New Magics: Parameter contour_label_format sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='contour_label_blanking' from='string' to='bool' member='blanking' xml='blanking' default='on' >
+         <documentation>Label Blanking</documentation>
+         <release>Magics++ 0.4</release>
+  </parameter>
+
+  <parameter name='contour_label_quality' from='string' to='string' member='quality' xml='quality' default='low' implemented='no'>
+         <documentation> (LOW/MEDIUM/HIGH) </documentation>
+         <release>Deprecated </release>
+         <release_info> Use label_font and label_font_style</release_info>
+  </parameter>
+  
+  <parameter name='contour_label_font' from='string' to='string' member='font' default='sansserif'>
+         <documentation> Name of the font  </documentation>
+         <migration> New Magics: Parameter contour_label_quality sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++0.1</release>
+  </parameter>
+  
+  <parameter name='contour_label_font_style' from='string' to='string'
+             member='style' xml='font_style' default='normal'>
+         <documentation>Style of the font bold/italic</documentation>
+         <migration>New Magics: Parameter contour_label_quality sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++ 1.4</release>
+  </parameter>
+
+  <parameter name='contour_label_colour' from='string' to='string'
+             member='colour'
+			 default='contour_line_colour'>
+         <documentation> Colour of contour labels </documentation>
+         <migration> New Magics: Parameter contour_label_colour sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++0.4</release>
+        
+  </parameter>
+
+  <parameter name='contour_label_frequency' from='int' to='int'
+             member='frequency' 
+			 default='2'>
+         <documentation> Every Nth contour line is labelled </documentation>
+         <migration> New Magics: Parameter contour_label_frequency sent to new Magics[IsoLabel].  </migration>
+         <release>Magics++0.4</release>
+         
+  </parameter>
+</class>
+
+<class name='NoIsoLabel' xmltag='nolabel' action='pcont' used_by='IsoPlot' directory='visualisers'  doc_inherits='no' include='IsoLabel.h'/>
+
+</magics>
diff --git a/src/xml/IsoPlot.xml b/src/xml/IsoPlot.xml
new file mode 100644
index 0000000..8805fe8
--- /dev/null
+++ b/src/xml/IsoPlot.xml
@@ -0,0 +1,86 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+ 
+<class name='IsoPlot' 
+                      action='pcont' used_by='Contour' xmltag='isoline'
+                      directory='visualisers' prefix='contour/contour_line'>
+  <documentation> This object contains all the attributes of the isolines </documentation>
+
+
+<parameter name='contour_special_legend' from='string' to='string' member='legend_special' default='' visible='off'> 
+		<documentation> Used in wrep to produce specail legend such as spaguetti! </documentation>
+		<release>2.10</release>
+</parameter>
+  
+<parameter name='contour_internal_reduction_factor' from='float' to='float' documented='off'  member='resolution' default='4' visible='no'>
+         <documentation> internal factor for contouring   </documentation>
+         <release>2.10</release> 
+</parameter>
+<parameter name='contour_internal_technique' from='string' to='string' documented='off'  member='technique' default='interpolate' visible='no'>
+         <documentation> internal technique for contouring : interpolate/nearest   </documentation>
+</parameter>
+
+<parameter name='contour_legend_text' from='string' to='string' documented='off'  member='legend_text' default=' ' visible='no'>
+         <documentation>Text to be used in legend</documentation>
+         <release>2.10</release>
+	 <!-- Introduced for WREP for standalone titles -->
+</parameter>
+
+<parameter name='contour_line_style' from='string' to='LineStyle' member='style' xml='style' default='solid'>
+         <documentation> Style of contour line  </documentation>
+         <migration> New Magics: Parameter contour_line_style sent to new Magics[IsoPlot].  </migration>
+         <release>0.1</release>
+</parameter>
+
+<parameter name='contour_line_thickness' from='int' to='int' member='thickness' xml='thickness' default='1' >
+         <documentation> Thickness of contour line </documentation>
+         <migration> New Magics: Parameter contour_line_thickness sent to new Magics[IsoPlot].  </migration>
+         <release>0.1</release>
+</parameter>
+
+<parameter name='contour_line_colour' from='string' to='Colour' member='colour' xml='colour' default='blue'>
+         <documentation> Colour of contour line </documentation>
+         <migration> New Magics: Parameter contour_line_colour sent to new Magics[IsoPlot].  </migration>
+         <release>0.1</release>
+</parameter>
+
+<parameter name='contour_highlight' from='string' to='NoIsoHighlight' member='highlight' xml='highlight' include='IsoHighlight.h' default='on' priority='0.2'>
+         <documentation> Plot contour highlights (ON/OFF) </documentation>
+          <option name='IsoHighlight'   fortran='on'  xml='highlight' include='IsoHighlight.h' />
+         <option name='NoIsoHighlight' fortran='off' xml='nohighlight'  include='IsoHighlight.h' />
+         <migration> New Magics: Parameter contour_highlight sent to new Magics[IsoPlot].  </migration>
+         <release>0.2</release>         
+</parameter>
+  
+<parameter name='contour_level_selection_type' from='string' to='LevelSelection' member='levelSelection' xml='level_selection_type' default='count'>
+         <documentation> count: calculate a reasonable  contour interval taking into account the min/max and the requested number of isolines. 
+         interval: regularly spaced intervals using the reference_level as base.
+         level_list: uses the given list of levels. </documentation>
+           <option name='CountSelectionType'   fortran='count'  xml='count' include='CountSelectionType.h'/>
+         <option name='IntervalSelectionType'   fortran='interval'  xml='interval' include='IntervalSelectionType.h'/>
+         <option name='LevelListSelectionType'   fortran='level_list'  xml='list' include='LevelListSelectionType.h'/>
+</parameter>
+
+<parameter name='contour_label' from='string' to='NoIsoLabel' include="IsoLabel.h" member='label' xml='label' default='on'>
+         <documentation> Plot labels on contour lines  </documentation>
+         <migration> New Magics: Parameter Contour sent to new Magics[Contour].  </migration>
+         <release>0.1</release>
+          <option name='IsoLabel'   fortran='on'  xml='label' include='IsoLabel.h' />
+         <option name='NoIsoLabel' fortran='off' xml='nolabel'  include='IsoLabel.h'/>
+</parameter>
+
+<parameter name='contour_shade' from='string' to='NoIsoShading'  include='IsoShading.h' member='shading' xml='shade' default='off'>
+         <documentation> Turn shading on </documentation>
+         <migration> New Magics: Parameter contour_label sent to new Magics[Contour].  </migration>
+         <release>0.2</release>
+         <option name='IsoShading'   fortran='on'  xml='shading' include='IsoShading.h'/>
+         <option name='NoIsoShading' fortran='off' xml='noshading'  include='IsoShading.h' />
+  </parameter>
+<parameter name='contour_legend_only' from='string' to='bool' member='legend_only' default='off'> 
+		<documentation> Inform the contour object do generate only the legend and not the plot!</documentation>  		       
+		<release>2.10</release>
+</parameter>
+</class>
+<class name='NoIsoPlot'  include='IsoPlot.h' inherits='IsoPlot' inherits_doc_inherits='no' directory='visualisers'/> 
+
+</magics>
diff --git a/src/xml/IsoShading.xml b/src/xml/IsoShading.xml
new file mode 100644
index 0000000..a7039dd
--- /dev/null
+++ b/src/xml/IsoShading.xml
@@ -0,0 +1,177 @@
+
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='NoIsoShading' action='pcont'  doc_inherits='no' include='IsoShading.h' directory='visualisers'  />
+
+<class name='IsoShading' action='pcont' xmltag='shading' inherits='NoIsoShading' 
+	directory='visualisers'
+	prefix='contour/contour/contour_shade/contour_shade/contour_shade'>
+
+   <parameter name='contour_shade_technique' from='string' to='ShadingTechnique'  member='technique'  default='polygon_shading'>
+         <documentation> Technique used for shading (POLYGON_SHADING/ CELL_SHADING/ MARKER) </documentation>
+         <option name= 'PolyShadingTechnique' fortran ='polygon_shading' xml='polygon' include='PolyShadingTechnique.h' />
+          <option name= 'GridShading' fortran ='grid_shading' xml='grid_shading' include='PolyShadingTechnique.h' visible='no' />
+         <option name= 'CellShading' fortran ='cell_shading' xml='cell_shading' include='CellShading.h' visible='no' />
+         <option name= 'MarkerShadingTechnique' fortran ='marker' xml='marker' include='MarkerShadingTechnique.h' /> 
+         <release>0.2</release>
+  </parameter>
+  
+  <parameter name='contour_shade_max_level' from='float' to='float'  member='max' default='1.0e+21' >
+         <documentation> Maximum level for which shading is required </documentation>
+          <release>0.2</release>
+  </parameter>
+
+  <parameter name='contour_shade_min_level' from='float' to='float' member='min' default='-1.0e+21'>
+         <documentation> Minimum level for which shading is required </documentation>
+          <release>0.2</release>
+  </parameter>
+  
+  <parameter name='contour_shade_colour_method' from='string' to='ColourTechnique' member='colourMethod' default='calculate'>
+         <documentation> Method of generating the colours of the bands in contour shading (LIST/CALCULATE) </documentation>
+         <option name='CalculateColourTechnique' fortran='calculate' xml='calculate' include='CalculateColourTechnique.h'/>
+         <option name='ListColourTechnique' fortran='list' xml='list' include='ListColourTechnique.h'/>
+  </parameter>
+  
+ 
+</class>
+
+
+<class name='ShadingTechnique' include='ShadingTechnique.h'  directory='visualisers' />
+<class name='PolyShadingMethod' include='PolyShadingMethod.h'  directory='visualisers'/>
+
+
+<class name='PolyShadingTechnique' action='pcont' 
+	 directory='visualisers' inherits='ShadingTechnique' prefix='contour/contour/contour_shade/contour_shade/contour_shade' xmltag='polygon'>
+
+  <parameter name='contour_shade_method' from='string' to='PolyShadingMethod'  member='method'   default='dot'>
+         <documentation> Method used for shading (DOT/ AREA_FILL/ HATCH) </documentation>
+         <option name='PolyShadingMethod' fortran='area_fill' xml='area_fill'  include='PolyShadingMethod.h'/>
+         <option name='DotPolyShadingMethod' fortran='dot' xml='dot'  include='DotPolyShadingMethod.h'/>
+         <option name='HatchPolyShadingMethod' fortran='hatch' xml='hatch'  include='HatchPolyShadingMethod.h'/>
+  </parameter>
+</class>
+
+
+<class name='CellShading' action='pcont' 
+	xmltag='cell_shading' directory='visualisers' 
+	inherits='ShadingTechnique'  prefix='contour/contour/contour_shade/contour_shade_cell'>
+	
+  <parameter name='contour_shade_cell_resolution' from='float' to='float' member='resolution' default='10'>
+         <documentation> Number of cells per cm for CELL shading </documentation> 
+         <release>0.8</release>
+  </parameter>
+  
+  <parameter name='contour_shade_cell_method' from='string' to='string' member='method' default='nearest'>
+         <documentation> NMethod of determining the colour of a cell (INTERPOLATE/ NEAREST) </documentation>
+         <release>0.8</release>
+  </parameter>
+</class>
+
+
+<class name='GridShading' action='pcont'  inherits='PolyShadingTechnique' include='PolyShadingTechnique.h' directory='visualisers'  >
+
+  <parameter name='contour_grid_shading_position' from='string' to='string'  member='position' default='middle'>
+         <documentation> Middle : the point is in the midlle of the cell, bottom_left : the point is in the bottom left corner </documentation>
+         <release>0.2</release>
+  </parameter>
+  </class>
+
+<class name='MarkerShadingTechnique' action='pcont' directory='visualisers'
+	inherits='ShadingTechnique' xmltag='marker' prefix='contour/contour/contour_shade/contour_shade/contour_shade'>
+	
+  <parameter name='contour_shade_colour_table' from='stringarray' to='stringarray' member='colour' default='stringarray()'>
+         <documentation> Colour table to be used with MARKER shading technique </documentation>
+  </parameter>
+
+  <parameter name='contour_shade_height_table' from='floatarray' to='floatarray' member='height' default='floatarray()'>
+         <documentation> Height table to be used with MARKER shading technique </documentation>
+         <release>0.2</release>
+  </parameter>
+
+  <parameter name='contour_shade_marker_table' from='intarray' to='intarray' member='marker' default='intarray()'>
+         <documentation> Marker table to be used with MARKER shading technique </documentation>
+         <release>0.2</release>
+  </parameter>
+</class>
+
+
+<class name='CalculateColourTechnique' action='pcont' directory='visualisers'   inherits='ColourTechnique'
+	implements='ColourTableDefinitionComputeInterface'  xmltag='calculate' prefix='contour/contour/contour_shade/contour_shade/contour_shade'>
+	
+  <parameter name='contour_shade_max_level_colour' from='string' to='Colour' member='max'  default='blue'>
+         <documentation> Highest shading band colour </documentation>
+         <release>0.2</release>
+  </parameter>
+
+  <parameter name='contour_shade_min_level_colour' from='string' to='Colour' member='min'  default='red'>
+         <documentation> Lowest shading band colour </documentation>
+         <release>0.2</release>
+  </parameter>
+  
+  <parameter name='contour_shade_colour_direction' from='string' to='string' member='direction'  default='anti_clockwise' values='clockwise/anti_clockwise'>
+         <documentation> Direction of colour sequencing for shading (CLOCKWISE/ ANTI_CLOCKWISE) </documentation>
+         <release>0.2</release>
+  </parameter>
+
+</class>
+
+
+<class name='ListColourTechnique' action='pcont' directory='visualisers' implements='ColourTableDefinitionListInterface' 
+	   inherits='ColourTechnique'  prefix='contour/contour/contour_shade/contour_shade/contour_shade' xmltag='list'>
+	   
+  <parameter name='contour_shade_colour_list'  colourlist='on' from='stringarray' to='stringarray' member='values'  default='stringarray()'>
+         <documentation> List of colours to be used in contour shading. </documentation>
+         <release>0.2</release>
+  </parameter>
+</class>
+
+
+<class name = 'DotPolyShadingMethod' action = 'pcont' directory='visualisers' 
+	inherits='PolyShadingMethod'  prefix='contour/contour/contour_shade/contour_shade/contour_shade' xmltag='dot'>
+
+  <parameter name='contour_shade_dot_size' from='float' to='float' member='size' default='0.02'>
+         <documentation> Size of dot in shading pattern </documentation>
+         <release>0.2</release>
+  </parameter>
+
+ <parameter name='contour_shade_max_level_density' from='float' to='float' member='max_density' default='50.0'>
+    <documentation> Dots/square centimetre in highest shading band </documentation>
+    <release>0.2</release>
+ </parameter>
+
+ <parameter name='contour_shade_min_level_density' from='float' to='float' member='min_density' xml='min_level_density' default='1.0'>
+         <documentation> Dots/square centimetre in lowest shading band </documentation>
+         <release>0.2</release>
+ </parameter>
+
+ <parameter name='contour_shade_angle' from='float' to='float' member='angle' default='45.0'>
+         <documentation> Angle of shading line to the horizontal in degrees in an anticlockwise direction </documentation>
+         <release>0.2</release>
+  </parameter>
+</class>
+
+
+<class name = 'HatchPolyShadingMethod' action = 'pcont' directory='visualisers' 
+	inherits='PolyShadingMethod'  prefix='contour/contour/contour_shade/contour_shade/contour_shade_hatch' xmltag='hatch'> 
+
+  <parameter name='contour_shade_hatch_index' from='int' to='int' member='index' default='0' >
+         <documentation>The hatching pattern(s) to use. 0 Provides an automatic sequence of patterns, other values set a constant pattern across all contour bands.</documentation>
+         <release>0.8</release>
+  </parameter>
+
+  <parameter name='contour_shade_hatch_thickness' from='int' to='int' member='thickness' default='1' >
+         <documentation> Thickness of hatch lines </documentation>
+         <release>0.5</release>
+  </parameter>
+
+  <parameter name='contour_shade_hatch_density' from='float' to='float' member='density' default='18.0' >
+         <documentation> Number of hatch lines per cm. </documentation>
+         <release>0.5</release>
+  </parameter>
+</class>
+
+
+<class name='ColourTechnique'  directory='visualisers' />
+
+</magics>
diff --git a/src/xml/KMLDriver.xml b/src/xml/KMLDriver.xml
new file mode 100644
index 0000000..e27440d
--- /dev/null
+++ b/src/xml/KMLDriver.xml
@@ -0,0 +1,58 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='KMLDriver' action='KML' directory='drivers' inherits='BaseDriver' xmltag='kml' prefix='kml'>
+	<documentation for_docs='no'>
+		This output driver produces output in the KML (Keyhole XML) format. This is the input format for 
+		Google Earth (http://earth.google.com) and Google Maps (http://maps.google.com).
+		
+		The output driver differs much from other drivers, because it describes not only a two-dimensional 
+		visualisation but also describes the dimensions of height and time.
+
+		See also the parameters for the BaseDriver.
+	</documentation>
+
+<parameter name='kml_kmz' from='string' to='bool' member='kmz' default='on'>
+  <documentation>Defines if output files will be zipped into a KMZ file.</documentation>
+</parameter>
+
+<parameter name='kml_description' from='string' to='string' member='description' default='Generated by Magics++'>
+  <documentation>Short description for the product.</documentation>
+</parameter>
+
+<parameter name='kml_author' from='string' to='string' member='author' default=''>
+  <documentation>Gives the author of the product.</documentation>
+</parameter>
+
+<parameter name='kml_link' from='string' to='string' member='link' default=''>
+  <documentation>Gives the HTTP link to the product (Example: http://www.ecmwf.int/products).</documentation>
+</parameter>
+
+<parameter name='kml_height' from='float' to='float' member='height' default='5.0'>
+  <documentation>Default height of all layers! [This is still WORK IN PROGRESS!!!]</documentation>
+</parameter>
+
+<parameter name='kml_latitude' from='float' to='float' member='latitude' default='40.0'>
+  <documentation>Defines the latitude of initial viewpoint.</documentation>
+  </parameter>
+
+<parameter name='kml_longitude' from='float' to='float' member='longitude' default='0.0'>
+  <documentation>Defines the longitude of initial viewpoint.</documentation>
+</parameter>
+
+<parameter name='kml_transparency' from='int' to='int' member='transparency' default='100'>
+  <documentation>Defines the transparency in percentage ( 0% = invisible) of the layers saved.</documentation>
+</parameter>
+
+<parameter name='kml_tilt' from='int' to='int' member='tilt' default='0'>
+  <documentation>Defines the tilting angle for the default view (0 equals from above).</documentation>
+</parameter>
+
+<parameter name='kml_range' from='int' to='int' member='range' default='6000'>
+  <documentation>Defines the distance (km) to the default view in km.</documentation>
+</parameter>
+
+<parameter name='kml_coastlines' from='string' to='bool' member='coastlines' default='off'>
+  <documentation>Determines if coastlines are plotted by Magics or not. Default is OFF because Google Earth and Google Maps have their own coastlines.</documentation>
+</parameter>
+</class>
+</magics>
diff --git a/src/xml/LabelPlotting.xml b/src/xml/LabelPlotting.xml
new file mode 100644
index 0000000..199f428
--- /dev/null
+++ b/src/xml/LabelPlotting.xml
@@ -0,0 +1,84 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='LabelPlotting' action='pcoast'  directory='visualisers' 
+	xmltag='label' prefix='map/map_label' inherits='NoLabelPlotting'>
+	<documentation>
+		This object will control the settings of the Map Labels.
+	</documentation>
+        <parameter name='map_label_quality' from='string' to='string'
+            member='quality' default='MEDIUM' >
+            <documentation>
+            Quality of grid labels
+           </documentation>
+            <release>Magics++0.1</release>
+       </parameter>
+       <parameter name='map_label_colour' from='string' to='Colour'
+            member='colour' default='black'>
+            <documentation>
+            Colour of map labels
+           </documentation>
+            <release>Magics++0.1</release>
+       </parameter>
+       <parameter name='map_label_height' from='float' to='float'
+            member='height' default='0.25'>
+            <documentation>
+            Height og grid labels
+           </documentation>
+            <release>Magics++0.1</release>
+       </parameter>
+       
+        <parameter name='map_label_latitude_frequency' from='int' to='int'
+            member='latFrequency' default='1'>
+            <documentation>
+            Evry Nth latitue grid is labelled
+           </documentation>
+            <release>Magics++0.1</release>
+       </parameter>
+        <parameter name='map_label_longitude_frequency' from='int' to='int'
+            member='lonFrequency' default='1'>
+            <documentation>
+            Evry Nth longitude grid is labelled
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+        <parameter name='map_label_left' from='string' to='bool'
+            member='left' default='on'>
+            <documentation>
+           Enable the labels on the left of the map
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+       <parameter name='map_label_right' from='string' to='bool'
+            member='right' default='on'>
+            <documentation>
+           Enable the labels on the right of the map
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+       <parameter name='map_label_top' from='string' to='bool'
+            member='top' default='on'>
+            <documentation>
+           Enable the labels on the top of the map
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+       <parameter name='map_label_bottom' from='string' to='bool'
+            member='bottom' default='on'>
+            <documentation>
+           Enable the labels on the bottom of the map
+           </documentation>
+           <release>Magics++0.1</release>
+       </parameter>
+</class>
+
+
+<class name='NoLabelPlotting' xmltag='nolabel' action='pcoast' 
+	directory='visualisers' include='LabelPlotting.h'>
+   <documentation>
+   This object suppresses the plotting of the map grid labels
+   </documentation>
+</class>
+
+   
+</magics>
diff --git a/src/xml/Landgram.xml b/src/xml/Landgram.xml
new file mode 100644
index 0000000..49143f6
--- /dev/null
+++ b/src/xml/Landgram.xml
@@ -0,0 +1,63 @@
+<magics>
+<class name='LandgramDecoder' directory='decoders' xmltag='landgram' prefix='landgram'>
+  <documentation> Landgram aplication</documentation>
+
+  <parameter name='landgram_input_file_name' from='string' to='string'
+             member='path' default=''>
+         <documentation> path to the file containing the xml description of the lansdgram</documentation>
+  </parameter>
+  <parameter name='landgram_input_scaling_factor' from='float' to='float'
+             member='scaling' default='1'>
+         <documentation> path to the file containing the xml description of the lansdgram</documentation>
+  </parameter>
+  <parameter name='landgram_input_offset_factor' from='float' to='float'
+             member='offset' default='0'>
+         <documentation> path to the file containing the xml description of the lansdgram</documentation>
+  </parameter>
+  <parameter name='landgram_title' from='string' to='string'
+             member='title' default='landgram parameter'>
+         <documentation> title to display </documentation>
+  </parameter>
+</class>
+<class name='LandgramBox' directory='visualisers' xmltag='landgrambox' prefix='landbox'>
+  <documentation> LandBox visualisation</documentation>
+<parameter name='landgram_width' from='float' to='float'
+             member='width' default='6'>
+         <documentation> Colour of the box </documentation>
+  </parameter>
+  <parameter name='landgram_top_box1_colour' from='string' to='Colour'
+             member='top1_colour' default='evergreen'>
+         <documentation> Colour of the box </documentation>
+  </parameter>
+   <parameter name='landgram_top_box1_shading' from='string' to='string'
+             member='top1_shading' default='solid'>
+         <documentation> could be solid or dot</documentation>
+  </parameter>
+   <parameter name='landgram_top_box2_colour' from='string' to='Colour'
+             member='top2_colour' default='evergreen'>
+         <documentation> Colour of the box </documentation>
+  </parameter>
+   <parameter name='landgram_top_box2_shading' from='string' to='string'
+             member='top2_shading' default='dot'>
+         <documentation> could be solid or dot</documentation>
+  </parameter>
+  <parameter name='landgram_bottom_box1_colour' from='string' to='Colour'
+             member='bottom1_colour' default='evergreen'>
+         <documentation> Colour of the box </documentation>
+  </parameter>
+   <parameter name='landgram_bottom_box1_shading' from='string' to='string'
+             member='bottom1_shading' default='solid'>
+         <documentation> could be solid or dot</documentation>
+  </parameter>
+  
+  <parameter name='landgram_bottom_box2_colour' from='string' to='Colour'
+             member='bottom2_colour' default='evergreen'>
+         <documentation> Colour of the box </documentation>
+  </parameter>
+   <parameter name='landgram_bottom_box2_shading' from='string' to='string'
+             member='bottom2_shading' default='dot'>
+         <documentation> could be solid or dot</documentation>
+  </parameter>
+</class>
+</magics>
+
diff --git a/src/xml/Layout.xml b/src/xml/Layout.xml
new file mode 100644
index 0000000..e188452
--- /dev/null
+++ b/src/xml/Layout.xml
@@ -0,0 +1,54 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<!--class name='MagicsSingleton' action ='popen' embedded_object='AutomaticPlotManager' directory='common'>
+    <parameter name='layout' from='string' to='PlotManager'
+             member='layout' xml='layout'
+			 default='automatic'>
+         <documentation> Type of page layout (POSITIONAL/AUTOMATIC) </documentation>
+         <migration> New Magics: Parameter layout sent to new Magics[MagicsSingleton].  </migration>
+         <available>automatic</available>
+         <available>positional</available>
+         <release>Magics++0.2</release>
+         <release_info>Only the automatic layout has been implemented</release_info>
+   </parameter>
+
+   
+</class-->
+
+<class name='AutomaticPlotManager' action='popen/pnew' directory='common'>
+  <documentation> Object used to handle the call to the Pseudo action routine PNEW </documentation>
+  <parameter name='plot_start' from='string' to='string'
+             member='plot_start' xml='plot_start'
+			 default='bottom'>
+         <documentation> Position of first page plotted (BOTTOM/TOP) </documentation>
+         <migration> New Magics: Parameter plot_start sent to new Magics[Page].  </migration>
+         <release>Magics++0.2</release>
+  </parameter>
+
+  <parameter name='plot_direction' from='string' to='string'
+             member='plot_direction' xml='plot_direction'
+			 default='vertical'>
+         <documentation> Direction of plotting (HORIZONTAL/VERTICAL) </documentation>
+         <migration> New Magics: Parameter plot_direction sent to new Magics[Page].  </migration>
+         <release>Magics++0.2</release>
+  </parameter>
+
+  <parameter name='page_x_gap' from='float' to='float'
+             member='page_x_gap' xml='page_x_gap'
+			 default='0.0cm' implemented='no'>
+         <documentation> Gap between pages in X direction </documentation>
+         <migration> New Magics: Parameter page_x_gap sent to new Magics[Page].  </migration>
+         <release>Magics++0.2</release>
+         <release_info>Not fully implemented</release_info>
+  </parameter>
+
+  <parameter name='page_y_gap' from='float' to='float'
+             member='page_y_gap' xml='page_y_gap'
+			 default='0.0cm' implemented='no'>
+         <documentation> Gap between pages in Y direction </documentation>
+         <migration> New Magics: Parameter page_y_gap sent to new Magics[Page].  </migration>
+         <release>Magics++0.2</release>
+          <release_info>Not fully implemented</release_info>
+  </parameter>
+</class>
+</magics>
diff --git a/src/xml/Legend.xml b/src/xml/Legend.xml
new file mode 100644
index 0000000..7b8b90f
--- /dev/null
+++ b/src/xml/Legend.xml
@@ -0,0 +1,269 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='NoLegendVisitor' directory='basic' include='LegendVisitor.h'/> 
+
+<class name='LegendVisitor' action='legend'  xmltag='legend' prefix='legend' directory='basic' xml_doc_inherits='XmlBasicNode'>
+	<documentation>
+	   Collection of parameters defining how a legend will be plotted. To plot a legend the parameter 'Legend' 
+	   needs to set to 'on'. 
+	</documentation>
+
+<parameter name='legend_text_colour' from='string' to='Colour' member='colour' default='blue' metview_default='navy'>
+    <documentation> Legend text colour </documentation>
+    <migration> New Magics: Parameter legend_text_colour sent to new Magics[Legend].  </migration>
+</parameter>
+        
+ <parameter name='legend_title' from='string' to='bool' member='title' default='off' >
+    <documentation> plot legend title text  </documentation>
+    <set value='on' name='legend_title_text'/>
+    <set value='on' name='legend_title_orientation'/>
+</parameter>
+
+<parameter name='legend_title_text' from='string' to='string' member='title_text' default='legend' >
+    <documentation> Text to plot as legend title </documentation>
+</parameter>
+<parameter name='legend_title_orientation' from='string' to='string' member='title_orientation' default='automatic' values='vertical/horizontal/automatic'>
+    <documentation> Orientation of legend title, if automatic the title will be 
+    	horizontal for horizontal legend and vertical for vertical  </documentation>
+</parameter>
+<parameter name='legend_units' from='string' to='bool' member='units' default='off' visible='off'>
+   <documentation> plot legend title text </documentation>
+</parameter>
+
+<parameter name='legend_units_text' from='string' to='string' member='units_text' default='' visible='off' >
+    <documentation> Text to plot as units </documentation>
+</parameter>
+
+<parameter name='legend_user_minimum' from='string' to='bool' member='use_min' default='off' >
+   <documentation> Use of user tailored text for minimum </documentation>
+   <set value='on' name='legend_user_minimum_text'/>
+</parameter>
+
+<parameter name='legend_user_minimum_text' from='string' to='string' member='use_min_text' default='' >
+   <documentation> User tailored text for minimum </documentation>
+</parameter>
+
+<parameter name='legend_user_maximum' from='string' to='bool' member='use_max' default='off' >
+   <documentation> Use of user tailored text for maximum </documentation>
+   <set value='on' name='legend_user_maximum_text'/>
+</parameter>
+
+<parameter name='legend_user_maximum_text' from='string' to='string' member='use_max_text' default='' >
+  <documentation> User tailored text for maximum   </documentation>
+</parameter>
+        
+<parameter name='legend_display_type' from='string' to='LegendMethod' member='method' default='disjoint' metview_default='continuous'>
+            <option name='LegendMethod' fortran='disjoint' xml='disjoint' include='LegendMethod.h'/>
+            <option name='ContinuousLegendMethod' fortran='continuous' xml='continuous' include='LegendMethod.h'/> 
+            <option name='HistogramLegendMethod' fortran='histogram' xml='histogram' include='LegendMethod.h'/>
+            <documentation> type of shaded legend required </documentation>
+</parameter>       
+
+<parameter name='legend_text_format' from='string' to='string' member='format' default='(automatic)'>
+     <documentation> Format of automatic text (MAGICS Format/(AUTOMATIC)) </documentation>
+</parameter>  
+        
+<parameter name='legend_box_mode' from='string' to='string' member='box' default='automatic' values='automatic/positional'>
+        	
+        	<set value='positional' name='legend_box_x_position'/>
+        	<set value='positional' name='legend_box_x_length'/>
+        	<set value='positional' name='legend_box_y_position'/>
+        	<set value='positional' name='legend_box_y_length'/>
+        	<documentation>Whether legend box is positioned automatically or by the user  </documentation>
+</parameter>
+<parameter name='legend_text_font' from='string' to='string' member='font' xml='font' default='sansserif'>
+	<documentation>Font name - please make sure this font is installed!</documentation>
+</parameter>
+<parameter name='legend_text_font_style' from='string' to='string' member='font_style' default='normal' values='normal/bold/italic/bolditalic'>
+		<documentation>Font style. Set this to an empty string in order to remove all styling.</documentation>
+</parameter>
+
+
+  
+<parameter name='legend_text_font_size' from='string' to='string' member='font_dimension' default='0.3' metview_default='0.2'>
+	<documentation>Font size, specified in cm or in % ex: 0.5cm or 10% </documentation>
+</parameter>
+  
+
+<parameter name='legend_text_quality' from='string' to='string' member='text_quality' default='medium' visible='off'>
+	<documentation>Quality of text in legend :
+		deprecated use legend_text_font and legend_text_font_style </documentation>
+</parameter>
+         
+<parameter name='legend_text_orientation' from='float' to='float' member='orientation' default='0' >
+	<documentation>Orientation of the text : horizontal by default </documentation>
+</parameter>
+      
+<parameter name='legend_user_lines' from='stringarray' to='stringarray' member='lines' default='stringarray()' >
+             <documentation> List of text for legend entries </documentation>        
+</parameter>
+
+<parameter name='legend_column_count' from='int' to='int' member='columns' default='1' >
+             <documentation> Number of columns in the legend </documentation>        
+</parameter>
+
+<parameter name='legend_entry_plot_direction' from='string' to='string' member='direction' default='automatic' values='automatic/row/column'>
+             <documentation> Method of filling in legend entries</documentation>        
+</parameter>
+<parameter name='legend_entry_plot_orientation' from='string' to='string' member='entry_orientation' default='bottom_top' values='bottom_top/top_bottom'>
+             <documentation> going from bootom to top ot top to bottom in column mode!   </documentation>        
+</parameter>
+
+<parameter name='legend_text_composition' from='string' to='string' member='composition' 
+		default='automatic_text_only' values='automatic_text_only/user_text_only/both'>
+             <documentation> Determines whether to use automatically-generated or user-generated text (or both) in the legend () </documentation>        
+</parameter>
+
+<parameter name='legend_user_text' from='string' to='string' member='text'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>
+</parameter>
+
+<parameter name='legend_user_text_1' from='string' to='string' member='text1'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter> 
+
+<parameter name='legend_user_text_2' from='string' to='string' member='text2' default='' visible='off' >
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter>
+
+<parameter name='legend_user_text_3' from='string' to='string' member='text3'  default='' visible='off' >
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter>
+
+<parameter name='legend_user_text_4' from='string' to='string' member='text4'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter>
+
+<parameter name='legend_user_text_5' from='string' to='string' member='text5'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter>
+
+<parameter name='legend_user_text_6' from='string' to='string' member='text6'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter>
+
+<parameter name='legend_user_text_7' from='string' to='string' member='text7'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter> 
+
+<parameter name='legend_user_text_8' from='string' to='string' member='text8'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter> 
+
+<parameter name='legend_user_text_9' from='string' to='string' member='text9' default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>        
+</parameter>
+
+<parameter name='legend_user_text_10' from='string' to='string' member='text10'  default='' visible='off'>
+             <documentation> User text to be associated with a legend sub-entry from a multiple entry </documentation>
+</parameter> 
+
+<parameter name='legend_box_x_position' from='float' to='float' member='box_x'  default='0'>
+         <documentation> X coordinate of lower left corner of legend box (Relative to page_x_position) </documentation>
+         <migration> New Magics: Parameter legend_box_x_position sent to new Magics[TextBox].  </migration>
+</parameter>
+
+<parameter name='legend_box_y_position' from='float' to='float' member='box_y'  default='0' >
+         <release>Magics++0.7</release>
+         <documentation> Y coordinate of lower left corner of legend box (Relative to page_y_position) </documentation>
+</parameter>
+
+<parameter name='legend_box_x_length' from='float' to='float' member='box_width'  default='0'>
+         <release>Magics++0.7</release>
+         <documentation> Length of legend box in X direction </documentation>
+</parameter>
+
+<parameter name='legend_box_y_length' from='float' to='float' member='box_height'  default='0'>
+         <documentation> Length of legend box in Y direction </documentation>
+</parameter>
+
+<parameter name='legend_box_blanking' from='string' to='bool' member='blanking' default='off'>
+         <documentation>  blanking of legend box  </documentation>
+</parameter>
+
+<parameter name='legend_border' from='string' to='bool' member='border'  default='off'>
+         <documentation> Plot border around legend box  </documentation>
+         <set value='on' name='legend_border_colour'/>  
+         <set value='on' name='legend_border_line_style'/>
+         <set value='on' name='legend_border_thickness'/>
+</parameter>
+  
+<parameter name='legend_border_line_style' from='string' to='LineStyle' member='border_line_style'  default='solid'>
+         <documentation> Line style of border around legend box </documentation>
+</parameter>
+
+<parameter name='legend_border_colour' from='string' to='Colour' member='border_colour'  default='blue' >
+          <release>Magics++0.7</release>    
+         <documentation> Colour of border around text box (Full choice of colours) </documentation>
+</parameter>
+
+<parameter name='legend_border_thickness' from='int' to='int' member='border_thickness'  default='1'>
+          <release>Magics++0.7</release>    
+         <documentation> Thickness of legend box border </documentation>
+</parameter>
+<parameter name='legend_wrep' from='string' to='bool' member='wrep' default='off' visible='off'>
+    <documentation> activate wrep mode for legend building</documentation>
+</parameter>
+<parameter name='legend_entry_text_width' from='float' to='float' member='text_width' default='60'>
+    <documentation> Width in percent used for the text part of a legend Entry </documentation>
+</parameter>
+<parameter name='legend_entry_border' from='string' to='bool' member='entry_border' default='on' >
+         	<documentation> add a border to the graphical part of each legend entry </documentation>
+         	set value='on' name='legend_entry_border_colour'/>
+   </parameter>  
+ <parameter name='legend_entry_border_colour' from='string' to='Colour' member='entry_border_colour' default='black' >
+         	<documentation> border colour </documentation>
+   </parameter>  
+</class>
+
+
+<class name='LegendBox' xmltag='legend' prefix='legend' action='legend' used_by='Legend' directory='visualisers' />  
+<class name='NoLegendNode' include='LegendNode.h' directory='visualisers'/>
+<class name='XmlLegendNode' include='LegendNode.h' directory='visualisers' inherits='XmlBasicNode/LegendNode'/>
+<class name='AutomaticLegendBox' xmltag='automatic' action='legend'  include='LegendBox.h' inherits='LegendBox' directory='visualisers'/>
+<class name='LegendMethod' action='legend' used_by='Legend' include='LegendMethod.h' directory='visualisers'/>
+
+<class name='ContinuousLegendMethod' action='legend' used_by='Legend' include='LegendMethod.h' inherits='LegendMethod' directory='visualisers'>
+
+<parameter name='legend_label_frequency' from='int' to='int' member='label_frequency' default='1' >
+         	<documentation>Frequency of the labels. </documentation>
+</parameter>
+
+</class>
+<class name='HistogramLegendMethod' action='legend' used_by='Legend' include='LegendMethod.h' inherits='LegendMethod' directory='visualisers'>
+	<parameter name='legend_label_frequency' from='int' to='int' member='label_frequency' default='1' >
+         	<documentation> Frequency of the labels. </documentation>
+   </parameter>
+   <parameter name='legend_histogram_border' from='string' to='bool' member='histo_border' default='on' >
+         	<documentation> add a border to the the bars </documentation>
+   </parameter>  
+  <parameter name='legend_histogram_border_colour' from='string' to='Colour' member='histo_border_colour' default='black' >
+         	<documentation> border colour of the bars</documentation>
+   </parameter>   
+   <parameter name='legend_histogram_mean_value' from='string' to='bool' member='histo_mean' default='off' >
+         	<documentation> show the mean value </documentation>
+   </parameter>  
+    <parameter name='legend_histogram_mean_value_marker' from='int' to='int' member='histo_mean_marker' default='15' >
+         	<documentation> show the mean value </documentation>
+   </parameter> 	
+    <parameter name='legend_histogram_mean_value_marker_colour' from='string' to='Colour' member='histo_mean_colour' default='black' >
+         	<documentation> show the mean value </documentation>
+   </parameter>  
+   <parameter name='legend_histogram_mean_value_marker_size' from='float' to='float' member='histo_mean_size' default='0.4' >
+         	<documentation> show the mean value </documentation>
+   </parameter> 
+   <parameter name='legend_histogram_max_value' from='string' to='bool' member='histo_max' default='on' >
+         	<documentation> show the max value </documentation>
+   </parameter>   
+   <parameter name='legend_histogram_grid_colour' from='string' to='Colour' member='histo_grid_colour' default='black' >
+         	<documentation> Colour of the grids </documentation>
+   </parameter>   
+   <parameter name='legend_histogram_grid_line_style' from='string' to='LineStyle' member='histo_grid_style' default='solid' >
+         	<documentation>  Line Style of the grids </documentation>
+   </parameter>  
+   <parameter name='legend_histogram_grid_thickness' from='int' to='int' member='histo_grid_thickness' default='1' >
+         	<documentation>  thickness of the grids </documentation>
+   </parameter>  
+</class>
+
+</magics>
diff --git a/src/xml/LevelSelection.xml b/src/xml/LevelSelection.xml
new file mode 100644
index 0000000..88ba148
--- /dev/null
+++ b/src/xml/LevelSelection.xml
@@ -0,0 +1,107 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='LevelSelection' action='pcont' directory='visualisers' 
+	prefix='contour' xml_tag='level'>
+  <documentation>  </documentation>
+
+  <parameter name='contour_max_level' from='float' to='float'
+             member='max' 
+			 default='1.0e+21'>
+         <documentation> Highest level for contours to be drawn </documentation>
+         <migration> New Magics: Parameter contour_max_level sent to new Magics[LevelSelection].  </migration>
+         <release>Magics++0.3</release>
+        
+  </parameter>
+
+  <parameter name='contour_min_level' from='float' to='float'
+             member='min' 
+			 default='-1.0e+21'>
+         <documentation> Lowest level for contours to be drawn </documentation>
+         <migration> New Magics: Parameter contour_min_level sent to new Magics[LevelSelection].  </migration>
+         <release>Magics++0.3</release>
+    
+  </parameter>
+  <parameter name='contour_shade_max_level' from='float' to='float'
+             member='max_shade' 
+			 default='1.0e+21'>
+         <documentation> Highest level for contours to be shaded </documentation>
+        
+        
+  </parameter>
+
+  <parameter name='contour_shade_min_level' from='float' to='float'
+             member='min_shade' 
+			 default='-1.0e+21'>
+         <documentation> Lowest level for contours to be shaded </documentation>
+      
+    
+  </parameter>
+</class>
+<class name='LevelListSelectionType' action='pcont' 
+	xmltag='list' prefix='contour' directory='visualisers' inherits='LevelSelection'>
+ <documentation>Users may supply a list of the contour levels to be plotted 
+ by setting the parameter CONTOUR_LEVEL_SELECTION_TYPE to 'LEVEL_LIST' 
+ and passing an array of contour level values. 
+ This method enables users to plot contours with irregular intervals.
+ </documentation>
+ <parameter name='contour_level_list' from='floatarray' to='floatarray'
+             member='list' xml='level_list'
+			 default='floatarray()'>
+         <documentation> List of contour levels to be plotted </documentation>
+         <migration> New Magics: Parameter contour_level_list sent to new Magics[LevelListSelectionType].  </migration>
+         <release>Magics++0.1</release>
+  </parameter>
+</class>
+
+<class name='IntervalSelectionType' action='pcont' 
+	xmltag='interval' prefix='contour/contour/contour' directory='visualisers' inherits='LevelSelection'>
+  <documentation>
+  If the parameter CONTOUR_LEVEL_SELECTION_TYPE is set to 'INTERVAL' , 
+  MAGICS will plot contours at regularly spaced intervals
+  using the value of CONTOUR_REFERENCE_LEVEL as a base
+  and the value in CONTOUR_INTERVAL as the interval between levels.
+  </documentation>
+  <parameter name='contour_reference_level' from='float' to='float'
+             member='reference'  default='0.0'>
+         <documentation> Contour level from which contour interval is calculated </documentation>
+         <release>Magics++0.1</release>        
+  </parameter>
+  <parameter name='contour_interval' from='float' to='float'
+             member='interval'  default='8.0'>
+         <documentation> Interval in data units between two contour lines </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+</class>
+<class name='CountSelectionType' action='pcont' 
+	xmltag='count' prefix='contour/contour/contour_level'
+	directory='visualisers' inherits='LevelSelection'>
+  <documentation>
+  The number of contour levels may be set by the user by setting 
+  the parameter CONTOUR_LEVEL_SELECTION_TYPE to 'COUNT' (default)
+  and CONTOUR_LEVEL_COUNT to the number of levels to be plotted. 
+  MAGICS will then calculate the contour interval
+  and the user's plot will consist of the number of levels specified
+  with a regular contour interval.
+  This is the default method and the default number of levels is 10. 
+  The exact number of contour levels plotted may not be CONTOUR_LEVEL_COUNT as
+  PCONT will always use the value stored in CONTOUR_REFERENCE_LEVEL as a starting point
+  and will pick reasonable values for the contour interval.
+  </documentation>
+  <parameter name='contour_level_count' from='int' to='int'
+             member='levelCount'  default='10'>
+         <documentation> Count or number of levels to be plotted. Magics will try to find "nice levels", 
+         this means that the number of levels could be slightly different from the asked number of levels</documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  <parameter name='contour_level_tolerance' from='int' to='int'
+             member='tolerance'  default='2'>
+         <documentation> Tolerance: Do not use nice levels if the number of levels is really to different [count +/- tolerance] </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  <parameter name='contour_reference_level' from='float' to='float'
+             member='reference'  default='0.0'>
+         <documentation> Contour level from which contour interval is calculated </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+</class>
+</magics>
\ No newline at end of file
diff --git a/src/xml/Makefile.am b/src/xml/Makefile.am
new file mode 100644
index 0000000..7748ce6
--- /dev/null
+++ b/src/xml/Makefile.am
@@ -0,0 +1,134 @@
+AUTOMAKE_OPTIONS	= foreign
+
+
+SUFFIXES: .xml .x .nx
+
+EXTRA_DIST =  \
+	Proj4Projection.xml Drivers.xml  output.xml BaseDriver.xml PostScriptDriver.xml SVGDriver.xml BinaryDriver.xml KMLDriver.xml \
+	Akima.xml ActionRoutines.xml HiLoText.xml XYList.xml \
+	BoxPlot.xml  Histogram.xml   LevelSelection.xml \
+	Epsgram.xml  Landgram.xml    ImagePlotting.xml      MetaData.xml  SubPage.xml \
+	SubPageProj4.xml XYTransformation.xml \
+	Frame.xml              Import.xml        TextVisitor.xml         NetcdfDecoder.xml  SuperPage.xml XmlBox.xml \
+	Axis.xml               NetcdfInterpretor.xml SymbolInput.xml InputData.xml TableDecoder.xml\
+	InputMatrix.xml        SymbolPlotting.xml      XmlPage.xml \
+	Geopoints.xml          Obs.xml        TextVisitor.xml     XmlSubPage.xml \
+	CoastPlotting.xml      Grib.xml               IsoHighlight.xml   ObsPlotting.xml     graph_params.xml \
+	Coastlines.xml         GridPlotting.xml       IsoLabel.xml       ObsStat.xml                          \
+	HiLo.xml               IsoPlot.xml            OdaDecoder.xml     Title.xml           magml.xml \
+	Contour.xml            HiLoMarker.xml         IsoShading.xml     TitleTemplate.xml \
+	HiLoNumber.xml         LabelPlotting.xml      Page.xml           ValuePlot.xml \
+	Layout.xml         PageID.xml           View.xml \
+	HiLoTechnique.xml      Legend.xml  Wind.xml   Taylor.xml SelectionMode.xml \
+	GeoRectangularProjection.xml SatelliteProjection.xml PolarStereographicProjection.xml\
+	EpsJSon.xml ObsJSon.xml QtDriver.xml CairoDriver.xml GDDriver.xml BinningObject.xml
+	
+XML_NODIST=	\
+	Title.nx \
+	XmlBox.nx \
+	Layout.nx \
+	XmlPage.nx \
+	Frame.nx \
+	SatelliteProjection.nx\
+	XYList.nx \
+	InputData.nx \
+	TableDecoder.nx \
+	TitleTemplate.nx \
+	graph_params.nx \
+	Histogram.nx \
+	ObsStat.nx \
+	Landgram.nx \
+	Taylor.nx
+
+NEW_XML_NODIST=	output.nx \
+        Coastlines.nx \
+	CoastPlotting.nx \
+	GridPlotting.nx \
+	LabelPlotting.nx \
+	InputMatrix.nx \
+	Grib.nx \
+	Epsgram.nx \
+	Contour.nx \
+	IsoPlot.nx \
+	IsoShading.nx \
+	IsoLabel.nx \
+	ValuePlot.nx \
+	LevelSelection.nx \
+	View.nx \
+	Page.nx \
+	TextVisitor.nx \
+	SymbolPlotting.nx \
+	SymbolInput.nx \
+	BaseDriver.nx PostScriptDriver.nx SVGDriver.nx BinaryDriver.nx KMLDriver.nx \
+	OdaDecoder.nx \
+	Obs.nx \
+	NetcdfInterpretor.nx \
+	NetcdfDecoder.nx \
+	IsoHighlight.nx \
+	HiLo.nx \
+	HiLoText.nx \
+	Akima.nx \
+	Import.nx \
+	Proj4Projection.nx \
+	SubPage.nx \
+	Wind.nx \
+	ImagePlotting.nx \
+	PageID.nx \
+	ObsPlotting.nx \
+	Legend.nx \
+	SuperPage.nx \
+	XYTransformation.nx \
+	Geopoints.nx \
+	MetaData.nx \
+	BoxPlot.nx \
+	Axis.nx \
+	SymbolPlotting.nx \
+	SelectionMode.nx\
+	EpsJSon.nx ObsJSon.nx BinningObject.nx
+
+PROJECTION_XML= \
+	GeoRectangularProjection.nx \
+	PolarStereographicProjection.nx
+
+
+if MAGICS_QT
+   NEW_XML_NODIST += QtDriver.nx
+endif
+
+if MAGICS_CAIRO
+   NEW_XML_NODIST += CairoDriver.nx
+endif
+
+if MAGICS_RASTER
+   NEW_XML_NODIST += GDDriver.nx
+endif
+
+if MAGICS_PROJ4
+   NEW_XML_NODIST += SubPageProj4.nx
+else 
+   NEW_XML_NODIST += SubPage.nx
+endif
+
+.xml.nx:
+	perl $(top_srcdir)/tools/xml2cc_new.pl $< $(top_srcdir)/src
+	cp $< $@
+	chmod +w $@
+if MAGICS_METVIEW
+	perl $(top_srcdir)/tools/xml2mv.pl $< $(top_srcdir)/src/libMagWrapper
+endif
+	cp $< $@
+	chmod +w $@
+
+.xml.x:
+	perl $(top_srcdir)/tools/xml2cc.pl $< $(top_srcdir)/src
+	cp $< $@
+	chmod +w $@
+
+install:$(XML_NODIST) $(NEW_XML_NODIST) $(PROJECTION_XML)
+
+all: $(XML_NODIST) $(NEW_XML_NODIST) $(PROJECTION_XML) #../common/OutputFactory.h
+	echo "make attributes"
+
+clean-local:
+	-rm -f $(XML_NODIST) $(NEW_XML_NODIST) $(PROJECTION_XML) QtDriver.nx SubPageProj4.nx SubPage.nx
+	-rm -f $(top_srcdir)/src/libMagWrapper/*Wrapper.cc $(top_srcdir)/src/libMagWrapper/*Wrapper.h $(top_srcdir)/src/*/*Attributes.cc $(top_srcdir)/src/*/*Attributes.h
diff --git a/src/xml/Makefile.in b/src/xml/Makefile.in
new file mode 100644
index 0000000..6066885
--- /dev/null
+++ b/src/xml/Makefile.in
@@ -0,0 +1,524 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_QT_TRUE@am__append_1 = QtDriver.nx
+ at MAGICS_CAIRO_TRUE@am__append_2 = CairoDriver.nx
+ at MAGICS_RASTER_TRUE@am__append_3 = GDDriver.nx
+ at MAGICS_PROJ4_TRUE@am__append_4 = SubPageProj4.nx
+ at MAGICS_PROJ4_FALSE@am__append_5 = SubPage.nx
+subdir = src/xml
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+EXTRA_DIST = \
+	Proj4Projection.xml Drivers.xml  output.xml BaseDriver.xml PostScriptDriver.xml SVGDriver.xml BinaryDriver.xml KMLDriver.xml \
+	Akima.xml ActionRoutines.xml HiLoText.xml XYList.xml \
+	BoxPlot.xml  Histogram.xml   LevelSelection.xml \
+	Epsgram.xml  Landgram.xml    ImagePlotting.xml      MetaData.xml  SubPage.xml \
+	SubPageProj4.xml XYTransformation.xml \
+	Frame.xml              Import.xml        TextVisitor.xml         NetcdfDecoder.xml  SuperPage.xml XmlBox.xml \
+	Axis.xml               NetcdfInterpretor.xml SymbolInput.xml InputData.xml TableDecoder.xml\
+	InputMatrix.xml        SymbolPlotting.xml      XmlPage.xml \
+	Geopoints.xml          Obs.xml        TextVisitor.xml     XmlSubPage.xml \
+	CoastPlotting.xml      Grib.xml               IsoHighlight.xml   ObsPlotting.xml     graph_params.xml \
+	Coastlines.xml         GridPlotting.xml       IsoLabel.xml       ObsStat.xml                          \
+	HiLo.xml               IsoPlot.xml            OdaDecoder.xml     Title.xml           magml.xml \
+	Contour.xml            HiLoMarker.xml         IsoShading.xml     TitleTemplate.xml \
+	HiLoNumber.xml         LabelPlotting.xml      Page.xml           ValuePlot.xml \
+	Layout.xml         PageID.xml           View.xml \
+	HiLoTechnique.xml      Legend.xml  Wind.xml   Taylor.xml SelectionMode.xml \
+	GeoRectangularProjection.xml SatelliteProjection.xml PolarStereographicProjection.xml\
+	EpsJSon.xml ObsJSon.xml QtDriver.xml CairoDriver.xml GDDriver.xml BinningObject.xml
+
+XML_NODIST = \
+	Title.nx \
+	XmlBox.nx \
+	Layout.nx \
+	XmlPage.nx \
+	Frame.nx \
+	SatelliteProjection.nx\
+	XYList.nx \
+	InputData.nx \
+	TableDecoder.nx \
+	TitleTemplate.nx \
+	graph_params.nx \
+	Histogram.nx \
+	ObsStat.nx \
+	Landgram.nx \
+	Taylor.nx
+
+NEW_XML_NODIST = output.nx Coastlines.nx CoastPlotting.nx \
+	GridPlotting.nx LabelPlotting.nx InputMatrix.nx Grib.nx \
+	Epsgram.nx Contour.nx IsoPlot.nx IsoShading.nx IsoLabel.nx \
+	ValuePlot.nx LevelSelection.nx View.nx Page.nx TextVisitor.nx \
+	SymbolPlotting.nx SymbolInput.nx BaseDriver.nx \
+	PostScriptDriver.nx SVGDriver.nx BinaryDriver.nx KMLDriver.nx \
+	OdaDecoder.nx Obs.nx NetcdfInterpretor.nx NetcdfDecoder.nx \
+	IsoHighlight.nx HiLo.nx HiLoText.nx Akima.nx Import.nx \
+	Proj4Projection.nx SubPage.nx Wind.nx ImagePlotting.nx \
+	PageID.nx ObsPlotting.nx Legend.nx SuperPage.nx \
+	XYTransformation.nx Geopoints.nx MetaData.nx BoxPlot.nx \
+	Axis.nx SymbolPlotting.nx SelectionMode.nx EpsJSon.nx \
+	ObsJSon.nx BinningObject.nx $(am__append_1) $(am__append_2) \
+	$(am__append_3) $(am__append_4) $(am__append_5)
+PROJECTION_XML = \
+	GeoRectangularProjection.nx \
+	PolarStereographicProjection.nx
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .nx .x .xml
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/xml/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign src/xml/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	clean-local distclean distclean-generic distclean-libtool \
+	distdir dvi dvi-am html html-am info info-am install \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	uninstall uninstall-am
+
+
+SUFFIXES: .xml .x .nx
+
+.xml.nx:
+	perl $(top_srcdir)/tools/xml2cc_new.pl $< $(top_srcdir)/src
+	cp $< $@
+	chmod +w $@
+ at MAGICS_METVIEW_TRUE@	perl $(top_srcdir)/tools/xml2mv.pl $< $(top_srcdir)/src/libMagWrapper
+	cp $< $@
+	chmod +w $@
+
+.xml.x:
+	perl $(top_srcdir)/tools/xml2cc.pl $< $(top_srcdir)/src
+	cp $< $@
+	chmod +w $@
+
+install:$(XML_NODIST) $(NEW_XML_NODIST) $(PROJECTION_XML)
+
+all: $(XML_NODIST) $(NEW_XML_NODIST) $(PROJECTION_XML) #../common/OutputFactory.h
+	echo "make attributes"
+
+clean-local:
+	-rm -f $(XML_NODIST) $(NEW_XML_NODIST) $(PROJECTION_XML) QtDriver.nx SubPageProj4.nx SubPage.nx
+	-rm -f $(top_srcdir)/src/libMagWrapper/*Wrapper.cc $(top_srcdir)/src/libMagWrapper/*Wrapper.h $(top_srcdir)/src/*/*Attributes.cc $(top_srcdir)/src/*/*Attributes.h
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/xml/MetaData.xml b/src/xml/MetaData.xml
new file mode 100644
index 0000000..9cb087a
--- /dev/null
+++ b/src/xml/MetaData.xml
@@ -0,0 +1,37 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='MetaData' xmltag='meta' prefix='metadata' directory='common'>
+  <documentation></documentation>
+  
+  <parameter name='metadata_path' from='string' to='string'
+             member='path' xml='path' default='meta.xml'>
+          <release>Magics 1.1</release>
+         <documentation> Path of the Meta data File </documentation>
+  </parameter>
+  <parameter name='javascript_path' from='string' to='string'
+             member='javascript' default='' >
+          <release>Magics 2.6</release>
+         <documentation> Path of the javascript </documentation>
+  </parameter>
+  <parameter name='profile_path' from='string' to='string'
+             member='profile' default='' >
+          <release>Magics 2.6</release>
+         <documentation> Path of the javascript </documentation>
+  </parameter>
+  <parameter name='world_file_path' from='string' to='string'
+             member='world_file' default='' >
+          <release>Magics 2.6</release>
+         <documentation> if defined,  a world file description will be generated </documentation>
+  </parameter>
+  <parameter name='efi_path' from='string' to='string'
+             member='efi'  default=''>     
+         <documentation> Path of the Meta data File </documentation>
+  </parameter> 
+  <parameter name='efi_template' from='string' to='string'
+             member='efi_template' default='efi_template.js'>     
+         <documentation> Path of the Meta data File </documentation>
+  </parameter> 
+</class>
+
+
+</magics>
diff --git a/src/xml/NetcdfDecoder.xml b/src/xml/NetcdfDecoder.xml
new file mode 100644
index 0000000..d2193d9
--- /dev/null
+++ b/src/xml/NetcdfDecoder.xml
@@ -0,0 +1,47 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='NetcdfDecoder' action='pnetcdf' prefix='netcdf' xmltag='netcdf' 
+	directory='decoders' >
+	<documentation>
+       This handles the decoding of NetCDF Files.
+	</documentation>
+
+    <!--parameter name='netcdf_convention' from='string' to='NetcdfConvention'
+               member='convention' default='mars' >
+        <release>Magics++0.1</release>
+           <option name='NetcdfMarsConvention' fortran='mars' xml='mars'
+                include='NetcdfMarsConvention.h'/>
+        <release_info>Parameter defined but not implemented</release_info>
+        <documentation>Not currently used</documentation>
+    </parameter-->
+
+     <parameter name='netcdf_type' from='string' to='NetcdfInterpretor'
+                member='interpretor' default='matrix'>
+        <option name='NetcdfMatrixInterpretor' fortran='matrix' xml='matrix'
+                include='NetcdfMatrixInterpretor.h'/>
+                
+           <option name='NetcdfGeoMatrixInterpretor' fortran='geomatrix' xml='geomatrix'
+                include='NetcdfGeoMatrixInterpretor.h'/>
+          
+          <option name='NetcdfVectorInterpretor' fortran='vector' xml='vector'
+                include='NetcdfVectorInterpretor.h'/>
+           <option name='NetcdfGeoVectorInterpretor' fortran='geovector' xml='geovector'
+                include='NetcdfVectorInterpretor.h'/>
+           <option name='NetcdfGeoPolarMatrixInterpretor' fortran='geopolarmatrix' xml='geopolarmatrix'
+                include='NetcdfVectorInterpretor.h'/>
+        
+        <option name='NetcdfGeopointsInterpretor' fortran='geopoint' xml='geopoint'
+                include='NetcdfGeopointsInterpretor.h'/>  
+          <option name='NetcdfXYpointsInterpretor' fortran='xypoint'
+                include='NetcdfGeopointsInterpretor.h'/>  
+         <option name='NetcdfOrcaInterpretor' fortran='complex_matrix' xml='complex_matrix'
+                include='NetcdfOrcaInterpretor.h'/>
+
+        <release>Magics++0.1</release>
+        <release_info>Only matrix is implemented</release_info>
+        <documentation>Type of data arrangement in the file (possible values: matrix) </documentation>
+    </parameter>
+</class>
+
+
+</magics>
diff --git a/src/xml/NetcdfInterpretor.xml b/src/xml/NetcdfInterpretor.xml
new file mode 100644
index 0000000..8b04725
--- /dev/null
+++ b/src/xml/NetcdfInterpretor.xml
@@ -0,0 +1,249 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+ 
+<class name='NetcdfInterpretor' action='pnetcdf' xmltag='netcdf' prefix='netcdf' directory='decoders'>
+	<documentation>
+		This object contains this attributes to set how to load the data from the file.
+        It is possible to load only a subarray of the data, by setting the dimensions.
+	</documentation>
+        <parameter name='netcdf_filename' from='string' to='string'
+            member='path' default=''>
+            <release>Magics++0.1</release>
+            <documentation>Path of the file to be read</documentation>
+        </parameter>
+
+        <parameter name='netcdf_dimension_setting' from='stringarray' to='stringarray'
+            member='dimension' default='stringarray()'>
+            <metview default='' class='' >  </metview>
+             <release>Magics++0.1</release>
+            <documentation>The dimensions of the data to load, eg. p/100/10</documentation>
+        </parameter>
+        
+         <parameter name='netcdf_value_variable' from='string' to='string'
+            member='field' default=''>
+              <release>Magics++0.1</release>
+              <documentation>Variable name to plot</documentation>
+        </parameter> 
+       
+          <parameter name='netcdf_field_scaling_factor' from='float' to='float'
+            member='scaling' default='1'>
+            <release>Magics++0.1</release>
+            <documentation>Scaling factor to multiply the field value by</documentation>
+        </parameter>
+         <parameter name='netcdf_field_add_offset' from='float' to='float'
+            member='offset' default='0'>
+            <release>Magics++0.1</release>
+            <documentation>Offset added to the field values</documentation>
+           </parameter>
+           <parameter name='netcdf_missing_attribute' from='string' to='string'
+            member='missing_attribute' default='missing_value'>
+            <release>Magics++2.15</release>
+            <documentation>Attribute to read to know the value used to indicate a missing value in the data</documentation>
+           </parameter>  
+            <parameter name='netcdf_reference_date' from='string' to='string'
+            member='reference' default='0'>
+            <release>Magics++0.7</release>
+            <documentation>attributes name to find the refernce date</documentation>
+           </parameter> 
+           <parameter name='netcdf_field_suppress_below' from='float' to='float'
+             member='suppress_below' default='-1.0e+21' >
+         <documentation> Values in the input field(s) below this value are to be suppressed, i.e. not to be taken into consideration for plotting purposes </documentation>
+  </parameter>
+
+  <parameter name='netcdf_field_suppress_above' from='float' to='float'
+             member='suppress_above'	 default='1.0e+21' >
+         <documentation> Values in the input field(s) above this value are to be suppressed, i.e not to be taken into consideration for plotting purposes </documentation>
+  </parameter>
+</class>
+<class name='NetcdfGeopointsInterpretor' action='pnetcdf' xmltag='geopoints' prefix='netcdf' directory='decoders' inherits='NetcdfInterpretor'>
+  <parameter name='netcdf_latitude_variable' from='string' to='string'
+            member='latitude' default='latitude'>
+             
+              <documentation>Variable name representing the x dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_longitude_variable' from='string' to='string'
+            member='longitude' default='longitude'>
+            
+            <documentation>Variable name representing the y dimension</documentation>
+        </parameter>
+ </class>
+ <class name='NetcdfXYpointsInterpretor' action='pnetcdf' xmltag='xypoints' prefix='netcdf' directory='decoders'
+  inherits='NetcdfInterpretor' include='NetcdfGeopointsInterpretor.h'>
+  <parameter name='netcdf_x_variable' from='string' to='string'
+            member='x' default='x'>
+              <release>Magics++0.1</release>
+              <documentation>Variable name representing the latitude dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_y_variable' from='string' to='string'
+            member='y' default='y'>
+            
+             <release>Magics++0.1</release>
+            <documentation>Variable name representing the longitude dimension</documentation>
+        </parameter>
+ </class>
+ <class name='NetcdfGeoPolarMatrixInterpretor' action='pnetcdf' xmltag='netcdf' prefix='netcdf' directory='decoders' 
+        inherits='NetcdfInterpretor' include='NetcdfVectorInterpretor.h'>
+        <parameter name='netcdf_speed_component_variable' from='string' to='string'
+            member='speed' default=''>
+              <release>Magics++2.6</release>
+              <documentation>Variable name representing the speed component of the vector</documentation>
+        </parameter> 
+         <parameter name='netcdf_direction_component_variable' from='string' to='string'
+            member='direction' default=''>
+             <release>Magics++2.6</release>
+            <documentation>Variable name representing the direction component of the vector</documentation>
+        </parameter>
+        <parameter name='netcdf_latitude_variable' from='string' to='string'
+            member='latitude' default='latitude'>
+              
+              <documentation>Variable name representing the latitude dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_longitude_variable' from='string' to='string'
+            member='longitude' default='longitude'>
+            
+            <documentation>Variable name representing the longitude dimension</documentation>
+        </parameter>
+</class>
+
+<class name='NetcdfGeoVectorInterpretor' action='pnetcdf' xmltag='geopoints' prefix='netcdf' directory='decoders' 
+        inherits='NetcdfInterpretor' include='NetcdfVectorInterpretor.h'>
+        <parameter name='netcdf_x_component_variable' from='string' to='string'
+            member='x_component' default=''>
+              <release>Magics++2.6</release>
+              <documentation>Variable name representing the x component of the vector</documentation>
+        </parameter> 
+         <parameter name='netcdf_y_component_variable' from='string' to='string'
+            member='y_component' default=''>
+             <release>Magics++2.6</release>
+            <documentation>Variable name representing the y component of the vector</documentation>
+        </parameter>
+        <parameter name='netcdf_latitude_variable' from='string' to='string'
+            member='latitude' default='latitude'>
+              <release>Magics++0.1</release>
+              <documentation>Variable name representing the latitude dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_longitude_variable' from='string' to='string'
+            member='longitude' default='longitude'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>Variable name representing the longitude dimension</documentation>
+        </parameter>
+</class>
+<class name='NetcdfVectorInterpretor' action='pnetcdf' xmltag='geopoints' prefix='netcdf' directory='decoders' 
+	inherits='NetcdfInterpretor' >
+        <parameter name='netcdf_x_component_variable' from='string' to='string'
+            member='x_component' default=''>
+              <release>Magics++2.6</release>
+              <documentation>Variable name representing the x component of the vector</documentation>
+        </parameter> 
+         <parameter name='netcdf_y_component_variable' from='string' to='string'
+            member='y_component' default=''>
+             <release>Magics++2.6</release>
+            <documentation>Variable name representing the y component of the vector</documentation>
+        </parameter>
+        <parameter name='netcdf_y_position_variable' from='string' to='string'
+            member='y' default='y'>
+              <release>Magics++0.1</release>
+              <documentation>Variable name representing the x dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_x_position_variable' from='string' to='string'
+            member='x' default='x'>
+            <metview default='' class='' >   </metview>
+            
+            <documentation>Variable name representing the y dimension</documentation>
+        </parameter>
+</class>
+
+<class name='NetcdfGeoMatrixInterpretor' action='pnetcdf' xmltag='geopoints' prefix='netcdf' directory='decoders' 
+         inherits='NetcdfInterpretor'>
+        <parameter name='netcdf_latitude_variable' from='string' to='string'
+            member='latitude' default='latitude'>
+              <release>Magics++0.1</release>
+              <documentation>Variable name representing the latitude dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_longitude_variable' from='string' to='string'
+            member='longitude' default='longitude'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>Variable name representing the longitude dimension</documentation>
+        </parameter>
+         <parameter name='netcdf_longitude_sample' from='int' to='int'
+            member='longitude_sample' default='1'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>sample the input data by taking aa longitude every nth longitude</documentation>
+        </parameter>
+         <parameter name='netcdf_latitude_sample' from='int' to='int'
+            member='latitude_sample' default='1'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>sample the input data by taking a latitude every nth latitude</documentation>
+        </parameter>
+        
+            <parameter name='netcdf_matrix_primary_index' from='string' to='string'
+            member='primary_index' default='longitude'>
+             <release>Magics++2.4</release>
+            <documentation> Primary index latitude/longitude</documentation>
+        </parameter>
+</class>
+<class name='NetcdfOrcaInterpretor' action='pnetcdf' xmltag='geopoints' prefix='netcdf' directory='decoders' 
+         inherits='NetcdfInterpretor'>
+        <parameter name='netcdf_latitude_variable' from='string' to='string'
+            member='latitude' default='latitude'>
+              <release>Magics++0.1</release>
+              <documentation>Variable name representing the latitude dimension</documentation>
+        </parameter> 
+         <parameter name='netcdf_longitude_variable' from='string' to='string'
+            member='longitude' default='longitude'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>Variable name representing the longitude dimension</documentation>
+        </parameter>
+         <parameter name='netcdf_longitude_sample' from='int' to='int'
+            member='longitude_sample' default='1'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>sample the input data by taking aa longitude every nth longitude</documentation>
+        </parameter>
+         <parameter name='netcdf_latitude_sample' from='int' to='int'
+            member='latitude_sample' default='1'>
+            <metview default='' class='' >   </metview>
+             <release>Magics++0.1</release>
+            <documentation>sample the input data by taking a latitude every nth latitude</documentation>
+        </parameter>
+       
+            <parameter name='netcdf_matrix_primary_index' from='string' to='string'
+            member='primary_index' default='longitude'>
+             <release>Magics++2.4</release>
+            <documentation> Primary index latitude/longitude</documentation>
+        </parameter>
+</class>
+<class name='NetcdfMatrixInterpretor' action='pnetcdf' xmltag='geopoints' prefix='netcdf' directory='decoders' inherits='NetcdfInterpretor'>
+        
+         <parameter name='netcdf_y_variable' from='string' to='string'
+            member='y' default='y'>
+             <release>Magics++0.1</release>
+            <documentation>Variable name representing the y dimension</documentation>
+        </parameter>
+        <parameter name='netcdf_x_variable' from='string' to='string'
+            member='x' default='x'>
+             <release>Magics++0.1</release>
+        <documentation>Variable name representing the x dimension</documentation>
+        </parameter> 
+        <parameter name='netcdf_x_auxiliary_variable' from='string' to='string'
+            member='aux_x' default=''>
+             <release>Magics++0.1</release>
+        <documentation>variable can used to define geoline definition.</documentation>
+        </parameter>  
+        <parameter name='netcdf_y_auxiliary_variable' from='string' to='string'
+            member='aux_y' default=''>
+             <release>Magics++0.1</release>
+        <documentation>variable can used to define geoline definition.</documentation>
+        </parameter>
+            <parameter name='netcdf_matrix_primary_index' from='string' to='string'
+            member='primary_index' default='longitude'>
+             <release>Magics++2.4</release>
+            <documentation> Primary index latitude/longitude</documentation>
+        </parameter>
+</class>
+</magics>
diff --git a/src/xml/Obs.xml b/src/xml/Obs.xml
new file mode 100644
index 0000000..35c77b9
--- /dev/null
+++ b/src/xml/Obs.xml
@@ -0,0 +1,26 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name = 'ObsDecoder' action_routine='pobs' directory='decoders' xmltag='bufr' prefix='obs'>
+
+  <parameter name='obs_input_file_name' from='string' to='string' member='file_name' default=''>
+         <documentation> The name of the input file containing the BUFR code field(s) </documentation>
+  </parameter>
+  
+  <parameter name='obs_level' from='int' to='int' member='level' default='500'>
+	<documentation> Pressure level to be plotted (upper air only) </documentation>
+  </parameter>
+  
+  <parameter name='obs_level_2' from='int' to='int' member='level2' default='1000' >
+	<documentation> 2nd pressure level (for thickness plots only) </documentation>
+  </parameter>
+  
+  <parameter name='obs_level_tolerance' from='int' to='int' member='tolerance' default='0'>
+	<documentation> Tolerance (hPa) above and below the requested level for which observations may be plotted (applies to OBS_LEVEL only) </documentation>
+  </parameter>
+
+  <parameter name='obs_type_list' from='stringarray' to='stringarray' member='types' default='stringarray()' >
+	<documentation> A list of observation types (SATEM, TEMP, etc) for which observations are to be plotted </documentation>
+  </parameter>
+</class>
+  
+</magics>
diff --git a/src/xml/ObsJSon.xml b/src/xml/ObsJSon.xml
new file mode 100644
index 0000000..fb87be1
--- /dev/null
+++ b/src/xml/ObsJSon.xml
@@ -0,0 +1,11 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name="ObsJSon" xmltag='obsjson' prefix='obsjson' action='pobsjson'  
+           directory='web' include='ObsJSon.h' >
+ <parameter name='obsjson_input_filename' from='string' to='string' 
+ 	    member='path' default=''>
+  	<documentation> Path to the file containing the Observation data </documentation>
+ </parameter>
+ </class>
+</magics>
diff --git a/src/xml/ObsPlotting.xml b/src/xml/ObsPlotting.xml
new file mode 100644
index 0000000..695842d
--- /dev/null
+++ b/src/xml/ObsPlotting.xml
@@ -0,0 +1,233 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name = 'ObsPlotting' action_routine='pobs' directory='visualisers'  xmltag='obs' prefix='obs'>
+
+ <parameter name='obs_distance_apart' from='float' to='float' member='apart' xml='distance_apart' default='1.0'>
+   <release>Magics++ 2.10</release>
+   <documentation>Minimum distance between the centre of any two observations in cm</documentation>
+ </parameter>
+
+</class>
+<class name = 'ObsTable' action_routine='pobs' directory='visualisers'  xmltag='obs' prefix='obs'>
+
+ <parameter name='obs_template_file_name' from='string' to='string' member='path'  default=''>
+   <release>Magics++ 2.10</release>
+   <documentation> User defined template </documentation>
+ </parameter>
+
+</class>
+
+
+<class name='ObsItem' prefix='obs' action_routine='pobs' directory='visualisers'>
+
+ <parameter name='obs_size' from='float' to='float' member='size' default='0.2'>
+   <documentation> Height of plotted variables </documentation>
+   <release_info>work in progress</release_info>
+ </parameter>
+
+ <parameter name='obs_quality' from='string' to='string' member='obs_quality' default='medium' implemented='no' priority='0.2'>
+    <documentation>Plotting quality of variables (LOW/MEDIUM/HIGH)</documentation>
+ </parameter> 
+
+</class>
+
+
+
+<class name = 'ObsStationRing' xmltag='station' prefix='obs/obs_station' action_routine='pobs' directory='visualisers'>
+
+ <parameter name = 'obs_station_ring' from='string' to='bool' member='visible' default='on'>
+    <documentation> Turn On/off the station ring </documentation>
+ </parameter>
+
+ <parameter name = 'obs_station_ring_colour' from='string' to='Colour' member='colour'  default='foreground'>
+   <documentation> Colour the station ring </documentation>
+ </parameter>
+
+</class>
+
+
+<class name = 'ObsWind' xmltag='wind' prefix='obs'  action_routine='pobs' directory='visualisers'>
+
+ <parameter name = 'obs_wind' from='string' to='bool' member='visible'  default='on'>
+    <documentation> Turn On/off the wind </documentation>
+ </parameter>
+
+ <parameter name = 'obs_wind_colour' from='string' to='Colour' member='colour' default='foreground'>
+    <documentation> Colour the station ring </documentation>
+ </parameter>
+</class>
+
+<class name = 'ObsTemperature'   xmltag='tempe' prefix='obs' action_routine='pobs' directory='visualisers'>
+
+ <parameter name = 'obs_temperature' from='string' to='bool' member='visible' default='on'>
+    <documentation> Turn On/off the Air temperature</documentation>
+ </parameter>
+
+ <parameter name = 'obs_temperature_colour' from='string' to='Colour' member='colour' default='foreground'>
+    <documentation> Colour the station ring </documentation>
+ </parameter>
+</class>
+
+<class name = 'ObsPressure' xmltag='pressure' prefix='obs' action_routine='pobs' directory='visualisers'>
+
+ <parameter name = 'obs_pressure' from='string' to='bool' member='visible'  default='on'>
+    <documentation> Turn On/off the pressure</documentation>
+ </parameter>
+
+ <parameter name = 'obs_pressure_colour' from='string' to='Colour' member='colour' default='foreground'>
+    <documentation> Colour the pressure info </documentation>
+ </parameter>
+</class>
+
+<class name = 'ObsPressureTendency' xmltag='pressure_tendency' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_pressure_tendency' from='string' to='bool' member='visible'  default='on'>
+		<documentation> Turn On/off the pressure</documentation>
+    </parameter>
+    
+    <parameter name = 'obs_pressure_tendency_colour' from='string' to='Colour' member='colour' default='foreground'>
+		<documentation> Colour the pressure info </documentation>
+    </parameter>
+</class>
+
+<class name = 'ObsDewPoint' xmltag='dewpoint' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_dewpoint' from='string' to='bool' member='visible'  default='on'>
+		<documentation> Turn On/off the pressure</documentation>
+    </parameter>
+    <parameter name = 'obs_dewpoint_colour' from='string' to='Colour' member='colour' default='red'>
+		<documentation> Colour the pressure info </documentation>
+    </parameter>
+</class>
+
+<class name = 'ObsVisibility' xmltag='visi' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_visibility' from='string' to='bool' member='visible'  default='on'>
+		<documentation> Turn On/off the pressure</documentation>
+    </parameter>
+    
+    <parameter name = 'obs_visibility_colour' from='string' to='Colour' member='colour' default='foreground'>
+		<documentation> Colour the pressure info </documentation>
+    </parameter>
+</class>
+
+<class name = 'ObsPresentWeather' xmltag='present_weather' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_present_weather' from='string' to='bool' member='visible'  default='on'>
+		<documentation> Turn On/off the pressure</documentation>
+    </parameter>
+
+    <parameter name = 'obs_present_weather_colour' from='string' to='Colour' member='colour' default='foreground'>
+		<documentation> Colour the pressure info </documentation>
+    </parameter>
+</class>
+
+<class name = 'ObsTimePlot' xmltag='time' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_time' from='string' to='bool' member='visible'  default='off'>
+		<documentation> Turn On/off the Air temperature</documentation>
+    </parameter>
+    
+    <parameter name = 'obs_time_colour' from='string' to='Colour' member='colour'  default='foreground'>
+		<documentation> Colour the station ring </documentation>
+    </parameter>
+</class>
+
+<class name = 'ObsThickness' xmltag='thickness' prefix='obs' action_routine='pobs' directory='visualisers'>
+    <parameter name = 'obs_thickness' from='string' to='bool' member='visible'  default='on'>
+        <documentation> Turn On/off the Thickness</documentation>
+        <release>2.6</release>
+    </parameter>
+    
+    <parameter name = 'obs_thickness_colour' from='string' to='Colour' member='colour'  default='foreground'>
+        <documentation> Colour the thickness </documentation>
+    </parameter>
+</class>
+
+
+<class name = 'ObsPressureLevel' xmltag='pressure_level' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_upper_air_pressure' from='string' to='bool' 
+			member='visible'  default='off'>
+		<documentation> Turn On/off the pressure level ( satob)  </documentation>
+    </parameter>
+
+    <parameter name = 'obs_upper_level_pressure_colour' from='string' to='Colour' 
+			member='colour' xml='colour' default='foreground'>
+		<documentation> Colour the station ring </documentation>
+    </parameter>
+</class>
+
+<class name = 'ObsHeight'  xmltag='height' prefix='obs' action_routine='pobs' directory='visualisers'>
+    <parameter name = 'obs_upper_air_pressure' from='string' to='bool' 
+            member='visible'  default='on'>
+        <documentation> Turn On/off the height (geopotential)  </documentation>
+        <release>2.6</release>
+    </parameter>
+    <parameter name = 'obs_height_colour' from='string' to='Colour' 
+            member='colour' default='foreground'>
+        <documentation> Colour of the height information </documentation>
+        <release>2.6</release>
+    </parameter>
+</class>
+
+<class name = 'ObsIdentifier' xmltag='ident' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_identification' from='string' to='bool' 
+			member='visible'  default='off'>
+		<documentation> Turn On/off the pressure level ( satob)  </documentation>
+    </parameter>
+
+    <parameter name = 'obs_identification_colour' from='string' to='Colour' 
+			member='colour'  default='foreground'>
+		<documentation> Colour the identification info </documentation>
+    </parameter>
+</class>
+
+
+<class name = 'ObsPastWeather' xmltag='past_weather' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_past_weather' from='string' to='bool' member='visible'  default='on'>
+		<documentation> Turn On/off the pressure level (satob)</documentation>
+    </parameter>
+    
+    <parameter name = 'obs_past_weather_colour' from='string' to='Colour' member='colour'  default='red'>
+		<documentation> Colour of the past weather </documentation>
+    </parameter>
+</class>
+
+
+<class name = 'ObsCloud' xmltag='cloud' prefix='obs' action_routine='pobs' directory='visualisers'>
+
+    <parameter name = 'obs_cloud' from='string' to='bool' member='visible'  default='on'>
+		<documentation> Turn On/off the pressure level ( satob)  </documentation>
+    </parameter>
+
+    <parameter name = 'obs_low_cloud' from='string' to='bool' member='low'  default='on'>
+		<documentation> Turn On/off the low cloud  </documentation>
+    </parameter>
+    
+    <parameter name = 'obs_low_cloud_colour' from='string' to='Colour' member='low_colour'  default='foreground'>
+		<documentation> Colour of the low cloud </documentation>
+    </parameter>
+    
+     <parameter name = 'obs_medium_cloud' from='string' to='bool' member='medium'  default='on'>
+		<documentation> Turn On/off the medium cloud  </documentation>
+    </parameter>    
+
+    <parameter name = 'obs_medium_cloud_colour' from='string' to='Colour' member='medium_colour'  default='foreground'>
+       <documentation> Colour of  medium cloud </documentation>
+    </parameter>
+
+    <parameter name = 'obs_high_cloud' from='string' to='bool' member='high'  default='on'>
+      <documentation> Turn On/off the high cloud  </documentation>
+    </parameter>
+
+    <parameter name = 'obs_high_cloud_colour' from='string' to='Colour' member='high_colour'  default='red'>
+      <documentation> Colour of the high cloud </documentation>
+    </parameter>    
+</class>
+
+<class name = 'ObsDemoItem2' xmltag='demo2' prefix='obs' action_routine='pobs' directory='visualisers'>
+	<parameter name = 'obs_demo2_missing_text' from='string' to='string' member='text'  default='///'>
+		<documentation> text to be displayed in case of missinmg data </documentation>
+    </parameter>
+    <parameter name = 'obs_demo2_text_colour' from='string' to='string' member='text_colour'  default='cyan'>
+		<documentation> Text colour </documentation>
+    </parameter>
+</class>
+
+</magics>
diff --git a/src/xml/ObsStat.xml b/src/xml/ObsStat.xml
new file mode 100644
index 0000000..221a522
--- /dev/null
+++ b/src/xml/ObsStat.xml
@@ -0,0 +1,32 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='ObsStatDecoder' action='pobsstat' directory='decoders'>
+	<documentation>
+		The Obstat decoder is responsible for decoding Obstat Ascii file.
+	</documentation>
+        <parameter name='obsstat_filename' from='string' to='string'
+            member='path' default='' xml='path'>
+           
+            <documentation> Epsgram Database Path </documentation>
+            <migration> New Magics: Parameter eps_database sent to new Magics[EpsgramDecoder].  </migration>
+        </parameter>
+         
+	
+</class>
+
+<class name='EfiDataDecoder' action='xml' directory='decoders'>
+	<documentation>
+		The Efi decoder is responsible for decoding EFi Ascii file.(Metops)
+	</documentation>
+        <parameter name='efi_filename' from='string' to='string'
+            member='path' default='' xml='path'>           
+            <documentation> Efi file name Path </documentation>
+        </parameter>        
+         <parameter name='efi_record' from='int' to='int'
+            member='record' default='0' xml='record'>
+            <documentation> Efi record ( starting at 0) </documentation>
+        </parameter>
+</class>
+<static name='obstat' class='ObsStatDecoder' base='BaseSceneObject' include_class='yes'/> 
+
+</magics>
diff --git a/src/xml/OdaDecoder.xml b/src/xml/OdaDecoder.xml
new file mode 100644
index 0000000..579f115
--- /dev/null
+++ b/src/xml/OdaDecoder.xml
@@ -0,0 +1,100 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='OdaGeoDecoder' include="OdaDecoder.h" action='podb' directory='oda' xmltag='odb' prefix='odb' >
+	<documentation>
+		New odb Access (Prototype Status) 
+	</documentation>
+    <parameter name='odb_filename' from='string' to='string'
+            member='path' default='' >
+            <documentation> odb Database Path </documentation>
+    </parameter>
+    
+    <parameter name='odb_latitude_variable' from='string' to='string'
+            member='latitude' default='lat'>          
+            <documentation> odb Column name for the latitudes   </documentation>
+    </parameter>
+    <parameter name='odb_longitude_variable' from='string' to='string'
+            member='longitude' default='lon'>        
+            <documentation> odb Column name for the longitudes   </documentation>
+    </parameter>
+    
+    <parameter name='odb_value_variable' from='string' to='string'  
+            member='value' default=''>        
+            <documentation> odb Column name for the values </documentation>
+    </parameter>
+    <parameter name='odb_y_component_variable' from='string' to='string'
+            member='y' default=''>        
+            <documentation> odb Column name for the y component of a vector </documentation>
+    </parameter>
+    <parameter name='odb_x_component_variable' from='string' to='string'
+            member='x' default=''>        
+            <documentation> odb Column name  for the x component of a vector</documentation>
+    </parameter>
+    <parameter name='odb_nb_rows' from='int' to='int'
+	       member='nb_rows' default ='-1' >
+	    <documentation> umber of rows to be retrieved </documentation>
+    </parameter>
+      <parameter name='odb_user_title' from='string' to='string'
+	       member='title' default ='' >
+	    <documentation> User defined title for automatic title </documentation>
+    </parameter>
+      <parameter name='odb_coordinates_unit' from='string' to='string'
+	       member='unit' default ='degrees' >
+	    <documentation> Coordinates unit used to define the location of the points (degrees/radians) </documentation>
+    </parameter>
+    <parameter name='odb_binning' from='string' to='BinningObject' member='odb_binning' default ='off' >
+     	<documentation> Information for the binning (degrees/radians) </documentation>
+     	  <option name='BinningObject'   fortran='on'  xml='binning' include='BinningObject.h'/>
+          <option name='NoBinningObject' fortran='off' xml='nobinning' include='BinningObject.h'/>
+    </parameter>
+</class>    
+<class name='OdaXYDecoder' include='OdaDecoder.h' action='podb' directory='oda' xmltag='odb' prefix='odb' >
+	<documentation>
+		New odb Access (Prototype Status) 
+	</documentation>
+    <parameter name='odb_filename' from='string' to='string'
+            member='path' default='' >
+            <documentation> odb Database Path </documentation>
+    </parameter>
+    
+    <parameter name='odb_x_variable' from='string' to='string'
+            member='x' default='lat'>          
+            <documentation> odb Column name for the x coordinates   </documentation>
+    </parameter>
+    <parameter name='odb_y_variable' from='string' to='string'
+            member='y' default='lon'>        
+            <documentation> odb Column name for the y coordinates   </documentation>
+    </parameter>
+    
+    <parameter name='odb_value_variable' from='string' to='string'  
+            member='value' default=''>        
+            <documentation> odb Column name for the values </documentation>
+    </parameter>
+    <parameter name='odb_y_component_variable' from='string' to='string'
+            member='y_component' default=''>        
+            <documentation> odb Column name for the y component of a vector </documentation>
+    </parameter>
+    <parameter name='odb_x_component_variable' from='string' to='string'
+            member='x_component' default=''>        
+            <documentation> odb Column name  for the x component of a vector</documentation>
+    </parameter>
+    <parameter name='odb_nb_rows' from='int' to='int'
+	       member='nb_rows' default ='-1' >
+	    <documentation> umber of rows to be retrieved </documentation>
+    </parameter>
+      <parameter name='odb_user_title' from='string' to='string'
+	       member='title' default ='' >
+	    <documentation> User defined title for automatic title </documentation>
+    </parameter>
+      <parameter name='odb_binning' from='string' to='BinningObject' member='odb_binning' default ='off' >
+     	<documentation> Information for the binning (degrees/radians) </documentation>
+     	  <option name='BinningObject'   fortran='on'  xml='binning' include='BinningObject.h'/>
+          <option name='NoBinningObject' fortran='off' xml='nobinning' include='BinningObject.h'/>
+    </parameter>
+    
+
+</class>    
+
+</magics>
+
diff --git a/src/xml/Page.xml b/src/xml/Page.xml
new file mode 100644
index 0000000..8922cab
--- /dev/null
+++ b/src/xml/Page.xml
@@ -0,0 +1,103 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='FortranSceneNode' include='SceneNode.h' action='pnew' 
+	xmltag='page' prefix='page' directory='common'>
+  <parameter name='page_x_position' from='float' to='float'
+             member='x' default='0'>
+         <release>Magics++0.1</release>
+         <documentation> X-Coordinate of lower left hand corner of page.Default </documentation>
+  </parameter>
+
+  <parameter name='page_y_position' from='float' to='float'
+             member='y' 	 default='0' >
+         <release>Magics++0.1</release>
+         <documentation> Y-Coordinate of lower left hand corner of page.Default </documentation>
+  </parameter>
+
+  <parameter name='page_x_length' from='float' to='float'
+             member='width'  default='29.7' >
+          <release>Magics++0.1</release>
+         <documentation> Length of page in horizontal direction </documentation>
+  </parameter>
+
+  <parameter name='page_y_length' from='float' to='float'
+             member='height'  default='21' >
+         <release>Magics++0.1</release>
+         <documentation> Length of page in vertical direction </documentation>
+  </parameter>
+
+ 
+  <parameter name='page_frame' from='string' to='bool'
+             member='frame' default='off'>
+         <release>Magics++2.4</release>
+         <documentation> Plot frame around page (ON/OFF) </documentation>
+         <migration> Default as changed from magics6) </migration>
+  </parameter>
+
+  <parameter name='page_frame_colour' from='string' to='Colour'
+             member='frame_colour'  default='blue' >
+         <release>Magics++0.5</release>
+         <documentation> Colour of page frame (Full choice of colours) </documentation>
+  </parameter>
+
+  <parameter name='page_frame_line_style' from='string' to='LineStyle'
+             member='frame_line_style' 	 default='solid'>
+         <release>Magics++0.5</release>
+         <documentation> Style of page frame(SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+  </parameter>
+
+  <parameter name='page_frame_thickness' from='int' to='int'
+             member='frame_thickness'  default='1' >
+         <documentation> Thickness of page frame </documentation>
+         <release>Magics++0.5</release>
+  </parameter>
+
+  <parameter name='page_id_line' from='string' to='NoPageID' include='PageID.h' 
+             member='page_id'  default='on'>
+         <release>Magics++0.6</release>
+         <release>Logo expected in 0.7</release>
+         <option name='PageID' fortran='on' include='PageID.h'/>
+         <option name='NoPageID' fortran='off' include='PageID.h'/>
+         <documentation> Plot identification line and ECMWF logo (ON/OFF) </documentation>
+  </parameter>
+  
+ 
+  
+  <parameter name='page_x_gap' from='float' to='float'
+             member='page_x_gap' 	 default='0.0cm' implemented='no'>
+         <documentation> Gap between pages in X direction </documentation>
+         <release>Magics++0.2</release>
+         <release_info>Not fully implemented</release_info>
+  </parameter>
+
+  <parameter name='page_y_gap' from='float' to='float'
+             member='page_y_gap'  default='0.0cm' implemented='no'>
+         <documentation> Gap between pages in Y direction </documentation>
+         <release>Magics++0.2</release>
+          <release_info>Not fully implemented</release_info>
+  </parameter>
+
+    <parameter name='layout' from='string' to='string'
+             member='plot_layout' 	 default='automatic'>
+         <documentation> Type of page layout (POSITIONAL/AUTOMATIC) </documentation>
+   </parameter>
+
+  <parameter name='plot_start' from='string' to='string'
+             member='plot_start'  default='bottom'>
+         <documentation> Position of first page plotted (BOTTOM/TOP) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+
+  <parameter name='plot_direction' from='string' to='string'
+             member='plot_direction'  default='vertical'>
+         <documentation> Direction of plotting (HORIZONTAL/VERTICAL) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+  
+</class>
+
+
+  
+  
+</magics>
diff --git a/src/xml/PageID.xml b/src/xml/PageID.xml
new file mode 100644
index 0000000..49cabc0
--- /dev/null
+++ b/src/xml/PageID.xml
@@ -0,0 +1,124 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+
+<class name='PageID' directory='common' xmltag='pageid' prefix='page_id/page_id_line' inherits='NoPageID'>
+
+  <parameter name='page_id_line_height' from='float' to='float' member='height' default='0.25'>
+         <documentation> Height of identification line</documentation>
+         <release>2.0</release>
+  </parameter>
+ <parameter name='page_id_line_colour' from='string' to='Colour' member='colour'  default='blue'>
+         <documentation> Colour of identification line. Default based on page_y_length</documentation>
+         <release>2.0</release>
+  </parameter>
+
+  <parameter name='page_id_line_magics' from='string' to='bool' member='magics'  default='on'>
+         <documentation>Display magics version in identification line (ON/OFF)</documentation>
+         <release>2.9</release>
+  </parameter>
+
+  <parameter name='page_id_line_user_text' from='string' to='string' member='user_text' default=''>
+         <documentation> User-supplied text for inclusion in identification line </documentation>
+         <release>2.0</release>
+  </parameter>
+
+  <parameter name='page_id_line_system_plot' from='string' to='bool' member='system'  default='on' >
+         <documentation> Plot system part of the identification line (ON/OFF) </documentation>
+         <release>2.0</release>
+  </parameter>
+
+  <parameter name='page_id_line_date_plot' from='string' to='bool' member='date'  default='on' >
+         <documentation> Plot date part of the identification line (ON/OFF) </documentation>
+         <release>2.0</release>
+  </parameter>
+
+  <parameter name='page_id_line_errors_plot' from='string' to='bool' member='errors'  default='on' >
+         <documentation> Plot error part of the identification line (ON/OFF) </documentation>
+         <release>2.0</release>
+         <release_info> Parameter defined but not implemented: no plan</release_info>
+  </parameter>
+
+  <parameter name='page_id_line_user_text_plot' from='string' to='bool' member='text'  default='on'>
+         <documentation> Plot user text part of the identification line (ON/OFF) </documentation>
+         <release>2.0</release>
+  </parameter>
+
+<parameter name='page_id_line_logo_plot' from='string' to='NoLogoPlotting' include='LogoPlotting.h' member='logo' default='on'>
+         <documentation>Plot logo part of the identification line (ON/OFF)</documentation>
+         <option name='LogoPlotting'     fortran='on'   xml='logo'     include='LogoPlotting.h'> </option>
+         <option name='NoLogoPlotting'   fortran='off'  xml='nologo' include='LogoPlotting.h'> </option>
+</parameter>
+  
+<parameter name='page_id_line_font' from='string' to='string' member='font' default='sansserif'>
+         <documentation> Font to be used </documentation>
+         <release>1.3</release>
+</parameter>
+
+<parameter name='page_id_line_font_style' from='string' to='string' member='font_style' default='normal'>
+         <documentation> Style of the Font to be used </documentation>
+         <release>1.3</release>
+</parameter>
+ 
+</class>
+
+<class name='LogoPlotting' xmltag='logo' inherits='NoLogoPlotting' include='LogoPlotting.h' directory='common'/>
+<class name='NoLogoPlotting' xmltag='nologo' include='LogoPlotting.h'  directory='common'/>
+<class name='LogoPlottingBase'  include='LogoPlotting.h' directory='common'/>
+
+
+<class name='UserLogoPlotting' xmltag='userlogo' prefix='page/page/user_logo' directory='common'  include='LogoPlotting.h' inherits='NoLogoPlotting'>  
+
+<parameter name='user_logo_filename' from='string' to='string' member='path' default=''>
+         <documentation for_docs='no'> Logo's Path </documentation>
+         <release>Basic implementation in 0.6</release>
+</parameter>
+
+<parameter name='user_logo_format' from='string' to='string' member='format' default='PNG'>
+  <documentation for_docs='no'>Specify the format of the logo</documentation>
+  <release>Basic implementation in 0.6</release>
+</parameter>
+
+<parameter name='user_logo_position_units' from='string' to='string' member='units' default='cm'>
+         <documentation for_docs='no'>Units used to define the position of the logo: cm or percent</documentation>
+         <release>Basic implementation in 0.6</release>
+</parameter>
+
+<parameter name='user_logo_y_position' from='float' to='float' member='y' default='2.5'>
+         <documentation for_docs='no'> Y position of the imported image </documentation>
+         <release>Basic implementation in 0.6</release>
+</parameter>
+  
+  <parameter name='user_logo_x_position' from='float' to='float' member='x' default='80'>
+         <documentation for_docs='no'> X position of the imported image </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+ 
+  <parameter name='user_logo_bottom' from='string' to='string' member='bottom'  default=''>
+         <documentation for_docs='no'> Y position of the imported image </documentation>
+         <release>Implementation in 2.4</release>
+  </parameter>
+  
+  <parameter name='user_logo_left' from='string' to='string' member='left' default=''>
+         <documentation for_docs='no'> X position of the imported image </documentation>
+         <release>implementation in 2.4</release>
+  </parameter>
+      
+  <parameter name='user_logo_width' from='float' to='float' member='width' default='-1'>
+         <documentation for_docs='no'> width of the imported image (-1 means use the dimension of the image) </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+  <parameter name='user_logo_height' from='float' to='float' member='height' default='-1'>
+         <documentation for_docs='no'> height of the imported image (-1 means use the dimension of the image) </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+</class>
+
+
+<class name='NoPageID' xmltag='nopageid' directory='common' include='PageID.h' >
+   <documentation>This object suppresses the plotting the page ID</documentation>
+</class>
+
+</magics>
diff --git a/src/xml/PolarStereographicProjection.xml b/src/xml/PolarStereographicProjection.xml
new file mode 100644
index 0000000..f3e9ce5
--- /dev/null
+++ b/src/xml/PolarStereographicProjection.xml
@@ -0,0 +1,116 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<!--
+ ******************************** LICENSE ********************************
+ 
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************
+-->
+<magics>
+<class name='PolarStereographicProjection' 
+		action='projection' 
+		xmltag='polar_stereographic' 
+		prefix='subpage/subpage/subpage_map/subpage_map_area' 
+		directory='common'
+		inherits='Transformation'>
+	<documentation>
+		These are the attributes of the PolarStereographic projection. 
+	</documentation>
+	<parameter name='subpage_map_area_coordinate_system' from='string' to='string'
+             member='system' default='users' visible='off'>
+         <release>Magics++2.8</release>
+         
+         
+         <documentation> If set to projection, the coordinates of the bounding box are described in projection coordinates
+          instead of the more natural lat/lon system  ( this is useful in the WMS context) </documentation>
+  </parameter>
+    <parameter name='subpage_map_area_definition_polar' from='string' to='string' 
+             member='area' default='corners' values='full/corners/centre'>
+             <set value="corners" name='subpage_lower_left_latitude'/>
+             <set value="corners" name='subpage_lower_left_longitude'/>
+             <set value="corners" name='subpage_upper_right_latitude'/>
+             <set value="corners" name='subpage_upper_right_longitude'/>
+             <set value="corners" name='subpage_upper_right_longitude'/>
+             <set value="centre" name='subpage_map_vertical_longitude'/>
+             <set value="centre" name='subpage_map_centre_latitude'/>
+             <set value="centre" name='subpage_map_centre_longitude'/>
+             <set value="centre" name='subpage_map_scale'/>
+         <release>Magics++0.1</release>
+         
+         <release_info>Basic implementation: only used for steroGraphicPolar Projection</release_info>
+         <documentation> Method of defining a polar stereographic map</documentation>
+  </parameter>
+  <parameter name='subpage_map_hemisphere' from='string' to='Hemisphere'
+             member='hemisphere' default='north'  >
+         <release>Magics++0.1</release>    
+         <documentation> Hemisphere required for polar stereographic map(NORTH/SOUTH) </documentation>
+  </parameter>
+
+ 
+  
+   <parameter name='subpage_lower_left_latitude' from='float' to='float'
+             member='min_latitude' default='-90.0' >
+         <release>Magics++0.1</release>
+         <documentation> Latitude of lower left corner of map, if map is CYLINDRICAL, MERCATOR or defined by 'CORNERS' in POLAR STEREOGRAPHIC </documentation>
+  </parameter>
+
+  <parameter name='subpage_lower_left_longitude' from='float' to='float'
+             member='min_longitude' default='-180.0' >
+         <release>Magics++0.1</release>
+         <documentation> Longitude of lower left corner of map, if map is CYLINDRICAL, MERCATOR or defined by 'CORNERS' in POLAR STEREOGRAPHIC </documentation>
+  </parameter>
+
+  <parameter name='subpage_upper_right_latitude' from='float' to='float'
+             member='max_latitude' default='90.0' >
+         <release>Magics++0.1</release>
+         <documentation> Latitude of upper right corner of map, if map is CYLINDRICAL, MERCATOR or defined by 'CORNERS' in POLAR STEREOGRAPHIC </documentation>
+  </parameter>
+
+  <parameter name='subpage_upper_right_longitude' from='float' to='float'
+             member='max_longitude' default='180.0' >
+         <release>Magics++0.1</release>
+         <documentation> Longitude of upper right corner of map, if map is CYLINDRICAL, MERCATOR or defined by 'CORNERS' in POLAR STEREOGRAPHIC </documentation>
+  </parameter>
+   <parameter name='subpage_map_vertical_longitude' from='float' to='float'
+             member='vertical_longitude'  default='0.0' >
+         <documentation> Vertical longitude of polar stereographic or Aitoff map </documentation>
+         <release>Magics++0.1</release>   
+         <release_info>Only available for polar sterepgraphic projection</release_info>
+  </parameter>
+   <parameter name='subpage_map_centre_latitude' from='float' to='float'
+             member='centre_latitude'  default='90.0'>
+         <release>Magics++0.3</release>   
+         <documentation> Latitude of centre of polar stereographic map defined by 'CENTRE' or centre latitude of Lambert/satellite subarea projections </documentation>
+  </parameter>
+
+  <parameter name='subpage_map_centre_longitude' from='float' to='float'
+             member='centre_longitude' default='0.0'>
+         <release>Magics++0.3</release>   
+         <documentation> Longitude of centre of polar stereographic map defined by 'CENTRE' or centre longitude of Lambert/satellite subarea projections </documentation>
+  </parameter>
+
+  <parameter name='subpage_map_scale' from='float' to='float'
+             member='map_scale'		 default='50.e6' >
+         <release>Magics++0.3</release>   
+         <release_info> only for polar stereographic projection</release_info>
+         <documentation> Scale of polar stereographic or Aitoff  map </documentation>
+  </parameter>
+
+
+</class>
+</magics>
+
diff --git a/src/xml/PostScriptDriver.xml b/src/xml/PostScriptDriver.xml
new file mode 100644
index 0000000..8ae4eab
--- /dev/null
+++ b/src/xml/PostScriptDriver.xml
@@ -0,0 +1,29 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='PostScriptDriver' action='PostScript' directory='drivers' inherits='BaseDriver' xmltag='ps' prefix='output_ps/output'>
+	<documentation for_docs='no'>
+		This is the default driver for Magics, and PostScript is the default output format. 
+	</documentation>
+
+<parameter name='output_ps_colour_model' from='string' to='string' member='colour_model' default='cmyk' values='rgb/cmyk/monochrome/gray/cmyk_monochrome/cmyk_gray'>
+   <metview default='' class='' >  </metview>
+   <documentation>Defines the PostScript colour model .</documentation>
+<!--         <option name='RGB'  fortran='rgb'  xml='rgb'/>
+             <option name='CMYK'  fortran='CMYK'  xml='CMYK'/>
+             <option name='MONOCHROME'  fortran='MONOCHROME'  xml='MONOCHROME'/>
+             <option name='GRAY'  fortran='GRAY'  xml='GRAY'/>
+             <option name='CMYK_MONOCHROME' fortran='CMYK_MONOCHROME'  xml='CMYK_MONOCHROME'/>
+             <option name='CMYK_GRAY' fortran='CMYK_GRAY'  xml='CMYK_GRAY'/>
+-->
+</parameter>
+
+<parameter name='output_ps_scale' from='float' to='float' member='scale' default='1.0'>
+   <documentation>Defines the PostScript scale between 0.1 and 1.0 (1.0 being the full page size).</documentation>
+</parameter>
+
+<parameter name='output_ps_split' from='string' to='bool' member='split' default='off'>
+   <documentation>Enables the output to be split into different (single page) PostScript files.</documentation>
+</parameter>
+</class>
+
+</magics>
diff --git a/src/xml/Proj4Projection.xml b/src/xml/Proj4Projection.xml
new file mode 100644
index 0000000..cc994e7
--- /dev/null
+++ b/src/xml/Proj4Projection.xml
@@ -0,0 +1,73 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<!--
+ ******************************** LICENSE ********************************
+ 
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************
+-->
+<magics>
+<class name='Proj4Projection' inherits='Transformation' action='projection' prefix='subpage' directory='common'>
+	<documentation>
+		These are the attributes of the Proj4 projection. 
+	</documentation>
+	
+     <parameter name='subpage_map_area_definition' from='string' to='string' member='setting' default='full' values='corners/full'>
+            <documentation>method used to define the geographical area.</documentation>
+            <set value='corners' name='subpage_lower_left_latitude'/>
+            <set value='corners' name='subpage_lower_left_longitude'/>
+            <set value='corners' name='subpage_upper_right_latitude'/>
+            <set value='corners' name='subpage_upper_right_longitude'/>
+        </parameter>   
+ <parameter name='subpage_lower_left_latitude' from='float' to='float'
+             member='min_latitude' default='-90.0'>
+         <release>Magics++0.1</release>
+         <documentation> Latitude of lower left corner of map. </documentation>
+  </parameter>
+
+  <parameter name='subpage_lower_left_longitude' from='float' to='float'
+             member='min_longitude' default='-180.0' >
+         <release>Magics++0.1</release>
+         <documentation> Longitude of lower left corner of map. </documentation>
+  </parameter>
+
+  <parameter name='subpage_upper_right_latitude' from='float' to='float'
+             member='max_latitude' default='90.0' >
+         <release>Magics++0.1</release>
+         <documentation> Latitude of upper right corner of map. </documentation>
+  </parameter>
+
+  <parameter name='subpage_upper_right_longitude' from='float' to='float'
+             member='max_longitude' default='180.0' >
+         <release>Magics++0.1</release>
+         <documentation> Longitude of upper right corner of map. </documentation>
+  </parameter>
+  </class>
+
+  <class name='Proj4PolarNorth' inherits='Proj4Projection'  include='Proj4Projection.h' prefix='subpage' directory='common'/>
+  <class name='Proj4Geos' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4EPSG3857' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4Goode' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4Lambert' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4Bonne' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4Collignon' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4Mollweide' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4EPSG4326' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  <class name='Proj4EPSG32661' inherits='Proj4Projection' prefix='subpage' include='Proj4Projection.h' directory='common'/>
+  
+</magics>
+
diff --git a/src/xml/QtDriver.xml b/src/xml/QtDriver.xml
new file mode 100644
index 0000000..c88fd64
--- /dev/null
+++ b/src/xml/QtDriver.xml
@@ -0,0 +1,39 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<!--
+ ******************************** LICENSE ********************************
+ 
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+ 
+ Licensed under the Apache License, Version 2.0 (the "License"); 
+ you may not use this file except in compliance with the License. 
+ You may obtain a copy of the License at 
+ 
+ 	http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software 
+ distributed under the License is distributed on an "AS IS" BASIS, 
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ See the License for the specific language governing permissions and 
+ limitations under the License.
+
+
+ ******************************** LICENSE ********************************
+-->
+<magics>
+<class name='QtDriver' action='Qt' prefix='output/output_qt' xmltag='qt' directory='drivers' include='Qt/qgraphicsscene.h' inherits='BaseDriver'>
+
+<documentation>
+These are the attributes of the Qt output driver. This driver is intended for Qt applications such as Metview.
+</documentation>
+
+<parameter name='output_qt_widget' from='QWidget*' to='QWidget*' member='widget' default='0'>
+	<documentation>Enable an application to instantiate its own QGraphicsScene and to pass it to Magics++ for it to use it.</documentation>
+</parameter>
+
+<parameter name='output_qt_scene' from='QGraphicsScene*' to='QGraphicsScene*' member='scene' default='0'>
+	<documentation>Enable an application to instantiate its own QGraphicsScene and to pass it to Magics++ for it to use it.</documentation>
+</parameter>
+
+</class>
+</magics>
diff --git a/src/xml/SVGDriver.xml b/src/xml/SVGDriver.xml
new file mode 100644
index 0000000..e07ef02
--- /dev/null
+++ b/src/xml/SVGDriver.xml
@@ -0,0 +1,38 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='SVGDriver' action='SVG' directory='drivers' inherits='BaseDriver' xmltag='svg' prefix='output_svg/output'>
+	<documentation for_docs='no'>
+		The output driver produces vector graphics in the SVG format. See also the parameters for the Base Driver.
+	</documentation>
+	<parameter name='output_svg_logo_location' from='string' to='string' member='logoLocation' default='inline' values='inline/share/www/local'>
+		<documentation>Sets where the (ECMWF) logo can be found. Possible values are 'inline'(default),'share', 'www' or 'local'.</documentation>
+	</parameter>
+	<parameter name='output_svg_desc' from='string' to='string' member='desc' default='' >
+		<documentation>Defines a text describing the content of the SVG output.</documentation>
+	</parameter>
+
+	<parameter name='output_svg_meta' from='string' to='string' member='meta' default='' >
+		<documentation>Defining meta data in RDF to be added to the SVG output.</documentation>
+	</parameter>
+
+	<parameter name='output_svg_use_external_files' from='string' to='bool' member='external' default='off'>
+		<documentation>Can the SVG driver use external files for cell and image plotting. External files will reduce the SVG file size but add an external dependency!</documentation>
+	</parameter>
+
+	<parameter name='output_svg_scripting' from='string' to='bool' member='scripting' default='off'>
+		<documentation>Integrates scripting for interaction (toggle layers and pan/zooming).</documentation>
+	</parameter>
+
+	<parameter name='output_svg_fix_size' from='string' to='bool' member='fixSize' default='off' >
+		<documentation>Decides if the size is fixed in the SVG document.</documentation>
+	</parameter>
+
+
+<!--
+	<parameter name='output_svg_compress' from='string' to='bool' member='compress' default='off' >
+		<documentation for_docs='no'>Forces Magics to write compressed svgz files.</documentation>
+	</parameter>	
+-->
+</class>
+
+</magics>
diff --git a/src/xml/SatelliteProjection.xml b/src/xml/SatelliteProjection.xml
new file mode 100644
index 0000000..e4ba49e
--- /dev/null
+++ b/src/xml/SatelliteProjection.xml
@@ -0,0 +1,19 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+  
+ 
+  <class name='SatelliteProjection' action='pnew'  directory='common' inherits='Transformation' >
+  <parameter name='subpage_map_corner_latitude' from='float' to='float' 
+ 	member='latitude' xml='latitude' default='-90' >
+	  <release>Magics++1.2</release>  
+	  <documentation>Latitude of one corner of subarea of satellite map</documentation>
+  </parameter>
+  <parameter name='subpage_map_corner_longitude' from='float' to='float' 
+ 	member='longitude' xml='longitude' default='-75' >
+	  <release>Magics++1.2</release>  
+	  <documentation>Longitude of one corner of subarea of satellite map</documentation>
+  </parameter>
+  </class>
+ 
+  
+</magics>
diff --git a/src/xml/SelectionMode.xml b/src/xml/SelectionMode.xml
new file mode 100644
index 0000000..58a775b
--- /dev/null
+++ b/src/xml/SelectionMode.xml
@@ -0,0 +1,39 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+  
+
+<class name='SelectionMode' action='Interactive' directory='drivers' xmltag='interactive_mode' prefix='selection_mode'> 
+  <parameter name='selection_mode_background_colour' from='string' to='Colour'
+             member='background_colour'  default='blue'>
+         <release>Magics++3.2</release>
+         <documentation> Background colour of selectables objets.</documentation>
+  </parameter>
+   <parameter name='selection_mode_background_opacity' from='int' to='int'
+             member='background_opacity'  default='75'>
+         <release>Magics++3.2</release>
+         <documentation> Background opacity of selectables objets.</documentation>
+  </parameter>
+   <parameter name='selection_mode_line_colour' from='string' to='Colour'
+             member='line_colour'  default='blue'>
+         <release>Magics++3.2</release>
+         <documentation> line colour of selectables objets.</documentation>
+  </parameter>
+    <parameter name='selection_mode_line_thickness' from='int' to='int'
+             member='line_thickness'  default='2'>
+         <release>Magics++3.2</release>
+         <documentation> line thickness of selectables objets.</documentation>
+  </parameter>
+    <parameter name='selection_mode_line_style' from='string' to='LineStyle'
+             member='line_style'  default='solid'>
+         <release>Magics++3.2</release>
+         <documentation> line style of selectables objets.</documentation>
+  </parameter>
+	  <parameter name='selection_mode_object_instancies' from='int' to='int'
+             member='object_instancies'  default='1'>
+         <release>Magics++3.2</release>
+         <documentation> max number of  selectables objets.</documentation>
+  </parameter>
+</class>
+
+  
+</magics>
diff --git a/src/xml/SubPage.xml b/src/xml/SubPage.xml
new file mode 100644
index 0000000..d9bbf8f
--- /dev/null
+++ b/src/xml/SubPage.xml
@@ -0,0 +1,214 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='FortranViewNode' action='pnew' include='ViewNode.h'
+	xmltag='subpage' prefix='subpage/subpage/subpage' directory='common'> 
+    
+
+
+
+<parameter name='subpage_x_position' from='float' to='float'  member='left'  default='-1' >
+         <documentation> Y-Coordinate of lower left hand corner of subpage in cm. 
+          -1 is the  default: 7.5% of the parent page </documentation>
+</parameter>
+<parameter name='subpage_y_position' from='float' to='float' member='bottom' default='-1' >
+         <documentation> X-Coordinate of lower left hand corner of subpage in cm. 
+          -1 is the  default: 5% of the parent page</documentation>
+</parameter>
+
+<parameter name='subpage_x_length' from='float' to='float' member='width'  default='-1'>
+         <documentation> Length of subpage in horizontal direction in cm.  
+          -1 is the  default: 85% of the parent page </documentation>
+</parameter>
+<parameter name='subpage_y_length' from='float' to='float' member='height'  default='-1'>
+         <documentation> Length of subpage in vertical direction in cm.
+         -1 is the  default:  85% of the parent page </documentation>
+</parameter>
+
+<parameter name='subpage_map_projection' from='string' to='Transformation' member='transformation'  default='cylindrical'>
+         <documentation>Projection to set in the drawing area </documentation>
+
+            <option name='GeoRectangularProjection' fortran='cylindrical' xml='cylindrical' include='GeoRectangularProjection.h'/>
+
+               <option name='PolarStereographicProjection' fortran='polar_stereographic' xml='polar_stereographic' include='PolarStereographicProjection.h'/>
+        <option name='Proj4PolarNorth' fortran='polar_north' include='Proj4Projection.h'/>
+ 		<option name='Proj4Geos' fortran='geos' include='Proj4Projection.h'/>
+ 		<option name='Proj4Lambert' fortran='lambert' include='Proj4Projection.h'/>
+ 		<option name='Proj4EPSG3857' fortran='EPSG3857' include='Proj4Projection.h'/>
+ 		<option name='Proj4Goode' fortran='goode' include='Proj4Projection.h'/>
+ 		<option name='Proj4Collignon' fortran='collignon' include='Proj4Projection.h'/>
+ 		<option name='Proj4Mollweide' fortran='mollweide' include='Proj4Projection.h'/>
+ 		<option name='Proj4Bonne' fortran='bonne' include='Proj4Projection.h'/>
+ 		<option name='Proj4EPSG4326' fortran='EPSG4326' include='Proj4Projection.h'/>
+ 		<option name='Proj4EPSG32661' fortran='EPSG32661' include='Proj4Projection.h'/>
+
+        <option name='MercatorProjection' fortran='mercator' xml='mercator' include='GeoRectangularProjection.h'/>
+		<option name='CartesianTransformation' fortran='cartesian' xml='cartesian' include='CartesianTransformation.h'/>
+        <option name='TaylorProjection' fortran='taylor' xml='taylor' include='TaylorProjection.h'/>
+        <!--option name='Tephigram' fortran='tephigram' xml='tephigram' include='Tephigram.h'/-->
+         <!-- Code to update to add a new projection...
+         	<option name='NewProjection' fortran='fortran-new-projection' xml='xm-tag-for-new-projection' include='NewProjection.h'/>
+         -->     
+</parameter>
+<parameter name='subpage_y_position_internal' from='float' to='float' member='bottom_internal' 
+		default='-1' visible='off'>
+         <documentation> X-Coordinate of lower left hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_x_position_internal' from='float' to='float'  member='left_internal' 
+		 default='-1' visible='off'>
+         <documentation> Y-Coordinate of lower left hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_right_position' from='float' to='float' member='right'  default='-1'  visible='off' >
+         <documentation> X-Coordinate of lower right  hand corner of subpage </documentation>
+</parameter>
+
+
+
+<parameter name='subpage_y_length_internal' from='float' to='float' member='height_internal'  default='-1'  visible='off'>
+         <documentation> Length of subpage in vertical direction.Default </documentation>
+</parameter>
+<parameter name='subpage_x_length_internal' from='float' to='float' member='width_internal'  default='-1' visible='off' >
+         <documentation> Length of subpage in horizontal direction.Default </documentation>
+</parameter>
+
+<parameter name='subpage_top_position' from='float' to='float' member='top' default='-1' visible='off'>
+         <release>Magics++2.4</release>
+         <documentation> Y-Coordinate of upper left hand corner of subpage </documentation>
+</parameter>
+
+
+<parameter name='subpage_background_colour' from='string' to='Colour' member='background'  default='white'>
+         <documentation> Colour of the subpage background </documentation>
+</parameter>
+
+<parameter name='subpage_frame' from='string' to='bool' member='frame' default='on' >
+         <documentation> Plot frame around subpage (ON/OFF) </documentation>
+         <set value='on' name='subpage_frame_colour'/>
+         <set value='on' name='subpage_frame_line_style'/>
+         <set value='on' name='subpage_frame_thickness'/>
+</parameter>
+
+<parameter name='subpage_frame_colour' from='string' to='Colour' member='frame_colour'  default='black'>
+         <documentation> Colour of subpage frame (Full choice of colours) </documentation>
+</parameter>
+
+<parameter name='subpage_frame_line_style' from='string' to='LineStyle' member='frame_line_style'  default='solid'>
+         <documentation> Style of subpage frame (SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+</parameter>
+
+<parameter name='subpage_frame_thickness' from='int' to='int' member='frame_thickness'  default='2'>
+         <documentation> Thickness of subpage frame </documentation>
+</parameter>
+
+<parameter name='subpage_vertical_axis_width' from='float' to='float' member='vertical_axis_with' default='1'>
+         <documentation> width of the vertical  axis in cm </documentation>
+</parameter>
+<parameter name='subpage_horizontal_axis_height' from='float' to='float' member='horizontal_axis_height' default='0.5'>
+         <documentation> height of the horizontal  axis in cm</documentation>
+</parameter>
+ <parameter name='subpage_map_overlay_control' from='string' to='string' member='overlay'  default='basic' visible='metview'>
+         <documentation for_docs='no'> Metview Only: overlay method. always: plot the fields as they come; never: never overlay; by_date/by_level: only overlay data with the same valid date/level  </documentation>
+  </parameter>
+<parameter name='subpage_align_horizontal' from='string' to='string'  member='horizontal' default='left' values='left/right'>
+         <release>Magics++2.4</release>     
+         <documentation>  Used in automatic layout to setup the horizontal alignment of the drawing area in the subpage  </documentation>
+</parameter>
+<parameter name='subpage_align_vertical' from='string' to='string' member='vertical' default='bottom'  values='bottom/top'>
+         <release>Magics++2.4</release>     
+         <documentation>  Used in automatic layout to setup the vertical alignment of the drawing area in the subpage </documentation>
+</parameter>
+
+
+
+<parameter name='subpage_map_json_definition' from='string' to='string' member='json'  default='' visible='off'>
+	<documentation> Metview only : store internal information about zooned area </documentation>
+</parameter>
+
+  
+ 
+
+<parameter name='automatic_title' from='string' to='bool' member='title'  default='off' visible='off'>
+         <documentation> Plot the title (ON/OFF) </documentation>
+</parameter>
+
+<parameter name='subpage_map_preview' from='string' to='NoPreviewVisitor' include="PreviewVisitor.h" member='preview'  
+	default='off' visible='metview'>
+         <documentation  for_docs='no'> Mv4: turn on/off the generation of the infomation for the preview box </documentation>
+         <release>Magics++2.8</release>
+         <option name='NoPreviewVisitor' fortran='off' xml='off' include='PreviewVisitor.h'/>
+         <option name='PreviewVisitor' fortran='on' xml='on' include='PreviewVisitor.h'/>
+</parameter> 
+
+<parameter name='subpage_map_magnifier' from='string' to='NoMagnifierVisitor' 
+		include="MagnifierVisitor.h" member='magnify'  default='off' visible='metview'>
+         <documentation for_docs='no'> Mv4: turn on/off the generation of the infomation for the magnifier tool </documentation>
+         <release>Magics++2.8</release>
+         <option name='NoMagnifierVisitor' fortran='off' xml='off' include='MagnifierVisitor.h'/>
+         <option name='MagnifierVisitor' fortran='on' xml='on' include='MagnifierVisitor.h'/>
+</parameter>
+</class>
+
+<class name='Transformation' directory='common'/>
+
+<class name='NoPreviewVisitor' directory='basic' include='PreviewVisitor.h'/>
+
+<class name='PreviewVisitor' directory='basic' inherits='NoPreviewVisitor'/>
+
+<class name='NoMagnifierVisitor' directory='basic' include='MagnifierVisitor.h'/>
+
+<class name='MagnifierVisitor' directory='basic' inherits='NoMagnifierVisitor'>
+<parameter name='magnifier_symbol_name' from='string' to='string' member='symbol_name'  default='magics_3'>
+         <documentation for_docs='no'> Mv4: Symbol used in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter> 
+
+<parameter name='magnifier_hidden_symbol_name' from='string' to='string' member='hidden_symbol_name'  default='magics_3'>
+         <documentation for_docs='no'> Mv4: Symbol used in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+    
+<parameter name='magnifier_symbol_colour' from='string' to='Colour' member='symbol_colour'  default='red'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter> 
+
+<parameter name='magnifier_hidden_symbol_colour' from='string' to='Colour' member='hidden_symbol_colour' default='navy'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_symbol_height' from='float' to='float' member='symbol_height' default='0.2'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_hidden_symbol_height' from='float' to='float' member='hidden_symbol_height'  default='0.1'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_text_font_name' from='string' to='string' member='text_font_name'  default='sanserif'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_text_font_size' from='float' to='float' member='text_font_size'  default='0.2'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_text_font_colour' from='string' to='Colour' member='text_font_colour' default='navy'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>  
+
+<parameter name='magnifier_text_format' from='string' to='string' member='text_format' default='(automatic)'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+</class>
+ 
+</magics>
diff --git a/src/xml/SubPageProj4.xml b/src/xml/SubPageProj4.xml
new file mode 100644
index 0000000..2b03b2e
--- /dev/null
+++ b/src/xml/SubPageProj4.xml
@@ -0,0 +1,212 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='FortranViewNode' action='pnew' include='ViewNode.h'
+	xmltag='subpage' prefix='subpage/subpage/subpage' directory='common'> 
+  
+<parameter name='subpage_align_vertical' from='string' to='string' member='vertical' default='bottom' >
+         <release>Magics++2.4</release>     
+         <documentation>  vertical alignment of the drawing area in the subpage: bottom/top </documentation>
+</parameter>
+
+<parameter name='subpage_align_horizontal' from='string' to='string'  member='horizontal' default='left' >
+         <release>Magics++2.4</release>     
+         <documentation>   horizontal alignment of the drawing area in the subpage: left/right  </documentation>
+</parameter>
+  
+<parameter name='subpage_top_position' from='float' to='float' member='top' default='-1' >
+         <release>Magics++2.4</release>
+         <documentation> Y-Coordinate of upper left hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_y_position' from='float' to='float' member='bottom' default='-1' >
+         <documentation> X-Coordinate of lower left hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_x_position' from='float' to='float'  member='left'  default='-1' >
+         <documentation> Y-Coordinate of lower left hand corner of subpage </documentation>
+</parameter>
+<parameter name='subpage_y_position_internal' from='float' to='float' member='bottom_internal' default='-1' >
+         <documentation> X-Coordinate of lower left hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_x_position_internal' from='float' to='float'  member='left_internal'  default='-1' >
+         <documentation> Y-Coordinate of lower left hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_right_position' from='float' to='float' member='right'  default='-1' >
+         <documentation> X-Coordinate of lower right  hand corner of subpage </documentation>
+</parameter>
+
+<parameter name='subpage_x_length' from='float' to='float' member='width'  default='-1'>
+         <documentation> Length of subpage in horizontal direction.Default </documentation>
+</parameter>
+<parameter name='subpage_y_length' from='float' to='float' member='height'  default='-1'>
+         <documentation> Length of subpage in vertical direction.Default </documentation>
+</parameter>
+
+<parameter name='subpage_y_length_internal' from='float' to='float' member='height_internal'  default='-1'>
+         <documentation> Length of subpage in vertical direction.Default </documentation>
+</parameter>
+<parameter name='subpage_x_length_internal' from='float' to='float' member='width_internal'  default='-1'>
+         <documentation> Length of subpage in horizontal direction.Default </documentation>
+</parameter>
+
+
+
+<parameter name='subpage_background_colour' from='string' to='Colour' member='background'  default='white'>
+         <documentation> Colour of the subpage background </documentation>
+</parameter>
+
+<parameter name='subpage_frame' from='string' to='bool' member='frame' default='on' >
+         <documentation> Plot frame around subpage (ON/OFF) </documentation>
+</parameter>
+
+<parameter name='subpage_frame_colour' from='string' to='Colour' member='frame_colour'  default='black'>
+         <documentation> Colour of subpage frame (Full choice of colours) </documentation>
+</parameter>
+
+<parameter name='subpage_frame_line_style' from='string' to='LineStyle' member='frame_line_style'  default='solid'>
+         <documentation> Style of subpage frame (SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+</parameter>
+
+<parameter name='subpage_frame_thickness' from='int' to='int' member='frame_thickness'  default='2'>
+         <documentation> Thickness of subpage frame </documentation>
+</parameter>
+
+<parameter name='subpage_vertical_axis_width' from='float' to='float' member='vertical_axis_with' default='1'>
+         <documentation> width of the vertical  axis in cm </documentation>
+</parameter>
+<parameter name='subpage_horizontal_axis_height' from='float' to='float' member='horizontal_axis_height' default='0.5'>
+         <documentation> height of the horizontal  axis in cm</documentation>
+</parameter>
+ <parameter name='subpage_map_overlay_control' from='string' to='string' member='overlay'  default='basic'>
+         <documentation for_docs='no'> overlay method. always: plot the fields as they come; never: never overlay; by_date/by_level: only overlay data with the same valid date/level  </documentation>
+  </parameter>
+<parameter name='subpage_map_projection' from='string' to='Transformation' member='transformation'  default='cylindrical'>
+         <documentation>Projection required(CYLINDRICAL, POLAR_STEREOGRAPHIC, MERCATOR, CARTESIAN) </documentation>
+
+         <!--option name='CylindricalProjection' fortran='cylindrical' xml='cylindrical' include='CylindricalProjection.h'/-->
+         <!-- New cylindrical prokjection...-->
+        <option name='GeoRectangularProjection' fortran='cylindrical' xml='cylindrical' include='GeoRectangularProjection.h'/>
+
+         <!--option name='Proj4Projection' fortran='proj4' xml='proj4' include='Proj4Projection.h'/-->
+         <!--option name='PolarStereoProjection' fortran='polar_stereographic' xml='polar_stereographic' include='PolarStereoProjection.h'/-->
+         <!-- New polar stereographic projection...-->
+        <option name='PolarStereographicProjection' fortran='polar_stereographic' xml='polar_stereographic' include='PolarStereographicProjection.h'/>
+        <option name='Proj4PolarNorth' fortran='polar_north' include='Proj4Projection.h'/>
+ 		<option name='Proj4Geos' fortran='geos' include='Proj4Projection.h'/>
+ 		<option name='Proj4Lambert' fortran='lambert' include='Proj4Projection.h'/>
+ 		<option name='Proj4Goode' fortran='goode' include='Proj4Projection.h'/>
+ 		<option name='Proj4Collignon' fortran='collignon' include='Proj4Projection.h'/>
+ 		<option name='Proj4Mollweide' fortran='mollweide' include='Proj4Projection.h'/>
+ 		<option name='Proj4Bonne' fortran='bonne' include='Proj4Projection.h'/>
+ 		<option name='Proj4EPSG4326' fortran='EPSG4326' include='Proj4Projection.h'/>
+ 		<option name='Proj4EPSG32661' fortran='EPSG32661' include='Proj4Projection.h'/>
+
+        <option name='MercatorProjection' fortran='mercator' xml='mercator' include='GeoRectangularProjection.h'/>
+	<option name='CartesianTransformation' fortran='none' xml='cartesian' include='CartesianTransformation.h'/>
+         <!--later 
+            <option name='TaylorProjection' fortran='taylor' xml='taylor' include='TaylorProjection.h'/>
+         	<option name='SatelliteProjection' fortran='satellite' xml='satellite' include='SatelliteProjection.h'/>
+         	<option name='TaylorProjection' fortran='taylor' xml='taylor' include='TaylorProjection.h'/-->
+         <!-- Code to update to add a new projection...
+         	<option name='NewProjection' fortran='fortran-new-projection' xml='xm-tag-for-new-projection' include='NewProjection.h'/>
+         -->     
+</parameter>
+<parameter name='subpage_map_json_definition' from='string' to='string' member='json'  default=''>
+	<documentation> Metview only : store internal information about zooned area </documentation>
+</parameter>
+
+  
+  <!--parameter name='legend' from='string' to='LegendBase'
+             member='legend' xml='legend'
+			 default='off' >
+         <documentation> Plot the legend (ON/OFF) </documentation>
+         <release>Magics++0.3</release>
+         <option name='Legend' fortran='on' xml='legend' include='Legend.h'/>
+         <option name='NoLegend' fortran='off' xml='nolegend' include='Legend.h'/>
+         <migration> New Magics: Parameter legend sent to new Magics[SubPage].  </migration>
+  </parameter-->
+
+<parameter name='automatic_title' from='string' to='bool' member='title'  default='off' >
+         <documentation> Plot the title (ON/OFF) </documentation>
+</parameter>
+
+<parameter name='subpage_map_preview' from='string' to='NoPreviewVisitor' include="PreviewVisitor.h" member='preview'  default='off'>
+         <documentation  for_docs='no'> Mv4: turn on/off the generation of the infomation for the preview box </documentation>
+         <release>Magics++2.8</release>
+         <option name='NoPreviewVisitor' fortran='off' xml='off' include='PreviewVisitor.h'/>
+         <option name='PreviewVisitor' fortran='on' xml='on' include='PreviewVisitor.h'/>
+</parameter> 
+
+<parameter name='subpage_map_magnifier' from='string' to='NoMagnifierVisitor' include="MagnifierVisitor.h" member='magnify'  default='off'>
+         <documentation for_docs='no'> Mv4: turn on/off the generation of the infomation for the magnifier tool </documentation>
+         <release>Magics++2.8</release>
+         <option name='NoMagnifierVisitor' fortran='off' xml='off' include='MagnifierVisitor.h'/>
+         <option name='MagnifierVisitor' fortran='on' xml='on' include='MagnifierVisitor.h'/>
+</parameter>
+</class>
+
+<class name='Transformation' directory='common'/>
+
+<class name='NoPreviewVisitor' directory='basic' include='PreviewVisitor.h'/>
+
+<class name='PreviewVisitor' directory='basic' inherits='NoPreviewVisitor'/>
+
+<class name='NoMagnifierVisitor' directory='basic' include='MagnifierVisitor.h'/>
+
+<class name='MagnifierVisitor' directory='basic' inherits='NoMagnifierVisitor'>
+<parameter name='magnifier_symbol_name' from='string' to='string' member='symbol_name'  default='magics_3'>
+         <documentation for_docs='no'> Mv4: Symbol used in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter> 
+
+<parameter name='magnifier_hidden_symbol_name' from='string' to='string' member='hidden_symbol_name'  default='magics_3'>
+         <documentation for_docs='no'> Mv4: Symbol used in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+    
+<parameter name='magnifier_symbol_colour' from='string' to='Colour' member='symbol_colour'  default='red'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter> 
+
+<parameter name='magnifier_hidden_symbol_colour' from='string' to='Colour' member='hidden_symbol_colour' default='navy'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_symbol_height' from='float' to='float' member='symbol_height' default='0.2'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_hidden_symbol_height' from='float' to='float' member='hidden_symbol_height'  default='0.1'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_text_font_name' from='string' to='string' member='text_font_name'  default='sanserif'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_text_font_size' from='float' to='float' member='text_font_size'  default='0.2'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+<parameter name='magnifier_text_font_colour' from='string' to='Colour' member='text_font_colour' default='navy'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>  
+
+<parameter name='magnifier_text_format' from='string' to='string' member='text_format' default='(automatic)'>
+         <documentation for_docs='no'> Mv4: Colour of the symbol in the magnifier </documentation>
+         <release>Magics++2.8</release>
+</parameter>
+
+</class>
+ 
+</magics>
diff --git a/src/xml/SuperPage.xml b/src/xml/SuperPage.xml
new file mode 100644
index 0000000..7ffdb4c
--- /dev/null
+++ b/src/xml/SuperPage.xml
@@ -0,0 +1,183 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+
+<class name='FortranRootSceneNode' action = 'pnew' xmltag='super_page' prefix='super_page' include='RootSceneNode.h' directory='common'>
+  
+  <parameter name='super_page_x_length' from='float' to='float' member='width'  default='29.7'>
+         <documentation> Horizontal length of super page </documentation>
+  </parameter>
+
+  <parameter name='super_page_y_length' from='float' to='float' member='height'  default='21.0'>
+           <release>Magics++0.1</release>
+         <documentation> Vertical length of super page </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame' from='string' to='bool' member='frame'  default='off'>
+         <release>Magics++0.5</release>
+         <documentation> Plot frame around super page (ON/OFF) </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame_colour' from='string' to='Colour' member='colour'  default='blue' >
+           <release>Magics++0.5</release>
+         <documentation> Colour of super page frame </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame_line_style' from='string' to='LineStyle' member='style'  default='solid' >
+         <release>Magics++0.5</release>
+         <documentation> Style of super page frame (SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame_thickness' from='int' to='int' member='thickness'  default='1'>
+         <documentation> Thickness of super page frame </documentation>
+         <release>Magics++0.5</release>
+  </parameter>
+  
+    <parameter name='layout' from='string' to='string' member='plot_layout'  default='automatic'>
+         <documentation> Type of page layout (POSITIONAL/AUTOMATIC) </documentation>
+   </parameter>
+
+  <parameter name='plot_start' from='string' to='string' member='plot_start' default='bottom'>
+         <documentation> Position of first page plotted (BOTTOM/TOP) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+
+  <parameter name='plot_direction' from='string' to='string' member='plot_direction'  default='vertical'>
+         <documentation> Direction of plotting (HORIZONTAL/VERTICAL) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+  
+  <parameter name='legend' from='string' to='bool' member='legend' default='off'>
+         <documentation>Turn on/off legend</documentation>
+         <release>Improved in Magics2.1</release>
+  </parameter>
+</class>
+
+
+
+<class name='MvRootSceneNode' action = 'pnew' xmltag='super_page' prefix='super_page' include='RootSceneNode.h' directory='common'>
+
+  <parameter name='super_page_x_length' from='float' to='float' member='width'  default='29.7'>
+           <release>Magics++0.1</release>
+         <documentation> Horizontal length of super page </documentation>
+  </parameter>
+
+  <parameter name='super_page_y_length' from='float' to='float' member='height'  default='21.0'>
+           <release>Magics++0.1</release>
+         <documentation> Vertical length of super page </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame' from='string' to='bool' member='frame'  default='off'>
+         <release>Magics++0.5</release>
+         <documentation> Plot frame around super page (ON/OFF) </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame_colour' from='string' to='Colour' member='colour'  default='blue' >
+           <release>Magics++0.5</release>
+         <documentation> Colour of super page frame </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame_line_style' from='string' to='LineStyle' member='style'  default='solid' >
+         <release>Magics++0.5</release>
+         <documentation> Style of super page frame (SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+  </parameter>
+
+  <parameter name='super_page_frame_thickness' from='int' to='int' member='thickness'  default='1'>
+         <documentation> Thickness of super page frame </documentation>
+         <release>Magics++0.5</release>
+  </parameter>
+  
+    <parameter name='layout' from='string' to='string' member='plot_layout'  default='automatic'>
+         <documentation> Type of page layout (POSITIONAL/AUTOMATIC) </documentation>
+   </parameter>
+
+  <parameter name='plot_start' from='string' to='string' member='plot_start' default='bottom'>
+         <documentation> Position of first page plotted (BOTTOM/TOP) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+
+  <parameter name='plot_direction' from='string' to='string' member='plot_direction'  default='vertical'>
+         <documentation> Direction of plotting (HORIZONTAL/VERTICAL) </documentation>
+         <release>Magics++0.2</release>
+  </parameter>
+  
+  <parameter name='legend' from='string' to='bool' member='legend' default='off'>
+         <documentation>Turn on/off legend </documentation>
+         <release>Improved in Magics2.1</release>
+  </parameter>
+</class>
+
+
+
+<class name='XmlRootNode' xmltag='magics' prefix='root_node' directory='basic'>
+ <parameter name='root_node_format' from='string' to='string' member='format'  default='a4'>
+           <release>Magics++2.4 </release>
+         <documentation>Format of super page (A4/A3/A2)</documentation>
+  </parameter>
+  
+   <parameter name='root_node_orientation' from='string' to='string' member='orientation'  default='landscape'>
+           <release>Magics++2.4</release>
+         <documentation>Orientation of super page (landscape/portrait)</documentation>
+  </parameter>
+  
+  <parameter name='root_node_width' from='float' to='float' member='width'  default='-1'>
+           <release>Magics++0.1</release>
+         <documentation> Horizontal length of super page </documentation>
+  </parameter>
+
+  <parameter name='root_node_height' from='float' to='float' member='height' default='-1'>
+           <release>Magics++0.1</release>
+         <documentation> Vertical length of super page </documentation>
+  </parameter>
+  
+  <parameter name='root_node_frame' from='string' to='bool' member='border'  default='off'>
+           <release>Magics++2.1</release>
+         <documentation> Frame on/off </documentation>
+  </parameter>
+  
+  <parameter name='root_node_frame_colour' from='string' to='Colour' member='border_colour'  default='blue'>
+           <release>Magics++2.1</release>
+         <documentation>Colour of frame</documentation>
+  </parameter>
+  
+  <parameter name='root_node_frame_line_style' from='string' to='LineStyle' member='border_style' 	 default='solid'>
+           <release>Magics++2.1</release>
+         <documentation> Frame Line Style </documentation>
+  </parameter>
+  
+  <parameter name='root_node_frame_thickness' from='int' to='int' member='border_thickness' default='1'>
+           <release>Magics++2.1</release>
+         <documentation> Frame thickness </documentation>
+  </parameter>
+   <parameter name='root_node_application' from='string' to='string' member='application' default='magml'>
+           <release>Magics++2.1</release>
+         <documentation> magml/wrep : set specail behaviour for wrep project </documentation>
+  </parameter>
+</class>
+
+
+
+<class name='WrepRootNode' xmltag='magics' prefix='wrep_node' directory='basic'>
+ <documentation>
+ 	In the wrep mode, magics will always try to fill the space: ie  the geographical area can be extended!
+ 	Different methods cab be used to control this extension.. 
+ 	centre : the middle point of the geographical will be put in the middle of the output ..
+ 	 top_left : the top_left point of the geographical will be put in the top_left of the output ..
+ 	 The other possibilities could be implemented but do not seem to be so important!
+ </documentation>
+  <parameter name='wrep_node_width' from='float' to='float' member='pixel_width'  default='800'>
+           <release>Magics++2.9</release>
+         <documentation> dimension in pixel of the output width </documentation>
+  </parameter>
+  <parameter name='wrep_node_height' from='float' to='float' member='pixel_height'  default='400'>
+           <release>Magics++2.9</release>
+         <documentation> dimension in pixel of the output height</documentation>
+  </parameter>
+
+  <parameter name='wrep_node_mapping_anchor' from='string' to='string' member='anchor'  default='centre'>
+           <release>Magics++2.9</release>
+         <documentation> method name used for the extension </documentation>
+  </parameter>
+</class>
+ 
+</magics>
diff --git a/src/xml/SymbolInput.xml b/src/xml/SymbolInput.xml
new file mode 100644
index 0000000..bc4c109
--- /dev/null
+++ b/src/xml/SymbolInput.xml
@@ -0,0 +1,43 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='SymbolInput' action_routine='psymb' directory='decoders' xmltag='input' prefix='symbol/symbol_input'>
+<documentation>
+	Here comes the description of the Symbol Plotting action
+</documentation>
+
+<parameter name='symbol_input_x_position' from='floatarray' to='floatarray' member='x' default='floatarray()' >
+   <documentation> array containing x positions for symbol plotting. values may be geographic, paper or graph units depending on the value set in symbol_position_type </documentation>
+   <release>0.6</release>
+   <release_info> only GEOGRAPHICAL position is implemented </release_info>
+</parameter>
+
+<parameter name='symbol_input_y_position' from='floatarray' to='floatarray' member='y' default='floatarray()'>
+   <documentation> array containing y positions for symbol plotting. values may be geographic, paper or graph units depending on the value set in symbol_position_type </documentation>
+   <release>0.6</release>
+   <release_info> only GEOGRAPHICAL position is implemented </release_info>
+</parameter>
+
+<parameter name='symbol_input_wind_speed' from='floatarray' to='floatarray' member='speed' default='floatarray()'>
+   <documentation> array containing wind speed for wind plotting. values may be geographic, paper or graph units depending on the value set in symbol_position_type </documentation>
+   <release_info> only GEOGRAPHICAL position is implemented </release_info>
+</parameter>
+
+<parameter name='symbol_input_wind_direction' from='floatarray' to='floatarray' member='direction' default='floatarray()'>
+   <documentation> array containing wind direction for wind plotting. values may be geographic, paper or graph units depending on the value set in symbol_position_type </documentation>
+   <release_info> only GEOGRAPHICAL position is implemented </release_info>
+</parameter>  
+
+<parameter name='symbol_input_number_list' from='floatarray' to='floatarray' member='value' default='floatarray()'>
+   <documentation> Array containing REAL VALUES. The value in a particular element of the array is plotted at the position defined by the corresponding 
+    elements of SYMBOL_INPUT_X_POSITION and SYMBOL_INPUT_Y_POSITION. This parameter may also be used with TEXT and MARKER plotting in TABLE mode </documentation>
+   <release>0.6</release>
+</parameter>
+
+<parameter name='symbol_position_mode' from='string' to='string' member='position' default='geographic'>
+   <documentation> Defines the input position data, valid values: GEOGRAPHIC, PAPER and GRAPH </documentation>
+   <release>1.3</release>
+</parameter>
+
+</class>
+
+</magics>
diff --git a/src/xml/SymbolPlotting.xml b/src/xml/SymbolPlotting.xml
new file mode 100644
index 0000000..a07e1b6
--- /dev/null
+++ b/src/xml/SymbolPlotting.xml
@@ -0,0 +1,441 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='SymbolPlotting' action='psymb' directory='visualisers'  metview='MSYMB' xmltag='symbol' prefix='symbol' >
+<documentation>
+This action routine (and C++object) controls the plotting of meteorological and marker symbols.
+</documentation>
+<parameter name='legend' from='string' to='bool' member='legend' default='off'>
+	 <documentation> Turn legend on or off (ON/OFF) : New Parameter! </documentation>
+</parameter>
+
+<parameter name='symbol_type' from='string' to='string' values='number/text/marker/wind/both' member='type' default='number'>
+            <documentation> Defines the type of symbol plotting required   </documentation>
+        <set value='text' name='symbol_text_list'/>
+        <set value='text' name='symbol_text_position'/> 
+        <set value='text' name='symbol_text_font_name'/>
+        <set value='text' name='symbol_text_font_size'/>
+        <set value='text' name='symbol_text_font_style'/>
+        <set value='text' name='symbol_text_font_colour'/>  
+        <set value='marker' name='symbol_text_list'/>
+        <set value='marker' name='symbol_text_position'/> 
+        <set value='marker' name='symbol_text_font_name'/>
+        <set value='marker' name='symbol_text_font_size'/>
+        <set value='marker' name='symbol_text_font_style'/>
+        <set value='marker' name='symbol_text_font_colour'/> 
+        <set value='number' name='symbol_format'/>
+        <set value='both' name='symbol_text_position'/> 
+        <set value='both' name='symbol_text_font_name'/>
+        <set value='both' name='symbol_text_font_size'/>
+        <set value='both' name='symbol_text_font_style'/>
+        <set value='both' name='symbol_text_font_colour'/> 
+        <set value='both' name='symbol_format'/>
+</parameter>
+
+<parameter name='symbol_table_mode' from='string' to='SymbolMode' member='mode' xml='table_mode' default='OFF'>
+            <option name='SymbolIndividualMode' fortran='off' xml='individual' include='SymbolMode.h'/>
+            <option name='SymbolAdvancedTableMode' fortran='advanced' xml='advanced' include='SymbolAdvancedTableMode.h' />
+            <option name='SymbolTableMode'      fortran='on'  xml='table' include='SymbolMode.h'/>
+            <documentation> Specifies if plotting is to be in advanced, table (on) or individual mode (off).
+            	Note:  The simple table mode is not recommended anymore, try to use the advanced mode instead, 
+            		   this  should give you easier control of the plot. </documentation>
+       
+</parameter>
+<parameter name='symbol_format' from='string' to='string' member='format' xml='format' default='(automatic)' >
+         <documentation> Format used to plot values (MAGICS Format/(AUTOMATIC)) </documentation>
+</parameter>
+	<parameter name='symbol_outline' from='string' to='bool' member='outline' default='off'> 
+            <set value='on' name='symbol_outline_colour'/> 
+            <set value='on' name='symbol_outline_thickness'/>
+            <set value='on' name='symbol_outline_style'/>
+            <documentation> Add an outline to each symbol </documentation>
+        </parameter>
+         <parameter name='symbol_outline_colour' from='string' to='Colour' member='outline_colour' default='black'>
+            <documentation> Colour of the outline </documentation>
+        </parameter>  
+         <parameter name='symbol_outline_thickness' from='int' to='int' member='outline_thickness' default='1'>
+            <documentation> thickness of the outline </documentation>
+        </parameter>
+       <parameter name='symbol_outline_style' from='string' to='LineStyle' member='outline_style'  default='solid'>
+         <documentation> Line Style of outline </documentation>
+  	</parameter>
+
+	<parameter name='symbol_connect_line' from='string' to='bool'
+            member='connect' default='off'> 
+            <set value='on' name='symbol_connect_automatic_line_colour'/> 
+            <set value='on' name='symbol_connect_line_colour'/> 
+            <set value='on' name='symbol_connect_line_thickness'/>
+            <set value='on' name='symbol_connect_line_style'/>
+            <documentation> Connect all the symbols with a line </documentation>
+        </parameter> 
+		<parameter name='symbol_connect_automatic_line_colour' from='string' to='bool'
+            member='automatic_connect_colour' default='on'>  
+             <set value='on' name='symbol_connect_line_colour'/>  
+            <documentation> if on, will use the colour of the symbol  </documentation>
+        </parameter>  
+         <parameter name='symbol_connect_line_colour' from='string' to='Colour'
+            member='connect_colour' default='black'>
+            <documentation> Colour of the connecting line  </documentation>
+        </parameter>  
+         <parameter name='symbol_connect_line_thickness' from='int' to='int'
+            member='connect_thickness' default='1'>
+            <documentation> thickness of the  connecting line </documentation>
+        </parameter>
+       <parameter name='symbol_connect_line_style' from='string' to='LineStyle' member='connect_style'  default='solid'>
+         <documentation> Line Style of  connecting line </documentation>
+  		</parameter>
+</class>
+
+
+<class name='SymbolIndividualMode' directory='visualisers' xmltag='individual' prefix='symbol' include='SymbolMode.h' inherits='SymbolMode'>
+	<documentation>Here comes the description of the SymbolIndividualMode object</documentation>
+        <parameter  name='legend_user_text' to='string' default='' from='string' member='legend_text' >
+	 		<documentation > if set, the text to be shown for the symbol group in the legend		</documentation>
+	</parameter>
+        <parameter name='symbol_marker_mode' from='string' to='string' member='marker_mode' default='index' values='index/name/image'>
+            <documentation> Method to select a marker : by name, by index, by image : in that case, Magics will use an external image as marker.  
+            	
+            </documentation>
+            <set value='index' name='symbol_marker_index'/>
+            <set value='image' name='symbol_image_path'/>
+            <set value='image' name='symbol_image_format'/> 
+            <set value='image' name='symbol_image_width'/>
+            <set value='image' name='symbol_image_height'/>
+        </parameter>
+        
+       
+        <parameter name='symbol_marker_index' from='int' to='int' member='marker' default='1'>
+            <documentation> Marker indice:  An integer between 1 and 28</documentation>
+        </parameter>
+        
+        <parameter name='symbol_marker_name' from='string' to='string'
+            member='symbol' default='dot' >
+            <documentation> Symbol name. Choose in a list of available markers dot/circle/ww_00 ... </documentation>
+        </parameter>
+        
+        
+        
+       <parameter name='symbol_colour' from='string' to='Colour' member='colour' default='BLUE'>
+            <documentation> Colour of symbols.   </documentation>
+        </parameter>
+        <parameter name='symbol_height' from='float' to='float' member='height' default='0.2'>
+            <documentation> Height of symbols.  </documentation>
+        </parameter>
+		<parameter name='symbol_image_path' from='string' to='string' member='image_path' default=''>
+            <documentation> Path to the image </documentation>
+        </parameter>
+        
+        <parameter name='symbol_image_format' from='string' to='string' member='image_format' default='' values='png/svg/gif/jpeg' >
+            <documentation>  Format of the image </documentation>
+        </parameter>
+        
+        <parameter name='symbol_image_width' from='float' to='float' member='image_width' default='-1' >
+            <documentation>  width of the image </documentation>
+        </parameter> 
+        <parameter name='symbol_image_height' from='float' to='float' member='image_height' default='-1' >
+            <documentation>  height of the image </documentation>
+        </parameter>
+        <parameter name='symbol_text_list' from='stringarray' to='stringarray'
+            member='text' default='stringarray()'>
+            <documentation> lsit of texts to plot </documentation>
+        </parameter>
+        <parameter name='symbol_text_position' from='string' to='string'
+            member='text_position' default='right' values='right/left/bottom/top'>
+            <documentation> Position of the text </documentation>
+        </parameter>
+         <parameter name='symbol_text_font_name' from='string' to='string'
+            member='text_font_name' default='sansserif'>
+            <documentation> Font to use  </documentation>
+        </parameter>
+          <parameter name='symbol_text_font_size' from='float' to='float'
+            member='text_font_size' default='0.25'>
+            <documentation> Font size  </documentation>
+        </parameter>
+         <parameter name='symbol_text_font_style' from='string' to='string'
+            member='text_font_style' default='normal'>
+            <documentation> Font style  </documentation>
+        </parameter>
+         <parameter name='symbol_text_font_colour' from='string' to='Colour'
+            member='text_font_colour' default='automatic'>
+            <documentation> Font colour.  </documentation>
+        </parameter> 
+        <parameter name='symbol_text_blanking' from='string' to='bool'
+            member='text_blanking' default='off'>
+            <documentation> blanking of the text </documentation>
+        </parameter>
+</class>
+
+
+<class name='SymbolMode' directory='visualisers' xmltag='table' prefix='symbol'>
+
+</class>
+
+<class name='SymbolTableMode' directory='visualisers' xmltag='table' prefix='symbol' include='SymbolMode.h' inherits='SymbolMode'>
+    <documentation>
+		Here comes the description of the SymbolTableMode object 
+	</documentation>
+    <parameter name='symbol_min_table' from='floatarray' to='floatarray'
+            member='min' default='floatarray()'>
+            <documentation> Table of minimum values.  The table is used in conjunction with SYMBOL_MAX_TABLE  </documentation>
+        </parameter>
+      <parameter name='symbol_max_table' from='floatarray' to='floatarray'
+            member='max' default='floatarray()' >
+            <documentation> Table of maximum values. The table is used in conjunction with SYMBOL_MIN_TABLE  </documentation>
+        </parameter>
+        <parameter name='symbol_marker_table' from='intarray' to='intarray'
+            member='marker' default='intarray()'>
+            <documentation> Table of MARKER indices. The table is to be used in conjunction with SYMBOL_MIN_TABLE and SYMBOL_MAX_TABLE  </documentation>
+        </parameter>
+          <parameter name='symbol_name_table' from='stringarray' to='stringarray'
+            member='symbol' default='stringarray()'>
+            <documentation> Table of Symbol names. The table is to be used in conjunction with SYMBOL_MIN_TABLE and SYMBOL_MAX_TABLE  </documentation>
+        </parameter>
+         <parameter name='symbol_colour_table' from='stringarray' to='stringarray'
+            member='colour' default='stringarray()'>
+            <documentation> Table of SYMBOL colours. T The table is to be used in conjunction with SYMBOL_MIN_TABLE and SYMBOL_MAX_TABLE  </documentation>
+        </parameter>
+        <parameter name='symbol_height_table' from='floatarray' to='floatarray'
+            member='height' default='floatarray()'>
+            <documentation> Table of SYMBOL heights.  The table is to be used in conjunction with SYMBOL_MIN_TABLE and SYMBOL_MAX_TABLE  </documentation>
+        </parameter>
+
+</class>
+
+
+
+
+
+
+
+
+<class name='SymbolAdvancedTableMode' directory='visualisers' 
+		prefix='symbol/symbol_advanced_table' xmltag='advanced' inherits='SymbolMode'>
+    <documentation>
+		Here comes the description of the SymbolTableMode object 
+	</documentation>
+     <parameter name='symbol_advanced_table_selection_type' 
+             from='string' to='LevelSelection'
+             member='levels' default='count' values='count/interval/list'>
+         <documentation>  Technique to use to calculate the shading band levels. </documentation>
+         <migration> New Magics: Parameter contour_level_selection_type sent to new Magics[IsoPlot].  </migration>
+         <release>2.6</release>
+         <option name='CountSelectionType'   fortran='count'  xml='count' docdive='no' include='CountSelectionType.h'/>
+         <option name='IntervalSelectionType'   fortran='interval'  xml='interval' docdive='no' include='IntervalSelectionType.h'/>
+         <option name='LevelListSelectionType'   fortran='list'  xml='list' docdive='no' include='LevelListSelectionType.h'/>
+       
+        
+         <set value='list' name='symbol_advanced_table_level_list'/>
+     	<set value='interval' name='symbol_advanced_table_interval'/> 
+     	<set value='interval' name='symbol_advanced_table_reference_level'/>
+         <set value='count' name='symbol_advanced_table_level_count'/>
+         <set value='count' name='symbol_advanced_table_level_tolerance'/>
+         
+     </parameter>
+   
+      <parameter name='symbol_advanced_table_min_value' from='float' to='float'
+             member='min'  default='-1.e21'>
+         <documentation> Min value to plot</documentation>
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_max_value' from='float' to='float'
+             member='max'  default='1.e21'>
+         <documentation> Max value to plot </documentation>
+         <release>2.6</release>
+  </parameter>
+       <parameter name='symbol_advanced_table_level_count' from='int' to='int'
+             member='count'  default='10'>
+         <documentation> Count or number of levels to be plotted. Magics will try to find "nice levels", 
+         this means that the number of levels could be slightly different from the requested number of levels</documentation>
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_level_tolerance' from='int' to='int'
+             member='tolerance'  default='2'>
+         <documentation> Tolerance: Do not use "nice levels" if the number of levels is really to different [count +/- tolerance] </documentation>
+         <release>2.6</release>
+  </parameter>
+
+
+
+  <parameter name='symbol_advanced_table_interval' from='float' to='float'
+             member='interval'  default='8.0'>
+         <documentation> Interval in data units between different bands of shading </documentation>
+         <release>2.6</release>
+  </parameter>
+   <parameter name='symbol_advanced_table_reference_level' from='float' to='float'
+             member='reference'  default='0.0'>
+         <documentation> Level from which the level interval is calculated </documentation>
+         <release>2.6</release>
+  </parameter>
+ <parameter name='symbol_advanced_table_level_list' from='floatarray' to='floatarray'
+             member='list'	 default='floatarray()'>
+         <documentation> List of shading band levels to be plotted </documentation>
+         <release>2.6</release>
+  </parameter>
+        
+     
+     
+      <parameter name='symbol_advanced_table_colour_method' from='string' to='ColourTechnique'
+             member='colourMethod' 	 default='calculate'>
+         <documentation> Method of generating the colours of the bands in polygon shading  </documentation>
+         <option name='CalculateColourTechnique' fortran='calculate' xml='calculate' docdive='no' include='CalculateColourTechnique.h'/>
+         <option name='ListColourTechnique'      fortran='list'      xml='list'      docdive='no' include='ListColourTechnique.h'/>
+         <available>list</available>
+         <release>2.6</release>
+         <set value='list' name='symbol_advanced_table_colour_list'/>
+         <set value='list' name='symbol_advanced_table_colour_list_policy'/>
+         <set value='calculate' name='symbol_advanced_table_max_level_colour'/>
+         <set value='calculate' name='symbol_advanced_table_min_level_colour'/>
+         <set value='calculate' name='symbol_advanced_table_colour_direction'/>
+  </parameter>
+
+  <parameter name='symbol_advanced_table_max_level_colour' from='string' to='Colour'
+             member='maxColour' default='blue'>
+         <documentation> Highest shading band colour </documentation>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='symbol_advanced_table_min_level_colour' from='string' to='Colour'
+             member='minColour'  default='red'>
+         <documentation> Lowest shading band colour </documentation>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='symbol_advanced_table_colour_direction' from='string' to='string'
+             member='direction' default='anti_clockwise' values='clockwise/anti-clockwise'>
+         <documentation> Direction of colour sequencing for plotting (CLOCKWISE/ ANTI_CLOCKWISE) </documentation>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='symbol_advanced_table_colour_list' from='stringarray' to='stringarray'
+             member='colours' default='stringarray()'>
+         <documentation> List of colours to be used in symbol plotting </documentation>
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_colour_list_policy' from='string' to='ListPolicy'
+             member='colour_policy' default='lastone'>
+         <documentation> What to do if, the list of markers is smaller that the list of intervals: lastone/cycle </documentation>     
+         <release>2.6</release>
+  </parameter>
+  
+  <parameter name='symbol_advanced_table_marker_list' from='intarray' to='intarray'
+             member='markers' default='intarray()'>
+         <documentation> List of markers to be used in symbol plotting </documentation>
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_marker_list_policy' from='string' to='ListPolicy'
+             member='marker_policy' default='lastone'>
+         <documentation>What to do if, the list of markers is smaller that the list of intervals: lastone/cycle </documentation>
+         <release>2.6</release>
+  </parameter>
+  
+  <parameter name='symbol_advanced_table_height_method' from='string' to='HeightTechnique'
+             member='height_method' default='list'>
+         <documentation> Method of generating the height   </documentation>
+         <option name='CalculateHeightTechnique' fortran='calculate' xml='calculate' docdive='no' include='HeightTechnique.h'/>
+         <option name='ListHeightTechnique'      fortran='list'      xml='list'      docdive='no' include='HeightTechnique.h'/>
+		 <set value='list' name='symbol_advanced_table_height_list'/>
+		 <set value='list' name='symbol_advanced_table_height_list_policy'/>
+		 <set value='calculate' name='symbol_advanced_table_height_max_value'/>
+		 <set value='calculate' name='symbol_advanced_table_height_min_value'/>
+         <release>2.6</release>
+  </parameter>
+  
+        
+   <parameter name='symbol_advanced_table_height_max_value' from='float' to='float'
+             member='height_max' default='0.2'>
+         <documentation> Min height to use </documentation>
+         
+         <release>2.6</release>
+  </parameter>    
+  <parameter name='symbol_advanced_table_height_min_value' from='float' to='float'
+             member='height_min' default='0.1'>
+         <documentation> Min height to use </documentation>
+         
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_height_list' from='floatarray' to='floatarray'
+             member='heights' default='floatarray()'>
+         <documentation> List of heights to be used </documentation>
+                 <available>list</available>
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_height_list_policy' from='string' to='ListPolicy'
+             member='height_policy' default='lastone'>
+         <documentation> What to do if, the list of markers is smaller that the list of intervals: lastone/cycle </documentation>     
+         <release>2.6</release>
+  </parameter>
+ 	   <parameter name='symbol_advanced_table_text_list' from='stringarray' to='stringarray'
+             member='text_list' default='stringarray()'>
+         <documentation> Text to display </documentation>
+         
+         <release>2.6</release>
+  </parameter>    
+  <parameter name='symbol_advanced_table_text_list_policy' from='string' to='ListPolicy'
+             member='text_policy' default='cycle'>
+         <documentation> What to do if, the list of markers is smaller that the list of intervals
+			lastone: reuse the last one, 
+			cycle: return to the fisrt one 
+		 </documentation>     
+         <release>2.6</release>
+  </parameter>
+  <parameter name='symbol_advanced_table_text_font_name' from='string' to='string'
+            member='text_font_name' default='sansserif'>
+            <documentation> Font to use for text plotting. </documentation>
+        </parameter>
+          <parameter name='symbol_advanced_table_text_font_size' from='float' to='float'
+            member='text_font_size' default='0.25'>
+            <documentation> Font size  </documentation>
+        </parameter>
+         <parameter name='symbol_advanced_table_text_font_style' from='string' to='string'
+            member='text_font_style' default='normal'>
+            <documentation>  Font Style   </documentation>
+        </parameter>
+         <parameter name='symbol_advanced_table_text_font_colour' from='string' to='Colour'
+            member='text_font_colour' default='automatic'>
+            <documentation> Symbol Colour  </documentation>
+        </parameter> 
+   <parameter name='symbol_advanced_table_text_display_type' from='string' to='string'
+             member='text_display_type' default='none' values='centre/none/right/left/top/bottom'>
+         <documentation>  How to display text 
+         	none:do not display it 
+         	centre : display it instead of the symbol, 
+         	right : attached it to the right of the symbol, 
+         	top : attached it to the top of the symbol, 
+         	bottom:   attached it to the bottom of the symbol, 
+         </documentation>
+         <release>2.6</release>
+  </parameter>    
+      <parameter name='symbol_advanced_table_outlayer_method' from='string' to='NoOutLayerTechnique'
+             member='outlayer' default='none' include='OutLayerTechnique.h'  >
+         <documentation> outlayer method </documentation> 
+         <option name='NoOutLayerTechnique' fortran='none' xml='nooutlayer' docdive='no' include='OutLayerTechnique.h'/>
+         <option name='SimpleOutLayerTechnique' visible='no' fortran='simple' xml='simple' docdive='no' include='OutLayerTechnique.h'/>                 
+         <release>2.6</release>
+  	  </parameter>    
+  	    <parameter name='symbol_advanced_table_outlayer_min_value' from='float' to='float'
+             member='outlayer_min' default='-1.e21' visible='no' >
+         <documentation> outlayer min value </documentation>         
+         <release>2.6</release>
+  	  </parameter>   
+  	  <parameter name='symbol_advanced_table_outlayer_max_value' from='float' to='float'
+             member='outlayer_max' default='1.e21' visible='no' >
+         <documentation> outlayer max value </documentation>         
+         <release>2.6</release>
+  	  </parameter>    
+  	 
+  
+</class>
+
+
+
+
+
+
+
+<class  name='HeightTechnique' directory='visualisers' />
+<class  name='CalculateHeightTechnique' directory='visualisers' inherits='HeightTechnique' include='HeightTechnique.h'/>
+<class  name='ListHeightTechnique' directory='visualisers' inherits='HeightTechnique' include='HeightTechnique.h'/>
+
+<class  name='NoOutLayerTechnique' directory='visualisers' include='OutLayerTechnique.h'/>
+<class  name='SimpleOutLayerTechnique' inherits='NoOutLayerTechnique' include='OutLayerTechnique.h' directory='visualisers'/>
+
+</magics>
diff --git a/src/xml/TableDecoder.xml b/src/xml/TableDecoder.xml
new file mode 100644
index 0000000..b23d69c
--- /dev/null
+++ b/src/xml/TableDecoder.xml
@@ -0,0 +1,93 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='TableDecoder' directory='decoders'  xmltag='table' >
+  <documentation> table data for curve </documentation>
+
+  <parameter name='table_filename' from='string' to='string' member='path' default='' >
+         <documentation>Path to the table data </documentation>
+  </parameter>
+  
+  <parameter name='table_delimiter' from='string' to='string' member='delimiter' default=',' >
+         <documentation>Used delimiter </documentation>
+  </parameter>
+  
+  <parameter name='table_combine_delimiters' from='string' to='bool' member='combine_delimiters' default='off' >
+         <documentation>Consecutive delimiters will be considered as one </documentation>
+  </parameter>
+  
+  <parameter name='table_header_row' from='int' to='int' member='header_row' default='1' >
+         <documentation>Which row (first is 1) is the header line on? </documentation>
+  </parameter>
+  
+   <parameter name='table_data_row_offset' from='int' to='int' member='data_row_offset' default='1' >
+         <documentation>How many rows after the header row does the data start? 1 if no header row.</documentation>
+  </parameter>
+
+   <parameter name='table_meta_data_rows' from='intarray' to='intarray' member='meta_data_rows' default='intarray()' >
+         <documentation>List of row indexes containing meta-data of the form P1=V1 P2=V2.</documentation>
+  </parameter> 
+   <!--parameter name='table_columns' from='intarray' to='array'
+             member='columns' default='1' >
+         <documentation>List of column indexes to selectively read (first is 1).</documentation>
+  </parameter>
+    <parameter name='table_column_types' from='stringarray' to='stringarray'
+             member='column_types' default='' >
+         <documentation>List of column data types (can be number/string)</documentation>
+  </parameter-->
+ 
+ <parameter name='table_x_type' from='string' to='string' member='x_type' default='number' >
+         <documentation>Type used for X variable_index: number or date </documentation>
+  </parameter>
+  
+  <parameter name='table_y_type' from='string' to='string' member='y_type' default='number' >
+         <documentation>Type used for Y variable_index: number or date </documentation>
+  </parameter>
+  
+  <parameter name='table_variable_identifier_type' from='string' to='string' member='name_mode' default='index' >
+         <documentation> are we refering to the columns by names or index (index/name) </documentation>
+  </parameter>
+  
+  <parameter name='table_x_variable' from='string' to='string' member='x' default='1' >
+         <documentation> X variable_index  </documentation>
+  </parameter>
+  
+  <parameter name='table_y_variable' from='string' to='string' member='y' default='2' >
+         <documentation> Y variable_index  </documentation>
+  </parameter>
+ 
+  <parameter name='table_value_variable' from='string' to='string' member='values' default='-1' >
+         <documentation>  variable_index  </documentation>
+  </parameter>
+  
+  <parameter name='table_latitude_variable' from='string' to='string' member='lat' default='2' >
+         <documentation>  Latitudes  </documentation>
+  </parameter>
+
+  <parameter name='table_longitude_variable' from='string' to='string' member='lon' default='1' >
+         <documentation>  longitudes  </documentation>
+  </parameter>
+  
+  <parameter name='table_x_component_variable' from='string' to='string' member='x_component' default='-1' >
+         <documentation>  u components for vectors  </documentation>
+  </parameter>
+
+  <parameter name='table_y_component_variable' from='string' to='string' member='y_component' default='-1' >
+         <documentation>  v components for vectors  </documentation>
+  </parameter>
+  
+  <parameter name='table_x_missing_value' from='float' to='float' member='x_missing' default='-21.e6' >
+         <documentation> mssing value for x   </documentation> 
+  </parameter>
+
+  <parameter name='table_y_missing_value' from='float' to='float' member='y_missing' default='-21.e6' >
+         <documentation> missing value for x   </documentation>
+  </parameter>
+
+  <parameter name='table_binning' from='string' to='BinningObject' include='BinningObject.h' member='table_binning' default='on' >
+         <documentation> Binning information </documentation>
+         <option name='NoBinningObject'   fortran='off'  xml='nobinning' include='BinningObject.h'/>
+         <option name='BinningObject'   fortran='on'  xml='binning' include='BinningObject.h'/>
+  </parameter>
+</class>
+
+</magics>
diff --git a/src/xml/Taylor.xml b/src/xml/Taylor.xml
new file mode 100644
index 0000000..56fecbf
--- /dev/null
+++ b/src/xml/Taylor.xml
@@ -0,0 +1,193 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='TaylorProjection' action='ptaylor' directory='common' xmltag='taylor' inherits='Transformation' prefix='taylor/taylor/taylor_standard_deviation'>
+	<documentation>
+		
+	</documentation>
+         <parameter name='taylor_standard_deviation_min' from='float' to='float'
+            member='min' default='0' xml='min'>
+            <documentation>
+              	Min of the Standard deviation axis.
+           </documentation>
+           <release>Magics++1.4</release> 
+       </parameter>
+       <parameter name='taylor_standard_deviation_max' from='float' to='float'
+            member='max' default='1' xml='max'>
+            <documentation>
+              	Max of the Standard deviation axis.
+           </documentation>
+           <release>Magics++1.4</release>
+       </parameter>
+</class> 
+
+<class name='TaylorGrid' action='ptaylor' directory='visualisers'  xmltag='taylorgrid' prefix='taylor/taylor'>
+	<documentation> description of the grid </documentation>
+    <parameter name='taylor_label' from='string' to='string'
+            member='label' default='Correlation'>
+            <documentation>
+              	Label of the grid
+           </documentation>
+           <release>Magics++2.7</release> 
+        </parameter> 
+        <parameter name='taylor_label_colour' from='string' to='Colour'
+            member='label_colour' default='navy'>
+            <documentation>
+              	Colour of the label
+           </documentation>
+           <release>Magics++1.4</release> 
+        </parameter>
+        <parameter name='taylor_label_height' from='float' to='float'
+            member='label_height' default='0.35'>
+            <documentation>
+              	Hieght of the label
+           </documentation>
+           <release>Magics++1.4</release> 
+        </parameter>
+        <parameter name='taylor_primary_grid_reference' from='float' to='float'
+            member='primary_reference' default='0.5'>
+            <documentation>
+              	Reference used  of the Standard deviation plotting.
+           </documentation>
+           <release>Magics++2.7</release> 
+        </parameter>
+        <parameter name='taylor_primary_grid_increment' from='float' to='float'
+            member='primary_increment' default='0.5'>
+            <documentation>
+              	Reference used  of the Standard deviation plotting.
+           </documentation>
+           <release>Magics++1.4</release> 
+        </parameter>
+        
+          <parameter name='taylor_reference_line_colour' from='string' to='Colour'
+            member='reference_colour' default='navy'>
+            <documentation>
+              	Colour used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_reference_line_thickness' from='int' to='int'
+            member='reference_thickness' default='2'>
+            <documentation>
+              	Thickness used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter> 
+          <parameter name='taylor_reference_line_style' from='string' to='LineStyle'
+            member='reference_style' default='solid'>
+            <documentation>
+              	Line Style used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       
+        
+       <parameter name='taylor_primary_grid_line_colour' from='string' to='Colour'
+            member='primary_colour' default='navy'>
+            <documentation>
+              	Colour used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_primary_grid_line_thickness' from='int' to='int'
+            member='primary_thickness' default='1'>
+            <documentation>
+              	Thickness used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter> 
+       <parameter name='taylor_primary_label' from='string' to='bool'
+            member='primary_label' default='on'>
+            <documentation>
+              	Turn the labels (on/off) of the primary grid
+            </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_primary_label_colour' from='string' to='Colour'
+            member='primary_label_colour' default='navy'>
+            <documentation>
+              	Colour of the  labels  of the primary grid
+            </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_primary_label_height' from='float' to='float'
+            member='primary_label_height' default='0.35'>
+            <documentation>
+              	Height of the  labels  of the primary grid
+            </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_primary_grid_line_style' from='string' to='LineStyle'
+            member='primary_style' default='solid'>
+            <documentation>
+              	Line Style used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_secondary_grid' from='string' to='bool'
+            member='secondary_grid' default='solid'>
+            <documentation>
+              	turn on/off the secondaries lines for the grid.
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_secondary_grid_reference' from='float' to='float'
+            member='secondary_reference' default='0.5'>
+            <documentation>
+              	Reference used  of the Standard deviation plotting.
+           </documentation>
+           <release>Magics++1.4</release> 
+        </parameter>
+        <parameter name='taylor_secondary_grid_increment' from='float' to='float'
+            member='secondary_increment' default='0.5'>
+            <documentation>
+              	Reference used  of the Standard deviation plotting.
+           </documentation>
+           <release>Magics++1.4</release> 
+        </parameter>
+        <parameter name='taylor_secondary_grid_line_colour' from='string' to='Colour'
+            member='secondary_colour' default='navy'>
+            <documentation>
+              	Colour used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+            
+       </parameter>
+       <parameter name='taylor_secondary_grid_line_thickness' from='int' to='int'
+            member='secondary_thickness' default='1'>
+            <documentation>
+              	Thickness used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_secondary_grid_line_style' from='string' to='LineStyle'
+            member='secondary_style' default='solid'>
+            <documentation>
+              	Line Style used to plot the primary grid
+           </documentation>
+           <release>Magics++2.8</release>
+       </parameter> <parameter name='taylor_secondary_label' from='string' to='bool'
+            member='secondary_label' default='on'>
+            <documentation>
+              	Turn the labels (on/off) of the secondary grid
+            </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_secondary_label_colour' from='string' to='Colour'
+            member='secondary_label_colour' default='navy'>
+            <documentation>
+              	Colour of the  labels  of the secondary grid
+            </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+       <parameter name='taylor_secondary_label_height' from='float' to='float'
+            member='secondary_label_height' default='0.35'>
+            <documentation>
+              	Height of the  labels  of the secondary grid
+            </documentation>
+           <release>Magics++2.8</release>
+       </parameter>
+</class>
+
+
+
+</magics>
diff --git a/src/xml/TextVisitor.xml b/src/xml/TextVisitor.xml
new file mode 100644
index 0000000..38d8577
--- /dev/null
+++ b/src/xml/TextVisitor.xml
@@ -0,0 +1,405 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='TextVisitor' action='ptext'
+	xmltag='text' prefix='text' xml_data='text_lines' directory='basic' xml_doc_inherits='XmlBasicNode'>
+  <documentation></documentation>
+  
+
+  
+
+  <parameter name='text_justification' from='string' to='Justification' member='justification' default='centre'>
+	<release>Magisc++0.3</release>
+	<documentation> How text is to be positioned in each line (LEFT/CENTRE/RIGHT)</documentation>
+  </parameter>
+
+  <parameter name='text_font' from='string' to='string' member='font' xml='font' default='sansserif'>
+	<documentation>Font name - please make sure this font is installed!</documentation>
+	<release>1.0</release>
+	<release_info>Much improved in version 1.3.</release_info>
+  </parameter>
+  
+  <parameter name='text_font_style' from='string' to='string' member='font_style' default=''>
+	<documentation>Font style. Set this to an empty string in order to remove all styling.</documentation>
+  </parameter>
+  
+  <parameter name='text_font_size' from='string' to='string' member='font_dimension' default='0.5' metview_default='0.3'>
+	<documentation>Font size, specified in cm.</documentation>
+  </parameter>
+
+  <parameter name='text_reference_character_height' from='float' to='float' member='height'  implemented ='no' default='0.5' >
+	<documentation> Reference height for calculating the height of the characters in text lines (see main text) in cm.</documentation>
+	<release>1.0</release>
+	<release_info>Change default from 2.0 to 0.5 ---> To be discussed later!</release_info>
+  </parameter>
+
+  <parameter name='text_colour' from='string' to='Colour' member='font_colour' default='blue' metview_default='navy'>
+	<documentation>Colour of text in text block (Full choice of colours)</documentation>
+	<release>1.0</release>
+  </parameter>
+
+  <parameter name='text_quality' from='string' to='string' member='text_quality' default='medium' implemented='no' priority='0.2'>
+	<documentation>Quality of text in text block (LOW/MEDIUM/HIGH)</documentation>
+	<release>Expected for Magisc++0.6</release>
+  </parameter>
+
+   <parameter name='text_automatic' from='string' to='bool' member='automatic' default='on' visible='no'>
+	<release>Magisc++2.1</release>
+	<documentation>How text is to be positioned in each line (LEFT/CENTRE/RIGHT)</documentation>
+  </parameter>
+
+  <parameter name='text_lines' from='stringarray' to='stringarray' member='lines' default='stringarray()' >
+         <documentation> text block to be plotted </documentation>
+         <migration> New Magics: Parameter text sent to new Magics[TextAction].  </migration>
+  </parameter>
+ 
+    <parameter name='text_box_x_position' from='float' to='float' member='x' default='-1'>
+         <release>0.1</release>
+         <documentation> X coordinate of lower left corner of text box (Relative to PAGE_X_POSITION) </documentation>
+  </parameter>
+
+  <parameter name='text_box_y_position' from='float' to='float' member='y' default='-1' >
+         <release>0.1</release>
+         <documentation> Y coordinate of lower left corner of text box (Relative to PAGE_Y_POSITION) </documentation>
+  </parameter>
+
+  <parameter name='text_box_x_length' from='float' to='float' member='width'  default='-1'>
+         <release>0.1</release>
+         <documentation> Length of text box in X direction </documentation>
+  </parameter>
+
+  <parameter name='text_box_y_length' from='float' to='float' member='height' xml='height' default='-1'>
+         <release>0.1</release>
+         <migration> New Magics: Parameter text_box_y_length sent to new Magics[TextBox].  </migration>
+  </parameter>
+
+  <parameter name='text_box_blanking' from='string' to='bool' member='blanking' default='off'>
+         <release>0.1</release>
+          <release_info>Paremeter defined but not implemeted : expected for 0.6</release_info>
+         <documentation> All plotting in the text box previous to PTEXT call will be blanked out. Plotting after PTEXT call will not be affected. (ON/OFF) </documentation>
+  </parameter>
+
+  <parameter name='text_border' from='string' to='bool' member='border' default='off'>
+         <release>0.5</release>    
+         <documentation> Plot border around text box (ON/OFF) </documentation>
+         <migration> New Magics: Parameter text_border sent to new Magics[TextBox].  </migration>
+  </parameter>
+  
+  <parameter name='text_border_line_style' from='string' to='LineStyle' member='border_line_style' default='solid'>
+          <release>0.5</release>    
+         <documentation> Line style of border around text box (SOLID/DASH/DOT/CHAIN_DASH/CHAIN_DOT) </documentation>
+  </parameter>
+
+  <parameter name='text_border_colour' from='string' to='Colour' member='border_colour' default='blue' >
+          <release>0.5</release>    
+         <documentation> Colour of border around text box (Full choice of colours) </documentation>
+  </parameter>
+
+  <parameter name='text_border_thickness' from='int' to='int' member='border_thickness' default='1'>
+          <release>0.5</release>    
+         <documentation> Thickness of text box border </documentation>
+  </parameter>
+  
+  <parameter name='text_mode' from='string' to='string' member='mode' default='title'>
+ 	<documentation>Whether text is to be a title or user positioned (TITLE/POSITIONAL)</documentation>
+	<release>1.0</release>
+  </parameter>
+  
+ <parameter name='text_line_count' from='int' to='int' member='count' default='1'>
+         <release>0.1</release>
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> The number of lines of text to be plotted </documentation>
+  </parameter>
+  
+ <parameter name='text_html' from='string' to='bool' member='html' default='on'>
+         <release>2.0</release>
+         <release_info> Change the default value from off to on in Magics2.12</release_info>
+         <documentation> enable use of HTML convention </documentation>
+  </parameter>
+  
+  <parameter name='text_line_1' from='string' to='string' member='line1' 	 default='<magics_title/>'>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+ <parameter name='text_line_2' from='string' to='string' member='line2' 	 default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_3' from='string' to='string' member='line3'  default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_4' from='string' to='string' member='line4' default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_5' from='string' to='string' member='line5'  default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_6' from='string' to='string' member='line6'  default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_line_7' from='string' to='string' member='line7' default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_8' from='string' to='string' member='line8'  default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_9' from='string' to='string'  member='line9' 	 default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_line_10' from='string' to='string' member='line10' default=''>
+         <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> Character string for holding lines of text (n=1,10) </documentation>
+  </parameter>
+  
+
+  <parameter name='text_first_line' from='int' to='int' member='first'  default='1'>
+          <release>0.1</release>    
+         <release_info>deprecated parameter : see text_lines </release_info>
+         <documentation> The first line in the text block to be plotted </documentation>
+  </parameter>
+  
+   <parameter name='text_character_1' from='string' to='string' member='character1'  default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  
+  <parameter name='text_character_2' from='string' to='string' member='character2' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_3' from='string' to='string'
+             member='character3' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_4' from='string' to='string'
+             member='character4' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_5' from='string' to='string'
+             member='character5' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_6' from='string' to='string'
+             member='character6' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_7' from='string' to='string'
+             member='character7' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_8' from='string' to='string'
+             member='character8' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_9' from='string' to='string'
+             member='character9' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  <parameter name='text_character_10' from='string' to='string'
+             member='character10' default=''>
+         <documentation> 10 MAGICS parameters enabling users to store CHARACTER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+
+  <parameter name='text_integer_1' from='int' to='int' member='integer1' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  
+  
+   <parameter name='text_integer_2' from='int' to='int' member='integer2' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_3' from='int' to='int'
+             member='integer3' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_4' from='int' to='int'
+             member='integer4' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_5' from='int' to='int'
+             member='integer5' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_6' from='int' to='int'
+             member='integer6' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_7' from='int' to='int'
+             member='integer7' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_8' from='int' to='int'
+             member='integer8' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_9' from='int' to='int'
+             member='integer9' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_integer_10' from='int' to='int'
+             member='integer10' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store INTEGER info for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+
+  <parameter name='text_real_1' from='float' to='float'
+             member='real1' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  
+   <parameter name='text_real_2' from='float' to='float'
+             member='real2' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_3' from='float' to='float'
+             member='real3' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_4' from='float' to='float'
+             member='real4' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_5' from='float' to='float'
+             member='real5' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_6' from='float' to='float'
+             member='real6' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_7' from='float' to='float'
+             member='real7' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_8' from='float' to='float'
+             member='real8' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_9' from='float' to='float'
+             member='real9' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+   <parameter name='text_real_10' from='float' to='float'
+             member='real10' default='0'>
+          <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> 10 MAGICS parameters enabling users to store REAL information for plotting in text lines (n=1,10) </documentation>
+  </parameter>
+  
+  <parameter name='text_line_height_ratio_1' from='float' to='float'
+             member='height_ratio_1' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  
+  <parameter name='text_line_height_ratio_2' from='float' to='float'
+             member='height_ratio_2' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_3' from='float' to='float'
+             member='height_ratio_3' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_4' from='float' to='float'
+             member='height_ratio_4' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_5' from='float' to='float'
+             member='height_ratio_5' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_6' from='float' to='float'
+             member='height_ratio_6' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_7' from='float' to='float'
+             member='height_ratio_7' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_8' from='float' to='float'
+             member='height_ratio_8' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  <parameter name='text_line_height_ratio_9' from='float' to='float'
+             member='height_ratio_9' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+  
+  <parameter name='text_line_height_ratio_10' from='float' to='float' member='height_ratio_10' default='1'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+
+ 
+  <parameter name='text_instruction_shift_character' from='string' to='string' member='text_instruction_shift_character' default='\' implemented='no'>
+         <documentation> Symbol or character for indicating that an Instruction String follows </documentation>
+  </parameter>
+
+  <parameter name='text_escape_character' from='string' to='string' member='text_escape_character' default='#' implemented='no'>
+         <documentation> Symbol or character followed by 3 octal numbers - see one of Figure XIV-1 to Figure XIV-3 </documentation>
+  </parameter>
+
+  <parameter name='text_parameter_escape_character' from='string' to='string' member='parameter_escape'  default='@'>
+         <documentation> Symbol or character for indicating that a MAGICS parameter follows. The MAGICS parameter is also terminated by the same symbol or character </documentation>
+  </parameter>
+  
+  <parameter name='text_line_height_ratios' from='floatarray' to='floatarray' member='height_ratios' xml='line_height_ratios' default='floatarray()'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of height of text lines to text reference character height (n=1,10). See main text </documentation>
+  </parameter>
+
+  <parameter name='text_line_space_ratio' from='float' to='float' member='text_line_space_ratio'  default='1.5' implemented='no' priory='0'>
+         <release_info>Needs user input to see the possible evolution of this parameter</release_info>
+         <documentation> Ratio of space above and below each line to text reference character height. See main text </documentation>
+  </parameter>
+
+</class>
+
+</magics>
diff --git a/src/xml/Title.xml b/src/xml/Title.xml
new file mode 100644
index 0000000..c30fe26
--- /dev/null
+++ b/src/xml/Title.xml
@@ -0,0 +1,54 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='Title' xml_data='title_text' directory='visualisers' inherits='TitleBase'>
+  <documentation></documentation>
+  
+  <parameter name='title_colour' from='string' to='Colour'
+             member='colour' xml='colour' default='blue'>
+          <release>Magisc++0.8</release>
+         <documentation> Colour of the title </documentation>
+         <migration> New Magics: Parameter text_mode sent to new Magics[TextAction].  </migration>
+  </parameter>
+  <parameter name='title_text' from='stringarray' to='stringarray'
+             member='text' xml='text' default='stringarray()'>
+          <release>Magisc++0.8</release>
+         <documentation>title </documentation>
+         <migration> New Magics: Parameter text_mode sent to new Magics[TextAction].  </migration>
+  </parameter>
+   <parameter name='title_justification' from='string' to='Justification'
+             member='justification' xml='justification' default='centre'>
+          <release>Magisc++0.8</release>
+         <documentation> How text is to be positioned in each line (LEFT/CENTRE/RIGHT)	 </documentation>
+         <migration> New Magics: Parameter title_justification sent to new Magics[Ttitle].  </migration>
+  </parameter>
+  
+  <parameter name='text_font_size' from='float' to='float'
+             member='height' xml='font_size' default='0.5' >
+	     <release>Magics++0.8</release>
+	      <release_info>Change default from 2.0 to 0.5 ---> To be discussed later!</release_info>
+         <documentation> height for calculating the height of the characters in text lines (see main text) </documentation>
+         <migration> New Magics: Parameter text_reference_character_height sent to new Magics[TextAction].  </migration>
+  </parameter>
+
+  <parameter name='title_font' from='string' to='string'
+             member='font' xml='font' default='sansserif' >
+	     <release>Magics++1.38</release>
+         <documentation>Font to use </documentation>
+         <migration> New Magics: Parameter text_reference_character_height sent to new Magics[TextAction].  </migration>
+  </parameter>
+   <parameter name='text_font_style' from='string' to='string' 
+   		member='style' xml='font_style' default='normal'>
+	<available>normal</available>
+	<available>bold</available>
+	<available>italic</available>
+	<available>bolditalic</available>
+	<documentation>Font style.</documentation>
+	<release>1.3</release>
+	<release_info>Implemented in Magics++ 1.3.</release_info>
+  </parameter>
+</class>
+
+<class name='NoTitle' include='Title.h' inherits='TitleBase' directory='visualisers'/>
+<class name='TitleBase' include='TitleBase.h' directory='visualisers'/>
+
+</magics>
diff --git a/src/xml/TitleTemplate.xml b/src/xml/TitleTemplate.xml
new file mode 100644
index 0000000..ae878cd
--- /dev/null
+++ b/src/xml/TitleTemplate.xml
@@ -0,0 +1,16 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='TitleTemplate' directory='decoders'>
+	<documentation>
+		Here comes the description of the TitleTemplate 
+	</documentation>
+        <parameter name='title_template_filename' from='string' to='string'
+            member='file' default='title_template.xml'>
+            <documentation> Description in Xml of the titles  </documentation>
+            <migration> New Magics: Parameter title_template_filename sent to new Magics[TitleTemplate].  </migration>
+        </parameter>
+        
+</class>
+
+
+</magics>
diff --git a/src/xml/ValuePlot.xml b/src/xml/ValuePlot.xml
new file mode 100644
index 0000000..92b980c
--- /dev/null
+++ b/src/xml/ValuePlot.xml
@@ -0,0 +1,130 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='ValuePlot'  xmltag='gridvalues' prefix='contour/contour_grid_value/contour_grid_value'
+	action='pcont' directory='visualisers' inherits='ValuePlotBase' >
+
+  <parameter name='contour_grid_value_type' from='string' to='string' member='type' default='normal' values='normal/reduced/akima' >
+         <documentation> For Gaussian fields, plot normal (regular) values or reduced grid values.  (NORMAL/REDUCED/akima). If akima, the akima grid values will be plotted </documentation>
+         <release>0.2</release>
+  </parameter>
+
+  <parameter name='contour_grid_value_plot_type' from='string' to='ValuePlotMethod'  member='method' xml='plot_type' default='value'>
+         <documentation> (VALUE/MARKER/BOTH) </documentation>
+         <option name='ValuePlotMethod'          fortran='value'  xml='value'  include='ValuePlotMethod.h' />
+         <option name='MarkerValuePlotMethod'    fortran='marker' xml='marker' include='MarkerValuePlotMethod.h' />
+         <option name='BothValuePlotMethod'           fortran='both'   xml='both'    include='BothValuePlotMethod.h' />
+         <release>0.2</release>
+ </parameter>
+
+ </class>
+
+
+<class name='NoValuePlot' xmltag='nogridvalues' action='pcont' directory='visualisers' include='ValuePlot.h'  inherits='ValuePlotBase'>
+   <documentation>This object suppresses the plotting of grid values. </documentation>
+</class>
+
+
+
+
+<class name='ValuePlotMethod' prefix='contour/contour_grid_value/contour_grid_value' action='pcont' directory='visualisers'  >
+
+<parameter name='contour_grid_value_min' from='float' to='float' member='min' default='-1.0e+21'>
+         <documentation> The minimum value for which grid point values are to be plotted </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_max' from='float' to='float' member='max' default='1.0e+21' >
+         <documentation> The maximum value for which grid point values are to be plotted </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_lat_frequency' from='int' to='int' member='lat_frequency' default='1' >
+         <documentation> The grid point values in every Nth latitude row are plotted </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_lon_frequency' from='int' to='int' member='lon_frequency'  default='1' >
+         <documentation> The grid point values in every Nth longitude column are plotted </documentation>
+         <release>0.2</release>
+</parameter>
+  
+<parameter name='contour_grid_value_height' from='float' to='float' member='height' default='0.25'>
+         <documentation> Height of grid point values  </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_colour' from='string' to='Colour' member='colour'  default='blue' >
+         <documentation> Colour of grid point values (Full choice of colours) </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_format' from='string' to='string' member='format'  default='(automatic)'>
+         <documentation> Format of grid point values (MAGICS Format/(AUTOMATIC)) </documentation>
+         <release>0.2</release>
+         <release>Format is not yet implemented. Expected Magics++0.3</release>
+</parameter>
+
+<parameter name='contour_grid_value_quality' from='string' to='string' member='quality'  default='low'>
+         <documentation> (LOW/MEDIUM/HIGH) </documentation>
+         <release>0.2</release>
+         <release>Quality is not yet implemented. Expected Magics++0.3</release>
+  </parameter>
+</class>
+
+<class name='MarkerValuePlotMethod' action='pcont'  xmltag='marker' prefix='contour/contour_grid_value/contour_grid_value' directory='visualisers' inherits='ValuePlotMethod'>
+
+<parameter name='contour_grid_value_marker_height' from='float' to='float' member='markerHeight' default='0.25' >
+         <documentation> Height of grid point markers </documentation>
+         <release>0.2</release>
+</parameter>
+
+  <parameter name='contour_grid_value_marker_colour' from='string' to='Colour'
+             member='markerColour' default='red'>
+         <documentation> Colour of grid point markers (Full choice of colours) </documentation>
+         <release>0.2</release>
+  </parameter>
+
+  <parameter name='contour_grid_value_marker_qual' from='string' to='string' member='markerQuality' default='low' >
+         <documentation> (LOW/MEDIUM/HIGH) </documentation>
+         <release>0.2</release>
+	 <!-- Spelling mistale QUAL instead of QUALITY comes from MAGICS 6! -->
+</parameter>
+
+  <parameter name='contour_grid_value_marker_index' from='int' to='int' member='markerIndex' default='3' >
+         <documentation> Table number of marker index. See Appendix for Plotting Attributes </documentation>
+         <release>0.2</release>
+  </parameter>
+  
+</class>
+
+
+<class name='BothValuePlotMethod'  xmltag='both' prefix='contour/contour_grid_value/contour_grid_value' action='pcont' 
+	inherits='ValuePlotMethod' directory='visualisers'>
+  <documentation>This object is reponsible for plotting both values and markers on grid points.</documentation>
+
+<parameter name='contour_grid_value_marker_height' from='float' to='float' member='markerHeight' default='0.25' >
+         <documentation> Height of grid point markers </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_marker_colour' from='string' to='Colour' member='markerColour' default='red'>
+         <documentation> Colour of grid point markers (Full choice of colours) </documentation>
+         <release>0.2</release>
+</parameter>
+
+<parameter name='contour_grid_value_marker_qual' from='string' to='string' member='markerQuality' default='low' >
+         <documentation> (LOW/MEDIUM/HIGH) </documentation>
+         <release>0.2</release>
+         <release>Quality is not yet implemented. Expected Magics++0.3</release>
+</parameter>
+
+<parameter name='contour_grid_value_marker_index' from='int' to='int' member='markerIndex' default='3' >
+         <documentation> Table number of marker index. See Appendix for Plotting Attributes </documentation>
+         <release>0.2</release>
+  </parameter>
+</class>
+
+<class name='ValuePlotBase' include='ValuePlotBase.h' directory='visualisers'/>
+
+</magics>
diff --git a/src/xml/View.xml b/src/xml/View.xml
new file mode 100644
index 0000000..f404442
--- /dev/null
+++ b/src/xml/View.xml
@@ -0,0 +1,348 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='XmlBasicNode' action='MagML' directory='basic' xmltag='view' prefix='view'> 
+  <parameter name='view_standalone' from='string' to='bool' member='standalone'  default='off'>
+         <release>Magics++2.9</release>
+         <documentation> If true, the node will be created in an external file .. can be useful for legend and text ...</documentation>
+  </parameter>
+  
+  <parameter name='view_standalone_file_name' from='string' to='string' member='standalone_path'  default=''>
+         <release>Magics++2.9</release>
+         <documentation> Path of the file wich will contain this view </documentation>
+  </parameter>
+  
+  <parameter name='view_standalone_format' from='string' to='string' member='standalone_format'  default='png'>
+         <release>Magics++2.9</release>
+         <documentation> format of the file wich will contain this view </documentation>
+  </parameter>
+ 
+  <parameter name='view_standalone_width' from='float' to='float' member='standalone_width'  default='128'>
+         <release>Magics++2.9</release>
+         <documentation> width of the image that will contain this view </documentation>
+  </parameter>
+  
+   <parameter name='view_standalone_height' from='float' to='float' member='standalone_height'  default='64'>
+         <release>Magics++2.9</release>
+         <documentation> height of the image that will contain this view </documentation>
+  </parameter>
+
+  <parameter name='view_display' from='string' to='DisplayType' member='display'  default='inline'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='view_bottom' from='string' to='string' member='bottom' default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>  
+  
+  <parameter name='view_left' from='string' to='string' member='left' default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='view_width' from='string' to='string' member='width'  default='100%'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='view_height' from='string' to='string' member='height'  default='100%' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+
+  <parameter name='view_margin_bottom' from='string' to='string' member='margin_bottom'  default='undef'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='view_margin_left' from='string' to='string' member='margin_left'  default='undef'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='view_margin_right' from='string' to='string' member='margin_right'  default='undef'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='view_margin_top' from='string' to='string' member='margin_top'  default='undef' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+
+  <parameter name='view_background_colour' from='string' to='Colour' member='background'  default='white'>
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='view_border_bottom' from='string' to='string' member='border_bottom'  default='1px'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='view_border_left' from='string' to='string' member='border_left' 	 default='1px'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='view_border_right' from='string' to='string' member='border_right'  default='1px'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='view_border_top' from='string' to='string' member='border_top'  default='1px' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+  
+  <parameter name='view_border' from='string' to='bool' member='border'  default='on'> 
+         <documentation> Frame </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+  
+  <parameter name='view_blanking' from='string' to='bool' member='blanking' default='on'> 
+         <documentation> Blanking </documentation>
+         <release>Magics++2.1</release>
+  </parameter>
+  
+  <parameter name='view_border_colour' from='string' to='Colour' member='border_colour'  default='tan'> 
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  
+  <parameter name='view_border_style' from='string' to='LineStyle' member='border_style'  default='solid'> 
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  
+  <parameter name='view_border_thickness' from='int' to='int'  member='border_thickness'  default='1'> 
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='view_padding_bottom' from='string' to='string' member='padding_bottom'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='view_padding_left' from='string' to='string' member='padding_left'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='view_padding_right' from='string' to='string' member='padding_right'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='view_padding_top' from='string' to='string' member='padding_top'  default='0%' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+  
+  <parameter name='view_padding_colour' from='string' to='Colour'  member='padding_colour' 	 default='none'>
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+</class>
+
+
+
+<class name='XmlViewNode' action='MagML' xmltag='map' directory='basic' prefix='view/subpage_map' inherits='XmlBasicNode'> 
+	<parameter name="view_fitted_mode" from="string" to="string" member="fitted" default="off">
+	<documentation> If set to cropped, the projection will force a resize of the output to respect the aspect ratio.. Useful in the context of the web..  If set to fitted, the projection willbe expendef to fill the space! a resize of the output to respect the aspect ratio.. Useful in the context of the web.. </documentation>
+	</parameter>
+	<parameter name='subpage_map_projection' from='string' to='Transformation'
+             member='transformation' 
+			 default='cylindrical'>
+         <documentation> Projection required(CYLINDRICAL/ POLAR_STEREOGRAPHIC/ MERCATOR/SATELLITE/LAMBERT/AITOFF/OCEAN_SECTION/NONE) </documentation>
+         <release>Magics++0.1</release>
+        <!--option name='CylindricalProjection' fortran='cylindrical' xml='cylindrical' include='CylindricalProjection.h'/-->
+         <!-- New cylindrical prokjection...-->
+         <option name='GeoRectangularProjection' fortran='cylindrical' xml='cylindrical' include='GeoRectangularProjection.h'/>
+
+         <!--option name='PolarStereoProjection' fortran='polar_stereographic' xml='polar_stereographic' include='PolarStereoProjection.h'/-->
+         <!-- New polar stereographic projection...-->
+<!--
+         <option name='Proj4Projection' fortran='proj4' xml='proj4' include='Proj4Projection.h'/>
+-->
+         <option name='MercatorProjection' fortran='mercator' xml='mercator' include='GeoRectangularProjection.h'/>
+		 <option name='CartesianTransformation' fortran='none' xml='cartesian' include='CartesianTransformation.h'/>
+         <option name='TaylorProjection' fortran='taylor' xml='taylor' include='TaylorProjection.h'/>
+         <!--later 
+         	<option name='SatelliteProjection' fortran='satellite' xml='satellite' include='SatelliteProjection.h'/>
+         	<option name='TaylorProjection' fortran='taylor' xml='taylor' include='TaylorProjection.h'/-->
+         <!-- Code to update to add a new projection...
+         	<option name='NewProjection' fortran='fortran-new-projection' xml='xm-tag-for-new-projection' include='NewProjection.h'/>
+         -->
+	</parameter>
+</class>
+        
+  
+<class name='XmlSceneNode' action='MagML' xmltag='page' prefix='scene_node/view' directory='basic'> 
+  <parameter name='view_display' from='string' to='DisplayType' member='display'  default='inline'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+
+  <parameter name='scene_node_bottom' from='string' to='string' member='bottom'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>  
+  
+  <parameter name='scene_node_left' from='string' to='string' member='left' default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='scene_node_width' from='string' to='string' member='width' 	 default='100%'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_height' from='string' to='string' member='height'  default='100%' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+
+  <parameter name='scene_node_margin_bottom' from='string' to='string' member='margin_bottom'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_margin_left' from='string' to='string' member='margin_left' 	 default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='scene_node_margin_right' from='string' to='string' member='margin_right'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_margin_top' from='string' to='string' member='margin_top' default='0%' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+
+  <parameter name='scene_node_background_colour' from='string' to='Colour' member='background' default='white'>
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='scene_node_border_bottom' from='string' to='string' member='border_bottom'  default='1px'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_border_left' from='string' to='string' member='border_left'  default='1px'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='scene_node_border_right' from='string' to='string' member='border_right'  default='1px'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+   <parameter name='scene_node_border' from='string' to='bool' member='border'  default='off' >
+         <release>Magics++0.1</release>
+          <documentation> Frame on/off </documentation>
+  </parameter>
+
+  <parameter name='scene_node_border_top' from='string' to='string' member='border_top'  default='1px' >
+         <release>Magics++0.1</release>
+          <documentation> Height of View.</documentation>
+  </parameter>
+
+  <parameter name='scene_node_border_colour' from='string' to='Colour' member='border_colour'  default='blue'>
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+  
+  <parameter name='scene_node_border_style' from='string' to='LineStyle' member='border_style'  default='solid'> 
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='scene_node_border_thickness' from='int' to='int' member='border_thickness'  default='1'> 
+         <documentation> Colour of the subpage background </documentation>
+         <release>Magics++0.1</release>
+  </parameter>
+
+  <parameter name='scene_node_padding_bottom' from='string' to='string' member='padding_bottom' default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> Y-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_padding_left' from='string' to='string' member='padding_left'  default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> X-Coordinate of bottom of View.</documentation>
+  </parameter>
+  
+   <parameter name='scene_node_padding_right' from='string' to='string' member='padding_right' default='0%'>
+         <release>Magics++0.8</release>
+         <documentation> width of the View .</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_padding_top' from='string' to='string' member='padding_top'  default='0%' >
+          <documentation> Height of View.</documentation>
+  </parameter>
+  
+  <parameter name='scene_node_padding_colour' from='string' to='Colour' member='padding_colour' default='none'>
+         <documentation> Colour of the subpage background </documentation>
+  </parameter>
+  
+ <parameter name='scene_node_id_line' from='string' to='NoPageID' include='PageID.h' member='page_id'  default='on'>
+         <release>Magics++2.1</release>
+         <option name='PageID' xml='pageid' include='PageID.h'/>
+         <option name='NoPageID' xml='nopageid' include='PageID.h'/>
+         <documentation> Plot identification line and ECMWF logo (ON/OFF) </documentation>
+  </parameter>
+</class>
+
+
+<class name ='LayerNode' directory='common' prefix='layer' xmltag='layer'>
+	<parameter name='layer_name' from='string' to='string' member='name' default='automatic'>
+	<release>Magics++2.1</release>
+	<documentation> Name of the layer : will be the button name! </documentation>
+	</parameter>
+	<parameter name='layer_active' from='string' to='bool' member='active' default='true'>
+	<release>Magics++2.1</release>
+	<documentation> if true, the layer will displayed and the button enabled. </documentation>
+	</parameter>
+</class>
+
+
+<class name ='BinaryObject' directory='common' prefix='mgb' xmltag='mgb'>
+
+<parameter name='mgb_filename' from='string' to='string' member='path' default=''>
+  <release>Magics++2.9</release>
+  <documentation for_docs='no'>Path to the binary file.</documentation>
+</parameter>
+
+<parameter name='mgb_transparency' from='float' to='float' member='transparency' default='1.0'>
+  <release>Magics++2.12.3</release>
+  <documentation for_docs='no'>Transpernecy scaling factor for binary layer.</documentation>
+</parameter>
+
+<parameter name='mgb_x' from='int' to='int' member='mgb_x' default='0' visible='no'>
+  <documentation for_docs='no'>X offset in percentage</documentation>
+</parameter>
+
+<parameter name='mgb_y' from='int' to='int' member='mgb_y' default='0' visible='no'>
+  <documentation for_docs='no'>Y offset in percentage</documentation>
+</parameter>
+
+<parameter name='mgb_width' from='int' to='int' member='mgb_width' default='100' visible='no'>
+  <documentation for_docs='no'>Width in percentage</documentation>
+</parameter>
+
+<parameter name='mgb_height' from='int' to='int' member='mgb_height' default='100' visible='no'>
+  <documentation for_docs='no'>Height in percentage</documentation>
+</parameter>
+
+</class>
+</magics>
diff --git a/src/xml/Wind.xml b/src/xml/Wind.xml
new file mode 100644
index 0000000..f454630
--- /dev/null
+++ b/src/xml/Wind.xml
@@ -0,0 +1,343 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='Wind' metview='MWIND' xmltag='wind' prefix='wind'  action='pwind' directory='visualisers'>
+  <documentation> Wind plotting facilities allow users to plot wind fields as either arrows or flags.</documentation>
+
+  <parameter name='wind_field_type' from='string' to='WindPlotting' member='type' default='arrows'>
+         <documentation> Method of wind field plotting  </documentation>
+         <release>Basic implementation in 0.6</release>
+         <option name='FlagPlotting' fortran='flags' xml='flags' include='FlagPlotting.h'  />
+         <option name='ArrowPlotting' fortran='arrows' xml='arrows' include='ArrowPlotting.h'/>
+  </parameter>
+
+ <parameter name='wind_thinning_method' from='string' to='string' member='thinning_method'  values='data/user' default='data' visible='false'>
+         <documentation> Method to control the thinning: 
+         data :  wind_thinning_factor will determine the frequency as before 
+         user : wind_thining_factor will determine the minimal distance in user coordinates betvween 2 winds. 
+         the default is "data" for backward compatibility.
+          </documentation>
+         <release>2.9</release>
+  </parameter>
+
+  <parameter name='wind_thinning_factor' from='float' to='float' member='thinning_factor' default='2.0'>
+         <documentation> Controls the actual number of wind arrows or flags plotted. See main text for explanation. Needs to 1.0 or larger.</documentation>
+         <release>0.6</release>
+  </parameter>
+</class>
+
+
+<class name='WindPlotting' xmltag='flags' prefix='wind/wind_flag' action='pwind'  directory='visualisers'>
+	<documentation>Parameters common to the falgs and arrows.</documentation>
+
+<parameter name='legend' from='string' to='bool' member='legend'  default='off'>
+	<release>2.1</release>
+	<set value='on' name='wind_legend_text'/>
+	<set value='on' name='wind_arrow_legend_text'/>
+	<documentation> Add  a wind legend information in the legend </documentation>
+</parameter>
+
+<parameter name='wind_legend_only' from='string' to='bool' member='legend_only'  default='off' visible='off'>
+	<release>2.1</release>
+	<documentation for_docs='no'> Wrep only : to build only the legned... </documentation>
+</parameter>
+
+<parameter name='wind_legend_text' from='string' to='string' member='legend_text'  default='vector'>
+	<release>2.1</release>
+	<documentation> Use your own text in the legend</documentation>
+</parameter>
+
+<parameter name='wind_advanced_method' from='string' to='string' member='advanced_method' default='off' values='on/off'> 
+         <documentation>Enable advanced plotting of wind (default is off for backward compatibility). 
+         The coour is selected according to the intensity of the wind (vector) </documentation>
+          <set value='on' name='wind_advanced_colour_selection_type'/> 		 
+		  <set value='on' name='wind_advanced_colour_max_value'/> 
+		  <set value='on' name='wind_advanced_colour_min_value'/>          
+          <set value='on' name='wind_advanced_colour_table_colour_method'/>
+         
+          
+  <release>2.9</release>
+</parameter>
+
+<parameter name='wind_advanced_colour_parameter' from='string' to='string' member='colour_method' default='speed' values='speed/parameter'>
+         <documentation>if speed, the wind is coloured using the norm of the vector, If parameter, a third parameter is used. </documentation>
+         <release>2.9</release>
+</parameter>
+
+<parameter name='wind_advanced_colour_selection_type' from='string' to='LevelSelection'  member='levels' default='count'>
+         <documentation>Set selection method </documentation>
+         <release>2.6</release>
+         <option name='CountSelectionType'   fortran='count'  xml='count' docdive='no' include='CountSelectionType.h'/>
+         <option name='IntervalSelectionType'   fortran='interval'  xml='interval' docdive='no' include='IntervalSelectionType.h'/>
+         <option name='LevelListSelectionType'   fortran='list'  xml='list' docdive='no' include='LevelListSelectionType.h'/>
+         <set value='list' name='wind_advanced_colour_level_list'/>
+         <set value='interval' name='wind_advanced_colour_level_interval'/>	
+         <set value='interval' name='wind_advanced_colour_reference_level'/>
+         <set value='count' name='wind_advanced_colour_reference_level'/>
+         <set value='count' name='wind_advanced_colour_level_count'/>
+         <set value='count' name='wind_advanced_colour_level_tolerance'/>
+</parameter>
+
+<parameter name='wind_advanced_colour_max_value' from='float' to='float' member='max' default='1.e21'>
+         <documentation>Max value to plot </documentation>
+         <release>2.6</release>
+</parameter>
+
+<parameter name='wind_advanced_colour_min_value' from='float' to='float' member='min' default='-1.e21'>
+         <documentation>Min value to plot </documentation>
+         <release>2.6</release>
+</parameter>
+
+<parameter name='wind_advanced_colour_level_count' from='int' to='int' member='count' default='10'>
+         <documentation>Number of levels to be plotted. Magics will try to find "nice levels", 
+         this means that the number of levels could be slightly different</documentation>
+         <release>2.6</release>
+</parameter>
+
+<parameter name='wind_advanced_colour_level_tolerance' from='int' to='int' member='tolerance' default='2'>
+         <documentation> Tolerance: Do not use "nice levels" if the number of levels is really to different [count +/- tolerance] </documentation>
+         <release>2.6</release>
+</parameter>
+ 
+<parameter name='wind_advanced_colour_reference_level' from='float' to='float' member='reference'  default='0.0'>
+         <documentation> Level from which the level interval is calculated </documentation>
+         <release>2.6</release>
+  </parameter>
+
+
+  <parameter name='wind_advanced_colour_level_interval' from='float' to='float'
+             member='interval'  default='8.0'>
+         <documentation> Interval in data units between different bands of colours </documentation>
+         <release>2.6</release>
+  </parameter>
+ 
+	<parameter name='wind_advanced_colour_level_list' from='floatarray' to='floatarray'
+             member='list'	 default='floatarray()' >
+         <documentation> List of levels  to be used </documentation>
+         <release>2.6</release>
+  </parameter>
+  
+  <parameter name='wind_advanced_colour_table_colour_method' from='string' to='ColourTechnique'
+             member='colourMethod' 	 default='calculate' >
+         <documentation> Method of generating the colours </documentation>
+  		<set value='calculate' name='wind_advanced_colour_max_level_colour'/>
+  		<set value='calculate' name='wind_advanced_colour_min_level_colour'/>
+  		<set value='calculate' name='wind_advanced_colour_direction'/>
+  		<set value='list' name='wind_advanced_colour_list'/>
+  		<set value='list' name='wind_advanced_colour_list_policy'/>
+         <option name='CalculateColourTechnique' fortran='calculate' xml='calculate' docdive='no' include='CalculateColourTechnique.h'/>
+         <option name='ListColourTechnique'      fortran='list'      xml='list'      docdive='no' include='ListColourTechnique.h'/>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='wind_advanced_colour_max_level_colour' from='string' to='Colour' member='maxColour' default='blue'>
+         <documentation> Highest shading band colour </documentation>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='wind_advanced_colour_min_level_colour' from='string' to='Colour' member='minColour'  default='red'>
+         <documentation> Lowest shading band colour </documentation>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='wind_advanced_colour_direction' from='string' to='string' member='direction' default='anti_clockwise' values='clockwise/anti_clockwise'>
+         <documentation> Direction of colour sequencing for plotting  </documentation>
+         <release>2.6</release>
+  </parameter>
+
+  <parameter name='wind_advanced_colour_list' from='stringarray' to='stringarray' colourlist='on' member='colours' default='stringarray()'>
+         <documentation> List of colours to be used in wind plotting </documentation>
+         <release>2.6</release>
+  </parameter>
+  <parameter name='wind_advanced_colour_list_policy' from='string' to='ListPolicy' member='colour_policy' default='lastone' >
+         <documentation> What to do if, the list of colours is smaller that the list of intervals: lastone/cycle </documentation>     
+         <release>2.6</release>
+  </parameter>
+  
+ <!-- 
+      <parameter name='wind_advanced_colour_outlayer_method' from='string' to='NoOutLayerTechnique'
+             member='outlayer' default='none' include='OutLayerTechnique.h' >
+         <documentation> outlayer method </documentation> 
+         <option name='NoOutLayerTechnique' fortran='none' xml='nooutlayer' docdive='no' include='OutLayerTechnique.h'/>
+         <option name='SimpleOutLayerTechnique' fortran='simple' xml='simple' docdive='no' include='OutLayerTechnique.h'/>                 
+         <release>2.6</release>
+  	  </parameter>    
+  	    <parameter name='wind_advanced_colour_outlayer_min_value' from='float' to='float'
+             member='outlayer_min' default='-1.e21' visible='no'>
+         <documentation> outlayer min value </documentation>         
+         <release>2.6</release>
+  	  </parameter>   
+  	  <parameter name='wind_advanced_colour_outlayer_max_value' from='float' to='float'
+             member='outlayer_max' default='1.e21' visible='no'>
+         <documentation> outlayer max value </documentation>         
+         <release>2.6</release>
+  	  </parameter>    
+  	--> 
+      
+</class>
+
+ <class name='CalmIndicator' directory='visualisers' /> 
+ <class name='NoCalmIndicator' inherits='CalmIndicator' include='CalmIndicator.h' directory='visualisers' />  
+ <class name='OriginMarker' directory='visualisers' /> 
+ <class name='DotOriginMarker' inherits='OriginMarker' include='OriginMarker.h' directory='visualisers' />
+ <class name='CircleOriginMarker'  inherits='OriginMarker' include='OriginMarker.h' directory='visualisers' />
+ <class name='NoOriginMarker' inherits='OriginMarker' include='OriginMarker.h' directory='visualisers' />
+
+<class name='FlagPlotting' xmltag='flags' prefix='wind/wind_flag' inherits='WindPlotting' action='pwind'  directory='visualisers'>
+  <documentation> WMO standard wind flags; represented by barbs and solid pennants </documentation> 
+  <parameter name='wind_flag_calm_indicator' from='string' to='CalmIndicator' member='calm'  default='on' values='on/off'>
+        <documentation> Plot calm indicator circle, if wind speed is less than 0.5 m/s (ON / OFF) </documentation>
+        <option name='CalmIndicator' fortran='on' xml='calm' include='CalmIndicator.h' />
+        <option name='NoCalmIndicator' fortran='off' xml='nocalm' include='CalmIndicator.h'  />
+	<set value='on' name='wind_flag_calm_indicator_size'/>
+	<set value='on' name='wind_flag_calm_below'/>
+  </parameter>
+
+  <parameter name='wind_flag_calm_indicator_size' from='float' to='float' member='calm_indicator_size'  default='0.3'>
+         <documentation> The radius of the circle which indicates calm in centimeter </documentation>
+        
+  </parameter>
+  
+   <parameter name='wind_flag_calm_below' from='float' to='float' member='calm_below'  default='0.5' >
+		
+         <documentation> Winds less than or equal to this value will be drawn as calm. </documentation>
+  </parameter>
+
+  <parameter name='wind_flag_colour' from='string' to='Colour' member='colour'  default='blue'>
+			 
+         <documentation> Colour of wind flag shaft, barbs and pennants  </documentation>
+        
+  </parameter>
+
+  <parameter name='wind_flag_cross_boundary' from='string' to='bool' member='cross_boundary' default='on' visible='false'>
+			
+         <documentation> If set to 'ON', wind flags are truncated if they cross the subpage border (ON / OFF) </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+  <parameter name='wind_flag_length' from='float' to='float' member='length'  default='1.0'>
+         <documentation> Physical length of wind flag shaft </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+  <parameter name='wind_flag_max_speed' from='float' to='float' member='max_speed'  default='1.0e+21'>
+         <documentation> Highest value of wind speed to be plotted </documentation>
+         <migration> New Magics: Parameter wind_flag_max_speed sent to new Magics[Wind].  </migration>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+  <parameter name='wind_flag_min_speed' from='float' to='float' member='min_speed' default='-1.0e+21' >
+         <documentation> Lowest value of wind speed to be plotted </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+  <parameter name='wind_flag_mode' from='string' to='string' member='wind_flag_mode'  default='normal' implemented='no'>
+      <release>Basic implementation in 0.6</release>
+      <documentation> Controls the line style of the wind flag shaft.(NORMAL / OFF_LEVEL / OFF_TIME) </documentation>
+  </parameter>
+
+ <parameter name='wind_flag_style' from='string' to='LineStyle' member='style' default='solid'>
+         <documentation> Controls the line style of the wind flag shaft. </documentation>
+         <release>Basic implementation in 0.6</release>
+  </parameter>
+
+  
+   <parameter name='wind_flag_origin_marker' from='string' to='OriginMarker' member='origin'  default='circle' values='circle/dot/off'> 
+	<release>Basic implementation in 0.6</release>
+	<documentation> Symbol for marking the exact location of the current grid point.</documentation>
+	<option name='DotOriginMarker' fortran='dot' xml='dotmarker' 	include='OriginMarker.h' />
+	<option name='CircleOriginMarker' fortran='circle' xml='circlemarker' 	include='OriginMarker.h' />
+	<option name='NoOriginMarker' fortran='off' xml='nomarker' 	include='OriginMarker.h' />
+  </parameter>
+  
+  <parameter name='wind_flag_origin_marker_size' from='float' to='float' member='origin_marker_size'  default='0.3'> 
+  </parameter>
+
+  <parameter name='wind_flag_thickness' from='int' to='int' member='thickness'  default='1'>
+	     <release>Basic implementation in 0.6</release>
+         <documentation> Thickness of wind flag shaft </documentation>  </parameter>
+</class>
+
+<class name = 'ArrowPlotting' xmltag='arrow' prefix='wind/wind_arrow' inherits='WindPlotting' action='pwind' directory='visualisers'>
+  <documentation></documentation>
+
+  <parameter name='wind_arrow_calm_indicator' from='string' to='CalmIndicator' member='calm' default='off' values='on/off'>
+	<release>Basic implementation in 0.6</release>
+	  <option name='CalmIndicator' fortran='on' xml='calm' include='CalmIndicator.h' />
+      <option name='NoCalmIndicator' fortran='off' xml='nocalm' include='CalmIndicator.h'  />
+    
+	<documentation>Plot calm indicator circle if wind speed is less than or equal to the value in WIND_ARROW_CALM_BELOW (ON / OFF)</documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_calm_indicator_size' from='float' to='float' member='calm_indicator_size' default='0.3'>
+	<release>Basic implementation in 0.6</release>
+	<documentation> The radius of the circle which indicates calm </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_calm_below' from='float' to='float' member='calm_below' default='0.5'>
+	<release>Basic implementation in 0.6</release>
+	<documentation> Winds less than or equal to this value will be drawn as calm. </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_colour' from='string' to='Colour' member='colour' default='blue' >
+	<release>Basic implementation in 0.6</release>
+	<documentation> Colour of wind arrow  </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_cross_boundary' from='string' to='bool' member='cross_boundary' default='on' implemented='no'>
+	<release>Basic implementation in 0.6</release>
+        <documentation> If set to 'ON', wind arrows are truncated if they cross the subpage border (ON / OFF). </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_head_shape' from='int' to='int' member='head' default='0' >
+	<release>Basic implementation in  1.3.</release>
+	<documentation>Table number, XY, indicating shape of arrowhead X</documentation>
+  </parameter>
+  
+  <parameter name='wind_arrow_head_ratio' from='float' to='float' member='ratio'  default='0.3' >
+	<release>Basic implementation in 0.6</release>
+	<documentation> Table number, XY, indicating style and shape of arrowhead X </documentation>
+  </parameter>
+  
+ 
+
+  
+
+ 
+
+  <parameter name='wind_arrow_max_speed' from='float' to='float' member='max_speed' default='1.0e+21'>
+	 <release>Basic implementation in 0.6</release>
+         <documentation> Highest value of wind speed to be plotted </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_min_speed' from='float' to='float' member='min_speed' default='-1.0e+21'>
+	<release>Basic implementation in 0.6</release>
+        <documentation> Lowest value of wind speed to be plotted </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_origin_position' from='string' to='ArrowPosition' member='origin_position' default='tail' values='centre/tail'>
+	<release>Basic implementation in 0.6</release>
+        <documentation> The position of the wind arrow relative to the wind origin  </documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_thickness' from='int' to='int' member='thickness'  default='1'>
+	 <release>Basic implementation in 0.8</release>
+         <documentation> Thickness of wind arrow shaft </documentation>
+  </parameter>
+  
+  <parameter name='wind_arrow_style' from='string' to='LineStyle' member='style'  default='solid'>
+         <documentation>Controls the line style of the arrow flag shaft.</documentation>
+         <release>Basic implementation in 0.8.</release>
+  </parameter>
+   <parameter name='wind_arrow_unit_system' from='string' to='string' member='unit_system'  default='paper' value='paper/user' visible='false'>
+        <documentation>Coordinates sysem used to sacle the arrow : paper -->1cm, user-->1 user unit</documentation>
+  </parameter>
+
+  <parameter name='wind_arrow_unit_velocity' from='float' to='float' member='unit_velocity'  default='25.0'>
+        <documentation>Wind speed in m/s represented by a unit vector (1.0 cm or 1.0 user unit depending on the value of wind_arrow_unit_system ).</documentation>
+  </parameter>  
+  <parameter name='wind_arrow_legend_text' from='string' to='string' member='legend_unit'  default='m/s'>
+        <documentation> Text to be used as units in the legend text </documentation>
+  </parameter>
+</class>   
+	
+</magics>
diff --git a/src/xml/XYList.xml b/src/xml/XYList.xml
new file mode 100644
index 0000000..a9cd14b
--- /dev/null
+++ b/src/xml/XYList.xml
@@ -0,0 +1,154 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='XYList' directory='decoders'  xmltag='xyinput' >
+  <documentation> Here comes the documentation of the XYSystem object </documentation>
+
+  <parameter name='x_values' from='floatarray' to='floatarray'
+             member='x' xml='x_values'
+			 default='floatarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y_values' from='floatarray' to='floatarray'
+             member='y' xml='y_values'
+			 default='floatarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  
+  
+  
+  
+  <parameter name='x_date_values' from='stringarray' to='stringarray'
+             member='x_date' xml='x_date_values'
+			 default='stringarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  <parameter name='x_base_date' from='string' to='string'
+             member='x_base'  default='' >
+         <documentation>Base Date to use when X date coordinates defined as offset  </documentation>
+         
+  </parameter>
+  <parameter name='x_date_offset' from='string' to='string'
+             member='x_offset'  default='second' >
+         <documentation>unit for the offset second/minute/hour/day</documentation>
+        
+  </parameter>
+   <parameter name='y_base_date' from='string' to='string'
+             member='y_base'  default='' >
+         <documentation>Base Date to use when Y date coordinates defined as offset  </documentation>
+         
+  </parameter>
+  <parameter name='y_date_offset' from='string' to='string'
+             member='y_offset'  default='second' >
+         <documentation>unit for the offset second/minute/hour/day</documentation>
+        
+  </parameter>
+
+  <parameter name='y_date_values' from='stringarray' to='stringarray'
+             member='y_date' xml='y_date_values'
+			 default='stringarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  <parameter name='x_missing_value' from='float' to='float'
+             member='x_missing' default='-21.e6' >
+         <documentation> mssing value for x   </documentation> 
+  </parameter> 
+  <parameter name='y_missing_value' from='float' to='float'
+             member='y_missing' default='-21.e6' >
+         <documentation> missing value for x   </documentation>
+  </parameter>
+  
+   <parameter name='x2_values' from='floatarray' to='floatarray'
+             member='x2' xml='x2_values'
+			 default='floatarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y2_values' from='floatarray' to='floatarray'
+             member='y2' xml='y2_values'
+			 default='floatarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  
+  
+  <parameter name='x2_date_values' from='stringarray' to='stringarray'
+             member='x2_date' xml='x2_date_values'
+			 default='stringarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y2_date_values' from='stringarray' to='stringarray'
+             member='y2_date' xml='y2_date_values'
+			 default='stringarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='x_lower_values' from='floatarray' to='floatarray'
+             member='x_lower' xml='x_values'
+			 default='floatarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y_lower_values' from='floatarray' to='floatarray'
+             member='y_lower' xml='y_values'
+			 default='floatarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  
+  <parameter name='x_lower_date_values' from='stringarray' to='stringarray'
+             member='x_lower_date' xml='x_lower_date_values'
+			 default='stringarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y_lower_date_values' from='stringarray' to='stringarray'
+             member='y_lower_date' xml='y_lower_date_values'
+			 default='stringarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  
+    <parameter name='x_upper_values' from='floatarray' to='floatarray'
+             member='x_upper' xml='x_upper_values'
+			 default='floatarray()' >
+         <documentation> X Upper Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y_upper_values' from='floatarray' to='floatarray'
+             member='y_upper' xml='y_upper_values'
+			 default='floatarray()' >
+         <documentation> y Upper Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  
+  <parameter name='x_upper_date_values' from='stringarray' to='stringarray'
+             member='x_upper_date' xml='x_upper_date_values'
+			 default='stringarray()' >
+         <documentation> X Values  </documentation>
+         <migration> New Magics: Parameter x_values sent to new Magics[XYList].  </migration>
+  </parameter>
+
+  <parameter name='y_upper_date_values' from='stringarray' to='stringarray'
+             member='y_upper_date' xml='y_upper_date_values'
+			 default='stringarray()' >
+         <documentation> y Values  </documentation>
+         <migration> New Magics: Parameter y_values sent to new Magics[XYList].  </migration>
+  </parameter>
+  
+</class>
+
+<static name='xy_list' class='XYList' base='BaseSceneObject' include_class='yes'/>
+
+</magics>
diff --git a/src/xml/XYTransformation.xml b/src/xml/XYTransformation.xml
new file mode 100644
index 0000000..8b2daae
--- /dev/null
+++ b/src/xml/XYTransformation.xml
@@ -0,0 +1,267 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='CartesianTransformation' xmltag='cartesian'  metview_prefix='subpage_' prefix='subpage' action='pnew' directory='common' inherits='Transformation'>
+  	This object contains the attributes to the cartesian Projection 
+
+<parameter name='subpage_x_axis_type' from='string' to='XCoordinate' member='x' default='regular' >
+    <option name='XRegularCoordinate'  fortran='regular'  xml='x_regular' include='Coordinate.h'/>
+    <option name='XDateCoordinate' fortran='date' xml='x_date' include='Coordinate.h'/>
+    <option name='XHyperCoordinate' fortran='geoline' xml='x_hyper' include='Coordinate.h'/>
+    <option name='XLogarithmicCoordinate' fortran='logarithmic' xml='x_logarithmic' include='Coordinate.h'/>
+    <release>Magics++1.3</release>         
+</parameter>    
+ 
+<parameter name='subpage_y_axis_type' from='string' to='YCoordinate' member='y' default='regular' >
+          
+           <option name='YRegularCoordinate'  fortran='regular'  xml='y_regular' include='Coordinate.h'/>
+           <option name='YDateCoordinate' fortran='date' xml='y_date' include='Coordinate.h'/>
+            <option name='YHyperCoordinate' fortran='geoline' xml='y_hyper' include='Coordinate.h'/>
+           <option name='YLogarithmicCoordinate' fortran='logarithmic' xml='y_logarithmic' include='Coordinate.h'/>
+           <release>Magics++1.3</release>
+</parameter>
+
+</class>
+
+
+<class name='XRegularCoordinate' metview_prefix='subpage_' xmltag='x_regular' prefix='subpage/subpage_x'  action='pnew' directory='common' inherits='XCoordinate' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+
+<parameter name='subpage_x_automatic' from='string' to='AxisAutomaticSetting' member='automatic' 
+	xml='automatic' 
+	default='off' values='on/off/min_only/max_only' >
+     <release>Magics2.1</release>
+     <set value='off' name='subpage_x_max'/> 
+     <set value='off' name='subpage_x_min'/>
+     <set value='min_only' name='subpage_x_max'/> 
+     <set value='max_only' name='subpage_x_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+
+<parameter name='subpage_x_min' from='float' to='float' member='min' xml='x_min' default='0' >
+    <release>Magics++0.1</release>
+</parameter>
+
+<parameter name='subpage_x_max' from='float' to='float' member='max' xml='x_max' default='100' >
+    <release>Magics++0.1</release>
+</parameter>
+
+
+
+</class>
+
+<class name='XLogarithmicCoordinate' metview_prefix='subpage_' xmltag='x_regular' prefix='subpage/subpage_x'  action='pnew' directory='common' inherits='XCoordinate' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+
+<parameter name='subpage_x_automatic' from='string' to='AxisAutomaticSetting' member='automatic' 
+	xml='automatic' 
+	default='off' values='on/off/min_only/max_only' >
+     <release>Magics2.1</release>
+     <set value='off' name='subpage_x_max'/> 
+     <set value='off' name='subpage_x_min'/>
+     <set value='min_only' name='subpage_x_max'/> 
+     <set value='max_only' name='subpage_x_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+
+<parameter name='subpage_x_min' from='float' to='float' member='min' xml='x_min' default='0' >
+    <release>Magics++0.1</release>
+</parameter>
+
+<parameter name='subpage_x_max' from='float' to='float' member='max' xml='x_max' default='100' >
+    <release>Magics++0.1</release>
+</parameter>
+
+
+
+</class>
+  
+
+<class name='XCoordinate'  xmltag='x_regular' action='pnew' directory='common'  include='Coordinate.h'/>
+<class name='YCoordinate' action='pnew'  xmltag='y_regular' directory='common'  include='Coordinate.h'/>
+
+
+<class name='YRegularCoordinate' metview_prefix='subpage_' action='pnew' prefix='subpage/subpage_y' xmltag='y_regular' directory='common' 
+		include='Coordinate.h' inherits='YCoordinate'>
+  This object contains the common attributes to the cartesian Projections
+<parameter name='subpage_y_automatic' from='string' to='AxisAutomaticSetting' 
+		values='on/off/min_only/max_only' member='automatic' xml='automatic' default='off' >
+         <release>Magics 2.1</release>
+        
+         <set value='off' name='subpage_y_max'/> 
+     <set value='off' name='subpage_y_min'/>
+     <set value='min_only' name='subpage_y_max'/> 
+     <set value='max_only' name='subpage_y_min'/>
+     <set value='off' name='subpage_y_date_max'/> 
+     <set value='off' name='subpage_y_date_min'/>
+     <set value='min_only' name='subpage_y_date_max'/> 
+     <set value='max_only' name='subpage_y_date_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+<parameter name='subpage_y_min' from='float' to='float' member='min' xml='min' default='0' > 
+    <release>Magics++0.1</release>
+</parameter>
+
+<parameter name='subpage_y_max' from='float' to='float' member='max' xml='max' default='100' >
+    <release>Magics++0.1</release>
+</parameter>
+
+
+
+</class>
+
+<class name='YLogarithmicCoordinate' metview_prefix='subpage_' action='pnew' inherits='YCoordinate' prefix='subpage/subpage_y' xmltag='y_regular' directory='common' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+<parameter name='subpage_y_automatic' from='string' to='AxisAutomaticSetting' 
+		values='on/off/min_only/max_only' member='automatic' xml='automatic' default='off' >
+         <release>Magics 2.1</release>
+        
+         <set value='off' name='subpage_y_max'/> 
+     <set value='off' name='subpage_y_min'/>
+     <set value='min_only' name='subpage_y_max'/> 
+     <set value='max_only' name='subpage_y_min'/>
+     <set value='off' name='subpage_y_date_max'/> 
+     <set value='off' name='subpage_y_date_min'/>
+     <set value='min_only' name='subpage_y_date_max'/> 
+     <set value='max_only' name='subpage_y_date_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+<parameter name='subpage_y_min' from='float' to='float' member='min' xml='min' default='0' > 
+    <release>Magics++0.1</release>
+</parameter>
+
+<parameter name='subpage_y_max' from='float' to='float' member='max' xml='max' default='100' >
+    <release>Magics++0.1</release>
+</parameter>
+
+
+
+</class>
+  
+
+<class name='XDateCoordinate' xmltag='x_date' metview_prefix='subpage_' prefix='subpage/subpage_x/subpage_x_date'  action='pnew' directory='common' inherits='XCoordinate' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+<parameter name='subpage_x_automatic' from='string' to='AxisAutomaticSetting' member='automatic' 
+	xml='automatic' 
+	default='off' values='on/off/min_only/max_only' >
+     <release>Magics2.1</release>
+     <set value='off' name='subpage_x_max'/> 
+     <set value='off' name='subpage_x_min'/>
+     <set value='min_only' name='subpage_x_max'/> 
+     <set value='max_only' name='subpage_x_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+<parameter name='subpage_x_date_min' from='string' to='string' member='date_min' default='' >
+         <release>Magics++0.1</release>
+</parameter> 
+
+<parameter name='subpage_x_date_max' from='string' to='string'  member='date_max' xml='max' default='' >
+    <release>Magics++0.1</release>
+</parameter>
+
+
+
+</class>
+
+
+<class name='YDateCoordinate' xmltag='y_date' metview_prefix='subpage_' prefix='subpage/subpage_y/subpage_y_date' action='pnew' directory='common' inherits='YCoordinate' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+<parameter name='subpage_y_automatic' from='string' to='AxisAutomaticSetting' 
+		values='on/off/min_only/max_only' member='automatic' xml='automatic' default='off' >
+         <release>Magics 2.1</release>
+        
+         <set value='off' name='subpage_y_max'/> 
+     <set value='off' name='subpage_y_min'/>
+     <set value='min_only' name='subpage_y_max'/> 
+     <set value='max_only' name='subpage_y_min'/>
+     <set value='off' name='subpage_y_date_max'/> 
+     <set value='off' name='subpage_y_date_min'/>
+     <set value='min_only' name='subpage_y_date_max'/> 
+     <set value='max_only' name='subpage_y_date_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+<parameter name='subpage_y_date_min' from='string' to='string'  member='date_min' default='' >
+   <release>Magics++0.1</release>
+</parameter>
+
+<parameter name='subpage_y_date_max' from='string' to='string' member='date_max'  default='' >
+         <release>Magics++0.1</release>
+</parameter>
+
+
+
+</class>
+  
+
+<class name='XHyperCoordinate' xmltag='x_hyper' metview_prefix='subpage_' prefix='subpage/subpage_x/subpage_x_hyper'  action='pnew' directory='common' inherits='XCoordinate' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+<parameter name='subpage_x_automatic' from='string' to='AxisAutomaticSetting' member='automatic' 
+	xml='automatic' 
+	default='off' values='on/off/min_only/max_only' >
+     <release>Magics2.1</release>
+     <set value='off' name='subpage_x_max'/> 
+     <set value='off' name='subpage_x_min'/>
+     <set value='min_only' name='subpage_x_max'/> 
+     <set value='max_only' name='subpage_x_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+<parameter name='subpage_x_min_latitude' from='float' to='float'  member='min_lat' xml='min' default='-90' >
+   <release>Magics++2.10</release>
+</parameter>
+
+<parameter name='subpage_x_max_latitude' from='float' to='float'  member='max_lat' xml='max' default='90' >
+     <release>Magics++2.10</release>
+</parameter>
+
+<parameter name='subpage_x_min_longitude' from='float' to='float'  member='min_lon' xml='min' default='-180' >
+   <release>Magics++2.10</release>
+</parameter>
+
+<parameter name='subpage_x_max_longitude' from='float' to='float'  member='max_lon' xml='max' default='180' >
+   <release>Magics++2.10</release>
+</parameter>
+
+
+
+</class>
+
+
+
+<class name='YHyperCoordinate' xmltag='y_hyper' metview_prefix='subpage_' prefix='subpage/subpage_y/subpage_y_hyper'  action='pnew' directory='common' inherits='YCoordinate' include='Coordinate.h'>
+  This object contains the common attributes to the cartesian Projections
+<parameter name='subpage_y_automatic' from='string' to='AxisAutomaticSetting' 
+		values='on/off/min_only/max_only' member='automatic' xml='automatic' default='off' >
+         <release>Magics 2.1</release>
+        
+         <set value='off' name='subpage_y_max'/> 
+     <set value='off' name='subpage_y_min'/>
+     <set value='min_only' name='subpage_y_max'/> 
+     <set value='max_only' name='subpage_y_min'/>
+     <set value='off' name='subpage_y_date_max'/> 
+     <set value='off' name='subpage_y_date_min'/>
+     <set value='min_only' name='subpage_y_date_max'/> 
+     <set value='max_only' name='subpage_y_date_min'/>
+     <documentation> The Min and Max are calculated from the data</documentation>    
+</parameter>
+<parameter name='subpage_y_min_latitude' from='float' to='float'  member='min_lat' xml='min' default='-90' >
+         <release>Magics++2.10</release>         
+ </parameter>
+
+<parameter name='subpage_y_max_latitude' from='float' to='float'  member='max_lat' xml='max' default='90' >
+         <release>Magics++2.10</release>         
+</parameter>
+
+<parameter name='subpage_y_min_longitude' from='float' to='float'  member='min_lon' xml='min' default='-180' >
+ <documentation>Set Y min value</documentation>        
+ <release>Magics++2.10</release>        
+</parameter>
+
+<parameter name='subpage_y_max_longitude' from='float' to='float'  member='max_lon' xml='max' default='180' >
+ <documentation>Set max Lon value</documentation>        
+         <release>Magics++2.10</release>         
+</parameter>
+  
+
+</class>
+
+</magics>
diff --git a/src/xml/XmlBox.xml b/src/xml/XmlBox.xml
new file mode 100644
index 0000000..f7a9c29
--- /dev/null
+++ b/src/xml/XmlBox.xml
@@ -0,0 +1,57 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='XmlBox' directory='visualisers'>
+  <parameter name='box_left' from='string' to='string'
+             member='left' xml='left' default='5%'>
+         <release>Magics++0.8</release>
+         <documentation> Left Position of Box </documentation>
+         <migration>Only avalaible in MagML  </migration>
+  </parameter>
+
+  <parameter name='box_bottom' from='string' to='string'
+             member='bottom' xml='bottom' default='80%' >
+         <release>Magics++0.8</release>
+         <documentation> Botton Position of Box </documentation>
+         <migration> Only avalaible in MagML  </migration>
+  </parameter>
+
+  <parameter name='box_width' from='string' to='string'
+             member='width' xml='width' default='85%'>
+         <release>Magics++0.8</release>
+         <documentation> Length of text box in X direction </documentation>
+         <migration> Only avalaible in MagML  </migration>
+  </parameter>
+
+  <parameter name='box_height' from='string' to='string'
+             member='height' xml='height' default='10%'>
+         <release>Magics++0.1</release>
+         <documentation> Length of text box in Y direction </documentation>
+         <migration> Only avalaible in MagML  </migration>
+  </parameter>
+
+  <parameter name='blanking' from='string' to='bool'
+             member='blanking' default='off'>
+         <release>Magics++0.1</release>
+          <release_info>Paremeter defined but not implemeted : expected for Magics++0.6</release_info>
+         <documentation> All plotting in the text box previous to PTEXT call will be blanked out. Plotting after PTEXT call will not be affected. (ON/OFF) </documentation>
+         <migration> New Magics: Parameter text_box_blanking sent to new Magics[TextBox].  </migration>
+  </parameter>
+
+  <parameter name='frame' from='string' to='FrameBase'
+             member='frame' default='off'>
+         <release>Magics++0.5</release>    
+         <documentation> Plot border around text box (ON/OFF) </documentation>
+         <option name='Frame'   fortran='on'  xml='frame' include='Frame.h' />
+         	<option name='NoFrame' fortran='off' xml='noframe' include='Frame.h'/>
+         <migration> New Magics: Parameter text_border sent to new Magics[TextBox].  </migration>
+  </parameter>
+  
+  
+  
+  
+</class>
+
+<static name='box' class='TextBox' include_class='yes'/>
+
+
+</magics>
diff --git a/src/xml/XmlPage.xml b/src/xml/XmlPage.xml
new file mode 100644
index 0000000..e71ffd2
--- /dev/null
+++ b/src/xml/XmlPage.xml
@@ -0,0 +1,39 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+
+<class name='XmlPage' embedded_objects='Frame' directory='common'>
+
+  	<parameter name='format' from='string' to='string'
+                   member='format' xml='format' default='a4'>
+		<documentation> format of the page </documentation>
+  		<migration>  Only used in the MagML Interface  </migration>
+    		<release>Magics++0.7</release>
+	</parameter>
+
+	<parameter name='orientation' from='string' to='string'
+                   member='orientation' xml='orientation' default='landscape'>
+         	<documentation>  orientation of the page </documentation>
+           	<migration> Only used in the MagML Interface </migration>
+		<release>Magics++0.7</release>
+	</parameter>
+
+	<!--parameter name='frame' from='string' to='FrameBase' member='frame' default='off'>
+                <documentation> Plot frame around super page (ON/OFF) </documentation>
+         	<option name='Frame'   fortran='on'  xml='frame' include='Frame.h' />
+         	<option name='NoFrame' fortran='off' xml='noframe' include='Frame.h'/>
+         	<migration>  Only used in the MagML Interface  </migration>
+		<release>Magics++0.7</release>
+	</parameter-->
+	<parameter name='meta' from='string' to='MetaData'
+             member='meta' default='nometadata'>
+           <release>Magics++0.7</release>         
+         <documentation> Write metadata in xml format </documentation>
+         <option name='MetaData' xml='metadata' include='MetaData.h'/>
+         <option name='NoMetaData' xml='nometadata' include='MetaData.h'/>
+         <migration>  Only used in the MagML Interface  </migration>
+  </parameter>
+  
+</class>
+
+</magics>
diff --git a/src/xml/XmlSubPage.xml b/src/xml/XmlSubPage.xml
new file mode 100644
index 0000000..999de3d
--- /dev/null
+++ b/src/xml/XmlSubPage.xml
@@ -0,0 +1,46 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+
+<class name='XmlSubPage' embedded_objects='FrameBase/PageIdBase/LegendBase/TitleBase' directory='common'>
+
+  <parameter name='bottom' from='string' to='string'
+             member='bottom' xml='bottom' default='0%'>
+	<documentation> Y-Coordinate of bottom of page.</documentation>
+	<migration> Only used in the MagML Interface </migration>
+	<release>Magics++0.8</release>
+  </parameter>
+  
+  <parameter name='left' from='string' to='string'
+             member='left' xml='left' default='0%'>
+	<documentation> X-Coordinate of bottom of page.</documentation>
+	<migration> Only used in the MagML Interface </migration>
+	<release>Magics++0.8</release>
+  </parameter>
+  
+   <parameter name='width' from='string' to='string'
+             member='width' xml='width' default='100%'>
+	<documentation> width of page.</documentation>
+	<migration> Only used in the MagML Interface </migration>
+	<release>Magics++0.8</release>
+  </parameter>
+  
+  <parameter name='height' from='string' to='string'
+             member='height' xml='height' default='100%' >
+	<documentation> Height of page.</documentation>
+	<migration> Only used in the MagML Interface </migration>
+	<release>Magics++0.1</release>
+  </parameter>
+
+ 
+  
+  
+	
+  
+
+  
+  
+</class>
+
+
+
+</magics>
diff --git a/src/xml/graph_params.xml b/src/xml/graph_params.xml
new file mode 100644
index 0000000..209b8b4
--- /dev/null
+++ b/src/xml/graph_params.xml
@@ -0,0 +1,233 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='GraphPlotting' xmltag='graph' directory='visualisers'>
+  <documentation>
+    This action routine (and C++object) controls the plotting of curves, bar charts and area charts.
+  </documentation>
+ <parameter name='legend' from='string' to='bool' member='legend' xml='legend'  default='on' >
+         <documentation>  Turn on/off the legend for this graph (this parameter is new to Magics++) </documentation>
+         <release>1.3</release>
+         <set value='on' name='legend_user_text'/>
+    </parameter>
+
+  <parameter name='legend_user_text' from='string' to='string' member='legend_text' xml='legend_text'  default=''>
+         <documentation> User-defined text for the legend of this graph </documentation>
+  </parameter>
+
+  <parameter name='graph_type' from='string' to='Graph' member='type' xml='type' default='curve'>
+         <documentation> Defines the type of curve required  </documentation>
+         <migration> New Magics: Parameter graph_type sent to new Magics[Graph].  </migration>
+         <option name='Curve'   fortran='curve'  xml='curve' include='Curve.h' />      
+         <option name='Bar' fortran='bar' xml='bar'  include='Bar.h'/>
+         <option name='GraphFlag' fortran='flag' xml='flag'  include='Bar.h'/>
+         <option name='GraphArrow' fortran='arrow' xml='arrow'  include='Bar.h' />
+         <option name='CurveArea' fortran='area' xml='area'  include='Curve.h'/>
+  </parameter>
+</class>
+
+
+<class name='Graph' directory='visualisers'>
+</class>
+
+
+<class name='CurveArea' directory='visualisers' inherits='Curve' include='Curve.h'>
+ 	<parameter name='graph_shade' from='string' to='GraphShade'  member='shade' default='on'>
+         <option name='GraphShade'   fortran='on'  xml='shading' include='GraphShade.h' />
+         <option name='NoGraphShade'   fortran='off'  xml='noshading' include='GraphShade.h' />
+         <documentation>Turn the shading on </documentation>
+   </parameter>
+</class>
+<class name='NoGraphShade' directory='visualisers' inherits='GraphShade' include='GraphShade.h'/>
+
+
+<class name='Curve' directory='visualisers' inherits='Graph' >
+  <documentation> Here comes the documentation of the Curve object </documentation>
+
+  <parameter name='graph_line' from='string' to='bool' member='line' xml='line' default='on'>
+         <documentation> Plot the curve line  </documentation>
+         <set value='on' name='graph_line_style'/>
+         <set value='on' name='graph_line_colour'/>
+         <set value='on' name='graph_line_thickness'/>
+  </parameter>
+
+  <parameter name='graph_line_style' from='string' to='LineStyle' member='style' xml='line_style' default='solid'>
+         <documentation> Line style of the curve </documentation>
+  </parameter>
+
+  <parameter name='graph_line_colour' from='string' to='Colour' member='colour' xml='line_colour' default='blue'>
+         <documentation> Colour of the curve</documentation>
+  </parameter>
+
+  <parameter name='graph_line_thickness' from='int' to='int' member='thickness' xml='line_thickness' default='1'>
+         <documentation> Thickness of the curve  </documentation>
+  </parameter>
+
+  <parameter name='graph_symbol' from='string' to='bool' member='symbol' default='off'>
+         <documentation> If symbols are to be drawn on the curves  </documentation>
+         <set value='on' name='graph_symbol_marker_index'/>
+         <set value='on' name='graph_symbol_height'/>
+         <set value='on' name='graph_symbol_colour'/>
+  </parameter>
+  
+  <parameter name='graph_symbol_marker_index' from='int' to='int' member='symbol_marker' xml='marker' default='3'>
+         <documentation> The marker symbol to be used. </documentation>
+  </parameter>
+ 
+
+  <parameter name='graph_symbol_height' from='float' to='float' member='symbol_height' xml='height' default='0.2' >
+         <documentation> Height of  symbol </documentation>
+  </parameter>
+
+  <parameter name='graph_symbol_colour' from='string' to='Colour' member='symbol_colour' default='red'>
+         <documentation> Colour of graph symbol </documentation>
+  </parameter>
+  
+ <parameter name='graph_x_suppress_below' from='float' to='float' member='x_below'  default='-INT_MAX'>
+         <documentation> Value on the x  below which a point is considered missing </documentation>
+  </parameter>
+   <parameter name='graph_x_suppress_above' from='float' to='float' member='x_above' default='INT_MAX'>
+         <documentation> Value on the x  above which a point is considered missing </documentation>
+  </parameter>
+
+  <parameter name='graph_y_suppress_below' from='float' to='float'   member='y_below' default='-INT_MAX'>
+         <documentation> Value on the y  below which a point is considered missing </documentation>
+  </parameter>
+
+  <parameter name='graph_y_suppress_above' from='float' to='float' member='y_above'  default='INT_MAX'>
+         <documentation> Value on the y  above which a point is considered missing </documentation>
+  </parameter>
+
+  
+  <parameter name='graph_missing_data_mode' from='string' to='string' member='missing_mode' default='ignore' values='ignore/join/drop'> 
+   <documentation> How to handle missing data  </documentation>
+   <set value='join' name='graph_missing_data_style'/>
+   <set value='join' name='graph_missing_data_colour'/>
+   <set value='join' name='graph_missing_data_thickness'/>
+    <set value='drop' name='graph_missing_data_style'/>
+   <set value='drop' name='graph_missing_data_colour'/>
+   <set value='drop' name='graph_missing_data_thickness'/>
+ </parameter>
+  <parameter name='graph_missing_data_style' from='string' to='LineStyle' member='missing_style' xml='style' default='dash'>
+         <documentation> Line style of the missing data part of curve  </documentation>
+  </parameter>
+
+  <parameter name='graph_missing_data_colour' from='string' to='Colour' member='missing_colour' xml='colour' default='red' >
+         <documentation> Colour of the missing data part of curve </documentation>
+  </parameter>
+
+  <parameter name='graph_missing_data_thickness' from='int' to='int' member='missing_thickness' xml='thickness' default='1'>
+         <documentation> Thickness of the missing data part of curve  </documentation>
+  </parameter>
+</class>
+
+
+
+
+<class name='GraphFlag' directory='visualisers' inherits='Graph'  xmltag='flag' include='Bar.h' >
+  <parameter name='graph_flag_colour' from='string' to='Colour' member='colour' default='black'>
+         <documentation> The colour of the Flags!</documentation>
+  </parameter>
+  <parameter name='graph_flag_length' from='float' to='float' member='length'  default='0.75'>
+         <documentation> Physical length of wind flag shaft </documentation>
+  </parameter>
+</class>
+
+
+<class name='GraphArrow' directory='visualisers' inherits='Graph'  xmltag='arrow' include='Bar.h' >
+   <parameter name='graph_arrow_colour' from='string' to='Colour' member='colour'  default='black'>
+         <documentation> The colour of the arrows</documentation>
+  </parameter>
+  <parameter name='graph_arrow_unit_velocity' from='float' to='float' member='unit_velocity'  default='25.0'>
+        <documentation>Wind speed in m/s represented by a unit vector (1.0 cm).</documentation>
+  </parameter>
+</class>
+
+
+<class name='Bar' directory='visualisers' inherits='Graph'  xmltag='bar'  >
+  <parameter name='graph_bar_width' from='float' to='float' member='width' xml='width' default='INT_MAX' >
+         <documentation> The width of a bar in a bar chart </documentation>
+  </parameter>
+  <parameter name='graph_bar_justification' from='string' to='Justification' member='justification'  default='centre'>
+         <documentation> the bar will be centered on the value, or left, right justify : useful for plotting any accumulated fields</documentation>
+  </parameter>
+  <parameter name='graph_bar_style' from='string' to='string' member='bar_style'  value='bar/linebar' default='bar'>
+         <documentation> If candlestick, a line will be drawn at the position with 2 small perpendicular lines at top and bottom  </documentation>
+  </parameter>
+  
+
+  <parameter name='graph_bar_line_style' from='string' to='LineStyle' member='style' xml='line_style' default='solid'>
+         <documentation> Line Style of the Bar Border </documentation>
+  </parameter>
+
+  <parameter name='graph_bar_line_thickness' from='int' to='int' member='thickness' xml='line_thickness' default='1' >
+         <documentation> Thickness of the Bar Border </documentation>
+  </parameter>
+  
+  <parameter name='graph_bar_line_colour' from='string' to='Colour' member='line_colour' xml='line_colour' default='black'>
+         <documentation> The colour of the  the Bar Border</documentation>
+  </parameter>
+
+  <parameter name='graph_bar_colour' from='string' to='Colour' member='colour' xml='colour' default='blue'>
+         <documentation> The colour of the interiors of bars </documentation>
+  </parameter>
+
+  <parameter name='graph_bar_clipping' from='string' to='bool' member='clipping' xml='clipping'  default='on'>
+         <documentation> whether or not to clip the bar if they go outside the view area. </documentation>
+  </parameter>
+	<parameter name='graph_shade' from='string' to='GraphShade'  member='shade' default='on'>
+         <option name='GraphShade'   fortran='on'  xml='shading' include='GraphShade.h' />
+         <option name='NoGraphShade'   fortran='off'  xml='noshading' include='GraphShade.h' />
+         <documentation>Turn the shading on </documentation>
+   </parameter>
+  <parameter name='graph_bar_annotation' from='stringarray' to='stringarray' member='annotation' default='stringarray()'>
+         <documentation> add annotation on the top box : List of strings to use </documentation>
+  </parameter>
+
+  <parameter name='graph_bar_annotation_font_size' from='float' to='float' member='annotation_size' default='0.25'>
+         <documentation> Font size for annotation </documentation>
+  </parameter>
+
+  <parameter name='graph_bar_annotation_font_colour' from='string' to='Colour' member='annotation_colour' default='red'>
+         <documentation> Font size for annotation </documentation>
+  </parameter>
+  <parameter name='graph_bar_minimum_value' from='float' to='float' member='min_value' default='INT_MAX' >
+         <documentation> If set, defines the bottom of the bar </documentation>
+  </parameter>
+</class>
+
+
+<class name='GraphShade'  directory='visualisers'>
+ <parameter name='graph_shade_style' from='string' to='GraphShadeStyle' member='style' default='area_fill'>
+         <!--option name='GraphShadeStyle' fortran='solid' xml='areafill' include='GraphShadeStyle.h'/-->
+         <option name='GraphShadeStyle' fortran='area_fill'  xml='solid' include='GraphShadeStyle.h'/>
+         <option name='HatchGraphShadeStyle' fortran='hatch' xml='hatch' include='GraphShadeStyle.h'/>
+         <option name='DotGraphShadeStyle' fortran='dot' xml='dot' include='GraphShadeStyle.h'/>
+         <documentation>  Style of shading </documentation>
+  </parameter>
+</class>
+
+
+<class name='GraphShadeStyle'  directory='visualisers'>
+  <parameter name='graph_shade_colour' from='string' to='Colour' member='colour' xml='colour' default='blue' >
+         <documentation> The colour of the shaded part of bars </documentation>
+  </parameter>
+</class>
+
+
+<class name='DotGraphShadeStyle'  directory='visualisers' inherits='GraphShadeStyle' include='GraphShadeStyle.h'>
+   <parameter name='graph_shade_density' from='int' to='int' member='density' xml='dot_density' default='20' implemented='no'>
+         <documentation> Density per square cm. of shading dots </documentation>
+  </parameter>
+
+  <parameter name='graph_shade_dot_size' from='float' to='float' member='size' xml='dot_size' default='0.02' >
+         <documentation> Size of shading dots  </documentation>
+  </parameter>
+</class>
+
+
+<class name='HatchGraphShadeStyle'  directory='visualisers'  inherits='GraphShadeStyle' include='GraphShadeStyle.h'>
+  <parameter name='graph_shade_hatch_index' from='int' to='int' member='index' xml='hatch_index' default='0'>
+         <documentation>Hatch index number</documentation>
+  </parameter>
+</class>
+</magics>
diff --git a/src/xml/magml.xml b/src/xml/magml.xml
new file mode 100644
index 0000000..c2b2319
--- /dev/null
+++ b/src/xml/magml.xml
@@ -0,0 +1,114 @@
+<!--
+
+    Meanings of 'occurence' attributes:
+      1:  exactly 2 allowed
+      1+: one or more allowed
+      0+: zero or more allowed
+      01: zero or one allowed
+
+-->
+
+
+<magml1>
+  <element name='magics' occurrence='1'> 
+    <element name='page' occurrence='1+' object='XmlPage' chapter='layout_mapping_coastlines'>  
+      <element name='subpage' occurrence='1+' object='XmlSubPage' chapter='layout_mapping_coastlines'>
+        <element name='coastlines' occurrence='0+' object='Coastlines' chapter='layout_mapping_coastlines'/>
+        <element name='layer or xylayer' occurrence='0+' object='VisualTask'>
+          <choice name='decoder' occurrence='1'> 
+            <element name='grib'   object='GribDecoder'   chapter='data'/>
+            <element name='netcdf' object='NetcdfDecoder' chapter='data'/>
+            <!--<element name='odb'    object='OdbDecoder'    chapter='data'/>-->
+            <element name='bufr'   object='ObsDecoder'    chapter='data'/>
+            <element name='import' object='ImportAction'  chapter='data'/>
+          </choice>
+          <choice name='visualisation' occurrence='1+'>
+            <element name='geocontour' object='Contour'        chapter='contour'/>
+            <element name='symbol'     object='SymbolPlotting'/>
+            <element name='wind'       object='Wind'/>
+            <element name='obs'        object='ObsPlotting'/>
+            <element name='image'      object='ImagePlotting'/>
+            <element name='graph'      object='GraphPlotting'/>
+            <element name='plot'       object='ImportPlot'/>
+            <element name='text'       object='TextAction'/>
+            <element name='legend'     object='Legend'/>
+            <element name='horizontal_axis' object='XYTransformation'/>
+            <element name='vertical_axis'   object='XYTransformation'/>
+          </choice>
+        </element>
+      </element>
+    </element>
+  </element>
+</magml1>
+
+
+<magml2>
+  <element name='magics' occurrence='1'> 
+    <element name='drivers' occurrence='1' chapter='drivers'>  
+      <element name='ps'            occurrence='01'  object='PostScriptDriver' chapter='drivers'/>  
+      <element name='svg'           occurrence='01'  object='SVGDriver'        chapter='drivers'/>  
+      <element name='kml'           occurrence='01'  object='KMLDriver'        chapter='drivers'/> 
+      <element name='pdf'           occurrence='01'  object='CairoDriver'      chapter='drivers'  linkid='Cairo_Driver'/>  
+      <element name='png'           occurrence='01'  object='CairoDriver'      chapter='drivers'  linkid='Cairo_Driver'/>  
+      <element name='gif'           occurrence='01'  object='GDDriver'         chapter='drivers'  linkid='GD_Driver' />  
+      <element name='gif_animation' occurrence='01'  object='GDDriver'         chapter='drivers'  linkid='GD_Driver' />  
+      <!-- <element name='cairo' occurrence='0+'  object='KMLDriver'        chapter='drivers'/> -->
+    </element>
+
+    <element name='page' occurrence='1+' object='XmlSceneNode' chapter='layout_mapping_coastlines'>  
+      <element name='gribloop' occurrence='0+' object='GribLoop' chapter='data' linkid='GRIBloop_input_magml_all_tables'>
+        <element name='map' occurrence='1+' object='XmlViewNode' chapter='layout_mapping_coastlines'>
+          <choice name='background' occurrence='1+'> 
+            <element name='coastlines' occurrence='0+' object='Coastlines' chapter='layout_mapping_coastlines'/>
+            <element name='taylor_grid' occurrence='0+' object='TaylorGrid' chapter='layout_mapping_coastlines'/>
+            <element name='horizontal_axis' object='Axis' chapter='axis'/>
+            <element name='vertical_axis'   object='Axis' chapter='axis'/>
+          </choice>
+          <element name='plot' occurrence='0+' object=''>
+            <choice name='decoder' occurrence='1'> 
+              <element name='grib'           object='GribDecoder'         chapter='data'/>
+              <element name='netcdf'         object='NetcdfDecoder'       chapter='data'/>
+              <!--<element name='odb'    object='OdbDecoder'    chapter='data'/>-->
+              <!--<element name='bufr'   object='ObsDecoder'    chapter='data'/>-->
+              <element name='polyline_input' object='SimplePolylineInput' chapter='polyline'/>
+            </choice>
+            <choice name='visualisation' occurrence='1+'>
+              <element name='contour'  object='Contour'            chapter='contour'/>
+              <element name='text'     object='TextVisitor'        chapter='text'/>
+              <element name='legend'   object='LegendVisitor'      chapter='legend'/>
+              <element name='polyline' object='SimplePolyline'     chapter='polyline'/>   
+              <element name='wind'     object='Wind'/>            
+              <element name='symbol'   object='SymbolPlotting'     chapter='symbol'/>            
+              <!--<element name='boxplot'  object='BoxPlotVisualiser'  chapter='boxplot'/>-->    
+            </choice>
+          </element>
+        </element>
+      </element>
+    </element>
+  </element>
+</magml2>
+
+
+<justcontour>
+  <element name='magics' occurrence='1'> 
+
+    <element name='page' occurrence='1+' object='XmlSceneNode' chapter='layout_mapping_coastlines'>  
+      <element name='map' occurrence='1+' object='XmlViewNode' chapter='layout_mapping_coastlines'>
+        <element name='layer' occurrence='0+' object=''>
+          <choice name='visualisation' occurrence='1+'>
+            <element name='contour'  object='Contour'            chapter='contour'/>
+          </choice>
+        </element>
+      </element>
+    </element>
+  </element>
+</justcontour>
+
+
+
+<epsml>
+  <element name='eps' occurrence='1'> 
+    <element name='station'    occurrence='1+' object='XmlPage' chapter='layout_mapping_coastlines'>  
+    </element>
+  </element>
+</epsml>
diff --git a/src/xml/output.xml b/src/xml/output.xml
new file mode 100644
index 0000000..0835592
--- /dev/null
+++ b/src/xml/output.xml
@@ -0,0 +1,16 @@
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<magics>
+<class name='OutputHandler' xmltag='output' action ='popen' directory='common'>    
+
+   <parameter name='output_format' from='string' to='string' member='format' xml='format' default='ps' >
+         <documentation>Defines the device to be used (ps/gif/svg).</documentation>
+	 <release>1.2</release>
+   </parameter>
+
+   <parameter name='output_formats' from='stringarray' to='stringarray' member='formats' xml='formats' default='stringarray()'>
+         <documentation>Defines the list of devices to be used (ps/gif/svg).</documentation>
+         <release>1.2</release>        
+   </parameter>  
+
+</class>
+</magics>
diff --git a/test/C/Makefile.am b/test/C/Makefile.am
new file mode 100755
index 0000000..d425621
--- /dev/null
+++ b/test/C/Makefile.am
@@ -0,0 +1,25 @@
+AUTOMAKE_OPTIONS     = foreign
+
+if MAGICS_CAIRO
+check_PROGRAMS       = contours land_sea_shade large_area drivers cairo
+else
+check_PROGRAMS       = contours land_sea_shade large_area
+endif
+
+TESTS_ENVIRONMENT    = MAGPLUS_HOME=$(top_srcdir)
+TESTS                = $(check_PROGRAMS)
+
+if MAGICS_BUFR
+FORTRAN_LIBS         = $(FLIBS)
+endif
+
+MAGPLUS              = -L$(top_srcdir)/src -L$(top_srcdir)/src/.libs -lMagPlus
+
+AM_CPPFLAGS          = -I$(top_srcdir)/src/common
+LDADD                = $(MAGPLUS) ${MAGICS_3RDPARTY_LIBS} ${FORTRAN_LIBS} ${CPPLIBS}
+
+drivers_SOURCES         = drivers.c
+contours_SOURCES        = contours.c
+land_sea_shade_SOURCES  = land_sea_shade.c
+large_area_SOURCES      = large_area.c
+cairo_SOURCES           = cairo.c
diff --git a/test/C/Makefile.in b/test/C/Makefile.in
new file mode 100644
index 0000000..2495de8
--- /dev/null
+++ b/test/C/Makefile.in
@@ -0,0 +1,722 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ at MAGICS_CAIRO_FALSE@check_PROGRAMS = contours$(EXEEXT) \
+ at MAGICS_CAIRO_FALSE@	land_sea_shade$(EXEEXT) \
+ at MAGICS_CAIRO_FALSE@	large_area$(EXEEXT)
+ at MAGICS_CAIRO_TRUE@check_PROGRAMS = contours$(EXEEXT) \
+ at MAGICS_CAIRO_TRUE@	land_sea_shade$(EXEEXT) large_area$(EXEEXT) \
+ at MAGICS_CAIRO_TRUE@	drivers$(EXEEXT) cairo$(EXEEXT)
+subdir = test/C
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am_cairo_OBJECTS = cairo.$(OBJEXT)
+cairo_OBJECTS = $(am_cairo_OBJECTS)
+cairo_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+ at MAGICS_BUFR_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
+cairo_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am_contours_OBJECTS = contours.$(OBJEXT)
+contours_OBJECTS = $(am_contours_OBJECTS)
+contours_LDADD = $(LDADD)
+contours_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
+am_drivers_OBJECTS = drivers.$(OBJEXT)
+drivers_OBJECTS = $(am_drivers_OBJECTS)
+drivers_LDADD = $(LDADD)
+drivers_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
+am_land_sea_shade_OBJECTS = land_sea_shade.$(OBJEXT)
+land_sea_shade_OBJECTS = $(am_land_sea_shade_OBJECTS)
+land_sea_shade_LDADD = $(LDADD)
+land_sea_shade_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
+	$(am__DEPENDENCIES_1)
+am_large_area_OBJECTS = large_area.$(OBJEXT)
+large_area_OBJECTS = $(am_large_area_OBJECTS)
+large_area_LDADD = $(LDADD)
+large_area_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC    " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD  " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(cairo_SOURCES) $(contours_SOURCES) $(drivers_SOURCES) \
+	$(land_sea_shade_SOURCES) $(large_area_SOURCES)
+DIST_SOURCES = $(cairo_SOURCES) $(contours_SOURCES) $(drivers_SOURCES) \
+	$(land_sea_shade_SOURCES) $(large_area_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+TESTS_ENVIRONMENT = MAGPLUS_HOME=$(top_srcdir)
+TESTS = $(check_PROGRAMS)
+ at MAGICS_BUFR_TRUE@FORTRAN_LIBS = $(FLIBS)
+MAGPLUS = -L$(top_srcdir)/src -L$(top_srcdir)/src/.libs -lMagPlus
+AM_CPPFLAGS = -I$(top_srcdir)/src/common
+LDADD = $(MAGPLUS) ${MAGICS_3RDPARTY_LIBS} ${FORTRAN_LIBS} ${CPPLIBS}
+drivers_SOURCES = drivers.c
+contours_SOURCES = contours.c
+land_sea_shade_SOURCES = land_sea_shade.c
+large_area_SOURCES = large_area.c
+cairo_SOURCES = cairo.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/C/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign test/C/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+cairo$(EXEEXT): $(cairo_OBJECTS) $(cairo_DEPENDENCIES) 
+	@rm -f cairo$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(cairo_OBJECTS) $(cairo_LDADD) $(LIBS)
+contours$(EXEEXT): $(contours_OBJECTS) $(contours_DEPENDENCIES) 
+	@rm -f contours$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(contours_OBJECTS) $(contours_LDADD) $(LIBS)
+drivers$(EXEEXT): $(drivers_OBJECTS) $(drivers_DEPENDENCIES) 
+	@rm -f drivers$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(drivers_OBJECTS) $(drivers_LDADD) $(LIBS)
+land_sea_shade$(EXEEXT): $(land_sea_shade_OBJECTS) $(land_sea_shade_DEPENDENCIES) 
+	@rm -f land_sea_shade$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(land_sea_shade_OBJECTS) $(land_sea_shade_LDADD) $(LIBS)
+large_area$(EXEEXT): $(large_area_OBJECTS) $(large_area_DEPENDENCIES) 
+	@rm -f large_area$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(large_area_OBJECTS) $(large_area_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cairo.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/contours.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/drivers.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/land_sea_shade.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/large_area.Po at am__quote@
+
+.c.o:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/test/C/cairo.c b/test/C/cairo.c
new file mode 100644
index 0000000..b9493b6
--- /dev/null
+++ b/test/C/cairo.c
@@ -0,0 +1,52 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include "magics_api.h"
+#include <cairo.h>
+
+int main(int argc, char **argv)
+{
+        /* First setup your cairo context */
+        cairo_surface_t *surface;
+        cairo_t* cr;
+
+        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 800, 500);
+        cr = cairo_create (surface);
+        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
+
+        /* Then call Magics++ */
+        mag_open();
+        mag_setp("output_cairo_drawing_context", cr);
+        mag_setc ("output_format","cairo");
+        mag_coast();
+        mag_close();
+
+        /* Then continue with cairo ... */
+        cairo_destroy (cr);
+        cr = cairo_create (surface);
+        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
+        cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+        cairo_set_font_size (cr, 32.0);
+
+        cairo_move_to (cr, 80., 100.0);
+        cairo_show_text (cr, "Hello, this is CAIRO calling Magics++");
+
+        cairo_destroy (cr);
+        cairo_surface_write_to_png (surface, "cairo.png");
+        cairo_surface_destroy (surface);
+}
diff --git a/test/C/contours.c b/test/C/contours.c
new file mode 100644
index 0000000..c43b90e
--- /dev/null
+++ b/test/C/contours.c
@@ -0,0 +1,68 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include <magics_api.h>
+
+int main()
+{
+	/* open magics and set the output device */
+	mag_open();
+	mag_setc("output_format", "ps");
+	mag_setc("output_name", "contour_test");
+
+	/* load the data */
+
+	mag_setc ("grib_input_file_name", "../data/z500.grb");
+	mag_grib ();
+
+ 
+	/* set up the coastline attributes */
+
+	mag_setc ("map_coastline_colour",    "khaki");
+	mag_setc ("map_grid_colour",	     "grey");     
+
+
+	/* define the contouring parameters */
+
+	mag_setc ("contour_line_colour",      "sky");
+	mag_setc ("contour_highlight_colour", "green");
+	mag_cont ();
+
+
+	/* plot the title text and the coastlines */
+
+	mag_text  ();
+	mag_coast ();
+
+
+	/* Start a new page - we will plot a smaller area */
+
+	mag_new ("super_page");
+
+	mag_setr ("SUBPAGE_LOWER_LEFT_LATITUDE",    30.0);
+	mag_setr ("SUBPAGE_LOWER_LEFT_LONGITUDE",  -30.0);
+	mag_setr ("SUBPAGE_UPPER_RIGHT_LATITUDE",   68.0);
+	mag_setr ("SUBPAGE_UPPER_RIGHT_LONGITUDE",  70.0);
+
+	mag_text  ();
+	mag_coast ();
+	mag_cont  ();
+
+	mag_close ();
+	return 0;
+}
diff --git a/test/C/drivers.c b/test/C/drivers.c
new file mode 100644
index 0000000..fff73bb
--- /dev/null
+++ b/test/C/drivers.c
@@ -0,0 +1,40 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+/* \file drivers.c
+
+   \brief test if the different output drivers work in C
+*/
+
+#include <magics_api.h>
+
+int main()
+{
+	const char *formats[] = {"svg","kml","ps","pdf","png"};
+	const int num = 5;
+
+	/* open magics and set the output device */
+	mag_open();
+	mag_set1c("output_formats", formats, num);
+	mag_setc("output_name", "driver_test");
+	mag_coast();
+
+	mag_close();
+
+	return 0;
+}
diff --git a/test/C/land_sea_shade.c b/test/C/land_sea_shade.c
new file mode 100644
index 0000000..1569abf
--- /dev/null
+++ b/test/C/land_sea_shade.c
@@ -0,0 +1,72 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include <magics_api.h>
+
+int main()
+{
+	/* open magics and set the output filename */
+	mag_open ();
+	mag_setc ("output_name", "land_sea_shade");
+
+
+	/* Set up the coastline attributes */
+	mag_setc ("map_coastline", 	  "on");
+	mag_setc ("map_coastline_colour", "grey");
+	mag_setc ("map_grid_colour",	  "grey");
+
+	/* First page: land and sea shading together: */
+	mag_setc  ("text_line_1", "LAND and SEA shading");
+	mag_setc  ("map_coastline_land_shade",        "on");
+	mag_setc  ("map_coastline_land_shade_colour", "cream");
+	mag_setc  ("map_coastline_sea_shade",         "on");
+	mag_setc  ("map_coastline_sea_shade_colour",  "blue");
+	mag_coast ();
+	mag_text  ();
+
+	/* Second page: land shading only: */
+	mag_new   ("super_page");
+	mag_setc  ("text_line_1", "LAND shading only");
+	mag_setc  ("map_coastline_land_shade", "on");
+	mag_setc  ("map_coastline_sea_shade",  "off");
+	mag_coast ();
+	mag_text  ();
+
+	/* Third page: sea shading only: */
+	mag_new   ("super_page");
+	mag_setc  ("text_line_1", "SEA shading only");
+	mag_setc  ("map_coastline_land_shade",  "off");
+	mag_setc  ("map_coastline_sea_shade",   "on");
+	mag_coast ();
+	mag_text  ();
+
+	/* Fourth page:  land and sea shading together, zoom in: */
+	mag_new   ("super_page");
+	mag_setc  ("text_line_1", "LAND and SEA shading");
+	mag_setr  ("subpage_lower_left_latitude",	   30.0);
+	mag_setr  ("subpage_lower_left_longitude",    -30.0);
+	mag_setr  ("subpage_upper_right_latitude",     68.0);
+	mag_setr  ("subpage_upper_right_longitude",    70.0);
+	mag_setc  ("map_coastline_land_shade",        "on");
+	mag_setc  ("map_coastline_sea_shade",         "on");
+	mag_coast ();
+	mag_text  ();
+
+	mag_close ();
+	return 0;
+}
diff --git a/test/C/large_area.c b/test/C/large_area.c
new file mode 100644
index 0000000..7eabd3b
--- /dev/null
+++ b/test/C/large_area.c
@@ -0,0 +1,61 @@
+/******************************** LICENSE ********************************
+
+ Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at 
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ******************************** LICENSE ********************************/
+
+#include <magics_api.h>
+
+/* This example demonstrates plotting an area with larger than
+360 degrees of longitude. The data and coastline are wrapped
+around seamlessly */
+
+int main()
+{
+	/* Open magics and set the output filename */
+	mag_open ();
+	mag_setc ("OUTPUT_NAME", "large_area");
+
+	/* Set our geographical area - larger than 360 degrees wide */
+	mag_setr ("SUBPAGE_LOWER_LEFT_LATITUDE",    -60.0);
+	mag_setr ("SUBPAGE_LOWER_LEFT_LONGITUDE",  -220.0);
+	mag_setr ("SUBPAGE_UPPER_RIGHT_LATITUDE",    60.0);
+	mag_setr ("SUBPAGE_UPPER_RIGHT_LONGITUDE",  320.0);
+
+	/* Pass the data to MAGICS */
+	mag_setc ("GRIB_INPUT_FILE_NAME", "../data/z500.grb");
+	mag_grib ();
+
+	/* Set up the coastline attributes */
+	mag_setc ("MAP_COASTLINE_COLOUR", "GREY");
+	mag_setc ("MAP_GRID_COLOUR",      "GREY");
+
+	/* Define the contour */
+	mag_setc ("CONTOUR_SHADE",            "ON");
+	mag_setc ("CONTOUR_SHADE_TECHNIQUE",  "POLYGON_SHADING");
+	mag_setc ("CONTOUR_SHADE_METHOD",     "AREA_FILL");
+	mag_setc ("CONTOUR_HILO",             "OFF");
+	mag_cont ();
+
+	/* Set up and plot the title text */
+	mag_setc ("TEXT_LINE_1",  "Area wider than 360 degrees");
+	mag_text ();
+
+	/* Plot the coastlines and then close */
+	mag_coast ();
+
+	mag_close ();
+	return 0;
+}
diff --git a/test/MagML/Makefile.am b/test/MagML/Makefile.am
new file mode 100644
index 0000000..76114ff
--- /dev/null
+++ b/test/MagML/Makefile.am
@@ -0,0 +1,7 @@
+AUTOMAKE_OPTIONS  = foreign
+M_COLOR_TESTS     = always
+
+TESTS_ENVIRONMENT = MAGPLUS_HOME=$(top_srcdir) $(top_builddir)/apps/MagMLInterpretor/magmlx
+TESTS             = drivers.magml
+
+EXTRA_DIST        = drivers.magml
diff --git a/test/MagML/Makefile.in b/test/MagML/Makefile.in
new file mode 100644
index 0000000..4a32abc
--- /dev/null
+++ b/test/MagML/Makefile.in
@@ -0,0 +1,539 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = test/MagML
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+M_COLOR_TESTS = always
+TESTS_ENVIRONMENT = MAGPLUS_HOME=$(top_srcdir) $(top_builddir)/apps/MagMLInterpretor/magmlx
+TESTS = drivers.magml
+EXTRA_DIST = drivers.magml
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/MagML/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign test/MagML/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-TESTS check-am clean clean-generic \
+	clean-libtool distclean distclean-generic distclean-libtool \
+	distdir dvi dvi-am html html-am info info-am install \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/test/MagML/drivers.magml b/test/MagML/drivers.magml
new file mode 100644
index 0000000..5b02646
--- /dev/null
+++ b/test/MagML/drivers.magml
@@ -0,0 +1,123 @@
+<!--
+ This file shows how various drivers can be used in MagML.
+-->
+<magics version="3.0" width='29.7' height='21'>
+
+<drivers>
+	<ps name="myname" filelist='on'
+		scale="0.97"/>
+	<kml name="mykml"  filelist='on'
+		title="Contours over Europe"
+		description="A simple KML example with Magics++"
+		author="The nice folk at ECMWF"
+		height='0'
+		latitude='49.'
+		longitude='12.'
+		transparency='80'
+		tilt='5.'
+		range='6500'
+		coastlines='ON' />
+<!--
+	<png name="mypng"  filelist='on'
+		output_cairo_transparent_background='on' />
+-->
+	<svg name="mysvg"  filelist='on'
+		title="Contours over Europe" 
+		desc="This plot shows a forecast from ECMWF"
+		meta="Grib contours" />
+<!--
+	<gif_animation name="myanimation"  filelist='on'
+		output_gif_delay="200" />
+	<gif name="mygif"  filelist='on'/>
+-->
+</drivers>
+
+<page format='a4' orientation='landscape'>
+   <map>
+      <text font='sansserif' colour='rgb(0.1,0.6,0.2)' bottom="90%" display="inline" >Z500 Contour Plot</text>
+<!--
+      <cylindrical>
+          <corners min_latitude='25' max_latitude='75' min_longitude='-30' max_longitude='77'/>
+      </cylindrical>
+-->
+      <cylindrical lower_left_longitude='-20' lower_left_latitude='25' upper_right_latitude='70' upper_right_longitude='50'/>
+
+      <plot>
+          <grib input_file_name='../data/z500.grb'/>
+          <contour>
+             <isoline style='solid' thickness='2' colour='blue'/>
+          </contour>
+      </plot>
+      <coastlines land_shade='off' sea_shade='off'/>
+   </map>
+</page>
+
+<page format='a4' orientation='landscape'>
+   <map>
+      <text font='sansserif' colour='rgb(0.1,0.6,0.2)' bottom="90%" display="inline" >Page2</text>
+
+      <cylindrical lower_left_longitude='-20' lower_left_latitude='25' upper_right_latitude='70' upper_right_longitude='50'/>
+
+           <plot>
+              <grib input_file_name='../data/z500.grb'/>
+              <contour>
+                 <isoline style='solid' thickness='1' colour='blue'>
+		   <shading>
+		     <polygon>
+                      <area_fill/>
+                     </polygon>
+		     <list colour_list='pink/red/red_orange/orange/yellow/yellow_green/green/evergreen/kelly_green/blue/navy/purple' />
+                   </shading>
+	        </isoline>
+	      </contour>
+	   </plot>
+       <coastlines land_shade='off' sea_shade='off'/>
+    </map>
+</page>
+
+<page format='a4' orientation='landscape'>
+   <map>
+      <text font='sansserif' colour='rgb(0.1,0.6,0.2)' bottom="90%" display="inline" >Page2</text>
+
+      <cylindrical lower_left_longitude='-20' lower_left_latitude='25' upper_right_latitude='70' upper_right_longitude='50'/>
+
+           <plot>
+              <grib input_file_name='../data/z500.grb'/>
+              <contour>
+                 <isoline style='solid' thickness='1' colour='blue'>
+		   <shading>
+		     <polygon>
+                      <hatch/>
+                     </polygon>
+		     <list colour_list='pink/red/red_orange/orange/yellow/yellow_green/green/evergreen/kelly_green/blue/navy/purple' />
+                   </shading>
+	        </isoline>
+	      </contour>
+	   </plot>
+       <coastlines land_shade='off' sea_shade='off'/>
+    </map>
+</page>
+
+<page format='a4' orientation='landscape'>
+   <map>
+      <text font='sansserif' colour='rgb(0.1,0.6,0.2)' bottom="90%" display="inline" >Page2</text>
+
+      <cylindrical lower_left_longitude='-20' lower_left_latitude='25' upper_right_latitude='70' upper_right_longitude='50'/>
+
+           <plot>
+              <grib input_file_name='../data/z500.grb'/>
+              <contour>
+                 <isoline style='solid' thickness='1' colour='blue'>
+		   <shading>
+		     <polygon>
+                      <dot/>
+                     </polygon>
+		     <list colour_list='pink/red/red_orange/orange/yellow/yellow_green/green/evergreen/kelly_green/blue/navy/purple' />
+                   </shading>
+	        </isoline>
+	      </contour>
+	   </plot>
+       <coastlines land_shade='off' sea_shade='off'/>
+    </map>
+</page>
+</magics>
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..28ceea3
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,18 @@
+AUTOMAKE_OPTIONS	= foreign
+
+if MAGICS_PYTHON
+python_subdir = python
+endif
+
+SUBDIRS		= C MagML fortran $(python_subdir) .
+
+#TESTS_ENVIRONMENT = python 
+#TESTS             = create_index.py
+
+EXTRA_DIST	= data/z500.grb \
+		data/uv500.grb \
+		data/t850_fc_12.grib \
+		data/z500_fc_12.grib \
+		data/t2m_fc12.grib \
+		data/cloudcover.grib \
+		data/wind30m_fc12.grib
diff --git a/test/Makefile.in b/test/Makefile.in
new file mode 100644
index 0000000..3d369f3
--- /dev/null
+++ b/test/Makefile.in
@@ -0,0 +1,654 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = test
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-dvi-recursive install-exec-recursive \
+	install-html-recursive install-info-recursive \
+	install-pdf-recursive install-ps-recursive install-recursive \
+	installcheck-recursive installdirs-recursive pdf-recursive \
+	ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = C MagML fortran python .
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+ at MAGICS_PYTHON_TRUE@python_subdir = python
+SUBDIRS = C MagML fortran $(python_subdir) .
+
+#TESTS_ENVIRONMENT = python 
+#TESTS             = create_index.py
+EXTRA_DIST = data/z500.grb \
+		data/uv500.grb \
+		data/t850_fc_12.grib \
+		data/z500_fc_12.grib \
+		data/t2m_fc12.grib \
+		data/cloudcover.grib \
+		data/wind30m_fc12.grib
+
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign test/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+	@fail= failcom='exit 1'; \
+	for f in x $$MAKEFLAGS; do \
+	  case $$f in \
+	    *=* | --[!k]*);; \
+	    *k*) failcom='fail=yes';; \
+	  esac; \
+	done; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d "$(distdir)/$$subdir" \
+	    || $(MKDIR_P) "$(distdir)/$$subdir" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+	install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+	all all-am check check-am clean clean-generic clean-libtool \
+	ctags ctags-recursive distclean distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/test/data/cloudcover.grib b/test/data/cloudcover.grib
new file mode 100644
index 0000000..afb9b5f
Binary files /dev/null and b/test/data/cloudcover.grib differ
diff --git a/test/data/t2m_fc12.grib b/test/data/t2m_fc12.grib
new file mode 100644
index 0000000..034af41
Binary files /dev/null and b/test/data/t2m_fc12.grib differ
diff --git a/test/data/t850_fc_12.grib b/test/data/t850_fc_12.grib
new file mode 100644
index 0000000..278f91a
Binary files /dev/null and b/test/data/t850_fc_12.grib differ
diff --git a/test/data/uv500.grb b/test/data/uv500.grb
new file mode 100644
index 0000000..82db217
Binary files /dev/null and b/test/data/uv500.grb differ
diff --git a/test/data/wind30m_fc12.grib b/test/data/wind30m_fc12.grib
new file mode 100644
index 0000000..272aa0a
Binary files /dev/null and b/test/data/wind30m_fc12.grib differ
diff --git a/test/data/z500.grb b/test/data/z500.grb
new file mode 100644
index 0000000..bbeaa88
Binary files /dev/null and b/test/data/z500.grb differ
diff --git a/test/data/z500_fc_12.grib b/test/data/z500_fc_12.grib
new file mode 100644
index 0000000..60db8ce
Binary files /dev/null and b/test/data/z500_fc_12.grib differ
diff --git a/test/fortran/Makefile.am b/test/fortran/Makefile.am
new file mode 100755
index 0000000..8bde245
--- /dev/null
+++ b/test/fortran/Makefile.am
@@ -0,0 +1,15 @@
+AUTOMAKE_OPTIONS    = foreign
+check_PROGRAMS      = boxplot coast_only wind shaded_isolines layout_test
+
+TESTS_ENVIRONMENT   = MAGPLUS_HOME=$(top_srcdir)
+TESTS               = $(check_PROGRAMS)
+
+magplus             = -L$(top_srcdir)/src -L$(top_srcdir)/src/.libs -lMagPlusSingle -lMagPlus 
+
+LDADD               = $(magplus) ${MAGICS_3RDPARTY_LIBS} $(CPPLIBS)
+
+boxplot_SOURCES          = boxplot.f
+coast_only_SOURCES       = coast_only.f
+shaded_isolines_SOURCES  = shaded_isolines.f
+wind_SOURCES             = wind.f
+layout_test_SOURCES      = layout_test.f
diff --git a/test/fortran/Makefile.in b/test/fortran/Makefile.in
new file mode 100644
index 0000000..15e0c4e
--- /dev/null
+++ b/test/fortran/Makefile.in
@@ -0,0 +1,690 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+check_PROGRAMS = boxplot$(EXEEXT) coast_only$(EXEEXT) wind$(EXEEXT) \
+	shaded_isolines$(EXEEXT) layout_test$(EXEEXT)
+subdir = test/fortran
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am_boxplot_OBJECTS = boxplot.$(OBJEXT)
+boxplot_OBJECTS = $(am_boxplot_OBJECTS)
+boxplot_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+boxplot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am_coast_only_OBJECTS = coast_only.$(OBJEXT)
+coast_only_OBJECTS = $(am_coast_only_OBJECTS)
+coast_only_LDADD = $(LDADD)
+coast_only_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am_layout_test_OBJECTS = layout_test.$(OBJEXT)
+layout_test_OBJECTS = $(am_layout_test_OBJECTS)
+layout_test_LDADD = $(LDADD)
+layout_test_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+am_shaded_isolines_OBJECTS = shaded_isolines.$(OBJEXT)
+shaded_isolines_OBJECTS = $(am_shaded_isolines_OBJECTS)
+shaded_isolines_LDADD = $(LDADD)
+shaded_isolines_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am_wind_OBJECTS = wind.$(OBJEXT)
+wind_OBJECTS = $(am_wind_OBJECTS)
+wind_LDADD = $(LDADD)
+wind_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)/src
+F77COMPILE = $(F77) $(AM_FFLAGS) $(FFLAGS)
+LTF77COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS)
+AM_V_F77 = $(am__v_F77_$(V))
+am__v_F77_ = $(am__v_F77_$(AM_DEFAULT_VERBOSITY))
+am__v_F77_0 = @echo "  F77   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+F77LD = $(F77)
+F77LINK = $(LIBTOOL) $(AM_V_lt) --tag=F77 $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(F77LD) $(AM_FFLAGS) $(FFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_F77LD = $(am__v_F77LD_$(V))
+am__v_F77LD_ = $(am__v_F77LD_$(AM_DEFAULT_VERBOSITY))
+am__v_F77LD_0 = @echo "  F77LD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+SOURCES = $(boxplot_SOURCES) $(coast_only_SOURCES) \
+	$(layout_test_SOURCES) $(shaded_isolines_SOURCES) \
+	$(wind_SOURCES)
+DIST_SOURCES = $(boxplot_SOURCES) $(coast_only_SOURCES) \
+	$(layout_test_SOURCES) $(shaded_isolines_SOURCES) \
+	$(wind_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+TESTS_ENVIRONMENT = MAGPLUS_HOME=$(top_srcdir)
+TESTS = $(check_PROGRAMS)
+magplus = -L$(top_srcdir)/src -L$(top_srcdir)/src/.libs -lMagPlusSingle -lMagPlus 
+LDADD = $(magplus) ${MAGICS_3RDPARTY_LIBS} $(CPPLIBS)
+boxplot_SOURCES = boxplot.f
+coast_only_SOURCES = coast_only.f
+shaded_isolines_SOURCES = shaded_isolines.f
+wind_SOURCES = wind.f
+layout_test_SOURCES = layout_test.f
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .f .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/fortran/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign test/fortran/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+boxplot$(EXEEXT): $(boxplot_OBJECTS) $(boxplot_DEPENDENCIES) 
+	@rm -f boxplot$(EXEEXT)
+	$(AM_V_F77LD)$(F77LINK) $(boxplot_OBJECTS) $(boxplot_LDADD) $(LIBS)
+coast_only$(EXEEXT): $(coast_only_OBJECTS) $(coast_only_DEPENDENCIES) 
+	@rm -f coast_only$(EXEEXT)
+	$(AM_V_F77LD)$(F77LINK) $(coast_only_OBJECTS) $(coast_only_LDADD) $(LIBS)
+layout_test$(EXEEXT): $(layout_test_OBJECTS) $(layout_test_DEPENDENCIES) 
+	@rm -f layout_test$(EXEEXT)
+	$(AM_V_F77LD)$(F77LINK) $(layout_test_OBJECTS) $(layout_test_LDADD) $(LIBS)
+shaded_isolines$(EXEEXT): $(shaded_isolines_OBJECTS) $(shaded_isolines_DEPENDENCIES) 
+	@rm -f shaded_isolines$(EXEEXT)
+	$(AM_V_F77LD)$(F77LINK) $(shaded_isolines_OBJECTS) $(shaded_isolines_LDADD) $(LIBS)
+wind$(EXEEXT): $(wind_OBJECTS) $(wind_DEPENDENCIES) 
+	@rm -f wind$(EXEEXT)
+	$(AM_V_F77LD)$(F77LINK) $(wind_OBJECTS) $(wind_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+.f.o:
+	$(AM_V_F77) @AM_BACKSLASH@
+	$(F77COMPILE) -c -o $@ $<
+
+.f.obj:
+	$(AM_V_F77) @AM_BACKSLASH@
+	$(F77COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.f.lo:
+	$(AM_V_F77) @AM_BACKSLASH@
+	$(LTF77COMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	set x; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+	clean-checkPROGRAMS clean-generic clean-libtool ctags \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/test/fortran/boxplot.f b/test/fortran/boxplot.f
new file mode 100644
index 0000000..2ed0164
--- /dev/null
+++ b/test/fortran/boxplot.f
@@ -0,0 +1,168 @@
+C     ****************** LICENSE ****************
+C
+C     Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+C
+C     Licensed under the Apache License, Version 2.0 (the "License");
+C     you may not use this file except in compliance with the License.
+C     You may obtain a copy of the License at 
+C
+C        http://www.apache.org/licenses/LICENSE-2.0
+C
+C     Unless required by applicable law or agreed to in writing, software
+C     distributed under the License is distributed on an "AS IS" BASIS,
+C     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+C     See the License for the specific language governing permissions and
+C     limitations under the License.
+C
+C     ****************** LICENSE ****************
+C
+C     This program demonstrates a new feature of Magics++: boxplots.
+C
+      PROGRAM BOXPLOT
+
+      DIMENSION RPOS(4),RMIN(4),RMAX(4),RMED(4),RUPP(4),RLOW(4)
+      DATA RPOS/2.0, 4.0, 6.5, 8.0/
+      DATA RMIN/1.0, 3.0, 5.2, 4.0/
+      DATA RMAX/5.0, 7.2, 9.4, 8.0/
+      DATA RMED/3.0, 5.0, 7.7, 6.0/
+      DATA RUPP/4.0, 6.0, 8.5, 7.0/
+      DATA RLOW/2.3, 4.0, 6.1, 5.0/
+C
+C     Open MAGICS and set the output file types/names
+C
+      CALL POPEN()
+C
+      CALL PSETC ('OUTPUT_FORMAT',  'PS')
+      CALL PSETC ('OUTPUT_NAME',    'boxplot')
+C
+C     Boxplots work in paper coordinates, not map projection
+C
+      CALL PSETC ('SUBPAGE_MAP_PROJECTION', 'NONE')
+C
+C     Set up our axes. We will always use a 10x10 axis for
+C     these examples. We must set up the axes before plotting
+C     our boxplots.
+C
+      CALL DRAW_AXES ()
+C
+C     Set up our data for the boxplots
+C
+      CALL PSET1R('BOXPLOT_POSITIONS',        RPOS, 4)
+      CALL PSET1R('BOXPLOT_MINIMUM_VALUES',   RMIN, 4)
+      CALL PSET1R('BOXPLOT_MAXIMUM_VALUES',   RMAX, 4)
+      CALL PSET1R('BOXPLOT_MEDIAN_VALUES',    RMED, 4)
+      CALL PSET1R('BOXPLOT_BOX_UPPER_VALUES', RUPP, 4)
+      CALL PSET1R('BOXPLOT_BOX_LOWER_VALUES', RLOW, 4)
+C
+C     Draw the boxplots using the default plotting attributes
+C
+      CALL PBOXPLOT
+C
+      CALL PSETC ('TEXT_LINE_1',
+     x            'Boxplot - default plotting attributes')
+      CALL PTEXT
+C
+C     New page - use different boxplot plotting attributes
+C
+      CALL PNEW ('PAGE')
+C
+      CALL DRAW_AXES ()
+C
+      CALL PSETR ('BOXPLOT_BOX_WIDTH', 1.)
+      CALL PSETC ('BOXPLOT_BOX_COLOUR', 'TURQUOISE')
+      CALL PSETI ('BOXPLOT_BOX_BORDER_THICKNESS', 1)
+      CALL PSETC ('BOXPLOT_BOX_BORDER_LINE_STYLE', 'DASH')
+      CALL PSETC ('BOXPLOT_WHISKER', 'BOX')
+      CALL PSETR ('BOXPLOT_WHISKER_BOX_WIDTH', 0.3)
+      CALL PSETC ('BOXPLOT_WHISKER_BOX_COLOUR', 'BLUE_PURPLE')
+      CALL PSETC ('BOXPLOT_WHISKER_BOX_BORDER_COLOUR', 'RED')
+      CALL PBOXPLOT
+C
+      CALL PSETC ('TEXT_LINE_1',
+     x            'Thick dashed border, box colour, whiskers as boxes')
+      CALL PTEXT
+C
+C
+C     New page - use different boxplot plotting attributes
+C
+      CALL PNEW ('PAGE')
+C
+      CALL DRAW_AXES ()
+C
+      CALL PSETC  ('BOXPLOT_WHISKER',            'LINE')
+      CALL PSETC  ('BOXPLOT_WHISKER_LINE_STYLE', 'DOT')
+      CALL PRESET ('BOXPLOT_BOX_COLOUR')
+      CALL PRESET ('BOXPLOT_BOX_BORDER_THICKNESS')
+      CALL PRESET ('BOXPLOT_BOX_BORDER_LINE_STYLE')
+      CALL PBOXPLOT
+C
+      CALL PSETC ('TEXT_LINE_1',
+     x            'Whiskers as lines')
+      CALL PTEXT
+C
+C     New page - use different median plotting attributes
+C
+      CALL PNEW ('PAGE')
+C
+      CALL DRAW_AXES ()
+C
+      CALL PSETC  ('BOXPLOT_MEDIAN_COLOUR',     'NAVY')
+      CALL PSETI  ('BOXPLOT_MEDIAN_THICKNESS',   4)
+      CALL PSETC  ('BOXPLOT_MEDIAN_LINE_STYLE', 'DOT')
+      CALL PRESET ('BOXPLOT_WHISKER_LINE_STYLE')
+      CALL PBOXPLOT
+C
+      CALL PSETC ('TEXT_LINE_1',
+     x            'Median styles - thick, navy, dotted')
+      CALL PTEXT
+C
+C
+C     New page - plot plain black & white boxplots
+C
+      CALL PNEW ('PAGE')
+C
+      CALL DRAW_AXES ()
+C
+      CALL PSETC  ('BOXPLOT_BOX_COLOUR',          'WHITE')
+      CALL PSETC  ('BOXPLOT_MEDIAN_COLOUR',       'BLACK')
+      CALL PSETC  ('BOXPLOT_BOX_BORDER_COLOUR',   'BLACK')
+      CALL PSETC  ('BOXPLOT_WHISKER_LINE_COLOUR', 'BLACK')
+      CALL PRESET ('BOXPLOT_MEDIAN_THICKNESS')
+      CALL PRESET ('BOXPLOT_MEDIAN_LINE_STYLE')
+      CALL PBOXPLOT
+
+      CALL PSETC ('TEXT_LINE_1', 'Plain boxplot')
+      CALL PTEXT
+C
+C     closing
+C
+      CALL PCLOSE()
+C
+      END
+C
+C
+C     ------------------------------------------------------------
+C     SUBROUTINE DRAW_AXES
+C     Sets up and draws the axes. We will need to do this for each
+C     page, to it's better to have it as a subroutine.
+C     ------------------------------------------------------------
+C
+      SUBROUTINE DRAW_AXES ()
+C
+      CALL PSETC ('AXIS_LINE_COLOUR', 'BLUE')
+      CALL PSETC ('AXIS_GRID', 'ON')
+      CALL PSETC ('AXIS_GRID', 'ON')
+      CALL PSETC ('AXIS_GRID_COLOUR', 'GREY')
+      CALL PSETC ('AXIS_GRID_LINE_STYLE', 'DASH')
+      CALL PSETC ('AXIS_ORIENTATION', 'VERTICAL')
+      CALL PSETR ('AXIS_MIN_VALUE', 0.)
+      CALL PSETR ('AXIS_MAX_VALUE', 10.)
+      CALL PAXIS
+C
+      CALL PSETC ('AXIS_ORIENTATION', 'HORIZONTAL')
+      CALL PSETR ('AXIS_MIN_VALUE', 0.)
+      CALL PSETR ('AXIS_MAX_VALUE', 10.)
+      CALL PAXIS
+C
+      RETURN
+      END
diff --git a/test/fortran/coast_only.f b/test/fortran/coast_only.f
new file mode 100644
index 0000000..d3e1c07
--- /dev/null
+++ b/test/fortran/coast_only.f
@@ -0,0 +1,52 @@
+C     ****************** LICENSE ****************
+C
+C     Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+C
+C     Licensed under the Apache License, Version 2.0 (the "License");
+C     you may not use this file except in compliance with the License.
+C     You may obtain a copy of the License at 
+C
+C        http://www.apache.org/licenses/LICENSE-2.0
+C
+C     Unless required by applicable law or agreed to in writing, software
+C     distributed under the License is distributed on an "AS IS" BASIS,
+C     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+C     See the License for the specific language governing permissions and
+C     limitations under the License.
+C
+C     ****************** LICENSE ****************
+C
+C     No data is plotted, just the global coastline
+C     We also demonstrate how to specify multiple output
+C     formats. This increases efficiency compared to either running
+C     the program multiple times or using an external conversion
+C     tool.
+C
+      PROGRAM COAST_ONLY
+C
+C     Define our array of output formats
+C
+      CHARACTER*16 FORMATS_PS_SVG
+      DIMENSION    FORMATS_PS_SVG(2)
+      DATA         FORMATS_PS_SVG /'PS','SVG'/
+C
+C     Open MAGICS and set the output file types/names
+C     Here we specify three output formats.
+C
+      CALL POPEN
+      CALL PSET1C ('OUTPUT_FORMATS', FORMATS_PS_SVG,2)
+      CALL PSETC  ('OUTPUT_NAME',    'coast_only')
+C
+C     Set up the coastline attributes
+C
+      CALL PSETC ('MAP_COASTLINE',        'ON')
+      CALL PSETC ('MAP_COASTLINE_COLOUR', 'GREY')
+      CALL PSETC ('MAP_GRID_COLOUR',      'GREY')     
+C
+C     Plot the coastlines and then close
+C
+      CALL PCOAST
+      CALL PCLOSE
+C
+      STOP
+      END
diff --git a/test/fortran/layout_test.f b/test/fortran/layout_test.f
new file mode 100644
index 0000000..5a41efb
--- /dev/null
+++ b/test/fortran/layout_test.f
@@ -0,0 +1,572 @@
+C     ****************** LICENSE ****************
+C
+C     Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+C
+C     Licensed under the Apache License, Version 2.0 (the "License");
+C     you may not use this file except in compliance with the License.
+C     You may obtain a copy of the License at 
+C
+C        http://www.apache.org/licenses/LICENSE-2.0
+C
+C     Unless required by applicable law or agreed to in writing, software
+C     distributed under the License is distributed on an "AS IS" BASIS,
+C     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+C     See the License for the specific language governing permissions and
+C     limitations under the License.
+C
+C     ****************** LICENSE ****************
+C
+C     This program demonstrates a new feature of Magics++: layout
+C
+      PROGRAM LAYOUT_TEST
+C
+      DIMENSION X(11),Y(11)
+      DATA X/0.0,1.,2.,3.,4.,5.,6.,7.,8.,9.,10./
+      DATA Y/0.0,4.,6.,8.,10.,15.,20.,30.,20.,10.,5./
+C
+C     Define our array of output formats
+C
+      CHARACTER*16 FORMATS_PS_SVG
+      DIMENSION    FORMATS_PS_SVG(2)
+      DATA         FORMATS_PS_SVG /'PS','SVG'/
+C
+C     OPEN MAGICS
+C 
+      CALL POPEN
+      CALL PSET1C ('OUTPUT_FORMATS', FORMATS_PS_SVG,2)
+      CALL PSETC  ('OUTPUT_NAME',    'layout_test')
+      CALL PARSE_COMMAND_LINE ('layout_test')
+C
+C   Set ID line text
+C
+      CALL PSETC ('PAGE_ID_LINE_USER_TEXT', 'Layout test')
+C      
+C     dimensions for A3      
+C
+      PX = 42.0
+      PY = 29.7
+      X1 =  0.5
+      X2 = 21.5
+      Y1 =  0.5
+      Y2 = 15.5
+C
+C     Page locations. We have a 2x3 grid of plots
+C
+      CALL PSETR('SUPER_PAGE_X_LENGTH',PX)
+      CALL PSETR('SUPER_PAGE_Y_LENGTH',PY)
+C
+      CALL PSETC ('SUBPAGE_MAP_PROJECTION', 'POLAR_STEREOGRAPHIC')
+      CALL PSETR ('SUBPAGE_LOWER_LEFT_LATITUDE',    23.0)
+      CALL PSETR ('SUBPAGE_LOWER_LEFT_LONGITUDE',  -33.0)
+      CALL PSETR ('SUBPAGE_UPPER_RIGHT_LATITUDE',   51.0)
+      CALL PSETR ('SUBPAGE_UPPER_RIGHT_LONGITUDE',  72.0)
+C
+C     Setup of subpages
+C      
+      CALL PSETC ('LAYOUT', 'POSITIONAL')
+      CALL PSETR ('PAGE_X_LENGTH', 20.0)
+      CALL PSETR ('PAGE_Y_LENGTH', 15.0)
+      CALL PSETR ('PAGE_X_POSITION', X1)
+      CALL PSETR ('PAGE_Y_POSITION', Y2)
+C
+      CALL MAP_SHADING
+C
+      CALL PCOAST
+C
+      CALL PNEW  ('PAGE')
+      CALL PSETR ('PAGE_X_POSITION', X2)
+      CALL PSETR ('PAGE_Y_POSITION', Y2)
+      CALL MAP_SHADING_2
+C
+      CALL PCOAST
+C
+      CALL PNEW  ('PAGE')
+      CALL PSETR ('PAGE_X_POSITION', X1)
+      CALL PSETR ('PAGE_Y_POSITION', Y1)
+      CALL MAP_THREE
+C
+      CALL PNEW  ('PAGE')
+      CALL PSETC ('PAGE_ID_LINE', 'OFF')
+      CALL PSETR ('PAGE_X_POSITION', X2)
+      CALL PSETR ('PAGE_Y_POSITION', Y1)
+      CALL GRAPH_ONE
+C
+C     Close
+C
+      CALL PCLOSE
+C
+      STOP
+      END
+C
+C
+      SUBROUTINE MAP_SHADING
+C
+      PARAMETER (NLEV=18)
+      CHARACTER*25 CTAB
+      DIMENSION  CTAB  (NLEV)
+      DATA       CTAB  /'BLUE_PURPLE',
+     +                  'BLUE',
+     +                  'GREENISH_BLUE',
+     +                  'BLUE_GREEN',
+     +                  'BLUISH_GREEN',
+     +                  'YELLOW_GREEN',
+     +                  'GREENISH_YELLOW',
+     +                  'YELLOW',
+     +                  'ORANGISH_YELLOW',
+     +                  'ORANGE_YELLOW',
+     +                  'YELLOWISH_ORANGE',
+     +                  'ORANGE',
+     +                  'REDDISH_ORANGE',
+     +                  'RED_ORANGE',
+     +                  'ORANGISH_RED',
+     +                  'RED',
+     +                  'REDDISH_PURPLE',
+     +                  'MAGENTA'/
+C
+C     Pass the data to MAGICS
+C
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/t2m_fc12.grib')
+      CALL PGRIB
+      CALL PSETC  ('CONTOUR',                      'OFF')
+      CALL PSETR  ('CONTOUR_SHADE_MIN_LEVEL',       -50.)
+      CALL PSETR  ('CONTOUR_SHADE_MAX_LEVEL',        40.)
+      CALL PSETC  ('CONTOUR_LEVEL_SELECTION_TYPE', 'INTERVAL')
+      CALL PSETR  ('CONTOUR_INTERVAL',              5.0)
+      CALL PSETC  ('CONTOUR_SHADE_COLOUR_METHOD',  'LIST')
+      CALL PSET1C ('CONTOUR_SHADE_COLOUR_LIST',     CTAB, NLEV)
+      CALL PSETC  ('CONTOUR_SHADE',                'ON')      
+      CALL PSETC  ('CONTOUR_SHADE_TECHNIQUE',      'POLYGON_SHADING')
+      CALL PSETC  ('CONTOUR_SHADE_METHOD',         'AREA_FILL')
+      CALL PSETC  ('CONTOUR_HILO',                 'OFF')
+      CALL PCONT
+C
+      CALL PSETC ('GRIB_INPUT_FILE_NAME',
+     x  '../data/wind30m_fc12.grib')
+      CALL PSETI ('GRIB_WIND_POSITION_1',1)                 
+      CALL PSETI ('GRIB_WIND_POSITION_2',2) 
+      CALL PGRIB
+      CALL PWIND
+C
+      CALL PRESET('CONTOUR_SHADE_MIN_LEVEL')
+      CALL PRESET('CONTOUR_SHADE_MAX_LEVEL')
+C
+      RETURN
+      END
+C
+C
+C
+      SUBROUTINE MAP_SHADING_2
+C
+      PARAMETER (NLEV=21)
+      CHARACTER*25 CTAB
+      DIMENSION  CTAB  (NLEV)
+      DATA       CTAB  /'BLUISH_PURPLE',
+     +                  'BLUE_PURPLE',
+     +                  'PURPLISH_BLUE',
+     +                  'BLUE',
+     +                  'GREENISH_BLUE',
+     +                  'BLUE_GREEN',
+     +                  'BLUISH_GREEN',
+     +                  'YELLOW_GREEN',
+     +                  'GREENISH_YELLOW',
+     +                  'YELLOW',
+     +                  'ORANGISH_YELLOW',
+     +                  'ORANGE_YELLOW',
+     +                  'YELLOWISH_ORANGE',
+     +                  'ORANGE',
+     +                  'REDDISH_ORANGE',
+     +                  'RED_ORANGE',
+     +                  'ORANGISH_RED',
+     +                  'RED',
+     +                  'REDDISH_PURPLE',
+     +                  'PURPLE_RED',
+     +                  'MAGENTA'/
+C
+C     Pass the data to MAGICS
+C 
+      CALL PSETC ('GRIB_INPUT_TYPE',      'FILE')
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/t850_fc_12.grib')
+      CALL PGRIB
+C
+      CALL PSETC  ('CONTOUR',                      'OFF')
+      CALL PSETR  ('CONTOUR_SHADE_MIN_LEVEL',       -40.)
+      CALL PSETR  ('CONTOUR_SHADE_MAX_LEVEL',        44.)
+      CALL PSETC  ('CONTOUR_LEVEL_SELECTION_TYPE', 'INTERVAL')
+      CALL PSETR  ('CONTOUR_INTERVAL',              4.0)
+      CALL PSETC  ('CONTOUR_SHADE_COLOUR_METHOD',  'LIST')
+      CALL PSET1C ('CONTOUR_SHADE_COLOUR_LIST',     CTAB, NLEV)
+      CALL PSETC  ('CONTOUR_SHADE',                'ON')      
+      CALL PSETC  ('CONTOUR_SHADE_TECHNIQUE',      'POLYGON_SHADING')
+      CALL PSETC  ('CONTOUR_SHADE_METHOD',         'AREA_FILL')
+      CALL PSETC  ('CONTOUR_HILO',                 'OFF')
+      CALL PCONT
+C
+C     Now load the Z500 data
+C
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/z500_fc_12.grib')
+      CALL PGRIB
+C     Redefine the contouring parameters for the Z500
+      CALL PSETC  ('CONTOUR',                      'ON')
+      CALL PSETR  ('CONTOUR_INTERVAL',              6.0)
+      CALL PSETC  ('CONTOUR_LEVEL_SELECTION_TYPE', 'INTERVAL')
+      CALL PSETC  ('CONTOUR_LINE_COLOUR',          'BLACK')
+      CALL PSETC  ('CONTOUR_HIGHLIGHT_COLOUR',     'BLACK')
+      CALL PSETI  ('CONTOUR_HIGHLIGHT_THICKNESS',   4)
+      CALL PSETC  ('CONTOUR_HILO',                 'ON')
+      CALL PSETR  ('CONTOUR_HILO_HEIGHT',           0.25)
+      CALL PSETR  ('CONTOUR_HILO_SUPPRESS_RADIUS',  40.0)
+      CALL PSETC  ('CONTOUR_SHADE',                'OFF')      
+      CALL PCONT
+C
+      CALL PRESET('CONTOUR_SHADE_MIN_LEVEL')
+      CALL PRESET('CONTOUR_SHADE_MAX_LEVEL')
+C
+      RETURN
+      END
+C
+C
+C
+      SUBROUTINE MAP_THREE
+C
+      PARAMETER (NCOLS=64)
+       CHARACTER*25 CTAB
+       DIMENSION  CTAB (NCOLS)
+       DATA       CTAB /'HSL(0,0,1)',
+     +                  'HSL(29,0.14,0.92)',
+     +                  'HSL(29,0.29,0.83)',
+     +                  'HSL(29,0.43,0.75)',
+     +                  'HSL(300,0.08,0.92)',
+     +                  'HSL(360,0.16,0.84)',
+     +                  'HSL(13,0.3,0.75)',
+     +                  'HSL(18,0.44,0.67)',
+     +                  'HSL(300,0.16,0.83)',
+     +                  'HSL(340,0.22,0.75)',
+     +                  'HSL(360,0.34,0.67)',
+     +                  'HSL(8,0.47,0.58)',
+     +                  'HSL(300,0.24,0.75)',
+     +                  'HSL(330,0.28,0.67)',
+     +                  'HSL(349,0.38,0.58)',
+     +                  'HSL(360,0.5,0.5)',
+     +                  'HSL(180,0.17,0.92)',
+     +                  'HSL(120,0.08,0.84)',
+     +                  'HSL(57,0.17,0.75)',
+     +                  'HSL(44,0.3,0.67)',
+     +                  'HSL(209,0.14,0.84)',
+     +                  'HSL(187,0,0.75)',
+     +                  'HSL(29,0.15,0.67)',
+     +                  'HSL(29,0.29,0.59)',
+     +                  'HSL(239,0.16,0.75)',
+     +                  'HSL(299,0.08,0.67)',
+     +                  'HSL(360,0.17,0.58)',
+     +                  'HSL(13,0.3,0.5)',
+     +                  'HSL(258,0.21,0.67)',
+     +                  'HSL(299,0.16,0.59)',
+     +                  'HSL(341,0.22,0.5)',
+     +                  'HSL(360,0.33,0.42)',
+     +                  'HSL(180,0.34,0.83)',
+     +                  'HSL(161,0.22,0.75)',
+     +                  'HSL(120,0.16,0.67)',
+     +                  'HSL(78,0.21,0.58)',
+     +                  'HSL(193,0.3,0.75)',
+     +                  'HSL(180,0.17,0.67)',
+     +                  'HSL(120,0.08,0.58)',
+     +                  'HSL(59,0.16,0.5)',
+     +                  'HSL(209,0.29,0.67)',
+     +                  'HSL(209,0.15,0.58)',
+     +                  'HSL(217,0,0.5)',
+     +                  'HSL(29,0.14,0.42)',
+     +                  'HSL(224,0.3,0.58)',
+     +                  'HSL(237,0.17,0.5)',
+     +                  'HSL(299,0.08,0.42)',
+     +                  'HSL(360,0.16,0.33)',
+     +                  'HSL(180,0.5,0.75)',
+     +                  'HSL(169,0.38,0.67)',
+     +                  'HSL(150,0.28,0.58)',
+     +                  'HSL(120,0.24,0.5)',
+     +                  'HSL(188,0.47,0.67)',
+     +                  'HSL(180,0.34,0.59)',
+     +                  'HSL(160,0.22,0.5)',
+     +                  'HSL(120,0.16,0.42)',
+     +                  'HSL(198,0.44,0.58)',
+     +                  'HSL(193,0.3,0.5)',
+     +                  'HSL(180,0.17,0.42)',
+     +                  'HSL(120,0.08,0.33)',
+     +                  'HSL(209,0.43,0.5)',
+     +                  'HSL(209,0.29,0.42)',
+     +                  'HSL(209,0.14,0.33)',
+     +                  'HSL(191,0,0.25)'/
+       PARAMETER (NLEV=65)
+       DIMENSION  RLEV (NLEV)
+       DATA       RLEV /-0.5,
+     +                  0.5,
+     +                  1.5,
+     +                  2.5,
+     +                  3.5,
+     +                  4.5,
+     +                  5.5,
+     +                  6.5,
+     +                  7.5,
+     +                  8.5,
+     +                  9.5,
+     +                  10.5,
+     +                  11.5,
+     +                  12.5,
+     +                  13.5,
+     +                  14.5,
+     +                  15.5,
+     +                  16.5,
+     +                  17.5,
+     +                  18.5,
+     +                  19.5,
+     +                  20.5,
+     +                  21.5,
+     +                  22.5,
+     +                  23.5,
+     +                  24.5,
+     +                  25.5,
+     +                  26.5,
+     +                  27.5,
+     +                  28.5,
+     +                  29.5,
+     +                  30.5,
+     +                  31.5,
+     +                  32.5,
+     +                  33.5,
+     +                  34.5,
+     +                  35.5,
+     +                  36.5,
+     +                  37.5,
+     +                  38.5,
+     +                  39.5,
+     +                  40.5,
+     +                  41.5,
+     +                  42.5,
+     +                  43.5,
+     +                  44.5,
+     +                  45.5,
+     +                  46.5,
+     +                  47.5,
+     +                  48.5,
+     +                  49.5,
+     +                  50.5,
+     +                  51.5,
+     +                  52.5,
+     +                  53.5,
+     +                  54.5,
+     +                  55.5,
+     +                  56.5,
+     +                  57.5,
+     +                  58.5,
+     +                  59.5,
+     +                  60.5,
+     +                  61.5,
+     +                  62.5,
+     +                  63.5/
+      CHARACTER TITLE*256
+
+C     First, load and plot the temperature data, shaded
+C     Pass the data to MAGICS
+
+      CALL PSETC ('GRIB_INPUT_TYPE',      'FILE')
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/cloudcover.grib')
+      CALL PGRIB
+
+C     Set up the coastline attributes
+
+      CALL PSETC ('MAP_COASTLINE_COLOUR', 'BLACK')
+      CALL PSETC ('MAP_GRID_COLOUR',      'BLACK')     
+
+C     Define the contour     
+
+      CALL PSETC  ('LEGEND',                       'OFF')
+      CALL PSETC  ('CONTOUR',                      'OFF')
+      CALL PSETC  ('CONTOUR_LEVEL_SELECTION_TYPE', 'LEVEL_LIST')
+      CALL PSET1R ('CONTOUR_LEVEL_LIST',            RLEV, NLEV)      
+      CALL PSETC  ('CONTOUR_SHADE',                'ON')      
+      CALL PSETC  ('CONTOUR_SHADE_TECHNIQUE',      'CELL_SHADING')
+      CALL PSETC  ('CONTOUR_SHADE_COLOUR_METHOD',  'LIST')
+      CALL PSET1C ('CONTOUR_SHADE_COLOUR_LIST',     CTAB, NCOLS)
+      CALL PSETC  ('CONTOUR_SHADE_METHOD',         'AREA_FILL')
+      CALL PSETC  ('CONTOUR_HILO',                 'OFF')
+      CALL PCONT
+      
+C     Plot the title text and the coastlines
+
+      TITLE = 'Z700 \\\CL' //  
+     +        CTAB(4)  // '\\\Low,\\\CL' //
+     +        CTAB(16) // '\\\ L+M,\\\CL' //
+     +        CTAB(13) // '\\\ Medium,\\\CL' //
+     +        CTAB(61) // '\\\ M+H,\\\CL' //
+     +        CTAB(49) // '\\\ High,\\\CL' //
+     +        CTAB(52) // '\\\ H+L,\\\CLBLACK\\\ H+M+L' //
+     +        '\\\CLR\\\ clouds'
+C
+      CALL PSETR  ('TEXT_FONT_SIZE', 0.4)
+      CALL PSETC  ('TEXT_LINE_1',TITLE)
+      CALL PTEXT
+      CALL PCOAST
+C
+      RETURN
+      END
+C
+C
+C
+	SUBROUTINE GRAPH_ONE
+C
+C	PLOT SIMPLE CURVE WITH SYMBOLS
+C
+	DIMENSION X(11),Y(11),Y2(11),Y3(11),X2(10),YL(10),YU(10),
+     + YL2(10),YU2(10)
+	DATA X/0.0,1.,2.,3.,4.,5.,6.,7.,8.,9.,10./
+	DATA  Y/0.0,15.,6.,18.,10.,15.,27.,37.,20.,10.,15./
+	DATA Y2/3.0,14.,2.,8.,13.,75.,57.,45.,26.,52.,58./
+	DATA Y3/2.0,10.,22.,12.,32.,12.,24.,38.,23.,34.,45./
+	DATA X2/1.,2.,3.,4.,5.,6.,7.,8.,9.,10./
+	DATA YL /10*0.0/
+	DATA YU/3.0,5.,9.,1.,2.,10.,19.,18.,10.,18./
+	DATA YU2 /13.0,15.,19.,11.,22.,20.,29.,28.,20.,21./
+C
+C	SET UP AXIS SYSTEM
+C
+	CALL PSETC ('SUBPAGE_MAP_PROJECTION','NONE')  
+	CALL PSETC ('AXIS_ORIENTATION','HORIZONTAL')
+	CALL PSETC ('AXIS_POSITION','BOTTOM')
+	CALL PSETR ('AXIS_MIN_VALUE',0.0)
+	CALL PSETR ('AXIS_MAX_VALUE',10.5)
+	CALL PSETR ('AXIS_TICK_INTERVAL',1.0)
+	CALL PAXIS
+	CALL PSETC ('AXIS_ORIENTATION','VERTICAL')
+	CALL PSETC ('AXIS_POSITION','LEFT')
+	CALL PSETR ('AXIS_MIN_VALUE',0.0)
+	CALL PSETR ('AXIS_MAX_VALUE',100.0)
+	CALL PSETR ('AXIS_TICK_INTERVAL',5.0)
+	CALL PAXIS
+C
+C	SET GRAPH PARAMETERS
+C 
+C     Set up our data for the boxplots
+c
+      CALL PSETC ('GRAPH_SHADE_COLOUR','SKY')
+      CALL PSETR ('boxplot_box_width',0.5)
+      CALL PSET1R('BOXPLOT_POSITIONS',
+     + (/2., 4., 6., 8. /), 4 )
+      CALL PSET1R('BOXPLOT_MINIMUM_VALUES', 
+     + (/10., 30., 52., 40./), 4)
+      CALL PSET1R('BOXPLOT_MAXIMUM_VALUES', 
+     + (/50., 72., 87., 81./), 4)
+      CALL PSET1R('BOXPLOT_MEDIAN_VALUES', 
+     + (/25., 42., 77., 46./), 4)
+      CALL PSET1R('BOXPLOT_BOX_UPPER_VALUES', 
+     + (/35., 56., 82.5, 67./), 4)
+      CALL PSET1R('BOXPLOT_BOX_LOWER_VALUES', 
+     + (/21.3, 34., 66.1, 45./), 4)
+C
+C     Draw the boxplots using the default plotting attributes
+C
+	CALL PBOXPLOT
+C      
+	CALL PSETC ('GRAPH_TYPE','BAR')
+	CALL PSETC ('GRAPH_SHADE','ON')
+	CALL PSETC ('GRAPH_SHADE_STYLE','HATCH')
+	CALL PSETI ('graph_shade_hatch_index',0)
+C
+	CALL PSETC ('GRAPH_SHADE_COLOUR','ORANGE')
+	CALL PSET1R ('GRAPH_BAR_X_VALUES',X2,10)
+	CALL PSET1R ('GRAPH_BAR_Y_LOWER_VALUES',YL,10)
+	CALL PSET1R ('GRAPH_BAR_Y_UPPER_VALUES',YU,10)
+	CALL PGRAPH
+C
+	CALL PSETC ('GRAPH_SHADE_STYLE','DOT')
+	CALL PSETC ('GRAPH_SHADE_COLOUR','BLUE')
+	CALL PSET1R ('GRAPH_BAR_X_VALUES',X2,10)
+	CALL PSET1R ('GRAPH_BAR_Y_LOWER_VALUES',YU,10)
+	CALL PSET1R ('GRAPH_BAR_Y_UPPER_VALUES',YU2,10)
+	CALL PGRAPH
+C
+	CALL PSETC ('GRAPH_TYPE','CURVE')
+	CALL PSETC ('GRAPH_SYMBOL','ON')
+	CALL PSETI ('GRAPH_SYMBOL_MARKER_INDEX',18)
+	CALL PSETC ('GRAPH_LINE_COLOUR','RED')
+	CALL PSET1R ('GRAPH_CURVE_X_VALUES',X,11)
+	CALL PSET1R ('GRAPH_CURVE_Y_VALUES',Y,11)
+	CALL PGRAPH
+
+	CALL PSETC ('GRAPH_LINE_COLOUR','BLUE')
+	CALL PSET1R ('GRAPH_CURVE_X_VALUES',X,11)
+	CALL PSET1R ('GRAPH_CURVE_Y_VALUES',Y2,11)
+	CALL PGRAPH
+
+	CALL PSETC ('GRAPH_LINE_COLOUR','GREEN')
+	CALL PSET1R ('GRAPH_CURVE_X_VALUES',X,11)
+	CALL PSET1R ('GRAPH_CURVE_Y_VALUES',Y3,11)
+	CALL PGRAPH
+
+	CALL PSETC ('TEXT_LINE_1','Graph Plotting in '//
+     x             'bar and line mode')
+	CALL PTEXT
+
+	RETURN
+	END
+
+C --------------------------------------------------------------------
+C     PARSE_COMMAND_LINE
+C     Checks the command-line for any arguments.
+C     Arguments can come in pairs. Currently supported arguments are:
+C     PROJECTION 
+C     DEVICE 
+C     e.g. Run the program with:
+C      PROJECTION POLAR_STEREOGRAPHIC
+C      PROJECTION CYLINDRICAL   DEVICE SVG
+C --------------------------------------------------------------------
+
+      SUBROUTINE PARSE_COMMAND_LINE (OUTROOTNAME)
+
+      CHARACTER*32 ARG
+      CHARACTER*64 ID_TEXT
+      CHARACTER*32 PROJECTION
+      CHARACTER*32 DEVICE
+      CHARACTER*48 EXENAME
+      CHARACTER*8  MINIMAL
+      CHARACTER*8  SEPARATOR
+      CHARACTER*64 OUTNAME
+      CHARACTER*(*) OUTROOTNAME
+
+      INTEGER NUM_ARGS
+      INTEGER DEVICE_SET
+
+      ID_TEXT = ''
+
+      NUM_ARGS = IARGC()
+
+      I = 1
+
+20    IF (I.LE.NUM_ARGS) THEN
+          CALL GETARG ( I, ARG ) 
+ 
+C         Set the projection?
+          IF (ARG.EQ.'PROJECTION') THEN
+              I = I + 1 
+              CALL GETARG ( I, PROJECTION ) 
+              CALL PSETC ('SUBPAGE_MAP_PROJECTION', PROJECTION)
+	      
+C        Set the device?
+          ELSEIF (ARG.EQ.'DEVICE') THEN
+              I = I + 1 
+              CALL GETARG ( I, DEVICE ) 
+
+              CALL PSETC ('OUTPUT_FORMAT', DEVICE )
+              CALL PSETC ('OUTPUT_NAME', OUTROOTNAME)
+	      CALL PSETC ('OUTPUT_SVG_COMPRESS', 'ON')
+
+C        Run using linear contouring?
+
+          ELSEIF (ARG.EQ.'LINEAR') THEN
+                CALL PSETC ('CONTOUR_METHOD', 'LINEAR')
+                CALL PSETC ('PAGE_ID_LINE_USER_TEXT_PLOT', 'ON')
+                CALL PSETC ('PAGE_ID_LINE_USER_TEXT', 'LINEAR')
+          ENDIF
+
+          I = I + 1 
+          GOTO 20
+      ENDIF
+      END
diff --git a/test/fortran/shaded_isolines.f b/test/fortran/shaded_isolines.f
new file mode 100644
index 0000000..9e54215
--- /dev/null
+++ b/test/fortran/shaded_isolines.f
@@ -0,0 +1,131 @@
+C     ****************** LICENSE ****************
+C
+C     Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+C
+C     Licensed under the Apache License, Version 2.0 (the "License");
+C     you may not use this file except in compliance with the License.
+C     You may obtain a copy of the License at 
+C
+C        http://www.apache.org/licenses/LICENSE-2.0
+C
+C     Unless required by applicable law or agreed to in writing, software
+C     distributed under the License is distributed on an "AS IS" BASIS,
+C     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+C     See the License for the specific language governing permissions and
+C     limitations under the License.
+C
+C     ****************** LICENSE ****************
+C
+C     This program demonstrates a new feature of Magics++: boxplots.
+C
+C     This example plots a shaded temperature field, then overlays
+C     z500 isolines.
+C
+      PROGRAM T_SHADED_Z_ISOLINES
+C
+C     Define our colour palette for the shading
+C
+      PARAMETER (NLEV=21)
+      CHARACTER*25 CTAB
+      DIMENSION  CTAB  (NLEV)
+      DATA       CTAB  /'BLUE_PURPLE',
+     +                  'BLUE_PURPLE',
+     +                  'BLUE_PURPLE',
+     +                  'BLUE_PURPLE',
+     +                  'GREENISH_BLUE',
+     +                  'BLUE_GREEN',
+     +                  'BLUISH_GREEN',
+     +                  'YELLOW_GREEN',
+     +                  'GREENISH_YELLOW',
+     +                  'YELLOW',
+     +                  'ORANGISH_YELLOW',
+     +                  'ORANGE_YELLOW',
+     +                  'YELLOWISH_ORANGE',
+     +                  'ORANGE',
+     +                  'REDDISH_ORANGE',
+     +                  'RED_ORANGE',
+     +                  'ORANGISH_RED',
+     +                  'RED',
+     +                  'REDDISH_PURPLE',
+     +                  'PURPLE_RED',
+     +                  'MAGENTA'/
+C
+C     Define our array of output formats
+C
+      CHARACTER*16 FORMATS_PS_SVG
+      DIMENSION    FORMATS_PS_SVG(2)
+      DATA         FORMATS_PS_SVG /'PS','SVG'/
+C
+C     Open MAGICS and set the output file type/name
+C     Note that 'PS' is the default so we don't need to 
+C     specify it here.
+C
+      CALL POPEN
+      CALL PSET1C ('OUTPUT_FORMATS', FORMATS_PS_SVG,2)
+      CALL PSETC  ('OUTPUT_NAME',    'shaded_isolines')
+      CALL PSETC  ('PAGE_ID_LINE_USER_TEXT', 'shading test')
+C
+C     Area specification (SOUTH, WEST, NORTH, EAST )
+C
+      CALL PSETC ('SUBPAGE_MAP_PROJECTION', 'CYLINDRICAL')
+      CALL PSETR ('SUBPAGE_LOWER_LEFT_LATITUDE',    25.0)
+      CALL PSETR ('SUBPAGE_LOWER_LEFT_LONGITUDE',  -30.0)
+      CALL PSETR ('SUBPAGE_UPPER_RIGHT_LATITUDE',   75.0)
+      CALL PSETR ('SUBPAGE_UPPER_RIGHT_LONGITUDE',  70.0)
+C
+C     First, load and plot the temperature data, shaded
+C
+C     Pass the data to MAGICS
+C
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/t850_fc_12.grib')
+      CALL PGRIB
+C
+C     Set up the coastline attributes
+C
+      CALL PSETC ('MAP_COASTLINE_COLOUR', 'BLACK')
+      CALL PSETC ('MAP_GRID_COLOUR',      'BLACK')     
+C
+C     Define and plot the contour     
+C
+      CALL PSETC  ('CONTOUR',                      'OFF')
+      CALL PSETR  ('CONTOUR_SHADE_MIN_LEVEL',       -40.)
+      CALL PSETR  ('CONTOUR_SHADE_MAX_LEVEL',        44.)
+      CALL PSETC  ('CONTOUR_LEVEL_SELECTION_TYPE', 'INTERVAL')
+      CALL PSETR  ('CONTOUR_INTERVAL',              4.0)
+      CALL PSETC  ('CONTOUR_SHADE_COLOUR_METHOD',  'LIST')
+      CALL PSET1C ('CONTOUR_SHADE_COLOUR_LIST',     CTAB, NLEV)
+      CALL PSETC  ('CONTOUR_SHADE',                'ON')      
+      CALL PSETC  ('CONTOUR_SHADE_TECHNIQUE',      'POLYGON_SHADING')
+      CALL PSETC  ('CONTOUR_SHADE_METHOD',         'AREA_FILL')
+      CALL PSETC  ('CONTOUR_HILO',                 'OFF')
+      CALL PCONT
+C
+C     Plot the title text and the coastlines
+C
+      CALL PCOAST
+C
+C     Now load the Z500 data
+C
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/z500_fc_12.grib')
+      CALL PGRIB
+C
+C     Redefine the contouring parameters for the Z500
+C
+      CALL PSETC  ('CONTOUR',                      'ON')
+      CALL PSETC  ('CONTOUR_LEVEL_SELECTION_TYPE', 'INTERVAL')
+      CALL PSETR  ('CONTOUR_INTERVAL',              6.0)
+      CALL PSETC  ('CONTOUR_LINE_COLOUR',          'BLACK')
+      CALL PSETC  ('CONTOUR_HIGHLIGHT_COLOUR',     'BLACK')
+      CALL PSETI  ('CONTOUR_HIGHLIGHT_THICKNESS',   4)
+      CALL PSETC  ('CONTOUR_HILO',                 'ON')
+      CALL PSETR  ('CONTOUR_HILO_HEIGHT',           0.25)
+      CALL PSETR  ('CONTOUR_HILO_SUPPRESS_RADIUS',  40.0)
+      CALL PSETC  ('CONTOUR_SHADE',                'OFF')      
+      CALL PCONT
+C
+      CALL PSETC  ('TEXT_LINE_1','T850 (shaded) & Z500')
+      CALL PTEXT
+      CALL PCLOSE
+C
+      STOP
+      END
diff --git a/test/fortran/wind.f b/test/fortran/wind.f
new file mode 100644
index 0000000..ef1d425
--- /dev/null
+++ b/test/fortran/wind.f
@@ -0,0 +1,69 @@
+C     ****************** LICENSE ****************
+C
+C     Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+C
+C     Licensed under the Apache License, Version 2.0 (the "License");
+C     you may not use this file except in compliance with the License.
+C     You may obtain a copy of the License at 
+C
+C        http://www.apache.org/licenses/LICENSE-2.0
+C
+C     Unless required by applicable law or agreed to in writing, software
+C     distributed under the License is distributed on an "AS IS" BASIS,
+C     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+C     See the License for the specific language governing permissions and
+C     limitations under the License.
+C
+C     ****************** LICENSE ****************
+C
+C     This example demonstrates the plotting of wind arrows
+C     and flags.
+C
+      PROGRAM WIND
+C
+C     Open MAGICS and set the output file type/name
+C     Note that 'PS' is the default so we don't need to 
+C     specify it here.
+C
+      CALL POPEN
+      CALL PSETC ('OUTPUT_FORMAT',  'PS')
+      CALL PSETC ('OUTPUT_NAME',    'wind')
+C
+C     Set up all the parameters we'll use in all the examples
+C
+      CALL PSETC ('MAP_COASTLINE_COLOUR',            'GREY')
+      CALL PSETC ('MAP_GRID_COLOUR',                 'GREY')
+      CALL PSETC ('MAP_LABEL_COLOUR',                'GREY')
+C
+C     Area specification (SOUTH, WEST, NORTH, EAST)
+C
+      CALL PSETR ('SUBPAGE_LOWER_LEFT_LATITUDE',    25.0)
+      CALL PSETR ('SUBPAGE_LOWER_LEFT_LONGITUDE',  -30.0)
+      CALL PSETR ('SUBPAGE_UPPER_RIGHT_LATITUDE',   75.0)
+      CALL PSETR ('SUBPAGE_UPPER_RIGHT_LONGITUDE',  70.0)
+C
+C     Tell MAGICS where the U/V fields are in the file
+C     Note that these values are the defaults and so are not
+C     actually necessary in this example
+C
+      CALL PSETI ('GRIB_WIND_POSITION_1', 1)               
+      CALL PSETI ('GRIB_WIND_POSITION_2', 2)
+C
+C     Load the data file
+C
+      CALL PSETC ('GRIB_INPUT_FILE_NAME', '../data/uv500.grb')
+      CALL PGRIB
+C
+C     --- Plot wind arrows with default settings ---
+C
+      CALL PSETI ('TEXT_LINE_COUNT',  2)
+      CALL PSETC ('TEXT_LINE_1',     'Wind arrows, default settings')
+      CALL PSETC ('TEXT_LINE_2',     '')
+      CALL PCOAST 
+      CALL PWIND
+      CALL PTEXT
+C
+C     Close MAGICS
+C
+      CALL PCLOSE
+      END
diff --git a/test/python/Makefile.am b/test/python/Makefile.am
new file mode 100755
index 0000000..b93da9c
--- /dev/null
+++ b/test/python/Makefile.am
@@ -0,0 +1,7 @@
+AUTOMAKE_OPTIONS  = foreign
+AM_COLOR_TESTS    = always
+
+TESTS_ENVIRONMENT = MAGPLUS_HOME=$(top_srcdir) LD_LIBRARY_PATH=$(top_builddir)/src/.libs:$LD_LIBRARY_PATH PYTHONPATH=$(top_builddir)/python python 
+TESTS             = simple.py magmacro_example.py
+
+EXTRA_DIST = simple.py magmacro_example.py
diff --git a/test/python/Makefile.in b/test/python/Makefile.in
new file mode 100644
index 0000000..a25d57c
--- /dev/null
+++ b/test/python/Makefile.in
@@ -0,0 +1,539 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = test/python
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+AM_COLOR_TESTS = always
+TESTS_ENVIRONMENT = MAGPLUS_HOME=$(top_srcdir) LD_LIBRARY_PATH=$(top_builddir)/src/.libs:$LD_LIBRARY_PATH PYTHONPATH=$(top_builddir)/python python 
+TESTS = simple.py magmacro_example.py
+EXTRA_DIST = simple.py magmacro_example.py
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/python/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign test/python/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-TESTS check-am clean clean-generic \
+	clean-libtool distclean distclean-generic distclean-libtool \
+	distdir dvi dvi-am html html-am info info-am install \
+	install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/test/python/magmacro_example.py b/test/python/magmacro_example.py
new file mode 100755
index 0000000..4151915
--- /dev/null
+++ b/test/python/magmacro_example.py
@@ -0,0 +1,35 @@
+from Magics.macro import *
+
+#Definition of the output formats
+formats = output({'output_formats':['ps','svg'],
+                  'output_name':'magmacro_example'})
+
+#Setting the coordinates of the geographical area
+europe = pmap({
+                "subpage_upper_right_longitude": 65.,
+                "subpage_map_projection": "polar_stereographic",
+                "subpage_map_vertical_longitude": 0.,
+                "subpage_lower_left_longitude": -37.27,
+                "subpage_lower_left_latitude": 18.51,
+                "subpage_upper_right_latitude": 51.28})
+
+coastlines = mcoast({'map_coastline_land_shade' : 'on',
+                     'map_coastline_land_shade_colour' : 'grey',
+                     'map_coastline_sea_shade' : 'on',
+                     'map_coastline_sea_shade_colour' : 'white'})
+
+#Import the z500 data
+z500 =  pgrib({ "grib_input_file_name" : "../data/z500.grb"})
+
+#Define the simple contouring for z500
+z500_contour = mcont({
+                "contour_level_selection_type": "interval",
+                "contour_line_colour": "black",
+                "contour_hilo_height": 0.25,
+                "contour_line_thickness": 1,
+                "contour_highlight_colour": "red",
+                "contour_highlight_thickness": 2,
+                "contour_interval": 5.})
+
+#Do the plot
+plot(formats, europe, coastlines, z500, z500_contour)
diff --git a/test/python/simple.py b/test/python/simple.py
new file mode 100755
index 0000000..4503600
--- /dev/null
+++ b/test/python/simple.py
@@ -0,0 +1,33 @@
+import Magics
+
+Magics.init ()
+Magics.setc("output_format","svg")
+Magics.setc("output_name",  "python_simple")
+Magics.setr("SUBPAGE_LOWER_LEFT_LATITUDE",    30.0)
+Magics.setr("SUBPAGE_LOWER_LEFT_LONGITUDE",  -30.0)
+Magics.setr("SUBPAGE_UPPER_RIGHT_LATITUDE",   65.0)
+Magics.setr("SUBPAGE_UPPER_RIGHT_LONGITUDE",  70.0)
+
+Magics.setc("grib_input_file_name", "../data/z500.grb")
+Magics.grib()
+
+Magics.setc("map_coastline_colour", "khaki")
+Magics.setc('map_coastline_land_shade', 'on')
+Magics.setc('map_coastline_land_shade_colour', 'tan')
+Magics.setc('map_coastline_sea_shade', 'on')
+Magics.setc('map_coastline_sea_shade_colour', 'sky')
+Magics.setc('map_boundaries', 'on')
+Magics.setc('map_boundaries_colour', 'white')
+Magics.setc('map_disputed_boundaries', 'on')
+Magics.setc('map_disputed_boundaries_colour', 'red')
+Magics.setc('map_cities', 'on')
+Magics.setc("map_grid_colour","grey")
+Magics.coast()
+
+Magics.setc("contour",  "on")
+Magics.setc("contour_line_colour","green")
+Magics.cont()
+
+Magics.text()
+ 
+Magics.finalize()
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100755
index 0000000..becb679
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,9 @@
+LIBRARY_REVISION	= @LIBRARY_REVISION@
+LIBRARY_AGE		= @LIBRARY_AGE@
+
+EXTRA_DIST	= \
+		make_attributes \
+		mergexml.pl xml2cc.pl xml2cc_new.pl xml2dtd.pl xml2mv.pl \
+		newdriver.pl magicsCompatibilityChecker mapgen_clip
+
+bin_SCRIPTS	= magicsCompatibilityChecker 
diff --git a/tools/Makefile.in b/tools/Makefile.in
new file mode 100644
index 0000000..0a4f4ac
--- /dev/null
+++ b/tools/Makefile.in
@@ -0,0 +1,508 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = tools
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_base.m4 \
+	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+	$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/autotroll.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/magics_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(bindir)"
+SCRIPTS = $(bin_SCRIPTS)
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN   " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+AXX = @AXX@
+BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
+BOOST_LDFLAGS = @BOOST_LDFLAGS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPLIBS = @CPPLIBS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EMOS_LIB_NAME = @EMOS_LIB_NAME@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLIB = @FLIB@
+FLIBS = @FLIBS@
+FORTRAN_LIB_PATH = @FORTRAN_LIB_PATH@
+GREP = @GREP@
+GRIBAPI_LIBS = @GRIBAPI_LIBS@
+GRIBAPI_ROOT = @GRIBAPI_ROOT@
+GSVersion = @GSVersion@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBNAME = @LIBNAME@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAGICS_3RDPARTY_INCLUDE = @MAGICS_3RDPARTY_INCLUDE@
+MAGICS_3RDPARTY_LIBS = @MAGICS_3RDPARTY_LIBS@
+MAGICS_LIBRARY_AGE = @MAGICS_LIBRARY_AGE@
+MAGICS_LIBRARY_CURRENT = @MAGICS_LIBRARY_CURRENT@
+MAGICS_LIBRARY_REVISION = @MAGICS_LIBRARY_REVISION@
+MAGICS_PACKAGE_COPYRIGHT_PERIOD = @MAGICS_PACKAGE_COPYRIGHT_PERIOD@
+MAGICS_PACKAGE_NAME = @MAGICS_PACKAGE_NAME@
+MAGICS_PACKAGE_RELEASE_DATE = @MAGICS_PACKAGE_RELEASE_DATE@
+MAGICS_PACKAGE_VERSION = @MAGICS_PACKAGE_VERSION@
+MAGICS_PACKAGE_VERSION_ADDENDUM = @MAGICS_PACKAGE_VERSION_ADDENDUM@
+MAGICS_VISIBILITY = @MAGICS_VISIBILITY@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NUMPY_INCLUDE = @NUMPY_INCLUDE@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ODB_PATH = @ODB_PATH@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_REQUIRES = @PKGCONFIG_REQUIRES@
+PKG_CONFIG = @PKG_CONFIG@
+PLATFORM_DEFINES_MARS = @PLATFORM_DEFINES_MARS@
+PSDelegate = @PSDelegate@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+QMAKE = @QMAKE@
+QT_CFLAGS = @QT_CFLAGS@
+QT_CPPFLAGS = @QT_CPPFLAGS@
+QT_CXXFLAGS = @QT_CXXFLAGS@
+QT_DEFINES = @QT_DEFINES@
+QT_INCPATH = @QT_INCPATH@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LFLAGS = @QT_LFLAGS@
+QT_LIBS = @QT_LIBS@
+QT_PATH = @QT_PATH@
+QT_VERSION = @QT_VERSION@
+QT_VERSION_MAJOR = @QT_VERSION_MAJOR@
+RANLIB = @RANLIB@
+RCC = @RCC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHLIB_EXT = @SHLIB_EXT@
+SITE_NAME = @SITE_NAME@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+bufr = @bufr@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+cairo = @cairo@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ghostscript_font_dir = @ghostscript_font_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+metview = @metview@
+mkdir_p = @mkdir_p@
+odb = @odb@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+proj4 = @proj4@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+python = @python@
+pythondir = @pythondir@
+qt = @qt@
+raster = @raster@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spot = @spot@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+LIBRARY_REVISION = @LIBRARY_REVISION@
+LIBRARY_AGE = @LIBRARY_AGE@
+EXTRA_DIST = \
+		make_attributes \
+		mergexml.pl xml2cc.pl xml2cc_new.pl xml2dtd.pl xml2mv.pl \
+		newdriver.pl magicsCompatibilityChecker mapgen_clip
+
+bin_SCRIPTS = magicsCompatibilityChecker 
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu tools/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n' \
+	    -e 'h;s|.*|.|' \
+	    -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+	      if (++n[d] == $(am__install_max)) { \
+		print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+	    else { print "f", d "/" $$4, $$1 } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	     if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	     test -z "$$files" || { \
+	       echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	       $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	     } \
+	; done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	       sed -e 's,.*/,,;$(transform)'`; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binSCRIPTS
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binSCRIPTS install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	uninstall uninstall-am uninstall-binSCRIPTS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tools/magicsCompatibilityChecker b/tools/magicsCompatibilityChecker
new file mode 100755
index 0000000..1996c47
--- /dev/null
+++ b/tools/magicsCompatibilityChecker
@@ -0,0 +1,184 @@
+#!/usr/bin/env python
+#
+# Copyright 2011 European Centre for Medium-Range Weather Forecasts (ECMWF)
+# 
+# Licensed under the Apache License, Version 2.0 (the "License"); 
+# you may not use this file except in compliance with the License. 
+# You may obtain a copy of the License at 
+# 
+# 	http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software 
+# distributed under the License is distributed on an "AS IS" BASIS, 
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+# See the License for the specific language governing permissions and 
+# limitations under the License.
+#
+#
+# This script is provided by the ECMWF Meteorological Visualisation Section as help to identify 
+# potential problems porting programs from using MAGICS 5/6 to Magics++.
+#
+# We do NOT garantee that all issues can be found with this script!!!
+#
+
+import sys
+
+def grep(f):
+
+	lno = 0
+	grib_decoding=0
+	errors=0
+
+	for s in f:
+		lno += 1
+		l = s.upper()
+
+		if "PSETC" in l:
+			if "AXIS_POSITION" in l:
+				if "POSITIONAL" in l:
+					print "line ",lno,"> INFO: default value POSITIONAL is replace with AUTOMATIC"
+					print ""
+			elif "AXIS_TICK_POSITIONING" in l:
+				print "line ",lno,"> INFO: Parameter AXIS_TICK_POSITIONING was undocumented feature of MAGICS6"
+				print ""
+			elif "SUBPAGE_MAP_PROJECTION" in l:
+				if "NONE" in l:
+					print "line ",lno,"> WARNING: You need to set SUBPAGE_MAP_PROJECTION to CARTESIAN for graph plotting."
+					print ""
+			elif "PS_DEVICE" in l:
+				print "line ",lno,"> INFO: Please replace setting of PS_DEVICE by setting 'output_format' to 'ps'"
+				print ""
+			elif "PS_FILE_NAME" in l:
+				print "line ",lno,"> INFO: Please change PS_FILE_NAME to OUTPUT_NAME or OUTPUT_FULLNAME"
+				print ""
+			elif "PS_METRIC" in l:
+				print "line ",lno,"> INFO: Parameter PS_METRIC is not used anymore"
+				print ""
+			elif "TEXT_QUALITY" in l:
+				print "line ",lno,"> INFO: Please set instead of TEXT_QUALITY the new parameters TEXT_FONT and TEXT_FONT_STYLE"
+				print ""
+			elif "PAGE_ID_LINE_QUALITY" in l:
+				print "line ",lno,"> INFO: Please set instead of PAGE_ID_LINE_QUALITY the new parameters PAGE_ID_LINE_FONT and PAGE_ID_LINE_FONT_STYLE"
+				print ""
+			elif "CONTOUR_LABEL_QUALITY" in l:
+				print "line ",lno,"> INFO: Please set instead of CONTOUR_LABEL_QUALITY the new parameters CONTOUR_LABEL_FONT and CONTOUR_LABEL_FONT_STYLE"
+				print ""
+			elif "TEXT_JUSTIFICATION" in l:
+				if "TYPESET" in l:
+					print "line ",lno,"> ERROR: value TYPESET is not allowed anymore for TEXT_JUSTIFICATION"
+					print ""
+			elif "GRAPH_SYMBOL" in l:
+				if "SYMBOLS_ONLY" in l:
+					print "line ",lno,"> ERROR: value SYMBOLS_ONLY is not allowed anymore - please set GRAPH_SYMBOL to ON and"
+					print "line ",lno,"> ERROR:    set GRAPH_LINE_THICKNESS to 0"
+					print ""
+			elif "CONTOUR_METHOD" in l and "CONICON" in l:
+				print "line ",lno,"> INFO: Setting CONICON has no effect anymore. Default contouring used."
+				print ""
+			elif "CONTOUR_LINE_PLOTTING" in l:
+				print "line ",lno,"> ERROR: Setting CONTOUR_LINE_PLOTTING has no effect anymore."
+				print "line ",lno,">        This is also true for all parameters starting CONTOUR_ABOVE_ and CONTOUR_BELOW_."
+				print "line ",lno,">        Please split your contouring or ask Graphics."
+				print ""
+			elif "GRIB_MODE" in l:
+				print "line ",lno,"> INFO: Please remove GRIB_MODE! It has no effect anymore!"
+				print ""
+			elif "GRIB_INPUT_TYPE" in l:
+				if "ARRAY" in l:
+					print "line ",lno,"> ERROR: Please remove GRIB_INPUT_TYPE! GRIB is now only read from files!"
+					print "line ",lno,"> ERROR:    The input through 'ARRAY' is NOT supported anymore!"
+					print "line ",lno,"> ERROR: ",s
+				else:
+					print "line ",lno,"> INFO: You can remove GRIB_INPUT_TYPE! This parameter is ignored - GRIB is now only read from files!"
+					print "line ",lno,"> INFO: ",s
+			elif "GRIB_ACTION" in l:
+				print "line ",lno,"> ERROR: Please remove GRIB_ACTION!"
+				grib_decoding+=1
+				errors+=1
+				print ""
+			elif "GRIB_SUBAREA_EXT" in l:
+				print "line ",lno,"> INFO: Please remove GRIB_SUBAREA_EXTRACTION. It has NO effect anymore."
+				print ""
+			elif "GRIB_TABLE2_ADD" in l:
+				print "line ",lno,"> INFO: Please remove GRIB_TABLE2_ADDRESS_MODE. It has NO effect anymore."
+				print ""
+			elif "WIND_ARROW_LEGEND" in l:
+				print "line ",lno,"> INFO: Please note WIND_ARROW_LEGEND is deprecated and LEGEND should be set instead."
+				print ""
+
+		if "PSETR" in l:
+			if "GRIB_SPECTRAL_RESOLUTION" in l:
+				print "line ",lno,"> ERROR: Please remove GRIB_SPECTRAL_RESOLUTION. Magics++ does NOT handle spectral fields!!!"
+				grib_decoding+=1
+				errors+=1
+				print ""
+			elif "TEXT_REFERENCE_CHARACTER_HEIGHT" in l:
+				print "line ",lno,"> INFO: Please set instead of TEXT_REFERENCE_CHARACTER_HEIGHT the new parameters TEXT_FONT_SIZE"
+				print ""
+			elif "AXIS_BASE_DATE" in l:
+				print "line ",lno,"> INFO: The parameter AXIS_BASE_DATE was an undocumendted feature of MAGICS6."
+				print "line ",lno,"> INFO:  Please make sure that you set your date axis explicit and define dates as strings."
+				print ""
+
+		if "PSETI" in l:
+			if "GRAPH_SMOOTHING_FACTOR" in l:
+				print "line ",lno,"> INFO: Please remove GRAPH_SMOOTHING_FACTOR. It was decided Magics should NOT smooth graphs."
+				print ""
+
+		if "PSET1I" in l:
+			if "GRIB_PRODUCT_BLOCK" in l or "GRIB_GRID_BLOCK" in l or "GRIB_OUTPUT_IMAGE" in l:
+				print "line ",lno,"> ERROR: Please remove lines with GRIB_PRODUCT_BLOCK, GRIB_GRID_BLOCK or GRIB_OUTPUT_IMAGE"
+				grib_decoding+=1
+				errors+=1
+				print ""
+
+		if "PSET1R" in l:
+			if "GRIB_OUTPUT_FIELD" in l:
+				print "line ",lno,"> ERROR: Magics++ does NOT support the saving of Grib arrays - please use GRIB_API"
+				print "line ",lno,">        Please remove lines with GRIB_OUTPUT_FIELD or GRIB_OUTPUT_FIELD_2"
+				grib_decoding+=1
+				errors+=1
+				print ""
+	
+		elif "PPIE" in l:
+			print "line ",lno,"> ERROR: A possible use of Pie charts? << NOT supported in Magics++"
+			print "line ",lno,"> ERROR: ",s
+			print ""
+			errors+=1
+
+		elif "PACT" in l:
+			print "line ",lno,"> ERROR: A possible use of specification groups? << NOT supported in Magics++"
+			print "line ",lno,"> ERROR: ",s
+			print ""
+			errors+=1
+
+		elif "PAPROJ" in l:
+			print "line ",lno,"> ERROR: Internal function of MAGICS6 - undocumented feature << NOT supported in Magics++"
+			print "line ",lno,"> ERROR: ",s
+			print ""
+			errors+=1
+
+	if grib_decoding > 0:
+		print "ERROR: The program used MAGICS 6 to decode GRIB files. This is NOT supported in Magics++!"
+		print "       Please use Grib_API directly for this!\n"
+	
+	if errors > 0:
+		print "ERROR: Your program will in the current form NOT run with Magics++!"
+		print "       Please contact MetVis (magics at ecmwf.int) for more help."
+		print "       Please copy the output of this script to your email.\n"
+		
+
+def main(argv):
+	if len(sys.argv) <= 1:
+		print "You need to give more options ... "
+		return 1
+
+	f = open(sys.argv[1])
+	print "****************************************\nNOTE: This script is given as a guiding help, but\ndoes not guarantee to find all migration issues!\n"
+	print "Checking ",sys.argv[1]," ...\n****************************************"
+	return grep(f)
+	f.close()
+
+
+if __name__ == "__main__":
+	sys.exit(main(sys.argv[1:]))
diff --git a/tools/make_attributes b/tools/make_attributes
new file mode 100755
index 0000000..92ab743
--- /dev/null
+++ b/tools/make_attributes
@@ -0,0 +1,110 @@
+directories='common visualisers drivers decoders'
+for dir in $directories
+do
+        mkdir --parent tools/src/$dir
+done
+
+rm -f all_static.cc
+
+files=' CentreGeoArea.xml
+	Coastlines.xml
+    output.xml
+	CoastPlotting.xml
+	View.xml
+	GridPlotting.xml
+	LabelPlotting.xml
+	Grib.xml
+	Contour.xml
+	IsoPlot.xml
+	Title.xml
+	TextBox.xml
+	TextActionMigration.xml
+	XmlBox.xml
+	TextAction.xml
+	SymbolPlotting.xml
+	SymbolInput.xml
+	SVGDriver.xml
+	SubPage.xml
+    BaseDriver.xml
+	PostScriptDriver.xml
+	OpenGLDriver.xml
+	Page.xml
+	OdbDecoder.xml
+	Obs.xml
+	NetcdfMatrixInterpretor.xml
+	NetcdfInterpretor.xml
+	NetcdfDecoder.xml
+	LevelSelection.xml
+	LevelListSelectionType.xml
+	Layout.xml
+	IsoLabel.xml
+	IsoHighlight.xml
+	IntervalSelectionType.xml
+	Import.xml
+	HiLo.xml
+	HiLoText.xml
+	HiLoTechnique.xml
+	HiLoSave.xml
+	HiLoNumber.xml
+	HiLoMarker.xml
+	GenericSQLDEcoder.xml
+	GDDriver.xml
+	CountSelectionType.xml
+	CornersArea.xml
+	ConicProjection.xml
+	ValuePlot.xml
+	IsoShading.xml
+	Wind.xml
+	ImagePlotting.xml
+	Akima474.xml
+	Akima760.xml
+	Akima761.xml
+	ppm.xml
+	PageID.xml
+	ObsPlotting.xml
+	Legend.xml
+	XmlPage.xml
+	Frame.xml
+	SuperPage.xml
+	CylindricalProjection.xml
+    SatelliteProjection.xml
+	XmlSubPage.xml
+	XmlDecoder.xml
+	XYList.xml
+	TitleTemplate.xml
+	Axis.xml
+	graph_params.xml
+	Histogram.xml
+	XYSystem.xml	
+	InputMatrix.xml
+	Epsgram.xml
+	EpsInput.xml
+	XYTransformation.xml
+	ObsStat.xml
+	Geopoints.xml
+	MetaData.xml
+'
+
+for i in $files
+do
+	echo "found--->" $i
+	perl tools/xml2cc.pl src/xml/$i >> all_static.cc
+done
+
+# copy the attributes files..
+directories='common visualisers drivers decoders'
+for dir in $directories
+do
+        
+	echo "updating--->" $dir
+	for file in `ls tools/src/$dir/*`
+	do		
+	     mv --backup $file src/$dir
+	done
+	rm -f tools/src/$dir/*
+	rmdir tools/src/$dir
+done
+
+mv --backup all_static.cc src/common
+
+
diff --git a/tools/mapgen_clip b/tools/mapgen_clip
new file mode 100755
index 0000000..a7e4edf
--- /dev/null
+++ b/tools/mapgen_clip
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 European Centre for Medium-Range Weather Forecasts (ECMWF)
+# 
+# Licensed under the Apache License, Version 2.0 (the "License"); 
+# you may not use this file except in compliance with the License. 
+# You may obtain a copy of the License at 
+# 
+# 	http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software 
+# distributed under the License is distributed on an "AS IS" BASIS, 
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+# See the License for the specific language governing permissions and 
+# limitations under the License.
+#
+#
+# This script is provided by the ECMWF Meteorological Visualisation Section as help to 
+# clip / reduce size of mapgen data files.
+#
+
+
+import sys
+
+if len(sys.argv) < 6:
+    print "Not enough parameters!"
+    print "mapgen_clip in.mapgen out.mapgen lon_min lon_max lat_min lat_max"
+    sys.exit()
+
+lon_min = float(sys.argv[3])
+lon_max = float(sys.argv[4])
+lat_min = float(sys.argv[5])
+lat_max = float(sys.argv[6])
+
+fin = open(sys.argv[1], 'r')
+fou = open(sys.argv[2], 'w')
+
+begin = ""
+
+for line in fin:
+  if line == "# -b\n":
+    begin=line
+  else:
+    s = line.split()
+    if float(s[0]) > lon_min and float(s[0]) < lon_max:
+     if float(s[1]) > lat_min and float(s[1]) < lat_max:
+      if begin != "":
+        fou.write(begin)
+        begin = ""
+      fou.write(line)
+
+fin.close()
+fou.close()
diff --git a/tools/mergexml.pl b/tools/mergexml.pl
new file mode 100755
index 0000000..58084fe
--- /dev/null
+++ b/tools/mergexml.pl
@@ -0,0 +1,173 @@
+# *****************************************************************************
+# Perl script to automatically merge all the MAGICS++ objects' .xml files
+# into one combined .xml file.
+#
+# Command-line options:
+#   -debug=?  where ? = 0, 1, 2, or 3
+#      This sets the level of debug information that is output.
+#      (0 - none; 1 - important only; 2 - detailed, 3 - very detailed)
+#
+#   -XMLDir='dir' where dir is the directory in which the xml files reside.
+#
+# Remember to use the -s option when calling Perl - eg:
+#   perl -s mergexml.pl -XMLDir='src/xml' -debug=1
+#
+# Description:
+#   
+# Authorship:
+#   Iain Russell, ECMWF
+#   Started:       7th July 2004
+#   Last modified: 14th January 2005
+# *****************************************************************************
+
+
+# ---------------
+# Useful globals
+# ---------------
+
+# $debug             = 2;  # set this to override the command-line option
+
+$strDefaultXMLDir = 'src/xml';  # if no command-line option is specified
+$strMergedFile    = "$XMLDir/magics.xml";
+$strHeader        = "<?xml-stylesheet type='text/css' href='parameter.css'?>";
+$strMagicsBegin   = "<magics>";
+$strMagicsEnd     = "</magics>";
+
+
+# if no user-supplied xml directory, then use the default.
+
+if ($XMLDir eq '')
+{
+    $XMLDir = $strDefaultXMLDir;
+}
+
+
+
+# -------------------------------------------------------------------------
+# Step 0 - determine the output files to create - and open them for writing
+# -------------------------------------------------------------------------
+
+open(MERGED_FILE, ">" . $strMergedFile);     # open for write, overwrite
+
+print MERGED_FILE "$strHeader\n$strMagicsBegin";
+
+
+
+
+# --------------------------------------------------------
+# Step 1 - add each .xml file in the directory
+# --------------------------------------------------------
+
+# Can we read the directory?
+
+if (opendir(DIR,"$XMLDir"))
+{
+	# Yes - examine each file in turn
+
+	while ($file = readdir(DIR))
+	{
+		# only process .xml files, but not magics.xml
+
+		if ( ($file ne "magics.xml") && ($file =~ /.*\.xml/) )
+		{		
+			append_xml ("$XMLDir/$file");
+		}
+	}
+}
+
+else
+{
+	debug_print("Directory $XMLDir cannot be read.\n", 1);
+}
+
+
+# ----------------
+# Step 2 - cleanup
+# ----------------
+
+print MERGED_FILE "\n\n$strMagicsEnd\n";
+
+closedir(DIR);
+
+
+
+
+# ----------------------------------Subroutines ----------------------------------
+
+
+
+
+
+
+
+# *****************************************************************
+# Subroutine : append_xml
+# Appends the given xml data to the merged file
+# Parameter 1 ($_[0]) : the path to the .xml file to append
+# *****************************************************************
+
+sub append_xml
+{
+	# Read the input parameters
+
+	local($file) = $_[0];
+
+	debug_print ("appending $file\n", 2);
+	
+	print MERGED_FILE "\n\n";
+
+
+	# Read the file and parse, line by line
+	# OK, a Perl magician may be able to come up with a more
+	# concise way of doing this, but this method will work.
+
+	open (FILE, $file) || die "cannot open file $file";
+
+	@Lines = <FILE>;
+
+	foreach $line (@Lines)
+	{
+		# don't append the header line(s)
+		
+		if (($line !~ /<\?xml.*/) && ($line !~ /<magics.*/) && ($line !~ /<\/magics.*/))
+		{
+			print MERGED_FILE "$line";
+		}
+	}
+	
+	close(FILE);
+}
+
+# End of subroutine 'append_xml'
+
+
+
+
+
+
+# ******************************************************************
+# Subroutine : debug_print
+# Prints the given string if debug is on
+# Parameter 1 ($_[0]): text to print
+# Parameter 2 ($_[1]): debug level to print it at
+# ******************************************************************
+
+sub debug_print
+{
+	local($text)  = @_[0];
+	local($level) = @_[1];
+
+	# Are we at a high enough debug level to print this text?
+
+	if ($debug >= $level)
+	{
+		print ("$text");
+	}
+}
+
+# End of subroutine 'debug_print'
+
+
+
+
+
diff --git a/tools/newdriver.pl b/tools/newdriver.pl
new file mode 100755
index 0000000..576bf3e
--- /dev/null
+++ b/tools/newdriver.pl
@@ -0,0 +1,536 @@
+#!/usr/bin/perl
+use strict;
+use Time::localtime;
+
+my $driver = @ARGV[0];
+my $class  = "${driver}Driver";
+shift @ARGV;
+my @parents = @ARGV;
+
+my $license_file = '../LICENSE_for_source_files';	# Name the file
+open(INFO, $license_file);				# Open the file
+my @license = <INFO>;					# Read it into an array
+close(INFO);						# Close the file
+
+my $date_string=ctime();
+
+########################################
+# Header file
+########################################
+open STDOUT, ">$class.h";
+print <<"EOF";
+/******************************** LICENSE ********************************
+
+ at license
+
+ ******************************** LICENSE ********************************/
+
+/*!
+    \\file $class.h
+    \\brief Definition of $class.
+    \\author Meteorological Visualisation Section, ECMWF
+
+    Started: $date_string
+*/
+
+#ifndef \_MPP\_$class\_H
+#define \_MPP\_$class\_H
+
+#include <BaseDriver.h>
+#include <${class}Attributes.h>
+#include <XmlNode.h>
+
+namespace magics
+{
+
+/*! \\class $class
+    \\brief This driver produces output for $driver
+    \\ingroup drivers
+
+    This driver ...
+*/
+class ${class}: public BaseDriver, public ${class}Attributes
+{
+
+public:
+	$class();
+	~$class();
+	void open();
+	void close();
+
+	/*!
+	  \\brief sets a new XML node
+	*/
+	void set(const XmlNode& node)
+	{
+/* >>> adopt to your needs
+		if ( magCompare(node.name(), "ps") ||
+		     magCompare(node.name(), "eps") ||
+		     magCompare(node.name(), "pdf") )
+		{
+			XmlNode basic = node;
+			basic.name("driver");
+			BaseDriver::set(basic);
+			basic.name("ps");
+			${class}Attributes::set(basic);
+		}
+  <<< adopt to your needs */
+	}
+
+	/*!
+	  \\brief sets a new map
+	*/
+	void set(const map<std::string, std::string>& map)
+	{
+		BaseDriver::set(map);
+		${class}Attributes::set(map);
+	}
+
+private:
+	MAGICS_NO_EXPORT void startPage() const;
+	MAGICS_NO_EXPORT void endPage() const;
+	MAGICS_NO_EXPORT void project(const Layout& lay) const;
+	MAGICS_NO_EXPORT void unproject() const;
+
+	MAGICS_NO_EXPORT void setNewLineWidth(const float) const;
+	MAGICS_NO_EXPORT void setNewColour(const Colour &col) const;
+	MAGICS_NO_EXPORT int setLineParameters(const LineStyle style, const float w) const;
+
+	MAGICS_NO_EXPORT void renderPolyline(const int, float *, float *) const;
+	MAGICS_NO_EXPORT void renderPolyline2(const int n, float *x, float *y) const;
+	MAGICS_NO_EXPORT void renderSimplePolygon(const int, float *, float *) const;
+	MAGICS_NO_EXPORT void renderText(const Text& text) const;
+	MAGICS_NO_EXPORT void circle(const float x, const float y, const float r, const int) const;
+	MAGICS_NO_EXPORT bool renderPixmap(float,float,float,float,int,int,unsigned char*,int,bool) const;
+	MAGICS_NO_EXPORT bool renderCellArray(const Image& obj) const;
+
+	// $class specific member functions BEGIN
+
+	// $class specific member functions END
+
+	//! Method to print string about this class on to a stream of type ostream (virtual).
+	void print(ostream&) const;
+	MAGICS_NO_EXPORT void debugOutput(const string &s) const;
+
+	//! Copy constructor - No copy allowed
+	$class(const $class&);
+	//! Overloaded << operator to copy - No copy allowed
+	$class& operator=(const $class&);
+
+	// -- Friends
+	//! Overloaded << operator to call print().
+	friend ostream& operator<<(ostream& s,const $class& p)
+		{ p.print(s); return s; }
+};
+
+} // namespace magics
+#endif
+EOF
+close STDOUT;
+
+open STDOUT, ">$class.cc";
+print <<"EOF";
+/******************************** LICENSE ********************************
+
+ at license
+
+ ******************************** LICENSE ********************************/
+
+/*! \\file $class.cc
+    \\brief Implementation of $class.
+    \\author Meteorological Visualisation Section, ECMWF
+
+    Started: $date_string
+
+*/
+
+#include <$class\.h>
+#include <Polyline.h>
+#include <Text.h>
+#include <Image.h>
+
+using namespace magics;
+
+/*!
+  \\brief Constructor
+*/
+$class\::$class() 
+{
+	MagLog::debug() << "$class\::$class needs implementing." <<endl;
+}
+
+/*!
+  \\brief Destructor
+*/
+$class\::~$class() 
+{
+}
+
+/*!
+  \\brief Opening the driver
+*/
+void $class\::open()
+{
+	MagLog::debug() << "$class\::open() needs implementing." <<endl;
+}
+
+/*!
+  \\brief Closing the driver
+*/
+void $class\::close()
+{
+	endPage();
+	currentPage_ = 0;
+
+	MagLog::debug() << "$class\::close() needs implementing." <<endl;
+}
+
+/*!
+  \\brief starting a new page
+
+  This method has to take care that previous pages are closed and that
+  for formats with multiple output files a new file is set up.
+*/
+MAGICS_NO_EXPORT void $class\::startPage() const
+{
+	if(currentPage_ > 0) endPage();
+
+	MagLog::debug() << "$class\::startPage needs implementing." <<endl;
+	
+	currentPage_++;
+	newPage_ = true;
+}
+
+/*!
+  \\brief ending a page
+ 
+  This method has to take care that for formats with multiple output 
+  files are closed.
+*/
+MAGICS_NO_EXPORT void $class\::endPage() const
+{
+	MagLog::debug() << "$class\::endPage needs implementing." <<endl;
+}
+
+/*!
+  \\brief project to a new Layout
+
+  This method will update the offset and scale according to the new Layout given.
+
+  \\sa Layout
+*/
+MAGICS_NO_EXPORT void $class\::project(const magics::Layout& layout) const
+{
+	MagLog::debug() << "$class\::project needs implementing." <<endl;
+}
+
+/*!
+  \\brief reproject out of the last Layout
+
+  This method will update the offset and scale to the state they were before the
+  last Layout was received.
+
+*/
+MAGICS_NO_EXPORT void $class\::unproject() const
+{
+	MagLog::debug() << "$class\::unproject needs implementing." <<endl;
+}
+
+
+/*!
+  \\brief sets a new colour
+
+  This colour stays the default drawing colour until the painting in the 
+  current box is finished.
+
+  \\sa Colour
+*/
+MAGICS_NO_EXPORT void $class\::setNewColour(const Colour &colour) const
+{
+	if(currentColour_ == colour) return;
+	currentColour_ = colour;
+	MagLog::debug() << "$class\::setNewColour needs checking." <<endl;
+}
+
+/*!
+  \\brief sets a new line width
+
+  This line width stays the default width until the painting in the 
+  current box is finished.
+
+  \\sa setLineParameters()
+*/
+MAGICS_NO_EXPORT void $class\::setNewLineWidth(const float width) const
+{
+	currentLineWidth_ = width;
+	MagLog::debug() << "$class\::setNewColour needs checking." <<endl;
+}
+
+/*!
+  \\brief sets new properties of how lines are drawn
+
+  These properties stay the default until the painting in the 
+  current box is finished.
+
+  \\sa LineStyle
+
+  \\param linestyle Object describing the line style
+  \\param w width of the line
+
+*/
+MAGICS_NO_EXPORT int $class\::setLineParameters(const LineStyle linestyle, const float w) const
+{
+	setNewLineWidth(w);
+
+	MagLog::debug() << "$class\::setLineParameters needs implementing." <<endl;
+	return 0;
+}
+
+/*!
+  \\brief renders polylines
+
+  This method renders a polyline given as two float arrays. The two 
+  arrays given as X and Y values have to be at least the length of
+  <i>n</i>. All values beyond <i>n</i> will be ignored. The style is
+  determined by what is described in the current LineStyle.
+
+  \\sa setLineParameters()
+  \\param n number of points
+  \\param x array of x values
+  \\param y array of y values
+*/
+MAGICS_NO_EXPORT void $class\::renderPolyline(const int n, float *x, float *y) const
+{
+	MagLog::debug() << "$class\::renderPolyline needs implementing." <<endl;
+}
+
+/*!
+  \\brief renders a single line
+
+  This method renders a polyline with two points.The style is
+  determined by what is described in the current LineStyle.
+
+  \\sa setLineParameters()
+  \\param n number of points
+  \\param x array of x values
+  \\param y array of y values
+*/
+MAGICS_NO_EXPORT void $class\::renderPolyline2(const int n, float* x, float* y) const
+{
+	MagLog::debug() << "$class\::renderPolyline2 needs implementing." <<endl;
+}
+
+/*!
+  \\brief renders a filled polygon
+
+  This method renders a filled polygon. The style is
+  determined by what is described in the current LineStyle.
+
+  \\sa setLineParameters()
+  \\param n number of points
+  \\param x array of x values
+  \\param y array of y values
+*/
+MAGICS_NO_EXPORT void $class\::renderSimplePolygon(const int n, float* x, float* y) const
+{
+	MagLog::debug() << "$class\::renderSimplePolygon needs implementing." <<endl;
+}
+
+/*!
+  \\brief renders text strings
+
+  This method renders given text strings.
+
+  \\note As of version 2.0 there are two forms of describing text in Text.
+
+  \\sa Text
+  \\param text object containing the strings and their description
+*/
+MAGICS_NO_EXPORT void $class\::renderText(const Text& text) const
+{
+	if(text.empty()) return;
+	MagLog::debug() << "$class\::renderText needs implementing." <<endl;
+}
+
+/*!
+  \\brief drawing a circle
+
+  This method renders given text strings.
+
+  The meaning of the last parameter <i>s</i> is as follows:
+     - 0-8 determines how many quarters of the circle are filled. Starting from the top clock-wise.
+     - 9 fills the whole circle but leaves a vertical bar empty in the middle of the circle.
+
+  \\param x X Position
+  \\param y Y Position
+  \\param r Radius of circle
+  \\param s Style which determines how the circle is shaded
+*/
+MAGICS_NO_EXPORT void $class\::circle(const float x, const float y, const float r, const int s) const
+{
+	MagLog::debug() << "$class\::circle needs implementing." <<endl;
+}
+
+/*!
+  \\brief render pixmaps
+
+  This method renders pixmaps. These are used for cell shading and raster input (GIFs and PNGs).
+
+  \\sa renderCellArray()
+
+  \\param x0 x of lower corner
+  \\param y0 y of lower corner
+  \\param x1 x of higher corner
+  \\param y1 y of higher corner
+  \\param w width of pixmap
+  \\param h height of pixmap
+  \\param pixmap contents
+  \\param landscape says if contents is landscape
+
+*/
+MAGICS_NO_EXPORT bool $class\::renderPixmap(float x0,float y0,float x1,float y1,
+                                            int w,int h,unsigned char* pixmap,int landscape, bool) const
+{
+	MagLog::debug() << "$class\::renderPixmap needs implementing." <<endl;
+	return true;
+}
+
+/*!
+  \\brief render cell arrays
+
+  This method renders cell arrays, also called images in Magics language. These are 
+  mainly used for satellite data.
+
+  \\sa renderPixmap()
+
+  \\param image Object containing an image
+*/
+MAGICS_NO_EXPORT bool $class\::renderCellArray(const Image& image) const
+{
+	MagLog::debug() << "$class\::renderCellArray needs implementing." <<endl;
+	return true;
+}
+
+
+
+/*!
+  \\brief prints debug output
+
+  When Magics++ is compiled in debug mode these extra strings are printed.
+
+  \\note This can increase file and MagLog file sizes if you run Magics++ in debug mode!
+
+  \\param s string to be printed
+*/
+MAGICS_NO_EXPORT void $class\::debugOutput(const std::string &s) const
+{
+	MagLog::debug() << s << endl;
+}
+
+/*!
+  \\brief class information are given to the output-stream
+*/
+void $class\::print(ostream& out)  const
+{
+	out << "$class\[";
+	out << "]";
+}
+
+static SimpleObjectMaker<${class}, BaseDriver> ${driver}_driver("${driver}");
+
+EOF
+
+close STDOUT;
+
+##############################################
+# XML attribute file
+##############################################
+open STDOUT, ">$class.xml";
+print <<"EOF";
+<?xml-stylesheet type='text/css' href='parameter.css'?>
+<!--
+ ******************************** LICENSE ********************************
+ 
+ at license
+
+ ******************************** LICENSE ********************************
+-->
+<magics>
+<class name='$class' action='$driver' directory='drivers' inherits='BaseDriver'>
+	<documentation>
+		These are the attributes of the $driver output driver. This driver is still in the developing stage! 
+	</documentation>
+<!--
+	<parameter name='' from='string' to='string' member='' default='' xml=''>
+            <documentation></documentation>
+        </parameter>
+-->
+</class>
+</magics>
+
+EOF
+
+close STDOUT;
+
+##############################################
+# Further action file !!!
+##############################################
+open STDOUT, ">$class.todo";
+print <<"EOF";
+
+
+
+src/common/OutputHandler.cc
+===========================
+
+For each format supported by your driver add
+
+#ifdef MAGICS_$driver
+static SimpleObjectMaker<${driver}OutputFactory, OutputFactory> format("format");
+#endif
+
+src/common/OutputFactory.h
+==========================
+
+For each format supported by your driver add
+
+#ifdef MAGICS_${driver}
+class ${driver}OutputFactory : public OutputFactory
+{
+public:
+	${driver}OutputFactory() {}
+	virtual ~${driver}OutputFactory() {}
+	
+	virtual OutputFactory* clone() const
+	{
+		return new ${driver}OutputFactory();
+	}
+	virtual void set(DriverManager&, const XmlNode&); 
+};
+#endif
+
+src/common/OutputFactory.cc
+===========================
+
+#ifdef MAGICS_${driver}
+#include "${class}.h"
+void ${driver}OutputFactory::set(DriverManager& magics, const XmlNode& node)
+{
+	
+	${class}* driver = new ${class}();
+	driver->set(node);
+	magics.push_back(driver);
+}
+#endif
+
+
+CONFIG & MAKEFILES:
+===================
+
+./src/drivers/Makefile.am  -  add driver (possibly with conditional)
+
+./configure.ac  -  If you want a conditional you need to add this code
+
+EOF
+
+close STDOUT;
diff --git a/tools/xml2cc.pl b/tools/xml2cc.pl
new file mode 100644
index 0000000..88d53fd
--- /dev/null
+++ b/tools/xml2cc.pl
@@ -0,0 +1,797 @@
+#!/usr/bin/perl
+#test juanjo
+
+use XML::Parser;
+use Time::localtime;
+
+my $file = shift;
+my $dir = shift;
+my $Author="MagicsTeam";
+my $ecmwf="http://wms.ecmwf.int";
+my $info = {};
+my $element = {};
+
+my %direct = {
+    "int" => "ParameterManager::getInt",
+    "float" => "ParameterManager::getDouble",
+    "string" => "ParameterManager::getString",
+};
+
+my %basetype = (
+    "int" => 1,
+    "float" => 1,
+    "string" => 1,
+    "bool"=>1,
+    "floatarray" =>1,
+    "stringarray" => 1,
+    "intarray" => 1, 
+    "LineStyle" =>1,
+    "ListPolicy" =>1,
+    "Hemisphere" =>1,
+    "ArrowPosition" => 1,
+    "Justification" => 1,
+    "DisplayType" => 1,
+    "OpenGLDriverObserverPtr" => 1,
+    "Widget" =>1, 
+    "cairo_t" =>1, 
+    "Matrix" => 1,
+    "GribHandlePtr" =>1,
+    "QGraphicsScenePtr" => 1,
+    "QWidgetPtr" => 1,
+);
+
+my %magtype = (
+	"float" =>'double',
+);
+
+my %classtype = (
+	"Colour" =>1,
+);
+
+my %arraytype = (
+	"floatarray" => "atof(data)",
+	"stringarray" => "data",
+	"intarray" => "atoi(data)",
+);
+
+my %quote = (
+    "string" => 1,
+);
+
+sub parse
+{
+    my $def = shift;
+    my $node = shift;   
+   
+    while ( defined ( $element = shift @{ $node } ) )
+    {
+       
+        my $child = shift @{ $node };
+        if ( ref $child )
+        {
+           my $attr = \%{ shift @{ $child } };
+           my $name = $attr->{name};
+           
+           if ($name ne "") 
+           {
+               
+               $def->{$element}->{$name} = {};
+               my $list = $element . "_list";
+               push( @{$def->{$list}}, $name);
+               foreach my $a (keys %{$attr}) 
+               {
+                   $def->{$element}->{$name}->{attributes}->{$a} = $attr->{$a}; 
+                  
+               }
+               parse($def->{$element}->{$name}, $child); 
+               
+           }
+           else
+           {
+                   $def->{$element} = {};
+                   foreach my $a (keys %{$attr}) 
+                   {
+                        $def->{$element}->{attributes}->{$a} = $attr->{$a};
+                       
+                   }
+                   parse($def->{$element}, $child); 
+           }
+        }
+        else 
+        {
+         
+          $def->{data} = $child;
+        }
+    }   
+}
+
+
+
+
+
+my $xml= new XML::Parser(Style=>"Tree");
+  
+parse ($info, $xml->parsefile($file));
+
+foreach my $object (keys %{$info->{magics}->{class}}) 
+{
+   
+    $current = $info->{magics}->{class}->{$object};
+    $directory = $info->{magics}->{class}->{$object}->{attributes}->{directory};
+    
+
+######################################################
+#####                Include file
+
+    open STDOUT, ">$dir/$directory/$object\Attributes.h";
+
+    my $string =  ctime();
+    print  <<EOF;
+
+/*! \\file $object\Attributes.h
+    \\brief Definition of $object Attributes class.
+    This file is automatically generated.
+    Do Not Edit!
+    
+    Magics Team - ECMWF 2004
+   
+    Created: $string
+    
+*/
+   
+
+#ifndef $object\Attributes_H
+#define $object\Attributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+EOF
+    my $includes = {};
+    my @impl=split(/\//, $current->{attributes}->{implements});
+    my @interfaces = (split(/\//, $current->{attributes}->{interface}), @impl);
+    foreach $i (@impl) 
+    {
+        
+        print "#include \"$i.h\"\n";
+    }
+    
+    my $parent ='';
+    my $sep = ":";
+    foreach $interface (@interfaces) 
+    {
+        
+        $parent="$parent$sep public $interface";
+        $sep = ", " 
+    }
+    
+    
+    foreach my $param (@{$current->{parameter_list}}) 
+    {   
+       my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+       my $to = $current->{parameter}->{$param}->{attributes}->{to};
+       my $include = $current->{parameter}->{$param}->{attributes}->{include};
+       
+       if ( !$basetype{$to} )
+       {
+            if   ($include eq "" ) {
+                $includes->{"$to.h"} = "ok";
+            }
+            else 
+            {
+                $includes->{$include} = "ok";
+            }    
+        }
+     
+    }
+    foreach my $include (keys %{$includes} ) 
+    {
+          print "#include \"$include\"\n"; 
+    }
+    
+    print "\n";
+  
+    
+    my $template = $current->{attributes}->{template_attributes};
+    my $class = "$object\Attributes";
+    my $line = "";
+    if ( $template ne "" ) {
+        $line = "template <class $template>";
+        $class = "$object\Attributes<$template>";
+        
+    }
+    
+    print <<EOF;
+namespace magics {
+
+class XmlNode;
+
+
+$line
+class $object\Attributes $parent
+{
+public:
+//  --  constructor
+    $object\Attributes();
+    
+//  --  destructor
+    virtual ~$object\Attributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const $object\Attributes&);
+    
+    void setTag(const string& tag) { tag_ = tag; }
+   
+    
+EOF
+    my $xml_data = $current->{attributes}->{xml_data};
+    if ($xml_data eq '' ) {
+        print <<EOF;
+    void setXmlData(const string&)  {}
+EOF
+    }
+    else {
+    	my $to = $current->{parameter}->{$xml_data}->{attributes}->{to};
+    	my $member = $current->{parameter}->{$xml_data}->{attributes}->{member};
+    	if ( $arraytype{$to} ) {    		
+    		print("\tvoid setXmlData(const string& data)  { $member\_.push_back($arraytype{$to}); } \n");
+    	}
+    	else {
+    		print("\tvoid setXmlData(const string& data)  { $member\_ = data; }\n");
+    	}
+    }
+    
+   
+    
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        $to = "$to<$tpl> " unless $tpl eq "";
+       
+        my $value = lc $member;
+        my $method = ucfirst $member;
+        
+        print <<EOF;
+/*!
+ *   Magics Information:
+ *     - Parameter name: $name 
+ *     - Default: $default
+ */
+EOF
+    my $magto = $to;
+    $magto = $magtype{$magto} if $magtype{$magto};
+    
+
+    if ( $basetype{$to} ) 
+    { 
+        print <<EOF;   
+	void set$method($magto $value) 
+		{ $member\_ =  $value; } 
+	$magto get$method() const 
+		{ return $member\_; } 
+        
+EOF
+    }
+    else
+    {
+        print <<EOF;   
+	void set$method($to* $value) 
+		{ auto_ptr<$to> tmp($value); $member\_ = tmp; } 
+	const $to&  get$method() const 
+		{ return *$member\_; }
+     
+EOF
+    }
+    
+    }
+
+    print <<EOF;
+    virtual void toxml(ostream& out, int tabs = 0) const { toxml(out, tag_, tabs); }
+    
+protected:
+//  --  method
+	virtual void print(ostream&) const;
+	
+	virtual void toxml(ostream&, const string&, int tabs) const;
+
+//  --  members:
+	string tag_;
+EOF
+     
+     print "\tstring $xml_data\_;\n" unless $xml_data eq ''; 
+     foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        $to = "$to<$tpl> " unless $tpl eq "";
+        
+        if ( $magtype{$to}  )
+        { 
+            print "\t$magtype{$to} $member\_;\n";
+        }
+        elsif ( $basetype{$to} ) 
+        { 
+            print "\t$to $member\_;\n";
+        }
+        else 
+        {
+            print "\tauto_ptr<$to> $member\_;\n";  
+        }
+    }
+
+print <<EOF;   
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const $class& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+EOF
+
+    if ( $template ne "" ) {
+        print "#include \"$object\Attributes.cc\" \n";
+    }
+    
+    print "\n#endif\n";
+ 
+    close STDOUT;
+    
+#####                Include file
+######################################################
+
+######################################################
+#####                Source file
+
+    open STDOUT, ">$dir/$directory/$object\Attributes.cc";
+    
+ 
+    print  <<EOF;
+/*! \\file $object\Attributes.cc
+    \\brief Implemtation of $object Attributes class.
+    This file is automatically generated.
+    Do Not Edit!
+    
+    Magics Team - ECMWF 2004
+   
+    Created: $string
+    
+*/    
+
+    
+#include "$object\Attributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "Translator.h"
+#include "XmlNode.h"
+
+using namespace magics;
+
+EOF
+   $header = "";
+    $p = "";
+   if ( $template ne "" ) {
+        $header = "template <class $template>";
+        $p = "<P>";
+    }
+    
+    my $count = 0;
+    
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        next if $todo eq 'no';
+        next if $tpl  ne "";
+        $count++;
+    }
+    
+    my $subclass = ":";
+    $subclass = "" if $count eq 0; 
+    
+    print "$header\n$object\Attributes$p\::$object\Attributes()$subclass"; 
+    my $sep = ""; 
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $constant= $current->{parameter}->{$param}->{attributes}->{constant};
+        next if $tpl ne "";
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+        print "$to\n";
+        if ($constant eq "yes" ) 
+        {
+            if ($direct{$to}) {
+                print "$direct{$to}\n";
+            }
+            else {
+        	    print "$sep\n\t$member\_(Translator<$from, $magto>()(\"$default\"))"; 
+            }
+        }
+        else {
+            if ($direct{$to}) {
+                print "$direct{$to}\n";
+            }
+            else {
+        	    print "$sep\n\t$member\_(Translator<$from, $magto>().magics(\"$name\"))"; 
+            }
+        }
+		$sep = ",";
+        
+        
+    }
+	print "\n";
+    print <<EOF;
+{
+EOF
+   foreach  my $param (@{$current->{parameter_list}}) 
+    {   
+    	my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        next if $tpl eq "";
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $method = ucfirst $member;
+        
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+        print "\n\tTranslator<string, $magto> $member;\n";
+        print "\tset$method($member.magics(\"$name\"));\n";
+       
+		
+   }
+   print <<EOF;
+} 
+
+
+$header
+$object\Attributes$p\::~$object\Attributes()
+{
+}
+
+$header    
+EOF
+	$val = 0;
+	  my $code = "";
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $xml = $current->{parameter}->{$param}->{attributes}->{xml};
+        
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+      
+        my $method = ucfirst $member;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+
+        if ( $basetype{$to} ) 
+        {
+        	$code = "$code\tval = params.find(\"$name\");\n";
+        	$code = "$code\tif ( val != params.end() ) { \n";
+            $code = "$code\t\tset$method(Translator<string, $magto>()(val->second));\n"; 
+            $code = "$code\t}\n";
+        }
+        elsif ( $to eq 'Colour')
+        {
+           $code = "$code\tval = params.find(\"$name\");\n";
+           $code = "$code\tif ( val != params.end() ) { \n";
+           $code = "$code\t\t$magto* $member = Translator<string, $magto>()(val->second);\n";
+           $code = "$code\t\tset$method($member);\n";
+           #print "\t\t$member->set(params);\n";
+           
+		   $code = "$code\t}\n";
+           
+        }
+       
+      
+        if ( $xml ne "" && $xml ne $name) {
+        	
+            	#print "\t\tMagLog::info() << \"Parameter $name set to \" << val->second << \"\\n\"; \n";
+        	if ( $basetype{$to} ) 
+            { 
+            	
+          		$code = "$code\tval = params.find(\"$xml\");\n";
+            	$code = "$code\tif ( val != params.end() ) { \n";
+                 $code = "$code\t\tset$method(Translator<string, $magto>()(val->second));\n"; 
+                 $code = "$code\t}\n";
+            }
+            elsif ( $to eq 'Colour')   {
+            	$code = "$code\tval = params.find(\"$xml\");\n";
+            	$code = "$code\tif ( val != params.end() ) { \n";
+               $code = "$code\t\t$magto* $member = Translator<string, $magto>()(val->second);\n";
+           	   $code = "$code\t\tset$method($member);\n";
+           	   #print "\t\t$member->set(params);\n";
+           	   $code = "$code\t}\n";
+            }
+            
+            
+        }
+       
+    }
+        
+ if ($code eq "") {
+ 	print "void $object\Attributes$p\::set(const std::map<string, string>&)\n{\n}\n";
+ }
+ else {
+ 	print "void $object\Attributes$p\::set(const std::map<string, string>& params)\n{\n";
+ 	print "\tstd::map<string, string>::const_iterator val;\n\n";
+ 	print "$code}\n"
+ } 
+ 
+ 
+     
+ 
+
+        	
+print  <<EOF;
+$header
+void $object\Attributes$p\::copy(const $object\Attributes& other)
+{
+EOF
+
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $xml = $current->{parameter}->{$param}->{attributes}->{xml};
+         my $xml_data = $current->{attributes}->{xml_data};
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        my $method = ucfirst $member;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+        
+        if ( $basetype{$to} ) 
+        {         	
+             print "\t$member\_ = other.$member\_;\n"; 
+        }
+        else 
+        {
+           print "\tset$method(other.$member\_->clone());\n";          
+        }
+       
+        print "";
+       
+        
+    }
+     print  <<EOF;
+} 
+
+$header
+void $object\Attributes$p\::set(const XmlNode& node)
+{
+	set(node.attributes());
+EOF
+	if ($xml_data ne '') {
+		print "\n\tfor (XmlNode::DataIterator data = node.firstData(); data != node.lastData(); ++data)\n";
+		print "\t\tsetXmlData(*data);\n";	
+	}
+	print "\n";
+	print "\tfor (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {\n";
+    		foreach  my $param (@{$current->{parameter_list}}) {
+    			 my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+    			next if $todo eq 'no';
+    			my $to = $current->{parameter}->{$param}->{attributes}->{to};
+    			next if $basetype{$to};
+    			next if $classtype{$to};
+    			my $member = $current->{parameter}->{$param}->{attributes}->{member};
+    			my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+    			$to = "$to<$tpl> " unless $tpl eq "";
+    			my $magto = $to;
+        		my $method = ucfirst $member;
+        		$magto = $magtype{$to} if $magtype{$to};
+    			
+    			print "\t\ttry {\n";
+    			print "\t\t\t$magto* $member = Translator<string, $magto>()((*elt)->name());\n";
+    			print "\t\t\t$member->set(*(*elt));\n";
+                print "\t\t\tset$method($member);\n";
+    			print "\t\t}\n";
+    			print "\t\tcatch (NoFactoryException& e) {}\n";
+       
+    	}
+    
+	
+
+print <<EOF; 		
+	}
+}
+$header
+void $object\Attributes$p\::print(ostream& out)  const
+{
+	out << "$object\Attributes[";
+EOF
+    $sep = "";
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+         my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+       
+       
+        $to = "$to<$tpl> " unless $tpl eq "";
+        $print = "$member\_";
+        $print = "*$member\_" unless  $basetype{$to} ;
+        
+        print "\tout << \"$sep$member = \" << $print;\n"; 
+        
+        $sep = ", ";
+        
+    }
+        
+    print "\tout << \"]\" << \"\\n\";\n";
+    print "}\n\n";
+    print <<EOF; 
+$header
+void $object\Attributes$p\::toxml(ostream& out, const string& tag, int tabs)  const
+{
+	string tab;
+	for ( int t = 0; t < tabs; t++) tab = tab + "\t";
+	
+	out << tab << "<" << tag << "\\n";
+EOF
+    $sep = " ";
+     my $calls = "";
+    
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $xml = $current->{parameter}->{$param}->{attributes}->{xml};
+         $xml = $name if $xml eq '';
+         my $xml_data = $current->{attributes}->{xml_data};
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        my $method = ucfirst $member;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+       
+        if ( $basetype{$to}  ) 
+        {         	
+             print "\tout << tab << \"\\t$xml = \\\'\" << $member\_ << \"\\\'\\n\";\n"; 
+        }
+        elsif ( $classtype{$to} ) {
+        	print "\tout << tab << \"\\t$xml = \\\'\" << *$member\_ << \"\\\'\\n\";\n"; 
+        }
+        else {
+        	 $calls = "$calls \t$member\_->toxml(out, tabs+1);\n";
+        	
+        }
+       
+        
+      
+        print "";
+
+    }
+    print "\tout << tab << \">\";\n\n";
+    print $calls;
+    
+    print "\n\tout << tab << \"</\" << tag << \">\\n\";\n";
+
+  
+        
+    
+    print "}\n\n";
+    
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {     
+         my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $migration = $current->{parameter}->{$param}->{migration}->{data};
+        $from = $magtype{$from} if $magtype{$from};
+        
+        
+        $default = "\"$default\"" if  $quote{$from} ;
+     
+        print <<EOF
+static MagicsParameter<$from> $name("$name", $default, "$migration");
+EOF
+        
+    }
+   
+ 
+        
+    
+       
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {     
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+       
+       
+        foreach  my $option (@{$current->{parameter}->{$param}->{option_list}}) { 
+        	my $include = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{include};
+        	my $template = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+        	my @templates = split("/", $template);
+        	foreach my $t (@templates) { 
+        		$includes_static->{$param}->{"$t.h"} = "$t.h";
+        	}
+        	$includes_static->{$param}->{$include} = $include unless $include eq "";
+        }
+       foreach  my $include (keys %{$includes_static->{$param}}) 
+    	{     
+        	print "#include \"$include\"\n";
+    	} 
+      
+        foreach  my $option (@{$current->{parameter}->{$param}->{option_list}}) { 
+        	my $class = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{name};
+        	my $include = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{include};
+        	my $fortran = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{fortran};
+        	my $template = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+        	my $xml = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{xml};
+        	my $base = $current->{parameter}->{$param}->{attributes}->{to};  
+        	my $templates = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+        	if ($template eq "") {
+        	print "static SimpleObjectMaker<$class, $base> $fortran\_$class(\"$fortran\");\n" if $fortran ne "";
+        	print "static SimpleObjectMaker<$class, $base> $xml\_$class(\"$xml\");\n" if $xml ne "" && $xml ne $fortran;
+        	}
+        	else {
+        		my @templates = split("/", $template);	
+        		for my $t (@templates) {
+        			print "static SimpleObjectMaker<$class<$t>, $base<$t> > $fortran\_$class\_$t(\"$fortran\");\n" if $fortran ne "";
+        	        print "static SimpleObjectMaker<$class<$t>, $base<$t> > $xml\_$class\_$t(\"$xml\");\n" if $xml ne "" && $xml ne $fortran;
+        		}
+        	}
+        }
+       
+    }
+}
+
+
diff --git a/tools/xml2cc_new.pl b/tools/xml2cc_new.pl
new file mode 100644
index 0000000..7b2f485
--- /dev/null
+++ b/tools/xml2cc_new.pl
@@ -0,0 +1,780 @@
+#!/usr/bin/perl
+
+use XML::Parser;
+use Time::localtime;
+
+my $file  = shift;
+my $dir   = shift;
+my $nosubdir = shift;
+
+my $Author="MagicsTeam";
+my $ecmwf="http://wms.ecmwf.int";
+my $info = {};
+my $element = {};
+
+
+my %basetype = (
+    "int" => 1,
+    "float" => 1,
+    "string" => 1,
+    "bool"=>1,
+    "floatarray" =>1,
+    "stringarray" => 1,
+    "intarray" => 1, 
+    "LineStyle" =>1,
+    "ListPolicy" =>1,
+    "Hemisphere" =>1,
+    "ArrowPosition" => 1,
+    "AxisAutomaticSetting" => 1,
+    "Justification" => 1,
+    "DisplayType" => 1,
+    "OpenGLDriverObserverPtr" => 1,
+    "Widget" =>1, 
+    "cairo_t*" =>1,
+    "QWidget*" =>1,
+    "QGraphicsScene*" => 1,
+    "Matrix" => 1,
+    "GribHandlePtr" =>1,  
+);
+
+my %translator = (
+    "int" => "ParameterManager::getInt",
+    "float" => "ParameterManager::getDouble",
+    "string" => "ParameterManager::getString",
+    "stringarray" => "ParameterManager::getStringArray",
+    "bool" => "ParameterManager::getBool",
+    "doublearray" => "ParameterManager::getDoubleArray",
+    "floatarray" => "ParameterManager::getDoubleArray",
+    "intarray" => "ParameterManager::getIntArray"
+    
+);
+my %magtype = (
+	"float" =>'double',
+);
+my %consttype = (
+	"string" =>'const string&',
+);
+
+my %classtype = (
+	"Colour" =>1,
+	"DateTime" =>1,
+	"Path" => 1
+);
+
+my %arraytype = (
+	"floatarray" => "atof(data)",
+	"stringarray" => "data",
+	"intarray" => "atoi(data)",
+);
+
+my %quote = (
+    "string" => 1,
+);
+
+sub parse
+{
+    my $def = shift;
+    my $node = shift;   
+   
+    while ( defined ( $element = shift @{ $node } ) )
+    {
+       
+        my $child = shift @{ $node };
+        if ( ref $child )
+        {
+           my $attr = \%{ shift @{ $child } };
+           my $name = $attr->{name};
+           
+           if ($name ne "") 
+           {
+               
+               $def->{$element}->{$name} = {};
+               my $list = $element . "_list";
+               push( @{$def->{$list}}, $name);
+               foreach my $a (keys %{$attr}) 
+               {
+                   $def->{$element}->{$name}->{attributes}->{$a} = $attr->{$a}; 
+                  
+               }
+               parse($def->{$element}->{$name}, $child); 
+               
+           }
+           else
+           {
+                   $def->{$element} = {};
+                   foreach my $a (keys %{$attr}) 
+                   {
+                        $def->{$element}->{attributes}->{$a} = $attr->{$a};
+                       
+                   }
+                   parse($def->{$element}, $child); 
+           }
+        }
+        else 
+        {
+         
+          $def->{data} = $child;
+        }
+    }   
+}
+
+
+my $license_file = '../../LICENSE_for_source_files';		# Name the file
+open(INFO, $license_file);									# Open the file
+my @license = <INFO>;								# Read it into an array
+close(INFO);										# Close the file
+
+
+my $xml= new XML::Parser(Style=>"Tree");
+  
+parse ($info, $xml->parsefile($file));
+
+foreach my $object (keys %{$info->{magics}->{class}}) 
+{
+    $current = $info->{magics}->{class}->{$object};
+    $directory = $info->{magics}->{class}->{$object}->{attributes}->{directory};
+    $tag = $info->{magics}->{class}->{$object}->{attributes}->{xmltag};
+
+    my $location;
+    if( defined $nosubdir and $nosubdir eq "nosubdir" ) { 
+        $location  = $dir; 
+    }
+    else { 
+        $location  = "$dir/$directory"; 
+    }
+        
+######################################################
+#####                Include file
+
+    open STDOUT, ">$location/$object\Attributes.h";
+
+    my $string =  ctime();
+    print  <<EOF;
+/*******************************  LICENSE  *******************************
+
+ at license
+
+ *******************************  LICENSE  *******************************/
+
+/*! \\file $object\Attributes.h
+    \\brief Definition of $object Attributes class.
+    \\author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+
+    Generated: $string
+*/
+   
+
+#ifndef $object\Attributes_H
+#define $object\Attributes_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+
+EOF
+    my $includes = {};
+    my @impl=split(/\//, $current->{attributes}->{implements});
+    my @prefixs=split(/\//, $current->{attributes}->{prefix});
+   
+    my @interfaces = (split(/\//, $current->{attributes}->{interface}), @impl);
+    
+    foreach $i (@impl) 
+    {
+        
+        print "#include \"$i.h\"\n";
+    }
+    
+    my $parent ='';
+    my $sep = ":";
+    foreach $interface (@interfaces) 
+    {
+        
+        $parent="$parent$sep public $interface";
+        $sep = ", " 
+    }
+    
+    
+    foreach my $param (@{$current->{parameter_list}}) 
+    {   
+       my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+       my $to = $current->{parameter}->{$param}->{attributes}->{to};
+       my $include = $current->{parameter}->{$param}->{attributes}->{include};
+       
+       if ( !$basetype{$to} )
+       {
+            if   ($include eq "" ) {
+                $includes->{"$to.h"} = "ok";
+            }
+            else 
+            {
+                $includes->{$include} = "ok";
+            }    
+        }
+     
+    }
+    foreach my $include (keys %{$includes} ) 
+    {
+          print "#include \"$include\"\n"; 
+    }
+    
+    print "\n";
+  
+    
+    my $template = $current->{attributes}->{template_attributes};
+    my $class = "$object\Attributes";
+    my $line = "";
+    if ( $template ne "" ) {
+        $line = "template <class $template>";
+        $class = "$object\Attributes<$template>";
+        
+    }
+    
+    print <<EOF;
+namespace magics {
+
+class XmlNode;
+
+
+$line
+class $object\Attributes $parent
+{
+public:
+//  --  constructor
+    $object\Attributes();
+    
+//  --  destructor
+    virtual ~$object\Attributes();
+    
+    virtual void set(const std::map<string, string>&);
+    virtual void set(const XmlNode&);
+    virtual void copy(const $object\Attributes&);
+    virtual bool accept(const string&);
+
+    void setTag(const string& tag) { tag_ = tag; }
+
+EOF
+    
+
+
+    
+print <<EOF;
+	
+
+public:
+	//  --  method
+	virtual void print(ostream&) const;
+	virtual void toxml(ostream& out) const;
+	//  --  members:
+	string tag_;
+EOF
+     
+     print "\tstring $xml_data\_;\n" unless $xml_data eq ''; 
+     foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        $to = "$to<$tpl> " unless $tpl eq "";
+        
+        if ( $magtype{$to}  )
+        { 
+            print "\t$magtype{$to} $member\_;\n";
+        }
+        elsif ( $basetype{$to} ) 
+        { 
+            print "\t$to $member\_;\n";
+        }
+        else 
+        {
+            print "\tauto_ptr<$to> $member\_;\n";  
+        }
+    }
+
+print <<EOF;   
+
+private:
+  
+	friend ostream& operator<<(ostream& s,const $class& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+EOF
+
+    if ( $template ne "" ) {
+        print "#include \"$object\Attributes.cc\" \n";
+    }
+    
+    print "\n#endif\n";
+ 
+    close STDOUT;
+    
+#####                Include file
+######################################################
+
+######################################################
+#####                Source file
+
+    open STDOUT, ">$location/$object\Attributes.cc";
+
+    print  <<EOF;
+/*******************************  LICENSE  *******************************
+
+ at license
+
+ *******************************  LICENSE  *******************************/
+
+/*! \\file $object\Attributes.cc
+    \\brief Implementation of $object Attributes class.
+    \\author Meteorological Visualisation Section, ECMWF
+
+    This file is automatically generated.
+    Do Not Edit!
+   
+    Generated: $string
+*/    
+
+#include "$object\Attributes.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+#include "XmlNode.h"
+#include "ParameterSettings.h"
+
+
+using namespace magics;
+
+EOF
+   $header = "";
+    $p = "";
+   if ( $template ne "" ) {
+        $header = "template <class $template>";
+        $p = "<P>";
+    }
+    
+    my $count = 0;
+    
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        next if $todo eq 'no';
+        next if $tpl  ne "";
+        $count++;
+    }
+    
+    my $subclass = ":";
+    $subclass = "" if $count eq 0; 
+    
+    print "$header\n$object\Attributes$p\::$object\Attributes()$subclass"; 
+    my $sep = ""; 
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $constant= $current->{parameter}->{$param}->{attributes}->{constant};
+        next if $tpl ne "";
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+      %xxx = {
+    "int" => "ParameterManager::getInt",
+    "float" => 1,
+    "string" => ParameterManager::getString,
+};
+        if ($constant eq "yes" ) 
+        {
+            if ($translator{$to} ne '') {
+                print "$sep\n\t$member\_($translator{$to}(\"$default\"))";
+            }
+            else {
+        	    print "$sep\n\t$member\_(MagTranslator<$from, $magto>().magics(\"$default\"))"; 
+            }
+        } 
+        else {
+           
+            if ($translator{$to} ne '') {
+                print "$sep\n\t$member\_($translator{$to}(\"$name\"))";
+            }
+            else {
+        	    print "$sep\n\t$member\_(MagTranslator<$from, $magto>().magics(\"$name\"))"; 
+            }
+        }
+		$sep = ",";
+    }
+	print "\n";
+    print <<EOF;
+{
+EOF
+   foreach  my $param (@{$current->{parameter_list}}) 
+    {   
+    	my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        next if $tpl eq "";
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $method = ucfirst $member;
+        
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+	
+        print "\tset$method(MagTranslator<string, $magto>()(\"$name\"));\n";
+   }
+   print <<EOF;
+} 
+
+
+$header
+$object\Attributes$p\::~$object\Attributes()
+{
+}
+
+$header    
+EOF
+	$val = 0;
+	my $code = "";
+	my $nb = $#prefixs+1;
+	
+	$code = "\tvector<string> prefix($nb);\n";
+	$j = 0;
+	for ($i = $nb; $i > 0; --$i) {		
+		$code = "$code\tprefix[$j] = \"@prefixs[$i-1]\";\n";
+		++$j;
+	}
+	$code = "$code\n";
+	
+	   
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $xml = $current->{parameter}->{$param}->{attributes}->{xml};
+        
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+     
+        my $method = ucfirst $member;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+        	
+        	if ( $basetype{$to} ) 
+            { 
+            	$code = "$code\tsetAttribute(prefix, \"$name\", $member\_, params);\n";          		
+            }
+            elsif ( $to eq 'Colour')   {
+            	$code = "$code\tsetAttribute(prefix, \"$name\", $member\_, params);\n" 
+            }
+            else {
+            	$code = "$code\tsetMember(prefix, \"$name\", $member\_, params);\n"   
+            }                     
+    }
+        
+ if ($code eq "") {
+ 	print "void $object\Attributes$p\::set(const std::map<string, string>&)\n{\n}\n";
+ }
+ else {
+ 	print "void $object\Attributes$p\::set(const std::map<string, string>& params)\n{\n";
+ 	print "$code}\n"
+ } 
+ 
+ 
+     
+ 
+
+        	
+print  <<EOF;
+$header
+void $object\Attributes$p\::copy(const $object\Attributes& other)
+{
+EOF
+
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $xml = $current->{parameter}->{$param}->{attributes}->{xml};
+         my $xml_data = $current->{attributes}->{xml_data};
+        $to = "$to<$tpl> " unless $tpl eq "";
+        my $magto = $to;
+        my $method = ucfirst $member;
+        $magto = $magtype{$to} if $magtype{$to};
+        $from = $magtype{$from} if $magtype{$from};
+        
+        if ( $basetype{$to} ) 
+        {         	
+             print "\t$member\_ = other.$member\_;\n"; 
+        }
+        else 
+        {
+           print "\t$member\_ = auto_ptr<$to>(other.$member\_->clone());\n";          
+        }
+       
+        print "";
+       
+        
+    }
+print  <<EOF;
+} 
+
+$header
+bool $object\Attributes$p\::accept(const string& node)
+{	
+EOF
+	print "\tif ( magCompare(node, \"$tag\")  )";
+	print "\n\t\treturn true;\n";
+	foreach  my $param (@{$current->{parameter_list}}) {
+    			my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+    			next if $todo eq 'no';
+    			my $to = $current->{parameter}->{$param}->{attributes}->{to};
+    			next if $basetype{$to};
+    			next if $classtype{$to};
+    			my $member = $current->{parameter}->{$param}->{attributes}->{member};
+    			my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+    			$to = "$to<$tpl> " unless $tpl eq "";
+    			my $magto = $to;
+        		my $method = ucfirst $member;
+        		$magto = $magtype{$to} if $magtype{$to};
+    			print "\n\tif ( acceptNode(node, $member\_) )\n";    
+    			print "\t\treturn true;\n";    			
+	}
+	
+print  <<EOF;
+	return false;
+}
+$header
+void $object\Attributes$p\::set(const XmlNode& node)
+{
+	if ( this->accept(node.name()) == false ) 
+		return;
+EOF
+	if ( $tag ne '') {
+		print "\n\tif ( magCompare(node.name(), \"$tag\") )";
+		print "\n\t\tset(node.attributes());";
+		print "\n\telse {";
+		foreach  my $param (@{$current->{parameter_list}}) {
+    			 my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+    			next if $todo eq 'no';
+    			my $to = $current->{parameter}->{$param}->{attributes}->{to};
+    			next if $basetype{$to};
+    			next if $classtype{$to};
+    			my $member = $current->{parameter}->{$param}->{attributes}->{member};
+    			my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+    			$to = "$to<$tpl> " unless $tpl eq "";
+    			my $magto = $to;
+        		my $method = ucfirst $member;
+        		$magto = $magtype{$to} if $magtype{$to};
+    			
+    			print "\n\t\tsetMember(node.name(), $member\_, node);";
+    			
+       
+    	}
+		print "\n\t}";
+	}
+	else {
+		print "\n\tset(node.attributes());";
+	}
+	
+	if ($xml_data ne '') {
+		print "\n\tfor (XmlNode::DataIterator data = node.firstData(); data != node.lastData(); ++data)\n";
+		print "\t\tsetXmlData(*data);\n";	
+	}
+	print "\n";
+	print "\tfor (XmlNode::ElementIterator elt = node.firstElement(); elt != node.lastElement(); ++elt) {\n";
+    		foreach  my $param (@{$current->{parameter_list}}) {
+    			 my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+    			next if $todo eq 'no';
+    			my $to = $current->{parameter}->{$param}->{attributes}->{to};
+    			next if $basetype{$to};
+    			next if $classtype{$to};
+    			my $member = $current->{parameter}->{$param}->{attributes}->{member};
+    			my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+    			$to = "$to<$tpl> " unless $tpl eq "";
+    			my $magto = $to;
+        		my $method = ucfirst $member;
+        		$magto = $magtype{$to} if $magtype{$to};
+    			
+    			print "\t\tsetMember((*elt)->name(), $member\_, *(*elt)); \n";
+    			
+       
+    	}
+    
+	
+
+print <<EOF; 		
+	}
+}
+$header
+void $object\Attributes$p\::print(ostream& out)  const
+{
+	out << "$object\Attributes[";
+EOF
+    $sep = "";
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+         my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+       
+       
+        $to = "$to<$tpl> " unless $tpl eq "";
+        $print = "$member\_";
+        $print = "*$member\_" unless  $basetype{$to} ;
+        
+        print "\tout << \"$sep$member = \" << $print;\n"; 
+        
+        $sep = ", ";
+        
+    }
+        
+    print "\tout << \"]\" << \"\\n\";\n";
+    print "}\n\n";
+
+     print <<EOF; 
+$header
+void $object\Attributes$p\::toxml(ostream& out)  const
+{
+     out <<  \"\\\"$tag\\\"\";
+EOF
+    
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {      
+         my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+       
+       
+        $to = "$to<$tpl> " unless $tpl eq "";
+        if ( $basetype{$to} ) 
+        {         	
+             print "\t out << \", \\\"$name\\\":\";\n";
+             print "\t niceprint(out,$member\_);\n";
+        }
+        elsif ( $classtype{$to}  )
+		{
+             print "\t out << \", \\\"$name\\\":\";\n";
+             print "\t niceprint(out, *$member\_);\n";
+		}
+		else 
+        {
+            print "\t out << \", \\\"$name\\\":\";\n";
+            print "\t $member\_->toxml(out);\n";       
+        }
+        
+        
+        
+    }
+    print "}\n";       
+    
+   
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {     
+         my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $migration = $current->{parameter}->{$param}->{migration}->{data};
+        $from = $magtype{$from} if $magtype{$from};
+        
+        
+        $default = "\"$default\"" if  $quote{$from} ;
+     
+        print <<EOF
+static MagicsParameter<$from> $name("$name", $default, "$migration");
+EOF
+        
+    }
+   
+ 
+        
+    
+       
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {     
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+       
+       
+        foreach  my $option (@{$current->{parameter}->{$param}->{option_list}}) { 
+        	my $include = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{include};
+        	my $template = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+        	my @templates = split("/", $template);
+        	foreach my $t (@templates) { 
+        		$includes_static->{$param}->{"$t.h"} = "$t.h";
+        	}
+        	$includes_static->{$param}->{$include} = $include unless $include eq "";
+        }
+       foreach  my $include (keys %{$includes_static->{$param}}) 
+    	{     
+        	print "#include \"$include\"\n";
+    	} 
+      
+        foreach  my $option (@{$current->{parameter}->{$param}->{option_list}}) { 
+        	my $class = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{name};
+        	my $include = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{include};
+        	my $fortran = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{fortran};
+        	my $template = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+        	my $xml = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{xml};
+        	my $base = $current->{parameter}->{$param}->{attributes}->{to};  
+        	my $templates = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+			my @fortrans = split("/", $fortran);
+        	if ($template eq "") {
+        		for my $o (@fortrans) {
+        			print "static SimpleObjectMaker<$class, $base> $o\_$class(\"$o\");\n" if $o ne "";
+        			print "static SimpleObjectMaker<$class, $base> $xml\_$class(\"$xml\");\n" if $xml ne "" && $xml ne $fortran;
+				}
+        	}
+        	else {
+        		my @templates = split("/", $template);	
+        		for my $t (@templates) {
+        			for my $o (@fortrans) {
+        				print "static SimpleObjectMaker<$class<$t>, $base<$t> > $o\_$class\_$t(\"$o\");\n" if $o ne "";
+        	        	print "static SimpleObjectMaker<$class<$t>, $base<$t> > $xml\_$class\_$t(\"$xml\");\n" if $xml ne "" && $xml ne $fortran;
+					}
+        		}
+        	}
+        }
+    }
+}
+
+
diff --git a/tools/xml2dtd.pl b/tools/xml2dtd.pl
new file mode 100644
index 0000000..ef1a0aa
--- /dev/null
+++ b/tools/xml2dtd.pl
@@ -0,0 +1,174 @@
+#!/usr/bin/perl
+
+
+use XML::Parser;
+use Data::Dumper;
+use Date::Calc;
+
+my $file = shift;
+my $Author="MagicsTeam";
+my $ecmwf="http://wms.ecmwf.int";
+my $info = {};
+my $element = {};
+
+
+my %basetype = (
+	"int" => 1,
+	"magint" => 1,
+	"double" => 1,
+	"float" => 1,
+	"magfloat" => 1,
+	"long" => 1,
+	"bool" => 1,
+    "string" => 1,
+    "magstring" => 1,
+    "FloatArray" =>1,
+    "magfloatarray" =>1,
+    "StringArray" => 1,
+    "IntArray" => 1,
+    "LineStyle" =>1,
+     "Hemisphere" =>1,
+    "Colour" =>1,
+);
+
+my %magtype = (
+	"int" => "magint",
+	"long" => "magint",
+	"float" => "magfloat",
+	"double" => "magfloat",
+    "string" => "magstring",
+    "FloatArray" => "magfloatarray",
+    "StringArray" => "magstringarray",
+    "IntArray" => "magintarray",
+);
+
+my %quote = (
+
+    "string" => 1,
+    "magstring" => 1,
+    
+);
+
+sub parse
+{
+    my $def = shift;
+    my $node = shift;   
+   
+    while ( defined ( $element = shift @{ $node } ) )
+    {
+       
+        my $child = shift @{ $node };
+        if ( ref $child )
+        {
+           my $attr = \%{ shift @{ $child } };
+           my $name = $attr->{name};
+           
+           if ($name ne "") 
+           {
+               
+               $def->{$element}->{$name} = {};
+               my $list = $element . "_list";
+               push( @{$def->{$list}}, $name);
+               foreach my $a (keys %{$attr}) 
+               {
+                   $def->{$element}->{$name}->{attributes}->{$a} = $attr->{$a}; 
+                  
+               }
+               parse($def->{$element}->{$name}, $child); 
+               
+           }
+           else
+           {
+                   $def->{$element} = {};
+                   foreach my $a (keys %{$attr}) 
+                   {
+                        $def->{$element}->{attributes}->{$a} = $attr->{$a};
+                       
+                   }
+                   parse($def->{$element}, $child); 
+           }
+        }
+        else 
+        {
+         
+          $def->{data} = $child;
+        }
+    }   
+}
+
+sub process
+{
+    my $current = shift;
+    
+    print " Found Class $current->{attributes}->{name}\n";
+    
+    foreach my $param (@{$current->{parameter_list}}) 
+    {   
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        print "    found param --->$param (To---> $to)\n";
+        print " $current->{parameter}->{$param}->{available}->{data}\n";
+        if  ( !$basetype{$to} )  {
+            print "    find subclasses! \n";
+            foreach my $available (@{$current->{parameter}->{$param}->{available_list}}) {
+                    print "      found available --->$available\n";
+                    process($info->{magics}->{class}->{$available});
+            }
+           
+        }
+    }
+    
+    my $objects = $current->{attributes}->{embedded_objects};
+    foreach my $subobject (split('/', $objects))
+    {   
+        print "    found subobject --->$subobject\n";
+        process($info->{magics}->{class}->{$subobject});
+        
+    
+    }
+    
+}
+
+sub element
+{
+    my $current = shift;
+    
+    
+    print " <!ELEMENT  $current->{attributes}->{name}";
+    my $sep = "(";
+    my $last = "";
+    
+    
+    {   
+        my $occurence = $current->{child}->{$child}->{attributes}->{occurence};
+        print "$sep$child$occurence";
+	$sep = ", ";
+	$last = ")";
+        
+    }
+    print "$last>\n";
+    
+}
+
+my $xml= new XML::Parser(Style=>"Tree");
+
+parse ($info, $xml->parsefile($file));
+print "<!DOCTYPE magics [\n";
+#foreach my $object (keys %{$info->{magics}->{xml_element}}) 
+foreach my $object (@{$info->{magics}->{xml_element_list}}) 
+{
+  
+   element($info->{magics}->{xml_element}->{$object});
+ 
+}
+print "]\n"; 
+
+foreach my $object (keys %{$info->{magics}->{class}}) 
+{
+   
+    process($info->{magics}->{class}->{$object});
+}
+        
+   
+
+
+
diff --git a/tools/xml2mv.pl b/tools/xml2mv.pl
new file mode 100644
index 0000000..d3516b4
--- /dev/null
+++ b/tools/xml2mv.pl
@@ -0,0 +1,563 @@
+#!/usr/bin/perl
+
+
+use XML::Parser;
+use Data::Dumper;
+
+use Time::localtime;
+
+my $file = shift;
+my $dir = shift;
+my $Author="MagicsTeam";
+my $ecmwf="http://wms.ecmwf.int";
+my $info = {};
+my $element = {};
+
+
+my %basetype = (
+    "int" => 1,
+    "float" => 1,
+    "bool" => 1,
+    "string" => 1,  
+    "Colour" => 1,  
+    "floatarray" =>1,
+    "stringarray" => 1,
+     "stringarray" => 1,
+    "intarray" => 1, 
+    "LineStyle" =>1,
+    "Hemisphere" =>1,
+    "ArrowPosition" => 1,
+    "ListPolicy" => 1,
+    "Justification" => 1,
+    "AxisAutomaticSetting" => 1,
+    "OpenGLDriverObserverPtr" => 1,
+    "Widget" =>1,
+    "QWidget*" =>1, 
+    "cairo_t*" =>1, 
+    "Matrix" => 1,
+    "GribHandlePtr" =>1,
+    "Path" =>1
+);
+
+my %arraytype = (
+	"doublearray" => "atof(data)",
+	"stringarray" => "data",
+	"intarray" => "atoi(data)",
+);
+
+my %pointertype = {
+	"Colour" => "1"
+};
+
+my %quote = (
+    "string" => 1,    
+);
+
+my %type = (
+    "float" => "double",    
+);
+
+sub parse
+{
+    my $def = shift;
+    my $node = shift;   
+   
+    while ( defined ( $element = shift @{ $node } ) )
+    {
+       
+        my $child = shift @{ $node };
+        if ( ref $child )
+        {
+           my $attr = \%{ shift @{ $child } };
+           my $name = $attr->{name};
+           
+           if ($name ne "") 
+           {
+               
+               $def->{$element}->{$name} = {};
+               my $list = $element . "_list";
+               push( @{$def->{$list}}, $name);
+               foreach my $a (keys %{$attr}) 
+               {
+                   $def->{$element}->{$name}->{attributes}->{$a} = $attr->{$a}; 
+                  
+               }
+               parse($def->{$element}->{$name}, $child); 
+               
+           }
+           else
+           {
+                   $def->{$element} = {};
+                   foreach my $a (keys %{$attr}) 
+                   {
+                        $def->{$element}->{attributes}->{$a} = $attr->{$a};
+                       
+                   }
+                   parse($def->{$element}, $child); 
+           }
+        }
+        else 
+        {
+         
+          $def->{data} = $child;
+        }
+    }   
+}
+
+
+
+
+
+my $xml= new XML::Parser(Style=>"Tree");
+  
+parse ($info, $xml->parsefile($file));
+
+
+
+
+
+foreach my $object (keys %{$info->{magics}->{class}}) 
+{
+   
+    $current = $info->{magics}->{class}->{$object};
+    $directory = $info->{magics}->{class}->{$object}->{attributes}->{directory};
+    my $include_file = $info->{magics}->{class}->{$object}->{attributes}->{include};
+    my $inherit = $info->{magics}->{class}->{$object}->{attributes}->{inherit};
+
+######################################################
+#####                Include file
+
+  
+
+    open STDOUT, ">$dir/$object\Wrapper.h";
+    
+    my $string =  ctime();
+    
+    $include_file = "$object.h" if  $include_file eq '';
+    print  <<EOF;
+
+/*! \\file $object\Wrapper.h
+    \\brief Wrapper for Metview Request
+    Automatically generated on $string
+    Do Not Edit!
+    
+    Magics Team - ECMWF 2004
+   
+    Created: $string
+    
+*/
+   
+
+#ifndef $object\Wrapper_H
+#define $object\Wrapper_H
+
+#include "magics.h"
+#include "ParameterManager.h"
+#include "Factory.h"
+
+#include "$include_file"
+
+EOF
+my $includes = {};
+    my $member = lc $object;
+    my $impl=$current->{attributes}->{inherits};
+    my $abstract=$current->{attributes}->{abstract};
+    
+    print "#include \"$impl\Wrapper.h\"\n" if $impl ne ''; 
+    my $parent ='';
+    $parent=": public $impl\Wrapper" if $impl ne ''; 
+    
+    
+    foreach my $param (@{$current->{parameter_list}}) 
+    {   
+       my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+       next if $todo eq 'no';
+       my $mv = $current->{parameter}->{$param}->{attributes}->{metview};
+       next if $mv eq 'no';
+       my $to = $current->{parameter}->{$param}->{attributes}->{to};
+     
+       $includes->{$to} = "find" unless $basetype{$to} || $to eq 'Colour' ;
+    }
+    
+    foreach my $include (keys %{$includes} ) 
+    {
+          print "#include \"$include\Wrapper.h\"\n"; 
+    }
+    
+    print "\n";
+  
+    
+    my $template = $current->{attributes}->{template};
+    my $inherits_template = $current->{attributes}->{inherits_template};
+    my $class = "$object\Wrapper";
+    my $line = "";
+    $object_t = "$object";
+    if ( $template ne "" ) {
+        $line = "template <class $template>";
+        $class = "$object\Wrapper<$template>";
+        $object_t = "$object<P>";
+        $parent = "$parent<P>" unless  $parent eq "";
+    }
+    
+    print <<EOF;
+
+
+
+namespace magics {
+
+class MagRequest;
+$line
+class $object\Wrapper $parent
+{
+public:
+//  --  constructor
+    $object\Wrapper();
+    $object\Wrapper($object_t*);
+//  --  destructor
+    virtual ~$object\Wrapper();
+    
+    virtual void set(const MagRequest&);
+EOF
+
+if ($impl eq '') {
+print <<EOF; 
+    void object($object_t* $member) 
+    	{ delete $member\_; $member\_ = $member; }
+    $object_t* object()   { return $member\_; }
+ 
+protected:
+    $object_t* $member\_;
+
+EOF
+}
+
+else {
+print <<EOF; 
+    $object_t* me() { return $member\_; }
+  
+protected:
+    $object_t* $member\_;
+EOF
+}
+
+
+print <<EOF;  
+
+//  --  method
+	virtual void print(ostream&) const;
+	//virtual void toxml(ostream& out, int tabs = 0) const { toxml(out, tag_, tabs); }
+	//virtual void toxml(ostream&, const string&, int tabs) const;
+	
+
+
+private:
+    string tag_;
+	friend ostream& operator<<(ostream& s,const $class& p)
+	{ p.print(s); return s; }
+};
+
+} // namespace magics
+EOF
+
+    if ( $template ne "" ) {
+        print "#include \"$object\Wrapper.cc\" \n";
+    }
+    
+    print "\n#endif\n";
+ 
+    close STDOUT;
+    
+#####                Include file
+######################################################
+
+######################################################
+#####                Source file
+
+    open STDOUT, ">$dir/$object\Wrapper.cc";
+    
+ 
+    print  <<EOF;
+/*! \\file $object\Wrapper.h
+    \\brief Implemtation of $object Wrapper class.
+    Automatically generated on $string
+    Do Not Edit!
+    
+    Magics Team - ECMWF 2004
+   
+    Created: $string
+    
+*/    
+
+#include "MagRequest.h" 
+#include "$object\Wrapper.h"
+#include "MagicsParameter.h"
+#include "Factory.h"
+#include "MagTranslator.h"
+
+using namespace magics;
+
+EOF
+   $header = "";
+   $p = "";
+   $ip = "";
+   
+   $ip = "<P>" if $inherits_template ne "";
+   if ( $template ne "" ) {
+        $header = "template <class $template>";
+        $p = "<P>";
+    }
+    my $var = lc "$object";
+    $member = lc "$object\_";
+   
+my $creator = '0';
+$creator="new $object_t()" if $abstract ne 'yes'; 
+if ($impl eq '') {
+	
+print <<EOF;
+$header\n$object\Wrapper$p\::$object\Wrapper(): $member($creator)
+{
+}
+
+$header\n$object\Wrapper$p\::$object\Wrapper($object_t* $var): $member($var)
+{
+}
+
+EOF
+}
+else {
+	
+print <<EOF;
+$header\n$object\Wrapper$p\::$object\Wrapper(): $impl\Wrapper$ip($creator)
+{
+	$member = static_cast<$object$p*>(this->object());
+}
+
+$header\n$object\Wrapper$p\::$object\Wrapper($object_t* $var): $impl\Wrapper$ip($var)
+{
+	$member = static_cast<$object$p*>(this->object());
+}
+EOF
+}
+
+print <<EOF;
+
+$header
+$object\Wrapper$p\::~$object\Wrapper()
+{
+}
+
+$header
+void $object\Wrapper$p\::set(const MagRequest& request)
+{
+EOF
+	my $impl=$current->{attributes}->{inherits};
+
+	print "\t$impl\Wrapper$p\::set(request);\n" unless $impl eq "";
+
+	$val = 0;
+	my $wrapper = lc $object;
+
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        my $mv = $current->{parameter}->{$param}->{attributes}->{metview};
+        next if $mv eq 'no';
+        my $name = $current->{parameter}->{$param}->{attributes}->{name};
+	my $pre = $current->{attributes}->{metview_prefix};
+	$name =~ s/$pre//;
+        my $default = $current->{parameter}->{$param}->{attributes}->{default};
+        my $mv_default = $default;
+        $mv_default = $current->{parameter}->{$param}->{attributes}->{metview_default} if $current->{parameter}->{$param}->{attributes}->{metview_default} ne "";
+        my $member = $current->{parameter}->{$param}->{attributes}->{member};
+        my $from = $current->{parameter}->{$param}->{attributes}->{from};
+        my $to = $current->{parameter}->{$param}->{attributes}->{to};
+        my $tpl = $current->{parameter}->{$param}->{attributes}->{template};
+        my $xml = $current->{parameter}->{$param}->{attributes}->{xml};
+        my $wrapper_t = "$to\Wrapper";
+
+        $wrapper_t = "$to\Wrapper<$tpl> " unless $tpl eq "";
+
+        $attr_t = "<$tpl>" unless $tpl eq "";;
+        $to = "$to<$tpl> " unless $tpl eq "";
+
+
+        my $magto = $to;
+        my $method = ucfirst $member;
+        $magto = $magtype{$to} if $magtype{$to};
+        $magto = "double" if $magto eq "float";
+        $from = $magtype{$from} if $magtype{$from};
+	
+	
+        $name = uc $name;
+	
+        my %simpletype = (
+	        "Path" =>1,
+	        "LineStyle" => 1,
+    		"AxisAutomaticSetting" => 1,
+            "ArrowPosition" =>1, 
+	        "Justification" => 1,
+            "ListPolicy" => 1,
+            "stringarray" =>1,
+            "bool" =>1,
+            "Hemisphere"=>1,
+	    );
+
+	    my %arraytype = (
+	    	"floatarray" => "(double)",
+	    	"stringarray" => "(string)",
+	    	"intarray" => "(int)",
+    	);
+	    my %pointertype = (
+	    	"Colour" => "1",
+	    	"Path" => "1",
+		);
+	    if ( $arraytype{$to} ) 
+	    {
+	    	print "\t\t$to $member;\n";
+	    	print "\t\tfor (int i = 0; i < request.countValues(\"$name\"); i++)\n";	
+	    	print "\t\t\t$member.push_back($arraytype{$to}request(\"$name\", i));\n";
+	    	print "\t\tif ( !$member.empty() ) \n";
+	    	print "\t\t\t$wrapper\_->$member\_ = $member;\n";
+	    }
+        elsif ( $basetype{$to} ) 
+        {
+            if ( $default eq $mv_default ) 
+            {             
+                print "\t\t if  (request.countValues(\"$name\") ) {\n";
+            if ( $simpletype{$magto} ) 
+            {
+                print "\t\t\tstring $member\_s = request(\"$name\");\n";
+                print "\t\t\t$wrapper\_->$member\_ = MagTranslator<string, $magto>()($member\_s);\n";
+            }
+            elsif ( $pointertype{$magto} ) 
+            {
+				
+                print "\t\t\tstring $member\_s = request(\"$name\");\n";
+                print "\t\t\t$wrapper\_->$member\_ = auto_ptr<$magto>(MagTranslator<string, $magto>()($member\_s));\n";
+            }
+            else
+            {
+        		if ( $quote{$magto} ) {
+        			print "\t\t\t$magto $member(request(\"$name\"));\n";
+        		}
+        		else {
+        			print "\t\t\t$magto $member = request(\"$name\");\n"; 
+        		}
+                print "\t\t\t$wrapper\_->$member\_ = $member;\n";
+            }
+            print "\t\t}\n\n";
+            }
+            else {
+                 if ( $simpletype{$magto} ) 
+            {
+                 $arg = "(request.countValues(\"$name\") ? (string) request(\"$name\") : \"$mv_default\")";
+                
+                print "\t\tstring $member\_s = $arg;\n";
+                print "\t\t$wrapper\_->$member\_ = (MagTranslator<string, $magto>()($member\_s));\n\n";
+            }
+                 elsif ( $pointertype{$magto} ) 
+            {
+                 $arg = "(request.countValues(\"$name\") ? (string) request(\"$name\") : \"$mv_default\")";
+                
+                print "\t\tstring $member\_s = $arg;\n";
+                print "\t\t$wrapper\_->$member\_ = auto_ptr<$magto>(MagTranslator<string, $magto>()($member\_s));\n\n";
+			}
+            else
+            {
+        		if ( $quote{$magto} ) {
+                 $arg = "(request.countValues(\"$name\") ? (string) request(\"$name\") : \"$mv_default\")";
+        	  		print "\t\t$magto $member($arg);\n";
+        		}
+        		else {
+                 $arg = "(request.countValues(\"$name\") ? request(\"$name\") : $mv_default)";
+        			print "\t\t$magto $member = $arg;\n"; 
+        		}
+                print "\t\t$wrapper\_->$member\_ = $member;\n\n";
+            }
+            }
+           
+            
+         }
+         else {
+         	    print "\t\tstring $member\_s = request.countValues(\"$name\") ?  (string) request(\"$name\") : \"$mv_default\";\n";
+         	    print "\t\tMagLog::dev() << \" $name set to \" << $member\_s << endl;\n";
+         	   	print "\t\t$wrapper_t* $member\_w = 0;\n";
+                print "#ifdef MAGICS_EXCEPTION\n";
+                print "\t\ttry\n";
+                print "#endif\n";
+                print "\t\t{\n";
+                print "\t\t\t$member\_w = SimpleFactory<$wrapper_t>::create($member\_s);\n";
+                print "\t\t}\n";
+                print "#ifdef MAGICS_EXCEPTION\n";
+                print "\t\t catch (NoFactoryException) {\n"; 
+                print "#else\n";
+                print "\t\t if (!$member\_w) {\n"; 
+                print "#endif\n";
+                print "\t\t\tMagLog::warning() << \"[\" << $member\_s << \"] is not a valid value for $name: reset to default -> [$mv_default]\" << endl;\n";
+                print "\t\t\t$member\_w = SimpleFactory<$wrapper_t>::create(\"$mv_default\");\n";
+			    print "\t\t}\n";
+                print "\t\t$member\_w->set(request);\n";
+                print "\t\t$wrapper\_->$member\_ =  auto_ptr<$magto>($member\_w->object());\n";
+                print "\t\tdelete $member\_w;\n\n";
+         }
+    }
+    
+print <<EOF;
+}
+
+$header
+void $object\Wrapper$p\::print(ostream& out)  const
+{
+	out << "$object\Wrapper[]";
+}
+
+EOF
+
+    foreach  my $param (@{$current->{parameter_list}}) 
+    {
+        my $todo = $current->{parameter}->{$param}->{attributes}->{implemented};
+        next if $todo eq 'no';
+        foreach  my $option (@{$current->{parameter}->{$param}->{option_list}}) { 
+        	my $class = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{name};
+        	my $include = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{include};
+        	my $fortran = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{fortran};
+        	my $xml = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{xml};
+        	my $base = $current->{parameter}->{$param}->{attributes}->{to};
+            my @fortrans = split("/", $fortran);
+        	my $template = $current->{parameter}->{$param}->{option}->{$option}->{attributes}->{template};
+        	if ($template eq "") {
+              if ( $class eq  $base) {
+                for my $o (@fortrans) {
+                    print "\nstatic SimpleObjectMaker<$base\Wrapper> $object\_$o\_$class\_w(\"$o\");\n" if $o ne "";
+        	    }  
+              }
+              else {
+                print "\n#include \"$class\Wrapper.h\"\n";  
+                for my $o (@fortrans) { 	
+        	        print "static SimpleObjectMaker<$class\Wrapper, $base\Wrapper> $object\_$o\_$class\_w(\"$o\");\n" if $o ne "";
+                }
+                if ($xml ne "") {
+                    if ($xml ne $fortran) {
+                        print "static SimpleObjectMaker<$class\Wrapper, $base\Wrapper> $object\_$xml\_$class\_w(\"$xml\");\n";
+                    }
+                }
+        	  }
+        	}
+        	else {
+        		my @templates = split("/", $template);	
+        		print "\n#include \"$class\Wrapper.h\"\n";
+
+        		for my $t (@templates) {
+        		  print "\n#include \"$t.h\"\n";  
+        		  if ( $class eq  $base) {
+                	print "static SimpleObjectMaker<$base\Wrapper<$t> > $object\_$fortran\_$class\_$t\_w(\"$fortran\");\n" if $fortran ne "";
+        	      }
+                  else {
+        	        print "static SimpleObjectMaker<$class\Wrapper<$t>, $base\Wrapper<$t> > $object\_$fortran\_$class\_$t\_w(\"$fortran\");\n" if $fortran ne "";
+        	      }
+        		}
+        	}
+        }
+    }
+}
diff --git a/version.sh b/version.sh
new file mode 100644
index 0000000..3baea24
--- /dev/null
+++ b/version.sh
@@ -0,0 +1,32 @@
+#
+# Package name and versioning information for Magics
+#
+MAGICS_PACKAGE_NAME='Magics'
+MAGICS_PACKAGE_VERSION='2.18.7'
+MAGICS_PACKAGE_COPYRIGHT_YEAR='2012'
+MAGICS_PACKAGE_COPYRIGHT_PERIOD='2007-2012'
+MAGICS_PACKAGE_RELEASE_DATE=`date +%d-%B-%Y`
+#
+#
+# Libtool library revision control info
+# See the libtool documentation under the heading "Libtool's versioning
+# system" in order to understand the meaning of these fields
+#
+# Here are a set of rules to help you update your library version
+# information:
+#
+#  1. Start with version information of `0:0:0' for each libtool library.
+#  2. Update the version information only immediately before a public
+#     release of your software. More frequent updates are unnecessary, and
+#     only guarantee that the current interface number gets larger faster.
+#  3. If the library source code has changed at all since the last update,
+#     then increment revision (`c:r:a' becomes `c:r+1:a').
+#  4. If any interfaces have been added, removed, or changed since the last
+#     update, increment current, and set revision to 0.
+#  5. If any interfaces have been added since the last public release, then
+#     increment age.
+#  6. If any interfaces have been removed since the last public release,
+#     then set age to 0.
+MAGICS_LIBRARY_CURRENT=3
+MAGICS_LIBRARY_REVISION=0
+MAGICS_LIBRARY_AGE=0

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/magics.git



More information about the debian-science-commits mailing list